[
  {
    "path": "README.md",
    "content": "# RfTPM: A Firmware TPM Implementation for RISC-V\n\nRfTPM is the first firmware TPM (fTPM) architecture designed for RISC-V platforms. It provides secure TPM functionalities, including isolated execution, secure storage, secure boot, and remote attestation, without requiring additional hardware costs. \n\n## Features\n- **Firmware TPM for RISC-V**: Implements TPM functionalities without dedicated hardware.\n- **Isolated Execution**: Runs as an OpenSBI extension in machine mode (M-mode) on RISC-V.\n- **Secure Storage**: Ensures the integrity and confidentiality of TPM persistent data.\n- **Efficient Communication**: Securely interacts with higher-level TPM applications.\n\n## Build and Installation\n### Prerequisites\nEnsure that your environment includes:\n- A RISC-V toolchain\n- QEMU or a real RISC-V platform for testing\n\n### Building and Installing\n#### 1. Set Up Environment Variables\nBefore compiling, define the necessary paths:\n```sh\nexport BUILD_DIR=/path/to/build-linux-stable-host\nexport FTPM_DIR=/path/to/rfTPM\nexport RISCV_TOOLCHAIN=/opt/riscv/bin\n```\n#### 2. Compile libcryptomini\n```sh\nmake\n```\n#### 3. Compile ftpm-opensbi\n```sh\nmake CROSS_COMPILE=$RISCV_TOOLCHAIN/riscv64-unknown-elf- \\\n     PLATFORM=generic \\\n     FW_PAYLOAD_PATH=$BUILD_DIR/arch/riscv/boot/Image \\\n     FW_PAYLOAD=y \\\n     PLATFORM_RISCV_XLEN=64 \\\n     PLATFORM_RISCV_ISA=rv64imafdc \\\n     PLATFORM_RISCV_ABI=lp64d\n```\n#### 4. Compile ftpm-driver\n```sh\nmake -C $BUILD_DIR \\\n     O=$BUILD_DIR \\\n     ARCH=riscv \\\n     CROSS_COMPILE=$RISCV_TOOLCHAIN/riscv64-unknown-linux-gnu- \\\n     M=$FTPM_DIR/ftpm-driver modules\n```\n#### 5. Compile ibmtss-ftpm\n```sh\nmake -f makefiletpm20\n```\n\n\n"
  },
  {
    "path": "cryptomini/.vscode/settings.json",
    "content": "{\n    \"files.associations\": {\n        \"intercept.h\": \"c\"\n    }\n}"
  },
  {
    "path": "cryptomini/README.md",
    "content": "# CRYPTOMINI\n\npruned libcrypto for vTPM on RISC-V\n"
  },
  {
    "path": "cryptomini/aes/aes_cbc.c",
    "content": "/*\n * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the Apache License 2.0 (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * AES low level APIs are deprecated for public use, but still ok for internal\n * use where we're using them to implement the higher level EVP interface, as is\n * the case here.\n */\n// #include \"internal/deprecated.h\"\n\n#include <string.h>\n#include <openssl/aes.h>\n#include <openssl/modes.h>\n\n\nvoid CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block)\n{\n    size_t n;\n    const unsigned char *iv = ivec;\n\n    if (len == 0)\n        return;\n\n// #if !defined(OPENSSL_SMALL_FOOTPRINT)\n//     if (STRICT_ALIGNMENT &&\n//         ((size_t)in | (size_t)out | (size_t)ivec) % sizeof(size_t) != 0) {\n//         while (len >= 16) {\n//             for (n = 0; n < 16; ++n)\n//                 out[n] = in[n] ^ iv[n];\n//             (*block) (out, out, key);\n//             iv = out;\n//             len -= 16;\n//             in += 16;\n//             out += 16;\n//         }\n//     } else {\n//         while (len >= 16) {\n//             for (n = 0; n < 16; n += sizeof(size_t))\n//                 *(size_t_aX *)(out + n) =\n//                     *(size_t_aX *)(in + n) ^ *(size_t_aX *)(iv + n);\n//             (*block) (out, out, key);\n//             iv = out;\n//             len -= 16;\n//             in += 16;\n//             out += 16;\n//         }\n//     }\n// #endif\n    while (len) {\n        for (n = 0; n < 16 && n < len; ++n)\n            out[n] = in[n] ^ iv[n];\n        for (; n < 16; ++n)\n            out[n] = iv[n];\n        (*block) (out, out, key);\n        iv = out;\n        if (len <= 16)\n            break;\n        len -= 16;\n        in += 16;\n        out += 16;\n    }\n    if (ivec != iv)\n        memcpy(ivec, iv, 16);\n}\n\nvoid CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block)\n{\n    size_t n;\n    union {\n        size_t t[16 / sizeof(size_t)];\n        unsigned char c[16];\n    } tmp;\n\n    if (len == 0)\n        return;\n\n// #if !defined(OPENSSL_SMALL_FOOTPRINT)\n//     if (in != out) {\n//         const unsigned char *iv = ivec;\n\n//         if (STRICT_ALIGNMENT &&\n//             ((size_t)in | (size_t)out | (size_t)ivec) % sizeof(size_t) != 0) {\n//             while (len >= 16) {\n//                 (*block) (in, out, key);\n//                 for (n = 0; n < 16; ++n)\n//                     out[n] ^= iv[n];\n//                 iv = in;\n//                 len -= 16;\n//                 in += 16;\n//                 out += 16;\n//             }\n//         } else if (16 % sizeof(size_t) == 0) { /* always true */\n//             while (len >= 16) {\n//                 size_t_aX *out_t = (size_t_aX *)out;\n//                 size_t_aX *iv_t = (size_t_aX *)iv;\n\n//                 (*block) (in, out, key);\n//                 for (n = 0; n < 16 / sizeof(size_t); n++)\n//                     out_t[n] ^= iv_t[n];\n//                 iv = in;\n//                 len -= 16;\n//                 in += 16;\n//                 out += 16;\n//             }\n//         }\n//         if (ivec != iv)\n//             memcpy(ivec, iv, 16);\n//     } else {\n//         if (STRICT_ALIGNMENT &&\n//             ((size_t)in | (size_t)out | (size_t)ivec) % sizeof(size_t) != 0) {\n//             unsigned char c;\n//             while (len >= 16) {\n//                 (*block) (in, tmp.c, key);\n//                 for (n = 0; n < 16; ++n) {\n//                     c = in[n];\n//                     out[n] = tmp.c[n] ^ ivec[n];\n//                     ivec[n] = c;\n//                 }\n//                 len -= 16;\n//                 in += 16;\n//                 out += 16;\n//             }\n//         } else if (16 % sizeof(size_t) == 0) { /* always true */\n//             while (len >= 16) {\n//                 size_t c;\n//                 size_t_aX *out_t = (size_t_aX *)out;\n//                 size_t_aX *ivec_t = (size_t_aX *)ivec;\n//                 const size_t_aX *in_t = (const size_t_aX *)in;\n\n//                 (*block) (in, tmp.c, key);\n//                 for (n = 0; n < 16 / sizeof(size_t); n++) {\n//                     c = in_t[n];\n//                     out_t[n] = tmp.t[n] ^ ivec_t[n];\n//                     ivec_t[n] = c;\n//                 }\n//                 len -= 16;\n//                 in += 16;\n//                 out += 16;\n//             }\n//         }\n//     }\n// #endif\n    while (len) {\n        unsigned char c;\n        (*block) (in, tmp.c, key);\n        for (n = 0; n < 16 && n < len; ++n) {\n            c = in[n];\n            out[n] = tmp.c[n] ^ ivec[n];\n            ivec[n] = c;\n        }\n        if (len <= 16) {\n            for (; n < 16; ++n)\n                ivec[n] = in[n];\n            break;\n        }\n        len -= 16;\n        in += 16;\n        out += 16;\n    }\n}\n\n\nvoid AES_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t len, const AES_KEY *key,\n                     unsigned char *ivec, const int enc)\n{\n\n    if (enc)\n        CRYPTO_cbc128_encrypt(in, out, len, key, ivec,\n                              (block128_f) AES_encrypt);\n    else\n        CRYPTO_cbc128_decrypt(in, out, len, key, ivec,\n                              (block128_f) AES_decrypt);\n}\n"
  },
  {
    "path": "cryptomini/aes/aes_core.c",
    "content": "/*\n * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/**\n * rijndael-alg-fst.c\n *\n * @version 3.0 (December 2000)\n *\n * Optimised ANSI C code for the Rijndael cipher (now AES)\n *\n * @author Vincent Rijmen\n * @author Antoon Bosselaers\n * @author Paulo Barreto\n *\n * This code is hereby placed in the public domain.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS\n * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/* Note: rewritten a little bit to provide error control and an OpenSSL-\n   compatible API */\n\n#include <assert.h>\n\n#include <stdlib.h>\n#include <openssl/crypto.h>\n#include <openssl/aes.h>\n#include \"aes_local.h\"\n\n#if defined(OPENSSL_AES_CONST_TIME) && !defined(AES_ASM)\ntypedef union {\n    unsigned char b[8];\n    u32 w[2];\n    u64 d;\n} uni;\n\n/*\n * Compute w := (w * x) mod (x^8 + x^4 + x^3 + x^1 + 1)\n * Therefore the name \"xtime\".\n */\nstatic void XtimeWord(u32 *w)\n{\n    u32 a, b;\n\n    a = *w;\n    b = a & 0x80808080u;\n    a ^= b;\n    b -= b >> 7;\n    b &= 0x1B1B1B1Bu;\n    b ^= a << 1;\n    *w = b;\n}\n\nstatic void XtimeLong(u64 *w)\n{\n    u64 a, b;\n\n    a = *w;\n    b = a & 0x8080808080808080uLL;\n    a ^= b;\n    b -= b >> 7;\n    b &= 0x1B1B1B1B1B1B1B1BuLL;\n    b ^= a << 1;\n    *w = b;\n}\n\n/*\n * This computes w := S * w ^ -1 + c, where c = {01100011}.\n * Instead of using GF(2^8) mod (x^8+x^4+x^3+x+1} we do the inversion\n * in GF(GF(GF(2^2)^2)^2) mod (X^2+X+8)\n * and GF(GF(2^2)^2) mod (X^2+X+2)\n * and GF(2^2) mod (X^2+X+1)\n * The first part of the algorithm below transfers the coordinates\n * {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80} =>\n * {1,Y,Y^2,Y^3,Y^4,Y^5,Y^6,Y^7} with Y=0x41:\n * {0x01,0x41,0x66,0x6c,0x56,0x9a,0x58,0xc4}\n * The last part undoes the coordinate transfer and the final affine\n * transformation S:\n * b[i] = b[i] + b[(i+4)%8] + b[(i+5)%8] + b[(i+6)%8] + b[(i+7)%8] + c[i]\n * in one step.\n * The multiplication in GF(2^2^2^2) is done in ordinary coords:\n * A = (a0*1 + a1*x^4)\n * B = (b0*1 + b1*x^4)\n * AB = ((a0*b0 + 8*a1*b1)*1 + (a1*b0 + (a0+a1)*b1)*x^4)\n * When A = (a0,a1) is given we want to solve AB = 1:\n * (a) 1 = a0*b0 + 8*a1*b1\n * (b) 0 = a1*b0 + (a0+a1)*b1\n * => multiply (a) by a1 and (b) by a0\n * (c) a1 = a1*a0*b0 + (8*a1*a1)*b1\n * (d) 0 = a1*a0*b0 + (a0*a0+a1*a0)*b1\n * => add (c) + (d)\n * (e) a1 = (a0*a0 + a1*a0 + 8*a1*a1)*b1\n * => therefore\n * b1 = (a0*a0 + a1*a0 + 8*a1*a1)^-1 * a1\n * => and adding (a1*b0) to (b) we get\n * (f) a1*b0 = (a0+a1)*b1\n * => therefore\n * b0 = (a0*a0 + a1*a0 + 8*a1*a1)^-1 * (a0+a1)\n * Note this formula also works for the case\n * (a0+a1)*a0 + 8*a1*a1 = 0\n * if the inverse element for 0^-1 is mapped to 0.\n * Repeat the same for GF(2^2^2) and GF(2^2).\n * We get the following algorithm:\n * inv8(a0,a1):\n *   x0 = a0^a1\n *   [y0,y1] = mul4([x0,a1],[a0,a1]); (*)\n *   y1 = mul4(8,y1);\n *   t = inv4(y0^y1);\n *   [b0,b1] = mul4([x0,a1],[t,t]); (*)\n *   return [b0,b1];\n * The non-linear multiplies (*) can be done in parallel at no extra cost.\n */\nstatic void SubWord(u32 *w)\n{\n    u32 x, y, a1, a2, a3, a4, a5, a6;\n\n    x = *w;\n    y = ((x & 0xFEFEFEFEu) >> 1) | ((x & 0x01010101u) << 7);\n    x &= 0xDDDDDDDDu;\n    x ^= y & 0x57575757u;\n    y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7);\n    x ^= y & 0x1C1C1C1Cu;\n    y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7);\n    x ^= y & 0x4A4A4A4Au;\n    y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7);\n    x ^= y & 0x42424242u;\n    y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7);\n    x ^= y & 0x64646464u;\n    y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7);\n    x ^= y & 0xE0E0E0E0u;\n    a1 = x;\n    a1 ^= (x & 0xF0F0F0F0u) >> 4;\n    a2 = ((x & 0xCCCCCCCCu) >> 2) | ((x & 0x33333333u) << 2);\n    a3 = x & a1;\n    a3 ^= (a3 & 0xAAAAAAAAu) >> 1;\n    a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAu;\n    a4 = a2 & a1;\n    a4 ^= (a4 & 0xAAAAAAAAu) >> 1;\n    a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAu;\n    a5 = (a3 & 0xCCCCCCCCu) >> 2;\n    a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCu;\n    a4 = a5 & 0x22222222u;\n    a4 |= a4 >> 1;\n    a4 ^= (a5 << 1) & 0x22222222u;\n    a3 ^= a4;\n    a5 = a3 & 0xA0A0A0A0u;\n    a5 |= a5 >> 1;\n    a5 ^= (a3 << 1) & 0xA0A0A0A0u;\n    a4 = a5 & 0xC0C0C0C0u;\n    a6 = a4 >> 2;\n    a4 ^= (a5 << 2) & 0xC0C0C0C0u;\n    a5 = a6 & 0x20202020u;\n    a5 |= a5 >> 1;\n    a5 ^= (a6 << 1) & 0x20202020u;\n    a4 |= a5;\n    a3 ^= a4 >> 4;\n    a3 &= 0x0F0F0F0Fu;\n    a2 = a3;\n    a2 ^= (a3 & 0x0C0C0C0Cu) >> 2;\n    a4 = a3 & a2;\n    a4 ^= (a4 & 0x0A0A0A0A0Au) >> 1;\n    a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0Au;\n    a5 = a4 & 0x08080808u;\n    a5 |= a5 >> 1;\n    a5 ^= (a4 << 1) & 0x08080808u;\n    a4 ^= a5 >> 2;\n    a4 &= 0x03030303u;\n    a4 ^= (a4 & 0x02020202u) >> 1;\n    a4 |= a4 << 2;\n    a3 = a2 & a4;\n    a3 ^= (a3 & 0x0A0A0A0Au) >> 1;\n    a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0Au;\n    a3 |= a3 << 4;\n    a2 = ((a1 & 0xCCCCCCCCu) >> 2) | ((a1 & 0x33333333u) << 2);\n    x = a1 & a3;\n    x ^= (x & 0xAAAAAAAAu) >> 1;\n    x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAu;\n    a4 = a2 & a3;\n    a4 ^= (a4 & 0xAAAAAAAAu) >> 1;\n    a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAu;\n    a5 = (x & 0xCCCCCCCCu) >> 2;\n    x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCu;\n    a4 = a5 & 0x22222222u;\n    a4 |= a4 >> 1;\n    a4 ^= (a5 << 1) & 0x22222222u;\n    x ^= a4;\n    y = ((x & 0xFEFEFEFEu) >> 1) | ((x & 0x01010101u) << 7);\n    x &= 0x39393939u;\n    x ^= y & 0x3F3F3F3Fu;\n    y = ((y & 0xFCFCFCFCu) >> 2) | ((y & 0x03030303u) << 6);\n    x ^= y & 0x97979797u;\n    y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7);\n    x ^= y & 0x9B9B9B9Bu;\n    y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7);\n    x ^= y & 0x3C3C3C3Cu;\n    y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7);\n    x ^= y & 0xDDDDDDDDu;\n    y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7);\n    x ^= y & 0x72727272u;\n    x ^= 0x63636363u;\n    *w = x;\n}\n\nstatic void SubLong(u64 *w)\n{\n    u64 x, y, a1, a2, a3, a4, a5, a6;\n\n    x = *w;\n    y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7);\n    x &= 0xDDDDDDDDDDDDDDDDuLL;\n    x ^= y & 0x5757575757575757uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x1C1C1C1C1C1C1C1CuLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x4A4A4A4A4A4A4A4AuLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x4242424242424242uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x6464646464646464uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0xE0E0E0E0E0E0E0E0uLL;\n    a1 = x;\n    a1 ^= (x & 0xF0F0F0F0F0F0F0F0uLL) >> 4;\n    a2 = ((x & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((x & 0x3333333333333333uLL) << 2);\n    a3 = x & a1;\n    a3 ^= (a3 & 0xAAAAAAAAAAAAAAAAuLL) >> 1;\n    a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAAAAAAAAAuLL;\n    a4 = a2 & a1;\n    a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1;\n    a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL;\n    a5 = (a3 & 0xCCCCCCCCCCCCCCCCuLL) >> 2;\n    a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL;\n    a4 = a5 & 0x2222222222222222uLL;\n    a4 |= a4 >> 1;\n    a4 ^= (a5 << 1) & 0x2222222222222222uLL;\n    a3 ^= a4;\n    a5 = a3 & 0xA0A0A0A0A0A0A0A0uLL;\n    a5 |= a5 >> 1;\n    a5 ^= (a3 << 1) & 0xA0A0A0A0A0A0A0A0uLL;\n    a4 = a5 & 0xC0C0C0C0C0C0C0C0uLL;\n    a6 = a4 >> 2;\n    a4 ^= (a5 << 2) & 0xC0C0C0C0C0C0C0C0uLL;\n    a5 = a6 & 0x2020202020202020uLL;\n    a5 |= a5 >> 1;\n    a5 ^= (a6 << 1) & 0x2020202020202020uLL;\n    a4 |= a5;\n    a3 ^= a4 >> 4;\n    a3 &= 0x0F0F0F0F0F0F0F0FuLL;\n    a2 = a3;\n    a2 ^= (a3 & 0x0C0C0C0C0C0C0C0CuLL) >> 2;\n    a4 = a3 & a2;\n    a4 ^= (a4 & 0x0A0A0A0A0A0A0A0AuLL) >> 1;\n    a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0A0A0A0A0AuLL;\n    a5 = a4 & 0x0808080808080808uLL;\n    a5 |= a5 >> 1;\n    a5 ^= (a4 << 1) & 0x0808080808080808uLL;\n    a4 ^= a5 >> 2;\n    a4 &= 0x0303030303030303uLL;\n    a4 ^= (a4 & 0x0202020202020202uLL) >> 1;\n    a4 |= a4 << 2;\n    a3 = a2 & a4;\n    a3 ^= (a3 & 0x0A0A0A0A0A0A0A0AuLL) >> 1;\n    a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0A0A0A0A0AuLL;\n    a3 |= a3 << 4;\n    a2 = ((a1 & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((a1 & 0x3333333333333333uLL) << 2);\n    x = a1 & a3;\n    x ^= (x & 0xAAAAAAAAAAAAAAAAuLL) >> 1;\n    x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAAAAAAAAAuLL;\n    a4 = a2 & a3;\n    a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1;\n    a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL;\n    a5 = (x & 0xCCCCCCCCCCCCCCCCuLL) >> 2;\n    x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL;\n    a4 = a5 & 0x2222222222222222uLL;\n    a4 |= a4 >> 1;\n    a4 ^= (a5 << 1) & 0x2222222222222222uLL;\n    x ^= a4;\n    y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7);\n    x &= 0x3939393939393939uLL;\n    x ^= y & 0x3F3F3F3F3F3F3F3FuLL;\n    y = ((y & 0xFCFCFCFCFCFCFCFCuLL) >> 2) | ((y & 0x0303030303030303uLL) << 6);\n    x ^= y & 0x9797979797979797uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x9B9B9B9B9B9B9B9BuLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x3C3C3C3C3C3C3C3CuLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0xDDDDDDDDDDDDDDDDuLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x7272727272727272uLL;\n    x ^= 0x6363636363636363uLL;\n    *w = x;\n}\n\n/*\n * This computes w := (S^-1 * (w + c))^-1\n */\nstatic void InvSubLong(u64 *w)\n{\n    u64 x, y, a1, a2, a3, a4, a5, a6;\n\n    x = *w;\n    x ^= 0x6363636363636363uLL;\n    y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7);\n    x &= 0xFDFDFDFDFDFDFDFDuLL;\n    x ^= y & 0x5E5E5E5E5E5E5E5EuLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0xF3F3F3F3F3F3F3F3uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0xF5F5F5F5F5F5F5F5uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x7878787878787878uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x7777777777777777uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x1515151515151515uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0xA5A5A5A5A5A5A5A5uLL;\n    a1 = x;\n    a1 ^= (x & 0xF0F0F0F0F0F0F0F0uLL) >> 4;\n    a2 = ((x & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((x & 0x3333333333333333uLL) << 2);\n    a3 = x & a1;\n    a3 ^= (a3 & 0xAAAAAAAAAAAAAAAAuLL) >> 1;\n    a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAAAAAAAAAuLL;\n    a4 = a2 & a1;\n    a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1;\n    a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL;\n    a5 = (a3 & 0xCCCCCCCCCCCCCCCCuLL) >> 2;\n    a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL;\n    a4 = a5 & 0x2222222222222222uLL;\n    a4 |= a4 >> 1;\n    a4 ^= (a5 << 1) & 0x2222222222222222uLL;\n    a3 ^= a4;\n    a5 = a3 & 0xA0A0A0A0A0A0A0A0uLL;\n    a5 |= a5 >> 1;\n    a5 ^= (a3 << 1) & 0xA0A0A0A0A0A0A0A0uLL;\n    a4 = a5 & 0xC0C0C0C0C0C0C0C0uLL;\n    a6 = a4 >> 2;\n    a4 ^= (a5 << 2) & 0xC0C0C0C0C0C0C0C0uLL;\n    a5 = a6 & 0x2020202020202020uLL;\n    a5 |= a5 >> 1;\n    a5 ^= (a6 << 1) & 0x2020202020202020uLL;\n    a4 |= a5;\n    a3 ^= a4 >> 4;\n    a3 &= 0x0F0F0F0F0F0F0F0FuLL;\n    a2 = a3;\n    a2 ^= (a3 & 0x0C0C0C0C0C0C0C0CuLL) >> 2;\n    a4 = a3 & a2;\n    a4 ^= (a4 & 0x0A0A0A0A0A0A0A0AuLL) >> 1;\n    a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0A0A0A0A0AuLL;\n    a5 = a4 & 0x0808080808080808uLL;\n    a5 |= a5 >> 1;\n    a5 ^= (a4 << 1) & 0x0808080808080808uLL;\n    a4 ^= a5 >> 2;\n    a4 &= 0x0303030303030303uLL;\n    a4 ^= (a4 & 0x0202020202020202uLL) >> 1;\n    a4 |= a4 << 2;\n    a3 = a2 & a4;\n    a3 ^= (a3 & 0x0A0A0A0A0A0A0A0AuLL) >> 1;\n    a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0A0A0A0A0AuLL;\n    a3 |= a3 << 4;\n    a2 = ((a1 & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((a1 & 0x3333333333333333uLL) << 2);\n    x = a1 & a3;\n    x ^= (x & 0xAAAAAAAAAAAAAAAAuLL) >> 1;\n    x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAAAAAAAAAuLL;\n    a4 = a2 & a3;\n    a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1;\n    a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL;\n    a5 = (x & 0xCCCCCCCCCCCCCCCCuLL) >> 2;\n    x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL;\n    a4 = a5 & 0x2222222222222222uLL;\n    a4 |= a4 >> 1;\n    a4 ^= (a5 << 1) & 0x2222222222222222uLL;\n    x ^= a4;\n    y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7);\n    x &= 0xB5B5B5B5B5B5B5B5uLL;\n    x ^= y & 0x4040404040404040uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x8080808080808080uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x1616161616161616uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0xEBEBEBEBEBEBEBEBuLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x9797979797979797uLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0xFBFBFBFBFBFBFBFBuLL;\n    y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7);\n    x ^= y & 0x7D7D7D7D7D7D7D7DuLL;\n    *w = x;\n}\n\nstatic void ShiftRows(u64 *state)\n{\n    unsigned char s[4];\n    unsigned char *s0;\n    int r;\n\n    s0 = (unsigned char *)state;\n    for (r = 0; r < 4; r++) {\n        s[0] = s0[0*4 + r];\n        s[1] = s0[1*4 + r];\n        s[2] = s0[2*4 + r];\n        s[3] = s0[3*4 + r];\n        s0[0*4 + r] = s[(r+0) % 4];\n        s0[1*4 + r] = s[(r+1) % 4];\n        s0[2*4 + r] = s[(r+2) % 4];\n        s0[3*4 + r] = s[(r+3) % 4];\n    }\n}\n\nstatic void InvShiftRows(u64 *state)\n{\n    unsigned char s[4];\n    unsigned char *s0;\n    int r;\n\n    s0 = (unsigned char *)state;\n    for (r = 0; r < 4; r++) {\n        s[0] = s0[0*4 + r];\n        s[1] = s0[1*4 + r];\n        s[2] = s0[2*4 + r];\n        s[3] = s0[3*4 + r];\n        s0[0*4 + r] = s[(4-r) % 4];\n        s0[1*4 + r] = s[(5-r) % 4];\n        s0[2*4 + r] = s[(6-r) % 4];\n        s0[3*4 + r] = s[(7-r) % 4];\n    }\n}\n\nstatic void MixColumns(u64 *state)\n{\n    uni s1;\n    uni s;\n    int c;\n\n    for (c = 0; c < 2; c++) {\n        s1.d = state[c];\n        s.d = s1.d;\n        s.d ^= ((s.d & 0xFFFF0000FFFF0000uLL) >> 16)\n               | ((s.d & 0x0000FFFF0000FFFFuLL) << 16);\n        s.d ^= ((s.d & 0xFF00FF00FF00FF00uLL) >> 8)\n               | ((s.d & 0x00FF00FF00FF00FFuLL) << 8);\n        s.d ^= s1.d;\n        XtimeLong(&s1.d);\n        s.d ^= s1.d;\n        s.b[0] ^= s1.b[1];\n        s.b[1] ^= s1.b[2];\n        s.b[2] ^= s1.b[3];\n        s.b[3] ^= s1.b[0];\n        s.b[4] ^= s1.b[5];\n        s.b[5] ^= s1.b[6];\n        s.b[6] ^= s1.b[7];\n        s.b[7] ^= s1.b[4];\n        state[c] = s.d;\n    }\n}\n\nstatic void InvMixColumns(u64 *state)\n{\n    uni s1;\n    uni s;\n    int c;\n\n    for (c = 0; c < 2; c++) {\n        s1.d = state[c];\n        s.d = s1.d;\n        s.d ^= ((s.d & 0xFFFF0000FFFF0000uLL) >> 16)\n               | ((s.d & 0x0000FFFF0000FFFFuLL) << 16);\n        s.d ^= ((s.d & 0xFF00FF00FF00FF00uLL) >> 8)\n               | ((s.d & 0x00FF00FF00FF00FFuLL) << 8);\n        s.d ^= s1.d;\n        XtimeLong(&s1.d);\n        s.d ^= s1.d;\n        s.b[0] ^= s1.b[1];\n        s.b[1] ^= s1.b[2];\n        s.b[2] ^= s1.b[3];\n        s.b[3] ^= s1.b[0];\n        s.b[4] ^= s1.b[5];\n        s.b[5] ^= s1.b[6];\n        s.b[6] ^= s1.b[7];\n        s.b[7] ^= s1.b[4];\n        XtimeLong(&s1.d);\n        s1.d ^= ((s1.d & 0xFFFF0000FFFF0000uLL) >> 16)\n                | ((s1.d & 0x0000FFFF0000FFFFuLL) << 16);\n        s.d ^= s1.d;\n        XtimeLong(&s1.d);\n        s1.d ^= ((s1.d & 0xFF00FF00FF00FF00uLL) >> 8)\n                | ((s1.d & 0x00FF00FF00FF00FFuLL) << 8);\n        s.d ^= s1.d;\n        state[c] = s.d;\n    }\n}\n\nstatic void AddRoundKey(u64 *state, const u64 *w)\n{\n    state[0] ^= w[0];\n    state[1] ^= w[1];\n}\n\nstatic void Cipher(const unsigned char *in, unsigned char *out,\n                   const u64 *w, int nr)\n{\n    u64 state[2];\n    int i;\n\n    memcpy(state, in, 16);\n\n    AddRoundKey(state, w);\n\n    for (i = 1; i < nr; i++) {\n        SubLong(&state[0]);\n        SubLong(&state[1]);\n        ShiftRows(state);\n        MixColumns(state);\n        AddRoundKey(state, w + i*2);\n    }\n\n    SubLong(&state[0]);\n    SubLong(&state[1]);\n    ShiftRows(state);\n    AddRoundKey(state, w + nr*2);\n\n    memcpy(out, state, 16);\n}\n\nstatic void InvCipher(const unsigned char *in, unsigned char *out,\n                      const u64 *w, int nr)\n\n{\n    u64 state[2];\n    int i;\n\n    memcpy(state, in, 16);\n\n    AddRoundKey(state, w + nr*2);\n\n    for (i = nr - 1; i > 0; i--) {\n        InvShiftRows(state);\n        InvSubLong(&state[0]);\n        InvSubLong(&state[1]);\n        AddRoundKey(state, w + i*2);\n        InvMixColumns(state);\n    }\n\n    InvShiftRows(state);\n    InvSubLong(&state[0]);\n    InvSubLong(&state[1]);\n    AddRoundKey(state, w);\n\n    memcpy(out, state, 16);\n}\n\nstatic void RotWord(u32 *x)\n{\n    unsigned char *w0;\n    unsigned char tmp;\n\n    w0 = (unsigned char *)x;\n    tmp = w0[0];\n    w0[0] = w0[1];\n    w0[1] = w0[2];\n    w0[2] = w0[3];\n    w0[3] = tmp;\n}\n\nstatic void KeyExpansion(const unsigned char *key, u64 *w,\n                         int nr, int nk)\n{\n    u32 rcon;\n    uni prev;\n    u32 temp;\n    int i, n;\n\n    memcpy(w, key, nk*4);\n    memcpy(&rcon, \"\\1\\0\\0\\0\", 4);\n    n = nk/2;\n    prev.d = w[n-1];\n    for (i = n; i < (nr+1)*2; i++) {\n        temp = prev.w[1];\n        if (i % n == 0) {\n            RotWord(&temp);\n            SubWord(&temp);\n            temp ^= rcon;\n            XtimeWord(&rcon);\n        } else if (nk > 6 && i % n == 2) {\n            SubWord(&temp);\n        }\n        prev.d = w[i-n];\n        prev.w[0] ^= temp;\n        prev.w[1] ^= prev.w[0];\n        w[i] = prev.d;\n    }\n}\n\n/**\n * Expand the cipher key into the encryption key schedule.\n */\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key)\n{\n    u64 *rk;\n\n    if (!userKey || !key)\n        return -1;\n    if (bits != 128 && bits != 192 && bits != 256)\n        return -2;\n\n    rk = (u64*)key->rd_key;\n\n    if (bits == 128)\n        key->rounds = 10;\n    else if (bits == 192)\n        key->rounds = 12;\n    else\n        key->rounds = 14;\n\n    KeyExpansion(userKey, rk, key->rounds, bits/32);\n    return 0;\n}\n\n/**\n * Expand the cipher key into the decryption key schedule.\n */\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key)\n{\n    return AES_set_encrypt_key(userKey, bits, key);\n}\n\n/*\n * Encrypt a single block\n * in and out can overlap\n */\nvoid AES_encrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key)\n{\n    const u64 *rk;\n\n    assert(in && out && key);\n    rk = (u64*)key->rd_key;\n\n    Cipher(in, out, rk, key->rounds);\n}\n\n/*\n * Decrypt a single block\n * in and out can overlap\n */\nvoid AES_decrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key)\n{\n    const u64 *rk;\n\n    assert(in && out && key);\n    rk = (u64*)key->rd_key;\n\n    InvCipher(in, out, rk, key->rounds);\n}\n#elif !defined(AES_ASM)\n/*-\nTe0[x] = S [x].[02, 01, 01, 03];\nTe1[x] = S [x].[03, 02, 01, 01];\nTe2[x] = S [x].[01, 03, 02, 01];\nTe3[x] = S [x].[01, 01, 03, 02];\n\nTd0[x] = Si[x].[0e, 09, 0d, 0b];\nTd1[x] = Si[x].[0b, 0e, 09, 0d];\nTd2[x] = Si[x].[0d, 0b, 0e, 09];\nTd3[x] = Si[x].[09, 0d, 0b, 0e];\nTd4[x] = Si[x].[01];\n*/\n\nstatic const u32 Te0[256] = {\n    0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,\n    0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,\n    0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,\n    0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,\n    0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,\n    0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,\n    0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,\n    0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,\n    0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,\n    0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,\n    0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,\n    0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,\n    0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,\n    0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,\n    0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,\n    0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,\n    0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,\n    0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,\n    0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,\n    0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,\n    0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,\n    0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,\n    0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,\n    0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,\n    0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,\n    0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,\n    0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,\n    0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,\n    0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,\n    0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,\n    0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,\n    0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,\n    0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,\n    0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,\n    0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,\n    0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,\n    0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,\n    0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,\n    0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,\n    0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,\n    0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,\n    0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,\n    0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,\n    0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,\n    0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,\n    0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,\n    0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,\n    0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,\n    0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,\n    0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,\n    0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,\n    0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,\n    0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,\n    0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,\n    0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,\n    0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,\n    0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,\n    0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,\n    0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,\n    0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,\n    0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,\n    0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,\n    0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,\n    0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,\n};\nstatic const u32 Te1[256] = {\n    0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,\n    0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,\n    0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,\n    0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,\n    0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,\n    0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,\n    0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,\n    0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,\n    0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,\n    0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,\n    0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,\n    0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,\n    0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,\n    0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,\n    0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,\n    0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,\n    0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,\n    0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,\n    0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,\n    0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,\n    0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,\n    0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,\n    0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,\n    0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,\n    0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,\n    0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,\n    0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,\n    0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,\n    0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,\n    0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,\n    0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,\n    0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,\n    0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,\n    0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,\n    0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,\n    0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,\n    0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,\n    0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,\n    0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,\n    0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,\n    0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,\n    0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,\n    0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,\n    0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,\n    0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,\n    0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,\n    0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,\n    0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,\n    0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,\n    0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,\n    0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,\n    0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,\n    0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,\n    0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,\n    0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,\n    0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,\n    0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,\n    0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,\n    0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,\n    0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,\n    0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,\n    0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,\n    0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,\n    0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,\n};\nstatic const u32 Te2[256] = {\n    0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,\n    0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,\n    0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,\n    0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,\n    0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,\n    0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,\n    0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,\n    0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,\n    0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,\n    0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,\n    0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,\n    0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,\n    0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,\n    0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,\n    0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,\n    0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,\n    0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,\n    0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,\n    0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,\n    0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,\n    0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,\n    0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,\n    0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,\n    0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,\n    0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,\n    0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,\n    0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,\n    0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,\n    0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,\n    0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,\n    0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,\n    0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,\n    0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,\n    0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,\n    0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,\n    0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,\n    0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,\n    0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,\n    0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,\n    0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,\n    0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,\n    0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,\n    0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,\n    0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,\n    0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,\n    0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,\n    0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,\n    0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,\n    0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,\n    0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,\n    0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,\n    0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,\n    0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,\n    0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,\n    0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,\n    0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,\n    0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,\n    0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,\n    0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,\n    0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,\n    0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,\n    0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,\n    0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,\n    0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,\n};\nstatic const u32 Te3[256] = {\n    0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,\n    0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,\n    0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,\n    0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,\n    0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,\n    0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,\n    0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,\n    0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,\n    0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,\n    0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,\n    0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,\n    0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,\n    0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,\n    0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,\n    0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,\n    0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,\n    0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,\n    0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,\n    0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,\n    0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,\n    0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,\n    0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,\n    0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,\n    0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,\n    0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,\n    0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,\n    0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,\n    0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,\n    0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,\n    0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,\n    0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,\n    0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,\n    0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,\n    0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,\n    0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,\n    0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,\n    0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,\n    0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,\n    0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,\n    0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,\n    0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,\n    0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,\n    0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,\n    0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,\n    0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,\n    0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,\n    0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,\n    0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,\n    0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,\n    0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,\n    0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,\n    0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,\n    0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,\n    0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,\n    0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,\n    0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,\n    0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,\n    0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,\n    0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,\n    0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,\n    0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,\n    0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,\n    0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,\n    0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,\n};\n\nstatic const u32 Td0[256] = {\n    0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,\n    0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,\n    0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,\n    0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,\n    0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,\n    0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,\n    0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,\n    0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,\n    0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,\n    0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,\n    0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,\n    0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,\n    0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,\n    0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,\n    0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,\n    0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,\n    0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,\n    0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,\n    0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,\n    0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,\n    0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,\n    0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,\n    0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,\n    0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,\n    0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,\n    0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,\n    0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,\n    0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,\n    0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,\n    0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,\n    0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,\n    0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,\n    0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,\n    0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,\n    0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,\n    0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,\n    0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,\n    0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,\n    0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,\n    0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,\n    0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,\n    0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,\n    0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,\n    0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,\n    0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,\n    0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,\n    0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,\n    0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,\n    0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,\n    0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,\n    0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,\n    0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,\n    0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,\n    0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,\n    0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,\n    0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,\n    0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,\n    0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,\n    0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,\n    0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,\n    0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,\n    0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,\n    0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,\n    0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,\n};\nstatic const u32 Td1[256] = {\n    0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,\n    0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,\n    0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,\n    0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,\n    0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,\n    0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,\n    0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,\n    0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,\n    0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,\n    0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,\n    0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,\n    0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,\n    0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,\n    0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,\n    0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,\n    0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,\n    0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,\n    0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,\n    0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,\n    0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,\n    0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,\n    0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,\n    0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,\n    0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,\n    0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,\n    0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,\n    0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,\n    0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,\n    0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,\n    0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,\n    0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,\n    0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,\n    0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,\n    0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,\n    0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,\n    0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,\n    0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,\n    0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,\n    0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,\n    0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,\n    0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,\n    0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,\n    0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,\n    0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,\n    0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,\n    0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,\n    0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,\n    0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,\n    0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,\n    0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,\n    0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,\n    0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,\n    0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,\n    0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,\n    0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,\n    0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,\n    0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,\n    0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,\n    0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,\n    0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,\n    0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,\n    0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,\n    0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,\n    0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,\n};\nstatic const u32 Td2[256] = {\n    0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,\n    0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,\n    0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,\n    0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,\n    0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,\n    0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,\n    0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,\n    0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,\n    0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,\n    0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,\n    0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,\n    0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,\n    0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,\n    0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,\n    0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,\n    0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,\n    0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,\n    0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,\n    0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,\n    0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,\n    0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,\n    0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,\n    0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,\n    0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,\n    0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,\n    0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,\n    0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,\n    0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,\n    0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,\n    0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,\n    0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,\n    0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,\n    0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,\n    0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,\n    0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,\n    0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,\n    0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,\n    0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,\n    0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,\n    0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,\n    0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,\n    0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,\n    0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,\n    0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,\n    0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,\n    0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,\n    0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,\n    0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,\n    0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,\n    0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,\n    0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,\n    0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,\n    0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,\n    0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,\n    0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,\n    0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,\n    0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,\n    0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,\n    0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,\n    0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,\n    0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,\n    0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,\n    0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,\n    0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,\n};\nstatic const u32 Td3[256] = {\n    0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,\n    0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,\n    0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,\n    0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,\n    0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,\n    0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,\n    0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,\n    0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,\n    0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,\n    0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,\n    0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,\n    0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,\n    0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,\n    0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,\n    0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,\n    0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,\n    0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,\n    0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,\n    0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,\n    0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,\n    0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,\n    0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,\n    0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,\n    0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,\n    0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,\n    0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,\n    0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,\n    0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,\n    0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,\n    0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,\n    0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,\n    0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,\n    0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,\n    0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,\n    0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,\n    0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,\n    0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,\n    0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,\n    0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,\n    0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,\n    0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,\n    0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,\n    0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,\n    0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,\n    0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,\n    0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,\n    0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,\n    0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,\n    0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,\n    0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,\n    0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,\n    0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,\n    0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,\n    0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,\n    0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,\n    0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,\n    0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,\n    0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,\n    0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,\n    0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,\n    0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,\n    0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,\n    0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,\n    0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,\n};\nstatic const u8 Td4[256] = {\n    0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U,\n    0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU,\n    0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U,\n    0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU,\n    0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU,\n    0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU,\n    0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U,\n    0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U,\n    0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U,\n    0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U,\n    0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU,\n    0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U,\n    0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU,\n    0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U,\n    0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U,\n    0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU,\n    0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU,\n    0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U,\n    0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U,\n    0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU,\n    0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U,\n    0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU,\n    0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U,\n    0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U,\n    0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U,\n    0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU,\n    0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU,\n    0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU,\n    0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U,\n    0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U,\n    0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U,\n    0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU,\n};\nstatic const u32 rcon[] = {\n    0x01000000, 0x02000000, 0x04000000, 0x08000000,\n    0x10000000, 0x20000000, 0x40000000, 0x80000000,\n    0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */\n};\n\n/**\n * Expand the cipher key into the encryption key schedule.\n */\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key)\n{\n\n    u32 *rk;\n    int i = 0;\n    u32 temp;\n\n    if (!userKey || !key)\n        return -1;\n    if (bits != 128 && bits != 192 && bits != 256)\n        return -2;\n\n    rk = key->rd_key;\n\n    if (bits == 128)\n        key->rounds = 10;\n    else if (bits == 192)\n        key->rounds = 12;\n    else\n        key->rounds = 14;\n\n    rk[0] = GETU32(userKey     );\n    rk[1] = GETU32(userKey +  4);\n    rk[2] = GETU32(userKey +  8);\n    rk[3] = GETU32(userKey + 12);\n    if (bits == 128) {\n        while (1) {\n            temp  = rk[3];\n            rk[4] = rk[0] ^\n                (Te2[(temp >> 16) & 0xff] & 0xff000000) ^\n                (Te3[(temp >>  8) & 0xff] & 0x00ff0000) ^\n                (Te0[(temp      ) & 0xff] & 0x0000ff00) ^\n                (Te1[(temp >> 24)       ] & 0x000000ff) ^\n                rcon[i];\n            rk[5] = rk[1] ^ rk[4];\n            rk[6] = rk[2] ^ rk[5];\n            rk[7] = rk[3] ^ rk[6];\n            if (++i == 10) {\n                return 0;\n            }\n            rk += 4;\n        }\n    }\n    rk[4] = GETU32(userKey + 16);\n    rk[5] = GETU32(userKey + 20);\n    if (bits == 192) {\n        while (1) {\n            temp = rk[ 5];\n            rk[ 6] = rk[ 0] ^\n                (Te2[(temp >> 16) & 0xff] & 0xff000000) ^\n                (Te3[(temp >>  8) & 0xff] & 0x00ff0000) ^\n                (Te0[(temp      ) & 0xff] & 0x0000ff00) ^\n                (Te1[(temp >> 24)       ] & 0x000000ff) ^\n                rcon[i];\n            rk[ 7] = rk[ 1] ^ rk[ 6];\n            rk[ 8] = rk[ 2] ^ rk[ 7];\n            rk[ 9] = rk[ 3] ^ rk[ 8];\n            if (++i == 8) {\n                return 0;\n            }\n            rk[10] = rk[ 4] ^ rk[ 9];\n            rk[11] = rk[ 5] ^ rk[10];\n            rk += 6;\n        }\n    }\n    rk[6] = GETU32(userKey + 24);\n    rk[7] = GETU32(userKey + 28);\n    if (bits == 256) {\n        while (1) {\n            temp = rk[ 7];\n            rk[ 8] = rk[ 0] ^\n                (Te2[(temp >> 16) & 0xff] & 0xff000000) ^\n                (Te3[(temp >>  8) & 0xff] & 0x00ff0000) ^\n                (Te0[(temp      ) & 0xff] & 0x0000ff00) ^\n                (Te1[(temp >> 24)       ] & 0x000000ff) ^\n                rcon[i];\n            rk[ 9] = rk[ 1] ^ rk[ 8];\n            rk[10] = rk[ 2] ^ rk[ 9];\n            rk[11] = rk[ 3] ^ rk[10];\n            if (++i == 7) {\n                return 0;\n            }\n            temp = rk[11];\n            rk[12] = rk[ 4] ^\n                (Te2[(temp >> 24)       ] & 0xff000000) ^\n                (Te3[(temp >> 16) & 0xff] & 0x00ff0000) ^\n                (Te0[(temp >>  8) & 0xff] & 0x0000ff00) ^\n                (Te1[(temp      ) & 0xff] & 0x000000ff);\n            rk[13] = rk[ 5] ^ rk[12];\n            rk[14] = rk[ 6] ^ rk[13];\n            rk[15] = rk[ 7] ^ rk[14];\n\n            rk += 8;\n            }\n    }\n    return 0;\n}\n\n/**\n * Expand the cipher key into the decryption key schedule.\n */\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key)\n{\n\n    u32 *rk;\n    int i, j, status;\n    u32 temp;\n\n    /* first, start with an encryption schedule */\n    status = AES_set_encrypt_key(userKey, bits, key);\n    if (status < 0)\n        return status;\n\n    rk = key->rd_key;\n\n    /* invert the order of the round keys: */\n    for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {\n        temp = rk[i    ]; rk[i    ] = rk[j    ]; rk[j    ] = temp;\n        temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;\n        temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;\n        temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;\n    }\n    /* apply the inverse MixColumn transform to all round keys but the first and the last: */\n    for (i = 1; i < (key->rounds); i++) {\n        rk += 4;\n        rk[0] =\n            Td0[Te1[(rk[0] >> 24)       ] & 0xff] ^\n            Td1[Te1[(rk[0] >> 16) & 0xff] & 0xff] ^\n            Td2[Te1[(rk[0] >>  8) & 0xff] & 0xff] ^\n            Td3[Te1[(rk[0]      ) & 0xff] & 0xff];\n        rk[1] =\n            Td0[Te1[(rk[1] >> 24)       ] & 0xff] ^\n            Td1[Te1[(rk[1] >> 16) & 0xff] & 0xff] ^\n            Td2[Te1[(rk[1] >>  8) & 0xff] & 0xff] ^\n            Td3[Te1[(rk[1]      ) & 0xff] & 0xff];\n        rk[2] =\n            Td0[Te1[(rk[2] >> 24)       ] & 0xff] ^\n            Td1[Te1[(rk[2] >> 16) & 0xff] & 0xff] ^\n            Td2[Te1[(rk[2] >>  8) & 0xff] & 0xff] ^\n            Td3[Te1[(rk[2]      ) & 0xff] & 0xff];\n        rk[3] =\n            Td0[Te1[(rk[3] >> 24)       ] & 0xff] ^\n            Td1[Te1[(rk[3] >> 16) & 0xff] & 0xff] ^\n            Td2[Te1[(rk[3] >>  8) & 0xff] & 0xff] ^\n            Td3[Te1[(rk[3]      ) & 0xff] & 0xff];\n    }\n    return 0;\n}\n\n/*\n * Encrypt a single block\n * in and out can overlap\n */\nvoid AES_encrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key) {\n\n    const u32 *rk;\n    u32 s0, s1, s2, s3, t0, t1, t2, t3;\n#ifndef FULL_UNROLL\n    int r;\n#endif /* ?FULL_UNROLL */\n\n    assert(in && out && key);\n    rk = key->rd_key;\n\n    /*\n     * map byte array block to cipher state\n     * and add initial round key:\n     */\n    s0 = GETU32(in     ) ^ rk[0];\n    s1 = GETU32(in +  4) ^ rk[1];\n    s2 = GETU32(in +  8) ^ rk[2];\n    s3 = GETU32(in + 12) ^ rk[3];\n#ifdef FULL_UNROLL\n    /* round 1: */\n    t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4];\n    t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5];\n    t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6];\n    t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7];\n    /* round 2: */\n    s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8];\n    s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9];\n    s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10];\n    s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11];\n    /* round 3: */\n    t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12];\n    t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13];\n    t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14];\n    t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15];\n    /* round 4: */\n    s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16];\n    s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17];\n    s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18];\n    s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19];\n    /* round 5: */\n    t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20];\n    t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21];\n    t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22];\n    t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23];\n    /* round 6: */\n    s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24];\n    s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25];\n    s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26];\n    s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27];\n    /* round 7: */\n    t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28];\n    t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29];\n    t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30];\n    t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31];\n    /* round 8: */\n    s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32];\n    s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33];\n    s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34];\n    s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35];\n    /* round 9: */\n    t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36];\n    t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37];\n    t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38];\n    t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39];\n    if (key->rounds > 10) {\n        /* round 10: */\n        s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40];\n        s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41];\n        s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42];\n        s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43];\n        /* round 11: */\n        t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44];\n        t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45];\n        t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46];\n        t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47];\n        if (key->rounds > 12) {\n            /* round 12: */\n            s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >>  8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48];\n            s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >>  8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49];\n            s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >>  8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50];\n            s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >>  8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51];\n            /* round 13: */\n            t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >>  8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52];\n            t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >>  8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53];\n            t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >>  8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54];\n            t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >>  8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55];\n        }\n    }\n    rk += key->rounds << 2;\n#else  /* !FULL_UNROLL */\n    /*\n     * Nr - 1 full rounds:\n     */\n    r = key->rounds >> 1;\n    for (;;) {\n        t0 =\n            Te0[(s0 >> 24)       ] ^\n            Te1[(s1 >> 16) & 0xff] ^\n            Te2[(s2 >>  8) & 0xff] ^\n            Te3[(s3      ) & 0xff] ^\n            rk[4];\n        t1 =\n            Te0[(s1 >> 24)       ] ^\n            Te1[(s2 >> 16) & 0xff] ^\n            Te2[(s3 >>  8) & 0xff] ^\n            Te3[(s0      ) & 0xff] ^\n            rk[5];\n        t2 =\n            Te0[(s2 >> 24)       ] ^\n            Te1[(s3 >> 16) & 0xff] ^\n            Te2[(s0 >>  8) & 0xff] ^\n            Te3[(s1      ) & 0xff] ^\n            rk[6];\n        t3 =\n            Te0[(s3 >> 24)       ] ^\n            Te1[(s0 >> 16) & 0xff] ^\n            Te2[(s1 >>  8) & 0xff] ^\n            Te3[(s2      ) & 0xff] ^\n            rk[7];\n\n        rk += 8;\n        if (--r == 0) {\n            break;\n        }\n\n        s0 =\n            Te0[(t0 >> 24)       ] ^\n            Te1[(t1 >> 16) & 0xff] ^\n            Te2[(t2 >>  8) & 0xff] ^\n            Te3[(t3      ) & 0xff] ^\n            rk[0];\n        s1 =\n            Te0[(t1 >> 24)       ] ^\n            Te1[(t2 >> 16) & 0xff] ^\n            Te2[(t3 >>  8) & 0xff] ^\n            Te3[(t0      ) & 0xff] ^\n            rk[1];\n        s2 =\n            Te0[(t2 >> 24)       ] ^\n            Te1[(t3 >> 16) & 0xff] ^\n            Te2[(t0 >>  8) & 0xff] ^\n            Te3[(t1      ) & 0xff] ^\n            rk[2];\n        s3 =\n            Te0[(t3 >> 24)       ] ^\n            Te1[(t0 >> 16) & 0xff] ^\n            Te2[(t1 >>  8) & 0xff] ^\n            Te3[(t2      ) & 0xff] ^\n            rk[3];\n    }\n#endif /* ?FULL_UNROLL */\n    /*\n     * apply last round and\n     * map cipher state to byte array block:\n     */\n    s0 =\n        (Te2[(t0 >> 24)       ] & 0xff000000) ^\n        (Te3[(t1 >> 16) & 0xff] & 0x00ff0000) ^\n        (Te0[(t2 >>  8) & 0xff] & 0x0000ff00) ^\n        (Te1[(t3      ) & 0xff] & 0x000000ff) ^\n        rk[0];\n    PUTU32(out     , s0);\n    s1 =\n        (Te2[(t1 >> 24)       ] & 0xff000000) ^\n        (Te3[(t2 >> 16) & 0xff] & 0x00ff0000) ^\n        (Te0[(t3 >>  8) & 0xff] & 0x0000ff00) ^\n        (Te1[(t0      ) & 0xff] & 0x000000ff) ^\n        rk[1];\n    PUTU32(out +  4, s1);\n    s2 =\n        (Te2[(t2 >> 24)       ] & 0xff000000) ^\n        (Te3[(t3 >> 16) & 0xff] & 0x00ff0000) ^\n        (Te0[(t0 >>  8) & 0xff] & 0x0000ff00) ^\n        (Te1[(t1      ) & 0xff] & 0x000000ff) ^\n        rk[2];\n    PUTU32(out +  8, s2);\n    s3 =\n        (Te2[(t3 >> 24)       ] & 0xff000000) ^\n        (Te3[(t0 >> 16) & 0xff] & 0x00ff0000) ^\n        (Te0[(t1 >>  8) & 0xff] & 0x0000ff00) ^\n        (Te1[(t2      ) & 0xff] & 0x000000ff) ^\n        rk[3];\n    PUTU32(out + 12, s3);\n}\n\n/*\n * Decrypt a single block\n * in and out can overlap\n */\nvoid AES_decrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key)\n{\n\n    const u32 *rk;\n    u32 s0, s1, s2, s3, t0, t1, t2, t3;\n#ifndef FULL_UNROLL\n    int r;\n#endif /* ?FULL_UNROLL */\n\n    assert(in && out && key);\n    rk = key->rd_key;\n\n    /*\n     * map byte array block to cipher state\n     * and add initial round key:\n     */\n    s0 = GETU32(in     ) ^ rk[0];\n    s1 = GETU32(in +  4) ^ rk[1];\n    s2 = GETU32(in +  8) ^ rk[2];\n    s3 = GETU32(in + 12) ^ rk[3];\n#ifdef FULL_UNROLL\n    /* round 1: */\n    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4];\n    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5];\n    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6];\n    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7];\n    /* round 2: */\n    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8];\n    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9];\n    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10];\n    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11];\n    /* round 3: */\n    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12];\n    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13];\n    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14];\n    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15];\n    /* round 4: */\n    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16];\n    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17];\n    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18];\n    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19];\n    /* round 5: */\n    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20];\n    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21];\n    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22];\n    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23];\n    /* round 6: */\n    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24];\n    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25];\n    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26];\n    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27];\n    /* round 7: */\n    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28];\n    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29];\n    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30];\n    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31];\n    /* round 8: */\n    s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32];\n    s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33];\n    s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34];\n    s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35];\n    /* round 9: */\n    t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36];\n    t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37];\n    t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38];\n    t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39];\n    if (key->rounds > 10) {\n        /* round 10: */\n        s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40];\n        s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41];\n        s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42];\n        s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43];\n        /* round 11: */\n        t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44];\n        t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45];\n        t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46];\n        t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47];\n        if (key->rounds > 12) {\n            /* round 12: */\n            s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >>  8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48];\n            s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >>  8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49];\n            s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >>  8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50];\n            s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >>  8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51];\n            /* round 13: */\n            t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >>  8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52];\n            t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >>  8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53];\n            t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >>  8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54];\n            t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >>  8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55];\n        }\n    }\n    rk += key->rounds << 2;\n#else  /* !FULL_UNROLL */\n    /*\n     * Nr - 1 full rounds:\n     */\n    r = key->rounds >> 1;\n    for (;;) {\n        t0 =\n            Td0[(s0 >> 24)       ] ^\n            Td1[(s3 >> 16) & 0xff] ^\n            Td2[(s2 >>  8) & 0xff] ^\n            Td3[(s1      ) & 0xff] ^\n            rk[4];\n        t1 =\n            Td0[(s1 >> 24)       ] ^\n            Td1[(s0 >> 16) & 0xff] ^\n            Td2[(s3 >>  8) & 0xff] ^\n            Td3[(s2      ) & 0xff] ^\n            rk[5];\n        t2 =\n            Td0[(s2 >> 24)       ] ^\n            Td1[(s1 >> 16) & 0xff] ^\n            Td2[(s0 >>  8) & 0xff] ^\n            Td3[(s3      ) & 0xff] ^\n            rk[6];\n        t3 =\n            Td0[(s3 >> 24)       ] ^\n            Td1[(s2 >> 16) & 0xff] ^\n            Td2[(s1 >>  8) & 0xff] ^\n            Td3[(s0      ) & 0xff] ^\n            rk[7];\n\n        rk += 8;\n        if (--r == 0) {\n            break;\n        }\n\n        s0 =\n            Td0[(t0 >> 24)       ] ^\n            Td1[(t3 >> 16) & 0xff] ^\n            Td2[(t2 >>  8) & 0xff] ^\n            Td3[(t1      ) & 0xff] ^\n            rk[0];\n        s1 =\n            Td0[(t1 >> 24)       ] ^\n            Td1[(t0 >> 16) & 0xff] ^\n            Td2[(t3 >>  8) & 0xff] ^\n            Td3[(t2      ) & 0xff] ^\n            rk[1];\n        s2 =\n            Td0[(t2 >> 24)       ] ^\n            Td1[(t1 >> 16) & 0xff] ^\n            Td2[(t0 >>  8) & 0xff] ^\n            Td3[(t3      ) & 0xff] ^\n            rk[2];\n        s3 =\n            Td0[(t3 >> 24)       ] ^\n            Td1[(t2 >> 16) & 0xff] ^\n            Td2[(t1 >>  8) & 0xff] ^\n            Td3[(t0      ) & 0xff] ^\n            rk[3];\n    }\n#endif /* ?FULL_UNROLL */\n    /*\n     * apply last round and\n     * map cipher state to byte array block:\n     */\n    s0 =\n        ((u32)Td4[(t0 >> 24)       ] << 24) ^\n        ((u32)Td4[(t3 >> 16) & 0xff] << 16) ^\n        ((u32)Td4[(t2 >>  8) & 0xff] <<  8) ^\n        ((u32)Td4[(t1      ) & 0xff])       ^\n        rk[0];\n    PUTU32(out     , s0);\n    s1 =\n        ((u32)Td4[(t1 >> 24)       ] << 24) ^\n        ((u32)Td4[(t0 >> 16) & 0xff] << 16) ^\n        ((u32)Td4[(t3 >>  8) & 0xff] <<  8) ^\n        ((u32)Td4[(t2      ) & 0xff])       ^\n        rk[1];\n    PUTU32(out +  4, s1);\n    s2 =\n        ((u32)Td4[(t2 >> 24)       ] << 24) ^\n        ((u32)Td4[(t1 >> 16) & 0xff] << 16) ^\n        ((u32)Td4[(t0 >>  8) & 0xff] <<  8) ^\n        ((u32)Td4[(t3      ) & 0xff])       ^\n        rk[2];\n    PUTU32(out +  8, s2);\n    s3 =\n        ((u32)Td4[(t3 >> 24)       ] << 24) ^\n        ((u32)Td4[(t2 >> 16) & 0xff] << 16) ^\n        ((u32)Td4[(t1 >>  8) & 0xff] <<  8) ^\n        ((u32)Td4[(t0      ) & 0xff])       ^\n        rk[3];\n    PUTU32(out + 12, s3);\n}\n\n#else /* AES_ASM */\n\nstatic const u8 Te4[256] = {\n    0x63U, 0x7cU, 0x77U, 0x7bU, 0xf2U, 0x6bU, 0x6fU, 0xc5U,\n    0x30U, 0x01U, 0x67U, 0x2bU, 0xfeU, 0xd7U, 0xabU, 0x76U,\n    0xcaU, 0x82U, 0xc9U, 0x7dU, 0xfaU, 0x59U, 0x47U, 0xf0U,\n    0xadU, 0xd4U, 0xa2U, 0xafU, 0x9cU, 0xa4U, 0x72U, 0xc0U,\n    0xb7U, 0xfdU, 0x93U, 0x26U, 0x36U, 0x3fU, 0xf7U, 0xccU,\n    0x34U, 0xa5U, 0xe5U, 0xf1U, 0x71U, 0xd8U, 0x31U, 0x15U,\n    0x04U, 0xc7U, 0x23U, 0xc3U, 0x18U, 0x96U, 0x05U, 0x9aU,\n    0x07U, 0x12U, 0x80U, 0xe2U, 0xebU, 0x27U, 0xb2U, 0x75U,\n    0x09U, 0x83U, 0x2cU, 0x1aU, 0x1bU, 0x6eU, 0x5aU, 0xa0U,\n    0x52U, 0x3bU, 0xd6U, 0xb3U, 0x29U, 0xe3U, 0x2fU, 0x84U,\n    0x53U, 0xd1U, 0x00U, 0xedU, 0x20U, 0xfcU, 0xb1U, 0x5bU,\n    0x6aU, 0xcbU, 0xbeU, 0x39U, 0x4aU, 0x4cU, 0x58U, 0xcfU,\n    0xd0U, 0xefU, 0xaaU, 0xfbU, 0x43U, 0x4dU, 0x33U, 0x85U,\n    0x45U, 0xf9U, 0x02U, 0x7fU, 0x50U, 0x3cU, 0x9fU, 0xa8U,\n    0x51U, 0xa3U, 0x40U, 0x8fU, 0x92U, 0x9dU, 0x38U, 0xf5U,\n    0xbcU, 0xb6U, 0xdaU, 0x21U, 0x10U, 0xffU, 0xf3U, 0xd2U,\n    0xcdU, 0x0cU, 0x13U, 0xecU, 0x5fU, 0x97U, 0x44U, 0x17U,\n    0xc4U, 0xa7U, 0x7eU, 0x3dU, 0x64U, 0x5dU, 0x19U, 0x73U,\n    0x60U, 0x81U, 0x4fU, 0xdcU, 0x22U, 0x2aU, 0x90U, 0x88U,\n    0x46U, 0xeeU, 0xb8U, 0x14U, 0xdeU, 0x5eU, 0x0bU, 0xdbU,\n    0xe0U, 0x32U, 0x3aU, 0x0aU, 0x49U, 0x06U, 0x24U, 0x5cU,\n    0xc2U, 0xd3U, 0xacU, 0x62U, 0x91U, 0x95U, 0xe4U, 0x79U,\n    0xe7U, 0xc8U, 0x37U, 0x6dU, 0x8dU, 0xd5U, 0x4eU, 0xa9U,\n    0x6cU, 0x56U, 0xf4U, 0xeaU, 0x65U, 0x7aU, 0xaeU, 0x08U,\n    0xbaU, 0x78U, 0x25U, 0x2eU, 0x1cU, 0xa6U, 0xb4U, 0xc6U,\n    0xe8U, 0xddU, 0x74U, 0x1fU, 0x4bU, 0xbdU, 0x8bU, 0x8aU,\n    0x70U, 0x3eU, 0xb5U, 0x66U, 0x48U, 0x03U, 0xf6U, 0x0eU,\n    0x61U, 0x35U, 0x57U, 0xb9U, 0x86U, 0xc1U, 0x1dU, 0x9eU,\n    0xe1U, 0xf8U, 0x98U, 0x11U, 0x69U, 0xd9U, 0x8eU, 0x94U,\n    0x9bU, 0x1eU, 0x87U, 0xe9U, 0xceU, 0x55U, 0x28U, 0xdfU,\n    0x8cU, 0xa1U, 0x89U, 0x0dU, 0xbfU, 0xe6U, 0x42U, 0x68U,\n    0x41U, 0x99U, 0x2dU, 0x0fU, 0xb0U, 0x54U, 0xbbU, 0x16U\n};\nstatic const u32 rcon[] = {\n    0x01000000, 0x02000000, 0x04000000, 0x08000000,\n    0x10000000, 0x20000000, 0x40000000, 0x80000000,\n    0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */\n};\n\n/**\n * Expand the cipher key into the encryption key schedule.\n */\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key)\n{\n    u32 *rk;\n    int i = 0;\n    u32 temp;\n\n    if (!userKey || !key)\n        return -1;\n    if (bits != 128 && bits != 192 && bits != 256)\n        return -2;\n\n    rk = key->rd_key;\n\n    if (bits == 128)\n        key->rounds = 10;\n    else if (bits == 192)\n        key->rounds = 12;\n    else\n        key->rounds = 14;\n\n    rk[0] = GETU32(userKey     );\n    rk[1] = GETU32(userKey +  4);\n    rk[2] = GETU32(userKey +  8);\n    rk[3] = GETU32(userKey + 12);\n    if (bits == 128) {\n        while (1) {\n            temp  = rk[3];\n            rk[4] = rk[0] ^\n                ((u32)Te4[(temp >> 16) & 0xff] << 24) ^\n                ((u32)Te4[(temp >>  8) & 0xff] << 16) ^\n                ((u32)Te4[(temp      ) & 0xff] << 8) ^\n                ((u32)Te4[(temp >> 24)       ]) ^\n                rcon[i];\n            rk[5] = rk[1] ^ rk[4];\n            rk[6] = rk[2] ^ rk[5];\n            rk[7] = rk[3] ^ rk[6];\n            if (++i == 10) {\n                return 0;\n            }\n            rk += 4;\n        }\n    }\n    rk[4] = GETU32(userKey + 16);\n    rk[5] = GETU32(userKey + 20);\n    if (bits == 192) {\n        while (1) {\n            temp = rk[ 5];\n            rk[ 6] = rk[ 0] ^\n                ((u32)Te4[(temp >> 16) & 0xff] << 24) ^\n                ((u32)Te4[(temp >>  8) & 0xff] << 16) ^\n                ((u32)Te4[(temp      ) & 0xff] << 8) ^\n                ((u32)Te4[(temp >> 24)       ]) ^\n                rcon[i];\n            rk[ 7] = rk[ 1] ^ rk[ 6];\n            rk[ 8] = rk[ 2] ^ rk[ 7];\n            rk[ 9] = rk[ 3] ^ rk[ 8];\n            if (++i == 8) {\n                return 0;\n            }\n            rk[10] = rk[ 4] ^ rk[ 9];\n            rk[11] = rk[ 5] ^ rk[10];\n            rk += 6;\n        }\n    }\n    rk[6] = GETU32(userKey + 24);\n    rk[7] = GETU32(userKey + 28);\n    if (bits == 256) {\n        while (1) {\n            temp = rk[ 7];\n            rk[ 8] = rk[ 0] ^\n                ((u32)Te4[(temp >> 16) & 0xff] << 24) ^\n                ((u32)Te4[(temp >>  8) & 0xff] << 16) ^\n                ((u32)Te4[(temp      ) & 0xff] << 8) ^\n                ((u32)Te4[(temp >> 24)       ]) ^\n                rcon[i];\n            rk[ 9] = rk[ 1] ^ rk[ 8];\n            rk[10] = rk[ 2] ^ rk[ 9];\n            rk[11] = rk[ 3] ^ rk[10];\n            if (++i == 7) {\n                return 0;\n            }\n            temp = rk[11];\n            rk[12] = rk[ 4] ^\n                ((u32)Te4[(temp >> 24)       ] << 24) ^\n                ((u32)Te4[(temp >> 16) & 0xff] << 16) ^\n                ((u32)Te4[(temp >>  8) & 0xff] << 8) ^\n                ((u32)Te4[(temp      ) & 0xff]);\n            rk[13] = rk[ 5] ^ rk[12];\n            rk[14] = rk[ 6] ^ rk[13];\n            rk[15] = rk[ 7] ^ rk[14];\n\n            rk += 8;\n        }\n    }\n    return 0;\n}\n\n/**\n * Expand the cipher key into the decryption key schedule.\n */\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key)\n{\n\n    u32 *rk;\n    int i, j, status;\n    u32 temp;\n\n    /* first, start with an encryption schedule */\n    status = AES_set_encrypt_key(userKey, bits, key);\n    if (status < 0)\n        return status;\n\n    rk = key->rd_key;\n\n    /* invert the order of the round keys: */\n    for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {\n        temp = rk[i    ]; rk[i    ] = rk[j    ]; rk[j    ] = temp;\n        temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;\n        temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;\n        temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;\n    }\n    /* apply the inverse MixColumn transform to all round keys but the first and the last: */\n    for (i = 1; i < (key->rounds); i++) {\n        rk += 4;\n        for (j = 0; j < 4; j++) {\n            u32 tp1, tp2, tp4, tp8, tp9, tpb, tpd, tpe, m;\n\n            tp1 = rk[j];\n            m = tp1 & 0x80808080;\n            tp2 = ((tp1 & 0x7f7f7f7f) << 1) ^\n                ((m - (m >> 7)) & 0x1b1b1b1b);\n            m = tp2 & 0x80808080;\n            tp4 = ((tp2 & 0x7f7f7f7f) << 1) ^\n                ((m - (m >> 7)) & 0x1b1b1b1b);\n            m = tp4 & 0x80808080;\n            tp8 = ((tp4 & 0x7f7f7f7f) << 1) ^\n                ((m - (m >> 7)) & 0x1b1b1b1b);\n            tp9 = tp8 ^ tp1;\n            tpb = tp9 ^ tp2;\n            tpd = tp9 ^ tp4;\n            tpe = tp8 ^ tp4 ^ tp2;\n#if defined(ROTATE)\n            rk[j] = tpe ^ ROTATE(tpd,16) ^\n                ROTATE(tp9,24) ^ ROTATE(tpb,8);\n#else\n            rk[j] = tpe ^ (tpd >> 16) ^ (tpd << 16) ^\n                (tp9 >> 8) ^ (tp9 << 24) ^\n                (tpb >> 24) ^ (tpb << 8);\n#endif\n        }\n    }\n    return 0;\n}\n\n#endif /* AES_ASM */\n"
  },
  {
    "path": "cryptomini/aes/aes_local.h",
    "content": "/*\n * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_AES_LOCAL_H\n# define OSSL_CRYPTO_AES_LOCAL_H\n\n# include <openssl/e_os2.h>\n# include <stdio.h>\n# include <stdlib.h>\n# include <string.h>\n\n# if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64))\n#  define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)\n#  define GETU32(p) SWAP(*((u32 *)(p)))\n#  define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }\n# else\n#  define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] <<  8) ^ ((u32)(pt)[3]))\n#  define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >>  8); (ct)[3] = (u8)(st); }\n# endif\n\ntypedef unsigned long long u64;\n# ifdef AES_LONG\ntypedef unsigned long u32;\n# else\ntypedef unsigned int u32;\n# endif\ntypedef unsigned short u16;\ntypedef unsigned char u8;\n\n# define MAXKC   (256/32)\n# define MAXKB   (256/8)\n# define MAXNR   14\n\n/* This controls loop-unrolling in aes_core.c */\n# undef FULL_UNROLL\n\n#endif                          /* !OSSL_CRYPTO_AES_LOCAL_H */\n"
  },
  {
    "path": "cryptomini/bn/README.pod",
    "content": "=pod\n\n=head1 NAME\n\nbn_mul_words, bn_mul_add_words, bn_sqr_words, bn_div_words,\nbn_add_words, bn_sub_words, bn_mul_comba4, bn_mul_comba8,\nbn_sqr_comba4, bn_sqr_comba8, bn_cmp_words, bn_mul_normal,\nbn_mul_low_normal, bn_mul_recursive, bn_mul_part_recursive,\nbn_mul_low_recursive, bn_sqr_normal, bn_sqr_recursive,\nbn_expand, bn_wexpand, bn_expand2, bn_fix_top, bn_check_top,\nbn_print, bn_dump, bn_set_max, bn_set_high, bn_set_low - BIGNUM\nlibrary internal functions\n\n=head1 SYNOPSIS\n\n #include <openssl/bn.h>\n\n BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);\n BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num,\n   BN_ULONG w);\n void     bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);\n BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);\n BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,\n   int num);\n BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,\n   int num);\n\n void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);\n void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);\n void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a);\n void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a);\n\n int bn_cmp_words(BN_ULONG *a, BN_ULONG *b, int n);\n\n void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b,\n   int nb);\n void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);\n void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,\n   int dna, int dnb, BN_ULONG *tmp);\n void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,\n   int n, int tna, int tnb, BN_ULONG *tmp);\n void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,\n   int n2, BN_ULONG *tmp);\n\n void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp);\n void bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *tmp);\n\n void mul(BN_ULONG r, BN_ULONG a, BN_ULONG w, BN_ULONG c);\n void mul_add(BN_ULONG r, BN_ULONG a, BN_ULONG w, BN_ULONG c);\n void sqr(BN_ULONG r0, BN_ULONG r1, BN_ULONG a);\n\n BIGNUM *bn_expand(BIGNUM *a, int bits);\n BIGNUM *bn_wexpand(BIGNUM *a, int n);\n BIGNUM *bn_expand2(BIGNUM *a, int n);\n void bn_fix_top(BIGNUM *a);\n\n void bn_check_top(BIGNUM *a);\n void bn_print(BIGNUM *a);\n void bn_dump(BN_ULONG *d, int n);\n void bn_set_max(BIGNUM *a);\n void bn_set_high(BIGNUM *r, BIGNUM *a, int n);\n void bn_set_low(BIGNUM *r, BIGNUM *a, int n);\n\n=head1 DESCRIPTION\n\nThis page documents the internal functions used by the OpenSSL\nB<BIGNUM> implementation. They are described here to facilitate\ndebugging and extending the library. They are I<not> to be used by\napplications.\n\n=head2 The BIGNUM structure\n\n typedef struct bignum_st BIGNUM;\n\n struct bignum_st\n        {\n        BN_ULONG *d;    /* Pointer to an array of 'BN_BITS2' bit chunks. */\n        int top;        /* Index of last used d +1. */\n        /* The next are internal book keeping for bn_expand. */\n        int dmax;       /* Size of the d array. */\n        int neg;        /* one if the number is negative */\n        int flags;\n        };\n\n\nThe integer value is stored in B<d>, a malloc()ed array of words (B<BN_ULONG>),\nleast significant word first. A B<BN_ULONG> can be either 16, 32 or 64 bits\nin size, depending on the 'number of bits' (B<BITS2>) specified in\nC<openssl/bn.h>.\n\nB<dmax> is the size of the B<d> array that has been allocated.  B<top>\nis the number of words being used, so for a value of 4, bn.d[0]=4 and\nbn.top=1.  B<neg> is 1 if the number is negative.  When a B<BIGNUM> is\nB<0>, the B<d> field can be B<NULL> and B<top> == B<0>.\n\nB<flags> is a bit field of flags which are defined in C<openssl/bn.h>. The\nflags begin with B<BN_FLG_>. The macros BN_set_flags(b, n) and\nBN_get_flags(b, n) exist to enable or fetch flag(s) B<n> from B<BIGNUM>\nstructure B<b>.\n\nVarious routines in this library require the use of temporary\nB<BIGNUM> variables during their execution.  Since dynamic memory\nallocation to create B<BIGNUM>s is rather expensive when used in\nconjunction with repeated subroutine calls, the B<BN_CTX> structure is\nused.  This structure contains B<BN_CTX_NUM> B<BIGNUM>s, see\nL<BN_CTX_start(3)>.\n\n=head2 Low-level arithmetic operations\n\nThese functions are implemented in C and for several platforms in\nassembly language:\n\nbn_mul_words(B<rp>, B<ap>, B<num>, B<w>) operates on the B<num> word\narrays B<rp> and B<ap>.  It computes B<ap> * B<w>, places the result\nin B<rp>, and returns the high word (carry).\n\nbn_mul_add_words(B<rp>, B<ap>, B<num>, B<w>) operates on the B<num>\nword arrays B<rp> and B<ap>.  It computes B<ap> * B<w> + B<rp>, places\nthe result in B<rp>, and returns the high word (carry).\n\nbn_sqr_words(B<rp>, B<ap>, B<n>) operates on the B<num> word array\nB<ap> and the 2*B<num> word array B<ap>.  It computes B<ap> * B<ap>\nword-wise, and places the low and high bytes of the result in B<rp>.\n\nbn_div_words(B<h>, B<l>, B<d>) divides the two word number (B<h>, B<l>)\nby B<d> and returns the result.\n\nbn_add_words(B<rp>, B<ap>, B<bp>, B<num>) operates on the B<num> word\narrays B<ap>, B<bp> and B<rp>.  It computes B<ap> + B<bp>, places the\nresult in B<rp>, and returns the high word (carry).\n\nbn_sub_words(B<rp>, B<ap>, B<bp>, B<num>) operates on the B<num> word\narrays B<ap>, B<bp> and B<rp>.  It computes B<ap> - B<bp>, places the\nresult in B<rp>, and returns the carry (1 if B<bp> E<gt> B<ap>, 0\notherwise).\n\nbn_mul_comba4(B<r>, B<a>, B<b>) operates on the 4 word arrays B<a> and\nB<b> and the 8 word array B<r>.  It computes B<a>*B<b> and places the\nresult in B<r>.\n\nbn_mul_comba8(B<r>, B<a>, B<b>) operates on the 8 word arrays B<a> and\nB<b> and the 16 word array B<r>.  It computes B<a>*B<b> and places the\nresult in B<r>.\n\nbn_sqr_comba4(B<r>, B<a>, B<b>) operates on the 4 word arrays B<a> and\nB<b> and the 8 word array B<r>.\n\nbn_sqr_comba8(B<r>, B<a>, B<b>) operates on the 8 word arrays B<a> and\nB<b> and the 16 word array B<r>.\n\nThe following functions are implemented in C:\n\nbn_cmp_words(B<a>, B<b>, B<n>) operates on the B<n> word arrays B<a>\nand B<b>.  It returns 1, 0 and -1 if B<a> is greater than, equal and\nless than B<b>.\n\nbn_mul_normal(B<r>, B<a>, B<na>, B<b>, B<nb>) operates on the B<na>\nword array B<a>, the B<nb> word array B<b> and the B<na>+B<nb> word\narray B<r>.  It computes B<a>*B<b> and places the result in B<r>.\n\nbn_mul_low_normal(B<r>, B<a>, B<b>, B<n>) operates on the B<n> word\narrays B<r>, B<a> and B<b>.  It computes the B<n> low words of\nB<a>*B<b> and places the result in B<r>.\n\nbn_mul_recursive(B<r>, B<a>, B<b>, B<n2>, B<dna>, B<dnb>, B<t>) operates\non the word arrays B<a> and B<b> of length B<n2>+B<dna> and B<n2>+B<dnb>\n(B<dna> and B<dnb> are currently allowed to be 0 or negative) and the 2*B<n2>\nword arrays B<r> and B<t>.  B<n2> must be a power of 2.  It computes\nB<a>*B<b> and places the result in B<r>.\n\nbn_mul_part_recursive(B<r>, B<a>, B<b>, B<n>, B<tna>, B<tnb>, B<tmp>)\noperates on the word arrays B<a> and B<b> of length B<n>+B<tna> and\nB<n>+B<tnb> and the 4*B<n> word arrays B<r> and B<tmp>.\n\nbn_mul_low_recursive(B<r>, B<a>, B<b>, B<n2>, B<tmp>) operates on the\nB<n2> word arrays B<r> and B<tmp> and the B<n2>/2 word arrays B<a>\nand B<b>.\n\nBN_mul() calls bn_mul_normal(), or an optimized implementation if the\nfactors have the same size: bn_mul_comba8() is used if they are 8\nwords long, bn_mul_recursive() if they are larger than\nB<BN_MULL_SIZE_NORMAL> and the size is an exact multiple of the word\nsize, and bn_mul_part_recursive() for others that are larger than\nB<BN_MULL_SIZE_NORMAL>.\n\nbn_sqr_normal(B<r>, B<a>, B<n>, B<tmp>) operates on the B<n> word array\nB<a> and the 2*B<n> word arrays B<tmp> and B<r>.\n\nThe implementations use the following macros which, depending on the\narchitecture, may use \"long long\" C operations or inline assembler.\nThey are defined in C<bn_local.h>.\n\nmul(B<r>, B<a>, B<w>, B<c>) computes B<w>*B<a>+B<c> and places the\nlow word of the result in B<r> and the high word in B<c>.\n\nmul_add(B<r>, B<a>, B<w>, B<c>) computes B<w>*B<a>+B<r>+B<c> and\nplaces the low word of the result in B<r> and the high word in B<c>.\n\nsqr(B<r0>, B<r1>, B<a>) computes B<a>*B<a> and places the low word\nof the result in B<r0> and the high word in B<r1>.\n\n=head2 Size changes\n\nbn_expand() ensures that B<b> has enough space for a B<bits> bit\nnumber.  bn_wexpand() ensures that B<b> has enough space for an\nB<n> word number.  If the number has to be expanded, both macros\ncall bn_expand2(), which allocates a new B<d> array and copies the\ndata.  They return B<NULL> on error, B<b> otherwise.\n\nThe bn_fix_top() macro reduces B<a-E<gt>top> to point to the most\nsignificant non-zero word plus one when B<a> has shrunk.\n\n=head2 Debugging\n\nbn_check_top() verifies that C<((a)-E<gt>top E<gt>= 0 && (a)-E<gt>top\nE<lt>= (a)-E<gt>dmax)>.  A violation will cause the program to abort.\n\nbn_print() prints B<a> to stderr. bn_dump() prints B<n> words at B<d>\n(in reverse order, i.e. most significant word first) to stderr.\n\nbn_set_max() makes B<a> a static number with a B<dmax> of its current size.\nThis is used by bn_set_low() and bn_set_high() to make B<r> a read-only\nB<BIGNUM> that contains the B<n> low or high words of B<a>.\n\nIf B<BN_DEBUG> is not defined, bn_check_top(), bn_print(), bn_dump()\nand bn_set_max() are defined as empty macros.\n\n=head1 SEE ALSO\n\nL<bn(3)>\n\n=head1 COPYRIGHT\n\nCopyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.\n\nLicensed under the OpenSSL license (the \"License\").  You may not use\nthis file except in compliance with the License.  You can obtain a copy\nin the file LICENSE in the source distribution or at\nL<https://www.openssl.org/source/license.html>.\n\n=cut\n"
  },
  {
    "path": "cryptomini/bn/bn_add.c",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\n/* signed add of b to a. */\nint BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n{\n    int ret, r_neg, cmp_res;\n\n    bn_check_top(a);\n    bn_check_top(b);\n\n    if (a->neg == b->neg) {\n        r_neg = a->neg;\n        ret = BN_uadd(r, a, b);\n    } else {\n        cmp_res = BN_ucmp(a, b);\n        if (cmp_res > 0) {\n            r_neg = a->neg;\n            ret = BN_usub(r, a, b);\n        } else if (cmp_res < 0) {\n            r_neg = b->neg;\n            ret = BN_usub(r, b, a);\n        } else {\n            r_neg = 0;\n            BN_zero(r);\n            ret = 1;\n        }\n    }\n\n    r->neg = r_neg;\n    bn_check_top(r);\n    return ret;\n}\n\n/* signed sub of b from a. */\nint BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n{\n    int ret, r_neg, cmp_res;\n\n    bn_check_top(a);\n    bn_check_top(b);\n\n    if (a->neg != b->neg) {\n        r_neg = a->neg;\n        ret = BN_uadd(r, a, b);\n    } else {\n        cmp_res = BN_ucmp(a, b);\n        if (cmp_res > 0) {\n            r_neg = a->neg;\n            ret = BN_usub(r, a, b);\n        } else if (cmp_res < 0) {\n            r_neg = !b->neg;\n            ret = BN_usub(r, b, a);\n        } else {\n            r_neg = 0;\n            BN_zero(r);\n            ret = 1;\n        }\n    }\n\n    r->neg = r_neg;\n    bn_check_top(r);\n    return ret;\n}\n\n/* unsigned add of b to a, r can be equal to a or b. */\nint BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n{\n    int max, min, dif;\n    const BN_ULONG *ap, *bp;\n    BN_ULONG *rp, carry, t1, t2;\n\n    bn_check_top(a);\n    bn_check_top(b);\n\n    if (a->top < b->top) {\n        const BIGNUM *tmp;\n\n        tmp = a;\n        a = b;\n        b = tmp;\n    }\n    max = a->top;\n    min = b->top;\n    dif = max - min;\n\n    if (bn_wexpand(r, max + 1) == NULL)\n        return 0;\n\n    r->top = max;\n\n    ap = a->d;\n    bp = b->d;\n    rp = r->d;\n\n    carry = bn_add_words(rp, ap, bp, min);\n    rp += min;\n    ap += min;\n\n    while (dif) {\n        dif--;\n        t1 = *(ap++);\n        t2 = (t1 + carry) & BN_MASK2;\n        *(rp++) = t2;\n        carry &= (t2 == 0);\n    }\n    *rp = carry;\n    r->top += carry;\n\n    r->neg = 0;\n    bn_check_top(r);\n    return 1;\n}\n\n/* unsigned subtraction of b from a, a must be larger than b. */\nint BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n{\n    int max, min, dif;\n    BN_ULONG t1, t2, borrow, *rp;\n    const BN_ULONG *ap, *bp;\n\n    bn_check_top(a);\n    bn_check_top(b);\n\n    max = a->top;\n    min = b->top;\n    dif = max - min;\n\n    if (dif < 0) {              /* hmm... should not be happening */\n        BNerr(BN_F_BN_USUB, BN_R_ARG2_LT_ARG3);\n        return 0;\n    }\n\n    if (bn_wexpand(r, max) == NULL)\n        return 0;\n\n    ap = a->d;\n    bp = b->d;\n    rp = r->d;\n\n    borrow = bn_sub_words(rp, ap, bp, min);\n    ap += min;\n    rp += min;\n\n    while (dif) {\n        dif--;\n        t1 = *(ap++);\n        t2 = (t1 - borrow) & BN_MASK2;\n        *(rp++) = t2;\n        borrow &= (t1 == 0);\n    }\n\n    while (max && *--rp == 0)\n        max--;\n\n    r->top = max;\n    r->neg = 0;\n    bn_pollute(r);\n\n    return 1;\n}\n\n"
  },
  {
    "path": "cryptomini/bn/bn_asm.c",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <assert.h>\n#include <openssl/crypto.h>\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\n#if defined(BN_LLONG) || defined(BN_UMULT_HIGH)\n\nBN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,\n                          BN_ULONG w)\n{\n    BN_ULONG c1 = 0;\n\n    assert(num >= 0);\n    if (num <= 0)\n        return c1;\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n    while (num & ~3) {\n        mul_add(rp[0], ap[0], w, c1);\n        mul_add(rp[1], ap[1], w, c1);\n        mul_add(rp[2], ap[2], w, c1);\n        mul_add(rp[3], ap[3], w, c1);\n        ap += 4;\n        rp += 4;\n        num -= 4;\n    }\n# endif\n    while (num) {\n        mul_add(rp[0], ap[0], w, c1);\n        ap++;\n        rp++;\n        num--;\n    }\n\n    return c1;\n}\n\nBN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)\n{\n    BN_ULONG c1 = 0;\n\n    assert(num >= 0);\n    if (num <= 0)\n        return c1;\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n    while (num & ~3) {\n        mul(rp[0], ap[0], w, c1);\n        mul(rp[1], ap[1], w, c1);\n        mul(rp[2], ap[2], w, c1);\n        mul(rp[3], ap[3], w, c1);\n        ap += 4;\n        rp += 4;\n        num -= 4;\n    }\n# endif\n    while (num) {\n        mul(rp[0], ap[0], w, c1);\n        ap++;\n        rp++;\n        num--;\n    }\n    return c1;\n}\n\nvoid bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)\n{\n    assert(n >= 0);\n    if (n <= 0)\n        return;\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n    while (n & ~3) {\n        sqr(r[0], r[1], a[0]);\n        sqr(r[2], r[3], a[1]);\n        sqr(r[4], r[5], a[2]);\n        sqr(r[6], r[7], a[3]);\n        a += 4;\n        r += 8;\n        n -= 4;\n    }\n# endif\n    while (n) {\n        sqr(r[0], r[1], a[0]);\n        a++;\n        r += 2;\n        n--;\n    }\n}\n\n#else                           /* !(defined(BN_LLONG) ||\n                                 * defined(BN_UMULT_HIGH)) */\n\nBN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,\n                          BN_ULONG w)\n{\n    BN_ULONG c = 0;\n    BN_ULONG bl, bh;\n\n    assert(num >= 0);\n    if (num <= 0)\n        return (BN_ULONG)0;\n\n    bl = LBITS(w);\n    bh = HBITS(w);\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n    while (num & ~3) {\n        mul_add(rp[0], ap[0], bl, bh, c);\n        mul_add(rp[1], ap[1], bl, bh, c);\n        mul_add(rp[2], ap[2], bl, bh, c);\n        mul_add(rp[3], ap[3], bl, bh, c);\n        ap += 4;\n        rp += 4;\n        num -= 4;\n    }\n# endif\n    while (num) {\n        mul_add(rp[0], ap[0], bl, bh, c);\n        ap++;\n        rp++;\n        num--;\n    }\n    return c;\n}\n\nBN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)\n{\n    BN_ULONG carry = 0;\n    BN_ULONG bl, bh;\n\n    assert(num >= 0);\n    if (num <= 0)\n        return (BN_ULONG)0;\n\n    bl = LBITS(w);\n    bh = HBITS(w);\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n    while (num & ~3) {\n        mul(rp[0], ap[0], bl, bh, carry);\n        mul(rp[1], ap[1], bl, bh, carry);\n        mul(rp[2], ap[2], bl, bh, carry);\n        mul(rp[3], ap[3], bl, bh, carry);\n        ap += 4;\n        rp += 4;\n        num -= 4;\n    }\n# endif\n    while (num) {\n        mul(rp[0], ap[0], bl, bh, carry);\n        ap++;\n        rp++;\n        num--;\n    }\n    return carry;\n}\n\nvoid bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)\n{\n    assert(n >= 0);\n    if (n <= 0)\n        return;\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n    while (n & ~3) {\n        sqr64(r[0], r[1], a[0]);\n        sqr64(r[2], r[3], a[1]);\n        sqr64(r[4], r[5], a[2]);\n        sqr64(r[6], r[7], a[3]);\n        a += 4;\n        r += 8;\n        n -= 4;\n    }\n# endif\n    while (n) {\n        sqr64(r[0], r[1], a[0]);\n        a++;\n        r += 2;\n        n--;\n    }\n}\n\n#endif                          /* !(defined(BN_LLONG) ||\n                                 * defined(BN_UMULT_HIGH)) */\n\n#if defined(BN_LLONG) && defined(BN_DIV2W)\n\nBN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)\n{\n    return ((BN_ULONG)(((((BN_ULLONG) h) << BN_BITS2) | l) / (BN_ULLONG) d));\n}\n\n#else\n\n/* Divide h,l by d and return the result. */\n/* I need to test this some more :-( */\nBN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)\n{\n    BN_ULONG dh, dl, q, ret = 0, th, tl, t;\n    int i, count = 2;\n\n    if (d == 0)\n        return BN_MASK2;\n\n    i = BN_num_bits_word(d);\n    assert((i == BN_BITS2) || (h <= (BN_ULONG)1 << i));\n\n    i = BN_BITS2 - i;\n    if (h >= d)\n        h -= d;\n\n    if (i) {\n        d <<= i;\n        h = (h << i) | (l >> (BN_BITS2 - i));\n        l <<= i;\n    }\n    dh = (d & BN_MASK2h) >> BN_BITS4;\n    dl = (d & BN_MASK2l);\n    for (;;) {\n        if ((h >> BN_BITS4) == dh)\n            q = BN_MASK2l;\n        else\n            q = h / dh;\n\n        th = q * dh;\n        tl = dl * q;\n        for (;;) {\n            t = h - th;\n            if ((t & BN_MASK2h) ||\n                ((tl) <= ((t << BN_BITS4) | ((l & BN_MASK2h) >> BN_BITS4))))\n                break;\n            q--;\n            th -= dh;\n            tl -= dl;\n        }\n        t = (tl >> BN_BITS4);\n        tl = (tl << BN_BITS4) & BN_MASK2h;\n        th += t;\n\n        if (l < tl)\n            th++;\n        l -= tl;\n        if (h < th) {\n            h += d;\n            q--;\n        }\n        h -= th;\n\n        if (--count == 0)\n            break;\n\n        ret = q << BN_BITS4;\n        h = ((h << BN_BITS4) | (l >> BN_BITS4)) & BN_MASK2;\n        l = (l & BN_MASK2l) << BN_BITS4;\n    }\n    ret |= q;\n    return ret;\n}\n#endif                          /* !defined(BN_LLONG) && defined(BN_DIV2W) */\n\n#ifdef BN_LLONG\nBN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,\n                      int n)\n{\n    BN_ULLONG ll = 0;\n\n    assert(n >= 0);\n    if (n <= 0)\n        return (BN_ULONG)0;\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n    while (n & ~3) {\n        ll += (BN_ULLONG) a[0] + b[0];\n        r[0] = (BN_ULONG)ll & BN_MASK2;\n        ll >>= BN_BITS2;\n        ll += (BN_ULLONG) a[1] + b[1];\n        r[1] = (BN_ULONG)ll & BN_MASK2;\n        ll >>= BN_BITS2;\n        ll += (BN_ULLONG) a[2] + b[2];\n        r[2] = (BN_ULONG)ll & BN_MASK2;\n        ll >>= BN_BITS2;\n        ll += (BN_ULLONG) a[3] + b[3];\n        r[3] = (BN_ULONG)ll & BN_MASK2;\n        ll >>= BN_BITS2;\n        a += 4;\n        b += 4;\n        r += 4;\n        n -= 4;\n    }\n# endif\n    while (n) {\n        ll += (BN_ULLONG) a[0] + b[0];\n        r[0] = (BN_ULONG)ll & BN_MASK2;\n        ll >>= BN_BITS2;\n        a++;\n        b++;\n        r++;\n        n--;\n    }\n    return (BN_ULONG)ll;\n}\n#else                           /* !BN_LLONG */\nBN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,\n                      int n)\n{\n    BN_ULONG c, l, t;\n\n    assert(n >= 0);\n    if (n <= 0)\n        return (BN_ULONG)0;\n\n    c = 0;\n# ifndef OPENSSL_SMALL_FOOTPRINT\n    while (n & ~3) {\n        t = a[0];\n        t = (t + c) & BN_MASK2;\n        c = (t < c);\n        l = (t + b[0]) & BN_MASK2;\n        c += (l < t);\n        r[0] = l;\n        t = a[1];\n        t = (t + c) & BN_MASK2;\n        c = (t < c);\n        l = (t + b[1]) & BN_MASK2;\n        c += (l < t);\n        r[1] = l;\n        t = a[2];\n        t = (t + c) & BN_MASK2;\n        c = (t < c);\n        l = (t + b[2]) & BN_MASK2;\n        c += (l < t);\n        r[2] = l;\n        t = a[3];\n        t = (t + c) & BN_MASK2;\n        c = (t < c);\n        l = (t + b[3]) & BN_MASK2;\n        c += (l < t);\n        r[3] = l;\n        a += 4;\n        b += 4;\n        r += 4;\n        n -= 4;\n    }\n# endif\n    while (n) {\n        t = a[0];\n        t = (t + c) & BN_MASK2;\n        c = (t < c);\n        l = (t + b[0]) & BN_MASK2;\n        c += (l < t);\n        r[0] = l;\n        a++;\n        b++;\n        r++;\n        n--;\n    }\n    return (BN_ULONG)c;\n}\n#endif                          /* !BN_LLONG */\n\nBN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,\n                      int n)\n{\n    BN_ULONG t1, t2;\n    int c = 0;\n\n    assert(n >= 0);\n    if (n <= 0)\n        return (BN_ULONG)0;\n\n#ifndef OPENSSL_SMALL_FOOTPRINT\n    while (n & ~3) {\n        t1 = a[0];\n        t2 = b[0];\n        r[0] = (t1 - t2 - c) & BN_MASK2;\n        if (t1 != t2)\n            c = (t1 < t2);\n        t1 = a[1];\n        t2 = b[1];\n        r[1] = (t1 - t2 - c) & BN_MASK2;\n        if (t1 != t2)\n            c = (t1 < t2);\n        t1 = a[2];\n        t2 = b[2];\n        r[2] = (t1 - t2 - c) & BN_MASK2;\n        if (t1 != t2)\n            c = (t1 < t2);\n        t1 = a[3];\n        t2 = b[3];\n        r[3] = (t1 - t2 - c) & BN_MASK2;\n        if (t1 != t2)\n            c = (t1 < t2);\n        a += 4;\n        b += 4;\n        r += 4;\n        n -= 4;\n    }\n#endif\n    while (n) {\n        t1 = a[0];\n        t2 = b[0];\n        r[0] = (t1 - t2 - c) & BN_MASK2;\n        if (t1 != t2)\n            c = (t1 < t2);\n        a++;\n        b++;\n        r++;\n        n--;\n    }\n    return c;\n}\n\n#if defined(BN_MUL_COMBA) && !defined(OPENSSL_SMALL_FOOTPRINT)\n\n# undef bn_mul_comba8\n# undef bn_mul_comba4\n# undef bn_sqr_comba8\n# undef bn_sqr_comba4\n\n/* mul_add_c(a,b,c0,c1,c2)  -- c+=a*b for three word number c=(c2,c1,c0) */\n/* mul_add_c2(a,b,c0,c1,c2) -- c+=2*a*b for three word number c=(c2,c1,c0) */\n/* sqr_add_c(a,i,c0,c1,c2)  -- c+=a[i]^2 for three word number c=(c2,c1,c0) */\n/*\n * sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number\n * c=(c2,c1,c0)\n */\n\n# ifdef BN_LLONG\n/*\n * Keep in mind that additions to multiplication result can not\n * overflow, because its high half cannot be all-ones.\n */\n#  define mul_add_c(a,b,c0,c1,c2)       do {    \\\n        BN_ULONG hi;                            \\\n        BN_ULLONG t = (BN_ULLONG)(a)*(b);       \\\n        t += c0;                /* no carry */  \\\n        c0 = (BN_ULONG)Lw(t);                   \\\n        hi = (BN_ULONG)Hw(t);                   \\\n        c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \\\n        } while(0)\n\n#  define mul_add_c2(a,b,c0,c1,c2)      do {    \\\n        BN_ULONG hi;                            \\\n        BN_ULLONG t = (BN_ULLONG)(a)*(b);       \\\n        BN_ULLONG tt = t+c0;    /* no carry */  \\\n        c0 = (BN_ULONG)Lw(tt);                  \\\n        hi = (BN_ULONG)Hw(tt);                  \\\n        c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \\\n        t += c0;                /* no carry */  \\\n        c0 = (BN_ULONG)Lw(t);                   \\\n        hi = (BN_ULONG)Hw(t);                   \\\n        c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \\\n        } while(0)\n\n#  define sqr_add_c(a,i,c0,c1,c2)       do {    \\\n        BN_ULONG hi;                            \\\n        BN_ULLONG t = (BN_ULLONG)a[i]*a[i];     \\\n        t += c0;                /* no carry */  \\\n        c0 = (BN_ULONG)Lw(t);                   \\\n        hi = (BN_ULONG)Hw(t);                   \\\n        c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \\\n        } while(0)\n\n#  define sqr_add_c2(a,i,j,c0,c1,c2) \\\n        mul_add_c2((a)[i],(a)[j],c0,c1,c2)\n\n# elif defined(BN_UMULT_LOHI)\n/*\n * Keep in mind that additions to hi can not overflow, because\n * the high word of a multiplication result cannot be all-ones.\n */\n#  define mul_add_c(a,b,c0,c1,c2)       do {    \\\n        BN_ULONG ta = (a), tb = (b);            \\\n        BN_ULONG lo, hi;                        \\\n        BN_UMULT_LOHI(lo,hi,ta,tb);             \\\n        c0 += lo; hi += (c0<lo)?1:0;            \\\n        c1 += hi; c2 += (c1<hi)?1:0;            \\\n        } while(0)\n\n#  define mul_add_c2(a,b,c0,c1,c2)      do {    \\\n        BN_ULONG ta = (a), tb = (b);            \\\n        BN_ULONG lo, hi, tt;                    \\\n        BN_UMULT_LOHI(lo,hi,ta,tb);             \\\n        c0 += lo; tt = hi+((c0<lo)?1:0);        \\\n        c1 += tt; c2 += (c1<tt)?1:0;            \\\n        c0 += lo; hi += (c0<lo)?1:0;            \\\n        c1 += hi; c2 += (c1<hi)?1:0;            \\\n        } while(0)\n\n#  define sqr_add_c(a,i,c0,c1,c2)       do {    \\\n        BN_ULONG ta = (a)[i];                   \\\n        BN_ULONG lo, hi;                        \\\n        BN_UMULT_LOHI(lo,hi,ta,ta);             \\\n        c0 += lo; hi += (c0<lo)?1:0;            \\\n        c1 += hi; c2 += (c1<hi)?1:0;            \\\n        } while(0)\n\n#  define sqr_add_c2(a,i,j,c0,c1,c2)    \\\n        mul_add_c2((a)[i],(a)[j],c0,c1,c2)\n\n# elif defined(BN_UMULT_HIGH)\n/*\n * Keep in mind that additions to hi can not overflow, because\n * the high word of a multiplication result cannot be all-ones.\n */\n#  define mul_add_c(a,b,c0,c1,c2)       do {    \\\n        BN_ULONG ta = (a), tb = (b);            \\\n        BN_ULONG lo = ta * tb;                  \\\n        BN_ULONG hi = BN_UMULT_HIGH(ta,tb);     \\\n        c0 += lo; hi += (c0<lo)?1:0;            \\\n        c1 += hi; c2 += (c1<hi)?1:0;            \\\n        } while(0)\n\n#  define mul_add_c2(a,b,c0,c1,c2)      do {    \\\n        BN_ULONG ta = (a), tb = (b), tt;        \\\n        BN_ULONG lo = ta * tb;                  \\\n        BN_ULONG hi = BN_UMULT_HIGH(ta,tb);     \\\n        c0 += lo; tt = hi + ((c0<lo)?1:0);      \\\n        c1 += tt; c2 += (c1<tt)?1:0;            \\\n        c0 += lo; hi += (c0<lo)?1:0;            \\\n        c1 += hi; c2 += (c1<hi)?1:0;            \\\n        } while(0)\n\n#  define sqr_add_c(a,i,c0,c1,c2)       do {    \\\n        BN_ULONG ta = (a)[i];                   \\\n        BN_ULONG lo = ta * ta;                  \\\n        BN_ULONG hi = BN_UMULT_HIGH(ta,ta);     \\\n        c0 += lo; hi += (c0<lo)?1:0;            \\\n        c1 += hi; c2 += (c1<hi)?1:0;            \\\n        } while(0)\n\n#  define sqr_add_c2(a,i,j,c0,c1,c2)      \\\n        mul_add_c2((a)[i],(a)[j],c0,c1,c2)\n\n# else                          /* !BN_LLONG */\n/*\n * Keep in mind that additions to hi can not overflow, because\n * the high word of a multiplication result cannot be all-ones.\n */\n#  define mul_add_c(a,b,c0,c1,c2)       do {    \\\n        BN_ULONG lo = LBITS(a), hi = HBITS(a);  \\\n        BN_ULONG bl = LBITS(b), bh = HBITS(b);  \\\n        mul64(lo,hi,bl,bh);                     \\\n        c0 = (c0+lo)&BN_MASK2; if (c0<lo) hi++; \\\n        c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \\\n        } while(0)\n\n#  define mul_add_c2(a,b,c0,c1,c2)      do {    \\\n        BN_ULONG tt;                            \\\n        BN_ULONG lo = LBITS(a), hi = HBITS(a);  \\\n        BN_ULONG bl = LBITS(b), bh = HBITS(b);  \\\n        mul64(lo,hi,bl,bh);                     \\\n        tt = hi;                                \\\n        c0 = (c0+lo)&BN_MASK2; if (c0<lo) tt++; \\\n        c1 = (c1+tt)&BN_MASK2; if (c1<tt) c2++; \\\n        c0 = (c0+lo)&BN_MASK2; if (c0<lo) hi++; \\\n        c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \\\n        } while(0)\n\n#  define sqr_add_c(a,i,c0,c1,c2)       do {    \\\n        BN_ULONG lo, hi;                        \\\n        sqr64(lo,hi,(a)[i]);                    \\\n        c0 = (c0+lo)&BN_MASK2; if (c0<lo) hi++; \\\n        c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \\\n        } while(0)\n\n#  define sqr_add_c2(a,i,j,c0,c1,c2) \\\n        mul_add_c2((a)[i],(a)[j],c0,c1,c2)\n# endif                         /* !BN_LLONG */\n\nvoid bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)\n{\n    BN_ULONG c1, c2, c3;\n\n    c1 = 0;\n    c2 = 0;\n    c3 = 0;\n    mul_add_c(a[0], b[0], c1, c2, c3);\n    r[0] = c1;\n    c1 = 0;\n    mul_add_c(a[0], b[1], c2, c3, c1);\n    mul_add_c(a[1], b[0], c2, c3, c1);\n    r[1] = c2;\n    c2 = 0;\n    mul_add_c(a[2], b[0], c3, c1, c2);\n    mul_add_c(a[1], b[1], c3, c1, c2);\n    mul_add_c(a[0], b[2], c3, c1, c2);\n    r[2] = c3;\n    c3 = 0;\n    mul_add_c(a[0], b[3], c1, c2, c3);\n    mul_add_c(a[1], b[2], c1, c2, c3);\n    mul_add_c(a[2], b[1], c1, c2, c3);\n    mul_add_c(a[3], b[0], c1, c2, c3);\n    r[3] = c1;\n    c1 = 0;\n    mul_add_c(a[4], b[0], c2, c3, c1);\n    mul_add_c(a[3], b[1], c2, c3, c1);\n    mul_add_c(a[2], b[2], c2, c3, c1);\n    mul_add_c(a[1], b[3], c2, c3, c1);\n    mul_add_c(a[0], b[4], c2, c3, c1);\n    r[4] = c2;\n    c2 = 0;\n    mul_add_c(a[0], b[5], c3, c1, c2);\n    mul_add_c(a[1], b[4], c3, c1, c2);\n    mul_add_c(a[2], b[3], c3, c1, c2);\n    mul_add_c(a[3], b[2], c3, c1, c2);\n    mul_add_c(a[4], b[1], c3, c1, c2);\n    mul_add_c(a[5], b[0], c3, c1, c2);\n    r[5] = c3;\n    c3 = 0;\n    mul_add_c(a[6], b[0], c1, c2, c3);\n    mul_add_c(a[5], b[1], c1, c2, c3);\n    mul_add_c(a[4], b[2], c1, c2, c3);\n    mul_add_c(a[3], b[3], c1, c2, c3);\n    mul_add_c(a[2], b[4], c1, c2, c3);\n    mul_add_c(a[1], b[5], c1, c2, c3);\n    mul_add_c(a[0], b[6], c1, c2, c3);\n    r[6] = c1;\n    c1 = 0;\n    mul_add_c(a[0], b[7], c2, c3, c1);\n    mul_add_c(a[1], b[6], c2, c3, c1);\n    mul_add_c(a[2], b[5], c2, c3, c1);\n    mul_add_c(a[3], b[4], c2, c3, c1);\n    mul_add_c(a[4], b[3], c2, c3, c1);\n    mul_add_c(a[5], b[2], c2, c3, c1);\n    mul_add_c(a[6], b[1], c2, c3, c1);\n    mul_add_c(a[7], b[0], c2, c3, c1);\n    r[7] = c2;\n    c2 = 0;\n    mul_add_c(a[7], b[1], c3, c1, c2);\n    mul_add_c(a[6], b[2], c3, c1, c2);\n    mul_add_c(a[5], b[3], c3, c1, c2);\n    mul_add_c(a[4], b[4], c3, c1, c2);\n    mul_add_c(a[3], b[5], c3, c1, c2);\n    mul_add_c(a[2], b[6], c3, c1, c2);\n    mul_add_c(a[1], b[7], c3, c1, c2);\n    r[8] = c3;\n    c3 = 0;\n    mul_add_c(a[2], b[7], c1, c2, c3);\n    mul_add_c(a[3], b[6], c1, c2, c3);\n    mul_add_c(a[4], b[5], c1, c2, c3);\n    mul_add_c(a[5], b[4], c1, c2, c3);\n    mul_add_c(a[6], b[3], c1, c2, c3);\n    mul_add_c(a[7], b[2], c1, c2, c3);\n    r[9] = c1;\n    c1 = 0;\n    mul_add_c(a[7], b[3], c2, c3, c1);\n    mul_add_c(a[6], b[4], c2, c3, c1);\n    mul_add_c(a[5], b[5], c2, c3, c1);\n    mul_add_c(a[4], b[6], c2, c3, c1);\n    mul_add_c(a[3], b[7], c2, c3, c1);\n    r[10] = c2;\n    c2 = 0;\n    mul_add_c(a[4], b[7], c3, c1, c2);\n    mul_add_c(a[5], b[6], c3, c1, c2);\n    mul_add_c(a[6], b[5], c3, c1, c2);\n    mul_add_c(a[7], b[4], c3, c1, c2);\n    r[11] = c3;\n    c3 = 0;\n    mul_add_c(a[7], b[5], c1, c2, c3);\n    mul_add_c(a[6], b[6], c1, c2, c3);\n    mul_add_c(a[5], b[7], c1, c2, c3);\n    r[12] = c1;\n    c1 = 0;\n    mul_add_c(a[6], b[7], c2, c3, c1);\n    mul_add_c(a[7], b[6], c2, c3, c1);\n    r[13] = c2;\n    c2 = 0;\n    mul_add_c(a[7], b[7], c3, c1, c2);\n    r[14] = c3;\n    r[15] = c1;\n}\n\nvoid bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)\n{\n    BN_ULONG c1, c2, c3;\n\n    c1 = 0;\n    c2 = 0;\n    c3 = 0;\n    mul_add_c(a[0], b[0], c1, c2, c3);\n    r[0] = c1;\n    c1 = 0;\n    mul_add_c(a[0], b[1], c2, c3, c1);\n    mul_add_c(a[1], b[0], c2, c3, c1);\n    r[1] = c2;\n    c2 = 0;\n    mul_add_c(a[2], b[0], c3, c1, c2);\n    mul_add_c(a[1], b[1], c3, c1, c2);\n    mul_add_c(a[0], b[2], c3, c1, c2);\n    r[2] = c3;\n    c3 = 0;\n    mul_add_c(a[0], b[3], c1, c2, c3);\n    mul_add_c(a[1], b[2], c1, c2, c3);\n    mul_add_c(a[2], b[1], c1, c2, c3);\n    mul_add_c(a[3], b[0], c1, c2, c3);\n    r[3] = c1;\n    c1 = 0;\n    mul_add_c(a[3], b[1], c2, c3, c1);\n    mul_add_c(a[2], b[2], c2, c3, c1);\n    mul_add_c(a[1], b[3], c2, c3, c1);\n    r[4] = c2;\n    c2 = 0;\n    mul_add_c(a[2], b[3], c3, c1, c2);\n    mul_add_c(a[3], b[2], c3, c1, c2);\n    r[5] = c3;\n    c3 = 0;\n    mul_add_c(a[3], b[3], c1, c2, c3);\n    r[6] = c1;\n    r[7] = c2;\n}\n\nvoid bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)\n{\n    BN_ULONG c1, c2, c3;\n\n    c1 = 0;\n    c2 = 0;\n    c3 = 0;\n    sqr_add_c(a, 0, c1, c2, c3);\n    r[0] = c1;\n    c1 = 0;\n    sqr_add_c2(a, 1, 0, c2, c3, c1);\n    r[1] = c2;\n    c2 = 0;\n    sqr_add_c(a, 1, c3, c1, c2);\n    sqr_add_c2(a, 2, 0, c3, c1, c2);\n    r[2] = c3;\n    c3 = 0;\n    sqr_add_c2(a, 3, 0, c1, c2, c3);\n    sqr_add_c2(a, 2, 1, c1, c2, c3);\n    r[3] = c1;\n    c1 = 0;\n    sqr_add_c(a, 2, c2, c3, c1);\n    sqr_add_c2(a, 3, 1, c2, c3, c1);\n    sqr_add_c2(a, 4, 0, c2, c3, c1);\n    r[4] = c2;\n    c2 = 0;\n    sqr_add_c2(a, 5, 0, c3, c1, c2);\n    sqr_add_c2(a, 4, 1, c3, c1, c2);\n    sqr_add_c2(a, 3, 2, c3, c1, c2);\n    r[5] = c3;\n    c3 = 0;\n    sqr_add_c(a, 3, c1, c2, c3);\n    sqr_add_c2(a, 4, 2, c1, c2, c3);\n    sqr_add_c2(a, 5, 1, c1, c2, c3);\n    sqr_add_c2(a, 6, 0, c1, c2, c3);\n    r[6] = c1;\n    c1 = 0;\n    sqr_add_c2(a, 7, 0, c2, c3, c1);\n    sqr_add_c2(a, 6, 1, c2, c3, c1);\n    sqr_add_c2(a, 5, 2, c2, c3, c1);\n    sqr_add_c2(a, 4, 3, c2, c3, c1);\n    r[7] = c2;\n    c2 = 0;\n    sqr_add_c(a, 4, c3, c1, c2);\n    sqr_add_c2(a, 5, 3, c3, c1, c2);\n    sqr_add_c2(a, 6, 2, c3, c1, c2);\n    sqr_add_c2(a, 7, 1, c3, c1, c2);\n    r[8] = c3;\n    c3 = 0;\n    sqr_add_c2(a, 7, 2, c1, c2, c3);\n    sqr_add_c2(a, 6, 3, c1, c2, c3);\n    sqr_add_c2(a, 5, 4, c1, c2, c3);\n    r[9] = c1;\n    c1 = 0;\n    sqr_add_c(a, 5, c2, c3, c1);\n    sqr_add_c2(a, 6, 4, c2, c3, c1);\n    sqr_add_c2(a, 7, 3, c2, c3, c1);\n    r[10] = c2;\n    c2 = 0;\n    sqr_add_c2(a, 7, 4, c3, c1, c2);\n    sqr_add_c2(a, 6, 5, c3, c1, c2);\n    r[11] = c3;\n    c3 = 0;\n    sqr_add_c(a, 6, c1, c2, c3);\n    sqr_add_c2(a, 7, 5, c1, c2, c3);\n    r[12] = c1;\n    c1 = 0;\n    sqr_add_c2(a, 7, 6, c2, c3, c1);\n    r[13] = c2;\n    c2 = 0;\n    sqr_add_c(a, 7, c3, c1, c2);\n    r[14] = c3;\n    r[15] = c1;\n}\n\nvoid bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)\n{\n    BN_ULONG c1, c2, c3;\n\n    c1 = 0;\n    c2 = 0;\n    c3 = 0;\n    sqr_add_c(a, 0, c1, c2, c3);\n    r[0] = c1;\n    c1 = 0;\n    sqr_add_c2(a, 1, 0, c2, c3, c1);\n    r[1] = c2;\n    c2 = 0;\n    sqr_add_c(a, 1, c3, c1, c2);\n    sqr_add_c2(a, 2, 0, c3, c1, c2);\n    r[2] = c3;\n    c3 = 0;\n    sqr_add_c2(a, 3, 0, c1, c2, c3);\n    sqr_add_c2(a, 2, 1, c1, c2, c3);\n    r[3] = c1;\n    c1 = 0;\n    sqr_add_c(a, 2, c2, c3, c1);\n    sqr_add_c2(a, 3, 1, c2, c3, c1);\n    r[4] = c2;\n    c2 = 0;\n    sqr_add_c2(a, 3, 2, c3, c1, c2);\n    r[5] = c3;\n    c3 = 0;\n    sqr_add_c(a, 3, c1, c2, c3);\n    r[6] = c1;\n    r[7] = c2;\n}\n\n# ifdef OPENSSL_NO_ASM\n#  ifdef OPENSSL_BN_ASM_MONT\n#   include <alloca.h>\n/*\n * This is essentially reference implementation, which may or may not\n * result in performance improvement. E.g. on IA-32 this routine was\n * observed to give 40% faster rsa1024 private key operations and 10%\n * faster rsa4096 ones, while on AMD64 it improves rsa1024 sign only\n * by 10% and *worsens* rsa4096 sign by 15%. Once again, it's a\n * reference implementation, one to be used as starting point for\n * platform-specific assembler. Mentioned numbers apply to compiler\n * generated code compiled with and without -DOPENSSL_BN_ASM_MONT and\n * can vary not only from platform to platform, but even for compiler\n * versions. Assembler vs. assembler improvement coefficients can\n * [and are known to] differ and are to be documented elsewhere.\n */\nint bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                const BN_ULONG *np, const BN_ULONG *n0p, int num)\n{\n    BN_ULONG c0, c1, ml, *tp, n0;\n#   ifdef mul64\n    BN_ULONG mh;\n#   endif\n    volatile BN_ULONG *vp;\n    int i = 0, j;\n\n#   if 0                        /* template for platform-specific\n                                 * implementation */\n    if (ap == bp)\n        return bn_sqr_mont(rp, ap, np, n0p, num);\n#   endif\n    vp = tp = alloca((num + 2) * sizeof(BN_ULONG));\n\n    n0 = *n0p;\n\n    c0 = 0;\n    ml = bp[0];\n#   ifdef mul64\n    mh = HBITS(ml);\n    ml = LBITS(ml);\n    for (j = 0; j < num; ++j)\n        mul(tp[j], ap[j], ml, mh, c0);\n#   else\n    for (j = 0; j < num; ++j)\n        mul(tp[j], ap[j], ml, c0);\n#   endif\n\n    tp[num] = c0;\n    tp[num + 1] = 0;\n    goto enter;\n\n    for (i = 0; i < num; i++) {\n        c0 = 0;\n        ml = bp[i];\n#   ifdef mul64\n        mh = HBITS(ml);\n        ml = LBITS(ml);\n        for (j = 0; j < num; ++j)\n            mul_add(tp[j], ap[j], ml, mh, c0);\n#   else\n        for (j = 0; j < num; ++j)\n            mul_add(tp[j], ap[j], ml, c0);\n#   endif\n        c1 = (tp[num] + c0) & BN_MASK2;\n        tp[num] = c1;\n        tp[num + 1] = (c1 < c0 ? 1 : 0);\n enter:\n        c1 = tp[0];\n        ml = (c1 * n0) & BN_MASK2;\n        c0 = 0;\n#   ifdef mul64\n        mh = HBITS(ml);\n        ml = LBITS(ml);\n        mul_add(c1, np[0], ml, mh, c0);\n#   else\n        mul_add(c1, ml, np[0], c0);\n#   endif\n        for (j = 1; j < num; j++) {\n            c1 = tp[j];\n#   ifdef mul64\n            mul_add(c1, np[j], ml, mh, c0);\n#   else\n            mul_add(c1, ml, np[j], c0);\n#   endif\n            tp[j - 1] = c1 & BN_MASK2;\n        }\n        c1 = (tp[num] + c0) & BN_MASK2;\n        tp[num - 1] = c1;\n        tp[num] = tp[num + 1] + (c1 < c0 ? 1 : 0);\n    }\n\n    if (tp[num] != 0 || tp[num - 1] >= np[num - 1]) {\n        c0 = bn_sub_words(rp, tp, np, num);\n        if (tp[num] != 0 || c0 == 0) {\n            for (i = 0; i < num + 2; i++)\n                vp[i] = 0;\n            return 1;\n        }\n    }\n    for (i = 0; i < num; i++)\n        rp[i] = tp[i], vp[i] = 0;\n    vp[num] = 0;\n    vp[num + 1] = 0;\n    return 1;\n}\n#  else\n/*\n * Return value of 0 indicates that multiplication/convolution was not\n * performed to signal the caller to fall down to alternative/original\n * code-path.\n */\nint bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                const BN_ULONG *np, const BN_ULONG *n0, int num)\n{\n    return 0;\n}\n#  endif                        /* OPENSSL_BN_ASM_MONT */\n# endif\n\n#else                           /* !BN_MUL_COMBA */\n\n/* hmm... is it faster just to do a multiply? */\n# undef bn_sqr_comba4\n# undef bn_sqr_comba8\nvoid bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)\n{\n    BN_ULONG t[8];\n    bn_sqr_normal(r, a, 4, t);\n}\n\nvoid bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)\n{\n    BN_ULONG t[16];\n    bn_sqr_normal(r, a, 8, t);\n}\n\nvoid bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)\n{\n    r[4] = bn_mul_words(&(r[0]), a, 4, b[0]);\n    r[5] = bn_mul_add_words(&(r[1]), a, 4, b[1]);\n    r[6] = bn_mul_add_words(&(r[2]), a, 4, b[2]);\n    r[7] = bn_mul_add_words(&(r[3]), a, 4, b[3]);\n}\n\nvoid bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)\n{\n    r[8] = bn_mul_words(&(r[0]), a, 8, b[0]);\n    r[9] = bn_mul_add_words(&(r[1]), a, 8, b[1]);\n    r[10] = bn_mul_add_words(&(r[2]), a, 8, b[2]);\n    r[11] = bn_mul_add_words(&(r[3]), a, 8, b[3]);\n    r[12] = bn_mul_add_words(&(r[4]), a, 8, b[4]);\n    r[13] = bn_mul_add_words(&(r[5]), a, 8, b[5]);\n    r[14] = bn_mul_add_words(&(r[6]), a, 8, b[6]);\n    r[15] = bn_mul_add_words(&(r[7]), a, 8, b[7]);\n}\n\n# ifdef OPENSSL_NO_ASM\n#  ifdef OPENSSL_BN_ASM_MONT\n#   include <alloca.h>\nint bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                const BN_ULONG *np, const BN_ULONG *n0p, int num)\n{\n    BN_ULONG c0, c1, *tp, n0 = *n0p;\n    volatile BN_ULONG *vp;\n    int i = 0, j;\n\n    vp = tp = alloca((num + 2) * sizeof(BN_ULONG));\n\n    for (i = 0; i <= num; i++)\n        tp[i] = 0;\n\n    for (i = 0; i < num; i++) {\n        c0 = bn_mul_add_words(tp, ap, num, bp[i]);\n        c1 = (tp[num] + c0) & BN_MASK2;\n        tp[num] = c1;\n        tp[num + 1] = (c1 < c0 ? 1 : 0);\n\n        c0 = bn_mul_add_words(tp, np, num, tp[0] * n0);\n        c1 = (tp[num] + c0) & BN_MASK2;\n        tp[num] = c1;\n        tp[num + 1] += (c1 < c0 ? 1 : 0);\n        for (j = 0; j <= num; j++)\n            tp[j] = tp[j + 1];\n    }\n\n    if (tp[num] != 0 || tp[num - 1] >= np[num - 1]) {\n        c0 = bn_sub_words(rp, tp, np, num);\n        if (tp[num] != 0 || c0 == 0) {\n            for (i = 0; i < num + 2; i++)\n                vp[i] = 0;\n            return 1;\n        }\n    }\n    for (i = 0; i < num; i++)\n        rp[i] = tp[i], vp[i] = 0;\n    vp[num] = 0;\n    vp[num + 1] = 0;\n    return 1;\n}\n#  else\nint bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                const BN_ULONG *np, const BN_ULONG *n0, int num)\n{\n    return 0;\n}\n#  endif                        /* OPENSSL_BN_ASM_MONT */\n# endif\n\n#endif                          /* !BN_MUL_COMBA */\n"
  },
  {
    "path": "cryptomini/bn/bn_ctx.c",
    "content": "/*\n * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\n/*-\n * TODO list\n *\n * 1. Check a bunch of \"(words+1)\" type hacks in various bignum functions and\n * check they can be safely removed.\n *  - Check +1 and other ugliness in BN_from_montgomery()\n *\n * 2. Consider allowing a BN_new_ex() that, at least, lets you specify an\n * appropriate 'block' size that will be honoured by bn_expand_internal() to\n * prevent piddly little reallocations. OTOH, profiling bignum expansions in\n * BN_CTX doesn't show this to be a big issue.\n */\n\n/* How many bignums are in each \"pool item\"; */\n#define BN_CTX_POOL_SIZE        16\n/* The stack frame info is resizing, set a first-time expansion size; */\n#define BN_CTX_START_FRAMES     32\n\n/***********/\n/* BN_POOL */\n/***********/\n\n/* A bundle of bignums that can be linked with other bundles */\ntypedef struct bignum_pool_item {\n    /* The bignum values */\n    BIGNUM vals[BN_CTX_POOL_SIZE];\n    /* Linked-list admin */\n    struct bignum_pool_item *prev, *next;\n} BN_POOL_ITEM;\n/* A linked-list of bignums grouped in bundles */\ntypedef struct bignum_pool {\n    /* Linked-list admin */\n    BN_POOL_ITEM *head, *current, *tail;\n    /* Stack depth and allocation size */\n    unsigned used, size;\n} BN_POOL;\nstatic void BN_POOL_init(BN_POOL *);\nstatic void BN_POOL_finish(BN_POOL *);\nstatic BIGNUM *BN_POOL_get(BN_POOL *, int);\nstatic void BN_POOL_release(BN_POOL *, unsigned int);\n\n/************/\n/* BN_STACK */\n/************/\n\n/* A wrapper to manage the \"stack frames\" */\ntypedef struct bignum_ctx_stack {\n    /* Array of indexes into the bignum stack */\n    unsigned int *indexes;\n    /* Number of stack frames, and the size of the allocated array */\n    unsigned int depth, size;\n} BN_STACK;\nstatic void BN_STACK_init(BN_STACK *);\nstatic void BN_STACK_finish(BN_STACK *);\nstatic int BN_STACK_push(BN_STACK *, unsigned int);\nstatic unsigned int BN_STACK_pop(BN_STACK *);\n\n/**********/\n/* BN_CTX */\n/**********/\n\n/* The opaque BN_CTX type */\nstruct bignum_ctx {\n    /* The bignum bundles */\n    BN_POOL pool;\n    /* The \"stack frames\", if you will */\n    BN_STACK stack;\n    /* The number of bignums currently assigned */\n    unsigned int used;\n    /* Depth of stack overflow */\n    int err_stack;\n    /* Block \"gets\" until an \"end\" (compatibility behaviour) */\n    int too_many;\n    /* Flags. */\n    int flags;\n};\n\n/* Enable this to find BN_CTX bugs */\n#ifdef BN_CTX_DEBUG\nstatic const char *ctxdbg_cur = NULL;\nstatic void ctxdbg(BN_CTX *ctx)\n{\n    unsigned int bnidx = 0, fpidx = 0;\n    BN_POOL_ITEM *item = ctx->pool.head;\n    BN_STACK *stack = &ctx->stack;\n    fprintf(stderr, \"(%16p): \", ctx);\n    while (bnidx < ctx->used) {\n        fprintf(stderr, \"%03x \", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);\n        if (!(bnidx % BN_CTX_POOL_SIZE))\n            item = item->next;\n    }\n    fprintf(stderr, \"\\n\");\n    bnidx = 0;\n    fprintf(stderr, \"          : \");\n    while (fpidx < stack->depth) {\n        while (bnidx++ < stack->indexes[fpidx])\n            fprintf(stderr, \"    \");\n        fprintf(stderr, \"^^^ \");\n        bnidx++;\n        fpidx++;\n    }\n    fprintf(stderr, \"\\n\");\n}\n\n# define CTXDBG_ENTRY(str, ctx)  do { \\\n                                ctxdbg_cur = (str); \\\n                                fprintf(stderr,\"Starting %s\\n\", ctxdbg_cur); \\\n                                ctxdbg(ctx); \\\n                                } while(0)\n# define CTXDBG_EXIT(ctx)        do { \\\n                                fprintf(stderr,\"Ending %s\\n\", ctxdbg_cur); \\\n                                ctxdbg(ctx); \\\n                                } while(0)\n# define CTXDBG_RET(ctx,ret)\n#else\n# define CTXDBG_ENTRY(str, ctx)\n# define CTXDBG_EXIT(ctx)\n# define CTXDBG_RET(ctx,ret)\n#endif\n\n\nBN_CTX *BN_CTX_new(void)\n{\n    BN_CTX *ret;\n\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    /* Initialise the structure */\n    BN_POOL_init(&ret->pool);\n    BN_STACK_init(&ret->stack);\n    return ret;\n}\n\nBN_CTX *BN_CTX_secure_new(void)\n{\n    BN_CTX *ret = BN_CTX_new();\n\n    if (ret != NULL)\n        ret->flags = BN_FLG_SECURE;\n    return ret;\n}\n\nvoid BN_CTX_free(BN_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n#ifdef BN_CTX_DEBUG\n    {\n        BN_POOL_ITEM *pool = ctx->pool.head;\n        fprintf(stderr, \"BN_CTX_free, stack-size=%d, pool-bignums=%d\\n\",\n                ctx->stack.size, ctx->pool.size);\n        fprintf(stderr, \"dmaxs: \");\n        while (pool) {\n            unsigned loop = 0;\n            while (loop < BN_CTX_POOL_SIZE)\n                fprintf(stderr, \"%02x \", pool->vals[loop++].dmax);\n            pool = pool->next;\n        }\n        fprintf(stderr, \"\\n\");\n    }\n#endif\n    BN_STACK_finish(&ctx->stack);\n    BN_POOL_finish(&ctx->pool);\n    OPENSSL_free(ctx);\n}\n\nvoid BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY(\"BN_CTX_start\", ctx);\n    /* If we're already overflowing ... */\n    if (ctx->err_stack || ctx->too_many)\n        ctx->err_stack++;\n    /* (Try to) get a new frame pointer */\n    else if (!BN_STACK_push(&ctx->stack, ctx->used)) {\n        BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        ctx->err_stack++;\n    }\n    CTXDBG_EXIT(ctx);\n}\n\nvoid BN_CTX_end(BN_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    CTXDBG_ENTRY(\"BN_CTX_end\", ctx);\n    if (ctx->err_stack)\n        ctx->err_stack--;\n    else {\n        unsigned int fp = BN_STACK_pop(&ctx->stack);\n        /* Does this stack frame have anything to release? */\n        if (fp < ctx->used)\n            BN_POOL_release(&ctx->pool, ctx->used - fp);\n        ctx->used = fp;\n        /* Unjam \"too_many\" in case \"get\" had failed */\n        ctx->too_many = 0;\n    }\n    CTXDBG_EXIT(ctx);\n}\n\nBIGNUM *BN_CTX_get(BN_CTX *ctx)\n{\n    BIGNUM *ret;\n\n    CTXDBG_ENTRY(\"BN_CTX_get\", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        return NULL;\n    if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {\n        /*\n         * Setting too_many prevents repeated \"get\" attempts from cluttering\n         * the error stack.\n         */\n        ctx->too_many = 1;\n        BNerr(BN_F_BN_CTX_GET, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        return NULL;\n    }\n    /* OK, make sure the returned bignum is \"zero\" */\n    BN_zero(ret);\n    /* clear BN_FLG_CONSTTIME if leaked from previous frames */\n    ret->flags &= (~BN_FLG_CONSTTIME);\n    ctx->used++;\n    CTXDBG_RET(ctx, ret);\n    return ret;\n}\n\n/************/\n/* BN_STACK */\n/************/\n\nstatic void BN_STACK_init(BN_STACK *st)\n{\n    st->indexes = NULL;\n    st->depth = st->size = 0;\n}\n\nstatic void BN_STACK_finish(BN_STACK *st)\n{\n    OPENSSL_free(st->indexes);\n    st->indexes = NULL;\n}\n\n\nstatic int BN_STACK_push(BN_STACK *st, unsigned int idx)\n{\n    if (st->depth == st->size) {\n        /* Need to expand */\n        unsigned int newsize =\n            st->size ? (st->size * 3 / 2) : BN_CTX_START_FRAMES;\n        unsigned int *newitems;\n\n        if ((newitems = OPENSSL_malloc(sizeof(*newitems) * newsize)) == NULL) {\n            BNerr(BN_F_BN_STACK_PUSH, ERR_R_MALLOC_FAILURE);\n            return 0;\n        }\n        if (st->depth)\n            memcpy(newitems, st->indexes, sizeof(*newitems) * st->depth);\n        OPENSSL_free(st->indexes);\n        st->indexes = newitems;\n        st->size = newsize;\n    }\n    st->indexes[(st->depth)++] = idx;\n    return 1;\n}\n\nstatic unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}\n\n/***********/\n/* BN_POOL */\n/***********/\n\nstatic void BN_POOL_init(BN_POOL *p)\n{\n    p->head = p->current = p->tail = NULL;\n    p->used = p->size = 0;\n}\n\nstatic void BN_POOL_finish(BN_POOL *p)\n{\n    unsigned int loop;\n    BIGNUM *bn;\n\n    while (p->head) {\n        for (loop = 0, bn = p->head->vals; loop++ < BN_CTX_POOL_SIZE; bn++)\n            if (bn->d)\n                BN_clear_free(bn);\n        p->current = p->head->next;\n        OPENSSL_free(p->head);\n        p->head = p->current;\n    }\n}\n\n\nstatic BIGNUM *BN_POOL_get(BN_POOL *p, int flag)\n{\n    BIGNUM *bn;\n    unsigned int loop;\n\n    /* Full; allocate a new pool item and link it in. */\n    if (p->used == p->size) {\n        BN_POOL_ITEM *item;\n\n        if ((item = OPENSSL_malloc(sizeof(*item))) == NULL) {\n            BNerr(BN_F_BN_POOL_GET, ERR_R_MALLOC_FAILURE);\n            return NULL;\n        }\n        for (loop = 0, bn = item->vals; loop++ < BN_CTX_POOL_SIZE; bn++) {\n            bn_init(bn);\n            if ((flag & BN_FLG_SECURE) != 0)\n                BN_set_flags(bn, BN_FLG_SECURE);\n        }\n        item->prev = p->tail;\n        item->next = NULL;\n\n        if (p->head == NULL)\n            p->head = p->current = p->tail = item;\n        else {\n            p->tail->next = item;\n            p->tail = item;\n            p->current = item;\n        }\n        p->size += BN_CTX_POOL_SIZE;\n        p->used++;\n        /* Return the first bignum from the new pool */\n        return item->vals;\n    }\n\n    if (!p->used)\n        p->current = p->head;\n    else if ((p->used % BN_CTX_POOL_SIZE) == 0)\n        p->current = p->current->next;\n    return p->current->vals + ((p->used++) % BN_CTX_POOL_SIZE);\n}\n\nstatic void BN_POOL_release(BN_POOL *p, unsigned int num)\n{\n    unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;\n\n    p->used -= num;\n    while (num--) {\n        bn_check_top(p->current->vals + offset);\n        if (offset == 0) {\n            offset = BN_CTX_POOL_SIZE - 1;\n            p->current = p->current->prev;\n        } else\n            offset--;\n    }\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_div.c",
    "content": "/*\n * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <assert.h>\n#include <openssl/bn.h>\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\n/* The old slow way */\n#if 0\nint BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,\n           BN_CTX *ctx)\n{\n    int i, nm, nd;\n    int ret = 0;\n    BIGNUM *D;\n\n    bn_check_top(m);\n    bn_check_top(d);\n    if (BN_is_zero(d)) {\n        BNerr(BN_F_BN_DIV, BN_R_DIV_BY_ZERO);\n        return 0;\n    }\n\n    if (BN_ucmp(m, d) < 0) {\n        if (rem != NULL) {\n            if (BN_copy(rem, m) == NULL)\n                return 0;\n        }\n        if (dv != NULL)\n            BN_zero(dv);\n        return 1;\n    }\n\n    BN_CTX_start(ctx);\n    D = BN_CTX_get(ctx);\n    if (dv == NULL)\n        dv = BN_CTX_get(ctx);\n    if (rem == NULL)\n        rem = BN_CTX_get(ctx);\n    if (D == NULL || dv == NULL || rem == NULL)\n        goto end;\n\n    nd = BN_num_bits(d);\n    nm = BN_num_bits(m);\n    if (BN_copy(D, d) == NULL)\n        goto end;\n    if (BN_copy(rem, m) == NULL)\n        goto end;\n\n    /*\n     * The next 2 are needed so we can do a dv->d[0]|=1 later since\n     * BN_lshift1 will only work once there is a value :-)\n     */\n    BN_zero(dv);\n    if (bn_wexpand(dv, 1) == NULL)\n        goto end;\n    dv->top = 1;\n\n    if (!BN_lshift(D, D, nm - nd))\n        goto end;\n    for (i = nm - nd; i >= 0; i--) {\n        if (!BN_lshift1(dv, dv))\n            goto end;\n        if (BN_ucmp(rem, D) >= 0) {\n            dv->d[0] |= 1;\n            if (!BN_usub(rem, rem, D))\n                goto end;\n        }\n/* CAN IMPROVE (and have now :=) */\n        if (!BN_rshift1(D, D))\n            goto end;\n    }\n    rem->neg = BN_is_zero(rem) ? 0 : m->neg;\n    dv->neg = m->neg ^ d->neg;\n    ret = 1;\n end:\n    BN_CTX_end(ctx);\n    return ret;\n}\n\n#else\n\n# if defined(BN_DIV3W)\nBN_ULONG bn_div_3_words(const BN_ULONG *m, BN_ULONG d1, BN_ULONG d0);\n# elif 0\n/*\n * This is #if-ed away, because it's a reference for assembly implementations,\n * where it can and should be made constant-time. But if you want to test it,\n * just replace 0 with 1.\n */\n#  if BN_BITS2 == 64 && defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16\n#   undef BN_ULLONG\n#   define BN_ULLONG __uint128_t\n#   define BN_LLONG\n#  endif\n\n#  ifdef BN_LLONG\n#   define BN_DIV3W\n/*\n * Interface is somewhat quirky, |m| is pointer to most significant limb,\n * and less significant limb is referred at |m[-1]|. This means that caller\n * is responsible for ensuring that |m[-1]| is valid. Second condition that\n * has to be met is that |d0|'s most significant bit has to be set. Or in\n * other words divisor has to be \"bit-aligned to the left.\" bn_div_fixed_top\n * does all this. The subroutine considers four limbs, two of which are\n * \"overlapping,\" hence the name...\n */\nstatic BN_ULONG bn_div_3_words(const BN_ULONG *m, BN_ULONG d1, BN_ULONG d0)\n{\n    BN_ULLONG R = ((BN_ULLONG)m[0] << BN_BITS2) | m[-1];\n    BN_ULLONG D = ((BN_ULLONG)d0 << BN_BITS2) | d1;\n    BN_ULONG Q = 0, mask;\n    int i;\n\n    for (i = 0; i < BN_BITS2; i++) {\n        Q <<= 1;\n        if (R >= D) {\n            Q |= 1;\n            R -= D;\n        }\n        D >>= 1;\n    }\n\n    mask = 0 - (Q >> (BN_BITS2 - 1));   /* does it overflow? */\n\n    Q <<= 1;\n    Q |= (R >= D);\n\n    return (Q | mask) & BN_MASK2;\n}\n#  endif\n# endif\n\nstatic int bn_left_align(BIGNUM *num)\n{\n    BN_ULONG *d = num->d, n, m, rmask;\n    int top = num->top;\n    int rshift = BN_num_bits_word(d[top - 1]), lshift, i;\n\n    lshift = BN_BITS2 - rshift;\n    rshift %= BN_BITS2;            /* say no to undefined behaviour */\n    rmask = (BN_ULONG)0 - rshift;  /* rmask = 0 - (rshift != 0) */\n    rmask |= rmask >> 8;\n\n    for (i = 0, m = 0; i < top; i++) {\n        n = d[i];\n        d[i] = ((n << lshift) | m) & BN_MASK2;\n        m = (n >> rshift) & rmask;\n    }\n\n    return lshift;\n}\n\n# if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \\\n    && !defined(PEDANTIC) && !defined(BN_DIV3W)\n#  if defined(__GNUC__) && __GNUC__>=2\n#   if defined(__i386) || defined (__i386__)\n   /*-\n    * There were two reasons for implementing this template:\n    * - GNU C generates a call to a function (__udivdi3 to be exact)\n    *   in reply to ((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0 (I fail to\n    *   understand why...);\n    * - divl doesn't only calculate quotient, but also leaves\n    *   remainder in %edx which we can definitely use here:-)\n    */\n#    undef bn_div_words\n#    define bn_div_words(n0,n1,d0)                \\\n        ({  asm volatile (                      \\\n                \"divl   %4\"                     \\\n                : \"=a\"(q), \"=d\"(rem)            \\\n                : \"a\"(n1), \"d\"(n0), \"r\"(d0)     \\\n                : \"cc\");                        \\\n            q;                                  \\\n        })\n#    define REMAINDER_IS_ALREADY_CALCULATED\n#   elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG)\n   /*\n    * Same story here, but it's 128-bit by 64-bit division. Wow!\n    */\n#    undef bn_div_words\n#    define bn_div_words(n0,n1,d0)                \\\n        ({  asm volatile (                      \\\n                \"divq   %4\"                     \\\n                : \"=a\"(q), \"=d\"(rem)            \\\n                : \"a\"(n1), \"d\"(n0), \"r\"(d0)     \\\n                : \"cc\");                        \\\n            q;                                  \\\n        })\n#    define REMAINDER_IS_ALREADY_CALCULATED\n#   endif                       /* __<cpu> */\n#  endif                        /* __GNUC__ */\n# endif                         /* OPENSSL_NO_ASM */\n\n/*-\n * BN_div computes  dv := num / divisor, rounding towards\n * zero, and sets up rm  such that  dv*divisor + rm = num  holds.\n * Thus:\n *     dv->neg == num->neg ^ divisor->neg  (unless the result is zero)\n *     rm->neg == num->neg                 (unless the remainder is zero)\n * If 'dv' or 'rm' is NULL, the respective value is not returned.\n */\nint BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,\n           BN_CTX *ctx)\n{\n    int ret;\n\n    if (BN_is_zero(divisor)) {\n        BNerr(BN_F_BN_DIV, BN_R_DIV_BY_ZERO);\n        return 0;\n    }\n\n    /*\n     * Invalid zero-padding would have particularly bad consequences so don't\n     * just rely on bn_check_top() here (bn_check_top() works only for\n     * BN_DEBUG builds)\n     */\n    if (divisor->d[divisor->top - 1] == 0) {\n        BNerr(BN_F_BN_DIV, BN_R_NOT_INITIALIZED);\n        return 0;\n    }\n\n    ret = bn_div_fixed_top(dv, rm, num, divisor, ctx);\n\n    if (ret) {\n        if (dv != NULL)\n            bn_correct_top(dv);\n        if (rm != NULL)\n            bn_correct_top(rm);\n    }\n\n    return ret;\n}\n\n/*\n * It's argued that *length* of *significant* part of divisor is public.\n * Even if it's private modulus that is. Again, *length* is assumed\n * public, but not *value*. Former is likely to be pre-defined by\n * algorithm with bit granularity, though below subroutine is invariant\n * of limb length. Thanks to this assumption we can require that |divisor|\n * may not be zero-padded, yet claim this subroutine \"constant-time\"(*).\n * This is because zero-padded dividend, |num|, is tolerated, so that\n * caller can pass dividend of public length(*), but with smaller amount\n * of significant limbs. This naturally means that quotient, |dv|, would\n * contain correspongly less significant limbs as well, and will be zero-\n * padded accordingly. Returned remainder, |rm|, will have same bit length\n * as divisor, also zero-padded if needed. These actually leave sign bits\n * in ambiguous state. In sense that we try to avoid negative zeros, while\n * zero-padded zeros would retain sign.\n *\n * (*) \"Constant-time-ness\" has two pre-conditions:\n *\n *     - availability of constant-time bn_div_3_words;\n *     - dividend is at least as \"wide\" as divisor, limb-wise, zero-padded\n *       if so required, which shouldn't be a privacy problem, because\n *       divisor's length is considered public;\n */\nint bn_div_fixed_top(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,\n                     const BIGNUM *divisor, BN_CTX *ctx)\n{\n    int norm_shift, i, j, loop;\n    BIGNUM *tmp, *snum, *sdiv, *res;\n    BN_ULONG *resp, *wnum, *wnumtop;\n    BN_ULONG d0, d1;\n    int num_n, div_n, num_neg;\n\n    assert(divisor->top > 0 && divisor->d[divisor->top - 1] != 0);\n\n    bn_check_top(num);\n    bn_check_top(divisor);\n    bn_check_top(dv);\n    bn_check_top(rm);\n\n    BN_CTX_start(ctx);\n    res = (dv == NULL) ? BN_CTX_get(ctx) : dv;\n    tmp = BN_CTX_get(ctx);\n    snum = BN_CTX_get(ctx);\n    sdiv = BN_CTX_get(ctx);\n    if (sdiv == NULL)\n        goto err;\n\n    /* First we normalise the numbers */\n    if (!BN_copy(sdiv, divisor))\n        goto err;\n    norm_shift = bn_left_align(sdiv);\n    sdiv->neg = 0;\n    /*\n     * Note that bn_lshift_fixed_top's output is always one limb longer\n     * than input, even when norm_shift is zero. This means that amount of\n     * inner loop iterations is invariant of dividend value, and that one\n     * doesn't need to compare dividend and divisor if they were originally\n     * of the same bit length.\n     */\n    if (!(bn_lshift_fixed_top(snum, num, norm_shift)))\n        goto err;\n\n    div_n = sdiv->top;\n    num_n = snum->top;\n\n    if (num_n <= div_n) {\n        /* caller didn't pad dividend -> no constant-time guarantee... */\n        if (bn_wexpand(snum, div_n + 1) == NULL)\n            goto err;\n        memset(&(snum->d[num_n]), 0, (div_n - num_n + 1) * sizeof(BN_ULONG));\n        snum->top = num_n = div_n + 1;\n    }\n\n    loop = num_n - div_n;\n    /*\n     * Lets setup a 'window' into snum This is the part that corresponds to\n     * the current 'area' being divided\n     */\n    wnum = &(snum->d[loop]);\n    wnumtop = &(snum->d[num_n - 1]);\n\n    /* Get the top 2 words of sdiv */\n    d0 = sdiv->d[div_n - 1];\n    d1 = (div_n == 1) ? 0 : sdiv->d[div_n - 2];\n\n    /* Setup quotient */\n    if (!bn_wexpand(res, loop))\n        goto err;\n    num_neg = num->neg;\n    res->neg = (num_neg ^ divisor->neg);\n    res->top = loop;\n    res->flags |= BN_FLG_FIXED_TOP;\n    resp = &(res->d[loop]);\n\n    /* space for temp */\n    if (!bn_wexpand(tmp, (div_n + 1)))\n        goto err;\n\n    for (i = 0; i < loop; i++, wnumtop--) {\n        BN_ULONG q, l0;\n        /*\n         * the first part of the loop uses the top two words of snum and sdiv\n         * to calculate a BN_ULONG q such that | wnum - sdiv * q | < sdiv\n         */\n# if defined(BN_DIV3W)\n        q = bn_div_3_words(wnumtop, d1, d0);\n# else\n        BN_ULONG n0, n1, rem = 0;\n\n        n0 = wnumtop[0];\n        n1 = wnumtop[-1];\n        if (n0 == d0)\n            q = BN_MASK2;\n        else {                  /* n0 < d0 */\n            BN_ULONG n2 = (wnumtop == wnum) ? 0 : wnumtop[-2];\n#  ifdef BN_LLONG\n            BN_ULLONG t2;\n\n#   if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)\n            q = (BN_ULONG)(((((BN_ULLONG) n0) << BN_BITS2) | n1) / d0);\n#   else\n            q = bn_div_words(n0, n1, d0);\n#   endif\n\n#   ifndef REMAINDER_IS_ALREADY_CALCULATED\n            /*\n             * rem doesn't have to be BN_ULLONG. The least we\n             * know it's less that d0, isn't it?\n             */\n            rem = (n1 - q * d0) & BN_MASK2;\n#   endif\n            t2 = (BN_ULLONG) d1 *q;\n\n            for (;;) {\n                if (t2 <= ((((BN_ULLONG) rem) << BN_BITS2) | n2))\n                    break;\n                q--;\n                rem += d0;\n                if (rem < d0)\n                    break;      /* don't let rem overflow */\n                t2 -= d1;\n            }\n#  else                         /* !BN_LLONG */\n            BN_ULONG t2l, t2h;\n\n            q = bn_div_words(n0, n1, d0);\n#   ifndef REMAINDER_IS_ALREADY_CALCULATED\n            rem = (n1 - q * d0) & BN_MASK2;\n#   endif\n\n#   if defined(BN_UMULT_LOHI)\n            BN_UMULT_LOHI(t2l, t2h, d1, q);\n#   elif defined(BN_UMULT_HIGH)\n            t2l = d1 * q;\n            t2h = BN_UMULT_HIGH(d1, q);\n#   else\n            {\n                BN_ULONG ql, qh;\n                t2l = LBITS(d1);\n                t2h = HBITS(d1);\n                ql = LBITS(q);\n                qh = HBITS(q);\n                mul64(t2l, t2h, ql, qh); /* t2=(BN_ULLONG)d1*q; */\n            }\n#   endif\n\n            for (;;) {\n                if ((t2h < rem) || ((t2h == rem) && (t2l <= n2)))\n                    break;\n                q--;\n                rem += d0;\n                if (rem < d0)\n                    break;      /* don't let rem overflow */\n                if (t2l < d1)\n                    t2h--;\n                t2l -= d1;\n            }\n#  endif                        /* !BN_LLONG */\n        }\n# endif                         /* !BN_DIV3W */\n\n        l0 = bn_mul_words(tmp->d, sdiv->d, div_n, q);\n        tmp->d[div_n] = l0;\n        wnum--;\n        /*\n         * ignore top values of the bignums just sub the two BN_ULONG arrays\n         * with bn_sub_words\n         */\n        l0 = bn_sub_words(wnum, wnum, tmp->d, div_n + 1);\n        q -= l0;\n        /*\n         * Note: As we have considered only the leading two BN_ULONGs in\n         * the calculation of q, sdiv * q might be greater than wnum (but\n         * then (q-1) * sdiv is less or equal than wnum)\n         */\n        for (l0 = 0 - l0, j = 0; j < div_n; j++)\n            tmp->d[j] = sdiv->d[j] & l0;\n        l0 = bn_add_words(wnum, wnum, tmp->d, div_n);\n        (*wnumtop) += l0;\n        assert((*wnumtop) == 0);\n\n        /* store part of the result */\n        *--resp = q;\n    }\n    /* snum holds remainder, it's as wide as divisor */\n    snum->neg = num_neg;\n    snum->top = div_n;\n    snum->flags |= BN_FLG_FIXED_TOP;\n\n    if (rm != NULL && bn_rshift_fixed_top(rm, snum, norm_shift) == 0)\n        goto err;\n\n    BN_CTX_end(ctx);\n    return 1;\n err:\n    bn_check_top(rm);\n    BN_CTX_end(ctx);\n    return 0;\n}\n#endif\n"
  },
  {
    "path": "cryptomini/bn/bn_exp.c",
    "content": "/*\n * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include \"internal/constant_time.h\"\n#include \"bn_local.h\"\n\n#include <stdlib.h>\n#ifdef _WIN32\n# include <malloc.h>\n# ifndef alloca\n#  define alloca _alloca\n# endif\n#elif defined(__GNUC__)\n# ifndef alloca\n#  define alloca(s) __builtin_alloca((s))\n# endif\n#elif defined(__sun)\n# include <alloca.h>\n#endif\n\n#include \"rsaz_exp.h\"\n\n#undef SPARC_T4_MONT\n#if defined(OPENSSL_BN_ASM_MONT) && (defined(__sparc__) || defined(__sparc))\n# include \"sparc_arch.h\"\nextern unsigned int OPENSSL_sparcv9cap_P[];\n# define SPARC_T4_MONT\n#endif\n\n/* maximum precomputation table size for *variable* sliding windows */\n#define TABLE_SIZE      32\n\n/* this one works - simple but works */\nint BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)\n{\n    int i, bits, ret = 0;\n    BIGNUM *v, *rr;\n\n    if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(a, BN_FLG_CONSTTIME) != 0) {\n        /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */\n        BNerr(BN_F_BN_EXP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n\n    BN_CTX_start(ctx);\n    rr = ((r == a) || (r == p)) ? BN_CTX_get(ctx) : r;\n    v = BN_CTX_get(ctx);\n    if (rr == NULL || v == NULL)\n        goto err;\n\n    if (BN_copy(v, a) == NULL)\n        goto err;\n    bits = BN_num_bits(p);\n\n    if (BN_is_odd(p)) {\n        if (BN_copy(rr, a) == NULL)\n            goto err;\n    } else {\n        if (!BN_one(rr))\n            goto err;\n    }\n\n    for (i = 1; i < bits; i++) {\n        if (!BN_sqr(v, v, ctx))\n            goto err;\n        if (BN_is_bit_set(p, i)) {\n            if (!BN_mul(rr, rr, v, ctx))\n                goto err;\n        }\n    }\n    if (r != rr && BN_copy(r, rr) == NULL)\n        goto err;\n\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(r);\n    return ret;\n}\n\nint BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    int ret;\n\n    bn_check_top(a);\n    bn_check_top(p);\n    bn_check_top(m);\n\n    /*-\n     * For even modulus  m = 2^k*m_odd, it might make sense to compute\n     * a^p mod m_odd  and  a^p mod 2^k  separately (with Montgomery\n     * exponentiation for the odd part), using appropriate exponent\n     * reductions, and combine the results using the CRT.\n     *\n     * For now, we use Montgomery only if the modulus is odd; otherwise,\n     * exponentiation using the reciprocal-based quick remaindering\n     * algorithm is used.\n     *\n     * (Timing obtained with expspeed.c [computations  a^p mod m\n     * where  a, p, m  are of the same length: 256, 512, 1024, 2048,\n     * 4096, 8192 bits], compared to the running time of the\n     * standard algorithm:\n     *\n     *   BN_mod_exp_mont   33 .. 40 %  [AMD K6-2, Linux, debug configuration]\n     *                     55 .. 77 %  [UltraSparc processor, but\n     *                                  debug-solaris-sparcv8-gcc conf.]\n     *\n     *   BN_mod_exp_recp   50 .. 70 %  [AMD K6-2, Linux, debug configuration]\n     *                     62 .. 118 % [UltraSparc, debug-solaris-sparcv8-gcc]\n     *\n     * On the Sparc, BN_mod_exp_recp was faster than BN_mod_exp_mont\n     * at 2048 and more bits, but at 512 and 1024 bits, it was\n     * slower even than the standard algorithm!\n     *\n     * \"Real\" timings [linux-elf, solaris-sparcv9-gcc configurations]\n     * should be obtained when the new Montgomery reduction code\n     * has been integrated into OpenSSL.)\n     */\n\n#define MONT_MUL_MOD\n#define MONT_EXP_WORD\n#define RECP_MUL_MOD\n\n#ifdef MONT_MUL_MOD\n    if (BN_is_odd(m)) {\n# ifdef MONT_EXP_WORD\n        if (a->top == 1 && !a->neg\n            && (BN_get_flags(p, BN_FLG_CONSTTIME) == 0)\n            && (BN_get_flags(a, BN_FLG_CONSTTIME) == 0)\n            && (BN_get_flags(m, BN_FLG_CONSTTIME) == 0)) {\n            BN_ULONG A = a->d[0];\n            ret = BN_mod_exp_mont_word(r, A, p, m, ctx, NULL);\n        } else\n# endif\n            ret = BN_mod_exp_mont(r, a, p, m, ctx, NULL);\n    } else\n#endif\n#ifdef RECP_MUL_MOD\n    {\n        ret = BN_mod_exp_recp(r, a, p, m, ctx);\n    }\n#else\n    {\n        ret = BN_mod_exp_simple(r, a, p, m, ctx);\n    }\n#endif\n\n    bn_check_top(r);\n    return ret;\n}\n\nint BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx)\n{\n    int i, j, bits, ret = 0, wstart, wend, window, wvalue;\n    int start = 1;\n    BIGNUM *aa;\n    /* Table of variables obtained from 'ctx' */\n    BIGNUM *val[TABLE_SIZE];\n    BN_RECP_CTX recp;\n\n    if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(a, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {\n        /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */\n        BNerr(BN_F_BN_MOD_EXP_RECP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n\n    bits = BN_num_bits(p);\n    if (bits == 0) {\n        /* x**0 mod 1, or x**0 mod -1 is still zero. */\n        if (BN_abs_is_word(m, 1)) {\n            ret = 1;\n            BN_zero(r);\n        } else {\n            ret = BN_one(r);\n        }\n        return ret;\n    }\n\n    BN_RECP_CTX_init(&recp);\n\n    BN_CTX_start(ctx);\n    aa = BN_CTX_get(ctx);\n    val[0] = BN_CTX_get(ctx);\n    if (val[0] == NULL)\n        goto err;\n\n    if (m->neg) {\n        /* ignore sign of 'm' */\n        if (!BN_copy(aa, m))\n            goto err;\n        aa->neg = 0;\n        if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0)\n            goto err;\n    } else {\n        if (BN_RECP_CTX_set(&recp, m, ctx) <= 0)\n            goto err;\n    }\n\n    if (!BN_nnmod(val[0], a, m, ctx))\n        goto err;               /* 1 */\n    if (BN_is_zero(val[0])) {\n        BN_zero(r);\n        ret = 1;\n        goto err;\n    }\n\n    window = BN_window_bits_for_exponent_size(bits);\n    if (window > 1) {\n        if (!BN_mod_mul_reciprocal(aa, val[0], val[0], &recp, ctx))\n            goto err;           /* 2 */\n        j = 1 << (window - 1);\n        for (i = 1; i < j; i++) {\n            if (((val[i] = BN_CTX_get(ctx)) == NULL) ||\n                !BN_mod_mul_reciprocal(val[i], val[i - 1], aa, &recp, ctx))\n                goto err;\n        }\n    }\n\n    start = 1;                  /* This is used to avoid multiplication etc\n                                 * when there is only the value '1' in the\n                                 * buffer. */\n    wvalue = 0;                 /* The 'value' of the window */\n    wstart = bits - 1;          /* The top bit of the window */\n    wend = 0;                   /* The bottom bit of the window */\n\n    if (!BN_one(r))\n        goto err;\n\n    for (;;) {\n        if (BN_is_bit_set(p, wstart) == 0) {\n            if (!start)\n                if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx))\n                    goto err;\n            if (wstart == 0)\n                break;\n            wstart--;\n            continue;\n        }\n        /*\n         * We now have wstart on a 'set' bit, we now need to work out how bit\n         * a window to do.  To do this we need to scan forward until the last\n         * set bit before the end of the window\n         */\n        j = wstart;\n        wvalue = 1;\n        wend = 0;\n        for (i = 1; i < window; i++) {\n            if (wstart - i < 0)\n                break;\n            if (BN_is_bit_set(p, wstart - i)) {\n                wvalue <<= (i - wend);\n                wvalue |= 1;\n                wend = i;\n            }\n        }\n\n        /* wend is the size of the current window */\n        j = wend + 1;\n        /* add the 'bytes above' */\n        if (!start)\n            for (i = 0; i < j; i++) {\n                if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx))\n                    goto err;\n            }\n\n        /* wvalue will be an odd number < 2^window */\n        if (!BN_mod_mul_reciprocal(r, r, val[wvalue >> 1], &recp, ctx))\n            goto err;\n\n        /* move the 'window' down further */\n        wstart -= wend + 1;\n        wvalue = 0;\n        start = 0;\n        if (wstart < 0)\n            break;\n    }\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    BN_RECP_CTX_free(&recp);\n    bn_check_top(r);\n    return ret;\n}\n\nint BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)\n{\n    int i, j, bits, ret = 0, wstart, wend, window, wvalue;\n    int start = 1;\n    BIGNUM *d, *r;\n    const BIGNUM *aa;\n    /* Table of variables obtained from 'ctx' */\n    BIGNUM *val[TABLE_SIZE];\n    BN_MONT_CTX *mont = NULL;\n\n    if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(a, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {\n        return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont);\n    }\n\n    bn_check_top(a);\n    bn_check_top(p);\n    bn_check_top(m);\n\n    if (!BN_is_odd(m)) {\n        BNerr(BN_F_BN_MOD_EXP_MONT, BN_R_CALLED_WITH_EVEN_MODULUS);\n        return 0;\n    }\n    bits = BN_num_bits(p);\n    if (bits == 0) {\n        /* x**0 mod 1, or x**0 mod -1 is still zero. */\n        if (BN_abs_is_word(m, 1)) {\n            ret = 1;\n            BN_zero(rr);\n        } else {\n            ret = BN_one(rr);\n        }\n        return ret;\n    }\n\n    BN_CTX_start(ctx);\n    d = BN_CTX_get(ctx);\n    r = BN_CTX_get(ctx);\n    val[0] = BN_CTX_get(ctx);\n    if (val[0] == NULL)\n        goto err;\n\n    /*\n     * If this is not done, things will break in the montgomery part\n     */\n\n    if (in_mont != NULL)\n        mont = in_mont;\n    else {\n        if ((mont = BN_MONT_CTX_new()) == NULL)\n            goto err;\n        if (!BN_MONT_CTX_set(mont, m, ctx))\n            goto err;\n    }\n\n    if (a->neg || BN_ucmp(a, m) >= 0) {\n        if (!BN_nnmod(val[0], a, m, ctx))\n            goto err;\n        aa = val[0];\n    } else\n        aa = a;\n    if (!bn_to_mont_fixed_top(val[0], aa, mont, ctx))\n        goto err;               /* 1 */\n\n    window = BN_window_bits_for_exponent_size(bits);\n    if (window > 1) {\n        if (!bn_mul_mont_fixed_top(d, val[0], val[0], mont, ctx))\n            goto err;           /* 2 */\n        j = 1 << (window - 1);\n        for (i = 1; i < j; i++) {\n            if (((val[i] = BN_CTX_get(ctx)) == NULL) ||\n                !bn_mul_mont_fixed_top(val[i], val[i - 1], d, mont, ctx))\n                goto err;\n        }\n    }\n\n    start = 1;                  /* This is used to avoid multiplication etc\n                                 * when there is only the value '1' in the\n                                 * buffer. */\n    wvalue = 0;                 /* The 'value' of the window */\n    wstart = bits - 1;          /* The top bit of the window */\n    wend = 0;                   /* The bottom bit of the window */\n\n#if 1                           /* by Shay Gueron's suggestion */\n    j = m->top;                 /* borrow j */\n    if (m->d[j - 1] & (((BN_ULONG)1) << (BN_BITS2 - 1))) {\n        if (bn_wexpand(r, j) == NULL)\n            goto err;\n        /* 2^(top*BN_BITS2) - m */\n        r->d[0] = (0 - m->d[0]) & BN_MASK2;\n        for (i = 1; i < j; i++)\n            r->d[i] = (~m->d[i]) & BN_MASK2;\n        r->top = j;\n        r->flags |= BN_FLG_FIXED_TOP;\n    } else\n#endif\n    if (!bn_to_mont_fixed_top(r, BN_value_one(), mont, ctx))\n        goto err;\n    for (;;) {\n        if (BN_is_bit_set(p, wstart) == 0) {\n            if (!start) {\n                if (!bn_mul_mont_fixed_top(r, r, r, mont, ctx))\n                    goto err;\n            }\n            if (wstart == 0)\n                break;\n            wstart--;\n            continue;\n        }\n        /*\n         * We now have wstart on a 'set' bit, we now need to work out how bit\n         * a window to do.  To do this we need to scan forward until the last\n         * set bit before the end of the window\n         */\n        j = wstart;\n        wvalue = 1;\n        wend = 0;\n        for (i = 1; i < window; i++) {\n            if (wstart - i < 0)\n                break;\n            if (BN_is_bit_set(p, wstart - i)) {\n                wvalue <<= (i - wend);\n                wvalue |= 1;\n                wend = i;\n            }\n        }\n\n        /* wend is the size of the current window */\n        j = wend + 1;\n        /* add the 'bytes above' */\n        if (!start)\n            for (i = 0; i < j; i++) {\n                if (!bn_mul_mont_fixed_top(r, r, r, mont, ctx))\n                    goto err;\n            }\n\n        /* wvalue will be an odd number < 2^window */\n        if (!bn_mul_mont_fixed_top(r, r, val[wvalue >> 1], mont, ctx))\n            goto err;\n\n        /* move the 'window' down further */\n        wstart -= wend + 1;\n        wvalue = 0;\n        start = 0;\n        if (wstart < 0)\n            break;\n    }\n    /*\n     * Done with zero-padded intermediate BIGNUMs. Final BN_from_montgomery\n     * removes padding [if any] and makes return value suitable for public\n     * API consumer.\n     */\n#if defined(SPARC_T4_MONT)\n    if (OPENSSL_sparcv9cap_P[0] & (SPARCV9_VIS3 | SPARCV9_PREFER_FPU)) {\n        j = mont->N.top;        /* borrow j */\n        val[0]->d[0] = 1;       /* borrow val[0] */\n        for (i = 1; i < j; i++)\n            val[0]->d[i] = 0;\n        val[0]->top = j;\n        if (!BN_mod_mul_montgomery(rr, r, val[0], mont, ctx))\n            goto err;\n    } else\n#endif\n    if (!BN_from_montgomery(rr, r, mont, ctx))\n        goto err;\n    ret = 1;\n err:\n    if (in_mont == NULL)\n        BN_MONT_CTX_free(mont);\n    BN_CTX_end(ctx);\n    bn_check_top(rr);\n    return ret;\n}\n\nstatic BN_ULONG bn_get_bits(const BIGNUM *a, int bitpos)\n{\n    BN_ULONG ret = 0;\n    int wordpos;\n\n    wordpos = bitpos / BN_BITS2;\n    bitpos %= BN_BITS2;\n    if (wordpos >= 0 && wordpos < a->top) {\n        ret = a->d[wordpos] & BN_MASK2;\n        if (bitpos) {\n            ret >>= bitpos;\n            if (++wordpos < a->top)\n                ret |= a->d[wordpos] << (BN_BITS2 - bitpos);\n        }\n    }\n\n    return ret & BN_MASK2;\n}\n\n/*\n * BN_mod_exp_mont_consttime() stores the precomputed powers in a specific\n * layout so that accessing any of these table values shows the same access\n * pattern as far as cache lines are concerned.  The following functions are\n * used to transfer a BIGNUM from/to that table.\n */\n\nstatic int MOD_EXP_CTIME_COPY_TO_PREBUF(const BIGNUM *b, int top,\n                                        unsigned char *buf, int idx,\n                                        int window)\n{\n    int i, j;\n    int width = 1 << window;\n    BN_ULONG *table = (BN_ULONG *)buf;\n\n    if (top > b->top)\n        top = b->top;           /* this works because 'buf' is explicitly\n                                 * zeroed */\n    for (i = 0, j = idx; i < top; i++, j += width) {\n        table[j] = b->d[i];\n    }\n\n    return 1;\n}\n\nstatic int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top,\n                                          unsigned char *buf, int idx,\n                                          int window)\n{\n    int i, j;\n    int width = 1 << window;\n    /*\n     * We declare table 'volatile' in order to discourage compiler\n     * from reordering loads from the table. Concern is that if\n     * reordered in specific manner loads might give away the\n     * information we are trying to conceal. Some would argue that\n     * compiler can reorder them anyway, but it can as well be\n     * argued that doing so would be violation of standard...\n     */\n    volatile BN_ULONG *table = (volatile BN_ULONG *)buf;\n\n    if (bn_wexpand(b, top) == NULL)\n        return 0;\n\n    if (window <= 3) {\n        for (i = 0; i < top; i++, table += width) {\n            BN_ULONG acc = 0;\n\n            for (j = 0; j < width; j++) {\n                acc |= table[j] &\n                       ((BN_ULONG)0 - (constant_time_eq_int(j,idx)&1));\n            }\n\n            b->d[i] = acc;\n        }\n    } else {\n        int xstride = 1 << (window - 2);\n        BN_ULONG y0, y1, y2, y3;\n\n        i = idx >> (window - 2);        /* equivalent of idx / xstride */\n        idx &= xstride - 1;             /* equivalent of idx % xstride */\n\n        y0 = (BN_ULONG)0 - (constant_time_eq_int(i,0)&1);\n        y1 = (BN_ULONG)0 - (constant_time_eq_int(i,1)&1);\n        y2 = (BN_ULONG)0 - (constant_time_eq_int(i,2)&1);\n        y3 = (BN_ULONG)0 - (constant_time_eq_int(i,3)&1);\n\n        for (i = 0; i < top; i++, table += width) {\n            BN_ULONG acc = 0;\n\n            for (j = 0; j < xstride; j++) {\n                acc |= ( (table[j + 0 * xstride] & y0) |\n                         (table[j + 1 * xstride] & y1) |\n                         (table[j + 2 * xstride] & y2) |\n                         (table[j + 3 * xstride] & y3) )\n                       & ((BN_ULONG)0 - (constant_time_eq_int(j,idx)&1));\n            }\n\n            b->d[i] = acc;\n        }\n    }\n\n    b->top = top;\n    b->flags |= BN_FLG_FIXED_TOP;\n    return 1;\n}\n\n/*\n * Given a pointer value, compute the next address that is a cache line\n * multiple.\n */\n#define MOD_EXP_CTIME_ALIGN(x_) \\\n        ((unsigned char*)(x_) + (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - (((size_t)(x_)) & (MOD_EXP_CTIME_MIN_CACHE_LINE_MASK))))\n\n/*\n * This variant of BN_mod_exp_mont() uses fixed windows and the special\n * precomputation memory layout to limit data-dependency to a minimum to\n * protect secret exponents (cf. the hyper-threading timing attacks pointed\n * out by Colin Percival,\n * http://www.daemonology.net/hyperthreading-considered-harmful/)\n */\nint BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,\n                              const BIGNUM *m, BN_CTX *ctx,\n                              BN_MONT_CTX *in_mont)\n{\n    int i, bits, ret = 0, window, wvalue, wmask, window0;\n    int top;\n    BN_MONT_CTX *mont = NULL;\n\n    int numPowers;\n    unsigned char *powerbufFree = NULL;\n    int powerbufLen = 0;\n    unsigned char *powerbuf = NULL;\n    BIGNUM tmp, am;\n#if defined(SPARC_T4_MONT)\n    unsigned int t4 = 0;\n#endif\n\n    bn_check_top(a);\n    bn_check_top(p);\n    bn_check_top(m);\n\n    if (!BN_is_odd(m)) {\n        BNerr(BN_F_BN_MOD_EXP_MONT_CONSTTIME, BN_R_CALLED_WITH_EVEN_MODULUS);\n        return 0;\n    }\n\n    top = m->top;\n\n    /*\n     * Use all bits stored in |p|, rather than |BN_num_bits|, so we do not leak\n     * whether the top bits are zero.\n     */\n    bits = p->top * BN_BITS2;\n    if (bits == 0) {\n        /* x**0 mod 1, or x**0 mod -1 is still zero. */\n        if (BN_abs_is_word(m, 1)) {\n            ret = 1;\n            BN_zero(rr);\n        } else {\n            ret = BN_one(rr);\n        }\n        return ret;\n    }\n\n    BN_CTX_start(ctx);\n\n    /*\n     * Allocate a montgomery context if it was not supplied by the caller. If\n     * this is not done, things will break in the montgomery part.\n     */\n    if (in_mont != NULL)\n        mont = in_mont;\n    else {\n        if ((mont = BN_MONT_CTX_new()) == NULL)\n            goto err;\n        if (!BN_MONT_CTX_set(mont, m, ctx))\n            goto err;\n    }\n\n    if (a->neg || BN_ucmp(a, m) >= 0) {\n        BIGNUM *reduced = BN_CTX_get(ctx);\n        if (reduced == NULL\n            || !BN_nnmod(reduced, a, m, ctx)) {\n            goto err;\n        }\n        a = reduced;\n    }\n\n#ifdef RSAZ_ENABLED\n    /*\n     * If the size of the operands allow it, perform the optimized\n     * RSAZ exponentiation. For further information see\n     * crypto/bn/rsaz_exp.c and accompanying assembly modules.\n     */\n    if ((16 == a->top) && (16 == p->top) && (BN_num_bits(m) == 1024)\n        && rsaz_avx2_eligible()) {\n        if (NULL == bn_wexpand(rr, 16))\n            goto err;\n        RSAZ_1024_mod_exp_avx2(rr->d, a->d, p->d, m->d, mont->RR.d,\n                               mont->n0[0]);\n        rr->top = 16;\n        rr->neg = 0;\n        bn_correct_top(rr);\n        ret = 1;\n        goto err;\n    } else if ((8 == a->top) && (8 == p->top) && (BN_num_bits(m) == 512)) {\n        if (NULL == bn_wexpand(rr, 8))\n            goto err;\n        RSAZ_512_mod_exp(rr->d, a->d, p->d, m->d, mont->n0[0], mont->RR.d);\n        rr->top = 8;\n        rr->neg = 0;\n        bn_correct_top(rr);\n        ret = 1;\n        goto err;\n    }\n#endif\n\n    /* Get the window size to use with size of p. */\n    window = BN_window_bits_for_ctime_exponent_size(bits);\n#if defined(SPARC_T4_MONT)\n    if (window >= 5 && (top & 15) == 0 && top <= 64 &&\n        (OPENSSL_sparcv9cap_P[1] & (CFR_MONTMUL | CFR_MONTSQR)) ==\n        (CFR_MONTMUL | CFR_MONTSQR) && (t4 = OPENSSL_sparcv9cap_P[0]))\n        window = 5;\n    else\n#endif\n#if defined(OPENSSL_BN_ASM_MONT5)\n    if (window >= 5) {\n        window = 5;             /* ~5% improvement for RSA2048 sign, and even\n                                 * for RSA4096 */\n        /* reserve space for mont->N.d[] copy */\n        powerbufLen += top * sizeof(mont->N.d[0]);\n    }\n#endif\n    (void)0;\n\n    /*\n     * Allocate a buffer large enough to hold all of the pre-computed powers\n     * of am, am itself and tmp.\n     */\n    numPowers = 1 << window;\n    powerbufLen += sizeof(m->d[0]) * (top * numPowers +\n                                      ((2 * top) >\n                                       numPowers ? (2 * top) : numPowers));\n#ifdef alloca\n    if (powerbufLen < 3072)\n        powerbufFree =\n            alloca(powerbufLen + MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH);\n    else\n#endif\n        if ((powerbufFree =\n             OPENSSL_malloc(powerbufLen + MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH))\n            == NULL)\n        goto err;\n\n    powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree);\n    memset(powerbuf, 0, powerbufLen);\n\n#ifdef alloca\n    if (powerbufLen < 3072)\n        powerbufFree = NULL;\n#endif\n\n    /* lay down tmp and am right after powers table */\n    tmp.d = (BN_ULONG *)(powerbuf + sizeof(m->d[0]) * top * numPowers);\n    am.d = tmp.d + top;\n    tmp.top = am.top = 0;\n    tmp.dmax = am.dmax = top;\n    tmp.neg = am.neg = 0;\n    tmp.flags = am.flags = BN_FLG_STATIC_DATA;\n\n    /* prepare a^0 in Montgomery domain */\n#if 1                           /* by Shay Gueron's suggestion */\n    if (m->d[top - 1] & (((BN_ULONG)1) << (BN_BITS2 - 1))) {\n        /* 2^(top*BN_BITS2) - m */\n        tmp.d[0] = (0 - m->d[0]) & BN_MASK2;\n        for (i = 1; i < top; i++)\n            tmp.d[i] = (~m->d[i]) & BN_MASK2;\n        tmp.top = top;\n    } else\n#endif\n    if (!bn_to_mont_fixed_top(&tmp, BN_value_one(), mont, ctx))\n        goto err;\n\n    /* prepare a^1 in Montgomery domain */\n    if (!bn_to_mont_fixed_top(&am, a, mont, ctx))\n        goto err;\n\n#if defined(SPARC_T4_MONT)\n    if (t4) {\n        typedef int (*bn_pwr5_mont_f) (BN_ULONG *tp, const BN_ULONG *np,\n                                       const BN_ULONG *n0, const void *table,\n                                       int power, int bits);\n        int bn_pwr5_mont_t4_8(BN_ULONG *tp, const BN_ULONG *np,\n                              const BN_ULONG *n0, const void *table,\n                              int power, int bits);\n        int bn_pwr5_mont_t4_16(BN_ULONG *tp, const BN_ULONG *np,\n                               const BN_ULONG *n0, const void *table,\n                               int power, int bits);\n        int bn_pwr5_mont_t4_24(BN_ULONG *tp, const BN_ULONG *np,\n                               const BN_ULONG *n0, const void *table,\n                               int power, int bits);\n        int bn_pwr5_mont_t4_32(BN_ULONG *tp, const BN_ULONG *np,\n                               const BN_ULONG *n0, const void *table,\n                               int power, int bits);\n        static const bn_pwr5_mont_f pwr5_funcs[4] = {\n            bn_pwr5_mont_t4_8, bn_pwr5_mont_t4_16,\n            bn_pwr5_mont_t4_24, bn_pwr5_mont_t4_32\n        };\n        bn_pwr5_mont_f pwr5_worker = pwr5_funcs[top / 16 - 1];\n\n        typedef int (*bn_mul_mont_f) (BN_ULONG *rp, const BN_ULONG *ap,\n                                      const void *bp, const BN_ULONG *np,\n                                      const BN_ULONG *n0);\n        int bn_mul_mont_t4_8(BN_ULONG *rp, const BN_ULONG *ap, const void *bp,\n                             const BN_ULONG *np, const BN_ULONG *n0);\n        int bn_mul_mont_t4_16(BN_ULONG *rp, const BN_ULONG *ap,\n                              const void *bp, const BN_ULONG *np,\n                              const BN_ULONG *n0);\n        int bn_mul_mont_t4_24(BN_ULONG *rp, const BN_ULONG *ap,\n                              const void *bp, const BN_ULONG *np,\n                              const BN_ULONG *n0);\n        int bn_mul_mont_t4_32(BN_ULONG *rp, const BN_ULONG *ap,\n                              const void *bp, const BN_ULONG *np,\n                              const BN_ULONG *n0);\n        static const bn_mul_mont_f mul_funcs[4] = {\n            bn_mul_mont_t4_8, bn_mul_mont_t4_16,\n            bn_mul_mont_t4_24, bn_mul_mont_t4_32\n        };\n        bn_mul_mont_f mul_worker = mul_funcs[top / 16 - 1];\n\n        void bn_mul_mont_vis3(BN_ULONG *rp, const BN_ULONG *ap,\n                              const void *bp, const BN_ULONG *np,\n                              const BN_ULONG *n0, int num);\n        void bn_mul_mont_t4(BN_ULONG *rp, const BN_ULONG *ap,\n                            const void *bp, const BN_ULONG *np,\n                            const BN_ULONG *n0, int num);\n        void bn_mul_mont_gather5_t4(BN_ULONG *rp, const BN_ULONG *ap,\n                                    const void *table, const BN_ULONG *np,\n                                    const BN_ULONG *n0, int num, int power);\n        void bn_flip_n_scatter5_t4(const BN_ULONG *inp, size_t num,\n                                   void *table, size_t power);\n        void bn_gather5_t4(BN_ULONG *out, size_t num,\n                           void *table, size_t power);\n        void bn_flip_t4(BN_ULONG *dst, BN_ULONG *src, size_t num);\n\n        BN_ULONG *np = mont->N.d, *n0 = mont->n0;\n        int stride = 5 * (6 - (top / 16 - 1)); /* multiple of 5, but less\n                                                * than 32 */\n\n        /*\n         * BN_to_montgomery can contaminate words above .top [in\n         * BN_DEBUG[_DEBUG] build]...\n         */\n        for (i = am.top; i < top; i++)\n            am.d[i] = 0;\n        for (i = tmp.top; i < top; i++)\n            tmp.d[i] = 0;\n\n        bn_flip_n_scatter5_t4(tmp.d, top, powerbuf, 0);\n        bn_flip_n_scatter5_t4(am.d, top, powerbuf, 1);\n        if (!(*mul_worker) (tmp.d, am.d, am.d, np, n0) &&\n            !(*mul_worker) (tmp.d, am.d, am.d, np, n0))\n            bn_mul_mont_vis3(tmp.d, am.d, am.d, np, n0, top);\n        bn_flip_n_scatter5_t4(tmp.d, top, powerbuf, 2);\n\n        for (i = 3; i < 32; i++) {\n            /* Calculate a^i = a^(i-1) * a */\n            if (!(*mul_worker) (tmp.d, tmp.d, am.d, np, n0) &&\n                !(*mul_worker) (tmp.d, tmp.d, am.d, np, n0))\n                bn_mul_mont_vis3(tmp.d, tmp.d, am.d, np, n0, top);\n            bn_flip_n_scatter5_t4(tmp.d, top, powerbuf, i);\n        }\n\n        /* switch to 64-bit domain */\n        np = alloca(top * sizeof(BN_ULONG));\n        top /= 2;\n        bn_flip_t4(np, mont->N.d, top);\n\n        /*\n         * The exponent may not have a whole number of fixed-size windows.\n         * To simplify the main loop, the initial window has between 1 and\n         * full-window-size bits such that what remains is always a whole\n         * number of windows\n         */\n        window0 = (bits - 1) % 5 + 1;\n        wmask = (1 << window0) - 1;\n        bits -= window0;\n        wvalue = bn_get_bits(p, bits) & wmask;\n        bn_gather5_t4(tmp.d, top, powerbuf, wvalue);\n\n        /*\n         * Scan the exponent one window at a time starting from the most\n         * significant bits.\n         */\n        while (bits > 0) {\n            if (bits < stride)\n                stride = bits;\n            bits -= stride;\n            wvalue = bn_get_bits(p, bits);\n\n            if ((*pwr5_worker) (tmp.d, np, n0, powerbuf, wvalue, stride))\n                continue;\n            /* retry once and fall back */\n            if ((*pwr5_worker) (tmp.d, np, n0, powerbuf, wvalue, stride))\n                continue;\n\n            bits += stride - 5;\n            wvalue >>= stride - 5;\n            wvalue &= 31;\n            bn_mul_mont_t4(tmp.d, tmp.d, tmp.d, np, n0, top);\n            bn_mul_mont_t4(tmp.d, tmp.d, tmp.d, np, n0, top);\n            bn_mul_mont_t4(tmp.d, tmp.d, tmp.d, np, n0, top);\n            bn_mul_mont_t4(tmp.d, tmp.d, tmp.d, np, n0, top);\n            bn_mul_mont_t4(tmp.d, tmp.d, tmp.d, np, n0, top);\n            bn_mul_mont_gather5_t4(tmp.d, tmp.d, powerbuf, np, n0, top,\n                                   wvalue);\n        }\n\n        bn_flip_t4(tmp.d, tmp.d, top);\n        top *= 2;\n        /* back to 32-bit domain */\n        tmp.top = top;\n        bn_correct_top(&tmp);\n        OPENSSL_cleanse(np, top * sizeof(BN_ULONG));\n    } else\n#endif\n#if defined(OPENSSL_BN_ASM_MONT5)\n    if (window == 5 && top > 1) {\n        /*\n         * This optimization uses ideas from http://eprint.iacr.org/2011/239,\n         * specifically optimization of cache-timing attack countermeasures\n         * and pre-computation optimization.\n         */\n\n        /*\n         * Dedicated window==4 case improves 512-bit RSA sign by ~15%, but as\n         * 512-bit RSA is hardly relevant, we omit it to spare size...\n         */\n        void bn_mul_mont_gather5(BN_ULONG *rp, const BN_ULONG *ap,\n                                 const void *table, const BN_ULONG *np,\n                                 const BN_ULONG *n0, int num, int power);\n        void bn_scatter5(const BN_ULONG *inp, size_t num,\n                         void *table, size_t power);\n        void bn_gather5(BN_ULONG *out, size_t num, void *table, size_t power);\n        void bn_power5(BN_ULONG *rp, const BN_ULONG *ap,\n                       const void *table, const BN_ULONG *np,\n                       const BN_ULONG *n0, int num, int power);\n        int bn_get_bits5(const BN_ULONG *ap, int off);\n        int bn_from_montgomery(BN_ULONG *rp, const BN_ULONG *ap,\n                               const BN_ULONG *not_used, const BN_ULONG *np,\n                               const BN_ULONG *n0, int num);\n\n        BN_ULONG *n0 = mont->n0, *np;\n\n        /*\n         * BN_to_montgomery can contaminate words above .top [in\n         * BN_DEBUG[_DEBUG] build]...\n         */\n        for (i = am.top; i < top; i++)\n            am.d[i] = 0;\n        for (i = tmp.top; i < top; i++)\n            tmp.d[i] = 0;\n\n        /*\n         * copy mont->N.d[] to improve cache locality\n         */\n        for (np = am.d + top, i = 0; i < top; i++)\n            np[i] = mont->N.d[i];\n\n        bn_scatter5(tmp.d, top, powerbuf, 0);\n        bn_scatter5(am.d, am.top, powerbuf, 1);\n        bn_mul_mont(tmp.d, am.d, am.d, np, n0, top);\n        bn_scatter5(tmp.d, top, powerbuf, 2);\n\n# if 0\n        for (i = 3; i < 32; i++) {\n            /* Calculate a^i = a^(i-1) * a */\n            bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1);\n            bn_scatter5(tmp.d, top, powerbuf, i);\n        }\n# else\n        /* same as above, but uses squaring for 1/2 of operations */\n        for (i = 4; i < 32; i *= 2) {\n            bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);\n            bn_scatter5(tmp.d, top, powerbuf, i);\n        }\n        for (i = 3; i < 8; i += 2) {\n            int j;\n            bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1);\n            bn_scatter5(tmp.d, top, powerbuf, i);\n            for (j = 2 * i; j < 32; j *= 2) {\n                bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);\n                bn_scatter5(tmp.d, top, powerbuf, j);\n            }\n        }\n        for (; i < 16; i += 2) {\n            bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1);\n            bn_scatter5(tmp.d, top, powerbuf, i);\n            bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);\n            bn_scatter5(tmp.d, top, powerbuf, 2 * i);\n        }\n        for (; i < 32; i += 2) {\n            bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1);\n            bn_scatter5(tmp.d, top, powerbuf, i);\n        }\n# endif\n        /*\n         * The exponent may not have a whole number of fixed-size windows.\n         * To simplify the main loop, the initial window has between 1 and\n         * full-window-size bits such that what remains is always a whole\n         * number of windows\n         */\n        window0 = (bits - 1) % 5 + 1;\n        wmask = (1 << window0) - 1;\n        bits -= window0;\n        wvalue = bn_get_bits(p, bits) & wmask;\n        bn_gather5(tmp.d, top, powerbuf, wvalue);\n\n        /*\n         * Scan the exponent one window at a time starting from the most\n         * significant bits.\n         */\n        if (top & 7) {\n            while (bits > 0) {\n                bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);\n                bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);\n                bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);\n                bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);\n                bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);\n                bn_mul_mont_gather5(tmp.d, tmp.d, powerbuf, np, n0, top,\n                                    bn_get_bits5(p->d, bits -= 5));\n            }\n        } else {\n            while (bits > 0) {\n                bn_power5(tmp.d, tmp.d, powerbuf, np, n0, top,\n                          bn_get_bits5(p->d, bits -= 5));\n            }\n        }\n\n        ret = bn_from_montgomery(tmp.d, tmp.d, NULL, np, n0, top);\n        tmp.top = top;\n        bn_correct_top(&tmp);\n        if (ret) {\n            if (!BN_copy(rr, &tmp))\n                ret = 0;\n            goto err;           /* non-zero ret means it's not error */\n        }\n    } else\n#endif\n    {\n        if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 0, window))\n            goto err;\n        if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&am, top, powerbuf, 1, window))\n            goto err;\n\n        /*\n         * If the window size is greater than 1, then calculate\n         * val[i=2..2^winsize-1]. Powers are computed as a*a^(i-1) (even\n         * powers could instead be computed as (a^(i/2))^2 to use the slight\n         * performance advantage of sqr over mul).\n         */\n        if (window > 1) {\n            if (!bn_mul_mont_fixed_top(&tmp, &am, &am, mont, ctx))\n                goto err;\n            if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 2,\n                                              window))\n                goto err;\n            for (i = 3; i < numPowers; i++) {\n                /* Calculate a^i = a^(i-1) * a */\n                if (!bn_mul_mont_fixed_top(&tmp, &am, &tmp, mont, ctx))\n                    goto err;\n                if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, i,\n                                                  window))\n                    goto err;\n            }\n        }\n\n        /*\n         * The exponent may not have a whole number of fixed-size windows.\n         * To simplify the main loop, the initial window has between 1 and\n         * full-window-size bits such that what remains is always a whole\n         * number of windows\n         */\n        window0 = (bits - 1) % window + 1;\n        wmask = (1 << window0) - 1;\n        bits -= window0;\n        wvalue = bn_get_bits(p, bits) & wmask;\n        if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&tmp, top, powerbuf, wvalue,\n                                            window))\n            goto err;\n\n        wmask = (1 << window) - 1;\n        /*\n         * Scan the exponent one window at a time starting from the most\n         * significant bits.\n         */\n        while (bits > 0) {\n\n            /* Square the result window-size times */\n            for (i = 0; i < window; i++)\n                if (!bn_mul_mont_fixed_top(&tmp, &tmp, &tmp, mont, ctx))\n                    goto err;\n\n            /*\n             * Get a window's worth of bits from the exponent\n             * This avoids calling BN_is_bit_set for each bit, which\n             * is not only slower but also makes each bit vulnerable to\n             * EM (and likely other) side-channel attacks like One&Done\n             * (for details see \"One&Done: A Single-Decryption EM-Based\n             *  Attack on OpenSSL's Constant-Time Blinded RSA\" by M. Alam,\n             *  H. Khan, M. Dey, N. Sinha, R. Callan, A. Zajic, and\n             *  M. Prvulovic, in USENIX Security'18)\n             */\n            bits -= window;\n            wvalue = bn_get_bits(p, bits) & wmask;\n            /*\n             * Fetch the appropriate pre-computed value from the pre-buf\n             */\n            if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&am, top, powerbuf, wvalue,\n                                                window))\n                goto err;\n\n            /* Multiply the result into the intermediate result */\n            if (!bn_mul_mont_fixed_top(&tmp, &tmp, &am, mont, ctx))\n                goto err;\n        }\n    }\n\n    /*\n     * Done with zero-padded intermediate BIGNUMs. Final BN_from_montgomery\n     * removes padding [if any] and makes return value suitable for public\n     * API consumer.\n     */\n#if defined(SPARC_T4_MONT)\n    if (OPENSSL_sparcv9cap_P[0] & (SPARCV9_VIS3 | SPARCV9_PREFER_FPU)) {\n        am.d[0] = 1;            /* borrow am */\n        for (i = 1; i < top; i++)\n            am.d[i] = 0;\n        if (!BN_mod_mul_montgomery(rr, &tmp, &am, mont, ctx))\n            goto err;\n    } else\n#endif\n    if (!BN_from_montgomery(rr, &tmp, mont, ctx))\n        goto err;\n    ret = 1;\n err:\n    if (in_mont == NULL)\n        BN_MONT_CTX_free(mont);\n    if (powerbuf != NULL) {\n        OPENSSL_cleanse(powerbuf, powerbufLen);\n        OPENSSL_free(powerbufFree);\n    }\n    BN_CTX_end(ctx);\n    return ret;\n}\n\nint BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p,\n                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)\n{\n    BN_MONT_CTX *mont = NULL;\n    int b, bits, ret = 0;\n    int r_is_one;\n    BN_ULONG w, next_w;\n    BIGNUM *r, *t;\n    BIGNUM *swap_tmp;\n#define BN_MOD_MUL_WORD(r, w, m) \\\n                (BN_mul_word(r, (w)) && \\\n                (/* BN_ucmp(r, (m)) < 0 ? 1 :*/  \\\n                        (BN_mod(t, r, m, ctx) && (swap_tmp = r, r = t, t = swap_tmp, 1))))\n    /*\n     * BN_MOD_MUL_WORD is only used with 'w' large, so the BN_ucmp test is\n     * probably more overhead than always using BN_mod (which uses BN_copy if\n     * a similar test returns true).\n     */\n    /*\n     * We can use BN_mod and do not need BN_nnmod because our accumulator is\n     * never negative (the result of BN_mod does not depend on the sign of\n     * the modulus).\n     */\n#define BN_TO_MONTGOMERY_WORD(r, w, mont) \\\n                (BN_set_word(r, (w)) && BN_to_montgomery(r, r, (mont), ctx))\n\n    if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {\n        /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */\n        BNerr(BN_F_BN_MOD_EXP_MONT_WORD, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n\n    bn_check_top(p);\n    bn_check_top(m);\n\n    if (!BN_is_odd(m)) {\n        BNerr(BN_F_BN_MOD_EXP_MONT_WORD, BN_R_CALLED_WITH_EVEN_MODULUS);\n        return 0;\n    }\n    if (m->top == 1)\n        a %= m->d[0];           /* make sure that 'a' is reduced */\n\n    bits = BN_num_bits(p);\n    if (bits == 0) {\n        /* x**0 mod 1, or x**0 mod -1 is still zero. */\n        if (BN_abs_is_word(m, 1)) {\n            ret = 1;\n            BN_zero(rr);\n        } else {\n            ret = BN_one(rr);\n        }\n        return ret;\n    }\n    if (a == 0) {\n        BN_zero(rr);\n        ret = 1;\n        return ret;\n    }\n\n    BN_CTX_start(ctx);\n    r = BN_CTX_get(ctx);\n    t = BN_CTX_get(ctx);\n    if (t == NULL)\n        goto err;\n\n    if (in_mont != NULL)\n        mont = in_mont;\n    else {\n        if ((mont = BN_MONT_CTX_new()) == NULL)\n            goto err;\n        if (!BN_MONT_CTX_set(mont, m, ctx))\n            goto err;\n    }\n\n    r_is_one = 1;               /* except for Montgomery factor */\n\n    /* bits-1 >= 0 */\n\n    /* The result is accumulated in the product r*w. */\n    w = a;                      /* bit 'bits-1' of 'p' is always set */\n    for (b = bits - 2; b >= 0; b--) {\n        /* First, square r*w. */\n        next_w = w * w;\n        if ((next_w / w) != w) { /* overflow */\n            if (r_is_one) {\n                if (!BN_TO_MONTGOMERY_WORD(r, w, mont))\n                    goto err;\n                r_is_one = 0;\n            } else {\n                if (!BN_MOD_MUL_WORD(r, w, m))\n                    goto err;\n            }\n            next_w = 1;\n        }\n        w = next_w;\n        if (!r_is_one) {\n            if (!BN_mod_mul_montgomery(r, r, r, mont, ctx))\n                goto err;\n        }\n\n        /* Second, multiply r*w by 'a' if exponent bit is set. */\n        if (BN_is_bit_set(p, b)) {\n            next_w = w * a;\n            if ((next_w / a) != w) { /* overflow */\n                if (r_is_one) {\n                    if (!BN_TO_MONTGOMERY_WORD(r, w, mont))\n                        goto err;\n                    r_is_one = 0;\n                } else {\n                    if (!BN_MOD_MUL_WORD(r, w, m))\n                        goto err;\n                }\n                next_w = a;\n            }\n            w = next_w;\n        }\n    }\n\n    /* Finally, set r:=r*w. */\n    if (w != 1) {\n        if (r_is_one) {\n            if (!BN_TO_MONTGOMERY_WORD(r, w, mont))\n                goto err;\n            r_is_one = 0;\n        } else {\n            if (!BN_MOD_MUL_WORD(r, w, m))\n                goto err;\n        }\n    }\n\n    if (r_is_one) {             /* can happen only if a == 1 */\n        if (!BN_one(rr))\n            goto err;\n    } else {\n        if (!BN_from_montgomery(rr, r, mont, ctx))\n            goto err;\n    }\n    ret = 1;\n err:\n    if (in_mont == NULL)\n        BN_MONT_CTX_free(mont);\n    BN_CTX_end(ctx);\n    bn_check_top(rr);\n    return ret;\n}\n\n/* The old fallback, simple version :-) */\nint BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                      const BIGNUM *m, BN_CTX *ctx)\n{\n    int i, j, bits, ret = 0, wstart, wend, window, wvalue;\n    int start = 1;\n    BIGNUM *d;\n    /* Table of variables obtained from 'ctx' */\n    BIGNUM *val[TABLE_SIZE];\n\n    if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(a, BN_FLG_CONSTTIME) != 0\n            || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {\n        /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */\n        BNerr(BN_F_BN_MOD_EXP_SIMPLE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n\n    bits = BN_num_bits(p);\n    if (bits == 0) {\n        /* x**0 mod 1, or x**0 mod -1 is still zero. */\n        if (BN_abs_is_word(m, 1)) {\n            ret = 1;\n            BN_zero(r);\n        } else {\n            ret = BN_one(r);\n        }\n        return ret;\n    }\n\n    BN_CTX_start(ctx);\n    d = BN_CTX_get(ctx);\n    val[0] = BN_CTX_get(ctx);\n    if (val[0] == NULL)\n        goto err;\n\n    if (!BN_nnmod(val[0], a, m, ctx))\n        goto err;               /* 1 */\n    if (BN_is_zero(val[0])) {\n        BN_zero(r);\n        ret = 1;\n        goto err;\n    }\n\n    window = BN_window_bits_for_exponent_size(bits);\n    if (window > 1) {\n        if (!BN_mod_mul(d, val[0], val[0], m, ctx))\n            goto err;           /* 2 */\n        j = 1 << (window - 1);\n        for (i = 1; i < j; i++) {\n            if (((val[i] = BN_CTX_get(ctx)) == NULL) ||\n                !BN_mod_mul(val[i], val[i - 1], d, m, ctx))\n                goto err;\n        }\n    }\n\n    start = 1;                  /* This is used to avoid multiplication etc\n                                 * when there is only the value '1' in the\n                                 * buffer. */\n    wvalue = 0;                 /* The 'value' of the window */\n    wstart = bits - 1;          /* The top bit of the window */\n    wend = 0;                   /* The bottom bit of the window */\n\n    if (!BN_one(r))\n        goto err;\n\n    for (;;) {\n        if (BN_is_bit_set(p, wstart) == 0) {\n            if (!start)\n                if (!BN_mod_mul(r, r, r, m, ctx))\n                    goto err;\n            if (wstart == 0)\n                break;\n            wstart--;\n            continue;\n        }\n        /*\n         * We now have wstart on a 'set' bit, we now need to work out how bit\n         * a window to do.  To do this we need to scan forward until the last\n         * set bit before the end of the window\n         */\n        j = wstart;\n        wvalue = 1;\n        wend = 0;\n        for (i = 1; i < window; i++) {\n            if (wstart - i < 0)\n                break;\n            if (BN_is_bit_set(p, wstart - i)) {\n                wvalue <<= (i - wend);\n                wvalue |= 1;\n                wend = i;\n            }\n        }\n\n        /* wend is the size of the current window */\n        j = wend + 1;\n        /* add the 'bytes above' */\n        if (!start)\n            for (i = 0; i < j; i++) {\n                if (!BN_mod_mul(r, r, r, m, ctx))\n                    goto err;\n            }\n\n        /* wvalue will be an odd number < 2^window */\n        if (!BN_mod_mul(r, r, val[wvalue >> 1], m, ctx))\n            goto err;\n\n        /* move the 'window' down further */\n        wstart -= wend + 1;\n        wvalue = 0;\n        start = 0;\n        if (wstart < 0)\n            break;\n    }\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(r);\n    return ret;\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_gcd.c",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\n/*\n * bn_mod_inverse_no_branch is a special version of BN_mod_inverse. It does\n * not contain branches that may leak sensitive information.\n *\n * This is a static function, we ensure all callers in this file pass valid\n * arguments: all passed pointers here are non-NULL.\n */\nstatic ossl_inline\nBIGNUM *bn_mod_inverse_no_branch(BIGNUM *in,\n                                 const BIGNUM *a, const BIGNUM *n,\n                                 BN_CTX *ctx, int *pnoinv)\n{\n    BIGNUM *A, *B, *X, *Y, *M, *D, *T, *R = NULL;\n    BIGNUM *ret = NULL;\n    int sign;\n\n    bn_check_top(a);\n    bn_check_top(n);\n\n    BN_CTX_start(ctx);\n    A = BN_CTX_get(ctx);\n    B = BN_CTX_get(ctx);\n    X = BN_CTX_get(ctx);\n    D = BN_CTX_get(ctx);\n    M = BN_CTX_get(ctx);\n    Y = BN_CTX_get(ctx);\n    T = BN_CTX_get(ctx);\n    if (T == NULL)\n        goto err;\n\n    if (in == NULL)\n        R = BN_new();\n    else\n        R = in;\n    if (R == NULL)\n        goto err;\n\n    BN_one(X);\n    BN_zero(Y);\n    if (BN_copy(B, a) == NULL)\n        goto err;\n    if (BN_copy(A, n) == NULL)\n        goto err;\n    A->neg = 0;\n\n    if (B->neg || (BN_ucmp(B, A) >= 0)) {\n        /*\n         * Turn BN_FLG_CONSTTIME flag on, so that when BN_div is invoked,\n         * BN_div_no_branch will be called eventually.\n         */\n         {\n            BIGNUM local_B;\n            bn_init(&local_B);\n            BN_with_flags(&local_B, B, BN_FLG_CONSTTIME);\n            if (!BN_nnmod(B, &local_B, A, ctx))\n                goto err;\n            /* Ensure local_B goes out of scope before any further use of B */\n        }\n    }\n    sign = -1;\n    /*-\n     * From  B = a mod |n|,  A = |n|  it follows that\n     *\n     *      0 <= B < A,\n     *     -sign*X*a  ==  B   (mod |n|),\n     *      sign*Y*a  ==  A   (mod |n|).\n     */\n\n    while (!BN_is_zero(B)) {\n        BIGNUM *tmp;\n\n        /*-\n         *      0 < B < A,\n         * (*) -sign*X*a  ==  B   (mod |n|),\n         *      sign*Y*a  ==  A   (mod |n|)\n         */\n\n        /*\n         * Turn BN_FLG_CONSTTIME flag on, so that when BN_div is invoked,\n         * BN_div_no_branch will be called eventually.\n         */\n        {\n            BIGNUM local_A;\n            bn_init(&local_A);\n            BN_with_flags(&local_A, A, BN_FLG_CONSTTIME);\n\n            /* (D, M) := (A/B, A%B) ... */\n            if (!BN_div(D, M, &local_A, B, ctx))\n                goto err;\n            /* Ensure local_A goes out of scope before any further use of A */\n        }\n\n        /*-\n         * Now\n         *      A = D*B + M;\n         * thus we have\n         * (**)  sign*Y*a  ==  D*B + M   (mod |n|).\n         */\n\n        tmp = A;                /* keep the BIGNUM object, the value does not\n                                 * matter */\n\n        /* (A, B) := (B, A mod B) ... */\n        A = B;\n        B = M;\n        /* ... so we have  0 <= B < A  again */\n\n        /*-\n         * Since the former  M  is now  B  and the former  B  is now  A,\n         * (**) translates into\n         *       sign*Y*a  ==  D*A + B    (mod |n|),\n         * i.e.\n         *       sign*Y*a - D*A  ==  B    (mod |n|).\n         * Similarly, (*) translates into\n         *      -sign*X*a  ==  A          (mod |n|).\n         *\n         * Thus,\n         *   sign*Y*a + D*sign*X*a  ==  B  (mod |n|),\n         * i.e.\n         *        sign*(Y + D*X)*a  ==  B  (mod |n|).\n         *\n         * So if we set  (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at\n         *      -sign*X*a  ==  B   (mod |n|),\n         *       sign*Y*a  ==  A   (mod |n|).\n         * Note that  X  and  Y  stay non-negative all the time.\n         */\n\n        if (!BN_mul(tmp, D, X, ctx))\n            goto err;\n        if (!BN_add(tmp, tmp, Y))\n            goto err;\n\n        M = Y;                  /* keep the BIGNUM object, the value does not\n                                 * matter */\n        Y = X;\n        X = tmp;\n        sign = -sign;\n    }\n\n    /*-\n     * The while loop (Euclid's algorithm) ends when\n     *      A == gcd(a,n);\n     * we have\n     *       sign*Y*a  ==  A  (mod |n|),\n     * where  Y  is non-negative.\n     */\n\n    if (sign < 0) {\n        if (!BN_sub(Y, n, Y))\n            goto err;\n    }\n    /* Now  Y*a  ==  A  (mod |n|).  */\n\n    if (BN_is_one(A)) {\n        /* Y*a == 1  (mod |n|) */\n        if (!Y->neg && BN_ucmp(Y, n) < 0) {\n            if (!BN_copy(R, Y))\n                goto err;\n        } else {\n            if (!BN_nnmod(R, Y, n, ctx))\n                goto err;\n        }\n    } else {\n        *pnoinv = 1;\n        /* caller sets the BN_R_NO_INVERSE error */\n        goto err;\n    }\n\n    ret = R;\n    *pnoinv = 0;\n\n err:\n    if ((ret == NULL) && (in == NULL))\n        BN_free(R);\n    BN_CTX_end(ctx);\n    bn_check_top(ret);\n    return ret;\n}\n\n/*\n * This is an internal function, we assume all callers pass valid arguments:\n * all pointers passed here are assumed non-NULL.\n */\nBIGNUM *int_bn_mod_inverse(BIGNUM *in,\n                           const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx,\n                           int *pnoinv)\n{\n    BIGNUM *A, *B, *X, *Y, *M, *D, *T, *R = NULL;\n    BIGNUM *ret = NULL;\n    int sign;\n\n    /* This is invalid input so we don't worry about constant time here */\n    if (BN_abs_is_word(n, 1) || BN_is_zero(n)) {\n        *pnoinv = 1;\n        return NULL;\n    }\n\n    *pnoinv = 0;\n\n    if ((BN_get_flags(a, BN_FLG_CONSTTIME) != 0)\n        || (BN_get_flags(n, BN_FLG_CONSTTIME) != 0)) {\n        return bn_mod_inverse_no_branch(in, a, n, ctx, pnoinv);\n    }\n\n    bn_check_top(a);\n    bn_check_top(n);\n\n    BN_CTX_start(ctx);\n    A = BN_CTX_get(ctx);\n    B = BN_CTX_get(ctx);\n    X = BN_CTX_get(ctx);\n    D = BN_CTX_get(ctx);\n    M = BN_CTX_get(ctx);\n    Y = BN_CTX_get(ctx);\n    T = BN_CTX_get(ctx);\n    if (T == NULL)\n        goto err;\n\n    if (in == NULL)\n        R = BN_new();\n    else\n        R = in;\n    if (R == NULL)\n        goto err;\n\n    BN_one(X);\n    BN_zero(Y);\n    if (BN_copy(B, a) == NULL)\n        goto err;\n    if (BN_copy(A, n) == NULL)\n        goto err;\n    A->neg = 0;\n    if (B->neg || (BN_ucmp(B, A) >= 0)) {\n        if (!BN_nnmod(B, B, A, ctx))\n            goto err;\n    }\n    sign = -1;\n    /*-\n     * From  B = a mod |n|,  A = |n|  it follows that\n     *\n     *      0 <= B < A,\n     *     -sign*X*a  ==  B   (mod |n|),\n     *      sign*Y*a  ==  A   (mod |n|).\n     */\n\n    if (BN_is_odd(n) && (BN_num_bits(n) <= 2048)) {\n        /*\n         * Binary inversion algorithm; requires odd modulus. This is faster\n         * than the general algorithm if the modulus is sufficiently small\n         * (about 400 .. 500 bits on 32-bit systems, but much more on 64-bit\n         * systems)\n         */\n        int shift;\n\n        while (!BN_is_zero(B)) {\n            /*-\n             *      0 < B < |n|,\n             *      0 < A <= |n|,\n             * (1) -sign*X*a  ==  B   (mod |n|),\n             * (2)  sign*Y*a  ==  A   (mod |n|)\n             */\n\n            /*\n             * Now divide B by the maximum possible power of two in the\n             * integers, and divide X by the same value mod |n|. When we're\n             * done, (1) still holds.\n             */\n            shift = 0;\n            while (!BN_is_bit_set(B, shift)) { /* note that 0 < B */\n                shift++;\n\n                if (BN_is_odd(X)) {\n                    if (!BN_uadd(X, X, n))\n                        goto err;\n                }\n                /*\n                 * now X is even, so we can easily divide it by two\n                 */\n                if (!BN_rshift1(X, X))\n                    goto err;\n            }\n            if (shift > 0) {\n                if (!BN_rshift(B, B, shift))\n                    goto err;\n            }\n\n            /*\n             * Same for A and Y.  Afterwards, (2) still holds.\n             */\n            shift = 0;\n            while (!BN_is_bit_set(A, shift)) { /* note that 0 < A */\n                shift++;\n\n                if (BN_is_odd(Y)) {\n                    if (!BN_uadd(Y, Y, n))\n                        goto err;\n                }\n                /* now Y is even */\n                if (!BN_rshift1(Y, Y))\n                    goto err;\n            }\n            if (shift > 0) {\n                if (!BN_rshift(A, A, shift))\n                    goto err;\n            }\n\n            /*-\n             * We still have (1) and (2).\n             * Both  A  and  B  are odd.\n             * The following computations ensure that\n             *\n             *     0 <= B < |n|,\n             *      0 < A < |n|,\n             * (1) -sign*X*a  ==  B   (mod |n|),\n             * (2)  sign*Y*a  ==  A   (mod |n|),\n             *\n             * and that either  A  or  B  is even in the next iteration.\n             */\n            if (BN_ucmp(B, A) >= 0) {\n                /* -sign*(X + Y)*a == B - A  (mod |n|) */\n                if (!BN_uadd(X, X, Y))\n                    goto err;\n                /*\n                 * NB: we could use BN_mod_add_quick(X, X, Y, n), but that\n                 * actually makes the algorithm slower\n                 */\n                if (!BN_usub(B, B, A))\n                    goto err;\n            } else {\n                /*  sign*(X + Y)*a == A - B  (mod |n|) */\n                if (!BN_uadd(Y, Y, X))\n                    goto err;\n                /*\n                 * as above, BN_mod_add_quick(Y, Y, X, n) would slow things down\n                 */\n                if (!BN_usub(A, A, B))\n                    goto err;\n            }\n        }\n    } else {\n        /* general inversion algorithm */\n\n        while (!BN_is_zero(B)) {\n            BIGNUM *tmp;\n\n            /*-\n             *      0 < B < A,\n             * (*) -sign*X*a  ==  B   (mod |n|),\n             *      sign*Y*a  ==  A   (mod |n|)\n             */\n\n            /* (D, M) := (A/B, A%B) ... */\n            if (BN_num_bits(A) == BN_num_bits(B)) {\n                if (!BN_one(D))\n                    goto err;\n                if (!BN_sub(M, A, B))\n                    goto err;\n            } else if (BN_num_bits(A) == BN_num_bits(B) + 1) {\n                /* A/B is 1, 2, or 3 */\n                if (!BN_lshift1(T, B))\n                    goto err;\n                if (BN_ucmp(A, T) < 0) {\n                    /* A < 2*B, so D=1 */\n                    if (!BN_one(D))\n                        goto err;\n                    if (!BN_sub(M, A, B))\n                        goto err;\n                } else {\n                    /* A >= 2*B, so D=2 or D=3 */\n                    if (!BN_sub(M, A, T))\n                        goto err;\n                    if (!BN_add(D, T, B))\n                        goto err; /* use D (:= 3*B) as temp */\n                    if (BN_ucmp(A, D) < 0) {\n                        /* A < 3*B, so D=2 */\n                        if (!BN_set_word(D, 2))\n                            goto err;\n                        /*\n                         * M (= A - 2*B) already has the correct value\n                         */\n                    } else {\n                        /* only D=3 remains */\n                        if (!BN_set_word(D, 3))\n                            goto err;\n                        /*\n                         * currently M = A - 2*B, but we need M = A - 3*B\n                         */\n                        if (!BN_sub(M, M, B))\n                            goto err;\n                    }\n                }\n            } else {\n                if (!BN_div(D, M, A, B, ctx))\n                    goto err;\n            }\n\n            /*-\n             * Now\n             *      A = D*B + M;\n             * thus we have\n             * (**)  sign*Y*a  ==  D*B + M   (mod |n|).\n             */\n\n            tmp = A;    /* keep the BIGNUM object, the value does not matter */\n\n            /* (A, B) := (B, A mod B) ... */\n            A = B;\n            B = M;\n            /* ... so we have  0 <= B < A  again */\n\n            /*-\n             * Since the former  M  is now  B  and the former  B  is now  A,\n             * (**) translates into\n             *       sign*Y*a  ==  D*A + B    (mod |n|),\n             * i.e.\n             *       sign*Y*a - D*A  ==  B    (mod |n|).\n             * Similarly, (*) translates into\n             *      -sign*X*a  ==  A          (mod |n|).\n             *\n             * Thus,\n             *   sign*Y*a + D*sign*X*a  ==  B  (mod |n|),\n             * i.e.\n             *        sign*(Y + D*X)*a  ==  B  (mod |n|).\n             *\n             * So if we set  (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at\n             *      -sign*X*a  ==  B   (mod |n|),\n             *       sign*Y*a  ==  A   (mod |n|).\n             * Note that  X  and  Y  stay non-negative all the time.\n             */\n\n            /*\n             * most of the time D is very small, so we can optimize tmp := D*X+Y\n             */\n            if (BN_is_one(D)) {\n                if (!BN_add(tmp, X, Y))\n                    goto err;\n            } else {\n                if (BN_is_word(D, 2)) {\n                    if (!BN_lshift1(tmp, X))\n                        goto err;\n                } else if (BN_is_word(D, 4)) {\n                    if (!BN_lshift(tmp, X, 2))\n                        goto err;\n                } else if (D->top == 1) {\n                    if (!BN_copy(tmp, X))\n                        goto err;\n                    if (!BN_mul_word(tmp, D->d[0]))\n                        goto err;\n                } else {\n                    if (!BN_mul(tmp, D, X, ctx))\n                        goto err;\n                }\n                if (!BN_add(tmp, tmp, Y))\n                    goto err;\n            }\n\n            M = Y;      /* keep the BIGNUM object, the value does not matter */\n            Y = X;\n            X = tmp;\n            sign = -sign;\n        }\n    }\n\n    /*-\n     * The while loop (Euclid's algorithm) ends when\n     *      A == gcd(a,n);\n     * we have\n     *       sign*Y*a  ==  A  (mod |n|),\n     * where  Y  is non-negative.\n     */\n\n    if (sign < 0) {\n        if (!BN_sub(Y, n, Y))\n            goto err;\n    }\n    /* Now  Y*a  ==  A  (mod |n|).  */\n\n    if (BN_is_one(A)) {\n        /* Y*a == 1  (mod |n|) */\n        if (!Y->neg && BN_ucmp(Y, n) < 0) {\n            if (!BN_copy(R, Y))\n                goto err;\n        } else {\n            if (!BN_nnmod(R, Y, n, ctx))\n                goto err;\n        }\n    } else {\n        *pnoinv = 1;\n        goto err;\n    }\n    ret = R;\n err:\n    if ((ret == NULL) && (in == NULL))\n        BN_free(R);\n    BN_CTX_end(ctx);\n    bn_check_top(ret);\n    return ret;\n}\n\n/* solves ax == 1 (mod n) */\nBIGNUM *BN_mod_inverse(BIGNUM *in,\n                       const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *rv;\n    int noinv = 0;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL) {\n            BNerr(BN_F_BN_MOD_INVERSE, ERR_R_MALLOC_FAILURE);\n            return NULL;\n        }\n    }\n\n    rv = int_bn_mod_inverse(in, a, n, ctx, &noinv);\n    if (noinv)\n        BNerr(BN_F_BN_MOD_INVERSE, BN_R_NO_INVERSE);\n    BN_CTX_free(new_ctx);\n    return rv;\n}\n\n/*-\n * This function is based on the constant-time GCD work by Bernstein and Yang:\n * https://eprint.iacr.org/2019/266\n * Generalized fast GCD function to allow even inputs.\n * The algorithm first finds the shared powers of 2 between\n * the inputs, and removes them, reducing at least one of the\n * inputs to an odd value. Then it proceeds to calculate the GCD.\n * Before returning the resulting GCD, we take care of adding\n * back the powers of two removed at the beginning.\n * Note 1: we assume the bit length of both inputs is public information,\n * since access to top potentially leaks this information.\n */\nint BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx)\n{\n    BIGNUM *g, *temp = NULL;\n    BN_ULONG mask = 0;\n    int i, j, top, rlen, glen, m, bit = 1, delta = 1, cond = 0, shifts = 0, ret = 0;\n\n    /* Note 2: zero input corner cases are not constant-time since they are\n     * handled immediately. An attacker can run an attack under this\n     * assumption without the need of side-channel information. */\n    if (BN_is_zero(in_b)) {\n        ret = BN_copy(r, in_a) != NULL;\n        r->neg = 0;\n        return ret;\n    }\n    if (BN_is_zero(in_a)) {\n        ret = BN_copy(r, in_b) != NULL;\n        r->neg = 0;\n        return ret;\n    }\n\n    bn_check_top(in_a);\n    bn_check_top(in_b);\n\n    BN_CTX_start(ctx);\n    temp = BN_CTX_get(ctx);\n    g = BN_CTX_get(ctx);\n\n    /* make r != 0, g != 0 even, so BN_rshift is not a potential nop */\n    if (g == NULL\n        || !BN_lshift1(g, in_b)\n        || !BN_lshift1(r, in_a))\n        goto err;\n\n    /* find shared powers of two, i.e. \"shifts\" >= 1 */\n    for (i = 0; i < r->dmax && i < g->dmax; i++) {\n        mask = ~(r->d[i] | g->d[i]);\n        for (j = 0; j < BN_BITS2; j++) {\n            bit &= mask;\n            shifts += bit;\n            mask >>= 1;\n        }\n    }\n\n    /* subtract shared powers of two; shifts >= 1 */\n    if (!BN_rshift(r, r, shifts)\n        || !BN_rshift(g, g, shifts))\n        goto err;\n\n    /* expand to biggest nword, with room for a possible extra word */\n    top = 1 + ((r->top >= g->top) ? r->top : g->top);\n    if (bn_wexpand(r, top) == NULL\n        || bn_wexpand(g, top) == NULL\n        || bn_wexpand(temp, top) == NULL)\n        goto err;\n\n    /* re arrange inputs s.t. r is odd */\n    BN_consttime_swap((~r->d[0]) & 1, r, g, top);\n\n    /* compute the number of iterations */\n    rlen = BN_num_bits(r);\n    glen = BN_num_bits(g);\n    m = 4 + 3 * ((rlen >= glen) ? rlen : glen);\n\n    for (i = 0; i < m; i++) {\n        /* conditionally flip signs if delta is positive and g is odd */\n        cond = (-delta >> (8 * sizeof(delta) - 1)) & g->d[0] & 1\n            /* make sure g->top > 0 (i.e. if top == 0 then g == 0 always) */\n            & (~((g->top - 1) >> (sizeof(g->top) * 8 - 1)));\n        delta = (-cond & -delta) | ((cond - 1) & delta);\n        r->neg ^= cond;\n        /* swap */\n        BN_consttime_swap(cond, r, g, top);\n\n        /* elimination step */\n        delta++;\n        if (!BN_add(temp, g, r))\n            goto err;\n        BN_consttime_swap(g->d[0] & 1 /* g is odd */\n                /* make sure g->top > 0 (i.e. if top == 0 then g == 0 always) */\n                & (~((g->top - 1) >> (sizeof(g->top) * 8 - 1))),\n                g, temp, top);\n        if (!BN_rshift1(g, g))\n            goto err;\n    }\n\n    /* remove possible negative sign */\n    r->neg = 0;\n    /* add powers of 2 removed, then correct the artificial shift */\n    if (!BN_lshift(r, r, shifts)\n        || !BN_rshift1(r, r))\n        goto err;\n\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(r);\n    return ret;\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_intern.c",
    "content": "/*\n * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\n/*\n * Determine the modified width-(w+1) Non-Adjacent Form (wNAF) of 'scalar'.\n * This is an array  r[]  of values that are either zero or odd with an\n * absolute value less than  2^w  satisfying\n *     scalar = \\sum_j r[j]*2^j\n * where at most one of any  w+1  consecutive digits is non-zero\n * with the exception that the most significant digit may be only\n * w-1 zeros away from that next non-zero digit.\n */\nsigned char *bn_compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)\n{\n    int window_val;\n    signed char *r = NULL;\n    int sign = 1;\n    int bit, next_bit, mask;\n    size_t len = 0, j;\n\n    if (BN_is_zero(scalar)) {\n        r = OPENSSL_malloc(1);\n        if (r == NULL) {\n            BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        r[0] = 0;\n        *ret_len = 1;\n        return r;\n    }\n\n    if (w <= 0 || w > 7) {      /* 'signed char' can represent integers with\n                                 * absolute values less than 2^7 */\n        BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    bit = 1 << w;               /* at most 128 */\n    next_bit = bit << 1;        /* at most 256 */\n    mask = next_bit - 1;        /* at most 255 */\n\n    if (BN_is_negative(scalar)) {\n        sign = -1;\n    }\n\n    if (scalar->d == NULL || scalar->top == 0) {\n        BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n\n    len = BN_num_bits(scalar);\n    r = OPENSSL_malloc(len + 1); /*\n                                  * Modified wNAF may be one digit longer than binary representation\n                                  * (*ret_len will be set to the actual length, i.e. at most\n                                  * BN_num_bits(scalar) + 1)\n                                  */\n    if (r == NULL) {\n        BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    window_val = scalar->d[0] & mask;\n    j = 0;\n    while ((window_val != 0) || (j + w + 1 < len)) { /* if j+w+1 >= len,\n                                                      * window_val will not\n                                                      * increase */\n        int digit = 0;\n\n        /* 0 <= window_val <= 2^(w+1) */\n\n        if (window_val & 1) {\n            /* 0 < window_val < 2^(w+1) */\n\n            if (window_val & bit) {\n                digit = window_val - next_bit; /* -2^w < digit < 0 */\n\n#if 1                           /* modified wNAF */\n                if (j + w + 1 >= len) {\n                    /*\n                     * Special case for generating modified wNAFs:\n                     * no new bits will be added into window_val,\n                     * so using a positive digit here will decrease\n                     * the total length of the representation\n                     */\n\n                    digit = window_val & (mask >> 1); /* 0 < digit < 2^w */\n                }\n#endif\n            } else {\n                digit = window_val; /* 0 < digit < 2^w */\n            }\n\n            if (digit <= -bit || digit >= bit || !(digit & 1)) {\n                BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n\n            window_val -= digit;\n\n            /*\n             * now window_val is 0 or 2^(w+1) in standard wNAF generation;\n             * for modified window NAFs, it may also be 2^w\n             */\n            if (window_val != 0 && window_val != next_bit\n                && window_val != bit) {\n                BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n        }\n\n        r[j++] = sign * digit;\n\n        window_val >>= 1;\n        window_val += bit * BN_is_bit_set(scalar, j + w);\n\n        if (window_val > next_bit) {\n            BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n    }\n\n    if (j > len + 1) {\n        BNerr(BN_F_BN_COMPUTE_WNAF, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    *ret_len = j;\n    return r;\n\n err:\n    OPENSSL_free(r);\n    return NULL;\n}\n\nint bn_get_top(const BIGNUM *a)\n{\n    return a->top;\n}\n\nint bn_get_dmax(const BIGNUM *a)\n{\n    return a->dmax;\n}\n\nvoid bn_set_all_zero(BIGNUM *a)\n{\n    int i;\n\n    for (i = a->top; i < a->dmax; i++)\n        a->d[i] = 0;\n}\n\nint bn_copy_words(BN_ULONG *out, const BIGNUM *in, int size)\n{\n    if (in->top > size)\n        return 0;\n\n    memset(out, 0, sizeof(*out) * size);\n    if (in->d != NULL)\n        memcpy(out, in->d, sizeof(*out) * in->top);\n    return 1;\n}\n\nBN_ULONG *bn_get_words(const BIGNUM *a)\n{\n    return a->d;\n}\n\nvoid bn_set_static_words(BIGNUM *a, const BN_ULONG *words, int size)\n{\n    /*\n     * |const| qualifier omission is compensated by BN_FLG_STATIC_DATA\n     * flag, which effectively means \"read-only data\".\n     */\n    a->d = (BN_ULONG *)words;\n    a->dmax = a->top = size;\n    a->neg = 0;\n    a->flags |= BN_FLG_STATIC_DATA;\n    bn_correct_top(a);\n}\n\nint bn_set_words(BIGNUM *a, const BN_ULONG *words, int num_words)\n{\n    if (bn_wexpand(a, num_words) == NULL) {\n        BNerr(BN_F_BN_SET_WORDS, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n\n    memcpy(a->d, words, sizeof(BN_ULONG) * num_words);\n    a->top = num_words;\n    bn_correct_top(a);\n    return 1;\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_lib.c",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <assert.h>\n#include <limits.h>\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n#include <openssl/opensslconf.h>\n#include \"internal/constant_time.h\"\n\n/* This stuff appears to be completely unused, so is deprecated */\n#if OPENSSL_API_COMPAT < 0x00908000L\n/*-\n * For a 32 bit machine\n * 2 -   4 ==  128\n * 3 -   8 ==  256\n * 4 -  16 ==  512\n * 5 -  32 == 1024\n * 6 -  64 == 2048\n * 7 - 128 == 4096\n * 8 - 256 == 8192\n */\nstatic int bn_limit_bits = 0;\nstatic int bn_limit_num = 8;    /* (1<<bn_limit_bits) */\nstatic int bn_limit_bits_low = 0;\nstatic int bn_limit_num_low = 8; /* (1<<bn_limit_bits_low) */\nstatic int bn_limit_bits_high = 0;\nstatic int bn_limit_num_high = 8; /* (1<<bn_limit_bits_high) */\nstatic int bn_limit_bits_mont = 0;\nstatic int bn_limit_num_mont = 8; /* (1<<bn_limit_bits_mont) */\n\nvoid BN_set_params(int mult, int high, int low, int mont)\n{\n    if (mult >= 0) {\n        if (mult > (int)(sizeof(int) * 8) - 1)\n            mult = sizeof(int) * 8 - 1;\n        bn_limit_bits = mult;\n        bn_limit_num = 1 << mult;\n    }\n    if (high >= 0) {\n        if (high > (int)(sizeof(int) * 8) - 1)\n            high = sizeof(int) * 8 - 1;\n        bn_limit_bits_high = high;\n        bn_limit_num_high = 1 << high;\n    }\n    if (low >= 0) {\n        if (low > (int)(sizeof(int) * 8) - 1)\n            low = sizeof(int) * 8 - 1;\n        bn_limit_bits_low = low;\n        bn_limit_num_low = 1 << low;\n    }\n    if (mont >= 0) {\n        if (mont > (int)(sizeof(int) * 8) - 1)\n            mont = sizeof(int) * 8 - 1;\n        bn_limit_bits_mont = mont;\n        bn_limit_num_mont = 1 << mont;\n    }\n}\n\nint BN_get_params(int which)\n{\n    if (which == 0)\n        return bn_limit_bits;\n    else if (which == 1)\n        return bn_limit_bits_high;\n    else if (which == 2)\n        return bn_limit_bits_low;\n    else if (which == 3)\n        return bn_limit_bits_mont;\n    else\n        return 0;\n}\n#endif\n\nconst BIGNUM *BN_value_one(void)\n{\n    static const BN_ULONG data_one = 1L;\n    static const BIGNUM const_one =\n        { (BN_ULONG *)&data_one, 1, 1, 0, BN_FLG_STATIC_DATA };\n\n    return &const_one;\n}\n\n/*\n * Old Visual Studio ARM compiler miscompiles BN_num_bits_word()\n * https://mta.openssl.org/pipermail/openssl-users/2018-August/008465.html\n */\n#if defined(_MSC_VER) && defined(_ARM_) && defined(_WIN32_WCE) \\\n    && _MSC_VER>=1400 && _MSC_VER<1501\n# define MS_BROKEN_BN_num_bits_word\n# pragma optimize(\"\", off)\n#endif\nint BN_num_bits_word(BN_ULONG l)\n{\n    BN_ULONG x, mask;\n    int bits = (l != 0);\n\n#if BN_BITS2 > 32\n    x = l >> 32;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 32 & mask;\n    l ^= (x ^ l) & mask;\n#endif\n\n    x = l >> 16;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 16 & mask;\n    l ^= (x ^ l) & mask;\n\n    x = l >> 8;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 8 & mask;\n    l ^= (x ^ l) & mask;\n\n    x = l >> 4;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 4 & mask;\n    l ^= (x ^ l) & mask;\n\n    x = l >> 2;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 2 & mask;\n    l ^= (x ^ l) & mask;\n\n    x = l >> 1;\n    mask = (0 - x) & BN_MASK2;\n    mask = (0 - (mask >> (BN_BITS2 - 1)));\n    bits += 1 & mask;\n\n    return bits;\n}\n#ifdef MS_BROKEN_BN_num_bits_word\n# pragma optimize(\"\", on)\n#endif\n\n/*\n * This function still leaks `a->dmax`: it's caller's responsibility to\n * expand the input `a` in advance to a public length.\n */\nstatic ossl_inline\nint bn_num_bits_consttime(const BIGNUM *a)\n{\n    int j, ret;\n    unsigned int mask, past_i;\n    int i = a->top - 1;\n    bn_check_top(a);\n\n    for (j = 0, past_i = 0, ret = 0; j < a->dmax; j++) {\n        mask = constant_time_eq_int(i, j); /* 0xff..ff if i==j, 0x0 otherwise */\n\n        ret += BN_BITS2 & (~mask & ~past_i);\n        ret += BN_num_bits_word(a->d[j]) & mask;\n\n        past_i |= mask; /* past_i will become 0xff..ff after i==j */\n    }\n\n    /*\n     * if BN_is_zero(a) => i is -1 and ret contains garbage, so we mask the\n     * final result.\n     */\n    mask = ~(constant_time_eq_int(i, ((int)-1)));\n\n    return ret & mask;\n}\n\nint BN_num_bits(const BIGNUM *a)\n{\n    int i = a->top - 1;\n    bn_check_top(a);\n\n    if (a->flags & BN_FLG_CONSTTIME) {\n        /*\n         * We assume that BIGNUMs flagged as CONSTTIME have also been expanded\n         * so that a->dmax is not leaking secret information.\n         *\n         * In other words, it's the caller's responsibility to ensure `a` has\n         * been preallocated in advance to a public length if we hit this\n         * branch.\n         *\n         */\n        return bn_num_bits_consttime(a);\n    }\n\n    if (BN_is_zero(a))\n        return 0;\n\n    return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));\n}\n\nstatic void bn_free_d(BIGNUM *a, int clear)\n{\n    if (BN_get_flags(a, BN_FLG_SECURE))\n        OPENSSL_secure_clear_free(a->d, a->dmax * sizeof(a->d[0]));\n    else if (clear != 0)\n        OPENSSL_clear_free(a->d, a->dmax * sizeof(a->d[0]));\n    else\n        OPENSSL_free(a->d);\n}\n\n\nvoid BN_clear_free(BIGNUM *a)\n{\n    if (a == NULL)\n        return;\n    if (a->d != NULL && !BN_get_flags(a, BN_FLG_STATIC_DATA))\n        bn_free_d(a, 1);\n    if (BN_get_flags(a, BN_FLG_MALLOCED)) {\n        OPENSSL_cleanse(a, sizeof(*a));\n        OPENSSL_free(a);\n    }\n}\n\nvoid BN_free(BIGNUM *a)\n{\n    if (a == NULL)\n        return;\n    if (!BN_get_flags(a, BN_FLG_STATIC_DATA))\n        bn_free_d(a, 0);\n    if (a->flags & BN_FLG_MALLOCED)\n        OPENSSL_free(a);\n}\n\nvoid bn_init(BIGNUM *a)\n{\n    static BIGNUM nilbn;\n\n    *a = nilbn;\n    bn_check_top(a);\n}\n\nBIGNUM *BN_new(void)\n{\n    BIGNUM *ret;\n\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    ret->flags = BN_FLG_MALLOCED;\n    bn_check_top(ret);\n    return ret;\n}\n\n BIGNUM *BN_secure_new(void)\n {\n     BIGNUM *ret = BN_new();\n     if (ret != NULL)\n         ret->flags |= BN_FLG_SECURE;\n     return ret;\n }\n\n/* This is used by bn_expand2() */\n/* The caller MUST check that words > b->dmax before calling this */\nstatic BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)\n{\n    BN_ULONG *a = NULL;\n\n    if (words > (INT_MAX / (4 * BN_BITS2))) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);\n        return NULL;\n    }\n    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);\n        return NULL;\n    }\n    if (BN_get_flags(b, BN_FLG_SECURE))\n        a = OPENSSL_secure_zalloc(words * sizeof(*a));\n    else\n        a = OPENSSL_zalloc(words * sizeof(*a));\n    if (a == NULL) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n\n    assert(b->top <= words);\n    if (b->top > 0)\n        memcpy(a, b->d, sizeof(*a) * b->top);\n\n    return a;\n}\n\n/*\n * This is an internal function that should not be used in applications. It\n * ensures that 'b' has enough room for a 'words' word number and initialises\n * any unused part of b->d with leading zeros. It is mostly used by the\n * various BIGNUM routines. If there is an error, NULL is returned. If not,\n * 'b' is returned.\n */\n\nBIGNUM *bn_expand2(BIGNUM *b, int words)\n{\n    if (words > b->dmax) {\n        BN_ULONG *a = bn_expand_internal(b, words);\n        if (!a)\n            return NULL;\n        if (b->d != NULL)\n            bn_free_d(b, 1);\n        b->d = a;\n        b->dmax = words;\n    }\n\n    return b;\n}\n\nBIGNUM *BN_dup(const BIGNUM *a)\n{\n    BIGNUM *t;\n\n    if (a == NULL)\n        return NULL;\n    bn_check_top(a);\n\n    t = BN_get_flags(a, BN_FLG_SECURE) ? BN_secure_new() : BN_new();\n    if (t == NULL)\n        return NULL;\n    if (!BN_copy(t, a)) {\n        BN_free(t);\n        return NULL;\n    }\n    bn_check_top(t);\n    return t;\n}\n\nBIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)\n{\n    int bn_words;\n\n    bn_check_top(b);\n\n    bn_words = BN_get_flags(b, BN_FLG_CONSTTIME) ? b->dmax : b->top;\n\n    if (a == b)\n        return a;\n    if (bn_wexpand(a, bn_words) == NULL)\n        return NULL;\n\n    if (b->top > 0)\n        memcpy(a->d, b->d, sizeof(b->d[0]) * bn_words);\n\n    a->neg = b->neg;\n    a->top = b->top;\n    a->flags |= b->flags & BN_FLG_FIXED_TOP;\n    bn_check_top(a);\n    return a;\n}\n\n#define FLAGS_DATA(flags) ((flags) & (BN_FLG_STATIC_DATA \\\n                                    | BN_FLG_CONSTTIME   \\\n                                    | BN_FLG_SECURE      \\\n                                    | BN_FLG_FIXED_TOP))\n#define FLAGS_STRUCT(flags) ((flags) & (BN_FLG_MALLOCED))\n\nvoid BN_swap(BIGNUM *a, BIGNUM *b)\n{\n    int flags_old_a, flags_old_b;\n    BN_ULONG *tmp_d;\n    int tmp_top, tmp_dmax, tmp_neg;\n\n    bn_check_top(a);\n    bn_check_top(b);\n\n    flags_old_a = a->flags;\n    flags_old_b = b->flags;\n\n    tmp_d = a->d;\n    tmp_top = a->top;\n    tmp_dmax = a->dmax;\n    tmp_neg = a->neg;\n\n    a->d = b->d;\n    a->top = b->top;\n    a->dmax = b->dmax;\n    a->neg = b->neg;\n\n    b->d = tmp_d;\n    b->top = tmp_top;\n    b->dmax = tmp_dmax;\n    b->neg = tmp_neg;\n\n    a->flags = FLAGS_STRUCT(flags_old_a) | FLAGS_DATA(flags_old_b);\n    b->flags = FLAGS_STRUCT(flags_old_b) | FLAGS_DATA(flags_old_a);\n    bn_check_top(a);\n    bn_check_top(b);\n}\n\nvoid BN_clear(BIGNUM *a)\n{\n    if (a == NULL)\n        return;\n    bn_check_top(a);\n    if (a->d != NULL)\n        OPENSSL_cleanse(a->d, sizeof(*a->d) * a->dmax);\n    a->neg = 0;\n    a->top = 0;\n    a->flags &= ~BN_FLG_FIXED_TOP;\n}\n\nBN_ULONG BN_get_word(const BIGNUM *a)\n{\n    if (a->top > 1)\n        return BN_MASK2;\n    else if (a->top == 1)\n        return a->d[0];\n    /* a->top == 0 */\n    return 0;\n}\n\nint BN_set_word(BIGNUM *a, BN_ULONG w)\n{\n    bn_check_top(a);\n    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)\n        return 0;\n    a->neg = 0;\n    a->d[0] = w;\n    a->top = (w ? 1 : 0);\n    a->flags &= ~BN_FLG_FIXED_TOP;\n    bn_check_top(a);\n    return 1;\n}\n\nBIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)\n{\n    unsigned int i, m;\n    unsigned int n;\n    BN_ULONG l;\n    BIGNUM *bn = NULL;\n\n    if (ret == NULL)\n        ret = bn = BN_new();\n    if (ret == NULL)\n        return NULL;\n    bn_check_top(ret);\n    /* Skip leading zero's. */\n    for ( ; len > 0 && *s == 0; s++, len--)\n        continue;\n    n = len;\n    if (n == 0) {\n        ret->top = 0;\n        return ret;\n    }\n    i = ((n - 1) / BN_BYTES) + 1;\n    m = ((n - 1) % (BN_BYTES));\n    if (bn_wexpand(ret, (int)i) == NULL) {\n        BN_free(bn);\n        return NULL;\n    }\n    ret->top = i;\n    ret->neg = 0;\n    l = 0;\n    while (n--) {\n        l = (l << 8L) | *(s++);\n        if (m-- == 0) {\n            ret->d[--i] = l;\n            l = 0;\n            m = BN_BYTES - 1;\n        }\n    }\n    /*\n     * need to call this due to clear byte at top if avoiding having the top\n     * bit set (-ve number)\n     */\n    bn_correct_top(ret);\n    return ret;\n}\n\ntypedef enum {big, little} endianess_t;\n\n/* ignore negative */\nstatic\nint bn2binpad(const BIGNUM *a, unsigned char *to, int tolen, endianess_t endianess)\n{\n    int n;\n    size_t i, lasti, j, atop, mask;\n    BN_ULONG l;\n\n    /*\n     * In case |a| is fixed-top, BN_num_bytes can return bogus length,\n     * but it's assumed that fixed-top inputs ought to be \"nominated\"\n     * even for padded output, so it works out...\n     */\n    n = BN_num_bytes(a);\n    if (tolen == -1) {\n        tolen = n;\n    } else if (tolen < n) {     /* uncommon/unlike case */\n        BIGNUM temp = *a;\n\n        bn_correct_top(&temp);\n        n = BN_num_bytes(&temp);\n        if (tolen < n)\n            return -1;\n    }\n\n    /* Swipe through whole available data and don't give away padded zero. */\n    atop = a->dmax * BN_BYTES;\n    if (atop == 0) {\n        OPENSSL_cleanse(to, tolen);\n        return tolen;\n    }\n\n    lasti = atop - 1;\n    atop = a->top * BN_BYTES;\n    if (endianess == big)\n        to += tolen; /* start from the end of the buffer */\n    for (i = 0, j = 0; j < (size_t)tolen; j++) {\n        unsigned char val;\n        l = a->d[i / BN_BYTES];\n        mask = 0 - ((j - atop) >> (8 * sizeof(i) - 1));\n        val = (unsigned char)(l >> (8 * (i % BN_BYTES)) & mask);\n        if (endianess == big)\n            *--to = val;\n        else\n            *to++ = val;\n        i += (i - lasti) >> (8 * sizeof(i) - 1); /* stay on last limb */\n    }\n\n    return tolen;\n}\n\nint BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen)\n{\n    if (tolen < 0)\n        return -1;\n    return bn2binpad(a, to, tolen, big);\n}\n\nint BN_bn2bin(const BIGNUM *a, unsigned char *to)\n{\n    return bn2binpad(a, to, -1, big);\n}\n\nBIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret)\n{\n    unsigned int i, m;\n    unsigned int n;\n    BN_ULONG l;\n    BIGNUM *bn = NULL;\n\n    if (ret == NULL)\n        ret = bn = BN_new();\n    if (ret == NULL)\n        return NULL;\n    bn_check_top(ret);\n    s += len;\n    /* Skip trailing zeroes. */\n    for ( ; len > 0 && s[-1] == 0; s--, len--)\n        continue;\n    n = len;\n    if (n == 0) {\n        ret->top = 0;\n        return ret;\n    }\n    i = ((n - 1) / BN_BYTES) + 1;\n    m = ((n - 1) % (BN_BYTES));\n    if (bn_wexpand(ret, (int)i) == NULL) {\n        BN_free(bn);\n        return NULL;\n    }\n    ret->top = i;\n    ret->neg = 0;\n    l = 0;\n    while (n--) {\n        s--;\n        l = (l << 8L) | *s;\n        if (m-- == 0) {\n            ret->d[--i] = l;\n            l = 0;\n            m = BN_BYTES - 1;\n        }\n    }\n    /*\n     * need to call this due to clear byte at top if avoiding having the top\n     * bit set (-ve number)\n     */\n    bn_correct_top(ret);\n    return ret;\n}\n\nint BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen)\n{\n    if (tolen < 0)\n        return -1;\n    return bn2binpad(a, to, tolen, little);\n}\n\nint BN_ucmp(const BIGNUM *a, const BIGNUM *b)\n{\n    int i;\n    BN_ULONG t1, t2, *ap, *bp;\n\n    bn_check_top(a);\n    bn_check_top(b);\n\n    i = a->top - b->top;\n    if (i != 0)\n        return i;\n    ap = a->d;\n    bp = b->d;\n    for (i = a->top - 1; i >= 0; i--) {\n        t1 = ap[i];\n        t2 = bp[i];\n        if (t1 != t2)\n            return ((t1 > t2) ? 1 : -1);\n    }\n    return 0;\n}\n\nint BN_cmp(const BIGNUM *a, const BIGNUM *b)\n{\n    int i;\n    int gt, lt;\n    BN_ULONG t1, t2;\n\n    if ((a == NULL) || (b == NULL)) {\n        if (a != NULL)\n            return -1;\n        else if (b != NULL)\n            return 1;\n        else\n            return 0;\n    }\n\n    bn_check_top(a);\n    bn_check_top(b);\n\n    if (a->neg != b->neg) {\n        if (a->neg)\n            return -1;\n        else\n            return 1;\n    }\n    if (a->neg == 0) {\n        gt = 1;\n        lt = -1;\n    } else {\n        gt = -1;\n        lt = 1;\n    }\n\n    if (a->top > b->top)\n        return gt;\n    if (a->top < b->top)\n        return lt;\n    for (i = a->top - 1; i >= 0; i--) {\n        t1 = a->d[i];\n        t2 = b->d[i];\n        if (t1 > t2)\n            return gt;\n        if (t1 < t2)\n            return lt;\n    }\n    return 0;\n}\n\nint BN_set_bit(BIGNUM *a, int n)\n{\n    int i, j, k;\n\n    if (n < 0)\n        return 0;\n\n    i = n / BN_BITS2;\n    j = n % BN_BITS2;\n    if (a->top <= i) {\n        if (bn_wexpand(a, i + 1) == NULL)\n            return 0;\n        for (k = a->top; k < i + 1; k++)\n            a->d[k] = 0;\n        a->top = i + 1;\n        a->flags &= ~BN_FLG_FIXED_TOP;\n    }\n\n    a->d[i] |= (((BN_ULONG)1) << j);\n    bn_check_top(a);\n    return 1;\n}\n\nint BN_clear_bit(BIGNUM *a, int n)\n{\n    int i, j;\n\n    bn_check_top(a);\n    if (n < 0)\n        return 0;\n\n    i = n / BN_BITS2;\n    j = n % BN_BITS2;\n    if (a->top <= i)\n        return 0;\n\n    a->d[i] &= (~(((BN_ULONG)1) << j));\n    bn_correct_top(a);\n    return 1;\n}\n\nint BN_is_bit_set(const BIGNUM *a, int n)\n{\n    int i, j;\n\n    bn_check_top(a);\n    if (n < 0)\n        return 0;\n    i = n / BN_BITS2;\n    j = n % BN_BITS2;\n    if (a->top <= i)\n        return 0;\n    return (int)(((a->d[i]) >> j) & ((BN_ULONG)1));\n}\n\nint BN_mask_bits(BIGNUM *a, int n)\n{\n    int b, w;\n\n    bn_check_top(a);\n    if (n < 0)\n        return 0;\n\n    w = n / BN_BITS2;\n    b = n % BN_BITS2;\n    if (w >= a->top)\n        return 0;\n    if (b == 0)\n        a->top = w;\n    else {\n        a->top = w + 1;\n        a->d[w] &= ~(BN_MASK2 << b);\n    }\n    bn_correct_top(a);\n    return 1;\n}\n\nvoid BN_set_negative(BIGNUM *a, int b)\n{\n    if (b && !BN_is_zero(a))\n        a->neg = 1;\n    else\n        a->neg = 0;\n}\n\nint bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n)\n{\n    int i;\n    BN_ULONG aa, bb;\n\n    if (n == 0)\n        return 0;\n\n    aa = a[n - 1];\n    bb = b[n - 1];\n    if (aa != bb)\n        return ((aa > bb) ? 1 : -1);\n    for (i = n - 2; i >= 0; i--) {\n        aa = a[i];\n        bb = b[i];\n        if (aa != bb)\n            return ((aa > bb) ? 1 : -1);\n    }\n    return 0;\n}\n\n/*\n * Here follows a specialised variants of bn_cmp_words().  It has the\n * capability of performing the operation on arrays of different sizes. The\n * sizes of those arrays is expressed through cl, which is the common length\n * ( basically, min(len(a),len(b)) ), and dl, which is the delta between the\n * two lengths, calculated as len(a)-len(b). All lengths are the number of\n * BN_ULONGs...\n */\n\nint bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl)\n{\n    int n, i;\n    n = cl - 1;\n\n    if (dl < 0) {\n        for (i = dl; i < 0; i++) {\n            if (b[n - i] != 0)\n                return -1;      /* a < b */\n        }\n    }\n    if (dl > 0) {\n        for (i = dl; i > 0; i--) {\n            if (a[n + i] != 0)\n                return 1;       /* a > b */\n        }\n    }\n    return bn_cmp_words(a, b, cl);\n}\n\n/*-\n * Constant-time conditional swap of a and b.\n * a and b are swapped if condition is not 0.\n * nwords is the number of words to swap.\n * Assumes that at least nwords are allocated in both a and b.\n * Assumes that no more than nwords are used by either a or b.\n */\nvoid BN_consttime_swap(BN_ULONG condition, BIGNUM *a, BIGNUM *b, int nwords)\n{\n    BN_ULONG t;\n    int i;\n\n    if (a == b)\n        return;\n\n    bn_wcheck_size(a, nwords);\n    bn_wcheck_size(b, nwords);\n\n    condition = ((~condition & ((condition - 1))) >> (BN_BITS2 - 1)) - 1;\n\n    t = (a->top ^ b->top) & condition;\n    a->top ^= t;\n    b->top ^= t;\n\n    t = (a->neg ^ b->neg) & condition;\n    a->neg ^= t;\n    b->neg ^= t;\n\n    /*-\n     * BN_FLG_STATIC_DATA: indicates that data may not be written to. Intention\n     * is actually to treat it as it's read-only data, and some (if not most)\n     * of it does reside in read-only segment. In other words observation of\n     * BN_FLG_STATIC_DATA in BN_consttime_swap should be treated as fatal\n     * condition. It would either cause SEGV or effectively cause data\n     * corruption.\n     *\n     * BN_FLG_MALLOCED: refers to BN structure itself, and hence must be\n     * preserved.\n     *\n     * BN_FLG_SECURE: must be preserved, because it determines how x->d was\n     * allocated and hence how to free it.\n     *\n     * BN_FLG_CONSTTIME: sufficient to mask and swap\n     *\n     * BN_FLG_FIXED_TOP: indicates that we haven't called bn_correct_top() on\n     * the data, so the d array may be padded with additional 0 values (i.e.\n     * top could be greater than the minimal value that it could be). We should\n     * be swapping it\n     */\n\n#define BN_CONSTTIME_SWAP_FLAGS (BN_FLG_CONSTTIME | BN_FLG_FIXED_TOP)\n\n    t = ((a->flags ^ b->flags) & BN_CONSTTIME_SWAP_FLAGS) & condition;\n    a->flags ^= t;\n    b->flags ^= t;\n\n    /* conditionally swap the data */\n    for (i = 0; i < nwords; i++) {\n        t = (a->d[i] ^ b->d[i]) & condition;\n        a->d[i] ^= t;\n        b->d[i] ^= t;\n    }\n}\n\n#undef BN_CONSTTIME_SWAP_FLAGS\n\n/* Bits of security, see SP800-57 */\n\nint BN_security_bits(int L, int N)\n{\n    int secbits, bits;\n    if (L >= 15360)\n        secbits = 256;\n    else if (L >= 7680)\n        secbits = 192;\n    else if (L >= 3072)\n        secbits = 128;\n    else if (L >= 2048)\n        secbits = 112;\n    else if (L >= 1024)\n        secbits = 80;\n    else\n        return 0;\n    if (N == -1)\n        return secbits;\n    bits = N / 2;\n    if (bits < 80)\n        return 0;\n    return bits >= secbits ? secbits : bits;\n}\n\nvoid BN_zero_ex(BIGNUM *a)\n{\n    a->neg = 0;\n    a->top = 0;\n    a->flags &= ~BN_FLG_FIXED_TOP;\n}\n\nint BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)\n{\n    return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));\n}\n\nint BN_is_zero(const BIGNUM *a)\n{\n    return a->top == 0;\n}\n\nint BN_is_one(const BIGNUM *a)\n{\n    return BN_abs_is_word(a, 1) && !a->neg;\n}\n\nint BN_is_word(const BIGNUM *a, const BN_ULONG w)\n{\n    return BN_abs_is_word(a, w) && (!w || !a->neg);\n}\n\nint BN_is_odd(const BIGNUM *a)\n{\n    return (a->top > 0) && (a->d[0] & 1);\n}\n\nint BN_is_negative(const BIGNUM *a)\n{\n    return (a->neg != 0);\n}\n\nint BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,\n                     BN_CTX *ctx)\n{\n    return BN_mod_mul_montgomery(r, a, &(mont->RR), mont, ctx);\n}\n\nvoid BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags)\n{\n    dest->d = b->d;\n    dest->top = b->top;\n    dest->dmax = b->dmax;\n    dest->neg = b->neg;\n    dest->flags = ((dest->flags & BN_FLG_MALLOCED)\n                   | (b->flags & ~BN_FLG_MALLOCED)\n                   | BN_FLG_STATIC_DATA | flags);\n}\n\nBN_GENCB *BN_GENCB_new(void)\n{\n    BN_GENCB *ret;\n\n    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_GENCB_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n\n    return ret;\n}\n\nvoid BN_GENCB_free(BN_GENCB *cb)\n{\n    if (cb == NULL)\n        return;\n    OPENSSL_free(cb);\n}\n\nvoid BN_set_flags(BIGNUM *b, int n)\n{\n    b->flags |= n;\n}\n\nint BN_get_flags(const BIGNUM *b, int n)\n{\n    return b->flags & n;\n}\n\n/* Populate a BN_GENCB structure with an \"old\"-style callback */\nvoid BN_GENCB_set_old(BN_GENCB *gencb, void (*callback) (int, int, void *),\n                      void *cb_arg)\n{\n    BN_GENCB *tmp_gencb = gencb;\n    tmp_gencb->ver = 1;\n    tmp_gencb->arg = cb_arg;\n    tmp_gencb->cb.cb_1 = callback;\n}\n\n/* Populate a BN_GENCB structure with a \"new\"-style callback */\nvoid BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *),\n                  void *cb_arg)\n{\n    BN_GENCB *tmp_gencb = gencb;\n    tmp_gencb->ver = 2;\n    tmp_gencb->arg = cb_arg;\n    tmp_gencb->cb.cb_2 = callback;\n}\n\nvoid *BN_GENCB_get_arg(BN_GENCB *cb)\n{\n    return cb->arg;\n}\n\nBIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}\n\nvoid bn_correct_top(BIGNUM *a)\n{\n    BN_ULONG *ftl;\n    int tmp_top = a->top;\n\n    if (tmp_top > 0) {\n        for (ftl = &(a->d[tmp_top]); tmp_top > 0; tmp_top--) {\n            ftl--;\n            if (*ftl != 0)\n                break;\n        }\n        a->top = tmp_top;\n    }\n    if (a->top == 0)\n        a->neg = 0;\n    a->flags &= ~BN_FLG_FIXED_TOP;\n    bn_pollute(a);\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_local.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_BN_LOCAL_H\n# define OSSL_CRYPTO_BN_LOCAL_H\n\n/*\n * The EDK2 build doesn't use bn_conf.h; it sets THIRTY_TWO_BIT or\n * SIXTY_FOUR_BIT in its own environment since it doesn't re-run our\n * Configure script and needs to support both 32-bit and 64-bit.\n */\n# include <openssl/opensslconf.h>\n\n# if !defined(OPENSSL_SYS_UEFI)\n#  include \"crypto/bn_conf.h\"\n# endif\n\n# include \"crypto/bn.h\"\n\n/*\n * These preprocessor symbols control various aspects of the bignum headers\n * and library code. They're not defined by any \"normal\" configuration, as\n * they are intended for development and testing purposes. NB: defining all\n * three can be useful for debugging application code as well as openssl\n * itself. BN_DEBUG - turn on various debugging alterations to the bignum\n * code BN_DEBUG_RAND - uses random poisoning of unused words to trip up\n * mismanagement of bignum internals. You must also define BN_DEBUG.\n */\n/* #define BN_DEBUG */\n/* #define BN_DEBUG_RAND */\n\n# ifndef OPENSSL_SMALL_FOOTPRINT\n#  define BN_MUL_COMBA\n#  define BN_SQR_COMBA\n#  define BN_RECURSION\n# endif\n\n/*\n * This next option uses the C libraries (2 word)/(1 word) function. If it is\n * not defined, I use my C version (which is slower). The reason for this\n * flag is that when the particular C compiler library routine is used, and\n * the library is linked with a different compiler, the library is missing.\n * This mostly happens when the library is built with gcc and then linked\n * using normal cc.  This would be a common occurrence because gcc normally\n * produces code that is 2 times faster than system compilers for the big\n * number stuff. For machines with only one compiler (or shared libraries),\n * this should be on.  Again this in only really a problem on machines using\n * \"long long's\", are 32bit, and are not using my assembler code.\n */\n# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \\\n    defined(OPENSSL_SYS_WIN32) || defined(linux)\n#  define BN_DIV2W\n# endif\n\n/*\n * 64-bit processor with LP64 ABI\n */\n# ifdef SIXTY_FOUR_BIT_LONG\n#  define BN_ULLONG       unsigned long long\n#  define BN_BITS4        32\n#  define BN_MASK2        (0xffffffffffffffffL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000L)\n#  define BN_MASK2h1      (0xffffffff80000000L)\n#  define BN_DEC_CONV     (10000000000000000000UL)\n#  define BN_DEC_NUM      19\n#  define BN_DEC_FMT1     \"%lu\"\n#  define BN_DEC_FMT2     \"%019lu\"\n# endif\n\n/*\n * 64-bit processor other than LP64 ABI\n */\n# ifdef SIXTY_FOUR_BIT\n#  undef BN_LLONG\n#  undef BN_ULLONG\n#  define BN_BITS4        32\n#  define BN_MASK2        (0xffffffffffffffffLL)\n#  define BN_MASK2l       (0xffffffffL)\n#  define BN_MASK2h       (0xffffffff00000000LL)\n#  define BN_MASK2h1      (0xffffffff80000000LL)\n#  define BN_DEC_CONV     (10000000000000000000ULL)\n#  define BN_DEC_NUM      19\n#  define BN_DEC_FMT1     \"%llu\"\n#  define BN_DEC_FMT2     \"%019llu\"\n# endif\n\n# ifdef THIRTY_TWO_BIT\n#  ifdef BN_LLONG\n#   if defined(_WIN32) && !defined(__GNUC__)\n#    define BN_ULLONG     unsigned __int64\n#   else\n#    define BN_ULLONG     unsigned long long\n#   endif\n#  endif\n#  define BN_BITS4        16\n#  define BN_MASK2        (0xffffffffL)\n#  define BN_MASK2l       (0xffff)\n#  define BN_MASK2h1      (0xffff8000L)\n#  define BN_MASK2h       (0xffff0000L)\n#  define BN_DEC_CONV     (1000000000L)\n#  define BN_DEC_NUM      9\n#  define BN_DEC_FMT1     \"%u\"\n#  define BN_DEC_FMT2     \"%09u\"\n# endif\n\n\n/*-\n * Bignum consistency macros\n * There is one \"API\" macro, bn_fix_top(), for stripping leading zeroes from\n * bignum data after direct manipulations on the data. There is also an\n * \"internal\" macro, bn_check_top(), for verifying that there are no leading\n * zeroes. Unfortunately, some auditing is required due to the fact that\n * bn_fix_top() has become an overabused duct-tape because bignum data is\n * occasionally passed around in an inconsistent state. So the following\n * changes have been made to sort this out;\n * - bn_fix_top()s implementation has been moved to bn_correct_top()\n * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and\n *   bn_check_top() is as before.\n * - if BN_DEBUG *is* defined;\n *   - bn_check_top() tries to pollute unused words even if the bignum 'top' is\n *     consistent. (ed: only if BN_DEBUG_RAND is defined)\n *   - bn_fix_top() maps to bn_check_top() rather than \"fixing\" anything.\n * The idea is to have debug builds flag up inconsistent bignums when they\n * occur. If that occurs in a bn_fix_top(), we examine the code in question; if\n * the use of bn_fix_top() was appropriate (ie. it follows directly after code\n * that manipulates the bignum) it is converted to bn_correct_top(), and if it\n * was not appropriate, we convert it permanently to bn_check_top() and track\n * down the cause of the bug. Eventually, no internal code should be using the\n * bn_fix_top() macro. External applications and libraries should try this with\n * their own code too, both in terms of building against the openssl headers\n * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it\n * defined. This not only improves external code, it provides more test\n * coverage for openssl's own code.\n */\n\n# ifdef BN_DEBUG\n/*\n * The new BN_FLG_FIXED_TOP flag marks vectors that were not treated with\n * bn_correct_top, in other words such vectors are permitted to have zeros\n * in most significant limbs. Such vectors are used internally to achieve\n * execution time invariance for critical operations with private keys.\n * It's BN_DEBUG-only flag, because user application is not supposed to\n * observe it anyway. Moreover, optimizing compiler would actually remove\n * all operations manipulating the bit in question in non-BN_DEBUG build.\n */\n#  define BN_FLG_FIXED_TOP 0x10000\n#  ifdef BN_DEBUG_RAND\n#   define bn_pollute(a) \\\n        do { \\\n            const BIGNUM *_bnum1 = (a); \\\n            if (_bnum1->top < _bnum1->dmax) { \\\n                unsigned char _tmp_char; \\\n                /* We cast away const without the compiler knowing, any \\\n                 * *genuinely* constant variables that aren't mutable \\\n                 * wouldn't be constructed with top!=dmax. */ \\\n                BN_ULONG *_not_const; \\\n                memcpy(&_not_const, &_bnum1->d, sizeof(_not_const)); \\\n                RAND_bytes(&_tmp_char, 1); /* Debug only - safe to ignore error return */\\\n                memset(_not_const + _bnum1->top, _tmp_char, \\\n                       sizeof(*_not_const) * (_bnum1->dmax - _bnum1->top)); \\\n            } \\\n        } while(0)\n#  else\n#   define bn_pollute(a)\n#  endif\n#  define bn_check_top(a) \\\n        do { \\\n                const BIGNUM *_bnum2 = (a); \\\n                if (_bnum2 != NULL) { \\\n                        int _top = _bnum2->top; \\\n                        (void)ossl_assert((_top == 0 && !_bnum2->neg) || \\\n                                  (_top && ((_bnum2->flags & BN_FLG_FIXED_TOP) \\\n                                            || _bnum2->d[_top - 1] != 0))); \\\n                        bn_pollute(_bnum2); \\\n                } \\\n        } while(0)\n\n#  define bn_fix_top(a)           bn_check_top(a)\n\n#  define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)\n#  define bn_wcheck_size(bn, words) \\\n        do { \\\n                const BIGNUM *_bnum2 = (bn); \\\n                assert((words) <= (_bnum2)->dmax && \\\n                       (words) >= (_bnum2)->top); \\\n                /* avoid unused variable warning with NDEBUG */ \\\n                (void)(_bnum2); \\\n        } while(0)\n\n# else                          /* !BN_DEBUG */\n\n#  define BN_FLG_FIXED_TOP 0\n#  define bn_pollute(a)\n#  define bn_check_top(a)\n#  define bn_fix_top(a)           bn_correct_top(a)\n#  define bn_check_size(bn, bits)\n#  define bn_wcheck_size(bn, words)\n\n# endif\n\nBN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,\n                          BN_ULONG w);\nBN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);\nvoid bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);\nBN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);\nBN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\nBN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                      int num);\n\nstruct bignum_st {\n    BN_ULONG *d;                /* Pointer to an array of 'BN_BITS2' bit\n                                 * chunks. */\n    int top;                    /* Index of last used d +1. */\n    /* The next are internal book keeping for bn_expand. */\n    int dmax;                   /* Size of the d array. */\n    int neg;                    /* one if the number is negative */\n    int flags;\n};\n\n/* Used for montgomery multiplication */\nstruct bn_mont_ctx_st {\n    int ri;                     /* number of bits in R */\n    BIGNUM RR;                  /* used to convert to montgomery form,\n                                   possibly zero-padded */\n    BIGNUM N;                   /* The modulus */\n    BIGNUM Ni;                  /* R*(1/R mod N) - N*Ni = 1 (Ni is only\n                                 * stored for bignum algorithm) */\n    BN_ULONG n0[2];             /* least significant word(s) of Ni; (type\n                                 * changed with 0.9.9, was \"BN_ULONG n0;\"\n                                 * before) */\n    int flags;\n};\n\n/*\n * Used for reciprocal division/mod functions It cannot be shared between\n * threads\n */\nstruct bn_recp_ctx_st {\n    BIGNUM N;                   /* the divisor */\n    BIGNUM Nr;                  /* the reciprocal */\n    int num_bits;\n    int shift;\n    int flags;\n};\n\n/* Used for slow \"generation\" functions. */\nstruct bn_gencb_st {\n    unsigned int ver;           /* To handle binary (in)compatibility */\n    void *arg;                  /* callback-specific data */\n    union {\n        /* if (ver==1) - handles old style callbacks */\n        void (*cb_1) (int, int, void *);\n        /* if (ver==2) - new callback style */\n        int (*cb_2) (int, int, BN_GENCB *);\n    } cb;\n};\n\n/*-\n * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions\n *\n *\n * For window size 'w' (w >= 2) and a random 'b' bits exponent,\n * the number of multiplications is a constant plus on average\n *\n *    2^(w-1) + (b-w)/(w+1);\n *\n * here  2^(w-1)  is for precomputing the table (we actually need\n * entries only for windows that have the lowest bit set), and\n * (b-w)/(w+1)  is an approximation for the expected number of\n * w-bit windows, not counting the first one.\n *\n * Thus we should use\n *\n *    w >= 6  if        b > 671\n *     w = 5  if  671 > b > 239\n *     w = 4  if  239 > b >  79\n *     w = 3  if   79 > b >  23\n *    w <= 2  if   23 > b\n *\n * (with draws in between).  Very small exponents are often selected\n * with low Hamming weight, so we use  w = 1  for b <= 23.\n */\n# define BN_window_bits_for_exponent_size(b) \\\n                ((b) > 671 ? 6 : \\\n                 (b) > 239 ? 5 : \\\n                 (b) >  79 ? 4 : \\\n                 (b) >  23 ? 3 : 1)\n\n/*\n * BN_mod_exp_mont_consttime is based on the assumption that the L1 data cache\n * line width of the target processor is at least the following value.\n */\n# define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH      ( 64 )\n# define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK       (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1)\n\n/*\n * Window sizes optimized for fixed window size modular exponentiation\n * algorithm (BN_mod_exp_mont_consttime). To achieve the security goals of\n * BN_mode_exp_mont_consttime, the maximum size of the window must not exceed\n * log_2(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH). Window size thresholds are\n * defined for cache line sizes of 32 and 64, cache line sizes where\n * log_2(32)=5 and log_2(64)=6 respectively. A window size of 7 should only be\n * used on processors that have a 128 byte or greater cache line size.\n */\n# if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64\n\n#  define BN_window_bits_for_ctime_exponent_size(b) \\\n                ((b) > 937 ? 6 : \\\n                 (b) > 306 ? 5 : \\\n                 (b) >  89 ? 4 : \\\n                 (b) >  22 ? 3 : 1)\n#  define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE    (6)\n\n# elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32\n\n#  define BN_window_bits_for_ctime_exponent_size(b) \\\n                ((b) > 306 ? 5 : \\\n                 (b) >  89 ? 4 : \\\n                 (b) >  22 ? 3 : 1)\n#  define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE    (5)\n\n# endif\n\n/* Pentium pro 16,16,16,32,64 */\n/* Alpha       16,16,16,16.64 */\n# define BN_MULL_SIZE_NORMAL                     (16)/* 32 */\n# define BN_MUL_RECURSIVE_SIZE_NORMAL            (16)/* 32 less than */\n# define BN_SQR_RECURSIVE_SIZE_NORMAL            (16)/* 32 */\n# define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL        (32)/* 32 */\n# define BN_MONT_CTX_SET_SIZE_WORD               (64)/* 32 */\n\n/*\n * 2011-02-22 SMS. In various places, a size_t variable or a type cast to\n * size_t was used to perform integer-only operations on pointers.  This\n * failed on VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t\n * is still only 32 bits.  What's needed in these cases is an integer type\n * with the same size as a pointer, which size_t is not certain to be. The\n * only fix here is VMS-specific.\n */\n# if defined(OPENSSL_SYS_VMS)\n#  if __INITIAL_POINTER_SIZE == 64\n#   define PTR_SIZE_INT long long\n#  else                         /* __INITIAL_POINTER_SIZE == 64 */\n#   define PTR_SIZE_INT int\n#  endif                        /* __INITIAL_POINTER_SIZE == 64 [else] */\n# elif !defined(PTR_SIZE_INT)   /* defined(OPENSSL_SYS_VMS) */\n#  define PTR_SIZE_INT size_t\n# endif                         /* defined(OPENSSL_SYS_VMS) [else] */\n\n# if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)\n/*\n * BN_UMULT_HIGH section.\n * If the compiler doesn't support 2*N integer type, then you have to\n * replace every N*N multiplication with 4 (N/2)*(N/2) accompanied by some\n * shifts and additions which unavoidably results in severe performance\n * penalties. Of course provided that the hardware is capable of producing\n * 2*N result... That's when you normally start considering assembler\n * implementation. However! It should be pointed out that some CPUs (e.g.,\n * PowerPC, Alpha, and IA-64) provide *separate* instruction calculating\n * the upper half of the product placing the result into a general\n * purpose register. Now *if* the compiler supports inline assembler,\n * then it's not impossible to implement the \"bignum\" routines (and have\n * the compiler optimize 'em) exhibiting \"native\" performance in C. That's\n * what BN_UMULT_HIGH macro is about:-) Note that more recent compilers do\n * support 2*64 integer type, which is also used here.\n */\n#  if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 && \\\n      (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))\n#   define BN_UMULT_HIGH(a,b)          (((__uint128_t)(a)*(b))>>64)\n#   define BN_UMULT_LOHI(low,high,a,b) ({       \\\n        __uint128_t ret=(__uint128_t)(a)*(b);   \\\n        (high)=ret>>64; (low)=ret;      })\n#  elif defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))\n#   if defined(__DECC)\n#    include <c_asm.h>\n#    define BN_UMULT_HIGH(a,b)   (BN_ULONG)asm(\"umulh %a0,%a1,%v0\",(a),(b))\n#   elif defined(__GNUC__) && __GNUC__>=2\n#    define BN_UMULT_HIGH(a,b)   ({     \\\n        register BN_ULONG ret;          \\\n        asm (\"umulh     %1,%2,%0\"       \\\n             : \"=r\"(ret)                \\\n             : \"r\"(a), \"r\"(b));         \\\n        ret;                      })\n#   endif                       /* compiler */\n#  elif defined(_ARCH_PPC64) && defined(SIXTY_FOUR_BIT_LONG)\n#   if defined(__GNUC__) && __GNUC__>=2\n#    define BN_UMULT_HIGH(a,b)   ({     \\\n        register BN_ULONG ret;          \\\n        asm (\"mulhdu    %0,%1,%2\"       \\\n             : \"=r\"(ret)                \\\n             : \"r\"(a), \"r\"(b));         \\\n        ret;                      })\n#   endif                       /* compiler */\n#  elif (defined(__x86_64) || defined(__x86_64__)) && \\\n       (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))\n#   if defined(__GNUC__) && __GNUC__>=2\n#    define BN_UMULT_HIGH(a,b)   ({     \\\n        register BN_ULONG ret,discard;  \\\n        asm (\"mulq      %3\"             \\\n             : \"=a\"(discard),\"=d\"(ret)  \\\n             : \"a\"(a), \"g\"(b)           \\\n             : \"cc\");                   \\\n        ret;                      })\n#    define BN_UMULT_LOHI(low,high,a,b) \\\n        asm (\"mulq      %3\"             \\\n                : \"=a\"(low),\"=d\"(high)  \\\n                : \"a\"(a),\"g\"(b)         \\\n                : \"cc\");\n#   endif\n#  elif (defined(_M_AMD64) || defined(_M_X64)) && defined(SIXTY_FOUR_BIT)\n#   if defined(_MSC_VER) && _MSC_VER>=1400\nunsigned __int64 __umulh(unsigned __int64 a, unsigned __int64 b);\nunsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,\n                          unsigned __int64 *h);\n#    pragma intrinsic(__umulh,_umul128)\n#    define BN_UMULT_HIGH(a,b)           __umulh((a),(b))\n#    define BN_UMULT_LOHI(low,high,a,b)  ((low)=_umul128((a),(b),&(high)))\n#   endif\n#  elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))\n#   if defined(__GNUC__) && __GNUC__>=2\n#    define BN_UMULT_HIGH(a,b) ({       \\\n        register BN_ULONG ret;          \\\n        asm (\"dmultu    %1,%2\"          \\\n             : \"=h\"(ret)                \\\n             : \"r\"(a), \"r\"(b) : \"l\");   \\\n        ret;                    })\n#    define BN_UMULT_LOHI(low,high,a,b) \\\n        asm (\"dmultu    %2,%3\"          \\\n             : \"=l\"(low),\"=h\"(high)     \\\n             : \"r\"(a), \"r\"(b));\n#   endif\n#  elif defined(__aarch64__) && defined(SIXTY_FOUR_BIT_LONG)\n#   if defined(__GNUC__) && __GNUC__>=2\n#    define BN_UMULT_HIGH(a,b)   ({     \\\n        register BN_ULONG ret;          \\\n        asm (\"umulh     %0,%1,%2\"       \\\n             : \"=r\"(ret)                \\\n             : \"r\"(a), \"r\"(b));         \\\n        ret;                      })\n#   endif\n#  endif                        /* cpu */\n# endif                         /* OPENSSL_NO_ASM */\n\n# ifdef BN_DEBUG_RAND\n#  define bn_clear_top2max(a) \\\n        { \\\n        int      ind = (a)->dmax - (a)->top; \\\n        BN_ULONG *ftl = &(a)->d[(a)->top-1]; \\\n        for (; ind != 0; ind--) \\\n                *(++ftl) = 0x0; \\\n        }\n# else\n#  define bn_clear_top2max(a)\n# endif\n\n# ifdef BN_LLONG\n/*******************************************************************\n * Using the long long type, has to be twice as wide as BN_ULONG...\n */\n#  define Lw(t)    (((BN_ULONG)(t))&BN_MASK2)\n#  define Hw(t)    (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)\n\n#  define mul_add(r,a,w,c) { \\\n        BN_ULLONG t; \\\n        t=(BN_ULLONG)w * (a) + (r) + (c); \\\n        (r)= Lw(t); \\\n        (c)= Hw(t); \\\n        }\n\n#  define mul(r,a,w,c) { \\\n        BN_ULLONG t; \\\n        t=(BN_ULLONG)w * (a) + (c); \\\n        (r)= Lw(t); \\\n        (c)= Hw(t); \\\n        }\n\n#  define sqr(r0,r1,a) { \\\n        BN_ULLONG t; \\\n        t=(BN_ULLONG)(a)*(a); \\\n        (r0)=Lw(t); \\\n        (r1)=Hw(t); \\\n        }\n\n# elif defined(BN_UMULT_LOHI)\n#  define mul_add(r,a,w,c) {              \\\n        BN_ULONG high,low,ret,tmp=(a);  \\\n        ret =  (r);                     \\\n        BN_UMULT_LOHI(low,high,w,tmp);  \\\n        ret += (c);                     \\\n        (c) =  (ret<(c))?1:0;           \\\n        (c) += high;                    \\\n        ret += low;                     \\\n        (c) += (ret<low)?1:0;           \\\n        (r) =  ret;                     \\\n        }\n\n#  define mul(r,a,w,c)    {               \\\n        BN_ULONG high,low,ret,ta=(a);   \\\n        BN_UMULT_LOHI(low,high,w,ta);   \\\n        ret =  low + (c);               \\\n        (c) =  high;                    \\\n        (c) += (ret<low)?1:0;           \\\n        (r) =  ret;                     \\\n        }\n\n#  define sqr(r0,r1,a)    {               \\\n        BN_ULONG tmp=(a);               \\\n        BN_UMULT_LOHI(r0,r1,tmp,tmp);   \\\n        }\n\n# elif defined(BN_UMULT_HIGH)\n#  define mul_add(r,a,w,c) {              \\\n        BN_ULONG high,low,ret,tmp=(a);  \\\n        ret =  (r);                     \\\n        high=  BN_UMULT_HIGH(w,tmp);    \\\n        ret += (c);                     \\\n        low =  (w) * tmp;               \\\n        (c) =  (ret<(c))?1:0;           \\\n        (c) += high;                    \\\n        ret += low;                     \\\n        (c) += (ret<low)?1:0;           \\\n        (r) =  ret;                     \\\n        }\n\n#  define mul(r,a,w,c)    {               \\\n        BN_ULONG high,low,ret,ta=(a);   \\\n        low =  (w) * ta;                \\\n        high=  BN_UMULT_HIGH(w,ta);     \\\n        ret =  low + (c);               \\\n        (c) =  high;                    \\\n        (c) += (ret<low)?1:0;           \\\n        (r) =  ret;                     \\\n        }\n\n#  define sqr(r0,r1,a)    {               \\\n        BN_ULONG tmp=(a);               \\\n        (r0) = tmp * tmp;               \\\n        (r1) = BN_UMULT_HIGH(tmp,tmp);  \\\n        }\n\n# else\n/*************************************************************\n * No long long type\n */\n\n#  define LBITS(a)        ((a)&BN_MASK2l)\n#  define HBITS(a)        (((a)>>BN_BITS4)&BN_MASK2l)\n#  define L2HBITS(a)      (((a)<<BN_BITS4)&BN_MASK2)\n\n#  define LLBITS(a)       ((a)&BN_MASKl)\n#  define LHBITS(a)       (((a)>>BN_BITS2)&BN_MASKl)\n#  define LL2HBITS(a)     ((BN_ULLONG)((a)&BN_MASKl)<<BN_BITS2)\n\n#  define mul64(l,h,bl,bh) \\\n        { \\\n        BN_ULONG m,m1,lt,ht; \\\n \\\n        lt=l; \\\n        ht=h; \\\n        m =(bh)*(lt); \\\n        lt=(bl)*(lt); \\\n        m1=(bl)*(ht); \\\n        ht =(bh)*(ht); \\\n        m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \\\n        ht+=HBITS(m); \\\n        m1=L2HBITS(m); \\\n        lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \\\n        (l)=lt; \\\n        (h)=ht; \\\n        }\n\n#  define sqr64(lo,ho,in) \\\n        { \\\n        BN_ULONG l,h,m; \\\n \\\n        h=(in); \\\n        l=LBITS(h); \\\n        h=HBITS(h); \\\n        m =(l)*(h); \\\n        l*=l; \\\n        h*=h; \\\n        h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \\\n        m =(m&BN_MASK2l)<<(BN_BITS4+1); \\\n        l=(l+m)&BN_MASK2; if (l < m) h++; \\\n        (lo)=l; \\\n        (ho)=h; \\\n        }\n\n#  define mul_add(r,a,bl,bh,c) { \\\n        BN_ULONG l,h; \\\n \\\n        h= (a); \\\n        l=LBITS(h); \\\n        h=HBITS(h); \\\n        mul64(l,h,(bl),(bh)); \\\n \\\n        /* non-multiply part */ \\\n        l=(l+(c))&BN_MASK2; if (l < (c)) h++; \\\n        (c)=(r); \\\n        l=(l+(c))&BN_MASK2; if (l < (c)) h++; \\\n        (c)=h&BN_MASK2; \\\n        (r)=l; \\\n        }\n\n#  define mul(r,a,bl,bh,c) { \\\n        BN_ULONG l,h; \\\n \\\n        h= (a); \\\n        l=LBITS(h); \\\n        h=HBITS(h); \\\n        mul64(l,h,(bl),(bh)); \\\n \\\n        /* non-multiply part */ \\\n        l+=(c); if ((l&BN_MASK2) < (c)) h++; \\\n        (c)=h&BN_MASK2; \\\n        (r)=l&BN_MASK2; \\\n        }\n# endif                         /* !BN_LLONG */\n\nvoid BN_RECP_CTX_init(BN_RECP_CTX *recp);\nvoid BN_MONT_CTX_init(BN_MONT_CTX *ctx);\n\nvoid bn_init(BIGNUM *a);\nvoid bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb);\nvoid bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);\nvoid bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);\nvoid bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp);\nvoid bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a);\nvoid bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a);\nint bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n);\nint bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl);\nvoid bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,\n                      int dna, int dnb, BN_ULONG *t);\nvoid bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,\n                           int n, int tna, int tnb, BN_ULONG *t);\nvoid bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t);\nvoid bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);\nvoid bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,\n                          BN_ULONG *t);\nBN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,\n                           int cl, int dl);\nint bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,\n                const BN_ULONG *np, const BN_ULONG *n0, int num);\n\nBIGNUM *int_bn_mod_inverse(BIGNUM *in,\n                           const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx,\n                           int *noinv);\n\nstatic ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)\n{\n    if (bits > (INT_MAX - BN_BITS2 + 1))\n        return NULL;\n\n    if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)\n        return a;\n\n    return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);\n}\n\n#endif\n"
  },
  {
    "path": "cryptomini/bn/bn_mod.c",
    "content": "/*\n * Copyright 1998-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\nint BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)\n{\n    /*\n     * like BN_mod, but returns non-negative remainder (i.e., 0 <= r < |d|\n     * always holds)\n     */\n\n    if (!(BN_mod(r, m, d, ctx)))\n        return 0;\n    if (!r->neg)\n        return 1;\n    /* now   -|d| < r < 0,  so we have to set  r := r + |d| */\n    return (d->neg ? BN_sub : BN_add) (r, r, d);\n}\n\nint BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    if (!BN_add(r, a, b))\n        return 0;\n    return BN_nnmod(r, r, m, ctx);\n}\n\n/*\n * BN_mod_add variant that may be used if both a and b are non-negative and\n * less than m. The original algorithm was\n *\n *    if (!BN_uadd(r, a, b))\n *       return 0;\n *    if (BN_ucmp(r, m) >= 0)\n *       return BN_usub(r, r, m);\n *\n * which is replaced with addition, subtracting modulus, and conditional\n * move depending on whether or not subtraction borrowed.\n */\nint bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                         const BIGNUM *m)\n{\n    size_t i, ai, bi, mtop = m->top;\n    BN_ULONG storage[1024 / BN_BITS2];\n    BN_ULONG carry, temp, mask, *rp, *tp = storage;\n    const BN_ULONG *ap, *bp;\n\n    if (bn_wexpand(r, mtop) == NULL)\n        return 0;\n\n    if (mtop > sizeof(storage) / sizeof(storage[0])\n        && (tp = OPENSSL_malloc(mtop * sizeof(BN_ULONG))) == NULL)\n        return 0;\n\n    ap = a->d != NULL ? a->d : tp;\n    bp = b->d != NULL ? b->d : tp;\n\n    for (i = 0, ai = 0, bi = 0, carry = 0; i < mtop;) {\n        mask = (BN_ULONG)0 - ((i - a->top) >> (8 * sizeof(i) - 1));\n        temp = ((ap[ai] & mask) + carry) & BN_MASK2;\n        carry = (temp < carry);\n\n        mask = (BN_ULONG)0 - ((i - b->top) >> (8 * sizeof(i) - 1));\n        tp[i] = ((bp[bi] & mask) + temp) & BN_MASK2;\n        carry += (tp[i] < temp);\n\n        i++;\n        ai += (i - a->dmax) >> (8 * sizeof(i) - 1);\n        bi += (i - b->dmax) >> (8 * sizeof(i) - 1);\n    }\n    rp = r->d;\n    carry -= bn_sub_words(rp, tp, m->d, mtop);\n    for (i = 0; i < mtop; i++) {\n        rp[i] = (carry & tp[i]) | (~carry & rp[i]);\n        ((volatile BN_ULONG *)tp)[i] = 0;\n    }\n    r->top = mtop;\n    r->flags |= BN_FLG_FIXED_TOP;\n    r->neg = 0;\n\n    if (tp != storage)\n        OPENSSL_free(tp);\n\n    return 1;\n}\n\nint BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m)\n{\n    int ret = bn_mod_add_fixed_top(r, a, b, m);\n\n    if (ret)\n        bn_correct_top(r);\n\n    return ret;\n}\n\nint BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    if (!BN_sub(r, a, b))\n        return 0;\n    return BN_nnmod(r, r, m, ctx);\n}\n\n/*\n * BN_mod_sub variant that may be used if both a and b are non-negative,\n * a is less than m, while b is of same bit width as m. It's implemented\n * as subtraction followed by two conditional additions.\n *\n * 0 <= a < m\n * 0 <= b < 2^w < 2*m\n *\n * after subtraction\n *\n * -2*m < r = a - b < m\n *\n * Thus it takes up to two conditional additions to make |r| positive.\n */\nint bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                         const BIGNUM *m)\n{\n    size_t i, ai, bi, mtop = m->top;\n    BN_ULONG borrow, carry, ta, tb, mask, *rp;\n    const BN_ULONG *ap, *bp;\n\n    if (bn_wexpand(r, mtop) == NULL)\n        return 0;\n\n    rp = r->d;\n    ap = a->d != NULL ? a->d : rp;\n    bp = b->d != NULL ? b->d : rp;\n\n    for (i = 0, ai = 0, bi = 0, borrow = 0; i < mtop;) {\n        mask = (BN_ULONG)0 - ((i - a->top) >> (8 * sizeof(i) - 1));\n        ta = ap[ai] & mask;\n\n        mask = (BN_ULONG)0 - ((i - b->top) >> (8 * sizeof(i) - 1));\n        tb = bp[bi] & mask;\n        rp[i] = ta - tb - borrow;\n        if (ta != tb)\n            borrow = (ta < tb);\n\n        i++;\n        ai += (i - a->dmax) >> (8 * sizeof(i) - 1);\n        bi += (i - b->dmax) >> (8 * sizeof(i) - 1);\n    }\n    ap = m->d;\n    for (i = 0, mask = 0 - borrow, carry = 0; i < mtop; i++) {\n        ta = ((ap[i] & mask) + carry) & BN_MASK2;\n        carry = (ta < carry);\n        rp[i] = (rp[i] + ta) & BN_MASK2;\n        carry += (rp[i] < ta);\n    }\n    borrow -= carry;\n    for (i = 0, mask = 0 - borrow, carry = 0; i < mtop; i++) {\n        ta = ((ap[i] & mask) + carry) & BN_MASK2;\n        carry = (ta < carry);\n        rp[i] = (rp[i] + ta) & BN_MASK2;\n        carry += (rp[i] < ta);\n    }\n\n    r->top = mtop;\n    r->flags |= BN_FLG_FIXED_TOP;\n    r->neg = 0;\n\n    return 1;\n}\n\n/*\n * BN_mod_sub variant that may be used if both a and b are non-negative and\n * less than m\n */\nint BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m)\n{\n    if (!BN_sub(r, a, b))\n        return 0;\n    if (r->neg)\n        return BN_add(r, r, m);\n    return 1;\n}\n\n/* slow but works */\nint BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx)\n{\n    BIGNUM *t;\n    int ret = 0;\n\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(m);\n\n    BN_CTX_start(ctx);\n    if ((t = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (a == b) {\n        if (!BN_sqr(t, a, ctx))\n            goto err;\n    } else {\n        if (!BN_mul(t, a, b, ctx))\n            goto err;\n    }\n    if (!BN_nnmod(r, t, m, ctx))\n        goto err;\n    bn_check_top(r);\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    return ret;\n}\n\nint BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)\n{\n    if (!BN_sqr(r, a, ctx))\n        return 0;\n    /* r->neg == 0,  thus we don't need BN_nnmod */\n    return BN_mod(r, r, m, ctx);\n}\n\nint BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)\n{\n    if (!BN_lshift1(r, a))\n        return 0;\n    bn_check_top(r);\n    return BN_nnmod(r, r, m, ctx);\n}\n\n/*\n * BN_mod_lshift1 variant that may be used if a is non-negative and less than\n * m\n */\nint BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m)\n{\n    if (!BN_lshift1(r, a))\n        return 0;\n    bn_check_top(r);\n    if (BN_cmp(r, m) >= 0)\n        return BN_sub(r, r, m);\n    return 1;\n}\n\nint BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,\n                  BN_CTX *ctx)\n{\n    BIGNUM *abs_m = NULL;\n    int ret;\n\n    if (!BN_nnmod(r, a, m, ctx))\n        return 0;\n\n    if (m->neg) {\n        abs_m = BN_dup(m);\n        if (abs_m == NULL)\n            return 0;\n        abs_m->neg = 0;\n    }\n\n    ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m));\n    bn_check_top(r);\n\n    BN_free(abs_m);\n    return ret;\n}\n\n/*\n * BN_mod_lshift variant that may be used if a is non-negative and less than\n * m\n */\nint BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m)\n{\n    if (r != a) {\n        if (BN_copy(r, a) == NULL)\n            return 0;\n    }\n\n    while (n > 0) {\n        int max_shift;\n\n        /* 0 < r < m */\n        max_shift = BN_num_bits(m) - BN_num_bits(r);\n        /* max_shift >= 0 */\n\n        if (max_shift < 0) {\n            BNerr(BN_F_BN_MOD_LSHIFT_QUICK, BN_R_INPUT_NOT_REDUCED);\n            return 0;\n        }\n\n        if (max_shift > n)\n            max_shift = n;\n\n        if (max_shift) {\n            if (!BN_lshift(r, r, max_shift))\n                return 0;\n            n -= max_shift;\n        } else {\n            if (!BN_lshift1(r, r))\n                return 0;\n            --n;\n        }\n\n        /* BN_num_bits(r) <= BN_num_bits(m) */\n\n        if (BN_cmp(r, m) >= 0) {\n            if (!BN_sub(r, r, m))\n                return 0;\n        }\n    }\n    bn_check_top(r);\n\n    return 1;\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_mont.c",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * Details about Montgomery multiplication algorithms can be found at\n * http://security.ece.orst.edu/publications.html, e.g.\n * http://security.ece.orst.edu/koc/papers/j37acmon.pdf and\n * sections 3.8 and 4.2 in http://security.ece.orst.edu/koc/papers/r01rsasw.pdf\n */\n\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\n#define MONT_WORD               /* use the faster word-based algorithm */\n\n#ifdef MONT_WORD\nstatic int bn_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont);\n#endif\n\nint BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx)\n{\n    int ret = bn_mul_mont_fixed_top(r, a, b, mont, ctx);\n\n    bn_correct_top(r);\n    bn_check_top(r);\n\n    return ret;\n}\n\nint bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx)\n{\n    BIGNUM *tmp;\n    int ret = 0;\n    int num = mont->N.top;\n\n#if defined(OPENSSL_BN_ASM_MONT) && defined(MONT_WORD)\n    if (num > 1 && a->top == num && b->top == num) {\n        if (bn_wexpand(r, num) == NULL)\n            return 0;\n        if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)) {\n            r->neg = a->neg ^ b->neg;\n            r->top = num;\n            r->flags |= BN_FLG_FIXED_TOP;\n            return 1;\n        }\n    }\n#endif\n\n    if ((a->top + b->top) > 2 * num)\n        return 0;\n\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (tmp == NULL)\n        goto err;\n\n    bn_check_top(tmp);\n    if (a == b) {\n        if (!bn_sqr_fixed_top(tmp, a, ctx))\n            goto err;\n    } else {\n        if (!bn_mul_fixed_top(tmp, a, b, ctx))\n            goto err;\n    }\n    /* reduce from aRR to aR */\n#ifdef MONT_WORD\n    if (!bn_from_montgomery_word(r, tmp, mont))\n        goto err;\n#else\n    if (!BN_from_montgomery(r, tmp, mont, ctx))\n        goto err;\n#endif\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    return ret;\n}\n\n#ifdef MONT_WORD\nstatic int bn_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)\n{\n    BIGNUM *n;\n    BN_ULONG *ap, *np, *rp, n0, v, carry;\n    int nl, max, i;\n    unsigned int rtop;\n\n    n = &(mont->N);\n    nl = n->top;\n    if (nl == 0) {\n        ret->top = 0;\n        return 1;\n    }\n\n    max = (2 * nl);             /* carry is stored separately */\n    if (bn_wexpand(r, max) == NULL)\n        return 0;\n\n    r->neg ^= n->neg;\n    np = n->d;\n    rp = r->d;\n\n    /* clear the top words of T */\n    for (rtop = r->top, i = 0; i < max; i++) {\n        v = (BN_ULONG)0 - ((i - rtop) >> (8 * sizeof(rtop) - 1));\n        rp[i] &= v;\n    }\n\n    r->top = max;\n    r->flags |= BN_FLG_FIXED_TOP;\n    n0 = mont->n0[0];\n\n    /*\n     * Add multiples of |n| to |r| until R = 2^(nl * BN_BITS2) divides it. On\n     * input, we had |r| < |n| * R, so now |r| < 2 * |n| * R. Note that |r|\n     * includes |carry| which is stored separately.\n     */\n    for (carry = 0, i = 0; i < nl; i++, rp++) {\n        v = bn_mul_add_words(rp, np, nl, (rp[0] * n0) & BN_MASK2);\n        v = (v + carry + rp[nl]) & BN_MASK2;\n        carry |= (v != rp[nl]);\n        carry &= (v <= rp[nl]);\n        rp[nl] = v;\n    }\n\n    if (bn_wexpand(ret, nl) == NULL)\n        return 0;\n    ret->top = nl;\n    ret->flags |= BN_FLG_FIXED_TOP;\n    ret->neg = r->neg;\n\n    rp = ret->d;\n\n    /*\n     * Shift |nl| words to divide by R. We have |ap| < 2 * |n|. Note that |ap|\n     * includes |carry| which is stored separately.\n     */\n    ap = &(r->d[nl]);\n\n    carry -= bn_sub_words(rp, ap, np, nl);\n    /*\n     * |carry| is -1 if |ap| - |np| underflowed or zero if it did not. Note\n     * |carry| cannot be 1. That would imply the subtraction did not fit in\n     * |nl| words, and we know at most one subtraction is needed.\n     */\n    for (i = 0; i < nl; i++) {\n        rp[i] = (carry & ap[i]) | (~carry & rp[i]);\n        ap[i] = 0;\n    }\n\n    return 1;\n}\n#endif                          /* MONT_WORD */\n\nint BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,\n                       BN_CTX *ctx)\n{\n    int retn;\n\n    retn = bn_from_mont_fixed_top(ret, a, mont, ctx);\n    bn_correct_top(ret);\n    bn_check_top(ret);\n\n    return retn;\n}\n\nint bn_from_mont_fixed_top(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont,\n                           BN_CTX *ctx)\n{\n    int retn = 0;\n#ifdef MONT_WORD\n    BIGNUM *t;\n\n    BN_CTX_start(ctx);\n    if ((t = BN_CTX_get(ctx)) && BN_copy(t, a)) {\n        retn = bn_from_montgomery_word(ret, t, mont);\n    }\n    BN_CTX_end(ctx);\n#else                           /* !MONT_WORD */\n    BIGNUM *t1, *t2;\n\n    BN_CTX_start(ctx);\n    t1 = BN_CTX_get(ctx);\n    t2 = BN_CTX_get(ctx);\n    if (t2 == NULL)\n        goto err;\n\n    if (!BN_copy(t1, a))\n        goto err;\n    BN_mask_bits(t1, mont->ri);\n\n    if (!BN_mul(t2, t1, &mont->Ni, ctx))\n        goto err;\n    BN_mask_bits(t2, mont->ri);\n\n    if (!BN_mul(t1, t2, &mont->N, ctx))\n        goto err;\n    if (!BN_add(t2, a, t1))\n        goto err;\n    if (!BN_rshift(ret, t2, mont->ri))\n        goto err;\n\n    if (BN_ucmp(ret, &(mont->N)) >= 0) {\n        if (!BN_usub(ret, ret, &(mont->N)))\n            goto err;\n    }\n    retn = 1;\n    bn_check_top(ret);\n err:\n    BN_CTX_end(ctx);\n#endif                          /* MONT_WORD */\n    return retn;\n}\n\nint bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,\n                         BN_CTX *ctx)\n{\n    return bn_mul_mont_fixed_top(r, a, &(mont->RR), mont, ctx);\n}\n\nBN_MONT_CTX *BN_MONT_CTX_new(void)\n{\n    BN_MONT_CTX *ret;\n\n    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_MONT_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n\n    BN_MONT_CTX_init(ret);\n    ret->flags = BN_FLG_MALLOCED;\n    return ret;\n}\n\nvoid BN_MONT_CTX_init(BN_MONT_CTX *ctx)\n{\n    ctx->ri = 0;\n    bn_init(&ctx->RR);\n    bn_init(&ctx->N);\n    bn_init(&ctx->Ni);\n    ctx->n0[0] = ctx->n0[1] = 0;\n    ctx->flags = 0;\n}\n\nvoid BN_MONT_CTX_free(BN_MONT_CTX *mont)\n{\n    if (mont == NULL)\n        return;\n    BN_clear_free(&mont->RR);\n    BN_clear_free(&mont->N);\n    BN_clear_free(&mont->Ni);\n    if (mont->flags & BN_FLG_MALLOCED)\n        OPENSSL_free(mont);\n}\n\nint BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)\n{\n    int i, ret = 0;\n    BIGNUM *Ri, *R;\n\n    if (BN_is_zero(mod))\n        return 0;\n\n    BN_CTX_start(ctx);\n    if ((Ri = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    R = &(mont->RR);            /* grab RR as a temp */\n    if (!BN_copy(&(mont->N), mod))\n        goto err;               /* Set N */\n    if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0)\n        BN_set_flags(&(mont->N), BN_FLG_CONSTTIME);\n    mont->N.neg = 0;\n\n#ifdef MONT_WORD\n    {\n        BIGNUM tmod;\n        BN_ULONG buf[2];\n\n        bn_init(&tmod);\n        tmod.d = buf;\n        tmod.dmax = 2;\n        tmod.neg = 0;\n\n        if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0)\n            BN_set_flags(&tmod, BN_FLG_CONSTTIME);\n\n        mont->ri = (BN_num_bits(mod) + (BN_BITS2 - 1)) / BN_BITS2 * BN_BITS2;\n\n# if defined(OPENSSL_BN_ASM_MONT) && (BN_BITS2<=32)\n        /*\n         * Only certain BN_BITS2<=32 platforms actually make use of n0[1],\n         * and we could use the #else case (with a shorter R value) for the\n         * others.  However, currently only the assembler files do know which\n         * is which.\n         */\n\n        BN_zero(R);\n        if (!(BN_set_bit(R, 2 * BN_BITS2)))\n            goto err;\n\n        tmod.top = 0;\n        if ((buf[0] = mod->d[0]))\n            tmod.top = 1;\n        if ((buf[1] = mod->top > 1 ? mod->d[1] : 0))\n            tmod.top = 2;\n\n        if (BN_is_one(&tmod))\n            BN_zero(Ri);\n        else if ((BN_mod_inverse(Ri, R, &tmod, ctx)) == NULL)\n            goto err;\n        if (!BN_lshift(Ri, Ri, 2 * BN_BITS2))\n            goto err;           /* R*Ri */\n        if (!BN_is_zero(Ri)) {\n            if (!BN_sub_word(Ri, 1))\n                goto err;\n        } else {                /* if N mod word size == 1 */\n\n            if (bn_expand(Ri, (int)sizeof(BN_ULONG) * 2) == NULL)\n                goto err;\n            /* Ri-- (mod double word size) */\n            Ri->neg = 0;\n            Ri->d[0] = BN_MASK2;\n            Ri->d[1] = BN_MASK2;\n            Ri->top = 2;\n        }\n        if (!BN_div(Ri, NULL, Ri, &tmod, ctx))\n            goto err;\n        /*\n         * Ni = (R*Ri-1)/N, keep only couple of least significant words:\n         */\n        mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0;\n        mont->n0[1] = (Ri->top > 1) ? Ri->d[1] : 0;\n# else\n        BN_zero(R);\n        if (!(BN_set_bit(R, BN_BITS2)))\n            goto err;           /* R */\n\n        buf[0] = mod->d[0];     /* tmod = N mod word size */\n        buf[1] = 0;\n        tmod.top = buf[0] != 0 ? 1 : 0;\n        /* Ri = R^-1 mod N */\n        if (BN_is_one(&tmod))\n            BN_zero(Ri);\n        else if ((BN_mod_inverse(Ri, R, &tmod, ctx)) == NULL)\n            goto err;\n        if (!BN_lshift(Ri, Ri, BN_BITS2))\n            goto err;           /* R*Ri */\n        if (!BN_is_zero(Ri)) {\n            if (!BN_sub_word(Ri, 1))\n                goto err;\n        } else {                /* if N mod word size == 1 */\n\n            if (!BN_set_word(Ri, BN_MASK2))\n                goto err;       /* Ri-- (mod word size) */\n        }\n        if (!BN_div(Ri, NULL, Ri, &tmod, ctx))\n            goto err;\n        /*\n         * Ni = (R*Ri-1)/N, keep only least significant word:\n         */\n        mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0;\n        mont->n0[1] = 0;\n# endif\n    }\n#else                           /* !MONT_WORD */\n    {                           /* bignum version */\n        mont->ri = BN_num_bits(&mont->N);\n        BN_zero(R);\n        if (!BN_set_bit(R, mont->ri))\n            goto err;           /* R = 2^ri */\n        /* Ri = R^-1 mod N */\n        if ((BN_mod_inverse(Ri, R, &mont->N, ctx)) == NULL)\n            goto err;\n        if (!BN_lshift(Ri, Ri, mont->ri))\n            goto err;           /* R*Ri */\n        if (!BN_sub_word(Ri, 1))\n            goto err;\n        /*\n         * Ni = (R*Ri-1) / N\n         */\n        if (!BN_div(&(mont->Ni), NULL, Ri, &mont->N, ctx))\n            goto err;\n    }\n#endif\n\n    /* setup RR for conversions */\n    BN_zero(&(mont->RR));\n    if (!BN_set_bit(&(mont->RR), mont->ri * 2))\n        goto err;\n    if (!BN_mod(&(mont->RR), &(mont->RR), &(mont->N), ctx))\n        goto err;\n\n    for (i = mont->RR.top, ret = mont->N.top; i < ret; i++)\n        mont->RR.d[i] = 0;\n    mont->RR.top = ret;\n    mont->RR.flags |= BN_FLG_FIXED_TOP;\n\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    return ret;\n}\n\nBN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)\n{\n    if (to == from)\n        return to;\n\n    if (!BN_copy(&(to->RR), &(from->RR)))\n        return NULL;\n    if (!BN_copy(&(to->N), &(from->N)))\n        return NULL;\n    if (!BN_copy(&(to->Ni), &(from->Ni)))\n        return NULL;\n    to->ri = from->ri;\n    to->n0[0] = from->n0[0];\n    to->n0[1] = from->n0[1];\n    return to;\n}\n\nBN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock,\n                                    const BIGNUM *mod, BN_CTX *ctx)\n{\n    BN_MONT_CTX *ret;\n\n    CRYPTO_THREAD_read_lock(lock);\n    ret = *pmont;\n    CRYPTO_THREAD_unlock(lock);\n    if (ret)\n        return ret;\n\n    /*\n     * We don't want to serialise globally while doing our lazy-init math in\n     * BN_MONT_CTX_set. That punishes threads that are doing independent\n     * things. Instead, punish the case where more than one thread tries to\n     * lazy-init the same 'pmont', by having each do the lazy-init math work\n     * independently and only use the one from the thread that wins the race\n     * (the losers throw away the work they've done).\n     */\n    ret = BN_MONT_CTX_new();\n    if (ret == NULL)\n        return NULL;\n    if (!BN_MONT_CTX_set(ret, mod, ctx)) {\n        BN_MONT_CTX_free(ret);\n        return NULL;\n    }\n\n    /* The locked compare-and-set, after the local work is done. */\n    CRYPTO_THREAD_write_lock(lock);\n    if (*pmont) {\n        BN_MONT_CTX_free(ret);\n        ret = *pmont;\n    } else\n        *pmont = ret;\n    CRYPTO_THREAD_unlock(lock);\n    return ret;\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_mul.c",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <assert.h>\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\n#if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS)\n/*\n * Here follows specialised variants of bn_add_words() and bn_sub_words().\n * They have the property performing operations on arrays of different sizes.\n * The sizes of those arrays is expressed through cl, which is the common\n * length ( basically, min(len(a),len(b)) ), and dl, which is the delta\n * between the two lengths, calculated as len(a)-len(b). All lengths are the\n * number of BN_ULONGs...  For the operations that require a result array as\n * parameter, it must have the length cl+abs(dl). These functions should\n * probably end up in bn_asm.c as soon as there are assembler counterparts\n * for the systems that use assembler files.\n */\n\nBN_ULONG bn_sub_part_words(BN_ULONG *r,\n                           const BN_ULONG *a, const BN_ULONG *b,\n                           int cl, int dl)\n{\n    BN_ULONG c, t;\n\n    assert(cl >= 0);\n    c = bn_sub_words(r, a, b, cl);\n\n    if (dl == 0)\n        return c;\n\n    r += cl;\n    a += cl;\n    b += cl;\n\n    if (dl < 0) {\n        for (;;) {\n            t = b[0];\n            r[0] = (0 - t - c) & BN_MASK2;\n            if (t != 0)\n                c = 1;\n            if (++dl >= 0)\n                break;\n\n            t = b[1];\n            r[1] = (0 - t - c) & BN_MASK2;\n            if (t != 0)\n                c = 1;\n            if (++dl >= 0)\n                break;\n\n            t = b[2];\n            r[2] = (0 - t - c) & BN_MASK2;\n            if (t != 0)\n                c = 1;\n            if (++dl >= 0)\n                break;\n\n            t = b[3];\n            r[3] = (0 - t - c) & BN_MASK2;\n            if (t != 0)\n                c = 1;\n            if (++dl >= 0)\n                break;\n\n            b += 4;\n            r += 4;\n        }\n    } else {\n        int save_dl = dl;\n        while (c) {\n            t = a[0];\n            r[0] = (t - c) & BN_MASK2;\n            if (t != 0)\n                c = 0;\n            if (--dl <= 0)\n                break;\n\n            t = a[1];\n            r[1] = (t - c) & BN_MASK2;\n            if (t != 0)\n                c = 0;\n            if (--dl <= 0)\n                break;\n\n            t = a[2];\n            r[2] = (t - c) & BN_MASK2;\n            if (t != 0)\n                c = 0;\n            if (--dl <= 0)\n                break;\n\n            t = a[3];\n            r[3] = (t - c) & BN_MASK2;\n            if (t != 0)\n                c = 0;\n            if (--dl <= 0)\n                break;\n\n            save_dl = dl;\n            a += 4;\n            r += 4;\n        }\n        if (dl > 0) {\n            if (save_dl > dl) {\n                switch (save_dl - dl) {\n                case 1:\n                    r[1] = a[1];\n                    if (--dl <= 0)\n                        break;\n                    /* fall thru */\n                case 2:\n                    r[2] = a[2];\n                    if (--dl <= 0)\n                        break;\n                    /* fall thru */\n                case 3:\n                    r[3] = a[3];\n                    if (--dl <= 0)\n                        break;\n                }\n                a += 4;\n                r += 4;\n            }\n        }\n        if (dl > 0) {\n            for (;;) {\n                r[0] = a[0];\n                if (--dl <= 0)\n                    break;\n                r[1] = a[1];\n                if (--dl <= 0)\n                    break;\n                r[2] = a[2];\n                if (--dl <= 0)\n                    break;\n                r[3] = a[3];\n                if (--dl <= 0)\n                    break;\n\n                a += 4;\n                r += 4;\n            }\n        }\n    }\n    return c;\n}\n#endif\n\n#ifdef BN_RECURSION\n/*\n * Karatsuba recursive multiplication algorithm (cf. Knuth, The Art of\n * Computer Programming, Vol. 2)\n */\n\n/*-\n * r is 2*n2 words in size,\n * a and b are both n2 words in size.\n * n2 must be a power of 2.\n * We multiply and return the result.\n * t must be 2*n2 words in size\n * We calculate\n * a[0]*b[0]\n * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])\n * a[1]*b[1]\n */\n/* dnX may not be positive, but n2/2+dnX has to be */\nvoid bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,\n                      int dna, int dnb, BN_ULONG *t)\n{\n    int n = n2 / 2, c1, c2;\n    int tna = n + dna, tnb = n + dnb;\n    unsigned int neg, zero;\n    BN_ULONG ln, lo, *p;\n\n# ifdef BN_MUL_COMBA\n#  if 0\n    if (n2 == 4) {\n        bn_mul_comba4(r, a, b);\n        return;\n    }\n#  endif\n    /*\n     * Only call bn_mul_comba 8 if n2 == 8 and the two arrays are complete\n     * [steve]\n     */\n    if (n2 == 8 && dna == 0 && dnb == 0) {\n        bn_mul_comba8(r, a, b);\n        return;\n    }\n# endif                         /* BN_MUL_COMBA */\n    /* Else do normal multiply */\n    if (n2 < BN_MUL_RECURSIVE_SIZE_NORMAL) {\n        bn_mul_normal(r, a, n2 + dna, b, n2 + dnb);\n        if ((dna + dnb) < 0)\n            memset(&r[2 * n2 + dna + dnb], 0,\n                   sizeof(BN_ULONG) * -(dna + dnb));\n        return;\n    }\n    /* r=(a[0]-a[1])*(b[1]-b[0]) */\n    c1 = bn_cmp_part_words(a, &(a[n]), tna, n - tna);\n    c2 = bn_cmp_part_words(&(b[n]), b, tnb, tnb - n);\n    zero = neg = 0;\n    switch (c1 * 3 + c2) {\n    case -4:\n        bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */\n        bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */\n        break;\n    case -3:\n        zero = 1;\n        break;\n    case -2:\n        bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */\n        bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); /* + */\n        neg = 1;\n        break;\n    case -1:\n    case 0:\n    case 1:\n        zero = 1;\n        break;\n    case 2:\n        bn_sub_part_words(t, a, &(a[n]), tna, n - tna); /* + */\n        bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */\n        neg = 1;\n        break;\n    case 3:\n        zero = 1;\n        break;\n    case 4:\n        bn_sub_part_words(t, a, &(a[n]), tna, n - tna);\n        bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n);\n        break;\n    }\n\n# ifdef BN_MUL_COMBA\n    if (n == 4 && dna == 0 && dnb == 0) { /* XXX: bn_mul_comba4 could take\n                                           * extra args to do this well */\n        if (!zero)\n            bn_mul_comba4(&(t[n2]), t, &(t[n]));\n        else\n            memset(&t[n2], 0, sizeof(*t) * 8);\n\n        bn_mul_comba4(r, a, b);\n        bn_mul_comba4(&(r[n2]), &(a[n]), &(b[n]));\n    } else if (n == 8 && dna == 0 && dnb == 0) { /* XXX: bn_mul_comba8 could\n                                                  * take extra args to do\n                                                  * this well */\n        if (!zero)\n            bn_mul_comba8(&(t[n2]), t, &(t[n]));\n        else\n            memset(&t[n2], 0, sizeof(*t) * 16);\n\n        bn_mul_comba8(r, a, b);\n        bn_mul_comba8(&(r[n2]), &(a[n]), &(b[n]));\n    } else\n# endif                         /* BN_MUL_COMBA */\n    {\n        p = &(t[n2 * 2]);\n        if (!zero)\n            bn_mul_recursive(&(t[n2]), t, &(t[n]), n, 0, 0, p);\n        else\n            memset(&t[n2], 0, sizeof(*t) * n2);\n        bn_mul_recursive(r, a, b, n, 0, 0, p);\n        bn_mul_recursive(&(r[n2]), &(a[n]), &(b[n]), n, dna, dnb, p);\n    }\n\n    /*-\n     * t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign\n     * r[10] holds (a[0]*b[0])\n     * r[32] holds (b[1]*b[1])\n     */\n\n    c1 = (int)(bn_add_words(t, r, &(r[n2]), n2));\n\n    if (neg) {                  /* if t[32] is negative */\n        c1 -= (int)(bn_sub_words(&(t[n2]), t, &(t[n2]), n2));\n    } else {\n        /* Might have a carry */\n        c1 += (int)(bn_add_words(&(t[n2]), &(t[n2]), t, n2));\n    }\n\n    /*-\n     * t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])\n     * r[10] holds (a[0]*b[0])\n     * r[32] holds (b[1]*b[1])\n     * c1 holds the carry bits\n     */\n    c1 += (int)(bn_add_words(&(r[n]), &(r[n]), &(t[n2]), n2));\n    if (c1) {\n        p = &(r[n + n2]);\n        lo = *p;\n        ln = (lo + c1) & BN_MASK2;\n        *p = ln;\n\n        /*\n         * The overflow will stop before we over write words we should not\n         * overwrite\n         */\n        if (ln < (BN_ULONG)c1) {\n            do {\n                p++;\n                lo = *p;\n                ln = (lo + 1) & BN_MASK2;\n                *p = ln;\n            } while (ln == 0);\n        }\n    }\n}\n\n/*\n * n+tn is the word length t needs to be n*4 is size, as does r\n */\n/* tnX may not be negative but less than n */\nvoid bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,\n                           int tna, int tnb, BN_ULONG *t)\n{\n    int i, j, n2 = n * 2;\n    int c1, c2, neg;\n    BN_ULONG ln, lo, *p;\n\n    if (n < 8) {\n        bn_mul_normal(r, a, n + tna, b, n + tnb);\n        return;\n    }\n\n    /* r=(a[0]-a[1])*(b[1]-b[0]) */\n    c1 = bn_cmp_part_words(a, &(a[n]), tna, n - tna);\n    c2 = bn_cmp_part_words(&(b[n]), b, tnb, tnb - n);\n    neg = 0;\n    switch (c1 * 3 + c2) {\n    case -4:\n        bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */\n        bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */\n        break;\n    case -3:\n    case -2:\n        bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */\n        bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); /* + */\n        neg = 1;\n        break;\n    case -1:\n    case 0:\n    case 1:\n    case 2:\n        bn_sub_part_words(t, a, &(a[n]), tna, n - tna); /* + */\n        bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */\n        neg = 1;\n        break;\n    case 3:\n    case 4:\n        bn_sub_part_words(t, a, &(a[n]), tna, n - tna);\n        bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n);\n        break;\n    }\n    /*\n     * The zero case isn't yet implemented here. The speedup would probably\n     * be negligible.\n     */\n# if 0\n    if (n == 4) {\n        bn_mul_comba4(&(t[n2]), t, &(t[n]));\n        bn_mul_comba4(r, a, b);\n        bn_mul_normal(&(r[n2]), &(a[n]), tn, &(b[n]), tn);\n        memset(&r[n2 + tn * 2], 0, sizeof(*r) * (n2 - tn * 2));\n    } else\n# endif\n    if (n == 8) {\n        bn_mul_comba8(&(t[n2]), t, &(t[n]));\n        bn_mul_comba8(r, a, b);\n        bn_mul_normal(&(r[n2]), &(a[n]), tna, &(b[n]), tnb);\n        memset(&r[n2 + tna + tnb], 0, sizeof(*r) * (n2 - tna - tnb));\n    } else {\n        p = &(t[n2 * 2]);\n        bn_mul_recursive(&(t[n2]), t, &(t[n]), n, 0, 0, p);\n        bn_mul_recursive(r, a, b, n, 0, 0, p);\n        i = n / 2;\n        /*\n         * If there is only a bottom half to the number, just do it\n         */\n        if (tna > tnb)\n            j = tna - i;\n        else\n            j = tnb - i;\n        if (j == 0) {\n            bn_mul_recursive(&(r[n2]), &(a[n]), &(b[n]),\n                             i, tna - i, tnb - i, p);\n            memset(&r[n2 + i * 2], 0, sizeof(*r) * (n2 - i * 2));\n        } else if (j > 0) {     /* eg, n == 16, i == 8 and tn == 11 */\n            bn_mul_part_recursive(&(r[n2]), &(a[n]), &(b[n]),\n                                  i, tna - i, tnb - i, p);\n            memset(&(r[n2 + tna + tnb]), 0,\n                   sizeof(BN_ULONG) * (n2 - tna - tnb));\n        } else {                /* (j < 0) eg, n == 16, i == 8 and tn == 5 */\n\n            memset(&r[n2], 0, sizeof(*r) * n2);\n            if (tna < BN_MUL_RECURSIVE_SIZE_NORMAL\n                && tnb < BN_MUL_RECURSIVE_SIZE_NORMAL) {\n                bn_mul_normal(&(r[n2]), &(a[n]), tna, &(b[n]), tnb);\n            } else {\n                for (;;) {\n                    i /= 2;\n                    /*\n                     * these simplified conditions work exclusively because\n                     * difference between tna and tnb is 1 or 0\n                     */\n                    if (i < tna || i < tnb) {\n                        bn_mul_part_recursive(&(r[n2]),\n                                              &(a[n]), &(b[n]),\n                                              i, tna - i, tnb - i, p);\n                        break;\n                    } else if (i == tna || i == tnb) {\n                        bn_mul_recursive(&(r[n2]),\n                                         &(a[n]), &(b[n]),\n                                         i, tna - i, tnb - i, p);\n                        break;\n                    }\n                }\n            }\n        }\n    }\n\n    /*-\n     * t[32] holds (a[0]-a[1])*(b[1]-b[0]), c1 is the sign\n     * r[10] holds (a[0]*b[0])\n     * r[32] holds (b[1]*b[1])\n     */\n\n    c1 = (int)(bn_add_words(t, r, &(r[n2]), n2));\n\n    if (neg) {                  /* if t[32] is negative */\n        c1 -= (int)(bn_sub_words(&(t[n2]), t, &(t[n2]), n2));\n    } else {\n        /* Might have a carry */\n        c1 += (int)(bn_add_words(&(t[n2]), &(t[n2]), t, n2));\n    }\n\n    /*-\n     * t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])\n     * r[10] holds (a[0]*b[0])\n     * r[32] holds (b[1]*b[1])\n     * c1 holds the carry bits\n     */\n    c1 += (int)(bn_add_words(&(r[n]), &(r[n]), &(t[n2]), n2));\n    if (c1) {\n        p = &(r[n + n2]);\n        lo = *p;\n        ln = (lo + c1) & BN_MASK2;\n        *p = ln;\n\n        /*\n         * The overflow will stop before we over write words we should not\n         * overwrite\n         */\n        if (ln < (BN_ULONG)c1) {\n            do {\n                p++;\n                lo = *p;\n                ln = (lo + 1) & BN_MASK2;\n                *p = ln;\n            } while (ln == 0);\n        }\n    }\n}\n\n/*-\n * a and b must be the same size, which is n2.\n * r needs to be n2 words and t needs to be n2*2\n */\nvoid bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,\n                          BN_ULONG *t)\n{\n    int n = n2 / 2;\n\n    bn_mul_recursive(r, a, b, n, 0, 0, &(t[0]));\n    if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL) {\n        bn_mul_low_recursive(&(t[0]), &(a[0]), &(b[n]), n, &(t[n2]));\n        bn_add_words(&(r[n]), &(r[n]), &(t[0]), n);\n        bn_mul_low_recursive(&(t[0]), &(a[n]), &(b[0]), n, &(t[n2]));\n        bn_add_words(&(r[n]), &(r[n]), &(t[0]), n);\n    } else {\n        bn_mul_low_normal(&(t[0]), &(a[0]), &(b[n]), n);\n        bn_mul_low_normal(&(t[n]), &(a[n]), &(b[0]), n);\n        bn_add_words(&(r[n]), &(r[n]), &(t[0]), n);\n        bn_add_words(&(r[n]), &(r[n]), &(t[n]), n);\n    }\n}\n#endif                          /* BN_RECURSION */\n\nint BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = bn_mul_fixed_top(r, a, b, ctx);\n\n    bn_correct_top(r);\n    bn_check_top(r);\n\n    return ret;\n}\n\nint bn_mul_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    int top, al, bl;\n    BIGNUM *rr;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    int i;\n#endif\n#ifdef BN_RECURSION\n    BIGNUM *t = NULL;\n    int j = 0, k;\n#endif\n\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(r);\n\n    al = a->top;\n    bl = b->top;\n\n    if ((al == 0) || (bl == 0)) {\n        BN_zero(r);\n        return 1;\n    }\n    top = al + bl;\n\n    BN_CTX_start(ctx);\n    if ((r == a) || (r == b)) {\n        if ((rr = BN_CTX_get(ctx)) == NULL)\n            goto err;\n    } else\n        rr = r;\n\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    i = al - bl;\n#endif\n#ifdef BN_MUL_COMBA\n    if (i == 0) {\n# if 0\n        if (al == 4) {\n            if (bn_wexpand(rr, 8) == NULL)\n                goto err;\n            rr->top = 8;\n            bn_mul_comba4(rr->d, a->d, b->d);\n            goto end;\n        }\n# endif\n        if (al == 8) {\n            if (bn_wexpand(rr, 16) == NULL)\n                goto err;\n            rr->top = 16;\n            bn_mul_comba8(rr->d, a->d, b->d);\n            goto end;\n        }\n    }\n#endif                          /* BN_MUL_COMBA */\n#ifdef BN_RECURSION\n    if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) {\n        if (i >= -1 && i <= 1) {\n            /*\n             * Find out the power of two lower or equal to the longest of the\n             * two numbers\n             */\n            if (i >= 0) {\n                j = BN_num_bits_word((BN_ULONG)al);\n            }\n            if (i == -1) {\n                j = BN_num_bits_word((BN_ULONG)bl);\n            }\n            j = 1 << (j - 1);\n            assert(j <= al || j <= bl);\n            k = j + j;\n            t = BN_CTX_get(ctx);\n            if (t == NULL)\n                goto err;\n            if (al > j || bl > j) {\n                if (bn_wexpand(t, k * 4) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 4) == NULL)\n                    goto err;\n                bn_mul_part_recursive(rr->d, a->d, b->d,\n                                      j, al - j, bl - j, t->d);\n            } else {            /* al <= j || bl <= j */\n\n                if (bn_wexpand(t, k * 2) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 2) == NULL)\n                    goto err;\n                bn_mul_recursive(rr->d, a->d, b->d, j, al - j, bl - j, t->d);\n            }\n            rr->top = top;\n            goto end;\n        }\n    }\n#endif                          /* BN_RECURSION */\n    if (bn_wexpand(rr, top) == NULL)\n        goto err;\n    rr->top = top;\n    bn_mul_normal(rr->d, a->d, al, b->d, bl);\n\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n end:\n#endif\n    rr->neg = a->neg ^ b->neg;\n    rr->flags |= BN_FLG_FIXED_TOP;\n    if (r != rr && BN_copy(r, rr) == NULL)\n        goto err;\n\n    ret = 1;\n err:\n    bn_check_top(r);\n    BN_CTX_end(ctx);\n    return ret;\n}\n\nvoid bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)\n{\n    BN_ULONG *rr;\n\n    if (na < nb) {\n        int itmp;\n        BN_ULONG *ltmp;\n\n        itmp = na;\n        na = nb;\n        nb = itmp;\n        ltmp = a;\n        a = b;\n        b = ltmp;\n\n    }\n    rr = &(r[na]);\n    if (nb <= 0) {\n        (void)bn_mul_words(r, a, na, 0);\n        return;\n    } else\n        rr[0] = bn_mul_words(r, a, na, b[0]);\n\n    for (;;) {\n        if (--nb <= 0)\n            return;\n        rr[1] = bn_mul_add_words(&(r[1]), a, na, b[1]);\n        if (--nb <= 0)\n            return;\n        rr[2] = bn_mul_add_words(&(r[2]), a, na, b[2]);\n        if (--nb <= 0)\n            return;\n        rr[3] = bn_mul_add_words(&(r[3]), a, na, b[3]);\n        if (--nb <= 0)\n            return;\n        rr[4] = bn_mul_add_words(&(r[4]), a, na, b[4]);\n        rr += 4;\n        r += 4;\n        b += 4;\n    }\n}\n\nvoid bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)\n{\n    bn_mul_words(r, a, n, b[0]);\n\n    for (;;) {\n        if (--n <= 0)\n            return;\n        bn_mul_add_words(&(r[1]), a, n, b[1]);\n        if (--n <= 0)\n            return;\n        bn_mul_add_words(&(r[2]), a, n, b[2]);\n        if (--n <= 0)\n            return;\n        bn_mul_add_words(&(r[3]), a, n, b[3]);\n        if (--n <= 0)\n            return;\n        bn_mul_add_words(&(r[4]), a, n, b[4]);\n        r += 4;\n        b += 4;\n    }\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_nist.c",
    "content": "/*\n * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"bn_local.h\"\n#include \"internal/cryptlib.h\"\n\n#define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2\n#define BN_NIST_224_TOP (224+BN_BITS2-1)/BN_BITS2\n#define BN_NIST_256_TOP (256+BN_BITS2-1)/BN_BITS2\n#define BN_NIST_384_TOP (384+BN_BITS2-1)/BN_BITS2\n#define BN_NIST_521_TOP (521+BN_BITS2-1)/BN_BITS2\n\n/* pre-computed tables are \"carry-less\" values of modulus*(i+1) */\n#if BN_BITS2 == 64\nstatic const BN_ULONG _nist_p_192[][BN_NIST_192_TOP] = {\n    {0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFEULL, 0xFFFFFFFFFFFFFFFFULL},\n    {0xFFFFFFFFFFFFFFFEULL, 0xFFFFFFFFFFFFFFFDULL, 0xFFFFFFFFFFFFFFFFULL},\n    {0xFFFFFFFFFFFFFFFDULL, 0xFFFFFFFFFFFFFFFCULL, 0xFFFFFFFFFFFFFFFFULL}\n};\n\nstatic const BN_ULONG _nist_p_192_sqr[] = {\n    0x0000000000000001ULL, 0x0000000000000002ULL, 0x0000000000000001ULL,\n    0xFFFFFFFFFFFFFFFEULL, 0xFFFFFFFFFFFFFFFDULL, 0xFFFFFFFFFFFFFFFFULL\n};\n\nstatic const BN_ULONG _nist_p_224[][BN_NIST_224_TOP] = {\n    {0x0000000000000001ULL, 0xFFFFFFFF00000000ULL,\n     0xFFFFFFFFFFFFFFFFULL, 0x00000000FFFFFFFFULL},\n    {0x0000000000000002ULL, 0xFFFFFFFE00000000ULL,\n     0xFFFFFFFFFFFFFFFFULL, 0x00000001FFFFFFFFULL} /* this one is\n                                                    * \"carry-full\" */\n};\n\nstatic const BN_ULONG _nist_p_224_sqr[] = {\n    0x0000000000000001ULL, 0xFFFFFFFE00000000ULL,\n    0xFFFFFFFFFFFFFFFFULL, 0x0000000200000000ULL,\n    0x0000000000000000ULL, 0xFFFFFFFFFFFFFFFEULL,\n    0xFFFFFFFFFFFFFFFFULL\n};\n\nstatic const BN_ULONG _nist_p_256[][BN_NIST_256_TOP] = {\n    {0xFFFFFFFFFFFFFFFFULL, 0x00000000FFFFFFFFULL,\n     0x0000000000000000ULL, 0xFFFFFFFF00000001ULL},\n    {0xFFFFFFFFFFFFFFFEULL, 0x00000001FFFFFFFFULL,\n     0x0000000000000000ULL, 0xFFFFFFFE00000002ULL},\n    {0xFFFFFFFFFFFFFFFDULL, 0x00000002FFFFFFFFULL,\n     0x0000000000000000ULL, 0xFFFFFFFD00000003ULL},\n    {0xFFFFFFFFFFFFFFFCULL, 0x00000003FFFFFFFFULL,\n     0x0000000000000000ULL, 0xFFFFFFFC00000004ULL},\n    {0xFFFFFFFFFFFFFFFBULL, 0x00000004FFFFFFFFULL,\n     0x0000000000000000ULL, 0xFFFFFFFB00000005ULL},\n};\n\nstatic const BN_ULONG _nist_p_256_sqr[] = {\n    0x0000000000000001ULL, 0xFFFFFFFE00000000ULL,\n    0xFFFFFFFFFFFFFFFFULL, 0x00000001FFFFFFFEULL,\n    0x00000001FFFFFFFEULL, 0x00000001FFFFFFFEULL,\n    0xFFFFFFFE00000001ULL, 0xFFFFFFFE00000002ULL\n};\n\nstatic const BN_ULONG _nist_p_384[][BN_NIST_384_TOP] = {\n    {0x00000000FFFFFFFFULL, 0xFFFFFFFF00000000ULL, 0xFFFFFFFFFFFFFFFEULL,\n     0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL},\n    {0x00000001FFFFFFFEULL, 0xFFFFFFFE00000000ULL, 0xFFFFFFFFFFFFFFFDULL,\n     0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL},\n    {0x00000002FFFFFFFDULL, 0xFFFFFFFD00000000ULL, 0xFFFFFFFFFFFFFFFCULL,\n     0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL},\n    {0x00000003FFFFFFFCULL, 0xFFFFFFFC00000000ULL, 0xFFFFFFFFFFFFFFFBULL,\n     0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL},\n    {0x00000004FFFFFFFBULL, 0xFFFFFFFB00000000ULL, 0xFFFFFFFFFFFFFFFAULL,\n     0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL},\n};\n\nstatic const BN_ULONG _nist_p_384_sqr[] = {\n    0xFFFFFFFE00000001ULL, 0x0000000200000000ULL, 0xFFFFFFFE00000000ULL,\n    0x0000000200000000ULL, 0x0000000000000001ULL, 0x0000000000000000ULL,\n    0x00000001FFFFFFFEULL, 0xFFFFFFFE00000000ULL, 0xFFFFFFFFFFFFFFFDULL,\n    0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL\n};\n\nstatic const BN_ULONG _nist_p_521[] =\n    { 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL,\n    0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL,\n    0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL,\n    0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL,\n    0x00000000000001FFULL\n};\n\nstatic const BN_ULONG _nist_p_521_sqr[] = {\n    0x0000000000000001ULL, 0x0000000000000000ULL, 0x0000000000000000ULL,\n    0x0000000000000000ULL, 0x0000000000000000ULL, 0x0000000000000000ULL,\n    0x0000000000000000ULL, 0x0000000000000000ULL, 0xFFFFFFFFFFFFFC00ULL,\n    0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL,\n    0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL,\n    0xFFFFFFFFFFFFFFFFULL, 0x000000000003FFFFULL\n};\n#elif BN_BITS2 == 32\nstatic const BN_ULONG _nist_p_192[][BN_NIST_192_TOP] = {\n    {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},\n    {0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},\n    {0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}\n};\n\nstatic const BN_ULONG _nist_p_192_sqr[] = {\n    0x00000001, 0x00000000, 0x00000002, 0x00000000, 0x00000001, 0x00000000,\n    0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF\n};\n\nstatic const BN_ULONG _nist_p_224[][BN_NIST_224_TOP] = {\n    {0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFF,\n     0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},\n    {0x00000002, 0x00000000, 0x00000000, 0xFFFFFFFE,\n     0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}\n};\n\nstatic const BN_ULONG _nist_p_224_sqr[] = {\n    0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFE,\n    0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000002,\n    0x00000000, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFF,\n    0xFFFFFFFF, 0xFFFFFFFF\n};\n\nstatic const BN_ULONG _nist_p_256[][BN_NIST_256_TOP] = {\n    {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,\n     0x00000000, 0x00000000, 0x00000001, 0xFFFFFFFF},\n    {0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000001,\n     0x00000000, 0x00000000, 0x00000002, 0xFFFFFFFE},\n    {0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000002,\n     0x00000000, 0x00000000, 0x00000003, 0xFFFFFFFD},\n    {0xFFFFFFFC, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000003,\n     0x00000000, 0x00000000, 0x00000004, 0xFFFFFFFC},\n    {0xFFFFFFFB, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000004,\n     0x00000000, 0x00000000, 0x00000005, 0xFFFFFFFB},\n};\n\nstatic const BN_ULONG _nist_p_256_sqr[] = {\n    0x00000001, 0x00000000, 0x00000000, 0xFFFFFFFE,\n    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE, 0x00000001,\n    0xFFFFFFFE, 0x00000001, 0xFFFFFFFE, 0x00000001,\n    0x00000001, 0xFFFFFFFE, 0x00000002, 0xFFFFFFFE\n};\n\nstatic const BN_ULONG _nist_p_384[][BN_NIST_384_TOP] = {\n    {0xFFFFFFFF, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,\n     0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},\n    {0xFFFFFFFE, 0x00000001, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFF,\n     0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},\n    {0xFFFFFFFD, 0x00000002, 0x00000000, 0xFFFFFFFD, 0xFFFFFFFC, 0xFFFFFFFF,\n     0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},\n    {0xFFFFFFFC, 0x00000003, 0x00000000, 0xFFFFFFFC, 0xFFFFFFFB, 0xFFFFFFFF,\n     0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},\n    {0xFFFFFFFB, 0x00000004, 0x00000000, 0xFFFFFFFB, 0xFFFFFFFA, 0xFFFFFFFF,\n     0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF},\n};\n\nstatic const BN_ULONG _nist_p_384_sqr[] = {\n    0x00000001, 0xFFFFFFFE, 0x00000000, 0x00000002, 0x00000000, 0xFFFFFFFE,\n    0x00000000, 0x00000002, 0x00000001, 0x00000000, 0x00000000, 0x00000000,\n    0xFFFFFFFE, 0x00000001, 0x00000000, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFF,\n    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF\n};\n\nstatic const BN_ULONG _nist_p_521[] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n    0xFFFFFFFF, 0x000001FF\n};\n\nstatic const BN_ULONG _nist_p_521_sqr[] = {\n    0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,\n    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,\n    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFC00, 0xFFFFFFFF,\n    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n    0xFFFFFFFF, 0xFFFFFFFF, 0x0003FFFF\n};\n#else\n# error \"unsupported BN_BITS2\"\n#endif\n\nstatic const BIGNUM _bignum_nist_p_192 = {\n    (BN_ULONG *)_nist_p_192[0],\n    BN_NIST_192_TOP,\n    BN_NIST_192_TOP,\n    0,\n    BN_FLG_STATIC_DATA\n};\n\nstatic const BIGNUM _bignum_nist_p_224 = {\n    (BN_ULONG *)_nist_p_224[0],\n    BN_NIST_224_TOP,\n    BN_NIST_224_TOP,\n    0,\n    BN_FLG_STATIC_DATA\n};\n\nstatic const BIGNUM _bignum_nist_p_256 = {\n    (BN_ULONG *)_nist_p_256[0],\n    BN_NIST_256_TOP,\n    BN_NIST_256_TOP,\n    0,\n    BN_FLG_STATIC_DATA\n};\n\nstatic const BIGNUM _bignum_nist_p_384 = {\n    (BN_ULONG *)_nist_p_384[0],\n    BN_NIST_384_TOP,\n    BN_NIST_384_TOP,\n    0,\n    BN_FLG_STATIC_DATA\n};\n\nstatic const BIGNUM _bignum_nist_p_521 = {\n    (BN_ULONG *)_nist_p_521,\n    BN_NIST_521_TOP,\n    BN_NIST_521_TOP,\n    0,\n    BN_FLG_STATIC_DATA\n};\n\nconst BIGNUM *BN_get0_nist_prime_192(void)\n{\n    return &_bignum_nist_p_192;\n}\n\nconst BIGNUM *BN_get0_nist_prime_224(void)\n{\n    return &_bignum_nist_p_224;\n}\n\nconst BIGNUM *BN_get0_nist_prime_256(void)\n{\n    return &_bignum_nist_p_256;\n}\n\nconst BIGNUM *BN_get0_nist_prime_384(void)\n{\n    return &_bignum_nist_p_384;\n}\n\nconst BIGNUM *BN_get0_nist_prime_521(void)\n{\n    return &_bignum_nist_p_521;\n}\n\nstatic void nist_cp_bn_0(BN_ULONG *dst, const BN_ULONG *src, int top, int max)\n{\n    int i;\n\n#ifdef BN_DEBUG\n    (void)ossl_assert(top <= max);\n#endif\n    for (i = 0; i < top; i++)\n        dst[i] = src[i];\n    for (; i < max; i++)\n        dst[i] = 0;\n}\n\nstatic void nist_cp_bn(BN_ULONG *dst, const BN_ULONG *src, int top)\n{\n    int i;\n\n    for (i = 0; i < top; i++)\n        dst[i] = src[i];\n}\n\n#if BN_BITS2 == 64\n# define bn_cp_64(to, n, from, m)        (to)[n] = (m>=0)?((from)[m]):0;\n# define bn_64_set_0(to, n)              (to)[n] = (BN_ULONG)0;\n/*\n * two following macros are implemented under assumption that they\n * are called in a sequence with *ascending* n, i.e. as they are...\n */\n# define bn_cp_32_naked(to, n, from, m)  (((n)&1)?(to[(n)/2]|=((m)&1)?(from[(m)/2]&BN_MASK2h):(from[(m)/2]<<32))\\\n                                                :(to[(n)/2] =((m)&1)?(from[(m)/2]>>32):(from[(m)/2]&BN_MASK2l)))\n# define bn_32_set_0(to, n)              (((n)&1)?(to[(n)/2]&=BN_MASK2l):(to[(n)/2]=0));\n# define bn_cp_32(to,n,from,m)           ((m)>=0)?bn_cp_32_naked(to,n,from,m):bn_32_set_0(to,n)\n# if defined(L_ENDIAN)\n#  if defined(__arch64__)\n#   define NIST_INT64 long\n#  else\n#   define NIST_INT64 long long\n#  endif\n# endif\n#else\n# define bn_cp_64(to, n, from, m) \\\n        { \\\n        bn_cp_32(to, (n)*2, from, (m)*2); \\\n        bn_cp_32(to, (n)*2+1, from, (m)*2+1); \\\n        }\n# define bn_64_set_0(to, n) \\\n        { \\\n        bn_32_set_0(to, (n)*2); \\\n        bn_32_set_0(to, (n)*2+1); \\\n        }\n# define bn_cp_32(to, n, from, m)        (to)[n] = (m>=0)?((from)[m]):0;\n# define bn_32_set_0(to, n)              (to)[n] = (BN_ULONG)0;\n# if defined(_WIN32) && !defined(__GNUC__)\n#  define NIST_INT64 __int64\n# elif defined(BN_LLONG)\n#  define NIST_INT64 long long\n# endif\n#endif                          /* BN_BITS2 != 64 */\n\n#define nist_set_192(to, from, a1, a2, a3) \\\n        { \\\n        bn_cp_64(to, 0, from, (a3) - 3) \\\n        bn_cp_64(to, 1, from, (a2) - 3) \\\n        bn_cp_64(to, 2, from, (a1) - 3) \\\n        }\n\nint BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,\n                    BN_CTX *ctx)\n{\n    int top = a->top, i;\n    int carry;\n    register BN_ULONG *r_d, *a_d = a->d;\n    union {\n        BN_ULONG bn[BN_NIST_192_TOP];\n        unsigned int ui[BN_NIST_192_TOP * sizeof(BN_ULONG) /\n                        sizeof(unsigned int)];\n    } buf;\n    BN_ULONG c_d[BN_NIST_192_TOP], *res;\n    PTR_SIZE_INT mask;\n    static const BIGNUM _bignum_nist_p_192_sqr = {\n        (BN_ULONG *)_nist_p_192_sqr,\n        OSSL_NELEM(_nist_p_192_sqr),\n        OSSL_NELEM(_nist_p_192_sqr),\n        0, BN_FLG_STATIC_DATA\n    };\n\n    field = &_bignum_nist_p_192; /* just to make sure */\n\n    if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_192_sqr) >= 0)\n        return BN_nnmod(r, a, field, ctx);\n\n    i = BN_ucmp(field, a);\n    if (i == 0) {\n        BN_zero(r);\n        return 1;\n    } else if (i > 0)\n        return (r == a) ? 1 : (BN_copy(r, a) != NULL);\n\n    if (r != a) {\n        if (!bn_wexpand(r, BN_NIST_192_TOP))\n            return 0;\n        r_d = r->d;\n        nist_cp_bn(r_d, a_d, BN_NIST_192_TOP);\n    } else\n        r_d = a_d;\n\n    nist_cp_bn_0(buf.bn, a_d + BN_NIST_192_TOP, top - BN_NIST_192_TOP,\n                 BN_NIST_192_TOP);\n\n#if defined(NIST_INT64)\n    {\n        NIST_INT64 acc;         /* accumulator */\n        unsigned int *rp = (unsigned int *)r_d;\n        const unsigned int *bp = (const unsigned int *)buf.ui;\n\n        acc = rp[0];\n        acc += bp[3 * 2 - 6];\n        acc += bp[5 * 2 - 6];\n        rp[0] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[1];\n        acc += bp[3 * 2 - 5];\n        acc += bp[5 * 2 - 5];\n        rp[1] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[2];\n        acc += bp[3 * 2 - 6];\n        acc += bp[4 * 2 - 6];\n        acc += bp[5 * 2 - 6];\n        rp[2] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[3];\n        acc += bp[3 * 2 - 5];\n        acc += bp[4 * 2 - 5];\n        acc += bp[5 * 2 - 5];\n        rp[3] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[4];\n        acc += bp[4 * 2 - 6];\n        acc += bp[5 * 2 - 6];\n        rp[4] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[5];\n        acc += bp[4 * 2 - 5];\n        acc += bp[5 * 2 - 5];\n        rp[5] = (unsigned int)acc;\n\n        carry = (int)(acc >> 32);\n    }\n#else\n    {\n        BN_ULONG t_d[BN_NIST_192_TOP];\n\n        nist_set_192(t_d, buf.bn, 0, 3, 3);\n        carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP);\n        nist_set_192(t_d, buf.bn, 4, 4, 0);\n        carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP);\n        nist_set_192(t_d, buf.bn, 5, 5, 5)\n            carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_192_TOP);\n    }\n#endif\n    if (carry > 0)\n        carry =\n            (int)bn_sub_words(r_d, r_d, _nist_p_192[carry - 1],\n                              BN_NIST_192_TOP);\n    else\n        carry = 1;\n\n    /*\n     * we need 'if (carry==0 || result>=modulus) result-=modulus;'\n     * as comparison implies subtraction, we can write\n     * 'tmp=result-modulus; if (!carry || !borrow) result=tmp;'\n     * this is what happens below, but without explicit if:-) a.\n     */\n    mask =\n        0 - (PTR_SIZE_INT) bn_sub_words(c_d, r_d, _nist_p_192[0],\n                                        BN_NIST_192_TOP);\n    mask &= 0 - (PTR_SIZE_INT) carry;\n    res = c_d;\n    res = (BN_ULONG *)\n        (((PTR_SIZE_INT) res & ~mask) | ((PTR_SIZE_INT) r_d & mask));\n    nist_cp_bn(r_d, res, BN_NIST_192_TOP);\n    r->top = BN_NIST_192_TOP;\n    bn_correct_top(r);\n\n    return 1;\n}\n\ntypedef BN_ULONG (*bn_addsub_f) (BN_ULONG *, const BN_ULONG *,\n                                 const BN_ULONG *, int);\n\n#define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \\\n        { \\\n        bn_cp_32(to, 0, from, (a7) - 7) \\\n        bn_cp_32(to, 1, from, (a6) - 7) \\\n        bn_cp_32(to, 2, from, (a5) - 7) \\\n        bn_cp_32(to, 3, from, (a4) - 7) \\\n        bn_cp_32(to, 4, from, (a3) - 7) \\\n        bn_cp_32(to, 5, from, (a2) - 7) \\\n        bn_cp_32(to, 6, from, (a1) - 7) \\\n        }\n\nint BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,\n                    BN_CTX *ctx)\n{\n    int top = a->top, i;\n    int carry;\n    BN_ULONG *r_d, *a_d = a->d;\n    union {\n        BN_ULONG bn[BN_NIST_224_TOP];\n        unsigned int ui[BN_NIST_224_TOP * sizeof(BN_ULONG) /\n                        sizeof(unsigned int)];\n    } buf;\n    BN_ULONG c_d[BN_NIST_224_TOP], *res;\n    PTR_SIZE_INT mask;\n    union {\n        bn_addsub_f f;\n        PTR_SIZE_INT p;\n    } u;\n    static const BIGNUM _bignum_nist_p_224_sqr = {\n        (BN_ULONG *)_nist_p_224_sqr,\n        OSSL_NELEM(_nist_p_224_sqr),\n        OSSL_NELEM(_nist_p_224_sqr),\n        0, BN_FLG_STATIC_DATA\n    };\n\n    field = &_bignum_nist_p_224; /* just to make sure */\n\n    if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_224_sqr) >= 0)\n        return BN_nnmod(r, a, field, ctx);\n\n    i = BN_ucmp(field, a);\n    if (i == 0) {\n        BN_zero(r);\n        return 1;\n    } else if (i > 0)\n        return (r == a) ? 1 : (BN_copy(r, a) != NULL);\n\n    if (r != a) {\n        if (!bn_wexpand(r, BN_NIST_224_TOP))\n            return 0;\n        r_d = r->d;\n        nist_cp_bn(r_d, a_d, BN_NIST_224_TOP);\n    } else\n        r_d = a_d;\n\n#if BN_BITS2==64\n    /* copy upper 256 bits of 448 bit number ... */\n    nist_cp_bn_0(c_d, a_d + (BN_NIST_224_TOP - 1),\n                 top - (BN_NIST_224_TOP - 1), BN_NIST_224_TOP);\n    /* ... and right shift by 32 to obtain upper 224 bits */\n    nist_set_224(buf.bn, c_d, 14, 13, 12, 11, 10, 9, 8);\n    /* truncate lower part to 224 bits too */\n    r_d[BN_NIST_224_TOP - 1] &= BN_MASK2l;\n#else\n    nist_cp_bn_0(buf.bn, a_d + BN_NIST_224_TOP, top - BN_NIST_224_TOP,\n                 BN_NIST_224_TOP);\n#endif\n\n#if defined(NIST_INT64) && BN_BITS2!=64\n    {\n        NIST_INT64 acc;         /* accumulator */\n        unsigned int *rp = (unsigned int *)r_d;\n        const unsigned int *bp = (const unsigned int *)buf.ui;\n\n        acc = rp[0];\n        acc -= bp[7 - 7];\n        acc -= bp[11 - 7];\n        rp[0] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[1];\n        acc -= bp[8 - 7];\n        acc -= bp[12 - 7];\n        rp[1] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[2];\n        acc -= bp[9 - 7];\n        acc -= bp[13 - 7];\n        rp[2] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[3];\n        acc += bp[7 - 7];\n        acc += bp[11 - 7];\n        acc -= bp[10 - 7];\n        rp[3] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[4];\n        acc += bp[8 - 7];\n        acc += bp[12 - 7];\n        acc -= bp[11 - 7];\n        rp[4] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[5];\n        acc += bp[9 - 7];\n        acc += bp[13 - 7];\n        acc -= bp[12 - 7];\n        rp[5] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[6];\n        acc += bp[10 - 7];\n        acc -= bp[13 - 7];\n        rp[6] = (unsigned int)acc;\n\n        carry = (int)(acc >> 32);\n# if BN_BITS2==64\n        rp[7] = carry;\n# endif\n    }\n#else\n    {\n        BN_ULONG t_d[BN_NIST_224_TOP];\n\n        nist_set_224(t_d, buf.bn, 10, 9, 8, 7, 0, 0, 0);\n        carry = (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP);\n        nist_set_224(t_d, buf.bn, 0, 13, 12, 11, 0, 0, 0);\n        carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_224_TOP);\n        nist_set_224(t_d, buf.bn, 13, 12, 11, 10, 9, 8, 7);\n        carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP);\n        nist_set_224(t_d, buf.bn, 0, 0, 0, 0, 13, 12, 11);\n        carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_224_TOP);\n\n# if BN_BITS2==64\n        carry = (int)(r_d[BN_NIST_224_TOP - 1] >> 32);\n# endif\n    }\n#endif\n    u.f = bn_sub_words;\n    if (carry > 0) {\n        carry =\n            (int)bn_sub_words(r_d, r_d, _nist_p_224[carry - 1],\n                              BN_NIST_224_TOP);\n#if BN_BITS2==64\n        carry = (int)(~(r_d[BN_NIST_224_TOP - 1] >> 32)) & 1;\n#endif\n    } else if (carry < 0) {\n        /*\n         * it's a bit more complicated logic in this case. if bn_add_words\n         * yields no carry, then result has to be adjusted by unconditionally\n         * *adding* the modulus. but if it does, then result has to be\n         * compared to the modulus and conditionally adjusted by\n         * *subtracting* the latter.\n         */\n        carry =\n            (int)bn_add_words(r_d, r_d, _nist_p_224[-carry - 1],\n                              BN_NIST_224_TOP);\n        mask = 0 - (PTR_SIZE_INT) carry;\n        u.p = ((PTR_SIZE_INT) bn_sub_words & mask) |\n            ((PTR_SIZE_INT) bn_add_words & ~mask);\n    } else\n        carry = 1;\n\n    /* otherwise it's effectively same as in BN_nist_mod_192... */\n    mask =\n        0 - (PTR_SIZE_INT) (*u.f) (c_d, r_d, _nist_p_224[0], BN_NIST_224_TOP);\n    mask &= 0 - (PTR_SIZE_INT) carry;\n    res = c_d;\n    res = (BN_ULONG *)(((PTR_SIZE_INT) res & ~mask) |\n                       ((PTR_SIZE_INT) r_d & mask));\n    nist_cp_bn(r_d, res, BN_NIST_224_TOP);\n    r->top = BN_NIST_224_TOP;\n    bn_correct_top(r);\n\n    return 1;\n}\n\n#define nist_set_256(to, from, a1, a2, a3, a4, a5, a6, a7, a8) \\\n        { \\\n        bn_cp_32(to, 0, from, (a8) - 8) \\\n        bn_cp_32(to, 1, from, (a7) - 8) \\\n        bn_cp_32(to, 2, from, (a6) - 8) \\\n        bn_cp_32(to, 3, from, (a5) - 8) \\\n        bn_cp_32(to, 4, from, (a4) - 8) \\\n        bn_cp_32(to, 5, from, (a3) - 8) \\\n        bn_cp_32(to, 6, from, (a2) - 8) \\\n        bn_cp_32(to, 7, from, (a1) - 8) \\\n        }\n\nint BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,\n                    BN_CTX *ctx)\n{\n    int i, top = a->top;\n    int carry = 0;\n    register BN_ULONG *a_d = a->d, *r_d;\n    union {\n        BN_ULONG bn[BN_NIST_256_TOP];\n        unsigned int ui[BN_NIST_256_TOP * sizeof(BN_ULONG) /\n                        sizeof(unsigned int)];\n    } buf;\n    BN_ULONG c_d[BN_NIST_256_TOP], *res;\n    PTR_SIZE_INT mask;\n    union {\n        bn_addsub_f f;\n        PTR_SIZE_INT p;\n    } u;\n    static const BIGNUM _bignum_nist_p_256_sqr = {\n        (BN_ULONG *)_nist_p_256_sqr,\n        OSSL_NELEM(_nist_p_256_sqr),\n        OSSL_NELEM(_nist_p_256_sqr),\n        0, BN_FLG_STATIC_DATA\n    };\n\n    field = &_bignum_nist_p_256; /* just to make sure */\n\n    if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_256_sqr) >= 0)\n        return BN_nnmod(r, a, field, ctx);\n\n    i = BN_ucmp(field, a);\n    if (i == 0) {\n        BN_zero(r);\n        return 1;\n    } else if (i > 0)\n        return (r == a) ? 1 : (BN_copy(r, a) != NULL);\n\n    if (r != a) {\n        if (!bn_wexpand(r, BN_NIST_256_TOP))\n            return 0;\n        r_d = r->d;\n        nist_cp_bn(r_d, a_d, BN_NIST_256_TOP);\n    } else\n        r_d = a_d;\n\n    nist_cp_bn_0(buf.bn, a_d + BN_NIST_256_TOP, top - BN_NIST_256_TOP,\n                 BN_NIST_256_TOP);\n\n#if defined(NIST_INT64)\n    {\n        NIST_INT64 acc;         /* accumulator */\n        unsigned int *rp = (unsigned int *)r_d;\n        const unsigned int *bp = (const unsigned int *)buf.ui;\n\n        acc = rp[0];\n        acc += bp[8 - 8];\n        acc += bp[9 - 8];\n        acc -= bp[11 - 8];\n        acc -= bp[12 - 8];\n        acc -= bp[13 - 8];\n        acc -= bp[14 - 8];\n        rp[0] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[1];\n        acc += bp[9 - 8];\n        acc += bp[10 - 8];\n        acc -= bp[12 - 8];\n        acc -= bp[13 - 8];\n        acc -= bp[14 - 8];\n        acc -= bp[15 - 8];\n        rp[1] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[2];\n        acc += bp[10 - 8];\n        acc += bp[11 - 8];\n        acc -= bp[13 - 8];\n        acc -= bp[14 - 8];\n        acc -= bp[15 - 8];\n        rp[2] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[3];\n        acc += bp[11 - 8];\n        acc += bp[11 - 8];\n        acc += bp[12 - 8];\n        acc += bp[12 - 8];\n        acc += bp[13 - 8];\n        acc -= bp[15 - 8];\n        acc -= bp[8 - 8];\n        acc -= bp[9 - 8];\n        rp[3] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[4];\n        acc += bp[12 - 8];\n        acc += bp[12 - 8];\n        acc += bp[13 - 8];\n        acc += bp[13 - 8];\n        acc += bp[14 - 8];\n        acc -= bp[9 - 8];\n        acc -= bp[10 - 8];\n        rp[4] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[5];\n        acc += bp[13 - 8];\n        acc += bp[13 - 8];\n        acc += bp[14 - 8];\n        acc += bp[14 - 8];\n        acc += bp[15 - 8];\n        acc -= bp[10 - 8];\n        acc -= bp[11 - 8];\n        rp[5] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[6];\n        acc += bp[14 - 8];\n        acc += bp[14 - 8];\n        acc += bp[15 - 8];\n        acc += bp[15 - 8];\n        acc += bp[14 - 8];\n        acc += bp[13 - 8];\n        acc -= bp[8 - 8];\n        acc -= bp[9 - 8];\n        rp[6] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[7];\n        acc += bp[15 - 8];\n        acc += bp[15 - 8];\n        acc += bp[15 - 8];\n        acc += bp[8 - 8];\n        acc -= bp[10 - 8];\n        acc -= bp[11 - 8];\n        acc -= bp[12 - 8];\n        acc -= bp[13 - 8];\n        rp[7] = (unsigned int)acc;\n\n        carry = (int)(acc >> 32);\n    }\n#else\n    {\n        BN_ULONG t_d[BN_NIST_256_TOP];\n\n        /*\n         * S1\n         */\n        nist_set_256(t_d, buf.bn, 15, 14, 13, 12, 11, 0, 0, 0);\n        /*\n         * S2\n         */\n        nist_set_256(c_d, buf.bn, 0, 15, 14, 13, 12, 0, 0, 0);\n        carry = (int)bn_add_words(t_d, t_d, c_d, BN_NIST_256_TOP);\n        /* left shift */\n        {\n            register BN_ULONG *ap, t, c;\n            ap = t_d;\n            c = 0;\n            for (i = BN_NIST_256_TOP; i != 0; --i) {\n                t = *ap;\n                *(ap++) = ((t << 1) | c) & BN_MASK2;\n                c = (t & BN_TBIT) ? 1 : 0;\n            }\n            carry <<= 1;\n            carry |= c;\n        }\n        carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n        /*\n         * S3\n         */\n        nist_set_256(t_d, buf.bn, 15, 14, 0, 0, 0, 10, 9, 8);\n        carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n        /*\n         * S4\n         */\n        nist_set_256(t_d, buf.bn, 8, 13, 15, 14, 13, 11, 10, 9);\n        carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n        /*\n         * D1\n         */\n        nist_set_256(t_d, buf.bn, 10, 8, 0, 0, 0, 13, 12, 11);\n        carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n        /*\n         * D2\n         */\n        nist_set_256(t_d, buf.bn, 11, 9, 0, 0, 15, 14, 13, 12);\n        carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n        /*\n         * D3\n         */\n        nist_set_256(t_d, buf.bn, 12, 0, 10, 9, 8, 15, 14, 13);\n        carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n        /*\n         * D4\n         */\n        nist_set_256(t_d, buf.bn, 13, 0, 11, 10, 9, 0, 15, 14);\n        carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_256_TOP);\n\n    }\n#endif\n    /* see BN_nist_mod_224 for explanation */\n    u.f = bn_sub_words;\n    if (carry > 0)\n        carry =\n            (int)bn_sub_words(r_d, r_d, _nist_p_256[carry - 1],\n                              BN_NIST_256_TOP);\n    else if (carry < 0) {\n        carry =\n            (int)bn_add_words(r_d, r_d, _nist_p_256[-carry - 1],\n                              BN_NIST_256_TOP);\n        mask = 0 - (PTR_SIZE_INT) carry;\n        u.p = ((PTR_SIZE_INT) bn_sub_words & mask) |\n            ((PTR_SIZE_INT) bn_add_words & ~mask);\n    } else\n        carry = 1;\n\n    mask =\n        0 - (PTR_SIZE_INT) (*u.f) (c_d, r_d, _nist_p_256[0], BN_NIST_256_TOP);\n    mask &= 0 - (PTR_SIZE_INT) carry;\n    res = c_d;\n    res = (BN_ULONG *)(((PTR_SIZE_INT) res & ~mask) |\n                       ((PTR_SIZE_INT) r_d & mask));\n    nist_cp_bn(r_d, res, BN_NIST_256_TOP);\n    r->top = BN_NIST_256_TOP;\n    bn_correct_top(r);\n\n    return 1;\n}\n\n#define nist_set_384(to,from,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \\\n        { \\\n        bn_cp_32(to, 0, from,  (a12) - 12) \\\n        bn_cp_32(to, 1, from,  (a11) - 12) \\\n        bn_cp_32(to, 2, from,  (a10) - 12) \\\n        bn_cp_32(to, 3, from,  (a9) - 12)  \\\n        bn_cp_32(to, 4, from,  (a8) - 12)  \\\n        bn_cp_32(to, 5, from,  (a7) - 12)  \\\n        bn_cp_32(to, 6, from,  (a6) - 12)  \\\n        bn_cp_32(to, 7, from,  (a5) - 12)  \\\n        bn_cp_32(to, 8, from,  (a4) - 12)  \\\n        bn_cp_32(to, 9, from,  (a3) - 12)  \\\n        bn_cp_32(to, 10, from, (a2) - 12)  \\\n        bn_cp_32(to, 11, from, (a1) - 12)  \\\n        }\n\nint BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,\n                    BN_CTX *ctx)\n{\n    int i, top = a->top;\n    int carry = 0;\n    register BN_ULONG *r_d, *a_d = a->d;\n    union {\n        BN_ULONG bn[BN_NIST_384_TOP];\n        unsigned int ui[BN_NIST_384_TOP * sizeof(BN_ULONG) /\n                        sizeof(unsigned int)];\n    } buf;\n    BN_ULONG c_d[BN_NIST_384_TOP], *res;\n    PTR_SIZE_INT mask;\n    union {\n        bn_addsub_f f;\n        PTR_SIZE_INT p;\n    } u;\n    static const BIGNUM _bignum_nist_p_384_sqr = {\n        (BN_ULONG *)_nist_p_384_sqr,\n        OSSL_NELEM(_nist_p_384_sqr),\n        OSSL_NELEM(_nist_p_384_sqr),\n        0, BN_FLG_STATIC_DATA\n    };\n\n    field = &_bignum_nist_p_384; /* just to make sure */\n\n    if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_384_sqr) >= 0)\n        return BN_nnmod(r, a, field, ctx);\n\n    i = BN_ucmp(field, a);\n    if (i == 0) {\n        BN_zero(r);\n        return 1;\n    } else if (i > 0)\n        return (r == a) ? 1 : (BN_copy(r, a) != NULL);\n\n    if (r != a) {\n        if (!bn_wexpand(r, BN_NIST_384_TOP))\n            return 0;\n        r_d = r->d;\n        nist_cp_bn(r_d, a_d, BN_NIST_384_TOP);\n    } else\n        r_d = a_d;\n\n    nist_cp_bn_0(buf.bn, a_d + BN_NIST_384_TOP, top - BN_NIST_384_TOP,\n                 BN_NIST_384_TOP);\n\n#if defined(NIST_INT64)\n    {\n        NIST_INT64 acc;         /* accumulator */\n        unsigned int *rp = (unsigned int *)r_d;\n        const unsigned int *bp = (const unsigned int *)buf.ui;\n\n        acc = rp[0];\n        acc += bp[12 - 12];\n        acc += bp[21 - 12];\n        acc += bp[20 - 12];\n        acc -= bp[23 - 12];\n        rp[0] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[1];\n        acc += bp[13 - 12];\n        acc += bp[22 - 12];\n        acc += bp[23 - 12];\n        acc -= bp[12 - 12];\n        acc -= bp[20 - 12];\n        rp[1] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[2];\n        acc += bp[14 - 12];\n        acc += bp[23 - 12];\n        acc -= bp[13 - 12];\n        acc -= bp[21 - 12];\n        rp[2] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[3];\n        acc += bp[15 - 12];\n        acc += bp[12 - 12];\n        acc += bp[20 - 12];\n        acc += bp[21 - 12];\n        acc -= bp[14 - 12];\n        acc -= bp[22 - 12];\n        acc -= bp[23 - 12];\n        rp[3] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[4];\n        acc += bp[21 - 12];\n        acc += bp[21 - 12];\n        acc += bp[16 - 12];\n        acc += bp[13 - 12];\n        acc += bp[12 - 12];\n        acc += bp[20 - 12];\n        acc += bp[22 - 12];\n        acc -= bp[15 - 12];\n        acc -= bp[23 - 12];\n        acc -= bp[23 - 12];\n        rp[4] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[5];\n        acc += bp[22 - 12];\n        acc += bp[22 - 12];\n        acc += bp[17 - 12];\n        acc += bp[14 - 12];\n        acc += bp[13 - 12];\n        acc += bp[21 - 12];\n        acc += bp[23 - 12];\n        acc -= bp[16 - 12];\n        rp[5] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[6];\n        acc += bp[23 - 12];\n        acc += bp[23 - 12];\n        acc += bp[18 - 12];\n        acc += bp[15 - 12];\n        acc += bp[14 - 12];\n        acc += bp[22 - 12];\n        acc -= bp[17 - 12];\n        rp[6] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[7];\n        acc += bp[19 - 12];\n        acc += bp[16 - 12];\n        acc += bp[15 - 12];\n        acc += bp[23 - 12];\n        acc -= bp[18 - 12];\n        rp[7] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[8];\n        acc += bp[20 - 12];\n        acc += bp[17 - 12];\n        acc += bp[16 - 12];\n        acc -= bp[19 - 12];\n        rp[8] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[9];\n        acc += bp[21 - 12];\n        acc += bp[18 - 12];\n        acc += bp[17 - 12];\n        acc -= bp[20 - 12];\n        rp[9] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[10];\n        acc += bp[22 - 12];\n        acc += bp[19 - 12];\n        acc += bp[18 - 12];\n        acc -= bp[21 - 12];\n        rp[10] = (unsigned int)acc;\n        acc >>= 32;\n\n        acc += rp[11];\n        acc += bp[23 - 12];\n        acc += bp[20 - 12];\n        acc += bp[19 - 12];\n        acc -= bp[22 - 12];\n        rp[11] = (unsigned int)acc;\n\n        carry = (int)(acc >> 32);\n    }\n#else\n    {\n        BN_ULONG t_d[BN_NIST_384_TOP];\n\n        /*\n         * S1\n         */\n        nist_set_256(t_d, buf.bn, 0, 0, 0, 0, 0, 23 - 4, 22 - 4, 21 - 4);\n        /* left shift */\n        {\n            register BN_ULONG *ap, t, c;\n            ap = t_d;\n            c = 0;\n            for (i = 3; i != 0; --i) {\n                t = *ap;\n                *(ap++) = ((t << 1) | c) & BN_MASK2;\n                c = (t & BN_TBIT) ? 1 : 0;\n            }\n            *ap = c;\n        }\n        carry =\n            (int)bn_add_words(r_d + (128 / BN_BITS2), r_d + (128 / BN_BITS2),\n                              t_d, BN_NIST_256_TOP);\n        /*\n         * S2\n         */\n        carry += (int)bn_add_words(r_d, r_d, buf.bn, BN_NIST_384_TOP);\n        /*\n         * S3\n         */\n        nist_set_384(t_d, buf.bn, 20, 19, 18, 17, 16, 15, 14, 13, 12, 23, 22,\n                     21);\n        carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP);\n        /*\n         * S4\n         */\n        nist_set_384(t_d, buf.bn, 19, 18, 17, 16, 15, 14, 13, 12, 20, 0, 23,\n                     0);\n        carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP);\n        /*\n         * S5\n         */\n        nist_set_384(t_d, buf.bn, 0, 0, 0, 0, 23, 22, 21, 20, 0, 0, 0, 0);\n        carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP);\n        /*\n         * S6\n         */\n        nist_set_384(t_d, buf.bn, 0, 0, 0, 0, 0, 0, 23, 22, 21, 0, 0, 20);\n        carry += (int)bn_add_words(r_d, r_d, t_d, BN_NIST_384_TOP);\n        /*\n         * D1\n         */\n        nist_set_384(t_d, buf.bn, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12,\n                     23);\n        carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP);\n        /*\n         * D2\n         */\n        nist_set_384(t_d, buf.bn, 0, 0, 0, 0, 0, 0, 0, 23, 22, 21, 20, 0);\n        carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP);\n        /*\n         * D3\n         */\n        nist_set_384(t_d, buf.bn, 0, 0, 0, 0, 0, 0, 0, 23, 23, 0, 0, 0);\n        carry -= (int)bn_sub_words(r_d, r_d, t_d, BN_NIST_384_TOP);\n\n    }\n#endif\n    /* see BN_nist_mod_224 for explanation */\n    u.f = bn_sub_words;\n    if (carry > 0)\n        carry =\n            (int)bn_sub_words(r_d, r_d, _nist_p_384[carry - 1],\n                              BN_NIST_384_TOP);\n    else if (carry < 0) {\n        carry =\n            (int)bn_add_words(r_d, r_d, _nist_p_384[-carry - 1],\n                              BN_NIST_384_TOP);\n        mask = 0 - (PTR_SIZE_INT) carry;\n        u.p = ((PTR_SIZE_INT) bn_sub_words & mask) |\n            ((PTR_SIZE_INT) bn_add_words & ~mask);\n    } else\n        carry = 1;\n\n    mask =\n        0 - (PTR_SIZE_INT) (*u.f) (c_d, r_d, _nist_p_384[0], BN_NIST_384_TOP);\n    mask &= 0 - (PTR_SIZE_INT) carry;\n    res = c_d;\n    res = (BN_ULONG *)(((PTR_SIZE_INT) res & ~mask) |\n                       ((PTR_SIZE_INT) r_d & mask));\n    nist_cp_bn(r_d, res, BN_NIST_384_TOP);\n    r->top = BN_NIST_384_TOP;\n    bn_correct_top(r);\n\n    return 1;\n}\n\n#define BN_NIST_521_RSHIFT      (521%BN_BITS2)\n#define BN_NIST_521_LSHIFT      (BN_BITS2-BN_NIST_521_RSHIFT)\n#define BN_NIST_521_TOP_MASK    ((BN_ULONG)BN_MASK2>>BN_NIST_521_LSHIFT)\n\nint BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,\n                    BN_CTX *ctx)\n{\n    int top = a->top, i;\n    BN_ULONG *r_d, *a_d = a->d, t_d[BN_NIST_521_TOP], val, tmp, *res;\n    PTR_SIZE_INT mask;\n    static const BIGNUM _bignum_nist_p_521_sqr = {\n        (BN_ULONG *)_nist_p_521_sqr,\n        OSSL_NELEM(_nist_p_521_sqr),\n        OSSL_NELEM(_nist_p_521_sqr),\n        0, BN_FLG_STATIC_DATA\n    };\n\n    field = &_bignum_nist_p_521; /* just to make sure */\n\n    if (BN_is_negative(a) || BN_ucmp(a, &_bignum_nist_p_521_sqr) >= 0)\n        return BN_nnmod(r, a, field, ctx);\n\n    i = BN_ucmp(field, a);\n    if (i == 0) {\n        BN_zero(r);\n        return 1;\n    } else if (i > 0)\n        return (r == a) ? 1 : (BN_copy(r, a) != NULL);\n\n    if (r != a) {\n        if (!bn_wexpand(r, BN_NIST_521_TOP))\n            return 0;\n        r_d = r->d;\n        nist_cp_bn(r_d, a_d, BN_NIST_521_TOP);\n    } else\n        r_d = a_d;\n\n    /* upper 521 bits, copy ... */\n    nist_cp_bn_0(t_d, a_d + (BN_NIST_521_TOP - 1),\n                 top - (BN_NIST_521_TOP - 1), BN_NIST_521_TOP);\n    /* ... and right shift */\n    for (val = t_d[0], i = 0; i < BN_NIST_521_TOP - 1; i++) {\n#if 0\n        /*\n         * MSC ARM compiler [version 2013, presumably even earlier,\n         * much earlier] miscompiles this code, but not one in\n         * #else section. See RT#3541.\n         */\n        tmp = val >> BN_NIST_521_RSHIFT;\n        val = t_d[i + 1];\n        t_d[i] = (tmp | val << BN_NIST_521_LSHIFT) & BN_MASK2;\n#else\n        t_d[i] = (val >> BN_NIST_521_RSHIFT |\n                  (tmp = t_d[i + 1]) << BN_NIST_521_LSHIFT) & BN_MASK2;\n        val = tmp;\n#endif\n    }\n    t_d[i] = val >> BN_NIST_521_RSHIFT;\n    /* lower 521 bits */\n    r_d[i] &= BN_NIST_521_TOP_MASK;\n\n    bn_add_words(r_d, r_d, t_d, BN_NIST_521_TOP);\n    mask =\n        0 - (PTR_SIZE_INT) bn_sub_words(t_d, r_d, _nist_p_521,\n                                        BN_NIST_521_TOP);\n    res = t_d;\n    res = (BN_ULONG *)(((PTR_SIZE_INT) res & ~mask) |\n                       ((PTR_SIZE_INT) r_d & mask));\n    nist_cp_bn(r_d, res, BN_NIST_521_TOP);\n    r->top = BN_NIST_521_TOP;\n    bn_correct_top(r);\n\n    return 1;\n}\n\nint (*BN_nist_mod_func(const BIGNUM *p)) (BIGNUM *r, const BIGNUM *a,\n                                          const BIGNUM *field, BN_CTX *ctx) {\n    if (BN_ucmp(&_bignum_nist_p_192, p) == 0)\n        return BN_nist_mod_192;\n    if (BN_ucmp(&_bignum_nist_p_224, p) == 0)\n        return BN_nist_mod_224;\n    if (BN_ucmp(&_bignum_nist_p_256, p) == 0)\n        return BN_nist_mod_256;\n    if (BN_ucmp(&_bignum_nist_p_384, p) == 0)\n        return BN_nist_mod_384;\n    if (BN_ucmp(&_bignum_nist_p_521, p) == 0)\n        return BN_nist_mod_521;\n    return 0;\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_rand.c",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <stdio.h>\n#include <time.h>\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n#include <openssl/rand.h>\n#include <openssl/sha.h>\n\ntypedef enum bnrand_flag_e {\n    NORMAL, TESTING, PRIVATE\n} BNRAND_FLAG;\n\nstatic int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom)\n{\n    unsigned char *buf = NULL;\n    int b, ret = 0, bit, bytes, mask;\n\n    if (bits == 0) {\n        if (top != BN_RAND_TOP_ANY || bottom != BN_RAND_BOTTOM_ANY)\n            goto toosmall;\n        BN_zero(rnd);\n        return 1;\n    }\n    if (bits < 0 || (bits == 1 && top > 0))\n        goto toosmall;\n\n    bytes = (bits + 7) / 8;\n    bit = (bits - 1) % 8;\n    mask = 0xff << (bit + 1);\n\n    buf = OPENSSL_malloc(bytes);\n    if (buf == NULL) {\n        BNerr(BN_F_BNRAND, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    /* make a random number and set the top and bottom bits */\n    b = flag == NORMAL ? RAND_bytes(buf, bytes) : RAND_priv_bytes(buf, bytes);\n    if (b <= 0)\n        goto err;\n\n    if (flag == TESTING) {\n        /*\n         * generate patterns that are more likely to trigger BN library bugs\n         */\n        int i;\n        unsigned char c;\n\n        for (i = 0; i < bytes; i++) {\n            if (RAND_bytes(&c, 1) <= 0)\n                goto err;\n            if (c >= 128 && i > 0)\n                buf[i] = buf[i - 1];\n            else if (c < 42)\n                buf[i] = 0;\n            else if (c < 84)\n                buf[i] = 255;\n        }\n    }\n\n    if (top >= 0) {\n        if (top) {\n            if (bit == 0) {\n                buf[0] = 1;\n                buf[1] |= 0x80;\n            } else {\n                buf[0] |= (3 << (bit - 1));\n            }\n        } else {\n            buf[0] |= (1 << bit);\n        }\n    }\n    buf[0] &= ~mask;\n    if (bottom)                 /* set bottom bit if requested */\n        buf[bytes - 1] |= 1;\n    if (!BN_bin2bn(buf, bytes, rnd))\n        goto err;\n    ret = 1;\n err:\n    OPENSSL_clear_free(buf, bytes);\n    bn_check_top(rnd);\n    return ret;\n\ntoosmall:\n    BNerr(BN_F_BNRAND, BN_R_BITS_TOO_SMALL);\n    return 0;\n}\n\nint BN_rand(BIGNUM *rnd, int bits, int top, int bottom)\n{\n    return bnrand(NORMAL, rnd, bits, top, bottom);\n}\n\nint BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)\n{\n    return bnrand(TESTING, rnd, bits, top, bottom);\n}\n\nint BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom)\n{\n    return bnrand(PRIVATE, rnd, bits, top, bottom);\n}\n\n/* random number r:  0 <= r < range */\nstatic int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range)\n{\n    int n;\n    int count = 100;\n\n    if (range->neg || BN_is_zero(range)) {\n        BNerr(BN_F_BNRAND_RANGE, BN_R_INVALID_RANGE);\n        return 0;\n    }\n\n    n = BN_num_bits(range);     /* n > 0 */\n\n    /* BN_is_bit_set(range, n - 1) always holds */\n\n    if (n == 1)\n        BN_zero(r);\n    else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3)) {\n        /*\n         * range = 100..._2, so 3*range (= 11..._2) is exactly one bit longer\n         * than range\n         */\n        do {\n            if (!bnrand(flag, r, n + 1, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))\n                return 0;\n\n            /*\n             * If r < 3*range, use r := r MOD range (which is either r, r -\n             * range, or r - 2*range). Otherwise, iterate once more. Since\n             * 3*range = 11..._2, each iteration succeeds with probability >=\n             * .75.\n             */\n            if (BN_cmp(r, range) >= 0) {\n                if (!BN_sub(r, r, range))\n                    return 0;\n                if (BN_cmp(r, range) >= 0)\n                    if (!BN_sub(r, r, range))\n                        return 0;\n            }\n\n            if (!--count) {\n                BNerr(BN_F_BNRAND_RANGE, BN_R_TOO_MANY_ITERATIONS);\n                return 0;\n            }\n\n        }\n        while (BN_cmp(r, range) >= 0);\n    } else {\n        do {\n            /* range = 11..._2  or  range = 101..._2 */\n            if (!bnrand(flag, r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))\n                return 0;\n\n            if (!--count) {\n                BNerr(BN_F_BNRAND_RANGE, BN_R_TOO_MANY_ITERATIONS);\n                return 0;\n            }\n        }\n        while (BN_cmp(r, range) >= 0);\n    }\n\n    bn_check_top(r);\n    return 1;\n}\n\nint BN_rand_range(BIGNUM *r, const BIGNUM *range)\n{\n    return bnrand_range(NORMAL, r, range);\n}\n\nint BN_priv_rand_range(BIGNUM *r, const BIGNUM *range)\n{\n    return bnrand_range(PRIVATE, r, range);\n}\n\nint BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)\n{\n    return BN_rand(rnd, bits, top, bottom);\n}\n\nint BN_pseudo_rand_range(BIGNUM *r, const BIGNUM *range)\n{\n    return BN_rand_range(r, range);\n}\n\n/*\n * BN_generate_dsa_nonce generates a random number 0 <= out < range. Unlike\n * BN_rand_range, it also includes the contents of |priv| and |message| in\n * the generation so that an RNG failure isn't fatal as long as |priv|\n * remains secret. This is intended for use in DSA and ECDSA where an RNG\n * weakness leads directly to private key exposure unless this function is\n * used.\n */\nint BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,\n                          const BIGNUM *priv, const unsigned char *message,\n                          size_t message_len, BN_CTX *ctx)\n{\n    SHA512_CTX sha;\n    /*\n     * We use 512 bits of random data per iteration to ensure that we have at\n     * least |range| bits of randomness.\n     */\n    unsigned char random_bytes[64];\n    unsigned char digest[SHA512_DIGEST_LENGTH];\n    unsigned done, todo;\n    /* We generate |range|+8 bytes of random output. */\n    const unsigned num_k_bytes = BN_num_bytes(range) + 8;\n    unsigned char private_bytes[96];\n    unsigned char *k_bytes;\n    int ret = 0;\n\n    k_bytes = OPENSSL_malloc(num_k_bytes);\n    if (k_bytes == NULL)\n        goto err;\n\n    /* We copy |priv| into a local buffer to avoid exposing its length. */\n    if (BN_bn2binpad(priv, private_bytes, sizeof(private_bytes)) < 0) {\n        /*\n         * No reasonable DSA or ECDSA key should have a private key this\n         * large and we don't handle this case in order to avoid leaking the\n         * length of the private key.\n         */\n        BNerr(BN_F_BN_GENERATE_DSA_NONCE, BN_R_PRIVATE_KEY_TOO_LARGE);\n        goto err;\n    }\n\n    for (done = 0; done < num_k_bytes;) {\n        if (RAND_priv_bytes(random_bytes, sizeof(random_bytes)) != 1)\n            goto err;\n        SHA512_Init(&sha);\n        SHA512_Update(&sha, &done, sizeof(done));\n        SHA512_Update(&sha, private_bytes, sizeof(private_bytes));\n        SHA512_Update(&sha, message, message_len);\n        SHA512_Update(&sha, random_bytes, sizeof(random_bytes));\n        SHA512_Final(digest, &sha);\n\n        todo = num_k_bytes - done;\n        if (todo > SHA512_DIGEST_LENGTH)\n            todo = SHA512_DIGEST_LENGTH;\n        memcpy(k_bytes + done, digest, todo);\n        done += todo;\n    }\n\n    if (!BN_bin2bn(k_bytes, num_k_bytes, out))\n        goto err;\n    if (BN_mod(out, out, range, ctx) != 1)\n        goto err;\n    ret = 1;\n\n err:\n    OPENSSL_free(k_bytes);\n    OPENSSL_cleanse(private_bytes, sizeof(private_bytes));\n    return ret;\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_recp.c",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\nvoid BN_RECP_CTX_init(BN_RECP_CTX *recp)\n{\n    memset(recp, 0, sizeof(*recp));\n    bn_init(&(recp->N));\n    bn_init(&(recp->Nr));\n}\n\nBN_RECP_CTX *BN_RECP_CTX_new(void)\n{\n    BN_RECP_CTX *ret;\n\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_RECP_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n\n    bn_init(&(ret->N));\n    bn_init(&(ret->Nr));\n    ret->flags = BN_FLG_MALLOCED;\n    return ret;\n}\n\nvoid BN_RECP_CTX_free(BN_RECP_CTX *recp)\n{\n    if (recp == NULL)\n        return;\n    BN_free(&recp->N);\n    BN_free(&recp->Nr);\n    if (recp->flags & BN_FLG_MALLOCED)\n        OPENSSL_free(recp);\n}\n\nint BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)\n{\n    if (!BN_copy(&(recp->N), d))\n        return 0;\n    BN_zero(&(recp->Nr));\n    recp->num_bits = BN_num_bits(d);\n    recp->shift = 0;\n    return 1;\n}\n\nint BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,\n                          BN_RECP_CTX *recp, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *a;\n    const BIGNUM *ca;\n\n    BN_CTX_start(ctx);\n    if ((a = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (y != NULL) {\n        if (x == y) {\n            if (!BN_sqr(a, x, ctx))\n                goto err;\n        } else {\n            if (!BN_mul(a, x, y, ctx))\n                goto err;\n        }\n        ca = a;\n    } else\n        ca = x;                 /* Just do the mod */\n\n    ret = BN_div_recp(NULL, r, ca, recp, ctx);\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(r);\n    return ret;\n}\n\nint BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                BN_RECP_CTX *recp, BN_CTX *ctx)\n{\n    int i, j, ret = 0;\n    BIGNUM *a, *b, *d, *r;\n\n    BN_CTX_start(ctx);\n    d = (dv != NULL) ? dv : BN_CTX_get(ctx);\n    r = (rem != NULL) ? rem : BN_CTX_get(ctx);\n    a = BN_CTX_get(ctx);\n    b = BN_CTX_get(ctx);\n    if (b == NULL)\n        goto err;\n\n    if (BN_ucmp(m, &(recp->N)) < 0) {\n        BN_zero(d);\n        if (!BN_copy(r, m)) {\n            BN_CTX_end(ctx);\n            return 0;\n        }\n        BN_CTX_end(ctx);\n        return 1;\n    }\n\n    /*\n     * We want the remainder Given input of ABCDEF / ab we need multiply\n     * ABCDEF by 3 digests of the reciprocal of ab\n     */\n\n    /* i := max(BN_num_bits(m), 2*BN_num_bits(N)) */\n    i = BN_num_bits(m);\n    j = recp->num_bits << 1;\n    if (j > i)\n        i = j;\n\n    /* Nr := round(2^i / N) */\n    if (i != recp->shift)\n        recp->shift = BN_reciprocal(&(recp->Nr), &(recp->N), i, ctx);\n    /* BN_reciprocal could have returned -1 for an error */\n    if (recp->shift == -1)\n        goto err;\n\n    /*-\n     * d := |round(round(m / 2^BN_num_bits(N)) * recp->Nr / 2^(i - BN_num_bits(N)))|\n     *    = |round(round(m / 2^BN_num_bits(N)) * round(2^i / N) / 2^(i - BN_num_bits(N)))|\n     *   <= |(m / 2^BN_num_bits(N)) * (2^i / N) * (2^BN_num_bits(N) / 2^i)|\n     *    = |m/N|\n     */\n    if (!BN_rshift(a, m, recp->num_bits))\n        goto err;\n    if (!BN_mul(b, a, &(recp->Nr), ctx))\n        goto err;\n    if (!BN_rshift(d, b, i - recp->num_bits))\n        goto err;\n    d->neg = 0;\n\n    if (!BN_mul(b, &(recp->N), d, ctx))\n        goto err;\n    if (!BN_usub(r, m, b))\n        goto err;\n    r->neg = 0;\n\n    j = 0;\n    while (BN_ucmp(r, &(recp->N)) >= 0) {\n        if (j++ > 2) {\n            BNerr(BN_F_BN_DIV_RECP, BN_R_BAD_RECIPROCAL);\n            goto err;\n        }\n        if (!BN_usub(r, r, &(recp->N)))\n            goto err;\n        if (!BN_add_word(d, 1))\n            goto err;\n    }\n\n    r->neg = BN_is_zero(r) ? 0 : m->neg;\n    d->neg = m->neg ^ recp->N.neg;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(dv);\n    bn_check_top(rem);\n    return ret;\n}\n\n/*\n * len is the expected size of the result We actually calculate with an extra\n * word of precision, so we can do faster division if the remainder is not\n * required.\n */\n/* r := 2^len / m */\nint BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx)\n{\n    int ret = -1;\n    BIGNUM *t;\n\n    BN_CTX_start(ctx);\n    if ((t = BN_CTX_get(ctx)) == NULL)\n        goto err;\n\n    if (!BN_set_bit(t, len))\n        goto err;\n\n    if (!BN_div(r, NULL, t, m, ctx))\n        goto err;\n\n    ret = len;\n err:\n    bn_check_top(r);\n    BN_CTX_end(ctx);\n    return ret;\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_shift.c",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <assert.h>\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\nint BN_lshift1(BIGNUM *r, const BIGNUM *a)\n{\n    register BN_ULONG *ap, *rp, t, c;\n    int i;\n\n    bn_check_top(r);\n    bn_check_top(a);\n\n    if (r != a) {\n        r->neg = a->neg;\n        if (bn_wexpand(r, a->top + 1) == NULL)\n            return 0;\n        r->top = a->top;\n    } else {\n        if (bn_wexpand(r, a->top + 1) == NULL)\n            return 0;\n    }\n    ap = a->d;\n    rp = r->d;\n    c = 0;\n    for (i = 0; i < a->top; i++) {\n        t = *(ap++);\n        *(rp++) = ((t << 1) | c) & BN_MASK2;\n        c = t >> (BN_BITS2 - 1);\n    }\n    *rp = c;\n    r->top += c;\n    bn_check_top(r);\n    return 1;\n}\n\nint BN_rshift1(BIGNUM *r, const BIGNUM *a)\n{\n    BN_ULONG *ap, *rp, t, c;\n    int i;\n\n    bn_check_top(r);\n    bn_check_top(a);\n\n    if (BN_is_zero(a)) {\n        BN_zero(r);\n        return 1;\n    }\n    i = a->top;\n    ap = a->d;\n    if (a != r) {\n        if (bn_wexpand(r, i) == NULL)\n            return 0;\n        r->neg = a->neg;\n    }\n    rp = r->d;\n    r->top = i;\n    t = ap[--i];\n    rp[i] = t >> 1;\n    c = t << (BN_BITS2 - 1);\n    r->top -= (t == 1);\n    while (i > 0) {\n        t = ap[--i];\n        rp[i] = ((t >> 1) & BN_MASK2) | c;\n        c = t << (BN_BITS2 - 1);\n    }\n    if (!r->top)\n        r->neg = 0; /* don't allow negative zero */\n    bn_check_top(r);\n    return 1;\n}\n\nint BN_lshift(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int ret;\n\n    if (n < 0) {\n        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);\n        return 0;\n    }\n\n    ret = bn_lshift_fixed_top(r, a, n);\n\n    bn_correct_top(r);\n    bn_check_top(r);\n\n    return ret;\n}\n\n/*\n * In respect to shift factor the execution time is invariant of\n * |n % BN_BITS2|, but not |n / BN_BITS2|. Or in other words pre-condition\n * for constant-time-ness is |n < BN_BITS2| or |n / BN_BITS2| being\n * non-secret.\n */\nint bn_lshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int i, nw;\n    unsigned int lb, rb;\n    BN_ULONG *t, *f;\n    BN_ULONG l, m, rmask = 0;\n\n    assert(n >= 0);\n\n    bn_check_top(r);\n    bn_check_top(a);\n\n    nw = n / BN_BITS2;\n    if (bn_wexpand(r, a->top + nw + 1) == NULL)\n        return 0;\n\n    if (a->top != 0) {\n        lb = (unsigned int)n % BN_BITS2;\n        rb = BN_BITS2 - lb;\n        rb %= BN_BITS2;            /* say no to undefined behaviour */\n        rmask = (BN_ULONG)0 - rb;  /* rmask = 0 - (rb != 0) */\n        rmask |= rmask >> 8;\n        f = &(a->d[0]);\n        t = &(r->d[nw]);\n        l = f[a->top - 1];\n        t[a->top] = (l >> rb) & rmask;\n        for (i = a->top - 1; i > 0; i--) {\n            m = l << lb;\n            l = f[i - 1];\n            t[i] = (m | ((l >> rb) & rmask)) & BN_MASK2;\n        }\n        t[0] = (l << lb) & BN_MASK2;\n    } else {\n        /* shouldn't happen, but formally required */\n        r->d[nw] = 0;\n    }\n    if (nw != 0)\n        memset(r->d, 0, sizeof(*t) * nw);\n\n    r->neg = a->neg;\n    r->top = a->top + nw + 1;\n    r->flags |= BN_FLG_FIXED_TOP;\n\n    return 1;\n}\n\nint BN_rshift(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int ret = 0;\n\n    if (n < 0) {\n        BNerr(BN_F_BN_RSHIFT, BN_R_INVALID_SHIFT);\n        return 0;\n    }\n\n    ret = bn_rshift_fixed_top(r, a, n);\n\n    bn_correct_top(r);\n    bn_check_top(r);\n\n    return ret;\n}\n\n/*\n * In respect to shift factor the execution time is invariant of\n * |n % BN_BITS2|, but not |n / BN_BITS2|. Or in other words pre-condition\n * for constant-time-ness for sufficiently[!] zero-padded inputs is\n * |n < BN_BITS2| or |n / BN_BITS2| being non-secret.\n */\nint bn_rshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int i, top, nw;\n    unsigned int lb, rb;\n    BN_ULONG *t, *f;\n    BN_ULONG l, m, mask;\n\n    bn_check_top(r);\n    bn_check_top(a);\n\n    assert(n >= 0);\n\n    nw = n / BN_BITS2;\n    if (nw >= a->top) {\n        /* shouldn't happen, but formally required */\n        BN_zero(r);\n        return 1;\n    }\n\n    rb = (unsigned int)n % BN_BITS2;\n    lb = BN_BITS2 - rb;\n    lb %= BN_BITS2;            /* say no to undefined behaviour */\n    mask = (BN_ULONG)0 - lb;   /* mask = 0 - (lb != 0) */\n    mask |= mask >> 8;\n    top = a->top - nw;\n    if (r != a && bn_wexpand(r, top) == NULL)\n        return 0;\n\n    t = &(r->d[0]);\n    f = &(a->d[nw]);\n    l = f[0];\n    for (i = 0; i < top - 1; i++) {\n        m = f[i + 1];\n        t[i] = (l >> rb) | ((m << lb) & mask);\n        l = m;\n    }\n    t[i] = l >> rb;\n\n    r->neg = a->neg;\n    r->top = top;\n    r->flags |= BN_FLG_FIXED_TOP;\n\n    return 1;\n}\n"
  },
  {
    "path": "cryptomini/bn/bn_sqr.c",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\n/* r must not be a */\n/*\n * I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96\n */\nint BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n{\n    int ret = bn_sqr_fixed_top(r, a, ctx);\n\n    bn_correct_top(r);\n    bn_check_top(r);\n\n    return ret;\n}\n\nint bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n{\n    int max, al;\n    int ret = 0;\n    BIGNUM *tmp, *rr;\n\n    bn_check_top(a);\n\n    al = a->top;\n    if (al <= 0) {\n        r->top = 0;\n        r->neg = 0;\n        return 1;\n    }\n\n    BN_CTX_start(ctx);\n    rr = (a != r) ? r : BN_CTX_get(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (rr == NULL || tmp == NULL)\n        goto err;\n\n    max = 2 * al;               /* Non-zero (from above) */\n    if (bn_wexpand(rr, max) == NULL)\n        goto err;\n\n    if (al == 4) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[8];\n        bn_sqr_normal(rr->d, a->d, 4, t);\n#else\n        bn_sqr_comba4(rr->d, a->d);\n#endif\n    } else if (al == 8) {\n#ifndef BN_SQR_COMBA\n        BN_ULONG t[16];\n        bn_sqr_normal(rr->d, a->d, 8, t);\n#else\n        bn_sqr_comba8(rr->d, a->d);\n#endif\n    } else {\n#if defined(BN_RECURSION)\n        if (al < BN_SQR_RECURSIVE_SIZE_NORMAL) {\n            BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL * 2];\n            bn_sqr_normal(rr->d, a->d, al, t);\n        } else {\n            int j, k;\n\n            j = BN_num_bits_word((BN_ULONG)al);\n            j = 1 << (j - 1);\n            k = j + j;\n            if (al == j) {\n                if (bn_wexpand(tmp, k * 2) == NULL)\n                    goto err;\n                bn_sqr_recursive(rr->d, a->d, al, tmp->d);\n            } else {\n                if (bn_wexpand(tmp, max) == NULL)\n                    goto err;\n                bn_sqr_normal(rr->d, a->d, al, tmp->d);\n            }\n        }\n#else\n        if (bn_wexpand(tmp, max) == NULL)\n            goto err;\n        bn_sqr_normal(rr->d, a->d, al, tmp->d);\n#endif\n    }\n\n    rr->neg = 0;\n    rr->top = max;\n    rr->flags |= BN_FLG_FIXED_TOP;\n    if (r != rr && BN_copy(r, rr) == NULL)\n        goto err;\n\n    ret = 1;\n err:\n    bn_check_top(rr);\n    bn_check_top(tmp);\n    BN_CTX_end(ctx);\n    return ret;\n}\n\n/* tmp must have 2*n words */\nvoid bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)\n{\n    int i, j, max;\n    const BN_ULONG *ap;\n    BN_ULONG *rp;\n\n    max = n * 2;\n    ap = a;\n    rp = r;\n    rp[0] = rp[max - 1] = 0;\n    rp++;\n    j = n;\n\n    if (--j > 0) {\n        ap++;\n        rp[j] = bn_mul_words(rp, ap, j, ap[-1]);\n        rp += 2;\n    }\n\n    for (i = n - 2; i > 0; i--) {\n        j--;\n        ap++;\n        rp[j] = bn_mul_add_words(rp, ap, j, ap[-1]);\n        rp += 2;\n    }\n\n    bn_add_words(r, r, r, max);\n\n    /* There will not be a carry */\n\n    bn_sqr_words(tmp, a, n);\n\n    bn_add_words(r, r, tmp, max);\n}\n\n#ifdef BN_RECURSION\n/*-\n * r is 2*n words in size,\n * a and b are both n words in size.    (There's not actually a 'b' here ...)\n * n must be a power of 2.\n * We multiply and return the result.\n * t must be 2*n words in size\n * We calculate\n * a[0]*b[0]\n * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])\n * a[1]*b[1]\n */\nvoid bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t)\n{\n    int n = n2 / 2;\n    int zero, c1;\n    BN_ULONG ln, lo, *p;\n\n    if (n2 == 4) {\n# ifndef BN_SQR_COMBA\n        bn_sqr_normal(r, a, 4, t);\n# else\n        bn_sqr_comba4(r, a);\n# endif\n        return;\n    } else if (n2 == 8) {\n# ifndef BN_SQR_COMBA\n        bn_sqr_normal(r, a, 8, t);\n# else\n        bn_sqr_comba8(r, a);\n# endif\n        return;\n    }\n    if (n2 < BN_SQR_RECURSIVE_SIZE_NORMAL) {\n        bn_sqr_normal(r, a, n2, t);\n        return;\n    }\n    /* r=(a[0]-a[1])*(a[1]-a[0]) */\n    c1 = bn_cmp_words(a, &(a[n]), n);\n    zero = 0;\n    if (c1 > 0)\n        bn_sub_words(t, a, &(a[n]), n);\n    else if (c1 < 0)\n        bn_sub_words(t, &(a[n]), a, n);\n    else\n        zero = 1;\n\n    /* The result will always be negative unless it is zero */\n    p = &(t[n2 * 2]);\n\n    if (!zero)\n        bn_sqr_recursive(&(t[n2]), t, n, p);\n    else\n        memset(&t[n2], 0, sizeof(*t) * n2);\n    bn_sqr_recursive(r, a, n, p);\n    bn_sqr_recursive(&(r[n2]), &(a[n]), n, p);\n\n    /*-\n     * t[32] holds (a[0]-a[1])*(a[1]-a[0]), it is negative or zero\n     * r[10] holds (a[0]*b[0])\n     * r[32] holds (b[1]*b[1])\n     */\n\n    c1 = (int)(bn_add_words(t, r, &(r[n2]), n2));\n\n    /* t[32] is negative */\n    c1 -= (int)(bn_sub_words(&(t[n2]), t, &(t[n2]), n2));\n\n    /*-\n     * t[32] holds (a[0]-a[1])*(a[1]-a[0])+(a[0]*a[0])+(a[1]*a[1])\n     * r[10] holds (a[0]*a[0])\n     * r[32] holds (a[1]*a[1])\n     * c1 holds the carry bits\n     */\n    c1 += (int)(bn_add_words(&(r[n]), &(r[n]), &(t[n2]), n2));\n    if (c1) {\n        p = &(r[n + n2]);\n        lo = *p;\n        ln = (lo + c1) & BN_MASK2;\n        *p = ln;\n\n        /*\n         * The overflow will stop before we over write words we should not\n         * overwrite\n         */\n        if (ln < (BN_ULONG)c1) {\n            do {\n                p++;\n                lo = *p;\n                ln = (lo + 1) & BN_MASK2;\n                *p = ln;\n            } while (ln == 0);\n        }\n    }\n}\n#endif\n"
  },
  {
    "path": "cryptomini/bn/bn_word.c",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include \"bn_local.h\"\n\nBN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)\n{\n#ifndef BN_LLONG\n    BN_ULONG ret = 0;\n#else\n    BN_ULLONG ret = 0;\n#endif\n    int i;\n\n    if (w == 0)\n        return (BN_ULONG)-1;\n\n#ifndef BN_LLONG\n    /*\n     * If |w| is too long and we don't have BN_ULLONG then we need to fall\n     * back to using BN_div_word\n     */\n    if (w > ((BN_ULONG)1 << BN_BITS4)) {\n        BIGNUM *tmp = BN_dup(a);\n        if (tmp == NULL)\n            return (BN_ULONG)-1;\n\n        ret = BN_div_word(tmp, w);\n        BN_free(tmp);\n\n        return ret;\n    }\n#endif\n\n    bn_check_top(a);\n    w &= BN_MASK2;\n    for (i = a->top - 1; i >= 0; i--) {\n#ifndef BN_LLONG\n        /*\n         * We can assume here that | w <= ((BN_ULONG)1 << BN_BITS4) | and so\n         * | ret < ((BN_ULONG)1 << BN_BITS4) | and therefore the shifts here are\n         * safe and will not overflow\n         */\n        ret = ((ret << BN_BITS4) | ((a->d[i] >> BN_BITS4) & BN_MASK2l)) % w;\n        ret = ((ret << BN_BITS4) | (a->d[i] & BN_MASK2l)) % w;\n#else\n        ret = (BN_ULLONG) (((ret << (BN_ULLONG) BN_BITS2) | a->d[i]) %\n                           (BN_ULLONG) w);\n#endif\n    }\n    return (BN_ULONG)ret;\n}\n\nBN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w)\n{\n    BN_ULONG ret = 0;\n    int i, j;\n\n    bn_check_top(a);\n    w &= BN_MASK2;\n\n    if (!w)\n        /* actually this an error (division by zero) */\n        return (BN_ULONG)-1;\n    if (a->top == 0)\n        return 0;\n\n    /* normalize input (so bn_div_words doesn't complain) */\n    j = BN_BITS2 - BN_num_bits_word(w);\n    w <<= j;\n    if (!BN_lshift(a, a, j))\n        return (BN_ULONG)-1;\n\n    for (i = a->top - 1; i >= 0; i--) {\n        BN_ULONG l, d;\n\n        l = a->d[i];\n        d = bn_div_words(ret, l, w);\n        ret = (l - ((d * w) & BN_MASK2)) & BN_MASK2;\n        a->d[i] = d;\n    }\n    if ((a->top > 0) && (a->d[a->top - 1] == 0))\n        a->top--;\n    ret >>= j;\n    if (!a->top)\n        a->neg = 0; /* don't allow negative zero */\n    bn_check_top(a);\n    return ret;\n}\n\nint BN_add_word(BIGNUM *a, BN_ULONG w)\n{\n    BN_ULONG l;\n    int i;\n\n    bn_check_top(a);\n    w &= BN_MASK2;\n\n    /* degenerate case: w is zero */\n    if (!w)\n        return 1;\n    /* degenerate case: a is zero */\n    if (BN_is_zero(a))\n        return BN_set_word(a, w);\n    /* handle 'a' when negative */\n    if (a->neg) {\n        a->neg = 0;\n        i = BN_sub_word(a, w);\n        if (!BN_is_zero(a))\n            a->neg = !(a->neg);\n        return i;\n    }\n    for (i = 0; w != 0 && i < a->top; i++) {\n        a->d[i] = l = (a->d[i] + w) & BN_MASK2;\n        w = (w > l) ? 1 : 0;\n    }\n    if (w && i == a->top) {\n        if (bn_wexpand(a, a->top + 1) == NULL)\n            return 0;\n        a->top++;\n        a->d[i] = w;\n    }\n    bn_check_top(a);\n    return 1;\n}\n\nint BN_sub_word(BIGNUM *a, BN_ULONG w)\n{\n    int i;\n\n    bn_check_top(a);\n    w &= BN_MASK2;\n\n    /* degenerate case: w is zero */\n    if (!w)\n        return 1;\n    /* degenerate case: a is zero */\n    if (BN_is_zero(a)) {\n        i = BN_set_word(a, w);\n        if (i != 0)\n            BN_set_negative(a, 1);\n        return i;\n    }\n    /* handle 'a' when negative */\n    if (a->neg) {\n        a->neg = 0;\n        i = BN_add_word(a, w);\n        a->neg = 1;\n        return i;\n    }\n\n    if ((a->top == 1) && (a->d[0] < w)) {\n        a->d[0] = w - a->d[0];\n        a->neg = 1;\n        return 1;\n    }\n    i = 0;\n    for (;;) {\n        if (a->d[i] >= w) {\n            a->d[i] -= w;\n            break;\n        } else {\n            a->d[i] = (a->d[i] - w) & BN_MASK2;\n            i++;\n            w = 1;\n        }\n    }\n    if ((a->d[i] == 0) && (i == (a->top - 1)))\n        a->top--;\n    bn_check_top(a);\n    return 1;\n}\n\nint BN_mul_word(BIGNUM *a, BN_ULONG w)\n{\n    BN_ULONG ll;\n\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (a->top) {\n        if (w == 0)\n            BN_zero(a);\n        else {\n            ll = bn_mul_words(a->d, a->d, a->top, w);\n            if (ll) {\n                if (bn_wexpand(a, a->top + 1) == NULL)\n                    return 0;\n                a->d[a->top++] = ll;\n            }\n        }\n    }\n    bn_check_top(a);\n    return 1;\n}\n"
  },
  {
    "path": "cryptomini/bn/rsaz_exp.h",
    "content": "/*\n * Copyright 2013-2018 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2012, Intel Corporation. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n *\n * Originally written by Shay Gueron (1, 2), and Vlad Krasnov (1)\n * (1) Intel Corporation, Israel Development Center, Haifa, Israel\n * (2) University of Haifa, Israel\n */\n\n#ifndef OSSL_CRYPTO_BN_RSAZ_EXP_H\n# define OSSL_CRYPTO_BN_RSAZ_EXP_H\n\n# undef RSAZ_ENABLED\n# if defined(OPENSSL_BN_ASM_MONT) && \\\n        (defined(__x86_64) || defined(__x86_64__) || \\\n         defined(_M_AMD64) || defined(_M_X64))\n#  define RSAZ_ENABLED\n\n#  include <openssl/bn.h>\n\nvoid RSAZ_1024_mod_exp_avx2(BN_ULONG result[16],\n                            const BN_ULONG base_norm[16],\n                            const BN_ULONG exponent[16],\n                            const BN_ULONG m_norm[16], const BN_ULONG RR[16],\n                            BN_ULONG k0);\nint rsaz_avx2_eligible(void);\n\nvoid RSAZ_512_mod_exp(BN_ULONG result[8],\n                      const BN_ULONG base_norm[8], const BN_ULONG exponent[8],\n                      const BN_ULONG m_norm[8], BN_ULONG k0,\n                      const BN_ULONG RR[8]);\n\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/camellia/camellia.c",
    "content": "/*\n * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/* ====================================================================\n * Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) .\n * ALL RIGHTS RESERVED.\n *\n * Intellectual Property information for Camellia:\n *     http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html\n *\n * News Release for Announcement of Camellia open source:\n *     http://www.ntt.co.jp/news/news06e/0604/060413a.html\n *\n * The Camellia Code included herein is developed by\n * NTT (Nippon Telegraph and Telephone Corporation), and is contributed\n * to the OpenSSL project.\n */\n\n/*\n * Algorithm Specification\n * http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html\n */\n\n/*\n * This release balances code size and performance. In particular key\n * schedule setup is fully unrolled, because doing so *significantly*\n * reduces amount of instructions per setup round and code increase is\n * justifiable. In block functions on the other hand only inner loops\n * are unrolled, as full unroll gives only nominal performance boost,\n * while code size grows 4 or 7 times. Also, unlike previous versions\n * this one \"encourages\" compiler to keep intermediate variables in\n * registers, which should give better \"all round\" results, in other\n * words reasonable performance even with not so modern compilers.\n */\n\n#include <openssl/camellia.h>\n#include \"cmll_local.h\"\n#include <string.h>\n#include <stdlib.h>\n\n#define RightRotate(x, s) ( ((x) >> (s)) + ((x) << (32 - s)) )\n#define LeftRotate(x, s)  ( ((x) << (s)) + ((x) >> (32 - s)) )\n\n#define GETU32(p)   (((u32)(p)[0] << 24) ^ ((u32)(p)[1] << 16) ^ ((u32)(p)[2] <<  8) ^ ((u32)(p)[3]))\n#define PUTU32(p,v) ((p)[0] = (u8)((v) >> 24), (p)[1] = (u8)((v) >> 16), (p)[2] = (u8)((v) >>  8), (p)[3] = (u8)(v))\n\n/* S-box data */\n#define SBOX1_1110 Camellia_SBOX[0]\n#define SBOX4_4404 Camellia_SBOX[1]\n#define SBOX2_0222 Camellia_SBOX[2]\n#define SBOX3_3033 Camellia_SBOX[3]\nstatic const u32 Camellia_SBOX[][256] = {\n    {0x70707000, 0x82828200, 0x2c2c2c00, 0xececec00, 0xb3b3b300, 0x27272700,\n     0xc0c0c000, 0xe5e5e500, 0xe4e4e400, 0x85858500, 0x57575700, 0x35353500,\n     0xeaeaea00, 0x0c0c0c00, 0xaeaeae00, 0x41414100, 0x23232300, 0xefefef00,\n     0x6b6b6b00, 0x93939300, 0x45454500, 0x19191900, 0xa5a5a500, 0x21212100,\n     0xededed00, 0x0e0e0e00, 0x4f4f4f00, 0x4e4e4e00, 0x1d1d1d00, 0x65656500,\n     0x92929200, 0xbdbdbd00, 0x86868600, 0xb8b8b800, 0xafafaf00, 0x8f8f8f00,\n     0x7c7c7c00, 0xebebeb00, 0x1f1f1f00, 0xcecece00, 0x3e3e3e00, 0x30303000,\n     0xdcdcdc00, 0x5f5f5f00, 0x5e5e5e00, 0xc5c5c500, 0x0b0b0b00, 0x1a1a1a00,\n     0xa6a6a600, 0xe1e1e100, 0x39393900, 0xcacaca00, 0xd5d5d500, 0x47474700,\n     0x5d5d5d00, 0x3d3d3d00, 0xd9d9d900, 0x01010100, 0x5a5a5a00, 0xd6d6d600,\n     0x51515100, 0x56565600, 0x6c6c6c00, 0x4d4d4d00, 0x8b8b8b00, 0x0d0d0d00,\n     0x9a9a9a00, 0x66666600, 0xfbfbfb00, 0xcccccc00, 0xb0b0b000, 0x2d2d2d00,\n     0x74747400, 0x12121200, 0x2b2b2b00, 0x20202000, 0xf0f0f000, 0xb1b1b100,\n     0x84848400, 0x99999900, 0xdfdfdf00, 0x4c4c4c00, 0xcbcbcb00, 0xc2c2c200,\n     0x34343400, 0x7e7e7e00, 0x76767600, 0x05050500, 0x6d6d6d00, 0xb7b7b700,\n     0xa9a9a900, 0x31313100, 0xd1d1d100, 0x17171700, 0x04040400, 0xd7d7d700,\n     0x14141400, 0x58585800, 0x3a3a3a00, 0x61616100, 0xdedede00, 0x1b1b1b00,\n     0x11111100, 0x1c1c1c00, 0x32323200, 0x0f0f0f00, 0x9c9c9c00, 0x16161600,\n     0x53535300, 0x18181800, 0xf2f2f200, 0x22222200, 0xfefefe00, 0x44444400,\n     0xcfcfcf00, 0xb2b2b200, 0xc3c3c300, 0xb5b5b500, 0x7a7a7a00, 0x91919100,\n     0x24242400, 0x08080800, 0xe8e8e800, 0xa8a8a800, 0x60606000, 0xfcfcfc00,\n     0x69696900, 0x50505000, 0xaaaaaa00, 0xd0d0d000, 0xa0a0a000, 0x7d7d7d00,\n     0xa1a1a100, 0x89898900, 0x62626200, 0x97979700, 0x54545400, 0x5b5b5b00,\n     0x1e1e1e00, 0x95959500, 0xe0e0e000, 0xffffff00, 0x64646400, 0xd2d2d200,\n     0x10101000, 0xc4c4c400, 0x00000000, 0x48484800, 0xa3a3a300, 0xf7f7f700,\n     0x75757500, 0xdbdbdb00, 0x8a8a8a00, 0x03030300, 0xe6e6e600, 0xdadada00,\n     0x09090900, 0x3f3f3f00, 0xdddddd00, 0x94949400, 0x87878700, 0x5c5c5c00,\n     0x83838300, 0x02020200, 0xcdcdcd00, 0x4a4a4a00, 0x90909000, 0x33333300,\n     0x73737300, 0x67676700, 0xf6f6f600, 0xf3f3f300, 0x9d9d9d00, 0x7f7f7f00,\n     0xbfbfbf00, 0xe2e2e200, 0x52525200, 0x9b9b9b00, 0xd8d8d800, 0x26262600,\n     0xc8c8c800, 0x37373700, 0xc6c6c600, 0x3b3b3b00, 0x81818100, 0x96969600,\n     0x6f6f6f00, 0x4b4b4b00, 0x13131300, 0xbebebe00, 0x63636300, 0x2e2e2e00,\n     0xe9e9e900, 0x79797900, 0xa7a7a700, 0x8c8c8c00, 0x9f9f9f00, 0x6e6e6e00,\n     0xbcbcbc00, 0x8e8e8e00, 0x29292900, 0xf5f5f500, 0xf9f9f900, 0xb6b6b600,\n     0x2f2f2f00, 0xfdfdfd00, 0xb4b4b400, 0x59595900, 0x78787800, 0x98989800,\n     0x06060600, 0x6a6a6a00, 0xe7e7e700, 0x46464600, 0x71717100, 0xbababa00,\n     0xd4d4d400, 0x25252500, 0xababab00, 0x42424200, 0x88888800, 0xa2a2a200,\n     0x8d8d8d00, 0xfafafa00, 0x72727200, 0x07070700, 0xb9b9b900, 0x55555500,\n     0xf8f8f800, 0xeeeeee00, 0xacacac00, 0x0a0a0a00, 0x36363600, 0x49494900,\n     0x2a2a2a00, 0x68686800, 0x3c3c3c00, 0x38383800, 0xf1f1f100, 0xa4a4a400,\n     0x40404000, 0x28282800, 0xd3d3d300, 0x7b7b7b00, 0xbbbbbb00, 0xc9c9c900,\n     0x43434300, 0xc1c1c100, 0x15151500, 0xe3e3e300, 0xadadad00, 0xf4f4f400,\n     0x77777700, 0xc7c7c700, 0x80808000, 0x9e9e9e00},\n    {0x70700070, 0x2c2c002c, 0xb3b300b3, 0xc0c000c0, 0xe4e400e4, 0x57570057,\n     0xeaea00ea, 0xaeae00ae, 0x23230023, 0x6b6b006b, 0x45450045, 0xa5a500a5,\n     0xeded00ed, 0x4f4f004f, 0x1d1d001d, 0x92920092, 0x86860086, 0xafaf00af,\n     0x7c7c007c, 0x1f1f001f, 0x3e3e003e, 0xdcdc00dc, 0x5e5e005e, 0x0b0b000b,\n     0xa6a600a6, 0x39390039, 0xd5d500d5, 0x5d5d005d, 0xd9d900d9, 0x5a5a005a,\n     0x51510051, 0x6c6c006c, 0x8b8b008b, 0x9a9a009a, 0xfbfb00fb, 0xb0b000b0,\n     0x74740074, 0x2b2b002b, 0xf0f000f0, 0x84840084, 0xdfdf00df, 0xcbcb00cb,\n     0x34340034, 0x76760076, 0x6d6d006d, 0xa9a900a9, 0xd1d100d1, 0x04040004,\n     0x14140014, 0x3a3a003a, 0xdede00de, 0x11110011, 0x32320032, 0x9c9c009c,\n     0x53530053, 0xf2f200f2, 0xfefe00fe, 0xcfcf00cf, 0xc3c300c3, 0x7a7a007a,\n     0x24240024, 0xe8e800e8, 0x60600060, 0x69690069, 0xaaaa00aa, 0xa0a000a0,\n     0xa1a100a1, 0x62620062, 0x54540054, 0x1e1e001e, 0xe0e000e0, 0x64640064,\n     0x10100010, 0x00000000, 0xa3a300a3, 0x75750075, 0x8a8a008a, 0xe6e600e6,\n     0x09090009, 0xdddd00dd, 0x87870087, 0x83830083, 0xcdcd00cd, 0x90900090,\n     0x73730073, 0xf6f600f6, 0x9d9d009d, 0xbfbf00bf, 0x52520052, 0xd8d800d8,\n     0xc8c800c8, 0xc6c600c6, 0x81810081, 0x6f6f006f, 0x13130013, 0x63630063,\n     0xe9e900e9, 0xa7a700a7, 0x9f9f009f, 0xbcbc00bc, 0x29290029, 0xf9f900f9,\n     0x2f2f002f, 0xb4b400b4, 0x78780078, 0x06060006, 0xe7e700e7, 0x71710071,\n     0xd4d400d4, 0xabab00ab, 0x88880088, 0x8d8d008d, 0x72720072, 0xb9b900b9,\n     0xf8f800f8, 0xacac00ac, 0x36360036, 0x2a2a002a, 0x3c3c003c, 0xf1f100f1,\n     0x40400040, 0xd3d300d3, 0xbbbb00bb, 0x43430043, 0x15150015, 0xadad00ad,\n     0x77770077, 0x80800080, 0x82820082, 0xecec00ec, 0x27270027, 0xe5e500e5,\n     0x85850085, 0x35350035, 0x0c0c000c, 0x41410041, 0xefef00ef, 0x93930093,\n     0x19190019, 0x21210021, 0x0e0e000e, 0x4e4e004e, 0x65650065, 0xbdbd00bd,\n     0xb8b800b8, 0x8f8f008f, 0xebeb00eb, 0xcece00ce, 0x30300030, 0x5f5f005f,\n     0xc5c500c5, 0x1a1a001a, 0xe1e100e1, 0xcaca00ca, 0x47470047, 0x3d3d003d,\n     0x01010001, 0xd6d600d6, 0x56560056, 0x4d4d004d, 0x0d0d000d, 0x66660066,\n     0xcccc00cc, 0x2d2d002d, 0x12120012, 0x20200020, 0xb1b100b1, 0x99990099,\n     0x4c4c004c, 0xc2c200c2, 0x7e7e007e, 0x05050005, 0xb7b700b7, 0x31310031,\n     0x17170017, 0xd7d700d7, 0x58580058, 0x61610061, 0x1b1b001b, 0x1c1c001c,\n     0x0f0f000f, 0x16160016, 0x18180018, 0x22220022, 0x44440044, 0xb2b200b2,\n     0xb5b500b5, 0x91910091, 0x08080008, 0xa8a800a8, 0xfcfc00fc, 0x50500050,\n     0xd0d000d0, 0x7d7d007d, 0x89890089, 0x97970097, 0x5b5b005b, 0x95950095,\n     0xffff00ff, 0xd2d200d2, 0xc4c400c4, 0x48480048, 0xf7f700f7, 0xdbdb00db,\n     0x03030003, 0xdada00da, 0x3f3f003f, 0x94940094, 0x5c5c005c, 0x02020002,\n     0x4a4a004a, 0x33330033, 0x67670067, 0xf3f300f3, 0x7f7f007f, 0xe2e200e2,\n     0x9b9b009b, 0x26260026, 0x37370037, 0x3b3b003b, 0x96960096, 0x4b4b004b,\n     0xbebe00be, 0x2e2e002e, 0x79790079, 0x8c8c008c, 0x6e6e006e, 0x8e8e008e,\n     0xf5f500f5, 0xb6b600b6, 0xfdfd00fd, 0x59590059, 0x98980098, 0x6a6a006a,\n     0x46460046, 0xbaba00ba, 0x25250025, 0x42420042, 0xa2a200a2, 0xfafa00fa,\n     0x07070007, 0x55550055, 0xeeee00ee, 0x0a0a000a, 0x49490049, 0x68680068,\n     0x38380038, 0xa4a400a4, 0x28280028, 0x7b7b007b, 0xc9c900c9, 0xc1c100c1,\n     0xe3e300e3, 0xf4f400f4, 0xc7c700c7, 0x9e9e009e},\n    {0x00e0e0e0, 0x00050505, 0x00585858, 0x00d9d9d9, 0x00676767, 0x004e4e4e,\n     0x00818181, 0x00cbcbcb, 0x00c9c9c9, 0x000b0b0b, 0x00aeaeae, 0x006a6a6a,\n     0x00d5d5d5, 0x00181818, 0x005d5d5d, 0x00828282, 0x00464646, 0x00dfdfdf,\n     0x00d6d6d6, 0x00272727, 0x008a8a8a, 0x00323232, 0x004b4b4b, 0x00424242,\n     0x00dbdbdb, 0x001c1c1c, 0x009e9e9e, 0x009c9c9c, 0x003a3a3a, 0x00cacaca,\n     0x00252525, 0x007b7b7b, 0x000d0d0d, 0x00717171, 0x005f5f5f, 0x001f1f1f,\n     0x00f8f8f8, 0x00d7d7d7, 0x003e3e3e, 0x009d9d9d, 0x007c7c7c, 0x00606060,\n     0x00b9b9b9, 0x00bebebe, 0x00bcbcbc, 0x008b8b8b, 0x00161616, 0x00343434,\n     0x004d4d4d, 0x00c3c3c3, 0x00727272, 0x00959595, 0x00ababab, 0x008e8e8e,\n     0x00bababa, 0x007a7a7a, 0x00b3b3b3, 0x00020202, 0x00b4b4b4, 0x00adadad,\n     0x00a2a2a2, 0x00acacac, 0x00d8d8d8, 0x009a9a9a, 0x00171717, 0x001a1a1a,\n     0x00353535, 0x00cccccc, 0x00f7f7f7, 0x00999999, 0x00616161, 0x005a5a5a,\n     0x00e8e8e8, 0x00242424, 0x00565656, 0x00404040, 0x00e1e1e1, 0x00636363,\n     0x00090909, 0x00333333, 0x00bfbfbf, 0x00989898, 0x00979797, 0x00858585,\n     0x00686868, 0x00fcfcfc, 0x00ececec, 0x000a0a0a, 0x00dadada, 0x006f6f6f,\n     0x00535353, 0x00626262, 0x00a3a3a3, 0x002e2e2e, 0x00080808, 0x00afafaf,\n     0x00282828, 0x00b0b0b0, 0x00747474, 0x00c2c2c2, 0x00bdbdbd, 0x00363636,\n     0x00222222, 0x00383838, 0x00646464, 0x001e1e1e, 0x00393939, 0x002c2c2c,\n     0x00a6a6a6, 0x00303030, 0x00e5e5e5, 0x00444444, 0x00fdfdfd, 0x00888888,\n     0x009f9f9f, 0x00656565, 0x00878787, 0x006b6b6b, 0x00f4f4f4, 0x00232323,\n     0x00484848, 0x00101010, 0x00d1d1d1, 0x00515151, 0x00c0c0c0, 0x00f9f9f9,\n     0x00d2d2d2, 0x00a0a0a0, 0x00555555, 0x00a1a1a1, 0x00414141, 0x00fafafa,\n     0x00434343, 0x00131313, 0x00c4c4c4, 0x002f2f2f, 0x00a8a8a8, 0x00b6b6b6,\n     0x003c3c3c, 0x002b2b2b, 0x00c1c1c1, 0x00ffffff, 0x00c8c8c8, 0x00a5a5a5,\n     0x00202020, 0x00898989, 0x00000000, 0x00909090, 0x00474747, 0x00efefef,\n     0x00eaeaea, 0x00b7b7b7, 0x00151515, 0x00060606, 0x00cdcdcd, 0x00b5b5b5,\n     0x00121212, 0x007e7e7e, 0x00bbbbbb, 0x00292929, 0x000f0f0f, 0x00b8b8b8,\n     0x00070707, 0x00040404, 0x009b9b9b, 0x00949494, 0x00212121, 0x00666666,\n     0x00e6e6e6, 0x00cecece, 0x00ededed, 0x00e7e7e7, 0x003b3b3b, 0x00fefefe,\n     0x007f7f7f, 0x00c5c5c5, 0x00a4a4a4, 0x00373737, 0x00b1b1b1, 0x004c4c4c,\n     0x00919191, 0x006e6e6e, 0x008d8d8d, 0x00767676, 0x00030303, 0x002d2d2d,\n     0x00dedede, 0x00969696, 0x00262626, 0x007d7d7d, 0x00c6c6c6, 0x005c5c5c,\n     0x00d3d3d3, 0x00f2f2f2, 0x004f4f4f, 0x00191919, 0x003f3f3f, 0x00dcdcdc,\n     0x00797979, 0x001d1d1d, 0x00525252, 0x00ebebeb, 0x00f3f3f3, 0x006d6d6d,\n     0x005e5e5e, 0x00fbfbfb, 0x00696969, 0x00b2b2b2, 0x00f0f0f0, 0x00313131,\n     0x000c0c0c, 0x00d4d4d4, 0x00cfcfcf, 0x008c8c8c, 0x00e2e2e2, 0x00757575,\n     0x00a9a9a9, 0x004a4a4a, 0x00575757, 0x00848484, 0x00111111, 0x00454545,\n     0x001b1b1b, 0x00f5f5f5, 0x00e4e4e4, 0x000e0e0e, 0x00737373, 0x00aaaaaa,\n     0x00f1f1f1, 0x00dddddd, 0x00595959, 0x00141414, 0x006c6c6c, 0x00929292,\n     0x00545454, 0x00d0d0d0, 0x00787878, 0x00707070, 0x00e3e3e3, 0x00494949,\n     0x00808080, 0x00505050, 0x00a7a7a7, 0x00f6f6f6, 0x00777777, 0x00939393,\n     0x00868686, 0x00838383, 0x002a2a2a, 0x00c7c7c7, 0x005b5b5b, 0x00e9e9e9,\n     0x00eeeeee, 0x008f8f8f, 0x00010101, 0x003d3d3d},\n    {0x38003838, 0x41004141, 0x16001616, 0x76007676, 0xd900d9d9, 0x93009393,\n     0x60006060, 0xf200f2f2, 0x72007272, 0xc200c2c2, 0xab00abab, 0x9a009a9a,\n     0x75007575, 0x06000606, 0x57005757, 0xa000a0a0, 0x91009191, 0xf700f7f7,\n     0xb500b5b5, 0xc900c9c9, 0xa200a2a2, 0x8c008c8c, 0xd200d2d2, 0x90009090,\n     0xf600f6f6, 0x07000707, 0xa700a7a7, 0x27002727, 0x8e008e8e, 0xb200b2b2,\n     0x49004949, 0xde00dede, 0x43004343, 0x5c005c5c, 0xd700d7d7, 0xc700c7c7,\n     0x3e003e3e, 0xf500f5f5, 0x8f008f8f, 0x67006767, 0x1f001f1f, 0x18001818,\n     0x6e006e6e, 0xaf00afaf, 0x2f002f2f, 0xe200e2e2, 0x85008585, 0x0d000d0d,\n     0x53005353, 0xf000f0f0, 0x9c009c9c, 0x65006565, 0xea00eaea, 0xa300a3a3,\n     0xae00aeae, 0x9e009e9e, 0xec00ecec, 0x80008080, 0x2d002d2d, 0x6b006b6b,\n     0xa800a8a8, 0x2b002b2b, 0x36003636, 0xa600a6a6, 0xc500c5c5, 0x86008686,\n     0x4d004d4d, 0x33003333, 0xfd00fdfd, 0x66006666, 0x58005858, 0x96009696,\n     0x3a003a3a, 0x09000909, 0x95009595, 0x10001010, 0x78007878, 0xd800d8d8,\n     0x42004242, 0xcc00cccc, 0xef00efef, 0x26002626, 0xe500e5e5, 0x61006161,\n     0x1a001a1a, 0x3f003f3f, 0x3b003b3b, 0x82008282, 0xb600b6b6, 0xdb00dbdb,\n     0xd400d4d4, 0x98009898, 0xe800e8e8, 0x8b008b8b, 0x02000202, 0xeb00ebeb,\n     0x0a000a0a, 0x2c002c2c, 0x1d001d1d, 0xb000b0b0, 0x6f006f6f, 0x8d008d8d,\n     0x88008888, 0x0e000e0e, 0x19001919, 0x87008787, 0x4e004e4e, 0x0b000b0b,\n     0xa900a9a9, 0x0c000c0c, 0x79007979, 0x11001111, 0x7f007f7f, 0x22002222,\n     0xe700e7e7, 0x59005959, 0xe100e1e1, 0xda00dada, 0x3d003d3d, 0xc800c8c8,\n     0x12001212, 0x04000404, 0x74007474, 0x54005454, 0x30003030, 0x7e007e7e,\n     0xb400b4b4, 0x28002828, 0x55005555, 0x68006868, 0x50005050, 0xbe00bebe,\n     0xd000d0d0, 0xc400c4c4, 0x31003131, 0xcb00cbcb, 0x2a002a2a, 0xad00adad,\n     0x0f000f0f, 0xca00caca, 0x70007070, 0xff00ffff, 0x32003232, 0x69006969,\n     0x08000808, 0x62006262, 0x00000000, 0x24002424, 0xd100d1d1, 0xfb00fbfb,\n     0xba00baba, 0xed00eded, 0x45004545, 0x81008181, 0x73007373, 0x6d006d6d,\n     0x84008484, 0x9f009f9f, 0xee00eeee, 0x4a004a4a, 0xc300c3c3, 0x2e002e2e,\n     0xc100c1c1, 0x01000101, 0xe600e6e6, 0x25002525, 0x48004848, 0x99009999,\n     0xb900b9b9, 0xb300b3b3, 0x7b007b7b, 0xf900f9f9, 0xce00cece, 0xbf00bfbf,\n     0xdf00dfdf, 0x71007171, 0x29002929, 0xcd00cdcd, 0x6c006c6c, 0x13001313,\n     0x64006464, 0x9b009b9b, 0x63006363, 0x9d009d9d, 0xc000c0c0, 0x4b004b4b,\n     0xb700b7b7, 0xa500a5a5, 0x89008989, 0x5f005f5f, 0xb100b1b1, 0x17001717,\n     0xf400f4f4, 0xbc00bcbc, 0xd300d3d3, 0x46004646, 0xcf00cfcf, 0x37003737,\n     0x5e005e5e, 0x47004747, 0x94009494, 0xfa00fafa, 0xfc00fcfc, 0x5b005b5b,\n     0x97009797, 0xfe00fefe, 0x5a005a5a, 0xac00acac, 0x3c003c3c, 0x4c004c4c,\n     0x03000303, 0x35003535, 0xf300f3f3, 0x23002323, 0xb800b8b8, 0x5d005d5d,\n     0x6a006a6a, 0x92009292, 0xd500d5d5, 0x21002121, 0x44004444, 0x51005151,\n     0xc600c6c6, 0x7d007d7d, 0x39003939, 0x83008383, 0xdc00dcdc, 0xaa00aaaa,\n     0x7c007c7c, 0x77007777, 0x56005656, 0x05000505, 0x1b001b1b, 0xa400a4a4,\n     0x15001515, 0x34003434, 0x1e001e1e, 0x1c001c1c, 0xf800f8f8, 0x52005252,\n     0x20002020, 0x14001414, 0xe900e9e9, 0xbd00bdbd, 0xdd00dddd, 0xe400e4e4,\n     0xa100a1a1, 0xe000e0e0, 0x8a008a8a, 0xf100f1f1, 0xd600d6d6, 0x7a007a7a,\n     0xbb00bbbb, 0xe300e3e3, 0x40004040, 0x4f004f4f}\n};\n\n/* Key generation constants */\nstatic const u32 SIGMA[] = {\n    0xa09e667f, 0x3bcc908b, 0xb67ae858, 0x4caa73b2, 0xc6ef372f, 0xe94f82be,\n    0x54ff53a5, 0xf1d36f1c, 0x10e527fa, 0xde682d1d, 0xb05688c2, 0xb3e6c1fd\n};\n\n/* The phi algorithm given in C.2.7 of the Camellia spec document. */\n/*\n * This version does not attempt to minimize amount of temporary\n * variables, but instead explicitly exposes algorithm's parallelism.\n * It is therefore most appropriate for platforms with not less than\n * ~16 registers. For platforms with less registers [well, x86 to be\n * specific] assembler version should be/is provided anyway...\n */\n#define Camellia_Feistel(_s0,_s1,_s2,_s3,_key) do {\\\n        register u32 _t0,_t1,_t2,_t3;\\\n\\\n        _t0  = _s0 ^ (_key)[0];\\\n        _t3  = SBOX4_4404[_t0&0xff];\\\n        _t1  = _s1 ^ (_key)[1];\\\n        _t3 ^= SBOX3_3033[(_t0 >> 8)&0xff];\\\n        _t2  = SBOX1_1110[_t1&0xff];\\\n        _t3 ^= SBOX2_0222[(_t0 >> 16)&0xff];\\\n        _t2 ^= SBOX4_4404[(_t1 >> 8)&0xff];\\\n        _t3 ^= SBOX1_1110[(_t0 >> 24)];\\\n        _t2 ^= _t3;\\\n        _t3  = RightRotate(_t3,8);\\\n        _t2 ^= SBOX3_3033[(_t1 >> 16)&0xff];\\\n        _s3 ^= _t3;\\\n        _t2 ^= SBOX2_0222[(_t1 >> 24)];\\\n        _s2 ^= _t2; \\\n        _s3 ^= _t2;\\\n} while(0)\n\n/*\n * Note that n has to be less than 32. Rotations for larger amount\n * of bits are achieved by \"rotating\" order of s-elements and\n * adjusting n accordingly, e.g. RotLeft128(s1,s2,s3,s0,n-32).\n */\n#define RotLeft128(_s0,_s1,_s2,_s3,_n) do {\\\n        u32 _t0=_s0>>(32-_n);\\\n        _s0 = (_s0<<_n) | (_s1>>(32-_n));\\\n        _s1 = (_s1<<_n) | (_s2>>(32-_n));\\\n        _s2 = (_s2<<_n) | (_s3>>(32-_n));\\\n        _s3 = (_s3<<_n) | _t0;\\\n} while (0)\n\nint Camellia_Ekeygen(int keyBitLength, const u8 *rawKey, KEY_TABLE_TYPE k)\n{\n    register u32 s0, s1, s2, s3;\n\n    k[0] = s0 = GETU32(rawKey);\n    k[1] = s1 = GETU32(rawKey + 4);\n    k[2] = s2 = GETU32(rawKey + 8);\n    k[3] = s3 = GETU32(rawKey + 12);\n\n    if (keyBitLength != 128) {\n        k[8] = s0 = GETU32(rawKey + 16);\n        k[9] = s1 = GETU32(rawKey + 20);\n        if (keyBitLength == 192) {\n            k[10] = s2 = ~s0;\n            k[11] = s3 = ~s1;\n        } else {\n            k[10] = s2 = GETU32(rawKey + 24);\n            k[11] = s3 = GETU32(rawKey + 28);\n        }\n        s0 ^= k[0], s1 ^= k[1], s2 ^= k[2], s3 ^= k[3];\n    }\n\n    /* Use the Feistel routine to scramble the key material */\n    Camellia_Feistel(s0, s1, s2, s3, SIGMA + 0);\n    Camellia_Feistel(s2, s3, s0, s1, SIGMA + 2);\n\n    s0 ^= k[0], s1 ^= k[1], s2 ^= k[2], s3 ^= k[3];\n    Camellia_Feistel(s0, s1, s2, s3, SIGMA + 4);\n    Camellia_Feistel(s2, s3, s0, s1, SIGMA + 6);\n\n    /* Fill the keyTable. Requires many block rotations. */\n    if (keyBitLength == 128) {\n        k[4] = s0, k[5] = s1, k[6] = s2, k[7] = s3;\n        RotLeft128(s0, s1, s2, s3, 15); /* KA <<< 15 */\n        k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3;\n        RotLeft128(s0, s1, s2, s3, 15); /* KA <<< 30 */\n        k[16] = s0, k[17] = s1, k[18] = s2, k[19] = s3;\n        RotLeft128(s0, s1, s2, s3, 15); /* KA <<< 45 */\n        k[24] = s0, k[25] = s1;\n        RotLeft128(s0, s1, s2, s3, 15); /* KA <<< 60 */\n        k[28] = s0, k[29] = s1, k[30] = s2, k[31] = s3;\n        RotLeft128(s1, s2, s3, s0, 2); /* KA <<< 94 */\n        k[40] = s1, k[41] = s2, k[42] = s3, k[43] = s0;\n        RotLeft128(s1, s2, s3, s0, 17); /* KA <<<111 */\n        k[48] = s1, k[49] = s2, k[50] = s3, k[51] = s0;\n\n        s0 = k[0], s1 = k[1], s2 = k[2], s3 = k[3];\n        RotLeft128(s0, s1, s2, s3, 15); /* KL <<< 15 */\n        k[8] = s0, k[9] = s1, k[10] = s2, k[11] = s3;\n        RotLeft128(s0, s1, s2, s3, 30); /* KL <<< 45 */\n        k[20] = s0, k[21] = s1, k[22] = s2, k[23] = s3;\n        RotLeft128(s0, s1, s2, s3, 15); /* KL <<< 60 */\n        k[26] = s2, k[27] = s3;\n        RotLeft128(s0, s1, s2, s3, 17); /* KL <<< 77 */\n        k[32] = s0, k[33] = s1, k[34] = s2, k[35] = s3;\n        RotLeft128(s0, s1, s2, s3, 17); /* KL <<< 94 */\n        k[36] = s0, k[37] = s1, k[38] = s2, k[39] = s3;\n        RotLeft128(s0, s1, s2, s3, 17); /* KL <<<111 */\n        k[44] = s0, k[45] = s1, k[46] = s2, k[47] = s3;\n\n        return 3;               /* grand rounds */\n    } else {\n        k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3;\n        s0 ^= k[8], s1 ^= k[9], s2 ^= k[10], s3 ^= k[11];\n        Camellia_Feistel(s0, s1, s2, s3, (SIGMA + 8));\n        Camellia_Feistel(s2, s3, s0, s1, (SIGMA + 10));\n\n        k[4] = s0, k[5] = s1, k[6] = s2, k[7] = s3;\n        RotLeft128(s0, s1, s2, s3, 30); /* KB <<< 30 */\n        k[20] = s0, k[21] = s1, k[22] = s2, k[23] = s3;\n        RotLeft128(s0, s1, s2, s3, 30); /* KB <<< 60 */\n        k[40] = s0, k[41] = s1, k[42] = s2, k[43] = s3;\n        RotLeft128(s1, s2, s3, s0, 19); /* KB <<<111 */\n        k[64] = s1, k[65] = s2, k[66] = s3, k[67] = s0;\n\n        s0 = k[8], s1 = k[9], s2 = k[10], s3 = k[11];\n        RotLeft128(s0, s1, s2, s3, 15); /* KR <<< 15 */\n        k[8] = s0, k[9] = s1, k[10] = s2, k[11] = s3;\n        RotLeft128(s0, s1, s2, s3, 15); /* KR <<< 30 */\n        k[16] = s0, k[17] = s1, k[18] = s2, k[19] = s3;\n        RotLeft128(s0, s1, s2, s3, 30); /* KR <<< 60 */\n        k[36] = s0, k[37] = s1, k[38] = s2, k[39] = s3;\n        RotLeft128(s1, s2, s3, s0, 2); /* KR <<< 94 */\n        k[52] = s1, k[53] = s2, k[54] = s3, k[55] = s0;\n\n        s0 = k[12], s1 = k[13], s2 = k[14], s3 = k[15];\n        RotLeft128(s0, s1, s2, s3, 15); /* KA <<< 15 */\n        k[12] = s0, k[13] = s1, k[14] = s2, k[15] = s3;\n        RotLeft128(s0, s1, s2, s3, 30); /* KA <<< 45 */\n        k[28] = s0, k[29] = s1, k[30] = s2, k[31] = s3;\n        /* KA <<< 77 */\n        k[48] = s1, k[49] = s2, k[50] = s3, k[51] = s0;\n        RotLeft128(s1, s2, s3, s0, 17); /* KA <<< 94 */\n        k[56] = s1, k[57] = s2, k[58] = s3, k[59] = s0;\n\n        s0 = k[0], s1 = k[1], s2 = k[2], s3 = k[3];\n        RotLeft128(s1, s2, s3, s0, 13); /* KL <<< 45 */\n        k[24] = s1, k[25] = s2, k[26] = s3, k[27] = s0;\n        RotLeft128(s1, s2, s3, s0, 15); /* KL <<< 60 */\n        k[32] = s1, k[33] = s2, k[34] = s3, k[35] = s0;\n        RotLeft128(s1, s2, s3, s0, 17); /* KL <<< 77 */\n        k[44] = s1, k[45] = s2, k[46] = s3, k[47] = s0;\n        RotLeft128(s2, s3, s0, s1, 2); /* KL <<<111 */\n        k[60] = s2, k[61] = s3, k[62] = s0, k[63] = s1;\n\n        return 4;               /* grand rounds */\n    }\n    /*\n     * It is possible to perform certain precalculations, which\n     * would spare few cycles in block procedure. It's not done,\n     * because it upsets the performance balance between key\n     * setup and block procedures, negatively affecting overall\n     * throughput in applications operating on short messages\n     * and volatile keys.\n     */\n}\n\nvoid Camellia_EncryptBlock_Rounds(int grandRounds, const u8 plaintext[],\n                                  const KEY_TABLE_TYPE keyTable,\n                                  u8 ciphertext[])\n{\n    register u32 s0, s1, s2, s3;\n    const u32 *k = keyTable, *kend = keyTable + grandRounds * 16;\n\n    s0 = GETU32(plaintext) ^ k[0];\n    s1 = GETU32(plaintext + 4) ^ k[1];\n    s2 = GETU32(plaintext + 8) ^ k[2];\n    s3 = GETU32(plaintext + 12) ^ k[3];\n    k += 4;\n\n    while (1) {\n        /* Camellia makes 6 Feistel rounds */\n        Camellia_Feistel(s0, s1, s2, s3, k + 0);\n        Camellia_Feistel(s2, s3, s0, s1, k + 2);\n        Camellia_Feistel(s0, s1, s2, s3, k + 4);\n        Camellia_Feistel(s2, s3, s0, s1, k + 6);\n        Camellia_Feistel(s0, s1, s2, s3, k + 8);\n        Camellia_Feistel(s2, s3, s0, s1, k + 10);\n        k += 12;\n\n        if (k == kend)\n            break;\n\n        /*\n         * This is the same function as the diffusion function D of the\n         * accompanying documentation. See section 3.2 for properties of the\n         * FLlayer function.\n         */\n        s1 ^= LeftRotate(s0 & k[0], 1);\n        s2 ^= s3 | k[3];\n        s0 ^= s1 | k[1];\n        s3 ^= LeftRotate(s2 & k[2], 1);\n        k += 4;\n    }\n\n    s2 ^= k[0], s3 ^= k[1], s0 ^= k[2], s1 ^= k[3];\n\n    PUTU32(ciphertext, s2);\n    PUTU32(ciphertext + 4, s3);\n    PUTU32(ciphertext + 8, s0);\n    PUTU32(ciphertext + 12, s1);\n}\n\nvoid Camellia_EncryptBlock(int keyBitLength, const u8 plaintext[],\n                           const KEY_TABLE_TYPE keyTable, u8 ciphertext[])\n{\n    Camellia_EncryptBlock_Rounds(keyBitLength == 128 ? 3 : 4,\n                                 plaintext, keyTable, ciphertext);\n}\n\nvoid Camellia_DecryptBlock_Rounds(int grandRounds, const u8 ciphertext[],\n                                  const KEY_TABLE_TYPE keyTable,\n                                  u8 plaintext[])\n{\n    u32 s0, s1, s2, s3;\n    const u32 *k = keyTable + grandRounds * 16, *kend = keyTable + 4;\n\n    s0 = GETU32(ciphertext) ^ k[0];\n    s1 = GETU32(ciphertext + 4) ^ k[1];\n    s2 = GETU32(ciphertext + 8) ^ k[2];\n    s3 = GETU32(ciphertext + 12) ^ k[3];\n\n    while (1) {\n        /* Camellia makes 6 Feistel rounds */\n        k -= 12;\n        Camellia_Feistel(s0, s1, s2, s3, k + 10);\n        Camellia_Feistel(s2, s3, s0, s1, k + 8);\n        Camellia_Feistel(s0, s1, s2, s3, k + 6);\n        Camellia_Feistel(s2, s3, s0, s1, k + 4);\n        Camellia_Feistel(s0, s1, s2, s3, k + 2);\n        Camellia_Feistel(s2, s3, s0, s1, k + 0);\n\n        if (k == kend)\n            break;\n\n        /*\n         * This is the same function as the diffusion function D of the\n         * accompanying documentation. See section 3.2 for properties of the\n         * FLlayer function.\n         */\n        k -= 4;\n        s1 ^= LeftRotate(s0 & k[2], 1);\n        s2 ^= s3 | k[1];\n        s0 ^= s1 | k[3];\n        s3 ^= LeftRotate(s2 & k[0], 1);\n    }\n\n    k -= 4;\n    s2 ^= k[0], s3 ^= k[1], s0 ^= k[2], s1 ^= k[3];\n\n    PUTU32(plaintext, s2);\n    PUTU32(plaintext + 4, s3);\n    PUTU32(plaintext + 8, s0);\n    PUTU32(plaintext + 12, s1);\n}\n\nvoid Camellia_DecryptBlock(int keyBitLength, const u8 plaintext[],\n                           const KEY_TABLE_TYPE keyTable, u8 ciphertext[])\n{\n    Camellia_DecryptBlock_Rounds(keyBitLength == 128 ? 3 : 4,\n                                 plaintext, keyTable, ciphertext);\n}\n"
  },
  {
    "path": "cryptomini/camellia/cmll_local.h",
    "content": "/*\n * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/* ====================================================================\n * Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) .\n * ALL RIGHTS RESERVED.\n *\n * Intellectual Property information for Camellia:\n *     http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html\n *\n * News Release for Announcement of Camellia open source:\n *     http://www.ntt.co.jp/news/news06e/0604/060413a.html\n *\n * The Camellia Code included herein is developed by\n * NTT (Nippon Telegraph and Telephone Corporation), and is contributed\n * to the OpenSSL project.\n */\n\n#ifndef OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H\n# define OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H\n\ntypedef unsigned int u32;\ntypedef unsigned char u8;\n\nint Camellia_Ekeygen(int keyBitLength, const u8 *rawKey,\n                     KEY_TABLE_TYPE keyTable);\nvoid Camellia_EncryptBlock_Rounds(int grandRounds, const u8 plaintext[],\n                                  const KEY_TABLE_TYPE keyTable,\n                                  u8 ciphertext[]);\nvoid Camellia_DecryptBlock_Rounds(int grandRounds, const u8 ciphertext[],\n                                  const KEY_TABLE_TYPE keyTable,\n                                  u8 plaintext[]);\nvoid Camellia_EncryptBlock(int keyBitLength, const u8 plaintext[],\n                           const KEY_TABLE_TYPE keyTable, u8 ciphertext[]);\nvoid Camellia_DecryptBlock(int keyBitLength, const u8 ciphertext[],\n                           const KEY_TABLE_TYPE keyTable, u8 plaintext[]);\n#endif                          /* #ifndef OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H */\n"
  },
  {
    "path": "cryptomini/camellia/cmll_misc.c",
    "content": "/*\n * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n#include <openssl/camellia.h>\n#include \"cmll_local.h\"\n\nint Camellia_set_key(const unsigned char *userKey, const int bits,\n                     CAMELLIA_KEY *key)\n{\n    if (!userKey || !key)\n        return -1;\n    if (bits != 128 && bits != 192 && bits != 256)\n        return -2;\n    key->grand_rounds = Camellia_Ekeygen(bits, userKey, key->u.rd_key);\n    return 0;\n}\n\nvoid Camellia_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key)\n{\n    Camellia_EncryptBlock_Rounds(key->grand_rounds, in, key->u.rd_key, out);\n}\n\nvoid Camellia_decrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key)\n{\n    Camellia_DecryptBlock_Rounds(key->grand_rounds, in, key->u.rd_key, out);\n}\n"
  },
  {
    "path": "cryptomini/cryptlib.c",
    "content": "/*\n * Copyright 1998-2019 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"e_os.h\"\n#include \"crypto/cryptlib.h\"\n#include <openssl/safestack.h>\n\n#if     defined(__i386)   || defined(__i386__)   || defined(_M_IX86) || \\\n        defined(__x86_64) || defined(__x86_64__) || \\\n        defined(_M_AMD64) || defined(_M_X64)\n\nextern unsigned int OPENSSL_ia32cap_P[4];\n\n# if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)\n\n/*\n * Purpose of these minimalistic and character-type-agnostic subroutines\n * is to break dependency on MSVCRT (on Windows) and locale. This makes\n * OPENSSL_cpuid_setup safe to use as \"constructor\". \"Character-type-\n * agnostic\" means that they work with either wide or 8-bit characters,\n * exploiting the fact that first 127 characters can be simply casted\n * between the sets, while the rest would be simply rejected by ossl_is*\n * subroutines.\n */\n#  ifdef _WIN32\ntypedef WCHAR variant_char;\n\nstatic variant_char *ossl_getenv(const char *name)\n{\n    /*\n     * Since we pull only one environment variable, it's simpler to\n     * to just ignore |name| and use equivalent wide-char L-literal.\n     * As well as to ignore excessively long values...\n     */\n    static WCHAR value[48];\n    DWORD len = GetEnvironmentVariableW(L\"OPENSSL_ia32cap\", value, 48);\n\n    return (len > 0 && len < 48) ? value : NULL;\n}\n#  else\ntypedef char variant_char;\n#   define ossl_getenv getenv\n#  endif\n\n#  include \"crypto/ctype.h\"\n\nstatic int todigit(variant_char c)\n{\n    if (ossl_isdigit(c))\n        return c - '0';\n    else if (ossl_isxdigit(c))\n        return ossl_tolower(c) - 'a' + 10;\n\n    /* return largest base value to make caller terminate the loop */\n    return 16;\n}\n\nstatic uint64_t ossl_strtouint64(const variant_char *str)\n{\n    uint64_t ret = 0;\n    unsigned int digit, base = 10;\n\n    if (*str == '0') {\n        base = 8, str++;\n        if (ossl_tolower(*str) == 'x')\n            base = 16, str++;\n    }\n\n    while((digit = todigit(*str++)) < base)\n        ret = ret * base + digit;\n\n    return ret;\n}\n\nstatic variant_char *ossl_strchr(const variant_char *str, char srch)\n{   variant_char c;\n\n    while((c = *str)) {\n        if (c == srch)\n\t    return (variant_char *)str;\n        str++;\n    }\n\n    return NULL;\n}\n\n#  define OPENSSL_CPUID_SETUP\ntypedef uint64_t IA32CAP;\n\nvoid OPENSSL_cpuid_setup(void)\n{\n    static int trigger = 0;\n    IA32CAP OPENSSL_ia32_cpuid(unsigned int *);\n    IA32CAP vec;\n    const variant_char *env;\n\n    if (trigger)\n        return;\n\n    trigger = 1;\n    if ((env = ossl_getenv(\"OPENSSL_ia32cap\")) != NULL) {\n        int off = (env[0] == '~') ? 1 : 0;\n\n        vec = ossl_strtouint64(env + off);\n\n        if (off) {\n            IA32CAP mask = vec;\n            vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P) & ~mask;\n            if (mask & (1<<24)) {\n                /*\n                 * User disables FXSR bit, mask even other capabilities\n                 * that operate exclusively on XMM, so we don't have to\n                 * double-check all the time. We mask PCLMULQDQ, AMD XOP,\n                 * AES-NI and AVX. Formally speaking we don't have to\n                 * do it in x86_64 case, but we can safely assume that\n                 * x86_64 users won't actually flip this flag.\n                 */\n                vec &= ~((IA32CAP)(1<<1|1<<11|1<<25|1<<28) << 32);\n            }\n        } else if (env[0] == ':') {\n            vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P);\n        }\n\n        if ((env = ossl_strchr(env, ':')) != NULL) {\n            IA32CAP vecx;\n\n            env++;\n            off = (env[0] == '~') ? 1 : 0;\n            vecx = ossl_strtouint64(env + off);\n            if (off) {\n                OPENSSL_ia32cap_P[2] &= ~(unsigned int)vecx;\n                OPENSSL_ia32cap_P[3] &= ~(unsigned int)(vecx >> 32);\n            } else {\n                OPENSSL_ia32cap_P[2] = (unsigned int)vecx;\n                OPENSSL_ia32cap_P[3] = (unsigned int)(vecx >> 32);\n            }\n        } else {\n            OPENSSL_ia32cap_P[2] = 0;\n            OPENSSL_ia32cap_P[3] = 0;\n        }\n    } else {\n        vec = OPENSSL_ia32_cpuid(OPENSSL_ia32cap_P);\n    }\n\n    /*\n     * |(1<<10) sets a reserved bit to signal that variable\n     * was initialized already... This is to avoid interference\n     * with cpuid snippets in ELF .init segment.\n     */\n    OPENSSL_ia32cap_P[0] = (unsigned int)vec | (1 << 10);\n    OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32);\n}\n# else\nunsigned int OPENSSL_ia32cap_P[4];\n# endif\n#endif\n#if !defined(OPENSSL_CPUID_SETUP) && !defined(OPENSSL_CPUID_OBJ)\nvoid OPENSSL_cpuid_setup(void)\n{\n}\n#endif\n\n#if defined(_WIN32)\n# include <tchar.h>\n# include <signal.h>\n# ifdef __WATCOMC__\n#  if defined(_UNICODE) || defined(__UNICODE__)\n#   define _vsntprintf _vsnwprintf\n#  else\n#   define _vsntprintf _vsnprintf\n#  endif\n# endif\n# ifdef _MSC_VER\n#  define alloca _alloca\n# endif\n\n# if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333\n#  ifdef OPENSSL_SYS_WIN_CORE\n\nint OPENSSL_isservice(void)\n{\n    /* OneCore API cannot interact with GUI */\n    return 1;\n}\n#  else\nint OPENSSL_isservice(void)\n{\n    HWINSTA h;\n    DWORD len;\n    WCHAR *name;\n    static union {\n        void *p;\n        FARPROC f;\n    } _OPENSSL_isservice = {\n        NULL\n    };\n\n    if (_OPENSSL_isservice.p == NULL) {\n        HANDLE mod = GetModuleHandle(NULL);\n        FARPROC f = NULL;\n\n        if (mod != NULL)\n            f = GetProcAddress(mod, \"_OPENSSL_isservice\");\n        if (f == NULL)\n            _OPENSSL_isservice.p = (void *)-1;\n        else\n            _OPENSSL_isservice.f = f;\n    }\n\n    if (_OPENSSL_isservice.p != (void *)-1)\n        return (*_OPENSSL_isservice.f) ();\n\n    h = GetProcessWindowStation();\n    if (h == NULL)\n        return -1;\n\n    if (GetUserObjectInformationW(h, UOI_NAME, NULL, 0, &len) ||\n        GetLastError() != ERROR_INSUFFICIENT_BUFFER)\n        return -1;\n\n    if (len > 512)\n        return -1;              /* paranoia */\n    len++, len &= ~1;           /* paranoia */\n    name = (WCHAR *)alloca(len + sizeof(WCHAR));\n    if (!GetUserObjectInformationW(h, UOI_NAME, name, len, &len))\n        return -1;\n\n    len++, len &= ~1;           /* paranoia */\n    name[len / sizeof(WCHAR)] = L'\\0'; /* paranoia */\n#   if 1\n    /*\n     * This doesn't cover \"interactive\" services [working with real\n     * WinSta0's] nor programs started non-interactively by Task Scheduler\n     * [those are working with SAWinSta].\n     */\n    if (wcsstr(name, L\"Service-0x\"))\n        return 1;\n#   else\n    /* This covers all non-interactive programs such as services. */\n    if (!wcsstr(name, L\"WinSta0\"))\n        return 1;\n#   endif\n    else\n        return 0;\n}\n#  endif\n# else\nint OPENSSL_isservice(void)\n{\n    return 0;\n}\n# endif\n\nvoid OPENSSL_showfatal(const char *fmta, ...)\n{\n    va_list ap;\n    TCHAR buf[256];\n    const TCHAR *fmt;\n    /*\n     * First check if it's a console application, in which case the\n     * error message would be printed to standard error.\n     * Windows CE does not have a concept of a console application,\n     * so we need to guard the check.\n     */\n# ifdef STD_ERROR_HANDLE\n    HANDLE h;\n\n    if ((h = GetStdHandle(STD_ERROR_HANDLE)) != NULL &&\n        GetFileType(h) != FILE_TYPE_UNKNOWN) {\n        /* must be console application */\n        int len;\n        DWORD out;\n\n        va_start(ap, fmta);\n        len = _vsnprintf((char *)buf, sizeof(buf), fmta, ap);\n        WriteFile(h, buf, len < 0 ? sizeof(buf) : (DWORD) len, &out, NULL);\n        va_end(ap);\n        return;\n    }\n# endif\n\n    if (sizeof(TCHAR) == sizeof(char))\n        fmt = (const TCHAR *)fmta;\n    else\n        do {\n            int keepgoing;\n            size_t len_0 = strlen(fmta) + 1, i;\n            WCHAR *fmtw;\n\n            fmtw = (WCHAR *)alloca(len_0 * sizeof(WCHAR));\n            if (fmtw == NULL) {\n                fmt = (const TCHAR *)L\"no stack?\";\n                break;\n            }\n            if (!MultiByteToWideChar(CP_ACP, 0, fmta, len_0, fmtw, len_0))\n                for (i = 0; i < len_0; i++)\n                    fmtw[i] = (WCHAR)fmta[i];\n            for (i = 0; i < len_0; i++) {\n                if (fmtw[i] == L'%')\n                    do {\n                        keepgoing = 0;\n                        switch (fmtw[i + 1]) {\n                        case L'0':\n                        case L'1':\n                        case L'2':\n                        case L'3':\n                        case L'4':\n                        case L'5':\n                        case L'6':\n                        case L'7':\n                        case L'8':\n                        case L'9':\n                        case L'.':\n                        case L'*':\n                        case L'-':\n                            i++;\n                            keepgoing = 1;\n                            break;\n                        case L's':\n                            fmtw[i + 1] = L'S';\n                            break;\n                        case L'S':\n                            fmtw[i + 1] = L's';\n                            break;\n                        case L'c':\n                            fmtw[i + 1] = L'C';\n                            break;\n                        case L'C':\n                            fmtw[i + 1] = L'c';\n                            break;\n                        }\n                    } while (keepgoing);\n            }\n            fmt = (const TCHAR *)fmtw;\n        } while (0);\n\n    va_start(ap, fmta);\n    _vsntprintf(buf, OSSL_NELEM(buf) - 1, fmt, ap);\n    buf[OSSL_NELEM(buf) - 1] = _T('\\0');\n    va_end(ap);\n\n# if defined(_WIN32_WINNT) && _WIN32_WINNT>=0x0333\n#  ifdef OPENSSL_SYS_WIN_CORE\n    /* ONECORE is always NONGUI and NT >= 0x0601 */\n\n    /*\n    * TODO: (For non GUI and no std error cases)\n    * Add event logging feature here.\n    */\n\n#   if !defined(NDEBUG)\n        /*\n        * We are in a situation where we tried to report a critical\n        * error and this failed for some reason. As a last resort,\n        * in debug builds, send output to the debugger or any other\n        * tool like DebugView which can monitor the output.\n        */\n        OutputDebugString(buf);\n#   endif\n#  else\n    /* this -------------v--- guards NT-specific calls */\n    if (check_winnt() && OPENSSL_isservice() > 0) {\n        HANDLE hEventLog = RegisterEventSource(NULL, _T(\"OpenSSL\"));\n\n        if (hEventLog != NULL) {\n            const TCHAR *pmsg = buf;\n\n            if (!ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, 0, 0, NULL,\n                             1, 0, &pmsg, NULL)) {\n#   if !defined(NDEBUG)\n                /*\n                 * We are in a situation where we tried to report a critical\n                 * error and this failed for some reason. As a last resort,\n                 * in debug builds, send output to the debugger or any other\n                 * tool like DebugView which can monitor the output.\n                 */\n                OutputDebugString(pmsg);\n#   endif\n            }\n\n            (void)DeregisterEventSource(hEventLog);\n        }\n    } else {\n        MessageBox(NULL, buf, _T(\"OpenSSL: FATAL\"), MB_OK | MB_ICONERROR);\n    }\n#  endif\n# else\n    MessageBox(NULL, buf, _T(\"OpenSSL: FATAL\"), MB_OK | MB_ICONERROR);\n# endif\n}\n#else\nvoid OPENSSL_showfatal(const char *fmta, ...)\n{\n#ifndef OPENSSL_NO_STDIO\n    va_list ap;\n\n    va_start(ap, fmta);\n    vfprintf(stderr, fmta, ap);\n    va_end(ap);\n#endif\n}\n\nint OPENSSL_isservice(void)\n{\n    return 0;\n}\n#endif\n\nvoid OPENSSL_die(const char *message, const char *file, int line)\n{\n    OPENSSL_showfatal(\"%s:%d: OpenSSL internal error: %s\\n\",\n                      file, line, message);\n#if !defined(_WIN32)\n    abort();\n#else\n    /*\n     * Win32 abort() customarily shows a dialog, but we just did that...\n     */\n# if !defined(_WIN32_WCE)\n    raise(SIGABRT);\n# endif\n    _exit(3);\n#endif\n}\n\n#if !defined(OPENSSL_CPUID_OBJ)\n/*\n * The volatile is used to to ensure that the compiler generates code that reads\n * all values from the array and doesn't try to optimize this away. The standard\n * doesn't actually require this behavior if the original data pointed to is\n * not volatile, but compilers do this in practice anyway.\n *\n * There are also assembler versions of this function.\n */\n# undef CRYPTO_memcmp\nint CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len)\n{\n    size_t i;\n    const volatile unsigned char *a = in_a;\n    const volatile unsigned char *b = in_b;\n    unsigned char x = 0;\n\n    for (i = 0; i < len; i++)\n        x |= a[i] ^ b[i];\n\n    return x;\n}\n\n/*\n * For systems that don't provide an instruction counter register or equivalent.\n */\nuint32_t OPENSSL_rdtsc(void)\n{\n    return 0;\n}\n\nsize_t OPENSSL_instrument_bus(unsigned int *out, size_t cnt)\n{\n    return 0;\n}\n\nsize_t OPENSSL_instrument_bus2(unsigned int *out, size_t cnt, size_t max)\n{\n    return 0;\n}\n#endif\n"
  },
  {
    "path": "cryptomini/e_os.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_E_OS_H\n# define OSSL_E_OS_H\n\n# include <limits.h>\n# include <openssl/opensslconf.h>\n\n# include <openssl/e_os2.h>\n# include <openssl/crypto.h>\n# include \"internal/nelem.h\"\n\n/*\n * <openssl/e_os2.h> contains what we can justify to make visible to the\n * outside; this file e_os.h is not part of the exported interface.\n */\n\n# ifndef DEVRANDOM\n/*\n * set this to a comma-separated list of 'random' device files to try out. By\n * default, we will try to read at least one of these files\n */\n#  define DEVRANDOM \"/dev/urandom\", \"/dev/random\", \"/dev/hwrng\", \"/dev/srandom\"\n#  if defined(__linux) && !defined(__ANDROID__)\n#   ifndef DEVRANDOM_WAIT\n#    define DEVRANDOM_WAIT   \"/dev/random\"\n#   endif\n/*\n * Linux kernels 4.8 and later changes how their random device works and there\n * is no reliable way to tell that /dev/urandom has been seeded -- getentropy(2)\n * should be used instead.\n */\n#   ifndef DEVRANDOM_SAFE_KERNEL\n#    define DEVRANDOM_SAFE_KERNEL        4, 8\n#   endif\n/*\n * Some operating systems do not permit select(2) on their random devices,\n * defining this to zero will force the use of read(2) to extract one byte\n * from /dev/random.\n */\n#   ifndef DEVRANDM_WAIT_USE_SELECT\n#    define DEVRANDM_WAIT_USE_SELECT     1\n#   endif\n/*\n * Define the shared memory identifier used to indicate if the operating\n * system has properly seeded the DEVRANDOM source.\n */\n#   ifndef OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID\n#    define OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID 114\n#   endif\n\n#  endif\n# endif\n# if !defined(OPENSSL_NO_EGD) && !defined(DEVRANDOM_EGD)\n/*\n * set this to a comma-separated list of 'egd' sockets to try out. These\n * sockets will be tried in the order listed in case accessing the device\n * files listed in DEVRANDOM did not return enough randomness.\n */\n#  define DEVRANDOM_EGD \"/var/run/egd-pool\", \"/dev/egd-pool\", \"/etc/egd-pool\", \"/etc/entropy\"\n# endif\n\n# if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)\n#  define NO_CHMOD\n#  define NO_SYSLOG\n# endif\n\n# define get_last_sys_error()    errno\n# define clear_sys_error()       errno=0\n# define set_sys_error(e)        errno=(e)\n\n/********************************************************************\n The Microsoft section\n ********************************************************************/\n# if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)\n#  define WIN32\n# endif\n# if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)\n#  define WINDOWS\n# endif\n# if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)\n#  define MSDOS\n# endif\n\n# ifdef WIN32\n#  undef get_last_sys_error\n#  undef clear_sys_error\n#  undef set_sys_error\n#  define get_last_sys_error()    GetLastError()\n#  define clear_sys_error()       SetLastError(0)\n#  define set_sys_error(e)        SetLastError(e)\n#  if !defined(WINNT)\n#   define WIN_CONSOLE_BUG\n#  endif\n# else\n# endif\n\n# if (defined(WINDOWS) || defined(MSDOS))\n\n#  ifdef __DJGPP__\n#   include <unistd.h>\n#   include <sys/stat.h>\n#   define _setmode setmode\n#   define _O_TEXT O_TEXT\n#   define _O_BINARY O_BINARY\n#   define HAS_LFN_SUPPORT(name)  (pathconf((name), _PC_NAME_MAX) > 12)\n#   undef DEVRANDOM_EGD  /*  Neither MS-DOS nor FreeDOS provide 'egd' sockets.  */\n#   undef DEVRANDOM\n#   define DEVRANDOM \"/dev/urandom\\x24\"\n#  endif                        /* __DJGPP__ */\n\n#  ifndef S_IFDIR\n#   define S_IFDIR     _S_IFDIR\n#  endif\n\n#  ifndef S_IFMT\n#   define S_IFMT      _S_IFMT\n#  endif\n\n#  if !defined(WINNT) && !defined(__DJGPP__)\n#   define NO_SYSLOG\n#  endif\n\n#  ifdef WINDOWS\n#   if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)\n       /*\n        * Defining _WIN32_WINNT here in e_os.h implies certain \"discipline.\"\n        * Most notably we ought to check for availability of each specific\n        * routine that was introduced after denoted _WIN32_WINNT with\n        * GetProcAddress(). Normally newer functions are masked with higher\n        * _WIN32_WINNT in SDK headers. So that if you wish to use them in\n        * some module, you'd need to override _WIN32_WINNT definition in\n        * the target module in order to \"reach for\" prototypes, but replace\n        * calls to new functions with indirect calls. Alternatively it\n        * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs\n        * and check for current OS version instead.\n        */\n#    define _WIN32_WINNT 0x0501\n#   endif\n#   if defined(_WIN32_WINNT) || defined(_WIN32_WCE)\n       /*\n        * Just like defining _WIN32_WINNT including winsock2.h implies\n        * certain \"discipline\" for maintaining [broad] binary compatibility.\n        * As long as structures are invariant among Winsock versions,\n        * it's sufficient to check for specific Winsock2 API availability\n        * at run-time [DSO_global_lookup is recommended]...\n        */\n#    include <winsock2.h>\n#    include <ws2tcpip.h>\n       /* yes, they have to be #included prior to <windows.h> */\n#   endif\n#   include <windows.h>\n#   include <stdio.h>\n#   include <stddef.h>\n#   include <errno.h>\n#   if defined(_WIN32_WCE) && !defined(EACCES)\n#    define EACCES   13\n#   endif\n#   include <string.h>\n#   ifdef _WIN64\n#    define strlen(s) _strlen31(s)\n/* cut strings to 2GB */\nstatic __inline unsigned int _strlen31(const char *str)\n{\n    unsigned int len = 0;\n    while (*str && len < 0x80000000U)\n        str++, len++;\n    return len & 0x7FFFFFFF;\n}\n#   endif\n#   include <malloc.h>\n#   if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin)\n#    if _MSC_VER>=1300 && _MSC_VER<1600\n#     undef stdin\n#     undef stdout\n#     undef stderr\nFILE *__iob_func();\n#     define stdin  (&__iob_func()[0])\n#     define stdout (&__iob_func()[1])\n#     define stderr (&__iob_func()[2])\n#    elif _MSC_VER<1300 && defined(I_CAN_LIVE_WITH_LNK4049)\n#     undef stdin\n#     undef stdout\n#     undef stderr\n         /*\n          * pre-1300 has __p__iob(), but it's available only in msvcrt.lib,\n          * or in other words with /MD. Declaring implicit import, i.e. with\n          * _imp_ prefix, works correctly with all compiler options, but\n          * without /MD results in LINK warning LNK4049: 'locally defined\n          * symbol \"__iob\" imported'.\n          */\nextern FILE *_imp___iob;\n#     define stdin  (&_imp___iob[0])\n#     define stdout (&_imp___iob[1])\n#     define stderr (&_imp___iob[2])\n#    endif\n#   endif\n#  endif\n#  include <io.h>\n#  include <fcntl.h>\n\n#  ifdef OPENSSL_SYS_WINCE\n#   define OPENSSL_NO_POSIX_IO\n#  endif\n\n#  define EXIT(n) exit(n)\n#  define LIST_SEPARATOR_CHAR ';'\n#  ifndef W_OK\n#   define W_OK        2\n#  endif\n#  ifndef R_OK\n#   define R_OK        4\n#  endif\n#  ifdef OPENSSL_SYS_WINCE\n#   define DEFAULT_HOME  \"\"\n#  else\n#   define DEFAULT_HOME  \"C:\"\n#  endif\n\n/* Avoid Visual Studio 13 GetVersion deprecated problems */\n#  if defined(_MSC_VER) && _MSC_VER>=1800\n#   define check_winnt() (1)\n#   define check_win_minplat(x) (1)\n#  else\n#   define check_winnt() (GetVersion() < 0x80000000)\n#   define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x))\n#  endif\n\n# else                          /* The non-microsoft world */\n\n#  if defined(OPENSSL_SYS_VXWORKS)\n#   include <sys/times.h>\n#  else\n#   include <sys/time.h>\n#  endif\n\n#  ifdef OPENSSL_SYS_VMS\n#   define VMS 1\n  /*\n   * some programs don't include stdlib, so exit() and others give implicit\n   * function warnings\n   */\n#   include <stdlib.h>\n#   if defined(__DECC)\n#    include <unistd.h>\n#   else\n#    include <unixlib.h>\n#   endif\n#   define LIST_SEPARATOR_CHAR ','\n  /* We don't have any well-defined random devices on VMS, yet... */\n#   undef DEVRANDOM\n  /*-\n     We need to do this since VMS has the following coding on status codes:\n\n     Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...\n               The important thing to know is that odd numbers are considered\n               good, while even ones are considered errors.\n     Bits 3-15: actual status number\n     Bits 16-27: facility number.  0 is considered \"unknown\"\n     Bits 28-31: control bits.  If bit 28 is set, the shell won't try to\n                 output the message (which, for random codes, just looks ugly)\n\n     So, what we do here is to change 0 to 1 to get the default success status,\n     and everything else is shifted up to fit into the status number field, and\n     the status is tagged as an error, which is what is wanted here.\n\n     Finally, we add the VMS C facility code 0x35a000, because there are some\n     programs, such as Perl, that will reinterpret the code back to something\n     POSIX.  'man perlvms' explains it further.\n\n     NOTE: the perlvms manual wants to turn all codes 2 to 255 into success\n     codes (status type = 1).  I couldn't disagree more.  Fortunately, the\n     status type doesn't seem to bother Perl.\n     -- Richard Levitte\n  */\n#   define EXIT(n)  exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1)\n\n#   define DEFAULT_HOME \"SYS$LOGIN:\"\n\n#  else\n     /* !defined VMS */\n#   ifdef OPENSSL_UNISTD\n#    include OPENSSL_UNISTD\n#   else\n#    include <unistd.h>\n#   endif\n#   include <sys/types.h>\n#   ifdef OPENSSL_SYS_WIN32_CYGWIN\n#    include <io.h>\n#    include <fcntl.h>\n#   endif\n\n#   define LIST_SEPARATOR_CHAR ':'\n#   define EXIT(n)             exit(n)\n#  endif\n\n# endif\n\n/***********************************************/\n\n# if defined(OPENSSL_SYS_WINDOWS)\n#  define strcasecmp _stricmp\n#  define strncasecmp _strnicmp\n#  if (_MSC_VER >= 1310) && !defined(_WIN32_WCE)\n#   define open _open\n#   define fdopen _fdopen\n#   define close _close\n#   ifndef strdup\n#    define strdup _strdup\n#   endif\n#   define unlink _unlink\n#   define fileno _fileno\n#  endif\n# else\n#  include <strings.h>\n# endif\n\n/* vxworks */\n# if defined(OPENSSL_SYS_VXWORKS)\n#  include <ioLib.h>\n#  include <tickLib.h>\n#  include <sysLib.h>\n#  include <vxWorks.h>\n#  include <sockLib.h>\n#  include <taskLib.h>\n\n#  define TTY_STRUCT int\n#  define sleep(a) taskDelay((a) * sysClkRateGet())\n\n/*\n * NOTE: these are implemented by helpers in database app! if the database is\n * not linked, we need to implement them elsewhere\n */\nstruct hostent *gethostbyname(const char *name);\nstruct hostent *gethostbyaddr(const char *addr, int length, int type);\nstruct servent *getservbyname(const char *name, const char *proto);\n\n# endif\n/* end vxworks */\n\n# ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION\n#  define CRYPTO_memcmp memcmp\n# endif\n\n/* unistd.h defines _POSIX_VERSION */\n# if !defined(OPENSSL_NO_SECURE_MEMORY) && defined(OPENSSL_SYS_UNIX) \\\n     && ( (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L)      \\\n          || defined(__sun) || defined(__hpux) || defined(__sgi)      \\\n          || defined(__osf__) )\n#  define OPENSSL_SECURE_MEMORY  /* secure memory is implemented */\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/ec/ec_cvt.c",
    "content": "/*\n * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/err.h>\n#include \"ec_local.h\"\n\nEC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,\n                                 const BIGNUM *b, BN_CTX *ctx)\n{\n    const EC_METHOD *meth;\n    EC_GROUP *ret;\n\n#if defined(OPENSSL_BN_ASM_MONT)\n    /*\n     * This might appear controversial, but the fact is that generic\n     * prime method was observed to deliver better performance even\n     * for NIST primes on a range of platforms, e.g.: 60%-15%\n     * improvement on IA-64, ~25% on ARM, 30%-90% on P4, 20%-25%\n     * in 32-bit build and 35%--12% in 64-bit build on Core2...\n     * Coefficients are relative to optimized bn_nist.c for most\n     * intensive ECDSA verify and ECDH operations for 192- and 521-\n     * bit keys respectively. Choice of these boundary values is\n     * arguable, because the dependency of improvement coefficient\n     * from key length is not a \"monotone\" curve. For example while\n     * 571-bit result is 23% on ARM, 384-bit one is -1%. But it's\n     * generally faster, sometimes \"respectfully\" faster, sometimes\n     * \"tolerably\" slower... What effectively happens is that loop\n     * with bn_mul_add_words is put against bn_mul_mont, and the\n     * latter \"wins\" on short vectors. Correct solution should be\n     * implementing dedicated NxN multiplication subroutines for\n     * small N. But till it materializes, let's stick to generic\n     * prime method...\n     *                                              <appro>\n     */\n    meth = EC_GFp_mont_method();\n#else\n    if (BN_nist_mod_func(p))\n        meth = EC_GFp_nist_method();\n    else\n        meth = EC_GFp_mont_method();\n#endif\n\n    ret = EC_GROUP_new(meth);\n    if (ret == NULL)\n        return NULL;\n\n    if (!EC_GROUP_set_curve(ret, p, a, b, ctx)) {\n        EC_GROUP_clear_free(ret);\n        return NULL;\n    }\n\n    return ret;\n}\n\n#ifndef OPENSSL_NO_EC2M\nEC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,\n                                  const BIGNUM *b, BN_CTX *ctx)\n{\n    const EC_METHOD *meth;\n    EC_GROUP *ret;\n\n    meth = EC_GF2m_simple_method();\n\n    ret = EC_GROUP_new(meth);\n    if (ret == NULL)\n        return NULL;\n\n    if (!EC_GROUP_set_curve(ret, p, a, b, ctx)) {\n        EC_GROUP_clear_free(ret);\n        return NULL;\n    }\n\n    return ret;\n}\n#endif\n"
  },
  {
    "path": "cryptomini/ec/ec_key.c",
    "content": "/*\n * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n#include <string.h>\n#include \"ec_local.h\"\n#include \"internal/refcount.h\"\n#include <openssl/err.h>\n#include <openssl/engine.h>\n#include \"crypto/bn.h\"\n\n// EC_KEY *EC_KEY_new(void)\n// {\n//     return EC_KEY_new_method(NULL);\n// }\n\n// EC_KEY *EC_KEY_new_by_curve_name(int nid)\n// {\n//     EC_KEY *ret = EC_KEY_new();\n//     if (ret == NULL)\n//         return NULL;\n//     ret->group = EC_GROUP_new_by_curve_name(nid);\n//     if (ret->group == NULL) {\n//         EC_KEY_free(ret);\n//         return NULL;\n//     }\n//     if (ret->meth->set_group != NULL\n//         && ret->meth->set_group(ret, ret->group) == 0) {\n//         EC_KEY_free(ret);\n//         return NULL;\n//     }\n//     return ret;\n// }\n\n// void EC_KEY_free(EC_KEY *r)\n// {\n//     int i;\n\n//     if (r == NULL)\n//         return;\n\n//     CRYPTO_DOWN_REF(&r->references, &i, r->lock);\n//     REF_PRINT_COUNT(\"EC_KEY\", r);\n//     if (i > 0)\n//         return;\n//     REF_ASSERT_ISNT(i < 0);\n\n//     if (r->meth != NULL && r->meth->finish != NULL)\n//         r->meth->finish(r);\n\n// #ifndef OPENSSL_NO_ENGINE\n//     ENGINE_finish(r->engine);\n// #endif\n\n//     if (r->group && r->group->meth->keyfinish)\n//         r->group->meth->keyfinish(r);\n\n//     CRYPTO_free_ex_data(CRYPTO_EX_INDEX_EC_KEY, r, &r->ex_data);\n//     CRYPTO_THREAD_lock_free(r->lock);\n//     EC_GROUP_free(r->group);\n//     EC_POINT_free(r->pub_key);\n//     BN_clear_free(r->priv_key);\n\n//     OPENSSL_clear_free((void *)r, sizeof(EC_KEY));\n// }\n\n// EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)\n// {\n//     if (dest == NULL || src == NULL) {\n//         ECerr(EC_F_EC_KEY_COPY, ERR_R_PASSED_NULL_PARAMETER);\n//         return NULL;\n//     }\n//     if (src->meth != dest->meth) {\n//         if (dest->meth->finish != NULL)\n//             dest->meth->finish(dest);\n//         if (dest->group && dest->group->meth->keyfinish)\n//             dest->group->meth->keyfinish(dest);\n// #ifndef OPENSSL_NO_ENGINE\n//         if (ENGINE_finish(dest->engine) == 0)\n//             return 0;\n//         dest->engine = NULL;\n// #endif\n//     }\n//     /* copy the parameters */\n//     if (src->group != NULL) {\n//         const EC_METHOD *meth = EC_GROUP_method_of(src->group);\n//         /* clear the old group */\n//         EC_GROUP_free(dest->group);\n//         dest->group = EC_GROUP_new(meth);\n//         if (dest->group == NULL)\n//             return NULL;\n//         if (!EC_GROUP_copy(dest->group, src->group))\n//             return NULL;\n\n//         /*  copy the public key */\n//         if (src->pub_key != NULL) {\n//             EC_POINT_free(dest->pub_key);\n//             dest->pub_key = EC_POINT_new(src->group);\n//             if (dest->pub_key == NULL)\n//                 return NULL;\n//             if (!EC_POINT_copy(dest->pub_key, src->pub_key))\n//                 return NULL;\n//         }\n//         /* copy the private key */\n//         if (src->priv_key != NULL) {\n//             if (dest->priv_key == NULL) {\n//                 dest->priv_key = BN_new();\n//                 if (dest->priv_key == NULL)\n//                     return NULL;\n//             }\n//             if (!BN_copy(dest->priv_key, src->priv_key))\n//                 return NULL;\n//             if (src->group->meth->keycopy\n//                 && src->group->meth->keycopy(dest, src) == 0)\n//                 return NULL;\n//         }\n//     }\n\n\n//     /* copy the rest */\n//     dest->enc_flag = src->enc_flag;\n//     dest->conv_form = src->conv_form;\n//     dest->version = src->version;\n//     dest->flags = src->flags;\n//     if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_EC_KEY,\n//                             &dest->ex_data, &src->ex_data))\n//         return NULL;\n\n//     if (src->meth != dest->meth) {\n// #ifndef OPENSSL_NO_ENGINE\n//         if (src->engine != NULL && ENGINE_init(src->engine) == 0)\n//             return NULL;\n//         dest->engine = src->engine;\n// #endif\n//         dest->meth = src->meth;\n//     }\n\n//     if (src->meth->copy != NULL && src->meth->copy(dest, src) == 0)\n//         return NULL;\n\n//     return dest;\n// }\n\n// EC_KEY *EC_KEY_dup(const EC_KEY *ec_key)\n// {\n//     EC_KEY *ret = EC_KEY_new_method(ec_key->engine);\n\n//     if (ret == NULL)\n//         return NULL;\n\n//     if (EC_KEY_copy(ret, ec_key) == NULL) {\n//         EC_KEY_free(ret);\n//         return NULL;\n//     }\n//     return ret;\n// }\n\nint EC_KEY_up_ref(EC_KEY *r)\n{\n    int i;\n\n    if (CRYPTO_UP_REF(&r->references, &i, r->lock) <= 0)\n        return 0;\n\n    REF_PRINT_COUNT(\"EC_KEY\", r);\n    REF_ASSERT_ISNT(i < 2);\n    return ((i > 1) ? 1 : 0);\n}\n\nENGINE *EC_KEY_get0_engine(const EC_KEY *eckey)\n{\n    return eckey->engine;\n}\n\nint EC_KEY_generate_key(EC_KEY *eckey)\n{\n    if (eckey == NULL || eckey->group == NULL) {\n        ECerr(EC_F_EC_KEY_GENERATE_KEY, ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n    if (eckey->meth->keygen != NULL)\n        return eckey->meth->keygen(eckey);\n    ECerr(EC_F_EC_KEY_GENERATE_KEY, EC_R_OPERATION_NOT_SUPPORTED);\n    return 0;\n}\n\nint ossl_ec_key_gen(EC_KEY *eckey)\n{\n    return eckey->group->meth->keygen(eckey);\n}\n\nint ec_key_simple_generate_key(EC_KEY *eckey)\n{\n    int ok = 0;\n    BN_CTX *ctx = NULL;\n    BIGNUM *priv_key = NULL;\n    const BIGNUM *order = NULL;\n    EC_POINT *pub_key = NULL;\n\n    if ((ctx = BN_CTX_new()) == NULL)\n        goto err;\n\n    if (eckey->priv_key == NULL) {\n        priv_key = BN_new();\n        if (priv_key == NULL)\n            goto err;\n    } else\n        priv_key = eckey->priv_key;\n\n    order = EC_GROUP_get0_order(eckey->group);\n    if (order == NULL)\n        goto err;\n\n    do\n        if (!BN_priv_rand_range(priv_key, order))\n            goto err;\n    while (BN_is_zero(priv_key)) ;\n\n    if (eckey->pub_key == NULL) {\n        pub_key = EC_POINT_new(eckey->group);\n        if (pub_key == NULL)\n            goto err;\n    } else\n        pub_key = eckey->pub_key;\n\n    if (!EC_POINT_mul(eckey->group, pub_key, priv_key, NULL, NULL, ctx))\n        goto err;\n\n    eckey->priv_key = priv_key;\n    eckey->pub_key = pub_key;\n\n    ok = 1;\n\n err:\n    if (eckey->pub_key == NULL)\n        EC_POINT_free(pub_key);\n    if (eckey->priv_key != priv_key)\n        BN_free(priv_key);\n    BN_CTX_free(ctx);\n    return ok;\n}\n\nint ec_key_simple_generate_public_key(EC_KEY *eckey)\n{\n    return EC_POINT_mul(eckey->group, eckey->pub_key, eckey->priv_key, NULL,\n                        NULL, NULL);\n}\n\nint EC_KEY_check_key(const EC_KEY *eckey)\n{\n    if (eckey == NULL || eckey->group == NULL || eckey->pub_key == NULL) {\n        ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n\n    if (eckey->group->meth->keycheck == NULL) {\n        ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n\n    return eckey->group->meth->keycheck(eckey);\n}\n\nint ec_key_simple_check_key(const EC_KEY *eckey)\n{\n    int ok = 0;\n    BN_CTX *ctx = NULL;\n    const BIGNUM *order = NULL;\n    EC_POINT *point = NULL;\n\n    if (eckey == NULL || eckey->group == NULL || eckey->pub_key == NULL) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n\n    if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_POINT_AT_INFINITY);\n        goto err;\n    }\n\n    if ((ctx = BN_CTX_new()) == NULL)\n        goto err;\n    if ((point = EC_POINT_new(eckey->group)) == NULL)\n        goto err;\n\n    /* testing whether the pub_key is on the elliptic curve */\n    if (EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx) <= 0) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_POINT_IS_NOT_ON_CURVE);\n        goto err;\n    }\n    /* testing whether pub_key * order is the point at infinity */\n    order = eckey->group->order;\n    if (BN_is_zero(order)) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_INVALID_GROUP_ORDER);\n        goto err;\n    }\n    if (!EC_POINT_mul(eckey->group, point, NULL, eckey->pub_key, order, ctx)) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, ERR_R_EC_LIB);\n        goto err;\n    }\n    if (!EC_POINT_is_at_infinity(eckey->group, point)) {\n        ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_WRONG_ORDER);\n        goto err;\n    }\n    /*\n     * in case the priv_key is present : check if generator * priv_key ==\n     * pub_key\n     */\n    if (eckey->priv_key != NULL) {\n        if (BN_cmp(eckey->priv_key, order) >= 0) {\n            ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_WRONG_ORDER);\n            goto err;\n        }\n        if (!EC_POINT_mul(eckey->group, point, eckey->priv_key,\n                          NULL, NULL, ctx)) {\n            ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, ERR_R_EC_LIB);\n            goto err;\n        }\n        if (EC_POINT_cmp(eckey->group, point, eckey->pub_key, ctx) != 0) {\n            ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_INVALID_PRIVATE_KEY);\n            goto err;\n        }\n    }\n    ok = 1;\n err:\n    BN_CTX_free(ctx);\n    EC_POINT_free(point);\n    return ok;\n}\n\nint EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,\n                                             BIGNUM *y)\n{\n    BN_CTX *ctx = NULL;\n    BIGNUM *tx, *ty;\n    EC_POINT *point = NULL;\n    int ok = 0;\n\n    if (key == NULL || key->group == NULL || x == NULL || y == NULL) {\n        ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES,\n              ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n    ctx = BN_CTX_new();\n    if (ctx == NULL)\n        return 0;\n\n    BN_CTX_start(ctx);\n    point = EC_POINT_new(key->group);\n\n    if (point == NULL)\n        goto err;\n\n    tx = BN_CTX_get(ctx);\n    ty = BN_CTX_get(ctx);\n    if (ty == NULL)\n        goto err;\n\n    if (!EC_POINT_set_affine_coordinates(key->group, point, x, y, ctx))\n        goto err;\n    if (!EC_POINT_get_affine_coordinates(key->group, point, tx, ty, ctx))\n        goto err;\n\n    /*\n     * Check if retrieved coordinates match originals and are less than field\n     * order: if not values are out of range.\n     */\n    if (BN_cmp(x, tx) || BN_cmp(y, ty)\n        || (BN_cmp(x, key->group->field) >= 0)\n        || (BN_cmp(y, key->group->field) >= 0)) {\n        ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES,\n              EC_R_COORDINATES_OUT_OF_RANGE);\n        goto err;\n    }\n\n    if (!EC_KEY_set_public_key(key, point))\n        goto err;\n\n    if (EC_KEY_check_key(key) == 0)\n        goto err;\n\n    ok = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(ctx);\n    EC_POINT_free(point);\n    return ok;\n\n}\n\nconst EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)\n{\n    return key->group;\n}\n\nint EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group)\n{\n    if (key->meth->set_group != NULL && key->meth->set_group(key, group) == 0)\n        return 0;\n    EC_GROUP_free(key->group);\n    key->group = EC_GROUP_dup(group);\n    return (key->group == NULL) ? 0 : 1;\n}\n\nconst BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key)\n{\n    return key->priv_key;\n}\n\nint EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *priv_key)\n{\n    int fixed_top;\n    const BIGNUM *order = NULL;\n    BIGNUM *tmp_key = NULL;\n\n    if (key->group == NULL || key->group->meth == NULL)\n        return 0;\n\n    /*\n     * Not only should key->group be set, but it should also be in a valid\n     * fully initialized state.\n     *\n     * Specifically, to operate in constant time, we need that the group order\n     * is set, as we use its length as the fixed public size of any scalar used\n     * as an EC private key.\n     */\n    order = EC_GROUP_get0_order(key->group);\n    if (order == NULL || BN_is_zero(order))\n        return 0; /* This should never happen */\n\n    if (key->group->meth->set_private != NULL\n        && key->group->meth->set_private(key, priv_key) == 0)\n        return 0;\n    if (key->meth->set_private != NULL\n        && key->meth->set_private(key, priv_key) == 0)\n        return 0;\n\n    /*\n     * We should never leak the bit length of the secret scalar in the key,\n     * so we always set the `BN_FLG_CONSTTIME` flag on the internal `BIGNUM`\n     * holding the secret scalar.\n     *\n     * This is important also because `BN_dup()` (and `BN_copy()`) do not\n     * propagate the `BN_FLG_CONSTTIME` flag from the source `BIGNUM`, and\n     * this brings an extra risk of inadvertently losing the flag, even when\n     * the caller specifically set it.\n     *\n     * The propagation has been turned on and off a few times in the past\n     * years because in some conditions has shown unintended consequences in\n     * some code paths, so at the moment we can't fix this in the BN layer.\n     *\n     * In `EC_KEY_set_private_key()` we can work around the propagation by\n     * manually setting the flag after `BN_dup()` as we know for sure that\n     * inside the EC module the `BN_FLG_CONSTTIME` is always treated\n     * correctly and should not generate unintended consequences.\n     *\n     * Setting the BN_FLG_CONSTTIME flag alone is never enough, we also have\n     * to preallocate the BIGNUM internal buffer to a fixed public size big\n     * enough that operations performed during the processing never trigger\n     * a realloc which would leak the size of the scalar through memory\n     * accesses.\n     *\n     * Fixed Length\n     * ------------\n     *\n     * The order of the large prime subgroup of the curve is our choice for\n     * a fixed public size, as that is generally the upper bound for\n     * generating a private key in EC cryptosystems and should fit all valid\n     * secret scalars.\n     *\n     * For preallocating the BIGNUM storage we look at the number of \"words\"\n     * required for the internal representation of the order, and we\n     * preallocate 2 extra \"words\" in case any of the subsequent processing\n     * might temporarily overflow the order length.\n     */\n    tmp_key = BN_dup(priv_key);\n    if (tmp_key == NULL)\n        return 0;\n\n    BN_set_flags(tmp_key, BN_FLG_CONSTTIME);\n\n    fixed_top = bn_get_top(order) + 2;\n    if (bn_wexpand(tmp_key, fixed_top) == NULL) {\n        BN_clear_free(tmp_key);\n        return 0;\n    }\n\n    BN_clear_free(key->priv_key);\n    key->priv_key = tmp_key;\n\n    return 1;\n}\n\nconst EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key)\n{\n    return key->pub_key;\n}\n\nint EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub_key)\n{\n    if (key->meth->set_public != NULL\n        && key->meth->set_public(key, pub_key) == 0)\n        return 0;\n    EC_POINT_free(key->pub_key);\n    key->pub_key = EC_POINT_dup(pub_key, key->group);\n    return (key->pub_key == NULL) ? 0 : 1;\n}\n\nunsigned int EC_KEY_get_enc_flags(const EC_KEY *key)\n{\n    return key->enc_flag;\n}\n\nvoid EC_KEY_set_enc_flags(EC_KEY *key, unsigned int flags)\n{\n    key->enc_flag = flags;\n}\n\npoint_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key)\n{\n    return key->conv_form;\n}\n\nvoid EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform)\n{\n    key->conv_form = cform;\n    if (key->group != NULL)\n        EC_GROUP_set_point_conversion_form(key->group, cform);\n}\n\nvoid EC_KEY_set_asn1_flag(EC_KEY *key, int flag)\n{\n    if (key->group != NULL)\n        EC_GROUP_set_asn1_flag(key->group, flag);\n}\n\nint EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx)\n{\n    if (key->group == NULL)\n        return 0;\n    return EC_GROUP_precompute_mult(key->group, ctx);\n}\n\nint EC_KEY_get_flags(const EC_KEY *key)\n{\n    return key->flags;\n}\n\nvoid EC_KEY_set_flags(EC_KEY *key, int flags)\n{\n    key->flags |= flags;\n}\n\nvoid EC_KEY_clear_flags(EC_KEY *key, int flags)\n{\n    key->flags &= ~flags;\n}\n\nint EC_KEY_decoded_from_explicit_params(const EC_KEY *key)\n{\n    if (key == NULL || key->group == NULL)\n        return -1;\n    return key->group->decoded_from_explicit_params;\n}\n\n// size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form,\n//                         unsigned char **pbuf, BN_CTX *ctx)\n// {\n//     if (key == NULL || key->pub_key == NULL || key->group == NULL)\n//         return 0;\n//     return EC_POINT_point2buf(key->group, key->pub_key, form, pbuf, ctx);\n// }\n\n// int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len,\n//                    BN_CTX *ctx)\n// {\n//     if (key == NULL || key->group == NULL)\n//         return 0;\n//     if (key->pub_key == NULL)\n//         key->pub_key = EC_POINT_new(key->group);\n//     if (key->pub_key == NULL)\n//         return 0;\n//     if (EC_POINT_oct2point(key->group, key->pub_key, buf, len, ctx) == 0)\n//         return 0;\n//     /*\n//      * Save the point conversion form.\n//      * For non-custom curves the first octet of the buffer (excluding\n//      * the last significant bit) contains the point conversion form.\n//      * EC_POINT_oct2point() has already performed sanity checking of\n//      * the buffer so we know it is valid.\n//      */\n//     if ((key->group->meth->flags & EC_FLAGS_CUSTOM_CURVE) == 0)\n//         key->conv_form = (point_conversion_form_t)(buf[0] & ~0x01);\n//     return 1;\n// }\n\nsize_t EC_KEY_priv2oct(const EC_KEY *eckey,\n                       unsigned char *buf, size_t len)\n{\n    if (eckey->group == NULL || eckey->group->meth == NULL)\n        return 0;\n    if (eckey->group->meth->priv2oct == NULL) {\n        ECerr(EC_F_EC_KEY_PRIV2OCT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n\n    return eckey->group->meth->priv2oct(eckey, buf, len);\n}\n\nsize_t ec_key_simple_priv2oct(const EC_KEY *eckey,\n                              unsigned char *buf, size_t len)\n{\n    size_t buf_len;\n\n    buf_len = (EC_GROUP_order_bits(eckey->group) + 7) / 8;\n    if (eckey->priv_key == NULL)\n        return 0;\n    if (buf == NULL)\n        return buf_len;\n    else if (len < buf_len)\n        return 0;\n\n    /* Octetstring may need leading zeros if BN is to short */\n\n    if (BN_bn2binpad(eckey->priv_key, buf, buf_len) == -1) {\n        ECerr(EC_F_EC_KEY_SIMPLE_PRIV2OCT, EC_R_BUFFER_TOO_SMALL);\n        return 0;\n    }\n\n    return buf_len;\n}\n\nint EC_KEY_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len)\n{\n    if (eckey->group == NULL || eckey->group->meth == NULL)\n        return 0;\n    if (eckey->group->meth->oct2priv == NULL) {\n        ECerr(EC_F_EC_KEY_OCT2PRIV, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    return eckey->group->meth->oct2priv(eckey, buf, len);\n}\n\nint ec_key_simple_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len)\n{\n    if (eckey->priv_key == NULL)\n        eckey->priv_key = BN_secure_new();\n    if (eckey->priv_key == NULL) {\n        ECerr(EC_F_EC_KEY_SIMPLE_OCT2PRIV, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    eckey->priv_key = BN_bin2bn(buf, len, eckey->priv_key);\n    if (eckey->priv_key == NULL) {\n        ECerr(EC_F_EC_KEY_SIMPLE_OCT2PRIV, ERR_R_BN_LIB);\n        return 0;\n    }\n    return 1;\n}\n\nsize_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf)\n{\n    size_t len;\n    unsigned char *buf;\n\n    len = EC_KEY_priv2oct(eckey, NULL, 0);\n    if (len == 0)\n        return 0;\n    if ((buf = OPENSSL_malloc(len)) == NULL) {\n        ECerr(EC_F_EC_KEY_PRIV2BUF, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    len = EC_KEY_priv2oct(eckey, buf, len);\n    if (len == 0) {\n        OPENSSL_free(buf);\n        return 0;\n    }\n    *pbuf = buf;\n    return len;\n}\n\nint EC_KEY_can_sign(const EC_KEY *eckey)\n{\n    if (eckey->group == NULL || eckey->group->meth == NULL\n        || (eckey->group->meth->flags & EC_FLAGS_NO_SIGN))\n        return 0;\n    return 1;\n}\n"
  },
  {
    "path": "cryptomini/ec/ec_lib.c",
    "content": "/*\n * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <string.h>\n\n#include <openssl/err.h>\n#include <openssl/opensslv.h>\n\n#include \"ec_local.h\"\n\n/* functions for EC_GROUP objects */\n\nEC_GROUP *EC_GROUP_new(const EC_METHOD *meth)\n{\n    EC_GROUP *ret;\n\n    if (meth == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW, EC_R_SLOT_FULL);\n        return NULL;\n    }\n    if (meth->group_init == 0) {\n        ECerr(EC_F_EC_GROUP_NEW, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return NULL;\n    }\n\n    ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        ECerr(EC_F_EC_GROUP_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n\n    ret->meth = meth;\n    if ((ret->meth->flags & EC_FLAGS_CUSTOM_CURVE) == 0) {\n        ret->order = BN_new();\n        if (ret->order == NULL)\n            goto err;\n        ret->cofactor = BN_new();\n        if (ret->cofactor == NULL)\n            goto err;\n    }\n    ret->asn1_flag = OPENSSL_EC_NAMED_CURVE;\n    ret->asn1_form = POINT_CONVERSION_UNCOMPRESSED;\n    if (!meth->group_init(ret))\n        goto err;\n    return ret;\n\n err:\n    BN_free(ret->order);\n    BN_free(ret->cofactor);\n    OPENSSL_free(ret);\n    return NULL;\n}\n\nvoid EC_pre_comp_free(EC_GROUP *group)\n{\n    switch (group->pre_comp_type) {\n    case PCT_none:\n        break;\n    case PCT_nistz256:\n#ifdef ECP_NISTZ256_ASM\n        EC_nistz256_pre_comp_free(group->pre_comp.nistz256);\n#endif\n        break;\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n    case PCT_nistp224:\n        EC_nistp224_pre_comp_free(group->pre_comp.nistp224);\n        break;\n    case PCT_nistp256:\n        EC_nistp256_pre_comp_free(group->pre_comp.nistp256);\n        break;\n    case PCT_nistp521:\n        EC_nistp521_pre_comp_free(group->pre_comp.nistp521);\n        break;\n#else\n    case PCT_nistp224:\n    case PCT_nistp256:\n    case PCT_nistp521:\n        break;\n#endif\n    case PCT_ec:\n        EC_ec_pre_comp_free(group->pre_comp.ec);\n        break;\n    }\n    group->pre_comp.ec = NULL;\n}\n\nvoid EC_GROUP_free(EC_GROUP *group)\n{\n    if (!group)\n        return;\n\n    if (group->meth->group_finish != 0)\n        group->meth->group_finish(group);\n\n    EC_pre_comp_free(group);\n    BN_MONT_CTX_free(group->mont_data);\n    EC_POINT_free(group->generator);\n    BN_free(group->order);\n    BN_free(group->cofactor);\n    OPENSSL_free(group->seed);\n    OPENSSL_free(group);\n}\n\nvoid EC_GROUP_clear_free(EC_GROUP *group)\n{\n    if (!group)\n        return;\n\n    if (group->meth->group_clear_finish != 0)\n        group->meth->group_clear_finish(group);\n    else if (group->meth->group_finish != 0)\n        group->meth->group_finish(group);\n\n    EC_pre_comp_free(group);\n    BN_MONT_CTX_free(group->mont_data);\n    EC_POINT_clear_free(group->generator);\n    BN_clear_free(group->order);\n    BN_clear_free(group->cofactor);\n    OPENSSL_clear_free(group->seed, group->seed_len);\n    OPENSSL_clear_free(group, sizeof(*group));\n}\n\nint EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)\n{\n    if (dest->meth->group_copy == 0) {\n        ECerr(EC_F_EC_GROUP_COPY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (dest->meth != src->meth) {\n        ECerr(EC_F_EC_GROUP_COPY, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    if (dest == src)\n        return 1;\n\n    dest->curve_name = src->curve_name;\n\n    /* Copy precomputed */\n    dest->pre_comp_type = src->pre_comp_type;\n    switch (src->pre_comp_type) {\n    case PCT_none:\n        dest->pre_comp.ec = NULL;\n        break;\n    case PCT_nistz256:\n#ifdef ECP_NISTZ256_ASM\n        dest->pre_comp.nistz256 = EC_nistz256_pre_comp_dup(src->pre_comp.nistz256);\n#endif\n        break;\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n    case PCT_nistp224:\n        dest->pre_comp.nistp224 = EC_nistp224_pre_comp_dup(src->pre_comp.nistp224);\n        break;\n    case PCT_nistp256:\n        dest->pre_comp.nistp256 = EC_nistp256_pre_comp_dup(src->pre_comp.nistp256);\n        break;\n    case PCT_nistp521:\n        dest->pre_comp.nistp521 = EC_nistp521_pre_comp_dup(src->pre_comp.nistp521);\n        break;\n#else\n    case PCT_nistp224:\n    case PCT_nistp256:\n    case PCT_nistp521:\n        break;\n#endif\n    case PCT_ec:\n        dest->pre_comp.ec = EC_ec_pre_comp_dup(src->pre_comp.ec);\n        break;\n    }\n\n    if (src->mont_data != NULL) {\n        if (dest->mont_data == NULL) {\n            dest->mont_data = BN_MONT_CTX_new();\n            if (dest->mont_data == NULL)\n                return 0;\n        }\n        if (!BN_MONT_CTX_copy(dest->mont_data, src->mont_data))\n            return 0;\n    } else {\n        /* src->generator == NULL */\n        BN_MONT_CTX_free(dest->mont_data);\n        dest->mont_data = NULL;\n    }\n\n    if (src->generator != NULL) {\n        if (dest->generator == NULL) {\n            dest->generator = EC_POINT_new(dest);\n            if (dest->generator == NULL)\n                return 0;\n        }\n        if (!EC_POINT_copy(dest->generator, src->generator))\n            return 0;\n    } else {\n        /* src->generator == NULL */\n        EC_POINT_clear_free(dest->generator);\n        dest->generator = NULL;\n    }\n\n    if ((src->meth->flags & EC_FLAGS_CUSTOM_CURVE) == 0) {\n        if (!BN_copy(dest->order, src->order))\n            return 0;\n        if (!BN_copy(dest->cofactor, src->cofactor))\n            return 0;\n    }\n\n    dest->asn1_flag = src->asn1_flag;\n    dest->asn1_form = src->asn1_form;\n    dest->decoded_from_explicit_params = src->decoded_from_explicit_params;\n\n    if (src->seed) {\n        OPENSSL_free(dest->seed);\n        if ((dest->seed = OPENSSL_malloc(src->seed_len)) == NULL) {\n            ECerr(EC_F_EC_GROUP_COPY, ERR_R_MALLOC_FAILURE);\n            return 0;\n        }\n        if (!memcpy(dest->seed, src->seed, src->seed_len))\n            return 0;\n        dest->seed_len = src->seed_len;\n    } else {\n        OPENSSL_free(dest->seed);\n        dest->seed = NULL;\n        dest->seed_len = 0;\n    }\n\n    return dest->meth->group_copy(dest, src);\n}\n\nEC_GROUP *EC_GROUP_dup(const EC_GROUP *a)\n{\n    EC_GROUP *t = NULL;\n    int ok = 0;\n\n    if (a == NULL)\n        return NULL;\n\n    if ((t = EC_GROUP_new(a->meth)) == NULL)\n        return NULL;\n    if (!EC_GROUP_copy(t, a))\n        goto err;\n\n    ok = 1;\n\n err:\n    if (!ok) {\n        EC_GROUP_free(t);\n        return NULL;\n    }\n        return t;\n}\n\nconst EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group)\n{\n    return group->meth;\n}\n\nint EC_METHOD_get_field_type(const EC_METHOD *meth)\n{\n    return meth->field_type;\n}\n\nstatic int ec_precompute_mont_data(EC_GROUP *);\n\n/*-\n * Try computing cofactor from the generator order (n) and field cardinality (q).\n * This works for all curves of cryptographic interest.\n *\n * Hasse thm: q + 1 - 2*sqrt(q) <= n*h <= q + 1 + 2*sqrt(q)\n * h_min = (q + 1 - 2*sqrt(q))/n\n * h_max = (q + 1 + 2*sqrt(q))/n\n * h_max - h_min = 4*sqrt(q)/n\n * So if n > 4*sqrt(q) holds, there is only one possible value for h:\n * h = \\lfloor (h_min + h_max)/2 \\rceil = \\lfloor (q + 1)/n \\rceil\n *\n * Otherwise, zero cofactor and return success.\n */\nstatic int ec_guess_cofactor(EC_GROUP *group) {\n    int ret = 0;\n    BN_CTX *ctx = NULL;\n    BIGNUM *q = NULL;\n\n    /*-\n     * If the cofactor is too large, we cannot guess it.\n     * The RHS of below is a strict overestimate of lg(4 * sqrt(q))\n     */\n    if (BN_num_bits(group->order) <= (BN_num_bits(group->field) + 1) / 2 + 3) {\n        /* default to 0 */\n        BN_zero(group->cofactor);\n        /* return success */\n        return 1;\n    }\n\n    if ((ctx = BN_CTX_new()) == NULL)\n        return 0;\n\n    BN_CTX_start(ctx);\n    if ((q = BN_CTX_get(ctx)) == NULL)\n        goto err;\n\n    /* set q = 2**m for binary fields; q = p otherwise */\n    if (group->meth->field_type == NID_X9_62_characteristic_two_field) {\n        BN_zero(q);\n        if (!BN_set_bit(q, BN_num_bits(group->field) - 1))\n            goto err;\n    } else {\n        if (!BN_copy(q, group->field))\n            goto err;\n    }\n\n    /* compute h = \\lfloor (q + 1)/n \\rceil = \\lfloor (q + 1 + n/2)/n \\rfloor */\n    if (!BN_rshift1(group->cofactor, group->order) /* n/2 */\n        || !BN_add(group->cofactor, group->cofactor, q) /* q + n/2 */\n        /* q + 1 + n/2 */\n        || !BN_add(group->cofactor, group->cofactor, BN_value_one())\n        /* (q + 1 + n/2)/n */\n        || !BN_div(group->cofactor, NULL, group->cofactor, group->order, ctx))\n        goto err;\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(ctx);\n    return ret;\n}\n\nint EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,\n                           const BIGNUM *order, const BIGNUM *cofactor)\n{\n    if (generator == NULL) {\n        ECerr(EC_F_EC_GROUP_SET_GENERATOR, ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n\n    /* require group->field >= 1 */\n    if (group->field == NULL || BN_is_zero(group->field)\n        || BN_is_negative(group->field)) {\n        ECerr(EC_F_EC_GROUP_SET_GENERATOR, EC_R_INVALID_FIELD);\n        return 0;\n    }\n\n    /*-\n     * - require order >= 1\n     * - enforce upper bound due to Hasse thm: order can be no more than one bit\n     *   longer than field cardinality\n     */\n    if (order == NULL || BN_is_zero(order) || BN_is_negative(order)\n        || BN_num_bits(order) > BN_num_bits(group->field) + 1) {\n        ECerr(EC_F_EC_GROUP_SET_GENERATOR, EC_R_INVALID_GROUP_ORDER);\n        return 0;\n    }\n\n    /*-\n     * Unfortunately the cofactor is an optional field in many standards.\n     * Internally, the lib uses 0 cofactor as a marker for \"unknown cofactor\".\n     * So accept cofactor == NULL or cofactor >= 0.\n     */\n    if (cofactor != NULL && BN_is_negative(cofactor)) {\n        ECerr(EC_F_EC_GROUP_SET_GENERATOR, EC_R_UNKNOWN_COFACTOR);\n        return 0;\n    }\n\n    if (group->generator == NULL) {\n        group->generator = EC_POINT_new(group);\n        if (group->generator == NULL)\n            return 0;\n    }\n    if (!EC_POINT_copy(group->generator, generator))\n        return 0;\n\n    if (!BN_copy(group->order, order))\n        return 0;\n\n    /* Either take the provided positive cofactor, or try to compute it */\n    if (cofactor != NULL && !BN_is_zero(cofactor)) {\n        if (!BN_copy(group->cofactor, cofactor))\n            return 0;\n    } else if (!ec_guess_cofactor(group)) {\n        BN_zero(group->cofactor);\n        return 0;\n    }\n\n    /*\n     * Some groups have an order with\n     * factors of two, which makes the Montgomery setup fail.\n     * |group->mont_data| will be NULL in this case.\n     */\n    if (BN_is_odd(group->order)) {\n        return ec_precompute_mont_data(group);\n    }\n\n    BN_MONT_CTX_free(group->mont_data);\n    group->mont_data = NULL;\n    return 1;\n}\n\nconst EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group)\n{\n    return group->generator;\n}\n\nBN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group)\n{\n    return group->mont_data;\n}\n\nint EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx)\n{\n    if (group->order == NULL)\n        return 0;\n    if (!BN_copy(order, group->order))\n        return 0;\n\n    return !BN_is_zero(order);\n}\n\nconst BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group)\n{\n    return group->order;\n}\n\nint EC_GROUP_order_bits(const EC_GROUP *group)\n{\n    return group->meth->group_order_bits(group);\n}\n\nint EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,\n                          BN_CTX *ctx)\n{\n\n    if (group->cofactor == NULL)\n        return 0;\n    if (!BN_copy(cofactor, group->cofactor))\n        return 0;\n\n    return !BN_is_zero(group->cofactor);\n}\n\nconst BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group)\n{\n    return group->cofactor;\n}\n\nvoid EC_GROUP_set_curve_name(EC_GROUP *group, int nid)\n{\n    group->curve_name = nid;\n}\n\nint EC_GROUP_get_curve_name(const EC_GROUP *group)\n{\n    return group->curve_name;\n}\n\nvoid EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag)\n{\n    group->asn1_flag = flag;\n}\n\nint EC_GROUP_get_asn1_flag(const EC_GROUP *group)\n{\n    return group->asn1_flag;\n}\n\nvoid EC_GROUP_set_point_conversion_form(EC_GROUP *group,\n                                        point_conversion_form_t form)\n{\n    group->asn1_form = form;\n}\n\npoint_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP\n                                                           *group)\n{\n    return group->asn1_form;\n}\n\nsize_t EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *p, size_t len)\n{\n    OPENSSL_free(group->seed);\n    group->seed = NULL;\n    group->seed_len = 0;\n\n    if (!len || !p)\n        return 1;\n\n    if ((group->seed = OPENSSL_malloc(len)) == NULL) {\n        ECerr(EC_F_EC_GROUP_SET_SEED, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    memcpy(group->seed, p, len);\n    group->seed_len = len;\n\n    return len;\n}\n\nunsigned char *EC_GROUP_get0_seed(const EC_GROUP *group)\n{\n    return group->seed;\n}\n\nsize_t EC_GROUP_get_seed_len(const EC_GROUP *group)\n{\n    return group->seed_len;\n}\n\nint EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                       const BIGNUM *b, BN_CTX *ctx)\n{\n    if (group->meth->group_set_curve == 0) {\n        ECerr(EC_F_EC_GROUP_SET_CURVE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    return group->meth->group_set_curve(group, p, a, b, ctx);\n}\n\nint EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,\n                       BN_CTX *ctx)\n{\n    if (group->meth->group_get_curve == NULL) {\n        ECerr(EC_F_EC_GROUP_GET_CURVE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    return group->meth->group_get_curve(group, p, a, b, ctx);\n}\n\n#if OPENSSL_API_COMPAT < 0x10200000L\nint EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                           const BIGNUM *b, BN_CTX *ctx)\n{\n    return EC_GROUP_set_curve(group, p, a, b, ctx);\n}\n\nint EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,\n                           BIGNUM *b, BN_CTX *ctx)\n{\n    return EC_GROUP_get_curve(group, p, a, b, ctx);\n}\n\n# ifndef OPENSSL_NO_EC2M\nint EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                            const BIGNUM *b, BN_CTX *ctx)\n{\n    return EC_GROUP_set_curve(group, p, a, b, ctx);\n}\n\nint EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,\n                            BIGNUM *b, BN_CTX *ctx)\n{\n    return EC_GROUP_get_curve(group, p, a, b, ctx);\n}\n# endif\n#endif\n\nint EC_GROUP_get_degree(const EC_GROUP *group)\n{\n    if (group->meth->group_get_degree == 0) {\n        ECerr(EC_F_EC_GROUP_GET_DEGREE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    return group->meth->group_get_degree(group);\n}\n\nint EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)\n{\n    if (group->meth->group_check_discriminant == 0) {\n        ECerr(EC_F_EC_GROUP_CHECK_DISCRIMINANT,\n              ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    return group->meth->group_check_discriminant(group, ctx);\n}\n\nint EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx)\n{\n    int r = 0;\n    BIGNUM *a1, *a2, *a3, *b1, *b2, *b3;\n    BN_CTX *ctx_new = NULL;\n\n    /* compare the field types */\n    if (EC_METHOD_get_field_type(EC_GROUP_method_of(a)) !=\n        EC_METHOD_get_field_type(EC_GROUP_method_of(b)))\n        return 1;\n    /* compare the curve name (if present in both) */\n    if (EC_GROUP_get_curve_name(a) && EC_GROUP_get_curve_name(b) &&\n        EC_GROUP_get_curve_name(a) != EC_GROUP_get_curve_name(b))\n        return 1;\n    if (a->meth->flags & EC_FLAGS_CUSTOM_CURVE)\n        return 0;\n\n    if (ctx == NULL)\n        ctx_new = ctx = BN_CTX_new();\n    if (ctx == NULL)\n        return -1;\n\n    BN_CTX_start(ctx);\n    a1 = BN_CTX_get(ctx);\n    a2 = BN_CTX_get(ctx);\n    a3 = BN_CTX_get(ctx);\n    b1 = BN_CTX_get(ctx);\n    b2 = BN_CTX_get(ctx);\n    b3 = BN_CTX_get(ctx);\n    if (b3 == NULL) {\n        BN_CTX_end(ctx);\n        BN_CTX_free(ctx_new);\n        return -1;\n    }\n\n    /*\n     * XXX This approach assumes that the external representation of curves\n     * over the same field type is the same.\n     */\n    if (!a->meth->group_get_curve(a, a1, a2, a3, ctx) ||\n        !b->meth->group_get_curve(b, b1, b2, b3, ctx))\n        r = 1;\n\n    if (r || BN_cmp(a1, b1) || BN_cmp(a2, b2) || BN_cmp(a3, b3))\n        r = 1;\n\n    /* XXX EC_POINT_cmp() assumes that the methods are equal */\n    if (r || EC_POINT_cmp(a, EC_GROUP_get0_generator(a),\n                          EC_GROUP_get0_generator(b), ctx))\n        r = 1;\n\n    if (!r) {\n        const BIGNUM *ao, *bo, *ac, *bc;\n        /* compare the order and cofactor */\n        ao = EC_GROUP_get0_order(a);\n        bo = EC_GROUP_get0_order(b);\n        ac = EC_GROUP_get0_cofactor(a);\n        bc = EC_GROUP_get0_cofactor(b);\n        if (ao == NULL || bo == NULL) {\n            BN_CTX_end(ctx);\n            BN_CTX_free(ctx_new);\n            return -1;\n        }\n        if (BN_cmp(ao, bo) || BN_cmp(ac, bc))\n            r = 1;\n    }\n\n    BN_CTX_end(ctx);\n    BN_CTX_free(ctx_new);\n\n    return r;\n}\n\n/* functions for EC_POINT objects */\n\nEC_POINT *EC_POINT_new(const EC_GROUP *group)\n{\n    EC_POINT *ret;\n\n    if (group == NULL) {\n        ECerr(EC_F_EC_POINT_NEW, ERR_R_PASSED_NULL_PARAMETER);\n        return NULL;\n    }\n    if (group->meth->point_init == NULL) {\n        ECerr(EC_F_EC_POINT_NEW, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return NULL;\n    }\n\n    ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        ECerr(EC_F_EC_POINT_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n\n    ret->meth = group->meth;\n    ret->curve_name = group->curve_name;\n\n    if (!ret->meth->point_init(ret)) {\n        OPENSSL_free(ret);\n        return NULL;\n    }\n\n    return ret;\n}\n\nvoid EC_POINT_free(EC_POINT *point)\n{\n    if (!point)\n        return;\n\n    if (point->meth->point_finish != 0)\n        point->meth->point_finish(point);\n    OPENSSL_free(point);\n}\n\nvoid EC_POINT_clear_free(EC_POINT *point)\n{\n    if (!point)\n        return;\n\n    if (point->meth->point_clear_finish != 0)\n        point->meth->point_clear_finish(point);\n    else if (point->meth->point_finish != 0)\n        point->meth->point_finish(point);\n    OPENSSL_clear_free(point, sizeof(*point));\n}\n\nint EC_POINT_copy(EC_POINT *dest, const EC_POINT *src)\n{\n    if (dest->meth->point_copy == 0) {\n        ECerr(EC_F_EC_POINT_COPY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (dest->meth != src->meth\n            || (dest->curve_name != src->curve_name\n                && dest->curve_name != 0\n                && src->curve_name != 0)) {\n        ECerr(EC_F_EC_POINT_COPY, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    if (dest == src)\n        return 1;\n    return dest->meth->point_copy(dest, src);\n}\n\nEC_POINT *EC_POINT_dup(const EC_POINT *a, const EC_GROUP *group)\n{\n    EC_POINT *t;\n    int r;\n\n    if (a == NULL)\n        return NULL;\n\n    t = EC_POINT_new(group);\n    if (t == NULL)\n        return NULL;\n    r = EC_POINT_copy(t, a);\n    if (!r) {\n        EC_POINT_free(t);\n        return NULL;\n    }\n    return t;\n}\n\nconst EC_METHOD *EC_POINT_method_of(const EC_POINT *point)\n{\n    return point->meth;\n}\n\nint EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point)\n{\n    if (group->meth->point_set_to_infinity == 0) {\n        ECerr(EC_F_EC_POINT_SET_TO_INFINITY,\n              ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (group->meth != point->meth) {\n        ECerr(EC_F_EC_POINT_SET_TO_INFINITY, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    return group->meth->point_set_to_infinity(group, point);\n}\n\nint EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             EC_POINT *point, const BIGNUM *x,\n                                             const BIGNUM *y, const BIGNUM *z,\n                                             BN_CTX *ctx)\n{\n    if (group->meth->point_set_Jprojective_coordinates_GFp == 0) {\n        ECerr(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP,\n              ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(point, group)) {\n        ECerr(EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP,\n              EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    return group->meth->point_set_Jprojective_coordinates_GFp(group, point, x,\n                                                              y, z, ctx);\n}\n\nint EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             const EC_POINT *point, BIGNUM *x,\n                                             BIGNUM *y, BIGNUM *z,\n                                             BN_CTX *ctx)\n{\n    if (group->meth->point_get_Jprojective_coordinates_GFp == 0) {\n        ECerr(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP,\n              ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(point, group)) {\n        ECerr(EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP,\n              EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    return group->meth->point_get_Jprojective_coordinates_GFp(group, point, x,\n                                                              y, z, ctx);\n}\n\nint EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,\n                                    const BIGNUM *x, const BIGNUM *y,\n                                    BN_CTX *ctx)\n{\n    if (group->meth->point_set_affine_coordinates == NULL) {\n        ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES,\n              ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(point, group)) {\n        ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    if (!group->meth->point_set_affine_coordinates(group, point, x, y, ctx))\n        return 0;\n\n    if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {\n        ECerr(EC_F_EC_POINT_SET_AFFINE_COORDINATES, EC_R_POINT_IS_NOT_ON_CURVE);\n        return 0;\n    }\n    return 1;\n}\n\n#if OPENSSL_API_COMPAT < 0x10200000L\nint EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,\n                                        EC_POINT *point, const BIGNUM *x,\n                                        const BIGNUM *y, BN_CTX *ctx)\n{\n    return EC_POINT_set_affine_coordinates(group, point, x, y, ctx);\n}\n\n# ifndef OPENSSL_NO_EC2M\nint EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,\n                                         EC_POINT *point, const BIGNUM *x,\n                                         const BIGNUM *y, BN_CTX *ctx)\n{\n    return EC_POINT_set_affine_coordinates(group, point, x, y, ctx);\n}\n# endif\n#endif\n\nint EC_POINT_get_affine_coordinates(const EC_GROUP *group,\n                                    const EC_POINT *point, BIGNUM *x, BIGNUM *y,\n                                    BN_CTX *ctx)\n{\n    if (group->meth->point_get_affine_coordinates == NULL) {\n        ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES,\n              ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(point, group)) {\n        ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    if (EC_POINT_is_at_infinity(group, point)) {\n        ECerr(EC_F_EC_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY);\n        return 0;\n    }\n    return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);\n}\n\n#if OPENSSL_API_COMPAT < 0x10200000L\nint EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,\n                                        const EC_POINT *point, BIGNUM *x,\n                                        BIGNUM *y, BN_CTX *ctx)\n{\n    return EC_POINT_get_affine_coordinates(group, point, x, y, ctx);\n}\n\n# ifndef OPENSSL_NO_EC2M\nint EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,\n                                         const EC_POINT *point, BIGNUM *x,\n                                         BIGNUM *y, BN_CTX *ctx)\n{\n    return EC_POINT_get_affine_coordinates(group, point, x, y, ctx);\n}\n# endif\n#endif\n\nint EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 const EC_POINT *b, BN_CTX *ctx)\n{\n    if (group->meth->add == 0) {\n        ECerr(EC_F_EC_POINT_ADD, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(r, group) || !ec_point_is_compat(a, group)\n        || !ec_point_is_compat(b, group)) {\n        ECerr(EC_F_EC_POINT_ADD, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    return group->meth->add(group, r, a, b, ctx);\n}\n\nint EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 BN_CTX *ctx)\n{\n    if (group->meth->dbl == 0) {\n        ECerr(EC_F_EC_POINT_DBL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(r, group) || !ec_point_is_compat(a, group)) {\n        ECerr(EC_F_EC_POINT_DBL, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    return group->meth->dbl(group, r, a, ctx);\n}\n\nint EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx)\n{\n    if (group->meth->invert == 0) {\n        ECerr(EC_F_EC_POINT_INVERT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(a, group)) {\n        ECerr(EC_F_EC_POINT_INVERT, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    return group->meth->invert(group, a, ctx);\n}\n\nint EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)\n{\n    if (group->meth->is_at_infinity == 0) {\n        ECerr(EC_F_EC_POINT_IS_AT_INFINITY,\n              ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(point, group)) {\n        ECerr(EC_F_EC_POINT_IS_AT_INFINITY, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    return group->meth->is_at_infinity(group, point);\n}\n\n/*\n * Check whether an EC_POINT is on the curve or not. Note that the return\n * value for this function should NOT be treated as a boolean. Return values:\n *  1: The point is on the curve\n *  0: The point is not on the curve\n * -1: An error occurred\n */\nint EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,\n                         BN_CTX *ctx)\n{\n    if (group->meth->is_on_curve == 0) {\n        ECerr(EC_F_EC_POINT_IS_ON_CURVE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(point, group)) {\n        ECerr(EC_F_EC_POINT_IS_ON_CURVE, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    return group->meth->is_on_curve(group, point, ctx);\n}\n\nint EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,\n                 BN_CTX *ctx)\n{\n    if (group->meth->point_cmp == 0) {\n        ECerr(EC_F_EC_POINT_CMP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return -1;\n    }\n    if (!ec_point_is_compat(a, group) || !ec_point_is_compat(b, group)) {\n        ECerr(EC_F_EC_POINT_CMP, EC_R_INCOMPATIBLE_OBJECTS);\n        return -1;\n    }\n    return group->meth->point_cmp(group, a, b, ctx);\n}\n\nint EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)\n{\n    if (group->meth->make_affine == 0) {\n        ECerr(EC_F_EC_POINT_MAKE_AFFINE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    if (!ec_point_is_compat(point, group)) {\n        ECerr(EC_F_EC_POINT_MAKE_AFFINE, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n    return group->meth->make_affine(group, point, ctx);\n}\n\nint EC_POINTs_make_affine(const EC_GROUP *group, size_t num,\n                          EC_POINT *points[], BN_CTX *ctx)\n{\n    size_t i;\n\n    if (group->meth->points_make_affine == 0) {\n        ECerr(EC_F_EC_POINTS_MAKE_AFFINE, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n        return 0;\n    }\n    for (i = 0; i < num; i++) {\n        if (!ec_point_is_compat(points[i], group)) {\n            ECerr(EC_F_EC_POINTS_MAKE_AFFINE, EC_R_INCOMPATIBLE_OBJECTS);\n            return 0;\n        }\n    }\n    return group->meth->points_make_affine(group, num, points, ctx);\n}\n\n/*\n * Functions for point multiplication. If group->meth->mul is 0, we use the\n * wNAF-based implementations in ec_mult.c; otherwise we dispatch through\n * methods.\n */\n\nint EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,\n                  size_t num, const EC_POINT *points[],\n                  const BIGNUM *scalars[], BN_CTX *ctx)\n{\n    int ret = 0;\n    size_t i = 0;\n    BN_CTX *new_ctx = NULL;\n\n    if (!ec_point_is_compat(r, group)) {\n        ECerr(EC_F_EC_POINTS_MUL, EC_R_INCOMPATIBLE_OBJECTS);\n        return 0;\n    }\n\n    if (scalar == NULL && num == 0)\n        return EC_POINT_set_to_infinity(group, r);\n\n    for (i = 0; i < num; i++) {\n        if (!ec_point_is_compat(points[i], group)) {\n            ECerr(EC_F_EC_POINTS_MUL, EC_R_INCOMPATIBLE_OBJECTS);\n            return 0;\n        }\n    }\n\n    if (ctx == NULL && (ctx = new_ctx = BN_CTX_secure_new()) == NULL) {\n        ECerr(EC_F_EC_POINTS_MUL, ERR_R_INTERNAL_ERROR);\n        return 0;\n    }\n\n    if (group->meth->mul != NULL)\n        ret = group->meth->mul(group, r, scalar, num, points, scalars, ctx);\n    else\n        /* use default */\n        ret = ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);\n\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,\n                 const EC_POINT *point, const BIGNUM *p_scalar, BN_CTX *ctx)\n{\n    /* just a convenient interface to EC_POINTs_mul() */\n\n    const EC_POINT *points[1];\n    const BIGNUM *scalars[1];\n\n    points[0] = point;\n    scalars[0] = p_scalar;\n\n    return EC_POINTs_mul(group, r, g_scalar,\n                         (point != NULL\n                          && p_scalar != NULL), points, scalars, ctx);\n}\n\nint EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx)\n{\n    if (group->meth->mul == 0)\n        /* use default */\n        return ec_wNAF_precompute_mult(group, ctx);\n\n    if (group->meth->precompute_mult != 0)\n        return group->meth->precompute_mult(group, ctx);\n    else\n        return 1;               /* nothing to do, so report success */\n}\n\nint EC_GROUP_have_precompute_mult(const EC_GROUP *group)\n{\n    if (group->meth->mul == 0)\n        /* use default */\n        return ec_wNAF_have_precompute_mult(group);\n\n    if (group->meth->have_precompute_mult != 0)\n        return group->meth->have_precompute_mult(group);\n    else\n        return 0;               /* cannot tell whether precomputation has\n                                 * been performed */\n}\n\n/*\n * ec_precompute_mont_data sets |group->mont_data| from |group->order| and\n * returns one on success. On error it returns zero.\n */\nstatic int ec_precompute_mont_data(EC_GROUP *group)\n{\n    BN_CTX *ctx = BN_CTX_new();\n    int ret = 0;\n\n    BN_MONT_CTX_free(group->mont_data);\n    group->mont_data = NULL;\n\n    if (ctx == NULL)\n        goto err;\n\n    group->mont_data = BN_MONT_CTX_new();\n    if (group->mont_data == NULL)\n        goto err;\n\n    if (!BN_MONT_CTX_set(group->mont_data, group->order, ctx)) {\n        BN_MONT_CTX_free(group->mont_data);\n        group->mont_data = NULL;\n        goto err;\n    }\n\n    ret = 1;\n\n err:\n\n    BN_CTX_free(ctx);\n    return ret;\n}\n\n// int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg)\n// {\n//     return CRYPTO_set_ex_data(&key->ex_data, idx, arg);\n// }\n\n// void *EC_KEY_get_ex_data(const EC_KEY *key, int idx)\n// {\n//     return CRYPTO_get_ex_data(&key->ex_data, idx);\n// }\n\nint ec_group_simple_order_bits(const EC_GROUP *group)\n{\n    if (group->order == NULL)\n        return 0;\n    return BN_num_bits(group->order);\n}\n\nstatic int ec_field_inverse_mod_ord(const EC_GROUP *group, BIGNUM *r,\n                                    const BIGNUM *x, BN_CTX *ctx)\n{\n    BIGNUM *e = NULL;\n    BN_CTX *new_ctx = NULL;\n    int ret = 0;\n\n    if (group->mont_data == NULL)\n        return 0;\n\n    if (ctx == NULL && (ctx = new_ctx = BN_CTX_secure_new()) == NULL)\n        return 0;\n\n    BN_CTX_start(ctx);\n    if ((e = BN_CTX_get(ctx)) == NULL)\n        goto err;\n\n    /*-\n     * We want inverse in constant time, therefore we utilize the fact\n     * order must be prime and use Fermats Little Theorem instead.\n     */\n    if (!BN_set_word(e, 2))\n        goto err;\n    if (!BN_sub(e, group->order, e))\n        goto err;\n    /*-\n     * Exponent e is public.\n     * No need for scatter-gather or BN_FLG_CONSTTIME.\n     */\n    if (!BN_mod_exp_mont(r, x, e, group->order, ctx, group->mont_data))\n        goto err;\n\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\n/*-\n * Default behavior, if group->meth->field_inverse_mod_ord is NULL:\n * - When group->order is even, this function returns an error.\n * - When group->order is otherwise composite, the correctness\n *   of the output is not guaranteed.\n * - When x is outside the range [1, group->order), the correctness\n *   of the output is not guaranteed.\n * - Otherwise, this function returns the multiplicative inverse in the\n *   range [1, group->order).\n *\n * EC_METHODs must implement their own field_inverse_mod_ord for\n * other functionality.\n */\nint ec_group_do_inverse_ord(const EC_GROUP *group, BIGNUM *res,\n                            const BIGNUM *x, BN_CTX *ctx)\n{\n    if (group->meth->field_inverse_mod_ord != NULL)\n        return group->meth->field_inverse_mod_ord(group, res, x, ctx);\n    else\n        return ec_field_inverse_mod_ord(group, res, x, ctx);\n}\n\n/*-\n * Coordinate blinding for EC_POINT.\n *\n * The underlying EC_METHOD can optionally implement this function:\n * underlying implementations should return 0 on errors, or 1 on\n * success.\n *\n * This wrapper returns 1 in case the underlying EC_METHOD does not\n * support coordinate blinding.\n */\nint ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx)\n{\n    if (group->meth->blind_coordinates == NULL)\n        return 1; /* ignore if not implemented */\n\n    return group->meth->blind_coordinates(group, p, ctx);\n}\n"
  },
  {
    "path": "cryptomini/ec/ec_local.h",
    "content": "/*\n * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <stdlib.h>\n\n#include <openssl/obj_mac.h>\n#include <openssl/ec.h>\n#include <openssl/bn.h>\n#include \"internal/refcount.h\"\n#include \"crypto/ec.h\"\n\n#if defined(__SUNPRO_C)\n# if __SUNPRO_C >= 0x520\n#  pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)\n# endif\n#endif\n\n/* Use default functions for poin2oct, oct2point and compressed coordinates */\n#define EC_FLAGS_DEFAULT_OCT    0x1\n\n/* Use custom formats for EC_GROUP, EC_POINT and EC_KEY */\n#define EC_FLAGS_CUSTOM_CURVE   0x2\n\n/* Curve does not support signing operations */\n#define EC_FLAGS_NO_SIGN        0x4\n\n/*\n * Structure details are not part of the exported interface, so all this may\n * change in future versions.\n */\n\nstruct ec_method_st {\n    /* Various method flags */\n    int flags;\n    /* used by EC_METHOD_get_field_type: */\n    int field_type;             /* a NID */\n    /*\n     * used by EC_GROUP_new, EC_GROUP_free, EC_GROUP_clear_free,\n     * EC_GROUP_copy:\n     */\n    int (*group_init) (EC_GROUP *);\n    void (*group_finish) (EC_GROUP *);\n    void (*group_clear_finish) (EC_GROUP *);\n    int (*group_copy) (EC_GROUP *, const EC_GROUP *);\n    /* used by EC_GROUP_set_curve, EC_GROUP_get_curve: */\n    int (*group_set_curve) (EC_GROUP *, const BIGNUM *p, const BIGNUM *a,\n                            const BIGNUM *b, BN_CTX *);\n    int (*group_get_curve) (const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b,\n                            BN_CTX *);\n    /* used by EC_GROUP_get_degree: */\n    int (*group_get_degree) (const EC_GROUP *);\n    int (*group_order_bits) (const EC_GROUP *);\n    /* used by EC_GROUP_check: */\n    int (*group_check_discriminant) (const EC_GROUP *, BN_CTX *);\n    /*\n     * used by EC_POINT_new, EC_POINT_free, EC_POINT_clear_free,\n     * EC_POINT_copy:\n     */\n    int (*point_init) (EC_POINT *);\n    void (*point_finish) (EC_POINT *);\n    void (*point_clear_finish) (EC_POINT *);\n    int (*point_copy) (EC_POINT *, const EC_POINT *);\n    /*-\n     * used by EC_POINT_set_to_infinity,\n     * EC_POINT_set_Jprojective_coordinates_GFp,\n     * EC_POINT_get_Jprojective_coordinates_GFp,\n     * EC_POINT_set_affine_coordinates,\n     * EC_POINT_get_affine_coordinates,\n     * EC_POINT_set_compressed_coordinates:\n     */\n    int (*point_set_to_infinity) (const EC_GROUP *, EC_POINT *);\n    int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *,\n                                                  EC_POINT *, const BIGNUM *x,\n                                                  const BIGNUM *y,\n                                                  const BIGNUM *z, BN_CTX *);\n    int (*point_get_Jprojective_coordinates_GFp) (const EC_GROUP *,\n                                                  const EC_POINT *, BIGNUM *x,\n                                                  BIGNUM *y, BIGNUM *z,\n                                                  BN_CTX *);\n    int (*point_set_affine_coordinates) (const EC_GROUP *, EC_POINT *,\n                                         const BIGNUM *x, const BIGNUM *y,\n                                         BN_CTX *);\n    int (*point_get_affine_coordinates) (const EC_GROUP *, const EC_POINT *,\n                                         BIGNUM *x, BIGNUM *y, BN_CTX *);\n    int (*point_set_compressed_coordinates) (const EC_GROUP *, EC_POINT *,\n                                             const BIGNUM *x, int y_bit,\n                                             BN_CTX *);\n    /* used by EC_POINT_point2oct, EC_POINT_oct2point: */\n    size_t (*point2oct) (const EC_GROUP *, const EC_POINT *,\n                         point_conversion_form_t form, unsigned char *buf,\n                         size_t len, BN_CTX *);\n    int (*oct2point) (const EC_GROUP *, EC_POINT *, const unsigned char *buf,\n                      size_t len, BN_CTX *);\n    /* used by EC_POINT_add, EC_POINT_dbl, ECP_POINT_invert: */\n    int (*add) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a,\n                const EC_POINT *b, BN_CTX *);\n    int (*dbl) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);\n    int (*invert) (const EC_GROUP *, EC_POINT *, BN_CTX *);\n    /*\n     * used by EC_POINT_is_at_infinity, EC_POINT_is_on_curve, EC_POINT_cmp:\n     */\n    int (*is_at_infinity) (const EC_GROUP *, const EC_POINT *);\n    int (*is_on_curve) (const EC_GROUP *, const EC_POINT *, BN_CTX *);\n    int (*point_cmp) (const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,\n                      BN_CTX *);\n    /* used by EC_POINT_make_affine, EC_POINTs_make_affine: */\n    int (*make_affine) (const EC_GROUP *, EC_POINT *, BN_CTX *);\n    int (*points_make_affine) (const EC_GROUP *, size_t num, EC_POINT *[],\n                               BN_CTX *);\n    /*\n     * used by EC_POINTs_mul, EC_POINT_mul, EC_POINT_precompute_mult,\n     * EC_POINT_have_precompute_mult (default implementations are used if the\n     * 'mul' pointer is 0):\n     */\n    /*-\n     * mul() calculates the value\n     *\n     *   r := generator * scalar\n     *        + points[0] * scalars[0]\n     *        + ...\n     *        + points[num-1] * scalars[num-1].\n     *\n     * For a fixed point multiplication (scalar != NULL, num == 0)\n     * or a variable point multiplication (scalar == NULL, num == 1),\n     * mul() must use a constant time algorithm: in both cases callers\n     * should provide an input scalar (either scalar or scalars[0])\n     * in the range [0, ec_group_order); for robustness, implementers\n     * should handle the case when the scalar has not been reduced, but\n     * may treat it as an unusual input, without any constant-timeness\n     * guarantee.\n     */\n    int (*mul) (const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,\n                size_t num, const EC_POINT *points[], const BIGNUM *scalars[],\n                BN_CTX *);\n    int (*precompute_mult) (EC_GROUP *group, BN_CTX *);\n    int (*have_precompute_mult) (const EC_GROUP *group);\n    /* internal functions */\n    /*\n     * 'field_mul', 'field_sqr', and 'field_div' can be used by 'add' and\n     * 'dbl' so that the same implementations of point operations can be used\n     * with different optimized implementations of expensive field\n     * operations:\n     */\n    int (*field_mul) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                      const BIGNUM *b, BN_CTX *);\n    int (*field_sqr) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);\n    int (*field_div) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                      const BIGNUM *b, BN_CTX *);\n    /*-\n     * 'field_inv' computes the multiplicative inverse of a in the field,\n     * storing the result in r.\n     *\n     * If 'a' is zero (or equivalent), you'll get an EC_R_CANNOT_INVERT error.\n     */\n    int (*field_inv) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);\n    /* e.g. to Montgomery */\n    int (*field_encode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                         BN_CTX *);\n    /* e.g. from Montgomery */\n    int (*field_decode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                         BN_CTX *);\n    int (*field_set_to_one) (const EC_GROUP *, BIGNUM *r, BN_CTX *);\n    /* private key operations */\n    size_t (*priv2oct)(const EC_KEY *eckey, unsigned char *buf, size_t len);\n    int (*oct2priv)(EC_KEY *eckey, const unsigned char *buf, size_t len);\n    int (*set_private)(EC_KEY *eckey, const BIGNUM *priv_key);\n    int (*keygen)(EC_KEY *eckey);\n    int (*keycheck)(const EC_KEY *eckey);\n    int (*keygenpub)(EC_KEY *eckey);\n    int (*keycopy)(EC_KEY *dst, const EC_KEY *src);\n    void (*keyfinish)(EC_KEY *eckey);\n    /* custom ECDH operation */\n    int (*ecdh_compute_key)(unsigned char **pout, size_t *poutlen,\n                            const EC_POINT *pub_key, const EC_KEY *ecdh);\n    /* Inverse modulo order */\n    int (*field_inverse_mod_ord)(const EC_GROUP *, BIGNUM *r,\n                                 const BIGNUM *x, BN_CTX *);\n    int (*blind_coordinates)(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);\n    int (*ladder_pre)(const EC_GROUP *group,\n                      EC_POINT *r, EC_POINT *s,\n                      EC_POINT *p, BN_CTX *ctx);\n    int (*ladder_step)(const EC_GROUP *group,\n                       EC_POINT *r, EC_POINT *s,\n                       EC_POINT *p, BN_CTX *ctx);\n    int (*ladder_post)(const EC_GROUP *group,\n                       EC_POINT *r, EC_POINT *s,\n                       EC_POINT *p, BN_CTX *ctx);\n};\n\n/*\n * Types and functions to manipulate pre-computed values.\n */\ntypedef struct nistp224_pre_comp_st NISTP224_PRE_COMP;\ntypedef struct nistp256_pre_comp_st NISTP256_PRE_COMP;\ntypedef struct nistp521_pre_comp_st NISTP521_PRE_COMP;\ntypedef struct nistz256_pre_comp_st NISTZ256_PRE_COMP;\ntypedef struct ec_pre_comp_st EC_PRE_COMP;\n\nstruct ec_group_st {\n    const EC_METHOD *meth;\n    EC_POINT *generator;        /* optional */\n    BIGNUM *order, *cofactor;\n    int curve_name;             /* optional NID for named curve */\n    int asn1_flag;              /* flag to control the asn1 encoding */\n    int decoded_from_explicit_params; /* set if decoded from explicit\n                                       * curve parameters encoding */\n    point_conversion_form_t asn1_form;\n    unsigned char *seed;        /* optional seed for parameters (appears in\n                                 * ASN1) */\n    size_t seed_len;\n    /*\n     * The following members are handled by the method functions, even if\n     * they appear generic\n     */\n    /*\n     * Field specification. For curves over GF(p), this is the modulus; for\n     * curves over GF(2^m), this is the irreducible polynomial defining the\n     * field.\n     */\n    BIGNUM *field;\n    /*\n     * Field specification for curves over GF(2^m). The irreducible f(t) is\n     * then of the form: t^poly[0] + t^poly[1] + ... + t^poly[k] where m =\n     * poly[0] > poly[1] > ... > poly[k] = 0. The array is terminated with\n     * poly[k+1]=-1. All elliptic curve irreducibles have at most 5 non-zero\n     * terms.\n     */\n    int poly[6];\n    /*\n     * Curve coefficients. (Here the assumption is that BIGNUMs can be used\n     * or abused for all kinds of fields, not just GF(p).) For characteristic\n     * > 3, the curve is defined by a Weierstrass equation of the form y^2 =\n     * x^3 + a*x + b. For characteristic 2, the curve is defined by an\n     * equation of the form y^2 + x*y = x^3 + a*x^2 + b.\n     */\n    BIGNUM *a, *b;\n    /* enable optimized point arithmetics for special case */\n    int a_is_minus3;\n    /* method-specific (e.g., Montgomery structure) */\n    void *field_data1;\n    /* method-specific */\n    void *field_data2;\n    /* method-specific */\n    int (*field_mod_func) (BIGNUM *, const BIGNUM *, const BIGNUM *,\n                           BN_CTX *);\n    /* data for ECDSA inverse */\n    BN_MONT_CTX *mont_data;\n\n    /*\n     * Precomputed values for speed. The PCT_xxx names match the\n     * pre_comp.xxx union names; see the SETPRECOMP and HAVEPRECOMP\n     * macros, below.\n     */\n    enum {\n        PCT_none,\n        PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256,\n        PCT_ec\n    } pre_comp_type;\n    union {\n        NISTP224_PRE_COMP *nistp224;\n        NISTP256_PRE_COMP *nistp256;\n        NISTP521_PRE_COMP *nistp521;\n        NISTZ256_PRE_COMP *nistz256;\n        EC_PRE_COMP *ec;\n    } pre_comp;\n};\n\n#define SETPRECOMP(g, type, pre) \\\n    g->pre_comp_type = PCT_##type, g->pre_comp.type = pre\n#define HAVEPRECOMP(g, type) \\\n    g->pre_comp_type == PCT_##type && g->pre_comp.type != NULL\n\nstruct ec_key_st {\n    const EC_KEY_METHOD *meth;\n    ENGINE *engine;\n    int version;\n    EC_GROUP *group;\n    EC_POINT *pub_key;\n    BIGNUM *priv_key;\n    unsigned int enc_flag;\n    point_conversion_form_t conv_form;\n    CRYPTO_REF_COUNT references;\n    int flags;\n    CRYPTO_EX_DATA ex_data;\n    CRYPTO_RWLOCK *lock;\n};\n\nstruct ec_point_st {\n    const EC_METHOD *meth;\n    /* NID for the curve if known */\n    int curve_name;\n    /*\n     * All members except 'meth' are handled by the method functions, even if\n     * they appear generic\n     */\n    BIGNUM *X;\n    BIGNUM *Y;\n    BIGNUM *Z;                  /* Jacobian projective coordinates: * (X, Y,\n                                 * Z) represents (X/Z^2, Y/Z^3) if Z != 0 */\n    int Z_is_one;               /* enable optimized point arithmetics for\n                                 * special case */\n};\n\nstatic ossl_inline int ec_point_is_compat(const EC_POINT *point,\n                                          const EC_GROUP *group)\n{\n    if (group->meth != point->meth\n        || (group->curve_name != 0\n            && point->curve_name != 0\n            && group->curve_name != point->curve_name))\n        return 0;\n\n    return 1;\n}\n\nNISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *);\nNISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);\nNISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *);\nNISTZ256_PRE_COMP *EC_nistz256_pre_comp_dup(NISTZ256_PRE_COMP *);\nNISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);\nEC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *);\n\nvoid EC_pre_comp_free(EC_GROUP *group);\nvoid EC_nistp224_pre_comp_free(NISTP224_PRE_COMP *);\nvoid EC_nistp256_pre_comp_free(NISTP256_PRE_COMP *);\nvoid EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *);\nvoid EC_nistz256_pre_comp_free(NISTZ256_PRE_COMP *);\nvoid EC_ec_pre_comp_free(EC_PRE_COMP *);\n\n/*\n * method functions in ec_mult.c (ec_lib.c uses these as defaults if\n * group->method->mul is 0)\n */\nint ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,\n                size_t num, const EC_POINT *points[], const BIGNUM *scalars[],\n                BN_CTX *);\nint ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *);\nint ec_wNAF_have_precompute_mult(const EC_GROUP *group);\n\n/* method functions in ecp_smpl.c */\nint ec_GFp_simple_group_init(EC_GROUP *);\nvoid ec_GFp_simple_group_finish(EC_GROUP *);\nvoid ec_GFp_simple_group_clear_finish(EC_GROUP *);\nint ec_GFp_simple_group_copy(EC_GROUP *, const EC_GROUP *);\nint ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p,\n                                  const BIGNUM *a, const BIGNUM *b, BN_CTX *);\nint ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,\n                                  BIGNUM *b, BN_CTX *);\nint ec_GFp_simple_group_get_degree(const EC_GROUP *);\nint ec_GFp_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);\nint ec_GFp_simple_point_init(EC_POINT *);\nvoid ec_GFp_simple_point_finish(EC_POINT *);\nvoid ec_GFp_simple_point_clear_finish(EC_POINT *);\nint ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *);\nint ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);\nint ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *,\n                                                  EC_POINT *, const BIGNUM *x,\n                                                  const BIGNUM *y,\n                                                  const BIGNUM *z, BN_CTX *);\nint ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *,\n                                                  const EC_POINT *, BIGNUM *x,\n                                                  BIGNUM *y, BIGNUM *z,\n                                                  BN_CTX *);\nint ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *,\n                                               const BIGNUM *x,\n                                               const BIGNUM *y, BN_CTX *);\nint ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *,\n                                               const EC_POINT *, BIGNUM *x,\n                                               BIGNUM *y, BN_CTX *);\nint ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,\n                                             const BIGNUM *x, int y_bit,\n                                             BN_CTX *);\nsize_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *,\n                               point_conversion_form_t form,\n                               unsigned char *buf, size_t len, BN_CTX *);\nint ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *,\n                            const unsigned char *buf, size_t len, BN_CTX *);\nint ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,\n                      const EC_POINT *b, BN_CTX *);\nint ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,\n                      BN_CTX *);\nint ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);\nint ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);\nint ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);\nint ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,\n                      BN_CTX *);\nint ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);\nint ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num,\n                                     EC_POINT *[], BN_CTX *);\nint ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                            const BIGNUM *b, BN_CTX *);\nint ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                            BN_CTX *);\nint ec_GFp_simple_field_inv(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                            BN_CTX *);\nint ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p,\n                                    BN_CTX *ctx);\nint ec_GFp_simple_ladder_pre(const EC_GROUP *group,\n                             EC_POINT *r, EC_POINT *s,\n                             EC_POINT *p, BN_CTX *ctx);\nint ec_GFp_simple_ladder_step(const EC_GROUP *group,\n                              EC_POINT *r, EC_POINT *s,\n                              EC_POINT *p, BN_CTX *ctx);\nint ec_GFp_simple_ladder_post(const EC_GROUP *group,\n                              EC_POINT *r, EC_POINT *s,\n                              EC_POINT *p, BN_CTX *ctx);\n\n/* method functions in ecp_mont.c */\nint ec_GFp_mont_group_init(EC_GROUP *);\nint ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,\n                                const BIGNUM *b, BN_CTX *);\nvoid ec_GFp_mont_group_finish(EC_GROUP *);\nvoid ec_GFp_mont_group_clear_finish(EC_GROUP *);\nint ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *);\nint ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                          const BIGNUM *b, BN_CTX *);\nint ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                          BN_CTX *);\nint ec_GFp_mont_field_inv(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                          BN_CTX *);\nint ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                             BN_CTX *);\nint ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                             BN_CTX *);\nint ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *);\n\n/* method functions in ecp_nist.c */\nint ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src);\nint ec_GFp_nist_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a,\n                                const BIGNUM *b, BN_CTX *);\nint ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                          const BIGNUM *b, BN_CTX *);\nint ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                          BN_CTX *);\n\n/* method functions in ec2_smpl.c */\nint ec_GF2m_simple_group_init(EC_GROUP *);\nvoid ec_GF2m_simple_group_finish(EC_GROUP *);\nvoid ec_GF2m_simple_group_clear_finish(EC_GROUP *);\nint ec_GF2m_simple_group_copy(EC_GROUP *, const EC_GROUP *);\nint ec_GF2m_simple_group_set_curve(EC_GROUP *, const BIGNUM *p,\n                                   const BIGNUM *a, const BIGNUM *b,\n                                   BN_CTX *);\nint ec_GF2m_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a,\n                                   BIGNUM *b, BN_CTX *);\nint ec_GF2m_simple_group_get_degree(const EC_GROUP *);\nint ec_GF2m_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);\nint ec_GF2m_simple_point_init(EC_POINT *);\nvoid ec_GF2m_simple_point_finish(EC_POINT *);\nvoid ec_GF2m_simple_point_clear_finish(EC_POINT *);\nint ec_GF2m_simple_point_copy(EC_POINT *, const EC_POINT *);\nint ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);\nint ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *,\n                                                const BIGNUM *x,\n                                                const BIGNUM *y, BN_CTX *);\nint ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *,\n                                                const EC_POINT *, BIGNUM *x,\n                                                BIGNUM *y, BN_CTX *);\nint ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,\n                                              const BIGNUM *x, int y_bit,\n                                              BN_CTX *);\nsize_t ec_GF2m_simple_point2oct(const EC_GROUP *, const EC_POINT *,\n                                point_conversion_form_t form,\n                                unsigned char *buf, size_t len, BN_CTX *);\nint ec_GF2m_simple_oct2point(const EC_GROUP *, EC_POINT *,\n                             const unsigned char *buf, size_t len, BN_CTX *);\nint ec_GF2m_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,\n                       const EC_POINT *b, BN_CTX *);\nint ec_GF2m_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a,\n                       BN_CTX *);\nint ec_GF2m_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);\nint ec_GF2m_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);\nint ec_GF2m_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);\nint ec_GF2m_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b,\n                       BN_CTX *);\nint ec_GF2m_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);\nint ec_GF2m_simple_points_make_affine(const EC_GROUP *, size_t num,\n                                      EC_POINT *[], BN_CTX *);\nint ec_GF2m_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                             const BIGNUM *b, BN_CTX *);\nint ec_GF2m_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                             BN_CTX *);\nint ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a,\n                             const BIGNUM *b, BN_CTX *);\n\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n/* method functions in ecp_nistp224.c */\nint ec_GFp_nistp224_group_init(EC_GROUP *group);\nint ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p,\n                                    const BIGNUM *a, const BIGNUM *n,\n                                    BN_CTX *);\nint ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP *group,\n                                                 const EC_POINT *point,\n                                                 BIGNUM *x, BIGNUM *y,\n                                                 BN_CTX *ctx);\nint ec_GFp_nistp224_mul(const EC_GROUP *group, EC_POINT *r,\n                        const BIGNUM *scalar, size_t num,\n                        const EC_POINT *points[], const BIGNUM *scalars[],\n                        BN_CTX *);\nint ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r,\n                               const BIGNUM *scalar, size_t num,\n                               const EC_POINT *points[],\n                               const BIGNUM *scalars[], BN_CTX *ctx);\nint ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx);\nint ec_GFp_nistp224_have_precompute_mult(const EC_GROUP *group);\n\n/* method functions in ecp_nistp256.c */\nint ec_GFp_nistp256_group_init(EC_GROUP *group);\nint ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p,\n                                    const BIGNUM *a, const BIGNUM *n,\n                                    BN_CTX *);\nint ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP *group,\n                                                 const EC_POINT *point,\n                                                 BIGNUM *x, BIGNUM *y,\n                                                 BN_CTX *ctx);\nint ec_GFp_nistp256_mul(const EC_GROUP *group, EC_POINT *r,\n                        const BIGNUM *scalar, size_t num,\n                        const EC_POINT *points[], const BIGNUM *scalars[],\n                        BN_CTX *);\nint ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r,\n                               const BIGNUM *scalar, size_t num,\n                               const EC_POINT *points[],\n                               const BIGNUM *scalars[], BN_CTX *ctx);\nint ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx);\nint ec_GFp_nistp256_have_precompute_mult(const EC_GROUP *group);\n\n/* method functions in ecp_nistp521.c */\nint ec_GFp_nistp521_group_init(EC_GROUP *group);\nint ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p,\n                                    const BIGNUM *a, const BIGNUM *n,\n                                    BN_CTX *);\nint ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP *group,\n                                                 const EC_POINT *point,\n                                                 BIGNUM *x, BIGNUM *y,\n                                                 BN_CTX *ctx);\nint ec_GFp_nistp521_mul(const EC_GROUP *group, EC_POINT *r,\n                        const BIGNUM *scalar, size_t num,\n                        const EC_POINT *points[], const BIGNUM *scalars[],\n                        BN_CTX *);\nint ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r,\n                               const BIGNUM *scalar, size_t num,\n                               const EC_POINT *points[],\n                               const BIGNUM *scalars[], BN_CTX *ctx);\nint ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx);\nint ec_GFp_nistp521_have_precompute_mult(const EC_GROUP *group);\n\n/* utility functions in ecp_nistputil.c */\nvoid ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array,\n                                              size_t felem_size,\n                                              void *tmp_felems,\n                                              void (*felem_one) (void *out),\n                                              int (*felem_is_zero) (const void\n                                                                    *in),\n                                              void (*felem_assign) (void *out,\n                                                                    const void\n                                                                    *in),\n                                              void (*felem_square) (void *out,\n                                                                    const void\n                                                                    *in),\n                                              void (*felem_mul) (void *out,\n                                                                 const void\n                                                                 *in1,\n                                                                 const void\n                                                                 *in2),\n                                              void (*felem_inv) (void *out,\n                                                                 const void\n                                                                 *in),\n                                              void (*felem_contract) (void\n                                                                      *out,\n                                                                      const\n                                                                      void\n                                                                      *in));\nvoid ec_GFp_nistp_recode_scalar_bits(unsigned char *sign,\n                                     unsigned char *digit, unsigned char in);\n#endif\nint ec_group_simple_order_bits(const EC_GROUP *group);\n\n#ifdef ECP_NISTZ256_ASM\n/** Returns GFp methods using montgomery multiplication, with x86-64 optimized\n * P256. See http://eprint.iacr.org/2013/816.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistz256_method(void);\n#endif\n\nsize_t ec_key_simple_priv2oct(const EC_KEY *eckey,\n                              unsigned char *buf, size_t len);\nint ec_key_simple_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len);\nint ec_key_simple_generate_key(EC_KEY *eckey);\nint ec_key_simple_generate_public_key(EC_KEY *eckey);\nint ec_key_simple_check_key(const EC_KEY *eckey);\n\nint ec_curve_nid_from_params(const EC_GROUP *group, BN_CTX *ctx);\n\n/* EC_METHOD definitions */\n\nstruct ec_key_method_st {\n    const char *name;\n    int32_t flags;\n    int (*init)(EC_KEY *key);\n    void (*finish)(EC_KEY *key);\n    int (*copy)(EC_KEY *dest, const EC_KEY *src);\n    int (*set_group)(EC_KEY *key, const EC_GROUP *grp);\n    int (*set_private)(EC_KEY *key, const BIGNUM *priv_key);\n    int (*set_public)(EC_KEY *key, const EC_POINT *pub_key);\n    int (*keygen)(EC_KEY *key);\n    int (*compute_key)(unsigned char **pout, size_t *poutlen,\n                       const EC_POINT *pub_key, const EC_KEY *ecdh);\n    int (*sign)(int type, const unsigned char *dgst, int dlen, unsigned char\n                *sig, unsigned int *siglen, const BIGNUM *kinv,\n                const BIGNUM *r, EC_KEY *eckey);\n    int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,\n                      BIGNUM **rp);\n    ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgst_len,\n                           const BIGNUM *in_kinv, const BIGNUM *in_r,\n                           EC_KEY *eckey);\n\n    int (*verify)(int type, const unsigned char *dgst, int dgst_len,\n                  const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);\n    int (*verify_sig)(const unsigned char *dgst, int dgst_len,\n                      const ECDSA_SIG *sig, EC_KEY *eckey);\n};\n\n#define EC_KEY_METHOD_DYNAMIC   1\n\nint ossl_ec_key_gen(EC_KEY *eckey);\nint ossl_ecdh_compute_key(unsigned char **pout, size_t *poutlen,\n                          const EC_POINT *pub_key, const EC_KEY *ecdh);\nint ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,\n                            const EC_POINT *pub_key, const EC_KEY *ecdh);\n\nstruct ECDSA_SIG_st {\n    BIGNUM *r;\n    BIGNUM *s;\n};\n\nint ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp,\n                          BIGNUM **rp);\nint ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen,\n                    unsigned char *sig, unsigned int *siglen,\n                    const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey);\nECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len,\n                               const BIGNUM *in_kinv, const BIGNUM *in_r,\n                               EC_KEY *eckey);\nint ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len,\n                      const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);\nint ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,\n                          const ECDSA_SIG *sig, EC_KEY *eckey);\n\nint ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len,\n                 const uint8_t public_key[32], const uint8_t private_key[32]);\nint ED25519_verify(const uint8_t *message, size_t message_len,\n                   const uint8_t signature[64], const uint8_t public_key[32]);\nvoid ED25519_public_from_private(uint8_t out_public_key[32],\n                                 const uint8_t private_key[32]);\n\nint X25519(uint8_t out_shared_key[32], const uint8_t private_key[32],\n           const uint8_t peer_public_value[32]);\nvoid X25519_public_from_private(uint8_t out_public_value[32],\n                                const uint8_t private_key[32]);\n\n/*-\n * This functions computes a single point multiplication over the EC group,\n * using, at a high level, a Montgomery ladder with conditional swaps, with\n * various timing attack defenses.\n *\n * It performs either a fixed point multiplication\n *          (scalar * generator)\n * when point is NULL, or a variable point multiplication\n *          (scalar * point)\n * when point is not NULL.\n *\n * `scalar` cannot be NULL and should be in the range [0,n) otherwise all\n * constant time bets are off (where n is the cardinality of the EC group).\n *\n * This function expects `group->order` and `group->cardinality` to be well\n * defined and non-zero: it fails with an error code otherwise.\n *\n * NB: This says nothing about the constant-timeness of the ladder step\n * implementation (i.e., the default implementation is based on EC_POINT_add and\n * EC_POINT_dbl, which of course are not constant time themselves) or the\n * underlying multiprecision arithmetic.\n *\n * The product is stored in `r`.\n *\n * This is an internal function: callers are in charge of ensuring that the\n * input parameters `group`, `r`, `scalar` and `ctx` are not NULL.\n *\n * Returns 1 on success, 0 otherwise.\n */\nint ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,\n                         const BIGNUM *scalar, const EC_POINT *point,\n                         BN_CTX *ctx);\n\nint ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx);\n\nstatic ossl_inline int ec_point_ladder_pre(const EC_GROUP *group,\n                                           EC_POINT *r, EC_POINT *s,\n                                           EC_POINT *p, BN_CTX *ctx)\n{\n    if (group->meth->ladder_pre != NULL)\n        return group->meth->ladder_pre(group, r, s, p, ctx);\n\n    if (!EC_POINT_copy(s, p)\n        || !EC_POINT_dbl(group, r, s, ctx))\n        return 0;\n\n    return 1;\n}\n\nstatic ossl_inline int ec_point_ladder_step(const EC_GROUP *group,\n                                            EC_POINT *r, EC_POINT *s,\n                                            EC_POINT *p, BN_CTX *ctx)\n{\n    if (group->meth->ladder_step != NULL)\n        return group->meth->ladder_step(group, r, s, p, ctx);\n\n    if (!EC_POINT_add(group, s, r, s, ctx)\n        || !EC_POINT_dbl(group, r, r, ctx))\n        return 0;\n\n    return 1;\n\n}\n\nstatic ossl_inline int ec_point_ladder_post(const EC_GROUP *group,\n                                            EC_POINT *r, EC_POINT *s,\n                                            EC_POINT *p, BN_CTX *ctx)\n{\n    if (group->meth->ladder_post != NULL)\n        return group->meth->ladder_post(group, r, s, p, ctx);\n\n    return 1;\n}\n"
  },
  {
    "path": "cryptomini/ec/ec_mult.c",
    "content": "/*\n * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <string.h>\n#include <openssl/err.h>\n\n#include \"internal/cryptlib.h\"\n#include \"crypto/bn.h\"\n#include \"ec_local.h\"\n#include \"internal/refcount.h\"\n\n/*\n * This file implements the wNAF-based interleaving multi-exponentiation method\n * Formerly at:\n *   http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/moeller.html#multiexp\n * You might now find it here:\n *   http://link.springer.com/chapter/10.1007%2F3-540-45537-X_13\n *   http://www.bmoeller.de/pdf/TI-01-08.multiexp.pdf\n * For multiplication with precomputation, we use wNAF splitting, formerly at:\n *   http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/moeller.html#fastexp\n */\n\n/* structure for precomputed multiples of the generator */\nstruct ec_pre_comp_st {\n    const EC_GROUP *group;      /* parent EC_GROUP object */\n    size_t blocksize;           /* block size for wNAF splitting */\n    size_t numblocks;           /* max. number of blocks for which we have\n                                 * precomputation */\n    size_t w;                   /* window size */\n    EC_POINT **points;          /* array with pre-calculated multiples of\n                                 * generator: 'num' pointers to EC_POINT\n                                 * objects followed by a NULL */\n    size_t num;                 /* numblocks * 2^(w-1) */\n    CRYPTO_REF_COUNT references;\n    CRYPTO_RWLOCK *lock;\n};\n\nstatic EC_PRE_COMP *ec_pre_comp_new(const EC_GROUP *group)\n{\n    EC_PRE_COMP *ret = NULL;\n\n    if (!group)\n        return NULL;\n\n    ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);\n        return ret;\n    }\n\n    ret->group = group;\n    ret->blocksize = 8;         /* default */\n    ret->w = 4;                 /* default */\n    ret->references = 1;\n\n    ret->lock = CRYPTO_THREAD_lock_new();\n    if (ret->lock == NULL) {\n        ECerr(EC_F_EC_PRE_COMP_NEW, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(ret);\n        return NULL;\n    }\n    return ret;\n}\n\nEC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *pre)\n{\n    int i;\n    if (pre != NULL)\n        CRYPTO_UP_REF(&pre->references, &i, pre->lock);\n    return pre;\n}\n\nvoid EC_ec_pre_comp_free(EC_PRE_COMP *pre)\n{\n    int i;\n\n    if (pre == NULL)\n        return;\n\n    CRYPTO_DOWN_REF(&pre->references, &i, pre->lock);\n    REF_PRINT_COUNT(\"EC_ec\", pre);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n\n    if (pre->points != NULL) {\n        EC_POINT **pts;\n\n        for (pts = pre->points; *pts != NULL; pts++)\n            EC_POINT_free(*pts);\n        OPENSSL_free(pre->points);\n    }\n    CRYPTO_THREAD_lock_free(pre->lock);\n    OPENSSL_free(pre);\n}\n\n#define EC_POINT_BN_set_flags(P, flags) do { \\\n    BN_set_flags((P)->X, (flags)); \\\n    BN_set_flags((P)->Y, (flags)); \\\n    BN_set_flags((P)->Z, (flags)); \\\n} while(0)\n\n/*-\n * This functions computes a single point multiplication over the EC group,\n * using, at a high level, a Montgomery ladder with conditional swaps, with\n * various timing attack defenses.\n *\n * It performs either a fixed point multiplication\n *          (scalar * generator)\n * when point is NULL, or a variable point multiplication\n *          (scalar * point)\n * when point is not NULL.\n *\n * `scalar` cannot be NULL and should be in the range [0,n) otherwise all\n * constant time bets are off (where n is the cardinality of the EC group).\n *\n * This function expects `group->order` and `group->cardinality` to be well\n * defined and non-zero: it fails with an error code otherwise.\n *\n * NB: This says nothing about the constant-timeness of the ladder step\n * implementation (i.e., the default implementation is based on EC_POINT_add and\n * EC_POINT_dbl, which of course are not constant time themselves) or the\n * underlying multiprecision arithmetic.\n *\n * The product is stored in `r`.\n *\n * This is an internal function: callers are in charge of ensuring that the\n * input parameters `group`, `r`, `scalar` and `ctx` are not NULL.\n *\n * Returns 1 on success, 0 otherwise.\n */\nint ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,\n                         const BIGNUM *scalar, const EC_POINT *point,\n                         BN_CTX *ctx)\n{\n    int i, cardinality_bits, group_top, kbit, pbit, Z_is_one;\n    EC_POINT *p = NULL;\n    EC_POINT *s = NULL;\n    BIGNUM *k = NULL;\n    BIGNUM *lambda = NULL;\n    BIGNUM *cardinality = NULL;\n    int ret = 0;\n\n    /* early exit if the input point is the point at infinity */\n    if (point != NULL && EC_POINT_is_at_infinity(group, point))\n        return EC_POINT_set_to_infinity(group, r);\n\n    if (BN_is_zero(group->order)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, EC_R_UNKNOWN_ORDER);\n        return 0;\n    }\n    if (BN_is_zero(group->cofactor)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, EC_R_UNKNOWN_COFACTOR);\n        return 0;\n    }\n\n    BN_CTX_start(ctx);\n\n    if (((p = EC_POINT_new(group)) == NULL)\n        || ((s = EC_POINT_new(group)) == NULL)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    if (point == NULL) {\n        if (!EC_POINT_copy(p, group->generator)) {\n            ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_EC_LIB);\n            goto err;\n        }\n    } else {\n        if (!EC_POINT_copy(p, point)) {\n            ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_EC_LIB);\n            goto err;\n        }\n    }\n\n    EC_POINT_BN_set_flags(p, BN_FLG_CONSTTIME);\n    EC_POINT_BN_set_flags(r, BN_FLG_CONSTTIME);\n    EC_POINT_BN_set_flags(s, BN_FLG_CONSTTIME);\n\n    cardinality = BN_CTX_get(ctx);\n    lambda = BN_CTX_get(ctx);\n    k = BN_CTX_get(ctx);\n    if (k == NULL) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    if (!BN_mul(cardinality, group->order, group->cofactor, ctx)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_BN_LIB);\n        goto err;\n    }\n\n    /*\n     * Group cardinalities are often on a word boundary.\n     * So when we pad the scalar, some timing diff might\n     * pop if it needs to be expanded due to carries.\n     * So expand ahead of time.\n     */\n    cardinality_bits = BN_num_bits(cardinality);\n    group_top = bn_get_top(cardinality);\n    if ((bn_wexpand(k, group_top + 2) == NULL)\n        || (bn_wexpand(lambda, group_top + 2) == NULL)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_BN_LIB);\n        goto err;\n    }\n\n    if (!BN_copy(k, scalar)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_BN_LIB);\n        goto err;\n    }\n\n    BN_set_flags(k, BN_FLG_CONSTTIME);\n\n    if ((BN_num_bits(k) > cardinality_bits) || (BN_is_negative(k))) {\n        /*-\n         * this is an unusual input, and we don't guarantee\n         * constant-timeness\n         */\n        if (!BN_nnmod(k, k, cardinality, ctx)) {\n            ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_BN_LIB);\n            goto err;\n        }\n    }\n\n    if (!BN_add(lambda, k, cardinality)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_BN_LIB);\n        goto err;\n    }\n    BN_set_flags(lambda, BN_FLG_CONSTTIME);\n    if (!BN_add(k, lambda, cardinality)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_BN_LIB);\n        goto err;\n    }\n    /*\n     * lambda := scalar + cardinality\n     * k := scalar + 2*cardinality\n     */\n    kbit = BN_is_bit_set(lambda, cardinality_bits);\n    BN_consttime_swap(kbit, k, lambda, group_top + 2);\n\n    group_top = bn_get_top(group->field);\n    if ((bn_wexpand(s->X, group_top) == NULL)\n        || (bn_wexpand(s->Y, group_top) == NULL)\n        || (bn_wexpand(s->Z, group_top) == NULL)\n        || (bn_wexpand(r->X, group_top) == NULL)\n        || (bn_wexpand(r->Y, group_top) == NULL)\n        || (bn_wexpand(r->Z, group_top) == NULL)\n        || (bn_wexpand(p->X, group_top) == NULL)\n        || (bn_wexpand(p->Y, group_top) == NULL)\n        || (bn_wexpand(p->Z, group_top) == NULL)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_BN_LIB);\n        goto err;\n    }\n\n    /* ensure input point is in affine coords for ladder step efficiency */\n    if (!p->Z_is_one && !EC_POINT_make_affine(group, p, ctx)) {\n            ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_EC_LIB);\n            goto err;\n    }\n\n    /* Initialize the Montgomery ladder */\n    if (!ec_point_ladder_pre(group, r, s, p, ctx)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, EC_R_LADDER_PRE_FAILURE);\n        goto err;\n    }\n\n    /* top bit is a 1, in a fixed pos */\n    pbit = 1;\n\n#define EC_POINT_CSWAP(c, a, b, w, t) do {         \\\n        BN_consttime_swap(c, (a)->X, (b)->X, w);   \\\n        BN_consttime_swap(c, (a)->Y, (b)->Y, w);   \\\n        BN_consttime_swap(c, (a)->Z, (b)->Z, w);   \\\n        t = ((a)->Z_is_one ^ (b)->Z_is_one) & (c); \\\n        (a)->Z_is_one ^= (t);                      \\\n        (b)->Z_is_one ^= (t);                      \\\n} while(0)\n\n    /*-\n     * The ladder step, with branches, is\n     *\n     * k[i] == 0: S = add(R, S), R = dbl(R)\n     * k[i] == 1: R = add(S, R), S = dbl(S)\n     *\n     * Swapping R, S conditionally on k[i] leaves you with state\n     *\n     * k[i] == 0: T, U = R, S\n     * k[i] == 1: T, U = S, R\n     *\n     * Then perform the ECC ops.\n     *\n     * U = add(T, U)\n     * T = dbl(T)\n     *\n     * Which leaves you with state\n     *\n     * k[i] == 0: U = add(R, S), T = dbl(R)\n     * k[i] == 1: U = add(S, R), T = dbl(S)\n     *\n     * Swapping T, U conditionally on k[i] leaves you with state\n     *\n     * k[i] == 0: R, S = T, U\n     * k[i] == 1: R, S = U, T\n     *\n     * Which leaves you with state\n     *\n     * k[i] == 0: S = add(R, S), R = dbl(R)\n     * k[i] == 1: R = add(S, R), S = dbl(S)\n     *\n     * So we get the same logic, but instead of a branch it's a\n     * conditional swap, followed by ECC ops, then another conditional swap.\n     *\n     * Optimization: The end of iteration i and start of i-1 looks like\n     *\n     * ...\n     * CSWAP(k[i], R, S)\n     * ECC\n     * CSWAP(k[i], R, S)\n     * (next iteration)\n     * CSWAP(k[i-1], R, S)\n     * ECC\n     * CSWAP(k[i-1], R, S)\n     * ...\n     *\n     * So instead of two contiguous swaps, you can merge the condition\n     * bits and do a single swap.\n     *\n     * k[i]   k[i-1]    Outcome\n     * 0      0         No Swap\n     * 0      1         Swap\n     * 1      0         Swap\n     * 1      1         No Swap\n     *\n     * This is XOR. pbit tracks the previous bit of k.\n     */\n\n    for (i = cardinality_bits - 1; i >= 0; i--) {\n        kbit = BN_is_bit_set(k, i) ^ pbit;\n        EC_POINT_CSWAP(kbit, r, s, group_top, Z_is_one);\n\n        /* Perform a single step of the Montgomery ladder */\n        if (!ec_point_ladder_step(group, r, s, p, ctx)) {\n            ECerr(EC_F_EC_SCALAR_MUL_LADDER, EC_R_LADDER_STEP_FAILURE);\n            goto err;\n        }\n        /*\n         * pbit logic merges this cswap with that of the\n         * next iteration\n         */\n        pbit ^= kbit;\n    }\n    /* one final cswap to move the right value into r */\n    EC_POINT_CSWAP(pbit, r, s, group_top, Z_is_one);\n#undef EC_POINT_CSWAP\n\n    /* Finalize ladder (and recover full point coordinates) */\n    if (!ec_point_ladder_post(group, r, s, p, ctx)) {\n        ECerr(EC_F_EC_SCALAR_MUL_LADDER, EC_R_LADDER_POST_FAILURE);\n        goto err;\n    }\n\n    ret = 1;\n\n err:\n    EC_POINT_free(p);\n    EC_POINT_clear_free(s);\n    BN_CTX_end(ctx);\n\n    return ret;\n}\n\n#undef EC_POINT_BN_set_flags\n\n/*\n * TODO: table should be optimised for the wNAF-based implementation,\n * sometimes smaller windows will give better performance (thus the\n * boundaries should be increased)\n */\n#define EC_window_bits_for_scalar_size(b) \\\n                ((size_t) \\\n                 ((b) >= 2000 ? 6 : \\\n                  (b) >=  800 ? 5 : \\\n                  (b) >=  300 ? 4 : \\\n                  (b) >=   70 ? 3 : \\\n                  (b) >=   20 ? 2 : \\\n                  1))\n\n/*-\n * Compute\n *      \\sum scalars[i]*points[i],\n * also including\n *      scalar*generator\n * in the addition if scalar != NULL\n */\nint ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,\n                size_t num, const EC_POINT *points[], const BIGNUM *scalars[],\n                BN_CTX *ctx)\n{\n    const EC_POINT *generator = NULL;\n    EC_POINT *tmp = NULL;\n    size_t totalnum;\n    size_t blocksize = 0, numblocks = 0; /* for wNAF splitting */\n    size_t pre_points_per_block = 0;\n    size_t i, j;\n    int k;\n    int r_is_inverted = 0;\n    int r_is_at_infinity = 1;\n    size_t *wsize = NULL;       /* individual window sizes */\n    signed char **wNAF = NULL;  /* individual wNAFs */\n    size_t *wNAF_len = NULL;\n    size_t max_len = 0;\n    size_t num_val;\n    EC_POINT **val = NULL;      /* precomputation */\n    EC_POINT **v;\n    EC_POINT ***val_sub = NULL; /* pointers to sub-arrays of 'val' or\n                                 * 'pre_comp->points' */\n    const EC_PRE_COMP *pre_comp = NULL;\n    int num_scalar = 0;         /* flag: will be set to 1 if 'scalar' must be\n                                 * treated like other scalars, i.e.\n                                 * precomputation is not available */\n    int ret = 0;\n\n    if (!BN_is_zero(group->order) && !BN_is_zero(group->cofactor)) {\n        /*-\n         * Handle the common cases where the scalar is secret, enforcing a\n         * scalar multiplication implementation based on a Montgomery ladder,\n         * with various timing attack defenses.\n         */\n        if ((scalar != group->order) && (scalar != NULL) && (num == 0)) {\n            /*-\n             * In this case we want to compute scalar * GeneratorPoint: this\n             * codepath is reached most prominently by (ephemeral) key\n             * generation of EC cryptosystems (i.e. ECDSA keygen and sign setup,\n             * ECDH keygen/first half), where the scalar is always secret. This\n             * is why we ignore if BN_FLG_CONSTTIME is actually set and we\n             * always call the ladder version.\n             */\n            return ec_scalar_mul_ladder(group, r, scalar, NULL, ctx);\n        }\n        if ((scalar == NULL) && (num == 1) && (scalars[0] != group->order)) {\n            /*-\n             * In this case we want to compute scalar * VariablePoint: this\n             * codepath is reached most prominently by the second half of ECDH,\n             * where the secret scalar is multiplied by the peer's public point.\n             * To protect the secret scalar, we ignore if BN_FLG_CONSTTIME is\n             * actually set and we always call the ladder version.\n             */\n            return ec_scalar_mul_ladder(group, r, scalars[0], points[0], ctx);\n        }\n    }\n\n    if (scalar != NULL) {\n        generator = EC_GROUP_get0_generator(group);\n        if (generator == NULL) {\n            ECerr(EC_F_EC_WNAF_MUL, EC_R_UNDEFINED_GENERATOR);\n            goto err;\n        }\n\n        /* look if we can use precomputed multiples of generator */\n\n        pre_comp = group->pre_comp.ec;\n        if (pre_comp && pre_comp->numblocks\n            && (EC_POINT_cmp(group, generator, pre_comp->points[0], ctx) ==\n                0)) {\n            blocksize = pre_comp->blocksize;\n\n            /*\n             * determine maximum number of blocks that wNAF splitting may\n             * yield (NB: maximum wNAF length is bit length plus one)\n             */\n            numblocks = (BN_num_bits(scalar) / blocksize) + 1;\n\n            /*\n             * we cannot use more blocks than we have precomputation for\n             */\n            if (numblocks > pre_comp->numblocks)\n                numblocks = pre_comp->numblocks;\n\n            pre_points_per_block = (size_t)1 << (pre_comp->w - 1);\n\n            /* check that pre_comp looks sane */\n            if (pre_comp->num != (pre_comp->numblocks * pre_points_per_block)) {\n                ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n        } else {\n            /* can't use precomputation */\n            pre_comp = NULL;\n            numblocks = 1;\n            num_scalar = 1;     /* treat 'scalar' like 'num'-th element of\n                                 * 'scalars' */\n        }\n    }\n\n    totalnum = num + numblocks;\n\n    wsize = OPENSSL_malloc(totalnum * sizeof(wsize[0]));\n    wNAF_len = OPENSSL_malloc(totalnum * sizeof(wNAF_len[0]));\n    /* include space for pivot */\n    wNAF = OPENSSL_malloc((totalnum + 1) * sizeof(wNAF[0]));\n    val_sub = OPENSSL_malloc(totalnum * sizeof(val_sub[0]));\n\n    /* Ensure wNAF is initialised in case we end up going to err */\n    if (wNAF != NULL)\n        wNAF[0] = NULL;         /* preliminary pivot */\n\n    if (wsize == NULL || wNAF_len == NULL || wNAF == NULL || val_sub == NULL) {\n        ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    /*\n     * num_val will be the total number of temporarily precomputed points\n     */\n    num_val = 0;\n\n    for (i = 0; i < num + num_scalar; i++) {\n        size_t bits;\n\n        bits = i < num ? BN_num_bits(scalars[i]) : BN_num_bits(scalar);\n        wsize[i] = EC_window_bits_for_scalar_size(bits);\n        num_val += (size_t)1 << (wsize[i] - 1);\n        wNAF[i + 1] = NULL;     /* make sure we always have a pivot */\n        wNAF[i] =\n            bn_compute_wNAF((i < num ? scalars[i] : scalar), wsize[i],\n                            &wNAF_len[i]);\n        if (wNAF[i] == NULL)\n            goto err;\n        if (wNAF_len[i] > max_len)\n            max_len = wNAF_len[i];\n    }\n\n    if (numblocks) {\n        /* we go here iff scalar != NULL */\n\n        if (pre_comp == NULL) {\n            if (num_scalar != 1) {\n                ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n            /* we have already generated a wNAF for 'scalar' */\n        } else {\n            signed char *tmp_wNAF = NULL;\n            size_t tmp_len = 0;\n\n            if (num_scalar != 0) {\n                ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n\n            /*\n             * use the window size for which we have precomputation\n             */\n            wsize[num] = pre_comp->w;\n            tmp_wNAF = bn_compute_wNAF(scalar, wsize[num], &tmp_len);\n            if (!tmp_wNAF)\n                goto err;\n\n            if (tmp_len <= max_len) {\n                /*\n                 * One of the other wNAFs is at least as long as the wNAF\n                 * belonging to the generator, so wNAF splitting will not buy\n                 * us anything.\n                 */\n\n                numblocks = 1;\n                totalnum = num + 1; /* don't use wNAF splitting */\n                wNAF[num] = tmp_wNAF;\n                wNAF[num + 1] = NULL;\n                wNAF_len[num] = tmp_len;\n                /*\n                 * pre_comp->points starts with the points that we need here:\n                 */\n                val_sub[num] = pre_comp->points;\n            } else {\n                /*\n                 * don't include tmp_wNAF directly into wNAF array - use wNAF\n                 * splitting and include the blocks\n                 */\n\n                signed char *pp;\n                EC_POINT **tmp_points;\n\n                if (tmp_len < numblocks * blocksize) {\n                    /*\n                     * possibly we can do with fewer blocks than estimated\n                     */\n                    numblocks = (tmp_len + blocksize - 1) / blocksize;\n                    if (numblocks > pre_comp->numblocks) {\n                        ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n                        OPENSSL_free(tmp_wNAF);\n                        goto err;\n                    }\n                    totalnum = num + numblocks;\n                }\n\n                /* split wNAF in 'numblocks' parts */\n                pp = tmp_wNAF;\n                tmp_points = pre_comp->points;\n\n                for (i = num; i < totalnum; i++) {\n                    if (i < totalnum - 1) {\n                        wNAF_len[i] = blocksize;\n                        if (tmp_len < blocksize) {\n                            ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n                            OPENSSL_free(tmp_wNAF);\n                            goto err;\n                        }\n                        tmp_len -= blocksize;\n                    } else\n                        /*\n                         * last block gets whatever is left (this could be\n                         * more or less than 'blocksize'!)\n                         */\n                        wNAF_len[i] = tmp_len;\n\n                    wNAF[i + 1] = NULL;\n                    wNAF[i] = OPENSSL_malloc(wNAF_len[i]);\n                    if (wNAF[i] == NULL) {\n                        ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE);\n                        OPENSSL_free(tmp_wNAF);\n                        goto err;\n                    }\n                    memcpy(wNAF[i], pp, wNAF_len[i]);\n                    if (wNAF_len[i] > max_len)\n                        max_len = wNAF_len[i];\n\n                    if (*tmp_points == NULL) {\n                        ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n                        OPENSSL_free(tmp_wNAF);\n                        goto err;\n                    }\n                    val_sub[i] = tmp_points;\n                    tmp_points += pre_points_per_block;\n                    pp += blocksize;\n                }\n                OPENSSL_free(tmp_wNAF);\n            }\n        }\n    }\n\n    /*\n     * All points we precompute now go into a single array 'val'.\n     * 'val_sub[i]' is a pointer to the subarray for the i-th point, or to a\n     * subarray of 'pre_comp->points' if we already have precomputation.\n     */\n    val = OPENSSL_malloc((num_val + 1) * sizeof(val[0]));\n    if (val == NULL) {\n        ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    val[num_val] = NULL;        /* pivot element */\n\n    /* allocate points for precomputation */\n    v = val;\n    for (i = 0; i < num + num_scalar; i++) {\n        val_sub[i] = v;\n        for (j = 0; j < ((size_t)1 << (wsize[i] - 1)); j++) {\n            *v = EC_POINT_new(group);\n            if (*v == NULL)\n                goto err;\n            v++;\n        }\n    }\n    if (!(v == val + num_val)) {\n        ECerr(EC_F_EC_WNAF_MUL, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n\n    if ((tmp = EC_POINT_new(group)) == NULL)\n        goto err;\n\n    /*-\n     * prepare precomputed values:\n     *    val_sub[i][0] :=     points[i]\n     *    val_sub[i][1] := 3 * points[i]\n     *    val_sub[i][2] := 5 * points[i]\n     *    ...\n     */\n    for (i = 0; i < num + num_scalar; i++) {\n        if (i < num) {\n            if (!EC_POINT_copy(val_sub[i][0], points[i]))\n                goto err;\n        } else {\n            if (!EC_POINT_copy(val_sub[i][0], generator))\n                goto err;\n        }\n\n        if (wsize[i] > 1) {\n            if (!EC_POINT_dbl(group, tmp, val_sub[i][0], ctx))\n                goto err;\n            for (j = 1; j < ((size_t)1 << (wsize[i] - 1)); j++) {\n                if (!EC_POINT_add\n                    (group, val_sub[i][j], val_sub[i][j - 1], tmp, ctx))\n                    goto err;\n            }\n        }\n    }\n\n    if (!EC_POINTs_make_affine(group, num_val, val, ctx))\n        goto err;\n\n    r_is_at_infinity = 1;\n\n    for (k = max_len - 1; k >= 0; k--) {\n        if (!r_is_at_infinity) {\n            if (!EC_POINT_dbl(group, r, r, ctx))\n                goto err;\n        }\n\n        for (i = 0; i < totalnum; i++) {\n            if (wNAF_len[i] > (size_t)k) {\n                int digit = wNAF[i][k];\n                int is_neg;\n\n                if (digit) {\n                    is_neg = digit < 0;\n\n                    if (is_neg)\n                        digit = -digit;\n\n                    if (is_neg != r_is_inverted) {\n                        if (!r_is_at_infinity) {\n                            if (!EC_POINT_invert(group, r, ctx))\n                                goto err;\n                        }\n                        r_is_inverted = !r_is_inverted;\n                    }\n\n                    /* digit > 0 */\n\n                    if (r_is_at_infinity) {\n                        if (!EC_POINT_copy(r, val_sub[i][digit >> 1]))\n                            goto err;\n\n                        /*-\n                         * Apply coordinate blinding for EC_POINT.\n                         *\n                         * The underlying EC_METHOD can optionally implement this function:\n                         * ec_point_blind_coordinates() returns 0 in case of errors or 1 on\n                         * success or if coordinate blinding is not implemented for this\n                         * group.\n                         */\n                        if (!ec_point_blind_coordinates(group, r, ctx)) {\n                            ECerr(EC_F_EC_WNAF_MUL, EC_R_POINT_COORDINATES_BLIND_FAILURE);\n                            goto err;\n                        }\n\n                        r_is_at_infinity = 0;\n                    } else {\n                        if (!EC_POINT_add\n                            (group, r, r, val_sub[i][digit >> 1], ctx))\n                            goto err;\n                    }\n                }\n            }\n        }\n    }\n\n    if (r_is_at_infinity) {\n        if (!EC_POINT_set_to_infinity(group, r))\n            goto err;\n    } else {\n        if (r_is_inverted)\n            if (!EC_POINT_invert(group, r, ctx))\n                goto err;\n    }\n\n    ret = 1;\n\n err:\n    EC_POINT_free(tmp);\n    OPENSSL_free(wsize);\n    OPENSSL_free(wNAF_len);\n    if (wNAF != NULL) {\n        signed char **w;\n\n        for (w = wNAF; *w != NULL; w++)\n            OPENSSL_free(*w);\n\n        OPENSSL_free(wNAF);\n    }\n    if (val != NULL) {\n        for (v = val; *v != NULL; v++)\n            EC_POINT_clear_free(*v);\n\n        OPENSSL_free(val);\n    }\n    OPENSSL_free(val_sub);\n    return ret;\n}\n\n/*-\n * ec_wNAF_precompute_mult()\n * creates an EC_PRE_COMP object with preprecomputed multiples of the generator\n * for use with wNAF splitting as implemented in ec_wNAF_mul().\n *\n * 'pre_comp->points' is an array of multiples of the generator\n * of the following form:\n * points[0] =     generator;\n * points[1] = 3 * generator;\n * ...\n * points[2^(w-1)-1] =     (2^(w-1)-1) * generator;\n * points[2^(w-1)]   =     2^blocksize * generator;\n * points[2^(w-1)+1] = 3 * 2^blocksize * generator;\n * ...\n * points[2^(w-1)*(numblocks-1)-1] = (2^(w-1)) *  2^(blocksize*(numblocks-2)) * generator\n * points[2^(w-1)*(numblocks-1)]   =              2^(blocksize*(numblocks-1)) * generator\n * ...\n * points[2^(w-1)*numblocks-1]     = (2^(w-1)) *  2^(blocksize*(numblocks-1)) * generator\n * points[2^(w-1)*numblocks]       = NULL\n */\nint ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)\n{\n    const EC_POINT *generator;\n    EC_POINT *tmp_point = NULL, *base = NULL, **var;\n    BN_CTX *new_ctx = NULL;\n    const BIGNUM *order;\n    size_t i, bits, w, pre_points_per_block, blocksize, numblocks, num;\n    EC_POINT **points = NULL;\n    EC_PRE_COMP *pre_comp;\n    int ret = 0;\n\n    /* if there is an old EC_PRE_COMP object, throw it away */\n    EC_pre_comp_free(group);\n    if ((pre_comp = ec_pre_comp_new(group)) == NULL)\n        return 0;\n\n    generator = EC_GROUP_get0_generator(group);\n    if (generator == NULL) {\n        ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, EC_R_UNDEFINED_GENERATOR);\n        goto err;\n    }\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            goto err;\n    }\n\n    BN_CTX_start(ctx);\n\n    order = EC_GROUP_get0_order(group);\n    if (order == NULL)\n        goto err;\n    if (BN_is_zero(order)) {\n        ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, EC_R_UNKNOWN_ORDER);\n        goto err;\n    }\n\n    bits = BN_num_bits(order);\n    /*\n     * The following parameters mean we precompute (approximately) one point\n     * per bit. TBD: The combination 8, 4 is perfect for 160 bits; for other\n     * bit lengths, other parameter combinations might provide better\n     * efficiency.\n     */\n    blocksize = 8;\n    w = 4;\n    if (EC_window_bits_for_scalar_size(bits) > w) {\n        /* let's not make the window too small ... */\n        w = EC_window_bits_for_scalar_size(bits);\n    }\n\n    numblocks = (bits + blocksize - 1) / blocksize; /* max. number of blocks\n                                                     * to use for wNAF\n                                                     * splitting */\n\n    pre_points_per_block = (size_t)1 << (w - 1);\n    num = pre_points_per_block * numblocks; /* number of points to compute\n                                             * and store */\n\n    points = OPENSSL_malloc(sizeof(*points) * (num + 1));\n    if (points == NULL) {\n        ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    var = points;\n    var[num] = NULL;            /* pivot */\n    for (i = 0; i < num; i++) {\n        if ((var[i] = EC_POINT_new(group)) == NULL) {\n            ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n    }\n\n    if ((tmp_point = EC_POINT_new(group)) == NULL\n        || (base = EC_POINT_new(group)) == NULL) {\n        ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    if (!EC_POINT_copy(base, generator))\n        goto err;\n\n    /* do the precomputation */\n    for (i = 0; i < numblocks; i++) {\n        size_t j;\n\n        if (!EC_POINT_dbl(group, tmp_point, base, ctx))\n            goto err;\n\n        if (!EC_POINT_copy(*var++, base))\n            goto err;\n\n        for (j = 1; j < pre_points_per_block; j++, var++) {\n            /*\n             * calculate odd multiples of the current base point\n             */\n            if (!EC_POINT_add(group, *var, tmp_point, *(var - 1), ctx))\n                goto err;\n        }\n\n        if (i < numblocks - 1) {\n            /*\n             * get the next base (multiply current one by 2^blocksize)\n             */\n            size_t k;\n\n            if (blocksize <= 2) {\n                ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_INTERNAL_ERROR);\n                goto err;\n            }\n\n            if (!EC_POINT_dbl(group, base, tmp_point, ctx))\n                goto err;\n            for (k = 2; k < blocksize; k++) {\n                if (!EC_POINT_dbl(group, base, base, ctx))\n                    goto err;\n            }\n        }\n    }\n\n    if (!EC_POINTs_make_affine(group, num, points, ctx))\n        goto err;\n\n    pre_comp->group = group;\n    pre_comp->blocksize = blocksize;\n    pre_comp->numblocks = numblocks;\n    pre_comp->w = w;\n    pre_comp->points = points;\n    points = NULL;\n    pre_comp->num = num;\n    SETPRECOMP(group, ec, pre_comp);\n    pre_comp = NULL;\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    EC_ec_pre_comp_free(pre_comp);\n    if (points) {\n        EC_POINT **p;\n\n        for (p = points; *p != NULL; p++)\n            EC_POINT_free(*p);\n        OPENSSL_free(points);\n    }\n    EC_POINT_free(tmp_point);\n    EC_POINT_free(base);\n    return ret;\n}\n\nint ec_wNAF_have_precompute_mult(const EC_GROUP *group)\n{\n    return HAVEPRECOMP(group, ec);\n}\n"
  },
  {
    "path": "cryptomini/ec/ecdh_ossl.c",
    "content": "/*\n * Copyright 2002-2019 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <string.h>\n#include <limits.h>\n\n#include \"internal/cryptlib.h\"\n\n#include <openssl/err.h>\n#include <openssl/bn.h>\n#include <openssl/objects.h>\n#include <openssl/ec.h>\n#include \"ec_local.h\"\n\nint ossl_ecdh_compute_key(unsigned char **psec, size_t *pseclen,\n                          const EC_POINT *pub_key, const EC_KEY *ecdh)\n{\n    if (ecdh->group->meth->ecdh_compute_key == NULL) {\n        ECerr(EC_F_OSSL_ECDH_COMPUTE_KEY, EC_R_CURVE_DOES_NOT_SUPPORT_ECDH);\n        return 0;\n    }\n\n    return ecdh->group->meth->ecdh_compute_key(psec, pseclen, pub_key, ecdh);\n}\n\n/*-\n * This implementation is based on the following primitives in the IEEE 1363 standard:\n *  - ECKAS-DH1\n *  - ECSVDP-DH\n */\nint ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen,\n                            const EC_POINT *pub_key, const EC_KEY *ecdh)\n{\n    BN_CTX *ctx;\n    EC_POINT *tmp = NULL;\n    BIGNUM *x = NULL;\n    const BIGNUM *priv_key;\n    const EC_GROUP *group;\n    int ret = 0;\n    size_t buflen, len;\n    unsigned char *buf = NULL;\n\n    if ((ctx = BN_CTX_new()) == NULL)\n        goto err;\n    BN_CTX_start(ctx);\n    x = BN_CTX_get(ctx);\n    if (x == NULL) {\n        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    priv_key = EC_KEY_get0_private_key(ecdh);\n    if (priv_key == NULL) {\n        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_MISSING_PRIVATE_KEY);\n        goto err;\n    }\n\n    group = EC_KEY_get0_group(ecdh);\n\n    if (EC_KEY_get_flags(ecdh) & EC_FLAG_COFACTOR_ECDH) {\n        if (!EC_GROUP_get_cofactor(group, x, NULL) ||\n            !BN_mul(x, x, priv_key, ctx)) {\n            ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        priv_key = x;\n    }\n\n    if ((tmp = EC_POINT_new(group)) == NULL) {\n        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    if (!EC_POINT_mul(group, tmp, NULL, pub_key, priv_key, ctx)) {\n        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE);\n        goto err;\n    }\n\n    if (!EC_POINT_get_affine_coordinates(group, tmp, x, NULL, ctx)) {\n        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE);\n        goto err;\n    }\n\n    buflen = (EC_GROUP_get_degree(group) + 7) / 8;\n    len = BN_num_bytes(x);\n    if (len > buflen) {\n        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    if ((buf = OPENSSL_malloc(buflen)) == NULL) {\n        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n\n    memset(buf, 0, buflen - len);\n    if (len != (size_t)BN_bn2bin(x, buf + buflen - len)) {\n        ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, ERR_R_BN_LIB);\n        goto err;\n    }\n\n    *pout = buf;\n    *poutlen = buflen;\n    buf = NULL;\n\n    ret = 1;\n\n err:\n    EC_POINT_clear_free(tmp);\n    BN_CTX_end(ctx);\n    BN_CTX_free(ctx);\n    OPENSSL_free(buf);\n    return ret;\n}\n"
  },
  {
    "path": "cryptomini/ec/ecp_mont.c",
    "content": "/*\n * Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/err.h>\n\n#include \"ec_local.h\"\n\nconst EC_METHOD *EC_GFp_mont_method(void)\n{\n    static const EC_METHOD ret = {\n        EC_FLAGS_DEFAULT_OCT,\n        NID_X9_62_prime_field,\n        ec_GFp_mont_group_init,\n        ec_GFp_mont_group_finish,\n        ec_GFp_mont_group_clear_finish,\n        ec_GFp_mont_group_copy,\n        ec_GFp_mont_group_set_curve,\n        ec_GFp_simple_group_get_curve,\n        ec_GFp_simple_group_get_degree,\n        ec_group_simple_order_bits,\n        ec_GFp_simple_group_check_discriminant,\n        ec_GFp_simple_point_init,\n        ec_GFp_simple_point_finish,\n        ec_GFp_simple_point_clear_finish,\n        ec_GFp_simple_point_copy,\n        ec_GFp_simple_point_set_to_infinity,\n        ec_GFp_simple_set_Jprojective_coordinates_GFp,\n        ec_GFp_simple_get_Jprojective_coordinates_GFp,\n        ec_GFp_simple_point_set_affine_coordinates,\n        ec_GFp_simple_point_get_affine_coordinates,\n        0, 0, 0,\n        ec_GFp_simple_add,\n        ec_GFp_simple_dbl,\n        ec_GFp_simple_invert,\n        ec_GFp_simple_is_at_infinity,\n        ec_GFp_simple_is_on_curve,\n        ec_GFp_simple_cmp,\n        ec_GFp_simple_make_affine,\n        ec_GFp_simple_points_make_affine,\n        0 /* mul */ ,\n        0 /* precompute_mult */ ,\n        0 /* have_precompute_mult */ ,\n        ec_GFp_mont_field_mul,\n        ec_GFp_mont_field_sqr,\n        0 /* field_div */ ,\n        ec_GFp_mont_field_inv,\n        ec_GFp_mont_field_encode,\n        ec_GFp_mont_field_decode,\n        ec_GFp_mont_field_set_to_one,\n        ec_key_simple_priv2oct,\n        ec_key_simple_oct2priv,\n        0, /* set private */\n        ec_key_simple_generate_key,\n        ec_key_simple_check_key,\n        ec_key_simple_generate_public_key,\n        0, /* keycopy */\n        0, /* keyfinish */\n        ecdh_simple_compute_key,\n        0, /* field_inverse_mod_ord */\n        ec_GFp_simple_blind_coordinates,\n        ec_GFp_simple_ladder_pre,\n        ec_GFp_simple_ladder_step,\n        ec_GFp_simple_ladder_post\n    };\n\n    return &ret;\n}\n\nint ec_GFp_mont_group_init(EC_GROUP *group)\n{\n    int ok;\n\n    ok = ec_GFp_simple_group_init(group);\n    group->field_data1 = NULL;\n    group->field_data2 = NULL;\n    return ok;\n}\n\nvoid ec_GFp_mont_group_finish(EC_GROUP *group)\n{\n    BN_MONT_CTX_free(group->field_data1);\n    group->field_data1 = NULL;\n    BN_free(group->field_data2);\n    group->field_data2 = NULL;\n    ec_GFp_simple_group_finish(group);\n}\n\nvoid ec_GFp_mont_group_clear_finish(EC_GROUP *group)\n{\n    BN_MONT_CTX_free(group->field_data1);\n    group->field_data1 = NULL;\n    BN_clear_free(group->field_data2);\n    group->field_data2 = NULL;\n    ec_GFp_simple_group_clear_finish(group);\n}\n\nint ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src)\n{\n    BN_MONT_CTX_free(dest->field_data1);\n    dest->field_data1 = NULL;\n    BN_clear_free(dest->field_data2);\n    dest->field_data2 = NULL;\n\n    if (!ec_GFp_simple_group_copy(dest, src))\n        return 0;\n\n    if (src->field_data1 != NULL) {\n        dest->field_data1 = BN_MONT_CTX_new();\n        if (dest->field_data1 == NULL)\n            return 0;\n        if (!BN_MONT_CTX_copy(dest->field_data1, src->field_data1))\n            goto err;\n    }\n    if (src->field_data2 != NULL) {\n        dest->field_data2 = BN_dup(src->field_data2);\n        if (dest->field_data2 == NULL)\n            goto err;\n    }\n\n    return 1;\n\n err:\n    BN_MONT_CTX_free(dest->field_data1);\n    dest->field_data1 = NULL;\n    return 0;\n}\n\nint ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p,\n                                const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BN_MONT_CTX *mont = NULL;\n    BIGNUM *one = NULL;\n    int ret = 0;\n\n    BN_MONT_CTX_free(group->field_data1);\n    group->field_data1 = NULL;\n    BN_free(group->field_data2);\n    group->field_data2 = NULL;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n\n    mont = BN_MONT_CTX_new();\n    if (mont == NULL)\n        goto err;\n    if (!BN_MONT_CTX_set(mont, p, ctx)) {\n        ECerr(EC_F_EC_GFP_MONT_GROUP_SET_CURVE, ERR_R_BN_LIB);\n        goto err;\n    }\n    one = BN_new();\n    if (one == NULL)\n        goto err;\n    if (!BN_to_montgomery(one, BN_value_one(), mont, ctx))\n        goto err;\n\n    group->field_data1 = mont;\n    mont = NULL;\n    group->field_data2 = one;\n    one = NULL;\n\n    ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx);\n\n    if (!ret) {\n        BN_MONT_CTX_free(group->field_data1);\n        group->field_data1 = NULL;\n        BN_free(group->field_data2);\n        group->field_data2 = NULL;\n    }\n\n err:\n    BN_free(one);\n    BN_CTX_free(new_ctx);\n    BN_MONT_CTX_free(mont);\n    return ret;\n}\n\nint ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,\n                          const BIGNUM *b, BN_CTX *ctx)\n{\n    if (group->field_data1 == NULL) {\n        ECerr(EC_F_EC_GFP_MONT_FIELD_MUL, EC_R_NOT_INITIALIZED);\n        return 0;\n    }\n\n    return BN_mod_mul_montgomery(r, a, b, group->field_data1, ctx);\n}\n\nint ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,\n                          BN_CTX *ctx)\n{\n    if (group->field_data1 == NULL) {\n        ECerr(EC_F_EC_GFP_MONT_FIELD_SQR, EC_R_NOT_INITIALIZED);\n        return 0;\n    }\n\n    return BN_mod_mul_montgomery(r, a, a, group->field_data1, ctx);\n}\n\n/*-\n * Computes the multiplicative inverse of a in GF(p), storing the result in r.\n * If a is zero (or equivalent), you'll get a EC_R_CANNOT_INVERT error.\n * We have a Mont structure, so SCA hardening is FLT inversion.\n */\nint ec_GFp_mont_field_inv(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,\n                            BN_CTX *ctx)\n{\n    BIGNUM *e = NULL;\n    BN_CTX *new_ctx = NULL;\n    int ret = 0;\n\n    if (group->field_data1 == NULL)\n        return 0;\n\n    if (ctx == NULL && (ctx = new_ctx = BN_CTX_secure_new()) == NULL)\n        return 0;\n\n    BN_CTX_start(ctx);\n    if ((e = BN_CTX_get(ctx)) == NULL)\n        goto err;\n\n    /* Inverse in constant time with Fermats Little Theorem */\n    if (!BN_set_word(e, 2))\n        goto err;\n    if (!BN_sub(e, group->field, e))\n        goto err;\n    /*-\n     * Exponent e is public.\n     * No need for scatter-gather or BN_FLG_CONSTTIME.\n     */\n    if (!BN_mod_exp_mont(r, a, e, group->field, ctx, group->field_data1))\n        goto err;\n\n    /* throw an error on zero */\n    if (BN_is_zero(r)) {\n        ECerr(EC_F_EC_GFP_MONT_FIELD_INV, EC_R_CANNOT_INVERT);\n        goto err;\n    }\n\n    ret = 1;\n\n  err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r,\n                             const BIGNUM *a, BN_CTX *ctx)\n{\n    if (group->field_data1 == NULL) {\n        ECerr(EC_F_EC_GFP_MONT_FIELD_ENCODE, EC_R_NOT_INITIALIZED);\n        return 0;\n    }\n\n    return BN_to_montgomery(r, a, (BN_MONT_CTX *)group->field_data1, ctx);\n}\n\nint ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r,\n                             const BIGNUM *a, BN_CTX *ctx)\n{\n    if (group->field_data1 == NULL) {\n        ECerr(EC_F_EC_GFP_MONT_FIELD_DECODE, EC_R_NOT_INITIALIZED);\n        return 0;\n    }\n\n    return BN_from_montgomery(r, a, group->field_data1, ctx);\n}\n\nint ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r,\n                                 BN_CTX *ctx)\n{\n    if (group->field_data2 == NULL) {\n        ECerr(EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE, EC_R_NOT_INITIALIZED);\n        return 0;\n    }\n\n    if (!BN_copy(r, group->field_data2))\n        return 0;\n    return 1;\n}\n"
  },
  {
    "path": "cryptomini/ec/ecp_nist.c",
    "content": "/*\n * Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <limits.h>\n\n#include <openssl/err.h>\n#include <openssl/obj_mac.h>\n#include \"ec_local.h\"\n\nconst EC_METHOD *EC_GFp_nist_method(void)\n{\n    static const EC_METHOD ret = {\n        EC_FLAGS_DEFAULT_OCT,\n        NID_X9_62_prime_field,\n        ec_GFp_simple_group_init,\n        ec_GFp_simple_group_finish,\n        ec_GFp_simple_group_clear_finish,\n        ec_GFp_nist_group_copy,\n        ec_GFp_nist_group_set_curve,\n        ec_GFp_simple_group_get_curve,\n        ec_GFp_simple_group_get_degree,\n        ec_group_simple_order_bits,\n        ec_GFp_simple_group_check_discriminant,\n        ec_GFp_simple_point_init,\n        ec_GFp_simple_point_finish,\n        ec_GFp_simple_point_clear_finish,\n        ec_GFp_simple_point_copy,\n        ec_GFp_simple_point_set_to_infinity,\n        ec_GFp_simple_set_Jprojective_coordinates_GFp,\n        ec_GFp_simple_get_Jprojective_coordinates_GFp,\n        ec_GFp_simple_point_set_affine_coordinates,\n        ec_GFp_simple_point_get_affine_coordinates,\n        0, 0, 0,\n        ec_GFp_simple_add,\n        ec_GFp_simple_dbl,\n        ec_GFp_simple_invert,\n        ec_GFp_simple_is_at_infinity,\n        ec_GFp_simple_is_on_curve,\n        ec_GFp_simple_cmp,\n        ec_GFp_simple_make_affine,\n        ec_GFp_simple_points_make_affine,\n        0 /* mul */ ,\n        0 /* precompute_mult */ ,\n        0 /* have_precompute_mult */ ,\n        ec_GFp_nist_field_mul,\n        ec_GFp_nist_field_sqr,\n        0 /* field_div */ ,\n        ec_GFp_simple_field_inv,\n        0 /* field_encode */ ,\n        0 /* field_decode */ ,\n        0,                      /* field_set_to_one */\n        ec_key_simple_priv2oct,\n        ec_key_simple_oct2priv,\n        0, /* set private */\n        ec_key_simple_generate_key,\n        ec_key_simple_check_key,\n        ec_key_simple_generate_public_key,\n        0, /* keycopy */\n        0, /* keyfinish */\n        ecdh_simple_compute_key,\n        0, /* field_inverse_mod_ord */\n        ec_GFp_simple_blind_coordinates,\n        ec_GFp_simple_ladder_pre,\n        ec_GFp_simple_ladder_step,\n        ec_GFp_simple_ladder_post\n    };\n\n    return &ret;\n}\n\nint ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src)\n{\n    dest->field_mod_func = src->field_mod_func;\n\n    return ec_GFp_simple_group_copy(dest, src);\n}\n\nint ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,\n                                const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    BN_CTX *new_ctx = NULL;\n\n    if (ctx == NULL)\n        if ((ctx = new_ctx = BN_CTX_new()) == NULL)\n            return 0;\n\n    BN_CTX_start(ctx);\n\n    if (BN_ucmp(BN_get0_nist_prime_192(), p) == 0)\n        group->field_mod_func = BN_nist_mod_192;\n    else if (BN_ucmp(BN_get0_nist_prime_224(), p) == 0)\n        group->field_mod_func = BN_nist_mod_224;\n    else if (BN_ucmp(BN_get0_nist_prime_256(), p) == 0)\n        group->field_mod_func = BN_nist_mod_256;\n    else if (BN_ucmp(BN_get0_nist_prime_384(), p) == 0)\n        group->field_mod_func = BN_nist_mod_384;\n    else if (BN_ucmp(BN_get0_nist_prime_521(), p) == 0)\n        group->field_mod_func = BN_nist_mod_521;\n    else {\n        ECerr(EC_F_EC_GFP_NIST_GROUP_SET_CURVE, EC_R_NOT_A_NIST_PRIME);\n        goto err;\n    }\n\n    ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx);\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,\n                          const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    BN_CTX *ctx_new = NULL;\n\n    if (!group || !r || !a || !b) {\n        ECerr(EC_F_EC_GFP_NIST_FIELD_MUL, ERR_R_PASSED_NULL_PARAMETER);\n        goto err;\n    }\n    if (!ctx)\n        if ((ctx_new = ctx = BN_CTX_new()) == NULL)\n            goto err;\n\n    if (!BN_mul(r, a, b, ctx))\n        goto err;\n    if (!group->field_mod_func(r, r, group->field, ctx))\n        goto err;\n\n    ret = 1;\n err:\n    BN_CTX_free(ctx_new);\n    return ret;\n}\n\nint ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,\n                          BN_CTX *ctx)\n{\n    int ret = 0;\n    BN_CTX *ctx_new = NULL;\n\n    if (!group || !r || !a) {\n        ECerr(EC_F_EC_GFP_NIST_FIELD_SQR, EC_R_PASSED_NULL_PARAMETER);\n        goto err;\n    }\n    if (!ctx)\n        if ((ctx_new = ctx = BN_CTX_new()) == NULL)\n            goto err;\n\n    if (!BN_sqr(r, a, ctx))\n        goto err;\n    if (!group->field_mod_func(r, r, group->field, ctx))\n        goto err;\n\n    ret = 1;\n err:\n    BN_CTX_free(ctx_new);\n    return ret;\n}\n"
  },
  {
    "path": "cryptomini/ec/ecp_smpl.c",
    "content": "/*\n * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/err.h>\n#include <openssl/symhacks.h>\n\n#include \"ec_local.h\"\n\nconst EC_METHOD *EC_GFp_simple_method(void)\n{\n    static const EC_METHOD ret = {\n        EC_FLAGS_DEFAULT_OCT,\n        NID_X9_62_prime_field,\n        ec_GFp_simple_group_init,\n        ec_GFp_simple_group_finish,\n        ec_GFp_simple_group_clear_finish,\n        ec_GFp_simple_group_copy,\n        ec_GFp_simple_group_set_curve,\n        ec_GFp_simple_group_get_curve,\n        ec_GFp_simple_group_get_degree,\n        ec_group_simple_order_bits,\n        ec_GFp_simple_group_check_discriminant,\n        ec_GFp_simple_point_init,\n        ec_GFp_simple_point_finish,\n        ec_GFp_simple_point_clear_finish,\n        ec_GFp_simple_point_copy,\n        ec_GFp_simple_point_set_to_infinity,\n        ec_GFp_simple_set_Jprojective_coordinates_GFp,\n        ec_GFp_simple_get_Jprojective_coordinates_GFp,\n        ec_GFp_simple_point_set_affine_coordinates,\n        ec_GFp_simple_point_get_affine_coordinates,\n        0, 0, 0,\n        ec_GFp_simple_add,\n        ec_GFp_simple_dbl,\n        ec_GFp_simple_invert,\n        ec_GFp_simple_is_at_infinity,\n        ec_GFp_simple_is_on_curve,\n        ec_GFp_simple_cmp,\n        ec_GFp_simple_make_affine,\n        ec_GFp_simple_points_make_affine,\n        0 /* mul */ ,\n        0 /* precompute_mult */ ,\n        0 /* have_precompute_mult */ ,\n        ec_GFp_simple_field_mul,\n        ec_GFp_simple_field_sqr,\n        0 /* field_div */ ,\n        ec_GFp_simple_field_inv,\n        0 /* field_encode */ ,\n        0 /* field_decode */ ,\n        0,                      /* field_set_to_one */\n        ec_key_simple_priv2oct,\n        ec_key_simple_oct2priv,\n        0, /* set private */\n        ec_key_simple_generate_key,\n        ec_key_simple_check_key,\n        ec_key_simple_generate_public_key,\n        0, /* keycopy */\n        0, /* keyfinish */\n        ecdh_simple_compute_key,\n        0, /* field_inverse_mod_ord */\n        ec_GFp_simple_blind_coordinates,\n        ec_GFp_simple_ladder_pre,\n        ec_GFp_simple_ladder_step,\n        ec_GFp_simple_ladder_post\n    };\n\n    return &ret;\n}\n\n/*\n * Most method functions in this file are designed to work with\n * non-trivial representations of field elements if necessary\n * (see ecp_mont.c): while standard modular addition and subtraction\n * are used, the field_mul and field_sqr methods will be used for\n * multiplication, and field_encode and field_decode (if defined)\n * will be used for converting between representations.\n *\n * Functions ec_GFp_simple_points_make_affine() and\n * ec_GFp_simple_point_get_affine_coordinates() specifically assume\n * that if a non-trivial representation is used, it is a Montgomery\n * representation (i.e. 'encoding' means multiplying by some factor R).\n */\n\nint ec_GFp_simple_group_init(EC_GROUP *group)\n{\n    group->field = BN_new();\n    group->a = BN_new();\n    group->b = BN_new();\n    if (group->field == NULL || group->a == NULL || group->b == NULL) {\n        BN_free(group->field);\n        BN_free(group->a);\n        BN_free(group->b);\n        return 0;\n    }\n    group->a_is_minus3 = 0;\n    return 1;\n}\n\nvoid ec_GFp_simple_group_finish(EC_GROUP *group)\n{\n    BN_free(group->field);\n    BN_free(group->a);\n    BN_free(group->b);\n}\n\nvoid ec_GFp_simple_group_clear_finish(EC_GROUP *group)\n{\n    BN_clear_free(group->field);\n    BN_clear_free(group->a);\n    BN_clear_free(group->b);\n}\n\nint ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src)\n{\n    if (!BN_copy(dest->field, src->field))\n        return 0;\n    if (!BN_copy(dest->a, src->a))\n        return 0;\n    if (!BN_copy(dest->b, src->b))\n        return 0;\n\n    dest->a_is_minus3 = src->a_is_minus3;\n\n    return 1;\n}\n\nint ec_GFp_simple_group_set_curve(EC_GROUP *group,\n                                  const BIGNUM *p, const BIGNUM *a,\n                                  const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *tmp_a;\n\n    /* p must be a prime > 3 */\n    if (BN_num_bits(p) <= 2 || !BN_is_odd(p)) {\n        ECerr(EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE, EC_R_INVALID_FIELD);\n        return 0;\n    }\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n\n    BN_CTX_start(ctx);\n    tmp_a = BN_CTX_get(ctx);\n    if (tmp_a == NULL)\n        goto err;\n\n    /* group->field */\n    if (!BN_copy(group->field, p))\n        goto err;\n    BN_set_negative(group->field, 0);\n\n    /* group->a */\n    if (!BN_nnmod(tmp_a, a, p, ctx))\n        goto err;\n    if (group->meth->field_encode) {\n        if (!group->meth->field_encode(group, group->a, tmp_a, ctx))\n            goto err;\n    } else if (!BN_copy(group->a, tmp_a))\n        goto err;\n\n    /* group->b */\n    if (!BN_nnmod(group->b, b, p, ctx))\n        goto err;\n    if (group->meth->field_encode)\n        if (!group->meth->field_encode(group, group->b, group->b, ctx))\n            goto err;\n\n    /* group->a_is_minus3 */\n    if (!BN_add_word(tmp_a, 3))\n        goto err;\n    group->a_is_minus3 = (0 == BN_cmp(tmp_a, group->field));\n\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,\n                                  BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    BN_CTX *new_ctx = NULL;\n\n    if (p != NULL) {\n        if (!BN_copy(p, group->field))\n            return 0;\n    }\n\n    if (a != NULL || b != NULL) {\n        if (group->meth->field_decode) {\n            if (ctx == NULL) {\n                ctx = new_ctx = BN_CTX_new();\n                if (ctx == NULL)\n                    return 0;\n            }\n            if (a != NULL) {\n                if (!group->meth->field_decode(group, a, group->a, ctx))\n                    goto err;\n            }\n            if (b != NULL) {\n                if (!group->meth->field_decode(group, b, group->b, ctx))\n                    goto err;\n            }\n        } else {\n            if (a != NULL) {\n                if (!BN_copy(a, group->a))\n                    goto err;\n            }\n            if (b != NULL) {\n                if (!BN_copy(b, group->b))\n                    goto err;\n            }\n        }\n    }\n\n    ret = 1;\n\n err:\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_group_get_degree(const EC_GROUP *group)\n{\n    return BN_num_bits(group->field);\n}\n\nint ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *a, *b, *order, *tmp_1, *tmp_2;\n    const BIGNUM *p = group->field;\n    BN_CTX *new_ctx = NULL;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL) {\n            ECerr(EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT,\n                  ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n    }\n    BN_CTX_start(ctx);\n    a = BN_CTX_get(ctx);\n    b = BN_CTX_get(ctx);\n    tmp_1 = BN_CTX_get(ctx);\n    tmp_2 = BN_CTX_get(ctx);\n    order = BN_CTX_get(ctx);\n    if (order == NULL)\n        goto err;\n\n    if (group->meth->field_decode) {\n        if (!group->meth->field_decode(group, a, group->a, ctx))\n            goto err;\n        if (!group->meth->field_decode(group, b, group->b, ctx))\n            goto err;\n    } else {\n        if (!BN_copy(a, group->a))\n            goto err;\n        if (!BN_copy(b, group->b))\n            goto err;\n    }\n\n    /*-\n     * check the discriminant:\n     * y^2 = x^3 + a*x + b is an elliptic curve <=> 4*a^3 + 27*b^2 != 0 (mod p)\n     * 0 =< a, b < p\n     */\n    if (BN_is_zero(a)) {\n        if (BN_is_zero(b))\n            goto err;\n    } else if (!BN_is_zero(b)) {\n        if (!BN_mod_sqr(tmp_1, a, p, ctx))\n            goto err;\n        if (!BN_mod_mul(tmp_2, tmp_1, a, p, ctx))\n            goto err;\n        if (!BN_lshift(tmp_1, tmp_2, 2))\n            goto err;\n        /* tmp_1 = 4*a^3 */\n\n        if (!BN_mod_sqr(tmp_2, b, p, ctx))\n            goto err;\n        if (!BN_mul_word(tmp_2, 27))\n            goto err;\n        /* tmp_2 = 27*b^2 */\n\n        if (!BN_mod_add(a, tmp_1, tmp_2, p, ctx))\n            goto err;\n        if (BN_is_zero(a))\n            goto err;\n    }\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_point_init(EC_POINT *point)\n{\n    point->X = BN_new();\n    point->Y = BN_new();\n    point->Z = BN_new();\n    point->Z_is_one = 0;\n\n    if (point->X == NULL || point->Y == NULL || point->Z == NULL) {\n        BN_free(point->X);\n        BN_free(point->Y);\n        BN_free(point->Z);\n        return 0;\n    }\n    return 1;\n}\n\nvoid ec_GFp_simple_point_finish(EC_POINT *point)\n{\n    BN_free(point->X);\n    BN_free(point->Y);\n    BN_free(point->Z);\n}\n\nvoid ec_GFp_simple_point_clear_finish(EC_POINT *point)\n{\n    BN_clear_free(point->X);\n    BN_clear_free(point->Y);\n    BN_clear_free(point->Z);\n    point->Z_is_one = 0;\n}\n\nint ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src)\n{\n    if (!BN_copy(dest->X, src->X))\n        return 0;\n    if (!BN_copy(dest->Y, src->Y))\n        return 0;\n    if (!BN_copy(dest->Z, src->Z))\n        return 0;\n    dest->Z_is_one = src->Z_is_one;\n    dest->curve_name = src->curve_name;\n\n    return 1;\n}\n\nint ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group,\n                                        EC_POINT *point)\n{\n    point->Z_is_one = 0;\n    BN_zero(point->Z);\n    return 1;\n}\n\nint ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                                  EC_POINT *point,\n                                                  const BIGNUM *x,\n                                                  const BIGNUM *y,\n                                                  const BIGNUM *z,\n                                                  BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    int ret = 0;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n\n    if (x != NULL) {\n        if (!BN_nnmod(point->X, x, group->field, ctx))\n            goto err;\n        if (group->meth->field_encode) {\n            if (!group->meth->field_encode(group, point->X, point->X, ctx))\n                goto err;\n        }\n    }\n\n    if (y != NULL) {\n        if (!BN_nnmod(point->Y, y, group->field, ctx))\n            goto err;\n        if (group->meth->field_encode) {\n            if (!group->meth->field_encode(group, point->Y, point->Y, ctx))\n                goto err;\n        }\n    }\n\n    if (z != NULL) {\n        int Z_is_one;\n\n        if (!BN_nnmod(point->Z, z, group->field, ctx))\n            goto err;\n        Z_is_one = BN_is_one(point->Z);\n        if (group->meth->field_encode) {\n            if (Z_is_one && (group->meth->field_set_to_one != 0)) {\n                if (!group->meth->field_set_to_one(group, point->Z, ctx))\n                    goto err;\n            } else {\n                if (!group->\n                    meth->field_encode(group, point->Z, point->Z, ctx))\n                    goto err;\n            }\n        }\n        point->Z_is_one = Z_is_one;\n    }\n\n    ret = 1;\n\n err:\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                                  const EC_POINT *point,\n                                                  BIGNUM *x, BIGNUM *y,\n                                                  BIGNUM *z, BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    int ret = 0;\n\n    if (group->meth->field_decode != 0) {\n        if (ctx == NULL) {\n            ctx = new_ctx = BN_CTX_new();\n            if (ctx == NULL)\n                return 0;\n        }\n\n        if (x != NULL) {\n            if (!group->meth->field_decode(group, x, point->X, ctx))\n                goto err;\n        }\n        if (y != NULL) {\n            if (!group->meth->field_decode(group, y, point->Y, ctx))\n                goto err;\n        }\n        if (z != NULL) {\n            if (!group->meth->field_decode(group, z, point->Z, ctx))\n                goto err;\n        }\n    } else {\n        if (x != NULL) {\n            if (!BN_copy(x, point->X))\n                goto err;\n        }\n        if (y != NULL) {\n            if (!BN_copy(y, point->Y))\n                goto err;\n        }\n        if (z != NULL) {\n            if (!BN_copy(z, point->Z))\n                goto err;\n        }\n    }\n\n    ret = 1;\n\n err:\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *group,\n                                               EC_POINT *point,\n                                               const BIGNUM *x,\n                                               const BIGNUM *y, BN_CTX *ctx)\n{\n    if (x == NULL || y == NULL) {\n        /*\n         * unlike for projective coordinates, we do not tolerate this\n         */\n        ECerr(EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES,\n              ERR_R_PASSED_NULL_PARAMETER);\n        return 0;\n    }\n\n    return EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y,\n                                                    BN_value_one(), ctx);\n}\n\nint ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group,\n                                               const EC_POINT *point,\n                                               BIGNUM *x, BIGNUM *y,\n                                               BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *Z, *Z_1, *Z_2, *Z_3;\n    const BIGNUM *Z_;\n    int ret = 0;\n\n    if (EC_POINT_is_at_infinity(group, point)) {\n        ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES,\n              EC_R_POINT_AT_INFINITY);\n        return 0;\n    }\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n\n    BN_CTX_start(ctx);\n    Z = BN_CTX_get(ctx);\n    Z_1 = BN_CTX_get(ctx);\n    Z_2 = BN_CTX_get(ctx);\n    Z_3 = BN_CTX_get(ctx);\n    if (Z_3 == NULL)\n        goto err;\n\n    /* transform  (X, Y, Z)  into  (x, y) := (X/Z^2, Y/Z^3) */\n\n    if (group->meth->field_decode) {\n        if (!group->meth->field_decode(group, Z, point->Z, ctx))\n            goto err;\n        Z_ = Z;\n    } else {\n        Z_ = point->Z;\n    }\n\n    if (BN_is_one(Z_)) {\n        if (group->meth->field_decode) {\n            if (x != NULL) {\n                if (!group->meth->field_decode(group, x, point->X, ctx))\n                    goto err;\n            }\n            if (y != NULL) {\n                if (!group->meth->field_decode(group, y, point->Y, ctx))\n                    goto err;\n            }\n        } else {\n            if (x != NULL) {\n                if (!BN_copy(x, point->X))\n                    goto err;\n            }\n            if (y != NULL) {\n                if (!BN_copy(y, point->Y))\n                    goto err;\n            }\n        }\n    } else {\n        if (!group->meth->field_inv(group, Z_1, Z_, ctx)) {\n            ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES,\n                  ERR_R_BN_LIB);\n            goto err;\n        }\n\n        if (group->meth->field_encode == 0) {\n            /* field_sqr works on standard representation */\n            if (!group->meth->field_sqr(group, Z_2, Z_1, ctx))\n                goto err;\n        } else {\n            if (!BN_mod_sqr(Z_2, Z_1, group->field, ctx))\n                goto err;\n        }\n\n        if (x != NULL) {\n            /*\n             * in the Montgomery case, field_mul will cancel out Montgomery\n             * factor in X:\n             */\n            if (!group->meth->field_mul(group, x, point->X, Z_2, ctx))\n                goto err;\n        }\n\n        if (y != NULL) {\n            if (group->meth->field_encode == 0) {\n                /*\n                 * field_mul works on standard representation\n                 */\n                if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx))\n                    goto err;\n            } else {\n                if (!BN_mod_mul(Z_3, Z_2, Z_1, group->field, ctx))\n                    goto err;\n            }\n\n            /*\n             * in the Montgomery case, field_mul will cancel out Montgomery\n             * factor in Y:\n             */\n            if (!group->meth->field_mul(group, y, point->Y, Z_3, ctx))\n                goto err;\n        }\n    }\n\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                      const EC_POINT *b, BN_CTX *ctx)\n{\n    int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *,\n                      const BIGNUM *, BN_CTX *);\n    int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);\n    const BIGNUM *p;\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *n0, *n1, *n2, *n3, *n4, *n5, *n6;\n    int ret = 0;\n\n    if (a == b)\n        return EC_POINT_dbl(group, r, a, ctx);\n    if (EC_POINT_is_at_infinity(group, a))\n        return EC_POINT_copy(r, b);\n    if (EC_POINT_is_at_infinity(group, b))\n        return EC_POINT_copy(r, a);\n\n    field_mul = group->meth->field_mul;\n    field_sqr = group->meth->field_sqr;\n    p = group->field;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n\n    BN_CTX_start(ctx);\n    n0 = BN_CTX_get(ctx);\n    n1 = BN_CTX_get(ctx);\n    n2 = BN_CTX_get(ctx);\n    n3 = BN_CTX_get(ctx);\n    n4 = BN_CTX_get(ctx);\n    n5 = BN_CTX_get(ctx);\n    n6 = BN_CTX_get(ctx);\n    if (n6 == NULL)\n        goto end;\n\n    /*\n     * Note that in this function we must not read components of 'a' or 'b'\n     * once we have written the corresponding components of 'r'. ('r' might\n     * be one of 'a' or 'b'.)\n     */\n\n    /* n1, n2 */\n    if (b->Z_is_one) {\n        if (!BN_copy(n1, a->X))\n            goto end;\n        if (!BN_copy(n2, a->Y))\n            goto end;\n        /* n1 = X_a */\n        /* n2 = Y_a */\n    } else {\n        if (!field_sqr(group, n0, b->Z, ctx))\n            goto end;\n        if (!field_mul(group, n1, a->X, n0, ctx))\n            goto end;\n        /* n1 = X_a * Z_b^2 */\n\n        if (!field_mul(group, n0, n0, b->Z, ctx))\n            goto end;\n        if (!field_mul(group, n2, a->Y, n0, ctx))\n            goto end;\n        /* n2 = Y_a * Z_b^3 */\n    }\n\n    /* n3, n4 */\n    if (a->Z_is_one) {\n        if (!BN_copy(n3, b->X))\n            goto end;\n        if (!BN_copy(n4, b->Y))\n            goto end;\n        /* n3 = X_b */\n        /* n4 = Y_b */\n    } else {\n        if (!field_sqr(group, n0, a->Z, ctx))\n            goto end;\n        if (!field_mul(group, n3, b->X, n0, ctx))\n            goto end;\n        /* n3 = X_b * Z_a^2 */\n\n        if (!field_mul(group, n0, n0, a->Z, ctx))\n            goto end;\n        if (!field_mul(group, n4, b->Y, n0, ctx))\n            goto end;\n        /* n4 = Y_b * Z_a^3 */\n    }\n\n    /* n5, n6 */\n    if (!BN_mod_sub_quick(n5, n1, n3, p))\n        goto end;\n    if (!BN_mod_sub_quick(n6, n2, n4, p))\n        goto end;\n    /* n5 = n1 - n3 */\n    /* n6 = n2 - n4 */\n\n    if (BN_is_zero(n5)) {\n        if (BN_is_zero(n6)) {\n            /* a is the same point as b */\n            BN_CTX_end(ctx);\n            ret = EC_POINT_dbl(group, r, a, ctx);\n            ctx = NULL;\n            goto end;\n        } else {\n            /* a is the inverse of b */\n            BN_zero(r->Z);\n            r->Z_is_one = 0;\n            ret = 1;\n            goto end;\n        }\n    }\n\n    /* 'n7', 'n8' */\n    if (!BN_mod_add_quick(n1, n1, n3, p))\n        goto end;\n    if (!BN_mod_add_quick(n2, n2, n4, p))\n        goto end;\n    /* 'n7' = n1 + n3 */\n    /* 'n8' = n2 + n4 */\n\n    /* Z_r */\n    if (a->Z_is_one && b->Z_is_one) {\n        if (!BN_copy(r->Z, n5))\n            goto end;\n    } else {\n        if (a->Z_is_one) {\n            if (!BN_copy(n0, b->Z))\n                goto end;\n        } else if (b->Z_is_one) {\n            if (!BN_copy(n0, a->Z))\n                goto end;\n        } else {\n            if (!field_mul(group, n0, a->Z, b->Z, ctx))\n                goto end;\n        }\n        if (!field_mul(group, r->Z, n0, n5, ctx))\n            goto end;\n    }\n    r->Z_is_one = 0;\n    /* Z_r = Z_a * Z_b * n5 */\n\n    /* X_r */\n    if (!field_sqr(group, n0, n6, ctx))\n        goto end;\n    if (!field_sqr(group, n4, n5, ctx))\n        goto end;\n    if (!field_mul(group, n3, n1, n4, ctx))\n        goto end;\n    if (!BN_mod_sub_quick(r->X, n0, n3, p))\n        goto end;\n    /* X_r = n6^2 - n5^2 * 'n7' */\n\n    /* 'n9' */\n    if (!BN_mod_lshift1_quick(n0, r->X, p))\n        goto end;\n    if (!BN_mod_sub_quick(n0, n3, n0, p))\n        goto end;\n    /* n9 = n5^2 * 'n7' - 2 * X_r */\n\n    /* Y_r */\n    if (!field_mul(group, n0, n0, n6, ctx))\n        goto end;\n    if (!field_mul(group, n5, n4, n5, ctx))\n        goto end;               /* now n5 is n5^3 */\n    if (!field_mul(group, n1, n2, n5, ctx))\n        goto end;\n    if (!BN_mod_sub_quick(n0, n0, n1, p))\n        goto end;\n    if (BN_is_odd(n0))\n        if (!BN_add(n0, n0, p))\n            goto end;\n    /* now  0 <= n0 < 2*p,  and n0 is even */\n    if (!BN_rshift1(r->Y, n0))\n        goto end;\n    /* Y_r = (n6 * 'n9' - 'n8' * 'n5^3') / 2 */\n\n    ret = 1;\n\n end:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                      BN_CTX *ctx)\n{\n    int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *,\n                      const BIGNUM *, BN_CTX *);\n    int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);\n    const BIGNUM *p;\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *n0, *n1, *n2, *n3;\n    int ret = 0;\n\n    if (EC_POINT_is_at_infinity(group, a)) {\n        BN_zero(r->Z);\n        r->Z_is_one = 0;\n        return 1;\n    }\n\n    field_mul = group->meth->field_mul;\n    field_sqr = group->meth->field_sqr;\n    p = group->field;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n\n    BN_CTX_start(ctx);\n    n0 = BN_CTX_get(ctx);\n    n1 = BN_CTX_get(ctx);\n    n2 = BN_CTX_get(ctx);\n    n3 = BN_CTX_get(ctx);\n    if (n3 == NULL)\n        goto err;\n\n    /*\n     * Note that in this function we must not read components of 'a' once we\n     * have written the corresponding components of 'r'. ('r' might the same\n     * as 'a'.)\n     */\n\n    /* n1 */\n    if (a->Z_is_one) {\n        if (!field_sqr(group, n0, a->X, ctx))\n            goto err;\n        if (!BN_mod_lshift1_quick(n1, n0, p))\n            goto err;\n        if (!BN_mod_add_quick(n0, n0, n1, p))\n            goto err;\n        if (!BN_mod_add_quick(n1, n0, group->a, p))\n            goto err;\n        /* n1 = 3 * X_a^2 + a_curve */\n    } else if (group->a_is_minus3) {\n        if (!field_sqr(group, n1, a->Z, ctx))\n            goto err;\n        if (!BN_mod_add_quick(n0, a->X, n1, p))\n            goto err;\n        if (!BN_mod_sub_quick(n2, a->X, n1, p))\n            goto err;\n        if (!field_mul(group, n1, n0, n2, ctx))\n            goto err;\n        if (!BN_mod_lshift1_quick(n0, n1, p))\n            goto err;\n        if (!BN_mod_add_quick(n1, n0, n1, p))\n            goto err;\n        /*-\n         * n1 = 3 * (X_a + Z_a^2) * (X_a - Z_a^2)\n         *    = 3 * X_a^2 - 3 * Z_a^4\n         */\n    } else {\n        if (!field_sqr(group, n0, a->X, ctx))\n            goto err;\n        if (!BN_mod_lshift1_quick(n1, n0, p))\n            goto err;\n        if (!BN_mod_add_quick(n0, n0, n1, p))\n            goto err;\n        if (!field_sqr(group, n1, a->Z, ctx))\n            goto err;\n        if (!field_sqr(group, n1, n1, ctx))\n            goto err;\n        if (!field_mul(group, n1, n1, group->a, ctx))\n            goto err;\n        if (!BN_mod_add_quick(n1, n1, n0, p))\n            goto err;\n        /* n1 = 3 * X_a^2 + a_curve * Z_a^4 */\n    }\n\n    /* Z_r */\n    if (a->Z_is_one) {\n        if (!BN_copy(n0, a->Y))\n            goto err;\n    } else {\n        if (!field_mul(group, n0, a->Y, a->Z, ctx))\n            goto err;\n    }\n    if (!BN_mod_lshift1_quick(r->Z, n0, p))\n        goto err;\n    r->Z_is_one = 0;\n    /* Z_r = 2 * Y_a * Z_a */\n\n    /* n2 */\n    if (!field_sqr(group, n3, a->Y, ctx))\n        goto err;\n    if (!field_mul(group, n2, a->X, n3, ctx))\n        goto err;\n    if (!BN_mod_lshift_quick(n2, n2, 2, p))\n        goto err;\n    /* n2 = 4 * X_a * Y_a^2 */\n\n    /* X_r */\n    if (!BN_mod_lshift1_quick(n0, n2, p))\n        goto err;\n    if (!field_sqr(group, r->X, n1, ctx))\n        goto err;\n    if (!BN_mod_sub_quick(r->X, r->X, n0, p))\n        goto err;\n    /* X_r = n1^2 - 2 * n2 */\n\n    /* n3 */\n    if (!field_sqr(group, n0, n3, ctx))\n        goto err;\n    if (!BN_mod_lshift_quick(n3, n0, 3, p))\n        goto err;\n    /* n3 = 8 * Y_a^4 */\n\n    /* Y_r */\n    if (!BN_mod_sub_quick(n0, n2, r->X, p))\n        goto err;\n    if (!field_mul(group, n0, n1, n0, ctx))\n        goto err;\n    if (!BN_mod_sub_quick(r->Y, n0, n3, p))\n        goto err;\n    /* Y_r = n1 * (n2 - X_r) - n3 */\n\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)\n{\n    if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(point->Y))\n        /* point is its own inverse */\n        return 1;\n\n    return BN_usub(point->Y, group->field, point->Y);\n}\n\nint ec_GFp_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)\n{\n    return BN_is_zero(point->Z);\n}\n\nint ec_GFp_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point,\n                              BN_CTX *ctx)\n{\n    int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *,\n                      const BIGNUM *, BN_CTX *);\n    int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);\n    const BIGNUM *p;\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *rh, *tmp, *Z4, *Z6;\n    int ret = -1;\n\n    if (EC_POINT_is_at_infinity(group, point))\n        return 1;\n\n    field_mul = group->meth->field_mul;\n    field_sqr = group->meth->field_sqr;\n    p = group->field;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return -1;\n    }\n\n    BN_CTX_start(ctx);\n    rh = BN_CTX_get(ctx);\n    tmp = BN_CTX_get(ctx);\n    Z4 = BN_CTX_get(ctx);\n    Z6 = BN_CTX_get(ctx);\n    if (Z6 == NULL)\n        goto err;\n\n    /*-\n     * We have a curve defined by a Weierstrass equation\n     *      y^2 = x^3 + a*x + b.\n     * The point to consider is given in Jacobian projective coordinates\n     * where  (X, Y, Z)  represents  (x, y) = (X/Z^2, Y/Z^3).\n     * Substituting this and multiplying by  Z^6  transforms the above equation into\n     *      Y^2 = X^3 + a*X*Z^4 + b*Z^6.\n     * To test this, we add up the right-hand side in 'rh'.\n     */\n\n    /* rh := X^2 */\n    if (!field_sqr(group, rh, point->X, ctx))\n        goto err;\n\n    if (!point->Z_is_one) {\n        if (!field_sqr(group, tmp, point->Z, ctx))\n            goto err;\n        if (!field_sqr(group, Z4, tmp, ctx))\n            goto err;\n        if (!field_mul(group, Z6, Z4, tmp, ctx))\n            goto err;\n\n        /* rh := (rh + a*Z^4)*X */\n        if (group->a_is_minus3) {\n            if (!BN_mod_lshift1_quick(tmp, Z4, p))\n                goto err;\n            if (!BN_mod_add_quick(tmp, tmp, Z4, p))\n                goto err;\n            if (!BN_mod_sub_quick(rh, rh, tmp, p))\n                goto err;\n            if (!field_mul(group, rh, rh, point->X, ctx))\n                goto err;\n        } else {\n            if (!field_mul(group, tmp, Z4, group->a, ctx))\n                goto err;\n            if (!BN_mod_add_quick(rh, rh, tmp, p))\n                goto err;\n            if (!field_mul(group, rh, rh, point->X, ctx))\n                goto err;\n        }\n\n        /* rh := rh + b*Z^6 */\n        if (!field_mul(group, tmp, group->b, Z6, ctx))\n            goto err;\n        if (!BN_mod_add_quick(rh, rh, tmp, p))\n            goto err;\n    } else {\n        /* point->Z_is_one */\n\n        /* rh := (rh + a)*X */\n        if (!BN_mod_add_quick(rh, rh, group->a, p))\n            goto err;\n        if (!field_mul(group, rh, rh, point->X, ctx))\n            goto err;\n        /* rh := rh + b */\n        if (!BN_mod_add_quick(rh, rh, group->b, p))\n            goto err;\n    }\n\n    /* 'lh' := Y^2 */\n    if (!field_sqr(group, tmp, point->Y, ctx))\n        goto err;\n\n    ret = (0 == BN_ucmp(tmp, rh));\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_cmp(const EC_GROUP *group, const EC_POINT *a,\n                      const EC_POINT *b, BN_CTX *ctx)\n{\n    /*-\n     * return values:\n     *  -1   error\n     *   0   equal (in affine coordinates)\n     *   1   not equal\n     */\n\n    int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *,\n                      const BIGNUM *, BN_CTX *);\n    int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *tmp1, *tmp2, *Za23, *Zb23;\n    const BIGNUM *tmp1_, *tmp2_;\n    int ret = -1;\n\n    if (EC_POINT_is_at_infinity(group, a)) {\n        return EC_POINT_is_at_infinity(group, b) ? 0 : 1;\n    }\n\n    if (EC_POINT_is_at_infinity(group, b))\n        return 1;\n\n    if (a->Z_is_one && b->Z_is_one) {\n        return ((BN_cmp(a->X, b->X) == 0) && BN_cmp(a->Y, b->Y) == 0) ? 0 : 1;\n    }\n\n    field_mul = group->meth->field_mul;\n    field_sqr = group->meth->field_sqr;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return -1;\n    }\n\n    BN_CTX_start(ctx);\n    tmp1 = BN_CTX_get(ctx);\n    tmp2 = BN_CTX_get(ctx);\n    Za23 = BN_CTX_get(ctx);\n    Zb23 = BN_CTX_get(ctx);\n    if (Zb23 == NULL)\n        goto end;\n\n    /*-\n     * We have to decide whether\n     *     (X_a/Z_a^2, Y_a/Z_a^3) = (X_b/Z_b^2, Y_b/Z_b^3),\n     * or equivalently, whether\n     *     (X_a*Z_b^2, Y_a*Z_b^3) = (X_b*Z_a^2, Y_b*Z_a^3).\n     */\n\n    if (!b->Z_is_one) {\n        if (!field_sqr(group, Zb23, b->Z, ctx))\n            goto end;\n        if (!field_mul(group, tmp1, a->X, Zb23, ctx))\n            goto end;\n        tmp1_ = tmp1;\n    } else\n        tmp1_ = a->X;\n    if (!a->Z_is_one) {\n        if (!field_sqr(group, Za23, a->Z, ctx))\n            goto end;\n        if (!field_mul(group, tmp2, b->X, Za23, ctx))\n            goto end;\n        tmp2_ = tmp2;\n    } else\n        tmp2_ = b->X;\n\n    /* compare  X_a*Z_b^2  with  X_b*Z_a^2 */\n    if (BN_cmp(tmp1_, tmp2_) != 0) {\n        ret = 1;                /* points differ */\n        goto end;\n    }\n\n    if (!b->Z_is_one) {\n        if (!field_mul(group, Zb23, Zb23, b->Z, ctx))\n            goto end;\n        if (!field_mul(group, tmp1, a->Y, Zb23, ctx))\n            goto end;\n        /* tmp1_ = tmp1 */\n    } else\n        tmp1_ = a->Y;\n    if (!a->Z_is_one) {\n        if (!field_mul(group, Za23, Za23, a->Z, ctx))\n            goto end;\n        if (!field_mul(group, tmp2, b->Y, Za23, ctx))\n            goto end;\n        /* tmp2_ = tmp2 */\n    } else\n        tmp2_ = b->Y;\n\n    /* compare  Y_a*Z_b^3  with  Y_b*Z_a^3 */\n    if (BN_cmp(tmp1_, tmp2_) != 0) {\n        ret = 1;                /* points differ */\n        goto end;\n    }\n\n    /* points are equal */\n    ret = 0;\n\n end:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point,\n                              BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *x, *y;\n    int ret = 0;\n\n    if (point->Z_is_one || EC_POINT_is_at_infinity(group, point))\n        return 1;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n\n    BN_CTX_start(ctx);\n    x = BN_CTX_get(ctx);\n    y = BN_CTX_get(ctx);\n    if (y == NULL)\n        goto err;\n\n    if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx))\n        goto err;\n    if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx))\n        goto err;\n    if (!point->Z_is_one) {\n        ECerr(EC_F_EC_GFP_SIMPLE_MAKE_AFFINE, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\nint ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num,\n                                     EC_POINT *points[], BN_CTX *ctx)\n{\n    BN_CTX *new_ctx = NULL;\n    BIGNUM *tmp, *tmp_Z;\n    BIGNUM **prod_Z = NULL;\n    size_t i;\n    int ret = 0;\n\n    if (num == 0)\n        return 1;\n\n    if (ctx == NULL) {\n        ctx = new_ctx = BN_CTX_new();\n        if (ctx == NULL)\n            return 0;\n    }\n\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    tmp_Z = BN_CTX_get(ctx);\n    if (tmp_Z == NULL)\n        goto err;\n\n    prod_Z = OPENSSL_malloc(num * sizeof(prod_Z[0]));\n    if (prod_Z == NULL)\n        goto err;\n    for (i = 0; i < num; i++) {\n        prod_Z[i] = BN_new();\n        if (prod_Z[i] == NULL)\n            goto err;\n    }\n\n    /*\n     * Set each prod_Z[i] to the product of points[0]->Z .. points[i]->Z,\n     * skipping any zero-valued inputs (pretend that they're 1).\n     */\n\n    if (!BN_is_zero(points[0]->Z)) {\n        if (!BN_copy(prod_Z[0], points[0]->Z))\n            goto err;\n    } else {\n        if (group->meth->field_set_to_one != 0) {\n            if (!group->meth->field_set_to_one(group, prod_Z[0], ctx))\n                goto err;\n        } else {\n            if (!BN_one(prod_Z[0]))\n                goto err;\n        }\n    }\n\n    for (i = 1; i < num; i++) {\n        if (!BN_is_zero(points[i]->Z)) {\n            if (!group->\n                meth->field_mul(group, prod_Z[i], prod_Z[i - 1], points[i]->Z,\n                                ctx))\n                goto err;\n        } else {\n            if (!BN_copy(prod_Z[i], prod_Z[i - 1]))\n                goto err;\n        }\n    }\n\n    /*\n     * Now use a single explicit inversion to replace every non-zero\n     * points[i]->Z by its inverse.\n     */\n\n    if (!group->meth->field_inv(group, tmp, prod_Z[num - 1], ctx)) {\n        ECerr(EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE, ERR_R_BN_LIB);\n        goto err;\n    }\n    if (group->meth->field_encode != 0) {\n        /*\n         * In the Montgomery case, we just turned R*H (representing H) into\n         * 1/(R*H), but we need R*(1/H) (representing 1/H); i.e. we need to\n         * multiply by the Montgomery factor twice.\n         */\n        if (!group->meth->field_encode(group, tmp, tmp, ctx))\n            goto err;\n        if (!group->meth->field_encode(group, tmp, tmp, ctx))\n            goto err;\n    }\n\n    for (i = num - 1; i > 0; --i) {\n        /*\n         * Loop invariant: tmp is the product of the inverses of points[0]->Z\n         * .. points[i]->Z (zero-valued inputs skipped).\n         */\n        if (!BN_is_zero(points[i]->Z)) {\n            /*\n             * Set tmp_Z to the inverse of points[i]->Z (as product of Z\n             * inverses 0 .. i, Z values 0 .. i - 1).\n             */\n            if (!group->\n                meth->field_mul(group, tmp_Z, prod_Z[i - 1], tmp, ctx))\n                goto err;\n            /*\n             * Update tmp to satisfy the loop invariant for i - 1.\n             */\n            if (!group->meth->field_mul(group, tmp, tmp, points[i]->Z, ctx))\n                goto err;\n            /* Replace points[i]->Z by its inverse. */\n            if (!BN_copy(points[i]->Z, tmp_Z))\n                goto err;\n        }\n    }\n\n    if (!BN_is_zero(points[0]->Z)) {\n        /* Replace points[0]->Z by its inverse. */\n        if (!BN_copy(points[0]->Z, tmp))\n            goto err;\n    }\n\n    /* Finally, fix up the X and Y coordinates for all points. */\n\n    for (i = 0; i < num; i++) {\n        EC_POINT *p = points[i];\n\n        if (!BN_is_zero(p->Z)) {\n            /* turn  (X, Y, 1/Z)  into  (X/Z^2, Y/Z^3, 1) */\n\n            if (!group->meth->field_sqr(group, tmp, p->Z, ctx))\n                goto err;\n            if (!group->meth->field_mul(group, p->X, p->X, tmp, ctx))\n                goto err;\n\n            if (!group->meth->field_mul(group, tmp, tmp, p->Z, ctx))\n                goto err;\n            if (!group->meth->field_mul(group, p->Y, p->Y, tmp, ctx))\n                goto err;\n\n            if (group->meth->field_set_to_one != 0) {\n                if (!group->meth->field_set_to_one(group, p->Z, ctx))\n                    goto err;\n            } else {\n                if (!BN_one(p->Z))\n                    goto err;\n            }\n            p->Z_is_one = 1;\n        }\n    }\n\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    if (prod_Z != NULL) {\n        for (i = 0; i < num; i++) {\n            if (prod_Z[i] == NULL)\n                break;\n            BN_clear_free(prod_Z[i]);\n        }\n        OPENSSL_free(prod_Z);\n    }\n    return ret;\n}\n\nint ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,\n                            const BIGNUM *b, BN_CTX *ctx)\n{\n    return BN_mod_mul(r, a, b, group->field, ctx);\n}\n\nint ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,\n                            BN_CTX *ctx)\n{\n    return BN_mod_sqr(r, a, group->field, ctx);\n}\n\n/*-\n * Computes the multiplicative inverse of a in GF(p), storing the result in r.\n * If a is zero (or equivalent), you'll get a EC_R_CANNOT_INVERT error.\n * Since we don't have a Mont structure here, SCA hardening is with blinding.\n * NB: \"a\" must be in _decoded_ form. (i.e. field_decode must precede.)\n */\nint ec_GFp_simple_field_inv(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,\n                            BN_CTX *ctx)\n{\n    BIGNUM *e = NULL;\n    BN_CTX *new_ctx = NULL;\n    int ret = 0;\n\n    if (ctx == NULL && (ctx = new_ctx = BN_CTX_secure_new()) == NULL)\n        return 0;\n\n    BN_CTX_start(ctx);\n    if ((e = BN_CTX_get(ctx)) == NULL)\n        goto err;\n\n    do {\n        if (!BN_priv_rand_range(e, group->field))\n        goto err;\n    } while (BN_is_zero(e));\n\n    /* r := a * e */\n    if (!group->meth->field_mul(group, r, a, e, ctx))\n        goto err;\n    /* r := 1/(a * e) */\n    if (!BN_mod_inverse(r, r, group->field, ctx)) {\n        ECerr(EC_F_EC_GFP_SIMPLE_FIELD_INV, EC_R_CANNOT_INVERT);\n        goto err;\n    }\n    /* r := e/(a * e) = 1/a */\n    if (!group->meth->field_mul(group, r, r, e, ctx))\n        goto err;\n\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    BN_CTX_free(new_ctx);\n    return ret;\n}\n\n/*-\n * Apply randomization of EC point projective coordinates:\n *\n *   (X, Y ,Z ) = (lambda^2*X, lambda^3*Y, lambda*Z)\n *   lambda = [1,group->field)\n *\n */\nint ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p,\n                                    BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *lambda = NULL;\n    BIGNUM *temp = NULL;\n\n    BN_CTX_start(ctx);\n    lambda = BN_CTX_get(ctx);\n    temp = BN_CTX_get(ctx);\n    if (temp == NULL) {\n        ECerr(EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES, ERR_R_MALLOC_FAILURE);\n        goto end;\n    }\n\n    /*-\n     * Make sure lambda is not zero.\n     * If the RNG fails, we cannot blind but nevertheless want\n     * code to continue smoothly and not clobber the error stack.\n     */\n    do {\n        ERR_set_mark();\n        ret = BN_priv_rand_range(lambda, group->field);\n        ERR_pop_to_mark();\n        if (ret == 0) {\n            ret = 1;\n            goto end;\n        }\n    } while (BN_is_zero(lambda));\n\n    /* if field_encode defined convert between representations */\n    if ((group->meth->field_encode != NULL\n         && !group->meth->field_encode(group, lambda, lambda, ctx))\n        || !group->meth->field_mul(group, p->Z, p->Z, lambda, ctx)\n        || !group->meth->field_sqr(group, temp, lambda, ctx)\n        || !group->meth->field_mul(group, p->X, p->X, temp, ctx)\n        || !group->meth->field_mul(group, temp, temp, lambda, ctx)\n        || !group->meth->field_mul(group, p->Y, p->Y, temp, ctx))\n        goto end;\n\n    p->Z_is_one = 0;\n    ret = 1;\n\n end:\n    BN_CTX_end(ctx);\n    return ret;\n}\n\n/*-\n * Input:\n * - p: affine coordinates\n *\n * Output:\n * - s := p, r := 2p: blinded projective (homogeneous) coordinates\n *\n * For doubling we use Formula 3 from Izu-Takagi \"A fast parallel elliptic curve\n * multiplication resistant against side channel attacks\" appendix, described at\n * https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#doubling-dbl-2002-it-2\n * simplified for Z1=1.\n *\n * Blinding uses the equivalence relation (\\lambda X, \\lambda Y, \\lambda Z)\n * for any non-zero \\lambda that holds for projective (homogeneous) coords.\n */\nint ec_GFp_simple_ladder_pre(const EC_GROUP *group,\n                             EC_POINT *r, EC_POINT *s,\n                             EC_POINT *p, BN_CTX *ctx)\n{\n    BIGNUM *t1, *t2, *t3, *t4, *t5 = NULL;\n\n    t1 = s->Z;\n    t2 = r->Z;\n    t3 = s->X;\n    t4 = r->X;\n    t5 = s->Y;\n\n    if (!p->Z_is_one /* r := 2p */\n        || !group->meth->field_sqr(group, t3, p->X, ctx)\n        || !BN_mod_sub_quick(t4, t3, group->a, group->field)\n        || !group->meth->field_sqr(group, t4, t4, ctx)\n        || !group->meth->field_mul(group, t5, p->X, group->b, ctx)\n        || !BN_mod_lshift_quick(t5, t5, 3, group->field)\n        /* r->X coord output */\n        || !BN_mod_sub_quick(r->X, t4, t5, group->field)\n        || !BN_mod_add_quick(t1, t3, group->a, group->field)\n        || !group->meth->field_mul(group, t2, p->X, t1, ctx)\n        || !BN_mod_add_quick(t2, group->b, t2, group->field)\n        /* r->Z coord output */\n        || !BN_mod_lshift_quick(r->Z, t2, 2, group->field))\n        return 0;\n\n    /* make sure lambda (r->Y here for storage) is not zero */\n    do {\n        if (!BN_priv_rand_range(r->Y, group->field))\n            return 0;\n    } while (BN_is_zero(r->Y));\n\n    /* make sure lambda (s->Z here for storage) is not zero */\n    do {\n        if (!BN_priv_rand_range(s->Z, group->field))\n            return 0;\n    } while (BN_is_zero(s->Z));\n\n    /* if field_encode defined convert between representations */\n    if (group->meth->field_encode != NULL\n        && (!group->meth->field_encode(group, r->Y, r->Y, ctx)\n            || !group->meth->field_encode(group, s->Z, s->Z, ctx)))\n        return 0;\n\n    /* blind r and s independently */\n    if (!group->meth->field_mul(group, r->Z, r->Z, r->Y, ctx)\n        || !group->meth->field_mul(group, r->X, r->X, r->Y, ctx)\n        || !group->meth->field_mul(group, s->X, p->X, s->Z, ctx)) /* s := p */\n        return 0;\n\n    r->Z_is_one = 0;\n    s->Z_is_one = 0;\n\n    return 1;\n}\n\n/*-\n * Input:\n * - s, r: projective (homogeneous) coordinates\n * - p: affine coordinates\n *\n * Output:\n * - s := r + s, r := 2r: projective (homogeneous) coordinates\n *\n * Differential addition-and-doubling using Eq. (9) and (10) from Izu-Takagi\n * \"A fast parallel elliptic curve multiplication resistant against side channel\n * attacks\", as described at\n * https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#ladder-mladd-2002-it-4\n */\nint ec_GFp_simple_ladder_step(const EC_GROUP *group,\n                              EC_POINT *r, EC_POINT *s,\n                              EC_POINT *p, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6 = NULL;\n\n    BN_CTX_start(ctx);\n    t0 = BN_CTX_get(ctx);\n    t1 = BN_CTX_get(ctx);\n    t2 = BN_CTX_get(ctx);\n    t3 = BN_CTX_get(ctx);\n    t4 = BN_CTX_get(ctx);\n    t5 = BN_CTX_get(ctx);\n    t6 = BN_CTX_get(ctx);\n\n    if (t6 == NULL\n        || !group->meth->field_mul(group, t6, r->X, s->X, ctx)\n        || !group->meth->field_mul(group, t0, r->Z, s->Z, ctx)\n        || !group->meth->field_mul(group, t4, r->X, s->Z, ctx)\n        || !group->meth->field_mul(group, t3, r->Z, s->X, ctx)\n        || !group->meth->field_mul(group, t5, group->a, t0, ctx)\n        || !BN_mod_add_quick(t5, t6, t5, group->field)\n        || !BN_mod_add_quick(t6, t3, t4, group->field)\n        || !group->meth->field_mul(group, t5, t6, t5, ctx)\n        || !group->meth->field_sqr(group, t0, t0, ctx)\n        || !BN_mod_lshift_quick(t2, group->b, 2, group->field)\n        || !group->meth->field_mul(group, t0, t2, t0, ctx)\n        || !BN_mod_lshift1_quick(t5, t5, group->field)\n        || !BN_mod_sub_quick(t3, t4, t3, group->field)\n        /* s->Z coord output */\n        || !group->meth->field_sqr(group, s->Z, t3, ctx)\n        || !group->meth->field_mul(group, t4, s->Z, p->X, ctx)\n        || !BN_mod_add_quick(t0, t0, t5, group->field)\n        /* s->X coord output */\n        || !BN_mod_sub_quick(s->X, t0, t4, group->field)\n        || !group->meth->field_sqr(group, t4, r->X, ctx)\n        || !group->meth->field_sqr(group, t5, r->Z, ctx)\n        || !group->meth->field_mul(group, t6, t5, group->a, ctx)\n        || !BN_mod_add_quick(t1, r->X, r->Z, group->field)\n        || !group->meth->field_sqr(group, t1, t1, ctx)\n        || !BN_mod_sub_quick(t1, t1, t4, group->field)\n        || !BN_mod_sub_quick(t1, t1, t5, group->field)\n        || !BN_mod_sub_quick(t3, t4, t6, group->field)\n        || !group->meth->field_sqr(group, t3, t3, ctx)\n        || !group->meth->field_mul(group, t0, t5, t1, ctx)\n        || !group->meth->field_mul(group, t0, t2, t0, ctx)\n        /* r->X coord output */\n        || !BN_mod_sub_quick(r->X, t3, t0, group->field)\n        || !BN_mod_add_quick(t3, t4, t6, group->field)\n        || !group->meth->field_sqr(group, t4, t5, ctx)\n        || !group->meth->field_mul(group, t4, t4, t2, ctx)\n        || !group->meth->field_mul(group, t1, t1, t3, ctx)\n        || !BN_mod_lshift1_quick(t1, t1, group->field)\n        /* r->Z coord output */\n        || !BN_mod_add_quick(r->Z, t4, t1, group->field))\n        goto err;\n\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    return ret;\n}\n\n/*-\n * Input:\n * - s, r: projective (homogeneous) coordinates\n * - p: affine coordinates\n *\n * Output:\n * - r := (x,y): affine coordinates\n *\n * Recovers the y-coordinate of r using Eq. (8) from Brier-Joye, \"Weierstrass\n * Elliptic Curves and Side-Channel Attacks\", modified to work in mixed\n * projective coords, i.e. p is affine and (r,s) in projective (homogeneous)\n * coords, and return r in affine coordinates.\n *\n * X4 = two*Y1*X2*Z3*Z2;\n * Y4 = two*b*Z3*SQR(Z2) + Z3*(a*Z2+X1*X2)*(X1*Z2+X2) - X3*SQR(X1*Z2-X2);\n * Z4 = two*Y1*Z3*SQR(Z2);\n *\n * Z4 != 0 because:\n *  - Z2==0 implies r is at infinity (handled by the BN_is_zero(r->Z) branch);\n *  - Z3==0 implies s is at infinity (handled by the BN_is_zero(s->Z) branch);\n *  - Y1==0 implies p has order 2, so either r or s are infinity and handled by\n *    one of the BN_is_zero(...) branches.\n */\nint ec_GFp_simple_ladder_post(const EC_GROUP *group,\n                              EC_POINT *r, EC_POINT *s,\n                              EC_POINT *p, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6 = NULL;\n\n    if (BN_is_zero(r->Z))\n        return EC_POINT_set_to_infinity(group, r);\n\n    if (BN_is_zero(s->Z)) {\n        if (!EC_POINT_copy(r, p)\n            || !EC_POINT_invert(group, r, ctx))\n            return 0;\n        return 1;\n    }\n\n    BN_CTX_start(ctx);\n    t0 = BN_CTX_get(ctx);\n    t1 = BN_CTX_get(ctx);\n    t2 = BN_CTX_get(ctx);\n    t3 = BN_CTX_get(ctx);\n    t4 = BN_CTX_get(ctx);\n    t5 = BN_CTX_get(ctx);\n    t6 = BN_CTX_get(ctx);\n\n    if (t6 == NULL\n        || !BN_mod_lshift1_quick(t4, p->Y, group->field)\n        || !group->meth->field_mul(group, t6, r->X, t4, ctx)\n        || !group->meth->field_mul(group, t6, s->Z, t6, ctx)\n        || !group->meth->field_mul(group, t5, r->Z, t6, ctx)\n        || !BN_mod_lshift1_quick(t1, group->b, group->field)\n        || !group->meth->field_mul(group, t1, s->Z, t1, ctx)\n        || !group->meth->field_sqr(group, t3, r->Z, ctx)\n        || !group->meth->field_mul(group, t2, t3, t1, ctx)\n        || !group->meth->field_mul(group, t6, r->Z, group->a, ctx)\n        || !group->meth->field_mul(group, t1, p->X, r->X, ctx)\n        || !BN_mod_add_quick(t1, t1, t6, group->field)\n        || !group->meth->field_mul(group, t1, s->Z, t1, ctx)\n        || !group->meth->field_mul(group, t0, p->X, r->Z, ctx)\n        || !BN_mod_add_quick(t6, r->X, t0, group->field)\n        || !group->meth->field_mul(group, t6, t6, t1, ctx)\n        || !BN_mod_add_quick(t6, t6, t2, group->field)\n        || !BN_mod_sub_quick(t0, t0, r->X, group->field)\n        || !group->meth->field_sqr(group, t0, t0, ctx)\n        || !group->meth->field_mul(group, t0, t0, s->X, ctx)\n        || !BN_mod_sub_quick(t0, t6, t0, group->field)\n        || !group->meth->field_mul(group, t1, s->Z, t4, ctx)\n        || !group->meth->field_mul(group, t1, t3, t1, ctx)\n        || (group->meth->field_decode != NULL\n            && !group->meth->field_decode(group, t1, t1, ctx))\n        || !group->meth->field_inv(group, t1, t1, ctx)\n        || (group->meth->field_encode != NULL\n            && !group->meth->field_encode(group, t1, t1, ctx))\n        || !group->meth->field_mul(group, r->X, t5, t1, ctx)\n        || !group->meth->field_mul(group, r->Y, t0, t1, ctx))\n        goto err;\n\n    if (group->meth->field_set_to_one != NULL) {\n        if (!group->meth->field_set_to_one(group, r->Z, ctx))\n            goto err;\n    } else {\n        if (!BN_one(r->Z))\n            goto err;\n    }\n\n    r->Z_is_one = 1;\n    ret = 1;\n\n err:\n    BN_CTX_end(ctx);\n    return ret;\n}\n"
  },
  {
    "path": "cryptomini/include/crypto/__DECC_INCLUDE_EPILOGUE.H",
    "content": "/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * This file is only used by HP C on VMS, and is included automatically\n * after each header file from this directory\n */\n\n/* restore state.  Must correspond to the save in __decc_include_prologue.h */\n#pragma names restore\n"
  },
  {
    "path": "cryptomini/include/crypto/__DECC_INCLUDE_PROLOGUE.H",
    "content": "/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * This file is only used by HP C on VMS, and is included automatically\n * after each header file from this directory\n */\n\n/* save state */\n#pragma names save\n/* have the compiler shorten symbols larger than 31 chars to 23 chars\n * followed by a 8 hex char CRC\n */\n#pragma names as_is,shortened\n"
  },
  {
    "path": "cryptomini/include/crypto/aria.h",
    "content": "/*\n * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2017, Oracle and/or its affiliates.  All rights reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n /* Copyright (c) 2017 National Security Research Institute.  All rights reserved. */\n\n#ifndef OSSL_CRYPTO_ARIA_H\n# define OSSL_CRYPTO_ARIA_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_ARIA\n#  error ARIA is disabled.\n# endif\n\n# define ARIA_ENCRYPT     1\n# define ARIA_DECRYPT     0\n\n# define ARIA_BLOCK_SIZE    16  /* Size of each encryption/decryption block */\n# define ARIA_MAX_KEYS      17  /* Number of keys needed in the worst case  */\n\ntypedef union {\n    unsigned char c[ARIA_BLOCK_SIZE];\n    unsigned int u[ARIA_BLOCK_SIZE / sizeof(unsigned int)];\n} ARIA_u128;\n\ntypedef unsigned char ARIA_c128[ARIA_BLOCK_SIZE];\n\nstruct aria_key_st {\n    ARIA_u128 rd_key[ARIA_MAX_KEYS];\n    unsigned int rounds;\n};\ntypedef struct aria_key_st ARIA_KEY;\n\n\nint aria_set_encrypt_key(const unsigned char *userKey, const int bits,\n                         ARIA_KEY *key);\nint aria_set_decrypt_key(const unsigned char *userKey, const int bits,\n                         ARIA_KEY *key);\n\nvoid aria_encrypt(const unsigned char *in, unsigned char *out,\n                  const ARIA_KEY *key);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/asn1.h",
    "content": "/*\n * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/* Internal ASN1 structures and functions: not for application use */\n\n/* ASN1 public key method structure */\n\nstruct evp_pkey_asn1_method_st {\n    int pkey_id;\n    int pkey_base_id;\n    unsigned long pkey_flags;\n    char *pem_str;\n    char *info;\n    int (*pub_decode) (EVP_PKEY *pk, X509_PUBKEY *pub);\n    int (*pub_encode) (X509_PUBKEY *pub, const EVP_PKEY *pk);\n    int (*pub_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);\n    int (*pub_print) (BIO *out, const EVP_PKEY *pkey, int indent,\n                      ASN1_PCTX *pctx);\n    int (*priv_decode) (EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf);\n    int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk);\n    int (*priv_print) (BIO *out, const EVP_PKEY *pkey, int indent,\n                       ASN1_PCTX *pctx);\n    int (*pkey_size) (const EVP_PKEY *pk);\n    int (*pkey_bits) (const EVP_PKEY *pk);\n    int (*pkey_security_bits) (const EVP_PKEY *pk);\n    int (*param_decode) (EVP_PKEY *pkey,\n                         const unsigned char **pder, int derlen);\n    int (*param_encode) (const EVP_PKEY *pkey, unsigned char **pder);\n    int (*param_missing) (const EVP_PKEY *pk);\n    int (*param_copy) (EVP_PKEY *to, const EVP_PKEY *from);\n    int (*param_cmp) (const EVP_PKEY *a, const EVP_PKEY *b);\n    int (*param_print) (BIO *out, const EVP_PKEY *pkey, int indent,\n                        ASN1_PCTX *pctx);\n    int (*sig_print) (BIO *out,\n                      const X509_ALGOR *sigalg, const ASN1_STRING *sig,\n                      int indent, ASN1_PCTX *pctx);\n    void (*pkey_free) (EVP_PKEY *pkey);\n    int (*pkey_ctrl) (EVP_PKEY *pkey, int op, long arg1, void *arg2);\n    /* Legacy functions for old PEM */\n    int (*old_priv_decode) (EVP_PKEY *pkey,\n                            const unsigned char **pder, int derlen);\n    int (*old_priv_encode) (const EVP_PKEY *pkey, unsigned char **pder);\n    /* Custom ASN1 signature verification */\n    int (*item_verify) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,\n                        X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey);\n    int (*item_sign) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,\n                      X509_ALGOR *alg1, X509_ALGOR *alg2,\n                      ASN1_BIT_STRING *sig);\n    int (*siginf_set) (X509_SIG_INFO *siginf, const X509_ALGOR *alg,\n                       const ASN1_STRING *sig);\n    /* Check */\n    int (*pkey_check) (const EVP_PKEY *pk);\n    int (*pkey_public_check) (const EVP_PKEY *pk);\n    int (*pkey_param_check) (const EVP_PKEY *pk);\n    /* Get/set raw private/public key data */\n    int (*set_priv_key) (EVP_PKEY *pk, const unsigned char *priv, size_t len);\n    int (*set_pub_key) (EVP_PKEY *pk, const unsigned char *pub, size_t len);\n    int (*get_priv_key) (const EVP_PKEY *pk, unsigned char *priv, size_t *len);\n    int (*get_pub_key) (const EVP_PKEY *pk, unsigned char *pub, size_t *len);\n} /* EVP_PKEY_ASN1_METHOD */ ;\n\nDEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD)\n\nextern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD dh_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[5];\nextern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD ed448_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD sm2_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD poly1305_asn1_meth;\n\nextern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[2];\nextern const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth;\nextern const EVP_PKEY_ASN1_METHOD siphash_asn1_meth;\n\n/*\n * These are used internally in the ASN1_OBJECT to keep track of whether the\n * names and data need to be free()ed\n */\n# define ASN1_OBJECT_FLAG_DYNAMIC         0x01/* internal use */\n# define ASN1_OBJECT_FLAG_CRITICAL        0x02/* critical x509v3 object id */\n# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */\n# define ASN1_OBJECT_FLAG_DYNAMIC_DATA    0x08/* internal use */\nstruct asn1_object_st {\n    const char *sn, *ln;\n    int nid;\n    int length;\n    const unsigned char *data;  /* data remains const after init */\n    int flags;                  /* Should we free this one */\n};\n\n/* ASN1 print context structure */\n\nstruct asn1_pctx_st {\n    unsigned long flags;\n    unsigned long nm_flags;\n    unsigned long cert_flags;\n    unsigned long oid_flags;\n    unsigned long str_flags;\n} /* ASN1_PCTX */ ;\n\nint asn1_d2i_read_bio(BIO *in, BUF_MEM **pb);\n"
  },
  {
    "path": "cryptomini/include/crypto/async.h",
    "content": "/*\n * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/async.h>\n\nint async_init(void);\nvoid async_deinit(void);\nvoid async_delete_thread_state(void);\n\n"
  },
  {
    "path": "cryptomini/include/crypto/bn.h",
    "content": "/*\n * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_BN_H\n# define OSSL_CRYPTO_BN_H\n\n# include <openssl/bn.h>\n# include <limits.h>\n\nBIGNUM *bn_wexpand(BIGNUM *a, int words);\nBIGNUM *bn_expand2(BIGNUM *a, int words);\n\nvoid bn_correct_top(BIGNUM *a);\n\n/*\n * Determine the modified width-(w+1) Non-Adjacent Form (wNAF) of 'scalar'.\n * This is an array r[] of values that are either zero or odd with an\n * absolute value less than 2^w satisfying scalar = \\sum_j r[j]*2^j where at\n * most one of any w+1 consecutive digits is non-zero with the exception that\n * the most significant digit may be only w-1 zeros away from that next\n * non-zero digit.\n */\nsigned char *bn_compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len);\n\nint bn_get_top(const BIGNUM *a);\n\nint bn_get_dmax(const BIGNUM *a);\n\n/* Set all words to zero */\nvoid bn_set_all_zero(BIGNUM *a);\n\n/*\n * Copy the internal BIGNUM words into out which holds size elements (and size\n * must be bigger than top)\n */\nint bn_copy_words(BN_ULONG *out, const BIGNUM *in, int size);\n\nBN_ULONG *bn_get_words(const BIGNUM *a);\n\n/*\n * Set the internal data words in a to point to words which contains size\n * elements. The BN_FLG_STATIC_DATA flag is set\n */\nvoid bn_set_static_words(BIGNUM *a, const BN_ULONG *words, int size);\n\n/*\n * Copy words into the BIGNUM |a|, reallocating space as necessary.\n * The negative flag of |a| is not modified.\n * Returns 1 on success and 0 on failure.\n */\n/*\n * |num_words| is int because bn_expand2 takes an int. This is an internal\n * function so we simply trust callers not to pass negative values.\n */\nint bn_set_words(BIGNUM *a, const BN_ULONG *words, int num_words);\n\n/*\n * Some BIGNUM functions assume most significant limb to be non-zero, which\n * is customarily arranged by bn_correct_top. Output from below functions\n * is not processed with bn_correct_top, and for this reason it may not be\n * returned out of public API. It may only be passed internally into other\n * functions known to support non-minimal or zero-padded BIGNUMs. Even\n * though the goal is to facilitate constant-time-ness, not each subroutine\n * is constant-time by itself. They all have pre-conditions, consult source\n * code...\n */\nint bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx);\nint bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,\n                         BN_CTX *ctx);\nint bn_from_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,\n                           BN_CTX *ctx);\nint bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                         const BIGNUM *m);\nint bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                         const BIGNUM *m);\nint bn_mul_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);\nint bn_lshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n);\nint bn_rshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n);\nint bn_div_fixed_top(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                     const BIGNUM *d, BN_CTX *ctx);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/bn_conf.h",
    "content": "/* WARNING: do not edit! */\n/* Generated by Makefile from include/crypto/bn_conf.h.in */\n/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_BN_CONF_H\n# define OSSL_CRYPTO_BN_CONF_H\n\n/*\n * The contents of this file are not used in the UEFI build, as\n * both 32-bit and 64-bit builds are supported from a single run\n * of the Configure script.\n */\n\n/* Should we define BN_DIV2W here? */\n\n/* Only one for the following should be defined */\n#define SIXTY_FOUR_BIT_LONG\n#undef SIXTY_FOUR_BIT\n#undef THIRTY_TWO_BIT\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/bn_conf.h.in",
    "content": "{- join(\"\\n\",map { \"/* $_ */\" } @autowarntext) -}\n/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_BN_CONF_H\n# define OSSL_CRYPTO_BN_CONF_H\n\n/*\n * The contents of this file are not used in the UEFI build, as\n * both 32-bit and 64-bit builds are supported from a single run\n * of the Configure script.\n */\n\n/* Should we define BN_DIV2W here? */\n\n/* Only one for the following should be defined */\n{- $config{b64l} ? \"#define\" : \"#undef\" -} SIXTY_FOUR_BIT_LONG\n{- $config{b64}  ? \"#define\" : \"#undef\" -} SIXTY_FOUR_BIT\n{- $config{b32}  ? \"#define\" : \"#undef\" -} THIRTY_TWO_BIT\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/bn_dh.h",
    "content": "/*\n * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#define declare_dh_bn(x) \\\n    extern const BIGNUM _bignum_dh##x##_p;              \\\n    extern const BIGNUM _bignum_dh##x##_g;              \\\n    extern const BIGNUM _bignum_dh##x##_q;\n\ndeclare_dh_bn(1024_160)\ndeclare_dh_bn(2048_224)\ndeclare_dh_bn(2048_256)\n\nextern const BIGNUM _bignum_ffdhe2048_p;\nextern const BIGNUM _bignum_ffdhe3072_p;\nextern const BIGNUM _bignum_ffdhe4096_p;\nextern const BIGNUM _bignum_ffdhe6144_p;\nextern const BIGNUM _bignum_ffdhe8192_p;\nextern const BIGNUM _bignum_const_2;\n"
  },
  {
    "path": "cryptomini/include/crypto/bn_srp.h",
    "content": "/*\n * Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OPENSSL_NO_SRP\n\nextern const BIGNUM bn_group_1024;\n\nextern const BIGNUM bn_group_1536;\n\nextern const BIGNUM bn_group_2048;\n\nextern const BIGNUM bn_group_3072;\n\nextern const BIGNUM bn_group_4096;\n\nextern const BIGNUM bn_group_6144;\n\nextern const BIGNUM bn_group_8192;\n\nextern const BIGNUM bn_generator_19;\n\nextern const BIGNUM bn_generator_5;\n\nextern const BIGNUM bn_generator_2;\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/chacha.h",
    "content": "/*\n * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_CHACHA_H\n#define OSSL_CRYPTO_CHACHA_H\n\n#include <stddef.h>\n\n/*\n * ChaCha20_ctr32 encrypts |len| bytes from |inp| with the given key and\n * nonce and writes the result to |out|, which may be equal to |inp|.\n * The |key| is not 32 bytes of verbatim key material though, but the\n * said material collected into 8 32-bit elements array in host byte\n * order. Same approach applies to nonce: the |counter| argument is\n * pointer to concatenated nonce and counter values collected into 4\n * 32-bit elements. This, passing crypto material collected into 32-bit\n * elements as opposite to passing verbatim byte vectors, is chosen for\n * efficiency in multi-call scenarios.\n */\nvoid ChaCha20_ctr32(unsigned char *out, const unsigned char *inp,\n                    size_t len, const unsigned int key[8],\n                    const unsigned int counter[4]);\n/*\n * You can notice that there is no key setup procedure. Because it's\n * as trivial as collecting bytes into 32-bit elements, it's reckoned\n * that below macro is sufficient.\n */\n#define CHACHA_U8TOU32(p)  ( \\\n                ((unsigned int)(p)[0])     | ((unsigned int)(p)[1]<<8) | \\\n                ((unsigned int)(p)[2]<<16) | ((unsigned int)(p)[3]<<24)  )\n\n#define CHACHA_KEY_SIZE\t\t32\n#define CHACHA_CTR_SIZE\t\t16\n#define CHACHA_BLK_SIZE\t\t64\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/cryptlib.h",
    "content": "/*\n * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/cryptlib.h\"\n\n/* This file is not scanned by mkdef.pl, whereas cryptlib.h is */\n\nstruct thread_local_inits_st {\n    int async;\n    int err_state;\n    int rand;\n};\n\nint ossl_init_thread_start(uint64_t opts);\n\n/*\n * OPENSSL_INIT flags. The primary list of these is in crypto.h. Flags below\n * are those omitted from crypto.h because they are \"reserved for internal\n * use\".\n */\n# define OPENSSL_INIT_ZLIB                   0x00010000L\n# define OPENSSL_INIT_BASE_ONLY              0x00040000L\n\n/* OPENSSL_INIT_THREAD flags */\n# define OPENSSL_INIT_THREAD_ASYNC           0x01\n# define OPENSSL_INIT_THREAD_ERR_STATE       0x02\n# define OPENSSL_INIT_THREAD_RAND            0x04\n\nvoid ossl_malloc_setup_failures(void);\n"
  },
  {
    "path": "cryptomini/include/crypto/ctype.h",
    "content": "/*\n * Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * This version of ctype.h provides a standardised and platform\n * independent implementation that supports seven bit ASCII characters.\n * The specific intent is to not pass extended ASCII characters (> 127)\n * even if the host operating system would.\n *\n * There is EBCDIC support included for machines which use this.  However,\n * there are a number of concerns about how well EBCDIC is supported\n * throughout the rest of the source code.  Refer to issue #4154 for\n * details.\n */\n#ifndef OSSL_CRYPTO_CTYPE_H\n# define OSSL_CRYPTO_CTYPE_H\n\n# define CTYPE_MASK_lower       0x1\n# define CTYPE_MASK_upper       0x2\n# define CTYPE_MASK_digit       0x4\n# define CTYPE_MASK_space       0x8\n# define CTYPE_MASK_xdigit      0x10\n# define CTYPE_MASK_blank       0x20\n# define CTYPE_MASK_cntrl       0x40\n# define CTYPE_MASK_graph       0x80\n# define CTYPE_MASK_print       0x100\n# define CTYPE_MASK_punct       0x200\n# define CTYPE_MASK_base64      0x400\n# define CTYPE_MASK_asn1print   0x800\n\n# define CTYPE_MASK_alpha   (CTYPE_MASK_lower | CTYPE_MASK_upper)\n# define CTYPE_MASK_alnum   (CTYPE_MASK_alpha | CTYPE_MASK_digit)\n\n/*\n * The ascii mask assumes that any other classification implies that\n * the character is ASCII and that there are no ASCII characters\n * that aren't in any of the classifications.\n *\n * This assumption holds at the moment, but it might not in the future.\n */\n# define CTYPE_MASK_ascii   (~0)\n\n# ifdef CHARSET_EBCDIC\nint ossl_toascii(int c);\nint ossl_fromascii(int c);\n# else\n#  define ossl_toascii(c)       (c)\n#  define ossl_fromascii(c)     (c)\n# endif\nint ossl_ctype_check(int c, unsigned int mask);\nint ossl_tolower(int c);\nint ossl_toupper(int c);\n\nint ascii_isdigit(const char inchar);\n\n# define ossl_isalnum(c)        (ossl_ctype_check((c), CTYPE_MASK_alnum))\n# define ossl_isalpha(c)        (ossl_ctype_check((c), CTYPE_MASK_alpha))\n# ifdef CHARSET_EBCDIC\n# define ossl_isascii(c)        (ossl_ctype_check((c), CTYPE_MASK_ascii))\n# else\n# define ossl_isascii(c)        (((c) & ~127) == 0)\n# endif\n# define ossl_isblank(c)        (ossl_ctype_check((c), CTYPE_MASK_blank))\n# define ossl_iscntrl(c)        (ossl_ctype_check((c), CTYPE_MASK_cntrl))\n# define ossl_isdigit(c)        (ossl_ctype_check((c), CTYPE_MASK_digit))\n# define ossl_isgraph(c)        (ossl_ctype_check((c), CTYPE_MASK_graph))\n# define ossl_islower(c)        (ossl_ctype_check((c), CTYPE_MASK_lower))\n# define ossl_isprint(c)        (ossl_ctype_check((c), CTYPE_MASK_print))\n# define ossl_ispunct(c)        (ossl_ctype_check((c), CTYPE_MASK_punct))\n# define ossl_isspace(c)        (ossl_ctype_check((c), CTYPE_MASK_space))\n# define ossl_isupper(c)        (ossl_ctype_check((c), CTYPE_MASK_upper))\n# define ossl_isxdigit(c)       (ossl_ctype_check((c), CTYPE_MASK_xdigit))\n# define ossl_isbase64(c)       (ossl_ctype_check((c), CTYPE_MASK_base64))\n# define ossl_isasn1print(c)    (ossl_ctype_check((c), CTYPE_MASK_asn1print))\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/dso_conf.h",
    "content": "/* WARNING: do not edit! */\n/* Generated by Makefile from include/crypto/dso_conf.h.in */\n/*\n * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_DSO_CONF_H\n# define OSSL_CRYPTO_DSO_CONF_H\n# define DSO_NONE\n# define DSO_EXTENSION \".so\"\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/dso_conf.h.in",
    "content": "{- join(\"\\n\",map { \"/* $_ */\" } @autowarntext) -}\n/*\n * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_DSO_CONF_H\n# define OSSL_CRYPTO_DSO_CONF_H\n{-  # The DSO code currently always implements all functions so that no\n    # applications will have to worry about that from a compilation point\n    # of view. However, the \"method\"s may return zero unless that platform\n    # has support compiled in for them. Currently each method is enabled\n    # by a define \"DSO_<name>\" ... we translate the \"dso_scheme\" config\n    # string entry into using the following logic;\n    my $scheme = $disabled{dso} ? undef : uc $target{dso_scheme};\n    if (!$scheme) {\n        $scheme = \"NONE\";\n    }\n    my @macros = ( \"DSO_$scheme\" );\n    if ($scheme eq 'DLFCN') {\n        @macros = ( \"DSO_DLFCN\", \"HAVE_DLFCN_H\" );\n    } elsif ($scheme eq \"DLFCN_NO_H\") {\n        @macros = ( \"DSO_DLFCN\" );\n    }\n    join(\"\\n\", map { \"# define $_\" } @macros); -}\n# define DSO_EXTENSION \"{- $target{dso_extension} -}\"\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/ec.h",
    "content": "/*\n * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/* Internal EC functions for other submodules: not for application use */\n\n#ifndef OSSL_CRYPTO_EC_H\n# define OSSL_CRYPTO_EC_H\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_EC\n\n#  include <openssl/ec.h>\n\n/*-\n * Computes the multiplicative inverse of x in the range\n * [1,EC_GROUP::order), where EC_GROUP::order is the cardinality of the\n * subgroup generated by the generator G:\n *\n *         res := x^(-1) (mod EC_GROUP::order).\n *\n * This function expects the following two conditions to hold:\n *  - the EC_GROUP order is prime, and\n *  - x is included in the range [1, EC_GROUP::order).\n *\n * This function returns 1 on success, 0 on error.\n *\n * If the EC_GROUP order is even, this function explicitly returns 0 as\n * an error.\n * In case any of the two conditions stated above is not satisfied,\n * the correctness of its output is not guaranteed, even if the return\n * value could still be 1 (as primality testing and a conditional modular\n * reduction round on the input can be omitted by the underlying\n * implementations for better SCA properties on regular input values).\n */\n__owur int ec_group_do_inverse_ord(const EC_GROUP *group, BIGNUM *res,\n                                   const BIGNUM *x, BN_CTX *ctx);\n\n/*-\n * ECDH Key Derivation Function as defined in ANSI X9.63\n */\nint ecdh_KDF_X9_63(unsigned char *out, size_t outlen,\n                   const unsigned char *Z, size_t Zlen,\n                   const unsigned char *sinfo, size_t sinfolen,\n                   const EVP_MD *md);\n\n# endif /* OPENSSL_NO_EC */\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/engine.h",
    "content": "/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/engine.h>\n\nvoid engine_load_openssl_int(void);\nvoid engine_load_devcrypto_int(void);\nvoid engine_load_rdrand_int(void);\nvoid engine_load_dynamic_int(void);\nvoid engine_load_padlock_int(void);\nvoid engine_load_capi_int(void);\nvoid engine_load_dasync_int(void);\nvoid engine_load_afalg_int(void);\nvoid engine_cleanup_int(void);\n"
  },
  {
    "path": "cryptomini/include/crypto/err.h",
    "content": "/*\n * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_ERR_H\n# define OSSL_CRYPTO_ERR_H\n\nint err_load_crypto_strings_int(void);\nvoid err_cleanup(void);\nvoid err_delete_thread_state(void);\nint err_shelve_state(void **);\nvoid err_unshelve_state(void *);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/evp.h",
    "content": "/*\n * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/evp.h>\n#include \"internal/refcount.h\"\n\n/*\n * Don't free up md_ctx->pctx in EVP_MD_CTX_reset, use the reserved flag\n * values in evp.h\n */\n#define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX   0x0400\n\nstruct evp_pkey_ctx_st {\n    /* Method associated with this operation */\n    const EVP_PKEY_METHOD *pmeth;\n    /* Engine that implements this method or NULL if builtin */\n    ENGINE *engine;\n    /* Key: may be NULL */\n    EVP_PKEY *pkey;\n    /* Peer key for key agreement, may be NULL */\n    EVP_PKEY *peerkey;\n    /* Actual operation */\n    int operation;\n    /* Algorithm specific data */\n    void *data;\n    /* Application specific data */\n    void *app_data;\n    /* Keygen callback */\n    EVP_PKEY_gen_cb *pkey_gencb;\n    /* implementation specific keygen data */\n    int *keygen_info;\n    int keygen_info_count;\n} /* EVP_PKEY_CTX */ ;\n\n#define EVP_PKEY_FLAG_DYNAMIC   1\n\nstruct evp_pkey_method_st {\n    int pkey_id;\n    int flags;\n    int (*init) (EVP_PKEY_CTX *ctx);\n    int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);\n    void (*cleanup) (EVP_PKEY_CTX *ctx);\n    int (*paramgen_init) (EVP_PKEY_CTX *ctx);\n    int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);\n    int (*keygen_init) (EVP_PKEY_CTX *ctx);\n    int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);\n    int (*sign_init) (EVP_PKEY_CTX *ctx);\n    int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,\n                 const unsigned char *tbs, size_t tbslen);\n    int (*verify_init) (EVP_PKEY_CTX *ctx);\n    int (*verify) (EVP_PKEY_CTX *ctx,\n                   const unsigned char *sig, size_t siglen,\n                   const unsigned char *tbs, size_t tbslen);\n    int (*verify_recover_init) (EVP_PKEY_CTX *ctx);\n    int (*verify_recover) (EVP_PKEY_CTX *ctx,\n                           unsigned char *rout, size_t *routlen,\n                           const unsigned char *sig, size_t siglen);\n    int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);\n    int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,\n                    EVP_MD_CTX *mctx);\n    int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);\n    int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,\n                      EVP_MD_CTX *mctx);\n    int (*encrypt_init) (EVP_PKEY_CTX *ctx);\n    int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,\n                    const unsigned char *in, size_t inlen);\n    int (*decrypt_init) (EVP_PKEY_CTX *ctx);\n    int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,\n                    const unsigned char *in, size_t inlen);\n    int (*derive_init) (EVP_PKEY_CTX *ctx);\n    int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);\n    int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);\n    int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);\n    int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,\n                       const unsigned char *tbs, size_t tbslen);\n    int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,\n                         size_t siglen, const unsigned char *tbs,\n                         size_t tbslen);\n    int (*check) (EVP_PKEY *pkey);\n    int (*public_check) (EVP_PKEY *pkey);\n    int (*param_check) (EVP_PKEY *pkey);\n\n    int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);\n} /* EVP_PKEY_METHOD */ ;\n\nDEFINE_STACK_OF_CONST(EVP_PKEY_METHOD)\n\nvoid evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);\n\nextern const EVP_PKEY_METHOD cmac_pkey_meth;\nextern const EVP_PKEY_METHOD dh_pkey_meth;\nextern const EVP_PKEY_METHOD dhx_pkey_meth;\nextern const EVP_PKEY_METHOD dsa_pkey_meth;\nextern const EVP_PKEY_METHOD ec_pkey_meth;\nextern const EVP_PKEY_METHOD sm2_pkey_meth;\nextern const EVP_PKEY_METHOD ecx25519_pkey_meth;\nextern const EVP_PKEY_METHOD ecx448_pkey_meth;\nextern const EVP_PKEY_METHOD ed25519_pkey_meth;\nextern const EVP_PKEY_METHOD ed448_pkey_meth;\nextern const EVP_PKEY_METHOD hmac_pkey_meth;\nextern const EVP_PKEY_METHOD rsa_pkey_meth;\nextern const EVP_PKEY_METHOD rsa_pss_pkey_meth;\nextern const EVP_PKEY_METHOD scrypt_pkey_meth;\nextern const EVP_PKEY_METHOD tls1_prf_pkey_meth;\nextern const EVP_PKEY_METHOD hkdf_pkey_meth;\nextern const EVP_PKEY_METHOD poly1305_pkey_meth;\nextern const EVP_PKEY_METHOD siphash_pkey_meth;\n\nstruct evp_md_st {\n    int type;\n    int pkey_type;\n    int md_size;\n    unsigned long flags;\n    int (*init) (EVP_MD_CTX *ctx);\n    int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);\n    int (*final) (EVP_MD_CTX *ctx, unsigned char *md);\n    int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from);\n    int (*cleanup) (EVP_MD_CTX *ctx);\n    int block_size;\n    int ctx_size;               /* how big does the ctx->md_data need to be */\n    /* control function */\n    int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2);\n} /* EVP_MD */ ;\n\nstruct evp_cipher_st {\n    int nid;\n    int block_size;\n    /* Default value for variable length ciphers */\n    int key_len;\n    int iv_len;\n    /* Various flags */\n    unsigned long flags;\n    /* init key */\n    int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key,\n                 const unsigned char *iv, int enc);\n    /* encrypt/decrypt data */\n    int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out,\n                      const unsigned char *in, size_t inl);\n    /* cleanup ctx */\n    int (*cleanup) (EVP_CIPHER_CTX *);\n    /* how big ctx->cipher_data needs to be */\n    int ctx_size;\n    /* Populate a ASN1_TYPE with parameters */\n    int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Get parameters from a ASN1_TYPE */\n    int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);\n    /* Miscellaneous operations */\n    int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr);\n    /* Application data */\n    void *app_data;\n} /* EVP_CIPHER */ ;\n\n/* Macros to code block cipher wrappers */\n\n/* Wrapper functions for each cipher mode */\n\n#define EVP_C_DATA(kstruct, ctx) \\\n        ((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx))\n\n#define BLOCK_CIPHER_ecb_loop() \\\n        size_t i, bl; \\\n        bl = EVP_CIPHER_CTX_cipher(ctx)->block_size;    \\\n        if (inl < bl) return 1;\\\n        inl -= bl; \\\n        for (i=0; i <= inl; i+=bl)\n\n#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \\\nstatic int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \\\n{\\\n        BLOCK_CIPHER_ecb_loop() \\\n            cprefix##_ecb_encrypt(in + i, out + i, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_encrypting(ctx)); \\\n        return 1;\\\n}\n\n#define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))\n\n#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \\\n    static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \\\n{\\\n        while(inl>=EVP_MAXCHUNK) {\\\n            int num = EVP_CIPHER_CTX_num(ctx);\\\n            cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \\\n            EVP_CIPHER_CTX_set_num(ctx, num);\\\n            inl-=EVP_MAXCHUNK;\\\n            in +=EVP_MAXCHUNK;\\\n            out+=EVP_MAXCHUNK;\\\n        }\\\n        if (inl) {\\\n            int num = EVP_CIPHER_CTX_num(ctx);\\\n            cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \\\n            EVP_CIPHER_CTX_set_num(ctx, num);\\\n        }\\\n        return 1;\\\n}\n\n#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \\\nstatic int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \\\n{\\\n        while(inl>=EVP_MAXCHUNK) \\\n            {\\\n            cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\\\n            inl-=EVP_MAXCHUNK;\\\n            in +=EVP_MAXCHUNK;\\\n            out+=EVP_MAXCHUNK;\\\n            }\\\n        if (inl)\\\n            cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\\\n        return 1;\\\n}\n\n#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched)  \\\nstatic int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \\\n{\\\n    size_t chunk = EVP_MAXCHUNK;\\\n    if (cbits == 1)  chunk >>= 3;\\\n    if (inl < chunk) chunk = inl;\\\n    while (inl && inl >= chunk)\\\n    {\\\n        int num = EVP_CIPHER_CTX_num(ctx);\\\n        cprefix##_cfb##cbits##_encrypt(in, out, (long) \\\n            ((cbits == 1) \\\n                && !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \\\n                ? chunk*8 : chunk), \\\n            &EVP_C_DATA(kstruct, ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx),\\\n            &num, EVP_CIPHER_CTX_encrypting(ctx));\\\n        EVP_CIPHER_CTX_set_num(ctx, num);\\\n        inl -= chunk;\\\n        in += chunk;\\\n        out += chunk;\\\n        if (inl < chunk) chunk = inl;\\\n    }\\\n    return 1;\\\n}\n\n#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \\\n        BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \\\n        BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \\\n        BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \\\n        BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)\n\n#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \\\n                          key_len, iv_len, flags, init_key, cleanup, \\\n                          set_asn1, get_asn1, ctrl) \\\nstatic const EVP_CIPHER cname##_##mode = { \\\n        nid##_##nmode, block_size, key_len, iv_len, \\\n        flags | EVP_CIPH_##MODE##_MODE, \\\n        init_key, \\\n        cname##_##mode##_cipher, \\\n        cleanup, \\\n        sizeof(kstruct), \\\n        set_asn1, get_asn1,\\\n        ctrl, \\\n        NULL \\\n}; \\\nconst EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }\n\n#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \\\n                             iv_len, flags, init_key, cleanup, set_asn1, \\\n                             get_asn1, ctrl) \\\nBLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \\\n                  iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)\n\n#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \\\n                             iv_len, cbits, flags, init_key, cleanup, \\\n                             set_asn1, get_asn1, ctrl) \\\nBLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \\\n                  key_len, iv_len, flags, init_key, cleanup, set_asn1, \\\n                  get_asn1, ctrl)\n\n#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \\\n                             iv_len, cbits, flags, init_key, cleanup, \\\n                             set_asn1, get_asn1, ctrl) \\\nBLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \\\n                  key_len, iv_len, flags, init_key, cleanup, set_asn1, \\\n                  get_asn1, ctrl)\n\n#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \\\n                             flags, init_key, cleanup, set_asn1, \\\n                             get_asn1, ctrl) \\\nBLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \\\n                  0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)\n\n#define BLOCK_CIPHER_defs(cname, kstruct, \\\n                          nid, block_size, key_len, iv_len, cbits, flags, \\\n                          init_key, cleanup, set_asn1, get_asn1, ctrl) \\\nBLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \\\n                     init_key, cleanup, set_asn1, get_asn1, ctrl) \\\nBLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \\\n                     flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \\\nBLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \\\n                     flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \\\nBLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \\\n                     init_key, cleanup, set_asn1, get_asn1, ctrl)\n\n/*-\n#define BLOCK_CIPHER_defs(cname, kstruct, \\\n                                nid, block_size, key_len, iv_len, flags,\\\n                                 init_key, cleanup, set_asn1, get_asn1, ctrl)\\\nstatic const EVP_CIPHER cname##_cbc = {\\\n        nid##_cbc, block_size, key_len, iv_len, \\\n        flags | EVP_CIPH_CBC_MODE,\\\n        init_key,\\\n        cname##_cbc_cipher,\\\n        cleanup,\\\n        sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\\\n                sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\\\n        set_asn1, get_asn1,\\\n        ctrl, \\\n        NULL \\\n};\\\nconst EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\\\nstatic const EVP_CIPHER cname##_cfb = {\\\n        nid##_cfb64, 1, key_len, iv_len, \\\n        flags | EVP_CIPH_CFB_MODE,\\\n        init_key,\\\n        cname##_cfb_cipher,\\\n        cleanup,\\\n        sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\\\n                sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\\\n        set_asn1, get_asn1,\\\n        ctrl,\\\n        NULL \\\n};\\\nconst EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\\\nstatic const EVP_CIPHER cname##_ofb = {\\\n        nid##_ofb64, 1, key_len, iv_len, \\\n        flags | EVP_CIPH_OFB_MODE,\\\n        init_key,\\\n        cname##_ofb_cipher,\\\n        cleanup,\\\n        sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\\\n                sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\\\n        set_asn1, get_asn1,\\\n        ctrl,\\\n        NULL \\\n};\\\nconst EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\\\nstatic const EVP_CIPHER cname##_ecb = {\\\n        nid##_ecb, block_size, key_len, iv_len, \\\n        flags | EVP_CIPH_ECB_MODE,\\\n        init_key,\\\n        cname##_ecb_cipher,\\\n        cleanup,\\\n        sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\\\n                sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\\\n        set_asn1, get_asn1,\\\n        ctrl,\\\n        NULL \\\n};\\\nconst EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }\n*/\n\n#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \\\n                               block_size, key_len, iv_len, cbits, \\\n                               flags, init_key, \\\n                               cleanup, set_asn1, get_asn1, ctrl) \\\n        BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \\\n        BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \\\n                          cbits, flags, init_key, cleanup, set_asn1, \\\n                          get_asn1, ctrl)\n\n#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \\\n        BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \\\n        BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \\\n                             NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \\\n                             (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \\\n                             cipher##_init_key, NULL, NULL, NULL, NULL)\n\n\n# ifndef OPENSSL_NO_EC\n\n#define X25519_KEYLEN        32\n#define X448_KEYLEN          56\n#define ED448_KEYLEN         57\n\n#define MAX_KEYLEN  ED448_KEYLEN\n\ntypedef struct {\n    unsigned char pubkey[MAX_KEYLEN];\n    unsigned char *privkey;\n} ECX_KEY;\n\n#endif\n\n/*\n * Type needs to be a bit field Sub-type needs to be for variations on the\n * method, as in, can it do arbitrary encryption....\n */\nstruct evp_pkey_st {\n    int type;\n    int save_type;\n    CRYPTO_REF_COUNT references;\n    const EVP_PKEY_ASN1_METHOD *ameth;\n    ENGINE *engine;\n    ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */\n    union {\n        void *ptr;\n# ifndef OPENSSL_NO_RSA\n        struct rsa_st *rsa;     /* RSA */\n# endif\n# ifndef OPENSSL_NO_DSA\n        struct dsa_st *dsa;     /* DSA */\n# endif\n# ifndef OPENSSL_NO_DH\n        struct dh_st *dh;       /* DH */\n# endif\n# ifndef OPENSSL_NO_EC\n        struct ec_key_st *ec;   /* ECC */\n        ECX_KEY *ecx;           /* X25519, X448, Ed25519, Ed448 */\n# endif\n    } pkey;\n    int save_parameters;\n    STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */\n    CRYPTO_RWLOCK *lock;\n} /* EVP_PKEY */ ;\n\n\nvoid openssl_add_all_ciphers_int(void);\nvoid openssl_add_all_digests_int(void);\nvoid evp_cleanup_int(void);\nvoid evp_app_cleanup_int(void);\n\n/* Pulling defines out of C source files */\n\n#define EVP_RC4_KEY_SIZE 16\n#ifndef TLS1_1_VERSION\n# define TLS1_1_VERSION   0x0302\n#endif\n\nvoid evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags);\n\n/* EVP_ENCODE_CTX flags */\n/* Don't generate new lines when encoding */\n#define EVP_ENCODE_CTX_NO_NEWLINES          1\n/* Use the SRP base64 alphabet instead of the standard one */\n#define EVP_ENCODE_CTX_USE_SRP_ALPHABET     2\n"
  },
  {
    "path": "cryptomini/include/crypto/lhash.h",
    "content": "/*\n * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_LHASH_H\n# define OSSL_CRYPTO_LHASH_H\n\nunsigned long openssl_lh_strcasehash(const char *);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/md32_common.h",
    "content": "/*\n * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*-\n * This is a generic 32 bit \"collector\" for message digest algorithms.\n * Whenever needed it collects input character stream into chunks of\n * 32 bit values and invokes a block function that performs actual hash\n * calculations.\n *\n * Porting guide.\n *\n * Obligatory macros:\n *\n * DATA_ORDER_IS_BIG_ENDIAN or DATA_ORDER_IS_LITTLE_ENDIAN\n *      this macro defines byte order of input stream.\n * HASH_CBLOCK\n *      size of a unit chunk HASH_BLOCK operates on.\n * HASH_LONG\n *      has to be at least 32 bit wide.\n * HASH_CTX\n *      context structure that at least contains following\n *      members:\n *              typedef struct {\n *                      ...\n *                      HASH_LONG       Nl,Nh;\n *                      either {\n *                      HASH_LONG       data[HASH_LBLOCK];\n *                      unsigned char   data[HASH_CBLOCK];\n *                      };\n *                      unsigned int    num;\n *                      ...\n *                      } HASH_CTX;\n *      data[] vector is expected to be zeroed upon first call to\n *      HASH_UPDATE.\n * HASH_UPDATE\n *      name of \"Update\" function, implemented here.\n * HASH_TRANSFORM\n *      name of \"Transform\" function, implemented here.\n * HASH_FINAL\n *      name of \"Final\" function, implemented here.\n * HASH_BLOCK_DATA_ORDER\n *      name of \"block\" function capable of treating *unaligned* input\n *      message in original (data) byte order, implemented externally.\n * HASH_MAKE_STRING\n *      macro converting context variables to an ASCII hash string.\n *\n * MD5 example:\n *\n *      #define DATA_ORDER_IS_LITTLE_ENDIAN\n *\n *      #define HASH_LONG               MD5_LONG\n *      #define HASH_CTX                MD5_CTX\n *      #define HASH_CBLOCK             MD5_CBLOCK\n *      #define HASH_UPDATE             MD5_Update\n *      #define HASH_TRANSFORM          MD5_Transform\n *      #define HASH_FINAL              MD5_Final\n *      #define HASH_BLOCK_DATA_ORDER   md5_block_data_order\n */\n\n#include <openssl/crypto.h>\n\n#if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN)\n# error \"DATA_ORDER must be defined!\"\n#endif\n\n#ifndef HASH_CBLOCK\n# error \"HASH_CBLOCK must be defined!\"\n#endif\n#ifndef HASH_LONG\n# error \"HASH_LONG must be defined!\"\n#endif\n#ifndef HASH_CTX\n# error \"HASH_CTX must be defined!\"\n#endif\n\n#ifndef HASH_UPDATE\n# error \"HASH_UPDATE must be defined!\"\n#endif\n#ifndef HASH_TRANSFORM\n# error \"HASH_TRANSFORM must be defined!\"\n#endif\n#ifndef HASH_FINAL\n# error \"HASH_FINAL must be defined!\"\n#endif\n\n#ifndef HASH_BLOCK_DATA_ORDER\n# error \"HASH_BLOCK_DATA_ORDER must be defined!\"\n#endif\n\n#define ROTATE(a,n)     (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))\n\n#if defined(DATA_ORDER_IS_BIG_ENDIAN)\n\n# define HOST_c2l(c,l)  (l =(((unsigned long)(*((c)++)))<<24),          \\\n                         l|=(((unsigned long)(*((c)++)))<<16),          \\\n                         l|=(((unsigned long)(*((c)++)))<< 8),          \\\n                         l|=(((unsigned long)(*((c)++)))    )           )\n# define HOST_l2c(l,c)  (*((c)++)=(unsigned char)(((l)>>24)&0xff),      \\\n                         *((c)++)=(unsigned char)(((l)>>16)&0xff),      \\\n                         *((c)++)=(unsigned char)(((l)>> 8)&0xff),      \\\n                         *((c)++)=(unsigned char)(((l)    )&0xff),      \\\n                         l)\n\n#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)\n\n# define HOST_c2l(c,l)  (l =(((unsigned long)(*((c)++)))    ),          \\\n                         l|=(((unsigned long)(*((c)++)))<< 8),          \\\n                         l|=(((unsigned long)(*((c)++)))<<16),          \\\n                         l|=(((unsigned long)(*((c)++)))<<24)           )\n# define HOST_l2c(l,c)  (*((c)++)=(unsigned char)(((l)    )&0xff),      \\\n                         *((c)++)=(unsigned char)(((l)>> 8)&0xff),      \\\n                         *((c)++)=(unsigned char)(((l)>>16)&0xff),      \\\n                         *((c)++)=(unsigned char)(((l)>>24)&0xff),      \\\n                         l)\n\n#endif\n\n/*\n * Time for some action :-)\n */\n\nint HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len)\n{\n    const unsigned char *data = data_;\n    unsigned char *p;\n    HASH_LONG l;\n    size_t n;\n\n    if (len == 0)\n        return 1;\n\n    l = (c->Nl + (((HASH_LONG) len) << 3)) & 0xffffffffUL;\n    if (l < c->Nl)              /* overflow */\n        c->Nh++;\n    c->Nh += (HASH_LONG) (len >> 29); /* might cause compiler warning on\n                                       * 16-bit */\n    c->Nl = l;\n\n    n = c->num;\n    if (n != 0) {\n        p = (unsigned char *)c->data;\n\n        if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) {\n            memcpy(p + n, data, HASH_CBLOCK - n);\n            HASH_BLOCK_DATA_ORDER(c, p, 1);\n            n = HASH_CBLOCK - n;\n            data += n;\n            len -= n;\n            c->num = 0;\n            /*\n             * We use memset rather than OPENSSL_cleanse() here deliberately.\n             * Using OPENSSL_cleanse() here could be a performance issue. It\n             * will get properly cleansed on finalisation so this isn't a\n             * security problem.\n             */\n            memset(p, 0, HASH_CBLOCK); /* keep it zeroed */\n        } else {\n            memcpy(p + n, data, len);\n            c->num += (unsigned int)len;\n            return 1;\n        }\n    }\n\n    n = len / HASH_CBLOCK;\n    if (n > 0) {\n        HASH_BLOCK_DATA_ORDER(c, data, n);\n        n *= HASH_CBLOCK;\n        data += n;\n        len -= n;\n    }\n\n    if (len != 0) {\n        p = (unsigned char *)c->data;\n        c->num = (unsigned int)len;\n        memcpy(p, data, len);\n    }\n    return 1;\n}\n\nvoid HASH_TRANSFORM(HASH_CTX *c, const unsigned char *data)\n{\n    HASH_BLOCK_DATA_ORDER(c, data, 1);\n}\n\nint HASH_FINAL(unsigned char *md, HASH_CTX *c)\n{\n    unsigned char *p = (unsigned char *)c->data;\n    size_t n = c->num;\n\n    p[n] = 0x80;                /* there is always room for one */\n    n++;\n\n    if (n > (HASH_CBLOCK - 8)) {\n        memset(p + n, 0, HASH_CBLOCK - n);\n        n = 0;\n        HASH_BLOCK_DATA_ORDER(c, p, 1);\n    }\n    memset(p + n, 0, HASH_CBLOCK - 8 - n);\n\n    p += HASH_CBLOCK - 8;\n#if   defined(DATA_ORDER_IS_BIG_ENDIAN)\n    (void)HOST_l2c(c->Nh, p);\n    (void)HOST_l2c(c->Nl, p);\n#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)\n    (void)HOST_l2c(c->Nl, p);\n    (void)HOST_l2c(c->Nh, p);\n#endif\n    p -= HASH_CBLOCK;\n    HASH_BLOCK_DATA_ORDER(c, p, 1);\n    c->num = 0;\n    OPENSSL_cleanse(p, HASH_CBLOCK);\n\n#ifndef HASH_MAKE_STRING\n# error \"HASH_MAKE_STRING must be defined!\"\n#else\n    HASH_MAKE_STRING(c, md);\n#endif\n\n    return 1;\n}\n\n#ifndef MD32_REG_T\n# if defined(__alpha) || defined(__sparcv9) || defined(__mips)\n#  define MD32_REG_T long\n/*\n * This comment was originally written for MD5, which is why it\n * discusses A-D. But it basically applies to all 32-bit digests,\n * which is why it was moved to common header file.\n *\n * In case you wonder why A-D are declared as long and not\n * as MD5_LONG. Doing so results in slight performance\n * boost on LP64 architectures. The catch is we don't\n * really care if 32 MSBs of a 64-bit register get polluted\n * with eventual overflows as we *save* only 32 LSBs in\n * *either* case. Now declaring 'em long excuses the compiler\n * from keeping 32 MSBs zeroed resulting in 13% performance\n * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.\n * Well, to be honest it should say that this *prevents*\n * performance degradation.\n */\n# else\n/*\n * Above is not absolute and there are LP64 compilers that\n * generate better code if MD32_REG_T is defined int. The above\n * pre-processor condition reflects the circumstances under which\n * the conclusion was made and is subject to further extension.\n */\n#  define MD32_REG_T int\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/objects.h",
    "content": "/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/objects.h>\n\nvoid obj_cleanup_int(void);\n"
  },
  {
    "path": "cryptomini/include/crypto/poly1305.h",
    "content": "/*\n * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <stddef.h>\n\n#define POLY1305_BLOCK_SIZE  16\n#define POLY1305_DIGEST_SIZE 16\n#define POLY1305_KEY_SIZE    32\n\ntypedef struct poly1305_context POLY1305;\n\nsize_t Poly1305_ctx_size(void);\nvoid Poly1305_Init(POLY1305 *ctx, const unsigned char key[32]);\nvoid Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len);\nvoid Poly1305_Final(POLY1305 *ctx, unsigned char mac[16]);\n"
  },
  {
    "path": "cryptomini/include/crypto/rand.h",
    "content": "/*\n * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * Licensed under the OpenSSL licenses, (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * https://www.openssl.org/source/license.html\n * or in the file LICENSE in the source distribution.\n */\n\n#ifndef OSSL_CRYPTO_RAND_H\n# define OSSL_CRYPTO_RAND_H\n\n# include <openssl/rand.h>\n\n# if defined(__APPLE__) && !defined(OPENSSL_NO_APPLE_CRYPTO_RANDOM)\n#  include <Availability.h>\n#  if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || \\\n     (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000)\n#   define OPENSSL_APPLE_CRYPTO_RANDOM 1\n#   include <CommonCrypto/CommonCryptoError.h>\n#   include <CommonCrypto/CommonRandom.h>\n#  endif\n# endif\n\n/* forward declaration */\ntypedef struct rand_pool_st RAND_POOL;\n\nvoid rand_cleanup_int(void);\nvoid rand_drbg_cleanup_int(void);\nvoid drbg_delete_thread_state(void);\n\n/* Hardware-based seeding functions. */\nsize_t rand_acquire_entropy_from_tsc(RAND_POOL *pool);\nsize_t rand_acquire_entropy_from_cpu(RAND_POOL *pool);\n\n/* DRBG entropy callbacks. */\nsize_t rand_drbg_get_entropy(RAND_DRBG *drbg,\n                             unsigned char **pout,\n                             int entropy, size_t min_len, size_t max_len,\n                             int prediction_resistance);\nvoid rand_drbg_cleanup_entropy(RAND_DRBG *drbg,\n                               unsigned char *out, size_t outlen);\nsize_t rand_drbg_get_nonce(RAND_DRBG *drbg,\n                           unsigned char **pout,\n                           int entropy, size_t min_len, size_t max_len);\nvoid rand_drbg_cleanup_nonce(RAND_DRBG *drbg,\n                             unsigned char *out, size_t outlen);\n\nsize_t rand_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout);\n\nvoid rand_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out);\n\n/*\n * RAND_POOL functions\n */\nRAND_POOL *rand_pool_new(int entropy_requested, int secure,\n                         size_t min_len, size_t max_len);\nRAND_POOL *rand_pool_attach(const unsigned char *buffer, size_t len,\n                            size_t entropy);\nvoid rand_pool_free(RAND_POOL *pool);\n\nconst unsigned char *rand_pool_buffer(RAND_POOL *pool);\nunsigned char *rand_pool_detach(RAND_POOL *pool);\nvoid rand_pool_reattach(RAND_POOL *pool, unsigned char *buffer);\n\nsize_t rand_pool_entropy(RAND_POOL *pool);\nsize_t rand_pool_length(RAND_POOL *pool);\n\nsize_t rand_pool_entropy_available(RAND_POOL *pool);\nsize_t rand_pool_entropy_needed(RAND_POOL *pool);\n/* |entropy_factor| expresses how many bits of data contain 1 bit of entropy */\nsize_t rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_factor);\nsize_t rand_pool_bytes_remaining(RAND_POOL *pool);\n\nint rand_pool_add(RAND_POOL *pool,\n                  const unsigned char *buffer, size_t len, size_t entropy);\nunsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len);\nint rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy);\n\n\n/*\n * Add random bytes to the pool to acquire requested amount of entropy\n *\n * This function is platform specific and tries to acquire the requested\n * amount of entropy by polling platform specific entropy sources.\n *\n * If the function succeeds in acquiring at least |entropy_requested| bits\n * of entropy, the total entropy count is returned. If it fails, it returns\n * an entropy count of 0.\n */\nsize_t rand_pool_acquire_entropy(RAND_POOL *pool);\n\n/*\n * Add some application specific nonce data\n *\n * This function is platform specific and adds some application specific\n * data to the nonce used for instantiating the drbg.\n *\n * This data currently consists of the process and thread id, and a high\n * resolution timestamp. The data does not include an atomic counter,\n * because that is added by the calling function rand_drbg_get_nonce().\n *\n * Returns 1 on success and 0 on failure.\n */\nint rand_pool_add_nonce_data(RAND_POOL *pool);\n\n\n/*\n * Add some platform specific additional data\n *\n * This function is platform specific and adds some random noise to the\n * additional data used for generating random bytes and for reseeding\n * the drbg.\n *\n * Returns 1 on success and 0 on failure.\n */\nint rand_pool_add_additional_data(RAND_POOL *pool);\n\n/*\n * Initialise the random pool reseeding sources.\n *\n * Returns 1 on success and 0 on failure.\n */\nint rand_pool_init(void);\n\n/*\n * Finalise the random pool reseeding sources.\n */\nvoid rand_pool_cleanup(void);\n\n/*\n * Control the random pool use of open file descriptors.\n */\nvoid rand_pool_keep_random_devices_open(int keep);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/sha.h",
    "content": "/*\n * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2018, Oracle and/or its affiliates.  All rights reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_SHA_H\n# define OSSL_CRYPTO_SHA_H\n\n# include <openssl/opensslconf.h>\n\nint sha512_224_init(SHA512_CTX *);\nint sha512_256_init(SHA512_CTX *);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/siphash.h",
    "content": "/*\n * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <stddef.h>\n\n#define SIPHASH_BLOCK_SIZE        8\n#define SIPHASH_KEY_SIZE         16\n#define SIPHASH_MIN_DIGEST_SIZE   8\n#define SIPHASH_MAX_DIGEST_SIZE  16\n\ntypedef struct siphash_st SIPHASH;\n\nsize_t SipHash_ctx_size(void);\nsize_t SipHash_hash_size(SIPHASH *ctx);\nint SipHash_set_hash_size(SIPHASH *ctx, size_t hash_size);\nint SipHash_Init(SIPHASH *ctx, const unsigned char *k,\n                 int crounds, int drounds);\nvoid SipHash_Update(SIPHASH *ctx, const unsigned char *in, size_t inlen);\nint SipHash_Final(SIPHASH *ctx, unsigned char *out, size_t outlen);\n"
  },
  {
    "path": "cryptomini/include/crypto/sm2.h",
    "content": "/*\n * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright 2017 Ribose Inc. All Rights Reserved.\n * Ported from Ribose contributions from Botan.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_SM2_H\n# define OSSL_CRYPTO_SM2_H\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_SM2\n\n#  include <openssl/ec.h>\n\n/* The default user id as specified in GM/T 0009-2012 */\n#  define SM2_DEFAULT_USERID \"1234567812345678\"\n\nint sm2_compute_z_digest(uint8_t *out,\n                         const EVP_MD *digest,\n                         const uint8_t *id,\n                         const size_t id_len,\n                         const EC_KEY *key);\n\n/*\n * SM2 signature operation. Computes Z and then signs H(Z || msg) using SM2\n */\nECDSA_SIG *sm2_do_sign(const EC_KEY *key,\n                       const EVP_MD *digest,\n                       const uint8_t *id,\n                       const size_t id_len,\n                       const uint8_t *msg, size_t msg_len);\n\nint sm2_do_verify(const EC_KEY *key,\n                  const EVP_MD *digest,\n                  const ECDSA_SIG *signature,\n                  const uint8_t *id,\n                  const size_t id_len,\n                  const uint8_t *msg, size_t msg_len);\n\n/*\n * SM2 signature generation.\n */\nint sm2_sign(const unsigned char *dgst, int dgstlen,\n             unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);\n\n/*\n * SM2 signature verification.\n */\nint sm2_verify(const unsigned char *dgst, int dgstlen,\n               const unsigned char *sig, int siglen, EC_KEY *eckey);\n\n/*\n * SM2 encryption\n */\nint sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len,\n                        size_t *ct_size);\n\nint sm2_plaintext_size(const unsigned char *ct, size_t ct_size, size_t *pt_size);\n\nint sm2_encrypt(const EC_KEY *key,\n                const EVP_MD *digest,\n                const uint8_t *msg,\n                size_t msg_len,\n                uint8_t *ciphertext_buf, size_t *ciphertext_len);\n\nint sm2_decrypt(const EC_KEY *key,\n                const EVP_MD *digest,\n                const uint8_t *ciphertext,\n                size_t ciphertext_len, uint8_t *ptext_buf, size_t *ptext_len);\n\n# endif /* OPENSSL_NO_SM2 */\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/sm2err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_SM2ERR_H\n# define OSSL_CRYPTO_SM2ERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_SM2\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_SM2_strings(void);\n\n/*\n * SM2 function codes.\n */\n#  define SM2_F_PKEY_SM2_COPY                              115\n#  define SM2_F_PKEY_SM2_CTRL                              109\n#  define SM2_F_PKEY_SM2_CTRL_STR                          110\n#  define SM2_F_PKEY_SM2_DIGEST_CUSTOM                     114\n#  define SM2_F_PKEY_SM2_INIT                              111\n#  define SM2_F_PKEY_SM2_SIGN                              112\n#  define SM2_F_SM2_COMPUTE_MSG_HASH                       100\n#  define SM2_F_SM2_COMPUTE_USERID_DIGEST                  101\n#  define SM2_F_SM2_COMPUTE_Z_DIGEST                       113\n#  define SM2_F_SM2_DECRYPT                                102\n#  define SM2_F_SM2_ENCRYPT                                103\n#  define SM2_F_SM2_PLAINTEXT_SIZE                         104\n#  define SM2_F_SM2_SIGN                                   105\n#  define SM2_F_SM2_SIG_GEN                                106\n#  define SM2_F_SM2_SIG_VERIFY                             107\n#  define SM2_F_SM2_VERIFY                                 108\n\n/*\n * SM2 reason codes.\n */\n#  define SM2_R_ASN1_ERROR                                 100\n#  define SM2_R_BAD_SIGNATURE                              101\n#  define SM2_R_BUFFER_TOO_SMALL                           107\n#  define SM2_R_DIST_ID_TOO_LARGE                          110\n#  define SM2_R_ID_NOT_SET                                 112\n#  define SM2_R_ID_TOO_LARGE                               111\n#  define SM2_R_INVALID_CURVE                              108\n#  define SM2_R_INVALID_DIGEST                             102\n#  define SM2_R_INVALID_DIGEST_TYPE                        103\n#  define SM2_R_INVALID_ENCODING                           104\n#  define SM2_R_INVALID_FIELD                              105\n#  define SM2_R_NO_PARAMETERS_SET                          109\n#  define SM2_R_USER_ID_TOO_LARGE                          106\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/sm3.h",
    "content": "/*\n * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright 2017 Ribose Inc. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_SM3_H\n# define OSSL_CRYPTO_SM3_H\n\n# include <openssl/opensslconf.h>\n\n# ifdef OPENSSL_NO_SM3\n#  error SM3 is disabled.\n# endif\n\n# define SM3_DIGEST_LENGTH 32\n# define SM3_WORD unsigned int\n\n# define SM3_CBLOCK      64\n# define SM3_LBLOCK      (SM3_CBLOCK/4)\n\ntypedef struct SM3state_st {\n   SM3_WORD A, B, C, D, E, F, G, H;\n   SM3_WORD Nl, Nh;\n   SM3_WORD data[SM3_LBLOCK];\n   unsigned int num;\n} SM3_CTX;\n\nint sm3_init(SM3_CTX *c);\nint sm3_update(SM3_CTX *c, const void *data, size_t len);\nint sm3_final(unsigned char *md, SM3_CTX *c);\n\nvoid sm3_block_data_order(SM3_CTX *c, const void *p, size_t num);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/sm4.h",
    "content": "/*\n * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright 2017 Ribose Inc. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_SM4_H\n# define OSSL_CRYPTO_SM4_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/e_os2.h>\n\n# ifdef OPENSSL_NO_SM4\n#  error SM4 is disabled.\n# endif\n\n# define SM4_ENCRYPT     1\n# define SM4_DECRYPT     0\n\n# define SM4_BLOCK_SIZE    16\n# define SM4_KEY_SCHEDULE  32\n\ntypedef struct SM4_KEY_st {\n    uint32_t rk[SM4_KEY_SCHEDULE];\n} SM4_KEY;\n\nint SM4_set_key(const uint8_t *key, SM4_KEY *ks);\n\nvoid SM4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);\n\nvoid SM4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/store.h",
    "content": "/*\n * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_CRYPTO_STORE_H\n# define OSSL_CRYPTO_STORE_H\n\n# include <openssl/bio.h>\n# include <openssl/store.h>\n# include <openssl/ui.h>\n\n/*\n * Two functions to read PEM data off an already opened BIO.  To be used\n * instead of OSSLSTORE_open() and OSSLSTORE_close().  Everything is done\n * as usual with OSSLSTORE_load() and OSSLSTORE_eof().\n */\nOSSL_STORE_CTX *ossl_store_attach_pem_bio(BIO *bp, const UI_METHOD *ui_method,\n                                          void *ui_data);\nint ossl_store_detach_pem_bio(OSSL_STORE_CTX *ctx);\n\nvoid ossl_store_cleanup_int(void);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/crypto/x509.h",
    "content": "/*\n * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"internal/refcount.h\"\n#include <openssl/x509.h>\n#include <openssl/conf.h>\n\n/* Internal X509 structures and functions: not for application use */\n\n/* Note: unless otherwise stated a field pointer is mandatory and should\n * never be set to NULL: the ASN.1 code and accessors rely on mandatory\n * fields never being NULL.\n */\n\n/*\n * name entry structure, equivalent to AttributeTypeAndValue defined\n * in RFC5280 et al.\n */\nstruct X509_name_entry_st {\n    ASN1_OBJECT *object;        /* AttributeType */\n    ASN1_STRING *value;         /* AttributeValue */\n    int set;                    /* index of RDNSequence for this entry */\n    int size;                   /* temp variable */\n};\n\n/* Name from RFC 5280. */\nstruct X509_name_st {\n    STACK_OF(X509_NAME_ENTRY) *entries; /* DN components */\n    int modified;               /* true if 'bytes' needs to be built */\n    BUF_MEM *bytes;             /* cached encoding: cannot be NULL */\n    /* canonical encoding used for rapid Name comparison */\n    unsigned char *canon_enc;\n    int canon_enclen;\n} /* X509_NAME */ ;\n\n/* Signature info structure */\n\nstruct x509_sig_info_st {\n    /* NID of message digest */\n    int mdnid;\n    /* NID of public key algorithm */\n    int pknid;\n    /* Security bits */\n    int secbits;\n    /* Various flags */\n    uint32_t flags;\n};\n\n/* PKCS#10 certificate request */\n\nstruct X509_req_info_st {\n    ASN1_ENCODING enc;          /* cached encoding of signed part */\n    ASN1_INTEGER *version;      /* version, defaults to v1(0) so can be NULL */\n    X509_NAME *subject;         /* certificate request DN */\n    X509_PUBKEY *pubkey;        /* public key of request */\n    /*\n     * Zero or more attributes.\n     * NB: although attributes is a mandatory field some broken\n     * encodings omit it so this may be NULL in that case.\n     */\n    STACK_OF(X509_ATTRIBUTE) *attributes;\n};\n\nstruct X509_req_st {\n    X509_REQ_INFO req_info;     /* signed certificate request data */\n    X509_ALGOR sig_alg;         /* signature algorithm */\n    ASN1_BIT_STRING *signature; /* signature */\n    CRYPTO_REF_COUNT references;\n    CRYPTO_RWLOCK *lock;\n};\n\nstruct X509_crl_info_st {\n    ASN1_INTEGER *version;      /* version: defaults to v1(0) so may be NULL */\n    X509_ALGOR sig_alg;         /* signature algorithm */\n    X509_NAME *issuer;          /* CRL issuer name */\n    ASN1_TIME *lastUpdate;      /* lastUpdate field */\n    ASN1_TIME *nextUpdate;      /* nextUpdate field: optional */\n    STACK_OF(X509_REVOKED) *revoked;        /* revoked entries: optional */\n    STACK_OF(X509_EXTENSION) *extensions;   /* extensions: optional */\n    ASN1_ENCODING enc;                      /* encoding of signed portion of CRL */\n};\n\nstruct X509_crl_st {\n    X509_CRL_INFO crl;          /* signed CRL data */\n    X509_ALGOR sig_alg;         /* CRL signature algorithm */\n    ASN1_BIT_STRING signature;  /* CRL signature */\n    CRYPTO_REF_COUNT references;\n    int flags;\n    /*\n     * Cached copies of decoded extension values, since extensions\n     * are optional any of these can be NULL.\n     */\n    AUTHORITY_KEYID *akid;\n    ISSUING_DIST_POINT *idp;\n    /* Convenient breakdown of IDP */\n    int idp_flags;\n    int idp_reasons;\n    /* CRL and base CRL numbers for delta processing */\n    ASN1_INTEGER *crl_number;\n    ASN1_INTEGER *base_crl_number;\n    STACK_OF(GENERAL_NAMES) *issuers;\n    /* hash of CRL */\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n    /* alternative method to handle this CRL */\n    const X509_CRL_METHOD *meth;\n    void *meth_data;\n    CRYPTO_RWLOCK *lock;\n};\n\nstruct x509_revoked_st {\n    ASN1_INTEGER serialNumber; /* revoked entry serial number */\n    ASN1_TIME *revocationDate;  /* revocation date */\n    STACK_OF(X509_EXTENSION) *extensions;   /* CRL entry extensions: optional */\n    /* decoded value of CRLissuer extension: set if indirect CRL */\n    STACK_OF(GENERAL_NAME) *issuer;\n    /* revocation reason: set to CRL_REASON_NONE if reason extension absent */\n    int reason;\n    /*\n     * CRL entries are reordered for faster lookup of serial numbers. This\n     * field contains the original load sequence for this entry.\n     */\n    int sequence;\n};\n\n/*\n * This stuff is certificate \"auxiliary info\": it contains details which are\n * useful in certificate stores and databases. When used this is tagged onto\n * the end of the certificate itself. OpenSSL specific structure not defined\n * in any RFC.\n */\n\nstruct x509_cert_aux_st {\n    STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */\n    STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */\n    ASN1_UTF8STRING *alias;     /* \"friendly name\" */\n    ASN1_OCTET_STRING *keyid;   /* key id of private key */\n    STACK_OF(X509_ALGOR) *other; /* other unspecified info */\n};\n\nstruct x509_cinf_st {\n    ASN1_INTEGER *version;      /* [ 0 ] default of v1 */\n    ASN1_INTEGER serialNumber;\n    X509_ALGOR signature;\n    X509_NAME *issuer;\n    X509_VAL validity;\n    X509_NAME *subject;\n    X509_PUBKEY *key;\n    ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */\n    ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */\n    STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */\n    ASN1_ENCODING enc;\n};\n\nstruct x509_st {\n    X509_CINF cert_info;\n    X509_ALGOR sig_alg;\n    ASN1_BIT_STRING signature;\n    X509_SIG_INFO siginf;\n    CRYPTO_REF_COUNT references;\n    CRYPTO_EX_DATA ex_data;\n    /* These contain copies of various extension values */\n    long ex_pathlen;\n    long ex_pcpathlen;\n    uint32_t ex_flags;\n    uint32_t ex_kusage;\n    uint32_t ex_xkusage;\n    uint32_t ex_nscert;\n    ASN1_OCTET_STRING *skid;\n    AUTHORITY_KEYID *akid;\n    X509_POLICY_CACHE *policy_cache;\n    STACK_OF(DIST_POINT) *crldp;\n    STACK_OF(GENERAL_NAME) *altname;\n    NAME_CONSTRAINTS *nc;\n#ifndef OPENSSL_NO_RFC3779\n    STACK_OF(IPAddressFamily) *rfc3779_addr;\n    struct ASIdentifiers_st *rfc3779_asid;\n# endif\n    unsigned char sha1_hash[SHA_DIGEST_LENGTH];\n    X509_CERT_AUX *aux;\n    CRYPTO_RWLOCK *lock;\n    volatile int ex_cached;\n} /* X509 */ ;\n\n/*\n * This is a used when verifying cert chains.  Since the gathering of the\n * cert chain can take some time (and have to be 'retried', this needs to be\n * kept and passed around.\n */\nstruct x509_store_ctx_st {      /* X509_STORE_CTX */\n    X509_STORE *ctx;\n    /* The following are set by the caller */\n    /* The cert to check */\n    X509 *cert;\n    /* chain of X509s - untrusted - passed in */\n    STACK_OF(X509) *untrusted;\n    /* set of CRLs passed in */\n    STACK_OF(X509_CRL) *crls;\n    X509_VERIFY_PARAM *param;\n    /* Other info for use with get_issuer() */\n    void *other_ctx;\n    /* Callbacks for various operations */\n    /* called to verify a certificate */\n    int (*verify) (X509_STORE_CTX *ctx);\n    /* error callback */\n    int (*verify_cb) (int ok, X509_STORE_CTX *ctx);\n    /* get issuers cert from ctx */\n    int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n    /* check issued */\n    int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer);\n    /* Check revocation status of chain */\n    int (*check_revocation) (X509_STORE_CTX *ctx);\n    /* retrieve CRL */\n    int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x);\n    /* Check CRL validity */\n    int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl);\n    /* Check certificate against CRL */\n    int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);\n    /* Check policy status of the chain */\n    int (*check_policy) (X509_STORE_CTX *ctx);\n    STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);\n    int (*cleanup) (X509_STORE_CTX *ctx);\n    /* The following is built up */\n    /* if 0, rebuild chain */\n    int valid;\n    /* number of untrusted certs */\n    int num_untrusted;\n    /* chain of X509s - built up and trusted */\n    STACK_OF(X509) *chain;\n    /* Valid policy tree */\n    X509_POLICY_TREE *tree;\n    /* Require explicit policy value */\n    int explicit_policy;\n    /* When something goes wrong, this is why */\n    int error_depth;\n    int error;\n    X509 *current_cert;\n    /* cert currently being tested as valid issuer */\n    X509 *current_issuer;\n    /* current CRL */\n    X509_CRL *current_crl;\n    /* score of current CRL */\n    int current_crl_score;\n    /* Reason mask */\n    unsigned int current_reasons;\n    /* For CRL path validation: parent context */\n    X509_STORE_CTX *parent;\n    CRYPTO_EX_DATA ex_data;\n    SSL_DANE *dane;\n    /* signed via bare TA public key, rather than CA certificate */\n    int bare_ta_signed;\n};\n\n/* PKCS#8 private key info structure */\n\nstruct pkcs8_priv_key_info_st {\n    ASN1_INTEGER *version;\n    X509_ALGOR *pkeyalg;\n    ASN1_OCTET_STRING *pkey;\n    STACK_OF(X509_ATTRIBUTE) *attributes;\n};\n\nstruct X509_sig_st {\n    X509_ALGOR *algor;\n    ASN1_OCTET_STRING *digest;\n};\n\nstruct x509_object_st {\n    /* one of the above types */\n    X509_LOOKUP_TYPE type;\n    union {\n        char *ptr;\n        X509 *x509;\n        X509_CRL *crl;\n        EVP_PKEY *pkey;\n    } data;\n};\n\nint a2i_ipadd(unsigned char *ipout, const char *ipasc);\nint x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm);\n\nvoid x509_init_sig_info(X509 *x);\n\nint x509v3_add_len_value_uchar(const char *name, const unsigned char *value,\n                               size_t vallen, STACK_OF(CONF_VALUE) **extlist);\n"
  },
  {
    "path": "cryptomini/include/intercept/intercept.h",
    "content": "\n#include <stdio.h>\n\n// #define malloc  sbi_malloc\n// #define free    sbi_free\n// #define memset  sbi_memset\n\n// void *sbi_malloc(size_t size);\n// void sbi_free(void *ptr);\n// void *sbi_memset(void *s, int c, size_t count);\n"
  },
  {
    "path": "cryptomini/include/internal/__DECC_INCLUDE_EPILOGUE.H",
    "content": "/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * This file is only used by HP C on VMS, and is included automatically\n * after each header file from this directory\n */\n\n/* restore state.  Must correspond to the save in __decc_include_prologue.h */\n#pragma names restore\n"
  },
  {
    "path": "cryptomini/include/internal/__DECC_INCLUDE_PROLOGUE.H",
    "content": "/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * This file is only used by HP C on VMS, and is included automatically\n * after each header file from this directory\n */\n\n/* save state */\n#pragma names save\n/* have the compiler shorten symbols larger than 31 chars to 23 chars\n * followed by a 8 hex char CRC\n */\n#pragma names as_is,shortened\n"
  },
  {
    "path": "cryptomini/include/internal/bio.h",
    "content": "/*\n * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/bio.h>\n\nstruct bio_method_st {\n    int type;\n    char *name;\n    int (*bwrite) (BIO *, const char *, size_t, size_t *);\n    int (*bwrite_old) (BIO *, const char *, int);\n    int (*bread) (BIO *, char *, size_t, size_t *);\n    int (*bread_old) (BIO *, char *, int);\n    int (*bputs) (BIO *, const char *);\n    int (*bgets) (BIO *, char *, int);\n    long (*ctrl) (BIO *, int, long, void *);\n    int (*create) (BIO *);\n    int (*destroy) (BIO *);\n    long (*callback_ctrl) (BIO *, int, BIO_info_cb *);\n};\n\nvoid bio_free_ex_data(BIO *bio);\nvoid bio_cleanup(void);\n\n\n/* Old style to new style BIO_METHOD conversion functions */\nint bwrite_conv(BIO *bio, const char *data, size_t datal, size_t *written);\nint bread_conv(BIO *bio, char *data, size_t datal, size_t *read);\n"
  },
  {
    "path": "cryptomini/include/internal/comp.h",
    "content": "/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/comp.h>\n\nvoid comp_zlib_cleanup_int(void);\n"
  },
  {
    "path": "cryptomini/include/internal/conf.h",
    "content": "/*\n * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_CONF_H\n# define OSSL_INTERNAL_CONF_H\n\n#include <openssl/conf.h>\n\n#define DEFAULT_CONF_MFLAGS \\\n    (CONF_MFLAGS_DEFAULT_SECTION | \\\n     CONF_MFLAGS_IGNORE_MISSING_FILE | \\\n     CONF_MFLAGS_IGNORE_RETURN_CODES)\n\nstruct ossl_init_settings_st {\n    char *filename;\n    char *appname;\n    unsigned long flags;\n};\n\nint openssl_config_int(const OPENSSL_INIT_SETTINGS *);\nvoid openssl_no_config_int(void);\nvoid conf_modules_free_int(void);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/constant_time.h",
    "content": "/*\n * Copyright 2014-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_CONSTANT_TIME_H\n# define OSSL_INTERNAL_CONSTANT_TIME_H\n\n# include <stdlib.h>\n# include <string.h>\n# include <openssl/e_os2.h>              /* For 'ossl_inline' */\n\n/*-\n * The boolean methods return a bitmask of all ones (0xff...f) for true\n * and 0 for false. This is useful for choosing a value based on the result\n * of a conditional in constant time. For example,\n *      if (a < b) {\n *        c = a;\n *      } else {\n *        c = b;\n *      }\n * can be written as\n *      unsigned int lt = constant_time_lt(a, b);\n *      c = constant_time_select(lt, a, b);\n */\n\n/* Returns the given value with the MSB copied to all the other bits. */\nstatic ossl_inline unsigned int constant_time_msb(unsigned int a);\n/* Convenience method for uint32_t. */\nstatic ossl_inline uint32_t constant_time_msb_32(uint32_t a);\n/* Convenience method for uint64_t. */\nstatic ossl_inline uint64_t constant_time_msb_64(uint64_t a);\n\n/* Returns 0xff..f if a < b and 0 otherwise. */\nstatic ossl_inline unsigned int constant_time_lt(unsigned int a,\n                                                 unsigned int b);\n/* Convenience method for getting an 8-bit mask. */\nstatic ossl_inline unsigned char constant_time_lt_8(unsigned int a,\n                                                    unsigned int b);\n/* Convenience method for uint64_t. */\nstatic ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b);\n\n/* Returns 0xff..f if a >= b and 0 otherwise. */\nstatic ossl_inline unsigned int constant_time_ge(unsigned int a,\n                                                 unsigned int b);\n/* Convenience method for getting an 8-bit mask. */\nstatic ossl_inline unsigned char constant_time_ge_8(unsigned int a,\n                                                    unsigned int b);\n\n/* Returns 0xff..f if a == 0 and 0 otherwise. */\nstatic ossl_inline unsigned int constant_time_is_zero(unsigned int a);\n/* Convenience method for getting an 8-bit mask. */\nstatic ossl_inline unsigned char constant_time_is_zero_8(unsigned int a);\n/* Convenience method for getting a 32-bit mask. */\nstatic ossl_inline uint32_t constant_time_is_zero_32(uint32_t a);\n\n/* Returns 0xff..f if a == b and 0 otherwise. */\nstatic ossl_inline unsigned int constant_time_eq(unsigned int a,\n                                                 unsigned int b);\n/* Convenience method for getting an 8-bit mask. */\nstatic ossl_inline unsigned char constant_time_eq_8(unsigned int a,\n                                                    unsigned int b);\n/* Signed integers. */\nstatic ossl_inline unsigned int constant_time_eq_int(int a, int b);\n/* Convenience method for getting an 8-bit mask. */\nstatic ossl_inline unsigned char constant_time_eq_int_8(int a, int b);\n\n/*-\n * Returns (mask & a) | (~mask & b).\n *\n * When |mask| is all 1s or all 0s (as returned by the methods above),\n * the select methods return either |a| (if |mask| is nonzero) or |b|\n * (if |mask| is zero).\n */\nstatic ossl_inline unsigned int constant_time_select(unsigned int mask,\n                                                     unsigned int a,\n                                                     unsigned int b);\n/* Convenience method for unsigned chars. */\nstatic ossl_inline unsigned char constant_time_select_8(unsigned char mask,\n                                                        unsigned char a,\n                                                        unsigned char b);\n\n/* Convenience method for uint32_t. */\nstatic ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a,\n                                                    uint32_t b);\n\n/* Convenience method for uint64_t. */\nstatic ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a,\n                                                    uint64_t b);\n/* Convenience method for signed integers. */\nstatic ossl_inline int constant_time_select_int(unsigned int mask, int a,\n                                                int b);\n\n\nstatic ossl_inline unsigned int constant_time_msb(unsigned int a)\n{\n    return 0 - (a >> (sizeof(a) * 8 - 1));\n}\n\n\nstatic ossl_inline uint32_t constant_time_msb_32(uint32_t a)\n{\n    return 0 - (a >> 31);\n}\n\nstatic ossl_inline uint64_t constant_time_msb_64(uint64_t a)\n{\n    return 0 - (a >> 63);\n}\n\nstatic ossl_inline size_t constant_time_msb_s(size_t a)\n{\n    return 0 - (a >> (sizeof(a) * 8 - 1));\n}\n\nstatic ossl_inline unsigned int constant_time_lt(unsigned int a,\n                                                 unsigned int b)\n{\n    return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));\n}\n\nstatic ossl_inline size_t constant_time_lt_s(size_t a, size_t b)\n{\n    return constant_time_msb_s(a ^ ((a ^ b) | ((a - b) ^ b)));\n}\n\nstatic ossl_inline unsigned char constant_time_lt_8(unsigned int a,\n                                                    unsigned int b)\n{\n    return (unsigned char)constant_time_lt(a, b);\n}\n\nstatic ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b)\n{\n    return constant_time_msb_64(a ^ ((a ^ b) | ((a - b) ^ b)));\n}\n\nstatic ossl_inline unsigned int constant_time_ge(unsigned int a,\n                                                 unsigned int b)\n{\n    return ~constant_time_lt(a, b);\n}\n\nstatic ossl_inline size_t constant_time_ge_s(size_t a, size_t b)\n{\n    return ~constant_time_lt_s(a, b);\n}\n\nstatic ossl_inline unsigned char constant_time_ge_8(unsigned int a,\n                                                    unsigned int b)\n{\n    return (unsigned char)constant_time_ge(a, b);\n}\n\nstatic ossl_inline unsigned char constant_time_ge_8_s(size_t a, size_t b)\n{\n    return (unsigned char)constant_time_ge_s(a, b);\n}\n\nstatic ossl_inline unsigned int constant_time_is_zero(unsigned int a)\n{\n    return constant_time_msb(~a & (a - 1));\n}\n\nstatic ossl_inline size_t constant_time_is_zero_s(size_t a)\n{\n    return constant_time_msb_s(~a & (a - 1));\n}\n\nstatic ossl_inline unsigned char constant_time_is_zero_8(unsigned int a)\n{\n    return (unsigned char)constant_time_is_zero(a);\n}\n\nstatic ossl_inline uint32_t constant_time_is_zero_32(uint32_t a)\n{\n    return constant_time_msb_32(~a & (a - 1));\n}\n\nstatic ossl_inline unsigned int constant_time_eq(unsigned int a,\n                                                 unsigned int b)\n{\n    return constant_time_is_zero(a ^ b);\n}\n\nstatic ossl_inline size_t constant_time_eq_s(size_t a, size_t b)\n{\n    return constant_time_is_zero_s(a ^ b);\n}\n\nstatic ossl_inline unsigned char constant_time_eq_8(unsigned int a,\n                                                    unsigned int b)\n{\n    return (unsigned char)constant_time_eq(a, b);\n}\n\nstatic ossl_inline unsigned char constant_time_eq_8_s(size_t a, size_t b)\n{\n    return (unsigned char)constant_time_eq_s(a, b);\n}\n\nstatic ossl_inline unsigned int constant_time_eq_int(int a, int b)\n{\n    return constant_time_eq((unsigned)(a), (unsigned)(b));\n}\n\nstatic ossl_inline unsigned char constant_time_eq_int_8(int a, int b)\n{\n    return constant_time_eq_8((unsigned)(a), (unsigned)(b));\n}\n\n/*\n * Returns the value unmodified, but avoids optimizations.\n * The barriers prevent the compiler from narrowing down the\n * possible value range of the mask and ~mask in the select\n * statements, which avoids the recognition of the select\n * and turning it into a conditional load or branch.\n */\nstatic ossl_inline unsigned int value_barrier(unsigned int a)\n{\n#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)\n    unsigned int r;\n    __asm__(\"\" : \"=r\"(r) : \"0\"(a));\n#else\n    volatile unsigned int r = a;\n#endif\n    return r;\n}\n\n/* Convenience method for uint32_t. */\nstatic ossl_inline uint32_t value_barrier_32(uint32_t a)\n{\n#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)\n    uint32_t r;\n    __asm__(\"\" : \"=r\"(r) : \"0\"(a));\n#else\n    volatile uint32_t r = a;\n#endif\n    return r;\n}\n\n/* Convenience method for uint64_t. */\nstatic ossl_inline uint64_t value_barrier_64(uint64_t a)\n{\n#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)\n    uint64_t r;\n    __asm__(\"\" : \"=r\"(r) : \"0\"(a));\n#else\n    volatile uint64_t r = a;\n#endif\n    return r;\n}\n\n/* Convenience method for size_t. */\nstatic ossl_inline size_t value_barrier_s(size_t a)\n{\n#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)\n    size_t r;\n    __asm__(\"\" : \"=r\"(r) : \"0\"(a));\n#else\n    volatile size_t r = a;\n#endif\n    return r;\n}\n\nstatic ossl_inline unsigned int constant_time_select(unsigned int mask,\n                                                     unsigned int a,\n                                                     unsigned int b)\n{\n    return (value_barrier(mask) & a) | (value_barrier(~mask) & b);\n}\n\nstatic ossl_inline size_t constant_time_select_s(size_t mask,\n                                                 size_t a,\n                                                 size_t b)\n{\n    return (value_barrier_s(mask) & a) | (value_barrier_s(~mask) & b);\n}\n\nstatic ossl_inline unsigned char constant_time_select_8(unsigned char mask,\n                                                        unsigned char a,\n                                                        unsigned char b)\n{\n    return (unsigned char)constant_time_select(mask, a, b);\n}\n\nstatic ossl_inline int constant_time_select_int(unsigned int mask, int a,\n                                                int b)\n{\n    return (int)constant_time_select(mask, (unsigned)(a), (unsigned)(b));\n}\n\nstatic ossl_inline int constant_time_select_int_s(size_t mask, int a, int b)\n{\n    return (int)constant_time_select((unsigned)mask, (unsigned)(a),\n                                      (unsigned)(b));\n}\n\nstatic ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a,\n                                                    uint32_t b)\n{\n    return (value_barrier_32(mask) & a) | (value_barrier_32(~mask) & b);\n}\n\nstatic ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a,\n                                                    uint64_t b)\n{\n    return (value_barrier_64(mask) & a) | (value_barrier_64(~mask) & b);\n}\n\n/*\n * mask must be 0xFFFFFFFF or 0x00000000.\n *\n * if (mask) {\n *     uint32_t tmp = *a;\n *\n *     *a = *b;\n *     *b = tmp;\n * }\n */\nstatic ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a,\n                                                   uint32_t *b)\n{\n    uint32_t xor = *a ^ *b;\n\n    xor &= mask;\n    *a ^= xor;\n    *b ^= xor;\n}\n\n/*\n * mask must be 0xFFFFFFFF or 0x00000000.\n *\n * if (mask) {\n *     uint64_t tmp = *a;\n *\n *     *a = *b;\n *     *b = tmp;\n * }\n */\nstatic ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a,\n                                                   uint64_t *b)\n{\n    uint64_t xor = *a ^ *b;\n\n    xor &= mask;\n    *a ^= xor;\n    *b ^= xor;\n}\n\n/*\n * table is a two dimensional array of bytes. Each row has rowsize elements.\n * Copies row number idx into out. rowsize and numrows are not considered\n * private.\n */\nstatic ossl_inline void constant_time_lookup(void *out,\n                                             const void *table,\n                                             size_t rowsize,\n                                             size_t numrows,\n                                             size_t idx)\n{\n    size_t i, j;\n    const unsigned char *tablec = (const unsigned char *)table;\n    unsigned char *outc = (unsigned char *)out;\n    unsigned char mask;\n\n    memset(out, 0, rowsize);\n\n    /* Note idx may underflow - but that is well defined */\n    for (i = 0; i < numrows; i++, idx--) {\n        mask = (unsigned char)constant_time_is_zero_s(idx);\n        for (j = 0; j < rowsize; j++)\n            *(outc + j) |= constant_time_select_8(mask, *(tablec++), 0);\n    }\n}\n\n/*\n * Expected usage pattern is to unconditionally set error and then\n * wipe it if there was no actual error. |clear| is 1 or 0.\n */\nvoid err_clear_last_constant_time(int clear);\n\n#endif                          /* OSSL_INTERNAL_CONSTANT_TIME_H */\n"
  },
  {
    "path": "cryptomini/include/internal/cryptlib.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_CRYPTLIB_H\n# define OSSL_INTERNAL_CRYPTLIB_H\n\n# include <stdlib.h>\n# include <string.h>\n\n# ifdef OPENSSL_USE_APPLINK\n#  undef BIO_FLAGS_UPLINK\n#  define BIO_FLAGS_UPLINK 0x8000\n#  include \"ms/uplink.h\"\n# endif\n\n# include <openssl/crypto.h>\n# include <openssl/buffer.h>\n# include <openssl/bio.h>\n# include <openssl/err.h>\n# include \"internal/nelem.h\"\n\n#ifdef NDEBUG\n# define ossl_assert(x) ((x) != 0)\n#else\n__owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr,\n                                              const char *file, int line)\n{\n    if (!expr)\n        OPENSSL_die(exprstr, file, line);\n\n    return expr;\n}\n\n# define ossl_assert(x) ossl_assert_int((x) != 0, \"Assertion failed: \"#x, \\\n                                         __FILE__, __LINE__)\n\n#endif\n\ntypedef struct ex_callback_st EX_CALLBACK;\n\nDEFINE_STACK_OF(EX_CALLBACK)\n\ntypedef struct app_mem_info_st APP_INFO;\n\ntypedef struct mem_st MEM;\nDEFINE_LHASH_OF(MEM);\n\n# define OPENSSL_CONF             \"openssl.cnf\"\n\n# ifndef OPENSSL_SYS_VMS\n#  define X509_CERT_AREA          OPENSSLDIR\n#  define X509_CERT_DIR           OPENSSLDIR \"/certs\"\n#  define X509_CERT_FILE          OPENSSLDIR \"/cert.pem\"\n#  define X509_PRIVATE_DIR        OPENSSLDIR \"/private\"\n#  define CTLOG_FILE              OPENSSLDIR \"/ct_log_list.cnf\"\n# else\n#  define X509_CERT_AREA          \"OSSL$DATAROOT:[000000]\"\n#  define X509_CERT_DIR           \"OSSL$DATAROOT:[CERTS]\"\n#  define X509_CERT_FILE          \"OSSL$DATAROOT:[000000]cert.pem\"\n#  define X509_PRIVATE_DIR        \"OSSL$DATAROOT:[PRIVATE]\"\n#  define CTLOG_FILE              \"OSSL$DATAROOT:[000000]ct_log_list.cnf\"\n# endif\n\n# define X509_CERT_DIR_EVP        \"SSL_CERT_DIR\"\n# define X509_CERT_FILE_EVP       \"SSL_CERT_FILE\"\n# define CTLOG_FILE_EVP           \"CTLOG_FILE\"\n\n/* size of string representations */\n# define DECIMAL_SIZE(type)      ((sizeof(type)*8+2)/3+1)\n# define HEX_SIZE(type)          (sizeof(type)*2)\n\nvoid OPENSSL_cpuid_setup(void);\nextern unsigned int OPENSSL_ia32cap_P[];\nvoid OPENSSL_showfatal(const char *fmta, ...);\nvoid crypto_cleanup_all_ex_data_int(void);\nint openssl_init_fork_handlers(void);\nint openssl_get_fork_id(void);\n\nchar *ossl_safe_getenv(const char *name);\n\nextern CRYPTO_RWLOCK *memdbg_lock;\nint openssl_strerror_r(int errnum, char *buf, size_t buflen);\n# if !defined(OPENSSL_NO_STDIO)\nFILE *openssl_fopen(const char *filename, const char *mode);\n# else\nvoid *openssl_fopen(const char *filename, const char *mode);\n# endif\n\nuint32_t OPENSSL_rdtsc(void);\nsize_t OPENSSL_instrument_bus(unsigned int *, size_t);\nsize_t OPENSSL_instrument_bus2(unsigned int *, size_t, size_t);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/dane.h",
    "content": "/*\n * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_DANE_H\n#define OSSL_INTERNAL_DANE_H\n\n#include <openssl/safestack.h>\n\n/*-\n * Certificate usages:\n * https://tools.ietf.org/html/rfc6698#section-2.1.1\n */\n#define DANETLS_USAGE_PKIX_TA   0\n#define DANETLS_USAGE_PKIX_EE   1\n#define DANETLS_USAGE_DANE_TA   2\n#define DANETLS_USAGE_DANE_EE   3\n#define DANETLS_USAGE_LAST      DANETLS_USAGE_DANE_EE\n\n/*-\n * Selectors:\n * https://tools.ietf.org/html/rfc6698#section-2.1.2\n */\n#define DANETLS_SELECTOR_CERT   0\n#define DANETLS_SELECTOR_SPKI   1\n#define DANETLS_SELECTOR_LAST   DANETLS_SELECTOR_SPKI\n\n/*-\n * Matching types:\n * https://tools.ietf.org/html/rfc6698#section-2.1.3\n */\n#define DANETLS_MATCHING_FULL   0\n#define DANETLS_MATCHING_2256   1\n#define DANETLS_MATCHING_2512   2\n#define DANETLS_MATCHING_LAST   DANETLS_MATCHING_2512\n\ntypedef struct danetls_record_st {\n    uint8_t usage;\n    uint8_t selector;\n    uint8_t mtype;\n    unsigned char *data;\n    size_t dlen;\n    EVP_PKEY *spki;\n} danetls_record;\n\nDEFINE_STACK_OF(danetls_record)\n\n/*\n * Shared DANE context\n */\nstruct dane_ctx_st {\n    const EVP_MD  **mdevp;      /* mtype -> digest */\n    uint8_t        *mdord;      /* mtype -> preference */\n    uint8_t         mdmax;      /* highest supported mtype */\n    unsigned long   flags;      /* feature bitmask */\n};\n\n/*\n * Per connection DANE state\n */\nstruct ssl_dane_st {\n    struct dane_ctx_st *dctx;\n    STACK_OF(danetls_record) *trecs;\n    STACK_OF(X509) *certs;      /* DANE-TA(2) Cert(0) Full(0) certs */\n    danetls_record *mtlsa;      /* Matching TLSA record */\n    X509           *mcert;      /* DANE matched cert */\n    uint32_t        umask;      /* Usages present */\n    int             mdpth;      /* Depth of matched cert */\n    int             pdpth;      /* Depth of PKIX trust */\n    unsigned long   flags;      /* feature bitmask */\n};\n\n#define DANETLS_ENABLED(dane)  \\\n    ((dane) != NULL && sk_danetls_record_num((dane)->trecs) > 0)\n\n#define DANETLS_USAGE_BIT(u)   (((uint32_t)1) << u)\n\n#define DANETLS_PKIX_TA_MASK (DANETLS_USAGE_BIT(DANETLS_USAGE_PKIX_TA))\n#define DANETLS_PKIX_EE_MASK (DANETLS_USAGE_BIT(DANETLS_USAGE_PKIX_EE))\n#define DANETLS_DANE_TA_MASK (DANETLS_USAGE_BIT(DANETLS_USAGE_DANE_TA))\n#define DANETLS_DANE_EE_MASK (DANETLS_USAGE_BIT(DANETLS_USAGE_DANE_EE))\n\n#define DANETLS_PKIX_MASK (DANETLS_PKIX_TA_MASK | DANETLS_PKIX_EE_MASK)\n#define DANETLS_DANE_MASK (DANETLS_DANE_TA_MASK | DANETLS_DANE_EE_MASK)\n#define DANETLS_TA_MASK (DANETLS_PKIX_TA_MASK | DANETLS_DANE_TA_MASK)\n#define DANETLS_EE_MASK (DANETLS_PKIX_EE_MASK | DANETLS_DANE_EE_MASK)\n\n#define DANETLS_HAS_PKIX(dane) ((dane) && ((dane)->umask & DANETLS_PKIX_MASK))\n#define DANETLS_HAS_DANE(dane) ((dane) && ((dane)->umask & DANETLS_DANE_MASK))\n#define DANETLS_HAS_TA(dane)   ((dane) && ((dane)->umask & DANETLS_TA_MASK))\n#define DANETLS_HAS_EE(dane)   ((dane) && ((dane)->umask & DANETLS_EE_MASK))\n\n#define DANETLS_HAS_PKIX_TA(dane) ((dane)&&((dane)->umask & DANETLS_PKIX_TA_MASK))\n#define DANETLS_HAS_PKIX_EE(dane) ((dane)&&((dane)->umask & DANETLS_PKIX_EE_MASK))\n#define DANETLS_HAS_DANE_TA(dane) ((dane)&&((dane)->umask & DANETLS_DANE_TA_MASK))\n#define DANETLS_HAS_DANE_EE(dane) ((dane)&&((dane)->umask & DANETLS_DANE_EE_MASK))\n\n#endif /* OSSL_INTERNAL_DANE_H */\n"
  },
  {
    "path": "cryptomini/include/internal/dso.h",
    "content": "/*\n * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_DSO_H\n# define OSSL_INTERNAL_DSO_H\n\n# include <openssl/crypto.h>\n# include \"internal/dsoerr.h\"\n\n/* These values are used as commands to DSO_ctrl() */\n# define DSO_CTRL_GET_FLAGS      1\n# define DSO_CTRL_SET_FLAGS      2\n# define DSO_CTRL_OR_FLAGS       3\n\n/*\n * By default, DSO_load() will translate the provided filename into a form\n * typical for the platform using the dso_name_converter function of the\n * method. Eg. win32 will transform \"blah\" into \"blah.dll\", and dlfcn will\n * transform it into \"libblah.so\". This callback could even utilise the\n * DSO_METHOD's converter too if it only wants to override behaviour for\n * one or two possible DSO methods. However, the following flag can be\n * set in a DSO to prevent *any* native name-translation at all - eg. if\n * the caller has prompted the user for a path to a driver library so the\n * filename should be interpreted as-is.\n */\n# define DSO_FLAG_NO_NAME_TRANSLATION            0x01\n/*\n * An extra flag to give if only the extension should be added as\n * translation.  This is obviously only of importance on Unix and other\n * operating systems where the translation also may prefix the name with\n * something, like 'lib', and ignored everywhere else. This flag is also\n * ignored if DSO_FLAG_NO_NAME_TRANSLATION is used at the same time.\n */\n# define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY      0x02\n\n/*\n * Don't unload the DSO when we call DSO_free()\n */\n# define DSO_FLAG_NO_UNLOAD_ON_FREE              0x04\n\n/*\n * This flag loads the library with public symbols. Meaning: The exported\n * symbols of this library are public to all libraries loaded after this\n * library. At the moment only implemented in unix.\n */\n# define DSO_FLAG_GLOBAL_SYMBOLS                 0x20\n\ntypedef void (*DSO_FUNC_TYPE) (void);\n\ntypedef struct dso_st DSO;\ntypedef struct dso_meth_st DSO_METHOD;\n\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that transform filenames. They are passed a DSO structure\n * pointer (or NULL if they are to be used independently of a DSO object) and\n * a filename to transform. They should either return NULL (if there is an\n * error condition) or a newly allocated string containing the transformed\n * form that the caller will need to free with OPENSSL_free() when done.\n */\ntypedef char *(*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *);\n/*\n * The function prototype used for method functions (or caller-provided\n * callbacks) that merge two file specifications. They are passed a DSO\n * structure pointer (or NULL if they are to be used independently of a DSO\n * object) and two file specifications to merge. They should either return\n * NULL (if there is an error condition) or a newly allocated string\n * containing the result of merging that the caller will need to free with\n * OPENSSL_free() when done. Here, merging means that bits and pieces are\n * taken from each of the file specifications and added together in whatever\n * fashion that is sensible for the DSO method in question.  The only rule\n * that really applies is that if the two specification contain pieces of the\n * same type, the copy from the first string takes priority.  One could see\n * it as the first specification is the one given by the user and the second\n * being a bunch of defaults to add on if they're missing in the first.\n */\ntypedef char *(*DSO_MERGER_FUNC)(DSO *, const char *, const char *);\n\nDSO *DSO_new(void);\nint DSO_free(DSO *dso);\nint DSO_flags(DSO *dso);\nint DSO_up_ref(DSO *dso);\nlong DSO_ctrl(DSO *dso, int cmd, long larg, void *parg);\n\n/*\n * These functions can be used to get/set the platform-independent filename\n * used for a DSO. NB: set will fail if the DSO is already loaded.\n */\nconst char *DSO_get_filename(DSO *dso);\nint DSO_set_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's name_converter callback to translate a\n * filename, or if the callback isn't set it will instead use the DSO_METHOD's\n * converter. If \"filename\" is NULL, the \"filename\" in the DSO itself will be\n * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is\n * simply duplicated. NB: This function is usually called from within a\n * DSO_METHOD during the processing of a DSO_load() call, and is exposed so\n * that caller-created DSO_METHODs can do the same thing. A non-NULL return\n * value will need to be OPENSSL_free()'d.\n */\nchar *DSO_convert_filename(DSO *dso, const char *filename);\n/*\n * This function will invoke the DSO's merger callback to merge two file\n * specifications, or if the callback isn't set it will instead use the\n * DSO_METHOD's merger.  A non-NULL return value will need to be\n * OPENSSL_free()'d.\n */\nchar *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2);\n\n/*\n * The all-singing all-dancing load function, you normally pass NULL for the\n * first and third parameters. Use DSO_up_ref and DSO_free for subsequent\n * reference count handling. Any flags passed in will be set in the\n * constructed DSO after its init() function but before the load operation.\n * If 'dso' is non-NULL, 'flags' is ignored.\n */\nDSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags);\n\n/* This function binds to a function inside a shared library. */\nDSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname);\n\n/*\n * This method is the default, but will beg, borrow, or steal whatever method\n * should be the default on any particular platform (including\n * DSO_METH_null() if necessary).\n */\nDSO_METHOD *DSO_METHOD_openssl(void);\n\n/*\n * This function writes null-terminated pathname of DSO module containing\n * 'addr' into 'sz' large caller-provided 'path' and returns the number of\n * characters [including trailing zero] written to it. If 'sz' is 0 or\n * negative, 'path' is ignored and required amount of characters [including\n * trailing zero] to accommodate pathname is returned. If 'addr' is NULL, then\n * pathname of cryptolib itself is returned. Negative or zero return value\n * denotes error.\n */\nint DSO_pathbyaddr(void *addr, char *path, int sz);\n\n/*\n * Like DSO_pathbyaddr() but instead returns a handle to the DSO for the symbol\n * or NULL on error.\n */\nDSO *DSO_dsobyaddr(void *addr, int flags);\n\n/*\n * This function should be used with caution! It looks up symbols in *all*\n * loaded modules and if module gets unloaded by somebody else attempt to\n * dereference the pointer is doomed to have fatal consequences. Primary\n * usage for this function is to probe *core* system functionality, e.g.\n * check if getnameinfo(3) is available at run-time without bothering about\n * OS-specific details such as libc.so.versioning or where does it actually\n * reside: in libc itself or libsocket.\n */\nvoid *DSO_global_lookup(const char *name);\n\nint ERR_load_DSO_strings(void);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/dsoerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_DSOERR_H\n# define OSSL_INTERNAL_DSOERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_DSO_strings(void);\n\n/*\n * DSO function codes.\n */\n#  define DSO_F_DLFCN_BIND_FUNC                            100\n#  define DSO_F_DLFCN_LOAD                                 102\n#  define DSO_F_DLFCN_MERGER                               130\n#  define DSO_F_DLFCN_NAME_CONVERTER                       123\n#  define DSO_F_DLFCN_UNLOAD                               103\n#  define DSO_F_DL_BIND_FUNC                               104\n#  define DSO_F_DL_LOAD                                    106\n#  define DSO_F_DL_MERGER                                  131\n#  define DSO_F_DL_NAME_CONVERTER                          124\n#  define DSO_F_DL_UNLOAD                                  107\n#  define DSO_F_DSO_BIND_FUNC                              108\n#  define DSO_F_DSO_CONVERT_FILENAME                       126\n#  define DSO_F_DSO_CTRL                                   110\n#  define DSO_F_DSO_FREE                                   111\n#  define DSO_F_DSO_GET_FILENAME                           127\n#  define DSO_F_DSO_GLOBAL_LOOKUP                          139\n#  define DSO_F_DSO_LOAD                                   112\n#  define DSO_F_DSO_MERGE                                  132\n#  define DSO_F_DSO_NEW_METHOD                             113\n#  define DSO_F_DSO_PATHBYADDR                             105\n#  define DSO_F_DSO_SET_FILENAME                           129\n#  define DSO_F_DSO_UP_REF                                 114\n#  define DSO_F_VMS_BIND_SYM                               115\n#  define DSO_F_VMS_LOAD                                   116\n#  define DSO_F_VMS_MERGER                                 133\n#  define DSO_F_VMS_UNLOAD                                 117\n#  define DSO_F_WIN32_BIND_FUNC                            101\n#  define DSO_F_WIN32_GLOBALLOOKUP                         142\n#  define DSO_F_WIN32_JOINER                               135\n#  define DSO_F_WIN32_LOAD                                 120\n#  define DSO_F_WIN32_MERGER                               134\n#  define DSO_F_WIN32_NAME_CONVERTER                       125\n#  define DSO_F_WIN32_PATHBYADDR                           109\n#  define DSO_F_WIN32_SPLITTER                             136\n#  define DSO_F_WIN32_UNLOAD                               121\n\n/*\n * DSO reason codes.\n */\n#  define DSO_R_CTRL_FAILED                                100\n#  define DSO_R_DSO_ALREADY_LOADED                         110\n#  define DSO_R_EMPTY_FILE_STRUCTURE                       113\n#  define DSO_R_FAILURE                                    114\n#  define DSO_R_FILENAME_TOO_BIG                           101\n#  define DSO_R_FINISH_FAILED                              102\n#  define DSO_R_INCORRECT_FILE_SYNTAX                      115\n#  define DSO_R_LOAD_FAILED                                103\n#  define DSO_R_NAME_TRANSLATION_FAILED                    109\n#  define DSO_R_NO_FILENAME                                111\n#  define DSO_R_NULL_HANDLE                                104\n#  define DSO_R_SET_FILENAME_FAILED                        112\n#  define DSO_R_STACK_ERROR                                105\n#  define DSO_R_SYM_FAILURE                                106\n#  define DSO_R_UNLOAD_FAILED                              107\n#  define DSO_R_UNSUPPORTED                                108\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/err.h",
    "content": "/*\n * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_ERR_H\n# define OSSL_INTERNAL_ERR_H\n\nvoid err_free_strings_int(void);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/nelem.h",
    "content": "/*\n * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_NELEM_H\n# define OSSL_INTERNAL_NELEM_H\n\n# define OSSL_NELEM(x)    (sizeof(x)/sizeof((x)[0]))\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/numbers.h",
    "content": "/*\n * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_NUMBERS_H\n# define OSSL_INTERNAL_NUMBERS_H\n\n# include <limits.h>\n\n# if (-1 & 3) == 0x03\t\t/* Two's complement */\n\n#  define __MAXUINT__(T) ((T) -1)\n#  define __MAXINT__(T) ((T) ((((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T)))\n#  define __MININT__(T) (-__MAXINT__(T) - 1)\n\n# elif (-1 & 3) == 0x02\t\t/* One's complement */\n\n#  define __MAXUINT__(T) (((T) -1) + 1)\n#  define __MAXINT__(T) ((T) ((((T) 1) << ((sizeof(T) * CHAR_BIT) - 1)) ^ __MAXUINT__(T)))\n#  define __MININT__(T) (-__MAXINT__(T))\n\n# elif (-1 & 3) == 0x01\t\t/* Sign/magnitude */\n\n#  define __MAXINT__(T) ((T) (((((T) 1) << ((sizeof(T) * CHAR_BIT) - 2)) - 1) | (((T) 1) << ((sizeof(T) * CHAR_BIT) - 2))))\n#  define __MAXUINT__(T) ((T) (__MAXINT__(T) | (((T) 1) << ((sizeof(T) * CHAR_BIT) - 1))))\n#  define __MININT__(T) (-__MAXINT__(T))\n\n# else\n\n#  error \"do not know the integer encoding on this architecture\"\n\n# endif\n\n# ifndef INT8_MAX\n#  define INT8_MIN __MININT__(int8_t)\n#  define INT8_MAX __MAXINT__(int8_t)\n#  define UINT8_MAX __MAXUINT__(uint8_t)\n# endif\n\n# ifndef INT16_MAX\n#  define INT16_MIN __MININT__(int16_t)\n#  define INT16_MAX __MAXINT__(int16_t)\n#  define UINT16_MAX __MAXUINT__(uint16_t)\n# endif\n\n# ifndef INT32_MAX\n#  define INT32_MIN __MININT__(int32_t)\n#  define INT32_MAX __MAXINT__(int32_t)\n#  define UINT32_MAX __MAXUINT__(uint32_t)\n# endif\n\n# ifndef INT64_MAX\n#  define INT64_MIN __MININT__(int64_t)\n#  define INT64_MAX __MAXINT__(int64_t)\n#  define UINT64_MAX __MAXUINT__(uint64_t)\n# endif\n\n# ifndef SIZE_MAX\n#  define SIZE_MAX __MAXUINT__(size_t)\n# endif\n\n#endif\n\n"
  },
  {
    "path": "cryptomini/include/internal/o_dir.h",
    "content": "/*\n * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * This file is dual-licensed and is also available under the following\n * terms:\n *\n * Copyright (c) 2004, Richard Levitte <richard@levitte.org>\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n */\n\n#ifndef OSSL_INTERNAL_O_DIR_H\n# define OSSL_INTERNAL_O_DIR_H\n\ntypedef struct OPENSSL_dir_context_st OPENSSL_DIR_CTX;\n\n/*\n * returns NULL on error or end-of-directory. If it is end-of-directory,\n * errno will be zero\n */\nconst char *OPENSSL_DIR_read(OPENSSL_DIR_CTX **ctx, const char *directory);\n/* returns 1 on success, 0 on error */\nint OPENSSL_DIR_end(OPENSSL_DIR_CTX **ctx);\n\n#endif                          /* LPDIR_H */\n"
  },
  {
    "path": "cryptomini/include/internal/o_str.h",
    "content": "/*\n * Copyright 2003-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_O_STR_H\n# define OSSL_INTERNAL_O_STR_H\n\n# include <stddef.h>            /* to get size_t */\n\nint OPENSSL_memcmp(const void *p1, const void *p2, size_t n);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/refcount.h",
    "content": "/*\n * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n#ifndef OSSL_INTERNAL_REFCOUNT_H\n# define OSSL_INTERNAL_REFCOUNT_H\n\n/* Used to checking reference counts, most while doing perl5 stuff :-) */\n# if defined(OPENSSL_NO_STDIO)\n#  if defined(REF_PRINT)\n#   error \"REF_PRINT requires stdio\"\n#  endif\n# endif\n\n# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \\\n     && !defined(__STDC_NO_ATOMICS__)\n#  include <stdatomic.h>\n#  define HAVE_C11_ATOMICS\n# endif\n\n# if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \\\n     && ATOMIC_INT_LOCK_FREE > 0\n\n#  define HAVE_ATOMICS 1\n\ntypedef _Atomic int CRYPTO_REF_COUNT;\n\nstatic inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)\n{\n    *ret = atomic_fetch_add_explicit(val, 1, memory_order_relaxed) + 1;\n    return 1;\n}\n\n/*\n * Changes to shared structure other than reference counter have to be\n * serialized. And any kind of serialization implies a release fence. This\n * means that by the time reference counter is decremented all other\n * changes are visible on all processors. Hence decrement itself can be\n * relaxed. In case it hits zero, object will be destructed. Since it's\n * last use of the object, destructor programmer might reason that access\n * to mutable members doesn't have to be serialized anymore, which would\n * otherwise imply an acquire fence. Hence conditional acquire fence...\n */\nstatic inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)\n{\n    *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1;\n    if (*ret == 0)\n        atomic_thread_fence(memory_order_acquire);\n    return 1;\n}\n\n# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0\n\n#  define HAVE_ATOMICS 1\n\ntypedef int CRYPTO_REF_COUNT;\n\nstatic __inline__ int CRYPTO_UP_REF(int *val, int *ret, void *lock)\n{\n    *ret = __atomic_fetch_add(val, 1, __ATOMIC_RELAXED) + 1;\n    return 1;\n}\n\nstatic __inline__ int CRYPTO_DOWN_REF(int *val, int *ret, void *lock)\n{\n    *ret = __atomic_fetch_sub(val, 1, __ATOMIC_RELAXED) - 1;\n    if (*ret == 0)\n        __atomic_thread_fence(__ATOMIC_ACQUIRE);\n    return 1;\n}\n\n# elif defined(_MSC_VER) && _MSC_VER>=1200\n\n#  define HAVE_ATOMICS 1\n\ntypedef volatile int CRYPTO_REF_COUNT;\n\n#  if (defined(_M_ARM) && _M_ARM>=7 && !defined(_WIN32_WCE)) || defined(_M_ARM64)\n#   include <intrin.h>\n#   if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH)\n#    define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH\n#   endif\n\nstatic __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock)\n{\n    *ret = _InterlockedExchangeAdd_nf(val, 1) + 1;\n    return 1;\n}\n\nstatic __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock)\n{\n    *ret = _InterlockedExchangeAdd_nf(val, -1) - 1;\n    if (*ret == 0)\n        __dmb(_ARM_BARRIER_ISH);\n    return 1;\n}\n#  else\n#   if !defined(_WIN32_WCE)\n#    pragma intrinsic(_InterlockedExchangeAdd)\n#   else\n#    if _WIN32_WCE >= 0x600\n      extern long __cdecl _InterlockedExchangeAdd(long volatile*, long);\n#    else\n      /* under Windows CE we still have old-style Interlocked* functions */\n      extern long __cdecl InterlockedExchangeAdd(long volatile*, long);\n#     define _InterlockedExchangeAdd InterlockedExchangeAdd\n#    endif\n#   endif\n\nstatic __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock)\n{\n    *ret = _InterlockedExchangeAdd(val, 1) + 1;\n    return 1;\n}\n\nstatic __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock)\n{\n    *ret = _InterlockedExchangeAdd(val, -1) - 1;\n    return 1;\n}\n#  endif\n\n# else\n\ntypedef int CRYPTO_REF_COUNT;\n\n# define CRYPTO_UP_REF(val, ret, lock) CRYPTO_atomic_add(val, 1, ret, lock)\n# define CRYPTO_DOWN_REF(val, ret, lock) CRYPTO_atomic_add(val, -1, ret, lock)\n\n# endif\n\n# if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO)\n#  define REF_ASSERT_ISNT(test) \\\n    (void)((test) ? (OPENSSL_die(\"refcount error\", __FILE__, __LINE__), 1) : 0)\n# else\n#  define REF_ASSERT_ISNT(i)\n# endif\n\n# ifdef REF_PRINT\n#  define REF_PRINT_COUNT(a, b) \\\n        fprintf(stderr, \"%p:%4d:%s\\n\", b, b->references, a)\n# else\n#  define REF_PRINT_COUNT(a, b)\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/sockets.h",
    "content": "/*\n * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n\n#ifndef OSSL_INTERNAL_SOCKETS_H\n# define OSSL_INTERNAL_SOCKETS_H\n\n# if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)\n#  define NO_SYS_PARAM_H\n# endif\n# ifdef WIN32\n#  define NO_SYS_UN_H\n# endif\n# ifdef OPENSSL_SYS_VMS\n#  define NO_SYS_PARAM_H\n#  define NO_SYS_UN_H\n# endif\n\n# ifdef OPENSSL_NO_SOCK\n\n# elif defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)\n#  if defined(__DJGPP__)\n#   include <sys/socket.h>\n#   include <sys/un.h>\n#   include <tcp.h>\n#   include <netdb.h>\n#   include <arpa/inet.h>\n#   include <netinet/tcp.h>\n#  elif defined(_WIN32_WCE) && _WIN32_WCE<410\n#   define getservbyname _masked_declaration_getservbyname\n#  endif\n#  if !defined(IPPROTO_IP)\n    /* winsock[2].h was included already? */\n#   include <winsock.h>\n#  endif\n#  ifdef getservbyname\n     /* this is used to be wcecompat/include/winsock_extras.h */\n#   undef getservbyname\nstruct servent *PASCAL getservbyname(const char *, const char *);\n#  endif\n\n#  ifdef _WIN64\n/*\n * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because\n * the value constitutes an index in per-process table of limited size\n * and not a real pointer. And we also depend on fact that all processors\n * Windows run on happen to be two's-complement, which allows to\n * interchange INVALID_SOCKET and -1.\n */\n#   define socket(d,t,p)   ((int)socket(d,t,p))\n#   define accept(s,f,l)   ((int)accept(s,f,l))\n#  endif\n\n# else\n\n#  ifndef NO_SYS_PARAM_H\n#   include <sys/param.h>\n#  endif\n#  ifdef OPENSSL_SYS_VXWORKS\n#   include <time.h>\n#  endif\n\n#  include <netdb.h>\n#  if defined(OPENSSL_SYS_VMS_NODECC)\n#   include <socket.h>\n#   include <in.h>\n#   include <inet.h>\n#  else\n#   include <sys/socket.h>\n#   ifndef NO_SYS_UN_H\n#    include <sys/un.h>\n#    ifndef UNIX_PATH_MAX\n#     define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)\n#    endif\n#   endif\n#   ifdef FILIO_H\n#    include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */\n#   endif\n#   include <netinet/in.h>\n#   include <arpa/inet.h>\n#   include <netinet/tcp.h>\n#  endif\n\n#  ifdef OPENSSL_SYS_AIX\n#   include <sys/select.h>\n#  endif\n\n#  ifndef VMS\n#   include <sys/ioctl.h>\n#  else\n#   if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)\n     /* ioctl is only in VMS > 7.0 and when socketshr is not used */\n#    include <sys/ioctl.h>\n#   endif\n#   include <unixio.h>\n#   if defined(TCPIP_TYPE_SOCKETSHR)\n#    include <socketshr.h>\n#   endif\n#  endif\n\n#  ifndef INVALID_SOCKET\n#   define INVALID_SOCKET      (-1)\n#  endif\n# endif\n\n/*\n * Some IPv6 implementations are broken, you can disable them in known\n * bad versions.\n */\n# if !defined(OPENSSL_USE_IPV6)\n#  if defined(AF_INET6)\n#   define OPENSSL_USE_IPV6 1\n#  else\n#   define OPENSSL_USE_IPV6 0\n#  endif\n# endif\n\n# define get_last_socket_error() errno\n# define clear_socket_error()    errno=0\n\n# if defined(OPENSSL_SYS_WINDOWS)\n#  undef get_last_socket_error\n#  undef clear_socket_error\n#  define get_last_socket_error() WSAGetLastError()\n#  define clear_socket_error()    WSASetLastError(0)\n#  define readsocket(s,b,n)       recv((s),(b),(n),0)\n#  define writesocket(s,b,n)      send((s),(b),(n),0)\n# elif defined(__DJGPP__)\n#  define WATT32\n#  define WATT32_NO_OLDIES\n#  define closesocket(s)          close_s(s)\n#  define readsocket(s,b,n)       read_s(s,b,n)\n#  define writesocket(s,b,n)      send(s,b,n,0)\n# elif defined(OPENSSL_SYS_VMS)\n#  define ioctlsocket(a,b,c)      ioctl(a,b,c)\n#  define closesocket(s)          close(s)\n#  define readsocket(s,b,n)       recv((s),(b),(n),0)\n#  define writesocket(s,b,n)      send((s),(b),(n),0)\n# elif defined(OPENSSL_SYS_VXWORKS)\n#  define ioctlsocket(a,b,c)          ioctl((a),(b),(int)(c))\n#  define closesocket(s)              close(s)\n#  define readsocket(s,b,n)           read((s),(b),(n))\n#  define writesocket(s,b,n)          write((s),(char *)(b),(n))\n# else\n#  define ioctlsocket(a,b,c)      ioctl(a,b,c)\n#  define closesocket(s)          close(s)\n#  define readsocket(s,b,n)       read((s),(b),(n))\n#  define writesocket(s,b,n)      write((s),(b),(n))\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/sslconf.h",
    "content": "/*\n * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef OSSL_INTERNAL_SSLCONF_H\n# define OSSL_INTERNAL_SSLCONF_H\n\ntypedef struct ssl_conf_cmd_st SSL_CONF_CMD;\n\nconst SSL_CONF_CMD *conf_ssl_get(size_t idx, const char **name, size_t *cnt);\nint conf_ssl_name_find(const char *name, size_t *idx);\nvoid conf_ssl_get_cmd(const SSL_CONF_CMD *cmd, size_t idx, char **cmdstr,\n                      char **arg);\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/internal/thread_once.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/crypto.h>\n\n/*\n * DEFINE_RUN_ONCE: Define an initialiser function that should be run exactly\n * once. It takes no arguments and returns and int result (1 for success or\n * 0 for failure). Typical usage might be:\n *\n * DEFINE_RUN_ONCE(myinitfunc)\n * {\n *     do_some_initialisation();\n *     if (init_is_successful())\n *         return 1;\n *\n *     return 0;\n * }\n */\n#define DEFINE_RUN_ONCE(init)                   \\\n    static int init(void);                     \\\n    int init##_ossl_ret_ = 0;                   \\\n    void init##_ossl_(void)                     \\\n    {                                           \\\n        init##_ossl_ret_ = init();              \\\n    }                                           \\\n    static int init(void)\n\n/*\n * DECLARE_RUN_ONCE: Declare an initialiser function that should be run exactly\n * once that has been defined in another file via DEFINE_RUN_ONCE().\n */\n#define DECLARE_RUN_ONCE(init)                  \\\n    extern int init##_ossl_ret_;                \\\n    void init##_ossl_(void);\n\n/*\n * DEFINE_RUN_ONCE_STATIC: Define an initialiser function that should be run\n * exactly once. This function will be declared as static within the file. It\n * takes no arguments and returns and int result (1 for success or 0 for\n * failure). Typical usage might be:\n *\n * DEFINE_RUN_ONCE_STATIC(myinitfunc)\n * {\n *     do_some_initialisation();\n *     if (init_is_successful())\n *         return 1;\n *\n *     return 0;\n * }\n */\n#define DEFINE_RUN_ONCE_STATIC(init)            \\\n    static int init(void);                     \\\n    static int init##_ossl_ret_ = 0;            \\\n    static void init##_ossl_(void)              \\\n    {                                           \\\n        init##_ossl_ret_ = init();              \\\n    }                                           \\\n    static int init(void)\n\n/*\n * DEFINE_RUN_ONCE_STATIC_ALT: Define an alternative initialiser function. This\n * function will be declared as static within the file. It takes no arguments\n * and returns an int result (1 for success or 0 for failure). An alternative\n * initialiser function is expected to be associated with a primary initialiser\n * function defined via DEFINE_ONCE_STATIC where both functions use the same\n * CRYPTO_ONCE object to synchronise. Where an alternative initialiser function\n * is used only one of the primary or the alternative initialiser function will\n * ever be called - and that function will be called exactly once. Definition\n * of an alternative initialiser function MUST occur AFTER the definition of the\n * primary initialiser function.\n *\n * Typical usage might be:\n *\n * DEFINE_RUN_ONCE_STATIC(myinitfunc)\n * {\n *     do_some_initialisation();\n *     if (init_is_successful())\n *         return 1;\n *\n *     return 0;\n * }\n *\n * DEFINE_RUN_ONCE_STATIC_ALT(myaltinitfunc, myinitfunc)\n * {\n *     do_some_alternative_initialisation();\n *     if (init_is_successful())\n *         return 1;\n *\n *     return 0;\n * }\n */\n#define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \\\n    static int initalt(void);                     \\\n    static void initalt##_ossl_(void)             \\\n    {                                             \\\n        init##_ossl_ret_ = initalt();             \\\n    }                                             \\\n    static int initalt(void)\n\n/*\n * RUN_ONCE - use CRYPTO_THREAD_run_once, and check if the init succeeded\n * @once: pointer to static object of type CRYPTO_ONCE\n * @init: function name that was previously given to DEFINE_RUN_ONCE,\n *        DEFINE_RUN_ONCE_STATIC or DECLARE_RUN_ONCE.  This function\n *        must return 1 for success or 0 for failure.\n *\n * The return value is 1 on success (*) or 0 in case of error.\n *\n * (*) by convention, since the init function must return 1 on success.\n */\n#define RUN_ONCE(once, init)                                            \\\n    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)\n\n/*\n * RUN_ONCE_ALT - use CRYPTO_THREAD_run_once, to run an alternative initialiser\n *                function and check if that initialisation succeeded\n * @once:    pointer to static object of type CRYPTO_ONCE\n * @initalt: alternative initialiser function name that was previously given to\n *           DEFINE_RUN_ONCE_STATIC_ALT.  This function must return 1 for\n *           success or 0 for failure.\n * @init:    primary initialiser function name that was previously given to\n *           DEFINE_RUN_ONCE_STATIC.  This function must return 1 for success or\n *           0 for failure.\n *\n * The return value is 1 on success (*) or 0 in case of error.\n *\n * (*) by convention, since the init function must return 1 on success.\n */\n#define RUN_ONCE_ALT(once, initalt, init)                               \\\n    (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0)\n"
  },
  {
    "path": "cryptomini/include/internal/tsan_assist.h",
    "content": "/*\n * Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * Contemporary compilers implement lock-free atomic memory access\n * primitives that facilitate writing \"thread-opportunistic\" or even real\n * multi-threading low-overhead code. \"Thread-opportunistic\" is when\n * exact result is not required, e.g. some statistics, or execution flow\n * doesn't have to be unambiguous. Simplest example is lazy \"constant\"\n * initialization when one can synchronize on variable itself, e.g.\n *\n * if (var == NOT_YET_INITIALIZED)\n *     var = function_returning_same_value();\n *\n * This does work provided that loads and stores are single-instruction\n * operations (and integer ones are on *all* supported platforms), but\n * it upsets Thread Sanitizer. Suggested solution is\n *\n * if (tsan_load(&var) == NOT_YET_INITIALIZED)\n *     tsan_store(&var, function_returning_same_value());\n *\n * Production machine code would be the same, so one can wonder why\n * bother. Having Thread Sanitizer accept \"thread-opportunistic\" code\n * allows to move on trouble-shooting real bugs.\n *\n * Resolving Thread Sanitizer nits was the initial purpose for this module,\n * but it was later extended with more nuanced primitives that are useful\n * even in \"non-opportunistic\" scenarios. Most notably verifying if a shared\n * structure is fully initialized and bypassing the initialization lock.\n * It's suggested to view macros defined in this module as \"annotations\" for\n * thread-safe lock-free code, \"Thread-Safe ANnotations\"...\n *\n * It's assumed that ATOMIC_{LONG|INT}_LOCK_FREE are assigned same value as\n * ATOMIC_POINTER_LOCK_FREE. And check for >= 2 ensures that corresponding\n * code is inlined. It should be noted that statistics counters become\n * accurate in such case.\n *\n * Special note about TSAN_QUALIFIER. It might be undesired to use it in\n * a shared header. Because whether operation on specific variable or member\n * is atomic or not might be irrelevant in other modules. In such case one\n * can use TSAN_QUALIFIER in cast specifically when it has to count.\n */\n\n#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \\\n    && !defined(__STDC_NO_ATOMICS__)\n# include <stdatomic.h>\n\n# if defined(ATOMIC_POINTER_LOCK_FREE) \\\n          && ATOMIC_POINTER_LOCK_FREE >= 2\n#  define TSAN_QUALIFIER _Atomic\n#  define tsan_load(ptr) atomic_load_explicit((ptr), memory_order_relaxed)\n#  define tsan_store(ptr, val) atomic_store_explicit((ptr), (val), memory_order_relaxed)\n#  define tsan_counter(ptr) atomic_fetch_add_explicit((ptr), 1, memory_order_relaxed)\n#  define tsan_decr(ptr) atomic_fetch_add_explicit((ptr), -1, memory_order_relaxed)\n#  define tsan_ld_acq(ptr) atomic_load_explicit((ptr), memory_order_acquire)\n#  define tsan_st_rel(ptr, val) atomic_store_explicit((ptr), (val), memory_order_release)\n# endif\n\n#elif defined(__GNUC__) && defined(__ATOMIC_RELAXED)\n\n# if defined(__GCC_ATOMIC_POINTER_LOCK_FREE) \\\n          && __GCC_ATOMIC_POINTER_LOCK_FREE >= 2\n#  define TSAN_QUALIFIER volatile\n#  define tsan_load(ptr) __atomic_load_n((ptr), __ATOMIC_RELAXED)\n#  define tsan_store(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELAXED)\n#  define tsan_counter(ptr) __atomic_fetch_add((ptr), 1, __ATOMIC_RELAXED)\n#  define tsan_decr(ptr) __atomic_fetch_add((ptr), -1, __ATOMIC_RELAXED)\n#  define tsan_ld_acq(ptr) __atomic_load_n((ptr), __ATOMIC_ACQUIRE)\n#  define tsan_st_rel(ptr, val) __atomic_store_n((ptr), (val), __ATOMIC_RELEASE)\n# endif\n\n#elif defined(_MSC_VER) && _MSC_VER>=1200 \\\n      && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \\\n          defined(_M_ARM64) || (defined(_M_ARM) && _M_ARM >= 7 && !defined(_WIN32_WCE)))\n/*\n * There is subtle dependency on /volatile:<iso|ms> command-line option.\n * \"ms\" implies same semantic as memory_order_acquire for loads and\n * memory_order_release for stores, while \"iso\" - memory_order_relaxed for\n * either. Real complication is that defaults are different on x86 and ARM.\n * There is explanation for that, \"ms\" is backward compatible with earlier\n * compiler versions, while multi-processor ARM can be viewed as brand new\n * platform to MSC and its users, and with non-relaxed semantic taking toll\n * with additional instructions and penalties, it kind of makes sense to\n * default to \"iso\"...\n */\n# define TSAN_QUALIFIER volatile\n# if defined(_M_ARM) || defined(_M_ARM64)\n#  define _InterlockedExchangeAdd _InterlockedExchangeAdd_nf\n#  pragma intrinsic(_InterlockedExchangeAdd_nf)\n#  pragma intrinsic(__iso_volatile_load32, __iso_volatile_store32)\n#  ifdef _WIN64\n#   define _InterlockedExchangeAdd64 _InterlockedExchangeAdd64_nf\n#   pragma intrinsic(_InterlockedExchangeAdd64_nf)\n#   pragma intrinsic(__iso_volatile_load64, __iso_volatile_store64)\n#   define tsan_load(ptr) (sizeof(*(ptr)) == 8 ? __iso_volatile_load64(ptr) \\\n                                               : __iso_volatile_load32(ptr))\n#   define tsan_store(ptr, val) (sizeof(*(ptr)) == 8 ? __iso_volatile_store64((ptr), (val)) \\\n                                                     : __iso_volatile_store32((ptr), (val)))\n#  else\n#   define tsan_load(ptr) __iso_volatile_load32(ptr)\n#   define tsan_store(ptr, val) __iso_volatile_store32((ptr), (val))\n#  endif\n# else\n#  define tsan_load(ptr) (*(ptr))\n#  define tsan_store(ptr, val) (*(ptr) = (val))\n# endif\n# pragma intrinsic(_InterlockedExchangeAdd)\n# ifdef _WIN64\n#  pragma intrinsic(_InterlockedExchangeAdd64)\n#  define tsan_counter(ptr) (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((ptr), 1) \\\n                                                 : _InterlockedExchangeAdd((ptr), 1))\n#  define tsan_decr(ptr) (sizeof(*(ptr)) == 8 ? _InterlockedExchangeAdd64((ptr), -1) \\\n                                                 : _InterlockedExchangeAdd((ptr), -1))\n# else\n#  define tsan_counter(ptr) _InterlockedExchangeAdd((ptr), 1)\n#  define tsan_decr(ptr) _InterlockedExchangeAdd((ptr), -1)\n# endif\n# if !defined(_ISO_VOLATILE)\n#  define tsan_ld_acq(ptr) (*(ptr))\n#  define tsan_st_rel(ptr, val) (*(ptr) = (val))\n# endif\n\n#endif\n\n#ifndef TSAN_QUALIFIER\n\n# define TSAN_QUALIFIER volatile\n# define tsan_load(ptr) (*(ptr))\n# define tsan_store(ptr, val) (*(ptr) = (val))\n# define tsan_counter(ptr) ((*(ptr))++)\n# define tsan_decr(ptr) ((*(ptr))--)\n/*\n * Lack of tsan_ld_acq and tsan_ld_rel means that compiler support is not\n * sophisticated enough to support them. Code that relies on them should be\n * protected with #ifdef tsan_ld_acq with locked fallback.\n */\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/__DECC_INCLUDE_EPILOGUE.H",
    "content": "/*\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * This file is only used by HP C/C++ on VMS, and is included automatically\n * after each header file from this directory\n */\n\n/*\n * The C++ compiler doesn't understand these pragmas, even though it\n * understands the corresponding command line qualifier.\n */\n#ifndef __cplusplus\n/* restore state.  Must correspond to the save in __decc_include_prologue.h */\n# pragma names restore\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/__DECC_INCLUDE_PROLOGUE.H",
    "content": "/*\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * This file is only used by HP C/C++ on VMS, and is included automatically\n * after each header file from this directory\n */\n\n/*\n * The C++ compiler doesn't understand these pragmas, even though it\n * understands the corresponding command line qualifier.\n */\n#ifndef __cplusplus\n/* save state */\n# pragma names save\n/* have the compiler shorten symbols larger than 31 chars to 23 chars\n * followed by a 8 hex char CRC\n */\n# pragma names as_is,shortened\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/aes.h",
    "content": "/*\n * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_AES_H\n# define HEADER_AES_H\n\n# include <openssl/opensslconf.h>\n\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define AES_ENCRYPT     1\n# define AES_DECRYPT     0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n# define AES_MAXNR 14\n# define AES_BLOCK_SIZE 16\n\n/* This should be a hidden type, but EVP requires that the size be known */\nstruct aes_key_st {\n# ifdef AES_LONG\n    unsigned long rd_key[4 * (AES_MAXNR + 1)];\n# else\n    unsigned int rd_key[4 * (AES_MAXNR + 1)];\n# endif\n    int rounds;\n};\ntypedef struct aes_key_st AES_KEY;\n\nconst char *AES_options(void);\n\nint AES_set_encrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\nint AES_set_decrypt_key(const unsigned char *userKey, const int bits,\n                        AES_KEY *key);\n\nvoid AES_encrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\nvoid AES_decrypt(const unsigned char *in, unsigned char *out,\n                 const AES_KEY *key);\n\nvoid AES_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     const AES_KEY *key, const int enc);\nvoid AES_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\nvoid AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                      size_t length, const AES_KEY *key,\n                      unsigned char *ivec, int *num, const int enc);\nvoid AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        unsigned char *ivec, int *num);\n/* NB: the IV is _two_ blocks long */\nvoid AES_ige_encrypt(const unsigned char *in, unsigned char *out,\n                     size_t length, const AES_KEY *key,\n                     unsigned char *ivec, const int enc);\n/* NB: the IV is _four_ blocks long */\nvoid AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,\n                        size_t length, const AES_KEY *key,\n                        const AES_KEY *key2, const unsigned char *ivec,\n                        const int enc);\n\nint AES_wrap_key(AES_KEY *key, const unsigned char *iv,\n                 unsigned char *out,\n                 const unsigned char *in, unsigned int inlen);\nint AES_unwrap_key(AES_KEY *key, const unsigned char *iv,\n                   unsigned char *out,\n                   const unsigned char *in, unsigned int inlen);\n\n\n# ifdef  __cplusplus\n}\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/asn1.h",
    "content": "/*\n * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ASN1_H\n# define HEADER_ASN1_H\n\n# include <time.h>\n# include <openssl/e_os2.h>\n# include <openssl/opensslconf.h>\n# include <openssl/bio.h>\n# include <openssl/safestack.h>\n# include <openssl/asn1err.h>\n# include <openssl/symhacks.h>\n\n# include <openssl/ossl_typ.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n# endif\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define V_ASN1_UNIVERSAL                0x00\n# define V_ASN1_APPLICATION              0x40\n# define V_ASN1_CONTEXT_SPECIFIC         0x80\n# define V_ASN1_PRIVATE                  0xc0\n\n# define V_ASN1_CONSTRUCTED              0x20\n# define V_ASN1_PRIMITIVE_TAG            0x1f\n# define V_ASN1_PRIMATIVE_TAG /*compat*/ V_ASN1_PRIMITIVE_TAG\n\n# define V_ASN1_APP_CHOOSE               -2/* let the recipient choose */\n# define V_ASN1_OTHER                    -3/* used in ASN1_TYPE */\n# define V_ASN1_ANY                      -4/* used in ASN1 template code */\n\n# define V_ASN1_UNDEF                    -1\n/* ASN.1 tag values */\n# define V_ASN1_EOC                      0\n# define V_ASN1_BOOLEAN                  1 /**/\n# define V_ASN1_INTEGER                  2\n# define V_ASN1_BIT_STRING               3\n# define V_ASN1_OCTET_STRING             4\n# define V_ASN1_NULL                     5\n# define V_ASN1_OBJECT                   6\n# define V_ASN1_OBJECT_DESCRIPTOR        7\n# define V_ASN1_EXTERNAL                 8\n# define V_ASN1_REAL                     9\n# define V_ASN1_ENUMERATED               10\n# define V_ASN1_UTF8STRING               12\n# define V_ASN1_SEQUENCE                 16\n# define V_ASN1_SET                      17\n# define V_ASN1_NUMERICSTRING            18 /**/\n# define V_ASN1_PRINTABLESTRING          19\n# define V_ASN1_T61STRING                20\n# define V_ASN1_TELETEXSTRING            20/* alias */\n# define V_ASN1_VIDEOTEXSTRING           21 /**/\n# define V_ASN1_IA5STRING                22\n# define V_ASN1_UTCTIME                  23\n# define V_ASN1_GENERALIZEDTIME          24 /**/\n# define V_ASN1_GRAPHICSTRING            25 /**/\n# define V_ASN1_ISO64STRING              26 /**/\n# define V_ASN1_VISIBLESTRING            26/* alias */\n# define V_ASN1_GENERALSTRING            27 /**/\n# define V_ASN1_UNIVERSALSTRING          28 /**/\n# define V_ASN1_BMPSTRING                30\n\n/*\n * NB the constants below are used internally by ASN1_INTEGER\n * and ASN1_ENUMERATED to indicate the sign. They are *not* on\n * the wire tag values.\n */\n\n# define V_ASN1_NEG                      0x100\n# define V_ASN1_NEG_INTEGER              (2 | V_ASN1_NEG)\n# define V_ASN1_NEG_ENUMERATED           (10 | V_ASN1_NEG)\n\n/* For use with d2i_ASN1_type_bytes() */\n# define B_ASN1_NUMERICSTRING    0x0001\n# define B_ASN1_PRINTABLESTRING  0x0002\n# define B_ASN1_T61STRING        0x0004\n# define B_ASN1_TELETEXSTRING    0x0004\n# define B_ASN1_VIDEOTEXSTRING   0x0008\n# define B_ASN1_IA5STRING        0x0010\n# define B_ASN1_GRAPHICSTRING    0x0020\n# define B_ASN1_ISO64STRING      0x0040\n# define B_ASN1_VISIBLESTRING    0x0040\n# define B_ASN1_GENERALSTRING    0x0080\n# define B_ASN1_UNIVERSALSTRING  0x0100\n# define B_ASN1_OCTET_STRING     0x0200\n# define B_ASN1_BIT_STRING       0x0400\n# define B_ASN1_BMPSTRING        0x0800\n# define B_ASN1_UNKNOWN          0x1000\n# define B_ASN1_UTF8STRING       0x2000\n# define B_ASN1_UTCTIME          0x4000\n# define B_ASN1_GENERALIZEDTIME  0x8000\n# define B_ASN1_SEQUENCE         0x10000\n/* For use with ASN1_mbstring_copy() */\n# define MBSTRING_FLAG           0x1000\n# define MBSTRING_UTF8           (MBSTRING_FLAG)\n# define MBSTRING_ASC            (MBSTRING_FLAG|1)\n# define MBSTRING_BMP            (MBSTRING_FLAG|2)\n# define MBSTRING_UNIV           (MBSTRING_FLAG|4)\n# define SMIME_OLDMIME           0x400\n# define SMIME_CRLFEOL           0x800\n# define SMIME_STREAM            0x1000\n    struct X509_algor_st;\nDEFINE_STACK_OF(X509_ALGOR)\n\n# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */\n/*\n * This indicates that the ASN1_STRING is not a real value but just a place\n * holder for the location where indefinite length constructed data should be\n * inserted in the memory buffer\n */\n# define ASN1_STRING_FLAG_NDEF 0x010\n\n/*\n * This flag is used by the CMS code to indicate that a string is not\n * complete and is a place holder for content when it had all been accessed.\n * The flag will be reset when content has been written to it.\n */\n\n# define ASN1_STRING_FLAG_CONT 0x020\n/*\n * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING\n * type.\n */\n# define ASN1_STRING_FLAG_MSTRING 0x040\n/* String is embedded and only content should be freed */\n# define ASN1_STRING_FLAG_EMBED 0x080\n/* String should be parsed in RFC 5280's time format */\n# define ASN1_STRING_FLAG_X509_TIME 0x100\n/* This is the base type that holds just about everything :-) */\nstruct asn1_string_st {\n    int length;\n    int type;\n    unsigned char *data;\n    /*\n     * The value of the following field depends on the type being held.  It\n     * is mostly being used for BIT_STRING so if the input data has a\n     * non-zero 'unused bits' value, it will be handled correctly\n     */\n    long flags;\n};\n\n/*\n * ASN1_ENCODING structure: this is used to save the received encoding of an\n * ASN1 type. This is useful to get round problems with invalid encodings\n * which can break signatures.\n */\n\ntypedef struct ASN1_ENCODING_st {\n    unsigned char *enc;         /* DER encoding */\n    long len;                   /* Length of encoding */\n    int modified;               /* set to 1 if 'enc' is invalid */\n} ASN1_ENCODING;\n\n/* Used with ASN1 LONG type: if a long is set to this it is omitted */\n# define ASN1_LONG_UNDEF 0x7fffffffL\n\n# define STABLE_FLAGS_MALLOC     0x01\n/*\n * A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted\n * as \"don't change\" and STABLE_FLAGS_MALLOC is always set. By setting\n * STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias\n * STABLE_FLAGS_CLEAR to reflect this.\n */\n# define STABLE_FLAGS_CLEAR      STABLE_FLAGS_MALLOC\n# define STABLE_NO_MASK          0x02\n# define DIRSTRING_TYPE  \\\n (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING)\n# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING)\n\ntypedef struct asn1_string_table_st {\n    int nid;\n    long minsize;\n    long maxsize;\n    unsigned long mask;\n    unsigned long flags;\n} ASN1_STRING_TABLE;\n\nDEFINE_STACK_OF(ASN1_STRING_TABLE)\n\n/* size limits: this stuff is taken straight from RFC2459 */\n\n# define ub_name                         32768\n# define ub_common_name                  64\n# define ub_locality_name                128\n# define ub_state_name                   128\n# define ub_organization_name            64\n# define ub_organization_unit_name       64\n# define ub_title                        64\n# define ub_email_address                128\n\n/*\n * Declarations for template structures: for full definitions see asn1t.h\n */\ntypedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE;\ntypedef struct ASN1_TLC_st ASN1_TLC;\n/* This is just an opaque pointer */\ntypedef struct ASN1_VALUE_st ASN1_VALUE;\n\n/* Declare ASN1 functions: the implement macro in in asn1t.h */\n\n# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type)\n\n# define DECLARE_ASN1_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name)\n\n# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(itname)\n\n# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \\\n        type *d2i_##name(type **a, const unsigned char **in, long len); \\\n        int i2d_##name(const type *a, unsigned char **out); \\\n        DECLARE_ASN1_ITEM(name)\n\n# define DECLARE_ASN1_NDEF_FUNCTION(name) \\\n        int i2d_##name##_NDEF(name *a, unsigned char **out);\n\n# define DECLARE_ASN1_FUNCTIONS_const(name) \\\n        DECLARE_ASN1_ALLOC_FUNCTIONS(name) \\\n        DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name)\n\n# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \\\n        type *name##_new(void); \\\n        void name##_free(type *a);\n\n# define DECLARE_ASN1_PRINT_FUNCTION(stname) \\\n        DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname)\n\n# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                         const ASN1_PCTX *pctx);\n\n# define D2I_OF(type) type *(*)(type **,const unsigned char **,long)\n# define I2D_OF(type) int (*)(type *,unsigned char **)\n# define I2D_OF_const(type) int (*)(const type *,unsigned char **)\n\n# define CHECKED_D2I_OF(type, d2i) \\\n    ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0)))\n# define CHECKED_I2D_OF(type, i2d) \\\n    ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0)))\n# define CHECKED_NEW_OF(type, xnew) \\\n    ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0)))\n# define CHECKED_PTR_OF(type, p) \\\n    ((void*) (1 ? p : (type*)0))\n# define CHECKED_PPTR_OF(type, p) \\\n    ((void**) (1 ? p : (type**)0))\n\n# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long)\n# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **)\n# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type)\n\nTYPEDEF_D2I2D_OF(void);\n\n/*-\n * The following macros and typedefs allow an ASN1_ITEM\n * to be embedded in a structure and referenced. Since\n * the ASN1_ITEM pointers need to be globally accessible\n * (possibly from shared libraries) they may exist in\n * different forms. On platforms that support it the\n * ASN1_ITEM structure itself will be globally exported.\n * Other platforms will export a function that returns\n * an ASN1_ITEM pointer.\n *\n * To handle both cases transparently the macros below\n * should be used instead of hard coding an ASN1_ITEM\n * pointer in a structure.\n *\n * The structure will look like this:\n *\n * typedef struct SOMETHING_st {\n *      ...\n *      ASN1_ITEM_EXP *iptr;\n *      ...\n * } SOMETHING;\n *\n * It would be initialised as e.g.:\n *\n * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...};\n *\n * and the actual pointer extracted with:\n *\n * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr);\n *\n * Finally an ASN1_ITEM pointer can be extracted from an\n * appropriate reference with: ASN1_ITEM_rptr(X509). This\n * would be used when a function takes an ASN1_ITEM * argument.\n *\n */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM ASN1_ITEM_EXP;\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr)\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (&(iptr##_it))\n\n#  define ASN1_ITEM_rptr(ref) (&(ref##_it))\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        OPENSSL_EXTERN const ASN1_ITEM name##_it;\n\n# else\n\n/*\n * Platforms that can't easily handle shared global variables are declared as\n * functions returning ASN1_ITEM pointers.\n */\n\n/* ASN1_ITEM pointer exported type */\ntypedef const ASN1_ITEM *ASN1_ITEM_EXP (void);\n\n/* Macro to obtain ASN1_ITEM pointer from exported type */\n#  define ASN1_ITEM_ptr(iptr) (iptr())\n\n/* Macro to include ASN1_ITEM pointer from base type */\n#  define ASN1_ITEM_ref(iptr) (iptr##_it)\n\n#  define ASN1_ITEM_rptr(ref) (ref##_it())\n\n#  define DECLARE_ASN1_ITEM(name) \\\n        const ASN1_ITEM * name##_it(void);\n\n# endif\n\n/* Parameters used by ASN1_STRING_print_ex() */\n\n/*\n * These determine which characters to escape: RFC2253 special characters,\n * control characters and MSB set characters\n */\n\n# define ASN1_STRFLGS_ESC_2253           1\n# define ASN1_STRFLGS_ESC_CTRL           2\n# define ASN1_STRFLGS_ESC_MSB            4\n\n/*\n * This flag determines how we do escaping: normally RC2253 backslash only,\n * set this to use backslash and quote.\n */\n\n# define ASN1_STRFLGS_ESC_QUOTE          8\n\n/* These three flags are internal use only. */\n\n/* Character is a valid PrintableString character */\n# define CHARTYPE_PRINTABLESTRING        0x10\n/* Character needs escaping if it is the first character */\n# define CHARTYPE_FIRST_ESC_2253         0x20\n/* Character needs escaping if it is the last character */\n# define CHARTYPE_LAST_ESC_2253          0x40\n\n/*\n * NB the internal flags are safely reused below by flags handled at the top\n * level.\n */\n\n/*\n * If this is set we convert all character strings to UTF8 first\n */\n\n# define ASN1_STRFLGS_UTF8_CONVERT       0x10\n\n/*\n * If this is set we don't attempt to interpret content: just assume all\n * strings are 1 byte per character. This will produce some pretty odd\n * looking output!\n */\n\n# define ASN1_STRFLGS_IGNORE_TYPE        0x20\n\n/* If this is set we include the string type in the output */\n# define ASN1_STRFLGS_SHOW_TYPE          0x40\n\n/*\n * This determines which strings to display and which to 'dump' (hex dump of\n * content octets or DER encoding). We can only dump non character strings or\n * everything. If we don't dump 'unknown' they are interpreted as character\n * strings with 1 octet per character and are subject to the usual escaping\n * options.\n */\n\n# define ASN1_STRFLGS_DUMP_ALL           0x80\n# define ASN1_STRFLGS_DUMP_UNKNOWN       0x100\n\n/*\n * These determine what 'dumping' does, we can dump the content octets or the\n * DER encoding: both use the RFC2253 #XXXXX notation.\n */\n\n# define ASN1_STRFLGS_DUMP_DER           0x200\n\n/*\n * This flag specifies that RC2254 escaping shall be performed.\n */\n#define ASN1_STRFLGS_ESC_2254           0x400\n\n/*\n * All the string flags consistent with RFC2253, escaping control characters\n * isn't essential in RFC2253 but it is advisable anyway.\n */\n\n# define ASN1_STRFLGS_RFC2253    (ASN1_STRFLGS_ESC_2253 | \\\n                                ASN1_STRFLGS_ESC_CTRL | \\\n                                ASN1_STRFLGS_ESC_MSB | \\\n                                ASN1_STRFLGS_UTF8_CONVERT | \\\n                                ASN1_STRFLGS_DUMP_UNKNOWN | \\\n                                ASN1_STRFLGS_DUMP_DER)\n\nDEFINE_STACK_OF(ASN1_INTEGER)\n\nDEFINE_STACK_OF(ASN1_GENERALSTRING)\n\nDEFINE_STACK_OF(ASN1_UTF8STRING)\n\ntypedef struct asn1_type_st {\n    int type;\n    union {\n        char *ptr;\n        ASN1_BOOLEAN boolean;\n        ASN1_STRING *asn1_string;\n        ASN1_OBJECT *object;\n        ASN1_INTEGER *integer;\n        ASN1_ENUMERATED *enumerated;\n        ASN1_BIT_STRING *bit_string;\n        ASN1_OCTET_STRING *octet_string;\n        ASN1_PRINTABLESTRING *printablestring;\n        ASN1_T61STRING *t61string;\n        ASN1_IA5STRING *ia5string;\n        ASN1_GENERALSTRING *generalstring;\n        ASN1_BMPSTRING *bmpstring;\n        ASN1_UNIVERSALSTRING *universalstring;\n        ASN1_UTCTIME *utctime;\n        ASN1_GENERALIZEDTIME *generalizedtime;\n        ASN1_VISIBLESTRING *visiblestring;\n        ASN1_UTF8STRING *utf8string;\n        /*\n         * set and sequence are left complete and still contain the set or\n         * sequence bytes\n         */\n        ASN1_STRING *set;\n        ASN1_STRING *sequence;\n        ASN1_VALUE *asn1_value;\n    } value;\n} ASN1_TYPE;\n\nDEFINE_STACK_OF(ASN1_TYPE)\n\ntypedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY;\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY)\n\n/* This is used to contain a list of bit names */\ntypedef struct BIT_STRING_BITNAME_st {\n    int bitnum;\n    const char *lname;\n    const char *sname;\n} BIT_STRING_BITNAME;\n\n# define B_ASN1_TIME \\\n                        B_ASN1_UTCTIME | \\\n                        B_ASN1_GENERALIZEDTIME\n\n# define B_ASN1_PRINTABLE \\\n                        B_ASN1_NUMERICSTRING| \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_T61STRING| \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_BIT_STRING| \\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING|\\\n                        B_ASN1_SEQUENCE|\\\n                        B_ASN1_UNKNOWN\n\n# define B_ASN1_DIRECTORYSTRING \\\n                        B_ASN1_PRINTABLESTRING| \\\n                        B_ASN1_TELETEXSTRING|\\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UNIVERSALSTRING|\\\n                        B_ASN1_UTF8STRING\n\n# define B_ASN1_DISPLAYTEXT \\\n                        B_ASN1_IA5STRING| \\\n                        B_ASN1_VISIBLESTRING| \\\n                        B_ASN1_BMPSTRING|\\\n                        B_ASN1_UTF8STRING\n\nDECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)\n\nint ASN1_TYPE_get(const ASN1_TYPE *a);\nvoid ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);\nint ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);\nint ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);\n\nASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t);\nvoid *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t);\n\nASN1_OBJECT *ASN1_OBJECT_new(void);\nvoid ASN1_OBJECT_free(ASN1_OBJECT *a);\nint i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp);\nASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,\n                             long length);\n\nDECLARE_ASN1_ITEM(ASN1_OBJECT)\n\nDEFINE_STACK_OF(ASN1_OBJECT)\n\nASN1_STRING *ASN1_STRING_new(void);\nvoid ASN1_STRING_free(ASN1_STRING *a);\nvoid ASN1_STRING_clear_free(ASN1_STRING *a);\nint ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str);\nASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a);\nASN1_STRING *ASN1_STRING_type_new(int type);\nint ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b);\n  /*\n   * Since this is used to store all sorts of things, via macros, for now,\n   * make its data void *\n   */\nint ASN1_STRING_set(ASN1_STRING *str, const void *data, int len);\nvoid ASN1_STRING_set0(ASN1_STRING *str, void *data, int len);\nint ASN1_STRING_length(const ASN1_STRING *x);\nvoid ASN1_STRING_length_set(ASN1_STRING *x, int n);\nint ASN1_STRING_type(const ASN1_STRING *x);\nDEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x))\nconst unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING)\nint ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length);\nint ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);\nint ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n);\nint ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a,\n                          const unsigned char *flags, int flags_len);\n\nint ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,\n                               BIT_STRING_BITNAME *tbl, int indent);\nint ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl);\nint ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value,\n                            BIT_STRING_BITNAME *tbl);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_INTEGER)\nASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,\n                                long length);\nASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x);\nint ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED)\n\nint ASN1_UTCTIME_check(const ASN1_UTCTIME *a);\nASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t);\nASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,\n                               int offset_day, long offset_sec);\nint ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str);\nint ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);\n\nint ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,\n                                               time_t t);\nASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,\n                                               time_t t, int offset_day,\n                                               long offset_sec);\nint ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str);\n\nint ASN1_TIME_diff(int *pday, int *psec,\n                   const ASN1_TIME *from, const ASN1_TIME *to);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING)\nASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a);\nint ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a,\n                          const ASN1_OCTET_STRING *b);\nint ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data,\n                          int len);\n\nDECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_NULL)\nDECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING)\n\nint UTF8_getc(const unsigned char *str, int len, unsigned long *val);\nint UTF8_putc(unsigned char *str, int len, unsigned long value);\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE)\n\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING)\nDECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT)\nDECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_T61STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING)\nDECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME)\nDECLARE_ASN1_FUNCTIONS(ASN1_TIME)\n\nDECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF)\n\nASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);\nASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,\n                         int offset_day, long offset_sec);\nint ASN1_TIME_check(const ASN1_TIME *t);\nASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,\n                                                   ASN1_GENERALIZEDTIME **out);\nint ASN1_TIME_set_string(ASN1_TIME *s, const char *str);\nint ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str);\nint ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm);\nint ASN1_TIME_normalize(ASN1_TIME *s);\nint ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t);\nint ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b);\n\nint i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a);\nint a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size);\nint i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a);\nint a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size);\nint i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a);\nint a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size);\nint i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type);\nint i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a);\n\nint a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num);\nASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len,\n                                const char *sn, const char *ln);\n\nint ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a);\nint ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r);\nint ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a);\nint ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r);\n\nint ASN1_INTEGER_set(ASN1_INTEGER *a, long v);\nlong ASN1_INTEGER_get(const ASN1_INTEGER *a);\nASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai);\nBIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn);\n\nint ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a);\nint ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r);\n\n\nint ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v);\nlong ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a);\nASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai);\nBIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn);\n\n/* General */\n/* given a string, return the correct type, max is the maximum length */\nint ASN1_PRINTABLE_type(const unsigned char *s, int max);\n\nunsigned long ASN1_tag2bit(int tag);\n\n/* SPECIALS */\nint ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,\n                    int *pclass, long omax);\nint ASN1_check_infinite_end(unsigned char **p, long len);\nint ASN1_const_check_infinite_end(const unsigned char **p, long len);\nvoid ASN1_put_object(unsigned char **pp, int constructed, int length,\n                     int tag, int xclass);\nint ASN1_put_eoc(unsigned char **pp);\nint ASN1_object_size(int constructed, int length, int tag);\n\n/* Used to implement other functions */\nvoid *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x);\n\n# define ASN1_dup_of(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(type, x)))\n\n# define ASN1_dup_of_const(type,i2d,d2i,x) \\\n    ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \\\n                     CHECKED_D2I_OF(type, d2i), \\\n                     CHECKED_PTR_OF(const type, x)))\n\nvoid *ASN1_item_dup(const ASN1_ITEM *it, void *x);\n\n/* ASN1 alloc/free macros for when a type is only used internally */\n\n# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type))\n# define M_ASN1_free_of(x, type) \\\n                ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type))\n\n# ifndef OPENSSL_NO_STDIO\nvoid *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x);\n\n#  define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \\\n                        CHECKED_D2I_OF(type, d2i), \\\n                        in, \\\n                        CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);\nint ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x);\n\n#  define ASN1_i2d_fp_of(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_fp_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \\\n                 out, \\\n                 CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);\nint ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags);\n# endif\n\nint ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in);\n\nvoid *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x);\n\n#  define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \\\n    ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \\\n                          CHECKED_D2I_OF(type, d2i), \\\n                          in, \\\n                          CHECKED_PPTR_OF(type, x)))\n\nvoid *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);\nint ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x);\n\n#  define ASN1_i2d_bio_of(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(type, x)))\n\n#  define ASN1_i2d_bio_of_const(type,i2d,out,x) \\\n    (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \\\n                  out, \\\n                  CHECKED_PTR_OF(const type, x)))\n\nint ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);\nint ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a);\nint ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a);\nint ASN1_TIME_print(BIO *fp, const ASN1_TIME *a);\nint ASN1_STRING_print(BIO *bp, const ASN1_STRING *v);\nint ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags);\nint ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off);\nint ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num,\n                  unsigned char *buf, int off);\nint ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent);\nint ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent,\n                    int dump);\nconst char *ASN1_tag2str(int tag);\n\n/* Used to load and write Netscape format cert */\n\nint ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s);\n\nint ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len);\nint ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len);\nint ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num,\n                                  unsigned char *data, int len);\nint ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num,\n                                  unsigned char *data, int max_len);\n\nvoid *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it);\n\nASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it,\n                            ASN1_OCTET_STRING **oct);\n\nvoid ASN1_STRING_set_default_mask(unsigned long mask);\nint ASN1_STRING_set_default_mask_asc(const char *p);\nunsigned long ASN1_STRING_get_default_mask(void);\nint ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,\n                       int inform, unsigned long mask);\nint ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,\n                        int inform, unsigned long mask,\n                        long minsize, long maxsize);\n\nASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out,\n                                    const unsigned char *in, int inlen,\n                                    int inform, int nid);\nASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid);\nint ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long);\nvoid ASN1_STRING_TABLE_cleanup(void);\n\n/* ASN1 template functions */\n\n/* Old API compatible functions */\nASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it);\nvoid ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it);\nASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in,\n                          long len, const ASN1_ITEM *it);\nint ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it);\nint ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,\n                       const ASN1_ITEM *it);\n\nvoid ASN1_add_oid_module(void);\nvoid ASN1_add_stable_module(void);\n\nASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf);\nASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf);\nint ASN1_str2mask(const char *str, unsigned long *pmask);\n\n/* ASN1 Print flags */\n\n/* Indicate missing OPTIONAL fields */\n# define ASN1_PCTX_FLAGS_SHOW_ABSENT             0x001\n/* Mark start and end of SEQUENCE */\n# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE           0x002\n/* Mark start and end of SEQUENCE/SET OF */\n# define ASN1_PCTX_FLAGS_SHOW_SSOF               0x004\n/* Show the ASN1 type of primitives */\n# define ASN1_PCTX_FLAGS_SHOW_TYPE               0x008\n/* Don't show ASN1 type of ANY */\n# define ASN1_PCTX_FLAGS_NO_ANY_TYPE             0x010\n/* Don't show ASN1 type of MSTRINGs */\n# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE         0x020\n/* Don't show field names in SEQUENCE */\n# define ASN1_PCTX_FLAGS_NO_FIELD_NAME           0x040\n/* Show structure names of each SEQUENCE field */\n# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME  0x080\n/* Don't show structure name even at top level */\n# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME          0x100\n\nint ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,\n                    const ASN1_ITEM *it, const ASN1_PCTX *pctx);\nASN1_PCTX *ASN1_PCTX_new(void);\nvoid ASN1_PCTX_free(ASN1_PCTX *p);\nunsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags);\nunsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p);\nvoid ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags);\n\nASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx));\nvoid ASN1_SCTX_free(ASN1_SCTX *p);\nconst ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p);\nconst ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p);\nunsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p);\nvoid ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data);\nvoid *ASN1_SCTX_get_app_data(ASN1_SCTX *p);\n\nconst BIO_METHOD *BIO_f_asn1(void);\n\nBIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it);\n\nint i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                        const ASN1_ITEM *it);\nint PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,\n                              const char *hdr, const ASN1_ITEM *it);\nint SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,\n                     int ctype_nid, int econt_nid,\n                     STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it);\nASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it);\nint SMIME_crlf_copy(BIO *in, BIO *out, int flags);\nint SMIME_text(BIO *in, BIO *out);\n\nconst ASN1_ITEM *ASN1_ITEM_lookup(const char *name);\nconst ASN1_ITEM *ASN1_ITEM_get(size_t i);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/asn1_mac.h",
    "content": "/*\n * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#error \"This file is obsolete; please update your software.\"\n"
  },
  {
    "path": "cryptomini/include/openssl/asn1err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ASN1ERR_H\n# define HEADER_ASN1ERR_H\n\n# include <openssl/symhacks.h>\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_ASN1_strings(void);\n\n/*\n * ASN1 function codes.\n */\n# define ASN1_F_A2D_ASN1_OBJECT                           100\n# define ASN1_F_A2I_ASN1_INTEGER                          102\n# define ASN1_F_A2I_ASN1_STRING                           103\n# define ASN1_F_APPEND_EXP                                176\n# define ASN1_F_ASN1_BIO_INIT                             113\n# define ASN1_F_ASN1_BIT_STRING_SET_BIT                   183\n# define ASN1_F_ASN1_CB                                   177\n# define ASN1_F_ASN1_CHECK_TLEN                           104\n# define ASN1_F_ASN1_COLLECT                              106\n# define ASN1_F_ASN1_D2I_EX_PRIMITIVE                     108\n# define ASN1_F_ASN1_D2I_FP                               109\n# define ASN1_F_ASN1_D2I_READ_BIO                         107\n# define ASN1_F_ASN1_DIGEST                               184\n# define ASN1_F_ASN1_DO_ADB                               110\n# define ASN1_F_ASN1_DO_LOCK                              233\n# define ASN1_F_ASN1_DUP                                  111\n# define ASN1_F_ASN1_ENC_SAVE                             115\n# define ASN1_F_ASN1_EX_C2I                               204\n# define ASN1_F_ASN1_FIND_END                             190\n# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ                  216\n# define ASN1_F_ASN1_GENERATE_V3                          178\n# define ASN1_F_ASN1_GET_INT64                            224\n# define ASN1_F_ASN1_GET_OBJECT                           114\n# define ASN1_F_ASN1_GET_UINT64                           225\n# define ASN1_F_ASN1_I2D_BIO                              116\n# define ASN1_F_ASN1_I2D_FP                               117\n# define ASN1_F_ASN1_ITEM_D2I_FP                          206\n# define ASN1_F_ASN1_ITEM_DUP                             191\n# define ASN1_F_ASN1_ITEM_EMBED_D2I                       120\n# define ASN1_F_ASN1_ITEM_EMBED_NEW                       121\n# define ASN1_F_ASN1_ITEM_EX_I2D                          144\n# define ASN1_F_ASN1_ITEM_FLAGS_I2D                       118\n# define ASN1_F_ASN1_ITEM_I2D_BIO                         192\n# define ASN1_F_ASN1_ITEM_I2D_FP                          193\n# define ASN1_F_ASN1_ITEM_PACK                            198\n# define ASN1_F_ASN1_ITEM_SIGN                            195\n# define ASN1_F_ASN1_ITEM_SIGN_CTX                        220\n# define ASN1_F_ASN1_ITEM_UNPACK                          199\n# define ASN1_F_ASN1_ITEM_VERIFY                          197\n# define ASN1_F_ASN1_MBSTRING_NCOPY                       122\n# define ASN1_F_ASN1_OBJECT_NEW                           123\n# define ASN1_F_ASN1_OUTPUT_DATA                          214\n# define ASN1_F_ASN1_PCTX_NEW                             205\n# define ASN1_F_ASN1_PRIMITIVE_NEW                        119\n# define ASN1_F_ASN1_SCTX_NEW                             221\n# define ASN1_F_ASN1_SIGN                                 128\n# define ASN1_F_ASN1_STR2TYPE                             179\n# define ASN1_F_ASN1_STRING_GET_INT64                     227\n# define ASN1_F_ASN1_STRING_GET_UINT64                    230\n# define ASN1_F_ASN1_STRING_SET                           186\n# define ASN1_F_ASN1_STRING_TABLE_ADD                     129\n# define ASN1_F_ASN1_STRING_TO_BN                         228\n# define ASN1_F_ASN1_STRING_TYPE_NEW                      130\n# define ASN1_F_ASN1_TEMPLATE_EX_D2I                      132\n# define ASN1_F_ASN1_TEMPLATE_NEW                         133\n# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I                   131\n# define ASN1_F_ASN1_TIME_ADJ                             217\n# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING             134\n# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING                 135\n# define ASN1_F_ASN1_UTCTIME_ADJ                          218\n# define ASN1_F_ASN1_VERIFY                               137\n# define ASN1_F_B64_READ_ASN1                             209\n# define ASN1_F_B64_WRITE_ASN1                            210\n# define ASN1_F_BIO_NEW_NDEF                              208\n# define ASN1_F_BITSTR_CB                                 180\n# define ASN1_F_BN_TO_ASN1_STRING                         229\n# define ASN1_F_C2I_ASN1_BIT_STRING                       189\n# define ASN1_F_C2I_ASN1_INTEGER                          194\n# define ASN1_F_C2I_ASN1_OBJECT                           196\n# define ASN1_F_C2I_IBUF                                  226\n# define ASN1_F_C2I_UINT64_INT                            101\n# define ASN1_F_COLLECT_DATA                              140\n# define ASN1_F_D2I_ASN1_OBJECT                           147\n# define ASN1_F_D2I_ASN1_UINTEGER                         150\n# define ASN1_F_D2I_AUTOPRIVATEKEY                        207\n# define ASN1_F_D2I_PRIVATEKEY                            154\n# define ASN1_F_D2I_PUBLICKEY                             155\n# define ASN1_F_DO_BUF                                    142\n# define ASN1_F_DO_CREATE                                 124\n# define ASN1_F_DO_DUMP                                   125\n# define ASN1_F_DO_TCREATE                                222\n# define ASN1_F_I2A_ASN1_OBJECT                           126\n# define ASN1_F_I2D_ASN1_BIO_STREAM                       211\n# define ASN1_F_I2D_ASN1_OBJECT                           143\n# define ASN1_F_I2D_DSA_PUBKEY                            161\n# define ASN1_F_I2D_EC_PUBKEY                             181\n# define ASN1_F_I2D_PRIVATEKEY                            163\n# define ASN1_F_I2D_PUBLICKEY                             164\n# define ASN1_F_I2D_RSA_PUBKEY                            165\n# define ASN1_F_LONG_C2I                                  166\n# define ASN1_F_NDEF_PREFIX                               127\n# define ASN1_F_NDEF_SUFFIX                               136\n# define ASN1_F_OID_MODULE_INIT                           174\n# define ASN1_F_PARSE_TAGGING                             182\n# define ASN1_F_PKCS5_PBE2_SET_IV                         167\n# define ASN1_F_PKCS5_PBE2_SET_SCRYPT                     231\n# define ASN1_F_PKCS5_PBE_SET                             202\n# define ASN1_F_PKCS5_PBE_SET0_ALGOR                      215\n# define ASN1_F_PKCS5_PBKDF2_SET                          219\n# define ASN1_F_PKCS5_SCRYPT_SET                          232\n# define ASN1_F_SMIME_READ_ASN1                           212\n# define ASN1_F_SMIME_TEXT                                213\n# define ASN1_F_STABLE_GET                                138\n# define ASN1_F_STBL_MODULE_INIT                          223\n# define ASN1_F_UINT32_C2I                                105\n# define ASN1_F_UINT32_NEW                                139\n# define ASN1_F_UINT64_C2I                                112\n# define ASN1_F_UINT64_NEW                                141\n# define ASN1_F_X509_CRL_ADD0_REVOKED                     169\n# define ASN1_F_X509_INFO_NEW                             170\n# define ASN1_F_X509_NAME_ENCODE                          203\n# define ASN1_F_X509_NAME_EX_D2I                          158\n# define ASN1_F_X509_NAME_EX_NEW                          171\n# define ASN1_F_X509_PKEY_NEW                             173\n\n/*\n * ASN1 reason codes.\n */\n# define ASN1_R_ADDING_OBJECT                             171\n# define ASN1_R_ASN1_PARSE_ERROR                          203\n# define ASN1_R_ASN1_SIG_PARSE_ERROR                      204\n# define ASN1_R_AUX_ERROR                                 100\n# define ASN1_R_BAD_OBJECT_HEADER                         102\n# define ASN1_R_BAD_TEMPLATE                              230\n# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH                 214\n# define ASN1_R_BN_LIB                                    105\n# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH                   106\n# define ASN1_R_BUFFER_TOO_SMALL                          107\n# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER           108\n# define ASN1_R_CONTEXT_NOT_INITIALISED                   217\n# define ASN1_R_DATA_IS_WRONG                             109\n# define ASN1_R_DECODE_ERROR                              110\n# define ASN1_R_DEPTH_EXCEEDED                            174\n# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED         198\n# define ASN1_R_ENCODE_ERROR                              112\n# define ASN1_R_ERROR_GETTING_TIME                        173\n# define ASN1_R_ERROR_LOADING_SECTION                     172\n# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS               114\n# define ASN1_R_EXPECTING_AN_INTEGER                      115\n# define ASN1_R_EXPECTING_AN_OBJECT                       116\n# define ASN1_R_EXPLICIT_LENGTH_MISMATCH                  119\n# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED              120\n# define ASN1_R_FIELD_MISSING                             121\n# define ASN1_R_FIRST_NUM_TOO_LARGE                       122\n# define ASN1_R_HEADER_TOO_LONG                           123\n# define ASN1_R_ILLEGAL_BITSTRING_FORMAT                  175\n# define ASN1_R_ILLEGAL_BOOLEAN                           176\n# define ASN1_R_ILLEGAL_CHARACTERS                        124\n# define ASN1_R_ILLEGAL_FORMAT                            177\n# define ASN1_R_ILLEGAL_HEX                               178\n# define ASN1_R_ILLEGAL_IMPLICIT_TAG                      179\n# define ASN1_R_ILLEGAL_INTEGER                           180\n# define ASN1_R_ILLEGAL_NEGATIVE_VALUE                    226\n# define ASN1_R_ILLEGAL_NESTED_TAGGING                    181\n# define ASN1_R_ILLEGAL_NULL                              125\n# define ASN1_R_ILLEGAL_NULL_VALUE                        182\n# define ASN1_R_ILLEGAL_OBJECT                            183\n# define ASN1_R_ILLEGAL_OPTIONAL_ANY                      126\n# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE          170\n# define ASN1_R_ILLEGAL_PADDING                           221\n# define ASN1_R_ILLEGAL_TAGGED_ANY                        127\n# define ASN1_R_ILLEGAL_TIME_VALUE                        184\n# define ASN1_R_ILLEGAL_ZERO_CONTENT                      222\n# define ASN1_R_INTEGER_NOT_ASCII_FORMAT                  185\n# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG                128\n# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT              220\n# define ASN1_R_INVALID_BMPSTRING_LENGTH                  129\n# define ASN1_R_INVALID_DIGIT                             130\n# define ASN1_R_INVALID_MIME_TYPE                         205\n# define ASN1_R_INVALID_MODIFIER                          186\n# define ASN1_R_INVALID_NUMBER                            187\n# define ASN1_R_INVALID_OBJECT_ENCODING                   216\n# define ASN1_R_INVALID_SCRYPT_PARAMETERS                 227\n# define ASN1_R_INVALID_SEPARATOR                         131\n# define ASN1_R_INVALID_STRING_TABLE_VALUE                218\n# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH            133\n# define ASN1_R_INVALID_UTF8STRING                        134\n# define ASN1_R_INVALID_VALUE                             219\n# define ASN1_R_LIST_ERROR                                188\n# define ASN1_R_MIME_NO_CONTENT_TYPE                      206\n# define ASN1_R_MIME_PARSE_ERROR                          207\n# define ASN1_R_MIME_SIG_PARSE_ERROR                      208\n# define ASN1_R_MISSING_EOC                               137\n# define ASN1_R_MISSING_SECOND_NUMBER                     138\n# define ASN1_R_MISSING_VALUE                             189\n# define ASN1_R_MSTRING_NOT_UNIVERSAL                     139\n# define ASN1_R_MSTRING_WRONG_TAG                         140\n# define ASN1_R_NESTED_ASN1_STRING                        197\n# define ASN1_R_NESTED_TOO_DEEP                           201\n# define ASN1_R_NON_HEX_CHARACTERS                        141\n# define ASN1_R_NOT_ASCII_FORMAT                          190\n# define ASN1_R_NOT_ENOUGH_DATA                           142\n# define ASN1_R_NO_CONTENT_TYPE                           209\n# define ASN1_R_NO_MATCHING_CHOICE_TYPE                   143\n# define ASN1_R_NO_MULTIPART_BODY_FAILURE                 210\n# define ASN1_R_NO_MULTIPART_BOUNDARY                     211\n# define ASN1_R_NO_SIG_CONTENT_TYPE                       212\n# define ASN1_R_NULL_IS_WRONG_LENGTH                      144\n# define ASN1_R_OBJECT_NOT_ASCII_FORMAT                   191\n# define ASN1_R_ODD_NUMBER_OF_CHARS                       145\n# define ASN1_R_SECOND_NUMBER_TOO_LARGE                   147\n# define ASN1_R_SEQUENCE_LENGTH_MISMATCH                  148\n# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED                  149\n# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG              192\n# define ASN1_R_SHORT_LINE                                150\n# define ASN1_R_SIG_INVALID_MIME_TYPE                     213\n# define ASN1_R_STREAMING_NOT_SUPPORTED                   202\n# define ASN1_R_STRING_TOO_LONG                           151\n# define ASN1_R_STRING_TOO_SHORT                          152\n# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154\n# define ASN1_R_TIME_NOT_ASCII_FORMAT                     193\n# define ASN1_R_TOO_LARGE                                 223\n# define ASN1_R_TOO_LONG                                  155\n# define ASN1_R_TOO_SMALL                                 224\n# define ASN1_R_TYPE_NOT_CONSTRUCTED                      156\n# define ASN1_R_TYPE_NOT_PRIMITIVE                        195\n# define ASN1_R_UNEXPECTED_EOC                            159\n# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH           215\n# define ASN1_R_UNKNOWN_FORMAT                            160\n# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM          161\n# define ASN1_R_UNKNOWN_OBJECT_TYPE                       162\n# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE                   163\n# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM               199\n# define ASN1_R_UNKNOWN_TAG                               194\n# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE           164\n# define ASN1_R_UNSUPPORTED_CIPHER                        228\n# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE               167\n# define ASN1_R_UNSUPPORTED_TYPE                          196\n# define ASN1_R_WRONG_INTEGER_TYPE                        225\n# define ASN1_R_WRONG_PUBLIC_KEY_TYPE                     200\n# define ASN1_R_WRONG_TAG                                 168\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/asn1t.h",
    "content": "/*\n * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ASN1T_H\n# define HEADER_ASN1T_H\n\n# include <stddef.h>\n# include <openssl/e_os2.h>\n# include <openssl/asn1.h>\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\n/* ASN1 template defines, structures and functions */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        const ASN1_ITEM itname##_it = {\n\n#  define static_ASN1_ITEM_start(itname) \\\n        static const ASN1_ITEM itname##_it = {\n\n#  define ASN1_ITEM_end(itname)                 \\\n                };\n\n# else\n\n/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */\n#  define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)()))\n\n/* Macros for start and end of ASN1_ITEM definition */\n\n#  define ASN1_ITEM_start(itname) \\\n        const ASN1_ITEM * itname##_it(void) \\\n        { \\\n                static const ASN1_ITEM local_it = {\n\n#  define static_ASN1_ITEM_start(itname) \\\n        static ASN1_ITEM_start(itname)\n\n#  define ASN1_ITEM_end(itname) \\\n                }; \\\n        return &local_it; \\\n        }\n\n# endif\n\n/* Macros to aid ASN1 template writing */\n\n# define ASN1_ITEM_TEMPLATE(tname) \\\n        static const ASN1_TEMPLATE tname##_item_tt\n\n# define ASN1_ITEM_TEMPLATE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_PRIMITIVE,\\\n                -1,\\\n                &tname##_item_tt,\\\n                0,\\\n                NULL,\\\n                0,\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n# define static_ASN1_ITEM_TEMPLATE_END(tname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_PRIMITIVE,\\\n                -1,\\\n                &tname##_item_tt,\\\n                0,\\\n                NULL,\\\n                0,\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n/* This is a ASN1 type which just embeds a template */\n\n/*-\n * This pair helps declare a SEQUENCE. We can do:\n *\n *      ASN1_SEQUENCE(stname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END(stname)\n *\n *      This will produce an ASN1_ITEM called stname_it\n *      for a structure called stname.\n *\n *      If you want the same structure but a different\n *      name then use:\n *\n *      ASN1_SEQUENCE(itname) = {\n *              ... SEQUENCE components ...\n *      } ASN1_SEQUENCE_END_name(stname, itname)\n *\n *      This will create an item called itname_it using\n *      a structure called stname.\n */\n\n# define ASN1_SEQUENCE(tname) \\\n        static const ASN1_TEMPLATE tname##_seq_tt[]\n\n# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)\n\n# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname)\n\n# define ASN1_SEQUENCE_END_name(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n# define static_ASN1_SEQUENCE_END_name(stname, tname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE(tname) \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \\\n        ASN1_SEQUENCE_cb(tname, cb)\n\n# define ASN1_SEQUENCE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_BROKEN_SEQUENCE(tname) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_ref(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_SEQUENCE_enc(tname, enc, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \\\n        ASN1_SEQUENCE(tname)\n\n# define ASN1_NDEF_SEQUENCE_END(tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(tname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n# define static_ASN1_NDEF_SEQUENCE_END(tname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(tname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname)\n# define static_ASN1_BROKEN_SEQUENCE_END(stname) \\\n        static_ASN1_SEQUENCE_END_ref(stname, stname)\n\n# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)\n# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname)\n\n# define ASN1_SEQUENCE_END_ref(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #tname \\\n        ASN1_ITEM_end(tname)\n# define static_ASN1_SEQUENCE_END_ref(stname, tname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_NDEF_SEQUENCE,\\\n                V_ASN1_SEQUENCE,\\\n                tname##_seq_tt,\\\n                sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/*-\n * This pair helps declare a CHOICE type. We can do:\n *\n *      ASN1_CHOICE(chname) = {\n *              ... CHOICE options ...\n *      ASN1_CHOICE_END(chname)\n *\n *      This will produce an ASN1_ITEM called chname_it\n *      for a structure called chname. The structure\n *      definition must look like this:\n *      typedef struct {\n *              int type;\n *              union {\n *                      ASN1_SOMETHING *opt1;\n *                      ASN1_SOMEOTHER *opt2;\n *              } value;\n *      } chname;\n *\n *      the name of the selector must be 'type'.\n *      to use an alternative selector name use the\n *      ASN1_CHOICE_END_selector() version.\n */\n\n# define ASN1_CHOICE(tname) \\\n        static const ASN1_TEMPLATE tname##_ch_tt[]\n\n# define ASN1_CHOICE_cb(tname, cb) \\\n        static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \\\n        ASN1_CHOICE(tname)\n\n# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)\n\n# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname)\n\n# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)\n\n# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type)\n\n# define ASN1_CHOICE_END_selector(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \\\n        ;\\\n        static_ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                NULL,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n# define ASN1_CHOICE_END_cb(stname, tname, selname) \\\n        ;\\\n        ASN1_ITEM_start(tname) \\\n                ASN1_ITYPE_CHOICE,\\\n                offsetof(stname,selname) ,\\\n                tname##_ch_tt,\\\n                sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\\\n                &tname##_aux,\\\n                sizeof(stname),\\\n                #stname \\\n        ASN1_ITEM_end(tname)\n\n/* This helps with the template wrapper form of ASN1_ITEM */\n\n# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \\\n        (flags), (tag), 0,\\\n        #name, ASN1_ITEM_ref(type) }\n\n/* These help with SEQUENCE or CHOICE components */\n\n/* used to declare other types */\n\n# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \\\n        (flags), (tag), offsetof(stname, field),\\\n        #field, ASN1_ITEM_ref(type) }\n\n/* implicit and explicit helper macros */\n\n# define ASN1_IMP_EX(stname, field, type, tag, ex) \\\n         ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type)\n\n# define ASN1_EXP_EX(stname, field, type, tag, ex) \\\n         ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type)\n\n/* Any defined by macros: the field used is in the table itself */\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) }\n# else\n#  define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }\n#  define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }\n# endif\n/* Plain simple type */\n# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)\n/* Embedded simple type */\n# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type)\n\n/* OPTIONAL simple type */\n# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n# define ASN1_OPT_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED, 0, stname, field, type)\n\n/* IMPLICIT tagged simple type */\n# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)\n# define ASN1_IMP_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)\n\n/* IMPLICIT tagged OPTIONAL simple type */\n# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n# define ASN1_IMP_OPT_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)\n\n/* Same as above but EXPLICIT */\n\n# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)\n# define ASN1_EXP_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)\n# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)\n# define ASN1_EXP_OPT_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)\n\n/* SEQUENCE OF type */\n# define ASN1_SEQUENCE_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)\n\n/* OPTIONAL SEQUENCE OF */\n# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Same as above but for SET OF */\n\n# define ASN1_SET_OF(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)\n\n# define ASN1_SET_OF_OPT(stname, field, type) \\\n                ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)\n\n/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */\n\n# define ASN1_IMP_SET_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_EXP_SET_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)\n\n# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)\n\n# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)\n\n/* EXPLICIT using indefinite length constructed form */\n# define ASN1_NDEF_EXP(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)\n\n/* EXPLICIT OPTIONAL using indefinite length constructed form */\n# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \\\n                        ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)\n\n/* Macros for the ASN1_ADB structure */\n\n# define ASN1_ADB(name) \\\n        static const ASN1_ADB_TABLE name##_adbtbl[]\n\n# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n#  define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \\\n        ;\\\n        static const ASN1_ADB name##_adb = {\\\n                flags,\\\n                offsetof(name, field),\\\n                adb_cb,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n        }\n\n# else\n\n#  define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \\\n        ;\\\n        static const ASN1_ITEM *name##_adb(void) \\\n        { \\\n        static const ASN1_ADB internal_adb = \\\n                {\\\n                flags,\\\n                offsetof(name, field),\\\n                adb_cb,\\\n                name##_adbtbl,\\\n                sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\\\n                def,\\\n                none\\\n                }; \\\n                return (const ASN1_ITEM *) &internal_adb; \\\n        } \\\n        void dummy_function(void)\n\n# endif\n\n# define ADB_ENTRY(val, template) {val, template}\n\n# define ASN1_ADB_TEMPLATE(name) \\\n        static const ASN1_TEMPLATE name##_tt\n\n/*\n * This is the ASN1 template structure that defines a wrapper round the\n * actual type. It determines the actual position of the field in the value\n * structure, various flags such as OPTIONAL and the field name.\n */\n\nstruct ASN1_TEMPLATE_st {\n    unsigned long flags;        /* Various flags */\n    long tag;                   /* tag, not used if no tagging */\n    unsigned long offset;       /* Offset of this field in structure */\n    const char *field_name;     /* Field name */\n    ASN1_ITEM_EXP *item;        /* Relevant ASN1_ITEM or ASN1_ADB */\n};\n\n/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */\n\n# define ASN1_TEMPLATE_item(t) (t->item_ptr)\n# define ASN1_TEMPLATE_adb(t) (t->item_ptr)\n\ntypedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;\ntypedef struct ASN1_ADB_st ASN1_ADB;\n\nstruct ASN1_ADB_st {\n    unsigned long flags;        /* Various flags */\n    unsigned long offset;       /* Offset of selector field */\n    int (*adb_cb)(long *psel);  /* Application callback */\n    const ASN1_ADB_TABLE *tbl;  /* Table of possible types */\n    long tblcount;              /* Number of entries in tbl */\n    const ASN1_TEMPLATE *default_tt; /* Type to use if no match */\n    const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */\n};\n\nstruct ASN1_ADB_TABLE_st {\n    long value;                 /* NID for an object or value for an int */\n    const ASN1_TEMPLATE tt;     /* item for this value */\n};\n\n/* template flags */\n\n/* Field is optional */\n# define ASN1_TFLG_OPTIONAL      (0x1)\n\n/* Field is a SET OF */\n# define ASN1_TFLG_SET_OF        (0x1 << 1)\n\n/* Field is a SEQUENCE OF */\n# define ASN1_TFLG_SEQUENCE_OF   (0x2 << 1)\n\n/*\n * Special case: this refers to a SET OF that will be sorted into DER order\n * when encoded *and* the corresponding STACK will be modified to match the\n * new order.\n */\n# define ASN1_TFLG_SET_ORDER     (0x3 << 1)\n\n/* Mask for SET OF or SEQUENCE OF */\n# define ASN1_TFLG_SK_MASK       (0x3 << 1)\n\n/*\n * These flags mean the tag should be taken from the tag field. If EXPLICIT\n * then the underlying type is used for the inner tag.\n */\n\n/* IMPLICIT tagging */\n# define ASN1_TFLG_IMPTAG        (0x1 << 3)\n\n/* EXPLICIT tagging, inner tag from underlying type */\n# define ASN1_TFLG_EXPTAG        (0x2 << 3)\n\n# define ASN1_TFLG_TAG_MASK      (0x3 << 3)\n\n/* context specific IMPLICIT */\n# define ASN1_TFLG_IMPLICIT      (ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT)\n\n/* context specific EXPLICIT */\n# define ASN1_TFLG_EXPLICIT      (ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT)\n\n/*\n * If tagging is in force these determine the type of tag to use. Otherwise\n * the tag is determined by the underlying type. These values reflect the\n * actual octet format.\n */\n\n/* Universal tag */\n# define ASN1_TFLG_UNIVERSAL     (0x0<<6)\n/* Application tag */\n# define ASN1_TFLG_APPLICATION   (0x1<<6)\n/* Context specific tag */\n# define ASN1_TFLG_CONTEXT       (0x2<<6)\n/* Private tag */\n# define ASN1_TFLG_PRIVATE       (0x3<<6)\n\n# define ASN1_TFLG_TAG_CLASS     (0x3<<6)\n\n/*\n * These are for ANY DEFINED BY type. In this case the 'item' field points to\n * an ASN1_ADB structure which contains a table of values to decode the\n * relevant type\n */\n\n# define ASN1_TFLG_ADB_MASK      (0x3<<8)\n\n# define ASN1_TFLG_ADB_OID       (0x1<<8)\n\n# define ASN1_TFLG_ADB_INT       (0x1<<9)\n\n/*\n * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes\n * indefinite length constructed encoding to be used if required.\n */\n\n# define ASN1_TFLG_NDEF          (0x1<<11)\n\n/* Field is embedded and not a pointer */\n# define ASN1_TFLG_EMBED         (0x1 << 12)\n\n/* This is the actual ASN1 item itself */\n\nstruct ASN1_ITEM_st {\n    char itype;                 /* The item type, primitive, SEQUENCE, CHOICE\n                                 * or extern */\n    long utype;                 /* underlying type */\n    const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains\n                                     * the contents */\n    long tcount;                /* Number of templates if SEQUENCE or CHOICE */\n    const void *funcs;          /* functions that handle this type */\n    long size;                  /* Structure size (usually) */\n    const char *sname;          /* Structure name */\n};\n\n/*-\n * These are values for the itype field and\n * determine how the type is interpreted.\n *\n * For PRIMITIVE types the underlying type\n * determines the behaviour if items is NULL.\n *\n * Otherwise templates must contain a single\n * template and the type is treated in the\n * same way as the type specified in the template.\n *\n * For SEQUENCE types the templates field points\n * to the members, the size field is the\n * structure size.\n *\n * For CHOICE types the templates field points\n * to each possible member (typically a union)\n * and the 'size' field is the offset of the\n * selector.\n *\n * The 'funcs' field is used for application\n * specific functions.\n *\n * The EXTERN type uses a new style d2i/i2d.\n * The new style should be used where possible\n * because it avoids things like the d2i IMPLICIT\n * hack.\n *\n * MSTRING is a multiple string type, it is used\n * for a CHOICE of character strings where the\n * actual strings all occupy an ASN1_STRING\n * structure. In this case the 'utype' field\n * has a special meaning, it is used as a mask\n * of acceptable types using the B_ASN1 constants.\n *\n * NDEF_SEQUENCE is the same as SEQUENCE except\n * that it will use indefinite length constructed\n * encoding if requested.\n *\n */\n\n# define ASN1_ITYPE_PRIMITIVE            0x0\n\n# define ASN1_ITYPE_SEQUENCE             0x1\n\n# define ASN1_ITYPE_CHOICE               0x2\n\n# define ASN1_ITYPE_EXTERN               0x4\n\n# define ASN1_ITYPE_MSTRING              0x5\n\n# define ASN1_ITYPE_NDEF_SEQUENCE        0x6\n\n/*\n * Cache for ASN1 tag and length, so we don't keep re-reading it for things\n * like CHOICE\n */\n\nstruct ASN1_TLC_st {\n    char valid;                 /* Values below are valid */\n    int ret;                    /* return value */\n    long plen;                  /* length */\n    int ptag;                   /* class value */\n    int pclass;                 /* class value */\n    int hdrlen;                 /* header length */\n};\n\n/* Typedefs for ASN1 function pointers */\ntypedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                        const ASN1_ITEM *it, int tag, int aclass, char opt,\n                        ASN1_TLC *ctx);\n\ntypedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                        const ASN1_ITEM *it, int tag, int aclass);\ntypedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\ntypedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\ntypedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval,\n                               int indent, const char *fname,\n                               const ASN1_PCTX *pctx);\n\ntypedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont,\n                               int *putype, const ASN1_ITEM *it);\ntypedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,\n                               int len, int utype, char *free_cont,\n                               const ASN1_ITEM *it);\ntypedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval,\n                                 const ASN1_ITEM *it, int indent,\n                                 const ASN1_PCTX *pctx);\n\ntypedef struct ASN1_EXTERN_FUNCS_st {\n    void *app_data;\n    ASN1_ex_new_func *asn1_ex_new;\n    ASN1_ex_free_func *asn1_ex_free;\n    ASN1_ex_free_func *asn1_ex_clear;\n    ASN1_ex_d2i *asn1_ex_d2i;\n    ASN1_ex_i2d *asn1_ex_i2d;\n    ASN1_ex_print_func *asn1_ex_print;\n} ASN1_EXTERN_FUNCS;\n\ntypedef struct ASN1_PRIMITIVE_FUNCS_st {\n    void *app_data;\n    unsigned long flags;\n    ASN1_ex_new_func *prim_new;\n    ASN1_ex_free_func *prim_free;\n    ASN1_ex_free_func *prim_clear;\n    ASN1_primitive_c2i *prim_c2i;\n    ASN1_primitive_i2c *prim_i2c;\n    ASN1_primitive_print *prim_print;\n} ASN1_PRIMITIVE_FUNCS;\n\n/*\n * This is the ASN1_AUX structure: it handles various miscellaneous\n * requirements. For example the use of reference counts and an informational\n * callback. The \"informational callback\" is called at various points during\n * the ASN1 encoding and decoding. It can be used to provide minor\n * customisation of the structures used. This is most useful where the\n * supplied routines *almost* do the right thing but need some extra help at\n * a few points. If the callback returns zero then it is assumed a fatal\n * error has occurred and the main operation should be abandoned. If major\n * changes in the default behaviour are required then an external type is\n * more appropriate.\n */\n\ntypedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,\n                        void *exarg);\n\ntypedef struct ASN1_AUX_st {\n    void *app_data;\n    int flags;\n    int ref_offset;             /* Offset of reference value */\n    int ref_lock;               /* Lock type to use */\n    ASN1_aux_cb *asn1_cb;\n    int enc_offset;             /* Offset of ASN1_ENCODING structure */\n} ASN1_AUX;\n\n/* For print related callbacks exarg points to this structure */\ntypedef struct ASN1_PRINT_ARG_st {\n    BIO *out;\n    int indent;\n    const ASN1_PCTX *pctx;\n} ASN1_PRINT_ARG;\n\n/* For streaming related callbacks exarg points to this structure */\ntypedef struct ASN1_STREAM_ARG_st {\n    /* BIO to stream through */\n    BIO *out;\n    /* BIO with filters appended */\n    BIO *ndef_bio;\n    /* Streaming I/O boundary */\n    unsigned char **boundary;\n} ASN1_STREAM_ARG;\n\n/* Flags in ASN1_AUX */\n\n/* Use a reference count */\n# define ASN1_AFLG_REFCOUNT      1\n/* Save the encoding of structure (useful for signatures) */\n# define ASN1_AFLG_ENCODING      2\n/* The Sequence length is invalid */\n# define ASN1_AFLG_BROKEN        4\n\n/* operation values for asn1_cb */\n\n# define ASN1_OP_NEW_PRE         0\n# define ASN1_OP_NEW_POST        1\n# define ASN1_OP_FREE_PRE        2\n# define ASN1_OP_FREE_POST       3\n# define ASN1_OP_D2I_PRE         4\n# define ASN1_OP_D2I_POST        5\n# define ASN1_OP_I2D_PRE         6\n# define ASN1_OP_I2D_POST        7\n# define ASN1_OP_PRINT_PRE       8\n# define ASN1_OP_PRINT_POST      9\n# define ASN1_OP_STREAM_PRE      10\n# define ASN1_OP_STREAM_POST     11\n# define ASN1_OP_DETACHED_PRE    12\n# define ASN1_OP_DETACHED_POST   13\n\n/* Macro to implement a primitive type */\n# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)\n# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \\\n                                ASN1_ITEM_end(itname)\n\n/* Macro to implement a multi string type */\n# define IMPLEMENT_ASN1_MSTRING(itname, mask) \\\n                                ASN1_ITEM_start(itname) \\\n                                        ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \\\n                                ASN1_ITEM_end(itname)\n\n# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \\\n        ASN1_ITEM_start(sname) \\\n                ASN1_ITYPE_EXTERN, \\\n                tag, \\\n                NULL, \\\n                0, \\\n                &fptrs, \\\n                0, \\\n                #sname \\\n        ASN1_ITEM_end(sname)\n\n/* Macro to implement standard functions in terms of ASN1_ITEM structures */\n\n# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \\\n                        IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)\n\n# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \\\n                IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \\\n        pre stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        pre void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *fname##_new(void) \\\n        { \\\n                return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \\\n        } \\\n        void fname##_free(stname *a) \\\n        { \\\n                ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \\\n        int i2d_##stname##_NDEF(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\\\n        }\n\n# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \\\n        static stname *d2i_##stname(stname **a, \\\n                                   const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \\\n                                               ASN1_ITEM_rptr(stname)); \\\n        } \\\n        static int i2d_##stname(stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, \\\n                                     ASN1_ITEM_rptr(stname)); \\\n        }\n\n/*\n * This includes evil casts to remove const: they will go away when full ASN1\n * constification is done.\n */\n# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        stname *d2i_##fname(stname **a, const unsigned char **in, long len) \\\n        { \\\n                return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\\\n        } \\\n        int i2d_##fname(const stname *a, unsigned char **out) \\\n        { \\\n                return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\\\n        }\n\n# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \\\n        stname * stname##_dup(stname *x) \\\n        { \\\n        return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \\\n        }\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \\\n        IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)\n\n# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \\\n        int fname##_print_ctx(BIO *out, stname *x, int indent, \\\n                                                const ASN1_PCTX *pctx) \\\n        { \\\n                return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \\\n                        ASN1_ITEM_rptr(itname), pctx); \\\n        }\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \\\n                IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name)\n\n# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \\\n        IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)\n\n/* external definitions for primitive types */\n\nDECLARE_ASN1_ITEM(ASN1_BOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_TBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_FBOOLEAN)\nDECLARE_ASN1_ITEM(ASN1_SEQUENCE)\nDECLARE_ASN1_ITEM(CBIGNUM)\nDECLARE_ASN1_ITEM(BIGNUM)\nDECLARE_ASN1_ITEM(INT32)\nDECLARE_ASN1_ITEM(ZINT32)\nDECLARE_ASN1_ITEM(UINT32)\nDECLARE_ASN1_ITEM(ZUINT32)\nDECLARE_ASN1_ITEM(INT64)\nDECLARE_ASN1_ITEM(ZINT64)\nDECLARE_ASN1_ITEM(UINT64)\nDECLARE_ASN1_ITEM(ZUINT64)\n\n# if OPENSSL_API_COMPAT < 0x10200000L\n/*\n * LONG and ZLONG are strongly discouraged for use as stored data, as the\n * underlying C type (long) differs in size depending on the architecture.\n * They are designed with 32-bit longs in mind.\n */\nDECLARE_ASN1_ITEM(LONG)\nDECLARE_ASN1_ITEM(ZLONG)\n# endif\n\nDEFINE_STACK_OF(ASN1_VALUE)\n\n/* Functions used internally by the ASN1 code */\n\nint ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);\nvoid ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);\n\nint ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                     const ASN1_ITEM *it, int tag, int aclass, char opt,\n                     ASN1_TLC *ctx);\n\nint ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,\n                     const ASN1_ITEM *it, int tag, int aclass);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/async.h",
    "content": "/*\n * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <stdlib.h>\n\n#ifndef HEADER_ASYNC_H\n# define HEADER_ASYNC_H\n\n#if defined(_WIN32)\n# if defined(BASETYPES) || defined(_WINDEF_H)\n/* application has to include <windows.h> to use this */\n#define OSSL_ASYNC_FD       HANDLE\n#define OSSL_BAD_ASYNC_FD   INVALID_HANDLE_VALUE\n# endif\n#else\n#define OSSL_ASYNC_FD       int\n#define OSSL_BAD_ASYNC_FD   -1\n#endif\n# include <openssl/asyncerr.h>\n\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef struct async_job_st ASYNC_JOB;\ntypedef struct async_wait_ctx_st ASYNC_WAIT_CTX;\n\n#define ASYNC_ERR      0\n#define ASYNC_NO_JOBS  1\n#define ASYNC_PAUSE    2\n#define ASYNC_FINISH   3\n\nint ASYNC_init_thread(size_t max_size, size_t init_size);\nvoid ASYNC_cleanup_thread(void);\n\n#ifdef OSSL_ASYNC_FD\nASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void);\nvoid ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx);\nint ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key,\n                               OSSL_ASYNC_FD fd,\n                               void *custom_data,\n                               void (*cleanup)(ASYNC_WAIT_CTX *, const void *,\n                                               OSSL_ASYNC_FD, void *));\nint ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key,\n                        OSSL_ASYNC_FD *fd, void **custom_data);\nint ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd,\n                               size_t *numfds);\nint ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd,\n                                   size_t *numaddfds, OSSL_ASYNC_FD *delfd,\n                                   size_t *numdelfds);\nint ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key);\n#endif\n\nint ASYNC_is_capable(void);\n\nint ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret,\n                    int (*func)(void *), void *args, size_t size);\nint ASYNC_pause_job(void);\n\nASYNC_JOB *ASYNC_get_current_job(void);\nASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job);\nvoid ASYNC_block_pause(void);\nvoid ASYNC_unblock_pause(void);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/asyncerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ASYNCERR_H\n# define HEADER_ASYNCERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_ASYNC_strings(void);\n\n/*\n * ASYNC function codes.\n */\n# define ASYNC_F_ASYNC_CTX_NEW                            100\n# define ASYNC_F_ASYNC_INIT_THREAD                        101\n# define ASYNC_F_ASYNC_JOB_NEW                            102\n# define ASYNC_F_ASYNC_PAUSE_JOB                          103\n# define ASYNC_F_ASYNC_START_FUNC                         104\n# define ASYNC_F_ASYNC_START_JOB                          105\n# define ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD               106\n\n/*\n * ASYNC reason codes.\n */\n# define ASYNC_R_FAILED_TO_SET_POOL                       101\n# define ASYNC_R_FAILED_TO_SWAP_CONTEXT                   102\n# define ASYNC_R_INIT_FAILED                              105\n# define ASYNC_R_INVALID_POOL_SIZE                        103\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/bio.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BIO_H\n# define HEADER_BIO_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_STDIO\n#  include <stdio.h>\n# endif\n# include <stdarg.h>\n\n# include <openssl/crypto.h>\n# include <openssl/bioerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* There are the classes of BIOs */\n# define BIO_TYPE_DESCRIPTOR     0x0100 /* socket, fd, connect or accept */\n# define BIO_TYPE_FILTER         0x0200\n# define BIO_TYPE_SOURCE_SINK    0x0400\n\n/* These are the 'types' of BIOs */\n# define BIO_TYPE_NONE             0\n# define BIO_TYPE_MEM            ( 1|BIO_TYPE_SOURCE_SINK)\n# define BIO_TYPE_FILE           ( 2|BIO_TYPE_SOURCE_SINK)\n\n# define BIO_TYPE_FD             ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# define BIO_TYPE_SOCKET         ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# define BIO_TYPE_NULL           ( 6|BIO_TYPE_SOURCE_SINK)\n# define BIO_TYPE_SSL            ( 7|BIO_TYPE_FILTER)\n# define BIO_TYPE_MD             ( 8|BIO_TYPE_FILTER)\n# define BIO_TYPE_BUFFER         ( 9|BIO_TYPE_FILTER)\n# define BIO_TYPE_CIPHER         (10|BIO_TYPE_FILTER)\n# define BIO_TYPE_BASE64         (11|BIO_TYPE_FILTER)\n# define BIO_TYPE_CONNECT        (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# define BIO_TYPE_ACCEPT         (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n\n# define BIO_TYPE_NBIO_TEST      (16|BIO_TYPE_FILTER)/* server proxy BIO */\n# define BIO_TYPE_NULL_FILTER    (17|BIO_TYPE_FILTER)\n# define BIO_TYPE_BIO            (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */\n# define BIO_TYPE_LINEBUFFER     (20|BIO_TYPE_FILTER)\n# define BIO_TYPE_DGRAM          (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# define BIO_TYPE_ASN1           (22|BIO_TYPE_FILTER)\n# define BIO_TYPE_COMP           (23|BIO_TYPE_FILTER)\n# ifndef OPENSSL_NO_SCTP\n#  define BIO_TYPE_DGRAM_SCTP    (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR)\n# endif\n\n#define BIO_TYPE_START           128\n\n/*\n * BIO_FILENAME_READ|BIO_CLOSE to open or close on free.\n * BIO_set_fp(in,stdin,BIO_NOCLOSE);\n */\n# define BIO_NOCLOSE             0x00\n# define BIO_CLOSE               0x01\n\n/*\n * These are used in the following macros and are passed to BIO_ctrl()\n */\n# define BIO_CTRL_RESET          1/* opt - rewind/zero etc */\n# define BIO_CTRL_EOF            2/* opt - are we at the eof */\n# define BIO_CTRL_INFO           3/* opt - extra tit-bits */\n# define BIO_CTRL_SET            4/* man - set the 'IO' type */\n# define BIO_CTRL_GET            5/* man - get the 'IO' type */\n# define BIO_CTRL_PUSH           6/* opt - internal, used to signify change */\n# define BIO_CTRL_POP            7/* opt - internal, used to signify change */\n# define BIO_CTRL_GET_CLOSE      8/* man - set the 'close' on free */\n# define BIO_CTRL_SET_CLOSE      9/* man - set the 'close' on free */\n# define BIO_CTRL_PENDING        10/* opt - is their more data buffered */\n# define BIO_CTRL_FLUSH          11/* opt - 'flush' buffered output */\n# define BIO_CTRL_DUP            12/* man - extra stuff for 'duped' BIO */\n# define BIO_CTRL_WPENDING       13/* opt - number of bytes still to write */\n# define BIO_CTRL_SET_CALLBACK   14/* opt - set callback function */\n# define BIO_CTRL_GET_CALLBACK   15/* opt - set callback function */\n\n# define BIO_CTRL_PEEK           29/* BIO_f_buffer special */\n# define BIO_CTRL_SET_FILENAME   30/* BIO_s_file special */\n\n/* dgram BIO stuff */\n# define BIO_CTRL_DGRAM_CONNECT       31/* BIO dgram special */\n# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected\n                                         * socket to be passed in */\n# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */\n# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */\n\n# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */\n# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */\n\n/* #ifdef IP_MTU_DISCOVER */\n# define BIO_CTRL_DGRAM_MTU_DISCOVER       39/* set DF bit on egress packets */\n/* #endif */\n\n# define BIO_CTRL_DGRAM_QUERY_MTU          40/* as kernel for current MTU */\n# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU   47\n# define BIO_CTRL_DGRAM_GET_MTU            41/* get cached value for MTU */\n# define BIO_CTRL_DGRAM_SET_MTU            42/* set cached value for MTU.\n                                              * want to use this if asking\n                                              * the kernel fails */\n\n# define BIO_CTRL_DGRAM_MTU_EXCEEDED       43/* check whether the MTU was\n                                              * exceed in the previous write\n                                              * operation */\n\n# define BIO_CTRL_DGRAM_GET_PEER           46\n# define BIO_CTRL_DGRAM_SET_PEER           44/* Destination for the data */\n\n# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT   45/* Next DTLS handshake timeout\n                                              * to adjust socket timeouts */\n# define BIO_CTRL_DGRAM_SET_DONT_FRAG      48\n\n# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD   49\n\n/* Deliberately outside of OPENSSL_NO_SCTP - used in bss_dgram.c */\n#  define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE    50\n# ifndef OPENSSL_NO_SCTP\n/* SCTP stuff */\n#  define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY                51\n#  define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY               52\n#  define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD               53\n#  define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO         60\n#  define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO         61\n#  define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO         62\n#  define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO         63\n#  define BIO_CTRL_DGRAM_SCTP_GET_PRINFO                  64\n#  define BIO_CTRL_DGRAM_SCTP_SET_PRINFO                  65\n#  define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN               70\n# endif\n\n# define BIO_CTRL_DGRAM_SET_PEEK_MODE      71\n\n/* modifiers */\n# define BIO_FP_READ             0x02\n# define BIO_FP_WRITE            0x04\n# define BIO_FP_APPEND           0x08\n# define BIO_FP_TEXT             0x10\n\n# define BIO_FLAGS_READ          0x01\n# define BIO_FLAGS_WRITE         0x02\n# define BIO_FLAGS_IO_SPECIAL    0x04\n# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)\n# define BIO_FLAGS_SHOULD_RETRY  0x08\n# ifndef BIO_FLAGS_UPLINK\n/*\n * \"UPLINK\" flag denotes file descriptors provided by application. It\n * defaults to 0, as most platforms don't require UPLINK interface.\n */\n#  define BIO_FLAGS_UPLINK        0\n# endif\n\n# define BIO_FLAGS_BASE64_NO_NL  0x100\n\n/*\n * This is used with memory BIOs:\n * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way;\n * BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset.\n */\n# define BIO_FLAGS_MEM_RDONLY    0x200\n# define BIO_FLAGS_NONCLEAR_RST  0x400\n# define BIO_FLAGS_IN_EOF        0x800\n\ntypedef union bio_addr_st BIO_ADDR;\ntypedef struct bio_addrinfo_st BIO_ADDRINFO;\n\nint BIO_get_new_index(void);\nvoid BIO_set_flags(BIO *b, int flags);\nint BIO_test_flags(const BIO *b, int flags);\nvoid BIO_clear_flags(BIO *b, int flags);\n\n# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0))\n# define BIO_set_retry_special(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_read(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_set_retry_write(b) \\\n                BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY))\n\n/* These are normally used internally in BIOs */\n# define BIO_clear_retry_flags(b) \\\n                BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n# define BIO_get_retry_flags(b) \\\n                BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY))\n\n/* These should be used by the application to tell why we should retry */\n# define BIO_should_read(a)              BIO_test_flags(a, BIO_FLAGS_READ)\n# define BIO_should_write(a)             BIO_test_flags(a, BIO_FLAGS_WRITE)\n# define BIO_should_io_special(a)        BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL)\n# define BIO_retry_type(a)               BIO_test_flags(a, BIO_FLAGS_RWS)\n# define BIO_should_retry(a)             BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY)\n\n/*\n * The next three are used in conjunction with the BIO_should_io_special()\n * condition.  After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int\n * *reason); will walk the BIO stack and return the 'reason' for the special\n * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return\n * the code.\n */\n/*\n * Returned from the SSL bio when the certificate retrieval code had an error\n */\n# define BIO_RR_SSL_X509_LOOKUP          0x01\n/* Returned from the connect BIO when a connect would have blocked */\n# define BIO_RR_CONNECT                  0x02\n/* Returned from the accept BIO when an accept would have blocked */\n# define BIO_RR_ACCEPT                   0x03\n\n/* These are passed by the BIO callback */\n# define BIO_CB_FREE     0x01\n# define BIO_CB_READ     0x02\n# define BIO_CB_WRITE    0x03\n# define BIO_CB_PUTS     0x04\n# define BIO_CB_GETS     0x05\n# define BIO_CB_CTRL     0x06\n\n/*\n * The callback is called before and after the underling operation, The\n * BIO_CB_RETURN flag indicates if it is after the call\n */\n# define BIO_CB_RETURN   0x80\n# define BIO_CB_return(a) ((a)|BIO_CB_RETURN)\n# define BIO_cb_pre(a)   (!((a)&BIO_CB_RETURN))\n# define BIO_cb_post(a)  ((a)&BIO_CB_RETURN)\n\ntypedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,\n                                long argl, long ret);\ntypedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp,\n                                   size_t len, int argi,\n                                   long argl, int ret, size_t *processed);\nBIO_callback_fn BIO_get_callback(const BIO *b);\nvoid BIO_set_callback(BIO *b, BIO_callback_fn callback);\n\nBIO_callback_fn_ex BIO_get_callback_ex(const BIO *b);\nvoid BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback);\n\nchar *BIO_get_callback_arg(const BIO *b);\nvoid BIO_set_callback_arg(BIO *b, char *arg);\n\ntypedef struct bio_method_st BIO_METHOD;\n\nconst char *BIO_method_name(const BIO *b);\nint BIO_method_type(const BIO *b);\n\ntypedef int BIO_info_cb(BIO *, int, int);\ntypedef BIO_info_cb bio_info_cb;  /* backward compatibility */\n\nDEFINE_STACK_OF(BIO)\n\n/* Prefix and suffix callback in ASN1 BIO */\ntypedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen,\n                          void *parg);\n\n# ifndef OPENSSL_NO_SCTP\n/* SCTP parameter structs */\nstruct bio_dgram_sctp_sndinfo {\n    uint16_t snd_sid;\n    uint16_t snd_flags;\n    uint32_t snd_ppid;\n    uint32_t snd_context;\n};\n\nstruct bio_dgram_sctp_rcvinfo {\n    uint16_t rcv_sid;\n    uint16_t rcv_ssn;\n    uint16_t rcv_flags;\n    uint32_t rcv_ppid;\n    uint32_t rcv_tsn;\n    uint32_t rcv_cumtsn;\n    uint32_t rcv_context;\n};\n\nstruct bio_dgram_sctp_prinfo {\n    uint16_t pr_policy;\n    uint32_t pr_value;\n};\n# endif\n\n/*\n * #define BIO_CONN_get_param_hostname BIO_ctrl\n */\n\n# define BIO_C_SET_CONNECT                       100\n# define BIO_C_DO_STATE_MACHINE                  101\n# define BIO_C_SET_NBIO                          102\n/* # define BIO_C_SET_PROXY_PARAM                   103 */\n# define BIO_C_SET_FD                            104\n# define BIO_C_GET_FD                            105\n# define BIO_C_SET_FILE_PTR                      106\n# define BIO_C_GET_FILE_PTR                      107\n# define BIO_C_SET_FILENAME                      108\n# define BIO_C_SET_SSL                           109\n# define BIO_C_GET_SSL                           110\n# define BIO_C_SET_MD                            111\n# define BIO_C_GET_MD                            112\n# define BIO_C_GET_CIPHER_STATUS                 113\n# define BIO_C_SET_BUF_MEM                       114\n# define BIO_C_GET_BUF_MEM_PTR                   115\n# define BIO_C_GET_BUFF_NUM_LINES                116\n# define BIO_C_SET_BUFF_SIZE                     117\n# define BIO_C_SET_ACCEPT                        118\n# define BIO_C_SSL_MODE                          119\n# define BIO_C_GET_MD_CTX                        120\n/* # define BIO_C_GET_PROXY_PARAM                   121 */\n# define BIO_C_SET_BUFF_READ_DATA                122/* data to read first */\n# define BIO_C_GET_CONNECT                       123\n# define BIO_C_GET_ACCEPT                        124\n# define BIO_C_SET_SSL_RENEGOTIATE_BYTES         125\n# define BIO_C_GET_SSL_NUM_RENEGOTIATES          126\n# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT       127\n# define BIO_C_FILE_SEEK                         128\n# define BIO_C_GET_CIPHER_CTX                    129\n# define BIO_C_SET_BUF_MEM_EOF_RETURN            130/* return end of input\n                                                     * value */\n# define BIO_C_SET_BIND_MODE                     131\n# define BIO_C_GET_BIND_MODE                     132\n# define BIO_C_FILE_TELL                         133\n# define BIO_C_GET_SOCKS                         134\n# define BIO_C_SET_SOCKS                         135\n\n# define BIO_C_SET_WRITE_BUF_SIZE                136/* for BIO_s_bio */\n# define BIO_C_GET_WRITE_BUF_SIZE                137\n# define BIO_C_MAKE_BIO_PAIR                     138\n# define BIO_C_DESTROY_BIO_PAIR                  139\n# define BIO_C_GET_WRITE_GUARANTEE               140\n# define BIO_C_GET_READ_REQUEST                  141\n# define BIO_C_SHUTDOWN_WR                       142\n# define BIO_C_NREAD0                            143\n# define BIO_C_NREAD                             144\n# define BIO_C_NWRITE0                           145\n# define BIO_C_NWRITE                            146\n# define BIO_C_RESET_READ_REQUEST                147\n# define BIO_C_SET_MD_CTX                        148\n\n# define BIO_C_SET_PREFIX                        149\n# define BIO_C_GET_PREFIX                        150\n# define BIO_C_SET_SUFFIX                        151\n# define BIO_C_GET_SUFFIX                        152\n\n# define BIO_C_SET_EX_ARG                        153\n# define BIO_C_GET_EX_ARG                        154\n\n# define BIO_C_SET_CONNECT_MODE                  155\n\n# define BIO_set_app_data(s,arg)         BIO_set_ex_data(s,0,arg)\n# define BIO_get_app_data(s)             BIO_get_ex_data(s,0)\n\n# define BIO_set_nbio(b,n)             BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)\n\n# ifndef OPENSSL_NO_SOCK\n/* IP families we support, for BIO_s_connect() and BIO_s_accept() */\n/* Note: the underlying operating system may not support some of them */\n#  define BIO_FAMILY_IPV4                         4\n#  define BIO_FAMILY_IPV6                         6\n#  define BIO_FAMILY_IPANY                        256\n\n/* BIO_s_connect() */\n#  define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0, \\\n                                                 (char *)(name))\n#  define BIO_set_conn_port(b,port)     BIO_ctrl(b,BIO_C_SET_CONNECT,1, \\\n                                                 (char *)(port))\n#  define BIO_set_conn_address(b,addr)  BIO_ctrl(b,BIO_C_SET_CONNECT,2, \\\n                                                 (char *)(addr))\n#  define BIO_set_conn_ip_family(b,f)   BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f)\n#  define BIO_get_conn_hostname(b)      ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0))\n#  define BIO_get_conn_port(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1))\n#  define BIO_get_conn_address(b)       ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2))\n#  define BIO_get_conn_ip_family(b)     BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)\n#  define BIO_set_conn_mode(b,n)        BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL)\n\n/* BIO_s_accept() */\n#  define BIO_set_accept_name(b,name)   BIO_ctrl(b,BIO_C_SET_ACCEPT,0, \\\n                                                 (char *)(name))\n#  define BIO_set_accept_port(b,port)   BIO_ctrl(b,BIO_C_SET_ACCEPT,1, \\\n                                                 (char *)(port))\n#  define BIO_get_accept_name(b)        ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0))\n#  define BIO_get_accept_port(b)        ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1))\n#  define BIO_get_peer_name(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2))\n#  define BIO_get_peer_port(b)          ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3))\n/* #define BIO_set_nbio(b,n)    BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */\n#  define BIO_set_nbio_accept(b,n)      BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)\"a\":NULL)\n#  define BIO_set_accept_bios(b,bio)    BIO_ctrl(b,BIO_C_SET_ACCEPT,3, \\\n                                                 (char *)(bio))\n#  define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f)\n#  define BIO_get_accept_ip_family(b)   BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL)\n\n/* Aliases kept for backward compatibility */\n#  define BIO_BIND_NORMAL                 0\n#  define BIO_BIND_REUSEADDR              BIO_SOCK_REUSEADDR\n#  define BIO_BIND_REUSEADDR_IF_UNUSED    BIO_SOCK_REUSEADDR\n#  define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)\n#  define BIO_get_bind_mode(b)    BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)\n\n/* BIO_s_accept() and BIO_s_connect() */\n#  define BIO_do_connect(b)       BIO_do_handshake(b)\n#  define BIO_do_accept(b)        BIO_do_handshake(b)\n# endif /* OPENSSL_NO_SOCK */\n\n# define BIO_do_handshake(b)     BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)\n\n/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */\n# define BIO_set_fd(b,fd,c)      BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)\n# define BIO_get_fd(b,c)         BIO_ctrl(b,BIO_C_GET_FD,0,(char *)(c))\n\n/* BIO_s_file() */\n# define BIO_set_fp(b,fp,c)      BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)(fp))\n# define BIO_get_fp(b,fpp)       BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)(fpp))\n\n/* BIO_s_fd() and BIO_s_file() */\n# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)\n# define BIO_tell(b)     (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)\n\n/*\n * name is cast to lose const, but might be better to route through a\n * function so we can do it safely\n */\n# ifdef CONST_STRICT\n/*\n * If you are wondering why this isn't defined, its because CONST_STRICT is\n * purely a compile-time kludge to allow const to be checked.\n */\nint BIO_read_filename(BIO *b, const char *name);\n# else\n#  define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ,(char *)(name))\n# endif\n# define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_WRITE,name)\n# define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_APPEND,name)\n# define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \\\n                BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name)\n\n/*\n * WARNING WARNING, this ups the reference count on the read bio of the SSL\n * structure.  This is because the ssl read BIO is now pointed to by the\n * next_bio field in the bio.  So when you free the BIO, make sure you are\n * doing a BIO_free_all() to catch the underlying BIO.\n */\n# define BIO_set_ssl(b,ssl,c)    BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)(ssl))\n# define BIO_get_ssl(b,sslp)     BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)(sslp))\n# define BIO_set_ssl_mode(b,client)      BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL)\n# define BIO_set_ssl_renegotiate_bytes(b,num) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL)\n# define BIO_get_num_renegotiates(b) \\\n        BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL)\n# define BIO_set_ssl_renegotiate_timeout(b,seconds) \\\n        BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL)\n\n/* defined in evp.h */\n/* #define BIO_set_md(b,md)     BIO_ctrl(b,BIO_C_SET_MD,1,(char *)(md)) */\n\n# define BIO_get_mem_data(b,pp)  BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)(pp))\n# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)(bm))\n# define BIO_get_mem_ptr(b,pp)   BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0, \\\n                                          (char *)(pp))\n# define BIO_set_mem_eof_return(b,v) \\\n                                BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)\n\n/* For the BIO_f_buffer() type */\n# define BIO_get_buffer_num_lines(b)     BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)\n# define BIO_set_buffer_size(b,size)     BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL)\n# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0)\n# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1)\n# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf)\n\n/* Don't use the next one unless you know what you are doing :-) */\n# define BIO_dup_state(b,ret)    BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret))\n\n# define BIO_reset(b)            (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL)\n# define BIO_eof(b)              (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL)\n# define BIO_set_close(b,c)      (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL)\n# define BIO_get_close(b)        (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL)\n# define BIO_pending(b)          (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL)\n# define BIO_wpending(b)         (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL)\n/* ...pending macros have inappropriate return type */\nsize_t BIO_ctrl_pending(BIO *b);\nsize_t BIO_ctrl_wpending(BIO *b);\n# define BIO_flush(b)            (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL)\n# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \\\n                                                   cbp)\n# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb)\n\n/* For the BIO_f_buffer() type */\n# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL)\n# define BIO_buffer_peek(b,s,l) BIO_ctrl(b,BIO_CTRL_PEEK,(l),(s))\n\n/* For BIO_s_bio() */\n# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL)\n# define BIO_make_bio_pair(b1,b2)   (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2)\n# define BIO_destroy_bio_pair(b)    (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL)\n# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL)\n/* macros with inappropriate type -- but ...pending macros use int too: */\n# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL)\n# define BIO_get_read_request(b)    (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL)\nsize_t BIO_ctrl_get_write_guarantee(BIO *b);\nsize_t BIO_ctrl_get_read_request(BIO *b);\nint BIO_ctrl_reset_read_request(BIO *b);\n\n/* ctrl macros for dgram */\n# define BIO_ctrl_dgram_connect(b,peer)  \\\n                     (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)(peer))\n# define BIO_ctrl_set_connected(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer))\n# define BIO_dgram_recv_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL)\n# define BIO_dgram_send_timedout(b) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL)\n# define BIO_dgram_get_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer))\n# define BIO_dgram_set_peer(b,peer) \\\n         (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer))\n# define BIO_dgram_get_mtu_overhead(b) \\\n         (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)\n\n#define BIO_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef)\nint BIO_set_ex_data(BIO *bio, int idx, void *data);\nvoid *BIO_get_ex_data(BIO *bio, int idx);\nuint64_t BIO_number_read(BIO *bio);\nuint64_t BIO_number_written(BIO *bio);\n\n/* For BIO_f_asn1() */\nint BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix,\n                        asn1_ps_func *prefix_free);\nint BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix,\n                        asn1_ps_func **pprefix_free);\nint BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix,\n                        asn1_ps_func *suffix_free);\nint BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,\n                        asn1_ps_func **psuffix_free);\n\nconst BIO_METHOD *BIO_s_file(void);\nBIO *BIO_new_file(const char *filename, const char *mode);\n# ifndef OPENSSL_NO_STDIO\nBIO *BIO_new_fp(FILE *stream, int close_flag);\n# endif\nBIO *BIO_new(const BIO_METHOD *type);\nint BIO_free(BIO *a);\nvoid BIO_set_data(BIO *a, void *ptr);\nvoid *BIO_get_data(BIO *a);\nvoid BIO_set_init(BIO *a, int init);\nint BIO_get_init(BIO *a);\nvoid BIO_set_shutdown(BIO *a, int shut);\nint BIO_get_shutdown(BIO *a);\nvoid BIO_vfree(BIO *a);\nint BIO_up_ref(BIO *a);\nint BIO_read(BIO *b, void *data, int dlen);\nint BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes);\nint BIO_gets(BIO *bp, char *buf, int size);\nint BIO_write(BIO *b, const void *data, int dlen);\nint BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);\nint BIO_puts(BIO *bp, const char *buf);\nint BIO_indent(BIO *b, int indent, int max);\nlong BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);\nlong BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);\nvoid *BIO_ptr_ctrl(BIO *bp, int cmd, long larg);\nlong BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg);\nBIO *BIO_push(BIO *b, BIO *append);\nBIO *BIO_pop(BIO *b);\nvoid BIO_free_all(BIO *a);\nBIO *BIO_find_type(BIO *b, int bio_type);\nBIO *BIO_next(BIO *b);\nvoid BIO_set_next(BIO *b, BIO *next);\nBIO *BIO_get_retry_BIO(BIO *bio, int *reason);\nint BIO_get_retry_reason(BIO *bio);\nvoid BIO_set_retry_reason(BIO *bio, int reason);\nBIO *BIO_dup_chain(BIO *in);\n\nint BIO_nread0(BIO *bio, char **buf);\nint BIO_nread(BIO *bio, char **buf, int num);\nint BIO_nwrite0(BIO *bio, char **buf);\nint BIO_nwrite(BIO *bio, char **buf, int num);\n\nlong BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,\n                        long argl, long ret);\n\nconst BIO_METHOD *BIO_s_mem(void);\nconst BIO_METHOD *BIO_s_secmem(void);\nBIO *BIO_new_mem_buf(const void *buf, int len);\n# ifndef OPENSSL_NO_SOCK\nconst BIO_METHOD *BIO_s_socket(void);\nconst BIO_METHOD *BIO_s_connect(void);\nconst BIO_METHOD *BIO_s_accept(void);\n# endif\nconst BIO_METHOD *BIO_s_fd(void);\nconst BIO_METHOD *BIO_s_log(void);\nconst BIO_METHOD *BIO_s_bio(void);\nconst BIO_METHOD *BIO_s_null(void);\nconst BIO_METHOD *BIO_f_null(void);\nconst BIO_METHOD *BIO_f_buffer(void);\nconst BIO_METHOD *BIO_f_linebuffer(void);\nconst BIO_METHOD *BIO_f_nbio_test(void);\n# ifndef OPENSSL_NO_DGRAM\nconst BIO_METHOD *BIO_s_datagram(void);\nint BIO_dgram_non_fatal_error(int error);\nBIO *BIO_new_dgram(int fd, int close_flag);\n#  ifndef OPENSSL_NO_SCTP\nconst BIO_METHOD *BIO_s_datagram_sctp(void);\nBIO *BIO_new_dgram_sctp(int fd, int close_flag);\nint BIO_dgram_is_sctp(BIO *bio);\nint BIO_dgram_sctp_notification_cb(BIO *b,\n                                   void (*handle_notifications) (BIO *bio,\n                                                                 void *context,\n                                                                 void *buf),\n                                   void *context);\nint BIO_dgram_sctp_wait_for_dry(BIO *b);\nint BIO_dgram_sctp_msg_waiting(BIO *b);\n#  endif\n# endif\n\n# ifndef OPENSSL_NO_SOCK\nint BIO_sock_should_retry(int i);\nint BIO_sock_non_fatal_error(int error);\n# endif\n\nint BIO_fd_should_retry(int i);\nint BIO_fd_non_fatal_error(int error);\nint BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),\n                void *u, const char *s, int len);\nint BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),\n                       void *u, const char *s, int len, int indent);\nint BIO_dump(BIO *b, const char *bytes, int len);\nint BIO_dump_indent(BIO *b, const char *bytes, int len, int indent);\n# ifndef OPENSSL_NO_STDIO\nint BIO_dump_fp(FILE *fp, const char *s, int len);\nint BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent);\n# endif\nint BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,\n                   int datalen);\n\n# ifndef OPENSSL_NO_SOCK\nBIO_ADDR *BIO_ADDR_new(void);\nint BIO_ADDR_rawmake(BIO_ADDR *ap, int family,\n                     const void *where, size_t wherelen, unsigned short port);\nvoid BIO_ADDR_free(BIO_ADDR *);\nvoid BIO_ADDR_clear(BIO_ADDR *ap);\nint BIO_ADDR_family(const BIO_ADDR *ap);\nint BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l);\nunsigned short BIO_ADDR_rawport(const BIO_ADDR *ap);\nchar *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric);\nchar *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric);\nchar *BIO_ADDR_path_string(const BIO_ADDR *ap);\n\nconst BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai);\nint BIO_ADDRINFO_family(const BIO_ADDRINFO *bai);\nint BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai);\nint BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai);\nconst BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai);\nvoid BIO_ADDRINFO_free(BIO_ADDRINFO *bai);\n\nenum BIO_hostserv_priorities {\n    BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV\n};\nint BIO_parse_hostserv(const char *hostserv, char **host, char **service,\n                       enum BIO_hostserv_priorities hostserv_prio);\nenum BIO_lookup_type {\n    BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER\n};\nint BIO_lookup(const char *host, const char *service,\n               enum BIO_lookup_type lookup_type,\n               int family, int socktype, BIO_ADDRINFO **res);\nint BIO_lookup_ex(const char *host, const char *service,\n                  int lookup_type, int family, int socktype, int protocol,\n                  BIO_ADDRINFO **res);\nint BIO_sock_error(int sock);\nint BIO_socket_ioctl(int fd, long type, void *arg);\nint BIO_socket_nbio(int fd, int mode);\nint BIO_sock_init(void);\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define BIO_sock_cleanup() while(0) continue\n# endif\nint BIO_set_tcp_ndelay(int sock, int turn_on);\n\nDEPRECATEDIN_1_1_0(struct hostent *BIO_gethostbyname(const char *name))\nDEPRECATEDIN_1_1_0(int BIO_get_port(const char *str, unsigned short *port_ptr))\nDEPRECATEDIN_1_1_0(int BIO_get_host_ip(const char *str, unsigned char *ip))\nDEPRECATEDIN_1_1_0(int BIO_get_accept_socket(char *host_port, int mode))\nDEPRECATEDIN_1_1_0(int BIO_accept(int sock, char **ip_port))\n\nunion BIO_sock_info_u {\n    BIO_ADDR *addr;\n};\nenum BIO_sock_info_type {\n    BIO_SOCK_INFO_ADDRESS\n};\nint BIO_sock_info(int sock,\n                  enum BIO_sock_info_type type, union BIO_sock_info_u *info);\n\n#  define BIO_SOCK_REUSEADDR    0x01\n#  define BIO_SOCK_V6_ONLY      0x02\n#  define BIO_SOCK_KEEPALIVE    0x04\n#  define BIO_SOCK_NONBLOCK     0x08\n#  define BIO_SOCK_NODELAY      0x10\n\nint BIO_socket(int domain, int socktype, int protocol, int options);\nint BIO_connect(int sock, const BIO_ADDR *addr, int options);\nint BIO_bind(int sock, const BIO_ADDR *addr, int options);\nint BIO_listen(int sock, const BIO_ADDR *addr, int options);\nint BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options);\nint BIO_closesocket(int sock);\n\nBIO *BIO_new_socket(int sock, int close_flag);\nBIO *BIO_new_connect(const char *host_port);\nBIO *BIO_new_accept(const char *host_port);\n# endif /* OPENSSL_NO_SOCK*/\n\nBIO *BIO_new_fd(int fd, int close_flag);\n\nint BIO_new_bio_pair(BIO **bio1, size_t writebuf1,\n                     BIO **bio2, size_t writebuf2);\n/*\n * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints.\n * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default\n * value.\n */\n\nvoid BIO_copy_next_retry(BIO *b);\n\n/*\n * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg);\n */\n\n# define ossl_bio__attr__(x)\n# if defined(__GNUC__) && defined(__STDC_VERSION__) \\\n    && !defined(__APPLE__)\n    /*\n     * Because we support the 'z' modifier, which made its appearance in C99,\n     * we can't use __attribute__ with pre C99 dialects.\n     */\n#  if __STDC_VERSION__ >= 199901L\n#   undef ossl_bio__attr__\n#   define ossl_bio__attr__ __attribute__\n#   if __GNUC__*10 + __GNUC_MINOR__ >= 44\n#    define ossl_bio__printf__ __gnu_printf__\n#   else\n#    define ossl_bio__printf__ __printf__\n#   endif\n#  endif\n# endif\nint BIO_printf(BIO *bio, const char *format, ...)\nossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3)));\nint BIO_vprintf(BIO *bio, const char *format, va_list args)\nossl_bio__attr__((__format__(ossl_bio__printf__, 2, 0)));\nint BIO_snprintf(char *buf, size_t n, const char *format, ...)\nossl_bio__attr__((__format__(ossl_bio__printf__, 3, 4)));\nint BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)\nossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0)));\n# undef ossl_bio__attr__\n# undef ossl_bio__printf__\n\n\nBIO_METHOD *BIO_meth_new(int type, const char *name);\nvoid BIO_meth_free(BIO_METHOD *biom);\nint (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int);\nint (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_t,\n                                                size_t *);\nint BIO_meth_set_write(BIO_METHOD *biom,\n                       int (*write) (BIO *, const char *, int));\nint BIO_meth_set_write_ex(BIO_METHOD *biom,\n                       int (*bwrite) (BIO *, const char *, size_t, size_t *));\nint (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int);\nint (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *);\nint BIO_meth_set_read(BIO_METHOD *biom,\n                      int (*read) (BIO *, char *, int));\nint BIO_meth_set_read_ex(BIO_METHOD *biom,\n                         int (*bread) (BIO *, char *, size_t, size_t *));\nint (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *);\nint BIO_meth_set_puts(BIO_METHOD *biom,\n                      int (*puts) (BIO *, const char *));\nint (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);\nint BIO_meth_set_gets(BIO_METHOD *biom,\n                      int (*gets) (BIO *, char *, int));\nlong (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *);\nint BIO_meth_set_ctrl(BIO_METHOD *biom,\n                      long (*ctrl) (BIO *, int, long, void *));\nint (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *);\nint BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *));\nint (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *);\nint BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *));\nlong (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))\n                                 (BIO *, int, BIO_info_cb *);\nint BIO_meth_set_callback_ctrl(BIO_METHOD *biom,\n                               long (*callback_ctrl) (BIO *, int,\n                                                      BIO_info_cb *));\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/bioerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BIOERR_H\n# define HEADER_BIOERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_BIO_strings(void);\n\n/*\n * BIO function codes.\n */\n# define BIO_F_ACPT_STATE                                 100\n# define BIO_F_ADDRINFO_WRAP                              148\n# define BIO_F_ADDR_STRINGS                               134\n# define BIO_F_BIO_ACCEPT                                 101\n# define BIO_F_BIO_ACCEPT_EX                              137\n# define BIO_F_BIO_ACCEPT_NEW                             152\n# define BIO_F_BIO_ADDR_NEW                               144\n# define BIO_F_BIO_BIND                                   147\n# define BIO_F_BIO_CALLBACK_CTRL                          131\n# define BIO_F_BIO_CONNECT                                138\n# define BIO_F_BIO_CONNECT_NEW                            153\n# define BIO_F_BIO_CTRL                                   103\n# define BIO_F_BIO_GETS                                   104\n# define BIO_F_BIO_GET_HOST_IP                            106\n# define BIO_F_BIO_GET_NEW_INDEX                          102\n# define BIO_F_BIO_GET_PORT                               107\n# define BIO_F_BIO_LISTEN                                 139\n# define BIO_F_BIO_LOOKUP                                 135\n# define BIO_F_BIO_LOOKUP_EX                              143\n# define BIO_F_BIO_MAKE_PAIR                              121\n# define BIO_F_BIO_METH_NEW                               146\n# define BIO_F_BIO_NEW                                    108\n# define BIO_F_BIO_NEW_DGRAM_SCTP                         145\n# define BIO_F_BIO_NEW_FILE                               109\n# define BIO_F_BIO_NEW_MEM_BUF                            126\n# define BIO_F_BIO_NREAD                                  123\n# define BIO_F_BIO_NREAD0                                 124\n# define BIO_F_BIO_NWRITE                                 125\n# define BIO_F_BIO_NWRITE0                                122\n# define BIO_F_BIO_PARSE_HOSTSERV                         136\n# define BIO_F_BIO_PUTS                                   110\n# define BIO_F_BIO_READ                                   111\n# define BIO_F_BIO_READ_EX                                105\n# define BIO_F_BIO_READ_INTERN                            120\n# define BIO_F_BIO_SOCKET                                 140\n# define BIO_F_BIO_SOCKET_NBIO                            142\n# define BIO_F_BIO_SOCK_INFO                              141\n# define BIO_F_BIO_SOCK_INIT                              112\n# define BIO_F_BIO_WRITE                                  113\n# define BIO_F_BIO_WRITE_EX                               119\n# define BIO_F_BIO_WRITE_INTERN                           128\n# define BIO_F_BUFFER_CTRL                                114\n# define BIO_F_CONN_CTRL                                  127\n# define BIO_F_CONN_STATE                                 115\n# define BIO_F_DGRAM_SCTP_NEW                             149\n# define BIO_F_DGRAM_SCTP_READ                            132\n# define BIO_F_DGRAM_SCTP_WRITE                           133\n# define BIO_F_DOAPR_OUTCH                                150\n# define BIO_F_FILE_CTRL                                  116\n# define BIO_F_FILE_READ                                  130\n# define BIO_F_LINEBUFFER_CTRL                            129\n# define BIO_F_LINEBUFFER_NEW                             151\n# define BIO_F_MEM_WRITE                                  117\n# define BIO_F_NBIOF_NEW                                  154\n# define BIO_F_SLG_WRITE                                  155\n# define BIO_F_SSL_NEW                                    118\n\n/*\n * BIO reason codes.\n */\n# define BIO_R_ACCEPT_ERROR                               100\n# define BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET               141\n# define BIO_R_AMBIGUOUS_HOST_OR_SERVICE                  129\n# define BIO_R_BAD_FOPEN_MODE                             101\n# define BIO_R_BROKEN_PIPE                                124\n# define BIO_R_CONNECT_ERROR                              103\n# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET          107\n# define BIO_R_GETSOCKNAME_ERROR                          132\n# define BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS              133\n# define BIO_R_GETTING_SOCKTYPE                           134\n# define BIO_R_INVALID_ARGUMENT                           125\n# define BIO_R_INVALID_SOCKET                             135\n# define BIO_R_IN_USE                                     123\n# define BIO_R_LENGTH_TOO_LONG                            102\n# define BIO_R_LISTEN_V6_ONLY                             136\n# define BIO_R_LOOKUP_RETURNED_NOTHING                    142\n# define BIO_R_MALFORMED_HOST_OR_SERVICE                  130\n# define BIO_R_NBIO_CONNECT_ERROR                         110\n# define BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED        143\n# define BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED           144\n# define BIO_R_NO_PORT_DEFINED                            113\n# define BIO_R_NO_SUCH_FILE                               128\n# define BIO_R_NULL_PARAMETER                             115\n# define BIO_R_UNABLE_TO_BIND_SOCKET                      117\n# define BIO_R_UNABLE_TO_CREATE_SOCKET                    118\n# define BIO_R_UNABLE_TO_KEEPALIVE                        137\n# define BIO_R_UNABLE_TO_LISTEN_SOCKET                    119\n# define BIO_R_UNABLE_TO_NODELAY                          138\n# define BIO_R_UNABLE_TO_REUSEADDR                        139\n# define BIO_R_UNAVAILABLE_IP_FAMILY                      145\n# define BIO_R_UNINITIALIZED                              120\n# define BIO_R_UNKNOWN_INFO_TYPE                          140\n# define BIO_R_UNSUPPORTED_IP_FAMILY                      146\n# define BIO_R_UNSUPPORTED_METHOD                         121\n# define BIO_R_UNSUPPORTED_PROTOCOL_FAMILY                131\n# define BIO_R_WRITE_TO_READ_ONLY_BIO                     126\n# define BIO_R_WSASTARTUP                                 122\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/blowfish.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BLOWFISH_H\n# define HEADER_BLOWFISH_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_BF\n# include <openssl/e_os2.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define BF_ENCRYPT      1\n# define BF_DECRYPT      0\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! BF_LONG has to be at least 32 bits wide.                     !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n# define BF_LONG unsigned int\n\n# define BF_ROUNDS       16\n# define BF_BLOCK        8\n\ntypedef struct bf_key_st {\n    BF_LONG P[BF_ROUNDS + 2];\n    BF_LONG S[4 * 256];\n} BF_KEY;\n\nvoid BF_set_key(BF_KEY *key, int len, const unsigned char *data);\n\nvoid BF_encrypt(BF_LONG *data, const BF_KEY *key);\nvoid BF_decrypt(BF_LONG *data, const BF_KEY *key);\n\nvoid BF_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                    const BF_KEY *key, int enc);\nvoid BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                    const BF_KEY *schedule, unsigned char *ivec, int enc);\nvoid BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num, int enc);\nvoid BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const BF_KEY *schedule,\n                      unsigned char *ivec, int *num);\nconst char *BF_options(void);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/bn.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BN_H\n# define HEADER_BN_H\n\n# include <openssl/e_os2.h>\n# ifndef OPENSSL_NO_STDIO\n#  include <stdio.h>\n# endif\n# include <openssl/opensslconf.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/crypto.h>\n# include <openssl/bnerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * 64-bit processor with LP64 ABI\n */\n# ifdef SIXTY_FOUR_BIT_LONG\n#  define BN_ULONG        unsigned long\n#  define BN_BYTES        8\n# endif\n\n/*\n * 64-bit processor other than LP64 ABI\n */\n# ifdef SIXTY_FOUR_BIT\n#  define BN_ULONG        unsigned long long\n#  define BN_BYTES        8\n# endif\n\n# ifdef THIRTY_TWO_BIT\n#  define BN_ULONG        unsigned int\n#  define BN_BYTES        4\n# endif\n\n# define BN_BITS2       (BN_BYTES * 8)\n# define BN_BITS        (BN_BITS2 * 2)\n# define BN_TBIT        ((BN_ULONG)1 << (BN_BITS2 - 1))\n\n# define BN_FLG_MALLOCED         0x01\n# define BN_FLG_STATIC_DATA      0x02\n\n/*\n * avoid leaking exponent information through timing,\n * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime,\n * BN_div() will call BN_div_no_branch,\n * BN_mod_inverse() will call bn_mod_inverse_no_branch.\n */\n# define BN_FLG_CONSTTIME        0x04\n# define BN_FLG_SECURE           0x08\n\n# if OPENSSL_API_COMPAT < 0x00908000L\n/* deprecated name for the flag */\n#  define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME\n#  define BN_FLG_FREE            0x8000 /* used for debugging */\n# endif\n\nvoid BN_set_flags(BIGNUM *b, int n);\nint BN_get_flags(const BIGNUM *b, int n);\n\n/* Values for |top| in BN_rand() */\n#define BN_RAND_TOP_ANY    -1\n#define BN_RAND_TOP_ONE     0\n#define BN_RAND_TOP_TWO     1\n\n/* Values for |bottom| in BN_rand() */\n#define BN_RAND_BOTTOM_ANY  0\n#define BN_RAND_BOTTOM_ODD  1\n\n/*\n * get a clone of a BIGNUM with changed flags, for *temporary* use only (the\n * two BIGNUMs cannot be used in parallel!). Also only for *read only* use. The\n * value |dest| should be a newly allocated BIGNUM obtained via BN_new() that\n * has not been otherwise initialised or used.\n */\nvoid BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags);\n\n/* Wrapper function to make using BN_GENCB easier */\nint BN_GENCB_call(BN_GENCB *cb, int a, int b);\n\nBN_GENCB *BN_GENCB_new(void);\nvoid BN_GENCB_free(BN_GENCB *cb);\n\n/* Populate a BN_GENCB structure with an \"old\"-style callback */\nvoid BN_GENCB_set_old(BN_GENCB *gencb, void (*callback) (int, int, void *),\n                      void *cb_arg);\n\n/* Populate a BN_GENCB structure with a \"new\"-style callback */\nvoid BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *),\n                  void *cb_arg);\n\nvoid *BN_GENCB_get_arg(BN_GENCB *cb);\n\n# define BN_prime_checks 0      /* default: select number of iterations based\n                                 * on the size of the number */\n\n/*\n * BN_prime_checks_for_size() returns the number of Miller-Rabin iterations\n * that will be done for checking that a random number is probably prime. The\n * error rate for accepting a composite number as prime depends on the size of\n * the prime |b|. The error rates used are for calculating an RSA key with 2 primes,\n * and so the level is what you would expect for a key of double the size of the\n * prime.\n *\n * This table is generated using the algorithm of FIPS PUB 186-4\n * Digital Signature Standard (DSS), section F.1, page 117.\n * (https://dx.doi.org/10.6028/NIST.FIPS.186-4)\n *\n * The following magma script was used to generate the output:\n * securitybits:=125;\n * k:=1024;\n * for t:=1 to 65 do\n *   for M:=3 to Floor(2*Sqrt(k-1)-1) do\n *     S:=0;\n *     // Sum over m\n *     for m:=3 to M do\n *       s:=0;\n *       // Sum over j\n *       for j:=2 to m do\n *         s+:=(RealField(32)!2)^-(j+(k-1)/j);\n *       end for;\n *       S+:=2^(m-(m-1)*t)*s;\n *     end for;\n *     A:=2^(k-2-M*t);\n *     B:=8*(Pi(RealField(32))^2-6)/3*2^(k-2)*S;\n *     pkt:=2.00743*Log(2)*k*2^-k*(A+B);\n *     seclevel:=Floor(-Log(2,pkt));\n *     if seclevel ge securitybits then\n *       printf \"k: %5o, security: %o bits  (t: %o, M: %o)\\n\",k,seclevel,t,M;\n *       break;\n *     end if;\n *   end for;\n *   if seclevel ge securitybits then break; end if;\n * end for;\n *\n * It can be run online at:\n * http://magma.maths.usyd.edu.au/calc\n *\n * And will output:\n * k:  1024, security: 129 bits  (t: 6, M: 23)\n *\n * k is the number of bits of the prime, securitybits is the level we want to\n * reach.\n *\n * prime length | RSA key size | # MR tests | security level\n * -------------+--------------|------------+---------------\n *  (b) >= 6394 |     >= 12788 |          3 |        256 bit\n *  (b) >= 3747 |     >=  7494 |          3 |        192 bit\n *  (b) >= 1345 |     >=  2690 |          4 |        128 bit\n *  (b) >= 1080 |     >=  2160 |          5 |        128 bit\n *  (b) >=  852 |     >=  1704 |          5 |        112 bit\n *  (b) >=  476 |     >=   952 |          5 |         80 bit\n *  (b) >=  400 |     >=   800 |          6 |         80 bit\n *  (b) >=  347 |     >=   694 |          7 |         80 bit\n *  (b) >=  308 |     >=   616 |          8 |         80 bit\n *  (b) >=   55 |     >=   110 |         27 |         64 bit\n *  (b) >=    6 |     >=    12 |         34 |         64 bit\n */\n\n# define BN_prime_checks_for_size(b) ((b) >= 3747 ?  3 : \\\n                                (b) >=  1345 ?  4 : \\\n                                (b) >=  476 ?  5 : \\\n                                (b) >=  400 ?  6 : \\\n                                (b) >=  347 ?  7 : \\\n                                (b) >=  308 ?  8 : \\\n                                (b) >=  55  ? 27 : \\\n                                /* b >= 6 */ 34)\n\n# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)\n\nint BN_abs_is_word(const BIGNUM *a, const BN_ULONG w);\nint BN_is_zero(const BIGNUM *a);\nint BN_is_one(const BIGNUM *a);\nint BN_is_word(const BIGNUM *a, const BN_ULONG w);\nint BN_is_odd(const BIGNUM *a);\n\n# define BN_one(a)       (BN_set_word((a),1))\n\nvoid BN_zero_ex(BIGNUM *a);\n\n# if OPENSSL_API_COMPAT >= 0x00908000L\n#  define BN_zero(a)      BN_zero_ex(a)\n# else\n#  define BN_zero(a)      (BN_set_word((a),0))\n# endif\n\nconst BIGNUM *BN_value_one(void);\nchar *BN_options(void);\nBN_CTX *BN_CTX_new(void);\nBN_CTX *BN_CTX_secure_new(void);\nvoid BN_CTX_free(BN_CTX *c);\nvoid BN_CTX_start(BN_CTX *ctx);\nBIGNUM *BN_CTX_get(BN_CTX *ctx);\nvoid BN_CTX_end(BN_CTX *ctx);\nint BN_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_priv_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);\nint BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);\nint BN_num_bits(const BIGNUM *a);\nint BN_num_bits_word(BN_ULONG l);\nint BN_security_bits(int L, int N);\nBIGNUM *BN_new(void);\nBIGNUM *BN_secure_new(void);\nvoid BN_clear_free(BIGNUM *a);\nBIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);\nvoid BN_swap(BIGNUM *a, BIGNUM *b);\nBIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2bin(const BIGNUM *a, unsigned char *to);\nint BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen);\nBIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen);\nBIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret);\nint BN_bn2mpi(const BIGNUM *a, unsigned char *to);\nint BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\nint BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);\n/** BN_set_negative sets sign of a BIGNUM\n * \\param  b  pointer to the BIGNUM object\n * \\param  n  0 if the BIGNUM b should be positive and a value != 0 otherwise\n */\nvoid BN_set_negative(BIGNUM *b, int n);\n/** BN_is_negative returns 1 if the BIGNUM is negative\n * \\param  b  pointer to the BIGNUM object\n * \\return 1 if a < 0 and 0 otherwise\n */\nint BN_is_negative(const BIGNUM *b);\n\nint BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,\n           BN_CTX *ctx);\n# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))\nint BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx);\nint BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m);\nint BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n               BN_CTX *ctx);\nint BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m);\nint BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m,\n                  BN_CTX *ctx);\nint BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m);\n\nBN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);\nint BN_mul_word(BIGNUM *a, BN_ULONG w);\nint BN_add_word(BIGNUM *a, BN_ULONG w);\nint BN_sub_word(BIGNUM *a, BN_ULONG w);\nint BN_set_word(BIGNUM *a, BN_ULONG w);\nBN_ULONG BN_get_word(const BIGNUM *a);\n\nint BN_cmp(const BIGNUM *a, const BIGNUM *b);\nvoid BN_free(BIGNUM *a);\nint BN_is_bit_set(const BIGNUM *a, int n);\nint BN_lshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_lshift1(BIGNUM *r, const BIGNUM *a);\nint BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nint BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n               const BIGNUM *m, BN_CTX *ctx);\nint BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,\n                              const BIGNUM *m, BN_CTX *ctx,\n                              BN_MONT_CTX *in_mont);\nint BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,\n                         const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1,\n                     const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m,\n                     BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                      const BIGNUM *m, BN_CTX *ctx);\n\nint BN_mask_bits(BIGNUM *a, int n);\n# ifndef OPENSSL_NO_STDIO\nint BN_print_fp(FILE *fp, const BIGNUM *a);\n# endif\nint BN_print(BIO *bio, const BIGNUM *a);\nint BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);\nint BN_rshift(BIGNUM *r, const BIGNUM *a, int n);\nint BN_rshift1(BIGNUM *r, const BIGNUM *a);\nvoid BN_clear(BIGNUM *a);\nBIGNUM *BN_dup(const BIGNUM *a);\nint BN_ucmp(const BIGNUM *a, const BIGNUM *b);\nint BN_set_bit(BIGNUM *a, int n);\nint BN_clear_bit(BIGNUM *a, int n);\nchar *BN_bn2hex(const BIGNUM *a);\nchar *BN_bn2dec(const BIGNUM *a);\nint BN_hex2bn(BIGNUM **a, const char *str);\nint BN_dec2bn(BIGNUM **a, const char *str);\nint BN_asc2bn(BIGNUM **a, const char *str);\nint BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);\nint BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns\n                                                                  * -2 for\n                                                                  * error */\nBIGNUM *BN_mod_inverse(BIGNUM *ret,\n                       const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\nBIGNUM *BN_mod_sqrt(BIGNUM *ret,\n                    const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx);\n\nvoid BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords);\n\n/* Deprecated versions */\nDEPRECATEDIN_0_9_8(BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,\n                                             const BIGNUM *add,\n                                             const BIGNUM *rem,\n                                             void (*callback) (int, int,\n                                                               void *),\n                                             void *cb_arg))\nDEPRECATEDIN_0_9_8(int\n                   BN_is_prime(const BIGNUM *p, int nchecks,\n                               void (*callback) (int, int, void *),\n                               BN_CTX *ctx, void *cb_arg))\nDEPRECATEDIN_0_9_8(int\n                   BN_is_prime_fasttest(const BIGNUM *p, int nchecks,\n                                        void (*callback) (int, int, void *),\n                                        BN_CTX *ctx, void *cb_arg,\n                                        int do_trial_division))\n\n/* Newer versions */\nint BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,\n                         const BIGNUM *rem, BN_GENCB *cb);\nint BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb);\nint BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx,\n                            int do_trial_division, BN_GENCB *cb);\n\nint BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx);\n\nint BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,\n                            const BIGNUM *Xp, const BIGNUM *Xp1,\n                            const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx,\n                            BN_GENCB *cb);\nint BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1,\n                              BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e,\n                              BN_CTX *ctx, BN_GENCB *cb);\n\nBN_MONT_CTX *BN_MONT_CTX_new(void);\nint BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx);\nint BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,\n                     BN_CTX *ctx);\nint BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,\n                       BN_CTX *ctx);\nvoid BN_MONT_CTX_free(BN_MONT_CTX *mont);\nint BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx);\nBN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from);\nBN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock,\n                                    const BIGNUM *mod, BN_CTX *ctx);\n\n/* BN_BLINDING flags */\n# define BN_BLINDING_NO_UPDATE   0x00000001\n# define BN_BLINDING_NO_RECREATE 0x00000002\n\nBN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod);\nvoid BN_BLINDING_free(BN_BLINDING *b);\nint BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);\nint BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);\nint BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,\n                          BN_CTX *);\n\nint BN_BLINDING_is_current_thread(BN_BLINDING *b);\nvoid BN_BLINDING_set_current_thread(BN_BLINDING *b);\nint BN_BLINDING_lock(BN_BLINDING *b);\nint BN_BLINDING_unlock(BN_BLINDING *b);\n\nunsigned long BN_BLINDING_get_flags(const BN_BLINDING *);\nvoid BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);\nBN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,\n                                      const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,\n                                      int (*bn_mod_exp) (BIGNUM *r,\n                                                         const BIGNUM *a,\n                                                         const BIGNUM *p,\n                                                         const BIGNUM *m,\n                                                         BN_CTX *ctx,\n                                                         BN_MONT_CTX *m_ctx),\n                                      BN_MONT_CTX *m_ctx);\n\nDEPRECATEDIN_0_9_8(void BN_set_params(int mul, int high, int low, int mont))\nDEPRECATEDIN_0_9_8(int BN_get_params(int which)) /* 0, mul, 1 high, 2 low, 3\n                                                  * mont */\n\nBN_RECP_CTX *BN_RECP_CTX_new(void);\nvoid BN_RECP_CTX_free(BN_RECP_CTX *recp);\nint BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx);\nint BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,\n                          BN_RECP_CTX *recp, BN_CTX *ctx);\nint BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                    const BIGNUM *m, BN_CTX *ctx);\nint BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,\n                BN_RECP_CTX *recp, BN_CTX *ctx);\n\n# ifndef OPENSSL_NO_EC2M\n\n/*\n * Functions for arithmetic over binary polynomials represented by BIGNUMs.\n * The BIGNUM::neg property of BIGNUMs representing binary polynomials is\n * ignored. Note that input arguments are not const so that their bit arrays\n * can be expanded to the appropriate size if needed.\n */\n\n/*\n * r = a + b\n */\nint BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);\n#  define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b)\n/*\n * r=a mod p\n */\nint BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                    const BIGNUM *p, BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                     BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n                           BN_CTX *ctx);\n#  define BN_GF2m_cmp(a, b) BN_ucmp((a), (b))\n/*-\n * Some functions allow for representation of the irreducible polynomials\n * as an unsigned int[], say p.  The irreducible f(t) is then of the form:\n *     t^p[0] + t^p[1] + ... + t^p[k]\n * where m = p[0] > p[1] > ... > p[k] = 0.\n */\n/* r = a mod p */\nint BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]);\n/* r = (a * b) mod p */\nint BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a * a) mod p */\nint BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[],\n                        BN_CTX *ctx);\n/* r = (1 / b) mod p */\nint BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[],\n                        BN_CTX *ctx);\n/* r = (a / b) mod p */\nint BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = (a ^ b) mod p */\nint BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                        const int p[], BN_CTX *ctx);\n/* r = sqrt(a) mod p */\nint BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a,\n                         const int p[], BN_CTX *ctx);\n/* r^2 + r = a mod p */\nint BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a,\n                               const int p[], BN_CTX *ctx);\nint BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max);\nint BN_GF2m_arr2poly(const int p[], BIGNUM *a);\n\n# endif\n\n/*\n * faster mod functions for the 'NIST primes' 0 <= a < p^2\n */\nint BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\nint BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);\n\nconst BIGNUM *BN_get0_nist_prime_192(void);\nconst BIGNUM *BN_get0_nist_prime_224(void);\nconst BIGNUM *BN_get0_nist_prime_256(void);\nconst BIGNUM *BN_get0_nist_prime_384(void);\nconst BIGNUM *BN_get0_nist_prime_521(void);\n\nint (*BN_nist_mod_func(const BIGNUM *p)) (BIGNUM *r, const BIGNUM *a,\n                                          const BIGNUM *field, BN_CTX *ctx);\n\nint BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,\n                          const BIGNUM *priv, const unsigned char *message,\n                          size_t message_len, BN_CTX *ctx);\n\n/* Primes from RFC 2409 */\nBIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn);\nBIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn);\n\n/* Primes from RFC 3526 */\nBIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn);\nBIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define get_rfc2409_prime_768 BN_get_rfc2409_prime_768\n#  define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024\n#  define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536\n#  define get_rfc3526_prime_2048 BN_get_rfc3526_prime_2048\n#  define get_rfc3526_prime_3072 BN_get_rfc3526_prime_3072\n#  define get_rfc3526_prime_4096 BN_get_rfc3526_prime_4096\n#  define get_rfc3526_prime_6144 BN_get_rfc3526_prime_6144\n#  define get_rfc3526_prime_8192 BN_get_rfc3526_prime_8192\n# endif\n\nint BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/bnerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BNERR_H\n# define HEADER_BNERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_BN_strings(void);\n\n/*\n * BN function codes.\n */\n# define BN_F_BNRAND                                      127\n# define BN_F_BNRAND_RANGE                                138\n# define BN_F_BN_BLINDING_CONVERT_EX                      100\n# define BN_F_BN_BLINDING_CREATE_PARAM                    128\n# define BN_F_BN_BLINDING_INVERT_EX                       101\n# define BN_F_BN_BLINDING_NEW                             102\n# define BN_F_BN_BLINDING_UPDATE                          103\n# define BN_F_BN_BN2DEC                                   104\n# define BN_F_BN_BN2HEX                                   105\n# define BN_F_BN_COMPUTE_WNAF                             142\n# define BN_F_BN_CTX_GET                                  116\n# define BN_F_BN_CTX_NEW                                  106\n# define BN_F_BN_CTX_START                                129\n# define BN_F_BN_DIV                                      107\n# define BN_F_BN_DIV_RECP                                 130\n# define BN_F_BN_EXP                                      123\n# define BN_F_BN_EXPAND_INTERNAL                          120\n# define BN_F_BN_GENCB_NEW                                143\n# define BN_F_BN_GENERATE_DSA_NONCE                       140\n# define BN_F_BN_GENERATE_PRIME_EX                        141\n# define BN_F_BN_GF2M_MOD                                 131\n# define BN_F_BN_GF2M_MOD_EXP                             132\n# define BN_F_BN_GF2M_MOD_MUL                             133\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD                      134\n# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR                  135\n# define BN_F_BN_GF2M_MOD_SQR                             136\n# define BN_F_BN_GF2M_MOD_SQRT                            137\n# define BN_F_BN_LSHIFT                                   145\n# define BN_F_BN_MOD_EXP2_MONT                            118\n# define BN_F_BN_MOD_EXP_MONT                             109\n# define BN_F_BN_MOD_EXP_MONT_CONSTTIME                   124\n# define BN_F_BN_MOD_EXP_MONT_WORD                        117\n# define BN_F_BN_MOD_EXP_RECP                             125\n# define BN_F_BN_MOD_EXP_SIMPLE                           126\n# define BN_F_BN_MOD_INVERSE                              110\n# define BN_F_BN_MOD_INVERSE_NO_BRANCH                    139\n# define BN_F_BN_MOD_LSHIFT_QUICK                         119\n# define BN_F_BN_MOD_SQRT                                 121\n# define BN_F_BN_MONT_CTX_NEW                             149\n# define BN_F_BN_MPI2BN                                   112\n# define BN_F_BN_NEW                                      113\n# define BN_F_BN_POOL_GET                                 147\n# define BN_F_BN_RAND                                     114\n# define BN_F_BN_RAND_RANGE                               122\n# define BN_F_BN_RECP_CTX_NEW                             150\n# define BN_F_BN_RSHIFT                                   146\n# define BN_F_BN_SET_WORDS                                144\n# define BN_F_BN_STACK_PUSH                               148\n# define BN_F_BN_USUB                                     115\n\n/*\n * BN reason codes.\n */\n# define BN_R_ARG2_LT_ARG3                                100\n# define BN_R_BAD_RECIPROCAL                              101\n# define BN_R_BIGNUM_TOO_LONG                             114\n# define BN_R_BITS_TOO_SMALL                              118\n# define BN_R_CALLED_WITH_EVEN_MODULUS                    102\n# define BN_R_DIV_BY_ZERO                                 103\n# define BN_R_ENCODING_ERROR                              104\n# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA                105\n# define BN_R_INPUT_NOT_REDUCED                           110\n# define BN_R_INVALID_LENGTH                              106\n# define BN_R_INVALID_RANGE                               115\n# define BN_R_INVALID_SHIFT                               119\n# define BN_R_NOT_A_SQUARE                                111\n# define BN_R_NOT_INITIALIZED                             107\n# define BN_R_NO_INVERSE                                  108\n# define BN_R_NO_SOLUTION                                 116\n# define BN_R_PRIVATE_KEY_TOO_LARGE                       117\n# define BN_R_P_IS_NOT_PRIME                              112\n# define BN_R_TOO_MANY_ITERATIONS                         113\n# define BN_R_TOO_MANY_TEMPORARY_VARIABLES                109\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/buffer.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BUFFER_H\n# define HEADER_BUFFER_H\n\n# include <openssl/ossl_typ.h>\n# ifndef HEADER_CRYPTO_H\n#  include <openssl/crypto.h>\n# endif\n# include <openssl/buffererr.h>\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <stddef.h>\n# include <sys/types.h>\n\n/*\n * These names are outdated as of OpenSSL 1.1; a future release\n * will move them to be deprecated.\n */\n# define BUF_strdup(s) OPENSSL_strdup(s)\n# define BUF_strndup(s, size) OPENSSL_strndup(s, size)\n# define BUF_memdup(data, size) OPENSSL_memdup(data, size)\n# define BUF_strlcpy(dst, src, size)  OPENSSL_strlcpy(dst, src, size)\n# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)\n# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)\n\nstruct buf_mem_st {\n    size_t length;              /* current number of bytes */\n    char *data;\n    size_t max;                 /* size of buffer */\n    unsigned long flags;\n};\n\n# define BUF_MEM_FLAG_SECURE  0x01\n\nBUF_MEM *BUF_MEM_new(void);\nBUF_MEM *BUF_MEM_new_ex(unsigned long flags);\nvoid BUF_MEM_free(BUF_MEM *a);\nsize_t BUF_MEM_grow(BUF_MEM *str, size_t len);\nsize_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);\nvoid BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/buffererr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_BUFERR_H\n# define HEADER_BUFERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_BUF_strings(void);\n\n/*\n * BUF function codes.\n */\n# define BUF_F_BUF_MEM_GROW                               100\n# define BUF_F_BUF_MEM_GROW_CLEAN                         105\n# define BUF_F_BUF_MEM_NEW                                101\n\n/*\n * BUF reason codes.\n */\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/camellia.h",
    "content": "/*\n * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CAMELLIA_H\n# define HEADER_CAMELLIA_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CAMELLIA\n# include <stddef.h>\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define CAMELLIA_ENCRYPT        1\n# define CAMELLIA_DECRYPT        0\n\n/*\n * Because array size can't be a const in C, the following two are macros.\n * Both sizes are in bytes.\n */\n\n/* This should be a hidden type, but EVP requires that the size be known */\n\n# define CAMELLIA_BLOCK_SIZE 16\n# define CAMELLIA_TABLE_BYTE_LEN 272\n# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)\n\ntypedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match\n                                                               * with WORD */\n\nstruct camellia_key_st {\n    union {\n        double d;               /* ensures 64-bit align */\n        KEY_TABLE_TYPE rd_key;\n    } u;\n    int grand_rounds;\n};\ntypedef struct camellia_key_st CAMELLIA_KEY;\n\nint Camellia_set_key(const unsigned char *userKey, const int bits,\n                     CAMELLIA_KEY *key);\n\nvoid Camellia_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\nvoid Camellia_decrypt(const unsigned char *in, unsigned char *out,\n                      const CAMELLIA_KEY *key);\n\nvoid Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                          const CAMELLIA_KEY *key, const int enc);\nvoid Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                          size_t length, const CAMELLIA_KEY *key,\n                          unsigned char *ivec, const int enc);\nvoid Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t length, const CAMELLIA_KEY *key,\n                           unsigned char *ivec, int *num, const int enc);\nvoid Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char *ivec, int *num);\nvoid Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const CAMELLIA_KEY *key,\n                             unsigned char ivec[CAMELLIA_BLOCK_SIZE],\n                             unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],\n                             unsigned int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/cast.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CAST_H\n# define HEADER_CAST_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CAST\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define CAST_ENCRYPT    1\n# define CAST_DECRYPT    0\n\n# define CAST_LONG unsigned int\n\n# define CAST_BLOCK      8\n# define CAST_KEY_LENGTH 16\n\ntypedef struct cast_key_st {\n    CAST_LONG data[32];\n    int short_key;              /* Use reduced rounds for short key */\n} CAST_KEY;\n\nvoid CAST_set_key(CAST_KEY *key, int len, const unsigned char *data);\nvoid CAST_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const CAST_KEY *key, int enc);\nvoid CAST_encrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_decrypt(CAST_LONG *data, const CAST_KEY *key);\nvoid CAST_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, const CAST_KEY *ks, unsigned char *iv,\n                      int enc);\nvoid CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num, int enc);\nvoid CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, const CAST_KEY *schedule,\n                        unsigned char *ivec, int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/cmac.h",
    "content": "/*\n * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CMAC_H\n# define HEADER_CMAC_H\n\n# ifndef OPENSSL_NO_CMAC\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/evp.h>\n\n/* Opaque */\ntypedef struct CMAC_CTX_st CMAC_CTX;\n\nCMAC_CTX *CMAC_CTX_new(void);\nvoid CMAC_CTX_cleanup(CMAC_CTX *ctx);\nvoid CMAC_CTX_free(CMAC_CTX *ctx);\nEVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx);\nint CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in);\n\nint CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,\n              const EVP_CIPHER *cipher, ENGINE *impl);\nint CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen);\nint CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen);\nint CMAC_resume(CMAC_CTX *ctx);\n\n#ifdef  __cplusplus\n}\n#endif\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/cms.h",
    "content": "/*\n * Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CMS_H\n# define HEADER_CMS_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CMS\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n# include <openssl/cmserr.h>\n# ifdef __cplusplus\nextern \"C\" {\n# endif\n\ntypedef struct CMS_ContentInfo_st CMS_ContentInfo;\ntypedef struct CMS_SignerInfo_st CMS_SignerInfo;\ntypedef struct CMS_CertificateChoices CMS_CertificateChoices;\ntypedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;\ntypedef struct CMS_RecipientInfo_st CMS_RecipientInfo;\ntypedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;\ntypedef struct CMS_Receipt_st CMS_Receipt;\ntypedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;\ntypedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;\n\nDEFINE_STACK_OF(CMS_SignerInfo)\nDEFINE_STACK_OF(CMS_RecipientEncryptedKey)\nDEFINE_STACK_OF(CMS_RecipientInfo)\nDEFINE_STACK_OF(CMS_RevocationInfoChoice)\nDECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)\nDECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)\nDECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)\n\n# define CMS_SIGNERINFO_ISSUER_SERIAL    0\n# define CMS_SIGNERINFO_KEYIDENTIFIER    1\n\n# define CMS_RECIPINFO_NONE              -1\n# define CMS_RECIPINFO_TRANS             0\n# define CMS_RECIPINFO_AGREE             1\n# define CMS_RECIPINFO_KEK               2\n# define CMS_RECIPINFO_PASS              3\n# define CMS_RECIPINFO_OTHER             4\n\n/* S/MIME related flags */\n\n# define CMS_TEXT                        0x1\n# define CMS_NOCERTS                     0x2\n# define CMS_NO_CONTENT_VERIFY           0x4\n# define CMS_NO_ATTR_VERIFY              0x8\n# define CMS_NOSIGS                      \\\n                        (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)\n# define CMS_NOINTERN                    0x10\n# define CMS_NO_SIGNER_CERT_VERIFY       0x20\n# define CMS_NOVERIFY                    0x20\n# define CMS_DETACHED                    0x40\n# define CMS_BINARY                      0x80\n# define CMS_NOATTR                      0x100\n# define CMS_NOSMIMECAP                  0x200\n# define CMS_NOOLDMIMETYPE               0x400\n# define CMS_CRLFEOL                     0x800\n# define CMS_STREAM                      0x1000\n# define CMS_NOCRL                       0x2000\n# define CMS_PARTIAL                     0x4000\n# define CMS_REUSE_DIGEST                0x8000\n# define CMS_USE_KEYID                   0x10000\n# define CMS_DEBUG_DECRYPT               0x20000\n# define CMS_KEY_PARAM                   0x40000\n# define CMS_ASCIICRLF                   0x80000\n\nconst ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms);\n\nBIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);\nint CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);\n\nASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);\nint CMS_is_detached(CMS_ContentInfo *cms);\nint CMS_set_detached(CMS_ContentInfo *cms, int detached);\n\n# ifdef HEADER_PEM_H\nDECLARE_PEM_rw_const(CMS, CMS_ContentInfo)\n# endif\nint CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);\nCMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);\nint i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);\n\nBIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);\nint i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);\nint PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,\n                             int flags);\nCMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);\nint SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);\n\nint CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,\n              unsigned int flags);\n\nCMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,\n                          STACK_OF(X509) *certs, BIO *data,\n                          unsigned int flags);\n\nCMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,\n                                  X509 *signcert, EVP_PKEY *pkey,\n                                  STACK_OF(X509) *certs, unsigned int flags);\n\nint CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);\nCMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);\n\nint CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                      unsigned int flags);\nCMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,\n                                   unsigned int flags);\n\nint CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,\n                              const unsigned char *key, size_t keylen,\n                              BIO *dcont, BIO *out, unsigned int flags);\n\nCMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,\n                                           const unsigned char *key,\n                                           size_t keylen, unsigned int flags);\n\nint CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,\n                               const unsigned char *key, size_t keylen);\n\nint CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n               X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,\n                       STACK_OF(X509) *certs,\n                       X509_STORE *store, unsigned int flags);\n\nSTACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);\n\nCMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,\n                             const EVP_CIPHER *cipher, unsigned int flags);\n\nint CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,\n                BIO *dcont, BIO *out, unsigned int flags);\n\nint CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);\nint CMS_decrypt_set1_key(CMS_ContentInfo *cms,\n                         unsigned char *key, size_t keylen,\n                         const unsigned char *id, size_t idlen);\nint CMS_decrypt_set1_password(CMS_ContentInfo *cms,\n                              unsigned char *pass, ossl_ssize_t passlen);\n\nSTACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);\nint CMS_RecipientInfo_type(CMS_RecipientInfo *ri);\nEVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);\nCMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);\nCMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,\n                                           X509 *recip, unsigned int flags);\nint CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);\nint CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);\nint CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,\n                                     EVP_PKEY **pk, X509 **recip,\n                                     X509_ALGOR **palg);\nint CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,\n                                          ASN1_OCTET_STRING **keyid,\n                                          X509_NAME **issuer,\n                                          ASN1_INTEGER **sno);\n\nCMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,\n                                          unsigned char *key, size_t keylen,\n                                          unsigned char *id, size_t idlen,\n                                          ASN1_GENERALIZEDTIME *date,\n                                          ASN1_OBJECT *otherTypeId,\n                                          ASN1_TYPE *otherType);\n\nint CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pid,\n                                    ASN1_GENERALIZEDTIME **pdate,\n                                    ASN1_OBJECT **potherid,\n                                    ASN1_TYPE **pothertype);\n\nint CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,\n                               unsigned char *key, size_t keylen);\n\nint CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,\n                                   const unsigned char *id, size_t idlen);\n\nint CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,\n                                    unsigned char *pass,\n                                    ossl_ssize_t passlen);\n\nCMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,\n                                               int iter, int wrap_nid,\n                                               int pbe_nid,\n                                               unsigned char *pass,\n                                               ossl_ssize_t passlen,\n                                               const EVP_CIPHER *kekciph);\n\nint CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);\n\nint CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,\n                   unsigned int flags);\nCMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);\n\nint CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);\nconst ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);\n\nCMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);\nint CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);\nint CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);\nSTACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);\n\nCMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);\nint CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nint CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);\nSTACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);\n\nint CMS_SignedData_init(CMS_ContentInfo *cms);\nCMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,\n                                X509 *signer, EVP_PKEY *pk, const EVP_MD *md,\n                                unsigned int flags);\nEVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);\nEVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);\nSTACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);\n\nvoid CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);\nint CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,\n                                  ASN1_OCTET_STRING **keyid,\n                                  X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);\nint CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,\n                           unsigned int flags);\nvoid CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,\n                              X509 **signer, X509_ALGOR **pdig,\n                              X509_ALGOR **psig);\nASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);\nint CMS_SignerInfo_sign(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify(CMS_SignerInfo *si);\nint CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);\n\nint CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);\nint CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,\n                            int algnid, int keysize);\nint CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);\n\nint CMS_signed_get_attr_count(const CMS_SignerInfo *si);\nint CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                               int lastpos);\nint CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj,\n                               int lastpos);\nX509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                const ASN1_OBJECT *obj, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,\n                                int nid, int type,\n                                const void *bytes, int len);\nint CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,\n                                const char *attrname, int type,\n                                const void *bytes, int len);\nvoid *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *oid,\n                                  int lastpos, int type);\n\nint CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);\nint CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,\n                                 int lastpos);\nint CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si,\n                                 const ASN1_OBJECT *obj, int lastpos);\nX509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);\nX509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);\nint CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);\nint CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,\n                                  const ASN1_OBJECT *obj, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,\n                                  int nid, int type,\n                                  const void *bytes, int len);\nint CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,\n                                  const char *attrname, int type,\n                                  const void *bytes, int len);\nvoid *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,\n                                    int lastpos, int type);\n\nint CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);\nCMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,\n                                               int allorfirst,\n                                               STACK_OF(GENERAL_NAMES)\n                                               *receiptList, STACK_OF(GENERAL_NAMES)\n                                               *receiptsTo);\nint CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);\nvoid CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,\n                                    ASN1_STRING **pcid,\n                                    int *pallorfirst,\n                                    STACK_OF(GENERAL_NAMES) **plist,\n                                    STACK_OF(GENERAL_NAMES) **prto);\nint CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,\n                                    X509_ALGOR **palg,\n                                    ASN1_OCTET_STRING **pukm);\nSTACK_OF(CMS_RecipientEncryptedKey)\n*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);\n\nint CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,\n                                        X509_ALGOR **pubalg,\n                                        ASN1_BIT_STRING **pubkey,\n                                        ASN1_OCTET_STRING **keyid,\n                                        X509_NAME **issuer,\n                                        ASN1_INTEGER **sno);\n\nint CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);\n\nint CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,\n                                      ASN1_OCTET_STRING **keyid,\n                                      ASN1_GENERALIZEDTIME **tm,\n                                      CMS_OtherKeyAttribute **other,\n                                      X509_NAME **issuer, ASN1_INTEGER **sno);\nint CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,\n                                       X509 *cert);\nint CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);\nEVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);\nint CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,\n                                   CMS_RecipientInfo *ri,\n                                   CMS_RecipientEncryptedKey *rek);\n\nint CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,\n                          ASN1_OCTET_STRING *ukm, int keylen);\n\n/* Backward compatibility for spelling errors. */\n# define CMS_R_UNKNOWN_DIGEST_ALGORITM CMS_R_UNKNOWN_DIGEST_ALGORITHM\n# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE \\\n    CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/cmserr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CMSERR_H\n# define HEADER_CMSERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CMS\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_CMS_strings(void);\n\n/*\n * CMS function codes.\n */\n#  define CMS_F_CHECK_CONTENT                              99\n#  define CMS_F_CMS_ADD0_CERT                              164\n#  define CMS_F_CMS_ADD0_RECIPIENT_KEY                     100\n#  define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD                165\n#  define CMS_F_CMS_ADD1_RECEIPTREQUEST                    158\n#  define CMS_F_CMS_ADD1_RECIPIENT_CERT                    101\n#  define CMS_F_CMS_ADD1_SIGNER                            102\n#  define CMS_F_CMS_ADD1_SIGNINGTIME                       103\n#  define CMS_F_CMS_COMPRESS                               104\n#  define CMS_F_CMS_COMPRESSEDDATA_CREATE                  105\n#  define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO                106\n#  define CMS_F_CMS_COPY_CONTENT                           107\n#  define CMS_F_CMS_COPY_MESSAGEDIGEST                     108\n#  define CMS_F_CMS_DATA                                   109\n#  define CMS_F_CMS_DATAFINAL                              110\n#  define CMS_F_CMS_DATAINIT                               111\n#  define CMS_F_CMS_DECRYPT                                112\n#  define CMS_F_CMS_DECRYPT_SET1_KEY                       113\n#  define CMS_F_CMS_DECRYPT_SET1_PASSWORD                  166\n#  define CMS_F_CMS_DECRYPT_SET1_PKEY                      114\n#  define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX               115\n#  define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO               116\n#  define CMS_F_CMS_DIGESTEDDATA_DO_FINAL                  117\n#  define CMS_F_CMS_DIGEST_VERIFY                          118\n#  define CMS_F_CMS_ENCODE_RECEIPT                         161\n#  define CMS_F_CMS_ENCRYPT                                119\n#  define CMS_F_CMS_ENCRYPTEDCONTENT_INIT                  179\n#  define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO              120\n#  define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT                  121\n#  define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT                  122\n#  define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY                 123\n#  define CMS_F_CMS_ENVELOPEDDATA_CREATE                   124\n#  define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO                 125\n#  define CMS_F_CMS_ENVELOPED_DATA_INIT                    126\n#  define CMS_F_CMS_ENV_ASN1_CTRL                          171\n#  define CMS_F_CMS_FINAL                                  127\n#  define CMS_F_CMS_GET0_CERTIFICATE_CHOICES               128\n#  define CMS_F_CMS_GET0_CONTENT                           129\n#  define CMS_F_CMS_GET0_ECONTENT_TYPE                     130\n#  define CMS_F_CMS_GET0_ENVELOPED                         131\n#  define CMS_F_CMS_GET0_REVOCATION_CHOICES                132\n#  define CMS_F_CMS_GET0_SIGNED                            133\n#  define CMS_F_CMS_MSGSIGDIGEST_ADD1                      162\n#  define CMS_F_CMS_RECEIPTREQUEST_CREATE0                 159\n#  define CMS_F_CMS_RECEIPT_VERIFY                         160\n#  define CMS_F_CMS_RECIPIENTINFO_DECRYPT                  134\n#  define CMS_F_CMS_RECIPIENTINFO_ENCRYPT                  169\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT             178\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG            175\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID        173\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS           172\n#  define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP         174\n#  define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT            135\n#  define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT            136\n#  define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID            137\n#  define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP             138\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP            139\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT             140\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT             141\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS           142\n#  define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID      143\n#  define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT               167\n#  define CMS_F_CMS_RECIPIENTINFO_SET0_KEY                 144\n#  define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD            168\n#  define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY                145\n#  define CMS_F_CMS_SD_ASN1_CTRL                           170\n#  define CMS_F_CMS_SET1_IAS                               176\n#  define CMS_F_CMS_SET1_KEYID                             177\n#  define CMS_F_CMS_SET1_SIGNERIDENTIFIER                  146\n#  define CMS_F_CMS_SET_DETACHED                           147\n#  define CMS_F_CMS_SIGN                                   148\n#  define CMS_F_CMS_SIGNED_DATA_INIT                       149\n#  define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN                150\n#  define CMS_F_CMS_SIGNERINFO_SIGN                        151\n#  define CMS_F_CMS_SIGNERINFO_VERIFY                      152\n#  define CMS_F_CMS_SIGNERINFO_VERIFY_CERT                 153\n#  define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT              154\n#  define CMS_F_CMS_SIGN_RECEIPT                           163\n#  define CMS_F_CMS_SI_CHECK_ATTRIBUTES                    183\n#  define CMS_F_CMS_STREAM                                 155\n#  define CMS_F_CMS_UNCOMPRESS                             156\n#  define CMS_F_CMS_VERIFY                                 157\n#  define CMS_F_KEK_UNWRAP_KEY                             180\n\n/*\n * CMS reason codes.\n */\n#  define CMS_R_ADD_SIGNER_ERROR                           99\n#  define CMS_R_ATTRIBUTE_ERROR                            161\n#  define CMS_R_CERTIFICATE_ALREADY_PRESENT                175\n#  define CMS_R_CERTIFICATE_HAS_NO_KEYID                   160\n#  define CMS_R_CERTIFICATE_VERIFY_ERROR                   100\n#  define CMS_R_CIPHER_INITIALISATION_ERROR                101\n#  define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR      102\n#  define CMS_R_CMS_DATAFINAL_ERROR                        103\n#  define CMS_R_CMS_LIB                                    104\n#  define CMS_R_CONTENTIDENTIFIER_MISMATCH                 170\n#  define CMS_R_CONTENT_NOT_FOUND                          105\n#  define CMS_R_CONTENT_TYPE_MISMATCH                      171\n#  define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA           106\n#  define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA            107\n#  define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA               108\n#  define CMS_R_CONTENT_VERIFY_ERROR                       109\n#  define CMS_R_CTRL_ERROR                                 110\n#  define CMS_R_CTRL_FAILURE                               111\n#  define CMS_R_DECRYPT_ERROR                              112\n#  define CMS_R_ERROR_GETTING_PUBLIC_KEY                   113\n#  define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE      114\n#  define CMS_R_ERROR_SETTING_KEY                          115\n#  define CMS_R_ERROR_SETTING_RECIPIENTINFO                116\n#  define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH               117\n#  define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER           176\n#  define CMS_R_INVALID_KEY_LENGTH                         118\n#  define CMS_R_MD_BIO_INIT_ERROR                          119\n#  define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH       120\n#  define CMS_R_MESSAGEDIGEST_WRONG_LENGTH                 121\n#  define CMS_R_MSGSIGDIGEST_ERROR                         172\n#  define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE          162\n#  define CMS_R_MSGSIGDIGEST_WRONG_LENGTH                  163\n#  define CMS_R_NEED_ONE_SIGNER                            164\n#  define CMS_R_NOT_A_SIGNED_RECEIPT                       165\n#  define CMS_R_NOT_ENCRYPTED_DATA                         122\n#  define CMS_R_NOT_KEK                                    123\n#  define CMS_R_NOT_KEY_AGREEMENT                          181\n#  define CMS_R_NOT_KEY_TRANSPORT                          124\n#  define CMS_R_NOT_PWRI                                   177\n#  define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE            125\n#  define CMS_R_NO_CIPHER                                  126\n#  define CMS_R_NO_CONTENT                                 127\n#  define CMS_R_NO_CONTENT_TYPE                            173\n#  define CMS_R_NO_DEFAULT_DIGEST                          128\n#  define CMS_R_NO_DIGEST_SET                              129\n#  define CMS_R_NO_KEY                                     130\n#  define CMS_R_NO_KEY_OR_CERT                             174\n#  define CMS_R_NO_MATCHING_DIGEST                         131\n#  define CMS_R_NO_MATCHING_RECIPIENT                      132\n#  define CMS_R_NO_MATCHING_SIGNATURE                      166\n#  define CMS_R_NO_MSGSIGDIGEST                            167\n#  define CMS_R_NO_PASSWORD                                178\n#  define CMS_R_NO_PRIVATE_KEY                             133\n#  define CMS_R_NO_PUBLIC_KEY                              134\n#  define CMS_R_NO_RECEIPT_REQUEST                         168\n#  define CMS_R_NO_SIGNERS                                 135\n#  define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE     136\n#  define CMS_R_RECEIPT_DECODE_ERROR                       169\n#  define CMS_R_RECIPIENT_ERROR                            137\n#  define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND               138\n#  define CMS_R_SIGNFINAL_ERROR                            139\n#  define CMS_R_SMIME_TEXT_ERROR                           140\n#  define CMS_R_STORE_INIT_ERROR                           141\n#  define CMS_R_TYPE_NOT_COMPRESSED_DATA                   142\n#  define CMS_R_TYPE_NOT_DATA                              143\n#  define CMS_R_TYPE_NOT_DIGESTED_DATA                     144\n#  define CMS_R_TYPE_NOT_ENCRYPTED_DATA                    145\n#  define CMS_R_TYPE_NOT_ENVELOPED_DATA                    146\n#  define CMS_R_UNABLE_TO_FINALIZE_CONTEXT                 147\n#  define CMS_R_UNKNOWN_CIPHER                             148\n#  define CMS_R_UNKNOWN_DIGEST_ALGORITHM                   149\n#  define CMS_R_UNKNOWN_ID                                 150\n#  define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM          151\n#  define CMS_R_UNSUPPORTED_CONTENT_TYPE                   152\n#  define CMS_R_UNSUPPORTED_KEK_ALGORITHM                  153\n#  define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM       179\n#  define CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE             155\n#  define CMS_R_UNSUPPORTED_RECIPIENT_TYPE                 154\n#  define CMS_R_UNSUPPORTED_TYPE                           156\n#  define CMS_R_UNWRAP_ERROR                               157\n#  define CMS_R_UNWRAP_FAILURE                             180\n#  define CMS_R_VERIFICATION_FAILURE                       158\n#  define CMS_R_WRAP_ERROR                                 159\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/comp.h",
    "content": "/*\n * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_COMP_H\n# define HEADER_COMP_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_COMP\n# include <openssl/crypto.h>\n# include <openssl/comperr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n\n\nCOMP_CTX *COMP_CTX_new(COMP_METHOD *meth);\nconst COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx);\nint COMP_CTX_get_type(const COMP_CTX* comp);\nint COMP_get_type(const COMP_METHOD *meth);\nconst char *COMP_get_name(const COMP_METHOD *meth);\nvoid COMP_CTX_free(COMP_CTX *ctx);\n\nint COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,\n                        unsigned char *in, int ilen);\nint COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,\n                      unsigned char *in, int ilen);\n\nCOMP_METHOD *COMP_zlib(void);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n#define COMP_zlib_cleanup() while(0) continue\n#endif\n\n# ifdef HEADER_BIO_H\n#  ifdef ZLIB\nconst BIO_METHOD *BIO_f_zlib(void);\n#  endif\n# endif\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/comperr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_COMPERR_H\n# define HEADER_COMPERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_COMP\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_COMP_strings(void);\n\n/*\n * COMP function codes.\n */\n#  define COMP_F_BIO_ZLIB_FLUSH                            99\n#  define COMP_F_BIO_ZLIB_NEW                              100\n#  define COMP_F_BIO_ZLIB_READ                             101\n#  define COMP_F_BIO_ZLIB_WRITE                            102\n#  define COMP_F_COMP_CTX_NEW                              103\n\n/*\n * COMP reason codes.\n */\n#  define COMP_R_ZLIB_DEFLATE_ERROR                        99\n#  define COMP_R_ZLIB_INFLATE_ERROR                        100\n#  define COMP_R_ZLIB_NOT_SUPPORTED                        101\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/conf.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef  HEADER_CONF_H\n# define HEADER_CONF_H\n\n# include <openssl/bio.h>\n# include <openssl/lhash.h>\n# include <openssl/safestack.h>\n# include <openssl/e_os2.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/conferr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct {\n    char *section;\n    char *name;\n    char *value;\n} CONF_VALUE;\n\nDEFINE_STACK_OF(CONF_VALUE)\nDEFINE_LHASH_OF(CONF_VALUE);\n\nstruct conf_st;\nstruct conf_method_st;\ntypedef struct conf_method_st CONF_METHOD;\n\nstruct conf_method_st {\n    const char *name;\n    CONF *(*create) (CONF_METHOD *meth);\n    int (*init) (CONF *conf);\n    int (*destroy) (CONF *conf);\n    int (*destroy_data) (CONF *conf);\n    int (*load_bio) (CONF *conf, BIO *bp, long *eline);\n    int (*dump) (const CONF *conf, BIO *bp);\n    int (*is_number) (const CONF *conf, char c);\n    int (*to_int) (const CONF *conf, char c);\n    int (*load) (CONF *conf, const char *name, long *eline);\n};\n\n/* Module definitions */\n\ntypedef struct conf_imodule_st CONF_IMODULE;\ntypedef struct conf_module_st CONF_MODULE;\n\nDEFINE_STACK_OF(CONF_MODULE)\nDEFINE_STACK_OF(CONF_IMODULE)\n\n/* DSO module function typedefs */\ntypedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf);\ntypedef void conf_finish_func (CONF_IMODULE *md);\n\n# define CONF_MFLAGS_IGNORE_ERRORS       0x1\n# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2\n# define CONF_MFLAGS_SILENT              0x4\n# define CONF_MFLAGS_NO_DSO              0x8\n# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10\n# define CONF_MFLAGS_DEFAULT_SECTION     0x20\n\nint CONF_set_default_method(CONF_METHOD *meth);\nvoid CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash);\nLHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,\n                                long *eline);\n# ifndef OPENSSL_NO_STDIO\nLHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,\n                                   long *eline);\n# endif\nLHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp,\n                                    long *eline);\nSTACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf,\n                                       const char *section);\nchar *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                      const char *name);\nlong CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group,\n                     const char *name);\nvoid CONF_free(LHASH_OF(CONF_VALUE) *conf);\n#ifndef OPENSSL_NO_STDIO\nint CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out);\n#endif\nint CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out);\n\nDEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name))\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define OPENSSL_no_config() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL)\n#endif\n\n/*\n * New conf code.  The semantics are different from the functions above. If\n * that wasn't the case, the above functions would have been replaced\n */\n\nstruct conf_st {\n    CONF_METHOD *meth;\n    void *meth_data;\n    LHASH_OF(CONF_VALUE) *data;\n};\n\nCONF *NCONF_new(CONF_METHOD *meth);\nCONF_METHOD *NCONF_default(void);\nCONF_METHOD *NCONF_WIN32(void);\nvoid NCONF_free(CONF *conf);\nvoid NCONF_free_data(CONF *conf);\n\nint NCONF_load(CONF *conf, const char *file, long *eline);\n# ifndef OPENSSL_NO_STDIO\nint NCONF_load_fp(CONF *conf, FILE *fp, long *eline);\n# endif\nint NCONF_load_bio(CONF *conf, BIO *bp, long *eline);\nSTACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf,\n                                        const char *section);\nchar *NCONF_get_string(const CONF *conf, const char *group, const char *name);\nint NCONF_get_number_e(const CONF *conf, const char *group, const char *name,\n                       long *result);\n#ifndef OPENSSL_NO_STDIO\nint NCONF_dump_fp(const CONF *conf, FILE *out);\n#endif\nint NCONF_dump_bio(const CONF *conf, BIO *out);\n\n#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r)\n\n/* Module functions */\n\nint CONF_modules_load(const CONF *cnf, const char *appname,\n                      unsigned long flags);\nint CONF_modules_load_file(const char *filename, const char *appname,\n                           unsigned long flags);\nvoid CONF_modules_unload(int all);\nvoid CONF_modules_finish(void);\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define CONF_modules_free() while(0) continue\n#endif\nint CONF_module_add(const char *name, conf_init_func *ifunc,\n                    conf_finish_func *ffunc);\n\nconst char *CONF_imodule_get_name(const CONF_IMODULE *md);\nconst char *CONF_imodule_get_value(const CONF_IMODULE *md);\nvoid *CONF_imodule_get_usr_data(const CONF_IMODULE *md);\nvoid CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data);\nCONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md);\nunsigned long CONF_imodule_get_flags(const CONF_IMODULE *md);\nvoid CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags);\nvoid *CONF_module_get_usr_data(CONF_MODULE *pmod);\nvoid CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data);\n\nchar *CONF_get1_default_config_file(void);\n\nint CONF_parse_list(const char *list, int sep, int nospc,\n                    int (*list_cb) (const char *elem, int len, void *usr),\n                    void *arg);\n\nvoid OPENSSL_load_builtin_modules(void);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/conf_api.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef  HEADER_CONF_API_H\n# define HEADER_CONF_API_H\n\n# include <openssl/lhash.h>\n# include <openssl/conf.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Up until OpenSSL 0.9.5a, this was new_section */\nCONF_VALUE *_CONF_new_section(CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was get_section */\nCONF_VALUE *_CONF_get_section(const CONF *conf, const char *section);\n/* Up until OpenSSL 0.9.5a, this was CONF_get_section */\nSTACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf,\n                                               const char *section);\n\nint _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value);\nchar *_CONF_get_string(const CONF *conf, const char *section,\n                       const char *name);\nlong _CONF_get_number(const CONF *conf, const char *section,\n                      const char *name);\n\nint _CONF_new_data(CONF *conf);\nvoid _CONF_free_data(CONF *conf);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/conferr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CONFERR_H\n# define HEADER_CONFERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_CONF_strings(void);\n\n/*\n * CONF function codes.\n */\n# define CONF_F_CONF_DUMP_FP                              104\n# define CONF_F_CONF_LOAD                                 100\n# define CONF_F_CONF_LOAD_FP                              103\n# define CONF_F_CONF_PARSE_LIST                           119\n# define CONF_F_DEF_LOAD                                  120\n# define CONF_F_DEF_LOAD_BIO                              121\n# define CONF_F_GET_NEXT_FILE                             107\n# define CONF_F_MODULE_ADD                                122\n# define CONF_F_MODULE_INIT                               115\n# define CONF_F_MODULE_LOAD_DSO                           117\n# define CONF_F_MODULE_RUN                                118\n# define CONF_F_NCONF_DUMP_BIO                            105\n# define CONF_F_NCONF_DUMP_FP                             106\n# define CONF_F_NCONF_GET_NUMBER_E                        112\n# define CONF_F_NCONF_GET_SECTION                         108\n# define CONF_F_NCONF_GET_STRING                          109\n# define CONF_F_NCONF_LOAD                                113\n# define CONF_F_NCONF_LOAD_BIO                            110\n# define CONF_F_NCONF_LOAD_FP                             114\n# define CONF_F_NCONF_NEW                                 111\n# define CONF_F_PROCESS_INCLUDE                           116\n# define CONF_F_SSL_MODULE_INIT                           123\n# define CONF_F_STR_COPY                                  101\n\n/*\n * CONF reason codes.\n */\n# define CONF_R_ERROR_LOADING_DSO                         110\n# define CONF_R_LIST_CANNOT_BE_NULL                       115\n# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET              100\n# define CONF_R_MISSING_EQUAL_SIGN                        101\n# define CONF_R_MISSING_INIT_FUNCTION                     112\n# define CONF_R_MODULE_INITIALIZATION_ERROR               109\n# define CONF_R_NO_CLOSE_BRACE                            102\n# define CONF_R_NO_CONF                                   105\n# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE           106\n# define CONF_R_NO_SECTION                                107\n# define CONF_R_NO_SUCH_FILE                              114\n# define CONF_R_NO_VALUE                                  108\n# define CONF_R_NUMBER_TOO_LARGE                          121\n# define CONF_R_RECURSIVE_DIRECTORY_INCLUDE               111\n# define CONF_R_SSL_COMMAND_SECTION_EMPTY                 117\n# define CONF_R_SSL_COMMAND_SECTION_NOT_FOUND             118\n# define CONF_R_SSL_SECTION_EMPTY                         119\n# define CONF_R_SSL_SECTION_NOT_FOUND                     120\n# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION              103\n# define CONF_R_UNKNOWN_MODULE_NAME                       113\n# define CONF_R_VARIABLE_EXPANSION_TOO_LONG               116\n# define CONF_R_VARIABLE_HAS_NO_VALUE                     104\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/crypto.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CRYPTO_H\n# define HEADER_CRYPTO_H\n\n# include <stdlib.h>\n# include <time.h>\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_STDIO\n#  include <stdio.h>\n# endif\n\n# include <openssl/safestack.h>\n# include <openssl/opensslv.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/opensslconf.h>\n# include <openssl/cryptoerr.h>\n\n# ifdef CHARSET_EBCDIC\n#  include <openssl/ebcdic.h>\n# endif\n\n/*\n * Resolve problems on some operating systems with symbol names that clash\n * one way or another\n */\n# include <openssl/symhacks.h>\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/opensslv.h>\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSLeay                  OpenSSL_version_num\n#  define SSLeay_version          OpenSSL_version\n#  define SSLEAY_VERSION_NUMBER   OPENSSL_VERSION_NUMBER\n#  define SSLEAY_VERSION          OPENSSL_VERSION\n#  define SSLEAY_CFLAGS           OPENSSL_CFLAGS\n#  define SSLEAY_BUILT_ON         OPENSSL_BUILT_ON\n#  define SSLEAY_PLATFORM         OPENSSL_PLATFORM\n#  define SSLEAY_DIR              OPENSSL_DIR\n\n/*\n * Old type for allocating dynamic locks. No longer used. Use the new thread\n * API instead.\n */\ntypedef struct {\n    int dummy;\n} CRYPTO_dynlock;\n\n# endif /* OPENSSL_API_COMPAT */\n\ntypedef void CRYPTO_RWLOCK;\n\nCRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void);\nint CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock);\nint CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock);\nint CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock);\nvoid CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock);\n\nint CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock);\n\n/*\n * The following can be used to detect memory leaks in the library. If\n * used, it turns on malloc checking\n */\n# define CRYPTO_MEM_CHECK_OFF     0x0   /* Control only */\n# define CRYPTO_MEM_CHECK_ON      0x1   /* Control and mode bit */\n# define CRYPTO_MEM_CHECK_ENABLE  0x2   /* Control and mode bit */\n# define CRYPTO_MEM_CHECK_DISABLE 0x3   /* Control only */\n\nstruct crypto_ex_data_st {\n    STACK_OF(void) *sk;\n};\nDEFINE_STACK_OF(void)\n\n/*\n * Per class, we have a STACK of function pointers.\n */\n# define CRYPTO_EX_INDEX_SSL              0\n# define CRYPTO_EX_INDEX_SSL_CTX          1\n# define CRYPTO_EX_INDEX_SSL_SESSION      2\n# define CRYPTO_EX_INDEX_X509             3\n# define CRYPTO_EX_INDEX_X509_STORE       4\n# define CRYPTO_EX_INDEX_X509_STORE_CTX   5\n# define CRYPTO_EX_INDEX_DH               6\n# define CRYPTO_EX_INDEX_DSA              7\n# define CRYPTO_EX_INDEX_EC_KEY           8\n# define CRYPTO_EX_INDEX_RSA              9\n# define CRYPTO_EX_INDEX_ENGINE          10\n# define CRYPTO_EX_INDEX_UI              11\n# define CRYPTO_EX_INDEX_BIO             12\n# define CRYPTO_EX_INDEX_APP             13\n# define CRYPTO_EX_INDEX_UI_METHOD       14\n# define CRYPTO_EX_INDEX_DRBG            15\n# define CRYPTO_EX_INDEX__COUNT          16\n\n/* No longer needed, so this is a no-op */\n#define OPENSSL_malloc_init() while(0) continue\n\nint CRYPTO_mem_ctrl(int mode);\n\n# define OPENSSL_malloc(num) \\\n        CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_zalloc(num) \\\n        CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)\n// # define OPENSSL_realloc(addr, num) \n//         CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_clear_realloc(addr, old_num, num) \\\n        CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_clear_free(addr, num) \\\n        CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_free(addr) \\\n        CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_memdup(str, s) \\\n        CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_strdup(str) \\\n        CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_strndup(str, n) \\\n        CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_malloc(num) \\\n        CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_zalloc(num) \\\n        CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_free(addr) \\\n        CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_clear_free(addr, num) \\\n        CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)\n# define OPENSSL_secure_actual_size(ptr) \\\n        CRYPTO_secure_actual_size(ptr)\n\nsize_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz);\nsize_t OPENSSL_strlcat(char *dst, const char *src, size_t siz);\nsize_t OPENSSL_strnlen(const char *str, size_t maxlen);\nchar *OPENSSL_buf2hexstr(const unsigned char *buffer, long len);\nunsigned char *OPENSSL_hexstr2buf(const char *str, long *len);\nint OPENSSL_hexchar2int(unsigned char c);\n\n# define OPENSSL_MALLOC_MAX_NELEMS(type)  (((1U<<(sizeof(int)*8-1))-1)/sizeof(type))\n\nunsigned long OpenSSL_version_num(void);\nconst char *OpenSSL_version(int type);\n# define OPENSSL_VERSION          0\n# define OPENSSL_CFLAGS           1\n# define OPENSSL_BUILT_ON         2\n# define OPENSSL_PLATFORM         3\n# define OPENSSL_DIR              4\n# define OPENSSL_ENGINES_DIR      5\n\nint OPENSSL_issetugid(void);\n\ntypedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                           int idx, long argl, void *argp);\ntypedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,\n                             int idx, long argl, void *argp);\ntypedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,\n                           void *from_d, int idx, long argl, void *argp);\n__owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,\n                            CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,\n                            CRYPTO_EX_free *free_func);\n/* No longer use an index. */\nint CRYPTO_free_ex_index(int class_index, int idx);\n\n/*\n * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a\n * given class (invokes whatever per-class callbacks are applicable)\n */\nint CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\nint CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,\n                       const CRYPTO_EX_DATA *from);\n\nvoid CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);\n\n/*\n * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular\n * index (relative to the class type involved)\n */\nint CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);\nvoid *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * This function cleans up all \"ex_data\" state. It mustn't be called under\n * potential race-conditions.\n */\n# define CRYPTO_cleanup_all_ex_data() while(0) continue\n\n/*\n * The old locking functions have been removed completely without compatibility\n * macros. This is because the old functions either could not properly report\n * errors, or the returned error values were not clearly documented.\n * Replacing the locking functions with no-ops would cause race condition\n * issues in the affected applications. It is far better for them to fail at\n * compile time.\n * On the other hand, the locking callbacks are no longer used.  Consequently,\n * the callback management functions can be safely replaced with no-op macros.\n */\n#  define CRYPTO_num_locks()            (1)\n#  define CRYPTO_set_locking_callback(func)\n#  define CRYPTO_get_locking_callback()         (NULL)\n#  define CRYPTO_set_add_lock_callback(func)\n#  define CRYPTO_get_add_lock_callback()        (NULL)\n\n/*\n * These defines where used in combination with the old locking callbacks,\n * they are not called anymore, but old code that's not called might still\n * use them.\n */\n#  define CRYPTO_LOCK             1\n#  define CRYPTO_UNLOCK           2\n#  define CRYPTO_READ             4\n#  define CRYPTO_WRITE            8\n\n/* This structure is no longer used */\ntypedef struct crypto_threadid_st {\n    int dummy;\n} CRYPTO_THREADID;\n/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */\n#  define CRYPTO_THREADID_set_numeric(id, val)\n#  define CRYPTO_THREADID_set_pointer(id, ptr)\n#  define CRYPTO_THREADID_set_callback(threadid_func)   (0)\n#  define CRYPTO_THREADID_get_callback()                (NULL)\n#  define CRYPTO_THREADID_current(id)\n#  define CRYPTO_THREADID_cmp(a, b)                     (-1)\n#  define CRYPTO_THREADID_cpy(dest, src)\n#  define CRYPTO_THREADID_hash(id)                      (0UL)\n\n#  if OPENSSL_API_COMPAT < 0x10000000L\n#   define CRYPTO_set_id_callback(func)\n#   define CRYPTO_get_id_callback()                     (NULL)\n#   define CRYPTO_thread_id()                           (0UL)\n#  endif /* OPENSSL_API_COMPAT < 0x10000000L */\n\n#  define CRYPTO_set_dynlock_create_callback(dyn_create_function)\n#  define CRYPTO_set_dynlock_lock_callback(dyn_lock_function)\n#  define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function)\n#  define CRYPTO_get_dynlock_create_callback()          (NULL)\n#  define CRYPTO_get_dynlock_lock_callback()            (NULL)\n#  define CRYPTO_get_dynlock_destroy_callback()         (NULL)\n# endif /* OPENSSL_API_COMPAT < 0x10100000L */\n\nint CRYPTO_set_mem_functions(\n        void *(*m) (size_t, const char *, int),\n        void *(*r) (void *, size_t, const char *, int),\n        void (*f) (void *, const char *, int));\nint CRYPTO_set_mem_debug(int flag);\nvoid CRYPTO_get_mem_functions(\n        void *(**m) (size_t, const char *, int),\n        void *(**r) (void *, size_t, const char *, int),\n        void (**f) (void *, const char *, int));\n\nvoid *CRYPTO_malloc(size_t num, const char *file, int line);\nvoid *CRYPTO_zalloc(size_t num, const char *file, int line);\nvoid *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line);\nchar *CRYPTO_strdup(const char *str, const char *file, int line);\nchar *CRYPTO_strndup(const char *str, size_t s, const char *file, int line);\nvoid CRYPTO_free(void *ptr, const char *file, int line);\nvoid CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line);\nvoid *CRYPTO_realloc(void *addr, size_t num, const char *file, int line);\nvoid *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num,\n                           const char *file, int line);\n\nint CRYPTO_secure_malloc_init(size_t sz, int minsize);\nint CRYPTO_secure_malloc_done(void);\nvoid *CRYPTO_secure_malloc(size_t num, const char *file, int line);\nvoid *CRYPTO_secure_zalloc(size_t num, const char *file, int line);\nvoid CRYPTO_secure_free(void *ptr, const char *file, int line);\nvoid CRYPTO_secure_clear_free(void *ptr, size_t num,\n                              const char *file, int line);\nint CRYPTO_secure_allocated(const void *ptr);\nint CRYPTO_secure_malloc_initialized(void);\nsize_t CRYPTO_secure_actual_size(void *ptr);\nsize_t CRYPTO_secure_used(void);\n\nvoid OPENSSL_cleanse(void *ptr, size_t len);\n\n# ifndef OPENSSL_NO_CRYPTO_MDEBUG\n#  define OPENSSL_mem_debug_push(info) \\\n        CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE)\n#  define OPENSSL_mem_debug_pop() \\\n        CRYPTO_mem_debug_pop()\nint CRYPTO_mem_debug_push(const char *info, const char *file, int line);\nint CRYPTO_mem_debug_pop(void);\nvoid CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount);\n\n/*-\n * Debugging functions (enabled by CRYPTO_set_mem_debug(1))\n * The flag argument has the following significance:\n *   0:   called before the actual memory allocation has taken place\n *   1:   called after the actual memory allocation has taken place\n */\nvoid CRYPTO_mem_debug_malloc(void *addr, size_t num, int flag,\n        const char *file, int line);\nvoid CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num, int flag,\n        const char *file, int line);\nvoid CRYPTO_mem_debug_free(void *addr, int flag,\n        const char *file, int line);\n\nint CRYPTO_mem_leaks_cb(int (*cb) (const char *str, size_t len, void *u),\n                        void *u);\n#  ifndef OPENSSL_NO_STDIO\nint CRYPTO_mem_leaks_fp(FILE *);\n#  endif\nint CRYPTO_mem_leaks(BIO *bio);\n# endif\n\n/* die if we have to */\nossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line);\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l))\n# endif\n# define OPENSSL_assert(e) \\\n    (void)((e) ? 0 : (OPENSSL_die(\"assertion failed: \" #e, OPENSSL_FILE, OPENSSL_LINE), 1))\n\nint OPENSSL_isservice(void);\n\nint FIPS_mode(void);\nint FIPS_mode_set(int r);\n\nvoid OPENSSL_init(void);\n# ifdef OPENSSL_SYS_UNIX\nvoid OPENSSL_fork_prepare(void);\nvoid OPENSSL_fork_parent(void);\nvoid OPENSSL_fork_child(void);\n# endif\n\nstruct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);\nint OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);\nint OPENSSL_gmtime_diff(int *pday, int *psec,\n                        const struct tm *from, const struct tm *to);\n\n/*\n * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.\n * It takes an amount of time dependent on |len|, but independent of the\n * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements\n * into a defined order as the return value when a != b is undefined, other\n * than to be non-zero.\n */\nint CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len);\n\n/* Standard initialisation options */\n# define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L\n# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS    0x00000002L\n# define OPENSSL_INIT_ADD_ALL_CIPHERS        0x00000004L\n# define OPENSSL_INIT_ADD_ALL_DIGESTS        0x00000008L\n# define OPENSSL_INIT_NO_ADD_ALL_CIPHERS     0x00000010L\n# define OPENSSL_INIT_NO_ADD_ALL_DIGESTS     0x00000020L\n# define OPENSSL_INIT_LOAD_CONFIG            0x00000040L\n# define OPENSSL_INIT_NO_LOAD_CONFIG         0x00000080L\n# define OPENSSL_INIT_ASYNC                  0x00000100L\n# define OPENSSL_INIT_ENGINE_RDRAND          0x00000200L\n# define OPENSSL_INIT_ENGINE_DYNAMIC         0x00000400L\n# define OPENSSL_INIT_ENGINE_OPENSSL         0x00000800L\n# define OPENSSL_INIT_ENGINE_CRYPTODEV       0x00001000L\n# define OPENSSL_INIT_ENGINE_CAPI            0x00002000L\n# define OPENSSL_INIT_ENGINE_PADLOCK         0x00004000L\n# define OPENSSL_INIT_ENGINE_AFALG           0x00008000L\n/* OPENSSL_INIT_ZLIB                         0x00010000L */\n# define OPENSSL_INIT_ATFORK                 0x00020000L\n/* OPENSSL_INIT_BASE_ONLY                    0x00040000L */\n# define OPENSSL_INIT_NO_ATEXIT              0x00080000L\n/* OPENSSL_INIT flag range 0xfff00000 reserved for OPENSSL_init_ssl() */\n/* Max OPENSSL_INIT flag value is 0x80000000 */\n\n/* openssl and dasync not counted as builtin */\n# define OPENSSL_INIT_ENGINE_ALL_BUILTIN \\\n    (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \\\n    | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \\\n    OPENSSL_INIT_ENGINE_PADLOCK)\n\n\n/* Library initialisation functions */\nvoid OPENSSL_cleanup(void);\nint OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);\nint OPENSSL_atexit(void (*handler)(void));\nvoid OPENSSL_thread_stop(void);\n\n/* Low-level control of initialization */\nOPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void);\n# ifndef OPENSSL_NO_STDIO\nint OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,\n                                     const char *config_filename);\nvoid OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings,\n                                        unsigned long flags);\nint OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings,\n                                    const char *config_appname);\n# endif\nvoid OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings);\n\n# if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG)\n#  if defined(_WIN32)\n#   if defined(BASETYPES) || defined(_WINDEF_H)\n/* application has to include <windows.h> in order to use this */\ntypedef DWORD CRYPTO_THREAD_LOCAL;\ntypedef DWORD CRYPTO_THREAD_ID;\n\ntypedef LONG CRYPTO_ONCE;\n#    define CRYPTO_ONCE_STATIC_INIT 0\n#   endif\n#  else\n#   include <pthread.h>\ntypedef pthread_once_t CRYPTO_ONCE;\ntypedef pthread_key_t CRYPTO_THREAD_LOCAL;\ntypedef pthread_t CRYPTO_THREAD_ID;\n\n#   define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT\n#  endif\n# endif\n\n# if !defined(CRYPTO_ONCE_STATIC_INIT)\ntypedef unsigned int CRYPTO_ONCE;\ntypedef unsigned int CRYPTO_THREAD_LOCAL;\ntypedef unsigned int CRYPTO_THREAD_ID;\n#  define CRYPTO_ONCE_STATIC_INIT 0\n# endif\n\nint CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void));\n\nint CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *));\nvoid *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key);\nint CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val);\nint CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key);\n\nCRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void);\nint CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/cryptoerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CRYPTOERR_H\n# define HEADER_CRYPTOERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_CRYPTO_strings(void);\n\n/*\n * CRYPTO function codes.\n */\n# define CRYPTO_F_CMAC_CTX_NEW                            120\n# define CRYPTO_F_CRYPTO_DUP_EX_DATA                      110\n# define CRYPTO_F_CRYPTO_FREE_EX_DATA                     111\n# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX                 100\n# define CRYPTO_F_CRYPTO_MEMDUP                           115\n# define CRYPTO_F_CRYPTO_NEW_EX_DATA                      112\n# define CRYPTO_F_CRYPTO_OCB128_COPY_CTX                  121\n# define CRYPTO_F_CRYPTO_OCB128_INIT                      122\n# define CRYPTO_F_CRYPTO_SET_EX_DATA                      102\n# define CRYPTO_F_FIPS_MODE_SET                           109\n# define CRYPTO_F_GET_AND_LOCK                            113\n# define CRYPTO_F_OPENSSL_ATEXIT                          114\n# define CRYPTO_F_OPENSSL_BUF2HEXSTR                      117\n# define CRYPTO_F_OPENSSL_FOPEN                           119\n# define CRYPTO_F_OPENSSL_HEXSTR2BUF                      118\n# define CRYPTO_F_OPENSSL_INIT_CRYPTO                     116\n# define CRYPTO_F_OPENSSL_LH_NEW                          126\n# define CRYPTO_F_OPENSSL_SK_DEEP_COPY                    127\n# define CRYPTO_F_OPENSSL_SK_DUP                          128\n# define CRYPTO_F_PKEY_HMAC_INIT                          123\n# define CRYPTO_F_PKEY_POLY1305_INIT                      124\n# define CRYPTO_F_PKEY_SIPHASH_INIT                       125\n# define CRYPTO_F_SK_RESERVE                              129\n\n/*\n * CRYPTO reason codes.\n */\n# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED                 101\n# define CRYPTO_R_ILLEGAL_HEX_DIGIT                       102\n# define CRYPTO_R_ODD_NUMBER_OF_DIGITS                    103\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ct.h",
    "content": "/*\n * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CT_H\n# define HEADER_CT_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CT\n# include <openssl/ossl_typ.h>\n# include <openssl/safestack.h>\n# include <openssl/x509.h>\n# include <openssl/cterr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n\n/* Minimum RSA key size, from RFC6962 */\n# define SCT_MIN_RSA_BITS 2048\n\n/* All hashes are SHA256 in v1 of Certificate Transparency */\n# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH\n\ntypedef enum {\n    CT_LOG_ENTRY_TYPE_NOT_SET = -1,\n    CT_LOG_ENTRY_TYPE_X509 = 0,\n    CT_LOG_ENTRY_TYPE_PRECERT = 1\n} ct_log_entry_type_t;\n\ntypedef enum {\n    SCT_VERSION_NOT_SET = -1,\n    SCT_VERSION_V1 = 0\n} sct_version_t;\n\ntypedef enum {\n    SCT_SOURCE_UNKNOWN,\n    SCT_SOURCE_TLS_EXTENSION,\n    SCT_SOURCE_X509V3_EXTENSION,\n    SCT_SOURCE_OCSP_STAPLED_RESPONSE\n} sct_source_t;\n\ntypedef enum {\n    SCT_VALIDATION_STATUS_NOT_SET,\n    SCT_VALIDATION_STATUS_UNKNOWN_LOG,\n    SCT_VALIDATION_STATUS_VALID,\n    SCT_VALIDATION_STATUS_INVALID,\n    SCT_VALIDATION_STATUS_UNVERIFIED,\n    SCT_VALIDATION_STATUS_UNKNOWN_VERSION\n} sct_validation_status_t;\n\nDEFINE_STACK_OF(SCT)\nDEFINE_STACK_OF(CTLOG)\n\n/******************************************\n * CT policy evaluation context functions *\n ******************************************/\n\n/*\n * Creates a new, empty policy evaluation context.\n * The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished\n * with the CT_POLICY_EVAL_CTX.\n */\nCT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void);\n\n/* Deletes a policy evaluation context and anything it owns. */\nvoid CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx);\n\n/* Gets the peer certificate that the SCTs are for */\nX509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx);\n\n/*\n * Sets the certificate associated with the received SCTs.\n * Increments the reference count of cert.\n * Returns 1 on success, 0 otherwise.\n */\nint CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert);\n\n/* Gets the issuer of the aforementioned certificate */\nX509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx);\n\n/*\n * Sets the issuer of the certificate associated with the received SCTs.\n * Increments the reference count of issuer.\n * Returns 1 on success, 0 otherwise.\n */\nint CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer);\n\n/* Gets the CT logs that are trusted sources of SCTs */\nconst CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx);\n\n/* Sets the log store that is in use. It must outlive the CT_POLICY_EVAL_CTX. */\nvoid CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx,\n                                               CTLOG_STORE *log_store);\n\n/*\n * Gets the time, in milliseconds since the Unix epoch, that will be used as the\n * current time when checking whether an SCT was issued in the future.\n * Such SCTs will fail validation, as required by RFC6962.\n */\nuint64_t CT_POLICY_EVAL_CTX_get_time(const CT_POLICY_EVAL_CTX *ctx);\n\n/*\n * Sets the time to evaluate SCTs against, in milliseconds since the Unix epoch.\n * If an SCT's timestamp is after this time, it will be interpreted as having\n * been issued in the future. RFC6962 states that \"TLS clients MUST reject SCTs\n * whose timestamp is in the future\", so an SCT will not validate in this case.\n */\nvoid CT_POLICY_EVAL_CTX_set_time(CT_POLICY_EVAL_CTX *ctx, uint64_t time_in_ms);\n\n/*****************\n * SCT functions *\n *****************/\n\n/*\n * Creates a new, blank SCT.\n * The caller is responsible for calling SCT_free when finished with the SCT.\n */\nSCT *SCT_new(void);\n\n/*\n * Creates a new SCT from some base64-encoded strings.\n * The caller is responsible for calling SCT_free when finished with the SCT.\n */\nSCT *SCT_new_from_base64(unsigned char version,\n                         const char *logid_base64,\n                         ct_log_entry_type_t entry_type,\n                         uint64_t timestamp,\n                         const char *extensions_base64,\n                         const char *signature_base64);\n\n/*\n * Frees the SCT and the underlying data structures.\n */\nvoid SCT_free(SCT *sct);\n\n/*\n * Free a stack of SCTs, and the underlying SCTs themselves.\n * Intended to be compatible with X509V3_EXT_FREE.\n */\nvoid SCT_LIST_free(STACK_OF(SCT) *a);\n\n/*\n * Returns the version of the SCT.\n */\nsct_version_t SCT_get_version(const SCT *sct);\n\n/*\n * Set the version of an SCT.\n * Returns 1 on success, 0 if the version is unrecognized.\n */\n__owur int SCT_set_version(SCT *sct, sct_version_t version);\n\n/*\n * Returns the log entry type of the SCT.\n */\nct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct);\n\n/*\n * Set the log entry type of an SCT.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type);\n\n/*\n * Gets the ID of the log that an SCT came from.\n * Ownership of the log ID remains with the SCT.\n * Returns the length of the log ID.\n */\nsize_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id);\n\n/*\n * Set the log ID of an SCT to point directly to the *log_id specified.\n * The SCT takes ownership of the specified pointer.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len);\n\n/*\n * Set the log ID of an SCT.\n * This makes a copy of the log_id.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id,\n                           size_t log_id_len);\n\n/*\n * Returns the timestamp for the SCT (epoch time in milliseconds).\n */\nuint64_t SCT_get_timestamp(const SCT *sct);\n\n/*\n * Set the timestamp of an SCT (epoch time in milliseconds).\n */\nvoid SCT_set_timestamp(SCT *sct, uint64_t timestamp);\n\n/*\n * Return the NID for the signature used by the SCT.\n * For CT v1, this will be either NID_sha256WithRSAEncryption or\n * NID_ecdsa_with_SHA256 (or NID_undef if incorrect/unset).\n */\nint SCT_get_signature_nid(const SCT *sct);\n\n/*\n * Set the signature type of an SCT\n * For CT v1, this should be either NID_sha256WithRSAEncryption or\n * NID_ecdsa_with_SHA256.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set_signature_nid(SCT *sct, int nid);\n\n/*\n * Set *ext to point to the extension data for the SCT. ext must not be NULL.\n * The SCT retains ownership of this pointer.\n * Returns length of the data pointed to.\n */\nsize_t SCT_get0_extensions(const SCT *sct, unsigned char **ext);\n\n/*\n * Set the extensions of an SCT to point directly to the *ext specified.\n * The SCT takes ownership of the specified pointer.\n */\nvoid SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len);\n\n/*\n * Set the extensions of an SCT.\n * This takes a copy of the ext.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext,\n                               size_t ext_len);\n\n/*\n * Set *sig to point to the signature for the SCT. sig must not be NULL.\n * The SCT retains ownership of this pointer.\n * Returns length of the data pointed to.\n */\nsize_t SCT_get0_signature(const SCT *sct, unsigned char **sig);\n\n/*\n * Set the signature of an SCT to point directly to the *sig specified.\n * The SCT takes ownership of the specified pointer.\n */\nvoid SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len);\n\n/*\n * Set the signature of an SCT to be a copy of the *sig specified.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig,\n                              size_t sig_len);\n\n/*\n * The origin of this SCT, e.g. TLS extension, OCSP response, etc.\n */\nsct_source_t SCT_get_source(const SCT *sct);\n\n/*\n * Set the origin of this SCT, e.g. TLS extension, OCSP response, etc.\n * Returns 1 on success, 0 otherwise.\n */\n__owur int SCT_set_source(SCT *sct, sct_source_t source);\n\n/*\n * Returns a text string describing the validation status of |sct|.\n */\nconst char *SCT_validation_status_string(const SCT *sct);\n\n/*\n * Pretty-prints an |sct| to |out|.\n * It will be indented by the number of spaces specified by |indent|.\n * If |logs| is not NULL, it will be used to lookup the CT log that the SCT came\n * from, so that the log name can be printed.\n */\nvoid SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs);\n\n/*\n * Pretty-prints an |sct_list| to |out|.\n * It will be indented by the number of spaces specified by |indent|.\n * SCTs will be delimited by |separator|.\n * If |logs| is not NULL, it will be used to lookup the CT log that each SCT\n * came from, so that the log names can be printed.\n */\nvoid SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent,\n                    const char *separator, const CTLOG_STORE *logs);\n\n/*\n * Gets the last result of validating this SCT.\n * If it has not been validated yet, returns SCT_VALIDATION_STATUS_NOT_SET.\n */\nsct_validation_status_t SCT_get_validation_status(const SCT *sct);\n\n/*\n * Validates the given SCT with the provided context.\n * Sets the \"validation_status\" field of the SCT.\n * Returns 1 if the SCT is valid and the signature verifies.\n * Returns 0 if the SCT is invalid or could not be verified.\n * Returns -1 if an error occurs.\n */\n__owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx);\n\n/*\n * Validates the given list of SCTs with the provided context.\n * Sets the \"validation_status\" field of each SCT.\n * Returns 1 if there are no invalid SCTs and all signatures verify.\n * Returns 0 if at least one SCT is invalid or could not be verified.\n * Returns a negative integer if an error occurs.\n */\n__owur int SCT_LIST_validate(const STACK_OF(SCT) *scts,\n                             CT_POLICY_EVAL_CTX *ctx);\n\n\n/*********************************\n * SCT parsing and serialisation *\n *********************************/\n\n/*\n * Serialize (to TLS format) a stack of SCTs and return the length.\n * \"a\" must not be NULL.\n * If \"pp\" is NULL, just return the length of what would have been serialized.\n * If \"pp\" is not NULL and \"*pp\" is null, function will allocate a new pointer\n * for data that caller is responsible for freeing (only if function returns\n * successfully).\n * If \"pp\" is NULL and \"*pp\" is not NULL, caller is responsible for ensuring\n * that \"*pp\" is large enough to accept all of the serialized data.\n * Returns < 0 on error, >= 0 indicating bytes written (or would have been)\n * on success.\n */\n__owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);\n\n/*\n * Convert TLS format SCT list to a stack of SCTs.\n * If \"a\" or \"*a\" is NULL, a new stack will be created that the caller is\n * responsible for freeing (by calling SCT_LIST_free).\n * \"**pp\" and \"*pp\" must not be NULL.\n * Upon success, \"*pp\" will point to after the last bytes read, and a stack\n * will be returned.\n * Upon failure, a NULL pointer will be returned, and the position of \"*pp\" is\n * not defined.\n */\nSTACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,\n                            size_t len);\n\n/*\n * Serialize (to DER format) a stack of SCTs and return the length.\n * \"a\" must not be NULL.\n * If \"pp\" is NULL, just returns the length of what would have been serialized.\n * If \"pp\" is not NULL and \"*pp\" is null, function will allocate a new pointer\n * for data that caller is responsible for freeing (only if function returns\n * successfully).\n * If \"pp\" is NULL and \"*pp\" is not NULL, caller is responsible for ensuring\n * that \"*pp\" is large enough to accept all of the serialized data.\n * Returns < 0 on error, >= 0 indicating bytes written (or would have been)\n * on success.\n */\n__owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);\n\n/*\n * Parses an SCT list in DER format and returns it.\n * If \"a\" or \"*a\" is NULL, a new stack will be created that the caller is\n * responsible for freeing (by calling SCT_LIST_free).\n * \"**pp\" and \"*pp\" must not be NULL.\n * Upon success, \"*pp\" will point to after the last bytes read, and a stack\n * will be returned.\n * Upon failure, a NULL pointer will be returned, and the position of \"*pp\" is\n * not defined.\n */\nSTACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,\n                            long len);\n\n/*\n * Serialize (to TLS format) an |sct| and write it to |out|.\n * If |out| is null, no SCT will be output but the length will still be returned.\n * If |out| points to a null pointer, a string will be allocated to hold the\n * TLS-format SCT. It is the responsibility of the caller to free it.\n * If |out| points to an allocated string, the TLS-format SCT will be written\n * to it.\n * The length of the SCT in TLS format will be returned.\n */\n__owur int i2o_SCT(const SCT *sct, unsigned char **out);\n\n/*\n * Parses an SCT in TLS format and returns it.\n * If |psct| is not null, it will end up pointing to the parsed SCT. If it\n * already points to a non-null pointer, the pointer will be free'd.\n * |in| should be a pointer to a string containing the TLS-format SCT.\n * |in| will be advanced to the end of the SCT if parsing succeeds.\n * |len| should be the length of the SCT in |in|.\n * Returns NULL if an error occurs.\n * If the SCT is an unsupported version, only the SCT's 'sct' and 'sct_len'\n * fields will be populated (with |in| and |len| respectively).\n */\nSCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len);\n\n/********************\n * CT log functions *\n ********************/\n\n/*\n * Creates a new CT log instance with the given |public_key| and |name|.\n * Takes ownership of |public_key| but copies |name|.\n * Returns NULL if malloc fails or if |public_key| cannot be converted to DER.\n * Should be deleted by the caller using CTLOG_free when no longer needed.\n */\nCTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name);\n\n/*\n * Creates a new CTLOG instance with the base64-encoded SubjectPublicKeyInfo DER\n * in |pkey_base64|. The |name| is a string to help users identify this log.\n * Returns 1 on success, 0 on failure.\n * Should be deleted by the caller using CTLOG_free when no longer needed.\n */\nint CTLOG_new_from_base64(CTLOG ** ct_log,\n                          const char *pkey_base64, const char *name);\n\n/*\n * Deletes a CT log instance and its fields.\n */\nvoid CTLOG_free(CTLOG *log);\n\n/* Gets the name of the CT log */\nconst char *CTLOG_get0_name(const CTLOG *log);\n/* Gets the ID of the CT log */\nvoid CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id,\n                       size_t *log_id_len);\n/* Gets the public key of the CT log */\nEVP_PKEY *CTLOG_get0_public_key(const CTLOG *log);\n\n/**************************\n * CT log store functions *\n **************************/\n\n/*\n * Creates a new CT log store.\n * Should be deleted by the caller using CTLOG_STORE_free when no longer needed.\n */\nCTLOG_STORE *CTLOG_STORE_new(void);\n\n/*\n * Deletes a CT log store and all of the CT log instances held within.\n */\nvoid CTLOG_STORE_free(CTLOG_STORE *store);\n\n/*\n * Finds a CT log in the store based on its log ID.\n * Returns the CT log, or NULL if no match is found.\n */\nconst CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store,\n                                        const uint8_t *log_id,\n                                        size_t log_id_len);\n\n/*\n * Loads a CT log list into a |store| from a |file|.\n * Returns 1 if loading is successful, or 0 otherwise.\n */\n__owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file);\n\n/*\n * Loads the default CT log list into a |store|.\n * Returns 1 if loading is successful, or 0 otherwise.\n */\n__owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store);\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/cterr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_CTERR_H\n# define HEADER_CTERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_CT\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_CT_strings(void);\n\n/*\n * CT function codes.\n */\n#  define CT_F_CTLOG_NEW                                   117\n#  define CT_F_CTLOG_NEW_FROM_BASE64                       118\n#  define CT_F_CTLOG_NEW_FROM_CONF                         119\n#  define CT_F_CTLOG_STORE_LOAD_CTX_NEW                    122\n#  define CT_F_CTLOG_STORE_LOAD_FILE                       123\n#  define CT_F_CTLOG_STORE_LOAD_LOG                        130\n#  define CT_F_CTLOG_STORE_NEW                             131\n#  define CT_F_CT_BASE64_DECODE                            124\n#  define CT_F_CT_POLICY_EVAL_CTX_NEW                      133\n#  define CT_F_CT_V1_LOG_ID_FROM_PKEY                      125\n#  define CT_F_I2O_SCT                                     107\n#  define CT_F_I2O_SCT_LIST                                108\n#  define CT_F_I2O_SCT_SIGNATURE                           109\n#  define CT_F_O2I_SCT                                     110\n#  define CT_F_O2I_SCT_LIST                                111\n#  define CT_F_O2I_SCT_SIGNATURE                           112\n#  define CT_F_SCT_CTX_NEW                                 126\n#  define CT_F_SCT_CTX_VERIFY                              128\n#  define CT_F_SCT_NEW                                     100\n#  define CT_F_SCT_NEW_FROM_BASE64                         127\n#  define CT_F_SCT_SET0_LOG_ID                             101\n#  define CT_F_SCT_SET1_EXTENSIONS                         114\n#  define CT_F_SCT_SET1_LOG_ID                             115\n#  define CT_F_SCT_SET1_SIGNATURE                          116\n#  define CT_F_SCT_SET_LOG_ENTRY_TYPE                      102\n#  define CT_F_SCT_SET_SIGNATURE_NID                       103\n#  define CT_F_SCT_SET_VERSION                             104\n\n/*\n * CT reason codes.\n */\n#  define CT_R_BASE64_DECODE_ERROR                         108\n#  define CT_R_INVALID_LOG_ID_LENGTH                       100\n#  define CT_R_LOG_CONF_INVALID                            109\n#  define CT_R_LOG_CONF_INVALID_KEY                        110\n#  define CT_R_LOG_CONF_MISSING_DESCRIPTION                111\n#  define CT_R_LOG_CONF_MISSING_KEY                        112\n#  define CT_R_LOG_KEY_INVALID                             113\n#  define CT_R_SCT_FUTURE_TIMESTAMP                        116\n#  define CT_R_SCT_INVALID                                 104\n#  define CT_R_SCT_INVALID_SIGNATURE                       107\n#  define CT_R_SCT_LIST_INVALID                            105\n#  define CT_R_SCT_LOG_ID_MISMATCH                         114\n#  define CT_R_SCT_NOT_SET                                 106\n#  define CT_R_SCT_UNSUPPORTED_VERSION                     115\n#  define CT_R_UNRECOGNIZED_SIGNATURE_NID                  101\n#  define CT_R_UNSUPPORTED_ENTRY_TYPE                      102\n#  define CT_R_UNSUPPORTED_VERSION                         103\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/des.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DES_H\n# define HEADER_DES_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DES\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n# include <openssl/e_os2.h>\n\ntypedef unsigned int DES_LONG;\n\n# ifdef OPENSSL_BUILD_SHLIBCRYPTO\n#  undef OPENSSL_EXTERN\n#  define OPENSSL_EXTERN OPENSSL_EXPORT\n# endif\n\ntypedef unsigned char DES_cblock[8];\ntypedef /* const */ unsigned char const_DES_cblock[8];\n/*\n * With \"const\", gcc 2.8.1 on Solaris thinks that DES_cblock * and\n * const_DES_cblock * are incompatible pointer types.\n */\n\ntypedef struct DES_ks {\n    union {\n        DES_cblock cblock;\n        /*\n         * make sure things are correct size on machines with 8 byte longs\n         */\n        DES_LONG deslong[2];\n    } ks[16];\n} DES_key_schedule;\n\n# define DES_KEY_SZ      (sizeof(DES_cblock))\n# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))\n\n# define DES_ENCRYPT     1\n# define DES_DECRYPT     0\n\n# define DES_CBC_MODE    0\n# define DES_PCBC_MODE   1\n\n# define DES_ecb2_encrypt(i,o,k1,k2,e) \\\n        DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))\n\n# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \\\n        DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))\n\n# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \\\n        DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))\n\n# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \\\n        DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))\n\nOPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */\n# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)\n\nconst char *DES_options(void);\nvoid DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,\n                      DES_key_schedule *ks1, DES_key_schedule *ks2,\n                      DES_key_schedule *ks3, int enc);\nDES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output,\n                       long length, DES_key_schedule *schedule,\n                       const_DES_cblock *ivec);\n/* DES_cbc_encrypt does not update the IV!  Use DES_ncbc_encrypt instead. */\nvoid DES_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ncbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nvoid DES_xcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, const_DES_cblock *inw,\n                      const_DES_cblock *outw, int enc);\nvoid DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec, int enc);\nvoid DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,\n                     DES_key_schedule *ks, int enc);\n\n/*\n * This is the DES encryption function that gets called by just about every\n * other DES routine in the library.  You should not use this function except\n * to implement 'modes' of DES.  I say this because the functions that call\n * this routine do the conversion from 'char *' to long, and this needs to be\n * done to make sure 'non-aligned' memory access do not occur.  The\n * characters are loaded 'little endian'. Data is a pointer to 2 unsigned\n * long's and ks is the DES_key_schedule to use.  enc, is non zero specifies\n * encryption, zero if decryption.\n */\nvoid DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);\n\n/*\n * This functions is the same as DES_encrypt1() except that the DES initial\n * permutation (IP) and final permutation (FP) have been left out.  As for\n * DES_encrypt1(), you should not use this function. It is used by the\n * routines in the library that implement triple DES. IP() DES_encrypt2()\n * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1()\n * DES_encrypt1() DES_encrypt1() except faster :-).\n */\nvoid DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc);\n\nvoid DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,\n                  DES_key_schedule *ks2, DES_key_schedule *ks3);\nvoid DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,\n                          long length,\n                          DES_key_schedule *ks1, DES_key_schedule *ks2,\n                          DES_key_schedule *ks3, DES_cblock *ivec, int enc);\nvoid DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num, int enc);\nvoid DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out,\n                          int numbits, long length, DES_key_schedule *ks1,\n                          DES_key_schedule *ks2, DES_key_schedule *ks3,\n                          DES_cblock *ivec, int enc);\nvoid DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                            long length, DES_key_schedule *ks1,\n                            DES_key_schedule *ks2, DES_key_schedule *ks3,\n                            DES_cblock *ivec, int *num);\nchar *DES_fcrypt(const char *buf, const char *salt, char *ret);\nchar *DES_crypt(const char *buf, const char *salt);\nvoid DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,\n                     long length, DES_key_schedule *schedule,\n                     DES_cblock *ivec);\nvoid DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,\n                      long length, DES_key_schedule *schedule,\n                      DES_cblock *ivec, int enc);\nDES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],\n                        long length, int out_count, DES_cblock *seed);\nint DES_random_key(DES_cblock *ret);\nvoid DES_set_odd_parity(DES_cblock *key);\nint DES_check_key_parity(const_DES_cblock *key);\nint DES_is_weak_key(const_DES_cblock *key);\n/*\n * DES_set_key (= set_key = DES_key_sched = key_sched) calls\n * DES_set_key_checked if global variable DES_check_key is set,\n * DES_set_key_unchecked otherwise.\n */\nint DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);\nint DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule);\nvoid DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule);\nvoid DES_string_to_key(const char *str, DES_cblock *key);\nvoid DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2);\nvoid DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num, int enc);\nvoid DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, DES_key_schedule *schedule,\n                       DES_cblock *ivec, int *num);\n\n# define DES_fixup_key_parity DES_set_odd_parity\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/dh.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DH_H\n# define HEADER_DH_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DH\n# include <openssl/e_os2.h>\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n# include <openssl/ossl_typ.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n# endif\n# include <openssl/dherr.h>\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# ifndef OPENSSL_DH_MAX_MODULUS_BITS\n#  define OPENSSL_DH_MAX_MODULUS_BITS    10000\n# endif\n\n# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024\n\n# define DH_FLAG_CACHE_MONT_P     0x01\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * Does nothing. Previously this switched off constant time behaviour.\n */\n#  define DH_FLAG_NO_EXP_CONSTTIME 0x00\n# endif\n\n/*\n * If this flag is set the DH method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its responsibility to ensure the\n * result is compliant.\n */\n\n# define DH_FLAG_FIPS_METHOD                     0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DH_FLAG_NON_FIPS_ALLOW                  0x0400\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dh_st DH; */\n/* typedef struct dh_method DH_METHOD; */\n\nDECLARE_ASN1_ITEM(DHparams)\n\n# define DH_GENERATOR_2          2\n/* #define DH_GENERATOR_3       3 */\n# define DH_GENERATOR_5          5\n\n/* DH_check error codes */\n# define DH_CHECK_P_NOT_PRIME            0x01\n# define DH_CHECK_P_NOT_SAFE_PRIME       0x02\n# define DH_UNABLE_TO_CHECK_GENERATOR    0x04\n# define DH_NOT_SUITABLE_GENERATOR       0x08\n# define DH_CHECK_Q_NOT_PRIME            0x10\n# define DH_CHECK_INVALID_Q_VALUE        0x20\n# define DH_CHECK_INVALID_J_VALUE        0x40\n\n/* DH_check_pub_key error codes */\n# define DH_CHECK_PUBKEY_TOO_SMALL       0x01\n# define DH_CHECK_PUBKEY_TOO_LARGE       0x02\n# define DH_CHECK_PUBKEY_INVALID         0x04\n\n/*\n * primes p where (p-1)/2 is prime too are called \"safe\"; we define this for\n * backward compatibility:\n */\n# define DH_CHECK_P_NOT_STRONG_PRIME     DH_CHECK_P_NOT_SAFE_PRIME\n\n# define d2i_DHparams_fp(fp,x) \\\n    (DH *)ASN1_d2i_fp((char *(*)())DH_new, \\\n                      (char *(*)())d2i_DHparams, \\\n                      (fp), \\\n                      (unsigned char **)(x))\n# define i2d_DHparams_fp(fp,x) \\\n    ASN1_i2d_fp(i2d_DHparams,(fp), (unsigned char *)(x))\n# define d2i_DHparams_bio(bp,x) \\\n    ASN1_d2i_bio_of(DH, DH_new, d2i_DHparams, bp, x)\n# define i2d_DHparams_bio(bp,x) \\\n    ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x)\n\n# define d2i_DHxparams_fp(fp,x) \\\n    (DH *)ASN1_d2i_fp((char *(*)())DH_new, \\\n                      (char *(*)())d2i_DHxparams, \\\n                      (fp), \\\n                      (unsigned char **)(x))\n# define i2d_DHxparams_fp(fp,x) \\\n    ASN1_i2d_fp(i2d_DHxparams,(fp), (unsigned char *)(x))\n# define d2i_DHxparams_bio(bp,x) \\\n    ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, bp, x)\n# define i2d_DHxparams_bio(bp,x) \\\n    ASN1_i2d_bio_of_const(DH, i2d_DHxparams, bp, x)\n\nDH *DHparams_dup(DH *);\n\nconst DH_METHOD *DH_OpenSSL(void);\n\nvoid DH_set_default_method(const DH_METHOD *meth);\nconst DH_METHOD *DH_get_default_method(void);\nint DH_set_method(DH *dh, const DH_METHOD *meth);\nDH *DH_new_method(ENGINE *engine);\n\nDH *DH_new(void);\nvoid DH_free(DH *dh);\nint DH_up_ref(DH *dh);\nint DH_bits(const DH *dh);\nint DH_size(const DH *dh);\nint DH_security_bits(const DH *dh);\n#define DH_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, l, p, newf, dupf, freef)\nint DH_set_ex_data(DH *d, int idx, void *arg);\nvoid *DH_get_ex_data(DH *d, int idx);\n\n/* Deprecated version */\nDEPRECATEDIN_0_9_8(DH *DH_generate_parameters(int prime_len, int generator,\n                                              void (*callback) (int, int,\n                                                                void *),\n                                              void *cb_arg))\n\n/* New version */\nint DH_generate_parameters_ex(DH *dh, int prime_len, int generator,\n                              BN_GENCB *cb);\n\nint DH_check_params_ex(const DH *dh);\nint DH_check_ex(const DH *dh);\nint DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key);\nint DH_check_params(const DH *dh, int *ret);\nint DH_check(const DH *dh, int *codes);\nint DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes);\nint DH_generate_key(DH *dh);\nint DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nint DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh);\nDH *d2i_DHparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHparams(const DH *a, unsigned char **pp);\nDH *d2i_DHxparams(DH **a, const unsigned char **pp, long length);\nint i2d_DHxparams(const DH *a, unsigned char **pp);\n# ifndef OPENSSL_NO_STDIO\nint DHparams_print_fp(FILE *fp, const DH *x);\n# endif\nint DHparams_print(BIO *bp, const DH *x);\n\n/* RFC 5114 parameters */\nDH *DH_get_1024_160(void);\nDH *DH_get_2048_224(void);\nDH *DH_get_2048_256(void);\n\n/* Named parameters, currently RFC7919 */\nDH *DH_new_by_nid(int nid);\nint DH_get_nid(const DH *dh);\n\n# ifndef OPENSSL_NO_CMS\n/* RFC2631 KDF */\nint DH_KDF_X9_42(unsigned char *out, size_t outlen,\n                 const unsigned char *Z, size_t Zlen,\n                 ASN1_OBJECT *key_oid,\n                 const unsigned char *ukm, size_t ukmlen, const EVP_MD *md);\n# endif\n\nvoid DH_get0_pqg(const DH *dh,\n                 const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);\nint DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);\nvoid DH_get0_key(const DH *dh,\n                 const BIGNUM **pub_key, const BIGNUM **priv_key);\nint DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);\nconst BIGNUM *DH_get0_p(const DH *dh);\nconst BIGNUM *DH_get0_q(const DH *dh);\nconst BIGNUM *DH_get0_g(const DH *dh);\nconst BIGNUM *DH_get0_priv_key(const DH *dh);\nconst BIGNUM *DH_get0_pub_key(const DH *dh);\nvoid DH_clear_flags(DH *dh, int flags);\nint DH_test_flags(const DH *dh, int flags);\nvoid DH_set_flags(DH *dh, int flags);\nENGINE *DH_get0_engine(DH *d);\nlong DH_get_length(const DH *dh);\nint DH_set_length(DH *dh, long length);\n\nDH_METHOD *DH_meth_new(const char *name, int flags);\nvoid DH_meth_free(DH_METHOD *dhm);\nDH_METHOD *DH_meth_dup(const DH_METHOD *dhm);\nconst char *DH_meth_get0_name(const DH_METHOD *dhm);\nint DH_meth_set1_name(DH_METHOD *dhm, const char *name);\nint DH_meth_get_flags(const DH_METHOD *dhm);\nint DH_meth_set_flags(DH_METHOD *dhm, int flags);\nvoid *DH_meth_get0_app_data(const DH_METHOD *dhm);\nint DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data);\nint (*DH_meth_get_generate_key(const DH_METHOD *dhm)) (DH *);\nint DH_meth_set_generate_key(DH_METHOD *dhm, int (*generate_key) (DH *));\nint (*DH_meth_get_compute_key(const DH_METHOD *dhm))\n        (unsigned char *key, const BIGNUM *pub_key, DH *dh);\nint DH_meth_set_compute_key(DH_METHOD *dhm,\n        int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh));\nint (*DH_meth_get_bn_mod_exp(const DH_METHOD *dhm))\n    (const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,\n     BN_CTX *, BN_MONT_CTX *);\nint DH_meth_set_bn_mod_exp(DH_METHOD *dhm,\n    int (*bn_mod_exp) (const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *,\n                       const BIGNUM *, BN_CTX *, BN_MONT_CTX *));\nint (*DH_meth_get_init(const DH_METHOD *dhm))(DH *);\nint DH_meth_set_init(DH_METHOD *dhm, int (*init)(DH *));\nint (*DH_meth_get_finish(const DH_METHOD *dhm)) (DH *);\nint DH_meth_set_finish(DH_METHOD *dhm, int (*finish) (DH *));\nint (*DH_meth_get_generate_params(const DH_METHOD *dhm))\n        (DH *, int, int, BN_GENCB *);\nint DH_meth_set_generate_params(DH_METHOD *dhm,\n        int (*generate_params) (DH *, int, int, BN_GENCB *));\n\n\n# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL)\n\n# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \\\n                        EVP_PKEY_CTRL_DH_RFC5114, gen, NULL)\n\n# define EVP_PKEY_CTX_set_dh_nid(ctx, nid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, \\\n                        EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN, \\\n                        EVP_PKEY_CTRL_DH_NID, nid, NULL)\n\n# define EVP_PKEY_CTX_set_dh_pad(ctx, pad) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_DERIVE, \\\n                          EVP_PKEY_CTRL_DH_PAD, pad, NULL)\n\n# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)(oid))\n\n# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)(poid))\n\n# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)(pmd))\n\n# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                        EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)(plen))\n\n# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)(p))\n\n# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)(p))\n\n# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN     (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR     (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DH_RFC5114                (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN  (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE          (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_DH_KDF_TYPE               (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_DH_KDF_MD                 (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_DH_KDF_MD             (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_DH_KDF_OUTLEN             (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN         (EVP_PKEY_ALG_CTRL + 10)\n# define EVP_PKEY_CTRL_DH_KDF_UKM                (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_DH_KDF_UKM            (EVP_PKEY_ALG_CTRL + 12)\n# define EVP_PKEY_CTRL_DH_KDF_OID                (EVP_PKEY_ALG_CTRL + 13)\n# define EVP_PKEY_CTRL_GET_DH_KDF_OID            (EVP_PKEY_ALG_CTRL + 14)\n# define EVP_PKEY_CTRL_DH_NID                    (EVP_PKEY_ALG_CTRL + 15)\n# define EVP_PKEY_CTRL_DH_PAD                    (EVP_PKEY_ALG_CTRL + 16)\n\n/* KDF types */\n# define EVP_PKEY_DH_KDF_NONE                            1\n# ifndef OPENSSL_NO_CMS\n# define EVP_PKEY_DH_KDF_X9_42                           2\n# endif\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/dherr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DHERR_H\n# define HEADER_DHERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DH\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_DH_strings(void);\n\n/*\n * DH function codes.\n */\n#  define DH_F_COMPUTE_KEY                                 102\n#  define DH_F_DHPARAMS_PRINT_FP                           101\n#  define DH_F_DH_BUILTIN_GENPARAMS                        106\n#  define DH_F_DH_CHECK_EX                                 121\n#  define DH_F_DH_CHECK_PARAMS_EX                          122\n#  define DH_F_DH_CHECK_PUB_KEY_EX                         123\n#  define DH_F_DH_CMS_DECRYPT                              114\n#  define DH_F_DH_CMS_SET_PEERKEY                          115\n#  define DH_F_DH_CMS_SET_SHARED_INFO                      116\n#  define DH_F_DH_METH_DUP                                 117\n#  define DH_F_DH_METH_NEW                                 118\n#  define DH_F_DH_METH_SET1_NAME                           119\n#  define DH_F_DH_NEW_BY_NID                               104\n#  define DH_F_DH_NEW_METHOD                               105\n#  define DH_F_DH_PARAM_DECODE                             107\n#  define DH_F_DH_PKEY_PUBLIC_CHECK                        124\n#  define DH_F_DH_PRIV_DECODE                              110\n#  define DH_F_DH_PRIV_ENCODE                              111\n#  define DH_F_DH_PUB_DECODE                               108\n#  define DH_F_DH_PUB_ENCODE                               109\n#  define DH_F_DO_DH_PRINT                                 100\n#  define DH_F_GENERATE_KEY                                103\n#  define DH_F_PKEY_DH_CTRL_STR                            120\n#  define DH_F_PKEY_DH_DERIVE                              112\n#  define DH_F_PKEY_DH_INIT                                125\n#  define DH_F_PKEY_DH_KEYGEN                              113\n\n/*\n * DH reason codes.\n */\n#  define DH_R_BAD_GENERATOR                               101\n#  define DH_R_BN_DECODE_ERROR                             109\n#  define DH_R_BN_ERROR                                    106\n#  define DH_R_CHECK_INVALID_J_VALUE                       115\n#  define DH_R_CHECK_INVALID_Q_VALUE                       116\n#  define DH_R_CHECK_PUBKEY_INVALID                        122\n#  define DH_R_CHECK_PUBKEY_TOO_LARGE                      123\n#  define DH_R_CHECK_PUBKEY_TOO_SMALL                      124\n#  define DH_R_CHECK_P_NOT_PRIME                           117\n#  define DH_R_CHECK_P_NOT_SAFE_PRIME                      118\n#  define DH_R_CHECK_Q_NOT_PRIME                           119\n#  define DH_R_DECODE_ERROR                                104\n#  define DH_R_INVALID_PARAMETER_NAME                      110\n#  define DH_R_INVALID_PARAMETER_NID                       114\n#  define DH_R_INVALID_PUBKEY                              102\n#  define DH_R_KDF_PARAMETER_ERROR                         112\n#  define DH_R_KEYS_NOT_SET                                108\n#  define DH_R_MISSING_PUBKEY                              125\n#  define DH_R_MODULUS_TOO_LARGE                           103\n#  define DH_R_NOT_SUITABLE_GENERATOR                      120\n#  define DH_R_NO_PARAMETERS_SET                           107\n#  define DH_R_NO_PRIVATE_VALUE                            100\n#  define DH_R_PARAMETER_ENCODING_ERROR                    105\n#  define DH_R_PEER_KEY_ERROR                              111\n#  define DH_R_SHARED_INFO_ERROR                           113\n#  define DH_R_UNABLE_TO_CHECK_GENERATOR                   121\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/dsa.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DSA_H\n# define HEADER_DSA_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DSA\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n# include <openssl/e_os2.h>\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/bn.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/dh.h>\n# endif\n# include <openssl/dsaerr.h>\n\n# ifndef OPENSSL_DSA_MAX_MODULUS_BITS\n#  define OPENSSL_DSA_MAX_MODULUS_BITS   10000\n# endif\n\n# define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024\n\n# define DSA_FLAG_CACHE_MONT_P   0x01\n# if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * Does nothing. Previously this switched off constant time behaviour.\n */\n#  define DSA_FLAG_NO_EXP_CONSTTIME       0x00\n# endif\n\n/*\n * If this flag is set the DSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its responsibility to ensure the\n * result is compliant.\n */\n\n# define DSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define DSA_FLAG_NON_FIPS_ALLOW                 0x0400\n# define DSA_FLAG_FIPS_CHECKED                   0x0800\n\n/* Already defined in ossl_typ.h */\n/* typedef struct dsa_st DSA; */\n/* typedef struct dsa_method DSA_METHOD; */\n\ntypedef struct DSA_SIG_st DSA_SIG;\n\n# define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \\\n                (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x))\n# define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \\\n                (unsigned char *)(x))\n# define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x)\n# define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x)\n\nDSA *DSAparams_dup(DSA *x);\nDSA_SIG *DSA_SIG_new(void);\nvoid DSA_SIG_free(DSA_SIG *a);\nint i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp);\nDSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length);\nvoid DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);\nint DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);\n\nDSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);\nint DSA_do_verify(const unsigned char *dgst, int dgst_len,\n                  DSA_SIG *sig, DSA *dsa);\n\nconst DSA_METHOD *DSA_OpenSSL(void);\n\nvoid DSA_set_default_method(const DSA_METHOD *);\nconst DSA_METHOD *DSA_get_default_method(void);\nint DSA_set_method(DSA *dsa, const DSA_METHOD *);\nconst DSA_METHOD *DSA_get_method(DSA *d);\n\nDSA *DSA_new(void);\nDSA *DSA_new_method(ENGINE *engine);\nvoid DSA_free(DSA *r);\n/* \"up\" the DSA object's reference count */\nint DSA_up_ref(DSA *r);\nint DSA_size(const DSA *);\nint DSA_bits(const DSA *d);\nint DSA_security_bits(const DSA *d);\n        /* next 4 return -1 on error */\nDEPRECATEDIN_1_2_0(int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp))\nint DSA_sign(int type, const unsigned char *dgst, int dlen,\n             unsigned char *sig, unsigned int *siglen, DSA *dsa);\nint DSA_verify(int type, const unsigned char *dgst, int dgst_len,\n               const unsigned char *sigbuf, int siglen, DSA *dsa);\n#define DSA_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef)\nint DSA_set_ex_data(DSA *d, int idx, void *arg);\nvoid *DSA_get_ex_data(DSA *d, int idx);\n\nDSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length);\nDSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length);\n\n/* Deprecated version */\nDEPRECATEDIN_0_9_8(DSA *DSA_generate_parameters(int bits,\n                                                unsigned char *seed,\n                                                int seed_len,\n                                                int *counter_ret,\n                                                unsigned long *h_ret, void\n                                                 (*callback) (int, int,\n                                                              void *),\n                                                void *cb_arg))\n\n/* New version */\nint DSA_generate_parameters_ex(DSA *dsa, int bits,\n                               const unsigned char *seed, int seed_len,\n                               int *counter_ret, unsigned long *h_ret,\n                               BN_GENCB *cb);\n\nint DSA_generate_key(DSA *a);\nint i2d_DSAPublicKey(const DSA *a, unsigned char **pp);\nint i2d_DSAPrivateKey(const DSA *a, unsigned char **pp);\nint i2d_DSAparams(const DSA *a, unsigned char **pp);\n\nint DSAparams_print(BIO *bp, const DSA *x);\nint DSA_print(BIO *bp, const DSA *x, int off);\n# ifndef OPENSSL_NO_STDIO\nint DSAparams_print_fp(FILE *fp, const DSA *x);\nint DSA_print_fp(FILE *bp, const DSA *x, int off);\n# endif\n\n# define DSS_prime_checks 64\n/*\n * Primality test according to FIPS PUB 186-4, Appendix C.3. Since we only\n * have one value here we set the number of checks to 64 which is the 128 bit\n * security level that is the highest level and valid for creating a 3072 bit\n * DSA key.\n */\n# define DSA_is_prime(n, callback, cb_arg) \\\n        BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)\n\n# ifndef OPENSSL_NO_DH\n/*\n * Convert DSA structure (key or just parameters) into DH structure (be\n * careful to avoid small subgroup attacks when using this!)\n */\nDH *DSA_dup_DH(const DSA *r);\n# endif\n\n# define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \\\n                                EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL)\n# define EVP_PKEY_CTX_set_dsa_paramgen_q_bits(ctx, qbits) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \\\n                                EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL)\n# define EVP_PKEY_CTX_set_dsa_paramgen_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \\\n                                EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS         (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS       (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD           (EVP_PKEY_ALG_CTRL + 3)\n\nvoid DSA_get0_pqg(const DSA *d,\n                  const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);\nint DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g);\nvoid DSA_get0_key(const DSA *d,\n                  const BIGNUM **pub_key, const BIGNUM **priv_key);\nint DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key);\nconst BIGNUM *DSA_get0_p(const DSA *d);\nconst BIGNUM *DSA_get0_q(const DSA *d);\nconst BIGNUM *DSA_get0_g(const DSA *d);\nconst BIGNUM *DSA_get0_pub_key(const DSA *d);\nconst BIGNUM *DSA_get0_priv_key(const DSA *d);\nvoid DSA_clear_flags(DSA *d, int flags);\nint DSA_test_flags(const DSA *d, int flags);\nvoid DSA_set_flags(DSA *d, int flags);\nENGINE *DSA_get0_engine(DSA *d);\n\nDSA_METHOD *DSA_meth_new(const char *name, int flags);\nvoid DSA_meth_free(DSA_METHOD *dsam);\nDSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam);\nconst char *DSA_meth_get0_name(const DSA_METHOD *dsam);\nint DSA_meth_set1_name(DSA_METHOD *dsam, const char *name);\nint DSA_meth_get_flags(const DSA_METHOD *dsam);\nint DSA_meth_set_flags(DSA_METHOD *dsam, int flags);\nvoid *DSA_meth_get0_app_data(const DSA_METHOD *dsam);\nint DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data);\nDSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))\n        (const unsigned char *, int, DSA *);\nint DSA_meth_set_sign(DSA_METHOD *dsam,\n                       DSA_SIG *(*sign) (const unsigned char *, int, DSA *));\nint (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))\n        (DSA *, BN_CTX *, BIGNUM **, BIGNUM **);\nint DSA_meth_set_sign_setup(DSA_METHOD *dsam,\n        int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **));\nint (*DSA_meth_get_verify(const DSA_METHOD *dsam))\n        (const unsigned char *, int, DSA_SIG *, DSA *);\nint DSA_meth_set_verify(DSA_METHOD *dsam,\n    int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *));\nint (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))\n        (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,\n         const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *);\nint DSA_meth_set_mod_exp(DSA_METHOD *dsam,\n    int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,\n                    const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,\n                    BN_MONT_CTX *));\nint (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))\n    (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,\n     BN_CTX *, BN_MONT_CTX *);\nint DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,\n    int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,\n                       const BIGNUM *, BN_CTX *, BN_MONT_CTX *));\nint (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *);\nint DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *));\nint (*DSA_meth_get_finish(const DSA_METHOD *dsam)) (DSA *);\nint DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish) (DSA *));\nint (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))\n        (DSA *, int, const unsigned char *, int, int *, unsigned long *,\n         BN_GENCB *);\nint DSA_meth_set_paramgen(DSA_METHOD *dsam,\n        int (*paramgen) (DSA *, int, const unsigned char *, int, int *,\n                         unsigned long *, BN_GENCB *));\nint (*DSA_meth_get_keygen(const DSA_METHOD *dsam)) (DSA *);\nint DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen) (DSA *));\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/dsaerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DSAERR_H\n# define HEADER_DSAERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_DSA\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_DSA_strings(void);\n\n/*\n * DSA function codes.\n */\n#  define DSA_F_DSAPARAMS_PRINT                            100\n#  define DSA_F_DSAPARAMS_PRINT_FP                         101\n#  define DSA_F_DSA_BUILTIN_PARAMGEN                       125\n#  define DSA_F_DSA_BUILTIN_PARAMGEN2                      126\n#  define DSA_F_DSA_DO_SIGN                                112\n#  define DSA_F_DSA_DO_VERIFY                              113\n#  define DSA_F_DSA_METH_DUP                               127\n#  define DSA_F_DSA_METH_NEW                               128\n#  define DSA_F_DSA_METH_SET1_NAME                         129\n#  define DSA_F_DSA_NEW_METHOD                             103\n#  define DSA_F_DSA_PARAM_DECODE                           119\n#  define DSA_F_DSA_PRINT_FP                               105\n#  define DSA_F_DSA_PRIV_DECODE                            115\n#  define DSA_F_DSA_PRIV_ENCODE                            116\n#  define DSA_F_DSA_PUB_DECODE                             117\n#  define DSA_F_DSA_PUB_ENCODE                             118\n#  define DSA_F_DSA_SIGN                                   106\n#  define DSA_F_DSA_SIGN_SETUP                             107\n#  define DSA_F_DSA_SIG_NEW                                102\n#  define DSA_F_OLD_DSA_PRIV_DECODE                        122\n#  define DSA_F_PKEY_DSA_CTRL                              120\n#  define DSA_F_PKEY_DSA_CTRL_STR                          104\n#  define DSA_F_PKEY_DSA_KEYGEN                            121\n\n/*\n * DSA reason codes.\n */\n#  define DSA_R_BAD_Q_VALUE                                102\n#  define DSA_R_BN_DECODE_ERROR                            108\n#  define DSA_R_BN_ERROR                                   109\n#  define DSA_R_DECODE_ERROR                               104\n#  define DSA_R_INVALID_DIGEST_TYPE                        106\n#  define DSA_R_INVALID_PARAMETERS                         112\n#  define DSA_R_MISSING_PARAMETERS                         101\n#  define DSA_R_MISSING_PRIVATE_KEY                        111\n#  define DSA_R_MODULUS_TOO_LARGE                          103\n#  define DSA_R_NO_PARAMETERS_SET                          107\n#  define DSA_R_PARAMETER_ENCODING_ERROR                   105\n#  define DSA_R_Q_NOT_PRIME                                113\n#  define DSA_R_SEED_LEN_SMALL                             110\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/dtls1.h",
    "content": "/*\n * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DTLS1_H\n# define HEADER_DTLS1_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define DTLS1_VERSION                   0xFEFF\n# define DTLS1_2_VERSION                 0xFEFD\n# define DTLS_MIN_VERSION                DTLS1_VERSION\n# define DTLS_MAX_VERSION                DTLS1_2_VERSION\n# define DTLS1_VERSION_MAJOR             0xFE\n\n# define DTLS1_BAD_VER                   0x0100\n\n/* Special value for method supporting multiple versions */\n# define DTLS_ANY_VERSION                0x1FFFF\n\n/* lengths of messages */\n/*\n * Actually the max cookie length in DTLS is 255. But we can't change this now\n * due to compatibility concerns.\n */\n# define DTLS1_COOKIE_LENGTH                     256\n\n# define DTLS1_RT_HEADER_LENGTH                  13\n\n# define DTLS1_HM_HEADER_LENGTH                  12\n\n# define DTLS1_HM_BAD_FRAGMENT                   -2\n# define DTLS1_HM_FRAGMENT_RETRY                 -3\n\n# define DTLS1_CCS_HEADER_LENGTH                  1\n\n# define DTLS1_AL_HEADER_LENGTH                   2\n\n/* Timeout multipliers */\n# define DTLS1_TMO_READ_COUNT                      2\n# define DTLS1_TMO_WRITE_COUNT                     2\n\n# define DTLS1_TMO_ALERT_COUNT                     12\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/e_os2.h",
    "content": "/*\n * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_E_OS2_H\n# define HEADER_E_OS2_H\n\n# include <openssl/opensslconf.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/******************************************************************************\n * Detect operating systems.  This probably needs completing.\n * The result is that at least one OPENSSL_SYS_os macro should be defined.\n * However, if none is defined, Unix is assumed.\n **/\n\n# define OPENSSL_SYS_UNIX\n\n/* --------------------- Microsoft operating systems ---------------------- */\n\n/*\n * Note that MSDOS actually denotes 32-bit environments running on top of\n * MS-DOS, such as DJGPP one.\n */\n# if defined(OPENSSL_SYS_MSDOS)\n#  undef OPENSSL_SYS_UNIX\n# endif\n\n/*\n * For 32 bit environment, there seems to be the CygWin environment and then\n * all the others that try to do the same thing Microsoft does...\n */\n/*\n * UEFI lives here because it might be built with a Microsoft toolchain and\n * we need to avoid the false positive match on Windows.\n */\n# if defined(OPENSSL_SYS_UEFI)\n#  undef OPENSSL_SYS_UNIX\n# elif defined(OPENSSL_SYS_UWIN)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WIN32_UWIN\n# else\n#  if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN)\n#   define OPENSSL_SYS_WIN32_CYGWIN\n#  else\n#   if defined(_WIN32) || defined(OPENSSL_SYS_WIN32)\n#    undef OPENSSL_SYS_UNIX\n#    if !defined(OPENSSL_SYS_WIN32)\n#     define OPENSSL_SYS_WIN32\n#    endif\n#   endif\n#   if defined(_WIN64) || defined(OPENSSL_SYS_WIN64)\n#    undef OPENSSL_SYS_UNIX\n#    if !defined(OPENSSL_SYS_WIN64)\n#     define OPENSSL_SYS_WIN64\n#    endif\n#   endif\n#   if defined(OPENSSL_SYS_WINNT)\n#    undef OPENSSL_SYS_UNIX\n#   endif\n#   if defined(OPENSSL_SYS_WINCE)\n#    undef OPENSSL_SYS_UNIX\n#   endif\n#  endif\n# endif\n\n/* Anything that tries to look like Microsoft is \"Windows\" */\n# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE)\n#  undef OPENSSL_SYS_UNIX\n#  define OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_SYS_MSDOS\n#   define OPENSSL_SYS_MSDOS\n#  endif\n# endif\n\n/*\n * DLL settings.  This part is a bit tough, because it's up to the\n * application implementor how he or she will link the application, so it\n * requires some macro to be used.\n */\n# ifdef OPENSSL_SYS_WINDOWS\n#  ifndef OPENSSL_OPT_WINDLL\n#   if defined(_WINDLL)         /* This is used when building OpenSSL to\n                                 * indicate that DLL linkage should be used */\n#    define OPENSSL_OPT_WINDLL\n#   endif\n#  endif\n# endif\n\n/* ------------------------------- OpenVMS -------------------------------- */\n# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS)\n#  if !defined(OPENSSL_SYS_VMS)\n#   undef OPENSSL_SYS_UNIX\n#  endif\n#  define OPENSSL_SYS_VMS\n#  if defined(__DECC)\n#   define OPENSSL_SYS_VMS_DECC\n#  elif defined(__DECCXX)\n#   define OPENSSL_SYS_VMS_DECC\n#   define OPENSSL_SYS_VMS_DECCXX\n#  else\n#   define OPENSSL_SYS_VMS_NODECC\n#  endif\n# endif\n\n/* -------------------------------- Unix ---------------------------------- */\n# ifdef OPENSSL_SYS_UNIX\n#  if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX)\n#   define OPENSSL_SYS_LINUX\n#  endif\n#  if defined(_AIX) && !defined(OPENSSL_SYS_AIX)\n#   define OPENSSL_SYS_AIX\n#  endif\n# endif\n\n/* -------------------------------- VOS ----------------------------------- */\n# if defined(__VOS__) && !defined(OPENSSL_SYS_VOS)\n#  define OPENSSL_SYS_VOS\n#  ifdef __HPPA__\n#   define OPENSSL_SYS_VOS_HPPA\n#  endif\n#  ifdef __IA32__\n#   define OPENSSL_SYS_VOS_IA32\n#  endif\n# endif\n\n/**\n * That's it for OS-specific stuff\n *****************************************************************************/\n\n/* Specials for I/O an exit */\n# ifdef OPENSSL_SYS_MSDOS\n#  define OPENSSL_UNISTD_IO <io.h>\n#  define OPENSSL_DECLARE_EXIT extern void exit(int);\n# else\n#  define OPENSSL_UNISTD_IO OPENSSL_UNISTD\n#  define OPENSSL_DECLARE_EXIT  /* declared in unistd.h */\n# endif\n\n/*-\n * OPENSSL_EXTERN is normally used to declare a symbol with possible extra\n * attributes to handle its presence in a shared library.\n * OPENSSL_EXPORT is used to define a symbol with extra possible attributes\n * to make it visible in a shared library.\n * Care needs to be taken when a header file is used both to declare and\n * define symbols.  Basically, for any library that exports some global\n * variables, the following code must be present in the header file that\n * declares them, before OPENSSL_EXTERN is used:\n *\n * #ifdef SOME_BUILD_FLAG_MACRO\n * # undef OPENSSL_EXTERN\n * # define OPENSSL_EXTERN OPENSSL_EXPORT\n * #endif\n *\n * The default is to have OPENSSL_EXPORT and OPENSSL_EXTERN\n * have some generally sensible values.\n */\n\n# if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL)\n#  define OPENSSL_EXPORT extern __declspec(dllexport)\n#  define OPENSSL_EXTERN extern __declspec(dllimport)\n# else\n#  define OPENSSL_EXPORT extern\n#  define OPENSSL_EXTERN extern\n# endif\n\n/*-\n * Macros to allow global variables to be reached through function calls when\n * required (if a shared library version requires it, for example.\n * The way it's done allows definitions like this:\n *\n *      // in foobar.c\n *      OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0)\n *      // in foobar.h\n *      OPENSSL_DECLARE_GLOBAL(int,foobar);\n *      #define foobar OPENSSL_GLOBAL_REF(foobar)\n */\n# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value)                      \\\n        type *_shadow_##name(void)                                      \\\n        { static type _hide_##name=value; return &_hide_##name; }\n#  define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void)\n#  define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name()))\n# else\n#  define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) type _shadow_##name=value;\n#  define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name\n#  define OPENSSL_GLOBAL_REF(name) _shadow_##name\n# endif\n\n# ifdef _WIN32\n#  ifdef _WIN64\n#   define ossl_ssize_t __int64\n#   define OSSL_SSIZE_MAX _I64_MAX\n#  else\n#   define ossl_ssize_t int\n#   define OSSL_SSIZE_MAX INT_MAX\n#  endif\n# endif\n\n# if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t)\n#  define ossl_ssize_t INTN\n#  define OSSL_SSIZE_MAX MAX_INTN\n# endif\n\n# ifndef ossl_ssize_t\n#  define ossl_ssize_t ssize_t\n#  if defined(SSIZE_MAX)\n#   define OSSL_SSIZE_MAX SSIZE_MAX\n#  elif defined(_POSIX_SSIZE_MAX)\n#   define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX\n#  else\n#   define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX>>1))\n#  endif\n# endif\n\n# ifdef DEBUG_UNUSED\n#  define __owur __attribute__((__warn_unused_result__))\n# else\n#  define __owur\n# endif\n\n/* Standard integer types */\n# if defined(OPENSSL_SYS_UEFI)\ntypedef INT8 int8_t;\ntypedef UINT8 uint8_t;\ntypedef INT16 int16_t;\ntypedef UINT16 uint16_t;\ntypedef INT32 int32_t;\ntypedef UINT32 uint32_t;\ntypedef INT64 int64_t;\ntypedef UINT64 uint64_t;\n# elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \\\n     defined(__osf__) || defined(__sgi) || defined(__hpux) || \\\n     defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__)\n#  include <inttypes.h>\n# elif defined(_MSC_VER) && _MSC_VER<1600\n/*\n * minimally required typdefs for systems not supporting inttypes.h or\n * stdint.h: currently just older VC++\n */\ntypedef signed char int8_t;\ntypedef unsigned char uint8_t;\ntypedef short int16_t;\ntypedef unsigned short uint16_t;\ntypedef int int32_t;\ntypedef unsigned int uint32_t;\ntypedef __int64 int64_t;\ntypedef unsigned __int64 uint64_t;\n# else\n#  include <stdint.h>\n# endif\n\n/* ossl_inline: portable inline definition usable in public headers */\n# if !defined(inline) && !defined(__cplusplus)\n#  if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L\n   /* just use inline */\n#   define ossl_inline inline\n#  elif defined(__GNUC__) && __GNUC__>=2\n#   define ossl_inline __inline__\n#  elif defined(_MSC_VER)\n  /*\n   * Visual Studio: inline is available in C++ only, however\n   * __inline is available for C, see\n   * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx\n   */\n#   define ossl_inline __inline\n#  else\n#   define ossl_inline\n#  endif\n# else\n#  define ossl_inline inline\n# endif\n\n# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \\\n     !defined(__cplusplus) \n#  define ossl_noreturn _Noreturn\n# elif defined(__GNUC__) && __GNUC__ >= 2\n#  define ossl_noreturn __attribute__((noreturn))\n# else\n#  define ossl_noreturn\n# endif\n\n/* ossl_unused: portable unused attribute for use in public headers */\n# if defined(__GNUC__)\n#  define ossl_unused __attribute__((unused))\n# else\n#  define ossl_unused\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ebcdic.h",
    "content": "/*\n * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_EBCDIC_H\n# define HEADER_EBCDIC_H\n\n# include <stdlib.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Avoid name clashes with other applications */\n# define os_toascii   _openssl_os_toascii\n# define os_toebcdic  _openssl_os_toebcdic\n# define ebcdic2ascii _openssl_ebcdic2ascii\n# define ascii2ebcdic _openssl_ascii2ebcdic\n\nextern const unsigned char os_toascii[256];\nextern const unsigned char os_toebcdic[256];\nvoid *ebcdic2ascii(void *dest, const void *srce, size_t count);\nvoid *ascii2ebcdic(void *dest, const void *srce, size_t count);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ec.h",
    "content": "/*\n * Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_EC_H\n# define HEADER_EC_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_EC\n# include <openssl/asn1.h>\n# include <openssl/symhacks.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n# endif\n# include <openssl/ecerr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# ifndef OPENSSL_ECC_MAX_FIELD_BITS\n#  define OPENSSL_ECC_MAX_FIELD_BITS 661\n# endif\n\n/** Enum for the point conversion form as defined in X9.62 (ECDSA)\n *  for the encoding of a elliptic curve point (x,y) */\ntypedef enum {\n        /** the point is encoded as z||x, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_COMPRESSED = 2,\n        /** the point is encoded as z||x||y, where z is the octet 0x04  */\n    POINT_CONVERSION_UNCOMPRESSED = 4,\n        /** the point is encoded as z||x||y, where the octet z specifies\n         *  which solution of the quadratic equation y is  */\n    POINT_CONVERSION_HYBRID = 6\n} point_conversion_form_t;\n\ntypedef struct ec_method_st EC_METHOD;\ntypedef struct ec_group_st EC_GROUP;\ntypedef struct ec_point_st EC_POINT;\ntypedef struct ecpk_parameters_st ECPKPARAMETERS;\ntypedef struct ec_parameters_st ECPARAMETERS;\n\n/********************************************************************/\n/*               EC_METHODs for curves over GF(p)                   */\n/********************************************************************/\n\n/** Returns the basic GFp ec methods which provides the basis for the\n *  optimized methods.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_simple_method(void);\n\n/** Returns GFp methods using montgomery multiplication.\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_mont_method(void);\n\n/** Returns GFp methods using optimized methods for NIST recommended curves\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nist_method(void);\n\n# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n/** Returns 64-bit optimized methods for nistp224\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp224_method(void);\n\n/** Returns 64-bit optimized methods for nistp256\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp256_method(void);\n\n/** Returns 64-bit optimized methods for nistp521\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GFp_nistp521_method(void);\n# endif\n\n# ifndef OPENSSL_NO_EC2M\n/********************************************************************/\n/*           EC_METHOD for curves over GF(2^m)                      */\n/********************************************************************/\n\n/** Returns the basic GF2m ec method\n *  \\return  EC_METHOD object\n */\nconst EC_METHOD *EC_GF2m_simple_method(void);\n\n# endif\n\n/********************************************************************/\n/*                   EC_GROUP functions                             */\n/********************************************************************/\n\n/** Creates a new EC_GROUP object\n *  \\param   meth  EC_METHOD to use\n *  \\return  newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_new(const EC_METHOD *meth);\n\n/** Frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be freed.\n */\nvoid EC_GROUP_free(EC_GROUP *group);\n\n/** Clears and frees a EC_GROUP object\n *  \\param  group  EC_GROUP object to be cleared and freed.\n */\nvoid EC_GROUP_clear_free(EC_GROUP *group);\n\n/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD.\n *  \\param  dst  destination EC_GROUP object\n *  \\param  src  source EC_GROUP object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src);\n\n/** Creates a new EC_GROUP object and copies the copies the content\n *  form src to the newly created EC_KEY object\n *  \\param  src  source EC_GROUP object\n *  \\return newly created EC_GROUP object or NULL in case of an error.\n */\nEC_GROUP *EC_GROUP_dup(const EC_GROUP *src);\n\n/** Returns the EC_METHOD of the EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return EC_METHOD used in this EC_GROUP object.\n */\nconst EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group);\n\n/** Returns the field type of the EC_METHOD.\n *  \\param  meth  EC_METHOD object\n *  \\return NID of the underlying field type OID.\n */\nint EC_METHOD_get_field_type(const EC_METHOD *meth);\n\n/** Sets the generator and its order/cofactor of a EC_GROUP object.\n *  \\param  group      EC_GROUP object\n *  \\param  generator  EC_POINT object with the generator.\n *  \\param  order      the order of the group generated by the generator.\n *  \\param  cofactor   the index of the sub-group generated by the generator\n *                     in the group of all points on the elliptic curve.\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,\n                           const BIGNUM *order, const BIGNUM *cofactor);\n\n/** Returns the generator of a EC_GROUP object.\n *  \\param  group  EC_GROUP object\n *  \\return the currently used generator (possibly NULL).\n */\nconst EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group);\n\n/** Returns the montgomery data for order(Generator)\n *  \\param  group  EC_GROUP object\n *  \\return the currently used montgomery data (possibly NULL).\n*/\nBN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group);\n\n/** Gets the order of a EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\param  order  BIGNUM to which the order is copied\n *  \\param  ctx    unused\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx);\n\n/** Gets the order of an EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\return the group order\n */\nconst BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group);\n\n/** Gets the number of bits of the order of an EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\return number of bits of group order.\n */\nint EC_GROUP_order_bits(const EC_GROUP *group);\n\n/** Gets the cofactor of a EC_GROUP\n *  \\param  group     EC_GROUP object\n *  \\param  cofactor  BIGNUM to which the cofactor is copied\n *  \\param  ctx       unused\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor,\n                          BN_CTX *ctx);\n\n/** Gets the cofactor of an EC_GROUP\n *  \\param  group  EC_GROUP object\n *  \\return the group cofactor\n */\nconst BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group);\n\n/** Sets the name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\param  nid    NID of the curve name OID\n */\nvoid EC_GROUP_set_curve_name(EC_GROUP *group, int nid);\n\n/** Returns the curve name of a EC_GROUP object\n *  \\param  group  EC_GROUP object\n *  \\return NID of the curve name OID or 0 if not set.\n */\nint EC_GROUP_get_curve_name(const EC_GROUP *group);\n\nvoid EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);\nint EC_GROUP_get_asn1_flag(const EC_GROUP *group);\n\nvoid EC_GROUP_set_point_conversion_form(EC_GROUP *group,\n                                        point_conversion_form_t form);\npoint_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *);\n\nunsigned char *EC_GROUP_get0_seed(const EC_GROUP *x);\nsize_t EC_GROUP_get_seed_len(const EC_GROUP *);\nsize_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len);\n\n/** Sets the parameters of a ec curve defined by y^2 = x^3 + a*x + b (for GFp)\n *  or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a,\n                       const BIGNUM *b, BN_CTX *ctx);\n\n/** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp)\n *  or y^2 + x*y = x^3 + a*x^2 + b (for GF2m)\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b,\n                       BN_CTX *ctx);\n\n/** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p,\n                                              const BIGNUM *a, const BIGNUM *b,\n                                              BN_CTX *ctx))\n\n/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p,\n                                              BIGNUM *a, BIGNUM *b,\n                                              BN_CTX *ctx))\n\n# ifndef OPENSSL_NO_EC2M\n/** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM with parameter a of the equation\n *  \\param  b      BIGNUM with parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p,\n                                               const BIGNUM *a, const BIGNUM *b,\n                                               BN_CTX *ctx))\n\n/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve\n *  \\param  group  EC_GROUP object\n *  \\param  p      BIGNUM with the prime number (GFp) or the polynomial\n *                 defining the underlying field (GF2m)\n *  \\param  a      BIGNUM for parameter a of the equation\n *  \\param  b      BIGNUM for parameter b of the equation\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p,\n                                               BIGNUM *a, BIGNUM *b,\n                                               BN_CTX *ctx))\n# endif\n/** Returns the number of bits needed to represent a field element\n *  \\param  group  EC_GROUP object\n *  \\return number of bits needed to represent a field element\n */\nint EC_GROUP_get_degree(const EC_GROUP *group);\n\n/** Checks whether the parameter in the EC_GROUP define a valid ec group\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if group is a valid ec group and 0 otherwise\n */\nint EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Checks whether the discriminant of the elliptic curve is zero or not\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if the discriminant is not zero and 0 otherwise\n */\nint EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);\n\n/** Compares two EC_GROUP objects\n *  \\param  a    first EC_GROUP object\n *  \\param  b    second EC_GROUP object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 0 if the groups are equal, 1 if not, or -1 on error\n */\nint EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx);\n\n/*\n * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after\n * choosing an appropriate EC_METHOD\n */\n\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GFp (defined by the equation y^2 = x^3 + a*x + b)\n *  \\param  p    BIGNUM with the prime number\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a,\n                                 const BIGNUM *b, BN_CTX *ctx);\n# ifndef OPENSSL_NO_EC2M\n/** Creates a new EC_GROUP object with the specified parameters defined\n *  over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b)\n *  \\param  p    BIGNUM with the polynomial defining the underlying field\n *  \\param  a    BIGNUM with the parameter a of the equation\n *  \\param  b    BIGNUM with the parameter b of the equation\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return newly created EC_GROUP object with the specified parameters\n */\nEC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a,\n                                  const BIGNUM *b, BN_CTX *ctx);\n# endif\n\n/** Creates a EC_GROUP object with a curve specified by a NID\n *  \\param  nid  NID of the OID of the curve name\n *  \\return newly created EC_GROUP object with specified curve or NULL\n *          if an error occurred\n */\nEC_GROUP *EC_GROUP_new_by_curve_name(int nid);\n\n/** Creates a new EC_GROUP object from an ECPARAMETERS object\n *  \\param  params  pointer to the ECPARAMETERS object\n *  \\return newly created EC_GROUP object with specified curve or NULL\n *          if an error occurred\n */\nEC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params);\n\n/** Creates an ECPARAMETERS object for the given EC_GROUP object.\n *  \\param  group   pointer to the EC_GROUP object\n *  \\param  params  pointer to an existing ECPARAMETERS object or NULL\n *  \\return pointer to the new ECPARAMETERS object or NULL\n *          if an error occurred.\n */\nECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group,\n                                        ECPARAMETERS *params);\n\n/** Creates a new EC_GROUP object from an ECPKPARAMETERS object\n *  \\param  params  pointer to an existing ECPKPARAMETERS object, or NULL\n *  \\return newly created EC_GROUP object with specified curve, or NULL\n *          if an error occurred\n */\nEC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params);\n\n/** Creates an ECPKPARAMETERS object for the given EC_GROUP object.\n *  \\param  group   pointer to the EC_GROUP object\n *  \\param  params  pointer to an existing ECPKPARAMETERS object or NULL\n *  \\return pointer to the new ECPKPARAMETERS object or NULL\n *          if an error occurred.\n */\nECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group,\n                                            ECPKPARAMETERS *params);\n\n/********************************************************************/\n/*               handling of internal curves                        */\n/********************************************************************/\n\ntypedef struct {\n    int nid;\n    const char *comment;\n} EC_builtin_curve;\n\n/*\n * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all\n * available curves or zero if a error occurred. In case r is not zero,\n * nitems EC_builtin_curve structures are filled with the data of the first\n * nitems internal groups\n */\nsize_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems);\n\nconst char *EC_curve_nid2nist(int nid);\nint EC_curve_nist2nid(const char *name);\n\n/********************************************************************/\n/*                    EC_POINT functions                            */\n/********************************************************************/\n\n/** Creates a new EC_POINT object for the specified EC_GROUP\n *  \\param  group  EC_GROUP the underlying EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_new(const EC_GROUP *group);\n\n/** Frees a EC_POINT object\n *  \\param  point  EC_POINT object to be freed\n */\nvoid EC_POINT_free(EC_POINT *point);\n\n/** Clears and frees a EC_POINT object\n *  \\param  point  EC_POINT object to be cleared and freed\n */\nvoid EC_POINT_clear_free(EC_POINT *point);\n\n/** Copies EC_POINT object\n *  \\param  dst  destination EC_POINT object\n *  \\param  src  source EC_POINT object\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_copy(EC_POINT *dst, const EC_POINT *src);\n\n/** Creates a new EC_POINT object and copies the content of the supplied\n *  EC_POINT\n *  \\param  src    source EC_POINT object\n *  \\param  group  underlying the EC_GROUP object\n *  \\return newly created EC_POINT object or NULL if an error occurred\n */\nEC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group);\n\n/** Returns the EC_METHOD used in EC_POINT object\n *  \\param  point  EC_POINT object\n *  \\return the EC_METHOD used\n */\nconst EC_METHOD *EC_POINT_method_of(const EC_POINT *point);\n\n/** Sets a point to infinity (neutral element)\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT to set to infinity\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point);\n\n/** Sets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  z      BIGNUM with the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             EC_POINT *p, const BIGNUM *x,\n                                             const BIGNUM *y, const BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Gets the jacobian projective coordinates of a EC_POINT over GFp\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  z      BIGNUM for the z-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,\n                                             const EC_POINT *p, BIGNUM *x,\n                                             BIGNUM *y, BIGNUM *z,\n                                             BN_CTX *ctx);\n\n/** Sets the affine coordinates of an EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p,\n                                    const BIGNUM *x, const BIGNUM *y,\n                                    BN_CTX *ctx);\n\n/** Gets the affine coordinates of an EC_POINT.\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p,\n                                    BIGNUM *x, BIGNUM *y, BN_CTX *ctx);\n\n/** Sets the affine coordinates of an EC_POINT. A synonym of\n *  EC_POINT_set_affine_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group,\n                                                           EC_POINT *p,\n                                                           const BIGNUM *x,\n                                                           const BIGNUM *y,\n                                                           BN_CTX *ctx))\n\n/** Gets the affine coordinates of an EC_POINT. A synonym of\n *  EC_POINT_get_affine_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,\n                                                           const EC_POINT *p,\n                                                           BIGNUM *x,\n                                                           BIGNUM *y,\n                                                           BN_CTX *ctx))\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p,\n                                        const BIGNUM *x, int y_bit,\n                                        BN_CTX *ctx);\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of\n *  EC_POINT_set_compressed_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group,\n                                                               EC_POINT *p,\n                                                               const BIGNUM *x,\n                                                               int y_bit,\n                                                               BN_CTX *ctx))\n# ifndef OPENSSL_NO_EC2M\n/** Sets the affine coordinates of an EC_POINT. A synonym of\n *  EC_POINT_set_affine_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with the x-coordinate\n *  \\param  y      BIGNUM with the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group,\n                                                            EC_POINT *p,\n                                                            const BIGNUM *x,\n                                                            const BIGNUM *y,\n                                                            BN_CTX *ctx))\n\n/** Gets the affine coordinates of an EC_POINT. A synonym of\n *  EC_POINT_get_affine_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM for the x-coordinate\n *  \\param  y      BIGNUM for the y-coordinate\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,\n                                                            const EC_POINT *p,\n                                                            BIGNUM *x,\n                                                            BIGNUM *y,\n                                                            BN_CTX *ctx))\n\n/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of\n *  EC_POINT_set_compressed_coordinates\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  x      BIGNUM with x-coordinate\n *  \\param  y_bit  integer with the y-Bit (either 0 or 1)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nDEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group,\n                                                                EC_POINT *p,\n                                                                const BIGNUM *x,\n                                                                int y_bit,\n                                                                BN_CTX *ctx))\n# endif\n/** Encodes a EC_POINT object to a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  form   point conversion form\n *  \\param  buf    memory buffer for the result. If NULL the function returns\n *                 required buffer size.\n *  \\param  len    length of the memory buffer\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p,\n                          point_conversion_form_t form,\n                          unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/** Decodes a EC_POINT from a octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\param  buf    memory buffer with the encoded ec point\n *  \\param  len    length of the encoded ec point\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p,\n                       const unsigned char *buf, size_t len, BN_CTX *ctx);\n\n/** Encodes an EC_POINT object to an allocated octet string\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT object\n *  \\param  form   point conversion form\n *  \\param  pbuf   returns pointer to allocated buffer\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,\n                          point_conversion_form_t form,\n                          unsigned char **pbuf, BN_CTX *ctx);\n\n/* other interfaces to point2oct/oct2point: */\nBIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,\n                          point_conversion_form_t form, BIGNUM *, BN_CTX *);\nEC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *,\n                            EC_POINT *, BN_CTX *);\nchar *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *,\n                         point_conversion_form_t form, BN_CTX *);\nEC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *,\n                             EC_POINT *, BN_CTX *);\n\n/********************************************************************/\n/*         functions for doing EC_POINT arithmetic                  */\n/********************************************************************/\n\n/** Computes the sum of two EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = a + b)\n *  \\param  a      EC_POINT object with the first summand\n *  \\param  b      EC_POINT object with the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 const EC_POINT *b, BN_CTX *ctx);\n\n/** Computes the double of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result (r = 2 * a)\n *  \\param  a      EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,\n                 BN_CTX *ctx);\n\n/** Computes the inverse of a EC_POINT\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      EC_POINT object to be inverted (it's used for the result as well)\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx);\n\n/** Checks whether the point is the neutral element of the group\n *  \\param  group  the underlying EC_GROUP object\n *  \\param  p      EC_POINT object\n *  \\return 1 if the point is the neutral element and 0 otherwise\n */\nint EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p);\n\n/** Checks whether the point is on the curve\n *  \\param  group  underlying EC_GROUP object\n *  \\param  point  EC_POINT object to check\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if the point is on the curve, 0 if not, or -1 on error\n */\nint EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point,\n                         BN_CTX *ctx);\n\n/** Compares two EC_POINTs\n *  \\param  group  underlying EC_GROUP object\n *  \\param  a      first EC_POINT object\n *  \\param  b      second EC_POINT object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 if the points are not equal, 0 if they are, or -1 on error\n */\nint EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,\n                 BN_CTX *ctx);\n\nint EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);\nint EC_POINTs_make_affine(const EC_GROUP *group, size_t num,\n                          EC_POINT *points[], BN_CTX *ctx);\n\n/** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i]\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  num    number further summands\n *  \\param  p      array of size num of EC_POINT objects\n *  \\param  m      array of size num of BIGNUM objects\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                  size_t num, const EC_POINT *p[], const BIGNUM *m[],\n                  BN_CTX *ctx);\n\n/** Computes r = generator * n + q * m\n *  \\param  group  underlying EC_GROUP object\n *  \\param  r      EC_POINT object for the result\n *  \\param  n      BIGNUM with the multiplier for the group generator (optional)\n *  \\param  q      EC_POINT object with the first factor of the second summand\n *  \\param  m      BIGNUM with the second factor of the second summand\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n,\n                 const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx);\n\n/** Stores multiples of generator for faster point multiplication\n *  \\param  group  EC_GROUP object\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx);\n\n/** Reports whether a precomputation has been done\n *  \\param  group  EC_GROUP object\n *  \\return 1 if a pre-computation has been done and 0 otherwise\n */\nint EC_GROUP_have_precompute_mult(const EC_GROUP *group);\n\n/********************************************************************/\n/*                       ASN1 stuff                                 */\n/********************************************************************/\n\nDECLARE_ASN1_ITEM(ECPKPARAMETERS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS)\nDECLARE_ASN1_ITEM(ECPARAMETERS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS)\n\n/*\n * EC_GROUP_get_basis_type() returns the NID of the basis type used to\n * represent the field elements\n */\nint EC_GROUP_get_basis_type(const EC_GROUP *);\n# ifndef OPENSSL_NO_EC2M\nint EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k);\nint EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1,\n                                   unsigned int *k2, unsigned int *k3);\n# endif\n\n# define OPENSSL_EC_EXPLICIT_CURVE  0x000\n# define OPENSSL_EC_NAMED_CURVE     0x001\n\nEC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len);\nint i2d_ECPKParameters(const EC_GROUP *, unsigned char **out);\n\n# define d2i_ECPKParameters_bio(bp,x) \\\n    ASN1_d2i_bio_of(EC_GROUP, NULL, d2i_ECPKParameters, bp, x)\n# define i2d_ECPKParameters_bio(bp,x) \\\n    ASN1_i2d_bio_of_const(EC_GROUP, i2d_ECPKParameters, bp, x)\n# define d2i_ECPKParameters_fp(fp,x) \\\n    (EC_GROUP *)ASN1_d2i_fp(NULL, (d2i_of_void *)d2i_ECPKParameters, (fp), \\\n                            (void **)(x))\n# define i2d_ECPKParameters_fp(fp,x) \\\n    ASN1_i2d_fp((i2d_of_void *)i2d_ECPKParameters, (fp), (void *)(x))\n\nint ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off);\n# ifndef OPENSSL_NO_STDIO\nint ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off);\n# endif\n\n/********************************************************************/\n/*                      EC_KEY functions                            */\n/********************************************************************/\n\n/* some values for the encoding_flag */\n# define EC_PKEY_NO_PARAMETERS   0x001\n# define EC_PKEY_NO_PUBKEY       0x002\n\n/* some values for the flags field */\n# define EC_FLAG_NON_FIPS_ALLOW  0x1\n# define EC_FLAG_FIPS_CHECKED    0x2\n# define EC_FLAG_COFACTOR_ECDH   0x1000\n\n/** Creates a new EC_KEY object.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new(void);\n\nint EC_KEY_get_flags(const EC_KEY *key);\n\nvoid EC_KEY_set_flags(EC_KEY *key, int flags);\n\nvoid EC_KEY_clear_flags(EC_KEY *key, int flags);\n\nint EC_KEY_decoded_from_explicit_params(const EC_KEY *key);\n\n/** Creates a new EC_KEY object using a named curve as underlying\n *  EC_GROUP object.\n *  \\param  nid  NID of the named curve.\n *  \\return EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_new_by_curve_name(int nid);\n\n/** Frees a EC_KEY object.\n *  \\param  key  EC_KEY object to be freed.\n */\nvoid EC_KEY_free(EC_KEY *key);\n\n/** Copies a EC_KEY object.\n *  \\param  dst  destination EC_KEY object\n *  \\param  src  src EC_KEY object\n *  \\return dst or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src);\n\n/** Creates a new EC_KEY object and copies the content from src to it.\n *  \\param  src  the source EC_KEY object\n *  \\return newly created EC_KEY object or NULL if an error occurred.\n */\nEC_KEY *EC_KEY_dup(const EC_KEY *src);\n\n/** Increases the internal reference count of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_up_ref(EC_KEY *key);\n\n/** Returns the ENGINE object of a EC_KEY object\n *  \\param  eckey  EC_KEY object\n *  \\return the ENGINE object (possibly NULL).\n */\nENGINE *EC_KEY_get0_engine(const EC_KEY *eckey);\n\n/** Returns the EC_GROUP object of a EC_KEY object\n *  \\param  key  EC_KEY object\n *  \\return the EC_GROUP object (possibly NULL).\n */\nconst EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);\n\n/** Sets the EC_GROUP of a EC_KEY object.\n *  \\param  key    EC_KEY object\n *  \\param  group  EC_GROUP to use in the EC_KEY object (note: the EC_KEY\n *                 object will use an own copy of the EC_GROUP).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);\n\n/** Returns the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\return a BIGNUM with the private key (possibly NULL).\n */\nconst BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);\n\n/** Sets the private key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  prv  BIGNUM with the private key (note: the EC_KEY object\n *               will use an own copy of the BIGNUM).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);\n\n/** Returns the public key of a EC_KEY object.\n *  \\param  key  the EC_KEY object\n *  \\return a EC_POINT object with the public key (possibly NULL)\n */\nconst EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);\n\n/** Sets the public key of a EC_KEY object.\n *  \\param  key  EC_KEY object\n *  \\param  pub  EC_POINT object with the public key (note: the EC_KEY object\n *               will use an own copy of the EC_POINT object).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);\n\nunsigned EC_KEY_get_enc_flags(const EC_KEY *key);\nvoid EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags);\npoint_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);\nvoid EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);\n\n#define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)\nint EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg);\nvoid *EC_KEY_get_ex_data(const EC_KEY *key, int idx);\n\n/* wrapper functions for the underlying EC_GROUP object */\nvoid EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);\n\n/** Creates a table of pre-computed multiples of the generator to\n *  accelerate further EC_KEY operations.\n *  \\param  key  EC_KEY object\n *  \\param  ctx  BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);\n\n/** Creates a new ec private (and optional a new public) key.\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred.\n */\nint EC_KEY_generate_key(EC_KEY *key);\n\n/** Verifies that a private and/or public key is valid.\n *  \\param  key  the EC_KEY object\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_check_key(const EC_KEY *key);\n\n/** Indicates if an EC_KEY can be used for signing.\n *  \\param  eckey  the EC_KEY object\n *  \\return 1 if can can sign and 0 otherwise.\n */\nint EC_KEY_can_sign(const EC_KEY *eckey);\n\n/** Sets a public key from affine coordinates performing\n *  necessary NIST PKV tests.\n *  \\param  key  the EC_KEY object\n *  \\param  x    public key x coordinate\n *  \\param  y    public key y coordinate\n *  \\return 1 on success and 0 otherwise.\n */\nint EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,\n                                             BIGNUM *y);\n\n/** Encodes an EC_KEY public key to an allocated octet string\n *  \\param  key    key to encode\n *  \\param  form   point conversion form\n *  \\param  pbuf   returns pointer to allocated buffer\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form,\n                      unsigned char **pbuf, BN_CTX *ctx);\n\n/** Decodes a EC_KEY public key from a octet string\n *  \\param  key    key to decode\n *  \\param  buf    memory buffer with the encoded ec point\n *  \\param  len    length of the encoded ec point\n *  \\param  ctx    BN_CTX object (optional)\n *  \\return 1 on success and 0 if an error occurred\n */\n\nint EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len,\n                   BN_CTX *ctx);\n\n/** Decodes an EC_KEY private key from an octet string\n *  \\param  key    key to decode\n *  \\param  buf    memory buffer with the encoded private key\n *  \\param  len    length of the encoded key\n *  \\return 1 on success and 0 if an error occurred\n */\n\nint EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, size_t len);\n\n/** Encodes a EC_KEY private key to an octet string\n *  \\param  key    key to encode\n *  \\param  buf    memory buffer for the result. If NULL the function returns\n *                 required buffer size.\n *  \\param  len    length of the memory buffer\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\n\nsize_t EC_KEY_priv2oct(const EC_KEY *key, unsigned char *buf, size_t len);\n\n/** Encodes an EC_KEY private key to an allocated octet string\n *  \\param  eckey  key to encode\n *  \\param  pbuf   returns pointer to allocated buffer\n *  \\return the length of the encoded octet string or 0 if an error occurred\n */\nsize_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf);\n\n/********************************************************************/\n/*        de- and encoding functions for SEC1 ECPrivateKey          */\n/********************************************************************/\n\n/** Decodes a private key from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded private key\n *  \\param  len  length of the DER encoded private key\n *  \\return the decoded private key or NULL if an error occurred.\n */\nEC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a private key object and stores the result in a buffer.\n *  \\param  key  the EC_KEY object to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECPrivateKey(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*        de- and encoding functions for EC parameters              */\n/********************************************************************/\n\n/** Decodes ec parameter from a memory buffer.\n *  \\param  key  a pointer to a EC_KEY object which should be used (or NULL)\n *  \\param  in   pointer to memory with the DER encoded ec parameters\n *  \\param  len  length of the DER encoded ec parameters\n *  \\return a EC_KEY object with the decoded parameters or NULL if an error\n *          occurred.\n */\nEC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes ec parameter and stores the result in a buffer.\n *  \\param  key  the EC_KEY object with ec parameters to encode\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred.\n */\nint i2d_ECParameters(EC_KEY *key, unsigned char **out);\n\n/********************************************************************/\n/*         de- and encoding functions for EC public key             */\n/*         (octet string, not DER -- hence 'o2i' and 'i2o')         */\n/********************************************************************/\n\n/** Decodes a ec public key from a octet string.\n *  \\param  key  a pointer to a EC_KEY object which should be used\n *  \\param  in   memory buffer with the encoded public key\n *  \\param  len  length of the encoded public key\n *  \\return EC_KEY object with decoded public key or NULL if an error\n *          occurred.\n */\nEC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len);\n\n/** Encodes a ec public key in an octet string.\n *  \\param  key  the EC_KEY object with the public key\n *  \\param  out  the buffer for the result (if NULL the function returns number\n *               of bytes needed).\n *  \\return 1 on success and 0 if an error occurred\n */\nint i2o_ECPublicKey(const EC_KEY *key, unsigned char **out);\n\n/** Prints out the ec parameters on human readable form.\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print(BIO *bp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  bp   BIO object to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print(BIO *bp, const EC_KEY *key, int off);\n\n# ifndef OPENSSL_NO_STDIO\n/** Prints out the ec parameters on human readable form.\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\return 1 on success and 0 if an error occurred\n */\nint ECParameters_print_fp(FILE *fp, const EC_KEY *key);\n\n/** Prints out the contents of a EC_KEY object\n *  \\param  fp   file descriptor to which the information is printed\n *  \\param  key  EC_KEY object\n *  \\param  off  line offset\n *  \\return 1 on success and 0 if an error occurred\n */\nint EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);\n\n# endif\n\nconst EC_KEY_METHOD *EC_KEY_OpenSSL(void);\nconst EC_KEY_METHOD *EC_KEY_get_default_method(void);\nvoid EC_KEY_set_default_method(const EC_KEY_METHOD *meth);\nconst EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key);\nint EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth);\nEC_KEY *EC_KEY_new_method(ENGINE *engine);\n\n/** The old name for ecdh_KDF_X9_63\n *  The ECDH KDF specification has been mistakingly attributed to ANSI X9.62,\n *  it is actually specified in ANSI X9.63.\n *  This identifier is retained for backwards compatibility\n */\nint ECDH_KDF_X9_62(unsigned char *out, size_t outlen,\n                   const unsigned char *Z, size_t Zlen,\n                   const unsigned char *sinfo, size_t sinfolen,\n                   const EVP_MD *md);\n\nint ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,\n                     const EC_KEY *ecdh,\n                     void *(*KDF) (const void *in, size_t inlen,\n                                   void *out, size_t *outlen));\n\ntypedef struct ECDSA_SIG_st ECDSA_SIG;\n\n/** Allocates and initialize a ECDSA_SIG structure\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_SIG_new(void);\n\n/** frees a ECDSA_SIG structure\n *  \\param  sig  pointer to the ECDSA_SIG structure\n */\nvoid ECDSA_SIG_free(ECDSA_SIG *sig);\n\n/** DER encode content of ECDSA_SIG object (note: this function modifies *pp\n *  (*pp += length of the DER encoded signature)).\n *  \\param  sig  pointer to the ECDSA_SIG object\n *  \\param  pp   pointer to a unsigned char pointer for the output or NULL\n *  \\return the length of the DER encoded ECDSA_SIG object or a negative value\n *          on error\n */\nint i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp);\n\n/** Decodes a DER encoded ECDSA signature (note: this function changes *pp\n *  (*pp += len)).\n *  \\param  sig  pointer to ECDSA_SIG pointer (may be NULL)\n *  \\param  pp   memory buffer with the DER encoded signature\n *  \\param  len  length of the buffer\n *  \\return pointer to the decoded ECDSA_SIG structure (or NULL)\n */\nECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len);\n\n/** Accessor for r and s fields of ECDSA_SIG\n *  \\param  sig  pointer to ECDSA_SIG structure\n *  \\param  pr   pointer to BIGNUM pointer for r (may be NULL)\n *  \\param  ps   pointer to BIGNUM pointer for s (may be NULL)\n */\nvoid ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps);\n\n/** Accessor for r field of ECDSA_SIG\n *  \\param  sig  pointer to ECDSA_SIG structure\n */\nconst BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig);\n\n/** Accessor for s field of ECDSA_SIG\n *  \\param  sig  pointer to ECDSA_SIG structure\n */\nconst BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig);\n\n/** Setter for r and s fields of ECDSA_SIG\n *  \\param  sig  pointer to ECDSA_SIG structure\n *  \\param  r    pointer to BIGNUM for r (may be NULL)\n *  \\param  s    pointer to BIGNUM for s (may be NULL)\n */\nint ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s);\n\n/** Computes the ECDSA signature of the given hash value using\n *  the supplied private key and returns the created signature.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  eckey     EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len,\n                         EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optional),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return pointer to a ECDSA_SIG structure or NULL if an error occurred\n */\nECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen,\n                            const BIGNUM *kinv, const BIGNUM *rp,\n                            EC_KEY *eckey);\n\n/** Verifies that the supplied signature is a valid ECDSA\n *  signature of the supplied hash value using the supplied public key.\n *  \\param  dgst      pointer to the hash value\n *  \\param  dgst_len  length of the hash value\n *  \\param  sig       ECDSA_SIG structure\n *  \\param  eckey     EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_do_verify(const unsigned char *dgst, int dgst_len,\n                    const ECDSA_SIG *sig, EC_KEY *eckey);\n\n/** Precompute parts of the signing operation\n *  \\param  eckey  EC_KEY object containing a private EC key\n *  \\param  ctx    BN_CTX object (optional)\n *  \\param  kinv   BIGNUM pointer for the inverse of k\n *  \\param  rp     BIGNUM pointer for x coordinate of k * generator\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      memory for the DER encoded created signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign(int type, const unsigned char *dgst, int dgstlen,\n               unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);\n\n/** Computes ECDSA signature of a given hash value using the supplied\n *  private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value to sign\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      buffer to hold the DER encoded signature\n *  \\param  siglen   pointer to the length of the returned signature\n *  \\param  kinv     BIGNUM with a pre-computed inverse k (optional)\n *  \\param  rp       BIGNUM with a pre-computed rp value (optional),\n *                   see ECDSA_sign_setup\n *  \\param  eckey    EC_KEY object containing a private EC key\n *  \\return 1 on success and 0 otherwise\n */\nint ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen,\n                  unsigned char *sig, unsigned int *siglen,\n                  const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);\n\n/** Verifies that the given signature is valid ECDSA signature\n *  of the supplied hash value using the specified public key.\n *  \\param  type     this parameter is ignored\n *  \\param  dgst     pointer to the hash value\n *  \\param  dgstlen  length of the hash value\n *  \\param  sig      pointer to the DER encoded signature\n *  \\param  siglen   length of the DER encoded signature\n *  \\param  eckey    EC_KEY object containing a public EC key\n *  \\return 1 if the signature is valid, 0 if the signature is invalid\n *          and -1 on error\n */\nint ECDSA_verify(int type, const unsigned char *dgst, int dgstlen,\n                 const unsigned char *sig, int siglen, EC_KEY *eckey);\n\n/** Returns the maximum length of the DER encoded signature\n *  \\param  eckey  EC_KEY object\n *  \\return numbers of bytes required for the DER encoded signature\n */\nint ECDSA_size(const EC_KEY *eckey);\n\n/********************************************************************/\n/*  EC_KEY_METHOD constructors, destructors, writers and accessors  */\n/********************************************************************/\n\nEC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth);\nvoid EC_KEY_METHOD_free(EC_KEY_METHOD *meth);\nvoid EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth,\n                            int (*init)(EC_KEY *key),\n                            void (*finish)(EC_KEY *key),\n                            int (*copy)(EC_KEY *dest, const EC_KEY *src),\n                            int (*set_group)(EC_KEY *key, const EC_GROUP *grp),\n                            int (*set_private)(EC_KEY *key,\n                                               const BIGNUM *priv_key),\n                            int (*set_public)(EC_KEY *key,\n                                              const EC_POINT *pub_key));\n\nvoid EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth,\n                              int (*keygen)(EC_KEY *key));\n\nvoid EC_KEY_METHOD_set_compute_key(EC_KEY_METHOD *meth,\n                                   int (*ckey)(unsigned char **psec,\n                                               size_t *pseclen,\n                                               const EC_POINT *pub_key,\n                                               const EC_KEY *ecdh));\n\nvoid EC_KEY_METHOD_set_sign(EC_KEY_METHOD *meth,\n                            int (*sign)(int type, const unsigned char *dgst,\n                                        int dlen, unsigned char *sig,\n                                        unsigned int *siglen,\n                                        const BIGNUM *kinv, const BIGNUM *r,\n                                        EC_KEY *eckey),\n                            int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in,\n                                              BIGNUM **kinvp, BIGNUM **rp),\n                            ECDSA_SIG *(*sign_sig)(const unsigned char *dgst,\n                                                   int dgst_len,\n                                                   const BIGNUM *in_kinv,\n                                                   const BIGNUM *in_r,\n                                                   EC_KEY *eckey));\n\nvoid EC_KEY_METHOD_set_verify(EC_KEY_METHOD *meth,\n                              int (*verify)(int type, const unsigned\n                                            char *dgst, int dgst_len,\n                                            const unsigned char *sigbuf,\n                                            int sig_len, EC_KEY *eckey),\n                              int (*verify_sig)(const unsigned char *dgst,\n                                                int dgst_len,\n                                                const ECDSA_SIG *sig,\n                                                EC_KEY *eckey));\n\nvoid EC_KEY_METHOD_get_init(const EC_KEY_METHOD *meth,\n                            int (**pinit)(EC_KEY *key),\n                            void (**pfinish)(EC_KEY *key),\n                            int (**pcopy)(EC_KEY *dest, const EC_KEY *src),\n                            int (**pset_group)(EC_KEY *key,\n                                               const EC_GROUP *grp),\n                            int (**pset_private)(EC_KEY *key,\n                                                 const BIGNUM *priv_key),\n                            int (**pset_public)(EC_KEY *key,\n                                                const EC_POINT *pub_key));\n\nvoid EC_KEY_METHOD_get_keygen(const EC_KEY_METHOD *meth,\n                              int (**pkeygen)(EC_KEY *key));\n\nvoid EC_KEY_METHOD_get_compute_key(const EC_KEY_METHOD *meth,\n                                   int (**pck)(unsigned char **psec,\n                                               size_t *pseclen,\n                                               const EC_POINT *pub_key,\n                                               const EC_KEY *ecdh));\n\nvoid EC_KEY_METHOD_get_sign(const EC_KEY_METHOD *meth,\n                            int (**psign)(int type, const unsigned char *dgst,\n                                          int dlen, unsigned char *sig,\n                                          unsigned int *siglen,\n                                          const BIGNUM *kinv, const BIGNUM *r,\n                                          EC_KEY *eckey),\n                            int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in,\n                                                BIGNUM **kinvp, BIGNUM **rp),\n                            ECDSA_SIG *(**psign_sig)(const unsigned char *dgst,\n                                                     int dgst_len,\n                                                     const BIGNUM *in_kinv,\n                                                     const BIGNUM *in_r,\n                                                     EC_KEY *eckey));\n\nvoid EC_KEY_METHOD_get_verify(const EC_KEY_METHOD *meth,\n                              int (**pverify)(int type, const unsigned\n                                              char *dgst, int dgst_len,\n                                              const unsigned char *sigbuf,\n                                              int sig_len, EC_KEY *eckey),\n                              int (**pverify_sig)(const unsigned char *dgst,\n                                                  int dgst_len,\n                                                  const ECDSA_SIG *sig,\n                                                  EC_KEY *eckey));\n\n# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)\n\n# ifndef __cplusplus\n#  if defined(__SUNPRO_C)\n#   if __SUNPRO_C >= 0x520\n#    pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE)\n#   endif\n#  endif\n# endif\n\n# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)\n\n# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \\\n                                EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)(pmd))\n\n# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, \\\n                                (void *)(plen))\n\n# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)(p))\n\n# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \\\n                                EVP_PKEY_OP_DERIVE, \\\n                                EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)(p))\n\n/* SM2 will skip the operation check so no need to pass operation here */\n# define EVP_PKEY_CTX_set1_id(ctx, id, id_len) \\\n        EVP_PKEY_CTX_ctrl(ctx, -1, -1, \\\n                                EVP_PKEY_CTRL_SET1_ID, (int)id_len, (void*)(id))\n\n# define EVP_PKEY_CTX_get1_id(ctx, id) \\\n        EVP_PKEY_CTX_ctrl(ctx, -1, -1, \\\n                                EVP_PKEY_CTRL_GET1_ID, 0, (void*)(id))\n\n# define EVP_PKEY_CTX_get1_id_len(ctx, id_len) \\\n        EVP_PKEY_CTX_ctrl(ctx, -1, -1, \\\n                                EVP_PKEY_CTRL_GET1_ID_LEN, 0, (void*)(id_len))\n\n# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID             (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_EC_PARAM_ENC                      (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_EC_ECDH_COFACTOR                  (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_EC_KDF_TYPE                       (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_EC_KDF_MD                         (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_GET_EC_KDF_MD                     (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_EC_KDF_OUTLEN                     (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN                 (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_EC_KDF_UKM                        (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_GET_EC_KDF_UKM                    (EVP_PKEY_ALG_CTRL + 10)\n# define EVP_PKEY_CTRL_SET1_ID                           (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET1_ID                           (EVP_PKEY_ALG_CTRL + 12)\n# define EVP_PKEY_CTRL_GET1_ID_LEN                       (EVP_PKEY_ALG_CTRL + 13)\n/* KDF types */\n# define EVP_PKEY_ECDH_KDF_NONE                          1\n# define EVP_PKEY_ECDH_KDF_X9_63                         2\n/** The old name for EVP_PKEY_ECDH_KDF_X9_63\n *  The ECDH KDF specification has been mistakingly attributed to ANSI X9.62,\n *  it is actually specified in ANSI X9.63.\n *  This identifier is retained for backwards compatibility\n */\n# define EVP_PKEY_ECDH_KDF_X9_62   EVP_PKEY_ECDH_KDF_X9_63\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ecdh.h",
    "content": "/*\n * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/ec.h>\n"
  },
  {
    "path": "cryptomini/include/openssl/ecdsa.h",
    "content": "/*\n * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/ec.h>\n"
  },
  {
    "path": "cryptomini/include/openssl/ecerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ECERR_H\n# define HEADER_ECERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_EC\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_EC_strings(void);\n\n/*\n * EC function codes.\n */\n#  define EC_F_BN_TO_FELEM                                 224\n#  define EC_F_D2I_ECPARAMETERS                            144\n#  define EC_F_D2I_ECPKPARAMETERS                          145\n#  define EC_F_D2I_ECPRIVATEKEY                            146\n#  define EC_F_DO_EC_KEY_PRINT                             221\n#  define EC_F_ECDH_CMS_DECRYPT                            238\n#  define EC_F_ECDH_CMS_SET_SHARED_INFO                    239\n#  define EC_F_ECDH_COMPUTE_KEY                            246\n#  define EC_F_ECDH_SIMPLE_COMPUTE_KEY                     257\n#  define EC_F_ECDSA_DO_SIGN_EX                            251\n#  define EC_F_ECDSA_DO_VERIFY                             252\n#  define EC_F_ECDSA_SIGN_EX                               254\n#  define EC_F_ECDSA_SIGN_SETUP                            248\n#  define EC_F_ECDSA_SIG_NEW                               265\n#  define EC_F_ECDSA_VERIFY                                253\n#  define EC_F_ECD_ITEM_VERIFY                             270\n#  define EC_F_ECKEY_PARAM2TYPE                            223\n#  define EC_F_ECKEY_PARAM_DECODE                          212\n#  define EC_F_ECKEY_PRIV_DECODE                           213\n#  define EC_F_ECKEY_PRIV_ENCODE                           214\n#  define EC_F_ECKEY_PUB_DECODE                            215\n#  define EC_F_ECKEY_PUB_ENCODE                            216\n#  define EC_F_ECKEY_TYPE2PARAM                            220\n#  define EC_F_ECPARAMETERS_PRINT                          147\n#  define EC_F_ECPARAMETERS_PRINT_FP                       148\n#  define EC_F_ECPKPARAMETERS_PRINT                        149\n#  define EC_F_ECPKPARAMETERS_PRINT_FP                     150\n#  define EC_F_ECP_NISTZ256_GET_AFFINE                     240\n#  define EC_F_ECP_NISTZ256_INV_MOD_ORD                    275\n#  define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE                243\n#  define EC_F_ECP_NISTZ256_POINTS_MUL                     241\n#  define EC_F_ECP_NISTZ256_PRE_COMP_NEW                   244\n#  define EC_F_ECP_NISTZ256_WINDOWED_MUL                   242\n#  define EC_F_ECX_KEY_OP                                  266\n#  define EC_F_ECX_PRIV_ENCODE                             267\n#  define EC_F_ECX_PUB_ENCODE                              268\n#  define EC_F_EC_ASN1_GROUP2CURVE                         153\n#  define EC_F_EC_ASN1_GROUP2FIELDID                       154\n#  define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY           208\n#  define EC_F_EC_GF2M_SIMPLE_FIELD_INV                    296\n#  define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT     159\n#  define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE              195\n#  define EC_F_EC_GF2M_SIMPLE_LADDER_POST                  285\n#  define EC_F_EC_GF2M_SIMPLE_LADDER_PRE                   288\n#  define EC_F_EC_GF2M_SIMPLE_OCT2POINT                    160\n#  define EC_F_EC_GF2M_SIMPLE_POINT2OCT                    161\n#  define EC_F_EC_GF2M_SIMPLE_POINTS_MUL                   289\n#  define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162\n#  define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163\n#  define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES   164\n#  define EC_F_EC_GFP_MONT_FIELD_DECODE                    133\n#  define EC_F_EC_GFP_MONT_FIELD_ENCODE                    134\n#  define EC_F_EC_GFP_MONT_FIELD_INV                       297\n#  define EC_F_EC_GFP_MONT_FIELD_MUL                       131\n#  define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE                209\n#  define EC_F_EC_GFP_MONT_FIELD_SQR                       132\n#  define EC_F_EC_GFP_MONT_GROUP_SET_CURVE                 189\n#  define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE             225\n#  define EC_F_EC_GFP_NISTP224_POINTS_MUL                  228\n#  define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226\n#  define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE             230\n#  define EC_F_EC_GFP_NISTP256_POINTS_MUL                  231\n#  define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232\n#  define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE             233\n#  define EC_F_EC_GFP_NISTP521_POINTS_MUL                  234\n#  define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235\n#  define EC_F_EC_GFP_NIST_FIELD_MUL                       200\n#  define EC_F_EC_GFP_NIST_FIELD_SQR                       201\n#  define EC_F_EC_GFP_NIST_GROUP_SET_CURVE                 202\n#  define EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES             287\n#  define EC_F_EC_GFP_SIMPLE_FIELD_INV                     298\n#  define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT      165\n#  define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE               166\n#  define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE                   102\n#  define EC_F_EC_GFP_SIMPLE_OCT2POINT                     103\n#  define EC_F_EC_GFP_SIMPLE_POINT2OCT                     104\n#  define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE            137\n#  define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES  167\n#  define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES  168\n#  define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES    169\n#  define EC_F_EC_GROUP_CHECK                              170\n#  define EC_F_EC_GROUP_CHECK_DISCRIMINANT                 171\n#  define EC_F_EC_GROUP_COPY                               106\n#  define EC_F_EC_GROUP_GET_CURVE                          291\n#  define EC_F_EC_GROUP_GET_CURVE_GF2M                     172\n#  define EC_F_EC_GROUP_GET_CURVE_GFP                      130\n#  define EC_F_EC_GROUP_GET_DEGREE                         173\n#  define EC_F_EC_GROUP_GET_ECPARAMETERS                   261\n#  define EC_F_EC_GROUP_GET_ECPKPARAMETERS                 262\n#  define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS              193\n#  define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS                194\n#  define EC_F_EC_GROUP_NEW                                108\n#  define EC_F_EC_GROUP_NEW_BY_CURVE_NAME                  174\n#  define EC_F_EC_GROUP_NEW_FROM_DATA                      175\n#  define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS              263\n#  define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS            264\n#  define EC_F_EC_GROUP_SET_CURVE                          292\n#  define EC_F_EC_GROUP_SET_CURVE_GF2M                     176\n#  define EC_F_EC_GROUP_SET_CURVE_GFP                      109\n#  define EC_F_EC_GROUP_SET_GENERATOR                      111\n#  define EC_F_EC_GROUP_SET_SEED                           286\n#  define EC_F_EC_KEY_CHECK_KEY                            177\n#  define EC_F_EC_KEY_COPY                                 178\n#  define EC_F_EC_KEY_GENERATE_KEY                         179\n#  define EC_F_EC_KEY_NEW                                  182\n#  define EC_F_EC_KEY_NEW_METHOD                           245\n#  define EC_F_EC_KEY_OCT2PRIV                             255\n#  define EC_F_EC_KEY_PRINT                                180\n#  define EC_F_EC_KEY_PRINT_FP                             181\n#  define EC_F_EC_KEY_PRIV2BUF                             279\n#  define EC_F_EC_KEY_PRIV2OCT                             256\n#  define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES    229\n#  define EC_F_EC_KEY_SIMPLE_CHECK_KEY                     258\n#  define EC_F_EC_KEY_SIMPLE_OCT2PRIV                      259\n#  define EC_F_EC_KEY_SIMPLE_PRIV2OCT                      260\n#  define EC_F_EC_PKEY_CHECK                               273\n#  define EC_F_EC_PKEY_PARAM_CHECK                         274\n#  define EC_F_EC_POINTS_MAKE_AFFINE                       136\n#  define EC_F_EC_POINTS_MUL                               290\n#  define EC_F_EC_POINT_ADD                                112\n#  define EC_F_EC_POINT_BN2POINT                           280\n#  define EC_F_EC_POINT_CMP                                113\n#  define EC_F_EC_POINT_COPY                               114\n#  define EC_F_EC_POINT_DBL                                115\n#  define EC_F_EC_POINT_GET_AFFINE_COORDINATES             293\n#  define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M        183\n#  define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP         116\n#  define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP    117\n#  define EC_F_EC_POINT_INVERT                             210\n#  define EC_F_EC_POINT_IS_AT_INFINITY                     118\n#  define EC_F_EC_POINT_IS_ON_CURVE                        119\n#  define EC_F_EC_POINT_MAKE_AFFINE                        120\n#  define EC_F_EC_POINT_NEW                                121\n#  define EC_F_EC_POINT_OCT2POINT                          122\n#  define EC_F_EC_POINT_POINT2BUF                          281\n#  define EC_F_EC_POINT_POINT2OCT                          123\n#  define EC_F_EC_POINT_SET_AFFINE_COORDINATES             294\n#  define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M        185\n#  define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP         124\n#  define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES         295\n#  define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M    186\n#  define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP     125\n#  define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP    126\n#  define EC_F_EC_POINT_SET_TO_INFINITY                    127\n#  define EC_F_EC_PRE_COMP_NEW                             196\n#  define EC_F_EC_SCALAR_MUL_LADDER                        284\n#  define EC_F_EC_WNAF_MUL                                 187\n#  define EC_F_EC_WNAF_PRECOMPUTE_MULT                     188\n#  define EC_F_I2D_ECPARAMETERS                            190\n#  define EC_F_I2D_ECPKPARAMETERS                          191\n#  define EC_F_I2D_ECPRIVATEKEY                            192\n#  define EC_F_I2O_ECPUBLICKEY                             151\n#  define EC_F_NISTP224_PRE_COMP_NEW                       227\n#  define EC_F_NISTP256_PRE_COMP_NEW                       236\n#  define EC_F_NISTP521_PRE_COMP_NEW                       237\n#  define EC_F_O2I_ECPUBLICKEY                             152\n#  define EC_F_OLD_EC_PRIV_DECODE                          222\n#  define EC_F_OSSL_ECDH_COMPUTE_KEY                       247\n#  define EC_F_OSSL_ECDSA_SIGN_SIG                         249\n#  define EC_F_OSSL_ECDSA_VERIFY_SIG                       250\n#  define EC_F_PKEY_ECD_CTRL                               271\n#  define EC_F_PKEY_ECD_DIGESTSIGN                         272\n#  define EC_F_PKEY_ECD_DIGESTSIGN25519                    276\n#  define EC_F_PKEY_ECD_DIGESTSIGN448                      277\n#  define EC_F_PKEY_ECX_DERIVE                             269\n#  define EC_F_PKEY_EC_CTRL                                197\n#  define EC_F_PKEY_EC_CTRL_STR                            198\n#  define EC_F_PKEY_EC_DERIVE                              217\n#  define EC_F_PKEY_EC_INIT                                282\n#  define EC_F_PKEY_EC_KDF_DERIVE                          283\n#  define EC_F_PKEY_EC_KEYGEN                              199\n#  define EC_F_PKEY_EC_PARAMGEN                            219\n#  define EC_F_PKEY_EC_SIGN                                218\n#  define EC_F_VALIDATE_ECX_DERIVE                         278\n\n/*\n * EC reason codes.\n */\n#  define EC_R_ASN1_ERROR                                  115\n#  define EC_R_BAD_SIGNATURE                               156\n#  define EC_R_BIGNUM_OUT_OF_RANGE                         144\n#  define EC_R_BUFFER_TOO_SMALL                            100\n#  define EC_R_CANNOT_INVERT                               165\n#  define EC_R_COORDINATES_OUT_OF_RANGE                    146\n#  define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH                 160\n#  define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING              159\n#  define EC_R_D2I_ECPKPARAMETERS_FAILURE                  117\n#  define EC_R_DECODE_ERROR                                142\n#  define EC_R_DISCRIMINANT_IS_ZERO                        118\n#  define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE                119\n#  define EC_R_FIELD_TOO_LARGE                             143\n#  define EC_R_GF2M_NOT_SUPPORTED                          147\n#  define EC_R_GROUP2PKPARAMETERS_FAILURE                  120\n#  define EC_R_I2D_ECPKPARAMETERS_FAILURE                  121\n#  define EC_R_INCOMPATIBLE_OBJECTS                        101\n#  define EC_R_INVALID_ARGUMENT                            112\n#  define EC_R_INVALID_COMPRESSED_POINT                    110\n#  define EC_R_INVALID_COMPRESSION_BIT                     109\n#  define EC_R_INVALID_CURVE                               141\n#  define EC_R_INVALID_DIGEST                              151\n#  define EC_R_INVALID_DIGEST_TYPE                         138\n#  define EC_R_INVALID_ENCODING                            102\n#  define EC_R_INVALID_FIELD                               103\n#  define EC_R_INVALID_FORM                                104\n#  define EC_R_INVALID_GROUP_ORDER                         122\n#  define EC_R_INVALID_KEY                                 116\n#  define EC_R_INVALID_OUTPUT_LENGTH                       161\n#  define EC_R_INVALID_PEER_KEY                            133\n#  define EC_R_INVALID_PENTANOMIAL_BASIS                   132\n#  define EC_R_INVALID_PRIVATE_KEY                         123\n#  define EC_R_INVALID_TRINOMIAL_BASIS                     137\n#  define EC_R_KDF_PARAMETER_ERROR                         148\n#  define EC_R_KEYS_NOT_SET                                140\n#  define EC_R_LADDER_POST_FAILURE                         136\n#  define EC_R_LADDER_PRE_FAILURE                          153\n#  define EC_R_LADDER_STEP_FAILURE                         162\n#  define EC_R_MISSING_OID                                 167\n#  define EC_R_MISSING_PARAMETERS                          124\n#  define EC_R_MISSING_PRIVATE_KEY                         125\n#  define EC_R_NEED_NEW_SETUP_VALUES                       157\n#  define EC_R_NOT_A_NIST_PRIME                            135\n#  define EC_R_NOT_IMPLEMENTED                             126\n#  define EC_R_NOT_INITIALIZED                             111\n#  define EC_R_NO_PARAMETERS_SET                           139\n#  define EC_R_NO_PRIVATE_VALUE                            154\n#  define EC_R_OPERATION_NOT_SUPPORTED                     152\n#  define EC_R_PASSED_NULL_PARAMETER                       134\n#  define EC_R_PEER_KEY_ERROR                              149\n#  define EC_R_PKPARAMETERS2GROUP_FAILURE                  127\n#  define EC_R_POINT_ARITHMETIC_FAILURE                    155\n#  define EC_R_POINT_AT_INFINITY                           106\n#  define EC_R_POINT_COORDINATES_BLIND_FAILURE             163\n#  define EC_R_POINT_IS_NOT_ON_CURVE                       107\n#  define EC_R_RANDOM_NUMBER_GENERATION_FAILED             158\n#  define EC_R_SHARED_INFO_ERROR                           150\n#  define EC_R_SLOT_FULL                                   108\n#  define EC_R_UNDEFINED_GENERATOR                         113\n#  define EC_R_UNDEFINED_ORDER                             128\n#  define EC_R_UNKNOWN_COFACTOR                            164\n#  define EC_R_UNKNOWN_GROUP                               129\n#  define EC_R_UNKNOWN_ORDER                               114\n#  define EC_R_UNSUPPORTED_FIELD                           131\n#  define EC_R_WRONG_CURVE_PARAMETERS                      145\n#  define EC_R_WRONG_ORDER                                 130\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/engine.h",
    "content": "/*\n * Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ENGINE_H\n# define HEADER_ENGINE_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_ENGINE\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n#  include <openssl/rsa.h>\n#  include <openssl/dsa.h>\n#  include <openssl/dh.h>\n#  include <openssl/ec.h>\n#  include <openssl/rand.h>\n#  include <openssl/ui.h>\n#  include <openssl/err.h>\n# endif\n# include <openssl/ossl_typ.h>\n# include <openssl/symhacks.h>\n# include <openssl/x509.h>\n# include <openssl/engineerr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*\n * These flags are used to control combinations of algorithm (methods) by\n * bitwise \"OR\"ing.\n */\n# define ENGINE_METHOD_RSA               (unsigned int)0x0001\n# define ENGINE_METHOD_DSA               (unsigned int)0x0002\n# define ENGINE_METHOD_DH                (unsigned int)0x0004\n# define ENGINE_METHOD_RAND              (unsigned int)0x0008\n# define ENGINE_METHOD_CIPHERS           (unsigned int)0x0040\n# define ENGINE_METHOD_DIGESTS           (unsigned int)0x0080\n# define ENGINE_METHOD_PKEY_METHS        (unsigned int)0x0200\n# define ENGINE_METHOD_PKEY_ASN1_METHS   (unsigned int)0x0400\n# define ENGINE_METHOD_EC                (unsigned int)0x0800\n/* Obvious all-or-nothing cases. */\n# define ENGINE_METHOD_ALL               (unsigned int)0xFFFF\n# define ENGINE_METHOD_NONE              (unsigned int)0x0000\n\n/*\n * This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used\n * internally to control registration of ENGINE implementations, and can be\n * set by ENGINE_set_table_flags(). The \"NOINIT\" flag prevents attempts to\n * initialise registered ENGINEs if they are not already initialised.\n */\n# define ENGINE_TABLE_FLAG_NOINIT        (unsigned int)0x0001\n\n/* ENGINE flags that can be set by ENGINE_set_flags(). */\n/* Not used */\n/* #define ENGINE_FLAGS_MALLOCED        0x0001 */\n\n/*\n * This flag is for ENGINEs that wish to handle the various 'CMD'-related\n * control commands on their own. Without this flag, ENGINE_ctrl() handles\n * these control commands on behalf of the ENGINE using their \"cmd_defns\"\n * data.\n */\n# define ENGINE_FLAGS_MANUAL_CMD_CTRL    (int)0x0002\n\n/*\n * This flag is for ENGINEs who return new duplicate structures when found\n * via \"ENGINE_by_id()\". When an ENGINE must store state (eg. if\n * ENGINE_ctrl() commands are called in sequence as part of some stateful\n * process like key-generation setup and execution), it can set this flag -\n * then each attempt to obtain the ENGINE will result in it being copied into\n * a new structure. Normally, ENGINEs don't declare this flag so\n * ENGINE_by_id() just increments the existing ENGINE's structural reference\n * count.\n */\n# define ENGINE_FLAGS_BY_ID_COPY         (int)0x0004\n\n/*\n * This flag if for an ENGINE that does not want its methods registered as\n * part of ENGINE_register_all_complete() for example if the methods are not\n * usable as default methods.\n */\n\n# define ENGINE_FLAGS_NO_REGISTER_ALL    (int)0x0008\n\n/*\n * ENGINEs can support their own command types, and these flags are used in\n * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input\n * each command expects. Currently only numeric and string input is\n * supported. If a control command supports none of the _NUMERIC, _STRING, or\n * _NO_INPUT options, then it is regarded as an \"internal\" control command -\n * and not for use in config setting situations. As such, they're not\n * available to the ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl()\n * access. Changes to this list of 'command types' should be reflected\n * carefully in ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string().\n */\n\n/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */\n# define ENGINE_CMD_FLAG_NUMERIC         (unsigned int)0x0001\n/*\n * accepts string input (cast from 'void*' to 'const char *', 4th parameter\n * to ENGINE_ctrl)\n */\n# define ENGINE_CMD_FLAG_STRING          (unsigned int)0x0002\n/*\n * Indicates that the control command takes *no* input. Ie. the control\n * command is unparameterised.\n */\n# define ENGINE_CMD_FLAG_NO_INPUT        (unsigned int)0x0004\n/*\n * Indicates that the control command is internal. This control command won't\n * be shown in any output, and is only usable through the ENGINE_ctrl_cmd()\n * function.\n */\n# define ENGINE_CMD_FLAG_INTERNAL        (unsigned int)0x0008\n\n/*\n * NB: These 3 control commands are deprecated and should not be used.\n * ENGINEs relying on these commands should compile conditional support for\n * compatibility (eg. if these symbols are defined) but should also migrate\n * the same functionality to their own ENGINE-specific control functions that\n * can be \"discovered\" by calling applications. The fact these control\n * commands wouldn't be \"executable\" (ie. usable by text-based config)\n * doesn't change the fact that application code can find and use them\n * without requiring per-ENGINE hacking.\n */\n\n/*\n * These flags are used to tell the ctrl function what should be done. All\n * command numbers are shared between all engines, even if some don't make\n * sense to some engines.  In such a case, they do nothing but return the\n * error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED.\n */\n# define ENGINE_CTRL_SET_LOGSTREAM               1\n# define ENGINE_CTRL_SET_PASSWORD_CALLBACK       2\n# define ENGINE_CTRL_HUP                         3/* Close and reinitialise\n                                                   * any handles/connections\n                                                   * etc. */\n# define ENGINE_CTRL_SET_USER_INTERFACE          4/* Alternative to callback */\n# define ENGINE_CTRL_SET_CALLBACK_DATA           5/* User-specific data, used\n                                                   * when calling the password\n                                                   * callback and the user\n                                                   * interface */\n# define ENGINE_CTRL_LOAD_CONFIGURATION          6/* Load a configuration,\n                                                   * given a string that\n                                                   * represents a file name\n                                                   * or so */\n# define ENGINE_CTRL_LOAD_SECTION                7/* Load data from a given\n                                                   * section in the already\n                                                   * loaded configuration */\n\n/*\n * These control commands allow an application to deal with an arbitrary\n * engine in a dynamic way. Warn: Negative return values indicate errors FOR\n * THESE COMMANDS because zero is used to indicate 'end-of-list'. Other\n * commands, including ENGINE-specific command types, return zero for an\n * error. An ENGINE can choose to implement these ctrl functions, and can\n * internally manage things however it chooses - it does so by setting the\n * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise\n * the ENGINE_ctrl() code handles this on the ENGINE's behalf using the\n * cmd_defns data (set using ENGINE_set_cmd_defns()). This means an ENGINE's\n * ctrl() handler need only implement its own commands - the above \"meta\"\n * commands will be taken care of.\n */\n\n/*\n * Returns non-zero if the supplied ENGINE has a ctrl() handler. If \"not\",\n * then all the remaining control commands will return failure, so it is\n * worth checking this first if the caller is trying to \"discover\" the\n * engine's capabilities and doesn't want errors generated unnecessarily.\n */\n# define ENGINE_CTRL_HAS_CTRL_FUNCTION           10\n/*\n * Returns a positive command number for the first command supported by the\n * engine. Returns zero if no ctrl commands are supported.\n */\n# define ENGINE_CTRL_GET_FIRST_CMD_TYPE          11\n/*\n * The 'long' argument specifies a command implemented by the engine, and the\n * return value is the next command supported, or zero if there are no more.\n */\n# define ENGINE_CTRL_GET_NEXT_CMD_TYPE           12\n/*\n * The 'void*' argument is a command name (cast from 'const char *'), and the\n * return value is the command that corresponds to it.\n */\n# define ENGINE_CTRL_GET_CMD_FROM_NAME           13\n/*\n * The next two allow a command to be converted into its corresponding string\n * form. In each case, the 'long' argument supplies the command. In the\n * NAME_LEN case, the return value is the length of the command name (not\n * counting a trailing EOL). In the NAME case, the 'void*' argument must be a\n * string buffer large enough, and it will be populated with the name of the\n * command (WITH a trailing EOL).\n */\n# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD       14\n# define ENGINE_CTRL_GET_NAME_FROM_CMD           15\n/* The next two are similar but give a \"short description\" of a command. */\n# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD       16\n# define ENGINE_CTRL_GET_DESC_FROM_CMD           17\n/*\n * With this command, the return value is the OR'd combination of\n * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given\n * engine-specific ctrl command expects.\n */\n# define ENGINE_CTRL_GET_CMD_FLAGS               18\n\n/*\n * ENGINE implementations should start the numbering of their own control\n * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc).\n */\n# define ENGINE_CMD_BASE                         200\n\n/*\n * NB: These 2 nCipher \"chil\" control commands are deprecated, and their\n * functionality is now available through ENGINE-specific control commands\n * (exposed through the above-mentioned 'CMD'-handling). Code using these 2\n * commands should be migrated to the more general command handling before\n * these are removed.\n */\n\n/* Flags specific to the nCipher \"chil\" engine */\n# define ENGINE_CTRL_CHIL_SET_FORKCHECK          100\n        /*\n         * Depending on the value of the (long)i argument, this sets or\n         * unsets the SimpleForkCheck flag in the CHIL API to enable or\n         * disable checking and workarounds for applications that fork().\n         */\n# define ENGINE_CTRL_CHIL_NO_LOCKING             101\n        /*\n         * This prevents the initialisation function from providing mutex\n         * callbacks to the nCipher library.\n         */\n\n/*\n * If an ENGINE supports its own specific control commands and wishes the\n * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on\n * its behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN\n * entries to ENGINE_set_cmd_defns(). It should also implement a ctrl()\n * handler that supports the stated commands (ie. the \"cmd_num\" entries as\n * described by the array). NB: The array must be ordered in increasing order\n * of cmd_num. \"null-terminated\" means that the last ENGINE_CMD_DEFN element\n * has cmd_num set to zero and/or cmd_name set to NULL.\n */\ntypedef struct ENGINE_CMD_DEFN_st {\n    unsigned int cmd_num;       /* The command number */\n    const char *cmd_name;       /* The command name itself */\n    const char *cmd_desc;       /* A short description of the command */\n    unsigned int cmd_flags;     /* The input the command expects */\n} ENGINE_CMD_DEFN;\n\n/* Generic function pointer */\ntypedef int (*ENGINE_GEN_FUNC_PTR) (void);\n/* Generic function pointer taking no arguments */\ntypedef int (*ENGINE_GEN_INT_FUNC_PTR) (ENGINE *);\n/* Specific control function pointer */\ntypedef int (*ENGINE_CTRL_FUNC_PTR) (ENGINE *, int, long, void *,\n                                     void (*f) (void));\n/* Generic load_key function pointer */\ntypedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *,\n                                         UI_METHOD *ui_method,\n                                         void *callback_data);\ntypedef int (*ENGINE_SSL_CLIENT_CERT_PTR) (ENGINE *, SSL *ssl,\n                                           STACK_OF(X509_NAME) *ca_dn,\n                                           X509 **pcert, EVP_PKEY **pkey,\n                                           STACK_OF(X509) **pother,\n                                           UI_METHOD *ui_method,\n                                           void *callback_data);\n/*-\n * These callback types are for an ENGINE's handler for cipher and digest logic.\n * These handlers have these prototypes;\n *   int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid);\n *   int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);\n * Looking at how to implement these handlers in the case of cipher support, if\n * the framework wants the EVP_CIPHER for 'nid', it will call;\n *   foo(e, &p_evp_cipher, NULL, nid);    (return zero for failure)\n * If the framework wants a list of supported 'nid's, it will call;\n *   foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error)\n */\n/*\n * Returns to a pointer to the array of supported cipher 'nid's. If the\n * second parameter is non-NULL it is set to the size of the returned array.\n */\ntypedef int (*ENGINE_CIPHERS_PTR) (ENGINE *, const EVP_CIPHER **,\n                                   const int **, int);\ntypedef int (*ENGINE_DIGESTS_PTR) (ENGINE *, const EVP_MD **, const int **,\n                                   int);\ntypedef int (*ENGINE_PKEY_METHS_PTR) (ENGINE *, EVP_PKEY_METHOD **,\n                                      const int **, int);\ntypedef int (*ENGINE_PKEY_ASN1_METHS_PTR) (ENGINE *, EVP_PKEY_ASN1_METHOD **,\n                                           const int **, int);\n/*\n * STRUCTURE functions ... all of these functions deal with pointers to\n * ENGINE structures where the pointers have a \"structural reference\". This\n * means that their reference is to allowed access to the structure but it\n * does not imply that the structure is functional. To simply increment or\n * decrement the structural reference count, use ENGINE_by_id and\n * ENGINE_free. NB: This is not required when iterating using ENGINE_get_next\n * as it will automatically decrement the structural reference count of the\n * \"current\" ENGINE and increment the structural reference count of the\n * ENGINE it returns (unless it is NULL).\n */\n\n/* Get the first/last \"ENGINE\" type available. */\nENGINE *ENGINE_get_first(void);\nENGINE *ENGINE_get_last(void);\n/* Iterate to the next/previous \"ENGINE\" type (NULL = end of the list). */\nENGINE *ENGINE_get_next(ENGINE *e);\nENGINE *ENGINE_get_prev(ENGINE *e);\n/* Add another \"ENGINE\" type into the array. */\nint ENGINE_add(ENGINE *e);\n/* Remove an existing \"ENGINE\" type from the array. */\nint ENGINE_remove(ENGINE *e);\n/* Retrieve an engine from the list by its unique \"id\" value. */\nENGINE *ENGINE_by_id(const char *id);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define ENGINE_load_openssl() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL)\n# define ENGINE_load_dynamic() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL)\n# ifndef OPENSSL_NO_STATIC_ENGINE\n#  define ENGINE_load_padlock() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL)\n#  define ENGINE_load_capi() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL)\n#  define ENGINE_load_afalg() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL)\n# endif\n# define ENGINE_load_cryptodev() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL)\n# define ENGINE_load_rdrand() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL)\n#endif\nvoid ENGINE_load_builtin_engines(void);\n\n/*\n * Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation\n * \"registry\" handling.\n */\nunsigned int ENGINE_get_table_flags(void);\nvoid ENGINE_set_table_flags(unsigned int flags);\n\n/*- Manage registration of ENGINEs per \"table\". For each type, there are 3\n * functions;\n *   ENGINE_register_***(e) - registers the implementation from 'e' (if it has one)\n *   ENGINE_unregister_***(e) - unregister the implementation from 'e'\n *   ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list\n * Cleanup is automatically registered from each table when required.\n */\n\nint ENGINE_register_RSA(ENGINE *e);\nvoid ENGINE_unregister_RSA(ENGINE *e);\nvoid ENGINE_register_all_RSA(void);\n\nint ENGINE_register_DSA(ENGINE *e);\nvoid ENGINE_unregister_DSA(ENGINE *e);\nvoid ENGINE_register_all_DSA(void);\n\nint ENGINE_register_EC(ENGINE *e);\nvoid ENGINE_unregister_EC(ENGINE *e);\nvoid ENGINE_register_all_EC(void);\n\nint ENGINE_register_DH(ENGINE *e);\nvoid ENGINE_unregister_DH(ENGINE *e);\nvoid ENGINE_register_all_DH(void);\n\nint ENGINE_register_RAND(ENGINE *e);\nvoid ENGINE_unregister_RAND(ENGINE *e);\nvoid ENGINE_register_all_RAND(void);\n\nint ENGINE_register_ciphers(ENGINE *e);\nvoid ENGINE_unregister_ciphers(ENGINE *e);\nvoid ENGINE_register_all_ciphers(void);\n\nint ENGINE_register_digests(ENGINE *e);\nvoid ENGINE_unregister_digests(ENGINE *e);\nvoid ENGINE_register_all_digests(void);\n\nint ENGINE_register_pkey_meths(ENGINE *e);\nvoid ENGINE_unregister_pkey_meths(ENGINE *e);\nvoid ENGINE_register_all_pkey_meths(void);\n\nint ENGINE_register_pkey_asn1_meths(ENGINE *e);\nvoid ENGINE_unregister_pkey_asn1_meths(ENGINE *e);\nvoid ENGINE_register_all_pkey_asn1_meths(void);\n\n/*\n * These functions register all support from the above categories. Note, use\n * of these functions can result in static linkage of code your application\n * may not need. If you only need a subset of functionality, consider using\n * more selective initialisation.\n */\nint ENGINE_register_complete(ENGINE *e);\nint ENGINE_register_all_complete(void);\n\n/*\n * Send parameterised control commands to the engine. The possibilities to\n * send down an integer, a pointer to data or a function pointer are\n * provided. Any of the parameters may or may not be NULL, depending on the\n * command number. In actuality, this function only requires a structural\n * (rather than functional) reference to an engine, but many control commands\n * may require the engine be functional. The caller should be aware of trying\n * commands that require an operational ENGINE, and only use functional\n * references in such situations.\n */\nint ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void));\n\n/*\n * This function tests if an ENGINE-specific command is usable as a\n * \"setting\". Eg. in an application's config file that gets processed through\n * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to\n * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl().\n */\nint ENGINE_cmd_is_executable(ENGINE *e, int cmd);\n\n/*\n * This function works like ENGINE_ctrl() with the exception of taking a\n * command name instead of a command number, and can handle optional\n * commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation\n * on how to use the cmd_name and cmd_optional.\n */\nint ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name,\n                    long i, void *p, void (*f) (void), int cmd_optional);\n\n/*\n * This function passes a command-name and argument to an ENGINE. The\n * cmd_name is converted to a command number and the control command is\n * called using 'arg' as an argument (unless the ENGINE doesn't support such\n * a command, in which case no control command is called). The command is\n * checked for input flags, and if necessary the argument will be converted\n * to a numeric value. If cmd_optional is non-zero, then if the ENGINE\n * doesn't support the given cmd_name the return value will be success\n * anyway. This function is intended for applications to use so that users\n * (or config files) can supply engine-specific config data to the ENGINE at\n * run-time to control behaviour of specific engines. As such, it shouldn't\n * be used for calling ENGINE_ctrl() functions that return data, deal with\n * binary data, or that are otherwise supposed to be used directly through\n * ENGINE_ctrl() in application code. Any \"return\" data from an ENGINE_ctrl()\n * operation in this function will be lost - the return value is interpreted\n * as failure if the return value is zero, success otherwise, and this\n * function returns a boolean value as a result. In other words, vendors of\n * 'ENGINE'-enabled devices should write ENGINE implementations with\n * parameterisations that work in this scheme, so that compliant ENGINE-based\n * applications can work consistently with the same configuration for the\n * same ENGINE-enabled devices, across applications.\n */\nint ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,\n                           int cmd_optional);\n\n/*\n * These functions are useful for manufacturing new ENGINE structures. They\n * don't address reference counting at all - one uses them to populate an\n * ENGINE structure with personalised implementations of things prior to\n * using it directly or adding it to the builtin ENGINE list in OpenSSL.\n * These are also here so that the ENGINE structure doesn't have to be\n * exposed and break binary compatibility!\n */\nENGINE *ENGINE_new(void);\nint ENGINE_free(ENGINE *e);\nint ENGINE_up_ref(ENGINE *e);\nint ENGINE_set_id(ENGINE *e, const char *id);\nint ENGINE_set_name(ENGINE *e, const char *name);\nint ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);\nint ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);\nint ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth);\nint ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);\nint ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);\nint ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);\nint ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);\nint ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);\nint ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);\nint ENGINE_set_load_privkey_function(ENGINE *e,\n                                     ENGINE_LOAD_KEY_PTR loadpriv_f);\nint ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f);\nint ENGINE_set_load_ssl_client_cert_function(ENGINE *e,\n                                             ENGINE_SSL_CLIENT_CERT_PTR\n                                             loadssl_f);\nint ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f);\nint ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f);\nint ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f);\nint ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f);\nint ENGINE_set_flags(ENGINE *e, int flags);\nint ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns);\n/* These functions allow control over any per-structure ENGINE data. */\n#define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef)\nint ENGINE_set_ex_data(ENGINE *e, int idx, void *arg);\nvoid *ENGINE_get_ex_data(const ENGINE *e, int idx);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * This function previously cleaned up anything that needs it. Auto-deinit will\n * now take care of it so it is no longer required to call this function.\n */\n# define ENGINE_cleanup() while(0) continue\n#endif\n\n/*\n * These return values from within the ENGINE structure. These can be useful\n * with functional references as well as structural references - it depends\n * which you obtained. Using the result for functional purposes if you only\n * obtained a structural reference may be problematic!\n */\nconst char *ENGINE_get_id(const ENGINE *e);\nconst char *ENGINE_get_name(const ENGINE *e);\nconst RSA_METHOD *ENGINE_get_RSA(const ENGINE *e);\nconst DSA_METHOD *ENGINE_get_DSA(const ENGINE *e);\nconst EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e);\nconst DH_METHOD *ENGINE_get_DH(const ENGINE *e);\nconst RAND_METHOD *ENGINE_get_RAND(const ENGINE *e);\nENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);\nENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);\nENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);\nENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);\nENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e);\nENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e);\nENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE\n                                                               *e);\nENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e);\nENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e);\nENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e);\nENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e);\nconst EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid);\nconst EVP_MD *ENGINE_get_digest(ENGINE *e, int nid);\nconst EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid);\nconst EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid);\nconst EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e,\n                                                          const char *str,\n                                                          int len);\nconst EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,\n                                                      const char *str,\n                                                      int len);\nconst ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e);\nint ENGINE_get_flags(const ENGINE *e);\n\n/*\n * FUNCTIONAL functions. These functions deal with ENGINE structures that\n * have (or will) be initialised for use. Broadly speaking, the structural\n * functions are useful for iterating the list of available engine types,\n * creating new engine types, and other \"list\" operations. These functions\n * actually deal with ENGINEs that are to be used. As such these functions\n * can fail (if applicable) when particular engines are unavailable - eg. if\n * a hardware accelerator is not attached or not functioning correctly. Each\n * ENGINE has 2 reference counts; structural and functional. Every time a\n * functional reference is obtained or released, a corresponding structural\n * reference is automatically obtained or released too.\n */\n\n/*\n * Initialise a engine type for use (or up its reference count if it's\n * already in use). This will fail if the engine is not currently operational\n * and cannot initialise.\n */\nint ENGINE_init(ENGINE *e);\n/*\n * Free a functional reference to a engine type. This does not require a\n * corresponding call to ENGINE_free as it also releases a structural\n * reference.\n */\nint ENGINE_finish(ENGINE *e);\n\n/*\n * The following functions handle keys that are stored in some secondary\n * location, handled by the engine.  The storage may be on a card or\n * whatever.\n */\nEVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id,\n                                  UI_METHOD *ui_method, void *callback_data);\nEVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id,\n                                 UI_METHOD *ui_method, void *callback_data);\nint ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s,\n                                STACK_OF(X509_NAME) *ca_dn, X509 **pcert,\n                                EVP_PKEY **ppkey, STACK_OF(X509) **pother,\n                                UI_METHOD *ui_method, void *callback_data);\n\n/*\n * This returns a pointer for the current ENGINE structure that is (by\n * default) performing any RSA operations. The value returned is an\n * incremented reference, so it should be free'd (ENGINE_finish) before it is\n * discarded.\n */\nENGINE *ENGINE_get_default_RSA(void);\n/* Same for the other \"methods\" */\nENGINE *ENGINE_get_default_DSA(void);\nENGINE *ENGINE_get_default_EC(void);\nENGINE *ENGINE_get_default_DH(void);\nENGINE *ENGINE_get_default_RAND(void);\n/*\n * These functions can be used to get a functional reference to perform\n * ciphering or digesting corresponding to \"nid\".\n */\nENGINE *ENGINE_get_cipher_engine(int nid);\nENGINE *ENGINE_get_digest_engine(int nid);\nENGINE *ENGINE_get_pkey_meth_engine(int nid);\nENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid);\n\n/*\n * This sets a new default ENGINE structure for performing RSA operations. If\n * the result is non-zero (success) then the ENGINE structure will have had\n * its reference count up'd so the caller should still free their own\n * reference 'e'.\n */\nint ENGINE_set_default_RSA(ENGINE *e);\nint ENGINE_set_default_string(ENGINE *e, const char *def_list);\n/* Same for the other \"methods\" */\nint ENGINE_set_default_DSA(ENGINE *e);\nint ENGINE_set_default_EC(ENGINE *e);\nint ENGINE_set_default_DH(ENGINE *e);\nint ENGINE_set_default_RAND(ENGINE *e);\nint ENGINE_set_default_ciphers(ENGINE *e);\nint ENGINE_set_default_digests(ENGINE *e);\nint ENGINE_set_default_pkey_meths(ENGINE *e);\nint ENGINE_set_default_pkey_asn1_meths(ENGINE *e);\n\n/*\n * The combination \"set\" - the flags are bitwise \"OR\"d from the\n * ENGINE_METHOD_*** defines above. As with the \"ENGINE_register_complete()\"\n * function, this function can result in unnecessary static linkage. If your\n * application requires only specific functionality, consider using more\n * selective functions.\n */\nint ENGINE_set_default(ENGINE *e, unsigned int flags);\n\nvoid ENGINE_add_conf_module(void);\n\n/* Deprecated functions ... */\n/* int ENGINE_clear_defaults(void); */\n\n/**************************/\n/* DYNAMIC ENGINE SUPPORT */\n/**************************/\n\n/* Binary/behaviour compatibility levels */\n# define OSSL_DYNAMIC_VERSION            (unsigned long)0x00030000\n/*\n * Binary versions older than this are too old for us (whether we're a loader\n * or a loadee)\n */\n# define OSSL_DYNAMIC_OLDEST             (unsigned long)0x00030000\n\n/*\n * When compiling an ENGINE entirely as an external shared library, loadable\n * by the \"dynamic\" ENGINE, these types are needed. The 'dynamic_fns'\n * structure type provides the calling application's (or library's) error\n * functionality and memory management function pointers to the loaded\n * library. These should be used/set in the loaded library code so that the\n * loading application's 'state' will be used/changed in all operations. The\n * 'static_state' pointer allows the loaded library to know if it shares the\n * same static data as the calling application (or library), and thus whether\n * these callbacks need to be set or not.\n */\ntypedef void *(*dyn_MEM_malloc_fn) (size_t, const char *, int);\ntypedef void *(*dyn_MEM_realloc_fn) (void *, size_t, const char *, int);\ntypedef void (*dyn_MEM_free_fn) (void *, const char *, int);\ntypedef struct st_dynamic_MEM_fns {\n    dyn_MEM_malloc_fn malloc_fn;\n    dyn_MEM_realloc_fn realloc_fn;\n    dyn_MEM_free_fn free_fn;\n} dynamic_MEM_fns;\n/*\n * FIXME: Perhaps the memory and locking code (crypto.h) should declare and\n * use these types so we (and any other dependent code) can simplify a bit??\n */\n/* The top-level structure */\ntypedef struct st_dynamic_fns {\n    void *static_state;\n    dynamic_MEM_fns mem_fns;\n} dynamic_fns;\n\n/*\n * The version checking function should be of this prototype. NB: The\n * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading\n * code. If this function returns zero, it indicates a (potential) version\n * incompatibility and the loaded library doesn't believe it can proceed.\n * Otherwise, the returned value is the (latest) version supported by the\n * loading library. The loader may still decide that the loaded code's\n * version is unsatisfactory and could veto the load. The function is\n * expected to be implemented with the symbol name \"v_check\", and a default\n * implementation can be fully instantiated with\n * IMPLEMENT_DYNAMIC_CHECK_FN().\n */\ntypedef unsigned long (*dynamic_v_check_fn) (unsigned long ossl_version);\n# define IMPLEMENT_DYNAMIC_CHECK_FN() \\\n        OPENSSL_EXPORT unsigned long v_check(unsigned long v); \\\n        OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \\\n                if (v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \\\n                return 0; }\n\n/*\n * This function is passed the ENGINE structure to initialise with its own\n * function and command settings. It should not adjust the structural or\n * functional reference counts. If this function returns zero, (a) the load\n * will be aborted, (b) the previous ENGINE state will be memcpy'd back onto\n * the structure, and (c) the shared library will be unloaded. So\n * implementations should do their own internal cleanup in failure\n * circumstances otherwise they could leak. The 'id' parameter, if non-NULL,\n * represents the ENGINE id that the loader is looking for. If this is NULL,\n * the shared library can choose to return failure or to initialise a\n * 'default' ENGINE. If non-NULL, the shared library must initialise only an\n * ENGINE matching the passed 'id'. The function is expected to be\n * implemented with the symbol name \"bind_engine\". A standard implementation\n * can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where the parameter\n * 'fn' is a callback function that populates the ENGINE structure and\n * returns an int value (zero for failure). 'fn' should have prototype;\n * [static] int fn(ENGINE *e, const char *id);\n */\ntypedef int (*dynamic_bind_engine) (ENGINE *e, const char *id,\n                                    const dynamic_fns *fns);\n# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \\\n        OPENSSL_EXPORT \\\n        int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \\\n        OPENSSL_EXPORT \\\n        int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \\\n            if (ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \\\n            CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \\\n                                     fns->mem_fns.realloc_fn, \\\n                                     fns->mem_fns.free_fn); \\\n            OPENSSL_init_crypto(OPENSSL_INIT_NO_ATEXIT, NULL); \\\n        skip_cbs: \\\n            if (!fn(e, id)) return 0; \\\n            return 1; }\n\n/*\n * If the loading application (or library) and the loaded ENGINE library\n * share the same static data (eg. they're both dynamically linked to the\n * same libcrypto.so) we need a way to avoid trying to set system callbacks -\n * this would fail, and for the same reason that it's unnecessary to try. If\n * the loaded ENGINE has (or gets from through the loader) its own copy of\n * the libcrypto static data, we will need to set the callbacks. The easiest\n * way to detect this is to have a function that returns a pointer to some\n * static data and let the loading application and loaded ENGINE compare\n * their respective values.\n */\nvoid *ENGINE_get_static_state(void);\n\n# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)\nDEPRECATEDIN_1_1_0(void ENGINE_setup_bsd_cryptodev(void))\n# endif\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/engineerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ENGINEERR_H\n# define HEADER_ENGINEERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_ENGINE\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_ENGINE_strings(void);\n\n/*\n * ENGINE function codes.\n */\n#  define ENGINE_F_DIGEST_UPDATE                           198\n#  define ENGINE_F_DYNAMIC_CTRL                            180\n#  define ENGINE_F_DYNAMIC_GET_DATA_CTX                    181\n#  define ENGINE_F_DYNAMIC_LOAD                            182\n#  define ENGINE_F_DYNAMIC_SET_DATA_CTX                    183\n#  define ENGINE_F_ENGINE_ADD                              105\n#  define ENGINE_F_ENGINE_BY_ID                            106\n#  define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE                170\n#  define ENGINE_F_ENGINE_CTRL                             142\n#  define ENGINE_F_ENGINE_CTRL_CMD                         178\n#  define ENGINE_F_ENGINE_CTRL_CMD_STRING                  171\n#  define ENGINE_F_ENGINE_FINISH                           107\n#  define ENGINE_F_ENGINE_GET_CIPHER                       185\n#  define ENGINE_F_ENGINE_GET_DIGEST                       186\n#  define ENGINE_F_ENGINE_GET_FIRST                        195\n#  define ENGINE_F_ENGINE_GET_LAST                         196\n#  define ENGINE_F_ENGINE_GET_NEXT                         115\n#  define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH               193\n#  define ENGINE_F_ENGINE_GET_PKEY_METH                    192\n#  define ENGINE_F_ENGINE_GET_PREV                         116\n#  define ENGINE_F_ENGINE_INIT                             119\n#  define ENGINE_F_ENGINE_LIST_ADD                         120\n#  define ENGINE_F_ENGINE_LIST_REMOVE                      121\n#  define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY                 150\n#  define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY                  151\n#  define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT             194\n#  define ENGINE_F_ENGINE_NEW                              122\n#  define ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR               197\n#  define ENGINE_F_ENGINE_REMOVE                           123\n#  define ENGINE_F_ENGINE_SET_DEFAULT_STRING               189\n#  define ENGINE_F_ENGINE_SET_ID                           129\n#  define ENGINE_F_ENGINE_SET_NAME                         130\n#  define ENGINE_F_ENGINE_TABLE_REGISTER                   184\n#  define ENGINE_F_ENGINE_UNLOCKED_FINISH                  191\n#  define ENGINE_F_ENGINE_UP_REF                           190\n#  define ENGINE_F_INT_CLEANUP_ITEM                        199\n#  define ENGINE_F_INT_CTRL_HELPER                         172\n#  define ENGINE_F_INT_ENGINE_CONFIGURE                    188\n#  define ENGINE_F_INT_ENGINE_MODULE_INIT                  187\n#  define ENGINE_F_OSSL_HMAC_INIT                          200\n\n/*\n * ENGINE reason codes.\n */\n#  define ENGINE_R_ALREADY_LOADED                          100\n#  define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER                133\n#  define ENGINE_R_CMD_NOT_EXECUTABLE                      134\n#  define ENGINE_R_COMMAND_TAKES_INPUT                     135\n#  define ENGINE_R_COMMAND_TAKES_NO_INPUT                  136\n#  define ENGINE_R_CONFLICTING_ENGINE_ID                   103\n#  define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED            119\n#  define ENGINE_R_DSO_FAILURE                             104\n#  define ENGINE_R_DSO_NOT_FOUND                           132\n#  define ENGINE_R_ENGINES_SECTION_ERROR                   148\n#  define ENGINE_R_ENGINE_CONFIGURATION_ERROR              102\n#  define ENGINE_R_ENGINE_IS_NOT_IN_LIST                   105\n#  define ENGINE_R_ENGINE_SECTION_ERROR                    149\n#  define ENGINE_R_FAILED_LOADING_PRIVATE_KEY              128\n#  define ENGINE_R_FAILED_LOADING_PUBLIC_KEY               129\n#  define ENGINE_R_FINISH_FAILED                           106\n#  define ENGINE_R_ID_OR_NAME_MISSING                      108\n#  define ENGINE_R_INIT_FAILED                             109\n#  define ENGINE_R_INTERNAL_LIST_ERROR                     110\n#  define ENGINE_R_INVALID_ARGUMENT                        143\n#  define ENGINE_R_INVALID_CMD_NAME                        137\n#  define ENGINE_R_INVALID_CMD_NUMBER                      138\n#  define ENGINE_R_INVALID_INIT_VALUE                      151\n#  define ENGINE_R_INVALID_STRING                          150\n#  define ENGINE_R_NOT_INITIALISED                         117\n#  define ENGINE_R_NOT_LOADED                              112\n#  define ENGINE_R_NO_CONTROL_FUNCTION                     120\n#  define ENGINE_R_NO_INDEX                                144\n#  define ENGINE_R_NO_LOAD_FUNCTION                        125\n#  define ENGINE_R_NO_REFERENCE                            130\n#  define ENGINE_R_NO_SUCH_ENGINE                          116\n#  define ENGINE_R_UNIMPLEMENTED_CIPHER                    146\n#  define ENGINE_R_UNIMPLEMENTED_DIGEST                    147\n#  define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD         101\n#  define ENGINE_R_VERSION_INCOMPATIBILITY                 145\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/err.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ERR_H\n# define HEADER_ERR_H\n\n# include <openssl/e_os2.h>\n\n# ifndef OPENSSL_NO_STDIO\n#  include <stdio.h>\n#  include <stdlib.h>\n# endif\n\n# include <openssl/ossl_typ.h>\n# include <openssl/bio.h>\n# include <openssl/lhash.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# ifndef OPENSSL_NO_ERR\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,d,e)\n# else\n#  define ERR_PUT_error(a,b,c,d,e)        ERR_put_error(a,b,c,NULL,0)\n# endif\n\n# include <errno.h>\n\n# define ERR_TXT_MALLOCED        0x01\n# define ERR_TXT_STRING          0x02\n\n# define ERR_FLAG_MARK           0x01\n# define ERR_FLAG_CLEAR          0x02\n\n# define ERR_NUM_ERRORS  16\ntypedef struct err_state_st {\n    int err_flags[ERR_NUM_ERRORS];\n    unsigned long err_buffer[ERR_NUM_ERRORS];\n    char *err_data[ERR_NUM_ERRORS];\n    int err_data_flags[ERR_NUM_ERRORS];\n    const char *err_file[ERR_NUM_ERRORS];\n    int err_line[ERR_NUM_ERRORS];\n    int top, bottom;\n} ERR_STATE;\n\n/* library */\n# define ERR_LIB_NONE            1\n# define ERR_LIB_SYS             2\n# define ERR_LIB_BN              3\n# define ERR_LIB_RSA             4\n# define ERR_LIB_DH              5\n# define ERR_LIB_EVP             6\n# define ERR_LIB_BUF             7\n# define ERR_LIB_OBJ             8\n# define ERR_LIB_PEM             9\n# define ERR_LIB_DSA             10\n# define ERR_LIB_X509            11\n/* #define ERR_LIB_METH         12 */\n# define ERR_LIB_ASN1            13\n# define ERR_LIB_CONF            14\n# define ERR_LIB_CRYPTO          15\n# define ERR_LIB_EC              16\n# define ERR_LIB_SSL             20\n/* #define ERR_LIB_SSL23        21 */\n/* #define ERR_LIB_SSL2         22 */\n/* #define ERR_LIB_SSL3         23 */\n/* #define ERR_LIB_RSAREF       30 */\n/* #define ERR_LIB_PROXY        31 */\n# define ERR_LIB_BIO             32\n# define ERR_LIB_PKCS7           33\n# define ERR_LIB_X509V3          34\n# define ERR_LIB_PKCS12          35\n# define ERR_LIB_RAND            36\n# define ERR_LIB_DSO             37\n# define ERR_LIB_ENGINE          38\n# define ERR_LIB_OCSP            39\n# define ERR_LIB_UI              40\n# define ERR_LIB_COMP            41\n# define ERR_LIB_ECDSA           42\n# define ERR_LIB_ECDH            43\n# define ERR_LIB_OSSL_STORE      44\n# define ERR_LIB_FIPS            45\n# define ERR_LIB_CMS             46\n# define ERR_LIB_TS              47\n# define ERR_LIB_HMAC            48\n/* # define ERR_LIB_JPAKE       49 */\n# define ERR_LIB_CT              50\n# define ERR_LIB_ASYNC           51\n# define ERR_LIB_KDF             52\n# define ERR_LIB_SM2             53\n\n# define ERR_LIB_USER            128\n\n# define SYSerr(f,r)  ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define BNerr(f,r)   ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define RSAerr(f,r)  ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define DHerr(f,r)   ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define EVPerr(f,r)  ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define BUFerr(f,r)  ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define OBJerr(f,r)  ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define PEMerr(f,r)  ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define DSAerr(f,r)  ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ECerr(f,r)   ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define SSLerr(f,r)  ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define BIOerr(f,r)  ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ECDSAerr(f,r)  ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ECDHerr(f,r)  ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define OSSL_STOREerr(f,r) ERR_PUT_error(ERR_LIB_OSSL_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define CTerr(f,r) ERR_PUT_error(ERR_LIB_CT,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define ASYNCerr(f,r) ERR_PUT_error(ERR_LIB_ASYNC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define KDFerr(f,r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n# define SM2err(f,r) ERR_PUT_error(ERR_LIB_SM2,(f),(r),OPENSSL_FILE,OPENSSL_LINE)\n\n# define ERR_PACK(l,f,r) ( \\\n        (((unsigned int)(l) & 0x0FF) << 24L) | \\\n        (((unsigned int)(f) & 0xFFF) << 12L) | \\\n        (((unsigned int)(r) & 0xFFF)       ) )\n# define ERR_GET_LIB(l)          (int)(((l) >> 24L) & 0x0FFL)\n# define ERR_GET_FUNC(l)         (int)(((l) >> 12L) & 0xFFFL)\n# define ERR_GET_REASON(l)       (int)( (l)         & 0xFFFL)\n# define ERR_FATAL_ERROR(l)      (int)( (l)         & ERR_R_FATAL)\n\n/* OS functions */\n# define SYS_F_FOPEN             1\n# define SYS_F_CONNECT           2\n# define SYS_F_GETSERVBYNAME     3\n# define SYS_F_SOCKET            4\n# define SYS_F_IOCTLSOCKET       5\n# define SYS_F_BIND              6\n# define SYS_F_LISTEN            7\n# define SYS_F_ACCEPT            8\n# define SYS_F_WSASTARTUP        9/* Winsock stuff */\n# define SYS_F_OPENDIR           10\n# define SYS_F_FREAD             11\n# define SYS_F_GETADDRINFO       12\n# define SYS_F_GETNAMEINFO       13\n# define SYS_F_SETSOCKOPT        14\n# define SYS_F_GETSOCKOPT        15\n# define SYS_F_GETSOCKNAME       16\n# define SYS_F_GETHOSTBYNAME     17\n# define SYS_F_FFLUSH            18\n# define SYS_F_OPEN              19\n# define SYS_F_CLOSE             20\n# define SYS_F_IOCTL             21\n# define SYS_F_STAT              22\n# define SYS_F_FCNTL             23\n# define SYS_F_FSTAT             24\n\n/* reasons */\n# define ERR_R_SYS_LIB   ERR_LIB_SYS/* 2 */\n# define ERR_R_BN_LIB    ERR_LIB_BN/* 3 */\n# define ERR_R_RSA_LIB   ERR_LIB_RSA/* 4 */\n# define ERR_R_DH_LIB    ERR_LIB_DH/* 5 */\n# define ERR_R_EVP_LIB   ERR_LIB_EVP/* 6 */\n# define ERR_R_BUF_LIB   ERR_LIB_BUF/* 7 */\n# define ERR_R_OBJ_LIB   ERR_LIB_OBJ/* 8 */\n# define ERR_R_PEM_LIB   ERR_LIB_PEM/* 9 */\n# define ERR_R_DSA_LIB   ERR_LIB_DSA/* 10 */\n# define ERR_R_X509_LIB  ERR_LIB_X509/* 11 */\n# define ERR_R_ASN1_LIB  ERR_LIB_ASN1/* 13 */\n# define ERR_R_EC_LIB    ERR_LIB_EC/* 16 */\n# define ERR_R_BIO_LIB   ERR_LIB_BIO/* 32 */\n# define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */\n# define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */\n# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */\n# define ERR_R_UI_LIB    ERR_LIB_UI/* 40 */\n# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */\n# define ERR_R_OSSL_STORE_LIB ERR_LIB_OSSL_STORE/* 44 */\n\n# define ERR_R_NESTED_ASN1_ERROR                 58\n# define ERR_R_MISSING_ASN1_EOS                  63\n\n/* fatal error */\n# define ERR_R_FATAL                             64\n# define ERR_R_MALLOC_FAILURE                    (1|ERR_R_FATAL)\n# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED       (2|ERR_R_FATAL)\n# define ERR_R_PASSED_NULL_PARAMETER             (3|ERR_R_FATAL)\n# define ERR_R_INTERNAL_ERROR                    (4|ERR_R_FATAL)\n# define ERR_R_DISABLED                          (5|ERR_R_FATAL)\n# define ERR_R_INIT_FAIL                         (6|ERR_R_FATAL)\n# define ERR_R_PASSED_INVALID_ARGUMENT           (7)\n# define ERR_R_OPERATION_FAIL                    (8|ERR_R_FATAL)\n\n/*\n * 99 is the maximum possible ERR_R_... code, higher values are reserved for\n * the individual libraries\n */\n\ntypedef struct ERR_string_data_st {\n    unsigned long error;\n    const char *string;\n} ERR_STRING_DATA;\n\nDEFINE_LHASH_OF(ERR_STRING_DATA);\n\nvoid ERR_put_error(int lib, int func, int reason, const char *file, int line);\nvoid ERR_set_error_data(char *data, int flags);\n\nunsigned long ERR_get_error(void);\nunsigned long ERR_get_error_line(const char **file, int *line);\nunsigned long ERR_get_error_line_data(const char **file, int *line,\n                                      const char **data, int *flags);\nunsigned long ERR_peek_error(void);\nunsigned long ERR_peek_error_line(const char **file, int *line);\nunsigned long ERR_peek_error_line_data(const char **file, int *line,\n                                       const char **data, int *flags);\nunsigned long ERR_peek_last_error(void);\nunsigned long ERR_peek_last_error_line(const char **file, int *line);\nunsigned long ERR_peek_last_error_line_data(const char **file, int *line,\n                                            const char **data, int *flags);\nvoid ERR_clear_error(void);\nchar *ERR_error_string(unsigned long e, char *buf);\nvoid ERR_error_string_n(unsigned long e, char *buf, size_t len);\nconst char *ERR_lib_error_string(unsigned long e);\nconst char *ERR_func_error_string(unsigned long e);\nconst char *ERR_reason_error_string(unsigned long e);\nvoid ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),\n                         void *u);\n# ifndef OPENSSL_NO_STDIO\nvoid ERR_print_errors_fp(FILE *fp);\n# endif\nvoid ERR_print_errors(BIO *bp);\nvoid ERR_add_error_data(int num, ...);\nvoid ERR_add_error_vdata(int num, va_list args);\nint ERR_load_strings(int lib, ERR_STRING_DATA *str);\nint ERR_load_strings_const(const ERR_STRING_DATA *str);\nint ERR_unload_strings(int lib, ERR_STRING_DATA *str);\nint ERR_load_ERR_strings(void);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define ERR_load_crypto_strings() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)\n# define ERR_free_strings() while(0) continue\n#endif\n\nDEPRECATEDIN_1_1_0(void ERR_remove_thread_state(void *))\nDEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid))\nERR_STATE *ERR_get_state(void);\n\nint ERR_get_next_error_library(void);\n\nint ERR_set_mark(void);\nint ERR_pop_to_mark(void);\nint ERR_clear_last_mark(void);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/evp.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_ENVELOPE_H\n# define HEADER_ENVELOPE_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/symhacks.h>\n# include <openssl/bio.h>\n# include <openssl/evperr.h>\n\n# define EVP_MAX_MD_SIZE                 64/* longest known is SHA512 */\n# define EVP_MAX_KEY_LENGTH              64\n# define EVP_MAX_IV_LENGTH               16\n# define EVP_MAX_BLOCK_LENGTH            32\n\n# define PKCS5_SALT_LEN                  8\n/* Default PKCS#5 iteration count */\n# define PKCS5_DEFAULT_ITER              2048\n\n# include <openssl/objects.h>\n\n# define EVP_PK_RSA      0x0001\n# define EVP_PK_DSA      0x0002\n# define EVP_PK_DH       0x0004\n# define EVP_PK_EC       0x0008\n# define EVP_PKT_SIGN    0x0010\n# define EVP_PKT_ENC     0x0020\n# define EVP_PKT_EXCH    0x0040\n# define EVP_PKS_RSA     0x0100\n# define EVP_PKS_DSA     0x0200\n# define EVP_PKS_EC      0x0400\n\n# define EVP_PKEY_NONE   NID_undef\n# define EVP_PKEY_RSA    NID_rsaEncryption\n# define EVP_PKEY_RSA2   NID_rsa\n# define EVP_PKEY_RSA_PSS NID_rsassaPss\n# define EVP_PKEY_DSA    NID_dsa\n# define EVP_PKEY_DSA1   NID_dsa_2\n# define EVP_PKEY_DSA2   NID_dsaWithSHA\n# define EVP_PKEY_DSA3   NID_dsaWithSHA1\n# define EVP_PKEY_DSA4   NID_dsaWithSHA1_2\n# define EVP_PKEY_DH     NID_dhKeyAgreement\n# define EVP_PKEY_DHX    NID_dhpublicnumber\n# define EVP_PKEY_EC     NID_X9_62_id_ecPublicKey\n# define EVP_PKEY_SM2    NID_sm2\n# define EVP_PKEY_HMAC   NID_hmac\n# define EVP_PKEY_CMAC   NID_cmac\n# define EVP_PKEY_SCRYPT NID_id_scrypt\n# define EVP_PKEY_TLS1_PRF NID_tls1_prf\n# define EVP_PKEY_HKDF   NID_hkdf\n# define EVP_PKEY_POLY1305 NID_poly1305\n# define EVP_PKEY_SIPHASH NID_siphash\n# define EVP_PKEY_X25519 NID_X25519\n# define EVP_PKEY_ED25519 NID_ED25519\n# define EVP_PKEY_X448 NID_X448\n# define EVP_PKEY_ED448 NID_ED448\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define EVP_PKEY_MO_SIGN        0x0001\n# define EVP_PKEY_MO_VERIFY      0x0002\n# define EVP_PKEY_MO_ENCRYPT     0x0004\n# define EVP_PKEY_MO_DECRYPT     0x0008\n\n# ifndef EVP_MD\nEVP_MD *EVP_MD_meth_new(int md_type, int pkey_type);\nEVP_MD *EVP_MD_meth_dup(const EVP_MD *md);\nvoid EVP_MD_meth_free(EVP_MD *md);\n\nint EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize);\nint EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize);\nint EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize);\nint EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags);\nint EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx));\nint EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx,\n                                                     const void *data,\n                                                     size_t count));\nint EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx,\n                                                   unsigned char *md));\nint EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to,\n                                                 const EVP_MD_CTX *from));\nint EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx));\nint EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd,\n                                                 int p1, void *p2));\n\nint EVP_MD_meth_get_input_blocksize(const EVP_MD *md);\nint EVP_MD_meth_get_result_size(const EVP_MD *md);\nint EVP_MD_meth_get_app_datasize(const EVP_MD *md);\nunsigned long EVP_MD_meth_get_flags(const EVP_MD *md);\nint (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx);\nint (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx,\n                                                const void *data,\n                                                size_t count);\nint (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx,\n                                               unsigned char *md);\nint (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to,\n                                              const EVP_MD_CTX *from);\nint (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx);\nint (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd,\n                                              int p1, void *p2);\n\n/* digest can only handle a single block */\n#  define EVP_MD_FLAG_ONESHOT     0x0001\n\n/* digest is extensible-output function, XOF */\n#  define EVP_MD_FLAG_XOF         0x0002\n\n/* DigestAlgorithmIdentifier flags... */\n\n#  define EVP_MD_FLAG_DIGALGID_MASK               0x0018\n\n/* NULL or absent parameter accepted. Use NULL */\n\n#  define EVP_MD_FLAG_DIGALGID_NULL               0x0000\n\n/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */\n\n#  define EVP_MD_FLAG_DIGALGID_ABSENT             0x0008\n\n/* Custom handling via ctrl */\n\n#  define EVP_MD_FLAG_DIGALGID_CUSTOM             0x0018\n\n/* Note if suitable for use in FIPS mode */\n#  define EVP_MD_FLAG_FIPS        0x0400\n\n/* Digest ctrls */\n\n#  define EVP_MD_CTRL_DIGALGID                    0x1\n#  define EVP_MD_CTRL_MICALG                      0x2\n#  define EVP_MD_CTRL_XOF_LEN                     0x3\n\n/* Minimum Algorithm specific ctrl value */\n\n#  define EVP_MD_CTRL_ALG_CTRL                    0x1000\n\n# endif                         /* !EVP_MD */\n\n/* values for EVP_MD_CTX flags */\n\n# define EVP_MD_CTX_FLAG_ONESHOT         0x0001/* digest update will be\n                                                * called once only */\n# define EVP_MD_CTX_FLAG_CLEANED         0x0002/* context has already been\n                                                * cleaned */\n# define EVP_MD_CTX_FLAG_REUSE           0x0004/* Don't free up ctx->md_data\n                                                * in EVP_MD_CTX_reset */\n/*\n * FIPS and pad options are ignored in 1.0.0, definitions are here so we\n * don't accidentally reuse the values for other purposes.\n */\n\n# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW  0x0008/* Allow use of non FIPS\n                                                * digest in FIPS mode */\n\n/*\n * The following PAD options are also currently ignored in 1.0.0, digest\n * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()\n * instead.\n */\n# define EVP_MD_CTX_FLAG_PAD_MASK        0xF0/* RSA mode to use */\n# define EVP_MD_CTX_FLAG_PAD_PKCS1       0x00/* PKCS#1 v1.5 mode */\n# define EVP_MD_CTX_FLAG_PAD_X931        0x10/* X9.31 mode */\n# define EVP_MD_CTX_FLAG_PAD_PSS         0x20/* PSS mode */\n\n# define EVP_MD_CTX_FLAG_NO_INIT         0x0100/* Don't initialize md_data */\n/*\n * Some functions such as EVP_DigestSign only finalise copies of internal\n * contexts so additional data can be included after the finalisation call.\n * This is inefficient if this functionality is not required: it is disabled\n * if the following flag is set.\n */\n# define EVP_MD_CTX_FLAG_FINALISE        0x0200\n/* NOTE: 0x0400 is reserved for internal usage */\n\nEVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len);\nEVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher);\nvoid EVP_CIPHER_meth_free(EVP_CIPHER *cipher);\n\nint EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len);\nint EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags);\nint EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size);\nint EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher,\n                             int (*init) (EVP_CIPHER_CTX *ctx,\n                                          const unsigned char *key,\n                                          const unsigned char *iv,\n                                          int enc));\nint EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher,\n                                  int (*do_cipher) (EVP_CIPHER_CTX *ctx,\n                                                    unsigned char *out,\n                                                    const unsigned char *in,\n                                                    size_t inl));\nint EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher,\n                                int (*cleanup) (EVP_CIPHER_CTX *));\nint EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher,\n                                        int (*set_asn1_parameters) (EVP_CIPHER_CTX *,\n                                                                    ASN1_TYPE *));\nint EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher,\n                                        int (*get_asn1_parameters) (EVP_CIPHER_CTX *,\n                                                                    ASN1_TYPE *));\nint EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher,\n                             int (*ctrl) (EVP_CIPHER_CTX *, int type,\n                                          int arg, void *ptr));\n\nint (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,\n                                                          const unsigned char *key,\n                                                          const unsigned char *iv,\n                                                          int enc);\nint (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,\n                                                               unsigned char *out,\n                                                               const unsigned char *in,\n                                                               size_t inl);\nint (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *);\nint (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,\n                                                                     ASN1_TYPE *);\nint (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,\n                                                               ASN1_TYPE *);\nint (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,\n                                                          int type, int arg,\n                                                          void *ptr);\n\n/* Values for cipher flags */\n\n/* Modes for ciphers */\n\n# define         EVP_CIPH_STREAM_CIPHER          0x0\n# define         EVP_CIPH_ECB_MODE               0x1\n# define         EVP_CIPH_CBC_MODE               0x2\n# define         EVP_CIPH_CFB_MODE               0x3\n# define         EVP_CIPH_OFB_MODE               0x4\n# define         EVP_CIPH_CTR_MODE               0x5\n# define         EVP_CIPH_GCM_MODE               0x6\n# define         EVP_CIPH_CCM_MODE               0x7\n# define         EVP_CIPH_XTS_MODE               0x10001\n# define         EVP_CIPH_WRAP_MODE              0x10002\n# define         EVP_CIPH_OCB_MODE               0x10003\n# define         EVP_CIPH_MODE                   0xF0007\n/* Set if variable length cipher */\n# define         EVP_CIPH_VARIABLE_LENGTH        0x8\n/* Set if the iv handling should be done by the cipher itself */\n# define         EVP_CIPH_CUSTOM_IV              0x10\n/* Set if the cipher's init() function should be called if key is NULL */\n# define         EVP_CIPH_ALWAYS_CALL_INIT       0x20\n/* Call ctrl() to init cipher parameters */\n# define         EVP_CIPH_CTRL_INIT              0x40\n/* Don't use standard key length function */\n# define         EVP_CIPH_CUSTOM_KEY_LENGTH      0x80\n/* Don't use standard block padding */\n# define         EVP_CIPH_NO_PADDING             0x100\n/* cipher handles random key generation */\n# define         EVP_CIPH_RAND_KEY               0x200\n/* cipher has its own additional copying logic */\n# define         EVP_CIPH_CUSTOM_COPY            0x400\n/* Don't use standard iv length function */\n# define         EVP_CIPH_CUSTOM_IV_LENGTH       0x800\n/* Allow use default ASN1 get/set iv */\n# define         EVP_CIPH_FLAG_DEFAULT_ASN1      0x1000\n/* Buffer length in bits not bytes: CFB1 mode only */\n# define         EVP_CIPH_FLAG_LENGTH_BITS       0x2000\n/* Note if suitable for use in FIPS mode */\n# define         EVP_CIPH_FLAG_FIPS              0x4000\n/* Allow non FIPS cipher in FIPS mode */\n# define         EVP_CIPH_FLAG_NON_FIPS_ALLOW    0x8000\n/*\n * Cipher handles any and all padding logic as well as finalisation.\n */\n# define         EVP_CIPH_FLAG_CUSTOM_CIPHER     0x100000\n# define         EVP_CIPH_FLAG_AEAD_CIPHER       0x200000\n# define         EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000\n/* Cipher can handle pipeline operations */\n# define         EVP_CIPH_FLAG_PIPELINE          0X800000\n\n/*\n * Cipher context flag to indicate we can handle wrap mode: if allowed in\n * older applications it could overflow buffers.\n */\n\n# define         EVP_CIPHER_CTX_FLAG_WRAP_ALLOW  0x1\n\n/* ctrl() values */\n\n# define         EVP_CTRL_INIT                   0x0\n# define         EVP_CTRL_SET_KEY_LENGTH         0x1\n# define         EVP_CTRL_GET_RC2_KEY_BITS       0x2\n# define         EVP_CTRL_SET_RC2_KEY_BITS       0x3\n# define         EVP_CTRL_GET_RC5_ROUNDS         0x4\n# define         EVP_CTRL_SET_RC5_ROUNDS         0x5\n# define         EVP_CTRL_RAND_KEY               0x6\n# define         EVP_CTRL_PBE_PRF_NID            0x7\n# define         EVP_CTRL_COPY                   0x8\n# define         EVP_CTRL_AEAD_SET_IVLEN         0x9\n# define         EVP_CTRL_AEAD_GET_TAG           0x10\n# define         EVP_CTRL_AEAD_SET_TAG           0x11\n# define         EVP_CTRL_AEAD_SET_IV_FIXED      0x12\n# define         EVP_CTRL_GCM_SET_IVLEN          EVP_CTRL_AEAD_SET_IVLEN\n# define         EVP_CTRL_GCM_GET_TAG            EVP_CTRL_AEAD_GET_TAG\n# define         EVP_CTRL_GCM_SET_TAG            EVP_CTRL_AEAD_SET_TAG\n# define         EVP_CTRL_GCM_SET_IV_FIXED       EVP_CTRL_AEAD_SET_IV_FIXED\n# define         EVP_CTRL_GCM_IV_GEN             0x13\n# define         EVP_CTRL_CCM_SET_IVLEN          EVP_CTRL_AEAD_SET_IVLEN\n# define         EVP_CTRL_CCM_GET_TAG            EVP_CTRL_AEAD_GET_TAG\n# define         EVP_CTRL_CCM_SET_TAG            EVP_CTRL_AEAD_SET_TAG\n# define         EVP_CTRL_CCM_SET_IV_FIXED       EVP_CTRL_AEAD_SET_IV_FIXED\n# define         EVP_CTRL_CCM_SET_L              0x14\n# define         EVP_CTRL_CCM_SET_MSGLEN         0x15\n/*\n * AEAD cipher deduces payload length and returns number of bytes required to\n * store MAC and eventual padding. Subsequent call to EVP_Cipher even\n * appends/verifies MAC.\n */\n# define         EVP_CTRL_AEAD_TLS1_AAD          0x16\n/* Used by composite AEAD ciphers, no-op in GCM, CCM... */\n# define         EVP_CTRL_AEAD_SET_MAC_KEY       0x17\n/* Set the GCM invocation field, decrypt only */\n# define         EVP_CTRL_GCM_SET_IV_INV         0x18\n\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_AAD  0x19\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT      0x1a\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT      0x1b\n# define         EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE  0x1c\n\n# define         EVP_CTRL_SSL3_MASTER_SECRET             0x1d\n\n/* EVP_CTRL_SET_SBOX takes the char * specifying S-boxes */\n# define         EVP_CTRL_SET_SBOX                       0x1e\n/*\n * EVP_CTRL_SBOX_USED takes a 'size_t' and 'char *', pointing at a\n * pre-allocated buffer with specified size\n */\n# define         EVP_CTRL_SBOX_USED                      0x1f\n/* EVP_CTRL_KEY_MESH takes 'size_t' number of bytes to mesh the key after,\n * 0 switches meshing off\n */\n# define         EVP_CTRL_KEY_MESH                       0x20\n/* EVP_CTRL_BLOCK_PADDING_MODE takes the padding mode */\n# define         EVP_CTRL_BLOCK_PADDING_MODE             0x21\n\n/* Set the output buffers to use for a pipelined operation */\n# define         EVP_CTRL_SET_PIPELINE_OUTPUT_BUFS       0x22\n/* Set the input buffers to use for a pipelined operation */\n# define         EVP_CTRL_SET_PIPELINE_INPUT_BUFS        0x23\n/* Set the input buffer lengths to use for a pipelined operation */\n# define         EVP_CTRL_SET_PIPELINE_INPUT_LENS        0x24\n\n# define         EVP_CTRL_GET_IVLEN                      0x25\n\n/* Padding modes */\n#define EVP_PADDING_PKCS7       1\n#define EVP_PADDING_ISO7816_4   2\n#define EVP_PADDING_ANSI923     3\n#define EVP_PADDING_ISO10126    4\n#define EVP_PADDING_ZERO        5\n\n/* RFC 5246 defines additional data to be 13 bytes in length */\n# define         EVP_AEAD_TLS1_AAD_LEN           13\n\ntypedef struct {\n    unsigned char *out;\n    const unsigned char *inp;\n    size_t len;\n    unsigned int interleave;\n} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;\n\n/* GCM TLS constants */\n/* Length of fixed part of IV derived from PRF */\n# define EVP_GCM_TLS_FIXED_IV_LEN                        4\n/* Length of explicit part of IV part of TLS records */\n# define EVP_GCM_TLS_EXPLICIT_IV_LEN                     8\n/* Length of tag for TLS */\n# define EVP_GCM_TLS_TAG_LEN                             16\n\n/* CCM TLS constants */\n/* Length of fixed part of IV derived from PRF */\n# define EVP_CCM_TLS_FIXED_IV_LEN                        4\n/* Length of explicit part of IV part of TLS records */\n# define EVP_CCM_TLS_EXPLICIT_IV_LEN                     8\n/* Total length of CCM IV length for TLS */\n# define EVP_CCM_TLS_IV_LEN                              12\n/* Length of tag for TLS */\n# define EVP_CCM_TLS_TAG_LEN                             16\n/* Length of CCM8 tag for TLS */\n# define EVP_CCM8_TLS_TAG_LEN                            8\n\n/* Length of tag for TLS */\n# define EVP_CHACHAPOLY_TLS_TAG_LEN                      16\n\ntypedef struct evp_cipher_info_st {\n    const EVP_CIPHER *cipher;\n    unsigned char iv[EVP_MAX_IV_LENGTH];\n} EVP_CIPHER_INFO;\n\n\n/* Password based encryption function */\ntypedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,\n                              int passlen, ASN1_TYPE *param,\n                              const EVP_CIPHER *cipher, const EVP_MD *md,\n                              int en_de);\n\n# ifndef OPENSSL_NO_RSA\n#  define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\\\n                                        (char *)(rsa))\n# endif\n\n# ifndef OPENSSL_NO_DSA\n#  define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\\\n                                        (char *)(dsa))\n# endif\n\n# ifndef OPENSSL_NO_DH\n#  define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\\\n                                        (char *)(dh))\n# endif\n\n# ifndef OPENSSL_NO_EC\n#  define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\\\n                                        (char *)(eckey))\n# endif\n# ifndef OPENSSL_NO_SIPHASH\n#  define EVP_PKEY_assign_SIPHASH(pkey,shkey) EVP_PKEY_assign((pkey),EVP_PKEY_SIPHASH,\\\n                                        (char *)(shkey))\n# endif\n\n# ifndef OPENSSL_NO_POLY1305\n#  define EVP_PKEY_assign_POLY1305(pkey,polykey) EVP_PKEY_assign((pkey),EVP_PKEY_POLY1305,\\\n                                        (char *)(polykey))\n# endif\n\n/* Add some extra combinations */\n# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))\n# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))\n# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))\n# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))\n\nint EVP_MD_type(const EVP_MD *md);\n# define EVP_MD_nid(e)                   EVP_MD_type(e)\n# define EVP_MD_name(e)                  OBJ_nid2sn(EVP_MD_nid(e))\nint EVP_MD_pkey_type(const EVP_MD *md);\nint EVP_MD_size(const EVP_MD *md);\nint EVP_MD_block_size(const EVP_MD *md);\nunsigned long EVP_MD_flags(const EVP_MD *md);\n\nconst EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);\nint (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx,\n                                             const void *data, size_t count);\nvoid EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx,\n                              int (*update) (EVP_MD_CTX *ctx,\n                                             const void *data, size_t count));\n# define EVP_MD_CTX_size(e)              EVP_MD_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_block_size(e)        EVP_MD_block_size(EVP_MD_CTX_md(e))\n# define EVP_MD_CTX_type(e)              EVP_MD_type(EVP_MD_CTX_md(e))\nEVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx);\nvoid EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx);\nvoid *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx);\n\nint EVP_CIPHER_nid(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_name(e)              OBJ_nid2sn(EVP_CIPHER_nid(e))\nint EVP_CIPHER_block_size(const EVP_CIPHER *cipher);\nint EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher);\nint EVP_CIPHER_key_length(const EVP_CIPHER *cipher);\nint EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);\nunsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);\n# define EVP_CIPHER_mode(e)              (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)\n\nconst EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);\nconst unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx);\nconst unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx);\nunsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx);\nunsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx);\nint EVP_CIPHER_CTX_num(const EVP_CIPHER_CTX *ctx);\nvoid EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num);\nint EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);\nvoid *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);\nvoid EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);\nvoid *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx);\nvoid *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data);\n# define EVP_CIPHER_CTX_type(c)         EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define EVP_CIPHER_CTX_flags(c)       EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(c))\n# endif\n# define EVP_CIPHER_CTX_mode(c)         EVP_CIPHER_mode(EVP_CIPHER_CTX_cipher(c))\n\n# define EVP_ENCODE_LENGTH(l)    ((((l)+2)/3*4)+((l)/48+1)*2+80)\n# define EVP_DECODE_LENGTH(l)    (((l)+3)/4*3+80)\n\n# define EVP_SignInit_ex(a,b,c)          EVP_DigestInit_ex(a,b,c)\n# define EVP_SignInit(a,b)               EVP_DigestInit(a,b)\n# define EVP_SignUpdate(a,b,c)           EVP_DigestUpdate(a,b,c)\n# define EVP_VerifyInit_ex(a,b,c)        EVP_DigestInit_ex(a,b,c)\n# define EVP_VerifyInit(a,b)             EVP_DigestInit(a,b)\n# define EVP_VerifyUpdate(a,b,c)         EVP_DigestUpdate(a,b,c)\n# define EVP_OpenUpdate(a,b,c,d,e)       EVP_DecryptUpdate(a,b,c,d,e)\n# define EVP_SealUpdate(a,b,c,d,e)       EVP_EncryptUpdate(a,b,c,d,e)\n# define EVP_DigestSignUpdate(a,b,c)     EVP_DigestUpdate(a,b,c)\n# define EVP_DigestVerifyUpdate(a,b,c)   EVP_DigestUpdate(a,b,c)\n\n# ifdef CONST_STRICT\nvoid BIO_set_md(BIO *, const EVP_MD *md);\n# else\n#  define BIO_set_md(b,md)          BIO_ctrl(b,BIO_C_SET_MD,0,(char *)(md))\n# endif\n# define BIO_get_md(b,mdp)          BIO_ctrl(b,BIO_C_GET_MD,0,(char *)(mdp))\n# define BIO_get_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_GET_MD_CTX,0, \\\n                                             (char *)(mdcp))\n# define BIO_set_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_SET_MD_CTX,0, \\\n                                             (char *)(mdcp))\n# define BIO_get_cipher_status(b)   BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)\n# define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0, \\\n                                             (char *)(c_pp))\n\n/*__owur*/ int EVP_Cipher(EVP_CIPHER_CTX *c,\n                          unsigned char *out,\n                          const unsigned char *in, unsigned int inl);\n\n# define EVP_add_cipher_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_add_digest_alias(n,alias) \\\n        OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))\n# define EVP_delete_cipher_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);\n# define EVP_delete_digest_alias(alias) \\\n        OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);\n\nint EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);\nEVP_MD_CTX *EVP_MD_CTX_new(void);\nint EVP_MD_CTX_reset(EVP_MD_CTX *ctx);\nvoid EVP_MD_CTX_free(EVP_MD_CTX *ctx);\n# define EVP_MD_CTX_create()     EVP_MD_CTX_new()\n# define EVP_MD_CTX_init(ctx)    EVP_MD_CTX_reset((ctx))\n# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))\n__owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);\nvoid EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);\nvoid EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);\nint EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);\n__owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type,\n                                 ENGINE *impl);\n__owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d,\n                                size_t cnt);\n__owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md,\n                                  unsigned int *s);\n__owur int EVP_Digest(const void *data, size_t count,\n                          unsigned char *md, unsigned int *size,\n                          const EVP_MD *type, ENGINE *impl);\n\n__owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);\n__owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);\n__owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,\n                           unsigned int *s);\n__owur int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md,\n                              size_t len);\n\nint EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);\nint EVP_read_pw_string_min(char *buf, int minlen, int maxlen,\n                           const char *prompt, int verify);\nvoid EVP_set_pw_prompt(const char *prompt);\nchar *EVP_get_pw_prompt(void);\n\n__owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,\n                          const unsigned char *salt,\n                          const unsigned char *data, int datal, int count,\n                          unsigned char *key, unsigned char *iv);\n\nvoid EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);\nvoid EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);\nint EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);\n\n__owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                           const unsigned char *key, const unsigned char *iv);\n/*__owur*/ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,\n                                  const EVP_CIPHER *cipher, ENGINE *impl,\n                                  const unsigned char *key,\n                                  const unsigned char *iv);\n/*__owur*/ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                 int *outl, const unsigned char *in, int inl);\n/*__owur*/ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                   int *outl);\n/*__owur*/ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                int *outl);\n\n__owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                           const unsigned char *key, const unsigned char *iv);\n/*__owur*/ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,\n                                  const EVP_CIPHER *cipher, ENGINE *impl,\n                                  const unsigned char *key,\n                                  const unsigned char *iv);\n/*__owur*/ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                 int *outl, const unsigned char *in, int inl);\n__owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,\n                            int *outl);\n/*__owur*/ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,\n                                   int *outl);\n\n__owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,\n                          const unsigned char *key, const unsigned char *iv,\n                          int enc);\n/*__owur*/ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,\n                                 const EVP_CIPHER *cipher, ENGINE *impl,\n                                 const unsigned char *key,\n                                 const unsigned char *iv, int enc);\n__owur int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                            int *outl, const unsigned char *in, int inl);\n__owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,\n                           int *outl);\n__owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,\n                              int *outl);\n\n__owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,\n                         EVP_PKEY *pkey);\n\n__owur int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret,\n                          size_t *siglen, const unsigned char *tbs,\n                          size_t tbslen);\n\n__owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,\n                           unsigned int siglen, EVP_PKEY *pkey);\n\n__owur int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret,\n                            size_t siglen, const unsigned char *tbs,\n                            size_t tbslen);\n\n/*__owur*/ int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                                  const EVP_MD *type, ENGINE *e,\n                                  EVP_PKEY *pkey);\n__owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,\n                               size_t *siglen);\n\n__owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,\n                                const EVP_MD *type, ENGINE *e,\n                                EVP_PKEY *pkey);\n__owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,\n                                 size_t siglen);\n\n# ifndef OPENSSL_NO_RSA\n__owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                        const unsigned char *ek, int ekl,\n                        const unsigned char *iv, EVP_PKEY *priv);\n__owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n\n__owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,\n                        unsigned char **ek, int *ekl, unsigned char *iv,\n                        EVP_PKEY **pubk, int npubk);\n__owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);\n# endif\n\nEVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void);\nvoid EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx);\nint EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, EVP_ENCODE_CTX *sctx);\nint EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx);\nvoid EVP_EncodeInit(EVP_ENCODE_CTX *ctx);\nint EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nvoid EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);\nint EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);\n\nvoid EVP_DecodeInit(EVP_ENCODE_CTX *ctx);\nint EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,\n                     const unsigned char *in, int inl);\nint EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned\n                    char *out, int *outl);\nint EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define EVP_CIPHER_CTX_init(c)      EVP_CIPHER_CTX_reset(c)\n#  define EVP_CIPHER_CTX_cleanup(c)   EVP_CIPHER_CTX_reset(c)\n# endif\nEVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);\nint EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);\nvoid EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c);\nint EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);\nint EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);\nint EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);\nint EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);\n\nconst BIO_METHOD *BIO_f_md(void);\nconst BIO_METHOD *BIO_f_base64(void);\nconst BIO_METHOD *BIO_f_cipher(void);\nconst BIO_METHOD *BIO_f_reliable(void);\n__owur int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,\n                          const unsigned char *i, int enc);\n\nconst EVP_MD *EVP_md_null(void);\n# ifndef OPENSSL_NO_MD2\nconst EVP_MD *EVP_md2(void);\n# endif\n# ifndef OPENSSL_NO_MD4\nconst EVP_MD *EVP_md4(void);\n# endif\n# ifndef OPENSSL_NO_MD5\nconst EVP_MD *EVP_md5(void);\nconst EVP_MD *EVP_md5_sha1(void);\n# endif\n# ifndef OPENSSL_NO_BLAKE2\nconst EVP_MD *EVP_blake2b512(void);\nconst EVP_MD *EVP_blake2s256(void);\n# endif\nconst EVP_MD *EVP_sha1(void);\nconst EVP_MD *EVP_sha224(void);\nconst EVP_MD *EVP_sha256(void);\nconst EVP_MD *EVP_sha384(void);\nconst EVP_MD *EVP_sha512(void);\nconst EVP_MD *EVP_sha512_224(void);\nconst EVP_MD *EVP_sha512_256(void);\nconst EVP_MD *EVP_sha3_224(void);\nconst EVP_MD *EVP_sha3_256(void);\nconst EVP_MD *EVP_sha3_384(void);\nconst EVP_MD *EVP_sha3_512(void);\nconst EVP_MD *EVP_shake128(void);\nconst EVP_MD *EVP_shake256(void);\n# ifndef OPENSSL_NO_MDC2\nconst EVP_MD *EVP_mdc2(void);\n# endif\n# ifndef OPENSSL_NO_RMD160\nconst EVP_MD *EVP_ripemd160(void);\n# endif\n# ifndef OPENSSL_NO_WHIRLPOOL\nconst EVP_MD *EVP_whirlpool(void);\n# endif\n# ifndef OPENSSL_NO_SM3\nconst EVP_MD *EVP_sm3(void);\n# endif\nconst EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */\n# ifndef OPENSSL_NO_DES\nconst EVP_CIPHER *EVP_des_ecb(void);\nconst EVP_CIPHER *EVP_des_ede(void);\nconst EVP_CIPHER *EVP_des_ede3(void);\nconst EVP_CIPHER *EVP_des_ede_ecb(void);\nconst EVP_CIPHER *EVP_des_ede3_ecb(void);\nconst EVP_CIPHER *EVP_des_cfb64(void);\n#  define EVP_des_cfb EVP_des_cfb64\nconst EVP_CIPHER *EVP_des_cfb1(void);\nconst EVP_CIPHER *EVP_des_cfb8(void);\nconst EVP_CIPHER *EVP_des_ede_cfb64(void);\n#  define EVP_des_ede_cfb EVP_des_ede_cfb64\nconst EVP_CIPHER *EVP_des_ede3_cfb64(void);\n#  define EVP_des_ede3_cfb EVP_des_ede3_cfb64\nconst EVP_CIPHER *EVP_des_ede3_cfb1(void);\nconst EVP_CIPHER *EVP_des_ede3_cfb8(void);\nconst EVP_CIPHER *EVP_des_ofb(void);\nconst EVP_CIPHER *EVP_des_ede_ofb(void);\nconst EVP_CIPHER *EVP_des_ede3_ofb(void);\nconst EVP_CIPHER *EVP_des_cbc(void);\nconst EVP_CIPHER *EVP_des_ede_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_cbc(void);\nconst EVP_CIPHER *EVP_desx_cbc(void);\nconst EVP_CIPHER *EVP_des_ede3_wrap(void);\n/*\n * This should now be supported through the dev_crypto ENGINE. But also, why\n * are rc4 and md5 declarations made here inside a \"NO_DES\" precompiler\n * branch?\n */\n# endif\n# ifndef OPENSSL_NO_RC4\nconst EVP_CIPHER *EVP_rc4(void);\nconst EVP_CIPHER *EVP_rc4_40(void);\n#  ifndef OPENSSL_NO_MD5\nconst EVP_CIPHER *EVP_rc4_hmac_md5(void);\n#  endif\n# endif\n# ifndef OPENSSL_NO_IDEA\nconst EVP_CIPHER *EVP_idea_ecb(void);\nconst EVP_CIPHER *EVP_idea_cfb64(void);\n#  define EVP_idea_cfb EVP_idea_cfb64\nconst EVP_CIPHER *EVP_idea_ofb(void);\nconst EVP_CIPHER *EVP_idea_cbc(void);\n# endif\n# ifndef OPENSSL_NO_RC2\nconst EVP_CIPHER *EVP_rc2_ecb(void);\nconst EVP_CIPHER *EVP_rc2_cbc(void);\nconst EVP_CIPHER *EVP_rc2_40_cbc(void);\nconst EVP_CIPHER *EVP_rc2_64_cbc(void);\nconst EVP_CIPHER *EVP_rc2_cfb64(void);\n#  define EVP_rc2_cfb EVP_rc2_cfb64\nconst EVP_CIPHER *EVP_rc2_ofb(void);\n# endif\n# ifndef OPENSSL_NO_BF\nconst EVP_CIPHER *EVP_bf_ecb(void);\nconst EVP_CIPHER *EVP_bf_cbc(void);\nconst EVP_CIPHER *EVP_bf_cfb64(void);\n#  define EVP_bf_cfb EVP_bf_cfb64\nconst EVP_CIPHER *EVP_bf_ofb(void);\n# endif\n# ifndef OPENSSL_NO_CAST\nconst EVP_CIPHER *EVP_cast5_ecb(void);\nconst EVP_CIPHER *EVP_cast5_cbc(void);\nconst EVP_CIPHER *EVP_cast5_cfb64(void);\n#  define EVP_cast5_cfb EVP_cast5_cfb64\nconst EVP_CIPHER *EVP_cast5_ofb(void);\n# endif\n# ifndef OPENSSL_NO_RC5\nconst EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);\nconst EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);\n#  define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64\nconst EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);\n# endif\nconst EVP_CIPHER *EVP_aes_128_ecb(void);\nconst EVP_CIPHER *EVP_aes_128_cbc(void);\nconst EVP_CIPHER *EVP_aes_128_cfb1(void);\nconst EVP_CIPHER *EVP_aes_128_cfb8(void);\nconst EVP_CIPHER *EVP_aes_128_cfb128(void);\n# define EVP_aes_128_cfb EVP_aes_128_cfb128\nconst EVP_CIPHER *EVP_aes_128_ofb(void);\nconst EVP_CIPHER *EVP_aes_128_ctr(void);\nconst EVP_CIPHER *EVP_aes_128_ccm(void);\nconst EVP_CIPHER *EVP_aes_128_gcm(void);\nconst EVP_CIPHER *EVP_aes_128_xts(void);\nconst EVP_CIPHER *EVP_aes_128_wrap(void);\nconst EVP_CIPHER *EVP_aes_128_wrap_pad(void);\n# ifndef OPENSSL_NO_OCB\nconst EVP_CIPHER *EVP_aes_128_ocb(void);\n# endif\nconst EVP_CIPHER *EVP_aes_192_ecb(void);\nconst EVP_CIPHER *EVP_aes_192_cbc(void);\nconst EVP_CIPHER *EVP_aes_192_cfb1(void);\nconst EVP_CIPHER *EVP_aes_192_cfb8(void);\nconst EVP_CIPHER *EVP_aes_192_cfb128(void);\n# define EVP_aes_192_cfb EVP_aes_192_cfb128\nconst EVP_CIPHER *EVP_aes_192_ofb(void);\nconst EVP_CIPHER *EVP_aes_192_ctr(void);\nconst EVP_CIPHER *EVP_aes_192_ccm(void);\nconst EVP_CIPHER *EVP_aes_192_gcm(void);\nconst EVP_CIPHER *EVP_aes_192_wrap(void);\nconst EVP_CIPHER *EVP_aes_192_wrap_pad(void);\n# ifndef OPENSSL_NO_OCB\nconst EVP_CIPHER *EVP_aes_192_ocb(void);\n# endif\nconst EVP_CIPHER *EVP_aes_256_ecb(void);\nconst EVP_CIPHER *EVP_aes_256_cbc(void);\nconst EVP_CIPHER *EVP_aes_256_cfb1(void);\nconst EVP_CIPHER *EVP_aes_256_cfb8(void);\nconst EVP_CIPHER *EVP_aes_256_cfb128(void);\n# define EVP_aes_256_cfb EVP_aes_256_cfb128\nconst EVP_CIPHER *EVP_aes_256_ofb(void);\nconst EVP_CIPHER *EVP_aes_256_ctr(void);\nconst EVP_CIPHER *EVP_aes_256_ccm(void);\nconst EVP_CIPHER *EVP_aes_256_gcm(void);\nconst EVP_CIPHER *EVP_aes_256_xts(void);\nconst EVP_CIPHER *EVP_aes_256_wrap(void);\nconst EVP_CIPHER *EVP_aes_256_wrap_pad(void);\n# ifndef OPENSSL_NO_OCB\nconst EVP_CIPHER *EVP_aes_256_ocb(void);\n# endif\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);\nconst EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);\nconst EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);\n# ifndef OPENSSL_NO_ARIA\nconst EVP_CIPHER *EVP_aria_128_ecb(void);\nconst EVP_CIPHER *EVP_aria_128_cbc(void);\nconst EVP_CIPHER *EVP_aria_128_cfb1(void);\nconst EVP_CIPHER *EVP_aria_128_cfb8(void);\nconst EVP_CIPHER *EVP_aria_128_cfb128(void);\n#  define EVP_aria_128_cfb EVP_aria_128_cfb128\nconst EVP_CIPHER *EVP_aria_128_ctr(void);\nconst EVP_CIPHER *EVP_aria_128_ofb(void);\nconst EVP_CIPHER *EVP_aria_128_gcm(void);\nconst EVP_CIPHER *EVP_aria_128_ccm(void);\nconst EVP_CIPHER *EVP_aria_192_ecb(void);\nconst EVP_CIPHER *EVP_aria_192_cbc(void);\nconst EVP_CIPHER *EVP_aria_192_cfb1(void);\nconst EVP_CIPHER *EVP_aria_192_cfb8(void);\nconst EVP_CIPHER *EVP_aria_192_cfb128(void);\n#  define EVP_aria_192_cfb EVP_aria_192_cfb128\nconst EVP_CIPHER *EVP_aria_192_ctr(void);\nconst EVP_CIPHER *EVP_aria_192_ofb(void);\nconst EVP_CIPHER *EVP_aria_192_gcm(void);\nconst EVP_CIPHER *EVP_aria_192_ccm(void);\nconst EVP_CIPHER *EVP_aria_256_ecb(void);\nconst EVP_CIPHER *EVP_aria_256_cbc(void);\nconst EVP_CIPHER *EVP_aria_256_cfb1(void);\nconst EVP_CIPHER *EVP_aria_256_cfb8(void);\nconst EVP_CIPHER *EVP_aria_256_cfb128(void);\n#  define EVP_aria_256_cfb EVP_aria_256_cfb128\nconst EVP_CIPHER *EVP_aria_256_ctr(void);\nconst EVP_CIPHER *EVP_aria_256_ofb(void);\nconst EVP_CIPHER *EVP_aria_256_gcm(void);\nconst EVP_CIPHER *EVP_aria_256_ccm(void);\n# endif\n# ifndef OPENSSL_NO_CAMELLIA\nconst EVP_CIPHER *EVP_camellia_128_ecb(void);\nconst EVP_CIPHER *EVP_camellia_128_cbc(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_128_cfb128(void);\n#  define EVP_camellia_128_cfb EVP_camellia_128_cfb128\nconst EVP_CIPHER *EVP_camellia_128_ofb(void);\nconst EVP_CIPHER *EVP_camellia_128_ctr(void);\nconst EVP_CIPHER *EVP_camellia_192_ecb(void);\nconst EVP_CIPHER *EVP_camellia_192_cbc(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_192_cfb128(void);\n#  define EVP_camellia_192_cfb EVP_camellia_192_cfb128\nconst EVP_CIPHER *EVP_camellia_192_ofb(void);\nconst EVP_CIPHER *EVP_camellia_192_ctr(void);\nconst EVP_CIPHER *EVP_camellia_256_ecb(void);\nconst EVP_CIPHER *EVP_camellia_256_cbc(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb1(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb8(void);\nconst EVP_CIPHER *EVP_camellia_256_cfb128(void);\n#  define EVP_camellia_256_cfb EVP_camellia_256_cfb128\nconst EVP_CIPHER *EVP_camellia_256_ofb(void);\nconst EVP_CIPHER *EVP_camellia_256_ctr(void);\n# endif\n# ifndef OPENSSL_NO_CHACHA\nconst EVP_CIPHER *EVP_chacha20(void);\n#  ifndef OPENSSL_NO_POLY1305\nconst EVP_CIPHER *EVP_chacha20_poly1305(void);\n#  endif\n# endif\n\n# ifndef OPENSSL_NO_SEED\nconst EVP_CIPHER *EVP_seed_ecb(void);\nconst EVP_CIPHER *EVP_seed_cbc(void);\nconst EVP_CIPHER *EVP_seed_cfb128(void);\n#  define EVP_seed_cfb EVP_seed_cfb128\nconst EVP_CIPHER *EVP_seed_ofb(void);\n# endif\n\n# ifndef OPENSSL_NO_SM4\nconst EVP_CIPHER *EVP_sm4_ecb(void);\nconst EVP_CIPHER *EVP_sm4_cbc(void);\nconst EVP_CIPHER *EVP_sm4_cfb128(void);\n#  define EVP_sm4_cfb EVP_sm4_cfb128\nconst EVP_CIPHER *EVP_sm4_ofb(void);\nconst EVP_CIPHER *EVP_sm4_ctr(void);\n# endif\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define OPENSSL_add_all_algorithms_conf() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \\\n                        | OPENSSL_INIT_ADD_ALL_DIGESTS \\\n                        | OPENSSL_INIT_LOAD_CONFIG, NULL)\n#  define OPENSSL_add_all_algorithms_noconf() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \\\n                        | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)\n\n#  ifdef OPENSSL_LOAD_CONF\n#   define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_conf()\n#  else\n#   define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_noconf()\n#  endif\n\n#  define OpenSSL_add_all_ciphers() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL)\n#  define OpenSSL_add_all_digests() \\\n    OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)\n\n#  define EVP_cleanup() while(0) continue\n# endif\n\nint EVP_add_cipher(const EVP_CIPHER *cipher);\nint EVP_add_digest(const EVP_MD *digest);\n\nconst EVP_CIPHER *EVP_get_cipherbyname(const char *name);\nconst EVP_MD *EVP_get_digestbyname(const char *name);\n\nvoid EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,\n                                   const char *from, const char *to, void *x),\n                       void *arg);\nvoid EVP_CIPHER_do_all_sorted(void (*fn)\n                               (const EVP_CIPHER *ciph, const char *from,\n                                const char *to, void *x), void *arg);\n\nvoid EVP_MD_do_all(void (*fn) (const EVP_MD *ciph,\n                               const char *from, const char *to, void *x),\n                   void *arg);\nvoid EVP_MD_do_all_sorted(void (*fn)\n                           (const EVP_MD *ciph, const char *from,\n                            const char *to, void *x), void *arg);\n\nint EVP_PKEY_decrypt_old(unsigned char *dec_key,\n                         const unsigned char *enc_key, int enc_key_len,\n                         EVP_PKEY *private_key);\nint EVP_PKEY_encrypt_old(unsigned char *enc_key,\n                         const unsigned char *key, int key_len,\n                         EVP_PKEY *pub_key);\nint EVP_PKEY_type(int type);\nint EVP_PKEY_id(const EVP_PKEY *pkey);\nint EVP_PKEY_base_id(const EVP_PKEY *pkey);\nint EVP_PKEY_bits(const EVP_PKEY *pkey);\nint EVP_PKEY_security_bits(const EVP_PKEY *pkey);\nint EVP_PKEY_size(const EVP_PKEY *pkey);\nint EVP_PKEY_set_type(EVP_PKEY *pkey, int type);\nint EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);\nint EVP_PKEY_set_alias_type(EVP_PKEY *pkey, int type);\n# ifndef OPENSSL_NO_ENGINE\nint EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e);\nENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey);\n# endif\nint EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);\nvoid *EVP_PKEY_get0(const EVP_PKEY *pkey);\nconst unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);\n# ifndef OPENSSL_NO_POLY1305\nconst unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len);\n# endif\n# ifndef OPENSSL_NO_SIPHASH\nconst unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len);\n# endif\n\n# ifndef OPENSSL_NO_RSA\nstruct rsa_st;\nint EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);\nstruct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);\nstruct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DSA\nstruct dsa_st;\nint EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);\nstruct dsa_st *EVP_PKEY_get0_DSA(EVP_PKEY *pkey);\nstruct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_DH\nstruct dh_st;\nint EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);\nstruct dh_st *EVP_PKEY_get0_DH(EVP_PKEY *pkey);\nstruct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);\n# endif\n# ifndef OPENSSL_NO_EC\nstruct ec_key_st;\nint EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);\nstruct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);\nstruct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);\n# endif\n\nEVP_PKEY *EVP_PKEY_new(void);\nint EVP_PKEY_up_ref(EVP_PKEY *pkey);\nvoid EVP_PKEY_free(EVP_PKEY *pkey);\n\nEVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                        long length);\nint i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);\n\nEVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,\n                         long length);\nEVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,\n                             long length);\nint i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);\n\nint EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);\nint EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);\nint EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);\nint EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);\n\nint EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,\n                           int indent, ASN1_PCTX *pctx);\nint EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,\n                          int indent, ASN1_PCTX *pctx);\n\nint EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);\n\nint EVP_PKEY_set1_tls_encodedpoint(EVP_PKEY *pkey,\n                                   const unsigned char *pt, size_t ptlen);\nsize_t EVP_PKEY_get1_tls_encodedpoint(EVP_PKEY *pkey, unsigned char **ppt);\n\nint EVP_CIPHER_type(const EVP_CIPHER *ctx);\n\n/* calls methods */\nint EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* These are used by EVP_CIPHER methods */\nint EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\nint EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);\n\n/* PKCS5 password based encryption */\nint PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                       ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                       const EVP_MD *md, int en_de);\nint PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,\n                           const unsigned char *salt, int saltlen, int iter,\n                           int keylen, unsigned char *out);\nint PKCS5_PBKDF2_HMAC(const char *pass, int passlen,\n                      const unsigned char *salt, int saltlen, int iter,\n                      const EVP_MD *digest, int keylen, unsigned char *out);\nint PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                          ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                          const EVP_MD *md, int en_de);\n\n#ifndef OPENSSL_NO_SCRYPT\nint EVP_PBE_scrypt(const char *pass, size_t passlen,\n                   const unsigned char *salt, size_t saltlen,\n                   uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem,\n                   unsigned char *key, size_t keylen);\n\nint PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,\n                             int passlen, ASN1_TYPE *param,\n                             const EVP_CIPHER *c, const EVP_MD *md, int en_de);\n#endif\n\nvoid PKCS5_PBE_add(void);\n\nint EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,\n                       ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);\n\n/* PBE type */\n\n/* Can appear as the outermost AlgorithmIdentifier */\n# define EVP_PBE_TYPE_OUTER      0x0\n/* Is an PRF type OID */\n# define EVP_PBE_TYPE_PRF        0x1\n/* Is a PKCS#5 v2.0 KDF */\n# define EVP_PBE_TYPE_KDF        0x2\n\nint EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,\n                         int md_nid, EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,\n                    EVP_PBE_KEYGEN *keygen);\nint EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,\n                 EVP_PBE_KEYGEN **pkeygen);\nvoid EVP_PBE_cleanup(void);\nint EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num);\n\n# define ASN1_PKEY_ALIAS         0x1\n# define ASN1_PKEY_DYNAMIC       0x2\n# define ASN1_PKEY_SIGPARAM_NULL 0x4\n\n# define ASN1_PKEY_CTRL_PKCS7_SIGN       0x1\n# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT    0x2\n# define ASN1_PKEY_CTRL_DEFAULT_MD_NID   0x3\n# define ASN1_PKEY_CTRL_CMS_SIGN         0x5\n# define ASN1_PKEY_CTRL_CMS_ENVELOPE     0x7\n# define ASN1_PKEY_CTRL_CMS_RI_TYPE      0x8\n\n# define ASN1_PKEY_CTRL_SET1_TLS_ENCPT   0x9\n# define ASN1_PKEY_CTRL_GET1_TLS_ENCPT   0xa\n\nint EVP_PKEY_asn1_get_count(void);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,\n                                                   const char *str, int len);\nint EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);\nint EVP_PKEY_asn1_add_alias(int to, int from);\nint EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,\n                            int *ppkey_flags, const char **pinfo,\n                            const char **ppem_str,\n                            const EVP_PKEY_ASN1_METHOD *ameth);\n\nconst EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey);\nEVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,\n                                        const char *pem_str,\n                                        const char *info);\nvoid EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,\n                        const EVP_PKEY_ASN1_METHOD *src);\nvoid EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);\nvoid EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,\n                              int (*pub_decode) (EVP_PKEY *pk,\n                                                 X509_PUBKEY *pub),\n                              int (*pub_encode) (X509_PUBKEY *pub,\n                                                 const EVP_PKEY *pk),\n                              int (*pub_cmp) (const EVP_PKEY *a,\n                                              const EVP_PKEY *b),\n                              int (*pub_print) (BIO *out,\n                                                const EVP_PKEY *pkey,\n                                                int indent, ASN1_PCTX *pctx),\n                              int (*pkey_size) (const EVP_PKEY *pk),\n                              int (*pkey_bits) (const EVP_PKEY *pk));\nvoid EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,\n                               int (*priv_decode) (EVP_PKEY *pk,\n                                                   const PKCS8_PRIV_KEY_INFO\n                                                   *p8inf),\n                               int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,\n                                                   const EVP_PKEY *pk),\n                               int (*priv_print) (BIO *out,\n                                                  const EVP_PKEY *pkey,\n                                                  int indent,\n                                                  ASN1_PCTX *pctx));\nvoid EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,\n                             int (*param_decode) (EVP_PKEY *pkey,\n                                                  const unsigned char **pder,\n                                                  int derlen),\n                             int (*param_encode) (const EVP_PKEY *pkey,\n                                                  unsigned char **pder),\n                             int (*param_missing) (const EVP_PKEY *pk),\n                             int (*param_copy) (EVP_PKEY *to,\n                                                const EVP_PKEY *from),\n                             int (*param_cmp) (const EVP_PKEY *a,\n                                               const EVP_PKEY *b),\n                             int (*param_print) (BIO *out,\n                                                 const EVP_PKEY *pkey,\n                                                 int indent,\n                                                 ASN1_PCTX *pctx));\n\nvoid EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,\n                            void (*pkey_free) (EVP_PKEY *pkey));\nvoid EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*pkey_ctrl) (EVP_PKEY *pkey, int op,\n                                              long arg1, void *arg2));\nvoid EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,\n                            int (*item_verify) (EVP_MD_CTX *ctx,\n                                                const ASN1_ITEM *it,\n                                                void *asn,\n                                                X509_ALGOR *a,\n                                                ASN1_BIT_STRING *sig,\n                                                EVP_PKEY *pkey),\n                            int (*item_sign) (EVP_MD_CTX *ctx,\n                                              const ASN1_ITEM *it,\n                                              void *asn,\n                                              X509_ALGOR *alg1,\n                                              X509_ALGOR *alg2,\n                                              ASN1_BIT_STRING *sig));\n\nvoid EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth,\n                              int (*siginf_set) (X509_SIG_INFO *siginf,\n                                                 const X509_ALGOR *alg,\n                                                 const ASN1_STRING *sig));\n\nvoid EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth,\n                             int (*pkey_check) (const EVP_PKEY *pk));\n\nvoid EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth,\n                                    int (*pkey_pub_check) (const EVP_PKEY *pk));\n\nvoid EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth,\n                                   int (*pkey_param_check) (const EVP_PKEY *pk));\n\nvoid EVP_PKEY_asn1_set_set_priv_key(EVP_PKEY_ASN1_METHOD *ameth,\n                                    int (*set_priv_key) (EVP_PKEY *pk,\n                                                         const unsigned char\n                                                            *priv,\n                                                         size_t len));\nvoid EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth,\n                                   int (*set_pub_key) (EVP_PKEY *pk,\n                                                       const unsigned char *pub,\n                                                       size_t len));\nvoid EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth,\n                                    int (*get_priv_key) (const EVP_PKEY *pk,\n                                                         unsigned char *priv,\n                                                         size_t *len));\nvoid EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth,\n                                   int (*get_pub_key) (const EVP_PKEY *pk,\n                                                       unsigned char *pub,\n                                                       size_t *len));\n\nvoid EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,\n                                     int (*pkey_security_bits) (const EVP_PKEY\n                                                                *pk));\n\n# define EVP_PKEY_OP_UNDEFINED           0\n# define EVP_PKEY_OP_PARAMGEN            (1<<1)\n# define EVP_PKEY_OP_KEYGEN              (1<<2)\n# define EVP_PKEY_OP_SIGN                (1<<3)\n# define EVP_PKEY_OP_VERIFY              (1<<4)\n# define EVP_PKEY_OP_VERIFYRECOVER       (1<<5)\n# define EVP_PKEY_OP_SIGNCTX             (1<<6)\n# define EVP_PKEY_OP_VERIFYCTX           (1<<7)\n# define EVP_PKEY_OP_ENCRYPT             (1<<8)\n# define EVP_PKEY_OP_DECRYPT             (1<<9)\n# define EVP_PKEY_OP_DERIVE              (1<<10)\n\n# define EVP_PKEY_OP_TYPE_SIG    \\\n        (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \\\n                | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)\n\n# define EVP_PKEY_OP_TYPE_CRYPT \\\n        (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)\n\n# define EVP_PKEY_OP_TYPE_NOGEN \\\n        (EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT | EVP_PKEY_OP_DERIVE)\n\n# define EVP_PKEY_OP_TYPE_GEN \\\n                (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)\n\n# define  EVP_PKEY_CTX_set_signature_md(ctx, md) \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_MD, 0, (void *)(md))\n\n# define  EVP_PKEY_CTX_get_signature_md(ctx, pmd)        \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \\\n                                        EVP_PKEY_CTRL_GET_MD, 0, (void *)(pmd))\n\n# define  EVP_PKEY_CTX_set_mac_key(ctx, key, len)        \\\n                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_KEYGEN,  \\\n                                  EVP_PKEY_CTRL_SET_MAC_KEY, len, (void *)(key))\n\n# define EVP_PKEY_CTRL_MD                1\n# define EVP_PKEY_CTRL_PEER_KEY          2\n\n# define EVP_PKEY_CTRL_PKCS7_ENCRYPT     3\n# define EVP_PKEY_CTRL_PKCS7_DECRYPT     4\n\n# define EVP_PKEY_CTRL_PKCS7_SIGN        5\n\n# define EVP_PKEY_CTRL_SET_MAC_KEY       6\n\n# define EVP_PKEY_CTRL_DIGESTINIT        7\n\n/* Used by GOST key encryption in TLS */\n# define EVP_PKEY_CTRL_SET_IV            8\n\n# define EVP_PKEY_CTRL_CMS_ENCRYPT       9\n# define EVP_PKEY_CTRL_CMS_DECRYPT       10\n# define EVP_PKEY_CTRL_CMS_SIGN          11\n\n# define EVP_PKEY_CTRL_CIPHER            12\n\n# define EVP_PKEY_CTRL_GET_MD            13\n\n# define EVP_PKEY_CTRL_SET_DIGEST_SIZE   14\n\n# define EVP_PKEY_ALG_CTRL               0x1000\n\n# define EVP_PKEY_FLAG_AUTOARGLEN        2\n/*\n * Method handles all operations: don't assume any digest related defaults.\n */\n# define EVP_PKEY_FLAG_SIGCTX_CUSTOM     4\n\nconst EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);\nEVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);\nvoid EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,\n                             const EVP_PKEY_METHOD *meth);\nvoid EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);\nvoid EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);\nint EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);\nint EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth);\nsize_t EVP_PKEY_meth_get_count(void);\nconst EVP_PKEY_METHOD *EVP_PKEY_meth_get0(size_t idx);\n\nEVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);\nEVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,\n                      int cmd, int p1, void *p2);\nint EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,\n                          const char *value);\nint EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype,\n                             int cmd, uint64_t value);\n\nint EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str);\nint EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex);\n\nint EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md);\n\nint EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);\nvoid EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);\n\nEVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,\n                               const unsigned char *key, int keylen);\nEVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *e,\n                                       const unsigned char *priv,\n                                       size_t len);\nEVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *e,\n                                      const unsigned char *pub,\n                                      size_t len);\nint EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, unsigned char *priv,\n                                 size_t *len);\nint EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, unsigned char *pub,\n                                size_t *len);\n\nEVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv,\n                                size_t len, const EVP_CIPHER *cipher);\n\nvoid EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);\nEVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);\n\nEVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);\n\nvoid EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);\nvoid *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_sign(EVP_PKEY_CTX *ctx,\n                  unsigned char *sig, size_t *siglen,\n                  const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify(EVP_PKEY_CTX *ctx,\n                    const unsigned char *sig, size_t siglen,\n                    const unsigned char *tbs, size_t tbslen);\nint EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,\n                            unsigned char *rout, size_t *routlen,\n                            const unsigned char *sig, size_t siglen);\nint EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\nint EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,\n                     unsigned char *out, size_t *outlen,\n                     const unsigned char *in, size_t inlen);\n\nint EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);\nint EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);\n\ntypedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\nint EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);\nint EVP_PKEY_check(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_public_check(EVP_PKEY_CTX *ctx);\nint EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);\n\nvoid EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);\nEVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);\n\nint EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);\n\nvoid EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,\n                            int (*init) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,\n                            int (*copy) (EVP_PKEY_CTX *dst,\n                                         EVP_PKEY_CTX *src));\n\nvoid EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,\n                               void (*cleanup) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,\n                                int (*paramgen_init) (EVP_PKEY_CTX *ctx),\n                                int (*paramgen) (EVP_PKEY_CTX *ctx,\n                                                 EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,\n                              int (*keygen_init) (EVP_PKEY_CTX *ctx),\n                              int (*keygen) (EVP_PKEY_CTX *ctx,\n                                             EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,\n                            int (*sign_init) (EVP_PKEY_CTX *ctx),\n                            int (*sign) (EVP_PKEY_CTX *ctx,\n                                         unsigned char *sig, size_t *siglen,\n                                         const unsigned char *tbs,\n                                         size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,\n                              int (*verify_init) (EVP_PKEY_CTX *ctx),\n                              int (*verify) (EVP_PKEY_CTX *ctx,\n                                             const unsigned char *sig,\n                                             size_t siglen,\n                                             const unsigned char *tbs,\n                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,\n                                      int (*verify_recover_init) (EVP_PKEY_CTX\n                                                                  *ctx),\n                                      int (*verify_recover) (EVP_PKEY_CTX\n                                                             *ctx,\n                                                             unsigned char\n                                                             *sig,\n                                                             size_t *siglen,\n                                                             const unsigned\n                                                             char *tbs,\n                                                             size_t tbslen));\n\nvoid EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,\n                               int (*signctx_init) (EVP_PKEY_CTX *ctx,\n                                                    EVP_MD_CTX *mctx),\n                               int (*signctx) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *sig,\n                                               size_t *siglen,\n                                               EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,\n                                 int (*verifyctx_init) (EVP_PKEY_CTX *ctx,\n                                                        EVP_MD_CTX *mctx),\n                                 int (*verifyctx) (EVP_PKEY_CTX *ctx,\n                                                   const unsigned char *sig,\n                                                   int siglen,\n                                                   EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*encrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*encryptfn) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *out,\n                                                 size_t *outlen,\n                                                 const unsigned char *in,\n                                                 size_t inlen));\n\nvoid EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,\n                               int (*decrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (*decrypt) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *out,\n                                               size_t *outlen,\n                                               const unsigned char *in,\n                                               size_t inlen));\n\nvoid EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,\n                              int (*derive_init) (EVP_PKEY_CTX *ctx),\n                              int (*derive) (EVP_PKEY_CTX *ctx,\n                                             unsigned char *key,\n                                             size_t *keylen));\n\nvoid EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,\n                            int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,\n                                         void *p2),\n                            int (*ctrl_str) (EVP_PKEY_CTX *ctx,\n                                             const char *type,\n                                             const char *value));\n\nvoid EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth,\n                                  int (*digestsign) (EVP_MD_CTX *ctx,\n                                                     unsigned char *sig,\n                                                     size_t *siglen,\n                                                     const unsigned char *tbs,\n                                                     size_t tbslen));\n\nvoid EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth,\n                                    int (*digestverify) (EVP_MD_CTX *ctx,\n                                                         const unsigned char *sig,\n                                                         size_t siglen,\n                                                         const unsigned char *tbs,\n                                                         size_t tbslen));\n\nvoid EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth,\n                             int (*check) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth,\n                                    int (*check) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth,\n                                   int (*check) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth,\n                                     int (*digest_custom) (EVP_PKEY_CTX *ctx,\n                                                           EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth,\n                            int (**pinit) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth,\n                            int (**pcopy) (EVP_PKEY_CTX *dst,\n                                           EVP_PKEY_CTX *src));\n\nvoid EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth,\n                               void (**pcleanup) (EVP_PKEY_CTX *ctx));\n\nvoid EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth,\n                                int (**pparamgen_init) (EVP_PKEY_CTX *ctx),\n                                int (**pparamgen) (EVP_PKEY_CTX *ctx,\n                                                   EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth,\n                              int (**pkeygen_init) (EVP_PKEY_CTX *ctx),\n                              int (**pkeygen) (EVP_PKEY_CTX *ctx,\n                                               EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth,\n                            int (**psign_init) (EVP_PKEY_CTX *ctx),\n                            int (**psign) (EVP_PKEY_CTX *ctx,\n                                           unsigned char *sig, size_t *siglen,\n                                           const unsigned char *tbs,\n                                           size_t tbslen));\n\nvoid EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth,\n                              int (**pverify_init) (EVP_PKEY_CTX *ctx),\n                              int (**pverify) (EVP_PKEY_CTX *ctx,\n                                               const unsigned char *sig,\n                                               size_t siglen,\n                                               const unsigned char *tbs,\n                                               size_t tbslen));\n\nvoid EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD *pmeth,\n                                      int (**pverify_recover_init) (EVP_PKEY_CTX\n                                                                    *ctx),\n                                      int (**pverify_recover) (EVP_PKEY_CTX\n                                                               *ctx,\n                                                               unsigned char\n                                                               *sig,\n                                                               size_t *siglen,\n                                                               const unsigned\n                                                               char *tbs,\n                                                               size_t tbslen));\n\nvoid EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD *pmeth,\n                               int (**psignctx_init) (EVP_PKEY_CTX *ctx,\n                                                      EVP_MD_CTX *mctx),\n                               int (**psignctx) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *sig,\n                                                 size_t *siglen,\n                                                 EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD *pmeth,\n                                 int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,\n                                                          EVP_MD_CTX *mctx),\n                                 int (**pverifyctx) (EVP_PKEY_CTX *ctx,\n                                                     const unsigned char *sig,\n                                                     int siglen,\n                                                     EVP_MD_CTX *mctx));\n\nvoid EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth,\n                               int (**pencrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (**pencryptfn) (EVP_PKEY_CTX *ctx,\n                                                   unsigned char *out,\n                                                   size_t *outlen,\n                                                   const unsigned char *in,\n                                                   size_t inlen));\n\nvoid EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth,\n                               int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),\n                               int (**pdecrypt) (EVP_PKEY_CTX *ctx,\n                                                 unsigned char *out,\n                                                 size_t *outlen,\n                                                 const unsigned char *in,\n                                                 size_t inlen));\n\nvoid EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth,\n                              int (**pderive_init) (EVP_PKEY_CTX *ctx),\n                              int (**pderive) (EVP_PKEY_CTX *ctx,\n                                               unsigned char *key,\n                                               size_t *keylen));\n\nvoid EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth,\n                            int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,\n                                           void *p2),\n                            int (**pctrl_str) (EVP_PKEY_CTX *ctx,\n                                               const char *type,\n                                               const char *value));\n\nvoid EVP_PKEY_meth_get_digestsign(EVP_PKEY_METHOD *pmeth,\n                                  int (**digestsign) (EVP_MD_CTX *ctx,\n                                                      unsigned char *sig,\n                                                      size_t *siglen,\n                                                      const unsigned char *tbs,\n                                                      size_t tbslen));\n\nvoid EVP_PKEY_meth_get_digestverify(EVP_PKEY_METHOD *pmeth,\n                                    int (**digestverify) (EVP_MD_CTX *ctx,\n                                                          const unsigned char *sig,\n                                                          size_t siglen,\n                                                          const unsigned char *tbs,\n                                                          size_t tbslen));\n\nvoid EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth,\n                             int (**pcheck) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth,\n                                    int (**pcheck) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth,\n                                   int (**pcheck) (EVP_PKEY *pkey));\n\nvoid EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD *pmeth,\n                                     int (**pdigest_custom) (EVP_PKEY_CTX *ctx,\n                                                             EVP_MD_CTX *mctx));\nvoid EVP_add_alg_module(void);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/evperr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_EVPERR_H\n# define HEADER_EVPERR_H\n\n# include <openssl/symhacks.h>\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_EVP_strings(void);\n\n/*\n * EVP function codes.\n */\n# define EVP_F_AESNI_INIT_KEY                             165\n# define EVP_F_AESNI_XTS_INIT_KEY                         207\n# define EVP_F_AES_GCM_CTRL                               196\n# define EVP_F_AES_INIT_KEY                               133\n# define EVP_F_AES_OCB_CIPHER                             169\n# define EVP_F_AES_T4_INIT_KEY                            178\n# define EVP_F_AES_T4_XTS_INIT_KEY                        208\n# define EVP_F_AES_WRAP_CIPHER                            170\n# define EVP_F_AES_XTS_INIT_KEY                           209\n# define EVP_F_ALG_MODULE_INIT                            177\n# define EVP_F_ARIA_CCM_INIT_KEY                          175\n# define EVP_F_ARIA_GCM_CTRL                              197\n# define EVP_F_ARIA_GCM_INIT_KEY                          176\n# define EVP_F_ARIA_INIT_KEY                              185\n# define EVP_F_B64_NEW                                    198\n# define EVP_F_CAMELLIA_INIT_KEY                          159\n# define EVP_F_CHACHA20_POLY1305_CTRL                     182\n# define EVP_F_CMLL_T4_INIT_KEY                           179\n# define EVP_F_DES_EDE3_WRAP_CIPHER                       171\n# define EVP_F_DO_SIGVER_INIT                             161\n# define EVP_F_ENC_NEW                                    199\n# define EVP_F_EVP_CIPHERINIT_EX                          123\n# define EVP_F_EVP_CIPHER_ASN1_TO_PARAM                   204\n# define EVP_F_EVP_CIPHER_CTX_COPY                        163\n# define EVP_F_EVP_CIPHER_CTX_CTRL                        124\n# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH              122\n# define EVP_F_EVP_CIPHER_PARAM_TO_ASN1                   205\n# define EVP_F_EVP_DECRYPTFINAL_EX                        101\n# define EVP_F_EVP_DECRYPTUPDATE                          166\n# define EVP_F_EVP_DIGESTFINALXOF                         174\n# define EVP_F_EVP_DIGESTINIT_EX                          128\n# define EVP_F_EVP_ENCRYPTDECRYPTUPDATE                   219\n# define EVP_F_EVP_ENCRYPTFINAL_EX                        127\n# define EVP_F_EVP_ENCRYPTUPDATE                          167\n# define EVP_F_EVP_MD_CTX_COPY_EX                         110\n# define EVP_F_EVP_MD_SIZE                                162\n# define EVP_F_EVP_OPENINIT                               102\n# define EVP_F_EVP_PBE_ALG_ADD                            115\n# define EVP_F_EVP_PBE_ALG_ADD_TYPE                       160\n# define EVP_F_EVP_PBE_CIPHERINIT                         116\n# define EVP_F_EVP_PBE_SCRYPT                             181\n# define EVP_F_EVP_PKCS82PKEY                             111\n# define EVP_F_EVP_PKEY2PKCS8                             113\n# define EVP_F_EVP_PKEY_ASN1_ADD0                         188\n# define EVP_F_EVP_PKEY_CHECK                             186\n# define EVP_F_EVP_PKEY_COPY_PARAMETERS                   103\n# define EVP_F_EVP_PKEY_CTX_CTRL                          137\n# define EVP_F_EVP_PKEY_CTX_CTRL_STR                      150\n# define EVP_F_EVP_PKEY_CTX_DUP                           156\n# define EVP_F_EVP_PKEY_CTX_MD                            168\n# define EVP_F_EVP_PKEY_DECRYPT                           104\n# define EVP_F_EVP_PKEY_DECRYPT_INIT                      138\n# define EVP_F_EVP_PKEY_DECRYPT_OLD                       151\n# define EVP_F_EVP_PKEY_DERIVE                            153\n# define EVP_F_EVP_PKEY_DERIVE_INIT                       154\n# define EVP_F_EVP_PKEY_DERIVE_SET_PEER                   155\n# define EVP_F_EVP_PKEY_ENCRYPT                           105\n# define EVP_F_EVP_PKEY_ENCRYPT_INIT                      139\n# define EVP_F_EVP_PKEY_ENCRYPT_OLD                       152\n# define EVP_F_EVP_PKEY_GET0_DH                           119\n# define EVP_F_EVP_PKEY_GET0_DSA                          120\n# define EVP_F_EVP_PKEY_GET0_EC_KEY                       131\n# define EVP_F_EVP_PKEY_GET0_HMAC                         183\n# define EVP_F_EVP_PKEY_GET0_POLY1305                     184\n# define EVP_F_EVP_PKEY_GET0_RSA                          121\n# define EVP_F_EVP_PKEY_GET0_SIPHASH                      172\n# define EVP_F_EVP_PKEY_GET_RAW_PRIVATE_KEY               202\n# define EVP_F_EVP_PKEY_GET_RAW_PUBLIC_KEY                203\n# define EVP_F_EVP_PKEY_KEYGEN                            146\n# define EVP_F_EVP_PKEY_KEYGEN_INIT                       147\n# define EVP_F_EVP_PKEY_METH_ADD0                         194\n# define EVP_F_EVP_PKEY_METH_NEW                          195\n# define EVP_F_EVP_PKEY_NEW                               106\n# define EVP_F_EVP_PKEY_NEW_CMAC_KEY                      193\n# define EVP_F_EVP_PKEY_NEW_RAW_PRIVATE_KEY               191\n# define EVP_F_EVP_PKEY_NEW_RAW_PUBLIC_KEY                192\n# define EVP_F_EVP_PKEY_PARAMGEN                          148\n# define EVP_F_EVP_PKEY_PARAMGEN_INIT                     149\n# define EVP_F_EVP_PKEY_PARAM_CHECK                       189\n# define EVP_F_EVP_PKEY_PUBLIC_CHECK                      190\n# define EVP_F_EVP_PKEY_SET1_ENGINE                       187\n# define EVP_F_EVP_PKEY_SET_ALIAS_TYPE                    206\n# define EVP_F_EVP_PKEY_SIGN                              140\n# define EVP_F_EVP_PKEY_SIGN_INIT                         141\n# define EVP_F_EVP_PKEY_VERIFY                            142\n# define EVP_F_EVP_PKEY_VERIFY_INIT                       143\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER                    144\n# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT               145\n# define EVP_F_EVP_SIGNFINAL                              107\n# define EVP_F_EVP_VERIFYFINAL                            108\n# define EVP_F_INT_CTX_NEW                                157\n# define EVP_F_OK_NEW                                     200\n# define EVP_F_PKCS5_PBE_KEYIVGEN                         117\n# define EVP_F_PKCS5_V2_PBE_KEYIVGEN                      118\n# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN                   164\n# define EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN                   180\n# define EVP_F_PKEY_SET_TYPE                              158\n# define EVP_F_RC2_MAGIC_TO_METH                          109\n# define EVP_F_RC5_CTRL                                   125\n# define EVP_F_R_32_12_16_INIT_KEY                        242\n# define EVP_F_S390X_AES_GCM_CTRL                         201\n# define EVP_F_UPDATE                                     173\n\n/*\n * EVP reason codes.\n */\n# define EVP_R_AES_KEY_SETUP_FAILED                       143\n# define EVP_R_ARIA_KEY_SETUP_FAILED                      176\n# define EVP_R_BAD_DECRYPT                                100\n# define EVP_R_BAD_KEY_LENGTH                             195\n# define EVP_R_BUFFER_TOO_SMALL                           155\n# define EVP_R_CAMELLIA_KEY_SETUP_FAILED                  157\n# define EVP_R_CIPHER_PARAMETER_ERROR                     122\n# define EVP_R_COMMAND_NOT_SUPPORTED                      147\n# define EVP_R_COPY_ERROR                                 173\n# define EVP_R_CTRL_NOT_IMPLEMENTED                       132\n# define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED             133\n# define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH          138\n# define EVP_R_DECODE_ERROR                               114\n# define EVP_R_DIFFERENT_KEY_TYPES                        101\n# define EVP_R_DIFFERENT_PARAMETERS                       153\n# define EVP_R_ERROR_LOADING_SECTION                      165\n# define EVP_R_ERROR_SETTING_FIPS_MODE                    166\n# define EVP_R_EXPECTING_AN_HMAC_KEY                      174\n# define EVP_R_EXPECTING_AN_RSA_KEY                       127\n# define EVP_R_EXPECTING_A_DH_KEY                         128\n# define EVP_R_EXPECTING_A_DSA_KEY                        129\n# define EVP_R_EXPECTING_A_EC_KEY                         142\n# define EVP_R_EXPECTING_A_POLY1305_KEY                   164\n# define EVP_R_EXPECTING_A_SIPHASH_KEY                    175\n# define EVP_R_FIPS_MODE_NOT_SUPPORTED                    167\n# define EVP_R_GET_RAW_KEY_FAILED                         182\n# define EVP_R_ILLEGAL_SCRYPT_PARAMETERS                  171\n# define EVP_R_INITIALIZATION_ERROR                       134\n# define EVP_R_INPUT_NOT_INITIALIZED                      111\n# define EVP_R_INVALID_DIGEST                             152\n# define EVP_R_INVALID_FIPS_MODE                          168\n# define EVP_R_INVALID_IV_LENGTH                          194\n# define EVP_R_INVALID_KEY                                163\n# define EVP_R_INVALID_KEY_LENGTH                         130\n# define EVP_R_INVALID_OPERATION                          148\n# define EVP_R_KEYGEN_FAILURE                             120\n# define EVP_R_KEY_SETUP_FAILED                           180\n# define EVP_R_MEMORY_LIMIT_EXCEEDED                      172\n# define EVP_R_MESSAGE_DIGEST_IS_NULL                     159\n# define EVP_R_METHOD_NOT_SUPPORTED                       144\n# define EVP_R_MISSING_PARAMETERS                         103\n# define EVP_R_NOT_XOF_OR_INVALID_LENGTH                  178\n# define EVP_R_NO_CIPHER_SET                              131\n# define EVP_R_NO_DEFAULT_DIGEST                          158\n# define EVP_R_NO_DIGEST_SET                              139\n# define EVP_R_NO_KEY_SET                                 154\n# define EVP_R_NO_OPERATION_SET                           149\n# define EVP_R_ONLY_ONESHOT_SUPPORTED                     177\n# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   150\n# define EVP_R_OPERATON_NOT_INITIALIZED                   151\n# define EVP_R_OUTPUT_WOULD_OVERFLOW                      184\n# define EVP_R_PARTIALLY_OVERLAPPING                      162\n# define EVP_R_PBKDF2_ERROR                               181\n# define EVP_R_PKEY_APPLICATION_ASN1_METHOD_ALREADY_REGISTERED 179\n# define EVP_R_PRIVATE_KEY_DECODE_ERROR                   145\n# define EVP_R_PRIVATE_KEY_ENCODE_ERROR                   146\n# define EVP_R_PUBLIC_KEY_NOT_RSA                         106\n# define EVP_R_UNKNOWN_CIPHER                             160\n# define EVP_R_UNKNOWN_DIGEST                             161\n# define EVP_R_UNKNOWN_OPTION                             169\n# define EVP_R_UNKNOWN_PBE_ALGORITHM                      121\n# define EVP_R_UNSUPPORTED_ALGORITHM                      156\n# define EVP_R_UNSUPPORTED_CIPHER                         107\n# define EVP_R_UNSUPPORTED_KEYLENGTH                      123\n# define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION        124\n# define EVP_R_UNSUPPORTED_KEY_SIZE                       108\n# define EVP_R_UNSUPPORTED_NUMBER_OF_ROUNDS               135\n# define EVP_R_UNSUPPORTED_PRF                            125\n# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM          118\n# define EVP_R_UNSUPPORTED_SALT_TYPE                      126\n# define EVP_R_WRAP_MODE_NOT_ALLOWED                      170\n# define EVP_R_WRONG_FINAL_BLOCK_LENGTH                   109\n# define EVP_R_XTS_DUPLICATED_KEYS                        183\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/hmac.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_HMAC_H\n# define HEADER_HMAC_H\n\n# include <openssl/opensslconf.h>\n\n# include <openssl/evp.h>\n\n# if OPENSSL_API_COMPAT < 0x10200000L\n#  define HMAC_MAX_MD_CBLOCK      128    /* Deprecated */\n# endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\nsize_t HMAC_size(const HMAC_CTX *e);\nHMAC_CTX *HMAC_CTX_new(void);\nint HMAC_CTX_reset(HMAC_CTX *ctx);\nvoid HMAC_CTX_free(HMAC_CTX *ctx);\n\nDEPRECATEDIN_1_1_0(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len,\n                     const EVP_MD *md))\n\n/*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,\n                            const EVP_MD *md, ENGINE *impl);\n/*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data,\n                           size_t len);\n/*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md,\n                          unsigned int *len);\nunsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,\n                    const unsigned char *d, size_t n, unsigned char *md,\n                    unsigned int *md_len);\n__owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx);\n\nvoid HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags);\nconst EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/idea.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_IDEA_H\n# define HEADER_IDEA_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_IDEA\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef unsigned int IDEA_INT;\n\n# define IDEA_ENCRYPT    1\n# define IDEA_DECRYPT    0\n\n# define IDEA_BLOCK      8\n# define IDEA_KEY_LENGTH 16\n\ntypedef struct idea_key_st {\n    IDEA_INT data[9][6];\n} IDEA_KEY_SCHEDULE;\n\nconst char *IDEA_options(void);\nvoid IDEA_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      IDEA_KEY_SCHEDULE *ks);\nvoid IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks);\nvoid IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk);\nvoid IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                      long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                      int enc);\nvoid IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num, int enc);\nvoid IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,\n                        int *num);\nvoid IDEA_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define idea_options          IDEA_options\n#  define idea_ecb_encrypt      IDEA_ecb_encrypt\n#  define idea_set_encrypt_key  IDEA_set_encrypt_key\n#  define idea_set_decrypt_key  IDEA_set_decrypt_key\n#  define idea_cbc_encrypt      IDEA_cbc_encrypt\n#  define idea_cfb64_encrypt    IDEA_cfb64_encrypt\n#  define idea_ofb64_encrypt    IDEA_ofb64_encrypt\n#  define idea_encrypt          IDEA_encrypt\n# endif\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/kdf.h",
    "content": "/*\n * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_KDF_H\n# define HEADER_KDF_H\n\n# include <openssl/kdferr.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define EVP_PKEY_CTRL_TLS_MD                   (EVP_PKEY_ALG_CTRL)\n# define EVP_PKEY_CTRL_TLS_SECRET               (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_TLS_SEED                 (EVP_PKEY_ALG_CTRL + 2)\n# define EVP_PKEY_CTRL_HKDF_MD                  (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_HKDF_SALT                (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_HKDF_KEY                 (EVP_PKEY_ALG_CTRL + 5)\n# define EVP_PKEY_CTRL_HKDF_INFO                (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_HKDF_MODE                (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_PASS                     (EVP_PKEY_ALG_CTRL + 8)\n# define EVP_PKEY_CTRL_SCRYPT_SALT              (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_SCRYPT_N                 (EVP_PKEY_ALG_CTRL + 10)\n# define EVP_PKEY_CTRL_SCRYPT_R                 (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_SCRYPT_P                 (EVP_PKEY_ALG_CTRL + 12)\n# define EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES      (EVP_PKEY_ALG_CTRL + 13)\n\n# define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND 0\n# define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY       1\n# define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY        2\n\n# define EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_TLS_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, seclen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_TLS_SECRET, seclen, (void *)(sec))\n\n# define EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed, seedlen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_TLS_SEED, seedlen, (void *)(seed))\n\n# define EVP_PKEY_CTX_set_hkdf_md(pctx, md) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_MD, 0, (void *)(md))\n\n# define EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, saltlen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_SALT, saltlen, (void *)(salt))\n\n# define EVP_PKEY_CTX_set1_hkdf_key(pctx, key, keylen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_KEY, keylen, (void *)(key))\n\n# define EVP_PKEY_CTX_add1_hkdf_info(pctx, info, infolen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_INFO, infolen, (void *)(info))\n\n# define EVP_PKEY_CTX_hkdf_mode(pctx, mode) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                              EVP_PKEY_CTRL_HKDF_MODE, mode, NULL)\n\n# define EVP_PKEY_CTX_set1_pbe_pass(pctx, pass, passlen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_PASS, passlen, (void *)(pass))\n\n# define EVP_PKEY_CTX_set1_scrypt_salt(pctx, salt, saltlen) \\\n            EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_SALT, saltlen, (void *)(salt))\n\n# define EVP_PKEY_CTX_set_scrypt_N(pctx, n) \\\n            EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_N, n)\n\n# define EVP_PKEY_CTX_set_scrypt_r(pctx, r) \\\n            EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_R, r)\n\n# define EVP_PKEY_CTX_set_scrypt_p(pctx, p) \\\n            EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_P, p)\n\n# define EVP_PKEY_CTX_set_scrypt_maxmem_bytes(pctx, maxmem_bytes) \\\n            EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \\\n                            EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES, maxmem_bytes)\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/kdferr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_KDFERR_H\n# define HEADER_KDFERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_KDF_strings(void);\n\n/*\n * KDF function codes.\n */\n# define KDF_F_PKEY_HKDF_CTRL_STR                         103\n# define KDF_F_PKEY_HKDF_DERIVE                           102\n# define KDF_F_PKEY_HKDF_INIT                             108\n# define KDF_F_PKEY_SCRYPT_CTRL_STR                       104\n# define KDF_F_PKEY_SCRYPT_CTRL_UINT64                    105\n# define KDF_F_PKEY_SCRYPT_DERIVE                         109\n# define KDF_F_PKEY_SCRYPT_INIT                           106\n# define KDF_F_PKEY_SCRYPT_SET_MEMBUF                     107\n# define KDF_F_PKEY_TLS1_PRF_CTRL_STR                     100\n# define KDF_F_PKEY_TLS1_PRF_DERIVE                       101\n# define KDF_F_PKEY_TLS1_PRF_INIT                         110\n# define KDF_F_TLS1_PRF_ALG                               111\n\n/*\n * KDF reason codes.\n */\n# define KDF_R_INVALID_DIGEST                             100\n# define KDF_R_MISSING_ITERATION_COUNT                    109\n# define KDF_R_MISSING_KEY                                104\n# define KDF_R_MISSING_MESSAGE_DIGEST                     105\n# define KDF_R_MISSING_PARAMETER                          101\n# define KDF_R_MISSING_PASS                               110\n# define KDF_R_MISSING_SALT                               111\n# define KDF_R_MISSING_SECRET                             107\n# define KDF_R_MISSING_SEED                               106\n# define KDF_R_UNKNOWN_PARAMETER_TYPE                     103\n# define KDF_R_VALUE_ERROR                                108\n# define KDF_R_VALUE_MISSING                              102\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/lhash.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * Header for dynamic hash table routines Author - Eric Young\n */\n\n#ifndef HEADER_LHASH_H\n# define HEADER_LHASH_H\n\n# include <openssl/e_os2.h>\n# include <openssl/bio.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct lhash_node_st OPENSSL_LH_NODE;\ntypedef int (*OPENSSL_LH_COMPFUNC) (const void *, const void *);\ntypedef unsigned long (*OPENSSL_LH_HASHFUNC) (const void *);\ntypedef void (*OPENSSL_LH_DOALL_FUNC) (void *);\ntypedef void (*OPENSSL_LH_DOALL_FUNCARG) (void *, void *);\ntypedef struct lhash_st OPENSSL_LHASH;\n\n/*\n * Macros for declaring and implementing type-safe wrappers for LHASH\n * callbacks. This way, callbacks can be provided to LHASH structures without\n * function pointer casting and the macro-defined callbacks provide\n * per-variable casting before deferring to the underlying type-specific\n * callbacks. NB: It is possible to place a \"static\" in front of both the\n * DECLARE and IMPLEMENT macros if the functions are strictly internal.\n */\n\n/* First: \"hash\" functions */\n# define DECLARE_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *);\n# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \\\n        unsigned long name##_LHASH_HASH(const void *arg) { \\\n                const o_type *a = arg; \\\n                return name##_hash(a); }\n# define LHASH_HASH_FN(name) name##_LHASH_HASH\n\n/* Second: \"compare\" functions */\n# define DECLARE_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *, const void *);\n# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \\\n        int name##_LHASH_COMP(const void *arg1, const void *arg2) { \\\n                const o_type *a = arg1;             \\\n                const o_type *b = arg2; \\\n                return name##_cmp(a,b); }\n# define LHASH_COMP_FN(name) name##_LHASH_COMP\n\n/* Fourth: \"doall_arg\" functions */\n# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *, void *);\n# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \\\n        void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \\\n                o_type *a = arg1; \\\n                a_type *b = arg2; \\\n                name##_doall_arg(a, b); }\n# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG\n\n\n# define LH_LOAD_MULT    256\n\nint OPENSSL_LH_error(OPENSSL_LHASH *lh);\nOPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c);\nvoid OPENSSL_LH_free(OPENSSL_LHASH *lh);\nvoid *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data);\nvoid *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data);\nvoid *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data);\nvoid OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func);\nvoid OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg);\nunsigned long OPENSSL_LH_strhash(const char *c);\nunsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh);\nunsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh);\nvoid OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load);\n\n# ifndef OPENSSL_NO_STDIO\nvoid OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp);\nvoid OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp);\nvoid OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp);\n# endif\nvoid OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out);\nvoid OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out);\nvoid OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define _LHASH OPENSSL_LHASH\n#  define LHASH_NODE OPENSSL_LH_NODE\n#  define lh_error OPENSSL_LH_error\n#  define lh_new OPENSSL_LH_new\n#  define lh_free OPENSSL_LH_free\n#  define lh_insert OPENSSL_LH_insert\n#  define lh_delete OPENSSL_LH_delete\n#  define lh_retrieve OPENSSL_LH_retrieve\n#  define lh_doall OPENSSL_LH_doall\n#  define lh_doall_arg OPENSSL_LH_doall_arg\n#  define lh_strhash OPENSSL_LH_strhash\n#  define lh_num_items OPENSSL_LH_num_items\n#  ifndef OPENSSL_NO_STDIO\n#   define lh_stats OPENSSL_LH_stats\n#   define lh_node_stats OPENSSL_LH_node_stats\n#   define lh_node_usage_stats OPENSSL_LH_node_usage_stats\n#  endif\n#  define lh_stats_bio OPENSSL_LH_stats_bio\n#  define lh_node_stats_bio OPENSSL_LH_node_stats_bio\n#  define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio\n# endif\n\n/* Type checking... */\n\n# define LHASH_OF(type) struct lhash_st_##type\n\n# define DEFINE_LHASH_OF(type) \\\n    LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \\\n    static ossl_unused ossl_inline LHASH_OF(type) *lh_##type##_new(unsigned long (*hfn)(const type *), \\\n                                                                   int (*cfn)(const type *, const type *)) \\\n    { \\\n        return (LHASH_OF(type) *) \\\n            OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_free(LHASH_OF(type) *lh) \\\n    { \\\n        OPENSSL_LH_free((OPENSSL_LHASH *)lh); \\\n    } \\\n    static ossl_unused ossl_inline type *lh_##type##_insert(LHASH_OF(type) *lh, type *d) \\\n    { \\\n        return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \\\n    } \\\n    static ossl_unused ossl_inline type *lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \\\n    { \\\n        return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \\\n    } \\\n    static ossl_unused ossl_inline type *lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \\\n    { \\\n        return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \\\n    } \\\n    static ossl_unused ossl_inline int lh_##type##_error(LHASH_OF(type) *lh) \\\n    { \\\n        return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \\\n    } \\\n    static ossl_unused ossl_inline unsigned long lh_##type##_num_items(LHASH_OF(type) *lh) \\\n    { \\\n        return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \\\n    { \\\n        OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \\\n    { \\\n        OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \\\n    { \\\n        OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \\\n    } \\\n    static ossl_unused ossl_inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) *lh) \\\n    { \\\n        return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \\\n    { \\\n        OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \\\n    } \\\n    static ossl_unused ossl_inline void lh_##type##_doall(LHASH_OF(type) *lh, \\\n                                                          void (*doall)(type *)) \\\n    { \\\n        OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \\\n    } \\\n    LHASH_OF(type)\n\n#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \\\n    int_implement_lhash_doall(type, argtype, const type)\n\n#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \\\n    int_implement_lhash_doall(type, argtype, type)\n\n#define int_implement_lhash_doall(type, argtype, cbargtype) \\\n    static ossl_unused ossl_inline void \\\n        lh_##type##_doall_##argtype(LHASH_OF(type) *lh, \\\n                                   void (*fn)(cbargtype *, argtype *), \\\n                                   argtype *arg) \\\n    { \\\n        OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); \\\n    } \\\n    LHASH_OF(type)\n\nDEFINE_LHASH_OF(OPENSSL_STRING);\n# ifdef _MSC_VER\n/*\n * push and pop this warning:\n *   warning C4090: 'function': different 'const' qualifiers\n */\n#  pragma warning (push)\n#  pragma warning (disable: 4090)\n# endif\n\nDEFINE_LHASH_OF(OPENSSL_CSTRING);\n\n# ifdef _MSC_VER\n#  pragma warning (pop)\n# endif\n\n/*\n * If called without higher optimization (min. -xO3) the Oracle Developer\n * Studio compiler generates code for the defined (static inline) functions\n * above.\n * This would later lead to the linker complaining about missing symbols when\n * this header file is included but the resulting object is not linked against\n * the Crypto library (openssl#6912).\n */\n# ifdef __SUNPRO_C\n#  pragma weak OPENSSL_LH_new\n#  pragma weak OPENSSL_LH_free\n#  pragma weak OPENSSL_LH_insert\n#  pragma weak OPENSSL_LH_delete\n#  pragma weak OPENSSL_LH_retrieve\n#  pragma weak OPENSSL_LH_error\n#  pragma weak OPENSSL_LH_num_items\n#  pragma weak OPENSSL_LH_node_stats_bio\n#  pragma weak OPENSSL_LH_node_usage_stats_bio\n#  pragma weak OPENSSL_LH_stats_bio\n#  pragma weak OPENSSL_LH_get_down_load\n#  pragma weak OPENSSL_LH_set_down_load\n#  pragma weak OPENSSL_LH_doall\n#  pragma weak OPENSSL_LH_doall_arg\n# endif /* __SUNPRO_C */\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/md2.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MD2_H\n# define HEADER_MD2_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_MD2\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef unsigned char MD2_INT;\n\n# define MD2_DIGEST_LENGTH       16\n# define MD2_BLOCK               16\n\ntypedef struct MD2state_st {\n    unsigned int num;\n    unsigned char data[MD2_BLOCK];\n    MD2_INT cksm[MD2_BLOCK];\n    MD2_INT state[MD2_BLOCK];\n} MD2_CTX;\n\nconst char *MD2_options(void);\nint MD2_Init(MD2_CTX *c);\nint MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len);\nint MD2_Final(unsigned char *md, MD2_CTX *c);\nunsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/md4.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MD4_H\n# define HEADER_MD4_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_MD4\n# include <openssl/e_os2.h>\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD4_LONG has to be at least 32 bits wide.                     !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n# define MD4_LONG unsigned int\n\n# define MD4_CBLOCK      64\n# define MD4_LBLOCK      (MD4_CBLOCK/4)\n# define MD4_DIGEST_LENGTH 16\n\ntypedef struct MD4state_st {\n    MD4_LONG A, B, C, D;\n    MD4_LONG Nl, Nh;\n    MD4_LONG data[MD4_LBLOCK];\n    unsigned int num;\n} MD4_CTX;\n\nint MD4_Init(MD4_CTX *c);\nint MD4_Update(MD4_CTX *c, const void *data, size_t len);\nint MD4_Final(unsigned char *md, MD4_CTX *c);\nunsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD4_Transform(MD4_CTX *c, const unsigned char *b);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/md5.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MD5_H\n# define HEADER_MD5_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_MD5\n# include <openssl/e_os2.h>\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! MD5_LONG has to be at least 32 bits wide.                     !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n# define MD5_LONG unsigned int\n\n# define MD5_CBLOCK      64\n# define MD5_LBLOCK      (MD5_CBLOCK/4)\n# define MD5_DIGEST_LENGTH 16\n\ntypedef struct MD5state_st {\n    MD5_LONG A, B, C, D;\n    MD5_LONG Nl, Nh;\n    MD5_LONG data[MD5_LBLOCK];\n    unsigned int num;\n} MD5_CTX;\n\nint MD5_Init(MD5_CTX *c);\nint MD5_Update(MD5_CTX *c, const void *data, size_t len);\nint MD5_Final(unsigned char *md, MD5_CTX *c);\nunsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md);\nvoid MD5_Transform(MD5_CTX *c, const unsigned char *b);\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/mdc2.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MDC2_H\n# define HEADER_MDC2_H\n\n# include <openssl/opensslconf.h>\n\n#ifndef OPENSSL_NO_MDC2\n# include <stdlib.h>\n# include <openssl/des.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define MDC2_BLOCK              8\n# define MDC2_DIGEST_LENGTH      16\n\ntypedef struct mdc2_ctx_st {\n    unsigned int num;\n    unsigned char data[MDC2_BLOCK];\n    DES_cblock h, hh;\n    int pad_type;               /* either 1 or 2, default 1 */\n} MDC2_CTX;\n\nint MDC2_Init(MDC2_CTX *c);\nint MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len);\nint MDC2_Final(unsigned char *md, MDC2_CTX *c);\nunsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/modes.h",
    "content": "/*\n * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_MODES_H\n# define HEADER_MODES_H\n\n# include <stddef.h>\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\ntypedef void (*block128_f) (const unsigned char in[16],\n                            unsigned char out[16], const void *key);\n\ntypedef void (*cbc128_f) (const unsigned char *in, unsigned char *out,\n                          size_t len, const void *key,\n                          unsigned char ivec[16], int enc);\n\ntypedef void (*ctr128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16]);\n\ntypedef void (*ccm128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          const unsigned char ivec[16],\n                          unsigned char cmac[16]);\n\nvoid CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\nvoid CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], block128_f block);\n\nvoid CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16],\n                           unsigned char ecount_buf[16], unsigned int *num,\n                           block128_f block);\n\nvoid CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16],\n                                 unsigned char ecount_buf[16],\n                                 unsigned int *num, ctr128_f ctr);\n\nvoid CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           block128_f block);\n\nvoid CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                           size_t len, const void *key,\n                           unsigned char ivec[16], int *num,\n                           int enc, block128_f block);\nvoid CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t length, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\nvoid CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t bits, const void *key,\n                             unsigned char ivec[16], int *num,\n                             int enc, block128_f block);\n\nsize_t CRYPTO_cts128_encrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_cts128_decrypt_block(const unsigned char *in,\n                                   unsigned char *out, size_t len,\n                                   const void *key, unsigned char ivec[16],\n                                   block128_f block);\nsize_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,\n                             size_t len, const void *key,\n                             unsigned char ivec[16], cbc128_f cbc);\n\nsize_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\nsize_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in,\n                                       unsigned char *out, size_t len,\n                                       const void *key,\n                                       unsigned char ivec[16],\n                                       block128_f block);\nsize_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,\n                                 size_t len, const void *key,\n                                 unsigned char ivec[16], cbc128_f cbc);\n\ntypedef struct gcm128_context GCM128_CONTEXT;\n\nGCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);\nvoid CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block);\nvoid CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,\n                         size_t len);\nint CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,\n                      size_t len);\nint CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,\n                          const unsigned char *in, unsigned char *out,\n                          size_t len);\nint CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,\n                                const unsigned char *in, unsigned char *out,\n                                size_t len, ctr128_f stream);\nint CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,\n                         size_t len);\nvoid CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\nvoid CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);\n\ntypedef struct ccm128_context CCM128_CONTEXT;\n\nvoid CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,\n                        unsigned int M, unsigned int L, void *key,\n                        block128_f block);\nint CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,\n                        size_t nlen, size_t mlen);\nvoid CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,\n                       size_t alen);\nint CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                          unsigned char *out, size_t len);\nint CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nint CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,\n                                unsigned char *out, size_t len,\n                                ccm128_f stream);\nsize_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);\n\ntypedef struct xts128_context XTS128_CONTEXT;\n\nint CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,\n                          const unsigned char iv[16],\n                          const unsigned char *inp, unsigned char *out,\n                          size_t len, int enc);\n\nsize_t CRYPTO_128_wrap(void *key, const unsigned char *iv,\n                       unsigned char *out,\n                       const unsigned char *in, size_t inlen,\n                       block128_f block);\n\nsize_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,\n                         unsigned char *out,\n                         const unsigned char *in, size_t inlen,\n                         block128_f block);\nsize_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv,\n                           unsigned char *out, const unsigned char *in,\n                           size_t inlen, block128_f block);\nsize_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv,\n                             unsigned char *out, const unsigned char *in,\n                             size_t inlen, block128_f block);\n\n# ifndef OPENSSL_NO_OCB\ntypedef struct ocb128_context OCB128_CONTEXT;\n\ntypedef void (*ocb128_f) (const unsigned char *in, unsigned char *out,\n                          size_t blocks, const void *key,\n                          size_t start_block_num,\n                          unsigned char offset_i[16],\n                          const unsigned char L_[][16],\n                          unsigned char checksum[16]);\n\nOCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec,\n                                  block128_f encrypt, block128_f decrypt,\n                                  ocb128_f stream);\nint CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec,\n                       block128_f encrypt, block128_f decrypt,\n                       ocb128_f stream);\nint CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src,\n                           void *keyenc, void *keydec);\nint CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,\n                        size_t len, size_t taglen);\nint CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad,\n                      size_t len);\nint CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in,\n                          unsigned char *out, size_t len);\nint CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in,\n                          unsigned char *out, size_t len);\nint CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag,\n                         size_t len);\nint CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len);\nvoid CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx);\n# endif                          /* OPENSSL_NO_OCB */\n\n# ifdef  __cplusplus\n}\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/obj_mac.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by crypto/objects/objects.pl\n *\n * Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#define SN_undef                        \"UNDEF\"\n#define LN_undef                        \"undefined\"\n#define NID_undef                       0\n#define OBJ_undef                       0L\n\n#define SN_itu_t                \"ITU-T\"\n#define LN_itu_t                \"itu-t\"\n#define NID_itu_t               645\n#define OBJ_itu_t               0L\n\n#define NID_ccitt               404\n#define OBJ_ccitt               OBJ_itu_t\n\n#define SN_iso          \"ISO\"\n#define LN_iso          \"iso\"\n#define NID_iso         181\n#define OBJ_iso         1L\n\n#define SN_joint_iso_itu_t              \"JOINT-ISO-ITU-T\"\n#define LN_joint_iso_itu_t              \"joint-iso-itu-t\"\n#define NID_joint_iso_itu_t             646\n#define OBJ_joint_iso_itu_t             2L\n\n#define NID_joint_iso_ccitt             393\n#define OBJ_joint_iso_ccitt             OBJ_joint_iso_itu_t\n\n#define SN_member_body          \"member-body\"\n#define LN_member_body          \"ISO Member Body\"\n#define NID_member_body         182\n#define OBJ_member_body         OBJ_iso,2L\n\n#define SN_identified_organization              \"identified-organization\"\n#define NID_identified_organization             676\n#define OBJ_identified_organization             OBJ_iso,3L\n\n#define SN_hmac_md5             \"HMAC-MD5\"\n#define LN_hmac_md5             \"hmac-md5\"\n#define NID_hmac_md5            780\n#define OBJ_hmac_md5            OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L\n\n#define SN_hmac_sha1            \"HMAC-SHA1\"\n#define LN_hmac_sha1            \"hmac-sha1\"\n#define NID_hmac_sha1           781\n#define OBJ_hmac_sha1           OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L\n\n#define SN_x509ExtAdmission             \"x509ExtAdmission\"\n#define LN_x509ExtAdmission             \"Professional Information or basis for Admission\"\n#define NID_x509ExtAdmission            1093\n#define OBJ_x509ExtAdmission            OBJ_identified_organization,36L,8L,3L,3L\n\n#define SN_certicom_arc         \"certicom-arc\"\n#define NID_certicom_arc                677\n#define OBJ_certicom_arc                OBJ_identified_organization,132L\n\n#define SN_ieee         \"ieee\"\n#define NID_ieee                1170\n#define OBJ_ieee                OBJ_identified_organization,111L\n\n#define SN_ieee_siswg           \"ieee-siswg\"\n#define LN_ieee_siswg           \"IEEE Security in Storage Working Group\"\n#define NID_ieee_siswg          1171\n#define OBJ_ieee_siswg          OBJ_ieee,2L,1619L\n\n#define SN_international_organizations          \"international-organizations\"\n#define LN_international_organizations          \"International Organizations\"\n#define NID_international_organizations         647\n#define OBJ_international_organizations         OBJ_joint_iso_itu_t,23L\n\n#define SN_wap          \"wap\"\n#define NID_wap         678\n#define OBJ_wap         OBJ_international_organizations,43L\n\n#define SN_wap_wsg              \"wap-wsg\"\n#define NID_wap_wsg             679\n#define OBJ_wap_wsg             OBJ_wap,1L\n\n#define SN_selected_attribute_types             \"selected-attribute-types\"\n#define LN_selected_attribute_types             \"Selected Attribute Types\"\n#define NID_selected_attribute_types            394\n#define OBJ_selected_attribute_types            OBJ_joint_iso_itu_t,5L,1L,5L\n\n#define SN_clearance            \"clearance\"\n#define NID_clearance           395\n#define OBJ_clearance           OBJ_selected_attribute_types,55L\n\n#define SN_ISO_US               \"ISO-US\"\n#define LN_ISO_US               \"ISO US Member Body\"\n#define NID_ISO_US              183\n#define OBJ_ISO_US              OBJ_member_body,840L\n\n#define SN_X9_57                \"X9-57\"\n#define LN_X9_57                \"X9.57\"\n#define NID_X9_57               184\n#define OBJ_X9_57               OBJ_ISO_US,10040L\n\n#define SN_X9cm         \"X9cm\"\n#define LN_X9cm         \"X9.57 CM ?\"\n#define NID_X9cm                185\n#define OBJ_X9cm                OBJ_X9_57,4L\n\n#define SN_ISO_CN               \"ISO-CN\"\n#define LN_ISO_CN               \"ISO CN Member Body\"\n#define NID_ISO_CN              1140\n#define OBJ_ISO_CN              OBJ_member_body,156L\n\n#define SN_oscca                \"oscca\"\n#define NID_oscca               1141\n#define OBJ_oscca               OBJ_ISO_CN,10197L\n\n#define SN_sm_scheme            \"sm-scheme\"\n#define NID_sm_scheme           1142\n#define OBJ_sm_scheme           OBJ_oscca,1L\n\n#define SN_dsa          \"DSA\"\n#define LN_dsa          \"dsaEncryption\"\n#define NID_dsa         116\n#define OBJ_dsa         OBJ_X9cm,1L\n\n#define SN_dsaWithSHA1          \"DSA-SHA1\"\n#define LN_dsaWithSHA1          \"dsaWithSHA1\"\n#define NID_dsaWithSHA1         113\n#define OBJ_dsaWithSHA1         OBJ_X9cm,3L\n\n#define SN_ansi_X9_62           \"ansi-X9-62\"\n#define LN_ansi_X9_62           \"ANSI X9.62\"\n#define NID_ansi_X9_62          405\n#define OBJ_ansi_X9_62          OBJ_ISO_US,10045L\n\n#define OBJ_X9_62_id_fieldType          OBJ_ansi_X9_62,1L\n\n#define SN_X9_62_prime_field            \"prime-field\"\n#define NID_X9_62_prime_field           406\n#define OBJ_X9_62_prime_field           OBJ_X9_62_id_fieldType,1L\n\n#define SN_X9_62_characteristic_two_field               \"characteristic-two-field\"\n#define NID_X9_62_characteristic_two_field              407\n#define OBJ_X9_62_characteristic_two_field              OBJ_X9_62_id_fieldType,2L\n\n#define SN_X9_62_id_characteristic_two_basis            \"id-characteristic-two-basis\"\n#define NID_X9_62_id_characteristic_two_basis           680\n#define OBJ_X9_62_id_characteristic_two_basis           OBJ_X9_62_characteristic_two_field,3L\n\n#define SN_X9_62_onBasis                \"onBasis\"\n#define NID_X9_62_onBasis               681\n#define OBJ_X9_62_onBasis               OBJ_X9_62_id_characteristic_two_basis,1L\n\n#define SN_X9_62_tpBasis                \"tpBasis\"\n#define NID_X9_62_tpBasis               682\n#define OBJ_X9_62_tpBasis               OBJ_X9_62_id_characteristic_two_basis,2L\n\n#define SN_X9_62_ppBasis                \"ppBasis\"\n#define NID_X9_62_ppBasis               683\n#define OBJ_X9_62_ppBasis               OBJ_X9_62_id_characteristic_two_basis,3L\n\n#define OBJ_X9_62_id_publicKeyType              OBJ_ansi_X9_62,2L\n\n#define SN_X9_62_id_ecPublicKey         \"id-ecPublicKey\"\n#define NID_X9_62_id_ecPublicKey                408\n#define OBJ_X9_62_id_ecPublicKey                OBJ_X9_62_id_publicKeyType,1L\n\n#define OBJ_X9_62_ellipticCurve         OBJ_ansi_X9_62,3L\n\n#define OBJ_X9_62_c_TwoCurve            OBJ_X9_62_ellipticCurve,0L\n\n#define SN_X9_62_c2pnb163v1             \"c2pnb163v1\"\n#define NID_X9_62_c2pnb163v1            684\n#define OBJ_X9_62_c2pnb163v1            OBJ_X9_62_c_TwoCurve,1L\n\n#define SN_X9_62_c2pnb163v2             \"c2pnb163v2\"\n#define NID_X9_62_c2pnb163v2            685\n#define OBJ_X9_62_c2pnb163v2            OBJ_X9_62_c_TwoCurve,2L\n\n#define SN_X9_62_c2pnb163v3             \"c2pnb163v3\"\n#define NID_X9_62_c2pnb163v3            686\n#define OBJ_X9_62_c2pnb163v3            OBJ_X9_62_c_TwoCurve,3L\n\n#define SN_X9_62_c2pnb176v1             \"c2pnb176v1\"\n#define NID_X9_62_c2pnb176v1            687\n#define OBJ_X9_62_c2pnb176v1            OBJ_X9_62_c_TwoCurve,4L\n\n#define SN_X9_62_c2tnb191v1             \"c2tnb191v1\"\n#define NID_X9_62_c2tnb191v1            688\n#define OBJ_X9_62_c2tnb191v1            OBJ_X9_62_c_TwoCurve,5L\n\n#define SN_X9_62_c2tnb191v2             \"c2tnb191v2\"\n#define NID_X9_62_c2tnb191v2            689\n#define OBJ_X9_62_c2tnb191v2            OBJ_X9_62_c_TwoCurve,6L\n\n#define SN_X9_62_c2tnb191v3             \"c2tnb191v3\"\n#define NID_X9_62_c2tnb191v3            690\n#define OBJ_X9_62_c2tnb191v3            OBJ_X9_62_c_TwoCurve,7L\n\n#define SN_X9_62_c2onb191v4             \"c2onb191v4\"\n#define NID_X9_62_c2onb191v4            691\n#define OBJ_X9_62_c2onb191v4            OBJ_X9_62_c_TwoCurve,8L\n\n#define SN_X9_62_c2onb191v5             \"c2onb191v5\"\n#define NID_X9_62_c2onb191v5            692\n#define OBJ_X9_62_c2onb191v5            OBJ_X9_62_c_TwoCurve,9L\n\n#define SN_X9_62_c2pnb208w1             \"c2pnb208w1\"\n#define NID_X9_62_c2pnb208w1            693\n#define OBJ_X9_62_c2pnb208w1            OBJ_X9_62_c_TwoCurve,10L\n\n#define SN_X9_62_c2tnb239v1             \"c2tnb239v1\"\n#define NID_X9_62_c2tnb239v1            694\n#define OBJ_X9_62_c2tnb239v1            OBJ_X9_62_c_TwoCurve,11L\n\n#define SN_X9_62_c2tnb239v2             \"c2tnb239v2\"\n#define NID_X9_62_c2tnb239v2            695\n#define OBJ_X9_62_c2tnb239v2            OBJ_X9_62_c_TwoCurve,12L\n\n#define SN_X9_62_c2tnb239v3             \"c2tnb239v3\"\n#define NID_X9_62_c2tnb239v3            696\n#define OBJ_X9_62_c2tnb239v3            OBJ_X9_62_c_TwoCurve,13L\n\n#define SN_X9_62_c2onb239v4             \"c2onb239v4\"\n#define NID_X9_62_c2onb239v4            697\n#define OBJ_X9_62_c2onb239v4            OBJ_X9_62_c_TwoCurve,14L\n\n#define SN_X9_62_c2onb239v5             \"c2onb239v5\"\n#define NID_X9_62_c2onb239v5            698\n#define OBJ_X9_62_c2onb239v5            OBJ_X9_62_c_TwoCurve,15L\n\n#define SN_X9_62_c2pnb272w1             \"c2pnb272w1\"\n#define NID_X9_62_c2pnb272w1            699\n#define OBJ_X9_62_c2pnb272w1            OBJ_X9_62_c_TwoCurve,16L\n\n#define SN_X9_62_c2pnb304w1             \"c2pnb304w1\"\n#define NID_X9_62_c2pnb304w1            700\n#define OBJ_X9_62_c2pnb304w1            OBJ_X9_62_c_TwoCurve,17L\n\n#define SN_X9_62_c2tnb359v1             \"c2tnb359v1\"\n#define NID_X9_62_c2tnb359v1            701\n#define OBJ_X9_62_c2tnb359v1            OBJ_X9_62_c_TwoCurve,18L\n\n#define SN_X9_62_c2pnb368w1             \"c2pnb368w1\"\n#define NID_X9_62_c2pnb368w1            702\n#define OBJ_X9_62_c2pnb368w1            OBJ_X9_62_c_TwoCurve,19L\n\n#define SN_X9_62_c2tnb431r1             \"c2tnb431r1\"\n#define NID_X9_62_c2tnb431r1            703\n#define OBJ_X9_62_c2tnb431r1            OBJ_X9_62_c_TwoCurve,20L\n\n#define OBJ_X9_62_primeCurve            OBJ_X9_62_ellipticCurve,1L\n\n#define SN_X9_62_prime192v1             \"prime192v1\"\n#define NID_X9_62_prime192v1            409\n#define OBJ_X9_62_prime192v1            OBJ_X9_62_primeCurve,1L\n\n#define SN_X9_62_prime192v2             \"prime192v2\"\n#define NID_X9_62_prime192v2            410\n#define OBJ_X9_62_prime192v2            OBJ_X9_62_primeCurve,2L\n\n#define SN_X9_62_prime192v3             \"prime192v3\"\n#define NID_X9_62_prime192v3            411\n#define OBJ_X9_62_prime192v3            OBJ_X9_62_primeCurve,3L\n\n#define SN_X9_62_prime239v1             \"prime239v1\"\n#define NID_X9_62_prime239v1            412\n#define OBJ_X9_62_prime239v1            OBJ_X9_62_primeCurve,4L\n\n#define SN_X9_62_prime239v2             \"prime239v2\"\n#define NID_X9_62_prime239v2            413\n#define OBJ_X9_62_prime239v2            OBJ_X9_62_primeCurve,5L\n\n#define SN_X9_62_prime239v3             \"prime239v3\"\n#define NID_X9_62_prime239v3            414\n#define OBJ_X9_62_prime239v3            OBJ_X9_62_primeCurve,6L\n\n#define SN_X9_62_prime256v1             \"prime256v1\"\n#define NID_X9_62_prime256v1            415\n#define OBJ_X9_62_prime256v1            OBJ_X9_62_primeCurve,7L\n\n#define OBJ_X9_62_id_ecSigType          OBJ_ansi_X9_62,4L\n\n#define SN_ecdsa_with_SHA1              \"ecdsa-with-SHA1\"\n#define NID_ecdsa_with_SHA1             416\n#define OBJ_ecdsa_with_SHA1             OBJ_X9_62_id_ecSigType,1L\n\n#define SN_ecdsa_with_Recommended               \"ecdsa-with-Recommended\"\n#define NID_ecdsa_with_Recommended              791\n#define OBJ_ecdsa_with_Recommended              OBJ_X9_62_id_ecSigType,2L\n\n#define SN_ecdsa_with_Specified         \"ecdsa-with-Specified\"\n#define NID_ecdsa_with_Specified                792\n#define OBJ_ecdsa_with_Specified                OBJ_X9_62_id_ecSigType,3L\n\n#define SN_ecdsa_with_SHA224            \"ecdsa-with-SHA224\"\n#define NID_ecdsa_with_SHA224           793\n#define OBJ_ecdsa_with_SHA224           OBJ_ecdsa_with_Specified,1L\n\n#define SN_ecdsa_with_SHA256            \"ecdsa-with-SHA256\"\n#define NID_ecdsa_with_SHA256           794\n#define OBJ_ecdsa_with_SHA256           OBJ_ecdsa_with_Specified,2L\n\n#define SN_ecdsa_with_SHA384            \"ecdsa-with-SHA384\"\n#define NID_ecdsa_with_SHA384           795\n#define OBJ_ecdsa_with_SHA384           OBJ_ecdsa_with_Specified,3L\n\n#define SN_ecdsa_with_SHA512            \"ecdsa-with-SHA512\"\n#define NID_ecdsa_with_SHA512           796\n#define OBJ_ecdsa_with_SHA512           OBJ_ecdsa_with_Specified,4L\n\n#define OBJ_secg_ellipticCurve          OBJ_certicom_arc,0L\n\n#define SN_secp112r1            \"secp112r1\"\n#define NID_secp112r1           704\n#define OBJ_secp112r1           OBJ_secg_ellipticCurve,6L\n\n#define SN_secp112r2            \"secp112r2\"\n#define NID_secp112r2           705\n#define OBJ_secp112r2           OBJ_secg_ellipticCurve,7L\n\n#define SN_secp128r1            \"secp128r1\"\n#define NID_secp128r1           706\n#define OBJ_secp128r1           OBJ_secg_ellipticCurve,28L\n\n#define SN_secp128r2            \"secp128r2\"\n#define NID_secp128r2           707\n#define OBJ_secp128r2           OBJ_secg_ellipticCurve,29L\n\n#define SN_secp160k1            \"secp160k1\"\n#define NID_secp160k1           708\n#define OBJ_secp160k1           OBJ_secg_ellipticCurve,9L\n\n#define SN_secp160r1            \"secp160r1\"\n#define NID_secp160r1           709\n#define OBJ_secp160r1           OBJ_secg_ellipticCurve,8L\n\n#define SN_secp160r2            \"secp160r2\"\n#define NID_secp160r2           710\n#define OBJ_secp160r2           OBJ_secg_ellipticCurve,30L\n\n#define SN_secp192k1            \"secp192k1\"\n#define NID_secp192k1           711\n#define OBJ_secp192k1           OBJ_secg_ellipticCurve,31L\n\n#define SN_secp224k1            \"secp224k1\"\n#define NID_secp224k1           712\n#define OBJ_secp224k1           OBJ_secg_ellipticCurve,32L\n\n#define SN_secp224r1            \"secp224r1\"\n#define NID_secp224r1           713\n#define OBJ_secp224r1           OBJ_secg_ellipticCurve,33L\n\n#define SN_secp256k1            \"secp256k1\"\n#define NID_secp256k1           714\n#define OBJ_secp256k1           OBJ_secg_ellipticCurve,10L\n\n#define SN_secp384r1            \"secp384r1\"\n#define NID_secp384r1           715\n#define OBJ_secp384r1           OBJ_secg_ellipticCurve,34L\n\n#define SN_secp521r1            \"secp521r1\"\n#define NID_secp521r1           716\n#define OBJ_secp521r1           OBJ_secg_ellipticCurve,35L\n\n#define SN_sect113r1            \"sect113r1\"\n#define NID_sect113r1           717\n#define OBJ_sect113r1           OBJ_secg_ellipticCurve,4L\n\n#define SN_sect113r2            \"sect113r2\"\n#define NID_sect113r2           718\n#define OBJ_sect113r2           OBJ_secg_ellipticCurve,5L\n\n#define SN_sect131r1            \"sect131r1\"\n#define NID_sect131r1           719\n#define OBJ_sect131r1           OBJ_secg_ellipticCurve,22L\n\n#define SN_sect131r2            \"sect131r2\"\n#define NID_sect131r2           720\n#define OBJ_sect131r2           OBJ_secg_ellipticCurve,23L\n\n#define SN_sect163k1            \"sect163k1\"\n#define NID_sect163k1           721\n#define OBJ_sect163k1           OBJ_secg_ellipticCurve,1L\n\n#define SN_sect163r1            \"sect163r1\"\n#define NID_sect163r1           722\n#define OBJ_sect163r1           OBJ_secg_ellipticCurve,2L\n\n#define SN_sect163r2            \"sect163r2\"\n#define NID_sect163r2           723\n#define OBJ_sect163r2           OBJ_secg_ellipticCurve,15L\n\n#define SN_sect193r1            \"sect193r1\"\n#define NID_sect193r1           724\n#define OBJ_sect193r1           OBJ_secg_ellipticCurve,24L\n\n#define SN_sect193r2            \"sect193r2\"\n#define NID_sect193r2           725\n#define OBJ_sect193r2           OBJ_secg_ellipticCurve,25L\n\n#define SN_sect233k1            \"sect233k1\"\n#define NID_sect233k1           726\n#define OBJ_sect233k1           OBJ_secg_ellipticCurve,26L\n\n#define SN_sect233r1            \"sect233r1\"\n#define NID_sect233r1           727\n#define OBJ_sect233r1           OBJ_secg_ellipticCurve,27L\n\n#define SN_sect239k1            \"sect239k1\"\n#define NID_sect239k1           728\n#define OBJ_sect239k1           OBJ_secg_ellipticCurve,3L\n\n#define SN_sect283k1            \"sect283k1\"\n#define NID_sect283k1           729\n#define OBJ_sect283k1           OBJ_secg_ellipticCurve,16L\n\n#define SN_sect283r1            \"sect283r1\"\n#define NID_sect283r1           730\n#define OBJ_sect283r1           OBJ_secg_ellipticCurve,17L\n\n#define SN_sect409k1            \"sect409k1\"\n#define NID_sect409k1           731\n#define OBJ_sect409k1           OBJ_secg_ellipticCurve,36L\n\n#define SN_sect409r1            \"sect409r1\"\n#define NID_sect409r1           732\n#define OBJ_sect409r1           OBJ_secg_ellipticCurve,37L\n\n#define SN_sect571k1            \"sect571k1\"\n#define NID_sect571k1           733\n#define OBJ_sect571k1           OBJ_secg_ellipticCurve,38L\n\n#define SN_sect571r1            \"sect571r1\"\n#define NID_sect571r1           734\n#define OBJ_sect571r1           OBJ_secg_ellipticCurve,39L\n\n#define OBJ_wap_wsg_idm_ecid            OBJ_wap_wsg,4L\n\n#define SN_wap_wsg_idm_ecid_wtls1               \"wap-wsg-idm-ecid-wtls1\"\n#define NID_wap_wsg_idm_ecid_wtls1              735\n#define OBJ_wap_wsg_idm_ecid_wtls1              OBJ_wap_wsg_idm_ecid,1L\n\n#define SN_wap_wsg_idm_ecid_wtls3               \"wap-wsg-idm-ecid-wtls3\"\n#define NID_wap_wsg_idm_ecid_wtls3              736\n#define OBJ_wap_wsg_idm_ecid_wtls3              OBJ_wap_wsg_idm_ecid,3L\n\n#define SN_wap_wsg_idm_ecid_wtls4               \"wap-wsg-idm-ecid-wtls4\"\n#define NID_wap_wsg_idm_ecid_wtls4              737\n#define OBJ_wap_wsg_idm_ecid_wtls4              OBJ_wap_wsg_idm_ecid,4L\n\n#define SN_wap_wsg_idm_ecid_wtls5               \"wap-wsg-idm-ecid-wtls5\"\n#define NID_wap_wsg_idm_ecid_wtls5              738\n#define OBJ_wap_wsg_idm_ecid_wtls5              OBJ_wap_wsg_idm_ecid,5L\n\n#define SN_wap_wsg_idm_ecid_wtls6               \"wap-wsg-idm-ecid-wtls6\"\n#define NID_wap_wsg_idm_ecid_wtls6              739\n#define OBJ_wap_wsg_idm_ecid_wtls6              OBJ_wap_wsg_idm_ecid,6L\n\n#define SN_wap_wsg_idm_ecid_wtls7               \"wap-wsg-idm-ecid-wtls7\"\n#define NID_wap_wsg_idm_ecid_wtls7              740\n#define OBJ_wap_wsg_idm_ecid_wtls7              OBJ_wap_wsg_idm_ecid,7L\n\n#define SN_wap_wsg_idm_ecid_wtls8               \"wap-wsg-idm-ecid-wtls8\"\n#define NID_wap_wsg_idm_ecid_wtls8              741\n#define OBJ_wap_wsg_idm_ecid_wtls8              OBJ_wap_wsg_idm_ecid,8L\n\n#define SN_wap_wsg_idm_ecid_wtls9               \"wap-wsg-idm-ecid-wtls9\"\n#define NID_wap_wsg_idm_ecid_wtls9              742\n#define OBJ_wap_wsg_idm_ecid_wtls9              OBJ_wap_wsg_idm_ecid,9L\n\n#define SN_wap_wsg_idm_ecid_wtls10              \"wap-wsg-idm-ecid-wtls10\"\n#define NID_wap_wsg_idm_ecid_wtls10             743\n#define OBJ_wap_wsg_idm_ecid_wtls10             OBJ_wap_wsg_idm_ecid,10L\n\n#define SN_wap_wsg_idm_ecid_wtls11              \"wap-wsg-idm-ecid-wtls11\"\n#define NID_wap_wsg_idm_ecid_wtls11             744\n#define OBJ_wap_wsg_idm_ecid_wtls11             OBJ_wap_wsg_idm_ecid,11L\n\n#define SN_wap_wsg_idm_ecid_wtls12              \"wap-wsg-idm-ecid-wtls12\"\n#define NID_wap_wsg_idm_ecid_wtls12             745\n#define OBJ_wap_wsg_idm_ecid_wtls12             OBJ_wap_wsg_idm_ecid,12L\n\n#define SN_cast5_cbc            \"CAST5-CBC\"\n#define LN_cast5_cbc            \"cast5-cbc\"\n#define NID_cast5_cbc           108\n#define OBJ_cast5_cbc           OBJ_ISO_US,113533L,7L,66L,10L\n\n#define SN_cast5_ecb            \"CAST5-ECB\"\n#define LN_cast5_ecb            \"cast5-ecb\"\n#define NID_cast5_ecb           109\n\n#define SN_cast5_cfb64          \"CAST5-CFB\"\n#define LN_cast5_cfb64          \"cast5-cfb\"\n#define NID_cast5_cfb64         110\n\n#define SN_cast5_ofb64          \"CAST5-OFB\"\n#define LN_cast5_ofb64          \"cast5-ofb\"\n#define NID_cast5_ofb64         111\n\n#define LN_pbeWithMD5AndCast5_CBC               \"pbeWithMD5AndCast5CBC\"\n#define NID_pbeWithMD5AndCast5_CBC              112\n#define OBJ_pbeWithMD5AndCast5_CBC              OBJ_ISO_US,113533L,7L,66L,12L\n\n#define SN_id_PasswordBasedMAC          \"id-PasswordBasedMAC\"\n#define LN_id_PasswordBasedMAC          \"password based MAC\"\n#define NID_id_PasswordBasedMAC         782\n#define OBJ_id_PasswordBasedMAC         OBJ_ISO_US,113533L,7L,66L,13L\n\n#define SN_id_DHBasedMac                \"id-DHBasedMac\"\n#define LN_id_DHBasedMac                \"Diffie-Hellman based MAC\"\n#define NID_id_DHBasedMac               783\n#define OBJ_id_DHBasedMac               OBJ_ISO_US,113533L,7L,66L,30L\n\n#define SN_rsadsi               \"rsadsi\"\n#define LN_rsadsi               \"RSA Data Security, Inc.\"\n#define NID_rsadsi              1\n#define OBJ_rsadsi              OBJ_ISO_US,113549L\n\n#define SN_pkcs         \"pkcs\"\n#define LN_pkcs         \"RSA Data Security, Inc. PKCS\"\n#define NID_pkcs                2\n#define OBJ_pkcs                OBJ_rsadsi,1L\n\n#define SN_pkcs1                \"pkcs1\"\n#define NID_pkcs1               186\n#define OBJ_pkcs1               OBJ_pkcs,1L\n\n#define LN_rsaEncryption                \"rsaEncryption\"\n#define NID_rsaEncryption               6\n#define OBJ_rsaEncryption               OBJ_pkcs1,1L\n\n#define SN_md2WithRSAEncryption         \"RSA-MD2\"\n#define LN_md2WithRSAEncryption         \"md2WithRSAEncryption\"\n#define NID_md2WithRSAEncryption                7\n#define OBJ_md2WithRSAEncryption                OBJ_pkcs1,2L\n\n#define SN_md4WithRSAEncryption         \"RSA-MD4\"\n#define LN_md4WithRSAEncryption         \"md4WithRSAEncryption\"\n#define NID_md4WithRSAEncryption                396\n#define OBJ_md4WithRSAEncryption                OBJ_pkcs1,3L\n\n#define SN_md5WithRSAEncryption         \"RSA-MD5\"\n#define LN_md5WithRSAEncryption         \"md5WithRSAEncryption\"\n#define NID_md5WithRSAEncryption                8\n#define OBJ_md5WithRSAEncryption                OBJ_pkcs1,4L\n\n#define SN_sha1WithRSAEncryption                \"RSA-SHA1\"\n#define LN_sha1WithRSAEncryption                \"sha1WithRSAEncryption\"\n#define NID_sha1WithRSAEncryption               65\n#define OBJ_sha1WithRSAEncryption               OBJ_pkcs1,5L\n\n#define SN_rsaesOaep            \"RSAES-OAEP\"\n#define LN_rsaesOaep            \"rsaesOaep\"\n#define NID_rsaesOaep           919\n#define OBJ_rsaesOaep           OBJ_pkcs1,7L\n\n#define SN_mgf1         \"MGF1\"\n#define LN_mgf1         \"mgf1\"\n#define NID_mgf1                911\n#define OBJ_mgf1                OBJ_pkcs1,8L\n\n#define SN_pSpecified           \"PSPECIFIED\"\n#define LN_pSpecified           \"pSpecified\"\n#define NID_pSpecified          935\n#define OBJ_pSpecified          OBJ_pkcs1,9L\n\n#define SN_rsassaPss            \"RSASSA-PSS\"\n#define LN_rsassaPss            \"rsassaPss\"\n#define NID_rsassaPss           912\n#define OBJ_rsassaPss           OBJ_pkcs1,10L\n\n#define SN_sha256WithRSAEncryption              \"RSA-SHA256\"\n#define LN_sha256WithRSAEncryption              \"sha256WithRSAEncryption\"\n#define NID_sha256WithRSAEncryption             668\n#define OBJ_sha256WithRSAEncryption             OBJ_pkcs1,11L\n\n#define SN_sha384WithRSAEncryption              \"RSA-SHA384\"\n#define LN_sha384WithRSAEncryption              \"sha384WithRSAEncryption\"\n#define NID_sha384WithRSAEncryption             669\n#define OBJ_sha384WithRSAEncryption             OBJ_pkcs1,12L\n\n#define SN_sha512WithRSAEncryption              \"RSA-SHA512\"\n#define LN_sha512WithRSAEncryption              \"sha512WithRSAEncryption\"\n#define NID_sha512WithRSAEncryption             670\n#define OBJ_sha512WithRSAEncryption             OBJ_pkcs1,13L\n\n#define SN_sha224WithRSAEncryption              \"RSA-SHA224\"\n#define LN_sha224WithRSAEncryption              \"sha224WithRSAEncryption\"\n#define NID_sha224WithRSAEncryption             671\n#define OBJ_sha224WithRSAEncryption             OBJ_pkcs1,14L\n\n#define SN_sha512_224WithRSAEncryption          \"RSA-SHA512/224\"\n#define LN_sha512_224WithRSAEncryption          \"sha512-224WithRSAEncryption\"\n#define NID_sha512_224WithRSAEncryption         1145\n#define OBJ_sha512_224WithRSAEncryption         OBJ_pkcs1,15L\n\n#define SN_sha512_256WithRSAEncryption          \"RSA-SHA512/256\"\n#define LN_sha512_256WithRSAEncryption          \"sha512-256WithRSAEncryption\"\n#define NID_sha512_256WithRSAEncryption         1146\n#define OBJ_sha512_256WithRSAEncryption         OBJ_pkcs1,16L\n\n#define SN_pkcs3                \"pkcs3\"\n#define NID_pkcs3               27\n#define OBJ_pkcs3               OBJ_pkcs,3L\n\n#define LN_dhKeyAgreement               \"dhKeyAgreement\"\n#define NID_dhKeyAgreement              28\n#define OBJ_dhKeyAgreement              OBJ_pkcs3,1L\n\n#define SN_pkcs5                \"pkcs5\"\n#define NID_pkcs5               187\n#define OBJ_pkcs5               OBJ_pkcs,5L\n\n#define SN_pbeWithMD2AndDES_CBC         \"PBE-MD2-DES\"\n#define LN_pbeWithMD2AndDES_CBC         \"pbeWithMD2AndDES-CBC\"\n#define NID_pbeWithMD2AndDES_CBC                9\n#define OBJ_pbeWithMD2AndDES_CBC                OBJ_pkcs5,1L\n\n#define SN_pbeWithMD5AndDES_CBC         \"PBE-MD5-DES\"\n#define LN_pbeWithMD5AndDES_CBC         \"pbeWithMD5AndDES-CBC\"\n#define NID_pbeWithMD5AndDES_CBC                10\n#define OBJ_pbeWithMD5AndDES_CBC                OBJ_pkcs5,3L\n\n#define SN_pbeWithMD2AndRC2_CBC         \"PBE-MD2-RC2-64\"\n#define LN_pbeWithMD2AndRC2_CBC         \"pbeWithMD2AndRC2-CBC\"\n#define NID_pbeWithMD2AndRC2_CBC                168\n#define OBJ_pbeWithMD2AndRC2_CBC                OBJ_pkcs5,4L\n\n#define SN_pbeWithMD5AndRC2_CBC         \"PBE-MD5-RC2-64\"\n#define LN_pbeWithMD5AndRC2_CBC         \"pbeWithMD5AndRC2-CBC\"\n#define NID_pbeWithMD5AndRC2_CBC                169\n#define OBJ_pbeWithMD5AndRC2_CBC                OBJ_pkcs5,6L\n\n#define SN_pbeWithSHA1AndDES_CBC                \"PBE-SHA1-DES\"\n#define LN_pbeWithSHA1AndDES_CBC                \"pbeWithSHA1AndDES-CBC\"\n#define NID_pbeWithSHA1AndDES_CBC               170\n#define OBJ_pbeWithSHA1AndDES_CBC               OBJ_pkcs5,10L\n\n#define SN_pbeWithSHA1AndRC2_CBC                \"PBE-SHA1-RC2-64\"\n#define LN_pbeWithSHA1AndRC2_CBC                \"pbeWithSHA1AndRC2-CBC\"\n#define NID_pbeWithSHA1AndRC2_CBC               68\n#define OBJ_pbeWithSHA1AndRC2_CBC               OBJ_pkcs5,11L\n\n#define LN_id_pbkdf2            \"PBKDF2\"\n#define NID_id_pbkdf2           69\n#define OBJ_id_pbkdf2           OBJ_pkcs5,12L\n\n#define LN_pbes2                \"PBES2\"\n#define NID_pbes2               161\n#define OBJ_pbes2               OBJ_pkcs5,13L\n\n#define LN_pbmac1               \"PBMAC1\"\n#define NID_pbmac1              162\n#define OBJ_pbmac1              OBJ_pkcs5,14L\n\n#define SN_pkcs7                \"pkcs7\"\n#define NID_pkcs7               20\n#define OBJ_pkcs7               OBJ_pkcs,7L\n\n#define LN_pkcs7_data           \"pkcs7-data\"\n#define NID_pkcs7_data          21\n#define OBJ_pkcs7_data          OBJ_pkcs7,1L\n\n#define LN_pkcs7_signed         \"pkcs7-signedData\"\n#define NID_pkcs7_signed                22\n#define OBJ_pkcs7_signed                OBJ_pkcs7,2L\n\n#define LN_pkcs7_enveloped              \"pkcs7-envelopedData\"\n#define NID_pkcs7_enveloped             23\n#define OBJ_pkcs7_enveloped             OBJ_pkcs7,3L\n\n#define LN_pkcs7_signedAndEnveloped             \"pkcs7-signedAndEnvelopedData\"\n#define NID_pkcs7_signedAndEnveloped            24\n#define OBJ_pkcs7_signedAndEnveloped            OBJ_pkcs7,4L\n\n#define LN_pkcs7_digest         \"pkcs7-digestData\"\n#define NID_pkcs7_digest                25\n#define OBJ_pkcs7_digest                OBJ_pkcs7,5L\n\n#define LN_pkcs7_encrypted              \"pkcs7-encryptedData\"\n#define NID_pkcs7_encrypted             26\n#define OBJ_pkcs7_encrypted             OBJ_pkcs7,6L\n\n#define SN_pkcs9                \"pkcs9\"\n#define NID_pkcs9               47\n#define OBJ_pkcs9               OBJ_pkcs,9L\n\n#define LN_pkcs9_emailAddress           \"emailAddress\"\n#define NID_pkcs9_emailAddress          48\n#define OBJ_pkcs9_emailAddress          OBJ_pkcs9,1L\n\n#define LN_pkcs9_unstructuredName               \"unstructuredName\"\n#define NID_pkcs9_unstructuredName              49\n#define OBJ_pkcs9_unstructuredName              OBJ_pkcs9,2L\n\n#define LN_pkcs9_contentType            \"contentType\"\n#define NID_pkcs9_contentType           50\n#define OBJ_pkcs9_contentType           OBJ_pkcs9,3L\n\n#define LN_pkcs9_messageDigest          \"messageDigest\"\n#define NID_pkcs9_messageDigest         51\n#define OBJ_pkcs9_messageDigest         OBJ_pkcs9,4L\n\n#define LN_pkcs9_signingTime            \"signingTime\"\n#define NID_pkcs9_signingTime           52\n#define OBJ_pkcs9_signingTime           OBJ_pkcs9,5L\n\n#define LN_pkcs9_countersignature               \"countersignature\"\n#define NID_pkcs9_countersignature              53\n#define OBJ_pkcs9_countersignature              OBJ_pkcs9,6L\n\n#define LN_pkcs9_challengePassword              \"challengePassword\"\n#define NID_pkcs9_challengePassword             54\n#define OBJ_pkcs9_challengePassword             OBJ_pkcs9,7L\n\n#define LN_pkcs9_unstructuredAddress            \"unstructuredAddress\"\n#define NID_pkcs9_unstructuredAddress           55\n#define OBJ_pkcs9_unstructuredAddress           OBJ_pkcs9,8L\n\n#define LN_pkcs9_extCertAttributes              \"extendedCertificateAttributes\"\n#define NID_pkcs9_extCertAttributes             56\n#define OBJ_pkcs9_extCertAttributes             OBJ_pkcs9,9L\n\n#define SN_ext_req              \"extReq\"\n#define LN_ext_req              \"Extension Request\"\n#define NID_ext_req             172\n#define OBJ_ext_req             OBJ_pkcs9,14L\n\n#define SN_SMIMECapabilities            \"SMIME-CAPS\"\n#define LN_SMIMECapabilities            \"S/MIME Capabilities\"\n#define NID_SMIMECapabilities           167\n#define OBJ_SMIMECapabilities           OBJ_pkcs9,15L\n\n#define SN_SMIME                \"SMIME\"\n#define LN_SMIME                \"S/MIME\"\n#define NID_SMIME               188\n#define OBJ_SMIME               OBJ_pkcs9,16L\n\n#define SN_id_smime_mod         \"id-smime-mod\"\n#define NID_id_smime_mod                189\n#define OBJ_id_smime_mod                OBJ_SMIME,0L\n\n#define SN_id_smime_ct          \"id-smime-ct\"\n#define NID_id_smime_ct         190\n#define OBJ_id_smime_ct         OBJ_SMIME,1L\n\n#define SN_id_smime_aa          \"id-smime-aa\"\n#define NID_id_smime_aa         191\n#define OBJ_id_smime_aa         OBJ_SMIME,2L\n\n#define SN_id_smime_alg         \"id-smime-alg\"\n#define NID_id_smime_alg                192\n#define OBJ_id_smime_alg                OBJ_SMIME,3L\n\n#define SN_id_smime_cd          \"id-smime-cd\"\n#define NID_id_smime_cd         193\n#define OBJ_id_smime_cd         OBJ_SMIME,4L\n\n#define SN_id_smime_spq         \"id-smime-spq\"\n#define NID_id_smime_spq                194\n#define OBJ_id_smime_spq                OBJ_SMIME,5L\n\n#define SN_id_smime_cti         \"id-smime-cti\"\n#define NID_id_smime_cti                195\n#define OBJ_id_smime_cti                OBJ_SMIME,6L\n\n#define SN_id_smime_mod_cms             \"id-smime-mod-cms\"\n#define NID_id_smime_mod_cms            196\n#define OBJ_id_smime_mod_cms            OBJ_id_smime_mod,1L\n\n#define SN_id_smime_mod_ess             \"id-smime-mod-ess\"\n#define NID_id_smime_mod_ess            197\n#define OBJ_id_smime_mod_ess            OBJ_id_smime_mod,2L\n\n#define SN_id_smime_mod_oid             \"id-smime-mod-oid\"\n#define NID_id_smime_mod_oid            198\n#define OBJ_id_smime_mod_oid            OBJ_id_smime_mod,3L\n\n#define SN_id_smime_mod_msg_v3          \"id-smime-mod-msg-v3\"\n#define NID_id_smime_mod_msg_v3         199\n#define OBJ_id_smime_mod_msg_v3         OBJ_id_smime_mod,4L\n\n#define SN_id_smime_mod_ets_eSignature_88               \"id-smime-mod-ets-eSignature-88\"\n#define NID_id_smime_mod_ets_eSignature_88              200\n#define OBJ_id_smime_mod_ets_eSignature_88              OBJ_id_smime_mod,5L\n\n#define SN_id_smime_mod_ets_eSignature_97               \"id-smime-mod-ets-eSignature-97\"\n#define NID_id_smime_mod_ets_eSignature_97              201\n#define OBJ_id_smime_mod_ets_eSignature_97              OBJ_id_smime_mod,6L\n\n#define SN_id_smime_mod_ets_eSigPolicy_88               \"id-smime-mod-ets-eSigPolicy-88\"\n#define NID_id_smime_mod_ets_eSigPolicy_88              202\n#define OBJ_id_smime_mod_ets_eSigPolicy_88              OBJ_id_smime_mod,7L\n\n#define SN_id_smime_mod_ets_eSigPolicy_97               \"id-smime-mod-ets-eSigPolicy-97\"\n#define NID_id_smime_mod_ets_eSigPolicy_97              203\n#define OBJ_id_smime_mod_ets_eSigPolicy_97              OBJ_id_smime_mod,8L\n\n#define SN_id_smime_ct_receipt          \"id-smime-ct-receipt\"\n#define NID_id_smime_ct_receipt         204\n#define OBJ_id_smime_ct_receipt         OBJ_id_smime_ct,1L\n\n#define SN_id_smime_ct_authData         \"id-smime-ct-authData\"\n#define NID_id_smime_ct_authData                205\n#define OBJ_id_smime_ct_authData                OBJ_id_smime_ct,2L\n\n#define SN_id_smime_ct_publishCert              \"id-smime-ct-publishCert\"\n#define NID_id_smime_ct_publishCert             206\n#define OBJ_id_smime_ct_publishCert             OBJ_id_smime_ct,3L\n\n#define SN_id_smime_ct_TSTInfo          \"id-smime-ct-TSTInfo\"\n#define NID_id_smime_ct_TSTInfo         207\n#define OBJ_id_smime_ct_TSTInfo         OBJ_id_smime_ct,4L\n\n#define SN_id_smime_ct_TDTInfo          \"id-smime-ct-TDTInfo\"\n#define NID_id_smime_ct_TDTInfo         208\n#define OBJ_id_smime_ct_TDTInfo         OBJ_id_smime_ct,5L\n\n#define SN_id_smime_ct_contentInfo              \"id-smime-ct-contentInfo\"\n#define NID_id_smime_ct_contentInfo             209\n#define OBJ_id_smime_ct_contentInfo             OBJ_id_smime_ct,6L\n\n#define SN_id_smime_ct_DVCSRequestData          \"id-smime-ct-DVCSRequestData\"\n#define NID_id_smime_ct_DVCSRequestData         210\n#define OBJ_id_smime_ct_DVCSRequestData         OBJ_id_smime_ct,7L\n\n#define SN_id_smime_ct_DVCSResponseData         \"id-smime-ct-DVCSResponseData\"\n#define NID_id_smime_ct_DVCSResponseData                211\n#define OBJ_id_smime_ct_DVCSResponseData                OBJ_id_smime_ct,8L\n\n#define SN_id_smime_ct_compressedData           \"id-smime-ct-compressedData\"\n#define NID_id_smime_ct_compressedData          786\n#define OBJ_id_smime_ct_compressedData          OBJ_id_smime_ct,9L\n\n#define SN_id_smime_ct_contentCollection                \"id-smime-ct-contentCollection\"\n#define NID_id_smime_ct_contentCollection               1058\n#define OBJ_id_smime_ct_contentCollection               OBJ_id_smime_ct,19L\n\n#define SN_id_smime_ct_authEnvelopedData                \"id-smime-ct-authEnvelopedData\"\n#define NID_id_smime_ct_authEnvelopedData               1059\n#define OBJ_id_smime_ct_authEnvelopedData               OBJ_id_smime_ct,23L\n\n#define SN_id_ct_asciiTextWithCRLF              \"id-ct-asciiTextWithCRLF\"\n#define NID_id_ct_asciiTextWithCRLF             787\n#define OBJ_id_ct_asciiTextWithCRLF             OBJ_id_smime_ct,27L\n\n#define SN_id_ct_xml            \"id-ct-xml\"\n#define NID_id_ct_xml           1060\n#define OBJ_id_ct_xml           OBJ_id_smime_ct,28L\n\n#define SN_id_smime_aa_receiptRequest           \"id-smime-aa-receiptRequest\"\n#define NID_id_smime_aa_receiptRequest          212\n#define OBJ_id_smime_aa_receiptRequest          OBJ_id_smime_aa,1L\n\n#define SN_id_smime_aa_securityLabel            \"id-smime-aa-securityLabel\"\n#define NID_id_smime_aa_securityLabel           213\n#define OBJ_id_smime_aa_securityLabel           OBJ_id_smime_aa,2L\n\n#define SN_id_smime_aa_mlExpandHistory          \"id-smime-aa-mlExpandHistory\"\n#define NID_id_smime_aa_mlExpandHistory         214\n#define OBJ_id_smime_aa_mlExpandHistory         OBJ_id_smime_aa,3L\n\n#define SN_id_smime_aa_contentHint              \"id-smime-aa-contentHint\"\n#define NID_id_smime_aa_contentHint             215\n#define OBJ_id_smime_aa_contentHint             OBJ_id_smime_aa,4L\n\n#define SN_id_smime_aa_msgSigDigest             \"id-smime-aa-msgSigDigest\"\n#define NID_id_smime_aa_msgSigDigest            216\n#define OBJ_id_smime_aa_msgSigDigest            OBJ_id_smime_aa,5L\n\n#define SN_id_smime_aa_encapContentType         \"id-smime-aa-encapContentType\"\n#define NID_id_smime_aa_encapContentType                217\n#define OBJ_id_smime_aa_encapContentType                OBJ_id_smime_aa,6L\n\n#define SN_id_smime_aa_contentIdentifier                \"id-smime-aa-contentIdentifier\"\n#define NID_id_smime_aa_contentIdentifier               218\n#define OBJ_id_smime_aa_contentIdentifier               OBJ_id_smime_aa,7L\n\n#define SN_id_smime_aa_macValue         \"id-smime-aa-macValue\"\n#define NID_id_smime_aa_macValue                219\n#define OBJ_id_smime_aa_macValue                OBJ_id_smime_aa,8L\n\n#define SN_id_smime_aa_equivalentLabels         \"id-smime-aa-equivalentLabels\"\n#define NID_id_smime_aa_equivalentLabels                220\n#define OBJ_id_smime_aa_equivalentLabels                OBJ_id_smime_aa,9L\n\n#define SN_id_smime_aa_contentReference         \"id-smime-aa-contentReference\"\n#define NID_id_smime_aa_contentReference                221\n#define OBJ_id_smime_aa_contentReference                OBJ_id_smime_aa,10L\n\n#define SN_id_smime_aa_encrypKeyPref            \"id-smime-aa-encrypKeyPref\"\n#define NID_id_smime_aa_encrypKeyPref           222\n#define OBJ_id_smime_aa_encrypKeyPref           OBJ_id_smime_aa,11L\n\n#define SN_id_smime_aa_signingCertificate               \"id-smime-aa-signingCertificate\"\n#define NID_id_smime_aa_signingCertificate              223\n#define OBJ_id_smime_aa_signingCertificate              OBJ_id_smime_aa,12L\n\n#define SN_id_smime_aa_smimeEncryptCerts                \"id-smime-aa-smimeEncryptCerts\"\n#define NID_id_smime_aa_smimeEncryptCerts               224\n#define OBJ_id_smime_aa_smimeEncryptCerts               OBJ_id_smime_aa,13L\n\n#define SN_id_smime_aa_timeStampToken           \"id-smime-aa-timeStampToken\"\n#define NID_id_smime_aa_timeStampToken          225\n#define OBJ_id_smime_aa_timeStampToken          OBJ_id_smime_aa,14L\n\n#define SN_id_smime_aa_ets_sigPolicyId          \"id-smime-aa-ets-sigPolicyId\"\n#define NID_id_smime_aa_ets_sigPolicyId         226\n#define OBJ_id_smime_aa_ets_sigPolicyId         OBJ_id_smime_aa,15L\n\n#define SN_id_smime_aa_ets_commitmentType               \"id-smime-aa-ets-commitmentType\"\n#define NID_id_smime_aa_ets_commitmentType              227\n#define OBJ_id_smime_aa_ets_commitmentType              OBJ_id_smime_aa,16L\n\n#define SN_id_smime_aa_ets_signerLocation               \"id-smime-aa-ets-signerLocation\"\n#define NID_id_smime_aa_ets_signerLocation              228\n#define OBJ_id_smime_aa_ets_signerLocation              OBJ_id_smime_aa,17L\n\n#define SN_id_smime_aa_ets_signerAttr           \"id-smime-aa-ets-signerAttr\"\n#define NID_id_smime_aa_ets_signerAttr          229\n#define OBJ_id_smime_aa_ets_signerAttr          OBJ_id_smime_aa,18L\n\n#define SN_id_smime_aa_ets_otherSigCert         \"id-smime-aa-ets-otherSigCert\"\n#define NID_id_smime_aa_ets_otherSigCert                230\n#define OBJ_id_smime_aa_ets_otherSigCert                OBJ_id_smime_aa,19L\n\n#define SN_id_smime_aa_ets_contentTimestamp             \"id-smime-aa-ets-contentTimestamp\"\n#define NID_id_smime_aa_ets_contentTimestamp            231\n#define OBJ_id_smime_aa_ets_contentTimestamp            OBJ_id_smime_aa,20L\n\n#define SN_id_smime_aa_ets_CertificateRefs              \"id-smime-aa-ets-CertificateRefs\"\n#define NID_id_smime_aa_ets_CertificateRefs             232\n#define OBJ_id_smime_aa_ets_CertificateRefs             OBJ_id_smime_aa,21L\n\n#define SN_id_smime_aa_ets_RevocationRefs               \"id-smime-aa-ets-RevocationRefs\"\n#define NID_id_smime_aa_ets_RevocationRefs              233\n#define OBJ_id_smime_aa_ets_RevocationRefs              OBJ_id_smime_aa,22L\n\n#define SN_id_smime_aa_ets_certValues           \"id-smime-aa-ets-certValues\"\n#define NID_id_smime_aa_ets_certValues          234\n#define OBJ_id_smime_aa_ets_certValues          OBJ_id_smime_aa,23L\n\n#define SN_id_smime_aa_ets_revocationValues             \"id-smime-aa-ets-revocationValues\"\n#define NID_id_smime_aa_ets_revocationValues            235\n#define OBJ_id_smime_aa_ets_revocationValues            OBJ_id_smime_aa,24L\n\n#define SN_id_smime_aa_ets_escTimeStamp         \"id-smime-aa-ets-escTimeStamp\"\n#define NID_id_smime_aa_ets_escTimeStamp                236\n#define OBJ_id_smime_aa_ets_escTimeStamp                OBJ_id_smime_aa,25L\n\n#define SN_id_smime_aa_ets_certCRLTimestamp             \"id-smime-aa-ets-certCRLTimestamp\"\n#define NID_id_smime_aa_ets_certCRLTimestamp            237\n#define OBJ_id_smime_aa_ets_certCRLTimestamp            OBJ_id_smime_aa,26L\n\n#define SN_id_smime_aa_ets_archiveTimeStamp             \"id-smime-aa-ets-archiveTimeStamp\"\n#define NID_id_smime_aa_ets_archiveTimeStamp            238\n#define OBJ_id_smime_aa_ets_archiveTimeStamp            OBJ_id_smime_aa,27L\n\n#define SN_id_smime_aa_signatureType            \"id-smime-aa-signatureType\"\n#define NID_id_smime_aa_signatureType           239\n#define OBJ_id_smime_aa_signatureType           OBJ_id_smime_aa,28L\n\n#define SN_id_smime_aa_dvcs_dvc         \"id-smime-aa-dvcs-dvc\"\n#define NID_id_smime_aa_dvcs_dvc                240\n#define OBJ_id_smime_aa_dvcs_dvc                OBJ_id_smime_aa,29L\n\n#define SN_id_smime_aa_signingCertificateV2             \"id-smime-aa-signingCertificateV2\"\n#define NID_id_smime_aa_signingCertificateV2            1086\n#define OBJ_id_smime_aa_signingCertificateV2            OBJ_id_smime_aa,47L\n\n#define SN_id_smime_alg_ESDHwith3DES            \"id-smime-alg-ESDHwith3DES\"\n#define NID_id_smime_alg_ESDHwith3DES           241\n#define OBJ_id_smime_alg_ESDHwith3DES           OBJ_id_smime_alg,1L\n\n#define SN_id_smime_alg_ESDHwithRC2             \"id-smime-alg-ESDHwithRC2\"\n#define NID_id_smime_alg_ESDHwithRC2            242\n#define OBJ_id_smime_alg_ESDHwithRC2            OBJ_id_smime_alg,2L\n\n#define SN_id_smime_alg_3DESwrap                \"id-smime-alg-3DESwrap\"\n#define NID_id_smime_alg_3DESwrap               243\n#define OBJ_id_smime_alg_3DESwrap               OBJ_id_smime_alg,3L\n\n#define SN_id_smime_alg_RC2wrap         \"id-smime-alg-RC2wrap\"\n#define NID_id_smime_alg_RC2wrap                244\n#define OBJ_id_smime_alg_RC2wrap                OBJ_id_smime_alg,4L\n\n#define SN_id_smime_alg_ESDH            \"id-smime-alg-ESDH\"\n#define NID_id_smime_alg_ESDH           245\n#define OBJ_id_smime_alg_ESDH           OBJ_id_smime_alg,5L\n\n#define SN_id_smime_alg_CMS3DESwrap             \"id-smime-alg-CMS3DESwrap\"\n#define NID_id_smime_alg_CMS3DESwrap            246\n#define OBJ_id_smime_alg_CMS3DESwrap            OBJ_id_smime_alg,6L\n\n#define SN_id_smime_alg_CMSRC2wrap              \"id-smime-alg-CMSRC2wrap\"\n#define NID_id_smime_alg_CMSRC2wrap             247\n#define OBJ_id_smime_alg_CMSRC2wrap             OBJ_id_smime_alg,7L\n\n#define SN_id_alg_PWRI_KEK              \"id-alg-PWRI-KEK\"\n#define NID_id_alg_PWRI_KEK             893\n#define OBJ_id_alg_PWRI_KEK             OBJ_id_smime_alg,9L\n\n#define SN_id_smime_cd_ldap             \"id-smime-cd-ldap\"\n#define NID_id_smime_cd_ldap            248\n#define OBJ_id_smime_cd_ldap            OBJ_id_smime_cd,1L\n\n#define SN_id_smime_spq_ets_sqt_uri             \"id-smime-spq-ets-sqt-uri\"\n#define NID_id_smime_spq_ets_sqt_uri            249\n#define OBJ_id_smime_spq_ets_sqt_uri            OBJ_id_smime_spq,1L\n\n#define SN_id_smime_spq_ets_sqt_unotice         \"id-smime-spq-ets-sqt-unotice\"\n#define NID_id_smime_spq_ets_sqt_unotice                250\n#define OBJ_id_smime_spq_ets_sqt_unotice                OBJ_id_smime_spq,2L\n\n#define SN_id_smime_cti_ets_proofOfOrigin               \"id-smime-cti-ets-proofOfOrigin\"\n#define NID_id_smime_cti_ets_proofOfOrigin              251\n#define OBJ_id_smime_cti_ets_proofOfOrigin              OBJ_id_smime_cti,1L\n\n#define SN_id_smime_cti_ets_proofOfReceipt              \"id-smime-cti-ets-proofOfReceipt\"\n#define NID_id_smime_cti_ets_proofOfReceipt             252\n#define OBJ_id_smime_cti_ets_proofOfReceipt             OBJ_id_smime_cti,2L\n\n#define SN_id_smime_cti_ets_proofOfDelivery             \"id-smime-cti-ets-proofOfDelivery\"\n#define NID_id_smime_cti_ets_proofOfDelivery            253\n#define OBJ_id_smime_cti_ets_proofOfDelivery            OBJ_id_smime_cti,3L\n\n#define SN_id_smime_cti_ets_proofOfSender               \"id-smime-cti-ets-proofOfSender\"\n#define NID_id_smime_cti_ets_proofOfSender              254\n#define OBJ_id_smime_cti_ets_proofOfSender              OBJ_id_smime_cti,4L\n\n#define SN_id_smime_cti_ets_proofOfApproval             \"id-smime-cti-ets-proofOfApproval\"\n#define NID_id_smime_cti_ets_proofOfApproval            255\n#define OBJ_id_smime_cti_ets_proofOfApproval            OBJ_id_smime_cti,5L\n\n#define SN_id_smime_cti_ets_proofOfCreation             \"id-smime-cti-ets-proofOfCreation\"\n#define NID_id_smime_cti_ets_proofOfCreation            256\n#define OBJ_id_smime_cti_ets_proofOfCreation            OBJ_id_smime_cti,6L\n\n#define LN_friendlyName         \"friendlyName\"\n#define NID_friendlyName                156\n#define OBJ_friendlyName                OBJ_pkcs9,20L\n\n#define LN_localKeyID           \"localKeyID\"\n#define NID_localKeyID          157\n#define OBJ_localKeyID          OBJ_pkcs9,21L\n\n#define SN_ms_csp_name          \"CSPName\"\n#define LN_ms_csp_name          \"Microsoft CSP Name\"\n#define NID_ms_csp_name         417\n#define OBJ_ms_csp_name         1L,3L,6L,1L,4L,1L,311L,17L,1L\n\n#define SN_LocalKeySet          \"LocalKeySet\"\n#define LN_LocalKeySet          \"Microsoft Local Key set\"\n#define NID_LocalKeySet         856\n#define OBJ_LocalKeySet         1L,3L,6L,1L,4L,1L,311L,17L,2L\n\n#define OBJ_certTypes           OBJ_pkcs9,22L\n\n#define LN_x509Certificate              \"x509Certificate\"\n#define NID_x509Certificate             158\n#define OBJ_x509Certificate             OBJ_certTypes,1L\n\n#define LN_sdsiCertificate              \"sdsiCertificate\"\n#define NID_sdsiCertificate             159\n#define OBJ_sdsiCertificate             OBJ_certTypes,2L\n\n#define OBJ_crlTypes            OBJ_pkcs9,23L\n\n#define LN_x509Crl              \"x509Crl\"\n#define NID_x509Crl             160\n#define OBJ_x509Crl             OBJ_crlTypes,1L\n\n#define OBJ_pkcs12              OBJ_pkcs,12L\n\n#define OBJ_pkcs12_pbeids               OBJ_pkcs12,1L\n\n#define SN_pbe_WithSHA1And128BitRC4             \"PBE-SHA1-RC4-128\"\n#define LN_pbe_WithSHA1And128BitRC4             \"pbeWithSHA1And128BitRC4\"\n#define NID_pbe_WithSHA1And128BitRC4            144\n#define OBJ_pbe_WithSHA1And128BitRC4            OBJ_pkcs12_pbeids,1L\n\n#define SN_pbe_WithSHA1And40BitRC4              \"PBE-SHA1-RC4-40\"\n#define LN_pbe_WithSHA1And40BitRC4              \"pbeWithSHA1And40BitRC4\"\n#define NID_pbe_WithSHA1And40BitRC4             145\n#define OBJ_pbe_WithSHA1And40BitRC4             OBJ_pkcs12_pbeids,2L\n\n#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"PBE-SHA1-3DES\"\n#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC           \"pbeWithSHA1And3-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC          146\n#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,3L\n\n#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"PBE-SHA1-2DES\"\n#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC           \"pbeWithSHA1And2-KeyTripleDES-CBC\"\n#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC          147\n#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC          OBJ_pkcs12_pbeids,4L\n\n#define SN_pbe_WithSHA1And128BitRC2_CBC         \"PBE-SHA1-RC2-128\"\n#define LN_pbe_WithSHA1And128BitRC2_CBC         \"pbeWithSHA1And128BitRC2-CBC\"\n#define NID_pbe_WithSHA1And128BitRC2_CBC                148\n#define OBJ_pbe_WithSHA1And128BitRC2_CBC                OBJ_pkcs12_pbeids,5L\n\n#define SN_pbe_WithSHA1And40BitRC2_CBC          \"PBE-SHA1-RC2-40\"\n#define LN_pbe_WithSHA1And40BitRC2_CBC          \"pbeWithSHA1And40BitRC2-CBC\"\n#define NID_pbe_WithSHA1And40BitRC2_CBC         149\n#define OBJ_pbe_WithSHA1And40BitRC2_CBC         OBJ_pkcs12_pbeids,6L\n\n#define OBJ_pkcs12_Version1             OBJ_pkcs12,10L\n\n#define OBJ_pkcs12_BagIds               OBJ_pkcs12_Version1,1L\n\n#define LN_keyBag               \"keyBag\"\n#define NID_keyBag              150\n#define OBJ_keyBag              OBJ_pkcs12_BagIds,1L\n\n#define LN_pkcs8ShroudedKeyBag          \"pkcs8ShroudedKeyBag\"\n#define NID_pkcs8ShroudedKeyBag         151\n#define OBJ_pkcs8ShroudedKeyBag         OBJ_pkcs12_BagIds,2L\n\n#define LN_certBag              \"certBag\"\n#define NID_certBag             152\n#define OBJ_certBag             OBJ_pkcs12_BagIds,3L\n\n#define LN_crlBag               \"crlBag\"\n#define NID_crlBag              153\n#define OBJ_crlBag              OBJ_pkcs12_BagIds,4L\n\n#define LN_secretBag            \"secretBag\"\n#define NID_secretBag           154\n#define OBJ_secretBag           OBJ_pkcs12_BagIds,5L\n\n#define LN_safeContentsBag              \"safeContentsBag\"\n#define NID_safeContentsBag             155\n#define OBJ_safeContentsBag             OBJ_pkcs12_BagIds,6L\n\n#define SN_md2          \"MD2\"\n#define LN_md2          \"md2\"\n#define NID_md2         3\n#define OBJ_md2         OBJ_rsadsi,2L,2L\n\n#define SN_md4          \"MD4\"\n#define LN_md4          \"md4\"\n#define NID_md4         257\n#define OBJ_md4         OBJ_rsadsi,2L,4L\n\n#define SN_md5          \"MD5\"\n#define LN_md5          \"md5\"\n#define NID_md5         4\n#define OBJ_md5         OBJ_rsadsi,2L,5L\n\n#define SN_md5_sha1             \"MD5-SHA1\"\n#define LN_md5_sha1             \"md5-sha1\"\n#define NID_md5_sha1            114\n\n#define LN_hmacWithMD5          \"hmacWithMD5\"\n#define NID_hmacWithMD5         797\n#define OBJ_hmacWithMD5         OBJ_rsadsi,2L,6L\n\n#define LN_hmacWithSHA1         \"hmacWithSHA1\"\n#define NID_hmacWithSHA1                163\n#define OBJ_hmacWithSHA1                OBJ_rsadsi,2L,7L\n\n#define SN_sm2          \"SM2\"\n#define LN_sm2          \"sm2\"\n#define NID_sm2         1172\n#define OBJ_sm2         OBJ_sm_scheme,301L\n\n#define SN_sm3          \"SM3\"\n#define LN_sm3          \"sm3\"\n#define NID_sm3         1143\n#define OBJ_sm3         OBJ_sm_scheme,401L\n\n#define SN_sm3WithRSAEncryption         \"RSA-SM3\"\n#define LN_sm3WithRSAEncryption         \"sm3WithRSAEncryption\"\n#define NID_sm3WithRSAEncryption                1144\n#define OBJ_sm3WithRSAEncryption                OBJ_sm_scheme,504L\n\n#define LN_hmacWithSHA224               \"hmacWithSHA224\"\n#define NID_hmacWithSHA224              798\n#define OBJ_hmacWithSHA224              OBJ_rsadsi,2L,8L\n\n#define LN_hmacWithSHA256               \"hmacWithSHA256\"\n#define NID_hmacWithSHA256              799\n#define OBJ_hmacWithSHA256              OBJ_rsadsi,2L,9L\n\n#define LN_hmacWithSHA384               \"hmacWithSHA384\"\n#define NID_hmacWithSHA384              800\n#define OBJ_hmacWithSHA384              OBJ_rsadsi,2L,10L\n\n#define LN_hmacWithSHA512               \"hmacWithSHA512\"\n#define NID_hmacWithSHA512              801\n#define OBJ_hmacWithSHA512              OBJ_rsadsi,2L,11L\n\n#define LN_hmacWithSHA512_224           \"hmacWithSHA512-224\"\n#define NID_hmacWithSHA512_224          1193\n#define OBJ_hmacWithSHA512_224          OBJ_rsadsi,2L,12L\n\n#define LN_hmacWithSHA512_256           \"hmacWithSHA512-256\"\n#define NID_hmacWithSHA512_256          1194\n#define OBJ_hmacWithSHA512_256          OBJ_rsadsi,2L,13L\n\n#define SN_rc2_cbc              \"RC2-CBC\"\n#define LN_rc2_cbc              \"rc2-cbc\"\n#define NID_rc2_cbc             37\n#define OBJ_rc2_cbc             OBJ_rsadsi,3L,2L\n\n#define SN_rc2_ecb              \"RC2-ECB\"\n#define LN_rc2_ecb              \"rc2-ecb\"\n#define NID_rc2_ecb             38\n\n#define SN_rc2_cfb64            \"RC2-CFB\"\n#define LN_rc2_cfb64            \"rc2-cfb\"\n#define NID_rc2_cfb64           39\n\n#define SN_rc2_ofb64            \"RC2-OFB\"\n#define LN_rc2_ofb64            \"rc2-ofb\"\n#define NID_rc2_ofb64           40\n\n#define SN_rc2_40_cbc           \"RC2-40-CBC\"\n#define LN_rc2_40_cbc           \"rc2-40-cbc\"\n#define NID_rc2_40_cbc          98\n\n#define SN_rc2_64_cbc           \"RC2-64-CBC\"\n#define LN_rc2_64_cbc           \"rc2-64-cbc\"\n#define NID_rc2_64_cbc          166\n\n#define SN_rc4          \"RC4\"\n#define LN_rc4          \"rc4\"\n#define NID_rc4         5\n#define OBJ_rc4         OBJ_rsadsi,3L,4L\n\n#define SN_rc4_40               \"RC4-40\"\n#define LN_rc4_40               \"rc4-40\"\n#define NID_rc4_40              97\n\n#define SN_des_ede3_cbc         \"DES-EDE3-CBC\"\n#define LN_des_ede3_cbc         \"des-ede3-cbc\"\n#define NID_des_ede3_cbc                44\n#define OBJ_des_ede3_cbc                OBJ_rsadsi,3L,7L\n\n#define SN_rc5_cbc              \"RC5-CBC\"\n#define LN_rc5_cbc              \"rc5-cbc\"\n#define NID_rc5_cbc             120\n#define OBJ_rc5_cbc             OBJ_rsadsi,3L,8L\n\n#define SN_rc5_ecb              \"RC5-ECB\"\n#define LN_rc5_ecb              \"rc5-ecb\"\n#define NID_rc5_ecb             121\n\n#define SN_rc5_cfb64            \"RC5-CFB\"\n#define LN_rc5_cfb64            \"rc5-cfb\"\n#define NID_rc5_cfb64           122\n\n#define SN_rc5_ofb64            \"RC5-OFB\"\n#define LN_rc5_ofb64            \"rc5-ofb\"\n#define NID_rc5_ofb64           123\n\n#define SN_ms_ext_req           \"msExtReq\"\n#define LN_ms_ext_req           \"Microsoft Extension Request\"\n#define NID_ms_ext_req          171\n#define OBJ_ms_ext_req          1L,3L,6L,1L,4L,1L,311L,2L,1L,14L\n\n#define SN_ms_code_ind          \"msCodeInd\"\n#define LN_ms_code_ind          \"Microsoft Individual Code Signing\"\n#define NID_ms_code_ind         134\n#define OBJ_ms_code_ind         1L,3L,6L,1L,4L,1L,311L,2L,1L,21L\n\n#define SN_ms_code_com          \"msCodeCom\"\n#define LN_ms_code_com          \"Microsoft Commercial Code Signing\"\n#define NID_ms_code_com         135\n#define OBJ_ms_code_com         1L,3L,6L,1L,4L,1L,311L,2L,1L,22L\n\n#define SN_ms_ctl_sign          \"msCTLSign\"\n#define LN_ms_ctl_sign          \"Microsoft Trust List Signing\"\n#define NID_ms_ctl_sign         136\n#define OBJ_ms_ctl_sign         1L,3L,6L,1L,4L,1L,311L,10L,3L,1L\n\n#define SN_ms_sgc               \"msSGC\"\n#define LN_ms_sgc               \"Microsoft Server Gated Crypto\"\n#define NID_ms_sgc              137\n#define OBJ_ms_sgc              1L,3L,6L,1L,4L,1L,311L,10L,3L,3L\n\n#define SN_ms_efs               \"msEFS\"\n#define LN_ms_efs               \"Microsoft Encrypted File System\"\n#define NID_ms_efs              138\n#define OBJ_ms_efs              1L,3L,6L,1L,4L,1L,311L,10L,3L,4L\n\n#define SN_ms_smartcard_login           \"msSmartcardLogin\"\n#define LN_ms_smartcard_login           \"Microsoft Smartcard Login\"\n#define NID_ms_smartcard_login          648\n#define OBJ_ms_smartcard_login          1L,3L,6L,1L,4L,1L,311L,20L,2L,2L\n\n#define SN_ms_upn               \"msUPN\"\n#define LN_ms_upn               \"Microsoft User Principal Name\"\n#define NID_ms_upn              649\n#define OBJ_ms_upn              1L,3L,6L,1L,4L,1L,311L,20L,2L,3L\n\n#define SN_idea_cbc             \"IDEA-CBC\"\n#define LN_idea_cbc             \"idea-cbc\"\n#define NID_idea_cbc            34\n#define OBJ_idea_cbc            1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L\n\n#define SN_idea_ecb             \"IDEA-ECB\"\n#define LN_idea_ecb             \"idea-ecb\"\n#define NID_idea_ecb            36\n\n#define SN_idea_cfb64           \"IDEA-CFB\"\n#define LN_idea_cfb64           \"idea-cfb\"\n#define NID_idea_cfb64          35\n\n#define SN_idea_ofb64           \"IDEA-OFB\"\n#define LN_idea_ofb64           \"idea-ofb\"\n#define NID_idea_ofb64          46\n\n#define SN_bf_cbc               \"BF-CBC\"\n#define LN_bf_cbc               \"bf-cbc\"\n#define NID_bf_cbc              91\n#define OBJ_bf_cbc              1L,3L,6L,1L,4L,1L,3029L,1L,2L\n\n#define SN_bf_ecb               \"BF-ECB\"\n#define LN_bf_ecb               \"bf-ecb\"\n#define NID_bf_ecb              92\n\n#define SN_bf_cfb64             \"BF-CFB\"\n#define LN_bf_cfb64             \"bf-cfb\"\n#define NID_bf_cfb64            93\n\n#define SN_bf_ofb64             \"BF-OFB\"\n#define LN_bf_ofb64             \"bf-ofb\"\n#define NID_bf_ofb64            94\n\n#define SN_id_pkix              \"PKIX\"\n#define NID_id_pkix             127\n#define OBJ_id_pkix             1L,3L,6L,1L,5L,5L,7L\n\n#define SN_id_pkix_mod          \"id-pkix-mod\"\n#define NID_id_pkix_mod         258\n#define OBJ_id_pkix_mod         OBJ_id_pkix,0L\n\n#define SN_id_pe                \"id-pe\"\n#define NID_id_pe               175\n#define OBJ_id_pe               OBJ_id_pkix,1L\n\n#define SN_id_qt                \"id-qt\"\n#define NID_id_qt               259\n#define OBJ_id_qt               OBJ_id_pkix,2L\n\n#define SN_id_kp                \"id-kp\"\n#define NID_id_kp               128\n#define OBJ_id_kp               OBJ_id_pkix,3L\n\n#define SN_id_it                \"id-it\"\n#define NID_id_it               260\n#define OBJ_id_it               OBJ_id_pkix,4L\n\n#define SN_id_pkip              \"id-pkip\"\n#define NID_id_pkip             261\n#define OBJ_id_pkip             OBJ_id_pkix,5L\n\n#define SN_id_alg               \"id-alg\"\n#define NID_id_alg              262\n#define OBJ_id_alg              OBJ_id_pkix,6L\n\n#define SN_id_cmc               \"id-cmc\"\n#define NID_id_cmc              263\n#define OBJ_id_cmc              OBJ_id_pkix,7L\n\n#define SN_id_on                \"id-on\"\n#define NID_id_on               264\n#define OBJ_id_on               OBJ_id_pkix,8L\n\n#define SN_id_pda               \"id-pda\"\n#define NID_id_pda              265\n#define OBJ_id_pda              OBJ_id_pkix,9L\n\n#define SN_id_aca               \"id-aca\"\n#define NID_id_aca              266\n#define OBJ_id_aca              OBJ_id_pkix,10L\n\n#define SN_id_qcs               \"id-qcs\"\n#define NID_id_qcs              267\n#define OBJ_id_qcs              OBJ_id_pkix,11L\n\n#define SN_id_cct               \"id-cct\"\n#define NID_id_cct              268\n#define OBJ_id_cct              OBJ_id_pkix,12L\n\n#define SN_id_ppl               \"id-ppl\"\n#define NID_id_ppl              662\n#define OBJ_id_ppl              OBJ_id_pkix,21L\n\n#define SN_id_ad                \"id-ad\"\n#define NID_id_ad               176\n#define OBJ_id_ad               OBJ_id_pkix,48L\n\n#define SN_id_pkix1_explicit_88         \"id-pkix1-explicit-88\"\n#define NID_id_pkix1_explicit_88                269\n#define OBJ_id_pkix1_explicit_88                OBJ_id_pkix_mod,1L\n\n#define SN_id_pkix1_implicit_88         \"id-pkix1-implicit-88\"\n#define NID_id_pkix1_implicit_88                270\n#define OBJ_id_pkix1_implicit_88                OBJ_id_pkix_mod,2L\n\n#define SN_id_pkix1_explicit_93         \"id-pkix1-explicit-93\"\n#define NID_id_pkix1_explicit_93                271\n#define OBJ_id_pkix1_explicit_93                OBJ_id_pkix_mod,3L\n\n#define SN_id_pkix1_implicit_93         \"id-pkix1-implicit-93\"\n#define NID_id_pkix1_implicit_93                272\n#define OBJ_id_pkix1_implicit_93                OBJ_id_pkix_mod,4L\n\n#define SN_id_mod_crmf          \"id-mod-crmf\"\n#define NID_id_mod_crmf         273\n#define OBJ_id_mod_crmf         OBJ_id_pkix_mod,5L\n\n#define SN_id_mod_cmc           \"id-mod-cmc\"\n#define NID_id_mod_cmc          274\n#define OBJ_id_mod_cmc          OBJ_id_pkix_mod,6L\n\n#define SN_id_mod_kea_profile_88                \"id-mod-kea-profile-88\"\n#define NID_id_mod_kea_profile_88               275\n#define OBJ_id_mod_kea_profile_88               OBJ_id_pkix_mod,7L\n\n#define SN_id_mod_kea_profile_93                \"id-mod-kea-profile-93\"\n#define NID_id_mod_kea_profile_93               276\n#define OBJ_id_mod_kea_profile_93               OBJ_id_pkix_mod,8L\n\n#define SN_id_mod_cmp           \"id-mod-cmp\"\n#define NID_id_mod_cmp          277\n#define OBJ_id_mod_cmp          OBJ_id_pkix_mod,9L\n\n#define SN_id_mod_qualified_cert_88             \"id-mod-qualified-cert-88\"\n#define NID_id_mod_qualified_cert_88            278\n#define OBJ_id_mod_qualified_cert_88            OBJ_id_pkix_mod,10L\n\n#define SN_id_mod_qualified_cert_93             \"id-mod-qualified-cert-93\"\n#define NID_id_mod_qualified_cert_93            279\n#define OBJ_id_mod_qualified_cert_93            OBJ_id_pkix_mod,11L\n\n#define SN_id_mod_attribute_cert                \"id-mod-attribute-cert\"\n#define NID_id_mod_attribute_cert               280\n#define OBJ_id_mod_attribute_cert               OBJ_id_pkix_mod,12L\n\n#define SN_id_mod_timestamp_protocol            \"id-mod-timestamp-protocol\"\n#define NID_id_mod_timestamp_protocol           281\n#define OBJ_id_mod_timestamp_protocol           OBJ_id_pkix_mod,13L\n\n#define SN_id_mod_ocsp          \"id-mod-ocsp\"\n#define NID_id_mod_ocsp         282\n#define OBJ_id_mod_ocsp         OBJ_id_pkix_mod,14L\n\n#define SN_id_mod_dvcs          \"id-mod-dvcs\"\n#define NID_id_mod_dvcs         283\n#define OBJ_id_mod_dvcs         OBJ_id_pkix_mod,15L\n\n#define SN_id_mod_cmp2000               \"id-mod-cmp2000\"\n#define NID_id_mod_cmp2000              284\n#define OBJ_id_mod_cmp2000              OBJ_id_pkix_mod,16L\n\n#define SN_info_access          \"authorityInfoAccess\"\n#define LN_info_access          \"Authority Information Access\"\n#define NID_info_access         177\n#define OBJ_info_access         OBJ_id_pe,1L\n\n#define SN_biometricInfo                \"biometricInfo\"\n#define LN_biometricInfo                \"Biometric Info\"\n#define NID_biometricInfo               285\n#define OBJ_biometricInfo               OBJ_id_pe,2L\n\n#define SN_qcStatements         \"qcStatements\"\n#define NID_qcStatements                286\n#define OBJ_qcStatements                OBJ_id_pe,3L\n\n#define SN_ac_auditEntity               \"ac-auditEntity\"\n#define NID_ac_auditEntity              287\n#define OBJ_ac_auditEntity              OBJ_id_pe,4L\n\n#define SN_ac_targeting         \"ac-targeting\"\n#define NID_ac_targeting                288\n#define OBJ_ac_targeting                OBJ_id_pe,5L\n\n#define SN_aaControls           \"aaControls\"\n#define NID_aaControls          289\n#define OBJ_aaControls          OBJ_id_pe,6L\n\n#define SN_sbgp_ipAddrBlock             \"sbgp-ipAddrBlock\"\n#define NID_sbgp_ipAddrBlock            290\n#define OBJ_sbgp_ipAddrBlock            OBJ_id_pe,7L\n\n#define SN_sbgp_autonomousSysNum                \"sbgp-autonomousSysNum\"\n#define NID_sbgp_autonomousSysNum               291\n#define OBJ_sbgp_autonomousSysNum               OBJ_id_pe,8L\n\n#define SN_sbgp_routerIdentifier                \"sbgp-routerIdentifier\"\n#define NID_sbgp_routerIdentifier               292\n#define OBJ_sbgp_routerIdentifier               OBJ_id_pe,9L\n\n#define SN_ac_proxying          \"ac-proxying\"\n#define NID_ac_proxying         397\n#define OBJ_ac_proxying         OBJ_id_pe,10L\n\n#define SN_sinfo_access         \"subjectInfoAccess\"\n#define LN_sinfo_access         \"Subject Information Access\"\n#define NID_sinfo_access                398\n#define OBJ_sinfo_access                OBJ_id_pe,11L\n\n#define SN_proxyCertInfo                \"proxyCertInfo\"\n#define LN_proxyCertInfo                \"Proxy Certificate Information\"\n#define NID_proxyCertInfo               663\n#define OBJ_proxyCertInfo               OBJ_id_pe,14L\n\n#define SN_tlsfeature           \"tlsfeature\"\n#define LN_tlsfeature           \"TLS Feature\"\n#define NID_tlsfeature          1020\n#define OBJ_tlsfeature          OBJ_id_pe,24L\n\n#define SN_id_qt_cps            \"id-qt-cps\"\n#define LN_id_qt_cps            \"Policy Qualifier CPS\"\n#define NID_id_qt_cps           164\n#define OBJ_id_qt_cps           OBJ_id_qt,1L\n\n#define SN_id_qt_unotice                \"id-qt-unotice\"\n#define LN_id_qt_unotice                \"Policy Qualifier User Notice\"\n#define NID_id_qt_unotice               165\n#define OBJ_id_qt_unotice               OBJ_id_qt,2L\n\n#define SN_textNotice           \"textNotice\"\n#define NID_textNotice          293\n#define OBJ_textNotice          OBJ_id_qt,3L\n\n#define SN_server_auth          \"serverAuth\"\n#define LN_server_auth          \"TLS Web Server Authentication\"\n#define NID_server_auth         129\n#define OBJ_server_auth         OBJ_id_kp,1L\n\n#define SN_client_auth          \"clientAuth\"\n#define LN_client_auth          \"TLS Web Client Authentication\"\n#define NID_client_auth         130\n#define OBJ_client_auth         OBJ_id_kp,2L\n\n#define SN_code_sign            \"codeSigning\"\n#define LN_code_sign            \"Code Signing\"\n#define NID_code_sign           131\n#define OBJ_code_sign           OBJ_id_kp,3L\n\n#define SN_email_protect                \"emailProtection\"\n#define LN_email_protect                \"E-mail Protection\"\n#define NID_email_protect               132\n#define OBJ_email_protect               OBJ_id_kp,4L\n\n#define SN_ipsecEndSystem               \"ipsecEndSystem\"\n#define LN_ipsecEndSystem               \"IPSec End System\"\n#define NID_ipsecEndSystem              294\n#define OBJ_ipsecEndSystem              OBJ_id_kp,5L\n\n#define SN_ipsecTunnel          \"ipsecTunnel\"\n#define LN_ipsecTunnel          \"IPSec Tunnel\"\n#define NID_ipsecTunnel         295\n#define OBJ_ipsecTunnel         OBJ_id_kp,6L\n\n#define SN_ipsecUser            \"ipsecUser\"\n#define LN_ipsecUser            \"IPSec User\"\n#define NID_ipsecUser           296\n#define OBJ_ipsecUser           OBJ_id_kp,7L\n\n#define SN_time_stamp           \"timeStamping\"\n#define LN_time_stamp           \"Time Stamping\"\n#define NID_time_stamp          133\n#define OBJ_time_stamp          OBJ_id_kp,8L\n\n#define SN_OCSP_sign            \"OCSPSigning\"\n#define LN_OCSP_sign            \"OCSP Signing\"\n#define NID_OCSP_sign           180\n#define OBJ_OCSP_sign           OBJ_id_kp,9L\n\n#define SN_dvcs         \"DVCS\"\n#define LN_dvcs         \"dvcs\"\n#define NID_dvcs                297\n#define OBJ_dvcs                OBJ_id_kp,10L\n\n#define SN_ipsec_IKE            \"ipsecIKE\"\n#define LN_ipsec_IKE            \"ipsec Internet Key Exchange\"\n#define NID_ipsec_IKE           1022\n#define OBJ_ipsec_IKE           OBJ_id_kp,17L\n\n#define SN_capwapAC             \"capwapAC\"\n#define LN_capwapAC             \"Ctrl/provision WAP Access\"\n#define NID_capwapAC            1023\n#define OBJ_capwapAC            OBJ_id_kp,18L\n\n#define SN_capwapWTP            \"capwapWTP\"\n#define LN_capwapWTP            \"Ctrl/Provision WAP Termination\"\n#define NID_capwapWTP           1024\n#define OBJ_capwapWTP           OBJ_id_kp,19L\n\n#define SN_sshClient            \"secureShellClient\"\n#define LN_sshClient            \"SSH Client\"\n#define NID_sshClient           1025\n#define OBJ_sshClient           OBJ_id_kp,21L\n\n#define SN_sshServer            \"secureShellServer\"\n#define LN_sshServer            \"SSH Server\"\n#define NID_sshServer           1026\n#define OBJ_sshServer           OBJ_id_kp,22L\n\n#define SN_sendRouter           \"sendRouter\"\n#define LN_sendRouter           \"Send Router\"\n#define NID_sendRouter          1027\n#define OBJ_sendRouter          OBJ_id_kp,23L\n\n#define SN_sendProxiedRouter            \"sendProxiedRouter\"\n#define LN_sendProxiedRouter            \"Send Proxied Router\"\n#define NID_sendProxiedRouter           1028\n#define OBJ_sendProxiedRouter           OBJ_id_kp,24L\n\n#define SN_sendOwner            \"sendOwner\"\n#define LN_sendOwner            \"Send Owner\"\n#define NID_sendOwner           1029\n#define OBJ_sendOwner           OBJ_id_kp,25L\n\n#define SN_sendProxiedOwner             \"sendProxiedOwner\"\n#define LN_sendProxiedOwner             \"Send Proxied Owner\"\n#define NID_sendProxiedOwner            1030\n#define OBJ_sendProxiedOwner            OBJ_id_kp,26L\n\n#define SN_cmcCA                \"cmcCA\"\n#define LN_cmcCA                \"CMC Certificate Authority\"\n#define NID_cmcCA               1131\n#define OBJ_cmcCA               OBJ_id_kp,27L\n\n#define SN_cmcRA                \"cmcRA\"\n#define LN_cmcRA                \"CMC Registration Authority\"\n#define NID_cmcRA               1132\n#define OBJ_cmcRA               OBJ_id_kp,28L\n\n#define SN_id_it_caProtEncCert          \"id-it-caProtEncCert\"\n#define NID_id_it_caProtEncCert         298\n#define OBJ_id_it_caProtEncCert         OBJ_id_it,1L\n\n#define SN_id_it_signKeyPairTypes               \"id-it-signKeyPairTypes\"\n#define NID_id_it_signKeyPairTypes              299\n#define OBJ_id_it_signKeyPairTypes              OBJ_id_it,2L\n\n#define SN_id_it_encKeyPairTypes                \"id-it-encKeyPairTypes\"\n#define NID_id_it_encKeyPairTypes               300\n#define OBJ_id_it_encKeyPairTypes               OBJ_id_it,3L\n\n#define SN_id_it_preferredSymmAlg               \"id-it-preferredSymmAlg\"\n#define NID_id_it_preferredSymmAlg              301\n#define OBJ_id_it_preferredSymmAlg              OBJ_id_it,4L\n\n#define SN_id_it_caKeyUpdateInfo                \"id-it-caKeyUpdateInfo\"\n#define NID_id_it_caKeyUpdateInfo               302\n#define OBJ_id_it_caKeyUpdateInfo               OBJ_id_it,5L\n\n#define SN_id_it_currentCRL             \"id-it-currentCRL\"\n#define NID_id_it_currentCRL            303\n#define OBJ_id_it_currentCRL            OBJ_id_it,6L\n\n#define SN_id_it_unsupportedOIDs                \"id-it-unsupportedOIDs\"\n#define NID_id_it_unsupportedOIDs               304\n#define OBJ_id_it_unsupportedOIDs               OBJ_id_it,7L\n\n#define SN_id_it_subscriptionRequest            \"id-it-subscriptionRequest\"\n#define NID_id_it_subscriptionRequest           305\n#define OBJ_id_it_subscriptionRequest           OBJ_id_it,8L\n\n#define SN_id_it_subscriptionResponse           \"id-it-subscriptionResponse\"\n#define NID_id_it_subscriptionResponse          306\n#define OBJ_id_it_subscriptionResponse          OBJ_id_it,9L\n\n#define SN_id_it_keyPairParamReq                \"id-it-keyPairParamReq\"\n#define NID_id_it_keyPairParamReq               307\n#define OBJ_id_it_keyPairParamReq               OBJ_id_it,10L\n\n#define SN_id_it_keyPairParamRep                \"id-it-keyPairParamRep\"\n#define NID_id_it_keyPairParamRep               308\n#define OBJ_id_it_keyPairParamRep               OBJ_id_it,11L\n\n#define SN_id_it_revPassphrase          \"id-it-revPassphrase\"\n#define NID_id_it_revPassphrase         309\n#define OBJ_id_it_revPassphrase         OBJ_id_it,12L\n\n#define SN_id_it_implicitConfirm                \"id-it-implicitConfirm\"\n#define NID_id_it_implicitConfirm               310\n#define OBJ_id_it_implicitConfirm               OBJ_id_it,13L\n\n#define SN_id_it_confirmWaitTime                \"id-it-confirmWaitTime\"\n#define NID_id_it_confirmWaitTime               311\n#define OBJ_id_it_confirmWaitTime               OBJ_id_it,14L\n\n#define SN_id_it_origPKIMessage         \"id-it-origPKIMessage\"\n#define NID_id_it_origPKIMessage                312\n#define OBJ_id_it_origPKIMessage                OBJ_id_it,15L\n\n#define SN_id_it_suppLangTags           \"id-it-suppLangTags\"\n#define NID_id_it_suppLangTags          784\n#define OBJ_id_it_suppLangTags          OBJ_id_it,16L\n\n#define SN_id_regCtrl           \"id-regCtrl\"\n#define NID_id_regCtrl          313\n#define OBJ_id_regCtrl          OBJ_id_pkip,1L\n\n#define SN_id_regInfo           \"id-regInfo\"\n#define NID_id_regInfo          314\n#define OBJ_id_regInfo          OBJ_id_pkip,2L\n\n#define SN_id_regCtrl_regToken          \"id-regCtrl-regToken\"\n#define NID_id_regCtrl_regToken         315\n#define OBJ_id_regCtrl_regToken         OBJ_id_regCtrl,1L\n\n#define SN_id_regCtrl_authenticator             \"id-regCtrl-authenticator\"\n#define NID_id_regCtrl_authenticator            316\n#define OBJ_id_regCtrl_authenticator            OBJ_id_regCtrl,2L\n\n#define SN_id_regCtrl_pkiPublicationInfo                \"id-regCtrl-pkiPublicationInfo\"\n#define NID_id_regCtrl_pkiPublicationInfo               317\n#define OBJ_id_regCtrl_pkiPublicationInfo               OBJ_id_regCtrl,3L\n\n#define SN_id_regCtrl_pkiArchiveOptions         \"id-regCtrl-pkiArchiveOptions\"\n#define NID_id_regCtrl_pkiArchiveOptions                318\n#define OBJ_id_regCtrl_pkiArchiveOptions                OBJ_id_regCtrl,4L\n\n#define SN_id_regCtrl_oldCertID         \"id-regCtrl-oldCertID\"\n#define NID_id_regCtrl_oldCertID                319\n#define OBJ_id_regCtrl_oldCertID                OBJ_id_regCtrl,5L\n\n#define SN_id_regCtrl_protocolEncrKey           \"id-regCtrl-protocolEncrKey\"\n#define NID_id_regCtrl_protocolEncrKey          320\n#define OBJ_id_regCtrl_protocolEncrKey          OBJ_id_regCtrl,6L\n\n#define SN_id_regInfo_utf8Pairs         \"id-regInfo-utf8Pairs\"\n#define NID_id_regInfo_utf8Pairs                321\n#define OBJ_id_regInfo_utf8Pairs                OBJ_id_regInfo,1L\n\n#define SN_id_regInfo_certReq           \"id-regInfo-certReq\"\n#define NID_id_regInfo_certReq          322\n#define OBJ_id_regInfo_certReq          OBJ_id_regInfo,2L\n\n#define SN_id_alg_des40         \"id-alg-des40\"\n#define NID_id_alg_des40                323\n#define OBJ_id_alg_des40                OBJ_id_alg,1L\n\n#define SN_id_alg_noSignature           \"id-alg-noSignature\"\n#define NID_id_alg_noSignature          324\n#define OBJ_id_alg_noSignature          OBJ_id_alg,2L\n\n#define SN_id_alg_dh_sig_hmac_sha1              \"id-alg-dh-sig-hmac-sha1\"\n#define NID_id_alg_dh_sig_hmac_sha1             325\n#define OBJ_id_alg_dh_sig_hmac_sha1             OBJ_id_alg,3L\n\n#define SN_id_alg_dh_pop                \"id-alg-dh-pop\"\n#define NID_id_alg_dh_pop               326\n#define OBJ_id_alg_dh_pop               OBJ_id_alg,4L\n\n#define SN_id_cmc_statusInfo            \"id-cmc-statusInfo\"\n#define NID_id_cmc_statusInfo           327\n#define OBJ_id_cmc_statusInfo           OBJ_id_cmc,1L\n\n#define SN_id_cmc_identification                \"id-cmc-identification\"\n#define NID_id_cmc_identification               328\n#define OBJ_id_cmc_identification               OBJ_id_cmc,2L\n\n#define SN_id_cmc_identityProof         \"id-cmc-identityProof\"\n#define NID_id_cmc_identityProof                329\n#define OBJ_id_cmc_identityProof                OBJ_id_cmc,3L\n\n#define SN_id_cmc_dataReturn            \"id-cmc-dataReturn\"\n#define NID_id_cmc_dataReturn           330\n#define OBJ_id_cmc_dataReturn           OBJ_id_cmc,4L\n\n#define SN_id_cmc_transactionId         \"id-cmc-transactionId\"\n#define NID_id_cmc_transactionId                331\n#define OBJ_id_cmc_transactionId                OBJ_id_cmc,5L\n\n#define SN_id_cmc_senderNonce           \"id-cmc-senderNonce\"\n#define NID_id_cmc_senderNonce          332\n#define OBJ_id_cmc_senderNonce          OBJ_id_cmc,6L\n\n#define SN_id_cmc_recipientNonce                \"id-cmc-recipientNonce\"\n#define NID_id_cmc_recipientNonce               333\n#define OBJ_id_cmc_recipientNonce               OBJ_id_cmc,7L\n\n#define SN_id_cmc_addExtensions         \"id-cmc-addExtensions\"\n#define NID_id_cmc_addExtensions                334\n#define OBJ_id_cmc_addExtensions                OBJ_id_cmc,8L\n\n#define SN_id_cmc_encryptedPOP          \"id-cmc-encryptedPOP\"\n#define NID_id_cmc_encryptedPOP         335\n#define OBJ_id_cmc_encryptedPOP         OBJ_id_cmc,9L\n\n#define SN_id_cmc_decryptedPOP          \"id-cmc-decryptedPOP\"\n#define NID_id_cmc_decryptedPOP         336\n#define OBJ_id_cmc_decryptedPOP         OBJ_id_cmc,10L\n\n#define SN_id_cmc_lraPOPWitness         \"id-cmc-lraPOPWitness\"\n#define NID_id_cmc_lraPOPWitness                337\n#define OBJ_id_cmc_lraPOPWitness                OBJ_id_cmc,11L\n\n#define SN_id_cmc_getCert               \"id-cmc-getCert\"\n#define NID_id_cmc_getCert              338\n#define OBJ_id_cmc_getCert              OBJ_id_cmc,15L\n\n#define SN_id_cmc_getCRL                \"id-cmc-getCRL\"\n#define NID_id_cmc_getCRL               339\n#define OBJ_id_cmc_getCRL               OBJ_id_cmc,16L\n\n#define SN_id_cmc_revokeRequest         \"id-cmc-revokeRequest\"\n#define NID_id_cmc_revokeRequest                340\n#define OBJ_id_cmc_revokeRequest                OBJ_id_cmc,17L\n\n#define SN_id_cmc_regInfo               \"id-cmc-regInfo\"\n#define NID_id_cmc_regInfo              341\n#define OBJ_id_cmc_regInfo              OBJ_id_cmc,18L\n\n#define SN_id_cmc_responseInfo          \"id-cmc-responseInfo\"\n#define NID_id_cmc_responseInfo         342\n#define OBJ_id_cmc_responseInfo         OBJ_id_cmc,19L\n\n#define SN_id_cmc_queryPending          \"id-cmc-queryPending\"\n#define NID_id_cmc_queryPending         343\n#define OBJ_id_cmc_queryPending         OBJ_id_cmc,21L\n\n#define SN_id_cmc_popLinkRandom         \"id-cmc-popLinkRandom\"\n#define NID_id_cmc_popLinkRandom                344\n#define OBJ_id_cmc_popLinkRandom                OBJ_id_cmc,22L\n\n#define SN_id_cmc_popLinkWitness                \"id-cmc-popLinkWitness\"\n#define NID_id_cmc_popLinkWitness               345\n#define OBJ_id_cmc_popLinkWitness               OBJ_id_cmc,23L\n\n#define SN_id_cmc_confirmCertAcceptance         \"id-cmc-confirmCertAcceptance\"\n#define NID_id_cmc_confirmCertAcceptance                346\n#define OBJ_id_cmc_confirmCertAcceptance                OBJ_id_cmc,24L\n\n#define SN_id_on_personalData           \"id-on-personalData\"\n#define NID_id_on_personalData          347\n#define OBJ_id_on_personalData          OBJ_id_on,1L\n\n#define SN_id_on_permanentIdentifier            \"id-on-permanentIdentifier\"\n#define LN_id_on_permanentIdentifier            \"Permanent Identifier\"\n#define NID_id_on_permanentIdentifier           858\n#define OBJ_id_on_permanentIdentifier           OBJ_id_on,3L\n\n#define SN_id_pda_dateOfBirth           \"id-pda-dateOfBirth\"\n#define NID_id_pda_dateOfBirth          348\n#define OBJ_id_pda_dateOfBirth          OBJ_id_pda,1L\n\n#define SN_id_pda_placeOfBirth          \"id-pda-placeOfBirth\"\n#define NID_id_pda_placeOfBirth         349\n#define OBJ_id_pda_placeOfBirth         OBJ_id_pda,2L\n\n#define SN_id_pda_gender                \"id-pda-gender\"\n#define NID_id_pda_gender               351\n#define OBJ_id_pda_gender               OBJ_id_pda,3L\n\n#define SN_id_pda_countryOfCitizenship          \"id-pda-countryOfCitizenship\"\n#define NID_id_pda_countryOfCitizenship         352\n#define OBJ_id_pda_countryOfCitizenship         OBJ_id_pda,4L\n\n#define SN_id_pda_countryOfResidence            \"id-pda-countryOfResidence\"\n#define NID_id_pda_countryOfResidence           353\n#define OBJ_id_pda_countryOfResidence           OBJ_id_pda,5L\n\n#define SN_id_aca_authenticationInfo            \"id-aca-authenticationInfo\"\n#define NID_id_aca_authenticationInfo           354\n#define OBJ_id_aca_authenticationInfo           OBJ_id_aca,1L\n\n#define SN_id_aca_accessIdentity                \"id-aca-accessIdentity\"\n#define NID_id_aca_accessIdentity               355\n#define OBJ_id_aca_accessIdentity               OBJ_id_aca,2L\n\n#define SN_id_aca_chargingIdentity              \"id-aca-chargingIdentity\"\n#define NID_id_aca_chargingIdentity             356\n#define OBJ_id_aca_chargingIdentity             OBJ_id_aca,3L\n\n#define SN_id_aca_group         \"id-aca-group\"\n#define NID_id_aca_group                357\n#define OBJ_id_aca_group                OBJ_id_aca,4L\n\n#define SN_id_aca_role          \"id-aca-role\"\n#define NID_id_aca_role         358\n#define OBJ_id_aca_role         OBJ_id_aca,5L\n\n#define SN_id_aca_encAttrs              \"id-aca-encAttrs\"\n#define NID_id_aca_encAttrs             399\n#define OBJ_id_aca_encAttrs             OBJ_id_aca,6L\n\n#define SN_id_qcs_pkixQCSyntax_v1               \"id-qcs-pkixQCSyntax-v1\"\n#define NID_id_qcs_pkixQCSyntax_v1              359\n#define OBJ_id_qcs_pkixQCSyntax_v1              OBJ_id_qcs,1L\n\n#define SN_id_cct_crs           \"id-cct-crs\"\n#define NID_id_cct_crs          360\n#define OBJ_id_cct_crs          OBJ_id_cct,1L\n\n#define SN_id_cct_PKIData               \"id-cct-PKIData\"\n#define NID_id_cct_PKIData              361\n#define OBJ_id_cct_PKIData              OBJ_id_cct,2L\n\n#define SN_id_cct_PKIResponse           \"id-cct-PKIResponse\"\n#define NID_id_cct_PKIResponse          362\n#define OBJ_id_cct_PKIResponse          OBJ_id_cct,3L\n\n#define SN_id_ppl_anyLanguage           \"id-ppl-anyLanguage\"\n#define LN_id_ppl_anyLanguage           \"Any language\"\n#define NID_id_ppl_anyLanguage          664\n#define OBJ_id_ppl_anyLanguage          OBJ_id_ppl,0L\n\n#define SN_id_ppl_inheritAll            \"id-ppl-inheritAll\"\n#define LN_id_ppl_inheritAll            \"Inherit all\"\n#define NID_id_ppl_inheritAll           665\n#define OBJ_id_ppl_inheritAll           OBJ_id_ppl,1L\n\n#define SN_Independent          \"id-ppl-independent\"\n#define LN_Independent          \"Independent\"\n#define NID_Independent         667\n#define OBJ_Independent         OBJ_id_ppl,2L\n\n#define SN_ad_OCSP              \"OCSP\"\n#define LN_ad_OCSP              \"OCSP\"\n#define NID_ad_OCSP             178\n#define OBJ_ad_OCSP             OBJ_id_ad,1L\n\n#define SN_ad_ca_issuers                \"caIssuers\"\n#define LN_ad_ca_issuers                \"CA Issuers\"\n#define NID_ad_ca_issuers               179\n#define OBJ_ad_ca_issuers               OBJ_id_ad,2L\n\n#define SN_ad_timeStamping              \"ad_timestamping\"\n#define LN_ad_timeStamping              \"AD Time Stamping\"\n#define NID_ad_timeStamping             363\n#define OBJ_ad_timeStamping             OBJ_id_ad,3L\n\n#define SN_ad_dvcs              \"AD_DVCS\"\n#define LN_ad_dvcs              \"ad dvcs\"\n#define NID_ad_dvcs             364\n#define OBJ_ad_dvcs             OBJ_id_ad,4L\n\n#define SN_caRepository         \"caRepository\"\n#define LN_caRepository         \"CA Repository\"\n#define NID_caRepository                785\n#define OBJ_caRepository                OBJ_id_ad,5L\n\n#define OBJ_id_pkix_OCSP                OBJ_ad_OCSP\n\n#define SN_id_pkix_OCSP_basic           \"basicOCSPResponse\"\n#define LN_id_pkix_OCSP_basic           \"Basic OCSP Response\"\n#define NID_id_pkix_OCSP_basic          365\n#define OBJ_id_pkix_OCSP_basic          OBJ_id_pkix_OCSP,1L\n\n#define SN_id_pkix_OCSP_Nonce           \"Nonce\"\n#define LN_id_pkix_OCSP_Nonce           \"OCSP Nonce\"\n#define NID_id_pkix_OCSP_Nonce          366\n#define OBJ_id_pkix_OCSP_Nonce          OBJ_id_pkix_OCSP,2L\n\n#define SN_id_pkix_OCSP_CrlID           \"CrlID\"\n#define LN_id_pkix_OCSP_CrlID           \"OCSP CRL ID\"\n#define NID_id_pkix_OCSP_CrlID          367\n#define OBJ_id_pkix_OCSP_CrlID          OBJ_id_pkix_OCSP,3L\n\n#define SN_id_pkix_OCSP_acceptableResponses             \"acceptableResponses\"\n#define LN_id_pkix_OCSP_acceptableResponses             \"Acceptable OCSP Responses\"\n#define NID_id_pkix_OCSP_acceptableResponses            368\n#define OBJ_id_pkix_OCSP_acceptableResponses            OBJ_id_pkix_OCSP,4L\n\n#define SN_id_pkix_OCSP_noCheck         \"noCheck\"\n#define LN_id_pkix_OCSP_noCheck         \"OCSP No Check\"\n#define NID_id_pkix_OCSP_noCheck                369\n#define OBJ_id_pkix_OCSP_noCheck                OBJ_id_pkix_OCSP,5L\n\n#define SN_id_pkix_OCSP_archiveCutoff           \"archiveCutoff\"\n#define LN_id_pkix_OCSP_archiveCutoff           \"OCSP Archive Cutoff\"\n#define NID_id_pkix_OCSP_archiveCutoff          370\n#define OBJ_id_pkix_OCSP_archiveCutoff          OBJ_id_pkix_OCSP,6L\n\n#define SN_id_pkix_OCSP_serviceLocator          \"serviceLocator\"\n#define LN_id_pkix_OCSP_serviceLocator          \"OCSP Service Locator\"\n#define NID_id_pkix_OCSP_serviceLocator         371\n#define OBJ_id_pkix_OCSP_serviceLocator         OBJ_id_pkix_OCSP,7L\n\n#define SN_id_pkix_OCSP_extendedStatus          \"extendedStatus\"\n#define LN_id_pkix_OCSP_extendedStatus          \"Extended OCSP Status\"\n#define NID_id_pkix_OCSP_extendedStatus         372\n#define OBJ_id_pkix_OCSP_extendedStatus         OBJ_id_pkix_OCSP,8L\n\n#define SN_id_pkix_OCSP_valid           \"valid\"\n#define NID_id_pkix_OCSP_valid          373\n#define OBJ_id_pkix_OCSP_valid          OBJ_id_pkix_OCSP,9L\n\n#define SN_id_pkix_OCSP_path            \"path\"\n#define NID_id_pkix_OCSP_path           374\n#define OBJ_id_pkix_OCSP_path           OBJ_id_pkix_OCSP,10L\n\n#define SN_id_pkix_OCSP_trustRoot               \"trustRoot\"\n#define LN_id_pkix_OCSP_trustRoot               \"Trust Root\"\n#define NID_id_pkix_OCSP_trustRoot              375\n#define OBJ_id_pkix_OCSP_trustRoot              OBJ_id_pkix_OCSP,11L\n\n#define SN_algorithm            \"algorithm\"\n#define LN_algorithm            \"algorithm\"\n#define NID_algorithm           376\n#define OBJ_algorithm           1L,3L,14L,3L,2L\n\n#define SN_md5WithRSA           \"RSA-NP-MD5\"\n#define LN_md5WithRSA           \"md5WithRSA\"\n#define NID_md5WithRSA          104\n#define OBJ_md5WithRSA          OBJ_algorithm,3L\n\n#define SN_des_ecb              \"DES-ECB\"\n#define LN_des_ecb              \"des-ecb\"\n#define NID_des_ecb             29\n#define OBJ_des_ecb             OBJ_algorithm,6L\n\n#define SN_des_cbc              \"DES-CBC\"\n#define LN_des_cbc              \"des-cbc\"\n#define NID_des_cbc             31\n#define OBJ_des_cbc             OBJ_algorithm,7L\n\n#define SN_des_ofb64            \"DES-OFB\"\n#define LN_des_ofb64            \"des-ofb\"\n#define NID_des_ofb64           45\n#define OBJ_des_ofb64           OBJ_algorithm,8L\n\n#define SN_des_cfb64            \"DES-CFB\"\n#define LN_des_cfb64            \"des-cfb\"\n#define NID_des_cfb64           30\n#define OBJ_des_cfb64           OBJ_algorithm,9L\n\n#define SN_rsaSignature         \"rsaSignature\"\n#define NID_rsaSignature                377\n#define OBJ_rsaSignature                OBJ_algorithm,11L\n\n#define SN_dsa_2                \"DSA-old\"\n#define LN_dsa_2                \"dsaEncryption-old\"\n#define NID_dsa_2               67\n#define OBJ_dsa_2               OBJ_algorithm,12L\n\n#define SN_dsaWithSHA           \"DSA-SHA\"\n#define LN_dsaWithSHA           \"dsaWithSHA\"\n#define NID_dsaWithSHA          66\n#define OBJ_dsaWithSHA          OBJ_algorithm,13L\n\n#define SN_shaWithRSAEncryption         \"RSA-SHA\"\n#define LN_shaWithRSAEncryption         \"shaWithRSAEncryption\"\n#define NID_shaWithRSAEncryption                42\n#define OBJ_shaWithRSAEncryption                OBJ_algorithm,15L\n\n#define SN_des_ede_ecb          \"DES-EDE\"\n#define LN_des_ede_ecb          \"des-ede\"\n#define NID_des_ede_ecb         32\n#define OBJ_des_ede_ecb         OBJ_algorithm,17L\n\n#define SN_des_ede3_ecb         \"DES-EDE3\"\n#define LN_des_ede3_ecb         \"des-ede3\"\n#define NID_des_ede3_ecb                33\n\n#define SN_des_ede_cbc          \"DES-EDE-CBC\"\n#define LN_des_ede_cbc          \"des-ede-cbc\"\n#define NID_des_ede_cbc         43\n\n#define SN_des_ede_cfb64                \"DES-EDE-CFB\"\n#define LN_des_ede_cfb64                \"des-ede-cfb\"\n#define NID_des_ede_cfb64               60\n\n#define SN_des_ede3_cfb64               \"DES-EDE3-CFB\"\n#define LN_des_ede3_cfb64               \"des-ede3-cfb\"\n#define NID_des_ede3_cfb64              61\n\n#define SN_des_ede_ofb64                \"DES-EDE-OFB\"\n#define LN_des_ede_ofb64                \"des-ede-ofb\"\n#define NID_des_ede_ofb64               62\n\n#define SN_des_ede3_ofb64               \"DES-EDE3-OFB\"\n#define LN_des_ede3_ofb64               \"des-ede3-ofb\"\n#define NID_des_ede3_ofb64              63\n\n#define SN_desx_cbc             \"DESX-CBC\"\n#define LN_desx_cbc             \"desx-cbc\"\n#define NID_desx_cbc            80\n\n#define SN_sha          \"SHA\"\n#define LN_sha          \"sha\"\n#define NID_sha         41\n#define OBJ_sha         OBJ_algorithm,18L\n\n#define SN_sha1         \"SHA1\"\n#define LN_sha1         \"sha1\"\n#define NID_sha1                64\n#define OBJ_sha1                OBJ_algorithm,26L\n\n#define SN_dsaWithSHA1_2                \"DSA-SHA1-old\"\n#define LN_dsaWithSHA1_2                \"dsaWithSHA1-old\"\n#define NID_dsaWithSHA1_2               70\n#define OBJ_dsaWithSHA1_2               OBJ_algorithm,27L\n\n#define SN_sha1WithRSA          \"RSA-SHA1-2\"\n#define LN_sha1WithRSA          \"sha1WithRSA\"\n#define NID_sha1WithRSA         115\n#define OBJ_sha1WithRSA         OBJ_algorithm,29L\n\n#define SN_ripemd160            \"RIPEMD160\"\n#define LN_ripemd160            \"ripemd160\"\n#define NID_ripemd160           117\n#define OBJ_ripemd160           1L,3L,36L,3L,2L,1L\n\n#define SN_ripemd160WithRSA             \"RSA-RIPEMD160\"\n#define LN_ripemd160WithRSA             \"ripemd160WithRSA\"\n#define NID_ripemd160WithRSA            119\n#define OBJ_ripemd160WithRSA            1L,3L,36L,3L,3L,1L,2L\n\n#define SN_blake2b512           \"BLAKE2b512\"\n#define LN_blake2b512           \"blake2b512\"\n#define NID_blake2b512          1056\n#define OBJ_blake2b512          1L,3L,6L,1L,4L,1L,1722L,12L,2L,1L,16L\n\n#define SN_blake2s256           \"BLAKE2s256\"\n#define LN_blake2s256           \"blake2s256\"\n#define NID_blake2s256          1057\n#define OBJ_blake2s256          1L,3L,6L,1L,4L,1L,1722L,12L,2L,2L,8L\n\n#define SN_sxnet                \"SXNetID\"\n#define LN_sxnet                \"Strong Extranet ID\"\n#define NID_sxnet               143\n#define OBJ_sxnet               1L,3L,101L,1L,4L,1L\n\n#define SN_X500         \"X500\"\n#define LN_X500         \"directory services (X.500)\"\n#define NID_X500                11\n#define OBJ_X500                2L,5L\n\n#define SN_X509         \"X509\"\n#define NID_X509                12\n#define OBJ_X509                OBJ_X500,4L\n\n#define SN_commonName           \"CN\"\n#define LN_commonName           \"commonName\"\n#define NID_commonName          13\n#define OBJ_commonName          OBJ_X509,3L\n\n#define SN_surname              \"SN\"\n#define LN_surname              \"surname\"\n#define NID_surname             100\n#define OBJ_surname             OBJ_X509,4L\n\n#define LN_serialNumber         \"serialNumber\"\n#define NID_serialNumber                105\n#define OBJ_serialNumber                OBJ_X509,5L\n\n#define SN_countryName          \"C\"\n#define LN_countryName          \"countryName\"\n#define NID_countryName         14\n#define OBJ_countryName         OBJ_X509,6L\n\n#define SN_localityName         \"L\"\n#define LN_localityName         \"localityName\"\n#define NID_localityName                15\n#define OBJ_localityName                OBJ_X509,7L\n\n#define SN_stateOrProvinceName          \"ST\"\n#define LN_stateOrProvinceName          \"stateOrProvinceName\"\n#define NID_stateOrProvinceName         16\n#define OBJ_stateOrProvinceName         OBJ_X509,8L\n\n#define SN_streetAddress                \"street\"\n#define LN_streetAddress                \"streetAddress\"\n#define NID_streetAddress               660\n#define OBJ_streetAddress               OBJ_X509,9L\n\n#define SN_organizationName             \"O\"\n#define LN_organizationName             \"organizationName\"\n#define NID_organizationName            17\n#define OBJ_organizationName            OBJ_X509,10L\n\n#define SN_organizationalUnitName               \"OU\"\n#define LN_organizationalUnitName               \"organizationalUnitName\"\n#define NID_organizationalUnitName              18\n#define OBJ_organizationalUnitName              OBJ_X509,11L\n\n#define SN_title                \"title\"\n#define LN_title                \"title\"\n#define NID_title               106\n#define OBJ_title               OBJ_X509,12L\n\n#define LN_description          \"description\"\n#define NID_description         107\n#define OBJ_description         OBJ_X509,13L\n\n#define LN_searchGuide          \"searchGuide\"\n#define NID_searchGuide         859\n#define OBJ_searchGuide         OBJ_X509,14L\n\n#define LN_businessCategory             \"businessCategory\"\n#define NID_businessCategory            860\n#define OBJ_businessCategory            OBJ_X509,15L\n\n#define LN_postalAddress                \"postalAddress\"\n#define NID_postalAddress               861\n#define OBJ_postalAddress               OBJ_X509,16L\n\n#define LN_postalCode           \"postalCode\"\n#define NID_postalCode          661\n#define OBJ_postalCode          OBJ_X509,17L\n\n#define LN_postOfficeBox                \"postOfficeBox\"\n#define NID_postOfficeBox               862\n#define OBJ_postOfficeBox               OBJ_X509,18L\n\n#define LN_physicalDeliveryOfficeName           \"physicalDeliveryOfficeName\"\n#define NID_physicalDeliveryOfficeName          863\n#define OBJ_physicalDeliveryOfficeName          OBJ_X509,19L\n\n#define LN_telephoneNumber              \"telephoneNumber\"\n#define NID_telephoneNumber             864\n#define OBJ_telephoneNumber             OBJ_X509,20L\n\n#define LN_telexNumber          \"telexNumber\"\n#define NID_telexNumber         865\n#define OBJ_telexNumber         OBJ_X509,21L\n\n#define LN_teletexTerminalIdentifier            \"teletexTerminalIdentifier\"\n#define NID_teletexTerminalIdentifier           866\n#define OBJ_teletexTerminalIdentifier           OBJ_X509,22L\n\n#define LN_facsimileTelephoneNumber             \"facsimileTelephoneNumber\"\n#define NID_facsimileTelephoneNumber            867\n#define OBJ_facsimileTelephoneNumber            OBJ_X509,23L\n\n#define LN_x121Address          \"x121Address\"\n#define NID_x121Address         868\n#define OBJ_x121Address         OBJ_X509,24L\n\n#define LN_internationaliSDNNumber              \"internationaliSDNNumber\"\n#define NID_internationaliSDNNumber             869\n#define OBJ_internationaliSDNNumber             OBJ_X509,25L\n\n#define LN_registeredAddress            \"registeredAddress\"\n#define NID_registeredAddress           870\n#define OBJ_registeredAddress           OBJ_X509,26L\n\n#define LN_destinationIndicator         \"destinationIndicator\"\n#define NID_destinationIndicator                871\n#define OBJ_destinationIndicator                OBJ_X509,27L\n\n#define LN_preferredDeliveryMethod              \"preferredDeliveryMethod\"\n#define NID_preferredDeliveryMethod             872\n#define OBJ_preferredDeliveryMethod             OBJ_X509,28L\n\n#define LN_presentationAddress          \"presentationAddress\"\n#define NID_presentationAddress         873\n#define OBJ_presentationAddress         OBJ_X509,29L\n\n#define LN_supportedApplicationContext          \"supportedApplicationContext\"\n#define NID_supportedApplicationContext         874\n#define OBJ_supportedApplicationContext         OBJ_X509,30L\n\n#define SN_member               \"member\"\n#define NID_member              875\n#define OBJ_member              OBJ_X509,31L\n\n#define SN_owner                \"owner\"\n#define NID_owner               876\n#define OBJ_owner               OBJ_X509,32L\n\n#define LN_roleOccupant         \"roleOccupant\"\n#define NID_roleOccupant                877\n#define OBJ_roleOccupant                OBJ_X509,33L\n\n#define SN_seeAlso              \"seeAlso\"\n#define NID_seeAlso             878\n#define OBJ_seeAlso             OBJ_X509,34L\n\n#define LN_userPassword         \"userPassword\"\n#define NID_userPassword                879\n#define OBJ_userPassword                OBJ_X509,35L\n\n#define LN_userCertificate              \"userCertificate\"\n#define NID_userCertificate             880\n#define OBJ_userCertificate             OBJ_X509,36L\n\n#define LN_cACertificate                \"cACertificate\"\n#define NID_cACertificate               881\n#define OBJ_cACertificate               OBJ_X509,37L\n\n#define LN_authorityRevocationList              \"authorityRevocationList\"\n#define NID_authorityRevocationList             882\n#define OBJ_authorityRevocationList             OBJ_X509,38L\n\n#define LN_certificateRevocationList            \"certificateRevocationList\"\n#define NID_certificateRevocationList           883\n#define OBJ_certificateRevocationList           OBJ_X509,39L\n\n#define LN_crossCertificatePair         \"crossCertificatePair\"\n#define NID_crossCertificatePair                884\n#define OBJ_crossCertificatePair                OBJ_X509,40L\n\n#define SN_name         \"name\"\n#define LN_name         \"name\"\n#define NID_name                173\n#define OBJ_name                OBJ_X509,41L\n\n#define SN_givenName            \"GN\"\n#define LN_givenName            \"givenName\"\n#define NID_givenName           99\n#define OBJ_givenName           OBJ_X509,42L\n\n#define SN_initials             \"initials\"\n#define LN_initials             \"initials\"\n#define NID_initials            101\n#define OBJ_initials            OBJ_X509,43L\n\n#define LN_generationQualifier          \"generationQualifier\"\n#define NID_generationQualifier         509\n#define OBJ_generationQualifier         OBJ_X509,44L\n\n#define LN_x500UniqueIdentifier         \"x500UniqueIdentifier\"\n#define NID_x500UniqueIdentifier                503\n#define OBJ_x500UniqueIdentifier                OBJ_X509,45L\n\n#define SN_dnQualifier          \"dnQualifier\"\n#define LN_dnQualifier          \"dnQualifier\"\n#define NID_dnQualifier         174\n#define OBJ_dnQualifier         OBJ_X509,46L\n\n#define LN_enhancedSearchGuide          \"enhancedSearchGuide\"\n#define NID_enhancedSearchGuide         885\n#define OBJ_enhancedSearchGuide         OBJ_X509,47L\n\n#define LN_protocolInformation          \"protocolInformation\"\n#define NID_protocolInformation         886\n#define OBJ_protocolInformation         OBJ_X509,48L\n\n#define LN_distinguishedName            \"distinguishedName\"\n#define NID_distinguishedName           887\n#define OBJ_distinguishedName           OBJ_X509,49L\n\n#define LN_uniqueMember         \"uniqueMember\"\n#define NID_uniqueMember                888\n#define OBJ_uniqueMember                OBJ_X509,50L\n\n#define LN_houseIdentifier              \"houseIdentifier\"\n#define NID_houseIdentifier             889\n#define OBJ_houseIdentifier             OBJ_X509,51L\n\n#define LN_supportedAlgorithms          \"supportedAlgorithms\"\n#define NID_supportedAlgorithms         890\n#define OBJ_supportedAlgorithms         OBJ_X509,52L\n\n#define LN_deltaRevocationList          \"deltaRevocationList\"\n#define NID_deltaRevocationList         891\n#define OBJ_deltaRevocationList         OBJ_X509,53L\n\n#define SN_dmdName              \"dmdName\"\n#define NID_dmdName             892\n#define OBJ_dmdName             OBJ_X509,54L\n\n#define LN_pseudonym            \"pseudonym\"\n#define NID_pseudonym           510\n#define OBJ_pseudonym           OBJ_X509,65L\n\n#define SN_role         \"role\"\n#define LN_role         \"role\"\n#define NID_role                400\n#define OBJ_role                OBJ_X509,72L\n\n#define LN_organizationIdentifier               \"organizationIdentifier\"\n#define NID_organizationIdentifier              1089\n#define OBJ_organizationIdentifier              OBJ_X509,97L\n\n#define SN_countryCode3c                \"c3\"\n#define LN_countryCode3c                \"countryCode3c\"\n#define NID_countryCode3c               1090\n#define OBJ_countryCode3c               OBJ_X509,98L\n\n#define SN_countryCode3n                \"n3\"\n#define LN_countryCode3n                \"countryCode3n\"\n#define NID_countryCode3n               1091\n#define OBJ_countryCode3n               OBJ_X509,99L\n\n#define LN_dnsName              \"dnsName\"\n#define NID_dnsName             1092\n#define OBJ_dnsName             OBJ_X509,100L\n\n#define SN_X500algorithms               \"X500algorithms\"\n#define LN_X500algorithms               \"directory services - algorithms\"\n#define NID_X500algorithms              378\n#define OBJ_X500algorithms              OBJ_X500,8L\n\n#define SN_rsa          \"RSA\"\n#define LN_rsa          \"rsa\"\n#define NID_rsa         19\n#define OBJ_rsa         OBJ_X500algorithms,1L,1L\n\n#define SN_mdc2WithRSA          \"RSA-MDC2\"\n#define LN_mdc2WithRSA          \"mdc2WithRSA\"\n#define NID_mdc2WithRSA         96\n#define OBJ_mdc2WithRSA         OBJ_X500algorithms,3L,100L\n\n#define SN_mdc2         \"MDC2\"\n#define LN_mdc2         \"mdc2\"\n#define NID_mdc2                95\n#define OBJ_mdc2                OBJ_X500algorithms,3L,101L\n\n#define SN_id_ce                \"id-ce\"\n#define NID_id_ce               81\n#define OBJ_id_ce               OBJ_X500,29L\n\n#define SN_subject_directory_attributes         \"subjectDirectoryAttributes\"\n#define LN_subject_directory_attributes         \"X509v3 Subject Directory Attributes\"\n#define NID_subject_directory_attributes                769\n#define OBJ_subject_directory_attributes                OBJ_id_ce,9L\n\n#define SN_subject_key_identifier               \"subjectKeyIdentifier\"\n#define LN_subject_key_identifier               \"X509v3 Subject Key Identifier\"\n#define NID_subject_key_identifier              82\n#define OBJ_subject_key_identifier              OBJ_id_ce,14L\n\n#define SN_key_usage            \"keyUsage\"\n#define LN_key_usage            \"X509v3 Key Usage\"\n#define NID_key_usage           83\n#define OBJ_key_usage           OBJ_id_ce,15L\n\n#define SN_private_key_usage_period             \"privateKeyUsagePeriod\"\n#define LN_private_key_usage_period             \"X509v3 Private Key Usage Period\"\n#define NID_private_key_usage_period            84\n#define OBJ_private_key_usage_period            OBJ_id_ce,16L\n\n#define SN_subject_alt_name             \"subjectAltName\"\n#define LN_subject_alt_name             \"X509v3 Subject Alternative Name\"\n#define NID_subject_alt_name            85\n#define OBJ_subject_alt_name            OBJ_id_ce,17L\n\n#define SN_issuer_alt_name              \"issuerAltName\"\n#define LN_issuer_alt_name              \"X509v3 Issuer Alternative Name\"\n#define NID_issuer_alt_name             86\n#define OBJ_issuer_alt_name             OBJ_id_ce,18L\n\n#define SN_basic_constraints            \"basicConstraints\"\n#define LN_basic_constraints            \"X509v3 Basic Constraints\"\n#define NID_basic_constraints           87\n#define OBJ_basic_constraints           OBJ_id_ce,19L\n\n#define SN_crl_number           \"crlNumber\"\n#define LN_crl_number           \"X509v3 CRL Number\"\n#define NID_crl_number          88\n#define OBJ_crl_number          OBJ_id_ce,20L\n\n#define SN_crl_reason           \"CRLReason\"\n#define LN_crl_reason           \"X509v3 CRL Reason Code\"\n#define NID_crl_reason          141\n#define OBJ_crl_reason          OBJ_id_ce,21L\n\n#define SN_invalidity_date              \"invalidityDate\"\n#define LN_invalidity_date              \"Invalidity Date\"\n#define NID_invalidity_date             142\n#define OBJ_invalidity_date             OBJ_id_ce,24L\n\n#define SN_delta_crl            \"deltaCRL\"\n#define LN_delta_crl            \"X509v3 Delta CRL Indicator\"\n#define NID_delta_crl           140\n#define OBJ_delta_crl           OBJ_id_ce,27L\n\n#define SN_issuing_distribution_point           \"issuingDistributionPoint\"\n#define LN_issuing_distribution_point           \"X509v3 Issuing Distribution Point\"\n#define NID_issuing_distribution_point          770\n#define OBJ_issuing_distribution_point          OBJ_id_ce,28L\n\n#define SN_certificate_issuer           \"certificateIssuer\"\n#define LN_certificate_issuer           \"X509v3 Certificate Issuer\"\n#define NID_certificate_issuer          771\n#define OBJ_certificate_issuer          OBJ_id_ce,29L\n\n#define SN_name_constraints             \"nameConstraints\"\n#define LN_name_constraints             \"X509v3 Name Constraints\"\n#define NID_name_constraints            666\n#define OBJ_name_constraints            OBJ_id_ce,30L\n\n#define SN_crl_distribution_points              \"crlDistributionPoints\"\n#define LN_crl_distribution_points              \"X509v3 CRL Distribution Points\"\n#define NID_crl_distribution_points             103\n#define OBJ_crl_distribution_points             OBJ_id_ce,31L\n\n#define SN_certificate_policies         \"certificatePolicies\"\n#define LN_certificate_policies         \"X509v3 Certificate Policies\"\n#define NID_certificate_policies                89\n#define OBJ_certificate_policies                OBJ_id_ce,32L\n\n#define SN_any_policy           \"anyPolicy\"\n#define LN_any_policy           \"X509v3 Any Policy\"\n#define NID_any_policy          746\n#define OBJ_any_policy          OBJ_certificate_policies,0L\n\n#define SN_policy_mappings              \"policyMappings\"\n#define LN_policy_mappings              \"X509v3 Policy Mappings\"\n#define NID_policy_mappings             747\n#define OBJ_policy_mappings             OBJ_id_ce,33L\n\n#define SN_authority_key_identifier             \"authorityKeyIdentifier\"\n#define LN_authority_key_identifier             \"X509v3 Authority Key Identifier\"\n#define NID_authority_key_identifier            90\n#define OBJ_authority_key_identifier            OBJ_id_ce,35L\n\n#define SN_policy_constraints           \"policyConstraints\"\n#define LN_policy_constraints           \"X509v3 Policy Constraints\"\n#define NID_policy_constraints          401\n#define OBJ_policy_constraints          OBJ_id_ce,36L\n\n#define SN_ext_key_usage                \"extendedKeyUsage\"\n#define LN_ext_key_usage                \"X509v3 Extended Key Usage\"\n#define NID_ext_key_usage               126\n#define OBJ_ext_key_usage               OBJ_id_ce,37L\n\n#define SN_freshest_crl         \"freshestCRL\"\n#define LN_freshest_crl         \"X509v3 Freshest CRL\"\n#define NID_freshest_crl                857\n#define OBJ_freshest_crl                OBJ_id_ce,46L\n\n#define SN_inhibit_any_policy           \"inhibitAnyPolicy\"\n#define LN_inhibit_any_policy           \"X509v3 Inhibit Any Policy\"\n#define NID_inhibit_any_policy          748\n#define OBJ_inhibit_any_policy          OBJ_id_ce,54L\n\n#define SN_target_information           \"targetInformation\"\n#define LN_target_information           \"X509v3 AC Targeting\"\n#define NID_target_information          402\n#define OBJ_target_information          OBJ_id_ce,55L\n\n#define SN_no_rev_avail         \"noRevAvail\"\n#define LN_no_rev_avail         \"X509v3 No Revocation Available\"\n#define NID_no_rev_avail                403\n#define OBJ_no_rev_avail                OBJ_id_ce,56L\n\n#define SN_anyExtendedKeyUsage          \"anyExtendedKeyUsage\"\n#define LN_anyExtendedKeyUsage          \"Any Extended Key Usage\"\n#define NID_anyExtendedKeyUsage         910\n#define OBJ_anyExtendedKeyUsage         OBJ_ext_key_usage,0L\n\n#define SN_netscape             \"Netscape\"\n#define LN_netscape             \"Netscape Communications Corp.\"\n#define NID_netscape            57\n#define OBJ_netscape            2L,16L,840L,1L,113730L\n\n#define SN_netscape_cert_extension              \"nsCertExt\"\n#define LN_netscape_cert_extension              \"Netscape Certificate Extension\"\n#define NID_netscape_cert_extension             58\n#define OBJ_netscape_cert_extension             OBJ_netscape,1L\n\n#define SN_netscape_data_type           \"nsDataType\"\n#define LN_netscape_data_type           \"Netscape Data Type\"\n#define NID_netscape_data_type          59\n#define OBJ_netscape_data_type          OBJ_netscape,2L\n\n#define SN_netscape_cert_type           \"nsCertType\"\n#define LN_netscape_cert_type           \"Netscape Cert Type\"\n#define NID_netscape_cert_type          71\n#define OBJ_netscape_cert_type          OBJ_netscape_cert_extension,1L\n\n#define SN_netscape_base_url            \"nsBaseUrl\"\n#define LN_netscape_base_url            \"Netscape Base Url\"\n#define NID_netscape_base_url           72\n#define OBJ_netscape_base_url           OBJ_netscape_cert_extension,2L\n\n#define SN_netscape_revocation_url              \"nsRevocationUrl\"\n#define LN_netscape_revocation_url              \"Netscape Revocation Url\"\n#define NID_netscape_revocation_url             73\n#define OBJ_netscape_revocation_url             OBJ_netscape_cert_extension,3L\n\n#define SN_netscape_ca_revocation_url           \"nsCaRevocationUrl\"\n#define LN_netscape_ca_revocation_url           \"Netscape CA Revocation Url\"\n#define NID_netscape_ca_revocation_url          74\n#define OBJ_netscape_ca_revocation_url          OBJ_netscape_cert_extension,4L\n\n#define SN_netscape_renewal_url         \"nsRenewalUrl\"\n#define LN_netscape_renewal_url         \"Netscape Renewal Url\"\n#define NID_netscape_renewal_url                75\n#define OBJ_netscape_renewal_url                OBJ_netscape_cert_extension,7L\n\n#define SN_netscape_ca_policy_url               \"nsCaPolicyUrl\"\n#define LN_netscape_ca_policy_url               \"Netscape CA Policy Url\"\n#define NID_netscape_ca_policy_url              76\n#define OBJ_netscape_ca_policy_url              OBJ_netscape_cert_extension,8L\n\n#define SN_netscape_ssl_server_name             \"nsSslServerName\"\n#define LN_netscape_ssl_server_name             \"Netscape SSL Server Name\"\n#define NID_netscape_ssl_server_name            77\n#define OBJ_netscape_ssl_server_name            OBJ_netscape_cert_extension,12L\n\n#define SN_netscape_comment             \"nsComment\"\n#define LN_netscape_comment             \"Netscape Comment\"\n#define NID_netscape_comment            78\n#define OBJ_netscape_comment            OBJ_netscape_cert_extension,13L\n\n#define SN_netscape_cert_sequence               \"nsCertSequence\"\n#define LN_netscape_cert_sequence               \"Netscape Certificate Sequence\"\n#define NID_netscape_cert_sequence              79\n#define OBJ_netscape_cert_sequence              OBJ_netscape_data_type,5L\n\n#define SN_ns_sgc               \"nsSGC\"\n#define LN_ns_sgc               \"Netscape Server Gated Crypto\"\n#define NID_ns_sgc              139\n#define OBJ_ns_sgc              OBJ_netscape,4L,1L\n\n#define SN_org          \"ORG\"\n#define LN_org          \"org\"\n#define NID_org         379\n#define OBJ_org         OBJ_iso,3L\n\n#define SN_dod          \"DOD\"\n#define LN_dod          \"dod\"\n#define NID_dod         380\n#define OBJ_dod         OBJ_org,6L\n\n#define SN_iana         \"IANA\"\n#define LN_iana         \"iana\"\n#define NID_iana                381\n#define OBJ_iana                OBJ_dod,1L\n\n#define OBJ_internet            OBJ_iana\n\n#define SN_Directory            \"directory\"\n#define LN_Directory            \"Directory\"\n#define NID_Directory           382\n#define OBJ_Directory           OBJ_internet,1L\n\n#define SN_Management           \"mgmt\"\n#define LN_Management           \"Management\"\n#define NID_Management          383\n#define OBJ_Management          OBJ_internet,2L\n\n#define SN_Experimental         \"experimental\"\n#define LN_Experimental         \"Experimental\"\n#define NID_Experimental                384\n#define OBJ_Experimental                OBJ_internet,3L\n\n#define SN_Private              \"private\"\n#define LN_Private              \"Private\"\n#define NID_Private             385\n#define OBJ_Private             OBJ_internet,4L\n\n#define SN_Security             \"security\"\n#define LN_Security             \"Security\"\n#define NID_Security            386\n#define OBJ_Security            OBJ_internet,5L\n\n#define SN_SNMPv2               \"snmpv2\"\n#define LN_SNMPv2               \"SNMPv2\"\n#define NID_SNMPv2              387\n#define OBJ_SNMPv2              OBJ_internet,6L\n\n#define LN_Mail         \"Mail\"\n#define NID_Mail                388\n#define OBJ_Mail                OBJ_internet,7L\n\n#define SN_Enterprises          \"enterprises\"\n#define LN_Enterprises          \"Enterprises\"\n#define NID_Enterprises         389\n#define OBJ_Enterprises         OBJ_Private,1L\n\n#define SN_dcObject             \"dcobject\"\n#define LN_dcObject             \"dcObject\"\n#define NID_dcObject            390\n#define OBJ_dcObject            OBJ_Enterprises,1466L,344L\n\n#define SN_mime_mhs             \"mime-mhs\"\n#define LN_mime_mhs             \"MIME MHS\"\n#define NID_mime_mhs            504\n#define OBJ_mime_mhs            OBJ_Mail,1L\n\n#define SN_mime_mhs_headings            \"mime-mhs-headings\"\n#define LN_mime_mhs_headings            \"mime-mhs-headings\"\n#define NID_mime_mhs_headings           505\n#define OBJ_mime_mhs_headings           OBJ_mime_mhs,1L\n\n#define SN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define LN_mime_mhs_bodies              \"mime-mhs-bodies\"\n#define NID_mime_mhs_bodies             506\n#define OBJ_mime_mhs_bodies             OBJ_mime_mhs,2L\n\n#define SN_id_hex_partial_message               \"id-hex-partial-message\"\n#define LN_id_hex_partial_message               \"id-hex-partial-message\"\n#define NID_id_hex_partial_message              507\n#define OBJ_id_hex_partial_message              OBJ_mime_mhs_headings,1L\n\n#define SN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define LN_id_hex_multipart_message             \"id-hex-multipart-message\"\n#define NID_id_hex_multipart_message            508\n#define OBJ_id_hex_multipart_message            OBJ_mime_mhs_headings,2L\n\n#define SN_zlib_compression             \"ZLIB\"\n#define LN_zlib_compression             \"zlib compression\"\n#define NID_zlib_compression            125\n#define OBJ_zlib_compression            OBJ_id_smime_alg,8L\n\n#define OBJ_csor                2L,16L,840L,1L,101L,3L\n\n#define OBJ_nistAlgorithms              OBJ_csor,4L\n\n#define OBJ_aes         OBJ_nistAlgorithms,1L\n\n#define SN_aes_128_ecb          \"AES-128-ECB\"\n#define LN_aes_128_ecb          \"aes-128-ecb\"\n#define NID_aes_128_ecb         418\n#define OBJ_aes_128_ecb         OBJ_aes,1L\n\n#define SN_aes_128_cbc          \"AES-128-CBC\"\n#define LN_aes_128_cbc          \"aes-128-cbc\"\n#define NID_aes_128_cbc         419\n#define OBJ_aes_128_cbc         OBJ_aes,2L\n\n#define SN_aes_128_ofb128               \"AES-128-OFB\"\n#define LN_aes_128_ofb128               \"aes-128-ofb\"\n#define NID_aes_128_ofb128              420\n#define OBJ_aes_128_ofb128              OBJ_aes,3L\n\n#define SN_aes_128_cfb128               \"AES-128-CFB\"\n#define LN_aes_128_cfb128               \"aes-128-cfb\"\n#define NID_aes_128_cfb128              421\n#define OBJ_aes_128_cfb128              OBJ_aes,4L\n\n#define SN_id_aes128_wrap               \"id-aes128-wrap\"\n#define NID_id_aes128_wrap              788\n#define OBJ_id_aes128_wrap              OBJ_aes,5L\n\n#define SN_aes_128_gcm          \"id-aes128-GCM\"\n#define LN_aes_128_gcm          \"aes-128-gcm\"\n#define NID_aes_128_gcm         895\n#define OBJ_aes_128_gcm         OBJ_aes,6L\n\n#define SN_aes_128_ccm          \"id-aes128-CCM\"\n#define LN_aes_128_ccm          \"aes-128-ccm\"\n#define NID_aes_128_ccm         896\n#define OBJ_aes_128_ccm         OBJ_aes,7L\n\n#define SN_id_aes128_wrap_pad           \"id-aes128-wrap-pad\"\n#define NID_id_aes128_wrap_pad          897\n#define OBJ_id_aes128_wrap_pad          OBJ_aes,8L\n\n#define SN_aes_192_ecb          \"AES-192-ECB\"\n#define LN_aes_192_ecb          \"aes-192-ecb\"\n#define NID_aes_192_ecb         422\n#define OBJ_aes_192_ecb         OBJ_aes,21L\n\n#define SN_aes_192_cbc          \"AES-192-CBC\"\n#define LN_aes_192_cbc          \"aes-192-cbc\"\n#define NID_aes_192_cbc         423\n#define OBJ_aes_192_cbc         OBJ_aes,22L\n\n#define SN_aes_192_ofb128               \"AES-192-OFB\"\n#define LN_aes_192_ofb128               \"aes-192-ofb\"\n#define NID_aes_192_ofb128              424\n#define OBJ_aes_192_ofb128              OBJ_aes,23L\n\n#define SN_aes_192_cfb128               \"AES-192-CFB\"\n#define LN_aes_192_cfb128               \"aes-192-cfb\"\n#define NID_aes_192_cfb128              425\n#define OBJ_aes_192_cfb128              OBJ_aes,24L\n\n#define SN_id_aes192_wrap               \"id-aes192-wrap\"\n#define NID_id_aes192_wrap              789\n#define OBJ_id_aes192_wrap              OBJ_aes,25L\n\n#define SN_aes_192_gcm          \"id-aes192-GCM\"\n#define LN_aes_192_gcm          \"aes-192-gcm\"\n#define NID_aes_192_gcm         898\n#define OBJ_aes_192_gcm         OBJ_aes,26L\n\n#define SN_aes_192_ccm          \"id-aes192-CCM\"\n#define LN_aes_192_ccm          \"aes-192-ccm\"\n#define NID_aes_192_ccm         899\n#define OBJ_aes_192_ccm         OBJ_aes,27L\n\n#define SN_id_aes192_wrap_pad           \"id-aes192-wrap-pad\"\n#define NID_id_aes192_wrap_pad          900\n#define OBJ_id_aes192_wrap_pad          OBJ_aes,28L\n\n#define SN_aes_256_ecb          \"AES-256-ECB\"\n#define LN_aes_256_ecb          \"aes-256-ecb\"\n#define NID_aes_256_ecb         426\n#define OBJ_aes_256_ecb         OBJ_aes,41L\n\n#define SN_aes_256_cbc          \"AES-256-CBC\"\n#define LN_aes_256_cbc          \"aes-256-cbc\"\n#define NID_aes_256_cbc         427\n#define OBJ_aes_256_cbc         OBJ_aes,42L\n\n#define SN_aes_256_ofb128               \"AES-256-OFB\"\n#define LN_aes_256_ofb128               \"aes-256-ofb\"\n#define NID_aes_256_ofb128              428\n#define OBJ_aes_256_ofb128              OBJ_aes,43L\n\n#define SN_aes_256_cfb128               \"AES-256-CFB\"\n#define LN_aes_256_cfb128               \"aes-256-cfb\"\n#define NID_aes_256_cfb128              429\n#define OBJ_aes_256_cfb128              OBJ_aes,44L\n\n#define SN_id_aes256_wrap               \"id-aes256-wrap\"\n#define NID_id_aes256_wrap              790\n#define OBJ_id_aes256_wrap              OBJ_aes,45L\n\n#define SN_aes_256_gcm          \"id-aes256-GCM\"\n#define LN_aes_256_gcm          \"aes-256-gcm\"\n#define NID_aes_256_gcm         901\n#define OBJ_aes_256_gcm         OBJ_aes,46L\n\n#define SN_aes_256_ccm          \"id-aes256-CCM\"\n#define LN_aes_256_ccm          \"aes-256-ccm\"\n#define NID_aes_256_ccm         902\n#define OBJ_aes_256_ccm         OBJ_aes,47L\n\n#define SN_id_aes256_wrap_pad           \"id-aes256-wrap-pad\"\n#define NID_id_aes256_wrap_pad          903\n#define OBJ_id_aes256_wrap_pad          OBJ_aes,48L\n\n#define SN_aes_128_xts          \"AES-128-XTS\"\n#define LN_aes_128_xts          \"aes-128-xts\"\n#define NID_aes_128_xts         913\n#define OBJ_aes_128_xts         OBJ_ieee_siswg,0L,1L,1L\n\n#define SN_aes_256_xts          \"AES-256-XTS\"\n#define LN_aes_256_xts          \"aes-256-xts\"\n#define NID_aes_256_xts         914\n#define OBJ_aes_256_xts         OBJ_ieee_siswg,0L,1L,2L\n\n#define SN_aes_128_cfb1         \"AES-128-CFB1\"\n#define LN_aes_128_cfb1         \"aes-128-cfb1\"\n#define NID_aes_128_cfb1                650\n\n#define SN_aes_192_cfb1         \"AES-192-CFB1\"\n#define LN_aes_192_cfb1         \"aes-192-cfb1\"\n#define NID_aes_192_cfb1                651\n\n#define SN_aes_256_cfb1         \"AES-256-CFB1\"\n#define LN_aes_256_cfb1         \"aes-256-cfb1\"\n#define NID_aes_256_cfb1                652\n\n#define SN_aes_128_cfb8         \"AES-128-CFB8\"\n#define LN_aes_128_cfb8         \"aes-128-cfb8\"\n#define NID_aes_128_cfb8                653\n\n#define SN_aes_192_cfb8         \"AES-192-CFB8\"\n#define LN_aes_192_cfb8         \"aes-192-cfb8\"\n#define NID_aes_192_cfb8                654\n\n#define SN_aes_256_cfb8         \"AES-256-CFB8\"\n#define LN_aes_256_cfb8         \"aes-256-cfb8\"\n#define NID_aes_256_cfb8                655\n\n#define SN_aes_128_ctr          \"AES-128-CTR\"\n#define LN_aes_128_ctr          \"aes-128-ctr\"\n#define NID_aes_128_ctr         904\n\n#define SN_aes_192_ctr          \"AES-192-CTR\"\n#define LN_aes_192_ctr          \"aes-192-ctr\"\n#define NID_aes_192_ctr         905\n\n#define SN_aes_256_ctr          \"AES-256-CTR\"\n#define LN_aes_256_ctr          \"aes-256-ctr\"\n#define NID_aes_256_ctr         906\n\n#define SN_aes_128_ocb          \"AES-128-OCB\"\n#define LN_aes_128_ocb          \"aes-128-ocb\"\n#define NID_aes_128_ocb         958\n\n#define SN_aes_192_ocb          \"AES-192-OCB\"\n#define LN_aes_192_ocb          \"aes-192-ocb\"\n#define NID_aes_192_ocb         959\n\n#define SN_aes_256_ocb          \"AES-256-OCB\"\n#define LN_aes_256_ocb          \"aes-256-ocb\"\n#define NID_aes_256_ocb         960\n\n#define SN_des_cfb1             \"DES-CFB1\"\n#define LN_des_cfb1             \"des-cfb1\"\n#define NID_des_cfb1            656\n\n#define SN_des_cfb8             \"DES-CFB8\"\n#define LN_des_cfb8             \"des-cfb8\"\n#define NID_des_cfb8            657\n\n#define SN_des_ede3_cfb1                \"DES-EDE3-CFB1\"\n#define LN_des_ede3_cfb1                \"des-ede3-cfb1\"\n#define NID_des_ede3_cfb1               658\n\n#define SN_des_ede3_cfb8                \"DES-EDE3-CFB8\"\n#define LN_des_ede3_cfb8                \"des-ede3-cfb8\"\n#define NID_des_ede3_cfb8               659\n\n#define OBJ_nist_hashalgs               OBJ_nistAlgorithms,2L\n\n#define SN_sha256               \"SHA256\"\n#define LN_sha256               \"sha256\"\n#define NID_sha256              672\n#define OBJ_sha256              OBJ_nist_hashalgs,1L\n\n#define SN_sha384               \"SHA384\"\n#define LN_sha384               \"sha384\"\n#define NID_sha384              673\n#define OBJ_sha384              OBJ_nist_hashalgs,2L\n\n#define SN_sha512               \"SHA512\"\n#define LN_sha512               \"sha512\"\n#define NID_sha512              674\n#define OBJ_sha512              OBJ_nist_hashalgs,3L\n\n#define SN_sha224               \"SHA224\"\n#define LN_sha224               \"sha224\"\n#define NID_sha224              675\n#define OBJ_sha224              OBJ_nist_hashalgs,4L\n\n#define SN_sha512_224           \"SHA512-224\"\n#define LN_sha512_224           \"sha512-224\"\n#define NID_sha512_224          1094\n#define OBJ_sha512_224          OBJ_nist_hashalgs,5L\n\n#define SN_sha512_256           \"SHA512-256\"\n#define LN_sha512_256           \"sha512-256\"\n#define NID_sha512_256          1095\n#define OBJ_sha512_256          OBJ_nist_hashalgs,6L\n\n#define SN_sha3_224             \"SHA3-224\"\n#define LN_sha3_224             \"sha3-224\"\n#define NID_sha3_224            1096\n#define OBJ_sha3_224            OBJ_nist_hashalgs,7L\n\n#define SN_sha3_256             \"SHA3-256\"\n#define LN_sha3_256             \"sha3-256\"\n#define NID_sha3_256            1097\n#define OBJ_sha3_256            OBJ_nist_hashalgs,8L\n\n#define SN_sha3_384             \"SHA3-384\"\n#define LN_sha3_384             \"sha3-384\"\n#define NID_sha3_384            1098\n#define OBJ_sha3_384            OBJ_nist_hashalgs,9L\n\n#define SN_sha3_512             \"SHA3-512\"\n#define LN_sha3_512             \"sha3-512\"\n#define NID_sha3_512            1099\n#define OBJ_sha3_512            OBJ_nist_hashalgs,10L\n\n#define SN_shake128             \"SHAKE128\"\n#define LN_shake128             \"shake128\"\n#define NID_shake128            1100\n#define OBJ_shake128            OBJ_nist_hashalgs,11L\n\n#define SN_shake256             \"SHAKE256\"\n#define LN_shake256             \"shake256\"\n#define NID_shake256            1101\n#define OBJ_shake256            OBJ_nist_hashalgs,12L\n\n#define SN_hmac_sha3_224                \"id-hmacWithSHA3-224\"\n#define LN_hmac_sha3_224                \"hmac-sha3-224\"\n#define NID_hmac_sha3_224               1102\n#define OBJ_hmac_sha3_224               OBJ_nist_hashalgs,13L\n\n#define SN_hmac_sha3_256                \"id-hmacWithSHA3-256\"\n#define LN_hmac_sha3_256                \"hmac-sha3-256\"\n#define NID_hmac_sha3_256               1103\n#define OBJ_hmac_sha3_256               OBJ_nist_hashalgs,14L\n\n#define SN_hmac_sha3_384                \"id-hmacWithSHA3-384\"\n#define LN_hmac_sha3_384                \"hmac-sha3-384\"\n#define NID_hmac_sha3_384               1104\n#define OBJ_hmac_sha3_384               OBJ_nist_hashalgs,15L\n\n#define SN_hmac_sha3_512                \"id-hmacWithSHA3-512\"\n#define LN_hmac_sha3_512                \"hmac-sha3-512\"\n#define NID_hmac_sha3_512               1105\n#define OBJ_hmac_sha3_512               OBJ_nist_hashalgs,16L\n\n#define OBJ_dsa_with_sha2               OBJ_nistAlgorithms,3L\n\n#define SN_dsa_with_SHA224              \"dsa_with_SHA224\"\n#define NID_dsa_with_SHA224             802\n#define OBJ_dsa_with_SHA224             OBJ_dsa_with_sha2,1L\n\n#define SN_dsa_with_SHA256              \"dsa_with_SHA256\"\n#define NID_dsa_with_SHA256             803\n#define OBJ_dsa_with_SHA256             OBJ_dsa_with_sha2,2L\n\n#define OBJ_sigAlgs             OBJ_nistAlgorithms,3L\n\n#define SN_dsa_with_SHA384              \"id-dsa-with-sha384\"\n#define LN_dsa_with_SHA384              \"dsa_with_SHA384\"\n#define NID_dsa_with_SHA384             1106\n#define OBJ_dsa_with_SHA384             OBJ_sigAlgs,3L\n\n#define SN_dsa_with_SHA512              \"id-dsa-with-sha512\"\n#define LN_dsa_with_SHA512              \"dsa_with_SHA512\"\n#define NID_dsa_with_SHA512             1107\n#define OBJ_dsa_with_SHA512             OBJ_sigAlgs,4L\n\n#define SN_dsa_with_SHA3_224            \"id-dsa-with-sha3-224\"\n#define LN_dsa_with_SHA3_224            \"dsa_with_SHA3-224\"\n#define NID_dsa_with_SHA3_224           1108\n#define OBJ_dsa_with_SHA3_224           OBJ_sigAlgs,5L\n\n#define SN_dsa_with_SHA3_256            \"id-dsa-with-sha3-256\"\n#define LN_dsa_with_SHA3_256            \"dsa_with_SHA3-256\"\n#define NID_dsa_with_SHA3_256           1109\n#define OBJ_dsa_with_SHA3_256           OBJ_sigAlgs,6L\n\n#define SN_dsa_with_SHA3_384            \"id-dsa-with-sha3-384\"\n#define LN_dsa_with_SHA3_384            \"dsa_with_SHA3-384\"\n#define NID_dsa_with_SHA3_384           1110\n#define OBJ_dsa_with_SHA3_384           OBJ_sigAlgs,7L\n\n#define SN_dsa_with_SHA3_512            \"id-dsa-with-sha3-512\"\n#define LN_dsa_with_SHA3_512            \"dsa_with_SHA3-512\"\n#define NID_dsa_with_SHA3_512           1111\n#define OBJ_dsa_with_SHA3_512           OBJ_sigAlgs,8L\n\n#define SN_ecdsa_with_SHA3_224          \"id-ecdsa-with-sha3-224\"\n#define LN_ecdsa_with_SHA3_224          \"ecdsa_with_SHA3-224\"\n#define NID_ecdsa_with_SHA3_224         1112\n#define OBJ_ecdsa_with_SHA3_224         OBJ_sigAlgs,9L\n\n#define SN_ecdsa_with_SHA3_256          \"id-ecdsa-with-sha3-256\"\n#define LN_ecdsa_with_SHA3_256          \"ecdsa_with_SHA3-256\"\n#define NID_ecdsa_with_SHA3_256         1113\n#define OBJ_ecdsa_with_SHA3_256         OBJ_sigAlgs,10L\n\n#define SN_ecdsa_with_SHA3_384          \"id-ecdsa-with-sha3-384\"\n#define LN_ecdsa_with_SHA3_384          \"ecdsa_with_SHA3-384\"\n#define NID_ecdsa_with_SHA3_384         1114\n#define OBJ_ecdsa_with_SHA3_384         OBJ_sigAlgs,11L\n\n#define SN_ecdsa_with_SHA3_512          \"id-ecdsa-with-sha3-512\"\n#define LN_ecdsa_with_SHA3_512          \"ecdsa_with_SHA3-512\"\n#define NID_ecdsa_with_SHA3_512         1115\n#define OBJ_ecdsa_with_SHA3_512         OBJ_sigAlgs,12L\n\n#define SN_RSA_SHA3_224         \"id-rsassa-pkcs1-v1_5-with-sha3-224\"\n#define LN_RSA_SHA3_224         \"RSA-SHA3-224\"\n#define NID_RSA_SHA3_224                1116\n#define OBJ_RSA_SHA3_224                OBJ_sigAlgs,13L\n\n#define SN_RSA_SHA3_256         \"id-rsassa-pkcs1-v1_5-with-sha3-256\"\n#define LN_RSA_SHA3_256         \"RSA-SHA3-256\"\n#define NID_RSA_SHA3_256                1117\n#define OBJ_RSA_SHA3_256                OBJ_sigAlgs,14L\n\n#define SN_RSA_SHA3_384         \"id-rsassa-pkcs1-v1_5-with-sha3-384\"\n#define LN_RSA_SHA3_384         \"RSA-SHA3-384\"\n#define NID_RSA_SHA3_384                1118\n#define OBJ_RSA_SHA3_384                OBJ_sigAlgs,15L\n\n#define SN_RSA_SHA3_512         \"id-rsassa-pkcs1-v1_5-with-sha3-512\"\n#define LN_RSA_SHA3_512         \"RSA-SHA3-512\"\n#define NID_RSA_SHA3_512                1119\n#define OBJ_RSA_SHA3_512                OBJ_sigAlgs,16L\n\n#define SN_hold_instruction_code                \"holdInstructionCode\"\n#define LN_hold_instruction_code                \"Hold Instruction Code\"\n#define NID_hold_instruction_code               430\n#define OBJ_hold_instruction_code               OBJ_id_ce,23L\n\n#define OBJ_holdInstruction             OBJ_X9_57,2L\n\n#define SN_hold_instruction_none                \"holdInstructionNone\"\n#define LN_hold_instruction_none                \"Hold Instruction None\"\n#define NID_hold_instruction_none               431\n#define OBJ_hold_instruction_none               OBJ_holdInstruction,1L\n\n#define SN_hold_instruction_call_issuer         \"holdInstructionCallIssuer\"\n#define LN_hold_instruction_call_issuer         \"Hold Instruction Call Issuer\"\n#define NID_hold_instruction_call_issuer                432\n#define OBJ_hold_instruction_call_issuer                OBJ_holdInstruction,2L\n\n#define SN_hold_instruction_reject              \"holdInstructionReject\"\n#define LN_hold_instruction_reject              \"Hold Instruction Reject\"\n#define NID_hold_instruction_reject             433\n#define OBJ_hold_instruction_reject             OBJ_holdInstruction,3L\n\n#define SN_data         \"data\"\n#define NID_data                434\n#define OBJ_data                OBJ_itu_t,9L\n\n#define SN_pss          \"pss\"\n#define NID_pss         435\n#define OBJ_pss         OBJ_data,2342L\n\n#define SN_ucl          \"ucl\"\n#define NID_ucl         436\n#define OBJ_ucl         OBJ_pss,19200300L\n\n#define SN_pilot                \"pilot\"\n#define NID_pilot               437\n#define OBJ_pilot               OBJ_ucl,100L\n\n#define LN_pilotAttributeType           \"pilotAttributeType\"\n#define NID_pilotAttributeType          438\n#define OBJ_pilotAttributeType          OBJ_pilot,1L\n\n#define LN_pilotAttributeSyntax         \"pilotAttributeSyntax\"\n#define NID_pilotAttributeSyntax                439\n#define OBJ_pilotAttributeSyntax                OBJ_pilot,3L\n\n#define LN_pilotObjectClass             \"pilotObjectClass\"\n#define NID_pilotObjectClass            440\n#define OBJ_pilotObjectClass            OBJ_pilot,4L\n\n#define LN_pilotGroups          \"pilotGroups\"\n#define NID_pilotGroups         441\n#define OBJ_pilotGroups         OBJ_pilot,10L\n\n#define LN_iA5StringSyntax              \"iA5StringSyntax\"\n#define NID_iA5StringSyntax             442\n#define OBJ_iA5StringSyntax             OBJ_pilotAttributeSyntax,4L\n\n#define LN_caseIgnoreIA5StringSyntax            \"caseIgnoreIA5StringSyntax\"\n#define NID_caseIgnoreIA5StringSyntax           443\n#define OBJ_caseIgnoreIA5StringSyntax           OBJ_pilotAttributeSyntax,5L\n\n#define LN_pilotObject          \"pilotObject\"\n#define NID_pilotObject         444\n#define OBJ_pilotObject         OBJ_pilotObjectClass,3L\n\n#define LN_pilotPerson          \"pilotPerson\"\n#define NID_pilotPerson         445\n#define OBJ_pilotPerson         OBJ_pilotObjectClass,4L\n\n#define SN_account              \"account\"\n#define NID_account             446\n#define OBJ_account             OBJ_pilotObjectClass,5L\n\n#define SN_document             \"document\"\n#define NID_document            447\n#define OBJ_document            OBJ_pilotObjectClass,6L\n\n#define SN_room         \"room\"\n#define NID_room                448\n#define OBJ_room                OBJ_pilotObjectClass,7L\n\n#define LN_documentSeries               \"documentSeries\"\n#define NID_documentSeries              449\n#define OBJ_documentSeries              OBJ_pilotObjectClass,9L\n\n#define SN_Domain               \"domain\"\n#define LN_Domain               \"Domain\"\n#define NID_Domain              392\n#define OBJ_Domain              OBJ_pilotObjectClass,13L\n\n#define LN_rFC822localPart              \"rFC822localPart\"\n#define NID_rFC822localPart             450\n#define OBJ_rFC822localPart             OBJ_pilotObjectClass,14L\n\n#define LN_dNSDomain            \"dNSDomain\"\n#define NID_dNSDomain           451\n#define OBJ_dNSDomain           OBJ_pilotObjectClass,15L\n\n#define LN_domainRelatedObject          \"domainRelatedObject\"\n#define NID_domainRelatedObject         452\n#define OBJ_domainRelatedObject         OBJ_pilotObjectClass,17L\n\n#define LN_friendlyCountry              \"friendlyCountry\"\n#define NID_friendlyCountry             453\n#define OBJ_friendlyCountry             OBJ_pilotObjectClass,18L\n\n#define LN_simpleSecurityObject         \"simpleSecurityObject\"\n#define NID_simpleSecurityObject                454\n#define OBJ_simpleSecurityObject                OBJ_pilotObjectClass,19L\n\n#define LN_pilotOrganization            \"pilotOrganization\"\n#define NID_pilotOrganization           455\n#define OBJ_pilotOrganization           OBJ_pilotObjectClass,20L\n\n#define LN_pilotDSA             \"pilotDSA\"\n#define NID_pilotDSA            456\n#define OBJ_pilotDSA            OBJ_pilotObjectClass,21L\n\n#define LN_qualityLabelledData          \"qualityLabelledData\"\n#define NID_qualityLabelledData         457\n#define OBJ_qualityLabelledData         OBJ_pilotObjectClass,22L\n\n#define SN_userId               \"UID\"\n#define LN_userId               \"userId\"\n#define NID_userId              458\n#define OBJ_userId              OBJ_pilotAttributeType,1L\n\n#define LN_textEncodedORAddress         \"textEncodedORAddress\"\n#define NID_textEncodedORAddress                459\n#define OBJ_textEncodedORAddress                OBJ_pilotAttributeType,2L\n\n#define SN_rfc822Mailbox                \"mail\"\n#define LN_rfc822Mailbox                \"rfc822Mailbox\"\n#define NID_rfc822Mailbox               460\n#define OBJ_rfc822Mailbox               OBJ_pilotAttributeType,3L\n\n#define SN_info         \"info\"\n#define NID_info                461\n#define OBJ_info                OBJ_pilotAttributeType,4L\n\n#define LN_favouriteDrink               \"favouriteDrink\"\n#define NID_favouriteDrink              462\n#define OBJ_favouriteDrink              OBJ_pilotAttributeType,5L\n\n#define LN_roomNumber           \"roomNumber\"\n#define NID_roomNumber          463\n#define OBJ_roomNumber          OBJ_pilotAttributeType,6L\n\n#define SN_photo                \"photo\"\n#define NID_photo               464\n#define OBJ_photo               OBJ_pilotAttributeType,7L\n\n#define LN_userClass            \"userClass\"\n#define NID_userClass           465\n#define OBJ_userClass           OBJ_pilotAttributeType,8L\n\n#define SN_host         \"host\"\n#define NID_host                466\n#define OBJ_host                OBJ_pilotAttributeType,9L\n\n#define SN_manager              \"manager\"\n#define NID_manager             467\n#define OBJ_manager             OBJ_pilotAttributeType,10L\n\n#define LN_documentIdentifier           \"documentIdentifier\"\n#define NID_documentIdentifier          468\n#define OBJ_documentIdentifier          OBJ_pilotAttributeType,11L\n\n#define LN_documentTitle                \"documentTitle\"\n#define NID_documentTitle               469\n#define OBJ_documentTitle               OBJ_pilotAttributeType,12L\n\n#define LN_documentVersion              \"documentVersion\"\n#define NID_documentVersion             470\n#define OBJ_documentVersion             OBJ_pilotAttributeType,13L\n\n#define LN_documentAuthor               \"documentAuthor\"\n#define NID_documentAuthor              471\n#define OBJ_documentAuthor              OBJ_pilotAttributeType,14L\n\n#define LN_documentLocation             \"documentLocation\"\n#define NID_documentLocation            472\n#define OBJ_documentLocation            OBJ_pilotAttributeType,15L\n\n#define LN_homeTelephoneNumber          \"homeTelephoneNumber\"\n#define NID_homeTelephoneNumber         473\n#define OBJ_homeTelephoneNumber         OBJ_pilotAttributeType,20L\n\n#define SN_secretary            \"secretary\"\n#define NID_secretary           474\n#define OBJ_secretary           OBJ_pilotAttributeType,21L\n\n#define LN_otherMailbox         \"otherMailbox\"\n#define NID_otherMailbox                475\n#define OBJ_otherMailbox                OBJ_pilotAttributeType,22L\n\n#define LN_lastModifiedTime             \"lastModifiedTime\"\n#define NID_lastModifiedTime            476\n#define OBJ_lastModifiedTime            OBJ_pilotAttributeType,23L\n\n#define LN_lastModifiedBy               \"lastModifiedBy\"\n#define NID_lastModifiedBy              477\n#define OBJ_lastModifiedBy              OBJ_pilotAttributeType,24L\n\n#define SN_domainComponent              \"DC\"\n#define LN_domainComponent              \"domainComponent\"\n#define NID_domainComponent             391\n#define OBJ_domainComponent             OBJ_pilotAttributeType,25L\n\n#define LN_aRecord              \"aRecord\"\n#define NID_aRecord             478\n#define OBJ_aRecord             OBJ_pilotAttributeType,26L\n\n#define LN_pilotAttributeType27         \"pilotAttributeType27\"\n#define NID_pilotAttributeType27                479\n#define OBJ_pilotAttributeType27                OBJ_pilotAttributeType,27L\n\n#define LN_mXRecord             \"mXRecord\"\n#define NID_mXRecord            480\n#define OBJ_mXRecord            OBJ_pilotAttributeType,28L\n\n#define LN_nSRecord             \"nSRecord\"\n#define NID_nSRecord            481\n#define OBJ_nSRecord            OBJ_pilotAttributeType,29L\n\n#define LN_sOARecord            \"sOARecord\"\n#define NID_sOARecord           482\n#define OBJ_sOARecord           OBJ_pilotAttributeType,30L\n\n#define LN_cNAMERecord          \"cNAMERecord\"\n#define NID_cNAMERecord         483\n#define OBJ_cNAMERecord         OBJ_pilotAttributeType,31L\n\n#define LN_associatedDomain             \"associatedDomain\"\n#define NID_associatedDomain            484\n#define OBJ_associatedDomain            OBJ_pilotAttributeType,37L\n\n#define LN_associatedName               \"associatedName\"\n#define NID_associatedName              485\n#define OBJ_associatedName              OBJ_pilotAttributeType,38L\n\n#define LN_homePostalAddress            \"homePostalAddress\"\n#define NID_homePostalAddress           486\n#define OBJ_homePostalAddress           OBJ_pilotAttributeType,39L\n\n#define LN_personalTitle                \"personalTitle\"\n#define NID_personalTitle               487\n#define OBJ_personalTitle               OBJ_pilotAttributeType,40L\n\n#define LN_mobileTelephoneNumber                \"mobileTelephoneNumber\"\n#define NID_mobileTelephoneNumber               488\n#define OBJ_mobileTelephoneNumber               OBJ_pilotAttributeType,41L\n\n#define LN_pagerTelephoneNumber         \"pagerTelephoneNumber\"\n#define NID_pagerTelephoneNumber                489\n#define OBJ_pagerTelephoneNumber                OBJ_pilotAttributeType,42L\n\n#define LN_friendlyCountryName          \"friendlyCountryName\"\n#define NID_friendlyCountryName         490\n#define OBJ_friendlyCountryName         OBJ_pilotAttributeType,43L\n\n#define SN_uniqueIdentifier             \"uid\"\n#define LN_uniqueIdentifier             \"uniqueIdentifier\"\n#define NID_uniqueIdentifier            102\n#define OBJ_uniqueIdentifier            OBJ_pilotAttributeType,44L\n\n#define LN_organizationalStatus         \"organizationalStatus\"\n#define NID_organizationalStatus                491\n#define OBJ_organizationalStatus                OBJ_pilotAttributeType,45L\n\n#define LN_janetMailbox         \"janetMailbox\"\n#define NID_janetMailbox                492\n#define OBJ_janetMailbox                OBJ_pilotAttributeType,46L\n\n#define LN_mailPreferenceOption         \"mailPreferenceOption\"\n#define NID_mailPreferenceOption                493\n#define OBJ_mailPreferenceOption                OBJ_pilotAttributeType,47L\n\n#define LN_buildingName         \"buildingName\"\n#define NID_buildingName                494\n#define OBJ_buildingName                OBJ_pilotAttributeType,48L\n\n#define LN_dSAQuality           \"dSAQuality\"\n#define NID_dSAQuality          495\n#define OBJ_dSAQuality          OBJ_pilotAttributeType,49L\n\n#define LN_singleLevelQuality           \"singleLevelQuality\"\n#define NID_singleLevelQuality          496\n#define OBJ_singleLevelQuality          OBJ_pilotAttributeType,50L\n\n#define LN_subtreeMinimumQuality                \"subtreeMinimumQuality\"\n#define NID_subtreeMinimumQuality               497\n#define OBJ_subtreeMinimumQuality               OBJ_pilotAttributeType,51L\n\n#define LN_subtreeMaximumQuality                \"subtreeMaximumQuality\"\n#define NID_subtreeMaximumQuality               498\n#define OBJ_subtreeMaximumQuality               OBJ_pilotAttributeType,52L\n\n#define LN_personalSignature            \"personalSignature\"\n#define NID_personalSignature           499\n#define OBJ_personalSignature           OBJ_pilotAttributeType,53L\n\n#define LN_dITRedirect          \"dITRedirect\"\n#define NID_dITRedirect         500\n#define OBJ_dITRedirect         OBJ_pilotAttributeType,54L\n\n#define SN_audio                \"audio\"\n#define NID_audio               501\n#define OBJ_audio               OBJ_pilotAttributeType,55L\n\n#define LN_documentPublisher            \"documentPublisher\"\n#define NID_documentPublisher           502\n#define OBJ_documentPublisher           OBJ_pilotAttributeType,56L\n\n#define SN_id_set               \"id-set\"\n#define LN_id_set               \"Secure Electronic Transactions\"\n#define NID_id_set              512\n#define OBJ_id_set              OBJ_international_organizations,42L\n\n#define SN_set_ctype            \"set-ctype\"\n#define LN_set_ctype            \"content types\"\n#define NID_set_ctype           513\n#define OBJ_set_ctype           OBJ_id_set,0L\n\n#define SN_set_msgExt           \"set-msgExt\"\n#define LN_set_msgExt           \"message extensions\"\n#define NID_set_msgExt          514\n#define OBJ_set_msgExt          OBJ_id_set,1L\n\n#define SN_set_attr             \"set-attr\"\n#define NID_set_attr            515\n#define OBJ_set_attr            OBJ_id_set,3L\n\n#define SN_set_policy           \"set-policy\"\n#define NID_set_policy          516\n#define OBJ_set_policy          OBJ_id_set,5L\n\n#define SN_set_certExt          \"set-certExt\"\n#define LN_set_certExt          \"certificate extensions\"\n#define NID_set_certExt         517\n#define OBJ_set_certExt         OBJ_id_set,7L\n\n#define SN_set_brand            \"set-brand\"\n#define NID_set_brand           518\n#define OBJ_set_brand           OBJ_id_set,8L\n\n#define SN_setct_PANData                \"setct-PANData\"\n#define NID_setct_PANData               519\n#define OBJ_setct_PANData               OBJ_set_ctype,0L\n\n#define SN_setct_PANToken               \"setct-PANToken\"\n#define NID_setct_PANToken              520\n#define OBJ_setct_PANToken              OBJ_set_ctype,1L\n\n#define SN_setct_PANOnly                \"setct-PANOnly\"\n#define NID_setct_PANOnly               521\n#define OBJ_setct_PANOnly               OBJ_set_ctype,2L\n\n#define SN_setct_OIData         \"setct-OIData\"\n#define NID_setct_OIData                522\n#define OBJ_setct_OIData                OBJ_set_ctype,3L\n\n#define SN_setct_PI             \"setct-PI\"\n#define NID_setct_PI            523\n#define OBJ_setct_PI            OBJ_set_ctype,4L\n\n#define SN_setct_PIData         \"setct-PIData\"\n#define NID_setct_PIData                524\n#define OBJ_setct_PIData                OBJ_set_ctype,5L\n\n#define SN_setct_PIDataUnsigned         \"setct-PIDataUnsigned\"\n#define NID_setct_PIDataUnsigned                525\n#define OBJ_setct_PIDataUnsigned                OBJ_set_ctype,6L\n\n#define SN_setct_HODInput               \"setct-HODInput\"\n#define NID_setct_HODInput              526\n#define OBJ_setct_HODInput              OBJ_set_ctype,7L\n\n#define SN_setct_AuthResBaggage         \"setct-AuthResBaggage\"\n#define NID_setct_AuthResBaggage                527\n#define OBJ_setct_AuthResBaggage                OBJ_set_ctype,8L\n\n#define SN_setct_AuthRevReqBaggage              \"setct-AuthRevReqBaggage\"\n#define NID_setct_AuthRevReqBaggage             528\n#define OBJ_setct_AuthRevReqBaggage             OBJ_set_ctype,9L\n\n#define SN_setct_AuthRevResBaggage              \"setct-AuthRevResBaggage\"\n#define NID_setct_AuthRevResBaggage             529\n#define OBJ_setct_AuthRevResBaggage             OBJ_set_ctype,10L\n\n#define SN_setct_CapTokenSeq            \"setct-CapTokenSeq\"\n#define NID_setct_CapTokenSeq           530\n#define OBJ_setct_CapTokenSeq           OBJ_set_ctype,11L\n\n#define SN_setct_PInitResData           \"setct-PInitResData\"\n#define NID_setct_PInitResData          531\n#define OBJ_setct_PInitResData          OBJ_set_ctype,12L\n\n#define SN_setct_PI_TBS         \"setct-PI-TBS\"\n#define NID_setct_PI_TBS                532\n#define OBJ_setct_PI_TBS                OBJ_set_ctype,13L\n\n#define SN_setct_PResData               \"setct-PResData\"\n#define NID_setct_PResData              533\n#define OBJ_setct_PResData              OBJ_set_ctype,14L\n\n#define SN_setct_AuthReqTBS             \"setct-AuthReqTBS\"\n#define NID_setct_AuthReqTBS            534\n#define OBJ_setct_AuthReqTBS            OBJ_set_ctype,16L\n\n#define SN_setct_AuthResTBS             \"setct-AuthResTBS\"\n#define NID_setct_AuthResTBS            535\n#define OBJ_setct_AuthResTBS            OBJ_set_ctype,17L\n\n#define SN_setct_AuthResTBSX            \"setct-AuthResTBSX\"\n#define NID_setct_AuthResTBSX           536\n#define OBJ_setct_AuthResTBSX           OBJ_set_ctype,18L\n\n#define SN_setct_AuthTokenTBS           \"setct-AuthTokenTBS\"\n#define NID_setct_AuthTokenTBS          537\n#define OBJ_setct_AuthTokenTBS          OBJ_set_ctype,19L\n\n#define SN_setct_CapTokenData           \"setct-CapTokenData\"\n#define NID_setct_CapTokenData          538\n#define OBJ_setct_CapTokenData          OBJ_set_ctype,20L\n\n#define SN_setct_CapTokenTBS            \"setct-CapTokenTBS\"\n#define NID_setct_CapTokenTBS           539\n#define OBJ_setct_CapTokenTBS           OBJ_set_ctype,21L\n\n#define SN_setct_AcqCardCodeMsg         \"setct-AcqCardCodeMsg\"\n#define NID_setct_AcqCardCodeMsg                540\n#define OBJ_setct_AcqCardCodeMsg                OBJ_set_ctype,22L\n\n#define SN_setct_AuthRevReqTBS          \"setct-AuthRevReqTBS\"\n#define NID_setct_AuthRevReqTBS         541\n#define OBJ_setct_AuthRevReqTBS         OBJ_set_ctype,23L\n\n#define SN_setct_AuthRevResData         \"setct-AuthRevResData\"\n#define NID_setct_AuthRevResData                542\n#define OBJ_setct_AuthRevResData                OBJ_set_ctype,24L\n\n#define SN_setct_AuthRevResTBS          \"setct-AuthRevResTBS\"\n#define NID_setct_AuthRevResTBS         543\n#define OBJ_setct_AuthRevResTBS         OBJ_set_ctype,25L\n\n#define SN_setct_CapReqTBS              \"setct-CapReqTBS\"\n#define NID_setct_CapReqTBS             544\n#define OBJ_setct_CapReqTBS             OBJ_set_ctype,26L\n\n#define SN_setct_CapReqTBSX             \"setct-CapReqTBSX\"\n#define NID_setct_CapReqTBSX            545\n#define OBJ_setct_CapReqTBSX            OBJ_set_ctype,27L\n\n#define SN_setct_CapResData             \"setct-CapResData\"\n#define NID_setct_CapResData            546\n#define OBJ_setct_CapResData            OBJ_set_ctype,28L\n\n#define SN_setct_CapRevReqTBS           \"setct-CapRevReqTBS\"\n#define NID_setct_CapRevReqTBS          547\n#define OBJ_setct_CapRevReqTBS          OBJ_set_ctype,29L\n\n#define SN_setct_CapRevReqTBSX          \"setct-CapRevReqTBSX\"\n#define NID_setct_CapRevReqTBSX         548\n#define OBJ_setct_CapRevReqTBSX         OBJ_set_ctype,30L\n\n#define SN_setct_CapRevResData          \"setct-CapRevResData\"\n#define NID_setct_CapRevResData         549\n#define OBJ_setct_CapRevResData         OBJ_set_ctype,31L\n\n#define SN_setct_CredReqTBS             \"setct-CredReqTBS\"\n#define NID_setct_CredReqTBS            550\n#define OBJ_setct_CredReqTBS            OBJ_set_ctype,32L\n\n#define SN_setct_CredReqTBSX            \"setct-CredReqTBSX\"\n#define NID_setct_CredReqTBSX           551\n#define OBJ_setct_CredReqTBSX           OBJ_set_ctype,33L\n\n#define SN_setct_CredResData            \"setct-CredResData\"\n#define NID_setct_CredResData           552\n#define OBJ_setct_CredResData           OBJ_set_ctype,34L\n\n#define SN_setct_CredRevReqTBS          \"setct-CredRevReqTBS\"\n#define NID_setct_CredRevReqTBS         553\n#define OBJ_setct_CredRevReqTBS         OBJ_set_ctype,35L\n\n#define SN_setct_CredRevReqTBSX         \"setct-CredRevReqTBSX\"\n#define NID_setct_CredRevReqTBSX                554\n#define OBJ_setct_CredRevReqTBSX                OBJ_set_ctype,36L\n\n#define SN_setct_CredRevResData         \"setct-CredRevResData\"\n#define NID_setct_CredRevResData                555\n#define OBJ_setct_CredRevResData                OBJ_set_ctype,37L\n\n#define SN_setct_PCertReqData           \"setct-PCertReqData\"\n#define NID_setct_PCertReqData          556\n#define OBJ_setct_PCertReqData          OBJ_set_ctype,38L\n\n#define SN_setct_PCertResTBS            \"setct-PCertResTBS\"\n#define NID_setct_PCertResTBS           557\n#define OBJ_setct_PCertResTBS           OBJ_set_ctype,39L\n\n#define SN_setct_BatchAdminReqData              \"setct-BatchAdminReqData\"\n#define NID_setct_BatchAdminReqData             558\n#define OBJ_setct_BatchAdminReqData             OBJ_set_ctype,40L\n\n#define SN_setct_BatchAdminResData              \"setct-BatchAdminResData\"\n#define NID_setct_BatchAdminResData             559\n#define OBJ_setct_BatchAdminResData             OBJ_set_ctype,41L\n\n#define SN_setct_CardCInitResTBS                \"setct-CardCInitResTBS\"\n#define NID_setct_CardCInitResTBS               560\n#define OBJ_setct_CardCInitResTBS               OBJ_set_ctype,42L\n\n#define SN_setct_MeAqCInitResTBS                \"setct-MeAqCInitResTBS\"\n#define NID_setct_MeAqCInitResTBS               561\n#define OBJ_setct_MeAqCInitResTBS               OBJ_set_ctype,43L\n\n#define SN_setct_RegFormResTBS          \"setct-RegFormResTBS\"\n#define NID_setct_RegFormResTBS         562\n#define OBJ_setct_RegFormResTBS         OBJ_set_ctype,44L\n\n#define SN_setct_CertReqData            \"setct-CertReqData\"\n#define NID_setct_CertReqData           563\n#define OBJ_setct_CertReqData           OBJ_set_ctype,45L\n\n#define SN_setct_CertReqTBS             \"setct-CertReqTBS\"\n#define NID_setct_CertReqTBS            564\n#define OBJ_setct_CertReqTBS            OBJ_set_ctype,46L\n\n#define SN_setct_CertResData            \"setct-CertResData\"\n#define NID_setct_CertResData           565\n#define OBJ_setct_CertResData           OBJ_set_ctype,47L\n\n#define SN_setct_CertInqReqTBS          \"setct-CertInqReqTBS\"\n#define NID_setct_CertInqReqTBS         566\n#define OBJ_setct_CertInqReqTBS         OBJ_set_ctype,48L\n\n#define SN_setct_ErrorTBS               \"setct-ErrorTBS\"\n#define NID_setct_ErrorTBS              567\n#define OBJ_setct_ErrorTBS              OBJ_set_ctype,49L\n\n#define SN_setct_PIDualSignedTBE                \"setct-PIDualSignedTBE\"\n#define NID_setct_PIDualSignedTBE               568\n#define OBJ_setct_PIDualSignedTBE               OBJ_set_ctype,50L\n\n#define SN_setct_PIUnsignedTBE          \"setct-PIUnsignedTBE\"\n#define NID_setct_PIUnsignedTBE         569\n#define OBJ_setct_PIUnsignedTBE         OBJ_set_ctype,51L\n\n#define SN_setct_AuthReqTBE             \"setct-AuthReqTBE\"\n#define NID_setct_AuthReqTBE            570\n#define OBJ_setct_AuthReqTBE            OBJ_set_ctype,52L\n\n#define SN_setct_AuthResTBE             \"setct-AuthResTBE\"\n#define NID_setct_AuthResTBE            571\n#define OBJ_setct_AuthResTBE            OBJ_set_ctype,53L\n\n#define SN_setct_AuthResTBEX            \"setct-AuthResTBEX\"\n#define NID_setct_AuthResTBEX           572\n#define OBJ_setct_AuthResTBEX           OBJ_set_ctype,54L\n\n#define SN_setct_AuthTokenTBE           \"setct-AuthTokenTBE\"\n#define NID_setct_AuthTokenTBE          573\n#define OBJ_setct_AuthTokenTBE          OBJ_set_ctype,55L\n\n#define SN_setct_CapTokenTBE            \"setct-CapTokenTBE\"\n#define NID_setct_CapTokenTBE           574\n#define OBJ_setct_CapTokenTBE           OBJ_set_ctype,56L\n\n#define SN_setct_CapTokenTBEX           \"setct-CapTokenTBEX\"\n#define NID_setct_CapTokenTBEX          575\n#define OBJ_setct_CapTokenTBEX          OBJ_set_ctype,57L\n\n#define SN_setct_AcqCardCodeMsgTBE              \"setct-AcqCardCodeMsgTBE\"\n#define NID_setct_AcqCardCodeMsgTBE             576\n#define OBJ_setct_AcqCardCodeMsgTBE             OBJ_set_ctype,58L\n\n#define SN_setct_AuthRevReqTBE          \"setct-AuthRevReqTBE\"\n#define NID_setct_AuthRevReqTBE         577\n#define OBJ_setct_AuthRevReqTBE         OBJ_set_ctype,59L\n\n#define SN_setct_AuthRevResTBE          \"setct-AuthRevResTBE\"\n#define NID_setct_AuthRevResTBE         578\n#define OBJ_setct_AuthRevResTBE         OBJ_set_ctype,60L\n\n#define SN_setct_AuthRevResTBEB         \"setct-AuthRevResTBEB\"\n#define NID_setct_AuthRevResTBEB                579\n#define OBJ_setct_AuthRevResTBEB                OBJ_set_ctype,61L\n\n#define SN_setct_CapReqTBE              \"setct-CapReqTBE\"\n#define NID_setct_CapReqTBE             580\n#define OBJ_setct_CapReqTBE             OBJ_set_ctype,62L\n\n#define SN_setct_CapReqTBEX             \"setct-CapReqTBEX\"\n#define NID_setct_CapReqTBEX            581\n#define OBJ_setct_CapReqTBEX            OBJ_set_ctype,63L\n\n#define SN_setct_CapResTBE              \"setct-CapResTBE\"\n#define NID_setct_CapResTBE             582\n#define OBJ_setct_CapResTBE             OBJ_set_ctype,64L\n\n#define SN_setct_CapRevReqTBE           \"setct-CapRevReqTBE\"\n#define NID_setct_CapRevReqTBE          583\n#define OBJ_setct_CapRevReqTBE          OBJ_set_ctype,65L\n\n#define SN_setct_CapRevReqTBEX          \"setct-CapRevReqTBEX\"\n#define NID_setct_CapRevReqTBEX         584\n#define OBJ_setct_CapRevReqTBEX         OBJ_set_ctype,66L\n\n#define SN_setct_CapRevResTBE           \"setct-CapRevResTBE\"\n#define NID_setct_CapRevResTBE          585\n#define OBJ_setct_CapRevResTBE          OBJ_set_ctype,67L\n\n#define SN_setct_CredReqTBE             \"setct-CredReqTBE\"\n#define NID_setct_CredReqTBE            586\n#define OBJ_setct_CredReqTBE            OBJ_set_ctype,68L\n\n#define SN_setct_CredReqTBEX            \"setct-CredReqTBEX\"\n#define NID_setct_CredReqTBEX           587\n#define OBJ_setct_CredReqTBEX           OBJ_set_ctype,69L\n\n#define SN_setct_CredResTBE             \"setct-CredResTBE\"\n#define NID_setct_CredResTBE            588\n#define OBJ_setct_CredResTBE            OBJ_set_ctype,70L\n\n#define SN_setct_CredRevReqTBE          \"setct-CredRevReqTBE\"\n#define NID_setct_CredRevReqTBE         589\n#define OBJ_setct_CredRevReqTBE         OBJ_set_ctype,71L\n\n#define SN_setct_CredRevReqTBEX         \"setct-CredRevReqTBEX\"\n#define NID_setct_CredRevReqTBEX                590\n#define OBJ_setct_CredRevReqTBEX                OBJ_set_ctype,72L\n\n#define SN_setct_CredRevResTBE          \"setct-CredRevResTBE\"\n#define NID_setct_CredRevResTBE         591\n#define OBJ_setct_CredRevResTBE         OBJ_set_ctype,73L\n\n#define SN_setct_BatchAdminReqTBE               \"setct-BatchAdminReqTBE\"\n#define NID_setct_BatchAdminReqTBE              592\n#define OBJ_setct_BatchAdminReqTBE              OBJ_set_ctype,74L\n\n#define SN_setct_BatchAdminResTBE               \"setct-BatchAdminResTBE\"\n#define NID_setct_BatchAdminResTBE              593\n#define OBJ_setct_BatchAdminResTBE              OBJ_set_ctype,75L\n\n#define SN_setct_RegFormReqTBE          \"setct-RegFormReqTBE\"\n#define NID_setct_RegFormReqTBE         594\n#define OBJ_setct_RegFormReqTBE         OBJ_set_ctype,76L\n\n#define SN_setct_CertReqTBE             \"setct-CertReqTBE\"\n#define NID_setct_CertReqTBE            595\n#define OBJ_setct_CertReqTBE            OBJ_set_ctype,77L\n\n#define SN_setct_CertReqTBEX            \"setct-CertReqTBEX\"\n#define NID_setct_CertReqTBEX           596\n#define OBJ_setct_CertReqTBEX           OBJ_set_ctype,78L\n\n#define SN_setct_CertResTBE             \"setct-CertResTBE\"\n#define NID_setct_CertResTBE            597\n#define OBJ_setct_CertResTBE            OBJ_set_ctype,79L\n\n#define SN_setct_CRLNotificationTBS             \"setct-CRLNotificationTBS\"\n#define NID_setct_CRLNotificationTBS            598\n#define OBJ_setct_CRLNotificationTBS            OBJ_set_ctype,80L\n\n#define SN_setct_CRLNotificationResTBS          \"setct-CRLNotificationResTBS\"\n#define NID_setct_CRLNotificationResTBS         599\n#define OBJ_setct_CRLNotificationResTBS         OBJ_set_ctype,81L\n\n#define SN_setct_BCIDistributionTBS             \"setct-BCIDistributionTBS\"\n#define NID_setct_BCIDistributionTBS            600\n#define OBJ_setct_BCIDistributionTBS            OBJ_set_ctype,82L\n\n#define SN_setext_genCrypt              \"setext-genCrypt\"\n#define LN_setext_genCrypt              \"generic cryptogram\"\n#define NID_setext_genCrypt             601\n#define OBJ_setext_genCrypt             OBJ_set_msgExt,1L\n\n#define SN_setext_miAuth                \"setext-miAuth\"\n#define LN_setext_miAuth                \"merchant initiated auth\"\n#define NID_setext_miAuth               602\n#define OBJ_setext_miAuth               OBJ_set_msgExt,3L\n\n#define SN_setext_pinSecure             \"setext-pinSecure\"\n#define NID_setext_pinSecure            603\n#define OBJ_setext_pinSecure            OBJ_set_msgExt,4L\n\n#define SN_setext_pinAny                \"setext-pinAny\"\n#define NID_setext_pinAny               604\n#define OBJ_setext_pinAny               OBJ_set_msgExt,5L\n\n#define SN_setext_track2                \"setext-track2\"\n#define NID_setext_track2               605\n#define OBJ_setext_track2               OBJ_set_msgExt,7L\n\n#define SN_setext_cv            \"setext-cv\"\n#define LN_setext_cv            \"additional verification\"\n#define NID_setext_cv           606\n#define OBJ_setext_cv           OBJ_set_msgExt,8L\n\n#define SN_set_policy_root              \"set-policy-root\"\n#define NID_set_policy_root             607\n#define OBJ_set_policy_root             OBJ_set_policy,0L\n\n#define SN_setCext_hashedRoot           \"setCext-hashedRoot\"\n#define NID_setCext_hashedRoot          608\n#define OBJ_setCext_hashedRoot          OBJ_set_certExt,0L\n\n#define SN_setCext_certType             \"setCext-certType\"\n#define NID_setCext_certType            609\n#define OBJ_setCext_certType            OBJ_set_certExt,1L\n\n#define SN_setCext_merchData            \"setCext-merchData\"\n#define NID_setCext_merchData           610\n#define OBJ_setCext_merchData           OBJ_set_certExt,2L\n\n#define SN_setCext_cCertRequired                \"setCext-cCertRequired\"\n#define NID_setCext_cCertRequired               611\n#define OBJ_setCext_cCertRequired               OBJ_set_certExt,3L\n\n#define SN_setCext_tunneling            \"setCext-tunneling\"\n#define NID_setCext_tunneling           612\n#define OBJ_setCext_tunneling           OBJ_set_certExt,4L\n\n#define SN_setCext_setExt               \"setCext-setExt\"\n#define NID_setCext_setExt              613\n#define OBJ_setCext_setExt              OBJ_set_certExt,5L\n\n#define SN_setCext_setQualf             \"setCext-setQualf\"\n#define NID_setCext_setQualf            614\n#define OBJ_setCext_setQualf            OBJ_set_certExt,6L\n\n#define SN_setCext_PGWYcapabilities             \"setCext-PGWYcapabilities\"\n#define NID_setCext_PGWYcapabilities            615\n#define OBJ_setCext_PGWYcapabilities            OBJ_set_certExt,7L\n\n#define SN_setCext_TokenIdentifier              \"setCext-TokenIdentifier\"\n#define NID_setCext_TokenIdentifier             616\n#define OBJ_setCext_TokenIdentifier             OBJ_set_certExt,8L\n\n#define SN_setCext_Track2Data           \"setCext-Track2Data\"\n#define NID_setCext_Track2Data          617\n#define OBJ_setCext_Track2Data          OBJ_set_certExt,9L\n\n#define SN_setCext_TokenType            \"setCext-TokenType\"\n#define NID_setCext_TokenType           618\n#define OBJ_setCext_TokenType           OBJ_set_certExt,10L\n\n#define SN_setCext_IssuerCapabilities           \"setCext-IssuerCapabilities\"\n#define NID_setCext_IssuerCapabilities          619\n#define OBJ_setCext_IssuerCapabilities          OBJ_set_certExt,11L\n\n#define SN_setAttr_Cert         \"setAttr-Cert\"\n#define NID_setAttr_Cert                620\n#define OBJ_setAttr_Cert                OBJ_set_attr,0L\n\n#define SN_setAttr_PGWYcap              \"setAttr-PGWYcap\"\n#define LN_setAttr_PGWYcap              \"payment gateway capabilities\"\n#define NID_setAttr_PGWYcap             621\n#define OBJ_setAttr_PGWYcap             OBJ_set_attr,1L\n\n#define SN_setAttr_TokenType            \"setAttr-TokenType\"\n#define NID_setAttr_TokenType           622\n#define OBJ_setAttr_TokenType           OBJ_set_attr,2L\n\n#define SN_setAttr_IssCap               \"setAttr-IssCap\"\n#define LN_setAttr_IssCap               \"issuer capabilities\"\n#define NID_setAttr_IssCap              623\n#define OBJ_setAttr_IssCap              OBJ_set_attr,3L\n\n#define SN_set_rootKeyThumb             \"set-rootKeyThumb\"\n#define NID_set_rootKeyThumb            624\n#define OBJ_set_rootKeyThumb            OBJ_setAttr_Cert,0L\n\n#define SN_set_addPolicy                \"set-addPolicy\"\n#define NID_set_addPolicy               625\n#define OBJ_set_addPolicy               OBJ_setAttr_Cert,1L\n\n#define SN_setAttr_Token_EMV            \"setAttr-Token-EMV\"\n#define NID_setAttr_Token_EMV           626\n#define OBJ_setAttr_Token_EMV           OBJ_setAttr_TokenType,1L\n\n#define SN_setAttr_Token_B0Prime                \"setAttr-Token-B0Prime\"\n#define NID_setAttr_Token_B0Prime               627\n#define OBJ_setAttr_Token_B0Prime               OBJ_setAttr_TokenType,2L\n\n#define SN_setAttr_IssCap_CVM           \"setAttr-IssCap-CVM\"\n#define NID_setAttr_IssCap_CVM          628\n#define OBJ_setAttr_IssCap_CVM          OBJ_setAttr_IssCap,3L\n\n#define SN_setAttr_IssCap_T2            \"setAttr-IssCap-T2\"\n#define NID_setAttr_IssCap_T2           629\n#define OBJ_setAttr_IssCap_T2           OBJ_setAttr_IssCap,4L\n\n#define SN_setAttr_IssCap_Sig           \"setAttr-IssCap-Sig\"\n#define NID_setAttr_IssCap_Sig          630\n#define OBJ_setAttr_IssCap_Sig          OBJ_setAttr_IssCap,5L\n\n#define SN_setAttr_GenCryptgrm          \"setAttr-GenCryptgrm\"\n#define LN_setAttr_GenCryptgrm          \"generate cryptogram\"\n#define NID_setAttr_GenCryptgrm         631\n#define OBJ_setAttr_GenCryptgrm         OBJ_setAttr_IssCap_CVM,1L\n\n#define SN_setAttr_T2Enc                \"setAttr-T2Enc\"\n#define LN_setAttr_T2Enc                \"encrypted track 2\"\n#define NID_setAttr_T2Enc               632\n#define OBJ_setAttr_T2Enc               OBJ_setAttr_IssCap_T2,1L\n\n#define SN_setAttr_T2cleartxt           \"setAttr-T2cleartxt\"\n#define LN_setAttr_T2cleartxt           \"cleartext track 2\"\n#define NID_setAttr_T2cleartxt          633\n#define OBJ_setAttr_T2cleartxt          OBJ_setAttr_IssCap_T2,2L\n\n#define SN_setAttr_TokICCsig            \"setAttr-TokICCsig\"\n#define LN_setAttr_TokICCsig            \"ICC or token signature\"\n#define NID_setAttr_TokICCsig           634\n#define OBJ_setAttr_TokICCsig           OBJ_setAttr_IssCap_Sig,1L\n\n#define SN_setAttr_SecDevSig            \"setAttr-SecDevSig\"\n#define LN_setAttr_SecDevSig            \"secure device signature\"\n#define NID_setAttr_SecDevSig           635\n#define OBJ_setAttr_SecDevSig           OBJ_setAttr_IssCap_Sig,2L\n\n#define SN_set_brand_IATA_ATA           \"set-brand-IATA-ATA\"\n#define NID_set_brand_IATA_ATA          636\n#define OBJ_set_brand_IATA_ATA          OBJ_set_brand,1L\n\n#define SN_set_brand_Diners             \"set-brand-Diners\"\n#define NID_set_brand_Diners            637\n#define OBJ_set_brand_Diners            OBJ_set_brand,30L\n\n#define SN_set_brand_AmericanExpress            \"set-brand-AmericanExpress\"\n#define NID_set_brand_AmericanExpress           638\n#define OBJ_set_brand_AmericanExpress           OBJ_set_brand,34L\n\n#define SN_set_brand_JCB                \"set-brand-JCB\"\n#define NID_set_brand_JCB               639\n#define OBJ_set_brand_JCB               OBJ_set_brand,35L\n\n#define SN_set_brand_Visa               \"set-brand-Visa\"\n#define NID_set_brand_Visa              640\n#define OBJ_set_brand_Visa              OBJ_set_brand,4L\n\n#define SN_set_brand_MasterCard         \"set-brand-MasterCard\"\n#define NID_set_brand_MasterCard                641\n#define OBJ_set_brand_MasterCard                OBJ_set_brand,5L\n\n#define SN_set_brand_Novus              \"set-brand-Novus\"\n#define NID_set_brand_Novus             642\n#define OBJ_set_brand_Novus             OBJ_set_brand,6011L\n\n#define SN_des_cdmf             \"DES-CDMF\"\n#define LN_des_cdmf             \"des-cdmf\"\n#define NID_des_cdmf            643\n#define OBJ_des_cdmf            OBJ_rsadsi,3L,10L\n\n#define SN_rsaOAEPEncryptionSET         \"rsaOAEPEncryptionSET\"\n#define NID_rsaOAEPEncryptionSET                644\n#define OBJ_rsaOAEPEncryptionSET                OBJ_rsadsi,1L,1L,6L\n\n#define SN_ipsec3               \"Oakley-EC2N-3\"\n#define LN_ipsec3               \"ipsec3\"\n#define NID_ipsec3              749\n\n#define SN_ipsec4               \"Oakley-EC2N-4\"\n#define LN_ipsec4               \"ipsec4\"\n#define NID_ipsec4              750\n\n#define SN_whirlpool            \"whirlpool\"\n#define NID_whirlpool           804\n#define OBJ_whirlpool           OBJ_iso,0L,10118L,3L,0L,55L\n\n#define SN_cryptopro            \"cryptopro\"\n#define NID_cryptopro           805\n#define OBJ_cryptopro           OBJ_member_body,643L,2L,2L\n\n#define SN_cryptocom            \"cryptocom\"\n#define NID_cryptocom           806\n#define OBJ_cryptocom           OBJ_member_body,643L,2L,9L\n\n#define SN_id_tc26              \"id-tc26\"\n#define NID_id_tc26             974\n#define OBJ_id_tc26             OBJ_member_body,643L,7L,1L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001          \"id-GostR3411-94-with-GostR3410-2001\"\n#define LN_id_GostR3411_94_with_GostR3410_2001          \"GOST R 34.11-94 with GOST R 34.10-2001\"\n#define NID_id_GostR3411_94_with_GostR3410_2001         807\n#define OBJ_id_GostR3411_94_with_GostR3410_2001         OBJ_cryptopro,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_94            \"id-GostR3411-94-with-GostR3410-94\"\n#define LN_id_GostR3411_94_with_GostR3410_94            \"GOST R 34.11-94 with GOST R 34.10-94\"\n#define NID_id_GostR3411_94_with_GostR3410_94           808\n#define OBJ_id_GostR3411_94_with_GostR3410_94           OBJ_cryptopro,4L\n\n#define SN_id_GostR3411_94              \"md_gost94\"\n#define LN_id_GostR3411_94              \"GOST R 34.11-94\"\n#define NID_id_GostR3411_94             809\n#define OBJ_id_GostR3411_94             OBJ_cryptopro,9L\n\n#define SN_id_HMACGostR3411_94          \"id-HMACGostR3411-94\"\n#define LN_id_HMACGostR3411_94          \"HMAC GOST 34.11-94\"\n#define NID_id_HMACGostR3411_94         810\n#define OBJ_id_HMACGostR3411_94         OBJ_cryptopro,10L\n\n#define SN_id_GostR3410_2001            \"gost2001\"\n#define LN_id_GostR3410_2001            \"GOST R 34.10-2001\"\n#define NID_id_GostR3410_2001           811\n#define OBJ_id_GostR3410_2001           OBJ_cryptopro,19L\n\n#define SN_id_GostR3410_94              \"gost94\"\n#define LN_id_GostR3410_94              \"GOST R 34.10-94\"\n#define NID_id_GostR3410_94             812\n#define OBJ_id_GostR3410_94             OBJ_cryptopro,20L\n\n#define SN_id_Gost28147_89              \"gost89\"\n#define LN_id_Gost28147_89              \"GOST 28147-89\"\n#define NID_id_Gost28147_89             813\n#define OBJ_id_Gost28147_89             OBJ_cryptopro,21L\n\n#define SN_gost89_cnt           \"gost89-cnt\"\n#define NID_gost89_cnt          814\n\n#define SN_gost89_cnt_12                \"gost89-cnt-12\"\n#define NID_gost89_cnt_12               975\n\n#define SN_gost89_cbc           \"gost89-cbc\"\n#define NID_gost89_cbc          1009\n\n#define SN_gost89_ecb           \"gost89-ecb\"\n#define NID_gost89_ecb          1010\n\n#define SN_gost89_ctr           \"gost89-ctr\"\n#define NID_gost89_ctr          1011\n\n#define SN_id_Gost28147_89_MAC          \"gost-mac\"\n#define LN_id_Gost28147_89_MAC          \"GOST 28147-89 MAC\"\n#define NID_id_Gost28147_89_MAC         815\n#define OBJ_id_Gost28147_89_MAC         OBJ_cryptopro,22L\n\n#define SN_gost_mac_12          \"gost-mac-12\"\n#define NID_gost_mac_12         976\n\n#define SN_id_GostR3411_94_prf          \"prf-gostr3411-94\"\n#define LN_id_GostR3411_94_prf          \"GOST R 34.11-94 PRF\"\n#define NID_id_GostR3411_94_prf         816\n#define OBJ_id_GostR3411_94_prf         OBJ_cryptopro,23L\n\n#define SN_id_GostR3410_2001DH          \"id-GostR3410-2001DH\"\n#define LN_id_GostR3410_2001DH          \"GOST R 34.10-2001 DH\"\n#define NID_id_GostR3410_2001DH         817\n#define OBJ_id_GostR3410_2001DH         OBJ_cryptopro,98L\n\n#define SN_id_GostR3410_94DH            \"id-GostR3410-94DH\"\n#define LN_id_GostR3410_94DH            \"GOST R 34.10-94 DH\"\n#define NID_id_GostR3410_94DH           818\n#define OBJ_id_GostR3410_94DH           OBJ_cryptopro,99L\n\n#define SN_id_Gost28147_89_CryptoPro_KeyMeshing         \"id-Gost28147-89-CryptoPro-KeyMeshing\"\n#define NID_id_Gost28147_89_CryptoPro_KeyMeshing                819\n#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing                OBJ_cryptopro,14L,1L\n\n#define SN_id_Gost28147_89_None_KeyMeshing              \"id-Gost28147-89-None-KeyMeshing\"\n#define NID_id_Gost28147_89_None_KeyMeshing             820\n#define OBJ_id_Gost28147_89_None_KeyMeshing             OBJ_cryptopro,14L,0L\n\n#define SN_id_GostR3411_94_TestParamSet         \"id-GostR3411-94-TestParamSet\"\n#define NID_id_GostR3411_94_TestParamSet                821\n#define OBJ_id_GostR3411_94_TestParamSet                OBJ_cryptopro,30L,0L\n\n#define SN_id_GostR3411_94_CryptoProParamSet            \"id-GostR3411-94-CryptoProParamSet\"\n#define NID_id_GostR3411_94_CryptoProParamSet           822\n#define OBJ_id_GostR3411_94_CryptoProParamSet           OBJ_cryptopro,30L,1L\n\n#define SN_id_Gost28147_89_TestParamSet         \"id-Gost28147-89-TestParamSet\"\n#define NID_id_Gost28147_89_TestParamSet                823\n#define OBJ_id_Gost28147_89_TestParamSet                OBJ_cryptopro,31L,0L\n\n#define SN_id_Gost28147_89_CryptoPro_A_ParamSet         \"id-Gost28147-89-CryptoPro-A-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_A_ParamSet                824\n#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet                OBJ_cryptopro,31L,1L\n\n#define SN_id_Gost28147_89_CryptoPro_B_ParamSet         \"id-Gost28147-89-CryptoPro-B-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_B_ParamSet                825\n#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet                OBJ_cryptopro,31L,2L\n\n#define SN_id_Gost28147_89_CryptoPro_C_ParamSet         \"id-Gost28147-89-CryptoPro-C-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_C_ParamSet                826\n#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet                OBJ_cryptopro,31L,3L\n\n#define SN_id_Gost28147_89_CryptoPro_D_ParamSet         \"id-Gost28147-89-CryptoPro-D-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_D_ParamSet                827\n#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet                OBJ_cryptopro,31L,4L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                828\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet                OBJ_cryptopro,31L,5L\n\n#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet         \"id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                829\n#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet                OBJ_cryptopro,31L,6L\n\n#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet             \"id-Gost28147-89-CryptoPro-RIC-1-ParamSet\"\n#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            830\n#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet            OBJ_cryptopro,31L,7L\n\n#define SN_id_GostR3410_94_TestParamSet         \"id-GostR3410-94-TestParamSet\"\n#define NID_id_GostR3410_94_TestParamSet                831\n#define OBJ_id_GostR3410_94_TestParamSet                OBJ_cryptopro,32L,0L\n\n#define SN_id_GostR3410_94_CryptoPro_A_ParamSet         \"id-GostR3410-94-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_A_ParamSet                832\n#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet                OBJ_cryptopro,32L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_B_ParamSet         \"id-GostR3410-94-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_B_ParamSet                833\n#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet                OBJ_cryptopro,32L,3L\n\n#define SN_id_GostR3410_94_CryptoPro_C_ParamSet         \"id-GostR3410-94-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_C_ParamSet                834\n#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet                OBJ_cryptopro,32L,4L\n\n#define SN_id_GostR3410_94_CryptoPro_D_ParamSet         \"id-GostR3410-94-CryptoPro-D-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_D_ParamSet                835\n#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet                OBJ_cryptopro,32L,5L\n\n#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet              \"id-GostR3410-94-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet             836\n#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet             OBJ_cryptopro,33L,1L\n\n#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet              \"id-GostR3410-94-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet             837\n#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet             OBJ_cryptopro,33L,2L\n\n#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet              \"id-GostR3410-94-CryptoPro-XchC-ParamSet\"\n#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet             838\n#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet             OBJ_cryptopro,33L,3L\n\n#define SN_id_GostR3410_2001_TestParamSet               \"id-GostR3410-2001-TestParamSet\"\n#define NID_id_GostR3410_2001_TestParamSet              839\n#define OBJ_id_GostR3410_2001_TestParamSet              OBJ_cryptopro,35L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet               \"id-GostR3410-2001-CryptoPro-A-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet              840\n#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet              OBJ_cryptopro,35L,1L\n\n#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet               \"id-GostR3410-2001-CryptoPro-B-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet              841\n#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet              OBJ_cryptopro,35L,2L\n\n#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet               \"id-GostR3410-2001-CryptoPro-C-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet              842\n#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet              OBJ_cryptopro,35L,3L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet            \"id-GostR3410-2001-CryptoPro-XchA-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet           843\n#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet           OBJ_cryptopro,36L,0L\n\n#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet            \"id-GostR3410-2001-CryptoPro-XchB-ParamSet\"\n#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet           844\n#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet           OBJ_cryptopro,36L,1L\n\n#define SN_id_GostR3410_94_a            \"id-GostR3410-94-a\"\n#define NID_id_GostR3410_94_a           845\n#define OBJ_id_GostR3410_94_a           OBJ_id_GostR3410_94,1L\n\n#define SN_id_GostR3410_94_aBis         \"id-GostR3410-94-aBis\"\n#define NID_id_GostR3410_94_aBis                846\n#define OBJ_id_GostR3410_94_aBis                OBJ_id_GostR3410_94,2L\n\n#define SN_id_GostR3410_94_b            \"id-GostR3410-94-b\"\n#define NID_id_GostR3410_94_b           847\n#define OBJ_id_GostR3410_94_b           OBJ_id_GostR3410_94,3L\n\n#define SN_id_GostR3410_94_bBis         \"id-GostR3410-94-bBis\"\n#define NID_id_GostR3410_94_bBis                848\n#define OBJ_id_GostR3410_94_bBis                OBJ_id_GostR3410_94,4L\n\n#define SN_id_Gost28147_89_cc           \"id-Gost28147-89-cc\"\n#define LN_id_Gost28147_89_cc           \"GOST 28147-89 Cryptocom ParamSet\"\n#define NID_id_Gost28147_89_cc          849\n#define OBJ_id_Gost28147_89_cc          OBJ_cryptocom,1L,6L,1L\n\n#define SN_id_GostR3410_94_cc           \"gost94cc\"\n#define LN_id_GostR3410_94_cc           \"GOST 34.10-94 Cryptocom\"\n#define NID_id_GostR3410_94_cc          850\n#define OBJ_id_GostR3410_94_cc          OBJ_cryptocom,1L,5L,3L\n\n#define SN_id_GostR3410_2001_cc         \"gost2001cc\"\n#define LN_id_GostR3410_2001_cc         \"GOST 34.10-2001 Cryptocom\"\n#define NID_id_GostR3410_2001_cc                851\n#define OBJ_id_GostR3410_2001_cc                OBJ_cryptocom,1L,5L,4L\n\n#define SN_id_GostR3411_94_with_GostR3410_94_cc         \"id-GostR3411-94-with-GostR3410-94-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_94_cc         \"GOST R 34.11-94 with GOST R 34.10-94 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_94_cc                852\n#define OBJ_id_GostR3411_94_with_GostR3410_94_cc                OBJ_cryptocom,1L,3L,3L\n\n#define SN_id_GostR3411_94_with_GostR3410_2001_cc               \"id-GostR3411-94-with-GostR3410-2001-cc\"\n#define LN_id_GostR3411_94_with_GostR3410_2001_cc               \"GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom\"\n#define NID_id_GostR3411_94_with_GostR3410_2001_cc              853\n#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc              OBJ_cryptocom,1L,3L,4L\n\n#define SN_id_GostR3410_2001_ParamSet_cc                \"id-GostR3410-2001-ParamSet-cc\"\n#define LN_id_GostR3410_2001_ParamSet_cc                \"GOST R 3410-2001 Parameter Set Cryptocom\"\n#define NID_id_GostR3410_2001_ParamSet_cc               854\n#define OBJ_id_GostR3410_2001_ParamSet_cc               OBJ_cryptocom,1L,8L,1L\n\n#define SN_id_tc26_algorithms           \"id-tc26-algorithms\"\n#define NID_id_tc26_algorithms          977\n#define OBJ_id_tc26_algorithms          OBJ_id_tc26,1L\n\n#define SN_id_tc26_sign         \"id-tc26-sign\"\n#define NID_id_tc26_sign                978\n#define OBJ_id_tc26_sign                OBJ_id_tc26_algorithms,1L\n\n#define SN_id_GostR3410_2012_256                \"gost2012_256\"\n#define LN_id_GostR3410_2012_256                \"GOST R 34.10-2012 with 256 bit modulus\"\n#define NID_id_GostR3410_2012_256               979\n#define OBJ_id_GostR3410_2012_256               OBJ_id_tc26_sign,1L\n\n#define SN_id_GostR3410_2012_512                \"gost2012_512\"\n#define LN_id_GostR3410_2012_512                \"GOST R 34.10-2012 with 512 bit modulus\"\n#define NID_id_GostR3410_2012_512               980\n#define OBJ_id_GostR3410_2012_512               OBJ_id_tc26_sign,2L\n\n#define SN_id_tc26_digest               \"id-tc26-digest\"\n#define NID_id_tc26_digest              981\n#define OBJ_id_tc26_digest              OBJ_id_tc26_algorithms,2L\n\n#define SN_id_GostR3411_2012_256                \"md_gost12_256\"\n#define LN_id_GostR3411_2012_256                \"GOST R 34.11-2012 with 256 bit hash\"\n#define NID_id_GostR3411_2012_256               982\n#define OBJ_id_GostR3411_2012_256               OBJ_id_tc26_digest,2L\n\n#define SN_id_GostR3411_2012_512                \"md_gost12_512\"\n#define LN_id_GostR3411_2012_512                \"GOST R 34.11-2012 with 512 bit hash\"\n#define NID_id_GostR3411_2012_512               983\n#define OBJ_id_GostR3411_2012_512               OBJ_id_tc26_digest,3L\n\n#define SN_id_tc26_signwithdigest               \"id-tc26-signwithdigest\"\n#define NID_id_tc26_signwithdigest              984\n#define OBJ_id_tc26_signwithdigest              OBJ_id_tc26_algorithms,3L\n\n#define SN_id_tc26_signwithdigest_gost3410_2012_256             \"id-tc26-signwithdigest-gost3410-2012-256\"\n#define LN_id_tc26_signwithdigest_gost3410_2012_256             \"GOST R 34.10-2012 with GOST R 34.11-2012 (256 bit)\"\n#define NID_id_tc26_signwithdigest_gost3410_2012_256            985\n#define OBJ_id_tc26_signwithdigest_gost3410_2012_256            OBJ_id_tc26_signwithdigest,2L\n\n#define SN_id_tc26_signwithdigest_gost3410_2012_512             \"id-tc26-signwithdigest-gost3410-2012-512\"\n#define LN_id_tc26_signwithdigest_gost3410_2012_512             \"GOST R 34.10-2012 with GOST R 34.11-2012 (512 bit)\"\n#define NID_id_tc26_signwithdigest_gost3410_2012_512            986\n#define OBJ_id_tc26_signwithdigest_gost3410_2012_512            OBJ_id_tc26_signwithdigest,3L\n\n#define SN_id_tc26_mac          \"id-tc26-mac\"\n#define NID_id_tc26_mac         987\n#define OBJ_id_tc26_mac         OBJ_id_tc26_algorithms,4L\n\n#define SN_id_tc26_hmac_gost_3411_2012_256              \"id-tc26-hmac-gost-3411-2012-256\"\n#define LN_id_tc26_hmac_gost_3411_2012_256              \"HMAC GOST 34.11-2012 256 bit\"\n#define NID_id_tc26_hmac_gost_3411_2012_256             988\n#define OBJ_id_tc26_hmac_gost_3411_2012_256             OBJ_id_tc26_mac,1L\n\n#define SN_id_tc26_hmac_gost_3411_2012_512              \"id-tc26-hmac-gost-3411-2012-512\"\n#define LN_id_tc26_hmac_gost_3411_2012_512              \"HMAC GOST 34.11-2012 512 bit\"\n#define NID_id_tc26_hmac_gost_3411_2012_512             989\n#define OBJ_id_tc26_hmac_gost_3411_2012_512             OBJ_id_tc26_mac,2L\n\n#define SN_id_tc26_cipher               \"id-tc26-cipher\"\n#define NID_id_tc26_cipher              990\n#define OBJ_id_tc26_cipher              OBJ_id_tc26_algorithms,5L\n\n#define SN_id_tc26_cipher_gostr3412_2015_magma          \"id-tc26-cipher-gostr3412-2015-magma\"\n#define NID_id_tc26_cipher_gostr3412_2015_magma         1173\n#define OBJ_id_tc26_cipher_gostr3412_2015_magma         OBJ_id_tc26_cipher,1L\n\n#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm         \"id-tc26-cipher-gostr3412-2015-magma-ctracpkm\"\n#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm                1174\n#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm                OBJ_id_tc26_cipher_gostr3412_2015_magma,1L\n\n#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac            \"id-tc26-cipher-gostr3412-2015-magma-ctracpkm-omac\"\n#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac           1175\n#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac           OBJ_id_tc26_cipher_gostr3412_2015_magma,2L\n\n#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik             \"id-tc26-cipher-gostr3412-2015-kuznyechik\"\n#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik            1176\n#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik            OBJ_id_tc26_cipher,2L\n\n#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm            \"id-tc26-cipher-gostr3412-2015-kuznyechik-ctracpkm\"\n#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm           1177\n#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm           OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik,1L\n\n#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac               \"id-tc26-cipher-gostr3412-2015-kuznyechik-ctracpkm-omac\"\n#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac              1178\n#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac              OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik,2L\n\n#define SN_id_tc26_agreement            \"id-tc26-agreement\"\n#define NID_id_tc26_agreement           991\n#define OBJ_id_tc26_agreement           OBJ_id_tc26_algorithms,6L\n\n#define SN_id_tc26_agreement_gost_3410_2012_256         \"id-tc26-agreement-gost-3410-2012-256\"\n#define NID_id_tc26_agreement_gost_3410_2012_256                992\n#define OBJ_id_tc26_agreement_gost_3410_2012_256                OBJ_id_tc26_agreement,1L\n\n#define SN_id_tc26_agreement_gost_3410_2012_512         \"id-tc26-agreement-gost-3410-2012-512\"\n#define NID_id_tc26_agreement_gost_3410_2012_512                993\n#define OBJ_id_tc26_agreement_gost_3410_2012_512                OBJ_id_tc26_agreement,2L\n\n#define SN_id_tc26_wrap         \"id-tc26-wrap\"\n#define NID_id_tc26_wrap                1179\n#define OBJ_id_tc26_wrap                OBJ_id_tc26_algorithms,7L\n\n#define SN_id_tc26_wrap_gostr3412_2015_magma            \"id-tc26-wrap-gostr3412-2015-magma\"\n#define NID_id_tc26_wrap_gostr3412_2015_magma           1180\n#define OBJ_id_tc26_wrap_gostr3412_2015_magma           OBJ_id_tc26_wrap,1L\n\n#define SN_id_tc26_wrap_gostr3412_2015_magma_kexp15             \"id-tc26-wrap-gostr3412-2015-magma-kexp15\"\n#define NID_id_tc26_wrap_gostr3412_2015_magma_kexp15            1181\n#define OBJ_id_tc26_wrap_gostr3412_2015_magma_kexp15            OBJ_id_tc26_wrap_gostr3412_2015_magma,1L\n\n#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik               \"id-tc26-wrap-gostr3412-2015-kuznyechik\"\n#define NID_id_tc26_wrap_gostr3412_2015_kuznyechik              1182\n#define OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik              OBJ_id_tc26_wrap,2L\n\n#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15                \"id-tc26-wrap-gostr3412-2015-kuznyechik-kexp15\"\n#define NID_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15               1183\n#define OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15               OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik,1L\n\n#define SN_id_tc26_constants            \"id-tc26-constants\"\n#define NID_id_tc26_constants           994\n#define OBJ_id_tc26_constants           OBJ_id_tc26,2L\n\n#define SN_id_tc26_sign_constants               \"id-tc26-sign-constants\"\n#define NID_id_tc26_sign_constants              995\n#define OBJ_id_tc26_sign_constants              OBJ_id_tc26_constants,1L\n\n#define SN_id_tc26_gost_3410_2012_256_constants         \"id-tc26-gost-3410-2012-256-constants\"\n#define NID_id_tc26_gost_3410_2012_256_constants                1147\n#define OBJ_id_tc26_gost_3410_2012_256_constants                OBJ_id_tc26_sign_constants,1L\n\n#define SN_id_tc26_gost_3410_2012_256_paramSetA         \"id-tc26-gost-3410-2012-256-paramSetA\"\n#define LN_id_tc26_gost_3410_2012_256_paramSetA         \"GOST R 34.10-2012 (256 bit) ParamSet A\"\n#define NID_id_tc26_gost_3410_2012_256_paramSetA                1148\n#define OBJ_id_tc26_gost_3410_2012_256_paramSetA                OBJ_id_tc26_gost_3410_2012_256_constants,1L\n\n#define SN_id_tc26_gost_3410_2012_256_paramSetB         \"id-tc26-gost-3410-2012-256-paramSetB\"\n#define LN_id_tc26_gost_3410_2012_256_paramSetB         \"GOST R 34.10-2012 (256 bit) ParamSet B\"\n#define NID_id_tc26_gost_3410_2012_256_paramSetB                1184\n#define OBJ_id_tc26_gost_3410_2012_256_paramSetB                OBJ_id_tc26_gost_3410_2012_256_constants,2L\n\n#define SN_id_tc26_gost_3410_2012_256_paramSetC         \"id-tc26-gost-3410-2012-256-paramSetC\"\n#define LN_id_tc26_gost_3410_2012_256_paramSetC         \"GOST R 34.10-2012 (256 bit) ParamSet C\"\n#define NID_id_tc26_gost_3410_2012_256_paramSetC                1185\n#define OBJ_id_tc26_gost_3410_2012_256_paramSetC                OBJ_id_tc26_gost_3410_2012_256_constants,3L\n\n#define SN_id_tc26_gost_3410_2012_256_paramSetD         \"id-tc26-gost-3410-2012-256-paramSetD\"\n#define LN_id_tc26_gost_3410_2012_256_paramSetD         \"GOST R 34.10-2012 (256 bit) ParamSet D\"\n#define NID_id_tc26_gost_3410_2012_256_paramSetD                1186\n#define OBJ_id_tc26_gost_3410_2012_256_paramSetD                OBJ_id_tc26_gost_3410_2012_256_constants,4L\n\n#define SN_id_tc26_gost_3410_2012_512_constants         \"id-tc26-gost-3410-2012-512-constants\"\n#define NID_id_tc26_gost_3410_2012_512_constants                996\n#define OBJ_id_tc26_gost_3410_2012_512_constants                OBJ_id_tc26_sign_constants,2L\n\n#define SN_id_tc26_gost_3410_2012_512_paramSetTest              \"id-tc26-gost-3410-2012-512-paramSetTest\"\n#define LN_id_tc26_gost_3410_2012_512_paramSetTest              \"GOST R 34.10-2012 (512 bit) testing parameter set\"\n#define NID_id_tc26_gost_3410_2012_512_paramSetTest             997\n#define OBJ_id_tc26_gost_3410_2012_512_paramSetTest             OBJ_id_tc26_gost_3410_2012_512_constants,0L\n\n#define SN_id_tc26_gost_3410_2012_512_paramSetA         \"id-tc26-gost-3410-2012-512-paramSetA\"\n#define LN_id_tc26_gost_3410_2012_512_paramSetA         \"GOST R 34.10-2012 (512 bit) ParamSet A\"\n#define NID_id_tc26_gost_3410_2012_512_paramSetA                998\n#define OBJ_id_tc26_gost_3410_2012_512_paramSetA                OBJ_id_tc26_gost_3410_2012_512_constants,1L\n\n#define SN_id_tc26_gost_3410_2012_512_paramSetB         \"id-tc26-gost-3410-2012-512-paramSetB\"\n#define LN_id_tc26_gost_3410_2012_512_paramSetB         \"GOST R 34.10-2012 (512 bit) ParamSet B\"\n#define NID_id_tc26_gost_3410_2012_512_paramSetB                999\n#define OBJ_id_tc26_gost_3410_2012_512_paramSetB                OBJ_id_tc26_gost_3410_2012_512_constants,2L\n\n#define SN_id_tc26_gost_3410_2012_512_paramSetC         \"id-tc26-gost-3410-2012-512-paramSetC\"\n#define LN_id_tc26_gost_3410_2012_512_paramSetC         \"GOST R 34.10-2012 (512 bit) ParamSet C\"\n#define NID_id_tc26_gost_3410_2012_512_paramSetC                1149\n#define OBJ_id_tc26_gost_3410_2012_512_paramSetC                OBJ_id_tc26_gost_3410_2012_512_constants,3L\n\n#define SN_id_tc26_digest_constants             \"id-tc26-digest-constants\"\n#define NID_id_tc26_digest_constants            1000\n#define OBJ_id_tc26_digest_constants            OBJ_id_tc26_constants,2L\n\n#define SN_id_tc26_cipher_constants             \"id-tc26-cipher-constants\"\n#define NID_id_tc26_cipher_constants            1001\n#define OBJ_id_tc26_cipher_constants            OBJ_id_tc26_constants,5L\n\n#define SN_id_tc26_gost_28147_constants         \"id-tc26-gost-28147-constants\"\n#define NID_id_tc26_gost_28147_constants                1002\n#define OBJ_id_tc26_gost_28147_constants                OBJ_id_tc26_cipher_constants,1L\n\n#define SN_id_tc26_gost_28147_param_Z           \"id-tc26-gost-28147-param-Z\"\n#define LN_id_tc26_gost_28147_param_Z           \"GOST 28147-89 TC26 parameter set\"\n#define NID_id_tc26_gost_28147_param_Z          1003\n#define OBJ_id_tc26_gost_28147_param_Z          OBJ_id_tc26_gost_28147_constants,1L\n\n#define SN_INN          \"INN\"\n#define LN_INN          \"INN\"\n#define NID_INN         1004\n#define OBJ_INN         OBJ_member_body,643L,3L,131L,1L,1L\n\n#define SN_OGRN         \"OGRN\"\n#define LN_OGRN         \"OGRN\"\n#define NID_OGRN                1005\n#define OBJ_OGRN                OBJ_member_body,643L,100L,1L\n\n#define SN_SNILS                \"SNILS\"\n#define LN_SNILS                \"SNILS\"\n#define NID_SNILS               1006\n#define OBJ_SNILS               OBJ_member_body,643L,100L,3L\n\n#define SN_subjectSignTool              \"subjectSignTool\"\n#define LN_subjectSignTool              \"Signing Tool of Subject\"\n#define NID_subjectSignTool             1007\n#define OBJ_subjectSignTool             OBJ_member_body,643L,100L,111L\n\n#define SN_issuerSignTool               \"issuerSignTool\"\n#define LN_issuerSignTool               \"Signing Tool of Issuer\"\n#define NID_issuerSignTool              1008\n#define OBJ_issuerSignTool              OBJ_member_body,643L,100L,112L\n\n#define SN_grasshopper_ecb              \"grasshopper-ecb\"\n#define NID_grasshopper_ecb             1012\n\n#define SN_grasshopper_ctr              \"grasshopper-ctr\"\n#define NID_grasshopper_ctr             1013\n\n#define SN_grasshopper_ofb              \"grasshopper-ofb\"\n#define NID_grasshopper_ofb             1014\n\n#define SN_grasshopper_cbc              \"grasshopper-cbc\"\n#define NID_grasshopper_cbc             1015\n\n#define SN_grasshopper_cfb              \"grasshopper-cfb\"\n#define NID_grasshopper_cfb             1016\n\n#define SN_grasshopper_mac              \"grasshopper-mac\"\n#define NID_grasshopper_mac             1017\n\n#define SN_magma_ecb            \"magma-ecb\"\n#define NID_magma_ecb           1187\n\n#define SN_magma_ctr            \"magma-ctr\"\n#define NID_magma_ctr           1188\n\n#define SN_magma_ofb            \"magma-ofb\"\n#define NID_magma_ofb           1189\n\n#define SN_magma_cbc            \"magma-cbc\"\n#define NID_magma_cbc           1190\n\n#define SN_magma_cfb            \"magma-cfb\"\n#define NID_magma_cfb           1191\n\n#define SN_magma_mac            \"magma-mac\"\n#define NID_magma_mac           1192\n\n#define SN_camellia_128_cbc             \"CAMELLIA-128-CBC\"\n#define LN_camellia_128_cbc             \"camellia-128-cbc\"\n#define NID_camellia_128_cbc            751\n#define OBJ_camellia_128_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,2L\n\n#define SN_camellia_192_cbc             \"CAMELLIA-192-CBC\"\n#define LN_camellia_192_cbc             \"camellia-192-cbc\"\n#define NID_camellia_192_cbc            752\n#define OBJ_camellia_192_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,3L\n\n#define SN_camellia_256_cbc             \"CAMELLIA-256-CBC\"\n#define LN_camellia_256_cbc             \"camellia-256-cbc\"\n#define NID_camellia_256_cbc            753\n#define OBJ_camellia_256_cbc            1L,2L,392L,200011L,61L,1L,1L,1L,4L\n\n#define SN_id_camellia128_wrap          \"id-camellia128-wrap\"\n#define NID_id_camellia128_wrap         907\n#define OBJ_id_camellia128_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,2L\n\n#define SN_id_camellia192_wrap          \"id-camellia192-wrap\"\n#define NID_id_camellia192_wrap         908\n#define OBJ_id_camellia192_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,3L\n\n#define SN_id_camellia256_wrap          \"id-camellia256-wrap\"\n#define NID_id_camellia256_wrap         909\n#define OBJ_id_camellia256_wrap         1L,2L,392L,200011L,61L,1L,1L,3L,4L\n\n#define OBJ_ntt_ds              0L,3L,4401L,5L\n\n#define OBJ_camellia            OBJ_ntt_ds,3L,1L,9L\n\n#define SN_camellia_128_ecb             \"CAMELLIA-128-ECB\"\n#define LN_camellia_128_ecb             \"camellia-128-ecb\"\n#define NID_camellia_128_ecb            754\n#define OBJ_camellia_128_ecb            OBJ_camellia,1L\n\n#define SN_camellia_128_ofb128          \"CAMELLIA-128-OFB\"\n#define LN_camellia_128_ofb128          \"camellia-128-ofb\"\n#define NID_camellia_128_ofb128         766\n#define OBJ_camellia_128_ofb128         OBJ_camellia,3L\n\n#define SN_camellia_128_cfb128          \"CAMELLIA-128-CFB\"\n#define LN_camellia_128_cfb128          \"camellia-128-cfb\"\n#define NID_camellia_128_cfb128         757\n#define OBJ_camellia_128_cfb128         OBJ_camellia,4L\n\n#define SN_camellia_128_gcm             \"CAMELLIA-128-GCM\"\n#define LN_camellia_128_gcm             \"camellia-128-gcm\"\n#define NID_camellia_128_gcm            961\n#define OBJ_camellia_128_gcm            OBJ_camellia,6L\n\n#define SN_camellia_128_ccm             \"CAMELLIA-128-CCM\"\n#define LN_camellia_128_ccm             \"camellia-128-ccm\"\n#define NID_camellia_128_ccm            962\n#define OBJ_camellia_128_ccm            OBJ_camellia,7L\n\n#define SN_camellia_128_ctr             \"CAMELLIA-128-CTR\"\n#define LN_camellia_128_ctr             \"camellia-128-ctr\"\n#define NID_camellia_128_ctr            963\n#define OBJ_camellia_128_ctr            OBJ_camellia,9L\n\n#define SN_camellia_128_cmac            \"CAMELLIA-128-CMAC\"\n#define LN_camellia_128_cmac            \"camellia-128-cmac\"\n#define NID_camellia_128_cmac           964\n#define OBJ_camellia_128_cmac           OBJ_camellia,10L\n\n#define SN_camellia_192_ecb             \"CAMELLIA-192-ECB\"\n#define LN_camellia_192_ecb             \"camellia-192-ecb\"\n#define NID_camellia_192_ecb            755\n#define OBJ_camellia_192_ecb            OBJ_camellia,21L\n\n#define SN_camellia_192_ofb128          \"CAMELLIA-192-OFB\"\n#define LN_camellia_192_ofb128          \"camellia-192-ofb\"\n#define NID_camellia_192_ofb128         767\n#define OBJ_camellia_192_ofb128         OBJ_camellia,23L\n\n#define SN_camellia_192_cfb128          \"CAMELLIA-192-CFB\"\n#define LN_camellia_192_cfb128          \"camellia-192-cfb\"\n#define NID_camellia_192_cfb128         758\n#define OBJ_camellia_192_cfb128         OBJ_camellia,24L\n\n#define SN_camellia_192_gcm             \"CAMELLIA-192-GCM\"\n#define LN_camellia_192_gcm             \"camellia-192-gcm\"\n#define NID_camellia_192_gcm            965\n#define OBJ_camellia_192_gcm            OBJ_camellia,26L\n\n#define SN_camellia_192_ccm             \"CAMELLIA-192-CCM\"\n#define LN_camellia_192_ccm             \"camellia-192-ccm\"\n#define NID_camellia_192_ccm            966\n#define OBJ_camellia_192_ccm            OBJ_camellia,27L\n\n#define SN_camellia_192_ctr             \"CAMELLIA-192-CTR\"\n#define LN_camellia_192_ctr             \"camellia-192-ctr\"\n#define NID_camellia_192_ctr            967\n#define OBJ_camellia_192_ctr            OBJ_camellia,29L\n\n#define SN_camellia_192_cmac            \"CAMELLIA-192-CMAC\"\n#define LN_camellia_192_cmac            \"camellia-192-cmac\"\n#define NID_camellia_192_cmac           968\n#define OBJ_camellia_192_cmac           OBJ_camellia,30L\n\n#define SN_camellia_256_ecb             \"CAMELLIA-256-ECB\"\n#define LN_camellia_256_ecb             \"camellia-256-ecb\"\n#define NID_camellia_256_ecb            756\n#define OBJ_camellia_256_ecb            OBJ_camellia,41L\n\n#define SN_camellia_256_ofb128          \"CAMELLIA-256-OFB\"\n#define LN_camellia_256_ofb128          \"camellia-256-ofb\"\n#define NID_camellia_256_ofb128         768\n#define OBJ_camellia_256_ofb128         OBJ_camellia,43L\n\n#define SN_camellia_256_cfb128          \"CAMELLIA-256-CFB\"\n#define LN_camellia_256_cfb128          \"camellia-256-cfb\"\n#define NID_camellia_256_cfb128         759\n#define OBJ_camellia_256_cfb128         OBJ_camellia,44L\n\n#define SN_camellia_256_gcm             \"CAMELLIA-256-GCM\"\n#define LN_camellia_256_gcm             \"camellia-256-gcm\"\n#define NID_camellia_256_gcm            969\n#define OBJ_camellia_256_gcm            OBJ_camellia,46L\n\n#define SN_camellia_256_ccm             \"CAMELLIA-256-CCM\"\n#define LN_camellia_256_ccm             \"camellia-256-ccm\"\n#define NID_camellia_256_ccm            970\n#define OBJ_camellia_256_ccm            OBJ_camellia,47L\n\n#define SN_camellia_256_ctr             \"CAMELLIA-256-CTR\"\n#define LN_camellia_256_ctr             \"camellia-256-ctr\"\n#define NID_camellia_256_ctr            971\n#define OBJ_camellia_256_ctr            OBJ_camellia,49L\n\n#define SN_camellia_256_cmac            \"CAMELLIA-256-CMAC\"\n#define LN_camellia_256_cmac            \"camellia-256-cmac\"\n#define NID_camellia_256_cmac           972\n#define OBJ_camellia_256_cmac           OBJ_camellia,50L\n\n#define SN_camellia_128_cfb1            \"CAMELLIA-128-CFB1\"\n#define LN_camellia_128_cfb1            \"camellia-128-cfb1\"\n#define NID_camellia_128_cfb1           760\n\n#define SN_camellia_192_cfb1            \"CAMELLIA-192-CFB1\"\n#define LN_camellia_192_cfb1            \"camellia-192-cfb1\"\n#define NID_camellia_192_cfb1           761\n\n#define SN_camellia_256_cfb1            \"CAMELLIA-256-CFB1\"\n#define LN_camellia_256_cfb1            \"camellia-256-cfb1\"\n#define NID_camellia_256_cfb1           762\n\n#define SN_camellia_128_cfb8            \"CAMELLIA-128-CFB8\"\n#define LN_camellia_128_cfb8            \"camellia-128-cfb8\"\n#define NID_camellia_128_cfb8           763\n\n#define SN_camellia_192_cfb8            \"CAMELLIA-192-CFB8\"\n#define LN_camellia_192_cfb8            \"camellia-192-cfb8\"\n#define NID_camellia_192_cfb8           764\n\n#define SN_camellia_256_cfb8            \"CAMELLIA-256-CFB8\"\n#define LN_camellia_256_cfb8            \"camellia-256-cfb8\"\n#define NID_camellia_256_cfb8           765\n\n#define OBJ_aria                1L,2L,410L,200046L,1L,1L\n\n#define SN_aria_128_ecb         \"ARIA-128-ECB\"\n#define LN_aria_128_ecb         \"aria-128-ecb\"\n#define NID_aria_128_ecb                1065\n#define OBJ_aria_128_ecb                OBJ_aria,1L\n\n#define SN_aria_128_cbc         \"ARIA-128-CBC\"\n#define LN_aria_128_cbc         \"aria-128-cbc\"\n#define NID_aria_128_cbc                1066\n#define OBJ_aria_128_cbc                OBJ_aria,2L\n\n#define SN_aria_128_cfb128              \"ARIA-128-CFB\"\n#define LN_aria_128_cfb128              \"aria-128-cfb\"\n#define NID_aria_128_cfb128             1067\n#define OBJ_aria_128_cfb128             OBJ_aria,3L\n\n#define SN_aria_128_ofb128              \"ARIA-128-OFB\"\n#define LN_aria_128_ofb128              \"aria-128-ofb\"\n#define NID_aria_128_ofb128             1068\n#define OBJ_aria_128_ofb128             OBJ_aria,4L\n\n#define SN_aria_128_ctr         \"ARIA-128-CTR\"\n#define LN_aria_128_ctr         \"aria-128-ctr\"\n#define NID_aria_128_ctr                1069\n#define OBJ_aria_128_ctr                OBJ_aria,5L\n\n#define SN_aria_192_ecb         \"ARIA-192-ECB\"\n#define LN_aria_192_ecb         \"aria-192-ecb\"\n#define NID_aria_192_ecb                1070\n#define OBJ_aria_192_ecb                OBJ_aria,6L\n\n#define SN_aria_192_cbc         \"ARIA-192-CBC\"\n#define LN_aria_192_cbc         \"aria-192-cbc\"\n#define NID_aria_192_cbc                1071\n#define OBJ_aria_192_cbc                OBJ_aria,7L\n\n#define SN_aria_192_cfb128              \"ARIA-192-CFB\"\n#define LN_aria_192_cfb128              \"aria-192-cfb\"\n#define NID_aria_192_cfb128             1072\n#define OBJ_aria_192_cfb128             OBJ_aria,8L\n\n#define SN_aria_192_ofb128              \"ARIA-192-OFB\"\n#define LN_aria_192_ofb128              \"aria-192-ofb\"\n#define NID_aria_192_ofb128             1073\n#define OBJ_aria_192_ofb128             OBJ_aria,9L\n\n#define SN_aria_192_ctr         \"ARIA-192-CTR\"\n#define LN_aria_192_ctr         \"aria-192-ctr\"\n#define NID_aria_192_ctr                1074\n#define OBJ_aria_192_ctr                OBJ_aria,10L\n\n#define SN_aria_256_ecb         \"ARIA-256-ECB\"\n#define LN_aria_256_ecb         \"aria-256-ecb\"\n#define NID_aria_256_ecb                1075\n#define OBJ_aria_256_ecb                OBJ_aria,11L\n\n#define SN_aria_256_cbc         \"ARIA-256-CBC\"\n#define LN_aria_256_cbc         \"aria-256-cbc\"\n#define NID_aria_256_cbc                1076\n#define OBJ_aria_256_cbc                OBJ_aria,12L\n\n#define SN_aria_256_cfb128              \"ARIA-256-CFB\"\n#define LN_aria_256_cfb128              \"aria-256-cfb\"\n#define NID_aria_256_cfb128             1077\n#define OBJ_aria_256_cfb128             OBJ_aria,13L\n\n#define SN_aria_256_ofb128              \"ARIA-256-OFB\"\n#define LN_aria_256_ofb128              \"aria-256-ofb\"\n#define NID_aria_256_ofb128             1078\n#define OBJ_aria_256_ofb128             OBJ_aria,14L\n\n#define SN_aria_256_ctr         \"ARIA-256-CTR\"\n#define LN_aria_256_ctr         \"aria-256-ctr\"\n#define NID_aria_256_ctr                1079\n#define OBJ_aria_256_ctr                OBJ_aria,15L\n\n#define SN_aria_128_cfb1                \"ARIA-128-CFB1\"\n#define LN_aria_128_cfb1                \"aria-128-cfb1\"\n#define NID_aria_128_cfb1               1080\n\n#define SN_aria_192_cfb1                \"ARIA-192-CFB1\"\n#define LN_aria_192_cfb1                \"aria-192-cfb1\"\n#define NID_aria_192_cfb1               1081\n\n#define SN_aria_256_cfb1                \"ARIA-256-CFB1\"\n#define LN_aria_256_cfb1                \"aria-256-cfb1\"\n#define NID_aria_256_cfb1               1082\n\n#define SN_aria_128_cfb8                \"ARIA-128-CFB8\"\n#define LN_aria_128_cfb8                \"aria-128-cfb8\"\n#define NID_aria_128_cfb8               1083\n\n#define SN_aria_192_cfb8                \"ARIA-192-CFB8\"\n#define LN_aria_192_cfb8                \"aria-192-cfb8\"\n#define NID_aria_192_cfb8               1084\n\n#define SN_aria_256_cfb8                \"ARIA-256-CFB8\"\n#define LN_aria_256_cfb8                \"aria-256-cfb8\"\n#define NID_aria_256_cfb8               1085\n\n#define SN_aria_128_ccm         \"ARIA-128-CCM\"\n#define LN_aria_128_ccm         \"aria-128-ccm\"\n#define NID_aria_128_ccm                1120\n#define OBJ_aria_128_ccm                OBJ_aria,37L\n\n#define SN_aria_192_ccm         \"ARIA-192-CCM\"\n#define LN_aria_192_ccm         \"aria-192-ccm\"\n#define NID_aria_192_ccm                1121\n#define OBJ_aria_192_ccm                OBJ_aria,38L\n\n#define SN_aria_256_ccm         \"ARIA-256-CCM\"\n#define LN_aria_256_ccm         \"aria-256-ccm\"\n#define NID_aria_256_ccm                1122\n#define OBJ_aria_256_ccm                OBJ_aria,39L\n\n#define SN_aria_128_gcm         \"ARIA-128-GCM\"\n#define LN_aria_128_gcm         \"aria-128-gcm\"\n#define NID_aria_128_gcm                1123\n#define OBJ_aria_128_gcm                OBJ_aria,34L\n\n#define SN_aria_192_gcm         \"ARIA-192-GCM\"\n#define LN_aria_192_gcm         \"aria-192-gcm\"\n#define NID_aria_192_gcm                1124\n#define OBJ_aria_192_gcm                OBJ_aria,35L\n\n#define SN_aria_256_gcm         \"ARIA-256-GCM\"\n#define LN_aria_256_gcm         \"aria-256-gcm\"\n#define NID_aria_256_gcm                1125\n#define OBJ_aria_256_gcm                OBJ_aria,36L\n\n#define SN_kisa         \"KISA\"\n#define LN_kisa         \"kisa\"\n#define NID_kisa                773\n#define OBJ_kisa                OBJ_member_body,410L,200004L\n\n#define SN_seed_ecb             \"SEED-ECB\"\n#define LN_seed_ecb             \"seed-ecb\"\n#define NID_seed_ecb            776\n#define OBJ_seed_ecb            OBJ_kisa,1L,3L\n\n#define SN_seed_cbc             \"SEED-CBC\"\n#define LN_seed_cbc             \"seed-cbc\"\n#define NID_seed_cbc            777\n#define OBJ_seed_cbc            OBJ_kisa,1L,4L\n\n#define SN_seed_cfb128          \"SEED-CFB\"\n#define LN_seed_cfb128          \"seed-cfb\"\n#define NID_seed_cfb128         779\n#define OBJ_seed_cfb128         OBJ_kisa,1L,5L\n\n#define SN_seed_ofb128          \"SEED-OFB\"\n#define LN_seed_ofb128          \"seed-ofb\"\n#define NID_seed_ofb128         778\n#define OBJ_seed_ofb128         OBJ_kisa,1L,6L\n\n#define SN_sm4_ecb              \"SM4-ECB\"\n#define LN_sm4_ecb              \"sm4-ecb\"\n#define NID_sm4_ecb             1133\n#define OBJ_sm4_ecb             OBJ_sm_scheme,104L,1L\n\n#define SN_sm4_cbc              \"SM4-CBC\"\n#define LN_sm4_cbc              \"sm4-cbc\"\n#define NID_sm4_cbc             1134\n#define OBJ_sm4_cbc             OBJ_sm_scheme,104L,2L\n\n#define SN_sm4_ofb128           \"SM4-OFB\"\n#define LN_sm4_ofb128           \"sm4-ofb\"\n#define NID_sm4_ofb128          1135\n#define OBJ_sm4_ofb128          OBJ_sm_scheme,104L,3L\n\n#define SN_sm4_cfb128           \"SM4-CFB\"\n#define LN_sm4_cfb128           \"sm4-cfb\"\n#define NID_sm4_cfb128          1137\n#define OBJ_sm4_cfb128          OBJ_sm_scheme,104L,4L\n\n#define SN_sm4_cfb1             \"SM4-CFB1\"\n#define LN_sm4_cfb1             \"sm4-cfb1\"\n#define NID_sm4_cfb1            1136\n#define OBJ_sm4_cfb1            OBJ_sm_scheme,104L,5L\n\n#define SN_sm4_cfb8             \"SM4-CFB8\"\n#define LN_sm4_cfb8             \"sm4-cfb8\"\n#define NID_sm4_cfb8            1138\n#define OBJ_sm4_cfb8            OBJ_sm_scheme,104L,6L\n\n#define SN_sm4_ctr              \"SM4-CTR\"\n#define LN_sm4_ctr              \"sm4-ctr\"\n#define NID_sm4_ctr             1139\n#define OBJ_sm4_ctr             OBJ_sm_scheme,104L,7L\n\n#define SN_hmac         \"HMAC\"\n#define LN_hmac         \"hmac\"\n#define NID_hmac                855\n\n#define SN_cmac         \"CMAC\"\n#define LN_cmac         \"cmac\"\n#define NID_cmac                894\n\n#define SN_rc4_hmac_md5         \"RC4-HMAC-MD5\"\n#define LN_rc4_hmac_md5         \"rc4-hmac-md5\"\n#define NID_rc4_hmac_md5                915\n\n#define SN_aes_128_cbc_hmac_sha1                \"AES-128-CBC-HMAC-SHA1\"\n#define LN_aes_128_cbc_hmac_sha1                \"aes-128-cbc-hmac-sha1\"\n#define NID_aes_128_cbc_hmac_sha1               916\n\n#define SN_aes_192_cbc_hmac_sha1                \"AES-192-CBC-HMAC-SHA1\"\n#define LN_aes_192_cbc_hmac_sha1                \"aes-192-cbc-hmac-sha1\"\n#define NID_aes_192_cbc_hmac_sha1               917\n\n#define SN_aes_256_cbc_hmac_sha1                \"AES-256-CBC-HMAC-SHA1\"\n#define LN_aes_256_cbc_hmac_sha1                \"aes-256-cbc-hmac-sha1\"\n#define NID_aes_256_cbc_hmac_sha1               918\n\n#define SN_aes_128_cbc_hmac_sha256              \"AES-128-CBC-HMAC-SHA256\"\n#define LN_aes_128_cbc_hmac_sha256              \"aes-128-cbc-hmac-sha256\"\n#define NID_aes_128_cbc_hmac_sha256             948\n\n#define SN_aes_192_cbc_hmac_sha256              \"AES-192-CBC-HMAC-SHA256\"\n#define LN_aes_192_cbc_hmac_sha256              \"aes-192-cbc-hmac-sha256\"\n#define NID_aes_192_cbc_hmac_sha256             949\n\n#define SN_aes_256_cbc_hmac_sha256              \"AES-256-CBC-HMAC-SHA256\"\n#define LN_aes_256_cbc_hmac_sha256              \"aes-256-cbc-hmac-sha256\"\n#define NID_aes_256_cbc_hmac_sha256             950\n\n#define SN_chacha20_poly1305            \"ChaCha20-Poly1305\"\n#define LN_chacha20_poly1305            \"chacha20-poly1305\"\n#define NID_chacha20_poly1305           1018\n\n#define SN_chacha20             \"ChaCha20\"\n#define LN_chacha20             \"chacha20\"\n#define NID_chacha20            1019\n\n#define SN_dhpublicnumber               \"dhpublicnumber\"\n#define LN_dhpublicnumber               \"X9.42 DH\"\n#define NID_dhpublicnumber              920\n#define OBJ_dhpublicnumber              OBJ_ISO_US,10046L,2L,1L\n\n#define SN_brainpoolP160r1              \"brainpoolP160r1\"\n#define NID_brainpoolP160r1             921\n#define OBJ_brainpoolP160r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,1L\n\n#define SN_brainpoolP160t1              \"brainpoolP160t1\"\n#define NID_brainpoolP160t1             922\n#define OBJ_brainpoolP160t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,2L\n\n#define SN_brainpoolP192r1              \"brainpoolP192r1\"\n#define NID_brainpoolP192r1             923\n#define OBJ_brainpoolP192r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,3L\n\n#define SN_brainpoolP192t1              \"brainpoolP192t1\"\n#define NID_brainpoolP192t1             924\n#define OBJ_brainpoolP192t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,4L\n\n#define SN_brainpoolP224r1              \"brainpoolP224r1\"\n#define NID_brainpoolP224r1             925\n#define OBJ_brainpoolP224r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,5L\n\n#define SN_brainpoolP224t1              \"brainpoolP224t1\"\n#define NID_brainpoolP224t1             926\n#define OBJ_brainpoolP224t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,6L\n\n#define SN_brainpoolP256r1              \"brainpoolP256r1\"\n#define NID_brainpoolP256r1             927\n#define OBJ_brainpoolP256r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,7L\n\n#define SN_brainpoolP256t1              \"brainpoolP256t1\"\n#define NID_brainpoolP256t1             928\n#define OBJ_brainpoolP256t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,8L\n\n#define SN_brainpoolP320r1              \"brainpoolP320r1\"\n#define NID_brainpoolP320r1             929\n#define OBJ_brainpoolP320r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,9L\n\n#define SN_brainpoolP320t1              \"brainpoolP320t1\"\n#define NID_brainpoolP320t1             930\n#define OBJ_brainpoolP320t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,10L\n\n#define SN_brainpoolP384r1              \"brainpoolP384r1\"\n#define NID_brainpoolP384r1             931\n#define OBJ_brainpoolP384r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,11L\n\n#define SN_brainpoolP384t1              \"brainpoolP384t1\"\n#define NID_brainpoolP384t1             932\n#define OBJ_brainpoolP384t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,12L\n\n#define SN_brainpoolP512r1              \"brainpoolP512r1\"\n#define NID_brainpoolP512r1             933\n#define OBJ_brainpoolP512r1             1L,3L,36L,3L,3L,2L,8L,1L,1L,13L\n\n#define SN_brainpoolP512t1              \"brainpoolP512t1\"\n#define NID_brainpoolP512t1             934\n#define OBJ_brainpoolP512t1             1L,3L,36L,3L,3L,2L,8L,1L,1L,14L\n\n#define OBJ_x9_63_scheme                1L,3L,133L,16L,840L,63L,0L\n\n#define OBJ_secg_scheme         OBJ_certicom_arc,1L\n\n#define SN_dhSinglePass_stdDH_sha1kdf_scheme            \"dhSinglePass-stdDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha1kdf_scheme           936\n#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme           OBJ_x9_63_scheme,2L\n\n#define SN_dhSinglePass_stdDH_sha224kdf_scheme          \"dhSinglePass-stdDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha224kdf_scheme         937\n#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme         OBJ_secg_scheme,11L,0L\n\n#define SN_dhSinglePass_stdDH_sha256kdf_scheme          \"dhSinglePass-stdDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha256kdf_scheme         938\n#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme         OBJ_secg_scheme,11L,1L\n\n#define SN_dhSinglePass_stdDH_sha384kdf_scheme          \"dhSinglePass-stdDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha384kdf_scheme         939\n#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme         OBJ_secg_scheme,11L,2L\n\n#define SN_dhSinglePass_stdDH_sha512kdf_scheme          \"dhSinglePass-stdDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_stdDH_sha512kdf_scheme         940\n#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme         OBJ_secg_scheme,11L,3L\n\n#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme               \"dhSinglePass-cofactorDH-sha1kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme              941\n#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme              OBJ_x9_63_scheme,3L\n\n#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme             \"dhSinglePass-cofactorDH-sha224kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme            942\n#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme            OBJ_secg_scheme,14L,0L\n\n#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme             \"dhSinglePass-cofactorDH-sha256kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme            943\n#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme            OBJ_secg_scheme,14L,1L\n\n#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme             \"dhSinglePass-cofactorDH-sha384kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme            944\n#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme            OBJ_secg_scheme,14L,2L\n\n#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme             \"dhSinglePass-cofactorDH-sha512kdf-scheme\"\n#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme            945\n#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme            OBJ_secg_scheme,14L,3L\n\n#define SN_dh_std_kdf           \"dh-std-kdf\"\n#define NID_dh_std_kdf          946\n\n#define SN_dh_cofactor_kdf              \"dh-cofactor-kdf\"\n#define NID_dh_cofactor_kdf             947\n\n#define SN_ct_precert_scts              \"ct_precert_scts\"\n#define LN_ct_precert_scts              \"CT Precertificate SCTs\"\n#define NID_ct_precert_scts             951\n#define OBJ_ct_precert_scts             1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L\n\n#define SN_ct_precert_poison            \"ct_precert_poison\"\n#define LN_ct_precert_poison            \"CT Precertificate Poison\"\n#define NID_ct_precert_poison           952\n#define OBJ_ct_precert_poison           1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L\n\n#define SN_ct_precert_signer            \"ct_precert_signer\"\n#define LN_ct_precert_signer            \"CT Precertificate Signer\"\n#define NID_ct_precert_signer           953\n#define OBJ_ct_precert_signer           1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L\n\n#define SN_ct_cert_scts         \"ct_cert_scts\"\n#define LN_ct_cert_scts         \"CT Certificate SCTs\"\n#define NID_ct_cert_scts                954\n#define OBJ_ct_cert_scts                1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L\n\n#define SN_jurisdictionLocalityName             \"jurisdictionL\"\n#define LN_jurisdictionLocalityName             \"jurisdictionLocalityName\"\n#define NID_jurisdictionLocalityName            955\n#define OBJ_jurisdictionLocalityName            1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,1L\n\n#define SN_jurisdictionStateOrProvinceName              \"jurisdictionST\"\n#define LN_jurisdictionStateOrProvinceName              \"jurisdictionStateOrProvinceName\"\n#define NID_jurisdictionStateOrProvinceName             956\n#define OBJ_jurisdictionStateOrProvinceName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,2L\n\n#define SN_jurisdictionCountryName              \"jurisdictionC\"\n#define LN_jurisdictionCountryName              \"jurisdictionCountryName\"\n#define NID_jurisdictionCountryName             957\n#define OBJ_jurisdictionCountryName             1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,3L\n\n#define SN_id_scrypt            \"id-scrypt\"\n#define LN_id_scrypt            \"scrypt\"\n#define NID_id_scrypt           973\n#define OBJ_id_scrypt           1L,3L,6L,1L,4L,1L,11591L,4L,11L\n\n#define SN_tls1_prf             \"TLS1-PRF\"\n#define LN_tls1_prf             \"tls1-prf\"\n#define NID_tls1_prf            1021\n\n#define SN_hkdf         \"HKDF\"\n#define LN_hkdf         \"hkdf\"\n#define NID_hkdf                1036\n\n#define SN_id_pkinit            \"id-pkinit\"\n#define NID_id_pkinit           1031\n#define OBJ_id_pkinit           1L,3L,6L,1L,5L,2L,3L\n\n#define SN_pkInitClientAuth             \"pkInitClientAuth\"\n#define LN_pkInitClientAuth             \"PKINIT Client Auth\"\n#define NID_pkInitClientAuth            1032\n#define OBJ_pkInitClientAuth            OBJ_id_pkinit,4L\n\n#define SN_pkInitKDC            \"pkInitKDC\"\n#define LN_pkInitKDC            \"Signing KDC Response\"\n#define NID_pkInitKDC           1033\n#define OBJ_pkInitKDC           OBJ_id_pkinit,5L\n\n#define SN_X25519               \"X25519\"\n#define NID_X25519              1034\n#define OBJ_X25519              1L,3L,101L,110L\n\n#define SN_X448         \"X448\"\n#define NID_X448                1035\n#define OBJ_X448                1L,3L,101L,111L\n\n#define SN_ED25519              \"ED25519\"\n#define NID_ED25519             1087\n#define OBJ_ED25519             1L,3L,101L,112L\n\n#define SN_ED448                \"ED448\"\n#define NID_ED448               1088\n#define OBJ_ED448               1L,3L,101L,113L\n\n#define SN_kx_rsa               \"KxRSA\"\n#define LN_kx_rsa               \"kx-rsa\"\n#define NID_kx_rsa              1037\n\n#define SN_kx_ecdhe             \"KxECDHE\"\n#define LN_kx_ecdhe             \"kx-ecdhe\"\n#define NID_kx_ecdhe            1038\n\n#define SN_kx_dhe               \"KxDHE\"\n#define LN_kx_dhe               \"kx-dhe\"\n#define NID_kx_dhe              1039\n\n#define SN_kx_ecdhe_psk         \"KxECDHE-PSK\"\n#define LN_kx_ecdhe_psk         \"kx-ecdhe-psk\"\n#define NID_kx_ecdhe_psk                1040\n\n#define SN_kx_dhe_psk           \"KxDHE-PSK\"\n#define LN_kx_dhe_psk           \"kx-dhe-psk\"\n#define NID_kx_dhe_psk          1041\n\n#define SN_kx_rsa_psk           \"KxRSA_PSK\"\n#define LN_kx_rsa_psk           \"kx-rsa-psk\"\n#define NID_kx_rsa_psk          1042\n\n#define SN_kx_psk               \"KxPSK\"\n#define LN_kx_psk               \"kx-psk\"\n#define NID_kx_psk              1043\n\n#define SN_kx_srp               \"KxSRP\"\n#define LN_kx_srp               \"kx-srp\"\n#define NID_kx_srp              1044\n\n#define SN_kx_gost              \"KxGOST\"\n#define LN_kx_gost              \"kx-gost\"\n#define NID_kx_gost             1045\n\n#define SN_kx_any               \"KxANY\"\n#define LN_kx_any               \"kx-any\"\n#define NID_kx_any              1063\n\n#define SN_auth_rsa             \"AuthRSA\"\n#define LN_auth_rsa             \"auth-rsa\"\n#define NID_auth_rsa            1046\n\n#define SN_auth_ecdsa           \"AuthECDSA\"\n#define LN_auth_ecdsa           \"auth-ecdsa\"\n#define NID_auth_ecdsa          1047\n\n#define SN_auth_psk             \"AuthPSK\"\n#define LN_auth_psk             \"auth-psk\"\n#define NID_auth_psk            1048\n\n#define SN_auth_dss             \"AuthDSS\"\n#define LN_auth_dss             \"auth-dss\"\n#define NID_auth_dss            1049\n\n#define SN_auth_gost01          \"AuthGOST01\"\n#define LN_auth_gost01          \"auth-gost01\"\n#define NID_auth_gost01         1050\n\n#define SN_auth_gost12          \"AuthGOST12\"\n#define LN_auth_gost12          \"auth-gost12\"\n#define NID_auth_gost12         1051\n\n#define SN_auth_srp             \"AuthSRP\"\n#define LN_auth_srp             \"auth-srp\"\n#define NID_auth_srp            1052\n\n#define SN_auth_null            \"AuthNULL\"\n#define LN_auth_null            \"auth-null\"\n#define NID_auth_null           1053\n\n#define SN_auth_any             \"AuthANY\"\n#define LN_auth_any             \"auth-any\"\n#define NID_auth_any            1064\n\n#define SN_poly1305             \"Poly1305\"\n#define LN_poly1305             \"poly1305\"\n#define NID_poly1305            1061\n\n#define SN_siphash              \"SipHash\"\n#define LN_siphash              \"siphash\"\n#define NID_siphash             1062\n\n#define SN_ffdhe2048            \"ffdhe2048\"\n#define NID_ffdhe2048           1126\n\n#define SN_ffdhe3072            \"ffdhe3072\"\n#define NID_ffdhe3072           1127\n\n#define SN_ffdhe4096            \"ffdhe4096\"\n#define NID_ffdhe4096           1128\n\n#define SN_ffdhe6144            \"ffdhe6144\"\n#define NID_ffdhe6144           1129\n\n#define SN_ffdhe8192            \"ffdhe8192\"\n#define NID_ffdhe8192           1130\n\n#define SN_ISO_UA               \"ISO-UA\"\n#define NID_ISO_UA              1150\n#define OBJ_ISO_UA              OBJ_member_body,804L\n\n#define SN_ua_pki               \"ua-pki\"\n#define NID_ua_pki              1151\n#define OBJ_ua_pki              OBJ_ISO_UA,2L,1L,1L,1L\n\n#define SN_dstu28147            \"dstu28147\"\n#define LN_dstu28147            \"DSTU Gost 28147-2009\"\n#define NID_dstu28147           1152\n#define OBJ_dstu28147           OBJ_ua_pki,1L,1L,1L\n\n#define SN_dstu28147_ofb                \"dstu28147-ofb\"\n#define LN_dstu28147_ofb                \"DSTU Gost 28147-2009 OFB mode\"\n#define NID_dstu28147_ofb               1153\n#define OBJ_dstu28147_ofb               OBJ_dstu28147,2L\n\n#define SN_dstu28147_cfb                \"dstu28147-cfb\"\n#define LN_dstu28147_cfb                \"DSTU Gost 28147-2009 CFB mode\"\n#define NID_dstu28147_cfb               1154\n#define OBJ_dstu28147_cfb               OBJ_dstu28147,3L\n\n#define SN_dstu28147_wrap               \"dstu28147-wrap\"\n#define LN_dstu28147_wrap               \"DSTU Gost 28147-2009 key wrap\"\n#define NID_dstu28147_wrap              1155\n#define OBJ_dstu28147_wrap              OBJ_dstu28147,5L\n\n#define SN_hmacWithDstu34311            \"hmacWithDstu34311\"\n#define LN_hmacWithDstu34311            \"HMAC DSTU Gost 34311-95\"\n#define NID_hmacWithDstu34311           1156\n#define OBJ_hmacWithDstu34311           OBJ_ua_pki,1L,1L,2L\n\n#define SN_dstu34311            \"dstu34311\"\n#define LN_dstu34311            \"DSTU Gost 34311-95\"\n#define NID_dstu34311           1157\n#define OBJ_dstu34311           OBJ_ua_pki,1L,2L,1L\n\n#define SN_dstu4145le           \"dstu4145le\"\n#define LN_dstu4145le           \"DSTU 4145-2002 little endian\"\n#define NID_dstu4145le          1158\n#define OBJ_dstu4145le          OBJ_ua_pki,1L,3L,1L,1L\n\n#define SN_dstu4145be           \"dstu4145be\"\n#define LN_dstu4145be           \"DSTU 4145-2002 big endian\"\n#define NID_dstu4145be          1159\n#define OBJ_dstu4145be          OBJ_dstu4145le,1L,1L\n\n#define SN_uacurve0             \"uacurve0\"\n#define LN_uacurve0             \"DSTU curve 0\"\n#define NID_uacurve0            1160\n#define OBJ_uacurve0            OBJ_dstu4145le,2L,0L\n\n#define SN_uacurve1             \"uacurve1\"\n#define LN_uacurve1             \"DSTU curve 1\"\n#define NID_uacurve1            1161\n#define OBJ_uacurve1            OBJ_dstu4145le,2L,1L\n\n#define SN_uacurve2             \"uacurve2\"\n#define LN_uacurve2             \"DSTU curve 2\"\n#define NID_uacurve2            1162\n#define OBJ_uacurve2            OBJ_dstu4145le,2L,2L\n\n#define SN_uacurve3             \"uacurve3\"\n#define LN_uacurve3             \"DSTU curve 3\"\n#define NID_uacurve3            1163\n#define OBJ_uacurve3            OBJ_dstu4145le,2L,3L\n\n#define SN_uacurve4             \"uacurve4\"\n#define LN_uacurve4             \"DSTU curve 4\"\n#define NID_uacurve4            1164\n#define OBJ_uacurve4            OBJ_dstu4145le,2L,4L\n\n#define SN_uacurve5             \"uacurve5\"\n#define LN_uacurve5             \"DSTU curve 5\"\n#define NID_uacurve5            1165\n#define OBJ_uacurve5            OBJ_dstu4145le,2L,5L\n\n#define SN_uacurve6             \"uacurve6\"\n#define LN_uacurve6             \"DSTU curve 6\"\n#define NID_uacurve6            1166\n#define OBJ_uacurve6            OBJ_dstu4145le,2L,6L\n\n#define SN_uacurve7             \"uacurve7\"\n#define LN_uacurve7             \"DSTU curve 7\"\n#define NID_uacurve7            1167\n#define OBJ_uacurve7            OBJ_dstu4145le,2L,7L\n\n#define SN_uacurve8             \"uacurve8\"\n#define LN_uacurve8             \"DSTU curve 8\"\n#define NID_uacurve8            1168\n#define OBJ_uacurve8            OBJ_dstu4145le,2L,8L\n\n#define SN_uacurve9             \"uacurve9\"\n#define LN_uacurve9             \"DSTU curve 9\"\n#define NID_uacurve9            1169\n#define OBJ_uacurve9            OBJ_dstu4145le,2L,9L\n"
  },
  {
    "path": "cryptomini/include/openssl/objects.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OBJECTS_H\n# define HEADER_OBJECTS_H\n\n# include <openssl/obj_mac.h>\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n# include <openssl/objectserr.h>\n\n# define OBJ_NAME_TYPE_UNDEF             0x00\n# define OBJ_NAME_TYPE_MD_METH           0x01\n# define OBJ_NAME_TYPE_CIPHER_METH       0x02\n# define OBJ_NAME_TYPE_PKEY_METH         0x03\n# define OBJ_NAME_TYPE_COMP_METH         0x04\n# define OBJ_NAME_TYPE_NUM               0x05\n\n# define OBJ_NAME_ALIAS                  0x8000\n\n# define OBJ_BSEARCH_VALUE_ON_NOMATCH            0x01\n# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH        0x02\n\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct obj_name_st {\n    int type;\n    int alias;\n    const char *name;\n    const char *data;\n} OBJ_NAME;\n\n# define         OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)\n\nint OBJ_NAME_init(void);\nint OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),\n                       int (*cmp_func) (const char *, const char *),\n                       void (*free_func) (const char *, int, const char *));\nconst char *OBJ_NAME_get(const char *name, int type);\nint OBJ_NAME_add(const char *name, int type, const char *data);\nint OBJ_NAME_remove(const char *name, int type);\nvoid OBJ_NAME_cleanup(int type); /* -1 for everything */\nvoid OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg),\n                     void *arg);\nvoid OBJ_NAME_do_all_sorted(int type,\n                            void (*fn) (const OBJ_NAME *, void *arg),\n                            void *arg);\n\nASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_nid2obj(int n);\nconst char *OBJ_nid2ln(int n);\nconst char *OBJ_nid2sn(int n);\nint OBJ_obj2nid(const ASN1_OBJECT *o);\nASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name);\nint OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);\nint OBJ_txt2nid(const char *s);\nint OBJ_ln2nid(const char *s);\nint OBJ_sn2nid(const char *s);\nint OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);\nconst void *OBJ_bsearch_(const void *key, const void *base, int num, int size,\n                         int (*cmp) (const void *, const void *));\nconst void *OBJ_bsearch_ex_(const void *key, const void *base, int num,\n                            int size,\n                            int (*cmp) (const void *, const void *),\n                            int flags);\n\n# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm)    \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \\\n  static int nm##_cmp(type1 const *, type2 const *); \\\n  scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp)   \\\n  _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)\n# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)     \\\n  type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)\n\n/*-\n * Unsolved problem: if a type is actually a pointer type, like\n * nid_triple is, then its impossible to get a const where you need\n * it. Consider:\n *\n * typedef int nid_triple[3];\n * const void *a_;\n * const nid_triple const *a = a_;\n *\n * The assignment discards a const because what you really want is:\n *\n * const int const * const *a = a_;\n *\n * But if you do that, you lose the fact that a is an array of 3 ints,\n * which breaks comparison functions.\n *\n * Thus we end up having to cast, sadly, or unpack the\n * declarations. Or, as I finally did in this case, declare nid_triple\n * to be a struct, which it should have been in the first place.\n *\n * Ben, August 2008.\n *\n * Also, strictly speaking not all types need be const, but handling\n * the non-constness means a lot of complication, and in practice\n * comparison routines do always not touch their arguments.\n */\n\n# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm)  \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm)   \\\n  static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_)    \\\n      { \\\n      type1 const *a = a_; \\\n      type2 const *b = b_; \\\n      return nm##_cmp(a,b); \\\n      } \\\n  type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \\\n      { \\\n      return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \\\n                                        nm##_cmp_BSEARCH_CMP_FN); \\\n      } \\\n      extern void dummy_prototype(void)\n\n# define OBJ_bsearch(type1,key,type2,base,num,cmp)                              \\\n  ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)CHECKED_PTR_OF(type2,cmp##_type_2),     \\\n                          cmp##_BSEARCH_CMP_FN)))\n\n# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags)                      \\\n  ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \\\n                         num,sizeof(type2),                             \\\n                         ((void)CHECKED_PTR_OF(type1,cmp##_type_1),     \\\n                          (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \\\n                          cmp##_BSEARCH_CMP_FN)),flags)\n\nint OBJ_new_nid(int num);\nint OBJ_add_object(const ASN1_OBJECT *obj);\nint OBJ_create(const char *oid, const char *sn, const char *ln);\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define OBJ_cleanup() while(0) continue\n#endif\nint OBJ_create_objects(BIO *in);\n\nsize_t OBJ_length(const ASN1_OBJECT *obj);\nconst unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj);\n\nint OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);\nint OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);\nint OBJ_add_sigid(int signid, int dig_id, int pkey_id);\nvoid OBJ_sigid_free(void);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/objectserr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OBJERR_H\n# define HEADER_OBJERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_OBJ_strings(void);\n\n/*\n * OBJ function codes.\n */\n# define OBJ_F_OBJ_ADD_OBJECT                             105\n# define OBJ_F_OBJ_ADD_SIGID                              107\n# define OBJ_F_OBJ_CREATE                                 100\n# define OBJ_F_OBJ_DUP                                    101\n# define OBJ_F_OBJ_NAME_NEW_INDEX                         106\n# define OBJ_F_OBJ_NID2LN                                 102\n# define OBJ_F_OBJ_NID2OBJ                                103\n# define OBJ_F_OBJ_NID2SN                                 104\n# define OBJ_F_OBJ_TXT2OBJ                                108\n\n/*\n * OBJ reason codes.\n */\n# define OBJ_R_OID_EXISTS                                 102\n# define OBJ_R_UNKNOWN_NID                                101\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ocsp.h",
    "content": "/*\n * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OCSP_H\n# define HEADER_OCSP_H\n\n#include <openssl/opensslconf.h>\n\n/*\n * These definitions are outside the OPENSSL_NO_OCSP guard because although for\n * historical reasons they have OCSP_* names, they can actually be used\n * independently of OCSP. E.g. see RFC5280\n */\n/*-\n *   CRLReason ::= ENUMERATED {\n *        unspecified             (0),\n *        keyCompromise           (1),\n *        cACompromise            (2),\n *        affiliationChanged      (3),\n *        superseded              (4),\n *        cessationOfOperation    (5),\n *        certificateHold         (6),\n *        removeFromCRL           (8) }\n */\n#  define OCSP_REVOKED_STATUS_NOSTATUS               -1\n#  define OCSP_REVOKED_STATUS_UNSPECIFIED             0\n#  define OCSP_REVOKED_STATUS_KEYCOMPROMISE           1\n#  define OCSP_REVOKED_STATUS_CACOMPROMISE            2\n#  define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED      3\n#  define OCSP_REVOKED_STATUS_SUPERSEDED              4\n#  define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION    5\n#  define OCSP_REVOKED_STATUS_CERTIFICATEHOLD         6\n#  define OCSP_REVOKED_STATUS_REMOVEFROMCRL           8\n\n\n# ifndef OPENSSL_NO_OCSP\n\n#  include <openssl/ossl_typ.h>\n#  include <openssl/x509.h>\n#  include <openssl/x509v3.h>\n#  include <openssl/safestack.h>\n#  include <openssl/ocsperr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Various flags and values */\n\n#  define OCSP_DEFAULT_NONCE_LENGTH       16\n\n#  define OCSP_NOCERTS                    0x1\n#  define OCSP_NOINTERN                   0x2\n#  define OCSP_NOSIGS                     0x4\n#  define OCSP_NOCHAIN                    0x8\n#  define OCSP_NOVERIFY                   0x10\n#  define OCSP_NOEXPLICIT                 0x20\n#  define OCSP_NOCASIGN                   0x40\n#  define OCSP_NODELEGATED                0x80\n#  define OCSP_NOCHECKS                   0x100\n#  define OCSP_TRUSTOTHER                 0x200\n#  define OCSP_RESPID_KEY                 0x400\n#  define OCSP_NOTIME                     0x800\n\ntypedef struct ocsp_cert_id_st OCSP_CERTID;\n\nDEFINE_STACK_OF(OCSP_CERTID)\n\ntypedef struct ocsp_one_request_st OCSP_ONEREQ;\n\nDEFINE_STACK_OF(OCSP_ONEREQ)\n\ntypedef struct ocsp_req_info_st OCSP_REQINFO;\ntypedef struct ocsp_signature_st OCSP_SIGNATURE;\ntypedef struct ocsp_request_st OCSP_REQUEST;\n\n#  define OCSP_RESPONSE_STATUS_SUCCESSFUL           0\n#  define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST     1\n#  define OCSP_RESPONSE_STATUS_INTERNALERROR        2\n#  define OCSP_RESPONSE_STATUS_TRYLATER             3\n#  define OCSP_RESPONSE_STATUS_SIGREQUIRED          5\n#  define OCSP_RESPONSE_STATUS_UNAUTHORIZED         6\n\ntypedef struct ocsp_resp_bytes_st OCSP_RESPBYTES;\n\n#  define V_OCSP_RESPID_NAME 0\n#  define V_OCSP_RESPID_KEY  1\n\nDEFINE_STACK_OF(OCSP_RESPID)\n\ntypedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO;\n\n#  define V_OCSP_CERTSTATUS_GOOD    0\n#  define V_OCSP_CERTSTATUS_REVOKED 1\n#  define V_OCSP_CERTSTATUS_UNKNOWN 2\n\ntypedef struct ocsp_cert_status_st OCSP_CERTSTATUS;\ntypedef struct ocsp_single_response_st OCSP_SINGLERESP;\n\nDEFINE_STACK_OF(OCSP_SINGLERESP)\n\ntypedef struct ocsp_response_data_st OCSP_RESPDATA;\n\ntypedef struct ocsp_basic_response_st OCSP_BASICRESP;\n\ntypedef struct ocsp_crl_id_st OCSP_CRLID;\ntypedef struct ocsp_service_locator_st OCSP_SERVICELOC;\n\n#  define PEM_STRING_OCSP_REQUEST \"OCSP REQUEST\"\n#  define PEM_STRING_OCSP_RESPONSE \"OCSP RESPONSE\"\n\n#  define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)\n\n#  define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)\n\n#  define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \\\n     (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST, \\\n     bp,(char **)(x),cb,NULL)\n\n#  define PEM_read_bio_OCSP_RESPONSE(bp,x,cb) (OCSP_RESPONSE *)PEM_ASN1_read_bio(\\\n     (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE, \\\n     bp,(char **)(x),cb,NULL)\n\n#  define PEM_write_bio_OCSP_REQUEST(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\\\n                        bp,(char *)(o), NULL,NULL,0,NULL,NULL)\n\n#  define PEM_write_bio_OCSP_RESPONSE(bp,o) \\\n    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\\\n                        bp,(char *)(o), NULL,NULL,0,NULL,NULL)\n\n#  define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)\n\n#  define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o)\n\n#  define ASN1_BIT_STRING_digest(data,type,md,len) \\\n        ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len)\n\n#  define OCSP_CERTSTATUS_dup(cs)\\\n                (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\\\n                (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs))\n\nOCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id);\n\nOCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req);\nOCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,\n                               int maxline);\nint OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx);\nint OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);\nOCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline);\nvoid OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);\nvoid OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);\nint OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,\n                     ASN1_VALUE *val);\nint OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,\n                          const ASN1_ITEM *it);\nBIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);\nint OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);\nint OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);\nint OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,\n                             const char *name, const char *value);\n\nOCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject,\n                             const X509 *issuer);\n\nOCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,\n                              const X509_NAME *issuerName,\n                              const ASN1_BIT_STRING *issuerKey,\n                              const ASN1_INTEGER *serialNumber);\n\nOCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid);\n\nint OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);\nint OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);\nint OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs);\nint OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);\n\nint OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm);\nint OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert);\n\nint OCSP_request_sign(OCSP_REQUEST *req,\n                      X509 *signer,\n                      EVP_PKEY *key,\n                      const EVP_MD *dgst,\n                      STACK_OF(X509) *certs, unsigned long flags);\n\nint OCSP_response_status(OCSP_RESPONSE *resp);\nOCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);\n\nconst ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs);\nconst X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs);\nconst OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs);\nint OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer,\n                          STACK_OF(X509) *extra_certs);\n\nint OCSP_resp_count(OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);\nconst ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(const OCSP_BASICRESP* bs);\nconst STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs);\nint OCSP_resp_get0_id(const OCSP_BASICRESP *bs,\n                      const ASN1_OCTET_STRING **pid,\n                      const X509_NAME **pname);\nint OCSP_resp_get1_id(const OCSP_BASICRESP *bs,\n                      ASN1_OCTET_STRING **pid,\n                      X509_NAME **pname);\n\nint OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);\nint OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,\n                            ASN1_GENERALIZEDTIME **revtime,\n                            ASN1_GENERALIZEDTIME **thisupd,\n                            ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status,\n                          int *reason,\n                          ASN1_GENERALIZEDTIME **revtime,\n                          ASN1_GENERALIZEDTIME **thisupd,\n                          ASN1_GENERALIZEDTIME **nextupd);\nint OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,\n                        ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec);\n\nint OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs,\n                        X509_STORE *store, unsigned long flags);\n\nint OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,\n                   int *pssl);\n\nint OCSP_id_issuer_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b);\nint OCSP_id_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b);\n\nint OCSP_request_onereq_count(OCSP_REQUEST *req);\nOCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i);\nOCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one);\nint OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,\n                      ASN1_OCTET_STRING **pikeyHash,\n                      ASN1_INTEGER **pserial, OCSP_CERTID *cid);\nint OCSP_request_is_signed(OCSP_REQUEST *req);\nOCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs);\nOCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp,\n                                        OCSP_CERTID *cid,\n                                        int status, int reason,\n                                        ASN1_TIME *revtime,\n                                        ASN1_TIME *thisupd,\n                                        ASN1_TIME *nextupd);\nint OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert);\nint OCSP_basic_sign(OCSP_BASICRESP *brsp,\n                    X509 *signer, EVP_PKEY *key, const EVP_MD *dgst,\n                    STACK_OF(X509) *certs, unsigned long flags);\nint OCSP_basic_sign_ctx(OCSP_BASICRESP *brsp,\n                        X509 *signer, EVP_MD_CTX *ctx,\n                        STACK_OF(X509) *certs, unsigned long flags);\nint OCSP_RESPID_set_by_name(OCSP_RESPID *respid, X509 *cert);\nint OCSP_RESPID_set_by_key(OCSP_RESPID *respid, X509 *cert);\nint OCSP_RESPID_match(OCSP_RESPID *respid, X509 *cert);\n\nX509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim);\n\nX509_EXTENSION *OCSP_accept_responses_new(char **oids);\n\nX509_EXTENSION *OCSP_archive_cutoff_new(char *tim);\n\nX509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, const char **urls);\n\nint OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x);\nint OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos);\nint OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj,\n                                int lastpos);\nint OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc);\nX509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc);\nvoid *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit,\n                                int *idx);\nint OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit,\n                              unsigned long flags);\nint OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x);\nint OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos);\nint OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, int lastpos);\nint OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos);\nX509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc);\nX509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc);\nvoid *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx);\nint OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit,\n                             unsigned long flags);\nint OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x);\nint OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos);\nint OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj,\n                                  int lastpos);\nint OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit,\n                                       int lastpos);\nX509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc);\nX509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc);\nvoid *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit,\n                                  int *idx);\nint OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value,\n                                int crit, unsigned long flags);\nint OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc);\n\nint OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x);\nint OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos);\nint OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, const ASN1_OBJECT *obj,\n                                   int lastpos);\nint OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit,\n                                        int lastpos);\nX509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc);\nX509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc);\nvoid *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,\n                                   int *idx);\nint OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,\n                                 int crit, unsigned long flags);\nint OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);\nconst OCSP_CERTID *OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x);\n\nDECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)\nDECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPID)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE)\nDECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES)\nDECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ)\nDECLARE_ASN1_FUNCTIONS(OCSP_CERTID)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQUEST)\nDECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE)\nDECLARE_ASN1_FUNCTIONS(OCSP_REQINFO)\nDECLARE_ASN1_FUNCTIONS(OCSP_CRLID)\nDECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC)\n\nconst char *OCSP_response_status_str(long s);\nconst char *OCSP_cert_status_str(long s);\nconst char *OCSP_crl_reason_str(long s);\n\nint OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags);\nint OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags);\n\nint OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs,\n                      X509_STORE *st, unsigned long flags);\n\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ocsperr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OCSPERR_H\n# define HEADER_OCSPERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_OCSP\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_OCSP_strings(void);\n\n/*\n * OCSP function codes.\n */\n#  define OCSP_F_D2I_OCSP_NONCE                            102\n#  define OCSP_F_OCSP_BASIC_ADD1_STATUS                    103\n#  define OCSP_F_OCSP_BASIC_SIGN                           104\n#  define OCSP_F_OCSP_BASIC_SIGN_CTX                       119\n#  define OCSP_F_OCSP_BASIC_VERIFY                         105\n#  define OCSP_F_OCSP_CERT_ID_NEW                          101\n#  define OCSP_F_OCSP_CHECK_DELEGATED                      106\n#  define OCSP_F_OCSP_CHECK_IDS                            107\n#  define OCSP_F_OCSP_CHECK_ISSUER                         108\n#  define OCSP_F_OCSP_CHECK_VALIDITY                       115\n#  define OCSP_F_OCSP_MATCH_ISSUERID                       109\n#  define OCSP_F_OCSP_PARSE_URL                            114\n#  define OCSP_F_OCSP_REQUEST_SIGN                         110\n#  define OCSP_F_OCSP_REQUEST_VERIFY                       116\n#  define OCSP_F_OCSP_RESPONSE_GET1_BASIC                  111\n#  define OCSP_F_PARSE_HTTP_LINE1                          118\n\n/*\n * OCSP reason codes.\n */\n#  define OCSP_R_CERTIFICATE_VERIFY_ERROR                  101\n#  define OCSP_R_DIGEST_ERR                                102\n#  define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD                 122\n#  define OCSP_R_ERROR_IN_THISUPDATE_FIELD                 123\n#  define OCSP_R_ERROR_PARSING_URL                         121\n#  define OCSP_R_MISSING_OCSPSIGNING_USAGE                 103\n#  define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE              124\n#  define OCSP_R_NOT_BASIC_RESPONSE                        104\n#  define OCSP_R_NO_CERTIFICATES_IN_CHAIN                  105\n#  define OCSP_R_NO_RESPONSE_DATA                          108\n#  define OCSP_R_NO_REVOKED_TIME                           109\n#  define OCSP_R_NO_SIGNER_KEY                             130\n#  define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE    110\n#  define OCSP_R_REQUEST_NOT_SIGNED                        128\n#  define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA      111\n#  define OCSP_R_ROOT_CA_NOT_TRUSTED                       112\n#  define OCSP_R_SERVER_RESPONSE_ERROR                     114\n#  define OCSP_R_SERVER_RESPONSE_PARSE_ERROR               115\n#  define OCSP_R_SIGNATURE_FAILURE                         117\n#  define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND              118\n#  define OCSP_R_STATUS_EXPIRED                            125\n#  define OCSP_R_STATUS_NOT_YET_VALID                      126\n#  define OCSP_R_STATUS_TOO_OLD                            127\n#  define OCSP_R_UNKNOWN_MESSAGE_DIGEST                    119\n#  define OCSP_R_UNKNOWN_NID                               120\n#  define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE            129\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/opensslconf.h",
    "content": "/*\n * WARNING: do not edit!\n * Generated by Makefile from include/openssl/opensslconf.h.in\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n#ifndef OPENSSL_NO_COMP\n# define OPENSSL_NO_COMP\n#endif\n#ifndef OPENSSL_NO_IDEA\n# define OPENSSL_NO_IDEA\n#endif\n#ifndef OPENSSL_NO_MD2\n# define OPENSSL_NO_MD2\n#endif\n#ifndef OPENSSL_NO_RC5\n# define OPENSSL_NO_RC5\n#endif\n#ifndef OPENSSL_NO_SRP\n# define OPENSSL_NO_SRP\n#endif\n#ifndef OPENSSL_RAND_SEED_OS\n# define OPENSSL_RAND_SEED_OS\n#endif\n#ifndef OPENSSL_NO_AFALGENG\n# define OPENSSL_NO_AFALGENG\n#endif\n#ifndef OPENSSL_NO_ASAN\n# define OPENSSL_NO_ASAN\n#endif\n#ifndef OPENSSL_NO_ASM\n# define OPENSSL_NO_ASM\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# define OPENSSL_NO_CRYPTO_MDEBUG\n#endif\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n#endif\n#ifndef OPENSSL_NO_DEVCRYPTOENG\n# define OPENSSL_NO_DEVCRYPTOENG\n#endif\n#ifndef OPENSSL_NO_DSO\n# define OPENSSL_NO_DSO\n#endif\n#ifndef OPENSSL_NO_DTLS\n# define OPENSSL_NO_DTLS\n#endif\n#ifndef OPENSSL_NO_DTLS1\n# define OPENSSL_NO_DTLS1\n#endif\n#ifndef OPENSSL_NO_DTLS1_2\n# define OPENSSL_NO_DTLS1_2\n#endif\n#ifndef OPENSSL_NO_EC2M\n# define OPENSSL_NO_EC2M\n#endif\n#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128\n# define OPENSSL_NO_EC_NISTP_64_GCC_128\n#endif\n#ifndef OPENSSL_NO_EGD\n# define OPENSSL_NO_EGD\n#endif\n#ifndef OPENSSL_NO_ENGINE\n# define OPENSSL_NO_ENGINE\n#endif\n#ifndef OPENSSL_NO_ERR\n# define OPENSSL_NO_ERR\n#endif\n#ifndef OPENSSL_NO_EXTERNAL_TESTS\n# define OPENSSL_NO_EXTERNAL_TESTS\n#endif\n#ifndef OPENSSL_NO_FUZZ_AFL\n# define OPENSSL_NO_FUZZ_AFL\n#endif\n#ifndef OPENSSL_NO_FUZZ_LIBFUZZER\n# define OPENSSL_NO_FUZZ_LIBFUZZER\n#endif\n#ifndef OPENSSL_NO_HEARTBEATS\n# define OPENSSL_NO_HEARTBEATS\n#endif\n#ifndef OPENSSL_NO_HW\n# define OPENSSL_NO_HW\n#endif\n#ifndef OPENSSL_NO_MSAN\n# define OPENSSL_NO_MSAN\n#endif\n#ifndef OPENSSL_NO_NEXTPROTONEG\n# define OPENSSL_NO_NEXTPROTONEG\n#endif\n#ifndef OPENSSL_NO_PSK\n# define OPENSSL_NO_PSK\n#endif\n#ifndef OPENSSL_NO_SCTP\n# define OPENSSL_NO_SCTP\n#endif\n#ifndef OPENSSL_NO_SSL_TRACE\n# define OPENSSL_NO_SSL_TRACE\n#endif\n#ifndef OPENSSL_NO_SSL3\n# define OPENSSL_NO_SSL3\n#endif\n#ifndef OPENSSL_NO_SSL3_METHOD\n# define OPENSSL_NO_SSL3_METHOD\n#endif\n#ifndef OPENSSL_NO_UBSAN\n# define OPENSSL_NO_UBSAN\n#endif\n#ifndef OPENSSL_NO_UNIT_TEST\n# define OPENSSL_NO_UNIT_TEST\n#endif\n#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS\n# define OPENSSL_NO_WEAK_SSL_CIPHERS\n#endif\n#ifndef OPENSSL_NO_DYNAMIC_ENGINE\n# define OPENSSL_NO_DYNAMIC_ENGINE\n#endif\n\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n#undef I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD <unistd.h>\n\n#undef OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n# undef BN_LLONG\n/* Only one for the following should be defined */\n# define SIXTY_FOUR_BIT_LONG\n# undef SIXTY_FOUR_BIT\n# undef THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT unsigned int\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/opensslconf.h.in",
    "content": "/*\n * {- join(\"\\n * \", @autowarntext) -}\n *\n * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslv.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef OPENSSL_ALGORITHM_DEFINES\n# error OPENSSL_ALGORITHM_DEFINES no longer supported\n#endif\n\n/*\n * OpenSSL was configured with the following options:\n */\n\n{- if (@{$config{openssl_sys_defines}}) {\n      foreach (@{$config{openssl_sys_defines}}) {\n\t$OUT .= \"#ifndef $_\\n\";\n\t$OUT .= \"# define $_ 1\\n\";\n\t$OUT .= \"#endif\\n\";\n      }\n    }\n    foreach (@{$config{openssl_api_defines}}) {\n        (my $macro, my $value) = $_ =~ /^(.*?)=(.*?)$/;\n        $OUT .= \"#define $macro $value\\n\";\n    }\n    if (@{$config{openssl_algorithm_defines}}) {\n      foreach (@{$config{openssl_algorithm_defines}}) {\n\t$OUT .= \"#ifndef $_\\n\";\n\t$OUT .= \"# define $_\\n\";\n\t$OUT .= \"#endif\\n\";\n      }\n    }\n    if (@{$config{openssl_thread_defines}}) {\n      foreach (@{$config{openssl_thread_defines}}) {\n\t$OUT .= \"#ifndef $_\\n\";\n\t$OUT .= \"# define $_\\n\";\n\t$OUT .= \"#endif\\n\";\n      }\n    }\n    if (@{$config{openssl_other_defines}}) {\n      foreach (@{$config{openssl_other_defines}}) {\n\t$OUT .= \"#ifndef $_\\n\";\n\t$OUT .= \"# define $_\\n\";\n\t$OUT .= \"#endif\\n\";\n      }\n    }\n    \"\";\n-}\n\n/*\n * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers\n * don't like that.  This will hopefully silence them.\n */\n#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;\n\n/*\n * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the\n * declarations of functions deprecated in or before <version>. Otherwise, they\n * still won't see them if the library has been built to disable deprecated\n * functions.\n */\n#ifndef DECLARE_DEPRECATED\n# define DECLARE_DEPRECATED(f)   f;\n# ifdef __GNUC__\n#  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# elif defined(__SUNPRO_C)\n#  if (__SUNPRO_C >= 0x5130)\n#   undef DECLARE_DEPRECATED\n#   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));\n#  endif\n# endif\n#endif\n\n#ifndef OPENSSL_FILE\n# ifdef OPENSSL_NO_FILENAMES\n#  define OPENSSL_FILE \"\"\n#  define OPENSSL_LINE 0\n# else\n#  define OPENSSL_FILE __FILE__\n#  define OPENSSL_LINE __LINE__\n# endif\n#endif\n\n#ifndef OPENSSL_MIN_API\n# define OPENSSL_MIN_API 0\n#endif\n\n#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API\n# undef OPENSSL_API_COMPAT\n# define OPENSSL_API_COMPAT OPENSSL_MIN_API\n#endif\n\n/*\n * Do not deprecate things to be deprecated in version 1.2.0 before the\n * OpenSSL version number matches.\n */\n#if OPENSSL_VERSION_NUMBER < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   f;\n#elif OPENSSL_API_COMPAT < 0x10200000L\n# define DEPRECATEDIN_1_2_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_2_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_1_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x10000000L\n# define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_1_0_0(f)\n#endif\n\n#if OPENSSL_API_COMPAT < 0x00908000L\n# define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)\n#else\n# define DEPRECATEDIN_0_9_8(f)\n#endif\n\n/* Generate 80386 code? */\n{- $config{processor} eq \"386\" ? \"#define\" : \"#undef\" -} I386_ONLY\n\n#undef OPENSSL_UNISTD\n#define OPENSSL_UNISTD {- $target{unistd} -}\n\n{- $config{export_var_as_fn} ? \"#define\" : \"#undef\" -} OPENSSL_EXPORT_VAR_AS_FUNCTION\n\n/*\n * The following are cipher-specific, but are part of the public API.\n */\n#if !defined(OPENSSL_SYS_UEFI)\n{- $config{bn_ll} ? \"# define\" : \"# undef\" -} BN_LLONG\n/* Only one for the following should be defined */\n{- $config{b64l} ? \"# define\" : \"# undef\" -} SIXTY_FOUR_BIT_LONG\n{- $config{b64}  ? \"# define\" : \"# undef\" -} SIXTY_FOUR_BIT\n{- $config{b32}  ? \"# define\" : \"# undef\" -} THIRTY_TWO_BIT\n#endif\n\n#define RC4_INT {- $config{rc4_int} -}\n\n#ifdef  __cplusplus\n}\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/opensslv.h",
    "content": "/*\n * Copyright 1999-2022 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OPENSSLV_H\n# define HEADER_OPENSSLV_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\n * Numeric release version identifier:\n * MNNFFPPS: major minor fix patch status\n * The status nibble has one of the values 0 for development, 1 to e for betas\n * 1 to 14, and f for release.  The patch level is exactly that.\n * For example:\n * 0.9.3-dev      0x00903000\n * 0.9.3-beta1    0x00903001\n * 0.9.3-beta2-dev 0x00903002\n * 0.9.3-beta2    0x00903002 (same as ...beta2-dev)\n * 0.9.3          0x0090300f\n * 0.9.3a         0x0090301f\n * 0.9.4          0x0090400f\n * 1.2.3z         0x102031af\n *\n * For continuity reasons (because 0.9.5 is already out, and is coded\n * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level\n * part is slightly different, by setting the highest bit.  This means\n * that 0.9.5a looks like this: 0x0090581f.  At 0.9.6, we can start\n * with 0x0090600S...\n *\n * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)\n * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for\n *  major minor fix final patch/beta)\n */\n# define OPENSSL_VERSION_NUMBER  0x101010ffL\n# define OPENSSL_VERSION_TEXT    \"OpenSSL 1.1.1o  3 May 2022\"\n\n/*-\n * The macros below are to be used for shared library (.so, .dll, ...)\n * versioning.  That kind of versioning works a bit differently between\n * operating systems.  The most usual scheme is to set a major and a minor\n * number, and have the runtime loader check that the major number is equal\n * to what it was at application link time, while the minor number has to\n * be greater or equal to what it was at application link time.  With this\n * scheme, the version number is usually part of the file name, like this:\n *\n *      libcrypto.so.0.9\n *\n * Some unixen also make a softlink with the major version number only:\n *\n *      libcrypto.so.0\n *\n * On Tru64 and IRIX 6.x it works a little bit differently.  There, the\n * shared library version is stored in the file, and is actually a series\n * of versions, separated by colons.  The rightmost version present in the\n * library when linking an application is stored in the application to be\n * matched at run time.  When the application is run, a check is done to\n * see if the library version stored in the application matches any of the\n * versions in the version string of the library itself.\n * This version string can be constructed in any way, depending on what\n * kind of matching is desired.  However, to implement the same scheme as\n * the one used in the other unixen, all compatible versions, from lowest\n * to highest, should be part of the string.  Consecutive builds would\n * give the following versions strings:\n *\n *      3.0\n *      3.0:3.1\n *      3.0:3.1:3.2\n *      4.0\n *      4.0:4.1\n *\n * Notice how version 4 is completely incompatible with version, and\n * therefore give the breach you can see.\n *\n * There may be other schemes as well that I haven't yet discovered.\n *\n * So, here's the way it works here: first of all, the library version\n * number doesn't need at all to match the overall OpenSSL version.\n * However, it's nice and more understandable if it actually does.\n * The current library version is stored in the macro SHLIB_VERSION_NUMBER,\n * which is just a piece of text in the format \"M.m.e\" (Major, minor, edit).\n * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways,\n * we need to keep a history of version numbers, which is done in the\n * macro SHLIB_VERSION_HISTORY.  The numbers are separated by colons and\n * should only keep the versions that are binary compatible with the current.\n */\n# define SHLIB_VERSION_HISTORY \"\"\n# define SHLIB_VERSION_NUMBER \"1.1\"\n\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* HEADER_OPENSSLV_H */\n"
  },
  {
    "path": "cryptomini/include/openssl/ossl_typ.h",
    "content": "/*\n * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OPENSSL_TYPES_H\n# define HEADER_OPENSSL_TYPES_H\n\n#include <limits.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# include <openssl/e_os2.h>\n\n# ifdef NO_ASN1_TYPEDEFS\n#  define ASN1_INTEGER            ASN1_STRING\n#  define ASN1_ENUMERATED         ASN1_STRING\n#  define ASN1_BIT_STRING         ASN1_STRING\n#  define ASN1_OCTET_STRING       ASN1_STRING\n#  define ASN1_PRINTABLESTRING    ASN1_STRING\n#  define ASN1_T61STRING          ASN1_STRING\n#  define ASN1_IA5STRING          ASN1_STRING\n#  define ASN1_UTCTIME            ASN1_STRING\n#  define ASN1_GENERALIZEDTIME    ASN1_STRING\n#  define ASN1_TIME               ASN1_STRING\n#  define ASN1_GENERALSTRING      ASN1_STRING\n#  define ASN1_UNIVERSALSTRING    ASN1_STRING\n#  define ASN1_BMPSTRING          ASN1_STRING\n#  define ASN1_VISIBLESTRING      ASN1_STRING\n#  define ASN1_UTF8STRING         ASN1_STRING\n#  define ASN1_BOOLEAN            int\n#  define ASN1_NULL               int\n# else\ntypedef struct asn1_string_st ASN1_INTEGER;\ntypedef struct asn1_string_st ASN1_ENUMERATED;\ntypedef struct asn1_string_st ASN1_BIT_STRING;\ntypedef struct asn1_string_st ASN1_OCTET_STRING;\ntypedef struct asn1_string_st ASN1_PRINTABLESTRING;\ntypedef struct asn1_string_st ASN1_T61STRING;\ntypedef struct asn1_string_st ASN1_IA5STRING;\ntypedef struct asn1_string_st ASN1_GENERALSTRING;\ntypedef struct asn1_string_st ASN1_UNIVERSALSTRING;\ntypedef struct asn1_string_st ASN1_BMPSTRING;\ntypedef struct asn1_string_st ASN1_UTCTIME;\ntypedef struct asn1_string_st ASN1_TIME;\ntypedef struct asn1_string_st ASN1_GENERALIZEDTIME;\ntypedef struct asn1_string_st ASN1_VISIBLESTRING;\ntypedef struct asn1_string_st ASN1_UTF8STRING;\ntypedef struct asn1_string_st ASN1_STRING;\ntypedef int ASN1_BOOLEAN;\ntypedef int ASN1_NULL;\n# endif\n\ntypedef struct asn1_object_st ASN1_OBJECT;\n\ntypedef struct ASN1_ITEM_st ASN1_ITEM;\ntypedef struct asn1_pctx_st ASN1_PCTX;\ntypedef struct asn1_sctx_st ASN1_SCTX;\n\n# ifdef _WIN32\n#  undef X509_NAME\n#  undef X509_EXTENSIONS\n#  undef PKCS7_ISSUER_AND_SERIAL\n#  undef PKCS7_SIGNER_INFO\n#  undef OCSP_REQUEST\n#  undef OCSP_RESPONSE\n# endif\n\n# ifdef BIGNUM\n#  undef BIGNUM\n# endif\nstruct dane_st;\ntypedef struct bio_st BIO;\ntypedef struct bignum_st BIGNUM;\ntypedef struct bignum_ctx BN_CTX;\ntypedef struct bn_blinding_st BN_BLINDING;\ntypedef struct bn_mont_ctx_st BN_MONT_CTX;\ntypedef struct bn_recp_ctx_st BN_RECP_CTX;\ntypedef struct bn_gencb_st BN_GENCB;\n\ntypedef struct buf_mem_st BUF_MEM;\n\ntypedef struct evp_cipher_st EVP_CIPHER;\ntypedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;\ntypedef struct evp_md_st EVP_MD;\ntypedef struct evp_md_ctx_st EVP_MD_CTX;\ntypedef struct evp_pkey_st EVP_PKEY;\n\ntypedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;\n\ntypedef struct evp_pkey_method_st EVP_PKEY_METHOD;\ntypedef struct evp_pkey_ctx_st EVP_PKEY_CTX;\n\ntypedef struct evp_Encode_Ctx_st EVP_ENCODE_CTX;\n\ntypedef struct hmac_ctx_st HMAC_CTX;\n\ntypedef struct dh_st DH;\ntypedef struct dh_method DH_METHOD;\n\ntypedef struct dsa_st DSA;\ntypedef struct dsa_method DSA_METHOD;\n\ntypedef struct rsa_st RSA;\ntypedef struct rsa_meth_st RSA_METHOD;\ntypedef struct rsa_pss_params_st RSA_PSS_PARAMS;\n\ntypedef struct ec_key_st EC_KEY;\ntypedef struct ec_key_method_st EC_KEY_METHOD;\n\ntypedef struct rand_meth_st RAND_METHOD;\ntypedef struct rand_drbg_st RAND_DRBG;\n\ntypedef struct ssl_dane_st SSL_DANE;\ntypedef struct x509_st X509;\ntypedef struct X509_algor_st X509_ALGOR;\ntypedef struct X509_crl_st X509_CRL;\ntypedef struct x509_crl_method_st X509_CRL_METHOD;\ntypedef struct x509_revoked_st X509_REVOKED;\ntypedef struct X509_name_st X509_NAME;\ntypedef struct X509_pubkey_st X509_PUBKEY;\ntypedef struct x509_store_st X509_STORE;\ntypedef struct x509_store_ctx_st X509_STORE_CTX;\n\ntypedef struct x509_object_st X509_OBJECT;\ntypedef struct x509_lookup_st X509_LOOKUP;\ntypedef struct x509_lookup_method_st X509_LOOKUP_METHOD;\ntypedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM;\n\ntypedef struct x509_sig_info_st X509_SIG_INFO;\n\ntypedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;\n\ntypedef struct v3_ext_ctx X509V3_CTX;\ntypedef struct conf_st CONF;\ntypedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS;\n\ntypedef struct ui_st UI;\ntypedef struct ui_method_st UI_METHOD;\n\ntypedef struct engine_st ENGINE;\ntypedef struct ssl_st SSL;\ntypedef struct ssl_ctx_st SSL_CTX;\n\ntypedef struct comp_ctx_st COMP_CTX;\ntypedef struct comp_method_st COMP_METHOD;\n\ntypedef struct X509_POLICY_NODE_st X509_POLICY_NODE;\ntypedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;\ntypedef struct X509_POLICY_TREE_st X509_POLICY_TREE;\ntypedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;\n\ntypedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;\ntypedef struct DIST_POINT_st DIST_POINT;\ntypedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;\ntypedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;\n\ntypedef struct crypto_ex_data_st CRYPTO_EX_DATA;\n\ntypedef struct ocsp_req_ctx_st OCSP_REQ_CTX;\ntypedef struct ocsp_response_st OCSP_RESPONSE;\ntypedef struct ocsp_responder_id_st OCSP_RESPID;\n\ntypedef struct sct_st SCT;\ntypedef struct sct_ctx_st SCT_CTX;\ntypedef struct ctlog_st CTLOG;\ntypedef struct ctlog_store_st CTLOG_STORE;\ntypedef struct ct_policy_eval_ctx_st CT_POLICY_EVAL_CTX;\n\ntypedef struct ossl_store_info_st OSSL_STORE_INFO;\ntypedef struct ossl_store_search_st OSSL_STORE_SEARCH;\n\n#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \\\n    defined(INTMAX_MAX) && defined(UINTMAX_MAX)\ntypedef intmax_t ossl_intmax_t;\ntypedef uintmax_t ossl_uintmax_t;\n#else\n/*\n * Not long long, because the C-library can only be expected to provide\n * strtoll(), strtoull() at the same time as intmax_t and strtoimax(),\n * strtoumax().  Since we use these for parsing arguments, we need the\n * conversion functions, not just the sizes.\n */\ntypedef long ossl_intmax_t;\ntypedef unsigned long ossl_uintmax_t;\n#endif\n\n#ifdef  __cplusplus\n}\n#endif\n#endif                          /* def HEADER_OPENSSL_TYPES_H */\n"
  },
  {
    "path": "cryptomini/include/openssl/pem.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PEM_H\n# define HEADER_PEM_H\n\n# include <openssl/e_os2.h>\n# include <openssl/bio.h>\n# include <openssl/safestack.h>\n# include <openssl/evp.h>\n# include <openssl/x509.h>\n# include <openssl/pemerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define PEM_BUFSIZE             1024\n\n# define PEM_STRING_X509_OLD     \"X509 CERTIFICATE\"\n# define PEM_STRING_X509         \"CERTIFICATE\"\n# define PEM_STRING_X509_TRUSTED \"TRUSTED CERTIFICATE\"\n# define PEM_STRING_X509_REQ_OLD \"NEW CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_REQ     \"CERTIFICATE REQUEST\"\n# define PEM_STRING_X509_CRL     \"X509 CRL\"\n# define PEM_STRING_EVP_PKEY     \"ANY PRIVATE KEY\"\n# define PEM_STRING_PUBLIC       \"PUBLIC KEY\"\n# define PEM_STRING_RSA          \"RSA PRIVATE KEY\"\n# define PEM_STRING_RSA_PUBLIC   \"RSA PUBLIC KEY\"\n# define PEM_STRING_DSA          \"DSA PRIVATE KEY\"\n# define PEM_STRING_DSA_PUBLIC   \"DSA PUBLIC KEY\"\n# define PEM_STRING_PKCS7        \"PKCS7\"\n# define PEM_STRING_PKCS7_SIGNED \"PKCS #7 SIGNED DATA\"\n# define PEM_STRING_PKCS8        \"ENCRYPTED PRIVATE KEY\"\n# define PEM_STRING_PKCS8INF     \"PRIVATE KEY\"\n# define PEM_STRING_DHPARAMS     \"DH PARAMETERS\"\n# define PEM_STRING_DHXPARAMS    \"X9.42 DH PARAMETERS\"\n# define PEM_STRING_SSL_SESSION  \"SSL SESSION PARAMETERS\"\n# define PEM_STRING_DSAPARAMS    \"DSA PARAMETERS\"\n# define PEM_STRING_ECDSA_PUBLIC \"ECDSA PUBLIC KEY\"\n# define PEM_STRING_ECPARAMETERS \"EC PARAMETERS\"\n# define PEM_STRING_ECPRIVATEKEY \"EC PRIVATE KEY\"\n# define PEM_STRING_PARAMETERS   \"PARAMETERS\"\n# define PEM_STRING_CMS          \"CMS\"\n\n# define PEM_TYPE_ENCRYPTED      10\n# define PEM_TYPE_MIC_ONLY       20\n# define PEM_TYPE_MIC_CLEAR      30\n# define PEM_TYPE_CLEAR          40\n\n/*\n * These macros make the PEM_read/PEM_write functions easier to maintain and\n * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or\n * IMPLEMENT_PEM_rw_cb(...)\n */\n\n# ifdef OPENSSL_NO_STDIO\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/\n# else\n\n#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \\\ntype *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \\\nint PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, \\\n                  void *u) \\\n        { \\\n        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# endif\n\n# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\ntype *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\\\n{ \\\nreturn PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \\\n}\n\n# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, const type *x) \\\n{ \\\nreturn PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \\\n}\n\n# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\nint PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \\\n        { \\\n        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \\\n        }\n\n# define IMPLEMENT_PEM_write(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_bio(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read_fp(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_const(name, type, str, asn1)\n\n# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \\\n        IMPLEMENT_PEM_read(name, type, str, asn1) \\\n        IMPLEMENT_PEM_write_cb(name, type, str, asn1)\n\n/* These are the same except they are for the declarations */\n\n# if defined(OPENSSL_NO_STDIO)\n\n#  define DECLARE_PEM_read_fp(name, type) /**/\n#  define DECLARE_PEM_write_fp(name, type) /**/\n#  define DECLARE_PEM_write_fp_const(name, type) /**/\n#  define DECLARE_PEM_write_cb_fp(name, type) /**/\n# else\n\n#  define DECLARE_PEM_read_fp(name, type) \\\n        type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x);\n\n#  define DECLARE_PEM_write_fp_const(name, type) \\\n        int PEM_write_##name(FILE *fp, const type *x);\n\n#  define DECLARE_PEM_write_cb_fp(name, type) \\\n        int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# endif\n\n#  define DECLARE_PEM_read_bio(name, type) \\\n        type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);\n\n#  define DECLARE_PEM_write_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x);\n\n#  define DECLARE_PEM_write_bio_const(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, const type *x);\n\n#  define DECLARE_PEM_write_cb_bio(name, type) \\\n        int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \\\n             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);\n\n# define DECLARE_PEM_write(name, type) \\\n        DECLARE_PEM_write_bio(name, type) \\\n        DECLARE_PEM_write_fp(name, type)\n# define DECLARE_PEM_write_const(name, type) \\\n        DECLARE_PEM_write_bio_const(name, type) \\\n        DECLARE_PEM_write_fp_const(name, type)\n# define DECLARE_PEM_write_cb(name, type) \\\n        DECLARE_PEM_write_cb_bio(name, type) \\\n        DECLARE_PEM_write_cb_fp(name, type)\n# define DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_read_bio(name, type) \\\n        DECLARE_PEM_read_fp(name, type)\n# define DECLARE_PEM_rw(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write(name, type)\n# define DECLARE_PEM_rw_const(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_const(name, type)\n# define DECLARE_PEM_rw_cb(name, type) \\\n        DECLARE_PEM_read(name, type) \\\n        DECLARE_PEM_write_cb(name, type)\ntypedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);\n\nint PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);\nint PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,\n                  pem_password_cb *callback, void *u);\n\nint PEM_read_bio(BIO *bp, char **name, char **header,\n                 unsigned char **data, long *len);\n#   define PEM_FLAG_SECURE             0x1\n#   define PEM_FLAG_EAY_COMPATIBLE     0x2\n#   define PEM_FLAG_ONLY_B64           0x4\nint PEM_read_bio_ex(BIO *bp, char **name, char **header,\n                    unsigned char **data, long *len, unsigned int flags);\nint PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm,\n                              const char *name, BIO *bp, pem_password_cb *cb,\n                              void *u);\nint PEM_write_bio(BIO *bp, const char *name, const char *hdr,\n                  const unsigned char *data, long len);\nint PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,\n                       const char *name, BIO *bp, pem_password_cb *cb,\n                       void *u);\nvoid *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,\n                        pem_password_cb *cb, void *u);\nint PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,\n                       const EVP_CIPHER *enc, unsigned char *kstr, int klen,\n                       pem_password_cb *cb, void *u);\n\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,\n                                            pem_password_cb *cb, void *u);\nint PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,\n                            unsigned char *kstr, int klen,\n                            pem_password_cb *cd, void *u);\n\n#ifndef OPENSSL_NO_STDIO\nint PEM_read(FILE *fp, char **name, char **header,\n             unsigned char **data, long *len);\nint PEM_write(FILE *fp, const char *name, const char *hdr,\n              const unsigned char *data, long len);\nvoid *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,\n                    pem_password_cb *cb, void *u);\nint PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,\n                   void *x, const EVP_CIPHER *enc, unsigned char *kstr,\n                   int klen, pem_password_cb *callback, void *u);\nSTACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,\n                                        pem_password_cb *cb, void *u);\n#endif\n\nint PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);\nint PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);\nint PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,\n                  unsigned int *siglen, EVP_PKEY *pkey);\n\n/* The default pem_password_cb that's used internally */\nint PEM_def_callback(char *buf, int num, int rwflag, void *userdata);\nvoid PEM_proc_type(char *buf, int type);\nvoid PEM_dek_info(char *buf, const char *type, int len, char *str);\n\n# include <openssl/symhacks.h>\n\nDECLARE_PEM_rw(X509, X509)\nDECLARE_PEM_rw(X509_AUX, X509)\nDECLARE_PEM_rw(X509_REQ, X509_REQ)\nDECLARE_PEM_write(X509_REQ_NEW, X509_REQ)\nDECLARE_PEM_rw(X509_CRL, X509_CRL)\nDECLARE_PEM_rw(PKCS7, PKCS7)\nDECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)\nDECLARE_PEM_rw(PKCS8, X509_SIG)\nDECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)\n# ifndef OPENSSL_NO_RSA\nDECLARE_PEM_rw_cb(RSAPrivateKey, RSA)\nDECLARE_PEM_rw_const(RSAPublicKey, RSA)\nDECLARE_PEM_rw(RSA_PUBKEY, RSA)\n# endif\n# ifndef OPENSSL_NO_DSA\nDECLARE_PEM_rw_cb(DSAPrivateKey, DSA)\nDECLARE_PEM_rw(DSA_PUBKEY, DSA)\nDECLARE_PEM_rw_const(DSAparams, DSA)\n# endif\n# ifndef OPENSSL_NO_EC\nDECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)\nDECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)\nDECLARE_PEM_rw(EC_PUBKEY, EC_KEY)\n# endif\n# ifndef OPENSSL_NO_DH\nDECLARE_PEM_rw_const(DHparams, DH)\nDECLARE_PEM_write_const(DHxparams, DH)\n# endif\nDECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)\nDECLARE_PEM_rw(PUBKEY, EVP_PKEY)\n\nint PEM_write_bio_PrivateKey_traditional(BIO *bp, EVP_PKEY *x,\n                                         const EVP_CIPHER *enc,\n                                         unsigned char *kstr, int klen,\n                                         pem_password_cb *cb, void *u);\n\nint PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,\n                                      char *kstr, int klen,\n                                      pem_password_cb *cb, void *u);\nint PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,\n                                  char *, int, pem_password_cb *, void *);\nint i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                            char *kstr, int klen,\n                            pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,\n                                char *kstr, int klen,\n                                pem_password_cb *cb, void *u);\nEVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,\n                                  void *u);\n\n# ifndef OPENSSL_NO_STDIO\nint i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                           char *kstr, int klen,\n                           pem_password_cb *cb, void *u);\nint i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,\n                               char *kstr, int klen,\n                               pem_password_cb *cb, void *u);\nint PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,\n                                  char *kstr, int klen,\n                                  pem_password_cb *cb, void *u);\n\nEVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,\n                                 void *u);\n\nint PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,\n                              char *kstr, int klen, pem_password_cb *cd,\n                              void *u);\n# endif\nEVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);\nint PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);\n\n# ifndef OPENSSL_NO_DSA\nEVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);\nEVP_PKEY *b2i_PrivateKey_bio(BIO *in);\nEVP_PKEY *b2i_PublicKey_bio(BIO *in);\nint i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);\nint i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);\n#  ifndef OPENSSL_NO_RC4\nEVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);\nint i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,\n                pem_password_cb *cb, void *u);\n#  endif\n# endif\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/pem2.h",
    "content": "/*\n * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PEM2_H\n# define HEADER_PEM2_H\n# include <openssl/pemerr.h>\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/pemerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PEMERR_H\n# define HEADER_PEMERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_PEM_strings(void);\n\n/*\n * PEM function codes.\n */\n# define PEM_F_B2I_DSS                                    127\n# define PEM_F_B2I_PVK_BIO                                128\n# define PEM_F_B2I_RSA                                    129\n# define PEM_F_CHECK_BITLEN_DSA                           130\n# define PEM_F_CHECK_BITLEN_RSA                           131\n# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO                    120\n# define PEM_F_D2I_PKCS8PRIVATEKEY_FP                     121\n# define PEM_F_DO_B2I                                     132\n# define PEM_F_DO_B2I_BIO                                 133\n# define PEM_F_DO_BLOB_HEADER                             134\n# define PEM_F_DO_I2B                                     146\n# define PEM_F_DO_PK8PKEY                                 126\n# define PEM_F_DO_PK8PKEY_FP                              125\n# define PEM_F_DO_PVK_BODY                                135\n# define PEM_F_DO_PVK_HEADER                              136\n# define PEM_F_GET_HEADER_AND_DATA                        143\n# define PEM_F_GET_NAME                                   144\n# define PEM_F_I2B_PVK                                    137\n# define PEM_F_I2B_PVK_BIO                                138\n# define PEM_F_LOAD_IV                                    101\n# define PEM_F_PEM_ASN1_READ                              102\n# define PEM_F_PEM_ASN1_READ_BIO                          103\n# define PEM_F_PEM_ASN1_WRITE                             104\n# define PEM_F_PEM_ASN1_WRITE_BIO                         105\n# define PEM_F_PEM_DEF_CALLBACK                           100\n# define PEM_F_PEM_DO_HEADER                              106\n# define PEM_F_PEM_GET_EVP_CIPHER_INFO                    107\n# define PEM_F_PEM_READ                                   108\n# define PEM_F_PEM_READ_BIO                               109\n# define PEM_F_PEM_READ_BIO_DHPARAMS                      141\n# define PEM_F_PEM_READ_BIO_EX                            145\n# define PEM_F_PEM_READ_BIO_PARAMETERS                    140\n# define PEM_F_PEM_READ_BIO_PRIVATEKEY                    123\n# define PEM_F_PEM_READ_DHPARAMS                          142\n# define PEM_F_PEM_READ_PRIVATEKEY                        124\n# define PEM_F_PEM_SIGNFINAL                              112\n# define PEM_F_PEM_WRITE                                  113\n# define PEM_F_PEM_WRITE_BIO                              114\n# define PEM_F_PEM_WRITE_BIO_PRIVATEKEY_TRADITIONAL       147\n# define PEM_F_PEM_WRITE_PRIVATEKEY                       139\n# define PEM_F_PEM_X509_INFO_READ                         115\n# define PEM_F_PEM_X509_INFO_READ_BIO                     116\n# define PEM_F_PEM_X509_INFO_WRITE_BIO                    117\n\n/*\n * PEM reason codes.\n */\n# define PEM_R_BAD_BASE64_DECODE                          100\n# define PEM_R_BAD_DECRYPT                                101\n# define PEM_R_BAD_END_LINE                               102\n# define PEM_R_BAD_IV_CHARS                               103\n# define PEM_R_BAD_MAGIC_NUMBER                           116\n# define PEM_R_BAD_PASSWORD_READ                          104\n# define PEM_R_BAD_VERSION_NUMBER                         117\n# define PEM_R_BIO_WRITE_FAILURE                          118\n# define PEM_R_CIPHER_IS_NULL                             127\n# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY               115\n# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB                 119\n# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB                  120\n# define PEM_R_HEADER_TOO_LONG                            128\n# define PEM_R_INCONSISTENT_HEADER                        121\n# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR                 122\n# define PEM_R_KEYBLOB_TOO_SHORT                          123\n# define PEM_R_MISSING_DEK_IV                             129\n# define PEM_R_NOT_DEK_INFO                               105\n# define PEM_R_NOT_ENCRYPTED                              106\n# define PEM_R_NOT_PROC_TYPE                              107\n# define PEM_R_NO_START_LINE                              108\n# define PEM_R_PROBLEMS_GETTING_PASSWORD                  109\n# define PEM_R_PVK_DATA_TOO_SHORT                         124\n# define PEM_R_PVK_TOO_SHORT                              125\n# define PEM_R_READ_KEY                                   111\n# define PEM_R_SHORT_HEADER                               112\n# define PEM_R_UNEXPECTED_DEK_IV                          130\n# define PEM_R_UNSUPPORTED_CIPHER                         113\n# define PEM_R_UNSUPPORTED_ENCRYPTION                     114\n# define PEM_R_UNSUPPORTED_KEY_COMPONENTS                 126\n# define PEM_R_UNSUPPORTED_PUBLIC_KEY_TYPE                110\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/pkcs12.h",
    "content": "/*\n * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PKCS12_H\n# define HEADER_PKCS12_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n# include <openssl/pkcs12err.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define PKCS12_KEY_ID   1\n# define PKCS12_IV_ID    2\n# define PKCS12_MAC_ID   3\n\n/* Default iteration count */\n# ifndef PKCS12_DEFAULT_ITER\n#  define PKCS12_DEFAULT_ITER     PKCS5_DEFAULT_ITER\n# endif\n\n# define PKCS12_MAC_KEY_LENGTH 20\n\n# define PKCS12_SALT_LEN 8\n\n/* It's not clear if these are actually needed... */\n# define PKCS12_key_gen PKCS12_key_gen_utf8\n# define PKCS12_add_friendlyname PKCS12_add_friendlyname_utf8\n\n/* MS key usage constants */\n\n# define KEY_EX  0x10\n# define KEY_SIG 0x80\n\ntypedef struct PKCS12_MAC_DATA_st PKCS12_MAC_DATA;\n\ntypedef struct PKCS12_st PKCS12;\n\ntypedef struct PKCS12_SAFEBAG_st PKCS12_SAFEBAG;\n\nDEFINE_STACK_OF(PKCS12_SAFEBAG)\n\ntypedef struct pkcs12_bag_st PKCS12_BAGS;\n\n# define PKCS12_ERROR    0\n# define PKCS12_OK       1\n\n/* Compatibility macros */\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n\n# define M_PKCS12_bag_type PKCS12_bag_type\n# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type\n# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type\n\n# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert\n# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl\n# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid\n# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid\n# define PKCS12_x5092certbag PKCS12_SAFEBAG_create_cert\n# define PKCS12_x509crl2certbag PKCS12_SAFEBAG_create_crl\n# define PKCS12_MAKE_KEYBAG PKCS12_SAFEBAG_create0_p8inf\n# define PKCS12_MAKE_SHKEYBAG PKCS12_SAFEBAG_create_pkcs8_encrypt\n\n#endif\n\nDEPRECATEDIN_1_1_0(ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid))\n\nASN1_TYPE *PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid);\nint PKCS12_mac_present(const PKCS12 *p12);\nvoid PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac,\n                     const X509_ALGOR **pmacalg,\n                     const ASN1_OCTET_STRING **psalt,\n                     const ASN1_INTEGER **piter,\n                     const PKCS12 *p12);\n\nconst ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag,\n                                          int attr_nid);\nconst ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag);\nint PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag);\nint PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag);\n\nX509 *PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag);\nX509_CRL *PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag);\nconst STACK_OF(PKCS12_SAFEBAG) *\nPKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag);\nconst PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag);\nconst X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag);\n\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create_cert(X509 *x509);\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create_crl(X509_CRL *crl);\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8);\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8);\nPKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid,\n                                                    const char *pass,\n                                                    int passlen,\n                                                    unsigned char *salt,\n                                                    int saltlen, int iter,\n                                                    PKCS8_PRIV_KEY_INFO *p8inf);\n\nPKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it,\n                                         int nid1, int nid2);\nPKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass,\n                                   int passlen);\nPKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag,\n                                         const char *pass, int passlen);\nX509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,\n                        const char *pass, int passlen, unsigned char *salt,\n                        int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8);\nX509_SIG *PKCS8_set0_pbe(const char *pass, int passlen,\n                        PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe);\nPKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7);\nPKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen,\n                             unsigned char *salt, int saltlen, int iter,\n                             STACK_OF(PKCS12_SAFEBAG) *bags);\nSTACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass,\n                                                  int passlen);\n\nint PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes);\nSTACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12);\n\nint PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name,\n                          int namelen);\nint PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name,\n                                int namelen);\nint PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name,\n                                 int namelen);\nint PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name,\n                           int namelen);\nint PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag,\n                                const unsigned char *name, int namelen);\nint PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage);\nASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs,\n                               int attr_nid);\nchar *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag);\nconst STACK_OF(X509_ATTRIBUTE) *\nPKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag);\nunsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor,\n                                const char *pass, int passlen,\n                                const unsigned char *in, int inlen,\n                                unsigned char **data, int *datalen,\n                                int en_de);\nvoid *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it,\n                              const char *pass, int passlen,\n                              const ASN1_OCTET_STRING *oct, int zbuf);\nASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor,\n                                           const ASN1_ITEM *it,\n                                           const char *pass, int passlen,\n                                           void *obj, int zbuf);\nPKCS12 *PKCS12_init(int mode);\nint PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,\n                       int saltlen, int id, int iter, int n,\n                       unsigned char *out, const EVP_MD *md_type);\nint PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt,\n                        int saltlen, int id, int iter, int n,\n                        unsigned char *out, const EVP_MD *md_type);\nint PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,\n                        ASN1_TYPE *param, const EVP_CIPHER *cipher,\n                        const EVP_MD *md_type, int en_de);\nint PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *mac, unsigned int *maclen);\nint PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);\nint PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,\n                   unsigned char *salt, int saltlen, int iter,\n                   const EVP_MD *md_type);\nint PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,\n                     int saltlen, const EVP_MD *md_type);\nunsigned char *OPENSSL_asc2uni(const char *asc, int asclen,\n                               unsigned char **uni, int *unilen);\nchar *OPENSSL_uni2asc(const unsigned char *uni, int unilen);\nunsigned char *OPENSSL_utf82uni(const char *asc, int asclen,\n                                unsigned char **uni, int *unilen);\nchar *OPENSSL_uni2utf8(const unsigned char *uni, int unilen);\n\nDECLARE_ASN1_FUNCTIONS(PKCS12)\nDECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA)\nDECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG)\nDECLARE_ASN1_FUNCTIONS(PKCS12_BAGS)\n\nDECLARE_ASN1_ITEM(PKCS12_SAFEBAGS)\nDECLARE_ASN1_ITEM(PKCS12_AUTHSAFES)\n\nvoid PKCS12_PBE_add(void);\nint PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,\n                 STACK_OF(X509) **ca);\nPKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey,\n                      X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert,\n                      int iter, int mac_iter, int keytype);\n\nPKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert);\nPKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags,\n                               EVP_PKEY *key, int key_usage, int iter,\n                               int key_nid, const char *pass);\nint PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags,\n                    int safe_nid, int iter, const char *pass);\nPKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid);\n\nint i2d_PKCS12_bio(BIO *bp, PKCS12 *p12);\n# ifndef OPENSSL_NO_STDIO\nint i2d_PKCS12_fp(FILE *fp, PKCS12 *p12);\n# endif\nPKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12);\n# ifndef OPENSSL_NO_STDIO\nPKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12);\n# endif\nint PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/pkcs12err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PKCS12ERR_H\n# define HEADER_PKCS12ERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_PKCS12_strings(void);\n\n/*\n * PKCS12 function codes.\n */\n# define PKCS12_F_OPENSSL_ASC2UNI                         121\n# define PKCS12_F_OPENSSL_UNI2ASC                         124\n# define PKCS12_F_OPENSSL_UNI2UTF8                        127\n# define PKCS12_F_OPENSSL_UTF82UNI                        129\n# define PKCS12_F_PKCS12_CREATE                           105\n# define PKCS12_F_PKCS12_GEN_MAC                          107\n# define PKCS12_F_PKCS12_INIT                             109\n# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I                 106\n# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT                 108\n# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG                117\n# define PKCS12_F_PKCS12_KEY_GEN_ASC                      110\n# define PKCS12_F_PKCS12_KEY_GEN_UNI                      111\n# define PKCS12_F_PKCS12_KEY_GEN_UTF8                     116\n# define PKCS12_F_PKCS12_NEWPASS                          128\n# define PKCS12_F_PKCS12_PACK_P7DATA                      114\n# define PKCS12_F_PKCS12_PACK_P7ENCDATA                   115\n# define PKCS12_F_PKCS12_PARSE                            118\n# define PKCS12_F_PKCS12_PBE_CRYPT                        119\n# define PKCS12_F_PKCS12_PBE_KEYIVGEN                     120\n# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_P8INF            112\n# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_PKCS8            113\n# define PKCS12_F_PKCS12_SAFEBAG_CREATE_PKCS8_ENCRYPT     133\n# define PKCS12_F_PKCS12_SETUP_MAC                        122\n# define PKCS12_F_PKCS12_SET_MAC                          123\n# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES                 130\n# define PKCS12_F_PKCS12_UNPACK_P7DATA                    131\n# define PKCS12_F_PKCS12_VERIFY_MAC                       126\n# define PKCS12_F_PKCS8_ENCRYPT                           125\n# define PKCS12_F_PKCS8_SET0_PBE                          132\n\n/*\n * PKCS12 reason codes.\n */\n# define PKCS12_R_CANT_PACK_STRUCTURE                     100\n# define PKCS12_R_CONTENT_TYPE_NOT_DATA                   121\n# define PKCS12_R_DECODE_ERROR                            101\n# define PKCS12_R_ENCODE_ERROR                            102\n# define PKCS12_R_ENCRYPT_ERROR                           103\n# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE       120\n# define PKCS12_R_INVALID_NULL_ARGUMENT                   104\n# define PKCS12_R_INVALID_NULL_PKCS12_POINTER             105\n# define PKCS12_R_IV_GEN_ERROR                            106\n# define PKCS12_R_KEY_GEN_ERROR                           107\n# define PKCS12_R_MAC_ABSENT                              108\n# define PKCS12_R_MAC_GENERATION_ERROR                    109\n# define PKCS12_R_MAC_SETUP_ERROR                         110\n# define PKCS12_R_MAC_STRING_SET_ERROR                    111\n# define PKCS12_R_MAC_VERIFY_FAILURE                      113\n# define PKCS12_R_PARSE_ERROR                             114\n# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR           115\n# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR                116\n# define PKCS12_R_PKCS12_PBE_CRYPT_ERROR                  117\n# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM                118\n# define PKCS12_R_UNSUPPORTED_PKCS12_MODE                 119\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/pkcs7.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PKCS7_H\n# define HEADER_PKCS7_H\n\n# include <openssl/asn1.h>\n# include <openssl/bio.h>\n# include <openssl/e_os2.h>\n\n# include <openssl/symhacks.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/pkcs7err.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\nEncryption_ID           DES-CBC\nDigest_ID               MD5\nDigest_Encryption_ID    rsaEncryption\nKey_Encryption_ID       rsaEncryption\n*/\n\ntypedef struct pkcs7_issuer_and_serial_st {\n    X509_NAME *issuer;\n    ASN1_INTEGER *serial;\n} PKCS7_ISSUER_AND_SERIAL;\n\ntypedef struct pkcs7_signer_info_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *digest_alg;\n    STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */\n    X509_ALGOR *digest_enc_alg;\n    ASN1_OCTET_STRING *enc_digest;\n    STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */\n    /* The private key to sign with */\n    EVP_PKEY *pkey;\n} PKCS7_SIGNER_INFO;\n\nDEFINE_STACK_OF(PKCS7_SIGNER_INFO)\n\ntypedef struct pkcs7_recip_info_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;\n    X509_ALGOR *key_enc_algor;\n    ASN1_OCTET_STRING *enc_key;\n    X509 *cert;                 /* get the pub-key from this */\n} PKCS7_RECIP_INFO;\n\nDEFINE_STACK_OF(PKCS7_RECIP_INFO)\n\ntypedef struct pkcs7_signed_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    struct pkcs7_st *contents;\n} PKCS7_SIGNED;\n/*\n * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about\n * merging the two\n */\n\ntypedef struct pkcs7_enc_content_st {\n    ASN1_OBJECT *content_type;\n    X509_ALGOR *algorithm;\n    ASN1_OCTET_STRING *enc_data; /* [ 0 ] */\n    const EVP_CIPHER *cipher;\n} PKCS7_ENC_CONTENT;\n\ntypedef struct pkcs7_enveloped_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENVELOPE;\n\ntypedef struct pkcs7_signedandenveloped_st {\n    ASN1_INTEGER *version;      /* version 1 */\n    STACK_OF(X509_ALGOR) *md_algs; /* md used */\n    STACK_OF(X509) *cert;       /* [ 0 ] */\n    STACK_OF(X509_CRL) *crl;    /* [ 1 ] */\n    STACK_OF(PKCS7_SIGNER_INFO) *signer_info;\n    PKCS7_ENC_CONTENT *enc_data;\n    STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;\n} PKCS7_SIGN_ENVELOPE;\n\ntypedef struct pkcs7_digest_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    X509_ALGOR *md;             /* md used */\n    struct pkcs7_st *contents;\n    ASN1_OCTET_STRING *digest;\n} PKCS7_DIGEST;\n\ntypedef struct pkcs7_encrypted_st {\n    ASN1_INTEGER *version;      /* version 0 */\n    PKCS7_ENC_CONTENT *enc_data;\n} PKCS7_ENCRYPT;\n\ntypedef struct pkcs7_st {\n    /*\n     * The following is non NULL if it contains ASN1 encoding of this\n     * structure\n     */\n    unsigned char *asn1;\n    long length;\n# define PKCS7_S_HEADER  0\n# define PKCS7_S_BODY    1\n# define PKCS7_S_TAIL    2\n    int state;                  /* used during processing */\n    int detached;\n    ASN1_OBJECT *type;\n    /* content as defined by the type */\n    /*\n     * all encryption/message digests are applied to the 'contents', leaving\n     * out the 'type' field.\n     */\n    union {\n        char *ptr;\n        /* NID_pkcs7_data */\n        ASN1_OCTET_STRING *data;\n        /* NID_pkcs7_signed */\n        PKCS7_SIGNED *sign;\n        /* NID_pkcs7_enveloped */\n        PKCS7_ENVELOPE *enveloped;\n        /* NID_pkcs7_signedAndEnveloped */\n        PKCS7_SIGN_ENVELOPE *signed_and_enveloped;\n        /* NID_pkcs7_digest */\n        PKCS7_DIGEST *digest;\n        /* NID_pkcs7_encrypted */\n        PKCS7_ENCRYPT *encrypted;\n        /* Anything else */\n        ASN1_TYPE *other;\n    } d;\n} PKCS7;\n\nDEFINE_STACK_OF(PKCS7)\n\n# define PKCS7_OP_SET_DETACHED_SIGNATURE 1\n# define PKCS7_OP_GET_DETACHED_SIGNATURE 2\n\n# define PKCS7_get_signed_attributes(si) ((si)->auth_attr)\n# define PKCS7_get_attributes(si)        ((si)->unauth_attr)\n\n# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)\n# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)\n# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)\n# define PKCS7_type_is_signedAndEnveloped(a) \\\n                (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)\n# define PKCS7_type_is_data(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_data)\n# define PKCS7_type_is_digest(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)\n\n# define PKCS7_set_detached(p,v) \\\n                PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)\n# define PKCS7_get_detached(p) \\\n                PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)\n\n# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))\n\n/* S/MIME related flags */\n\n# define PKCS7_TEXT              0x1\n# define PKCS7_NOCERTS           0x2\n# define PKCS7_NOSIGS            0x4\n# define PKCS7_NOCHAIN           0x8\n# define PKCS7_NOINTERN          0x10\n# define PKCS7_NOVERIFY          0x20\n# define PKCS7_DETACHED          0x40\n# define PKCS7_BINARY            0x80\n# define PKCS7_NOATTR            0x100\n# define PKCS7_NOSMIMECAP        0x200\n# define PKCS7_NOOLDMIMETYPE     0x400\n# define PKCS7_CRLFEOL           0x800\n# define PKCS7_STREAM            0x1000\n# define PKCS7_NOCRL             0x2000\n# define PKCS7_PARTIAL           0x4000\n# define PKCS7_REUSE_DIGEST      0x8000\n# define PKCS7_NO_DUAL_CONTENT   0x10000\n\n/* Flags: for compatibility with older code */\n\n# define SMIME_TEXT      PKCS7_TEXT\n# define SMIME_NOCERTS   PKCS7_NOCERTS\n# define SMIME_NOSIGS    PKCS7_NOSIGS\n# define SMIME_NOCHAIN   PKCS7_NOCHAIN\n# define SMIME_NOINTERN  PKCS7_NOINTERN\n# define SMIME_NOVERIFY  PKCS7_NOVERIFY\n# define SMIME_DETACHED  PKCS7_DETACHED\n# define SMIME_BINARY    PKCS7_BINARY\n# define SMIME_NOATTR    PKCS7_NOATTR\n\n/* CRLF ASCII canonicalisation */\n# define SMIME_ASCIICRLF         0x80000\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)\n\nint PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,\n                                   const EVP_MD *type, unsigned char *md,\n                                   unsigned int *len);\n# ifndef OPENSSL_NO_STDIO\nPKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7);\nint i2d_PKCS7_fp(FILE *fp, PKCS7 *p7);\n# endif\nPKCS7 *PKCS7_dup(PKCS7 *p7);\nPKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7);\nint i2d_PKCS7_bio(BIO *bp, PKCS7 *p7);\nint i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\nint PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);\n\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)\nDECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)\nDECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)\nDECLARE_ASN1_FUNCTIONS(PKCS7)\n\nDECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)\nDECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)\n\nDECLARE_ASN1_NDEF_FUNCTION(PKCS7)\nDECLARE_ASN1_PRINT_FUNCTION(PKCS7)\n\nlong PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);\n\nint PKCS7_set_type(PKCS7 *p7, int type);\nint PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);\nint PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);\nint PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,\n                          const EVP_MD *dgst);\nint PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);\nint PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);\nint PKCS7_add_certificate(PKCS7 *p7, X509 *x509);\nint PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);\nint PKCS7_content_new(PKCS7 *p7, int nid);\nint PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,\n                     BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,\n                          X509 *x509);\n\nBIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);\nint PKCS7_dataFinal(PKCS7 *p7, BIO *bio);\nBIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);\n\nPKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,\n                                       EVP_PKEY *pkey, const EVP_MD *dgst);\nX509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);\nint PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);\nSTACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);\n\nPKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);\nvoid PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,\n                                 X509_ALGOR **pdig, X509_ALGOR **psig);\nvoid PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);\nint PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);\nint PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);\nint PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);\nint PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);\n\nPKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);\nASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,\n                               void *data);\nint PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,\n                        void *value);\nASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);\nASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);\nint PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,\n                                STACK_OF(X509_ATTRIBUTE) *sk);\nint PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,\n                         STACK_OF(X509_ATTRIBUTE) *sk);\n\nPKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,\n                  BIO *data, int flags);\n\nPKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,\n                                         X509 *signcert, EVP_PKEY *pkey,\n                                         const EVP_MD *md, int flags);\n\nint PKCS7_final(PKCS7 *p7, BIO *data, int flags);\nint PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,\n                 BIO *indata, BIO *out, int flags);\nSTACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs,\n                                   int flags);\nPKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,\n                     int flags);\nint PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data,\n                  int flags);\n\nint PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,\n                              STACK_OF(X509_ALGOR) *cap);\nSTACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);\nint PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);\n\nint PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);\nint PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);\nint PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,\n                             const unsigned char *md, int mdlen);\n\nint SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);\nPKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);\n\nBIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/pkcs7err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_PKCS7ERR_H\n# define HEADER_PKCS7ERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_PKCS7_strings(void);\n\n/*\n * PKCS7 function codes.\n */\n# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB                   136\n# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME           135\n# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP                118\n# define PKCS7_F_PKCS7_ADD_CERTIFICATE                    100\n# define PKCS7_F_PKCS7_ADD_CRL                            101\n# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO                 102\n# define PKCS7_F_PKCS7_ADD_SIGNATURE                      131\n# define PKCS7_F_PKCS7_ADD_SIGNER                         103\n# define PKCS7_F_PKCS7_BIO_ADD_DIGEST                     125\n# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST               138\n# define PKCS7_F_PKCS7_CTRL                               104\n# define PKCS7_F_PKCS7_DATADECODE                         112\n# define PKCS7_F_PKCS7_DATAFINAL                          128\n# define PKCS7_F_PKCS7_DATAINIT                           105\n# define PKCS7_F_PKCS7_DATAVERIFY                         107\n# define PKCS7_F_PKCS7_DECRYPT                            114\n# define PKCS7_F_PKCS7_DECRYPT_RINFO                      133\n# define PKCS7_F_PKCS7_ENCODE_RINFO                       132\n# define PKCS7_F_PKCS7_ENCRYPT                            115\n# define PKCS7_F_PKCS7_FINAL                              134\n# define PKCS7_F_PKCS7_FIND_DIGEST                        127\n# define PKCS7_F_PKCS7_GET0_SIGNERS                       124\n# define PKCS7_F_PKCS7_RECIP_INFO_SET                     130\n# define PKCS7_F_PKCS7_SET_CIPHER                         108\n# define PKCS7_F_PKCS7_SET_CONTENT                        109\n# define PKCS7_F_PKCS7_SET_DIGEST                         126\n# define PKCS7_F_PKCS7_SET_TYPE                           110\n# define PKCS7_F_PKCS7_SIGN                               116\n# define PKCS7_F_PKCS7_SIGNATUREVERIFY                    113\n# define PKCS7_F_PKCS7_SIGNER_INFO_SET                    129\n# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN                   139\n# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER                    137\n# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP                    119\n# define PKCS7_F_PKCS7_VERIFY                             117\n\n/*\n * PKCS7 reason codes.\n */\n# define PKCS7_R_CERTIFICATE_VERIFY_ERROR                 117\n# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER          144\n# define PKCS7_R_CIPHER_NOT_INITIALIZED                   116\n# define PKCS7_R_CONTENT_AND_DATA_PRESENT                 118\n# define PKCS7_R_CTRL_ERROR                               152\n# define PKCS7_R_DECRYPT_ERROR                            119\n# define PKCS7_R_DIGEST_FAILURE                           101\n# define PKCS7_R_ENCRYPTION_CTRL_FAILURE                  149\n# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150\n# define PKCS7_R_ERROR_ADDING_RECIPIENT                   120\n# define PKCS7_R_ERROR_SETTING_CIPHER                     121\n# define PKCS7_R_INVALID_NULL_POINTER                     143\n# define PKCS7_R_INVALID_SIGNED_DATA_TYPE                 155\n# define PKCS7_R_NO_CONTENT                               122\n# define PKCS7_R_NO_DEFAULT_DIGEST                        151\n# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND            154\n# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE         115\n# define PKCS7_R_NO_SIGNATURES_ON_DATA                    123\n# define PKCS7_R_NO_SIGNERS                               142\n# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE     104\n# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR                124\n# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR                   153\n# define PKCS7_R_PKCS7_DATASIGN                           145\n# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE   127\n# define PKCS7_R_SIGNATURE_FAILURE                        105\n# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND             128\n# define PKCS7_R_SIGNING_CTRL_FAILURE                     147\n# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE  148\n# define PKCS7_R_SMIME_TEXT_ERROR                         129\n# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE               106\n# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO                   107\n# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST            108\n# define PKCS7_R_UNKNOWN_DIGEST_TYPE                      109\n# define PKCS7_R_UNKNOWN_OPERATION                        110\n# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE                  111\n# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE                 112\n# define PKCS7_R_WRONG_CONTENT_TYPE                       113\n# define PKCS7_R_WRONG_PKCS7_TYPE                         114\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/rand.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RAND_H\n# define HEADER_RAND_H\n\n# include <stdlib.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/e_os2.h>\n# include <openssl/randerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\nstruct rand_meth_st {\n    int (*seed) (const void *buf, int num);\n    int (*bytes) (unsigned char *buf, int num);\n    void (*cleanup) (void);\n    int (*add) (const void *buf, int num, double randomness);\n    int (*pseudorand) (unsigned char *buf, int num);\n    int (*status) (void);\n};\n\nint RAND_set_rand_method(const RAND_METHOD *meth);\nconst RAND_METHOD *RAND_get_rand_method(void);\n# ifndef OPENSSL_NO_ENGINE\nint RAND_set_rand_engine(ENGINE *engine);\n# endif\n\nRAND_METHOD *RAND_OpenSSL(void);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#   define RAND_cleanup() while(0) continue\n# endif\nint RAND_bytes(unsigned char *buf, int num);\nint RAND_priv_bytes(unsigned char *buf, int num);\nDEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))\n\nvoid RAND_seed(const void *buf, int num);\nvoid RAND_keep_random_devices_open(int keep);\n\n# if defined(__ANDROID__) && defined(__NDK_FPABI__)\n__NDK_FPABI__\t/* __attribute__((pcs(\"aapcs\"))) on ARM */\n# endif\nvoid RAND_add(const void *buf, int num, double randomness);\nint RAND_load_file(const char *file, long max_bytes);\nint RAND_write_file(const char *file);\nconst char *RAND_file_name(char *file, size_t num);\nint RAND_status(void);\n\n# ifndef OPENSSL_NO_EGD\nint RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);\nint RAND_egd(const char *path);\nint RAND_egd_bytes(const char *path, int bytes);\n# endif\n\nint RAND_poll(void);\n\n# if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))\n/* application has to include <windows.h> in order to use these */\nDEPRECATEDIN_1_1_0(void RAND_screen(void))\nDEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM))\n# endif\n\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/rand_drbg.h",
    "content": "/*\n * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_DRBG_RAND_H\n# define HEADER_DRBG_RAND_H\n\n# include <time.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/obj_mac.h>\n\n/*\n * RAND_DRBG  flags\n *\n * Note: if new flags are added, the constant `rand_drbg_used_flags`\n *       in drbg_lib.c needs to be updated accordingly.\n */\n\n/* In CTR mode, disable derivation function ctr_df */\n# define RAND_DRBG_FLAG_CTR_NO_DF            0x1\n\n\n# if OPENSSL_API_COMPAT < 0x10200000L\n/* This #define was replaced by an internal constant and should not be used. */\n#  define RAND_DRBG_USED_FLAGS  (RAND_DRBG_FLAG_CTR_NO_DF)\n# endif\n\n/*\n * Default security strength (in the sense of [NIST SP 800-90Ar1])\n *\n * NIST SP 800-90Ar1 supports the strength of the DRBG being smaller than that\n * of the cipher by collecting less entropy. The current DRBG implementation\n * does not take RAND_DRBG_STRENGTH into account and sets the strength of the\n * DRBG to that of the cipher.\n *\n * RAND_DRBG_STRENGTH is currently only used for the legacy RAND\n * implementation.\n *\n * Currently supported ciphers are: NID_aes_128_ctr, NID_aes_192_ctr and\n * NID_aes_256_ctr\n */\n# define RAND_DRBG_STRENGTH             256\n/* Default drbg type */\n# define RAND_DRBG_TYPE                 NID_aes_256_ctr\n/* Default drbg flags */\n# define RAND_DRBG_FLAGS                0\n\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*\n * Object lifetime functions.\n */\nRAND_DRBG *RAND_DRBG_new(int type, unsigned int flags, RAND_DRBG *parent);\nRAND_DRBG *RAND_DRBG_secure_new(int type, unsigned int flags, RAND_DRBG *parent);\nint RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags);\nint RAND_DRBG_set_defaults(int type, unsigned int flags);\nint RAND_DRBG_instantiate(RAND_DRBG *drbg,\n                          const unsigned char *pers, size_t perslen);\nint RAND_DRBG_uninstantiate(RAND_DRBG *drbg);\nvoid RAND_DRBG_free(RAND_DRBG *drbg);\n\n/*\n * Object \"use\" functions.\n */\nint RAND_DRBG_reseed(RAND_DRBG *drbg,\n                     const unsigned char *adin, size_t adinlen,\n                     int prediction_resistance);\nint RAND_DRBG_generate(RAND_DRBG *drbg, unsigned char *out, size_t outlen,\n                       int prediction_resistance,\n                       const unsigned char *adin, size_t adinlen);\nint RAND_DRBG_bytes(RAND_DRBG *drbg, unsigned char *out, size_t outlen);\n\nint RAND_DRBG_set_reseed_interval(RAND_DRBG *drbg, unsigned int interval);\nint RAND_DRBG_set_reseed_time_interval(RAND_DRBG *drbg, time_t interval);\n\nint RAND_DRBG_set_reseed_defaults(\n                                  unsigned int master_reseed_interval,\n                                  unsigned int slave_reseed_interval,\n                                  time_t master_reseed_time_interval,\n                                  time_t slave_reseed_time_interval\n                                  );\n\nRAND_DRBG *RAND_DRBG_get0_master(void);\nRAND_DRBG *RAND_DRBG_get0_public(void);\nRAND_DRBG *RAND_DRBG_get0_private(void);\n\n/*\n * EXDATA\n */\n# define RAND_DRBG_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DRBG, l, p, newf, dupf, freef)\nint RAND_DRBG_set_ex_data(RAND_DRBG *drbg, int idx, void *arg);\nvoid *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx);\n\n/*\n * Callback function typedefs\n */\ntypedef size_t (*RAND_DRBG_get_entropy_fn)(RAND_DRBG *drbg,\n                                           unsigned char **pout,\n                                           int entropy, size_t min_len,\n                                           size_t max_len,\n                                           int prediction_resistance);\ntypedef void (*RAND_DRBG_cleanup_entropy_fn)(RAND_DRBG *ctx,\n                                             unsigned char *out, size_t outlen);\ntypedef size_t (*RAND_DRBG_get_nonce_fn)(RAND_DRBG *drbg, unsigned char **pout,\n                                         int entropy, size_t min_len,\n                                         size_t max_len);\ntypedef void (*RAND_DRBG_cleanup_nonce_fn)(RAND_DRBG *drbg,\n                                           unsigned char *out, size_t outlen);\n\nint RAND_DRBG_set_callbacks(RAND_DRBG *drbg,\n                            RAND_DRBG_get_entropy_fn get_entropy,\n                            RAND_DRBG_cleanup_entropy_fn cleanup_entropy,\n                            RAND_DRBG_get_nonce_fn get_nonce,\n                            RAND_DRBG_cleanup_nonce_fn cleanup_nonce);\n\n\n# ifdef  __cplusplus\n}\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/randerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RANDERR_H\n# define HEADER_RANDERR_H\n\n# include <openssl/symhacks.h>\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_RAND_strings(void);\n\n/*\n * RAND function codes.\n */\n# define RAND_F_DATA_COLLECT_METHOD                       127\n# define RAND_F_DRBG_BYTES                                101\n# define RAND_F_DRBG_GET_ENTROPY                          105\n# define RAND_F_DRBG_SETUP                                117\n# define RAND_F_GET_ENTROPY                               106\n# define RAND_F_RAND_BYTES                                100\n# define RAND_F_RAND_DRBG_ENABLE_LOCKING                  119\n# define RAND_F_RAND_DRBG_GENERATE                        107\n# define RAND_F_RAND_DRBG_GET_ENTROPY                     120\n# define RAND_F_RAND_DRBG_GET_NONCE                       123\n# define RAND_F_RAND_DRBG_INSTANTIATE                     108\n# define RAND_F_RAND_DRBG_NEW                             109\n# define RAND_F_RAND_DRBG_RESEED                          110\n# define RAND_F_RAND_DRBG_RESTART                         102\n# define RAND_F_RAND_DRBG_SET                             104\n# define RAND_F_RAND_DRBG_SET_DEFAULTS                    121\n# define RAND_F_RAND_DRBG_UNINSTANTIATE                   118\n# define RAND_F_RAND_LOAD_FILE                            111\n# define RAND_F_RAND_POOL_ACQUIRE_ENTROPY                 122\n# define RAND_F_RAND_POOL_ADD                             103\n# define RAND_F_RAND_POOL_ADD_BEGIN                       113\n# define RAND_F_RAND_POOL_ADD_END                         114\n# define RAND_F_RAND_POOL_ATTACH                          124\n# define RAND_F_RAND_POOL_BYTES_NEEDED                    115\n# define RAND_F_RAND_POOL_GROW                            125\n# define RAND_F_RAND_POOL_NEW                             116\n# define RAND_F_RAND_PSEUDO_BYTES                         126\n# define RAND_F_RAND_WRITE_FILE                           112\n\n/*\n * RAND reason codes.\n */\n# define RAND_R_ADDITIONAL_INPUT_TOO_LONG                 102\n# define RAND_R_ALREADY_INSTANTIATED                      103\n# define RAND_R_ARGUMENT_OUT_OF_RANGE                     105\n# define RAND_R_CANNOT_OPEN_FILE                          121\n# define RAND_R_DRBG_ALREADY_INITIALIZED                  129\n# define RAND_R_DRBG_NOT_INITIALISED                      104\n# define RAND_R_ENTROPY_INPUT_TOO_LONG                    106\n# define RAND_R_ENTROPY_OUT_OF_RANGE                      124\n# define RAND_R_ERROR_ENTROPY_POOL_WAS_IGNORED            127\n# define RAND_R_ERROR_INITIALISING_DRBG                   107\n# define RAND_R_ERROR_INSTANTIATING_DRBG                  108\n# define RAND_R_ERROR_RETRIEVING_ADDITIONAL_INPUT         109\n# define RAND_R_ERROR_RETRIEVING_ENTROPY                  110\n# define RAND_R_ERROR_RETRIEVING_NONCE                    111\n# define RAND_R_FAILED_TO_CREATE_LOCK                     126\n# define RAND_R_FUNC_NOT_IMPLEMENTED                      101\n# define RAND_R_FWRITE_ERROR                              123\n# define RAND_R_GENERATE_ERROR                            112\n# define RAND_R_INTERNAL_ERROR                            113\n# define RAND_R_IN_ERROR_STATE                            114\n# define RAND_R_NOT_A_REGULAR_FILE                        122\n# define RAND_R_NOT_INSTANTIATED                          115\n# define RAND_R_NO_DRBG_IMPLEMENTATION_SELECTED           128\n# define RAND_R_PARENT_LOCKING_NOT_ENABLED                130\n# define RAND_R_PARENT_STRENGTH_TOO_WEAK                  131\n# define RAND_R_PERSONALISATION_STRING_TOO_LONG           116\n# define RAND_R_PREDICTION_RESISTANCE_NOT_SUPPORTED       133\n# define RAND_R_PRNG_NOT_SEEDED                           100\n# define RAND_R_RANDOM_POOL_OVERFLOW                      125\n# define RAND_R_RANDOM_POOL_UNDERFLOW                     134\n# define RAND_R_REQUEST_TOO_LARGE_FOR_DRBG                117\n# define RAND_R_RESEED_ERROR                              118\n# define RAND_R_SELFTEST_FAILURE                          119\n# define RAND_R_TOO_LITTLE_NONCE_REQUESTED                135\n# define RAND_R_TOO_MUCH_NONCE_REQUESTED                  136\n# define RAND_R_UNSUPPORTED_DRBG_FLAGS                    132\n# define RAND_R_UNSUPPORTED_DRBG_TYPE                     120\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/rc2.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RC2_H\n# define HEADER_RC2_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_RC2\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef unsigned int RC2_INT;\n\n# define RC2_ENCRYPT     1\n# define RC2_DECRYPT     0\n\n# define RC2_BLOCK       8\n# define RC2_KEY_LENGTH  16\n\ntypedef struct rc2_key_st {\n    RC2_INT data[64];\n} RC2_KEY;\n\nvoid RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits);\nvoid RC2_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                     RC2_KEY *key, int enc);\nvoid RC2_encrypt(unsigned long *data, RC2_KEY *key);\nvoid RC2_decrypt(unsigned long *data, RC2_KEY *key);\nvoid RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,\n                     RC2_KEY *ks, unsigned char *iv, int enc);\nvoid RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, RC2_KEY *schedule, unsigned char *ivec,\n                       int *num, int enc);\nvoid RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                       long length, RC2_KEY *schedule, unsigned char *ivec,\n                       int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/rc4.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RC4_H\n# define HEADER_RC4_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_RC4\n# include <stddef.h>\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct rc4_key_st {\n    RC4_INT x, y;\n    RC4_INT data[256];\n} RC4_KEY;\n\nconst char *RC4_options(void);\nvoid RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);\nvoid RC4(RC4_KEY *key, size_t len, const unsigned char *indata,\n         unsigned char *outdata);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/rc5.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RC5_H\n# define HEADER_RC5_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_RC5\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define RC5_ENCRYPT     1\n# define RC5_DECRYPT     0\n\n# define RC5_32_INT unsigned int\n\n# define RC5_32_BLOCK            8\n# define RC5_32_KEY_LENGTH       16/* This is a default, max is 255 */\n\n/*\n * This are the only values supported.  Tweak the code if you want more The\n * most supported modes will be RC5-32/12/16 RC5-32/16/8\n */\n# define RC5_8_ROUNDS    8\n# define RC5_12_ROUNDS   12\n# define RC5_16_ROUNDS   16\n\ntypedef struct rc5_key_st {\n    /* Number of rounds */\n    int rounds;\n    RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)];\n} RC5_32_KEY;\n\nvoid RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,\n                    int rounds);\nvoid RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                        RC5_32_KEY *key, int enc);\nvoid RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key);\nvoid RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key);\nvoid RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,\n                        long length, RC5_32_KEY *ks, unsigned char *iv,\n                        int enc);\nvoid RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out,\n                          long length, RC5_32_KEY *schedule,\n                          unsigned char *ivec, int *num, int enc);\nvoid RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out,\n                          long length, RC5_32_KEY *schedule,\n                          unsigned char *ivec, int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ripemd.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RIPEMD_H\n# define HEADER_RIPEMD_H\n\n# include <openssl/opensslconf.h>\n\n#ifndef OPENSSL_NO_RMD160\n# include <openssl/e_os2.h>\n# include <stddef.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# define RIPEMD160_LONG unsigned int\n\n# define RIPEMD160_CBLOCK        64\n# define RIPEMD160_LBLOCK        (RIPEMD160_CBLOCK/4)\n# define RIPEMD160_DIGEST_LENGTH 20\n\ntypedef struct RIPEMD160state_st {\n    RIPEMD160_LONG A, B, C, D, E;\n    RIPEMD160_LONG Nl, Nh;\n    RIPEMD160_LONG data[RIPEMD160_LBLOCK];\n    unsigned int num;\n} RIPEMD160_CTX;\n\nint RIPEMD160_Init(RIPEMD160_CTX *c);\nint RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len);\nint RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c);\nunsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md);\nvoid RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/rsa.h",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RSA_H\n# define HEADER_RSA_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_RSA\n# include <openssl/asn1.h>\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/ossl_typ.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/bn.h>\n# endif\n# include <openssl/rsaerr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/* The types RSA and RSA_METHOD are defined in ossl_typ.h */\n\n# ifndef OPENSSL_RSA_MAX_MODULUS_BITS\n#  define OPENSSL_RSA_MAX_MODULUS_BITS   16384\n# endif\n\n# define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024\n\n# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS\n#  define OPENSSL_RSA_SMALL_MODULUS_BITS 3072\n# endif\n# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS\n\n/* exponent limit enforced for \"large\" modulus only */\n#  define OPENSSL_RSA_MAX_PUBEXP_BITS    64\n# endif\n\n# define RSA_3   0x3L\n# define RSA_F4  0x10001L\n\n/* based on RFC 8017 appendix A.1.2 */\n# define RSA_ASN1_VERSION_DEFAULT        0\n# define RSA_ASN1_VERSION_MULTI          1\n\n# define RSA_DEFAULT_PRIME_NUM           2\n\n# define RSA_METHOD_FLAG_NO_CHECK        0x0001/* don't check pub/private\n                                                * match */\n\n# define RSA_FLAG_CACHE_PUBLIC           0x0002\n# define RSA_FLAG_CACHE_PRIVATE          0x0004\n# define RSA_FLAG_BLINDING               0x0008\n# define RSA_FLAG_THREAD_SAFE            0x0010\n/*\n * This flag means the private key operations will be handled by rsa_mod_exp\n * and that they do not depend on the private key components being present:\n * for example a key stored in external hardware. Without this flag\n * bn_mod_exp gets called when private key components are absent.\n */\n# define RSA_FLAG_EXT_PKEY               0x0020\n\n/*\n * new with 0.9.6j and 0.9.7b; the built-in\n * RSA implementation now uses blinding by\n * default (ignoring RSA_FLAG_BLINDING),\n * but other engines might not need it\n */\n# define RSA_FLAG_NO_BLINDING            0x0080\n# if OPENSSL_API_COMPAT < 0x10100000L\n/*\n * Does nothing. Previously this switched off constant time behaviour.\n */\n#  define RSA_FLAG_NO_CONSTTIME           0x0000\n# endif\n# if OPENSSL_API_COMPAT < 0x00908000L\n/* deprecated name for the flag*/\n/*\n * new with 0.9.7h; the built-in RSA\n * implementation now uses constant time\n * modular exponentiation for secret exponents\n * by default. This flag causes the\n * faster variable sliding window method to\n * be used for all exponents.\n */\n#  define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME\n# endif\n\n# define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \\\n        RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_RSA_PADDING, pad, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \\\n        RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)\n\n# define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \\\n        RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                          EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)\n/* Salt length matches digest */\n# define RSA_PSS_SALTLEN_DIGEST -1\n/* Verify only: auto detect salt length */\n# define RSA_PSS_SALTLEN_AUTO   -2\n/* Set salt length to maximum possible */\n# define RSA_PSS_SALTLEN_MAX    -3\n/* Old compatible max salt length for sign only */\n# define RSA_PSS_SALTLEN_MAX_SIGN    -2\n\n# define EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx, len) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)\n\n# define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \\\n        RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \\\n                          EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, 0, plen)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)\n\n# define EVP_PKEY_CTX_set_rsa_keygen_primes(ctx, primes) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES, primes, NULL)\n\n# define  EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                          EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))\n\n# define  EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \\\n                          EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))\n\n# define  EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                          EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)(md))\n\n# define  EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \\\n        RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \\\n                          EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)(pmd))\n\n# define  EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                          EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)(pmd))\n\n# define  EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                          EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)(l))\n\n# define  EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \\\n                          EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)(l))\n\n# define  EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx, md) \\\n        EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS,  \\\n                          EVP_PKEY_OP_KEYGEN, EVP_PKEY_CTRL_MD,  \\\n                          0, (void *)(md))\n\n# define EVP_PKEY_CTRL_RSA_PADDING       (EVP_PKEY_ALG_CTRL + 1)\n# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN   (EVP_PKEY_ALG_CTRL + 2)\n\n# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS   (EVP_PKEY_ALG_CTRL + 3)\n# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)\n# define EVP_PKEY_CTRL_RSA_MGF1_MD       (EVP_PKEY_ALG_CTRL + 5)\n\n# define EVP_PKEY_CTRL_GET_RSA_PADDING           (EVP_PKEY_ALG_CTRL + 6)\n# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN       (EVP_PKEY_ALG_CTRL + 7)\n# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD           (EVP_PKEY_ALG_CTRL + 8)\n\n# define EVP_PKEY_CTRL_RSA_OAEP_MD       (EVP_PKEY_ALG_CTRL + 9)\n# define EVP_PKEY_CTRL_RSA_OAEP_LABEL    (EVP_PKEY_ALG_CTRL + 10)\n\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD   (EVP_PKEY_ALG_CTRL + 11)\n# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)\n\n# define EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES  (EVP_PKEY_ALG_CTRL + 13)\n\n# define RSA_PKCS1_PADDING       1\n# define RSA_SSLV23_PADDING      2\n# define RSA_NO_PADDING          3\n# define RSA_PKCS1_OAEP_PADDING  4\n# define RSA_X931_PADDING        5\n/* EVP_PKEY_ only */\n# define RSA_PKCS1_PSS_PADDING   6\n\n# define RSA_PKCS1_PADDING_SIZE  11\n\n# define RSA_set_app_data(s,arg)         RSA_set_ex_data(s,0,arg)\n# define RSA_get_app_data(s)             RSA_get_ex_data(s,0)\n\nRSA *RSA_new(void);\nRSA *RSA_new_method(ENGINE *engine);\nint RSA_bits(const RSA *rsa);\nint RSA_size(const RSA *rsa);\nint RSA_security_bits(const RSA *rsa);\n\nint RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);\nint RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);\nint RSA_set0_crt_params(RSA *r,BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);\nint RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], BIGNUM *exps[],\n                                BIGNUM *coeffs[], int pnum);\nvoid RSA_get0_key(const RSA *r,\n                  const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);\nvoid RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);\nint RSA_get_multi_prime_extra_count(const RSA *r);\nint RSA_get0_multi_prime_factors(const RSA *r, const BIGNUM *primes[]);\nvoid RSA_get0_crt_params(const RSA *r,\n                         const BIGNUM **dmp1, const BIGNUM **dmq1,\n                         const BIGNUM **iqmp);\nint RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[],\n                                    const BIGNUM *coeffs[]);\nconst BIGNUM *RSA_get0_n(const RSA *d);\nconst BIGNUM *RSA_get0_e(const RSA *d);\nconst BIGNUM *RSA_get0_d(const RSA *d);\nconst BIGNUM *RSA_get0_p(const RSA *d);\nconst BIGNUM *RSA_get0_q(const RSA *d);\nconst BIGNUM *RSA_get0_dmp1(const RSA *r);\nconst BIGNUM *RSA_get0_dmq1(const RSA *r);\nconst BIGNUM *RSA_get0_iqmp(const RSA *r);\nconst RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r);\nvoid RSA_clear_flags(RSA *r, int flags);\nint RSA_test_flags(const RSA *r, int flags);\nvoid RSA_set_flags(RSA *r, int flags);\nint RSA_get_version(RSA *r);\nENGINE *RSA_get0_engine(const RSA *r);\n\n/* Deprecated version */\nDEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void\n                                         (*callback) (int, int, void *),\n                                         void *cb_arg))\n\n/* New version */\nint RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\n/* Multi-prime version */\nint RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes,\n                                 BIGNUM *e, BN_GENCB *cb);\n\nint RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1,\n                       BIGNUM *q2, const BIGNUM *Xp1, const BIGNUM *Xp2,\n                       const BIGNUM *Xp, const BIGNUM *Xq1, const BIGNUM *Xq2,\n                       const BIGNUM *Xq, const BIGNUM *e, BN_GENCB *cb);\nint RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e,\n                             BN_GENCB *cb);\n\nint RSA_check_key(const RSA *);\nint RSA_check_key_ex(const RSA *, BN_GENCB *cb);\n        /* next 4 return -1 on error */\nint RSA_public_encrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_encrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nint RSA_public_decrypt(int flen, const unsigned char *from,\n                       unsigned char *to, RSA *rsa, int padding);\nint RSA_private_decrypt(int flen, const unsigned char *from,\n                        unsigned char *to, RSA *rsa, int padding);\nvoid RSA_free(RSA *r);\n/* \"up\" the RSA object's reference count */\nint RSA_up_ref(RSA *r);\n\nint RSA_flags(const RSA *r);\n\nvoid RSA_set_default_method(const RSA_METHOD *meth);\nconst RSA_METHOD *RSA_get_default_method(void);\nconst RSA_METHOD *RSA_null_method(void);\nconst RSA_METHOD *RSA_get_method(const RSA *rsa);\nint RSA_set_method(RSA *rsa, const RSA_METHOD *meth);\n\n/* these are the actual RSA functions */\nconst RSA_METHOD *RSA_PKCS1_OpenSSL(void);\n\nint RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2);\n\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)\nDECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)\n\nstruct rsa_pss_params_st {\n    X509_ALGOR *hashAlgorithm;\n    X509_ALGOR *maskGenAlgorithm;\n    ASN1_INTEGER *saltLength;\n    ASN1_INTEGER *trailerField;\n    /* Decoded hash algorithm from maskGenAlgorithm */\n    X509_ALGOR *maskHash;\n};\n\nDECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)\n\ntypedef struct rsa_oaep_params_st {\n    X509_ALGOR *hashFunc;\n    X509_ALGOR *maskGenFunc;\n    X509_ALGOR *pSourceFunc;\n    /* Decoded hash algorithm from maskGenFunc */\n    X509_ALGOR *maskHash;\n} RSA_OAEP_PARAMS;\n\nDECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)\n\n# ifndef OPENSSL_NO_STDIO\nint RSA_print_fp(FILE *fp, const RSA *r, int offset);\n# endif\n\nint RSA_print(BIO *bp, const RSA *r, int offset);\n\n/*\n * The following 2 functions sign and verify a X509_SIG ASN1 object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign(int type, const unsigned char *m, unsigned int m_length,\n             unsigned char *sigret, unsigned int *siglen, RSA *rsa);\nint RSA_verify(int type, const unsigned char *m, unsigned int m_length,\n               const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);\n\n/*\n * The following 2 function sign and verify a ASN1_OCTET_STRING object inside\n * PKCS#1 padded RSA encryption\n */\nint RSA_sign_ASN1_OCTET_STRING(int type,\n                               const unsigned char *m, unsigned int m_length,\n                               unsigned char *sigret, unsigned int *siglen,\n                               RSA *rsa);\nint RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m,\n                                 unsigned int m_length, unsigned char *sigbuf,\n                                 unsigned int siglen, RSA *rsa);\n\nint RSA_blinding_on(RSA *rsa, BN_CTX *ctx);\nvoid RSA_blinding_off(RSA *rsa);\nBN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);\n\nint RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl);\nint RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,\n                                   const unsigned char *f, int fl,\n                                   int rsa_len);\nint PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed,\n               long seedlen, const EVP_MD *dgst);\nint RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,\n                               const unsigned char *f, int fl,\n                               const unsigned char *p, int pl);\nint RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,\n                                 const unsigned char *f, int fl, int rsa_len,\n                                 const unsigned char *p, int pl);\nint RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                    const unsigned char *from, int flen,\n                                    const unsigned char *param, int plen,\n                                    const EVP_MD *md, const EVP_MD *mgf1md);\nint RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,\n                                      const unsigned char *from, int flen,\n                                      int num, const unsigned char *param,\n                                      int plen, const EVP_MD *md,\n                                      const EVP_MD *mgf1md);\nint RSA_padding_add_SSLv23(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl);\nint RSA_padding_check_SSLv23(unsigned char *to, int tlen,\n                             const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_none(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f,\n                         int fl);\nint RSA_padding_check_X931(unsigned char *to, int tlen,\n                           const unsigned char *f, int fl, int rsa_len);\nint RSA_X931_hash_id(int nid);\n\nint RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,\n                         const EVP_MD *Hash, const unsigned char *EM,\n                         int sLen);\nint RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,\n                              const unsigned char *mHash, const EVP_MD *Hash,\n                              int sLen);\n\nint RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,\n                              const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                              const unsigned char *EM, int sLen);\n\nint RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,\n                                   const unsigned char *mHash,\n                                   const EVP_MD *Hash, const EVP_MD *mgf1Hash,\n                                   int sLen);\n\n#define RSA_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef)\nint RSA_set_ex_data(RSA *r, int idx, void *arg);\nvoid *RSA_get_ex_data(const RSA *r, int idx);\n\nRSA *RSAPublicKey_dup(RSA *rsa);\nRSA *RSAPrivateKey_dup(RSA *rsa);\n\n/*\n * If this flag is set the RSA method is FIPS compliant and can be used in\n * FIPS mode. This is set in the validated module method. If an application\n * sets this flag in its own methods it is its responsibility to ensure the\n * result is compliant.\n */\n\n# define RSA_FLAG_FIPS_METHOD                    0x0400\n\n/*\n * If this flag is set the operations normally disabled in FIPS mode are\n * permitted it is then the applications responsibility to ensure that the\n * usage is compliant.\n */\n\n# define RSA_FLAG_NON_FIPS_ALLOW                 0x0400\n/*\n * Application has decided PRNG is good enough to generate a key: don't\n * check.\n */\n# define RSA_FLAG_CHECKED                        0x0800\n\nRSA_METHOD *RSA_meth_new(const char *name, int flags);\nvoid RSA_meth_free(RSA_METHOD *meth);\nRSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);\nconst char *RSA_meth_get0_name(const RSA_METHOD *meth);\nint RSA_meth_set1_name(RSA_METHOD *meth, const char *name);\nint RSA_meth_get_flags(const RSA_METHOD *meth);\nint RSA_meth_set_flags(RSA_METHOD *meth, int flags);\nvoid *RSA_meth_get0_app_data(const RSA_METHOD *meth);\nint RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);\nint (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))\n    (int flen, const unsigned char *from,\n     unsigned char *to, RSA *rsa, int padding);\nint RSA_meth_set_pub_enc(RSA_METHOD *rsa,\n                         int (*pub_enc) (int flen, const unsigned char *from,\n                                         unsigned char *to, RSA *rsa,\n                                         int padding));\nint (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))\n    (int flen, const unsigned char *from,\n     unsigned char *to, RSA *rsa, int padding);\nint RSA_meth_set_pub_dec(RSA_METHOD *rsa,\n                         int (*pub_dec) (int flen, const unsigned char *from,\n                                         unsigned char *to, RSA *rsa,\n                                         int padding));\nint (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))\n    (int flen, const unsigned char *from,\n     unsigned char *to, RSA *rsa, int padding);\nint RSA_meth_set_priv_enc(RSA_METHOD *rsa,\n                          int (*priv_enc) (int flen, const unsigned char *from,\n                                           unsigned char *to, RSA *rsa,\n                                           int padding));\nint (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))\n    (int flen, const unsigned char *from,\n     unsigned char *to, RSA *rsa, int padding);\nint RSA_meth_set_priv_dec(RSA_METHOD *rsa,\n                          int (*priv_dec) (int flen, const unsigned char *from,\n                                           unsigned char *to, RSA *rsa,\n                                           int padding));\nint (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))\n    (BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx);\nint RSA_meth_set_mod_exp(RSA_METHOD *rsa,\n                         int (*mod_exp) (BIGNUM *r0, const BIGNUM *i, RSA *rsa,\n                                         BN_CTX *ctx));\nint (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))\n    (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n     const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);\nint RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,\n                            int (*bn_mod_exp) (BIGNUM *r,\n                                               const BIGNUM *a,\n                                               const BIGNUM *p,\n                                               const BIGNUM *m,\n                                               BN_CTX *ctx,\n                                               BN_MONT_CTX *m_ctx));\nint (*RSA_meth_get_init(const RSA_METHOD *meth)) (RSA *rsa);\nint RSA_meth_set_init(RSA_METHOD *rsa, int (*init) (RSA *rsa));\nint (*RSA_meth_get_finish(const RSA_METHOD *meth)) (RSA *rsa);\nint RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish) (RSA *rsa));\nint (*RSA_meth_get_sign(const RSA_METHOD *meth))\n    (int type,\n     const unsigned char *m, unsigned int m_length,\n     unsigned char *sigret, unsigned int *siglen,\n     const RSA *rsa);\nint RSA_meth_set_sign(RSA_METHOD *rsa,\n                      int (*sign) (int type, const unsigned char *m,\n                                   unsigned int m_length,\n                                   unsigned char *sigret, unsigned int *siglen,\n                                   const RSA *rsa));\nint (*RSA_meth_get_verify(const RSA_METHOD *meth))\n    (int dtype, const unsigned char *m,\n     unsigned int m_length, const unsigned char *sigbuf,\n     unsigned int siglen, const RSA *rsa);\nint RSA_meth_set_verify(RSA_METHOD *rsa,\n                        int (*verify) (int dtype, const unsigned char *m,\n                                       unsigned int m_length,\n                                       const unsigned char *sigbuf,\n                                       unsigned int siglen, const RSA *rsa));\nint (*RSA_meth_get_keygen(const RSA_METHOD *meth))\n    (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);\nint RSA_meth_set_keygen(RSA_METHOD *rsa,\n                        int (*keygen) (RSA *rsa, int bits, BIGNUM *e,\n                                       BN_GENCB *cb));\nint (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))\n    (RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb);\nint RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,\n                                    int (*keygen) (RSA *rsa, int bits,\n                                                   int primes, BIGNUM *e,\n                                                   BN_GENCB *cb));\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/rsaerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_RSAERR_H\n# define HEADER_RSAERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_RSA_strings(void);\n\n/*\n * RSA function codes.\n */\n# define RSA_F_CHECK_PADDING_MD                           140\n# define RSA_F_ENCODE_PKCS1                               146\n# define RSA_F_INT_RSA_VERIFY                             145\n# define RSA_F_OLD_RSA_PRIV_DECODE                        147\n# define RSA_F_PKEY_PSS_INIT                              165\n# define RSA_F_PKEY_RSA_CTRL                              143\n# define RSA_F_PKEY_RSA_CTRL_STR                          144\n# define RSA_F_PKEY_RSA_SIGN                              142\n# define RSA_F_PKEY_RSA_VERIFY                            149\n# define RSA_F_PKEY_RSA_VERIFYRECOVER                     141\n# define RSA_F_RSA_ALGOR_TO_MD                            156\n# define RSA_F_RSA_BUILTIN_KEYGEN                         129\n# define RSA_F_RSA_CHECK_KEY                              123\n# define RSA_F_RSA_CHECK_KEY_EX                           160\n# define RSA_F_RSA_CMS_DECRYPT                            159\n# define RSA_F_RSA_CMS_VERIFY                             158\n# define RSA_F_RSA_ITEM_VERIFY                            148\n# define RSA_F_RSA_METH_DUP                               161\n# define RSA_F_RSA_METH_NEW                               162\n# define RSA_F_RSA_METH_SET1_NAME                         163\n# define RSA_F_RSA_MGF1_TO_MD                             157\n# define RSA_F_RSA_MULTIP_INFO_NEW                        166\n# define RSA_F_RSA_NEW_METHOD                             106\n# define RSA_F_RSA_NULL                                   124\n# define RSA_F_RSA_NULL_PRIVATE_DECRYPT                   132\n# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT                   133\n# define RSA_F_RSA_NULL_PUBLIC_DECRYPT                    134\n# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT                    135\n# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT                   101\n# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT                   102\n# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT                    103\n# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT                    104\n# define RSA_F_RSA_PADDING_ADD_NONE                       107\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP                 121\n# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1            154\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS                  125\n# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1             152\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1               108\n# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2               109\n# define RSA_F_RSA_PADDING_ADD_SSLV23                     110\n# define RSA_F_RSA_PADDING_ADD_X931                       127\n# define RSA_F_RSA_PADDING_CHECK_NONE                     111\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP               122\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1          153\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1             112\n# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2             113\n# define RSA_F_RSA_PADDING_CHECK_SSLV23                   114\n# define RSA_F_RSA_PADDING_CHECK_X931                     128\n# define RSA_F_RSA_PARAM_DECODE                           164\n# define RSA_F_RSA_PRINT                                  115\n# define RSA_F_RSA_PRINT_FP                               116\n# define RSA_F_RSA_PRIV_DECODE                            150\n# define RSA_F_RSA_PRIV_ENCODE                            138\n# define RSA_F_RSA_PSS_GET_PARAM                          151\n# define RSA_F_RSA_PSS_TO_CTX                             155\n# define RSA_F_RSA_PUB_DECODE                             139\n# define RSA_F_RSA_SETUP_BLINDING                         136\n# define RSA_F_RSA_SIGN                                   117\n# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING                 118\n# define RSA_F_RSA_VERIFY                                 119\n# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING               120\n# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1                  126\n# define RSA_F_SETUP_TBUF                                 167\n\n/*\n * RSA reason codes.\n */\n# define RSA_R_ALGORITHM_MISMATCH                         100\n# define RSA_R_BAD_E_VALUE                                101\n# define RSA_R_BAD_FIXED_HEADER_DECRYPT                   102\n# define RSA_R_BAD_PAD_BYTE_COUNT                         103\n# define RSA_R_BAD_SIGNATURE                              104\n# define RSA_R_BLOCK_TYPE_IS_NOT_01                       106\n# define RSA_R_BLOCK_TYPE_IS_NOT_02                       107\n# define RSA_R_DATA_GREATER_THAN_MOD_LEN                  108\n# define RSA_R_DATA_TOO_LARGE                             109\n# define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE                110\n# define RSA_R_DATA_TOO_LARGE_FOR_MODULUS                 132\n# define RSA_R_DATA_TOO_SMALL                             111\n# define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE                122\n# define RSA_R_DIGEST_DOES_NOT_MATCH                      158\n# define RSA_R_DIGEST_NOT_ALLOWED                         145\n# define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY                 112\n# define RSA_R_DMP1_NOT_CONGRUENT_TO_D                    124\n# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D                    125\n# define RSA_R_D_E_NOT_CONGRUENT_TO_1                     123\n# define RSA_R_FIRST_OCTET_INVALID                        133\n# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE        144\n# define RSA_R_INVALID_DIGEST                             157\n# define RSA_R_INVALID_DIGEST_LENGTH                      143\n# define RSA_R_INVALID_HEADER                             137\n# define RSA_R_INVALID_LABEL                              160\n# define RSA_R_INVALID_MESSAGE_LENGTH                     131\n# define RSA_R_INVALID_MGF1_MD                            156\n# define RSA_R_INVALID_MULTI_PRIME_KEY                    167\n# define RSA_R_INVALID_OAEP_PARAMETERS                    161\n# define RSA_R_INVALID_PADDING                            138\n# define RSA_R_INVALID_PADDING_MODE                       141\n# define RSA_R_INVALID_PSS_PARAMETERS                     149\n# define RSA_R_INVALID_PSS_SALTLEN                        146\n# define RSA_R_INVALID_SALT_LENGTH                        150\n# define RSA_R_INVALID_TRAILER                            139\n# define RSA_R_INVALID_X931_DIGEST                        142\n# define RSA_R_IQMP_NOT_INVERSE_OF_Q                      126\n# define RSA_R_KEY_PRIME_NUM_INVALID                      165\n# define RSA_R_KEY_SIZE_TOO_SMALL                         120\n# define RSA_R_LAST_OCTET_INVALID                         134\n# define RSA_R_MISSING_PRIVATE_KEY                        179\n# define RSA_R_MGF1_DIGEST_NOT_ALLOWED                    152\n# define RSA_R_MODULUS_TOO_LARGE                          105\n# define RSA_R_MP_COEFFICIENT_NOT_INVERSE_OF_R            168\n# define RSA_R_MP_EXPONENT_NOT_CONGRUENT_TO_D             169\n# define RSA_R_MP_R_NOT_PRIME                             170\n# define RSA_R_NO_PUBLIC_EXPONENT                         140\n# define RSA_R_NULL_BEFORE_BLOCK_MISSING                  113\n# define RSA_R_N_DOES_NOT_EQUAL_PRODUCT_OF_PRIMES         172\n# define RSA_R_N_DOES_NOT_EQUAL_P_Q                       127\n# define RSA_R_OAEP_DECODING_ERROR                        121\n# define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE   148\n# define RSA_R_PADDING_CHECK_FAILED                       114\n# define RSA_R_PKCS_DECODING_ERROR                        159\n# define RSA_R_PSS_SALTLEN_TOO_SMALL                      164\n# define RSA_R_P_NOT_PRIME                                128\n# define RSA_R_Q_NOT_PRIME                                129\n# define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED               130\n# define RSA_R_SLEN_CHECK_FAILED                          136\n# define RSA_R_SLEN_RECOVERY_FAILED                       135\n# define RSA_R_SSLV3_ROLLBACK_ATTACK                      115\n# define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116\n# define RSA_R_UNKNOWN_ALGORITHM_TYPE                     117\n# define RSA_R_UNKNOWN_DIGEST                             166\n# define RSA_R_UNKNOWN_MASK_DIGEST                        151\n# define RSA_R_UNKNOWN_PADDING_TYPE                       118\n# define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE                162\n# define RSA_R_UNSUPPORTED_LABEL_SOURCE                   163\n# define RSA_R_UNSUPPORTED_MASK_ALGORITHM                 153\n# define RSA_R_UNSUPPORTED_MASK_PARAMETER                 154\n# define RSA_R_UNSUPPORTED_SIGNATURE_TYPE                 155\n# define RSA_R_VALUE_MISSING                              147\n# define RSA_R_WRONG_SIGNATURE_LENGTH                     119\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/safestack.h",
    "content": "/*\n * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SAFESTACK_H\n# define HEADER_SAFESTACK_H\n\n# include <openssl/stack.h>\n# include <openssl/e_os2.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n# define STACK_OF(type) struct stack_st_##type\n\n# define SKM_DEFINE_STACK_OF(t1, t2, t3) \\\n    STACK_OF(t1); \\\n    typedef int (*sk_##t1##_compfunc)(const t3 * const *a, const t3 *const *b); \\\n    typedef void (*sk_##t1##_freefunc)(t3 *a); \\\n    typedef t3 * (*sk_##t1##_copyfunc)(const t3 *a); \\\n    static ossl_unused ossl_inline int sk_##t1##_num(const STACK_OF(t1) *sk) \\\n    { \\\n        return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_value(const STACK_OF(t1) *sk, int idx) \\\n    { \\\n        return (t2 *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new(sk_##t1##_compfunc compare) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_new((OPENSSL_sk_compfunc)compare); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new_null(void) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new_reserve(sk_##t1##_compfunc compare, int n) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_new_reserve((OPENSSL_sk_compfunc)compare, n); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_reserve(STACK_OF(t1) *sk, int n) \\\n    { \\\n        return OPENSSL_sk_reserve((OPENSSL_STACK *)sk, n); \\\n    } \\\n    static ossl_unused ossl_inline void sk_##t1##_free(STACK_OF(t1) *sk) \\\n    { \\\n        OPENSSL_sk_free((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline void sk_##t1##_zero(STACK_OF(t1) *sk) \\\n    { \\\n        OPENSSL_sk_zero((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_delete(STACK_OF(t1) *sk, int i) \\\n    { \\\n        return (t2 *)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \\\n                                           (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_push(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_unshift(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) *sk) \\\n    { \\\n        return (t2 *)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_shift(STACK_OF(t1) *sk) \\\n    { \\\n        return (t2 *)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline void sk_##t1##_pop_free(STACK_OF(t1) *sk, sk_##t1##_freefunc freefunc) \\\n    { \\\n        OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_insert(STACK_OF(t1) *sk, t2 *ptr, int idx) \\\n    { \\\n        return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \\\n    } \\\n    static ossl_unused ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) *sk, int idx, t2 *ptr) \\\n    { \\\n        return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_find(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) *sk, t2 *ptr) \\\n    { \\\n        return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \\\n    } \\\n    static ossl_unused ossl_inline void sk_##t1##_sort(STACK_OF(t1) *sk) \\\n    { \\\n        OPENSSL_sk_sort((OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline int sk_##t1##_is_sorted(const STACK_OF(t1) *sk) \\\n    { \\\n        return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) * sk_##t1##_dup(const STACK_OF(t1) *sk) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \\\n    } \\\n    static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_deep_copy(const STACK_OF(t1) *sk, \\\n                                                    sk_##t1##_copyfunc copyfunc, \\\n                                                    sk_##t1##_freefunc freefunc) \\\n    { \\\n        return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((const OPENSSL_STACK *)sk, \\\n                                            (OPENSSL_sk_copyfunc)copyfunc, \\\n                                            (OPENSSL_sk_freefunc)freefunc); \\\n    } \\\n    static ossl_unused ossl_inline sk_##t1##_compfunc sk_##t1##_set_cmp_func(STACK_OF(t1) *sk, sk_##t1##_compfunc compare) \\\n    { \\\n        return (sk_##t1##_compfunc)OPENSSL_sk_set_cmp_func((OPENSSL_STACK *)sk, (OPENSSL_sk_compfunc)compare); \\\n    }\n\n# define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2)\n# define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t)\n# define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) \\\n            SKM_DEFINE_STACK_OF(t1, const t2, t2)\n# define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t)\n\n/*-\n * Strings are special: normally an lhash entry will point to a single\n * (somewhat) mutable object. In the case of strings:\n *\n * a) Instead of a single char, there is an array of chars, NUL-terminated.\n * b) The string may have be immutable.\n *\n * So, they need their own declarations. Especially important for\n * type-checking tools, such as Deputy.\n *\n * In practice, however, it appears to be hard to have a const\n * string. For now, I'm settling for dealing with the fact it is a\n * string at all.\n */\ntypedef char *OPENSSL_STRING;\ntypedef const char *OPENSSL_CSTRING;\n\n/*-\n * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but\n * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned\n * above, instead of a single char each entry is a NUL-terminated array of\n * chars. So, we have to implement STRING specially for STACK_OF. This is\n * dealt with in the autogenerated macros below.\n */\nDEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)\nDEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)\n\n/*\n * Similarly, we sometimes use a block of characters, NOT nul-terminated.\n * These should also be distinguished from \"normal\" stacks.\n */\ntypedef void *OPENSSL_BLOCK;\nDEFINE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void)\n\n/*\n * If called without higher optimization (min. -xO3) the Oracle Developer\n * Studio compiler generates code for the defined (static inline) functions\n * above.\n * This would later lead to the linker complaining about missing symbols when\n * this header file is included but the resulting object is not linked against\n * the Crypto library (openssl#6912).\n */\n# ifdef __SUNPRO_C\n#  pragma weak OPENSSL_sk_num\n#  pragma weak OPENSSL_sk_value\n#  pragma weak OPENSSL_sk_new\n#  pragma weak OPENSSL_sk_new_null\n#  pragma weak OPENSSL_sk_new_reserve\n#  pragma weak OPENSSL_sk_reserve\n#  pragma weak OPENSSL_sk_free\n#  pragma weak OPENSSL_sk_zero\n#  pragma weak OPENSSL_sk_delete\n#  pragma weak OPENSSL_sk_delete_ptr\n#  pragma weak OPENSSL_sk_push\n#  pragma weak OPENSSL_sk_unshift\n#  pragma weak OPENSSL_sk_pop\n#  pragma weak OPENSSL_sk_shift\n#  pragma weak OPENSSL_sk_pop_free\n#  pragma weak OPENSSL_sk_insert\n#  pragma weak OPENSSL_sk_set\n#  pragma weak OPENSSL_sk_find\n#  pragma weak OPENSSL_sk_find_ex\n#  pragma weak OPENSSL_sk_sort\n#  pragma weak OPENSSL_sk_is_sorted\n#  pragma weak OPENSSL_sk_dup\n#  pragma weak OPENSSL_sk_deep_copy\n#  pragma weak OPENSSL_sk_set_cmp_func\n# endif /* __SUNPRO_C */\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/seed.h",
    "content": "/*\n * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Neither the name of author nor the names of its contributors may\n *    be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n */\n\n#ifndef HEADER_SEED_H\n# define HEADER_SEED_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_SEED\n# include <openssl/e_os2.h>\n# include <openssl/crypto.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* look whether we need 'long' to get 32 bits */\n# ifdef AES_LONG\n#  ifndef SEED_LONG\n#   define SEED_LONG 1\n#  endif\n# endif\n\n# include <sys/types.h>\n\n# define SEED_BLOCK_SIZE 16\n# define SEED_KEY_LENGTH 16\n\ntypedef struct seed_key_st {\n# ifdef SEED_LONG\n    unsigned long data[32];\n# else\n    unsigned int data[32];\n# endif\n} SEED_KEY_SCHEDULE;\n\nvoid SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH],\n                  SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\nvoid SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE],\n                  unsigned char d[SEED_BLOCK_SIZE],\n                  const SEED_KEY_SCHEDULE *ks);\n\nvoid SEED_ecb_encrypt(const unsigned char *in, unsigned char *out,\n                      const SEED_KEY_SCHEDULE *ks, int enc);\nvoid SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len,\n                      const SEED_KEY_SCHEDULE *ks,\n                      unsigned char ivec[SEED_BLOCK_SIZE], int enc);\nvoid SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num,\n                         int enc);\nvoid SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,\n                         size_t len, const SEED_KEY_SCHEDULE *ks,\n                         unsigned char ivec[SEED_BLOCK_SIZE], int *num);\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/sha.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SHA_H\n# define HEADER_SHA_H\n\n# include <openssl/e_os2.h>\n# include <stddef.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n * ! SHA_LONG has to be at least 32 bits wide.                    !\n * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n */\n# define SHA_LONG unsigned int\n\n# define SHA_LBLOCK      16\n# define SHA_CBLOCK      (SHA_LBLOCK*4)/* SHA treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n# define SHA_LAST_BLOCK  (SHA_CBLOCK-8)\n# define SHA_DIGEST_LENGTH 20\n\ntypedef struct SHAstate_st {\n    SHA_LONG h0, h1, h2, h3, h4;\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num;\n} SHA_CTX;\n\nint SHA1_Init(SHA_CTX *c);\nint SHA1_Update(SHA_CTX *c, const void *data, size_t len);\nint SHA1_Final(unsigned char *md, SHA_CTX *c);\nunsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA1_Transform(SHA_CTX *c, const unsigned char *data);\n\n# define SHA256_CBLOCK   (SHA_LBLOCK*4)/* SHA-256 treats input data as a\n                                        * contiguous array of 32 bit wide\n                                        * big-endian values. */\n\ntypedef struct SHA256state_st {\n    SHA_LONG h[8];\n    SHA_LONG Nl, Nh;\n    SHA_LONG data[SHA_LBLOCK];\n    unsigned int num, md_len;\n} SHA256_CTX;\n\nint SHA224_Init(SHA256_CTX *c);\nint SHA224_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA224_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md);\nint SHA256_Init(SHA256_CTX *c);\nint SHA256_Update(SHA256_CTX *c, const void *data, size_t len);\nint SHA256_Final(unsigned char *md, SHA256_CTX *c);\nunsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA256_Transform(SHA256_CTX *c, const unsigned char *data);\n\n# define SHA224_DIGEST_LENGTH    28\n# define SHA256_DIGEST_LENGTH    32\n# define SHA384_DIGEST_LENGTH    48\n# define SHA512_DIGEST_LENGTH    64\n\n/*\n * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64\n * being exactly 64-bit wide. See Implementation Notes in sha512.c\n * for further details.\n */\n/*\n * SHA-512 treats input data as a\n * contiguous array of 64 bit\n * wide big-endian values.\n */\n# define SHA512_CBLOCK   (SHA_LBLOCK*8)\n# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)\n#  define SHA_LONG64 unsigned __int64\n#  define U64(C)     C##UI64\n# elif defined(__arch64__)\n#  define SHA_LONG64 unsigned long\n#  define U64(C)     C##UL\n# else\n#  define SHA_LONG64 unsigned long long\n#  define U64(C)     C##ULL\n# endif\n\ntypedef struct SHA512state_st {\n    SHA_LONG64 h[8];\n    SHA_LONG64 Nl, Nh;\n    union {\n        SHA_LONG64 d[SHA_LBLOCK];\n        unsigned char p[SHA512_CBLOCK];\n    } u;\n    unsigned int num, md_len;\n} SHA512_CTX;\n\nint SHA384_Init(SHA512_CTX *c);\nint SHA384_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA384_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md);\nint SHA512_Init(SHA512_CTX *c);\nint SHA512_Update(SHA512_CTX *c, const void *data, size_t len);\nint SHA512_Final(unsigned char *md, SHA512_CTX *c);\nunsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md);\nvoid SHA512_Transform(SHA512_CTX *c, const unsigned char *data);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/srp.h",
    "content": "/*\n * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2004, EdelKey Project. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n *\n * Originally written by Christophe Renou and Peter Sylvester,\n * for the EdelKey project.\n */\n\n#ifndef HEADER_SRP_H\n# define HEADER_SRP_H\n\n#include <openssl/opensslconf.h>\n\n#ifndef OPENSSL_NO_SRP\n# include <stdio.h>\n# include <string.h>\n# include <openssl/safestack.h>\n# include <openssl/bn.h>\n# include <openssl/crypto.h>\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\ntypedef struct SRP_gN_cache_st {\n    char *b64_bn;\n    BIGNUM *bn;\n} SRP_gN_cache;\n\n\nDEFINE_STACK_OF(SRP_gN_cache)\n\ntypedef struct SRP_user_pwd_st {\n    /* Owned by us. */\n    char *id;\n    BIGNUM *s;\n    BIGNUM *v;\n    /* Not owned by us. */\n    const BIGNUM *g;\n    const BIGNUM *N;\n    /* Owned by us. */\n    char *info;\n} SRP_user_pwd;\n\nvoid SRP_user_pwd_free(SRP_user_pwd *user_pwd);\n\nDEFINE_STACK_OF(SRP_user_pwd)\n\ntypedef struct SRP_VBASE_st {\n    STACK_OF(SRP_user_pwd) *users_pwd;\n    STACK_OF(SRP_gN_cache) *gN_cache;\n/* to simulate a user */\n    char *seed_key;\n    const BIGNUM *default_g;\n    const BIGNUM *default_N;\n} SRP_VBASE;\n\n/*\n * Internal structure storing N and g pair\n */\ntypedef struct SRP_gN_st {\n    char *id;\n    const BIGNUM *g;\n    const BIGNUM *N;\n} SRP_gN;\n\nDEFINE_STACK_OF(SRP_gN)\n\nSRP_VBASE *SRP_VBASE_new(char *seed_key);\nvoid SRP_VBASE_free(SRP_VBASE *vb);\nint SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file);\n\n/* This method ignores the configured seed and fails for an unknown user. */\nDEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username))\n/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/\nSRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username);\n\nchar *SRP_create_verifier(const char *user, const char *pass, char **salt,\n                          char **verifier, const char *N, const char *g);\nint SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt,\n                           BIGNUM **verifier, const BIGNUM *N,\n                           const BIGNUM *g);\n\n# define SRP_NO_ERROR 0\n# define SRP_ERR_VBASE_INCOMPLETE_FILE 1\n# define SRP_ERR_VBASE_BN_LIB 2\n# define SRP_ERR_OPEN_FILE 3\n# define SRP_ERR_MEMORY 4\n\n# define DB_srptype      0\n# define DB_srpverifier  1\n# define DB_srpsalt      2\n# define DB_srpid        3\n# define DB_srpgN        4\n# define DB_srpinfo      5\n# undef  DB_NUMBER\n# define DB_NUMBER       6\n\n# define DB_SRP_INDEX    'I'\n# define DB_SRP_VALID    'V'\n# define DB_SRP_REVOKED  'R'\n# define DB_SRP_MODIF    'v'\n\n/* see srp.c */\nchar *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N);\nSRP_gN *SRP_get_default_gN(const char *id);\n\n/* server side .... */\nBIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u,\n                            const BIGNUM *b, const BIGNUM *N);\nBIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g,\n                   const BIGNUM *v);\nint SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N);\nBIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N);\n\n/* client side .... */\nBIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass);\nBIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g);\nBIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g,\n                            const BIGNUM *x, const BIGNUM *a, const BIGNUM *u);\nint SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N);\n\n# define SRP_MINIMAL_N 1024\n\n# ifdef  __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/srtp.h",
    "content": "/*\n * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * DTLS code by Eric Rescorla <ekr@rtfm.com>\n *\n * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc.\n */\n\n#ifndef HEADER_D1_SRTP_H\n# define HEADER_D1_SRTP_H\n\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define SRTP_AES128_CM_SHA1_80 0x0001\n# define SRTP_AES128_CM_SHA1_32 0x0002\n# define SRTP_AES128_F8_SHA1_80 0x0003\n# define SRTP_AES128_F8_SHA1_32 0x0004\n# define SRTP_NULL_SHA1_80      0x0005\n# define SRTP_NULL_SHA1_32      0x0006\n\n/* AEAD SRTP protection profiles from RFC 7714 */\n# define SRTP_AEAD_AES_128_GCM  0x0007\n# define SRTP_AEAD_AES_256_GCM  0x0008\n\n# ifndef OPENSSL_NO_SRTP\n\n__owur int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);\n__owur int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles);\n\n__owur STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);\n__owur SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);\n\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ssl.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n * Copyright 2005 Nokia. All rights reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SSL_H\n# define HEADER_SSL_H\n\n# include <openssl/e_os2.h>\n# include <openssl/opensslconf.h>\n# include <openssl/comp.h>\n# include <openssl/bio.h>\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/x509.h>\n#  include <openssl/crypto.h>\n#  include <openssl/buffer.h>\n# endif\n# include <openssl/lhash.h>\n# include <openssl/pem.h>\n# include <openssl/hmac.h>\n# include <openssl/async.h>\n\n# include <openssl/safestack.h>\n# include <openssl/symhacks.h>\n# include <openssl/ct.h>\n# include <openssl/sslerr.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* OpenSSL version number for ASN.1 encoding of the session information */\n/*-\n * Version 0 - initial version\n * Version 1 - added the optional peer certificate\n */\n# define SSL_SESSION_ASN1_VERSION 0x0001\n\n# define SSL_MAX_SSL_SESSION_ID_LENGTH           32\n# define SSL_MAX_SID_CTX_LENGTH                  32\n\n# define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES     (512/8)\n# define SSL_MAX_KEY_ARG_LENGTH                  8\n# define SSL_MAX_MASTER_KEY_LENGTH               48\n\n/* The maximum number of encrypt/decrypt pipelines we can support */\n# define SSL_MAX_PIPELINES  32\n\n/* text strings for the ciphers */\n\n/* These are used to specify which ciphers to use and not to use */\n\n# define SSL_TXT_LOW             \"LOW\"\n# define SSL_TXT_MEDIUM          \"MEDIUM\"\n# define SSL_TXT_HIGH            \"HIGH\"\n# define SSL_TXT_FIPS            \"FIPS\"\n\n# define SSL_TXT_aNULL           \"aNULL\"\n# define SSL_TXT_eNULL           \"eNULL\"\n# define SSL_TXT_NULL            \"NULL\"\n\n# define SSL_TXT_kRSA            \"kRSA\"\n# define SSL_TXT_kDHr            \"kDHr\"/* this cipher class has been removed */\n# define SSL_TXT_kDHd            \"kDHd\"/* this cipher class has been removed */\n# define SSL_TXT_kDH             \"kDH\"/* this cipher class has been removed */\n# define SSL_TXT_kEDH            \"kEDH\"/* alias for kDHE */\n# define SSL_TXT_kDHE            \"kDHE\"\n# define SSL_TXT_kECDHr          \"kECDHr\"/* this cipher class has been removed */\n# define SSL_TXT_kECDHe          \"kECDHe\"/* this cipher class has been removed */\n# define SSL_TXT_kECDH           \"kECDH\"/* this cipher class has been removed */\n# define SSL_TXT_kEECDH          \"kEECDH\"/* alias for kECDHE */\n# define SSL_TXT_kECDHE          \"kECDHE\"\n# define SSL_TXT_kPSK            \"kPSK\"\n# define SSL_TXT_kRSAPSK         \"kRSAPSK\"\n# define SSL_TXT_kECDHEPSK       \"kECDHEPSK\"\n# define SSL_TXT_kDHEPSK         \"kDHEPSK\"\n# define SSL_TXT_kGOST           \"kGOST\"\n# define SSL_TXT_kSRP            \"kSRP\"\n\n# define SSL_TXT_aRSA            \"aRSA\"\n# define SSL_TXT_aDSS            \"aDSS\"\n# define SSL_TXT_aDH             \"aDH\"/* this cipher class has been removed */\n# define SSL_TXT_aECDH           \"aECDH\"/* this cipher class has been removed */\n# define SSL_TXT_aECDSA          \"aECDSA\"\n# define SSL_TXT_aPSK            \"aPSK\"\n# define SSL_TXT_aGOST94         \"aGOST94\"\n# define SSL_TXT_aGOST01         \"aGOST01\"\n# define SSL_TXT_aGOST12         \"aGOST12\"\n# define SSL_TXT_aGOST           \"aGOST\"\n# define SSL_TXT_aSRP            \"aSRP\"\n\n# define SSL_TXT_DSS             \"DSS\"\n# define SSL_TXT_DH              \"DH\"\n# define SSL_TXT_DHE             \"DHE\"/* same as \"kDHE:-ADH\" */\n# define SSL_TXT_EDH             \"EDH\"/* alias for DHE */\n# define SSL_TXT_ADH             \"ADH\"\n# define SSL_TXT_RSA             \"RSA\"\n# define SSL_TXT_ECDH            \"ECDH\"\n# define SSL_TXT_EECDH           \"EECDH\"/* alias for ECDHE\" */\n# define SSL_TXT_ECDHE           \"ECDHE\"/* same as \"kECDHE:-AECDH\" */\n# define SSL_TXT_AECDH           \"AECDH\"\n# define SSL_TXT_ECDSA           \"ECDSA\"\n# define SSL_TXT_PSK             \"PSK\"\n# define SSL_TXT_SRP             \"SRP\"\n\n# define SSL_TXT_DES             \"DES\"\n# define SSL_TXT_3DES            \"3DES\"\n# define SSL_TXT_RC4             \"RC4\"\n# define SSL_TXT_RC2             \"RC2\"\n# define SSL_TXT_IDEA            \"IDEA\"\n# define SSL_TXT_SEED            \"SEED\"\n# define SSL_TXT_AES128          \"AES128\"\n# define SSL_TXT_AES256          \"AES256\"\n# define SSL_TXT_AES             \"AES\"\n# define SSL_TXT_AES_GCM         \"AESGCM\"\n# define SSL_TXT_AES_CCM         \"AESCCM\"\n# define SSL_TXT_AES_CCM_8       \"AESCCM8\"\n# define SSL_TXT_CAMELLIA128     \"CAMELLIA128\"\n# define SSL_TXT_CAMELLIA256     \"CAMELLIA256\"\n# define SSL_TXT_CAMELLIA        \"CAMELLIA\"\n# define SSL_TXT_CHACHA20        \"CHACHA20\"\n# define SSL_TXT_GOST            \"GOST89\"\n# define SSL_TXT_ARIA            \"ARIA\"\n# define SSL_TXT_ARIA_GCM        \"ARIAGCM\"\n# define SSL_TXT_ARIA128         \"ARIA128\"\n# define SSL_TXT_ARIA256         \"ARIA256\"\n\n# define SSL_TXT_MD5             \"MD5\"\n# define SSL_TXT_SHA1            \"SHA1\"\n# define SSL_TXT_SHA             \"SHA\"/* same as \"SHA1\" */\n# define SSL_TXT_GOST94          \"GOST94\"\n# define SSL_TXT_GOST89MAC       \"GOST89MAC\"\n# define SSL_TXT_GOST12          \"GOST12\"\n# define SSL_TXT_GOST89MAC12     \"GOST89MAC12\"\n# define SSL_TXT_SHA256          \"SHA256\"\n# define SSL_TXT_SHA384          \"SHA384\"\n\n# define SSL_TXT_SSLV3           \"SSLv3\"\n# define SSL_TXT_TLSV1           \"TLSv1\"\n# define SSL_TXT_TLSV1_1         \"TLSv1.1\"\n# define SSL_TXT_TLSV1_2         \"TLSv1.2\"\n\n# define SSL_TXT_ALL             \"ALL\"\n\n/*-\n * COMPLEMENTOF* definitions. These identifiers are used to (de-select)\n * ciphers normally not being used.\n * Example: \"RC4\" will activate all ciphers using RC4 including ciphers\n * without authentication, which would normally disabled by DEFAULT (due\n * the \"!ADH\" being part of default). Therefore \"RC4:!COMPLEMENTOFDEFAULT\"\n * will make sure that it is also disabled in the specific selection.\n * COMPLEMENTOF* identifiers are portable between version, as adjustments\n * to the default cipher setup will also be included here.\n *\n * COMPLEMENTOFDEFAULT does not experience the same special treatment that\n * DEFAULT gets, as only selection is being done and no sorting as needed\n * for DEFAULT.\n */\n# define SSL_TXT_CMPALL          \"COMPLEMENTOFALL\"\n# define SSL_TXT_CMPDEF          \"COMPLEMENTOFDEFAULT\"\n\n/*\n * The following cipher list is used by default. It also is substituted when\n * an application-defined cipher list string starts with 'DEFAULT'.\n * This applies to ciphersuites for TLSv1.2 and below.\n */\n# define SSL_DEFAULT_CIPHER_LIST \"ALL:!COMPLEMENTOFDEFAULT:!eNULL\"\n/* This is the default set of TLSv1.3 ciphersuites */\n# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)\n#  define TLS_DEFAULT_CIPHERSUITES \"TLS_AES_256_GCM_SHA384:\" \\\n                                   \"TLS_CHACHA20_POLY1305_SHA256:\" \\\n                                   \"TLS_AES_128_GCM_SHA256\"\n# else\n#  define TLS_DEFAULT_CIPHERSUITES \"TLS_AES_256_GCM_SHA384:\" \\\n                                   \"TLS_AES_128_GCM_SHA256\"\n#endif\n/*\n * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always\n * starts with a reasonable order, and all we have to do for DEFAULT is\n * throwing out anonymous and unencrypted ciphersuites! (The latter are not\n * actually enabled by ALL, but \"ALL:RSA\" would enable some of them.)\n */\n\n/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */\n# define SSL_SENT_SHUTDOWN       1\n# define SSL_RECEIVED_SHUTDOWN   2\n\n#ifdef __cplusplus\n}\n#endif\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define SSL_FILETYPE_ASN1       X509_FILETYPE_ASN1\n# define SSL_FILETYPE_PEM        X509_FILETYPE_PEM\n\n/*\n * This is needed to stop compilers complaining about the 'struct ssl_st *'\n * function parameters used to prototype callbacks in SSL_CTX.\n */\ntypedef struct ssl_st *ssl_crock_st;\ntypedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;\ntypedef struct ssl_method_st SSL_METHOD;\ntypedef struct ssl_cipher_st SSL_CIPHER;\ntypedef struct ssl_session_st SSL_SESSION;\ntypedef struct tls_sigalgs_st TLS_SIGALGS;\ntypedef struct ssl_conf_ctx_st SSL_CONF_CTX;\ntypedef struct ssl_comp_st SSL_COMP;\n\nSTACK_OF(SSL_CIPHER);\nSTACK_OF(SSL_COMP);\n\n/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/\ntypedef struct srtp_protection_profile_st {\n    const char *name;\n    unsigned long id;\n} SRTP_PROTECTION_PROFILE;\n\nDEFINE_STACK_OF(SRTP_PROTECTION_PROFILE)\n\ntypedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data,\n                                            int len, void *arg);\ntypedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len,\n                                        STACK_OF(SSL_CIPHER) *peer_ciphers,\n                                        const SSL_CIPHER **cipher, void *arg);\n\n/* Extension context codes */\n/* This extension is only allowed in TLS */\n#define SSL_EXT_TLS_ONLY                        0x0001\n/* This extension is only allowed in DTLS */\n#define SSL_EXT_DTLS_ONLY                       0x0002\n/* Some extensions may be allowed in DTLS but we don't implement them for it */\n#define SSL_EXT_TLS_IMPLEMENTATION_ONLY         0x0004\n/* Most extensions are not defined for SSLv3 but EXT_TYPE_renegotiate is */\n#define SSL_EXT_SSL3_ALLOWED                    0x0008\n/* Extension is only defined for TLS1.2 and below */\n#define SSL_EXT_TLS1_2_AND_BELOW_ONLY           0x0010\n/* Extension is only defined for TLS1.3 and above */\n#define SSL_EXT_TLS1_3_ONLY                     0x0020\n/* Ignore this extension during parsing if we are resuming */\n#define SSL_EXT_IGNORE_ON_RESUMPTION            0x0040\n#define SSL_EXT_CLIENT_HELLO                    0x0080\n/* Really means TLS1.2 or below */\n#define SSL_EXT_TLS1_2_SERVER_HELLO             0x0100\n#define SSL_EXT_TLS1_3_SERVER_HELLO             0x0200\n#define SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS     0x0400\n#define SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST      0x0800\n#define SSL_EXT_TLS1_3_CERTIFICATE              0x1000\n#define SSL_EXT_TLS1_3_NEW_SESSION_TICKET       0x2000\n#define SSL_EXT_TLS1_3_CERTIFICATE_REQUEST      0x4000\n\n/* Typedefs for handling custom extensions */\n\ntypedef int (*custom_ext_add_cb)(SSL *s, unsigned int ext_type,\n                                 const unsigned char **out, size_t *outlen,\n                                 int *al, void *add_arg);\n\ntypedef void (*custom_ext_free_cb)(SSL *s, unsigned int ext_type,\n                                   const unsigned char *out, void *add_arg);\n\ntypedef int (*custom_ext_parse_cb)(SSL *s, unsigned int ext_type,\n                                   const unsigned char *in, size_t inlen,\n                                   int *al, void *parse_arg);\n\n\ntypedef int (*SSL_custom_ext_add_cb_ex)(SSL *s, unsigned int ext_type,\n                                        unsigned int context,\n                                        const unsigned char **out,\n                                        size_t *outlen, X509 *x,\n                                        size_t chainidx,\n                                        int *al, void *add_arg);\n\ntypedef void (*SSL_custom_ext_free_cb_ex)(SSL *s, unsigned int ext_type,\n                                          unsigned int context,\n                                          const unsigned char *out,\n                                          void *add_arg);\n\ntypedef int (*SSL_custom_ext_parse_cb_ex)(SSL *s, unsigned int ext_type,\n                                          unsigned int context,\n                                          const unsigned char *in,\n                                          size_t inlen, X509 *x,\n                                          size_t chainidx,\n                                          int *al, void *parse_arg);\n\n/* Typedef for verification callback */\ntypedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx);\n\n/*\n * Some values are reserved until OpenSSL 1.2.0 because they were previously\n * included in SSL_OP_ALL in a 1.1.x release.\n *\n * Reserved value (until OpenSSL 1.2.0)                  0x00000001U\n * Reserved value (until OpenSSL 1.2.0)                  0x00000002U\n */\n/* Allow initial connection to servers that don't support RI */\n# define SSL_OP_LEGACY_SERVER_CONNECT                    0x00000004U\n\n/* Reserved value (until OpenSSL 1.2.0)                  0x00000008U */\n# define SSL_OP_TLSEXT_PADDING                           0x00000010U\n/* Reserved value (until OpenSSL 1.2.0)                  0x00000020U */\n# define SSL_OP_SAFARI_ECDHE_ECDSA_BUG                   0x00000040U\n/*\n * Reserved value (until OpenSSL 1.2.0)                  0x00000080U\n * Reserved value (until OpenSSL 1.2.0)                  0x00000100U\n * Reserved value (until OpenSSL 1.2.0)                  0x00000200U\n */\n\n/* In TLSv1.3 allow a non-(ec)dhe based kex_mode */\n# define SSL_OP_ALLOW_NO_DHE_KEX                         0x00000400U\n\n/*\n * Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in\n * OpenSSL 0.9.6d.  Usually (depending on the application protocol) the\n * workaround is not needed.  Unfortunately some broken SSL/TLS\n * implementations cannot handle it at all, which is why we include it in\n * SSL_OP_ALL. Added in 0.9.6e\n */\n# define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS              0x00000800U\n\n/* DTLS options */\n# define SSL_OP_NO_QUERY_MTU                             0x00001000U\n/* Turn on Cookie Exchange (on relevant for servers) */\n# define SSL_OP_COOKIE_EXCHANGE                          0x00002000U\n/* Don't use RFC4507 ticket extension */\n# define SSL_OP_NO_TICKET                                0x00004000U\n# ifndef OPENSSL_NO_DTLS1_METHOD\n/* Use Cisco's \"speshul\" version of DTLS_BAD_VER\n * (only with deprecated DTLSv1_client_method())  */\n#  define SSL_OP_CISCO_ANYCONNECT                        0x00008000U\n# endif\n\n/* As server, disallow session resumption on renegotiation */\n# define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION   0x00010000U\n/* Don't use compression even if supported */\n# define SSL_OP_NO_COMPRESSION                           0x00020000U\n/* Permit unsafe legacy renegotiation */\n# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION        0x00040000U\n/* Disable encrypt-then-mac */\n# define SSL_OP_NO_ENCRYPT_THEN_MAC                      0x00080000U\n\n/*\n * Enable TLSv1.3 Compatibility mode. This is on by default. A future version\n * of OpenSSL may have this disabled by default.\n */\n# define SSL_OP_ENABLE_MIDDLEBOX_COMPAT                  0x00100000U\n\n/* Prioritize Chacha20Poly1305 when client does.\n * Modifies SSL_OP_CIPHER_SERVER_PREFERENCE */\n# define SSL_OP_PRIORITIZE_CHACHA                        0x00200000U\n\n/*\n * Set on servers to choose the cipher according to the server's preferences\n */\n# define SSL_OP_CIPHER_SERVER_PREFERENCE                 0x00400000U\n/*\n * If set, a server will allow a client to issue a SSLv3.0 version number as\n * latest version supported in the premaster secret, even when TLSv1.0\n * (version 3.1) was announced in the client hello. Normally this is\n * forbidden to prevent version rollback attacks.\n */\n# define SSL_OP_TLS_ROLLBACK_BUG                         0x00800000U\n\n/*\n * Switches off automatic TLSv1.3 anti-replay protection for early data. This\n * is a server-side option only (no effect on the client).\n */\n# define SSL_OP_NO_ANTI_REPLAY                           0x01000000U\n\n# define SSL_OP_NO_SSLv3                                 0x02000000U\n# define SSL_OP_NO_TLSv1                                 0x04000000U\n# define SSL_OP_NO_TLSv1_2                               0x08000000U\n# define SSL_OP_NO_TLSv1_1                               0x10000000U\n# define SSL_OP_NO_TLSv1_3                               0x20000000U\n\n# define SSL_OP_NO_DTLSv1                                0x04000000U\n# define SSL_OP_NO_DTLSv1_2                              0x08000000U\n\n# define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv3|\\\n        SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2|SSL_OP_NO_TLSv1_3)\n# define SSL_OP_NO_DTLS_MASK (SSL_OP_NO_DTLSv1|SSL_OP_NO_DTLSv1_2)\n\n/* Disallow all renegotiation */\n# define SSL_OP_NO_RENEGOTIATION                         0x40000000U\n\n/*\n * Make server add server-hello extension from early version of cryptopro\n * draft, when GOST ciphersuite is negotiated. Required for interoperability\n * with CryptoPro CSP 3.x\n */\n# define SSL_OP_CRYPTOPRO_TLSEXT_BUG                     0x80000000U\n\n/*\n * SSL_OP_ALL: various bug workarounds that should be rather harmless.\n * This used to be 0x000FFFFFL before 0.9.7.\n * This used to be 0x80000BFFU before 1.1.1.\n */\n# define SSL_OP_ALL        (SSL_OP_CRYPTOPRO_TLSEXT_BUG|\\\n                            SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS|\\\n                            SSL_OP_LEGACY_SERVER_CONNECT|\\\n                            SSL_OP_TLSEXT_PADDING|\\\n                            SSL_OP_SAFARI_ECDHE_ECDSA_BUG)\n\n/* OBSOLETE OPTIONS: retained for compatibility */\n\n/* Removed from OpenSSL 1.1.0. Was 0x00000001L */\n/* Related to removed SSLv2. */\n# define SSL_OP_MICROSOFT_SESS_ID_BUG                    0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000002L */\n/* Related to removed SSLv2. */\n# define SSL_OP_NETSCAPE_CHALLENGE_BUG                   0x0\n/* Removed from OpenSSL 0.9.8q and 1.0.0c. Was 0x00000008L */\n/* Dead forever, see CVE-2010-4180 */\n# define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG         0x0\n/* Removed from OpenSSL 1.0.1h and 1.0.2. Was 0x00000010L */\n/* Refers to ancient SSLREF and SSLv2. */\n# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG              0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000020 */\n# define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER               0x0\n/* Removed from OpenSSL 0.9.7h and 0.9.8b. Was 0x00000040L */\n# define SSL_OP_MSIE_SSLV2_RSA_PADDING                   0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000080 */\n/* Ancient SSLeay version. */\n# define SSL_OP_SSLEAY_080_CLIENT_DH_BUG                 0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000100L */\n# define SSL_OP_TLS_D5_BUG                               0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00000200L */\n# define SSL_OP_TLS_BLOCK_PADDING_BUG                    0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00080000L */\n# define SSL_OP_SINGLE_ECDH_USE                          0x0\n/* Removed from OpenSSL 1.1.0. Was 0x00100000L */\n# define SSL_OP_SINGLE_DH_USE                            0x0\n/* Removed from OpenSSL 1.0.1k and 1.0.2. Was 0x00200000L */\n# define SSL_OP_EPHEMERAL_RSA                            0x0\n/* Removed from OpenSSL 1.1.0. Was 0x01000000L */\n# define SSL_OP_NO_SSLv2                                 0x0\n/* Removed from OpenSSL 1.0.1. Was 0x08000000L */\n# define SSL_OP_PKCS1_CHECK_1                            0x0\n/* Removed from OpenSSL 1.0.1. Was 0x10000000L */\n# define SSL_OP_PKCS1_CHECK_2                            0x0\n/* Removed from OpenSSL 1.1.0. Was 0x20000000L */\n# define SSL_OP_NETSCAPE_CA_DN_BUG                       0x0\n/* Removed from OpenSSL 1.1.0. Was 0x40000000L */\n# define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG          0x0\n\n/*\n * Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success\n * when just a single record has been written):\n */\n# define SSL_MODE_ENABLE_PARTIAL_WRITE       0x00000001U\n/*\n * Make it possible to retry SSL_write() with changed buffer location (buffer\n * contents must stay the same!); this is not the default to avoid the\n * misconception that non-blocking SSL_write() behaves like non-blocking\n * write():\n */\n# define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U\n/*\n * Never bother the application with retries if the transport is blocking:\n */\n# define SSL_MODE_AUTO_RETRY 0x00000004U\n/* Don't attempt to automatically build certificate chain */\n# define SSL_MODE_NO_AUTO_CHAIN 0x00000008U\n/*\n * Save RAM by releasing read and write buffers when they're empty. (SSL3 and\n * TLS only.) Released buffers are freed.\n */\n# define SSL_MODE_RELEASE_BUFFERS 0x00000010U\n/*\n * Send the current time in the Random fields of the ClientHello and\n * ServerHello records for compatibility with hypothetical implementations\n * that require it.\n */\n# define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020U\n# define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040U\n/*\n * Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications\n * that reconnect with a downgraded protocol version; see\n * draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your\n * application attempts a normal handshake. Only use this in explicit\n * fallback retries, following the guidance in\n * draft-ietf-tls-downgrade-scsv-00.\n */\n# define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080U\n/*\n * Support Asynchronous operation\n */\n# define SSL_MODE_ASYNC 0x00000100U\n\n/*\n * When using DTLS/SCTP, include the terminating zero in the label\n * used for computing the endpoint-pair shared secret. Required for\n * interoperability with implementations having this bug like these\n * older version of OpenSSL:\n * - OpenSSL 1.0.0 series\n * - OpenSSL 1.0.1 series\n * - OpenSSL 1.0.2 series\n * - OpenSSL 1.1.0 series\n * - OpenSSL 1.1.1 and 1.1.1a\n */\n# define SSL_MODE_DTLS_SCTP_LABEL_LENGTH_BUG 0x00000400U\n\n/* Cert related flags */\n/*\n * Many implementations ignore some aspects of the TLS standards such as\n * enforcing certificate chain algorithms. When this is set we enforce them.\n */\n# define SSL_CERT_FLAG_TLS_STRICT                0x00000001U\n\n/* Suite B modes, takes same values as certificate verify flags */\n# define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY       0x10000\n/* Suite B 192 bit only mode */\n# define SSL_CERT_FLAG_SUITEB_192_LOS            0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define SSL_CERT_FLAG_SUITEB_128_LOS            0x30000\n\n/* Perform all sorts of protocol violations for testing purposes */\n# define SSL_CERT_FLAG_BROKEN_PROTOCOL           0x10000000\n\n/* Flags for building certificate chains */\n/* Treat any existing certificates as untrusted CAs */\n# define SSL_BUILD_CHAIN_FLAG_UNTRUSTED          0x1\n/* Don't include root CA in chain */\n# define SSL_BUILD_CHAIN_FLAG_NO_ROOT            0x2\n/* Just check certificates already there */\n# define SSL_BUILD_CHAIN_FLAG_CHECK              0x4\n/* Ignore verification errors */\n# define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR       0x8\n/* Clear verification errors from queue */\n# define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR        0x10\n\n/* Flags returned by SSL_check_chain */\n/* Certificate can be used with this session */\n# define CERT_PKEY_VALID         0x1\n/* Certificate can also be used for signing */\n# define CERT_PKEY_SIGN          0x2\n/* EE certificate signing algorithm OK */\n# define CERT_PKEY_EE_SIGNATURE  0x10\n/* CA signature algorithms OK */\n# define CERT_PKEY_CA_SIGNATURE  0x20\n/* EE certificate parameters OK */\n# define CERT_PKEY_EE_PARAM      0x40\n/* CA certificate parameters OK */\n# define CERT_PKEY_CA_PARAM      0x80\n/* Signing explicitly allowed as opposed to SHA1 fallback */\n# define CERT_PKEY_EXPLICIT_SIGN 0x100\n/* Client CA issuer names match (always set for server cert) */\n# define CERT_PKEY_ISSUER_NAME   0x200\n/* Cert type matches client types (always set for server cert) */\n# define CERT_PKEY_CERT_TYPE     0x400\n/* Cert chain suitable to Suite B */\n# define CERT_PKEY_SUITEB        0x800\n\n# define SSL_CONF_FLAG_CMDLINE           0x1\n# define SSL_CONF_FLAG_FILE              0x2\n# define SSL_CONF_FLAG_CLIENT            0x4\n# define SSL_CONF_FLAG_SERVER            0x8\n# define SSL_CONF_FLAG_SHOW_ERRORS       0x10\n# define SSL_CONF_FLAG_CERTIFICATE       0x20\n# define SSL_CONF_FLAG_REQUIRE_PRIVATE   0x40\n/* Configuration value types */\n# define SSL_CONF_TYPE_UNKNOWN           0x0\n# define SSL_CONF_TYPE_STRING            0x1\n# define SSL_CONF_TYPE_FILE              0x2\n# define SSL_CONF_TYPE_DIR               0x3\n# define SSL_CONF_TYPE_NONE              0x4\n\n/* Maximum length of the application-controlled segment of a a TLSv1.3 cookie */\n# define SSL_COOKIE_LENGTH                       4096\n\n/*\n * Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they\n * cannot be used to clear bits.\n */\n\nunsigned long SSL_CTX_get_options(const SSL_CTX *ctx);\nunsigned long SSL_get_options(const SSL *s);\nunsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op);\nunsigned long SSL_clear_options(SSL *s, unsigned long op);\nunsigned long SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);\nunsigned long SSL_set_options(SSL *s, unsigned long op);\n\n# define SSL_CTX_set_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)\n# define SSL_CTX_clear_mode(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_CTX_get_mode(ctx) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)\n# define SSL_clear_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL)\n# define SSL_set_mode(ssl,op) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)\n# define SSL_get_mode(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)\n# define SSL_set_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL)\n# define DTLS_set_link_mtu(ssl, mtu) \\\n        SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL)\n# define DTLS_get_link_min_mtu(ssl) \\\n        SSL_ctrl((ssl),DTLS_CTRL_GET_LINK_MIN_MTU,0,NULL)\n\n# define SSL_get_secure_renegotiation_support(ssl) \\\n        SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL)\n\n# ifndef OPENSSL_NO_HEARTBEATS\n#  define SSL_heartbeat(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT,0,NULL)\n# endif\n\n# define SSL_CTX_set_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_set_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CERT_FLAGS,(op),NULL)\n# define SSL_CTX_clear_cert_flags(ctx,op) \\\n        SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n# define SSL_clear_cert_flags(s,op) \\\n        SSL_ctrl((s),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)\n\nvoid SSL_CTX_set_msg_callback(SSL_CTX *ctx,\n                              void (*cb) (int write_p, int version,\n                                          int content_type, const void *buf,\n                                          size_t len, SSL *ssl, void *arg));\nvoid SSL_set_msg_callback(SSL *ssl,\n                          void (*cb) (int write_p, int version,\n                                      int content_type, const void *buf,\n                                      size_t len, SSL *ssl, void *arg));\n# define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n# define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))\n\n# define SSL_get_extms_support(s) \\\n        SSL_ctrl((s),SSL_CTRL_GET_EXTMS_SUPPORT,0,NULL)\n\n# ifndef OPENSSL_NO_SRP\n\n/* see tls_srp.c */\n__owur int SSL_SRP_CTX_init(SSL *s);\n__owur int SSL_CTX_SRP_CTX_init(SSL_CTX *ctx);\nint SSL_SRP_CTX_free(SSL *ctx);\nint SSL_CTX_SRP_CTX_free(SSL_CTX *ctx);\n__owur int SSL_srp_server_param_with_username(SSL *s, int *ad);\n__owur int SRP_Calc_A_param(SSL *s);\n\n# endif\n\n/* 100k max cert list */\n# define SSL_MAX_CERT_LIST_DEFAULT 1024*100\n\n# define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT      (1024*20)\n\n/*\n * This callback type is used inside SSL_CTX, SSL, and in the functions that\n * set them. It is used to override the generation of SSL/TLS session IDs in\n * a server. Return value should be zero on an error, non-zero to proceed.\n * Also, callbacks should themselves check if the id they generate is unique\n * otherwise the SSL handshake will fail with an error - callbacks can do\n * this using the 'ssl' value they're passed by;\n * SSL_has_matching_session_id(ssl, id, *id_len) The length value passed in\n * is set at the maximum size the session ID can be. In SSLv3/TLSv1 it is 32\n * bytes. The callback can alter this length to be less if desired. It is\n * also an error for the callback to set the size to zero.\n */\ntypedef int (*GEN_SESSION_CB) (SSL *ssl, unsigned char *id,\n                               unsigned int *id_len);\n\n# define SSL_SESS_CACHE_OFF                      0x0000\n# define SSL_SESS_CACHE_CLIENT                   0x0001\n# define SSL_SESS_CACHE_SERVER                   0x0002\n# define SSL_SESS_CACHE_BOTH     (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)\n# define SSL_SESS_CACHE_NO_AUTO_CLEAR            0x0080\n/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */\n# define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP       0x0100\n# define SSL_SESS_CACHE_NO_INTERNAL_STORE        0x0200\n# define SSL_SESS_CACHE_NO_INTERNAL \\\n        (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)\n\nLHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx);\n# define SSL_CTX_sess_number(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)\n# define SSL_CTX_sess_connect(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL)\n# define SSL_CTX_sess_connect_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL)\n# define SSL_CTX_sess_connect_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL)\n# define SSL_CTX_sess_accept_renegotiate(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL)\n# define SSL_CTX_sess_accept_good(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL)\n# define SSL_CTX_sess_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL)\n# define SSL_CTX_sess_cb_hits(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL)\n# define SSL_CTX_sess_misses(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL)\n# define SSL_CTX_sess_timeouts(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL)\n# define SSL_CTX_sess_cache_full(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL)\n\nvoid SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,\n                             int (*new_session_cb) (struct ssl_st *ssl,\n                                                    SSL_SESSION *sess));\nint (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                              SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,\n                                void (*remove_session_cb) (struct ssl_ctx_st\n                                                           *ctx,\n                                                           SSL_SESSION *sess));\nvoid (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)) (struct ssl_ctx_st *ctx,\n                                                  SSL_SESSION *sess);\nvoid SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,\n                             SSL_SESSION *(*get_session_cb) (struct ssl_st\n                                                             *ssl,\n                                                             const unsigned char\n                                                             *data, int len,\n                                                             int *copy));\nSSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,\n                                                       const unsigned char *data,\n                                                       int len, int *copy);\nvoid SSL_CTX_set_info_callback(SSL_CTX *ctx,\n                               void (*cb) (const SSL *ssl, int type, int val));\nvoid (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type,\n                                                 int val);\nvoid SSL_CTX_set_client_cert_cb(SSL_CTX *ctx,\n                                int (*client_cert_cb) (SSL *ssl, X509 **x509,\n                                                       EVP_PKEY **pkey));\nint (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509,\n                                                 EVP_PKEY **pkey);\n# ifndef OPENSSL_NO_ENGINE\n__owur int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e);\n# endif\nvoid SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx,\n                                    int (*app_gen_cookie_cb) (SSL *ssl,\n                                                              unsigned char\n                                                              *cookie,\n                                                              unsigned int\n                                                              *cookie_len));\nvoid SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx,\n                                  int (*app_verify_cookie_cb) (SSL *ssl,\n                                                               const unsigned\n                                                               char *cookie,\n                                                               unsigned int\n                                                               cookie_len));\n\nvoid SSL_CTX_set_stateless_cookie_generate_cb(\n    SSL_CTX *ctx,\n    int (*gen_stateless_cookie_cb) (SSL *ssl,\n                                    unsigned char *cookie,\n                                    size_t *cookie_len));\nvoid SSL_CTX_set_stateless_cookie_verify_cb(\n    SSL_CTX *ctx,\n    int (*verify_stateless_cookie_cb) (SSL *ssl,\n                                       const unsigned char *cookie,\n                                       size_t cookie_len));\n# ifndef OPENSSL_NO_NEXTPROTONEG\n\ntypedef int (*SSL_CTX_npn_advertised_cb_func)(SSL *ssl,\n                                              const unsigned char **out,\n                                              unsigned int *outlen,\n                                              void *arg);\nvoid SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s,\n                                           SSL_CTX_npn_advertised_cb_func cb,\n                                           void *arg);\n#  define SSL_CTX_set_npn_advertised_cb SSL_CTX_set_next_protos_advertised_cb\n\ntypedef int (*SSL_CTX_npn_select_cb_func)(SSL *s,\n                                          unsigned char **out,\n                                          unsigned char *outlen,\n                                          const unsigned char *in,\n                                          unsigned int inlen,\n                                          void *arg);\nvoid SSL_CTX_set_next_proto_select_cb(SSL_CTX *s,\n                                      SSL_CTX_npn_select_cb_func cb,\n                                      void *arg);\n#  define SSL_CTX_set_npn_select_cb SSL_CTX_set_next_proto_select_cb\n\nvoid SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,\n                                    unsigned *len);\n#  define SSL_get0_npn_negotiated SSL_get0_next_proto_negotiated\n# endif\n\n__owur int SSL_select_next_proto(unsigned char **out, unsigned char *outlen,\n                                 const unsigned char *in, unsigned int inlen,\n                                 const unsigned char *client,\n                                 unsigned int client_len);\n\n# define OPENSSL_NPN_UNSUPPORTED 0\n# define OPENSSL_NPN_NEGOTIATED  1\n# define OPENSSL_NPN_NO_OVERLAP  2\n\n__owur int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos,\n                                   unsigned int protos_len);\n__owur int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,\n                               unsigned int protos_len);\ntypedef int (*SSL_CTX_alpn_select_cb_func)(SSL *ssl,\n                                           const unsigned char **out,\n                                           unsigned char *outlen,\n                                           const unsigned char *in,\n                                           unsigned int inlen,\n                                           void *arg);\nvoid SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,\n                                SSL_CTX_alpn_select_cb_func cb,\n                                void *arg);\nvoid SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data,\n                            unsigned int *len);\n\n# ifndef OPENSSL_NO_PSK\n/*\n * the maximum length of the buffer given to callbacks containing the\n * resulting identity/psk\n */\n#  define PSK_MAX_IDENTITY_LEN 128\n#  define PSK_MAX_PSK_LEN 256\ntypedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl,\n                                               const char *hint,\n                                               char *identity,\n                                               unsigned int max_identity_len,\n                                               unsigned char *psk,\n                                               unsigned int max_psk_len);\nvoid SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, SSL_psk_client_cb_func cb);\nvoid SSL_set_psk_client_callback(SSL *ssl, SSL_psk_client_cb_func cb);\n\ntypedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl,\n                                               const char *identity,\n                                               unsigned char *psk,\n                                               unsigned int max_psk_len);\nvoid SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb);\nvoid SSL_set_psk_server_callback(SSL *ssl, SSL_psk_server_cb_func cb);\n\n__owur int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint);\n__owur int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint);\nconst char *SSL_get_psk_identity_hint(const SSL *s);\nconst char *SSL_get_psk_identity(const SSL *s);\n# endif\n\ntypedef int (*SSL_psk_find_session_cb_func)(SSL *ssl,\n                                            const unsigned char *identity,\n                                            size_t identity_len,\n                                            SSL_SESSION **sess);\ntypedef int (*SSL_psk_use_session_cb_func)(SSL *ssl, const EVP_MD *md,\n                                           const unsigned char **id,\n                                           size_t *idlen,\n                                           SSL_SESSION **sess);\n\nvoid SSL_set_psk_find_session_callback(SSL *s, SSL_psk_find_session_cb_func cb);\nvoid SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx,\n                                           SSL_psk_find_session_cb_func cb);\nvoid SSL_set_psk_use_session_callback(SSL *s, SSL_psk_use_session_cb_func cb);\nvoid SSL_CTX_set_psk_use_session_callback(SSL_CTX *ctx,\n                                          SSL_psk_use_session_cb_func cb);\n\n/* Register callbacks to handle custom TLS Extensions for client or server. */\n\n__owur int SSL_CTX_has_client_custom_ext(const SSL_CTX *ctx,\n                                         unsigned int ext_type);\n\n__owur int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx,\n                                         unsigned int ext_type,\n                                         custom_ext_add_cb add_cb,\n                                         custom_ext_free_cb free_cb,\n                                         void *add_arg,\n                                         custom_ext_parse_cb parse_cb,\n                                         void *parse_arg);\n\n__owur int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx,\n                                         unsigned int ext_type,\n                                         custom_ext_add_cb add_cb,\n                                         custom_ext_free_cb free_cb,\n                                         void *add_arg,\n                                         custom_ext_parse_cb parse_cb,\n                                         void *parse_arg);\n\n__owur int SSL_CTX_add_custom_ext(SSL_CTX *ctx, unsigned int ext_type,\n                                  unsigned int context,\n                                  SSL_custom_ext_add_cb_ex add_cb,\n                                  SSL_custom_ext_free_cb_ex free_cb,\n                                  void *add_arg,\n                                  SSL_custom_ext_parse_cb_ex parse_cb,\n                                  void *parse_arg);\n\n__owur int SSL_extension_supported(unsigned int ext_type);\n\n# define SSL_NOTHING            1\n# define SSL_WRITING            2\n# define SSL_READING            3\n# define SSL_X509_LOOKUP        4\n# define SSL_ASYNC_PAUSED       5\n# define SSL_ASYNC_NO_JOBS      6\n# define SSL_CLIENT_HELLO_CB    7\n\n/* These will only be used when doing non-blocking IO */\n# define SSL_want_nothing(s)         (SSL_want(s) == SSL_NOTHING)\n# define SSL_want_read(s)            (SSL_want(s) == SSL_READING)\n# define SSL_want_write(s)           (SSL_want(s) == SSL_WRITING)\n# define SSL_want_x509_lookup(s)     (SSL_want(s) == SSL_X509_LOOKUP)\n# define SSL_want_async(s)           (SSL_want(s) == SSL_ASYNC_PAUSED)\n# define SSL_want_async_job(s)       (SSL_want(s) == SSL_ASYNC_NO_JOBS)\n# define SSL_want_client_hello_cb(s) (SSL_want(s) == SSL_CLIENT_HELLO_CB)\n\n# define SSL_MAC_FLAG_READ_MAC_STREAM 1\n# define SSL_MAC_FLAG_WRITE_MAC_STREAM 2\n\n/*\n * A callback for logging out TLS key material. This callback should log out\n * |line| followed by a newline.\n */\ntypedef void (*SSL_CTX_keylog_cb_func)(const SSL *ssl, const char *line);\n\n/*\n * SSL_CTX_set_keylog_callback configures a callback to log key material. This\n * is intended for debugging use with tools like Wireshark. The cb function\n * should log line followed by a newline.\n */\nvoid SSL_CTX_set_keylog_callback(SSL_CTX *ctx, SSL_CTX_keylog_cb_func cb);\n\n/*\n * SSL_CTX_get_keylog_callback returns the callback configured by\n * SSL_CTX_set_keylog_callback.\n */\nSSL_CTX_keylog_cb_func SSL_CTX_get_keylog_callback(const SSL_CTX *ctx);\n\nint SSL_CTX_set_max_early_data(SSL_CTX *ctx, uint32_t max_early_data);\nuint32_t SSL_CTX_get_max_early_data(const SSL_CTX *ctx);\nint SSL_set_max_early_data(SSL *s, uint32_t max_early_data);\nuint32_t SSL_get_max_early_data(const SSL *s);\nint SSL_CTX_set_recv_max_early_data(SSL_CTX *ctx, uint32_t recv_max_early_data);\nuint32_t SSL_CTX_get_recv_max_early_data(const SSL_CTX *ctx);\nint SSL_set_recv_max_early_data(SSL *s, uint32_t recv_max_early_data);\nuint32_t SSL_get_recv_max_early_data(const SSL *s);\n\n#ifdef __cplusplus\n}\n#endif\n\n# include <openssl/ssl2.h>\n# include <openssl/ssl3.h>\n# include <openssl/tls1.h>      /* This is mostly sslv3 with a few tweaks */\n# include <openssl/dtls1.h>     /* Datagram TLS */\n# include <openssl/srtp.h>      /* Support for the use_srtp extension */\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * These need to be after the above set of includes due to a compiler bug\n * in VisualStudio 2015\n */\nDEFINE_STACK_OF_CONST(SSL_CIPHER)\nDEFINE_STACK_OF(SSL_COMP)\n\n/* compatibility */\n# define SSL_set_app_data(s,arg)         (SSL_set_ex_data(s,0,(char *)(arg)))\n# define SSL_get_app_data(s)             (SSL_get_ex_data(s,0))\n# define SSL_SESSION_set_app_data(s,a)   (SSL_SESSION_set_ex_data(s,0, \\\n                                                                  (char *)(a)))\n# define SSL_SESSION_get_app_data(s)     (SSL_SESSION_get_ex_data(s,0))\n# define SSL_CTX_get_app_data(ctx)       (SSL_CTX_get_ex_data(ctx,0))\n# define SSL_CTX_set_app_data(ctx,arg)   (SSL_CTX_set_ex_data(ctx,0, \\\n                                                              (char *)(arg)))\nDEPRECATEDIN_1_1_0(void SSL_set_debug(SSL *s, int debug))\n\n/* TLSv1.3 KeyUpdate message types */\n/* -1 used so that this is an invalid value for the on-the-wire protocol */\n#define SSL_KEY_UPDATE_NONE             -1\n/* Values as defined for the on-the-wire protocol */\n#define SSL_KEY_UPDATE_NOT_REQUESTED     0\n#define SSL_KEY_UPDATE_REQUESTED         1\n\n/*\n * The valid handshake states (one for each type message sent and one for each\n * type of message received). There are also two \"special\" states:\n * TLS = TLS or DTLS state\n * DTLS = DTLS specific state\n * CR/SR = Client Read/Server Read\n * CW/SW = Client Write/Server Write\n *\n * The \"special\" states are:\n * TLS_ST_BEFORE = No handshake has been initiated yet\n * TLS_ST_OK = A handshake has been successfully completed\n */\ntypedef enum {\n    TLS_ST_BEFORE,\n    TLS_ST_OK,\n    DTLS_ST_CR_HELLO_VERIFY_REQUEST,\n    TLS_ST_CR_SRVR_HELLO,\n    TLS_ST_CR_CERT,\n    TLS_ST_CR_CERT_STATUS,\n    TLS_ST_CR_KEY_EXCH,\n    TLS_ST_CR_CERT_REQ,\n    TLS_ST_CR_SRVR_DONE,\n    TLS_ST_CR_SESSION_TICKET,\n    TLS_ST_CR_CHANGE,\n    TLS_ST_CR_FINISHED,\n    TLS_ST_CW_CLNT_HELLO,\n    TLS_ST_CW_CERT,\n    TLS_ST_CW_KEY_EXCH,\n    TLS_ST_CW_CERT_VRFY,\n    TLS_ST_CW_CHANGE,\n    TLS_ST_CW_NEXT_PROTO,\n    TLS_ST_CW_FINISHED,\n    TLS_ST_SW_HELLO_REQ,\n    TLS_ST_SR_CLNT_HELLO,\n    DTLS_ST_SW_HELLO_VERIFY_REQUEST,\n    TLS_ST_SW_SRVR_HELLO,\n    TLS_ST_SW_CERT,\n    TLS_ST_SW_KEY_EXCH,\n    TLS_ST_SW_CERT_REQ,\n    TLS_ST_SW_SRVR_DONE,\n    TLS_ST_SR_CERT,\n    TLS_ST_SR_KEY_EXCH,\n    TLS_ST_SR_CERT_VRFY,\n    TLS_ST_SR_NEXT_PROTO,\n    TLS_ST_SR_CHANGE,\n    TLS_ST_SR_FINISHED,\n    TLS_ST_SW_SESSION_TICKET,\n    TLS_ST_SW_CERT_STATUS,\n    TLS_ST_SW_CHANGE,\n    TLS_ST_SW_FINISHED,\n    TLS_ST_SW_ENCRYPTED_EXTENSIONS,\n    TLS_ST_CR_ENCRYPTED_EXTENSIONS,\n    TLS_ST_CR_CERT_VRFY,\n    TLS_ST_SW_CERT_VRFY,\n    TLS_ST_CR_HELLO_REQ,\n    TLS_ST_SW_KEY_UPDATE,\n    TLS_ST_CW_KEY_UPDATE,\n    TLS_ST_SR_KEY_UPDATE,\n    TLS_ST_CR_KEY_UPDATE,\n    TLS_ST_EARLY_DATA,\n    TLS_ST_PENDING_EARLY_DATA_END,\n    TLS_ST_CW_END_OF_EARLY_DATA,\n    TLS_ST_SR_END_OF_EARLY_DATA\n} OSSL_HANDSHAKE_STATE;\n\n/*\n * Most of the following state values are no longer used and are defined to be\n * the closest equivalent value in the current state machine code. Not all\n * defines have an equivalent and are set to a dummy value (-1). SSL_ST_CONNECT\n * and SSL_ST_ACCEPT are still in use in the definition of SSL_CB_ACCEPT_LOOP,\n * SSL_CB_ACCEPT_EXIT, SSL_CB_CONNECT_LOOP and SSL_CB_CONNECT_EXIT.\n */\n\n# define SSL_ST_CONNECT                  0x1000\n# define SSL_ST_ACCEPT                   0x2000\n\n# define SSL_ST_MASK                     0x0FFF\n\n# define SSL_CB_LOOP                     0x01\n# define SSL_CB_EXIT                     0x02\n# define SSL_CB_READ                     0x04\n# define SSL_CB_WRITE                    0x08\n# define SSL_CB_ALERT                    0x4000/* used in callback */\n# define SSL_CB_READ_ALERT               (SSL_CB_ALERT|SSL_CB_READ)\n# define SSL_CB_WRITE_ALERT              (SSL_CB_ALERT|SSL_CB_WRITE)\n# define SSL_CB_ACCEPT_LOOP              (SSL_ST_ACCEPT|SSL_CB_LOOP)\n# define SSL_CB_ACCEPT_EXIT              (SSL_ST_ACCEPT|SSL_CB_EXIT)\n# define SSL_CB_CONNECT_LOOP             (SSL_ST_CONNECT|SSL_CB_LOOP)\n# define SSL_CB_CONNECT_EXIT             (SSL_ST_CONNECT|SSL_CB_EXIT)\n# define SSL_CB_HANDSHAKE_START          0x10\n# define SSL_CB_HANDSHAKE_DONE           0x20\n\n/* Is the SSL_connection established? */\n# define SSL_in_connect_init(a)          (SSL_in_init(a) && !SSL_is_server(a))\n# define SSL_in_accept_init(a)           (SSL_in_init(a) && SSL_is_server(a))\nint SSL_in_init(const SSL *s);\nint SSL_in_before(const SSL *s);\nint SSL_is_init_finished(const SSL *s);\n\n/*\n * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you\n * should not need these\n */\n# define SSL_ST_READ_HEADER                      0xF0\n# define SSL_ST_READ_BODY                        0xF1\n# define SSL_ST_READ_DONE                        0xF2\n\n/*-\n * Obtain latest Finished message\n *   -- that we sent (SSL_get_finished)\n *   -- that we expected from peer (SSL_get_peer_finished).\n * Returns length (0 == no Finished so far), copies up to 'count' bytes.\n */\nsize_t SSL_get_finished(const SSL *s, void *buf, size_t count);\nsize_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);\n\n/*\n * use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 3 options are\n * 'ored' with SSL_VERIFY_PEER if they are desired\n */\n# define SSL_VERIFY_NONE                 0x00\n# define SSL_VERIFY_PEER                 0x01\n# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02\n# define SSL_VERIFY_CLIENT_ONCE          0x04\n# define SSL_VERIFY_POST_HANDSHAKE       0x08\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define OpenSSL_add_ssl_algorithms()   SSL_library_init()\n#  define SSLeay_add_ssl_algorithms()    SSL_library_init()\n# endif\n\n/* More backward compatibility */\n# define SSL_get_cipher(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_cipher_bits(s,np) \\\n                SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)\n# define SSL_get_cipher_version(s) \\\n                SSL_CIPHER_get_version(SSL_get_current_cipher(s))\n# define SSL_get_cipher_name(s) \\\n                SSL_CIPHER_get_name(SSL_get_current_cipher(s))\n# define SSL_get_time(a)         SSL_SESSION_get_time(a)\n# define SSL_set_time(a,b)       SSL_SESSION_set_time((a),(b))\n# define SSL_get_timeout(a)      SSL_SESSION_get_timeout(a)\n# define SSL_set_timeout(a,b)    SSL_SESSION_set_timeout((a),(b))\n\n# define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)\n# define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)\n\nDECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)\n# define SSL_AD_REASON_OFFSET            1000/* offset to get SSL_R_... value\n                                              * from SSL_AD_... */\n/* These alert types are for SSLv3 and TLSv1 */\n# define SSL_AD_CLOSE_NOTIFY             SSL3_AD_CLOSE_NOTIFY\n/* fatal */\n# define SSL_AD_UNEXPECTED_MESSAGE       SSL3_AD_UNEXPECTED_MESSAGE\n/* fatal */\n# define SSL_AD_BAD_RECORD_MAC           SSL3_AD_BAD_RECORD_MAC\n# define SSL_AD_DECRYPTION_FAILED        TLS1_AD_DECRYPTION_FAILED\n# define SSL_AD_RECORD_OVERFLOW          TLS1_AD_RECORD_OVERFLOW\n/* fatal */\n# define SSL_AD_DECOMPRESSION_FAILURE    SSL3_AD_DECOMPRESSION_FAILURE\n/* fatal */\n# define SSL_AD_HANDSHAKE_FAILURE        SSL3_AD_HANDSHAKE_FAILURE\n/* Not for TLS */\n# define SSL_AD_NO_CERTIFICATE           SSL3_AD_NO_CERTIFICATE\n# define SSL_AD_BAD_CERTIFICATE          SSL3_AD_BAD_CERTIFICATE\n# define SSL_AD_UNSUPPORTED_CERTIFICATE  SSL3_AD_UNSUPPORTED_CERTIFICATE\n# define SSL_AD_CERTIFICATE_REVOKED      SSL3_AD_CERTIFICATE_REVOKED\n# define SSL_AD_CERTIFICATE_EXPIRED      SSL3_AD_CERTIFICATE_EXPIRED\n# define SSL_AD_CERTIFICATE_UNKNOWN      SSL3_AD_CERTIFICATE_UNKNOWN\n/* fatal */\n# define SSL_AD_ILLEGAL_PARAMETER        SSL3_AD_ILLEGAL_PARAMETER\n/* fatal */\n# define SSL_AD_UNKNOWN_CA               TLS1_AD_UNKNOWN_CA\n/* fatal */\n# define SSL_AD_ACCESS_DENIED            TLS1_AD_ACCESS_DENIED\n/* fatal */\n# define SSL_AD_DECODE_ERROR             TLS1_AD_DECODE_ERROR\n# define SSL_AD_DECRYPT_ERROR            TLS1_AD_DECRYPT_ERROR\n/* fatal */\n# define SSL_AD_EXPORT_RESTRICTION       TLS1_AD_EXPORT_RESTRICTION\n/* fatal */\n# define SSL_AD_PROTOCOL_VERSION         TLS1_AD_PROTOCOL_VERSION\n/* fatal */\n# define SSL_AD_INSUFFICIENT_SECURITY    TLS1_AD_INSUFFICIENT_SECURITY\n/* fatal */\n# define SSL_AD_INTERNAL_ERROR           TLS1_AD_INTERNAL_ERROR\n# define SSL_AD_USER_CANCELLED           TLS1_AD_USER_CANCELLED\n# define SSL_AD_NO_RENEGOTIATION         TLS1_AD_NO_RENEGOTIATION\n# define SSL_AD_MISSING_EXTENSION        TLS13_AD_MISSING_EXTENSION\n# define SSL_AD_CERTIFICATE_REQUIRED     TLS13_AD_CERTIFICATE_REQUIRED\n# define SSL_AD_UNSUPPORTED_EXTENSION    TLS1_AD_UNSUPPORTED_EXTENSION\n# define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE\n# define SSL_AD_UNRECOGNIZED_NAME        TLS1_AD_UNRECOGNIZED_NAME\n# define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE\n# define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE\n/* fatal */\n# define SSL_AD_UNKNOWN_PSK_IDENTITY     TLS1_AD_UNKNOWN_PSK_IDENTITY\n/* fatal */\n# define SSL_AD_INAPPROPRIATE_FALLBACK   TLS1_AD_INAPPROPRIATE_FALLBACK\n# define SSL_AD_NO_APPLICATION_PROTOCOL  TLS1_AD_NO_APPLICATION_PROTOCOL\n# define SSL_ERROR_NONE                  0\n# define SSL_ERROR_SSL                   1\n# define SSL_ERROR_WANT_READ             2\n# define SSL_ERROR_WANT_WRITE            3\n# define SSL_ERROR_WANT_X509_LOOKUP      4\n# define SSL_ERROR_SYSCALL               5/* look at error stack/return\n                                           * value/errno */\n# define SSL_ERROR_ZERO_RETURN           6\n# define SSL_ERROR_WANT_CONNECT          7\n# define SSL_ERROR_WANT_ACCEPT           8\n# define SSL_ERROR_WANT_ASYNC            9\n# define SSL_ERROR_WANT_ASYNC_JOB       10\n# define SSL_ERROR_WANT_CLIENT_HELLO_CB 11\n# define SSL_CTRL_SET_TMP_DH                     3\n# define SSL_CTRL_SET_TMP_ECDH                   4\n# define SSL_CTRL_SET_TMP_DH_CB                  6\n# define SSL_CTRL_GET_CLIENT_CERT_REQUEST        9\n# define SSL_CTRL_GET_NUM_RENEGOTIATIONS         10\n# define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS       11\n# define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS       12\n# define SSL_CTRL_GET_FLAGS                      13\n# define SSL_CTRL_EXTRA_CHAIN_CERT               14\n# define SSL_CTRL_SET_MSG_CALLBACK               15\n# define SSL_CTRL_SET_MSG_CALLBACK_ARG           16\n/* only applies to datagram connections */\n# define SSL_CTRL_SET_MTU                17\n/* Stats */\n# define SSL_CTRL_SESS_NUMBER                    20\n# define SSL_CTRL_SESS_CONNECT                   21\n# define SSL_CTRL_SESS_CONNECT_GOOD              22\n# define SSL_CTRL_SESS_CONNECT_RENEGOTIATE       23\n# define SSL_CTRL_SESS_ACCEPT                    24\n# define SSL_CTRL_SESS_ACCEPT_GOOD               25\n# define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE        26\n# define SSL_CTRL_SESS_HIT                       27\n# define SSL_CTRL_SESS_CB_HIT                    28\n# define SSL_CTRL_SESS_MISSES                    29\n# define SSL_CTRL_SESS_TIMEOUTS                  30\n# define SSL_CTRL_SESS_CACHE_FULL                31\n# define SSL_CTRL_MODE                           33\n# define SSL_CTRL_GET_READ_AHEAD                 40\n# define SSL_CTRL_SET_READ_AHEAD                 41\n# define SSL_CTRL_SET_SESS_CACHE_SIZE            42\n# define SSL_CTRL_GET_SESS_CACHE_SIZE            43\n# define SSL_CTRL_SET_SESS_CACHE_MODE            44\n# define SSL_CTRL_GET_SESS_CACHE_MODE            45\n# define SSL_CTRL_GET_MAX_CERT_LIST              50\n# define SSL_CTRL_SET_MAX_CERT_LIST              51\n# define SSL_CTRL_SET_MAX_SEND_FRAGMENT          52\n/* see tls1.h for macros based on these */\n# define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB       53\n# define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG      54\n# define SSL_CTRL_SET_TLSEXT_HOSTNAME            55\n# define SSL_CTRL_SET_TLSEXT_DEBUG_CB            56\n# define SSL_CTRL_SET_TLSEXT_DEBUG_ARG           57\n# define SSL_CTRL_GET_TLSEXT_TICKET_KEYS         58\n# define SSL_CTRL_SET_TLSEXT_TICKET_KEYS         59\n/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT    60 */\n/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB 61 */\n/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG 62 */\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB       63\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG   64\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE     65\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS     66\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS     67\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS      68\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS      69\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP        70\n# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP        71\n# define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB       72\n# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB    75\n# define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB                76\n# define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB             77\n# define SSL_CTRL_SET_SRP_ARG            78\n# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME               79\n# define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH               80\n# define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD               81\n# ifndef OPENSSL_NO_HEARTBEATS\n#  define SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT               85\n#  define SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING        86\n#  define SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS    87\n# endif\n# define DTLS_CTRL_GET_TIMEOUT           73\n# define DTLS_CTRL_HANDLE_TIMEOUT        74\n# define SSL_CTRL_GET_RI_SUPPORT                 76\n# define SSL_CTRL_CLEAR_MODE                     78\n# define SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB      79\n# define SSL_CTRL_GET_EXTRA_CHAIN_CERTS          82\n# define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS        83\n# define SSL_CTRL_CHAIN                          88\n# define SSL_CTRL_CHAIN_CERT                     89\n# define SSL_CTRL_GET_GROUPS                     90\n# define SSL_CTRL_SET_GROUPS                     91\n# define SSL_CTRL_SET_GROUPS_LIST                92\n# define SSL_CTRL_GET_SHARED_GROUP               93\n# define SSL_CTRL_SET_SIGALGS                    97\n# define SSL_CTRL_SET_SIGALGS_LIST               98\n# define SSL_CTRL_CERT_FLAGS                     99\n# define SSL_CTRL_CLEAR_CERT_FLAGS               100\n# define SSL_CTRL_SET_CLIENT_SIGALGS             101\n# define SSL_CTRL_SET_CLIENT_SIGALGS_LIST        102\n# define SSL_CTRL_GET_CLIENT_CERT_TYPES          103\n# define SSL_CTRL_SET_CLIENT_CERT_TYPES          104\n# define SSL_CTRL_BUILD_CERT_CHAIN               105\n# define SSL_CTRL_SET_VERIFY_CERT_STORE          106\n# define SSL_CTRL_SET_CHAIN_CERT_STORE           107\n# define SSL_CTRL_GET_PEER_SIGNATURE_NID         108\n# define SSL_CTRL_GET_PEER_TMP_KEY               109\n# define SSL_CTRL_GET_RAW_CIPHERLIST             110\n# define SSL_CTRL_GET_EC_POINT_FORMATS           111\n# define SSL_CTRL_GET_CHAIN_CERTS                115\n# define SSL_CTRL_SELECT_CURRENT_CERT            116\n# define SSL_CTRL_SET_CURRENT_CERT               117\n# define SSL_CTRL_SET_DH_AUTO                    118\n# define DTLS_CTRL_SET_LINK_MTU                  120\n# define DTLS_CTRL_GET_LINK_MIN_MTU              121\n# define SSL_CTRL_GET_EXTMS_SUPPORT              122\n# define SSL_CTRL_SET_MIN_PROTO_VERSION          123\n# define SSL_CTRL_SET_MAX_PROTO_VERSION          124\n# define SSL_CTRL_SET_SPLIT_SEND_FRAGMENT        125\n# define SSL_CTRL_SET_MAX_PIPELINES              126\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE     127\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB       128\n# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG   129\n# define SSL_CTRL_GET_MIN_PROTO_VERSION          130\n# define SSL_CTRL_GET_MAX_PROTO_VERSION          131\n# define SSL_CTRL_GET_SIGNATURE_NID              132\n# define SSL_CTRL_GET_TMP_KEY                    133\n# define SSL_CERT_SET_FIRST                      1\n# define SSL_CERT_SET_NEXT                       2\n# define SSL_CERT_SET_SERVER                     3\n# define DTLSv1_get_timeout(ssl, arg) \\\n        SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)(arg))\n# define DTLSv1_handle_timeout(ssl) \\\n        SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL)\n# define SSL_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_clear_num_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL)\n# define SSL_total_renegotiations(ssl) \\\n        SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL)\n# define SSL_CTX_set_tmp_dh(ctx,dh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)(dh))\n# define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh))\n# define SSL_CTX_set_dh_auto(ctx, onoff) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_DH_AUTO,onoff,NULL)\n# define SSL_set_dh_auto(s, onoff) \\\n        SSL_ctrl(s,SSL_CTRL_SET_DH_AUTO,onoff,NULL)\n# define SSL_set_tmp_dh(ssl,dh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)(dh))\n# define SSL_set_tmp_ecdh(ssl,ecdh) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh))\n# define SSL_CTX_add_extra_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)(x509))\n# define SSL_CTX_get_extra_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509)\n# define SSL_CTX_get_extra_chain_certs_only(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,1,px509)\n# define SSL_CTX_clear_extra_chain_certs(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL)\n# define SSL_CTX_set0_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)(sk))\n# define SSL_CTX_set1_chain(ctx,sk) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)(sk))\n# define SSL_CTX_add0_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)(x509))\n# define SSL_CTX_add1_chain_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)(x509))\n# define SSL_CTX_get0_chain_certs(ctx,px509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_CTX_clear_chain_certs(ctx) \\\n        SSL_CTX_set0_chain(ctx,NULL)\n# define SSL_CTX_build_cert_chain(ctx, flags) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_CTX_select_current_cert(ctx,x509) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509))\n# define SSL_CTX_set_current_cert(ctx, op) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_CTX_set0_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st))\n# define SSL_CTX_set1_verify_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st))\n# define SSL_CTX_set0_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st))\n# define SSL_CTX_set1_chain_cert_store(ctx,st) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st))\n# define SSL_set0_chain(s,sk) \\\n        SSL_ctrl(s,SSL_CTRL_CHAIN,0,(char *)(sk))\n# define SSL_set1_chain(s,sk) \\\n        SSL_ctrl(s,SSL_CTRL_CHAIN,1,(char *)(sk))\n# define SSL_add0_chain_cert(s,x509) \\\n        SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,0,(char *)(x509))\n# define SSL_add1_chain_cert(s,x509) \\\n        SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,1,(char *)(x509))\n# define SSL_get0_chain_certs(s,px509) \\\n        SSL_ctrl(s,SSL_CTRL_GET_CHAIN_CERTS,0,px509)\n# define SSL_clear_chain_certs(s) \\\n        SSL_set0_chain(s,NULL)\n# define SSL_build_cert_chain(s, flags) \\\n        SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)\n# define SSL_select_current_cert(s,x509) \\\n        SSL_ctrl(s,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509))\n# define SSL_set_current_cert(s,op) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CURRENT_CERT, op, NULL)\n# define SSL_set0_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st))\n# define SSL_set1_verify_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st))\n# define SSL_set0_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st))\n# define SSL_set1_chain_cert_store(s,st) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st))\n# define SSL_get1_groups(s, glist) \\\n        SSL_ctrl(s,SSL_CTRL_GET_GROUPS,0,(int*)(glist))\n# define SSL_CTX_set1_groups(ctx, glist, glistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS,glistlen,(int *)(glist))\n# define SSL_CTX_set1_groups_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(s))\n# define SSL_set1_groups(s, glist, glistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_GROUPS,glistlen,(char *)(glist))\n# define SSL_set1_groups_list(s, str) \\\n        SSL_ctrl(s,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(str))\n# define SSL_get_shared_group(s, n) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SHARED_GROUP,n,NULL)\n# define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist))\n# define SSL_CTX_set1_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(s))\n# define SSL_set1_sigalgs(s, slist, slistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist))\n# define SSL_set1_sigalgs_list(s, str) \\\n        SSL_ctrl(s,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(str))\n# define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist))\n# define SSL_CTX_set1_client_sigalgs_list(ctx, s) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(s))\n# define SSL_set1_client_sigalgs(s, slist, slistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist))\n# define SSL_set1_client_sigalgs_list(s, str) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(str))\n# define SSL_get0_certificate_types(s, clist) \\\n        SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)(clist))\n# define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen, \\\n                     (char *)(clist))\n# define SSL_set1_client_certificate_types(s, clist, clistlen) \\\n        SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)(clist))\n# define SSL_get_signature_nid(s, pn) \\\n        SSL_ctrl(s,SSL_CTRL_GET_SIGNATURE_NID,0,pn)\n# define SSL_get_peer_signature_nid(s, pn) \\\n        SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn)\n# define SSL_get_peer_tmp_key(s, pk) \\\n        SSL_ctrl(s,SSL_CTRL_GET_PEER_TMP_KEY,0,pk)\n# define SSL_get_tmp_key(s, pk) \\\n        SSL_ctrl(s,SSL_CTRL_GET_TMP_KEY,0,pk)\n# define SSL_get0_raw_cipherlist(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_RAW_CIPHERLIST,0,plst)\n# define SSL_get0_ec_point_formats(s, plst) \\\n        SSL_ctrl(s,SSL_CTRL_GET_EC_POINT_FORMATS,0,plst)\n# define SSL_CTX_set_min_proto_version(ctx, version) \\\n        SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL)\n# define SSL_CTX_set_max_proto_version(ctx, version) \\\n        SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL)\n# define SSL_CTX_get_min_proto_version(ctx) \\\n        SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL)\n# define SSL_CTX_get_max_proto_version(ctx) \\\n        SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL)\n# define SSL_set_min_proto_version(s, version) \\\n        SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL)\n# define SSL_set_max_proto_version(s, version) \\\n        SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL)\n# define SSL_get_min_proto_version(s) \\\n        SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL)\n# define SSL_get_max_proto_version(s) \\\n        SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL)\n\n/* Backwards compatibility, original 1.1.0 names */\n# define SSL_CTRL_GET_SERVER_TMP_KEY \\\n         SSL_CTRL_GET_PEER_TMP_KEY\n# define SSL_get_server_tmp_key(s, pk) \\\n         SSL_get_peer_tmp_key(s, pk)\n\n/*\n * The following symbol names are old and obsolete. They are kept\n * for compatibility reasons only and should not be used anymore.\n */\n# define SSL_CTRL_GET_CURVES           SSL_CTRL_GET_GROUPS\n# define SSL_CTRL_SET_CURVES           SSL_CTRL_SET_GROUPS\n# define SSL_CTRL_SET_CURVES_LIST      SSL_CTRL_SET_GROUPS_LIST\n# define SSL_CTRL_GET_SHARED_CURVE     SSL_CTRL_GET_SHARED_GROUP\n\n# define SSL_get1_curves               SSL_get1_groups\n# define SSL_CTX_set1_curves           SSL_CTX_set1_groups\n# define SSL_CTX_set1_curves_list      SSL_CTX_set1_groups_list\n# define SSL_set1_curves               SSL_set1_groups\n# define SSL_set1_curves_list          SSL_set1_groups_list\n# define SSL_get_shared_curve          SSL_get_shared_group\n\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n/* Provide some compatibility macros for removed functionality. */\n#  define SSL_CTX_need_tmp_RSA(ctx)                0\n#  define SSL_CTX_set_tmp_rsa(ctx,rsa)             1\n#  define SSL_need_tmp_RSA(ssl)                    0\n#  define SSL_set_tmp_rsa(ssl,rsa)                 1\n#  define SSL_CTX_set_ecdh_auto(dummy, onoff)      ((onoff) != 0)\n#  define SSL_set_ecdh_auto(dummy, onoff)          ((onoff) != 0)\n/*\n * We \"pretend\" to call the callback to avoid warnings about unused static\n * functions.\n */\n#  define SSL_CTX_set_tmp_rsa_callback(ctx, cb)    while(0) (cb)(NULL, 0, 0)\n#  define SSL_set_tmp_rsa_callback(ssl, cb)        while(0) (cb)(NULL, 0, 0)\n# endif\n__owur const BIO_METHOD *BIO_f_ssl(void);\n__owur BIO *BIO_new_ssl(SSL_CTX *ctx, int client);\n__owur BIO *BIO_new_ssl_connect(SSL_CTX *ctx);\n__owur BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);\n__owur int BIO_ssl_copy_session_id(BIO *to, BIO *from);\nvoid BIO_ssl_shutdown(BIO *ssl_bio);\n\n__owur int SSL_CTX_set_cipher_list(SSL_CTX *, const char *str);\n__owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);\nint SSL_CTX_up_ref(SSL_CTX *ctx);\nvoid SSL_CTX_free(SSL_CTX *);\n__owur long SSL_CTX_set_timeout(SSL_CTX *ctx, long t);\n__owur long SSL_CTX_get_timeout(const SSL_CTX *ctx);\n__owur X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);\nvoid SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *);\nvoid SSL_CTX_set1_cert_store(SSL_CTX *, X509_STORE *);\n__owur int SSL_want(const SSL *s);\n__owur int SSL_clear(SSL *s);\n\nvoid SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);\n\n__owur const SSL_CIPHER *SSL_get_current_cipher(const SSL *s);\n__owur const SSL_CIPHER *SSL_get_pending_cipher(const SSL *s);\n__owur int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits);\n__owur const char *SSL_CIPHER_get_version(const SSL_CIPHER *c);\n__owur const char *SSL_CIPHER_get_name(const SSL_CIPHER *c);\n__owur const char *SSL_CIPHER_standard_name(const SSL_CIPHER *c);\n__owur const char *OPENSSL_cipher_name(const char *rfc_name);\n__owur uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c);\n__owur uint16_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *c);\n__owur int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c);\n__owur int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c);\n__owur const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c);\n__owur int SSL_CIPHER_is_aead(const SSL_CIPHER *c);\n\n__owur int SSL_get_fd(const SSL *s);\n__owur int SSL_get_rfd(const SSL *s);\n__owur int SSL_get_wfd(const SSL *s);\n__owur const char *SSL_get_cipher_list(const SSL *s, int n);\n__owur char *SSL_get_shared_ciphers(const SSL *s, char *buf, int size);\n__owur int SSL_get_read_ahead(const SSL *s);\n__owur int SSL_pending(const SSL *s);\n__owur int SSL_has_pending(const SSL *s);\n# ifndef OPENSSL_NO_SOCK\n__owur int SSL_set_fd(SSL *s, int fd);\n__owur int SSL_set_rfd(SSL *s, int fd);\n__owur int SSL_set_wfd(SSL *s, int fd);\n# endif\nvoid SSL_set0_rbio(SSL *s, BIO *rbio);\nvoid SSL_set0_wbio(SSL *s, BIO *wbio);\nvoid SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio);\n__owur BIO *SSL_get_rbio(const SSL *s);\n__owur BIO *SSL_get_wbio(const SSL *s);\n__owur int SSL_set_cipher_list(SSL *s, const char *str);\n__owur int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str);\n__owur int SSL_set_ciphersuites(SSL *s, const char *str);\nvoid SSL_set_read_ahead(SSL *s, int yes);\n__owur int SSL_get_verify_mode(const SSL *s);\n__owur int SSL_get_verify_depth(const SSL *s);\n__owur SSL_verify_cb SSL_get_verify_callback(const SSL *s);\nvoid SSL_set_verify(SSL *s, int mode, SSL_verify_cb callback);\nvoid SSL_set_verify_depth(SSL *s, int depth);\nvoid SSL_set_cert_cb(SSL *s, int (*cb) (SSL *ssl, void *arg), void *arg);\n# ifndef OPENSSL_NO_RSA\n__owur int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);\n__owur int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const unsigned char *d,\n                                      long len);\n# endif\n__owur int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);\n__owur int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d,\n                                   long len);\n__owur int SSL_use_certificate(SSL *ssl, X509 *x);\n__owur int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);\n__owur int SSL_use_cert_and_key(SSL *ssl, X509 *x509, EVP_PKEY *privatekey,\n                                STACK_OF(X509) *chain, int override);\n\n\n/* serverinfo file format versions */\n# define SSL_SERVERINFOV1   1\n# define SSL_SERVERINFOV2   2\n\n/* Set serverinfo data for the current active cert. */\n__owur int SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo,\n                                  size_t serverinfo_length);\n__owur int SSL_CTX_use_serverinfo_ex(SSL_CTX *ctx, unsigned int version,\n                                     const unsigned char *serverinfo,\n                                     size_t serverinfo_length);\n__owur int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file);\n\n#ifndef OPENSSL_NO_RSA\n__owur int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);\n#endif\n\n__owur int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);\n__owur int SSL_use_certificate_file(SSL *ssl, const char *file, int type);\n\n#ifndef OPENSSL_NO_RSA\n__owur int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file,\n                                          int type);\n#endif\n__owur int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file,\n                                       int type);\n__owur int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file,\n                                        int type);\n/* PEM type */\n__owur int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);\n__owur int SSL_use_certificate_chain_file(SSL *ssl, const char *file);\n__owur STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);\n__owur int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                               const char *file);\nint SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,\n                                       const char *dir);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSL_load_error_strings() \\\n    OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \\\n                     | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)\n# endif\n\n__owur const char *SSL_state_string(const SSL *s);\n__owur const char *SSL_rstate_string(const SSL *s);\n__owur const char *SSL_state_string_long(const SSL *s);\n__owur const char *SSL_rstate_string_long(const SSL *s);\n__owur long SSL_SESSION_get_time(const SSL_SESSION *s);\n__owur long SSL_SESSION_set_time(SSL_SESSION *s, long t);\n__owur long SSL_SESSION_get_timeout(const SSL_SESSION *s);\n__owur long SSL_SESSION_set_timeout(SSL_SESSION *s, long t);\n__owur int SSL_SESSION_get_protocol_version(const SSL_SESSION *s);\n__owur int SSL_SESSION_set_protocol_version(SSL_SESSION *s, int version);\n\n__owur const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s);\n__owur int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname);\nvoid SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s,\n                                    const unsigned char **alpn,\n                                    size_t *len);\n__owur int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s,\n                                          const unsigned char *alpn,\n                                          size_t len);\n__owur const SSL_CIPHER *SSL_SESSION_get0_cipher(const SSL_SESSION *s);\n__owur int SSL_SESSION_set_cipher(SSL_SESSION *s, const SSL_CIPHER *cipher);\n__owur int SSL_SESSION_has_ticket(const SSL_SESSION *s);\n__owur unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s);\nvoid SSL_SESSION_get0_ticket(const SSL_SESSION *s, const unsigned char **tick,\n                             size_t *len);\n__owur uint32_t SSL_SESSION_get_max_early_data(const SSL_SESSION *s);\n__owur int SSL_SESSION_set_max_early_data(SSL_SESSION *s,\n                                          uint32_t max_early_data);\n__owur int SSL_copy_session_id(SSL *to, const SSL *from);\n__owur X509 *SSL_SESSION_get0_peer(SSL_SESSION *s);\n__owur int SSL_SESSION_set1_id_context(SSL_SESSION *s,\n                                       const unsigned char *sid_ctx,\n                                       unsigned int sid_ctx_len);\n__owur int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid,\n                               unsigned int sid_len);\n__owur int SSL_SESSION_is_resumable(const SSL_SESSION *s);\n\n__owur SSL_SESSION *SSL_SESSION_new(void);\n__owur SSL_SESSION *SSL_SESSION_dup(SSL_SESSION *src);\nconst unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,\n                                        unsigned int *len);\nconst unsigned char *SSL_SESSION_get0_id_context(const SSL_SESSION *s,\n                                                 unsigned int *len);\n__owur unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s);\n# ifndef OPENSSL_NO_STDIO\nint SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses);\n# endif\nint SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses);\nint SSL_SESSION_print_keylog(BIO *bp, const SSL_SESSION *x);\nint SSL_SESSION_up_ref(SSL_SESSION *ses);\nvoid SSL_SESSION_free(SSL_SESSION *ses);\n__owur int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);\n__owur int SSL_set_session(SSL *to, SSL_SESSION *session);\nint SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *session);\nint SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *session);\n__owur int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb);\n__owur int SSL_set_generate_session_id(SSL *s, GEN_SESSION_CB cb);\n__owur int SSL_has_matching_session_id(const SSL *s,\n                                       const unsigned char *id,\n                                       unsigned int id_len);\nSSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,\n                             long length);\n\n# ifdef HEADER_X509_H\n__owur X509 *SSL_get_peer_certificate(const SSL *s);\n# endif\n\n__owur STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s);\n\n__owur int SSL_CTX_get_verify_mode(const SSL_CTX *ctx);\n__owur int SSL_CTX_get_verify_depth(const SSL_CTX *ctx);\n__owur SSL_verify_cb SSL_CTX_get_verify_callback(const SSL_CTX *ctx);\nvoid SSL_CTX_set_verify(SSL_CTX *ctx, int mode, SSL_verify_cb callback);\nvoid SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);\nvoid SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx,\n                                      int (*cb) (X509_STORE_CTX *, void *),\n                                      void *arg);\nvoid SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb) (SSL *ssl, void *arg),\n                         void *arg);\n# ifndef OPENSSL_NO_RSA\n__owur int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);\n__owur int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d,\n                                          long len);\n# endif\n__owur int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);\n__owur int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx,\n                                       const unsigned char *d, long len);\n__owur int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);\n__owur int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len,\n                                        const unsigned char *d);\n__owur int SSL_CTX_use_cert_and_key(SSL_CTX *ctx, X509 *x509, EVP_PKEY *privatekey,\n                                    STACK_OF(X509) *chain, int override);\n\nvoid SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);\nvoid SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);\npem_password_cb *SSL_CTX_get_default_passwd_cb(SSL_CTX *ctx);\nvoid *SSL_CTX_get_default_passwd_cb_userdata(SSL_CTX *ctx);\nvoid SSL_set_default_passwd_cb(SSL *s, pem_password_cb *cb);\nvoid SSL_set_default_passwd_cb_userdata(SSL *s, void *u);\npem_password_cb *SSL_get_default_passwd_cb(SSL *s);\nvoid *SSL_get_default_passwd_cb_userdata(SSL *s);\n\n__owur int SSL_CTX_check_private_key(const SSL_CTX *ctx);\n__owur int SSL_check_private_key(const SSL *ctx);\n\n__owur int SSL_CTX_set_session_id_context(SSL_CTX *ctx,\n                                          const unsigned char *sid_ctx,\n                                          unsigned int sid_ctx_len);\n\nSSL *SSL_new(SSL_CTX *ctx);\nint SSL_up_ref(SSL *s);\nint SSL_is_dtls(const SSL *s);\n__owur int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,\n                                      unsigned int sid_ctx_len);\n\n__owur int SSL_CTX_set_purpose(SSL_CTX *ctx, int purpose);\n__owur int SSL_set_purpose(SSL *ssl, int purpose);\n__owur int SSL_CTX_set_trust(SSL_CTX *ctx, int trust);\n__owur int SSL_set_trust(SSL *ssl, int trust);\n\n__owur int SSL_set1_host(SSL *s, const char *hostname);\n__owur int SSL_add1_host(SSL *s, const char *hostname);\n__owur const char *SSL_get0_peername(SSL *s);\nvoid SSL_set_hostflags(SSL *s, unsigned int flags);\n\n__owur int SSL_CTX_dane_enable(SSL_CTX *ctx);\n__owur int SSL_CTX_dane_mtype_set(SSL_CTX *ctx, const EVP_MD *md,\n                                  uint8_t mtype, uint8_t ord);\n__owur int SSL_dane_enable(SSL *s, const char *basedomain);\n__owur int SSL_dane_tlsa_add(SSL *s, uint8_t usage, uint8_t selector,\n                             uint8_t mtype, unsigned const char *data, size_t dlen);\n__owur int SSL_get0_dane_authority(SSL *s, X509 **mcert, EVP_PKEY **mspki);\n__owur int SSL_get0_dane_tlsa(SSL *s, uint8_t *usage, uint8_t *selector,\n                              uint8_t *mtype, unsigned const char **data,\n                              size_t *dlen);\n/*\n * Bridge opacity barrier between libcrypt and libssl, also needed to support\n * offline testing in test/danetest.c\n */\nSSL_DANE *SSL_get0_dane(SSL *ssl);\n/*\n * DANE flags\n */\nunsigned long SSL_CTX_dane_set_flags(SSL_CTX *ctx, unsigned long flags);\nunsigned long SSL_CTX_dane_clear_flags(SSL_CTX *ctx, unsigned long flags);\nunsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags);\nunsigned long SSL_dane_clear_flags(SSL *ssl, unsigned long flags);\n\n__owur int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm);\n__owur int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm);\n\n__owur X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx);\n__owur X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl);\n\n# ifndef OPENSSL_NO_SRP\nint SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name);\nint SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password);\nint SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength);\nint SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,\n                                        char *(*cb) (SSL *, void *));\nint SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,\n                                          int (*cb) (SSL *, void *));\nint SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,\n                                      int (*cb) (SSL *, int *, void *));\nint SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg);\n\nint SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,\n                             BIGNUM *sa, BIGNUM *v, char *info);\nint SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,\n                                const char *grp);\n\n__owur BIGNUM *SSL_get_srp_g(SSL *s);\n__owur BIGNUM *SSL_get_srp_N(SSL *s);\n\n__owur char *SSL_get_srp_username(SSL *s);\n__owur char *SSL_get_srp_userinfo(SSL *s);\n# endif\n\n/*\n * ClientHello callback and helpers.\n */\n\n# define SSL_CLIENT_HELLO_SUCCESS 1\n# define SSL_CLIENT_HELLO_ERROR   0\n# define SSL_CLIENT_HELLO_RETRY   (-1)\n\ntypedef int (*SSL_client_hello_cb_fn) (SSL *s, int *al, void *arg);\nvoid SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn cb,\n                                 void *arg);\nint SSL_client_hello_isv2(SSL *s);\nunsigned int SSL_client_hello_get0_legacy_version(SSL *s);\nsize_t SSL_client_hello_get0_random(SSL *s, const unsigned char **out);\nsize_t SSL_client_hello_get0_session_id(SSL *s, const unsigned char **out);\nsize_t SSL_client_hello_get0_ciphers(SSL *s, const unsigned char **out);\nsize_t SSL_client_hello_get0_compression_methods(SSL *s,\n                                                 const unsigned char **out);\nint SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen);\nint SSL_client_hello_get0_ext(SSL *s, unsigned int type,\n                              const unsigned char **out, size_t *outlen);\n\nvoid SSL_certs_clear(SSL *s);\nvoid SSL_free(SSL *ssl);\n# ifdef OSSL_ASYNC_FD\n/*\n * Windows application developer has to include windows.h to use these.\n */\n__owur int SSL_waiting_for_async(SSL *s);\n__owur int SSL_get_all_async_fds(SSL *s, OSSL_ASYNC_FD *fds, size_t *numfds);\n__owur int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd,\n                                     size_t *numaddfds, OSSL_ASYNC_FD *delfd,\n                                     size_t *numdelfds);\n# endif\n__owur int SSL_accept(SSL *ssl);\n__owur int SSL_stateless(SSL *s);\n__owur int SSL_connect(SSL *ssl);\n__owur int SSL_read(SSL *ssl, void *buf, int num);\n__owur int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);\n\n# define SSL_READ_EARLY_DATA_ERROR   0\n# define SSL_READ_EARLY_DATA_SUCCESS 1\n# define SSL_READ_EARLY_DATA_FINISH  2\n\n__owur int SSL_read_early_data(SSL *s, void *buf, size_t num,\n                               size_t *readbytes);\n__owur int SSL_peek(SSL *ssl, void *buf, int num);\n__owur int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);\n__owur int SSL_write(SSL *ssl, const void *buf, int num);\n__owur int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written);\n__owur int SSL_write_early_data(SSL *s, const void *buf, size_t num,\n                                size_t *written);\nlong SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);\nlong SSL_callback_ctrl(SSL *, int, void (*)(void));\nlong SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);\nlong SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void));\n\n# define SSL_EARLY_DATA_NOT_SENT    0\n# define SSL_EARLY_DATA_REJECTED    1\n# define SSL_EARLY_DATA_ACCEPTED    2\n\n__owur int SSL_get_early_data_status(const SSL *s);\n\n__owur int SSL_get_error(const SSL *s, int ret_code);\n__owur const char *SSL_get_version(const SSL *s);\n\n/* This sets the 'default' SSL version that SSL_new() will create */\n__owur int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth);\n\n# ifndef OPENSSL_NO_SSL3_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_method(void)) /* SSLv3 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_client_method(void))\n# endif\n\n#define SSLv23_method           TLS_method\n#define SSLv23_server_method    TLS_server_method\n#define SSLv23_client_method    TLS_client_method\n\n/* Negotiate highest available SSL/TLS version */\n__owur const SSL_METHOD *TLS_method(void);\n__owur const SSL_METHOD *TLS_server_method(void);\n__owur const SSL_METHOD *TLS_client_method(void);\n\n# ifndef OPENSSL_NO_TLS1_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_method(void)) /* TLSv1.0 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_client_method(void))\n# endif\n\n# ifndef OPENSSL_NO_TLS1_1_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_method(void)) /* TLSv1.1 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_client_method(void))\n# endif\n\n# ifndef OPENSSL_NO_TLS1_2_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_method(void)) /* TLSv1.2 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_client_method(void))\n# endif\n\n# ifndef OPENSSL_NO_DTLS1_METHOD\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_method(void)) /* DTLSv1.0 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_client_method(void))\n# endif\n\n# ifndef OPENSSL_NO_DTLS1_2_METHOD\n/* DTLSv1.2 */\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_server_method(void))\nDEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_client_method(void))\n# endif\n\n__owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */\n__owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */\n__owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */\n\n__owur size_t DTLS_get_data_mtu(const SSL *s);\n\n__owur STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);\n__owur STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx);\n__owur STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *s);\n__owur STACK_OF(SSL_CIPHER) *SSL_get1_supported_ciphers(SSL *s);\n\n__owur int SSL_do_handshake(SSL *s);\nint SSL_key_update(SSL *s, int updatetype);\nint SSL_get_key_update_type(const SSL *s);\nint SSL_renegotiate(SSL *s);\nint SSL_renegotiate_abbreviated(SSL *s);\n__owur int SSL_renegotiate_pending(const SSL *s);\nint SSL_shutdown(SSL *s);\n__owur int SSL_verify_client_post_handshake(SSL *s);\nvoid SSL_CTX_set_post_handshake_auth(SSL_CTX *ctx, int val);\nvoid SSL_set_post_handshake_auth(SSL *s, int val);\n\n__owur const SSL_METHOD *SSL_CTX_get_ssl_method(const SSL_CTX *ctx);\n__owur const SSL_METHOD *SSL_get_ssl_method(const SSL *s);\n__owur int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method);\n__owur const char *SSL_alert_type_string_long(int value);\n__owur const char *SSL_alert_type_string(int value);\n__owur const char *SSL_alert_desc_string_long(int value);\n__owur const char *SSL_alert_desc_string(int value);\n\nvoid SSL_set0_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);\nvoid SSL_CTX_set0_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);\n__owur const STACK_OF(X509_NAME) *SSL_get0_CA_list(const SSL *s);\n__owur const STACK_OF(X509_NAME) *SSL_CTX_get0_CA_list(const SSL_CTX *ctx);\n__owur int SSL_add1_to_CA_list(SSL *ssl, const X509 *x);\n__owur int SSL_CTX_add1_to_CA_list(SSL_CTX *ctx, const X509 *x);\n__owur const STACK_OF(X509_NAME) *SSL_get0_peer_CA_list(const SSL *s);\n\nvoid SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);\nvoid SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);\n__owur STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);\n__owur STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s);\n__owur int SSL_add_client_CA(SSL *ssl, X509 *x);\n__owur int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);\n\nvoid SSL_set_connect_state(SSL *s);\nvoid SSL_set_accept_state(SSL *s);\n\n__owur long SSL_get_default_timeout(const SSL *s);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSL_library_init() OPENSSL_init_ssl(0, NULL)\n# endif\n\n__owur char *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size);\n__owur STACK_OF(X509_NAME) *SSL_dup_CA_list(const STACK_OF(X509_NAME) *sk);\n\n__owur SSL *SSL_dup(SSL *ssl);\n\n__owur X509 *SSL_get_certificate(const SSL *ssl);\n/*\n * EVP_PKEY\n */\nstruct evp_pkey_st *SSL_get_privatekey(const SSL *ssl);\n\n__owur X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx);\n__owur EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx);\n\nvoid SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);\n__owur int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);\nvoid SSL_set_quiet_shutdown(SSL *ssl, int mode);\n__owur int SSL_get_quiet_shutdown(const SSL *ssl);\nvoid SSL_set_shutdown(SSL *ssl, int mode);\n__owur int SSL_get_shutdown(const SSL *ssl);\n__owur int SSL_version(const SSL *ssl);\n__owur int SSL_client_version(const SSL *s);\n__owur int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);\n__owur int SSL_CTX_set_default_verify_dir(SSL_CTX *ctx);\n__owur int SSL_CTX_set_default_verify_file(SSL_CTX *ctx);\n__owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,\n                                         const char *CApath);\n# define SSL_get0_session SSL_get_session/* just peek at pointer */\n__owur SSL_SESSION *SSL_get_session(const SSL *ssl);\n__owur SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */\n__owur SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);\nSSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx);\nvoid SSL_set_info_callback(SSL *ssl,\n                           void (*cb) (const SSL *ssl, int type, int val));\nvoid (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type,\n                                               int val);\n__owur OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl);\n\nvoid SSL_set_verify_result(SSL *ssl, long v);\n__owur long SSL_get_verify_result(const SSL *ssl);\n__owur STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s);\n\n__owur size_t SSL_get_client_random(const SSL *ssl, unsigned char *out,\n                                    size_t outlen);\n__owur size_t SSL_get_server_random(const SSL *ssl, unsigned char *out,\n                                    size_t outlen);\n__owur size_t SSL_SESSION_get_master_key(const SSL_SESSION *sess,\n                                         unsigned char *out, size_t outlen);\n__owur int SSL_SESSION_set1_master_key(SSL_SESSION *sess,\n                                       const unsigned char *in, size_t len);\nuint8_t SSL_SESSION_get_max_fragment_length(const SSL_SESSION *sess);\n\n#define SSL_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef)\n__owur int SSL_set_ex_data(SSL *ssl, int idx, void *data);\nvoid *SSL_get_ex_data(const SSL *ssl, int idx);\n#define SSL_SESSION_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, l, p, newf, dupf, freef)\n__owur int SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data);\nvoid *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx);\n#define SSL_CTX_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef)\n__owur int SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data);\nvoid *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx);\n\n__owur int SSL_get_ex_data_X509_STORE_CTX_idx(void);\n\n# define SSL_CTX_sess_set_cache_size(ctx,t) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL)\n# define SSL_CTX_sess_get_cache_size(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL)\n# define SSL_CTX_set_session_cache_mode(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL)\n# define SSL_CTX_get_session_cache_mode(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL)\n\n# define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx)\n# define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m)\n# define SSL_CTX_get_read_ahead(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)\n# define SSL_CTX_set_read_ahead(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)\n# define SSL_CTX_get_max_cert_list(ctx) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_CTX_set_max_cert_list(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n# define SSL_get_max_cert_list(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)\n# define SSL_set_max_cert_list(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)\n\n# define SSL_CTX_set_max_send_fragment(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n# define SSL_set_max_send_fragment(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)\n# define SSL_CTX_set_split_send_fragment(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL)\n# define SSL_set_split_send_fragment(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL)\n# define SSL_CTX_set_max_pipelines(ctx,m) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_PIPELINES,m,NULL)\n# define SSL_set_max_pipelines(ssl,m) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_MAX_PIPELINES,m,NULL)\n\nvoid SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len);\nvoid SSL_set_default_read_buffer_len(SSL *s, size_t len);\n\n# ifndef OPENSSL_NO_DH\n/* NB: the |keylength| is only applicable when is_export is true */\nvoid SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,\n                                 DH *(*dh) (SSL *ssl, int is_export,\n                                            int keylength));\nvoid SSL_set_tmp_dh_callback(SSL *ssl,\n                             DH *(*dh) (SSL *ssl, int is_export,\n                                        int keylength));\n# endif\n\n__owur const COMP_METHOD *SSL_get_current_compression(const SSL *s);\n__owur const COMP_METHOD *SSL_get_current_expansion(const SSL *s);\n__owur const char *SSL_COMP_get_name(const COMP_METHOD *comp);\n__owur const char *SSL_COMP_get0_name(const SSL_COMP *comp);\n__owur int SSL_COMP_get_id(const SSL_COMP *comp);\nSTACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);\n__owur STACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP)\n                                                             *meths);\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSL_COMP_free_compression_methods() while(0) continue\n# endif\n__owur int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);\n\nconst SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr);\nint SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c);\nint SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c);\nint SSL_bytes_to_cipher_list(SSL *s, const unsigned char *bytes, size_t len,\n                             int isv2format, STACK_OF(SSL_CIPHER) **sk,\n                             STACK_OF(SSL_CIPHER) **scsvs);\n\n/* TLS extensions functions */\n__owur int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);\n\n__owur int SSL_set_session_ticket_ext_cb(SSL *s,\n                                         tls_session_ticket_ext_cb_fn cb,\n                                         void *arg);\n\n/* Pre-shared secret session resumption functions */\n__owur int SSL_set_session_secret_cb(SSL *s,\n                                     tls_session_secret_cb_fn session_secret_cb,\n                                     void *arg);\n\nvoid SSL_CTX_set_not_resumable_session_callback(SSL_CTX *ctx,\n                                                int (*cb) (SSL *ssl,\n                                                           int\n                                                           is_forward_secure));\n\nvoid SSL_set_not_resumable_session_callback(SSL *ssl,\n                                            int (*cb) (SSL *ssl,\n                                                       int is_forward_secure));\n\nvoid SSL_CTX_set_record_padding_callback(SSL_CTX *ctx,\n                                         size_t (*cb) (SSL *ssl, int type,\n                                                       size_t len, void *arg));\nvoid SSL_CTX_set_record_padding_callback_arg(SSL_CTX *ctx, void *arg);\nvoid *SSL_CTX_get_record_padding_callback_arg(const SSL_CTX *ctx);\nint SSL_CTX_set_block_padding(SSL_CTX *ctx, size_t block_size);\n\nvoid SSL_set_record_padding_callback(SSL *ssl,\n                                    size_t (*cb) (SSL *ssl, int type,\n                                                  size_t len, void *arg));\nvoid SSL_set_record_padding_callback_arg(SSL *ssl, void *arg);\nvoid *SSL_get_record_padding_callback_arg(const SSL *ssl);\nint SSL_set_block_padding(SSL *ssl, size_t block_size);\n\nint SSL_set_num_tickets(SSL *s, size_t num_tickets);\nsize_t SSL_get_num_tickets(const SSL *s);\nint SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets);\nsize_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define SSL_cache_hit(s) SSL_session_reused(s)\n# endif\n\n__owur int SSL_session_reused(const SSL *s);\n__owur int SSL_is_server(const SSL *s);\n\n__owur __owur SSL_CONF_CTX *SSL_CONF_CTX_new(void);\nint SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx);\nvoid SSL_CONF_CTX_free(SSL_CONF_CTX *cctx);\nunsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags);\n__owur unsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx,\n                                             unsigned int flags);\n__owur int SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre);\n\nvoid SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl);\nvoid SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx);\n\n__owur int SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value);\n__owur int SSL_CONF_cmd_argv(SSL_CONF_CTX *cctx, int *pargc, char ***pargv);\n__owur int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd);\n\nvoid SSL_add_ssl_module(void);\nint SSL_config(SSL *s, const char *name);\nint SSL_CTX_config(SSL_CTX *ctx, const char *name);\n\n# ifndef OPENSSL_NO_SSL_TRACE\nvoid SSL_trace(int write_p, int version, int content_type,\n               const void *buf, size_t len, SSL *ssl, void *arg);\n# endif\n\n# ifndef OPENSSL_NO_SOCK\nint DTLSv1_listen(SSL *s, BIO_ADDR *client);\n# endif\n\n# ifndef OPENSSL_NO_CT\n\n/*\n * A callback for verifying that the received SCTs are sufficient.\n * Expected to return 1 if they are sufficient, otherwise 0.\n * May return a negative integer if an error occurs.\n * A connection should be aborted if the SCTs are deemed insufficient.\n */\ntypedef int (*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx,\n                                    const STACK_OF(SCT) *scts, void *arg);\n\n/*\n * Sets a |callback| that is invoked upon receipt of ServerHelloDone to validate\n * the received SCTs.\n * If the callback returns a non-positive result, the connection is terminated.\n * Call this function before beginning a handshake.\n * If a NULL |callback| is provided, SCT validation is disabled.\n * |arg| is arbitrary userdata that will be passed to the callback whenever it\n * is invoked. Ownership of |arg| remains with the caller.\n *\n * NOTE: A side-effect of setting a CT callback is that an OCSP stapled response\n *       will be requested.\n */\nint SSL_set_ct_validation_callback(SSL *s, ssl_ct_validation_cb callback,\n                                   void *arg);\nint SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx,\n                                       ssl_ct_validation_cb callback,\n                                       void *arg);\n#define SSL_disable_ct(s) \\\n        ((void) SSL_set_validation_callback((s), NULL, NULL))\n#define SSL_CTX_disable_ct(ctx) \\\n        ((void) SSL_CTX_set_validation_callback((ctx), NULL, NULL))\n\n/*\n * The validation type enumerates the available behaviours of the built-in SSL\n * CT validation callback selected via SSL_enable_ct() and SSL_CTX_enable_ct().\n * The underlying callback is a static function in libssl.\n */\nenum {\n    SSL_CT_VALIDATION_PERMISSIVE = 0,\n    SSL_CT_VALIDATION_STRICT\n};\n\n/*\n * Enable CT by setting up a callback that implements one of the built-in\n * validation variants.  The SSL_CT_VALIDATION_PERMISSIVE variant always\n * continues the handshake, the application can make appropriate decisions at\n * handshake completion.  The SSL_CT_VALIDATION_STRICT variant requires at\n * least one valid SCT, or else handshake termination will be requested.  The\n * handshake may continue anyway if SSL_VERIFY_NONE is in effect.\n */\nint SSL_enable_ct(SSL *s, int validation_mode);\nint SSL_CTX_enable_ct(SSL_CTX *ctx, int validation_mode);\n\n/*\n * Report whether a non-NULL callback is enabled.\n */\nint SSL_ct_is_enabled(const SSL *s);\nint SSL_CTX_ct_is_enabled(const SSL_CTX *ctx);\n\n/* Gets the SCTs received from a connection */\nconst STACK_OF(SCT) *SSL_get0_peer_scts(SSL *s);\n\n/*\n * Loads the CT log list from the default location.\n * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store,\n * the log information loaded from this file will be appended to the\n * CTLOG_STORE.\n * Returns 1 on success, 0 otherwise.\n */\nint SSL_CTX_set_default_ctlog_list_file(SSL_CTX *ctx);\n\n/*\n * Loads the CT log list from the specified file path.\n * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store,\n * the log information loaded from this file will be appended to the\n * CTLOG_STORE.\n * Returns 1 on success, 0 otherwise.\n */\nint SSL_CTX_set_ctlog_list_file(SSL_CTX *ctx, const char *path);\n\n/*\n * Sets the CT log list used by all SSL connections created from this SSL_CTX.\n * Ownership of the CTLOG_STORE is transferred to the SSL_CTX.\n */\nvoid SSL_CTX_set0_ctlog_store(SSL_CTX *ctx, CTLOG_STORE *logs);\n\n/*\n * Gets the CT log list used by all SSL connections created from this SSL_CTX.\n * This will be NULL unless one of the following functions has been called:\n * - SSL_CTX_set_default_ctlog_list_file\n * - SSL_CTX_set_ctlog_list_file\n * - SSL_CTX_set_ctlog_store\n */\nconst CTLOG_STORE *SSL_CTX_get0_ctlog_store(const SSL_CTX *ctx);\n\n# endif /* OPENSSL_NO_CT */\n\n/* What the \"other\" parameter contains in security callback */\n/* Mask for type */\n# define SSL_SECOP_OTHER_TYPE    0xffff0000\n# define SSL_SECOP_OTHER_NONE    0\n# define SSL_SECOP_OTHER_CIPHER  (1 << 16)\n# define SSL_SECOP_OTHER_CURVE   (2 << 16)\n# define SSL_SECOP_OTHER_DH      (3 << 16)\n# define SSL_SECOP_OTHER_PKEY    (4 << 16)\n# define SSL_SECOP_OTHER_SIGALG  (5 << 16)\n# define SSL_SECOP_OTHER_CERT    (6 << 16)\n\n/* Indicated operation refers to peer key or certificate */\n# define SSL_SECOP_PEER          0x1000\n\n/* Values for \"op\" parameter in security callback */\n\n/* Called to filter ciphers */\n/* Ciphers client supports */\n# define SSL_SECOP_CIPHER_SUPPORTED      (1 | SSL_SECOP_OTHER_CIPHER)\n/* Cipher shared by client/server */\n# define SSL_SECOP_CIPHER_SHARED         (2 | SSL_SECOP_OTHER_CIPHER)\n/* Sanity check of cipher server selects */\n# define SSL_SECOP_CIPHER_CHECK          (3 | SSL_SECOP_OTHER_CIPHER)\n/* Curves supported by client */\n# define SSL_SECOP_CURVE_SUPPORTED       (4 | SSL_SECOP_OTHER_CURVE)\n/* Curves shared by client/server */\n# define SSL_SECOP_CURVE_SHARED          (5 | SSL_SECOP_OTHER_CURVE)\n/* Sanity check of curve server selects */\n# define SSL_SECOP_CURVE_CHECK           (6 | SSL_SECOP_OTHER_CURVE)\n/* Temporary DH key */\n# define SSL_SECOP_TMP_DH                (7 | SSL_SECOP_OTHER_PKEY)\n/* SSL/TLS version */\n# define SSL_SECOP_VERSION               (9 | SSL_SECOP_OTHER_NONE)\n/* Session tickets */\n# define SSL_SECOP_TICKET                (10 | SSL_SECOP_OTHER_NONE)\n/* Supported signature algorithms sent to peer */\n# define SSL_SECOP_SIGALG_SUPPORTED      (11 | SSL_SECOP_OTHER_SIGALG)\n/* Shared signature algorithm */\n# define SSL_SECOP_SIGALG_SHARED         (12 | SSL_SECOP_OTHER_SIGALG)\n/* Sanity check signature algorithm allowed */\n# define SSL_SECOP_SIGALG_CHECK          (13 | SSL_SECOP_OTHER_SIGALG)\n/* Used to get mask of supported public key signature algorithms */\n# define SSL_SECOP_SIGALG_MASK           (14 | SSL_SECOP_OTHER_SIGALG)\n/* Use to see if compression is allowed */\n# define SSL_SECOP_COMPRESSION           (15 | SSL_SECOP_OTHER_NONE)\n/* EE key in certificate */\n# define SSL_SECOP_EE_KEY                (16 | SSL_SECOP_OTHER_CERT)\n/* CA key in certificate */\n# define SSL_SECOP_CA_KEY                (17 | SSL_SECOP_OTHER_CERT)\n/* CA digest algorithm in certificate */\n# define SSL_SECOP_CA_MD                 (18 | SSL_SECOP_OTHER_CERT)\n/* Peer EE key in certificate */\n# define SSL_SECOP_PEER_EE_KEY           (SSL_SECOP_EE_KEY | SSL_SECOP_PEER)\n/* Peer CA key in certificate */\n# define SSL_SECOP_PEER_CA_KEY           (SSL_SECOP_CA_KEY | SSL_SECOP_PEER)\n/* Peer CA digest algorithm in certificate */\n# define SSL_SECOP_PEER_CA_MD            (SSL_SECOP_CA_MD | SSL_SECOP_PEER)\n\nvoid SSL_set_security_level(SSL *s, int level);\n__owur int SSL_get_security_level(const SSL *s);\nvoid SSL_set_security_callback(SSL *s,\n                               int (*cb) (const SSL *s, const SSL_CTX *ctx,\n                                          int op, int bits, int nid,\n                                          void *other, void *ex));\nint (*SSL_get_security_callback(const SSL *s)) (const SSL *s,\n                                                const SSL_CTX *ctx, int op,\n                                                int bits, int nid, void *other,\n                                                void *ex);\nvoid SSL_set0_security_ex_data(SSL *s, void *ex);\n__owur void *SSL_get0_security_ex_data(const SSL *s);\n\nvoid SSL_CTX_set_security_level(SSL_CTX *ctx, int level);\n__owur int SSL_CTX_get_security_level(const SSL_CTX *ctx);\nvoid SSL_CTX_set_security_callback(SSL_CTX *ctx,\n                                   int (*cb) (const SSL *s, const SSL_CTX *ctx,\n                                              int op, int bits, int nid,\n                                              void *other, void *ex));\nint (*SSL_CTX_get_security_callback(const SSL_CTX *ctx)) (const SSL *s,\n                                                          const SSL_CTX *ctx,\n                                                          int op, int bits,\n                                                          int nid,\n                                                          void *other,\n                                                          void *ex);\nvoid SSL_CTX_set0_security_ex_data(SSL_CTX *ctx, void *ex);\n__owur void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx);\n\n/* OPENSSL_INIT flag 0x010000 reserved for internal use */\n# define OPENSSL_INIT_NO_LOAD_SSL_STRINGS    0x00100000L\n# define OPENSSL_INIT_LOAD_SSL_STRINGS       0x00200000L\n\n# define OPENSSL_INIT_SSL_DEFAULT \\\n        (OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS)\n\nint OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);\n\n# ifndef OPENSSL_NO_UNIT_TEST\n__owur const struct openssl_ssl_test_functions *SSL_test_functions(void);\n# endif\n\n__owur int SSL_free_buffers(SSL *ssl);\n__owur int SSL_alloc_buffers(SSL *ssl);\n\n/* Status codes passed to the decrypt session ticket callback. Some of these\n * are for internal use only and are never passed to the callback. */\ntypedef int SSL_TICKET_STATUS;\n\n/* Support for ticket appdata */\n/* fatal error, malloc failure */\n# define SSL_TICKET_FATAL_ERR_MALLOC 0\n/* fatal error, either from parsing or decrypting the ticket */\n# define SSL_TICKET_FATAL_ERR_OTHER  1\n/* No ticket present */\n# define SSL_TICKET_NONE             2\n/* Empty ticket present */\n# define SSL_TICKET_EMPTY            3\n/* the ticket couldn't be decrypted */\n# define SSL_TICKET_NO_DECRYPT       4\n/* a ticket was successfully decrypted */\n# define SSL_TICKET_SUCCESS          5\n/* same as above but the ticket needs to be renewed */\n# define SSL_TICKET_SUCCESS_RENEW    6\n\n/* Return codes for the decrypt session ticket callback */\ntypedef int SSL_TICKET_RETURN;\n\n/* An error occurred */\n#define SSL_TICKET_RETURN_ABORT             0\n/* Do not use the ticket, do not send a renewed ticket to the client */\n#define SSL_TICKET_RETURN_IGNORE            1\n/* Do not use the ticket, send a renewed ticket to the client */\n#define SSL_TICKET_RETURN_IGNORE_RENEW      2\n/* Use the ticket, do not send a renewed ticket to the client */\n#define SSL_TICKET_RETURN_USE               3\n/* Use the ticket, send a renewed ticket to the client */\n#define SSL_TICKET_RETURN_USE_RENEW         4\n\ntypedef int (*SSL_CTX_generate_session_ticket_fn)(SSL *s, void *arg);\ntypedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)(SSL *s, SSL_SESSION *ss,\n                                                               const unsigned char *keyname,\n                                                               size_t keyname_length,\n                                                               SSL_TICKET_STATUS status,\n                                                               void *arg);\nint SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx,\n                                  SSL_CTX_generate_session_ticket_fn gen_cb,\n                                  SSL_CTX_decrypt_session_ticket_fn dec_cb,\n                                  void *arg);\nint SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, size_t len);\nint SSL_SESSION_get0_ticket_appdata(SSL_SESSION *ss, void **data, size_t *len);\n\nextern const char SSL_version_str[];\n\ntypedef unsigned int (*DTLS_timer_cb)(SSL *s, unsigned int timer_us);\n\nvoid DTLS_set_timer_cb(SSL *s, DTLS_timer_cb cb);\n\n\ntypedef int (*SSL_allow_early_data_cb_fn)(SSL *s, void *arg);\nvoid SSL_CTX_set_allow_early_data_cb(SSL_CTX *ctx,\n                                     SSL_allow_early_data_cb_fn cb,\n                                     void *arg);\nvoid SSL_set_allow_early_data_cb(SSL *s,\n                                 SSL_allow_early_data_cb_fn cb,\n                                 void *arg);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ssl2.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SSL2_H\n# define HEADER_SSL2_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define SSL2_VERSION            0x0002\n\n# define SSL2_MT_CLIENT_HELLO            1\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ssl3.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SSL3_H\n# define HEADER_SSL3_H\n\n# include <openssl/comp.h>\n# include <openssl/buffer.h>\n# include <openssl/evp.h>\n# include <openssl/ssl.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Signalling cipher suite value from RFC 5746\n * (TLS_EMPTY_RENEGOTIATION_INFO_SCSV)\n */\n# define SSL3_CK_SCSV                            0x030000FF\n\n/*\n * Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00\n * (TLS_FALLBACK_SCSV)\n */\n# define SSL3_CK_FALLBACK_SCSV                   0x03005600\n\n# define SSL3_CK_RSA_NULL_MD5                    0x03000001\n# define SSL3_CK_RSA_NULL_SHA                    0x03000002\n# define SSL3_CK_RSA_RC4_40_MD5                  0x03000003\n# define SSL3_CK_RSA_RC4_128_MD5                 0x03000004\n# define SSL3_CK_RSA_RC4_128_SHA                 0x03000005\n# define SSL3_CK_RSA_RC2_40_MD5                  0x03000006\n# define SSL3_CK_RSA_IDEA_128_SHA                0x03000007\n# define SSL3_CK_RSA_DES_40_CBC_SHA              0x03000008\n# define SSL3_CK_RSA_DES_64_CBC_SHA              0x03000009\n# define SSL3_CK_RSA_DES_192_CBC3_SHA            0x0300000A\n\n# define SSL3_CK_DH_DSS_DES_40_CBC_SHA           0x0300000B\n# define SSL3_CK_DH_DSS_DES_64_CBC_SHA           0x0300000C\n# define SSL3_CK_DH_DSS_DES_192_CBC3_SHA         0x0300000D\n# define SSL3_CK_DH_RSA_DES_40_CBC_SHA           0x0300000E\n# define SSL3_CK_DH_RSA_DES_64_CBC_SHA           0x0300000F\n# define SSL3_CK_DH_RSA_DES_192_CBC3_SHA         0x03000010\n\n# define SSL3_CK_DHE_DSS_DES_40_CBC_SHA          0x03000011\n# define SSL3_CK_EDH_DSS_DES_40_CBC_SHA          SSL3_CK_DHE_DSS_DES_40_CBC_SHA\n# define SSL3_CK_DHE_DSS_DES_64_CBC_SHA          0x03000012\n# define SSL3_CK_EDH_DSS_DES_64_CBC_SHA          SSL3_CK_DHE_DSS_DES_64_CBC_SHA\n# define SSL3_CK_DHE_DSS_DES_192_CBC3_SHA        0x03000013\n# define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA        SSL3_CK_DHE_DSS_DES_192_CBC3_SHA\n# define SSL3_CK_DHE_RSA_DES_40_CBC_SHA          0x03000014\n# define SSL3_CK_EDH_RSA_DES_40_CBC_SHA          SSL3_CK_DHE_RSA_DES_40_CBC_SHA\n# define SSL3_CK_DHE_RSA_DES_64_CBC_SHA          0x03000015\n# define SSL3_CK_EDH_RSA_DES_64_CBC_SHA          SSL3_CK_DHE_RSA_DES_64_CBC_SHA\n# define SSL3_CK_DHE_RSA_DES_192_CBC3_SHA        0x03000016\n# define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA        SSL3_CK_DHE_RSA_DES_192_CBC3_SHA\n\n# define SSL3_CK_ADH_RC4_40_MD5                  0x03000017\n# define SSL3_CK_ADH_RC4_128_MD5                 0x03000018\n# define SSL3_CK_ADH_DES_40_CBC_SHA              0x03000019\n# define SSL3_CK_ADH_DES_64_CBC_SHA              0x0300001A\n# define SSL3_CK_ADH_DES_192_CBC_SHA             0x0300001B\n\n/* a bundle of RFC standard cipher names, generated from ssl3_ciphers[] */\n# define SSL3_RFC_RSA_NULL_MD5                   \"TLS_RSA_WITH_NULL_MD5\"\n# define SSL3_RFC_RSA_NULL_SHA                   \"TLS_RSA_WITH_NULL_SHA\"\n# define SSL3_RFC_RSA_DES_192_CBC3_SHA           \"TLS_RSA_WITH_3DES_EDE_CBC_SHA\"\n# define SSL3_RFC_DHE_DSS_DES_192_CBC3_SHA       \"TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA\"\n# define SSL3_RFC_DHE_RSA_DES_192_CBC3_SHA       \"TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA\"\n# define SSL3_RFC_ADH_DES_192_CBC_SHA            \"TLS_DH_anon_WITH_3DES_EDE_CBC_SHA\"\n# define SSL3_RFC_RSA_IDEA_128_SHA               \"TLS_RSA_WITH_IDEA_CBC_SHA\"\n# define SSL3_RFC_RSA_RC4_128_MD5                \"TLS_RSA_WITH_RC4_128_MD5\"\n# define SSL3_RFC_RSA_RC4_128_SHA                \"TLS_RSA_WITH_RC4_128_SHA\"\n# define SSL3_RFC_ADH_RC4_128_MD5                \"TLS_DH_anon_WITH_RC4_128_MD5\"\n\n# define SSL3_TXT_RSA_NULL_MD5                   \"NULL-MD5\"\n# define SSL3_TXT_RSA_NULL_SHA                   \"NULL-SHA\"\n# define SSL3_TXT_RSA_RC4_40_MD5                 \"EXP-RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_MD5                \"RC4-MD5\"\n# define SSL3_TXT_RSA_RC4_128_SHA                \"RC4-SHA\"\n# define SSL3_TXT_RSA_RC2_40_MD5                 \"EXP-RC2-CBC-MD5\"\n# define SSL3_TXT_RSA_IDEA_128_SHA               \"IDEA-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_40_CBC_SHA             \"EXP-DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_64_CBC_SHA             \"DES-CBC-SHA\"\n# define SSL3_TXT_RSA_DES_192_CBC3_SHA           \"DES-CBC3-SHA\"\n\n# define SSL3_TXT_DH_DSS_DES_40_CBC_SHA          \"EXP-DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_64_CBC_SHA          \"DH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA        \"DH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DH_RSA_DES_40_CBC_SHA          \"EXP-DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_64_CBC_SHA          \"DH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA        \"DH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_DHE_DSS_DES_40_CBC_SHA         \"EXP-DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_64_CBC_SHA         \"DHE-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA       \"DHE-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_40_CBC_SHA         \"EXP-DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_64_CBC_SHA         \"DHE-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA       \"DHE-RSA-DES-CBC3-SHA\"\n\n/*\n * This next block of six \"EDH\" labels is for backward compatibility with\n * older versions of OpenSSL.  New code should use the six \"DHE\" labels above\n * instead:\n */\n# define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA         \"EXP-EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA         \"EDH-DSS-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA       \"EDH-DSS-DES-CBC3-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA         \"EXP-EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA         \"EDH-RSA-DES-CBC-SHA\"\n# define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA       \"EDH-RSA-DES-CBC3-SHA\"\n\n# define SSL3_TXT_ADH_RC4_40_MD5                 \"EXP-ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_RC4_128_MD5                \"ADH-RC4-MD5\"\n# define SSL3_TXT_ADH_DES_40_CBC_SHA             \"EXP-ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_64_CBC_SHA             \"ADH-DES-CBC-SHA\"\n# define SSL3_TXT_ADH_DES_192_CBC_SHA            \"ADH-DES-CBC3-SHA\"\n\n# define SSL3_SSL_SESSION_ID_LENGTH              32\n# define SSL3_MAX_SSL_SESSION_ID_LENGTH          32\n\n# define SSL3_MASTER_SECRET_SIZE                 48\n# define SSL3_RANDOM_SIZE                        32\n# define SSL3_SESSION_ID_SIZE                    32\n# define SSL3_RT_HEADER_LENGTH                   5\n\n# define SSL3_HM_HEADER_LENGTH                  4\n\n# ifndef SSL3_ALIGN_PAYLOAD\n /*\n  * Some will argue that this increases memory footprint, but it's not\n  * actually true. Point is that malloc has to return at least 64-bit aligned\n  * pointers, meaning that allocating 5 bytes wastes 3 bytes in either case.\n  * Suggested pre-gaping simply moves these wasted bytes from the end of\n  * allocated region to its front, but makes data payload aligned, which\n  * improves performance:-)\n  */\n#  define SSL3_ALIGN_PAYLOAD                     8\n# else\n#  if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0\n#   error \"insane SSL3_ALIGN_PAYLOAD\"\n#   undef SSL3_ALIGN_PAYLOAD\n#  endif\n# endif\n\n/*\n * This is the maximum MAC (digest) size used by the SSL library. Currently\n * maximum of 20 is used by SHA1, but we reserve for future extension for\n * 512-bit hashes.\n */\n\n# define SSL3_RT_MAX_MD_SIZE                     64\n\n/*\n * Maximum block size used in all ciphersuites. Currently 16 for AES.\n */\n\n# define SSL_RT_MAX_CIPHER_BLOCK_SIZE            16\n\n# define SSL3_RT_MAX_EXTRA                       (16384)\n\n/* Maximum plaintext length: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_PLAIN_LENGTH                16384\n/* Maximum compression overhead: defined by SSL/TLS standards */\n# define SSL3_RT_MAX_COMPRESSED_OVERHEAD         1024\n\n/*\n * The standards give a maximum encryption overhead of 1024 bytes. In\n * practice the value is lower than this. The overhead is the maximum number\n * of padding bytes (256) plus the mac size.\n */\n# define SSL3_RT_MAX_ENCRYPTED_OVERHEAD        (256 + SSL3_RT_MAX_MD_SIZE)\n# define SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD  256\n\n/*\n * OpenSSL currently only uses a padding length of at most one block so the\n * send overhead is smaller.\n */\n\n# define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \\\n                        (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE)\n\n/* If compression isn't used don't include the compression overhead */\n\n# ifdef OPENSSL_NO_COMP\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH           SSL3_RT_MAX_PLAIN_LENGTH\n# else\n#  define SSL3_RT_MAX_COMPRESSED_LENGTH   \\\n            (SSL3_RT_MAX_PLAIN_LENGTH+SSL3_RT_MAX_COMPRESSED_OVERHEAD)\n# endif\n# define SSL3_RT_MAX_ENCRYPTED_LENGTH    \\\n            (SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH)\n# define SSL3_RT_MAX_TLS13_ENCRYPTED_LENGTH \\\n            (SSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD)\n# define SSL3_RT_MAX_PACKET_SIZE         \\\n            (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)\n\n# define SSL3_MD_CLIENT_FINISHED_CONST   \"\\x43\\x4C\\x4E\\x54\"\n# define SSL3_MD_SERVER_FINISHED_CONST   \"\\x53\\x52\\x56\\x52\"\n\n# define SSL3_VERSION                    0x0300\n# define SSL3_VERSION_MAJOR              0x03\n# define SSL3_VERSION_MINOR              0x00\n\n# define SSL3_RT_CHANGE_CIPHER_SPEC      20\n# define SSL3_RT_ALERT                   21\n# define SSL3_RT_HANDSHAKE               22\n# define SSL3_RT_APPLICATION_DATA        23\n# define DTLS1_RT_HEARTBEAT              24\n\n/* Pseudo content types to indicate additional parameters */\n# define TLS1_RT_CRYPTO                  0x1000\n# define TLS1_RT_CRYPTO_PREMASTER        (TLS1_RT_CRYPTO | 0x1)\n# define TLS1_RT_CRYPTO_CLIENT_RANDOM    (TLS1_RT_CRYPTO | 0x2)\n# define TLS1_RT_CRYPTO_SERVER_RANDOM    (TLS1_RT_CRYPTO | 0x3)\n# define TLS1_RT_CRYPTO_MASTER           (TLS1_RT_CRYPTO | 0x4)\n\n# define TLS1_RT_CRYPTO_READ             0x0000\n# define TLS1_RT_CRYPTO_WRITE            0x0100\n# define TLS1_RT_CRYPTO_MAC              (TLS1_RT_CRYPTO | 0x5)\n# define TLS1_RT_CRYPTO_KEY              (TLS1_RT_CRYPTO | 0x6)\n# define TLS1_RT_CRYPTO_IV               (TLS1_RT_CRYPTO | 0x7)\n# define TLS1_RT_CRYPTO_FIXED_IV         (TLS1_RT_CRYPTO | 0x8)\n\n/* Pseudo content types for SSL/TLS header info */\n# define SSL3_RT_HEADER                  0x100\n# define SSL3_RT_INNER_CONTENT_TYPE      0x101\n\n# define SSL3_AL_WARNING                 1\n# define SSL3_AL_FATAL                   2\n\n# define SSL3_AD_CLOSE_NOTIFY             0\n# define SSL3_AD_UNEXPECTED_MESSAGE      10/* fatal */\n# define SSL3_AD_BAD_RECORD_MAC          20/* fatal */\n# define SSL3_AD_DECOMPRESSION_FAILURE   30/* fatal */\n# define SSL3_AD_HANDSHAKE_FAILURE       40/* fatal */\n# define SSL3_AD_NO_CERTIFICATE          41\n# define SSL3_AD_BAD_CERTIFICATE         42\n# define SSL3_AD_UNSUPPORTED_CERTIFICATE 43\n# define SSL3_AD_CERTIFICATE_REVOKED     44\n# define SSL3_AD_CERTIFICATE_EXPIRED     45\n# define SSL3_AD_CERTIFICATE_UNKNOWN     46\n# define SSL3_AD_ILLEGAL_PARAMETER       47/* fatal */\n\n# define TLS1_HB_REQUEST         1\n# define TLS1_HB_RESPONSE        2\n\n\n# define SSL3_CT_RSA_SIGN                        1\n# define SSL3_CT_DSS_SIGN                        2\n# define SSL3_CT_RSA_FIXED_DH                    3\n# define SSL3_CT_DSS_FIXED_DH                    4\n# define SSL3_CT_RSA_EPHEMERAL_DH                5\n# define SSL3_CT_DSS_EPHEMERAL_DH                6\n# define SSL3_CT_FORTEZZA_DMS                    20\n/*\n * SSL3_CT_NUMBER is used to size arrays and it must be large enough to\n * contain all of the cert types defined for *either* SSLv3 and TLSv1.\n */\n# define SSL3_CT_NUMBER                  10\n\n# if defined(TLS_CT_NUMBER)\n#  if TLS_CT_NUMBER != SSL3_CT_NUMBER\n#    error \"SSL/TLS CT_NUMBER values do not match\"\n#  endif\n# endif\n\n/* No longer used as of OpenSSL 1.1.1 */\n# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS       0x0001\n\n/* Removed from OpenSSL 1.1.0 */\n# define TLS1_FLAGS_TLS_PADDING_BUG              0x0\n\n# define TLS1_FLAGS_SKIP_CERT_VERIFY             0x0010\n\n/* Set if we encrypt then mac instead of usual mac then encrypt */\n# define TLS1_FLAGS_ENCRYPT_THEN_MAC_READ        0x0100\n# define TLS1_FLAGS_ENCRYPT_THEN_MAC             TLS1_FLAGS_ENCRYPT_THEN_MAC_READ\n\n/* Set if extended master secret extension received from peer */\n# define TLS1_FLAGS_RECEIVED_EXTMS               0x0200\n\n# define TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE       0x0400\n\n# define TLS1_FLAGS_STATELESS                    0x0800\n\n/* Set if extended master secret extension required on renegotiation */\n# define TLS1_FLAGS_REQUIRED_EXTMS               0x1000\n\n# define SSL3_MT_HELLO_REQUEST                   0\n# define SSL3_MT_CLIENT_HELLO                    1\n# define SSL3_MT_SERVER_HELLO                    2\n# define SSL3_MT_NEWSESSION_TICKET               4\n# define SSL3_MT_END_OF_EARLY_DATA               5\n# define SSL3_MT_ENCRYPTED_EXTENSIONS            8\n# define SSL3_MT_CERTIFICATE                     11\n# define SSL3_MT_SERVER_KEY_EXCHANGE             12\n# define SSL3_MT_CERTIFICATE_REQUEST             13\n# define SSL3_MT_SERVER_DONE                     14\n# define SSL3_MT_CERTIFICATE_VERIFY              15\n# define SSL3_MT_CLIENT_KEY_EXCHANGE             16\n# define SSL3_MT_FINISHED                        20\n# define SSL3_MT_CERTIFICATE_URL                 21\n# define SSL3_MT_CERTIFICATE_STATUS              22\n# define SSL3_MT_SUPPLEMENTAL_DATA               23\n# define SSL3_MT_KEY_UPDATE                      24\n# ifndef OPENSSL_NO_NEXTPROTONEG\n#  define SSL3_MT_NEXT_PROTO                     67\n# endif\n# define SSL3_MT_MESSAGE_HASH                    254\n# define DTLS1_MT_HELLO_VERIFY_REQUEST           3\n\n/* Dummy message type for handling CCS like a normal handshake message */\n# define SSL3_MT_CHANGE_CIPHER_SPEC              0x0101\n\n# define SSL3_MT_CCS                             1\n\n/* These are used when changing over to a new cipher */\n# define SSL3_CC_READ            0x001\n# define SSL3_CC_WRITE           0x002\n# define SSL3_CC_CLIENT          0x010\n# define SSL3_CC_SERVER          0x020\n# define SSL3_CC_EARLY           0x040\n# define SSL3_CC_HANDSHAKE       0x080\n# define SSL3_CC_APPLICATION     0x100\n# define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE)\n# define SSL3_CHANGE_CIPHER_SERVER_READ  (SSL3_CC_SERVER|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_CLIENT_READ  (SSL3_CC_CLIENT|SSL3_CC_READ)\n# define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE)\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/sslerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SSLERR_H\n# define HEADER_SSLERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_SSL_strings(void);\n\n/*\n * SSL function codes.\n */\n# define SSL_F_ADD_CLIENT_KEY_SHARE_EXT                   438\n# define SSL_F_ADD_KEY_SHARE                              512\n# define SSL_F_BYTES_TO_CIPHER_LIST                       519\n# define SSL_F_CHECK_SUITEB_CIPHER_LIST                   331\n# define SSL_F_CIPHERSUITE_CB                             622\n# define SSL_F_CONSTRUCT_CA_NAMES                         552\n# define SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS                 553\n# define SSL_F_CONSTRUCT_STATEFUL_TICKET                  636\n# define SSL_F_CONSTRUCT_STATELESS_TICKET                 637\n# define SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH              539\n# define SSL_F_CREATE_TICKET_PREQUEL                      638\n# define SSL_F_CT_MOVE_SCTS                               345\n# define SSL_F_CT_STRICT                                  349\n# define SSL_F_CUSTOM_EXT_ADD                             554\n# define SSL_F_CUSTOM_EXT_PARSE                           555\n# define SSL_F_D2I_SSL_SESSION                            103\n# define SSL_F_DANE_CTX_ENABLE                            347\n# define SSL_F_DANE_MTYPE_SET                             393\n# define SSL_F_DANE_TLSA_ADD                              394\n# define SSL_F_DERIVE_SECRET_KEY_AND_IV                   514\n# define SSL_F_DO_DTLS1_WRITE                             245\n# define SSL_F_DO_SSL3_WRITE                              104\n# define SSL_F_DTLS1_BUFFER_RECORD                        247\n# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM                    318\n# define SSL_F_DTLS1_HEARTBEAT                            305\n# define SSL_F_DTLS1_HM_FRAGMENT_NEW                      623\n# define SSL_F_DTLS1_PREPROCESS_FRAGMENT                  288\n# define SSL_F_DTLS1_PROCESS_BUFFERED_RECORDS             424\n# define SSL_F_DTLS1_PROCESS_RECORD                       257\n# define SSL_F_DTLS1_READ_BYTES                           258\n# define SSL_F_DTLS1_READ_FAILED                          339\n# define SSL_F_DTLS1_RETRANSMIT_MESSAGE                   390\n# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES                 268\n# define SSL_F_DTLS1_WRITE_BYTES                          545\n# define SSL_F_DTLSV1_LISTEN                              350\n# define SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC          371\n# define SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST        385\n# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE               370\n# define SSL_F_DTLS_PROCESS_HELLO_VERIFY                  386\n# define SSL_F_DTLS_RECORD_LAYER_NEW                      635\n# define SSL_F_DTLS_WAIT_FOR_DRY                          592\n# define SSL_F_EARLY_DATA_COUNT_OK                        532\n# define SSL_F_FINAL_EARLY_DATA                           556\n# define SSL_F_FINAL_EC_PT_FORMATS                        485\n# define SSL_F_FINAL_EMS                                  486\n# define SSL_F_FINAL_KEY_SHARE                            503\n# define SSL_F_FINAL_MAXFRAGMENTLEN                       557\n# define SSL_F_FINAL_PSK                                  639\n# define SSL_F_FINAL_RENEGOTIATE                          483\n# define SSL_F_FINAL_SERVER_NAME                          558\n# define SSL_F_FINAL_SIG_ALGS                             497\n# define SSL_F_GET_CERT_VERIFY_TBS_DATA                   588\n# define SSL_F_NSS_KEYLOG_INT                             500\n# define SSL_F_OPENSSL_INIT_SSL                           342\n# define SSL_F_OSSL_STATEM_CLIENT13_READ_TRANSITION       436\n# define SSL_F_OSSL_STATEM_CLIENT13_WRITE_TRANSITION      598\n# define SSL_F_OSSL_STATEM_CLIENT_CONSTRUCT_MESSAGE       430\n# define SSL_F_OSSL_STATEM_CLIENT_POST_PROCESS_MESSAGE    593\n# define SSL_F_OSSL_STATEM_CLIENT_PROCESS_MESSAGE         594\n# define SSL_F_OSSL_STATEM_CLIENT_READ_TRANSITION         417\n# define SSL_F_OSSL_STATEM_CLIENT_WRITE_TRANSITION        599\n# define SSL_F_OSSL_STATEM_SERVER13_READ_TRANSITION       437\n# define SSL_F_OSSL_STATEM_SERVER13_WRITE_TRANSITION      600\n# define SSL_F_OSSL_STATEM_SERVER_CONSTRUCT_MESSAGE       431\n# define SSL_F_OSSL_STATEM_SERVER_POST_PROCESS_MESSAGE    601\n# define SSL_F_OSSL_STATEM_SERVER_POST_WORK               602\n# define SSL_F_OSSL_STATEM_SERVER_PRE_WORK                640\n# define SSL_F_OSSL_STATEM_SERVER_PROCESS_MESSAGE         603\n# define SSL_F_OSSL_STATEM_SERVER_READ_TRANSITION         418\n# define SSL_F_OSSL_STATEM_SERVER_WRITE_TRANSITION        604\n# define SSL_F_PARSE_CA_NAMES                             541\n# define SSL_F_PITEM_NEW                                  624\n# define SSL_F_PQUEUE_NEW                                 625\n# define SSL_F_PROCESS_KEY_SHARE_EXT                      439\n# define SSL_F_READ_STATE_MACHINE                         352\n# define SSL_F_SET_CLIENT_CIPHERSUITE                     540\n# define SSL_F_SRP_GENERATE_CLIENT_MASTER_SECRET          595\n# define SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET          589\n# define SSL_F_SRP_VERIFY_SERVER_PARAM                    596\n# define SSL_F_SSL3_CHANGE_CIPHER_STATE                   129\n# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM              130\n# define SSL_F_SSL3_CTRL                                  213\n# define SSL_F_SSL3_CTX_CTRL                              133\n# define SSL_F_SSL3_DIGEST_CACHED_RECORDS                 293\n# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC                 292\n# define SSL_F_SSL3_ENC                                   608\n# define SSL_F_SSL3_FINAL_FINISH_MAC                      285\n# define SSL_F_SSL3_FINISH_MAC                            587\n# define SSL_F_SSL3_GENERATE_KEY_BLOCK                    238\n# define SSL_F_SSL3_GENERATE_MASTER_SECRET                388\n# define SSL_F_SSL3_GET_RECORD                            143\n# define SSL_F_SSL3_INIT_FINISHED_MAC                     397\n# define SSL_F_SSL3_OUTPUT_CERT_CHAIN                     147\n# define SSL_F_SSL3_READ_BYTES                            148\n# define SSL_F_SSL3_READ_N                                149\n# define SSL_F_SSL3_SETUP_KEY_BLOCK                       157\n# define SSL_F_SSL3_SETUP_READ_BUFFER                     156\n# define SSL_F_SSL3_SETUP_WRITE_BUFFER                    291\n# define SSL_F_SSL3_WRITE_BYTES                           158\n# define SSL_F_SSL3_WRITE_PENDING                         159\n# define SSL_F_SSL_ADD_CERT_CHAIN                         316\n# define SSL_F_SSL_ADD_CERT_TO_BUF                        319\n# define SSL_F_SSL_ADD_CERT_TO_WPACKET                    493\n# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT        298\n# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT                 277\n# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT           307\n# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK         215\n# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK        216\n# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT        299\n# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT                 278\n# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT           308\n# define SSL_F_SSL_BAD_METHOD                             160\n# define SSL_F_SSL_BUILD_CERT_CHAIN                       332\n# define SSL_F_SSL_BYTES_TO_CIPHER_LIST                   161\n# define SSL_F_SSL_CACHE_CIPHERLIST                       520\n# define SSL_F_SSL_CERT_ADD0_CHAIN_CERT                   346\n# define SSL_F_SSL_CERT_DUP                               221\n# define SSL_F_SSL_CERT_NEW                               162\n# define SSL_F_SSL_CERT_SET0_CHAIN                        340\n# define SSL_F_SSL_CHECK_PRIVATE_KEY                      163\n# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT               280\n# define SSL_F_SSL_CHECK_SRP_EXT_CLIENTHELLO              606\n# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG            279\n# define SSL_F_SSL_CHOOSE_CLIENT_VERSION                  607\n# define SSL_F_SSL_CIPHER_DESCRIPTION                     626\n# define SSL_F_SSL_CIPHER_LIST_TO_BYTES                   425\n# define SSL_F_SSL_CIPHER_PROCESS_RULESTR                 230\n# define SSL_F_SSL_CIPHER_STRENGTH_SORT                   231\n# define SSL_F_SSL_CLEAR                                  164\n# define SSL_F_SSL_CLIENT_HELLO_GET1_EXTENSIONS_PRESENT   627\n# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD            165\n# define SSL_F_SSL_CONF_CMD                               334\n# define SSL_F_SSL_CREATE_CIPHER_LIST                     166\n# define SSL_F_SSL_CTRL                                   232\n# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY                  168\n# define SSL_F_SSL_CTX_ENABLE_CT                          398\n# define SSL_F_SSL_CTX_MAKE_PROFILES                      309\n# define SSL_F_SSL_CTX_NEW                                169\n# define SSL_F_SSL_CTX_SET_ALPN_PROTOS                    343\n# define SSL_F_SSL_CTX_SET_CIPHER_LIST                    269\n# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE             290\n# define SSL_F_SSL_CTX_SET_CT_VALIDATION_CALLBACK         396\n# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT             219\n# define SSL_F_SSL_CTX_SET_SSL_VERSION                    170\n# define SSL_F_SSL_CTX_SET_TLSEXT_MAX_FRAGMENT_LENGTH     551\n# define SSL_F_SSL_CTX_USE_CERTIFICATE                    171\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1               172\n# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE               173\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY                     174\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1                175\n# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE                176\n# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT              272\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY                  177\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1             178\n# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE             179\n# define SSL_F_SSL_CTX_USE_SERVERINFO                     336\n# define SSL_F_SSL_CTX_USE_SERVERINFO_EX                  543\n# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE                337\n# define SSL_F_SSL_DANE_DUP                               403\n# define SSL_F_SSL_DANE_ENABLE                            395\n# define SSL_F_SSL_DERIVE                                 590\n# define SSL_F_SSL_DO_CONFIG                              391\n# define SSL_F_SSL_DO_HANDSHAKE                           180\n# define SSL_F_SSL_DUP_CA_LIST                            408\n# define SSL_F_SSL_ENABLE_CT                              402\n# define SSL_F_SSL_GENERATE_PKEY_GROUP                    559\n# define SSL_F_SSL_GENERATE_SESSION_ID                    547\n# define SSL_F_SSL_GET_NEW_SESSION                        181\n# define SSL_F_SSL_GET_PREV_SESSION                       217\n# define SSL_F_SSL_GET_SERVER_CERT_INDEX                  322\n# define SSL_F_SSL_GET_SIGN_PKEY                          183\n# define SSL_F_SSL_HANDSHAKE_HASH                         560\n# define SSL_F_SSL_INIT_WBIO_BUFFER                       184\n# define SSL_F_SSL_KEY_UPDATE                             515\n# define SSL_F_SSL_LOAD_CLIENT_CA_FILE                    185\n# define SSL_F_SSL_LOG_MASTER_SECRET                      498\n# define SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE            499\n# define SSL_F_SSL_MODULE_INIT                            392\n# define SSL_F_SSL_NEW                                    186\n# define SSL_F_SSL_NEXT_PROTO_VALIDATE                    565\n# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT      300\n# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT               302\n# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT         310\n# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT      301\n# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT               303\n# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT         311\n# define SSL_F_SSL_PEEK                                   270\n# define SSL_F_SSL_PEEK_EX                                432\n# define SSL_F_SSL_PEEK_INTERNAL                          522\n# define SSL_F_SSL_READ                                   223\n# define SSL_F_SSL_READ_EARLY_DATA                        529\n# define SSL_F_SSL_READ_EX                                434\n# define SSL_F_SSL_READ_INTERNAL                          523\n# define SSL_F_SSL_RENEGOTIATE                            516\n# define SSL_F_SSL_RENEGOTIATE_ABBREVIATED                546\n# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT                320\n# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT                321\n# define SSL_F_SSL_SESSION_DUP                            348\n# define SSL_F_SSL_SESSION_NEW                            189\n# define SSL_F_SSL_SESSION_PRINT_FP                       190\n# define SSL_F_SSL_SESSION_SET1_ID                        423\n# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT                312\n# define SSL_F_SSL_SET_ALPN_PROTOS                        344\n# define SSL_F_SSL_SET_CERT                               191\n# define SSL_F_SSL_SET_CERT_AND_KEY                       621\n# define SSL_F_SSL_SET_CIPHER_LIST                        271\n# define SSL_F_SSL_SET_CT_VALIDATION_CALLBACK             399\n# define SSL_F_SSL_SET_FD                                 192\n# define SSL_F_SSL_SET_PKEY                               193\n# define SSL_F_SSL_SET_RFD                                194\n# define SSL_F_SSL_SET_SESSION                            195\n# define SSL_F_SSL_SET_SESSION_ID_CONTEXT                 218\n# define SSL_F_SSL_SET_SESSION_TICKET_EXT                 294\n# define SSL_F_SSL_SET_TLSEXT_MAX_FRAGMENT_LENGTH         550\n# define SSL_F_SSL_SET_WFD                                196\n# define SSL_F_SSL_SHUTDOWN                               224\n# define SSL_F_SSL_SRP_CTX_INIT                           313\n# define SSL_F_SSL_START_ASYNC_JOB                        389\n# define SSL_F_SSL_UNDEFINED_FUNCTION                     197\n# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION                244\n# define SSL_F_SSL_USE_CERTIFICATE                        198\n# define SSL_F_SSL_USE_CERTIFICATE_ASN1                   199\n# define SSL_F_SSL_USE_CERTIFICATE_FILE                   200\n# define SSL_F_SSL_USE_PRIVATEKEY                         201\n# define SSL_F_SSL_USE_PRIVATEKEY_ASN1                    202\n# define SSL_F_SSL_USE_PRIVATEKEY_FILE                    203\n# define SSL_F_SSL_USE_PSK_IDENTITY_HINT                  273\n# define SSL_F_SSL_USE_RSAPRIVATEKEY                      204\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1                 205\n# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE                 206\n# define SSL_F_SSL_VALIDATE_CT                            400\n# define SSL_F_SSL_VERIFY_CERT_CHAIN                      207\n# define SSL_F_SSL_VERIFY_CLIENT_POST_HANDSHAKE           616\n# define SSL_F_SSL_WRITE                                  208\n# define SSL_F_SSL_WRITE_EARLY_DATA                       526\n# define SSL_F_SSL_WRITE_EARLY_FINISH                     527\n# define SSL_F_SSL_WRITE_EX                               433\n# define SSL_F_SSL_WRITE_INTERNAL                         524\n# define SSL_F_STATE_MACHINE                              353\n# define SSL_F_TLS12_CHECK_PEER_SIGALG                    333\n# define SSL_F_TLS12_COPY_SIGALGS                         533\n# define SSL_F_TLS13_CHANGE_CIPHER_STATE                  440\n# define SSL_F_TLS13_ENC                                  609\n# define SSL_F_TLS13_FINAL_FINISH_MAC                     605\n# define SSL_F_TLS13_GENERATE_SECRET                      591\n# define SSL_F_TLS13_HKDF_EXPAND                          561\n# define SSL_F_TLS13_RESTORE_HANDSHAKE_DIGEST_FOR_PHA     617\n# define SSL_F_TLS13_SAVE_HANDSHAKE_DIGEST_FOR_PHA        618\n# define SSL_F_TLS13_SETUP_KEY_BLOCK                      441\n# define SSL_F_TLS1_CHANGE_CIPHER_STATE                   209\n# define SSL_F_TLS1_CHECK_DUPLICATE_EXTENSIONS            341\n# define SSL_F_TLS1_ENC                                   401\n# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL                314\n# define SSL_F_TLS1_GET_CURVELIST                         338\n# define SSL_F_TLS1_PRF                                   284\n# define SSL_F_TLS1_SAVE_U16                              628\n# define SSL_F_TLS1_SETUP_KEY_BLOCK                       211\n# define SSL_F_TLS1_SET_GROUPS                            629\n# define SSL_F_TLS1_SET_RAW_SIGALGS                       630\n# define SSL_F_TLS1_SET_SERVER_SIGALGS                    335\n# define SSL_F_TLS1_SET_SHARED_SIGALGS                    631\n# define SSL_F_TLS1_SET_SIGALGS                           632\n# define SSL_F_TLS_CHOOSE_SIGALG                          513\n# define SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK          354\n# define SSL_F_TLS_COLLECT_EXTENSIONS                     435\n# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_AUTHORITIES      542\n# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST          372\n# define SSL_F_TLS_CONSTRUCT_CERT_STATUS                  429\n# define SSL_F_TLS_CONSTRUCT_CERT_STATUS_BODY             494\n# define SSL_F_TLS_CONSTRUCT_CERT_VERIFY                  496\n# define SSL_F_TLS_CONSTRUCT_CHANGE_CIPHER_SPEC           427\n# define SSL_F_TLS_CONSTRUCT_CKE_DHE                      404\n# define SSL_F_TLS_CONSTRUCT_CKE_ECDHE                    405\n# define SSL_F_TLS_CONSTRUCT_CKE_GOST                     406\n# define SSL_F_TLS_CONSTRUCT_CKE_PSK_PREAMBLE             407\n# define SSL_F_TLS_CONSTRUCT_CKE_RSA                      409\n# define SSL_F_TLS_CONSTRUCT_CKE_SRP                      410\n# define SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE           484\n# define SSL_F_TLS_CONSTRUCT_CLIENT_HELLO                 487\n# define SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE          488\n# define SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY                489\n# define SSL_F_TLS_CONSTRUCT_CTOS_ALPN                    466\n# define SSL_F_TLS_CONSTRUCT_CTOS_CERTIFICATE             355\n# define SSL_F_TLS_CONSTRUCT_CTOS_COOKIE                  535\n# define SSL_F_TLS_CONSTRUCT_CTOS_EARLY_DATA              530\n# define SSL_F_TLS_CONSTRUCT_CTOS_EC_PT_FORMATS           467\n# define SSL_F_TLS_CONSTRUCT_CTOS_EMS                     468\n# define SSL_F_TLS_CONSTRUCT_CTOS_ETM                     469\n# define SSL_F_TLS_CONSTRUCT_CTOS_HELLO                   356\n# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_EXCHANGE            357\n# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_SHARE               470\n# define SSL_F_TLS_CONSTRUCT_CTOS_MAXFRAGMENTLEN          549\n# define SSL_F_TLS_CONSTRUCT_CTOS_NPN                     471\n# define SSL_F_TLS_CONSTRUCT_CTOS_PADDING                 472\n# define SSL_F_TLS_CONSTRUCT_CTOS_POST_HANDSHAKE_AUTH     619\n# define SSL_F_TLS_CONSTRUCT_CTOS_PSK                     501\n# define SSL_F_TLS_CONSTRUCT_CTOS_PSK_KEX_MODES           509\n# define SSL_F_TLS_CONSTRUCT_CTOS_RENEGOTIATE             473\n# define SSL_F_TLS_CONSTRUCT_CTOS_SCT                     474\n# define SSL_F_TLS_CONSTRUCT_CTOS_SERVER_NAME             475\n# define SSL_F_TLS_CONSTRUCT_CTOS_SESSION_TICKET          476\n# define SSL_F_TLS_CONSTRUCT_CTOS_SIG_ALGS                477\n# define SSL_F_TLS_CONSTRUCT_CTOS_SRP                     478\n# define SSL_F_TLS_CONSTRUCT_CTOS_STATUS_REQUEST          479\n# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS        480\n# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_VERSIONS      481\n# define SSL_F_TLS_CONSTRUCT_CTOS_USE_SRTP                482\n# define SSL_F_TLS_CONSTRUCT_CTOS_VERIFY                  358\n# define SSL_F_TLS_CONSTRUCT_ENCRYPTED_EXTENSIONS         443\n# define SSL_F_TLS_CONSTRUCT_END_OF_EARLY_DATA            536\n# define SSL_F_TLS_CONSTRUCT_EXTENSIONS                   447\n# define SSL_F_TLS_CONSTRUCT_FINISHED                     359\n# define SSL_F_TLS_CONSTRUCT_HELLO_REQUEST                373\n# define SSL_F_TLS_CONSTRUCT_HELLO_RETRY_REQUEST          510\n# define SSL_F_TLS_CONSTRUCT_KEY_UPDATE                   517\n# define SSL_F_TLS_CONSTRUCT_NEW_SESSION_TICKET           428\n# define SSL_F_TLS_CONSTRUCT_NEXT_PROTO                   426\n# define SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE           490\n# define SSL_F_TLS_CONSTRUCT_SERVER_HELLO                 491\n# define SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE          492\n# define SSL_F_TLS_CONSTRUCT_STOC_ALPN                    451\n# define SSL_F_TLS_CONSTRUCT_STOC_CERTIFICATE             374\n# define SSL_F_TLS_CONSTRUCT_STOC_COOKIE                  613\n# define SSL_F_TLS_CONSTRUCT_STOC_CRYPTOPRO_BUG           452\n# define SSL_F_TLS_CONSTRUCT_STOC_DONE                    375\n# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA              531\n# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA_INFO         525\n# define SSL_F_TLS_CONSTRUCT_STOC_EC_PT_FORMATS           453\n# define SSL_F_TLS_CONSTRUCT_STOC_EMS                     454\n# define SSL_F_TLS_CONSTRUCT_STOC_ETM                     455\n# define SSL_F_TLS_CONSTRUCT_STOC_HELLO                   376\n# define SSL_F_TLS_CONSTRUCT_STOC_KEY_EXCHANGE            377\n# define SSL_F_TLS_CONSTRUCT_STOC_KEY_SHARE               456\n# define SSL_F_TLS_CONSTRUCT_STOC_MAXFRAGMENTLEN          548\n# define SSL_F_TLS_CONSTRUCT_STOC_NEXT_PROTO_NEG          457\n# define SSL_F_TLS_CONSTRUCT_STOC_PSK                     504\n# define SSL_F_TLS_CONSTRUCT_STOC_RENEGOTIATE             458\n# define SSL_F_TLS_CONSTRUCT_STOC_SERVER_NAME             459\n# define SSL_F_TLS_CONSTRUCT_STOC_SESSION_TICKET          460\n# define SSL_F_TLS_CONSTRUCT_STOC_STATUS_REQUEST          461\n# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_GROUPS        544\n# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_VERSIONS      611\n# define SSL_F_TLS_CONSTRUCT_STOC_USE_SRTP                462\n# define SSL_F_TLS_EARLY_POST_PROCESS_CLIENT_HELLO        521\n# define SSL_F_TLS_FINISH_HANDSHAKE                       597\n# define SSL_F_TLS_GET_MESSAGE_BODY                       351\n# define SSL_F_TLS_GET_MESSAGE_HEADER                     387\n# define SSL_F_TLS_HANDLE_ALPN                            562\n# define SSL_F_TLS_HANDLE_STATUS_REQUEST                  563\n# define SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES          566\n# define SSL_F_TLS_PARSE_CLIENTHELLO_TLSEXT               449\n# define SSL_F_TLS_PARSE_CTOS_ALPN                        567\n# define SSL_F_TLS_PARSE_CTOS_COOKIE                      614\n# define SSL_F_TLS_PARSE_CTOS_EARLY_DATA                  568\n# define SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS               569\n# define SSL_F_TLS_PARSE_CTOS_EMS                         570\n# define SSL_F_TLS_PARSE_CTOS_KEY_SHARE                   463\n# define SSL_F_TLS_PARSE_CTOS_MAXFRAGMENTLEN              571\n# define SSL_F_TLS_PARSE_CTOS_POST_HANDSHAKE_AUTH         620\n# define SSL_F_TLS_PARSE_CTOS_PSK                         505\n# define SSL_F_TLS_PARSE_CTOS_PSK_KEX_MODES               572\n# define SSL_F_TLS_PARSE_CTOS_RENEGOTIATE                 464\n# define SSL_F_TLS_PARSE_CTOS_SERVER_NAME                 573\n# define SSL_F_TLS_PARSE_CTOS_SESSION_TICKET              574\n# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS                    575\n# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS_CERT               615\n# define SSL_F_TLS_PARSE_CTOS_SRP                         576\n# define SSL_F_TLS_PARSE_CTOS_STATUS_REQUEST              577\n# define SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS            578\n# define SSL_F_TLS_PARSE_CTOS_USE_SRTP                    465\n# define SSL_F_TLS_PARSE_STOC_ALPN                        579\n# define SSL_F_TLS_PARSE_STOC_COOKIE                      534\n# define SSL_F_TLS_PARSE_STOC_EARLY_DATA                  538\n# define SSL_F_TLS_PARSE_STOC_EARLY_DATA_INFO             528\n# define SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS               580\n# define SSL_F_TLS_PARSE_STOC_KEY_SHARE                   445\n# define SSL_F_TLS_PARSE_STOC_MAXFRAGMENTLEN              581\n# define SSL_F_TLS_PARSE_STOC_NPN                         582\n# define SSL_F_TLS_PARSE_STOC_PSK                         502\n# define SSL_F_TLS_PARSE_STOC_RENEGOTIATE                 448\n# define SSL_F_TLS_PARSE_STOC_SCT                         564\n# define SSL_F_TLS_PARSE_STOC_SERVER_NAME                 583\n# define SSL_F_TLS_PARSE_STOC_SESSION_TICKET              584\n# define SSL_F_TLS_PARSE_STOC_STATUS_REQUEST              585\n# define SSL_F_TLS_PARSE_STOC_SUPPORTED_VERSIONS          612\n# define SSL_F_TLS_PARSE_STOC_USE_SRTP                    446\n# define SSL_F_TLS_POST_PROCESS_CLIENT_HELLO              378\n# define SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE       384\n# define SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE             360\n# define SSL_F_TLS_PROCESS_AS_HELLO_RETRY_REQUEST         610\n# define SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST            361\n# define SSL_F_TLS_PROCESS_CERT_STATUS                    362\n# define SSL_F_TLS_PROCESS_CERT_STATUS_BODY               495\n# define SSL_F_TLS_PROCESS_CERT_VERIFY                    379\n# define SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC             363\n# define SSL_F_TLS_PROCESS_CKE_DHE                        411\n# define SSL_F_TLS_PROCESS_CKE_ECDHE                      412\n# define SSL_F_TLS_PROCESS_CKE_GOST                       413\n# define SSL_F_TLS_PROCESS_CKE_PSK_PREAMBLE               414\n# define SSL_F_TLS_PROCESS_CKE_RSA                        415\n# define SSL_F_TLS_PROCESS_CKE_SRP                        416\n# define SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE             380\n# define SSL_F_TLS_PROCESS_CLIENT_HELLO                   381\n# define SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE            382\n# define SSL_F_TLS_PROCESS_ENCRYPTED_EXTENSIONS           444\n# define SSL_F_TLS_PROCESS_END_OF_EARLY_DATA              537\n# define SSL_F_TLS_PROCESS_FINISHED                       364\n# define SSL_F_TLS_PROCESS_HELLO_REQ                      507\n# define SSL_F_TLS_PROCESS_HELLO_RETRY_REQUEST            511\n# define SSL_F_TLS_PROCESS_INITIAL_SERVER_FLIGHT          442\n# define SSL_F_TLS_PROCESS_KEY_EXCHANGE                   365\n# define SSL_F_TLS_PROCESS_KEY_UPDATE                     518\n# define SSL_F_TLS_PROCESS_NEW_SESSION_TICKET             366\n# define SSL_F_TLS_PROCESS_NEXT_PROTO                     383\n# define SSL_F_TLS_PROCESS_SERVER_CERTIFICATE             367\n# define SSL_F_TLS_PROCESS_SERVER_DONE                    368\n# define SSL_F_TLS_PROCESS_SERVER_HELLO                   369\n# define SSL_F_TLS_PROCESS_SKE_DHE                        419\n# define SSL_F_TLS_PROCESS_SKE_ECDHE                      420\n# define SSL_F_TLS_PROCESS_SKE_PSK_PREAMBLE               421\n# define SSL_F_TLS_PROCESS_SKE_SRP                        422\n# define SSL_F_TLS_PSK_DO_BINDER                          506\n# define SSL_F_TLS_SCAN_CLIENTHELLO_TLSEXT                450\n# define SSL_F_TLS_SETUP_HANDSHAKE                        508\n# define SSL_F_USE_CERTIFICATE_CHAIN_FILE                 220\n# define SSL_F_WPACKET_INTERN_INIT_LEN                    633\n# define SSL_F_WPACKET_START_SUB_PACKET_LEN__             634\n# define SSL_F_WRITE_STATE_MACHINE                        586\n\n/*\n * SSL reason codes.\n */\n# define SSL_R_APPLICATION_DATA_AFTER_CLOSE_NOTIFY        291\n# define SSL_R_APP_DATA_IN_HANDSHAKE                      100\n# define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272\n# define SSL_R_AT_LEAST_TLS_1_0_NEEDED_IN_FIPS_MODE       143\n# define SSL_R_AT_LEAST_TLS_1_2_NEEDED_IN_SUITEB_MODE     158\n# define SSL_R_BAD_CHANGE_CIPHER_SPEC                     103\n# define SSL_R_BAD_CIPHER                                 186\n# define SSL_R_BAD_DATA                                   390\n# define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK              106\n# define SSL_R_BAD_DECOMPRESSION                          107\n# define SSL_R_BAD_DH_VALUE                               102\n# define SSL_R_BAD_DIGEST_LENGTH                          111\n# define SSL_R_BAD_EARLY_DATA                             233\n# define SSL_R_BAD_ECC_CERT                               304\n# define SSL_R_BAD_ECPOINT                                306\n# define SSL_R_BAD_EXTENSION                              110\n# define SSL_R_BAD_HANDSHAKE_LENGTH                       332\n# define SSL_R_BAD_HANDSHAKE_STATE                        236\n# define SSL_R_BAD_HELLO_REQUEST                          105\n# define SSL_R_BAD_HRR_VERSION                            263\n# define SSL_R_BAD_KEY_SHARE                              108\n# define SSL_R_BAD_KEY_UPDATE                             122\n# define SSL_R_BAD_LEGACY_VERSION                         292\n# define SSL_R_BAD_LENGTH                                 271\n# define SSL_R_BAD_PACKET                                 240\n# define SSL_R_BAD_PACKET_LENGTH                          115\n# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER                116\n# define SSL_R_BAD_PSK                                    219\n# define SSL_R_BAD_PSK_IDENTITY                           114\n# define SSL_R_BAD_RECORD_TYPE                            443\n# define SSL_R_BAD_RSA_ENCRYPT                            119\n# define SSL_R_BAD_SIGNATURE                              123\n# define SSL_R_BAD_SRP_A_LENGTH                           347\n# define SSL_R_BAD_SRP_PARAMETERS                         371\n# define SSL_R_BAD_SRTP_MKI_VALUE                         352\n# define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST           353\n# define SSL_R_BAD_SSL_FILETYPE                           124\n# define SSL_R_BAD_VALUE                                  384\n# define SSL_R_BAD_WRITE_RETRY                            127\n# define SSL_R_BINDER_DOES_NOT_VERIFY                     253\n# define SSL_R_BIO_NOT_SET                                128\n# define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG                  129\n# define SSL_R_BN_LIB                                     130\n# define SSL_R_CALLBACK_FAILED                            234\n# define SSL_R_CANNOT_CHANGE_CIPHER                       109\n# define SSL_R_CA_DN_LENGTH_MISMATCH                      131\n# define SSL_R_CA_KEY_TOO_SMALL                           397\n# define SSL_R_CA_MD_TOO_WEAK                             398\n# define SSL_R_CCS_RECEIVED_EARLY                         133\n# define SSL_R_CERTIFICATE_VERIFY_FAILED                  134\n# define SSL_R_CERT_CB_ERROR                              377\n# define SSL_R_CERT_LENGTH_MISMATCH                       135\n# define SSL_R_CIPHERSUITE_DIGEST_HAS_CHANGED             218\n# define SSL_R_CIPHER_CODE_WRONG_LENGTH                   137\n# define SSL_R_CIPHER_OR_HASH_UNAVAILABLE                 138\n# define SSL_R_CLIENTHELLO_TLSEXT                         226\n# define SSL_R_COMPRESSED_LENGTH_TOO_LONG                 140\n# define SSL_R_COMPRESSION_DISABLED                       343\n# define SSL_R_COMPRESSION_FAILURE                        141\n# define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE    307\n# define SSL_R_COMPRESSION_LIBRARY_ERROR                  142\n# define SSL_R_CONNECTION_TYPE_NOT_SET                    144\n# define SSL_R_CONTEXT_NOT_DANE_ENABLED                   167\n# define SSL_R_COOKIE_GEN_CALLBACK_FAILURE                400\n# define SSL_R_COOKIE_MISMATCH                            308\n# define SSL_R_CUSTOM_EXT_HANDLER_ALREADY_INSTALLED       206\n# define SSL_R_DANE_ALREADY_ENABLED                       172\n# define SSL_R_DANE_CANNOT_OVERRIDE_MTYPE_FULL            173\n# define SSL_R_DANE_NOT_ENABLED                           175\n# define SSL_R_DANE_TLSA_BAD_CERTIFICATE                  180\n# define SSL_R_DANE_TLSA_BAD_CERTIFICATE_USAGE            184\n# define SSL_R_DANE_TLSA_BAD_DATA_LENGTH                  189\n# define SSL_R_DANE_TLSA_BAD_DIGEST_LENGTH                192\n# define SSL_R_DANE_TLSA_BAD_MATCHING_TYPE                200\n# define SSL_R_DANE_TLSA_BAD_PUBLIC_KEY                   201\n# define SSL_R_DANE_TLSA_BAD_SELECTOR                     202\n# define SSL_R_DANE_TLSA_NULL_DATA                        203\n# define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED              145\n# define SSL_R_DATA_LENGTH_TOO_LONG                       146\n# define SSL_R_DECRYPTION_FAILED                          147\n# define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC        281\n# define SSL_R_DH_KEY_TOO_SMALL                           394\n# define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG            148\n# define SSL_R_DIGEST_CHECK_FAILED                        149\n# define SSL_R_DTLS_MESSAGE_TOO_BIG                       334\n# define SSL_R_DUPLICATE_COMPRESSION_ID                   309\n# define SSL_R_ECC_CERT_NOT_FOR_SIGNING                   318\n# define SSL_R_ECDH_REQUIRED_FOR_SUITEB_MODE              374\n# define SSL_R_EE_KEY_TOO_SMALL                           399\n# define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST         354\n# define SSL_R_ENCRYPTED_LENGTH_TOO_LONG                  150\n# define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST              151\n# define SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN             204\n# define SSL_R_EXCEEDS_MAX_FRAGMENT_SIZE                  194\n# define SSL_R_EXCESSIVE_MESSAGE_SIZE                     152\n# define SSL_R_EXTENSION_NOT_RECEIVED                     279\n# define SSL_R_EXTRA_DATA_IN_MESSAGE                      153\n# define SSL_R_EXT_LENGTH_MISMATCH                        163\n# define SSL_R_FAILED_TO_INIT_ASYNC                       405\n# define SSL_R_FRAGMENTED_CLIENT_HELLO                    401\n# define SSL_R_GOT_A_FIN_BEFORE_A_CCS                     154\n# define SSL_R_HTTPS_PROXY_REQUEST                        155\n# define SSL_R_HTTP_REQUEST                               156\n# define SSL_R_ILLEGAL_POINT_COMPRESSION                  162\n# define SSL_R_ILLEGAL_SUITEB_DIGEST                      380\n# define SSL_R_INAPPROPRIATE_FALLBACK                     373\n# define SSL_R_INCONSISTENT_COMPRESSION                   340\n# define SSL_R_INCONSISTENT_EARLY_DATA_ALPN               222\n# define SSL_R_INCONSISTENT_EARLY_DATA_SNI                231\n# define SSL_R_INCONSISTENT_EXTMS                         104\n# define SSL_R_INSUFFICIENT_SECURITY                      241\n# define SSL_R_INVALID_ALERT                              205\n# define SSL_R_INVALID_CCS_MESSAGE                        260\n# define SSL_R_INVALID_CERTIFICATE_OR_ALG                 238\n# define SSL_R_INVALID_COMMAND                            280\n# define SSL_R_INVALID_COMPRESSION_ALGORITHM              341\n# define SSL_R_INVALID_CONFIG                             283\n# define SSL_R_INVALID_CONFIGURATION_NAME                 113\n# define SSL_R_INVALID_CONTEXT                            282\n# define SSL_R_INVALID_CT_VALIDATION_TYPE                 212\n# define SSL_R_INVALID_KEY_UPDATE_TYPE                    120\n# define SSL_R_INVALID_MAX_EARLY_DATA                     174\n# define SSL_R_INVALID_NULL_CMD_NAME                      385\n# define SSL_R_INVALID_SEQUENCE_NUMBER                    402\n# define SSL_R_INVALID_SERVERINFO_DATA                    388\n# define SSL_R_INVALID_SESSION_ID                         999\n# define SSL_R_INVALID_SRP_USERNAME                       357\n# define SSL_R_INVALID_STATUS_RESPONSE                    328\n# define SSL_R_INVALID_TICKET_KEYS_LENGTH                 325\n# define SSL_R_LENGTH_MISMATCH                            159\n# define SSL_R_LENGTH_TOO_LONG                            404\n# define SSL_R_LENGTH_TOO_SHORT                           160\n# define SSL_R_LIBRARY_BUG                                274\n# define SSL_R_LIBRARY_HAS_NO_CIPHERS                     161\n# define SSL_R_MISSING_DSA_SIGNING_CERT                   165\n# define SSL_R_MISSING_ECDSA_SIGNING_CERT                 381\n# define SSL_R_MISSING_FATAL                              256\n# define SSL_R_MISSING_PARAMETERS                         290\n# define SSL_R_MISSING_PSK_KEX_MODES_EXTENSION            310\n# define SSL_R_MISSING_RSA_CERTIFICATE                    168\n# define SSL_R_MISSING_RSA_ENCRYPTING_CERT                169\n# define SSL_R_MISSING_RSA_SIGNING_CERT                   170\n# define SSL_R_MISSING_SIGALGS_EXTENSION                  112\n# define SSL_R_MISSING_SIGNING_CERT                       221\n# define SSL_R_MISSING_SRP_PARAM                          358\n# define SSL_R_MISSING_SUPPORTED_GROUPS_EXTENSION         209\n# define SSL_R_MISSING_TMP_DH_KEY                         171\n# define SSL_R_MISSING_TMP_ECDH_KEY                       311\n# define SSL_R_MIXED_HANDSHAKE_AND_NON_HANDSHAKE_DATA     293\n# define SSL_R_NOT_ON_RECORD_BOUNDARY                     182\n# define SSL_R_NOT_REPLACING_CERTIFICATE                  289\n# define SSL_R_NOT_SERVER                                 284\n# define SSL_R_NO_APPLICATION_PROTOCOL                    235\n# define SSL_R_NO_CERTIFICATES_RETURNED                   176\n# define SSL_R_NO_CERTIFICATE_ASSIGNED                    177\n# define SSL_R_NO_CERTIFICATE_SET                         179\n# define SSL_R_NO_CHANGE_FOLLOWING_HRR                    214\n# define SSL_R_NO_CIPHERS_AVAILABLE                       181\n# define SSL_R_NO_CIPHERS_SPECIFIED                       183\n# define SSL_R_NO_CIPHER_MATCH                            185\n# define SSL_R_NO_CLIENT_CERT_METHOD                      331\n# define SSL_R_NO_COMPRESSION_SPECIFIED                   187\n# define SSL_R_NO_COOKIE_CALLBACK_SET                     287\n# define SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER           330\n# define SSL_R_NO_METHOD_SPECIFIED                        188\n# define SSL_R_NO_PEM_EXTENSIONS                          389\n# define SSL_R_NO_PRIVATE_KEY_ASSIGNED                    190\n# define SSL_R_NO_PROTOCOLS_AVAILABLE                     191\n# define SSL_R_NO_RENEGOTIATION                           339\n# define SSL_R_NO_REQUIRED_DIGEST                         324\n# define SSL_R_NO_SHARED_CIPHER                           193\n# define SSL_R_NO_SHARED_GROUPS                           410\n# define SSL_R_NO_SHARED_SIGNATURE_ALGORITHMS             376\n# define SSL_R_NO_SRTP_PROFILES                           359\n# define SSL_R_NO_SUITABLE_KEY_SHARE                      101\n# define SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM            118\n# define SSL_R_NO_VALID_SCTS                              216\n# define SSL_R_NO_VERIFY_COOKIE_CALLBACK                  403\n# define SSL_R_NULL_SSL_CTX                               195\n# define SSL_R_NULL_SSL_METHOD_PASSED                     196\n# define SSL_R_OCSP_CALLBACK_FAILURE                      294\n# define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED            197\n# define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344\n# define SSL_R_OVERFLOW_ERROR                             237\n# define SSL_R_PACKET_LENGTH_TOO_LONG                     198\n# define SSL_R_PARSE_TLSEXT                               227\n# define SSL_R_PATH_TOO_LONG                              270\n# define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE          199\n# define SSL_R_PEM_NAME_BAD_PREFIX                        391\n# define SSL_R_PEM_NAME_TOO_SHORT                         392\n# define SSL_R_PIPELINE_FAILURE                           406\n# define SSL_R_POST_HANDSHAKE_AUTH_ENCODING_ERR           278\n# define SSL_R_PRIVATE_KEY_MISMATCH                       288\n# define SSL_R_PROTOCOL_IS_SHUTDOWN                       207\n# define SSL_R_PSK_IDENTITY_NOT_FOUND                     223\n# define SSL_R_PSK_NO_CLIENT_CB                           224\n# define SSL_R_PSK_NO_SERVER_CB                           225\n# define SSL_R_READ_BIO_NOT_SET                           211\n# define SSL_R_READ_TIMEOUT_EXPIRED                       312\n# define SSL_R_RECORD_LENGTH_MISMATCH                     213\n# define SSL_R_RECORD_TOO_SMALL                           298\n# define SSL_R_RENEGOTIATE_EXT_TOO_LONG                   335\n# define SSL_R_RENEGOTIATION_ENCODING_ERR                 336\n# define SSL_R_RENEGOTIATION_MISMATCH                     337\n# define SSL_R_REQUEST_PENDING                            285\n# define SSL_R_REQUEST_SENT                               286\n# define SSL_R_REQUIRED_CIPHER_MISSING                    215\n# define SSL_R_REQUIRED_COMPRESSION_ALGORITHM_MISSING     342\n# define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING           345\n# define SSL_R_SCT_VERIFICATION_FAILED                    208\n# define SSL_R_SERVERHELLO_TLSEXT                         275\n# define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED           277\n# define SSL_R_SHUTDOWN_WHILE_IN_INIT                     407\n# define SSL_R_SIGNATURE_ALGORITHMS_ERROR                 360\n# define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE      220\n# define SSL_R_SRP_A_CALC                                 361\n# define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES           362\n# define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG      363\n# define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE            364\n# define SSL_R_SSL3_EXT_INVALID_MAX_FRAGMENT_LENGTH       232\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME                319\n# define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE           320\n# define SSL_R_SSL3_SESSION_ID_TOO_LONG                   300\n# define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE                1042\n# define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC                 1020\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED            1045\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED            1044\n# define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN            1046\n# define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE          1030\n# define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE              1040\n# define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER              1047\n# define SSL_R_SSLV3_ALERT_NO_CERTIFICATE                 1041\n# define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE             1010\n# define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE        1043\n# define SSL_R_SSL_COMMAND_SECTION_EMPTY                  117\n# define SSL_R_SSL_COMMAND_SECTION_NOT_FOUND              125\n# define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION         228\n# define SSL_R_SSL_HANDSHAKE_FAILURE                      229\n# define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS                 230\n# define SSL_R_SSL_NEGATIVE_LENGTH                        372\n# define SSL_R_SSL_SECTION_EMPTY                          126\n# define SSL_R_SSL_SECTION_NOT_FOUND                      136\n# define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED             301\n# define SSL_R_SSL_SESSION_ID_CONFLICT                    302\n# define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG            273\n# define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH              303\n# define SSL_R_SSL_SESSION_ID_TOO_LONG                    408\n# define SSL_R_SSL_SESSION_VERSION_MISMATCH               210\n# define SSL_R_STILL_IN_INIT                              121\n# define SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED          1116\n# define SSL_R_TLSV13_ALERT_MISSING_EXTENSION             1109\n# define SSL_R_TLSV1_ALERT_ACCESS_DENIED                  1049\n# define SSL_R_TLSV1_ALERT_DECODE_ERROR                   1050\n# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED              1021\n# define SSL_R_TLSV1_ALERT_DECRYPT_ERROR                  1051\n# define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION             1060\n# define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK         1086\n# define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY          1071\n# define SSL_R_TLSV1_ALERT_INTERNAL_ERROR                 1080\n# define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION               1100\n# define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION               1070\n# define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW                1022\n# define SSL_R_TLSV1_ALERT_UNKNOWN_CA                     1048\n# define SSL_R_TLSV1_ALERT_USER_CANCELLED                 1090\n# define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE           1114\n# define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE      1113\n# define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE             1111\n# define SSL_R_TLSV1_UNRECOGNIZED_NAME                    1112\n# define SSL_R_TLSV1_UNSUPPORTED_EXTENSION                1110\n# define SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT           365\n# define SSL_R_TLS_HEARTBEAT_PENDING                      366\n# define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL                 367\n# define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST             157\n# define SSL_R_TOO_MANY_KEY_UPDATES                       132\n# define SSL_R_TOO_MANY_WARN_ALERTS                       409\n# define SSL_R_TOO_MUCH_EARLY_DATA                        164\n# define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS             314\n# define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS       239\n# define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES           242\n# define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES          243\n# define SSL_R_UNEXPECTED_CCS_MESSAGE                     262\n# define SSL_R_UNEXPECTED_END_OF_EARLY_DATA               178\n# define SSL_R_UNEXPECTED_MESSAGE                         244\n# define SSL_R_UNEXPECTED_RECORD                          245\n# define SSL_R_UNINITIALIZED                              276\n# define SSL_R_UNKNOWN_ALERT_TYPE                         246\n# define SSL_R_UNKNOWN_CERTIFICATE_TYPE                   247\n# define SSL_R_UNKNOWN_CIPHER_RETURNED                    248\n# define SSL_R_UNKNOWN_CIPHER_TYPE                        249\n# define SSL_R_UNKNOWN_CMD_NAME                           386\n# define SSL_R_UNKNOWN_COMMAND                            139\n# define SSL_R_UNKNOWN_DIGEST                             368\n# define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE                  250\n# define SSL_R_UNKNOWN_PKEY_TYPE                          251\n# define SSL_R_UNKNOWN_PROTOCOL                           252\n# define SSL_R_UNKNOWN_SSL_VERSION                        254\n# define SSL_R_UNKNOWN_STATE                              255\n# define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED       338\n# define SSL_R_UNSOLICITED_EXTENSION                      217\n# define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM          257\n# define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE                 315\n# define SSL_R_UNSUPPORTED_PROTOCOL                       258\n# define SSL_R_UNSUPPORTED_SSL_VERSION                    259\n# define SSL_R_UNSUPPORTED_STATUS_TYPE                    329\n# define SSL_R_USE_SRTP_NOT_NEGOTIATED                    369\n# define SSL_R_VERSION_TOO_HIGH                           166\n# define SSL_R_VERSION_TOO_LOW                            396\n# define SSL_R_WRONG_CERTIFICATE_TYPE                     383\n# define SSL_R_WRONG_CIPHER_RETURNED                      261\n# define SSL_R_WRONG_CURVE                                378\n# define SSL_R_WRONG_SIGNATURE_LENGTH                     264\n# define SSL_R_WRONG_SIGNATURE_SIZE                       265\n# define SSL_R_WRONG_SIGNATURE_TYPE                       370\n# define SSL_R_WRONG_SSL_VERSION                          266\n# define SSL_R_WRONG_VERSION_NUMBER                       267\n# define SSL_R_X509_LIB                                   268\n# define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS           269\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/stack.h",
    "content": "/*\n * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_STACK_H\n# define HEADER_STACK_H\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct stack_st OPENSSL_STACK; /* Use STACK_OF(...) instead */\n\ntypedef int (*OPENSSL_sk_compfunc)(const void *, const void *);\ntypedef void (*OPENSSL_sk_freefunc)(void *);\ntypedef void *(*OPENSSL_sk_copyfunc)(const void *);\n\nint OPENSSL_sk_num(const OPENSSL_STACK *);\nvoid *OPENSSL_sk_value(const OPENSSL_STACK *, int);\n\nvoid *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data);\n\nOPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp);\nOPENSSL_STACK *OPENSSL_sk_new_null(void);\nOPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n);\nint OPENSSL_sk_reserve(OPENSSL_STACK *st, int n);\nvoid OPENSSL_sk_free(OPENSSL_STACK *);\nvoid OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *));\nOPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *,\n                                    OPENSSL_sk_copyfunc c,\n                                    OPENSSL_sk_freefunc f);\nint OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where);\nvoid *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc);\nvoid *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p);\nint OPENSSL_sk_find(OPENSSL_STACK *st, const void *data);\nint OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data);\nint OPENSSL_sk_push(OPENSSL_STACK *st, const void *data);\nint OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data);\nvoid *OPENSSL_sk_shift(OPENSSL_STACK *st);\nvoid *OPENSSL_sk_pop(OPENSSL_STACK *st);\nvoid OPENSSL_sk_zero(OPENSSL_STACK *st);\nOPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk,\n                                            OPENSSL_sk_compfunc cmp);\nOPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st);\nvoid OPENSSL_sk_sort(OPENSSL_STACK *st);\nint OPENSSL_sk_is_sorted(const OPENSSL_STACK *st);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define _STACK OPENSSL_STACK\n#  define sk_num OPENSSL_sk_num\n#  define sk_value OPENSSL_sk_value\n#  define sk_set OPENSSL_sk_set\n#  define sk_new OPENSSL_sk_new\n#  define sk_new_null OPENSSL_sk_new_null\n#  define sk_free OPENSSL_sk_free\n#  define sk_pop_free OPENSSL_sk_pop_free\n#  define sk_deep_copy OPENSSL_sk_deep_copy\n#  define sk_insert OPENSSL_sk_insert\n#  define sk_delete OPENSSL_sk_delete\n#  define sk_delete_ptr OPENSSL_sk_delete_ptr\n#  define sk_find OPENSSL_sk_find\n#  define sk_find_ex OPENSSL_sk_find_ex\n#  define sk_push OPENSSL_sk_push\n#  define sk_unshift OPENSSL_sk_unshift\n#  define sk_shift OPENSSL_sk_shift\n#  define sk_pop OPENSSL_sk_pop\n#  define sk_zero OPENSSL_sk_zero\n#  define sk_set_cmp_func OPENSSL_sk_set_cmp_func\n#  define sk_dup OPENSSL_sk_dup\n#  define sk_sort OPENSSL_sk_sort\n#  define sk_is_sorted OPENSSL_sk_is_sorted\n# endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/store.h",
    "content": "/*\n * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OSSL_STORE_H\n# define HEADER_OSSL_STORE_H\n\n# include <stdarg.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/pem.h>\n# include <openssl/storeerr.h>\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*-\n *  The main OSSL_STORE functions.\n *  ------------------------------\n *\n *  These allow applications to open a channel to a resource with supported\n *  data (keys, certs, crls, ...), read the data a piece at a time and decide\n *  what to do with it, and finally close.\n */\n\ntypedef struct ossl_store_ctx_st OSSL_STORE_CTX;\n\n/*\n * Typedef for the OSSL_STORE_INFO post processing callback.  This can be used\n * to massage the given OSSL_STORE_INFO, or to drop it entirely (by returning\n * NULL).\n */\ntypedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *,\n                                                            void *);\n\n/*\n * Open a channel given a URI.  The given UI method will be used any time the\n * loader needs extra input, for example when a password or pin is needed, and\n * will be passed the same user data every time it's needed in this context.\n *\n * Returns a context reference which represents the channel to communicate\n * through.\n */\nOSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method,\n                                void *ui_data,\n                                OSSL_STORE_post_process_info_fn post_process,\n                                void *post_process_data);\n\n/*\n * Control / fine tune the OSSL_STORE channel.  |cmd| determines what is to be\n * done, and depends on the underlying loader (use OSSL_STORE_get0_scheme to\n * determine which loader is used), except for common commands (see below).\n * Each command takes different arguments.\n */\nint OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, ... /* args */);\nint OSSL_STORE_vctrl(OSSL_STORE_CTX *ctx, int cmd, va_list args);\n\n/*\n * Common ctrl commands that different loaders may choose to support.\n */\n/* int on = 0 or 1; STORE_ctrl(ctx, STORE_C_USE_SECMEM, &on); */\n# define OSSL_STORE_C_USE_SECMEM      1\n/* Where custom commands start */\n# define OSSL_STORE_C_CUSTOM_START    100\n\n/*\n * Read one data item (a key, a cert, a CRL) that is supported by the OSSL_STORE\n * functionality, given a context.\n * Returns a OSSL_STORE_INFO pointer, from which OpenSSL typed data can be\n * extracted with OSSL_STORE_INFO_get0_PKEY(), OSSL_STORE_INFO_get0_CERT(), ...\n * NULL is returned on error, which may include that the data found at the URI\n * can't be figured out for certain or is ambiguous.\n */\nOSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx);\n\n/*\n * Check if end of data (end of file) is reached\n * Returns 1 on end, 0 otherwise.\n */\nint OSSL_STORE_eof(OSSL_STORE_CTX *ctx);\n\n/*\n * Check if an error occurred\n * Returns 1 if it did, 0 otherwise.\n */\nint OSSL_STORE_error(OSSL_STORE_CTX *ctx);\n\n/*\n * Close the channel\n * Returns 1 on success, 0 on error.\n */\nint OSSL_STORE_close(OSSL_STORE_CTX *ctx);\n\n\n/*-\n *  Extracting OpenSSL types from and creating new OSSL_STORE_INFOs\n *  ---------------------------------------------------------------\n */\n\n/*\n * Types of data that can be ossl_stored in a OSSL_STORE_INFO.\n * OSSL_STORE_INFO_NAME is typically found when getting a listing of\n * available \"files\" / \"tokens\" / what have you.\n */\n# define OSSL_STORE_INFO_NAME           1   /* char * */\n# define OSSL_STORE_INFO_PARAMS         2   /* EVP_PKEY * */\n# define OSSL_STORE_INFO_PKEY           3   /* EVP_PKEY * */\n# define OSSL_STORE_INFO_CERT           4   /* X509 * */\n# define OSSL_STORE_INFO_CRL            5   /* X509_CRL * */\n\n/*\n * Functions to generate OSSL_STORE_INFOs, one function for each type we\n * support having in them, as well as a generic constructor.\n *\n * In all cases, ownership of the object is transferred to the OSSL_STORE_INFO\n * and will therefore be freed when the OSSL_STORE_INFO is freed.\n */\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_NAME(char *name);\nint OSSL_STORE_INFO_set0_NAME_description(OSSL_STORE_INFO *info, char *desc);\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_PARAMS(EVP_PKEY *params);\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_PKEY(EVP_PKEY *pkey);\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_CERT(X509 *x509);\nOSSL_STORE_INFO *OSSL_STORE_INFO_new_CRL(X509_CRL *crl);\n\n/*\n * Functions to try to extract data from a OSSL_STORE_INFO.\n */\nint OSSL_STORE_INFO_get_type(const OSSL_STORE_INFO *info);\nconst char *OSSL_STORE_INFO_get0_NAME(const OSSL_STORE_INFO *info);\nchar *OSSL_STORE_INFO_get1_NAME(const OSSL_STORE_INFO *info);\nconst char *OSSL_STORE_INFO_get0_NAME_description(const OSSL_STORE_INFO *info);\nchar *OSSL_STORE_INFO_get1_NAME_description(const OSSL_STORE_INFO *info);\nEVP_PKEY *OSSL_STORE_INFO_get0_PARAMS(const OSSL_STORE_INFO *info);\nEVP_PKEY *OSSL_STORE_INFO_get1_PARAMS(const OSSL_STORE_INFO *info);\nEVP_PKEY *OSSL_STORE_INFO_get0_PKEY(const OSSL_STORE_INFO *info);\nEVP_PKEY *OSSL_STORE_INFO_get1_PKEY(const OSSL_STORE_INFO *info);\nX509 *OSSL_STORE_INFO_get0_CERT(const OSSL_STORE_INFO *info);\nX509 *OSSL_STORE_INFO_get1_CERT(const OSSL_STORE_INFO *info);\nX509_CRL *OSSL_STORE_INFO_get0_CRL(const OSSL_STORE_INFO *info);\nX509_CRL *OSSL_STORE_INFO_get1_CRL(const OSSL_STORE_INFO *info);\n\nconst char *OSSL_STORE_INFO_type_string(int type);\n\n/*\n * Free the OSSL_STORE_INFO\n */\nvoid OSSL_STORE_INFO_free(OSSL_STORE_INFO *info);\n\n\n/*-\n *  Functions to construct a search URI from a base URI and search criteria\n *  -----------------------------------------------------------------------\n */\n\n/* OSSL_STORE search types */\n# define OSSL_STORE_SEARCH_BY_NAME              1 /* subject in certs, issuer in CRLs */\n# define OSSL_STORE_SEARCH_BY_ISSUER_SERIAL     2\n# define OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT   3\n# define OSSL_STORE_SEARCH_BY_ALIAS             4\n\n/* To check what search types the scheme handler supports */\nint OSSL_STORE_supports_search(OSSL_STORE_CTX *ctx, int search_type);\n\n/* Search term constructors */\n/*\n * The input is considered to be owned by the caller, and must therefore\n * remain present throughout the lifetime of the returned OSSL_STORE_SEARCH\n */\nOSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_name(X509_NAME *name);\nOSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_issuer_serial(X509_NAME *name,\n                                                      const ASN1_INTEGER\n                                                      *serial);\nOSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_key_fingerprint(const EVP_MD *digest,\n                                                        const unsigned char\n                                                        *bytes, size_t len);\nOSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_alias(const char *alias);\n\n/* Search term destructor */\nvoid OSSL_STORE_SEARCH_free(OSSL_STORE_SEARCH *search);\n\n/* Search term accessors */\nint OSSL_STORE_SEARCH_get_type(const OSSL_STORE_SEARCH *criterion);\nX509_NAME *OSSL_STORE_SEARCH_get0_name(OSSL_STORE_SEARCH *criterion);\nconst ASN1_INTEGER *OSSL_STORE_SEARCH_get0_serial(const OSSL_STORE_SEARCH\n                                                  *criterion);\nconst unsigned char *OSSL_STORE_SEARCH_get0_bytes(const OSSL_STORE_SEARCH\n                                                  *criterion, size_t *length);\nconst char *OSSL_STORE_SEARCH_get0_string(const OSSL_STORE_SEARCH *criterion);\nconst EVP_MD *OSSL_STORE_SEARCH_get0_digest(const OSSL_STORE_SEARCH *criterion);\n\n/*\n * Add search criterion and expected return type (which can be unspecified)\n * to the loading channel.  This MUST happen before the first OSSL_STORE_load().\n */\nint OSSL_STORE_expect(OSSL_STORE_CTX *ctx, int expected_type);\nint OSSL_STORE_find(OSSL_STORE_CTX *ctx, OSSL_STORE_SEARCH *search);\n\n\n/*-\n *  Function to register a loader for the given URI scheme.\n *  -------------------------------------------------------\n *\n *  The loader receives all the main components of an URI except for the\n *  scheme.\n */\n\ntypedef struct ossl_store_loader_st OSSL_STORE_LOADER;\nOSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme);\nconst ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER *loader);\nconst char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER *loader);\n/* struct ossl_store_loader_ctx_st is defined differently by each loader */\ntypedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX;\ntypedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn)(const OSSL_STORE_LOADER\n                                                     *loader,\n                                                     const char *uri,\n                                                     const UI_METHOD *ui_method,\n                                                     void *ui_data);\nint OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *loader,\n                               OSSL_STORE_open_fn open_function);\ntypedef int (*OSSL_STORE_ctrl_fn)(OSSL_STORE_LOADER_CTX *ctx, int cmd,\n                                  va_list args);\nint OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *loader,\n                               OSSL_STORE_ctrl_fn ctrl_function);\ntypedef int (*OSSL_STORE_expect_fn)(OSSL_STORE_LOADER_CTX *ctx, int expected);\nint OSSL_STORE_LOADER_set_expect(OSSL_STORE_LOADER *loader,\n                                 OSSL_STORE_expect_fn expect_function);\ntypedef int (*OSSL_STORE_find_fn)(OSSL_STORE_LOADER_CTX *ctx,\n                                  OSSL_STORE_SEARCH *criteria);\nint OSSL_STORE_LOADER_set_find(OSSL_STORE_LOADER *loader,\n                               OSSL_STORE_find_fn find_function);\ntypedef OSSL_STORE_INFO *(*OSSL_STORE_load_fn)(OSSL_STORE_LOADER_CTX *ctx,\n                                               const UI_METHOD *ui_method,\n                                               void *ui_data);\nint OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *loader,\n                               OSSL_STORE_load_fn load_function);\ntypedef int (*OSSL_STORE_eof_fn)(OSSL_STORE_LOADER_CTX *ctx);\nint OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *loader,\n                              OSSL_STORE_eof_fn eof_function);\ntypedef int (*OSSL_STORE_error_fn)(OSSL_STORE_LOADER_CTX *ctx);\nint OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *loader,\n                                OSSL_STORE_error_fn error_function);\ntypedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx);\nint OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *loader,\n                                OSSL_STORE_close_fn close_function);\nvoid OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader);\n\nint OSSL_STORE_register_loader(OSSL_STORE_LOADER *loader);\nOSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme);\n\n/*-\n *  Functions to list STORE loaders\n *  -------------------------------\n */\nint OSSL_STORE_do_all_loaders(void (*do_function) (const OSSL_STORE_LOADER\n                                                   *loader, void *do_arg),\n                              void *do_arg);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/storeerr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_OSSL_STOREERR_H\n# define HEADER_OSSL_STOREERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_OSSL_STORE_strings(void);\n\n/*\n * OSSL_STORE function codes.\n */\n# define OSSL_STORE_F_FILE_CTRL                           129\n# define OSSL_STORE_F_FILE_FIND                           138\n# define OSSL_STORE_F_FILE_GET_PASS                       118\n# define OSSL_STORE_F_FILE_LOAD                           119\n# define OSSL_STORE_F_FILE_LOAD_TRY_DECODE                124\n# define OSSL_STORE_F_FILE_NAME_TO_URI                    126\n# define OSSL_STORE_F_FILE_OPEN                           120\n# define OSSL_STORE_F_OSSL_STORE_ATTACH_PEM_BIO           127\n# define OSSL_STORE_F_OSSL_STORE_EXPECT                   130\n# define OSSL_STORE_F_OSSL_STORE_FILE_ATTACH_PEM_BIO_INT  128\n# define OSSL_STORE_F_OSSL_STORE_FIND                     131\n# define OSSL_STORE_F_OSSL_STORE_GET0_LOADER_INT          100\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CERT           101\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CRL            102\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME           103\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME_DESCRIPTION 135\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PARAMS         104\n# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PKEY           105\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CERT            106\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CRL             107\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_EMBEDDED        123\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_NAME            109\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PARAMS          110\n# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PKEY            111\n# define OSSL_STORE_F_OSSL_STORE_INFO_SET0_NAME_DESCRIPTION 134\n# define OSSL_STORE_F_OSSL_STORE_INIT_ONCE                112\n# define OSSL_STORE_F_OSSL_STORE_LOADER_NEW               113\n# define OSSL_STORE_F_OSSL_STORE_OPEN                     114\n# define OSSL_STORE_F_OSSL_STORE_OPEN_INT                 115\n# define OSSL_STORE_F_OSSL_STORE_REGISTER_LOADER_INT      117\n# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ALIAS          132\n# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ISSUER_SERIAL  133\n# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT 136\n# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_NAME           137\n# define OSSL_STORE_F_OSSL_STORE_UNREGISTER_LOADER_INT    116\n# define OSSL_STORE_F_TRY_DECODE_PARAMS                   121\n# define OSSL_STORE_F_TRY_DECODE_PKCS12                   122\n# define OSSL_STORE_F_TRY_DECODE_PKCS8ENCRYPTED           125\n\n/*\n * OSSL_STORE reason codes.\n */\n# define OSSL_STORE_R_AMBIGUOUS_CONTENT_TYPE              107\n# define OSSL_STORE_R_BAD_PASSWORD_READ                   115\n# define OSSL_STORE_R_ERROR_VERIFYING_PKCS12_MAC          113\n# define OSSL_STORE_R_FINGERPRINT_SIZE_DOES_NOT_MATCH_DIGEST 121\n# define OSSL_STORE_R_INVALID_SCHEME                      106\n# define OSSL_STORE_R_IS_NOT_A                            112\n# define OSSL_STORE_R_LOADER_INCOMPLETE                   116\n# define OSSL_STORE_R_LOADING_STARTED                     117\n# define OSSL_STORE_R_NOT_A_CERTIFICATE                   100\n# define OSSL_STORE_R_NOT_A_CRL                           101\n# define OSSL_STORE_R_NOT_A_KEY                           102\n# define OSSL_STORE_R_NOT_A_NAME                          103\n# define OSSL_STORE_R_NOT_PARAMETERS                      104\n# define OSSL_STORE_R_PASSPHRASE_CALLBACK_ERROR           114\n# define OSSL_STORE_R_PATH_MUST_BE_ABSOLUTE               108\n# define OSSL_STORE_R_SEARCH_ONLY_SUPPORTED_FOR_DIRECTORIES 119\n# define OSSL_STORE_R_UI_PROCESS_INTERRUPTED_OR_CANCELLED 109\n# define OSSL_STORE_R_UNREGISTERED_SCHEME                 105\n# define OSSL_STORE_R_UNSUPPORTED_CONTENT_TYPE            110\n# define OSSL_STORE_R_UNSUPPORTED_OPERATION               118\n# define OSSL_STORE_R_UNSUPPORTED_SEARCH_TYPE             120\n# define OSSL_STORE_R_URI_AUTHORITY_UNSUPPORTED           111\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/symhacks.h",
    "content": "/*\n * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_SYMHACKS_H\n# define HEADER_SYMHACKS_H\n\n# include <openssl/e_os2.h>\n\n/* Case insensitive linking causes problems.... */\n# if defined(OPENSSL_SYS_VMS)\n#  undef ERR_load_CRYPTO_strings\n#  define ERR_load_CRYPTO_strings                 ERR_load_CRYPTOlib_strings\n#  undef OCSP_crlID_new\n#  define OCSP_crlID_new                          OCSP_crlID2_new\n\n#  undef d2i_ECPARAMETERS\n#  define d2i_ECPARAMETERS                        d2i_UC_ECPARAMETERS\n#  undef i2d_ECPARAMETERS\n#  define i2d_ECPARAMETERS                        i2d_UC_ECPARAMETERS\n#  undef d2i_ECPKPARAMETERS\n#  define d2i_ECPKPARAMETERS                      d2i_UC_ECPKPARAMETERS\n#  undef i2d_ECPKPARAMETERS\n#  define i2d_ECPKPARAMETERS                      i2d_UC_ECPKPARAMETERS\n\n/* This one clashes with CMS_data_create */\n#  undef cms_Data_create\n#  define cms_Data_create                         priv_cms_Data_create\n\n# endif\n\n#endif                          /* ! defined HEADER_VMS_IDHACKS_H */\n"
  },
  {
    "path": "cryptomini/include/openssl/tls1.h",
    "content": "/*\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n * Copyright 2005 Nokia. All rights reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_TLS1_H\n# define HEADER_TLS1_H\n\n# include <openssl/buffer.h>\n# include <openssl/x509.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/* Default security level if not overridden at config time */\n# ifndef OPENSSL_TLS_SECURITY_LEVEL\n#  define OPENSSL_TLS_SECURITY_LEVEL 1\n# endif\n\n# define TLS1_VERSION                    0x0301\n# define TLS1_1_VERSION                  0x0302\n# define TLS1_2_VERSION                  0x0303\n# define TLS1_3_VERSION                  0x0304\n# define TLS_MAX_VERSION                 TLS1_3_VERSION\n\n/* Special value for method supporting multiple versions */\n# define TLS_ANY_VERSION                 0x10000\n\n# define TLS1_VERSION_MAJOR              0x03\n# define TLS1_VERSION_MINOR              0x01\n\n# define TLS1_1_VERSION_MAJOR            0x03\n# define TLS1_1_VERSION_MINOR            0x02\n\n# define TLS1_2_VERSION_MAJOR            0x03\n# define TLS1_2_VERSION_MINOR            0x03\n\n# define TLS1_get_version(s) \\\n        ((SSL_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_version(s) : 0)\n\n# define TLS1_get_client_version(s) \\\n        ((SSL_client_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_client_version(s) : 0)\n\n# define TLS1_AD_DECRYPTION_FAILED       21\n# define TLS1_AD_RECORD_OVERFLOW         22\n# define TLS1_AD_UNKNOWN_CA              48/* fatal */\n# define TLS1_AD_ACCESS_DENIED           49/* fatal */\n# define TLS1_AD_DECODE_ERROR            50/* fatal */\n# define TLS1_AD_DECRYPT_ERROR           51\n# define TLS1_AD_EXPORT_RESTRICTION      60/* fatal */\n# define TLS1_AD_PROTOCOL_VERSION        70/* fatal */\n# define TLS1_AD_INSUFFICIENT_SECURITY   71/* fatal */\n# define TLS1_AD_INTERNAL_ERROR          80/* fatal */\n# define TLS1_AD_INAPPROPRIATE_FALLBACK  86/* fatal */\n# define TLS1_AD_USER_CANCELLED          90\n# define TLS1_AD_NO_RENEGOTIATION        100\n/* TLSv1.3 alerts */\n# define TLS13_AD_MISSING_EXTENSION      109 /* fatal */\n# define TLS13_AD_CERTIFICATE_REQUIRED   116 /* fatal */\n/* codes 110-114 are from RFC3546 */\n# define TLS1_AD_UNSUPPORTED_EXTENSION   110\n# define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111\n# define TLS1_AD_UNRECOGNIZED_NAME       112\n# define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113\n# define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114\n# define TLS1_AD_UNKNOWN_PSK_IDENTITY    115/* fatal */\n# define TLS1_AD_NO_APPLICATION_PROTOCOL 120 /* fatal */\n\n/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */\n# define TLSEXT_TYPE_server_name                 0\n# define TLSEXT_TYPE_max_fragment_length         1\n# define TLSEXT_TYPE_client_certificate_url      2\n# define TLSEXT_TYPE_trusted_ca_keys             3\n# define TLSEXT_TYPE_truncated_hmac              4\n# define TLSEXT_TYPE_status_request              5\n/* ExtensionType values from RFC4681 */\n# define TLSEXT_TYPE_user_mapping                6\n/* ExtensionType values from RFC5878 */\n# define TLSEXT_TYPE_client_authz                7\n# define TLSEXT_TYPE_server_authz                8\n/* ExtensionType values from RFC6091 */\n# define TLSEXT_TYPE_cert_type           9\n\n/* ExtensionType values from RFC4492 */\n/*\n * Prior to TLSv1.3 the supported_groups extension was known as\n * elliptic_curves\n */\n# define TLSEXT_TYPE_supported_groups            10\n# define TLSEXT_TYPE_elliptic_curves             TLSEXT_TYPE_supported_groups\n# define TLSEXT_TYPE_ec_point_formats            11\n\n\n/* ExtensionType value from RFC5054 */\n# define TLSEXT_TYPE_srp                         12\n\n/* ExtensionType values from RFC5246 */\n# define TLSEXT_TYPE_signature_algorithms        13\n\n/* ExtensionType value from RFC5764 */\n# define TLSEXT_TYPE_use_srtp    14\n\n/* ExtensionType value from RFC5620 */\n# define TLSEXT_TYPE_heartbeat   15\n\n/* ExtensionType value from RFC7301 */\n# define TLSEXT_TYPE_application_layer_protocol_negotiation 16\n\n/*\n * Extension type for Certificate Transparency\n * https://tools.ietf.org/html/rfc6962#section-3.3.1\n */\n# define TLSEXT_TYPE_signed_certificate_timestamp    18\n\n/*\n * ExtensionType value for TLS padding extension.\n * http://tools.ietf.org/html/draft-agl-tls-padding\n */\n# define TLSEXT_TYPE_padding     21\n\n/* ExtensionType value from RFC7366 */\n# define TLSEXT_TYPE_encrypt_then_mac    22\n\n/* ExtensionType value from RFC7627 */\n# define TLSEXT_TYPE_extended_master_secret      23\n\n/* ExtensionType value from RFC4507 */\n# define TLSEXT_TYPE_session_ticket              35\n\n/* As defined for TLS1.3 */\n# define TLSEXT_TYPE_psk                         41\n# define TLSEXT_TYPE_early_data                  42\n# define TLSEXT_TYPE_supported_versions          43\n# define TLSEXT_TYPE_cookie                      44\n# define TLSEXT_TYPE_psk_kex_modes               45\n# define TLSEXT_TYPE_certificate_authorities     47\n# define TLSEXT_TYPE_post_handshake_auth         49\n# define TLSEXT_TYPE_signature_algorithms_cert   50\n# define TLSEXT_TYPE_key_share                   51\n\n/* Temporary extension type */\n# define TLSEXT_TYPE_renegotiate                 0xff01\n\n# ifndef OPENSSL_NO_NEXTPROTONEG\n/* This is not an IANA defined extension number */\n#  define TLSEXT_TYPE_next_proto_neg              13172\n# endif\n\n/* NameType value from RFC3546 */\n# define TLSEXT_NAMETYPE_host_name 0\n/* status request value from RFC3546 */\n# define TLSEXT_STATUSTYPE_ocsp 1\n\n/* ECPointFormat values from RFC4492 */\n# define TLSEXT_ECPOINTFORMAT_first                      0\n# define TLSEXT_ECPOINTFORMAT_uncompressed               0\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime  1\n# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2  2\n# define TLSEXT_ECPOINTFORMAT_last                       2\n\n/* Signature and hash algorithms from RFC5246 */\n# define TLSEXT_signature_anonymous                      0\n# define TLSEXT_signature_rsa                            1\n# define TLSEXT_signature_dsa                            2\n# define TLSEXT_signature_ecdsa                          3\n# define TLSEXT_signature_gostr34102001                  237\n# define TLSEXT_signature_gostr34102012_256              238\n# define TLSEXT_signature_gostr34102012_512              239\n\n/* Total number of different signature algorithms */\n# define TLSEXT_signature_num                            7\n\n# define TLSEXT_hash_none                                0\n# define TLSEXT_hash_md5                                 1\n# define TLSEXT_hash_sha1                                2\n# define TLSEXT_hash_sha224                              3\n# define TLSEXT_hash_sha256                              4\n# define TLSEXT_hash_sha384                              5\n# define TLSEXT_hash_sha512                              6\n# define TLSEXT_hash_gostr3411                           237\n# define TLSEXT_hash_gostr34112012_256                   238\n# define TLSEXT_hash_gostr34112012_512                   239\n\n/* Total number of different digest algorithms */\n\n# define TLSEXT_hash_num                                 10\n\n/* Flag set for unrecognised algorithms */\n# define TLSEXT_nid_unknown                              0x1000000\n\n/* ECC curves */\n\n# define TLSEXT_curve_P_256                              23\n# define TLSEXT_curve_P_384                              24\n\n/* OpenSSL value to disable maximum fragment length extension */\n# define TLSEXT_max_fragment_length_DISABLED    0\n/* Allowed values for max fragment length extension */\n# define TLSEXT_max_fragment_length_512         1\n# define TLSEXT_max_fragment_length_1024        2\n# define TLSEXT_max_fragment_length_2048        3\n# define TLSEXT_max_fragment_length_4096        4\n\nint SSL_CTX_set_tlsext_max_fragment_length(SSL_CTX *ctx, uint8_t mode);\nint SSL_set_tlsext_max_fragment_length(SSL *ssl, uint8_t mode);\n\n# define TLSEXT_MAXLEN_host_name 255\n\n__owur const char *SSL_get_servername(const SSL *s, const int type);\n__owur int SSL_get_servername_type(const SSL *s);\n/*\n * SSL_export_keying_material exports a value derived from the master secret,\n * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and\n * optional context. (Since a zero length context is allowed, the |use_context|\n * flag controls whether a context is included.) It returns 1 on success and\n * 0 or -1 otherwise.\n */\n__owur int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen,\n                                      const char *label, size_t llen,\n                                      const unsigned char *context,\n                                      size_t contextlen, int use_context);\n\n/*\n * SSL_export_keying_material_early exports a value derived from the\n * early exporter master secret, as specified in\n * https://tools.ietf.org/html/draft-ietf-tls-tls13-23. It writes\n * |olen| bytes to |out| given a label and optional context. It\n * returns 1 on success and 0 otherwise.\n */\n__owur int SSL_export_keying_material_early(SSL *s, unsigned char *out,\n                                            size_t olen, const char *label,\n                                            size_t llen,\n                                            const unsigned char *context,\n                                            size_t contextlen);\n\nint SSL_get_peer_signature_type_nid(const SSL *s, int *pnid);\nint SSL_get_signature_type_nid(const SSL *s, int *pnid);\n\nint SSL_get_sigalgs(SSL *s, int idx,\n                    int *psign, int *phash, int *psignandhash,\n                    unsigned char *rsig, unsigned char *rhash);\n\nint SSL_get_shared_sigalgs(SSL *s, int idx,\n                           int *psign, int *phash, int *psignandhash,\n                           unsigned char *rsig, unsigned char *rhash);\n\n__owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain);\n\n# define SSL_set_tlsext_host_name(s,name) \\\n        SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,\\\n                (void *)name)\n\n# define SSL_set_tlsext_debug_callback(ssl, cb) \\\n        SSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,\\\n                (void (*)(void))cb)\n\n# define SSL_set_tlsext_debug_arg(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0,arg)\n\n# define SSL_get_tlsext_status_type(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0,NULL)\n\n# define SSL_set_tlsext_status_type(ssl, type) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type,NULL)\n\n# define SSL_get_tlsext_status_exts(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0,arg)\n\n# define SSL_set_tlsext_status_exts(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0,arg)\n\n# define SSL_get_tlsext_status_ids(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0,arg)\n\n# define SSL_set_tlsext_status_ids(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0,arg)\n\n# define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0,arg)\n\n# define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen,arg)\n\n# define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \\\n        SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,\\\n                (void (*)(void))cb)\n\n# define SSL_TLSEXT_ERR_OK 0\n# define SSL_TLSEXT_ERR_ALERT_WARNING 1\n# define SSL_TLSEXT_ERR_ALERT_FATAL 2\n# define SSL_TLSEXT_ERR_NOACK 3\n\n# define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0,arg)\n\n# define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_GET_TLSEXT_TICKET_KEYS,keylen,keys)\n# define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \\\n        SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_TICKET_KEYS,keylen,keys)\n\n# define SSL_CTX_get_tlsext_status_cb(ssl, cb) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB,0,(void *)cb)\n# define SSL_CTX_set_tlsext_status_cb(ssl, cb) \\\n        SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,\\\n                (void (*)(void))cb)\n\n# define SSL_CTX_get_tlsext_status_arg(ssl, arg) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG,0,arg)\n# define SSL_CTX_set_tlsext_status_arg(ssl, arg) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0,arg)\n\n# define SSL_CTX_set_tlsext_status_type(ssl, type) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type,NULL)\n\n# define SSL_CTX_get_tlsext_status_type(ssl) \\\n        SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0,NULL)\n\n# define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \\\n        SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,\\\n                (void (*)(void))cb)\n\n# ifndef OPENSSL_NO_HEARTBEATS\n#  define SSL_DTLSEXT_HB_ENABLED                   0x01\n#  define SSL_DTLSEXT_HB_DONT_SEND_REQUESTS        0x02\n#  define SSL_DTLSEXT_HB_DONT_RECV_REQUESTS        0x04\n#  define SSL_get_dtlsext_heartbeat_pending(ssl) \\\n        SSL_ctrl(ssl,SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING,0,NULL)\n#  define SSL_set_dtlsext_heartbeat_no_requests(ssl, arg) \\\n        SSL_ctrl(ssl,SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS,arg,NULL)\n\n#  if OPENSSL_API_COMPAT < 0x10100000L\n#   define SSL_CTRL_TLS_EXT_SEND_HEARTBEAT \\\n        SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT\n#   define SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING \\\n        SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING\n#   define SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS \\\n        SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS\n#   define SSL_TLSEXT_HB_ENABLED \\\n        SSL_DTLSEXT_HB_ENABLED\n#   define SSL_TLSEXT_HB_DONT_SEND_REQUESTS \\\n        SSL_DTLSEXT_HB_DONT_SEND_REQUESTS\n#   define SSL_TLSEXT_HB_DONT_RECV_REQUESTS \\\n        SSL_DTLSEXT_HB_DONT_RECV_REQUESTS\n#   define SSL_get_tlsext_heartbeat_pending(ssl) \\\n        SSL_get_dtlsext_heartbeat_pending(ssl)\n#   define SSL_set_tlsext_heartbeat_no_requests(ssl, arg) \\\n        SSL_set_dtlsext_heartbeat_no_requests(ssl,arg)\n#  endif\n# endif\n\n/* PSK ciphersuites from 4279 */\n# define TLS1_CK_PSK_WITH_RC4_128_SHA                    0x0300008A\n# define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA               0x0300008B\n# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA                0x0300008C\n# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA                0x0300008D\n# define TLS1_CK_DHE_PSK_WITH_RC4_128_SHA                0x0300008E\n# define TLS1_CK_DHE_PSK_WITH_3DES_EDE_CBC_SHA           0x0300008F\n# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA            0x03000090\n# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA            0x03000091\n# define TLS1_CK_RSA_PSK_WITH_RC4_128_SHA                0x03000092\n# define TLS1_CK_RSA_PSK_WITH_3DES_EDE_CBC_SHA           0x03000093\n# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA            0x03000094\n# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA            0x03000095\n\n/* PSK ciphersuites from 5487 */\n# define TLS1_CK_PSK_WITH_AES_128_GCM_SHA256             0x030000A8\n# define TLS1_CK_PSK_WITH_AES_256_GCM_SHA384             0x030000A9\n# define TLS1_CK_DHE_PSK_WITH_AES_128_GCM_SHA256         0x030000AA\n# define TLS1_CK_DHE_PSK_WITH_AES_256_GCM_SHA384         0x030000AB\n# define TLS1_CK_RSA_PSK_WITH_AES_128_GCM_SHA256         0x030000AC\n# define TLS1_CK_RSA_PSK_WITH_AES_256_GCM_SHA384         0x030000AD\n# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA256             0x030000AE\n# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA384             0x030000AF\n# define TLS1_CK_PSK_WITH_NULL_SHA256                    0x030000B0\n# define TLS1_CK_PSK_WITH_NULL_SHA384                    0x030000B1\n# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA256         0x030000B2\n# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA384         0x030000B3\n# define TLS1_CK_DHE_PSK_WITH_NULL_SHA256                0x030000B4\n# define TLS1_CK_DHE_PSK_WITH_NULL_SHA384                0x030000B5\n# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA256         0x030000B6\n# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA384         0x030000B7\n# define TLS1_CK_RSA_PSK_WITH_NULL_SHA256                0x030000B8\n# define TLS1_CK_RSA_PSK_WITH_NULL_SHA384                0x030000B9\n\n/* NULL PSK ciphersuites from RFC4785 */\n# define TLS1_CK_PSK_WITH_NULL_SHA                       0x0300002C\n# define TLS1_CK_DHE_PSK_WITH_NULL_SHA                   0x0300002D\n# define TLS1_CK_RSA_PSK_WITH_NULL_SHA                   0x0300002E\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_CK_RSA_WITH_AES_128_SHA                    0x0300002F\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA                 0x03000030\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA                 0x03000031\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA                0x03000032\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA                0x03000033\n# define TLS1_CK_ADH_WITH_AES_128_SHA                    0x03000034\n# define TLS1_CK_RSA_WITH_AES_256_SHA                    0x03000035\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA                 0x03000036\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA                 0x03000037\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA                0x03000038\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA                0x03000039\n# define TLS1_CK_ADH_WITH_AES_256_SHA                    0x0300003A\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_RSA_WITH_NULL_SHA256                    0x0300003B\n# define TLS1_CK_RSA_WITH_AES_128_SHA256                 0x0300003C\n# define TLS1_CK_RSA_WITH_AES_256_SHA256                 0x0300003D\n# define TLS1_CK_DH_DSS_WITH_AES_128_SHA256              0x0300003E\n# define TLS1_CK_DH_RSA_WITH_AES_128_SHA256              0x0300003F\n# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256             0x03000040\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA           0x03000041\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA        0x03000042\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA        0x03000043\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA       0x03000044\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA       0x03000045\n# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA           0x03000046\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256             0x03000067\n# define TLS1_CK_DH_DSS_WITH_AES_256_SHA256              0x03000068\n# define TLS1_CK_DH_RSA_WITH_AES_256_SHA256              0x03000069\n# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256             0x0300006A\n# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256             0x0300006B\n# define TLS1_CK_ADH_WITH_AES_128_SHA256                 0x0300006C\n# define TLS1_CK_ADH_WITH_AES_256_SHA256                 0x0300006D\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA           0x03000084\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA        0x03000085\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA        0x03000086\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA       0x03000087\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA       0x03000088\n# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA           0x03000089\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_CK_RSA_WITH_SEED_SHA                       0x03000096\n# define TLS1_CK_DH_DSS_WITH_SEED_SHA                    0x03000097\n# define TLS1_CK_DH_RSA_WITH_SEED_SHA                    0x03000098\n# define TLS1_CK_DHE_DSS_WITH_SEED_SHA                   0x03000099\n# define TLS1_CK_DHE_RSA_WITH_SEED_SHA                   0x0300009A\n# define TLS1_CK_ADH_WITH_SEED_SHA                       0x0300009B\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256             0x0300009C\n# define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384             0x0300009D\n# define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256         0x0300009E\n# define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384         0x0300009F\n# define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256          0x030000A0\n# define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384          0x030000A1\n# define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256         0x030000A2\n# define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384         0x030000A3\n# define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256          0x030000A4\n# define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384          0x030000A5\n# define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256             0x030000A6\n# define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384             0x030000A7\n\n/* CCM ciphersuites from RFC6655 */\n# define TLS1_CK_RSA_WITH_AES_128_CCM                    0x0300C09C\n# define TLS1_CK_RSA_WITH_AES_256_CCM                    0x0300C09D\n# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM                0x0300C09E\n# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM                0x0300C09F\n# define TLS1_CK_RSA_WITH_AES_128_CCM_8                  0x0300C0A0\n# define TLS1_CK_RSA_WITH_AES_256_CCM_8                  0x0300C0A1\n# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM_8              0x0300C0A2\n# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM_8              0x0300C0A3\n# define TLS1_CK_PSK_WITH_AES_128_CCM                    0x0300C0A4\n# define TLS1_CK_PSK_WITH_AES_256_CCM                    0x0300C0A5\n# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM                0x0300C0A6\n# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM                0x0300C0A7\n# define TLS1_CK_PSK_WITH_AES_128_CCM_8                  0x0300C0A8\n# define TLS1_CK_PSK_WITH_AES_256_CCM_8                  0x0300C0A9\n# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM_8              0x0300C0AA\n# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM_8              0x0300C0AB\n\n/* CCM ciphersuites from RFC7251 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM            0x0300C0AC\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM            0x0300C0AD\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM_8          0x0300C0AE\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM_8          0x0300C0AF\n\n/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */\n# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA256                0x030000BA\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256             0x030000BB\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256             0x030000BC\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256            0x030000BD\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256            0x030000BE\n# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA256                0x030000BF\n\n# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA256                0x030000C0\n# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256             0x030000C1\n# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256             0x030000C2\n# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256            0x030000C3\n# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256            0x030000C4\n# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256                0x030000C5\n\n/* ECC ciphersuites from RFC4492 */\n# define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA                0x0300C001\n# define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA             0x0300C002\n# define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA        0x0300C003\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA         0x0300C004\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA         0x0300C005\n\n# define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA               0x0300C006\n# define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA            0x0300C007\n# define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA       0x0300C008\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA        0x0300C009\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA        0x0300C00A\n\n# define TLS1_CK_ECDH_RSA_WITH_NULL_SHA                  0x0300C00B\n# define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA               0x0300C00C\n# define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA          0x0300C00D\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA           0x0300C00E\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA           0x0300C00F\n\n# define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA                 0x0300C010\n# define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA              0x0300C011\n# define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA         0x0300C012\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA          0x0300C013\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA          0x0300C014\n\n# define TLS1_CK_ECDH_anon_WITH_NULL_SHA                 0x0300C015\n# define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA              0x0300C016\n# define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA         0x0300C017\n# define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA          0x0300C018\n# define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA          0x0300C019\n\n/* SRP ciphersuites from RFC 5054 */\n# define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA           0x0300C01A\n# define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA       0x0300C01B\n# define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA       0x0300C01C\n# define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA            0x0300C01D\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA        0x0300C01E\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA        0x0300C01F\n# define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA            0x0300C020\n# define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA        0x0300C021\n# define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA        0x0300C022\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256         0x0300C023\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384         0x0300C024\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256          0x0300C025\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384          0x0300C026\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256           0x0300C027\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384           0x0300C028\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256            0x0300C029\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384            0x0300C02A\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256     0x0300C02B\n# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384     0x0300C02C\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256      0x0300C02D\n# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384      0x0300C02E\n# define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256       0x0300C02F\n# define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384       0x0300C030\n# define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256        0x0300C031\n# define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384        0x0300C032\n\n/* ECDHE PSK ciphersuites from RFC5489 */\n# define TLS1_CK_ECDHE_PSK_WITH_RC4_128_SHA              0x0300C033\n# define TLS1_CK_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA         0x0300C034\n# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA          0x0300C035\n# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA          0x0300C036\n\n# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA256       0x0300C037\n# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA384       0x0300C038\n\n/* NULL PSK ciphersuites from RFC4785 */\n# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA                 0x0300C039\n# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA256              0x0300C03A\n# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA384              0x0300C03B\n\n/* Camellia-CBC ciphersuites from RFC6367 */\n# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C072\n# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C073\n# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256  0x0300C074\n# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384  0x0300C075\n# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256   0x0300C076\n# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384   0x0300C077\n# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256    0x0300C078\n# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384    0x0300C079\n\n# define TLS1_CK_PSK_WITH_CAMELLIA_128_CBC_SHA256         0x0300C094\n# define TLS1_CK_PSK_WITH_CAMELLIA_256_CBC_SHA384         0x0300C095\n# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256     0x0300C096\n# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384     0x0300C097\n# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256     0x0300C098\n# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384     0x0300C099\n# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256   0x0300C09A\n# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384   0x0300C09B\n\n/* draft-ietf-tls-chacha20-poly1305-03 */\n# define TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305         0x0300CCA8\n# define TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305       0x0300CCA9\n# define TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305           0x0300CCAA\n# define TLS1_CK_PSK_WITH_CHACHA20_POLY1305               0x0300CCAB\n# define TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305         0x0300CCAC\n# define TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305           0x0300CCAD\n# define TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305           0x0300CCAE\n\n/* TLS v1.3 ciphersuites */\n# define TLS1_3_CK_AES_128_GCM_SHA256                     0x03001301\n# define TLS1_3_CK_AES_256_GCM_SHA384                     0x03001302\n# define TLS1_3_CK_CHACHA20_POLY1305_SHA256               0x03001303\n# define TLS1_3_CK_AES_128_CCM_SHA256                     0x03001304\n# define TLS1_3_CK_AES_128_CCM_8_SHA256                   0x03001305\n\n/* Aria ciphersuites from RFC6209 */\n# define TLS1_CK_RSA_WITH_ARIA_128_GCM_SHA256             0x0300C050\n# define TLS1_CK_RSA_WITH_ARIA_256_GCM_SHA384             0x0300C051\n# define TLS1_CK_DHE_RSA_WITH_ARIA_128_GCM_SHA256         0x0300C052\n# define TLS1_CK_DHE_RSA_WITH_ARIA_256_GCM_SHA384         0x0300C053\n# define TLS1_CK_DH_RSA_WITH_ARIA_128_GCM_SHA256          0x0300C054\n# define TLS1_CK_DH_RSA_WITH_ARIA_256_GCM_SHA384          0x0300C055\n# define TLS1_CK_DHE_DSS_WITH_ARIA_128_GCM_SHA256         0x0300C056\n# define TLS1_CK_DHE_DSS_WITH_ARIA_256_GCM_SHA384         0x0300C057\n# define TLS1_CK_DH_DSS_WITH_ARIA_128_GCM_SHA256          0x0300C058\n# define TLS1_CK_DH_DSS_WITH_ARIA_256_GCM_SHA384          0x0300C059\n# define TLS1_CK_DH_anon_WITH_ARIA_128_GCM_SHA256         0x0300C05A\n# define TLS1_CK_DH_anon_WITH_ARIA_256_GCM_SHA384         0x0300C05B\n# define TLS1_CK_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256     0x0300C05C\n# define TLS1_CK_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384     0x0300C05D\n# define TLS1_CK_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256      0x0300C05E\n# define TLS1_CK_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384      0x0300C05F\n# define TLS1_CK_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256       0x0300C060\n# define TLS1_CK_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384       0x0300C061\n# define TLS1_CK_ECDH_RSA_WITH_ARIA_128_GCM_SHA256        0x0300C062\n# define TLS1_CK_ECDH_RSA_WITH_ARIA_256_GCM_SHA384        0x0300C063\n# define TLS1_CK_PSK_WITH_ARIA_128_GCM_SHA256             0x0300C06A\n# define TLS1_CK_PSK_WITH_ARIA_256_GCM_SHA384             0x0300C06B\n# define TLS1_CK_DHE_PSK_WITH_ARIA_128_GCM_SHA256         0x0300C06C\n# define TLS1_CK_DHE_PSK_WITH_ARIA_256_GCM_SHA384         0x0300C06D\n# define TLS1_CK_RSA_PSK_WITH_ARIA_128_GCM_SHA256         0x0300C06E\n# define TLS1_CK_RSA_PSK_WITH_ARIA_256_GCM_SHA384         0x0300C06F\n\n/* a bundle of RFC standard cipher names, generated from ssl3_ciphers[] */\n# define TLS1_RFC_RSA_WITH_AES_128_SHA                   \"TLS_RSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA               \"TLS_DHE_DSS_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA               \"TLS_DHE_RSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_AES_128_SHA                   \"TLS_DH_anon_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_RSA_WITH_AES_256_SHA                   \"TLS_RSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA               \"TLS_DHE_DSS_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA               \"TLS_DHE_RSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_AES_256_SHA                   \"TLS_DH_anon_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_RSA_WITH_NULL_SHA256                   \"TLS_RSA_WITH_NULL_SHA256\"\n# define TLS1_RFC_RSA_WITH_AES_128_SHA256                \"TLS_RSA_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_RSA_WITH_AES_256_SHA256                \"TLS_RSA_WITH_AES_256_CBC_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA256            \"TLS_DHE_DSS_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA256            \"TLS_DHE_RSA_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA256            \"TLS_DHE_DSS_WITH_AES_256_CBC_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA256            \"TLS_DHE_RSA_WITH_AES_256_CBC_SHA256\"\n# define TLS1_RFC_ADH_WITH_AES_128_SHA256                \"TLS_DH_anon_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_ADH_WITH_AES_256_SHA256                \"TLS_DH_anon_WITH_AES_256_CBC_SHA256\"\n# define TLS1_RFC_RSA_WITH_AES_128_GCM_SHA256            \"TLS_RSA_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_RSA_WITH_AES_256_GCM_SHA384            \"TLS_RSA_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_GCM_SHA256        \"TLS_DHE_RSA_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_GCM_SHA384        \"TLS_DHE_RSA_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_128_GCM_SHA256        \"TLS_DHE_DSS_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_AES_256_GCM_SHA384        \"TLS_DHE_DSS_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_ADH_WITH_AES_128_GCM_SHA256            \"TLS_DH_anon_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_ADH_WITH_AES_256_GCM_SHA384            \"TLS_DH_anon_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_RSA_WITH_AES_128_CCM                   \"TLS_RSA_WITH_AES_128_CCM\"\n# define TLS1_RFC_RSA_WITH_AES_256_CCM                   \"TLS_RSA_WITH_AES_256_CCM\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_CCM               \"TLS_DHE_RSA_WITH_AES_128_CCM\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_CCM               \"TLS_DHE_RSA_WITH_AES_256_CCM\"\n# define TLS1_RFC_RSA_WITH_AES_128_CCM_8                 \"TLS_RSA_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_RSA_WITH_AES_256_CCM_8                 \"TLS_RSA_WITH_AES_256_CCM_8\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_128_CCM_8             \"TLS_DHE_RSA_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_DHE_RSA_WITH_AES_256_CCM_8             \"TLS_DHE_RSA_WITH_AES_256_CCM_8\"\n# define TLS1_RFC_PSK_WITH_AES_128_CCM                   \"TLS_PSK_WITH_AES_128_CCM\"\n# define TLS1_RFC_PSK_WITH_AES_256_CCM                   \"TLS_PSK_WITH_AES_256_CCM\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_CCM               \"TLS_DHE_PSK_WITH_AES_128_CCM\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_CCM               \"TLS_DHE_PSK_WITH_AES_256_CCM\"\n# define TLS1_RFC_PSK_WITH_AES_128_CCM_8                 \"TLS_PSK_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_PSK_WITH_AES_256_CCM_8                 \"TLS_PSK_WITH_AES_256_CCM_8\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_CCM_8             \"TLS_PSK_DHE_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_CCM_8             \"TLS_PSK_DHE_WITH_AES_256_CCM_8\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM           \"TLS_ECDHE_ECDSA_WITH_AES_128_CCM\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM           \"TLS_ECDHE_ECDSA_WITH_AES_256_CCM\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM_8         \"TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM_8         \"TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8\"\n# define TLS1_3_RFC_AES_128_GCM_SHA256                   \"TLS_AES_128_GCM_SHA256\"\n# define TLS1_3_RFC_AES_256_GCM_SHA384                   \"TLS_AES_256_GCM_SHA384\"\n# define TLS1_3_RFC_CHACHA20_POLY1305_SHA256             \"TLS_CHACHA20_POLY1305_SHA256\"\n# define TLS1_3_RFC_AES_128_CCM_SHA256                   \"TLS_AES_128_CCM_SHA256\"\n# define TLS1_3_RFC_AES_128_CCM_8_SHA256                 \"TLS_AES_128_CCM_8_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_NULL_SHA              \"TLS_ECDHE_ECDSA_WITH_NULL_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA      \"TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CBC_SHA       \"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CBC_SHA       \"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_NULL_SHA                \"TLS_ECDHE_RSA_WITH_NULL_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_DES_192_CBC3_SHA        \"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_CBC_SHA         \"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_CBC_SHA         \"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_NULL_SHA                \"TLS_ECDH_anon_WITH_NULL_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_DES_192_CBC3_SHA        \"TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_AES_128_CBC_SHA         \"TLS_ECDH_anon_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_AES_256_CBC_SHA         \"TLS_ECDH_anon_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_SHA256        \"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_SHA384        \"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_SHA256          \"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_SHA384          \"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256    \"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384    \"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_GCM_SHA256      \"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_GCM_SHA384      \"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_PSK_WITH_NULL_SHA                      \"TLS_PSK_WITH_NULL_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA                  \"TLS_DHE_PSK_WITH_NULL_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA                  \"TLS_RSA_PSK_WITH_NULL_SHA\"\n# define TLS1_RFC_PSK_WITH_3DES_EDE_CBC_SHA              \"TLS_PSK_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA               \"TLS_PSK_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA               \"TLS_PSK_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_3DES_EDE_CBC_SHA          \"TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA           \"TLS_DHE_PSK_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA           \"TLS_DHE_PSK_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_3DES_EDE_CBC_SHA          \"TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA           \"TLS_RSA_PSK_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA           \"TLS_RSA_PSK_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_PSK_WITH_AES_128_GCM_SHA256            \"TLS_PSK_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_PSK_WITH_AES_256_GCM_SHA384            \"TLS_PSK_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_GCM_SHA256        \"TLS_DHE_PSK_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_GCM_SHA384        \"TLS_DHE_PSK_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_128_GCM_SHA256        \"TLS_RSA_PSK_WITH_AES_128_GCM_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_256_GCM_SHA384        \"TLS_RSA_PSK_WITH_AES_256_GCM_SHA384\"\n# define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA256            \"TLS_PSK_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA384            \"TLS_PSK_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_PSK_WITH_NULL_SHA256                   \"TLS_PSK_WITH_NULL_SHA256\"\n# define TLS1_RFC_PSK_WITH_NULL_SHA384                   \"TLS_PSK_WITH_NULL_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA256        \"TLS_DHE_PSK_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA384        \"TLS_DHE_PSK_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA256               \"TLS_DHE_PSK_WITH_NULL_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA384               \"TLS_DHE_PSK_WITH_NULL_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA256        \"TLS_RSA_PSK_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA384        \"TLS_RSA_PSK_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA256               \"TLS_RSA_PSK_WITH_NULL_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA384               \"TLS_RSA_PSK_WITH_NULL_SHA384\"\n# define TLS1_RFC_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA        \"TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA         \"TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA         \"TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA256      \"TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA384      \"TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA                \"TLS_ECDHE_PSK_WITH_NULL_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA256             \"TLS_ECDHE_PSK_WITH_NULL_SHA256\"\n# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA384             \"TLS_ECDHE_PSK_WITH_NULL_SHA384\"\n# define TLS1_RFC_SRP_SHA_WITH_3DES_EDE_CBC_SHA          \"TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA      \"TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA      \"TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_WITH_AES_128_CBC_SHA           \"TLS_SRP_SHA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_RSA_WITH_AES_128_CBC_SHA       \"TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_DSS_WITH_AES_128_CBC_SHA       \"TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_WITH_AES_256_CBC_SHA           \"TLS_SRP_SHA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_RSA_WITH_AES_256_CBC_SHA       \"TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_SRP_SHA_DSS_WITH_AES_256_CBC_SHA       \"TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_CHACHA20_POLY1305         \"TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_CHACHA20_POLY1305       \"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_CHACHA20_POLY1305     \"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_PSK_WITH_CHACHA20_POLY1305             \"TLS_PSK_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_ECDHE_PSK_WITH_CHACHA20_POLY1305       \"TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_CHACHA20_POLY1305         \"TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_CHACHA20_POLY1305         \"TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256\"\n# define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA256       \"TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256   \"TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256   \"TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA256       \"TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA256       \"TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256   \"TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256   \"TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256\"\n# define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA256       \"TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256\"\n# define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA          \"TLS_RSA_WITH_CAMELLIA_256_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA      \"TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA      \"TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA          \"TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA\"\n# define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA          \"TLS_RSA_WITH_CAMELLIA_128_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA      \"TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA      \"TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA          \"TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \"TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \"TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 \"TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 \"TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_PSK_WITH_CAMELLIA_128_CBC_SHA256       \"TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_PSK_WITH_CAMELLIA_256_CBC_SHA384       \"TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256   \"TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384   \"TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256   \"TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384   \"TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 \"TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256\"\n# define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 \"TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384\"\n# define TLS1_RFC_RSA_WITH_SEED_SHA                      \"TLS_RSA_WITH_SEED_CBC_SHA\"\n# define TLS1_RFC_DHE_DSS_WITH_SEED_SHA                  \"TLS_DHE_DSS_WITH_SEED_CBC_SHA\"\n# define TLS1_RFC_DHE_RSA_WITH_SEED_SHA                  \"TLS_DHE_RSA_WITH_SEED_CBC_SHA\"\n# define TLS1_RFC_ADH_WITH_SEED_SHA                      \"TLS_DH_anon_WITH_SEED_CBC_SHA\"\n# define TLS1_RFC_ECDHE_PSK_WITH_RC4_128_SHA             \"TLS_ECDHE_PSK_WITH_RC4_128_SHA\"\n# define TLS1_RFC_ECDH_anon_WITH_RC4_128_SHA             \"TLS_ECDH_anon_WITH_RC4_128_SHA\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_RC4_128_SHA           \"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA\"\n# define TLS1_RFC_ECDHE_RSA_WITH_RC4_128_SHA             \"TLS_ECDHE_RSA_WITH_RC4_128_SHA\"\n# define TLS1_RFC_PSK_WITH_RC4_128_SHA                   \"TLS_PSK_WITH_RC4_128_SHA\"\n# define TLS1_RFC_RSA_PSK_WITH_RC4_128_SHA               \"TLS_RSA_PSK_WITH_RC4_128_SHA\"\n# define TLS1_RFC_DHE_PSK_WITH_RC4_128_SHA               \"TLS_DHE_PSK_WITH_RC4_128_SHA\"\n# define TLS1_RFC_RSA_WITH_ARIA_128_GCM_SHA256           \"TLS_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_RSA_WITH_ARIA_256_GCM_SHA384           \"TLS_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_RSA_WITH_ARIA_128_GCM_SHA256       \"TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_RSA_WITH_ARIA_256_GCM_SHA384       \"TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DH_RSA_WITH_ARIA_128_GCM_SHA256        \"TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DH_RSA_WITH_ARIA_256_GCM_SHA384        \"TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_DSS_WITH_ARIA_128_GCM_SHA256       \"TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_DSS_WITH_ARIA_256_GCM_SHA384       \"TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DH_DSS_WITH_ARIA_128_GCM_SHA256        \"TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DH_DSS_WITH_ARIA_256_GCM_SHA384        \"TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DH_anon_WITH_ARIA_128_GCM_SHA256       \"TLS_DH_anon_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DH_anon_WITH_ARIA_256_GCM_SHA384       \"TLS_DH_anon_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256   \"TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384   \"TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256    \"TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384    \"TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256     \"TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384     \"TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_ECDH_RSA_WITH_ARIA_128_GCM_SHA256      \"TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_ECDH_RSA_WITH_ARIA_256_GCM_SHA384      \"TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_PSK_WITH_ARIA_128_GCM_SHA256           \"TLS_PSK_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_PSK_WITH_ARIA_256_GCM_SHA384           \"TLS_PSK_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_DHE_PSK_WITH_ARIA_128_GCM_SHA256       \"TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_DHE_PSK_WITH_ARIA_256_GCM_SHA384       \"TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384\"\n# define TLS1_RFC_RSA_PSK_WITH_ARIA_128_GCM_SHA256       \"TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256\"\n# define TLS1_RFC_RSA_PSK_WITH_ARIA_256_GCM_SHA384       \"TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384\"\n\n\n/*\n * XXX Backward compatibility alert: Older versions of OpenSSL gave some DHE\n * ciphers names with \"EDH\" instead of \"DHE\".  Going forward, we should be\n * using DHE everywhere, though we may indefinitely maintain aliases for\n * users or configurations that used \"EDH\"\n */\n# define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA               \"DHE-DSS-RC4-SHA\"\n\n# define TLS1_TXT_PSK_WITH_NULL_SHA                      \"PSK-NULL-SHA\"\n# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA                  \"DHE-PSK-NULL-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA                  \"RSA-PSK-NULL-SHA\"\n\n/* AES ciphersuites from RFC3268 */\n# define TLS1_TXT_RSA_WITH_AES_128_SHA                   \"AES128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA                \"DH-DSS-AES128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA                \"DH-RSA-AES128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA               \"DHE-DSS-AES128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA               \"DHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA                   \"ADH-AES128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_AES_256_SHA                   \"AES256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA                \"DH-DSS-AES256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA                \"DH-RSA-AES256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA               \"DHE-DSS-AES256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA               \"DHE-RSA-AES256-SHA\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA                   \"ADH-AES256-SHA\"\n\n/* ECC ciphersuites from RFC4492 */\n# define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA               \"ECDH-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA            \"ECDH-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA       \"ECDH-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA        \"ECDH-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA        \"ECDH-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA              \"ECDHE-ECDSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA           \"ECDHE-ECDSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA      \"ECDHE-ECDSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA       \"ECDHE-ECDSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA       \"ECDHE-ECDSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA                 \"ECDH-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA              \"ECDH-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA         \"ECDH-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA          \"ECDH-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA          \"ECDH-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA                \"ECDHE-RSA-NULL-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA             \"ECDHE-RSA-RC4-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA        \"ECDHE-RSA-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA         \"ECDHE-RSA-AES128-SHA\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA         \"ECDHE-RSA-AES256-SHA\"\n\n# define TLS1_TXT_ECDH_anon_WITH_NULL_SHA                \"AECDH-NULL-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA             \"AECDH-RC4-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA        \"AECDH-DES-CBC3-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA         \"AECDH-AES128-SHA\"\n# define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA         \"AECDH-AES256-SHA\"\n\n/* PSK ciphersuites from RFC 4279 */\n# define TLS1_TXT_PSK_WITH_RC4_128_SHA                   \"PSK-RC4-SHA\"\n# define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA              \"PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA               \"PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA               \"PSK-AES256-CBC-SHA\"\n\n# define TLS1_TXT_DHE_PSK_WITH_RC4_128_SHA               \"DHE-PSK-RC4-SHA\"\n# define TLS1_TXT_DHE_PSK_WITH_3DES_EDE_CBC_SHA          \"DHE-PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA           \"DHE-PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA           \"DHE-PSK-AES256-CBC-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_RC4_128_SHA               \"RSA-PSK-RC4-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_3DES_EDE_CBC_SHA          \"RSA-PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA           \"RSA-PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA           \"RSA-PSK-AES256-CBC-SHA\"\n\n/* PSK ciphersuites from RFC 5487 */\n# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256            \"PSK-AES128-GCM-SHA256\"\n# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384            \"PSK-AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_GCM_SHA256        \"DHE-PSK-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_GCM_SHA384        \"DHE-PSK-AES256-GCM-SHA384\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_128_GCM_SHA256        \"RSA-PSK-AES128-GCM-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_256_GCM_SHA384        \"RSA-PSK-AES256-GCM-SHA384\"\n\n# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA256            \"PSK-AES128-CBC-SHA256\"\n# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA384            \"PSK-AES256-CBC-SHA384\"\n# define TLS1_TXT_PSK_WITH_NULL_SHA256                   \"PSK-NULL-SHA256\"\n# define TLS1_TXT_PSK_WITH_NULL_SHA384                   \"PSK-NULL-SHA384\"\n\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA256        \"DHE-PSK-AES128-CBC-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA384        \"DHE-PSK-AES256-CBC-SHA384\"\n# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA256               \"DHE-PSK-NULL-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA384               \"DHE-PSK-NULL-SHA384\"\n\n# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA256        \"RSA-PSK-AES128-CBC-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA384        \"RSA-PSK-AES256-CBC-SHA384\"\n# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA256               \"RSA-PSK-NULL-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA384               \"RSA-PSK-NULL-SHA384\"\n\n/* SRP ciphersuite from RFC 5054 */\n# define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA          \"SRP-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA      \"SRP-RSA-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA      \"SRP-DSS-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA           \"SRP-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA       \"SRP-RSA-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA       \"SRP-DSS-AES-128-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA           \"SRP-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA       \"SRP-RSA-AES-256-CBC-SHA\"\n# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA       \"SRP-DSS-AES-256-CBC-SHA\"\n\n/* Camellia ciphersuites from RFC4132 */\n# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA          \"CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA       \"DH-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA       \"DH-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA      \"DHE-DSS-CAMELLIA128-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA      \"DHE-RSA-CAMELLIA128-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA          \"ADH-CAMELLIA128-SHA\"\n\n# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA          \"CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA       \"DH-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA       \"DH-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA      \"DHE-DSS-CAMELLIA256-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA      \"DHE-RSA-CAMELLIA256-SHA\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA          \"ADH-CAMELLIA256-SHA\"\n\n/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */\n# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256               \"CAMELLIA128-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256            \"DH-DSS-CAMELLIA128-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256            \"DH-RSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256           \"DHE-DSS-CAMELLIA128-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256           \"DHE-RSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256               \"ADH-CAMELLIA128-SHA256\"\n\n# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256               \"CAMELLIA256-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256            \"DH-DSS-CAMELLIA256-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256            \"DH-RSA-CAMELLIA256-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256           \"DHE-DSS-CAMELLIA256-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256           \"DHE-RSA-CAMELLIA256-SHA256\"\n# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256               \"ADH-CAMELLIA256-SHA256\"\n\n# define TLS1_TXT_PSK_WITH_CAMELLIA_128_CBC_SHA256               \"PSK-CAMELLIA128-SHA256\"\n# define TLS1_TXT_PSK_WITH_CAMELLIA_256_CBC_SHA384               \"PSK-CAMELLIA256-SHA384\"\n# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256           \"DHE-PSK-CAMELLIA128-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384           \"DHE-PSK-CAMELLIA256-SHA384\"\n# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256           \"RSA-PSK-CAMELLIA128-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384           \"RSA-PSK-CAMELLIA256-SHA384\"\n# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256         \"ECDHE-PSK-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384         \"ECDHE-PSK-CAMELLIA256-SHA384\"\n\n/* SEED ciphersuites from RFC4162 */\n# define TLS1_TXT_RSA_WITH_SEED_SHA                      \"SEED-SHA\"\n# define TLS1_TXT_DH_DSS_WITH_SEED_SHA                   \"DH-DSS-SEED-SHA\"\n# define TLS1_TXT_DH_RSA_WITH_SEED_SHA                   \"DH-RSA-SEED-SHA\"\n# define TLS1_TXT_DHE_DSS_WITH_SEED_SHA                  \"DHE-DSS-SEED-SHA\"\n# define TLS1_TXT_DHE_RSA_WITH_SEED_SHA                  \"DHE-RSA-SEED-SHA\"\n# define TLS1_TXT_ADH_WITH_SEED_SHA                      \"ADH-SEED-SHA\"\n\n/* TLS v1.2 ciphersuites */\n# define TLS1_TXT_RSA_WITH_NULL_SHA256                   \"NULL-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_128_SHA256                \"AES128-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_SHA256                \"AES256-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256             \"DH-DSS-AES128-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256             \"DH-RSA-AES128-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256            \"DHE-DSS-AES128-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256            \"DHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256             \"DH-DSS-AES256-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256             \"DH-RSA-AES256-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256            \"DHE-DSS-AES256-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256            \"DHE-RSA-AES256-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_128_SHA256                \"ADH-AES128-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_SHA256                \"ADH-AES256-SHA256\"\n\n/* TLS v1.2 GCM ciphersuites from RFC5288 */\n# define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256            \"AES128-GCM-SHA256\"\n# define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384            \"AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256        \"DHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384        \"DHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256         \"DH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384         \"DH-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256        \"DHE-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384        \"DHE-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256         \"DH-DSS-AES128-GCM-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384         \"DH-DSS-AES256-GCM-SHA384\"\n# define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256            \"ADH-AES128-GCM-SHA256\"\n# define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384            \"ADH-AES256-GCM-SHA384\"\n\n/* CCM ciphersuites from RFC6655 */\n# define TLS1_TXT_RSA_WITH_AES_128_CCM                   \"AES128-CCM\"\n# define TLS1_TXT_RSA_WITH_AES_256_CCM                   \"AES256-CCM\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM               \"DHE-RSA-AES128-CCM\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM               \"DHE-RSA-AES256-CCM\"\n\n# define TLS1_TXT_RSA_WITH_AES_128_CCM_8                 \"AES128-CCM8\"\n# define TLS1_TXT_RSA_WITH_AES_256_CCM_8                 \"AES256-CCM8\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM_8             \"DHE-RSA-AES128-CCM8\"\n# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM_8             \"DHE-RSA-AES256-CCM8\"\n\n# define TLS1_TXT_PSK_WITH_AES_128_CCM                   \"PSK-AES128-CCM\"\n# define TLS1_TXT_PSK_WITH_AES_256_CCM                   \"PSK-AES256-CCM\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM               \"DHE-PSK-AES128-CCM\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM               \"DHE-PSK-AES256-CCM\"\n\n# define TLS1_TXT_PSK_WITH_AES_128_CCM_8                 \"PSK-AES128-CCM8\"\n# define TLS1_TXT_PSK_WITH_AES_256_CCM_8                 \"PSK-AES256-CCM8\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM_8             \"DHE-PSK-AES128-CCM8\"\n# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM_8             \"DHE-PSK-AES256-CCM8\"\n\n/* CCM ciphersuites from RFC7251 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM       \"ECDHE-ECDSA-AES128-CCM\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM       \"ECDHE-ECDSA-AES256-CCM\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM_8     \"ECDHE-ECDSA-AES128-CCM8\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM_8     \"ECDHE-ECDSA-AES256-CCM8\"\n\n/* ECDH HMAC based ciphersuites from RFC5289 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256    \"ECDHE-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384    \"ECDHE-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256     \"ECDH-ECDSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384     \"ECDH-ECDSA-AES256-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256      \"ECDHE-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384      \"ECDHE-RSA-AES256-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256       \"ECDH-RSA-AES128-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384       \"ECDH-RSA-AES256-SHA384\"\n\n/* ECDH GCM based ciphersuites from RFC5289 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256    \"ECDHE-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384    \"ECDHE-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256     \"ECDH-ECDSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384     \"ECDH-ECDSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256      \"ECDHE-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384      \"ECDHE-RSA-AES256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256       \"ECDH-RSA-AES128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384       \"ECDH-RSA-AES256-GCM-SHA384\"\n\n/* TLS v1.2 PSK GCM ciphersuites from RFC5487 */\n# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256            \"PSK-AES128-GCM-SHA256\"\n# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384            \"PSK-AES256-GCM-SHA384\"\n\n/* ECDHE PSK ciphersuites from RFC 5489 */\n# define TLS1_TXT_ECDHE_PSK_WITH_RC4_128_SHA               \"ECDHE-PSK-RC4-SHA\"\n# define TLS1_TXT_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA          \"ECDHE-PSK-3DES-EDE-CBC-SHA\"\n# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA           \"ECDHE-PSK-AES128-CBC-SHA\"\n# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA           \"ECDHE-PSK-AES256-CBC-SHA\"\n\n# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA256        \"ECDHE-PSK-AES128-CBC-SHA256\"\n# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA384        \"ECDHE-PSK-AES256-CBC-SHA384\"\n\n# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA                  \"ECDHE-PSK-NULL-SHA\"\n# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA256               \"ECDHE-PSK-NULL-SHA256\"\n# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA384               \"ECDHE-PSK-NULL-SHA384\"\n\n/* Camellia-CBC ciphersuites from RFC6367 */\n# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 \"ECDHE-ECDSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 \"ECDHE-ECDSA-CAMELLIA256-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256  \"ECDH-ECDSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384  \"ECDH-ECDSA-CAMELLIA256-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256   \"ECDHE-RSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384   \"ECDHE-RSA-CAMELLIA256-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256    \"ECDH-RSA-CAMELLIA128-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384    \"ECDH-RSA-CAMELLIA256-SHA384\"\n\n/* draft-ietf-tls-chacha20-poly1305-03 */\n# define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305         \"ECDHE-RSA-CHACHA20-POLY1305\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305       \"ECDHE-ECDSA-CHACHA20-POLY1305\"\n# define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305           \"DHE-RSA-CHACHA20-POLY1305\"\n# define TLS1_TXT_PSK_WITH_CHACHA20_POLY1305               \"PSK-CHACHA20-POLY1305\"\n# define TLS1_TXT_ECDHE_PSK_WITH_CHACHA20_POLY1305         \"ECDHE-PSK-CHACHA20-POLY1305\"\n# define TLS1_TXT_DHE_PSK_WITH_CHACHA20_POLY1305           \"DHE-PSK-CHACHA20-POLY1305\"\n# define TLS1_TXT_RSA_PSK_WITH_CHACHA20_POLY1305           \"RSA-PSK-CHACHA20-POLY1305\"\n\n/* Aria ciphersuites from RFC6209 */\n# define TLS1_TXT_RSA_WITH_ARIA_128_GCM_SHA256             \"ARIA128-GCM-SHA256\"\n# define TLS1_TXT_RSA_WITH_ARIA_256_GCM_SHA384             \"ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DHE_RSA_WITH_ARIA_128_GCM_SHA256         \"DHE-RSA-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DHE_RSA_WITH_ARIA_256_GCM_SHA384         \"DHE-RSA-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DH_RSA_WITH_ARIA_128_GCM_SHA256          \"DH-RSA-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DH_RSA_WITH_ARIA_256_GCM_SHA384          \"DH-RSA-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DHE_DSS_WITH_ARIA_128_GCM_SHA256         \"DHE-DSS-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DHE_DSS_WITH_ARIA_256_GCM_SHA384         \"DHE-DSS-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DH_DSS_WITH_ARIA_128_GCM_SHA256          \"DH-DSS-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DH_DSS_WITH_ARIA_256_GCM_SHA384          \"DH-DSS-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DH_anon_WITH_ARIA_128_GCM_SHA256         \"ADH-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DH_anon_WITH_ARIA_256_GCM_SHA384         \"ADH-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256     \"ECDHE-ECDSA-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384     \"ECDHE-ECDSA-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256      \"ECDH-ECDSA-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384      \"ECDH-ECDSA-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256       \"ECDHE-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384       \"ECDHE-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_ECDH_RSA_WITH_ARIA_128_GCM_SHA256        \"ECDH-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_ECDH_RSA_WITH_ARIA_256_GCM_SHA384        \"ECDH-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_PSK_WITH_ARIA_128_GCM_SHA256             \"PSK-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_PSK_WITH_ARIA_256_GCM_SHA384             \"PSK-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_DHE_PSK_WITH_ARIA_128_GCM_SHA256         \"DHE-PSK-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_DHE_PSK_WITH_ARIA_256_GCM_SHA384         \"DHE-PSK-ARIA256-GCM-SHA384\"\n# define TLS1_TXT_RSA_PSK_WITH_ARIA_128_GCM_SHA256         \"RSA-PSK-ARIA128-GCM-SHA256\"\n# define TLS1_TXT_RSA_PSK_WITH_ARIA_256_GCM_SHA384         \"RSA-PSK-ARIA256-GCM-SHA384\"\n\n# define TLS_CT_RSA_SIGN                 1\n# define TLS_CT_DSS_SIGN                 2\n# define TLS_CT_RSA_FIXED_DH             3\n# define TLS_CT_DSS_FIXED_DH             4\n# define TLS_CT_ECDSA_SIGN               64\n# define TLS_CT_RSA_FIXED_ECDH           65\n# define TLS_CT_ECDSA_FIXED_ECDH         66\n# define TLS_CT_GOST01_SIGN              22\n# define TLS_CT_GOST12_SIGN              238\n# define TLS_CT_GOST12_512_SIGN          239\n\n/*\n * when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see\n * comment there)\n */\n# define TLS_CT_NUMBER                   10\n\n# if defined(SSL3_CT_NUMBER)\n#  if TLS_CT_NUMBER != SSL3_CT_NUMBER\n#    error \"SSL/TLS CT_NUMBER values do not match\"\n#  endif\n# endif\n\n# define TLS1_FINISH_MAC_LENGTH          12\n\n# define TLS_MD_MAX_CONST_SIZE                   22\n# define TLS_MD_CLIENT_FINISH_CONST              \"client finished\"\n# define TLS_MD_CLIENT_FINISH_CONST_SIZE         15\n# define TLS_MD_SERVER_FINISH_CONST              \"server finished\"\n# define TLS_MD_SERVER_FINISH_CONST_SIZE         15\n# define TLS_MD_KEY_EXPANSION_CONST              \"key expansion\"\n# define TLS_MD_KEY_EXPANSION_CONST_SIZE         13\n# define TLS_MD_CLIENT_WRITE_KEY_CONST           \"client write key\"\n# define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_SERVER_WRITE_KEY_CONST           \"server write key\"\n# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE      16\n# define TLS_MD_IV_BLOCK_CONST                   \"IV block\"\n# define TLS_MD_IV_BLOCK_CONST_SIZE              8\n# define TLS_MD_MASTER_SECRET_CONST              \"master secret\"\n# define TLS_MD_MASTER_SECRET_CONST_SIZE         13\n# define TLS_MD_EXTENDED_MASTER_SECRET_CONST     \"extended master secret\"\n# define TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE        22\n\n# ifdef CHARSET_EBCDIC\n#  undef TLS_MD_CLIENT_FINISH_CONST\n/*\n * client finished\n */\n#  define TLS_MD_CLIENT_FINISH_CONST    \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_FINISH_CONST\n/*\n * server finished\n */\n#  define TLS_MD_SERVER_FINISH_CONST    \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x66\\x69\\x6e\\x69\\x73\\x68\\x65\\x64\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_KEY_EXPANSION_CONST\n/*\n * key expansion\n */\n#  define TLS_MD_KEY_EXPANSION_CONST    \"\\x6b\\x65\\x79\\x20\\x65\\x78\\x70\\x61\\x6e\\x73\\x69\\x6f\\x6e\"\n\n#  undef TLS_MD_CLIENT_WRITE_KEY_CONST\n/*\n * client write key\n */\n#  define TLS_MD_CLIENT_WRITE_KEY_CONST \"\\x63\\x6c\\x69\\x65\\x6e\\x74\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_SERVER_WRITE_KEY_CONST\n/*\n * server write key\n */\n#  define TLS_MD_SERVER_WRITE_KEY_CONST \"\\x73\\x65\\x72\\x76\\x65\\x72\\x20\\x77\\x72\\x69\\x74\\x65\\x20\\x6b\\x65\\x79\"\n\n#  undef TLS_MD_IV_BLOCK_CONST\n/*\n * IV block\n */\n#  define TLS_MD_IV_BLOCK_CONST         \"\\x49\\x56\\x20\\x62\\x6c\\x6f\\x63\\x6b\"\n\n#  undef TLS_MD_MASTER_SECRET_CONST\n/*\n * master secret\n */\n#  define TLS_MD_MASTER_SECRET_CONST    \"\\x6d\\x61\\x73\\x74\\x65\\x72\\x20\\x73\\x65\\x63\\x72\\x65\\x74\"\n#  undef TLS_MD_EXTENDED_MASTER_SECRET_CONST\n/*\n * extended master secret\n */\n#  define TLS_MD_EXTENDED_MASTER_SECRET_CONST    \"\\x65\\x78\\x74\\x65\\x6e\\x64\\x65\\x64\\x20\\x6d\\x61\\x73\\x74\\x65\\x72\\x20\\x73\\x65\\x63\\x72\\x65\\x74\"\n# endif\n\n/* TLS Session Ticket extension struct */\nstruct tls_session_ticket_ext_st {\n    unsigned short length;\n    void *data;\n};\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ts.h",
    "content": "/*\n * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_TS_H\n# define HEADER_TS_H\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_TS\n# include <openssl/symhacks.h>\n# include <openssl/buffer.h>\n# include <openssl/evp.h>\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n# include <openssl/rsa.h>\n# include <openssl/dsa.h>\n# include <openssl/dh.h>\n# include <openssl/tserr.h>\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n# include <openssl/x509.h>\n# include <openssl/x509v3.h>\n\ntypedef struct TS_msg_imprint_st TS_MSG_IMPRINT;\ntypedef struct TS_req_st TS_REQ;\ntypedef struct TS_accuracy_st TS_ACCURACY;\ntypedef struct TS_tst_info_st TS_TST_INFO;\n\n/* Possible values for status. */\n# define TS_STATUS_GRANTED                       0\n# define TS_STATUS_GRANTED_WITH_MODS             1\n# define TS_STATUS_REJECTION                     2\n# define TS_STATUS_WAITING                       3\n# define TS_STATUS_REVOCATION_WARNING            4\n# define TS_STATUS_REVOCATION_NOTIFICATION       5\n\n/* Possible values for failure_info. */\n# define TS_INFO_BAD_ALG                 0\n# define TS_INFO_BAD_REQUEST             2\n# define TS_INFO_BAD_DATA_FORMAT         5\n# define TS_INFO_TIME_NOT_AVAILABLE      14\n# define TS_INFO_UNACCEPTED_POLICY       15\n# define TS_INFO_UNACCEPTED_EXTENSION    16\n# define TS_INFO_ADD_INFO_NOT_AVAILABLE  17\n# define TS_INFO_SYSTEM_FAILURE          25\n\n\ntypedef struct TS_status_info_st TS_STATUS_INFO;\ntypedef struct ESS_issuer_serial ESS_ISSUER_SERIAL;\ntypedef struct ESS_cert_id ESS_CERT_ID;\ntypedef struct ESS_signing_cert ESS_SIGNING_CERT;\n\nDEFINE_STACK_OF(ESS_CERT_ID)\n\ntypedef struct ESS_cert_id_v2_st ESS_CERT_ID_V2;\ntypedef struct ESS_signing_cert_v2_st ESS_SIGNING_CERT_V2;\n\nDEFINE_STACK_OF(ESS_CERT_ID_V2)\n\ntypedef struct TS_resp_st TS_RESP;\n\nTS_REQ *TS_REQ_new(void);\nvoid TS_REQ_free(TS_REQ *a);\nint i2d_TS_REQ(const TS_REQ *a, unsigned char **pp);\nTS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length);\n\nTS_REQ *TS_REQ_dup(TS_REQ *a);\n\n#ifndef OPENSSL_NO_STDIO\nTS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a);\nint i2d_TS_REQ_fp(FILE *fp, TS_REQ *a);\n#endif\nTS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a);\nint i2d_TS_REQ_bio(BIO *fp, TS_REQ *a);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_new(void);\nvoid TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a);\nint i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp);\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a,\n                                   const unsigned char **pp, long length);\n\nTS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a);\n\n#ifndef OPENSSL_NO_STDIO\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a);\n#endif\nTS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a);\nint i2d_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT *a);\n\nTS_RESP *TS_RESP_new(void);\nvoid TS_RESP_free(TS_RESP *a);\nint i2d_TS_RESP(const TS_RESP *a, unsigned char **pp);\nTS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length);\nTS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token);\nTS_RESP *TS_RESP_dup(TS_RESP *a);\n\n#ifndef OPENSSL_NO_STDIO\nTS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a);\nint i2d_TS_RESP_fp(FILE *fp, TS_RESP *a);\n#endif\nTS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a);\nint i2d_TS_RESP_bio(BIO *bio, TS_RESP *a);\n\nTS_STATUS_INFO *TS_STATUS_INFO_new(void);\nvoid TS_STATUS_INFO_free(TS_STATUS_INFO *a);\nint i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp);\nTS_STATUS_INFO *d2i_TS_STATUS_INFO(TS_STATUS_INFO **a,\n                                   const unsigned char **pp, long length);\nTS_STATUS_INFO *TS_STATUS_INFO_dup(TS_STATUS_INFO *a);\n\nTS_TST_INFO *TS_TST_INFO_new(void);\nvoid TS_TST_INFO_free(TS_TST_INFO *a);\nint i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp);\nTS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp,\n                             long length);\nTS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a);\n\n#ifndef OPENSSL_NO_STDIO\nTS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a);\n#endif\nTS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a);\nint i2d_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO *a);\n\nTS_ACCURACY *TS_ACCURACY_new(void);\nvoid TS_ACCURACY_free(TS_ACCURACY *a);\nint i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp);\nTS_ACCURACY *d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp,\n                             long length);\nTS_ACCURACY *TS_ACCURACY_dup(TS_ACCURACY *a);\n\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void);\nvoid ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a);\nint i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **pp);\nESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a,\n                                         const unsigned char **pp,\n                                         long length);\nESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a);\n\nESS_CERT_ID *ESS_CERT_ID_new(void);\nvoid ESS_CERT_ID_free(ESS_CERT_ID *a);\nint i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp);\nESS_CERT_ID *d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp,\n                             long length);\nESS_CERT_ID *ESS_CERT_ID_dup(ESS_CERT_ID *a);\n\nESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void);\nvoid ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a);\nint i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **pp);\nESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a,\n                                       const unsigned char **pp, long length);\nESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a);\n\nESS_CERT_ID_V2 *ESS_CERT_ID_V2_new(void);\nvoid ESS_CERT_ID_V2_free(ESS_CERT_ID_V2 *a);\nint i2d_ESS_CERT_ID_V2(const ESS_CERT_ID_V2 *a, unsigned char **pp);\nESS_CERT_ID_V2 *d2i_ESS_CERT_ID_V2(ESS_CERT_ID_V2 **a,\n                                   const unsigned char **pp, long length);\nESS_CERT_ID_V2 *ESS_CERT_ID_V2_dup(ESS_CERT_ID_V2 *a);\n\nESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_new(void);\nvoid ESS_SIGNING_CERT_V2_free(ESS_SIGNING_CERT_V2 *a);\nint i2d_ESS_SIGNING_CERT_V2(const ESS_SIGNING_CERT_V2 *a, unsigned char **pp);\nESS_SIGNING_CERT_V2 *d2i_ESS_SIGNING_CERT_V2(ESS_SIGNING_CERT_V2 **a,\n                                             const unsigned char **pp,\n                                             long length);\nESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_dup(ESS_SIGNING_CERT_V2 *a);\n\nint TS_REQ_set_version(TS_REQ *a, long version);\nlong TS_REQ_get_version(const TS_REQ *a);\n\nint TS_STATUS_INFO_set_status(TS_STATUS_INFO *a, int i);\nconst ASN1_INTEGER *TS_STATUS_INFO_get0_status(const TS_STATUS_INFO *a);\n\nconst STACK_OF(ASN1_UTF8STRING) *\nTS_STATUS_INFO_get0_text(const TS_STATUS_INFO *a);\n\nconst ASN1_BIT_STRING *\nTS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a);\n\nint TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a);\n\nint TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg);\nX509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a);\n\nint TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len);\nASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a);\n\nint TS_REQ_set_policy_id(TS_REQ *a, const ASN1_OBJECT *policy);\nASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a);\n\nint TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a);\n\nint TS_REQ_set_cert_req(TS_REQ *a, int cert_req);\nint TS_REQ_get_cert_req(const TS_REQ *a);\n\nSTACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a);\nvoid TS_REQ_ext_free(TS_REQ *a);\nint TS_REQ_get_ext_count(TS_REQ *a);\nint TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos);\nint TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos);\nint TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos);\nX509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc);\nX509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc);\nint TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc);\nvoid *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx);\n\n/* Function declarations for TS_REQ defined in ts/ts_req_print.c */\n\nint TS_REQ_print_bio(BIO *bio, TS_REQ *a);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */\n\nint TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info);\nTS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a);\n\n/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */\nvoid TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info);\nPKCS7 *TS_RESP_get_token(TS_RESP *a);\nTS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a);\n\nint TS_TST_INFO_set_version(TS_TST_INFO *a, long version);\nlong TS_TST_INFO_get_version(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id);\nASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint);\nTS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a);\n\nint TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial);\nconst ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime);\nconst ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy);\nTS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a);\n\nint TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds);\nconst ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis);\nconst ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a);\n\nint TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros);\nconst ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a);\n\nint TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering);\nint TS_TST_INFO_get_ordering(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce);\nconst ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a);\n\nint TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa);\nGENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a);\n\nSTACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a);\nvoid TS_TST_INFO_ext_free(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_count(TS_TST_INFO *a);\nint TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos);\nint TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj,\n                               int lastpos);\nint TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos);\nX509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc);\nX509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc);\nint TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc);\nvoid *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx);\n\n/*\n * Declarations related to response generation, defined in ts/ts_resp_sign.c.\n */\n\n/* Optional flags for response generation. */\n\n/* Don't include the TSA name in response. */\n# define TS_TSA_NAME             0x01\n\n/* Set ordering to true in response. */\n# define TS_ORDERING             0x02\n\n/*\n * Include the signer certificate and the other specified certificates in\n * the ESS signing certificate attribute beside the PKCS7 signed data.\n * Only the signer certificates is included by default.\n */\n# define TS_ESS_CERT_ID_CHAIN    0x04\n\n/* Forward declaration. */\nstruct TS_resp_ctx;\n\n/* This must return a unique number less than 160 bits long. */\ntypedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *);\n\n/*\n * This must return the seconds and microseconds since Jan 1, 1970 in the sec\n * and usec variables allocated by the caller. Return non-zero for success\n * and zero for failure.\n */\ntypedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec,\n                           long *usec);\n\n/*\n * This must process the given extension. It can modify the TS_TST_INFO\n * object of the context. Return values: !0 (processed), 0 (error, it must\n * set the status info/failure info of the response).\n */\ntypedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *,\n                                void *);\n\ntypedef struct TS_resp_ctx TS_RESP_CTX;\n\nDEFINE_STACK_OF_CONST(EVP_MD)\n\n/* Creates a response context that can be used for generating responses. */\nTS_RESP_CTX *TS_RESP_CTX_new(void);\nvoid TS_RESP_CTX_free(TS_RESP_CTX *ctx);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key);\n\nint TS_RESP_CTX_set_signer_digest(TS_RESP_CTX *ctx,\n                                  const EVP_MD *signer_digest);\nint TS_RESP_CTX_set_ess_cert_id_digest(TS_RESP_CTX *ctx, const EVP_MD *md);\n\n/* This parameter must be set. */\nint TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *def_policy);\n\n/* No additional certs are included in the response by default. */\nint TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs);\n\n/*\n * Adds a new acceptable policy, only the default policy is accepted by\n * default.\n */\nint TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy);\n\n/*\n * Adds a new acceptable message digest. Note that no message digests are\n * accepted by default. The md argument is shared with the caller.\n */\nint TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md);\n\n/* Accuracy is not included by default. */\nint TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx,\n                             int secs, int millis, int micros);\n\n/*\n * Clock precision digits, i.e. the number of decimal digits: '0' means sec,\n * '3' msec, '6' usec, and so on. Default is 0.\n */\nint TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx,\n                                           unsigned clock_precision_digits);\n/* At most we accept usec precision. */\n# define TS_MAX_CLOCK_PRECISION_DIGITS   6\n\n/* Maximum status message length */\n# define TS_MAX_STATUS_LENGTH   (1024 * 1024)\n\n/* No flags are set by default. */\nvoid TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags);\n\n/* Default callback always returns a constant. */\nvoid TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data);\n\n/* Default callback uses the gettimeofday() and gmtime() system calls. */\nvoid TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data);\n\n/*\n * Default callback rejects all extensions. The extension callback is called\n * when the TS_TST_INFO object is already set up and not signed yet.\n */\n/* FIXME: extension handling is not tested yet. */\nvoid TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx,\n                                  TS_extension_cb cb, void *data);\n\n/* The following methods can be used in the callbacks. */\nint TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx,\n                                int status, const char *text);\n\n/* Sets the status info only if it is still TS_STATUS_GRANTED. */\nint TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx,\n                                     int status, const char *text);\n\nint TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure);\n\n/* The get methods below can be used in the extension callback. */\nTS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx);\n\nTS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx);\n\n/*\n * Creates the signed TS_TST_INFO and puts it in TS_RESP.\n * In case of errors it sets the status info properly.\n * Returns NULL only in case of memory allocation/fatal error.\n */\nTS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio);\n\n/*\n * Declarations related to response verification,\n * they are defined in ts/ts_resp_verify.c.\n */\n\nint TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs,\n                             X509_STORE *store, X509 **signer_out);\n\n/* Context structure for the generic verify method. */\n\n/* Verify the signer's certificate and the signature of the response. */\n# define TS_VFY_SIGNATURE        (1u << 0)\n/* Verify the version number of the response. */\n# define TS_VFY_VERSION          (1u << 1)\n/* Verify if the policy supplied by the user matches the policy of the TSA. */\n# define TS_VFY_POLICY           (1u << 2)\n/*\n * Verify the message imprint provided by the user. This flag should not be\n * specified with TS_VFY_DATA.\n */\n# define TS_VFY_IMPRINT          (1u << 3)\n/*\n * Verify the message imprint computed by the verify method from the user\n * provided data and the MD algorithm of the response. This flag should not\n * be specified with TS_VFY_IMPRINT.\n */\n# define TS_VFY_DATA             (1u << 4)\n/* Verify the nonce value. */\n# define TS_VFY_NONCE            (1u << 5)\n/* Verify if the TSA name field matches the signer certificate. */\n# define TS_VFY_SIGNER           (1u << 6)\n/* Verify if the TSA name field equals to the user provided name. */\n# define TS_VFY_TSA_NAME         (1u << 7)\n\n/* You can use the following convenience constants. */\n# define TS_VFY_ALL_IMPRINT      (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_IMPRINT       \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n# define TS_VFY_ALL_DATA         (TS_VFY_SIGNATURE       \\\n                                 | TS_VFY_VERSION       \\\n                                 | TS_VFY_POLICY        \\\n                                 | TS_VFY_DATA          \\\n                                 | TS_VFY_NONCE         \\\n                                 | TS_VFY_SIGNER        \\\n                                 | TS_VFY_TSA_NAME)\n\ntypedef struct TS_verify_ctx TS_VERIFY_CTX;\n\nint TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response);\nint TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token);\n\n/*\n * Declarations related to response verification context,\n */\nTS_VERIFY_CTX *TS_VERIFY_CTX_new(void);\nvoid TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx);\nvoid TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx);\nint TS_VERIFY_CTX_set_flags(TS_VERIFY_CTX *ctx, int f);\nint TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f);\nBIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b);\nunsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx,\n                                         unsigned char *hexstr, long len);\nX509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s);\nSTACK_OF(X509) *TS_VERIFY_CTS_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs);\n\n/*-\n * If ctx is NULL, it allocates and returns a new object, otherwise\n * it returns ctx. It initialises all the members as follows:\n * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE)\n * certs = NULL\n * store = NULL\n * policy = policy from the request or NULL if absent (in this case\n *      TS_VFY_POLICY is cleared from flags as well)\n * md_alg = MD algorithm from request\n * imprint, imprint_len = imprint from request\n * data = NULL\n * nonce, nonce_len = nonce from the request or NULL if absent (in this case\n *      TS_VFY_NONCE is cleared from flags as well)\n * tsa_name = NULL\n * Important: after calling this method TS_VFY_SIGNATURE should be added!\n */\nTS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx);\n\n/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */\n\nint TS_RESP_print_bio(BIO *bio, TS_RESP *a);\nint TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a);\nint TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a);\n\n/* Common utility functions defined in ts/ts_lib.c */\n\nint TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num);\nint TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj);\nint TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions);\nint TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg);\nint TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg);\n\n/*\n * Function declarations for handling configuration options, defined in\n * ts/ts_conf.c\n */\n\nX509 *TS_CONF_load_cert(const char *file);\nSTACK_OF(X509) *TS_CONF_load_certs(const char *file);\nEVP_PKEY *TS_CONF_load_key(const char *file, const char *pass);\nconst char *TS_CONF_get_tsa_section(CONF *conf, const char *section);\nint TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb,\n                       TS_RESP_CTX *ctx);\n#ifndef OPENSSL_NO_ENGINE\nint TS_CONF_set_crypto_device(CONF *conf, const char *section,\n                              const char *device);\nint TS_CONF_set_default_engine(const char *name);\n#endif\nint TS_CONF_set_signer_cert(CONF *conf, const char *section,\n                            const char *cert, TS_RESP_CTX *ctx);\nint TS_CONF_set_certs(CONF *conf, const char *section, const char *certs,\n                      TS_RESP_CTX *ctx);\nint TS_CONF_set_signer_key(CONF *conf, const char *section,\n                           const char *key, const char *pass,\n                           TS_RESP_CTX *ctx);\nint TS_CONF_set_signer_digest(CONF *conf, const char *section,\n                               const char *md, TS_RESP_CTX *ctx);\nint TS_CONF_set_def_policy(CONF *conf, const char *section,\n                           const char *policy, TS_RESP_CTX *ctx);\nint TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_clock_precision_digits(CONF *conf, const char *section,\n                                       TS_RESP_CTX *ctx);\nint TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx);\nint TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section,\n                                  TS_RESP_CTX *ctx);\nint TS_CONF_set_ess_cert_id_digest(CONF *conf, const char *section,\n                                      TS_RESP_CTX *ctx);\n\n#  ifdef  __cplusplus\n}\n#  endif\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/tserr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_TSERR_H\n# define HEADER_TSERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_TS\n\n#  ifdef  __cplusplus\nextern \"C\"\n#  endif\nint ERR_load_TS_strings(void);\n\n/*\n * TS function codes.\n */\n#  define TS_F_DEF_SERIAL_CB                               110\n#  define TS_F_DEF_TIME_CB                                 111\n#  define TS_F_ESS_ADD_SIGNING_CERT                        112\n#  define TS_F_ESS_ADD_SIGNING_CERT_V2                     147\n#  define TS_F_ESS_CERT_ID_NEW_INIT                        113\n#  define TS_F_ESS_CERT_ID_V2_NEW_INIT                     156\n#  define TS_F_ESS_SIGNING_CERT_NEW_INIT                   114\n#  define TS_F_ESS_SIGNING_CERT_V2_NEW_INIT                157\n#  define TS_F_INT_TS_RESP_VERIFY_TOKEN                    149\n#  define TS_F_PKCS7_TO_TS_TST_INFO                        148\n#  define TS_F_TS_ACCURACY_SET_MICROS                      115\n#  define TS_F_TS_ACCURACY_SET_MILLIS                      116\n#  define TS_F_TS_ACCURACY_SET_SECONDS                     117\n#  define TS_F_TS_CHECK_IMPRINTS                           100\n#  define TS_F_TS_CHECK_NONCES                             101\n#  define TS_F_TS_CHECK_POLICY                             102\n#  define TS_F_TS_CHECK_SIGNING_CERTS                      103\n#  define TS_F_TS_CHECK_STATUS_INFO                        104\n#  define TS_F_TS_COMPUTE_IMPRINT                          145\n#  define TS_F_TS_CONF_INVALID                             151\n#  define TS_F_TS_CONF_LOAD_CERT                           153\n#  define TS_F_TS_CONF_LOAD_CERTS                          154\n#  define TS_F_TS_CONF_LOAD_KEY                            155\n#  define TS_F_TS_CONF_LOOKUP_FAIL                         152\n#  define TS_F_TS_CONF_SET_DEFAULT_ENGINE                  146\n#  define TS_F_TS_GET_STATUS_TEXT                          105\n#  define TS_F_TS_MSG_IMPRINT_SET_ALGO                     118\n#  define TS_F_TS_REQ_SET_MSG_IMPRINT                      119\n#  define TS_F_TS_REQ_SET_NONCE                            120\n#  define TS_F_TS_REQ_SET_POLICY_ID                        121\n#  define TS_F_TS_RESP_CREATE_RESPONSE                     122\n#  define TS_F_TS_RESP_CREATE_TST_INFO                     123\n#  define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO                124\n#  define TS_F_TS_RESP_CTX_ADD_MD                          125\n#  define TS_F_TS_RESP_CTX_ADD_POLICY                      126\n#  define TS_F_TS_RESP_CTX_NEW                             127\n#  define TS_F_TS_RESP_CTX_SET_ACCURACY                    128\n#  define TS_F_TS_RESP_CTX_SET_CERTS                       129\n#  define TS_F_TS_RESP_CTX_SET_DEF_POLICY                  130\n#  define TS_F_TS_RESP_CTX_SET_SIGNER_CERT                 131\n#  define TS_F_TS_RESP_CTX_SET_STATUS_INFO                 132\n#  define TS_F_TS_RESP_GET_POLICY                          133\n#  define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION          134\n#  define TS_F_TS_RESP_SET_STATUS_INFO                     135\n#  define TS_F_TS_RESP_SET_TST_INFO                        150\n#  define TS_F_TS_RESP_SIGN                                136\n#  define TS_F_TS_RESP_VERIFY_SIGNATURE                    106\n#  define TS_F_TS_TST_INFO_SET_ACCURACY                    137\n#  define TS_F_TS_TST_INFO_SET_MSG_IMPRINT                 138\n#  define TS_F_TS_TST_INFO_SET_NONCE                       139\n#  define TS_F_TS_TST_INFO_SET_POLICY_ID                   140\n#  define TS_F_TS_TST_INFO_SET_SERIAL                      141\n#  define TS_F_TS_TST_INFO_SET_TIME                        142\n#  define TS_F_TS_TST_INFO_SET_TSA                         143\n#  define TS_F_TS_VERIFY                                   108\n#  define TS_F_TS_VERIFY_CERT                              109\n#  define TS_F_TS_VERIFY_CTX_NEW                           144\n\n/*\n * TS reason codes.\n */\n#  define TS_R_BAD_PKCS7_TYPE                              132\n#  define TS_R_BAD_TYPE                                    133\n#  define TS_R_CANNOT_LOAD_CERT                            137\n#  define TS_R_CANNOT_LOAD_KEY                             138\n#  define TS_R_CERTIFICATE_VERIFY_ERROR                    100\n#  define TS_R_COULD_NOT_SET_ENGINE                        127\n#  define TS_R_COULD_NOT_SET_TIME                          115\n#  define TS_R_DETACHED_CONTENT                            134\n#  define TS_R_ESS_ADD_SIGNING_CERT_ERROR                  116\n#  define TS_R_ESS_ADD_SIGNING_CERT_V2_ERROR               139\n#  define TS_R_ESS_SIGNING_CERTIFICATE_ERROR               101\n#  define TS_R_INVALID_NULL_POINTER                        102\n#  define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE          117\n#  define TS_R_MESSAGE_IMPRINT_MISMATCH                    103\n#  define TS_R_NONCE_MISMATCH                              104\n#  define TS_R_NONCE_NOT_RETURNED                          105\n#  define TS_R_NO_CONTENT                                  106\n#  define TS_R_NO_TIME_STAMP_TOKEN                         107\n#  define TS_R_PKCS7_ADD_SIGNATURE_ERROR                   118\n#  define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR                 119\n#  define TS_R_PKCS7_TO_TS_TST_INFO_FAILED                 129\n#  define TS_R_POLICY_MISMATCH                             108\n#  define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE      120\n#  define TS_R_RESPONSE_SETUP_ERROR                        121\n#  define TS_R_SIGNATURE_FAILURE                           109\n#  define TS_R_THERE_MUST_BE_ONE_SIGNER                    110\n#  define TS_R_TIME_SYSCALL_ERROR                          122\n#  define TS_R_TOKEN_NOT_PRESENT                           130\n#  define TS_R_TOKEN_PRESENT                               131\n#  define TS_R_TSA_NAME_MISMATCH                           111\n#  define TS_R_TSA_UNTRUSTED                               112\n#  define TS_R_TST_INFO_SETUP_ERROR                        123\n#  define TS_R_TS_DATASIGN                                 124\n#  define TS_R_UNACCEPTABLE_POLICY                         125\n#  define TS_R_UNSUPPORTED_MD_ALGORITHM                    126\n#  define TS_R_UNSUPPORTED_VERSION                         113\n#  define TS_R_VAR_BAD_VALUE                               135\n#  define TS_R_VAR_LOOKUP_FAILURE                          136\n#  define TS_R_WRONG_CONTENT_TYPE                          114\n\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/txt_db.h",
    "content": "/*\n * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_TXT_DB_H\n# define HEADER_TXT_DB_H\n\n# include <openssl/opensslconf.h>\n# include <openssl/bio.h>\n# include <openssl/safestack.h>\n# include <openssl/lhash.h>\n\n# define DB_ERROR_OK                     0\n# define DB_ERROR_MALLOC                 1\n# define DB_ERROR_INDEX_CLASH            2\n# define DB_ERROR_INDEX_OUT_OF_RANGE     3\n# define DB_ERROR_NO_INDEX               4\n# define DB_ERROR_INSERT_INDEX_CLASH     5\n# define DB_ERROR_WRONG_NUM_FIELDS       6\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\ntypedef OPENSSL_STRING *OPENSSL_PSTRING;\nDEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING)\n\ntypedef struct txt_db_st {\n    int num_fields;\n    STACK_OF(OPENSSL_PSTRING) *data;\n    LHASH_OF(OPENSSL_STRING) **index;\n    int (**qual) (OPENSSL_STRING *);\n    long error;\n    long arg1;\n    long arg2;\n    OPENSSL_STRING *arg_row;\n} TXT_DB;\n\nTXT_DB *TXT_DB_read(BIO *in, int num);\nlong TXT_DB_write(BIO *out, TXT_DB *db);\nint TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),\n                        OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp);\nvoid TXT_DB_free(TXT_DB *db);\nOPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx,\n                                    OPENSSL_STRING *value);\nint TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value);\n\n#ifdef  __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/ui.h",
    "content": "/*\n * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_UI_H\n# define HEADER_UI_H\n\n# include <openssl/opensslconf.h>\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/crypto.h>\n# endif\n# include <openssl/safestack.h>\n# include <openssl/pem.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/uierr.h>\n\n/* For compatibility reasons, the macro OPENSSL_NO_UI is currently retained */\n# if OPENSSL_API_COMPAT < 0x10200000L\n#  ifdef OPENSSL_NO_UI_CONSOLE\n#   define OPENSSL_NO_UI\n#  endif\n# endif\n\n# ifdef  __cplusplus\nextern \"C\" {\n# endif\n\n/*\n * All the following functions return -1 or NULL on error and in some cases\n * (UI_process()) -2 if interrupted or in some other way cancelled. When\n * everything is fine, they return 0, a positive value or a non-NULL pointer,\n * all depending on their purpose.\n */\n\n/* Creators and destructor.   */\nUI *UI_new(void);\nUI *UI_new_method(const UI_METHOD *method);\nvoid UI_free(UI *ui);\n\n/*-\n   The following functions are used to add strings to be printed and prompt\n   strings to prompt for data.  The names are UI_{add,dup}_<function>_string\n   and UI_{add,dup}_input_boolean.\n\n   UI_{add,dup}_<function>_string have the following meanings:\n        add     add a text or prompt string.  The pointers given to these\n                functions are used verbatim, no copying is done.\n        dup     make a copy of the text or prompt string, then add the copy\n                to the collection of strings in the user interface.\n        <function>\n                The function is a name for the functionality that the given\n                string shall be used for.  It can be one of:\n                        input   use the string as data prompt.\n                        verify  use the string as verification prompt.  This\n                                is used to verify a previous input.\n                        info    use the string for informational output.\n                        error   use the string for error output.\n   Honestly, there's currently no difference between info and error for the\n   moment.\n\n   UI_{add,dup}_input_boolean have the same semantics for \"add\" and \"dup\",\n   and are typically used when one wants to prompt for a yes/no response.\n\n   All of the functions in this group take a UI and a prompt string.\n   The string input and verify addition functions also take a flag argument,\n   a buffer for the result to end up with, a minimum input size and a maximum\n   input size (the result buffer MUST be large enough to be able to contain\n   the maximum number of characters).  Additionally, the verify addition\n   functions takes another buffer to compare the result against.\n   The boolean input functions take an action description string (which should\n   be safe to ignore if the expected user action is obvious, for example with\n   a dialog box with an OK button and a Cancel button), a string of acceptable\n   characters to mean OK and to mean Cancel.  The two last strings are checked\n   to make sure they don't have common characters.  Additionally, the same\n   flag argument as for the string input is taken, as well as a result buffer.\n   The result buffer is required to be at least one byte long.  Depending on\n   the answer, the first character from the OK or the Cancel character strings\n   will be stored in the first byte of the result buffer.  No NUL will be\n   added, so the result is *not* a string.\n\n   On success, the all return an index of the added information.  That index\n   is useful when retrieving results with UI_get0_result(). */\nint UI_add_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_dup_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize);\nint UI_add_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_dup_verify_string(UI *ui, const char *prompt, int flags,\n                         char *result_buf, int minsize, int maxsize,\n                         const char *test_buf);\nint UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc,\n                         const char *ok_chars, const char *cancel_chars,\n                         int flags, char *result_buf);\nint UI_add_info_string(UI *ui, const char *text);\nint UI_dup_info_string(UI *ui, const char *text);\nint UI_add_error_string(UI *ui, const char *text);\nint UI_dup_error_string(UI *ui, const char *text);\n\n/* These are the possible flags.  They can be or'ed together. */\n/* Use to have echoing of input */\n# define UI_INPUT_FLAG_ECHO              0x01\n/*\n * Use a default password.  Where that password is found is completely up to\n * the application, it might for example be in the user data set with\n * UI_add_user_data().  It is not recommended to have more than one input in\n * each UI being marked with this flag, or the application might get\n * confused.\n */\n# define UI_INPUT_FLAG_DEFAULT_PWD       0x02\n\n/*-\n * The user of these routines may want to define flags of their own.  The core\n * UI won't look at those, but will pass them on to the method routines.  They\n * must use higher bits so they don't get confused with the UI bits above.\n * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use.  A good\n * example of use is this:\n *\n *    #define MY_UI_FLAG1       (0x01 << UI_INPUT_FLAG_USER_BASE)\n *\n*/\n# define UI_INPUT_FLAG_USER_BASE 16\n\n/*-\n * The following function helps construct a prompt.  object_desc is a\n * textual short description of the object, for example \"pass phrase\",\n * and object_name is the name of the object (might be a card name or\n * a file name.\n * The returned string shall always be allocated on the heap with\n * OPENSSL_malloc(), and need to be free'd with OPENSSL_free().\n *\n * If the ui_method doesn't contain a pointer to a user-defined prompt\n * constructor, a default string is built, looking like this:\n *\n *       \"Enter {object_desc} for {object_name}:\"\n *\n * So, if object_desc has the value \"pass phrase\" and object_name has\n * the value \"foo.key\", the resulting string is:\n *\n *       \"Enter pass phrase for foo.key:\"\n*/\nchar *UI_construct_prompt(UI *ui_method,\n                          const char *object_desc, const char *object_name);\n\n/*\n * The following function is used to store a pointer to user-specific data.\n * Any previous such pointer will be returned and replaced.\n *\n * For callback purposes, this function makes a lot more sense than using\n * ex_data, since the latter requires that different parts of OpenSSL or\n * applications share the same ex_data index.\n *\n * Note that the UI_OpenSSL() method completely ignores the user data. Other\n * methods may not, however.\n */\nvoid *UI_add_user_data(UI *ui, void *user_data);\n/*\n * Alternatively, this function is used to duplicate the user data.\n * This uses the duplicator method function.  The destroy function will\n * be used to free the user data in this case.\n */\nint UI_dup_user_data(UI *ui, void *user_data);\n/* We need a user data retrieving function as well.  */\nvoid *UI_get0_user_data(UI *ui);\n\n/* Return the result associated with a prompt given with the index i. */\nconst char *UI_get0_result(UI *ui, int i);\nint UI_get_result_length(UI *ui, int i);\n\n/* When all strings have been added, process the whole thing. */\nint UI_process(UI *ui);\n\n/*\n * Give a user interface parameterised control commands.  This can be used to\n * send down an integer, a data pointer or a function pointer, as well as be\n * used to get information from a UI.\n */\nint UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void));\n\n/* The commands */\n/*\n * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the\n * OpenSSL error stack before printing any info or added error messages and\n * before any prompting.\n */\n# define UI_CTRL_PRINT_ERRORS            1\n/*\n * Check if a UI_process() is possible to do again with the same instance of\n * a user interface.  This makes UI_ctrl() return 1 if it is redoable, and 0\n * if not.\n */\n# define UI_CTRL_IS_REDOABLE             2\n\n/* Some methods may use extra data */\n# define UI_set_app_data(s,arg)         UI_set_ex_data(s,0,arg)\n# define UI_get_app_data(s)             UI_get_ex_data(s,0)\n\n# define UI_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef)\nint UI_set_ex_data(UI *r, int idx, void *arg);\nvoid *UI_get_ex_data(UI *r, int idx);\n\n/* Use specific methods instead of the built-in one */\nvoid UI_set_default_method(const UI_METHOD *meth);\nconst UI_METHOD *UI_get_default_method(void);\nconst UI_METHOD *UI_get_method(UI *ui);\nconst UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth);\n\n# ifndef OPENSSL_NO_UI_CONSOLE\n\n/* The method with all the built-in thingies */\nUI_METHOD *UI_OpenSSL(void);\n\n# endif\n\n/*\n * NULL method.  Literally does nothing, but may serve as a placeholder\n * to avoid internal default.\n */\nconst UI_METHOD *UI_null(void);\n\n/* ---------- For method writers ---------- */\n/*-\n   A method contains a number of functions that implement the low level\n   of the User Interface.  The functions are:\n\n        an opener       This function starts a session, maybe by opening\n                        a channel to a tty, or by opening a window.\n        a writer        This function is called to write a given string,\n                        maybe to the tty, maybe as a field label in a\n                        window.\n        a flusher       This function is called to flush everything that\n                        has been output so far.  It can be used to actually\n                        display a dialog box after it has been built.\n        a reader        This function is called to read a given prompt,\n                        maybe from the tty, maybe from a field in a\n                        window.  Note that it's called with all string\n                        structures, not only the prompt ones, so it must\n                        check such things itself.\n        a closer        This function closes the session, maybe by closing\n                        the channel to the tty, or closing the window.\n\n   All these functions are expected to return:\n\n        0       on error.\n        1       on success.\n        -1      on out-of-band events, for example if some prompting has\n                been canceled (by pressing Ctrl-C, for example).  This is\n                only checked when returned by the flusher or the reader.\n\n   The way this is used, the opener is first called, then the writer for all\n   strings, then the flusher, then the reader for all strings and finally the\n   closer.  Note that if you want to prompt from a terminal or other command\n   line interface, the best is to have the reader also write the prompts\n   instead of having the writer do it.  If you want to prompt from a dialog\n   box, the writer can be used to build up the contents of the box, and the\n   flusher to actually display the box and run the event loop until all data\n   has been given, after which the reader only grabs the given data and puts\n   them back into the UI strings.\n\n   All method functions take a UI as argument.  Additionally, the writer and\n   the reader take a UI_STRING.\n*/\n\n/*\n * The UI_STRING type is the data structure that contains all the needed info\n * about a string or a prompt, including test data for a verification prompt.\n */\ntypedef struct ui_string_st UI_STRING;\nDEFINE_STACK_OF(UI_STRING)\n\n/*\n * The different types of strings that are currently supported. This is only\n * needed by method authors.\n */\nenum UI_string_types {\n    UIT_NONE = 0,\n    UIT_PROMPT,                 /* Prompt for a string */\n    UIT_VERIFY,                 /* Prompt for a string and verify */\n    UIT_BOOLEAN,                /* Prompt for a yes/no response */\n    UIT_INFO,                   /* Send info to the user */\n    UIT_ERROR                   /* Send an error message to the user */\n};\n\n/* Create and manipulate methods */\nUI_METHOD *UI_create_method(const char *name);\nvoid UI_destroy_method(UI_METHOD *ui_method);\nint UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui));\nint UI_method_set_writer(UI_METHOD *method,\n                         int (*writer) (UI *ui, UI_STRING *uis));\nint UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui));\nint UI_method_set_reader(UI_METHOD *method,\n                         int (*reader) (UI *ui, UI_STRING *uis));\nint UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui));\nint UI_method_set_data_duplicator(UI_METHOD *method,\n                                  void *(*duplicator) (UI *ui, void *ui_data),\n                                  void (*destructor)(UI *ui, void *ui_data));\nint UI_method_set_prompt_constructor(UI_METHOD *method,\n                                     char *(*prompt_constructor) (UI *ui,\n                                                                  const char\n                                                                  *object_desc,\n                                                                  const char\n                                                                  *object_name));\nint UI_method_set_ex_data(UI_METHOD *method, int idx, void *data);\nint (*UI_method_get_opener(const UI_METHOD *method)) (UI *);\nint (*UI_method_get_writer(const UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_flusher(const UI_METHOD *method)) (UI *);\nint (*UI_method_get_reader(const UI_METHOD *method)) (UI *, UI_STRING *);\nint (*UI_method_get_closer(const UI_METHOD *method)) (UI *);\nchar *(*UI_method_get_prompt_constructor(const UI_METHOD *method))\n    (UI *, const char *, const char *);\nvoid *(*UI_method_get_data_duplicator(const UI_METHOD *method)) (UI *, void *);\nvoid (*UI_method_get_data_destructor(const UI_METHOD *method)) (UI *, void *);\nconst void *UI_method_get_ex_data(const UI_METHOD *method, int idx);\n\n/*\n * The following functions are helpers for method writers to access relevant\n * data from a UI_STRING.\n */\n\n/* Return type of the UI_STRING */\nenum UI_string_types UI_get_string_type(UI_STRING *uis);\n/* Return input flags of the UI_STRING */\nint UI_get_input_flags(UI_STRING *uis);\n/* Return the actual string to output (the prompt, info or error) */\nconst char *UI_get0_output_string(UI_STRING *uis);\n/*\n * Return the optional action string to output (the boolean prompt\n * instruction)\n */\nconst char *UI_get0_action_string(UI_STRING *uis);\n/* Return the result of a prompt */\nconst char *UI_get0_result_string(UI_STRING *uis);\nint UI_get_result_string_length(UI_STRING *uis);\n/*\n * Return the string to test the result against.  Only useful with verifies.\n */\nconst char *UI_get0_test_string(UI_STRING *uis);\n/* Return the required minimum size of the result */\nint UI_get_result_minsize(UI_STRING *uis);\n/* Return the required maximum size of the result */\nint UI_get_result_maxsize(UI_STRING *uis);\n/* Set the result of a UI_STRING. */\nint UI_set_result(UI *ui, UI_STRING *uis, const char *result);\nint UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len);\n\n/* A couple of popular utility functions */\nint UI_UTIL_read_pw_string(char *buf, int length, const char *prompt,\n                           int verify);\nint UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt,\n                    int verify);\nUI_METHOD *UI_UTIL_wrap_read_pem_callback(pem_password_cb *cb, int rwflag);\n\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/uierr.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_UIERR_H\n# define HEADER_UIERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_UI_strings(void);\n\n/*\n * UI function codes.\n */\n# define UI_F_CLOSE_CONSOLE                               115\n# define UI_F_ECHO_CONSOLE                                116\n# define UI_F_GENERAL_ALLOCATE_BOOLEAN                    108\n# define UI_F_GENERAL_ALLOCATE_PROMPT                     109\n# define UI_F_NOECHO_CONSOLE                              117\n# define UI_F_OPEN_CONSOLE                                114\n# define UI_F_UI_CONSTRUCT_PROMPT                         121\n# define UI_F_UI_CREATE_METHOD                            112\n# define UI_F_UI_CTRL                                     111\n# define UI_F_UI_DUP_ERROR_STRING                         101\n# define UI_F_UI_DUP_INFO_STRING                          102\n# define UI_F_UI_DUP_INPUT_BOOLEAN                        110\n# define UI_F_UI_DUP_INPUT_STRING                         103\n# define UI_F_UI_DUP_USER_DATA                            118\n# define UI_F_UI_DUP_VERIFY_STRING                        106\n# define UI_F_UI_GET0_RESULT                              107\n# define UI_F_UI_GET_RESULT_LENGTH                        119\n# define UI_F_UI_NEW_METHOD                               104\n# define UI_F_UI_PROCESS                                  113\n# define UI_F_UI_SET_RESULT                               105\n# define UI_F_UI_SET_RESULT_EX                            120\n\n/*\n * UI reason codes.\n */\n# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS             104\n# define UI_R_INDEX_TOO_LARGE                             102\n# define UI_R_INDEX_TOO_SMALL                             103\n# define UI_R_NO_RESULT_BUFFER                            105\n# define UI_R_PROCESSING_ERROR                            107\n# define UI_R_RESULT_TOO_LARGE                            100\n# define UI_R_RESULT_TOO_SMALL                            101\n# define UI_R_SYSASSIGN_ERROR                             109\n# define UI_R_SYSDASSGN_ERROR                             110\n# define UI_R_SYSQIOW_ERROR                               111\n# define UI_R_UNKNOWN_CONTROL_COMMAND                     106\n# define UI_R_UNKNOWN_TTYGET_ERRNO_VALUE                  108\n# define UI_R_USER_DATA_DUPLICATION_UNSUPPORTED           112\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/whrlpool.h",
    "content": "/*\n * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_WHRLPOOL_H\n# define HEADER_WHRLPOOL_H\n\n#include <openssl/opensslconf.h>\n\n# ifndef OPENSSL_NO_WHIRLPOOL\n# include <openssl/e_os2.h>\n# include <stddef.h>\n# ifdef __cplusplus\nextern \"C\" {\n# endif\n\n# define WHIRLPOOL_DIGEST_LENGTH (512/8)\n# define WHIRLPOOL_BBLOCK        512\n# define WHIRLPOOL_COUNTER       (256/8)\n\ntypedef struct {\n    union {\n        unsigned char c[WHIRLPOOL_DIGEST_LENGTH];\n        /* double q is here to ensure 64-bit alignment */\n        double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)];\n    } H;\n    unsigned char data[WHIRLPOOL_BBLOCK / 8];\n    unsigned int bitoff;\n    size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)];\n} WHIRLPOOL_CTX;\n\nint WHIRLPOOL_Init(WHIRLPOOL_CTX *c);\nint WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes);\nvoid WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits);\nint WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c);\nunsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md);\n\n# ifdef __cplusplus\n}\n# endif\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/x509.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509_H\n# define HEADER_X509_H\n\n# include <openssl/e_os2.h>\n# include <openssl/ossl_typ.h>\n# include <openssl/symhacks.h>\n# include <openssl/buffer.h>\n# include <openssl/evp.h>\n# include <openssl/bio.h>\n# include <openssl/asn1.h>\n# include <openssl/safestack.h>\n# include <openssl/ec.h>\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  include <openssl/rsa.h>\n#  include <openssl/dsa.h>\n#  include <openssl/dh.h>\n# endif\n\n# include <openssl/sha.h>\n# include <openssl/x509err.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n\n/* Flags for X509_get_signature_info() */\n/* Signature info is valid */\n# define X509_SIG_INFO_VALID     0x1\n/* Signature is suitable for TLS use */\n# define X509_SIG_INFO_TLS       0x2\n\n# define X509_FILETYPE_PEM       1\n# define X509_FILETYPE_ASN1      2\n# define X509_FILETYPE_DEFAULT   3\n\n# define X509v3_KU_DIGITAL_SIGNATURE     0x0080\n# define X509v3_KU_NON_REPUDIATION       0x0040\n# define X509v3_KU_KEY_ENCIPHERMENT      0x0020\n# define X509v3_KU_DATA_ENCIPHERMENT     0x0010\n# define X509v3_KU_KEY_AGREEMENT         0x0008\n# define X509v3_KU_KEY_CERT_SIGN         0x0004\n# define X509v3_KU_CRL_SIGN              0x0002\n# define X509v3_KU_ENCIPHER_ONLY         0x0001\n# define X509v3_KU_DECIPHER_ONLY         0x8000\n# define X509v3_KU_UNDEF                 0xffff\n\nstruct X509_algor_st {\n    ASN1_OBJECT *algorithm;\n    ASN1_TYPE *parameter;\n} /* X509_ALGOR */ ;\n\ntypedef STACK_OF(X509_ALGOR) X509_ALGORS;\n\ntypedef struct X509_val_st {\n    ASN1_TIME *notBefore;\n    ASN1_TIME *notAfter;\n} X509_VAL;\n\ntypedef struct X509_sig_st X509_SIG;\n\ntypedef struct X509_name_entry_st X509_NAME_ENTRY;\n\nDEFINE_STACK_OF(X509_NAME_ENTRY)\n\nDEFINE_STACK_OF(X509_NAME)\n\n# define X509_EX_V_NETSCAPE_HACK         0x8000\n# define X509_EX_V_INIT                  0x0001\ntypedef struct X509_extension_st X509_EXTENSION;\n\ntypedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;\n\nDEFINE_STACK_OF(X509_EXTENSION)\n\ntypedef struct x509_attributes_st X509_ATTRIBUTE;\n\nDEFINE_STACK_OF(X509_ATTRIBUTE)\n\ntypedef struct X509_req_info_st X509_REQ_INFO;\n\ntypedef struct X509_req_st X509_REQ;\n\ntypedef struct x509_cert_aux_st X509_CERT_AUX;\n\ntypedef struct x509_cinf_st X509_CINF;\n\nDEFINE_STACK_OF(X509)\n\n/* This is used for a table of trust checking functions */\n\ntypedef struct x509_trust_st {\n    int trust;\n    int flags;\n    int (*check_trust) (struct x509_trust_st *, X509 *, int);\n    char *name;\n    int arg1;\n    void *arg2;\n} X509_TRUST;\n\nDEFINE_STACK_OF(X509_TRUST)\n\n/* standard trust ids */\n\n# define X509_TRUST_DEFAULT      0 /* Only valid in purpose settings */\n\n# define X509_TRUST_COMPAT       1\n# define X509_TRUST_SSL_CLIENT   2\n# define X509_TRUST_SSL_SERVER   3\n# define X509_TRUST_EMAIL        4\n# define X509_TRUST_OBJECT_SIGN  5\n# define X509_TRUST_OCSP_SIGN    6\n# define X509_TRUST_OCSP_REQUEST 7\n# define X509_TRUST_TSA          8\n\n/* Keep these up to date! */\n# define X509_TRUST_MIN          1\n# define X509_TRUST_MAX          8\n\n/* trust_flags values */\n# define X509_TRUST_DYNAMIC      (1U << 0)\n# define X509_TRUST_DYNAMIC_NAME (1U << 1)\n/* No compat trust if self-signed, preempts \"DO_SS\" */\n# define X509_TRUST_NO_SS_COMPAT (1U << 2)\n/* Compat trust if no explicit accepted trust EKUs */\n# define X509_TRUST_DO_SS_COMPAT (1U << 3)\n/* Accept \"anyEKU\" as a wildcard trust OID */\n# define X509_TRUST_OK_ANY_EKU   (1U << 4)\n\n/* check_trust return codes */\n\n# define X509_TRUST_TRUSTED      1\n# define X509_TRUST_REJECTED     2\n# define X509_TRUST_UNTRUSTED    3\n\n/* Flags for X509_print_ex() */\n\n# define X509_FLAG_COMPAT                0\n# define X509_FLAG_NO_HEADER             1L\n# define X509_FLAG_NO_VERSION            (1L << 1)\n# define X509_FLAG_NO_SERIAL             (1L << 2)\n# define X509_FLAG_NO_SIGNAME            (1L << 3)\n# define X509_FLAG_NO_ISSUER             (1L << 4)\n# define X509_FLAG_NO_VALIDITY           (1L << 5)\n# define X509_FLAG_NO_SUBJECT            (1L << 6)\n# define X509_FLAG_NO_PUBKEY             (1L << 7)\n# define X509_FLAG_NO_EXTENSIONS         (1L << 8)\n# define X509_FLAG_NO_SIGDUMP            (1L << 9)\n# define X509_FLAG_NO_AUX                (1L << 10)\n# define X509_FLAG_NO_ATTRIBUTES         (1L << 11)\n# define X509_FLAG_NO_IDS                (1L << 12)\n\n/* Flags specific to X509_NAME_print_ex() */\n\n/* The field separator information */\n\n# define XN_FLAG_SEP_MASK        (0xf << 16)\n\n# define XN_FLAG_COMPAT          0/* Traditional; use old X509_NAME_print */\n# define XN_FLAG_SEP_COMMA_PLUS  (1 << 16)/* RFC2253 ,+ */\n# define XN_FLAG_SEP_CPLUS_SPC   (2 << 16)/* ,+ spaced: more readable */\n# define XN_FLAG_SEP_SPLUS_SPC   (3 << 16)/* ;+ spaced */\n# define XN_FLAG_SEP_MULTILINE   (4 << 16)/* One line per field */\n\n# define XN_FLAG_DN_REV          (1 << 20)/* Reverse DN order */\n\n/* How the field name is shown */\n\n# define XN_FLAG_FN_MASK         (0x3 << 21)\n\n# define XN_FLAG_FN_SN           0/* Object short name */\n# define XN_FLAG_FN_LN           (1 << 21)/* Object long name */\n# define XN_FLAG_FN_OID          (2 << 21)/* Always use OIDs */\n# define XN_FLAG_FN_NONE         (3 << 21)/* No field names */\n\n# define XN_FLAG_SPC_EQ          (1 << 23)/* Put spaces round '=' */\n\n/*\n * This determines if we dump fields we don't recognise: RFC2253 requires\n * this.\n */\n\n# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)\n\n# define XN_FLAG_FN_ALIGN        (1 << 25)/* Align field names to 20\n                                           * characters */\n\n/* Complete set of RFC2253 flags */\n\n# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \\\n                        XN_FLAG_SEP_COMMA_PLUS | \\\n                        XN_FLAG_DN_REV | \\\n                        XN_FLAG_FN_SN | \\\n                        XN_FLAG_DUMP_UNKNOWN_FIELDS)\n\n/* readable oneline form */\n\n# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \\\n                        ASN1_STRFLGS_ESC_QUOTE | \\\n                        XN_FLAG_SEP_CPLUS_SPC | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_SN)\n\n/* readable multiline form */\n\n# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \\\n                        ASN1_STRFLGS_ESC_MSB | \\\n                        XN_FLAG_SEP_MULTILINE | \\\n                        XN_FLAG_SPC_EQ | \\\n                        XN_FLAG_FN_LN | \\\n                        XN_FLAG_FN_ALIGN)\n\nDEFINE_STACK_OF(X509_REVOKED)\n\ntypedef struct X509_crl_info_st X509_CRL_INFO;\n\nDEFINE_STACK_OF(X509_CRL)\n\ntypedef struct private_key_st {\n    int version;\n    /* The PKCS#8 data types */\n    X509_ALGOR *enc_algor;\n    ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */\n    /* When decrypted, the following will not be NULL */\n    EVP_PKEY *dec_pkey;\n    /* used to encrypt and decrypt */\n    int key_length;\n    char *key_data;\n    int key_free;               /* true if we should auto free key_data */\n    /* expanded version of 'enc_algor' */\n    EVP_CIPHER_INFO cipher;\n} X509_PKEY;\n\ntypedef struct X509_info_st {\n    X509 *x509;\n    X509_CRL *crl;\n    X509_PKEY *x_pkey;\n    EVP_CIPHER_INFO enc_cipher;\n    int enc_len;\n    char *enc_data;\n} X509_INFO;\n\nDEFINE_STACK_OF(X509_INFO)\n\n/*\n * The next 2 structures and their 8 routines are used to manipulate Netscape's\n * spki structures - useful if you are writing a CA web page\n */\ntypedef struct Netscape_spkac_st {\n    X509_PUBKEY *pubkey;\n    ASN1_IA5STRING *challenge;  /* challenge sent in atlas >= PR2 */\n} NETSCAPE_SPKAC;\n\ntypedef struct Netscape_spki_st {\n    NETSCAPE_SPKAC *spkac;      /* signed public key and challenge */\n    X509_ALGOR sig_algor;\n    ASN1_BIT_STRING *signature;\n} NETSCAPE_SPKI;\n\n/* Netscape certificate sequence structure */\ntypedef struct Netscape_certificate_sequence {\n    ASN1_OBJECT *type;\n    STACK_OF(X509) *certs;\n} NETSCAPE_CERT_SEQUENCE;\n\n/*- Unused (and iv length is wrong)\ntypedef struct CBCParameter_st\n        {\n        unsigned char iv[8];\n        } CBC_PARAM;\n*/\n\n/* Password based encryption structure */\n\ntypedef struct PBEPARAM_st {\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *iter;\n} PBEPARAM;\n\n/* Password based encryption V2 structures */\n\ntypedef struct PBE2PARAM_st {\n    X509_ALGOR *keyfunc;\n    X509_ALGOR *encryption;\n} PBE2PARAM;\n\ntypedef struct PBKDF2PARAM_st {\n/* Usually OCTET STRING but could be anything */\n    ASN1_TYPE *salt;\n    ASN1_INTEGER *iter;\n    ASN1_INTEGER *keylength;\n    X509_ALGOR *prf;\n} PBKDF2PARAM;\n\n#ifndef OPENSSL_NO_SCRYPT\ntypedef struct SCRYPT_PARAMS_st {\n    ASN1_OCTET_STRING *salt;\n    ASN1_INTEGER *costParameter;\n    ASN1_INTEGER *blockSize;\n    ASN1_INTEGER *parallelizationParameter;\n    ASN1_INTEGER *keyLength;\n} SCRYPT_PARAMS;\n#endif\n\n#ifdef  __cplusplus\n}\n#endif\n\n# include <openssl/x509_vfy.h>\n# include <openssl/pkcs7.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n# define X509_EXT_PACK_UNKNOWN   1\n# define X509_EXT_PACK_STRING    2\n\n# define         X509_extract_key(x)     X509_get_pubkey(x)/*****/\n# define         X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)\n# define         X509_name_cmp(a,b)      X509_NAME_cmp((a),(b))\n\nvoid X509_CRL_set_default_method(const X509_CRL_METHOD *meth);\nX509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),\n                                     int (*crl_free) (X509_CRL *crl),\n                                     int (*crl_lookup) (X509_CRL *crl,\n                                                        X509_REVOKED **ret,\n                                                        ASN1_INTEGER *ser,\n                                                        X509_NAME *issuer),\n                                     int (*crl_verify) (X509_CRL *crl,\n                                                        EVP_PKEY *pk));\nvoid X509_CRL_METHOD_free(X509_CRL_METHOD *m);\n\nvoid X509_CRL_set_meth_data(X509_CRL *crl, void *dat);\nvoid *X509_CRL_get_meth_data(X509_CRL *crl);\n\nconst char *X509_verify_cert_error_string(long n);\n\nint X509_verify(X509 *a, EVP_PKEY *r);\n\nint X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);\nint X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);\nint NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);\n\nNETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);\nchar *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);\nEVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);\nint NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);\n\nint NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);\n\nint X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);\nint X509_signature_print(BIO *bp, const X509_ALGOR *alg,\n                         const ASN1_STRING *sig);\n\nint X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);\n# ifndef OPENSSL_NO_OCSP\nint X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert);\n# endif\nint X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);\nint X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);\nint X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);\n# ifndef OPENSSL_NO_OCSP\nint X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl);\n# endif\nint NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);\n\nint X509_pubkey_digest(const X509 *data, const EVP_MD *type,\n                       unsigned char *md, unsigned int *len);\nint X509_digest(const X509 *data, const EVP_MD *type,\n                unsigned char *md, unsigned int *len);\nint X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,\n                    unsigned char *md, unsigned int *len);\nint X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,\n                     unsigned char *md, unsigned int *len);\n\n# ifndef OPENSSL_NO_STDIO\nX509 *d2i_X509_fp(FILE *fp, X509 **x509);\nint i2d_X509_fp(FILE *fp, X509 *x509);\nX509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);\nint i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);\nint i2d_X509_REQ_fp(FILE *fp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);\nint i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);\nint i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);\nint i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);\nint i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);\nint i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);\nint i2d_PKCS8_fp(FILE *fp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,\n                                                PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);\nint i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);\nint i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);\n# endif\n\nX509 *d2i_X509_bio(BIO *bp, X509 **x509);\nint i2d_X509_bio(BIO *bp, X509 *x509);\nX509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);\nint i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl);\nX509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);\nint i2d_X509_REQ_bio(BIO *bp, X509_REQ *req);\n#  ifndef OPENSSL_NO_RSA\nRSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);\nint i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa);\nRSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);\nint i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa);\n#  endif\n#  ifndef OPENSSL_NO_DSA\nDSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);\nint i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);\nDSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);\nint i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);\n#  endif\n#  ifndef OPENSSL_NO_EC\nEC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);\nint i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);\nEC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);\nint i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);\n#  endif\nX509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);\nint i2d_PKCS8_bio(BIO *bp, X509_SIG *p8);\nPKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,\n                                                 PKCS8_PRIV_KEY_INFO **p8inf);\nint i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf);\nint i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);\nint i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);\nint i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);\nEVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);\n\nX509 *X509_dup(X509 *x509);\nX509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);\nX509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);\nX509_CRL *X509_CRL_dup(X509_CRL *crl);\nX509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev);\nX509_REQ *X509_REQ_dup(X509_REQ *req);\nX509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);\nint X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,\n                    void *pval);\nvoid X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype,\n                     const void **ppval, const X509_ALGOR *algor);\nvoid X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);\nint X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);\nint X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src);\n\nX509_NAME *X509_NAME_dup(X509_NAME *xn);\nX509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);\n\nint X509_cmp_time(const ASN1_TIME *s, time_t *t);\nint X509_cmp_current_time(const ASN1_TIME *s);\nASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);\nASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,\n                            int offset_day, long offset_sec, time_t *t);\nASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);\n\nconst char *X509_get_default_cert_area(void);\nconst char *X509_get_default_cert_dir(void);\nconst char *X509_get_default_cert_file(void);\nconst char *X509_get_default_cert_dir_env(void);\nconst char *X509_get_default_cert_file_env(void);\nconst char *X509_get_default_private_dir(void);\n\nX509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);\nX509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);\n\nDECLARE_ASN1_FUNCTIONS(X509_ALGOR)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)\nDECLARE_ASN1_FUNCTIONS(X509_VAL)\n\nDECLARE_ASN1_FUNCTIONS(X509_PUBKEY)\n\nint X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);\nEVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key);\nEVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key);\nint X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);\nlong X509_get_pathlen(X509 *x);\nint i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp);\nEVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length);\n# ifndef OPENSSL_NO_RSA\nint i2d_RSA_PUBKEY(RSA *a, unsigned char **pp);\nRSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_DSA\nint i2d_DSA_PUBKEY(DSA *a, unsigned char **pp);\nDSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length);\n# endif\n# ifndef OPENSSL_NO_EC\nint i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);\nEC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length);\n# endif\n\nDECLARE_ASN1_FUNCTIONS(X509_SIG)\nvoid X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg,\n                   const ASN1_OCTET_STRING **pdigest);\nvoid X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg,\n                   ASN1_OCTET_STRING **pdigest);\n\nDECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_REQ)\n\nDECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)\nX509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);\n\nDECLARE_ASN1_FUNCTIONS(X509_EXTENSION)\nDECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)\n\nDECLARE_ASN1_FUNCTIONS(X509_NAME)\n\nint X509_NAME_set(X509_NAME **xn, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(X509_CINF)\n\nDECLARE_ASN1_FUNCTIONS(X509)\nDECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)\n\n#define X509_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef)\nint X509_set_ex_data(X509 *r, int idx, void *arg);\nvoid *X509_get_ex_data(X509 *r, int idx);\nint i2d_X509_AUX(X509 *a, unsigned char **pp);\nX509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length);\n\nint i2d_re_X509_tbs(X509 *x, unsigned char **pp);\n\nint X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid,\n                      int *secbits, uint32_t *flags);\nvoid X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid,\n                       int secbits, uint32_t flags);\n\nint X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits,\n                            uint32_t *flags);\n\nvoid X509_get0_signature(const ASN1_BIT_STRING **psig,\n                         const X509_ALGOR **palg, const X509 *x);\nint X509_get_signature_nid(const X509 *x);\n\nint X509_trusted(const X509 *x);\nint X509_alias_set1(X509 *x, const unsigned char *name, int len);\nint X509_keyid_set1(X509 *x, const unsigned char *id, int len);\nunsigned char *X509_alias_get0(X509 *x, int *len);\nunsigned char *X509_keyid_get0(X509 *x, int *len);\nint (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,\n                                                                int);\nint X509_TRUST_set(int *t, int trust);\nint X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj);\nint X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj);\nvoid X509_trust_clear(X509 *x);\nvoid X509_reject_clear(X509 *x);\n\nSTACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x);\nSTACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x);\n\nDECLARE_ASN1_FUNCTIONS(X509_REVOKED)\nDECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)\nDECLARE_ASN1_FUNCTIONS(X509_CRL)\n\nint X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);\nint X509_CRL_get0_by_serial(X509_CRL *crl,\n                            X509_REVOKED **ret, ASN1_INTEGER *serial);\nint X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);\n\nX509_PKEY *X509_PKEY_new(void);\nvoid X509_PKEY_free(X509_PKEY *a);\n\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)\nDECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)\n\nX509_INFO *X509_INFO_new(void);\nvoid X509_INFO_free(X509_INFO *a);\nchar *X509_NAME_oneline(const X509_NAME *a, char *buf, int size);\n\nint ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,\n                ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);\n\nint ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,\n                unsigned char *md, unsigned int *len);\n\nint ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,\n              X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n              char *data, EVP_PKEY *pkey, const EVP_MD *type);\n\nint ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,\n                     unsigned char *md, unsigned int *len);\n\nint ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                     ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey);\n\nint ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                   X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data,\n                   EVP_PKEY *pkey, const EVP_MD *type);\nint ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,\n                       X509_ALGOR *algor2, ASN1_BIT_STRING *signature,\n                       void *asn, EVP_MD_CTX *ctx);\n\nlong X509_get_version(const X509 *x);\nint X509_set_version(X509 *x, long version);\nint X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);\nASN1_INTEGER *X509_get_serialNumber(X509 *x);\nconst ASN1_INTEGER *X509_get0_serialNumber(const X509 *x);\nint X509_set_issuer_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_issuer_name(const X509 *a);\nint X509_set_subject_name(X509 *x, X509_NAME *name);\nX509_NAME *X509_get_subject_name(const X509 *a);\nconst ASN1_TIME * X509_get0_notBefore(const X509 *x);\nASN1_TIME *X509_getm_notBefore(const X509 *x);\nint X509_set1_notBefore(X509 *x, const ASN1_TIME *tm);\nconst ASN1_TIME *X509_get0_notAfter(const X509 *x);\nASN1_TIME *X509_getm_notAfter(const X509 *x);\nint X509_set1_notAfter(X509 *x, const ASN1_TIME *tm);\nint X509_set_pubkey(X509 *x, EVP_PKEY *pkey);\nint X509_up_ref(X509 *x);\nint X509_get_signature_type(const X509 *x);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define X509_get_notBefore X509_getm_notBefore\n#  define X509_get_notAfter X509_getm_notAfter\n#  define X509_set_notBefore X509_set1_notBefore\n#  define X509_set_notAfter X509_set1_notAfter\n#endif\n\n\n/*\n * This one is only used so that a binary form can output, as in\n * i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &buf)\n */\nX509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x);\nconst STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x);\nvoid X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid,\n                    const ASN1_BIT_STRING **psuid);\nconst X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);\n\nEVP_PKEY *X509_get0_pubkey(const X509 *x);\nEVP_PKEY *X509_get_pubkey(X509 *x);\nASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);\nint X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey);\n\nlong X509_REQ_get_version(const X509_REQ *req);\nint X509_REQ_set_version(X509_REQ *x, long version);\nX509_NAME *X509_REQ_get_subject_name(const X509_REQ *req);\nint X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);\nvoid X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig,\n                             const X509_ALGOR **palg);\nvoid X509_REQ_set0_signature(X509_REQ *req, ASN1_BIT_STRING *psig);\nint X509_REQ_set1_signature_algo(X509_REQ *req, X509_ALGOR *palg);\nint X509_REQ_get_signature_nid(const X509_REQ *req);\nint i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);\nint X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);\nEVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);\nEVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *req);\nX509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req);\nint X509_REQ_extension_nid(int nid);\nint *X509_REQ_get_extension_nids(void);\nvoid X509_REQ_set_extension_nids(int *nids);\nSTACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);\nint X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,\n                                int nid);\nint X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);\nint X509_REQ_get_attr_count(const X509_REQ *req);\nint X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);\nint X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);\nX509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);\nint X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);\nint X509_REQ_add1_attr_by_OBJ(X509_REQ *req,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_NID(X509_REQ *req,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint X509_REQ_add1_attr_by_txt(X509_REQ *req,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_CRL_set_version(X509_CRL *x, long version);\nint X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);\nint X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);\nint X509_CRL_sort(X509_CRL *crl);\nint X509_CRL_up_ref(X509_CRL *crl);\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate\n#  define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate\n#endif\n\nlong X509_CRL_get_version(const X509_CRL *crl);\nconst ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl);\nconst ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl);\nDEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl))\nDEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl))\nX509_NAME *X509_CRL_get_issuer(const X509_CRL *crl);\nconst STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl);\nSTACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);\nvoid X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,\n                             const X509_ALGOR **palg);\nint X509_CRL_get_signature_nid(const X509_CRL *crl);\nint i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp);\n\nconst ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x);\nint X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);\nconst ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x);\nint X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);\nconst STACK_OF(X509_EXTENSION) *\nX509_REVOKED_get0_extensions(const X509_REVOKED *r);\n\nX509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,\n                        EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);\n\nint X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey);\n\nint X509_check_private_key(const X509 *x509, const EVP_PKEY *pkey);\nint X509_chain_check_suiteb(int *perror_depth,\n                            X509 *x, STACK_OF(X509) *chain,\n                            unsigned long flags);\nint X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);\nSTACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);\n\nint X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_and_serial_hash(X509 *a);\n\nint X509_issuer_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_issuer_name_hash(X509 *a);\n\nint X509_subject_name_cmp(const X509 *a, const X509 *b);\nunsigned long X509_subject_name_hash(X509 *x);\n\n# ifndef OPENSSL_NO_MD5\nunsigned long X509_issuer_name_hash_old(X509 *a);\nunsigned long X509_subject_name_hash_old(X509 *x);\n# endif\n\nint X509_cmp(const X509 *a, const X509 *b);\nint X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);\nunsigned long X509_NAME_hash(X509_NAME *x);\nunsigned long X509_NAME_hash_old(X509_NAME *x);\n\nint X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);\nint X509_CRL_match(const X509_CRL *a, const X509_CRL *b);\nint X509_aux_print(BIO *out, X509 *x, int indent);\n# ifndef OPENSSL_NO_STDIO\nint X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,\n                     unsigned long cflag);\nint X509_print_fp(FILE *bp, X509 *x);\nint X509_CRL_print_fp(FILE *bp, X509_CRL *x);\nint X509_REQ_print_fp(FILE *bp, X509_REQ *req);\nint X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent,\n                          unsigned long flags);\n# endif\n\nint X509_NAME_print(BIO *bp, const X509_NAME *name, int obase);\nint X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent,\n                       unsigned long flags);\nint X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,\n                  unsigned long cflag);\nint X509_print(BIO *bp, X509 *x);\nint X509_ocspid_print(BIO *bp, X509 *x);\nint X509_CRL_print_ex(BIO *out, X509_CRL *x, unsigned long nmflag);\nint X509_CRL_print(BIO *bp, X509_CRL *x);\nint X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,\n                      unsigned long cflag);\nint X509_REQ_print(BIO *bp, X509_REQ *req);\n\nint X509_NAME_entry_count(const X509_NAME *name);\nint X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);\nint X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj,\n                              char *buf, int len);\n\n/*\n * NOTE: you should be passing -1, not 0 as lastpos. The functions that use\n * lastpos, search after that position on.\n */\nint X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos);\nint X509_NAME_get_index_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj,\n                               int lastpos);\nX509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc);\nX509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);\nint X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne,\n                        int loc, int set);\nint X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nint X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,\n                                               const char *field, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,\n                                               int type,\n                                               const unsigned char *bytes,\n                                               int len);\nint X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,\n                               const unsigned char *bytes, int len, int loc,\n                               int set);\nX509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,\n                                               const ASN1_OBJECT *obj, int type,\n                                               const unsigned char *bytes,\n                                               int len);\nint X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj);\nint X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,\n                             const unsigned char *bytes, int len);\nASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne);\nASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne);\nint X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne);\n\nint X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder,\n                       size_t *pderlen);\n\nint X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);\nint X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,\n                          int nid, int lastpos);\nint X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,\n                          const ASN1_OBJECT *obj, int lastpos);\nint X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,\n                               int crit, int lastpos);\nX509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);\nX509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);\nSTACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,\n                                         X509_EXTENSION *ex, int loc);\n\nint X509_get_ext_count(const X509 *x);\nint X509_get_ext_by_NID(const X509 *x, int nid, int lastpos);\nint X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos);\nint X509_get_ext_by_critical(const X509 *x, int crit, int lastpos);\nX509_EXTENSION *X509_get_ext(const X509 *x, int loc);\nX509_EXTENSION *X509_delete_ext(X509 *x, int loc);\nint X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);\nvoid *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx);\nint X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,\n                      unsigned long flags);\n\nint X509_CRL_get_ext_count(const X509_CRL *x);\nint X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos);\nint X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj,\n                            int lastpos);\nint X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos);\nX509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc);\nX509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);\nint X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);\nvoid *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx);\nint X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,\n                          unsigned long flags);\n\nint X509_REVOKED_get_ext_count(const X509_REVOKED *x);\nint X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos);\nint X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj,\n                                int lastpos);\nint X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit,\n                                     int lastpos);\nX509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc);\nX509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);\nint X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);\nvoid *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit,\n                               int *idx);\nint X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,\n                              unsigned long flags);\n\nX509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,\n                                             int nid, int crit,\n                                             ASN1_OCTET_STRING *data);\nX509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,\n                                             const ASN1_OBJECT *obj, int crit,\n                                             ASN1_OCTET_STRING *data);\nint X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj);\nint X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);\nint X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);\nASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);\nASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);\nint X509_EXTENSION_get_critical(const X509_EXTENSION *ex);\n\nint X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);\nint X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,\n                           int lastpos);\nint X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,\n                           const ASN1_OBJECT *obj, int lastpos);\nX509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);\nX509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,\n                                           X509_ATTRIBUTE *attr);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const ASN1_OBJECT *obj,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, int nid, int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nSTACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)\n                                                  **x, const char *attrname,\n                                                  int type,\n                                                  const unsigned char *bytes,\n                                                  int len);\nvoid *X509at_get0_data_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *x,\n                              const ASN1_OBJECT *obj, int lastpos, int type);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,\n                                             const ASN1_OBJECT *obj,\n                                             int atrtype, const void *data,\n                                             int len);\nX509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,\n                                             const char *atrname, int type,\n                                             const unsigned char *bytes,\n                                             int len);\nint X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);\nint X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,\n                             const void *data, int len);\nvoid *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,\n                               void *data);\nint X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr);\nASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);\nASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);\n\nint EVP_PKEY_get_attr_count(const EVP_PKEY *key);\nint EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);\nint EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj,\n                             int lastpos);\nX509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);\nX509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);\nint EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);\nint EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,\n                              const ASN1_OBJECT *obj, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,\n                              int nid, int type,\n                              const unsigned char *bytes, int len);\nint EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,\n                              const char *attrname, int type,\n                              const unsigned char *bytes, int len);\n\nint X509_verify_cert(X509_STORE_CTX *ctx);\n\n/* lookup a cert from a X509 STACK */\nX509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,\n                                     ASN1_INTEGER *serial);\nX509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name);\n\nDECLARE_ASN1_FUNCTIONS(PBEPARAM)\nDECLARE_ASN1_FUNCTIONS(PBE2PARAM)\nDECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)\n#ifndef OPENSSL_NO_SCRYPT\nDECLARE_ASN1_FUNCTIONS(SCRYPT_PARAMS)\n#endif\n\nint PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,\n                         const unsigned char *salt, int saltlen);\n\nX509_ALGOR *PKCS5_pbe_set(int alg, int iter,\n                          const unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,\n                           unsigned char *salt, int saltlen);\nX509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,\n                              unsigned char *salt, int saltlen,\n                              unsigned char *aiv, int prf_nid);\n\n#ifndef OPENSSL_NO_SCRYPT\nX509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher,\n                                  const unsigned char *salt, int saltlen,\n                                  unsigned char *aiv, uint64_t N, uint64_t r,\n                                  uint64_t p);\n#endif\n\nX509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,\n                             int prf_nid, int keylen);\n\n/* PKCS#8 utilities */\n\nDECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)\n\nEVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8);\nPKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);\n\nint PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,\n                    int version, int ptype, void *pval,\n                    unsigned char *penc, int penclen);\nint PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg,\n                    const unsigned char **pk, int *ppklen,\n                    const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8);\n\nconst STACK_OF(X509_ATTRIBUTE) *\nPKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8);\nint PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type,\n                                const unsigned char *bytes, int len);\n\nint X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,\n                           int ptype, void *pval,\n                           unsigned char *penc, int penclen);\nint X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,\n                           const unsigned char **pk, int *ppklen,\n                           X509_ALGOR **pa, X509_PUBKEY *pub);\n\nint X509_check_trust(X509 *x, int id, int flags);\nint X509_TRUST_get_count(void);\nX509_TRUST *X509_TRUST_get0(int idx);\nint X509_TRUST_get_by_id(int id);\nint X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),\n                   const char *name, int arg1, void *arg2);\nvoid X509_TRUST_cleanup(void);\nint X509_TRUST_get_flags(const X509_TRUST *xp);\nchar *X509_TRUST_get0_name(const X509_TRUST *xp);\nint X509_TRUST_get_trust(const X509_TRUST *xp);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/x509_vfy.h",
    "content": "/*\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509_VFY_H\n# define HEADER_X509_VFY_H\n\n/*\n * Protect against recursion, x509.h and x509_vfy.h each include the other.\n */\n# ifndef HEADER_X509_H\n#  include <openssl/x509.h>\n# endif\n\n# include <openssl/opensslconf.h>\n# include <openssl/lhash.h>\n# include <openssl/bio.h>\n# include <openssl/crypto.h>\n# include <openssl/symhacks.h>\n\n#ifdef  __cplusplus\nextern \"C\" {\n#endif\n\n/*-\nSSL_CTX -> X509_STORE\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n                -> X509_LOOKUP\n                        ->X509_LOOKUP_METHOD\n\nSSL     -> X509_STORE_CTX\n                ->X509_STORE\n\nThe X509_STORE holds the tables etc for verification stuff.\nA X509_STORE_CTX is used while validating a single certificate.\nThe X509_STORE has X509_LOOKUPs for looking up certs.\nThe X509_STORE then calls a function to actually verify the\ncertificate chain.\n*/\n\ntypedef enum {\n    X509_LU_NONE = 0,\n    X509_LU_X509, X509_LU_CRL\n} X509_LOOKUP_TYPE;\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n#define X509_LU_RETRY   -1\n#define X509_LU_FAIL    0\n#endif\n\nDEFINE_STACK_OF(X509_LOOKUP)\nDEFINE_STACK_OF(X509_OBJECT)\nDEFINE_STACK_OF(X509_VERIFY_PARAM)\n\nint X509_STORE_set_depth(X509_STORE *store, int depth);\n\ntypedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *);\ntypedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *);\ntypedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer,\n                                            X509_STORE_CTX *ctx, X509 *x);\ntypedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx,\n                                              X509 *x, X509 *issuer);\ntypedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx);\ntypedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx,\n                                         X509_CRL **crl, X509 *x);\ntypedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl);\ntypedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx,\n                                          X509_CRL *crl, X509 *x);\ntypedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx);\ntypedef STACK_OF(X509) *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx,\n                                                          X509_NAME *nm);\ntypedef STACK_OF(X509_CRL) *(*X509_STORE_CTX_lookup_crls_fn)(X509_STORE_CTX *ctx,\n                                                             X509_NAME *nm);\ntypedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx);\n\n\nvoid X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth);\n\n# define X509_STORE_CTX_set_app_data(ctx,data) \\\n        X509_STORE_CTX_set_ex_data(ctx,0,data)\n# define X509_STORE_CTX_get_app_data(ctx) \\\n        X509_STORE_CTX_get_ex_data(ctx,0)\n\n# define X509_L_FILE_LOAD        1\n# define X509_L_ADD_DIR          2\n\n# define X509_LOOKUP_load_file(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL)\n\n# define X509_LOOKUP_add_dir(x,name,type) \\\n                X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL)\n\n# define         X509_V_OK                                       0\n# define         X509_V_ERR_UNSPECIFIED                          1\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT            2\n# define         X509_V_ERR_UNABLE_TO_GET_CRL                    3\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE     4\n# define         X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE      5\n# define         X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY   6\n# define         X509_V_ERR_CERT_SIGNATURE_FAILURE               7\n# define         X509_V_ERR_CRL_SIGNATURE_FAILURE                8\n# define         X509_V_ERR_CERT_NOT_YET_VALID                   9\n# define         X509_V_ERR_CERT_HAS_EXPIRED                     10\n# define         X509_V_ERR_CRL_NOT_YET_VALID                    11\n# define         X509_V_ERR_CRL_HAS_EXPIRED                      12\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD       13\n# define         X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD        14\n# define         X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD       15\n# define         X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD       16\n# define         X509_V_ERR_OUT_OF_MEM                           17\n# define         X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT          18\n# define         X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN            19\n# define         X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY    20\n# define         X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE      21\n# define         X509_V_ERR_CERT_CHAIN_TOO_LONG                  22\n# define         X509_V_ERR_CERT_REVOKED                         23\n# define         X509_V_ERR_INVALID_CA                           24\n# define         X509_V_ERR_PATH_LENGTH_EXCEEDED                 25\n# define         X509_V_ERR_INVALID_PURPOSE                      26\n# define         X509_V_ERR_CERT_UNTRUSTED                       27\n# define         X509_V_ERR_CERT_REJECTED                        28\n/* These are 'informational' when looking for issuer cert */\n# define         X509_V_ERR_SUBJECT_ISSUER_MISMATCH              29\n# define         X509_V_ERR_AKID_SKID_MISMATCH                   30\n# define         X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH          31\n# define         X509_V_ERR_KEYUSAGE_NO_CERTSIGN                 32\n# define         X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER             33\n# define         X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION         34\n# define         X509_V_ERR_KEYUSAGE_NO_CRL_SIGN                 35\n# define         X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION     36\n# define         X509_V_ERR_INVALID_NON_CA                       37\n# define         X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED           38\n# define         X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE        39\n# define         X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED       40\n# define         X509_V_ERR_INVALID_EXTENSION                    41\n# define         X509_V_ERR_INVALID_POLICY_EXTENSION             42\n# define         X509_V_ERR_NO_EXPLICIT_POLICY                   43\n# define         X509_V_ERR_DIFFERENT_CRL_SCOPE                  44\n# define         X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE        45\n# define         X509_V_ERR_UNNESTED_RESOURCE                    46\n# define         X509_V_ERR_PERMITTED_VIOLATION                  47\n# define         X509_V_ERR_EXCLUDED_VIOLATION                   48\n# define         X509_V_ERR_SUBTREE_MINMAX                       49\n/* The application is not happy */\n# define         X509_V_ERR_APPLICATION_VERIFICATION             50\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE          51\n# define         X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX        52\n# define         X509_V_ERR_UNSUPPORTED_NAME_SYNTAX              53\n# define         X509_V_ERR_CRL_PATH_VALIDATION_ERROR            54\n/* Another issuer check debug option */\n# define         X509_V_ERR_PATH_LOOP                            55\n/* Suite B mode algorithm violation */\n# define         X509_V_ERR_SUITE_B_INVALID_VERSION              56\n# define         X509_V_ERR_SUITE_B_INVALID_ALGORITHM            57\n# define         X509_V_ERR_SUITE_B_INVALID_CURVE                58\n# define         X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM  59\n# define         X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED              60\n# define         X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61\n/* Host, email and IP check errors */\n# define         X509_V_ERR_HOSTNAME_MISMATCH                    62\n# define         X509_V_ERR_EMAIL_MISMATCH                       63\n# define         X509_V_ERR_IP_ADDRESS_MISMATCH                  64\n/* DANE TLSA errors */\n# define         X509_V_ERR_DANE_NO_MATCH                        65\n/* security level errors */\n# define         X509_V_ERR_EE_KEY_TOO_SMALL                     66\n# define         X509_V_ERR_CA_KEY_TOO_SMALL                     67\n# define         X509_V_ERR_CA_MD_TOO_WEAK                       68\n/* Caller error */\n# define         X509_V_ERR_INVALID_CALL                         69\n/* Issuer lookup error */\n# define         X509_V_ERR_STORE_LOOKUP                         70\n/* Certificate transparency */\n# define         X509_V_ERR_NO_VALID_SCTS                        71\n\n# define         X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION         72\n/* OCSP status errors */\n# define         X509_V_ERR_OCSP_VERIFY_NEEDED                   73  /* Need OCSP verification */\n# define         X509_V_ERR_OCSP_VERIFY_FAILED                   74  /* Couldn't verify cert through OCSP */\n# define         X509_V_ERR_OCSP_CERT_UNKNOWN                    75  /* Certificate wasn't recognized by the OCSP responder */\n# define         X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCH         76\n# define         X509_V_ERR_NO_ISSUER_PUBLIC_KEY                 77\n# define         X509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHM      78\n# define         X509_V_ERR_EC_KEY_EXPLICIT_PARAMS               79\n\n/* Certificate verify flags */\n\n# if OPENSSL_API_COMPAT < 0x10100000L\n#  define X509_V_FLAG_CB_ISSUER_CHECK             0x0   /* Deprecated */\n# endif\n/* Use check time instead of current time */\n# define X509_V_FLAG_USE_CHECK_TIME              0x2\n/* Lookup CRLs */\n# define X509_V_FLAG_CRL_CHECK                   0x4\n/* Lookup CRLs for whole chain */\n# define X509_V_FLAG_CRL_CHECK_ALL               0x8\n/* Ignore unhandled critical extensions */\n# define X509_V_FLAG_IGNORE_CRITICAL             0x10\n/* Disable workarounds for broken certificates */\n# define X509_V_FLAG_X509_STRICT                 0x20\n/* Enable proxy certificate validation */\n# define X509_V_FLAG_ALLOW_PROXY_CERTS           0x40\n/* Enable policy checking */\n# define X509_V_FLAG_POLICY_CHECK                0x80\n/* Policy variable require-explicit-policy */\n# define X509_V_FLAG_EXPLICIT_POLICY             0x100\n/* Policy variable inhibit-any-policy */\n# define X509_V_FLAG_INHIBIT_ANY                 0x200\n/* Policy variable inhibit-policy-mapping */\n# define X509_V_FLAG_INHIBIT_MAP                 0x400\n/* Notify callback that policy is OK */\n# define X509_V_FLAG_NOTIFY_POLICY               0x800\n/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */\n# define X509_V_FLAG_EXTENDED_CRL_SUPPORT        0x1000\n/* Delta CRL support */\n# define X509_V_FLAG_USE_DELTAS                  0x2000\n/* Check self-signed CA signature */\n# define X509_V_FLAG_CHECK_SS_SIGNATURE          0x4000\n/* Use trusted store first */\n# define X509_V_FLAG_TRUSTED_FIRST               0x8000\n/* Suite B 128 bit only mode: not normally used */\n# define X509_V_FLAG_SUITEB_128_LOS_ONLY         0x10000\n/* Suite B 192 bit only mode */\n# define X509_V_FLAG_SUITEB_192_LOS              0x20000\n/* Suite B 128 bit mode allowing 192 bit algorithms */\n# define X509_V_FLAG_SUITEB_128_LOS              0x30000\n/* Allow partial chains if at least one certificate is in trusted store */\n# define X509_V_FLAG_PARTIAL_CHAIN               0x80000\n/*\n * If the initial chain is not trusted, do not attempt to build an alternative\n * chain. Alternate chain checking was introduced in 1.1.0. Setting this flag\n * will force the behaviour to match that of previous versions.\n */\n# define X509_V_FLAG_NO_ALT_CHAINS               0x100000\n/* Do not check certificate/CRL validity against current time */\n# define X509_V_FLAG_NO_CHECK_TIME               0x200000\n\n# define X509_VP_FLAG_DEFAULT                    0x1\n# define X509_VP_FLAG_OVERWRITE                  0x2\n# define X509_VP_FLAG_RESET_FLAGS                0x4\n# define X509_VP_FLAG_LOCKED                     0x8\n# define X509_VP_FLAG_ONCE                       0x10\n\n/* Internal use: mask of policy related options */\n# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \\\n                                | X509_V_FLAG_EXPLICIT_POLICY \\\n                                | X509_V_FLAG_INHIBIT_ANY \\\n                                | X509_V_FLAG_INHIBIT_MAP)\n\nint X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,\n                               X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,\n                                             X509_LOOKUP_TYPE type,\n                                             X509_NAME *name);\nX509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,\n                                        X509_OBJECT *x);\nint X509_OBJECT_up_ref_count(X509_OBJECT *a);\nX509_OBJECT *X509_OBJECT_new(void);\nvoid X509_OBJECT_free(X509_OBJECT *a);\nX509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a);\nX509 *X509_OBJECT_get0_X509(const X509_OBJECT *a);\nint X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj);\nX509_CRL *X509_OBJECT_get0_X509_CRL(X509_OBJECT *a);\nint X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj);\nX509_STORE *X509_STORE_new(void);\nvoid X509_STORE_free(X509_STORE *v);\nint X509_STORE_lock(X509_STORE *ctx);\nint X509_STORE_unlock(X509_STORE *ctx);\nint X509_STORE_up_ref(X509_STORE *v);\nSTACK_OF(X509_OBJECT) *X509_STORE_get0_objects(X509_STORE *v);\n\nSTACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *st, X509_NAME *nm);\nSTACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(X509_STORE_CTX *st, X509_NAME *nm);\nint X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags);\nint X509_STORE_set_purpose(X509_STORE *ctx, int purpose);\nint X509_STORE_set_trust(X509_STORE *ctx, int trust);\nint X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm);\nX509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *ctx);\n\nvoid X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify);\n#define X509_STORE_set_verify_func(ctx, func) \\\n            X509_STORE_set_verify((ctx),(func))\nvoid X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx,\n                               X509_STORE_CTX_verify_fn verify);\nX509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *ctx);\nvoid X509_STORE_set_verify_cb(X509_STORE *ctx,\n                              X509_STORE_CTX_verify_cb verify_cb);\n# define X509_STORE_set_verify_cb_func(ctx,func) \\\n            X509_STORE_set_verify_cb((ctx),(func))\nX509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(X509_STORE *ctx);\nvoid X509_STORE_set_get_issuer(X509_STORE *ctx,\n                               X509_STORE_CTX_get_issuer_fn get_issuer);\nX509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(X509_STORE *ctx);\nvoid X509_STORE_set_check_issued(X509_STORE *ctx,\n                                 X509_STORE_CTX_check_issued_fn check_issued);\nX509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(X509_STORE *ctx);\nvoid X509_STORE_set_check_revocation(X509_STORE *ctx,\n                                     X509_STORE_CTX_check_revocation_fn check_revocation);\nX509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(X509_STORE *ctx);\nvoid X509_STORE_set_get_crl(X509_STORE *ctx,\n                            X509_STORE_CTX_get_crl_fn get_crl);\nX509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(X509_STORE *ctx);\nvoid X509_STORE_set_check_crl(X509_STORE *ctx,\n                              X509_STORE_CTX_check_crl_fn check_crl);\nX509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(X509_STORE *ctx);\nvoid X509_STORE_set_cert_crl(X509_STORE *ctx,\n                             X509_STORE_CTX_cert_crl_fn cert_crl);\nX509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(X509_STORE *ctx);\nvoid X509_STORE_set_check_policy(X509_STORE *ctx,\n                                 X509_STORE_CTX_check_policy_fn check_policy);\nX509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(X509_STORE *ctx);\nvoid X509_STORE_set_lookup_certs(X509_STORE *ctx,\n                                 X509_STORE_CTX_lookup_certs_fn lookup_certs);\nX509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(X509_STORE *ctx);\nvoid X509_STORE_set_lookup_crls(X509_STORE *ctx,\n                                X509_STORE_CTX_lookup_crls_fn lookup_crls);\n#define X509_STORE_set_lookup_crls_cb(ctx, func) \\\n    X509_STORE_set_lookup_crls((ctx), (func))\nX509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(X509_STORE *ctx);\nvoid X509_STORE_set_cleanup(X509_STORE *ctx,\n                            X509_STORE_CTX_cleanup_fn cleanup);\nX509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(X509_STORE *ctx);\n\n#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef)\nint X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data);\nvoid *X509_STORE_get_ex_data(X509_STORE *ctx, int idx);\n\nX509_STORE_CTX *X509_STORE_CTX_new(void);\n\nint X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x);\n\nvoid X509_STORE_CTX_free(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store,\n                        X509 *x509, STACK_OF(X509) *chain);\nvoid X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx);\n\nX509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx);\nX509 *X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx);\nSTACK_OF(X509)* X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,\n                                  X509_STORE_CTX_verify_cb verify);\nX509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(X509_STORE_CTX *ctx);\nX509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx);\nX509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(X509_STORE_CTX *ctx);\nX509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(X509_STORE_CTX *ctx);\nX509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(X509_STORE_CTX *ctx);\nX509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(X509_STORE_CTX *ctx);\nX509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(X509_STORE_CTX *ctx);\nX509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(X509_STORE_CTX *ctx);\nX509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(X509_STORE_CTX *ctx);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain\n# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted\n# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack\n# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject\n# define X509_STORE_get1_certs X509_STORE_CTX_get1_certs\n# define X509_STORE_get1_crls X509_STORE_CTX_get1_crls\n/* the following macro is misspelled; use X509_STORE_get1_certs instead */\n# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs\n/* the following macro is misspelled; use X509_STORE_get1_crls instead */\n# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls\n#endif\n\nX509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m);\nX509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);\nX509_LOOKUP_METHOD *X509_LOOKUP_file(void);\n\ntypedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc,\n                                   long argl, char **ret);\ntypedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx,\n                                             X509_LOOKUP_TYPE type,\n                                             X509_NAME *name,\n                                             X509_OBJECT *ret);\ntypedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx,\n                                                   X509_LOOKUP_TYPE type,\n                                                   X509_NAME *name,\n                                                   ASN1_INTEGER *serial,\n                                                   X509_OBJECT *ret);\ntypedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx,\n                                                 X509_LOOKUP_TYPE type,\n                                                 const unsigned char* bytes,\n                                                 int len,\n                                                 X509_OBJECT *ret);\ntypedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx,\n                                           X509_LOOKUP_TYPE type,\n                                           const char *str,\n                                           int len,\n                                           X509_OBJECT *ret);\n\nX509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name);\nvoid X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method,\n                                  int (*new_item) (X509_LOOKUP *ctx));\nint (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method))\n    (X509_LOOKUP *ctx);\n\nint X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method,\n                              void (*free_fn) (X509_LOOKUP *ctx));\nvoid (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method))\n    (X509_LOOKUP *ctx);\n\nint X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method,\n                              int (*init) (X509_LOOKUP *ctx));\nint (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method))\n    (X509_LOOKUP *ctx);\n\nint X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method,\n                                  int (*shutdown) (X509_LOOKUP *ctx));\nint (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method))\n    (X509_LOOKUP *ctx);\n\nint X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method,\n                              X509_LOOKUP_ctrl_fn ctrl_fn);\nX509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method,\n                                        X509_LOOKUP_get_by_subject_fn fn);\nX509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject(\n    const X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method,\n    X509_LOOKUP_get_by_issuer_serial_fn fn);\nX509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial(\n    const X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method,\n    X509_LOOKUP_get_by_fingerprint_fn fn);\nX509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint(\n    const X509_LOOKUP_METHOD *method);\n\nint X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method,\n                                      X509_LOOKUP_get_by_alias_fn fn);\nX509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias(\n    const X509_LOOKUP_METHOD *method);\n\n\nint X509_STORE_add_cert(X509_STORE *ctx, X509 *x);\nint X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);\n\nint X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type,\n                                  X509_NAME *name, X509_OBJECT *ret);\nX509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs,\n                                               X509_LOOKUP_TYPE type,\n                                               X509_NAME *name);\n\nint X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,\n                     long argl, char **ret);\n\nint X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);\nint X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);\n\nX509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);\nvoid X509_LOOKUP_free(X509_LOOKUP *ctx);\nint X509_LOOKUP_init(X509_LOOKUP *ctx);\nint X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,\n                           X509_NAME *name, X509_OBJECT *ret);\nint X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,\n                                 X509_NAME *name, ASN1_INTEGER *serial,\n                                 X509_OBJECT *ret);\nint X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,\n                               const unsigned char *bytes, int len,\n                               X509_OBJECT *ret);\nint X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,\n                         const char *str, int len, X509_OBJECT *ret);\nint X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);\nvoid *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);\nX509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);\nint X509_LOOKUP_shutdown(X509_LOOKUP *ctx);\n\nint X509_STORE_load_locations(X509_STORE *ctx,\n                              const char *file, const char *dir);\nint X509_STORE_set_default_paths(X509_STORE *ctx);\n\n#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \\\n    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, freef)\nint X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data);\nvoid *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx);\nint X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s);\nint X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth);\nX509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x);\nX509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx);\nX509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx);\nX509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx);\nSTACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x);\nvoid X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk);\nvoid X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk);\nint X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);\nint X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust);\nint X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,\n                                   int purpose, int trust);\nvoid X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);\nvoid X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,\n                             time_t t);\n\nX509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx);\nint X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx);\n\nX509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx);\nvoid X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param);\nint X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name);\n\n/*\n * Bridge opacity barrier between libcrypt and libssl, also needed to support\n * offline testing in test/danetest.c\n */\nvoid X509_STORE_CTX_set0_dane(X509_STORE_CTX *ctx, SSL_DANE *dane);\n#define DANE_FLAG_NO_DANE_EE_NAMECHECKS (1L << 0)\n\n/* X509_VERIFY_PARAM functions */\n\nX509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void);\nvoid X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to,\n                              const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to,\n                           const X509_VERIFY_PARAM *from);\nint X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name);\nint X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param,\n                                unsigned long flags);\nint X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param,\n                                  unsigned long flags);\nunsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose);\nint X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust);\nvoid X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth);\nvoid X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level);\ntime_t X509_VERIFY_PARAM_get_time(const X509_VERIFY_PARAM *param);\nvoid X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t);\nint X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,\n                                  ASN1_OBJECT *policy);\nint X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param,\n                                    STACK_OF(ASN1_OBJECT) *policies);\n\nint X509_VERIFY_PARAM_set_inh_flags(X509_VERIFY_PARAM *param,\n                                    uint32_t flags);\nuint32_t X509_VERIFY_PARAM_get_inh_flags(const X509_VERIFY_PARAM *param);\n\nint X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nint X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen);\nvoid X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,\n                                     unsigned int flags);\nunsigned int X509_VERIFY_PARAM_get_hostflags(const X509_VERIFY_PARAM *param);\nchar *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *);\nvoid X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *);\nint X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param,\n                                 const char *email, size_t emaillen);\nint X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param,\n                              const unsigned char *ip, size_t iplen);\nint X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param,\n                                  const char *ipasc);\n\nint X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_get_auth_level(const X509_VERIFY_PARAM *param);\nconst char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param);\n\nint X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param);\nint X509_VERIFY_PARAM_get_count(void);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id);\nconst X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name);\nvoid X509_VERIFY_PARAM_table_cleanup(void);\n\n/* Non positive return values are errors */\n#define X509_PCY_TREE_FAILURE  -2 /* Failure to satisfy explicit policy */\n#define X509_PCY_TREE_INVALID  -1 /* Inconsistent or invalid extensions */\n#define X509_PCY_TREE_INTERNAL  0 /* Internal error, most likely malloc */\n\n/*\n * Positive return values form a bit mask, all but the first are internal to\n * the library and don't appear in results from X509_policy_check().\n */\n#define X509_PCY_TREE_VALID     1 /* The policy tree is valid */\n#define X509_PCY_TREE_EMPTY     2 /* The policy tree is empty */\n#define X509_PCY_TREE_EXPLICIT  4 /* Explicit policy required */\n\nint X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy,\n                      STACK_OF(X509) *certs,\n                      STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags);\n\nvoid X509_policy_tree_free(X509_POLICY_TREE *tree);\n\nint X509_policy_tree_level_count(const X509_POLICY_TREE *tree);\nX509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree,\n                                               int i);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const\n                                                           X509_POLICY_TREE\n                                                           *tree);\n\nSTACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const\n                                                                X509_POLICY_TREE\n                                                                *tree);\n\nint X509_policy_level_node_count(X509_POLICY_LEVEL *level);\n\nX509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level,\n                                              int i);\n\nconst ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node);\n\nSTACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const\n                                                           X509_POLICY_NODE\n                                                           *node);\nconst X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE\n                                                     *node);\n\n#ifdef  __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/x509err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509ERR_H\n# define HEADER_X509ERR_H\n\n# include <openssl/symhacks.h>\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_X509_strings(void);\n\n/*\n * X509 function codes.\n */\n# define X509_F_ADD_CERT_DIR                              100\n# define X509_F_BUILD_CHAIN                               106\n# define X509_F_BY_FILE_CTRL                              101\n# define X509_F_CHECK_NAME_CONSTRAINTS                    149\n# define X509_F_CHECK_POLICY                              145\n# define X509_F_DANE_I2D                                  107\n# define X509_F_DIR_CTRL                                  102\n# define X509_F_GET_CERT_BY_SUBJECT                       103\n# define X509_F_I2D_X509_AUX                              151\n# define X509_F_LOOKUP_CERTS_SK                           152\n# define X509_F_NETSCAPE_SPKI_B64_DECODE                  129\n# define X509_F_NETSCAPE_SPKI_B64_ENCODE                  130\n# define X509_F_NEW_DIR                                   153\n# define X509_F_X509AT_ADD1_ATTR                          135\n# define X509_F_X509V3_ADD_EXT                            104\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID              136\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ              137\n# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT              140\n# define X509_F_X509_ATTRIBUTE_GET0_DATA                  139\n# define X509_F_X509_ATTRIBUTE_SET1_DATA                  138\n# define X509_F_X509_CHECK_PRIVATE_KEY                    128\n# define X509_F_X509_CRL_DIFF                             105\n# define X509_F_X509_CRL_METHOD_NEW                       154\n# define X509_F_X509_CRL_PRINT_FP                         147\n# define X509_F_X509_EXTENSION_CREATE_BY_NID              108\n# define X509_F_X509_EXTENSION_CREATE_BY_OBJ              109\n# define X509_F_X509_GET_PUBKEY_PARAMETERS                110\n# define X509_F_X509_LOAD_CERT_CRL_FILE                   132\n# define X509_F_X509_LOAD_CERT_FILE                       111\n# define X509_F_X509_LOAD_CRL_FILE                        112\n# define X509_F_X509_LOOKUP_METH_NEW                      160\n# define X509_F_X509_LOOKUP_NEW                           155\n# define X509_F_X509_NAME_ADD_ENTRY                       113\n# define X509_F_X509_NAME_CANON                           156\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID             114\n# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT             131\n# define X509_F_X509_NAME_ENTRY_SET_OBJECT                115\n# define X509_F_X509_NAME_ONELINE                         116\n# define X509_F_X509_NAME_PRINT                           117\n# define X509_F_X509_OBJECT_NEW                           150\n# define X509_F_X509_PRINT_EX_FP                          118\n# define X509_F_X509_PUBKEY_DECODE                        148\n# define X509_F_X509_PUBKEY_GET                           161\n# define X509_F_X509_PUBKEY_GET0                          119\n# define X509_F_X509_PUBKEY_SET                           120\n# define X509_F_X509_REQ_CHECK_PRIVATE_KEY                144\n# define X509_F_X509_REQ_PRINT_EX                         121\n# define X509_F_X509_REQ_PRINT_FP                         122\n# define X509_F_X509_REQ_TO_X509                          123\n# define X509_F_X509_STORE_ADD_CERT                       124\n# define X509_F_X509_STORE_ADD_CRL                        125\n# define X509_F_X509_STORE_ADD_LOOKUP                     157\n# define X509_F_X509_STORE_CTX_GET1_ISSUER                146\n# define X509_F_X509_STORE_CTX_INIT                       143\n# define X509_F_X509_STORE_CTX_NEW                        142\n# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT            134\n# define X509_F_X509_STORE_NEW                            158\n# define X509_F_X509_TO_X509_REQ                          126\n# define X509_F_X509_TRUST_ADD                            133\n# define X509_F_X509_TRUST_SET                            141\n# define X509_F_X509_VERIFY_CERT                          127\n# define X509_F_X509_VERIFY_PARAM_NEW                     159\n\n/*\n * X509 reason codes.\n */\n# define X509_R_AKID_MISMATCH                             110\n# define X509_R_BAD_SELECTOR                              133\n# define X509_R_BAD_X509_FILETYPE                         100\n# define X509_R_BASE64_DECODE_ERROR                       118\n# define X509_R_CANT_CHECK_DH_KEY                         114\n# define X509_R_CERT_ALREADY_IN_HASH_TABLE                101\n# define X509_R_CRL_ALREADY_DELTA                         127\n# define X509_R_CRL_VERIFY_FAILURE                        131\n# define X509_R_IDP_MISMATCH                              128\n# define X509_R_INVALID_ATTRIBUTES                        138\n# define X509_R_INVALID_DIRECTORY                         113\n# define X509_R_INVALID_FIELD_NAME                        119\n# define X509_R_INVALID_TRUST                             123\n# define X509_R_ISSUER_MISMATCH                           129\n# define X509_R_KEY_TYPE_MISMATCH                         115\n# define X509_R_KEY_VALUES_MISMATCH                       116\n# define X509_R_LOADING_CERT_DIR                          103\n# define X509_R_LOADING_DEFAULTS                          104\n# define X509_R_METHOD_NOT_SUPPORTED                      124\n# define X509_R_NAME_TOO_LONG                             134\n# define X509_R_NEWER_CRL_NOT_NEWER                       132\n# define X509_R_NO_CERTIFICATE_FOUND                      135\n# define X509_R_NO_CERTIFICATE_OR_CRL_FOUND               136\n# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY              105\n# define X509_R_NO_CRL_FOUND                              137\n# define X509_R_NO_CRL_NUMBER                             130\n# define X509_R_PUBLIC_KEY_DECODE_ERROR                   125\n# define X509_R_PUBLIC_KEY_ENCODE_ERROR                   126\n# define X509_R_SHOULD_RETRY                              106\n# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN        107\n# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY            108\n# define X509_R_UNKNOWN_KEY_TYPE                          117\n# define X509_R_UNKNOWN_NID                               109\n# define X509_R_UNKNOWN_PURPOSE_ID                        121\n# define X509_R_UNKNOWN_TRUST_ID                          120\n# define X509_R_UNSUPPORTED_ALGORITHM                     111\n# define X509_R_WRONG_LOOKUP_TYPE                         112\n# define X509_R_WRONG_TYPE                                122\n\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/x509v3.h",
    "content": "/*\n * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509V3_H\n# define HEADER_X509V3_H\n\n# include <openssl/bio.h>\n# include <openssl/x509.h>\n# include <openssl/conf.h>\n# include <openssl/x509v3err.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Forward reference */\nstruct v3_ext_method;\nstruct v3_ext_ctx;\n\n/* Useful typedefs */\n\ntypedef void *(*X509V3_EXT_NEW)(void);\ntypedef void (*X509V3_EXT_FREE) (void *);\ntypedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);\ntypedef int (*X509V3_EXT_I2D) (void *, unsigned char **);\ntypedef STACK_OF(CONF_VALUE) *\n    (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext,\n                       STACK_OF(CONF_VALUE) *extlist);\ntypedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx,\n                                STACK_OF(CONF_VALUE) *values);\ntypedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method,\n                                void *ext);\ntypedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\ntypedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext,\n                               BIO *out, int indent);\ntypedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method,\n                                struct v3_ext_ctx *ctx, const char *str);\n\n/* V3 extension structure */\n\nstruct v3_ext_method {\n    int ext_nid;\n    int ext_flags;\n/* If this is set the following four fields are ignored */\n    ASN1_ITEM_EXP *it;\n/* Old style ASN1 calls */\n    X509V3_EXT_NEW ext_new;\n    X509V3_EXT_FREE ext_free;\n    X509V3_EXT_D2I d2i;\n    X509V3_EXT_I2D i2d;\n/* The following pair is used for string extensions */\n    X509V3_EXT_I2S i2s;\n    X509V3_EXT_S2I s2i;\n/* The following pair is used for multi-valued extensions */\n    X509V3_EXT_I2V i2v;\n    X509V3_EXT_V2I v2i;\n/* The following are used for raw extensions */\n    X509V3_EXT_I2R i2r;\n    X509V3_EXT_R2I r2i;\n    void *usr_data;             /* Any extension specific data */\n};\n\ntypedef struct X509V3_CONF_METHOD_st {\n    char *(*get_string) (void *db, const char *section, const char *value);\n    STACK_OF(CONF_VALUE) *(*get_section) (void *db, const char *section);\n    void (*free_string) (void *db, char *string);\n    void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section);\n} X509V3_CONF_METHOD;\n\n/* Context specific info */\nstruct v3_ext_ctx {\n# define CTX_TEST 0x1\n# define X509V3_CTX_REPLACE 0x2\n    int flags;\n    X509 *issuer_cert;\n    X509 *subject_cert;\n    X509_REQ *subject_req;\n    X509_CRL *crl;\n    X509V3_CONF_METHOD *db_meth;\n    void *db;\n/* Maybe more here */\n};\n\ntypedef struct v3_ext_method X509V3_EXT_METHOD;\n\nDEFINE_STACK_OF(X509V3_EXT_METHOD)\n\n/* ext_flags values */\n# define X509V3_EXT_DYNAMIC      0x1\n# define X509V3_EXT_CTX_DEP      0x2\n# define X509V3_EXT_MULTILINE    0x4\n\ntypedef BIT_STRING_BITNAME ENUMERATED_NAMES;\n\ntypedef struct BASIC_CONSTRAINTS_st {\n    int ca;\n    ASN1_INTEGER *pathlen;\n} BASIC_CONSTRAINTS;\n\ntypedef struct PKEY_USAGE_PERIOD_st {\n    ASN1_GENERALIZEDTIME *notBefore;\n    ASN1_GENERALIZEDTIME *notAfter;\n} PKEY_USAGE_PERIOD;\n\ntypedef struct otherName_st {\n    ASN1_OBJECT *type_id;\n    ASN1_TYPE *value;\n} OTHERNAME;\n\ntypedef struct EDIPartyName_st {\n    ASN1_STRING *nameAssigner;\n    ASN1_STRING *partyName;\n} EDIPARTYNAME;\n\ntypedef struct GENERAL_NAME_st {\n# define GEN_OTHERNAME   0\n# define GEN_EMAIL       1\n# define GEN_DNS         2\n# define GEN_X400        3\n# define GEN_DIRNAME     4\n# define GEN_EDIPARTY    5\n# define GEN_URI         6\n# define GEN_IPADD       7\n# define GEN_RID         8\n    int type;\n    union {\n        char *ptr;\n        OTHERNAME *otherName;   /* otherName */\n        ASN1_IA5STRING *rfc822Name;\n        ASN1_IA5STRING *dNSName;\n        ASN1_TYPE *x400Address;\n        X509_NAME *directoryName;\n        EDIPARTYNAME *ediPartyName;\n        ASN1_IA5STRING *uniformResourceIdentifier;\n        ASN1_OCTET_STRING *iPAddress;\n        ASN1_OBJECT *registeredID;\n        /* Old names */\n        ASN1_OCTET_STRING *ip;  /* iPAddress */\n        X509_NAME *dirn;        /* dirn */\n        ASN1_IA5STRING *ia5;    /* rfc822Name, dNSName,\n                                 * uniformResourceIdentifier */\n        ASN1_OBJECT *rid;       /* registeredID */\n        ASN1_TYPE *other;       /* x400Address */\n    } d;\n} GENERAL_NAME;\n\ntypedef struct ACCESS_DESCRIPTION_st {\n    ASN1_OBJECT *method;\n    GENERAL_NAME *location;\n} ACCESS_DESCRIPTION;\n\ntypedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;\n\ntypedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;\n\ntypedef STACK_OF(ASN1_INTEGER) TLS_FEATURE;\n\nDEFINE_STACK_OF(GENERAL_NAME)\ntypedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;\nDEFINE_STACK_OF(GENERAL_NAMES)\n\nDEFINE_STACK_OF(ACCESS_DESCRIPTION)\n\ntypedef struct DIST_POINT_NAME_st {\n    int type;\n    union {\n        GENERAL_NAMES *fullname;\n        STACK_OF(X509_NAME_ENTRY) *relativename;\n    } name;\n/* If relativename then this contains the full distribution point name */\n    X509_NAME *dpname;\n} DIST_POINT_NAME;\n/* All existing reasons */\n# define CRLDP_ALL_REASONS       0x807f\n\n# define CRL_REASON_NONE                         -1\n# define CRL_REASON_UNSPECIFIED                  0\n# define CRL_REASON_KEY_COMPROMISE               1\n# define CRL_REASON_CA_COMPROMISE                2\n# define CRL_REASON_AFFILIATION_CHANGED          3\n# define CRL_REASON_SUPERSEDED                   4\n# define CRL_REASON_CESSATION_OF_OPERATION       5\n# define CRL_REASON_CERTIFICATE_HOLD             6\n# define CRL_REASON_REMOVE_FROM_CRL              8\n# define CRL_REASON_PRIVILEGE_WITHDRAWN          9\n# define CRL_REASON_AA_COMPROMISE                10\n\nstruct DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    ASN1_BIT_STRING *reasons;\n    GENERAL_NAMES *CRLissuer;\n    int dp_reasons;\n};\n\ntypedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;\n\nDEFINE_STACK_OF(DIST_POINT)\n\nstruct AUTHORITY_KEYID_st {\n    ASN1_OCTET_STRING *keyid;\n    GENERAL_NAMES *issuer;\n    ASN1_INTEGER *serial;\n};\n\n/* Strong extranet structures */\n\ntypedef struct SXNET_ID_st {\n    ASN1_INTEGER *zone;\n    ASN1_OCTET_STRING *user;\n} SXNETID;\n\nDEFINE_STACK_OF(SXNETID)\n\ntypedef struct SXNET_st {\n    ASN1_INTEGER *version;\n    STACK_OF(SXNETID) *ids;\n} SXNET;\n\ntypedef struct NOTICEREF_st {\n    ASN1_STRING *organization;\n    STACK_OF(ASN1_INTEGER) *noticenos;\n} NOTICEREF;\n\ntypedef struct USERNOTICE_st {\n    NOTICEREF *noticeref;\n    ASN1_STRING *exptext;\n} USERNOTICE;\n\ntypedef struct POLICYQUALINFO_st {\n    ASN1_OBJECT *pqualid;\n    union {\n        ASN1_IA5STRING *cpsuri;\n        USERNOTICE *usernotice;\n        ASN1_TYPE *other;\n    } d;\n} POLICYQUALINFO;\n\nDEFINE_STACK_OF(POLICYQUALINFO)\n\ntypedef struct POLICYINFO_st {\n    ASN1_OBJECT *policyid;\n    STACK_OF(POLICYQUALINFO) *qualifiers;\n} POLICYINFO;\n\ntypedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;\n\nDEFINE_STACK_OF(POLICYINFO)\n\ntypedef struct POLICY_MAPPING_st {\n    ASN1_OBJECT *issuerDomainPolicy;\n    ASN1_OBJECT *subjectDomainPolicy;\n} POLICY_MAPPING;\n\nDEFINE_STACK_OF(POLICY_MAPPING)\n\ntypedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;\n\ntypedef struct GENERAL_SUBTREE_st {\n    GENERAL_NAME *base;\n    ASN1_INTEGER *minimum;\n    ASN1_INTEGER *maximum;\n} GENERAL_SUBTREE;\n\nDEFINE_STACK_OF(GENERAL_SUBTREE)\n\nstruct NAME_CONSTRAINTS_st {\n    STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;\n    STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;\n};\n\ntypedef struct POLICY_CONSTRAINTS_st {\n    ASN1_INTEGER *requireExplicitPolicy;\n    ASN1_INTEGER *inhibitPolicyMapping;\n} POLICY_CONSTRAINTS;\n\n/* Proxy certificate structures, see RFC 3820 */\ntypedef struct PROXY_POLICY_st {\n    ASN1_OBJECT *policyLanguage;\n    ASN1_OCTET_STRING *policy;\n} PROXY_POLICY;\n\ntypedef struct PROXY_CERT_INFO_EXTENSION_st {\n    ASN1_INTEGER *pcPathLengthConstraint;\n    PROXY_POLICY *proxyPolicy;\n} PROXY_CERT_INFO_EXTENSION;\n\nDECLARE_ASN1_FUNCTIONS(PROXY_POLICY)\nDECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)\n\nstruct ISSUING_DIST_POINT_st {\n    DIST_POINT_NAME *distpoint;\n    int onlyuser;\n    int onlyCA;\n    ASN1_BIT_STRING *onlysomereasons;\n    int indirectCRL;\n    int onlyattr;\n};\n\n/* Values in idp_flags field */\n/* IDP present */\n# define IDP_PRESENT     0x1\n/* IDP values inconsistent */\n# define IDP_INVALID     0x2\n/* onlyuser true */\n# define IDP_ONLYUSER    0x4\n/* onlyCA true */\n# define IDP_ONLYCA      0x8\n/* onlyattr true */\n# define IDP_ONLYATTR    0x10\n/* indirectCRL true */\n# define IDP_INDIRECT    0x20\n/* onlysomereasons present */\n# define IDP_REASONS     0x40\n\n# define X509V3_conf_err(val) ERR_add_error_data(6, \\\n                        \"section:\", (val)->section, \\\n                        \",name:\", (val)->name, \",value:\", (val)->value)\n\n# define X509V3_set_ctx_test(ctx) \\\n                        X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)\n# define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;\n\n# define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \\\n                        0,0,0,0, \\\n                        0,0, \\\n                        (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \\\n                        (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \\\n                        NULL, NULL, \\\n                        table}\n\n# define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \\\n                        0,0,0,0, \\\n                        (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \\\n                        (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \\\n                        0,0,0,0, \\\n                        NULL}\n\n# define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}\n\n/* X509_PURPOSE stuff */\n\n# define EXFLAG_BCONS            0x1\n# define EXFLAG_KUSAGE           0x2\n# define EXFLAG_XKUSAGE          0x4\n# define EXFLAG_NSCERT           0x8\n\n# define EXFLAG_CA               0x10\n/* Really self issued not necessarily self signed */\n# define EXFLAG_SI               0x20\n# define EXFLAG_V1               0x40\n# define EXFLAG_INVALID          0x80\n/* EXFLAG_SET is set to indicate that some values have been precomputed */\n# define EXFLAG_SET              0x100\n# define EXFLAG_CRITICAL         0x200\n# define EXFLAG_PROXY            0x400\n\n# define EXFLAG_INVALID_POLICY   0x800\n# define EXFLAG_FRESHEST         0x1000\n# define EXFLAG_SS               0x2000 /* cert is apparently self-signed */\n\n# define EXFLAG_NO_FINGERPRINT   0x100000\n\n# define KU_DIGITAL_SIGNATURE    0x0080\n# define KU_NON_REPUDIATION      0x0040\n# define KU_KEY_ENCIPHERMENT     0x0020\n# define KU_DATA_ENCIPHERMENT    0x0010\n# define KU_KEY_AGREEMENT        0x0008\n# define KU_KEY_CERT_SIGN        0x0004\n# define KU_CRL_SIGN             0x0002\n# define KU_ENCIPHER_ONLY        0x0001\n# define KU_DECIPHER_ONLY        0x8000\n\n# define NS_SSL_CLIENT           0x80\n# define NS_SSL_SERVER           0x40\n# define NS_SMIME                0x20\n# define NS_OBJSIGN              0x10\n# define NS_SSL_CA               0x04\n# define NS_SMIME_CA             0x02\n# define NS_OBJSIGN_CA           0x01\n# define NS_ANY_CA               (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA)\n\n# define XKU_SSL_SERVER          0x1\n# define XKU_SSL_CLIENT          0x2\n# define XKU_SMIME               0x4\n# define XKU_CODE_SIGN           0x8\n# define XKU_SGC                 0x10\n# define XKU_OCSP_SIGN           0x20\n# define XKU_TIMESTAMP           0x40\n# define XKU_DVCS                0x80\n# define XKU_ANYEKU              0x100\n\n# define X509_PURPOSE_DYNAMIC    0x1\n# define X509_PURPOSE_DYNAMIC_NAME       0x2\n\ntypedef struct x509_purpose_st {\n    int purpose;\n    int trust;                  /* Default trust ID */\n    int flags;\n    int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int);\n    char *name;\n    char *sname;\n    void *usr_data;\n} X509_PURPOSE;\n\n# define X509_PURPOSE_SSL_CLIENT         1\n# define X509_PURPOSE_SSL_SERVER         2\n# define X509_PURPOSE_NS_SSL_SERVER      3\n# define X509_PURPOSE_SMIME_SIGN         4\n# define X509_PURPOSE_SMIME_ENCRYPT      5\n# define X509_PURPOSE_CRL_SIGN           6\n# define X509_PURPOSE_ANY                7\n# define X509_PURPOSE_OCSP_HELPER        8\n# define X509_PURPOSE_TIMESTAMP_SIGN     9\n\n# define X509_PURPOSE_MIN                1\n# define X509_PURPOSE_MAX                9\n\n/* Flags for X509V3_EXT_print() */\n\n# define X509V3_EXT_UNKNOWN_MASK         (0xfL << 16)\n/* Return error for unknown extensions */\n# define X509V3_EXT_DEFAULT              0\n/* Print error for unknown extensions */\n# define X509V3_EXT_ERROR_UNKNOWN        (1L << 16)\n/* ASN1 parse unknown extensions */\n# define X509V3_EXT_PARSE_UNKNOWN        (2L << 16)\n/* BIO_dump unknown extensions */\n# define X509V3_EXT_DUMP_UNKNOWN         (3L << 16)\n\n/* Flags for X509V3_add1_i2d */\n\n# define X509V3_ADD_OP_MASK              0xfL\n# define X509V3_ADD_DEFAULT              0L\n# define X509V3_ADD_APPEND               1L\n# define X509V3_ADD_REPLACE              2L\n# define X509V3_ADD_REPLACE_EXISTING     3L\n# define X509V3_ADD_KEEP_EXISTING        4L\n# define X509V3_ADD_DELETE               5L\n# define X509V3_ADD_SILENT               0x10\n\nDEFINE_STACK_OF(X509_PURPOSE)\n\nDECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)\n\nDECLARE_ASN1_FUNCTIONS(SXNET)\nDECLARE_ASN1_FUNCTIONS(SXNETID)\n\nint SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen);\nint SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user,\n                       int userlen);\nint SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user,\n                         int userlen);\n\nASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone);\nASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone);\nASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone);\n\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)\n\nDECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD)\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAME)\nGENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);\nint GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b);\n\nASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                     X509V3_CTX *ctx,\n                                     STACK_OF(CONF_VALUE) *nval);\nSTACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,\n                                          ASN1_BIT_STRING *bits,\n                                          STACK_OF(CONF_VALUE) *extlist);\nchar *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5);\nASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,\n                                   X509V3_CTX *ctx, const char *str);\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method,\n                                       GENERAL_NAME *gen,\n                                       STACK_OF(CONF_VALUE) *ret);\nint GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);\n\nDECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)\n\nSTACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method,\n                                        GENERAL_NAMES *gen,\n                                        STACK_OF(CONF_VALUE) *extlist);\nGENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,\n                                 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);\n\nDECLARE_ASN1_FUNCTIONS(OTHERNAME)\nDECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)\nint OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);\nvoid GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value);\nvoid *GENERAL_NAME_get0_value(const GENERAL_NAME *a, int *ptype);\nint GENERAL_NAME_set0_othername(GENERAL_NAME *gen,\n                                ASN1_OBJECT *oid, ASN1_TYPE *value);\nint GENERAL_NAME_get0_otherName(const GENERAL_NAME *gen,\n                                ASN1_OBJECT **poid, ASN1_TYPE **pvalue);\n\nchar *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                            const ASN1_OCTET_STRING *ia5);\nASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,\n                                         X509V3_CTX *ctx, const char *str);\n\nDECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)\nint i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a);\n\nDECLARE_ASN1_ALLOC_FUNCTIONS(TLS_FEATURE)\n\nDECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)\nDECLARE_ASN1_FUNCTIONS(POLICYINFO)\nDECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)\nDECLARE_ASN1_FUNCTIONS(USERNOTICE)\nDECLARE_ASN1_FUNCTIONS(NOTICEREF)\n\nDECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT)\nDECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)\nDECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)\n\nint DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname);\n\nint NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);\nint NAME_CONSTRAINTS_check_CN(X509 *x, NAME_CONSTRAINTS *nc);\n\nDECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)\nDECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)\n\nDECLARE_ASN1_ITEM(POLICY_MAPPING)\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)\nDECLARE_ASN1_ITEM(POLICY_MAPPINGS)\n\nDECLARE_ASN1_ITEM(GENERAL_SUBTREE)\nDECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)\n\nDECLARE_ASN1_ITEM(NAME_CONSTRAINTS)\nDECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)\n\nDECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)\nDECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)\n\nGENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,\n                               const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, int gen_type,\n                               const char *value, int is_nc);\n\n# ifdef HEADER_CONF_H\nGENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,\n                               X509V3_CTX *ctx, CONF_VALUE *cnf);\nGENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,\n                                  const X509V3_EXT_METHOD *method,\n                                  X509V3_CTX *ctx, CONF_VALUE *cnf,\n                                  int is_nc);\nvoid X509V3_conf_free(CONF_VALUE *val);\n\nX509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,\n                                     const char *value);\nX509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name,\n                                 const char *value);\nint X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section,\n                            STACK_OF(X509_EXTENSION) **sk);\nint X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,\n                         X509 *cert);\nint X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,\n                             X509_REQ *req);\nint X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section,\n                             X509_CRL *crl);\n\nX509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,\n                                    X509V3_CTX *ctx, int ext_nid,\n                                    const char *value);\nX509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                                const char *name, const char *value);\nint X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                        const char *section, X509 *cert);\nint X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            const char *section, X509_REQ *req);\nint X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx,\n                            const char *section, X509_CRL *crl);\n\nint X509V3_add_value_bool_nf(const char *name, int asn1_bool,\n                             STACK_OF(CONF_VALUE) **extlist);\nint X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool);\nint X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint);\nvoid X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);\nvoid X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash);\n# endif\n\nchar *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section);\nSTACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section);\nvoid X509V3_string_free(X509V3_CTX *ctx, char *str);\nvoid X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section);\nvoid X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,\n                    X509_REQ *req, X509_CRL *crl, int flags);\n\nint X509V3_add_value(const char *name, const char *value,\n                     STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_uchar(const char *name, const unsigned char *value,\n                           STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_bool(const char *name, int asn1_bool,\n                          STACK_OF(CONF_VALUE) **extlist);\nint X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint,\n                         STACK_OF(CONF_VALUE) **extlist);\nchar *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const ASN1_INTEGER *aint);\nASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value);\nchar *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint);\nchar *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth,\n                                const ASN1_ENUMERATED *aint);\nint X509V3_EXT_add(X509V3_EXT_METHOD *ext);\nint X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);\nint X509V3_EXT_add_alias(int nid_to, int nid_from);\nvoid X509V3_EXT_cleanup(void);\n\nconst X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext);\nconst X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);\nint X509V3_add_standard_extensions(void);\nSTACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);\nvoid *X509V3_EXT_d2i(X509_EXTENSION *ext);\nvoid *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit,\n                     int *idx);\n\nX509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc);\nint X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value,\n                    int crit, unsigned long flags);\n\n#if OPENSSL_API_COMPAT < 0x10100000L\n/* The new declarations are in crypto.h, but the old ones were here. */\n# define hex_to_string OPENSSL_buf2hexstr\n# define string_to_hex OPENSSL_hexstr2buf\n#endif\n\nvoid X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent,\n                        int ml);\nint X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,\n                     int indent);\n#ifndef OPENSSL_NO_STDIO\nint X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent);\n#endif\nint X509V3_extensions_print(BIO *out, const char *title,\n                            const STACK_OF(X509_EXTENSION) *exts,\n                            unsigned long flag, int indent);\n\nint X509_check_ca(X509 *x);\nint X509_check_purpose(X509 *x, int id, int ca);\nint X509_supported_extension(X509_EXTENSION *ex);\nint X509_PURPOSE_set(int *p, int purpose);\nint X509_check_issued(X509 *issuer, X509 *subject);\nint X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);\nvoid X509_set_proxy_flag(X509 *x);\nvoid X509_set_proxy_pathlen(X509 *x, long l);\nlong X509_get_proxy_pathlen(X509 *x);\n\nuint32_t X509_get_extension_flags(X509 *x);\nuint32_t X509_get_key_usage(X509 *x);\nuint32_t X509_get_extended_key_usage(X509 *x);\nconst ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x);\nconst ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x);\nconst GENERAL_NAMES *X509_get0_authority_issuer(X509 *x);\nconst ASN1_INTEGER *X509_get0_authority_serial(X509 *x);\n\nint X509_PURPOSE_get_count(void);\nX509_PURPOSE *X509_PURPOSE_get0(int idx);\nint X509_PURPOSE_get_by_sname(const char *sname);\nint X509_PURPOSE_get_by_id(int id);\nint X509_PURPOSE_add(int id, int trust, int flags,\n                     int (*ck) (const X509_PURPOSE *, const X509 *, int),\n                     const char *name, const char *sname, void *arg);\nchar *X509_PURPOSE_get0_name(const X509_PURPOSE *xp);\nchar *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp);\nint X509_PURPOSE_get_trust(const X509_PURPOSE *xp);\nvoid X509_PURPOSE_cleanup(void);\nint X509_PURPOSE_get_id(const X509_PURPOSE *);\n\nSTACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);\nSTACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);\nvoid X509_email_free(STACK_OF(OPENSSL_STRING) *sk);\nSTACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);\n/* Flags for X509_check_* functions */\n\n/*\n * Always check subject name for host match even if subject alt names present\n */\n# define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT    0x1\n/* Disable wildcard matching for dnsName fields and common name. */\n# define X509_CHECK_FLAG_NO_WILDCARDS    0x2\n/* Wildcards must not match a partial label. */\n# define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4\n/* Allow (non-partial) wildcards to match multiple labels. */\n# define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8\n/* Constraint verifier subdomain patterns to match a single labels. */\n# define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10\n/* Never check the subject CN */\n# define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT    0x20\n/*\n * Match reference identifiers starting with \".\" to any sub-domain.\n * This is a non-public flag, turned on implicitly when the subject\n * reference identity is a DNS name.\n */\n# define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000\n\nint X509_check_host(X509 *x, const char *chk, size_t chklen,\n                    unsigned int flags, char **peername);\nint X509_check_email(X509 *x, const char *chk, size_t chklen,\n                     unsigned int flags);\nint X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen,\n                  unsigned int flags);\nint X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags);\n\nASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);\nASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);\nint X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk,\n                             unsigned long chtype);\n\nvoid X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent);\nDEFINE_STACK_OF(X509_POLICY_NODE)\n\n#ifndef OPENSSL_NO_RFC3779\ntypedef struct ASRange_st {\n    ASN1_INTEGER *min, *max;\n} ASRange;\n\n# define ASIdOrRange_id          0\n# define ASIdOrRange_range       1\n\ntypedef struct ASIdOrRange_st {\n    int type;\n    union {\n        ASN1_INTEGER *id;\n        ASRange *range;\n    } u;\n} ASIdOrRange;\n\ntypedef STACK_OF(ASIdOrRange) ASIdOrRanges;\nDEFINE_STACK_OF(ASIdOrRange)\n\n# define ASIdentifierChoice_inherit              0\n# define ASIdentifierChoice_asIdsOrRanges        1\n\ntypedef struct ASIdentifierChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        ASIdOrRanges *asIdsOrRanges;\n    } u;\n} ASIdentifierChoice;\n\ntypedef struct ASIdentifiers_st {\n    ASIdentifierChoice *asnum, *rdi;\n} ASIdentifiers;\n\nDECLARE_ASN1_FUNCTIONS(ASRange)\nDECLARE_ASN1_FUNCTIONS(ASIdOrRange)\nDECLARE_ASN1_FUNCTIONS(ASIdentifierChoice)\nDECLARE_ASN1_FUNCTIONS(ASIdentifiers)\n\ntypedef struct IPAddressRange_st {\n    ASN1_BIT_STRING *min, *max;\n} IPAddressRange;\n\n# define IPAddressOrRange_addressPrefix  0\n# define IPAddressOrRange_addressRange   1\n\ntypedef struct IPAddressOrRange_st {\n    int type;\n    union {\n        ASN1_BIT_STRING *addressPrefix;\n        IPAddressRange *addressRange;\n    } u;\n} IPAddressOrRange;\n\ntypedef STACK_OF(IPAddressOrRange) IPAddressOrRanges;\nDEFINE_STACK_OF(IPAddressOrRange)\n\n# define IPAddressChoice_inherit                 0\n# define IPAddressChoice_addressesOrRanges       1\n\ntypedef struct IPAddressChoice_st {\n    int type;\n    union {\n        ASN1_NULL *inherit;\n        IPAddressOrRanges *addressesOrRanges;\n    } u;\n} IPAddressChoice;\n\ntypedef struct IPAddressFamily_st {\n    ASN1_OCTET_STRING *addressFamily;\n    IPAddressChoice *ipAddressChoice;\n} IPAddressFamily;\n\ntypedef STACK_OF(IPAddressFamily) IPAddrBlocks;\nDEFINE_STACK_OF(IPAddressFamily)\n\nDECLARE_ASN1_FUNCTIONS(IPAddressRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressOrRange)\nDECLARE_ASN1_FUNCTIONS(IPAddressChoice)\nDECLARE_ASN1_FUNCTIONS(IPAddressFamily)\n\n/*\n * API tag for elements of the ASIdentifer SEQUENCE.\n */\n# define V3_ASID_ASNUM   0\n# define V3_ASID_RDI     1\n\n/*\n * AFI values, assigned by IANA.  It'd be nice to make the AFI\n * handling code totally generic, but there are too many little things\n * that would need to be defined for other address families for it to\n * be worth the trouble.\n */\n# define IANA_AFI_IPV4   1\n# define IANA_AFI_IPV6   2\n\n/*\n * Utilities to construct and extract values from RFC3779 extensions,\n * since some of the encodings (particularly for IP address prefixes\n * and ranges) are a bit tedious to work with directly.\n */\nint X509v3_asid_add_inherit(ASIdentifiers *asid, int which);\nint X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which,\n                                ASN1_INTEGER *min, ASN1_INTEGER *max);\nint X509v3_addr_add_inherit(IPAddrBlocks *addr,\n                            const unsigned afi, const unsigned *safi);\nint X509v3_addr_add_prefix(IPAddrBlocks *addr,\n                           const unsigned afi, const unsigned *safi,\n                           unsigned char *a, const int prefixlen);\nint X509v3_addr_add_range(IPAddrBlocks *addr,\n                          const unsigned afi, const unsigned *safi,\n                          unsigned char *min, unsigned char *max);\nunsigned X509v3_addr_get_afi(const IPAddressFamily *f);\nint X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi,\n                          unsigned char *min, unsigned char *max,\n                          const int length);\n\n/*\n * Canonical forms.\n */\nint X509v3_asid_is_canonical(ASIdentifiers *asid);\nint X509v3_addr_is_canonical(IPAddrBlocks *addr);\nint X509v3_asid_canonize(ASIdentifiers *asid);\nint X509v3_addr_canonize(IPAddrBlocks *addr);\n\n/*\n * Tests for inheritance and containment.\n */\nint X509v3_asid_inherits(ASIdentifiers *asid);\nint X509v3_addr_inherits(IPAddrBlocks *addr);\nint X509v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b);\nint X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b);\n\n/*\n * Check whether RFC 3779 extensions nest properly in chains.\n */\nint X509v3_asid_validate_path(X509_STORE_CTX *);\nint X509v3_addr_validate_path(X509_STORE_CTX *);\nint X509v3_asid_validate_resource_set(STACK_OF(X509) *chain,\n                                      ASIdentifiers *ext,\n                                      int allow_inheritance);\nint X509v3_addr_validate_resource_set(STACK_OF(X509) *chain,\n                                      IPAddrBlocks *ext, int allow_inheritance);\n\n#endif                         /* OPENSSL_NO_RFC3779 */\n\nDEFINE_STACK_OF(ASN1_STRING)\n\n/*\n * Admission Syntax\n */\ntypedef struct NamingAuthority_st NAMING_AUTHORITY;\ntypedef struct ProfessionInfo_st PROFESSION_INFO;\ntypedef struct Admissions_st ADMISSIONS;\ntypedef struct AdmissionSyntax_st ADMISSION_SYNTAX;\nDECLARE_ASN1_FUNCTIONS(NAMING_AUTHORITY)\nDECLARE_ASN1_FUNCTIONS(PROFESSION_INFO)\nDECLARE_ASN1_FUNCTIONS(ADMISSIONS)\nDECLARE_ASN1_FUNCTIONS(ADMISSION_SYNTAX)\nDEFINE_STACK_OF(ADMISSIONS)\nDEFINE_STACK_OF(PROFESSION_INFO)\ntypedef STACK_OF(PROFESSION_INFO) PROFESSION_INFOS;\n\nconst ASN1_OBJECT *NAMING_AUTHORITY_get0_authorityId(\n    const NAMING_AUTHORITY *n);\nconst ASN1_IA5STRING *NAMING_AUTHORITY_get0_authorityURL(\n    const NAMING_AUTHORITY *n);\nconst ASN1_STRING *NAMING_AUTHORITY_get0_authorityText(\n    const NAMING_AUTHORITY *n);\nvoid NAMING_AUTHORITY_set0_authorityId(NAMING_AUTHORITY *n,\n    ASN1_OBJECT* namingAuthorityId);\nvoid NAMING_AUTHORITY_set0_authorityURL(NAMING_AUTHORITY *n,\n    ASN1_IA5STRING* namingAuthorityUrl);\nvoid NAMING_AUTHORITY_set0_authorityText(NAMING_AUTHORITY *n,\n    ASN1_STRING* namingAuthorityText);\n\nconst GENERAL_NAME *ADMISSION_SYNTAX_get0_admissionAuthority(\n    const ADMISSION_SYNTAX *as);\nvoid ADMISSION_SYNTAX_set0_admissionAuthority(\n    ADMISSION_SYNTAX *as, GENERAL_NAME *aa);\nconst STACK_OF(ADMISSIONS) *ADMISSION_SYNTAX_get0_contentsOfAdmissions(\n    const ADMISSION_SYNTAX *as);\nvoid ADMISSION_SYNTAX_set0_contentsOfAdmissions(\n    ADMISSION_SYNTAX *as, STACK_OF(ADMISSIONS) *a);\nconst GENERAL_NAME *ADMISSIONS_get0_admissionAuthority(const ADMISSIONS *a);\nvoid ADMISSIONS_set0_admissionAuthority(ADMISSIONS *a, GENERAL_NAME *aa);\nconst NAMING_AUTHORITY *ADMISSIONS_get0_namingAuthority(const ADMISSIONS *a);\nvoid ADMISSIONS_set0_namingAuthority(ADMISSIONS *a, NAMING_AUTHORITY *na);\nconst PROFESSION_INFOS *ADMISSIONS_get0_professionInfos(const ADMISSIONS *a);\nvoid ADMISSIONS_set0_professionInfos(ADMISSIONS *a, PROFESSION_INFOS *pi);\nconst ASN1_OCTET_STRING *PROFESSION_INFO_get0_addProfessionInfo(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_addProfessionInfo(\n    PROFESSION_INFO *pi, ASN1_OCTET_STRING *aos);\nconst NAMING_AUTHORITY *PROFESSION_INFO_get0_namingAuthority(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_namingAuthority(\n    PROFESSION_INFO *pi, NAMING_AUTHORITY *na);\nconst STACK_OF(ASN1_STRING) *PROFESSION_INFO_get0_professionItems(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_professionItems(\n    PROFESSION_INFO *pi, STACK_OF(ASN1_STRING) *as);\nconst STACK_OF(ASN1_OBJECT) *PROFESSION_INFO_get0_professionOIDs(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_professionOIDs(\n    PROFESSION_INFO *pi, STACK_OF(ASN1_OBJECT) *po);\nconst ASN1_PRINTABLESTRING *PROFESSION_INFO_get0_registrationNumber(\n    const PROFESSION_INFO *pi);\nvoid PROFESSION_INFO_set0_registrationNumber(\n    PROFESSION_INFO *pi, ASN1_PRINTABLESTRING *rn);\n\n# ifdef  __cplusplus\n}\n# endif\n#endif\n"
  },
  {
    "path": "cryptomini/include/openssl/x509v3err.h",
    "content": "/*\n * Generated by util/mkerr.pl DO NOT EDIT\n * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#ifndef HEADER_X509V3ERR_H\n# define HEADER_X509V3ERR_H\n\n# ifndef HEADER_SYMHACKS_H\n#  include <openssl/symhacks.h>\n# endif\n\n# ifdef  __cplusplus\nextern \"C\"\n# endif\nint ERR_load_X509V3_strings(void);\n\n/*\n * X509V3 function codes.\n */\n# define X509V3_F_A2I_GENERAL_NAME                        164\n# define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL             166\n# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE             161\n# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL         162\n# define X509V3_F_BIGNUM_TO_STRING                        167\n# define X509V3_F_COPY_EMAIL                              122\n# define X509V3_F_COPY_ISSUER                             123\n# define X509V3_F_DO_DIRNAME                              144\n# define X509V3_F_DO_EXT_I2D                              135\n# define X509V3_F_DO_EXT_NCONF                            151\n# define X509V3_F_GNAMES_FROM_SECTNAME                    156\n# define X509V3_F_I2S_ASN1_ENUMERATED                     121\n# define X509V3_F_I2S_ASN1_IA5STRING                      149\n# define X509V3_F_I2S_ASN1_INTEGER                        120\n# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS               138\n# define X509V3_F_I2V_AUTHORITY_KEYID                     173\n# define X509V3_F_LEVEL_ADD_NODE                          168\n# define X509V3_F_NOTICE_SECTION                          132\n# define X509V3_F_NREF_NOS                                133\n# define X509V3_F_POLICY_CACHE_CREATE                     169\n# define X509V3_F_POLICY_CACHE_NEW                        170\n# define X509V3_F_POLICY_DATA_NEW                         171\n# define X509V3_F_POLICY_SECTION                          131\n# define X509V3_F_PROCESS_PCI_VALUE                       150\n# define X509V3_F_R2I_CERTPOL                             130\n# define X509V3_F_R2I_PCI                                 155\n# define X509V3_F_S2I_ASN1_IA5STRING                      100\n# define X509V3_F_S2I_ASN1_INTEGER                        108\n# define X509V3_F_S2I_ASN1_OCTET_STRING                   112\n# define X509V3_F_S2I_SKEY_ID                             115\n# define X509V3_F_SET_DIST_POINT_NAME                     158\n# define X509V3_F_SXNET_ADD_ID_ASC                        125\n# define X509V3_F_SXNET_ADD_ID_INTEGER                    126\n# define X509V3_F_SXNET_ADD_ID_ULONG                      127\n# define X509V3_F_SXNET_GET_ID_ASC                        128\n# define X509V3_F_SXNET_GET_ID_ULONG                      129\n# define X509V3_F_TREE_INIT                               172\n# define X509V3_F_V2I_ASIDENTIFIERS                       163\n# define X509V3_F_V2I_ASN1_BIT_STRING                     101\n# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS               139\n# define X509V3_F_V2I_AUTHORITY_KEYID                     119\n# define X509V3_F_V2I_BASIC_CONSTRAINTS                   102\n# define X509V3_F_V2I_CRLD                                134\n# define X509V3_F_V2I_EXTENDED_KEY_USAGE                  103\n# define X509V3_F_V2I_GENERAL_NAMES                       118\n# define X509V3_F_V2I_GENERAL_NAME_EX                     117\n# define X509V3_F_V2I_IDP                                 157\n# define X509V3_F_V2I_IPADDRBLOCKS                        159\n# define X509V3_F_V2I_ISSUER_ALT                          153\n# define X509V3_F_V2I_NAME_CONSTRAINTS                    147\n# define X509V3_F_V2I_POLICY_CONSTRAINTS                  146\n# define X509V3_F_V2I_POLICY_MAPPINGS                     145\n# define X509V3_F_V2I_SUBJECT_ALT                         154\n# define X509V3_F_V2I_TLS_FEATURE                         165\n# define X509V3_F_V3_GENERIC_EXTENSION                    116\n# define X509V3_F_X509V3_ADD1_I2D                         140\n# define X509V3_F_X509V3_ADD_LEN_VALUE                    174\n# define X509V3_F_X509V3_ADD_VALUE                        105\n# define X509V3_F_X509V3_EXT_ADD                          104\n# define X509V3_F_X509V3_EXT_ADD_ALIAS                    106\n# define X509V3_F_X509V3_EXT_I2D                          136\n# define X509V3_F_X509V3_EXT_NCONF                        152\n# define X509V3_F_X509V3_GET_SECTION                      142\n# define X509V3_F_X509V3_GET_STRING                       143\n# define X509V3_F_X509V3_GET_VALUE_BOOL                   110\n# define X509V3_F_X509V3_PARSE_LIST                       109\n# define X509V3_F_X509_PURPOSE_ADD                        137\n# define X509V3_F_X509_PURPOSE_SET                        141\n\n/*\n * X509V3 reason codes.\n */\n# define X509V3_R_BAD_IP_ADDRESS                          118\n# define X509V3_R_BAD_OBJECT                              119\n# define X509V3_R_BN_DEC2BN_ERROR                         100\n# define X509V3_R_BN_TO_ASN1_INTEGER_ERROR                101\n# define X509V3_R_DIRNAME_ERROR                           149\n# define X509V3_R_DISTPOINT_ALREADY_SET                   160\n# define X509V3_R_DUPLICATE_ZONE_ID                       133\n# define X509V3_R_ERROR_CONVERTING_ZONE                   131\n# define X509V3_R_ERROR_CREATING_EXTENSION                144\n# define X509V3_R_ERROR_IN_EXTENSION                      128\n# define X509V3_R_EXPECTED_A_SECTION_NAME                 137\n# define X509V3_R_EXTENSION_EXISTS                        145\n# define X509V3_R_EXTENSION_NAME_ERROR                    115\n# define X509V3_R_EXTENSION_NOT_FOUND                     102\n# define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED         103\n# define X509V3_R_EXTENSION_VALUE_ERROR                   116\n# define X509V3_R_ILLEGAL_EMPTY_EXTENSION                 151\n# define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG             152\n# define X509V3_R_INVALID_ASNUMBER                        162\n# define X509V3_R_INVALID_ASRANGE                         163\n# define X509V3_R_INVALID_BOOLEAN_STRING                  104\n# define X509V3_R_INVALID_EXTENSION_STRING                105\n# define X509V3_R_INVALID_INHERITANCE                     165\n# define X509V3_R_INVALID_IPADDRESS                       166\n# define X509V3_R_INVALID_MULTIPLE_RDNS                   161\n# define X509V3_R_INVALID_NAME                            106\n# define X509V3_R_INVALID_NULL_ARGUMENT                   107\n# define X509V3_R_INVALID_NULL_NAME                       108\n# define X509V3_R_INVALID_NULL_VALUE                      109\n# define X509V3_R_INVALID_NUMBER                          140\n# define X509V3_R_INVALID_NUMBERS                         141\n# define X509V3_R_INVALID_OBJECT_IDENTIFIER               110\n# define X509V3_R_INVALID_OPTION                          138\n# define X509V3_R_INVALID_POLICY_IDENTIFIER               134\n# define X509V3_R_INVALID_PROXY_POLICY_SETTING            153\n# define X509V3_R_INVALID_PURPOSE                         146\n# define X509V3_R_INVALID_SAFI                            164\n# define X509V3_R_INVALID_SECTION                         135\n# define X509V3_R_INVALID_SYNTAX                          143\n# define X509V3_R_ISSUER_DECODE_ERROR                     126\n# define X509V3_R_MISSING_VALUE                           124\n# define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS           142\n# define X509V3_R_NO_CONFIG_DATABASE                      136\n# define X509V3_R_NO_ISSUER_CERTIFICATE                   121\n# define X509V3_R_NO_ISSUER_DETAILS                       127\n# define X509V3_R_NO_POLICY_IDENTIFIER                    139\n# define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED   154\n# define X509V3_R_NO_PUBLIC_KEY                           114\n# define X509V3_R_NO_SUBJECT_DETAILS                      125\n# define X509V3_R_OPERATION_NOT_DEFINED                   148\n# define X509V3_R_OTHERNAME_ERROR                         147\n# define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED         155\n# define X509V3_R_POLICY_PATH_LENGTH                      156\n# define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED      157\n# define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159\n# define X509V3_R_SECTION_NOT_FOUND                       150\n# define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS            122\n# define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID              123\n# define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT             111\n# define X509V3_R_UNKNOWN_EXTENSION                       129\n# define X509V3_R_UNKNOWN_EXTENSION_NAME                  130\n# define X509V3_R_UNKNOWN_OPTION                          120\n# define X509V3_R_UNSUPPORTED_OPTION                      117\n# define X509V3_R_UNSUPPORTED_TYPE                        167\n# define X509V3_R_USER_TOO_LONG                           132\n\n#endif\n"
  },
  {
    "path": "cryptomini/intercept/err.c",
    "content": "\n\nvoid ERR_put_error(int lib, int func, int reason, const char *file, int line) {\n\t\n\n}\n\nint ERR_set_mark(void) {\n    return 1;\n}\n\nint ERR_pop_to_mark(void) {\n    return 1;\n}\n"
  },
  {
    "path": "cryptomini/intercept/intercept.c",
    "content": "\n#include <stdio.h>\n#include <stddef.h>\n\n\n// void *malloc(size_t size);\n// void free(void *ptr);\n\n// void *sbi_malloc(size_t size);\n// void sbi_free(void *ptr);\n\n// void *sbi_memset(void *s, int c, size_t count);\n\n\n// void *malloc(size_t size)\n// {\n//     return sbi_malloc(size);\n// }\n\n// void free(void *ptr)\n// {\n//     sbi_free(ptr);\n// }\n\n\n// void *memset(void *s, int c, size_t count)\n// {\n//     return sbi_memset(s, c, count);\n// }"
  },
  {
    "path": "cryptomini/intercept/rand.c",
    "content": "\n#include <stddef.h>\n#include <stdio.h>\n#include <stdint.h>\n// #include <openssl/types.h>\n// #include <openssl/evp.h>\n\ninline uint64_t rdtsc()\n{\n   uint32_t hi, lo;\n   __asm__ __volatile__ (\"rdtsc\" : \"=a\"(lo), \"=d\"(hi));\n   return ( (uint64_t)lo)|( ((uint64_t)hi)<<32 );\n}\n\nuint64_t platform_random(){\n  #pragma message(\"Platform has no entropy source, this is unsafe. TEST ONLY\")\n  static uint64_t w = 0, s = 0xb5ad4eceda1ce2a9;\n\n  unsigned long cycles;\n  #ifdef RISC_V\n    asm volatile (\"rdcycle %0\" : \"=r\" (cycles));\n  #else\n    cycles = rdtsc();\n  #endif\n  \n\n  // from Middle Square Weyl Sequence algorithm\n  uint64_t x = cycles;\n  x *= x;\n  x += (w += s);\n  return (x>>32) | (x<<32);\n}\n\nvoid *crypto_memcpy(void *dest, const void *src, size_t count)\n{\n\tchar *temp1\t  = dest;\n\tconst char *temp2 = src;\n\n\twhile (count > 0) {\n\t\t*temp1++ = *temp2++;\n\t\tcount--;\n\t}\n\treturn dest;\n}\n\n\n\n// uint64_t rand64() {\n//   static uint64_t w = 0, s = 0xb5ad4eceda1ce2a9;\n\n//   uint64_t cycles = rdtsc();\n\n//   // from Middle Square Weyl Sequence algorithm\n//   uint64_t x = cycles;\n//   x *= x;\n//   x += (w += s);\n//   uint64_t rnd = (x>>32) | (x<<32);\n// //   printf(\"\\n0x%lx\\n\", rnd);\n// //   return rnd;\n//   return (x>>32) | (x<<32);\n// }\n\nint RAND_bytes(unsigned char *buf, int num)\n{\n    unsigned char *temp = buf;\n    while (num-8 >= 0){\n        *(uint64_t*)temp = platform_random();\n        temp+=8;\n        num -= 8;\n    }\n    if (num > 0)\n    {\n        uint64_t rand = platform_random();\n        crypto_memcpy(temp, &rand, num);\n    }\n    return 1;\n}\n\n\nint RAND_priv_bytes(unsigned char *buf, int num)\n{\n    return RAND_bytes(buf, num);\n}\n// int main() {\n//     unsigned char array[100];\n//     for (size_t i = 0; i < 100; i++)\n//     {\n//         array[i] = 0;\n//     }\n    \n//     RAND_bytes(array, 39);\n//     for (size_t i = 0; i < 50; i++)\n//     {\n//         printf(\"%x \", array[i]);\n//     }\n\n// }\n"
  },
  {
    "path": "cryptomini/makefile",
    "content": "#CC = /usr/bin/gcc\n#CC = /usr/bin/riscv64-linux-gnu-gcc\n\nCC = /opt/riscv/bin/riscv64-unknown-linux-gnu-gcc\nAR = /opt/riscv/bin/riscv64-unknown-linux-gnu-ar\n\n# CC = /opt/riscv/bin/riscv64-unknown-elf-gcc\n# AR = /opt/riscv/bin/riscv64-unknown-elf-ar\n\n#CC = riscv64-linux-gnu-gcc\n#AR = riscv64-linux-gnu-ar\n\nCCFLAGS = -c -ffunction-sections -fdata-sections \\\n\t-Wall -Werror -ffreestanding -fno-stack-protector -fno-strict-aliasing \\\n\t-O3 -g0 -fno-omit-frame-pointer -fno-optimize-sibling-calls\t\\\n\t-mstrict-align -mno-save-restore -mabi=lp64\t-march=rv64imafdc_zicsr_zifencei -mcmodel=medany \\\n\t-fno-pie -no-pie\t\\\n\t-mabi=lp64d\t\t\t\\\n\t-DRISC_V -DNDEBUG\t\t\\\n\t-DOPENSSL_NO_STDIO\t\t\\\n\t-I. -Iinclude\t\n\n# -nostdlib \\\n# -I. -Iinclude\t\\\n# -lc -lgloss -lgcc -Wl,--start-group -lc -lgloss -Wl,--end-group -lgcc\n\n# LNFLAGS = -static -Wl,-gc-sections\n\n\n\nSRC_DIR     := .\nSUB_SRC_DIR_AES := ./aes\nSUB_SRC_DIR_BN := ./bn\nSUB_SRC_DIR_CAMELLIA := ./camellia\nSUB_SRC_DIR_EC := ./ec\nSUB_SRC_DIR_SHA := ./sha\nSUB_SRC_DIR_INTERCEPT := ./intercept\n\nBUILD_DIR   := ./build\n\nSRCS    := $(wildcard $(SRC_DIR)/*.c $(SUB_SRC_DIR)/*.c)\nOBJS    += $(addprefix $(BUILD_DIR)/,$(patsubst %.c,%.o,$(notdir \\\n\t\t\t$(wildcard $(SRC_DIR)/*.c $(SUB_SRC_DIR_AES)/*.c $(SUB_SRC_DIR_BN)/*.c  \\\n\t\t\t$(SUB_SRC_DIR_EC)/*.c $(SUB_SRC_DIR_SHA)/*.c $(SUB_SRC_DIR_INTERCEPT)/*.c $(SUB_SRC_DIR_CAMELLIA)/*.c))))\n\nlibcryptomini.a: $(OBJS)\n\t$(AR) crs $@ $^\n\n$(BUILD_DIR)/%.o:$(SRC_DIR)/%.c\n\t$(CC) $(CCFLAGS) -o $@ $^\n\n$(BUILD_DIR)/%.o:$(SUB_SRC_DIR_AES)/%.c\n\t$(CC) $(CCFLAGS) -o $@ $^\n\n$(BUILD_DIR)/%.o:$(SUB_SRC_DIR_BN)/%.c\n\t$(CC) $(CCFLAGS) -o $@ $^\n\n$(BUILD_DIR)/%.o:$(SUB_SRC_DIR_EC)/%.c\n\t$(CC) $(CCFLAGS) -o $@ $^\n\n$(BUILD_DIR)/%.o:$(SUB_SRC_DIR_SHA)/%.c\n\t$(CC) $(CCFLAGS) -o $@ $^\n\n$(BUILD_DIR)/%.o:$(SUB_SRC_DIR_INTERCEPT)/%.c\n\t$(CC) $(CCFLAGS) -o $@ $^\n\n$(BUILD_DIR)/%.o:$(SUB_SRC_DIR_CAMELLIA)/%.c\n\t$(CC) $(CCFLAGS) -o $@ $^\n\n.PHONY: clean\nclean:\n\trm -f libcryptomini.a $(OBJS)\n"
  },
  {
    "path": "cryptomini/mem.c",
    "content": "/*\n * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include \"e_os.h\"\n#include \"internal/cryptlib.h\"\n#include \"crypto/cryptlib.h\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <limits.h>\n#include <openssl/crypto.h>\n#include \"intercept/intercept.h\"\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n# include <execinfo.h>\n#endif\n\n/*\n * the following pointers may be changed as long as 'allow_customize' is set\n */\nstatic int allow_customize = 1;\n\nstatic void *(*malloc_impl)(size_t, const char *, int)\n    = CRYPTO_malloc;\n// static void *(*realloc_impl)(void *, size_t, const char *, int)\n//     = CRYPTO_realloc;\nstatic void (*free_impl)(void *, const char *, int)\n    = CRYPTO_free;\n\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n# include \"internal/tsan_assist.h\"\n\nstatic TSAN_QUALIFIER int malloc_count;\nstatic TSAN_QUALIFIER int realloc_count;\nstatic TSAN_QUALIFIER int free_count;\n\n# define INCREMENT(x) tsan_counter(&(x))\n\nstatic char *md_failstring;\nstatic long md_count;\nstatic int md_fail_percent = 0;\nstatic int md_tracefd = -1;\nstatic int call_malloc_debug = 1;\n\nstatic void parseit(void);\nstatic int shouldfail(void);\n\n# define FAILTEST() if (shouldfail()) return NULL\n\n#else\nstatic int call_malloc_debug = 0;\n\n# define INCREMENT(x) /* empty */\n# define FAILTEST() /* empty */\n#endif\n\nint CRYPTO_set_mem_functions(\n        void *(*m)(size_t, const char *, int),\n        void *(*r)(void *, size_t, const char *, int),\n        void (*f)(void *, const char *, int))\n{\n    if (!allow_customize)\n        return 0;\n    if (m)\n        malloc_impl = m;\n    // if (r)\n    //     realloc_impl = r;\n    if (f)\n        free_impl = f;\n    return 1;\n}\n\nint CRYPTO_set_mem_debug(int flag)\n{\n    if (!allow_customize)\n        return 0;\n    call_malloc_debug = flag;\n    return 1;\n}\n\nvoid CRYPTO_get_mem_functions(\n        void *(**m)(size_t, const char *, int),\n        void *(**r)(void *, size_t, const char *, int),\n        void (**f)(void *, const char *, int))\n{\n    if (m != NULL)\n        *m = malloc_impl;\n    // if (r != NULL)\n    //     *r = realloc_impl;\n    if (f != NULL)\n        *f = free_impl;\n}\n\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\nvoid CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount)\n{\n    if (mcount != NULL)\n        *mcount = tsan_load(&malloc_count);\n    if (rcount != NULL)\n        *rcount = tsan_load(&realloc_count);\n    if (fcount != NULL)\n        *fcount = tsan_load(&free_count);\n}\n\n/*\n * Parse a \"malloc failure spec\" string.  This likes like a set of fields\n * separated by semicolons.  Each field has a count and an optional failure\n * percentage.  For example:\n *          100@0;100@25;0@0\n *    or    100;100@25;0\n * This means 100 mallocs succeed, then next 100 fail 25% of the time, and\n * all remaining (count is zero) succeed.\n */\nstatic void parseit(void)\n{\n    char *semi = strchr(md_failstring, ';');\n    char *atsign;\n\n    if (semi != NULL)\n        *semi++ = '\\0';\n\n    /* Get the count (atol will stop at the @ if there), and percentage */\n    md_count = atol(md_failstring);\n    atsign = strchr(md_failstring, '@');\n    md_fail_percent = atsign == NULL ? 0 : atoi(atsign + 1);\n\n    if (semi != NULL)\n        md_failstring = semi;\n}\n\n/*\n * Windows doesn't have random(), but it has rand()\n * Some rand() implementations aren't good, but we're not\n * dealing with secure randomness here.\n */\n# ifdef _WIN32\n#  define random() rand()\n# endif\n/*\n * See if the current malloc should fail.\n */\nstatic int shouldfail(void)\n{\n    int roll = (int)(random() % 100);\n    int shoulditfail = roll < md_fail_percent;\n# ifndef _WIN32\n/* suppressed on Windows as POSIX-like file descriptors are non-inheritable */\n    int len;\n    char buff[80];\n\n    if (md_tracefd > 0) {\n        BIO_snprintf(buff, sizeof(buff),\n                     \"%c C%ld %%%d R%d\\n\",\n                     shoulditfail ? '-' : '+', md_count, md_fail_percent, roll);\n        len = strlen(buff);\n        if (write(md_tracefd, buff, len) != len)\n            perror(\"shouldfail write failed\");\n#  ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE\n        if (shoulditfail) {\n            void *addrs[30];\n            int num = backtrace(addrs, OSSL_NELEM(addrs));\n\n            backtrace_symbols_fd(addrs, num, md_tracefd);\n        }\n#  endif\n    }\n# endif\n\n    if (md_count) {\n        /* If we used up this one, go to the next. */\n        if (--md_count == 0)\n            parseit();\n    }\n\n    return shoulditfail;\n}\n\nvoid ossl_malloc_setup_failures(void)\n{\n    const char *cp = getenv(\"OPENSSL_MALLOC_FAILURES\");\n\n    if (cp != NULL && (md_failstring = strdup(cp)) != NULL)\n        parseit();\n    if ((cp = getenv(\"OPENSSL_MALLOC_FD\")) != NULL)\n        md_tracefd = atoi(cp);\n}\n#endif\n\nvoid *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n\n    if (num == 0)\n        return NULL;\n\n    FAILTEST();\n    if (allow_customize) {\n        /*\n         * Disallow customization after the first allocation. We only set this\n         * if necessary to avoid a store to the same cache line on every\n         * allocation.\n         */\n        allow_customize = 0;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n\n    return ret;\n}\n\nvoid *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}\n\n// void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)\n// {\n//     INCREMENT(realloc_count);\n//     if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)\n//         return realloc_impl(str, num, file, line);\n\n//     FAILTEST();\n//     if (str == NULL)\n//         return CRYPTO_malloc(num, file, line);\n\n//     if (num == 0) {\n//         CRYPTO_free(str, file, line);\n//         return NULL;\n//     }\n\n// #ifndef OPENSSL_NO_CRYPTO_MDEBUG\n//     if (call_malloc_debug) {\n//         void *ret;\n//         CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);\n//         ret = realloc(str, num);\n//         CRYPTO_mem_debug_realloc(str, ret, num, 1, file, line);\n//         return ret;\n//     }\n// #else\n//     (void)(file); (void)(line);\n// #endif\n//     return realloc(str, num);\n\n// }\n\nvoid *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num,\n                           const char *file, int line)\n{\n    void *ret = NULL;\n\n    if (str == NULL)\n        return CRYPTO_malloc(num, file, line);\n\n    if (num == 0) {\n        CRYPTO_clear_free(str, old_len, file, line);\n        return NULL;\n    }\n\n    /* Can't shrink the buffer since memcpy below copies |old_len| bytes. */\n    if (num < old_len) {\n        OPENSSL_cleanse((char*)str + num, old_len - num);\n        return str;\n    }\n\n    ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL) {\n        memcpy(ret, str, old_len);\n        CRYPTO_clear_free(str, old_len, file, line);\n    }\n    return ret;\n}\n\nvoid CRYPTO_free(void *str, const char *file, int line)\n{\n    INCREMENT(free_count);\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}\n\nvoid CRYPTO_clear_free(void *str, size_t num, const char *file, int line)\n{\n    if (str == NULL)\n        return;\n    if (num)\n        OPENSSL_cleanse(str, num);\n    CRYPTO_free(str, file, line);\n}\n"
  },
  {
    "path": "cryptomini/mem_clr.c",
    "content": "/*\n * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <string.h>\n#include <openssl/crypto.h>\n\n/*\n * Pointer to memset is volatile so that compiler must de-reference\n * the pointer and can't assume that it points to any function in\n * particular (such as memset, which it then might further \"optimize\")\n */\ntypedef void *(*memset_t)(void *, int, size_t);\n\nstatic volatile memset_t memset_func = memset;\n\nvoid OPENSSL_cleanse(void *ptr, size_t len)\n{\n    memset_func(ptr, 0, len);\n}\n\n// void *sbi_memset(void *s, int c, size_t count);\n// void OPENSSL_cleanse(void *ptr, size_t len)\n// {\n//     sbi_memset(ptr, 0, len);\n// }\n\n"
  },
  {
    "path": "cryptomini/mem_sec.c",
    "content": "/*\n * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.\n * Copyright 2004-2014, Akamai Technologies. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n/*\n * This file is in two halves. The first half implements the public API\n * to be used by external consumers, and to be used by OpenSSL to store\n * data in a \"secure arena.\" The second half implements the secure arena.\n * For details on that implementation, see below (look for uppercase\n * \"SECURE HEAP IMPLEMENTATION\").\n */\n#include \"e_os.h\"\n#include <openssl/crypto.h>\n\n#include <string.h>\n\n/* e_os.h defines OPENSSL_SECURE_MEMORY if secure memory can be implemented */\n#undef OPENSSL_SECURE_MEMORY\n#ifdef OPENSSL_SECURE_MEMORY\n# include <stdlib.h>\n# include <assert.h>\n# include <unistd.h>\n# include <sys/types.h>\n# include <sys/mman.h>\n# if defined(OPENSSL_SYS_LINUX)\n#  include <sys/syscall.h>\n#  if defined(SYS_mlock2)\n#   include <linux/mman.h>\n#   include <errno.h>\n#  endif\n# endif\n# if defined(__FreeBSD__)\n#  define MADV_DONTDUMP MADV_NOCORE\n# endif\n# if !defined(MAP_CONCEAL)\n#  define MAP_CONCEAL 0\n# endif\n# include <sys/param.h>\n# include <sys/stat.h>\n# include <fcntl.h>\n#endif\n\n#define CLEAR(p, s) OPENSSL_cleanse(p, s)\n#ifndef PAGE_SIZE\n# define PAGE_SIZE    4096\n#endif\n#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)\n# define MAP_ANON MAP_ANONYMOUS\n#endif\n\n#ifdef OPENSSL_SECURE_MEMORY\nstatic size_t secure_mem_used;\n\nstatic int secure_mem_initialized;\n\nstatic CRYPTO_RWLOCK *sec_malloc_lock = NULL;\n\n/*\n * These are the functions that must be implemented by a secure heap (sh).\n */\nstatic int sh_init(size_t size, int minsize);\nstatic void *sh_malloc(size_t size);\nstatic void sh_free(void *ptr);\nstatic void sh_done(void);\nstatic size_t sh_actual_size(char *ptr);\nstatic int sh_allocated(const char *ptr);\n#endif\n\nint CRYPTO_secure_malloc_init(size_t size, int minsize)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    int ret = 0;\n\n    if (!secure_mem_initialized) {\n        sec_malloc_lock = CRYPTO_THREAD_lock_new();\n        if (sec_malloc_lock == NULL)\n            return 0;\n        if ((ret = sh_init(size, minsize)) != 0) {\n            secure_mem_initialized = 1;\n        } else {\n            CRYPTO_THREAD_lock_free(sec_malloc_lock);\n            sec_malloc_lock = NULL;\n        }\n    }\n\n    return ret;\n#else\n    return 0;\n#endif /* OPENSSL_SECURE_MEMORY */\n}\n\nint CRYPTO_secure_malloc_done(void)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    if (secure_mem_used == 0) {\n        sh_done();\n        secure_mem_initialized = 0;\n        CRYPTO_THREAD_lock_free(sec_malloc_lock);\n        sec_malloc_lock = NULL;\n        return 1;\n    }\n#endif /* OPENSSL_SECURE_MEMORY */\n    return 0;\n}\n\nint CRYPTO_secure_malloc_initialized(void)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    return secure_mem_initialized;\n#else\n    return 0;\n#endif /* OPENSSL_SECURE_MEMORY */\n}\n\nvoid *CRYPTO_secure_malloc(size_t num, const char *file, int line)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    void *ret;\n    size_t actual_size;\n\n    if (!secure_mem_initialized) {\n        return CRYPTO_malloc(num, file, line);\n    }\n    CRYPTO_THREAD_write_lock(sec_malloc_lock);\n    ret = sh_malloc(num);\n    actual_size = ret ? sh_actual_size(ret) : 0;\n    secure_mem_used += actual_size;\n    CRYPTO_THREAD_unlock(sec_malloc_lock);\n    return ret;\n#else\n    return CRYPTO_malloc(num, file, line);\n#endif /* OPENSSL_SECURE_MEMORY */\n}\n\nvoid *CRYPTO_secure_zalloc(size_t num, const char *file, int line)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    if (secure_mem_initialized)\n        /* CRYPTO_secure_malloc() zeroes allocations when it is implemented */\n        return CRYPTO_secure_malloc(num, file, line);\n#endif\n    return CRYPTO_zalloc(num, file, line);\n}\n\nvoid CRYPTO_secure_free(void *ptr, const char *file, int line)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    size_t actual_size;\n\n    if (ptr == NULL)\n        return;\n    if (!CRYPTO_secure_allocated(ptr)) {\n        CRYPTO_free(ptr, file, line);\n        return;\n    }\n    CRYPTO_THREAD_write_lock(sec_malloc_lock);\n    actual_size = sh_actual_size(ptr);\n    CLEAR(ptr, actual_size);\n    secure_mem_used -= actual_size;\n    sh_free(ptr);\n    CRYPTO_THREAD_unlock(sec_malloc_lock);\n#else\n    CRYPTO_free(ptr, file, line);\n#endif /* OPENSSL_SECURE_MEMORY */\n}\n\nvoid CRYPTO_secure_clear_free(void *ptr, size_t num,\n                              const char *file, int line)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    size_t actual_size;\n\n    if (ptr == NULL)\n        return;\n    if (!CRYPTO_secure_allocated(ptr)) {\n        OPENSSL_cleanse(ptr, num);\n        CRYPTO_free(ptr, file, line);\n        return;\n    }\n    CRYPTO_THREAD_write_lock(sec_malloc_lock);\n    actual_size = sh_actual_size(ptr);\n    CLEAR(ptr, actual_size);\n    secure_mem_used -= actual_size;\n    sh_free(ptr);\n    CRYPTO_THREAD_unlock(sec_malloc_lock);\n#else\n    if (ptr == NULL)\n        return;\n    OPENSSL_cleanse(ptr, num);\n    CRYPTO_free(ptr, file, line);\n#endif /* OPENSSL_SECURE_MEMORY */\n}\n\nint CRYPTO_secure_allocated(const void *ptr)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    int ret;\n\n    if (!secure_mem_initialized)\n        return 0;\n    CRYPTO_THREAD_write_lock(sec_malloc_lock);\n    ret = sh_allocated(ptr);\n    CRYPTO_THREAD_unlock(sec_malloc_lock);\n    return ret;\n#else\n    return 0;\n#endif /* OPENSSL_SECURE_MEMORY */\n}\n\nsize_t CRYPTO_secure_used(void)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    return secure_mem_used;\n#else\n    return 0;\n#endif /* OPENSSL_SECURE_MEMORY */\n}\n\nsize_t CRYPTO_secure_actual_size(void *ptr)\n{\n#ifdef OPENSSL_SECURE_MEMORY\n    size_t actual_size;\n\n    CRYPTO_THREAD_write_lock(sec_malloc_lock);\n    actual_size = sh_actual_size(ptr);\n    CRYPTO_THREAD_unlock(sec_malloc_lock);\n    return actual_size;\n#else\n    return 0;\n#endif\n}\n/* END OF PAGE ...\n\n   ... START OF PAGE */\n\n/*\n * SECURE HEAP IMPLEMENTATION\n */\n#ifdef OPENSSL_SECURE_MEMORY\n\n\n/*\n * The implementation provided here uses a fixed-sized mmap() heap,\n * which is locked into memory, not written to core files, and protected\n * on either side by an unmapped page, which will catch pointer overruns\n * (or underruns) and an attempt to read data out of the secure heap.\n * Free'd memory is zero'd or otherwise cleansed.\n *\n * This is a pretty standard buddy allocator.  We keep areas in a multiple\n * of \"sh.minsize\" units.  The freelist and bitmaps are kept separately,\n * so all (and only) data is kept in the mmap'd heap.\n *\n * This code assumes eight-bit bytes.  The numbers 3 and 7 are all over the\n * place.\n */\n\n#define ONE ((size_t)1)\n\n# define TESTBIT(t, b)  (t[(b) >> 3] &  (ONE << ((b) & 7)))\n# define SETBIT(t, b)   (t[(b) >> 3] |= (ONE << ((b) & 7)))\n# define CLEARBIT(t, b) (t[(b) >> 3] &= (0xFF & ~(ONE << ((b) & 7))))\n\n#define WITHIN_ARENA(p) \\\n    ((char*)(p) >= sh.arena && (char*)(p) < &sh.arena[sh.arena_size])\n#define WITHIN_FREELIST(p) \\\n    ((char*)(p) >= (char*)sh.freelist && (char*)(p) < (char*)&sh.freelist[sh.freelist_size])\n\n\ntypedef struct sh_list_st\n{\n    struct sh_list_st *next;\n    struct sh_list_st **p_next;\n} SH_LIST;\n\ntypedef struct sh_st\n{\n    char* map_result;\n    size_t map_size;\n    char *arena;\n    size_t arena_size;\n    char **freelist;\n    ossl_ssize_t freelist_size;\n    size_t minsize;\n    unsigned char *bittable;\n    unsigned char *bitmalloc;\n    size_t bittable_size; /* size in bits */\n} SH;\n\nstatic SH sh;\n\nstatic size_t sh_getlist(char *ptr)\n{\n    ossl_ssize_t list = sh.freelist_size - 1;\n    size_t bit = (sh.arena_size + ptr - sh.arena) / sh.minsize;\n\n    for (; bit; bit >>= 1, list--) {\n        if (TESTBIT(sh.bittable, bit))\n            break;\n        OPENSSL_assert((bit & 1) == 0);\n    }\n\n    return list;\n}\n\n\nstatic int sh_testbit(char *ptr, int list, unsigned char *table)\n{\n    size_t bit;\n\n    OPENSSL_assert(list >= 0 && list < sh.freelist_size);\n    OPENSSL_assert(((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0);\n    bit = (ONE << list) + ((ptr - sh.arena) / (sh.arena_size >> list));\n    OPENSSL_assert(bit > 0 && bit < sh.bittable_size);\n    return TESTBIT(table, bit);\n}\n\nstatic void sh_clearbit(char *ptr, int list, unsigned char *table)\n{\n    size_t bit;\n\n    OPENSSL_assert(list >= 0 && list < sh.freelist_size);\n    OPENSSL_assert(((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0);\n    bit = (ONE << list) + ((ptr - sh.arena) / (sh.arena_size >> list));\n    OPENSSL_assert(bit > 0 && bit < sh.bittable_size);\n    OPENSSL_assert(TESTBIT(table, bit));\n    CLEARBIT(table, bit);\n}\n\nstatic void sh_setbit(char *ptr, int list, unsigned char *table)\n{\n    size_t bit;\n\n    OPENSSL_assert(list >= 0 && list < sh.freelist_size);\n    OPENSSL_assert(((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0);\n    bit = (ONE << list) + ((ptr - sh.arena) / (sh.arena_size >> list));\n    OPENSSL_assert(bit > 0 && bit < sh.bittable_size);\n    OPENSSL_assert(!TESTBIT(table, bit));\n    SETBIT(table, bit);\n}\n\nstatic void sh_add_to_list(char **list, char *ptr)\n{\n    SH_LIST *temp;\n\n    OPENSSL_assert(WITHIN_FREELIST(list));\n    OPENSSL_assert(WITHIN_ARENA(ptr));\n\n    temp = (SH_LIST *)ptr;\n    temp->next = *(SH_LIST **)list;\n    OPENSSL_assert(temp->next == NULL || WITHIN_ARENA(temp->next));\n    temp->p_next = (SH_LIST **)list;\n\n    if (temp->next != NULL) {\n        OPENSSL_assert((char **)temp->next->p_next == list);\n        temp->next->p_next = &(temp->next);\n    }\n\n    *list = ptr;\n}\n\nstatic void sh_remove_from_list(char *ptr)\n{\n    SH_LIST *temp, *temp2;\n\n    temp = (SH_LIST *)ptr;\n    if (temp->next != NULL)\n        temp->next->p_next = temp->p_next;\n    *temp->p_next = temp->next;\n    if (temp->next == NULL)\n        return;\n\n    temp2 = temp->next;\n    OPENSSL_assert(WITHIN_FREELIST(temp2->p_next) || WITHIN_ARENA(temp2->p_next));\n}\n\n\nstatic int sh_init(size_t size, int minsize)\n{\n    int ret;\n    size_t i;\n    size_t pgsize;\n    size_t aligned;\n\n    memset(&sh, 0, sizeof(sh));\n\n    /* make sure size and minsize are powers of 2 */\n    OPENSSL_assert(size > 0);\n    OPENSSL_assert((size & (size - 1)) == 0);\n    OPENSSL_assert(minsize > 0);\n    OPENSSL_assert((minsize & (minsize - 1)) == 0);\n    if (size <= 0 || (size & (size - 1)) != 0)\n        goto err;\n    if (minsize <= 0 || (minsize & (minsize - 1)) != 0)\n        goto err;\n\n    while (minsize < (int)sizeof(SH_LIST))\n        minsize *= 2;\n\n    sh.arena_size = size;\n    sh.minsize = minsize;\n    sh.bittable_size = (sh.arena_size / sh.minsize) * 2;\n\n    /* Prevent allocations of size 0 later on */\n    if (sh.bittable_size >> 3 == 0)\n        goto err;\n\n    sh.freelist_size = -1;\n    for (i = sh.bittable_size; i; i >>= 1)\n        sh.freelist_size++;\n\n    sh.freelist = OPENSSL_zalloc(sh.freelist_size * sizeof(char *));\n    OPENSSL_assert(sh.freelist != NULL);\n    if (sh.freelist == NULL)\n        goto err;\n\n    sh.bittable = OPENSSL_zalloc(sh.bittable_size >> 3);\n    OPENSSL_assert(sh.bittable != NULL);\n    if (sh.bittable == NULL)\n        goto err;\n\n    sh.bitmalloc = OPENSSL_zalloc(sh.bittable_size >> 3);\n    OPENSSL_assert(sh.bitmalloc != NULL);\n    if (sh.bitmalloc == NULL)\n        goto err;\n\n    /* Allocate space for heap, and two extra pages as guards */\n#if defined(_SC_PAGE_SIZE) || defined (_SC_PAGESIZE)\n    {\n# if defined(_SC_PAGE_SIZE)\n        long tmppgsize = sysconf(_SC_PAGE_SIZE);\n# else\n        long tmppgsize = sysconf(_SC_PAGESIZE);\n# endif\n        if (tmppgsize < 1)\n            pgsize = PAGE_SIZE;\n        else\n            pgsize = (size_t)tmppgsize;\n    }\n#else\n    pgsize = PAGE_SIZE;\n#endif\n    sh.map_size = pgsize + sh.arena_size + pgsize;\n    if (1) {\n#ifdef MAP_ANON\n        sh.map_result = mmap(NULL, sh.map_size,\n                             PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE|MAP_CONCEAL, -1, 0);\n    } else {\n#endif\n        int fd;\n\n        sh.map_result = MAP_FAILED;\n        if ((fd = open(\"/dev/zero\", O_RDWR)) >= 0) {\n            sh.map_result = mmap(NULL, sh.map_size,\n                                 PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);\n            close(fd);\n        }\n    }\n    if (sh.map_result == MAP_FAILED)\n        goto err;\n    sh.arena = (char *)(sh.map_result + pgsize);\n    sh_setbit(sh.arena, 0, sh.bittable);\n    sh_add_to_list(&sh.freelist[0], sh.arena);\n\n    /* Now try to add guard pages and lock into memory. */\n    ret = 1;\n\n    /* Starting guard is already aligned from mmap. */\n    if (mprotect(sh.map_result, pgsize, PROT_NONE) < 0)\n        ret = 2;\n\n    /* Ending guard page - need to round up to page boundary */\n    aligned = (pgsize + sh.arena_size + (pgsize - 1)) & ~(pgsize - 1);\n    if (mprotect(sh.map_result + aligned, pgsize, PROT_NONE) < 0)\n        ret = 2;\n\n#if defined(OPENSSL_SYS_LINUX) && defined(MLOCK_ONFAULT) && defined(SYS_mlock2)\n    if (syscall(SYS_mlock2, sh.arena, sh.arena_size, MLOCK_ONFAULT) < 0) {\n        if (errno == ENOSYS) {\n            if (mlock(sh.arena, sh.arena_size) < 0)\n                ret = 2;\n        } else {\n            ret = 2;\n        }\n    }\n#else\n    if (mlock(sh.arena, sh.arena_size) < 0)\n        ret = 2;\n#endif\n#ifdef MADV_DONTDUMP\n    if (madvise(sh.arena, sh.arena_size, MADV_DONTDUMP) < 0)\n        ret = 2;\n#endif\n\n    return ret;\n\n err:\n    sh_done();\n    return 0;\n}\n\nstatic void sh_done(void)\n{\n    OPENSSL_free(sh.freelist);\n    OPENSSL_free(sh.bittable);\n    OPENSSL_free(sh.bitmalloc);\n    if (sh.map_result != MAP_FAILED && sh.map_size)\n        munmap(sh.map_result, sh.map_size);\n    memset(&sh, 0, sizeof(sh));\n}\n\nstatic int sh_allocated(const char *ptr)\n{\n    return WITHIN_ARENA(ptr) ? 1 : 0;\n}\n\nstatic char *sh_find_my_buddy(char *ptr, int list)\n{\n    size_t bit;\n    char *chunk = NULL;\n\n    bit = (ONE << list) + (ptr - sh.arena) / (sh.arena_size >> list);\n    bit ^= 1;\n\n    if (TESTBIT(sh.bittable, bit) && !TESTBIT(sh.bitmalloc, bit))\n        chunk = sh.arena + ((bit & ((ONE << list) - 1)) * (sh.arena_size >> list));\n\n    return chunk;\n}\n\nstatic void *sh_malloc(size_t size)\n{\n    ossl_ssize_t list, slist;\n    size_t i;\n    char *chunk;\n\n    if (size > sh.arena_size)\n        return NULL;\n\n    list = sh.freelist_size - 1;\n    for (i = sh.minsize; i < size; i <<= 1)\n        list--;\n    if (list < 0)\n        return NULL;\n\n    /* try to find a larger entry to split */\n    for (slist = list; slist >= 0; slist--)\n        if (sh.freelist[slist] != NULL)\n            break;\n    if (slist < 0)\n        return NULL;\n\n    /* split larger entry */\n    while (slist != list) {\n        char *temp = sh.freelist[slist];\n\n        /* remove from bigger list */\n        OPENSSL_assert(!sh_testbit(temp, slist, sh.bitmalloc));\n        sh_clearbit(temp, slist, sh.bittable);\n        sh_remove_from_list(temp);\n        OPENSSL_assert(temp != sh.freelist[slist]);\n\n        /* done with bigger list */\n        slist++;\n\n        /* add to smaller list */\n        OPENSSL_assert(!sh_testbit(temp, slist, sh.bitmalloc));\n        sh_setbit(temp, slist, sh.bittable);\n        sh_add_to_list(&sh.freelist[slist], temp);\n        OPENSSL_assert(sh.freelist[slist] == temp);\n\n        /* split in 2 */\n        temp += sh.arena_size >> slist;\n        OPENSSL_assert(!sh_testbit(temp, slist, sh.bitmalloc));\n        sh_setbit(temp, slist, sh.bittable);\n        sh_add_to_list(&sh.freelist[slist], temp);\n        OPENSSL_assert(sh.freelist[slist] == temp);\n\n        OPENSSL_assert(temp-(sh.arena_size >> slist) == sh_find_my_buddy(temp, slist));\n    }\n\n    /* peel off memory to hand back */\n    chunk = sh.freelist[list];\n    OPENSSL_assert(sh_testbit(chunk, list, sh.bittable));\n    sh_setbit(chunk, list, sh.bitmalloc);\n    sh_remove_from_list(chunk);\n\n    OPENSSL_assert(WITHIN_ARENA(chunk));\n\n    /* zero the free list header as a precaution against information leakage */\n    memset(chunk, 0, sizeof(SH_LIST));\n\n    return chunk;\n}\n\nstatic void sh_free(void *ptr)\n{\n    size_t list;\n    void *buddy;\n\n    if (ptr == NULL)\n        return;\n    OPENSSL_assert(WITHIN_ARENA(ptr));\n    if (!WITHIN_ARENA(ptr))\n        return;\n\n    list = sh_getlist(ptr);\n    OPENSSL_assert(sh_testbit(ptr, list, sh.bittable));\n    sh_clearbit(ptr, list, sh.bitmalloc);\n    sh_add_to_list(&sh.freelist[list], ptr);\n\n    /* Try to coalesce two adjacent free areas. */\n    while ((buddy = sh_find_my_buddy(ptr, list)) != NULL) {\n        OPENSSL_assert(ptr == sh_find_my_buddy(buddy, list));\n        OPENSSL_assert(ptr != NULL);\n        OPENSSL_assert(!sh_testbit(ptr, list, sh.bitmalloc));\n        sh_clearbit(ptr, list, sh.bittable);\n        sh_remove_from_list(ptr);\n        OPENSSL_assert(!sh_testbit(ptr, list, sh.bitmalloc));\n        sh_clearbit(buddy, list, sh.bittable);\n        sh_remove_from_list(buddy);\n\n        list--;\n\n        /* Zero the higher addressed block's free list pointers */\n        memset(ptr > buddy ? ptr : buddy, 0, sizeof(SH_LIST));\n        if (ptr > buddy)\n            ptr = buddy;\n\n        OPENSSL_assert(!sh_testbit(ptr, list, sh.bitmalloc));\n        sh_setbit(ptr, list, sh.bittable);\n        sh_add_to_list(&sh.freelist[list], ptr);\n        OPENSSL_assert(sh.freelist[list] == ptr);\n    }\n}\n\nstatic size_t sh_actual_size(char *ptr)\n{\n    int list;\n\n    OPENSSL_assert(WITHIN_ARENA(ptr));\n    if (!WITHIN_ARENA(ptr))\n        return 0;\n    list = sh_getlist(ptr);\n    OPENSSL_assert(sh_testbit(ptr, list, sh.bittable));\n    return sh.arena_size / (ONE << list);\n}\n#endif /* OPENSSL_SECURE_MEMORY */\n"
  },
  {
    "path": "cryptomini/sha/sha1_one.c",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <stdio.h>\n#include <string.h>\n#include <openssl/crypto.h>\n#include <openssl/sha.h>\n\nunsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md)\n{\n    SHA_CTX c;\n    static unsigned char m[SHA_DIGEST_LENGTH];\n\n    if (md == NULL)\n        md = m;\n    if (!SHA1_Init(&c))\n        return NULL;\n    SHA1_Update(&c, d, n);\n    SHA1_Final(md, &c);\n    OPENSSL_cleanse(&c, sizeof(c));\n    return md;\n}\n"
  },
  {
    "path": "cryptomini/sha/sha1dgst.c",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/crypto.h>\n#include <openssl/opensslconf.h>\n\n# include <openssl/opensslv.h>\n\n/* The implementation is in ../md32_common.h */\n\n# include \"sha_local.h\"\n"
  },
  {
    "path": "cryptomini/sha/sha256.c",
    "content": "/*\n * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslconf.h>\n\n#include <stdlib.h>\n#include <string.h>\n\n#include <openssl/crypto.h>\n#include <openssl/sha.h>\n#include <openssl/opensslv.h>\n\nint SHA224_Init(SHA256_CTX *c)\n{\n    memset(c, 0, sizeof(*c));\n    c->h[0] = 0xc1059ed8UL;\n    c->h[1] = 0x367cd507UL;\n    c->h[2] = 0x3070dd17UL;\n    c->h[3] = 0xf70e5939UL;\n    c->h[4] = 0xffc00b31UL;\n    c->h[5] = 0x68581511UL;\n    c->h[6] = 0x64f98fa7UL;\n    c->h[7] = 0xbefa4fa4UL;\n    c->md_len = SHA224_DIGEST_LENGTH;\n    return 1;\n}\n\nint SHA256_Init(SHA256_CTX *c)\n{\n    memset(c, 0, sizeof(*c));\n    c->h[0] = 0x6a09e667UL;\n    c->h[1] = 0xbb67ae85UL;\n    c->h[2] = 0x3c6ef372UL;\n    c->h[3] = 0xa54ff53aUL;\n    c->h[4] = 0x510e527fUL;\n    c->h[5] = 0x9b05688cUL;\n    c->h[6] = 0x1f83d9abUL;\n    c->h[7] = 0x5be0cd19UL;\n    c->md_len = SHA256_DIGEST_LENGTH;\n    return 1;\n}\n\nunsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md)\n{\n    SHA256_CTX c;\n    static unsigned char m[SHA224_DIGEST_LENGTH];\n\n    if (md == NULL)\n        md = m;\n    SHA224_Init(&c);\n    SHA256_Update(&c, d, n);\n    SHA256_Final(md, &c);\n    OPENSSL_cleanse(&c, sizeof(c));\n    return md;\n}\n\nunsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md)\n{\n    SHA256_CTX c;\n    static unsigned char m[SHA256_DIGEST_LENGTH];\n\n    if (md == NULL)\n        md = m;\n    SHA256_Init(&c);\n    SHA256_Update(&c, d, n);\n    SHA256_Final(md, &c);\n    OPENSSL_cleanse(&c, sizeof(c));\n    return md;\n}\n\nint SHA224_Update(SHA256_CTX *c, const void *data, size_t len)\n{\n    return SHA256_Update(c, data, len);\n}\n\nint SHA224_Final(unsigned char *md, SHA256_CTX *c)\n{\n    return SHA256_Final(md, c);\n}\n\n#define DATA_ORDER_IS_BIG_ENDIAN\n\n#define HASH_LONG               SHA_LONG\n#define HASH_CTX                SHA256_CTX\n#define HASH_CBLOCK             SHA_CBLOCK\n\n/*\n * Note that FIPS180-2 discusses \"Truncation of the Hash Function Output.\"\n * default: case below covers for it. It's not clear however if it's\n * permitted to truncate to amount of bytes not divisible by 4. I bet not,\n * but if it is, then default: case shall be extended. For reference.\n * Idea behind separate cases for pre-defined lengths is to let the\n * compiler decide if it's appropriate to unroll small loops.\n */\n#define HASH_MAKE_STRING(c,s)   do {    \\\n        unsigned long ll;               \\\n        unsigned int  nn;               \\\n        switch ((c)->md_len)            \\\n        {   case SHA224_DIGEST_LENGTH:  \\\n                for (nn=0;nn<SHA224_DIGEST_LENGTH/4;nn++)       \\\n                {   ll=(c)->h[nn]; (void)HOST_l2c(ll,(s));   }  \\\n                break;                  \\\n            case SHA256_DIGEST_LENGTH:  \\\n                for (nn=0;nn<SHA256_DIGEST_LENGTH/4;nn++)       \\\n                {   ll=(c)->h[nn]; (void)HOST_l2c(ll,(s));   }  \\\n                break;                  \\\n            default:                    \\\n                if ((c)->md_len > SHA256_DIGEST_LENGTH) \\\n                    return 0;                           \\\n                for (nn=0;nn<(c)->md_len/4;nn++)                \\\n                {   ll=(c)->h[nn]; (void)HOST_l2c(ll,(s));   }  \\\n                break;                  \\\n        }                               \\\n        } while (0)\n\n#define HASH_UPDATE             SHA256_Update\n#define HASH_TRANSFORM          SHA256_Transform\n#define HASH_FINAL              SHA256_Final\n#define HASH_BLOCK_DATA_ORDER   sha256_block_data_order\n#ifndef SHA256_ASM\nstatic\n#endif\nvoid sha256_block_data_order(SHA256_CTX *ctx, const void *in, size_t num);\n\n#include \"crypto/md32_common.h\"\n\n#ifndef SHA256_ASM\nstatic const SHA_LONG K256[64] = {\n    0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,\n    0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,\n    0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,\n    0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,\n    0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,\n    0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,\n    0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,\n    0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,\n    0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,\n    0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,\n    0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,\n    0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,\n    0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,\n    0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,\n    0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,\n    0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL\n};\n\n/*\n * FIPS specification refers to right rotations, while our ROTATE macro\n * is left one. This is why you might notice that rotation coefficients\n * differ from those observed in FIPS document by 32-N...\n */\n# define Sigma0(x)       (ROTATE((x),30) ^ ROTATE((x),19) ^ ROTATE((x),10))\n# define Sigma1(x)       (ROTATE((x),26) ^ ROTATE((x),21) ^ ROTATE((x),7))\n# define sigma0(x)       (ROTATE((x),25) ^ ROTATE((x),14) ^ ((x)>>3))\n# define sigma1(x)       (ROTATE((x),15) ^ ROTATE((x),13) ^ ((x)>>10))\n\n# define Ch(x,y,z)       (((x) & (y)) ^ ((~(x)) & (z)))\n# define Maj(x,y,z)      (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))\n\n# ifdef OPENSSL_SMALL_FOOTPRINT\n\nstatic void sha256_block_data_order(SHA256_CTX *ctx, const void *in,\n                                    size_t num)\n{\n    unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1, T2;\n    SHA_LONG X[16], l;\n    int i;\n    const unsigned char *data = in;\n\n    while (num--) {\n\n        a = ctx->h[0];\n        b = ctx->h[1];\n        c = ctx->h[2];\n        d = ctx->h[3];\n        e = ctx->h[4];\n        f = ctx->h[5];\n        g = ctx->h[6];\n        h = ctx->h[7];\n\n        for (i = 0; i < 16; i++) {\n            (void)HOST_c2l(data, l);\n            T1 = X[i] = l;\n            T1 += h + Sigma1(e) + Ch(e, f, g) + K256[i];\n            T2 = Sigma0(a) + Maj(a, b, c);\n            h = g;\n            g = f;\n            f = e;\n            e = d + T1;\n            d = c;\n            c = b;\n            b = a;\n            a = T1 + T2;\n        }\n\n        for (; i < 64; i++) {\n            s0 = X[(i + 1) & 0x0f];\n            s0 = sigma0(s0);\n            s1 = X[(i + 14) & 0x0f];\n            s1 = sigma1(s1);\n\n            T1 = X[i & 0xf] += s0 + s1 + X[(i + 9) & 0xf];\n            T1 += h + Sigma1(e) + Ch(e, f, g) + K256[i];\n            T2 = Sigma0(a) + Maj(a, b, c);\n            h = g;\n            g = f;\n            f = e;\n            e = d + T1;\n            d = c;\n            c = b;\n            b = a;\n            a = T1 + T2;\n        }\n\n        ctx->h[0] += a;\n        ctx->h[1] += b;\n        ctx->h[2] += c;\n        ctx->h[3] += d;\n        ctx->h[4] += e;\n        ctx->h[5] += f;\n        ctx->h[6] += g;\n        ctx->h[7] += h;\n\n    }\n}\n\n# else\n\n#  define ROUND_00_15(i,a,b,c,d,e,f,g,h)          do {    \\\n        T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i];      \\\n        h = Sigma0(a) + Maj(a,b,c);                     \\\n        d += T1;        h += T1;                } while (0)\n\n#  define ROUND_16_63(i,a,b,c,d,e,f,g,h,X)        do {    \\\n        s0 = X[(i+1)&0x0f];     s0 = sigma0(s0);        \\\n        s1 = X[(i+14)&0x0f];    s1 = sigma1(s1);        \\\n        T1 = X[(i)&0x0f] += s0 + s1 + X[(i+9)&0x0f];    \\\n        ROUND_00_15(i,a,b,c,d,e,f,g,h);         } while (0)\n\nstatic void sha256_block_data_order(SHA256_CTX *ctx, const void *in,\n                                    size_t num)\n{\n    unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1;\n    SHA_LONG X[16];\n    int i;\n    const unsigned char *data = in;\n    const union {\n        long one;\n        char little;\n    } is_endian = {\n        1\n    };\n\n    while (num--) {\n\n        a = ctx->h[0];\n        b = ctx->h[1];\n        c = ctx->h[2];\n        d = ctx->h[3];\n        e = ctx->h[4];\n        f = ctx->h[5];\n        g = ctx->h[6];\n        h = ctx->h[7];\n\n        if (!is_endian.little && sizeof(SHA_LONG) == 4\n            && ((size_t)in % 4) == 0) {\n            const SHA_LONG *W = (const SHA_LONG *)data;\n\n            T1 = X[0] = W[0];\n            ROUND_00_15(0, a, b, c, d, e, f, g, h);\n            T1 = X[1] = W[1];\n            ROUND_00_15(1, h, a, b, c, d, e, f, g);\n            T1 = X[2] = W[2];\n            ROUND_00_15(2, g, h, a, b, c, d, e, f);\n            T1 = X[3] = W[3];\n            ROUND_00_15(3, f, g, h, a, b, c, d, e);\n            T1 = X[4] = W[4];\n            ROUND_00_15(4, e, f, g, h, a, b, c, d);\n            T1 = X[5] = W[5];\n            ROUND_00_15(5, d, e, f, g, h, a, b, c);\n            T1 = X[6] = W[6];\n            ROUND_00_15(6, c, d, e, f, g, h, a, b);\n            T1 = X[7] = W[7];\n            ROUND_00_15(7, b, c, d, e, f, g, h, a);\n            T1 = X[8] = W[8];\n            ROUND_00_15(8, a, b, c, d, e, f, g, h);\n            T1 = X[9] = W[9];\n            ROUND_00_15(9, h, a, b, c, d, e, f, g);\n            T1 = X[10] = W[10];\n            ROUND_00_15(10, g, h, a, b, c, d, e, f);\n            T1 = X[11] = W[11];\n            ROUND_00_15(11, f, g, h, a, b, c, d, e);\n            T1 = X[12] = W[12];\n            ROUND_00_15(12, e, f, g, h, a, b, c, d);\n            T1 = X[13] = W[13];\n            ROUND_00_15(13, d, e, f, g, h, a, b, c);\n            T1 = X[14] = W[14];\n            ROUND_00_15(14, c, d, e, f, g, h, a, b);\n            T1 = X[15] = W[15];\n            ROUND_00_15(15, b, c, d, e, f, g, h, a);\n\n            data += SHA256_CBLOCK;\n        } else {\n            SHA_LONG l;\n\n            (void)HOST_c2l(data, l);\n            T1 = X[0] = l;\n            ROUND_00_15(0, a, b, c, d, e, f, g, h);\n            (void)HOST_c2l(data, l);\n            T1 = X[1] = l;\n            ROUND_00_15(1, h, a, b, c, d, e, f, g);\n            (void)HOST_c2l(data, l);\n            T1 = X[2] = l;\n            ROUND_00_15(2, g, h, a, b, c, d, e, f);\n            (void)HOST_c2l(data, l);\n            T1 = X[3] = l;\n            ROUND_00_15(3, f, g, h, a, b, c, d, e);\n            (void)HOST_c2l(data, l);\n            T1 = X[4] = l;\n            ROUND_00_15(4, e, f, g, h, a, b, c, d);\n            (void)HOST_c2l(data, l);\n            T1 = X[5] = l;\n            ROUND_00_15(5, d, e, f, g, h, a, b, c);\n            (void)HOST_c2l(data, l);\n            T1 = X[6] = l;\n            ROUND_00_15(6, c, d, e, f, g, h, a, b);\n            (void)HOST_c2l(data, l);\n            T1 = X[7] = l;\n            ROUND_00_15(7, b, c, d, e, f, g, h, a);\n            (void)HOST_c2l(data, l);\n            T1 = X[8] = l;\n            ROUND_00_15(8, a, b, c, d, e, f, g, h);\n            (void)HOST_c2l(data, l);\n            T1 = X[9] = l;\n            ROUND_00_15(9, h, a, b, c, d, e, f, g);\n            (void)HOST_c2l(data, l);\n            T1 = X[10] = l;\n            ROUND_00_15(10, g, h, a, b, c, d, e, f);\n            (void)HOST_c2l(data, l);\n            T1 = X[11] = l;\n            ROUND_00_15(11, f, g, h, a, b, c, d, e);\n            (void)HOST_c2l(data, l);\n            T1 = X[12] = l;\n            ROUND_00_15(12, e, f, g, h, a, b, c, d);\n            (void)HOST_c2l(data, l);\n            T1 = X[13] = l;\n            ROUND_00_15(13, d, e, f, g, h, a, b, c);\n            (void)HOST_c2l(data, l);\n            T1 = X[14] = l;\n            ROUND_00_15(14, c, d, e, f, g, h, a, b);\n            (void)HOST_c2l(data, l);\n            T1 = X[15] = l;\n            ROUND_00_15(15, b, c, d, e, f, g, h, a);\n        }\n\n        for (i = 16; i < 64; i += 8) {\n            ROUND_16_63(i + 0, a, b, c, d, e, f, g, h, X);\n            ROUND_16_63(i + 1, h, a, b, c, d, e, f, g, X);\n            ROUND_16_63(i + 2, g, h, a, b, c, d, e, f, X);\n            ROUND_16_63(i + 3, f, g, h, a, b, c, d, e, X);\n            ROUND_16_63(i + 4, e, f, g, h, a, b, c, d, X);\n            ROUND_16_63(i + 5, d, e, f, g, h, a, b, c, X);\n            ROUND_16_63(i + 6, c, d, e, f, g, h, a, b, X);\n            ROUND_16_63(i + 7, b, c, d, e, f, g, h, a, X);\n        }\n\n        ctx->h[0] += a;\n        ctx->h[1] += b;\n        ctx->h[2] += c;\n        ctx->h[3] += d;\n        ctx->h[4] += e;\n        ctx->h[5] += f;\n        ctx->h[6] += g;\n        ctx->h[7] += h;\n\n    }\n}\n\n# endif\n#endif                         /* SHA256_ASM */\n"
  },
  {
    "path": "cryptomini/sha/sha512.c",
    "content": "/*\n * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/opensslconf.h>\n/*-\n * IMPLEMENTATION NOTES.\n *\n * As you might have noticed 32-bit hash algorithms:\n *\n * - permit SHA_LONG to be wider than 32-bit\n * - optimized versions implement two transform functions: one operating\n *   on [aligned] data in host byte order and one - on data in input\n *   stream byte order;\n * - share common byte-order neutral collector and padding function\n *   implementations, ../md32_common.h;\n *\n * Neither of the above applies to this SHA-512 implementations. Reasons\n * [in reverse order] are:\n *\n * - it's the only 64-bit hash algorithm for the moment of this writing,\n *   there is no need for common collector/padding implementation [yet];\n * - by supporting only one transform function [which operates on\n *   *aligned* data in input stream byte order, big-endian in this case]\n *   we minimize burden of maintenance in two ways: a) collector/padding\n *   function is simpler; b) only one transform function to stare at;\n * - SHA_LONG64 is required to be exactly 64-bit in order to be able to\n *   apply a number of optimizations to mitigate potential performance\n *   penalties caused by previous design decision;\n *\n * Caveat lector.\n *\n * Implementation relies on the fact that \"long long\" is 64-bit on\n * both 32- and 64-bit platforms. If some compiler vendor comes up\n * with 128-bit long long, adjustment to sha.h would be required.\n * As this implementation relies on 64-bit integer type, it's totally\n * inappropriate for platforms which don't support it, most notably\n * 16-bit platforms.\n */\n#include <stdlib.h>\n#include <string.h>\n\n#include <openssl/crypto.h>\n#include <openssl/sha.h>\n#include <openssl/opensslv.h>\n\n#include \"internal/cryptlib.h\"\n#include \"crypto/sha.h\"\n\n#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \\\n    defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || \\\n    defined(__s390__) || defined(__s390x__) || \\\n    defined(__aarch64__) || \\\n    defined(SHA512_ASM)\n# define SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA\n#endif\n\nint sha512_224_init(SHA512_CTX *c)\n{\n    c->h[0] = U64(0x8c3d37c819544da2);\n    c->h[1] = U64(0x73e1996689dcd4d6);\n    c->h[2] = U64(0x1dfab7ae32ff9c82);\n    c->h[3] = U64(0x679dd514582f9fcf);\n    c->h[4] = U64(0x0f6d2b697bd44da8);\n    c->h[5] = U64(0x77e36f7304c48942);\n    c->h[6] = U64(0x3f9d85a86a1d36c8);\n    c->h[7] = U64(0x1112e6ad91d692a1);\n\n    c->Nl = 0;\n    c->Nh = 0;\n    c->num = 0;\n    c->md_len = SHA224_DIGEST_LENGTH;\n    return 1;\n}\n\nint sha512_256_init(SHA512_CTX *c)\n{\n    c->h[0] = U64(0x22312194fc2bf72c);\n    c->h[1] = U64(0x9f555fa3c84c64c2);\n    c->h[2] = U64(0x2393b86b6f53b151);\n    c->h[3] = U64(0x963877195940eabd);\n    c->h[4] = U64(0x96283ee2a88effe3);\n    c->h[5] = U64(0xbe5e1e2553863992);\n    c->h[6] = U64(0x2b0199fc2c85b8aa);\n    c->h[7] = U64(0x0eb72ddc81c52ca2);\n\n    c->Nl = 0;\n    c->Nh = 0;\n    c->num = 0;\n    c->md_len = SHA256_DIGEST_LENGTH;\n    return 1;\n}\n\nint SHA384_Init(SHA512_CTX *c)\n{\n    c->h[0] = U64(0xcbbb9d5dc1059ed8);\n    c->h[1] = U64(0x629a292a367cd507);\n    c->h[2] = U64(0x9159015a3070dd17);\n    c->h[3] = U64(0x152fecd8f70e5939);\n    c->h[4] = U64(0x67332667ffc00b31);\n    c->h[5] = U64(0x8eb44a8768581511);\n    c->h[6] = U64(0xdb0c2e0d64f98fa7);\n    c->h[7] = U64(0x47b5481dbefa4fa4);\n\n    c->Nl = 0;\n    c->Nh = 0;\n    c->num = 0;\n    c->md_len = SHA384_DIGEST_LENGTH;\n    return 1;\n}\n\nint SHA512_Init(SHA512_CTX *c)\n{\n    c->h[0] = U64(0x6a09e667f3bcc908);\n    c->h[1] = U64(0xbb67ae8584caa73b);\n    c->h[2] = U64(0x3c6ef372fe94f82b);\n    c->h[3] = U64(0xa54ff53a5f1d36f1);\n    c->h[4] = U64(0x510e527fade682d1);\n    c->h[5] = U64(0x9b05688c2b3e6c1f);\n    c->h[6] = U64(0x1f83d9abfb41bd6b);\n    c->h[7] = U64(0x5be0cd19137e2179);\n\n    c->Nl = 0;\n    c->Nh = 0;\n    c->num = 0;\n    c->md_len = SHA512_DIGEST_LENGTH;\n    return 1;\n}\n\n#ifndef SHA512_ASM\nstatic\n#endif\nvoid sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num);\n\nint SHA512_Final(unsigned char *md, SHA512_CTX *c)\n{\n    unsigned char *p = (unsigned char *)c->u.p;\n    size_t n = c->num;\n\n    p[n] = 0x80;                /* There always is a room for one */\n    n++;\n    if (n > (sizeof(c->u) - 16)) {\n        memset(p + n, 0, sizeof(c->u) - n);\n        n = 0;\n        sha512_block_data_order(c, p, 1);\n    }\n\n    memset(p + n, 0, sizeof(c->u) - 16 - n);\n#ifdef  B_ENDIAN\n    c->u.d[SHA_LBLOCK - 2] = c->Nh;\n    c->u.d[SHA_LBLOCK - 1] = c->Nl;\n#else\n    p[sizeof(c->u) - 1] = (unsigned char)(c->Nl);\n    p[sizeof(c->u) - 2] = (unsigned char)(c->Nl >> 8);\n    p[sizeof(c->u) - 3] = (unsigned char)(c->Nl >> 16);\n    p[sizeof(c->u) - 4] = (unsigned char)(c->Nl >> 24);\n    p[sizeof(c->u) - 5] = (unsigned char)(c->Nl >> 32);\n    p[sizeof(c->u) - 6] = (unsigned char)(c->Nl >> 40);\n    p[sizeof(c->u) - 7] = (unsigned char)(c->Nl >> 48);\n    p[sizeof(c->u) - 8] = (unsigned char)(c->Nl >> 56);\n    p[sizeof(c->u) - 9] = (unsigned char)(c->Nh);\n    p[sizeof(c->u) - 10] = (unsigned char)(c->Nh >> 8);\n    p[sizeof(c->u) - 11] = (unsigned char)(c->Nh >> 16);\n    p[sizeof(c->u) - 12] = (unsigned char)(c->Nh >> 24);\n    p[sizeof(c->u) - 13] = (unsigned char)(c->Nh >> 32);\n    p[sizeof(c->u) - 14] = (unsigned char)(c->Nh >> 40);\n    p[sizeof(c->u) - 15] = (unsigned char)(c->Nh >> 48);\n    p[sizeof(c->u) - 16] = (unsigned char)(c->Nh >> 56);\n#endif\n\n    sha512_block_data_order(c, p, 1);\n\n    if (md == 0)\n        return 0;\n\n    switch (c->md_len) {\n    /* Let compiler decide if it's appropriate to unroll... */\n    case SHA224_DIGEST_LENGTH:\n        for (n = 0; n < SHA224_DIGEST_LENGTH / 8; n++) {\n            SHA_LONG64 t = c->h[n];\n\n            *(md++) = (unsigned char)(t >> 56);\n            *(md++) = (unsigned char)(t >> 48);\n            *(md++) = (unsigned char)(t >> 40);\n            *(md++) = (unsigned char)(t >> 32);\n            *(md++) = (unsigned char)(t >> 24);\n            *(md++) = (unsigned char)(t >> 16);\n            *(md++) = (unsigned char)(t >> 8);\n            *(md++) = (unsigned char)(t);\n        }\n        /*\n         * For 224 bits, there are four bytes left over that have to be\n         * processed separately.\n         */\n        {\n            SHA_LONG64 t = c->h[SHA224_DIGEST_LENGTH / 8];\n\n            *(md++) = (unsigned char)(t >> 56);\n            *(md++) = (unsigned char)(t >> 48);\n            *(md++) = (unsigned char)(t >> 40);\n            *(md++) = (unsigned char)(t >> 32);\n        }\n        break;\n    case SHA256_DIGEST_LENGTH:\n        for (n = 0; n < SHA256_DIGEST_LENGTH / 8; n++) {\n            SHA_LONG64 t = c->h[n];\n\n            *(md++) = (unsigned char)(t >> 56);\n            *(md++) = (unsigned char)(t >> 48);\n            *(md++) = (unsigned char)(t >> 40);\n            *(md++) = (unsigned char)(t >> 32);\n            *(md++) = (unsigned char)(t >> 24);\n            *(md++) = (unsigned char)(t >> 16);\n            *(md++) = (unsigned char)(t >> 8);\n            *(md++) = (unsigned char)(t);\n        }\n        break;\n    case SHA384_DIGEST_LENGTH:\n        for (n = 0; n < SHA384_DIGEST_LENGTH / 8; n++) {\n            SHA_LONG64 t = c->h[n];\n\n            *(md++) = (unsigned char)(t >> 56);\n            *(md++) = (unsigned char)(t >> 48);\n            *(md++) = (unsigned char)(t >> 40);\n            *(md++) = (unsigned char)(t >> 32);\n            *(md++) = (unsigned char)(t >> 24);\n            *(md++) = (unsigned char)(t >> 16);\n            *(md++) = (unsigned char)(t >> 8);\n            *(md++) = (unsigned char)(t);\n        }\n        break;\n    case SHA512_DIGEST_LENGTH:\n        for (n = 0; n < SHA512_DIGEST_LENGTH / 8; n++) {\n            SHA_LONG64 t = c->h[n];\n\n            *(md++) = (unsigned char)(t >> 56);\n            *(md++) = (unsigned char)(t >> 48);\n            *(md++) = (unsigned char)(t >> 40);\n            *(md++) = (unsigned char)(t >> 32);\n            *(md++) = (unsigned char)(t >> 24);\n            *(md++) = (unsigned char)(t >> 16);\n            *(md++) = (unsigned char)(t >> 8);\n            *(md++) = (unsigned char)(t);\n        }\n        break;\n    /* ... as well as make sure md_len is not abused. */\n    default:\n        return 0;\n    }\n\n    return 1;\n}\n\nint SHA384_Final(unsigned char *md, SHA512_CTX *c)\n{\n    return SHA512_Final(md, c);\n}\n\nint SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)\n{\n    SHA_LONG64 l;\n    unsigned char *p = c->u.p;\n    const unsigned char *data = (const unsigned char *)_data;\n\n    if (len == 0)\n        return 1;\n\n    l = (c->Nl + (((SHA_LONG64) len) << 3)) & U64(0xffffffffffffffff);\n    if (l < c->Nl)\n        c->Nh++;\n    if (sizeof(len) >= 8)\n        c->Nh += (((SHA_LONG64) len) >> 61);\n    c->Nl = l;\n\n    if (c->num != 0) {\n        size_t n = sizeof(c->u) - c->num;\n\n        if (len < n) {\n            memcpy(p + c->num, data, len), c->num += (unsigned int)len;\n            return 1;\n        } else {\n            memcpy(p + c->num, data, n), c->num = 0;\n            len -= n, data += n;\n            sha512_block_data_order(c, p, 1);\n        }\n    }\n\n    if (len >= sizeof(c->u)) {\n#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA\n        if ((size_t)data % sizeof(c->u.d[0]) != 0)\n            while (len >= sizeof(c->u))\n                memcpy(p, data, sizeof(c->u)),\n                sha512_block_data_order(c, p, 1),\n                len -= sizeof(c->u), data += sizeof(c->u);\n        else\n#endif\n            sha512_block_data_order(c, data, len / sizeof(c->u)),\n            data += len, len %= sizeof(c->u), data -= len;\n    }\n\n    if (len != 0)\n        memcpy(p, data, len), c->num = (int)len;\n\n    return 1;\n}\n\nint SHA384_Update(SHA512_CTX *c, const void *data, size_t len)\n{\n    return SHA512_Update(c, data, len);\n}\n\nvoid SHA512_Transform(SHA512_CTX *c, const unsigned char *data)\n{\n#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA\n    if ((size_t)data % sizeof(c->u.d[0]) != 0)\n        memcpy(c->u.p, data, sizeof(c->u.p)), data = c->u.p;\n#endif\n    sha512_block_data_order(c, data, 1);\n}\n\nunsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md)\n{\n    SHA512_CTX c;\n    static unsigned char m[SHA384_DIGEST_LENGTH];\n\n    if (md == NULL)\n        md = m;\n    SHA384_Init(&c);\n    SHA512_Update(&c, d, n);\n    SHA512_Final(md, &c);\n    OPENSSL_cleanse(&c, sizeof(c));\n    return md;\n}\n\nunsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md)\n{\n    SHA512_CTX c;\n    static unsigned char m[SHA512_DIGEST_LENGTH];\n\n    if (md == NULL)\n        md = m;\n    SHA512_Init(&c);\n    SHA512_Update(&c, d, n);\n    SHA512_Final(md, &c);\n    OPENSSL_cleanse(&c, sizeof(c));\n    return md;\n}\n\n#ifndef SHA512_ASM\nstatic const SHA_LONG64 K512[80] = {\n    U64(0x428a2f98d728ae22), U64(0x7137449123ef65cd),\n    U64(0xb5c0fbcfec4d3b2f), U64(0xe9b5dba58189dbbc),\n    U64(0x3956c25bf348b538), U64(0x59f111f1b605d019),\n    U64(0x923f82a4af194f9b), U64(0xab1c5ed5da6d8118),\n    U64(0xd807aa98a3030242), U64(0x12835b0145706fbe),\n    U64(0x243185be4ee4b28c), U64(0x550c7dc3d5ffb4e2),\n    U64(0x72be5d74f27b896f), U64(0x80deb1fe3b1696b1),\n    U64(0x9bdc06a725c71235), U64(0xc19bf174cf692694),\n    U64(0xe49b69c19ef14ad2), U64(0xefbe4786384f25e3),\n    U64(0x0fc19dc68b8cd5b5), U64(0x240ca1cc77ac9c65),\n    U64(0x2de92c6f592b0275), U64(0x4a7484aa6ea6e483),\n    U64(0x5cb0a9dcbd41fbd4), U64(0x76f988da831153b5),\n    U64(0x983e5152ee66dfab), U64(0xa831c66d2db43210),\n    U64(0xb00327c898fb213f), U64(0xbf597fc7beef0ee4),\n    U64(0xc6e00bf33da88fc2), U64(0xd5a79147930aa725),\n    U64(0x06ca6351e003826f), U64(0x142929670a0e6e70),\n    U64(0x27b70a8546d22ffc), U64(0x2e1b21385c26c926),\n    U64(0x4d2c6dfc5ac42aed), U64(0x53380d139d95b3df),\n    U64(0x650a73548baf63de), U64(0x766a0abb3c77b2a8),\n    U64(0x81c2c92e47edaee6), U64(0x92722c851482353b),\n    U64(0xa2bfe8a14cf10364), U64(0xa81a664bbc423001),\n    U64(0xc24b8b70d0f89791), U64(0xc76c51a30654be30),\n    U64(0xd192e819d6ef5218), U64(0xd69906245565a910),\n    U64(0xf40e35855771202a), U64(0x106aa07032bbd1b8),\n    U64(0x19a4c116b8d2d0c8), U64(0x1e376c085141ab53),\n    U64(0x2748774cdf8eeb99), U64(0x34b0bcb5e19b48a8),\n    U64(0x391c0cb3c5c95a63), U64(0x4ed8aa4ae3418acb),\n    U64(0x5b9cca4f7763e373), U64(0x682e6ff3d6b2b8a3),\n    U64(0x748f82ee5defb2fc), U64(0x78a5636f43172f60),\n    U64(0x84c87814a1f0ab72), U64(0x8cc702081a6439ec),\n    U64(0x90befffa23631e28), U64(0xa4506cebde82bde9),\n    U64(0xbef9a3f7b2c67915), U64(0xc67178f2e372532b),\n    U64(0xca273eceea26619c), U64(0xd186b8c721c0c207),\n    U64(0xeada7dd6cde0eb1e), U64(0xf57d4f7fee6ed178),\n    U64(0x06f067aa72176fba), U64(0x0a637dc5a2c898a6),\n    U64(0x113f9804bef90dae), U64(0x1b710b35131c471b),\n    U64(0x28db77f523047d84), U64(0x32caab7b40c72493),\n    U64(0x3c9ebe0a15c9bebc), U64(0x431d67c49c100d4c),\n    U64(0x4cc5d4becb3e42b6), U64(0x597f299cfc657e2a),\n    U64(0x5fcb6fab3ad6faec), U64(0x6c44198c4a475817)\n};\n\n# ifndef PEDANTIC\n#  if defined(__GNUC__) && __GNUC__>=2 && \\\n      !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)\n#   if defined(__x86_64) || defined(__x86_64__)\n#    define ROTR(a,n)    ({ SHA_LONG64 ret;             \\\n                                asm (\"rorq %1,%0\"       \\\n                                : \"=r\"(ret)             \\\n                                : \"J\"(n),\"0\"(a)         \\\n                                : \"cc\"); ret;           })\n#    if !defined(B_ENDIAN)\n#     define PULL64(x) ({ SHA_LONG64 ret=*((const SHA_LONG64 *)(&(x)));  \\\n                                asm (\"bswapq    %0\"             \\\n                                : \"=r\"(ret)                     \\\n                                : \"0\"(ret)); ret;               })\n#    endif\n#   elif (defined(__i386) || defined(__i386__)) && !defined(B_ENDIAN)\n#    if defined(I386_ONLY)\n#     define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\\\n                          unsigned int hi=p[0],lo=p[1];          \\\n                                asm(\"xchgb %%ah,%%al;xchgb %%dh,%%dl;\"\\\n                                    \"roll $16,%%eax; roll $16,%%edx; \"\\\n                                    \"xchgb %%ah,%%al;xchgb %%dh,%%dl;\"\\\n                                : \"=a\"(lo),\"=d\"(hi)             \\\n                                : \"0\"(lo),\"1\"(hi) : \"cc\");      \\\n                                ((SHA_LONG64)hi)<<32|lo;        })\n#    else\n#     define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\\\n                          unsigned int hi=p[0],lo=p[1];         \\\n                                asm (\"bswapl %0; bswapl %1;\"    \\\n                                : \"=r\"(lo),\"=r\"(hi)             \\\n                                : \"0\"(lo),\"1\"(hi));             \\\n                                ((SHA_LONG64)hi)<<32|lo;        })\n#    endif\n#   elif (defined(_ARCH_PPC) && defined(__64BIT__)) || defined(_ARCH_PPC64)\n#    define ROTR(a,n)    ({ SHA_LONG64 ret;             \\\n                                asm (\"rotrdi %0,%1,%2\"  \\\n                                : \"=r\"(ret)             \\\n                                : \"r\"(a),\"K\"(n)); ret;  })\n#   elif defined(__aarch64__)\n#    define ROTR(a,n)    ({ SHA_LONG64 ret;             \\\n                                asm (\"ror %0,%1,%2\"     \\\n                                : \"=r\"(ret)             \\\n                                : \"r\"(a),\"I\"(n)); ret;  })\n#    if  defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \\\n        __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__\n#     define PULL64(x)   ({ SHA_LONG64 ret;                     \\\n                                asm (\"rev       %0,%1\"          \\\n                                : \"=r\"(ret)                     \\\n                                : \"r\"(*((const SHA_LONG64 *)(&(x))))); ret; })\n#    endif\n#   endif\n#  elif defined(_MSC_VER)\n#   if defined(_WIN64)         /* applies to both IA-64 and AMD64 */\n#    pragma intrinsic(_rotr64)\n#    define ROTR(a,n)    _rotr64((a),n)\n#   endif\n#   if defined(_M_IX86) && !defined(OPENSSL_NO_ASM) && \\\n       !defined(OPENSSL_NO_INLINE_ASM)\n#    if defined(I386_ONLY)\nstatic SHA_LONG64 __fastcall __pull64be(const void *x)\n{\n    _asm mov  edx,[ecx + 0]\n    _asm mov  eax,[ecx + 4]\n    _asm xchg dh, dl\n    _asm xchg ah, al\n    _asm rol  edx, 16\n    _asm rol  eax, 16\n    _asm xchg dh, dl\n    _asm xchg ah, al\n}\n#    else\nstatic SHA_LONG64 __fastcall __pull64be(const void *x)\n{\n    _asm mov   edx,[ecx + 0]\n    _asm mov   eax,[ecx + 4]\n    _asm bswap edx\n    _asm bswap eax\n}\n#    endif\n#    define PULL64(x) __pull64be(&(x))\n#   endif\n#  endif\n# endif\n# ifndef PULL64\n#  define B(x,j)    (((SHA_LONG64)(*(((const unsigned char *)(&x))+j)))<<((7-j)*8))\n#  define PULL64(x) (B(x,0)|B(x,1)|B(x,2)|B(x,3)|B(x,4)|B(x,5)|B(x,6)|B(x,7))\n# endif\n# ifndef ROTR\n#  define ROTR(x,s)       (((x)>>s) | (x)<<(64-s))\n# endif\n# define Sigma0(x)       (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39))\n# define Sigma1(x)       (ROTR((x),14) ^ ROTR((x),18) ^ ROTR((x),41))\n# define sigma0(x)       (ROTR((x),1)  ^ ROTR((x),8)  ^ ((x)>>7))\n# define sigma1(x)       (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6))\n# define Ch(x,y,z)       (((x) & (y)) ^ ((~(x)) & (z)))\n# define Maj(x,y,z)      (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))\n\n# if defined(__i386) || defined(__i386__) || defined(_M_IX86)\n/*\n * This code should give better results on 32-bit CPU with less than\n * ~24 registers, both size and performance wise...\n */\n\nstatic void sha512_block_data_order(SHA512_CTX *ctx, const void *in,\n                                    size_t num)\n{\n    const SHA_LONG64 *W = in;\n    SHA_LONG64 A, E, T;\n    SHA_LONG64 X[9 + 80], *F;\n    int i;\n\n    while (num--) {\n\n        F = X + 80;\n        A = ctx->h[0];\n        F[1] = ctx->h[1];\n        F[2] = ctx->h[2];\n        F[3] = ctx->h[3];\n        E = ctx->h[4];\n        F[5] = ctx->h[5];\n        F[6] = ctx->h[6];\n        F[7] = ctx->h[7];\n\n        for (i = 0; i < 16; i++, F--) {\n#  ifdef B_ENDIAN\n            T = W[i];\n#  else\n            T = PULL64(W[i]);\n#  endif\n            F[0] = A;\n            F[4] = E;\n            F[8] = T;\n            T += F[7] + Sigma1(E) + Ch(E, F[5], F[6]) + K512[i];\n            E = F[3] + T;\n            A = T + Sigma0(A) + Maj(A, F[1], F[2]);\n        }\n\n        for (; i < 80; i++, F--) {\n            T = sigma0(F[8 + 16 - 1]);\n            T += sigma1(F[8 + 16 - 14]);\n            T += F[8 + 16] + F[8 + 16 - 9];\n\n            F[0] = A;\n            F[4] = E;\n            F[8] = T;\n            T += F[7] + Sigma1(E) + Ch(E, F[5], F[6]) + K512[i];\n            E = F[3] + T;\n            A = T + Sigma0(A) + Maj(A, F[1], F[2]);\n        }\n\n        ctx->h[0] += A;\n        ctx->h[1] += F[1];\n        ctx->h[2] += F[2];\n        ctx->h[3] += F[3];\n        ctx->h[4] += E;\n        ctx->h[5] += F[5];\n        ctx->h[6] += F[6];\n        ctx->h[7] += F[7];\n\n        W += SHA_LBLOCK;\n    }\n}\n\n# elif defined(OPENSSL_SMALL_FOOTPRINT)\n\nstatic void sha512_block_data_order(SHA512_CTX *ctx, const void *in,\n                                    size_t num)\n{\n    const SHA_LONG64 *W = in;\n    SHA_LONG64 a, b, c, d, e, f, g, h, s0, s1, T1, T2;\n    SHA_LONG64 X[16];\n    int i;\n\n    while (num--) {\n\n        a = ctx->h[0];\n        b = ctx->h[1];\n        c = ctx->h[2];\n        d = ctx->h[3];\n        e = ctx->h[4];\n        f = ctx->h[5];\n        g = ctx->h[6];\n        h = ctx->h[7];\n\n        for (i = 0; i < 16; i++) {\n#  ifdef B_ENDIAN\n            T1 = X[i] = W[i];\n#  else\n            T1 = X[i] = PULL64(W[i]);\n#  endif\n            T1 += h + Sigma1(e) + Ch(e, f, g) + K512[i];\n            T2 = Sigma0(a) + Maj(a, b, c);\n            h = g;\n            g = f;\n            f = e;\n            e = d + T1;\n            d = c;\n            c = b;\n            b = a;\n            a = T1 + T2;\n        }\n\n        for (; i < 80; i++) {\n            s0 = X[(i + 1) & 0x0f];\n            s0 = sigma0(s0);\n            s1 = X[(i + 14) & 0x0f];\n            s1 = sigma1(s1);\n\n            T1 = X[i & 0xf] += s0 + s1 + X[(i + 9) & 0xf];\n            T1 += h + Sigma1(e) + Ch(e, f, g) + K512[i];\n            T2 = Sigma0(a) + Maj(a, b, c);\n            h = g;\n            g = f;\n            f = e;\n            e = d + T1;\n            d = c;\n            c = b;\n            b = a;\n            a = T1 + T2;\n        }\n\n        ctx->h[0] += a;\n        ctx->h[1] += b;\n        ctx->h[2] += c;\n        ctx->h[3] += d;\n        ctx->h[4] += e;\n        ctx->h[5] += f;\n        ctx->h[6] += g;\n        ctx->h[7] += h;\n\n        W += SHA_LBLOCK;\n    }\n}\n\n# else\n#  define ROUND_00_15(i,a,b,c,d,e,f,g,h)        do {    \\\n        T1 += h + Sigma1(e) + Ch(e,f,g) + K512[i];      \\\n        h = Sigma0(a) + Maj(a,b,c);                     \\\n        d += T1;        h += T1;                        } while (0)\n\n#  define ROUND_16_80(i,j,a,b,c,d,e,f,g,h,X)    do {    \\\n        s0 = X[(j+1)&0x0f];     s0 = sigma0(s0);        \\\n        s1 = X[(j+14)&0x0f];    s1 = sigma1(s1);        \\\n        T1 = X[(j)&0x0f] += s0 + s1 + X[(j+9)&0x0f];    \\\n        ROUND_00_15(i+j,a,b,c,d,e,f,g,h);               } while (0)\n\nstatic void sha512_block_data_order(SHA512_CTX *ctx, const void *in,\n                                    size_t num)\n{\n    const SHA_LONG64 *W = in;\n    SHA_LONG64 a, b, c, d, e, f, g, h, s0, s1, T1;\n    SHA_LONG64 X[16];\n    int i;\n\n    while (num--) {\n\n        a = ctx->h[0];\n        b = ctx->h[1];\n        c = ctx->h[2];\n        d = ctx->h[3];\n        e = ctx->h[4];\n        f = ctx->h[5];\n        g = ctx->h[6];\n        h = ctx->h[7];\n\n#  ifdef B_ENDIAN\n        T1 = X[0] = W[0];\n        ROUND_00_15(0, a, b, c, d, e, f, g, h);\n        T1 = X[1] = W[1];\n        ROUND_00_15(1, h, a, b, c, d, e, f, g);\n        T1 = X[2] = W[2];\n        ROUND_00_15(2, g, h, a, b, c, d, e, f);\n        T1 = X[3] = W[3];\n        ROUND_00_15(3, f, g, h, a, b, c, d, e);\n        T1 = X[4] = W[4];\n        ROUND_00_15(4, e, f, g, h, a, b, c, d);\n        T1 = X[5] = W[5];\n        ROUND_00_15(5, d, e, f, g, h, a, b, c);\n        T1 = X[6] = W[6];\n        ROUND_00_15(6, c, d, e, f, g, h, a, b);\n        T1 = X[7] = W[7];\n        ROUND_00_15(7, b, c, d, e, f, g, h, a);\n        T1 = X[8] = W[8];\n        ROUND_00_15(8, a, b, c, d, e, f, g, h);\n        T1 = X[9] = W[9];\n        ROUND_00_15(9, h, a, b, c, d, e, f, g);\n        T1 = X[10] = W[10];\n        ROUND_00_15(10, g, h, a, b, c, d, e, f);\n        T1 = X[11] = W[11];\n        ROUND_00_15(11, f, g, h, a, b, c, d, e);\n        T1 = X[12] = W[12];\n        ROUND_00_15(12, e, f, g, h, a, b, c, d);\n        T1 = X[13] = W[13];\n        ROUND_00_15(13, d, e, f, g, h, a, b, c);\n        T1 = X[14] = W[14];\n        ROUND_00_15(14, c, d, e, f, g, h, a, b);\n        T1 = X[15] = W[15];\n        ROUND_00_15(15, b, c, d, e, f, g, h, a);\n#  else\n        T1 = X[0] = PULL64(W[0]);\n        ROUND_00_15(0, a, b, c, d, e, f, g, h);\n        T1 = X[1] = PULL64(W[1]);\n        ROUND_00_15(1, h, a, b, c, d, e, f, g);\n        T1 = X[2] = PULL64(W[2]);\n        ROUND_00_15(2, g, h, a, b, c, d, e, f);\n        T1 = X[3] = PULL64(W[3]);\n        ROUND_00_15(3, f, g, h, a, b, c, d, e);\n        T1 = X[4] = PULL64(W[4]);\n        ROUND_00_15(4, e, f, g, h, a, b, c, d);\n        T1 = X[5] = PULL64(W[5]);\n        ROUND_00_15(5, d, e, f, g, h, a, b, c);\n        T1 = X[6] = PULL64(W[6]);\n        ROUND_00_15(6, c, d, e, f, g, h, a, b);\n        T1 = X[7] = PULL64(W[7]);\n        ROUND_00_15(7, b, c, d, e, f, g, h, a);\n        T1 = X[8] = PULL64(W[8]);\n        ROUND_00_15(8, a, b, c, d, e, f, g, h);\n        T1 = X[9] = PULL64(W[9]);\n        ROUND_00_15(9, h, a, b, c, d, e, f, g);\n        T1 = X[10] = PULL64(W[10]);\n        ROUND_00_15(10, g, h, a, b, c, d, e, f);\n        T1 = X[11] = PULL64(W[11]);\n        ROUND_00_15(11, f, g, h, a, b, c, d, e);\n        T1 = X[12] = PULL64(W[12]);\n        ROUND_00_15(12, e, f, g, h, a, b, c, d);\n        T1 = X[13] = PULL64(W[13]);\n        ROUND_00_15(13, d, e, f, g, h, a, b, c);\n        T1 = X[14] = PULL64(W[14]);\n        ROUND_00_15(14, c, d, e, f, g, h, a, b);\n        T1 = X[15] = PULL64(W[15]);\n        ROUND_00_15(15, b, c, d, e, f, g, h, a);\n#  endif\n\n        for (i = 16; i < 80; i += 16) {\n            ROUND_16_80(i, 0, a, b, c, d, e, f, g, h, X);\n            ROUND_16_80(i, 1, h, a, b, c, d, e, f, g, X);\n            ROUND_16_80(i, 2, g, h, a, b, c, d, e, f, X);\n            ROUND_16_80(i, 3, f, g, h, a, b, c, d, e, X);\n            ROUND_16_80(i, 4, e, f, g, h, a, b, c, d, X);\n            ROUND_16_80(i, 5, d, e, f, g, h, a, b, c, X);\n            ROUND_16_80(i, 6, c, d, e, f, g, h, a, b, X);\n            ROUND_16_80(i, 7, b, c, d, e, f, g, h, a, X);\n            ROUND_16_80(i, 8, a, b, c, d, e, f, g, h, X);\n            ROUND_16_80(i, 9, h, a, b, c, d, e, f, g, X);\n            ROUND_16_80(i, 10, g, h, a, b, c, d, e, f, X);\n            ROUND_16_80(i, 11, f, g, h, a, b, c, d, e, X);\n            ROUND_16_80(i, 12, e, f, g, h, a, b, c, d, X);\n            ROUND_16_80(i, 13, d, e, f, g, h, a, b, c, X);\n            ROUND_16_80(i, 14, c, d, e, f, g, h, a, b, X);\n            ROUND_16_80(i, 15, b, c, d, e, f, g, h, a, X);\n        }\n\n        ctx->h[0] += a;\n        ctx->h[1] += b;\n        ctx->h[2] += c;\n        ctx->h[3] += d;\n        ctx->h[4] += e;\n        ctx->h[5] += f;\n        ctx->h[6] += g;\n        ctx->h[7] += h;\n\n        W += SHA_LBLOCK;\n    }\n}\n\n# endif\n\n#endif                         /* SHA512_ASM */\n"
  },
  {
    "path": "cryptomini/sha/sha_local.h",
    "content": "/*\n * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <stdlib.h>\n#include <string.h>\n\n#include <openssl/opensslconf.h>\n#include <openssl/sha.h>\n\n#define DATA_ORDER_IS_BIG_ENDIAN\n\n#define HASH_LONG               SHA_LONG\n#define HASH_CTX                SHA_CTX\n#define HASH_CBLOCK             SHA_CBLOCK\n#define HASH_MAKE_STRING(c,s)   do {    \\\n        unsigned long ll;               \\\n        ll=(c)->h0; (void)HOST_l2c(ll,(s));     \\\n        ll=(c)->h1; (void)HOST_l2c(ll,(s));     \\\n        ll=(c)->h2; (void)HOST_l2c(ll,(s));     \\\n        ll=(c)->h3; (void)HOST_l2c(ll,(s));     \\\n        ll=(c)->h4; (void)HOST_l2c(ll,(s));     \\\n        } while (0)\n\n#define HASH_UPDATE                     SHA1_Update\n#define HASH_TRANSFORM                  SHA1_Transform\n#define HASH_FINAL                      SHA1_Final\n#define HASH_INIT                       SHA1_Init\n#define HASH_BLOCK_DATA_ORDER           sha1_block_data_order\n#define Xupdate(a,ix,ia,ib,ic,id)       ( (a)=(ia^ib^ic^id),    \\\n                                          ix=(a)=ROTATE((a),1)  \\\n                                        )\n\n#ifndef SHA1_ASM\nstatic void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num);\n#else\nvoid sha1_block_data_order(SHA_CTX *c, const void *p, size_t num);\n#endif\n\n#include \"crypto/md32_common.h\"\n\n#define INIT_DATA_h0 0x67452301UL\n#define INIT_DATA_h1 0xefcdab89UL\n#define INIT_DATA_h2 0x98badcfeUL\n#define INIT_DATA_h3 0x10325476UL\n#define INIT_DATA_h4 0xc3d2e1f0UL\n\nint HASH_INIT(SHA_CTX *c)\n{\n    memset(c, 0, sizeof(*c));\n    c->h0 = INIT_DATA_h0;\n    c->h1 = INIT_DATA_h1;\n    c->h2 = INIT_DATA_h2;\n    c->h3 = INIT_DATA_h3;\n    c->h4 = INIT_DATA_h4;\n    return 1;\n}\n\n#define K_00_19 0x5a827999UL\n#define K_20_39 0x6ed9eba1UL\n#define K_40_59 0x8f1bbcdcUL\n#define K_60_79 0xca62c1d6UL\n\n/*\n * As pointed out by Wei Dai, F() below can be simplified to the code in\n * F_00_19.  Wei attributes these optimizations to Peter Gutmann's SHS code,\n * and he attributes it to Rich Schroeppel.\n *      #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))\n * I've just become aware of another tweak to be made, again from Wei Dai,\n * in F_40_59, (x&a)|(y&a) -> (x|y)&a\n */\n#define F_00_19(b,c,d)  ((((c) ^ (d)) & (b)) ^ (d))\n#define F_20_39(b,c,d)  ((b) ^ (c) ^ (d))\n#define F_40_59(b,c,d)  (((b) & (c)) | (((b)|(c)) & (d)))\n#define F_60_79(b,c,d)  F_20_39(b,c,d)\n\n#ifndef OPENSSL_SMALL_FOOTPRINT\n\n# define BODY_00_15(i,a,b,c,d,e,f,xi) \\\n        (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \\\n        (b)=ROTATE((b),30);\n\n# define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \\\n        Xupdate(f,xi,xa,xb,xc,xd); \\\n        (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \\\n        (b)=ROTATE((b),30);\n\n# define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \\\n        Xupdate(f,xi,xa,xb,xc,xd); \\\n        (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \\\n        (b)=ROTATE((b),30);\n\n# define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \\\n        Xupdate(f,xa,xa,xb,xc,xd); \\\n        (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \\\n        (b)=ROTATE((b),30);\n\n# define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \\\n        Xupdate(f,xa,xa,xb,xc,xd); \\\n        (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \\\n        (b)=ROTATE((b),30);\n\n# define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \\\n        Xupdate(f,xa,xa,xb,xc,xd); \\\n        (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \\\n        (b)=ROTATE((b),30);\n\n# ifdef X\n#  undef X\n# endif\n# ifndef MD32_XARRAY\n  /*\n   * Originally X was an array. As it's automatic it's natural\n   * to expect RISC compiler to accommodate at least part of it in\n   * the register bank, isn't it? Unfortunately not all compilers\n   * \"find\" this expectation reasonable:-( On order to make such\n   * compilers generate better code I replace X[] with a bunch of\n   * X0, X1, etc. See the function body below...\n   */\n#  define X(i)   XX##i\n# else\n  /*\n   * However! Some compilers (most notably HP C) get overwhelmed by\n   * that many local variables so that we have to have the way to\n   * fall down to the original behavior.\n   */\n#  define X(i)   XX[i]\n# endif\n\n# if !defined(SHA1_ASM)\nstatic void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num)\n{\n    const unsigned char *data = p;\n    register unsigned MD32_REG_T A, B, C, D, E, T, l;\n#  ifndef MD32_XARRAY\n    unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,\n        XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;\n#  else\n    SHA_LONG XX[16];\n#  endif\n\n    A = c->h0;\n    B = c->h1;\n    C = c->h2;\n    D = c->h3;\n    E = c->h4;\n\n    for (;;) {\n        const union {\n            long one;\n            char little;\n        } is_endian = {\n            1\n        };\n\n        if (!is_endian.little && sizeof(SHA_LONG) == 4\n            && ((size_t)p % 4) == 0) {\n            const SHA_LONG *W = (const SHA_LONG *)data;\n\n            X(0) = W[0];\n            X(1) = W[1];\n            BODY_00_15(0, A, B, C, D, E, T, X(0));\n            X(2) = W[2];\n            BODY_00_15(1, T, A, B, C, D, E, X(1));\n            X(3) = W[3];\n            BODY_00_15(2, E, T, A, B, C, D, X(2));\n            X(4) = W[4];\n            BODY_00_15(3, D, E, T, A, B, C, X(3));\n            X(5) = W[5];\n            BODY_00_15(4, C, D, E, T, A, B, X(4));\n            X(6) = W[6];\n            BODY_00_15(5, B, C, D, E, T, A, X(5));\n            X(7) = W[7];\n            BODY_00_15(6, A, B, C, D, E, T, X(6));\n            X(8) = W[8];\n            BODY_00_15(7, T, A, B, C, D, E, X(7));\n            X(9) = W[9];\n            BODY_00_15(8, E, T, A, B, C, D, X(8));\n            X(10) = W[10];\n            BODY_00_15(9, D, E, T, A, B, C, X(9));\n            X(11) = W[11];\n            BODY_00_15(10, C, D, E, T, A, B, X(10));\n            X(12) = W[12];\n            BODY_00_15(11, B, C, D, E, T, A, X(11));\n            X(13) = W[13];\n            BODY_00_15(12, A, B, C, D, E, T, X(12));\n            X(14) = W[14];\n            BODY_00_15(13, T, A, B, C, D, E, X(13));\n            X(15) = W[15];\n            BODY_00_15(14, E, T, A, B, C, D, X(14));\n            BODY_00_15(15, D, E, T, A, B, C, X(15));\n\n            data += SHA_CBLOCK;\n        } else {\n            (void)HOST_c2l(data, l);\n            X(0) = l;\n            (void)HOST_c2l(data, l);\n            X(1) = l;\n            BODY_00_15(0, A, B, C, D, E, T, X(0));\n            (void)HOST_c2l(data, l);\n            X(2) = l;\n            BODY_00_15(1, T, A, B, C, D, E, X(1));\n            (void)HOST_c2l(data, l);\n            X(3) = l;\n            BODY_00_15(2, E, T, A, B, C, D, X(2));\n            (void)HOST_c2l(data, l);\n            X(4) = l;\n            BODY_00_15(3, D, E, T, A, B, C, X(3));\n            (void)HOST_c2l(data, l);\n            X(5) = l;\n            BODY_00_15(4, C, D, E, T, A, B, X(4));\n            (void)HOST_c2l(data, l);\n            X(6) = l;\n            BODY_00_15(5, B, C, D, E, T, A, X(5));\n            (void)HOST_c2l(data, l);\n            X(7) = l;\n            BODY_00_15(6, A, B, C, D, E, T, X(6));\n            (void)HOST_c2l(data, l);\n            X(8) = l;\n            BODY_00_15(7, T, A, B, C, D, E, X(7));\n            (void)HOST_c2l(data, l);\n            X(9) = l;\n            BODY_00_15(8, E, T, A, B, C, D, X(8));\n            (void)HOST_c2l(data, l);\n            X(10) = l;\n            BODY_00_15(9, D, E, T, A, B, C, X(9));\n            (void)HOST_c2l(data, l);\n            X(11) = l;\n            BODY_00_15(10, C, D, E, T, A, B, X(10));\n            (void)HOST_c2l(data, l);\n            X(12) = l;\n            BODY_00_15(11, B, C, D, E, T, A, X(11));\n            (void)HOST_c2l(data, l);\n            X(13) = l;\n            BODY_00_15(12, A, B, C, D, E, T, X(12));\n            (void)HOST_c2l(data, l);\n            X(14) = l;\n            BODY_00_15(13, T, A, B, C, D, E, X(13));\n            (void)HOST_c2l(data, l);\n            X(15) = l;\n            BODY_00_15(14, E, T, A, B, C, D, X(14));\n            BODY_00_15(15, D, E, T, A, B, C, X(15));\n        }\n\n        BODY_16_19(16, C, D, E, T, A, B, X(0), X(0), X(2), X(8), X(13));\n        BODY_16_19(17, B, C, D, E, T, A, X(1), X(1), X(3), X(9), X(14));\n        BODY_16_19(18, A, B, C, D, E, T, X(2), X(2), X(4), X(10), X(15));\n        BODY_16_19(19, T, A, B, C, D, E, X(3), X(3), X(5), X(11), X(0));\n\n        BODY_20_31(20, E, T, A, B, C, D, X(4), X(4), X(6), X(12), X(1));\n        BODY_20_31(21, D, E, T, A, B, C, X(5), X(5), X(7), X(13), X(2));\n        BODY_20_31(22, C, D, E, T, A, B, X(6), X(6), X(8), X(14), X(3));\n        BODY_20_31(23, B, C, D, E, T, A, X(7), X(7), X(9), X(15), X(4));\n        BODY_20_31(24, A, B, C, D, E, T, X(8), X(8), X(10), X(0), X(5));\n        BODY_20_31(25, T, A, B, C, D, E, X(9), X(9), X(11), X(1), X(6));\n        BODY_20_31(26, E, T, A, B, C, D, X(10), X(10), X(12), X(2), X(7));\n        BODY_20_31(27, D, E, T, A, B, C, X(11), X(11), X(13), X(3), X(8));\n        BODY_20_31(28, C, D, E, T, A, B, X(12), X(12), X(14), X(4), X(9));\n        BODY_20_31(29, B, C, D, E, T, A, X(13), X(13), X(15), X(5), X(10));\n        BODY_20_31(30, A, B, C, D, E, T, X(14), X(14), X(0), X(6), X(11));\n        BODY_20_31(31, T, A, B, C, D, E, X(15), X(15), X(1), X(7), X(12));\n\n        BODY_32_39(32, E, T, A, B, C, D, X(0), X(2), X(8), X(13));\n        BODY_32_39(33, D, E, T, A, B, C, X(1), X(3), X(9), X(14));\n        BODY_32_39(34, C, D, E, T, A, B, X(2), X(4), X(10), X(15));\n        BODY_32_39(35, B, C, D, E, T, A, X(3), X(5), X(11), X(0));\n        BODY_32_39(36, A, B, C, D, E, T, X(4), X(6), X(12), X(1));\n        BODY_32_39(37, T, A, B, C, D, E, X(5), X(7), X(13), X(2));\n        BODY_32_39(38, E, T, A, B, C, D, X(6), X(8), X(14), X(3));\n        BODY_32_39(39, D, E, T, A, B, C, X(7), X(9), X(15), X(4));\n\n        BODY_40_59(40, C, D, E, T, A, B, X(8), X(10), X(0), X(5));\n        BODY_40_59(41, B, C, D, E, T, A, X(9), X(11), X(1), X(6));\n        BODY_40_59(42, A, B, C, D, E, T, X(10), X(12), X(2), X(7));\n        BODY_40_59(43, T, A, B, C, D, E, X(11), X(13), X(3), X(8));\n        BODY_40_59(44, E, T, A, B, C, D, X(12), X(14), X(4), X(9));\n        BODY_40_59(45, D, E, T, A, B, C, X(13), X(15), X(5), X(10));\n        BODY_40_59(46, C, D, E, T, A, B, X(14), X(0), X(6), X(11));\n        BODY_40_59(47, B, C, D, E, T, A, X(15), X(1), X(7), X(12));\n        BODY_40_59(48, A, B, C, D, E, T, X(0), X(2), X(8), X(13));\n        BODY_40_59(49, T, A, B, C, D, E, X(1), X(3), X(9), X(14));\n        BODY_40_59(50, E, T, A, B, C, D, X(2), X(4), X(10), X(15));\n        BODY_40_59(51, D, E, T, A, B, C, X(3), X(5), X(11), X(0));\n        BODY_40_59(52, C, D, E, T, A, B, X(4), X(6), X(12), X(1));\n        BODY_40_59(53, B, C, D, E, T, A, X(5), X(7), X(13), X(2));\n        BODY_40_59(54, A, B, C, D, E, T, X(6), X(8), X(14), X(3));\n        BODY_40_59(55, T, A, B, C, D, E, X(7), X(9), X(15), X(4));\n        BODY_40_59(56, E, T, A, B, C, D, X(8), X(10), X(0), X(5));\n        BODY_40_59(57, D, E, T, A, B, C, X(9), X(11), X(1), X(6));\n        BODY_40_59(58, C, D, E, T, A, B, X(10), X(12), X(2), X(7));\n        BODY_40_59(59, B, C, D, E, T, A, X(11), X(13), X(3), X(8));\n\n        BODY_60_79(60, A, B, C, D, E, T, X(12), X(14), X(4), X(9));\n        BODY_60_79(61, T, A, B, C, D, E, X(13), X(15), X(5), X(10));\n        BODY_60_79(62, E, T, A, B, C, D, X(14), X(0), X(6), X(11));\n        BODY_60_79(63, D, E, T, A, B, C, X(15), X(1), X(7), X(12));\n        BODY_60_79(64, C, D, E, T, A, B, X(0), X(2), X(8), X(13));\n        BODY_60_79(65, B, C, D, E, T, A, X(1), X(3), X(9), X(14));\n        BODY_60_79(66, A, B, C, D, E, T, X(2), X(4), X(10), X(15));\n        BODY_60_79(67, T, A, B, C, D, E, X(3), X(5), X(11), X(0));\n        BODY_60_79(68, E, T, A, B, C, D, X(4), X(6), X(12), X(1));\n        BODY_60_79(69, D, E, T, A, B, C, X(5), X(7), X(13), X(2));\n        BODY_60_79(70, C, D, E, T, A, B, X(6), X(8), X(14), X(3));\n        BODY_60_79(71, B, C, D, E, T, A, X(7), X(9), X(15), X(4));\n        BODY_60_79(72, A, B, C, D, E, T, X(8), X(10), X(0), X(5));\n        BODY_60_79(73, T, A, B, C, D, E, X(9), X(11), X(1), X(6));\n        BODY_60_79(74, E, T, A, B, C, D, X(10), X(12), X(2), X(7));\n        BODY_60_79(75, D, E, T, A, B, C, X(11), X(13), X(3), X(8));\n        BODY_60_79(76, C, D, E, T, A, B, X(12), X(14), X(4), X(9));\n        BODY_60_79(77, B, C, D, E, T, A, X(13), X(15), X(5), X(10));\n        BODY_60_79(78, A, B, C, D, E, T, X(14), X(0), X(6), X(11));\n        BODY_60_79(79, T, A, B, C, D, E, X(15), X(1), X(7), X(12));\n\n        c->h0 = (c->h0 + E) & 0xffffffffL;\n        c->h1 = (c->h1 + T) & 0xffffffffL;\n        c->h2 = (c->h2 + A) & 0xffffffffL;\n        c->h3 = (c->h3 + B) & 0xffffffffL;\n        c->h4 = (c->h4 + C) & 0xffffffffL;\n\n        if (--num == 0)\n            break;\n\n        A = c->h0;\n        B = c->h1;\n        C = c->h2;\n        D = c->h3;\n        E = c->h4;\n\n    }\n}\n# endif\n\n#else                           /* OPENSSL_SMALL_FOOTPRINT */\n\n# define BODY_00_15(xi)           do {   \\\n        T=E+K_00_19+F_00_19(B,C,D);     \\\n        E=D, D=C, C=ROTATE(B,30), B=A;  \\\n        A=ROTATE(A,5)+T+xi;         } while(0)\n\n# define BODY_16_19(xa,xb,xc,xd)  do {   \\\n        Xupdate(T,xa,xa,xb,xc,xd);      \\\n        T+=E+K_00_19+F_00_19(B,C,D);    \\\n        E=D, D=C, C=ROTATE(B,30), B=A;  \\\n        A=ROTATE(A,5)+T;            } while(0)\n\n# define BODY_20_39(xa,xb,xc,xd)  do {   \\\n        Xupdate(T,xa,xa,xb,xc,xd);      \\\n        T+=E+K_20_39+F_20_39(B,C,D);    \\\n        E=D, D=C, C=ROTATE(B,30), B=A;  \\\n        A=ROTATE(A,5)+T;            } while(0)\n\n# define BODY_40_59(xa,xb,xc,xd)  do {   \\\n        Xupdate(T,xa,xa,xb,xc,xd);      \\\n        T+=E+K_40_59+F_40_59(B,C,D);    \\\n        E=D, D=C, C=ROTATE(B,30), B=A;  \\\n        A=ROTATE(A,5)+T;            } while(0)\n\n# define BODY_60_79(xa,xb,xc,xd)  do {   \\\n        Xupdate(T,xa,xa,xb,xc,xd);      \\\n        T=E+K_60_79+F_60_79(B,C,D);     \\\n        E=D, D=C, C=ROTATE(B,30), B=A;  \\\n        A=ROTATE(A,5)+T+xa;         } while(0)\n\n# if !defined(SHA1_ASM)\nstatic void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num)\n{\n    const unsigned char *data = p;\n    register unsigned MD32_REG_T A, B, C, D, E, T, l;\n    int i;\n    SHA_LONG X[16];\n\n    A = c->h0;\n    B = c->h1;\n    C = c->h2;\n    D = c->h3;\n    E = c->h4;\n\n    for (;;) {\n        for (i = 0; i < 16; i++) {\n            (void)HOST_c2l(data, l);\n            X[i] = l;\n            BODY_00_15(X[i]);\n        }\n        for (i = 0; i < 4; i++) {\n            BODY_16_19(X[i], X[i + 2], X[i + 8], X[(i + 13) & 15]);\n        }\n        for (; i < 24; i++) {\n            BODY_20_39(X[i & 15], X[(i + 2) & 15], X[(i + 8) & 15],\n                       X[(i + 13) & 15]);\n        }\n        for (i = 0; i < 20; i++) {\n            BODY_40_59(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15],\n                       X[(i + 5) & 15]);\n        }\n        for (i = 4; i < 24; i++) {\n            BODY_60_79(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15],\n                       X[(i + 5) & 15]);\n        }\n\n        c->h0 = (c->h0 + A) & 0xffffffffL;\n        c->h1 = (c->h1 + B) & 0xffffffffL;\n        c->h2 = (c->h2 + C) & 0xffffffffL;\n        c->h3 = (c->h3 + D) & 0xffffffffL;\n        c->h4 = (c->h4 + E) & 0xffffffffL;\n\n        if (--num == 0)\n            break;\n\n        A = c->h0;\n        B = c->h1;\n        C = c->h2;\n        D = c->h3;\n        E = c->h4;\n\n    }\n}\n# endif\n\n#endif\n"
  },
  {
    "path": "cryptomini/threads_none.c",
    "content": "/*\n * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.\n *\n * Licensed under the OpenSSL license (the \"License\").  You may not use\n * this file except in compliance with the License.  You can obtain a copy\n * in the file LICENSE in the source distribution or at\n * https://www.openssl.org/source/license.html\n */\n\n#include <openssl/crypto.h>\n#include \"internal/cryptlib.h\"\n\n#if !defined(OPENSSL_THREADS) || defined(CRYPTO_TDEBUG)\n\n# if defined(OPENSSL_SYS_UNIX)\n#  include <sys/types.h>\n#  include <unistd.h>\n# endif\n\nCRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)\n{\n    CRYPTO_RWLOCK *lock;\n\n    if ((lock = OPENSSL_zalloc(sizeof(unsigned int))) == NULL) {\n        /* Don't set error, to avoid recursion blowup. */\n        return NULL;\n    }\n\n    *(unsigned int *)lock = 1;\n\n    return lock;\n}\n\nint CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)\n{\n    if (!ossl_assert(*(unsigned int *)lock == 1))\n        return 0;\n    return 1;\n}\n\nint CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)\n{\n    if (!ossl_assert(*(unsigned int *)lock == 1))\n        return 0;\n    return 1;\n}\n\nint CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)\n{\n    if (!ossl_assert(*(unsigned int *)lock == 1))\n        return 0;\n    return 1;\n}\n\nvoid CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock) {\n    if (lock == NULL)\n        return;\n\n    *(unsigned int *)lock = 0;\n    OPENSSL_free(lock);\n\n    return;\n}\n\nint CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))\n{\n    if (*once != 0)\n        return 1;\n\n    init();\n    *once = 1;\n\n    return 1;\n}\n\n#define OPENSSL_CRYPTO_THREAD_LOCAL_KEY_MAX 256\n\nstatic void *thread_local_storage[OPENSSL_CRYPTO_THREAD_LOCAL_KEY_MAX];\n\nint CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))\n{\n    static unsigned int thread_local_key = 0;\n\n    if (thread_local_key >= OPENSSL_CRYPTO_THREAD_LOCAL_KEY_MAX)\n        return 0;\n\n    *key = thread_local_key++;\n\n    thread_local_storage[*key] = NULL;\n\n    return 1;\n}\n\nvoid *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)\n{\n    if (*key >= OPENSSL_CRYPTO_THREAD_LOCAL_KEY_MAX)\n        return NULL;\n\n    return thread_local_storage[*key];\n}\n\nint CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)\n{\n    if (*key >= OPENSSL_CRYPTO_THREAD_LOCAL_KEY_MAX)\n        return 0;\n\n    thread_local_storage[*key] = val;\n\n    return 1;\n}\n\nint CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)\n{\n    *key = OPENSSL_CRYPTO_THREAD_LOCAL_KEY_MAX + 1;\n    return 1;\n}\n\nCRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void)\n{\n    return 0;\n}\n\nint CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b)\n{\n    return (a == b);\n}\n\nint CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)\n{\n    *val += amount;\n    *ret  = *val;\n\n    return 1;\n}\n\nint openssl_init_fork_handlers(void)\n{\n    return 0;\n}\n\nint openssl_get_fork_id(void)\n{\n    return 0;\n// # if defined(OPENSSL_SYS_UNIX)\n//     return getpid();\n// # else\n//     return 0;\n// # endif\n}\n#endif\n"
  },
  {
    "path": "ftpm-driver/.vscode/settings.json",
    "content": "{\n  \"files.associations\": {\n    \"types.h\": \"c\",\n    \"string.h\": \"c\"\n  }\n}"
  },
  {
    "path": "ftpm-driver/Makefile",
    "content": "\nDRIVER = ftpm-driver.ko\n\nifneq ($(KERNELRELEASE),)\n\tftpm-driver-y := \\\n\t\tftpm.o \\\n\t\tftpm-ioctl.o \\\n\t  ftpm-sbi.o\n\tobj-m += ftpm-driver.o\n\n\n\n\nPWD := $(shell pwd)\nLINUXSRC := $(PWD)/../linuxs\n\n\n\nall:\n\t$(MAKE) -C $(LINUXSRC) ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- M=$(PWD)\n\nendif\n\nclean:\n\trm -rvf *.o *.ko *.order *.symvers *.mod.c .tmp_versions .*o.cmd\n"
  },
  {
    "path": "ftpm-driver/ftpm-driver.mod",
    "content": "/workspace/rfTPM/ftpm-driver/ftpm.o\n/workspace/rfTPM/ftpm-driver/ftpm-ioctl.o\n/workspace/rfTPM/ftpm-driver/ftpm-sbi.o\n"
  },
  {
    "path": "ftpm-driver/ftpm-ioctl.c",
    "content": "//******************************************************************************\n// Copyright (c) 2018, The Regents of the University of California (Regents).\n// All Rights Reserved. See LICENSE for license details.\n//------------------------------------------------------------------------------\n#include <asm/sbi.h>\n#include <linux/uaccess.h>\n#include <linux/io.h>\n#include <linux/string.h>\n\n#include \"ftpm.h\"\n#include \"ftpm-sbi.h\"\n#include \"ftpm_user.h\"\n\nunsigned long ftpm_tid;\nunsigned long state_pfn;\n\nvoid *state_vaddr;\n\nstruct ftpm_cmd {\n  uint32_t length;\n  uint8_t buffer[];\n};\n\nint ftpm_run_command(struct tss_ftpm_context* cnx)\n{\n  struct sbiret ret;\n\n  ret = sbi_sm_ftpm_run_command(cnx);\n\n  return 0;\n}\n\n\nlong ftpm_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)\n{\n  long ret;\n  char data[64];\n\n  size_t ioc_size;\n\n  if (!arg)\n    return -EINVAL;\n\n  ioc_size = _IOC_SIZE(cmd);\n  ioc_size = ioc_size > sizeof(data) ? sizeof(data) : ioc_size;\n\n  if (copy_from_user(data, (void __user *)arg, ioc_size)) {\n    return -EFAULT;\n  }\n\n  switch (cmd) {\n    case FTPM_IOC_RUN_COMMAND:\n      ret = ftpm_run_command((struct tss_ftpm_context*)data);\n    break;\n\n  default:\n    return -ENOSYS;\n  }\n\n  if (copy_to_user((void __user *)arg, data, ioc_size)) {\n    return -EFAULT;\n  }\n\n  return ret;\n}"
  },
  {
    "path": "ftpm-driver/ftpm-sbi.c",
    "content": "#include \"ftpm-sbi.h\"\n\n#include \"ftpm_user.h\"\n\n\nstruct sbiret sbi_sm_ftpm_run_command(struct tss_ftpm_context *cnx) {\n  return sbi_ecall(SBI_EXT_EXPERIMENTAL_FTPM,\n      SBI_FTPM_RUN_COMMAND,\n      (unsigned long) cnx, 0, 0, 0, 0, 0);\n}"
  },
  {
    "path": "ftpm-driver/ftpm-sbi.h",
    "content": "#ifndef _FTPM_SBI_H_\n#define _FTPM_SBI_H_\n\n#include <asm/sbi.h>\n#include \"ftpm_user.h\"\n\n\nstruct sbiret sbi_sm_ftpm_run_command(struct tss_ftpm_context *cnx);\n#endif"
  },
  {
    "path": "ftpm-driver/ftpm.c",
    "content": "\n#include \"ftpm.h\"\n#include \"ftpm-sbi.h\"\n\n#include <linux/dma-mapping.h>\n#include <linux/mm.h>\n#include <linux/file.h>\n#include <linux/module.h>\n#include <linux/moduleparam.h>\n#include <linux/miscdevice.h>\n#include <linux/slab.h>\n\n#define   DRV_DESCRIPTION   \"ftpm\"\n#define   DRV_VERSION       \"1.0.0\"\n\nMODULE_DESCRIPTION(DRV_DESCRIPTION);\nMODULE_AUTHOR(\"iwangjye@gmail.com\");\nMODULE_VERSION(DRV_VERSION);\nMODULE_LICENSE(\"Dual BSD/GPL\");\n\nstatic const struct file_operations ftpm_fops = {\n    .owner          = THIS_MODULE,\n    .unlocked_ioctl = ftpm_ioctl,\n};\n\n\nstruct miscdevice ftpm_dev = {\n  .minor = MISC_DYNAMIC_MINOR,\n  .name = \"ftpm\",\n  .fops = &ftpm_fops,\n  .mode = 0666,\n};\n\n\nstatic int __init ftpm_dev_init(void)\n{\n  int  ret;\n\n\n  ret = misc_register(&ftpm_dev);\n  if (ret < 0)\n  {\n    pr_err(\"[fTPM-DRIVER] misc_register() failed\\n\");\n  }\n\n  ftpm_dev.this_device->coherent_dma_mask = DMA_BIT_MASK(32);\n\n  pr_info(\"[fTPM-DRIVER] \" DRV_DESCRIPTION \" v\" DRV_VERSION \"\\n\");\n\n  return ret;\n}\n\n\nstatic void __exit ftpm_dev_exit(void)\n{\n  pr_info(\"[fTPM-DRIVER] ftpm_dev_exit()\\n\");\n  misc_deregister(&ftpm_dev); \n  return;\n}\n\nmodule_init(ftpm_dev_init);\nmodule_exit(ftpm_dev_exit);\n"
  },
  {
    "path": "ftpm-driver/ftpm.h",
    "content": "//******************************************************************************\n// Copyright (c) 2018, The Regents of the University of California (Regents).\n// All Rights Reserved. See LICENSE for license details.\n//------------------------------------------------------------------------------\n#ifndef _FTPM_H_\n#define _FTPM_H_\n\n\n\n\n\n\n\n#include <asm/sbi.h>\n#include <asm/csr.h>\n#include <linux/slab.h>\n#include <linux/module.h>\n#include <linux/uaccess.h>\n#include <linux/init.h>\n#include <linux/kernel.h>\n#include <linux/fs.h>\n#include <linux/miscdevice.h>\n#include <linux/idr.h>\n#include <linux/types.h>\n#include <linux/file.h>\n\n\n\n\n\n\n\n\n\n// /* IMPORTANT: This code assumes Sv39 */\n// // #include \"riscv64.h\"\n\n// #define PAGE_UP(addr)\t(((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1)))\n// #define MAX_COMMAND_SIZE\t\t4096\t/* maximum size of a command */\n// #define MAX_RESPONSE_SIZE\t\t4096\t/* maximum size of a response */\n\n// #define TPM_SEND_COMMAND            8\n\n// typedef uintptr_t vaddr_t;\n// typedef uintptr_t paddr_t;\n\n// extern struct miscdevice rtpm_dev;\n// extern struct rtpm_sbi_communication_t *cm;\n\n\n// int rtpm_mmap(struct file *filp, struct vm_area_struct *vma);\n// long rtpm_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);\n// // ssize_t rtpm_read (struct file *, char __user *buffer, size_t length, loff_t *);\n// // ssize_t rtpm_write (struct file *, const char __user *buffer, size_t length, loff_t *);\n\n\n// // struct sbiret sbi_rtpm_tee_acquire(unsigned long tid, unsigned long addr);\n\n// int rtpm_tee_acquire(unsigned long data);\n\nlong ftpm_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);\n\n#define rtpm_info(fmt, ...) \\\n  pr_info(\"rtpm: \" fmt, ##__VA_ARGS__)\n#define rtpm_err(fmt, ...) \\\n  pr_err(\"rtpm: \" fmt, ##__VA_ARGS__)\n#define rtpm_warn(fmt, ...) \\\n  pr_warn(\"rtpm: \" fmt, ##__VA_ARGS__)\n#endif\n"
  },
  {
    "path": "ftpm-driver/ftpm_user.h",
    "content": "\n#ifndef _FTPM_USER_H_\n#define _FTPM_USER_H_\n\n\n\n// struct rtpm_ioctl_tee_acquire {\n//   unsigned long tid;\n//   unsigned long pfn;\n// };\n\nstruct tss_ftpm_context {\n    uintptr_t commandBuffer;\n    uint32_t written;\n    uintptr_t responseBuffer;\n    uint32_t read;\n};\n\n\n#define SBI_EXT_EXPERIMENTAL_FTPM 0x08424b45\n#define SBI_FTPM_RUN_COMMAND    2001\n\n#define FTPM_IOC_MAGIC 0xa5\n\n\n#define FTPM_IOC_RUN_COMMAND \\\n  _IOWR(FTPM_IOC_MAGIC, 0x01, struct tss_ftpm_context)\n\n#endif"
  },
  {
    "path": "ftpm-driver/rtpm-controller.c",
    "content": "#include <sys/ioctl.h>\n#include <stdlib.h>\n#include <fcntl.h>\n#include <stdio.h>\n#include <string.h>\n\n#include <stdint.h>\n#include <stdbool.h>\n#include <fcntl.h>\n#include <unistd.h>\n\n#include \"rtpm_user.h\"\n\n#define RTPM_DEV_PATH \"/dev/utpm\"\n\n// ./rtpm-controller acquire 1 32767\n\nint main(int argc, char **argv) {\n\n  char *type;\n  unsigned long tid;\n  unsigned long pfn = 0x80000000;\n\n  struct rtpm_ioctl_tee_acquire tee_acquire;\n\n  type = argv[1];\n  tid = atoi(argv[2]);\n  pfn = atoi(argv[3]);\n\n  printf(\"[RTPM-CONTROLLER] type=%s, tid=%lx, pfn=%lx\\n\", type, tid, pfn);\n\n  int fd = open(RTPM_DEV_PATH, O_RDWR);\n  if (fd < 0) {\n    printf(\"cannot open device file\\n\");\n    return -1;\n  }\n\n  if (strcmp(type, \"acquire\") == 0) {\n    tee_acquire.tid = tid;\n    tee_acquire.pfn = pfn;\n\n    if (ioctl(fd, RTPM_IOC_TEE_ACQUIRE, &tee_acquire) < 0) {\n      printf(\"ioctl failed\\n\");\n      return -1;\n    }\n  }\n\n  close(fd);\n}"
  },
  {
    "path": "ftpm-driver/rtpm-driver.mod",
    "content": "/opt/NestedTEE/enclave/vtpm/rtpm-driver/rtpm.o\n/opt/NestedTEE/enclave/vtpm/rtpm-driver/rtpm-ioctl.o\n/opt/NestedTEE/enclave/vtpm/rtpm-driver/rtpm-sbi.o\n"
  },
  {
    "path": "ftpm-opensbi/.clang-format",
    "content": "AlignConsecutiveAssignments: true\nAlignEscapedNewlines: Left\nAlignTrailingComments: true\nAllowShortFunctionsOnASingleLine: None\nBraceWrapping:\n  AfterFunction: true\nBreakBeforeBraces: Custom\nBreakStringLiterals: false\nContinuationIndentWidth: 8\nCpp11BracedListStyle: false\nIndentWidth: 8\nReflowComments: false\nSortIncludes: false\nSpacesInContainerLiterals: false\nTabWidth: 8\nUseTab: Always\n"
  },
  {
    "path": "ftpm-opensbi/.gitignore",
    "content": "# Object files\n*.o\n*.a\n*.dep\n\n#Build & install directories\nbuild/\ninstall/\n\n# Development friendly files\ntags\ncscope*\n*.swp\n"
  },
  {
    "path": "ftpm-opensbi/.vscode/settings.json",
    "content": "{\n    \"files.associations\": {\n        \"string_view\": \"c\",\n        \"semihosting.h\": \"c\",\n        \"fdt_helper.h\": \"c\",\n        \"intercept.h\": \"c\",\n        \"ff.h\": \"c\",\n        \"diskio.h\": \"c\",\n        \"ffconf.h\": \"c\",\n        \"time.h\": \"c\",\n        \"sbi_console.h\": \"c\",\n        \"platform.h\": \"c\",\n        \"fdt_timer.h\": \"c\",\n        \"cerrno\": \"c\",\n        \"aes.h\": \"c\",\n        \"ftpm.h\": \"c\"\n    }\n}"
  },
  {
    "path": "ftpm-opensbi/CONTRIBUTORS.md",
    "content": "\nList of OpenSBI Contributors (Alphabetically sorted)\n====================================================\n\n* **[Western Digital Corporation](https://www.wdc.com/)**\n  * Project initiator and maintainer\n  * Copyright (c) 2019 Western Digital Corporation or its affiliates\n\n* Alistair Francis <alistair@alistair23.me>\n\n* Andreas Schwab <schwab@suse.de>\n\n* Anup Patel <anup.patel@wdc.com>\n\n* Atish Patra <atish.patra@wdc.com>\n\n* Bin Meng <bmeng.cn@gmail.com>\n\n* Damien Le Moal <damien.lemoal@wdc.com>\n\n* Karsten Merker <merker@debian.org>\n\n* Nick Kossifidis <mickflemm@gmail.com>\n\n* Shawn Chang <citypw@gmail.com>\n\n* Xiang Wang <wxjstz@126.com>\n"
  },
  {
    "path": "ftpm-opensbi/COPYING.BSD",
    "content": "The 2-Clause BSD License\nSPDX short identifier: BSD-2-Clause\n\nCopyright (c) 2019 Western Digital Corporation or its affiliates and other\ncontributors.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "ftpm-opensbi/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmainmenu \"OpenSBI $(OPENSBI_PLATFORM) Configuration\"\n\nconfig OPENSBI_SRC_DIR\n\tstring\n\toption env=\"OPENSBI_SRC_DIR\"\n\nconfig OPENSBI_PLATFORM\n\tstring\n\toption env=\"OPENSBI_PLATFORM\"\n\nconfig OPENSBI_PLATFORM_SRC_DIR\n\tstring\n\toption env=\"OPENSBI_PLATFORM_SRC_DIR\"\n\nmenu \"Platform Options\"\nsource \"$(OPENSBI_PLATFORM_SRC_DIR)/Kconfig\"\nendmenu\n\nsource \"$(OPENSBI_SRC_DIR)/lib/sbi/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/firmware/Kconfig\"\n"
  },
  {
    "path": "ftpm-opensbi/ThirdPartyNotices.md",
    "content": "Copyright (c) 2019 Western Digital Corporation or its affiliates.\n\nThird Party Notices\n===================\n\nThis project includes or partly uses code from the following open source\nsoftware subject to the following open source licenses.\n\nlibfdt\n------\n\nCopyright (C) 2016 Free Electrons\nCopyright (C) 2016 NextThing Co.\n\nThe libfdt source code is disjunctively dual licensed (GPL-2.0+ or\nBSD-2-Clause). Some of this project code is used in OpenSBI under the terms of\nthe BSD 2-Clause license. The full text of this license can be found in the\nfile [COPYING.BSD](COPYING.BSD).\n"
  },
  {
    "path": "ftpm-opensbi/docs/contributing.md",
    "content": "OpenSBI Contribution Guideline\n==============================\n\nAll contributions to OpenSBI can be sent in the following ways:\n1. Email patches to the OpenSBI mailing list at `opensbi@lists.infradead.org`\n2. GitHub Pull Requests (PRs) to the [OpenSBI main repository]\n\nTo join the OpenSBI mailing list, please visit the [OpenSBI infradead page].\n\nThe OpenSBI maintainers prefer patches via the OpenSBI mailing list\n(option 1 above) so that they are visible to a wider audience. All\naccepted patches on the OpenSBI mailing list will be taken by any of\nthe OpenSBI maintainers and merged into the [OpenSBI main repository]\nusing GitHub PRs.\n\nAll contributed work must follow the following rules:\n1. OpenSBI code should be written in accordance to the [Linux coding style].\n2. This project embraces the [Developer Certificate of Origin (DCO)] for\ncontributions. This means that you must agree to the following prior to\nsubmitting patches: if you agree with this developer certificate you\nacknowledge this by adding a Signed-off-by tag to your patch commit log.\nEvery submitted patch must have this tag.\n3. A commit message must have a subject line, followed by a blank line,\nfollowed by a description of the patch content. A blank line and the author\nSigned-off-by tag must follow this description.\n4. A commit subject line must start with a prefix followed by a \":\". Common\nprefixes are for example \"lib:\", \"platform:\", \"firmware:\", \"docs:\", \"utils:\"\nand \"top:\".\n5. Maintainers should use \"Rebase and Merge\" when using GitHub to merge pull\nrequests to avoid creating unnecessary merge commits.\n6. Maintainers should avoid creating branches directly in the main\nriscv/opensbi repository. Instead, prefer using a fork of the riscv/opensbi main\nrepository and branches within that fork to create pull requests.\n7. A maintainer cannot merge his own pull requests in the riscv/opensbi main\nrepository.\n8. A pull request must get at least one review from a maintainer.\n9. A pull request must spend at least 24 hours in review to allow for other\ndevelopers to review.\n\n-----------------------------------------------------------------------\n\nDeveloper Certificate of Origin\nVersion 1.1\n\nCopyright (C) 2004, 2006 The Linux Foundation and its contributors.\n660 York Street, Suite 102,\nSan Francisco, CA 94110 USA\n\nEveryone is permitted to copy and distribute verbatim copies of this\nlicense document, but changing it is not allowed.\n\n\nDeveloper's Certificate of Origin 1.1\n\nBy making a contribution to this project, I certify that:\n\n(a) The contribution was created in whole or in part by me and I\n    have the right to submit it under the open source license\n    indicated in the file; or\n\n(b) The contribution is based upon previous work that, to the best\n    of my knowledge, is covered under an appropriate open source\n    license and I have the right under that license to submit that\n    work with modifications, whether created in whole or in part\n    by me, under the same open source license (unless I am\n    permitted to submit under a different license), as indicated\n    in the file; or\n\n(c) The contribution was provided directly to me by some other\n    person who certified (a), (b) or (c) and I have not modified\n    it.\n\n(d) I understand and agree that this project and the contribution\n    are public and that a record of the contribution (including all\n    personal information I submit with it, including my sign-off) is\n    maintained indefinitely and may be redistributed consistent with\n    this project or the open source license(s) involved.\n\n-----------------------------------------------------------------------\n\n[OpenSBI main repository]: https://github.com/riscv/opensbi\n[OpenSBI infradead page]: http://lists.infradead.org/mailman/listinfo/opensbi\n[Linux coding style]: https://www.kernel.org/doc/html/v4.10/process/coding-style.html\n[Developer Certificate of Origin (DCO)]: http://developercertificate.org/\n"
  },
  {
    "path": "ftpm-opensbi/docs/domain_support.md",
    "content": "OpenSBI Domain Support\n======================\n\nAn OpenSBI domain is a system-level partition (subset) of underlying hardware\nhaving its own memory regions (RAM and MMIO devices) and HARTs. The OpenSBI\nwill try to achieve secure isolation between domains using RISC-V platform\nfeatures such as PMP, ePMP, IOPMP, SiFive Shield, etc.\n\nImportant entities which help implement OpenSBI domain support are:\n\n* **struct sbi_domain_memregion** - Representation of a domain memory region\n* **struct sbi_hartmask** - Representation of domain HART set\n* **struct sbi_domain** - Representation of a domain instance\n\nEach HART of a RISC-V platform must have an OpenSBI domain assigned to it.\nThe OpenSBI platform support is responsible for populating domains and\nproviding HART id to domain mapping. The OpenSBI domain support will by\ndefault assign **the ROOT domain** to all HARTs of a RISC-V platform, so\nit is not mandatory for the OpenSBI platform support to populate domains.\n\nDomain Memory Region\n--------------------\n\nA domain memory region is represented by **struct sbi_domain_memregion** in\nOpenSBI and has following details:\n\n* **order** - The size of a memory region is **2 ^ order** where **order**\n  must be **3 <= order <= __riscv_xlen**\n* **base** - The base address of a memory region is **2 ^ order**\n  aligned start address\n* **flags** - The flags of a memory region represent memory type (i.e.\n  RAM or MMIO) and allowed accesses (i.e. READ, WRITE, EXECUTE, etc.)\n\nDomain Instance\n---------------\n\nA domain instance is represented by **struct sbi_domain** in OpenSBI and\nhas following details:\n\n* **index** - Logical index of this domain\n* **name** - Name of this domain\n* **assigned_harts** - HARTs assigned to this domain\n* **possible_harts** - HARTs possible in this domain\n* **regions** - Array of memory regions terminated by a memory region\n  with order zero\n* **boot_hartid** - HART id of the HART booting this domain. The domain\n  boot HART will be started at boot-time if boot HART is possible and\n  assigned for this domain.\n* **next_addr** - Address of the next booting stage for this domain\n* **next_arg1** - Arg1 (or 'a1' register) of the next booting stage for\n  this domain\n* **next_mode** - Privilege mode of the next booting stage for this\n  domain. This can be either S-mode or U-mode.\n* **system_reset_allowed** - Is domain allowed to reset the system?\n\nThe memory regions represented by **regions** in **struct sbi_domain** have\nfollowing additional constraints to align with RISC-V PMP requirements:\n\n* A memory region to protect OpenSBI firmware from S-mode and U-mode\n  should always be present\n* For two overlapping memory regions, one should be sub-region of another\n* Two overlapping memory regions should not be of same size\n* Two overlapping memory regions cannot have same flags\n* Memory access checks on overlapping address should prefer smallest\n  overlapping memory region flags.\n\nROOT Domain\n-----------\n\n**The ROOT domain** is the default OpenSBI domain which is assigned by\ndefault to all HARTs of a RISC-V platform. The OpenSBI domain support\nwill hand-craft **the ROOT domain** very early at boot-time in the\nfollowing manner:\n\n* **index** - Logical index of the ROOT domain is always zero\n* **name** - Name of the ROOT domain is \"root\"\n* **assigned_harts** - At boot-time all valid HARTs of a RISC-V platform\n  are assigned the ROOT domain which changes later based on OpenSBI\n  platform support\n* **possible_harts** - All valid HARTs of a RISC-V platform are possible\n  HARTs of the ROOT domain\n* **regions** - Two memory regions available to the ROOT domain:\n  **A)** A memory region to protect OpenSBI firmware from S-mode and U-mode\n  **B)** A memory region of **order=__riscv_xlen** allowing S-mode and\n  U-mode access to full memory address space\n* **boot_hartid** - Coldboot HART is the HART booting the ROOT domain\n* **next_addr** - Next booting stage address in coldboot HART scratch\n  space is the next address for the ROOT domain\n* **next_arg1** - Next booting stage arg1 in coldboot HART scratch space\n  is the next arg1 for the ROOT domain\n* **next_mode** - Next booting stage mode in coldboot HART scratch space\n  is the next mode for the ROOT domain\n* **system_reset_allowed** - The ROOT domain is allowed to reset the system\n\nDomain Effects\n--------------\n\nFew noteworthy effects of a system partitioned into domains are as follows:\n\n* At any point in time, a HART is running in exactly one OpenSBI domain context\n* The SBI IPI and RFENCE calls from HART A are restricted to the HARTs in\n  domain assigned to HART A\n* The SBI HSM calls which try to change/read state of HART B from HART A will\n  only work if both HART A and HART B are assigned same domain\n* A HART running in S-mode or U-mode can only access memory based on the\n  memory regions of the domain assigned to the HART\n\nDomain Device Tree Bindings\n---------------------------\n\nThe OpenSBI domains can be described in the **device tree (DT) blob** (or\nflattened device tree) passed to the OpenSBI firmwares by the previous\nbooting stage. This allows OpenSBI platform support to parse and populate\nOpenSBI domains from the device tree blob (or flattened device tree).\n\n### Domain Configuration Node\n\nAll OpenSBI domain description related DT nodes should be under the domain\nconfiguration DT node. The **/chosen** DT node is the preferred parent of\nthe domain configuration DT node.\n\nThe DT properties of a domain configuration DT node are as follows:\n\n* **compatible** (Mandatory) - The compatible string of the domain\n  configuration. This DT property should have value *\"opensbi,domain,config\"*\n\n### Domain Memory Region Node\n\nThe domain memory region DT node describes details of a memory region and\ncan be pointed by multiple domain instance DT nodes. The access permissions\nof the memory region are specified separately in domain instance node.\n\nThe DT properties of a domain memory region DT node are as follows:\n\n* **compatible** (Mandatory) - The compatible string of the domain memory\n  region. This DT property should have value *\"opensbi,domain,memregion\"*\n* **base** (Mandatory) - The base address of the domain memory region. This\n  DT property should have a **2 ^ order** aligned 64 bit address (i.e. two\n  DT cells).\n* **order** (Mandatory) - The order of the domain memory region. This DT\n  property should have a 32 bit value (i.e. one DT cell) in the range\n  **3 <= order <= __riscv_xlen**.\n* **mmio** (Optional) - A boolean flag representing whether the domain\n  memory region is a memory-mapped I/O (MMIO) region.\n* **devices** (Optional) - The list of device DT node phandles for devices\n  which fall under this domain memory region.\n\n### Domain Instance Node\n\nThe domain instance DT node describes set of possible HARTs, set of memory\nregions, and other details of a domain instance.\n\nThe DT properties of a domain instance DT node are as follows:\n\n* **compatible** (Mandatory) - The compatible string of the domain instance.\n  This DT property should have value *\"opensbi,domain,instance\"*\n* **possible-harts** (Optional) - The list of CPU DT node phandles for the\n  the domain instance. This list represents the possible HARTs of the\n  domain instance.\n* **regions** (Optional) - The list of domain memory region DT node phandle\n  and access permissions for the domain instance. Each list entry is a pair\n  of DT node phandle and access permissions. The access permissions are\n  represented as a 32bit bitmask having bits: **readable** (BIT[0]),\n  **writeable** (BIT[1]), **executable** (BIT[2]), and **m-mode** (BIT[3]).\n* **boot-hart** (Optional) - The DT node phandle of the HART booting the\n  domain instance. If coldboot HART is assigned to the domain instance then\n  this DT property is ignored and the coldboot HART is assumed to be the\n  boot HART of the domain instance.\n* **next-arg1** (Optional) - The 64 bit next booting stage arg1 for the\n  domain instance. If this DT property is not available and coldboot HART\n  is not assigned to the domain instance then **0x0** is used as default\n  value. If this DT property is not available and coldboot HART is assigned\n  to the domain instance then **next booting stage arg1 of coldboot HART**\n  is used as default value.\n* **next-addr** (Optional) - The 64 bit next booting stage address for the\n  domain instance. If this DT property is not available and coldboot HART\n  is not assigned to the domain instance then **0x0** is used as default\n  value. If this DT property is not available and coldboot HART is assigned\n  to the domain instance then **next booting stage address of coldboot HART**\n  is used as default value.\n* **next-mode** (Optional) - The 32 bit next booting stage mode for the\n  domain instance. The possible values of this DT property are: **0x1**\n  (s-mode), and **0x0** (u-mode). If this DT property is not available\n  and coldboot HART is not assigned to the domain instance then **0x1**\n  is used as default value. If this DT property is not available and\n  coldboot HART is assigned to the domain instance then **next booting\n  stage mode of coldboot HART** is used as default value.\n* **system-reset-allowed** (Optional) - A boolean flag representing\n  whether the domain instance is allowed to do system reset.\n\n### Assigning HART To Domain Instance\n\nBy default, all HARTs are assigned to **the ROOT domain**. The OpenSBI\nplatform support can provide the HART to domain instance assignment using\nplatform specific callback.\n\nThe HART to domain instance assignment can be parsed from the device tree\nusing optional DT property **opensbi,domain** in each CPU DT node. The\nvalue of DT property **opensbi,domain** is the DT phandle of the domain\ninstance DT node. If **opensbi,domain** DT property is not specified then\ncorresponding HART is assigned to **the ROOT domain**.\n\n### Domain Configuration Only Accessible to OpenSBI\n\nThe software running inside a domain instance should only be aware of\ndevices and hardware resources accessible to itself.\n\nTo hide domain configuration from domain instances, the following should\nbe done:\n\n* The previous booting stage should preferably provide a separate device\n  tree for each domain instance and mention location of device tree in\n  respective domain instance DT nodes using **next-arg1** DT property.\n* If domain assigned to a HART does not have separate device tree then\n  OpenSBI platform support should remove all domain configuration details\n  from the device tree passed by previous booting stage before passing it\n  to the next booting stage.\n\n### Example\n\n```\n    chosen {\n        opensbi-domains {\n            compatible = \"opensbi,domain,config\";\n\n            tmem: tmem {\n                compatible = \"opensbi,domain,memregion\";\n                base = <0x0 0x80100000>;\n                order = <20>;\n            };\n\n            tuart: tuart {\n                compatible = \"opensbi,domain,memregion\";\n                base = <0x0 0x10011000>;\n                order = <12>;\n                mmio;\n                devices = <&uart1>;\n            };\n\n            allmem: allmem {\n                compatible = \"opensbi,domain,memregion\";\n                base = <0x0 0x0>;\n                order = <64>;\n            };\n\n            tdomain: trusted-domain {\n                compatible = \"opensbi,domain,instance\";\n                possible-harts = <&cpu0>;\n                regions = <&tmem 0x7>, <&tuart 0x7>;\n                boot-hart = <&cpu0>;\n                next-arg1 = <0x0 0x0>;\n                next-addr = <0x0 0x80100000>;\n                next-mode = <0x0>;\n                system-reset-allowed;\n            };\n\n            udomain: untrusted-domain {\n                compatible = \"opensbi,domain,instance\";\n                possible-harts = <&cpu1 &cpu2 &cpu3 &cpu4>;\n                regions = <&tmem 0x0>, <&tuart 0x0>, <&allmem 0x7>;\n            };\n        };\n    };\n\n    cpus {\n        #address-cells = <1>;\n        #size-cells = <0>;\n        timebase-frequency = <10000000>;\n\n        cpu0: cpu@0 {\n            device_type = \"cpu\";\n            reg = <0x00>;\n            compatible = \"riscv\";\n            opensbi-domain = <&tdomain>;\n            ...\n        };\n\n        cpu1: cpu@1 {\n            device_type = \"cpu\";\n            reg = <0x01>;\n            compatible = \"riscv\";\n            opensbi-domain = <&udomain>;\n            ...\n        };\n\n        cpu2: cpu@2 {\n            device_type = \"cpu\";\n            reg = <0x02>;\n            compatible = \"riscv\";\n            opensbi-domain = <&udomain>;\n            ...\n        };\n\n        cpu3: cpu@3 {\n            device_type = \"cpu\";\n            reg = <0x03>;\n            compatible = \"riscv\";\n            opensbi-domain = <&udomain>;\n            ...\n        };\n\n        cpu4: cpu@4 {\n            device_type = \"cpu\";\n            reg = <0x04>;\n            compatible = \"riscv\";\n            opensbi-domain = <&udomain>;\n            ...\n        };\n    };\n\n    uart1: serial@10011000 {\n        ...\n    };\n```\n"
  },
  {
    "path": "ftpm-opensbi/docs/doxygen.cfg",
    "content": "# Doxyfile 1.8.13\n\n# This file describes the settings to be used by the documentation system\n# doxygen (www.doxygen.org) for a project.\n#\n# All text after a double hash (##) is considered a comment and is placed in\n# front of the TAG it is preceding.\n#\n# All text after a single hash (#) is considered a comment and will be ignored.\n# The format is:\n# TAG = value [value, ...]\n# For lists, items can also be appended using:\n# TAG += value [value, ...]\n# Values that contain spaces should be placed between quotes (\\\" \\\").\n\n#---------------------------------------------------------------------------\n# Project related configuration options\n#---------------------------------------------------------------------------\n\n# This tag specifies the encoding used for all characters in the config file\n# that follow. The default is UTF-8 which is also the encoding used for all text\n# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv\n# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv\n# for the list of possible encodings.\n# The default value is: UTF-8.\n\nDOXYFILE_ENCODING      = UTF-8\n\n# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by\n# double-quotes, unless you are using Doxywizard) that should identify the\n# project for which the documentation is generated. This name is used in the\n# title of most generated pages and in a few other places.\n# The default value is: My Project.\n\nPROJECT_NAME           = \"RISC-V OpenSBI\"\n\n# The PROJECT_NUMBER tag can be used to enter a project or revision number. This\n# could be handy for archiving the generated documentation or if some version\n# control system is used.\n\nPROJECT_NUMBER         = \"v@@OPENSBI_MAJOR@@.@@OPENSBI_MINOR@@\"\n\n# Using the PROJECT_BRIEF tag one can provide an optional one line description\n# for a project that appears at the top of each page and should give viewer a\n# quick idea about the purpose of the project. Keep the description short.\n\nPROJECT_BRIEF          = \"Open source implemenation of the supervisor binary interface\"\n\n# With the PROJECT_LOGO tag one can specify a logo or an icon that is included\n# in the documentation. The maximum height of the logo should not exceed 55\n# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy\n# the logo to the output directory.\n\nPROJECT_LOGO           = \n\n# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path\n# into which the generated documentation will be written. If a relative path is\n# entered, it will be relative to the location where doxygen was started. If\n# left blank the current directory will be used.\n\nOUTPUT_DIRECTORY       = @@BUILD_DIR@@/docs\n\n# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-\n# directories (in 2 levels) under the output directory of each output format and\n# will distribute the generated files over these directories. Enabling this\n# option can be useful when feeding doxygen a huge amount of source files, where\n# putting all generated files in the same directory would otherwise causes\n# performance problems for the file system.\n# The default value is: NO.\n\nCREATE_SUBDIRS         = NO\n\n# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII\n# characters to appear in the names of generated files. If set to NO, non-ASCII\n# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode\n# U+3044.\n# The default value is: NO.\n\nALLOW_UNICODE_NAMES    = NO\n\n# The OUTPUT_LANGUAGE tag is used to specify the language in which all\n# documentation generated by doxygen is written. Doxygen will use this\n# information to generate all constant output in the proper language.\n# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,\n# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),\n# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,\n# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),\n# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,\n# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,\n# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,\n# Ukrainian and Vietnamese.\n# The default value is: English.\n\nOUTPUT_LANGUAGE        = English\n\n# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member\n# descriptions after the members that are listed in the file and class\n# documentation (similar to Javadoc). Set to NO to disable this.\n# The default value is: YES.\n\nBRIEF_MEMBER_DESC      = YES\n\n# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief\n# description of a member or function before the detailed description\n#\n# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the\n# brief descriptions will be completely suppressed.\n# The default value is: YES.\n\nREPEAT_BRIEF           = YES\n\n# This tag implements a quasi-intelligent brief description abbreviator that is\n# used to form the text in various listings. Each string in this list, if found\n# as the leading text of the brief description, will be stripped from the text\n# and the result, after processing the whole list, is used as the annotated\n# text. Otherwise, the brief description is used as-is. If left blank, the\n# following values are used ($name is automatically replaced with the name of\n# the entity):The $name class, The $name widget, The $name file, is, provides,\n# specifies, contains, represents, a, an and the.\n\nABBREVIATE_BRIEF       = \"The $name class\" \\\n                         \"The $name widget\" \\\n                         \"The $name file\" \\\n                         is \\\n                         provides \\\n                         specifies \\\n                         contains \\\n                         represents \\\n                         a \\\n                         an \\\n                         the\n\n# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then\n# doxygen will generate a detailed section even if there is only a brief\n# description.\n# The default value is: NO.\n\nALWAYS_DETAILED_SEC    = NO\n\n# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all\n# inherited members of a class in the documentation of that class as if those\n# members were ordinary class members. Constructors, destructors and assignment\n# operators of the base classes will not be shown.\n# The default value is: NO.\n\nINLINE_INHERITED_MEMB  = NO\n\n# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path\n# before files name in the file list and in the header files. If set to NO the\n# shortest path that makes the file name unique will be used\n# The default value is: YES.\n\nFULL_PATH_NAMES        = YES\n\n# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.\n# Stripping is only done if one of the specified strings matches the left-hand\n# part of the path. The tag can be used to show relative paths in the file list.\n# If left blank the directory from which doxygen is run is used as the path to\n# strip.\n#\n# Note that you can specify absolute paths here, but also relative paths, which\n# will be relative from the directory where doxygen is started.\n# This tag requires that the tag FULL_PATH_NAMES is set to YES.\n\nSTRIP_FROM_PATH        = \n\n# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the\n# path mentioned in the documentation of a class, which tells the reader which\n# header file to include in order to use a class. If left blank only the name of\n# the header file containing the class definition is used. Otherwise one should\n# specify the list of include paths that are normally passed to the compiler\n# using the -I flag.\n\nSTRIP_FROM_INC_PATH    = \n\n# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but\n# less readable) file names. This can be useful is your file systems doesn't\n# support long names like on DOS, Mac, or CD-ROM.\n# The default value is: NO.\n\nSHORT_NAMES            = NO\n\n# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the\n# first line (until the first dot) of a Javadoc-style comment as the brief\n# description. If set to NO, the Javadoc-style will behave just like regular Qt-\n# style comments (thus requiring an explicit @brief command for a brief\n# description.)\n# The default value is: NO.\n\nJAVADOC_AUTOBRIEF      = NO\n\n# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first\n# line (until the first dot) of a Qt-style comment as the brief description. If\n# set to NO, the Qt-style will behave just like regular Qt-style comments (thus\n# requiring an explicit \\brief command for a brief description.)\n# The default value is: NO.\n\nQT_AUTOBRIEF           = NO\n\n# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a\n# multi-line C++ special comment block (i.e. a block of //! or /// comments) as\n# a brief description. This used to be the default behavior. The new default is\n# to treat a multi-line C++ comment block as a detailed description. Set this\n# tag to YES if you prefer the old behavior instead.\n#\n# Note that setting this tag to YES also means that rational rose comments are\n# not recognized any more.\n# The default value is: NO.\n\nMULTILINE_CPP_IS_BRIEF = NO\n\n# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the\n# documentation from any documented member that it re-implements.\n# The default value is: YES.\n\nINHERIT_DOCS           = YES\n\n# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new\n# page for each member. If set to NO, the documentation of a member will be part\n# of the file/class/namespace that contains it.\n# The default value is: NO.\n\nSEPARATE_MEMBER_PAGES  = NO\n\n# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen\n# uses this value to replace tabs by spaces in code fragments.\n# Minimum value: 1, maximum value: 16, default value: 4.\n\nTAB_SIZE               = 4\n\n# This tag can be used to specify a number of aliases that act as commands in\n# the documentation. An alias has the form:\n# name=value\n# For example adding\n# \"sideeffect=@par Side Effects:\\n\"\n# will allow you to put the command \\sideeffect (or @sideeffect) in the\n# documentation, which will result in a user-defined paragraph with heading\n# \"Side Effects:\". You can put \\n's in the value part of an alias to insert\n# newlines.\n\nALIASES                = \n\n# This tag can be used to specify a number of word-keyword mappings (TCL only).\n# A mapping has the form \"name=value\". For example adding \"class=itcl::class\"\n# will allow you to use the command class in the itcl::class meaning.\n\nTCL_SUBST              = \n\n# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources\n# only. Doxygen will then generate output that is more tailored for C. For\n# instance, some of the names that are used will be different. The list of all\n# members will be omitted, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_FOR_C  = YES\n\n# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or\n# Python sources only. Doxygen will then generate output that is more tailored\n# for that language. For instance, namespaces will be presented as packages,\n# qualified scopes will look different, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_JAVA   = NO\n\n# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran\n# sources. Doxygen will then generate output that is tailored for Fortran.\n# The default value is: NO.\n\nOPTIMIZE_FOR_FORTRAN   = NO\n\n# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL\n# sources. Doxygen will then generate output that is tailored for VHDL.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_VHDL   = NO\n\n# Doxygen selects the parser to use depending on the extension of the files it\n# parses. With this tag you can assign which parser to use for a given\n# extension. Doxygen has a built-in mapping, but you can override or extend it\n# using this tag. The format is ext=language, where ext is a file extension, and\n# language is one of the parsers supported by doxygen: IDL, Java, Javascript,\n# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:\n# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:\n# Fortran. In the later case the parser tries to guess whether the code is fixed\n# or free formatted code, this is the default for Fortran type files), VHDL. For\n# instance to make doxygen treat .inc files as Fortran files (default is PHP),\n# and .f files as C (default is Fortran), use: inc=Fortran f=C.\n#\n# Note: For files without extension you can use no_extension as a placeholder.\n#\n# Note that for custom extensions you also need to set FILE_PATTERNS otherwise\n# the files are not read by doxygen.\n\nEXTENSION_MAPPING      = \n\n# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments\n# according to the Markdown format, which allows for more readable\n# documentation. See http://daringfireball.net/projects/markdown/ for details.\n# The output of markdown processing is further processed by doxygen, so you can\n# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in\n# case of backward compatibilities issues.\n# The default value is: YES.\n\nMARKDOWN_SUPPORT       = YES\n\n# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up\n# to that level are automatically included in the table of contents, even if\n# they do not have an id attribute.\n# Note: This feature currently applies only to Markdown headings.\n# Minimum value: 0, maximum value: 99, default value: 0.\n# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.\n\nTOC_INCLUDE_HEADINGS   = 0\n\n# When enabled doxygen tries to link words that correspond to documented\n# classes, or namespaces to their corresponding documentation. Such a link can\n# be prevented in individual cases by putting a % sign in front of the word or\n# globally by setting AUTOLINK_SUPPORT to NO.\n# The default value is: YES.\n\nAUTOLINK_SUPPORT       = YES\n\n# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want\n# to include (a tag file for) the STL sources as input, then you should set this\n# tag to YES in order to let doxygen match functions declarations and\n# definitions whose arguments contain STL classes (e.g. func(std::string);\n# versus func(std::string) {}). This also make the inheritance and collaboration\n# diagrams that involve STL classes more complete and accurate.\n# The default value is: NO.\n\nBUILTIN_STL_SUPPORT    = NO\n\n# If you use Microsoft's C++/CLI language, you should set this option to YES to\n# enable parsing support.\n# The default value is: NO.\n\nCPP_CLI_SUPPORT        = NO\n\n# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:\n# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen\n# will parse them like normal C++ but will assume all classes use public instead\n# of private inheritance when no explicit protection keyword is present.\n# The default value is: NO.\n\nSIP_SUPPORT            = NO\n\n# For Microsoft's IDL there are propget and propput attributes to indicate\n# getter and setter methods for a property. Setting this option to YES will make\n# doxygen to replace the get and set methods by a property in the documentation.\n# This will only work if the methods are indeed getting or setting a simple\n# type. If this is not the case, or you want to show the methods anyway, you\n# should set this option to NO.\n# The default value is: YES.\n\nIDL_PROPERTY_SUPPORT   = YES\n\n# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC\n# tag is set to YES then doxygen will reuse the documentation of the first\n# member in the group (if any) for the other members of the group. By default\n# all members of a group must be documented explicitly.\n# The default value is: NO.\n\nDISTRIBUTE_GROUP_DOC   = NO\n\n# If one adds a struct or class to a group and this option is enabled, then also\n# any nested class or struct is added to the same group. By default this option\n# is disabled and one has to add nested compounds explicitly via \\ingroup.\n# The default value is: NO.\n\nGROUP_NESTED_COMPOUNDS = NO\n\n# Set the SUBGROUPING tag to YES to allow class member groups of the same type\n# (for instance a group of public functions) to be put as a subgroup of that\n# type (e.g. under the Public Functions section). Set it to NO to prevent\n# subgrouping. Alternatively, this can be done per class using the\n# \\nosubgrouping command.\n# The default value is: YES.\n\nSUBGROUPING            = YES\n\n# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions\n# are shown inside the group in which they are included (e.g. using \\ingroup)\n# instead of on a separate page (for HTML and Man pages) or section (for LaTeX\n# and RTF).\n#\n# Note that this feature does not work in combination with\n# SEPARATE_MEMBER_PAGES.\n# The default value is: NO.\n\nINLINE_GROUPED_CLASSES = NO\n\n# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions\n# with only public data fields or simple typedef fields will be shown inline in\n# the documentation of the scope in which they are defined (i.e. file,\n# namespace, or group documentation), provided this scope is documented. If set\n# to NO, structs, classes, and unions are shown on a separate page (for HTML and\n# Man pages) or section (for LaTeX and RTF).\n# The default value is: NO.\n\nINLINE_SIMPLE_STRUCTS  = NO\n\n# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or\n# enum is documented as struct, union, or enum with the name of the typedef. So\n# typedef struct TypeS {} TypeT, will appear in the documentation as a struct\n# with name TypeT. When disabled the typedef will appear as a member of a file,\n# namespace, or class. And the struct will be named TypeS. This can typically be\n# useful for C code in case the coding convention dictates that all compound\n# types are typedef'ed and only the typedef is referenced, never the tag name.\n# The default value is: NO.\n\nTYPEDEF_HIDES_STRUCT   = NO\n\n# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This\n# cache is used to resolve symbols given their name and scope. Since this can be\n# an expensive process and often the same symbol appears multiple times in the\n# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small\n# doxygen will become slower. If the cache is too large, memory is wasted. The\n# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range\n# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536\n# symbols. At the end of a run doxygen will report the cache usage and suggest\n# the optimal cache size from a speed point of view.\n# Minimum value: 0, maximum value: 9, default value: 0.\n\nLOOKUP_CACHE_SIZE      = 0\n\n#---------------------------------------------------------------------------\n# Build related configuration options\n#---------------------------------------------------------------------------\n\n# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in\n# documentation are documented, even if no documentation was available. Private\n# class members and static file members will be hidden unless the\n# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.\n# Note: This will also disable the warnings about undocumented members that are\n# normally produced when WARNINGS is set to YES.\n# The default value is: NO.\n\nEXTRACT_ALL            = YES\n\n# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will\n# be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PRIVATE        = NO\n\n# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal\n# scope will be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PACKAGE        = NO\n\n# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be\n# included in the documentation.\n# The default value is: NO.\n\nEXTRACT_STATIC         = YES\n\n# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined\n# locally in source files will be included in the documentation. If set to NO,\n# only classes defined in header files are included. Does not have any effect\n# for Java sources.\n# The default value is: YES.\n\nEXTRACT_LOCAL_CLASSES  = NO\n\n# This flag is only useful for Objective-C code. If set to YES, local methods,\n# which are defined in the implementation section but not in the interface are\n# included in the documentation. If set to NO, only methods in the interface are\n# included.\n# The default value is: NO.\n\nEXTRACT_LOCAL_METHODS  = NO\n\n# If this flag is set to YES, the members of anonymous namespaces will be\n# extracted and appear in the documentation as a namespace called\n# 'anonymous_namespace{file}', where file will be replaced with the base name of\n# the file that contains the anonymous namespace. By default anonymous namespace\n# are hidden.\n# The default value is: NO.\n\nEXTRACT_ANON_NSPACES   = NO\n\n# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all\n# undocumented members inside documented classes or files. If set to NO these\n# members will be included in the various overviews, but no documentation\n# section is generated. This option has no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_MEMBERS     = NO\n\n# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all\n# undocumented classes that are normally visible in the class hierarchy. If set\n# to NO, these classes will be included in the various overviews. This option\n# has no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_CLASSES     = YES\n\n# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend\n# (class|struct|union) declarations. If set to NO, these declarations will be\n# included in the documentation.\n# The default value is: NO.\n\nHIDE_FRIEND_COMPOUNDS  = YES\n\n# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any\n# documentation blocks found inside the body of a function. If set to NO, these\n# blocks will be appended to the function's detailed documentation block.\n# The default value is: NO.\n\nHIDE_IN_BODY_DOCS      = NO\n\n# The INTERNAL_DOCS tag determines if documentation that is typed after a\n# \\internal command is included. If the tag is set to NO then the documentation\n# will be excluded. Set it to YES to include the internal documentation.\n# The default value is: NO.\n\nINTERNAL_DOCS          = NO\n\n# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file\n# names in lower-case letters. If set to YES, upper-case letters are also\n# allowed. This is useful if you have classes or files whose names only differ\n# in case and if your file system supports case sensitive file names. Windows\n# and Mac users are advised to set this option to NO.\n# The default value is: system dependent.\n\nCASE_SENSE_NAMES       = NO\n\n# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with\n# their full class and namespace scopes in the documentation. If set to YES, the\n# scope will be hidden.\n# The default value is: NO.\n\nHIDE_SCOPE_NAMES       = NO\n\n# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will\n# append additional text to a page's title, such as Class Reference. If set to\n# YES the compound reference will be hidden.\n# The default value is: NO.\n\nHIDE_COMPOUND_REFERENCE= NO\n\n# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of\n# the files that are included by a file in the documentation of that file.\n# The default value is: YES.\n\nSHOW_INCLUDE_FILES     = YES\n\n# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each\n# grouped member an include statement to the documentation, telling the reader\n# which file to include in order to use the member.\n# The default value is: NO.\n\nSHOW_GROUPED_MEMB_INC  = NO\n\n# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include\n# files with double quotes in the documentation rather than with sharp brackets.\n# The default value is: NO.\n\nFORCE_LOCAL_INCLUDES   = NO\n\n# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the\n# documentation for inline members.\n# The default value is: YES.\n\nINLINE_INFO            = YES\n\n# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the\n# (detailed) documentation of file and class members alphabetically by member\n# name. If set to NO, the members will appear in declaration order.\n# The default value is: YES.\n\nSORT_MEMBER_DOCS       = YES\n\n# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief\n# descriptions of file, namespace and class members alphabetically by member\n# name. If set to NO, the members will appear in declaration order. Note that\n# this will also influence the order of the classes in the class list.\n# The default value is: NO.\n\nSORT_BRIEF_DOCS        = NO\n\n# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the\n# (brief and detailed) documentation of class members so that constructors and\n# destructors are listed first. If set to NO the constructors will appear in the\n# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.\n# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief\n# member documentation.\n# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting\n# detailed member documentation.\n# The default value is: NO.\n\nSORT_MEMBERS_CTORS_1ST = NO\n\n# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy\n# of group names into alphabetical order. If set to NO the group names will\n# appear in their defined order.\n# The default value is: NO.\n\nSORT_GROUP_NAMES       = NO\n\n# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by\n# fully-qualified names, including namespaces. If set to NO, the class list will\n# be sorted only by class name, not including the namespace part.\n# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.\n# Note: This option applies only to the class list, not to the alphabetical\n# list.\n# The default value is: NO.\n\nSORT_BY_SCOPE_NAME     = NO\n\n# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper\n# type resolution of all parameters of a function it will reject a match between\n# the prototype and the implementation of a member function even if there is\n# only one candidate or it is obvious which candidate to choose by doing a\n# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still\n# accept a match between prototype and implementation in such cases.\n# The default value is: NO.\n\nSTRICT_PROTO_MATCHING  = NO\n\n# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo\n# list. This list is created by putting \\todo commands in the documentation.\n# The default value is: YES.\n\nGENERATE_TODOLIST      = YES\n\n# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test\n# list. This list is created by putting \\test commands in the documentation.\n# The default value is: YES.\n\nGENERATE_TESTLIST      = YES\n\n# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug\n# list. This list is created by putting \\bug commands in the documentation.\n# The default value is: YES.\n\nGENERATE_BUGLIST       = YES\n\n# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)\n# the deprecated list. This list is created by putting \\deprecated commands in\n# the documentation.\n# The default value is: YES.\n\nGENERATE_DEPRECATEDLIST= YES\n\n# The ENABLED_SECTIONS tag can be used to enable conditional documentation\n# sections, marked by \\if <section_label> ... \\endif and \\cond <section_label>\n# ... \\endcond blocks.\n\nENABLED_SECTIONS       = \n\n# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the\n# initial value of a variable or macro / define can have for it to appear in the\n# documentation. If the initializer consists of more lines than specified here\n# it will be hidden. Use a value of 0 to hide initializers completely. The\n# appearance of the value of individual variables and macros / defines can be\n# controlled using \\showinitializer or \\hideinitializer command in the\n# documentation regardless of this setting.\n# Minimum value: 0, maximum value: 10000, default value: 30.\n\nMAX_INITIALIZER_LINES  = 30\n\n# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at\n# the bottom of the documentation of classes and structs. If set to YES, the\n# list will mention the files that were used to generate the documentation.\n# The default value is: YES.\n\nSHOW_USED_FILES        = YES\n\n# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This\n# will remove the Files entry from the Quick Index and from the Folder Tree View\n# (if specified).\n# The default value is: YES.\n\nSHOW_FILES             = YES\n\n# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces\n# page. This will remove the Namespaces entry from the Quick Index and from the\n# Folder Tree View (if specified).\n# The default value is: YES.\n\nSHOW_NAMESPACES        = YES\n\n# The FILE_VERSION_FILTER tag can be used to specify a program or script that\n# doxygen should invoke to get the current version for each file (typically from\n# the version control system). Doxygen will invoke the program by executing (via\n# popen()) the command command input-file, where command is the value of the\n# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided\n# by doxygen. Whatever the program writes to standard output is used as the file\n# version. For an example see the documentation.\n\nFILE_VERSION_FILTER    = \n\n# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed\n# by doxygen. The layout file controls the global structure of the generated\n# output files in an output format independent way. To create the layout file\n# that represents doxygen's defaults, run doxygen with the -l option. You can\n# optionally specify a file name after the option, if omitted DoxygenLayout.xml\n# will be used as the name of the layout file.\n#\n# Note that if you run doxygen from a directory containing a file called\n# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE\n# tag is left empty.\n\nLAYOUT_FILE            = \n\n# The CITE_BIB_FILES tag can be used to specify one or more bib files containing\n# the reference definitions. This must be a list of .bib files. The .bib\n# extension is automatically appended if omitted. This requires the bibtex tool\n# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.\n# For LaTeX the style of the bibliography can be controlled using\n# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the\n# search path. See also \\cite for info how to create references.\n\nCITE_BIB_FILES         = \n\n#---------------------------------------------------------------------------\n# Configuration options related to warning and progress messages\n#---------------------------------------------------------------------------\n\n# The QUIET tag can be used to turn on/off the messages that are generated to\n# standard output by doxygen. If QUIET is set to YES this implies that the\n# messages are off.\n# The default value is: NO.\n\nQUIET                  = NO\n\n# The WARNINGS tag can be used to turn on/off the warning messages that are\n# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES\n# this implies that the warnings are on.\n#\n# Tip: Turn warnings on while writing the documentation.\n# The default value is: YES.\n\nWARNINGS               = YES\n\n# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate\n# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag\n# will automatically be disabled.\n# The default value is: YES.\n\nWARN_IF_UNDOCUMENTED   = YES\n\n# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for\n# potential errors in the documentation, such as not documenting some parameters\n# in a documented function, or documenting parameters that don't exist or using\n# markup commands wrongly.\n# The default value is: YES.\n\nWARN_IF_DOC_ERROR      = YES\n\n# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that\n# are documented, but have no documentation for their parameters or return\n# value. If set to NO, doxygen will only warn about wrong or incomplete\n# parameter documentation, but not about the absence of documentation.\n# The default value is: NO.\n\nWARN_NO_PARAMDOC       = NO\n\n# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when\n# a warning is encountered.\n# The default value is: NO.\n\nWARN_AS_ERROR          = NO\n\n# The WARN_FORMAT tag determines the format of the warning messages that doxygen\n# can produce. The string should contain the $file, $line, and $text tags, which\n# will be replaced by the file and line number from which the warning originated\n# and the warning text. Optionally the format may contain $version, which will\n# be replaced by the version of the file (if it could be obtained via\n# FILE_VERSION_FILTER)\n# The default value is: $file:$line: $text.\n\nWARN_FORMAT            = \"$file:$line: $text\"\n\n# The WARN_LOGFILE tag can be used to specify a file to which warning and error\n# messages should be written. If left blank the output is written to standard\n# error (stderr).\n\nWARN_LOGFILE           = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the input files\n#---------------------------------------------------------------------------\n\n# The INPUT tag is used to specify the files and/or directories that contain\n# documented source files. You may enter file names like myfile.cpp or\n# directories like /usr/src/myproject. Separate the files or directories with\n# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING\n# Note: If this tag is empty the current directory is searched.\n\nINPUT                  = @@SRC_DIR@@/README.md \\\n                         @@SRC_DIR@@/docs/contributing.md \\\n                         @@SRC_DIR@@/docs/platform_guide.md \\\n                         @@SRC_DIR@@/docs/platform_requirements.md \\\n                         @@SRC_DIR@@/docs/library_usage.md \\\n                         @@SRC_DIR@@/docs/domain_support.md \\\n                         @@SRC_DIR@@/docs/firmware \\\n                         @@SRC_DIR@@/docs/platform \\\n                         @@SRC_DIR@@/include \\\n                         @@SRC_DIR@@/lib\n\n# This tag can be used to specify the character encoding of the source files\n# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses\n# libiconv (or the iconv built into libc) for the transcoding. See the libiconv\n# documentation (see: http://www.gnu.org/software/libiconv) for the list of\n# possible encodings.\n# The default value is: UTF-8.\n\nINPUT_ENCODING         = UTF-8\n\n# If the value of the INPUT tag contains directories, you can use the\n# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and\n# *.h) to filter out the source-files in the directories.\n#\n# Note that for custom extensions or not directly supported extensions you also\n# need to set EXTENSION_MAPPING for the extension otherwise the files are not\n# read by doxygen.\n#\n# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,\n# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,\n# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,\n# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08,\n# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf and *.qsf.\n\nFILE_PATTERNS          = *.c \\\n                         *.h \\\n                         *.md\n\n# The RECURSIVE tag can be used to specify whether or not subdirectories should\n# be searched for input files as well.\n# The default value is: NO.\n\nRECURSIVE              = YES\n\n# The EXCLUDE tag can be used to specify files and/or directories that should be\n# excluded from the INPUT source files. This way you can easily exclude a\n# subdirectory from a directory tree whose root is specified with the INPUT tag.\n#\n# Note that relative paths are relative to the directory from which doxygen is\n# run.\n\nEXCLUDE                = \n\n# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or\n# directories that are symbolic links (a Unix file system feature) are excluded\n# from the input.\n# The default value is: NO.\n\nEXCLUDE_SYMLINKS       = NO\n\n# If the value of the INPUT tag contains directories, you can use the\n# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude\n# certain files from those directories.\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories for example use the pattern */test/*\n\nEXCLUDE_PATTERNS       = \n\n# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names\n# (namespaces, classes, functions, etc.) that should be excluded from the\n# output. The symbol name can be a fully qualified name, a word, or if the\n# wildcard * is used, a substring. Examples: ANamespace, AClass,\n# AClass::ANamespace, ANamespace::*Test\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories use the pattern */test/*\n\nEXCLUDE_SYMBOLS        = \n\n# The EXAMPLE_PATH tag can be used to specify one or more files or directories\n# that contain example code fragments that are included (see the \\include\n# command).\n\nEXAMPLE_PATH           = \n\n# If the value of the EXAMPLE_PATH tag contains directories, you can use the\n# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank all\n# files are included.\n\nEXAMPLE_PATTERNS       = *\n\n# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be\n# searched for input files to be used with the \\include or \\dontinclude commands\n# irrespective of the value of the RECURSIVE tag.\n# The default value is: NO.\n\nEXAMPLE_RECURSIVE      = NO\n\n# The IMAGE_PATH tag can be used to specify one or more files or directories\n# that contain images that are to be included in the documentation (see the\n# \\image command).\n\nIMAGE_PATH             = \n\n# The INPUT_FILTER tag can be used to specify a program that doxygen should\n# invoke to filter for each input file. Doxygen will invoke the filter program\n# by executing (via popen()) the command:\n#\n# <filter> <input-file>\n#\n# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the\n# name of an input file. Doxygen will then use the output that the filter\n# program writes to standard output. If FILTER_PATTERNS is specified, this tag\n# will be ignored.\n#\n# Note that the filter must not add or remove lines; it is applied before the\n# code is scanned, but not when the output code is generated. If lines are added\n# or removed, the anchors will not be placed correctly.\n#\n# Note that for custom extensions or not directly supported extensions you also\n# need to set EXTENSION_MAPPING for the extension otherwise the files are not\n# properly processed by doxygen.\n\nINPUT_FILTER           = \n\n# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern\n# basis. Doxygen will compare the file name with each pattern and apply the\n# filter if there is a match. The filters are a list of the form: pattern=filter\n# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how\n# filters are used. If the FILTER_PATTERNS tag is empty or if none of the\n# patterns match the file name, INPUT_FILTER is applied.\n#\n# Note that for custom extensions or not directly supported extensions you also\n# need to set EXTENSION_MAPPING for the extension otherwise the files are not\n# properly processed by doxygen.\n\nFILTER_PATTERNS        = \n\n# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using\n# INPUT_FILTER) will also be used to filter the input files that are used for\n# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).\n# The default value is: NO.\n\nFILTER_SOURCE_FILES    = NO\n\n# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file\n# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and\n# it is also possible to disable source filtering for a specific pattern using\n# *.ext= (so without naming a filter).\n# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.\n\nFILTER_SOURCE_PATTERNS = \n\n# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that\n# is part of the input, its contents will be placed on the main page\n# (index.html). This can be useful if you have a project on for instance GitHub\n# and want to reuse the introduction page also for the doxygen output.\n\nUSE_MDFILE_AS_MAINPAGE = README.md\n\n#---------------------------------------------------------------------------\n# Configuration options related to source browsing\n#---------------------------------------------------------------------------\n\n# If the SOURCE_BROWSER tag is set to YES then a list of source files will be\n# generated. Documented entities will be cross-referenced with these sources.\n#\n# Note: To get rid of all source code in the generated output, make sure that\n# also VERBATIM_HEADERS is set to NO.\n# The default value is: NO.\n\nSOURCE_BROWSER         = NO\n\n# Setting the INLINE_SOURCES tag to YES will include the body of functions,\n# classes and enums directly into the documentation.\n# The default value is: NO.\n\nINLINE_SOURCES         = NO\n\n# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any\n# special comment blocks from generated source code fragments. Normal C, C++ and\n# Fortran comments will always remain visible.\n# The default value is: YES.\n\nSTRIP_CODE_COMMENTS    = YES\n\n# If the REFERENCED_BY_RELATION tag is set to YES then for each documented\n# function all documented functions referencing it will be listed.\n# The default value is: NO.\n\nREFERENCED_BY_RELATION = NO\n\n# If the REFERENCES_RELATION tag is set to YES then for each documented function\n# all documented entities called/used by that function will be listed.\n# The default value is: NO.\n\nREFERENCES_RELATION    = NO\n\n# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set\n# to YES then the hyperlinks from functions in REFERENCES_RELATION and\n# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will\n# link to the documentation.\n# The default value is: YES.\n\nREFERENCES_LINK_SOURCE = YES\n\n# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the\n# source code will show a tooltip with additional information such as prototype,\n# brief description and links to the definition and documentation. Since this\n# will make the HTML file larger and loading of large files a bit slower, you\n# can opt to disable this feature.\n# The default value is: YES.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nSOURCE_TOOLTIPS        = YES\n\n# If the USE_HTAGS tag is set to YES then the references to source code will\n# point to the HTML generated by the htags(1) tool instead of doxygen built-in\n# source browser. The htags tool is part of GNU's global source tagging system\n# (see http://www.gnu.org/software/global/global.html). You will need version\n# 4.8.6 or higher.\n#\n# To use it do the following:\n# - Install the latest version of global\n# - Enable SOURCE_BROWSER and USE_HTAGS in the config file\n# - Make sure the INPUT points to the root of the source tree\n# - Run doxygen as normal\n#\n# Doxygen will invoke htags (and that will in turn invoke gtags), so these\n# tools must be available from the command line (i.e. in the search path).\n#\n# The result: instead of the source browser generated by doxygen, the links to\n# source code will now point to the output of htags.\n# The default value is: NO.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nUSE_HTAGS              = NO\n\n# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a\n# verbatim copy of the header file for each class for which an include is\n# specified. Set to NO to disable this.\n# See also: Section \\class.\n# The default value is: YES.\n\nVERBATIM_HEADERS       = YES\n\n# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the\n# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the\n# cost of reduced performance. This can be particularly helpful with template\n# rich C++ code for which doxygen's built-in parser lacks the necessary type\n# information.\n# Note: The availability of this option depends on whether or not doxygen was\n# generated with the -Duse-libclang=ON option for CMake.\n# The default value is: NO.\n\nCLANG_ASSISTED_PARSING = NO\n\n# If clang assisted parsing is enabled you can provide the compiler with command\n# line options that you would normally use when invoking the compiler. Note that\n# the include paths will already be set by doxygen for the files and directories\n# specified with INPUT and INCLUDE_PATH.\n# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.\n\nCLANG_OPTIONS          = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the alphabetical class index\n#---------------------------------------------------------------------------\n\n# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all\n# compounds will be generated. Enable this if the project contains a lot of\n# classes, structs, unions or interfaces.\n# The default value is: YES.\n\nALPHABETICAL_INDEX     = YES\n\n# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in\n# which the alphabetical index list will be split.\n# Minimum value: 1, maximum value: 20, default value: 5.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nCOLS_IN_ALPHA_INDEX    = 5\n\n# In case all classes in a project start with a common prefix, all classes will\n# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag\n# can be used to specify a prefix (or a list of prefixes) that should be ignored\n# while generating the index headers.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nIGNORE_PREFIX          = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the HTML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output\n# The default value is: YES.\n\nGENERATE_HTML          = YES\n\n# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_OUTPUT            = html\n\n# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each\n# generated HTML page (for example: .htm, .php, .asp).\n# The default value is: .html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FILE_EXTENSION    = .html\n\n# The HTML_HEADER tag can be used to specify a user-defined HTML header file for\n# each generated HTML page. If the tag is left blank doxygen will generate a\n# standard header.\n#\n# To get valid HTML the header file that includes any scripts and style sheets\n# that doxygen needs, which is dependent on the configuration options used (e.g.\n# the setting GENERATE_TREEVIEW). It is highly recommended to start with a\n# default header using\n# doxygen -w html new_header.html new_footer.html new_stylesheet.css\n# YourConfigFile\n# and then modify the file new_header.html. See also section \"Doxygen usage\"\n# for information on how to generate the default header that doxygen normally\n# uses.\n# Note: The header is subject to change so you typically have to regenerate the\n# default header when upgrading to a newer version of doxygen. For a description\n# of the possible markers and block names see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_HEADER            = \n\n# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each\n# generated HTML page. If the tag is left blank doxygen will generate a standard\n# footer. See HTML_HEADER for more information on how to generate a default\n# footer and what special commands can be used inside the footer. See also\n# section \"Doxygen usage\" for information on how to generate the default footer\n# that doxygen normally uses.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FOOTER            = \n\n# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style\n# sheet that is used by each HTML page. It can be used to fine-tune the look of\n# the HTML output. If left blank doxygen will generate a default style sheet.\n# See also section \"Doxygen usage\" for information on how to generate the style\n# sheet that doxygen normally uses.\n# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as\n# it is more robust and this tag (HTML_STYLESHEET) will in the future become\n# obsolete.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_STYLESHEET        = \n\n# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined\n# cascading style sheets that are included after the standard style sheets\n# created by doxygen. Using this option one can overrule certain style aspects.\n# This is preferred over using HTML_STYLESHEET since it does not replace the\n# standard style sheet and is therefore more robust against future updates.\n# Doxygen will copy the style sheet files to the output directory.\n# Note: The order of the extra style sheet files is of importance (e.g. the last\n# style sheet in the list overrules the setting of the previous ones in the\n# list). For an example see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_STYLESHEET  = \n\n# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the HTML output directory. Note\n# that these files will be copied to the base HTML output directory. Use the\n# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these\n# files. In the HTML_STYLESHEET file, use the file name only. Also note that the\n# files will be copied as-is; there are no commands or markers available.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_FILES       = \n\n# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen\n# will adjust the colors in the style sheet and background images according to\n# this color. Hue is specified as an angle on a colorwheel, see\n# http://en.wikipedia.org/wiki/Hue for more information. For instance the value\n# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300\n# purple, and 360 is red again.\n# Minimum value: 0, maximum value: 359, default value: 220.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_HUE    = 220\n\n# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors\n# in the HTML output. For a value of 0 the output will use grayscales only. A\n# value of 255 will produce the most vivid colors.\n# Minimum value: 0, maximum value: 255, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_SAT    = 100\n\n# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the\n# luminance component of the colors in the HTML output. Values below 100\n# gradually make the output lighter, whereas values above 100 make the output\n# darker. The value divided by 100 is the actual gamma applied, so 80 represents\n# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not\n# change the gamma.\n# Minimum value: 40, maximum value: 240, default value: 80.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_GAMMA  = 80\n\n# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML\n# page will contain the date and time when the page was generated. Setting this\n# to YES can help to show when doxygen was last run and thus if the\n# documentation is up to date.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_TIMESTAMP         = NO\n\n# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML\n# documentation will contain sections that can be hidden and shown after the\n# page has loaded.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_DYNAMIC_SECTIONS  = NO\n\n# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries\n# shown in the various tree structured indices initially; the user can expand\n# and collapse entries dynamically later on. Doxygen will expand the tree to\n# such a level that at most the specified number of entries are visible (unless\n# a fully collapsed tree already exceeds this amount). So setting the number of\n# entries 1 will produce a full collapsed tree by default. 0 is a special value\n# representing an infinite number of entries and will result in a full expanded\n# tree by default.\n# Minimum value: 0, maximum value: 9999, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_INDEX_NUM_ENTRIES = 100\n\n# If the GENERATE_DOCSET tag is set to YES, additional index files will be\n# generated that can be used as input for Apple's Xcode 3 integrated development\n# environment (see: http://developer.apple.com/tools/xcode/), introduced with\n# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a\n# Makefile in the HTML output directory. Running make will produce the docset in\n# that directory and running make install will install the docset in\n# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at\n# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html\n# for more information.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_DOCSET        = NO\n\n# This tag determines the name of the docset feed. A documentation feed provides\n# an umbrella under which multiple documentation sets from a single provider\n# (such as a company or product suite) can be grouped.\n# The default value is: Doxygen generated docs.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_FEEDNAME        = \"Doxygen generated docs\"\n\n# This tag specifies a string that should uniquely identify the documentation\n# set bundle. This should be a reverse domain-name style string, e.g.\n# com.mycompany.MyDocSet. Doxygen will append .docset to the name.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_BUNDLE_ID       = org.doxygen.Project\n\n# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify\n# the documentation publisher. This should be a reverse domain-name style\n# string, e.g. com.mycompany.MyDocSet.documentation.\n# The default value is: org.doxygen.Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_ID    = org.doxygen.Publisher\n\n# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.\n# The default value is: Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_NAME  = Publisher\n\n# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three\n# additional HTML index files: index.hhp, index.hhc, and index.hhk. The\n# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop\n# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on\n# Windows.\n#\n# The HTML Help Workshop contains a compiler that can convert all HTML output\n# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML\n# files are now used as the Windows 98 help format, and will replace the old\n# Windows help format (.hlp) on all Windows platforms in the future. Compressed\n# HTML files also contain an index, a table of contents, and you can search for\n# words in the documentation. The HTML workshop also contains a viewer for\n# compressed HTML files.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_HTMLHELP      = NO\n\n# The CHM_FILE tag can be used to specify the file name of the resulting .chm\n# file. You can add a path in front of the file if the result should not be\n# written to the html output directory.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_FILE               = \n\n# The HHC_LOCATION tag can be used to specify the location (absolute path\n# including file name) of the HTML help compiler (hhc.exe). If non-empty,\n# doxygen will try to run the HTML help compiler on the generated index.hhp.\n# The file has to be specified with full path.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nHHC_LOCATION           = \n\n# The GENERATE_CHI flag controls if a separate .chi index file is generated\n# (YES) or that it should be included in the master .chm file (NO).\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nGENERATE_CHI           = NO\n\n# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)\n# and project file content.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_INDEX_ENCODING     = \n\n# The BINARY_TOC flag controls whether a binary table of contents is generated\n# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it\n# enables the Previous and Next buttons.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nBINARY_TOC             = NO\n\n# The TOC_EXPAND flag can be set to YES to add extra items for group members to\n# the table of contents of the HTML help documentation and to the tree view.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nTOC_EXPAND             = NO\n\n# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and\n# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that\n# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help\n# (.qch) of the generated HTML documentation.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_QHP           = NO\n\n# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify\n# the file name of the resulting .qch file. The path specified is relative to\n# the HTML output folder.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQCH_FILE               = \n\n# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help\n# Project output. For more information please see Qt Help Project / Namespace\n# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_NAMESPACE          = org.doxygen.Project\n\n# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt\n# Help Project output. For more information please see Qt Help Project / Virtual\n# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-\n# folders).\n# The default value is: doc.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_VIRTUAL_FOLDER     = doc\n\n# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom\n# filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_NAME   = \n\n# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the\n# custom filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_ATTRS  = \n\n# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this\n# project's filter section matches. Qt Help Project / Filter Attributes (see:\n# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_SECT_FILTER_ATTRS  = \n\n# The QHG_LOCATION tag can be used to specify the location of Qt's\n# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the\n# generated .qhp file.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHG_LOCATION           = \n\n# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be\n# generated, together with the HTML files, they form an Eclipse help plugin. To\n# install this plugin and make it available under the help contents menu in\n# Eclipse, the contents of the directory containing the HTML and XML files needs\n# to be copied into the plugins directory of eclipse. The name of the directory\n# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.\n# After copying Eclipse needs to be restarted before the help appears.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_ECLIPSEHELP   = NO\n\n# A unique identifier for the Eclipse help plugin. When installing the plugin\n# the directory name containing the HTML and XML files should also have this\n# name. Each documentation set should have its own identifier.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.\n\nECLIPSE_DOC_ID         = org.doxygen.Project\n\n# If you want full control over the layout of the generated HTML pages it might\n# be necessary to disable the index and replace it with your own. The\n# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top\n# of each HTML page. A value of NO enables the index and the value YES disables\n# it. Since the tabs in the index contain the same information as the navigation\n# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nDISABLE_INDEX          = NO\n\n# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index\n# structure should be generated to display hierarchical information. If the tag\n# value is set to YES, a side panel will be generated containing a tree-like\n# index structure (just like the one that is generated for HTML Help). For this\n# to work a browser that supports JavaScript, DHTML, CSS and frames is required\n# (i.e. any modern browser). Windows users are probably better off using the\n# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can\n# further fine-tune the look of the index. As an example, the default style\n# sheet generated by doxygen has an example that shows how to put an image at\n# the root of the tree instead of the PROJECT_NAME. Since the tree basically has\n# the same information as the tab index, you could consider setting\n# DISABLE_INDEX to YES when enabling this option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_TREEVIEW      = YES\n\n# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that\n# doxygen will group on one line in the generated HTML documentation.\n#\n# Note that a value of 0 will completely suppress the enum values from appearing\n# in the overview section.\n# Minimum value: 0, maximum value: 20, default value: 4.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nENUM_VALUES_PER_LINE   = 4\n\n# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used\n# to set the initial width (in pixels) of the frame in which the tree is shown.\n# Minimum value: 0, maximum value: 1500, default value: 250.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nTREEVIEW_WIDTH         = 250\n\n# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to\n# external symbols imported via tag files in a separate window.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nEXT_LINKS_IN_WINDOW    = NO\n\n# Use this tag to change the font size of LaTeX formulas included as images in\n# the HTML documentation. When you change the font size after a successful\n# doxygen run you need to manually remove any form_*.png images from the HTML\n# output directory to force them to be regenerated.\n# Minimum value: 8, maximum value: 50, default value: 10.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_FONTSIZE       = 10\n\n# Use the FORMULA_TRANPARENT tag to determine whether or not the images\n# generated for formulas are transparent PNGs. Transparent PNGs are not\n# supported properly for IE 6.0, but are supported on all modern browsers.\n#\n# Note that when changing this option you need to delete any form_*.png files in\n# the HTML output directory before the changes have effect.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_TRANSPARENT    = YES\n\n# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see\n# http://www.mathjax.org) which uses client side Javascript for the rendering\n# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX\n# installed or if you want to formulas look prettier in the HTML output. When\n# enabled you may also need to install MathJax separately and configure the path\n# to it using the MATHJAX_RELPATH option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nUSE_MATHJAX            = NO\n\n# When MathJax is enabled you can set the default output format to be used for\n# the MathJax output. See the MathJax site (see:\n# http://docs.mathjax.org/en/latest/output.html) for more details.\n# Possible values are: HTML-CSS (which is slower, but has the best\n# compatibility), NativeMML (i.e. MathML) and SVG.\n# The default value is: HTML-CSS.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_FORMAT         = HTML-CSS\n\n# When MathJax is enabled you need to specify the location relative to the HTML\n# output directory using the MATHJAX_RELPATH option. The destination directory\n# should contain the MathJax.js script. For instance, if the mathjax directory\n# is located at the same level as the HTML output directory, then\n# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax\n# Content Delivery Network so you can quickly see the result without installing\n# MathJax. However, it is strongly recommended to install a local copy of\n# MathJax from http://www.mathjax.org before deployment.\n# The default value is: http://cdn.mathjax.org/mathjax/latest.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest\n\n# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax\n# extension names that should be enabled during MathJax rendering. For example\n# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_EXTENSIONS     = \n\n# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces\n# of code that will be used on startup of the MathJax code. See the MathJax site\n# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an\n# example see the documentation.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_CODEFILE       = \n\n# When the SEARCHENGINE tag is enabled doxygen will generate a search box for\n# the HTML output. The underlying search engine uses javascript and DHTML and\n# should work on any modern browser. Note that when using HTML help\n# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)\n# there is already a search function so this one should typically be disabled.\n# For large projects the javascript based search engine can be slow, then\n# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to\n# search using the keyboard; to jump to the search box use <access key> + S\n# (what the <access key> is depends on the OS and browser, but it is typically\n# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down\n# key> to jump into the search results window, the results can be navigated\n# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel\n# the search. The filter options can be selected when the cursor is inside the\n# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>\n# to select a filter and <Enter> or <escape> to activate or cancel the filter\n# option.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nSEARCHENGINE           = YES\n\n# When the SERVER_BASED_SEARCH tag is enabled the search engine will be\n# implemented using a web server instead of a web client using Javascript. There\n# are two flavors of web server based searching depending on the EXTERNAL_SEARCH\n# setting. When disabled, doxygen will generate a PHP script for searching and\n# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing\n# and searching needs to be provided by external tools. See the section\n# \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSERVER_BASED_SEARCH    = NO\n\n# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP\n# script for searching. Instead the search results are written to an XML file\n# which needs to be processed by an external indexer. Doxygen will invoke an\n# external search engine pointed to by the SEARCHENGINE_URL option to obtain the\n# search results.\n#\n# Doxygen ships with an example indexer (doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/).\n#\n# See the section \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH        = NO\n\n# The SEARCHENGINE_URL should point to a search engine hosted by a web server\n# which will return the search results when EXTERNAL_SEARCH is enabled.\n#\n# Doxygen ships with an example indexer (doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/). See the section \"External Indexing and\n# Searching\" for details.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHENGINE_URL       = \n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed\n# search data is written to a file for indexing by an external tool. With the\n# SEARCHDATA_FILE tag the name of this file can be specified.\n# The default file is: searchdata.xml.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHDATA_FILE        = searchdata.xml\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the\n# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is\n# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple\n# projects and redirect the results back to the right project.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH_ID     = \n\n# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen\n# projects other than the one defined by this configuration file, but that are\n# all added to the same external search index. Each project needs to have a\n# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of\n# to a relative location where the documentation can be found. The format is:\n# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTRA_SEARCH_MAPPINGS  = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the LaTeX output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.\n# The default value is: YES.\n\nGENERATE_LATEX         = YES\n\n# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_OUTPUT           = latex\n\n# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be\n# invoked.\n#\n# Note that when enabling USE_PDFLATEX this option is only used for generating\n# bitmaps for formulas in the HTML output, but not in the Makefile that is\n# written to the output directory.\n# The default file is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_CMD_NAME         = latex\n\n# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate\n# index for LaTeX.\n# The default file is: makeindex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nMAKEINDEX_CMD_NAME     = makeindex\n\n# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nCOMPACT_LATEX          = NO\n\n# The PAPER_TYPE tag can be used to set the paper type that is used by the\n# printer.\n# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x\n# 14 inches) and executive (7.25 x 10.5 inches).\n# The default value is: a4.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPAPER_TYPE             = a4\n\n# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names\n# that should be included in the LaTeX output. The package can be specified just\n# by its name or with the correct syntax as to be used with the LaTeX\n# \\usepackage command. To get the times font for instance you can specify :\n# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}\n# To use the option intlimits with the amsmath package you can specify:\n# EXTRA_PACKAGES=[intlimits]{amsmath}\n# If left blank no extra packages will be included.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nEXTRA_PACKAGES         = \n\n# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the\n# generated LaTeX document. The header should contain everything until the first\n# chapter. If it is left blank doxygen will generate a standard header. See\n# section \"Doxygen usage\" for information on how to let doxygen write the\n# default header to a separate file.\n#\n# Note: Only use a user-defined header if you know what you are doing! The\n# following commands have a special meaning inside the header: $title,\n# $datetime, $date, $doxygenversion, $projectname, $projectnumber,\n# $projectbrief, $projectlogo. Doxygen will replace $title with the empty\n# string, for the replacement values of the other commands the user is referred\n# to HTML_HEADER.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HEADER           = \n\n# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the\n# generated LaTeX document. The footer should contain everything after the last\n# chapter. If it is left blank doxygen will generate a standard footer. See\n# LATEX_HEADER for more information on how to generate a default footer and what\n# special commands can be used inside the footer.\n#\n# Note: Only use a user-defined footer if you know what you are doing!\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_FOOTER           = \n\n# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined\n# LaTeX style sheets that are included after the standard style sheets created\n# by doxygen. Using this option one can overrule certain style aspects. Doxygen\n# will copy the style sheet files to the output directory.\n# Note: The order of the extra style sheet files is of importance (e.g. the last\n# style sheet in the list overrules the setting of the previous ones in the\n# list).\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_EXTRA_STYLESHEET = \n\n# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the LATEX_OUTPUT output\n# directory. Note that the files will be copied as-is; there are no commands or\n# markers available.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_EXTRA_FILES      = \n\n# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is\n# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will\n# contain links (just like the HTML output) instead of page references. This\n# makes the output suitable for online browsing using a PDF viewer.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPDF_HYPERLINKS         = YES\n\n# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate\n# the PDF file directly from the LaTeX files. Set this option to YES, to get a\n# higher quality PDF documentation.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nUSE_PDFLATEX           = YES\n\n# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode\n# command to the generated LaTeX files. This will instruct LaTeX to keep running\n# if errors occur, instead of asking the user for help. This option is also used\n# when generating formulas in HTML.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BATCHMODE        = NO\n\n# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the\n# index chapters (such as File Index, Compound Index, etc.) in the output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HIDE_INDICES     = NO\n\n# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source\n# code with syntax highlighting in the LaTeX output.\n#\n# Note that which sources are shown also depends on other settings such as\n# SOURCE_BROWSER.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_SOURCE_CODE      = NO\n\n# The LATEX_BIB_STYLE tag can be used to specify the style to use for the\n# bibliography, e.g. plainnat, or ieeetr. See\n# http://en.wikipedia.org/wiki/BibTeX and \\cite for more info.\n# The default value is: plain.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BIB_STYLE        = plain\n\n# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated\n# page will contain the date and time when the page was generated. Setting this\n# to NO can help when comparing the output of multiple runs.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_TIMESTAMP        = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the RTF output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The\n# RTF output is optimized for Word 97 and may not look too pretty with other RTF\n# readers/editors.\n# The default value is: NO.\n\nGENERATE_RTF           = NO\n\n# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: rtf.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_OUTPUT             = rtf\n\n# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nCOMPACT_RTF            = NO\n\n# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will\n# contain hyperlink fields. The RTF file will contain links (just like the HTML\n# output) instead of page references. This makes the output suitable for online\n# browsing using Word or some other Word compatible readers that support those\n# fields.\n#\n# Note: WordPad (write) and others do not support links.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_HYPERLINKS         = NO\n\n# Load stylesheet definitions from file. Syntax is similar to doxygen's config\n# file, i.e. a series of assignments. You only have to provide replacements,\n# missing definitions are set to their default value.\n#\n# See also section \"Doxygen usage\" for information on how to generate the\n# default style sheet that doxygen normally uses.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_STYLESHEET_FILE    = \n\n# Set optional variables used in the generation of an RTF document. Syntax is\n# similar to doxygen's config file. A template extensions file can be generated\n# using doxygen -e rtf extensionFile.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_EXTENSIONS_FILE    = \n\n# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code\n# with syntax highlighting in the RTF output.\n#\n# Note that which sources are shown also depends on other settings such as\n# SOURCE_BROWSER.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_SOURCE_CODE        = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the man page output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for\n# classes and files.\n# The default value is: NO.\n\nGENERATE_MAN           = NO\n\n# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it. A directory man3 will be created inside the directory specified by\n# MAN_OUTPUT.\n# The default directory is: man.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_OUTPUT             = man\n\n# The MAN_EXTENSION tag determines the extension that is added to the generated\n# man pages. In case the manual section does not start with a number, the number\n# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is\n# optional.\n# The default value is: .3.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_EXTENSION          = .3\n\n# The MAN_SUBDIR tag determines the name of the directory created within\n# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by\n# MAN_EXTENSION with the initial . removed.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_SUBDIR             = \n\n# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it\n# will generate one additional man file for each entity documented in the real\n# man page(s). These additional files only source the real man page, but without\n# them the man command would be unable to find the correct page.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_LINKS              = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the XML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that\n# captures the structure of the code including all documentation.\n# The default value is: NO.\n\nGENERATE_XML           = NO\n\n# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: xml.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_OUTPUT             = xml\n\n# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program\n# listings (including syntax highlighting and cross-referencing information) to\n# the XML output. Note that enabling this will significantly increase the size\n# of the XML output.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_PROGRAMLISTING     = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to the DOCBOOK output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files\n# that can be used to generate PDF.\n# The default value is: NO.\n\nGENERATE_DOCBOOK       = NO\n\n# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in\n# front of it.\n# The default directory is: docbook.\n# This tag requires that the tag GENERATE_DOCBOOK is set to YES.\n\nDOCBOOK_OUTPUT         = docbook\n\n# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the\n# program listings (including syntax highlighting and cross-referencing\n# information) to the DOCBOOK output. Note that enabling this will significantly\n# increase the size of the DOCBOOK output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_DOCBOOK is set to YES.\n\nDOCBOOK_PROGRAMLISTING = NO\n\n#---------------------------------------------------------------------------\n# Configuration options for the AutoGen Definitions output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an\n# AutoGen Definitions (see http://autogen.sf.net) file that captures the\n# structure of the code including all documentation. Note that this feature is\n# still experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_AUTOGEN_DEF   = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the Perl module output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module\n# file that captures the structure of the code including all documentation.\n#\n# Note that this feature is still experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_PERLMOD       = NO\n\n# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary\n# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI\n# output from the Perl module output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_LATEX          = NO\n\n# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely\n# formatted so it can be parsed by a human reader. This is useful if you want to\n# understand what is going on. On the other hand, if this tag is set to NO, the\n# size of the Perl module output will be much smaller and Perl will parse it\n# just the same.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_PRETTY         = YES\n\n# The names of the make variables in the generated doxyrules.make file are\n# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful\n# so different doxyrules.make files included by the same Makefile don't\n# overwrite each other's variables.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_MAKEVAR_PREFIX = \n\n#---------------------------------------------------------------------------\n# Configuration options related to the preprocessor\n#---------------------------------------------------------------------------\n\n# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all\n# C-preprocessor directives found in the sources and include files.\n# The default value is: YES.\n\nENABLE_PREPROCESSING   = YES\n\n# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names\n# in the source code. If set to NO, only conditional compilation will be\n# performed. Macro expansion can be done in a controlled way by setting\n# EXPAND_ONLY_PREDEF to YES.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nMACRO_EXPANSION        = NO\n\n# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then\n# the macro expansion is limited to the macros specified with the PREDEFINED and\n# EXPAND_AS_DEFINED tags.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_ONLY_PREDEF     = NO\n\n# If the SEARCH_INCLUDES tag is set to YES, the include files in the\n# INCLUDE_PATH will be searched if a #include is found.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSEARCH_INCLUDES        = YES\n\n# The INCLUDE_PATH tag can be used to specify one or more directories that\n# contain include files that are not input files but should be processed by the\n# preprocessor.\n# This tag requires that the tag SEARCH_INCLUDES is set to YES.\n\nINCLUDE_PATH           = \n\n# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard\n# patterns (like *.h and *.hpp) to filter out the header-files in the\n# directories. If left blank, the patterns specified with FILE_PATTERNS will be\n# used.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nINCLUDE_FILE_PATTERNS  = \n\n# The PREDEFINED tag can be used to specify one or more macro names that are\n# defined before the preprocessor is started (similar to the -D option of e.g.\n# gcc). The argument of the tag is a list of macros of the form: name or\n# name=definition (no spaces). If the definition and the \"=\" are omitted, \"=1\"\n# is assumed. To prevent a macro definition from being undefined via #undef or\n# recursively expanded use the := operator instead of the = operator.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nPREDEFINED             = \n\n# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this\n# tag can be used to specify a list of macro names that should be expanded. The\n# macro definition that is found in the sources will be used. Use the PREDEFINED\n# tag if you want to use a different macro definition that overrules the\n# definition found in the source code.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_AS_DEFINED      = \n\n# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will\n# remove all references to function-like macros that are alone on a line, have\n# an all uppercase name, and do not end with a semicolon. Such function macros\n# are typically used for boiler-plate code, and will confuse the parser if not\n# removed.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSKIP_FUNCTION_MACROS   = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to external references\n#---------------------------------------------------------------------------\n\n# The TAGFILES tag can be used to specify one or more tag files. For each tag\n# file the location of the external documentation should be added. The format of\n# a tag file without this location is as follows:\n# TAGFILES = file1 file2 ...\n# Adding location for the tag files is done as follows:\n# TAGFILES = file1=loc1 \"file2 = loc2\" ...\n# where loc1 and loc2 can be relative or absolute paths or URLs. See the\n# section \"Linking to external documentation\" for more information about the use\n# of tag files.\n# Note: Each tag file must have a unique name (where the name does NOT include\n# the path). If a tag file is not located in the directory in which doxygen is\n# run, you must also specify the path to the tagfile here.\n\nTAGFILES               = \n\n# When a file name is specified after GENERATE_TAGFILE, doxygen will create a\n# tag file that is based on the input files it reads. See section \"Linking to\n# external documentation\" for more information about the usage of tag files.\n\nGENERATE_TAGFILE       = \n\n# If the ALLEXTERNALS tag is set to YES, all external class will be listed in\n# the class index. If set to NO, only the inherited external classes will be\n# listed.\n# The default value is: NO.\n\nALLEXTERNALS           = NO\n\n# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed\n# in the modules index. If set to NO, only the current project's groups will be\n# listed.\n# The default value is: YES.\n\nEXTERNAL_GROUPS        = YES\n\n# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in\n# the related pages index. If set to NO, only the current project's pages will\n# be listed.\n# The default value is: YES.\n\nEXTERNAL_PAGES         = YES\n\n# The PERL_PATH should be the absolute path and name of the perl script\n# interpreter (i.e. the result of 'which perl').\n# The default file (with absolute path) is: /usr/bin/perl.\n\nPERL_PATH              = /usr/bin/perl\n\n#---------------------------------------------------------------------------\n# Configuration options related to the dot tool\n#---------------------------------------------------------------------------\n\n# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram\n# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to\n# NO turns the diagrams off. Note that this option also works with HAVE_DOT\n# disabled, but it is recommended to install and use dot, since it yields more\n# powerful graphs.\n# The default value is: YES.\n\nCLASS_DIAGRAMS         = NO\n\n# You can define message sequence charts within doxygen comments using the \\msc\n# command. Doxygen will then run the mscgen tool (see:\n# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the\n# documentation. The MSCGEN_PATH tag allows you to specify the directory where\n# the mscgen tool resides. If left empty the tool is assumed to be found in the\n# default search path.\n\nMSCGEN_PATH            = \n\n# You can include diagrams made with dia in doxygen documentation. Doxygen will\n# then run dia to produce the diagram and insert it in the documentation. The\n# DIA_PATH tag allows you to specify the directory where the dia binary resides.\n# If left empty dia is assumed to be found in the default search path.\n\nDIA_PATH               = \n\n# If set to YES the inheritance and collaboration graphs will hide inheritance\n# and usage relations if the target is undocumented or is not a class.\n# The default value is: YES.\n\nHIDE_UNDOC_RELATIONS   = YES\n\n# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is\n# available from the path. This tool is part of Graphviz (see:\n# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent\n# Bell Labs. The other options in this section have no effect if this option is\n# set to NO\n# The default value is: YES.\n\nHAVE_DOT               = YES\n\n# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed\n# to run in parallel. When set to 0 doxygen will base this on the number of\n# processors available in the system. You can set it explicitly to a value\n# larger than 0 to get control over the balance between CPU load and processing\n# speed.\n# Minimum value: 0, maximum value: 32, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_NUM_THREADS        = 0\n\n# When you want a differently looking font in the dot files that doxygen\n# generates you can specify the font name using DOT_FONTNAME. You need to make\n# sure dot is able to find the font, which can be done by putting it in a\n# standard location or by setting the DOTFONTPATH environment variable or by\n# setting DOT_FONTPATH to the directory containing the font.\n# The default value is: Helvetica.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTNAME           = Helvetica\n\n# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of\n# dot graphs.\n# Minimum value: 4, maximum value: 24, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTSIZE           = 10\n\n# By default doxygen will tell dot to use the default font as specified with\n# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set\n# the path where dot can find it using this tag.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTPATH           = \n\n# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for\n# each documented class showing the direct and indirect inheritance relations.\n# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCLASS_GRAPH            = NO\n\n# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a\n# graph for each documented class showing the direct and indirect implementation\n# dependencies (inheritance, containment, and class references variables) of the\n# class with other documented classes.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCOLLABORATION_GRAPH    = NO\n\n# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for\n# groups, showing the direct groups dependencies.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGROUP_GRAPHS           = YES\n\n# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and\n# collaboration diagrams in a style similar to the OMG's Unified Modeling\n# Language.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LOOK               = NO\n\n# If the UML_LOOK tag is enabled, the fields and methods are shown inside the\n# class node. If there are many fields or methods and many nodes the graph may\n# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the\n# number of items for each type to make the size more manageable. Set this to 0\n# for no limit. Note that the threshold may be exceeded by 50% before the limit\n# is enforced. So when you set the threshold to 10, up to 15 fields may appear,\n# but if the number exceeds 15, the total amount of fields shown is limited to\n# 10.\n# Minimum value: 0, maximum value: 100, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LIMIT_NUM_FIELDS   = 10\n\n# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and\n# collaboration graphs will show the relations between templates and their\n# instances.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nTEMPLATE_RELATIONS     = NO\n\n# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to\n# YES then doxygen will generate a graph for each documented file showing the\n# direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDE_GRAPH          = YES\n\n# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are\n# set to YES then doxygen will generate a graph for each documented file showing\n# the direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDED_BY_GRAPH      = YES\n\n# If the CALL_GRAPH tag is set to YES then doxygen will generate a call\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable call graphs for selected\n# functions only using the \\callgraph command. Disabling a call graph can be\n# accomplished by means of the command \\hidecallgraph.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALL_GRAPH             = YES\n\n# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable caller graphs for selected\n# functions only using the \\callergraph command. Disabling a caller graph can be\n# accomplished by means of the command \\hidecallergraph.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALLER_GRAPH           = YES\n\n# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical\n# hierarchy of all classes instead of a textual one.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGRAPHICAL_HIERARCHY    = YES\n\n# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the\n# dependencies a directory has on other directories in a graphical way. The\n# dependency relations are determined by the #include relations between the\n# files in the directories.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDIRECTORY_GRAPH        = YES\n\n# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images\n# generated by dot. For an explanation of the image formats see the section\n# output formats in the documentation of the dot tool (Graphviz (see:\n# http://www.graphviz.org/)).\n# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order\n# to make the SVG files visible in IE 9+ (other browsers do not have this\n# requirement).\n# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,\n# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,\n# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo,\n# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and\n# png:gdiplus:gdiplus.\n# The default value is: png.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_IMAGE_FORMAT       = png\n\n# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to\n# enable generation of interactive SVG images that allow zooming and panning.\n#\n# Note that this requires a modern browser other than Internet Explorer. Tested\n# and working are Firefox, Chrome, Safari, and Opera.\n# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make\n# the SVG files visible. Older versions of IE do not have SVG support.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINTERACTIVE_SVG        = NO\n\n# The DOT_PATH tag can be used to specify the path where the dot tool can be\n# found. If left blank, it is assumed the dot tool can be found in the path.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_PATH               = \n\n# The DOTFILE_DIRS tag can be used to specify one or more directories that\n# contain dot files that are included in the documentation (see the \\dotfile\n# command).\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOTFILE_DIRS           = \n\n# The MSCFILE_DIRS tag can be used to specify one or more directories that\n# contain msc files that are included in the documentation (see the \\mscfile\n# command).\n\nMSCFILE_DIRS           = \n\n# The DIAFILE_DIRS tag can be used to specify one or more directories that\n# contain dia files that are included in the documentation (see the \\diafile\n# command).\n\nDIAFILE_DIRS           = \n\n# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the\n# path where java can find the plantuml.jar file. If left blank, it is assumed\n# PlantUML is not used or called during a preprocessing step. Doxygen will\n# generate a warning when it encounters a \\startuml command in this case and\n# will not generate output for the diagram.\n\nPLANTUML_JAR_PATH      = \n\n# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a\n# configuration file for plantuml.\n\nPLANTUML_CFG_FILE      = \n\n# When using plantuml, the specified paths are searched for files specified by\n# the !include statement in a plantuml block.\n\nPLANTUML_INCLUDE_PATH  = \n\n# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes\n# that will be shown in the graph. If the number of nodes in a graph becomes\n# larger than this value, doxygen will truncate the graph, which is visualized\n# by representing a node as a red box. Note that doxygen if the number of direct\n# children of the root node in a graph is already larger than\n# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that\n# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.\n# Minimum value: 0, maximum value: 10000, default value: 50.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_GRAPH_MAX_NODES    = 50\n\n# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs\n# generated by dot. A depth value of 3 means that only nodes reachable from the\n# root by following a path via at most 3 edges will be shown. Nodes that lay\n# further from the root node will be omitted. Note that setting this option to 1\n# or 2 may greatly reduce the computation time needed for large code bases. Also\n# note that the size of a graph can be further restricted by\n# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.\n# Minimum value: 0, maximum value: 1000, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nMAX_DOT_GRAPH_DEPTH    = 0\n\n# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent\n# background. This is disabled by default, because dot on Windows does not seem\n# to support this out of the box.\n#\n# Warning: Depending on the platform used, enabling this option may lead to\n# badly anti-aliased labels on the edges of a graph (i.e. they become hard to\n# read).\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_TRANSPARENT        = NO\n\n# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output\n# files in one run (i.e. multiple -o and -T options on the command line). This\n# makes dot run faster, but since only newer versions of dot (>1.8.10) support\n# this, this feature is disabled by default.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_MULTI_TARGETS      = NO\n\n# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page\n# explaining the meaning of the various boxes and arrows in the dot generated\n# graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGENERATE_LEGEND        = YES\n\n# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot\n# files that are used to generate the various graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_CLEANUP            = YES\n"
  },
  {
    "path": "ftpm-opensbi/docs/external/coreboot.md",
    "content": "OpenSBI as coreboot payload\n===========================\n\n[coreboot] is a free/libre and open source firmware platform support multiple\nhardware architectures(x86, ARMv7, arm64, PowerPC64, MIPS and RISC-V) and\ndiverse hardware models. In RISC-V world, coreboot currently support HiFive\nUnleashed with OpenSBI as a payload to boot GNU/Linux:\n\n```\nSiFive HiFive unleashed's original firmware boot process:\n                                    +-----------+\n+------+    +------+    +------+    | BBL       |\n| MSEL |--->| ZSBL |--->| FSBL |--->|   +-------+\n+------+    +------+    +------+    |   | linux |\n                                    +---+-------+\n\ncoreboot boot process:\n                      +---------------------------------------------------------------------+\n                      | coreboot                                                            |\n+------+   +------+   |  +-----------+  +----------+  +----------+  +-----------------------+\n| MSEL |-->| ZSBL |-->|  | bootblock |->| romstage |->| ramstage |->| payload ( OpenSBI)    |\n+------+   +------+   |  +-----------+  +----------+  +----------+  |             +-------+ |\n                      |                                             |             | linux | |\n                      +---------------------------------------------+-------------+-------+-+\n```\n\nThe upstreaming work is still in progress. There's a [documentation] about how\nto build [out-of-tree code] to load OpenSBI.\n\n[coreboot]: https://www.coreboot.org/\n[documentation]: https://github.com/hardenedlinux/embedded-iot_profile/blob/master/docs/riscv/hifiveunleashed_coreboot_notes-en.md\n[out-of-tree code]: https://github.com/hardenedlinux/coreboot-HiFiveUnleashed\n"
  },
  {
    "path": "ftpm-opensbi/docs/firmware/fw.md",
    "content": "OpenSBI Platform Firmwares\n==========================\n\nOpenSBI provides firmware builds for specific platforms. Different types of\nfirmwares are supported to deal with the differences between different platforms\nearly boot stage. All firmwares will execute the same initialization procedure\nof the platform hardware according to the platform specific code as well as\nOpenSBI generic library code. The supported firmwares type will differ in how\nthe arguments passed by the platform early boot stage are handled, as well as\nhow the boot stage following the firmware will be handled and executed.\n\nThe previous booting stage will pass information via the following registers\nof RISC-V CPU:\n\n* hartid via *a0* register\n* device tree blob address in memory via *a1* register. The address must\n  be aligned to 8 bytes.\n\nOpenSBI currently supports three different types of firmwares.\n\nFirmware with Dynamic Information (*FW_DYNAMIC*)\n------------------------------------------------\n\nThe *FW_DYNAMIC* firmware gets information about the next booting stage entry,\ne.g. a bootloader or an OS kernel, from previous booting stage at runtime.\n\nA *FW_DYNAMIC* firmware is particularly useful when the booting stage executed\nprior to OpenSBI firmware is capable of loading both the OpenSBI firmware\nand the booting stage binary to follow OpenSBI firmware.\n\nFirmware with Jump Address (*FW_JUMP*)\n--------------------------------------\n\nThe *FW_JUMP* firmware assumes a fixed address of the next booting stage\nentry, e.g. a bootloader or an OS kernel, without directly including the\nbinary code for this next stage.\n\nA *FW_JUMP* firmware is particularly useful when the booting stage executed\nprior to OpenSBI firmware is capable of loading both the OpenSBI firmware\nand the booting stage binary to follow OpenSBI firmware.\n\nFirmware with Payload (*FW_PAYLOAD*)\n------------------------------------\n\nThe *FW_PAYLOAD* firmware directly includes the binary code for the booting\nstage to follow OpenSBI firmware execution. Typically, this payload will be a\nbootloader or an OS kernel.\n\nA *FW_PAYLOAD* firmware is particularly useful when the booting stage executed\nprior to OpenSBI firmware is not capable of loading both OpenSBI firmware and\nthe booting stage to follow OpenSBI firmware.\n\nA *FW_PAYLOAD* firmware is also useful for cases where the booting stage prior\nto OpenSBI firmware does not pass a *flattened device tree (FDT file)*. In such\ncase, a *FW_PAYLOAD* firmware allows embedding a flattened device tree in the\n.rodata section of the final firmware.\n\nFirmware Configuration and Compilation\n--------------------------------------\n\nAll firmware types support the following common compile time configuration\nparameters:\n\n* **FW_TEXT_ADDR** - Defines the execution address of the OpenSBI firmware.\n  This configuration parameter is mandatory.\n* **FW_FDT_PATH** - Path to an external flattened device tree binary file to\n  be embedded in the *.rodata* section of the final firmware. If this option\n  is not provided then the firmware will expect the FDT to be passed as an\n  argument by the prior booting stage.\n* **FW_FDT_PADDING** - Optional zero bytes padding to the embedded flattened\n  device tree binary file specified by **FW_FDT_PATH** option.\n* **FW_PIC** - \"FW_PIC=y\" generates position independent executable firmware\n  images. OpenSBI can run at arbitrary address with appropriate alignment.\n  Therefore, the original relocation mechanism (\"FW_PIC=n\") will be skipped.\n  In other words, OpenSBI will directly run at the load address without any\n  code movement. This option requires a toolchain with PIE support, and it\n  is on by default.\n\nAdditionally, each firmware type as a set of type specific configuration\nparameters. Detailed information for each firmware type can be found in the\nfollowing documents.\n\n* *[FW_DYNAMIC]*: The *Firmware with Dynamic Information (FW_DYNAMIC)* is\n  described in more details in the file *fw_dynamic.md*.\n* *[FW_JUMP]*: The *Firmware with Jump Address (FW_JUMP)* is described in more\n  details in the file *fw_jump.md*.\n* *[FW_PAYLOAD]*: The *Firmware with Payload (FW_PAYLOAD)* is described in more\n  details in the file *fw_payload.md*.\n\n[FW_DYNAMIC]: fw_dynamic.md\n[FW_JUMP]: fw_jump.md\n[FW_PAYLOAD]: fw_payload.md\n\nProviding different payloads to OpenSBI Firmware\n------------------------------------------------\nOpenSBI firmware can accept various payloads using a compile time option.\nTypically, these payloads refer to the next stage boot loader (e.g. U-Boot)\nor operating system kernel images (e.g. Linux). By default, OpenSBI\nautomatically provides a test payload if no specific payload is specified\nat compile time.\n\nTo specify a payload at compile time, the make variable _FW_PAYLOAD_PATH_ is\nused.\n```\nmake PLATFORM=<platform_subdir> FW_PAYLOAD_PATH=<payload path>\n```\nThe instructions to build each payload is different and the details can\nbe found in the\n*docs/firmware/payload_<payload_name>.md* files.\n\nOptions for OpenSBI Firmware behaviors\n--------------------------------------\nAn optional compile time flag FW_OPTIONS can be used to control the OpenSBI\nfirmware run-time behaviors.\n\n```\nmake PLATFORM=<platform_subdir> FW_OPTIONS=<options>\n```\n\nFW_OPTIONS is a bitwise or'ed value of various options, eg: *FW_OPTIONS=0x1*\nstands for disabling boot prints from the OpenSBI library.\n\nFor all supported options, please check \"enum sbi_scratch_options\" in the\n*include/sbi/sbi_scratch.h* header file.\n"
  },
  {
    "path": "ftpm-opensbi/docs/firmware/fw_dynamic.md",
    "content": "OpenSBI Firmware with Dynamic Information (FW_DYNAMIC)\n======================================================\n\nOpenSBI **firmware with dynamic info (FW_DYNAMIC)** is a firmware which gets\ninformation about next booting stage (e.g. a bootloader or an OS) and runtime\nOpenSBI library options from previous booting stage.\n\nThe previous booting stage will pass information to *FW_DYNAMIC* by creating\n*struct fw_dynamic_info* in memory and passing its address to *FW_DYNAMIC*\nvia *a2* register of RISC-V CPU. The address must be aligned to 8 bytes on\nRV64 and 4 bytes on RV32.\n\nA *FW_DYNAMIC* firmware is particularly useful when the booting stage executed\nprior to OpenSBI firmware is capable of loading both the OpenSBI firmware and\nthe booting stage binary to follow OpenSBI firmware.\n\n*FW_DYNAMIC* Compilation\n------------------------\n\nA platform can enable *FW_DYNAMIC* firmware using any of the following methods.\n\n1. Specifying `FW_DYNAMIC=y` on the top level `make` command line.\n2. Specifying `FW_DYNAMIC=y` in the target platform *objects.mk* configuration\nfile.\n\nThe compiled *FW_DYNAMIC* firmware ELF file is named *fw_dynamic.elf*. It's\nexpanded image file is *fw_dynamic.bin*. Both files are created in the platform\nspecific build directory under the *build/platform/<platform_subdir>/firmware*\ndirectory.\n\n*FW_DYNAMIC* Firmware Configuration Options\n-------------------------------------------\n\nThe *FW_DYNAMIC* firmware does not require any platform specific configuration\nparameters because all required information is passed by previous booting stage\nat runtime via *struct fw_dynamic_info*.\n"
  },
  {
    "path": "ftpm-opensbi/docs/firmware/fw_jump.md",
    "content": "OpenSBI Firmware with Jump Address (FW_JUMP)\n============================================\n\nOpenSBI **firmware with Jump Address (FW_JUMP)** is a firmware which only\nhandles the address of the next booting stage entry, e.g. a bootloader or an OS\nkernel, without directly including the binary code for this next stage.\n\nA *FW_JUMP* firmware is particularly useful when the booting stage executed\nprior to the OpenSBI firmware is capable of loading both the OpenSBI firmware\nand the booting stage binary to follow the OpenSBI firmware.\n\n*FW_JUMP* Compilation\n---------------------\n\nA platform *FW_JUMP* firmware can be enabled by any of the following methods:\n\n1. Specifying `FW_JUMP=y` on the top level `make` command line.\n2. Specifying `FW_JUMP=y` in the target platform *objects.mk* configuration file.\n\nThe compiled *FW_JUMP* firmware ELF file is named *fw_jump.elf*. Its expanded\nimage file is *fw_jump.bin*. Both files are created in the platform-specific\nbuild directory under the *build/platform/<platform_subdir>/firmware* directory.\n\n*FW_JUMP* Firmware Configuration Options\n----------------------------------------\n\nTo operate correctly, a *FW_JUMP* firmware requires some configuration\nparameters to be defined using either the top level `make` command line or the\ntarget platform *objects.mk* configuration file. The possible parameters are as\nfollows:\n\n* **FW_JUMP_ADDR** - Address of the entry point of the booting stage to be\n  executed following OpenSBI firmware. This address generally corresponds\n  exactly to the address where this next booting stage was loaded. This is a\n  mandatory parameter. Compilation errors will result from not defining this\n  address.\n\n* **FW_JUMP_FDT_ADDR** - Address where the *flattened device tree (FDT file)*\n  passed by the prior booting stage will be placed in memory before executing\n  the booting stage following the OpenSBI firmware. If this option is not\n  provided, then the OpenSBI firmware will pass the FDT address passed by the\n  previous booting stage to the next booting stage.\n\n  When using the default *FW_JUMP_FDT_ADDR* with *PLATFORM=generic*, you must\n  ensure *FW_JUMP_FDT_ADDR* is set high enough to avoid overwriting the kernel.\n  You can use the following method.\n\n  ```\n  ${CROSS_COMPILE}objdump -h $KERNEL_ELF | sort -k 5,5 | awk -n '/^ +[0-9]+ /\\\n  {addr=\"0x\"$3; size=\"0x\"$5; printf \"0x\"\"%x\\n\",addr+size}' \\\n  | (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\\\n  increase FW_JUMP_FDT_ADDR\n\n  ${LLVM}objdump -h --show-lma $KERNEL_ELF | sort -k 5,5 | \\\n  awk -n '/^ +[0-9]+ / {addr=\"0x\"$3; size=\"0x\"$5; printf \"0x\"\"%x\\n\",addr+size}'\\\n  | (( `tail -1` > 0x2200000 )) && echo fdt overlaps kernel,\\\n  increase FW_JUMP_FDT_ADDR\n  ```\n\n*FW_JUMP* Example\n-----------------\n\nThe *[qemu/virt]* platform illustrates how to configure and use a *FW_JUMP*\nfirmware. Detailed information regarding these platforms can be found in the\nplatform documentation files.\n\n[qemu/virt]: ../platform/qemu_virt.md\n"
  },
  {
    "path": "ftpm-opensbi/docs/firmware/fw_payload.md",
    "content": "OpenSBI Firmware with Payload (FW_PAYLOAD)\n==========================================\n\nOpenSBI **firmware with Payload (FW_PAYLOAD)** is a firmware which directly\nincludes the binary for the booting stage to follow the OpenSBI firmware\nexecution. Typically, this payload will be a bootloader or an OS kernel.\n\nA *FW_PAYLOAD* firmware is particularly useful when the booting stage executed\nprior to the OpenSBI firmware is not capable of loading both the OpenSBI\nfirmware and the booting stage to follow OpenSBI firmware.\n\nA *FW_PAYLOAD* firmware is also useful for cases where the booting stage prior\nto the OpenSBI firmware does not pass a *flattened device tree (FDT file)*. In\nsuch a case, a *FW_PAYLOAD* firmware allows embedding a flattened device tree\nin the .rodata section of the final firmware.\n\nEnabling *FW_PAYLOAD* compilation\n---------------------------------\n\nThe *FW_PAYLOAD* firmware can be enabled by any of the following methods:\n\n1. Specifying `FW_PAYLOAD=y` on the top level `make` command line.\n2. Specifying `FW_PAYLOAD=y` in the target platform *objects.mk* configuration\n   file.\n\nThe compiled *FW_PAYLOAD* firmware ELF file is named *fw_jump.elf*. Its\nexpanded image file is *fw_payload.bin*. Both files are created in the\nplatform-specific build directory under the\n*build/platform/<platform_subdir>/firmware* directory.\n\nConfiguration Options\n---------------------\n\nA *FW_PAYLOAD* firmware is built according to configuration parameters and\noptions. These configuration parameters can be defined using either the top\nlevel `make` command line or the target platform *objects.mk* configuration\nfile. The parameters currently defined are as follows:\n\n* **FW_PAYLOAD_OFFSET** - Offset from *FW_TEXT_BASE* where the payload binary\n  will be linked in the final *FW_PAYLOAD* firmware binary image. This\n  configuration parameter is mandatory if *FW_PAYLOAD_ALIGN* is not defined.\n  Compilation errors will result from an incorrect definition of\n  *FW_PAYLOAD_OFFSET* or of *FW_PAYLOAD_ALIGN*, or if neither of these\n  parameters are defined.\n\n* **FW_PAYLOAD_ALIGN** - Address alignment constraint where the payload binary\n  will be linked after the end of the base firmware binary in the final\n  *FW_PAYLOAD* firmware binary image. This configuration parameter is mandatory\n  if *FW_PAYLOAD_OFFSET* is not defined. If both *FW_PAYLOAD_OFFSET* and\n  *FW_PAYLOAD_ALIGN* are defined, *FW_PAYLOAD_OFFSET* is used and\n  *FW_PAYLOAD_ALIGN* is ignored.\n\n* **FW_PAYLOAD_PATH** - Path to the image file of the next booting stage\n  binary.  If this option is not provided then a simple test payload is\n  automatically generated and used as a payload. This test payload executes\n  an infinite `while (1)` loop after printing a message on the platform console.\n\n* **FW_PAYLOAD_FDT_ADDR** - Address where the FDT passed by the prior booting\n  stage or specified by the *FW_FDT_PATH* parameter and embedded in the\n  *.rodata* section will be placed before executing the next booting stage,\n  that is, the payload firmware. If this option is not provided, then the\n  firmware will pass the FDT address passed by the previous booting stage\n  to the next booting stage.\n\n*FW_PAYLOAD* Example\n--------------------\n\nThe *[qemu/virt]* platforms illustrate how to configure and use a *FW_PAYLOAD*\nfirmware. Detailed information regarding these platforms can be found in the\nplatform documentation files.\n\n[qemu/virt]: ../platform/qemu_virt.md\n"
  },
  {
    "path": "ftpm-opensbi/docs/firmware/payload_linux.md",
    "content": "Linux as a direct payload to OpenSBI\n====================================\n\nOpenSBI has the capability to load a Linux kernel image directly in supervisor\nmode. The flattened image generated by the Linux kernel build process can be\nprovided as a payload to OpenSBI.\n\nDetailed examples can be found in both the [QEMU](../platform/qemu_virt.md)\nand the [HiFive Unleashed](../platform/sifive_fu540.md) platform guides.\n"
  },
  {
    "path": "ftpm-opensbi/docs/firmware/payload_uboot.md",
    "content": "U-Boot as a payload to OpenSBI\n==============================\n\n[U-Boot](https://www.denx.de/wiki/U-Boot) is an open-source primary boot loader.\nIt can be used as first and/or second stage boot loader in an embedded\nenvironment. In the context of OpenSBI, U-Boot can be specified as a payload to\nthe OpenSBI firmware, becoming the boot stage following the OpenSBI firmware\nexecution.\n\nBuilding and Generating U-Boot images\n=====================================\nPlease refer to the U-Boot build documentation for detailed instructions on\nhow to build U-Boot image and boot high level operating systems from U-Boot\nprompt.\n\n"
  },
  {
    "path": "ftpm-opensbi/docs/library_usage.md",
    "content": "OpenSBI Library Usage\n=====================\n\nOpenSBI provides two types of static libraries:\n\n1. *libsbi.a* - A platform-independent generic static library implementing the\n   interface defined by the SBI specifications. Platform-specific processing\n   hooks for the execution of this interface must be provided by the firmware or\n   bootloader linking with this library. This library is installed as\n   *<install_directory>/lib/libsbi.a*\n2. *libplatsbi.a* - An example platform-specific static library integrating\n   *libsbi.a* with platform-specific hooks. This library is available only for\n   the platforms supported by OpenSBI. This library is installed as\n   *<install_directory>/platform/<platform_subdir>/lib/libplatsbi.a*\n\nImplementations may choose either *libsbi.a* or *libplatsbi.a* to link with\ntheir firmware or bootloader. In the case of *libsbi.a*, platform-specific\nhooks in the form of a *struct sbi_platform* instance need to be provided.\n\nThe platform-specific example firmwares provided by OpenSBI are not mandatory.\nAn implementation may choose to link the OpenSBI generic static library together\nwith an M-mode firmware or bootloader providing the hardware-specific hooks.\nSince OpenSBI is a statically linked library, users must ensure that the\nlicense of these external components is compatible with the OpenSBI license.\n\nConstraints on OpenSBI usage from external firmware\n---------------------------------------------------\n\nUsers have to ensure that an external firmware or bootloader linking against\nOpenSBI static libraries (*libsbi.a* or *libplatsbi.a*) is compiled with the\nsame GCC target options *-mabi*, *-march*, and *-mcmodel*.\n\nThere are only two constraints on calling any OpenSBI library function from an\nexternal M-mode firmware or bootloader:\n\n1. The RISC-V *MSCRATCH* CSR must point to a valid OpenSBI scratch space\n   (i.e. a *struct sbi_scratch* instance).\n2. The RISC-V *SP* register (i.e. the stack pointer) must be set per-HART\n   pointing to distinct non-overlapping stacks.\n\nThe most important functions from an external firmware or bootloader\nperspective are *sbi_init()* and *sbi_trap_handler()*.\n\nIn addition to the above constraints, the external firmware or bootloader must\nensure that interrupts are disabled in the *MSTATUS* and *MIE* CSRs when calling\nthe functions *sbi_init()* and *sbi_trap_handler()*.\n\nThe *sbi_init()* function should be called by the external firmware or\nbootloader for each HART that is powered-up at boot-time or in response to a\nCPU hotplug event.\n\nThe *sbi_trap_handler()* function should be called by the external firmware or\nbootloader to service the following interrupts and traps:\n\n1. M-mode timer interrupt\n2. M-mode software interrupt\n3. Illegal instruction trap\n4. Misaligned load trap\n5. Misaligned store trap\n6. Supervisor ecall trap\n7. Hypervisor ecall trap\n\n**Note:** external firmwares or bootloaders can be more conservative by\nforwarding all traps and interrupts to *sbi_trap_handler()*.\n\nDefinitions of OpenSBI Data Types for the External Firmware\n-----------------------------------------------------------\n\nOpenSBI can be built as library using external firmware build system such as EDK2\ncode base (The open source of UEFI firmware implementation) and linked with external\nfirmware drivers based on the external firmware architecture.\n\n**OPENSBI_EXTERNAL_SBI_TYPES** identifier is introduced to *sbi_types.h* for selecting\nexternal header file during the build preprocess in order to define OpensSBI data types\nbased on external firmware data type binding.\nFor example, *bool* is declared as *int* in sbi_types.h. However, in EDK2 build system,\n*bool* is declared as *BOOLEAN* which is defined as *unsigned char* data type.\n\nExternal firmware can define **OPENSBI_EXTERNAL_SBI_TYPES** in CFLAGS and specify it to the\nheader file maintained in its code tree. However, the external build system has to address\nthe additional include directory for the external header file based on its own build system.\nFor example,\n*-D***OPENSBI_EXTERNAL_SBI_TYPES***=OpensbiTypes.h*\nAbove tells *sbi_types.h* to refer to *OpensbiTypes.h* instead of using original definitions of\ndata types.\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/andes-ae350.md",
    "content": "Andes AE350 SoC Platform\n========================\nThe AE350 AXI/AHB-based platform N25(F)/NX25(F)/D25F/A25/AX25 CPU with level-one\nmemories, interrupt controller, debug module, AXI and AHB Bus Matrix Controller,\nAXI-to-AHB Bridge and a collection of fundamental AHB/APB bus IP components\npre-integrated together as a system design. The high-quality and configurable\nAHB/APB IPs suites a majority embedded systems, and the verified platform serves\nas a starting point to jump start SoC designs.\n\nTo build platform specific library and firmwares, provide the\n*PLATFORM=generic* parameter to the top level `make` command.\n\nPlatform Options\n----------------\n\nThe Andes AE350 platform does not have any platform-specific options.\n\nBuilding Andes AE350 Platform\n-----------------------------\n\nAE350's dts is included in https://github.com/andestech/linux/tree/RISCV-Linux-5.4-ast-v5_1_0-branch\n\n**Linux Kernel Payload**\n\n```\nmake PLATFORM=generic FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image FW_FDT_PATH=<ae350.dtb path>\n```\n\nDTS Example: (Quad-core AX45MP)\n-------------------------------\n\n```\n\tcompatible = \"andestech,ae350\";\n\tcpus {\n\t\t#address-cells = <1>;\n\t\t#size-cells = <0>;\n\t\ttimebase-frequency = <60000000>;\n\n\t\tCPU0: cpu@0 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <0>;\n\t\t\tstatus = \"okay\";\n\t\t\tcompatible = \"riscv\";\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\triscv,priv-major = <1>;\n\t\t\triscv,priv-minor = <10>;\n\t\t\tmmu-type = \"riscv,sv48\";\n\t\t\tclock-frequency = <60000000>;\n\t\t\ti-cache-size = <0x8000>;\n\t\t\ti-cache-sets = <256>;\n\t\t\ti-cache-line-size = <64>;\n\t\t\ti-cache-block-size = <64>;\n\t\t\td-cache-size = <0x8000>;\n\t\t\td-cache-sets = <128>;\n\t\t\td-cache-line-size = <64>;\n\t\t\td-cache-block-size = <64>;\n\t\t\tnext-level-cache = <&L2>;\n\t\t\tCPU0_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tinterrupt-controller;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t};\n\t\t};\n\t\tCPU1: cpu@1 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <1>;\n\t\t\tstatus = \"okay\";\n\t\t\tcompatible = \"riscv\";\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\triscv,priv-major = <1>;\n\t\t\triscv,priv-minor = <10>;\n\t\t\tmmu-type = \"riscv,sv48\";\n\t\t\tclock-frequency = <60000000>;\n\t\t\ti-cache-size = <0x8000>;\n\t\t\ti-cache-sets = <256>;\n\t\t\ti-cache-line-size = <64>;\n\t\t\ti-cache-block-size = <64>;\n\t\t\td-cache-size = <0x8000>;\n\t\t\td-cache-sets = <128>;\n\t\t\td-cache-line-size = <64>;\n\t\t\td-cache-block-size = <64>;\n\t\t\tnext-level-cache = <&L2>;\n\t\t\tCPU1_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tinterrupt-controller;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t};\n\t\t};\n\t\tCPU2: cpu@2 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <2>;\n\t\t\tstatus = \"okay\";\n\t\t\tcompatible = \"riscv\";\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\triscv,priv-major = <1>;\n\t\t\triscv,priv-minor = <10>;\n\t\t\tmmu-type = \"riscv,sv48\";\n\t\t\tclock-frequency = <60000000>;\n\t\t\ti-cache-size = <0x8000>;\n\t\t\ti-cache-sets = <256>;\n\t\t\ti-cache-line-size = <64>;\n\t\t\ti-cache-block-size = <64>;\n\t\t\td-cache-size = <0x8000>;\n\t\t\td-cache-sets = <128>;\n\t\t\td-cache-line-size = <64>;\n\t\t\td-cache-block-size = <64>;\n\t\t\tnext-level-cache = <&L2>;\n\t\t\tCPU2_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tinterrupt-controller;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t};\n\t\t};\n\t\tCPU3: cpu@3 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <3>;\n\t\t\tstatus = \"okay\";\n\t\t\tcompatible = \"riscv\";\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\triscv,priv-major = <1>;\n\t\t\triscv,priv-minor = <10>;\n\t\t\tmmu-type = \"riscv,sv48\";\n\t\t\tclock-frequency = <60000000>;\n\t\t\ti-cache-size = <0x8000>;\n\t\t\ti-cache-sets = <256>;\n\t\t\ti-cache-line-size = <64>;\n\t\t\ti-cache-block-size = <64>;\n\t\t\td-cache-size = <0x8000>;\n\t\t\td-cache-sets = <128>;\n\t\t\td-cache-line-size = <64>;\n\t\t\td-cache-block-size = <64>;\n\t\t\tnext-level-cache = <&L2>;\n\t\t\tCPU3_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tinterrupt-controller;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t};\n\t\t};\n\t};\n\n\tsoc {\n\t\t#address-cells = <2>;\n\t\t#size-cells = <2>;\n\t\tcompatible = \"andestech,riscv-ae350-soc\", \"simple-bus\";\n\t\tranges;\n\n\t\tplic0: interrupt-controller@e4000000 {\n\t\t\tcompatible = \"riscv,plic0\";\n\t\t\treg = <0x00000000 0xe4000000 0x00000000 0x02000000>;\n\t\t\tinterrupts-extended = < &CPU0_intc 11 &CPU0_intc 9\n\t\t\t                        &CPU1_intc 11 &CPU1_intc 9\n\t\t\t                        &CPU2_intc 11 &CPU2_intc 9\n\t\t\t                        &CPU3_intc 11 &CPU3_intc 9 >;\n\t\t\tinterrupt-controller;\n\t\t\t#address-cells = <2>;\n\t\t\t#interrupt-cells = <2>;\n\t\t\triscv,ndev = <71>;\n\t\t};\n\n\t\tplicsw: interrupt-controller@e6400000 {\n\t\t\tcompatible = \"andestech,plicsw\";\n\t\t\treg = <0x00000000 0xe6400000 0x00000000 0x00400000>;\n\t\t\tinterrupts-extended = < &CPU0_intc 3\n\t\t\t                        &CPU1_intc 3\n\t\t\t                        &CPU2_intc 3\n\t\t\t                        &CPU3_intc 3 >;\n\t\t\tinterrupt-controller;\n\t\t\t#address-cells = <2>;\n\t\t\t#interrupt-cells = <2>;\n\t\t};\n\n\t\tplmt0: plmt0@e6000000 {\n\t\t\tcompatible = \"andestech,plmt0\";\n\t\t\treg = <0x00000000 0xe6000000 0x00000000 0x00100000>;\n\t\t\tinterrupts-extended = < &CPU0_intc 7\n\t\t\t                        &CPU1_intc 7\n\t\t\t                        &CPU2_intc 7\n\t\t\t                        &CPU3_intc 7 >;\n\t\t};\n\n\t\twdt: watchdog@f0500000 {\n\t\t\tcompatible = \"andestech,atcwdt200\";\n\t\t\treg = <0x00000000 0xf0500000 0x00000000 0x00001000>;\n\t\t\tinterrupts = <3 4>;\n\t\t\tinterrupt-parent = <&plic0>;\n\t\t\tclock-frequency = <15000000>;\n\t\t};\n\n\t\tserial0: serial@f0300000 {\n\t\t\tcompatible = \"andestech,uart16550\", \"ns16550a\";\n\t\t\treg = <0x00000000 0xf0300000 0x00000000 0x00001000>;\n\t\t\tinterrupts = <9 4>;\n\t\t\tinterrupt-parent = <&plic0>;\n\t\t\tclock-frequency = <19660800>;\n\t\t\tcurrent-speed = <38400>;\n\t\t\treg-shift = <2>;\n\t\t\treg-offset = <32>;\n\t\t\treg-io-width = <4>;\n\t\t\tno-loopback-test = <1>;\n\t\t};\n\n\t\tsmu: smu@f0100000 {\n\t\t\tcompatible = \"andestech,atcsmu\";\n\t\t\treg = <0x00000000 0xf0100000 0x00000000 0x00001000>;\n\t\t};\n\t};\n```\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/fpga-ariane.md",
    "content": "Ariane FPGA SoC Platform\n========================\nAriane is a 6-stage, single issue, in-order CPU which implements the 64-bit\nRISC-V instruction set. The Ariane FPGA development platform is based on FPGA\nSoC (which currently supports only Genesys 2 board) and is capable of running\nLinux.\n\nThe FPGA SoC currently contains the following peripherals:\n- DDR3 memory controller\n- SPI controller to connect to an SDCard\n- Ethernet controller\n- JTAG port (see debugging section below)\n- Bootrom containing zero stage bootloader and device tree.\n\nTo build platform specific library and firmwares, provide the\n*PLATFORM=fpga/ariane* parameter to the top level `make` command.\n\nPlatform Options\n----------------\n\nThe *Ariane FPGA* platform does not have any platform-specific options.\n\nBuilding Ariane FPGA Platform\n-----------------------------\n\n**Linux Kernel Payload**\n\n```\nmake PLATFORM=fpga/ariane FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image\n```\n\nBooting Ariane FPGA Platform\n----------------------------\n\n**Linux Kernel Payload**\n\nAs Linux kernel image is embedded in the OpenSBI firmware binary, Ariane will\ndirectly boot into Linux directly after powered on.\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/fpga-openpiton.md",
    "content": "OpenPiton FPGA SoC Platform\n========================\nOpenPiton is the world's first open source, general purpose, multithreaded\nmanycore processor. It is a tiled manycore framework scalable from one to\n1/2 billion cores. Currently, OpenPiton supports the 64bit Ariane RISC-V\nprocessor from ETH Zurich. To this end, Ariane has been equipped with a\ndifferent L1 cache subsystem that follows a write-through protocol and that has\nsupport for cache invalidations and atomics.\n\nTo build platform specific library and firmwares, provide the\n*PLATFORM=fpga/openpiton* parameter to the top level `make` command.\n\nPlatform Options\n----------------\n\nThe *OpenPiton* platform does not have any platform-specific options.\n\nBuilding Ariane FPGA Platform\n-----------------------------\n\n**Linux Kernel Payload**\n\n```\nmake PLATFORM=fpga/openpiton FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image\n```\n\nBooting Ariane FPGA Platform\n----------------------------\n\n**Linux Kernel Payload**\n\nAs Linux kernel image is embedded in the OpenSBI firmware binary, Ariane will\ndirectly boot into Linux directly after powered on.\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/generic.md",
    "content": "Generic Platform\n================\n\nThe **Generic** platform is a flattened device tree (FDT) based platform\nwhere all platform specific functionality is provided based on FDT passed\nby previous booting stage. The **Generic** platform allows us to use same\nOpenSBI firmware binaries on various emulators, simulators, FPGAs, and\nboards.\n\nBy default, the generic FDT platform makes following assumptions:\n\n1. platform FW_TEXT_START is 0x80000000\n2. platform features are default\n3. platform stack size is default\n4. platform has no quirks or work-arounds\n\nThe above assumptions (except 1) can be overridden by adding special platform\ncallbacks which will be called based on FDT root node compatible string.\n\nUsers of the generic FDT platform will have to ensure that:\n\n1. Various FDT based drivers under lib/utils directory are upto date\n   based on their platform requirements\n2. The FDT passed by previous booting stage has DT compatible strings and\n   DT properties in sync with the FDT based drivers under lib/utils directory\n3. The FDT must have \"stdout-path\" DT property in the \"/chosen\" DT node when\n   a platform has multiple serial ports or consoles\n4. On multi-HART platform, the FDT must have a DT node for IPI device and\n   lib/utils/ipi directory must have corresponding FDT based IPI driver\n5. The FDT must have a DT node for timer device and lib/utils/timer directory\n   must have corresponding FDT based timer driver\n\nTo build the platform-specific library and firmware images, provide the\n*PLATFORM=generic* parameter to the top level `make` command.\n\nFor custom FW_TEXT_START, we can build the platform-specific library and\nfirmware images by passing *PLATFORM=generic FW_TEXT_START=<custom_text_start>*\nparameter to the top level `make` command.\n\nPlatform Options\n----------------\n\nThe *Generic* platform does not have any platform-specific options.\n\nRISC-V Platforms Using Generic Platform\n---------------------------------------\n\n* **Andes AE350 Platform** (*[andes-ae350.md]*)\n* **QEMU RISC-V Virt Machine** (*[qemu_virt.md]*)\n* **Renesas RZ/Five SoC** (*[renesas-rzfive.md]*)\n* **Shakti C-class SoC Platform** (*[shakti_cclass.md]*)\n* **SiFive HiFive Unleashed** (*[sifive_fu540.md]*)\n* **Spike** (*[spike.md]*)\n* **T-HEAD C9xx series Processors** (*[thead-c9xx.md]*)\n\n[andes-ae350.md]: andse-ae350.md\n[qemu_virt.md]: qemu_virt.md\n[renesas-rzfive.md]: renesas-rzfive.md\n[shakti_cclass.md]: shakti_cclass.md\n[sifive_fu540.md]: sifive_fu540.md\n[spike.md]: spike.md\n[thead-c9xx.md]: thead-c9xx.md\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/nuclei_ux600.md",
    "content": "\nNuclei UX600 Platform\n=====================\n\nThe **Nuclei UX600** is a 64-bit RISC-V Core which is capable of running Linux.\n\n> Nuclei UX600: single core, pipeline as single-issue and 6~9 variable stages, in-order dispatch and out-of-order write-back, running up to >1.2GHz\n\nTo build the platform-specific library and firmware images, provide the\n*PLATFORM=nuclei/ux600* parameter to the top level `make` command.\n\nPlatform Options\n----------------\n\nThe *Nuclei UX600* platform does not have any platform-specific options.\n\nBuilding Nuclei UX600 Platform\n------------------------------\n\n```\nmake PLATFORM=nuclei/ux600 clean all\n```\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/platform.md",
    "content": "OpenSBI Supported Platforms\n===========================\n\nOpenSBI currently supports the following virtual and hardware platforms:\n\n* **Generic**: Flattened device tree (FDT) based platform where platform\n  specific functionality is provided based on the FDT passed by previous\n  booting stage. More details on this platform can be found in the file\n  *[generic.md]*.\n\n* **QEMU RISC-V Virt Machine**: Platform support for the QEMU *virt* virtual\n  RISC-V machine. This virtual machine is intended for RISC-V software\n  development and tests. More details on this platform can be found in the\n  file *[qemu_virt.md]*.\n\n* **SiFive FU540 SoC**: Platform support for SiFive FU540 SoC used on the\n  HiFive Unleashed board, as well as the *sifive_u* QEMU virtual RISC-V\n  machine. More details on this platform can be found in the file\n  *[sifive_fu540.md]*.\n\n* **Kendryte K210 SoC**: Platform support for the Kendryte K210 SoC used on\n  boards such as the Kendryte KD233 or the Sipeed MAIX Dock.\n\n* **Ariane FPGA SoC**: Platform support for the Ariane FPGA SoC used on\n  Genesys 2 board. More details on this platform can be found in the file\n  *[fpga-ariane.md]*.\n\n* **Andes AE350 SoC**: Platform support for the Andes's SoC (AE350). More\n  details on this platform can be found in the file *[andes-ae350.md]*.\n\n* **Spike**: Platform support for the Spike emulator. More\n  details on this platform can be found in the file *[spike.md]*.\n\n* **OpenPiton FPGA SoC**: Platform support OpenPiton research platform based\n  on ariane core. More details on this platform can be found in the file\n  *[fpga-openpiton.md]*.\n\n* **Shakti C-class SoC Platform**: Platform support for Shakti C-class\n  processor based SOCs. More details on this platform can be found in the\n  file *[shakti_cclass.md]*.\n\n* **Renesas RZ/Five SoC**: Platform support for Renesas RZ/Five (R9A07G043F) SoC\n  used on the Renesas RZ/Five SMARC EVK board. More details on this platform can\n  be found in the file *[renesas-rzfive.md]*.\n\nThe code for these supported platforms can be used as example to implement\nsupport for other platforms. The *platform/template* directory also provides\ntemplate files for implementing support for a new platform. The *objects.mk*,\n*Kconfig*, *configs/defconfig* and *platform.c* template files provides enough\ncomments to facilitate the implementation.\n\n[generic.md]: generic.md\n[qemu_virt.md]: qemu_virt.md\n[sifive_fu540.md]: sifive_fu540.md\n[fpga-ariane.md]: fpga-ariane.md\n[andes-ae350.md]: andes-ae350.md\n[thead-c910.md]: thead-c910.md\n[spike.md]: spike.md\n[fpga-openpiton.md]: fpga-openpiton.md\n[shakti_cclass.md]: shakti_cclass.md\n[renesas-rzfive.md]: renesas-rzfive.md\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/qemu_virt.md",
    "content": "QEMU RISC-V Virt Machine Platform\n=================================\n\nThe **QEMU RISC-V Virt Machine** is a virtual platform created for RISC-V\nsoftware development and testing. It is also referred to as\n*QEMU RISC-V VirtIO machine* because it uses VirtIO devices for network,\nstorage, and other types of IO.\n\nTo build the platform-specific library and firmware images, provide the\n*PLATFORM=generic* parameter to the top level `make` command.\n\nPlatform Options\n----------------\n\nThe *QEMU RISC-V Virt Machine* platform does not have any platform-specific\noptions.\n\nExecution on QEMU RISC-V 64-bit\n-------------------------------\n\n**No Payload Case**\n\nBuild:\n```\nmake PLATFORM=generic\n```\n\nRun:\n```\nqemu-system-riscv64 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.bin\n```\n\n**U-Boot Payload**\n\nNote: the command line examples here assume that U-Boot was compiled using\nthe `qemu-riscv64_smode_defconfig` configuration.\n\nBuild:\n```\nmake PLATFORM=generic FW_PAYLOAD_PATH=<uboot_build_directory>/u-boot.bin\n```\n\nRun:\n```\nqemu-system-riscv64 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.elf\n```\nor\n```\nqemu-system-riscv64 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_jump.bin \\\n\t-kernel <uboot_build_directory>/u-boot.bin\n```\n\n**Linux Kernel Payload**\n\nNote: We assume that the Linux kernel is compiled using\n*arch/riscv/configs/defconfig*.\n\nBuild:\n```\nmake PLATFORM=generic FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image\n```\n\nRun:\n```\nqemu-system-riscv64 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.elf \\\n\t-drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \\\n\t-device virtio-blk-device,drive=hd0 \\\n\t-append \"root=/dev/vda rw console=ttyS0\"\n```\nor\n```\nqemu-system-riscv64 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_jump.bin \\\n\t-kernel <linux_build_directory>/arch/riscv/boot/Image \\\n\t-drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \\\n\t-device virtio-blk-device,drive=hd0 \\\n\t-append \"root=/dev/vda rw console=ttyS0\"\n```\n\n\nExecution on QEMU RISC-V 32-bit\n-------------------------------\n\n**No Payload Case**\n\nBuild:\n```\nmake PLATFORM=generic PLATFORM_RISCV_XLEN=32\n```\n\nRun:\n```\nqemu-system-riscv32 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.bin\n```\n\n**U-Boot Payload**\n\nNote: the command line examples here assume that U-Boot was compiled using\nthe `qemu-riscv32_smode_defconfig` configuration.\n\nBuild:\n```\nmake PLATFORM=generic PLATFORM_RISCV_XLEN=32 FW_PAYLOAD_PATH=<uboot_build_directory>/u-boot.bin\n```\n\nRun:\n```\nqemu-system-riscv32 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.elf\n```\nor\n```\nqemu-system-riscv32 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_jump.bin \\\n\t-kernel <uboot_build_directory>/u-boot.bin\n```\n\n**Linux Kernel Payload**\n\nNote: We assume that the Linux kernel is compiled using\n*arch/riscv/configs/rv32_defconfig*.\n\nBuild:\n```\nmake PLATFORM=generic PLATFORM_RISCV_XLEN=32 FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image\n```\n\nRun:\n```\nqemu-system-riscv32 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.elf \\\n\t-drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \\\n\t-device virtio-blk-device,drive=hd0 \\\n\t-append \"root=/dev/vda rw console=ttyS0\"\n```\nor\n```\nqemu-system-riscv32 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_jump.bin \\\n\t-kernel <linux_build_directory>/arch/riscv/boot/Image \\\n\t-drive file=<path_to_linux_rootfs>,format=raw,id=hd0 \\\n\t-device virtio-blk-device,drive=hd0 \\\n\t-append \"root=/dev/vda rw console=ttyS0\"\n```\n\nDebugging with GDB\n------------------\n\nIn a first console start OpenSBI with QEMU:\n\n```\nqemu-system-riscv64 -M virt -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.bin \\\n\t-gdb tcp::1234 \\\n\t-S\n\n```\n\nParameter *-gdb tcp::1234* specifies 1234 as the debug port.\nParameter *-S* lets QEMU wait at the first instruction.\n\nIn a second console start GDB:\n\n```\ngdb build/platform/generic/firmware/fw_payload.elf \\\n\t-ex 'target remote localhost:1234'\n\n```\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/renesas-rzfive.md",
    "content": "Renesas RZ/Five SoC (R9A07G043F) Platform\n=========================================\nThe RZ/Five microprocessor includes a single RISC-V CPU Core (Andes AX45MP)\n1.0 GHz, 16-bit DDR3L/DDR4 interface. Supported interfaces include:\n- Memory controller for DDR4-1600 / DDR3L-1333 with 16 bits\n- System RAM (RAM of 128 Kbytes (ECC))\n- SPI Multi I/O Bus Controller 1ch\n- SD Card Host Interface/Multimedia Card Interface (SD/MMC) 2ch\n- Serial Sound Interface (SSI) 4ch\n- Sampling Rate Converter (SRC) 1ch\n- USB2.0 host/function interface 2ch (ch0: Host-Function ch1: Host only)\n- Gigabit Ethernet Interface (GbE) 2ch\n- Controller Area Network Interface (CAN) 2ch (CAN-FD ISO 11898-1 (CD2014) compliant)\n- Multi-function Timer Pulse Unit 3 (MTU3a) 9 ch (16 bits × 8 channels, 32 bits × 1 channel)\n- Port Output Enable 3 (POE3)\n- Watchdog Timer (WDT) 1ch\n- General Timer (GTM) 3ch (32bits)\n- I2C Bus Interface (I2C) 4ch\n- Serial Communication Interface with FIFO (SCIFA) 5ch\n- Serial Communication Interface (SCI) 2ch\n- Renesas Serial Peripheral Interface (RSPI) 3ch\n- A/D Converter (ADC) 2ch\nmaking it ideal for applications such as entry-class social infrastructure\ngateway control and industrial gateway control. More details can be found at\nbelow link [0].\n\n[0] https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rz-mpus/rzfive-general-purpose-microprocessors-risc-v-cpu-core-andes-ax45mp-single-10-ghz-2ch-gigabit-ethernet\n\nTo build platform specific library and firmwares, provide the\n*PLATFORM=generic* parameter to the top level make command.\n\nPlatform Options\n----------------\n\nThe Renesas RZ/Five platform does not have any platform-specific options.\n\nBuilding Renesas RZ/Five Platform\n---------------------------------\n\n```\nmake PLATFORM=generic\n```\n\nDTS Example: (RZ/Five AX45MP)\n-----------------------------\n\n```\n\tcompatible = \"renesas,r9a07g043f01\", \"renesas,r9a07g043\";\n\n\tcpus {\n\t\t#address-cells = <1>;\n\t\t#size-cells = <0>;\n\t\ttimebase-frequency = <12000000>;\n\n\t\tcpu0: cpu@0 {\n\t\t\tcompatible = \"andestech,ax45mp\", \"riscv\";\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <0x0>;\n\t\t\tstatus = \"okay\";\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\tmmu-type = \"riscv,sv39\";\n\t\t\ti-cache-size = <0x8000>;\n\t\t\ti-cache-line-size = <0x40>;\n\t\t\td-cache-size = <0x8000>;\n\t\t\td-cache-line-size = <0x40>;\n\t\t\tclocks = <&cpg CPG_CORE R9A07G043_CLK_I>;\n\n\t\t\tcpu0_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t\tinterrupt-controller;\n\t\t\t};\n\t\t};\n\t};\n\n\tsoc {\n\t\tcompatible = \"simple-bus\";\n\t\t#address-cells = <1>;\n\t\t#size-cells = <0>;\n\t\tranges;\n\n\t\tscif0: serial@1004b800 {\n\t\t\tcompatible = \"renesas,scif-r9a07g043\",\n\t\t\t\t     \"renesas,scif-r9a07g044\";\n\t\t\treg = <0 0x1004b800 0 0x400>;\n\t\t\tinterrupts = <412 IRQ_TYPE_LEVEL_HIGH>,\n\t\t\t\t     <414 IRQ_TYPE_LEVEL_HIGH>,\n\t\t\t\t     <415 IRQ_TYPE_LEVEL_HIGH>,\n\t\t\t\t     <413 IRQ_TYPE_LEVEL_HIGH>,\n\t\t\t\t     <416 IRQ_TYPE_LEVEL_HIGH>,\n\t\t\t\t     <416 IRQ_TYPE_LEVEL_HIGH>;\n\t\t\tinterrupt-names = \"eri\", \"rxi\", \"txi\",\n\t\t\t\t\t  \"bri\", \"dri\", \"tei\";\n\t\t\tclocks = <&cpg CPG_MOD R9A07G043_SCIF0_CLK_PCK>;\n\t\t\tclock-names = \"fck\";\n\t\t\tpower-domains = <&cpg>;\n\t\t\tresets = <&cpg R9A07G043_SCIF0_RST_SYSTEM_N>;\n\t\t\tstatus = \"disabled\";\n\t\t};\n\n\t\tcpg: clock-controller@11010000 {\n\t\t\tcompatible = \"renesas,r9a07g043-cpg\";\n\t\t\treg = <0 0x11010000 0 0x10000>;\n\t\t\tclocks = <&extal_clk>;\n\t\t\tclock-names = \"extal\";\n\t\t\t#clock-cells = <2>;\n\t\t\t#reset-cells = <1>;\n\t\t\t#power-domain-cells = <0>;\n\t\t};\n\n\t\tsysc: system-controller@11020000 {\n\t\t\tcompatible = \"renesas,r9a07g043-sysc\";\n\t\t\treg = <0 0x11020000 0 0x10000>;\n\t\t\tstatus = \"disabled\";\n\t\t};\n\n\t\tpinctrl: pinctrl@11030000 {\n\t\t\tcompatible = \"renesas,r9a07g043-pinctrl\";\n\t\t\treg = <0 0x11030000 0 0x10000>;\n\t\t\tgpio-controller;\n\t\t\t#gpio-cells = <2>;\n\t\t\t#interrupt-cells = <2>;\n\t\t\tinterrupt-controller;\n\t\t\tgpio-ranges = <&pinctrl 0 0 152>;\n\t\t\tclocks = <&cpg CPG_MOD R9A07G043_GPIO_HCLK>;\n\t\t\tpower-domains = <&cpg>;\n\t\t\tresets = <&cpg R9A07G043_GPIO_RSTN>,\n\t\t\t\t <&cpg R9A07G043_GPIO_PORT_RESETN>,\n\t\t\t\t <&cpg R9A07G043_GPIO_SPARE_RESETN>;\n\t\t};\n\n\t\tplmt0: plmt0@110c0000 {\n\t\t\tcompatible = \"andestech,plmt0\", \"riscv,plmt0\";\n\t\t\treg = <0x0 0x110c0000 0x0 0x10000>;\n\t\t\tinterrupts-extended = <&cpu0_intc 7>;\n\t\t};\n\n\t\tplic: interrupt-controller@12c00000 {\n\t\t\tcompatible = \"renesas,r9a07g043-plic\", \"andestech,nceplic100\";\n\t\t\t#interrupt-cells = <2>;\n\t\t\t#address-cells = <0>;\n\t\t\triscv,ndev = <511>;\n\t\t\tinterrupt-controller;\n\t\t\treg = <0x0 0x12c00000 0x0 0x400000>;\n\t\t\tclocks = <&cpg CPG_MOD R9A07G043_NCEPLIC_ACLK>;\n\t\t\tpower-domains = <&cpg>;\n\t\t\tresets = <&cpg R9A07G043_NCEPLIC_ARESETN>;\n\t\t\tinterrupts-extended = <&cpu0_intc 11 &cpu0_intc 9>;\n\t\t};\n\n\t\tplicsw: interrupt-controller@13000000 {\n\t\t\tcompatible = \"andestech,plicsw\";\n\t\t\treg = <0x0 0x13000000 0x0 0x400000>;\n\t\t\tinterrupts-extended = <&cpu0_intc 3>;\n\t\t\tinterrupt-controller;\n\t\t\t#address-cells = <2>;\n\t\t\t#interrupt-cells = <2>;\n\t\t};\n\t};\n```\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/shakti_cclass.md",
    "content": "Shakti C-class SoC Platform\n===========================\nC-Class is a member of the SHAKTI family of processors from\nIndian Institute of Technology - Madras (IIT-M).\n\nIt is an extremely configurable and commercial-grade 5-stage\nin-order core supporting the standard RV64GCSUN ISA extensions.\n\nFor more details, refer:\n* https://gitlab.com/shaktiproject/cores/c-class/blob/master/README.md\n* https://c-class.readthedocs.io/en/latest\n* https://shakti.org.in\n\nPlatform Options\n----------------\n\nThe *Shakti C-class SoC* platform does not have any platform-specific\noptions.\n\nBuilding Shakti C-class Platform\n--------------------------------\n\n**Linux Kernel Payload**\n\n```\nmake PLATFORM=generic FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image FW_FDT_PATH=<shakti.dtb path>\n```\n\n**Test Payload**\n\n```\nmake PLATFORM=generic FW_FDT_PATH=<shakti.dtb path>\n```\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/sifive_fu540.md",
    "content": "SiFive FU540 SoC Platform\n=========================\nThe FU540-C000 is the world’s first 4+1 64-bit RISC-V SoC from SiFive.\nThe HiFive Unleashed development platform is based on FU540-C000 and capable\nof running Linux.\n\nWith QEMU v4.2 or above release, the 'sifive_u' machine can be used to test\nOpenSBI image built for the real hardware as well.\n\nTo build platform specific library and firmwares, provide the\n*PLATFORM=generic* parameter to the top level `make` command.\n\nPlatform Options\n----------------\n\nThe *SiFive FU540 SoC* platform does not have any platform-specific\noptions.\n\nBuilding SiFive Fu540 Platform\n------------------------------\n\nIn order to boot SMP Linux in U-Boot, Linux v5.1 (or higher) and latest\nU-Boot v2020.01 (or higher) should be used.\n\n**Linux Kernel Payload**\n\nThe HiFive Unleashed device tree(DT) is merged in Linux v5.2 release. This\nDT (device tree) is not backward compatible with the DT passed from FSBL.\n\nTo use Linux v5.2 (or higher), the pre-built DTB (DT binary) from Linux v5.2\n(or higher) should be used to build SiFive FU540 OpenSBI binaries by using\nthe compile time option *FW_FDT_PATH*.\n\n```\nmake PLATFORM=generic FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image\nor\n(For Linux v5.2 or higher)\nmake PLATFORM=generic FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image FW_FDT_PATH=<hifive-unleashed-a00.dtb path from Linux kernel>\n```\n\n**U-Boot Payload**\n\nThe command-line example here assumes that U-Boot was compiled using the\nsifive_fu540_defconfig configuration and with U-Boot v2020.01, and up to\nv2021.04. sifive_unleashed_defconfig shall be used with v2021.07 or above.\n\n```\nmake PLATFORM=generic FW_PAYLOAD_PATH=<u-boot_build_dir>/u-boot-dtb.bin\n```\nFor U-Boot v2020.07-rc4 or later releases, SPL support was added in U-Boot.\nPlease refer to the detailed U-Boot booting guide available at [U-Boot].\n\nFlashing the OpenSBI firmware binary to storage media:\n------------------------------------------------------\nThe first stage boot loader ([FSBL]) expects the storage media to have a GPT\npartition table. It tries to look for a partition with following GUID to load\nthe next stage boot loader (OpenSBI in this case).\n\n```\n2E54B353-1271-4842-806F-E436D6AF6985\n```\n\nThat's why the generated firmware binary in above steps should be copied to\nthe partition of the sdcard with above GUID.\n\n```\ndd if=build/platform/generic/firmware/fw_payload.bin of=/dev/disk2s1 bs=1024\n```\n\nIn my case, it is the first partition is **disk2s1** that has been formatted\nwith the above specified GUID.\n\nIn case of a brand new sdcard, it should be formatted with below partition\ntables as described here.\n\n```\nsgdisk --clear                                                               \\\n       --new=1:2048:67583  --change-name=1:bootloader --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985   \\\n       --new=2:264192:     --change-name=2:root       --typecode=2:0FC63DAF-8483-4772-8E79-3D69D8477DE4 \\\n       ${DISK}\n```\n\nBooting SiFive Fu540 Platform\n-----------------------------\n\n**Linux Kernel Payload**\n\nAs Linux kernel image is embedded in the OpenSBI firmware binary, HiFive\nUnleashed will directly boot into Linux directly after powered on.\n\n**U-Boot Payload**\n\nAs U-Boot image is used as payload, HiFive Unleashed will boot into a U-Boot\nprompt. U-Boot tftp boot method can be used to load kernel image in U-Boot\nprompt. Here are the steps do a tftpboot.\n\n1. Set the ip address of the board.\n```\nsetenv ipaddr <ipaddr of the board>\n```\n2. Set the tftpboot server IP.\n```\nsetenv serverip <ipaddr of the tftp server>\n```\n3. Set the network gateway address.\n```\nsetenv gatewayip <ipaddress of the network gateway>\n```\n4. Load the Linux kernel image from the tftp server.\n```\ntftpboot ${kernel_addr_r} <Image path in tftpboot directory>\n```\n5. Load the ramdisk image from the tftp server. This is only required if\nramdisk is loaded from tftp server. This step is optional, if rootfs is\nalready part of the kernel or loaded from an external storage by kernel.\n```\ntftpboot ${ramdisk_addr_r} <ramdisk path in tftpboot directory>\n```\n6. Load the pre-compiled device tree via tftpboot.\n```\ntftpboot ${fdt_addr_r} <hifive-unleashed-a00.dtb path in tftpboot directory>\n```\n7. Set the boot command-line arguments.\n```\nsetenv bootargs \"root=<root partition> rw console=ttySIF0 earlycon=sbi\"\n```\n(Note: root partition should point to\n** /dev/ram ** - If a ramdisk is used\n** root=/dev/mmcblk0pX ** - If a rootfs is already on some other partition\nof sdcard)\n8. Now boot into Linux.\n```\nbooti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}\nor\n(If ramdisk is not loaded from network)\nbooti ${kernel_addr_r} - ${fdt_addr_r}\n```\n\n**U-Boot & Linux Kernel as a single payload**\n\nAt U-Boot prompt execute the following boot command to boot Linux.\n\n```\nbooti ${kernel_addr_r} - ${fdt_addr_r}\n```\n\nQEMU Specific Instructions\n--------------------------\nIf you want to test OpenSBI with QEMU 'sifive_u' machine, please follow the\nsame instructions above, with the exception of not passing FW_FDT_PATH.\n\nThis is because QEMU generates a device tree blob on the fly based on the\ncommand line parameters, and it's compatible with the one used in the upstream\nLinux kernel.\n\nWhen U-Boot v2021.07 (or higher) is used as the payload, as the SiFive FU540\nDTB for the real hardware is embedded in U-Boot binary itself, due to the same\nreason above, we need to switch the U-Boot sifive_unleashed_defconfig\nconfiguration from **CONFIG_OF_SEPARATE** to **CONFIG_OF_PRIOR_STAGE** so that\nU-Boot uses the DTB generated by QEMU, and u-boot.bin should be used as the\npayload image, like:\n\n```\nmake PLATFORM=generic FW_PAYLOAD_PATH=<u-boot_build_dir>/u-boot.bin\n```\n\nU-Boot v2020.07 release added SPL support to SiFive HiFive Unleashed board,\nhence a build error will be seen after you switch to **CONFIG_OF_PRIOR_STAGE**.\n\n```\n./tools/mkimage: Can't open arch/riscv/dts/hifive-unleashed-a00.dtb: No such file or directory\n./tools/mkimage: failed to build FIT\nMakefile:1402: recipe for target 'u-boot.img' failed\nmake: *** [u-boot.img] Error 1\n```\n\nThe above errors can be safely ignored as we don't run U-Boot SPL under QEMU.\n\nRun:\n```\nqemu-system-riscv64 -M sifive_u -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.bin\n```\nor\n```\nqemu-system-riscv64 -M sifive_u -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_jump.bin \\\n\t-kernel <uboot_build_dir>/u-boot.bin\n```\n\nWhile the real hardware operates at the 64-bit mode, it's possible for QEMU to\ntest the 32-bit OpenSBI firmware. This can be helpful for testing 32-bit SiFive\nspecific drivers.\n\n[U-Boot]: https://gitlab.denx.de/u-boot/u-boot/blob/master/doc/board/sifive/fu540.rst\n[FSBL]: https://github.com/sifive/freedom-u540-c000-bootloader\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/spike.md",
    "content": "Spike Simulator Platform\n========================\n\nThe **Spike** is a RISC-V ISA simulator which implements a functional model\nof one or more RISC-V harts. The **Spike** compatible virtual platform is\nalso available on QEMU. In fact, we can use same OpenSBI firmware binaries\non **Spike** simulator and QEMU Spike machine.\n\nFor more details, refer [Spike on GitHub](https://github.com/riscv/riscv-isa-sim)\n\nTo build the platform-specific library and firmware images, provide the\n*PLATFORM=generic* parameter to the top level `make` command.\n\nPlatform Options\n----------------\n\nThe *Spike* platform does not have any platform-specific options.\n\nExecution on Spike Simulator\n----------------------------\n\n**No Payload Case**\n\nBuild:\n```\nmake PLATFORM=generic\n```\n\nRun:\n```\nspike build/platform/generic/firmware/fw_payload.elf\n```\n\n**Linux Kernel Payload**\n\nNote: We assume that the Linux kernel is compiled using\n*arch/riscv/configs/defconfig*.\n\nBuild:\n```\nmake PLATFORM=generic FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image\n```\n\nRun:\n```\nspike -m256 \\\n\t--initrd <path_to_cpio_ramdisk> \\\n\t--bootargs 'root=/dev/ram rw console=hvc0 earlycon=sbi' \\\n\tbuild/platform/generic/firmware/fw_payload.elf\n```\nor\n```\nspike -m256 \\\n\t--kernel <linux_build_directory>/arch/riscv/boot/Image \\\n\t--initrd <path_to_cpio_ramdisk> \\\n\t--bootargs 'root=/dev/ram rw console=hvc0 earlycon=sbi' \\\n\tbuild/platform/generic/firmware/fw_jump.elf\n```\n\nExecution on QEMU RISC-V 64-bit\n-------------------------------\n\n**No Payload Case**\n\nBuild:\n```\nmake PLATFORM=generic\n```\n\nRun:\n```\nqemu-system-riscv64 -M spike -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.elf\n```\n\n**Linux Kernel Payload**\n\nNote: We assume that the Linux kernel is compiled using\n*arch/riscv/configs/defconfig*.\n\nBuild:\n```\nmake PLATFORM=generic FW_PAYLOAD_PATH=<linux_build_directory>/arch/riscv/boot/Image\n```\n\nRun:\n```\nqemu-system-riscv64 -M spike -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_payload.elf \\\n\t-initrd <path_to_cpio_ramdisk> \\\n\t-append \"root=/dev/ram rw console=hvc0 earlycon=sbi\"\n```\nor\n```\nqemu-system-riscv64 -M spike -m 256M -nographic \\\n\t-bios build/platform/generic/firmware/fw_jump.elf \\\n\t-kernel <linux_build_directory>/arch/riscv/boot/Image \\\n\t-initrd <path_to_cpio_ramdisk> \\\n\t-append \"root=/dev/ram rw console=hvc0 earlycon=sbi\"\n```\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform/thead-c9xx.md",
    "content": "T-HEAD C9xx Series Processors\n=============================\n\nThe **C9xx** series processors are high-performance RISC-V architecture\nmulti-core processors with AI vector acceleration engine.\n\nFor more details, refer [T-HEAD.CN](https://www.t-head.cn/)\n\nTo build the platform-specific library and firmware images, provide the\n*PLATFORM=generic* parameter to the top level `make` command.\n\nPlatform Options\n----------------\n\nThe *T-HEAD C9xx* does not have any platform-specific compile options\nbecause it uses generic platform.\n\n```\nCROSS_COMPILE=riscv64-linux-gnu- PLATFORM=generic /usr/bin/make\n```\n\nThe *T-HEAD C9xx* DTB provided to OpenSBI generic firmwares will usually have\n\"riscv,clint0\", \"riscv,plic0\", \"thead,reset-sample\" compatible strings.\n\nDTS Example1: (Single core, eg: Allwinner D1 - c906)\n----------------------------------------------------\n\n```\n\tcpus {\n\t\t#address-cells = <1>;\n\t\t#size-cells = <0>;\n\t\ttimebase-frequency = <3000000>;\n\t\tcpu@0 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <0>;\n\t\t\tstatus = \"okay\";\n\t\t\tcompatible = \"riscv\";\n\t\t\triscv,isa = \"rv64imafdcv\";\n\t\t\tmmu-type = \"riscv,sv39\";\n\t\t\tcpu0_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t\tinterrupt-controller;\n\t\t\t};\n\t\t};\n\t};\n\n\tsoc {\n\t\t#address-cells = <2>;\n\t\t#size-cells = <2>;\n\t\tcompatible = \"simple-bus\";\n\t\tranges;\n\n\t\tclint0: clint@14000000 {\n\t\t\tcompatible = \"allwinner,sun20i-d1-clint\";\n\t\t\tinterrupts-extended = <\n\t\t\t\t&cpu0_intc  3 &cpu0_intc  7\n\t\t\t\t>;\n\t\t\treg = <0x0 0x14000000 0x0 0x04000000>;\n\t\t};\n\n\t\tintc: interrupt-controller@10000000 {\n\t\t\t#interrupt-cells = <1>;\n\t\t\tcompatible = \"allwinner,sun20i-d1-plic\",\n\t\t\t\t     \"thead,c900-plic\";\n\t\t\tinterrupt-controller;\n\t\t\tinterrupts-extended = <\n\t\t\t\t&cpu0_intc  0xffffffff &cpu0_intc  9\n\t\t\t\t>;\n\t\t\treg = <0x0 0x10000000 0x0 0x04000000>;\n\t\t\treg-names = \"control\";\n\t\t\triscv,max-priority = <7>;\n\t\t\triscv,ndev = <200>;\n\t\t};\n\t}\n```\n\nDTS Example2: (Multi cores with soc reset-regs)\n-----------------------------------------------\n\n```\n\tcpus {\n\t\t#address-cells = <1>;\n\t\t#size-cells = <0>;\n\t\ttimebase-frequency = <3000000>;\n\t\tcpu@0 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <0>;\n\t\t\tstatus = \"okay\";\n\t\t\tcompatible = \"riscv\";\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\tmmu-type = \"riscv,sv39\";\n\t\t\tcpu0_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t\tinterrupt-controller;\n\t\t\t};\n\t\t};\n\t\tcpu@1 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <1>;\n\t\t\tstatus = \"fail\";\n\t\t\tcompatible = \"riscv\";\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\tmmu-type = \"riscv,sv39\";\n\t\t\tcpu1_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t\tinterrupt-controller;\n\t\t\t};\n\t\t};\n\t\tcpu@2 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <2>;\n\t\t\tstatus = \"fail\";\n\t\t\tcompatible = \"riscv\";\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\tmmu-type = \"riscv,sv39\";\n\t\t\tcpu2_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t\tinterrupt-controller;\n\t\t\t};\n\t\t};\n\t\tcpu@3 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\treg = <3>;\n\t\t\tstatus = \"fail\";\n\t\t\tcompatible = \"riscv\";\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\tmmu-type = \"riscv,sv39\";\n\t\t\tcpu3_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t\tinterrupt-controller;\n\t\t\t};\n\t\t};\n\t};\n\n\tsoc {\n\t\t#address-cells = <2>;\n\t\t#size-cells = <2>;\n\t\tcompatible = \"simple-bus\";\n\t\tranges;\n\n\t\treset: reset-sample {\n\t\t\tcompatible = \"thead,reset-sample\";\n\t\t\tentry-reg = <0xff 0xff019050>;\n\t\t\tentry-cnt = <4>;\n\t\t\tcontrol-reg = <0xff 0xff015004>;\n\t\t\tcontrol-val = <0x1c>;\n\t\t\tcsr-copy = <0x7f3 0x7c0 0x7c1 0x7c2 0x7c3 0x7c5 0x7cc>;\n\t\t};\n\n\t\tclint0: clint@ffdc000000 {\n\t\t\tcompatible = \"riscv,clint0\";\n\t\t\tinterrupts-extended = <\n\t\t\t\t&cpu0_intc  3 &cpu0_intc  7\n\t\t\t\t&cpu1_intc  3 &cpu1_intc  7\n\t\t\t\t&cpu2_intc  3 &cpu2_intc  7\n\t\t\t\t&cpu3_intc  3 &cpu3_intc  7\n\t\t\t\t&cpu4_intc  3 &cpu4_intc  7\n\t\t\t\t>;\n\t\t\treg = <0xff 0xdc000000 0x0 0x04000000>;\n\t\t};\n\n\t\tintc: interrupt-controller@ffd8000000 {\n\t\t\t#interrupt-cells = <1>;\n\t\t\tcompatible = \"thead,c900-plic\";\n\t\t\tinterrupt-controller;\n\t\t\tinterrupts-extended = <\n\t\t\t\t&cpu0_intc  0xffffffff &cpu0_intc  9\n\t\t\t\t&cpu1_intc  0xffffffff &cpu1_intc  9\n\t\t\t\t&cpu2_intc  0xffffffff &cpu2_intc  9\n\t\t\t\t&cpu3_intc  0xffffffff &cpu3_intc  9\n\t\t\t\t>;\n\t\t\treg = <0xff 0xd8000000 0x0 0x04000000>;\n\t\t\treg-names = \"control\";\n\t\t\triscv,max-priority = <7>;\n\t\t\triscv,ndev = <80>;\n\t\t};\n\t}\n```\n\nDTS Example2: (Multi cores with old reset csrs)\n-----------------------------------------------\n```\n\treset: reset-sample {\n\t\tcompatible = \"thead,reset-sample\";\n\t\tusing-csr-reset;\n\t\tcsr-copy = <0x7c0 0x7c1 0x7c2 0x7c3 0x7c5 0x7cc\n\t\t\t    0x3b0 0x3b1 0x3b2 0x3b3\n\t\t\t    0x3b4 0x3b5 0x3b6 0x3b7\n\t\t\t    0x3a0>;\n\t};\n```\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform_guide.md",
    "content": "OpenSBI Platform Support Guideline\n==================================\n\nThe OpenSBI platform support allows an implementation to define a set of\nplatform-specific hooks (hardware manipulation functions) in the form of a\n*struct sbi_platform* data structure instance. This instance is required by\nthe platform-independent *libsbi.a* to execute platform-specific operations.\n\nEach of the reference platform supports provided by OpenSBI defines an instance\nof the *struct sbi_platform* data structure. For each supported platform,\n*libplatsbi.a* integrates this instance with *libsbi.a* to create a\nplatform-specific OpenSBI static library. This library is installed\nin *<install_directory>/platform/<platform_subdir>/lib/libplatsbi.a*\n\nOpenSBI also provides implementation examples of bootable runtime firmwares for\nthe supported platforms. These firmwares are linked against *libplatsbi.a*.\nFirmware binaries are installed in\n*<install_directory>/platform/<platform_subdir>/bin*. These firmwares can be\nused as executable runtime firmwares on the supported platforms as a replacement\nfor the legacy *riscv-pk* boot loader (BBL).\n\nA complete doxygen-style documentation of *struct sbi_platform* and related\nAPIs is available in the file *include/sbi/sbi_platform.h*.\n\nAdding support for a new platform\n---------------------------------\n\nSupport for a new platform named *&lt;xyz&gt;* can be added as follows:\n\n1. Create a directory named *&lt;xyz&gt;* under the *platform/* directory.\n2. Create platform configuration files named *Kconfig* and *configs/defconfig*\n   under the *platform/&lt;xyz&gt;/* directory. These configuration files will\n   provide the build time configuration for the sources to be compiled.\n3. Create a *platform/&lt;xyz&gt;/objects.mk* file for listing the platform\n   object files to be compiled. This file also provides platform-specific\n   compiler flags, and select firmware options.\n4. Create a *platform/&lt;xyz&gt;/platform.c* file providing a\n   *struct sbi_platform* instance.\n\nA platform support code template is available under the *platform/template*\ndirectory. Copying this directory and its content as a new directory named\n*&lt;xyz&gt;* under the *platform/* directory will create all the files\nmentioned above.\n"
  },
  {
    "path": "ftpm-opensbi/docs/platform_requirements.md",
    "content": "OpenSBI Platform Requirements\n=============================\n\nThe RISC-V platform requirements for OpenSBI can change over time\nwith advances in RISC-V specifications and ecosystem.\n\nTo handle this, we have two types of RISC-V platform requirements:\n\n1. **Base platform requirements** which apply to all OpenSBI releases\n2. **Release specific platform requirements** which apply to a OpenSBI\n   release and later releases\n\nCurrently, we don't have any **Release specific platform requirements**,\nbut such platform requirements will be added in future.\n\nBase Platform Requirements\n--------------------------\n\nThe base RISC-V platform requirements for OpenSBI are as follows:\n\n1. At least rv32ima or rv64ima required on all HARTs\n2. At least one HART should have S-mode support because:\n\n     * SBI calls are meant for RISC-V S-mode (Supervisor mode)\n     * OpenSBI implements SBI calls for S-mode software\n\n3. The MTVEC CSR on all HARTs must support direct mode\n4. The PMP CSRs are optional. If PMP CSRs are not implemented then\n   OpenSBI cannot protect M-mode firmware and secured memory regions\n5. The TIME CSR is optional. If TIME CSR is not implemented in\n   hardware then a 64-bit MMIO counter is required to track time\n   and emulate TIME CSR\n6. Hardware support for injecting M-mode software interrupts on\n   a multi-HART platform\n\nThe RISC-V extensions not covered by rv32ima or rv64ima are optional\nfor OpenSBI. Although, OpenSBI will detect and handle some of these\noptional RISC-V extensions at runtime.\n\nThe optional RISC-V extensions handled by OpenSBI at runtime are:\n\n* D-extension: Double precision floating point\n* F-extension: Single precision floating point\n* H-extension: Hypervisor\n"
  },
  {
    "path": "ftpm-opensbi/docs/pmu_support.md",
    "content": "OpenSBI SBI PMU extension support\n==================================\nSBI PMU extension supports allow supervisor software to configure/start/stop\nany performance counter at anytime. Thus, a user can leverage full\ncapability of performance analysis tools such as perf if SBI PMU extension is\nenabled. The OpenSBI implementation makes the following assumptions about the\nhardware platform.\n\n * The platform must provide information about PMU event to counter mapping\nvia device tree or platform specific hooks. Otherwise, SBI PMU extension will\nnot be enabled.\n\n * The platforms should provide information about the PMU event selector values\nthat should be encoded in the expected value of MHPMEVENTx while configuring\nMHPMCOUNTERx for that specific event. This can be done via a device tree or\nplatform specific hooks. The exact value to be written to he MHPMEVENTx is\ncompletely depends on platform. Generic platform writes the zero-extended event_idx\nas the expected value for hardware cache/generic events as suggested by the SBI\nspecification.\n\nSBI PMU Device Tree Bindings\n----------------------------\n\nPlatforms may choose to describe PMU event selector and event to counter mapping\nvalues via device tree. The following sections describe the PMU DT node\nbindings in details.\n\n* **compatible** (Mandatory) - The compatible string of SBI PMU device tree node.\nThis DT property must have the value **riscv,pmu**.\n\n* **riscv,event-to-mhpmevent**(Optional) - It represents an ONE-to-ONE mapping\nbetween a PMU event and the event selector value that platform expects to be\nwritten to the MHPMEVENTx CSR for that event. The mapping is encoded in a\ntable format where each row represents an event. The first column represent the\nevent idx where the 2nd & 3rd column represent the event selector value that\nshould be encoded in the expected value to be written in MHPMEVENTx.\nThis property shouldn't encode any raw hardware event.\n\n* **riscv,event-to-mhpmcounters**(Optional) - It represents a MANY-to-MANY\nmapping between a range of events and all the MHPMCOUNTERx in a bitmap format\nthat can be used to monitor these range of events. The information is encoded in\na table format where each row represents a certain range of events and\ncorresponding counters. The first column represents starting of the pmu event id\nand 2nd column represents the end of the pmu event id. The third column\nrepresent a bitmap of all the MHPMCOUNTERx. This property is mandatory if\nriscv,event-to-mhpmevent is present. Otherwise, it can be omitted. This property\nshouldn't encode any raw event.\n\n* **riscv,raw-event-to-mhpmcounters**(Optional) - It represents an ONE-to-MANY\nor MANY-to-MANY mapping between the raw event(s) and all the MHPMCOUNTERx in\na bitmap format that can be used to monitor that raw event. The encoding of the\nraw events are platform specific. The information is encoded in a table format\nwhere each row represents the specific raw event(s). The first column is a 64bit\nmatch value where the invariant bits of range of events are set. The second\ncolumn is a 64 bit mask that will have all the variant bits of the range of\nevents cleared. All other bits should be set in the mask.\nThe third column is a 32bit value to represent bitmap of all MHPMCOUNTERx that\ncan monitor these set of event(s).\nIf a platform directly encodes each raw PMU event as a unique ID, the value of\nselect_mask must be 0xffffffff_ffffffff.\n\n*Note:* A platform may choose to provide the mapping between event & counters\nvia platform hooks rather than the device tree.\n\n### Example 1\n\n```\npmu {\n\tcompatible \t\t\t= \"riscv,pmu\";\n\triscv,event-to-mhpmevent \t\t= <0x0000B  0x0000 0x0001>;\n\triscv,event-to-mhpmcounters \t= <0x00001 0x00001 0x00000001>,\n\t\t\t\t\t\t  <0x00002 0x00002 0x00000004>,\n\t\t\t\t\t\t  <0x00003 0x0000A 0x00000ff8>,\n\t\t\t\t\t\t  <0x10000 0x10033 0x000ff000>;\n\t\t\t\t\t/* For event ID 0x0002 */\n\triscv,raw-event-to-mhpmcounters = <0x0000 0x0002 0xffffffff 0xffffffff 0x00000f8>,\n\t\t\t\t\t/* For event ID 0-4 */\n\t\t\t\t\t<0x0 0x0 0xffffffff 0xfffffff0 0x00000ff0>,\n\t\t\t\t\t/* For event ID 0xffffffff0000000f - 0xffffffff000000ff */\n\t\t\t\t\t<0xffffffff 0x0 0xffffffff 0xffffff0f 0x00000ff0>;\n};\n```\n\n### Example 2\n\n```\n/*\n * For HiFive Unmatched board. The encodings can be found here\n * https://sifive.cdn.prismic.io/sifive/1a82e600-1f93-4f41-b2d8-86ed8b16acba_fu740-c000-manual-v1p6.pdf\n * This example also binds standard SBI PMU hardware id's to U74 PMU event codes, U74 uses bitfield for\n * events encoding, so several U74 events can be bound to single perf id.\n * See SBI PMU hardware id's in include/sbi/sbi_ecall_interface.h\n */\npmu {\n\tcompatible \t\t\t= \"riscv,pmu\";\n\triscv,event-to-mhpmevent =\n/* SBI_PMU_HW_CACHE_REFERENCES -> Instruction cache/ITIM busy | Data cache/DTIM busy */\n\t\t\t\t   <0x00003 0x00000000 0x1801>,\n/* SBI_PMU_HW_CACHE_MISSES -> Instruction cache miss | Data cache miss or memory-mapped I/O access */\n\t\t\t\t   <0x00004 0x00000000 0x0302>,\n/* SBI_PMU_HW_BRANCH_INSTRUCTIONS -> Conditional branch retired */\n\t\t\t\t   <0x00005 0x00000000 0x4000>,\n/* SBI_PMU_HW_BRANCH_MISSES -> Branch direction misprediction | Branch/jump target misprediction */\n\t\t\t\t   <0x00006 0x00000000 0x6001>,\n/* L1D_READ_MISS -> Data cache miss or memory-mapped I/O access */\n\t\t\t\t   <0x10001 0x00000000 0x0202>,\n/* L1D_WRITE_ACCESS -> Data cache write-back */\n\t\t\t\t   <0x10002 0x00000000 0x0402>,\n/* L1I_READ_ACCESS -> Instruction cache miss */\n\t\t\t\t   <0x10009 0x00000000 0x0102>,\n/* LL_READ_MISS -> UTLB miss */\n\t\t\t\t   <0x10011 0x00000000 0x2002>,\n/* DTLB_READ_MISS -> Data TLB miss */\n\t\t\t\t   <0x10019 0x00000000 0x1002>,\n/* ITLB_READ_MISS-> Instruction TLB miss */\n\t\t\t\t   <0x10021 0x00000000 0x0802>;\n\triscv,event-to-mhpmcounters = <0x00003 0x00006 0x18>,\n\t\t\t\t      <0x10001 0x10002 0x18>,\n\t\t\t\t      <0x10009 0x10009 0x18>,\n\t\t\t\t      <0x10011 0x10011 0x18>,\n\t\t\t\t      <0x10019 0x10019 0x18>,\n\t\t\t\t      <0x10021 0x10021 0x18>;\n\triscv,raw-event-to-mhpmcounters = <0x0 0x0 0xffffffff 0xfc0000ff 0x18>,\n\t\t\t\t\t  <0x0 0x1 0xffffffff 0xfff800ff 0x18>,\n\t\t\t\t\t  <0x0 0x2 0xffffffff 0xffffe0ff 0x18>;\n};\n```\n"
  },
  {
    "path": "ftpm-opensbi/firmware/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n"
  },
  {
    "path": "ftpm-opensbi/firmware/external_deps.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\n$(platform_build_dir)/firmware/fw_dynamic.o: $(FW_FDT_PATH)\n$(platform_build_dir)/firmware/fw_jump.o: $(FW_FDT_PATH)\n$(platform_build_dir)/firmware/fw_payload.o: $(FW_FDT_PATH)\n\n$(platform_build_dir)/firmware/fw_payload.o: $(FW_PAYLOAD_PATH_FINAL)\n"
  },
  {
    "path": "ftpm-opensbi/firmware/fw_base.S",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/riscv_elf.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_trap.h>\n\n#define BOOT_STATUS_RELOCATE_DONE\t1\n#define BOOT_STATUS_BOOT_HART_DONE\t2\n\n.macro\tMOV_3R __d0, __s0, __d1, __s1, __d2, __s2\n\tadd\t\\__d0, \\__s0, zero\n\tadd\t\\__d1, \\__s1, zero\n\tadd\t\\__d2, \\__s2, zero\n.endm\n\n.macro\tMOV_5R __d0, __s0, __d1, __s1, __d2, __s2, __d3, __s3, __d4, __s4\n\tadd\t\\__d0, \\__s0, zero\n\tadd\t\\__d1, \\__s1, zero\n\tadd\t\\__d2, \\__s2, zero\n\tadd\t\\__d3, \\__s3, zero\n\tadd\t\\__d4, \\__s4, zero\n.endm\n\n/*\n * If __start_reg <= __check_reg and __check_reg < __end_reg then\n *   jump to __pass\n */\n.macro BRANGE __start_reg, __end_reg, __check_reg, __jump_lable\n\tblt\t\\__check_reg, \\__start_reg, 999f\n\tbge\t\\__check_reg, \\__end_reg, 999f\n\tj\t\\__jump_lable\n999:\n.endm\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.globl _start\n\t.globl _start_warm\n_start:\n\t/* Find preferred boot HART id */\n\tMOV_3R\ts0, a0, s1, a1, s2, a2\n\tcall\tfw_boot_hart\n\tadd\ta6, a0, zero\n\tMOV_3R\ta0, s0, a1, s1, a2, s2\n\tli\ta7, -1\n\tbeq\ta6, a7, _try_lottery\n\t/* Jump to relocation wait loop if we are not boot hart */\n\tbne\ta0, a6, _wait_relocate_copy_done\n_try_lottery:\n\t/* Jump to relocation wait loop if we don't get relocation lottery */\n\tlla\ta6, _relocate_lottery\n\tli\ta7, 1\n\tamoadd.w a6, a7, (a6)\n\tbnez\ta6, _wait_relocate_copy_done\n\n\t/* Save load address */\n\tlla\tt0, _load_start\n\tlla\tt1, _fw_start\n\tREG_S\tt1, 0(t0)\n\n#ifdef FW_PIC\n\t/* relocate the global table content */\n\tlla\tt0, _link_start\n\tREG_L\tt0, 0(t0)\n\t/* t1 shall has the address of _fw_start */\n\tsub\tt2, t1, t0\n\tlla\tt3, _runtime_offset\n\tREG_S\tt2, (t3)\n\tlla\tt0, __rel_dyn_start\n\tlla\tt1, __rel_dyn_end\n\tbeq\tt0, t1, _relocate_done\n\tj\t5f\n2:\n\tREG_L\tt5, -(REGBYTES*2)(t0)\t/* t5 <-- relocation info:type */\n\tli\tt3, R_RISCV_RELATIVE\t/* reloc type R_RISCV_RELATIVE */\n\tbne\tt5, t3, 3f\n\tREG_L\tt3, -(REGBYTES*3)(t0)\n\tREG_L\tt5, -(REGBYTES)(t0)\t/* t5 <-- addend */\n\tadd\tt5, t5, t2\n\tadd\tt3, t3, t2\n\tREG_S\tt5, 0(t3)\t\t/* store runtime address to the GOT entry */\n\tj\t5f\n\n3:\n\tlla\tt4, __dyn_sym_start\n\n4:\n\tREG_L\tt5, -(REGBYTES*2)(t0)\t/* t5 <-- relocation info:type */\n\tsrli\tt6, t5, SYM_INDEX\t/* t6 <--- sym table index */\n\tandi\tt5, t5, 0xFF\t\t/* t5 <--- relocation type */\n\tli\tt3, RELOC_TYPE\n\tbne\tt5, t3, 5f\n\n\t/* address R_RISCV_64 or R_RISCV_32 cases*/\n\tREG_L\tt3, -(REGBYTES*3)(t0)\n\tli\tt5, SYM_SIZE\n\tmul\tt6, t6, t5\n\tadd\ts5, t4, t6\n\tREG_L\tt6, -(REGBYTES)(t0)\t/* t0 <-- addend */\n\tREG_L\tt5, REGBYTES(s5)\n\tadd\tt5, t5, t6\n\tadd\tt5, t5, t2\t\t/* t5 <-- location to fix up in RAM */\n\tadd\tt3, t3, t2\t\t/* t3 <-- location to fix up in RAM */\n\tREG_S\tt5, 0(t3)\t\t/* store runtime address to the variable */\n\n5:\n\taddi\tt0, t0, (REGBYTES*3)\n\tble\tt0, t1, 2b\n\tj\t_relocate_done\n_wait_relocate_copy_done:\n\tj\t_wait_for_boot_hart\n#else\n\t/* Relocate if load address != link address */\n_relocate:\n\tlla\tt0, _link_start\n\tREG_L\tt0, 0(t0)\n\tlla\tt1, _link_end\n\tREG_L\tt1, 0(t1)\n\tlla\tt2, _load_start\n\tREG_L\tt2, 0(t2)\n\tbeq\tt0, t2, _relocate_done\n\tsub\tt3, t1, t0\n\tadd\tt3, t3, t2\n\tlla\tt4, _relocate_done\n\tsub\tt4, t4, t2\n\tadd\tt4, t4, t0\n\tblt\tt2, t0, _relocate_copy_to_upper\n_relocate_copy_to_lower:\n\tble\tt1, t2, _relocate_copy_to_lower_loop\n\tlla\tt3, _relocate_lottery\n\tBRANGE\tt2, t1, t3, _start_hang\n\tlla\tt3, _boot_status\n\tBRANGE\tt2, t1, t3, _start_hang\n\tlla\tt3, _relocate\n\tlla\tt5, _relocate_done\n\tBRANGE\tt2, t1, t3, _start_hang\n\tBRANGE\tt2, t1, t5, _start_hang\n\tBRANGE  t3, t5, t2, _start_hang\n_relocate_copy_to_lower_loop:\n\tREG_L\tt3, 0(t2)\n\tREG_S\tt3, 0(t0)\n\tadd\tt0, t0, __SIZEOF_POINTER__\n\tadd\tt2, t2, __SIZEOF_POINTER__\n\tblt\tt0, t1, _relocate_copy_to_lower_loop\n\tjr\tt4\n_relocate_copy_to_upper:\n\tble\tt3, t0, _relocate_copy_to_upper_loop\n\tlla\tt2, _relocate_lottery\n\tBRANGE\tt0, t3, t2, _start_hang\n\tlla\tt2, _boot_status\n\tBRANGE\tt0, t3, t2, _start_hang\n\tlla\tt2, _relocate\n\tlla\tt5, _relocate_done\n\tBRANGE\tt0, t3, t2, _start_hang\n\tBRANGE\tt0, t3, t5, _start_hang\n\tBRANGE\tt2, t5, t0, _start_hang\n_relocate_copy_to_upper_loop:\n\tadd\tt3, t3, -__SIZEOF_POINTER__\n\tadd\tt1, t1, -__SIZEOF_POINTER__\n\tREG_L\tt2, 0(t3)\n\tREG_S\tt2, 0(t1)\n\tblt\tt0, t1, _relocate_copy_to_upper_loop\n\tjr\tt4\n_wait_relocate_copy_done:\n\tlla\tt0, _fw_start\n\tlla\tt1, _link_start\n\tREG_L\tt1, 0(t1)\n\tbeq\tt0, t1, _wait_for_boot_hart\n\tlla\tt2, _boot_status\n\tlla\tt3, _wait_for_boot_hart\n\tsub\tt3, t3, t0\n\tadd\tt3, t3, t1\n1:\n\t/* waitting for relocate copy done (_boot_status == 1) */\n\tli\tt4, BOOT_STATUS_RELOCATE_DONE\n\tREG_L\tt5, 0(t2)\n\t/* Reduce the bus traffic so that boot hart may proceed faster */\n\tnop\n\tnop\n\tnop\n\tbgt     t4, t5, 1b\n\tjr\tt3\n#endif\n_relocate_done:\n\n\t/*\n\t * Mark relocate copy done\n\t * Use _boot_status copy relative to the load address\n\t */\n\tlla\tt0, _boot_status\n#ifndef FW_PIC\n\tlla\tt1, _link_start\n\tREG_L\tt1, 0(t1)\n\tlla\tt2, _load_start\n\tREG_L\tt2, 0(t2)\n\tsub\tt0, t0, t1\n\tadd\tt0, t0, t2\n#endif\n\tli\tt1, BOOT_STATUS_RELOCATE_DONE\n\tREG_S\tt1, 0(t0)\n\tfence\trw, rw\n\n\t/* At this point we are running from link address */\n\n\t/* Reset all registers for boot HART */\n\tli\tra, 0\n\tcall\t_reset_regs\n\n\t/* Zero-out BSS */\n\tlla\ts4, _bss_start\n\tlla\ts5, _bss_end\n_bss_zero:\n\tREG_S\tzero, (s4)\n\tadd\ts4, s4, __SIZEOF_POINTER__\n\tblt\ts4, s5, _bss_zero\n\n\t/* Setup temporary trap handler */\n\tlla\ts4, _start_hang\n\tcsrw\tCSR_MTVEC, s4\n\n\t/* Setup temporary stack */\n\tlla\ts4, _fw_end\n\tli\ts5, (SBI_SCRATCH_SIZE * 2)\n\tadd\tsp, s4, s5\n\n\t/* Allow main firmware to save info */\n\tMOV_5R\ts0, a0, s1, a1, s2, a2, s3, a3, s4, a4\n\tcall\tfw_save_info\n\tMOV_5R\ta0, s0, a1, s1, a2, s2, a3, s3, a4, s4\n\n#ifdef FW_FDT_PATH\n\t/* Override previous arg1 */\n\tlla\ta1, fw_fdt_bin\n#endif\n\n\t/*\n\t * Initialize platform\n\t * Note: The a0 to a4 registers passed to the\n\t * firmware are parameters to this function.\n\t */\n\tMOV_5R\ts0, a0, s1, a1, s2, a2, s3, a3, s4, a4\n\tcall\tfw_platform_init\n\tadd\tt0, a0, zero\n\tMOV_5R\ta0, s0, a1, s1, a2, s2, a3, s3, a4, s4\n\tadd\ta1, t0, zero\n\n\t/* Preload HART details\n\t * s7 -> HART Count\n\t * s8 -> HART Stack Size\n\t */\n\tlla\ta4, platform\n#if __riscv_xlen > 32\n\tlwu\ts7, SBI_PLATFORM_HART_COUNT_OFFSET(a4)\n\tlwu\ts8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4)\n#else\n\tlw\ts7, SBI_PLATFORM_HART_COUNT_OFFSET(a4)\n\tlw\ts8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4)\n#endif\n\n\t/* Setup scratch space for all the HARTs*/\n\tlla\ttp, _fw_end\n\tmul\ta5, s7, s8\n\tadd\ttp, tp, a5\n\t/* Keep a copy of tp */\n\tadd\tt3, tp, zero\n\t/* Counter */\n\tli\tt2, 1\n\t/* hartid 0 is mandated by ISA */\n\tli\tt1, 0\n_scratch_init:\n\t/*\n\t * The following registers hold values that are computed before\n\t * entering this block, and should remain unchanged.\n\t *\n\t * t3 -> the firmware end address\n\t * s7 -> HART count\n\t * s8 -> HART stack size\n\t */\n\tadd\ttp, t3, zero\n\tmul\ta5, s8, t1\n\tsub\ttp, tp, a5\n\tli\ta5, SBI_SCRATCH_SIZE\n\tsub\ttp, tp, a5\n\n\t/* Initialize scratch space */\n\t/* Store fw_start and fw_size in scratch space */\n\tlla\ta4, _fw_start\n\tsub\ta5, t3, a4\n\tREG_S\ta4, SBI_SCRATCH_FW_START_OFFSET(tp)\n\tREG_S\ta5, SBI_SCRATCH_FW_SIZE_OFFSET(tp)\n\t/* Store next arg1 in scratch space */\n\tMOV_3R\ts0, a0, s1, a1, s2, a2\n\tcall\tfw_next_arg1\n\tREG_S\ta0, SBI_SCRATCH_NEXT_ARG1_OFFSET(tp)\n\tMOV_3R\ta0, s0, a1, s1, a2, s2\n\t/* Store next address in scratch space */\n\tMOV_3R\ts0, a0, s1, a1, s2, a2\n\tcall\tfw_next_addr\n\tREG_S\ta0, SBI_SCRATCH_NEXT_ADDR_OFFSET(tp)\n\tMOV_3R\ta0, s0, a1, s1, a2, s2\n\t/* Store next mode in scratch space */\n\tMOV_3R\ts0, a0, s1, a1, s2, a2\n\tcall\tfw_next_mode\n\tREG_S\ta0, SBI_SCRATCH_NEXT_MODE_OFFSET(tp)\n\tMOV_3R\ta0, s0, a1, s1, a2, s2\n\t/* Store warm_boot address in scratch space */\n\tlla\ta4, _start_warm\n\tREG_S\ta4, SBI_SCRATCH_WARMBOOT_ADDR_OFFSET(tp)\n\t/* Store platform address in scratch space */\n\tlla\ta4, platform\n\tREG_S\ta4, SBI_SCRATCH_PLATFORM_ADDR_OFFSET(tp)\n\t/* Store hartid-to-scratch function address in scratch space */\n\tlla\ta4, _hartid_to_scratch\n\tREG_S\ta4, SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET(tp)\n\t/* Store trap-exit function address in scratch space */\n\tlla\ta4, _trap_exit\n\tREG_S\ta4, SBI_SCRATCH_TRAP_EXIT_OFFSET(tp)\n\t/* Clear tmp0 in scratch space */\n\tREG_S\tzero, SBI_SCRATCH_TMP0_OFFSET(tp)\n\t/* Store firmware options in scratch space */\n\tMOV_3R\ts0, a0, s1, a1, s2, a2\n#ifdef FW_OPTIONS\n\tli\ta0, FW_OPTIONS\n#else\n\tcall\tfw_options\n#endif\n\tREG_S\ta0, SBI_SCRATCH_OPTIONS_OFFSET(tp)\n\tMOV_3R\ta0, s0, a1, s1, a2, s2\n\t/* Move to next scratch space */\n\tadd\tt1, t1, t2\n\tblt\tt1, s7, _scratch_init\n\n\t/*\n\t * Relocate Flatened Device Tree (FDT)\n\t * source FDT address = previous arg1\n\t * destination FDT address = next arg1\n\t *\n\t * Note: We will preserve a0 and a1 passed by\n\t * previous booting stage.\n\t */\n\tbeqz\ta1, _fdt_reloc_done\n\t/* Mask values in a4 */\n\tli\ta4, 0xff\n\t/* t1 = destination FDT start address */\n\tMOV_3R\ts0, a0, s1, a1, s2, a2\n\tcall\tfw_next_arg1\n\tadd\tt1, a0, zero\n\tMOV_3R\ta0, s0, a1, s1, a2, s2\n\tbeqz\tt1, _fdt_reloc_done\n\tbeq\tt1, a1, _fdt_reloc_done\n\t/* t0 = source FDT start address */\n\tadd\tt0, a1, zero\n\t/* t2 = source FDT size in big-endian */\n#if __riscv_xlen == 64\n\tlwu\tt2, 4(t0)\n#else\n\tlw\tt2, 4(t0)\n#endif\n\t/* t3 = bit[15:8] of FDT size */\n\tadd\tt3, t2, zero\n\tsrli\tt3, t3, 16\n\tand\tt3, t3, a4\n\tslli\tt3, t3, 8\n\t/* t4 = bit[23:16] of FDT size */\n\tadd\tt4, t2, zero\n\tsrli\tt4, t4, 8\n\tand\tt4, t4, a4\n\tslli\tt4, t4, 16\n\t/* t5 = bit[31:24] of FDT size */\n\tadd\tt5, t2, zero\n\tand\tt5, t5, a4\n\tslli\tt5, t5, 24\n\t/* t2 = bit[7:0] of FDT size */\n\tsrli\tt2, t2, 24\n\tand\tt2, t2, a4\n\t/* t2 = FDT size in little-endian */\n\tor\tt2, t2, t3\n\tor\tt2, t2, t4\n\tor\tt2, t2, t5\n\t/* t2 = destination FDT end address */\n\tadd\tt2, t1, t2\n\t/* FDT copy loop */\n\tble\tt2, t1, _fdt_reloc_done\n_fdt_reloc_again:\n\tREG_L\tt3, 0(t0)\n\tREG_S\tt3, 0(t1)\n\tadd\tt0, t0, __SIZEOF_POINTER__\n\tadd\tt1, t1, __SIZEOF_POINTER__\n\tblt\tt1, t2, _fdt_reloc_again\n_fdt_reloc_done:\n\n\t/* mark boot hart done */\n\tli\tt0, BOOT_STATUS_BOOT_HART_DONE\n\tlla\tt1, _boot_status\n\tREG_S\tt0, 0(t1)\n\tfence\trw, rw\n\tj\t_start_warm\n\n\t/* waiting for boot hart to be done (_boot_status == 2) */\n_wait_for_boot_hart:\n\tli\tt0, BOOT_STATUS_BOOT_HART_DONE\n\tlla\tt1, _boot_status\n\tREG_L\tt1, 0(t1)\n\t/* Reduce the bus traffic so that boot hart may proceed faster */\n\tnop\n\tnop\n\tnop\n\tbne\tt0, t1, _wait_for_boot_hart\n\n_start_warm:\n\t/* Reset all registers for non-boot HARTs */\n\tli\tra, 0\n\tcall\t_reset_regs\n\n\t/* Disable and clear all interrupts */\n\tcsrw\tCSR_MIE, zero\n\tcsrw\tCSR_MIP, zero\n\n\t/* Find HART count and HART stack size */\n\tlla\ta4, platform\n#if __riscv_xlen == 64\n\tlwu\ts7, SBI_PLATFORM_HART_COUNT_OFFSET(a4)\n\tlwu\ts8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4)\n#else\n\tlw\ts7, SBI_PLATFORM_HART_COUNT_OFFSET(a4)\n\tlw\ts8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4)\n#endif\n\tREG_L\ts9, SBI_PLATFORM_HART_INDEX2ID_OFFSET(a4)\n\n\t/* Find HART id */\n\tcsrr\ts6, CSR_MHARTID\n\n\t/* Find HART index */\n\tbeqz\ts9, 3f\n\tli\ta4, 0\n1:\n#if __riscv_xlen == 64\n\tlwu\ta5, (s9)\n#else\n\tlw\ta5, (s9)\n#endif\n\tbeq\ta5, s6, 2f\n\tadd\ts9, s9, 4\n\tadd\ta4, a4, 1\n\tblt\ta4, s7, 1b\n\tli\ta4, -1\n2:\tadd\ts6, a4, zero\n3:\tbge\ts6, s7, _start_hang\n\n\t/* Find the scratch space based on HART index */\n\tlla\ttp, _fw_end\n\tmul\ta5, s7, s8\n\tadd\ttp, tp, a5\n\tmul\ta5, s8, s6\n\tsub\ttp, tp, a5\n\tli\ta5, SBI_SCRATCH_SIZE\n\tsub\ttp, tp, a5\n\n\t/* update the mscratch */\n\tcsrw\tCSR_MSCRATCH, tp\n\n\t/* Setup stack */\n\tadd\tsp, tp, zero\n\n\t/* Setup trap handler */\n\tlla\ta4, _trap_handler\n#if __riscv_xlen == 32\n\tcsrr\ta5, CSR_MISA\n\tsrli\ta5, a5, ('H' - 'A')\n\tandi\ta5, a5, 0x1\n\tbeq\ta5, zero, _skip_trap_handler_rv32_hyp\n\tlla\ta4, _trap_handler_rv32_hyp\n_skip_trap_handler_rv32_hyp:\n#endif\n\tcsrw\tCSR_MTVEC, a4\n\n#if __riscv_xlen == 32\n\t/* Override trap exit for H-extension */\n\tcsrr\ta5, CSR_MISA\n\tsrli\ta5, a5, ('H' - 'A')\n\tandi\ta5, a5, 0x1\n\tbeq\ta5, zero, _skip_trap_exit_rv32_hyp\n\tlla\ta4, _trap_exit_rv32_hyp\n\tcsrr\ta5, CSR_MSCRATCH\n\tREG_S\ta4, SBI_SCRATCH_TRAP_EXIT_OFFSET(a5)\n_skip_trap_exit_rv32_hyp:\n#endif\n\n\t/* Initialize SBI runtime */\n\tcsrr\ta0, CSR_MSCRATCH\n\tcall\tsbi_init\n\n\t/* We don't expect to reach here hence just hang */\n\tj\t_start_hang\n\n\t.data\n\t.align 3\n#ifdef FW_PIC\n_runtime_offset:\n\tRISCV_PTR\t0\n#endif\n_relocate_lottery:\n\tRISCV_PTR\t0\n_boot_status:\n\tRISCV_PTR\t0\n_load_start:\n\tRISCV_PTR\t_fw_start\n_link_start:\n\tRISCV_PTR\tFW_TEXT_START\n_link_end:\n\tRISCV_PTR\t_fw_reloc_end\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.globl _hartid_to_scratch\n_hartid_to_scratch:\n\t/*\n\t * a0 -> HART ID (passed by caller)\n\t * a1 -> HART Index (passed by caller)\n\t * t0 -> HART Stack Size\n\t * t1 -> HART Stack End\n\t * t2 -> Temporary\n\t */\n\tlla\tt2, platform\n#if __riscv_xlen == 64\n\tlwu\tt0, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(t2)\n\tlwu\tt2, SBI_PLATFORM_HART_COUNT_OFFSET(t2)\n#else\n\tlw\tt0, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(t2)\n\tlw\tt2, SBI_PLATFORM_HART_COUNT_OFFSET(t2)\n#endif\n\tsub\tt2, t2, a1\n\tmul\tt2, t2, t0\n\tlla\tt1, _fw_end\n\tadd\tt1, t1, t2\n\tli\tt2, SBI_SCRATCH_SIZE\n\tsub\ta0, t1, t2\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.globl _start_hang\n_start_hang:\n\twfi\n\tj\t_start_hang\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.weak fw_platform_init\nfw_platform_init:\n\tadd\ta0, a1, zero\n\tret\n\n\t/* Map implicit memcpy() added by compiler to sbi_memcpy() */\n\t.section .text\n\t.align 3\n\t.globl memcpy\nmemcpy:\n\ttail\tsbi_memcpy\n\n\t/* Map implicit memset() added by compiler to sbi_memset() */\n\t.section .text\n\t.align 3\n\t.globl memset\nmemset:\n\ttail\tsbi_memset\n\n\t/* Map implicit memmove() added by compiler to sbi_memmove() */\n\t.section .text\n\t.align 3\n\t.globl memmove\nmemmove:\n\ttail\tsbi_memmove\n\n\t/* Map implicit memcmp() added by compiler to sbi_memcmp() */\n\t.section .text\n\t.align 3\n\t.globl memcmp\nmemcmp:\n\ttail\tsbi_memcmp\n\n.macro\tTRAP_SAVE_AND_SETUP_SP_T0\n\t/* Swap TP and MSCRATCH */\n\tcsrrw\ttp, CSR_MSCRATCH, tp\n\n\t/* Save T0 in scratch space */\n\tREG_S\tt0, SBI_SCRATCH_TMP0_OFFSET(tp)\n\n\t/*\n\t * Set T0 to appropriate exception stack\n\t *\n\t * Came_From_M_Mode = ((MSTATUS.MPP < PRV_M) ? 1 : 0) - 1;\n\t * Exception_Stack = TP ^ (Came_From_M_Mode & (SP ^ TP))\n\t *\n\t * Came_From_M_Mode = 0    ==>    Exception_Stack = TP\n\t * Came_From_M_Mode = -1   ==>    Exception_Stack = SP\n\t */\n\tcsrr\tt0, CSR_MSTATUS\n\tsrl\tt0, t0, MSTATUS_MPP_SHIFT\n\tand\tt0, t0, PRV_M\n\tslti\tt0, t0, PRV_M\n\tadd\tt0, t0, -1\n\txor\tsp, sp, tp\n\tand\tt0, t0, sp\n\txor\tsp, sp, tp\n\txor\tt0, tp, t0\n\n\t/* Save original SP on exception stack */\n\tREG_S\tsp, (SBI_TRAP_REGS_OFFSET(sp) - SBI_TRAP_REGS_SIZE)(t0)\n\n\t/* Set SP to exception stack and make room for trap registers */\n\tadd\tsp, t0, -(SBI_TRAP_REGS_SIZE)\n\n\t/* Restore T0 from scratch space */\n\tREG_L\tt0, SBI_SCRATCH_TMP0_OFFSET(tp)\n\n\t/* Save T0 on stack */\n\tREG_S\tt0, SBI_TRAP_REGS_OFFSET(t0)(sp)\n\n\t/* Swap TP and MSCRATCH */\n\tcsrrw\ttp, CSR_MSCRATCH, tp\n.endm\n\n.macro\tTRAP_SAVE_MEPC_MSTATUS have_mstatush\n\t/* Save MEPC and MSTATUS CSRs */\n\tcsrr\tt0, CSR_MEPC\n\tREG_S\tt0, SBI_TRAP_REGS_OFFSET(mepc)(sp)\n\tcsrr\tt0, CSR_MSTATUS\n\tREG_S\tt0, SBI_TRAP_REGS_OFFSET(mstatus)(sp)\n\t.if \\have_mstatush\n\tcsrr\tt0, CSR_MSTATUSH\n\tREG_S\tt0, SBI_TRAP_REGS_OFFSET(mstatusH)(sp)\n\t.else\n\tREG_S\tzero, SBI_TRAP_REGS_OFFSET(mstatusH)(sp)\n\t.endif\n.endm\n\n.macro\tTRAP_SAVE_GENERAL_REGS_EXCEPT_SP_T0\n\t/* Save all general regisers except SP and T0 */\n\tREG_S\tzero, SBI_TRAP_REGS_OFFSET(zero)(sp)\n\tREG_S\tra, SBI_TRAP_REGS_OFFSET(ra)(sp)\n\tREG_S\tgp, SBI_TRAP_REGS_OFFSET(gp)(sp)\n\tREG_S\ttp, SBI_TRAP_REGS_OFFSET(tp)(sp)\n\tREG_S\tt1, SBI_TRAP_REGS_OFFSET(t1)(sp)\n\tREG_S\tt2, SBI_TRAP_REGS_OFFSET(t2)(sp)\n\tREG_S\ts0, SBI_TRAP_REGS_OFFSET(s0)(sp)\n\tREG_S\ts1, SBI_TRAP_REGS_OFFSET(s1)(sp)\n\tREG_S\ta0, SBI_TRAP_REGS_OFFSET(a0)(sp)\n\tREG_S\ta1, SBI_TRAP_REGS_OFFSET(a1)(sp)\n\tREG_S\ta2, SBI_TRAP_REGS_OFFSET(a2)(sp)\n\tREG_S\ta3, SBI_TRAP_REGS_OFFSET(a3)(sp)\n\tREG_S\ta4, SBI_TRAP_REGS_OFFSET(a4)(sp)\n\tREG_S\ta5, SBI_TRAP_REGS_OFFSET(a5)(sp)\n\tREG_S\ta6, SBI_TRAP_REGS_OFFSET(a6)(sp)\n\tREG_S\ta7, SBI_TRAP_REGS_OFFSET(a7)(sp)\n\tREG_S\ts2, SBI_TRAP_REGS_OFFSET(s2)(sp)\n\tREG_S\ts3, SBI_TRAP_REGS_OFFSET(s3)(sp)\n\tREG_S\ts4, SBI_TRAP_REGS_OFFSET(s4)(sp)\n\tREG_S\ts5, SBI_TRAP_REGS_OFFSET(s5)(sp)\n\tREG_S\ts6, SBI_TRAP_REGS_OFFSET(s6)(sp)\n\tREG_S\ts7, SBI_TRAP_REGS_OFFSET(s7)(sp)\n\tREG_S\ts8, SBI_TRAP_REGS_OFFSET(s8)(sp)\n\tREG_S\ts9, SBI_TRAP_REGS_OFFSET(s9)(sp)\n\tREG_S\ts10, SBI_TRAP_REGS_OFFSET(s10)(sp)\n\tREG_S\ts11, SBI_TRAP_REGS_OFFSET(s11)(sp)\n\tREG_S\tt3, SBI_TRAP_REGS_OFFSET(t3)(sp)\n\tREG_S\tt4, SBI_TRAP_REGS_OFFSET(t4)(sp)\n\tREG_S\tt5, SBI_TRAP_REGS_OFFSET(t5)(sp)\n\tREG_S\tt6, SBI_TRAP_REGS_OFFSET(t6)(sp)\n.endm\n\n.macro\tTRAP_CALL_C_ROUTINE\n\t/* Call C routine */\n\tadd\ta0, sp, zero\n\tcall\tsbi_trap_handler\n.endm\n\n.macro\tTRAP_RESTORE_GENERAL_REGS_EXCEPT_A0_T0\n\t/* Restore all general regisers except A0 and T0 */\n\tREG_L\tra, SBI_TRAP_REGS_OFFSET(ra)(a0)\n\tREG_L\tsp, SBI_TRAP_REGS_OFFSET(sp)(a0)\n\tREG_L\tgp, SBI_TRAP_REGS_OFFSET(gp)(a0)\n\tREG_L\ttp, SBI_TRAP_REGS_OFFSET(tp)(a0)\n\tREG_L\tt1, SBI_TRAP_REGS_OFFSET(t1)(a0)\n\tREG_L\tt2, SBI_TRAP_REGS_OFFSET(t2)(a0)\n\tREG_L\ts0, SBI_TRAP_REGS_OFFSET(s0)(a0)\n\tREG_L\ts1, SBI_TRAP_REGS_OFFSET(s1)(a0)\n\tREG_L\ta1, SBI_TRAP_REGS_OFFSET(a1)(a0)\n\tREG_L\ta2, SBI_TRAP_REGS_OFFSET(a2)(a0)\n\tREG_L\ta3, SBI_TRAP_REGS_OFFSET(a3)(a0)\n\tREG_L\ta4, SBI_TRAP_REGS_OFFSET(a4)(a0)\n\tREG_L\ta5, SBI_TRAP_REGS_OFFSET(a5)(a0)\n\tREG_L\ta6, SBI_TRAP_REGS_OFFSET(a6)(a0)\n\tREG_L\ta7, SBI_TRAP_REGS_OFFSET(a7)(a0)\n\tREG_L\ts2, SBI_TRAP_REGS_OFFSET(s2)(a0)\n\tREG_L\ts3, SBI_TRAP_REGS_OFFSET(s3)(a0)\n\tREG_L\ts4, SBI_TRAP_REGS_OFFSET(s4)(a0)\n\tREG_L\ts5, SBI_TRAP_REGS_OFFSET(s5)(a0)\n\tREG_L\ts6, SBI_TRAP_REGS_OFFSET(s6)(a0)\n\tREG_L\ts7, SBI_TRAP_REGS_OFFSET(s7)(a0)\n\tREG_L\ts8, SBI_TRAP_REGS_OFFSET(s8)(a0)\n\tREG_L\ts9, SBI_TRAP_REGS_OFFSET(s9)(a0)\n\tREG_L\ts10, SBI_TRAP_REGS_OFFSET(s10)(a0)\n\tREG_L\ts11, SBI_TRAP_REGS_OFFSET(s11)(a0)\n\tREG_L\tt3, SBI_TRAP_REGS_OFFSET(t3)(a0)\n\tREG_L\tt4, SBI_TRAP_REGS_OFFSET(t4)(a0)\n\tREG_L\tt5, SBI_TRAP_REGS_OFFSET(t5)(a0)\n\tREG_L\tt6, SBI_TRAP_REGS_OFFSET(t6)(a0)\n.endm\n\n.macro\tTRAP_RESTORE_MEPC_MSTATUS have_mstatush\n\t/* Restore MEPC and MSTATUS CSRs */\n\tREG_L\tt0, SBI_TRAP_REGS_OFFSET(mepc)(a0)\n\tcsrw\tCSR_MEPC, t0\n\tREG_L\tt0, SBI_TRAP_REGS_OFFSET(mstatus)(a0)\n\tcsrw\tCSR_MSTATUS, t0\n\t.if \\have_mstatush\n\tREG_L\tt0, SBI_TRAP_REGS_OFFSET(mstatusH)(a0)\n\tcsrw\tCSR_MSTATUSH, t0\n\t.endif\n.endm\n\n.macro TRAP_RESTORE_A0_T0\n\t/* Restore T0 */\n\tREG_L\tt0, SBI_TRAP_REGS_OFFSET(t0)(a0)\n\n\t/* Restore A0 */\n\tREG_L\ta0, SBI_TRAP_REGS_OFFSET(a0)(a0)\n.endm\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.globl _trap_handler\n\t.globl _trap_exit\n_trap_handler:\n\tTRAP_SAVE_AND_SETUP_SP_T0\n\n\tTRAP_SAVE_MEPC_MSTATUS 0\n\n\tTRAP_SAVE_GENERAL_REGS_EXCEPT_SP_T0\n\n\tTRAP_CALL_C_ROUTINE\n\n_trap_exit:\n\tTRAP_RESTORE_GENERAL_REGS_EXCEPT_A0_T0\n\n\tTRAP_RESTORE_MEPC_MSTATUS 0\n\n\tTRAP_RESTORE_A0_T0\n\n\tmret\n\n#if __riscv_xlen == 32\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.globl _trap_handler_rv32_hyp\n\t.globl _trap_exit_rv32_hyp\n_trap_handler_rv32_hyp:\n\tTRAP_SAVE_AND_SETUP_SP_T0\n\n\tTRAP_SAVE_MEPC_MSTATUS 1\n\n\tTRAP_SAVE_GENERAL_REGS_EXCEPT_SP_T0\n\n\tTRAP_CALL_C_ROUTINE\n\n_trap_exit_rv32_hyp:\n\tTRAP_RESTORE_GENERAL_REGS_EXCEPT_A0_T0\n\n\tTRAP_RESTORE_MEPC_MSTATUS 1\n\n\tTRAP_RESTORE_A0_T0\n\n\tmret\n#endif\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.globl _reset_regs\n_reset_regs:\n\n\t/* flush the instruction cache */\n\tfence.i\n\t/* Reset all registers except ra, a0, a1 and a2 */\n\tli sp, 0\n\tli gp, 0\n\tli tp, 0\n\tli t0, 0\n\tli t1, 0\n\tli t2, 0\n\tli s0, 0\n\tli s1, 0\n\tli a3, 0\n\tli a4, 0\n\tli a5, 0\n\tli a6, 0\n\tli a7, 0\n\tli s2, 0\n\tli s3, 0\n\tli s4, 0\n\tli s5, 0\n\tli s6, 0\n\tli s7, 0\n\tli s8, 0\n\tli s9, 0\n\tli s10, 0\n\tli s11, 0\n\tli t3, 0\n\tli t4, 0\n\tli t5, 0\n\tli t6, 0\n\tcsrw CSR_MSCRATCH, 0\n\n\tret\n\n#ifdef FW_FDT_PATH\n\t.section .rodata\n\t.align 4\n\t.globl fw_fdt_bin\nfw_fdt_bin:\n\t.incbin FW_FDT_PATH\n#ifdef FW_FDT_PADDING\n\t.fill FW_FDT_PADDING, 1, 0\n#endif\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/firmware/fw_base.ldS",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n\t. = FW_TEXT_START;\n\t/* Don't add any section between FW_TEXT_START and _fw_start */\n\tPROVIDE(_fw_start = .);\n\n\t. = ALIGN(0x1000); /* Need this to create proper sections */\n\n\t/* Beginning of the code section */\n\n\t.text :\n \t{\n\t\tPROVIDE(_text_start = .);\n\t\t*(.entry)\n\t\t*(.text)\n\t\t. = ALIGN(8);\n\t\tPROVIDE(_text_end = .);\n\t}\n\n\t/* End of the code sections */\n\n\t. = ALIGN(0x1000); /* Ensure next section is page aligned */\n\n\t/* Beginning of the read-only data sections */\n\n\t.rodata :\n\t{\n\t\tPROVIDE(_rodata_start = .);\n\t\t*(.rodata .rodata.*)\n\t\t. = ALIGN(8);\n\t\tPROVIDE(_rodata_end = .);\n\t}\n\n\t/* End of the read-only data sections */\n\n\t. = ALIGN(0x1000); /* Ensure next section is page aligned */\n\n\t/* Beginning of the read-write data sections */\n\n\t.data :\n\t{\n\t\tPROVIDE(_data_start = .);\n\n\t\t*(.sdata)\n\t\t*(.sdata.*)\n\t\t*(.data)\n\t\t*(.data.*)\n\t\t*(.readmostly.data)\n\t\t*(*.data)\n\t\t. = ALIGN(8);\n\n\t\tPROVIDE(_data_end = .);\n\t}\n\n\t.dynsym : {\n\t\tPROVIDE(__dyn_sym_start = .);\n\t\t*(.dynsym)\n\t\tPROVIDE(__dyn_sym_end = .);\n\t}\n\n\t.rela.dyn : {\n\t\tPROVIDE(__rel_dyn_start = .);\n\t\t*(.rela*)\n\t\t. = ALIGN(8);\n\t\tPROVIDE(__rel_dyn_end = .);\n\t}\n\n\t. = ALIGN(0x1000); /* Ensure next section is page aligned */\n\n\t.bss :\n\t{\n\t\tPROVIDE(_bss_start = .);\n\t\t*(.sbss)\n\t\t*(.sbss.*)\n\t\t*(.bss)\n\t\t*(.bss.*)\n\t\t. = ALIGN(8);\n\t\tPROVIDE(_bss_end = .);\n\t}\n\n\t/* End of the read-write data sections */\n\n\t. = ALIGN(0x1000); /* Need this to create proper sections */\n\n    /* Adding heap section for 4MB */\n    .heap : {\n        PROVIDE(_heap_start = .);\n        . = . + 32K;  /* Allocate 4MB for the heap */\n        PROVIDE(_heap_end = .);\n    }\n    /* End of heap section */\n\n\tPROVIDE(_fw_end = .);\n"
  },
  {
    "path": "ftpm-opensbi/firmware/fw_dynamic.S",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/fw_dynamic.h>\n\n#include \"fw_base.S\"\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n_bad_dynamic_info:\n\twfi\n\tj\t_bad_dynamic_info\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_boot_hart\n\t/*\n\t * This function is called very early even before\n\t * fw_save_info() is called.\n\t * We can only use a0, a1, and a2 registers here.\n\t * The boot HART id should be returned in 'a0'.\n\t */\nfw_boot_hart:\n\t/* Sanity checks */\n\tli\ta1, FW_DYNAMIC_INFO_MAGIC_VALUE\n\tREG_L\ta0, FW_DYNAMIC_INFO_MAGIC_OFFSET(a2)\n\tbne\ta0, a1, _bad_dynamic_info\n\tli\ta1, FW_DYNAMIC_INFO_VERSION_MAX\n\tREG_L\ta0, FW_DYNAMIC_INFO_VERSION_OFFSET(a2)\n\tbgt\ta0, a1, _bad_dynamic_info\n\n\t/* Read boot HART id */\n\tli\ta1, FW_DYNAMIC_INFO_VERSION_2\n\tblt\ta0, a1, 2f\n\tREG_L\ta0, FW_DYNAMIC_INFO_BOOT_HART_OFFSET(a2)\n\tret\n2:\tli\ta0, -1\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_save_info\n\t/*\n\t * We can only use a0, a1, a2, a3, and a4 registers here.\n\t * The a0, a1, and a2 registers will be same as passed by\n\t * previous booting stage.\n\t * Nothing to be returned here.\n\t */\nfw_save_info:\n\t/* Save next arg1 in 'a1' */\n\tlla\ta4, _dynamic_next_arg1\n\tREG_S\ta1, (a4)\n\n\t/* Save version == 0x1 fields */\n\tlla\ta4, _dynamic_next_addr\n\tREG_L\ta3, FW_DYNAMIC_INFO_NEXT_ADDR_OFFSET(a2)\n\tREG_S\ta3, (a4)\n\tlla\ta4, _dynamic_next_mode\n\tREG_L\ta3, FW_DYNAMIC_INFO_NEXT_MODE_OFFSET(a2)\n\tREG_S\ta3, (a4)\n\tlla\ta4, _dynamic_options\n\tREG_L\ta3, FW_DYNAMIC_INFO_OPTIONS_OFFSET(a2)\n\tREG_S\ta3, (a4)\n\n\t/* Save version == 0x2 fields */\n\tli\ta4, FW_DYNAMIC_INFO_VERSION_2\n\tREG_L\ta3, FW_DYNAMIC_INFO_VERSION_OFFSET(a2)\n\tblt\ta3, a4, 2f\n\tlla\ta4, _dynamic_boot_hart\n\tREG_L\ta3, FW_DYNAMIC_INFO_BOOT_HART_OFFSET(a2)\n\tREG_S\ta3, (a4)\n2:\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_next_arg1\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The a0, a1, and a2 registers will be same as passed by\n\t * previous booting stage.\n\t * The next arg1 should be returned in 'a0'.\n\t */\nfw_next_arg1:\n\tlla\ta0, _dynamic_next_arg1\n\tREG_L\ta0, (a0)\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_next_addr\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The next address should be returned in 'a0'.\n\t */\nfw_next_addr:\n\tlla\ta0, _dynamic_next_addr\n\tREG_L\ta0, (a0)\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_next_mode\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The next address should be returned in 'a0'\n\t */\nfw_next_mode:\n\tlla\ta0, _dynamic_next_mode\n\tREG_L\ta0, (a0)\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_options\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The 'a4' register will have default options.\n\t * The next address should be returned in 'a0'.\n\t */\nfw_options:\n\tlla\ta0, _dynamic_options\n\tREG_L\ta0, (a0)\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n_dynamic_next_arg1:\n\tRISCV_PTR 0x0\n_dynamic_next_addr:\n\tRISCV_PTR 0x0\n_dynamic_next_mode:\n\tRISCV_PTR PRV_S\n_dynamic_options:\n\tRISCV_PTR 0x0\n_dynamic_boot_hart:\n\tRISCV_PTR -1\n"
  },
  {
    "path": "ftpm-opensbi/firmware/fw_dynamic.elf.ldS",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\nOUTPUT_ARCH(riscv)\nENTRY(_start)\n\nSECTIONS\n{\n\t#include \"fw_base.ldS\"\n\n\tPROVIDE(_fw_reloc_end = .);\n}\n"
  },
  {
    "path": "ftpm-opensbi/firmware/fw_jump.S",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include \"fw_base.S\"\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_boot_hart\n\t/*\n\t * This function is called very early even before\n\t * fw_save_info() is called.\n\t * We can only use a0, a1, and a2 registers here.\n\t * The boot HART id should be returned in 'a0'.\n\t */\nfw_boot_hart:\n\tli\ta0, -1\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_save_info\n\t/*\n\t * We can only use a0, a1, a2, a3, and a4 registers here.\n\t * The a0, a1, and a2 registers will be same as passed by\n\t * previous booting stage.\n\t * Nothing to be returned here.\n\t */\nfw_save_info:\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_next_arg1\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The a0, a1, and a2 registers will be same as passed by\n\t * previous booting stage.\n\t * The next arg1 should be returned in 'a0'.\n\t */\nfw_next_arg1:\n#ifdef FW_JUMP_FDT_ADDR\n\tli\ta0, FW_JUMP_FDT_ADDR\n#else\n\tadd\ta0, a1, zero\n#endif\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_next_addr\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The next address should be returned in 'a0'.\n\t */\nfw_next_addr:\n\tlla\ta0, _jump_addr\n\tREG_L\ta0, (a0)\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_next_mode\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The next address should be returned in 'a0'\n\t */\nfw_next_mode:\n\tli\ta0, PRV_S\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_options\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The 'a4' register will have default options.\n\t * The next address should be returned in 'a0'.\n\t */\nfw_options:\n\tadd\ta0, zero, zero\n\tret\n\n#ifndef FW_JUMP_ADDR\n#error \"Must define FW_JUMP_ADDR\"\n#endif\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n_jump_addr:\n\tRISCV_PTR FW_JUMP_ADDR\n"
  },
  {
    "path": "ftpm-opensbi/firmware/fw_jump.elf.ldS",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\nOUTPUT_ARCH(riscv)\nENTRY(_start)\n\nSECTIONS\n{\n\t#include \"fw_base.ldS\"\n\n\tPROVIDE(_fw_reloc_end = .);\n}\n"
  },
  {
    "path": "ftpm-opensbi/firmware/fw_payload.S",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include \"fw_base.S\"\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_boot_hart\n\t/*\n\t * This function is called very early even before\n\t * fw_save_info() is called.\n\t * We can only use a0, a1, and a2 registers here.\n\t * The boot HART id should be returned in 'a0'.\n\t */\nfw_boot_hart:\n\tli\ta0, -1\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_save_info\n\t/*\n\t * We can only use a0, a1, a2, a3, and a4 registers here.\n\t * The a0, a1, and a2 registers will be same as passed by\n\t * previous booting stage.\n\t * Nothing to be returned here.\n\t */\nfw_save_info:\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_next_arg1\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The a0, a1, and a2 registers will be same as passed by\n\t * previous booting stage.\n\t * The next arg1 should be returned in 'a0'.\n\t */\nfw_next_arg1:\n#ifdef FW_PAYLOAD_FDT_ADDR\n\tli\ta0, FW_PAYLOAD_FDT_ADDR\n#else\n\tadd\ta0, a1, zero\n#endif\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_next_addr\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The next address should be returned in 'a0'.\n\t */\nfw_next_addr:\n\tlla\ta0, payload_bin\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_next_mode\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The next address should be returned in 'a0'.\n\t */\nfw_next_mode:\n\tli\ta0, PRV_S\n\tret\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.global fw_options\n\t/*\n\t * We can only use a0, a1, and a2 registers here.\n\t * The 'a4' register will have default options.\n\t * The next address should be returned in 'a0'.\n\t */\nfw_options:\n\tadd\ta0, zero, zero\n\tret\n\n\t.section .payload, \"ax\", %progbits\n\t.align 4\n\t.globl payload_bin\npayload_bin:\n#ifndef FW_PAYLOAD_PATH\n\twfi\n\tj\tpayload_bin\n#else\n\t.incbin\tFW_PAYLOAD_PATH\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/firmware/fw_payload.elf.ldS",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\nOUTPUT_ARCH(riscv)\nENTRY(_start)\n\nSECTIONS\n{\n\t#include \"fw_base.ldS\"\n\n#ifdef FW_PAYLOAD_OFFSET\n\t. = FW_TEXT_START + FW_PAYLOAD_OFFSET;\n#else\n\t. = ALIGN(FW_PAYLOAD_ALIGN);\n#endif\n\n\t.payload :\n\t{\n\t\tPROVIDE(_payload_start = .);\n\t\t*(.payload)\n\t\t. = ALIGN(8);\n\t\tPROVIDE(_payload_end = .);\n\t}\n\n\tPROVIDE(_fw_reloc_end = .);\n}\n"
  },
  {
    "path": "ftpm-opensbi/firmware/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nfirmware-genflags-y =\nfirmware-cppflags-y +=\nfirmware-cflags-y +=\nfirmware-asflags-y +=\nfirmware-ldflags-y +=\n\nifndef FW_PIC\nFW_PIC := $(OPENSBI_LD_PIE)\nendif\n\nifeq ($(FW_PIC),y)\nfirmware-genflags-y +=\t-DFW_PIC\nfirmware-asflags-y  +=\t-fpic\nfirmware-cflags-y   +=\t-fPIE -pie\nfirmware-ldflags-y  +=\t-Wl,--no-dynamic-linker -Wl,-pie\nendif\n\nifdef FW_TEXT_START\nfirmware-genflags-y += -DFW_TEXT_START=$(FW_TEXT_START)\nendif\n\nifdef FW_FDT_PATH\nfirmware-genflags-y += -DFW_FDT_PATH=\\\"$(FW_FDT_PATH)\\\"\nifdef FW_FDT_PADDING\nfirmware-genflags-y += -DFW_FDT_PADDING=$(FW_FDT_PADDING)\nendif\nendif\n\nfirmware-bins-$(FW_DYNAMIC) += fw_dynamic.bin\n\nfirmware-bins-$(FW_JUMP) += fw_jump.bin\nifdef FW_JUMP_ADDR\nfirmware-genflags-$(FW_JUMP) += -DFW_JUMP_ADDR=$(FW_JUMP_ADDR)\nendif\nifdef FW_JUMP_FDT_ADDR\nfirmware-genflags-$(FW_JUMP) += -DFW_JUMP_FDT_ADDR=$(FW_JUMP_FDT_ADDR)\nendif\n\nfirmware-bins-$(FW_PAYLOAD) += fw_payload.bin\nifdef FW_PAYLOAD_PATH\nFW_PAYLOAD_PATH_FINAL=$(FW_PAYLOAD_PATH)\nelse\nFW_PAYLOAD_PATH_FINAL=$(platform_build_dir)/firmware/payloads/test.bin\nendif\nfirmware-genflags-$(FW_PAYLOAD) += -DFW_PAYLOAD_PATH=\\\"$(FW_PAYLOAD_PATH_FINAL)\\\"\nifdef FW_PAYLOAD_OFFSET\nfirmware-genflags-$(FW_PAYLOAD) += -DFW_PAYLOAD_OFFSET=$(FW_PAYLOAD_OFFSET)\nendif\nifdef FW_PAYLOAD_ALIGN\nfirmware-genflags-$(FW_PAYLOAD) += -DFW_PAYLOAD_ALIGN=$(FW_PAYLOAD_ALIGN)\nendif\n\nifdef FW_PAYLOAD_FDT_ADDR\nfirmware-genflags-$(FW_PAYLOAD) += -DFW_PAYLOAD_FDT_ADDR=$(FW_PAYLOAD_FDT_ADDR)\nendif\n\nifdef FW_OPTIONS\nfirmware-genflags-y += -DFW_OPTIONS=$(FW_OPTIONS)\nendif\n"
  },
  {
    "path": "ftpm-opensbi/firmware/payloads/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nfirmware-bins-$(FW_PAYLOAD) += payloads/test.bin\n\ntest-y += test_head.o\ntest-y += test_main.o\n\n%/test.o: $(foreach obj,$(test-y),%/$(obj))\n\t$(call merge_objs,$@,$^)\n\n%/test.dep: $(foreach dep,$(test-y:.o=.dep),%/$(dep))\n\t$(call merge_deps,$@,$^)\n"
  },
  {
    "path": "ftpm-opensbi/firmware/payloads/test.elf.ldS",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\nOUTPUT_ARCH(riscv)\nENTRY(_start)\n\nSECTIONS\n{\n#ifdef FW_PAYLOAD_OFFSET\n\t. = FW_TEXT_START + FW_PAYLOAD_OFFSET;\n#else\n\t. = ALIGN(FW_PAYLOAD_ALIGN);\n#endif\n\n\tPROVIDE(_payload_start = .);\n\n\t. = ALIGN(0x1000); /* Need this to create proper sections */\n\n\t/* Beginning of the code section */\n\n\t.text :\n\t{\n\t\tPROVIDE(_text_start = .);\n\t\t*(.entry)\n\t\t*(.text)\n\t\t. = ALIGN(8);\n\t\tPROVIDE(_text_end = .);\n\t}\n\n\t/* End of the code sections */\n\n\t. = ALIGN(0x1000); /* Ensure next section is page aligned */\n\n\t/* Beginning of the read-only data sections */\n\n\t.rodata :\n\t{\n\t\tPROVIDE(_rodata_start = .);\n\t\t*(.rodata .rodata.*)\n\t\t. = ALIGN(8);\n\t\tPROVIDE(_rodata_end = .);\n\t}\n\n\t/* End of the read-only data sections */\n\n\t. = ALIGN(0x1000); /* Ensure next section is page aligned */\n\n\t/* Beginning of the read-write data sections */\n\n\t.data :\n\t{\n\t\tPROVIDE(_data_start = .);\n\n\t\t*(.data)\n\t\t*(.data.*)\n\t\t*(.readmostly.data)\n\t\t*(*.data)\n\t\t. = ALIGN(8);\n\n\t\tPROVIDE(_data_end = .);\n\t}\n\n\t. = ALIGN(0x1000); /* Ensure next section is page aligned */\n\n\t.bss :\n\t{\n\t\tPROVIDE(_bss_start = .);\n\t\t*(.bss)\n\t\t*(.bss.*)\n\t\t. = ALIGN(8);\n\t\tPROVIDE(_bss_end = .);\n\t}\n\n\t/* End of the read-write data sections */\n\n\t. = ALIGN(0x1000); /* Need this to create proper sections */\n\n\tPROVIDE(_payload_end = .);\n}\n"
  },
  {
    "path": "ftpm-opensbi/firmware/payloads/test_head.S",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_encoding.h>\n#define __ASM_STR(x)\tx\n\n#if __riscv_xlen == 64\n#define __REG_SEL(a, b)\t\t__ASM_STR(a)\n#define RISCV_PTR\t\t.dword\n#elif __riscv_xlen == 32\n#define __REG_SEL(a, b)\t\t__ASM_STR(b)\n#define RISCV_PTR\t\t.word\n#else\n#error \"Unexpected __riscv_xlen\"\n#endif\n\n#define REG_L\t\t__REG_SEL(ld, lw)\n#define REG_S\t\t__REG_SEL(sd, sw)\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.globl _start\n_start:\n\t/* Pick one hart to run the main boot sequence */\n\tlla\ta3, _hart_lottery\n\tli\ta2, 1\n\tamoadd.w a3, a2, (a3)\n\tbnez\ta3, _start_hang\n\n\t/* Save a0 and a1 */\n\tlla\ta3, _boot_a0\n\tREG_S\ta0, 0(a3)\n\tlla\ta3, _boot_a1\n\tREG_S\ta1, 0(a3)\n\n\t/* Zero-out BSS */\n\tlla\ta4, _bss_start\n\tlla\ta5, _bss_end\n_bss_zero:\n\tREG_S\tzero, (a4)\n\tadd\ta4, a4, __SIZEOF_POINTER__\n\tblt\ta4, a5, _bss_zero\n\n_start_warm:\n\t/* Disable and clear all interrupts */\n\tcsrw\tCSR_SIE, zero\n\tcsrw\tCSR_SIP, zero\n\n\t/* Setup exception vectors */\n\tlla\ta3, _start_hang\n\tcsrw\tCSR_STVEC, a3\n\n\t/* Setup stack */\n\tlla\ta3, _payload_end\n\tli\ta4, 0x2000\n\tadd\tsp, a3, a4\n\n\t/* Jump to C main */\n\tlla\ta3, _boot_a0\n\tREG_L\ta0, 0(a3)\n\tlla\ta3, _boot_a1\n\tREG_L\ta1, 0(a3)\n\tcall\ttest_main\n\n\t/* We don't expect to reach here hence just hang */\n\tj\t_start_hang\n\n\t.section .entry, \"ax\", %progbits\n\t.align 3\n\t.globl _start_hang\n_start_hang:\n\twfi\n\tj\t_start_hang\n\n\t.section .entry, \"ax\", %progbits\n\t.align\t3\n_hart_lottery:\n\tRISCV_PTR\t0\n_boot_a0:\n\tRISCV_PTR\t0\n_boot_a1:\n\tRISCV_PTR\t0\n"
  },
  {
    "path": "ftpm-opensbi/firmware/payloads/test_main.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_ecall_interface.h>\n\n#define SBI_ECALL(__eid, __fid, __a0, __a1, __a2)                             \\\n\t({                                                                    \\\n\t\tregister unsigned long a0 asm(\"a0\") = (unsigned long)(__a0);  \\\n\t\tregister unsigned long a1 asm(\"a1\") = (unsigned long)(__a1);  \\\n\t\tregister unsigned long a2 asm(\"a2\") = (unsigned long)(__a2);  \\\n\t\tregister unsigned long a6 asm(\"a6\") = (unsigned long)(__fid); \\\n\t\tregister unsigned long a7 asm(\"a7\") = (unsigned long)(__eid); \\\n\t\tasm volatile(\"ecall\"                                          \\\n\t\t\t     : \"+r\"(a0)                                       \\\n\t\t\t     : \"r\"(a1), \"r\"(a2), \"r\"(a6), \"r\"(a7)             \\\n\t\t\t     : \"memory\");                                     \\\n\t\ta0;                                                           \\\n\t})\n\n#define SBI_ECALL_0(__eid, __fid) SBI_ECALL(__eid, __fid, 0, 0, 0)\n#define SBI_ECALL_1(__eid, __fid, __a0) SBI_ECALL(__eid, __fid, __a0, 0, 0)\n#define SBI_ECALL_2(__eid, __fid, __a0, __a1) SBI_ECALL(__eid, __fid, __a0, __a1, 0)\n\n#define sbi_ecall_console_putc(c) SBI_ECALL_1(SBI_EXT_0_1_CONSOLE_PUTCHAR, 0, (c))\n\nstatic inline void sbi_ecall_console_puts(const char *str)\n{\n\twhile (str && *str)\n\t\tsbi_ecall_console_putc(*str++);\n}\n\n#define wfi()                                             \\\n\tdo {                                              \\\n\t\t__asm__ __volatile__(\"wfi\" ::: \"memory\"); \\\n\t} while (0)\n\nvoid test_main(unsigned long a0, unsigned long a1)\n{\n\tsbi_ecall_console_puts(\"\\nTest payload running\\n\");\n\n\twhile (1)\n\t\twfi();\n}\n"
  },
  {
    "path": "ftpm-opensbi/include/fatfs/diskio.h",
    "content": "/*-----------------------------------------------------------------------/\r\n/  Low level disk interface modlue include file   (C)ChaN, 2019          /\r\n/-----------------------------------------------------------------------*/\r\n\r\n#ifndef _DISKIO_DEFINED\r\n#define _DISKIO_DEFINED\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n#include \"fatfs/ff.h\"\r\n\r\n/* Status of Disk Functions */\r\ntypedef BYTE\tDSTATUS;\r\n\r\n/* Results of Disk Functions */\r\ntypedef enum {\r\n\tRES_OK = 0,\t\t/* 0: Successful */\r\n\tRES_ERROR,\t\t/* 1: R/W Error */\r\n\tRES_WRPRT,\t\t/* 2: Write Protected */\r\n\tRES_NOTRDY,\t\t/* 3: Not Ready */\r\n\tRES_PARERR\t\t/* 4: Invalid Parameter */\r\n} DRESULT;\r\n\r\n\r\n/*---------------------------------------*/\r\n/* Prototypes for disk control functions */\r\n\r\n\r\nDSTATUS disk_initialize (BYTE pdrv);\r\nDSTATUS disk_status (BYTE pdrv);\r\nDRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);\r\nDRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);\r\n// DRESULT disk_write (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);\r\nDRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);\r\nconst char * errno_to_str(void);\r\n\r\n\r\n/* Disk Status Bits (DSTATUS) */\r\n\r\n#define STA_NOINIT\t\t0x01\t/* Drive not initialized */\r\n#define STA_NODISK\t\t0x02\t/* No medium in the drive */\r\n#define STA_PROTECT\t\t0x04\t/* Write protected */\r\n\r\n\r\n/* Command code for disk_ioctrl fucntion */\r\n\r\n/* Generic command (Used by FatFs) */\r\n#define CTRL_SYNC\t\t\t0\t/* Complete pending write process (needed at FF_FS_READONLY == 0) */\r\n#define GET_SECTOR_COUNT\t1\t/* Get media size (needed at FF_USE_MKFS == 1) */\r\n#define GET_SECTOR_SIZE\t\t2\t/* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */\r\n#define GET_BLOCK_SIZE\t\t3\t/* Get erase block size (needed at FF_USE_MKFS == 1) */\r\n#define CTRL_TRIM\t\t\t4\t/* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */\r\n\r\n/* Generic command (Not used by FatFs) */\r\n#define CTRL_POWER\t\t\t5\t/* Get/Set power status */\r\n#define CTRL_LOCK\t\t\t6\t/* Lock/Unlock media removal */\r\n#define CTRL_EJECT\t\t\t7\t/* Eject media */\r\n#define CTRL_FORMAT\t\t\t8\t/* Create physical format on the media */\r\n\r\n/* MMC/SDC specific ioctl command */\r\n#define MMC_GET_TYPE\t\t10\t/* Get card type */\r\n#define MMC_GET_CSD\t\t\t11\t/* Get CSD */\r\n#define MMC_GET_CID\t\t\t12\t/* Get CID */\r\n#define MMC_GET_OCR\t\t\t13\t/* Get OCR */\r\n#define MMC_GET_SDSTAT\t\t14\t/* Get SD status */\r\n#define ISDIO_READ\t\t\t55\t/* Read data form SD iSDIO register */\r\n#define ISDIO_WRITE\t\t\t56\t/* Write data to SD iSDIO register */\r\n#define ISDIO_MRITE\t\t\t57\t/* Masked write data to SD iSDIO register */\r\n\r\n/* ATA/CF specific ioctl command */\r\n#define ATA_GET_REV\t\t\t20\t/* Get F/W revision */\r\n#define ATA_GET_MODEL\t\t21\t/* Get model name */\r\n#define ATA_GET_SN\t\t\t22\t/* Get serial number */\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif\r\n"
  },
  {
    "path": "ftpm-opensbi/include/fatfs/ff.h",
    "content": "/*----------------------------------------------------------------------------/\r\n/  FatFs - Generic FAT Filesystem module  R0.15a                              /\r\n/-----------------------------------------------------------------------------/\r\n/\r\n/ Copyright (C) 2024, ChaN, all right reserved.\r\n/\r\n/ FatFs module is an open source software. Redistribution and use of FatFs in\r\n/ source and binary forms, with or without modification, are permitted provided\r\n/ that the following condition is met:\r\n\r\n/ 1. Redistributions of source code must retain the above copyright notice,\r\n/    this condition and the following disclaimer.\r\n/\r\n/ This software is provided by the copyright holder and contributors \"AS IS\"\r\n/ and any warranties related to this software are DISCLAIMED.\r\n/ The copyright owner or contributors be NOT LIABLE for any damages caused\r\n/ by use of this software.\r\n/\r\n/----------------------------------------------------------------------------*/\r\n\r\n\r\n#ifndef FF_DEFINED\r\n#define FF_DEFINED\t5380\t/* Revision ID */\r\n\r\n#ifdef __cplusplus\r\nextern \"C\" {\r\n#endif\r\n\r\n#if !defined(FFCONF_DEF)\r\n#include \"fatfs/ffconf.h\"\t\t/* FatFs configuration options */\r\n#endif\r\n#if FF_DEFINED != FFCONF_DEF\r\n#error Wrong configuration file (ffconf.h).\r\n#endif\r\n\r\n\r\n/* Integer types used for FatFs API */\r\n\r\n#if defined(_WIN32)\t\t/* Windows VC++ (for development only) */\r\n#define FF_INTDEF 2\r\n#include <windows.h>\r\ntypedef unsigned __int64 QWORD;\r\n#include <float.h>\r\n#define isnan(v) _isnan(v)\r\n#define isinf(v) (!_finite(v))\r\n\r\n#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus)\t/* C99 or later */\r\n#define FF_INTDEF 2\r\n#include <stdint.h>\r\ntypedef unsigned int\tUINT;\t/* int must be 16-bit or 32-bit */\r\ntypedef unsigned char\tBYTE;\t/* char must be 8-bit */\r\ntypedef uint16_t\t\tWORD;\t/* 16-bit unsigned */\r\ntypedef uint32_t\t\tDWORD;\t/* 32-bit unsigned */\r\ntypedef uint64_t\t\tQWORD;\t/* 64-bit unsigned */\r\ntypedef WORD\t\t\tWCHAR;\t/* UTF-16 code unit */\r\n\r\n#else  \t/* Earlier than C99 */\r\n#define FF_INTDEF 1\r\ntypedef unsigned int\tUINT;\t/* int must be 16-bit or 32-bit */\r\ntypedef unsigned char\tBYTE;\t/* char must be 8-bit */\r\ntypedef unsigned short\tWORD;\t/* short must be 16-bit */\r\ntypedef unsigned long\tDWORD;\t/* long must be 32-bit */\r\ntypedef WORD\t\t\tWCHAR;\t/* UTF-16 code unit */\r\n#endif\r\n\r\n\r\n/* Type of file size and LBA variables */\r\n\r\n#if FF_FS_EXFAT\r\n#if FF_INTDEF != 2\r\n#error exFAT feature wants C99 or later\r\n#endif\r\ntypedef QWORD FSIZE_t;\r\n#if FF_LBA64\r\ntypedef QWORD LBA_t;\r\n#else\r\ntypedef DWORD LBA_t;\r\n#endif\r\n#else\r\n#if FF_LBA64\r\n#error exFAT needs to be enabled when enable 64-bit LBA\r\n#endif\r\ntypedef DWORD FSIZE_t;\r\ntypedef DWORD LBA_t;\r\n#endif\r\n\r\n\r\n\r\n/* Type of path name strings on FatFs API (TCHAR) */\r\n\r\n#if FF_USE_LFN && FF_LFN_UNICODE == 1 \t/* Unicode in UTF-16 encoding */\r\ntypedef WCHAR TCHAR;\r\n#define _T(x) L ## x\r\n#define _TEXT(x) L ## x\r\n#elif FF_USE_LFN && FF_LFN_UNICODE == 2\t/* Unicode in UTF-8 encoding */\r\ntypedef char TCHAR;\r\n#define _T(x) u8 ## x\r\n#define _TEXT(x) u8 ## x\r\n#elif FF_USE_LFN && FF_LFN_UNICODE == 3\t/* Unicode in UTF-32 encoding */\r\ntypedef DWORD TCHAR;\r\n#define _T(x) U ## x\r\n#define _TEXT(x) U ## x\r\n#elif FF_USE_LFN && (FF_LFN_UNICODE < 0 || FF_LFN_UNICODE > 3)\r\n#error Wrong FF_LFN_UNICODE setting\r\n#else\t\t\t\t\t\t\t\t\t/* ANSI/OEM code in SBCS/DBCS */\r\ntypedef char TCHAR;\r\n#define _T(x) x\r\n#define _TEXT(x) x\r\n#endif\r\n\r\n\r\n\r\n/* Definitions of volume management */\r\n\r\n#if FF_MULTI_PARTITION\t\t/* Multiple partition configuration */\r\ntypedef struct {\r\n\tBYTE pd;\t/* Associated physical drive */\r\n\tBYTE pt;\t/* Associated partition (0:Auto detect, 1-4:Forced partition) */\r\n} PARTITION;\r\nextern PARTITION VolToPart[];\t/* Volume to partition mapping table */\r\n#endif\r\n\r\n#if FF_STR_VOLUME_ID\r\n#ifndef FF_VOLUME_STRS\r\nextern const char* VolumeStr[FF_VOLUMES];\t/* User defined volume ID table */\r\n#endif\r\n#endif\r\n\r\n\r\n\r\n/* Filesystem object structure (FATFS) */\r\n\r\ntypedef struct {\r\n\tBYTE\tfs_type;\t\t/* Filesystem type (0:blank filesystem object) */\r\n\tBYTE\tpdrv;\t\t\t/* Volume hosting physical drive */\r\n\tBYTE\tldrv;\t\t\t/* Logical drive number (used only when FF_FS_REENTRANT) */\r\n\tBYTE\tn_fats;\t\t\t/* Number of FATs (1 or 2) */\r\n\tBYTE\twflag;\t\t\t/* win[] status (1:dirty) */\r\n\tBYTE\tfsi_flag;\t\t/* Allocation information control (b7:disabled, b0:dirty) */\r\n\tWORD\tid;\t\t\t\t/* Volume mount ID */\r\n\tWORD\tn_rootdir;\t\t/* Number of root directory entries (FAT12/16) */\r\n\tWORD\tcsize;\t\t\t/* Cluster size [sectors] */\r\n#if FF_MAX_SS != FF_MIN_SS\r\n\tWORD\tssize;\t\t\t/* Sector size (512, 1024, 2048 or 4096) */\r\n#endif\r\n#if FF_USE_LFN\r\n\tWCHAR*\tlfnbuf;\t\t\t/* LFN working buffer */\r\n#endif\r\n#if FF_FS_EXFAT\r\n\tBYTE*\tdirbuf;\t\t\t/* Directory entry block scratch pad buffer for exFAT */\r\n#endif\r\n#if !FF_FS_READONLY\r\n\tDWORD\tlast_clst;\t\t/* Last allocated cluster (Unknown if >= n_fatent) */\r\n\tDWORD\tfree_clst;\t\t/* Number of free clusters (Unknown if >= n_fatent-2) */\r\n#endif\r\n#if FF_FS_RPATH\r\n\tDWORD\tcdir;\t\t\t/* Current directory start cluster (0:root) */\r\n#if FF_FS_EXFAT\r\n\tDWORD\tcdc_scl;\t\t/* Containing directory start cluster (invalid when cdir is 0) */\r\n\tDWORD\tcdc_size;\t\t/* b31-b8:Size of containing directory, b7-b0: Chain status */\r\n\tDWORD\tcdc_ofs;\t\t/* Offset in the containing directory (invalid when cdir is 0) */\r\n#endif\r\n#endif\r\n\tDWORD\tn_fatent;\t\t/* Number of FAT entries (number of clusters + 2) */\r\n\tDWORD\tfsize;\t\t\t/* Number of sectors per FAT */\r\n\tLBA_t\tvolbase;\t\t/* Volume base sector */\r\n\tLBA_t\tfatbase;\t\t/* FAT base sector */\r\n\tLBA_t\tdirbase;\t\t/* Root directory base sector (FAT12/16) or cluster (FAT32/exFAT) */\r\n\tLBA_t\tdatabase;\t\t/* Data base sector */\r\n#if FF_FS_EXFAT\r\n\tLBA_t\tbitbase;\t\t/* Allocation bitmap base sector */\r\n#endif\r\n\tLBA_t\twinsect;\t\t/* Current sector appearing in the win[] */\r\n\tBYTE\twin[FF_MAX_SS];\t/* Disk access window for Directory, FAT (and file data at tiny cfg) */\r\n} FATFS;\r\n\r\n\r\n\r\n/* Object ID and allocation information (FFOBJID) */\r\n\r\ntypedef struct {\r\n\tFATFS*\tfs;\t\t\t\t/* Pointer to the hosting volume of this object */\r\n\tWORD\tid;\t\t\t\t/* Hosting volume's mount ID */\r\n\tBYTE\tattr;\t\t\t/* Object attribute */\r\n\tBYTE\tstat;\t\t\t/* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */\r\n\tDWORD\tsclust;\t\t\t/* Object data start cluster (0:no cluster or root directory) */\r\n\tFSIZE_t\tobjsize;\t\t/* Object size (valid when sclust != 0) */\r\n#if FF_FS_EXFAT\r\n\tDWORD\tn_cont;\t\t\t/* Size of first fragment - 1 (valid when stat == 3) */\r\n\tDWORD\tn_frag;\t\t\t/* Size of last fragment needs to be written to FAT (valid when not zero) */\r\n\tDWORD\tc_scl;\t\t\t/* Containing directory start cluster (valid when sclust != 0) */\r\n\tDWORD\tc_size;\t\t\t/* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */\r\n\tDWORD\tc_ofs;\t\t\t/* Offset in the containing directory (valid when file object and sclust != 0) */\r\n#endif\r\n#if FF_FS_LOCK\r\n\tUINT\tlockid;\t\t\t/* File lock ID origin from 1 (index of file semaphore table Files[]) */\r\n#endif\r\n} FFOBJID;\r\n\r\n\r\n\r\n/* File object structure (FIL) */\r\n\r\ntypedef struct {\r\n\tFFOBJID\tobj;\t\t\t/* Object identifier (must be the 1st member to detect invalid object pointer) */\r\n\tBYTE\tflag;\t\t\t/* File status flags */\r\n\tBYTE\terr;\t\t\t/* Abort flag (error code) */\r\n\tFSIZE_t\tfptr;\t\t\t/* File read/write pointer (Zeroed on file open) */\r\n\tDWORD\tclust;\t\t\t/* Current cluster of fpter (invalid when fptr is 0) */\r\n\tLBA_t\tsect;\t\t\t/* Sector number appearing in buf[] (0:invalid) */\r\n#if !FF_FS_READONLY\r\n\tLBA_t\tdir_sect;\t\t/* Sector number containing the directory entry (not used at exFAT) */\r\n\tBYTE*\tdir_ptr;\t\t/* Pointer to the directory entry in the win[] (not used at exFAT) */\r\n#endif\r\n#if FF_USE_FASTSEEK\r\n\tDWORD*\tcltbl;\t\t\t/* Pointer to the cluster link map table (nulled on open, set by application) */\r\n#endif\r\n#if !FF_FS_TINY\r\n\tBYTE\tbuf[FF_MAX_SS];\t/* File private data read/write window */\r\n#endif\r\n} FIL;\r\n\r\n\r\n\r\n/* Directory object structure (DIR) */\r\n\r\ntypedef struct {\r\n\tFFOBJID\tobj;\t\t\t/* Object identifier */\r\n\tDWORD\tdptr;\t\t\t/* Current read/write offset */\r\n\tDWORD\tclust;\t\t\t/* Current cluster */\r\n\tLBA_t\tsect;\t\t\t/* Current sector (0:Read operation has terminated) */\r\n\tBYTE*\tdir;\t\t\t/* Pointer to the directory item in the win[] */\r\n\tBYTE\tfn[12];\t\t\t/* SFN (in/out) {body[8],ext[3],status[1]} */\r\n#if FF_USE_LFN\r\n\tDWORD\tblk_ofs;\t\t/* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */\r\n#endif\r\n#if FF_USE_FIND\r\n\tconst TCHAR* pat;\t\t/* Pointer to the name matching pattern */\r\n#endif\r\n} DIR;\r\n\r\n\r\n\r\n/* File information structure (FILINFO) */\r\n\r\ntypedef struct {\r\n\tFSIZE_t\tfsize;\t\t\t/* File size */\r\n\tWORD\tfdate;\t\t\t/* Modified date */\r\n\tWORD\tftime;\t\t\t/* Modified time */\r\n\tBYTE\tfattrib;\t\t/* File attribute */\r\n#if FF_USE_LFN\r\n\tTCHAR\taltname[FF_SFN_BUF + 1];/* Alternative file name */\r\n\tTCHAR\tfname[FF_LFN_BUF + 1];\t/* Primary file name */\r\n#else\r\n\tTCHAR\tfname[12 + 1];\t/* File name */\r\n#endif\r\n} FILINFO;\r\n\r\n\r\n\r\n/* Format parameter structure (MKFS_PARM) */\r\n\r\ntypedef struct {\r\n\tBYTE fmt;\t\t\t/* Format option (FM_FAT, FM_FAT32, FM_EXFAT and FM_SFD) */\r\n\tBYTE n_fat;\t\t\t/* Number of FATs */\r\n\tUINT align;\t\t\t/* Data area alignment (sector) */\r\n\tUINT n_root;\t\t/* Number of root directory entries */\r\n\tDWORD au_size;\t\t/* Cluster size (byte) */\r\n} MKFS_PARM;\r\n\r\n\r\n\r\n/* File function return code (FRESULT) */\r\n\r\ntypedef enum {\r\n\tFR_OK = 0,\t\t\t\t/* (0) Function succeeded */\r\n\tFR_DISK_ERR,\t\t\t/* (1) A hard error occurred in the low level disk I/O layer */\r\n\tFR_INT_ERR,\t\t\t\t/* (2) Assertion failed */\r\n\tFR_NOT_READY,\t\t\t/* (3) The physical drive does not work */\r\n\tFR_NO_FILE,\t\t\t\t/* (4) Could not find the file */\r\n\tFR_NO_PATH,\t\t\t\t/* (5) Could not find the path */\r\n\tFR_INVALID_NAME,\t\t/* (6) The path name format is invalid */\r\n\tFR_DENIED,\t\t\t\t/* (7) Access denied due to a prohibited access or directory full */\r\n\tFR_EXIST,\t\t\t\t/* (8) Access denied due to a prohibited access */\r\n\tFR_INVALID_OBJECT,\t\t/* (9) The file/directory object is invalid */\r\n\tFR_WRITE_PROTECTED,\t\t/* (10) The physical drive is write protected */\r\n\tFR_INVALID_DRIVE,\t\t/* (11) The logical drive number is invalid */\r\n\tFR_NOT_ENABLED,\t\t\t/* (12) The volume has no work area */\r\n\tFR_NO_FILESYSTEM,\t\t/* (13) Could not find a valid FAT volume */\r\n\tFR_MKFS_ABORTED,\t\t/* (14) The f_mkfs function aborted due to some problem */\r\n\tFR_TIMEOUT,\t\t\t\t/* (15) Could not take control of the volume within defined period */\r\n\tFR_LOCKED,\t\t\t\t/* (16) The operation is rejected according to the file sharing policy */\r\n\tFR_NOT_ENOUGH_CORE,\t\t/* (17) LFN working buffer could not be allocated or given buffer is insufficient in size */\r\n\tFR_TOO_MANY_OPEN_FILES,\t/* (18) Number of open files > FF_FS_LOCK */\r\n\tFR_INVALID_PARAMETER\t/* (19) Given parameter is invalid */\r\n} FRESULT;\r\n\r\n\r\n\r\n\r\n/*--------------------------------------------------------------*/\r\n/* FatFs Module Application Interface                           */\r\n/*--------------------------------------------------------------*/\r\n\r\nFRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode);\t\t\t\t/* Open or create a file */\r\nFRESULT f_close (FIL* fp);\t\t\t\t\t\t\t\t\t\t\t/* Close an open file object */\r\nFRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br);\t\t\t/* Read data from the file */\r\nFRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw);\t/* Write data to the file */\r\nFRESULT f_lseek (FIL* fp, FSIZE_t ofs);\t\t\t\t\t\t\t\t/* Move file pointer of the file object */\r\nFRESULT f_truncate (FIL* fp);\t\t\t\t\t\t\t\t\t\t/* Truncate the file */\r\nFRESULT f_sync (FIL* fp);\t\t\t\t\t\t\t\t\t\t\t/* Flush cached data of the writing file */\r\nFRESULT f_opendir (DIR* dp, const TCHAR* path);\t\t\t\t\t\t/* Open a directory */\r\nFRESULT f_closedir (DIR* dp);\t\t\t\t\t\t\t\t\t\t/* Close an open directory */\r\nFRESULT f_readdir (DIR* dp, FILINFO* fno);\t\t\t\t\t\t\t/* Read a directory item */\r\nFRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern);\t/* Find first file */\r\nFRESULT f_findnext (DIR* dp, FILINFO* fno);\t\t\t\t\t\t\t/* Find next file */\r\nFRESULT f_mkdir (const TCHAR* path);\t\t\t\t\t\t\t\t/* Create a sub directory */\r\nFRESULT f_unlink (const TCHAR* path);\t\t\t\t\t\t\t\t/* Delete an existing file or directory */\r\nFRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new);\t/* Rename/Move a file or directory */\r\nFRESULT f_stat (const TCHAR* path, FILINFO* fno);\t\t\t\t\t/* Get file status */\r\nFRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask);\t\t\t/* Change attribute of a file/dir */\r\nFRESULT f_utime (const TCHAR* path, const FILINFO* fno);\t\t\t/* Change timestamp of a file/dir */\r\nFRESULT f_chdir (const TCHAR* path);\t\t\t\t\t\t\t\t/* Change current directory */\r\nFRESULT f_chdrive (const TCHAR* path);\t\t\t\t\t\t\t\t/* Change current drive */\r\nFRESULT f_getcwd (TCHAR* buff, UINT len);\t\t\t\t\t\t\t/* Get current directory */\r\nFRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs);\t/* Get number of free clusters on the drive */\r\nFRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn);\t/* Get volume label */\r\nFRESULT f_setlabel (const TCHAR* label);\t\t\t\t\t\t\t/* Set volume label */\r\nFRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf);\t/* Forward data to the stream */\r\nFRESULT f_expand (FIL* fp, FSIZE_t fsz, BYTE opt);\t\t\t\t\t/* Allocate a contiguous block to the file */\r\nFRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt);\t\t\t/* Mount/Unmount a logical drive */\r\nFRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len);\t/* Create a FAT volume */\r\nFRESULT f_fdisk (BYTE pdrv, const LBA_t ptbl[], void* work);\t\t/* Divide a physical drive into some partitions */\r\nFRESULT f_setcp (WORD cp);\t\t\t\t\t\t\t\t\t\t\t/* Set current code page */\r\nint f_putc (TCHAR c, FIL* fp);\t\t\t\t\t\t\t\t\t\t/* Put a character to the file */\r\nint f_puts (const TCHAR* str, FIL* cp);\t\t\t\t\t\t\t\t/* Put a string to the file */\r\nint f_printf (FIL* fp, const TCHAR* str, ...);\t\t\t\t\t\t/* Put a formatted string to the file */\r\nTCHAR* f_gets (TCHAR* buff, int len, FIL* fp);\t\t\t\t\t\t/* Get a string from the file */\r\n\r\n/* Some API fucntions are implemented as macro */\r\n\r\n#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))\r\n#define f_error(fp) ((fp)->err)\r\n#define f_tell(fp) ((fp)->fptr)\r\n#define f_size(fp) ((fp)->obj.objsize)\r\n#define f_rewind(fp) f_lseek((fp), 0)\r\n#define f_rewinddir(dp) f_readdir((dp), 0)\r\n#define f_rmdir(path) f_unlink(path)\r\n#define f_unmount(path) f_mount(0, path, 0)\r\n\r\n\r\n\r\n\r\n/*--------------------------------------------------------------*/\r\n/* Additional Functions                                         */\r\n/*--------------------------------------------------------------*/\r\n\r\n/* RTC function (provided by user) */\r\n#if !FF_FS_READONLY && !FF_FS_NORTC\r\nDWORD get_fattime (void);\t/* Get current time */\r\n#endif\r\n\r\n\r\n/* LFN support functions (defined in ffunicode.c) */\r\n\r\n#if FF_USE_LFN >= 1\r\nWCHAR ff_oem2uni (WCHAR oem, WORD cp);\t/* OEM code to Unicode conversion */\r\nWCHAR ff_uni2oem (DWORD uni, WORD cp);\t/* Unicode to OEM code conversion */\r\nDWORD ff_wtoupper (DWORD uni);\t\t\t/* Unicode upper-case conversion */\r\n#endif\r\n\r\n\r\n/* O/S dependent functions (samples available in ffsystem.c) */\r\n\r\n#if FF_USE_LFN == 3\t\t/* Dynamic memory allocation */\r\nvoid* ff_memalloc (UINT msize);\t\t/* Allocate memory block */\r\nvoid ff_memfree (void* mblock);\t\t/* Free memory block */\r\n#endif\r\n#if FF_FS_REENTRANT\t\t/* Sync functions */\r\nint ff_mutex_create (int vol);\t\t/* Create a sync object */\r\nvoid ff_mutex_delete (int vol);\t\t/* Delete a sync object */\r\nint ff_mutex_take (int vol);\t\t/* Lock sync object */\r\nvoid ff_mutex_give (int vol);\t\t/* Unlock sync object */\r\n#endif\r\n\r\n\r\n\r\n\r\n/*--------------------------------------------------------------*/\r\n/* Flags and Offset Address                                     */\r\n/*--------------------------------------------------------------*/\r\n\r\n/* File access mode and open method flags (3rd argument of f_open function) */\r\n#define\tFA_READ\t\t\t\t0x01\r\n#define\tFA_WRITE\t\t\t0x02\r\n#define\tFA_OPEN_EXISTING\t0x00\r\n#define\tFA_CREATE_NEW\t\t0x04\r\n#define\tFA_CREATE_ALWAYS\t0x08\r\n#define\tFA_OPEN_ALWAYS\t\t0x10\r\n#define\tFA_OPEN_APPEND\t\t0x30\r\n\r\n/* Fast seek controls (2nd argument of f_lseek function) */\r\n#define CREATE_LINKMAP\t((FSIZE_t)0 - 1)\r\n\r\n/* Format options (2nd argument of f_mkfs function) */\r\n#define FM_FAT\t\t0x01\r\n#define FM_FAT32\t0x02\r\n#define FM_EXFAT\t0x04\r\n#define FM_ANY\t\t0x07\r\n#define FM_SFD\t\t0x08\r\n\r\n/* Filesystem type (FATFS.fs_type) */\r\n#define FS_FAT12\t1\r\n#define FS_FAT16\t2\r\n#define FS_FAT32\t3\r\n#define FS_EXFAT\t4\r\n\r\n/* File attribute bits for directory entry (FILINFO.fattrib) */\r\n#define\tAM_RDO\t0x01\t/* Read only */\r\n#define\tAM_HID\t0x02\t/* Hidden */\r\n#define\tAM_SYS\t0x04\t/* System */\r\n#define AM_DIR\t0x10\t/* Directory */\r\n#define AM_ARC\t0x20\t/* Archive */\r\n\r\n\r\n#ifdef __cplusplus\r\n}\r\n#endif\r\n\r\n#endif /* FF_DEFINED */\r\n"
  },
  {
    "path": "ftpm-opensbi/include/fatfs/ffconf.h",
    "content": "/*---------------------------------------------------------------------------/\r\n/  Configurations of FatFs Module\r\n/---------------------------------------------------------------------------*/\r\n\r\n#define FFCONF_DEF\t5380\t/* Revision ID */\r\n\r\n/*---------------------------------------------------------------------------/\r\n/ Function Configurations\r\n/---------------------------------------------------------------------------*/\r\n\r\n#define FF_FS_READONLY\t0\r\n/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)\r\n/  Read-only configuration removes writing API functions, f_write(), f_sync(),\r\n/  f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()\r\n/  and optional writing functions as well. */\r\n\r\n\r\n#define FF_FS_MINIMIZE\t2\r\n/* This option defines minimization level to remove some basic API functions.\r\n/\r\n/   0: Basic functions are fully enabled.\r\n/   1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()\r\n/      are removed.\r\n/   2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.\r\n/   3: f_lseek() function is removed in addition to 2. */\r\n\r\n\r\n#define FF_USE_FIND\t\t0\r\n/* This option switches filtered directory read functions, f_findfirst() and\r\n/  f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */\r\n\r\n\r\n#define FF_USE_MKFS\t\t0\r\n/* This option switches f_mkfs(). (0:Disable or 1:Enable) */\r\n\r\n\r\n#define FF_USE_FASTSEEK\t0\r\n/* This option switches fast seek feature. (0:Disable or 1:Enable) */\r\n\r\n\r\n#define FF_USE_EXPAND\t0\r\n/* This option switches f_expand(). (0:Disable or 1:Enable) */\r\n\r\n\r\n#define FF_USE_CHMOD\t0\r\n/* This option switches attribute control API functions, f_chmod() and f_utime().\r\n/  (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */\r\n\r\n\r\n#define FF_USE_LABEL\t0\r\n/* This option switches volume label API functions, f_getlabel() and f_setlabel().\r\n/  (0:Disable or 1:Enable) */\r\n\r\n\r\n#define FF_USE_FORWARD\t0\r\n/* This option switches f_forward(). (0:Disable or 1:Enable) */\r\n\r\n\r\n#define FF_USE_STRFUNC\t0\r\n#define FF_PRINT_LLI\t0\r\n#define FF_PRINT_FLOAT\t0\r\n#define FF_STRF_ENCODE\t3\r\n/* FF_USE_STRFUNC switches the string API functions, f_gets(), f_putc(), f_puts()\r\n/  and f_printf().\r\n/\r\n/   0: Disable. FF_PRINT_LLI, FF_PRINT_FLOAT and FF_STRF_ENCODE have no effect.\r\n/   1: Enable without LF - CRLF conversion.\r\n/   2: Enable with LF - CRLF conversion.\r\n/\r\n/  FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2\r\n/  makes f_printf() support floating point argument. These features want C99 or later.\r\n/  When FF_LFN_UNICODE >= 1 with LFN enabled, string API functions convert the character\r\n/  encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE\r\n/  to be read/written via those functions.\r\n/\r\n/   0: ANSI/OEM in current CP\r\n/   1: Unicode in UTF-16LE\r\n/   2: Unicode in UTF-16BE\r\n/   3: Unicode in UTF-8\r\n*/\r\n\r\n\r\n/*---------------------------------------------------------------------------/\r\n/ Locale and Namespace Configurations\r\n/---------------------------------------------------------------------------*/\r\n\r\n#define FF_CODE_PAGE\t932\r\n/* This option specifies the OEM code page to be used on the target system.\r\n/  Incorrect code page setting can cause a file open failure.\r\n/\r\n/   437 - U.S.\r\n/   720 - Arabic\r\n/   737 - Greek\r\n/   771 - KBL\r\n/   775 - Baltic\r\n/   850 - Latin 1\r\n/   852 - Latin 2\r\n/   855 - Cyrillic\r\n/   857 - Turkish\r\n/   860 - Portuguese\r\n/   861 - Icelandic\r\n/   862 - Hebrew\r\n/   863 - Canadian French\r\n/   864 - Arabic\r\n/   865 - Nordic\r\n/   866 - Russian\r\n/   869 - Greek 2\r\n/   932 - Japanese (DBCS)\r\n/   936 - Simplified Chinese (DBCS)\r\n/   949 - Korean (DBCS)\r\n/   950 - Traditional Chinese (DBCS)\r\n/     0 - Include all code pages above and configured by f_setcp()\r\n*/\r\n\r\n\r\n#define FF_USE_LFN\t\t0\r\n#define FF_MAX_LFN\t\t255\r\n/* The FF_USE_LFN switches the support for LFN (long file name).\r\n/\r\n/   0: Disable LFN. FF_MAX_LFN has no effect.\r\n/   1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.\r\n/   2: Enable LFN with dynamic working buffer on the STACK.\r\n/   3: Enable LFN with dynamic working buffer on the HEAP.\r\n/\r\n/  To enable the LFN, ffunicode.c needs to be added to the project. The LFN feature\r\n/  requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and\r\n/  additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.\r\n/  The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can\r\n/  be in range of 12 to 255. It is recommended to be set 255 to fully support the LFN\r\n/  specification.\r\n/  When use stack for the working buffer, take care on stack overflow. When use heap\r\n/  memory for the working buffer, memory management functions, ff_memalloc() and\r\n/  ff_memfree() exemplified in ffsystem.c, need to be added to the project. */\r\n\r\n\r\n#define FF_LFN_UNICODE\t0\r\n/* This option switches the character encoding on the API when LFN is enabled.\r\n/\r\n/   0: ANSI/OEM in current CP (TCHAR = char)\r\n/   1: Unicode in UTF-16 (TCHAR = WCHAR)\r\n/   2: Unicode in UTF-8 (TCHAR = char)\r\n/   3: Unicode in UTF-32 (TCHAR = DWORD)\r\n/\r\n/  Also behavior of string I/O functions will be affected by this option.\r\n/  When LFN is not enabled, this option has no effect. */\r\n\r\n\r\n#define FF_LFN_BUF\t\t255\r\n#define FF_SFN_BUF\t\t12\r\n/* This set of options defines size of file name members in the FILINFO structure\r\n/  which is used to read out directory items. These values should be suffcient for\r\n/  the file names to read. The maximum possible length of the read file name depends\r\n/  on character encoding. When LFN is not enabled, these options have no effect. */\r\n\r\n\r\n#define FF_FS_RPATH\t\t0\r\n/* This option configures support for relative path.\r\n/\r\n/   0: Disable relative path and remove related API functions.\r\n/   1: Enable relative path. f_chdir() and f_chdrive() are available.\r\n/   2: f_getcwd() is available in addition to 1.\r\n*/\r\n\r\n\r\n/*---------------------------------------------------------------------------/\r\n/ Drive/Volume Configurations\r\n/---------------------------------------------------------------------------*/\r\n\r\n#define FF_VOLUMES\t\t1\r\n/* Number of volumes (logical drives) to be used. (1-10) */\r\n\r\n\r\n#define FF_STR_VOLUME_ID\t0\r\n#define FF_VOLUME_STRS\t\t\"RAM\",\"NAND\",\"CF\",\"SD\",\"SD2\",\"USB\",\"USB2\",\"USB3\"\r\n/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.\r\n/  When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive\r\n/  number in the path name. FF_VOLUME_STRS defines the volume ID strings for each\r\n/  logical drive. Number of items must not be less than FF_VOLUMES. Valid\r\n/  characters for the volume ID strings are A-Z, a-z and 0-9, however, they are\r\n/  compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is\r\n/  not defined, a user defined volume string table is needed as:\r\n/\r\n/  const char* VolumeStr[FF_VOLUMES] = {\"ram\",\"flash\",\"sd\",\"usb\",...\r\n*/\r\n\r\n\r\n#define FF_MULTI_PARTITION\t0\r\n/* This option switches support for multiple volumes on the physical drive.\r\n/  By default (0), each logical drive number is bound to the same physical drive\r\n/  number and only an FAT volume found on the physical drive will be mounted.\r\n/  When this feature is enabled (1), each logical drive number can be bound to\r\n/  arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()\r\n/  will be available. */\r\n\r\n\r\n#define FF_MIN_SS\t\t512\r\n#define FF_MAX_SS\t\t512\r\n/* This set of options configures the range of sector size to be supported. (512,\r\n/  1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and\r\n/  harddisk, but a larger value may be required for on-board flash memory and some\r\n/  type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is\r\n/  configured for variable sector size mode and disk_ioctl() needs to implement\r\n/  GET_SECTOR_SIZE command. */\r\n\r\n\r\n#define FF_LBA64\t\t0\r\n/* This option switches support for 64-bit LBA. (0:Disable or 1:Enable)\r\n/  To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */\r\n\r\n\r\n#define FF_MIN_GPT\t\t0x10000000\r\n/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs() and \r\n/  f_fdisk(). 2^32 sectors maximum. This option has no effect when FF_LBA64 == 0. */\r\n\r\n\r\n#define FF_USE_TRIM\t\t0\r\n/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)\r\n/  To enable this feature, also CTRL_TRIM command should be implemented to\r\n/  the disk_ioctl(). */\r\n\r\n\r\n\r\n/*---------------------------------------------------------------------------/\r\n/ System Configurations\r\n/---------------------------------------------------------------------------*/\r\n\r\n#define FF_FS_TINY\t\t0\r\n/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)\r\n/  At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.\r\n/  Instead of private sector buffer eliminated from the file object, common sector\r\n/  buffer in the filesystem object (FATFS) is used for the file data transfer. */\r\n\r\n\r\n#define FF_FS_EXFAT\t\t0\r\n/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)\r\n/  To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)\r\n/  Note that enabling exFAT discards ANSI C (C89) compatibility. */\r\n\r\n\r\n#define FF_FS_NORTC\t\t1\r\n#define FF_NORTC_MON\t11\r\n#define FF_NORTC_MDAY\t1\r\n#define FF_NORTC_YEAR\t2024\r\n/* The option FF_FS_NORTC switches timestamp feature. If the system does not have\r\n/  an RTC or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable the\r\n/  timestamp feature. Every object modified by FatFs will have a fixed timestamp\r\n/  defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.\r\n/  To enable timestamp function (FF_FS_NORTC = 0), get_fattime() need to be added\r\n/  to the project to read current time form real-time clock. FF_NORTC_MON,\r\n/  FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.\r\n/  These options have no effect in read-only configuration (FF_FS_READONLY = 1). */\r\n\r\n\r\n#define FF_FS_NOFSINFO\t0\r\n/* If you need to know correct free space on the FAT32 volume, set bit 0 of this\r\n/  option, and f_getfree() at the first time after volume mount will force\r\n/  a full FAT scan. Bit 1 controls the use of last allocated cluster number.\r\n/\r\n/  bit0=0: Use free cluster count in the FSINFO if available.\r\n/  bit0=1: Do not trust free cluster count in the FSINFO.\r\n/  bit1=0: Use last allocated cluster number in the FSINFO if available.\r\n/  bit1=1: Do not trust last allocated cluster number in the FSINFO.\r\n*/\r\n\r\n\r\n#define FF_FS_LOCK\t\t0\r\n/* The option FF_FS_LOCK switches file lock function to control duplicated file open\r\n/  and illegal operation to open objects. This option must be 0 when FF_FS_READONLY\r\n/  is 1.\r\n/\r\n/  0:  Disable file lock function. To avoid volume corruption, application program\r\n/      should avoid illegal open, remove and rename to the open objects.\r\n/  >0: Enable file lock function. The value defines how many files/sub-directories\r\n/      can be opened simultaneously under file lock control. Note that the file\r\n/      lock control is independent of re-entrancy. */\r\n\r\n\r\n#define FF_FS_REENTRANT\t0\r\n#define FF_FS_TIMEOUT\t1000\r\n/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs\r\n/  module itself. Note that regardless of this option, file access to different\r\n/  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()\r\n/  and f_fdisk(), are always not re-entrant. Only file/directory access to\r\n/  the same volume is under control of this featuer.\r\n/\r\n/   0: Disable re-entrancy. FF_FS_TIMEOUT have no effect.\r\n/   1: Enable re-entrancy. Also user provided synchronization handlers,\r\n/      ff_mutex_create(), ff_mutex_delete(), ff_mutex_take() and ff_mutex_give(),\r\n/      must be added to the project. Samples are available in ffsystem.c.\r\n/\r\n/  The FF_FS_TIMEOUT defines timeout period in unit of O/S time tick.\r\n*/\r\n\r\n\r\n\r\n/*--- End of configuration options ---*/\r\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ACT.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t Authenticated Countdown Timer\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id$\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// 5.24\tACT.h\n\n#ifndef _ACT_H_\n#define _ACT_H_\n#include \"TpmProfile.h\"\n#if !(defined RH_ACT_0) || (RH_ACT_0 != YES)\n#   undef   RH_ACT_0\n#   define  RH_ACT_0 NO\n#   define IF_ACT_0_IMPLEMENTED(op)\n#else\n#   define IF_ACT_0_IMPLEMENTED(op) op(0)\n#endif\n#if !(defined RH_ACT_1) || (RH_ACT_1 != YES)\n#   undef   RH_ACT_1\n#   define  RH_ACT_1 NO\n#   define IF_ACT_1_IMPLEMENTED(op)\n#else\n#   define IF_ACT_1_IMPLEMENTED(op) op(1)\n#endif\n#if !(defined RH_ACT_2) || (RH_ACT_2 != YES)\n#   undef   RH_ACT_2\n#   define  RH_ACT_2 NO\n#   define IF_ACT_2_IMPLEMENTED(op)\n#else\n#   define IF_ACT_2_IMPLEMENTED(op) op(2)\n#endif\n#if !(defined RH_ACT_3) || (RH_ACT_3 != YES)\n#   undef   RH_ACT_3\n#   define  RH_ACT_3 NO\n#   define IF_ACT_3_IMPLEMENTED(op)\n#else\n#   define IF_ACT_3_IMPLEMENTED(op) op(3)\n#endif\n#if !(defined RH_ACT_4) || (RH_ACT_4 != YES)\n#   undef   RH_ACT_4\n#   define  RH_ACT_4 NO\n#   define IF_ACT_4_IMPLEMENTED(op)\n#else\n#   define IF_ACT_4_IMPLEMENTED(op) op(4)\n#endif\n#if !(defined RH_ACT_5) || (RH_ACT_5 != YES)\n#   undef   RH_ACT_5\n#   define  RH_ACT_5 NO\n#   define IF_ACT_5_IMPLEMENTED(op)\n#else\n#   define IF_ACT_5_IMPLEMENTED(op) op(5)\n#endif\n#if !(defined RH_ACT_6) || (RH_ACT_6 != YES)\n#   undef   RH_ACT_6\n#   define  RH_ACT_6 NO\n#   define IF_ACT_6_IMPLEMENTED(op)\n#else\n#   define IF_ACT_6_IMPLEMENTED(op) op(6)\n#endif\n#if !(defined RH_ACT_7) || (RH_ACT_7 != YES)\n#   undef   RH_ACT_7\n#   define  RH_ACT_7 NO\n#   define IF_ACT_7_IMPLEMENTED(op)\n#else\n#   define IF_ACT_7_IMPLEMENTED(op) op(7)\n#endif\n#if !(defined RH_ACT_8) || (RH_ACT_8 != YES)\n#   undef   RH_ACT_8\n#   define  RH_ACT_8 NO\n#   define IF_ACT_8_IMPLEMENTED(op)\n#else\n#   define IF_ACT_8_IMPLEMENTED(op) op(8)\n#endif\n#if !(defined RH_ACT_9) || (RH_ACT_9 != YES)\n#   undef   RH_ACT_9\n#   define  RH_ACT_9 NO\n#   define IF_ACT_9_IMPLEMENTED(op)\n#else\n#   define IF_ACT_9_IMPLEMENTED(op) op(9)\n#endif\n#if !(defined RH_ACT_A) || (RH_ACT_A != YES)\n#   undef   RH_ACT_A\n#   define  RH_ACT_A NO\n#   define IF_ACT_A_IMPLEMENTED(op)\n#else\n#   define IF_ACT_A_IMPLEMENTED(op) op(A)\n#endif\n#if !(defined RH_ACT_B) || (RH_ACT_B != YES)\n#   undef   RH_ACT_B\n#   define  RH_ACT_B NO\n#   define IF_ACT_B_IMPLEMENTED(op)\n#else\n#   define IF_ACT_B_IMPLEMENTED(op) op(B)\n#endif\n#if !(defined RH_ACT_C) || (RH_ACT_C != YES)\n#   undef   RH_ACT_C\n#   define  RH_ACT_C NO\n#   define IF_ACT_C_IMPLEMENTED(op)\n#else\n#   define IF_ACT_C_IMPLEMENTED(op) op(C)\n#endif\n#if !(defined RH_ACT_D) || (RH_ACT_D != YES)\n#   undef   RH_ACT_D\n#   define  RH_ACT_D NO\n#   define IF_ACT_D_IMPLEMENTED(op)\n#else\n#   define IF_ACT_D_IMPLEMENTED(op) op(D)\n#endif\n#if !(defined RH_ACT_E) || (RH_ACT_E != YES)\n#   undef   RH_ACT_E\n#   define  RH_ACT_E NO\n#   define IF_ACT_E_IMPLEMENTED(op)\n#else\n#   define IF_ACT_E_IMPLEMENTED(op) op(E)\n#endif\n#if !(defined RH_ACT_F) || (RH_ACT_F != YES)\n#   undef   RH_ACT_F\n#   define  RH_ACT_F NO\n#   define IF_ACT_F_IMPLEMENTED(op)\n#else\n#   define IF_ACT_F_IMPLEMENTED(op) op(F)\n#endif\n#ifndef TPM_RH_ACT_0\n#error Need numeric definition for TPM_RH_ACT_0\n#endif\n#ifndef TPM_RH_ACT_1\n#   define TPM_RH_ACT_1    (TPM_RH_ACT_0 + 1)\n#endif\n#ifndef TPM_RH_ACT_2\n#   define TPM_RH_ACT_2    (TPM_RH_ACT_0 + 2)\n#endif\n#ifndef TPM_RH_ACT_3\n#   define TPM_RH_ACT_3    (TPM_RH_ACT_0 + 3)\n#endif\n#ifndef TPM_RH_ACT_4\n#   define TPM_RH_ACT_4    (TPM_RH_ACT_0 + 4)\n#endif\n#ifndef TPM_RH_ACT_5\n#   define TPM_RH_ACT_5    (TPM_RH_ACT_0 + 5)\n#endif\n#ifndef TPM_RH_ACT_6\n#   define TPM_RH_ACT_6    (TPM_RH_ACT_0 + 6)\n#endif\n#ifndef TPM_RH_ACT_7\n#   define TPM_RH_ACT_7    (TPM_RH_ACT_0 + 7)\n#endif\n#ifndef TPM_RH_ACT_8\n#   define TPM_RH_ACT_8    (TPM_RH_ACT_0 + 8)\n#endif\n#ifndef TPM_RH_ACT_9\n#   define TPM_RH_ACT_9    (TPM_RH_ACT_0 + 9)\n#endif\n#ifndef TPM_RH_ACT_A\n#   define TPM_RH_ACT_A    (TPM_RH_ACT_0 + 0xA)\n#endif\n#ifndef TPM_RH_ACT_B\n#   define TPM_RH_ACT_B    (TPM_RH_ACT_0 + 0xB)\n#endif\n#ifndef TPM_RH_ACT_C\n#   define TPM_RH_ACT_C    (TPM_RH_ACT_0 + 0xC)\n#endif\n#ifndef TPM_RH_ACT_D\n#   define TPM_RH_ACT_D    (TPM_RH_ACT_0 + 0xD)\n#endif\n#ifndef TPM_RH_ACT_E\n#   define TPM_RH_ACT_E    (TPM_RH_ACT_0 + 0xE)\n#endif\n#ifndef TPM_RH_ACT_F\n#   define TPM_RH_ACT_F    (TPM_RH_ACT_0 + 0xF)\n#endif\n#define FOR_EACH_ACT(op)\t\t\t\t\t\t\\\n    IF_ACT_0_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_1_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_2_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_3_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_4_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_5_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_6_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_7_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_8_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_9_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_A_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_B_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_C_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_D_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_E_IMPLEMENTED(op)\t\t\t\t\t\t\\\n    IF_ACT_F_IMPLEMENTED(op)\n\n// This is the mask for ACT that are implemented\n\n//#define ACT_MASK(N)     | (1 << 0x##N)\n//#define ACT_IMPLEMENTED_MASK    (0 FOR_EACH_ACT(ACT_MASK))\n#define CASE_ACT_HANDLE(N)     case TPM_RH_ACT_##N:\n#define CASE_ACT_NUMBER(N)     case 0x##N:\ntypedef struct ACT_STATE\n{\n    UINT32          remaining;\n    TPM_ALG_ID      hashAlg;\n    TPM2B_DIGEST    authPolicy;\n} ACT_STATE, *P_ACT_STATE;\n#endif // _ACT_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ACT_SetTimeout_fp.h",
    "content": "/********************************************************************************/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*\t \t\tTPM2_ACT_SetTimeout Header\t\t\t\t*/\r\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\r\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\r\n/*            $Id$\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\r\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\r\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\r\n/*    derivative works, distribute, display and perform the Source Code and\t*/\r\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - The TCG grants to the user of the other parts of the specification \t*/\r\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\r\n/*    display, and perform the specification solely for the purpose of \t\t*/\r\n/*    developing products based on such documents.\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\r\n/*    this list of conditions and the following disclaimers.\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\r\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\r\n/*    documentation and/or other materials provided with the distribution.\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\r\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\r\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\r\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\r\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\r\n/*  information on specification licensing rights available through TCG \t*/\r\n/*  membership agreements.\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\r\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\r\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\r\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\r\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\r\n/*    liability, including liability for infringement of any proprietary \t*/\r\n/*    rights, relating to use of information in this specification and to the\t*/\r\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\r\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\r\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\r\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\r\n/*    arising in any way out of use or reliance upon this specification or any \t*/\r\n/*    information herein.\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  (c) Copyright IBM Corp. and others, 2019\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/********************************************************************************/\r\n\r\n#ifndef ACT_SETTIMEOUT_FP_H\r\n#define ACT_SETTIMEOUT_FP_H\r\n\r\ntypedef struct {\r\n    TPMI_RH_ACT\t\tactHandle;\r\n    UINT32\t\tstartTimeout;\r\n} ACT_SetTimeout_In;\r\n\r\n#define RC_ACT_SetTimeout_actHandle \t(TPM_RC_H + TPM_RC_1)\r\n#define RC_ACT_SetTimeout_startTimeout \t(TPM_RC_H + TPM_RC_2)\r\n\r\nTPM_RC\r\nTPM2_ACT_SetTimeout(\r\n\t\t    ACT_SetTimeout_In      *in             // IN: input parameter list\r\n\t\t    );\r\n\r\n\r\n#endif\r\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ACT_spt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t ACT Command Support   \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes 1.00\n *  Date: Oct 24, 2019  Time: 10:38:43AM\n */\n\n#ifndef _ACT_SPT_FP_H_\n#define _ACT_SPT_FP_H_\n\n//*** ActStartup()\n// This function is called by TPM2_Startup() to initialize the ACT counter values.\nBOOL ActStartup(STARTUP_TYPE type);\n\n//*** ActGetSignaled()\n// This function returns the state of the signaled flag associated with an ACT.\nBOOL ActGetSignaled(TPM_RH actHandle);\n\n//***ActShutdown()\n// This function saves the current state of the counters\nBOOL ActShutdown(TPM_SU state  //IN: the type of the shutdown.\n\t\t );\n\n//*** ActIsImplemented()\n// This function determines if an ACT is implemented in both the TPM and the platform\n// code.\nBOOL ActIsImplemented(UINT32 act);\n\n//***ActCounterUpdate()\n// This function updates the ACT counter. If the counter already has a pending update,\n// it returns TPM_RC_RETRY so that the update can be tried again later.\nTPM_RC\nActCounterUpdate(TPM_RH handle,   //IN: the handle of the act\n\t\t UINT32 newValue  //IN: the value to set in the ACT\n\t\t );\n\n//*** ActGetCapabilityData()\n// This function returns the list of ACT data\n//  Return Type: TPMI_YES_NO\n//      YES             if more ACT data is available\n//      NO              if no more ACT data to\nTPMI_YES_NO\nActGetCapabilityData(TPM_HANDLE     actHandle,  // IN: the handle for the starting ACT\n\t\t     UINT32         maxCount,   // IN: maximum allowed return values\n\t\t     TPML_ACT_DATA* actList     // OUT: ACT data list\n\t\t     );\n\n//*** ActGetOneCapability()\n// This function returns an ACT's capability, if present.\nBOOL ActGetOneCapability(TPM_HANDLE     actHandle,  // IN: the handle for the ACT\n\t\t\t TPMS_ACT_DATA* actData     // OUT: ACT data\n\t\t\t );\n\n#endif  // _ACT_SPT_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ActivateCredential_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ActivateCredential_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef ACTIVATECREDENTIAL_FP_H\n#define ACTIVATECREDENTIAL_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tactivateHandle;\n    TPMI_DH_OBJECT\t\tkeyHandle;\n    TPM2B_ID_OBJECT\t\tcredentialBlob;\n    TPM2B_ENCRYPTED_SECRET\tsecret;\n} ActivateCredential_In;\n\n#define RC_ActivateCredential_activateHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_ActivateCredential_keyHandle \t(TPM_RC_H + TPM_RC_2)\n#define RC_ActivateCredential_credentialBlob\t(TPM_RC_P + TPM_RC_1)\n#define RC_ActivateCredential_secret \t\t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM2B_DIGEST\t\tcertInfo;\n} ActivateCredential_Out;\n\nTPM_RC\nTPM2_ActivateCredential(\n\t\t\tActivateCredential_In   *in,            // IN: input parameter list\n\t\t\tActivateCredential_Out  *out            // OUT: output parameter list\n\t\t\t);\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/AlgorithmCap_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef ALGORITHMCAP_FP_H\n#define ALGORITHMCAP_FP_H\n\nTPMI_YES_NO\nAlgorithmCapGetImplemented(\n\t\t\t   TPM_ALG_ID                   algID,     // IN: the starting algorithm ID\n\t\t\t   UINT32                       count,     // IN: count of returned algorithms\n\t\t\t   TPML_ALG_PROPERTY           *algList    // OUT: algorithm list\n\t\t\t   );\n//** AlgorithmCapGetOneImplemented()\n// This function returns whether a single algorithm was implemented, along\n// with its properties (if implemented).\nBOOL AlgorithmCapGetOneImplemented(\n\t\t\t\t   TPM_ALG_ID         algID,       // IN: the algorithm ID\n\t\t\t\t   TPMS_ALG_PROPERTY* algProperty  // OUT: algorithm properties\n\t\t\t\t   );\n\nLIB_EXPORT\nvoid\nAlgorithmGetImplementedVector(\n\t\t\t      ALGORITHM_VECTOR    *implemented    // OUT: the implemented bits are SET\n\t\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/AlgorithmTests_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef ALGORITHMTESTS_FP_H\n#define ALGORITHMTESTS_FP_H\n\n#if ENABLE_SELF_TESTS\n\nLIB_EXPORT\nTPM_RC\nTestAlgorithm(\n\t      TPM_ALG_ID               alg,\n\t      ALGORITHM_VECTOR        *toTest\n\t      );\n\n#endif  // ENABLE_SELF_TESTS\n#endif  // ALGORITHMTESTS_FP_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Attest_spt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Attest_spt_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef ATTEST_SPT_FP_H\n#define ATTEST_SPT_FP_H\n\nvoid\nFillInAttestInfo(\n\t\t TPMI_DH_OBJECT       signHandle,    // IN: handle of signing object\n\t\t TPMT_SIG_SCHEME     *scheme,        // IN/OUT: scheme to be used for signing\n\t\t TPM2B_DATA          *data,          // IN: qualifying data\n\t\t TPMS_ATTEST         *attest         // OUT: attest structure\n\t\t );\nTPM_RC\nSignAttestInfo(\n\t       OBJECT              *signKey,           // IN: sign object\n\t       TPMT_SIG_SCHEME     *scheme,            // IN: sign scheme\n\t       TPMS_ATTEST         *certifyInfo,       // IN: the data to be signed\n\t       TPM2B_DATA          *qualifyingData,    // IN: extra data for the signing\n\t       //     process\n\t       TPM2B_ATTEST        *attest,            // OUT: marshaled attest blob to be\n\t       //     signed\n\t       TPMT_SIGNATURE      *signature          // OUT: signature\n\t       );\nBOOL\nIsSigningObject(\n\t\tOBJECT          *object         // IN:\n\t\t);\n\n\n\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BaseTypes.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t Basic Typedefs\t\t    \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: BaseTypes.h 1531 2019-11-21 23:54:38Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 5.2\tBaseTypes.h */\n\n#ifndef BASETYPES_H\n#define BASETYPES_H\n\n#include <stdint.h>\n\n/* NULL definition */\n\n#ifndef         NULL\n#define         NULL        (0)\n#endif\ntypedef  uint8_t            UINT8;\ntypedef  uint8_t            BYTE;\ntypedef  int8_t             INT8;\ntypedef  int                BOOL;\ntypedef  uint16_t           UINT16;\ntypedef  int16_t            INT16;\ntypedef  uint32_t           UINT32;\ntypedef  int32_t            INT32;\ntypedef  uint64_t           UINT64;\ntypedef  int64_t            INT64;\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Bits_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Bit Handling\t\t  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Bits_fp.h 803 2016-11-15 20:19:26Z kgoldman \t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef BITS_FP_H\n#define BITS_FP_H\n\n/* 5.3.1 TestBit() */\n/* This function is used to check the setting of a bit in an array of bits. */\n/* Return Value Meaning */\n/* TRUE bit is set */\n/* FALSE bit is not set */\n\nBOOL\nTestBit(\n\tunsigned int     bitNum,        // IN: number of the bit in 'bArray'\n\tBYTE            *bArray,        // IN: array containing the bits\n\tunsigned int     bytesInArray   // IN: size in bytes of 'bArray'\n\t);\n\n/* 5.3.2 SetBit() */\n/* This function will set the indicated bit in bArray. */\n\nvoid\nSetBit(\n       unsigned int     bitNum,        // IN: number of the bit in 'bArray'\n       BYTE            *bArray,        // IN: array containing the bits\n       unsigned int     bytesInArray   // IN: size in bytes of 'bArray'\n       );\n\n/* 5.3.3 ClearBit() */\n/* This function will clear the indicated bit in bArray. */\n\nvoid\nClearBit(\n\t unsigned int     bitNum,        // IN: number of the bit in 'bArray'.\n\t BYTE            *bArray,        // IN: array containing the bits\n\t unsigned int     bytesInArray   // IN: size in bytes of 'bArray'\n\t );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnConvert.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar 28, 2019  Time: 08:25:18PM\n */\n\n#ifndef _BN_CONVERT_FP_H_\n#define _BN_CONVERT_FP_H_\n\n//*** BnFromBytes()\n// This function will convert a big-endian byte array to the internal number\n// format. If bn is NULL, then the output is NULL. If bytes is null or the\n// required size is 0, then the output is set to zero\nLIB_EXPORT bigNum BnFromBytes(bigNum bn, const BYTE* bytes, NUMBYTES nBytes);\n\n//*** BnFrom2B()\n// Convert an TPM2B to a BIG_NUM.\n// If the input value does not exist, or the output does not exist, or the input\n// will not fit into the output the function returns NULL\nLIB_EXPORT bigNum BnFrom2B(bigNum       bn,  // OUT:\n\t\t\t   const TPM2B* a2B  // IN: number to convert\n\t\t\t   );\n\n//*** BnToBytes()\n// This function converts a BIG_NUM to a byte array. It converts the bigNum to a\n// big-endian byte string and sets 'size' to the normalized value. If  'size' is an\n// input 0, then the receiving buffer is guaranteed to be large enough for the result\n// and the size will be set to the size required for bigNum (leading zeros\n// suppressed).\n//\n// The conversion for a little-endian machine simply requires that all significant\n// bytes of the bigNum be reversed. For a big-endian machine, rather than\n// unpack each word individually, the bigNum is converted to little-endian words,\n// copied, and then converted back to big-endian.\nLIB_EXPORT BOOL BnToBytes(bigConst  bn,\n\t\t\t  BYTE*     buffer,\n\t\t\t  NUMBYTES* size  // This the number of bytes that are\n\t\t\t  // available in the buffer. The result\n\t\t\t  // should be this big.\n\t\t\t  );\n\n//*** BnTo2B()\n// Function to convert a BIG_NUM to TPM2B.\n// The TPM2B size is set to the requested 'size' which may require padding.\n// If 'size' is non-zero and less than required by the value in 'bn' then an error\n// is returned. If 'size' is zero, then the TPM2B is assumed to be large enough\n// for the data and a2b->size will be adjusted accordingly.\nLIB_EXPORT BOOL BnTo2B(bigConst bn,   // IN:\n\t\t       TPM2B*   a2B,  // OUT:\n\t\t       NUMBYTES size  // IN: the desired size\n\t\t       );\n#if ALG_ECC\n\n//*** BnPointFromBytes()\n// Function to create a BIG_POINT structure from a byte buffer in big-endian order.\n// A point is going to be two ECC values in the same buffer. The values are going\n// to be the size of the modulus.  They are in modular form.\nLIB_EXPORT bn_point_t* BnPointFromBytes(\n\t\t\t\t\tbigPoint    ecP,  // OUT: the preallocated point structure\n\t\t\t\t\tconst BYTE* x,\n\t\t\t\t\tNUMBYTES    nBytesX,\n\t\t\t\t\tconst BYTE* y,\n\t\t\t\t\tNUMBYTES    nBytesY);\n\n//*** BnPointToBytes()\n// This function converts a BIG_POINT into a TPMS_ECC_POINT. A TPMS_ECC_POINT\n// contains two TPM2B_ECC_PARAMETER values. The maximum size of the parameters\n// is dependent on the maximum EC key size used in an implementation.\n// The presumption is that the TPMS_ECC_POINT is large enough to hold 2 TPM2B\n// values, each as large as a MAX_ECC_PARAMETER_BYTES\nLIB_EXPORT BOOL BnPointToBytes(\n\t\t\t       pointConst ecP,  // OUT: the preallocated point structure\n\t\t\t       BYTE*      x,\n\t\t\t       NUMBYTES*  pBytesX,\n\t\t\t       BYTE*      y,\n\t\t\t       NUMBYTES*  pBytesY);\n#endif  // ALG_ECC\n\n#endif  // _BN_CONVERT_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnConvert_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar 28, 2019  Time: 08:25:18PM\n */\n\n#ifndef _BN_CONVERT_FP_H_\n#define _BN_CONVERT_FP_H_\n\n//*** BnFromBytes()\n// This function will convert a big-endian byte array to the internal number\n// format. If bn is NULL, then the output is NULL. If bytes is null or the\n// required size is 0, then the output is set to zero\nLIB_EXPORT bigNum BnFromBytes(bigNum bn, const BYTE* bytes, NUMBYTES nBytes);\n\n//*** BnFrom2B()\n// Convert an TPM2B to a BIG_NUM.\n// If the input value does not exist, or the output does not exist, or the input\n// will not fit into the output the function returns NULL\nLIB_EXPORT bigNum BnFrom2B(bigNum       bn,  // OUT:\n\t\t\t   const TPM2B* a2B  // IN: number to convert\n\t\t\t   );\n\n//*** BnToBytes()\n// This function converts a BIG_NUM to a byte array. It converts the bigNum to a\n// big-endian byte string and sets 'size' to the normalized value. If  'size' is an\n// input 0, then the receiving buffer is guaranteed to be large enough for the result\n// and the size will be set to the size required for bigNum (leading zeros\n// suppressed).\n//\n// The conversion for a little-endian machine simply requires that all significant\n// bytes of the bigNum be reversed. For a big-endian machine, rather than\n// unpack each word individually, the bigNum is converted to little-endian words,\n// copied, and then converted back to big-endian.\nLIB_EXPORT BOOL BnToBytes(bigConst  bn,\n\t\t\t  BYTE*     buffer,\n\t\t\t  NUMBYTES* size  // This the number of bytes that are\n\t\t\t  // available in the buffer. The result\n\t\t\t  // should be this big.\n\t\t\t  );\n\n//*** BnTo2B()\n// Function to convert a BIG_NUM to TPM2B.\n// The TPM2B size is set to the requested 'size' which may require padding.\n// If 'size' is non-zero and less than required by the value in 'bn' then an error\n// is returned. If 'size' is zero, then the TPM2B is assumed to be large enough\n// for the data and a2b->size will be adjusted accordingly.\nLIB_EXPORT BOOL BnTo2B(bigConst bn,   // IN:\n\t\t       TPM2B*   a2B,  // OUT:\n\t\t       NUMBYTES size  // IN: the desired size\n\t\t       );\n#if ALG_ECC\n\n//*** BnPointFromBytes()\n// Function to create a BIG_POINT structure from a byte buffer in big-endian order.\n// A point is going to be two ECC values in the same buffer. The values are going\n// to be the size of the modulus.  They are in modular form.\nLIB_EXPORT bn_point_t* BnPointFromBytes(\n\t\t\t\t\tbigPoint    ecP,  // OUT: the preallocated point structure\n\t\t\t\t\tconst BYTE* x,\n\t\t\t\t\tNUMBYTES    nBytesX,\n\t\t\t\t\tconst BYTE* y,\n\t\t\t\t\tNUMBYTES    nBytesY);\n\n//*** BnPointToBytes()\n// This function converts a BIG_POINT into a TPMS_ECC_POINT. A TPMS_ECC_POINT\n// contains two TPM2B_ECC_PARAMETER values. The maximum size of the parameters\n// is dependent on the maximum EC key size used in an implementation.\n// The presumption is that the TPMS_ECC_POINT is large enough to hold 2 TPM2B\n// values, each as large as a MAX_ECC_PARAMETER_BYTES\nLIB_EXPORT BOOL BnPointToBytes(\n\t\t\t       pointConst ecP,  // OUT: the preallocated point structure\n\t\t\t       BYTE*      x,\n\t\t\t       NUMBYTES*  pBytesX,\n\t\t\t       BYTE*      y,\n\t\t\t       NUMBYTES*  pBytesY);\n#endif  // ALG_ECC\n\n#endif  // _BN_CONVERT_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnMath_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Aug 30, 2019  Time: 02:11:54PM\n */\n\n#ifndef _BN_MATH_FP_H_\n#define _BN_MATH_FP_H_\n\n//*** BnAdd()\n// This function adds two bigNum values. This function always returns TRUE.\nLIB_EXPORT BOOL BnAdd(bigNum result, bigConst op1, bigConst op2);\n\n//*** BnAddWord()\n// This function adds a word value to a bigNum. This function always returns TRUE.\nLIB_EXPORT BOOL BnAddWord(bigNum result, bigConst op, crypt_uword_t word);\n\n//*** BnSub()\n// This function does subtraction of two bigNum values and returns result = op1 - op2\n// when op1 is greater than op2. If op2 is greater than op1, then a fault is\n// generated. This function always returns TRUE.\nLIB_EXPORT BOOL BnSub(bigNum result, bigConst op1, bigConst op2);\n\n//*** BnSubWord()\n// This function subtracts a word value from a bigNum. This function always\n// returns TRUE.\nLIB_EXPORT BOOL BnSubWord(bigNum result, bigConst op, crypt_uword_t word);\n\n//*** BnUnsignedCmp()\n// This function performs a comparison of op1 to op2. The compare is approximately\n// constant time if the size of the values used in the compare is consistent\n// across calls (from the same line in the calling code).\n//  Return Type: int\n//      < 0             op1 is less than op2\n//      0               op1 is equal to op2\n//      > 0             op1 is greater than op2\nLIB_EXPORT int BnUnsignedCmp(bigConst op1, bigConst op2);\n\n//*** BnUnsignedCmpWord()\n// Compare a bigNum to a crypt_uword_t.\n//  Return Type: int\n//      -1              op1 is less that word\n//      0               op1 is equal to word\n//      1               op1 is greater than word\nLIB_EXPORT int BnUnsignedCmpWord(bigConst op1, crypt_uword_t word);\n\n//*** BnModWord()\n// This function does modular division of a big number when the modulus is a\n// word value.\nLIB_EXPORT crypt_word_t BnModWord(bigConst numerator, crypt_word_t modulus);\n\n//*** BnMsb()\n// This function returns the number of the MSb of a bigNum value.\n//  Return Type: int\n//      -1              the word was zero or 'bn' was NULL\n//      n               the bit number of the most significant bit in the word\nLIB_EXPORT int BnMsb(bigConst bn);\n\n//*** BnSizeInBits()\n// This function returns the number of bits required to hold a number. It is one\n// greater than the Msb.\n//\nLIB_EXPORT unsigned BnSizeInBits(bigConst n);\n\n//*** BnSetWord()\n// Change the value of a bignum_t to a word value.\nLIB_EXPORT bigNum BnSetWord(bigNum n, crypt_uword_t w);\n\n//*** BnSetBit()\n// This function will SET a bit in a bigNum. Bit 0 is the least-significant bit in\n// the 0th digit_t. The function always return TRUE\nLIB_EXPORT BOOL BnSetBit(bigNum       bn,     // IN/OUT: big number to modify\n\t\t\t unsigned int bitNum  // IN: Bit number to SET\n\t\t\t );\n\n//*** BnTestBit()\n// This function is used to check to see if a bit is SET in a bignum_t. The 0th bit\n// is the LSb of d[0].\n//  Return Type: BOOL\n//      TRUE(1)         the bit is set\n//      FALSE(0)        the bit is not set or the number is out of range\nLIB_EXPORT BOOL BnTestBit(bigNum       bn,     // IN: number to check\n\t\t\t  unsigned int bitNum  // IN: bit to test\n\t\t\t  );\n\n//***BnMaskBits()\n// This function is used to mask off high order bits of a big number.\n// The returned value will have no more than 'maskBit' bits\n// set.\n// Note: There is a requirement that unused words of a bignum_t are set to zero.\n//  Return Type: BOOL\n//      TRUE(1)         result masked\n//      FALSE(0)        the input was not as large as the mask\nLIB_EXPORT BOOL BnMaskBits(bigNum        bn,      // IN/OUT: number to mask\n\t\t\t   crypt_uword_t maskBit  // IN: the bit number for the mask.\n\t\t\t   );\n\n//*** BnShiftRight()\n// This function will shift a bigNum to the right by the shiftAmount.\n// This function always returns TRUE.\nLIB_EXPORT BOOL BnShiftRight(bigNum result, bigConst toShift, uint32_t shiftAmount);\n\n//*** BnGetCurveData()\n// This function returns the pointer for the parameter data\n// associated with a curve.\nconst TPMBN_ECC_CURVE_CONSTANTS* BnGetCurveData(TPM_ECC_CURVE curveId);\n\n//*** BnIsPointOnCurve()\n// This function checks if a point is on the curve.\nBOOL BnIsPointOnCurve(pointConst Q, const TPMBN_ECC_CURVE_CONSTANTS* C);\n\n#endif  // _BN_MATH_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnMemory_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef BNMEMORY_FP_H\n#define BNMEMORY_FP_H\n\nLIB_EXPORT bigNum\nBnSetTop(\n\t bigNum           bn,        // IN/OUT: number to clean\n\t crypt_uword_t    top        // IN: the new top\n\t );\nLIB_EXPORT bigNum\nBnClearTop(\n\t   bigNum          bn\n\t   );\nLIB_EXPORT bigNum\nBnInitializeWord(\n\t\t bigNum          bn,         // IN:\n\t\t crypt_uword_t   allocated,  // IN:\n\t\t crypt_uword_t   word        // IN:\n\t\t );\nLIB_EXPORT bigNum\nBnInit(\n       bigNum               bn,\n       crypt_uword_t        allocated\n       );\nLIB_EXPORT BOOL\nBnCopy(\n       bigNum           out,\n       bigConst         in\n       );\n#if ALG_ECC\nLIB_EXPORT BOOL\nBnPointCopy(\n\t    bigPoint                 pOut,\n\t    pointConst               pIn\n\t    );\nLIB_EXPORT bn_point_t *\nBnInitializePoint(\n\t\t  bigPoint             p,     // OUT: structure to receive pointers\n\t\t  bigNum               x,     // IN: x coordinate\n\t\t  bigNum               y,     // IN: y coordinate\n\t\t  bigNum               z      // IN: x coordinate\n\t\t  );\n\n#endif  // ALG_ECC\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnOssl.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the headers necessary to build the Open SSL support for\n// the TpmBigNum library.\n#ifndef _BNOSSL_H_\n#define _BNOSSL_H_\n// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers\n#include \"tpm_public.h\"\n#include \"TpmFail_fp.h\"\n#include \"BnToOsslMath.h\"\n// TODO_RENAME_INC_FOLDER: these refer to TpmBigNum protected headers\n#include \"BnSupport_Interface.h\"\n#include \"BnUtil_fp.h\"\n#include \"BnMemory_fp.h\"\n#include \"BnMath_fp.h\"\n#include \"BnConvert_fp.h\"\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnSupport_Interface.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// Prototypes for functions the bignum library requires\n// from a bignum-based math support library.\n// Functions contained in the MathInterface but not listed here are provided by\n// the TpmBigNum library itself.\n//\n// This file contains the function prototypes for the functions that need to be\n// present in the selected math library. For each function listed, there should\n// be a small stub function. That stub provides the interface between the TPM\n// code and the support library. In most cases, the stub function will only need\n// to do a format conversion between the TPM big number and the support library\n// big number. The TPM big number format was chosen to make this relatively\n// simple and fast.\n//\n// Arithmetic operations return a BOOL to indicate if the operation completed\n// successfully or not.\n\n#ifndef BN_SUPPORT_INTERFACE_H\n#define BN_SUPPORT_INTERFACE_H\n// TODO_RENAME_INC_FOLDER:private refers to the TPM_CoreLib private headers\n#include \"GpMacros.h\"\n#include \"BnValues.h\"\n\n//** BnSupportLibInit()\n// This function is called by CryptInit() so that necessary initializations can be\n// performed on the cryptographic library.\nLIB_EXPORT\nint BnSupportLibInit(void);\n\n//** MathLibraryCompatibililtyCheck()\n// This function is only used during development to make sure that the library\n// that is being referenced is using the same size of data structures as the TPM.\nBOOL BnMathLibraryCompatibilityCheck(void);\n\n//** BnModMult()\n// Does 'op1' * 'op2' and divide by 'modulus' returning the remainder of the divide.\nLIB_EXPORT BOOL BnModMult(\n\t\t\t  bigNum result, bigConst op1, bigConst op2, bigConst modulus);\n\n//** BnMult()\n// Multiplies two numbers and returns the result\nLIB_EXPORT BOOL BnMult(bigNum result, bigConst multiplicand, bigConst multiplier);\n\n//** BnDiv()\n// This function divides two bigNum values. The function returns FALSE if there is\n// an error in the operation.\nLIB_EXPORT BOOL BnDiv(\n\t\t      bigNum quotient, bigNum remainder, bigConst dividend, bigConst divisor);\n//** BnMod()\n#define BnMod(a, b) BnDiv(NULL, (a), (a), (b))\n\n#if ALG_RSA\n//** BnGcd()\n// Get the greatest common divisor of two numbers. This function is only needed\n// when the TPM implements RSA.\nLIB_EXPORT BOOL BnGcd(bigNum gcd, bigConst number1, bigConst number2);\n\n//** BnModExp()\n// Do modular exponentiation using bigNum values. This function is only needed\n// when the TPM implements RSA.\nLIB_EXPORT BOOL BnModExp(\n\t\t\t bigNum result, bigConst number, bigConst exponent, bigConst modulus);\n#endif  // ALG_RSA\n\n\t//** BnModInverse()\n\t// Modular multiplicative inverse.\nLIB_EXPORT BOOL BnModInverse(bigNum result, bigConst number, bigConst modulus);\n\n#if ALG_ECC\n\n//** BnCurveInitialize()\n// This function is used to initialize the pointers of a bigCurveData structure. The\n// structure is a set of pointers to bigNum values. The curve-dependent values are\n// set by a different function. This function is only needed\n// if the TPM supports ECC.\nLIB_EXPORT bigCurveData* BnCurveInitialize(bigCurveData* E, TPM_ECC_CURVE curveId);\n\n//*** BnCurveFree()\n// This function will free the allocated components of the curve and end the\n// frame in which the curve data exists\nLIB_EXPORT void BnCurveFree(bigCurveData* E);\n\n//** BnEccModMult()\n// This function does a point multiply of the form R = [d]S. A return of FALSE\n// indicates that the result was the point at infinity. This function is only needed\n// if the TPM supports ECC.\nLIB_EXPORT BOOL BnEccModMult(\n\t\t\t     bigPoint R, pointConst S, bigConst d, const bigCurveData* E);\n\n//** BnEccModMult2()\n// This function does a point multiply of the form R = [d]S + [u]Q. A return of\n// FALSE indicates that the result was the point at infinity. This function is only\n// needed if the TPM supports ECC.\nLIB_EXPORT BOOL BnEccModMult2(bigPoint            R,\n\t\t\t      pointConst          S,\n\t\t\t      bigConst            d,\n\t\t\t      pointConst          Q,\n\t\t\t      bigConst            u,\n\t\t\t      const bigCurveData* E);\n\n//** BnEccAdd()\n// This function does a point add R = S + Q. A return of FALSE\n// indicates that the result was the point at infinity. This function is only needed\n// if the TPM supports ECC.\nLIB_EXPORT BOOL BnEccAdd(\n\t\t\t bigPoint R, pointConst S, pointConst Q, const bigCurveData* E);\n\n#endif  // ALG_ECC\n\n#endif  //BN_SUPPORT_INTERFACE_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnToOsslMath.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains OpenSSL specific functions called by TpmBigNum library to provide\n// the TpmBigNum + OpenSSL math support.\n\n#ifndef _BN_TO_OSSL_MATH_H_\n#define _BN_TO_OSSL_MATH_H_\n\n#define MATH_LIB_OSSL\n\n// Require TPM Big Num types\n#if !defined(MATH_LIB_TPMBIGNUM) && !defined(_BNOSSL_H_)\n#  error this OpenSSL Interface expects to be used from TpmBigNum\n#endif\n\n#include \"BnValues.h\"\n#include <openssl/evp.h>\n#include <openssl/ec.h>\n#include <openssl/bn.h>\n\n#if OPENSSL_VERSION_NUMBER >= 0x30300ff0L\n// Check the bignum_st definition against the one below and either update the\n// version check or provide the new definition for this version.\n#  error Untested OpenSSL version\n#elif OPENSSL_VERSION_NUMBER >= 0x10100000L\n// from crypto/bn/bn_lcl.h (OpenSSL 1.x) or crypto/bn/bn_local.h (OpenSSL 3.0)\nstruct bignum_st\n{\n    BN_ULONG* d;   /* Pointer to an array of 'BN_BITS2' bit\n\t\t    * chunks. */\n    int       top; /* Index of last used d +1. */\n    /* The next are internal book keeping for bn_expand. */\n    int dmax;      /* Size of the d array. */\n    int neg;       /* one if the number is negative */\n    int flags;\n};\n#else\n#  define EC_POINT_get_affine_coordinates EC_POINT_get_affine_coordinates_GFp\n#  define EC_POINT_set_affine_coordinates EC_POINT_set_affine_coordinates_GFp\n#endif  // OPENSSL_VERSION_NUMBER\n\n\t//** Macros and Defines\n\n\t// Make sure that the library is using the correct size for a crypt word\n#if defined THIRTY_TWO_BIT && (RADIX_BITS != 32)\t\t\t\\\n    || ((defined SIXTY_FOUR_BIT_LONG || defined SIXTY_FOUR_BIT)\t\t\\\n\t&& (RADIX_BITS != 64))\n#  error Ossl library is using different radix\n#endif\n\n// Allocate a local BIGNUM value. For the allocation, a bigNum structure is created\n// as is a local BIGNUM. The bigNum is initialized and then the BIGNUM is\n// set to reference the local value.\n#define BIG_VAR(name, bits)\t\t \\\n    BN_VAR(name##Bn, (bits));\t\t \\\n    BIGNUM  _##name;\t\t\t \\\n    BIGNUM* name = BigInitialized(\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t, BnInit(name##Bn, BYTES_TO_CRYPT_WORDS(sizeof(_##name##Bn.d))))\n\n// Allocate a BIGNUM and initialize with the values in a bigNum initializer\n#define BIG_INITIALIZED(name, initializer)\t\t\t\t\\\n    BIGNUM  _##name;\t\t\t\t\t\t\t\\\n    BIGNUM* name = BigInitialized(&_##name, initializer)\n\ntypedef struct\n{\n    const TPMBN_ECC_CURVE_CONSTANTS* C;  // the TPM curve values\n    EC_GROUP*                        G;  // group parameters\n    BN_CTX* CTX;  // the context for the math (this might not be\n    // the context in which the curve was created>;\n} OSSL_CURVE_DATA;\n\n// Define the curve data type expected by the TpmBigNum library:\ntypedef OSSL_CURVE_DATA                     bigCurveData;\n\nTPM_INLINE const TPMBN_ECC_CURVE_CONSTANTS* AccessCurveConstants(\n\t\t\t\t\t\t\t\t const bigCurveData* E)\n{\n    return E->C;\n}\n\n#include \"TpmToOsslSupport_fp.h\"\n\n// Start and end a context within which the OpenSSL memory management works\n#define OSSL_ENTER() BN_CTX* CTX = OsslContextEnter()\n#define OSSL_LEAVE() OsslContextLeave(CTX)\n\n// Start and end a local stack frame within the context of the curve frame\n#define ECC_ENTER() BN_CTX* CTX = OsslPushContext(E->CTX)\n#define ECC_LEAVE() OsslPopContext(CTX)\n\n#define BN_NEW() BnNewVariable(CTX)\n\n// This definition would change if there were something to report\n#define MathLibSimulationEnd()\n\n#endif  // _BN_TO_OSSL_MATH_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnToOsslMath_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Oct 24, 2019  Time: 11:37:07AM\n */\n\n#ifndef _BN_TO_OSSL_MATH_FP_H_\n#define _BN_TO_OSSL_MATH_FP_H_\n\n#ifdef MATH_LIB_OSSL\n\n//*** OsslToTpmBn()\n// This function converts an OpenSSL BIGNUM to a TPM bigNum. In this implementation\n// it is assumed that OpenSSL uses a different control structure but the same data\n// layout -- an array of native-endian words in little-endian order.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure because value will not fit or OpenSSL variable doesn't\n//                      exist\nBOOL OsslToTpmBn(bigNum bn, BIGNUM* osslBn);\n\n//*** BigInitialized()\n// This function initializes an OSSL BIGNUM from a TPM bigConst. Do not use this for\n// values that are passed to OpenSLL when they are not declared as const in the\n// function prototype. Instead, use BnNewVariable().\nBIGNUM* BigInitialized(BIGNUM* toInit, bigConst initializer);\n#endif  // MATHLIB OSSL\n\n#endif // _TPM_TO_OSSL_MATH_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnToOsslSupport.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnToOsslSym.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnUtil_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// Utility functions to support TpmBigNum library\n#ifndef _BNUTIL_FP_H_\n#define _BNUTIL_FP_H_\n\n#endif  // _BNUTIL_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/BnValues.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  For defining the internal BIGNUM structure   \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n\n// This file contains the definitions needed for defining the internal bigNum\n// structure.\n\n// A bigNum is a pointer to a structure. The structure has three fields. The\n// last field is and array (d) of crypt_uword_t. Each word is in machine format\n// (big- or little-endian) with the words in ascending significance (i.e. words\n// in little-endian order). This is the order that seems to be used in every\n// big number library in the worlds, so...\n//\n// The first field in the structure (allocated) is the number of words in 'd'.\n// This is the upper limit on the size of the number that can be held in the\n// structure. This differs from libraries like OpenSSL as this is not intended\n// to deal with numbers of arbitrary size; just numbers that are needed to deal\n// with the algorithms that are defined in the TPM implementation.\n//\n// The second field in the structure (size) is the number of significant words\n// in 'n'. When this number is zero, the number is zero. The word at used-1 should\n// never be zero. All words between d[size] and d[allocated-1] should be zero.\n\n//** Defines\n\n#ifndef _BN_NUMBERS_H\n#define _BN_NUMBERS_H\n// TODO_RENAME_INC_FOLDER:private refers to the TPM_CoreLib private headers\n#include \"TpmAlgorithmDefines.h\"\n#include \"GpMacros.h\"  // required for TpmFail_fp.h\n#include \"Capabilities.h\"\n#include \"TpmTypes.h\"  // requires capabilities & GpMacros\n\n// These are the basic big number formats. This is convertible to the library-\n// specific format without too much difficulty. For the math performed using\n// these numbers, the value is always positive.\n#define BN_STRUCT_DEF(struct_type, count)\t  \\\n    struct st_##struct_type##_t\t\t\t  \\\n    {\t\t\t\t\t\t  \\\n\tcrypt_uword_t allocated;\t\t  \\\n\tcrypt_uword_t size;\t\t\t  \\\n\tcrypt_uword_t d[count];\t\t\t  \\\n    }\n\ntypedef BN_STRUCT_DEF(bnroot, 1) bignum_t;\n\n#ifndef bigNum\ntypedef bignum_t*       bigNum;\ntypedef const bignum_t* bigConst;\n#endif  //bigNum\n\nextern const bignum_t BnConstZero;\n\n// The Functions to access the properties of a big number.\n// Get number of allocated words\n#define BnGetAllocated(x) (unsigned)((x)->allocated)\n\n// Get number of words used\n#define BnGetSize(x) ((x)->size)\n\n// Get a pointer to the data array\n#define BnGetArray(x) ((crypt_uword_t*)&((x)->d[0]))\n\n// Get the nth word of a bigNum (zero-based)\n#define BnGetWord(x, i) (crypt_uword_t)((x)->d[i])\n\n// Some things that are done often.\n\n// Test to see if a bignum_t is equal to zero\n#define BnEqualZero(bn) (BnGetSize(bn) == 0)\n\n// Test to see if a bignum_t is equal to a word type\n#define BnEqualWord(bn, word)\t\t\t\t\t\t\\\n    ((BnGetSize(bn) == 1) && (BnGetWord(bn, 0) == (crypt_uword_t)word))\n\n// Determine if a bigNum is even. A zero is even. Although the\n// indication that a number is zero is that its size is zero,\n// all words of the number are 0 so this test works on zero.\n#define BnIsEven(n) ((BnGetWord(n, 0) & 1) == 0)\n\n// The macros below are used to define bigNum values of the required\n// size. The values are allocated on the stack so they can be\n// treated like simple local values.\n\n// This will call the initialization function for a defined bignum_t.\n// This sets the allocated and used fields and clears the words of 'n'.\n#define BN_INIT(name)\t\t\t\t\t\t\t\\\n    (bigNum) BnInit((bigNum) & (name), BYTES_TO_CRYPT_WORDS(sizeof(name.d)))\n\n#define CRYPT_WORDS(bytes) BYTES_TO_CRYPT_WORDS(bytes)\n#define MIN_ALLOC(bytes)   (CRYPT_WORDS(bytes) < 1 ? 1 : CRYPT_WORDS(bytes))\n#define BN_CONST(name, bytes, initializer)\t   \\\n    typedef const struct name##_type\t\t   \\\n    {\t\t\t\t\t\t   \\\n\tcrypt_uword_t allocated;\t\t   \\\n\tcrypt_uword_t size;\t\t\t   \\\n\tcrypt_uword_t d[MIN_ALLOC(bytes)];\t   \\\n    } name##_type;\t\t\t\t\t\t\t\\\n    name##_type name = {MIN_ALLOC(bytes), CRYPT_WORDS(bytes), {initializer}};\n\n#define BN_STRUCT_ALLOCATION(bits) (BITS_TO_CRYPT_WORDS(bits) + 1)\n\n// Create a structure of the correct size.\n#define BN_STRUCT(struct_type, bits)\t\t\t\t\t\\\n    BN_STRUCT_DEF(struct_type, BN_STRUCT_ALLOCATION(bits))\n\n// Define a bigNum type with a specific allocation\n#define BN_TYPE(name, bits) typedef BN_STRUCT(name, bits) bn_##name##_t\n\n// This creates a local bigNum variable of a specific size and\n// initializes it from a TPM2B input parameter.\n#define BN_INITIALIZED(name, bits, initializer)\t\t\\\n    BN_STRUCT(name, bits) name##_;\t\t\t\t\t\\\n    bigNum name = TpmMath_IntFrom2B(BN_INIT(name##_), (const TPM2B*)initializer)\n\n// Create a local variable that can hold a number with 'bits'\n#define BN_VAR(name, bits)\t\t\t\t\t \\\n    BN_STRUCT(name, bits) _##name;\t\t\t\t \\\n    bigNum name = BN_INIT(_##name)\n\n// Create a type that can hold the largest number defined by the\n// implementation.\n#define BN_MAX(name) BN_VAR(name, LARGEST_NUMBER_BITS)\n#define BN_MAX_INITIALIZED(name, initializer)\t\t\t\t\\\n    BN_INITIALIZED(name, LARGEST_NUMBER_BITS, initializer)\n\n// A word size value is useful\n#define BN_WORD(name) BN_VAR(name, RADIX_BITS)\n\n// This is used to create a word-size bigNum and initialize it with\n// an input parameter to a function.\n#define BN_WORD_INITIALIZED(name, initial)\t\t\t\t\\\n    BN_STRUCT(RADIX_BITS) name##_;\t\t\t\t\t\\\n    bigNum name =\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\tBnInitializeWord((bigNum)&name##_, BN_STRUCT_ALLOCATION(RADIX_BITS), initial)\n\n// ECC-Specific Values\n\n// This is the format for a point. It is always in affine format. The Z value is\n// carried as part of the point, primarily to simplify the interface to the support\n// library. Rather than have the interface layer have to create space for the\n// point each time it is used...\n// The x, y, and z values are pointers to bigNum values and not in-line versions of\n// the numbers. This is a relic of the days when there was no standard TPM format\n// for the numbers\ntypedef struct _bn_point_t\n{\n    bigNum x;\n    bigNum y;\n    bigNum z;\n} bn_point_t;\n\ntypedef bn_point_t*       bigPoint;\ntypedef const bn_point_t* pointConst;\n\ntypedef struct constant_point_t\n{\n    bigConst x;\n    bigConst y;\n    bigConst z;\n} constant_point_t;\n\n// coords points into x,y,z\n// a bigPoint is a pointer to one of these structures, and\n// therefore a pointer to bn_point_t (a coords).\n// so bigPoint->coords->x->size is the size of x, and\n// all 3 components are the same size.\n#define BN_POINT_BUF(typename, bits)\t\t\t \\\n    struct bnpt_st_##typename##_t\t\t\t \\\n    {\t\t\t\t\t\t\t \\\n\tbn_point_t coords;\t\t\t\t \\\n\tBN_STRUCT(typename##_x, MAX_ECC_KEY_BITS) x;\t \\\n\tBN_STRUCT(typename##_y, MAX_ECC_KEY_BITS) y;\t \\\n\tBN_STRUCT(typename##_z, MAX_ECC_KEY_BITS) z;\t \\\n    }\n\ntypedef BN_POINT_BUF(fullpoint, MAX_ECC_KEY_BITS) bn_fullpoint_t;\n\n// TPMBN_ECC_CURVE_CONSTANTS\n// =========================\n// A cryptographic elliptic curve is a mathematical set (Group) of points that\n// satisfy the group equation and are generated by linear multiples of some\n// initial \"generator\" point (Gx,Gy).\n//\n// The TPM code supports ECC Curves that satisfy equations of the following\n// form:\n//\n// (y^2 = x^3 + a*x + b) mod p\n//\n// A particular cryptographic curve is fully described by the following\n// parameters:\n//\n// | Name    | Meaning                                                                             |\n// | :------ | :---------------------------------------------------------------------------------- |\n// | p       | curve prime                                                                         |\n// | a, b    | equation coefficients                                                               |\n// | (Gx,Gy) | X and Y coordinates of the generator point.                                         |\n// | n       | the order (size) of the generated group.  n must be prime.                          |\n// | h       | the cofactor of the group size to the full set of points for a particular equation. |\n//\n// The group of constants to describe a particular ECC Curve (such as NIST P256\n// or P384) are contained in TPMBN_ECC_CURVE_CONSTANTS objects.  In the\n// TpmBigNum library these constants are always stored in TPM's internal BN\n// (bigNum) format.\n//\n// Other math libraries are expected to provide these as compile time constants\n// in a format they can efficiently consume at runtime.\n\n// Structure for the curve parameters. This is an analog to the\n// TPMS_ALGORITHM_DETAIL_ECC\ntypedef struct\n{\n    TPM_ECC_CURVE    curveId;  // TPM Algorithm ID for this data\n    bigConst         prime;    // a prime number\n    bigConst         order;    // the order of the curve\n    bigConst         h;        // cofactor\n    bigConst         a;        // linear coefficient\n    bigConst         b;        // constant term\n    constant_point_t base;     // base point\n} TPMBN_ECC_CURVE_CONSTANTS;\n\n// Access macros for the TPMBN_ECC_CURVE_CONSTANTS structure. The parameter 'C' is a pointer\n// to an TPMBN_ECC_CURVE_CONSTANTS structure. In some libraries, the curve structure E contains\n// a pointer to an TPMBN_ECC_CURVE_CONSTANTS structure as well as some other bits. For those\n// cases, the AccessCurveConstants function is used in the code to first get the pointer\n// to the TPMBN_ECC_CURVE_CONSTANTS for access. In some cases, the function does nothing.\n// AccessCurveConstants and these functions are all defined as inline so they can be optimized\n// away in cases where they are no-ops.\nTPM_INLINE bigConst BnCurveGetPrime(const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    return C->prime;\n}\nTPM_INLINE bigConst BnCurveGetOrder(const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    return C->order;\n}\nTPM_INLINE bigConst BnCurveGetCofactor(const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    return C->h;\n}\nTPM_INLINE bigConst BnCurveGet_a(const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    return C->a;\n}\nTPM_INLINE bigConst BnCurveGet_b(const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    return C->b;\n}\nTPM_INLINE pointConst BnCurveGetG(const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    return (pointConst) & (C->base);\n}\nTPM_INLINE bigConst BnCurveGetGx(const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    return C->base.x;\n}\nTPM_INLINE bigConst BnCurveGetGy(const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    return C->base.y;\n}\nTPM_INLINE TPM_ECC_CURVE BnCurveGetCurveId(const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    return C->curveId;\n}\n\n// Convert bytes in initializers\n// This is used for CryptEccData.c.\n#define BIG_ENDIAN_BYTES_TO_UINT32(a, b, c, d)\t\t\t\t\\\n    (((UINT32)(a) << 24) + ((UINT32)(b) << 16) + ((UINT32)(c) << 8) + ((UINT32)(d)))\n\n#define BIG_ENDIAN_BYTES_TO_UINT64(a, b, c, d, e, f, g, h)\t\t\\\n    (((UINT64)(a) << 56) + ((UINT64)(b) << 48) + ((UINT64)(c) << 40)\t\\\n     + ((UINT64)(d) << 32) + ((UINT64)(e) << 24) + ((UINT64)(f) << 16)\t\\\n     + ((UINT64)(g) << 8) + ((UINT64)(h)))\n\n// These macros are used for data initialization of big number ECC constants\n// These two macros combine a macro for data definition with a macro for\n// structure initialization. The 'a' parameter is a macro that gives numbers to\n// each of the bytes of the initializer and defines where each of the numberd\n// bytes will show up in the final structure. The 'b' value is a structure that\n// contains the requisite number of bytes in big endian order. S, the MJOIN\n// and JOIND macros will combine a macro defining a data layout with a macro defining\n// the data to be places. Generally, these macros will only need expansion when\n// CryptEccData.c gets compiled.\n#define JOINED(a, b) a b\n#define MJOIN(a, b)  a b\n\n#if RADIX_BYTES == 64\n#  define B8_TO_BN(a, b, c, d, e, f, g, h)\t\t\t\t\\\n    ((((((((((((((((UINT64)a) << 8) | (UINT64)b) << 8) | (UINT64)c) << 8) \\\n\t     | (UINT64)d)\t\t\t\t\t\t\\\n\t    << 8)\t\t\t\t\t\t\t\\\n\t   | (UINT64)e)\t\t\t\t\t\t\t\\\n\t  << 8)\t\t\t\t\t\t\t\t\\\n\t | (UINT64)f)\t\t\t\t\t\t\t\\\n\t<< 8)\t\t\t\t\t\t\t\t\\\n       | (UINT64)g)\t\t\t\t\t\t\t\\\n      << 8)\t\t\t\t\t\t\t\t\\\n     | (UINT64)h)\n#  define B1_TO_BN(a)                   B8_TO_BN(0, 0, 0, 0, 0, 0, 0, a)\n#  define B2_TO_BN(a, b)                B8_TO_BN(0, 0, 0, 0, 0, 0, a, b)\n#  define B3_TO_BN(a, b, c)             B8_TO_BN(0, 0, 0, 0, 0, a, b, c)\n#  define B4_TO_BN(a, b, c, d)          B8_TO_BN(0, 0, 0, 0, a, b, c, d)\n#  define B5_TO_BN(a, b, c, d, e)       B8_TO_BN(0, 0, 0, a, b, c, d, e)\n#  define B6_TO_BN(a, b, c, d, e, f)    B8_TO_BN(0, 0, a, b, c, d, e, f)\n#  define B7_TO_BN(a, b, c, d, e, f, g) B8_TO_BN(0, a, b, c, d, e, f, g)\n#else\n#  define B1_TO_BN(a)       B4_TO_BN(0, 0, 0, a)\n#  define B2_TO_BN(a, b)    B4_TO_BN(0, 0, a, b)\n#  define B3_TO_BN(a, b, c) B4_TO_BN(0, a, b, c)\n#  define B4_TO_BN(a, b, c, d)\t\t\t\t\t\t\\\n    (((((((UINT32)a << 8) | (UINT32)b) << 8) | (UINT32)c) << 8) | (UINT32)d)\n#  define B5_TO_BN(a, b, c, d, e)          B4_TO_BN(b, c, d, e), B1_TO_BN(a)\n#  define B6_TO_BN(a, b, c, d, e, f)       B4_TO_BN(c, d, e, f), B2_TO_BN(a, b)\n#  define B7_TO_BN(a, b, c, d, e, f, g)    B4_TO_BN(d, e, f, g), B3_TO_BN(a, b, c)\n#  define B8_TO_BN(a, b, c, d, e, f, g, h) B4_TO_BN(e, f, g, h), B4_TO_BN(a, b, c, d)\n\n#endif\n\n#endif  // _BN_NUMBERS_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Capabilities.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tNumber of capability values that will fit into the largest data buffer\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Capabilities.h 1519 2019-11-15 20:43:51Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef     _CAPABILITIES_H\n#define     _CAPABILITIES_H\n\n#define    MAX_CAP_DATA         (MAX_CAP_BUFFER - sizeof(TPM_CAP)-sizeof(UINT32))\n#define    MAX_CAP_ALGS         (MAX_CAP_DATA / sizeof(TPMS_ALG_PROPERTY))\n#define    MAX_CAP_HANDLES      (MAX_CAP_DATA / sizeof(TPM_HANDLE))\n#define    MAX_CAP_CC           (MAX_CAP_DATA / sizeof(TPM_CC))\n#define    MAX_TPM_PROPERTIES   (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PROPERTY))\n#define    MAX_PCR_PROPERTIES   (MAX_CAP_DATA / sizeof(TPMS_TAGGED_PCR_SELECT))\n#define    MAX_ECC_CURVES       (MAX_CAP_DATA / sizeof(TPM_ECC_CURVE))\n#define    MAX_TAGGED_POLICIES  (MAX_CAP_DATA / sizeof(TPMS_TAGGED_POLICY))\n#define    MAX_ACT_DATA\t\t(MAX_CAP_DATA / sizeof(TPMS_ACT_DATA))\n#define    MAX_AC_CAPABILITIES  (MAX_CAP_DATA / sizeof(TPMS_AC_OUTPUT))\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CertifyCreation_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CertifyCreation_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CERTIFYCREATION_FP_H\n#define CERTIFYCREATION_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tsignHandle;\n    TPMI_DH_OBJECT\tobjectHandle;\n    TPM2B_DATA\t\tqualifyingData;\n    TPM2B_DIGEST\tcreationHash;\n    TPMT_SIG_SCHEME\tinScheme;\n    TPMT_TK_CREATION\tcreationTicket;\n} CertifyCreation_In;\n\n#define RC_CertifyCreation_signHandle \t\t(TPM_RC_H + TPM_RC_1)\n#define RC_CertifyCreation_objectHandle\t\t(TPM_RC_H + TPM_RC_2)\n#define RC_CertifyCreation_qualifyingData\t(TPM_RC_P + TPM_RC_1)\n#define RC_CertifyCreation_creationHash\t\t(TPM_RC_P + TPM_RC_2)\n#define RC_CertifyCreation_inScheme \t\t(TPM_RC_P + TPM_RC_3)\n#define RC_CertifyCreation_creationTicket \t(TPM_RC_P + TPM_RC_4)\n\ntypedef struct {\n    TPM2B_ATTEST\tcertifyInfo;\n    TPMT_SIGNATURE\tsignature;\n} CertifyCreation_Out;\n\nTPM_RC\nTPM2_CertifyCreation(\n\t\t     CertifyCreation_In      *in,            // IN: input parameter list\n\t\t     CertifyCreation_Out     *out            // OUT: output parameter list\n\t\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CertifyX509_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tTPM2_CertifyX509 Command Header\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CertifyX509_fp.h 1519 2019-11-15 20:43:51Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 155 */\n\n#ifndef CERTIFYX509_FP_H\n#define CERTIFYX509_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tobjectHandle;\n    TPMI_DH_OBJECT\tsignHandle;\n    TPM2B_DATA\t\treserved;\n    TPMT_SIG_SCHEME\tinScheme;\n    TPM2B_MAX_BUFFER\tpartialCertificate;\n} CertifyX509_In;\n\n#define RC_CertifyX509_signHandle\t\t(TPM_RC_H + TPM_RC_1)\n#define RC_CertifyX509_objectHandle \t\t(TPM_RC_H + TPM_RC_2)\n#define RC_CertifyX509_reserved\t\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_CertifyX509_inScheme\t\t\t(TPM_RC_P + TPM_RC_2)\n#define RC_CertifyX509_partialCertificate\t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPM2B_MAX_BUFFER\taddedToCertificate;\n    TPM2B_DIGEST\ttbsDigest;\n    TPMT_SIGNATURE\tsignature;\n} CertifyX509_Out;\n\nTPM_RC\nTPM2_CertifyX509(\n\t     CertifyX509_In      *in,            // IN: input parameter list\n\t     CertifyX509_Out     *out            // OUT: output parameter list\n\t     );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Certify_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Certify_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CERTIFY_FP_H\n#define CERTIFY_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tobjectHandle;\n    TPMI_DH_OBJECT\tsignHandle;\n    TPM2B_DATA\t\tqualifyingData;\n    TPMT_SIG_SCHEME\tinScheme;\n} Certify_In;\n\n#define RC_Certify_objectHandle\t\t(TPM_RC_H + TPM_RC_1)\n#define RC_Certify_signHandle \t\t(TPM_RC_H + TPM_RC_2)\n#define RC_Certify_qualifyingData\t(TPM_RC_P + TPM_RC_1)\n#define RC_Certify_inScheme \t\t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM2B_ATTEST\tcertifyInfo;\n    TPMT_SIGNATURE\tsignature;\n} Certify_Out;\n\n\n\nTPM_RC\nTPM2_Certify(\n\t     Certify_In      *in,            // IN: input parameter list\n\t     Certify_Out     *out            // OUT: output parameter list\n\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ChangeEPS_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ChangeEPS_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CHANGEEPS_FP_H\n#define CHANGEEPS_FP_H\n\ntypedef struct {\n    TPMI_RH_PLATFORM\tauthHandle;\n} ChangeEPS_In;\n\n#define RC_ChangeEPS_authHandle\t(TPM_RC_H + TPM_RC_1)\n\nTPM_RC\nTPM2_ChangeEPS(\n\t       ChangeEPS_In    *in             // IN: input parameter list\n\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ChangePPS_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ChangePPS_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CHANGEPPS_FP_H\n#define CHANGEPPS_FP_H\n\ntypedef struct {\n    TPMI_RH_PLATFORM\tauthHandle;\n} ChangePPS_In;\n\n#define RC_ChangePPS_authHandle\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_ChangePPS(\n\t       ChangePPS_In    *in             // IN: input parameter list\n\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ClearControl_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ClearControl_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CLEARCONTROL_FP_H\n#define CLEARCONTROL_FP_H\n\ntypedef struct {\n    TPMI_RH_CLEAR\tauth;\n    TPMI_YES_NO\t\tdisable;\n} ClearControl_In;\n\n#define RC_ClearControl_auth\t(TPM_RC_H + TPM_RC_1)\n#define RC_ClearControl_disable\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_ClearControl(\n\t\t  ClearControl_In     *in             // IN: input parameter list\n\t\t  );\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Clear_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Clear_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CLEAR_FP_H\n#define CLEAR_FP_H\n\ntypedef struct {\n    TPMI_RH_CLEAR\tauthHandle;\n} Clear_In;\n\n#define RC_Clear_authHandle\t(TPM_RC_H + TPM_RC_1)\n\nTPM_RC\nTPM2_Clear(\n\t   Clear_In        *in             // IN: input parameter list\n\t   );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ClockRateAdjust_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ClockRateAdjust_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CLOCKRATEADJUST_FP_H\n#define CLOCKRATEADJUST_FP_H\n\ntypedef struct {\n    TPMI_RH_PROVISION\tauth;\n    TPM_CLOCK_ADJUST\trateAdjust;\n} ClockRateAdjust_In;\n\n#define RC_ClockRateAdjust_auth\t\t(TPM_RC_H + TPM_RC_1)\n#define RC_ClockRateAdjust_rateAdjust\t(TPM_RC_P + TPM_RC_1)\n\n\nTPM_RC\nTPM2_ClockRateAdjust(\n\t\t     ClockRateAdjust_In  *in             // IN: input parameter list\n\t\t     );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ClockSet_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ClockSet_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CLOCKSET_FP_H\n#define CLOCKSET_FP_H\n\ntypedef struct {\n    TPMI_RH_PROVISION\tauth;\n    UINT64\t\tnewTime;\n} ClockSet_In;\n\n#define RC_ClockSet_auth\t(TPM_RC_H + TPM_RC_1)\n#define RC_ClockSet_newTime\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_ClockSet(\n\t      ClockSet_In     *in             // IN: input parameter list\n\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CommandAttributeData.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tCommand code attribute array for GetCapability\t    \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 5.6\tCommandAttributeData.h */\n/* This file should only be included by CommandCodeAttibutes.c */\n\n#ifdef _COMMAND_CODE_ATTRIBUTES_\n#include \"CommandAttributes.h\"\n#if COMPRESSED_LISTS\n#   define      PAD_LIST    0\n#else\n#   define      PAD_LIST    1\n#endif\n\n/* This is the command code attribute array for GetCapability(). Both this array and\n   s_commandAttributes provides command code attributes, but tuned for different purpose */\n\nconst TPMA_CC    s_ccAttr [] = {\n#if (PAD_LIST  || CC_NV_UndefineSpaceSpecial)\n    TPMA_CC_INITIALIZER(0x011f, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_EvictControl)\n    TPMA_CC_INITIALIZER(0x0120, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_HierarchyControl)\n    TPMA_CC_INITIALIZER(0x0121, 0, 1, 1, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_UndefineSpace)\n    TPMA_CC_INITIALIZER(0x0122, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST )\n    TPMA_CC_INITIALIZER(0x0123, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ChangeEPS)\n    TPMA_CC_INITIALIZER(0x0124, 0, 1, 1, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ChangePPS)\n    TPMA_CC_INITIALIZER(0x0125, 0, 1, 1, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Clear)\n    TPMA_CC_INITIALIZER(0x0126, 0, 1, 1, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ClearControl)\n    TPMA_CC_INITIALIZER(0x0127, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ClockSet)\n    TPMA_CC_INITIALIZER(0x0128, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_HierarchyChangeAuth)\n    TPMA_CC_INITIALIZER(0x0129, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_DefineSpace)\n    TPMA_CC_INITIALIZER(0x012a, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PCR_Allocate)\n    TPMA_CC_INITIALIZER(0x012b, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PCR_SetAuthPolicy)\n    TPMA_CC_INITIALIZER(0x012c, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PP_Commands)\n    TPMA_CC_INITIALIZER(0x012d, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_SetPrimaryPolicy)\n    TPMA_CC_INITIALIZER(0x012e, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_FieldUpgradeStart)\n    TPMA_CC_INITIALIZER(0x012f, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ClockRateAdjust)\n    TPMA_CC_INITIALIZER(0x0130, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_CreatePrimary)\n    TPMA_CC_INITIALIZER(0x0131, 0, 0, 0, 0, 1, 1, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_GlobalWriteLock)\n    TPMA_CC_INITIALIZER(0x0132, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_GetCommandAuditDigest)\n    TPMA_CC_INITIALIZER(0x0133, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_Increment)\n    TPMA_CC_INITIALIZER(0x0134, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_SetBits)\n    TPMA_CC_INITIALIZER(0x0135, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_Extend)\n    TPMA_CC_INITIALIZER(0x0136, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_Write)\n    TPMA_CC_INITIALIZER(0x0137, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_WriteLock)\n    TPMA_CC_INITIALIZER(0x0138, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_DictionaryAttackLockReset)\n    TPMA_CC_INITIALIZER(0x0139, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_DictionaryAttackParameters)\n    TPMA_CC_INITIALIZER(0x013a, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_ChangeAuth)\n    TPMA_CC_INITIALIZER(0x013b, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PCR_Event)\n    TPMA_CC_INITIALIZER(0x013c, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PCR_Reset)\n    TPMA_CC_INITIALIZER(0x013d, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_SequenceComplete)\n    TPMA_CC_INITIALIZER(0x013e, 0, 0, 0, 1, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_SetAlgorithmSet)\n    TPMA_CC_INITIALIZER(0x013f, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_SetCommandCodeAuditStatus)\n    TPMA_CC_INITIALIZER(0x0140, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_FieldUpgradeData)\n    TPMA_CC_INITIALIZER(0x0141, 0, 1, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_IncrementalSelfTest)\n    TPMA_CC_INITIALIZER(0x0142, 0, 1, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_SelfTest)\n    TPMA_CC_INITIALIZER(0x0143, 0, 1, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Startup)\n    TPMA_CC_INITIALIZER(0x0144, 0, 1, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Shutdown)\n    TPMA_CC_INITIALIZER(0x0145, 0, 1, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_StirRandom)\n    TPMA_CC_INITIALIZER(0x0146, 0, 1, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ActivateCredential)\n    TPMA_CC_INITIALIZER(0x0147, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Certify)\n    TPMA_CC_INITIALIZER(0x0148, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyNV)\n    TPMA_CC_INITIALIZER(0x0149, 0, 0, 0, 0, 3, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_CertifyCreation)\n    TPMA_CC_INITIALIZER(0x014a, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Duplicate)\n    TPMA_CC_INITIALIZER(0x014b, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_GetTime)\n    TPMA_CC_INITIALIZER(0x014c, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_GetSessionAuditDigest)\n    TPMA_CC_INITIALIZER(0x014d, 0, 0, 0, 0, 3, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_Read)\n    TPMA_CC_INITIALIZER(0x014e, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_ReadLock)\n    TPMA_CC_INITIALIZER(0x014f, 0, 1, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ObjectChangeAuth)\n    TPMA_CC_INITIALIZER(0x0150, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicySecret)\n    TPMA_CC_INITIALIZER(0x0151, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Rewrap)\n    TPMA_CC_INITIALIZER(0x0152, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Create)\n    TPMA_CC_INITIALIZER(0x0153, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ECDH_ZGen)\n    TPMA_CC_INITIALIZER(0x0154, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || (CC_HMAC || CC_MAC))\n    TPMA_CC_INITIALIZER(0x0155, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Import)\n    TPMA_CC_INITIALIZER(0x0156, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Load)\n    TPMA_CC_INITIALIZER(0x0157, 0, 0, 0, 0, 1, 1, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Quote)\n    TPMA_CC_INITIALIZER(0x0158, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_RSA_Decrypt)\n    TPMA_CC_INITIALIZER(0x0159, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST )\n    TPMA_CC_INITIALIZER(0x015a, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || (CC_HMAC_Start || CC_MAC_Start))\n    TPMA_CC_INITIALIZER(0x015b, 0, 0, 0, 0, 1, 1, 0, 0),\n#endif\n#if (PAD_LIST  || CC_SequenceUpdate)\n    TPMA_CC_INITIALIZER(0x015c, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Sign)\n    TPMA_CC_INITIALIZER(0x015d, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Unseal)\n    TPMA_CC_INITIALIZER(0x015e, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST )\n    TPMA_CC_INITIALIZER(0x015f, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicySigned)\n    TPMA_CC_INITIALIZER(0x0160, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ContextLoad)\n    TPMA_CC_INITIALIZER(0x0161, 0, 0, 0, 0, 0, 1, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ContextSave)\n    TPMA_CC_INITIALIZER(0x0162, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ECDH_KeyGen)\n    TPMA_CC_INITIALIZER(0x0163, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_EncryptDecrypt)\n    TPMA_CC_INITIALIZER(0x0164, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_FlushContext)\n    TPMA_CC_INITIALIZER(0x0165, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST )\n    TPMA_CC_INITIALIZER(0x0166, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_LoadExternal)\n    TPMA_CC_INITIALIZER(0x0167, 0, 0, 0, 0, 0, 1, 0, 0),\n#endif\n#if (PAD_LIST  || CC_MakeCredential)\n    TPMA_CC_INITIALIZER(0x0168, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_ReadPublic)\n    TPMA_CC_INITIALIZER(0x0169, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyAuthorize)\n    TPMA_CC_INITIALIZER(0x016a, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyAuthValue)\n    TPMA_CC_INITIALIZER(0x016b, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyCommandCode)\n    TPMA_CC_INITIALIZER(0x016c, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyCounterTimer)\n    TPMA_CC_INITIALIZER(0x016d, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyCpHash)\n    TPMA_CC_INITIALIZER(0x016e, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyLocality)\n    TPMA_CC_INITIALIZER(0x016f, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyNameHash)\n    TPMA_CC_INITIALIZER(0x0170, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyOR)\n    TPMA_CC_INITIALIZER(0x0171, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyTicket)\n    TPMA_CC_INITIALIZER(0x0172, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ReadPublic)\n    TPMA_CC_INITIALIZER(0x0173, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_RSA_Encrypt)\n    TPMA_CC_INITIALIZER(0x0174, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST )\n    TPMA_CC_INITIALIZER(0x0175, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_StartAuthSession)\n    TPMA_CC_INITIALIZER(0x0176, 0, 0, 0, 0, 2, 1, 0, 0),\n#endif\n#if (PAD_LIST  || CC_VerifySignature)\n    TPMA_CC_INITIALIZER(0x0177, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ECC_Parameters)\n    TPMA_CC_INITIALIZER(0x0178, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_FirmwareRead)\n    TPMA_CC_INITIALIZER(0x0179, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_GetCapability)\n    TPMA_CC_INITIALIZER(0x017a, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_GetRandom)\n    TPMA_CC_INITIALIZER(0x017b, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_GetTestResult)\n    TPMA_CC_INITIALIZER(0x017c, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Hash)\n    TPMA_CC_INITIALIZER(0x017d, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PCR_Read)\n    TPMA_CC_INITIALIZER(0x017e, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyPCR)\n    TPMA_CC_INITIALIZER(0x017f, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyRestart)\n    TPMA_CC_INITIALIZER(0x0180, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ReadClock)\n    TPMA_CC_INITIALIZER(0x0181, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PCR_Extend)\n    TPMA_CC_INITIALIZER(0x0182, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PCR_SetAuthValue)\n    TPMA_CC_INITIALIZER(0x0183, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_NV_Certify)\n    TPMA_CC_INITIALIZER(0x0184, 0, 0, 0, 0, 3, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_EventSequenceComplete)\n    TPMA_CC_INITIALIZER(0x0185, 0, 1, 0, 1, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_HashSequenceStart)\n    TPMA_CC_INITIALIZER(0x0186, 0, 0, 0, 0, 0, 1, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyPhysicalPresence)\n    TPMA_CC_INITIALIZER(0x0187, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyDuplicationSelect)\n    TPMA_CC_INITIALIZER(0x0188, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyGetDigest)\n    TPMA_CC_INITIALIZER(0x0189, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_TestParms)\n    TPMA_CC_INITIALIZER(0x018a, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Commit)\n    TPMA_CC_INITIALIZER(0x018b, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyPassword)\n    TPMA_CC_INITIALIZER(0x018c, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_ZGen_2Phase)\n    TPMA_CC_INITIALIZER(0x018d, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_EC_Ephemeral)\n    TPMA_CC_INITIALIZER(0x018e, 0, 0, 0, 0, 0, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyNvWritten)\n    TPMA_CC_INITIALIZER(0x018f, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyTemplate)\n    TPMA_CC_INITIALIZER(0x0190, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_CreateLoaded)\n    TPMA_CC_INITIALIZER(0x0191, 0, 0, 0, 0, 1, 1, 0, 0),\n#endif\n#if (PAD_LIST  || CC_PolicyAuthorizeNV)\n    TPMA_CC_INITIALIZER(0x0192, 0, 0, 0, 0, 3, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_EncryptDecrypt2)\n    TPMA_CC_INITIALIZER(0x0193, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_AC_GetCapability)\n    TPMA_CC_INITIALIZER(0x0194, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_AC_Send)\n    TPMA_CC_INITIALIZER(0x0195, 0, 0, 0, 0, 3, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Policy_AC_SendSelect)\n    TPMA_CC_INITIALIZER(0x0196, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST || CC_CertifyX509)\n    TPMA_CC_INITIALIZER(0x0197, 0, 0, 0, 0, 2, 0, 0, 0),\n#endif\n#if (PAD_LIST || CC_ACT_SetTimeout)\n    TPMA_CC_INITIALIZER(0x0198, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST || CC_ECC_Encrypt)\n    TPMA_CC_INITIALIZER(0x0199, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST || CC_ECC_Decrypt)\n    TPMA_CC_INITIALIZER(0x019A, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST || CC_PolicyCapability)\n    TPMA_CC_INITIALIZER(0x019B, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST || CC_PolicyParameters)\n    TPMA_CC_INITIALIZER(0x019C, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST || CC_NV_DefineSpace2)\n    TPMA_CC_INITIALIZER(0x019D, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST || CC_NV_ReadPublic2)\n    TPMA_CC_INITIALIZER(0x019E, 0, 0, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST || CC_SetCapability)\n    TPMA_CC_INITIALIZER(0x019F, 0, 1, 0, 0, 1, 0, 0, 0),\n#endif\n#if (PAD_LIST  || CC_Vendor_TCG_Test)\n    TPMA_CC_INITIALIZER(0x0000, 0, 0, 0, 0, 0, 0, 1, 0),\n#endif\n\n#ifdef TPM_NUVOTON\n    \n#if (PAD_LIST || CC_NTC2_PreConfig)\n    TPMA_CC_INITIALIZER(0x0211, 0, 1, 0, 0, 0, 0, 1, 0),     // TPM_CC_NTC2_PreConfig\n#endif\n#if (PAD_LIST || CC_NTC2_LockPreConfig)\n    TPMA_CC_INITIALIZER(0x0212, 0, 1, 0, 0, 0, 0, 1, 0),     // TPM_CC_NTC2_LockPreConfig\n#endif\n#if (PAD_LIST || CC_NTC2_GetConfig)\n    TPMA_CC_INITIALIZER(0x0213, 0, 1, 0, 0, 0, 0, 1, 0),     // TPM_CC_NTC2_GetConfig\n#endif\n\n#endif\t/* TPM_NUVOTON */\n\n    TPMA_ZERO_INITIALIZER()\n};\n\n/* This is the command code attribute structure. */\n\nconst COMMAND_ATTRIBUTES    s_commandAttributes [] = {\n#if (PAD_LIST  || CC_NV_UndefineSpaceSpecial)\n    (COMMAND_ATTRIBUTES)(CC_NV_UndefineSpaceSpecial     *  // 0x011f\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_ADMIN+HANDLE_2_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_EvictControl)\n    (COMMAND_ATTRIBUTES)(CC_EvictControl                *  // 0x0120\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_HierarchyControl)\n    (COMMAND_ATTRIBUTES)(CC_HierarchyControl            *  // 0x0121\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_NV_UndefineSpace)\n    (COMMAND_ATTRIBUTES)(CC_NV_UndefineSpace            *  // 0x0122\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST )\n    (COMMAND_ATTRIBUTES)(0),                               // 0x0123\n#endif\n#if (PAD_LIST  || CC_ChangeEPS)\n    (COMMAND_ATTRIBUTES)(CC_ChangeEPS                   *  // 0x0124\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_ChangePPS)\n    (COMMAND_ATTRIBUTES)(CC_ChangePPS                   *  // 0x0125\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_Clear)\n    (COMMAND_ATTRIBUTES)(CC_Clear                       *  // 0x0126\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_ClearControl)\n    (COMMAND_ATTRIBUTES)(CC_ClearControl                *  // 0x0127\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_ClockSet)\n    (COMMAND_ATTRIBUTES)(CC_ClockSet                    *  // 0x0128\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_HierarchyChangeAuth)\n    (COMMAND_ATTRIBUTES)(CC_HierarchyChangeAuth         *  // 0x0129\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_NV_DefineSpace)\n    (COMMAND_ATTRIBUTES)(CC_NV_DefineSpace              *  // 0x012a\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_PCR_Allocate)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Allocate                *  // 0x012b\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_PCR_SetAuthPolicy)\n    (COMMAND_ATTRIBUTES)(CC_PCR_SetAuthPolicy           *  // 0x012c\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_PP_Commands)\n    (COMMAND_ATTRIBUTES)(CC_PP_Commands                 *  // 0x012d\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_REQUIRED)),\n#endif\n#if (PAD_LIST  || CC_SetPrimaryPolicy)\n    (COMMAND_ATTRIBUTES)(CC_SetPrimaryPolicy            *  // 0x012e\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_FieldUpgradeStart)\n    (COMMAND_ATTRIBUTES)(CC_FieldUpgradeStart           *  // 0x012f\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_ClockRateAdjust)\n    (COMMAND_ATTRIBUTES)(CC_ClockRateAdjust             *  // 0x0130\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_CreatePrimary)\n    (COMMAND_ATTRIBUTES)(CC_CreatePrimary               *  // 0x0131\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST  || CC_NV_GlobalWriteLock)\n    (COMMAND_ATTRIBUTES)(CC_NV_GlobalWriteLock          *  // 0x0132\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_GetCommandAuditDigest)\n    (COMMAND_ATTRIBUTES)(CC_GetCommandAuditDigest       *  // 0x0133\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_NV_Increment)\n    (COMMAND_ATTRIBUTES)(CC_NV_Increment                *  // 0x0134\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_NV_SetBits)\n    (COMMAND_ATTRIBUTES)(CC_NV_SetBits                  *  // 0x0135\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_NV_Extend)\n    (COMMAND_ATTRIBUTES)(CC_NV_Extend                   *  // 0x0136\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_NV_Write)\n    (COMMAND_ATTRIBUTES)(CC_NV_Write                    *  // 0x0137\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_NV_WriteLock)\n    (COMMAND_ATTRIBUTES)(CC_NV_WriteLock                *  // 0x0138\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_DictionaryAttackLockReset)\n    (COMMAND_ATTRIBUTES)(CC_DictionaryAttackLockReset   *  // 0x0139\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_DictionaryAttackParameters)\n    (COMMAND_ATTRIBUTES)(CC_DictionaryAttackParameters  *  // 0x013a\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_NV_ChangeAuth)\n    (COMMAND_ATTRIBUTES)(CC_NV_ChangeAuth               *  // 0x013b\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN)),\n#endif\n#if (PAD_LIST  || CC_PCR_Event)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Event                   *  // 0x013c\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_PCR_Reset)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Reset                   *  // 0x013d\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_SequenceComplete)\n    (COMMAND_ATTRIBUTES)(CC_SequenceComplete            *  // 0x013e\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_SetAlgorithmSet)\n    (COMMAND_ATTRIBUTES)(CC_SetAlgorithmSet             *  // 0x013f\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_SetCommandCodeAuditStatus)\n    (COMMAND_ATTRIBUTES)(CC_SetCommandCodeAuditStatus   *  // 0x0140\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST  || CC_FieldUpgradeData)\n    (COMMAND_ATTRIBUTES)(CC_FieldUpgradeData            *  // 0x0141\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_IncrementalSelfTest)\n    (COMMAND_ATTRIBUTES)(CC_IncrementalSelfTest         *  // 0x0142\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST  || CC_SelfTest)\n    (COMMAND_ATTRIBUTES)(CC_SelfTest                    *  // 0x0143\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST  || CC_Startup)\n    (COMMAND_ATTRIBUTES)(CC_Startup                     *  // 0x0144\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST  || CC_Shutdown)\n    (COMMAND_ATTRIBUTES)(CC_Shutdown                    *  // 0x0145\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST  || CC_StirRandom)\n    (COMMAND_ATTRIBUTES)(CC_StirRandom                  *  // 0x0146\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_ActivateCredential)\n    (COMMAND_ATTRIBUTES)(CC_ActivateCredential          *  // 0x0147\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_Certify)\n    (COMMAND_ATTRIBUTES)(CC_Certify                     *  // 0x0148\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_PolicyNV)\n    (COMMAND_ATTRIBUTES)(CC_PolicyNV                    *  // 0x0149\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_CertifyCreation)\n    (COMMAND_ATTRIBUTES)(CC_CertifyCreation             *  // 0x014a\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_Duplicate)\n    (COMMAND_ATTRIBUTES)(CC_Duplicate                   *  // 0x014b\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_DUP+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_GetTime)\n    (COMMAND_ATTRIBUTES)(CC_GetTime                     *  // 0x014c\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_GetSessionAuditDigest)\n    (COMMAND_ATTRIBUTES)(CC_GetSessionAuditDigest       *  // 0x014d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_NV_Read)\n    (COMMAND_ATTRIBUTES)(CC_NV_Read                     *  // 0x014e\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_NV_ReadLock)\n    (COMMAND_ATTRIBUTES)(CC_NV_ReadLock                 *  // 0x014f\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_ObjectChangeAuth)\n    (COMMAND_ATTRIBUTES)(CC_ObjectChangeAuth            *  // 0x0150\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_PolicySecret)\n    (COMMAND_ATTRIBUTES)(CC_PolicySecret                *  // 0x0151\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_Rewrap)\n    (COMMAND_ATTRIBUTES)(CC_Rewrap                      *  // 0x0152\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_Create)\n    (COMMAND_ATTRIBUTES)(CC_Create                      *  // 0x0153\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_ECDH_ZGen)\n    (COMMAND_ATTRIBUTES)(CC_ECDH_ZGen                   *  // 0x0154\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || (CC_HMAC || CC_MAC))\n    (COMMAND_ATTRIBUTES)((CC_HMAC || CC_MAC)            *  // 0x0155\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_Import)\n    (COMMAND_ATTRIBUTES)(CC_Import                      *  // 0x0156\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_Load)\n    (COMMAND_ATTRIBUTES)(CC_Load                        *  // 0x0157\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST  || CC_Quote)\n    (COMMAND_ATTRIBUTES)(CC_Quote                       *  // 0x0158\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_RSA_Decrypt)\n    (COMMAND_ATTRIBUTES)(CC_RSA_Decrypt                 *  // 0x0159\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST )\n    (COMMAND_ATTRIBUTES)(0),                               // 0x015a\n#endif\n#if (PAD_LIST  || (CC_HMAC_Start || CC_MAC_Start))\n    (COMMAND_ATTRIBUTES)((CC_HMAC_Start || CC_MAC_Start) *  // 0x015b\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+R_HANDLE)),\n#endif\n#if (PAD_LIST  || CC_SequenceUpdate)\n    (COMMAND_ATTRIBUTES)(CC_SequenceUpdate              *  // 0x015c\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_Sign)\n    (COMMAND_ATTRIBUTES)(CC_Sign                        *  // 0x015d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_Unseal)\n    (COMMAND_ATTRIBUTES)(CC_Unseal                      *  // 0x015e\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST )\n    (COMMAND_ATTRIBUTES)(0),                               // 0x015f\n#endif\n#if (PAD_LIST  || CC_PolicySigned)\n    (COMMAND_ATTRIBUTES)(CC_PolicySigned                *  // 0x0160\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_ContextLoad)\n    (COMMAND_ATTRIBUTES)(CC_ContextLoad                 *  // 0x0161\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS+R_HANDLE)),\n#endif\n#if (PAD_LIST  || CC_ContextSave)\n    (COMMAND_ATTRIBUTES)(CC_ContextSave                 *  // 0x0162\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST  || CC_ECDH_KeyGen)\n    (COMMAND_ATTRIBUTES)(CC_ECDH_KeyGen                 *  // 0x0163\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_EncryptDecrypt)\n    (COMMAND_ATTRIBUTES)(CC_EncryptDecrypt              *  // 0x0164\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_FlushContext)\n    (COMMAND_ATTRIBUTES)(CC_FlushContext                *  // 0x0165\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST )\n    (COMMAND_ATTRIBUTES)(0),                               // 0x0166\n#endif\n#if (PAD_LIST  || CC_LoadExternal)\n    (COMMAND_ATTRIBUTES)(CC_LoadExternal                *  // 0x0167\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST  || CC_MakeCredential)\n    (COMMAND_ATTRIBUTES)(CC_MakeCredential              *  // 0x0168\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_NV_ReadPublic)\n    (COMMAND_ATTRIBUTES)(CC_NV_ReadPublic               *  // 0x0169\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_PolicyAuthorize)\n    (COMMAND_ATTRIBUTES)(CC_PolicyAuthorize             *  // 0x016a\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyAuthValue)\n    (COMMAND_ATTRIBUTES)(CC_PolicyAuthValue             *  // 0x016b\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyCommandCode)\n    (COMMAND_ATTRIBUTES)(CC_PolicyCommandCode           *  // 0x016c\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyCounterTimer)\n    (COMMAND_ATTRIBUTES)(CC_PolicyCounterTimer          *  // 0x016d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyCpHash)\n    (COMMAND_ATTRIBUTES)(CC_PolicyCpHash                *  // 0x016e\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyLocality)\n    (COMMAND_ATTRIBUTES)(CC_PolicyLocality              *  // 0x016f\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyNameHash)\n    (COMMAND_ATTRIBUTES)(CC_PolicyNameHash              *  // 0x0170\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyOR)\n    (COMMAND_ATTRIBUTES)(CC_PolicyOR                    *  // 0x0171\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyTicket)\n    (COMMAND_ATTRIBUTES)(CC_PolicyTicket                *  // 0x0172\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_ReadPublic)\n    (COMMAND_ATTRIBUTES)(CC_ReadPublic                  *  // 0x0173\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_RSA_Encrypt)\n    (COMMAND_ATTRIBUTES)(CC_RSA_Encrypt                 *  // 0x0174\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n#if (PAD_LIST )\n    (COMMAND_ATTRIBUTES)(0),                               // 0x0175\n#endif\n#if (PAD_LIST  || CC_StartAuthSession)\n    (COMMAND_ATTRIBUTES)(CC_StartAuthSession            *  // 0x0176\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST  || CC_VerifySignature)\n    (COMMAND_ATTRIBUTES)(CC_VerifySignature             *  // 0x0177\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_ECC_Parameters)\n    (COMMAND_ATTRIBUTES)(CC_ECC_Parameters              *  // 0x0178\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST  || CC_FirmwareRead)\n    (COMMAND_ATTRIBUTES)(CC_FirmwareRead                *  // 0x0179\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_GetCapability)\n    (COMMAND_ATTRIBUTES)(CC_GetCapability               *  // 0x017a\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST  || CC_GetRandom)\n    (COMMAND_ATTRIBUTES)(CC_GetRandom                   *  // 0x017b\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_GetTestResult)\n    (COMMAND_ATTRIBUTES)(CC_GetTestResult               *  // 0x017c\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_Hash)\n    (COMMAND_ATTRIBUTES)(CC_Hash                        *  // 0x017d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_PCR_Read)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Read                    *  // 0x017e\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST  || CC_PolicyPCR)\n    (COMMAND_ATTRIBUTES)(CC_PolicyPCR                   *  // 0x017f\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyRestart)\n    (COMMAND_ATTRIBUTES)(CC_PolicyRestart               *  // 0x0180\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_ReadClock)\n    (COMMAND_ATTRIBUTES)(CC_ReadClock                   *  // 0x0181\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST  || CC_PCR_Extend)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Extend                  *  // 0x0182\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_PCR_SetAuthValue)\n    (COMMAND_ATTRIBUTES)(CC_PCR_SetAuthValue            *  // 0x0183\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_NV_Certify)\n    (COMMAND_ATTRIBUTES)(CC_NV_Certify                  *  // 0x0184\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_EventSequenceComplete)\n    (COMMAND_ATTRIBUTES)(CC_EventSequenceComplete       *  // 0x0185\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER)),\n#endif\n#if (PAD_LIST  || CC_HashSequenceStart)\n    (COMMAND_ATTRIBUTES)(CC_HashSequenceStart           *  // 0x0186\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST  || CC_PolicyPhysicalPresence)\n    (COMMAND_ATTRIBUTES)(CC_PolicyPhysicalPresence      *  // 0x0187\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyDuplicationSelect)\n    (COMMAND_ATTRIBUTES)(CC_PolicyDuplicationSelect     *  // 0x0188\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyGetDigest)\n    (COMMAND_ATTRIBUTES)(CC_PolicyGetDigest             *  // 0x0189\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_TestParms)\n    (COMMAND_ATTRIBUTES)(CC_TestParms                   *  // 0x018a\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST  || CC_Commit)\n    (COMMAND_ATTRIBUTES)(CC_Commit                      *  // 0x018b\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_PolicyPassword)\n    (COMMAND_ATTRIBUTES)(CC_PolicyPassword              *  // 0x018c\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_ZGen_2Phase)\n    (COMMAND_ATTRIBUTES)(CC_ZGen_2Phase                 *  // 0x018d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_EC_Ephemeral)\n    (COMMAND_ATTRIBUTES)(CC_EC_Ephemeral                *  // 0x018e\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_PolicyNvWritten)\n    (COMMAND_ATTRIBUTES)(CC_PolicyNvWritten             *  // 0x018f\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_PolicyTemplate)\n    (COMMAND_ATTRIBUTES)(CC_PolicyTemplate              *  // 0x0190\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_CreateLoaded)\n    (COMMAND_ATTRIBUTES)(CC_CreateLoaded                *  // 0x0191\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST  || CC_PolicyAuthorizeNV)\n    (COMMAND_ATTRIBUTES)(CC_PolicyAuthorizeNV           *  // 0x0192\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST  || CC_EncryptDecrypt2)\n    (COMMAND_ATTRIBUTES)(CC_EncryptDecrypt2             *  // 0x0193\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST  || CC_AC_GetCapability)\n    (COMMAND_ATTRIBUTES)(CC_AC_GetCapability            *  // 0x0194\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST  || CC_AC_Send)\n    (COMMAND_ATTRIBUTES)(CC_AC_Send                     *  // 0x0195\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_DUP+HANDLE_2_USER)),\n#endif\n#if (PAD_LIST  || CC_Policy_AC_SendSelect)\n    (COMMAND_ATTRIBUTES)(CC_Policy_AC_SendSelect        *  // 0x0196\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_CertifyX509)\n    (COMMAND_ATTRIBUTES)(CC_CertifyX509                 *  // 0x0197\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_ACT_SetTimeout)\n    (COMMAND_ATTRIBUTES)(CC_ACT_SetTimeout              *  // 0x0198\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_ECC_Encrypt)\n    (COMMAND_ATTRIBUTES)(CC_ECC_Encrypt                 *  // 0x0199\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_ECC_Decrypt)\n    (COMMAND_ATTRIBUTES)(CC_ECC_Decrypt                 *  // 0x019A\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_PolicyCapability)\n    (COMMAND_ATTRIBUTES)(CC_PolicyCapability *   \t // 0x019B\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyParameters)\n    (COMMAND_ATTRIBUTES)(CC_PolicyParameters *  \t// 0x019C\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_NV_DefineSpace2)\n    (COMMAND_ATTRIBUTES)(CC_NV_DefineSpace2 * \t\t// 0x019D\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_NV_ReadPublic2)\n    (COMMAND_ATTRIBUTES)(CC_NV_ReadPublic2 * \t\t// 0x019E\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_SetCapability)\n    (COMMAND_ATTRIBUTES)(CC_SetCapability * \t\t// 0x019F\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST  || CC_Vendor_TCG_Test)\n    (COMMAND_ATTRIBUTES)(CC_Vendor_TCG_Test          *  // 0x0000\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n\n#ifdef TPM_NUVOTON\n#if (PAD_LIST  || CC_NTC2_PreConfig)\n    (COMMAND_ATTRIBUTES)(CC_NTC2_PreConfig             *  // 0x20000211\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST  || CC_NTC2_LockPreConfig)\n    (COMMAND_ATTRIBUTES)(CC_NTC2_LockPreConfig         *  // 0x20000212\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST  || CC_NTC2_GetConfig)\n    (COMMAND_ATTRIBUTES)(CC_NTC2_GetConfig             *  // 0x20000213\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#endif\n    0\n};\n\n#endif  // _COMMAND_CODE_ATTRIBUTES_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CommandAttributes.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Command Attributes\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CommandAttributes.h 1594 2020-03-26 22:15:48Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef COMMANDATTRIBUTES_H\n#define COMMANDATTRIBUTES_H\n\n/* 5.7\tCommandAttributes.h */\n/* The attributes defined in this file are produced by the parser that creates the structure\n   definitions from Part 3. The attributes are defined in that parser and should track the\n   attributes being tested in CommandCodeAttributes.c. Generally, when an attribute is added to this\n   list, new code will be needed in CommandCodeAttributes.c to test it. */\n\ntypedef  UINT16             COMMAND_ATTRIBUTES;\n#define NOT_IMPLEMENTED     (COMMAND_ATTRIBUTES)(0)\n#define ENCRYPT_2           ((COMMAND_ATTRIBUTES)1 << 0)\n#define ENCRYPT_4           ((COMMAND_ATTRIBUTES)1 << 1)\n#define DECRYPT_2           ((COMMAND_ATTRIBUTES)1 << 2)\n#define DECRYPT_4           ((COMMAND_ATTRIBUTES)1 << 3)\n#define HANDLE_1_USER       ((COMMAND_ATTRIBUTES)1 << 4)\n#define HANDLE_1_ADMIN      ((COMMAND_ATTRIBUTES)1 << 5)\n#define HANDLE_1_DUP        ((COMMAND_ATTRIBUTES)1 << 6)\n#define HANDLE_2_USER       ((COMMAND_ATTRIBUTES)1 << 7)\n#define PP_COMMAND          ((COMMAND_ATTRIBUTES)1 << 8)\n#define IS_IMPLEMENTED      ((COMMAND_ATTRIBUTES)1 << 9)\n#define NO_SESSIONS         ((COMMAND_ATTRIBUTES)1 << 10)\n#define NV_COMMAND          ((COMMAND_ATTRIBUTES)1 << 11)\n#define PP_REQUIRED         ((COMMAND_ATTRIBUTES)1 << 12)\n#define R_HANDLE            ((COMMAND_ATTRIBUTES)1 << 13)\n#define ALLOW_TRIAL         ((COMMAND_ATTRIBUTES)1 << 14)\n#endif // COMMAND_ATTRIBUTES_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CommandAudit_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef COMMANDAUDIT_FP_H\n#define COMMANDAUDIT_FP_H\n\nvoid\nCommandAuditPreInstall_Init(\n\t\t\t    void\n\t\t\t    );\nBOOL\nCommandAuditStartup(\n\t\t    STARTUP_TYPE     type           // IN: start up type\n\t\t    );\nBOOL\nCommandAuditSet(\n\t\tTPM_CC           commandCode    // IN: command code\n\t\t);\nBOOL\nCommandAuditClear(\n\t\t  TPM_CC           commandCode    // IN: command code\n\t\t  );\nBOOL\nCommandAuditIsRequired(\n\t\t       COMMAND_INDEX    commandIndex   // IN: command index\n\t\t       );\nTPMI_YES_NO\nCommandAuditCapGetCCList(\n\t\t\t TPM_CC           commandCode,   // IN: start command code\n\t\t\t UINT32           count,         // IN: count of returned TPM_CC\n\t\t\t TPML_CC         *commandList    // OUT: list of TPM_CC\n\t\t\t );\nBOOL CommandAuditCapGetOneCC(TPM_CC commandCode  // IN: command code\n\t\t\t     );\nvoid\nCommandAuditGetDigest(\n\t\t      TPM2B_DIGEST    *digest         // OUT: command digest\n\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CommandCodeAttributes_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef COMMANDCODEATTRIBUTES_FP_H\n#define COMMANDCODEATTRIBUTES_FP_H\n\nCOMMAND_INDEX\nGetClosestCommandIndex(\n\t\t       TPM_CC           commandCode    // IN: the command code to start at\n\t\t       );\nCOMMAND_INDEX\nCommandCodeToCommandIndex(\n\t\t\t  TPM_CC           commandCode    // IN: the command code to look up\n\t\t\t  );\nCOMMAND_INDEX\nGetNextCommandIndex(\n\t\t    COMMAND_INDEX    commandIndex   // IN: the starting index\n\t\t    );\nTPM_CC\nGetCommandCode(\n\t       COMMAND_INDEX    commandIndex   // IN: the command index\n\t       );\nAUTH_ROLE\nCommandAuthRole(\n\t\tCOMMAND_INDEX    commandIndex,  // IN: command index\n\t\tUINT32           handleIndex    // IN: handle index (zero based)\n\t\t);\nint\nEncryptSize(\n\t    COMMAND_INDEX    commandIndex   // IN: command index\n\t    );\nint\nDecryptSize(\n\t    COMMAND_INDEX    commandIndex   // IN: command index\n\t    );\nBOOL\nIsSessionAllowed(\n\t\t COMMAND_INDEX    commandIndex   // IN: the command to be checked\n\t\t );\nBOOL\nIsHandleInResponse(\n\t\t   COMMAND_INDEX    commandIndex\n\t\t   );\nBOOL\nIsWriteOperation(\n\t\t COMMAND_INDEX    commandIndex   // IN: Command to check\n\t\t );\nBOOL\nIsReadOperation(\n\t\tCOMMAND_INDEX    commandIndex   // IN: Command to check\n\t\t);\nTPMI_YES_NO\nCommandCapGetCCList(\n\t\t    TPM_CC           commandCode,   // IN: start command code\n\t\t    UINT32           count,         // IN: maximum count for number of entries in\n\t\t    //     'commandList'\n\t\t    TPML_CCA        *commandList    // OUT: list of TPMA_CC\n\t\t    );\nBOOL CommandCapGetOneCC(TPM_CC   commandCode,       // IN: command code\n\t\t\tTPMA_CC* commandAttributes  // OUT: Command attributes\n\t\t\t);\nBOOL\nIsVendorCommand(\n\t\tCOMMAND_INDEX    commandIndex   // IN: command index to check\n\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CommandDispatchData.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Command DIspatch Data\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* This file should only be included by CommandCodeAttibutes.c */\n#ifdef _COMMAND_TABLE_DISPATCH_\n\n#define END_OF_LIST     0xff\n#define ADD_FLAG        0x80\n\n#ifdef TPM_NUVOTON\n#include \"ntc2_fp.h\"\n#include \"ntc2lib.h\"\n#endif\n\n/* These macros provide some variability in how the data is encoded. They also make the lines a\n   little shorter. ;-) */\n\n#if TABLE_DRIVEN_MARSHAL\n#   define UNMARSHAL_DISPATCH(name)   (marshalIndex_t)name##_MARSHAL_REF\n#   define MARSHAL_DISPATCH(name)     (marshalIndex_t)name##_MARSHAL_REF\n#   define _UNMARSHAL_T_    marshalIndex_t\n#   define _MARSHAL_T_      marshalIndex_t\n#\n#else\n#   define UNMARSHAL_DISPATCH(name)   (UNMARSHAL_t)name##_Unmarshal\n#   define MARSHAL_DISPATCH(name)     (MARSHAL_t)name##_Marshal\n#   define _UNMARSHAL_T_    UNMARSHAL_t\n#   define _MARSHAL_T_      MARSHAL_t\n#endif\n\nconst _UNMARSHAL_T_ unmarshalArray[] = {\n#define TPMI_DH_CONTEXT_H_UNMARSHAL             0\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_DH_CONTEXT),\n#define TPMI_RH_AC_H_UNMARSHAL                  (TPMI_DH_CONTEXT_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_AC),\n#define TPMI_RH_ACT_H_UNMARSHAL                 (TPMI_RH_AC_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_ACT),\n#define TPMI_RH_CLEAR_H_UNMARSHAL               (TPMI_RH_ACT_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_CLEAR),\n#define TPMI_RH_HIERARCHY_AUTH_H_UNMARSHAL      (TPMI_RH_CLEAR_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_HIERARCHY_AUTH),\n#define TPMI_RH_HIERARCHY_POLICY_H_UNMARSHAL\t\t\t\t\\\n\t\t\t\t\t(TPMI_RH_HIERARCHY_AUTH_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_HIERARCHY_POLICY),\n#define TPMI_RH_LOCKOUT_H_UNMARSHAL\t\t\t\t\t\\\n\t\t\t\t\t(TPMI_RH_HIERARCHY_POLICY_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_LOCKOUT),\n#define TPMI_RH_NV_AUTH_H_UNMARSHAL             (TPMI_RH_LOCKOUT_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_NV_AUTH),\n#define TPMI_RH_NV_INDEX_H_UNMARSHAL            (TPMI_RH_NV_AUTH_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_NV_INDEX),\n#define TPMI_RH_PLATFORM_H_UNMARSHAL            (TPMI_RH_NV_INDEX_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_PLATFORM),\n#define TPMI_RH_PROVISION_H_UNMARSHAL           (TPMI_RH_PLATFORM_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_PROVISION),\n#define TPMI_SH_HMAC_H_UNMARSHAL                (TPMI_RH_PROVISION_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_SH_HMAC),\n#define TPMI_SH_POLICY_H_UNMARSHAL              (TPMI_SH_HMAC_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_SH_POLICY),\n\t\t\t\t\t// HANDLE_FIRST_FLAG_TYPE is the first handle that needs a flag when called.\n#define HANDLE_FIRST_FLAG_TYPE                  (TPMI_SH_POLICY_H_UNMARSHAL + 1)\n#define TPMI_DH_ENTITY_H_UNMARSHAL              (TPMI_SH_POLICY_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_DH_ENTITY),\n#define TPMI_DH_OBJECT_H_UNMARSHAL              (TPMI_DH_ENTITY_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_DH_OBJECT),\n#define TPMI_DH_PARENT_H_UNMARSHAL              (TPMI_DH_OBJECT_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_DH_PARENT),\n#define TPMI_DH_PCR_H_UNMARSHAL                 (TPMI_DH_PARENT_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_DH_PCR),\n#define TPMI_RH_ENDORSEMENT_H_UNMARSHAL         (TPMI_DH_PCR_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_ENDORSEMENT),\n#define TPMI_RH_HIERARCHY_H_UNMARSHAL\t\t\t\t\t\\\n\t\t\t\t\t(TPMI_RH_ENDORSEMENT_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_HIERARCHY),\n\t\t\t\t\t// PARAMETER_FIRST_TYPE marks the end of the handle list.\n#define PARAMETER_FIRST_TYPE                    (TPMI_RH_HIERARCHY_H_UNMARSHAL + 1)\n#define TPM2B_DATA_P_UNMARSHAL                  (TPMI_RH_HIERARCHY_H_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_DATA),\n#define TPM2B_DIGEST_P_UNMARSHAL                (TPM2B_DATA_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_DIGEST),\n#define TPM2B_ECC_PARAMETER_P_UNMARSHAL         (TPM2B_DIGEST_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_ECC_PARAMETER),\n#define TPM2B_ECC_POINT_P_UNMARSHAL\t\t\t\t\t\\\n\t\t\t\t\t(TPM2B_ECC_PARAMETER_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_ECC_POINT),\n#define TPM2B_ENCRYPTED_SECRET_P_UNMARSHAL      (TPM2B_ECC_POINT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_ENCRYPTED_SECRET),\n#define TPM2B_EVENT_P_UNMARSHAL\t\t\t\t\t\t\\\n\t\t\t\t\t(TPM2B_ENCRYPTED_SECRET_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_EVENT),\n#define TPM2B_ID_OBJECT_P_UNMARSHAL             (TPM2B_EVENT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_ID_OBJECT),\n#define TPM2B_IV_P_UNMARSHAL                    (TPM2B_ID_OBJECT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_IV),\n#define TPM2B_MAX_BUFFER_P_UNMARSHAL            (TPM2B_IV_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_MAX_BUFFER),\n#define TPM2B_MAX_NV_BUFFER_P_UNMARSHAL         (TPM2B_MAX_BUFFER_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_MAX_NV_BUFFER),\n#define TPM2B_NAME_P_UNMARSHAL\t\t\t\t\t\t\\\n\t\t\t\t\t(TPM2B_MAX_NV_BUFFER_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_NAME),\n#define TPM2B_NV_PUBLIC_P_UNMARSHAL             (TPM2B_NAME_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_NV_PUBLIC),\n#define TPM2B_NV_PUBLIC_2_P_UNMARSHAL           (TPM2B_NV_PUBLIC_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_NV_PUBLIC_2),\n#define TPM2B_PRIVATE_P_UNMARSHAL               (TPM2B_NV_PUBLIC_2_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_PRIVATE),\n#define TPM2B_PUBLIC_KEY_RSA_P_UNMARSHAL        (TPM2B_PRIVATE_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_PUBLIC_KEY_RSA),\n#define TPM2B_SENSITIVE_P_UNMARSHAL\t\t\t\t\t\\\n\t\t\t\t\t(TPM2B_PUBLIC_KEY_RSA_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_SENSITIVE),\n#define TPM2B_SENSITIVE_CREATE_P_UNMARSHAL      (TPM2B_SENSITIVE_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_SENSITIVE_CREATE),\n#define TPM2B_SENSITIVE_DATA_P_UNMARSHAL\t\t\t\t\\\n\t\t\t\t\t(TPM2B_SENSITIVE_CREATE_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_SENSITIVE_DATA),\n#define TPM2B_SET_CAPABILITY_DATA_P_UNMARSHAL   (TPM2B_SENSITIVE_DATA_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_SET_CAPABILITY_DATA),\n#define TPM2B_TEMPLATE_P_UNMARSHAL\t\t\t\t\t\\\n\t\t\t\t\t(TPM2B_SET_CAPABILITY_DATA_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_TEMPLATE),\n#define TPM2B_TIMEOUT_P_UNMARSHAL               (TPM2B_TEMPLATE_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_TIMEOUT),\n#define TPMI_DH_CONTEXT_P_UNMARSHAL             (TPM2B_TIMEOUT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_DH_CONTEXT),\n#define TPMI_DH_PERSISTENT_P_UNMARSHAL          (TPMI_DH_CONTEXT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_DH_PERSISTENT),\n#define TPMI_YES_NO_P_UNMARSHAL                 (TPMI_DH_PERSISTENT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_YES_NO),\n#define TPML_ALG_P_UNMARSHAL                    (TPMI_YES_NO_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPML_ALG),\n#define TPML_CC_P_UNMARSHAL                     (TPML_ALG_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPML_CC),\n#define TPML_DIGEST_P_UNMARSHAL                 (TPML_CC_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPML_DIGEST),\n#define TPML_DIGEST_VALUES_P_UNMARSHAL          (TPML_DIGEST_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPML_DIGEST_VALUES),\n#define TPML_PCR_SELECTION_P_UNMARSHAL          (TPML_DIGEST_VALUES_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPML_PCR_SELECTION),\n#define TPMS_CONTEXT_P_UNMARSHAL                (TPML_PCR_SELECTION_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMS_CONTEXT),\n#define TPMT_PUBLIC_PARMS_P_UNMARSHAL           (TPMS_CONTEXT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_PUBLIC_PARMS),\n#define TPMT_TK_AUTH_P_UNMARSHAL                (TPMT_PUBLIC_PARMS_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_TK_AUTH),\n#define TPMT_TK_CREATION_P_UNMARSHAL            (TPMT_TK_AUTH_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_TK_CREATION),\n#define TPMT_TK_HASHCHECK_P_UNMARSHAL           (TPMT_TK_CREATION_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_TK_HASHCHECK),\n#define TPMT_TK_VERIFIED_P_UNMARSHAL            (TPMT_TK_HASHCHECK_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_TK_VERIFIED),\n#define TPM_AT_P_UNMARSHAL                      (TPMT_TK_VERIFIED_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM_AT),\n#define TPM_CAP_P_UNMARSHAL                     (TPM_AT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM_CAP),\n#define TPM_CLOCK_ADJUST_P_UNMARSHAL            (TPM_CAP_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM_CLOCK_ADJUST),\n#define TPM_EO_P_UNMARSHAL                      (TPM_CLOCK_ADJUST_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM_EO),\n#define TPM_SE_P_UNMARSHAL                      (TPM_EO_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM_SE),\n#define TPM_SU_P_UNMARSHAL                      (TPM_SE_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM_SU),\n#define UINT16_P_UNMARSHAL                      (TPM_SU_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(UINT16),\n#define UINT32_P_UNMARSHAL                      (UINT16_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(UINT32),\n#define UINT64_P_UNMARSHAL                      (UINT32_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(UINT64),\n#define UINT8_P_UNMARSHAL                       (UINT64_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(UINT8),\n\t\t\t\t\t// PARAMETER_FIRST_FLAG_TYPE is the first parameter to need a flag.\n#define PARAMETER_FIRST_FLAG_TYPE               (UINT8_P_UNMARSHAL + 1)\n#define TPM2B_PUBLIC_P_UNMARSHAL                (UINT8_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPM2B_PUBLIC),\n#define TPMI_ALG_CIPHER_MODE_P_UNMARSHAL        (TPM2B_PUBLIC_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_ALG_CIPHER_MODE),\n#define TPMI_ALG_HASH_P_UNMARSHAL\t\t\t\t\t\\\n\t\t\t\t\t(TPMI_ALG_CIPHER_MODE_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_ALG_HASH),\n#define TPMI_ALG_MAC_SCHEME_P_UNMARSHAL         (TPMI_ALG_HASH_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_ALG_MAC_SCHEME),\n#define TPMI_DH_PCR_P_UNMARSHAL\t\t\t\t\t\t\\\n\t\t\t\t\t(TPMI_ALG_MAC_SCHEME_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_DH_PCR),\n#define TPMI_ECC_CURVE_P_UNMARSHAL              (TPMI_DH_PCR_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_ECC_CURVE),\n#define TPMI_ECC_KEY_EXCHANGE_P_UNMARSHAL       (TPMI_ECC_CURVE_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_ECC_KEY_EXCHANGE),\n#define TPMI_RH_ENABLES_P_UNMARSHAL\t\t\t\t\t\\\n\t\t\t\t\t(TPMI_ECC_KEY_EXCHANGE_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_ENABLES),\n#define TPMI_RH_HIERARCHY_P_UNMARSHAL           (TPMI_RH_ENABLES_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMI_RH_HIERARCHY),\n#define TPMT_KDF_SCHEME_P_UNMARSHAL             (TPMI_RH_HIERARCHY_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_KDF_SCHEME),\n#define TPMT_RSA_DECRYPT_P_UNMARSHAL            (TPMT_KDF_SCHEME_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_RSA_DECRYPT),\n#define TPMT_SIGNATURE_P_UNMARSHAL              (TPMT_RSA_DECRYPT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_SIGNATURE),\n#define TPMT_SIG_SCHEME_P_UNMARSHAL             (TPMT_SIGNATURE_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_SIG_SCHEME),\n#define TPMT_SYM_DEF_P_UNMARSHAL                (TPMT_SIG_SCHEME_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_SYM_DEF),\n#define TPMT_SYM_DEF_OBJECT_P_UNMARSHAL         (TPMT_SYM_DEF_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(TPMT_SYM_DEF_OBJECT)\n\t\t\t\t\t// PARAMETER_LAST_TYPE is the end of the command parameter list.\n#ifdef TPM_NUVOTON\n,\n#define NTC2_CFG_STRUCT_P_UNMARSHAL\t(TPMT_SYM_DEF_OBJECT_P_UNMARSHAL + 1)\n\t\t\t\t\tUNMARSHAL_DISPATCH(NTC2_CFG_STRUCT)\n\t\t\t\t\t\n#define PARAMETER_LAST_TYPE             (NTC2_CFG_STRUCT_P_UNMARSHAL)\n\n#else\n\n    // PARAMETER_LAST_TYPE is the end of the command parameter list.    \n#define PARAMETER_LAST_TYPE             (TPMT_SYM_DEF_OBJECT_P_UNMARSHAL)\n\n#endif\t/* TPM_NUVOTON */\n\n};\n\n\nconst _MARSHAL_T_ marshalArray[] = {\n\n#define UINT32_H_MARSHAL                        0\n\t\t\t\t    MARSHAL_DISPATCH(UINT32),\n\t\t\t\t    // RESPONSE_PARAMETER_FIRST_TYPE marks the end of the response handles.\n#define RESPONSE_PARAMETER_FIRST_TYPE           (UINT32_H_MARSHAL + 1)\n#define TPM2B_ATTEST_P_MARSHAL                  (UINT32_H_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_ATTEST),\n#define TPM2B_CREATION_DATA_P_MARSHAL           (TPM2B_ATTEST_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_CREATION_DATA),\n#define TPM2B_DATA_P_MARSHAL                    (TPM2B_CREATION_DATA_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_DATA),\n#define TPM2B_DIGEST_P_MARSHAL                  (TPM2B_DATA_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_DIGEST),\n#define TPM2B_ECC_POINT_P_MARSHAL               (TPM2B_DIGEST_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_ECC_POINT),\n#define TPM2B_ENCRYPTED_SECRET_P_MARSHAL        (TPM2B_ECC_POINT_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_ENCRYPTED_SECRET),\n#define TPM2B_ID_OBJECT_P_MARSHAL\t\t\t\t\t\\\n\t\t\t\t    (TPM2B_ENCRYPTED_SECRET_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_ID_OBJECT),\n#define TPM2B_IV_P_MARSHAL                      (TPM2B_ID_OBJECT_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_IV),\n#define TPM2B_MAX_BUFFER_P_MARSHAL              (TPM2B_IV_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_MAX_BUFFER),\n#define TPM2B_MAX_NV_BUFFER_P_MARSHAL           (TPM2B_MAX_BUFFER_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_MAX_NV_BUFFER),\n#define TPM2B_NAME_P_MARSHAL                    (TPM2B_MAX_NV_BUFFER_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_NAME),\n#define TPM2B_NV_PUBLIC_P_MARSHAL               (TPM2B_NAME_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_NV_PUBLIC),\n#define TPM2B_NV_PUBLIC_2_P_MARSHAL             (TPM2B_NV_PUBLIC_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_NV_PUBLIC_2),\n#define TPM2B_PRIVATE_P_MARSHAL                 (TPM2B_NV_PUBLIC_2_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_PRIVATE),\n#define TPM2B_PUBLIC_P_MARSHAL                  (TPM2B_PRIVATE_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_PUBLIC),\n#define TPM2B_PUBLIC_KEY_RSA_P_MARSHAL          (TPM2B_PUBLIC_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_PUBLIC_KEY_RSA),\n#define TPM2B_SENSITIVE_DATA_P_MARSHAL          (TPM2B_PUBLIC_KEY_RSA_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_SENSITIVE_DATA),\n#define TPM2B_TIMEOUT_P_MARSHAL                 (TPM2B_SENSITIVE_DATA_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPM2B_TIMEOUT),\n#define UINT8_P_MARSHAL                         (TPM2B_TIMEOUT_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(UINT8),\n#define TPML_AC_CAPABILITIES_P_MARSHAL          (UINT8_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPML_AC_CAPABILITIES),\n#define TPML_ALG_P_MARSHAL                      (TPML_AC_CAPABILITIES_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPML_ALG),\n#define TPML_DIGEST_P_MARSHAL                   (TPML_ALG_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPML_DIGEST),\n#define TPML_DIGEST_VALUES_P_MARSHAL            (TPML_DIGEST_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPML_DIGEST_VALUES),\n#define TPML_PCR_SELECTION_P_MARSHAL            (TPML_DIGEST_VALUES_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPML_PCR_SELECTION),\n#define TPMS_AC_OUTPUT_P_MARSHAL                (TPML_PCR_SELECTION_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMS_AC_OUTPUT),\n#define TPMS_ALGORITHM_DETAIL_ECC_P_MARSHAL     (TPMS_AC_OUTPUT_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMS_ALGORITHM_DETAIL_ECC),\n#define TPMS_CAPABILITY_DATA_P_MARSHAL\t\t\t\t\t\\\n\t\t\t\t    (TPMS_ALGORITHM_DETAIL_ECC_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMS_CAPABILITY_DATA),\n#define TPMS_CONTEXT_P_MARSHAL                  (TPMS_CAPABILITY_DATA_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMS_CONTEXT),\n#define TPMS_TIME_INFO_P_MARSHAL                (TPMS_CONTEXT_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMS_TIME_INFO),\n#define TPMT_HA_P_MARSHAL                       (TPMS_TIME_INFO_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMT_HA),\n#define TPMT_SIGNATURE_P_MARSHAL                (TPMT_HA_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMT_SIGNATURE),\n#define TPMT_TK_AUTH_P_MARSHAL                  (TPMT_SIGNATURE_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMT_TK_AUTH),\n#define TPMT_TK_CREATION_P_MARSHAL              (TPMT_TK_AUTH_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMT_TK_CREATION),\n#define TPMT_TK_HASHCHECK_P_MARSHAL             (TPMT_TK_CREATION_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMT_TK_HASHCHECK),\n#define TPMT_TK_VERIFIED_P_MARSHAL              (TPMT_TK_HASHCHECK_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(TPMT_TK_VERIFIED),\n#define UINT32_P_MARSHAL                        (TPMT_TK_VERIFIED_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(UINT32),\n#define UINT16_P_MARSHAL                        (UINT32_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(UINT16)\n\n#ifdef TPM_NUVOTON\n,\n#define NTC2_CFG_STRUCT_P_MARSHAL\t\t(UINT16_P_MARSHAL + 1)\n\t\t\t\t    MARSHAL_DISPATCH(NTC2_CFG_STRUCT)\n\n#define RESPONSE_PARAMETER_LAST_TYPE    (NTC2_CFG_STRUCT_P_MARSHAL)\n\n#else     \n\t\t\t\t    // RESPONSE_PARAMETER_LAST_TYPE is the end of the response parameter list.\n#define RESPONSE_PARAMETER_LAST_TYPE    (UINT16_P_MARSHAL)\n\n#endif\t/* TPM_NUVOTON */\n\t\t\t\t    // RESPONSE_PARAMETER_LAST_TYPE is the end of the response parameter list.\n};\n\n/* This list of aliases allows the types in the _COMMAND_DESCRIPTOR_T to match the types in the\n   command/response templates of part 3. */\n#define INT32_P_UNMARSHAL                   UINT32_P_UNMARSHAL\n#define TPM2B_AUTH_P_UNMARSHAL              TPM2B_DIGEST_P_UNMARSHAL\n#define TPM2B_NONCE_P_UNMARSHAL             TPM2B_DIGEST_P_UNMARSHAL\n#define TPM2B_OPERAND_P_UNMARSHAL           TPM2B_DIGEST_P_UNMARSHAL\n#define TPMA_LOCALITY_P_UNMARSHAL           UINT8_P_UNMARSHAL\n#define TPM_CC_P_UNMARSHAL                  UINT32_P_UNMARSHAL\n#define TPMI_DH_CONTEXT_H_MARSHAL           UINT32_H_MARSHAL\n#define TPMI_DH_OBJECT_H_MARSHAL            UINT32_H_MARSHAL\n#define TPMI_SH_AUTH_SESSION_H_MARSHAL      UINT32_H_MARSHAL\n#define TPM_HANDLE_H_MARSHAL                UINT32_H_MARSHAL\n#define TPM2B_NONCE_P_MARSHAL               TPM2B_DIGEST_P_MARSHAL\n#define TPMI_YES_NO_P_MARSHAL               UINT8_P_MARSHAL\n#define TPM_RC_P_MARSHAL                    UINT32_P_MARSHAL\n\n#if CC_Startup\n#include \"Startup_fp.h\"\ntypedef TPM_RC  (Startup_Entry)(\n\t\t\t\tStartup_In *in\n\t\t\t\t);\ntypedef const struct {\n    Startup_Entry    *entry;\n    UINT16           inSize;\n    UINT16           outSize;\n    UINT16           offsetOfTypes;\n    BYTE             types[3];\n} Startup_COMMAND_DESCRIPTOR_t;\nStartup_COMMAND_DESCRIPTOR_t _StartupData = {\n    /* entry  */          &TPM2_Startup,\n    /* inSize */          (UINT16)(sizeof(Startup_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(Startup_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPM_SU_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _StartupDataAddress (&_StartupData)\n#else\n#define _StartupDataAddress 0\n#endif\n#if CC_Shutdown\n#include \"Shutdown_fp.h\"\ntypedef TPM_RC  (Shutdown_Entry)(\n\t\t\t\t Shutdown_In *in\n\t\t\t\t );\ntypedef const struct {\n    Shutdown_Entry    *entry;\n    UINT16            inSize;\n    UINT16            outSize;\n    UINT16            offsetOfTypes;\n    BYTE              types[3];\n} Shutdown_COMMAND_DESCRIPTOR_t;\nShutdown_COMMAND_DESCRIPTOR_t _ShutdownData = {\n    /* entry  */          &TPM2_Shutdown,\n    /* inSize */          (UINT16)(sizeof(Shutdown_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(Shutdown_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPM_SU_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _ShutdownDataAddress (&_ShutdownData)\n#else\n#define _ShutdownDataAddress 0\n#endif\n#if CC_SelfTest\n#include \"SelfTest_fp.h\"\ntypedef TPM_RC  (SelfTest_Entry)(\n\t\t\t\t SelfTest_In *in\n\t\t\t\t );\ntypedef const struct {\n    SelfTest_Entry    *entry;\n    UINT16            inSize;\n    UINT16            outSize;\n    UINT16            offsetOfTypes;\n    BYTE              types[3];\n} SelfTest_COMMAND_DESCRIPTOR_t;\nSelfTest_COMMAND_DESCRIPTOR_t _SelfTestData = {\n    /* entry  */          &TPM2_SelfTest,\n    /* inSize */          (UINT16)(sizeof(SelfTest_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(SelfTest_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_YES_NO_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _SelfTestDataAddress (&_SelfTestData)\n#else\n#define _SelfTestDataAddress 0\n#endif\n#if CC_IncrementalSelfTest\n#include \"IncrementalSelfTest_fp.h\"\ntypedef TPM_RC  (IncrementalSelfTest_Entry)(\n\t\t\t\t\t    IncrementalSelfTest_In *in,\n\t\t\t\t\t    IncrementalSelfTest_Out *out\n\t\t\t\t\t    );\ntypedef const struct {\n    IncrementalSelfTest_Entry    *entry;\n    UINT16                       inSize;\n    UINT16                       outSize;\n    UINT16                       offsetOfTypes;\n    BYTE                         types[4];\n} IncrementalSelfTest_COMMAND_DESCRIPTOR_t;\nIncrementalSelfTest_COMMAND_DESCRIPTOR_t _IncrementalSelfTestData = {\n    /* entry  */          &TPM2_IncrementalSelfTest,\n    /* inSize */          (UINT16)(sizeof(IncrementalSelfTest_In)),\n    /* outSize */         (UINT16)(sizeof(IncrementalSelfTest_Out)),\n    /* offsetOfTypes */   offsetof(IncrementalSelfTest_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPML_ALG_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPML_ALG_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _IncrementalSelfTestDataAddress (&_IncrementalSelfTestData)\n#else\n#define _IncrementalSelfTestDataAddress 0\n#endif\n#if CC_GetTestResult\n#include \"GetTestResult_fp.h\"\ntypedef TPM_RC  (GetTestResult_Entry)(\n\t\t\t\t      GetTestResult_Out *out\n\t\t\t\t      );\ntypedef const struct {\n    GetTestResult_Entry    *entry;\n    UINT16                 inSize;\n    UINT16                 outSize;\n    UINT16                 offsetOfTypes;\n    UINT16                 paramOffsets[1];\n    BYTE                   types[4];\n} GetTestResult_COMMAND_DESCRIPTOR_t;\nGetTestResult_COMMAND_DESCRIPTOR_t _GetTestResultData = {\n    /* entry  */          &TPM2_GetTestResult,\n    /* inSize */          0,\n    /* outSize */         (UINT16)(sizeof(GetTestResult_Out)),\n    /* offsetOfTypes */   offsetof(GetTestResult_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(GetTestResult_Out, testResult))},\n    /* types */           {END_OF_LIST,\n\t\t\t   TPM2B_MAX_BUFFER_P_MARSHAL,\n\t\t\t   TPM_RC_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _GetTestResultDataAddress (&_GetTestResultData)\n#else\n#define _GetTestResultDataAddress 0\n#endif\n#if CC_StartAuthSession\n#include \"StartAuthSession_fp.h\"\ntypedef TPM_RC  (StartAuthSession_Entry)(\n\t\t\t\t\t StartAuthSession_In *in,\n\t\t\t\t\t StartAuthSession_Out *out\n\t\t\t\t\t );\ntypedef const struct {\n    StartAuthSession_Entry    *entry;\n    UINT16                    inSize;\n    UINT16                    outSize;\n    UINT16                    offsetOfTypes;\n    UINT16                    paramOffsets[7];\n    BYTE                      types[11];\n} StartAuthSession_COMMAND_DESCRIPTOR_t;\nStartAuthSession_COMMAND_DESCRIPTOR_t _StartAuthSessionData = {\n    /* entry  */          &TPM2_StartAuthSession,\n    /* inSize */          (UINT16)(sizeof(StartAuthSession_In)),\n    /* outSize */         (UINT16)(sizeof(StartAuthSession_Out)),\n    /* offsetOfTypes */   offsetof(StartAuthSession_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(StartAuthSession_In, bind)),\n\t\t\t   (UINT16)(offsetof(StartAuthSession_In, nonceCaller)),\n\t\t\t   (UINT16)(offsetof(StartAuthSession_In, encryptedSalt)),\n\t\t\t   (UINT16)(offsetof(StartAuthSession_In, sessionType)),\n\t\t\t   (UINT16)(offsetof(StartAuthSession_In, symmetric)),\n\t\t\t   (UINT16)(offsetof(StartAuthSession_In, authHash)),\n\t\t\t   (UINT16)(offsetof(StartAuthSession_Out, nonceTPM))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMI_DH_ENTITY_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_NONCE_P_UNMARSHAL,\n\t\t\t   TPM2B_ENCRYPTED_SECRET_P_UNMARSHAL,\n\t\t\t   TPM_SE_P_UNMARSHAL,\n\t\t\t   TPMT_SYM_DEF_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMI_ALG_HASH_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMI_SH_AUTH_SESSION_H_MARSHAL,\n\t\t\t   TPM2B_NONCE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _StartAuthSessionDataAddress (&_StartAuthSessionData)\n#else\n#define _StartAuthSessionDataAddress 0\n#endif\n#if CC_PolicyRestart\n#include \"PolicyRestart_fp.h\"\ntypedef TPM_RC  (PolicyRestart_Entry)(\n\t\t\t\t      PolicyRestart_In *in\n\t\t\t\t      );\ntypedef const struct {\n    PolicyRestart_Entry    *entry;\n    UINT16                 inSize;\n    UINT16                 outSize;\n    UINT16                 offsetOfTypes;\n    BYTE                   types[3];\n} PolicyRestart_COMMAND_DESCRIPTOR_t;\nPolicyRestart_COMMAND_DESCRIPTOR_t _PolicyRestartData = {\n    /* entry  */          &TPM2_PolicyRestart,\n    /* inSize */          (UINT16)(sizeof(PolicyRestart_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyRestart_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyRestartDataAddress (&_PolicyRestartData)\n#else\n#define _PolicyRestartDataAddress 0\n#endif\n#if CC_Create\n#include \"Create_fp.h\"\ntypedef TPM_RC  (Create_Entry)(\n\t\t\t       Create_In *in,\n\t\t\t       Create_Out *out\n\t\t\t       );\ntypedef const struct {\n    Create_Entry    *entry;\n    UINT16          inSize;\n    UINT16          outSize;\n    UINT16          offsetOfTypes;\n    UINT16          paramOffsets[8];\n    BYTE            types[12];\n} Create_COMMAND_DESCRIPTOR_t;\nCreate_COMMAND_DESCRIPTOR_t _CreateData = {\n    /* entry  */          &TPM2_Create,\n    /* inSize */          (UINT16)(sizeof(Create_In)),\n    /* outSize */         (UINT16)(sizeof(Create_Out)),\n    /* offsetOfTypes */   offsetof(Create_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Create_In, inSensitive)),\n\t\t\t   (UINT16)(offsetof(Create_In, inPublic)),\n\t\t\t   (UINT16)(offsetof(Create_In, outsideInfo)),\n\t\t\t   (UINT16)(offsetof(Create_In, creationPCR)),\n\t\t\t   (UINT16)(offsetof(Create_Out, outPublic)),\n\t\t\t   (UINT16)(offsetof(Create_Out, creationData)),\n\t\t\t   (UINT16)(offsetof(Create_Out, creationHash)),\n\t\t\t   (UINT16)(offsetof(Create_Out, creationTicket))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_SENSITIVE_CREATE_P_UNMARSHAL,\n\t\t\t   TPM2B_PUBLIC_P_UNMARSHAL,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPML_PCR_SELECTION_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_PRIVATE_P_MARSHAL,\n\t\t\t   TPM2B_PUBLIC_P_MARSHAL,\n\t\t\t   TPM2B_CREATION_DATA_P_MARSHAL,\n\t\t\t   TPM2B_DIGEST_P_MARSHAL,\n\t\t\t   TPMT_TK_CREATION_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _CreateDataAddress (&_CreateData)\n#else\n#define _CreateDataAddress 0\n#endif\n#if CC_Load\n#include \"Load_fp.h\"\ntypedef TPM_RC  (Load_Entry)(\n\t\t\t     Load_In *in,\n\t\t\t     Load_Out *out\n\t\t\t     );\ntypedef const struct {\n    Load_Entry    *entry;\n    UINT16        inSize;\n    UINT16        outSize;\n    UINT16        offsetOfTypes;\n    UINT16        paramOffsets[3];\n    BYTE          types[7];\n} Load_COMMAND_DESCRIPTOR_t;\nLoad_COMMAND_DESCRIPTOR_t _LoadData = {\n    /* entry  */          &TPM2_Load,\n    /* inSize */          (UINT16)(sizeof(Load_In)),\n    /* outSize */         (UINT16)(sizeof(Load_Out)),\n    /* offsetOfTypes */   offsetof(Load_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Load_In, inPrivate)),\n\t\t\t   (UINT16)(offsetof(Load_In, inPublic)),\n\t\t\t   (UINT16)(offsetof(Load_Out, name))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_PRIVATE_P_UNMARSHAL,\n\t\t\t   TPM2B_PUBLIC_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM_HANDLE_H_MARSHAL,\n\t\t\t   TPM2B_NAME_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _LoadDataAddress (&_LoadData)\n#else\n#define _LoadDataAddress 0\n#endif\n#if CC_LoadExternal\n#include \"LoadExternal_fp.h\"\ntypedef TPM_RC  (LoadExternal_Entry)(\n\t\t\t\t     LoadExternal_In *in,\n\t\t\t\t     LoadExternal_Out *out\n\t\t\t\t     );\ntypedef const struct {\n    LoadExternal_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[3];\n    BYTE                  types[7];\n} LoadExternal_COMMAND_DESCRIPTOR_t;\nLoadExternal_COMMAND_DESCRIPTOR_t _LoadExternalData = {\n    /* entry  */          &TPM2_LoadExternal,\n    /* inSize */          (UINT16)(sizeof(LoadExternal_In)),\n    /* outSize */         (UINT16)(sizeof(LoadExternal_Out)),\n    /* offsetOfTypes */   offsetof(LoadExternal_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(LoadExternal_In, inPublic)),\n\t\t\t   (UINT16)(offsetof(LoadExternal_In, hierarchy)),\n\t\t\t   (UINT16)(offsetof(LoadExternal_Out, name))},\n    /* types */           {TPM2B_SENSITIVE_P_UNMARSHAL,\n\t\t\t   TPM2B_PUBLIC_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMI_RH_HIERARCHY_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM_HANDLE_H_MARSHAL,\n\t\t\t   TPM2B_NAME_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _LoadExternalDataAddress (&_LoadExternalData)\n#else\n#define _LoadExternalDataAddress 0\n#endif\n#if CC_ReadPublic\n#include \"ReadPublic_fp.h\"\ntypedef TPM_RC  (ReadPublic_Entry)(\n\t\t\t\t   ReadPublic_In *in,\n\t\t\t\t   ReadPublic_Out *out\n\t\t\t\t   );\ntypedef const struct {\n    ReadPublic_Entry    *entry;\n    UINT16              inSize;\n    UINT16              outSize;\n    UINT16              offsetOfTypes;\n    UINT16              paramOffsets[2];\n    BYTE                types[6];\n} ReadPublic_COMMAND_DESCRIPTOR_t;\nReadPublic_COMMAND_DESCRIPTOR_t _ReadPublicData = {\n    /* entry  */          &TPM2_ReadPublic,\n    /* inSize */          (UINT16)(sizeof(ReadPublic_In)),\n    /* outSize */         (UINT16)(sizeof(ReadPublic_Out)),\n    /* offsetOfTypes */   offsetof(ReadPublic_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(ReadPublic_Out, name)),\n\t\t\t   (UINT16)(offsetof(ReadPublic_Out, qualifiedName))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_PUBLIC_P_MARSHAL,\n\t\t\t   TPM2B_NAME_P_MARSHAL,\n\t\t\t   TPM2B_NAME_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ReadPublicDataAddress (&_ReadPublicData)\n#else\n#define _ReadPublicDataAddress 0\n#endif\n#if CC_ActivateCredential\n#include \"ActivateCredential_fp.h\"\ntypedef TPM_RC  (ActivateCredential_Entry)(\n\t\t\t\t\t   ActivateCredential_In *in,\n\t\t\t\t\t   ActivateCredential_Out *out\n\t\t\t\t\t   );\ntypedef const struct {\n    ActivateCredential_Entry    *entry;\n    UINT16                      inSize;\n    UINT16                      outSize;\n    UINT16                      offsetOfTypes;\n    UINT16                      paramOffsets[3];\n    BYTE                        types[7];\n} ActivateCredential_COMMAND_DESCRIPTOR_t;\nActivateCredential_COMMAND_DESCRIPTOR_t _ActivateCredentialData = {\n    /* entry  */          &TPM2_ActivateCredential,\n    /* inSize */          (UINT16)(sizeof(ActivateCredential_In)),\n    /* outSize */         (UINT16)(sizeof(ActivateCredential_Out)),\n    /* offsetOfTypes */   offsetof(ActivateCredential_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(ActivateCredential_In, keyHandle)),\n\t\t\t   (UINT16)(offsetof(ActivateCredential_In, credentialBlob)),\n\t\t\t   (UINT16)(offsetof(ActivateCredential_In, secret))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_ID_OBJECT_P_UNMARSHAL,\n\t\t\t   TPM2B_ENCRYPTED_SECRET_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_DIGEST_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ActivateCredentialDataAddress (&_ActivateCredentialData)\n#else\n#define _ActivateCredentialDataAddress 0\n#endif\n#if CC_MakeCredential\n#include \"MakeCredential_fp.h\"\ntypedef TPM_RC  (MakeCredential_Entry)(\n\t\t\t\t       MakeCredential_In *in,\n\t\t\t\t       MakeCredential_Out *out\n\t\t\t\t       );\ntypedef const struct {\n    MakeCredential_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[3];\n    BYTE                    types[7];\n} MakeCredential_COMMAND_DESCRIPTOR_t;\nMakeCredential_COMMAND_DESCRIPTOR_t _MakeCredentialData = {\n    /* entry  */          &TPM2_MakeCredential,\n    /* inSize */          (UINT16)(sizeof(MakeCredential_In)),\n    /* outSize */         (UINT16)(sizeof(MakeCredential_Out)),\n    /* offsetOfTypes */   offsetof(MakeCredential_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(MakeCredential_In, credential)),\n\t\t\t   (UINT16)(offsetof(MakeCredential_In, objectName)),\n\t\t\t   (UINT16)(offsetof(MakeCredential_Out, secret))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPM2B_NAME_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ID_OBJECT_P_MARSHAL,\n\t\t\t   TPM2B_ENCRYPTED_SECRET_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _MakeCredentialDataAddress (&_MakeCredentialData)\n#else\n#define _MakeCredentialDataAddress 0\n#endif\n#if CC_Unseal\n#include \"Unseal_fp.h\"\ntypedef TPM_RC  (Unseal_Entry)(\n\t\t\t       Unseal_In *in,\n\t\t\t       Unseal_Out *out\n\t\t\t       );\ntypedef const struct {\n    Unseal_Entry    *entry;\n    UINT16          inSize;\n    UINT16          outSize;\n    UINT16          offsetOfTypes;\n    BYTE            types[4];\n} Unseal_COMMAND_DESCRIPTOR_t;\nUnseal_COMMAND_DESCRIPTOR_t _UnsealData = {\n    /* entry  */          &TPM2_Unseal,\n    /* inSize */          (UINT16)(sizeof(Unseal_In)),\n    /* outSize */         (UINT16)(sizeof(Unseal_Out)),\n    /* offsetOfTypes */   offsetof(Unseal_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_SENSITIVE_DATA_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _UnsealDataAddress (&_UnsealData)\n#else\n#define _UnsealDataAddress 0\n#endif\n#if CC_ObjectChangeAuth\n#include \"ObjectChangeAuth_fp.h\"\ntypedef TPM_RC  (ObjectChangeAuth_Entry)(\n\t\t\t\t\t ObjectChangeAuth_In *in,\n\t\t\t\t\t ObjectChangeAuth_Out *out\n\t\t\t\t\t );\ntypedef const struct {\n    ObjectChangeAuth_Entry    *entry;\n    UINT16                    inSize;\n    UINT16                    outSize;\n    UINT16                    offsetOfTypes;\n    UINT16                    paramOffsets[2];\n    BYTE                      types[6];\n} ObjectChangeAuth_COMMAND_DESCRIPTOR_t;\nObjectChangeAuth_COMMAND_DESCRIPTOR_t _ObjectChangeAuthData = {\n    /* entry  */          &TPM2_ObjectChangeAuth,\n    /* inSize */          (UINT16)(sizeof(ObjectChangeAuth_In)),\n    /* outSize */         (UINT16)(sizeof(ObjectChangeAuth_Out)),\n    /* offsetOfTypes */   offsetof(ObjectChangeAuth_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(ObjectChangeAuth_In, parentHandle)),\n\t\t\t   (UINT16)(offsetof(ObjectChangeAuth_In, newAuth))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_AUTH_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_PRIVATE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ObjectChangeAuthDataAddress (&_ObjectChangeAuthData)\n#else\n#define _ObjectChangeAuthDataAddress 0\n#endif\n#if CC_CreateLoaded\n#include \"CreateLoaded_fp.h\"\ntypedef TPM_RC  (CreateLoaded_Entry)(\n\t\t\t\t     CreateLoaded_In *in,\n\t\t\t\t     CreateLoaded_Out *out\n\t\t\t\t     );\ntypedef const struct {\n    CreateLoaded_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[5];\n    BYTE                  types[9];\n} CreateLoaded_COMMAND_DESCRIPTOR_t;\nCreateLoaded_COMMAND_DESCRIPTOR_t _CreateLoadedData = {\n    /* entry  */          &TPM2_CreateLoaded,\n    /* inSize */          (UINT16)(sizeof(CreateLoaded_In)),\n    /* outSize */         (UINT16)(sizeof(CreateLoaded_Out)),\n    /* offsetOfTypes */   offsetof(CreateLoaded_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(CreateLoaded_In, inSensitive)),\n\t\t\t   (UINT16)(offsetof(CreateLoaded_In, inPublic)),\n\t\t\t   (UINT16)(offsetof(CreateLoaded_Out, outPrivate)),\n\t\t\t   (UINT16)(offsetof(CreateLoaded_Out, outPublic)),\n\t\t\t   (UINT16)(offsetof(CreateLoaded_Out, name))},\n    /* types */           {TPMI_DH_PARENT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_SENSITIVE_CREATE_P_UNMARSHAL,\n\t\t\t   TPM2B_TEMPLATE_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM_HANDLE_H_MARSHAL,\n\t\t\t   TPM2B_PRIVATE_P_MARSHAL,\n\t\t\t   TPM2B_PUBLIC_P_MARSHAL,\n\t\t\t   TPM2B_NAME_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _CreateLoadedDataAddress (&_CreateLoadedData)\n#else\n#define _CreateLoadedDataAddress 0\n#endif\n#if CC_Duplicate\n#include \"Duplicate_fp.h\"\ntypedef TPM_RC  (Duplicate_Entry)(\n\t\t\t\t  Duplicate_In *in,\n\t\t\t\t  Duplicate_Out *out\n\t\t\t\t  );\ntypedef const struct {\n    Duplicate_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    UINT16             paramOffsets[5];\n    BYTE               types[9];\n} Duplicate_COMMAND_DESCRIPTOR_t;\nDuplicate_COMMAND_DESCRIPTOR_t _DuplicateData = {\n    /* entry  */          &TPM2_Duplicate,\n    /* inSize */          (UINT16)(sizeof(Duplicate_In)),\n    /* outSize */         (UINT16)(sizeof(Duplicate_Out)),\n    /* offsetOfTypes */   offsetof(Duplicate_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Duplicate_In, newParentHandle)),\n\t\t\t   (UINT16)(offsetof(Duplicate_In, encryptionKeyIn)),\n\t\t\t   (UINT16)(offsetof(Duplicate_In, symmetricAlg)),\n\t\t\t   (UINT16)(offsetof(Duplicate_Out, duplicate)),\n\t\t\t   (UINT16)(offsetof(Duplicate_Out, outSymSeed))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPMT_SYM_DEF_OBJECT_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_DATA_P_MARSHAL,\n\t\t\t   TPM2B_PRIVATE_P_MARSHAL,\n\t\t\t   TPM2B_ENCRYPTED_SECRET_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _DuplicateDataAddress (&_DuplicateData)\n#else\n#define _DuplicateDataAddress 0\n#endif\n#if CC_Rewrap\n#include \"Rewrap_fp.h\"\ntypedef TPM_RC  (Rewrap_Entry)(\n\t\t\t       Rewrap_In *in,\n\t\t\t       Rewrap_Out *out\n\t\t\t       );\ntypedef const struct {\n    Rewrap_Entry    *entry;\n    UINT16          inSize;\n    UINT16          outSize;\n    UINT16          offsetOfTypes;\n    UINT16          paramOffsets[5];\n    BYTE            types[9];\n} Rewrap_COMMAND_DESCRIPTOR_t;\nRewrap_COMMAND_DESCRIPTOR_t _RewrapData = {\n    /* entry  */          &TPM2_Rewrap,\n    /* inSize */          (UINT16)(sizeof(Rewrap_In)),\n    /* outSize */         (UINT16)(sizeof(Rewrap_Out)),\n    /* offsetOfTypes */   offsetof(Rewrap_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Rewrap_In, newParent)),\n\t\t\t   (UINT16)(offsetof(Rewrap_In, inDuplicate)),\n\t\t\t   (UINT16)(offsetof(Rewrap_In, name)),\n\t\t\t   (UINT16)(offsetof(Rewrap_In, inSymSeed)),\n\t\t\t   (UINT16)(offsetof(Rewrap_Out, outSymSeed))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_PRIVATE_P_UNMARSHAL,\n\t\t\t   TPM2B_NAME_P_UNMARSHAL,\n\t\t\t   TPM2B_ENCRYPTED_SECRET_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_PRIVATE_P_MARSHAL,\n\t\t\t   TPM2B_ENCRYPTED_SECRET_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _RewrapDataAddress (&_RewrapData)\n#else\n#define _RewrapDataAddress 0\n#endif\n#if CC_Import\n#include \"Import_fp.h\"\ntypedef TPM_RC  (Import_Entry)(\n\t\t\t       Import_In *in,\n\t\t\t       Import_Out *out\n\t\t\t       );\ntypedef const struct {\n    Import_Entry    *entry;\n    UINT16          inSize;\n    UINT16          outSize;\n    UINT16          offsetOfTypes;\n    UINT16          paramOffsets[5];\n    BYTE            types[9];\n} Import_COMMAND_DESCRIPTOR_t;\nImport_COMMAND_DESCRIPTOR_t _ImportData = {\n    /* entry  */          &TPM2_Import,\n    /* inSize */          (UINT16)(sizeof(Import_In)),\n    /* outSize */         (UINT16)(sizeof(Import_Out)),\n    /* offsetOfTypes */   offsetof(Import_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Import_In, encryptionKey)),\n\t\t\t   (UINT16)(offsetof(Import_In, objectPublic)),\n\t\t\t   (UINT16)(offsetof(Import_In, duplicate)),\n\t\t\t   (UINT16)(offsetof(Import_In, inSymSeed)),\n\t\t\t   (UINT16)(offsetof(Import_In, symmetricAlg))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPM2B_PUBLIC_P_UNMARSHAL,\n\t\t\t   TPM2B_PRIVATE_P_UNMARSHAL,\n\t\t\t   TPM2B_ENCRYPTED_SECRET_P_UNMARSHAL,\n\t\t\t   TPMT_SYM_DEF_OBJECT_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_PRIVATE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ImportDataAddress (&_ImportData)\n#else\n#define _ImportDataAddress 0\n#endif\n#if CC_RSA_Encrypt\n#include \"RSA_Encrypt_fp.h\"\ntypedef TPM_RC  (RSA_Encrypt_Entry)(\n\t\t\t\t    RSA_Encrypt_In *in,\n\t\t\t\t    RSA_Encrypt_Out *out\n\t\t\t\t    );\ntypedef const struct {\n    RSA_Encrypt_Entry    *entry;\n    UINT16               inSize;\n    UINT16               outSize;\n    UINT16               offsetOfTypes;\n    UINT16               paramOffsets[3];\n    BYTE                 types[7];\n} RSA_Encrypt_COMMAND_DESCRIPTOR_t;\nRSA_Encrypt_COMMAND_DESCRIPTOR_t _RSA_EncryptData = {\n    /* entry  */          &TPM2_RSA_Encrypt,\n    /* inSize */          (UINT16)(sizeof(RSA_Encrypt_In)),\n    /* outSize */         (UINT16)(sizeof(RSA_Encrypt_Out)),\n    /* offsetOfTypes */   offsetof(RSA_Encrypt_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(RSA_Encrypt_In, message)),\n\t\t\t   (UINT16)(offsetof(RSA_Encrypt_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(RSA_Encrypt_In, label))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_PUBLIC_KEY_RSA_P_UNMARSHAL,\n\t\t\t   TPMT_RSA_DECRYPT_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_PUBLIC_KEY_RSA_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _RSA_EncryptDataAddress (&_RSA_EncryptData)\n#else\n#define _RSA_EncryptDataAddress 0\n#endif\n#if CC_RSA_Decrypt\n#include \"RSA_Decrypt_fp.h\"\ntypedef TPM_RC  (RSA_Decrypt_Entry)(\n\t\t\t\t    RSA_Decrypt_In *in,\n\t\t\t\t    RSA_Decrypt_Out *out\n\t\t\t\t    );\ntypedef const struct {\n    RSA_Decrypt_Entry    *entry;\n    UINT16               inSize;\n    UINT16               outSize;\n    UINT16               offsetOfTypes;\n    UINT16               paramOffsets[3];\n    BYTE                 types[7];\n} RSA_Decrypt_COMMAND_DESCRIPTOR_t;\nRSA_Decrypt_COMMAND_DESCRIPTOR_t _RSA_DecryptData = {\n    /* entry  */          &TPM2_RSA_Decrypt,\n    /* inSize */          (UINT16)(sizeof(RSA_Decrypt_In)),\n    /* outSize */         (UINT16)(sizeof(RSA_Decrypt_Out)),\n    /* offsetOfTypes */   offsetof(RSA_Decrypt_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(RSA_Decrypt_In, cipherText)),\n\t\t\t   (UINT16)(offsetof(RSA_Decrypt_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(RSA_Decrypt_In, label))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_PUBLIC_KEY_RSA_P_UNMARSHAL,\n\t\t\t   TPMT_RSA_DECRYPT_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_PUBLIC_KEY_RSA_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _RSA_DecryptDataAddress (&_RSA_DecryptData)\n#else\n#define _RSA_DecryptDataAddress 0\n#endif\n#if CC_ECDH_KeyGen\n#include \"ECDH_KeyGen_fp.h\"\ntypedef TPM_RC  (ECDH_KeyGen_Entry)(\n\t\t\t\t    ECDH_KeyGen_In *in,\n\t\t\t\t    ECDH_KeyGen_Out *out\n\t\t\t\t    );\ntypedef const struct {\n    ECDH_KeyGen_Entry    *entry;\n    UINT16               inSize;\n    UINT16               outSize;\n    UINT16               offsetOfTypes;\n    UINT16               paramOffsets[1];\n    BYTE                 types[5];\n} ECDH_KeyGen_COMMAND_DESCRIPTOR_t;\nECDH_KeyGen_COMMAND_DESCRIPTOR_t _ECDH_KeyGenData = {\n    /* entry  */          &TPM2_ECDH_KeyGen,\n    /* inSize */          (UINT16)(sizeof(ECDH_KeyGen_In)),\n    /* outSize */         (UINT16)(sizeof(ECDH_KeyGen_Out)),\n    /* offsetOfTypes */   offsetof(ECDH_KeyGen_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(ECDH_KeyGen_Out, pubPoint))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t   TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ECDH_KeyGenDataAddress (&_ECDH_KeyGenData)\n#else\n#define _ECDH_KeyGenDataAddress 0\n#endif\n#if CC_ECDH_ZGen\n#include \"ECDH_ZGen_fp.h\"\ntypedef TPM_RC  (ECDH_ZGen_Entry)(\n\t\t\t\t  ECDH_ZGen_In *in,\n\t\t\t\t  ECDH_ZGen_Out *out\n\t\t\t\t  );\ntypedef const struct {\n    ECDH_ZGen_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    UINT16             paramOffsets[1];\n    BYTE               types[5];\n} ECDH_ZGen_COMMAND_DESCRIPTOR_t;\nECDH_ZGen_COMMAND_DESCRIPTOR_t _ECDH_ZGenData = {\n    /* entry  */          &TPM2_ECDH_ZGen,\n    /* inSize */          (UINT16)(sizeof(ECDH_ZGen_In)),\n    /* outSize */         (UINT16)(sizeof(ECDH_ZGen_Out)),\n    /* offsetOfTypes */   offsetof(ECDH_ZGen_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(ECDH_ZGen_In, inPoint))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_ECC_POINT_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ECDH_ZGenDataAddress (&_ECDH_ZGenData)\n#else\n#define _ECDH_ZGenDataAddress 0\n#endif\n\n#if CC_ECC_Encrypt\n\n#include \"ECC_Encrypt_fp.h\"\n\ntypedef TPM_RC  (ECC_Encrypt_Entry)(\n\t\t\t\t    ECC_Encrypt_In              *in,\n\t\t\t\t    ECC_Encrypt_Out             *out\n\t\t\t\t    );\n\ntypedef const struct {\n    ECC_Encrypt_Entry       *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[4];\n    BYTE                    types[8];\n} ECC_Encrypt_COMMAND_DESCRIPTOR_t;\n\nECC_Encrypt_COMMAND_DESCRIPTOR_t _ECC_EncryptData = {\n    /* entry         */     &TPM2_ECC_Encrypt,\n    /* inSize        */     (UINT16)(sizeof(ECC_Encrypt_In)),\n    /* outSize       */     (UINT16)(sizeof(ECC_Encrypt_Out)),\n    /* offsetOfTypes */     offsetof(ECC_Encrypt_COMMAND_DESCRIPTOR_t, types),\n    /* offsets       */     {(UINT16)(offsetof(ECC_Encrypt_In, plainText)),\n\t\t\t     (UINT16)(offsetof(ECC_Encrypt_In, inScheme)),\n\t\t\t     (UINT16)(offsetof(ECC_Encrypt_Out, C2)),\n\t\t\t     (UINT16)(offsetof(ECC_Encrypt_Out, C3))},\n    /* types         */     {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t     TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t     TPMT_KDF_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t     END_OF_LIST,\n\t\t\t     TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t     TPM2B_MAX_BUFFER_P_MARSHAL,\n\t\t\t     TPM2B_DIGEST_P_MARSHAL,\n\t\t\t     END_OF_LIST}\n};\n\n#define _ECC_EncryptDataAddress (&_ECC_EncryptData)\n#else\n#define _ECC_EncryptDataAddress 0\n#endif // CC_ECC_Encrypt\n\n#if CC_ECC_Decrypt\n\n#include \"ECC_Decrypt_fp.h\"\n\ntypedef TPM_RC  (ECC_Decrypt_Entry)(\n\t\t\t\t    ECC_Decrypt_In              *in,\n\t\t\t\t    ECC_Decrypt_Out             *out\n\t\t\t\t    );\n\ntypedef const struct {\n    ECC_Decrypt_Entry       *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[4];\n    BYTE                    types[8];\n} ECC_Decrypt_COMMAND_DESCRIPTOR_t;\n\nECC_Decrypt_COMMAND_DESCRIPTOR_t _ECC_DecryptData = {\n    /* entry         */     &TPM2_ECC_Decrypt,\n    /* inSize        */     (UINT16)(sizeof(ECC_Decrypt_In)),\n    /* outSize       */     (UINT16)(sizeof(ECC_Decrypt_Out)),\n    /* offsetOfTypes */     offsetof(ECC_Decrypt_COMMAND_DESCRIPTOR_t, types),\n    /* offsets       */     {(UINT16)(offsetof(ECC_Decrypt_In, C1)),\n\t\t\t     (UINT16)(offsetof(ECC_Decrypt_In, C2)),\n\t\t\t     (UINT16)(offsetof(ECC_Decrypt_In, C3)),\n\t\t\t     (UINT16)(offsetof(ECC_Decrypt_In, inScheme))},\n    /* types         */     {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t     TPM2B_ECC_POINT_P_UNMARSHAL,\n\t\t\t     TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t     TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t     TPMT_KDF_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t     END_OF_LIST,\n\t\t\t     TPM2B_MAX_BUFFER_P_MARSHAL,\n\t\t\t     END_OF_LIST}\n};\n\n#define _ECC_DecryptDataAddress (&_ECC_DecryptData)\n#else\n#define _ECC_DecryptDataAddress 0\n#endif // CC_ECC_Decrypt\n\n#if CC_ECC_Parameters\n#include \"ECC_Parameters_fp.h\"\ntypedef TPM_RC  (ECC_Parameters_Entry)(\n\t\t\t\t       ECC_Parameters_In *in,\n\t\t\t\t       ECC_Parameters_Out *out\n\t\t\t\t       );\ntypedef const struct {\n    ECC_Parameters_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    BYTE                    types[4];\n} ECC_Parameters_COMMAND_DESCRIPTOR_t;\nECC_Parameters_COMMAND_DESCRIPTOR_t _ECC_ParametersData = {\n    /* entry  */          &TPM2_ECC_Parameters,\n    /* inSize */          (UINT16)(sizeof(ECC_Parameters_In)),\n    /* outSize */         (UINT16)(sizeof(ECC_Parameters_Out)),\n    /* offsetOfTypes */   offsetof(ECC_Parameters_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_ECC_CURVE_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMS_ALGORITHM_DETAIL_ECC_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ECC_ParametersDataAddress (&_ECC_ParametersData)\n#else\n#define _ECC_ParametersDataAddress 0\n#endif\n#if CC_ZGen_2Phase\n#include \"ZGen_2Phase_fp.h\"\ntypedef TPM_RC  (ZGen_2Phase_Entry)(\n\t\t\t\t    ZGen_2Phase_In *in,\n\t\t\t\t    ZGen_2Phase_Out *out\n\t\t\t\t    );\ntypedef const struct {\n    ZGen_2Phase_Entry    *entry;\n    UINT16               inSize;\n    UINT16               outSize;\n    UINT16               offsetOfTypes;\n    UINT16               paramOffsets[5];\n    BYTE                 types[9];\n} ZGen_2Phase_COMMAND_DESCRIPTOR_t;\nZGen_2Phase_COMMAND_DESCRIPTOR_t _ZGen_2PhaseData = {\n    /* entry  */          &TPM2_ZGen_2Phase,\n    /* inSize */          (UINT16)(sizeof(ZGen_2Phase_In)),\n    /* outSize */         (UINT16)(sizeof(ZGen_2Phase_Out)),\n    /* offsetOfTypes */   offsetof(ZGen_2Phase_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(ZGen_2Phase_In, inQsB)),\n\t\t\t   (UINT16)(offsetof(ZGen_2Phase_In, inQeB)),\n\t\t\t   (UINT16)(offsetof(ZGen_2Phase_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(ZGen_2Phase_In, counter)),\n\t\t\t   (UINT16)(offsetof(ZGen_2Phase_Out, outZ2))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_ECC_POINT_P_UNMARSHAL,\n\t\t\t   TPM2B_ECC_POINT_P_UNMARSHAL,\n\t\t\t   TPMI_ECC_KEY_EXCHANGE_P_UNMARSHAL,\n\t\t\t   UINT16_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t   TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ZGen_2PhaseDataAddress (&_ZGen_2PhaseData)\n#else\n#define _ZGen_2PhaseDataAddress 0\n#endif\n#if CC_EncryptDecrypt\n#include \"EncryptDecrypt_fp.h\"\ntypedef TPM_RC  (EncryptDecrypt_Entry)(\n\t\t\t\t       EncryptDecrypt_In *in,\n\t\t\t\t       EncryptDecrypt_Out *out\n\t\t\t\t       );\ntypedef const struct {\n    EncryptDecrypt_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[5];\n    BYTE                    types[9];\n} EncryptDecrypt_COMMAND_DESCRIPTOR_t;\nEncryptDecrypt_COMMAND_DESCRIPTOR_t _EncryptDecryptData = {\n    /* entry  */          &TPM2_EncryptDecrypt,\n    /* inSize */          (UINT16)(sizeof(EncryptDecrypt_In)),\n    /* outSize */         (UINT16)(sizeof(EncryptDecrypt_Out)),\n    /* offsetOfTypes */   offsetof(EncryptDecrypt_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(EncryptDecrypt_In, decrypt)),\n\t\t\t   (UINT16)(offsetof(EncryptDecrypt_In, mode)),\n\t\t\t   (UINT16)(offsetof(EncryptDecrypt_In, ivIn)),\n\t\t\t   (UINT16)(offsetof(EncryptDecrypt_In, inData)),\n\t\t\t   (UINT16)(offsetof(EncryptDecrypt_Out, ivOut))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPMI_YES_NO_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_CIPHER_MODE_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_IV_P_UNMARSHAL,\n\t\t\t   TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_MAX_BUFFER_P_MARSHAL,\n\t\t\t   TPM2B_IV_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _EncryptDecryptDataAddress (&_EncryptDecryptData)\n#else\n#define _EncryptDecryptDataAddress 0\n#endif\n#if CC_EncryptDecrypt2\n#include \"EncryptDecrypt2_fp.h\"\ntypedef TPM_RC  (EncryptDecrypt2_Entry)(\n\t\t\t\t\tEncryptDecrypt2_In *in,\n\t\t\t\t\tEncryptDecrypt2_Out *out\n\t\t\t\t\t);\ntypedef const struct {\n    EncryptDecrypt2_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    UINT16                   paramOffsets[5];\n    BYTE                     types[9];\n} EncryptDecrypt2_COMMAND_DESCRIPTOR_t;\nEncryptDecrypt2_COMMAND_DESCRIPTOR_t _EncryptDecrypt2Data = {\n    /* entry  */          &TPM2_EncryptDecrypt2,\n    /* inSize */          (UINT16)(sizeof(EncryptDecrypt2_In)),\n    /* outSize */         (UINT16)(sizeof(EncryptDecrypt2_Out)),\n    /* offsetOfTypes */   offsetof(EncryptDecrypt2_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(EncryptDecrypt2_In, inData)),\n\t\t\t   (UINT16)(offsetof(EncryptDecrypt2_In, decrypt)),\n\t\t\t   (UINT16)(offsetof(EncryptDecrypt2_In, mode)),\n\t\t\t   (UINT16)(offsetof(EncryptDecrypt2_In, ivIn)),\n\t\t\t   (UINT16)(offsetof(EncryptDecrypt2_Out, ivOut))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   TPMI_YES_NO_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_CIPHER_MODE_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_IV_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_MAX_BUFFER_P_MARSHAL,\n\t\t\t   TPM2B_IV_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _EncryptDecrypt2DataAddress (&_EncryptDecrypt2Data)\n#else\n#define _EncryptDecrypt2DataAddress 0\n#endif\n#if CC_Hash\n#include \"Hash_fp.h\"\ntypedef TPM_RC  (Hash_Entry)(\n\t\t\t     Hash_In *in,\n\t\t\t     Hash_Out *out\n\t\t\t     );\ntypedef const struct {\n    Hash_Entry    *entry;\n    UINT16        inSize;\n    UINT16        outSize;\n    UINT16        offsetOfTypes;\n    UINT16        paramOffsets[3];\n    BYTE          types[7];\n} Hash_COMMAND_DESCRIPTOR_t;\nHash_COMMAND_DESCRIPTOR_t _HashData = {\n    /* entry  */          &TPM2_Hash,\n    /* inSize */          (UINT16)(sizeof(Hash_In)),\n    /* outSize */         (UINT16)(sizeof(Hash_Out)),\n    /* offsetOfTypes */   offsetof(Hash_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Hash_In, hashAlg)),\n\t\t\t   (UINT16)(offsetof(Hash_In, hierarchy)),\n\t\t\t   (UINT16)(offsetof(Hash_Out, validation))},\n    /* types */           {TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_HASH_P_UNMARSHAL,\n\t\t\t   TPMI_RH_HIERARCHY_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_DIGEST_P_MARSHAL,\n\t\t\t   TPMT_TK_HASHCHECK_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _HashDataAddress (&_HashData)\n#else\n#define _HashDataAddress 0\n#endif\n#if CC_HMAC\n#include \"HMAC_fp.h\"\ntypedef TPM_RC  (HMAC_Entry)(\n\t\t\t     HMAC_In *in,\n\t\t\t     HMAC_Out *out\n\t\t\t     );\ntypedef const struct {\n    HMAC_Entry    *entry;\n    UINT16        inSize;\n    UINT16        outSize;\n    UINT16        offsetOfTypes;\n    UINT16        paramOffsets[2];\n    BYTE          types[6];\n} HMAC_COMMAND_DESCRIPTOR_t;\nHMAC_COMMAND_DESCRIPTOR_t _HMACData = {\n    /* entry  */          &TPM2_HMAC,\n    /* inSize */          (UINT16)(sizeof(HMAC_In)),\n    /* outSize */         (UINT16)(sizeof(HMAC_Out)),\n    /* offsetOfTypes */   offsetof(HMAC_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(HMAC_In, buffer)),\n\t\t\t   (UINT16)(offsetof(HMAC_In, hashAlg))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_HASH_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_DIGEST_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _HMACDataAddress (&_HMACData)\n#else\n#define _HMACDataAddress 0\n#endif\n#if CC_MAC\n#include \"MAC_fp.h\"\ntypedef TPM_RC  (MAC_Entry)(\n\t\t\t    MAC_In *in,\n\t\t\t    MAC_Out *out\n\t\t\t    );\ntypedef const struct {\n    MAC_Entry    *entry;\n    UINT16       inSize;\n    UINT16       outSize;\n    UINT16       offsetOfTypes;\n    UINT16       paramOffsets[2];\n    BYTE         types[6];\n} MAC_COMMAND_DESCRIPTOR_t;\nMAC_COMMAND_DESCRIPTOR_t _MACData = {\n    /* entry  */          &TPM2_MAC,\n    /* inSize */          (UINT16)(sizeof(MAC_In)),\n    /* outSize */         (UINT16)(sizeof(MAC_Out)),\n    /* offsetOfTypes */   offsetof(MAC_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(MAC_In, buffer)),\n\t\t\t   (UINT16)(offsetof(MAC_In, inScheme))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_MAC_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_DIGEST_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _MACDataAddress (&_MACData)\n#else\n#define _MACDataAddress 0\n#endif\n#if CC_GetRandom\n#include \"GetRandom_fp.h\"\ntypedef TPM_RC  (GetRandom_Entry)(\n\t\t\t\t  GetRandom_In *in,\n\t\t\t\t  GetRandom_Out *out\n\t\t\t\t  );\ntypedef const struct {\n    GetRandom_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    BYTE               types[4];\n} GetRandom_COMMAND_DESCRIPTOR_t;\nGetRandom_COMMAND_DESCRIPTOR_t _GetRandomData = {\n    /* entry  */          &TPM2_GetRandom,\n    /* inSize */          (UINT16)(sizeof(GetRandom_In)),\n    /* outSize */         (UINT16)(sizeof(GetRandom_Out)),\n    /* offsetOfTypes */   offsetof(GetRandom_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {UINT16_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_DIGEST_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _GetRandomDataAddress (&_GetRandomData)\n#else\n#define _GetRandomDataAddress 0\n#endif\n#if CC_StirRandom\n#include \"StirRandom_fp.h\"\ntypedef TPM_RC  (StirRandom_Entry)(\n\t\t\t\t   StirRandom_In *in\n\t\t\t\t   );\ntypedef const struct {\n    StirRandom_Entry    *entry;\n    UINT16              inSize;\n    UINT16              outSize;\n    UINT16              offsetOfTypes;\n    BYTE                types[3];\n} StirRandom_COMMAND_DESCRIPTOR_t;\nStirRandom_COMMAND_DESCRIPTOR_t _StirRandomData = {\n    /* entry  */          &TPM2_StirRandom,\n    /* inSize */          (UINT16)(sizeof(StirRandom_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(StirRandom_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPM2B_SENSITIVE_DATA_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _StirRandomDataAddress (&_StirRandomData)\n#else\n#define _StirRandomDataAddress 0\n#endif\n#if CC_HMAC_Start\n#include \"HMAC_Start_fp.h\"\ntypedef TPM_RC  (HMAC_Start_Entry)(\n\t\t\t\t   HMAC_Start_In *in,\n\t\t\t\t   HMAC_Start_Out *out\n\t\t\t\t   );\ntypedef const struct {\n    HMAC_Start_Entry    *entry;\n    UINT16              inSize;\n    UINT16              outSize;\n    UINT16              offsetOfTypes;\n    UINT16              paramOffsets[2];\n    BYTE                types[6];\n} HMAC_Start_COMMAND_DESCRIPTOR_t;\nHMAC_Start_COMMAND_DESCRIPTOR_t _HMAC_StartData = {\n    /* entry  */          &TPM2_HMAC_Start,\n    /* inSize */          (UINT16)(sizeof(HMAC_Start_In)),\n    /* outSize */         (UINT16)(sizeof(HMAC_Start_Out)),\n    /* offsetOfTypes */   offsetof(HMAC_Start_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(HMAC_Start_In, auth)),\n\t\t\t   (UINT16)(offsetof(HMAC_Start_In, hashAlg))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_AUTH_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_HASH_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMI_DH_OBJECT_H_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _HMAC_StartDataAddress (&_HMAC_StartData)\n#else\n#define _HMAC_StartDataAddress 0\n#endif\n#if CC_MAC_Start\n#include \"MAC_Start_fp.h\"\ntypedef TPM_RC  (MAC_Start_Entry)(\n\t\t\t\t  MAC_Start_In *in,\n\t\t\t\t  MAC_Start_Out *out\n\t\t\t\t  );\ntypedef const struct {\n    MAC_Start_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    UINT16             paramOffsets[2];\n    BYTE               types[6];\n} MAC_Start_COMMAND_DESCRIPTOR_t;\nMAC_Start_COMMAND_DESCRIPTOR_t _MAC_StartData = {\n    /* entry  */          &TPM2_MAC_Start,\n    /* inSize */          (UINT16)(sizeof(MAC_Start_In)),\n    /* outSize */         (UINT16)(sizeof(MAC_Start_Out)),\n    /* offsetOfTypes */   offsetof(MAC_Start_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(MAC_Start_In, auth)),\n\t\t\t   (UINT16)(offsetof(MAC_Start_In, inScheme))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_AUTH_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_MAC_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMI_DH_OBJECT_H_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _MAC_StartDataAddress (&_MAC_StartData)\n#else\n#define _MAC_StartDataAddress 0\n#endif\n#if CC_HashSequenceStart\n#include \"HashSequenceStart_fp.h\"\ntypedef TPM_RC  (HashSequenceStart_Entry)(\n\t\t\t\t\t  HashSequenceStart_In *in,\n\t\t\t\t\t  HashSequenceStart_Out *out\n\t\t\t\t\t  );\ntypedef const struct {\n    HashSequenceStart_Entry    *entry;\n    UINT16                     inSize;\n    UINT16                     outSize;\n    UINT16                     offsetOfTypes;\n    UINT16                     paramOffsets[1];\n    BYTE                       types[5];\n} HashSequenceStart_COMMAND_DESCRIPTOR_t;\nHashSequenceStart_COMMAND_DESCRIPTOR_t _HashSequenceStartData = {\n    /* entry  */          &TPM2_HashSequenceStart,\n    /* inSize */          (UINT16)(sizeof(HashSequenceStart_In)),\n    /* outSize */         (UINT16)(sizeof(HashSequenceStart_Out)),\n    /* offsetOfTypes */   offsetof(HashSequenceStart_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(HashSequenceStart_In, hashAlg))},\n    /* types */           {TPM2B_AUTH_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_HASH_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMI_DH_OBJECT_H_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _HashSequenceStartDataAddress (&_HashSequenceStartData)\n#else\n#define _HashSequenceStartDataAddress 0\n#endif\n#if CC_SequenceUpdate\n#include \"SequenceUpdate_fp.h\"\ntypedef TPM_RC  (SequenceUpdate_Entry)(\n\t\t\t\t       SequenceUpdate_In *in\n\t\t\t\t       );\ntypedef const struct {\n    SequenceUpdate_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[1];\n    BYTE                    types[4];\n} SequenceUpdate_COMMAND_DESCRIPTOR_t;\nSequenceUpdate_COMMAND_DESCRIPTOR_t _SequenceUpdateData = {\n    /* entry  */          &TPM2_SequenceUpdate,\n    /* inSize */          (UINT16)(sizeof(SequenceUpdate_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(SequenceUpdate_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(SequenceUpdate_In, buffer))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _SequenceUpdateDataAddress (&_SequenceUpdateData)\n#else\n#define _SequenceUpdateDataAddress 0\n#endif\n#if CC_SequenceComplete\n#include \"SequenceComplete_fp.h\"\ntypedef TPM_RC  (SequenceComplete_Entry)(\n\t\t\t\t\t SequenceComplete_In *in,\n\t\t\t\t\t SequenceComplete_Out *out\n\t\t\t\t\t );\ntypedef const struct {\n    SequenceComplete_Entry    *entry;\n    UINT16                    inSize;\n    UINT16                    outSize;\n    UINT16                    offsetOfTypes;\n    UINT16                    paramOffsets[3];\n    BYTE                      types[7];\n} SequenceComplete_COMMAND_DESCRIPTOR_t;\nSequenceComplete_COMMAND_DESCRIPTOR_t _SequenceCompleteData = {\n    /* entry  */          &TPM2_SequenceComplete,\n    /* inSize */          (UINT16)(sizeof(SequenceComplete_In)),\n    /* outSize */         (UINT16)(sizeof(SequenceComplete_Out)),\n    /* offsetOfTypes */   offsetof(SequenceComplete_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(SequenceComplete_In, buffer)),\n\t\t\t   (UINT16)(offsetof(SequenceComplete_In, hierarchy)),\n\t\t\t   (UINT16)(offsetof(SequenceComplete_Out, validation))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   TPMI_RH_HIERARCHY_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_DIGEST_P_MARSHAL,\n\t\t\t   TPMT_TK_HASHCHECK_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _SequenceCompleteDataAddress (&_SequenceCompleteData)\n#else\n#define _SequenceCompleteDataAddress 0\n#endif\n#if CC_EventSequenceComplete\n#include \"EventSequenceComplete_fp.h\"\ntypedef TPM_RC  (EventSequenceComplete_Entry)(\n\t\t\t\t\t      EventSequenceComplete_In *in,\n\t\t\t\t\t      EventSequenceComplete_Out *out\n\t\t\t\t\t      );\ntypedef const struct {\n    EventSequenceComplete_Entry    *entry;\n    UINT16                         inSize;\n    UINT16                         outSize;\n    UINT16                         offsetOfTypes;\n    UINT16                         paramOffsets[2];\n    BYTE                           types[6];\n} EventSequenceComplete_COMMAND_DESCRIPTOR_t;\nEventSequenceComplete_COMMAND_DESCRIPTOR_t _EventSequenceCompleteData = {\n    /* entry  */          &TPM2_EventSequenceComplete,\n    /* inSize */          (UINT16)(sizeof(EventSequenceComplete_In)),\n    /* outSize */         (UINT16)(sizeof(EventSequenceComplete_Out)),\n    /* offsetOfTypes */   offsetof(EventSequenceComplete_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(EventSequenceComplete_In, sequenceHandle)),\n\t\t\t   (UINT16)(offsetof(EventSequenceComplete_In, buffer))},\n    /* types */           {TPMI_DH_PCR_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPML_DIGEST_VALUES_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _EventSequenceCompleteDataAddress (&_EventSequenceCompleteData)\n#else\n#define _EventSequenceCompleteDataAddress 0\n#endif\n#if CC_Certify\n#include \"Certify_fp.h\"\ntypedef TPM_RC  (Certify_Entry)(\n\t\t\t\tCertify_In *in,\n\t\t\t\tCertify_Out *out\n\t\t\t\t);\ntypedef const struct {\n    Certify_Entry    *entry;\n    UINT16           inSize;\n    UINT16           outSize;\n    UINT16           offsetOfTypes;\n    UINT16           paramOffsets[4];\n    BYTE             types[8];\n} Certify_COMMAND_DESCRIPTOR_t;\nCertify_COMMAND_DESCRIPTOR_t _CertifyData = {\n    /* entry  */          &TPM2_Certify,\n    /* inSize */          (UINT16)(sizeof(Certify_In)),\n    /* outSize */         (UINT16)(sizeof(Certify_Out)),\n    /* offsetOfTypes */   offsetof(Certify_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Certify_In, signHandle)),\n\t\t\t   (UINT16)(offsetof(Certify_In, qualifyingData)),\n\t\t\t   (UINT16)(offsetof(Certify_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(Certify_Out, signature))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ATTEST_P_MARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _CertifyDataAddress (&_CertifyData)\n#else\n#define _CertifyDataAddress 0\n#endif\n#if CC_CertifyCreation\n#include \"CertifyCreation_fp.h\"\ntypedef TPM_RC  (CertifyCreation_Entry)(\n\t\t\t\t\tCertifyCreation_In *in,\n\t\t\t\t\tCertifyCreation_Out *out\n\t\t\t\t\t);\ntypedef const struct {\n    CertifyCreation_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    UINT16                   paramOffsets[6];\n    BYTE                     types[10];\n} CertifyCreation_COMMAND_DESCRIPTOR_t;\nCertifyCreation_COMMAND_DESCRIPTOR_t _CertifyCreationData = {\n    /* entry  */          &TPM2_CertifyCreation,\n    /* inSize */          (UINT16)(sizeof(CertifyCreation_In)),\n    /* outSize */         (UINT16)(sizeof(CertifyCreation_Out)),\n    /* offsetOfTypes */   offsetof(CertifyCreation_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(CertifyCreation_In, objectHandle)),\n\t\t\t   (UINT16)(offsetof(CertifyCreation_In, qualifyingData)),\n\t\t\t   (UINT16)(offsetof(CertifyCreation_In, creationHash)),\n\t\t\t   (UINT16)(offsetof(CertifyCreation_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(CertifyCreation_In, creationTicket)),\n\t\t\t   (UINT16)(offsetof(CertifyCreation_Out, signature))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMT_TK_CREATION_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ATTEST_P_MARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _CertifyCreationDataAddress (&_CertifyCreationData)\n#else\n#define _CertifyCreationDataAddress 0\n#endif\n#if CC_Quote\n#include \"Quote_fp.h\"\ntypedef TPM_RC  (Quote_Entry)(\n\t\t\t      Quote_In *in,\n\t\t\t      Quote_Out *out\n\t\t\t      );\ntypedef const struct {\n    Quote_Entry    *entry;\n    UINT16         inSize;\n    UINT16         outSize;\n    UINT16         offsetOfTypes;\n    UINT16         paramOffsets[4];\n    BYTE           types[8];\n} Quote_COMMAND_DESCRIPTOR_t;\nQuote_COMMAND_DESCRIPTOR_t _QuoteData = {\n    /* entry  */          &TPM2_Quote,\n    /* inSize */          (UINT16)(sizeof(Quote_In)),\n    /* outSize */         (UINT16)(sizeof(Quote_Out)),\n    /* offsetOfTypes */   offsetof(Quote_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Quote_In, qualifyingData)),\n\t\t\t   (UINT16)(offsetof(Quote_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(Quote_In, PCRselect)),\n\t\t\t   (UINT16)(offsetof(Quote_Out, signature))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPML_PCR_SELECTION_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ATTEST_P_MARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _QuoteDataAddress (&_QuoteData)\n#else\n#define _QuoteDataAddress 0\n#endif\n#if CC_GetSessionAuditDigest\n#include \"GetSessionAuditDigest_fp.h\"\ntypedef TPM_RC  (GetSessionAuditDigest_Entry)(\n\t\t\t\t\t      GetSessionAuditDigest_In *in,\n\t\t\t\t\t      GetSessionAuditDigest_Out *out\n\t\t\t\t\t      );\ntypedef const struct {\n    GetSessionAuditDigest_Entry    *entry;\n    UINT16                         inSize;\n    UINT16                         outSize;\n    UINT16                         offsetOfTypes;\n    UINT16                         paramOffsets[5];\n    BYTE                           types[9];\n} GetSessionAuditDigest_COMMAND_DESCRIPTOR_t;\nGetSessionAuditDigest_COMMAND_DESCRIPTOR_t _GetSessionAuditDigestData = {\n    /* entry  */          &TPM2_GetSessionAuditDigest,\n    /* inSize */          (UINT16)(sizeof(GetSessionAuditDigest_In)),\n    /* outSize */         (UINT16)(sizeof(GetSessionAuditDigest_Out)),\n    /* offsetOfTypes */   offsetof(GetSessionAuditDigest_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(GetSessionAuditDigest_In, signHandle)),\n\t\t\t   (UINT16)(offsetof(GetSessionAuditDigest_In, sessionHandle)),\n\t\t\t   (UINT16)(offsetof(GetSessionAuditDigest_In, qualifyingData)),\n\t\t\t   (UINT16)(offsetof(GetSessionAuditDigest_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(GetSessionAuditDigest_Out, signature))},\n    /* types */           {TPMI_RH_ENDORSEMENT_H_UNMARSHAL,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMI_SH_HMAC_H_UNMARSHAL,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ATTEST_P_MARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _GetSessionAuditDigestDataAddress (&_GetSessionAuditDigestData)\n#else\n#define _GetSessionAuditDigestDataAddress 0\n#endif\n#if CC_GetCommandAuditDigest\n#include \"GetCommandAuditDigest_fp.h\"\ntypedef TPM_RC  (GetCommandAuditDigest_Entry)(\n\t\t\t\t\t      GetCommandAuditDigest_In *in,\n\t\t\t\t\t      GetCommandAuditDigest_Out *out\n\t\t\t\t\t      );\ntypedef const struct {\n    GetCommandAuditDigest_Entry    *entry;\n    UINT16                         inSize;\n    UINT16                         outSize;\n    UINT16                         offsetOfTypes;\n    UINT16                         paramOffsets[4];\n    BYTE                           types[8];\n} GetCommandAuditDigest_COMMAND_DESCRIPTOR_t;\nGetCommandAuditDigest_COMMAND_DESCRIPTOR_t _GetCommandAuditDigestData = {\n    /* entry  */          &TPM2_GetCommandAuditDigest,\n    /* inSize */          (UINT16)(sizeof(GetCommandAuditDigest_In)),\n    /* outSize */         (UINT16)(sizeof(GetCommandAuditDigest_Out)),\n    /* offsetOfTypes */   offsetof(GetCommandAuditDigest_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(GetCommandAuditDigest_In, signHandle)),\n\t\t\t   (UINT16)(offsetof(GetCommandAuditDigest_In, qualifyingData)),\n\t\t\t   (UINT16)(offsetof(GetCommandAuditDigest_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(GetCommandAuditDigest_Out, signature))},\n    /* types */           {TPMI_RH_ENDORSEMENT_H_UNMARSHAL,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ATTEST_P_MARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _GetCommandAuditDigestDataAddress (&_GetCommandAuditDigestData)\n#else\n#define _GetCommandAuditDigestDataAddress 0\n#endif\n#if CC_GetTime\n#include \"GetTime_fp.h\"\ntypedef TPM_RC  (GetTime_Entry)(\n\t\t\t\tGetTime_In *in,\n\t\t\t\tGetTime_Out *out\n\t\t\t\t);\ntypedef const struct {\n    GetTime_Entry    *entry;\n    UINT16           inSize;\n    UINT16           outSize;\n    UINT16           offsetOfTypes;\n    UINT16           paramOffsets[4];\n    BYTE             types[8];\n} GetTime_COMMAND_DESCRIPTOR_t;\nGetTime_COMMAND_DESCRIPTOR_t _GetTimeData = {\n    /* entry  */          &TPM2_GetTime,\n    /* inSize */          (UINT16)(sizeof(GetTime_In)),\n    /* outSize */         (UINT16)(sizeof(GetTime_Out)),\n    /* offsetOfTypes */   offsetof(GetTime_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(GetTime_In, signHandle)),\n\t\t\t   (UINT16)(offsetof(GetTime_In, qualifyingData)),\n\t\t\t   (UINT16)(offsetof(GetTime_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(GetTime_Out, signature))},\n    /* types */           {TPMI_RH_ENDORSEMENT_H_UNMARSHAL,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ATTEST_P_MARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _GetTimeDataAddress (&_GetTimeData)\n#else\n#define _GetTimeDataAddress 0\n#endif\n#if CC_CertifyX509\n#include \"CertifyX509_fp.h\"\ntypedef TPM_RC  (CertifyX509_Entry)(\n\t\t\t\t    CertifyX509_In              *in,\n\t\t\t\t    CertifyX509_Out             *out\n\t\t\t\t    );\ntypedef const struct {\n    CertifyX509_Entry       *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[6];\n    BYTE                    types[10];\n} CertifyX509_COMMAND_DESCRIPTOR_t;\nCertifyX509_COMMAND_DESCRIPTOR_t _CertifyX509Data = {\n\t/* entry         */     &TPM2_CertifyX509,\n\t/* inSize        */     (UINT16)(sizeof(CertifyX509_In)),\n\t/* outSize       */     (UINT16)(sizeof(CertifyX509_Out)),\n\t/* offsetOfTypes */     offsetof(CertifyX509_COMMAND_DESCRIPTOR_t, types),\n\t/* offsets       */     {(UINT16)(offsetof(CertifyX509_In, signHandle)),\n\t\t\t\t (UINT16)(offsetof(CertifyX509_In, reserved)),\n\t\t\t\t (UINT16)(offsetof(CertifyX509_In, inScheme)),\n\t\t\t\t (UINT16)(offsetof(CertifyX509_In, partialCertificate)),\n\t\t\t\t (UINT16)(offsetof(CertifyX509_Out, tbsDigest)),\n\t\t\t\t (UINT16)(offsetof(CertifyX509_Out, signature))},\n\t/* types         */     {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t\t TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t\t TPM2B_DATA_P_UNMARSHAL,\n\t\t\t\t TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t\t TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t\t END_OF_LIST,\n\t\t\t\t TPM2B_MAX_BUFFER_P_MARSHAL,\n\t\t\t\t TPM2B_DIGEST_P_MARSHAL,\n\t\t\t\t TPMT_SIGNATURE_P_MARSHAL,\n\t\t\t\t END_OF_LIST}\n};\n#define _CertifyX509DataAddress (&_CertifyX509Data)\n#else\n#define _CertifyX509DataAddress 0\n#endif // CC_CertifyX509\n#if CC_Commit\n#include \"Commit_fp.h\"\ntypedef TPM_RC  (Commit_Entry)(\n\t\t\t       Commit_In *in,\n\t\t\t       Commit_Out *out\n\t\t\t       );\ntypedef const struct {\n    Commit_Entry    *entry;\n    UINT16          inSize;\n    UINT16          outSize;\n    UINT16          offsetOfTypes;\n    UINT16          paramOffsets[6];\n    BYTE            types[10];\n} Commit_COMMAND_DESCRIPTOR_t;\nCommit_COMMAND_DESCRIPTOR_t _CommitData = {\n    /* entry  */          &TPM2_Commit,\n    /* inSize */          (UINT16)(sizeof(Commit_In)),\n    /* outSize */         (UINT16)(sizeof(Commit_Out)),\n    /* offsetOfTypes */   offsetof(Commit_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Commit_In, P1)),\n\t\t\t   (UINT16)(offsetof(Commit_In, s2)),\n\t\t\t   (UINT16)(offsetof(Commit_In, y2)),\n\t\t\t   (UINT16)(offsetof(Commit_Out, L)),\n\t\t\t   (UINT16)(offsetof(Commit_Out, E)),\n\t\t\t   (UINT16)(offsetof(Commit_Out, counter))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_ECC_POINT_P_UNMARSHAL,\n\t\t\t   TPM2B_SENSITIVE_DATA_P_UNMARSHAL,\n\t\t\t   TPM2B_ECC_PARAMETER_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t   TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t   TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t   UINT16_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _CommitDataAddress (&_CommitData)\n#else\n#define _CommitDataAddress 0\n#endif\n#if CC_EC_Ephemeral\n#include \"EC_Ephemeral_fp.h\"\ntypedef TPM_RC  (EC_Ephemeral_Entry)(\n\t\t\t\t     EC_Ephemeral_In *in,\n\t\t\t\t     EC_Ephemeral_Out *out\n\t\t\t\t     );\ntypedef const struct {\n    EC_Ephemeral_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[1];\n    BYTE                  types[5];\n} EC_Ephemeral_COMMAND_DESCRIPTOR_t;\nEC_Ephemeral_COMMAND_DESCRIPTOR_t _EC_EphemeralData = {\n    /* entry  */          &TPM2_EC_Ephemeral,\n    /* inSize */          (UINT16)(sizeof(EC_Ephemeral_In)),\n    /* outSize */         (UINT16)(sizeof(EC_Ephemeral_Out)),\n    /* offsetOfTypes */   offsetof(EC_Ephemeral_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(EC_Ephemeral_Out, counter))},\n    /* types */           {TPMI_ECC_CURVE_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ECC_POINT_P_MARSHAL,\n\t\t\t   UINT16_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _EC_EphemeralDataAddress (&_EC_EphemeralData)\n#else\n#define _EC_EphemeralDataAddress 0\n#endif\n#if CC_VerifySignature\n#include \"VerifySignature_fp.h\"\ntypedef TPM_RC  (VerifySignature_Entry)(\n\t\t\t\t\tVerifySignature_In *in,\n\t\t\t\t\tVerifySignature_Out *out\n\t\t\t\t\t);\ntypedef const struct {\n    VerifySignature_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    UINT16                   paramOffsets[2];\n    BYTE                     types[6];\n} VerifySignature_COMMAND_DESCRIPTOR_t;\nVerifySignature_COMMAND_DESCRIPTOR_t _VerifySignatureData = {\n    /* entry  */          &TPM2_VerifySignature,\n    /* inSize */          (UINT16)(sizeof(VerifySignature_In)),\n    /* outSize */         (UINT16)(sizeof(VerifySignature_Out)),\n    /* offsetOfTypes */   offsetof(VerifySignature_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(VerifySignature_In, digest)),\n\t\t\t   (UINT16)(offsetof(VerifySignature_In, signature))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMT_TK_VERIFIED_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _VerifySignatureDataAddress (&_VerifySignatureData)\n#else\n#define _VerifySignatureDataAddress 0\n#endif\n#if CC_Sign\n#include \"Sign_fp.h\"\ntypedef TPM_RC  (Sign_Entry)(\n\t\t\t     Sign_In *in,\n\t\t\t     Sign_Out *out\n\t\t\t     );\ntypedef const struct {\n    Sign_Entry    *entry;\n    UINT16        inSize;\n    UINT16        outSize;\n    UINT16        offsetOfTypes;\n    UINT16        paramOffsets[3];\n    BYTE          types[7];\n} Sign_COMMAND_DESCRIPTOR_t;\nSign_COMMAND_DESCRIPTOR_t _SignData = {\n    /* entry  */          &TPM2_Sign,\n    /* inSize */          (UINT16)(sizeof(Sign_In)),\n    /* outSize */         (UINT16)(sizeof(Sign_Out)),\n    /* offsetOfTypes */   offsetof(Sign_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Sign_In, digest)),\n\t\t\t   (UINT16)(offsetof(Sign_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(Sign_In, validation))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMT_TK_HASHCHECK_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMT_SIGNATURE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _SignDataAddress (&_SignData)\n#else\n#define _SignDataAddress 0\n#endif\n#if CC_SetCommandCodeAuditStatus\n#include \"SetCommandCodeAuditStatus_fp.h\"\ntypedef TPM_RC  (SetCommandCodeAuditStatus_Entry)(\n\t\t\t\t\t\t  SetCommandCodeAuditStatus_In *in\n\t\t\t\t\t\t  );\ntypedef const struct {\n    SetCommandCodeAuditStatus_Entry    *entry;\n    UINT16                             inSize;\n    UINT16                             outSize;\n    UINT16                             offsetOfTypes;\n    UINT16                             paramOffsets[3];\n    BYTE                               types[6];\n} SetCommandCodeAuditStatus_COMMAND_DESCRIPTOR_t;\nSetCommandCodeAuditStatus_COMMAND_DESCRIPTOR_t _SetCommandCodeAuditStatusData = {\n    /* entry  */          &TPM2_SetCommandCodeAuditStatus,\n    /* inSize */          (UINT16)(sizeof(SetCommandCodeAuditStatus_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(SetCommandCodeAuditStatus_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(SetCommandCodeAuditStatus_In, auditAlg)),\n\t\t\t   (UINT16)(offsetof(SetCommandCodeAuditStatus_In, setList)),\n\t\t\t   (UINT16)(offsetof(SetCommandCodeAuditStatus_In, clearList))},\n    /* types */           {TPMI_RH_PROVISION_H_UNMARSHAL,\n\t\t\t   TPMI_ALG_HASH_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPML_CC_P_UNMARSHAL,\n\t\t\t   TPML_CC_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _SetCommandCodeAuditStatusDataAddress (&_SetCommandCodeAuditStatusData)\n#else\n#define _SetCommandCodeAuditStatusDataAddress 0\n#endif\n#if CC_PCR_Extend\n#include \"PCR_Extend_fp.h\"\ntypedef TPM_RC  (PCR_Extend_Entry)(\n\t\t\t\t   PCR_Extend_In *in\n\t\t\t\t   );\ntypedef const struct {\n    PCR_Extend_Entry    *entry;\n    UINT16              inSize;\n    UINT16              outSize;\n    UINT16              offsetOfTypes;\n    UINT16              paramOffsets[1];\n    BYTE                types[4];\n} PCR_Extend_COMMAND_DESCRIPTOR_t;\nPCR_Extend_COMMAND_DESCRIPTOR_t _PCR_ExtendData = {\n    /* entry  */          &TPM2_PCR_Extend,\n    /* inSize */          (UINT16)(sizeof(PCR_Extend_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PCR_Extend_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PCR_Extend_In, digests))},\n    /* types */           {TPMI_DH_PCR_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPML_DIGEST_VALUES_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PCR_ExtendDataAddress (&_PCR_ExtendData)\n#else\n#define _PCR_ExtendDataAddress 0\n#endif\n#if CC_PCR_Event\n#include \"PCR_Event_fp.h\"\ntypedef TPM_RC  (PCR_Event_Entry)(\n\t\t\t\t  PCR_Event_In *in,\n\t\t\t\t  PCR_Event_Out *out\n\t\t\t\t  );\ntypedef const struct {\n    PCR_Event_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    UINT16             paramOffsets[1];\n    BYTE               types[5];\n} PCR_Event_COMMAND_DESCRIPTOR_t;\nPCR_Event_COMMAND_DESCRIPTOR_t _PCR_EventData = {\n    /* entry  */          &TPM2_PCR_Event,\n    /* inSize */          (UINT16)(sizeof(PCR_Event_In)),\n    /* outSize */         (UINT16)(sizeof(PCR_Event_Out)),\n    /* offsetOfTypes */   offsetof(PCR_Event_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PCR_Event_In, eventData))},\n    /* types */           {TPMI_DH_PCR_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_EVENT_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPML_DIGEST_VALUES_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _PCR_EventDataAddress (&_PCR_EventData)\n#else\n#define _PCR_EventDataAddress 0\n#endif\n#if CC_PCR_Read\n#include \"PCR_Read_fp.h\"\ntypedef TPM_RC  (PCR_Read_Entry)(\n\t\t\t\t PCR_Read_In *in,\n\t\t\t\t PCR_Read_Out *out\n\t\t\t\t );\ntypedef const struct {\n    PCR_Read_Entry    *entry;\n    UINT16            inSize;\n    UINT16            outSize;\n    UINT16            offsetOfTypes;\n    UINT16            paramOffsets[2];\n    BYTE              types[6];\n} PCR_Read_COMMAND_DESCRIPTOR_t;\nPCR_Read_COMMAND_DESCRIPTOR_t _PCR_ReadData = {\n    /* entry  */          &TPM2_PCR_Read,\n    /* inSize */          (UINT16)(sizeof(PCR_Read_In)),\n    /* outSize */         (UINT16)(sizeof(PCR_Read_Out)),\n    /* offsetOfTypes */   offsetof(PCR_Read_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PCR_Read_Out, pcrSelectionOut)),\n\t\t\t   (UINT16)(offsetof(PCR_Read_Out, pcrValues))},\n    /* types */           {TPML_PCR_SELECTION_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   UINT32_P_MARSHAL,\n\t\t\t   TPML_PCR_SELECTION_P_MARSHAL,\n\t\t\t   TPML_DIGEST_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _PCR_ReadDataAddress (&_PCR_ReadData)\n#else\n#define _PCR_ReadDataAddress 0\n#endif\n#if CC_PCR_Allocate\n#include \"PCR_Allocate_fp.h\"\ntypedef TPM_RC  (PCR_Allocate_Entry)(\n\t\t\t\t     PCR_Allocate_In *in,\n\t\t\t\t     PCR_Allocate_Out *out\n\t\t\t\t     );\ntypedef const struct {\n    PCR_Allocate_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[4];\n    BYTE                  types[8];\n} PCR_Allocate_COMMAND_DESCRIPTOR_t;\nPCR_Allocate_COMMAND_DESCRIPTOR_t _PCR_AllocateData = {\n    /* entry  */          &TPM2_PCR_Allocate,\n    /* inSize */          (UINT16)(sizeof(PCR_Allocate_In)),\n    /* outSize */         (UINT16)(sizeof(PCR_Allocate_Out)),\n    /* offsetOfTypes */   offsetof(PCR_Allocate_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PCR_Allocate_In, pcrAllocation)),\n\t\t\t   (UINT16)(offsetof(PCR_Allocate_Out, maxPCR)),\n\t\t\t   (UINT16)(offsetof(PCR_Allocate_Out, sizeNeeded)),\n\t\t\t   (UINT16)(offsetof(PCR_Allocate_Out, sizeAvailable))},\n    /* types */           {TPMI_RH_PLATFORM_H_UNMARSHAL,\n\t\t\t   TPML_PCR_SELECTION_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMI_YES_NO_P_MARSHAL,\n\t\t\t   UINT32_P_MARSHAL,\n\t\t\t   UINT32_P_MARSHAL,\n\t\t\t   UINT32_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _PCR_AllocateDataAddress (&_PCR_AllocateData)\n#else\n#define _PCR_AllocateDataAddress 0\n#endif\n#if CC_PCR_SetAuthPolicy\n#include \"PCR_SetAuthPolicy_fp.h\"\ntypedef TPM_RC  (PCR_SetAuthPolicy_Entry)(\n\t\t\t\t\t  PCR_SetAuthPolicy_In *in\n\t\t\t\t\t  );\ntypedef const struct {\n    PCR_SetAuthPolicy_Entry    *entry;\n    UINT16                     inSize;\n    UINT16                     outSize;\n    UINT16                     offsetOfTypes;\n    UINT16                     paramOffsets[3];\n    BYTE                       types[6];\n} PCR_SetAuthPolicy_COMMAND_DESCRIPTOR_t;\nPCR_SetAuthPolicy_COMMAND_DESCRIPTOR_t _PCR_SetAuthPolicyData = {\n    /* entry  */          &TPM2_PCR_SetAuthPolicy,\n    /* inSize */          (UINT16)(sizeof(PCR_SetAuthPolicy_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PCR_SetAuthPolicy_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PCR_SetAuthPolicy_In, authPolicy)),\n\t\t\t   (UINT16)(offsetof(PCR_SetAuthPolicy_In, hashAlg)),\n\t\t\t   (UINT16)(offsetof(PCR_SetAuthPolicy_In, pcrNum))},\n    /* types */           {TPMI_RH_PLATFORM_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_HASH_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMI_DH_PCR_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PCR_SetAuthPolicyDataAddress (&_PCR_SetAuthPolicyData)\n#else\n#define _PCR_SetAuthPolicyDataAddress 0\n#endif\n#if CC_PCR_SetAuthValue\n#include \"PCR_SetAuthValue_fp.h\"\ntypedef TPM_RC  (PCR_SetAuthValue_Entry)(\n\t\t\t\t\t PCR_SetAuthValue_In *in\n\t\t\t\t\t );\ntypedef const struct {\n    PCR_SetAuthValue_Entry    *entry;\n    UINT16                    inSize;\n    UINT16                    outSize;\n    UINT16                    offsetOfTypes;\n    UINT16                    paramOffsets[1];\n    BYTE                      types[4];\n} PCR_SetAuthValue_COMMAND_DESCRIPTOR_t;\nPCR_SetAuthValue_COMMAND_DESCRIPTOR_t _PCR_SetAuthValueData = {\n    /* entry  */          &TPM2_PCR_SetAuthValue,\n    /* inSize */          (UINT16)(sizeof(PCR_SetAuthValue_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PCR_SetAuthValue_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PCR_SetAuthValue_In, auth))},\n    /* types */           {TPMI_DH_PCR_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PCR_SetAuthValueDataAddress (&_PCR_SetAuthValueData)\n#else\n#define _PCR_SetAuthValueDataAddress 0\n#endif\n#if CC_PCR_Reset\n#include \"PCR_Reset_fp.h\"\ntypedef TPM_RC  (PCR_Reset_Entry)(\n\t\t\t\t  PCR_Reset_In *in\n\t\t\t\t  );\ntypedef const struct {\n    PCR_Reset_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    BYTE               types[3];\n} PCR_Reset_COMMAND_DESCRIPTOR_t;\nPCR_Reset_COMMAND_DESCRIPTOR_t _PCR_ResetData = {\n    /* entry  */          &TPM2_PCR_Reset,\n    /* inSize */          (UINT16)(sizeof(PCR_Reset_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PCR_Reset_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_DH_PCR_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PCR_ResetDataAddress (&_PCR_ResetData)\n#else\n#define _PCR_ResetDataAddress 0\n#endif\n#if CC_PolicySigned\n#include \"PolicySigned_fp.h\"\ntypedef TPM_RC  (PolicySigned_Entry)(\n\t\t\t\t     PolicySigned_In *in,\n\t\t\t\t     PolicySigned_Out *out\n\t\t\t\t     );\ntypedef const struct {\n    PolicySigned_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[7];\n    BYTE                  types[11];\n} PolicySigned_COMMAND_DESCRIPTOR_t;\nPolicySigned_COMMAND_DESCRIPTOR_t _PolicySignedData = {\n    /* entry  */          &TPM2_PolicySigned,\n    /* inSize */          (UINT16)(sizeof(PolicySigned_In)),\n    /* outSize */         (UINT16)(sizeof(PolicySigned_Out)),\n    /* offsetOfTypes */   offsetof(PolicySigned_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicySigned_In, policySession)),\n\t\t\t   (UINT16)(offsetof(PolicySigned_In, nonceTPM)),\n\t\t\t   (UINT16)(offsetof(PolicySigned_In, cpHashA)),\n\t\t\t   (UINT16)(offsetof(PolicySigned_In, policyRef)),\n\t\t\t   (UINT16)(offsetof(PolicySigned_In, expiration)),\n\t\t\t   (UINT16)(offsetof(PolicySigned_In, auth)),\n\t\t\t   (UINT16)(offsetof(PolicySigned_Out, policyTicket))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_NONCE_P_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPM2B_NONCE_P_UNMARSHAL,\n\t\t\t   INT32_P_UNMARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_TIMEOUT_P_MARSHAL,\n\t\t\t   TPMT_TK_AUTH_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicySignedDataAddress (&_PolicySignedData)\n#else\n#define _PolicySignedDataAddress 0\n#endif\n#if CC_PolicySecret\n#include \"PolicySecret_fp.h\"\ntypedef TPM_RC  (PolicySecret_Entry)(\n\t\t\t\t     PolicySecret_In *in,\n\t\t\t\t     PolicySecret_Out *out\n\t\t\t\t     );\ntypedef const struct {\n    PolicySecret_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[6];\n    BYTE                  types[10];\n} PolicySecret_COMMAND_DESCRIPTOR_t;\nPolicySecret_COMMAND_DESCRIPTOR_t _PolicySecretData = {\n    /* entry  */          &TPM2_PolicySecret,\n    /* inSize */          (UINT16)(sizeof(PolicySecret_In)),\n    /* outSize */         (UINT16)(sizeof(PolicySecret_Out)),\n    /* offsetOfTypes */   offsetof(PolicySecret_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicySecret_In, policySession)),\n\t\t\t   (UINT16)(offsetof(PolicySecret_In, nonceTPM)),\n\t\t\t   (UINT16)(offsetof(PolicySecret_In, cpHashA)),\n\t\t\t   (UINT16)(offsetof(PolicySecret_In, policyRef)),\n\t\t\t   (UINT16)(offsetof(PolicySecret_In, expiration)),\n\t\t\t   (UINT16)(offsetof(PolicySecret_Out, policyTicket))},\n    /* types */           {TPMI_DH_ENTITY_H_UNMARSHAL,\n\t\t\t   TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_NONCE_P_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPM2B_NONCE_P_UNMARSHAL,\n\t\t\t   INT32_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_TIMEOUT_P_MARSHAL,\n\t\t\t   TPMT_TK_AUTH_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicySecretDataAddress (&_PolicySecretData)\n#else\n#define _PolicySecretDataAddress 0\n#endif\n#if CC_PolicyTicket\n#include \"PolicyTicket_fp.h\"\ntypedef TPM_RC  (PolicyTicket_Entry)(\n\t\t\t\t     PolicyTicket_In *in\n\t\t\t\t     );\ntypedef const struct {\n    PolicyTicket_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[5];\n    BYTE                  types[8];\n} PolicyTicket_COMMAND_DESCRIPTOR_t;\nPolicyTicket_COMMAND_DESCRIPTOR_t _PolicyTicketData = {\n    /* entry  */          &TPM2_PolicyTicket,\n    /* inSize */          (UINT16)(sizeof(PolicyTicket_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyTicket_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyTicket_In, timeout)),\n\t\t\t   (UINT16)(offsetof(PolicyTicket_In, cpHashA)),\n\t\t\t   (UINT16)(offsetof(PolicyTicket_In, policyRef)),\n\t\t\t   (UINT16)(offsetof(PolicyTicket_In, authName)),\n\t\t\t   (UINT16)(offsetof(PolicyTicket_In, ticket))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_TIMEOUT_P_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPM2B_NONCE_P_UNMARSHAL,\n\t\t\t   TPM2B_NAME_P_UNMARSHAL,\n\t\t\t   TPMT_TK_AUTH_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyTicketDataAddress (&_PolicyTicketData)\n#else\n#define _PolicyTicketDataAddress 0\n#endif\n#if CC_PolicyOR\n#include \"PolicyOR_fp.h\"\ntypedef TPM_RC  (PolicyOR_Entry)(\n\t\t\t\t PolicyOR_In *in\n\t\t\t\t );\ntypedef const struct {\n    PolicyOR_Entry    *entry;\n    UINT16            inSize;\n    UINT16            outSize;\n    UINT16            offsetOfTypes;\n    UINT16            paramOffsets[1];\n    BYTE              types[4];\n} PolicyOR_COMMAND_DESCRIPTOR_t;\nPolicyOR_COMMAND_DESCRIPTOR_t _PolicyORData = {\n    /* entry  */          &TPM2_PolicyOR,\n    /* inSize */          (UINT16)(sizeof(PolicyOR_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyOR_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyOR_In, pHashList))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPML_DIGEST_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyORDataAddress (&_PolicyORData)\n#else\n#define _PolicyORDataAddress 0\n#endif\n#if CC_PolicyPCR\n#include \"PolicyPCR_fp.h\"\ntypedef TPM_RC  (PolicyPCR_Entry)(\n\t\t\t\t  PolicyPCR_In *in\n\t\t\t\t  );\ntypedef const struct {\n    PolicyPCR_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    UINT16             paramOffsets[2];\n    BYTE               types[5];\n} PolicyPCR_COMMAND_DESCRIPTOR_t;\nPolicyPCR_COMMAND_DESCRIPTOR_t _PolicyPCRData = {\n    /* entry  */          &TPM2_PolicyPCR,\n    /* inSize */          (UINT16)(sizeof(PolicyPCR_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyPCR_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyPCR_In, pcrDigest)),\n\t\t\t   (UINT16)(offsetof(PolicyPCR_In, pcrs))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPML_PCR_SELECTION_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyPCRDataAddress (&_PolicyPCRData)\n#else\n#define _PolicyPCRDataAddress 0\n#endif\n#if CC_PolicyLocality\n#include \"PolicyLocality_fp.h\"\ntypedef TPM_RC  (PolicyLocality_Entry)(\n\t\t\t\t       PolicyLocality_In *in\n\t\t\t\t       );\ntypedef const struct {\n    PolicyLocality_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[1];\n    BYTE                    types[4];\n} PolicyLocality_COMMAND_DESCRIPTOR_t;\nPolicyLocality_COMMAND_DESCRIPTOR_t _PolicyLocalityData = {\n    /* entry  */          &TPM2_PolicyLocality,\n    /* inSize */          (UINT16)(sizeof(PolicyLocality_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyLocality_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyLocality_In, locality))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPMA_LOCALITY_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyLocalityDataAddress (&_PolicyLocalityData)\n#else\n#define _PolicyLocalityDataAddress 0\n#endif\n#if CC_PolicyNV\n#include \"PolicyNV_fp.h\"\ntypedef TPM_RC  (PolicyNV_Entry)(\n\t\t\t\t PolicyNV_In *in\n\t\t\t\t );\ntypedef const struct {\n    PolicyNV_Entry    *entry;\n    UINT16            inSize;\n    UINT16            outSize;\n    UINT16            offsetOfTypes;\n    UINT16            paramOffsets[5];\n    BYTE              types[8];\n} PolicyNV_COMMAND_DESCRIPTOR_t;\nPolicyNV_COMMAND_DESCRIPTOR_t _PolicyNVData = {\n    /* entry  */          &TPM2_PolicyNV,\n    /* inSize */          (UINT16)(sizeof(PolicyNV_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyNV_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyNV_In, nvIndex)),\n\t\t\t   (UINT16)(offsetof(PolicyNV_In, policySession)),\n\t\t\t   (UINT16)(offsetof(PolicyNV_In, operandB)),\n\t\t\t   (UINT16)(offsetof(PolicyNV_In, offset)),\n\t\t\t   (UINT16)(offsetof(PolicyNV_In, operation))},\n    /* types */           {TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_OPERAND_P_UNMARSHAL,\n\t\t\t   UINT16_P_UNMARSHAL,\n\t\t\t   TPM_EO_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyNVDataAddress (&_PolicyNVData)\n#else\n#define _PolicyNVDataAddress 0\n#endif\n#if CC_PolicyCounterTimer\n#include \"PolicyCounterTimer_fp.h\"\ntypedef TPM_RC  (PolicyCounterTimer_Entry)(\n\t\t\t\t\t   PolicyCounterTimer_In *in\n\t\t\t\t\t   );\ntypedef const struct {\n    PolicyCounterTimer_Entry    *entry;\n    UINT16                      inSize;\n    UINT16                      outSize;\n    UINT16                      offsetOfTypes;\n    UINT16                      paramOffsets[3];\n    BYTE                        types[6];\n} PolicyCounterTimer_COMMAND_DESCRIPTOR_t;\nPolicyCounterTimer_COMMAND_DESCRIPTOR_t _PolicyCounterTimerData = {\n    /* entry  */          &TPM2_PolicyCounterTimer,\n    /* inSize */          (UINT16)(sizeof(PolicyCounterTimer_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyCounterTimer_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyCounterTimer_In, operandB)),\n\t\t\t   (UINT16)(offsetof(PolicyCounterTimer_In, offset)),\n\t\t\t   (UINT16)(offsetof(PolicyCounterTimer_In, operation))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_OPERAND_P_UNMARSHAL,\n\t\t\t   UINT16_P_UNMARSHAL,\n\t\t\t   TPM_EO_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyCounterTimerDataAddress (&_PolicyCounterTimerData)\n#else\n#define _PolicyCounterTimerDataAddress 0\n#endif\n#if CC_PolicyCommandCode\n#include \"PolicyCommandCode_fp.h\"\ntypedef TPM_RC  (PolicyCommandCode_Entry)(\n\t\t\t\t\t  PolicyCommandCode_In *in\n\t\t\t\t\t  );\ntypedef const struct {\n    PolicyCommandCode_Entry    *entry;\n    UINT16                     inSize;\n    UINT16                     outSize;\n    UINT16                     offsetOfTypes;\n    UINT16                     paramOffsets[1];\n    BYTE                       types[4];\n} PolicyCommandCode_COMMAND_DESCRIPTOR_t;\nPolicyCommandCode_COMMAND_DESCRIPTOR_t _PolicyCommandCodeData = {\n    /* entry  */          &TPM2_PolicyCommandCode,\n    /* inSize */          (UINT16)(sizeof(PolicyCommandCode_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyCommandCode_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyCommandCode_In, code))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM_CC_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyCommandCodeDataAddress (&_PolicyCommandCodeData)\n#else\n#define _PolicyCommandCodeDataAddress 0\n#endif\n#if CC_PolicyPhysicalPresence\n#include \"PolicyPhysicalPresence_fp.h\"\ntypedef TPM_RC  (PolicyPhysicalPresence_Entry)(\n\t\t\t\t\t       PolicyPhysicalPresence_In *in\n\t\t\t\t\t       );\ntypedef const struct {\n    PolicyPhysicalPresence_Entry    *entry;\n    UINT16                          inSize;\n    UINT16                          outSize;\n    UINT16                          offsetOfTypes;\n    BYTE                            types[3];\n} PolicyPhysicalPresence_COMMAND_DESCRIPTOR_t;\nPolicyPhysicalPresence_COMMAND_DESCRIPTOR_t _PolicyPhysicalPresenceData = {\n    /* entry  */          &TPM2_PolicyPhysicalPresence,\n    /* inSize */          (UINT16)(sizeof(PolicyPhysicalPresence_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyPhysicalPresence_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyPhysicalPresenceDataAddress (&_PolicyPhysicalPresenceData)\n#else\n#define _PolicyPhysicalPresenceDataAddress 0\n#endif\n#if CC_PolicyCpHash\n#include \"PolicyCpHash_fp.h\"\ntypedef TPM_RC  (PolicyCpHash_Entry)(\n\t\t\t\t     PolicyCpHash_In *in\n\t\t\t\t     );\ntypedef const struct {\n    PolicyCpHash_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[1];\n    BYTE                  types[4];\n} PolicyCpHash_COMMAND_DESCRIPTOR_t;\nPolicyCpHash_COMMAND_DESCRIPTOR_t _PolicyCpHashData = {\n    /* entry  */          &TPM2_PolicyCpHash,\n    /* inSize */          (UINT16)(sizeof(PolicyCpHash_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyCpHash_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyCpHash_In, cpHashA))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyCpHashDataAddress (&_PolicyCpHashData)\n#else\n#define _PolicyCpHashDataAddress 0\n#endif\n#if CC_PolicyNameHash\n#include \"PolicyNameHash_fp.h\"\ntypedef TPM_RC  (PolicyNameHash_Entry)(\n\t\t\t\t       PolicyNameHash_In *in\n\t\t\t\t       );\ntypedef const struct {\n    PolicyNameHash_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[1];\n    BYTE                    types[4];\n} PolicyNameHash_COMMAND_DESCRIPTOR_t;\nPolicyNameHash_COMMAND_DESCRIPTOR_t _PolicyNameHashData = {\n    /* entry  */          &TPM2_PolicyNameHash,\n    /* inSize */          (UINT16)(sizeof(PolicyNameHash_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyNameHash_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyNameHash_In, nameHash))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyNameHashDataAddress (&_PolicyNameHashData)\n#else\n#define _PolicyNameHashDataAddress 0\n#endif\n#if CC_PolicyDuplicationSelect\n#include \"PolicyDuplicationSelect_fp.h\"\ntypedef TPM_RC  (PolicyDuplicationSelect_Entry)(\n\t\t\t\t\t\tPolicyDuplicationSelect_In *in\n\t\t\t\t\t\t);\ntypedef const struct {\n    PolicyDuplicationSelect_Entry    *entry;\n    UINT16                           inSize;\n    UINT16                           outSize;\n    UINT16                           offsetOfTypes;\n    UINT16                           paramOffsets[3];\n    BYTE                             types[6];\n} PolicyDuplicationSelect_COMMAND_DESCRIPTOR_t;\nPolicyDuplicationSelect_COMMAND_DESCRIPTOR_t _PolicyDuplicationSelectData = {\n    /* entry  */          &TPM2_PolicyDuplicationSelect,\n    /* inSize */          (UINT16)(sizeof(PolicyDuplicationSelect_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyDuplicationSelect_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyDuplicationSelect_In, objectName)),\n\t\t\t   (UINT16)(offsetof(PolicyDuplicationSelect_In, newParentName)),\n\t\t\t   (UINT16)(offsetof(PolicyDuplicationSelect_In, includeObject))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_NAME_P_UNMARSHAL,\n\t\t\t   TPM2B_NAME_P_UNMARSHAL,\n\t\t\t   TPMI_YES_NO_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyDuplicationSelectDataAddress (&_PolicyDuplicationSelectData)\n#else\n#define _PolicyDuplicationSelectDataAddress 0\n#endif\n#if CC_PolicyAuthorize\n#include \"PolicyAuthorize_fp.h\"\ntypedef TPM_RC  (PolicyAuthorize_Entry)(\n\t\t\t\t\tPolicyAuthorize_In *in\n\t\t\t\t\t);\ntypedef const struct {\n    PolicyAuthorize_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    UINT16                   paramOffsets[4];\n    BYTE                     types[7];\n} PolicyAuthorize_COMMAND_DESCRIPTOR_t;\nPolicyAuthorize_COMMAND_DESCRIPTOR_t _PolicyAuthorizeData = {\n    /* entry  */          &TPM2_PolicyAuthorize,\n    /* inSize */          (UINT16)(sizeof(PolicyAuthorize_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyAuthorize_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyAuthorize_In, approvedPolicy)),\n\t\t\t   (UINT16)(offsetof(PolicyAuthorize_In, policyRef)),\n\t\t\t   (UINT16)(offsetof(PolicyAuthorize_In, keySign)),\n\t\t\t   (UINT16)(offsetof(PolicyAuthorize_In, checkTicket))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPM2B_NONCE_P_UNMARSHAL,\n\t\t\t   TPM2B_NAME_P_UNMARSHAL,\n\t\t\t   TPMT_TK_VERIFIED_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyAuthorizeDataAddress (&_PolicyAuthorizeData)\n#else\n#define _PolicyAuthorizeDataAddress 0\n#endif\n#if CC_PolicyAuthValue\n#include \"PolicyAuthValue_fp.h\"\ntypedef TPM_RC  (PolicyAuthValue_Entry)(\n\t\t\t\t\tPolicyAuthValue_In *in\n\t\t\t\t\t);\ntypedef const struct {\n    PolicyAuthValue_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    BYTE                     types[3];\n} PolicyAuthValue_COMMAND_DESCRIPTOR_t;\nPolicyAuthValue_COMMAND_DESCRIPTOR_t _PolicyAuthValueData = {\n    /* entry  */          &TPM2_PolicyAuthValue,\n    /* inSize */          (UINT16)(sizeof(PolicyAuthValue_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyAuthValue_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyAuthValueDataAddress (&_PolicyAuthValueData)\n#else\n#define _PolicyAuthValueDataAddress 0\n#endif\n#if CC_PolicyPassword\n#include \"PolicyPassword_fp.h\"\ntypedef TPM_RC  (PolicyPassword_Entry)(\n\t\t\t\t       PolicyPassword_In *in\n\t\t\t\t       );\ntypedef const struct {\n    PolicyPassword_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    BYTE                    types[3];\n} PolicyPassword_COMMAND_DESCRIPTOR_t;\nPolicyPassword_COMMAND_DESCRIPTOR_t _PolicyPasswordData = {\n    /* entry  */          &TPM2_PolicyPassword,\n    /* inSize */          (UINT16)(sizeof(PolicyPassword_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyPassword_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyPasswordDataAddress (&_PolicyPasswordData)\n#else\n#define _PolicyPasswordDataAddress 0\n#endif\n#if CC_PolicyGetDigest\n#include \"PolicyGetDigest_fp.h\"\ntypedef TPM_RC  (PolicyGetDigest_Entry)(\n\t\t\t\t\tPolicyGetDigest_In *in,\n\t\t\t\t\tPolicyGetDigest_Out *out\n\t\t\t\t\t);\ntypedef const struct {\n    PolicyGetDigest_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    BYTE                     types[4];\n} PolicyGetDigest_COMMAND_DESCRIPTOR_t;\nPolicyGetDigest_COMMAND_DESCRIPTOR_t _PolicyGetDigestData = {\n    /* entry  */          &TPM2_PolicyGetDigest,\n    /* inSize */          (UINT16)(sizeof(PolicyGetDigest_In)),\n    /* outSize */         (UINT16)(sizeof(PolicyGetDigest_Out)),\n    /* offsetOfTypes */   offsetof(PolicyGetDigest_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_DIGEST_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyGetDigestDataAddress (&_PolicyGetDigestData)\n#else\n#define _PolicyGetDigestDataAddress 0\n#endif\n#if CC_PolicyNvWritten\n#include \"PolicyNvWritten_fp.h\"\ntypedef TPM_RC  (PolicyNvWritten_Entry)(\n\t\t\t\t\tPolicyNvWritten_In *in\n\t\t\t\t\t);\ntypedef const struct {\n    PolicyNvWritten_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    UINT16                   paramOffsets[1];\n    BYTE                     types[4];\n} PolicyNvWritten_COMMAND_DESCRIPTOR_t;\nPolicyNvWritten_COMMAND_DESCRIPTOR_t _PolicyNvWrittenData = {\n    /* entry  */          &TPM2_PolicyNvWritten,\n    /* inSize */          (UINT16)(sizeof(PolicyNvWritten_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyNvWritten_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyNvWritten_In, writtenSet))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPMI_YES_NO_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyNvWrittenDataAddress (&_PolicyNvWrittenData)\n#else\n#define _PolicyNvWrittenDataAddress 0\n#endif\n#if CC_PolicyTemplate\n#include \"PolicyTemplate_fp.h\"\ntypedef TPM_RC  (PolicyTemplate_Entry)(\n\t\t\t\t       PolicyTemplate_In *in\n\t\t\t\t       );\ntypedef const struct {\n    PolicyTemplate_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[1];\n    BYTE                    types[4];\n} PolicyTemplate_COMMAND_DESCRIPTOR_t;\nPolicyTemplate_COMMAND_DESCRIPTOR_t _PolicyTemplateData = {\n    /* entry  */          &TPM2_PolicyTemplate,\n    /* inSize */          (UINT16)(sizeof(PolicyTemplate_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyTemplate_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyTemplate_In, templateHash))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyTemplateDataAddress (&_PolicyTemplateData)\n#else\n#define _PolicyTemplateDataAddress 0\n#endif\n#if CC_PolicyAuthorizeNV\n#include \"PolicyAuthorizeNV_fp.h\"\ntypedef TPM_RC  (PolicyAuthorizeNV_Entry)(\n\t\t\t\t\t  PolicyAuthorizeNV_In *in\n\t\t\t\t\t  );\ntypedef const struct {\n    PolicyAuthorizeNV_Entry    *entry;\n    UINT16                     inSize;\n    UINT16                     outSize;\n    UINT16                     offsetOfTypes;\n    UINT16                     paramOffsets[2];\n    BYTE                       types[5];\n} PolicyAuthorizeNV_COMMAND_DESCRIPTOR_t;\nPolicyAuthorizeNV_COMMAND_DESCRIPTOR_t _PolicyAuthorizeNVData = {\n    /* entry  */          &TPM2_PolicyAuthorizeNV,\n    /* inSize */          (UINT16)(sizeof(PolicyAuthorizeNV_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PolicyAuthorizeNV_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PolicyAuthorizeNV_In, nvIndex)),\n\t\t\t   (UINT16)(offsetof(PolicyAuthorizeNV_In, policySession))},\n    /* types */           {TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PolicyAuthorizeNVDataAddress (&_PolicyAuthorizeNVData)\n#else\n#define _PolicyAuthorizeNVDataAddress 0\n#endif\n\n#if       CC_PolicyCapability\n#include    \"PolicyCapability_fp.h\"\n\ntypedef TPM_RC (PolicyCapability_Entry)(\n\t\t\t\t\tPolicyCapability_In*        in\n\t\t\t\t\t);\n\ntypedef const struct\n{\n    PolicyCapability_Entry      *entry;\n    UINT16                      inSize;\n    UINT16                      outSize;\n    UINT16                      offsetOfTypes;\n    UINT16                      paramOffsets[5];\n    BYTE                        types[8];\n} PolicyCapability_COMMAND_DESCRIPTOR_t;\n\nPolicyCapability_COMMAND_DESCRIPTOR_t _PolicyCapabilityData = {\n    /* entry         */         &TPM2_PolicyCapability,\n    /* inSize        */         (UINT16)(sizeof(PolicyCapability_In)),\n    /* outSize       */         0,\n    /* offsetOfTypes */         offsetof(PolicyCapability_COMMAND_DESCRIPTOR_t, types),\n    /* offsets       */         {(UINT16)(offsetof(PolicyCapability_In, operandB)),\n\t\t\t\t (UINT16)(offsetof(PolicyCapability_In, offset)),\n\t\t\t\t (UINT16)(offsetof(PolicyCapability_In, operation)),\n\t\t\t\t (UINT16)(offsetof(PolicyCapability_In, capability)),\n\t\t\t\t (UINT16)(offsetof(PolicyCapability_In, property))},\n    /* types         */         {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t\t TPM2B_OPERAND_P_UNMARSHAL,\n\t\t\t\t UINT16_P_UNMARSHAL,\n\t\t\t\t TPM_EO_P_UNMARSHAL,\n\t\t\t\t TPM_CAP_P_UNMARSHAL,\n\t\t\t\t UINT32_P_UNMARSHAL,\n\t\t\t\t END_OF_LIST,\n\t\t\t\t END_OF_LIST}\n};\n\n#define _PolicyCapabilityDataAddress (&_PolicyCapabilityData)\n#else\n#define _PolicyCapabilityDataAddress 0\n#endif // CC_PolicyCapability\n\n#if       CC_PolicyParameters\n#include    \"PolicyParameters_fp.h\"\n\ntypedef TPM_RC (PolicyParameters_Entry)(\n\t\t\t\t\tPolicyParameters_In*        in\n\t\t\t\t\t);\n\n\ntypedef const struct\n{\n    PolicyParameters_Entry      *entry;\n    UINT16                      inSize;\n    UINT16                      outSize;\n    UINT16                      offsetOfTypes;\n    UINT16                      paramOffsets[1];\n    BYTE                        types[4];\n} PolicyParameters_COMMAND_DESCRIPTOR_t;\n\nPolicyParameters_COMMAND_DESCRIPTOR_t _PolicyParametersData = {\n    /* entry         */         &TPM2_PolicyParameters,\n    /* inSize        */         (UINT16)(sizeof(PolicyParameters_In)),\n    /* outSize       */         0,\n    /* offsetOfTypes */         offsetof(PolicyParameters_COMMAND_DESCRIPTOR_t, types),\n    /* offsets       */         {(UINT16)(offsetof(PolicyParameters_In, pHash))},\n    /* types         */         {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t\t TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t\t END_OF_LIST,\n\t\t\t\t END_OF_LIST}\n};\n\n#define _PolicyParametersDataAddress (&_PolicyParametersData)\n#else\n#define _PolicyParametersDataAddress 0\n#endif // CC_PolicyParameters\n\n#if CC_CreatePrimary\n#include \"CreatePrimary_fp.h\"\ntypedef TPM_RC  (CreatePrimary_Entry)(\n\t\t\t\t      CreatePrimary_In *in,\n\t\t\t\t      CreatePrimary_Out *out\n\t\t\t\t      );\ntypedef const struct {\n    CreatePrimary_Entry    *entry;\n    UINT16                 inSize;\n    UINT16                 outSize;\n    UINT16                 offsetOfTypes;\n    UINT16                 paramOffsets[9];\n    BYTE                   types[13];\n} CreatePrimary_COMMAND_DESCRIPTOR_t;\nCreatePrimary_COMMAND_DESCRIPTOR_t _CreatePrimaryData = {\n    /* entry  */          &TPM2_CreatePrimary,\n    /* inSize */          (UINT16)(sizeof(CreatePrimary_In)),\n    /* outSize */         (UINT16)(sizeof(CreatePrimary_Out)),\n    /* offsetOfTypes */   offsetof(CreatePrimary_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(CreatePrimary_In, inSensitive)),\n\t\t\t   (UINT16)(offsetof(CreatePrimary_In, inPublic)),\n\t\t\t   (UINT16)(offsetof(CreatePrimary_In, outsideInfo)),\n\t\t\t   (UINT16)(offsetof(CreatePrimary_In, creationPCR)),\n\t\t\t   (UINT16)(offsetof(CreatePrimary_Out, outPublic)),\n\t\t\t   (UINT16)(offsetof(CreatePrimary_Out, creationData)),\n\t\t\t   (UINT16)(offsetof(CreatePrimary_Out, creationHash)),\n\t\t\t   (UINT16)(offsetof(CreatePrimary_Out, creationTicket)),\n\t\t\t   (UINT16)(offsetof(CreatePrimary_Out, name))},\n    /* types */           {TPMI_RH_HIERARCHY_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPM2B_SENSITIVE_CREATE_P_UNMARSHAL,\n\t\t\t   TPM2B_PUBLIC_P_UNMARSHAL,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPML_PCR_SELECTION_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM_HANDLE_H_MARSHAL,\n\t\t\t   TPM2B_PUBLIC_P_MARSHAL,\n\t\t\t   TPM2B_CREATION_DATA_P_MARSHAL,\n\t\t\t   TPM2B_DIGEST_P_MARSHAL,\n\t\t\t   TPMT_TK_CREATION_P_MARSHAL,\n\t\t\t   TPM2B_NAME_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _CreatePrimaryDataAddress (&_CreatePrimaryData)\n#else\n#define _CreatePrimaryDataAddress 0\n#endif\n#if CC_HierarchyControl\n#include \"HierarchyControl_fp.h\"\ntypedef TPM_RC  (HierarchyControl_Entry)(\n\t\t\t\t\t HierarchyControl_In *in\n\t\t\t\t\t );\ntypedef const struct {\n    HierarchyControl_Entry    *entry;\n    UINT16                    inSize;\n    UINT16                    outSize;\n    UINT16                    offsetOfTypes;\n    UINT16                    paramOffsets[2];\n    BYTE                      types[5];\n} HierarchyControl_COMMAND_DESCRIPTOR_t;\nHierarchyControl_COMMAND_DESCRIPTOR_t _HierarchyControlData = {\n    /* entry  */          &TPM2_HierarchyControl,\n    /* inSize */          (UINT16)(sizeof(HierarchyControl_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(HierarchyControl_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(HierarchyControl_In, enable)),\n\t\t\t   (UINT16)(offsetof(HierarchyControl_In, state))},\n    /* types */           {TPMI_RH_HIERARCHY_H_UNMARSHAL,\n\t\t\t   TPMI_RH_ENABLES_P_UNMARSHAL,\n\t\t\t   TPMI_YES_NO_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _HierarchyControlDataAddress (&_HierarchyControlData)\n#else\n#define _HierarchyControlDataAddress 0\n#endif\n#if CC_SetPrimaryPolicy\n#include \"SetPrimaryPolicy_fp.h\"\ntypedef TPM_RC  (SetPrimaryPolicy_Entry)(\n\t\t\t\t\t SetPrimaryPolicy_In *in\n\t\t\t\t\t );\ntypedef const struct {\n    SetPrimaryPolicy_Entry    *entry;\n    UINT16                    inSize;\n    UINT16                    outSize;\n    UINT16                    offsetOfTypes;\n    UINT16                    paramOffsets[2];\n    BYTE                      types[5];\n} SetPrimaryPolicy_COMMAND_DESCRIPTOR_t;\nSetPrimaryPolicy_COMMAND_DESCRIPTOR_t _SetPrimaryPolicyData = {\n    /* entry  */          &TPM2_SetPrimaryPolicy,\n    /* inSize */          (UINT16)(sizeof(SetPrimaryPolicy_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(SetPrimaryPolicy_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(SetPrimaryPolicy_In, authPolicy)),\n\t\t\t   (UINT16)(offsetof(SetPrimaryPolicy_In, hashAlg))},\n    /* types */           {TPMI_RH_HIERARCHY_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPMI_ALG_HASH_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _SetPrimaryPolicyDataAddress (&_SetPrimaryPolicyData)\n#else\n#define _SetPrimaryPolicyDataAddress 0\n#endif\n#if CC_ChangePPS\n#include \"ChangePPS_fp.h\"\ntypedef TPM_RC  (ChangePPS_Entry)(\n\t\t\t\t  ChangePPS_In *in\n\t\t\t\t  );\ntypedef const struct {\n    ChangePPS_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    BYTE               types[3];\n} ChangePPS_COMMAND_DESCRIPTOR_t;\nChangePPS_COMMAND_DESCRIPTOR_t _ChangePPSData = {\n    /* entry  */          &TPM2_ChangePPS,\n    /* inSize */          (UINT16)(sizeof(ChangePPS_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(ChangePPS_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_RH_PLATFORM_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _ChangePPSDataAddress (&_ChangePPSData)\n#else\n#define _ChangePPSDataAddress 0\n#endif\n#if CC_ChangeEPS\n#include \"ChangeEPS_fp.h\"\ntypedef TPM_RC  (ChangeEPS_Entry)(\n\t\t\t\t  ChangeEPS_In *in\n\t\t\t\t  );\ntypedef const struct {\n    ChangeEPS_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    BYTE               types[3];\n} ChangeEPS_COMMAND_DESCRIPTOR_t;\nChangeEPS_COMMAND_DESCRIPTOR_t _ChangeEPSData = {\n    /* entry  */          &TPM2_ChangeEPS,\n    /* inSize */          (UINT16)(sizeof(ChangeEPS_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(ChangeEPS_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_RH_PLATFORM_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _ChangeEPSDataAddress (&_ChangeEPSData)\n#else\n#define _ChangeEPSDataAddress 0\n#endif\n#if CC_Clear\n#include \"Clear_fp.h\"\ntypedef TPM_RC  (Clear_Entry)(\n\t\t\t      Clear_In *in\n\t\t\t      );\ntypedef const struct {\n    Clear_Entry    *entry;\n    UINT16         inSize;\n    UINT16         outSize;\n    UINT16         offsetOfTypes;\n    BYTE           types[3];\n} Clear_COMMAND_DESCRIPTOR_t;\nClear_COMMAND_DESCRIPTOR_t _ClearData = {\n    /* entry  */          &TPM2_Clear,\n    /* inSize */          (UINT16)(sizeof(Clear_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(Clear_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_RH_CLEAR_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _ClearDataAddress (&_ClearData)\n#else\n#define _ClearDataAddress 0\n#endif\n#if CC_ClearControl\n#include \"ClearControl_fp.h\"\ntypedef TPM_RC  (ClearControl_Entry)(\n\t\t\t\t     ClearControl_In *in\n\t\t\t\t     );\ntypedef const struct {\n    ClearControl_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[1];\n    BYTE                  types[4];\n} ClearControl_COMMAND_DESCRIPTOR_t;\nClearControl_COMMAND_DESCRIPTOR_t _ClearControlData = {\n    /* entry  */          &TPM2_ClearControl,\n    /* inSize */          (UINT16)(sizeof(ClearControl_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(ClearControl_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(ClearControl_In, disable))},\n    /* types */           {TPMI_RH_CLEAR_H_UNMARSHAL,\n\t\t\t   TPMI_YES_NO_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _ClearControlDataAddress (&_ClearControlData)\n#else\n#define _ClearControlDataAddress 0\n#endif\n#if CC_HierarchyChangeAuth\n#include \"HierarchyChangeAuth_fp.h\"\ntypedef TPM_RC  (HierarchyChangeAuth_Entry)(\n\t\t\t\t\t    HierarchyChangeAuth_In *in\n\t\t\t\t\t    );\ntypedef const struct {\n    HierarchyChangeAuth_Entry    *entry;\n    UINT16                       inSize;\n    UINT16                       outSize;\n    UINT16                       offsetOfTypes;\n    UINT16                       paramOffsets[1];\n    BYTE                         types[4];\n} HierarchyChangeAuth_COMMAND_DESCRIPTOR_t;\nHierarchyChangeAuth_COMMAND_DESCRIPTOR_t _HierarchyChangeAuthData = {\n    /* entry  */          &TPM2_HierarchyChangeAuth,\n    /* inSize */          (UINT16)(sizeof(HierarchyChangeAuth_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(HierarchyChangeAuth_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(HierarchyChangeAuth_In, newAuth))},\n    /* types */           {TPMI_RH_HIERARCHY_AUTH_H_UNMARSHAL,\n\t\t\t   TPM2B_AUTH_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _HierarchyChangeAuthDataAddress (&_HierarchyChangeAuthData)\n#else\n#define _HierarchyChangeAuthDataAddress 0\n#endif\n#if CC_DictionaryAttackLockReset\n#include \"DictionaryAttackLockReset_fp.h\"\ntypedef TPM_RC  (DictionaryAttackLockReset_Entry)(\n\t\t\t\t\t\t  DictionaryAttackLockReset_In *in\n\t\t\t\t\t\t  );\ntypedef const struct {\n    DictionaryAttackLockReset_Entry    *entry;\n    UINT16                             inSize;\n    UINT16                             outSize;\n    UINT16                             offsetOfTypes;\n    BYTE                               types[3];\n} DictionaryAttackLockReset_COMMAND_DESCRIPTOR_t;\nDictionaryAttackLockReset_COMMAND_DESCRIPTOR_t _DictionaryAttackLockResetData = {\n    /* entry  */          &TPM2_DictionaryAttackLockReset,\n    /* inSize */          (UINT16)(sizeof(DictionaryAttackLockReset_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(DictionaryAttackLockReset_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_RH_LOCKOUT_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _DictionaryAttackLockResetDataAddress (&_DictionaryAttackLockResetData)\n#else\n#define _DictionaryAttackLockResetDataAddress 0\n#endif\n#if CC_DictionaryAttackParameters\n#include \"DictionaryAttackParameters_fp.h\"\ntypedef TPM_RC  (DictionaryAttackParameters_Entry)(\n\t\t\t\t\t\t   DictionaryAttackParameters_In *in\n\t\t\t\t\t\t   );\ntypedef const struct {\n    DictionaryAttackParameters_Entry    *entry;\n    UINT16                              inSize;\n    UINT16                              outSize;\n    UINT16                              offsetOfTypes;\n    UINT16                              paramOffsets[3];\n    BYTE                                types[6];\n} DictionaryAttackParameters_COMMAND_DESCRIPTOR_t;\nDictionaryAttackParameters_COMMAND_DESCRIPTOR_t _DictionaryAttackParametersData = {\n    /* entry  */          &TPM2_DictionaryAttackParameters,\n    /* inSize */          (UINT16)(sizeof(DictionaryAttackParameters_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(DictionaryAttackParameters_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(DictionaryAttackParameters_In, newMaxTries)),\n\t\t\t   (UINT16)(offsetof(DictionaryAttackParameters_In, newRecoveryTime)),\n\t\t\t   (UINT16)(offsetof(DictionaryAttackParameters_In, lockoutRecovery))},\n    /* types */           {TPMI_RH_LOCKOUT_H_UNMARSHAL,\n\t\t\t   UINT32_P_UNMARSHAL,\n\t\t\t   UINT32_P_UNMARSHAL,\n\t\t\t   UINT32_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _DictionaryAttackParametersDataAddress (&_DictionaryAttackParametersData)\n#else\n#define _DictionaryAttackParametersDataAddress 0\n#endif\n#if CC_PP_Commands\n#include \"PP_Commands_fp.h\"\ntypedef TPM_RC  (PP_Commands_Entry)(\n\t\t\t\t    PP_Commands_In *in\n\t\t\t\t    );\ntypedef const struct {\n    PP_Commands_Entry    *entry;\n    UINT16               inSize;\n    UINT16               outSize;\n    UINT16               offsetOfTypes;\n    UINT16               paramOffsets[2];\n    BYTE                 types[5];\n} PP_Commands_COMMAND_DESCRIPTOR_t;\nPP_Commands_COMMAND_DESCRIPTOR_t _PP_CommandsData = {\n    /* entry  */          &TPM2_PP_Commands,\n    /* inSize */          (UINT16)(sizeof(PP_Commands_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(PP_Commands_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(PP_Commands_In, setList)),\n\t\t\t   (UINT16)(offsetof(PP_Commands_In, clearList))},\n    /* types */           {TPMI_RH_PLATFORM_H_UNMARSHAL,\n\t\t\t   TPML_CC_P_UNMARSHAL,\n\t\t\t   TPML_CC_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _PP_CommandsDataAddress (&_PP_CommandsData)\n#else\n#define _PP_CommandsDataAddress 0\n#endif\n#if CC_SetAlgorithmSet\n#include \"SetAlgorithmSet_fp.h\"\ntypedef TPM_RC  (SetAlgorithmSet_Entry)(\n\t\t\t\t\tSetAlgorithmSet_In *in\n\t\t\t\t\t);\ntypedef const struct {\n    SetAlgorithmSet_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    UINT16                   paramOffsets[1];\n    BYTE                     types[4];\n} SetAlgorithmSet_COMMAND_DESCRIPTOR_t;\nSetAlgorithmSet_COMMAND_DESCRIPTOR_t _SetAlgorithmSetData = {\n    /* entry  */          &TPM2_SetAlgorithmSet,\n    /* inSize */          (UINT16)(sizeof(SetAlgorithmSet_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(SetAlgorithmSet_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(SetAlgorithmSet_In, algorithmSet))},\n    /* types */           {TPMI_RH_PLATFORM_H_UNMARSHAL,\n\t\t\t   UINT32_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _SetAlgorithmSetDataAddress (&_SetAlgorithmSetData)\n#else\n#define _SetAlgorithmSetDataAddress 0\n#endif\n#if CC_FieldUpgradeStart\n#include \"FieldUpgradeStart_fp.h\"\ntypedef TPM_RC  (FieldUpgradeStart_Entry)(\n\t\t\t\t\t  FieldUpgradeStart_In *in\n\t\t\t\t\t  );\ntypedef const struct {\n    FieldUpgradeStart_Entry    *entry;\n    UINT16                     inSize;\n    UINT16                     outSize;\n    UINT16                     offsetOfTypes;\n    UINT16                     paramOffsets[3];\n    BYTE                       types[6];\n} FieldUpgradeStart_COMMAND_DESCRIPTOR_t;\nFieldUpgradeStart_COMMAND_DESCRIPTOR_t _FieldUpgradeStartData = {\n    /* entry  */          &TPM2_FieldUpgradeStart,\n    /* inSize */          (UINT16)(sizeof(FieldUpgradeStart_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(FieldUpgradeStart_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(FieldUpgradeStart_In, keyHandle)),\n\t\t\t   (UINT16)(offsetof(FieldUpgradeStart_In, fuDigest)),\n\t\t\t   (UINT16)(offsetof(FieldUpgradeStart_In, manifestSignature))},\n    /* types */           {TPMI_RH_PLATFORM_H_UNMARSHAL,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPM2B_DIGEST_P_UNMARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _FieldUpgradeStartDataAddress (&_FieldUpgradeStartData)\n#else\n#define _FieldUpgradeStartDataAddress 0\n#endif\n#if CC_FieldUpgradeData\n#include \"FieldUpgradeData_fp.h\"\ntypedef TPM_RC  (FieldUpgradeData_Entry)(\n\t\t\t\t\t FieldUpgradeData_In *in,\n\t\t\t\t\t FieldUpgradeData_Out *out\n\t\t\t\t\t );\ntypedef const struct {\n    FieldUpgradeData_Entry    *entry;\n    UINT16                    inSize;\n    UINT16                    outSize;\n    UINT16                    offsetOfTypes;\n    UINT16                    paramOffsets[1];\n    BYTE                      types[5];\n} FieldUpgradeData_COMMAND_DESCRIPTOR_t;\nFieldUpgradeData_COMMAND_DESCRIPTOR_t _FieldUpgradeDataData = {\n    /* entry  */          &TPM2_FieldUpgradeData,\n    /* inSize */          (UINT16)(sizeof(FieldUpgradeData_In)),\n    /* outSize */         (UINT16)(sizeof(FieldUpgradeData_Out)),\n    /* offsetOfTypes */   offsetof(FieldUpgradeData_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(FieldUpgradeData_Out, firstDigest))},\n    /* types */           {TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMT_HA_P_MARSHAL,\n\t\t\t   TPMT_HA_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _FieldUpgradeDataDataAddress (&_FieldUpgradeDataData)\n#else\n#define _FieldUpgradeDataDataAddress 0\n#endif\n#if CC_FirmwareRead\n#include \"FirmwareRead_fp.h\"\ntypedef TPM_RC  (FirmwareRead_Entry)(\n\t\t\t\t     FirmwareRead_In *in,\n\t\t\t\t     FirmwareRead_Out *out\n\t\t\t\t     );\ntypedef const struct {\n    FirmwareRead_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    BYTE                  types[4];\n} FirmwareRead_COMMAND_DESCRIPTOR_t;\nFirmwareRead_COMMAND_DESCRIPTOR_t _FirmwareReadData = {\n    /* entry  */          &TPM2_FirmwareRead,\n    /* inSize */          (UINT16)(sizeof(FirmwareRead_In)),\n    /* outSize */         (UINT16)(sizeof(FirmwareRead_Out)),\n    /* offsetOfTypes */   offsetof(FirmwareRead_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {UINT32_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_MAX_BUFFER_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _FirmwareReadDataAddress (&_FirmwareReadData)\n#else\n#define _FirmwareReadDataAddress 0\n#endif\n#if CC_ContextSave\n#include \"ContextSave_fp.h\"\ntypedef TPM_RC  (ContextSave_Entry)(\n\t\t\t\t    ContextSave_In *in,\n\t\t\t\t    ContextSave_Out *out\n\t\t\t\t    );\ntypedef const struct {\n    ContextSave_Entry    *entry;\n    UINT16               inSize;\n    UINT16               outSize;\n    UINT16               offsetOfTypes;\n    BYTE                 types[4];\n} ContextSave_COMMAND_DESCRIPTOR_t;\nContextSave_COMMAND_DESCRIPTOR_t _ContextSaveData = {\n    /* entry  */          &TPM2_ContextSave,\n    /* inSize */          (UINT16)(sizeof(ContextSave_In)),\n    /* outSize */         (UINT16)(sizeof(ContextSave_Out)),\n    /* offsetOfTypes */   offsetof(ContextSave_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_DH_CONTEXT_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMS_CONTEXT_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ContextSaveDataAddress (&_ContextSaveData)\n#else\n#define _ContextSaveDataAddress 0\n#endif\n#if CC_ContextLoad\n#include \"ContextLoad_fp.h\"\ntypedef TPM_RC  (ContextLoad_Entry)(\n\t\t\t\t    ContextLoad_In *in,\n\t\t\t\t    ContextLoad_Out *out\n\t\t\t\t    );\ntypedef const struct {\n    ContextLoad_Entry    *entry;\n    UINT16               inSize;\n    UINT16               outSize;\n    UINT16               offsetOfTypes;\n    BYTE                 types[4];\n} ContextLoad_COMMAND_DESCRIPTOR_t;\nContextLoad_COMMAND_DESCRIPTOR_t _ContextLoadData = {\n    /* entry  */          &TPM2_ContextLoad,\n    /* inSize */          (UINT16)(sizeof(ContextLoad_In)),\n    /* outSize */         (UINT16)(sizeof(ContextLoad_Out)),\n    /* offsetOfTypes */   offsetof(ContextLoad_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMS_CONTEXT_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMI_DH_CONTEXT_H_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ContextLoadDataAddress (&_ContextLoadData)\n#else\n#define _ContextLoadDataAddress 0\n#endif\n#if CC_FlushContext\n#include \"FlushContext_fp.h\"\ntypedef TPM_RC  (FlushContext_Entry)(\n\t\t\t\t     FlushContext_In *in\n\t\t\t\t     );\ntypedef const struct {\n    FlushContext_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    BYTE                  types[3];\n} FlushContext_COMMAND_DESCRIPTOR_t;\nFlushContext_COMMAND_DESCRIPTOR_t _FlushContextData = {\n    /* entry  */          &TPM2_FlushContext,\n    /* inSize */          (UINT16)(sizeof(FlushContext_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(FlushContext_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_DH_CONTEXT_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _FlushContextDataAddress (&_FlushContextData)\n#else\n#define _FlushContextDataAddress 0\n#endif\n#if CC_EvictControl\n#include \"EvictControl_fp.h\"\ntypedef TPM_RC  (EvictControl_Entry)(\n\t\t\t\t     EvictControl_In *in\n\t\t\t\t     );\ntypedef const struct {\n    EvictControl_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[2];\n    BYTE                  types[5];\n} EvictControl_COMMAND_DESCRIPTOR_t;\nEvictControl_COMMAND_DESCRIPTOR_t _EvictControlData = {\n    /* entry  */          &TPM2_EvictControl,\n    /* inSize */          (UINT16)(sizeof(EvictControl_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(EvictControl_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(EvictControl_In, objectHandle)),\n\t\t\t   (UINT16)(offsetof(EvictControl_In, persistentHandle))},\n    /* types */           {TPMI_RH_PROVISION_H_UNMARSHAL,\n\t\t\t   TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPMI_DH_PERSISTENT_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _EvictControlDataAddress (&_EvictControlData)\n#else\n#define _EvictControlDataAddress 0\n#endif\n#if CC_ReadClock\n#include \"ReadClock_fp.h\"\ntypedef TPM_RC  (ReadClock_Entry)(\n\t\t\t\t  ReadClock_Out *out\n\t\t\t\t  );\ntypedef const struct {\n    ReadClock_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    BYTE               types[3];\n} ReadClock_COMMAND_DESCRIPTOR_t;\nReadClock_COMMAND_DESCRIPTOR_t _ReadClockData = {\n    /* entry  */          &TPM2_ReadClock,\n    /* inSize */          0,\n    /* outSize */         (UINT16)(sizeof(ReadClock_Out)),\n    /* offsetOfTypes */   offsetof(ReadClock_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {END_OF_LIST,\n\t\t\t   TPMS_TIME_INFO_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _ReadClockDataAddress (&_ReadClockData)\n#else\n#define _ReadClockDataAddress 0\n#endif\n#if CC_ClockSet\n#include \"ClockSet_fp.h\"\ntypedef TPM_RC  (ClockSet_Entry)(\n\t\t\t\t ClockSet_In *in\n\t\t\t\t );\ntypedef const struct {\n    ClockSet_Entry    *entry;\n    UINT16            inSize;\n    UINT16            outSize;\n    UINT16            offsetOfTypes;\n    UINT16            paramOffsets[1];\n    BYTE              types[4];\n} ClockSet_COMMAND_DESCRIPTOR_t;\nClockSet_COMMAND_DESCRIPTOR_t _ClockSetData = {\n    /* entry  */          &TPM2_ClockSet,\n    /* inSize */          (UINT16)(sizeof(ClockSet_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(ClockSet_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(ClockSet_In, newTime))},\n    /* types */           {TPMI_RH_PROVISION_H_UNMARSHAL,\n\t\t\t   UINT64_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _ClockSetDataAddress (&_ClockSetData)\n#else\n#define _ClockSetDataAddress 0\n#endif\n#if CC_ClockRateAdjust\n#include \"ClockRateAdjust_fp.h\"\ntypedef TPM_RC  (ClockRateAdjust_Entry)(\n\t\t\t\t\tClockRateAdjust_In *in\n\t\t\t\t\t);\ntypedef const struct {\n    ClockRateAdjust_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    UINT16                   paramOffsets[1];\n    BYTE                     types[4];\n} ClockRateAdjust_COMMAND_DESCRIPTOR_t;\nClockRateAdjust_COMMAND_DESCRIPTOR_t _ClockRateAdjustData = {\n    /* entry  */          &TPM2_ClockRateAdjust,\n    /* inSize */          (UINT16)(sizeof(ClockRateAdjust_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(ClockRateAdjust_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(ClockRateAdjust_In, rateAdjust))},\n    /* types */           {TPMI_RH_PROVISION_H_UNMARSHAL,\n\t\t\t   TPM_CLOCK_ADJUST_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _ClockRateAdjustDataAddress (&_ClockRateAdjustData)\n#else\n#define _ClockRateAdjustDataAddress 0\n#endif\n#if CC_GetCapability\n#include \"GetCapability_fp.h\"\ntypedef TPM_RC  (GetCapability_Entry)(\n\t\t\t\t      GetCapability_In *in,\n\t\t\t\t      GetCapability_Out *out\n\t\t\t\t      );\ntypedef const struct {\n    GetCapability_Entry    *entry;\n    UINT16                 inSize;\n    UINT16                 outSize;\n    UINT16                 offsetOfTypes;\n    UINT16                 paramOffsets[3];\n    BYTE                   types[7];\n} GetCapability_COMMAND_DESCRIPTOR_t;\nGetCapability_COMMAND_DESCRIPTOR_t _GetCapabilityData = {\n    /* entry  */          &TPM2_GetCapability,\n    /* inSize */          (UINT16)(sizeof(GetCapability_In)),\n    /* outSize */         (UINT16)(sizeof(GetCapability_Out)),\n    /* offsetOfTypes */   offsetof(GetCapability_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(GetCapability_In, property)),\n\t\t\t   (UINT16)(offsetof(GetCapability_In, propertyCount)),\n\t\t\t   (UINT16)(offsetof(GetCapability_Out, capabilityData))},\n    /* types */           {TPM_CAP_P_UNMARSHAL,\n\t\t\t   UINT32_P_UNMARSHAL,\n\t\t\t   UINT32_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMI_YES_NO_P_MARSHAL,\n\t\t\t   TPMS_CAPABILITY_DATA_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _GetCapabilityDataAddress (&_GetCapabilityData)\n#else\n#define _GetCapabilityDataAddress 0\n#endif\n#if CC_TestParms\n#include \"TestParms_fp.h\"\ntypedef TPM_RC  (TestParms_Entry)(\n\t\t\t\t  TestParms_In *in\n\t\t\t\t  );\ntypedef const struct {\n    TestParms_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    BYTE               types[3];\n} TestParms_COMMAND_DESCRIPTOR_t;\nTestParms_COMMAND_DESCRIPTOR_t _TestParmsData = {\n    /* entry  */          &TPM2_TestParms,\n    /* inSize */          (UINT16)(sizeof(TestParms_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(TestParms_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMT_PUBLIC_PARMS_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _TestParmsDataAddress (&_TestParmsData)\n#else\n#define _TestParmsDataAddress 0\n#endif\n#if CC_NV_DefineSpace\n#include \"NV_DefineSpace_fp.h\"\ntypedef TPM_RC  (NV_DefineSpace_Entry)(\n\t\t\t\t       NV_DefineSpace_In *in\n\t\t\t\t       );\ntypedef const struct {\n    NV_DefineSpace_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[2];\n    BYTE                    types[5];\n} NV_DefineSpace_COMMAND_DESCRIPTOR_t;\nNV_DefineSpace_COMMAND_DESCRIPTOR_t _NV_DefineSpaceData = {\n    /* entry  */          &TPM2_NV_DefineSpace,\n    /* inSize */          (UINT16)(sizeof(NV_DefineSpace_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_DefineSpace_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_DefineSpace_In, auth)),\n\t\t\t   (UINT16)(offsetof(NV_DefineSpace_In, publicInfo))},\n    /* types */           {TPMI_RH_PROVISION_H_UNMARSHAL,\n\t\t\t   TPM2B_AUTH_P_UNMARSHAL,\n\t\t\t   TPM2B_NV_PUBLIC_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_DefineSpaceDataAddress (&_NV_DefineSpaceData)\n#else\n#define _NV_DefineSpaceDataAddress 0\n#endif\n#if CC_NV_UndefineSpace\n#include \"NV_UndefineSpace_fp.h\"\ntypedef TPM_RC  (NV_UndefineSpace_Entry)(\n\t\t\t\t\t NV_UndefineSpace_In *in\n\t\t\t\t\t );\ntypedef const struct {\n    NV_UndefineSpace_Entry    *entry;\n    UINT16                    inSize;\n    UINT16                    outSize;\n    UINT16                    offsetOfTypes;\n    UINT16                    paramOffsets[1];\n    BYTE                      types[4];\n} NV_UndefineSpace_COMMAND_DESCRIPTOR_t;\nNV_UndefineSpace_COMMAND_DESCRIPTOR_t _NV_UndefineSpaceData = {\n    /* entry  */          &TPM2_NV_UndefineSpace,\n    /* inSize */          (UINT16)(sizeof(NV_UndefineSpace_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_UndefineSpace_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_UndefineSpace_In, nvIndex))},\n    /* types */           {TPMI_RH_PROVISION_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_UndefineSpaceDataAddress (&_NV_UndefineSpaceData)\n#else\n#define _NV_UndefineSpaceDataAddress 0\n#endif\n#if CC_NV_UndefineSpaceSpecial\n#include \"NV_UndefineSpaceSpecial_fp.h\"\ntypedef TPM_RC  (NV_UndefineSpaceSpecial_Entry)(\n\t\t\t\t\t\tNV_UndefineSpaceSpecial_In *in\n\t\t\t\t\t\t);\ntypedef const struct {\n    NV_UndefineSpaceSpecial_Entry    *entry;\n    UINT16                           inSize;\n    UINT16                           outSize;\n    UINT16                           offsetOfTypes;\n    UINT16                           paramOffsets[1];\n    BYTE                             types[4];\n} NV_UndefineSpaceSpecial_COMMAND_DESCRIPTOR_t;\nNV_UndefineSpaceSpecial_COMMAND_DESCRIPTOR_t _NV_UndefineSpaceSpecialData = {\n    /* entry  */          &TPM2_NV_UndefineSpaceSpecial,\n    /* inSize */          (UINT16)(sizeof(NV_UndefineSpaceSpecial_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_UndefineSpaceSpecial_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_UndefineSpaceSpecial_In, platform))},\n    /* types */           {TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   TPMI_RH_PLATFORM_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_UndefineSpaceSpecialDataAddress (&_NV_UndefineSpaceSpecialData)\n#else\n#define _NV_UndefineSpaceSpecialDataAddress 0\n#endif\n#if CC_NV_ReadPublic\n#include \"NV_ReadPublic_fp.h\"\ntypedef TPM_RC  (NV_ReadPublic_Entry)(\n\t\t\t\t      NV_ReadPublic_In *in,\n\t\t\t\t      NV_ReadPublic_Out *out\n\t\t\t\t      );\ntypedef const struct {\n    NV_ReadPublic_Entry    *entry;\n    UINT16                 inSize;\n    UINT16                 outSize;\n    UINT16                 offsetOfTypes;\n    UINT16                 paramOffsets[1];\n    BYTE                   types[5];\n} NV_ReadPublic_COMMAND_DESCRIPTOR_t;\nNV_ReadPublic_COMMAND_DESCRIPTOR_t _NV_ReadPublicData = {\n    /* entry  */          &TPM2_NV_ReadPublic,\n    /* inSize */          (UINT16)(sizeof(NV_ReadPublic_In)),\n    /* outSize */         (UINT16)(sizeof(NV_ReadPublic_Out)),\n    /* offsetOfTypes */   offsetof(NV_ReadPublic_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_ReadPublic_Out, nvName))},\n    /* types */           {TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_NV_PUBLIC_P_MARSHAL,\n\t\t\t   TPM2B_NAME_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_ReadPublicDataAddress (&_NV_ReadPublicData)\n#else\n#define _NV_ReadPublicDataAddress 0\n#endif\n#if CC_NV_Write\n#include \"NV_Write_fp.h\"\ntypedef TPM_RC  (NV_Write_Entry)(\n\t\t\t\t NV_Write_In *in\n\t\t\t\t );\ntypedef const struct {\n    NV_Write_Entry    *entry;\n    UINT16            inSize;\n    UINT16            outSize;\n    UINT16            offsetOfTypes;\n    UINT16            paramOffsets[3];\n    BYTE              types[6];\n} NV_Write_COMMAND_DESCRIPTOR_t;\nNV_Write_COMMAND_DESCRIPTOR_t _NV_WriteData = {\n    /* entry  */          &TPM2_NV_Write,\n    /* inSize */          (UINT16)(sizeof(NV_Write_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_Write_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_Write_In, nvIndex)),\n\t\t\t   (UINT16)(offsetof(NV_Write_In, data)),\n\t\t\t   (UINT16)(offsetof(NV_Write_In, offset))},\n    /* types */           {TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   TPM2B_MAX_NV_BUFFER_P_UNMARSHAL,\n\t\t\t   UINT16_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_WriteDataAddress (&_NV_WriteData)\n#else\n#define _NV_WriteDataAddress 0\n#endif\n#if CC_NV_Increment\n#include \"NV_Increment_fp.h\"\ntypedef TPM_RC  (NV_Increment_Entry)(\n\t\t\t\t     NV_Increment_In *in\n\t\t\t\t     );\ntypedef const struct {\n    NV_Increment_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[1];\n    BYTE                  types[4];\n} NV_Increment_COMMAND_DESCRIPTOR_t;\nNV_Increment_COMMAND_DESCRIPTOR_t _NV_IncrementData = {\n    /* entry  */          &TPM2_NV_Increment,\n    /* inSize */          (UINT16)(sizeof(NV_Increment_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_Increment_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_Increment_In, nvIndex))},\n    /* types */           {TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_IncrementDataAddress (&_NV_IncrementData)\n#else\n#define _NV_IncrementDataAddress 0\n#endif\n#if CC_NV_Extend\n#include \"NV_Extend_fp.h\"\ntypedef TPM_RC  (NV_Extend_Entry)(\n\t\t\t\t  NV_Extend_In *in\n\t\t\t\t  );\ntypedef const struct {\n    NV_Extend_Entry    *entry;\n    UINT16             inSize;\n    UINT16             outSize;\n    UINT16             offsetOfTypes;\n    UINT16             paramOffsets[2];\n    BYTE               types[5];\n} NV_Extend_COMMAND_DESCRIPTOR_t;\nNV_Extend_COMMAND_DESCRIPTOR_t _NV_ExtendData = {\n    /* entry  */          &TPM2_NV_Extend,\n    /* inSize */          (UINT16)(sizeof(NV_Extend_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_Extend_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_Extend_In, nvIndex)),\n\t\t\t   (UINT16)(offsetof(NV_Extend_In, data))},\n    /* types */           {TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   TPM2B_MAX_NV_BUFFER_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_ExtendDataAddress (&_NV_ExtendData)\n#else\n#define _NV_ExtendDataAddress 0\n#endif\n#if CC_NV_SetBits\n#include \"NV_SetBits_fp.h\"\ntypedef TPM_RC  (NV_SetBits_Entry)(\n\t\t\t\t   NV_SetBits_In *in\n\t\t\t\t   );\ntypedef const struct {\n    NV_SetBits_Entry    *entry;\n    UINT16              inSize;\n    UINT16              outSize;\n    UINT16              offsetOfTypes;\n    UINT16              paramOffsets[2];\n    BYTE                types[5];\n} NV_SetBits_COMMAND_DESCRIPTOR_t;\nNV_SetBits_COMMAND_DESCRIPTOR_t _NV_SetBitsData = {\n    /* entry  */          &TPM2_NV_SetBits,\n    /* inSize */          (UINT16)(sizeof(NV_SetBits_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_SetBits_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_SetBits_In, nvIndex)),\n\t\t\t   (UINT16)(offsetof(NV_SetBits_In, bits))},\n    /* types */           {TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   UINT64_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_SetBitsDataAddress (&_NV_SetBitsData)\n#else\n#define _NV_SetBitsDataAddress 0\n#endif\n#if CC_NV_WriteLock\n#include \"NV_WriteLock_fp.h\"\ntypedef TPM_RC  (NV_WriteLock_Entry)(\n\t\t\t\t     NV_WriteLock_In *in\n\t\t\t\t     );\ntypedef const struct {\n    NV_WriteLock_Entry    *entry;\n    UINT16                inSize;\n    UINT16                outSize;\n    UINT16                offsetOfTypes;\n    UINT16                paramOffsets[1];\n    BYTE                  types[4];\n} NV_WriteLock_COMMAND_DESCRIPTOR_t;\nNV_WriteLock_COMMAND_DESCRIPTOR_t _NV_WriteLockData = {\n    /* entry  */          &TPM2_NV_WriteLock,\n    /* inSize */          (UINT16)(sizeof(NV_WriteLock_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_WriteLock_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_WriteLock_In, nvIndex))},\n    /* types */           {TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_WriteLockDataAddress (&_NV_WriteLockData)\n#else\n#define _NV_WriteLockDataAddress 0\n#endif\n#if CC_NV_GlobalWriteLock\n#include \"NV_GlobalWriteLock_fp.h\"\ntypedef TPM_RC  (NV_GlobalWriteLock_Entry)(\n\t\t\t\t\t   NV_GlobalWriteLock_In *in\n\t\t\t\t\t   );\ntypedef const struct {\n    NV_GlobalWriteLock_Entry    *entry;\n    UINT16                      inSize;\n    UINT16                      outSize;\n    UINT16                      offsetOfTypes;\n    BYTE                        types[3];\n} NV_GlobalWriteLock_COMMAND_DESCRIPTOR_t;\nNV_GlobalWriteLock_COMMAND_DESCRIPTOR_t _NV_GlobalWriteLockData = {\n    /* entry  */          &TPM2_NV_GlobalWriteLock,\n    /* inSize */          (UINT16)(sizeof(NV_GlobalWriteLock_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_GlobalWriteLock_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPMI_RH_PROVISION_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_GlobalWriteLockDataAddress (&_NV_GlobalWriteLockData)\n#else\n#define _NV_GlobalWriteLockDataAddress 0\n#endif\n#if CC_NV_Read\n#include \"NV_Read_fp.h\"\ntypedef TPM_RC  (NV_Read_Entry)(\n\t\t\t\tNV_Read_In *in,\n\t\t\t\tNV_Read_Out *out\n\t\t\t\t);\ntypedef const struct {\n    NV_Read_Entry    *entry;\n    UINT16           inSize;\n    UINT16           outSize;\n    UINT16           offsetOfTypes;\n    UINT16           paramOffsets[3];\n    BYTE             types[7];\n} NV_Read_COMMAND_DESCRIPTOR_t;\nNV_Read_COMMAND_DESCRIPTOR_t _NV_ReadData = {\n    /* entry  */          &TPM2_NV_Read,\n    /* inSize */          (UINT16)(sizeof(NV_Read_In)),\n    /* outSize */         (UINT16)(sizeof(NV_Read_Out)),\n    /* offsetOfTypes */   offsetof(NV_Read_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_Read_In, nvIndex)),\n\t\t\t   (UINT16)(offsetof(NV_Read_In, size)),\n\t\t\t   (UINT16)(offsetof(NV_Read_In, offset))},\n    /* types */           {TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   UINT16_P_UNMARSHAL,\n\t\t\t   UINT16_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_MAX_NV_BUFFER_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_ReadDataAddress (&_NV_ReadData)\n#else\n#define _NV_ReadDataAddress 0\n#endif\n#if CC_NV_ReadLock\n#include \"NV_ReadLock_fp.h\"\ntypedef TPM_RC  (NV_ReadLock_Entry)(\n\t\t\t\t    NV_ReadLock_In *in\n\t\t\t\t    );\ntypedef const struct {\n    NV_ReadLock_Entry    *entry;\n    UINT16               inSize;\n    UINT16               outSize;\n    UINT16               offsetOfTypes;\n    UINT16               paramOffsets[1];\n    BYTE                 types[4];\n} NV_ReadLock_COMMAND_DESCRIPTOR_t;\nNV_ReadLock_COMMAND_DESCRIPTOR_t _NV_ReadLockData = {\n    /* entry  */          &TPM2_NV_ReadLock,\n    /* inSize */          (UINT16)(sizeof(NV_ReadLock_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_ReadLock_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_ReadLock_In, nvIndex))},\n    /* types */           {TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_ReadLockDataAddress (&_NV_ReadLockData)\n#else\n#define _NV_ReadLockDataAddress 0\n#endif\n#if CC_NV_ChangeAuth\n#include \"NV_ChangeAuth_fp.h\"\ntypedef TPM_RC  (NV_ChangeAuth_Entry)(\n\t\t\t\t      NV_ChangeAuth_In *in\n\t\t\t\t      );\ntypedef const struct {\n    NV_ChangeAuth_Entry    *entry;\n    UINT16                 inSize;\n    UINT16                 outSize;\n    UINT16                 offsetOfTypes;\n    UINT16                 paramOffsets[1];\n    BYTE                   types[4];\n} NV_ChangeAuth_COMMAND_DESCRIPTOR_t;\nNV_ChangeAuth_COMMAND_DESCRIPTOR_t _NV_ChangeAuthData = {\n    /* entry  */          &TPM2_NV_ChangeAuth,\n    /* inSize */          (UINT16)(sizeof(NV_ChangeAuth_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NV_ChangeAuth_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_ChangeAuth_In, newAuth))},\n    /* types */           {TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   TPM2B_AUTH_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_ChangeAuthDataAddress (&_NV_ChangeAuthData)\n#else\n#define _NV_ChangeAuthDataAddress 0\n#endif\n#if CC_NV_Certify\n#include \"NV_Certify_fp.h\"\ntypedef TPM_RC  (NV_Certify_Entry)(\n\t\t\t\t   NV_Certify_In *in,\n\t\t\t\t   NV_Certify_Out *out\n\t\t\t\t   );\ntypedef const struct {\n    NV_Certify_Entry    *entry;\n    UINT16              inSize;\n    UINT16              outSize;\n    UINT16              offsetOfTypes;\n    UINT16              paramOffsets[7];\n    BYTE                types[11];\n} NV_Certify_COMMAND_DESCRIPTOR_t;\nNV_Certify_COMMAND_DESCRIPTOR_t _NV_CertifyData = {\n    /* entry  */          &TPM2_NV_Certify,\n    /* inSize */          (UINT16)(sizeof(NV_Certify_In)),\n    /* outSize */         (UINT16)(sizeof(NV_Certify_Out)),\n    /* offsetOfTypes */   offsetof(NV_Certify_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(NV_Certify_In, authHandle)),\n\t\t\t   (UINT16)(offsetof(NV_Certify_In, nvIndex)),\n\t\t\t   (UINT16)(offsetof(NV_Certify_In, qualifyingData)),\n\t\t\t   (UINT16)(offsetof(NV_Certify_In, inScheme)),\n\t\t\t   (UINT16)(offsetof(NV_Certify_In, size)),\n\t\t\t   (UINT16)(offsetof(NV_Certify_In, offset)),\n\t\t\t   (UINT16)(offsetof(NV_Certify_Out, signature))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL + ADD_FLAG,\n\t\t\t   TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t   TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   TPMT_SIG_SCHEME_P_UNMARSHAL + ADD_FLAG,\n\t\t\t   UINT16_P_UNMARSHAL,\n\t\t\t   UINT16_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_ATTEST_P_MARSHAL,\n\t\t\t   TPMT_SIGNATURE_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _NV_CertifyDataAddress (&_NV_CertifyData)\n#else\n#define _NV_CertifyDataAddress 0\n#endif\n\n#if       CC_NV_DefineSpace2\n#include    \"NV_DefineSpace2_fp.h\"\n\ntypedef TPM_RC (NV_DefineSpace2_Entry)(\n\t\t\t\t       NV_DefineSpace2_In*         in\n\t\t\t\t       );\n\ntypedef const struct\n{\n    NV_DefineSpace2_Entry       *entry;\n    UINT16                      inSize;\n    UINT16                      outSize;\n    UINT16                      offsetOfTypes;\n    UINT16                      paramOffsets[2];\n    BYTE                        types[5];\n} NV_DefineSpace2_COMMAND_DESCRIPTOR_t;\n\nNV_DefineSpace2_COMMAND_DESCRIPTOR_t _NV_DefineSpace2Data = {\n    /* entry         */         &TPM2_NV_DefineSpace2,\n    /* inSize        */         (UINT16)(sizeof(NV_DefineSpace2_In)),\n    /* outSize       */         0,\n    /* offsetOfTypes */         offsetof(NV_DefineSpace2_COMMAND_DESCRIPTOR_t, types),\n    /* offsets       */         {(UINT16)(offsetof(NV_DefineSpace2_In, auth)),\n\t\t\t\t (UINT16)(offsetof(NV_DefineSpace2_In, publicInfo))},\n    /* types         */         {TPMI_RH_PROVISION_H_UNMARSHAL,\n\t\t\t\t TPM2B_AUTH_P_UNMARSHAL,\n\t\t\t\t TPM2B_NV_PUBLIC_2_P_UNMARSHAL,\n\t\t\t\t END_OF_LIST,\n\t\t\t\t END_OF_LIST}\n};\n\n#define _NV_DefineSpace2DataAddress (&_NV_DefineSpace2Data)\n#else\n#define _NV_DefineSpace2DataAddress 0\n#endif // CC_NV_DefineSpace2\n\n#if       CC_NV_ReadPublic2\n#include    \"NV_ReadPublic2_fp.h\"\n\ntypedef TPM_RC (NV_ReadPublic2_Entry)(\n\t\t\t\t      NV_ReadPublic2_In*          in,\n\t\t\t\t      NV_ReadPublic2_Out*         out\n\t\t\t\t      );\n\n\ntypedef const struct\n{\n    NV_ReadPublic2_Entry        *entry;\n    UINT16                      inSize;\n    UINT16                      outSize;\n    UINT16                      offsetOfTypes;\n    UINT16                      paramOffsets[1];\n    BYTE                        types[5];\n} NV_ReadPublic2_COMMAND_DESCRIPTOR_t;\n\nNV_ReadPublic2_COMMAND_DESCRIPTOR_t _NV_ReadPublic2Data = {\n    /* entry         */         &TPM2_NV_ReadPublic2,\n    /* inSize        */         (UINT16)(sizeof(NV_ReadPublic2_In)),\n    /* outSize       */         (UINT16)(sizeof(NV_ReadPublic2_Out)),\n    /* offsetOfTypes */         offsetof(NV_ReadPublic2_COMMAND_DESCRIPTOR_t, types),\n    /* offsets       */         {(UINT16)(offsetof(NV_ReadPublic2_Out, nvName))},\n    /* types         */         {TPMI_RH_NV_INDEX_H_UNMARSHAL,\n\t\t\t\t END_OF_LIST,\n\t\t\t\t TPM2B_NV_PUBLIC_2_P_MARSHAL,\n\t\t\t\t TPM2B_NAME_P_MARSHAL,\n\t\t\t\t END_OF_LIST}\n};\n\n#define _NV_ReadPublic2DataAddress (&_NV_ReadPublic2Data)\n#else\n#define _NV_ReadPublic2DataAddress 0\n#endif // CC_NV_ReadPublic2\n\n#if       CC_SetCapability\n#include    \"SetCapability_fp.h\"\n\ntypedef TPM_RC (SetCapability_Entry)(\n\t\t\t\t     SetCapability_In*        in\n\t\t\t\t     );\n\ntypedef const struct\n{\n    SetCapability_Entry         *entry;\n    UINT16                      inSize;\n    UINT16                      outSize;\n    UINT16                      offsetOfTypes;\n    UINT16                      paramOffsets[1];\n    BYTE                        types[4];\n} SetCapability_COMMAND_DESCRIPTOR_t;\n\nSetCapability_COMMAND_DESCRIPTOR_t _SetCapabilityData = {\n    /* entry         */         &TPM2_SetCapability,\n    /* inSize        */         (UINT16)(sizeof(SetCapability_In)),\n    /* outSize       */         0,\n    /* offsetOfTypes */         offsetof(SetCapability_COMMAND_DESCRIPTOR_t, types),\n    /* offsets       */         {(UINT16)(offsetof(SetCapability_In, setCapabilityData))},\n    /* types         */         {TPMI_RH_HIERARCHY_H_UNMARSHAL,\n\t\t\t\t TPM2B_SET_CAPABILITY_DATA_P_UNMARSHAL,\n\t\t\t\t END_OF_LIST,\n\t\t\t\t END_OF_LIST}\n};\n\n#define _SetCapabilityDataAddress (&_SetCapabilityData)\n#else\n#define _SetCapabilityDataAddress 0\n#endif // CC_SetCapability\n\n#if CC_AC_GetCapability\n#include \"AC_GetCapability_fp.h\"\ntypedef TPM_RC  (AC_GetCapability_Entry)(\n\t\t\t\t\t AC_GetCapability_In *in,\n\t\t\t\t\t AC_GetCapability_Out *out\n\t\t\t\t\t );\ntypedef const struct {\n    AC_GetCapability_Entry    *entry;\n    UINT16                    inSize;\n    UINT16                    outSize;\n    UINT16                    offsetOfTypes;\n    UINT16                    paramOffsets[3];\n    BYTE                      types[7];\n} AC_GetCapability_COMMAND_DESCRIPTOR_t;\nAC_GetCapability_COMMAND_DESCRIPTOR_t _AC_GetCapabilityData = {\n    /* entry  */          &TPM2_AC_GetCapability,\n    /* inSize */          (UINT16)(sizeof(AC_GetCapability_In)),\n    /* outSize */         (UINT16)(sizeof(AC_GetCapability_Out)),\n    /* offsetOfTypes */   offsetof(AC_GetCapability_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(AC_GetCapability_In, capability)),\n\t\t\t   (UINT16)(offsetof(AC_GetCapability_In, count)),\n\t\t\t   (UINT16)(offsetof(AC_GetCapability_Out, capabilitiesData))},\n    /* types */           {TPMI_RH_AC_H_UNMARSHAL,\n\t\t\t   TPM_AT_P_UNMARSHAL,\n\t\t\t   UINT32_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMI_YES_NO_P_MARSHAL,\n\t\t\t   TPML_AC_CAPABILITIES_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _AC_GetCapabilityDataAddress (&_AC_GetCapabilityData)\n#else\n#define _AC_GetCapabilityDataAddress 0\n#endif\n\n#if CC_AC_Send\n#include \"AC_Send_fp.h\"\ntypedef TPM_RC  (AC_Send_Entry)(\n\t\t\t\tAC_Send_In *in,\n\t\t\t\tAC_Send_Out *out\n\t\t\t\t);\ntypedef const struct {\n    AC_Send_Entry    *entry;\n    UINT16           inSize;\n    UINT16           outSize;\n    UINT16           offsetOfTypes;\n    UINT16           paramOffsets[3];\n    BYTE             types[7];\n} AC_Send_COMMAND_DESCRIPTOR_t;\nAC_Send_COMMAND_DESCRIPTOR_t _AC_SendData = {\n    /* entry  */          &TPM2_AC_Send,\n    /* inSize */          (UINT16)(sizeof(AC_Send_In)),\n    /* outSize */         (UINT16)(sizeof(AC_Send_Out)),\n    /* offsetOfTypes */   offsetof(AC_Send_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(AC_Send_In, authHandle)),\n\t\t\t   (UINT16)(offsetof(AC_Send_In, ac)),\n\t\t\t   (UINT16)(offsetof(AC_Send_In, acDataIn))},\n    /* types */           {TPMI_DH_OBJECT_H_UNMARSHAL,\n\t\t\t   TPMI_RH_NV_AUTH_H_UNMARSHAL,\n\t\t\t   TPMI_RH_AC_H_UNMARSHAL,\n\t\t\t   TPM2B_MAX_BUFFER_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPMS_AC_OUTPUT_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _AC_SendDataAddress (&_AC_SendData)\n#else\n#define _AC_SendDataAddress 0\n#endif\n\n#if CC_Policy_AC_SendSelect\n#include \"Policy_AC_SendSelect_fp.h\"\ntypedef TPM_RC  (Policy_AC_SendSelect_Entry)(\n\t\t\t\t\t     Policy_AC_SendSelect_In *in\n\t\t\t\t\t     );\ntypedef const struct {\n    Policy_AC_SendSelect_Entry    *entry;\n    UINT16                        inSize;\n    UINT16                        outSize;\n    UINT16                        offsetOfTypes;\n    UINT16                        paramOffsets[4];\n    BYTE                          types[7];\n} Policy_AC_SendSelect_COMMAND_DESCRIPTOR_t;\nPolicy_AC_SendSelect_COMMAND_DESCRIPTOR_t _Policy_AC_SendSelectData = {\n    /* entry  */          &TPM2_Policy_AC_SendSelect,\n    /* inSize */          (UINT16)(sizeof(Policy_AC_SendSelect_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(Policy_AC_SendSelect_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         {(UINT16)(offsetof(Policy_AC_SendSelect_In, objectName)),\n\t\t\t   (UINT16)(offsetof(Policy_AC_SendSelect_In, authHandleName)),\n\t\t\t   (UINT16)(offsetof(Policy_AC_SendSelect_In, acName)),\n\t\t\t   (UINT16)(offsetof(Policy_AC_SendSelect_In, includeObject))},\n    /* types */           {TPMI_SH_POLICY_H_UNMARSHAL,\n\t\t\t   TPM2B_NAME_P_UNMARSHAL,\n\t\t\t   TPM2B_NAME_P_UNMARSHAL,\n\t\t\t   TPM2B_NAME_P_UNMARSHAL,\n\t\t\t   TPMI_YES_NO_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n#define _Policy_AC_SendSelectDataAddress (&_Policy_AC_SendSelectData)\n#else\n#define _Policy_AC_SendSelectDataAddress 0\n#endif\n\n#if CC_ACT_SetTimeout\n#include \"ACT_SetTimeout_fp.h\"\ntypedef TPM_RC  (ACT_SetTimeout_Entry)(\n\t\t\t\t       ACT_SetTimeout_In           *in\n\t\t\t\t       );\ntypedef const struct {\n    ACT_SetTimeout_Entry    *entry;\n    UINT16                  inSize;\n    UINT16                  outSize;\n    UINT16                  offsetOfTypes;\n    UINT16                  paramOffsets[1];\n    BYTE                    types[4];\n} ACT_SetTimeout_COMMAND_DESCRIPTOR_t;\nACT_SetTimeout_COMMAND_DESCRIPTOR_t _ACT_SetTimeoutData = {\n\t/* entry         */     &TPM2_ACT_SetTimeout,\n\t/* inSize        */     (UINT16)(sizeof(ACT_SetTimeout_In)),\n\t/* outSize       */     0,\n\t/* offsetOfTypes */     offsetof(ACT_SetTimeout_COMMAND_DESCRIPTOR_t, types),\n\t/* offsets\t */\t{(UINT16)(offsetof(ACT_SetTimeout_In, startTimeout))},\n\t/* types         */     {TPMI_RH_ACT_H_UNMARSHAL,\n\t\t\t\t UINT32_P_UNMARSHAL,\n\t\t\t\t END_OF_LIST,\n\t\t\t\t END_OF_LIST}\n};\n#define _ACT_SetTimeoutDataAddress (&_ACT_SetTimeoutData)\n#else\n#define _ACT_SetTimeoutDataAddress 0\n#endif // CC_ACT_SetTimeout\n\n#if CC_Vendor_TCG_Test\n#include \"Vendor_TCG_Test_fp.h\"\ntypedef TPM_RC  (Vendor_TCG_Test_Entry)(\n\t\t\t\t\tVendor_TCG_Test_In *in,\n\t\t\t\t\tVendor_TCG_Test_Out *out\n\t\t\t\t\t);\ntypedef const struct {\n    Vendor_TCG_Test_Entry    *entry;\n    UINT16                   inSize;\n    UINT16                   outSize;\n    UINT16                   offsetOfTypes;\n    BYTE                     types[4];\n} Vendor_TCG_Test_COMMAND_DESCRIPTOR_t;\nVendor_TCG_Test_COMMAND_DESCRIPTOR_t _Vendor_TCG_TestData = {\n    /* entry  */          &TPM2_Vendor_TCG_Test,\n    /* inSize */          (UINT16)(sizeof(Vendor_TCG_Test_In)),\n    /* outSize */         (UINT16)(sizeof(Vendor_TCG_Test_Out)),\n    /* offsetOfTypes */   offsetof(Vendor_TCG_Test_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {TPM2B_DATA_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   TPM2B_DATA_P_MARSHAL,\n\t\t\t   END_OF_LIST}\n};\n#define _Vendor_TCG_TestDataAddress (&_Vendor_TCG_TestData)\n#else\n#define _Vendor_TCG_TestDataAddress 0\n#endif\n\n#ifdef TPM_NUVOTON\n\ntypedef TPM_RC (NTC2_PreConfig_Entry) (\n\t\t\t\t       NTC2_PreConfig_In *in\n\t\t\t\t       );\n\ntypedef const struct {\n    NTC2_PreConfig_Entry    \t*entry;\n    UINT16           \t\tinSize;\n    UINT16           \t\toutSize;\n    UINT16           \t\toffsetOfTypes;\n    BYTE             \t\ttypes[3];\n} NTC2_PreConfig_COMMAND_DESCRIPTOR_t;\n\nNTC2_PreConfig_COMMAND_DESCRIPTOR_t _NTC2_PreConfigData = {\n    /* entry  */          &NTC2_PreConfig,\n    /* inSize */          (UINT16)(sizeof(NTC2_PreConfig_In)),\n    /* outSize */         0,\n    /* offsetOfTypes */   offsetof(NTC2_PreConfig_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */           {NTC2_CFG_STRUCT_P_UNMARSHAL,\n\t\t\t   END_OF_LIST,\n\t\t\t   END_OF_LIST}\n};\n\n#define _NTC2_PreConfigDataAddress (&_NTC2_PreConfigData)\n\ntypedef TPM_RC (NTC2_LockPreConfig_Entry) ();\n\t\t\t\t   \ntypedef const struct {\n    NTC2_LockPreConfig_Entry    *entry;\n    UINT16           \t\tinSize;\n    UINT16           \t\toutSize;\n    UINT16             \t\toffsetOfTypes;\n    BYTE                        types[2];\n} NTC2_LockPreConfig_COMMAND_DESCRIPTOR_t;\n\nNTC2_LockPreConfig_COMMAND_DESCRIPTOR_t _NTC2_LockPreConfigData = {\n    /* entry */\t\t&NTC2_LockPreConfig,\n    /* inSize */        0,\n    /* outSize */       0,\n    /* offsetOfTypes */ offsetof(NTC2_LockPreConfig_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */         {END_OF_LIST,\n\t\t\t END_OF_LIST}\n};\n\n#define _NTC2_LockPreConfigDataAddress (&_NTC2_LockPreConfigData)\n\ntypedef TPM_RC (NTC2_GetConfig_Entry) (\n\t\t\t\t       NTC2_GetConfig_Out *out\n\t\t\t\t       );\ntypedef const struct {\n    NTC2_GetConfig_Entry\t*entry;\n    UINT16             \t\tinSize;\n    UINT16             \t\toutSize;\n    UINT16             \t\toffsetOfTypes;\n    BYTE               \t\ttypes[3];\n} NTC2_GetConfig_COMMAND_DESCRIPTOR_t;\n\nNTC2_GetConfig_COMMAND_DESCRIPTOR_t _NTC2_GetConfigData = {\n    /* entry */\t\t&NTC2_GetConfig,\n    /* inSize */        0,\n    /* outSize */       (UINT16)(sizeof(NTC2_GetConfig_Out)),\n    /* offsetOfTypes */ offsetof(NTC2_GetConfig_COMMAND_DESCRIPTOR_t, types),\n    /* offsets */         // No parameter offsets\n    /* types */         {END_OF_LIST,\n\t\t\t NTC2_CFG_STRUCT_P_MARSHAL,\n\t\t\t END_OF_LIST}\n};\n\n#define _NTC2_GetConfigDataAddress (&_NTC2_GetConfigData)\n\n#else\n#define _NTC2_PreConfigDataAddress 0\n#define _NTC2_LockPreConfigDataAddress 0\n#define _NTC2_GetConfigDataAddress 0\n#endif\t\t/* TPM_NUVOTON */\n\nCOMMAND_DESCRIPTOR_t *s_CommandDataArray[] = {\n#if (PAD_LIST || CC_NV_UndefineSpaceSpecial)\n    (COMMAND_DESCRIPTOR_t *)_NV_UndefineSpaceSpecialDataAddress,\n#endif\n#if (PAD_LIST || CC_EvictControl)\n    (COMMAND_DESCRIPTOR_t *)_EvictControlDataAddress,\n#endif\n#if (PAD_LIST || CC_HierarchyControl)\n    (COMMAND_DESCRIPTOR_t *)_HierarchyControlDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_UndefineSpace)\n    (COMMAND_DESCRIPTOR_t *)_NV_UndefineSpaceDataAddress,\n#endif\n#if (PAD_LIST)\n    (COMMAND_DESCRIPTOR_t *)0,\n#endif\n#if (PAD_LIST || CC_ChangeEPS)\n    (COMMAND_DESCRIPTOR_t *)_ChangeEPSDataAddress,\n#endif\n#if (PAD_LIST || CC_ChangePPS)\n    (COMMAND_DESCRIPTOR_t *)_ChangePPSDataAddress,\n#endif\n#if (PAD_LIST || CC_Clear)\n    (COMMAND_DESCRIPTOR_t *)_ClearDataAddress,\n#endif\n#if (PAD_LIST || CC_ClearControl)\n    (COMMAND_DESCRIPTOR_t *)_ClearControlDataAddress,\n#endif\n#if (PAD_LIST || CC_ClockSet)\n    (COMMAND_DESCRIPTOR_t *)_ClockSetDataAddress,\n#endif\n#if (PAD_LIST || CC_HierarchyChangeAuth)\n    (COMMAND_DESCRIPTOR_t *)_HierarchyChangeAuthDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_DefineSpace)\n    (COMMAND_DESCRIPTOR_t *)_NV_DefineSpaceDataAddress,\n#endif\n#if (PAD_LIST || CC_PCR_Allocate)\n    (COMMAND_DESCRIPTOR_t *)_PCR_AllocateDataAddress,\n#endif\n#if (PAD_LIST || CC_PCR_SetAuthPolicy)\n    (COMMAND_DESCRIPTOR_t *)_PCR_SetAuthPolicyDataAddress,\n#endif\n#if (PAD_LIST || CC_PP_Commands)\n    (COMMAND_DESCRIPTOR_t *)_PP_CommandsDataAddress,\n#endif\n#if (PAD_LIST || CC_SetPrimaryPolicy)\n    (COMMAND_DESCRIPTOR_t *)_SetPrimaryPolicyDataAddress,\n#endif\n#if (PAD_LIST || CC_FieldUpgradeStart)\n    (COMMAND_DESCRIPTOR_t *)_FieldUpgradeStartDataAddress,\n#endif\n#if (PAD_LIST || CC_ClockRateAdjust)\n    (COMMAND_DESCRIPTOR_t *)_ClockRateAdjustDataAddress,\n#endif\n#if (PAD_LIST || CC_CreatePrimary)\n    (COMMAND_DESCRIPTOR_t *)_CreatePrimaryDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_GlobalWriteLock)\n    (COMMAND_DESCRIPTOR_t *)_NV_GlobalWriteLockDataAddress,\n#endif\n#if (PAD_LIST || CC_GetCommandAuditDigest)\n    (COMMAND_DESCRIPTOR_t *)_GetCommandAuditDigestDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_Increment)\n    (COMMAND_DESCRIPTOR_t *)_NV_IncrementDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_SetBits)\n    (COMMAND_DESCRIPTOR_t *)_NV_SetBitsDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_Extend)\n    (COMMAND_DESCRIPTOR_t *)_NV_ExtendDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_Write)\n    (COMMAND_DESCRIPTOR_t *)_NV_WriteDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_WriteLock)\n    (COMMAND_DESCRIPTOR_t *)_NV_WriteLockDataAddress,\n#endif\n#if (PAD_LIST || CC_DictionaryAttackLockReset)\n    (COMMAND_DESCRIPTOR_t *)_DictionaryAttackLockResetDataAddress,\n#endif\n#if (PAD_LIST || CC_DictionaryAttackParameters)\n    (COMMAND_DESCRIPTOR_t *)_DictionaryAttackParametersDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_ChangeAuth)\n    (COMMAND_DESCRIPTOR_t *)_NV_ChangeAuthDataAddress,\n#endif\n#if (PAD_LIST || CC_PCR_Event)\n    (COMMAND_DESCRIPTOR_t *)_PCR_EventDataAddress,\n#endif\n#if (PAD_LIST || CC_PCR_Reset)\n    (COMMAND_DESCRIPTOR_t *)_PCR_ResetDataAddress,\n#endif\n#if (PAD_LIST || CC_SequenceComplete)\n    (COMMAND_DESCRIPTOR_t *)_SequenceCompleteDataAddress,\n#endif\n#if (PAD_LIST || CC_SetAlgorithmSet)\n    (COMMAND_DESCRIPTOR_t *)_SetAlgorithmSetDataAddress,\n#endif\n#if (PAD_LIST || CC_SetCommandCodeAuditStatus)\n    (COMMAND_DESCRIPTOR_t *)_SetCommandCodeAuditStatusDataAddress,\n#endif\n#if (PAD_LIST || CC_FieldUpgradeData)\n    (COMMAND_DESCRIPTOR_t *)_FieldUpgradeDataDataAddress,\n#endif\n#if (PAD_LIST || CC_IncrementalSelfTest)\n    (COMMAND_DESCRIPTOR_t *)_IncrementalSelfTestDataAddress,\n#endif\n#if (PAD_LIST || CC_SelfTest)\n    (COMMAND_DESCRIPTOR_t *)_SelfTestDataAddress,\n#endif\n#if (PAD_LIST || CC_Startup)\n    (COMMAND_DESCRIPTOR_t *)_StartupDataAddress,\n#endif\n#if (PAD_LIST || CC_Shutdown)\n    (COMMAND_DESCRIPTOR_t *)_ShutdownDataAddress,\n#endif\n#if (PAD_LIST || CC_StirRandom)\n    (COMMAND_DESCRIPTOR_t *)_StirRandomDataAddress,\n#endif\n#if (PAD_LIST || CC_ActivateCredential)\n    (COMMAND_DESCRIPTOR_t *)_ActivateCredentialDataAddress,\n#endif\n#if (PAD_LIST || CC_Certify)\n    (COMMAND_DESCRIPTOR_t *)_CertifyDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyNV)\n    (COMMAND_DESCRIPTOR_t *)_PolicyNVDataAddress,\n#endif\n#if (PAD_LIST || CC_CertifyCreation)\n    (COMMAND_DESCRIPTOR_t *)_CertifyCreationDataAddress,\n#endif\n#if (PAD_LIST || CC_Duplicate)\n    (COMMAND_DESCRIPTOR_t *)_DuplicateDataAddress,\n#endif\n#if (PAD_LIST || CC_GetTime)\n    (COMMAND_DESCRIPTOR_t *)_GetTimeDataAddress,\n#endif\n#if (PAD_LIST || CC_GetSessionAuditDigest)\n    (COMMAND_DESCRIPTOR_t *)_GetSessionAuditDigestDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_Read)\n    (COMMAND_DESCRIPTOR_t *)_NV_ReadDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_ReadLock)\n    (COMMAND_DESCRIPTOR_t *)_NV_ReadLockDataAddress,\n#endif\n#if (PAD_LIST || CC_ObjectChangeAuth)\n    (COMMAND_DESCRIPTOR_t *)_ObjectChangeAuthDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicySecret)\n    (COMMAND_DESCRIPTOR_t *)_PolicySecretDataAddress,\n#endif\n#if (PAD_LIST || CC_Rewrap)\n    (COMMAND_DESCRIPTOR_t *)_RewrapDataAddress,\n#endif\n#if (PAD_LIST || CC_Create)\n    (COMMAND_DESCRIPTOR_t *)_CreateDataAddress,\n#endif\n#if (PAD_LIST || CC_ECDH_ZGen)\n    (COMMAND_DESCRIPTOR_t *)_ECDH_ZGenDataAddress,\n#endif\n#if (PAD_LIST || (CC_HMAC || CC_MAC))\n#    if CC_HMAC\n    (COMMAND_DESCRIPTOR_t *)_HMACDataAddress,\n#    endif\n#    if CC_MAC\n    (COMMAND_DESCRIPTOR_t *)_MACDataAddress,\n#    endif\n#    if (CC_HMAC || CC_MAC) > 1\n#        error \"More than one aliased command defined\"\n#    endif\n#endif // CC_HMAC CC_MAC\n#if (PAD_LIST || CC_Import)\n    (COMMAND_DESCRIPTOR_t *)_ImportDataAddress,\n#endif\n#if (PAD_LIST || CC_Load)\n    (COMMAND_DESCRIPTOR_t *)_LoadDataAddress,\n#endif\n#if (PAD_LIST || CC_Quote)\n    (COMMAND_DESCRIPTOR_t *)_QuoteDataAddress,\n#endif\n#if (PAD_LIST || CC_RSA_Decrypt)\n    (COMMAND_DESCRIPTOR_t *)_RSA_DecryptDataAddress,\n#endif\n#if (PAD_LIST)\n    (COMMAND_DESCRIPTOR_t *)0,\n#endif\n#if (PAD_LIST || (CC_HMAC_Start || CC_MAC_Start))\n#    if CC_HMAC_Start\n    (COMMAND_DESCRIPTOR_t *)_HMAC_StartDataAddress,\n#    endif\n#    if CC_MAC_Start\n    (COMMAND_DESCRIPTOR_t *)_MAC_StartDataAddress,\n#    endif\n#    if (CC_HMAC_Start || CC_MAC_Start) > 1\n#        error \"More than one aliased command defined\"\n#    endif\n#endif // CC_HMAC_Start CC_MAC_Start\n#if (PAD_LIST || CC_SequenceUpdate)\n    (COMMAND_DESCRIPTOR_t *)_SequenceUpdateDataAddress,\n#endif\n#if (PAD_LIST || CC_Sign)\n    (COMMAND_DESCRIPTOR_t *)_SignDataAddress,\n#endif\n#if (PAD_LIST || CC_Unseal)\n    (COMMAND_DESCRIPTOR_t *)_UnsealDataAddress,\n#endif\n#if (PAD_LIST)\n    (COMMAND_DESCRIPTOR_t *)0,\n#endif\n#if (PAD_LIST || CC_PolicySigned)\n    (COMMAND_DESCRIPTOR_t *)_PolicySignedDataAddress,\n#endif\n#if (PAD_LIST || CC_ContextLoad)\n    (COMMAND_DESCRIPTOR_t *)_ContextLoadDataAddress,\n#endif\n#if (PAD_LIST || CC_ContextSave)\n    (COMMAND_DESCRIPTOR_t *)_ContextSaveDataAddress,\n#endif\n#if (PAD_LIST || CC_ECDH_KeyGen)\n    (COMMAND_DESCRIPTOR_t *)_ECDH_KeyGenDataAddress,\n#endif\n#if (PAD_LIST || CC_EncryptDecrypt)\n    (COMMAND_DESCRIPTOR_t *)_EncryptDecryptDataAddress,\n#endif\n#if (PAD_LIST || CC_FlushContext)\n    (COMMAND_DESCRIPTOR_t *)_FlushContextDataAddress,\n#endif\n#if (PAD_LIST)\n    (COMMAND_DESCRIPTOR_t *)0,\n#endif\n#if (PAD_LIST || CC_LoadExternal)\n    (COMMAND_DESCRIPTOR_t *)_LoadExternalDataAddress,\n#endif\n#if (PAD_LIST || CC_MakeCredential)\n    (COMMAND_DESCRIPTOR_t *)_MakeCredentialDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_ReadPublic)\n    (COMMAND_DESCRIPTOR_t *)_NV_ReadPublicDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyAuthorize)\n    (COMMAND_DESCRIPTOR_t *)_PolicyAuthorizeDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyAuthValue)\n    (COMMAND_DESCRIPTOR_t *)_PolicyAuthValueDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyCommandCode)\n    (COMMAND_DESCRIPTOR_t *)_PolicyCommandCodeDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyCounterTimer)\n    (COMMAND_DESCRIPTOR_t *)_PolicyCounterTimerDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyCpHash)\n    (COMMAND_DESCRIPTOR_t *)_PolicyCpHashDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyLocality)\n    (COMMAND_DESCRIPTOR_t *)_PolicyLocalityDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyNameHash)\n    (COMMAND_DESCRIPTOR_t *)_PolicyNameHashDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyOR)\n    (COMMAND_DESCRIPTOR_t *)_PolicyORDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyTicket)\n    (COMMAND_DESCRIPTOR_t *)_PolicyTicketDataAddress,\n#endif\n#if (PAD_LIST || CC_ReadPublic)\n    (COMMAND_DESCRIPTOR_t *)_ReadPublicDataAddress,\n#endif\n#if (PAD_LIST || CC_RSA_Encrypt)\n    (COMMAND_DESCRIPTOR_t *)_RSA_EncryptDataAddress,\n#endif\n#if (PAD_LIST)\n    (COMMAND_DESCRIPTOR_t *)0,\n#endif\n#if (PAD_LIST || CC_StartAuthSession)\n    (COMMAND_DESCRIPTOR_t *)_StartAuthSessionDataAddress,\n#endif\n#if (PAD_LIST || CC_VerifySignature)\n    (COMMAND_DESCRIPTOR_t *)_VerifySignatureDataAddress,\n#endif\n#if (PAD_LIST || CC_ECC_Parameters)\n    (COMMAND_DESCRIPTOR_t *)_ECC_ParametersDataAddress,\n#endif\n#if (PAD_LIST || CC_FirmwareRead)\n    (COMMAND_DESCRIPTOR_t *)_FirmwareReadDataAddress,\n#endif\n#if (PAD_LIST || CC_GetCapability)\n    (COMMAND_DESCRIPTOR_t *)_GetCapabilityDataAddress,\n#endif\n#if (PAD_LIST || CC_GetRandom)\n    (COMMAND_DESCRIPTOR_t *)_GetRandomDataAddress,\n#endif\n#if (PAD_LIST || CC_GetTestResult)\n    (COMMAND_DESCRIPTOR_t *)_GetTestResultDataAddress,\n#endif\n#if (PAD_LIST || CC_Hash)\n    (COMMAND_DESCRIPTOR_t *)_HashDataAddress,\n#endif\n#if (PAD_LIST || CC_PCR_Read)\n    (COMMAND_DESCRIPTOR_t *)_PCR_ReadDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyPCR)\n    (COMMAND_DESCRIPTOR_t *)_PolicyPCRDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyRestart)\n    (COMMAND_DESCRIPTOR_t *)_PolicyRestartDataAddress,\n#endif\n#if (PAD_LIST || CC_ReadClock)\n    (COMMAND_DESCRIPTOR_t *)_ReadClockDataAddress,\n#endif\n#if (PAD_LIST || CC_PCR_Extend)\n    (COMMAND_DESCRIPTOR_t *)_PCR_ExtendDataAddress,\n#endif\n#if (PAD_LIST || CC_PCR_SetAuthValue)\n    (COMMAND_DESCRIPTOR_t *)_PCR_SetAuthValueDataAddress,\n#endif\n#if (PAD_LIST || CC_NV_Certify)\n    (COMMAND_DESCRIPTOR_t *)_NV_CertifyDataAddress,\n#endif\n#if (PAD_LIST || CC_EventSequenceComplete)\n    (COMMAND_DESCRIPTOR_t *)_EventSequenceCompleteDataAddress,\n#endif\n#if (PAD_LIST || CC_HashSequenceStart)\n    (COMMAND_DESCRIPTOR_t *)_HashSequenceStartDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyPhysicalPresence)\n    (COMMAND_DESCRIPTOR_t *)_PolicyPhysicalPresenceDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyDuplicationSelect)\n    (COMMAND_DESCRIPTOR_t *)_PolicyDuplicationSelectDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyGetDigest)\n    (COMMAND_DESCRIPTOR_t *)_PolicyGetDigestDataAddress,\n#endif\n#if (PAD_LIST || CC_TestParms)\n    (COMMAND_DESCRIPTOR_t *)_TestParmsDataAddress,\n#endif\n#if (PAD_LIST || CC_Commit)\n    (COMMAND_DESCRIPTOR_t *)_CommitDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyPassword)\n    (COMMAND_DESCRIPTOR_t *)_PolicyPasswordDataAddress,\n#endif\n#if (PAD_LIST || CC_ZGen_2Phase)\n    (COMMAND_DESCRIPTOR_t *)_ZGen_2PhaseDataAddress,\n#endif\n#if (PAD_LIST || CC_EC_Ephemeral)\n    (COMMAND_DESCRIPTOR_t *)_EC_EphemeralDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyNvWritten)\n    (COMMAND_DESCRIPTOR_t *)_PolicyNvWrittenDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyTemplate)\n    (COMMAND_DESCRIPTOR_t *)_PolicyTemplateDataAddress,\n#endif\n#if (PAD_LIST || CC_CreateLoaded)\n    (COMMAND_DESCRIPTOR_t *)_CreateLoadedDataAddress,\n#endif\n#if (PAD_LIST || CC_PolicyAuthorizeNV)\n    (COMMAND_DESCRIPTOR_t *)_PolicyAuthorizeNVDataAddress,\n#endif\n#if (PAD_LIST || CC_EncryptDecrypt2)\n    (COMMAND_DESCRIPTOR_t *)_EncryptDecrypt2DataAddress,\n#endif\n#if (PAD_LIST || CC_AC_GetCapability)\n    (COMMAND_DESCRIPTOR_t *)_AC_GetCapabilityDataAddress,\n#endif // CC_AC_GetCapability\n#if (PAD_LIST || CC_AC_Send)\n    (COMMAND_DESCRIPTOR_t *)_AC_SendDataAddress,\n#endif // CC_AC_Send\n#if (PAD_LIST || CC_Policy_AC_SendSelect)\n    (COMMAND_DESCRIPTOR_t *)_Policy_AC_SendSelectDataAddress,\n#endif // CC_Policy_AC_SendSelect\n#if (PAD_LIST || CC_CertifyX509)\n    (COMMAND_DESCRIPTOR_t *)_CertifyX509DataAddress,\n#endif // CC_CertifyX509\n#if (PAD_LIST || CC_ACT_SetTimeout)\n    (COMMAND_DESCRIPTOR_t *)_ACT_SetTimeoutDataAddress,\n#endif // CC_ACT_SetTimeout\n#if (PAD_LIST || CC_ECC_Encrypt)\n    (COMMAND_DESCRIPTOR_t *)_ECC_EncryptDataAddress,\n#endif // CC_ECC_Encrypt\n#if (PAD_LIST || CC_ECC_Decrypt)\n    (COMMAND_DESCRIPTOR_t *)_ECC_DecryptDataAddress,\n#endif // CC_ECC_Decrypt\n#if (PAD_LIST || CC_PolicyCapability)\n    (COMMAND_DESCRIPTOR_t*)_PolicyCapabilityDataAddress,\n#endif // CC_PolicyCapability\n#if (PAD_LIST || CC_PolicyParameters)\n    (COMMAND_DESCRIPTOR_t*)_PolicyParametersDataAddress,\n#endif // CC_PolicyParameters\n#if (PAD_LIST || CC_NV_DefineSpace2)\n    (COMMAND_DESCRIPTOR_t*)_NV_DefineSpace2DataAddress,\n#endif // CC_NV_DefineSpace2\n#if (PAD_LIST || CC_NV_ReadPublic2)\n    (COMMAND_DESCRIPTOR_t*)_NV_ReadPublic2DataAddress,\n#endif // CC_NV_ReadPublic2\n#if (PAD_LIST || CC_SetCapability)\n    (COMMAND_DESCRIPTOR_t*)_SetCapabilityDataAddress,\n#endif // CC_SetCapability\n#if (PAD_LIST || CC_Vendor_TCG_Test)\n    (COMMAND_DESCRIPTOR_t *)_Vendor_TCG_TestDataAddress,\n#endif\n#ifdef TPM_NUVOTON\n#if (PAD_LIST || TPM_NUVOTON)\n    (COMMAND_DESCRIPTOR_t *)_NTC2_PreConfigDataAddress,\n    (COMMAND_DESCRIPTOR_t *)_NTC2_LockPreConfigDataAddress,\n    (COMMAND_DESCRIPTOR_t *)_NTC2_GetConfigDataAddress,\n#endif\n#endif    \n    0\n};\n\n#endif  // _COMMAND_TABLE_DISPATCH_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CommandDispatcher_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CommandDispatcher_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef COMMANDDISPATCHER_FP_H\n#define COMMANDDISPATCHER_FP_H\n\nTPM_RC\nCommandDispatcher(\n\t\t  COMMAND                 *command\n\t\t  );\nTPM_RC\nParseHandleBuffer(\n\t\t  COMMAND                 *command\n\t\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Commands.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Command Header Includes   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Commands.h 1594 2020-03-26 22:15:48Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef COMMANDS_H\n#define COMMANDS_H\n\n#if CC_Startup\n#include \"Startup_fp.h\"\n#endif\n#if CC_Shutdown\n#include \"Shutdown_fp.h\"\n#endif\n/* Testing */\n#if CC_SelfTest\n#include \"SelfTest_fp.h\"\n#endif\n#if CC_IncrementalSelfTest\n#include \"IncrementalSelfTest_fp.h\"\n#endif\n#if CC_GetTestResult\n#include \"GetTestResult_fp.h\"\n#endif\n/* Session Commands */\n#if CC_StartAuthSession\n#include \"StartAuthSession_fp.h\"\n#endif\n#if CC_PolicyRestart\n#include \"PolicyRestart_fp.h\"\n#endif\n/* Object Commands */\n#if CC_Create\n#include \"Create_fp.h\"\n#endif\n#if CC_Load\n#include \"Load_fp.h\"\n#endif\n#if CC_LoadExternal\n#include \"LoadExternal_fp.h\"\n#endif\n#if CC_ReadPublic\n#include \"ReadPublic_fp.h\"\n#endif\n#if CC_ActivateCredential\n#include \"ActivateCredential_fp.h\"\n#endif\n#if CC_MakeCredential\n#include \"MakeCredential_fp.h\"\n#endif\n#if CC_Unseal\n#include \"Unseal_fp.h\"\n#endif\n#if CC_ObjectChangeAuth\n#include \"ObjectChangeAuth_fp.h\"\n#endif\n#if CC_CreateLoaded\n#include \"CreateLoaded_fp.h\"\n#endif\n/* Duplication Commands */\n#if CC_Duplicate\n#include \"Duplicate_fp.h\"\n#endif\n#if CC_Rewrap\n#include \"Rewrap_fp.h\"\n#endif\n#if CC_Import\n#include \"Import_fp.h\"\n#endif\n/* Asymmetric Primitives */\n#if CC_RSA_Encrypt\n#include \"RSA_Encrypt_fp.h\"\n#endif\n#if CC_RSA_Decrypt\n#include \"RSA_Decrypt_fp.h\"\n#endif\n#if CC_ECDH_KeyGen\n#include \"ECDH_KeyGen_fp.h\"\n#endif\n#if CC_ECDH_ZGen\n#include \"ECDH_ZGen_fp.h\"\n#endif\n#if CC_ECC_Parameters\n#include \"ECC_Parameters_fp.h\"\n#endif\n#if CC_ZGen_2Phase\n#include \"ZGen_2Phase_fp.h\"\n#endif\n#if CC_ECC_Encrypt\n#include \"ECC_Encrypt_fp.h\"\n#endif\n#if CC_ECC_Decrypt\n#include \"ECC_Decrypt_fp.h\"\n#endif\n/* Symmetric Primitives */\n#if CC_EncryptDecrypt\n#include \"EncryptDecrypt_fp.h\"\n#endif\n#if CC_EncryptDecrypt2\n#include \"EncryptDecrypt2_fp.h\"\n#endif\n#if CC_Hash\n#include \"Hash_fp.h\"\n#endif\n#if CC_HMAC\n#include \"HMAC_fp.h\"\n#endif\n#if CC_MAC\n#include \"MAC_fp.h\"\n#endif\n/* Random Number Generator */\n#if CC_GetRandom\n#include \"GetRandom_fp.h\"\n#endif\n#if CC_StirRandom\n#include \"StirRandom_fp.h\"\n#endif\n/* Hash/HMAC/Event Sequences */\n#if CC_HMAC_Start\n#include \"HMAC_Start_fp.h\"\n#endif\n#if CC_MAC_Start\n#include \"MAC_Start_fp.h\"\n#endif\n#if CC_HashSequenceStart\n#include \"HashSequenceStart_fp.h\"\n#endif\n#if CC_SequenceUpdate\n#include \"SequenceUpdate_fp.h\"\n#endif\n#if CC_SequenceComplete\n#include \"SequenceComplete_fp.h\"\n#endif\n#if CC_EventSequenceComplete\n#include \"EventSequenceComplete_fp.h\"\n#endif\n/* Attestation Commands */\n#if CC_Certify\n#include \"Certify_fp.h\"\n#endif\n#if CC_CertifyCreation\n#include \"CertifyCreation_fp.h\"\n#endif\n#if CC_CertifyX509\n#include \"CertifyX509_fp.h\"\n#endif\n#if CC_Quote\n#include \"Quote_fp.h\"\n#endif\n#if CC_GetSessionAuditDigest\n#include \"GetSessionAuditDigest_fp.h\"\n#endif\n#if CC_GetCommandAuditDigest\n#include \"GetCommandAuditDigest_fp.h\"\n#endif\n#if CC_GetTime\n#include \"GetTime_fp.h\"\n#endif\n#ifdef TPM_CC_CertifyX509\n#include \"CertifyX509_fp.h\"\n#endif\n/* Ephemeral EC Keys */\n#if CC_Commit\n#include \"Commit_fp.h\"\n#endif\n#if CC_EC_Ephemeral\n#include \"EC_Ephemeral_fp.h\"\n#endif\n/* Signing and Signature Verification */\n#if CC_VerifySignature\n#include \"VerifySignature_fp.h\"\n#endif\n#if CC_Sign\n#include \"Sign_fp.h\"\n#endif\n/* Command Audit */\n#if CC_SetCommandCodeAuditStatus\n#include \"SetCommandCodeAuditStatus_fp.h\"\n#endif\n/* Integrity Collection (PCR) */\n#if CC_PCR_Extend\n#include \"PCR_Extend_fp.h\"\n#endif\n#if CC_PCR_Event\n#include \"PCR_Event_fp.h\"\n#endif\n#if CC_PCR_Read\n#include \"PCR_Read_fp.h\"\n#endif\n#if CC_PCR_Allocate\n#include \"PCR_Allocate_fp.h\"\n#endif\n#if CC_PCR_SetAuthPolicy\n#include \"PCR_SetAuthPolicy_fp.h\"\n#endif\n#if CC_PCR_SetAuthValue\n#include \"PCR_SetAuthValue_fp.h\"\n#endif\n#if CC_PCR_Reset\n#include \"PCR_Reset_fp.h\"\n#endif\n/* Enhanced Authorization (EA) Commands */\n#if CC_PolicySigned\n#include \"PolicySigned_fp.h\"\n#endif\n#if CC_PolicySecret\n#include \"PolicySecret_fp.h\"\n#endif\n#if CC_PolicyTicket\n#include \"PolicyTicket_fp.h\"\n#endif\n#if CC_PolicyOR\n#include \"PolicyOR_fp.h\"\n#endif\n#if CC_PolicyPCR\n#include \"PolicyPCR_fp.h\"\n#endif\n#if CC_PolicyLocality\n#include \"PolicyLocality_fp.h\"\n#endif\n#if CC_PolicyNV\n#include \"PolicyNV_fp.h\"\n#endif\n#if CC_PolicyCounterTimer\n#include \"PolicyCounterTimer_fp.h\"\n#endif\n#if CC_PolicyCommandCode\n#include \"PolicyCommandCode_fp.h\"\n#endif\n#if CC_PolicyPhysicalPresence\n#include \"PolicyPhysicalPresence_fp.h\"\n#endif\n#if CC_PolicyCpHash\n#include \"PolicyCpHash_fp.h\"\n#endif\n#if CC_PolicyNameHash\n#include \"PolicyNameHash_fp.h\"\n#endif\n#if CC_PolicyDuplicationSelect\n#include \"PolicyDuplicationSelect_fp.h\"\n#endif\n#if CC_PolicyAuthorize\n#include \"PolicyAuthorize_fp.h\"\n#endif\n#if CC_PolicyAuthValue\n#include \"PolicyAuthValue_fp.h\"\n#endif\n#if CC_PolicyPassword\n#include \"PolicyPassword_fp.h\"\n#endif\n#if CC_PolicyGetDigest\n#include \"PolicyGetDigest_fp.h\"\n#endif\n#if CC_PolicyNvWritten\n#include \"PolicyNvWritten_fp.h\"\n#endif\n#if CC_PolicyTemplate\n#include \"PolicyTemplate_fp.h\"\n#endif\n#if CC_PolicyAuthorizeNV\n#include \"PolicyAuthorizeNV_fp.h\"\n#endif\n#if CC_PolicyCapability\n#include \"PolicyCapability_fp.h\"\n#endif\n#if CC_PolicyParameters\n#include \"PolicyParameters_fp.h\"\n#endif\n/* Hierarchy Commands */\n#if CC_CreatePrimary\n#include \"CreatePrimary_fp.h\"\n#endif\n#if CC_HierarchyControl\n#include \"HierarchyControl_fp.h\"\n#endif\n#if CC_SetPrimaryPolicy\n#include \"SetPrimaryPolicy_fp.h\"\n#endif\n#if CC_ChangePPS\n#include \"ChangePPS_fp.h\"\n#endif\n#if CC_ChangeEPS\n#include \"ChangeEPS_fp.h\"\n#endif\n#if CC_Clear\n#include \"Clear_fp.h\"\n#endif\n#if CC_ClearControl\n#include \"ClearControl_fp.h\"\n#endif\n#if CC_HierarchyChangeAuth\n#include \"HierarchyChangeAuth_fp.h\"\n#endif\n/* Dictionary Attack Functions */\n#if CC_DictionaryAttackLockReset\n#include \"DictionaryAttackLockReset_fp.h\"\n#endif\n#if CC_DictionaryAttackParameters\n#include \"DictionaryAttackParameters_fp.h\"\n#endif\n/* Miscellaneous Management Functions */\n#if CC_PP_Commands\n#include \"PP_Commands_fp.h\"\n#endif\n#if CC_SetAlgorithmSet\n#include \"SetAlgorithmSet_fp.h\"\n#endif\n/* Field Upgrade */\n#if CC_FieldUpgradeStart\n#include \"FieldUpgradeStart_fp.h\"\n#endif\n#if CC_FieldUpgradeData\n#include \"FieldUpgradeData_fp.h\"\n#endif\n#if CC_FirmwareRead\n#include \"FirmwareRead_fp.h\"\n#endif\n/* Context Management */\n#if CC_ContextSave\n#include \"ContextSave_fp.h\"\n#endif\n#if CC_ContextLoad\n#include \"ContextLoad_fp.h\"\n#endif\n#if CC_FlushContext\n#include \"FlushContext_fp.h\"\n#endif\n#if CC_EvictControl\n#include \"EvictControl_fp.h\"\n#endif\n/* Clocks and Timers */\n#if CC_ReadClock\n#include \"ReadClock_fp.h\"\n#endif\n#if CC_ClockSet\n#include \"ClockSet_fp.h\"\n#endif\n#if CC_ClockRateAdjust\n#include \"ClockRateAdjust_fp.h\"\n#endif\n/* Capability Commands */\n#if CC_GetCapability\n#include \"GetCapability_fp.h\"\n#endif\n#if CC_TestParms\n#include \"TestParms_fp.h\"\n#endif\n#if CC_NV_DefineSpace\n#include \"NV_DefineSpace_fp.h\"\n#endif\n#if CC_NV_UndefineSpace\n#include \"NV_UndefineSpace_fp.h\"\n#endif\n#if CC_NV_UndefineSpaceSpecial\n#include \"NV_UndefineSpaceSpecial_fp.h\"\n#endif\n#if CC_NV_ReadPublic\n#include \"NV_ReadPublic_fp.h\"\n#endif\n#if CC_NV_Write\n#include \"NV_Write_fp.h\"\n#endif\n#if CC_NV_Increment\n#include \"NV_Increment_fp.h\"\n#endif\n#if CC_NV_Extend\n#include \"NV_Extend_fp.h\"\n#endif\n#if CC_NV_SetBits\n#include \"NV_SetBits_fp.h\"\n#endif\n#if CC_NV_WriteLock\n#include \"NV_WriteLock_fp.h\"\n#endif\n#if CC_NV_GlobalWriteLock\n#include \"NV_GlobalWriteLock_fp.h\"\n#endif\n#if CC_NV_Read\n#include \"NV_Read_fp.h\"\n#endif\n#if CC_NV_ReadLock\n#include \"NV_ReadLock_fp.h\"\n#endif\n#if CC_NV_ChangeAuth\n#include \"NV_ChangeAuth_fp.h\"\n#endif\n#if CC_NV_Certify\n#include \"NV_Certify_fp.h\"\n#endif\n#if CC_NV_DefineSpace2\n#  include \"NV_DefineSpace2_fp.h\"\n#endif\n#if CC_NV_ReadPublic2\n#  include \"NV_ReadPublic2_fp.h\"\n#endif\n#if CC_SetCapability\n#  include \"SetCapability_fp.h\"\n#endif\n\n/* Attached Components */\n\n#if CC_AC_GetCapability\n#include \"AC_GetCapability_fp.h\"\n#endif\n#if CC_AC_Send\n#include \"AC_Send_fp.h\"\n#endif\n#if CC_Policy_AC_SendSelect\n#include \"Policy_AC_SendSelect_fp.h\"\n#endif\n\n/* Authenticated Countdown Timer */\n#ifdef TPM_CC_ACT_SetTimeout\n#include \"ACT_SetTimeout_fp.h\"\n#endif\n\n/* Vendor Specific */\n#if CC_Vendor_TCG_Test\n#include \"Vendor_TCG_Test_fp.h\"\n#endif\n\n/* Nuvoton Commands */\n#ifdef TPM_NUVOTON\n#include \"ntc2_fp.h\"\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Commit_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Commit_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef COMMIT_FP_H\n#define COMMIT_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tsignHandle;\n    TPM2B_ECC_POINT\t\tP1;\n    TPM2B_SENSITIVE_DATA\ts2;\n    TPM2B_ECC_PARAMETER\t\ty2;\n} Commit_In;\n\n#define RC_Commit_signHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_Commit_P1 \t\t(TPM_RC_P + TPM_RC_1)\n#define RC_Commit_s2 \t\t(TPM_RC_P + TPM_RC_2)\n#define RC_Commit_y2 \t\t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPM2B_ECC_POINT\tK;\n    TPM2B_ECC_POINT\tL;\n    TPM2B_ECC_POINT\tE;\n    UINT16\t\tcounter;\n} Commit_Out;\n\nTPM_RC\nTPM2_Commit(\n\t    Commit_In       *in,            // IN: input parameter list\n\t    Commit_Out      *out            // OUT: output parameter list\n\t    );\n\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CompilerDependencies.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This file contains the build switches. This contains switches for multiple\n// versions of the crypto-library so some may not apply to your environment.\n//\n\n#ifndef _COMPILER_DEPENDENCIES_H_\n#define _COMPILER_DEPENDENCIES_H_\n\n#if defined(__GNUC__)\n#  include \"CompilerDependencies_gcc.h\"\n#elif defined(_MSC_VER)\n#  include \"CompilerDependencies_msvc.h\"\n#else\n#  error unexpected\n#endif\n\n#include <stdint.h>\n\n// Things that are not defined should be defined as NULL\n\n#ifndef NORETURN\n#  define NORETURN\n#endif\n#ifndef LIB_EXPORT\n#  define LIB_EXPORT\n#endif\n#ifndef LIB_IMPORT\n#  define LIB_IMPORT\n#endif\n#ifndef _REDUCE_WARNING_LEVEL_\n#  define _REDUCE_WARNING_LEVEL_(n)\n#endif\n#ifndef _NORMAL_WARNING_LEVEL_\n#  define _NORMAL_WARNING_LEVEL_\n#endif\n#ifndef NOT_REFERENCED\n#  define NOT_REFERENCED(x) (x = x)\n#endif\n\n#ifdef _POSIX_\ntypedef int SOCKET;\n#endif\n\n#if !defined(TPM_STATIC_ASSERT) || !defined(COMPILER_CHECKS)\n#  error Expect definitions of COMPILER_CHECKS and TPM_STATIC_ASSERT\n#elif COMPILER_CHECKS\n// pre static_assert static_assert\n#  define MUST_BE(e) TPM_STATIC_ASSERT(e)\n\n#else\n// intentionally disabled, fine.\n#  define MUST_BE(e)\n#endif\n\n#endif  // _COMPILER_DEPENDENCIES_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CompilerDependencies_gcc.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This file contains compiler specific switches.\n// These definitions are for the GCC compiler\n//\n\n#ifndef _COMPILER_DEPENDENCIES_GCC_H_\n#define _COMPILER_DEPENDENCIES_GCC_H_\n\n#if !defined(__GNUC__)\n#  error CompilerDependencies_gcc.h included for wrong compiler\n#endif\n\n// don't warn on unused local typedefs, they are used as a\n// cross-compiler static_assert\n#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wunused-local-typedefs\"\n#pragma GCC diagnostic pop\n\n#undef _MSC_VER\n#undef WIN32\n\n#ifndef WINAPI\n#  define WINAPI\n#endif\n#ifndef __pragma\n#  define __pragma(x)\n#endif\n#define REVERSE_ENDIAN_16(_Number) __builtin_bswap16(_Number)\n#define REVERSE_ENDIAN_32(_Number) __builtin_bswap32(_Number)\n#define REVERSE_ENDIAN_64(_Number) __builtin_bswap64(_Number)\n\n#define NORETURN __attribute__((noreturn))\n\n#define TPM_INLINE           inline __attribute__((always_inline))\n#define TPM_STATIC_ASSERT(e) _Static_assert(e, \"static assert\")\n#endif  // _COMPILER_DEPENDENCIES_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CompilerDependencies_msvc.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This file contains compiler specific switches.\n// These definitions are for the Microsoft compiler\n//\n\n#ifndef _COMPILER_DEPENDENCIES_MSVC_H_\n#define _COMPILER_DEPENDENCIES_MSVC_H_\n\n#if !defined(_MSC_VER)\n#  error CompilerDependencies_msvc.h included for wrong compiler\n#endif\n\n// Endian conversion for aligned structures\n#define REVERSE_ENDIAN_16(_Number) _byteswap_ushort(_Number)\n#define REVERSE_ENDIAN_32(_Number) _byteswap_ulong(_Number)\n#define REVERSE_ENDIAN_64(_Number) _byteswap_uint64(_Number)\n\n// Avoid compiler warning for in line of stdio (or not)\n//#define _NO_CRT_STDIO_INLINE\n\n// This macro is used to handle LIB_EXPORT of function and variable names in lieu\n// of a .def file. Visual Studio requires that functions be explicitly exported and\n// imported.\n#ifdef TPM_AS_DLL\n#  define LIB_EXPORT __declspec(dllexport)  // VS compatible version\n#  define LIB_IMPORT __declspec(dllimport)\n#else\n// building static libraries\n#  define LIB_EXPORT\n#  define LIB_IMPORT\n#endif\n\n#define TPM_INLINE inline\n\n// This is defined to indicate a function that does not return. Microsoft compilers\n// do not support the _Noretrun function parameter.\n#define NORETURN __declspec(noreturn)\n#if _MSC_VER >= 1400  // SAL processing when needed\n#  include <sal.h>\n#endif\n\n// #  ifdef _WIN64\n// #    define _INTPTR 2\n// #  else\n// #    define _INTPTR 1\n// #  endif\n\n#define NOT_REFERENCED(x) (x)\n\n// Lower the compiler error warning for system include\n// files. They tend not to be that clean and there is no\n// reason to sort through all the spurious errors that they\n// generate when the normal error level is set to /Wall\n#define _REDUCE_WARNING_LEVEL_(n) __pragma(warning(push, n))\n// Restore the compiler warning level\n#define _NORMAL_WARNING_LEVEL_ __pragma(warning(pop))\n#include <stdint.h>\n\n#ifdef TPM_STATIC_ASSERT\n#  error TPM_STATIC_ASSERT already defined\n#endif\n\n// MSVC: failure results in error C2118: negative subscript error\n#define TPM_STATIC_ASSERT(e) typedef char __C_ASSERT__[(e) ? 1 : -1]\n\n#endif  // _COMPILER_DEPENDENCIES_MSVC_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ContextLoad_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ContextLoad_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CONTEXTLOAD_FP_H\n#define CONTEXTLOAD_FP_H\n\ntypedef struct {\n    TPMS_CONTEXT\tcontext;\n} ContextLoad_In;\n\n#define RC_ContextLoad_context \t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPMI_DH_CONTEXT\tloadedHandle;\n} ContextLoad_Out;\n\nTPM_RC\nTPM2_ContextLoad(\n\t\t ContextLoad_In      *in,            // IN: input parameter list\n\t\t ContextLoad_Out     *out            // OUT: output parameter list\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ContextSave_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ContextSave_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CONTEXTSAVE_FP_H\n#define CONTEXTSAVE_FP_H\n\ntypedef struct {\n    TPMI_DH_CONTEXT\tsaveHandle;\n} ContextSave_In;\n\n#define RC_ContextSave_saveHandle\t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPMS_CONTEXT\tcontext;\n} ContextSave_Out;\n\nTPM_RC\nTPM2_ContextSave(\n\t\t ContextSave_In      *in,            // IN: input parameter list\n\t\t ContextSave_Out     *out            // OUT: output parameter list\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Context_spt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar 28, 2019  Time: 08:25:18PM\n */\n\n#ifndef _CONTEXT_SPT_FP_H_\n#define _CONTEXT_SPT_FP_H_\n\n//*** ComputeContextProtectionKey()\n// This function retrieves the symmetric protection key for context encryption\n// It is used by TPM2_ConextSave and TPM2_ContextLoad to create the symmetric\n// encryption key and iv\n//  Return Type: TPM_RC\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects or the TPM failed\n//                              to derive the Firmware Secret.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the TPM\n//                              failed to derive the Firmware SVN Secret for the\n//                              requested SVN.\nTPM_RC ComputeContextProtectionKey(TPMS_CONTEXT*  contextBlob,  // IN: context blob\n\t\t\t\t   TPM2B_SYM_KEY* symKey,  // OUT: the symmetric key\n\t\t\t\t   TPM2B_IV*      iv       // OUT: the IV.\n\t\t\t\t   );\n\n//*** ComputeContextIntegrity()\n// Generate the integrity hash for a context\n//       It is used by TPM2_ContextSave to create an integrity hash\n//       and by TPM2_ContextLoad to compare an integrity hash\n//  Return Type: TPM_RC\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects or the TPM failed\n//                              to derive the Firmware Secret.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the TPM\n//                              failed to derive the Firmware SVN Secret for the\n//                              requested SVN.\nTPM_RC ComputeContextIntegrity(TPMS_CONTEXT* contextBlob,  // IN: context blob\n\t\t\t       TPM2B_DIGEST* integrity     // OUT: integrity\n\t\t\t       );\n\n//*** SequenceDataExport()\n// This function is used scan through the sequence object and\n// either modify the hash state data for export (contextSave) or to\n// import it into the internal format (contextLoad).\n// This function should only be called after the sequence object has been copied\n// to the context buffer (contextSave) or from the context buffer into the sequence\n// object. The presumption is that the context buffer version of the data is the\n// same size as the internal representation so nothing outsize of the hash context\n// area gets modified.\nvoid SequenceDataExport(\n\t\t\tHASH_OBJECT*        object,       // IN: an internal hash object\n\t\t\tHASH_OBJECT_BUFFER* exportObject  // OUT: a sequence context in a buffer\n\t\t\t);\n\n//*** SequenceDataImport()\n// This function is used scan through the sequence object and\n// either modify the hash state data for export (contextSave) or to\n// import it into the internal format (contextLoad).\n// This function should only be called after the sequence object has been copied\n// to the context buffer (contextSave) or from the context buffer into the sequence\n// object. The presumption is that the context buffer version of the data is the\n// same size as the internal representation so nothing outsize of the hash context\n// area gets modified.\nvoid SequenceDataImport(\n\t\t\tHASH_OBJECT*        object,       // IN/OUT: an internal hash object\n\t\t\tHASH_OBJECT_BUFFER* exportObject  // IN/OUT: a sequence context in a buffer\n\t\t\t);\n\n#endif  // _CONTEXT_SPT_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CreateLoaded_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CreateLoaded_fp.h 1600 2020-03-30 22:08:01Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CREATELOADED_FP_H\n#define CREATELOADED_FP_H\n\n/* rev 136 */\n\ntypedef struct {\n    TPMI_DH_PARENT\t\tparentHandle;\n    TPM2B_SENSITIVE_CREATE\tinSensitive;\n    TPM2B_TEMPLATE\t\tinPublic;\n} CreateLoaded_In;\n\n#define RC_CreateLoaded_parentHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_CreateLoaded_inSensitive \t(TPM_RC_P + TPM_RC_1)\n#define RC_CreateLoaded_inPublic \t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM_HANDLE\t\tobjectHandle;\n    TPM2B_PRIVATE\toutPrivate;\n    TPM2B_PUBLIC\toutPublic;\n    TPM2B_NAME\t\tname;\n} CreateLoaded_Out;\n\nTPM_RC\nTPM2_CreateLoaded(\n\t\t  CreateLoaded_In       *in,            // IN: input parameter list\n\t\t  CreateLoaded_Out      *out            // OUT: output parameter list\n\t\t  );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CreatePrimary_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CreatePrimary_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef CREATEPRIMARY_FP_H\n#define CREATEPRIMARY_FP_H\n\ntypedef struct {\n    TPMI_RH_HIERARCHY\t\tprimaryHandle;\n    TPM2B_SENSITIVE_CREATE\tinSensitive;\n    TPM2B_PUBLIC\t\tinPublic;\n    TPM2B_DATA\t\t\toutsideInfo;\n    TPML_PCR_SELECTION\t\tcreationPCR;\n} CreatePrimary_In;\n\n#define RC_CreatePrimary_primaryHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_CreatePrimary_inSensitive \t(TPM_RC_P + TPM_RC_1)\n#define RC_CreatePrimary_inPublic \t(TPM_RC_P + TPM_RC_2)\n#define RC_CreatePrimary_outsideInfo\t(TPM_RC_P + TPM_RC_3)\n#define RC_CreatePrimary_creationPCR\t(TPM_RC_P + TPM_RC_4)\n\ntypedef struct {\n    TPM_HANDLE\t\tobjectHandle;\n    TPM2B_PUBLIC\toutPublic;\n    TPM2B_CREATION_DATA\tcreationData;\n    TPM2B_DIGEST\tcreationHash;\n    TPMT_TK_CREATION\tcreationTicket;\n    TPM2B_NAME\t\tname;\n} CreatePrimary_Out;\n\nTPM_RC\nTPM2_CreatePrimary(\n\t\t   CreatePrimary_In    *in,            // IN: input parameter list\n\t\t   CreatePrimary_Out   *out            // OUT: output parameter list\n\t\t   );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Create_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Create_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 137 */\n\n#ifndef CREATE_FP_H\n#define CREATE_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tparentHandle;\n    TPM2B_SENSITIVE_CREATE\tinSensitive;\n    TPM2B_PUBLIC\t\tinPublic;\n    TPM2B_DATA\t\t\toutsideInfo;\n    TPML_PCR_SELECTION\t\tcreationPCR;\n} Create_In;     \n\n#define RC_Create_parentHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_Create_inSensitive \t(TPM_RC_P + TPM_RC_1)\n#define RC_Create_inPublic \t(TPM_RC_P + TPM_RC_2)\n#define RC_Create_outsideInfo\t(TPM_RC_P + TPM_RC_3)\n#define RC_Create_creationPCR\t(TPM_RC_P + TPM_RC_4)\n\ntypedef struct {\n    TPM2B_PRIVATE\toutPrivate;\n    TPM2B_PUBLIC\toutPublic;\n    TPM2B_CREATION_DATA\tcreationData;\n    TPM2B_DIGEST\tcreationHash;\n    TPMT_TK_CREATION\tcreationTicket;\n} Create_Out;\n\nTPM_RC\nTPM2_Create(\n\t    Create_In       *in,            // IN: input parameter list\n\t    Create_Out      *out            // OUT: output parameter list\n\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptCmac_fp.h",
    "content": "/********************************************************************************/\n/*\tMessage Authentication Codes Based on a Symmetric Block Cipher\t\t*/\n/*\t\tImplementation of cryptographic functions for hashing.\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2018 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar 28, 2019  Time: 08:25:18PM\n */\n\n#ifndef _CRYPT_CMAC_FP_H_\n#define _CRYPT_CMAC_FP_H_\n\n#if ALG_CMAC\n\n//*** CryptCmacStart()\n// This is the function to start the CMAC sequence operation. It initializes the\n// dispatch functions for the data and end operations for CMAC and initializes the\n// parameters that are used for the processing of data, including the key, key size\n// and block cipher algorithm.\nUINT16\nCryptCmacStart(\n\t       SMAC_STATE* state, TPMU_PUBLIC_PARMS* keyParms, TPM_ALG_ID macAlg, TPM2B* key);\n\n//*** CryptCmacData()\n// This function is used to add data to the CMAC sequence computation. The function\n// will XOR new data into the IV. If the buffer is full, and there is additional\n// input data, the data is encrypted into the IV buffer, the new data is then\n// XOR into the IV. When the data runs out, the function returns without encrypting\n// even if the buffer is full. The last data block of a sequence will not be\n// encrypted until the call to CryptCmacEnd(). This is to allow the proper subkey\n// to be computed and applied before the last block is encrypted.\nvoid CryptCmacData(SMAC_STATES* state, UINT32 size, const BYTE* buffer);\n\n//*** CryptCmacEnd()\n// This is the completion function for the CMAC. It does padding, if needed, and\n// selects the subkey to be applied before the last block is encrypted.\nUINT16\nCryptCmacEnd(SMAC_STATES* state, UINT32 outSize, BYTE* outBuffer);\n#endif\n\n#endif  // _CRYPT_CMAC_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptDes_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CryptDes_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CRYPTDES_FP_H\n#define CRYPTDES_FP_H\n\nUINT64\nCryptSetOddByteParity(\n\t\t      UINT64          k\n\t\t      );\nBOOL\nCryptDesValidateKey(\n\t\t    TPM2B_SYM_KEY       *desKey     // IN: key to validate\n\t\t    );\nTPM_RC\nCryptGenerateKeyDes(\n\t\t    TPMT_PUBLIC             *publicArea,        // IN/OUT: The public area template\n\t\t    //     for the new key.\n\t\t    TPMT_SENSITIVE          *sensitive,         // OUT: sensitive area\n\t\t    RAND_STATE              *rand               // IN: the \"entropy\" source for\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptEcc.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Structure definitions used for ECC \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// This file contains structure definitions used for ECC. The structures in this\n// file are only used internally. The ECC-related structures that cross the\n// public TPM interface are defined in TpmTypes.h\n//\n\n// ECC Curve data type decoder ring\n// ================================\n// | Name                      | Old Name*      | Comments                                                                                   |\n// | ------------------------- | -------------- | ------------------------------------------------------------------------------------------ |\n// | TPM_ECC_CURVE             |                | 16-bit Curve ID from Part 2 of TCG TPM Spec                                                |\n// | TPM_ECC_CURVE_METADATA    | ECC_CURVE      | See description below                                                                      |\n// |                           |                |                                                                                            |\n// * - if different\n\n// TPM_ECC_CURVE_METADATA\n// ======================\n// TPM-specific metadata for a particular curve, such as OIDs and signing/kdf\n// schemes associated with the curve.\n//\n// TODO_ECC: Need to remove the curve constants from this structure and replace\n// them with a reference to math-lib provided calls. <Once done, add this\n// revised comment to the above description> Note: this structure does *NOT*\n// include the actual curve constants. The curve constants are no longer in this\n// structure because the constants need to be in a format compatible with the\n// math library and are retrieved by the `ExtEcc_CurveGet*` family of functions.\n//\n// Using the math library's constant structure here is not necessary and breaks\n// encapsulation.  Using a tpm-specific format means either redundancy (the same\n// values exist here and in a math-specific format), or forces the math library\n// to adopt a particular format determined by this structure.  Neither outcome\n// is as clean as simply leaving the actual constants out of this structure.\n\n#ifndef _CRYPT_ECC_H\n#define _CRYPT_ECC_H\n\n//** Structures\n\n#define ECC_BITS (MAX_ECC_KEY_BYTES * 8)\nCRYPT_INT_TYPE(ecc, ECC_BITS);\n\n#define CRYPT_ECC_NUM(name) CRYPT_INT_VAR(name, ECC_BITS)\n\n#define CRYPT_ECC_INITIALIZED(name, initializer)\t\t\\\n    CRYPT_INT_INITIALIZED(name, ECC_BITS, initializer)\n\ntypedef struct TPM_ECC_CURVE_METADATA\n{\n    const TPM_ECC_CURVE   curveId;\n    const UINT16          keySizeBits;\n    const TPMT_KDF_SCHEME kdf;\n    const TPMT_ECC_SCHEME sign;\n    const BYTE*           OID;\n} TPM_ECC_CURVE_METADATA;\n\n//*** Macros\nextern const TPM_ECC_CURVE_METADATA eccCurves[ECC_CURVE_COUNT];\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptEccCrypt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tInclude Headers for Internal Routines\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CryptEccCrypt_fp.h 1594 2020-03-26 22:15:48Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2020 - 2022\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CRYPTECCCRYPT_FP_H\n#define CRYPTECCCRYPT_FP_H\n\nBOOL\nCryptEccSelectScheme(\n\t\t     OBJECT              *key,           //IN: key containing default scheme\n\t\t     TPMT_KDF_SCHEME     *scheme         // IN: a decrypt scheme\n\t\t     );\n\nLIB_EXPORT TPM_RC\nCryptEccEncrypt(\n\t\tOBJECT                  *key,           // IN: public key of recipient\n\t\tTPMT_KDF_SCHEME         *scheme,        // IN: scheme to use.\n\t\tTPM2B_MAX_BUFFER        *plainText,     // IN: the text to obfuscate\n\t\tTPMS_ECC_POINT          *c1,            // OUT: public ephemeral key\n\t\tTPM2B_MAX_BUFFER        *c2,            // OUT: obfuscated text\n\t\tTPM2B_DIGEST            *c3             // OUT: digest of ephemeral key\n\t\t//      and plainText\n\t\t);\nLIB_EXPORT TPM_RC\nCryptEccDecrypt(\n\t\tOBJECT                  *key,           // IN: key used for data recovery\n\t\tTPMT_KDF_SCHEME         *scheme,        // IN: scheme to use.\n\t\tTPM2B_MAX_BUFFER        *plainText,     // OUT: the recovered text\n\t\tTPMS_ECC_POINT          *c1,            // IN: public ephemeral key\n\t\tTPM2B_MAX_BUFFER        *c2,            // IN: obfuscated text\n\t\tTPM2B_DIGEST            *c3             // IN: digest of ephemeral key\n\t\t//      and plainText\n\t\t);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptEccKeyExchange_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar 28, 2019  Time: 08:25:18PM\n */\n\n#ifndef _CRYPT_ECC_KEY_EXCHANGE_FP_H_\n#define _CRYPT_ECC_KEY_EXCHANGE_FP_H_\n\n#if CC_ZGen_2Phase == YES\n\n//*** CryptEcc2PhaseKeyExchange()\n// This function is the dispatch routine for the EC key exchange functions that use\n// two ephemeral and two static keys.\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME             scheme is not defined\nLIB_EXPORT TPM_RC CryptEcc2PhaseKeyExchange(\n\t\t\t\t\t    TPMS_ECC_POINT*      outZ1,    // OUT: a computed point\n\t\t\t\t\t    TPMS_ECC_POINT*      outZ2,    // OUT: and optional second point\n\t\t\t\t\t    TPM_ECC_CURVE        curveId,  // IN: the curve for the computations\n\t\t\t\t\t    TPM_ALG_ID           scheme,   // IN: the key exchange scheme\n\t\t\t\t\t    TPM2B_ECC_PARAMETER* dsA,      // IN: static private TPM key\n\t\t\t\t\t    TPM2B_ECC_PARAMETER* deA,      // IN: ephemeral private TPM key\n\t\t\t\t\t    TPMS_ECC_POINT*      QsB,      // IN: static public party B key\n\t\t\t\t\t    TPMS_ECC_POINT*      QeB       // IN: ephemeral public party B key\n\t\t\t\t\t    );\n#  if ALG_SM2\n\n//*** SM2KeyExchange()\n// This function performs the key exchange defined in SM2.\n// The first step is to compute\n//  'tA' = ('dsA' + 'deA'  avf(Xe,A)) mod 'n'\n// Then, compute the 'Z' value from\n// 'outZ' = ('h'  'tA' mod 'n') ('QsA' + [avf('QeB.x')]('QeB')).\n// The function will compute the ephemeral public key from the ephemeral\n// private key.\n// All points are required to be on the curve of 'inQsA'. The function will fail\n// catastrophically if this is not the case\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        the value for dsA does not give a valid point on the\n//                              curve\nLIB_EXPORT TPM_RC SM2KeyExchange(\n\t\t\t\t TPMS_ECC_POINT*      outZ,     // OUT: the computed point\n\t\t\t\t TPM_ECC_CURVE        curveId,  // IN: the curve for the computations\n\t\t\t\t TPM2B_ECC_PARAMETER* dsAIn,    // IN: static private TPM key\n\t\t\t\t TPM2B_ECC_PARAMETER* deAIn,    // IN: ephemeral private TPM key\n\t\t\t\t TPMS_ECC_POINT*      QsBIn,    // IN: static public party B key\n\t\t\t\t TPMS_ECC_POINT*      QeBIn     // IN: ephemeral public party B key\n\t\t\t\t );\n#  endif\n#endif  // CC_ZGen_2Phase\n\n#endif  // _CRYPT_ECC_KEY_EXCHANGE_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptEccMain_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \tECC Main\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Apr  2, 2019  Time: 03:18:00PM\n */\n\n#ifndef _CRYPT_ECC_MAIN_FP_H_\n#define _CRYPT_ECC_MAIN_FP_H_\n\n#if ALG_ECC\n\n//** Functions\n#  if SIMULATION\nvoid EccSimulationEnd(void);\n#  endif  // SIMULATION\n\n//*** CryptEccInit()\n// This function is called at _TPM_Init\nBOOL CryptEccInit(void);\n\n//*** CryptEccStartup()\n// This function is called at TPM2_Startup().\nBOOL CryptEccStartup(void);\n\n//*** ClearPoint2B(generic)\n// Initialize the size values of a TPMS_ECC_POINT structure.\nvoid ClearPoint2B(TPMS_ECC_POINT* p  // IN: the point\n\t\t  );\n\n//*** CryptEccGetParametersByCurveId()\n// This function returns a pointer to the curve data that is associated with\n// the indicated curveId.\n// If there is no curve with the indicated ID, the function returns NULL. This\n// function is in this module so that it can be called by GetCurve data.\n//  Return Type: const TPM_ECC_CURVE_METADATA\n//      NULL            curve with the indicated TPM_ECC_CURVE is not implemented\n//      != NULL         pointer to the curve data\nLIB_EXPORT const TPM_ECC_CURVE_METADATA* CryptEccGetParametersByCurveId(\n\t\t\t\t\t\t\t\t\tTPM_ECC_CURVE curveId  // IN: the curveID\n\t\t\t\t\t\t\t\t\t);\n\n//*** CryptEccGetKeySizeForCurve()\n// This function returns the key size in bits of the indicated curve.\nLIB_EXPORT UINT16 CryptEccGetKeySizeForCurve(TPM_ECC_CURVE curveId  // IN: the curve\n\t\t\t\t\t     );\n\n//***CryptEccGetOID()\nconst BYTE* CryptEccGetOID(TPM_ECC_CURVE curveId);\n\n//*** CryptEccGetCurveByIndex()\n// This function returns the number of the 'i'-th implemented curve. The normal\n// use would be to call this function with 'i' starting at 0. When the 'i' is greater\n// than or equal to the number of implemented curves, TPM_ECC_NONE is returned.\nLIB_EXPORT TPM_ECC_CURVE CryptEccGetCurveByIndex(UINT16 i);\n\n//*** CryptCapGetECCCurve()\n// This function returns the list of implemented ECC curves.\n//  Return Type: TPMI_YES_NO\n//      YES             if no more ECC curve is available\n//      NO              if there are more ECC curves not reported\nTPMI_YES_NO\nCryptCapGetECCCurve(TPM_ECC_CURVE   curveID,   // IN: the starting ECC curve\n\t\t    UINT32          maxCount,  // IN: count of returned curves\n\t\t    TPML_ECC_CURVE* curveList  // OUT: ECC curve list\n\t\t    );\n\n//*** CryptCapGetOneECCCurve()\n// This function returns whether the ECC curve is implemented.\nBOOL CryptCapGetOneECCCurve(TPM_ECC_CURVE curveID  // IN: the  ECC curve\n\t\t\t    );\n\n//*** CryptGetCurveSignScheme()\n// This function will return a pointer to the scheme of the curve.\nconst TPMT_ECC_SCHEME* CryptGetCurveSignScheme(\n\t\t\t\t\t       TPM_ECC_CURVE curveId  // IN: The curve selector\n\t\t\t\t\t       );\n\n//*** CryptGenerateR()\n// This function computes the commit random value for a split signing scheme.\n//\n// If 'c' is NULL, it indicates that 'r' is being generated\n// for TPM2_Commit.\n// If 'c' is not NULL, the TPM will validate that the 'gr.commitArray'\n// bit associated with the input value of 'c' is SET. If not, the TPM\n// returns FALSE and no 'r' value is generated.\n//  Return Type: BOOL\n//      TRUE(1)         r value computed\n//      FALSE(0)        no r value computed\nBOOL CryptGenerateR(TPM2B_ECC_PARAMETER* r,        // OUT: the generated random value\n\t\t    UINT16*              c,        // IN/OUT: count value.\n\t\t    TPMI_ECC_CURVE       curveID,  // IN: the curve for the value\n\t\t    TPM2B_NAME*          name      // IN: optional name of a key to\n\t\t    //     associate with 'r'\n\t\t    );\n\n//*** CryptCommit()\n// This function is called when the count value is committed. The 'gr.commitArray'\n// value associated with the current count value is SET and g_commitCounter is\n// incremented. The low-order 16 bits of old value of the counter is returned.\nUINT16\nCryptCommit(void);\n\n//*** CryptEndCommit()\n// This function is called when the signing operation using the committed value\n// is completed. It clears the gr.commitArray bit associated with the count\n// value so that it can't be used again.\nvoid CryptEndCommit(UINT16 c  // IN: the counter value of the commitment\n\t\t    );\n\n//*** CryptEccGetParameters()\n// This function returns the ECC parameter details of the given curve.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        unsupported ECC curve ID\nBOOL CryptEccGetParameters(\n\t\t\t   TPM_ECC_CURVE              curveId,    // IN: ECC curve ID\n\t\t\t   TPMS_ALGORITHM_DETAIL_ECC* parameters  // OUT: ECC parameters\n\t\t\t   );\n\n//*** TpmEcc_IsValidPrivateEcc()\n// Checks that 0 < 'x' < 'q'\nBOOL TpmEcc_IsValidPrivateEcc(const Crypt_Int*      x,  // IN: private key to check\n\t\t\t      const Crypt_EccCurve* E   // IN: the curve to check\n\t\t\t      );\n\nLIB_EXPORT BOOL CryptEccIsValidPrivateKey(TPM2B_ECC_PARAMETER* d,\n\t\t\t\t\t  TPM_ECC_CURVE        curveId);\n\n//*** TpmEcc_PointMult()\n// This function does a point multiply of the form 'R' = ['d']'S' + ['u']'Q' where the\n// parameters are Crypt_Int* values. If 'S' is NULL and d is not NULL, then it computes\n// 'R' = ['d']'G' + ['u']'Q'  or just 'R' = ['d']'G' if 'u' and 'Q' are NULL.\n// If 'skipChecks' is TRUE, then the function will not verify that the inputs are\n// correct for the domain. This would be the case when the values were created by the\n// CryptoEngine code.\n// It will return TPM_RC_NO_RESULT if the resulting point is the point at infinity.\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        result of multiplication is a point at infinity\n//      TPM_RC_ECC_POINT        'S' or 'Q' is not on the curve\n//      TPM_RC_VALUE            'd' or 'u' is not < n\nTPM_RC\nTpmEcc_PointMult(Crypt_Point*          R,  // OUT: computed point\n\t\t const Crypt_Point*    S,  // IN: optional point to multiply by 'd'\n\t\t const Crypt_Int*      d,  // IN: scalar for [d]S or [d]G\n\t\t const Crypt_Point*    Q,  // IN: optional second point\n\t\t const Crypt_Int*      u,  // IN: optional second scalar\n\t\t const Crypt_EccCurve* E   // IN: curve parameters\n\t\t );\n\n//***TpmEcc_GenPrivateScalar()\n// This function gets random values that are the size of the key plus 64 bits. The\n// value is reduced (mod ('q' - 1)) and incremented by 1 ('q' is the order of the\n// curve. This produces a value ('d') such that 1 <= 'd' < 'q'. This is the method\n// of FIPS 186-4 Section B.4.1 \"\"Key Pair Generation Using Extra Random Bits\"\".\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure generating private key\nBOOL TpmEcc_GenPrivateScalar(\n\t\t\t     Crypt_Int*            dOut,  // OUT: the qualified random value\n\t\t\t     const Crypt_EccCurve* E,     // IN: curve for which the private key\n\t\t\t     //     needs to be appropriate\n\t\t\t     RAND_STATE* rand             // IN: state for DRBG\n\t\t\t     );\n\n//*** TpmEcc_GenerateKeyPair()\n// This function gets a private scalar from the source of random bits and does\n// the point multiply to get the public key.\nBOOL TpmEcc_GenerateKeyPair(Crypt_Int*            bnD,  // OUT: private scalar\n\t\t\t    Crypt_Point*          ecQ,  // OUT: public point\n\t\t\t    const Crypt_EccCurve* E,    // IN: curve for the point\n\t\t\t    RAND_STATE*           rand  // IN: DRBG state to use\n\t\t\t    );\n\n//***CryptEccNewKeyPair(***)\n// This function creates an ephemeral ECC. It is ephemeral in that\n// is expected that the private part of the key will be discarded\nLIB_EXPORT TPM_RC CryptEccNewKeyPair(\n\t\t\t\t     TPMS_ECC_POINT*      Qout,    // OUT: the public point\n\t\t\t\t     TPM2B_ECC_PARAMETER* dOut,    // OUT: the private scalar\n\t\t\t\t     TPM_ECC_CURVE        curveId  // IN: the curve for the key\n\t\t\t\t     );\n\n//*** CryptEccPointMultiply()\n// This function computes 'R' := ['dIn']'G' + ['uIn']'QIn'. Where 'dIn' and\n// 'uIn' are scalars, 'G' and 'QIn' are points on the specified curve and 'G' is the\n// default generator of the curve.\n//\n// The 'xOut' and 'yOut' parameters are optional and may be set to NULL if not\n// used.\n//\n// It is not necessary to provide 'uIn' if 'QIn' is specified but one of 'uIn' and\n// 'dIn' must be provided. If 'dIn' and 'QIn' are specified but 'uIn' is not\n// provided, then 'R' = ['dIn']'QIn'.\n//\n// If the multiply produces the point at infinity, the TPM_RC_NO_RESULT is returned.\n//\n// The sizes of 'xOut' and yOut' will be set to be the size of the degree of\n// the curve\n//\n// It is a fatal error if 'dIn' and 'uIn' are both unspecified (NULL) or if 'Qin'\n// or 'Rout' is unspecified.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_ECC_POINT         the point 'Pin' or 'Qin' is not on the curve\n//      TPM_RC_NO_RESULT         the product point is at infinity\n//      TPM_RC_CURVE             bad curve\n//      TPM_RC_VALUE             'dIn' or 'uIn' out of range\n//\nLIB_EXPORT TPM_RC CryptEccPointMultiply(\n\t\t\t\t\tTPMS_ECC_POINT*      Rout,     // OUT: the product point R\n\t\t\t\t\tTPM_ECC_CURVE        curveId,  // IN: the curve to use\n\t\t\t\t\tTPMS_ECC_POINT*      Pin,      // IN: first point (can be null)\n\t\t\t\t\tTPM2B_ECC_PARAMETER* dIn,      // IN: scalar value for [dIn]Qin\n\t\t\t\t\t//     the Pin\n\t\t\t\t\tTPMS_ECC_POINT*      Qin,      // IN: point Q\n\t\t\t\t\tTPM2B_ECC_PARAMETER* uIn       // IN: scalar value for the multiplier\n\t\t\t\t\t//     of Q\n\t\t\t\t\t);\n\n//*** CryptEccIsPointOnCurve()\n// This function is used to test if a point is on a defined curve. It does this\n// by checking that 'y'^2 mod 'p' = 'x'^3 + 'a'*'x' + 'b' mod 'p'.\n//\n// It is a fatal error if 'Q' is not specified (is NULL).\n//  Return Type: BOOL\n//      TRUE(1)         point is on curve\n//      FALSE(0)        point is not on curve or curve is not supported\nLIB_EXPORT BOOL CryptEccIsPointOnCurve(\n\t\t\t\t       TPM_ECC_CURVE   curveId,  // IN: the curve selector\n\t\t\t\t       TPMS_ECC_POINT* Qin       // IN: the point.\n\t\t\t\t       );\n\n//*** CryptEccGenerateKey()\n// This function generates an ECC key pair based on the input parameters.\n// This routine uses KDFa to produce candidate numbers. The method is according\n// to FIPS 186-3, section B.1.2 \"Key Pair Generation by Testing Candidates.\"\n// According to the method in FIPS 186-3, the resulting private value 'd' should be\n// 1 <= 'd' < 'n' where 'n' is the order of the base point.\n//\n// It is a fatal error if 'Qout', 'dOut', is not provided (is NULL).\n//\n// If the curve is not supported\n// If 'seed' is not provided, then a random number will be used for the key\n//  Return Type: TPM_RC\n//      TPM_RC_CURVE            curve is not supported\n//      TPM_RC_NO_RESULT        could not verify key with signature (FIPS only)\nLIB_EXPORT TPM_RC CryptEccGenerateKey(\n\t\t\t\t      TPMT_PUBLIC* publicArea,    // IN/OUT: The public area template for\n\t\t\t\t      //      the new key. The public key\n\t\t\t\t      //      area will be replaced computed\n\t\t\t\t      //      ECC public key\n\t\t\t\t      TPMT_SENSITIVE* sensitive,  // OUT: the sensitive area will be\n\t\t\t\t      //      updated to contain the private\n\t\t\t\t      //      ECC key and the symmetric\n\t\t\t\t      //      encryption key\n\t\t\t\t      RAND_STATE* rand            // IN: if not NULL, the deterministic\n\t\t\t\t      //     RNG state\n\t\t\t\t      );\n#endif  // ALG_ECC\n\n#endif  // _CRYPT_ECC_MAIN_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptEccSignature_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 -2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar 28, 2019  Time: 08:25:18PM\n */\n\n#ifndef _CRYPT_ECC_SIGNATURE_FP_H_\n#define _CRYPT_ECC_SIGNATURE_FP_H_\n\n#if ALG_ECC\n\n//*** CryptEccSign()\n// This function is the dispatch function for the various ECC-based\n// signing schemes.\n// There is a bit of ugliness to the parameter passing. In order to test this,\n// we sometime would like to use a deterministic RNG so that we can get the same\n// signatures during testing. The easiest way to do this for most schemes is to\n// pass in a deterministic RNG and let it return canned values during testing.\n// There is a competing need for a canned parameter to use in ECDAA. To accommodate\n// both needs with minimal fuss, a special type of RAND_STATE is defined to carry\n// the address of the commit value. The setup and handling of this is not very\n// different for the caller than what was in previous versions of the code.\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME            'scheme' is not supported\nLIB_EXPORT TPM_RC CryptEccSign(TPMT_SIGNATURE* signature,  // OUT: signature\n\t\t\t       OBJECT* signKey,  // IN: ECC key to sign the hash\n\t\t\t       const TPM2B_DIGEST* digest,  // IN: digest to sign\n\t\t\t       TPMT_ECC_SCHEME*    scheme,  // IN: signing scheme\n\t\t\t       RAND_STATE*         rand);\n\n//*** CryptEccValidateSignature()\n// This function validates an EcDsa or EcSchnorr signature.\n// The point 'Qin' needs to have been validated to be on the curve of 'curveId'.\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE            not a valid signature\nLIB_EXPORT TPM_RC CryptEccValidateSignature(\n\t\t\t\t\t    TPMT_SIGNATURE*     signature,  // IN: signature to be verified\n\t\t\t\t\t    OBJECT*             signKey,    // IN: ECC key signed the hash\n\t\t\t\t\t    const TPM2B_DIGEST* digest      // IN: digest that was signed\n\t\t\t\t\t    );\n\n//***CryptEccCommitCompute()\n// This function performs the point multiply operations required by TPM2_Commit.\n//\n// If 'B' or 'M' is provided, they must be on the curve defined by 'curveId'. This\n// routine does not check that they are on the curve and results are unpredictable\n// if they are not.\n//\n// It is a fatal error if 'r' is NULL. If 'B' is not NULL, then it is a\n// fatal error if 'd' is NULL or if 'K' and 'L' are both NULL.\n// If 'M' is not NULL, then it is a fatal error if 'E' is NULL.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        if 'K', 'L' or 'E' was computed to be the point\n//                              at infinity\n//      TPM_RC_CANCELED         a cancel indication was asserted during this\n//                              function\nLIB_EXPORT TPM_RC CryptEccCommitCompute(\n\t\t\t\t\tTPMS_ECC_POINT*      K,        // OUT: [d]B or [r]Q\n\t\t\t\t\tTPMS_ECC_POINT*      L,        // OUT: [r]B\n\t\t\t\t\tTPMS_ECC_POINT*      E,        // OUT: [r]M\n\t\t\t\t\tTPM_ECC_CURVE        curveId,  // IN: the curve for the computations\n\t\t\t\t\tTPMS_ECC_POINT*      M,        // IN: M (optional)\n\t\t\t\t\tTPMS_ECC_POINT*      B,        // IN: B (optional)\n\t\t\t\t\tTPM2B_ECC_PARAMETER* d,        // IN: d (optional)\n\t\t\t\t\tTPM2B_ECC_PARAMETER* r         // IN: the computed r value (required)\n\t\t\t\t\t);\n#endif  // ALG_ECC\n\n#endif  // _CRYPT_ECC_SIGNATURE_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptHash.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Hash structure definitions  \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CryptHash.h 1658 2021-01-22 23:14:01Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CRYPTHASH_H\n#define CRYPTHASH_H\n\n/* 10.1.3.1\tIntroduction */\n\n/* This header contains the hash structure definitions used in the TPM code to define the amount of\n   space to be reserved for the hash state. This allows the TPM code to not have to import all of\n   the symbols used by the hash computations. This lets the build environment of the TPM code not to\n   have include the header files associated with the CryptoEngine() code. */\n\n/* 10.1.3.2\tHash-related Structures */\n\nunion SMAC_STATES;\n\n/* These definitions add the high-level methods for processing state that may be an SMAC */\ntypedef void(* SMAC_DATA_METHOD)(\n\t\t\t\t union SMAC_STATES       *state,\n\t\t\t\t UINT32                   size,\n\t\t\t\t const BYTE              *buffer\n\t\t\t\t );\ntypedef UINT16(* SMAC_END_METHOD)(\n\t\t\t\t  union SMAC_STATES       *state,\n\t\t\t\t  UINT32                   size,\n\t\t\t\t  BYTE                    *buffer\n\t\t\t\t  );\ntypedef struct sequenceMethods {\n    SMAC_DATA_METHOD          data;\n    SMAC_END_METHOD           end;\n} SMAC_METHODS;\n#define SMAC_IMPLEMENTED (CC_MAC || CC_MAC_Start)\n\n/* These definitions are here because the SMAC state is in the union of hash states. */\n\ntypedef struct tpmCmacState {\n    TPM_ALG_ID              symAlg;\n    UINT16                  keySizeBits;\n    INT16                   bcount; // current count of bytes accumulated in IV\n    TPM2B_IV                iv;     // IV buffer\n    TPM2B_SYM_KEY           symKey;\n} tpmCmacState_t;\n\ntypedef union SMAC_STATES {\n#if ALG_CMAC\n    tpmCmacState_t          cmac;\n#endif\n    UINT64                  pad;\n} SMAC_STATES;\n\ntypedef struct SMAC_STATE {\n    SMAC_METHODS            smacMethods;\n    SMAC_STATES             state;\n} SMAC_STATE;\n\n#if ALG_SHA1\n#   define  IF_IMPLEMENTED_SHA1(op)     op(SHA1, Sha1)\n#else\n#   define  IF_IMPLEMENTED_SHA1(op)\n#endif\n#if ALG_SHA256\n#   define  IF_IMPLEMENTED_SHA256(op)     op(SHA256, Sha256)\n#else\n#   define  IF_IMPLEMENTED_SHA256(op)\n#endif\n#if ALG_SHA384\n#   define  IF_IMPLEMENTED_SHA384(op)     op(SHA384, Sha384)\n#else\n#   define  IF_IMPLEMENTED_SHA384(op)\n#endif\n#if ALG_SHA512\n#   define  IF_IMPLEMENTED_SHA512(op)     op(SHA512, Sha512)\n#else\n#   define  IF_IMPLEMENTED_SHA512(op)\n#endif\n#if ALG_SM3_256\n#   define  IF_IMPLEMENTED_SM3_256(op)     op(SM3_256, Sm3_256)\n#else\n#   define  IF_IMPLEMENTED_SM3_256(op)\n#endif\n#if ALG_SHA3_256\n#   define  IF_IMPLEMENTED_SHA3_256(op)     op(SHA3_256, Sha3_256)\n#else\n#   define  IF_IMPLEMENTED_SHA3_256(op)\n#endif\n#if ALG_SHA3_384\n#   define  IF_IMPLEMENTED_SHA3_384(op)     op(SHA3_384, Sha3_384)\n#else\n#   define  IF_IMPLEMENTED_SHA3_384(op)\n#endif\n#if ALG_SHA3_512\n#   define  IF_IMPLEMENTED_SHA3_512(op)     op(SHA3_512, Sha3_512)\n#else\n#   define  IF_IMPLEMENTED_SHA3_512(op)\n#endif\n\n/* SHA512 added kgold */\n#define FOR_EACH_HASH(op)\t\t    \\\n    IF_IMPLEMENTED_SHA1(op)\t\t    \\\n    IF_IMPLEMENTED_SHA256(op)\t\t    \\\n    IF_IMPLEMENTED_SHA384(op)\t\t    \\\n    IF_IMPLEMENTED_SHA512(op)\t\t    \\\n    IF_IMPLEMENTED_SM3_256(op)\t\t    \\\n    IF_IMPLEMENTED_SHA3_256(op)\t\t    \\\n    IF_IMPLEMENTED_SHA3_384(op)\t\t    \\\n    IF_IMPLEMENTED_SHA3_512(op)\n\n#define HASH_TYPE(HASH, Hash)   tpmHashState##HASH##_t  Hash;\n\ntypedef union\n{\n    FOR_EACH_HASH(HASH_TYPE)\n    // Additions for symmetric block cipher MAC\n#if SMAC_IMPLEMENTED\n    SMAC_STATE                 smac;\n#endif\n    // to force structure alignment to be no worse than HASH_ALIGNMENT\n#if HASH_ALIGNMENT == 8\n    uint64_t             align;\n#else\n    uint32_t             align;\n#endif\n} ANY_HASH_STATE;\n\ntypedef ANY_HASH_STATE *PANY_HASH_STATE;\ntypedef const ANY_HASH_STATE    *PCANY_HASH_STATE;\n#define ALIGNED_SIZE(x, b) ((((x) + (b) - 1) / (b)) * (b))\n/* MAX_HASH_STATE_SIZE will change with each implementation. It is assumed that a hash state will\n   not be larger than twice the block size plus some overhead (in this case, 16 bytes). The overall\n   size needs to be as large as any of the hash contexts. The structure needs to start on an\n   alignment boundary and be an even multiple of the alignment */\n#define MAX_HASH_STATE_SIZE ((2 * MAX_HASH_BLOCK_SIZE) + 16)\n#define MAX_HASH_STATE_SIZE_ALIGNED\t\t\t\t\t\\\n    ALIGNED_SIZE(MAX_HASH_STATE_SIZE, HASH_ALIGNMENT)\n/* This is an aligned byte array that will hold any of the hash contexts. */\ntypedef  ANY_HASH_STATE ALIGNED_HASH_STATE;\n/* The header associated with the hash library is expected to define the methods which include the\n   calling sequence. When not compiling CryptHash.c, the methods are not defined so we need\n   placeholder functions for the structures */\n#ifndef HASH_START_METHOD_DEF\n#   define HASH_START_METHOD_DEF    void (HASH_START_METHOD)(void)\n#endif\n#ifndef HASH_DATA_METHOD_DEF\n#   define HASH_DATA_METHOD_DEF     void (HASH_DATA_METHOD)(void)\n#endif\n#ifndef HASH_END_METHOD_DEF\n#   define HASH_END_METHOD_DEF      void (HASH_END_METHOD)(void)\n#endif\n#ifndef HASH_STATE_COPY_METHOD_DEF\n#   define HASH_STATE_COPY_METHOD_DEF     void (HASH_STATE_COPY_METHOD)(void)\n#endif\n#ifndef  HASH_STATE_EXPORT_METHOD_DEF\n#   define  HASH_STATE_EXPORT_METHOD_DEF   void (HASH_STATE_EXPORT_METHOD)(void)\n#endif\n#ifndef  HASH_STATE_IMPORT_METHOD_DEF\n#   define  HASH_STATE_IMPORT_METHOD_DEF   void (HASH_STATE_IMPORT_METHOD)(void)\n#endif\n/* Define the prototypical function call for each of the methods. This defines the order in which\n   the parameters are passed to the underlying function. */\ntypedef HASH_START_METHOD_DEF;\ntypedef HASH_DATA_METHOD_DEF;\ntypedef HASH_END_METHOD_DEF;\ntypedef HASH_STATE_COPY_METHOD_DEF;\ntypedef HASH_STATE_EXPORT_METHOD_DEF;\ntypedef HASH_STATE_IMPORT_METHOD_DEF;\ntypedef struct _HASH_METHODS\n{\n    HASH_START_METHOD           *start;\n    HASH_DATA_METHOD            *data;\n    HASH_END_METHOD             *end;\n    HASH_STATE_COPY_METHOD      *copy;      // Copy a hash block\n    HASH_STATE_EXPORT_METHOD    *copyOut;   // Copy a hash block from a hash\n    // context\n    HASH_STATE_IMPORT_METHOD    *copyIn;    // Copy a hash block to a proper hash\n    // context\n} HASH_METHODS, *PHASH_METHODS;\n\n#define HASH_TPM2B(HASH, Hash)  TPM2B_TYPE(HASH##_DIGEST, HASH##_DIGEST_SIZE);\n\nFOR_EACH_HASH(HASH_TPM2B)\n\n/* When the TPM implements RSA, the hash-dependent OID pointers are part of the HASH_DEF. These\n   macros conditionally add the OID reference to the HASH_DEF and the HASH_DEF_TEMPLATE. */\n#if ALG_RSA\n#define PKCS1_HASH_REF   const BYTE  *PKCS1;\n#define PKCS1_OID(NAME)  , OID_PKCS1_##NAME\n#else\n#define PKCS1_HASH_REF\n#define PKCS1_OID(NAME)\n#endif\n\n/* When the TPM implements ECC, the hash-dependent OID pointers are part of the HASH_DEF. These\n   macros conditionally add the OID reference to the HASH_DEF and the HASH_DEF_TEMPLATE. */\n#if ALG_ECDSA\n#define ECDSA_HASH_REF    const BYTE  *ECDSA;\n#define ECDSA_OID(NAME)  , OID_ECDSA_##NAME\n#else\n#define ECDSA_HASH_REF\n#define ECDSA_OID(NAME)\n#endif\n\ntypedef const struct\n{\n    HASH_METHODS         method;\n    uint16_t             blockSize;\n    uint16_t             digestSize;\n    uint16_t             contextSize;\n    uint16_t             hashAlg;\n    const BYTE          *OID;\n    PKCS1_HASH_REF      // PKCS1 OID\n    ECDSA_HASH_REF      // ECDSA OID\n} HASH_DEF, *PHASH_DEF;\n\n/* Macro to fill in the HASH_DEF for an algorithm. For SHA1, the instance would be:\n   HASH_DEF_TEMPLATE(Sha1, SHA1) This handles the difference in capitalization for the various\n   pieces. */\n\n#define HASH_DEF_TEMPLATE(HASH, Hash)\t\t\t\t\t\\\n    HASH_DEF    Hash##_Def= {\t\t\t\t\t\t\\\n\t\t\t     {(HASH_START_METHOD *)&tpmHashStart_##HASH, \\\n\t\t\t      (HASH_DATA_METHOD *)&tpmHashData_##HASH,\t\\\n\t\t\t      (HASH_END_METHOD *)&tpmHashEnd_##HASH,\t\\\n\t\t\t      (HASH_STATE_COPY_METHOD *)&tpmHashStateCopy_##HASH, \\\n\t\t\t      (HASH_STATE_EXPORT_METHOD *)&tpmHashStateExport_##HASH, \\\n\t\t\t      (HASH_STATE_IMPORT_METHOD *)&tpmHashStateImport_##HASH, \\\n\t\t\t     },\t\t\t\t\t\t\\\n\t\t\t     HASH##_BLOCK_SIZE,     /*block size */\t\\\n\t\t\t     HASH##_DIGEST_SIZE,    /*data size */\t\\\n\t\t\t     sizeof(tpmHashState##HASH##_t),\t\t\\\n\t\t\t     TPM_ALG_##HASH, OID_##HASH\t\t\t\\\n\t\t\t     PKCS1_OID(HASH) ECDSA_OID(HASH)};\n\n/* These definitions are for the types that can be in a hash state structure. These types are used\n   in the cryptographic utilities. This is a define rather than an enum so that the size of this\n   field can be explicit. */\ntypedef BYTE    HASH_STATE_TYPE;\n#define HASH_STATE_EMPTY        ((HASH_STATE_TYPE) 0)\n#define HASH_STATE_HASH         ((HASH_STATE_TYPE) 1)\n#define HASH_STATE_HMAC         ((HASH_STATE_TYPE) 2)\n#if CC_MAC || CC_MAC_Start\n#define HASH_STATE_SMAC         ((HASH_STATE_TYPE) 3)\n#endif\n/* This is the structure that is used for passing a context into the hashing functions. It should be\n   the same size as the function context used within the hashing functions. This is checked when the\n   hash function is initialized. This version uses a new layout for the contexts and a different\n   definition. The state buffer is an array of HASH_UNIT values so that a decent compiler will put\n   the structure on a HASH_UNIT boundary. If the structure is not properly aligned, the code that\n   manipulates the structure will copy to a properly aligned structure before it is used and copy\n   the result back. This just makes things slower. */\n/*     NOTE: This version of the state had the pointer to the update method in the state. This is to\n       allow the SMAC functions to use the same structure without having to replicate the entire\n       HASH_DEF structure. */\ntypedef struct _HASH_STATE\n{\n    HASH_STATE_TYPE          type;               // type of the context\n    TPM_ALG_ID               hashAlg;\n    PHASH_DEF                def;\n    ANY_HASH_STATE           state;\n} HASH_STATE, *PHASH_STATE;\ntypedef const HASH_STATE *PCHASH_STATE;\n\n/* 10.1.3.3 HMAC State Structures */\n/* This header contains the hash structure definitions used in the TPM code to define the amount of\n   space to be reserved for the hash state. This allows the TPM code to not have to import all of\n   the symbols used by the hash computations. This lets the build environment of the TPM code not to\n   have include the header files associated with the CryptoEngine() code. */\n\n/* An HMAC_STATE structure contains an opaque HMAC stack state. A caller would use this structure\n   when performing incremental HMAC operations. This structure contains a hash state and an HMAC key\n   and allows slightly better stack optimization than adding an HMAC key to each hash state. */\ntypedef struct hmacState\n{\n    HASH_STATE           hashState;          // the hash state\n    TPM2B_HASH_BLOCK     hmacKey;            // the HMAC key\n} HMAC_STATE, *PHMAC_STATE;\n/* This is for the external hash state. This implementation assumes that the size of the exported\n   hash state is no larger than the internal hash state. */\ntypedef struct\n{\n    BYTE                     buffer[sizeof(HASH_STATE)];\n} EXPORT_HASH_STATE, *PEXPORT_HASH_STATE;\ntypedef const EXPORT_HASH_STATE *PCEXPORT_HASH_STATE;\n\n#endif\t//  _CRYPT_HASH_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptHash_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tImplementation of cryptographic functions for hashing.\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Feb 28, 2020  Time: 03:04:48PM\n */\n\n#ifndef _CRYPT_HASH_FP_H_\n#define _CRYPT_HASH_FP_H_\n\n//*** CryptHashInit()\n// This function is called by _TPM_Init do perform the initialization operations for\n// the library.\nBOOL CryptHashInit(void);\n\n//*** CryptHashStartup()\n// This function is called by TPM2_Startup(). It checks that the size of the\n// HashDefArray is consistent with the HASH_COUNT.\nBOOL CryptHashStartup(void);\n\n//*** CryptGetHashDef()\n// This function accesses the hash descriptor associated with a hash a\n// algorithm. The function returns a pointer to a 'null' descriptor if hashAlg is\n// TPM_ALG_NULL or not a defined algorithm.\nPHASH_DEF\nCryptGetHashDef(TPM_ALG_ID hashAlg);\n\n//*** CryptHashIsValidAlg()\n// This function tests to see if an algorithm ID is a valid hash algorithm. If\n// flag is true, then TPM_ALG_NULL is a valid hash.\n//  Return Type: BOOL\n//      TRUE(1)         hashAlg is a valid, implemented hash on this TPM\n//      FALSE(0)        hashAlg is not valid for this TPM\nBOOL CryptHashIsValidAlg(TPM_ALG_ID hashAlg,  // IN: the algorithm to check\n\t\t\t BOOL       flag  // IN: TRUE if TPM_ALG_NULL is to be treated\n\t\t\t //     as a valid hash\n\t\t\t );\n\n//*** CryptHashGetAlgByIndex()\n// This function is used to iterate through the hashes. TPM_ALG_NULL\n// is returned for all indexes that are not valid hashes.\n// If the TPM implements 3 hashes, then an 'index' value of 0 will\n// return the first implemented hash and an 'index' of 2 will return the\n// last. All other index values will return TPM_ALG_NULL.\n//\n//  Return Type: TPM_ALG_ID\n// TPM_ALG_xxx         a hash algorithm\n// TPM_ALG_NULL        this can be used as a stop value\nLIB_EXPORT TPM_ALG_ID CryptHashGetAlgByIndex(UINT32 index  // IN: the index\n\t\t\t\t\t     );\n\n//*** CryptHashGetDigestSize()\n// Returns the size of the digest produced by the hash. If 'hashAlg' is not a hash\n// algorithm, the TPM will FAIL.\n//  Return Type: UINT16\n//   0       TPM_ALG_NULL\n//   > 0     the digest size\n//\nLIB_EXPORT UINT16 CryptHashGetDigestSize(\n\t\t\t\t\t TPM_ALG_ID hashAlg  // IN: hash algorithm to look up\n\t\t\t\t\t );\n\n//*** CryptHashGetBlockSize()\n// Returns the size of the block used by the hash. If 'hashAlg' is not a hash\n// algorithm, the TPM will FAIL.\n//  Return Type: UINT16\n//   0       TPM_ALG_NULL\n//   > 0     the digest size\n//\nLIB_EXPORT UINT16 CryptHashGetBlockSize(\n\t\t\t\t\tTPM_ALG_ID hashAlg  // IN: hash algorithm to look up\n\t\t\t\t\t);\n\n//*** CryptHashGetOid()\n// This function returns a pointer to DER=encoded OID for a hash algorithm. All OIDs\n// are full OID values including the Tag (0x06) and length byte.\nLIB_EXPORT const BYTE* CryptHashGetOid(TPM_ALG_ID hashAlg);\n\n//***  CryptHashGetContextAlg()\n// This function returns the hash algorithm associated with a hash context.\nTPM_ALG_ID\nCryptHashGetContextAlg(PHASH_STATE state  // IN: the context to check\n\t\t       );\n\n//*** CryptHashCopyState\n// This function is used to clone a HASH_STATE.\nLIB_EXPORT void CryptHashCopyState(HASH_STATE* out,  // OUT: destination of the state\n\t\t\t\t   const HASH_STATE* in  // IN: source of the state\n\t\t\t\t   );\n\n//*** CryptHashExportState()\n// This function is used to export a hash or HMAC hash state. This function\n// would be called when preparing to context save a sequence object.\nvoid CryptHashExportState(\n\t\t\t  PCHASH_STATE internalFmt,       // IN: the hash state formatted for use by\n\t\t\t  //     library\n\t\t\t  PEXPORT_HASH_STATE externalFmt  // OUT: the exported hash state\n\t\t\t  );\n\n//*** CryptHashImportState()\n// This function is used to import the hash state. This function\n// would be called to import a hash state when the context of a sequence object\n// was being loaded.\nvoid CryptHashImportState(\n\t\t\t  PHASH_STATE internalFmt,         // OUT: the hash state formatted for use by\n\t\t\t  //     the library\n\t\t\t  PCEXPORT_HASH_STATE externalFmt  // IN: the exported hash state\n\t\t\t  );\n\n//*** CryptHashStart()\n// Functions starts a hash stack\n// Start a hash stack and returns the digest size. As a side effect, the\n// value of 'stateSize' in hashState is updated to indicate the number of bytes\n// of state that were saved. This function calls GetHashServer() and that function\n// will put the TPM into failure mode if the hash algorithm is not supported.\n//\n// This function does not use the sequence parameter. If it is necessary to import\n// or export context, this will start the sequence in a local state\n// and export the state to the input buffer. Will need to add a flag to the state\n// structure to indicate that it needs to be imported before it can be used.\n// (BLEH).\n//  Return Type: UINT16\n//  0           hash is TPM_ALG_NULL\n// >0           digest size\nLIB_EXPORT UINT16 CryptHashStart(\n\t\t\t\t PHASH_STATE hashState,  // OUT: the running hash state\n\t\t\t\t TPM_ALG_ID  hashAlg     // IN: hash algorithm\n\t\t\t\t );\n\n//*** CryptDigestUpdate()\n// Add data to a hash or HMAC, SMAC stack.\n//\nvoid CryptDigestUpdate(PHASH_STATE hashState,  // IN: the hash context information\n\t\t       UINT32      dataSize,   // IN: the size of data to be added\n\t\t       const BYTE* data        // IN: data to be hashed\n\t\t       );\n\n//*** CryptHashEnd()\n// Complete a hash or HMAC computation. This function will place the smaller of\n// 'digestSize' or the size of the digest in 'dOut'. The number of bytes in the\n// placed in the buffer is returned. If there is a failure, the returned value\n// is <= 0.\n//  Return Type: UINT16\n//       0      no data returned\n//      > 0     the number of bytes in the digest or dOutSize, whichever is smaller\nLIB_EXPORT UINT16 CryptHashEnd(PHASH_STATE hashState,  // IN: the state of hash stack\n\t\t\t       UINT32      dOutSize,   // IN: size of digest buffer\n\t\t\t       BYTE*       dOut        // OUT: hash digest\n\t\t\t       );\n\n//*** CryptHashBlock()\n// Start a hash, hash a single block, update 'digest' and return the size of\n// the results.\n//\n// The 'digestSize' parameter can be smaller than the digest. If so, only the more\n// significant bytes are returned.\n//  Return Type: UINT16\n//  >= 0        number of bytes placed in 'dOut'\nLIB_EXPORT UINT16 CryptHashBlock(TPM_ALG_ID  hashAlg,   // IN: The hash algorithm\n\t\t\t\t UINT32      dataSize,  // IN: size of buffer to hash\n\t\t\t\t const BYTE* data,      // IN: the buffer to hash\n\t\t\t\t UINT32 dOutSize,  // IN: size of the digest buffer\n\t\t\t\t BYTE*  dOut       // OUT: digest buffer\n\t\t\t\t );\n\n//*** CryptDigestUpdate2B()\n// This function updates a digest (hash or HMAC) with a TPM2B.\n//\n// This function can be used for both HMAC and hash functions so the\n// 'digestState' is void so that either state type can be passed.\nLIB_EXPORT void CryptDigestUpdate2B(PHASH_STATE  state,  // IN: the digest state\n\t\t\t\t    const TPM2B* bIn     // IN: 2B containing the data\n\t\t\t\t    );\n\n//*** CryptHashEnd2B()\n// This function is the same as CryptCompleteHash() but the digest is\n// placed in a TPM2B. This is the most common use and this is provided\n// for specification clarity. 'digest.size' should be set to indicate the number of\n// bytes to place in the buffer\n//  Return Type: UINT16\n//      >=0     the number of bytes placed in 'digest.buffer'\nLIB_EXPORT UINT16 CryptHashEnd2B(\n\t\t\t\t PHASH_STATE state,  // IN: the hash state\n\t\t\t\t P2B         digest  // IN: the size of the buffer Out: requested\n\t\t\t\t //     number of bytes\n\t\t\t\t );\n\n//*** CryptDigestUpdateInt()\n// This function is used to include an integer value to a hash stack. The function\n// marshals the integer into its canonical form before calling CryptDigestUpdate().\nLIB_EXPORT void CryptDigestUpdateInt(\n\t\t\t\t     void*  state,    // IN: the state of hash stack\n\t\t\t\t     UINT32 intSize,  // IN: the size of 'intValue' in bytes\n\t\t\t\t     UINT64 intValue  // IN: integer value to be hashed\n\t\t\t\t     );\n\n//*** CryptHmacStart()\n// This function is used to start an HMAC using a temp\n// hash context. The function does the initialization\n// of the hash with the HMAC key XOR iPad and updates the\n// HMAC key XOR oPad.\n//\n// The function returns the number of bytes in a digest produced by 'hashAlg'.\n//  Return Type: UINT16\n//  >= 0        number of bytes in digest produced by 'hashAlg' (may be zero)\n//\nLIB_EXPORT UINT16 CryptHmacStart(PHMAC_STATE state,    // IN/OUT: the state buffer\n\t\t\t\t TPM_ALG_ID  hashAlg,  // IN: the algorithm to use\n\t\t\t\t UINT16      keySize,  // IN: the size of the HMAC key\n\t\t\t\t const BYTE* key       // IN: the HMAC key\n\t\t\t\t );\n\n//*** CryptHmacEnd()\n// This function is called to complete an HMAC. It will finish the current\n// digest, and start a new digest. It will then add the oPadKey and the\n// completed digest and return the results in dOut. It will not return more\n// than dOutSize bytes.\n//  Return Type: UINT16\n//  >= 0        number of bytes in 'dOut' (may be zero)\nLIB_EXPORT UINT16 CryptHmacEnd(PHMAC_STATE state,     // IN: the hash state buffer\n\t\t\t       UINT32      dOutSize,  // IN: size of digest buffer\n\t\t\t       BYTE*       dOut       // OUT: hash digest\n\t\t\t       );\n\n//*** CryptHmacStart2B()\n// This function starts an HMAC and returns the size of the digest\n// that will be produced.\n//\n// This function is provided to support the most common use of starting an HMAC\n// with a TPM2B key.\n//\n// The caller must provide a block of memory in which the hash sequence state\n// is kept.  The caller should not alter the contents of this buffer until the\n// hash sequence is completed or abandoned.\n//\n//  Return Type: UINT16\n//      > 0     the digest size of the algorithm\n//      = 0     the hashAlg was TPM_ALG_NULL\nLIB_EXPORT UINT16 CryptHmacStart2B(\n\t\t\t\t   PHMAC_STATE hmacState,  // OUT: the state of HMAC stack. It will be used\n\t\t\t\t   //     in HMAC update and completion\n\t\t\t\t   TPMI_ALG_HASH hashAlg,  // IN: hash algorithm\n\t\t\t\t   P2B           key       // IN: HMAC key\n\t\t\t\t   );\n\n//*** CryptHmacEnd2B()\n//   This function is the same as CryptHmacEnd() but the HMAC result\n//   is returned in a TPM2B which is the most common use.\n//  Return Type: UINT16\n//      >=0     the number of bytes placed in 'digest'\nLIB_EXPORT UINT16 CryptHmacEnd2B(\n\t\t\t\t PHMAC_STATE hmacState,  // IN: the state of HMAC stack\n\t\t\t\t P2B         digest      // OUT: HMAC\n\t\t\t\t );\n\n//** Mask and Key Generation Functions\n//*** CryptMGF_KDF()\n// This function performs MGF1/KDF1 or KDF2 using the selected hash. KDF1 and KDF2 are\n// T('n') = T('n'-1) || H('seed' || 'counter') with the difference being that, with\n// KDF1, 'counter' starts at 0 but with KDF2, 'counter' starts at 1. The caller\n// determines which version by setting the initial value of counter to either 0 or 1.\n// Note: Any value that is not 0 is considered to be 1.\n//\n// This function returns the length of the mask produced which\n// could be zero if the digest algorithm is not supported\n//  Return Type: UINT16\n//      0       hash algorithm was TPM_ALG_NULL\n//    > 0       should be the same as 'mSize'\nLIB_EXPORT UINT16 CryptMGF_KDF(UINT32 mSize,  // IN: length of the mask to be produced\n\t\t\t       BYTE*  mask,   // OUT: buffer to receive the mask\n\t\t\t       TPM_ALG_ID hashAlg,   // IN: hash to use\n\t\t\t       UINT32     seedSize,  // IN: size of the seed\n\t\t\t       BYTE*      seed,      // IN: seed size\n\t\t\t       UINT32     counter    // IN: counter initial value\n\t\t\t       );\n\n//*** CryptKDFa()\n// This function performs the key generation according to Part 1 of the\n// TPM specification.\n//\n// This function returns the number of bytes generated which may be zero.\n//\n// The 'key' and 'keyStream' pointers are not allowed to be NULL. The other\n// pointer values may be NULL. The value of 'sizeInBits' must be no larger\n// than (2^18)-1 = 256K bits (32385 bytes).\n//\n// The 'once' parameter is set to allow incremental generation of a large\n// value. If this flag is TRUE, 'sizeInBits' will be used in the HMAC computation\n// but only one iteration of the KDF is performed. This would be used for\n// XOR obfuscation so that the mask value can be generated in digest-sized\n// chunks rather than having to be generated all at once in an arbitrarily\n// large buffer and then XORed into the result. If 'once' is TRUE, then\n// 'sizeInBits' must be a multiple of 8.\n//\n// Any error in the processing of this command is considered fatal.\n//  Return Type: UINT16\n//     0            hash algorithm is not supported or is TPM_ALG_NULL\n//    > 0           the number of bytes in the 'keyStream' buffer\nLIB_EXPORT UINT16 CryptKDFa(\n\t\t\t    TPM_ALG_ID   hashAlg,       // IN: hash algorithm used in HMAC\n\t\t\t    const TPM2B* key,           // IN: HMAC key\n\t\t\t    const TPM2B* label,         // IN: a label for the KDF\n\t\t\t    const TPM2B* contextU,      // IN: context U\n\t\t\t    const TPM2B* contextV,      // IN: context V\n\t\t\t    UINT32       sizeInBits,    // IN: size of generated key in bits\n\t\t\t    BYTE*        keyStream,     // OUT: key buffer\n\t\t\t    UINT32*      counterInOut,  // IN/OUT: caller may provide the iteration\n\t\t\t    //     counter for incremental operations to\n\t\t\t    //     avoid large intermediate buffers.\n\t\t\t    UINT16 blocks               // IN: If non-zero, this is the maximum number\n\t\t\t    //     of blocks to be returned, regardless\n\t\t\t    //     of sizeInBits\n\t\t\t    );\n\n//*** CryptKDFe()\n// This function implements KDFe() as defined in TPM specification part 1.\n//\n// This function returns the number of bytes generated which may be zero.\n//\n// The 'Z' and 'keyStream' pointers are not allowed to be NULL. The other\n// pointer values may be NULL. The value of 'sizeInBits' must be no larger\n// than (2^18)-1 = 256K bits (32385 bytes).\n// Any error in the processing of this command is considered fatal.\n//  Return Type: UINT16\n//     0            hash algorithm is not supported or is TPM_ALG_NULL\n//    > 0           the number of bytes in the 'keyStream' buffer\n//\nLIB_EXPORT UINT16 CryptKDFe(TPM_ALG_ID   hashAlg,  // IN: hash algorithm used in HMAC\n\t\t\t    TPM2B*       Z,        // IN: Z\n\t\t\t    const TPM2B* label,    // IN: a label value for the KDF\n\t\t\t    TPM2B*       partyUInfo,  // IN: PartyUInfo\n\t\t\t    TPM2B*       partyVInfo,  // IN: PartyVInfo\n\t\t\t    UINT32 sizeInBits,  // IN: size of generated key in bits\n\t\t\t    BYTE*  keyStream    // OUT: key buffer\n\t\t\t    );\n\n#endif  // _CRYPT_HASH_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptPrimeSieve_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Aug 30, 2019  Time: 02:11:54PM\n */\n\n#ifndef _CRYPT_PRIME_SIEVE_FP_H_\n#define _CRYPT_PRIME_SIEVE_FP_H_\n\n#if RSA_KEY_SIEVE\n\n//*** RsaAdjustPrimeLimit()\n// This used during the sieve process. The iterator for getting the\n// next prime (RsaNextPrime()) will return primes until it hits the\n// limit (primeLimit) set up by this function. This causes the sieve\n// process to stop when an appropriate number of primes have been\n// sieved.\nLIB_EXPORT void RsaAdjustPrimeLimit(uint32_t requestedPrimes);\n\n//*** RsaNextPrime()\n// This the iterator used during the sieve process. The input is the\n// last prime returned (or any starting point) and the output is the\n// next higher prime. The function returns 0 when the primeLimit is\n// reached.\nLIB_EXPORT uint32_t RsaNextPrime(uint32_t lastPrime);\n\n//*** FindNthSetBit()\n// This function finds the nth SET bit in a bit array. The 'n' parameter is\n// between 1 and the number of bits in the array (always a multiple of 8).\n// If called when the array does not have n bits set, it will return -1\n//  Return Type: unsigned int\n//      <0      no bit is set or no bit with the requested number is set\n//      >=0    the number of the bit in the array that is the nth set\nLIB_EXPORT int FindNthSetBit(\n\t\t\t     const UINT16 aSize,  // IN: the size of the array to check\n\t\t\t     const BYTE*  a,      // IN: the array to check\n\t\t\t     const UINT32 n       // IN, the number of the SET bit\n\t\t\t     );\n\n//*** PrimeSieve()\n// This function does a prime sieve over the input 'field' which has as its\n// starting address the value in bnN. Since this initializes the Sieve\n// using a precomputed field with the bits associated with 3, 5 and 7 already\n// turned off, the value of pnN may need to be adjusted by a few counts to allow\n// the precomputed field to be used without modification.\n//\n// To get better performance, one could address the issue of developing the\n// composite numbers. When the size of the prime gets large, the time for doing\n// the divisions goes up, noticeably. It could be better to develop larger composite\n// numbers even if they need to be Crypt_Int*'s themselves. The object would be to\n// reduce the number of times that the large prime is divided into a few large\n// divides and then use smaller divides to get to the final 16 bit (or smaller)\n// remainders.\nLIB_EXPORT UINT32 PrimeSieve(Crypt_Int* bnN,    // IN/OUT: number to sieve\n\t\t\t     UINT32 fieldSize,  // IN: size of the field area in bytes\n\t\t\t     BYTE*  field       // IN: field\n\t\t\t     );\n#  ifdef SIEVE_DEBUG\n\n//***SetFieldSize()\n// Function to set the field size used for prime generation. Used for tuning.\nLIB_EXPORT uint32_t SetFieldSize(uint32_t newFieldSize);\n#  endif  // SIEVE_DEBUG\n\n//*** PrimeSelectWithSieve()\n// This function will sieve the field around the input prime candidate. If the\n// sieve field is not empty, one of the one bits in the field is chosen for testing\n// with Miller-Rabin. If the value is prime, 'pnP' is updated with this value\n// and the function returns success. If this value is not prime, another\n// pseudo-random candidate is chosen and tested. This process repeats until\n// all values in the field have been checked. If all bits in the field have\n// been checked and none is prime, the function returns FALSE and a new random\n// value needs to be chosen.\n//  Return Type: TPM_RC\n//      TPM_RC_FAILURE      TPM in failure mode, probably due to entropy source\n//      TPM_RC_SUCCESS      candidate is probably prime\n//      TPM_RC_NO_RESULT    candidate is not prime and couldn't find and alternative\n//                          in the field\nLIB_EXPORT TPM_RC PrimeSelectWithSieve(\n\t\t\t\t       Crypt_Int*  candidate,  // IN/OUT: The candidate to filter\n\t\t\t\t       UINT32      e,          // IN: the exponent\n\t\t\t\t       RAND_STATE* rand        // IN: the random number generator state\n\t\t\t\t       );\n#  if RSA_INSTRUMENT\n\n//*** PrintTuple()\nchar* PrintTuple(UINT32* i);\n\n//*** RsaSimulationEnd()\nvoid RsaSimulationEnd(void);\n\n//*** GetSieveStats()\nLIB_EXPORT void GetSieveStats(\n\t\t\t      uint32_t* trials, uint32_t* emptyFields, uint32_t* averageBits);\n#  endif\n#endif  // RSA_KEY_SIEVE\n#if !RSA_INSTRUMENT\n\n//*** RsaSimulationEnd()\n// Stub for call when not doing instrumentation.\nvoid RsaSimulationEnd(void);\n#endif\n\n#endif  // _CRYPT_PRIME_SIEVE_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptPrime_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t      Code for prime validation\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Aug 30, 2019  Time: 02:11:54PM\n */\n\n#ifndef _CRYPT_PRIME_FP_H_\n#define _CRYPT_PRIME_FP_H_\n\n//*** IsPrimeInt()\n// This will do a test of a word of up to 32-bits in size.\nBOOL IsPrimeInt(uint32_t n);\n\n//*** TpmMath_IsProbablyPrime()\n// This function is used when the key sieve is not implemented. This function\n// Will try to eliminate some of the obvious things before going on\n// to perform MillerRabin as a final verification of primeness.\nBOOL TpmMath_IsProbablyPrime(Crypt_Int*  prime,  // IN:\n\t\t\t     RAND_STATE* rand    // IN: the random state just\n\t\t\t     //     in case Miller-Rabin is required\n\t\t\t     );\n\n//*** MillerRabinRounds()\n// Function returns the number of Miller-Rabin rounds necessary to give an\n// error probability equal to the security strength of the prime. These values\n// are from FIPS 186-3.\nUINT32\nMillerRabinRounds(UINT32 bits  // IN: Number of bits in the RSA prime\n\t\t  );\n\n//*** MillerRabin()\n// This function performs a Miller-Rabin test from FIPS 186-3. It does\n// 'iterations' trials on the number. In all likelihood, if the number\n// is not prime, the first test fails.\n//  Return Type: BOOL\n//      TRUE(1)         probably prime\n//      FALSE(0)        composite\nBOOL MillerRabin(Crypt_Int* bnW, RAND_STATE* rand);\n#if ALG_RSA\n\n//*** RsaCheckPrime()\n// This will check to see if a number is prime and appropriate for an\n// RSA prime.\n//\n// This has different functionality based on whether we are using key\n// sieving or not. If not, the number checked to see if it is divisible by\n// the public exponent, then the number is adjusted either up or down\n// in order to make it a better candidate. It is then checked for being\n// probably prime.\n//\n// If sieving is used, the number is used to root a sieving process.\n//\nTPM_RC\nRsaCheckPrime(Crypt_Int* prime, UINT32 exponent, RAND_STATE* rand);\n\n//*** TpmRsa_GeneratePrimeForRSA()\n// Function to generate a prime of the desired size with the proper attributes\n// for an RSA prime.\nTPM_RC\nTpmRsa_GeneratePrimeForRSA(\n\t\t\t   Crypt_Int* prime,      // IN/OUT: points to the BN that will get the\n\t\t\t   //  random value\n\t\t\t   UINT32      bits,      // IN: number of bits to get\n\t\t\t   UINT32      exponent,  // IN: the exponent\n\t\t\t   RAND_STATE* rand       // IN: the random state\n\t\t\t   );\n#endif  // ALG_RSA\n\n#endif  // _CRYPT_PRIME_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptRand.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tDRBG with a behavior according to SP800-90A\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains constant definition shared by CryptUtil and the parts\n// of the Crypto Engine.\n//\n\n#ifndef _CRYPT_RAND_H\n#define _CRYPT_RAND_H\n\n//** DRBG Structures and Defines\n\n// Values and structures for the random number generator. These values are defined\n// in this header file so that the size of the RNG state can be known to TPM.lib.\n// This allows the allocation of some space in NV memory for the state to\n// be stored on an orderly shutdown.\n\n// The DRBG based on a symmetric block cipher is defined by three values,\n// 1) the key size\n// 2) the block size (the IV size)\n// 3) the symmetric algorithm\n\n#define DRBG_KEY_SIZE_BITS AES_MAX_KEY_SIZE_BITS\n#define DRBG_IV_SIZE_BITS  (AES_MAX_BLOCK_SIZE * 8)\n#define DRBG_ALGORITHM     TPM_ALG_AES\n\n#define DRBG_ENCRYPT_SETUP(key, keySizeInBits, schedule)\t\t\\\n    TpmCryptSetEncryptKeyAES(key, keySizeInBits, schedule)\n#define DRBG_ENCRYPT(keySchedule, in, out)\t\t\t\\\n    TpmCryptEncryptAES(SWIZZLE(keySchedule, in, out))\n\n#if((DRBG_KEY_SIZE_BITS % RADIX_BITS) != 0) || ((DRBG_IV_SIZE_BITS % RADIX_BITS) != 0)\n#  error \"Key size and IV for DRBG must be even multiples of the radix\"\n#endif\n#if(DRBG_KEY_SIZE_BITS % DRBG_IV_SIZE_BITS) != 0\n#  error \"Key size for DRBG must be even multiple of the cypher block size\"\n#endif\n\n// Derived values\n#define DRBG_MAX_REQUESTS_PER_RESEED (1 << 48)\n#define DRBG_MAX_REQEST_SIZE         (1 << 32)\n\n#define pDRBG_KEY(seed) ((DRBG_KEY*)&(((BYTE*)(seed))[0]))\n#define pDRBG_IV(seed)  ((DRBG_IV*)&(((BYTE*)(seed))[DRBG_KEY_SIZE_BYTES]))\n\n#define DRBG_KEY_SIZE_WORDS (BITS_TO_CRYPT_WORDS(DRBG_KEY_SIZE_BITS))\n#define DRBG_KEY_SIZE_BYTES (DRBG_KEY_SIZE_WORDS * RADIX_BYTES)\n\n#define DRBG_IV_SIZE_WORDS (BITS_TO_CRYPT_WORDS(DRBG_IV_SIZE_BITS))\n#define DRBG_IV_SIZE_BYTES (DRBG_IV_SIZE_WORDS * RADIX_BYTES)\n\n#define DRBG_SEED_SIZE_WORDS (DRBG_KEY_SIZE_WORDS + DRBG_IV_SIZE_WORDS)\n#define DRBG_SEED_SIZE_BYTES (DRBG_KEY_SIZE_BYTES + DRBG_IV_SIZE_BYTES)\n\ntypedef union\n{\n    BYTE          bytes[DRBG_KEY_SIZE_BYTES];\n    crypt_uword_t words[DRBG_KEY_SIZE_WORDS];\n} DRBG_KEY;\n\ntypedef union\n{\n    BYTE          bytes[DRBG_IV_SIZE_BYTES];\n    crypt_uword_t words[DRBG_IV_SIZE_WORDS];\n} DRBG_IV;\n\ntypedef union\n{\n    BYTE          bytes[DRBG_SEED_SIZE_BYTES];\n    crypt_uword_t words[DRBG_SEED_SIZE_WORDS];\n} DRBG_SEED;\n\n#define CTR_DRBG_MAX_REQUESTS_PER_RESEED ((UINT64)1 << 20)\n#define CTR_DRBG_MAX_BYTES_PER_REQUEST   (1 << 16)\n\n#define CTR_DRBG_MIN_ENTROPY_INPUT_LENGTH    DRBG_SEED_SIZE_BYTES\n#define CTR_DRBG_MAX_ENTROPY_INPUT_LENGTH    DRBG_SEED_SIZE_BYTES\n#define CTR_DRBG_MAX_ADDITIONAL_INPUT_LENGTH DRBG_SEED_SIZE_BYTES\n\n#define TESTING (1 << 0)\n#define ENTROPY (1 << 1)\n#define TESTED  (1 << 2)\n\n#define IsTestStateSet(BIT)    ((g_cryptoSelfTestState.rng & BIT) != 0)\n#define SetTestStateBit(BIT)   (g_cryptoSelfTestState.rng |= BIT)\n#define ClearTestStateBit(BIT) (g_cryptoSelfTestState.rng &= ~BIT)\n\n#define IsSelfTest()    IsTestStateSet(TESTING)\n#define SetSelfTest()   SetTestStateBit(TESTING)\n#define ClearSelfTest() ClearTestStateBit(TESTING)\n\n#define IsEntropyBad()    IsTestStateSet(ENTROPY)\n#define SetEntropyBad()   SetTestStateBit(ENTROPY)\n#define ClearEntropyBad() ClearTestStateBit(ENTROPY)\n\n#define IsDrbgTested()    IsTestStateSet(TESTED)\n#define SetDrbgTested()   SetTestStateBit(TESTED)\n#define ClearDrbgTested() ClearTestStateBit(TESTED)\n\ntypedef struct\n{\n    UINT64    reseedCounter;\n    UINT32    magic;\n    DRBG_SEED seed;          // contains the key and IV for the counter mode DRBG\n    UINT32    lastValue[4];  // used when the TPM does continuous self-test\n    // for FIPS compliance of DRBG\n} DRBG_STATE, *pDRBG_STATE;\n#define DRBG_MAGIC ((UINT32)0x47425244)  // \"DRBG\" backwards so that it displays\n\ntypedef struct KDF_STATE\n{\n    UINT64       counter;\n    UINT32       magic;\n    UINT32       limit;\n    TPM2B*       seed;\n    const TPM2B* label;\n    TPM2B*       context;\n    TPM_ALG_ID   hash;\n    TPM_ALG_ID   kdf;\n    UINT16       digestSize;\n    TPM2B_DIGEST residual;\n} KDF_STATE, *pKDR_STATE;\n#define KDF_MAGIC ((UINT32)0x4048444a)  // \"KDF \" backwards\n\n// Make sure that any other structures added to this union start with a 64-bit\n// counter and a 32-bit magic number\ntypedef union\n{\n    DRBG_STATE drbg;\n    KDF_STATE  kdf;\n} RAND_STATE;\n\n// This is the state used when the library uses a random number generator.\n// A special function is installed for the library to call. That function\n// picks up the state from this location and uses it for the generation\n// of the random number.\nextern RAND_STATE* s_random;\n\n// When instrumenting RSA key sieve\n#if RSA_INSTRUMENT\n#  define PRIME_INDEX(x)       ((x) == 512 ? 0 : (x) == 1024 ? 1 : 2)\n#  define INSTRUMENT_SET(a, b) ((a) = (b))\n#  define INSTRUMENT_ADD(a, b) (a) = (a) + (b)\n#  define INSTRUMENT_INC(a)    (a) = (a) + 1\n\nextern UINT32 PrimeIndex;\nextern UINT32 failedAtIteration[10];\nextern UINT32 PrimeCounts[3];\nextern UINT32 MillerRabinTrials[3];\nextern UINT32 totalFieldsSieved[3];\nextern UINT32 bitsInFieldAfterSieve[3];\nextern UINT32 emptyFieldsSieved[3];\nextern UINT32 noPrimeFields[3];\nextern UINT32 primesChecked[3];\nextern UINT16 lastSievePrime;\n#else\n#  define INSTRUMENT_SET(a, b)\n#  define INSTRUMENT_ADD(a, b)\n#  define INSTRUMENT_INC(a)\n#endif\n\n#endif  // _CRYPT_RAND_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptRand_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tDRBG with a behavior according to SP800-90A\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CryptRand_fp.h 1476 2019-06-10 19:32:03Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CRYPTRAND_FP_H\n#define CRYPTRAND_FP_H\n\nBOOL\nDRBG_GetEntropy(\n\t\tUINT32           requiredEntropy,   // IN: requested number of bytes of full\n\t\t//     entropy\n\t\tBYTE            *entropy            // OUT: buffer to return collected entropy\n\t\t);\nvoid\nIncrementIv(\n\t    DRBG_IV         *iv\n\t    );\nBOOL\nDRBG_Reseed(\n\t    DRBG_STATE          *drbgState,         // IN: the state to update\n\t    DRBG_SEED           *providedEntropy,   // IN: entropy\n\t    DRBG_SEED           *additionalData     // IN:\n\t    );\nBOOL\nDRBG_SelfTest(\n\t      void\n\t      );\nLIB_EXPORT TPM_RC\nCryptRandomStir(\n\t\tUINT16           additionalDataSize,\n\t\tBYTE            *additionalData\n\t\t);\nLIB_EXPORT UINT16\nCryptRandomGenerate(\n\t\t    UINT16           randomSize,\n\t\t    BYTE            *buffer\n\t\t    );\nLIB_EXPORT BOOL\nDRBG_InstantiateSeededKdf(\n\t\t\t  KDF_STATE       *state,         // IN: buffer to hold the state\n\t\t\t  TPM_ALG_ID       hashAlg,       // IN: hash algorithm\n\t\t\t  TPM_ALG_ID       kdf,           // IN: the KDF to use\n\t\t\t  TPM2B           *seed,          // IN: the seed to use\n\t\t\t  const TPM2B     *label,         // IN: a label for the generation process.\n\t\t\t  TPM2B           *context,       // IN: the context value\n\t\t\t  UINT32           limit          // IN: Maximum number of bits from the KDF\n\t\t\t  );\nLIB_EXPORT void\nDRBG_AdditionalData(\n\t\t    DRBG_STATE      *drbgState,     // IN:OUT state to update\n\t\t    TPM2B           *additionalData // IN: value to incorporate\n\t\t    );\nLIB_EXPORT TPM_RC\nDRBG_InstantiateSeeded(\n\t\t       DRBG_STATE      *drbgState,     // IN: buffer to hold the state\n\t\t       const TPM2B     *seed,          // IN: the seed to use\n\t\t       const TPM2B     *purpose,       // IN: a label for the generation process.\n\t\t       const TPM2B     *name,          // IN: name of the object\n\t\t       const TPM2B     *additional     // IN: additional data\n\t\t       );\nLIB_EXPORT BOOL\nCryptRandStartup(\n\t\t void\n\t\t );\nLIB_EXPORT BOOL\nCryptRandInit(\n\t      void\n\t      );\nLIB_EXPORT UINT16\nDRBG_Generate(\n\t      RAND_STATE      *state,\n\t      BYTE            *random,        // OUT: buffer to receive the random values\n\t      UINT16           randomSize     // IN: the number of bytes to generate\n\t      );\nLIB_EXPORT BOOL\nDRBG_Instantiate(\n\t\t DRBG_STATE      *drbgState,         // OUT: the instantiated value\n\t\t UINT16           pSize,             // IN: Size of personalization string\n\t\t BYTE            *personalization    // IN: The personalization string\n\t\t );\nLIB_EXPORT TPM_RC\nDRBG_Uninstantiate(\n\t\t   DRBG_STATE      *drbgState      // IN/OUT: working state to erase\n\t\t   );\nLIB_EXPORT NUMBYTES\nCryptRandMinMax(\n\t\tBYTE            *out,\n\t\tUINT32           max,\n\t\tUINT32           min,\n\t\tRAND_STATE      *rand\n\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptRsa.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     RSA-related structures and defines\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This file contains the RSA-related structures and defines.\n\n#ifndef _CRYPT_RSA_H\n#define _CRYPT_RSA_H\n\n// These values are used in the Crypt_Int* representation of various RSA values.\n// define ci_rsa_t as buffer containing a CRYPT_INT object with space for\n// (MAX_RSA_KEY_BITS) of actual data.\nCRYPT_INT_TYPE(rsa, MAX_RSA_KEY_BITS);\n#define CRYPT_RSA_VAR(name) CRYPT_INT_VAR(name, MAX_RSA_KEY_BITS)\n#define CRYPT_RSA_INITIALIZED(name, initializer)\t\t\t\\\n    CRYPT_INT_INITIALIZED(name, MAX_RSA_KEY_BITS, initializer)\n\n#define CRYPT_PRIME_VAR(name) CRYPT_INT_VAR(name, (MAX_RSA_KEY_BITS / 2))\n// define ci_prime_t as buffer containing a CRYPT_INT object with space for\n// (MAX_RSA_KEY_BITS/2) of actual data.\nCRYPT_INT_TYPE(prime, (MAX_RSA_KEY_BITS / 2));\n#define CRYPT_PRIME_INITIALIZED(name, initializer)\t\t\t\\\n    CRYPT_INT_INITIALIZED(name, MAX_RSA_KEY_BITS / 2, initializer)\n\n#if !CRT_FORMAT_RSA\n#  error This verson only works with CRT formatted data\n#endif  // !CRT_FORMAT_RSA\n\ntypedef struct privateExponent\n{\n    Crypt_Int* P;\n    Crypt_Int* Q;\n    Crypt_Int* dP;\n    Crypt_Int* dQ;\n    Crypt_Int* qInv;\n    ci_prime_t entries[5];\n} privateExponent;\n\n#define NEW_PRIVATE_EXPONENT(X)\t\t\\\n    privateExponent  _##X;\t\t\t\t\t\\\n    privateExponent* X = RsaInitializeExponent(&(_##X))\n\n#endif  // _CRYPT_RSA_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptRsa_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tImplementation of cryptographic primitives for RSA\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CRYPTRSA_FP_H\n#define CRYPTRSA_FP_H\n\nBOOL\nCryptRsaInit(\n\t     void\n\t     );\nBOOL\nCryptRsaStartup(\n\t\tvoid\n\t\t);\nINT16\nCryptRsaPssSaltSize(\n\t\t    INT16              hashSize,\n\t\t    INT16               outSize\n\t\t    );\nTPMT_RSA_DECRYPT*\nCryptRsaSelectScheme(\n\t\t     TPMI_DH_OBJECT       rsaHandle,     // IN: handle of an RSA key\n\t\t     TPMT_RSA_DECRYPT    *scheme         // IN: a sign or decrypt scheme\n\t\t     );\nTPM_RC\nCryptRsaLoadPrivateExponent(TPMT_PUBLIC             *publicArea,\n\t\t\t    TPMT_SENSITIVE          *sensitive);\nLIB_EXPORT TPM_RC\nCryptRsaEncrypt(\n\t\tTPM2B_PUBLIC_KEY_RSA        *cOut,          // OUT: the encrypted data\n\t\tTPM2B                       *dIn,           // IN: the data to encrypt\n\t\tOBJECT                      *key,           // IN: the key used for encryption\n\t\tTPMT_RSA_DECRYPT            *scheme,        // IN: the type of padding and hash\n\t\t//     if needed\n\t\tconst TPM2B                 *label,         // IN: in case it is needed\n\t\tRAND_STATE                  *rand           // IN: random number generator\n\t\t//     state (mostly for testing)\n\t\t);\nLIB_EXPORT TPM_RC\nCryptRsaDecrypt(\n\t\tTPM2B               *dOut,          // OUT: the decrypted data\n\t\tTPM2B               *cIn,           // IN: the data to decrypt\n\t\tOBJECT              *key,           // IN: the key to use for decryption\n\t\tTPMT_RSA_DECRYPT    *scheme,        // IN: the padding scheme\n\t\tconst TPM2B         *label          // IN: in case it is needed for the scheme\n\t\t);\nLIB_EXPORT TPM_RC\nCryptRsaSign(\n\t     TPMT_SIGNATURE      *sigOut,\n\t     OBJECT              *key,           // IN: key to use\n\t     TPM2B_DIGEST        *hIn,           // IN: the digest to sign\n\t     RAND_STATE          *rand           // IN: the random number generator\n\t     //      to use (mostly for testing)\n\t     );\nLIB_EXPORT TPM_RC\nCryptRsaValidateSignature(\n\t\t\t  TPMT_SIGNATURE  *sig,           // IN: signature\n\t\t\t  OBJECT          *key,           // IN: public modulus\n\t\t\t  TPM2B_DIGEST    *digest         // IN: The digest being validated\n\t\t\t  );\nLIB_EXPORT TPM_RC\nCryptRsaGenerateKey(\n\t\t    TPMT_PUBLIC         *publicArea,\n\t\t    TPMT_SENSITIVE      *sensitive,\n\t\t    RAND_STATE          *rand               // IN: if not NULL, the deterministic\n\t\t    );\nINT16\nMakeDerTag(\n\t   TPM_ALG_ID   hashAlg,\n\t   INT16        sizeOfBuffer,\n\t   BYTE        *buffer\n\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptSelfTest_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CryptSelfTest_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CRYPTSELFTEST_FP_H\n#define CRYPTSELFTEST_FP_H\n\nLIB_EXPORT\nTPM_RC\nCryptSelfTest(\n\t      TPMI_YES_NO      fullTest       // IN: if full test is required\n\t      );\nTPM_RC\nCryptIncrementalSelfTest(\n\t\t\t TPML_ALG            *toTest,        // IN: list of algorithms to be tested\n\t\t\t TPML_ALG            *toDoList       // OUT: list of algorithms needing test\n\t\t\t );\nvoid\nCryptInitializeToTest(\n\t\t      void\n\t\t      );\nLIB_EXPORT\nTPM_RC\nCryptTestAlgorithm(\n\t\t   TPM_ALG_ID           alg,\n\t\t   ALGORITHM_VECTOR    *toTest\n\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptSmac_fp.h",
    "content": "/********************************************************************************/\n/*\t\tMessage Authentication Codes Based on a Symmetric Block Cipher\t*/\n/*\t\tImplementation of cryptographic functions for hashing.\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CryptSmac_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2018\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CRYPTSMAC_FP_H\n#define CRYPTSMAC_FP_H\n#include \"Tpm.h\"\n\nUINT16\nCryptSmacStart(\n\t       HASH_STATE              *state,\n\t       TPMU_PUBLIC_PARMS       *keyParameters,\n\t       TPM_ALG_ID               macAlg, \n\t       TPM2B                   *key\n\t       );\nUINT16\nCryptMacStart(\n\t      HMAC_STATE              *state,\n\t      TPMU_PUBLIC_PARMS       *keyParameters,\n\t      TPM_ALG_ID               macAlg, \n\t      TPM2B                   *key\n\t      );\nUINT16\nCryptMacEnd(\n\t    HMAC_STATE          *state,\n\t    UINT32               size,\n\t    BYTE                *buffer\n\t    );\nUINT16\nCryptMacEnd(\n\t    HMAC_STATE          *state,\n\t    UINT32               size,\n\t    BYTE                *buffer\n\t    );\nUINT16\nCryptMacEnd2B (\n\t       HMAC_STATE          *state,\n\t       TPM2B               *data\n\t       );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptSym.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tImplementation of the symmetric block cipher modes \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2017 - 2023 \t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// This file contains the implementation of the symmetric block cipher modes\n// allowed for a TPM. These functions only use the single block encryption functions\n// of the selected symmetric cryptographic library.\n\n//** Includes, Defines, and Typedefs\n#ifndef CRYPT_SYM_H\n#define CRYPT_SYM_H\n\n#if ALG_AES\n#  define IF_IMPLEMENTED_AES(op) op(AES, aes)\n#else\n#  define IF_IMPLEMENTED_AES(op)\n#endif\n#if ALG_SM4\n#  define IF_IMPLEMENTED_SM4(op) op(SM4, sm4)\n#else\n#  define IF_IMPLEMENTED_SM4(op)\n#endif\n#if ALG_CAMELLIA\n#  define IF_IMPLEMENTED_CAMELLIA(op) op(CAMELLIA, camellia)\n#else\n#  define IF_IMPLEMENTED_CAMELLIA(op)\n#endif\n\n#define FOR_EACH_SYM(op)\t   \\\n    IF_IMPLEMENTED_AES(op)\t   \\\n    IF_IMPLEMENTED_SM4(op)\t\t\t\\\n    IF_IMPLEMENTED_CAMELLIA(op)\n\n// Macros for creating the key schedule union\n#define KEY_SCHEDULE(SYM, sym) tpmKeySchedule##SYM sym;\ntypedef union tpmCryptKeySchedule_t\n{\n    FOR_EACH_SYM(KEY_SCHEDULE)\n    \n#if SYMMETRIC_ALIGNMENT == 8\n    uint64_t alignment;\n#else\n    uint32_t alignment;\n#endif\n} tpmCryptKeySchedule_t;\n\n// Each block cipher within a library is expected to conform to the same calling\n// conventions with three parameters ('keySchedule', 'in', and 'out') in the same\n// order. That means that all algorithms would use the same order of the same\n// parameters. The code is written assuming the ('keySchedule', 'in', and 'out')\n// order. However, if the library uses a different order, the order can be changed\n// with a SWIZZLE macro that puts the parameters in the correct order.\n// Note that all algorithms have to use the same order and number of parameters\n// because the code to build the calling list is common for each call to encrypt\n// or decrypt with the algorithm chosen by setting a function pointer to select\n// the algorithm that is used.\n\n#define ENCRYPT(keySchedule, in, out) encrypt(SWIZZLE(keySchedule, in, out))\n\n#define DECRYPT(keySchedule, in, out) decrypt(SWIZZLE(keySchedule, in, out))\n\n// Note that the macros rely on 'encrypt' as local values in the\n// functions that use these macros. Those parameters are set by the macro that\n// set the key schedule to be used for the call.\n\n#define ENCRYPT_CASE(ALG, alg)\t\t\t\t\t\t\\\n    case TPM_ALG_##ALG:\t\t\t\t\t\t\t\\\n    TpmCryptSetEncryptKey##ALG(key, keySizeInBits, &keySchedule.alg);\t\\\n    encrypt = (TpmCryptSetSymKeyCall_t)TpmCryptEncrypt##ALG;\t\t\\\n    break;\n#define DECRYPT_CASE(ALG, alg)\t\t\t\t\t\t\\\n    case TPM_ALG_##ALG:\t\t\t\t\t\t\t\\\n    TpmCryptSetDecryptKey##ALG(key, keySizeInBits, &keySchedule.alg);\t\\\n    decrypt = (TpmCryptSetSymKeyCall_t)TpmCryptDecrypt##ALG;\t\t\\\n    break;\n\n#endif  // CRYPT_SYM_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptSym_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CryptSym_fp.h 1047 2017-07-20 18:27:34Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CRYPTSYM_FP_H\n#define CRYPTSYM_FP_H\n\nBOOL\nCryptSymInit(\n\t     void\n\t     );\nBOOL\nCryptSymStartup(\n\t\tvoid\n\t\t);\nLIB_EXPORT INT16\nCryptGetSymmetricBlockSize(\n\t\t\t   TPM_ALG_ID      symmetricAlg,   // IN: the symmetric algorithm\n\t\t\t   UINT16          keySizeInBits   // IN: the key size\n\t\t\t   );\nLIB_EXPORT TPM_RC\nCryptSymmetricEncrypt(\n\t\t      BYTE                *dOut,          // OUT:\n\t\t      TPM_ALG_ID           algorithm,     // IN: the symmetric algorithm\n\t\t      UINT16               keySizeInBits, // IN: key size in bits\n\t\t      const BYTE          *key,           // IN: key buffer. The size of this buffer\n\t\t      //     in bytes is (keySizeInBits + 7) / 8\n\t\t      TPM2B_IV            *ivInOut,       // IN/OUT: IV for decryption.\n\t\t      TPM_ALG_ID           mode,          // IN: Mode to use\n\t\t      INT32                dSize,         // IN: data size (may need to be a\n\t\t      //     multiple of the blockSize)\n\t\t      const BYTE          *dIn            // IN: data buffer\n\t\t      );\nLIB_EXPORT TPM_RC\nCryptSymmetricDecrypt(\n\t\t      BYTE                *dOut,          // OUT: decrypted data\n\t\t      TPM_ALG_ID           algorithm,     // IN: the symmetric algorithm\n\t\t      UINT16               keySizeInBits, // IN: key size in bits\n\t\t      const BYTE          *key,           // IN: key buffer. The size of this buffer\n\t\t      //     in bytes is (keySizeInBits + 7) / 8\n\t\t      TPM2B_IV            *ivInOut,       // IN/OUT: IV for decryption.\n\t\t      TPM_ALG_ID           mode,          // IN: Mode to use\n\t\t      INT32                dSize,         // IN: data size (may need to be a\n\t\t      //     multiple of the blockSize)\n\t\t      const BYTE          *dIn            // IN: data buffer\n\t\t      );\nTPM_RC\nCryptSymKeyValidate(\n\t\t    TPMT_SYM_DEF_OBJECT *symDef,\n\t\t    TPM2B_SYM_KEY       *key\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptTest.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  constant definitions used for self-test.   \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This file contains constant definitions used for self-test.\n\n#ifndef _CRYPT_TEST_H\n#define _CRYPT_TEST_H\n\n// This is the definition of a bit array with one bit per algorithm.\n// NOTE: Since bit numbering starts at zero, when TPM_ALG_LAST is a multiple of 8,\n// ALGORITHM_VECTOR will need to have byte for the single bit in the last byte. So,\n// for example, when TPM_ALG_LAST is 8, ALGORITHM_VECTOR will need 2 bytes.\n#define ALGORITHM_VECTOR_BYTES ((TPM_ALG_LAST + 8) / 8)\ntypedef BYTE ALGORITHM_VECTOR[ALGORITHM_VECTOR_BYTES];\n\n#ifdef TEST_SELF_TEST\nLIB_EXPORT extern ALGORITHM_VECTOR LibToTest;\n#endif\n\n// This structure is used to contain self-test tracking information for the\n// cryptographic modules. Each of the major modules is given a 32-bit value in\n// which it may maintain its own self test information. The convention for this\n// state is that when all of the bits in this structure are 0, all functions need\n// to be tested.\ntypedef struct\n{\n    UINT32 rng;\n    UINT32 hash;\n    UINT32 sym;\n#if ALG_RSA\n    UINT32 rsa;\n#endif\n#if ALG_ECC\n    UINT32 ecc;\n#endif\n} CRYPTO_SELF_TEST_STATE;\n\n#endif  // _CRYPT_TEST_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/CryptUtil_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Interfaces to the CryptoEngine\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef CRYPTUTIL_FP_H\n#define CRYPTUTIL_FP_H\n\nBOOL\nCryptIsSchemeAnonymous(\n\t\t       TPM_ALG_ID       scheme         // IN: the scheme algorithm to test\n\t\t       );\nvoid\nParmDecryptSym(\n\t       TPM_ALG_ID       symAlg,        // IN: the symmetric algorithm\n\t       TPM_ALG_ID       hash,          // IN: hash algorithm for KDFa\n\t       UINT16           keySizeInBits, // IN: the key size in bits\n\t       TPM2B           *key,           // IN: KDF HMAC key\n\t       TPM2B           *nonceCaller,   // IN: nonce caller\n\t       TPM2B           *nonceTpm,      // IN: nonce TPM\n\t       UINT32           dataSize,      // IN: size of parameter buffer\n\t       BYTE            *data           // OUT: buffer to be decrypted\n\t       );\nvoid\nParmEncryptSym(\n\t       TPM_ALG_ID       symAlg,        // IN: symmetric algorithm\n\t       TPM_ALG_ID       hash,          // IN: hash algorithm for KDFa\n\t       UINT16           keySizeInBits, // IN: AES key size in bits\n\t       TPM2B           *key,           // IN: KDF HMAC key\n\t       TPM2B           *nonceCaller,   // IN: nonce caller\n\t       TPM2B           *nonceTpm,      // IN: nonce TPM\n\t       UINT32           dataSize,      // IN: size of parameter buffer\n\t       BYTE            *data           // OUT: buffer to be encrypted\n\t       );\nvoid\nCryptXORObfuscation(\n\t\t    TPM_ALG_ID       hash,          // IN: hash algorithm for KDF\n\t\t    TPM2B           *key,           // IN: KDF key\n\t\t    TPM2B           *contextU,      // IN: contextU\n\t\t    TPM2B           *contextV,      // IN: contextV\n\t\t    UINT32           dataSize,      // IN: size of data buffer\n\t\t    BYTE            *data           // IN/OUT: data to be XORed in place\n\t\t    );\nBOOL\nCryptInit(\n\t  void\n\t  );\nBOOL\nCryptStartup(\n\t     STARTUP_TYPE     type           // IN: the startup type\n\t     );\nBOOL\nCryptIsAsymAlgorithm(\n\t\t     TPM_ALG_ID       algID          // IN: algorithm ID\n\t\t     );\nTPM_RC\nCryptSecretEncrypt(\n\t\t   OBJECT                  *encryptKey,    // IN: encryption key object\n\t\t   const TPM2B             *label,         // IN: a null-terminated string as L\n\t\t   TPM2B_DATA              *data,          // OUT: secret value\n\t\t   TPM2B_ENCRYPTED_SECRET  *secret         // OUT: secret structure\n\t\t   );\nTPM_RC\nCryptSecretDecrypt(\n\t\t   OBJECT                 *decryptKey,    // IN: decrypt key\n\t\t   TPM2B_NONCE             *nonceCaller,   // IN: nonceCaller.  It is needed for\n\t\t   //     symmetric decryption.  For\n\t\t   //     asymmetric decryption, this\n\t\t   //     parameter is NULL\n\t\t   const TPM2B             *label,         // IN: a value for L\n\t\t   TPM2B_ENCRYPTED_SECRET  *secret,        // IN: input secret\n\t\t   TPM2B_DATA              *data           // OUT: decrypted secret value\n\t\t   );\nvoid\nCryptParameterEncryption(\n\t\t\t TPM_HANDLE       handle,            // IN: encrypt session handle\n\t\t\t TPM2B           *nonceCaller,       // IN: nonce caller\n\t\t\t INT32            bufferSize,        // IN: size of parameter buffer\n\t\t\t UINT16           leadingSizeInByte, // IN: the size of the leading size field in\n\t\t\t //     bytes\n\t\t\t TPM2B_AUTH      *extraKey,          // IN: additional key material other than\n\t\t\t //     sessionAuth\n\t\t\t BYTE            *buffer             // IN/OUT: parameter buffer to be encrypted\n\t\t\t );\nTPM_RC\nCryptParameterDecryption(\n\t\t\t TPM_HANDLE       handle,            // IN: encrypted session handle\n\t\t\t TPM2B           *nonceCaller,       // IN: nonce caller\n\t\t\t INT32            bufferSize,        // IN: size of parameter buffer\n\t\t\t UINT16           leadingSizeInByte, // IN: the size of the leading size field in\n\t\t\t //     byte\n\t\t\t TPM2B_AUTH      *extraKey,          // IN: the authValue\n\t\t\t BYTE            *buffer             // IN/OUT: parameter buffer to be decrypted\n\t\t\t );\nvoid\nCryptComputeSymmetricUnique(\n\t\t\t    TPMT_PUBLIC     *publicArea,    // IN: the object's public area\n\t\t\t    TPMT_SENSITIVE  *sensitive,     // IN: the associated sensitive area\n\t\t\t    TPM2B_DIGEST    *unique         // OUT: unique buffer\n\t\t\t    );\nTPM_RC\nCryptCreateObject(\n\t\t  OBJECT                  *object,            // IN: new object structure pointer\n\t\t  TPMS_SENSITIVE_CREATE   *sensitiveCreate,   // IN: sensitive creation\n\t\t  RAND_STATE              *rand               // IN: the random number generator\n\t\t  //      to use\n\t\t  );\nTPMI_ALG_HASH\nCryptGetSignHashAlg(\n\t\t    TPMT_SIGNATURE  *auth           // IN: signature\n\t\t    );\nBOOL\nCryptIsSplitSign(\n\t\t TPM_ALG_ID       scheme         // IN: the algorithm selector\n\t\t );\nBOOL\nCryptIsAsymSignScheme(\n\t\t      TPMI_ALG_PUBLIC          publicType,        // IN: Type of the object\n\t\t      TPMI_ALG_ASYM_SCHEME     scheme             // IN: the scheme\n\t\t      );\nBOOL\nCryptIsAsymDecryptScheme(\n\t\t\t TPMI_ALG_PUBLIC          publicType,        // IN: Type of the object\n\t\t\t TPMI_ALG_ASYM_SCHEME     scheme             // IN: the scheme\n\t\t\t );\nBOOL\nCryptSelectSignScheme(\n\t\t      OBJECT              *signObject,    // IN: signing key\n\t\t      TPMT_SIG_SCHEME     *scheme         // IN/OUT: signing scheme\n\t\t      );\nTPM_RC\nCryptSign(\n\t  OBJECT              *signKey,       // IN: signing key\n\t  TPMT_SIG_SCHEME     *signScheme,    // IN: sign scheme.\n\t  TPM2B_DIGEST        *digest,        // IN: The digest being signed\n\t  TPMT_SIGNATURE      *signature      // OUT: signature\n\t  );\nTPM_RC\nCryptValidateSignature(\n\t\t       TPMI_DH_OBJECT   keyHandle,     // IN: The handle of sign key\n\t\t       TPM2B_DIGEST    *digest,        // IN: The digest being validated\n\t\t       TPMT_SIGNATURE  *signature      // IN: signature\n\t\t       );\nTPM_RC\nCryptGetTestResult(\n\t\t   TPM2B_MAX_BUFFER    *outData        // OUT: test result data\n\t\t   );\nTPM_RC\nCryptValidateKeys(\n\t\t  TPMT_PUBLIC      *publicArea,\n\t\t  TPMT_SENSITIVE   *sensitive,\n\t\t  TPM_RC            blamePublic,\n\t\t  TPM_RC            blameSensitive\n\t\t  );\nTPM_RC\nCryptSelectMac(\n\t       TPMT_PUBLIC             *publicArea,\n\t       TPMI_ALG_MAC_SCHEME     *inMac\n\t       );\nBOOL\nCryptMacIsValidForKey(\n\t\t      TPM_ALG_ID          keyType,\n\t\t      TPM_ALG_ID          macAlg,\n\t\t      BOOL                flag\n\t\t      );\nBOOL\nCryptSmacIsValidAlg(\n\t\t    TPM_ALG_ID      alg,\n\t\t    BOOL            FLAG        // IN: Indicates if TPM_ALG_NULL is valid\n\t\t    );\nBOOL\nCryptSymModeIsValid(\n\t\t    TPM_ALG_ID          mode,\n\t\t    BOOL                flag\n\t\t    );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/DA_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: DA_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef DA_FP_H\n#define DA_FP_H\n\nvoid\nDAPreInstall_Init(\n\t\t  void\n\t\t  );\nvoid\nDAInit(\n       void\n       );\nBOOL\nDAStartup(\n\t  STARTUP_TYPE     type           // IN: startup type\n\t  );\nvoid\nDARegisterFailure(\n\t\t  TPM_HANDLE       handle         // IN: handle for failure\n\t\t  );\nvoid\nDASelfHeal(\n\t   void\n\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/DebugHelpers_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Debug Helper\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: DebugHelpers_fp.h 1658 2021-01-22 23:14:01Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n#ifndef DEBUGHELPERS_FP_H\n#define DEBUGHELPERS_FP_H\n\nint\nDebugFileInit(\n\t      void\n\t      );\nvoid\nDebugFileClose(\n\t       void\n\t       );\nvoid\nDebugDumpBuffer(\n\t\tint             size,\n\t\tunsigned char   *buf,\n\t\tconst char      *identifier\n\t\t);\n\n\n\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/DictionaryAttackLockReset_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t$Id: DictionaryAttackLockReset_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef DICTIONARYATTACKLOCKRESET_FP_H\n#define DICTIONARYATTACKLOCKRESET_FP_H\n\ntypedef struct {\n    TPMI_RH_LOCKOUT\tlockHandle;\n} DictionaryAttackLockReset_In;\n\n#define RC_DictionaryAttackLockReset_lockHandle\t(TPM_RC_H + TPM_RC_1)\n\nTPM_RC\nTPM2_DictionaryAttackLockReset(\n\t\t\t       DictionaryAttackLockReset_In    *in             // IN: input parameter list\n\t\t\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/DictionaryAttackParameters_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t$Id: DictionaryAttackParameters_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef DICTIONARYATTACKPARAMETERS_FP_H\n#define DICTIONARYATTACKPARAMETERS_FP_H\n\n\ntypedef struct {\n    TPMI_RH_LOCKOUT\tlockHandle;\n    UINT32\t\tnewMaxTries;\n    UINT32\t\tnewRecoveryTime;\n    UINT32\t\tlockoutRecovery;\n} DictionaryAttackParameters_In;\n\n#define RC_DictionaryAttackParameters_lockHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_DictionaryAttackParameters_newMaxTries\t(TPM_RC_P + TPM_RC_1)\n#define RC_DictionaryAttackParameters_newRecoveryTime\t(TPM_RC_P + TPM_RC_2)\n#define RC_DictionaryAttackParameters_lockoutRecovery\t(TPM_RC_P + TPM_RC_3)\n\nTPM_RC\nTPM2_DictionaryAttackParameters(\n\t\t\t\tDictionaryAttackParameters_In   *in             // IN: input parameter list\n\t\t\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Duplicate_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Duplicate_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef DUPLICATE_FP_H\n#define DUPLICATE_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tobjectHandle;\n    TPMI_DH_OBJECT\t\tnewParentHandle;\n    TPM2B_DATA\t\t\tencryptionKeyIn;\n    TPMT_SYM_DEF_OBJECT\t\tsymmetricAlg;\n} Duplicate_In;\n\ntypedef struct {\n    TPM2B_DATA\t\t\tencryptionKeyOut;\n    TPM2B_PRIVATE\t\tduplicate;\n    TPM2B_ENCRYPTED_SECRET\toutSymSeed;\n} Duplicate_Out;\n\n#define RC_Duplicate_objectHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_Duplicate_newParentHandle \t(TPM_RC_H + TPM_RC_2)\n#define RC_Duplicate_encryptionKeyIn \t(TPM_RC_P + TPM_RC_1)\n#define RC_Duplicate_symmetricAlg \t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_Duplicate(\n\t       Duplicate_In    *in,            // IN: input parameter list\n\t       Duplicate_Out   *out            // OUT: output parameter list\n\t       );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ECC_Decrypt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id$\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2022\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n\n#ifndef ECC_Decrypt_FP_H\n#define ECC_Decrypt_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tkeyHandle;\n    TPM2B_ECC_POINT\tC1;\n    TPM2B_MAX_BUFFER\tC2;\n    TPM2B_DIGEST\tC3;\n    TPMT_KDF_SCHEME\tinScheme;\n} ECC_Decrypt_In;\n\n#define RC_ECC_Decrypt_keyHandle (TPM_RC_H + TPM_RC_1)\n#define RC_ECC_Decrypt_C1\t (TPM_RC_P + TPM_RC_1)\n#define RC_ECC_Decrypt_C2\t (TPM_RC_P + TPM_RC_2)\n#define RC_ECC_Decrypt_C3\t (TPM_RC_P + TPM_RC_3)\n#define RC_ECC_Decrypt_inScheme  (TPM_RC_P + TPM_RC_4)\n\ntypedef struct {\n    TPM2B_MAX_BUFFER\tplainText;\n} ECC_Decrypt_Out;\n\nTPM_RC\nTPM2_ECC_Decrypt(\n\t\t ECC_Decrypt_In      *in,            // IN: input parameter list\n\t\t ECC_Decrypt_Out     *out            // OUT: output parameter list\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ECC_Encrypt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id$\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2022\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef ECC_ENCRYPT_FP_H\n#define ECC_ENCRYPT_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tkeyHandle;\n    TPM2B_MAX_BUFFER\tplainText;\n    TPMT_KDF_SCHEME\tinScheme;\n} ECC_Encrypt_In;\n\n#define RC_ECC_Encrypt_keyHandle (TPM_RC_H + TPM_RC_1)\n#define RC_ECC_Encrypt_plainText (TPM_RC_P + TPM_RC_1)\n#define RC_ECC_Encrypt_inScheme  (TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM2B_ECC_POINT\tC1;\n    TPM2B_MAX_BUFFER\tC2;\n    TPM2B_DIGEST\tC3;\n} ECC_Encrypt_Out;\n\nTPM_RC\nTPM2_ECC_Encrypt(\n\t\t ECC_Encrypt_In      *in,            // IN: input parameter list\n\t\t ECC_Encrypt_Out     *out            // OUT: output parameter list\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ECC_Parameters_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ECC_Parameters_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef ECC_PARAMETERS_FP_H\n#define ECC_PARAMETERS_FP_H\n\ntypedef struct {\n    TPMI_ECC_CURVE\tcurveID;\n} ECC_Parameters_In;\n\n#define RC_ECC_Parameters_curveID \t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPMS_ALGORITHM_DETAIL_ECC\tparameters;\n} ECC_Parameters_Out;\n\nTPM_RC\nTPM2_ECC_Parameters(\n\t\t    ECC_Parameters_In   *in,            // IN: input parameter list\n\t\t    ECC_Parameters_Out  *out            // OUT: output parameter list\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ECDH_KeyGen_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ECDH_KeyGen_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef ECDH_KEYGEN_FP_H\n#define ECDH_KEYGEN_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tkeyHandle;\n} ECDH_KeyGen_In;\n\n#define RC_ECDH_KeyGen_keyHandle \t(TPM_RC_H + TPM_RC_1)\n\ntypedef struct {\n    TPM2B_ECC_POINT\tzPoint;\n    TPM2B_ECC_POINT\tpubPoint;\n} ECDH_KeyGen_Out;\n\nTPM_RC\nTPM2_ECDH_KeyGen(\n\t\t ECDH_KeyGen_In      *in,            // IN: input parameter list\n\t\t ECDH_KeyGen_Out     *out            // OUT: output parameter list\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ECDH_ZGen_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ECDH_ZGen_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef ECDH_ZGEN_FP_H\n#define ECDH_ZGEN_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tkeyHandle;\n    TPM2B_ECC_POINT\tinPoint;\n} ECDH_ZGen_In;\n\n#define RC_ECDH_ZGen_keyHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_ECDH_ZGen_inPoint \t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPM2B_ECC_POINT\toutPoint;\n} ECDH_ZGen_Out;\n\nTPM_RC\nTPM2_ECDH_ZGen(\n\t       ECDH_ZGen_In    *in,            // IN: input parameter list\n\t       ECDH_ZGen_Out   *out            // OUT: output parameter list\n\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/EC_Ephemeral_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: EC_Ephemeral_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef EC_EPHEMERAL_FP_H\n#define EC_EPHEMERAL_FP_H\n\ntypedef struct {\n    TPMI_ECC_CURVE\tcurveID;\n} EC_Ephemeral_In;\n\n#define RC_EC_Ephemeral_curveID\t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPM2B_ECC_POINT\tQ;\n    UINT16\t\tcounter;\n} EC_Ephemeral_Out;\n\nTPM_RC\nTPM2_EC_Ephemeral(\n\t\t  EC_Ephemeral_In     *in,            // IN: input parameter list\n\t\t  EC_Ephemeral_Out    *out            // OUT: output parameter list\n\t\t  );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/EccTestData.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Parameter data for ECC testing   \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: EccTestData.h 1259 2018-07-10 19:11:09Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifdef  SELF_TEST_DATA\nTPM2B_TYPE(EC_TEST, 32);\nconst  TPM_ECC_CURVE        c_testCurve = 00003;\n// The static key\nconst  TPM2B_EC_TEST    c_ecTestKey_ds = {{32, {\n\t    0xdf,0x8d,0xa4,0xa3,0x88,0xf6,0x76,0x96,0x89,0xfc,0x2f,0x2d,0xa1,0xb4,0x39,0x7a,\n\t    0x78,0xc4,0x7f,0x71,0x8c,0xa6,0x91,0x85,0xc0,0xbf,0xf3,0x54,0x20,0x91,0x2f,0x73}}};\nconst  TPM2B_EC_TEST    c_ecTestKey_QsX = {{32, {\n\t    0x17,0xad,0x2f,0xcb,0x18,0xd4,0xdb,0x3f,0x2c,0x53,0x13,0x82,0x42,0x97,0xff,0x8d,\n\t    0x99,0x50,0x16,0x02,0x35,0xa7,0x06,0xae,0x1f,0xda,0xe2,0x9c,0x12,0x77,0xc0,0xf9}}};\nconst  TPM2B_EC_TEST    c_ecTestKey_QsY = {{32, {\n\t    0xa6,0xca,0xf2,0x18,0x45,0x96,0x6e,0x58,0xe6,0x72,0x34,0x12,0x89,0xcd,0xaa,0xad,\n\t    0xcb,0x68,0xb2,0x51,0xdc,0x5e,0xd1,0x6d,0x38,0x20,0x35,0x57,0xb2,0xfd,0xc7,0x52}}};\n// The ephemeral key\nconst  TPM2B_EC_TEST    c_ecTestKey_de = {{32, {\n\t    0xb6,0xb5,0x33,0x5c,0xd1,0xee,0x52,0x07,0x99,0xea,0x2e,0x8f,0x8b,0x19,0x18,0x07,\n\t    0xc1,0xf8,0xdf,0xdd,0xb8,0x77,0x00,0xc7,0xd6,0x53,0x21,0xed,0x02,0x53,0xee,0xac}}};\nconst  TPM2B_EC_TEST    c_ecTestKey_QeX = {{32, {\n\t    0xa5,0x1e,0x80,0xd1,0x76,0x3e,0x8b,0x96,0xce,0xcc,0x21,0x82,0xc9,0xa2,0xa2,0xed,\n\t    0x47,0x21,0x89,0x53,0x44,0xe9,0xc7,0x92,0xe7,0x31,0x48,0x38,0xe6,0xea,0x93,0x47}}};\nconst  TPM2B_EC_TEST    c_ecTestKey_QeY = {{32, {\n\t    0x30,0xe6,0x4f,0x97,0x03,0xa1,0xcb,0x3b,0x32,0x2a,0x70,0x39,0x94,0xeb,0x4e,0xea,\n\t    0x55,0x88,0x81,0x3f,0xb5,0x00,0xb8,0x54,0x25,0xab,0xd4,0xda,0xfd,0x53,0x7a,0x18}}};\n// ECDH test results\nconst  TPM2B_EC_TEST    c_ecTestEcdh_X = {{32, {\n\t    0x64,0x02,0x68,0x92,0x78,0xdb,0x33,0x52,0xed,0x3b,0xfa,0x3b,0x74,0xa3,0x3d,0x2c,\n\t    0x2f,0x9c,0x59,0x03,0x07,0xf8,0x22,0x90,0xed,0xe3,0x45,0xf8,0x2a,0x0a,0xd8,0x1d}}};\nconst  TPM2B_EC_TEST    c_ecTestEcdh_Y = {{32, {\n\t    0x58,0x94,0x05,0x82,0xbe,0x5f,0x33,0x02,0x25,0x90,0x3a,0x33,0x90,0x89,0xe3,0xe5,\n\t    0x10,0x4a,0xbc,0x78,0xa5,0xc5,0x07,0x64,0xaf,0x91,0xbc,0xe6,0xff,0x85,0x11,0x40}}};\nTPM2B_TYPE(TEST_VALUE, 64);\nconst TPM2B_TEST_VALUE        c_ecTestValue = {{64, {\n\t    0x78,0xd5,0xd4,0x56,0x43,0x61,0xdb,0x97,0xa4,0x32,0xc4,0x0b,0x06,0xa9,0xa8,0xa0,\n\t    0xf4,0x45,0x7f,0x13,0xd8,0x13,0x81,0x0b,0xe5,0x76,0xbe,0xaa,0xb6,0x3f,0x8d,0x4d,\n\t    0x23,0x65,0xcc,0xa7,0xc9,0x19,0x10,0xce,0x69,0xcb,0x0c,0xc7,0x11,0x8d,0xc3,0xff,\n\t    0x62,0x69,0xa2,0xbe,0x46,0x90,0xe7,0x7d,0x81,0x77,0x94,0x65,0x1c,0x3e,0xc1,0x3e}}};\n#if ALG_SHA1_VALUE == DEFAULT_TEST_HASH\nconst TPM2B_EC_TEST    c_TestEcDsa_r = {{32, {\n\t    0x57,0xf3,0x36,0xb7,0xec,0xc2,0xdd,0x76,0x0e,0xe2,0x81,0x21,0x49,0xc5,0x66,0x11,\n\t    0x4b,0x8a,0x4f,0x17,0x62,0x82,0xcc,0x06,0xf6,0x64,0x78,0xef,0x6b,0x7c,0xf2,0x6c}}};\nconst TPM2B_EC_TEST    c_TestEcDsa_s = {{32, {\n\t    0x1b,0xed,0x23,0x72,0x8f,0x17,0x5f,0x47,0x2e,0xa7,0x97,0x2c,0x51,0x57,0x20,0x70,\n\t    0x6f,0x89,0x74,0x8a,0xa8,0xf4,0x26,0xf4,0x96,0xa1,0xb8,0x3e,0xe5,0x35,0xc5,0x94}}};\nconst TPM2B_EC_TEST    c_TestEcSchnorr_r = {{32,{\n\t    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x08,0x9f,0xde,\n\t    0xef,0x62,0xe3,0xf1,0x14,0xcb,0x54,0x28,0x13,0x76,0xfc,0x6d,0x69,0x22,0xb5,0x3e}}};\nconst TPM2B_EC_TEST    c_TestEcSchnorr_s = {{32,{\n\t    0xd9,0xd3,0x20,0xfb,0x4d,0x16,0xf2,0xe6,0xe2,0x45,0x07,0x45,0x1c,0x92,0x92,0x92,\n\t    0xa9,0x6b,0x48,0xf8,0xd1,0x98,0x29,0x4d,0xd3,0x8f,0x56,0xf2,0xbb,0x2e,0x22,0x3b}}};\n#endif // SHA1\n#if ALG_SHA256_VALUE == DEFAULT_TEST_HASH\nconst TPM2B_EC_TEST    c_TestEcDsa_r = {{32, {\n\t    0x04,0x7d,0x54,0xeb,0x04,0x6f,0x56,0xec,0xa2,0x6c,0x38,0x8c,0xeb,0x43,0x0b,0x71,\n\t    0xf8,0xf2,0xf4,0xa5,0xe0,0x1d,0x3c,0xa2,0x39,0x31,0xe4,0xe7,0x36,0x3b,0xb5,0x5f}}};\nconst TPM2B_EC_TEST    c_TestEcDsa_s = {{32, {\n\t    0x8f,0xd0,0x12,0xd9,0x24,0x75,0xf6,0xc4,0x3b,0xb5,0x46,0x75,0x3a,0x41,0x8d,0x80,\n\t    0x23,0x99,0x38,0xd7,0xe2,0x40,0xca,0x9a,0x19,0x2a,0xfc,0x54,0x75,0xd3,0x4a,0x6e}}};\nconst TPM2B_EC_TEST    c_TestEcSchnorr_r = {{32, {\n\t    0xf7,0xb9,0x15,0x4c,0x34,0xf6,0x41,0x19,0xa3,0xd2,0xf1,0xbd,0xf4,0x13,0x6a,0x4f,\n\t    0x63,0xb8,0x4d,0xb5,0xc8,0xcd,0xde,0x85,0x95,0xa5,0x39,0x0a,0x14,0x49,0x3d,0x2f}}};\nconst TPM2B_EC_TEST    c_TestEcSchnorr_s = {{32,{\n\t    0xfe,0xbe,0x17,0xaa,0x31,0x22,0x9f,0xd0,0xd2,0xf5,0x25,0x04,0x92,0xb0,0xaa,0x4e,\n\t    0xcc,0x1c,0xb6,0x79,0xd6,0x42,0xb3,0x4e,0x3f,0xbb,0xfe,0x5f,0xd0,0xd0,0x8b,0xc3}}};\n#endif // SHA256\n#if ALG_SHA384_VALUE == DEFAULT_TEST_HASH\nconst TPM2B_EC_TEST    c_TestEcDsa_r = {{32, {\n\t    0xf5,0x74,0x6d,0xd6,0xc6,0x56,0x86,0xbb,0xba,0x1c,0xba,0x75,0x65,0xee,0x64,0x31,\n\t    0xce,0x04,0xe3,0x9f,0x24,0x3f,0xbd,0xfe,0x04,0xcd,0xab,0x7e,0xfe,0xad,0xcb,0x82}}};\nconst TPM2B_EC_TEST    c_TestEcDsa_s = {{32, {\n\t    0xc2,0x4f,0x32,0xa1,0x06,0xc0,0x85,0x4f,0xc6,0xd8,0x31,0x66,0x91,0x9f,0x79,0xcd,\n\t    0x5b,0xe5,0x7b,0x94,0xa1,0x91,0x38,0xac,0xd4,0x20,0xa2,0x10,0xf0,0xd5,0x9d,0xbf}}};\nconst TPM2B_EC_TEST    c_TestEcSchnorr_r = {{32, {\n\t    0x1e,0xb8,0xe1,0xbf,0xa1,0x9e,0x39,0x1e,0x58,0xa2,0xe6,0x59,0xd0,0x1a,0x6a,0x03,\n\t    0x6a,0x1f,0x1c,0x4f,0x36,0x19,0xc1,0xec,0x30,0xa4,0x85,0x1b,0xe9,0x74,0x35,0x66}}};\nconst TPM2B_EC_TEST    c_TestEcSchnorr_s = {{32,{\n\t    0xb9,0xe6,0xe3,0x7e,0xcb,0xb9,0xea,0xf1,0xcc,0xf4,0x48,0x44,0x4a,0xda,0xc8,0xd7,\n\t    0x87,0xb4,0xba,0x40,0xfe,0x5b,0x68,0x11,0x14,0xcf,0xa0,0x0e,0x85,0x46,0x99,0x01}}};\n#endif // SHA384\n#if ALG_SHA512_VALUE == DEFAULT_TEST_HASH\nconst TPM2B_EC_TEST    c_TestEcDsa_r = {{32, {\n\t    0xc9,0x71,0xa6,0xb4,0xaf,0x46,0x26,0x8c,0x27,0x00,0x06,0x3b,0x00,0x0f,0xa3,0x17,\n\t    0x72,0x48,0x40,0x49,0x4d,0x51,0x4f,0xa4,0xcb,0x7e,0x86,0xe9,0xe7,0xb4,0x79,0xb2}}};\nconst TPM2B_EC_TEST    c_TestEcDsa_s = {{32,{\n\t    0x87,0xbc,0xc0,0xed,0x74,0x60,0x9e,0xfa,0x4e,0xe8,0x16,0xf3,0xf9,0x6b,0x26,0x07,\n\t    0x3c,0x74,0x31,0x7e,0xf0,0x62,0x46,0xdc,0xd6,0x45,0x22,0x47,0x3e,0x0c,0xa0,0x02}}};\nconst TPM2B_EC_TEST    c_TestEcSchnorr_r = {{32,{\n\t    0xcc,0x07,0xad,0x65,0x91,0xdd,0xa0,0x10,0x23,0xae,0x53,0xec,0xdf,0xf1,0x50,0x90,\n\t    0x16,0x96,0xf4,0x45,0x09,0x73,0x9c,0x84,0xb5,0x5c,0x5f,0x08,0x51,0xcb,0x60,0x01}}};\nconst TPM2B_EC_TEST    c_TestEcSchnorr_s = {{32,{\n\t    0x55,0x20,0x21,0x54,0xe2,0x49,0x07,0x47,0x71,0xf4,0x99,0x15,0x54,0xf3,0xab,0x14,\n\t    0xdb,0x8e,0xda,0x79,0xb6,0x02,0x0e,0xe3,0x5e,0x6f,0x2c,0xb6,0x05,0xbd,0x14,0x10}}};\n#endif // SHA512\n#endif // SELF_TEST_DATA\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/EncryptDecrypt2_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: EncryptDecrypt2_fp.h 1047 2017-07-20 18:27:34Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015, 2016\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 146 */\n\n#ifndef ENCRYPTDECRYPT2_FP_H\n#define ENCRYPTDECRYPT2_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tkeyHandle;\n    TPM2B_MAX_BUFFER\t\tinData;\n    TPMI_YES_NO\t\t\tdecrypt;\n    TPMI_ALG_CIPHER_MODE\tmode;\n    TPM2B_IV\t\t\tivIn;\n} EncryptDecrypt2_In;\n\n#define RC_EncryptDecrypt2_keyHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_EncryptDecrypt2_inData \t(TPM_RC_P + TPM_RC_1)\n#define RC_EncryptDecrypt2_decrypt\t(TPM_RC_P + TPM_RC_2)\n#define RC_EncryptDecrypt2_mode\t\t(TPM_RC_P + TPM_RC_3)\n#define RC_EncryptDecrypt2_ivIn\t\t(TPM_RC_P + TPM_RC_4)\n\ntypedef struct {\n    TPM2B_MAX_BUFFER\toutData;\n    TPM2B_IV\t\tivOut;\n} EncryptDecrypt2_Out;\n\nTPM_RC\nTPM2_EncryptDecrypt2(\n\t\t     EncryptDecrypt2_In   *in,            // IN: input parameter list\n\t\t     EncryptDecrypt2_Out  *out            // OUT: output parameter list\n\t\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/EncryptDecrypt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: EncryptDecrypt_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef ENCRYPTDECRYPT_FP_H\n#define ENCRYPTDECRYPT_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tkeyHandle;\n    TPMI_YES_NO\t\t\tdecrypt;\n    TPMI_ALG_CIPHER_MODE\tmode;\n    TPM2B_IV\t\t\tivIn;\n    TPM2B_MAX_BUFFER\t\tinData;\n} EncryptDecrypt_In;\n\n#define RC_EncryptDecrypt_keyHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_EncryptDecrypt_decrypt\t(TPM_RC_P + TPM_RC_1)\n#define RC_EncryptDecrypt_mode \t\t(TPM_RC_P + TPM_RC_2)\n#define RC_EncryptDecrypt_ivIn \t\t(TPM_RC_P + TPM_RC_3)\n#define RC_EncryptDecrypt_inData \t(TPM_RC_P + TPM_RC_4)\n\ntypedef struct {\n    TPM2B_MAX_BUFFER\toutData;\n    TPM2B_IV\t\tivOut;\n} EncryptDecrypt_Out;\n\nTPM_RC\nTPM2_EncryptDecrypt(\n\t\t    EncryptDecrypt_In   *in,            // IN: input parameter list\n\t\t    EncryptDecrypt_Out  *out            // OUT: output parameter list\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/EncryptDecrypt_spt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: EncryptDecrypt_spt_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef ENCRYPTDECRYPT_SPT_FP_H\n#define ENCRYPTDECRYPT_SPT_FP_H\n\nTPM_RC\nEncryptDecryptShared(\n\t\t     TPMI_DH_OBJECT        keyHandleIn,\n\t\t     TPMI_YES_NO           decryptIn,\n\t\t     TPMI_ALG_SYM_MODE     modeIn,\n\t\t     TPM2B_IV              *ivIn,\n\t\t     TPM2B_MAX_BUFFER      *inData,\n\t\t     EncryptDecrypt_Out    *out\n\t\t     );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Entity_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Entity_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef ENTITY_FP_H\n#define ENTITY_FP_H\n\nTPM_RC\nEntityGetLoadStatus(\n\t\t    COMMAND         *command        // IN/OUT: command parsing structure\n\t\t    );\nUINT16\nEntityGetAuthValue(\n\t\t   TPMI_DH_ENTITY   handle,        // IN: handle of entity\n\t\t   TPM2B_AUTH      *auth           // OUT: authValue of the entity\n\t\t   );\nTPMI_ALG_HASH\nEntityGetAuthPolicy(\n\t\t    TPMI_DH_ENTITY   handle,        // IN: handle of entity\n\t\t    TPM2B_DIGEST    *authPolicy     // OUT: authPolicy of the entity\n\t\t    );\nTPM2B_NAME *\nEntityGetName(\n\t      TPMI_DH_ENTITY   handle,        // IN: handle of entity\n\t      TPM2B_NAME      *name           // OUT: name of entity\n\t      );\nTPMI_RH_HIERARCHY\nEntityGetHierarchy(\n\t\t   TPMI_DH_ENTITY   handle         // IN :handle of entity\n\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/EventSequenceComplete_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t$Id: EventSequenceComplete_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef EVENTSEQUENCECOMPLETE_FP_H\n#define EVENTSEQUENCECOMPLETE_FP_H\n\ntypedef struct {\n    TPMI_DH_PCR\t\tpcrHandle;\n    TPMI_DH_OBJECT\tsequenceHandle;\n    TPM2B_MAX_BUFFER\tbuffer;\n} EventSequenceComplete_In;\n\n#define RC_EventSequenceComplete_pcrHandle\t\t(TPM_RC_H + TPM_RC_1)\n#define RC_EventSequenceComplete_sequenceHandle \t(TPM_RC_H + TPM_RC_2)\n#define RC_EventSequenceComplete_buffer\t\t\t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPML_DIGEST_VALUES\tresults;\n} EventSequenceComplete_Out;\n\nTPM_RC\nTPM2_EventSequenceComplete(\n\t\t\t   EventSequenceComplete_In    *in,            // IN: input parameter list\n\t\t\t   EventSequenceComplete_Out   *out            // OUT: output parameter list\n\t\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/EvictControl_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: EvictControl_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef EVICTCONTROL_FP_H\n#define EVICTCONTROL_FP_H\n\ntypedef struct {\n    TPMI_RH_PROVISION\tauth;\n    TPMI_DH_OBJECT\tobjectHandle;\n    TPMI_DH_PERSISTENT\tpersistentHandle;\n} EvictControl_In;\n\n#define RC_EvictControl_auth\t\t\t(TPM_RC_H + TPM_RC_1)\n#define RC_EvictControl_objectHandle \t\t(TPM_RC_H + TPM_RC_2)\n#define RC_EvictControl_persistentHandle \t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_EvictControl(\n\t\t  EvictControl_In     *in             // IN: input parameter list\n\t\t  );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ExecCommand_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ExecCommand_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef EXECCOMMAND_FP_H\n#define EXECCOMMAND_FP_H\n\nLIB_EXPORT void\nExecuteCommand(\n\t       uint32_t         requestSize,   // IN: command buffer size\n\t       unsigned char   *request,       // IN: command buffer\n\t       uint32_t        *responseSize,  // IN/OUT: response buffer size\n\t       unsigned char   **response      // IN/OUT: response buffer\n\t       );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/FlushContext_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: FlushContext_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef FLUSHCONTEXT_FP_H\n#define FLUSHCONTEXT_FP_H\n\ntypedef struct {\n    TPMI_DH_CONTEXT\tflushHandle;\n} FlushContext_In;\n\n#define RC_FlushContext_flushHandle\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_FlushContext(\n\t\t  FlushContext_In     *in             // IN: input parameter list\n\t\t  );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/GetCapability_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: GetCapability_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef GETCAPABILITY_FP_H\n#define GETCAPABILITY_FP_H\n\ntypedef struct {\n    TPM_CAP\tcapability;\n    UINT32\tproperty;\n    UINT32\tpropertyCount;\n} GetCapability_In;\n\n#define RC_GetCapability_capability\t(TPM_RC_P + TPM_RC_1)\n#define RC_GetCapability_property \t(TPM_RC_P + TPM_RC_2)\n#define RC_GetCapability_propertyCount\t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPMI_YES_NO\t\t\tmoreData;\n    TPMS_CAPABILITY_DATA\tcapabilityData;\n} GetCapability_Out;\n\n\nTPM_RC\nTPM2_GetCapability(\n\t\t   GetCapability_In    *in,            // IN: input parameter list\n\t\t   GetCapability_Out   *out            // OUT: output parameter list\n\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/GetCommandAuditDigest_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t$Id: GetCommandAuditDigest_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef GETCOMMANDAUDITDIGEST_FP_H\n#define GETCOMMANDAUDITDIGEST_FP_H\n\ntypedef struct {\n    TPMI_RH_ENDORSEMENT\tprivacyHandle;\n    TPMI_DH_OBJECT\tsignHandle;\n    TPM2B_DATA\t\tqualifyingData;\n    TPMT_SIG_SCHEME\tinScheme;\n} GetCommandAuditDigest_In;\n\n#define RC_GetCommandAuditDigest_privacyHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_GetCommandAuditDigest_signHandle \t(TPM_RC_H + TPM_RC_2)\n#define RC_GetCommandAuditDigest_qualifyingData\t(TPM_RC_P + TPM_RC_1)\n#define RC_GetCommandAuditDigest_inScheme \t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM2B_ATTEST\tauditInfo;\n    TPMT_SIGNATURE\tsignature;\n} GetCommandAuditDigest_Out;\n\nTPM_RC\nTPM2_GetCommandAuditDigest(\n\t\t\t   GetCommandAuditDigest_In    *in,            // IN: input parameter list\n\t\t\t   GetCommandAuditDigest_Out   *out            // OUT: output parameter list\n\t\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/GetRandom_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: GetRandom_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef GETRANDOM_FP_H\n#define GETRANDOM_FP_H\n\ntypedef struct {\n    UINT16\tbytesRequested;\n} GetRandom_In;\n\n#define RC_GetRandom_bytesRequested\t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPM2B_DIGEST\trandomBytes;\n} GetRandom_Out;\n\nTPM_RC\nTPM2_GetRandom(\n\t       GetRandom_In    *in,            // IN: input parameter list\n\t       GetRandom_Out   *out            // OUT: output parameter list\n\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/GetSessionAuditDigest_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t$Id: GetSessionAuditDigest_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef GETSESSIONAUDITDIGEST_FP_H\n#define GETSESSIONAUDITDIGEST_FP_H\n\ntypedef struct {\n    TPMI_RH_ENDORSEMENT\t\tprivacyAdminHandle;\n    TPMI_DH_OBJECT\t\tsignHandle;\n    TPMI_SH_HMAC\t\tsessionHandle;\n    TPM2B_DATA\t\t\tqualifyingData;\n    TPMT_SIG_SCHEME\t\tinScheme;\n} GetSessionAuditDigest_In;\n\n#define RC_GetSessionAuditDigest_privacyAdminHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_GetSessionAuditDigest_signHandle\t\t(TPM_RC_H + TPM_RC_2)\n#define RC_GetSessionAuditDigest_sessionHandle\t\t(TPM_RC_H + TPM_RC_3)\n#define RC_GetSessionAuditDigest_qualifyingData\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_GetSessionAuditDigest_inScheme\t\t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM2B_ATTEST\tauditInfo;\n    TPMT_SIGNATURE\tsignature;\n} GetSessionAuditDigest_Out;\n\nTPM_RC\nTPM2_GetSessionAuditDigest(\n\t\t\t   GetSessionAuditDigest_In    *in,            // IN: input parameter list\n\t\t\t   GetSessionAuditDigest_Out   *out            // OUT: output parameter list\n\t\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/GetTestResult_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: GetTestResult_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2016\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef GETTESTRESULT_FP_H\n#define GETTESTRESULT_FP_H\n\ntypedef struct{\n    TPM2B_MAX_BUFFER\toutData;\n    TPM_RC\t\ttestResult;\n} GetTestResult_Out;\n\n\n    TPM_RC\nTPM2_GetTestResult(\n\t\t   GetTestResult_Out   *out            // OUT: output parameter list\n\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/GetTime_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: GetTime_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef GETTIME_FP_H\n#define GETTIME_FP_H\n\ntypedef struct {\n    TPMI_RH_ENDORSEMENT\tprivacyAdminHandle;\n    TPMI_DH_OBJECT\tsignHandle;\n    TPM2B_DATA\t\tqualifyingData;\n    TPMT_SIG_SCHEME\tinScheme;\n} GetTime_In;\n\n#define RC_GetTime_privacyAdminHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_GetTime_signHandle \t\t(TPM_RC_H + TPM_RC_2)\n#define RC_GetTime_qualifyingData\t(TPM_RC_P + TPM_RC_1)\n#define RC_GetTime_inScheme \t\t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM2B_ATTEST\ttimeInfo;\n    TPMT_SIGNATURE\tsignature;\n} GetTime_Out;\n\nTPM_RC\nTPM2_GetTime(\n\t     GetTime_In      *in,            // IN: input parameter list\n\t     GetTime_Out     *out            // OUT: output parameter list\n\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Global.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tInternal Global Type Definitions\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n\n// This file contains internal global type definitions and data declarations that\n// are need between subsystems. The instantiation of global data is in Global.c.\n// The initialization of global data is in the subsystem that is the primary owner\n// of the data.\n//\n// The first part of this file has the 'typedefs' for structures and other defines\n// used in many portions of the code. After the 'typedef' section, is a section that\n// defines global values that are only present in RAM. The next three sections\n// define the structures for the NV data areas: persistent, orderly, and state\n// save. Additional sections define the data that is used in specific modules. That\n// data is private to the module but is collected here to simplify the management\n// of the instance data.\n//\n// All the data is instanced in Global.c.\n#if !defined _TPM_H_\n#  error \"Should only be instanced in TPM.h\"\n#endif\n\n//** Includes\n\n#ifndef GLOBAL_H\n#  define GLOBAL_H\n\n_REDUCE_WARNING_LEVEL_(2)\n#  include <string.h>\n#  include <stddef.h>\n_NORMAL_WARNING_LEVEL_\n\n#  include \"GpMacros.h\"\n#  include \"Capabilities.h\"\n#  include \"TpmTypes.h\"  // requires GpMacros & Capabilities\n#  include \"CommandAttributes.h\"\n#  include \"CryptTest.h\"\n\n#  ifndef MATH_LIB\n#    error MATH_LIB required\n#  endif\n#  include LIB_INCLUDE(TpmTo, MATH_LIB, Math)\n\n#  include \"CryptHash.h\"\n#  include \"CryptSym.h\"\n#  include \"CryptRand.h\"\n#  include \"CryptEcc.h\"\n#  include \"CryptRsa.h\"\n#  include \"CryptTest.h\"\n#  include \"NV.h\"\n#  include \"ACT.h\"\n\n//** Defines and Types\n\n//*** Other Types\n// An AUTH_VALUE is a BYTE array containing a digest (TPMU_HA)\ntypedef BYTE AUTH_VALUE[sizeof(TPMU_HA)];\n\n// A TIME_INFO is a BYTE array that can contain a TPMS_TIME_INFO\ntypedef BYTE TIME_INFO[sizeof(TPMS_TIME_INFO)];\n\n// A NAME is a BYTE array that can contain a TPMU_NAME\ntypedef BYTE NAME[sizeof(TPMU_NAME)];\n\n// Definition for a PROOF value\nTPM2B_TYPE(PROOF, PROOF_SIZE);\n\n// Definition for a Primary Seed value\nTPM2B_TYPE(SEED, PRIMARY_SEED_SIZE);\n\n// A CLOCK_NONCE is used to tag the time value in the authorization session and\n// in the ticket computation so that the ticket expires when there is a time\n// discontinuity. When the clock stops during normal operation, the nonce is\n// 64-bit value kept in RAM but it is a 32-bit counter when the clock only stops\n// during power events.\n#  if CLOCK_STOPS\ntypedef UINT64 CLOCK_NONCE;\n#  else\ntypedef UINT32 CLOCK_NONCE;\n#  endif\n\n//** Loaded Object Structures\n//*** Description\n// The structures in this section define the object layout as it exists in TPM\n// memory.\n//\n// Two types of objects are defined: an ordinary object such as a key, and a\n// sequence object that may be a hash, HMAC, or event.\n//\n//*** OBJECT_ATTRIBUTES\n// An OBJECT_ATTRIBUTES structure contains the variable attributes of an object.\n// These properties are not part of the public properties but are used by the\n// TPM in managing the object. An OBJECT_ATTRIBUTES is used in the definition of\n// the OBJECT data type.\n\ntypedef struct\n{\n    unsigned publicOnly : 1;    //0) SET if only the public portion of\n    //   an object is loaded\n    unsigned epsHierarchy : 1;  //1) SET if the object belongs to EPS\n    //   Hierarchy\n    unsigned ppsHierarchy : 1;  //2) SET if the object belongs to PPS\n    //   Hierarchy\n    unsigned spsHierarchy : 1;  //3) SET f the object belongs to SPS\n    //   Hierarchy\n    unsigned evict : 1;         //4) SET if the object is a platform or\n    //   owner evict object.  Platform-\n    //   evict object belongs to PPS\n    //   hierarchy, owner-evict object\n    //   belongs to SPS or EPS hierarchy.\n    //   This bit is also used to mark a\n    //   completed sequence object so it\n    //   will be flush when the\n    //   SequenceComplete command succeeds.\n    unsigned primary   : 1;     //5) SET for a primary object\n    unsigned temporary : 1;     //6) SET for a temporary object\n    unsigned stClear   : 1;     //7) SET for an stClear object\n    unsigned hmacSeq   : 1;     //8) SET for an HMAC or MAC sequence\n    //   object\n    unsigned hashSeq    : 1;    //9) SET for a hash sequence object\n    unsigned eventSeq   : 1;    //10) SET for an event sequence object\n    unsigned ticketSafe : 1;    //11) SET if a ticket is safe to create\n    //    for hash sequence object\n    unsigned firstBlock : 1;    //12) SET if the first block of hash\n    //    data has been received.  It\n    //    works with ticketSafe bit\n    unsigned isParent : 1;      //13) SET if the key has the proper\n    //    attributes to be a parent key\n    //   unsigned            privateExp : 1;    //14) SET when the private exponent\n    //                                          //    of an RSA key has been validated.\n    unsigned not_used_14 : 1;\n    unsigned occupied    : 1;  //15) SET when the slot is occupied.\n    unsigned derivation  : 1;  //16) SET when the key is a derivation\n    //        parent\n    unsigned external : 1;     //17) SET when the object is loaded with\n    //    TPM2_LoadExternal();\n} OBJECT_ATTRIBUTES;\n\n#  if ALG_RSA\n// There is an overload of the sensitive.rsa.t.size field of a TPMT_SENSITIVE when an\n// RSA key is loaded. When the sensitive->sensitive contains an RSA key with all of\n// the CRT values, then the MSB of the size field will be set to indicate that the\n// buffer contains all 5 of the CRT private key values.\n#    define RSA_prime_flag 0x8000\n#  endif\n\n//*** OBJECT Structure\n// An OBJECT structure holds the object public, sensitive, and meta-data\n// associated. This structure is implementation dependent. For this\n// implementation, the structure is not optimized for space but rather\n// for clarity of the reference implementation. Other implementations\n// may choose to overlap portions of the structure that are not used\n// simultaneously. These changes would necessitate changes to the source\n// code but those changes would be compatible with the reference\n// implementation.\n\ntypedef struct OBJECT\n{\n    // The attributes field is required to be first followed by the publicArea.\n    // This allows the overlay of the object structure and a sequence structure\n    OBJECT_ATTRIBUTES attributes;     // object attributes\n    TPMT_PUBLIC       publicArea;     // public area of an object\n    TPMT_SENSITIVE    sensitive;      // sensitive area of an object\n    TPM2B_NAME        qualifiedName;  // object qualified name\n    TPMI_DH_OBJECT    evictHandle;    // if the object is an evict object,\n    // the original handle is kept here.\n    // The 'working' handle will be the\n    // handle of an object slot.\n    TPM2B_NAME name;                  // Name of the object name. Kept here\n    // to avoid repeatedly computing it.\n    TPMI_RH_HIERARCHY hierarchy;      // Hierarchy for the object. While the\n    // base hierarchy can be deduced from\n    // 'attributes', if the hierarchy is\n    // firmware-bound or SVN-bound then\n    // this field carries additional metadata\n    // needed to derive the proof value for\n    // the object.\n} OBJECT;\n\n//*** HASH_OBJECT Structure\n// This structure holds a hash sequence object or an event sequence object.\n//\n// The first four components of this structure are manually set to be the same as\n// the first four components of the object structure. This prevents the object\n// from being inadvertently misused as sequence objects occupy the same memory as\n// a regular object. A debug check is present to make sure that the offsets are\n// what they are supposed to be.\n// NOTE: In a future version, this will probably be renamed as SEQUENCE_OBJECT\ntypedef struct HASH_OBJECT\n{\n    OBJECT_ATTRIBUTES attributes;        // The attributes of the HASH object\n    TPMI_ALG_PUBLIC   type;              // algorithm\n    TPMI_ALG_HASH     nameAlg;           // name algorithm\n    TPMA_OBJECT       objectAttributes;  // object attributes\n    \n    // The data below is unique to a sequence object\n    TPM2B_AUTH auth;  // authorization for use of sequence\n    union\n    {\n\tHASH_STATE hashState[HASH_COUNT];\n\tHMAC_STATE hmacState;\n    } state;\n} HASH_OBJECT;\n\ntypedef BYTE HASH_OBJECT_BUFFER[sizeof(HASH_OBJECT)];\n\n//*** ANY_OBJECT\n// This is the union for holding either a sequence object or a regular object\n// for ContextSave and ContextLoad.\ntypedef union ANY_OBJECT\n{\n    OBJECT      entity;\n    HASH_OBJECT hash;\n} ANY_OBJECT;\n\ntypedef BYTE ANY_OBJECT_BUFFER[sizeof(ANY_OBJECT)];\n\n//**AUTH_DUP Types\n// These values are used in the authorization processing.\n\ntypedef UINT32 AUTH_ROLE;\n#  define AUTH_NONE  ((AUTH_ROLE)(0))\n#  define AUTH_USER  ((AUTH_ROLE)(1))\n#  define AUTH_ADMIN ((AUTH_ROLE)(2))\n#  define AUTH_DUP   ((AUTH_ROLE)(3))\n\n//** Active Session Context\n//*** Description\n// The structures in this section define the internal structure of a session\n// context.\n//\n//*** SESSION_ATTRIBUTES\n// The attributes in the SESSION_ATTRIBUTES structure track the various properties\n// of the session. It maintains most of the tracking state information for the\n// policy session. It is used within the SESSION structure.\n\ntypedef struct SESSION_ATTRIBUTES\n{\n    // SET if the session may only be used for policy\n    unsigned isPolicy : 1;\n    // SET if the session is used for audit\n    unsigned isAudit : 1;\n    // SET if the session is bound to an entity. This attribute will be CLEAR if\n    // either isPolicy or isAudit is SET.\n    unsigned isBound : 1;\n    // SET if the cpHash has been defined. This attribute is not SET unless\n    // 'isPolicy' is SET.\n    unsigned isCpHashDefined : 1;\n    // SET if the nameHash has been defined. This attribute is not SET unless\n    // 'isPolicy' is SET.\n    unsigned isNameHashDefined : 1;\n    // SET if the pHash has been defined. This attribute is not SET unless\n    // 'isPolicy' is SET.\n    unsigned isParametersHashDefined : 1;\n    // SET if the templateHash needs to be checked for Create, CreatePrimary, or\n    // CreateLoaded.\n    unsigned isTemplateHashDefined : 1;\n    // SET if the authValue is required for computing the session HMAC. This\n    // attribute is not SET unless 'isPolicy' is SET.\n    unsigned isAuthValueNeeded : 1;\n    // SET if a password authValue is required for authorization This attribute\n    // is not SET unless 'isPolicy' is SET.\n    unsigned isPasswordNeeded : 1;\n    // SET if physical presence is required to be asserted when the\n    // authorization is checked. This attribute is not SET unless 'isPolicy' is\n    // SET.\n    unsigned isPPRequired : 1;\n    // SET if the policy session is created for trial of the policy's policyHash\n    // generation. This attribute is not SET unless 'isPolicy' is SET.\n    unsigned isTrialPolicy : 1;\n    // SET if the bind entity had noDA CLEAR. If this is SET, then an\n    // authorization failure using this session will count against lockout even\n    // if the object being authorized is exempt from DA.\n    unsigned isDaBound : 1;\n    // SET if the session is bound to lockoutAuth.\n    unsigned isLockoutBound : 1;\n    // This attribute is SET when the authValue of an object is to be included\n    // in the computation of the HMAC key for the command and response\n    // computations. (was 'requestWasBound')\n    unsigned includeAuth : 1;\n    // SET if the TPMA_NV_WRITTEN attribute needs to be checked when the policy\n    // is used for authorization for NV access. If this is SET for any other\n    // type, the policy will fail.\n    unsigned checkNvWritten : 1;\n    // SET if TPMA_NV_WRITTEN is required to be SET. Used when 'checkNvWritten'\n    // is SET\n    unsigned nvWrittenState : 1;\n} SESSION_ATTRIBUTES;\n\n//*** IsCpHashUnionOccupied()\n// This function indicates whether the session attributes indicate that one of\n// the members of the union containing `cpHash` are set.\nBOOL IsCpHashUnionOccupied(SESSION_ATTRIBUTES attrs);\n\n//*** SESSION Structure\n// The SESSION structure contains all the context of a session except for the\n// associated contextID.\n//\n// Note: The contextID of a session is only relevant when the session context\n// is stored off the TPM.\n\ntypedef struct SESSION\n{\n    SESSION_ATTRIBUTES attributes;  // session attributes\n    UINT32             pcrCounter;  // PCR counter value when PCR is\n    // included (policy session)\n    // If no PCR is included, this\n    // value is 0.\n    UINT64 startTime;               // The value in g_time when the session\n    // was started (policy session)\n    UINT64 timeout;                 // The timeout relative to g_time\n    // There is no timeout if this value\n    // is 0.\n    CLOCK_NONCE epoch;              // The g_clockEpoch value when the\n    // session was started. If g_clockEpoch\n    // does not match this value when the\n    // timeout is used, then\n    // then the command will fail.\n    TPM_CC        commandCode;      // command code (policy session)\n    TPM_ALG_ID    authHashAlg;      // session hash algorithm\n    TPMA_LOCALITY commandLocality;  // command locality (policy session)\n    TPMT_SYM_DEF  symmetric;        // session symmetric algorithm (if any)\n    TPM2B_AUTH    sessionKey;       // session secret value used for\n    // this session\n    TPM2B_NONCE nonceTPM;           // last TPM-generated nonce for\n    // generating HMAC and encryption keys\n    union\n    {\n\tTPM2B_NAME boundEntity;  // value used to track the entity to\n\t// which the session is bound\n\t\n\tTPM2B_DIGEST cpHash;        // the required cpHash value for the\n\t// command being authorized\n\tTPM2B_DIGEST nameHash;      // the required nameHash\n\tTPM2B_DIGEST templateHash;  // the required template for creation\n\tTPM2B_DIGEST pHash;         // the required parameter hash value for the\n\t// command being authorized\n    } u1;\n    \n    union\n    {\n\tTPM2B_DIGEST auditDigest;   // audit session digest\n\tTPM2B_DIGEST policyDigest;  // policyHash\n    } u2;                           // audit log and policyHash may\n    // share space to save memory\n} SESSION;\n\n#  define EXPIRES_ON_RESET   INT32_MIN\n#  define TIMEOUT_ON_RESET   UINT64_MAX\n#  define EXPIRES_ON_RESTART (INT32_MIN + 1)\n#  define TIMEOUT_ON_RESTART (UINT64_MAX - 1)\n\ntypedef BYTE SESSION_BUF[sizeof(SESSION)];\n\n//*********************************************************************************\n//** PCR\n//*********************************************************************************\n//***PCR_SAVE Structure\n// The PCR_SAVE structure type contains the PCR data that are saved across power\n// cycles. Only the static PCR are required to be saved across power cycles. The\n// DRTM and resettable PCR are not saved. The number of static and resettable PCR\n// is determined by the platform-specific specification to which the TPM is built.\n\n#  define PCR_SAVE_SPACE(HASH, Hash) BYTE Hash[NUM_STATIC_PCR][HASH##_DIGEST_SIZE];\n\ntypedef struct PCR_SAVE\n{\n    FOR_EACH_HASH(PCR_SAVE_SPACE)\n    \n    // This counter increments whenever the PCR are updated.\n    // NOTE: A platform-specific specification may designate\n    //       certain PCR changes as not causing this counter\n    //       to increment.\n    UINT32 pcrCounter;\n} PCR_SAVE;\n\n//***PCR_POLICY\n#  if defined NUM_POLICY_PCR_GROUP && NUM_POLICY_PCR_GROUP > 0\n// This structure holds the PCR policies, one for each group of PCR controlled\n// by policy.\ntypedef struct PCR_POLICY\n{\n    TPMI_ALG_HASH hashAlg[NUM_POLICY_PCR_GROUP];\n    TPM2B_DIGEST  a;\n    TPM2B_DIGEST  policy[NUM_POLICY_PCR_GROUP];\n} PCR_POLICY;\n#  endif\n\n//***PCR_AUTHVALUE\n// This structure holds the PCR policies, one for each group of PCR controlled\n// by policy.\ntypedef struct PCR_AUTH_VALUE\n{\n    TPM2B_DIGEST auth[NUM_AUTHVALUE_PCR_GROUP];\n} PCR_AUTHVALUE;\n\n//**STARTUP_TYPE\n// This enumeration is the possible startup types. The type is determined\n// by the combination of TPM2_ShutDown and TPM2_Startup.\ntypedef enum\n    {\n\tSU_RESET,\n\tSU_RESTART,\n\tSU_RESUME\n    } STARTUP_TYPE;\n\n//**NV\n\n//***NV_INDEX\n// The NV_INDEX structure defines the internal format for an NV index.\n// The 'indexData' size varies according to the type of the index.\n// In this implementation, all of the index is manipulated as a unit.\n// NOTE: In this implementation of the TPM, the extended bits are always 0.\n// Therefore, they are stored in the NV subsystem as legacy structures,\n// even when the handle type indicates that the index can have extended\n// attributes.\ntypedef struct NV_INDEX\n{\n    TPMS_NV_PUBLIC publicArea;\n    TPM2B_AUTH     authValue;\n} NV_INDEX;\n\n//*** NV_REF\n// An NV_REF is an opaque value returned by the NV subsystem. It is used to\n// reference and NV Index in a relatively efficient way. Rather than having to\n// continually search for an Index, its reference value may be used. In this\n// implementation, an NV_REF is a byte pointer that points to the copy of the\n// NV memory that is kept in RAM.\ntypedef UINT32 NV_REF;\n\ntypedef BYTE*  NV_RAM_REF;\n//***NV_PIN\n// This structure deals with the possible endianess differences between the\n// canonical form of the TPMS_NV_PIN_COUNTER_PARAMETERS structure and the internal\n// value. The structures allow the data in a PIN index to be read as an 8-octet\n// value using NvReadUINT64Data(). That function will byte swap all the values on a\n// little endian system. This will put the bytes with the 4-octet values in the\n// correct order but will swap the pinLimit and pinCount values. When written, the\n// PIN index is simply handled as a normal index with the octets in canonical order.\n#  if BIG_ENDIAN_TPM\ntypedef struct\n{\n    UINT32 pinCount;\n    UINT32 pinLimit;\n} PIN_DATA;\n#  else\ntypedef struct\n{\n    UINT32 pinLimit;\n    UINT32 pinCount;\n} PIN_DATA;\n#  endif\n\ntypedef union\n{\n    UINT64   intVal;\n    PIN_DATA pin;\n} NV_PIN;\n\n//**COMMIT_INDEX_MASK\n// This is the define for the mask value that is used when manipulating\n// the bits in the commit bit array. The commit counter is a 64-bit\n// value and the low order bits are used to index the commitArray.\n// This mask value is applied to the commit counter to extract the\n// bit number in the array.\n#  if ALG_ECC\n\n#    define COMMIT_INDEX_MASK ((UINT16)((sizeof(gr.commitArray) * 8) - 1))\n\n#  endif\n\n//*****************************************************************************\n//*****************************************************************************\n//** RAM Global Values\n//*****************************************************************************\n//*****************************************************************************\n//*** Description\n// The values in this section are only extant in RAM or ROM as constant values.\n\n//*** Crypto Self-Test Values\nEXTERN ALGORITHM_VECTOR g_implementedAlgorithms;\nEXTERN ALGORITHM_VECTOR g_toTest;\n\n//*** g_rcIndex[]\n// This array is used to contain the array of values that are added to a return\n// code when it is a parameter-, handle-, or session-related error.\n// This is an implementation choice and the same result can be achieved by using\n// a macro.\nextern const UINT16 g_rcIndex[15];\n\n//*** g_exclusiveAuditSession\n// This location holds the session handle for the current exclusive audit\n// session. If there is no exclusive audit session, the location is set to\n// TPM_RH_UNASSIGNED.\nEXTERN TPM_HANDLE g_exclusiveAuditSession;\n\n//*** g_time\n// This is the value in which we keep the current command time. This is initialized\n// at the start of each command. The time is the accumulated time since the last\n// time that the TPM's timer was last powered up. Clock is the accumulated time\n// since the last time that the TPM was cleared. g_time is in mS.\nEXTERN UINT64 g_time;\n\n//*** g_timeEpoch\n// This value contains the current clock Epoch. It changes when there is a clock\n// discontinuity. It may be necessary to place this in NV should the timer be able\n// to run across a power down of the TPM but not in all cases (e.g. dead battery).\n// If the nonce is placed in NV, it should go in gp because it should be changing\n// slowly.\n#  if CLOCK_STOPS\nEXTERN CLOCK_NONCE g_timeEpoch;\n#  else\n#    define g_timeEpoch gp.timeEpoch\n#  endif\n\n//*** g_phEnable\n// This is the platform hierarchy control and determines if the platform hierarchy\n// is available. This value is SET on each TPM2_Startup(). The default value is\n// SET.\nEXTERN BOOL g_phEnable;\n\n//*** g_pcrReConfig\n// This value is SET if a TPM2_PCR_Allocate command successfully executed since\n// the last TPM2_Startup(). If so, then the next shutdown is required to be\n// Shutdown(CLEAR).\nEXTERN BOOL g_pcrReConfig;\n\n//*** g_DRTMHandle\n// This location indicates the sequence object handle that holds the DRTM\n// sequence data. When not used, it is set to TPM_RH_UNASSIGNED. A sequence\n// DRTM sequence is started on either _TPM_Init or _TPM_Hash_Start.\nEXTERN TPMI_DH_OBJECT g_DRTMHandle;\n\n//*** g_DrtmPreStartup\n// This value indicates that an H-CRTM occurred after _TPM_Init but before\n// TPM2_Startup(). The define for PRE_STARTUP_FLAG is used to add the\n// g_DrtmPreStartup value to gp_orderlyState at shutdown. This hack is to avoid\n// adding another NV variable.\nEXTERN BOOL g_DrtmPreStartup;\n\n//*** g_StartupLocality3\n// This value indicates that a TPM2_Startup() occurred at locality 3. Otherwise, it\n// at locality 0. The define for STARTUP_LOCALITY_3 is to\n// indicate that the startup was not at locality 0. This hack is to avoid\n// adding another NV variable.\nEXTERN BOOL g_StartupLocality3;\n\n//***TPM_SU_NONE\n// Part 2 defines the two shutdown/startup types that may be used in\n// TPM2_Shutdown() and TPM2_Starup(). This additional define is\n// used by the TPM to indicate that no shutdown was received.\n// NOTE: This is a reserved value.\n#  define SU_NONE_VALUE (0xFFFF)\n#  define TPM_SU_NONE   (TPM_SU)(SU_NONE_VALUE)\n\n//*** TPM_SU_DA_USED\n// As with TPM_SU_NONE, this value is added to allow indication that the shutdown\n// was not orderly and that a DA=protected object was reference during the previous\n// cycle.\n#  define SU_DA_USED_VALUE (SU_NONE_VALUE - 1)\n#  define TPM_SU_DA_USED   (TPM_SU)(SU_DA_USED_VALUE)\n\n//*** Startup Flags\n// These flags are included in gp.orderlyState. These are hacks and are being\n// used to avoid having to change the layout of gp. The PRE_STARTUP_FLAG indicates\n// that a _TPM_Hash_Start/_Data/_End sequence was received after _TPM_Init but\n// before TPM2_StartUp(). STARTUP_LOCALITY_3 indicates that the last TPM2_Startup()\n// was received at locality 3. These flags are only  relevant if after a\n// TPM2_Shutdown(STATE).\n#  define PRE_STARTUP_FLAG   0x8000\n#  define STARTUP_LOCALITY_3 0x4000\n\n#  if USE_DA_USED\n//*** g_daUsed\n// This location indicates if a DA-protected value is accessed during a boot\n// cycle. If none has, then there is no need to increment 'failedTries' on the\n// next non-orderly startup. This bit is merged with gp.orderlyState when\n// gp.orderly is set to SU_NONE_VALUE\nEXTERN BOOL g_daUsed;\n#  endif\n\n//*** g_updateNV\n// This flag indicates if NV should be updated at the end of a command.\n// This flag is set to UT_NONE at the beginning of each command in ExecuteCommand().\n// This flag is checked in ExecuteCommand() after the detailed actions of a command\n// complete. If the command execution was successful and this flag is not UT_NONE,\n// any pending NV writes will be committed to NV.\n// UT_ORDERLY causes any RAM data to be written to the orderly space for staging\n// the write to NV.\ntypedef BYTE UPDATE_TYPE;\n#  define UT_NONE    (UPDATE_TYPE)0\n#  define UT_NV      (UPDATE_TYPE)1\n#  define UT_ORDERLY (UPDATE_TYPE)(UT_NV + 2)\nEXTERN UPDATE_TYPE g_updateNV;\n\n//*** g_powerWasLost\n// This flag is used to indicate if the power was lost. It is SET in _TPM__Init.\n// This flag is cleared by TPM2_Startup() after all power-lost activities are\n// completed.\n// Note: When power is applied, this value can come up as anything. However,\n// _plat__WasPowerLost() will provide the proper indication in that case. So, when\n// power is actually lost, we get the correct answer. When power was not lost, but\n// the power-lost processing has not been completed before the next _TPM_Init(),\n// then the TPM still does the correct thing.\nEXTERN BOOL g_powerWasLost;\n\n//*** g_clearOrderly\n// This flag indicates if the execution of a command should cause the orderly\n// state to be cleared.  This flag is set to FALSE at the beginning of each\n// command in ExecuteCommand() and is checked in ExecuteCommand() after the\n// detailed actions of a command complete but before the check of\n// 'g_updateNV'. If this flag is TRUE, and the orderly state is not\n// SU_NONE_VALUE, then the orderly state in NV memory will be changed to\n// SU_NONE_VALUE or SU_DA_USED_VALUE.\nEXTERN BOOL g_clearOrderly;\n\n//*** g_prevOrderlyState\n// This location indicates how the TPM was shut down before the most recent\n// TPM2_Startup(). This value, along with the startup type, determines if\n// the TPM should do a TPM Reset, TPM Restart, or TPM Resume.\nEXTERN TPM_SU g_prevOrderlyState;\n\n//*** g_nvOk\n// This value indicates if the NV integrity check was successful or not. If not and\n// the failure was severe, then the TPM would have been put into failure mode after\n// it had been re-manufactured. If the NV failure was in the area where the state-save\n// data is kept, then this variable will have a value of FALSE indicating that\n// a TPM2_Startup(CLEAR) is required.\nEXTERN BOOL g_nvOk;\n// NV availability is sampled as the start of each command and stored here\n// so that its value remains consistent during the command execution\nEXTERN TPM_RC g_NvStatus;\n\n//*** g_platformUnique\n\n// This location contains unique value(s) used by the TPM Platform vendor.\n// These are loaded on every _TPM2_Startup() using the _plat__GetUnique function.\n// The \"which\" parameter to  _plat__GetUnique indicates the value to return.\n// If used, the TPM vendor is expected to use these values for authentication.\n#  if VENDOR_PERMANENT_AUTH_ENABLED == YES\n// which = 1, the authorization value for VENDOR_PERMANENT_AUTH_HANDLE\nEXTERN TPM2B_AUTH g_platformUniqueAuth;\n#  endif\n\n//*********************************************************************************\n//*********************************************************************************\n//** Persistent Global Values\n//*********************************************************************************\n//*********************************************************************************\n//*** Description\n// The values in this section are global values that are persistent across power\n// events. The lifetime of the values determines the structure in which the value\n// is placed.\n\n//*********************************************************************************\n//*** PERSISTENT_DATA\n//*********************************************************************************\n// This structure holds the persistent values that only change as a consequence\n// of a specific Protected Capability and are not affected by TPM power events\n// (TPM2_Startup() or TPM2_Shutdown().\ntypedef struct\n{\n    // data provided by the platform library during manufacturing.\n    // Opaque to the TPM Core library, but may be used by the platform library.\n    BYTE platformReserved[PERSISTENT_DATA_PLATFORM_SPACE];\n    \n    //*********************************************************************************\n    //          Hierarchy\n    //*********************************************************************************\n    // The values in this section are related to the hierarchies.\n    \n    BOOL disableClear;  // TRUE if TPM2_Clear() using\n    // lockoutAuth is disabled\n    \n    // Hierarchy authPolicies\n    TPMI_ALG_HASH ownerAlg;\n    TPMI_ALG_HASH endorsementAlg;\n    TPMI_ALG_HASH lockoutAlg;\n    TPM2B_DIGEST  ownerPolicy;\n    TPM2B_DIGEST  endorsementPolicy;\n    TPM2B_DIGEST  lockoutPolicy;\n    \n    // Hierarchy authValues\n    TPM2B_AUTH ownerAuth;\n    TPM2B_AUTH endorsementAuth;\n    TPM2B_AUTH lockoutAuth;\n    \n    // Primary Seeds\n    TPM2B_SEED EPSeed;\n    TPM2B_SEED SPSeed;\n    TPM2B_SEED PPSeed;\n    // Note there is a nullSeed in the state_reset memory.\n    \n    // Hierarchy proofs\n    TPM2B_PROOF phProof;\n    TPM2B_PROOF shProof;\n    TPM2B_PROOF ehProof;\n    // Note there is a nullProof in the state_reset memory.\n    \n    //*********************************************************************************\n    //          Reset Events\n    //*********************************************************************************\n    // A count that increments at each TPM reset and never get reset during the life\n    // time of TPM.  The value of this counter is initialized to 1 during TPM\n    // manufacture process. It is used to invalidate all saved contexts after a TPM\n    // Reset.\n    UINT64 totalResetCount;\n    \n    // This counter increments on each TPM Reset. The counter is reset by\n    // TPM2_Clear().\n    UINT32 resetCount;\n    \n    //*********************************************************************************\n    //          PCR\n    //*********************************************************************************\n    // This structure hold the policies for those PCR that have an update policy.\n    // This implementation only supports a single group of PCR controlled by\n    // policy. If more are required, then this structure would be changed to\n    // an array.\n#  if defined  NUM_POLICY_PCR_GROUP && NUM_POLICY_PCR_GROUP > 0\n    PCR_POLICY pcrPolicies;\n#  endif\n    \n    // This structure indicates the allocation of PCR. The structure contains a\n    // list of PCR allocations for each implemented algorithm. If no PCR are\n    // allocated for an algorithm, a list entry still exists but the bit map\n    // will contain no SET bits.\n    TPML_PCR_SELECTION pcrAllocated;\n    \n    //*********************************************************************************\n    //          Physical Presence\n    //*********************************************************************************\n    // The PP_LIST type contains a bit map of the commands that require physical\n    // to be asserted when the authorization is evaluated. Physical presence will be\n    // checked if the corresponding bit in the array is SET and if the authorization\n    // handle is TPM_RH_PLATFORM.\n    //\n    // These bits may be changed with TPM2_PP_Commands().\n    BYTE ppList[(COMMAND_COUNT + 7) / 8];\n    \n    //*********************************************************************************\n    //          Dictionary attack values\n    //*********************************************************************************\n    // These values are used for dictionary attack tracking and control.\n    UINT32 failedTries;  // the current count of unexpired\n    // authorization failures\n    \n    UINT32 maxTries;  // number of unexpired authorization\n    // failures before the TPM is in\n    // lockout\n    \n    UINT32 recoveryTime;  // time between authorization failures\n    // before failedTries is decremented\n    \n    UINT32 lockoutRecovery;  // time that must expire between\n    // authorization failures associated\n    // with lockoutAuth\n    \n    BOOL lockOutAuthEnabled;  // TRUE if use of lockoutAuth is\n    // allowed\n    \n    //*****************************************************************************\n    //            Orderly State\n    //*****************************************************************************\n    // The orderly state for current cycle\n    TPM_SU orderlyState;\n    \n    //*****************************************************************************\n    //           Command audit values.\n    //*****************************************************************************\n    BYTE          auditCommands[((COMMAND_COUNT + 1) + 7) / 8];\n    TPMI_ALG_HASH auditHashAlg;\n    UINT64        auditCounter;\n    \n    //*****************************************************************************\n    //           Algorithm selection\n    //*****************************************************************************\n    //\n    // The 'algorithmSet' value indicates the collection of algorithms that are\n    // currently in used on the TPM.  The interpretation of value is vendor dependent.\n    UINT32 algorithmSet;\n    \n    //*****************************************************************************\n    //           Firmware version\n    //*****************************************************************************\n    // The firmwareV1 and firmwareV2 values are instanced in TimeStamp.c. This is\n    // a scheme used in development to allow determination of the linker build time\n    // of the TPM. An actual implementation would implement these values in a way that\n    // is consistent with vendor needs. The values are maintained in RAM for simplified\n    // access with a master version in NV.  These values are modified in a\n    // vendor-specific way.\n    \n    // g_firmwareV1 contains the more significant 32-bits of the vendor version number.\n    // In the reference implementation, if this value is printed as a hex\n    // value, it will have the format of YYYYMMDD\n    UINT32 firmwareV1;\n    \n    // g_firmwareV1 contains the less significant 32-bits of the vendor version number.\n    // In the reference implementation, if this value is printed as a hex\n    // value, it will have the format of 00 HH MM SS\n    UINT32 firmwareV2;\n    //*****************************************************************************\n    //           Timer Epoch\n    //*****************************************************************************\n    // timeEpoch contains a nonce that has a vendor=specific size (should not be\n    // less than 8 bytes. This nonce changes when the clock epoch changes. The clock\n    // epoch changes when there is a discontinuity in the timing of the TPM.\n#  if !CLOCK_STOPS\n    CLOCK_NONCE timeEpoch;\n#  endif\n    \n} PERSISTENT_DATA;\n\nEXTERN PERSISTENT_DATA gp;\n\n//*********************************************************************************\n//*********************************************************************************\n//*** ORDERLY_DATA\n//*********************************************************************************\n//*********************************************************************************\n// The data in this structure is saved to NV on each TPM2_Shutdown().\ntypedef struct orderly_data\n{\n    //*****************************************************************************\n    //           TIME\n    //*****************************************************************************\n    \n    // Clock has two parts. One is the state save part and one is the NV part. The\n    // state save version is updated on each command. When the clock rolls over, the\n    // NV version is updated. When the TPM starts up, if the TPM was shutdown in and\n    // orderly way, then the sClock value is used to initialize the clock. If the\n    // TPM shutdown was not orderly, then the persistent value is used and the safe\n    // attribute is clear.\n    \n    UINT64      clock;      // The orderly version of clock\n    TPMI_YES_NO clockSafe;  // Indicates if the clock value is\n    // safe.\n    \n    // In many implementations, the quality of the entropy available is not that\n    // high. To compensate, the current value of the drbgState can be saved and\n    // restored on each power cycle. This prevents the internal state from reverting\n    // to the initial state on each power cycle and starting with a limited amount\n    // of entropy. By keeping the old state and adding entropy, the entropy will\n    // accumulate.\n    DRBG_STATE drbgState;\n    \n    // These values allow the accumulation of self-healing time across orderly shutdown\n    // of the TPM.\n#  if ACCUMULATE_SELF_HEAL_TIMER\n    UINT64 selfHealTimer;  // current value of s_selfHealTimer\n    UINT64 lockoutTimer;   // current value of s_lockoutTimer\n    UINT64 time;           // current value of g_time at shutdown\n#  endif                   // ACCUMULATE_SELF_HEAL_TIMER\n    \n    // These are the ACT Timeout values. They are saved with the other timers\n#  define DefineActData(N) ACT_STATE ACT_##N;\n    FOR_EACH_ACT(DefineActData)\n    \n    // this is the 'signaled' attribute data for all the ACT. It is done this way so\n    // that they can be manipulated by ACT number rather than having to access a\n    // structure.\n    UINT16 signaledACT;\n    UINT16 preservedSignaled;\n    \n#  if ORDERLY_DATA_PADDING != 0\n    BYTE reserved[ORDERLY_DATA_PADDING];\n#  endif\n    \n} ORDERLY_DATA;\n\n#  if ACCUMULATE_SELF_HEAL_TIMER\n#    define s_selfHealTimer go.selfHealTimer\n#    define s_lockoutTimer  go.lockoutTimer\n#  endif  // ACCUMULATE_SELF_HEAL_TIMER\n\n#  define drbgDefault go.drbgState\n\nEXTERN ORDERLY_DATA go;\n\n//*********************************************************************************\n//*********************************************************************************\n//*** STATE_CLEAR_DATA\n//*********************************************************************************\n//*********************************************************************************\n// This structure contains the data that is saved on Shutdown(STATE)\n// and restored on Startup(STATE).  The values are set to their default\n// settings on any Startup(Clear). In other words, the data is only persistent\n// across TPM Resume.\n//\n// If the comments associated with a parameter indicate a default reset value, the\n// value is applied on each Startup(CLEAR).\n\ntypedef struct state_clear_data\n{\n    //*****************************************************************************\n    //           Hierarchy Control\n    //*****************************************************************************\n    BOOL          shEnable;        // default reset is SET\n    BOOL          ehEnable;        // default reset is SET\n    BOOL          phEnableNV;      // default reset is SET\n    TPMI_ALG_HASH platformAlg;     // default reset is TPM_ALG_NULL\n    TPM2B_DIGEST  platformPolicy;  // default reset is an Empty Buffer\n    TPM2B_AUTH    platformAuth;    // default reset is an Empty Buffer\n    \n    //*****************************************************************************\n    //           PCR\n    //*****************************************************************************\n    // The set of PCR to be saved on Shutdown(STATE)\n    PCR_SAVE pcrSave;  // default reset is 0...0\n    \n    // This structure hold the authorization values for those PCR that have an\n    // update authorization.\n    // This implementation only supports a single group of PCR controlled by\n    // authorization. If more are required, then this structure would be changed to\n    // an array.\n    PCR_AUTHVALUE pcrAuthValues;\n    \n    //*****************************************************************************\n    //           ACT\n    //*****************************************************************************\n#  define DefineActPolicySpace(N) TPMT_HA act_##N;\n    FOR_EACH_ACT(DefineActPolicySpace)\n    \n#  if STATE_CLEAR_DATA_PADDING != 0\n    BYTE reserved[STATE_CLEAR_DATA_PADDING];\n#  endif\n} STATE_CLEAR_DATA;\n\nEXTERN STATE_CLEAR_DATA gc;\n\n//*********************************************************************************\n//*********************************************************************************\n//***  State Reset Data\n//*********************************************************************************\n//*********************************************************************************\n// This structure contains data is that is saved on Shutdown(STATE) and restored on\n// the subsequent Startup(ANY). That is, the data is preserved across TPM Resume\n// and TPM Restart.\n//\n// If a default value is specified in the comments this value is applied on\n// TPM Reset.\n\ntypedef struct state_reset_data\n{\n    //*****************************************************************************\n    //          Hierarchy Control\n    //*****************************************************************************\n    TPM2B_PROOF nullProof;  // The proof value associated with\n    // the TPM_RH_NULL hierarchy. The\n    // default reset value is from the RNG.\n    \n    TPM2B_SEED nullSeed;  // The seed value for the TPM_RN_NULL\n    // hierarchy. The default reset value\n    // is from the RNG.\n    \n    //*****************************************************************************\n    //           Context\n    //*****************************************************************************\n    // The 'clearCount' counter is incremented each time the TPM successfully executes\n    // a TPM Resume. The counter is included in each saved context that has 'stClear'\n    // SET (including descendants of keys that have 'stClear' SET). This prevents these\n    // objects from being loaded after a TPM Resume.\n    // If 'clearCount' is at its maximum value when the TPM receives a Shutdown(STATE),\n    // the TPM will return TPM_RC_RANGE and the TPM will only accept Shutdown(CLEAR).\n    UINT32 clearCount;  // The default reset value is 0.\n    \n    UINT64 objectContextID;  // This is the context ID for a saved\n    //  object context. The default reset\n    //  value is 0.\n    CONTEXT_SLOT contextArray[MAX_ACTIVE_SESSIONS];  // This array contains\n    // contains the values used to track\n    // the version numbers of saved\n    // contexts (see\n    // Session.c in for details). The\n    // default reset value is {0}.\n    \n    CONTEXT_COUNTER contextCounter;  // This is the value from which the\n    // 'contextID' is derived. The\n    // default reset value is {0}.\n    \n    //*****************************************************************************\n    //           Command Audit\n    //*****************************************************************************\n    // When an audited command completes, ExecuteCommand() checks the return\n    // value.  If it is TPM_RC_SUCCESS, and the command is an audited command, the\n    // TPM will extend the cpHash and rpHash for the command to this value. If this\n    // digest was the Zero Digest before the cpHash was extended, the audit counter\n    // is incremented.\n    \n    TPM2B_DIGEST commandAuditDigest;  // This value is set to an Empty Digest\n    // by TPM2_GetCommandAuditDigest() or a\n    // TPM Reset.\n    \n    //*****************************************************************************\n    //           Boot counter\n    //*****************************************************************************\n    \n    UINT32 restartCount;  // This counter counts TPM Restarts.\n    // The default reset value is 0.\n    \n    //*********************************************************************************\n    //            PCR\n    //*********************************************************************************\n    // This counter increments whenever the PCR are updated. This counter is preserved\n    // across TPM Resume even though the PCR are not preserved. This is because\n    // sessions remain active across TPM Restart and the count value in the session\n    // is compared to this counter so this counter must have values that are unique\n    // as long as the sessions are active.\n    // NOTE: A platform-specific specification may designate that certain PCR changes\n    //       do not increment this counter to increment.\n    UINT32 pcrCounter;  // The default reset value is 0.\n    \n#  if ALG_ECC\n    \n    //*****************************************************************************\n    //         ECDAA\n    //*****************************************************************************\n    UINT64 commitCounter;  // This counter increments each time\n    // TPM2_Commit() returns\n    // TPM_RC_SUCCESS. The default reset\n    // value is 0.\n    \n    TPM2B_NONCE commitNonce;  // This random value is used to compute\n    // the commit values. The default reset\n    // value is from the RNG.\n    \n    // This implementation relies on the number of bits in g_commitArray being a\n    // power of 2 (8, 16, 32, 64, etc.) and no greater than 64K.\n    BYTE commitArray[16];  // The default reset value is {0}.\n    \n#  endif  // ALG_ECC\n#  if STATE_RESET_DATA_PADDING != 0\n    BYTE reserved[STATE_RESET_DATA_PADDING];\n#  endif\n} STATE_RESET_DATA;\n\nEXTERN STATE_RESET_DATA gr;\n\n//** NV Layout\n// The NV data organization is\n// 1) a PERSISTENT_DATA structure\n// 2) a STATE_RESET_DATA structure\n// 3) a STATE_CLEAR_DATA structure\n// 4) an ORDERLY_DATA structure\n// 5) the user defined NV index space\n#  define NV_PERSISTENT_DATA  (0)\n#  define NV_STATE_RESET_DATA (NV_PERSISTENT_DATA + sizeof(PERSISTENT_DATA))\n#  define NV_STATE_CLEAR_DATA (NV_STATE_RESET_DATA + sizeof(STATE_RESET_DATA))\n#  define NV_ORDERLY_DATA     (NV_STATE_CLEAR_DATA + sizeof(STATE_CLEAR_DATA))\n#  define NV_INDEX_RAM_DATA   (NV_ORDERLY_DATA + sizeof(ORDERLY_DATA))\n#  define NV_USER_DYNAMIC     (NV_INDEX_RAM_DATA + sizeof(s_indexOrderlyRam))\n#  define NV_USER_DYNAMIC_END NV_MEMORY_SIZE\n\n//** Global Macro Definitions\n// The NV_READ_PERSISTENT and NV_WRITE_PERSISTENT macros are used to access members\n// of the PERSISTENT_DATA structure in NV.\n#  define NV_READ_PERSISTENT(to, from)\t\t\t\t\t\\\n    NvRead(&to, offsetof(PERSISTENT_DATA, from), sizeof(to))\n\n#  define NV_WRITE_PERSISTENT(to, from)\t\t\t\t\t\\\n    NvWrite(offsetof(PERSISTENT_DATA, to), sizeof(gp.to), &from)\n\n#  define CLEAR_PERSISTENT(item)\t\t\t\t\t\\\n    NvClearPersistent(offsetof(PERSISTENT_DATA, item), sizeof(gp.item))\n\n#  define NV_SYNC_PERSISTENT(item) NV_WRITE_PERSISTENT(item, gp.item)\n\n// At the start of command processing, the index of the command is determined. This\n// index value is used to access the various data tables that contain per-command\n// information. There are multiple options for how the per-command tables can be\n// implemented. This is resolved in GetClosestCommandIndex().\ntypedef UINT16 COMMAND_INDEX;\n#  define UNIMPLEMENTED_COMMAND_INDEX ((COMMAND_INDEX)(~0))\n\ntypedef struct _COMMAND_FLAGS_\n{\n    unsigned trialPolicy : 1;  //1) If SET, one of the handles references a\n    //   trial policy and authorization may be\n    //   skipped. This is only allowed for a policy\n    //   command.\n} COMMAND_FLAGS;\n\n// This structure is used to avoid having to manage a large number of\n// parameters being passed through various levels of the command input processing.\n//\n\n// The following macros are used to define the space for the CP and RP hashes. Space,\n// is provided for each implemented hash algorithm because it is not known what the\n// caller may use.\n#  define CP_HASH(HASH, Hash) TPM2B_##HASH##_DIGEST Hash##CpHash;\n#  define RP_HASH(HASH, Hash) TPM2B_##HASH##_DIGEST Hash##RpHash;\n\ntypedef struct COMMAND\n{\n    TPM_ST        tag;                   // the parsed command tag\n    TPM_CC        code;                  // the parsed command code\n    COMMAND_INDEX index;                 // the computed command index\n    UINT32        handleNum;             // the number of entity handles in the\n    //   handle area of the command\n    TPM_HANDLE handles[MAX_HANDLE_NUM];  // the parsed handle values\n    UINT32     sessionNum;               // the number of sessions found\n    INT32      parameterSize;            // starts out with the parsed command size\n    // and is reduced and values are\n    // unmarshaled. Just before calling the\n    // command actions, this should be zero.\n    // After the command actions, this number\n    // should grow as values are marshaled\n    // in to the response buffer.\n    INT32 authSize;                      // this is initialized with the parsed size\n    // of authorizationSize field and should\n    // be zero when the authorizations are\n    // parsed.\n    BYTE* parameterBuffer;               // input to ExecuteCommand\n    BYTE* responseBuffer;                // input to ExecuteCommand\n    FOR_EACH_HASH(CP_HASH)               // space for the CP hashes\n    FOR_EACH_HASH(RP_HASH)               // space for the RP hashes\n} COMMAND;\n\n// TPM2B String constants used for KDFs.\n// actual definition in global.c\nextern const TPM2B* PRIMARY_OBJECT_CREATION;\nextern const TPM2B* CFB_KEY;\nextern const TPM2B* CONTEXT_KEY;\nextern const TPM2B* INTEGRITY_KEY;\nextern const TPM2B* SECRET_KEY;\nextern const TPM2B* HIERARCHY_PROOF_SECRET_LABEL;\nextern const TPM2B* HIERARCHY_SEED_SECRET_LABEL;\nextern const TPM2B* HIERARCHY_FW_SECRET_LABEL;\nextern const TPM2B* HIERARCHY_SVN_SECRET_LABEL;\nextern const TPM2B* SESSION_KEY;\nextern const TPM2B* STORAGE_KEY;\nextern const TPM2B* XOR_KEY;\nextern const TPM2B* COMMIT_STRING;\nextern const TPM2B* DUPLICATE_STRING;\nextern const TPM2B* IDENTITY_STRING;\nextern const TPM2B* OBFUSCATE_STRING;\n#  if ENABLE_SELF_TESTS\nextern const TPM2B* OAEP_TEST_STRING;\n#  endif  // ENABLE_SELF_TESTS\n\n//*****************************************************************************\n//** From CryptTest.c\n//*****************************************************************************\n// This structure contains the self-test state values for the cryptographic modules.\nEXTERN CRYPTO_SELF_TEST_STATE g_cryptoSelfTestState;\n\n//*****************************************************************************\n//** From Manufacture.c\n//*****************************************************************************\nextern BOOL g_manufactured;\n\n// This value indicates if a TPM2_Startup commands has been\n// receive since the power on event.  This flag is maintained in power\n// simulation module because this is the only place that may reliably set this\n// flag to FALSE.\nEXTERN BOOL g_initialized;\n\n//** Private data\n\n//*****************************************************************************\n//*** From SessionProcess.c\n//*****************************************************************************\n#  if defined SESSION_PROCESS_C || defined GLOBAL_C || defined MANUFACTURE_C\n// The following arrays are used to save command sessions information so that the\n// command handle/session buffer does not have to be preserved for the duration of\n// the command. These arrays are indexed by the session index in accordance with\n// the order of sessions in the session area of the command.\n//\n// Array of the authorization session handles\nEXTERN TPM_HANDLE s_sessionHandles[MAX_SESSION_NUM];\n\n// Array of authorization session attributes\nEXTERN TPMA_SESSION s_attributes[MAX_SESSION_NUM];\n\n// Array of handles authorized by the corresponding authorization sessions;\n// and if none, then TPM_RH_UNASSIGNED value is used\nEXTERN TPM_HANDLE s_associatedHandles[MAX_SESSION_NUM];\n\n// Array of nonces provided by the caller for the corresponding sessions\nEXTERN TPM2B_NONCE s_nonceCaller[MAX_SESSION_NUM];\n\n// Array of authorization values (HMAC's or passwords) for the corresponding\n// sessions\nEXTERN TPM2B_AUTH s_inputAuthValues[MAX_SESSION_NUM];\n\n// Array of pointers to the SESSION structures for the sessions in a command\nEXTERN SESSION* s_usedSessions[MAX_SESSION_NUM];\n\n// Special value to indicate an undefined session index\n#    define UNDEFINED_INDEX (0xFFFF)\n\n// Index of the session used for encryption of a response parameter\nEXTERN UINT32 s_encryptSessionIndex;\n\n// Index of the session used for decryption of a command parameter\nEXTERN UINT32 s_decryptSessionIndex;\n\n// Index of a session used for audit\nEXTERN UINT32 s_auditSessionIndex;\n\n// The cpHash for command audit\n#    if CC_GetCommandAuditDigest\nEXTERN TPM2B_DIGEST s_cpHashForCommandAudit;\n#    endif\n\n// Flag indicating if NV update is pending for the lockOutAuthEnabled or\n// failedTries DA parameter\nEXTERN BOOL s_DAPendingOnNV;\n\n#  endif  // SESSION_PROCESS_C\n\n//*****************************************************************************\n//*** From DA.c\n//*****************************************************************************\n#  if defined DA_C || defined GLOBAL_C || defined MANUFACTURE_C\n// This variable holds the accumulated time since the last time\n// that 'failedTries' was decremented. This value is in millisecond.\n#    if !ACCUMULATE_SELF_HEAL_TIMER\nEXTERN UINT64 s_selfHealTimer;\n\n// This variable holds the accumulated time that the lockoutAuth has been\n// blocked.\nEXTERN UINT64 s_lockoutTimer;\n#    endif  // ACCUMULATE_SELF_HEAL_TIMER\n\n#  endif  // DA_C\n\n//*****************************************************************************\n//*** From NV.c\n//*****************************************************************************\n#  if defined NV_C || defined GLOBAL_C\n// This marks the end of the NV area. This is a run-time variable as it might\n// not be compile-time constant.\nEXTERN NV_REF s_evictNvEnd;\n\n// This space is used to hold the index data for an orderly Index. It also contains\n// the attributes for the index.\nEXTERN BYTE s_indexOrderlyRam[RAM_INDEX_SPACE];  // The orderly NV Index data\n\n// This value contains the current max counter value. It is written to the end of\n// allocatable NV space each time an index is deleted or added. This value is\n// initialized on Startup. The indices are searched and the maximum of all the\n// current counter indices and this value is the initial value for this.\nEXTERN UINT64 s_maxCounter;\n\n// This is space used for the NV Index cache. As with a persistent object, the\n// contents of a referenced index are copied into the cache so that the\n// NV Index memory scanning and data copying can be reduced.\n// Only code that operates on NV Index data should use this cache directly. When\n// that action code runs, s_lastNvIndex will contain the index header information.\n// It will have been loaded when the handles were verified.\n// NOTE: An NV index handle can appear in many commands that do not operate on the\n// NV data (e.g. TPM2_StartAuthSession). However, only one NV Index at a time is\n// ever directly referenced by any command. If that changes, then the NV Index\n// caching needs to be changed to accommodate that. Currently, the code will verify\n// that only one NV Index is referenced by the handles of the command.\nEXTERN NV_INDEX s_cachedNvIndex;\nEXTERN NV_REF   s_cachedNvRef;\nEXTERN BYTE*    s_cachedNvRamRef;\n\n// Initial NV Index/evict object iterator value\n#    define NV_REF_INIT (NV_REF)0xFFFFFFFF\n\n#  endif\n\n//*****************************************************************************\n//*** From Object.c\n//*****************************************************************************\n#  if defined OBJECT_C || defined GLOBAL_C\n// This type is the container for an object.\n\nEXTERN OBJECT s_objects[MAX_LOADED_OBJECTS];\n\n#  endif  // OBJECT_C\n\n//*****************************************************************************\n//*** From PCR.c\n//*****************************************************************************\n#  if defined PCR_C || defined GLOBAL_C\n#    include \"pcrstruct.h\"\n\nEXTERN PCR s_pcrs[IMPLEMENTATION_PCR];\n\n#  endif  // PCR_C\n\n//*****************************************************************************\n//*** From Session.c\n//*****************************************************************************\n#  if defined SESSION_C || defined GLOBAL_C\n// Container for HMAC or policy session tracking information\ntypedef struct\n{\n    BOOL    occupied;\n    SESSION session;  // session structure\n} SESSION_SLOT;\n\nEXTERN SESSION_SLOT s_sessions[MAX_LOADED_SESSIONS];\n\n//  The index in contextArray that has the value of the oldest saved session\n//  context. When no context is saved, this will have a value that is greater\n//  than or equal to MAX_ACTIVE_SESSIONS.\nEXTERN UINT32 s_oldestSavedSession;\n\n// The number of available session slot openings.  When this is 1,\n// a session can't be created or loaded if the GAP is maxed out.\n// The exception is that the oldest saved session context can always\n// be loaded (assuming that there is a space in memory to put it)\nEXTERN int s_freeSessionSlots;\n\n#  endif  // SESSION_C\n\n//*****************************************************************************\n//*** From IoBuffers.c\n//*****************************************************************************\n#  if defined IO_BUFFER_C || defined GLOBAL_C\n// Each command function is allowed a structure for the inputs to the function and\n// a structure for the outputs. The command dispatch code unmarshals the input butter\n// to the command action input structure starting at the first byte of\n// s_actionIoBuffer. The value of s_actionIoAllocation is the number of UINT64 values\n// allocated. It is used to set the pointer for the response structure. The command\n// dispatch code will marshal the response values into the final output buffer.\nEXTERN UINT64 s_actionIoBuffer[768];  // action I/O buffer\nEXTERN UINT32 s_actionIoAllocation;   // number of UIN64 allocated for the\n// action input structure\n#  endif                              // IO_BUFFER_C\n\n//*****************************************************************************\n//*** From TPMFail.c\n//*****************************************************************************\n// This value holds the address of the string containing the name of the function\n// in which the failure occurred. This address value is not useful for anything\n// other than helping the vendor to know in which file the failure  occurred.\nEXTERN BOOL g_inFailureMode;  // Indicates that the TPM is in failure mode\n#  if ALLOW_FORCE_FAILURE_MODE\nEXTERN BOOL g_forceFailureMode;  // flag to force failure mode during test\n#  endif\n\n#  if FAIL_TRACE\n// The name of the function that triggered failure mode.\nEXTERN const char* s_failFunctionName;\n#  endif  // FAIL_TRACE\n// A numeric indicator of the function that triggered failure mode.\nEXTERN UINT32 s_failFunction;\n// The line in the file at which the error was signaled.\nEXTERN UINT32 s_failLine;\n// the reason for the failure.\nEXTERN UINT32 s_failCode;\n\n//*****************************************************************************\n//*** From ACT_spt.c\n//*****************************************************************************\n// This value is used to indicate if an ACT has been updated since the last\n// TPM2_Startup() (one bit for each ACT). If the ACT is not updated\n// (TPM2_ACT_SetTimeout()) after a startup, then on each TPM2_Shutdown() the TPM will\n// save 1/2 of the current timer value. This prevents an attack on the ACT by saving\n// the counter and then running for a long period of time before doing a TPM Restart.\n// A quick TPM2_Shutdown() after each\nEXTERN UINT16 s_ActUpdated;\n\n//*****************************************************************************\n//*** From CommandCodeAttributes.c\n//*****************************************************************************\n// This array is instanced in CommandCodeAttributes.c when it includes\n// CommandCodeAttributes.h. Don't change the extern to EXTERN.\nextern const TPMA_CC            s_ccAttr[];\nextern const COMMAND_ATTRIBUTES s_commandAttributes[];\n\n#endif  // GLOBAL_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/GpMacros.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tThis file is a collection of miscellaneous macros.     \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file is a collection of miscellaneous macros.\n\n#ifndef GP_MACROS_H\n#define GP_MACROS_H\n\n#ifndef NULL\n#  define NULL 0\n#endif\n\n#include \"endian_swap.h\"\n#include \"VendorInfo.h\"\n\n//** For Self-test\n// These macros are used in CryptUtil to invoke the incremental self test.\n#if ENABLE_SELF_TESTS\n#  define TPM_DO_SELF_TEST(alg)              \\\n      do                                     \\\n      {                                      \\\n          if(TEST_BIT(alg, g_toTest))        \\\n              CryptTestAlgorithm(alg, NULL); \\\n      } while(0)\n#else\n#  define TPM_DO_SELF_TEST(alg)\n#endif  // ENABLE_SELF_TESTS\n\n//** For Failures\n#if defined _POSIX_\n#  define FUNCTION_NAME 0\n#else\n#  define FUNCTION_NAME __FUNCTION__\n#endif\n\n#if defined(FAIL_TRACE) && FAIL_TRACE != 0\n#  define CODELOCATOR() FUNCTION_NAME, __LINE__\n#else  // !FAIL_TRACE\n// if provided, use the definition of CODELOCATOR from TpmConfiguration so\n// implementor can customize this.\n#  ifndef CODELOCATOR\n#    define CODELOCATOR() 0\n#  endif\n#endif  // FAIL_TRACE\n\n\t// SETFAILED calls TpmFail.  It may or may not return based on the NO_LONGJMP flag.\n\t// CODELOCATOR is a macro that expands to either one 64-bit value that encodes the\n\t// location, or two parameters: Function Name and Line Number.\n#define SETFAILED(errorCode) (TpmFail(CODELOCATOR(), errorCode))\n\n// If implementation is using longjmp, then calls to TpmFail() will never\n// return.  However, without longjmp facility, TpmFail will return while most of\n// the code currently expects FAIL() calls to immediately abort the current\n// command. If they don't, some commands return success instead of failure.  The\n// family of macros below are provided to allow the code to be modified to\n// correctly propagate errors correctly, based on the context.\n//\n// * Some functions, particularly the ECC crypto have state cleanup at the end\n//   of the function and need to use the goto Exit pattern.\n// * Other functions return TPM_RC values, which should return TPM_RC_FAILURE\n// * Still other functions return an isOK boolean and need to return FALSE.\n//\n// if longjmp is available, all these macros just call SETFAILED and immediately\n// abort.  Note any of these approaches could leak memory if the crypto adapter\n// libraries are using dynamic memory.\n//\n// FAIL vs. FAIL_NORET\n// ===================\n// Be cautious with these macros.  FAIL_NORET is intended as an affirmation\n// that the upstream code calling the function using this macro has been\n// investigated to confirm that upstream functions correctly handle this\n// function putting the TPM into failure mode without returning an error.\n//\n// The TPM library was originally written with a lot of error checking omitted,\n// which means code occurring after a FAIL macro may not expect to be called\n// when the TPM is in failure mode.  When NO_LONGJMP is false (the system has a\n// longjmp API), then none of that code is executed because the sample platform\n// sets up longjmp before calling ExecuteCommand.  However, in the NO_LONGJMP\n// case, code following a FAIL or FAIL_NORET macro will get run.  The\n// conservative assumption is that code is untested and may be unsafe in such a\n// situation.  FAIL_NORET can replace FAIL when the code has been reviewed to\n// ensure the post-FAIL code is safe.  Of course, this is a point-in-time\n// assertion that is only true when the FAIL_NORET macro is first inserted;\n// hence it is better to use one of the early-exit macros to immediately return.\n// However, the necessary return-code plumbing may be large and FAIL/FAIL_NORET\n// are provided to support gradual improvement over time.\n\n#define NO_LONGJMP\n\n#ifndef NO_LONGJMP\n// has longjmp\n// necesary to reference Exit, even though the code is no-return\n#  define TPM_FAIL_RETURN NORETURN void\n\n// see discussion above about FAIL/FAIL_NORET\n#  define FAIL(failCode)                   SETFAILED(failCode)\n#  define FAIL_NORET(failCode)             SETFAILED(failCode)\n#  define FAIL_IMMEDIATE(failCode, retval) SETFAILED(failCode)\n#  define FAIL_BOOL(failCode)              SETFAILED(failCode)\n#  define FAIL_RC(failCode)                SETFAILED(failCode)\n#  define FAIL_VOID(failCode)              SETFAILED(failCode)\n#  define FAIL_NULL(failCode)              SETFAILED(failCode)\n#  define FAIL_EXIT(failCode, returnVar, returnCode)\t     \\\n    do\t\t\t\t\t\t\t\t     \\\n\t{\t\t\t\t\t\t\t     \\\n\t    SETFAILED(failCode);\t\t\t\t     \\\n\t    goto Exit;\t\t\t\t\t\t     \\\n\t} while(0)\n\n#else  // NO_LONGJMP\n// no longjmp service is available\n#  define TPM_FAIL_RETURN      void\n\n// This macro is provided for existing code and should not be used in new code.\n// see discussion above.\n#  define FAIL(failCode)       FAIL_NORET(failCode)\n\n// Be cautious with this macro, see discussion above.\n#  define FAIL_NORET(failCode) SETFAILED(failCode)\n\n// fail and immediately return void\n#  define FAIL_VOID(failCode)\t\t       \\\n    do\t\t\t\t\t\t       \\\n\t{\t\t\t\t\t       \\\n\t    SETFAILED(failCode);\t\t       \\\n\t    return;\t\t\t\t       \\\n\t} while(0)\n\n// fail and immediately return a value\n#  define FAIL_IMMEDIATE(failCode, retval)\t\t\t   \\\n    do\t\t\t\t\t\t\t\t   \\\n\t{\t\t\t\t\t\t\t\t\\\n\t    SETFAILED(failCode);\t\t\t\t\t\\\n\t    return retval;\t\t\t\t\t\t\\\n\t} while(0)\n\n// fail and return FALSE\n#  define FAIL_BOOL(failCode) FAIL_IMMEDIATE(failCode, FALSE)\n\n// fail and return TPM_RC_FAILURE\n#  define FAIL_RC(failCode)   FAIL_IMMEDIATE(failCode, TPM_RC_FAILURE)\n\n// fail and return NULL\n#  define FAIL_NULL(failCode) FAIL_IMMEDIATE(failCode, NULL)\n\n// fail and return using the goto exit pattern\n#  define FAIL_EXIT(failCode, returnVar, returnCode)\t\t\t\\\n    do\t\t\t\t\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\t\\\n\t    SETFAILED(failCode);\t\t\t\t\t\\\n\t    returnVar = returnCode;\t\t\t\t\t\\\n\t    goto Exit;\t\t\t\t\t\t\t\\\n\t} while(0)\n\n#endif\n\n// This macro tests that a condition is TRUE and puts the TPM into failure mode\n// if it is not. If longjmp is being used, then the macro makes a call from\n// which there is no return. Otherwise, the function will return the given\n// return code.\n#define VERIFY(condition, failCode, returnCode)\t\t\t\t\\\n    do\t\t\t\t\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\t\\\n\t    if(!(condition))\t\t\t\t\t\t\\\n\t\t{\t\t\t\t\t\t\t\\\n\t\t    FAIL_IMMEDIATE(failCode, returnCode);\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t} while(0)\n\n// this function also verifies a condition and enters failure mode, but sets a\n// return value and jumps to Exit on failure - allowing for cleanup.\n#define VERIFY_OR_EXIT(condition, failCode, returnVar, returnCode)\t\\\n    do\t\t\t\t\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\t\\\n\t    if(!(condition))\t\t\t\t\t\t\\\n\t\t{\t\t\t\t\t\t\t\\\n\t\t    FAIL_EXIT(failCode, returnVar, returnCode);\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t} while(0)\n\n// verify the given TPM_RC is success and we are not in\n// failure mode.  Otherwise, return immediately with TPM_RC_FAILURE.\n// note that failure mode is checked first so that an existing FATAL_* error code\n// is not overwritten with the default from this macro.\n#define VERIFY_RC(rc)\t\t\t\t\t\t\t\\\n    do\t\t\t\t\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\t\\\n\t    if(g_inFailureMode)\t\t\t\t\t\t\\\n\t\t{\t\t\t\t\t\t\t\\\n\t\t    return TPM_RC_FAILURE;\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t    if(rc != TPM_RC_SUCCESS)\t\t\t\t\t\\\n\t\t{\t\t\t\t\t\t\t\\\n\t\t    FAIL_IMMEDIATE(FATAL_ERROR_ASSERT, TPM_RC_FAILURE); \\\n\t\t}\t\t\t\t\t\t\t\\\n\t} while(0)\n\n// verify the TPM is not in failure mode or return failure\n#define VERIFY_NOT_FAILED()\t\t\t\t\t\t\\\n    do\t\t\t\t\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\t\\\n\t    if(g_inFailureMode)\t\t\t\t\t\t\\\n\t\t{\t\t\t\t\t\t\t\\\n\t\t    return TPM_RC_FAILURE;\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t} while(0)\n\n// Enter failure mode if the given TPM_RC is not success, return void.\n#define VERIFY_RC_VOID(rc)\t\t\t\t\t\t\\\n    do\t\t\t\t\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\t\\\n\t    if(g_inFailureMode)\t\t\t\t\t\t\\\n\t\t{\t\t\t\t\t\t\t\\\n\t\t    return;\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t    if(rc != TPM_RC_SUCCESS)\t\t\t\t\t\\\n\t\t{\t\t\t\t\t\t\t\\\n\t\t    FAIL_VOID(FATAL_ERROR_ASSERT);\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t} while(0)\n\n// These VERIFY_CRYPTO macros all set failure mode to FATAL_ERROR_CRYPTO\n// and immediately return.  The general way to parse the names is:\n// VERIFY_CRYPTO_[conditionType]_[OR_EXIT]_[retValType]\n// if conditionType is omitted, it is taken as BOOL.\n// Without OR_EXIT, implies an immediate return. Thus VERIFY_CRYPTO_BOOL:\n// 1. check fn against TRUE\n// 2. if false,  set failure mode to FATAL_ERROR_CRYPTO\n// 3. immediately return FALSE.\n// and, VERIFY_CRYPTO_OR_EXIT_RC translates to:\n// 1. Check a BOOL\n// 2. If false, set failure mode with FATAL_ERROR_CRYPTO,\n// 3. assume retVal is type TPM_RC, set it to TPM_RC_FAILURE\n// 4. Goto Exit\n// while VERIFY_CRYPTO_RC_OR_EXIT translates to:\n// 1. Check fn result against TPM_RC_SUCCESS\n// 2. if not equal, set failure mode to FATAL_ERROR_CRYPTO\n// 3. assume retVal is type TPM_RC, set it to TPM_RC_FAILURE\n// 4. Goto Exit.\n#define VERIFY_CRYPTO(fn) VERIFY((fn), FATAL_ERROR_CRYPTO, TPM_RC_FAILURE)\n\n#define VERIFY_CRYPTO_BOOL(fn) VERIFY((fn), FATAL_ERROR_CRYPTO, FALSE)\n\n#define VERIFY_CRYPTO_OR_NULL(fn) VERIFY((fn), FATAL_ERROR_CRYPTO, NULL)\n\n// these VERIFY_CRYPTO macros all set a result value and goto Exit\n#define VERIFY_CRYPTO_OR_EXIT(fn, returnVar, returnCode)\t\t\\\n    VERIFY_OR_EXIT(fn, FATAL_ERROR_CRYPTO, returnVar, returnCode);\n\n// these VERIFY_CRYPTO_OR_EXIT functions assume the return value variable is\n// named retVal\n#define VERIFY_CRYPTO_OR_EXIT_RC(fn)\t\t\t\t\t\\\n    VERIFY_CRYPTO_OR_EXIT_GENERIC(fn, retVal, TPM_RC_FAILURE)\n\n#define VERIFY_CRYPTO_OR_EXIT_FALSE(fn)\t\t\t\t\\\n    VERIFY_CRYPTO_OR_EXIT_GENERIC(fn, retVal, FALSE)\n\n#define VERIFY_CRYPTO_RC_OR_EXIT(fn)\t\t\t       \\\n    do\t\t\t\t\t\t\t       \\\n\t{\t\t\t\t\t\t\t       \\\n\t    TPM_RC rc = fn;\t\t\t\t\t       \\\n\t    if(rc != TPM_RC_SUCCESS)\t\t\t\t       \\\n\t\t{\t\t\t\t\t\t\t\\\n\t\t    FAIL_EXIT(FATAL_ERROR_CRYPTO, retVal, rc);\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t} while(0)\n\n#if(defined EMPTY_ASSERT) && (EMPTY_ASSERT != NO)\n#  define pAssert(a) ((void)0)\n#else\n#  define pAssert(a)\t\t\t\t\t   \\\n    do\t\t\t\t\t\t\t   \\\n\t{\t\t\t\t\t\t\t   \\\n\t    if(!(a))\t\t\t\t\t\t   \\\n\t\tFAIL(FATAL_ERROR_PARAMETER);\t\t\t   \\\n\t} while(0)\n\n#  define pAssert_ZERO(a)\t\t\t\t\t\t\\\n    do\t\t\t\t\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\t\\\n\t    if(!(a))\t\t\t\t\t\t\t\\\n\t\tFAIL_IMMEDIATE(FATAL_ERROR_ASSERT, 0);\t\t\t\\\n\t} while(0);\n\n#  define pAssert_RC(a)\t\t\t\t   \\\n    do\t\t\t\t\t\t   \\\n\t{\t\t\t\t\t\t   \\\n\t    if(!(a))\t\t\t\t\t   \\\n\t\tFAIL_RC(FATAL_ERROR_ASSERT);\t\t   \\\n\t} while(0);\n\n#  define pAssert_BOOL(a)\t\t\t     \\\n    do\t\t\t\t\t\t     \\\n\t{\t\t\t\t\t\t     \\\n\t    if(!(a))\t\t\t\t\t     \\\n\t\tFAIL_BOOL(FATAL_ERROR_ASSERT);\t\t     \\\n\t} while(0);\n\n#  define pAssert_NULL(a)\t\t\t     \\\n    do\t\t\t\t\t\t     \\\n\t{\t\t\t\t\t\t     \\\n\t    if(!(a))\t\t\t\t\t     \\\n\t\tFAIL_NULL(FATAL_ERROR_ASSERT);\t\t     \\\n\t} while(0);\n\n// using FAIL_NORET isn't optimium but is available in limited cases that\n// result in wrong calculated values, and can be checked later\n// but should have no vulnerability implications.\n#  define pAssert_NORET(a)\t\t\t      \\\n    {\t\t\t\t\t\t      \\\n\tif(!(a))\t\t\t\t\t      \\\n\t    FAIL_NORET(FATAL_ERROR_ASSERT);\t\t      \\\n    }\n\n// this macro is used where a calling code has been verified to function correctly\n// when the failing assert immediately returns without an error code.\n// this can be because either the caller checks the fatal error flag, or\n// the state is safe and a higher-level check will catch it.\n#  define pAssert_VOID_OK(a)\t\t\t     \\\n    {\t\t\t\t\t\t     \\\n\tif(!(a))\t\t\t\t\t     \\\n\t    FAIL_VOID(FATAL_ERROR_ASSERT);\t\t     \\\n    }\n\n#endif\n\n// These macros are commonly used in the \"Crypt\" code as a way to keep listings from\n// getting too long. This is not to save paper but to allow one to see more\n// useful stuff on the screen at any given time.  Neither macro sets failure mode.\n#define ERROR_EXIT(returnCode)\t       \\\n    do\t\t\t\t       \\\n\t{\t\t\t\t       \\\n\t    retVal = returnCode;\t       \\\n\t    goto Exit;\t\t\t       \\\n\t} while(0)\n\n// braces are necessary for this usage:\n// if (y)\n//     GOTO_ERROR_UNLESS(x)\n// else ...\n// without braces the else would attach to the GOTO macro instead of the\n// outer if statement; given the amount of TPM code that doesn't use braces on\n// if statements, this is a live risk.\n#define GOTO_ERROR_UNLESS(_X)\t\t      \\\n    do\t\t\t\t\t      \\\n\t{\t\t\t\t      \\\n\t    if(!(_X))\t\t\t\t      \\\n\t\tgoto Error;\t\t\t      \\\n\t} while(0)\n\n#include \"MinMax.h\"\n\n#ifndef IsOdd\n#  define IsOdd(a) (((a)&1) != 0)\n#endif\n\n#ifndef BITS_TO_BYTES\n#  define BITS_TO_BYTES(bits) (((bits) + 7) >> 3)\n#endif\n\n// These are defined for use when the size of the vector being checked is known\n// at compile time.\n#define TEST_BIT(bit, vector)  TestBit((bit), (BYTE*)&(vector), sizeof(vector))\n#define SET_BIT(bit, vector)   SetBit((bit), (BYTE*)&(vector), sizeof(vector))\n#define CLEAR_BIT(bit, vector) ClearBit((bit), (BYTE*)&(vector), sizeof(vector))\n\n// The following definitions are used if they have not already been defined. The\n// defaults for these settings are compatible with ISO/IEC 9899:2011 (E)\n#ifndef LIB_EXPORT\n#  define LIB_EXPORT\n#  define LIB_IMPORT\n#endif\n#ifndef NORETURN\n#  define NORETURN _Noreturn\n#endif\n#ifndef NOT_REFERENCED\n#  define NOT_REFERENCED(x = x) ((void)(x))\n#endif\n\n#define STD_RESPONSE_HEADER (sizeof(TPM_ST) + sizeof(UINT32) + sizeof(TPM_RC))\n\n// This bit is used to indicate that an authorization ticket expires on TPM Reset\n// and TPM Restart. It is added to the timeout value returned by TPM2_PoliySigned()\n// and TPM2_PolicySecret() and used by TPM2_PolicyTicket(). The timeout value is\n// relative to Time (g_time). Time is reset whenever the TPM loses power and cannot\n// be moved forward by the user (as can Clock). 'g_time' is a 64-bit value expressing\n// time in ms. Stealing the MSb for a flag means that the TPM needs to be reset\n// at least once every 292,471,208 years rather than once every 584,942,417 years.\n#define EXPIRATION_BIT ((UINT64)1 << 63)\n\n// Check for consistency of the bit ordering of bit fields\n#if BIG_ENDIAN_TPM && MOST_SIGNIFICANT_BIT_0 && USE_BIT_FIELD_STRUCTURES\n#  error \"Settings not consistent\"\n#endif\n\n// These macros are used to handle the variation in handling of bit fields. If\n#if USE_BIT_FIELD_STRUCTURES  // The default, old version, with bit fields\n#  define IS_ATTRIBUTE(a, type, b)    ((a.b) != 0)\n#  define SET_ATTRIBUTE(a, type, b)   (a.b = SET)\n#  define CLEAR_ATTRIBUTE(a, type, b) (a.b = CLEAR)\n#  define GET_ATTRIBUTE(a, type, b)   (a.b)\n#  define TPMA_ZERO_INITIALIZER()\t\t  \\\n    {\t\t\t\t\t\t\t  \\\n\t0\t\t\t\t\t\t  \\\n    }\n#else\n#  define IS_ATTRIBUTE(a, type, b)    ((a & type##_##b) != 0)\n#  define SET_ATTRIBUTE(a, type, b)   (a |= type##_##b)\n#  define CLEAR_ATTRIBUTE(a, type, b) (a &= ~type##_##b)\n#  define GET_ATTRIBUTE(a, type, b)   (type)((a & type##_##b) >> type##_##b##_SHIFT)\n#  define TPMA_ZERO_INITIALIZER()     (0)\n#endif\n\n// These macros determine if the values in this file are referenced or instanced.\n// Global.c defines GLOBAL_C so all the values in this file will be instanced in\n// Global.obj. For all other files that include this file, the values will simply\n// be external references. For constants, there can be an initializer.\n#ifndef EXTERN\n#  ifdef GLOBAL_C\n#    define EXTERN\n#  else\n#    define EXTERN extern\n#  endif\n#endif  // EXTERN\n\n#ifdef GLOBAL_C\n#  define INITIALIZER(_value_) = _value_\n#else\n#  define INITIALIZER(_value_)\n#endif\n\n// This macro will create an OID. All OIDs are in DER form with a first octet of\n// 0x06 indicating an OID fallowed by an octet indicating the number of octets in the\n// rest of the OID. This allows a user of this OID to know how much/little to copy.\n#define MAKE_OID(NAME) EXTERN const BYTE OID##NAME[] INITIALIZER({OID##NAME##_VALUE})\n\n// This definition is moved from TpmProfile.h because it is not actually vendor-\n// specific. It has to be the same size as the 'sequence' parameter of a TPMS_CONTEXT\n// and that is a UINT64. So, this is an invariant value\n#define CONTEXT_COUNTER UINT64\n\n#include \"TpmCalculatedAttributes.h\"\n\n#endif  // GP_MACROS_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/HMAC_Start_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: HMAC_Start_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef HMAC_START_FP_H\n#define HMAC_START_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\thandle;\n    TPM2B_AUTH\t\tauth;\n    TPMI_ALG_HASH\thashAlg;\n} HMAC_Start_In;\n\ntypedef struct {\n    TPMI_DH_OBJECT\tsequenceHandle;\n} HMAC_Start_Out;\n\n#define RC_HMAC_Start_handle\t(TPM_RC_H + TPM_RC_1)\n#define RC_HMAC_Start_auth\t(TPM_RC_P + TPM_RC_1)\n#define RC_HMAC_Start_hashAlg\t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_HMAC_Start(\n\t\tHMAC_Start_In   *in,            // IN: input parameter list\n\t\tHMAC_Start_Out  *out            // OUT: output parameter list\n\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/HMAC_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: HMAC_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef HMAC_FP_H\n#define HMAC_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\thandle;\n    TPM2B_MAX_BUFFER\tbuffer;\n    TPMI_ALG_HASH\thashAlg;\n} HMAC_In;\n\n#define RC_HMAC_handle \t\t(TPM_RC_H + TPM_RC_1)\n#define RC_HMAC_buffer\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_HMAC_hashAlg \t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM2B_DIGEST\toutHMAC;\n} HMAC_Out;\n\nTPM_RC\nTPM2_HMAC(\n\t  HMAC_In         *in,            // IN: input parameter list\n\t  HMAC_Out        *out            // OUT: output parameter list\n\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Handle_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 -2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef HANDLE_FP_H\n#define HANDLE_FP_H\n\nTPM_HT\nHandleGetType(\n\t      TPM_HANDLE       handle         // IN: a handle to be checked\n\t      );\nTPM_HANDLE\nNextPermanentHandle(\n\t\t    TPM_HANDLE       inHandle       // IN: the handle to check\n\t\t    );\nTPMI_YES_NO\nPermanentCapGetHandles(\n\t\t       TPM_HANDLE       handle,        // IN: start handle\n\t\t       UINT32           count,         // IN: count of returned handles\n\t\t       TPML_HANDLE     *handleList     // OUT: list of handle\n\t\t       );\nBOOL PermanentCapGetOneHandle(TPM_HANDLE handle  // IN: handle\n\t\t\t      );\nTPMI_YES_NO\nPermanentHandleGetPolicy(\n\t\t\t TPM_HANDLE           handle,        // IN: start handle\n\t\t\t UINT32               count,         // IN: count of returned handles\n\t\t\t TPML_TAGGED_POLICY  *policyList     // OUT: list of handle\n\t\t\t );\nBOOL PermanentHandleGetOnePolicy(TPM_HANDLE          handle,  // IN: handle\n\t\t\t\t TPMS_TAGGED_POLICY* policy   // OUT: tagged policy\n\t\t\t\t );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/HashSequenceStart_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: HashSequenceStart_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef HASHSEQUENCESTART_FP_H\n#define HASHSEQUENCESTART_FP_H\n\ntypedef struct {\n    TPM2B_AUTH\t\tauth;\n    TPMI_ALG_HASH\thashAlg;\n} HashSequenceStart_In;\n\n#define RC_HashSequenceStart_auth\t(TPM_RC_P + TPM_RC_1)\n#define RC_HashSequenceStart_hashAlg\t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPMI_DH_OBJECT\tsequenceHandle;\n} HashSequenceStart_Out;\n\n\n\nTPM_RC\nTPM2_HashSequenceStart(\n\t\t       HashSequenceStart_In    *in,            // IN: input parameter list\n\t\t       HashSequenceStart_Out   *out            // OUT: output parameter list\n\t\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/HashTestData.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Hash Test Vectors\t  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: HashTestData.h 1658 2021-01-22 23:14:01Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef HASHTESTDATA_H\n#define HASHTESTDATA_H\n\n/* 10.1.8 HashTestData.h */\n/* Hash Test Vectors */\nTPM2B_TYPE(HASH_TEST_KEY, 128); // Twice the largest digest size\nTPM2B_HASH_TEST_KEY        c_hashTestKey = {{128, {\n\t    0xa0,0xed,0x5c,0x9a,0xd2,0x4a,0x21,0x40,0x1a,0xd0,0x81,0x47,0x39,0x63,0xf9,0x50,\n\t    0xdc,0x59,0x47,0x11,0x40,0x13,0x99,0x92,0xc0,0x72,0xa4,0x0f,0xe2,0x33,0xe4,0x63,\n\t    0x9b,0xb6,0x76,0xc3,0x1e,0x6f,0x13,0xee,0xcc,0x99,0x71,0xa5,0xc0,0xcf,0x9a,0x40,\n\t    0xcf,0xdb,0x66,0x70,0x05,0x63,0x54,0x12,0x25,0xf4,0xe0,0x1b,0x23,0x35,0xe3,0x70,\n\t    0x7d,0x19,0x5f,0x00,0xe4,0xf1,0x61,0x73,0x05,0xd8,0x58,0x7f,0x60,0x61,0x84,0x36,\n\t    0xec,0xbe,0x96,0x1b,0x69,0x00,0xf0,0x9a,0x6e,0xe3,0x26,0x73,0x0d,0x17,0x5b,0x33,\n\t    0x41,0x44,0x9d,0x90,0xab,0xd9,0x6b,0x7d,0x48,0x99,0x25,0x93,0x29,0x14,0x2b,0xce,\n\t    0x93,0x8d,0x8c,0xaf,0x31,0x0e,0x9c,0x57,0xd8,0x5b,0x57,0x20,0x1b,0x9f,0x2d,0xa5\n\t}}};\n\nTPM2B_TYPE(HASH_TEST_DATA, 256); // Twice the largest block size\nTPM2B_HASH_TEST_DATA       c_hashTestData = {{256, {\n\t    0x88,0xac,0xc3,0xe5,0x5f,0x66,0x9d,0x18,0x80,0xc9,0x7a,0x9c,0xa4,0x08,0x90,0x98,\n\t    0x0f,0x3a,0x53,0x92,0x4c,0x67,0x4e,0xb7,0x37,0xec,0x67,0x87,0xb6,0xbe,0x10,0xca,\n\t    0x11,0x5b,0x4a,0x0b,0x45,0xc3,0x32,0x68,0x48,0x69,0xce,0x25,0x1b,0xc8,0xaf,0x44,\n\t    0x79,0x22,0x83,0xc8,0xfb,0xe2,0x63,0x94,0xa2,0x3c,0x59,0x3e,0x3e,0xc6,0x64,0x2c,\n\t    0x1f,0x8c,0x11,0x93,0x24,0xa3,0x17,0xc5,0x2f,0x37,0xcf,0x95,0x97,0x8e,0x63,0x39,\n\t    0x68,0xd5,0xca,0xba,0x18,0x37,0x69,0x6e,0x4f,0x19,0xfd,0x8a,0xc0,0x8d,0x87,0x3a,\n\t    0xbc,0x31,0x42,0x04,0x05,0xef,0xb5,0x02,0xef,0x1e,0x92,0x4b,0xb7,0x73,0x2c,0x8c,\n\t    0xeb,0x23,0x13,0x81,0x34,0xb9,0xb5,0xc1,0x17,0x37,0x39,0xf8,0x3e,0xe4,0x4c,0x06,\n\t    0xa8,0x81,0x52,0x2f,0xef,0xc9,0x9c,0x69,0x89,0xbc,0x85,0x9c,0x30,0x16,0x02,0xca,\n\t    0xe3,0x61,0xd4,0x0f,0xed,0x34,0x1b,0xca,0xc1,0x1b,0xd1,0xfa,0xc1,0xa2,0xe0,0xdf,\n\t    0x52,0x2f,0x0b,0x4b,0x9f,0x0e,0x45,0x54,0xb9,0x17,0xb6,0xaf,0xd6,0xd5,0xca,0x90,\n\t    0x29,0x57,0x7b,0x70,0x50,0x94,0x5c,0x8e,0xf6,0x4e,0x21,0x8b,0xc6,0x8b,0xa6,0xbc,\n\t    0xb9,0x64,0xd4,0x4d,0xf3,0x68,0xd8,0xac,0xde,0xd8,0xd8,0xb5,0x6d,0xcd,0x93,0xeb,\n\t    0x28,0xa4,0xe2,0x5c,0x44,0xef,0xf0,0xe1,0x6f,0x38,0x1a,0x3c,0xe6,0xef,0xa2,0x9d,\n\t    0xb9,0xa8,0x05,0x2a,0x95,0xec,0x5f,0xdb,0xb0,0x25,0x67,0x9c,0x86,0x7a,0x8e,0xea,\n\t    0x51,0xcc,0xc3,0xd3,0xff,0x6e,0xf0,0xed,0xa3,0xae,0xf9,0x5d,0x33,0x70,0xf2,0x11\n\t}}};\n#if ALG_SHA1 == YES\nTPM2B_TYPE(SHA1, 20);\nTPM2B_SHA1    c_SHA1_digest = {{20, {\n\t    0xee,0x2c,0xef,0x93,0x76,0xbd,0xf8,0x91,0xbc,0xe6,0xe5,0x57,0x53,0x77,0x01,0xb5,\n\t    0x70,0x95,0xe5,0x40\n\t}}};\n#endif\n#if ALG_SHA256 == YES\nTPM2B_TYPE(SHA256, 32);\nTPM2B_SHA256    c_SHA256_digest = {{32, {\n\t    0x64,0xe8,0xe0,0xc3,0xa9,0xa4,0x51,0x49,0x10,0x55,0x8d,0x31,0x71,0xe5,0x2f,0x69,\n\t    0x3a,0xdc,0xc7,0x11,0x32,0x44,0x61,0xbd,0x34,0x39,0x57,0xb0,0xa8,0x75,0x86,0x1b\n\t}}};\n#endif\n#if ALG_SHA384 == YES\nTPM2B_TYPE(SHA384, 48);\nTPM2B_SHA384    c_SHA384_digest = {{48, {\n\t    0x37,0x75,0x29,0xb5,0x20,0x15,0x6e,0xa3,0x7e,0xa3,0x0d,0xcd,0x80,0xa8,0xa3,0x3d,\n\t    0xeb,0xe8,0xad,0x4e,0x1c,0x77,0x94,0x5a,0xaf,0x6c,0xd0,0xc1,0xfa,0x43,0x3f,0xc7,\n\t    0xb8,0xf1,0x01,0xc0,0x60,0xbf,0xf2,0x87,0xe8,0x71,0x9e,0x51,0x97,0xa0,0x09,0x8d\n\t}}};\n#endif\n#if ALG_SHA512 == YES\nTPM2B_TYPE(SHA512, 64);\nTPM2B_SHA512    c_SHA512_digest = {{64, {\n\t    0xe2,0x7b,0x10,0x3d,0x5e,0x48,0x58,0x44,0x67,0xac,0xa3,0x81,0x8c,0x1d,0xc5,0x71,\n\t    0x66,0x92,0x8a,0x89,0xaa,0xd4,0x35,0x51,0x60,0x37,0x31,0xd7,0xba,0xe7,0x93,0x0b,\n\t    0x16,0x4d,0xb3,0xc8,0x34,0x98,0x3c,0xd3,0x53,0xde,0x5e,0xe8,0x0c,0xbc,0xaf,0xc9,\n\t    0x24,0x2c,0xcc,0xed,0xdb,0xde,0xba,0x1f,0x14,0x14,0x5a,0x95,0x80,0xde,0x66,0xbd\n\t}}};\n#endif\n\nTPM2B_TYPE(EMPTY, 1);\n\n#if ALG_SM3_256 == YES\nTPM2B_EMPTY c_SM3_256_digest = {{0, {0}}};\n#endif\n\n#if ALG_SHA3_256 == YES\nTPM2B_EMPTY c_SHA3_256_digest = {{0, {0}}};\n#endif\n\n#if ALG_SHA3_384 == YES\nTPM2B_EMPTY c_SHA3_384_digest = {{0, {0}}};\n#endif\n\n#if ALG_SHA3_512 == YES\nTPM2B_EMPTY c_SHA3_512_digest = {{0, {0}}};\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Hash_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Hash_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef HASH_FP_H\n#define HASH_FP_H\n\ntypedef struct {\n    TPM2B_MAX_BUFFER\tdata;\n    TPMI_ALG_HASH\thashAlg;\n    TPMI_RH_HIERARCHY\thierarchy;\n} Hash_In;\n\n#define RC_Hash_data\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_Hash_hashAlg\t\t(TPM_RC_P + TPM_RC_2)\n#define RC_Hash_hierarchy\t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPM2B_DIGEST\toutHash;\n    TPMT_TK_HASHCHECK\tvalidation;\n} Hash_Out;\n\nTPM_RC\nTPM2_Hash(\n\t  Hash_In         *in,            // IN: input parameter list\n\t  Hash_Out        *out            // OUT: output parameter list\n\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/HierarchyChangeAuth_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: HierarchyChangeAuth_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef HIERARCHYCHANGEAUTH_FP_H\n#define HIERARCHYCHANGEAUTH_FP_H\n\ntypedef struct {\n    TPMI_RH_HIERARCHY_AUTH\tauthHandle;\n    TPM2B_AUTH\t\t\tnewAuth;\n} HierarchyChangeAuth_In;\n\n#define RC_HierarchyChangeAuth_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_HierarchyChangeAuth_newAuth \t\t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_HierarchyChangeAuth(\n\t\t\t HierarchyChangeAuth_In  *in             // IN: input parameter list\n\t\t\t );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/HierarchyControl_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: HierarchyControl_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef HIERARCHYCONTROL_FP_H\n#define HIERARCHYCONTROL_FP_H\n\ntypedef struct {\n    TPMI_RH_HIERARCHY\tauthHandle;\n    TPMI_RH_ENABLES\tenable;\n    TPMI_YES_NO\t\tstate;\n} HierarchyControl_In;\n\n#define RC_HierarchyControl_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_HierarchyControl_enable\t(TPM_RC_P + TPM_RC_1)\n#define RC_HierarchyControl_state\t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_HierarchyControl(\n\t\t      HierarchyControl_In     *in             // IN: input parameter list\n\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Hierarchy_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Apr  2, 2019  Time: 04:23:27PM\n */\n\n#ifndef _HIERARCHY_FP_H_\n#define _HIERARCHY_FP_H_\n\n//*** HierarchyPreInstall()\n// This function performs the initialization functions for the hierarchy\n// when the TPM is simulated. This function should not be called if the\n// TPM is not in a manufacturing mode at the manufacturer, or in a simulated\n// environment.\nvoid HierarchyPreInstall_Init(void);\n\n//*** HierarchyStartup()\n// This function is called at TPM2_Startup() to initialize the hierarchy\n// related values.\nBOOL HierarchyStartup(STARTUP_TYPE type  // IN: start up type\n\t\t      );\n\n//*** HierarchyGetProof()\n// This function derives the proof value associated with a hierarchy. It returns a\n// buffer containing the proof value.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects or the TPM failed\n//                              to derive the Firmware Secret.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the TPM failed\n//                              to derive the Firmware SVN Secret for the requested\n//                              SVN.\nTPM_RC HierarchyGetProof(TPMI_RH_HIERARCHY hierarchy,  // IN: hierarchy constant\n\t\t\t TPM2B_PROOF*      proof       // OUT: proof buffer\n\t\t\t );\n\n//*** HierarchyGetPrimarySeed()\n// This function derives the primary seed of a hierarchy.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects or the TPM failed\n//                              to derive the Firmware Secret.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the TPM failed\n//                              to derive the Firmware SVN Secret for the requested\n//                              SVN.\nTPM_RC HierarchyGetPrimarySeed(TPMI_RH_HIERARCHY hierarchy,  // IN: hierarchy\n\t\t\t       TPM2B_SEED*       seed        // OUT: seed buffer\n\t\t\t       );\n\n//*** ValidateHierarchy()\n// This function ensures a given hierarchy is valid and enabled.\n//  Return Type: TPM_RC\n//      TPM_RC_HIERARCHY        Hierarchy is disabled\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the given SVN\n//                              is greater than the TPM's current SVN.\n//      TPM_RC_VALUE            Hierarchy is not valid\nTPM_RC ValidateHierarchy(TPMI_RH_HIERARCHY hierarchy  // IN: hierarchy\n\t\t\t );\n\n//*** HierarchyIsEnabled()\n// This function checks to see if a hierarchy is enabled.\n// NOTE: The TPM_RH_NULL hierarchy is always enabled.\n//  Return Type: BOOL\n//      TRUE(1)         hierarchy is enabled\n//      FALSE(0)        hierarchy is disabled\nBOOL HierarchyIsEnabled(TPMI_RH_HIERARCHY hierarchy  // IN: hierarchy\n\t\t\t);\n\n//*** HierarchyNormalizeHandle\n// This function accepts a handle that may or may not be FW- or SVN-bound,\n// and returns the base hierarchy to which the handle refers.\nTPMI_RH_HIERARCHY HierarchyNormalizeHandle(TPMI_RH_HIERARCHY handle  // IN\n\t\t\t\t\t   );\n\n//*** HierarchyIsFirmwareLimited\n// This function accepts a hierarchy handle and returns whether it is firmware-\n// limited.\nBOOL HierarchyIsFirmwareLimited(TPMI_RH_HIERARCHY handle  // IN\n\t\t\t\t);\n\n//*** HierarchyIsSvnLimited\n// This function accepts a hierarchy handle and returns whether it is SVN-\n// limited.\nBOOL HierarchyIsSvnLimited(TPMI_RH_HIERARCHY handle  // IN\n\t\t\t   );\n\n#endif  // _HIERARCHY_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Import_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Import_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef IMPORT_FP_H\n#define IMPORT_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tparentHandle;\n    TPM2B_DATA\t\t\tencryptionKey;\n    TPM2B_PUBLIC\t\tobjectPublic;\n    TPM2B_PRIVATE\t\tduplicate;\n    TPM2B_ENCRYPTED_SECRET\tinSymSeed;\n    TPMT_SYM_DEF_OBJECT\t\tsymmetricAlg;\n} Import_In;\n\n#define RC_Import_parentHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_Import_encryptionKey\t(TPM_RC_P + TPM_RC_1)\n#define RC_Import_objectPublic \t(TPM_RC_P + TPM_RC_2)\n#define RC_Import_duplicate \t(TPM_RC_P + TPM_RC_3)\n#define RC_Import_inSymSeed \t(TPM_RC_P + TPM_RC_4)\n#define RC_Import_symmetricAlg\t(TPM_RC_P + TPM_RC_5)\n\ntypedef struct {\n    TPM2B_PRIVATE\toutPrivate;\n} Import_Out;\n\nTPM_RC\nTPM2_Import(\n\t    Import_In       *in,            // IN: input parameter list\n\t    Import_Out      *out            // OUT: output parameter list\n\t    );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/IncrementalSelfTest_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: IncrementalSelfTest_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef INCREMENTALSELFTEST_FP_H\n#define INCREMENTALSELFTEST_FP_H\n\ntypedef struct{\n    TPML_ALG\ttoTest;\n} IncrementalSelfTest_In;\n\ntypedef struct{\n    TPML_ALG\ttoDoList;\n} IncrementalSelfTest_Out;  \n\n#define RC_IncrementalSelfTest_toTest (TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_IncrementalSelfTest(\n\t\t\t IncrementalSelfTest_In      *in,            // IN: input parameter list\n\t\t\t IncrementalSelfTest_Out     *out            // OUT: output parameter list\n\t\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/InternalRoutines.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tInclude Headers for Internal Routines\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: InternalRoutines.h 1594 2020-03-26 22:15:48Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef INTERNALROUTINES_H\n#define INTERNALROUTINES_H\n\n#if !defined _LIB_SUPPORT_H_ && !defined _TPM_H_\n#error \"Should not be called\"\n#endif\n/* DRTM functions */\n#include \"_TPM_Hash_Start_fp.h\"\n#include \"_TPM_Hash_Data_fp.h\"\n#include \"_TPM_Hash_End_fp.h\"\n/* Internal subsystem functions */\n#include \"Object_fp.h\"\n#include \"Context_spt_fp.h\"\n#include \"Object_spt_fp.h\"\n#include \"Entity_fp.h\"\n#include \"Session_fp.h\"\n#include \"Hierarchy_fp.h\"\n#include \"NVReserved_fp.h\"\n#include \"NVDynamic_fp.h\"\n#include \"NV_spt_fp.h\"\n#include \"ACT_spt_fp.h\"\n#include \"PCR_fp.h\"\n#include \"DA_fp.h\"\n#include \"TpmFail_fp.h\"\n#include \"SessionProcess_fp.h\"\n/* Internal support functions */\n#include \"CommandCodeAttributes_fp.h\"\n#include \"Marshal_fp.h\"\n#include \"Unmarshal_fp.h\"\t/* kgold */\n#include \"Time_fp.h\"\n#include \"Locality_fp.h\"\n#include \"PP_fp.h\"\n#include \"CommandAudit_fp.h\"\n#include \"Manufacture_fp.h\"\n#include \"Handle_fp.h\"\n#include \"Power_fp.h\"\n#include \"Response_fp.h\"\n#include \"CommandDispatcher_fp.h\"\n#if CC_AC_Send\n#   include \"AC_spt_fp.h\"\n#endif // CC_AC_Send\n/* Miscellaneous */\n#include \"Bits_fp.h\"\n#include \"AlgorithmCap_fp.h\"\n#include \"PropertyCap_fp.h\"\n#include \"IoBuffers_fp.h\"\n#include \"Memory_fp.h\"\n#include \"ResponseCodeProcessing_fp.h\"\n/* Internal cryptographic functions */\n#include \"BnConvert_fp.h\"\n#include \"BnMath_fp.h\"\n#include \"BnMemory_fp.h\"\n#include \"Ticket_fp.h\"\n#include \"CryptUtil_fp.h\"\n#include \"CryptHash_fp.h\"\n#include \"CryptSym_fp.h\"\n#include \"CryptDes_fp.h\"\n#include \"CryptPrime_fp.h\"\n#include \"CryptRand_fp.h\"\n#include \"CryptSelfTest_fp.h\"\n#include \"MathOnByteBuffers_fp.h\"\n#include \"CryptSym_fp.h\"\n#include \"AlgorithmTests_fp.h\"\n#if ALG_RSA\n#include \"CryptRsa_fp.h\"\n#include \"CryptPrimeSieve_fp.h\"\n#endif\n#if ALG_ECC\n#include \"CryptEccMain_fp.h\"\n#include \"CryptEccSignature_fp.h\"\n#include \"CryptEccKeyExchange_fp.h\"\n#include \"CryptEccCrypt_fp.h\"\n#endif\n#if CC_MAC || CC_MAC_Start\n#   include \"CryptSmac_fp.h\"\n#   if ALG_CMAC\n#       include \"CryptCmac_fp.h\"\n#   endif\n#endif\n// Asymmetric Support library Interface\n// TODO_RENAME_INC_FOLDER: needs a component prefix\n#include \"MathLibraryInterface.h\"\n\n// Linkage to platform functions\n// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface\n#include \"tpm_to_platform_interface.h\"\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/IoBuffers_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    I/O Buffers\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: IoBuffers_fp.h 1259 2018-07-10 19:11:09Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef IOBUFFERS_FP_H\n#define IOBUFFERS_FP_H\n\nvoid\nMemoryIoBufferAllocationReset(\n\t\t\t      void\n\t\t\t      );\nvoid\nMemoryIoBufferZero(\n\t\t   void\n\t\t   );\nBYTE *\nMemoryGetInBuffer(\n\t\t  UINT32           size           // Size, in bytes, required for the input\n\t\t  // unmarshaling\n\t\t  );\nBYTE *\nMemoryGetOutBuffer(\n\t\t   UINT32           size           // required size of the buffer\n\t\t   );\nBOOL\nIsLabelProperlyFormatted(\n\t\t\t TPM2B           *x\n\t\t\t );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/KdfTestData.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\tHash Test Vectors \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: KdfTestData.h 1311 2018-08-23 21:39:29Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//\n// Hash Test Vectors\n//\n\n#define TEST_KDF_KEY_SIZE   20\nTPM2B_TYPE(KDF_TEST_KEY, TEST_KDF_KEY_SIZE);\nTPM2B_KDF_TEST_KEY      c_kdfTestKeyIn = {{TEST_KDF_KEY_SIZE, {\n\t    0x27, 0x1F, 0xA0, 0x8B, 0xBD, 0xC5, 0x06, 0x0E, 0xC3, 0xDF,\n\t    0xA9, 0x28, 0xFF, 0x9B, 0x73, 0x12, 0x3A, 0x12, 0xDA, 0x0C }}};\nTPM2B_TYPE(KDF_TEST_LABEL, 17);\nTPM2B_KDF_TEST_LABEL    c_kdfTestLabel = {{17, {\n\t    0x4B, 0x44, 0x46, 0x53, 0x45, 0x4C, 0x46, 0x54,\n\t    0x45, 0x53, 0x54, 0x4C, 0x41, 0x42, 0x45, 0x4C, 0x00 }}};\nTPM2B_TYPE(KDF_TEST_CONTEXT, 8);\nTPM2B_KDF_TEST_CONTEXT  c_kdfTestContextU = {{8, {\n\t    0xCE, 0x24, 0x4F, 0x39, 0x5D, 0xCA, 0x73, 0x91 }}};\nTPM2B_KDF_TEST_CONTEXT  c_kdfTestContextV = {{8, {\n\t    0xDA, 0x50, 0x40, 0x31, 0xDD, 0xF1, 0x2E, 0x83 }}};\n#if ALG_SHA512 == ALG_YES\nTPM2B_KDF_TEST_KEY  c_kdfTestKeyOut = {{20, {\n\t    0x8b, 0xe2, 0xc1, 0xb8, 0x5b, 0x78, 0x56, 0x9b, 0x9f, 0xa7,\n\t    0x59, 0xf5, 0x85, 0x7c, 0x56, 0xd6, 0x84, 0x81, 0x0f, 0xd3 }}};\n#define KDF_TEST_ALG    TPM_ALG_SHA512\n#elif ALG_SHA384 == ALG_YES\nTPM2B_KDF_TEST_KEY  c_kdfTestKeyOut = {{20, {\n\t    0x1d, 0xce, 0x70, 0xc9, 0x11, 0x3e, 0xb2, 0xdb, 0xa4, 0x7b,\n\t    0xd9, 0xcf, 0xc7, 0x2b, 0xf4, 0x6f, 0x45, 0xb0, 0x93, 0x12 }}};\n#define KDF_TEST_ALG    TPM_ALG_SHA384\n#elif ALG_SHA256 == ALG_YES\nTPM2B_KDF_TEST_KEY  c_kdfTestKeyOut = {{20, {\n\t    0xbb, 0x02, 0x59, 0xe1, 0xc8, 0xba, 0x60, 0x7e, 0x6a, 0x2c,\n\t    0xd7, 0x04, 0xb6, 0x9a, 0x90, 0x2e, 0x9a, 0xde, 0x84, 0xc4 }}};\n#define KDF_TEST_ALG    TPM_ALG_SHA256\n#elif ALG_SHA1 == ALG_YES\nTPM2B_KDF_TEST_KEY  c_kdfTestKeyOut = {{20, {\n\t    0x55, 0xb5, 0xa7, 0x18, 0x4a, 0xa0, 0x74, 0x23, 0xc4, 0x7d,\n\t    0xae, 0x76, 0x6c, 0x26, 0xa2, 0x37, 0x7d, 0x7c, 0xf8, 0x51 }}};\n#define KDF_TEST_ALG    TPM_ALG_SHA1\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/LibSupport.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t select the library code that gets included in the TPM build \t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This header file is used to select the library code that gets included in the\n// TPM build.\n\n#ifndef _LIB_SUPPORT_H_\n#define _LIB_SUPPORT_H_\n// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers\n#include \"tpm_radix.h\"\n\n// Include the options for hashing and symmetric. Defer the load of the math package\n// Until the bignum parameters are defined.\n#ifndef SYM_LIB\n#  error SYM_LIB required\n#endif\n#ifndef HASH_LIB\n#  error HASH_LIB required\n#endif\n\n#include LIB_INCLUDE(TpmTo, SYM_LIB, Sym)\n#include LIB_INCLUDE(TpmTo, HASH_LIB, Hash)\n\n//TODO: was #undef MIN\n//was #undef MAX\n\n#endif  // _LIB_SUPPORT_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/LoadExternal_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: LoadExternal_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef LOADEXTERNAL_FP_H\n#define LOADEXTERNAL_FP_H\n\ntypedef struct {\n    TPM2B_SENSITIVE\tinPrivate;\n    TPM2B_PUBLIC\tinPublic;\n    TPMI_RH_HIERARCHY\thierarchy;\n} LoadExternal_In;    \n\n#define RC_LoadExternal_inPrivate\t(TPM_RC_P + TPM_RC_1)\n#define RC_LoadExternal_inPublic \t(TPM_RC_P + TPM_RC_2)\n#define RC_LoadExternal_hierarchy \t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPM_HANDLE\t\tobjectHandle;\n    TPM2B_NAME\t\tname;\n} LoadExternal_Out;\n\nTPM_RC\nTPM2_LoadExternal(\n\t\t  LoadExternal_In     *in,            // IN: input parameter list\n\t\t  LoadExternal_Out    *out            // OUT: output parameter list\n\t\t  );\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Load_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Load_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef LOAD_FP_H\n#define LOAD_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tparentHandle;\n    TPM2B_PRIVATE\tinPrivate;\n    TPM2B_PUBLIC\tinPublic;\n} Load_In;\n\n#define RC_Load_parentHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_Load_inPrivate \t(TPM_RC_P + TPM_RC_1)\n#define RC_Load_inPublic\t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM_HANDLE\tobjectHandle;\n    TPM2B_NAME\tname;\n} Load_Out;\n\nTPM_RC\nTPM2_Load(\n\t  Load_In         *in,            // IN: input parameter list\n\t  Load_Out        *out            // OUT: output parameter list\n\t  );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Locality_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Locality_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef LOCALITY_FP_H\n#define LOCALITY_FP_H\n\nTPMA_LOCALITY\nLocalityGetAttributes(\n\t\t      UINT8            locality       // IN: locality value\n\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/MAC_Start_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: MAC_Start_fp.h 1047 2017-07-20 18:27:34Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2017\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 146 */\n\n#ifndef MAC_START_FP_H\n#define MAC_START_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\thandle;\n    TPM2B_AUTH\t\tauth;\n    TPMI_ALG_MAC_SCHEME\tinScheme;\n} MAC_Start_In;\n\ntypedef struct {\n    TPMI_DH_OBJECT\tsequenceHandle;\n} MAC_Start_Out;\n\n#define RC_MAC_Start_handle\t(TPM_RC_H + TPM_RC_1)\n#define RC_MAC_Start_auth\t(TPM_RC_P + TPM_RC_1)\n#define RC_MAC_Start_inScheme\t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_MAC_Start(\n\t\tMAC_Start_In   *in,            // IN: input parameter list\n\t\tMAC_Start_Out  *out            // OUT: output parameter list\n\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/MAC_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: MAC_fp.h 1259 2018-07-10 19:11:09Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef MAC_FP_H\n#define MAC_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\thandle;\n    TPM2B_MAX_BUFFER\t\tbuffer;\n    TPMI_ALG_MAC_SCHEME\t\tinScheme;\n} MAC_In;\n\n#define RC_MAC_handle \t\t(TPM_RC_H + TPM_RC_1)\n#define RC_MAC_buffer\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_MAC_inScheme\t\t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM2B_MAX_BUFFER\toutMAC;\n} MAC_Out;\n\nTPM_RC\nTPM2_MAC(\n\t\t    MAC_In   *in,            // IN: input parameter list\n\t\t    MAC_Out  *out            // OUT: output parameter list\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/MakeCredential_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: MakeCredential_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef MAKECREDENTIAL_FP_H\n#define MAKECREDENTIAL_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\thandle;\n    TPM2B_DIGEST\tcredential;\n    TPM2B_NAME\t\tobjectName;\n} MakeCredential_In;\n\n#define RC_MakeCredential_handle \t(TPM_RC_H + TPM_RC_1)\n#define RC_MakeCredential_credential \t(TPM_RC_P + TPM_RC_1)\n#define RC_MakeCredential_objectName\t(TPM_RC_P + TPM_RC_2)\n\n\ntypedef struct {\n    TPM2B_ID_OBJECT\tcredentialBlob;\n    TPM2B_ENCRYPTED_SECRET\tsecret;\n} MakeCredential_Out;\n\nTPM_RC\nTPM2_MakeCredential(\n\t\t    MakeCredential_In   *in,            // IN: input parameter list\n\t\t    MakeCredential_Out  *out            // OUT: output parameter list\n\t\t    );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Manufacture_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tPerforms the manufacturing of the TPM\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _MANUFACTURE_FP_H_\n#define _MANUFACTURE_FP_H_\n\n//*** TPM_Manufacture()\n// This function initializes the TPM values in preparation for the TPM's first\n// use. This function will fail if previously called. The TPM can be re-manufactured\n// by calling TPM_Teardown() first and then calling this function again.\n// NV must be enabled first (typically with NvPowerOn() via _TPM_Init)\n//\n// return type: int\n//      -2          NV System not available\n//      -1          FAILURE - System is incorrectly compiled.\n//      0           success\n//      1           manufacturing process previously performed\n// returns\n#define MANUF_NV_NOT_READY   (-2)\n#define MANUF_INVALID_CONFIG (-1)\n#define MANUF_OK             0\n#define MANUF_ALREADY_DONE   1\n// params\n#define MANUF_FIRST_TIME    1\n#define MANUF_REMANUFACTURE 0\nLIB_EXPORT int TPM_Manufacture(\n\t\t\t       int firstTime  // IN: indicates if this is the first call from\n\t\t\t       //     main()\n\t\t\t       );\n\n//*** TPM_TearDown()\n// This function prepares the TPM for re-manufacture. It should not be implemented\n// in anything other than a simulated TPM.\n//\n// In this implementation, all that is needs is to stop the cryptographic units\n// and set a flag to indicate that the TPM can be re-manufactured. This should\n// be all that is necessary to start the manufacturing process again.\n//  Return Type: int\n//      0        success\n//      1        TPM not previously manufactured\n#define TEARDOWN_OK          0\n#define TEARDOWN_NOTHINGDONE 1\nLIB_EXPORT int TPM_TearDown(void);\n\n//*** TpmEndSimulation()\n// This function is called at the end of the simulation run. It is used to provoke\n// printing of any statistics that might be needed.\nLIB_EXPORT void TpmEndSimulation(void);\n\n#endif  // _MANUFACTURE_FP_H_\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Marshal.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file is used to provide the things needed by a module that uses the marshaling\n// functions. It handles the variations between the marshaling choices (procedural or\n// table-driven).\n\n#if TABLE_DRIVEN_MARSHAL\n\n#  include \"TableMarshalTypes.h\"\n\n#  include \"TableMarshalDefines.h\"\n\n#  include \"TableDrivenMarshal_fp.h\"\n\n#else\n\n#  include \"Marshal_fp.h\"\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Marshal_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Parameter Marshaling  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef MARSHAL_FP_H\n#define MARSHAL_FP_H\n\n#include \"TpmTypes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n    UINT16\n    UINT8_Marshal(UINT8 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    UINT16_Marshal(UINT16 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    UINT32_Marshal(UINT32 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    UINT64_Marshal(UINT64 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    Array_Marshal(BYTE *sourceBuffer, UINT16 sourceSize, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_Marshal(TPM2B *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_KEY_BITS_Marshal(TPM_KEY_BITS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_CONSTANTS32_Marshal(TPM_CONSTANTS32 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_ALG_ID_Marshal(TPM_ALG_ID *source, BYTE **buffer, INT32 *size);    \n    UINT16\n    TPM_ECC_CURVE_Marshal(TPM_ECC_CURVE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_CC_Marshal(TPM_CC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_RC_Marshal(TPM_RC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_ST_Marshal(TPM_ST *source, BYTE **buffer, INT32 *size);\n    INT16\n    TPM_CAP_Marshal(TPM_CAP *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_PT_Marshal(TPM_PT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_PT_PCR_Marshal(TPM_PT_PCR *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_HANDLE_Marshal(TPM_HANDLE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMA_ALGORITHM_Marshal(TPMA_ALGORITHM *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMA_OBJECT_Marshal(TPMA_OBJECT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMA_SESSION_Marshal(TPMA_SESSION *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMA_LOCALITY_Marshal(TPMA_LOCALITY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMA_CC_Marshal(TPMA_CC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_YES_NO_Marshal(TPMI_YES_NO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMA_ACT_Marshal(TPMA_ACT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_DH_SAVED_Marshal(TPMI_DH_CONTEXT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_RH_HIERARCHY_Marshal(TPMI_RH_HIERARCHY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_RH_NV_INDEX_Marshal(TPMI_RH_NV_INDEX *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_RH_NV_EXP_INDEX_Marshal(TPMI_RH_NV_INDEX *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_ALG_HASH_Marshal(TPMI_ALG_HASH *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_ALG_SYM_OBJECT_Marshal(TPMI_ALG_SYM_OBJECT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_SYM_KEY_BITS_Marshal(TPMU_SYM_KEY_BITS *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMI_ALG_SYM_MODE_Marshal(TPMI_ALG_SYM_MODE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_ALG_KDF_Marshal(TPMI_ALG_KDF *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_ALG_SIG_SCHEME_Marshal(TPMI_ALG_SIG_SCHEME *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_HA_Marshal(TPMU_HA *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMT_HA_Marshal(TPMT_HA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_DIGEST_Marshal(TPM2B_DIGEST *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_DATA_Marshal(TPM2B_DATA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_NONCE_Marshal(TPM2B_NONCE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_AUTH_Marshal(TPM2B_AUTH *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_MAX_BUFFER_Marshal(TPM2B_MAX_BUFFER *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_MAX_NV_BUFFER_Marshal(TPM2B_MAX_NV_BUFFER *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_TIMEOUT_Marshal(TPM2B_TIMEOUT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_IV_Marshal(TPM2B_IV *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_NAME_Marshal(TPM2B_NAME *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_PCR_SELECTION_Marshal(TPMS_PCR_SELECTION *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMT_TK_CREATION_Marshal(TPMT_TK_CREATION *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMT_TK_VERIFIED_Marshal(TPMT_TK_VERIFIED *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMT_TK_AUTH_Marshal(TPMT_TK_AUTH *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMT_TK_HASHCHECK_Marshal(TPMT_TK_HASHCHECK *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_ALG_PROPERTY_Marshal(TPMS_ALG_PROPERTY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_TAGGED_PCR_SELECT_Marshal(TPMS_TAGGED_PCR_SELECT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_TAGGED_POLICY_Marshal(TPMS_TAGGED_POLICY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_ACT_DATA_Marshal(TPMS_ACT_DATA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_TAGGED_PROPERTY_Marshal(TPMS_TAGGED_PROPERTY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_CC_Marshal(TPML_CC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_CCA_Marshal(TPML_CCA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_ALG_Marshal(TPML_ALG *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_DIGEST_Marshal(TPML_DIGEST *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_HANDLE_Marshal(TPML_HANDLE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_DIGEST_VALUES_Marshal(TPML_DIGEST_VALUES *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_PCR_SELECTION_Marshal(TPML_PCR_SELECTION *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_ALG_PROPERTY_Marshal(TPML_ALG_PROPERTY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_TAGGED_TPM_PROPERTY_Marshal(TPML_TAGGED_TPM_PROPERTY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_TAGGED_PCR_PROPERTY_Marshal(TPML_TAGGED_PCR_PROPERTY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_ECC_CURVE_Marshal(TPML_ECC_CURVE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_TAGGED_POLICY_Marshal(TPML_TAGGED_POLICY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_ACT_DATA_Marshal(TPML_ACT_DATA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_CAPABILITIES_Marshal(TPMU_CAPABILITIES *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMS_CAPABILITY_DATA_Marshal(TPMS_CAPABILITY_DATA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_CLOCK_INFO_Marshal(TPMS_CLOCK_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_TIME_INFO_Marshal(TPMS_TIME_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_TIME_ATTEST_INFO_Marshal(TPMS_TIME_ATTEST_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_CERTIFY_INFO_Marshal(TPMS_CERTIFY_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_QUOTE_INFO_Marshal(TPMS_QUOTE_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_COMMAND_AUDIT_INFO_Marshal(TPMS_COMMAND_AUDIT_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SESSION_AUDIT_INFO_Marshal(TPMS_SESSION_AUDIT_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_CREATION_INFO_Marshal(TPMS_CREATION_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_NV_CERTIFY_INFO_Marshal(TPMS_NV_CERTIFY_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_NV_DIGEST_CERTIFY_INFO_Marshal(TPMS_NV_DIGEST_CERTIFY_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_ST_ATTEST_NV_DIGEST_Marshal(TPMS_NV_DIGEST_CERTIFY_INFO *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_ST_ATTEST_Marshal(TPMI_ST_ATTEST *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_ATTEST_Marshal(TPMU_ATTEST  *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMS_ATTEST_Marshal(TPMS_ATTEST  *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_ATTEST_Marshal(TPM2B_ATTEST *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_AES_KEY_BITS_Marshal(TPMI_AES_KEY_BITS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_CAMELLIA_KEY_BITS_Marshal(TPMI_CAMELLIA_KEY_BITS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_SYM_KEY_BITS_Marshal(TPMU_SYM_KEY_BITS *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMU_SYM_MODE_Marshal(TPMU_SYM_MODE *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMT_SYM_DEF_OBJECT_Marshal(TPMT_SYM_DEF_OBJECT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_SYM_KEY_Marshal(TPM2B_SYM_KEY *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SYMCIPHER_PARMS_Marshal(TPMS_SYMCIPHER_PARMS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_SENSITIVE_DATA_Marshal(TPM2B_SENSITIVE_DATA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SCHEME_HASH_Marshal(TPMS_SCHEME_HASH *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SCHEME_ECDAA_Marshal(TPMS_SCHEME_ECDAA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_ALG_KEYEDHASH_SCHEME_Marshal(TPMI_ALG_KEYEDHASH_SCHEME *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SCHEME_HMAC_Marshal(TPMS_SCHEME_HMAC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SCHEME_XOR_Marshal(TPMS_SCHEME_XOR *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMT_KEYEDHASH_SCHEME_Marshal(TPMT_KEYEDHASH_SCHEME *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIG_SCHEME_RSASSA_Marshal(TPMS_SIG_SCHEME_RSASSA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIG_SCHEME_RSAPSS_Marshal(TPMS_SIG_SCHEME_RSAPSS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIG_SCHEME_ECDSA_Marshal(TPMS_SIG_SCHEME_ECDSA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIG_SCHEME_SM2_Marshal(TPMS_SIG_SCHEME_SM2 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIG_SCHEME_ECSCHNORR_Marshal(TPMS_SIG_SCHEME_ECSCHNORR *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIG_SCHEME_ECDAA_Marshal(TPMS_SIG_SCHEME_ECDAA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_ENC_SCHEME_OAEP_Marshal(TPMS_ENC_SCHEME_OAEP *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_ENC_SCHEME_RSAES_Marshal(TPMS_ENC_SCHEME_RSAES *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_SCHEME_KEYEDHASH_Marshal(TPMU_SCHEME_KEYEDHASH *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMS_KEY_SCHEME_ECDH_Marshal(TPMS_KEY_SCHEME_ECDH *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_KEY_SCHEME_ECMQV_Marshal(TPMS_KEY_SCHEME_ECMQV*source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_KDF_SCHEME_MGF1_Marshal(TPMS_KDF_SCHEME_MGF1 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_KDF_SCHEME_KDF1_SP800_56A_Marshal(TPMS_KDF_SCHEME_KDF1_SP800_56A *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_KDF_SCHEME_KDF2_Marshal(TPMS_KDF_SCHEME_KDF2 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_KDF_SCHEME_KDF1_SP800_108_Marshal(TPMS_KDF_SCHEME_KDF1_SP800_108 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_KDF_SCHEME_Marshal(TPMU_KDF_SCHEME *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMT_KDF_SCHEME_Marshal(TPMT_KDF_SCHEME *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_ASYM_SCHEME_Marshal(TPMU_ASYM_SCHEME  *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMI_ALG_RSA_SCHEME_Marshal(TPMI_ALG_RSA_SCHEME *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMT_RSA_SCHEME_Marshal(TPMT_RSA_SCHEME *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_PUBLIC_KEY_RSA_Marshal(TPM2B_PUBLIC_KEY_RSA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_RSA_KEY_BITS_Marshal(TPMI_RSA_KEY_BITS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_PRIVATE_KEY_RSA_Marshal(TPM2B_PRIVATE_KEY_RSA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_ECC_PARAMETER_Marshal(TPM2B_ECC_PARAMETER *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_ECC_POINT_Marshal(TPMS_ECC_POINT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_ECC_POINT_Marshal(TPM2B_ECC_POINT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_ALG_ECC_SCHEME_Marshal(TPMI_ALG_ECC_SCHEME *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_ECC_CURVE_Marshal(TPMI_ECC_CURVE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMT_ECC_SCHEME_Marshal(TPMT_ECC_SCHEME *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_ALGORITHM_DETAIL_ECC_Marshal(TPMS_ALGORITHM_DETAIL_ECC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIGNATURE_RSA_Marshal(TPMS_SIGNATURE_RSA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIGNATURE_RSASSA_Marshal(TPMS_SIGNATURE_RSASSA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIGNATURE_RSAPSS_Marshal(TPMS_SIGNATURE_RSAPSS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIGNATURE_ECC_Marshal(TPMS_SIGNATURE_ECC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIGNATURE_ECDSA_Marshal(TPMS_SIGNATURE_ECDSA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIGNATURE_ECDAA_Marshal(TPMS_SIGNATURE_ECDAA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIGNATURE_SM2_Marshal(TPMS_SIGNATURE_SM2 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_SIGNATURE_ECSCHNORR_Marshal(TPMS_SIGNATURE_ECSCHNORR *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_SIGNATURE_Marshal(TPMU_SIGNATURE *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMT_SIGNATURE_Marshal(TPMT_SIGNATURE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_ENCRYPTED_SECRET_Marshal(TPM2B_ENCRYPTED_SECRET *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMI_ALG_PUBLIC_Marshal(TPMI_ALG_PUBLIC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_PUBLIC_ID_Marshal(TPMU_PUBLIC_ID *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMS_KEYEDHASH_PARMS_Marshal(TPMS_KEYEDHASH_PARMS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_RSA_PARMS_Marshal(TPMS_RSA_PARMS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_ECC_PARMS_Marshal(TPMS_ECC_PARMS *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_PUBLIC_PARMS_Marshal(TPMU_PUBLIC_PARMS *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMT_PUBLIC_Marshal(TPMT_PUBLIC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_PUBLIC_Marshal(TPM2B_PUBLIC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_SENSITIVE_COMPOSITE_Marshal(TPMU_SENSITIVE_COMPOSITE *source, BYTE **buffer, INT32 *size, UINT32 selector);\n    UINT16\n    TPMT_SENSITIVE_Marshal(TPMT_SENSITIVE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_PRIVATE_Marshal(TPM2B_PRIVATE *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_ID_OBJECT_Marshal(TPM2B_ID_OBJECT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMA_NV_Marshal(TPMA_NV *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMA_NV_EXP_Marshal(TPMA_NV_EXP *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_NV_PUBLIC_Marshal(TPMS_NV_PUBLIC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_NV_PUBLIC_Marshal(TPM2B_NV_PUBLIC *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_NV_PUBLIC_EXP_ATTR_Marshal(TPMS_NV_PUBLIC_EXP_ATTR *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_NV_PUBLIC_2_Marshal(TPMU_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size, UINT8 selector);\n    UINT16\n    TPMT_NV_PUBLIC_2_Marshal(TPMT_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_NV_PUBLIC_2_Marshal(TPM2B_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_CONTEXT_DATA_Marshal(TPM2B_CONTEXT_DATA  *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_CONTEXT_Marshal(TPMS_CONTEXT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_CREATION_DATA_Marshal(TPMS_CREATION_DATA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM2B_CREATION_DATA_Marshal(TPM2B_CREATION_DATA *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPM_AT_Marshal(TPM_AT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMS_AC_OUTPUT_Marshal(TPMS_AC_OUTPUT *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPML_AC_CAPABILITIES_Marshal(TPML_AC_CAPABILITIES *source, BYTE **buffer, INT32 *size);\n    UINT16\n    TPMU_CAPABILITIES_Marshal(TPMU_CAPABILITIES* source, BYTE** buffer, INT32* size, UINT32 selector);\n    UINT16\n    TPMS_CAPABILITY_DATA_Marshal(TPMS_CAPABILITY_DATA* source, BYTE** buffer, INT32* size);\n    TPM_RC\n    TPMU_SET_CAPABILITIES_Unmarshal(TPMU_SET_CAPABILITIES* target, BYTE** buffer, INT32* size, UINT32 selector);\n    TPM_RC\n    TPMS_SET_CAPABILITY_DATA_Unmarshal(TPMS_SET_CAPABILITY_DATA* target, BYTE** buffer, INT32* size);\n    TPM_RC\n    TPM2B_SET_CAPABILITY_DATA_Unmarshal(TPM2B_SET_CAPABILITY_DATA* target, BYTE** buffer, INT32* size);\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/MathLibraryInterface.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// This file contains the function prototypes for the functions that need to be\n// present in the selected math library. For each function listed, there should\n// be a small stub function. That stub provides the interface between the TPM\n// code and the support library. In most cases, the stub function will only need\n// to do a format conversion between the Crypt_* formats to the internal support\n// library format.  Since the external library also provides the buffer macros\n// for the underlying types, this is typically just a cast from the TPM type to\n// the internal type.\n//\n// Arithmetic operations return a BOOL to indicate if the operation completed\n// successfully or not.\n\n#ifndef MATH_LIBRARY_INTERFACE_H\n#define MATH_LIBRARY_INTERFACE_H\n\n// Types\n#include \"MathLibraryInterfaceTypes.h\"\n\n// ***************************************************************************\n// Library Level Functions\n// ***************************************************************************\n\n//** ExtMath_LibInit()\n// This function is called by CryptInit() so that necessary initializations can be\n// performed on the cryptographic library.\nLIB_EXPORT int ExtMath_LibInit(void);\n\n//** MathLibraryCompatibililtyCheck()\n// This function is only used during development to make sure that the library\n// that is being referenced is using the same size of data structures as the TPM.\nLIB_EXPORT BOOL ExtMath_Debug_CompatibilityCheck(void);\n\n// ***************************************************************************\n// Integer/Number Functions (non-ECC)\n// ***************************************************************************\n\n// #################\n// type initializers\n// #################\n\n//** ExtMath_Initialize_Int()\n// Initialize* functions tells the Crypt_Int types how large of a value it can\n// contain which is a compile time constant\nLIB_EXPORT Crypt_Int* ExtMath_Initialize_Int(Crypt_Int* buffer, NUMBYTES bits);\n\n// #################\n// Buffer Converters\n// #################\n// convert TPM2B byte datainto the private format. The Crypt_Int must already be\n// initialized with it's maximum size. Byte-based Initializers must be MSB first\n// (TPM external format).\nLIB_EXPORT Crypt_Int* ExtMath_IntFromBytes(\n\t\t\t\t\t   Crypt_Int* buffer, const BYTE* input, NUMBYTES byteCount);\n// Convert Crypt_Int into external format as a byte array.\nLIB_EXPORT BOOL ExtMath_IntToBytes(\n\t\t\t\t   const Crypt_Int* value, BYTE* output, NUMBYTES* pByteCount);\n// Set Crypt_Int to a given small value. Words are native format.\nLIB_EXPORT Crypt_Int* ExtMath_SetWord(Crypt_Int* buffer, crypt_uword_t word);\n\n// #################\n// Copy Functions\n// #################\n\n//*** ExtMath_Copy()\n// Function to copy a bignum_t. If the output is NULL, then\n// nothing happens. If the input is NULL, the output is set to zero.\nLIB_EXPORT BOOL ExtMath_Copy(Crypt_Int* out, const Crypt_Int* in);\n\n// ###############################\n// Ordinary Arithmetic, writ large\n// ###############################\n\n//** ExtMath_Multiply()\n// Multiplies two numbers and returns the result\nLIB_EXPORT BOOL ExtMath_Multiply(\n\t\t\t\t Crypt_Int* result, const Crypt_Int* multiplicand, const Crypt_Int* multiplier);\n\n//** ExtMath_Divide()\n// This function divides two Crypt_Int* values. The function returns FALSE if there is\n// an error in the operation. Quotient may be null, in which case this function returns\n// only the remainder.\nLIB_EXPORT BOOL ExtMath_Divide(Crypt_Int*       quotient,\n\t\t\t       Crypt_Int*       remainder,\n\t\t\t       const Crypt_Int* dividend,\n\t\t\t       const Crypt_Int* divisor);\n\n//** ExtMath_GCD()\n// Get the greatest common divisor of two numbers. This function is only needed\n// when the TPM implements RSA.\nLIB_EXPORT BOOL ExtMath_GCD(\n\t\t\t    Crypt_Int* gcd, const Crypt_Int* number1, const Crypt_Int* number2);\n\n//*** ExtMath_Add()\n// This function adds two Crypt_Int* values. This function always returns TRUE.\nLIB_EXPORT BOOL ExtMath_Add(\n\t\t\t    Crypt_Int* result, const Crypt_Int* op1, const Crypt_Int* op2);\n\n//*** ExtMath_AddWord()\n// This function adds a word value to a Crypt_Int*. This function always returns TRUE.\nLIB_EXPORT BOOL ExtMath_AddWord(\n\t\t\t\tCrypt_Int* result, const Crypt_Int* op, crypt_uword_t word);\n\n//*** ExtMath_Subtract()\n// This function does subtraction of two Crypt_Int* values and returns result = op1 - op2\n// when op1 is greater than op2. If op2 is greater than op1, then a fault is\n// generated. This function always returns TRUE.\nLIB_EXPORT BOOL ExtMath_Subtract(\n\t\t\t\t Crypt_Int* result, const Crypt_Int* op1, const Crypt_Int* op2);\n\n//*** ExtMath_SubtractWord()\n// This function subtracts a word value from a Crypt_Int*. This function always\n// returns TRUE.\nLIB_EXPORT BOOL ExtMath_SubtractWord(\n\t\t\t\t     Crypt_Int* result, const Crypt_Int* op, crypt_uword_t word);\n\n// ###############################\n// Modular Arithmetic, writ large\n// ###############################\n\n//** ExtMath_Mod()\n// compute valueAndResult = valueAndResult mod modulus\n// This function divides two Crypt_Int* values and returns only the remainder,\n// replacing the original dividend. The function returns FALSE if there is an\n// error in the operation.\nLIB_EXPORT BOOL ExtMath_Mod(Crypt_Int* valueAndResult, const Crypt_Int* modulus);\n\n//** ExtMath_ModMult()\n// Compute result = (op1 * op2) mod modulus\nLIB_EXPORT BOOL ExtMath_ModMult(Crypt_Int*       result,\n\t\t\t\tconst Crypt_Int* op1,\n\t\t\t\tconst Crypt_Int* op2,\n\t\t\t\tconst Crypt_Int* modulus);\n\n//** ExtMath_ModExp()\n// Compute result = (number ^ exponent) mod modulus\n// where ^ indicates exponentiation.\n// This function is only needed when the TPM implements RSA.\nLIB_EXPORT BOOL ExtMath_ModExp(Crypt_Int*       result,\n\t\t\t       const Crypt_Int* number,\n\t\t\t       const Crypt_Int* exponent,\n\t\t\t       const Crypt_Int* modulus);\n\n//** ExtMath_ModInverse()\n// Compute the modular multiplicative inverse.\n// result = (number ^ -1) mod modulus\n// This function is only needed when the TPM implements RSA.\nLIB_EXPORT BOOL ExtMath_ModInverse(\n\t\t\t\t   Crypt_Int* result, const Crypt_Int* number, const Crypt_Int* modulus);\n\n//** ExtMath_ModInversePrime()\n// Compute the modular multiplicative inverse. This is an optimized function for\n// the case where the modulus is known to be prime.\n//\n// CAUTION: Depending on the library implementation this may be much faster than\n// the normal ModInverse, and therefore is subject to exposing the fact the\n// modulus is prime via a timing side-channel. In many cases (e.g. ECC primes),\n// the prime is not sensitive and this optimized route can be used.\nLIB_EXPORT BOOL ExtMath_ModInversePrime(\n\t\t\t\t\tCrypt_Int* result, const Crypt_Int* number, const Crypt_Int* primeModulus);\n\n//*** ExtMath_ModWord()\n// compute numerator\n// This function does modular division of a big number when the modulus is a\n// word value.\nLIB_EXPORT crypt_word_t ExtMath_ModWord(const Crypt_Int* numerator,\n\t\t\t\t\tcrypt_word_t     modulus);\n\n// ###############################\n// Queries\n// ###############################\n\n//*** ExtMath_UnsignedCmp()\n// This function performs a comparison of op1 to op2. The compare is approximately\n// constant time if the size of the values used in the compare is consistent\n// across calls (from the same line in the calling code).\n//  Return Type: int\n//      < 0             op1 is less than op2\n//      0               op1 is equal to op2\n//      > 0             op1 is greater than op2\nLIB_EXPORT int ExtMath_UnsignedCmp(const Crypt_Int* op1, const Crypt_Int* op2);\n\n//*** ExtMath_UnsignedCmpWord()\n// Compare a Crypt_Int* to a crypt_uword_t.\n//  Return Type: int\n//      -1              op1 is less that word\n//      0               op1 is equal to word\n//      1               op1 is greater than word\nLIB_EXPORT int ExtMath_UnsignedCmpWord(const Crypt_Int* op1, crypt_uword_t word);\n\n//*** ExtMath_IsEqualWord()\n// Compare a Crypt_Int* to a crypt_uword_t for equality\n//  Return Type: BOOL\nLIB_EXPORT BOOL ExtMath_IsEqualWord(const Crypt_Int* bn, crypt_uword_t word);\n\n//*** ExtMath_IsZero()\n// Compare a Crypt_Int* to zero, expected to be O(1) time.\n//  Return Type: BOOL\nLIB_EXPORT BOOL ExtMath_IsZero(const Crypt_Int* op1);\n\n//*** ExtMath_MostSigBitNum()\n//\n// This function returns the zero-based number of the MSb (Most significant bit)\n// of a Crypt_Int* value.\n//\n// Return Type: int\n//\n//      -1              the word was zero or 'bn' was NULL\n//      n               the bit number of the most significant bit in the word\nLIB_EXPORT int ExtMath_MostSigBitNum(const Crypt_Int* bn);\n\n//*** ExtMath_GetLeastSignificant32bits()\n//\n// This function returns the least significant 32-bits of an integer value\n// Return Type: uint32_t\nLIB_EXPORT uint32_t ExtMath_GetLeastSignificant32bits(const Crypt_Int* bn);\n\n//*** ExtMath_SizeInBits()\n//\n// This function returns the number of bits required to hold a number. It is one\n// greater than the Msb.  This function is expected to be side channel safe, and\n// may be O(size) or O(1) where 'size' is the allocated (not actual) size of the\n// value.\nLIB_EXPORT unsigned ExtMath_SizeInBits(const Crypt_Int* n);\n\n// ###############################\n// Bitwise Operations\n// ###############################\n\n//*** ExtMath_SetBit()\n//\n// This function will SET a bit in a Crypt_Int*. Bit 0 is the least-significant\n// bit in the 0th digit_t. The function returns TRUE if the bitNum is within the\n// range valid for the given number.  If bitNum is too large, the function\n// should return FALSE, and the TPM will enter failure mode.\n// Return Type: BOOL\nLIB_EXPORT BOOL ExtMath_SetBit(Crypt_Int*   bn,     // IN/OUT: big number to modify\n\t\t\t       unsigned int bitNum  // IN: Bit number to SET\n\t\t\t       );\n\n//*** ExtMath_TestBit()\n// This function is used to check to see if a bit is SET in a bignum_t. The 0th bit\n// is the LSb of d[0].\n//  Return Type: BOOL\n//      TRUE(1)         the bit is set\n//      FALSE(0)        the bit is not set or the number is out of range\nLIB_EXPORT BOOL ExtMath_TestBit(Crypt_Int*   bn,     // IN: number to check\n\t\t\t\tunsigned int bitNum  // IN: bit to test\n\t\t\t\t);\n\n//***ExtMath_MaskBits()\n// This function is used to mask off high order bits of a big number.\n// The returned value will have no more than 'maskBit' bits\n// set.\n// Note: There is a requirement that unused words of a bignum_t are set to zero.\n//  Return Type: BOOL\n//      TRUE(1)         result masked\n//      FALSE(0)        the input was not as large as the mask\nLIB_EXPORT BOOL ExtMath_MaskBits(\n\t\t\t\t Crypt_Int*    bn,      // IN/OUT: number to mask\n\t\t\t\t crypt_uword_t maskBit  // IN: the bit number for the mask.\n\t\t\t\t );\n\n//*** ExtMath_ShiftRight()\n// This function will shift a Crypt_Int* to the right by the shiftAmount.\n// This function always returns TRUE.\nLIB_EXPORT BOOL ExtMath_ShiftRight(\n\t\t\t\t   Crypt_Int* result, const Crypt_Int* toShift, uint32_t shiftAmount);\n\n// ***************************************************************************\n// ECC Functions\n// ***************************************************************************\n// #################\n// type initializers\n// #################\n\n//** initialize point structure given memory size of each coordinate\nLIB_EXPORT Crypt_Point* ExtEcc_Initialize_Point(Crypt_Point* buffer,\n\t\t\t\t\t\tNUMBYTES     bitsPerCoord);\n\n//** ExtEcc_CurveInitialize()\n// This function is used to initialize a Crypt_EccCurve structure. The\n// structure is a set of pointers to Crypt_Int* values. The curve-dependent values are\n// set by a different function. This function is only needed\n// if the TPM supports ECC.\nLIB_EXPORT const Crypt_EccCurve* ExtEcc_CurveInitialize(Crypt_EccCurve* E,\n\t\t\t\t\t\t\tTPM_ECC_CURVE   curveId);\n\n// #################\n// DESTRUCTOR - See Warning\n// #################\n\n//*** ExtEcc_CurveFree()\n// This function will free the allocated components of the curve and end the\n// frame in which the curve data exists.\n// WARNING: Not guaranteed to be called in presence of LONGJMP.\nLIB_EXPORT void ExtEcc_CurveFree(const Crypt_EccCurve* E);\n\n// #################\n// Buffer Converters\n// #################\n//** point structure to/from raw coordinate buffers.\nLIB_EXPORT Crypt_Point* ExtEcc_PointFromBytes(Crypt_Point* buffer,\n\t\t\t\t\t      const BYTE*  x,\n\t\t\t\t\t      NUMBYTES     nBytesX,\n\t\t\t\t\t      const BYTE*  y,\n\t\t\t\t\t      NUMBYTES     nBytesY);\n\nLIB_EXPORT BOOL         ExtEcc_PointToBytes(\n\t\t\t\t\t    const Crypt_Point* point, BYTE* x, NUMBYTES* nBytesX, BYTE* y, NUMBYTES* nBytesY);\n\n// ####################\n// ECC Point Operations\n// ####################\n\n//** ExtEcc_PointMultiply()\n// This function does a point multiply of the form R = [d]S. A return of FALSE\n// indicates that the result was the point at infinity. This function is only needed\n// if the TPM supports ECC.\nLIB_EXPORT BOOL ExtEcc_PointMultiply(Crypt_Point*          R,\n\t\t\t\t     const Crypt_Point*    S,\n\t\t\t\t     const Crypt_Int*      d,\n\t\t\t\t     const Crypt_EccCurve* E);\n\n//** ExtEcc_PointMultiplyAndAdd()\n// This function does a point multiply of the form R = [d]S + [u]Q. A return of\n// FALSE indicates that the result was the point at infinity. This function is only\n// needed if the TPM supports ECC.\nLIB_EXPORT BOOL ExtEcc_PointMultiplyAndAdd(Crypt_Point*          R,\n\t\t\t\t\t   const Crypt_Point*    S,\n\t\t\t\t\t   const Crypt_Int*      d,\n\t\t\t\t\t   const Crypt_Point*    Q,\n\t\t\t\t\t   const Crypt_Int*      u,\n\t\t\t\t\t   const Crypt_EccCurve* E);\n\n//** ExtEcc_PointAdd()\n// This function does a point add R = S + Q. A return of FALSE\n// indicates that the result was the point at infinity. This function is only needed\n// if the TPM supports ECC.\nLIB_EXPORT BOOL ExtEcc_PointAdd(Crypt_Point*          R,\n\t\t\t\tconst Crypt_Point*    S,\n\t\t\t\tconst Crypt_Point*    Q,\n\t\t\t\tconst Crypt_EccCurve* E);\n\n// #####################\n// ECC Point Information\n// #####################\nLIB_EXPORT BOOL ExtEcc_IsPointOnCurve(const Crypt_Point* Q, const Crypt_EccCurve* E);\nLIB_EXPORT BOOL ExtEcc_IsInfinityPoint(const Crypt_Point* pt);\n// extract the X-Coordinate of a point\nLIB_EXPORT const Crypt_Int* ExtEcc_PointX(const Crypt_Point* pt);\n\n// extract the Y-Coordinate of a point\n// (no current use case for the Y coordinate alone, signatures use X)\n// LIB_EXPORT const Crypt_Int* ExtEcc_PointY(const Crypt_Point* pt);\n\n// #####################\n// ECC Curve Information\n// #####################\n// These functions are expected to be fast, returning pre-built constants without\n// allocation or copying.\nLIB_EXPORT const Crypt_Int*   ExtEcc_CurveGetPrime(TPM_ECC_CURVE curveId);\nLIB_EXPORT const Crypt_Int*   ExtEcc_CurveGetOrder(TPM_ECC_CURVE curveId);\nLIB_EXPORT const Crypt_Int*   ExtEcc_CurveGetCofactor(TPM_ECC_CURVE curveId);\nLIB_EXPORT const Crypt_Int*   ExtEcc_CurveGet_a(TPM_ECC_CURVE curveId);\nLIB_EXPORT const Crypt_Int*   ExtEcc_CurveGet_b(TPM_ECC_CURVE curveId);\nLIB_EXPORT const Crypt_Point* ExtEcc_CurveGetG(TPM_ECC_CURVE curveId);\nLIB_EXPORT const Crypt_Int*   ExtEcc_CurveGetGx(TPM_ECC_CURVE curveId);\nLIB_EXPORT const Crypt_Int*   ExtEcc_CurveGetGy(TPM_ECC_CURVE curveId);\nLIB_EXPORT TPM_ECC_CURVE      ExtEcc_CurveGetCurveId(const Crypt_EccCurve* E);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/MathLibraryInterfaceTypes.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the declaration and initialization macros for\n// low-level cryptographic buffer types.  This requires the underlying\n// Crypto library to have already defined the CRYPT_INT_BUF family of\n// macros.  See tpm_crypto_lib.md for details.\n\n#ifndef MATH_LIBRARY_INTERFACE_TYPES_H\n#define MATH_LIBRARY_INTERFACE_TYPES_H\n\n#ifndef CRYPT_INT_BUF\n#  error CRYPT_INT_BUF must be defined before including this file.\n#endif\n#ifndef CRYPT_POINT_BUF\n#  error CRYPT_POINT_BUF must be defined before including this file.\n#endif\n#ifndef CRYPT_CURVE_BUF\n#  error CRYPT_CURVE_BUF must be defined before including this file.\n#endif\n\n// Crypt_Int underlying types Crypt_Int is an abstract type that is used as a\n// pointer. The underlying math library is expected to be able to find the\n// actual allocated size for a given Crypt_Int object given a pointer to it, and\n// therefore we typedef here to a size 1 (smallest possible).\ntypedef CRYPT_INT_BUF(one, 1) Crypt_Int;\ntypedef CRYPT_POINT_BUF(pointone, 1) Crypt_Point;\ntypedef CRYPT_CURVE_BUF(curvebuft, MAX_ECC_KEY_BITS) Crypt_EccCurve;\n\n// produces bare typedef ci_<typename>_t\n#define CRYPT_INT_TYPE(typename, bits)\t\t\t\t\t\\\n    typedef CRYPT_INT_BUF(ci_##typename##_buf_t, bits) ci_##typename##_t\n\n// produces allocated `Crypt_Int* varname` backed by a\n// stack buffer named `<varname>_buf`.  Initialization at the discretion of the\n// ExtMath library.\n#define CRYPT_INT_VAR(varname, bits)\t\t\t\t   \\\n    CRYPT_INT_BUF(ci_##varname##_buf_t, bits) varname##_buf;\t\t\\\n    Crypt_Int* varname = ExtMath_Initialize_Int((Crypt_Int*)&(varname##_buf), bits);\n\n// produces initialized `Crypt_Int* varname = (TPM2B) initializer` backed by a\n// stack buffer named `<varname>_buf`\n#define CRYPT_INT_INITIALIZED(varname, bits, initializer)\t\t\\\n    CRYPT_INT_BUF(cibuf##varname, bits) varname##_buf;\t\t\t\\\n    Crypt_Int* varname =\t\t\t\t\t\t\\\n\t\tTpmMath_IntFrom2B(ExtMath_Initialize_Int((Crypt_Int*)&(varname##_buf), bits), \\\n\t\t  (TPM2B*)initializer);\n\n// convenience variants of above:\n// largest supported integer\n#define CRYPT_INT_MAX(varname) CRYPT_INT_VAR(varname, LARGEST_NUMBER_BITS)\n\n#define CRYPT_INT_MAX_INITIALIZED(name, initializer)\t\t\t\\\n    CRYPT_INT_INITIALIZED(name, LARGEST_NUMBER_BITS, initializer)\n\n// A single RADIX_BITS value.\n#define CRYPT_INT_WORD(name) CRYPT_INT_VAR(name, RADIX_BITS)\n\n#define CRYPT_INT_WORD_INITIALIZED(varname, initializer)\t\t\\\n    CRYPT_INT_BUF(cibuf##varname, RADIX_BITS) varname##_buf;\t\t\\\n    Crypt_Int* varname = ExtMath_SetWord(\t\t\t\t\\\n\t\t\tExtMath_Initialize_Int((Crypt_Int*)&(varname##_buf), RADIX_BITS), \\\n\t\t\tinitializer);\n\n// Crypt_EccCurve underlying types\n#define CRYPT_CURVE_INITIALIZED(varname, initializer)\t\t\t\\\n    CRYPT_CURVE_BUF(cv##varname, MAX_ECC_KEY_BITS) varname##_buf;\t\\\n    const Crypt_EccCurve* varname =\t\t\t\t\t\\\n\t\t\tExtEcc_CurveInitialize(&(varname##_buf), initializer)\n\n/* no guarantee free will be called in the presence of longjmp */\n#define CRYPT_CURVE_FREE(varname) ExtEcc_CurveFree(varname)\n\n#define CRYPT_POINT_VAR(varname)\t\t\t\t\t\\\n    CRYPT_POINT_BUF(cp_##varname##_buf_t, MAX_ECC_KEY_BITS) varname##_buf; \\\n    Crypt_Point* varname =\t\t\t\t\t\t\\\n\t\t\tExtEcc_Initialize_Point((Crypt_Point*)&(varname##_buf), MAX_ECC_KEY_BITS);\n\n\n#define CRYPT_POINT_INITIALIZED(varname, initValue)\t\t\t\\\n    CRYPT_POINT_BUF(cp_##varname##_buf_t, MAX_ECC_KEY_BITS) varname##_buf; \\\n    Crypt_Point* varname = TpmEcc_PointFrom2B(\t\t\t\t\\\n\t\tExtEcc_Initialize_Point((Crypt_Point*)&(varname##_buf), MAX_ECC_KEY_BITS), \\\n\t\tinitValue);\n\n#endif  //MATH_LIBRARY_INTERFACE_TYPES_H\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/MathOnByteBuffers_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tMath functions performed with canonical integers in byte buffers\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar 28, 2019  Time: 08:25:19PM\n */\n\n#ifndef _MATH_ON_BYTE_BUFFERS_FP_H_\n#define _MATH_ON_BYTE_BUFFERS_FP_H_\n\n//*** UnsignedCmpB\n// This function compare two unsigned values. The values are byte-aligned,\n// big-endian numbers (e.g, a hash).\n//  Return Type: int\n//      1          if (a > b)\n//      0          if (a = b)\n//      -1         if (a < b)\nLIB_EXPORT int UnsignedCompareB(UINT32      aSize,  // IN: size of a\n\t\t\t\tconst BYTE* a,      // IN: a\n\t\t\t\tUINT32      bSize,  // IN: size of b\n\t\t\t\tconst BYTE* b       // IN: b\n\t\t\t\t);\n\n//***SignedCompareB()\n// Compare two signed integers:\n//  Return Type: int\n//      1         if a > b\n//      0         if a = b\n//      -1        if a < b\nint SignedCompareB(const UINT32 aSize,  // IN: size of a\n\t\t   const BYTE*  a,      // IN: a buffer\n\t\t   const UINT32 bSize,  // IN: size of b\n\t\t   const BYTE*  b       // IN: b buffer\n\t\t   );\n\n//*** ModExpB\n// This function is used to do modular exponentiation in support of RSA.\n// The most typical uses are: 'c' = 'm'^'e' mod 'n' (RSA encrypt) and\n// 'm' = 'c'^'d' mod 'n' (RSA decrypt).  When doing decryption, the 'e' parameter\n// of the function will contain the private exponent 'd' instead of the public\n// exponent 'e'.\n//\n// If the results will not fit in the provided buffer,\n// an error is returned (CRYPT_ERROR_UNDERFLOW). If the results is smaller\n// than the buffer, the results is de-normalized.\n//\n// This version is intended for use with RSA and requires that 'm' be\n// less than 'n'.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SIZE         number to exponentiate is larger than the modulus\n//      TPM_RC_NO_RESULT    result will not fit into the provided buffer\n//\nTPM_RC\nModExpB(UINT32 cSize,  // IN: the size of the output buffer. It will\n\t//     need to be the same size as the modulus\n\tBYTE* c,       // OUT: the buffer to receive the results\n\t//     (c->size must be set to the maximum size\n\t//     for the returned value)\n\tconst UINT32 mSize,\n\tconst BYTE*  m,  // IN: number to exponentiate\n\tconst UINT32 eSize,\n\tconst BYTE*  e,  // IN: power\n\tconst UINT32 nSize,\n\tconst BYTE*  n  // IN: modulus\n\t);\n\n//*** DivideB()\n// Divide an integer ('n') by an integer ('d') producing a quotient ('q') and\n// a remainder ('r'). If 'q' or 'r' is not needed, then the pointer to them\n// may be set to NULL.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT         'q' or 'r' is too small to receive the result\n//\nLIB_EXPORT TPM_RC DivideB(const TPM2B* n,  // IN: numerator\n\t\t\t  const TPM2B* d,  // IN: denominator\n\t\t\t  TPM2B*       q,  // OUT: quotient\n\t\t\t  TPM2B*       r   // OUT: remainder\n\t\t\t  );\n\n//*** AdjustNumberB()\n// Remove/add leading zeros from a number in a TPM2B. Will try to make the number\n// by adding or removing leading zeros. If the number is larger than the requested\n// size, it will make the number as small as possible. Setting 'requestedSize' to\n// zero is equivalent to requesting that the number be normalized.\nUINT16\nAdjustNumberB(TPM2B* num, UINT16 requestedSize);\n\n//*** ShiftLeft()\n// This function shifts a byte buffer (a TPM2B) one byte to the left. That is,\n// the most significant bit of the most significant byte is lost.\nTPM2B* ShiftLeft(TPM2B* value  // IN/OUT: value to shift and shifted value out\n\t\t );\n\n#endif  // _MATH_ON_BYTE_BUFFERS_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Memory_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t Miscellaneous Memory Manipulation Routines\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Memory_fp.h 1476 2019-06-10 19:32:03Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef MEMORY_FP_H\n#define MEMORY_FP_H\n\nvoid\nMemoryCopy(\n\t   void        *dest,\n\t   const void  *src,\n\t   int          sSize\n\t   );\nBOOL\nMemoryEqual(\n\t    const void      *buffer1,       // IN: compare buffer1\n\t    const void      *buffer2,       // IN: compare buffer2\n\t    unsigned int     size           // IN: size of bytes being compared\n\t    );\nLIB_EXPORT INT16\nMemoryCopy2B(\n\t     TPM2B           *dest,          // OUT: receiving TPM2B\n\t     const TPM2B     *source,        // IN: source TPM2B\n\t     unsigned int     dSize          // IN: size of the receiving buffer\n\t     );\nvoid\nMemoryConcat2B(\n\t       TPM2B           *aInOut,        // IN/OUT: destination 2B\n\t       TPM2B           *bIn,           // IN: second 2B\n\t       unsigned int     aMaxSize       // IN: The size of aInOut.buffer (max values for\n\t       //     aInOut.size)\n\t       );\nBOOL\nMemoryEqual2B(\n\t      const TPM2B     *aIn,           // IN: compare value\n\t      const TPM2B     *bIn            // IN: compare value\n\t      );\nvoid\nMemorySet(\n\t  void            *dest,\n\t  int              value,\n\t  size_t           size\n\t  );\nvoid\nMemoryPad2B(\n\t    TPM2B           *b,\n\t    UINT16           newSize\n\t    );\nvoid\nUint16ToByteArray(\n\t\t  UINT16              i,\n\t\t  BYTE                *a\n\t\t  );\nvoid\nUint32ToByteArray(\n\t\t  UINT32              i,\n\t\t  BYTE                *a\n\t\t  );\nvoid\nUint64ToByteArray(\n\t\t  UINT64               i,\n\t\t  BYTE                *a\n\t\t  );\nUINT8\nByteArrayToUint8(\n\t\t BYTE                *a\n\t\t );\nUINT16\nByteArrayToUint16(\n\t\t  BYTE                *a\n\t\t  );\nUINT32\nByteArrayToUint32(\n\t\t  BYTE                *a\n\t\t  );\nUINT64\nByteArrayToUint64(\n\t\t  BYTE                *a\n\t\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/MinMax.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t  \tMin Max Macros \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n\n#ifndef _MIN_MAX_H_\n#define _MIN_MAX_H_\n\n#ifndef MAX\n#  define MAX(a, b) ((a) > (b) ? (a) : (b))\n#endif\n#ifndef MIN\n#  define MIN(a, b) ((a) < (b) ? (a) : (b))\n#endif\n\n#ifndef SIZEOF_MEMBER\n#  define SIZEOF_MEMBER(type, member) sizeof(((type*)0)->member)\n#endif\n\n#endif  // _MIN_MAX_H_\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef NV_H\n#define NV_H\n\n/* 5.14.1\tIndex Type Definitions */\n/* These definitions allow the same code to be used pre and post 1.21. The main action is to\n   redefine the index type values from the bit values. Use TPM_NT_ORDINARY to indicate if the TPM_NT\n   type is defined */\n#ifdef     TPM_NT_ORDINARY\n/* If TPM_NT_ORDINARY is defined, then the TPM_NT field is present in a TPMA_NV */\n#   define GET_TPM_NT(attributes) GET_ATTRIBUTE(attributes, TPMA_NV, TPM_NT)\n#else\n/* If TPM_NT_ORDINARY is not defined, then need to synthesize it from the attributes */\n#   define GetNv_TPM_NV(attributes)\t\t\t\t\t\\\n    (   IS_ATTRIBUTE(attributes, TPMA_NV, COUNTER)\t\t\t\\\n\t+   (IS_ATTRIBUTE(attributes, TPMA_NV, BITS) << 1)\t\t\\\n\t+   (IS_ATTRIBUTE(attributes, TPMA_NV, EXTEND) << 2)\t\t\\\n\t)\n#   define TPM_NT_ORDINARY (0)\n#   define TPM_NT_COUNTER  (1)\n#   define TPM_NT_BITS     (2)\n#   define TPM_NT_EXTEND   (4)\n#endif\n/* 5.14.2\tAttribute Macros */\n/* These macros are used to isolate the differences in the way that the index type changed in\n   version 1.21 of the specification */\n#   define IsNvOrdinaryIndex(attributes)\t\t\t\t\\\n    (GET_TPM_NT(attributes) == TPM_NT_ORDINARY)\n#   define  IsNvCounterIndex(attributes)\t\t\t\t\\\n    (GET_TPM_NT(attributes) == TPM_NT_COUNTER)\n#   define  IsNvBitsIndex(attributes)\t\t\t\t\t\\\n    (GET_TPM_NT(attributes) == TPM_NT_BITS)\n#   define  IsNvExtendIndex(attributes)\t\t\t\t\t\\\n    (GET_TPM_NT(attributes) == TPM_NT_EXTEND)\n#ifdef TPM_NT_PIN_PASS\n#   define  IsNvPinPassIndex(attributes)\t\t\t\t\\\n    (GET_TPM_NT(attributes) == TPM_NT_PIN_PASS)\n#endif\n#ifdef TPM_NT_PIN_FAIL\n#   define  IsNvPinFailIndex(attributes)\t\t\t\t\\\n    (GET_TPM_NT(attributes) == TPM_NT_PIN_FAIL)\n#endif\ntypedef struct {\n    UINT32      size;\n    TPM_HANDLE  handle;\n} NV_ENTRY_HEADER;\n#define NV_EVICT_OBJECT_SIZE\t\t\t\t\t\t\\\n    (sizeof(UINT32)  + sizeof(TPM_HANDLE) + sizeof(OBJECT))\n#define NV_INDEX_COUNTER_SIZE\t\t\t\t\t\t\\\n    (sizeof(UINT32) + sizeof(NV_INDEX) + sizeof(UINT64))\n#define NV_RAM_INDEX_COUNTER_SIZE\t\t\t\\\n    (sizeof(NV_RAM_HEADER) + sizeof(UINT64))\ntypedef struct {\n    UINT32          size;\n    TPM_HANDLE      handle;\n    TPMA_NV         attributes;\n} NV_RAM_HEADER;\n/* Defines the end-of-list marker for NV. The list terminator is a UINT32 of zero, followed by the\n   current value of s_maxCounter which is a 64-bit value. The structure is defined as an array of 3\n   UINT32 values so that there is no padding between the UINT32 list end marker and the UINT64\n   maxCounter value. */\ntypedef UINT32 NV_LIST_TERMINATOR[3];\n/* 5.14.3\tOrderly RAM Values */\n/* The following defines are for accessing orderly RAM values. This is the initialize for the RAM\n   reference iterator. */\n#define     NV_RAM_REF_INIT         0\n/* This is the starting address of the RAM space used for orderly data */\n#define     RAM_ORDERLY_START\t\t\t\\\n    (&s_indexOrderlyRam[0])\n/* This is the offset within NV that is used to save the orderly data on an orderly shutdown. */\n#define     NV_ORDERLY_START\t\t\t\\\n    (NV_INDEX_RAM_DATA)\n/* This is the end of the orderly RAM space. It is actually the first byte after the last byte of\n   orderly RAM data */\n#define     RAM_ORDERLY_END\t\t\t\t\t\t\\\n    (RAM_ORDERLY_START + sizeof(s_indexOrderlyRam))\n/* This is the end of the orderly space in NV memory. As with RAM_ORDERLY_END, it is actually the\n   offset of the first byte after the end of the NV orderly data. */\n#define     NV_ORDERLY_END\t\t\t\t\t\t\\\n    (NV_ORDERLY_START + sizeof(s_indexOrderlyRam))\n/* Macro to check that an orderly RAM address is with range. */\n#define ORDERLY_RAM_ADDRESS_OK(start, offset)\t\t\t\t\\\n    ((start >= RAM_ORDERLY_START) && ((start + offset - 1) < RAM_ORDERLY_END))\n#define RETURN_IF_NV_IS_NOT_AVAILABLE\t\t\t    \\\n    {\t\t\t\t\t\t\t    \\\n\tif(g_NvStatus != TPM_RC_SUCCESS)\t\t\t    \\\n\t    return g_NvStatus;\t\t\t\t\t    \\\n    }\n/* Routinely have to clear the orderly flag and fail if the NV is not available so that it can be\n   cleared. */\n#define RETURN_IF_ORDERLY\t\t\t\t    \\\n    {\t\t\t\t\t\t\t    \\\n\tif(NvClearOrderly() != TPM_RC_SUCCESS)\t\t\t    \\\n\t    return g_NvStatus;\t\t\t\t\t    \\\n    }\n#define NV_IS_AVAILABLE     (g_NvStatus == TPM_RC_SUCCESS)\n#define IS_ORDERLY(value)   (value < SU_DA_USED_VALUE)\n#define NV_IS_ORDERLY       (IS_ORDERLY(gp.orderlyState))\n/* Macro to set the NV UPDATE_TYPE. This deals with the fact that the update is possibly a\n   combination of UT_NV and UT_ORDERLY. */\n#define SET_NV_UPDATE(type)     g_updateNV |= (type)\n#endif  // _NV_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NVDynamic_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tDynamic space for user defined NV \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef NVDYNAMIC_FP_H\n#define NVDYNAMIC_FP_H\n\nNV_REF\nNvWriteNvListEnd(\n\t\t NV_REF           end\n\t\t );\nvoid\nNvUpdateIndexOrderlyData(\n\t\t\t void\n\t\t\t );\nvoid\nNvReadNvIndexInfo(\n\t\t  NV_REF           ref,           // IN: points to NV where index is located\n\t\t  NV_INDEX        *nvIndex        // OUT: place to receive index data\n\t\t  );\nvoid\nNvReadObject(\n\t     NV_REF           ref,           // IN: points to NV where index is located\n\t     OBJECT          *object         // OUT: place to receive the object data\n\t     );\nBOOL\nNvIndexIsDefined(\n\t\t TPM_HANDLE       nvHandle       // IN: Index to look for\n\t\t );\nBOOL\nNvIsPlatformPersistentHandle(\n\t\t\t     TPM_HANDLE       handle         // IN: handle\n\t\t\t     );\nBOOL\nNvIsOwnerPersistentHandle(\n\t\t\t  TPM_HANDLE       handle         // IN: handle\n\t\t\t  );\nTPM_RC\nNvIndexIsAccessible(\n\t\t    TPMI_RH_NV_INDEX     handle        // IN: handle\n\t\t    );\nTPM_RC\nNvGetEvictObject(\n\t\t TPM_HANDLE       handle,        // IN: handle\n\t\t OBJECT          *object         // OUT: object data\n\t\t );\nvoid\nNvIndexCacheInit(\n\t\t void\n\t\t );\nvoid\nNvGetIndexData(\n\t       NV_INDEX        *nvIndex,       // IN: the in RAM index descriptor\n\t       NV_REF           locator,       // IN: where the data is located\n\t       UINT32           offset,        // IN: offset of NV data\n\t       UINT16           size,          // IN: size of NV data\n\t       void            *data           // OUT: data buffer\n\t       );\nvoid\nNvHashIndexData(\n\t\tHASH_STATE          *hashState,     // IN: Initialized hash state\n\t\tNV_INDEX            *nvIndex,       // IN: Index\n\t\tNV_REF               locator,       // IN: where the data is located\n\t\tUINT32               offset,        // IN: starting offset\n\t\tUINT16               size           // IN: amount to hash\n\t\t);\nUINT64\nNvGetUINT64Data(\n\t\tNV_INDEX        *nvIndex,       // IN: the in RAM index descriptor\n\t\tNV_REF           locator        // IN: where index exists in NV\n\t\t);\nTPM_RC\nNvWriteIndexAttributes(\n\t\t       TPM_HANDLE       handle,\n\t\t       NV_REF           locator,       // IN: location of the index\n\t\t       TPMA_NV          attributes     // IN: attributes to write\n\t\t       );\nTPM_RC\nNvWriteIndexAuth(\n\t\t NV_REF           locator,       // IN: location of the index\n\t\t TPM2B_AUTH      *authValue      // IN: the authValue to write\n\t\t );\nNV_INDEX *\nNvGetIndexInfo(\n\t       TPM_HANDLE       nvHandle,      // IN: the index handle\n\t       NV_REF          *locator        // OUT: location of the index\n\t       );\nTPM_RC\nNvWriteIndexData(\n\t\t NV_INDEX        *nvIndex,       // IN: the description of the index\n\t\t UINT32           offset,        // IN: offset of NV data\n\t\t UINT32           size,          // IN: size of NV data\n\t\t void            *data           // IN: data buffer\n\t\t );\nTPM_RC\nNvWriteUINT64Data(\n\t\t  NV_INDEX        *nvIndex,       // IN: the description of the index\n\t\t  UINT64           intValue       // IN: the value to write\n\t\t  );\nTPM2B_NAME *\nNvGetNameByIndexHandle(\n\t\t       TPMI_RH_NV_INDEX     handle,        // IN: handle of the index\n\t\t       TPM2B_NAME          *name           // OUT: name of the index\n\t\t       );\nTPM_RC\nNvDefineIndex(\n\t      TPMS_NV_PUBLIC  *publicArea,    // IN: A template for an area to create.\n\t      TPM2B_AUTH      *authValue      // IN: The initial authorization value\n\t      );\nTPM_RC\nNvAddEvictObject(\n\t\t TPMI_DH_OBJECT   evictHandle,   // IN: new evict handle\n\t\t OBJECT          *object         // IN: object to be added\n\t\t );\nTPM_RC\nNvDeleteIndex(\n\t      NV_INDEX        *nvIndex,       // IN: an in RAM index descriptor\n\t      NV_REF           entityAddr     // IN: location in NV\n\t      );\nTPM_RC\nNvDeleteEvict(\n\t      TPM_HANDLE       handle         // IN: handle of entity to be deleted\n\t      );\nTPM_RC\nNvFlushHierarchy(\n\t\t TPMI_RH_HIERARCHY    hierarchy      // IN: hierarchy to be flushed.\n\t\t );\nTPM_RC\nNvSetGlobalLock(\n\t\tvoid\n\t\t);\nTPMI_YES_NO\nNvCapGetPersistent(\n\t\t   TPMI_DH_OBJECT   handle,        // IN: start handle\n\t\t   UINT32           count,         // IN: maximum number of returned handles\n\t\t   TPML_HANDLE     *handleList     // OUT: list of handle\n\t\t   );\n//*** NvCapGetOnePersistent()\n// This function returns whether a given persistent handle exists.\n//\n// 'Handle' must be in valid persistent object handle range.\nBOOL NvCapGetOnePersistent(TPMI_DH_OBJECT handle  // IN: handle\n\t\t\t   );\n\nTPMI_YES_NO\nNvCapGetIndex(\n\t      TPMI_DH_OBJECT   handle,        // IN: start handle\n\t      UINT32           count,         // IN: max number of returned handles\n\t      TPML_HANDLE     *handleList     // OUT: list of handle\n\t      );\nBOOL NvCapGetOneIndex(TPMI_DH_OBJECT handle);  // IN: start handle\nUINT32\nNvCapGetIndexNumber(\n\t\t    void\n\t\t    );\nUINT32\nNvCapGetPersistentNumber(\n\t\t\t void\n\t\t\t );\nUINT32\nNvCapGetPersistentAvail(\n\t\t\tvoid\n\t\t\t);\nUINT32\nNvCapGetCounterNumber(\n\t\t      void\n\t\t      );\nBOOL\nNvEntityStartup(\n\t\tSTARTUP_TYPE     type           // IN: start up type\n\t\t);\nUINT32\nNvCapGetCounterAvail(\n\t\t     void\n\t\t     );\nNV_REF\nNvFindHandle(\n\t     TPM_HANDLE       handle\n\t     );\nUINT64\nNvReadMaxCount(\n\t       void\n\t       );\nvoid\nNvUpdateMaxCount(\n\t\t UINT64           count\n\t\t );\nvoid\nNvSetMaxCount(\n\t      UINT64          value\n\t      );\nUINT64\nNvGetMaxCount(\n\t      void\n\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NVReserved_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NVReserved_fp.h 1476 2019-06-10 19:32:03Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef NVRESERVED_FP_H\n#define NVRESERVED_FP_H\n\nvoid\nNvCheckState(\n\t     void\n\t     );\nBOOL\nNvCommit(\n\t void\n\t );\nBOOL\nNvPowerOn(\n\t  void\n\t  );\nvoid\nNvManufacture(\n\t      void\n\t      );\nvoid\nNvRead(\n       void            *outBuffer,     // OUT: buffer to receive data\n       UINT32           nvOffset,      // IN: offset in NV of value\n       UINT32           size           // IN: size of the value to read\n       );\nBOOL\nNvWrite(\n\tUINT32           nvOffset,      // IN: location in NV to receive data\n\tUINT32           size,          // IN: size of the data to move\n\tvoid            *inBuffer       // IN: location containing data to write\n\t);\nvoid\nNvUpdatePersistent(\n\t\t   UINT32           offset,        // IN: location in PERMANENT_DATA to be updated\n\t\t   UINT32           size,          // IN: size of the value\n\t\t   void            *buffer         // IN: the new data\n\t\t   );\nvoid\nNvClearPersistent(\n\t\t  UINT32           offset,        // IN: the offset in the PERMANENT_DATA\n\t\t  //     structure to be cleared (zeroed)\n\t\t  UINT32           size           // IN: number of bytes to clear\n\t\t  );\nvoid\nNvReadPersistent(\n\t\t void\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_Certify_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_Certify_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_CERTIFY_FP_H\n#define NV_CERTIFY_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tsignHandle;\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n    TPM2B_DATA\t\tqualifyingData;\n    TPMT_SIG_SCHEME\tinScheme;\n    UINT16\t\tsize;\n    UINT16\t\toffset;\n} NV_Certify_In;\n\n#define RC_NV_Certify_signHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_Certify_authHandle\t(TPM_RC_H + TPM_RC_2)\n#define RC_NV_Certify_nvIndex\t\t(TPM_RC_H + TPM_RC_3)\n#define RC_NV_Certify_qualifyingData\t(TPM_RC_P + TPM_RC_1)\n#define RC_NV_Certify_inScheme\t\t(TPM_RC_P + TPM_RC_2)\n#define RC_NV_Certify_size\t\t(TPM_RC_P + TPM_RC_3)\n#define RC_NV_Certify_offset\t\t(TPM_RC_P + TPM_RC_4)\n\n\ntypedef struct {\n    TPM2B_ATTEST\tcertifyInfo;\n    TPMT_SIGNATURE\tsignature;\n} NV_Certify_Out;\n\nTPM_RC\nTPM2_NV_Certify(\n\t\tNV_Certify_In   *in,            // IN: input parameter list\n\t\tNV_Certify_Out  *out            // OUT: output parameter list\n\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_ChangeAuth_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_ChangeAuth_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_CHANGEAUTH_FP_H\n#define NV_CHANGEAUTH_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_INDEX\tnvIndex;\n    TPM2B_AUTH\t\tnewAuth;\n} NV_ChangeAuth_In;\n\n#define RC_NV_ChangeAuth_nvIndex\t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_ChangeAuth_newAuth \t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_NV_ChangeAuth(\n\t\t   NV_ChangeAuth_In    *in             // IN: input parameter list\n\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_DefineSpace2_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023   \t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#if CC_NV_DefineSpace2  // Command must be enabled\n\n#ifndef NV_DEFINESPACE2_FP_H\n#define NV_DEFINESPACE2_FP_H\n\ntypedef struct\n{\n    TPMI_RH_PROVISION authHandle;\n    TPM2B_AUTH        auth;\n    TPM2B_NV_PUBLIC_2 publicInfo;\n} NV_DefineSpace2_In;\n\n#define RC_NV_DefineSpace2_authHandle (TPM_RC_H + TPM_RC_1)\n#define RC_NV_DefineSpace2_auth       (TPM_RC_P + TPM_RC_1)\n#define RC_NV_DefineSpace2_publicInfo (TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_NV_DefineSpace2(NV_DefineSpace2_In* in);\n\n#endif    // NV_DEFINESPACE2_FP_H\n#endif    // CC_NV_DefineSpace2\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_DefineSpace_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_DefineSpace_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_DEFINESPACE_FP_H\n#define NV_DEFINESPACE_FP_H\n\ntypedef struct {\n    TPMI_RH_PROVISION\tauthHandle;\n    TPM2B_AUTH\t\tauth;\n    TPM2B_NV_PUBLIC\tpublicInfo;\n} NV_DefineSpace_In;\n\n#define RC_NV_DefineSpace_authHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_DefineSpace_auth \t\t(TPM_RC_P + TPM_RC_1)\n#define RC_NV_DefineSpace_publicInfo \t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_NV_DefineSpace(\n\t\t    NV_DefineSpace_In   *in             // IN: input parameter list\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_Extend_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_Extend_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_EXTEND_FP_H\n#define NV_EXTEND_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n    TPM2B_MAX_NV_BUFFER\tdata;\n} NV_Extend_In;\n\n#define RC_NV_Extend_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_Extend_nvIndex \t(TPM_RC_H + TPM_RC_2)\n#define RC_NV_Extend_data\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_NV_Extend(\n\t       NV_Extend_In    *in             // IN: input parameter list\n\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_GlobalWriteLock_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_GlobalWriteLock_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_GLOBALWRITELOCK_FP_H\n#define NV_GLOBALWRITELOCK_FP_H\n\ntypedef struct {\n    TPMI_RH_PROVISION\tauthHandle;\n} NV_GlobalWriteLock_In;\n\n#define RC_NV_GlobalWriteLock_authHandle\t(TPM_RC_H + TPM_RC_1)\n\nTPM_RC\nTPM2_NV_GlobalWriteLock(\n\t\t\tNV_GlobalWriteLock_In   *in             // IN: input parameter list\n\t\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_Increment_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_Increment_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_INCREMENT_FP_H\n#define NV_INCREMENT_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n} NV_Increment_In;;\n\n#define RC_NV_Increment_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_Increment_nvIndex \t(TPM_RC_H + TPM_RC_2)\n\nTPM_RC\nTPM2_NV_Increment(\n\t\t  NV_Increment_In     *in             // IN: input parameter list\n\t\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_ReadLock_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_ReadLock_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_READLOCK_FP_H\n#define NV_READLOCK_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n} NV_ReadLock_In;\n\n#define RC_NV_ReadLock_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_ReadLock_nvIndex \t\t(TPM_RC_H + TPM_RC_2)\n\nTPM_RC\nTPM2_NV_ReadLock(\n\t\t NV_ReadLock_In  *in             // IN: input parameter list\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_ReadPublic2_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef NV_READPUBLIC2_FP_H\n#define NV_READPUBLIC2_FP_H\n\ntypedef struct\n{\n    TPMI_RH_NV_INDEX nvIndex;\n} NV_ReadPublic2_In;\n\ntypedef struct\n{\n    TPM2B_NV_PUBLIC_2 nvPublic;\n    TPM2B_NAME        nvName;\n} NV_ReadPublic2_Out;\n\n#    define RC_NV_ReadPublic2_nvIndex (TPM_RC_H + TPM_RC_1)\n\n// Function prototype\nTPM_RC\nTPM2_NV_ReadPublic2(NV_ReadPublic2_In* in, NV_ReadPublic2_Out* out);\n\n#  endif\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_ReadPublic_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_ReadPublic_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_READPUBLIC_FP_H\n#define NV_READPUBLIC_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_INDEX\tnvIndex;\n} NV_ReadPublic_In;\n\n#define RC_NV_ReadPublic_nvIndex\t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPM2B_NV_PUBLIC\tnvPublic;\n    TPM2B_NAME\t\tnvName;\n} NV_ReadPublic_Out;\n\nTPM_RC\nTPM2_NV_ReadPublic(\n\t\t   NV_ReadPublic_In    *in,            // IN: input parameter list\n\t\t   NV_ReadPublic_Out   *out            // OUT: output parameter list\n\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_Read_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_Read_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_READ_FP_H\n#define NV_READ_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n    UINT16\t\tsize;\n    UINT16\t\toffset;\n} NV_Read_In;\n\n#define RC_NV_Read_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_Read_nvIndex\t(TPM_RC_H + TPM_RC_2)\n#define RC_NV_Read_size \t(TPM_RC_P + TPM_RC_1)\n#define RC_NV_Read_offset \t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPM2B_MAX_NV_BUFFER\tdata;\n} NV_Read_Out;\n\nTPM_RC\nTPM2_NV_Read(\n\t     NV_Read_In      *in,            // IN: input parameter list\n\t     NV_Read_Out     *out            // OUT: output parameter list\n\t     );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_SetBits_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_SetBits_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_SETBITS_FP_H\n#define NV_SETBITS_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n    UINT64\t\tbits;\n} NV_SetBits_In;\n\n#define RC_NV_SetBits_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_SetBits_nvIndex \t\t(TPM_RC_H + TPM_RC_2)\n#define RC_NV_SetBits_bits\t\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_NV_SetBits(\n\t\tNV_SetBits_In   *in             // IN: input parameter list\n\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_UndefineSpaceSpecial_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t$Id: NV_UndefineSpaceSpecial_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_UNDEFINESPACESPECIAL_FP_H\n#define NV_UNDEFINESPACESPECIAL_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_INDEX\tnvIndex;\n    TPMI_RH_PLATFORM\tplatform;\n} NV_UndefineSpaceSpecial_In;\n\n#define RC_NV_UndefineSpaceSpecial_nvIndex \t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_UndefineSpaceSpecial_platform\t(TPM_RC_H + TPM_RC_2)\n\nTPM_RC\nTPM2_NV_UndefineSpaceSpecial(\n\t\t\t     NV_UndefineSpaceSpecial_In  *in             // IN: input parameter list\n\t\t\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_UndefineSpace_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_UndefineSpace_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_UNDEFINESPACE_FP_H\n#define NV_UNDEFINESPACE_FP_H\n\ntypedef struct {\n    TPMI_RH_PROVISION\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n} NV_UndefineSpace_In;\n\n#define RC_NV_UndefineSpace_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_UndefineSpace_nvIndex \t(TPM_RC_H + TPM_RC_2)\n\nTPM_RC\nTPM2_NV_UndefineSpace(\n\t\t      NV_UndefineSpace_In     *in             // IN: input parameter list\n\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_WriteLock_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_WriteLock_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_WRITELOCK_FP_H\n#define NV_WRITELOCK_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n} NV_WriteLock_In;\n\n#define RC_NV_WriteLock_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_WriteLock_nvIndex \t(TPM_RC_H + TPM_RC_2)\n\nTPM_RC\nTPM2_NV_WriteLock(\n\t\t  NV_WriteLock_In     *in             // IN: input parameter list\n\t\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_Write_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: NV_Write_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef NV_WRITE_FP_H\n#define NV_WRITE_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n    TPM2B_MAX_NV_BUFFER\tdata;\n    UINT16\t\toffset;\n} NV_Write_In;\n\n#define RC_NV_Write_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_NV_Write_nvIndex\t(TPM_RC_H + TPM_RC_2)\n#define RC_NV_Write_data\t(TPM_RC_P + TPM_RC_1)\n#define RC_NV_Write_offset \t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_NV_Write(\n\t      NV_Write_In     *in             // IN: input parameter list\n\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/NV_spt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef NV_SPT_FP_H\n#define NV_SPT_FP_H\n\nTPM_RC\nNvReadAccessChecks(\n\t\t   TPM_HANDLE       authHandle,    // IN: the handle that provided the\n\t\t   //     authorization\n\t\t   TPM_HANDLE       nvHandle,      // IN: the handle of the NV index to be read\n\t\t   TPMA_NV          attributes     // IN: the attributes of 'nvHandle'\n\t\t   );\nTPM_RC\nNvWriteAccessChecks(\n\t\t    TPM_HANDLE       authHandle,    // IN: the handle that provided the\n\t\t    //     authorization\n\t\t    TPM_HANDLE       nvHandle,      // IN: the handle of the NV index to be written\n\t\t    TPMA_NV          attributes     // IN: the attributes of 'nvHandle'\n\t\t    );\nTPM_RC\nNvClearOrderly(\n\t       void\n\t       );\nBOOL\nNvIsPinPassIndex(\n\t\t TPM_HANDLE          index       // IN: Handle to check\n\t\t );\nTPM2B_NAME* NvGetIndexName(\n\t\t\t   NV_INDEX* nvIndex,  // IN: the index over which the name is to be\n\t\t\t   //     computed\n\t\t\t   TPM2B_NAME* name    // OUT: name of the index\n\t\t\t   );\nTPM_RC NvPublic2FromNvPublic(\n\t\t\t     TPMS_NV_PUBLIC*   nvPublic,  // IN: the source S-form NV public area\n\t\t\t     TPMT_NV_PUBLIC_2* nvPublic2  // OUT: the T-form NV public area to populate\n\t\t\t     );\nTPM_RC NvPublicFromNvPublic2(\n\t\t\t     TPMT_NV_PUBLIC_2* nvPublic2,  // IN: the source T-form NV public area\n\t\t\t     TPMS_NV_PUBLIC*   nvPublic    // OUT: the S-form NV public area to populate\n\t\t\t     );\nTPM_RC NvDefineSpace(TPMI_RH_PROVISION authHandle,\n\t\t     TPM2B_AUTH*       auth,\n\t\t     TPMS_NV_PUBLIC*   publicInfo,\n\t\t     TPM_RC            blameAuthHandle,\n\t\t     TPM_RC            blameAuth,\n\t\t     TPM_RC            blamePublic);\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/OIDs.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tOID values\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: OIDs.h 1628 2020-05-27 19:35:29Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// 10.1.16\tOIDs.h\n\n#include \"Tpm.h\"\n\n#ifndef _OIDS_H_\n#define _OIDS_H_\n\n// All the OIDs in this file are defined as DER-encoded values with a leading tag 0x06\n// (ASN1_OBJECT_IDENTIFIER), followed by a single length byte. This allows the OID size to be\n// determined by looking at octet[1] of the OID (total size is OID[1] + 2).\n\n// These macros allow OIDs to be defined (or not) depending on whether the associated hash\n// algorithm is implemented.\n\n// NOTE: When one of these macros is used, the NAME needs '_\" on each side. The exception is when\n// the macro is used for the hash OID when only a single _ is used.\n\n#ifndef ALG_SHA1\n#   define ALG_SHA1 NO\n#endif\n#if ALG_SHA1\n#define SHA1_OID(NAME)    MAKE_OID(NAME##SHA1)\n#else\n#define SHA1_OID(NAME)\n#endif\n#ifndef ALG_SHA256\n#   define ALG_SHA256 NO\n#endif\n#if ALG_SHA256\n#define SHA256_OID(NAME)  MAKE_OID(NAME##SHA256)\n#else\n#define SHA256_OID(NAME)\n#endif\n#ifndef ALG_SHA384\n#   define ALG_SHA384 NO\n#endif\n#if ALG_SHA384\n#define SHA384_OID(NAME)  MAKE_OID(NAME##SHA384)\n#else\n#define SHA384_OID(NAME)\n#endif\n#ifndef ALG_SHA512\n#   define ALG_SHA512 NO\n#endif\n#if ALG_SHA512\n#define SHA512_OID(NAME)  MAKE_OID(NAME##SHA512)\n#else\n#define SHA512_OID(NAME)\n#endif\n#ifndef ALG_SM3_256\n#   define ALG_SM3_256 NO\n#endif\n#if ALG_SM3_256\n#define SM3_256_OID(NAME) MAKE_OID(NAME##SM3_256)\n#else\n#define SM3_256_OID(NAME)\n#endif\n#ifndef ALG_SHA3_256\n#   define ALG_SHA3_256 NO\n#endif\n#if ALG_SHA3_256\n#define SHA3_256_OID(NAME) MAKE_OID(NAME##SHA3_256)\n#else\n#define SHA3_256_OID(NAME)\n#endif\n#ifndef ALG_SHA3_384\n#   define ALG_SHA3_384 NO\n#endif\n#if ALG_SHA3_384\n#define SHA3_384_OID(NAME) MAKE_OID(NAME##SHA3_384)\n#else\n#define SHA3_384_OID(NAME)\n#endif\n#ifndef ALG_SHA3_512\n#   define ALG_SHA3_512 NO\n#endif\n#if ALG_SHA3_512\n#define SHA3_512_OID(NAME) MAKE_OID(NAME##SHA3_512)\n#else\n#define SHA3_512_OID(NAME)\n#endif\n// These are encoded to take one additional byte of algorithm selector\n#define NIST_HASH       0x06, 0x09, 0x60, 0x86, 0x48, 1, 101, 3, 4, 2\n#define NIST_SIG        0x06, 0x09, 0x60, 0x86, 0x48, 1, 101, 3, 4, 3\n\n// These hash OIDs used in a lot of places.\n#define OID_SHA1_VALUE              0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A\nSHA1_OID(_);        // Expands to:\n//     MAKE_OID(_SHA1)\n// which expands to:\n//     EXTERN  const BYTE OID_SHA1[] INITIALIZER({OID_SHA1_VALUE})\n// which, depending on the setting of EXTERN and\n// INITIALIZER, expands to either:\n//      extern const BYTE    OID_SHA1[]\n// or\n//      const BYTE           OID_SHA1[] = {OID_SHA1_VALUE}\n// which is:\n//      const BYTE           OID_SHA1[] = {0x06, 0x05, 0x2B, 0x0E,\n//                                         0x03, 0x02, 0x1A}\n#define OID_SHA256_VALUE            NIST_HASH, 1\nSHA256_OID(_);\n#define OID_SHA384_VALUE            NIST_HASH, 2\nSHA384_OID(_);\n#define OID_SHA512_VALUE            NIST_HASH, 3\nSHA512_OID(_);\n#define OID_SM3_256_VALUE           0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, \\\n\t0x83, 0x11\nSM3_256_OID(_);         // (1.2.156.10197.1.401)\n#define OID_SHA3_256_VALUE          NIST_HASH, 8\nSHA3_256_OID(_);\n#define OID_SHA3_384_VALUE          NIST_HASH, 9\nSHA3_384_OID(_);\n#define OID_SHA3_512_VALUE          NIST_HASH, 10\nSHA3_512_OID(_);\n// These are used for RSA-PSS\n#if ALG_RSA\n#define OID_MGF1_VALUE              0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, \\\n\t0x01, 0x01, 0x08\nMAKE_OID(_MGF1);\n#define OID_RSAPSS_VALUE            0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, \\\n\t0x01, 0x01, 0x0A\nMAKE_OID(_RSAPSS);\n// This is the OID to designate the public part of an RSA key.\n#define OID_PKCS1_PUB_VALUE         0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, \\\n\t0x01, 0x01, 0x01\nMAKE_OID(_PKCS1_PUB);\n// These are used for RSA PKCS1 signature Algorithms\n#define OID_PKCS1_SHA1_VALUE        0x06,0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, \\\n\t0x0D, 0x01, 0x01, 0x05\nSHA1_OID(_PKCS1_);      // (1.2.840.113549.1.1.5)\n#define OID_PKCS1_SHA256_VALUE      0x06,0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, \\\n\t0x0D, 0x01, 0x01, 0x0B\nSHA256_OID(_PKCS1_);    // (1.2.840.113549.1.1.11)\n#define OID_PKCS1_SHA384_VALUE      0x06,0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, \\\n\t0x0D, 0x01, 0x01, 0x0C\nSHA384_OID(_PKCS1_);    // (1.2.840.113549.1.1.12)\n#define OID_PKCS1_SHA512_VALUE      0x06,0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, \\\n\t0x0D, 0x01, 0x01, 0x0D\nSHA512_OID(_PKCS1_);    //(1.2.840.113549.1.1.13)\n#define OID_PKCS1_SM3_256_VALUE     0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, \\\n\t0x01, 0x83, 0x78\nSM3_256_OID(_PKCS1_);   // 1.2.156.10197.1.504\n#define OID_PKCS1_SHA3_256_VALUE    NIST_SIG, 14\nSHA3_256_OID(_PKCS1_);\n#define OID_PKCS1_SHA3_384_VALUE    NIST_SIG, 15\nSHA3_384_OID(_PKCS1_);\n#define OID_PKCS1_SHA3_512_VALUE    NIST_SIG, 16\nSHA3_512_OID(_PKCS1_);\n#endif // ALG_RSA\n#if ALG_ECDSA\n#define OID_ECDSA_SHA1_VALUE        0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, \\\n\t0x01\nSHA1_OID(_ECDSA_);      // (1.2.840.10045.4.1) SHA1 digest signed by an ECDSA key.\n#define OID_ECDSA_SHA256_VALUE      0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, \\\n\t0x03, 0x02\nSHA256_OID(_ECDSA_);    // (1.2.840.10045.4.3.2) SHA256 digest signed by an ECDSA key.\n#define OID_ECDSA_SHA384_VALUE      0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, \\\n\t0x03, 0x03\nSHA384_OID(_ECDSA_);    // (1.2.840.10045.4.3.3) SHA384 digest signed by an ECDSA key.\n#define OID_ECDSA_SHA512_VALUE      0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x04, \\\n\t0x03, 0x04\nSHA512_OID(_ECDSA_);    // (1.2.840.10045.4.3.4) SHA512 digest signed by an ECDSA key.\n#define OID_ECDSA_SM3_256_VALUE     0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, \\\n\t0x83, 0x75\nSM3_256_OID(_ECDSA_);   // 1.2.156.10197.1.501\n#define OID_ECDSA_SHA3_256_VALUE    NIST_SIG, 10\nSHA3_256_OID(_ECDSA_);\n#define OID_ECDSA_SHA3_384_VALUE    NIST_SIG, 11\nSHA3_384_OID(_ECDSA_);\n#define OID_ECDSA_SHA3_512_VALUE    NIST_SIG, 12\nSHA3_512_OID(_ECDSA_);\n#endif // ALG_ECDSA\n#if ALG_ECC\n#define OID_ECC_PUBLIC_VALUE        0x06, 0x07, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x02, \\\n\t0x01\nMAKE_OID(_ECC_PUBLIC);\n#define OID_ECC_NIST_P192_VALUE     0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, \\\n\t0x01, 0x01\n#if ECC_NIST_P192\nMAKE_OID(_ECC_NIST_P192);   // (1.2.840.10045.3.1.1) 'nistP192'\n#endif // ECC_NIST_P192\n#define OID_ECC_NIST_P224_VALUE     0x06, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x21\n#if ECC_NIST_P224\nMAKE_OID(_ECC_NIST_P224);   // (1.3.132.0.33)        'nistP224'\n#endif // ECC_NIST_P224\n#define OID_ECC_NIST_P256_VALUE     0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, \\\n\t0x01, 0x07\n#if ECC_NIST_P256\nMAKE_OID(_ECC_NIST_P256);   // (1.2.840.10045.3.1.7)  'nistP256'\n#endif // ECC_NIST_P256\n#define OID_ECC_NIST_P384_VALUE     0x06, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x22\n#if ECC_NIST_P384\nMAKE_OID(_ECC_NIST_P384);   // (1.3.132.0.34)         'nistP384'\n#endif // ECC_NIST_P384\n#define OID_ECC_NIST_P521_VALUE     0x06, 0x05, 0x2B, 0x81, 0x04, 0x00, 0x23\n#if ECC_NIST_P521\nMAKE_OID(_ECC_NIST_P521);   // (1.3.132.0.35)         'nistP521'\n#endif // ECC_NIST_P521\n// No OIDs defined for these anonymous curves\n#define OID_ECC_BN_P256_VALUE       0x00\n#if ECC_BN_P256\nMAKE_OID(_ECC_BN_P256);\n#endif // ECC_BN_P256\n#define OID_ECC_BN_P638_VALUE       0x00\n#if ECC_BN_P638\nMAKE_OID(_ECC_BN_P638);\n#endif // ECC_BN_P638\n#define OID_ECC_SM2_P256_VALUE      0x06, 0x08, 0x2A, 0x81, 0x1C, 0xCF, 0x55, 0x01, \\\n\t0x82, 0x2D\n#if ECC_SM2_P256\nMAKE_OID(_ECC_SM2_P256);    // Don't know where I found this OID. It needs checking\n#endif // ECC_SM2_P256\n#if ECC_BN_P256\n#define OID_ECC_BN_P256     NULL\n#endif // ECC_BN_P256\n#endif // ALG_ECC\n// #undef MAKE_OID\n#define OID_SIZE(OID)   (OID[1] + 2)\n#endif // !_OIDS_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ObjectChangeAuth_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ObjectChangeAuth_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef OBJECTCHANGEAUTH_FP_H\n#define OBJECTCHANGEAUTH_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tobjectHandle;\n    TPMI_DH_OBJECT\tparentHandle;\n    TPM2B_AUTH\t\tnewAuth;\n} ObjectChangeAuth_In;\n\n#define RC_ObjectChangeAuth_objectHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_ObjectChangeAuth_parentHandle \t(TPM_RC_H + TPM_RC_2)\n#define RC_ObjectChangeAuth_newAuth\t \t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPM2B_PRIVATE\toutPrivate;\n} ObjectChangeAuth_Out;\n\n\nTPM_RC\nTPM2_ObjectChangeAuth(\n\t\t      ObjectChangeAuth_In     *in,            // IN: input parameter list\n\t\t      ObjectChangeAuth_Out    *out            // OUT: output parameter list\n\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Object_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tFunctions That Manage the Object Store of the TPM\t  \t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar  4, 2020  Time: 02:36:44PM\n */\n\n#ifndef _OBJECT_FP_H_\n#define _OBJECT_FP_H_\n\n//*** ObjectFlush()\n// This function marks an object slot as available.\n// Since there is no checking of the input parameters, it should be used\n// judiciously.\n// Note: This could be converted to a macro.\nvoid ObjectFlush(OBJECT* object);\n\n//*** ObjectSetInUse()\n// This access function sets the occupied attribute of an object slot.\nvoid ObjectSetInUse(OBJECT* object);\n\n//*** ObjectStartup()\n// This function is called at TPM2_Startup() to initialize the object subsystem.\nBOOL ObjectStartup(void);\n\n//*** ObjectCleanupEvict()\n//\n// In this implementation, a persistent object is moved from NV into an object slot\n// for processing. It is flushed after command execution. This function is called\n// from ExecuteCommand().\nvoid ObjectCleanupEvict(void);\n\n//*** IsObjectPresent()\n// This function checks to see if a transient handle references a loaded\n// object.  This routine should not be called if the handle is not a\n// transient handle. The function validates that the handle is in the\n// implementation-dependent allowed in range for loaded transient objects.\n//  Return Type: BOOL\n//      TRUE(1)         handle references a loaded object\n//      FALSE(0)        handle is not an object handle, or it does not\n//                      reference to a loaded object\nBOOL IsObjectPresent(TPMI_DH_OBJECT handle  // IN: handle to be checked\n\t\t     );\n\n//*** ObjectIsSequence()\n// This function is used to check if the object is a sequence object. This function\n// should not be called if the handle does not reference a loaded object.\n//  Return Type: BOOL\n//      TRUE(1)         object is an HMAC, hash, or event sequence object\n//      FALSE(0)        object is not an HMAC, hash, or event sequence object\nBOOL ObjectIsSequence(OBJECT* object  // IN: handle to be checked\n\t\t      );\n\n//*** HandleToObject()\n// This function is used to find the object structure associated with a handle.\n//\n// This function requires that 'handle' references a loaded object or a permanent\n// handle.\nOBJECT* HandleToObject(TPMI_DH_OBJECT handle  // IN: handle of the object\n\t\t       );\n\n//*** GetQualifiedName()\n// This function returns the Qualified Name of the object. In this implementation,\n// the Qualified Name is computed when the object is loaded and is saved in the\n// internal representation of the object. The alternative would be to retain the\n// Name of the parent and compute the QN when needed. This would take the same\n// amount of space so it is not recommended that the alternate be used.\n//\n// This function requires that 'handle' references a loaded object.\nvoid GetQualifiedName(TPMI_DH_OBJECT handle,     // IN: handle of the object\n\t\t      TPM2B_NAME* qualifiedName  // OUT: qualified name of the object\n\t\t      );\n\n//*** GetHierarchy()\n// This function returns the handle of the hierarchy to which a handle belongs.\n//\n// This function requires that 'handle' references a loaded object.\nTPMI_RH_HIERARCHY\nGetHierarchy(TPMI_DH_OBJECT handle  // IN :object handle\n\t     );\n\n//*** FindEmptyObjectSlot()\n// This function finds an open object slot, if any. It will clear the attributes\n// but will not set the occupied attribute. This is so that a slot may be used\n// and discarded if everything does not go as planned.\n//  Return Type: OBJECT *\n//      NULL        no open slot found\n//      != NULL     pointer to available slot\nOBJECT* FindEmptyObjectSlot(TPMI_DH_OBJECT* handle  // OUT: (optional)\n\t\t\t    );\n\n//*** ObjectAllocateSlot()\n// This function is used to allocate a slot in internal object array.\nOBJECT* ObjectAllocateSlot(TPMI_DH_OBJECT* handle  // OUT: handle of allocated object\n\t\t\t   );\n\n//*** ObjectSetLoadedAttributes()\n// This function sets the internal attributes for a loaded object. It is called to\n// finalize the OBJECT attributes (not the TPMA_OBJECT attributes) for a loaded\n// object.\nvoid ObjectSetLoadedAttributes(OBJECT* object,  // IN: object attributes to finalize\n\t\t\t       TPM_HANDLE parentHandle  // IN: the parent handle\n\t\t\t       );\n\n//*** ObjectLoad()\n// Common function to load a non-primary object (i.e., either an Ordinary Object,\n// or an External Object). A loaded object has its public area validated\n// (unless its 'nameAlg' is TPM_ALG_NULL). If a sensitive part is loaded, it is\n// verified to be correct and if both public and sensitive parts are loaded, then\n// the cryptographic binding between the objects is validated. This function does\n// not cause the allocated slot to be marked as in use.\nTPM_RC\nObjectLoad(OBJECT* object,           // IN: pointer to object slot\n\t   //     object\n\t   OBJECT*      parent,      // IN: (optional) the parent object\n\t   TPMT_PUBLIC* publicArea,  // IN: public area to be installed in the object\n\t   TPMT_SENSITIVE* sensitive,  // IN: (optional) sensitive area to be\n\t   //      installed in the object\n\t   TPM_RC blamePublic,         // IN: parameter number to associate with the\n\t   //     publicArea errors\n\t   TPM_RC blameSensitive,      // IN: parameter number to associate with the\n\t   //     sensitive area errors\n\t   TPM2B_NAME* name            // IN: (optional)\n\t   );\n\n#if CC_HMAC_Start || CC_MAC_Start\n//*** ObjectCreateHMACSequence()\n// This function creates an internal HMAC sequence object.\n//  Return Type: TPM_RC\n//      TPM_RC_OBJECT_MEMORY        if there is no free slot for an object\nTPM_RC\nObjectCreateHMACSequence(\n\t\t\t TPMI_ALG_HASH   hashAlg,    // IN: hash algorithm\n\t\t\t OBJECT*         keyObject,  // IN: the object containing the HMAC key\n\t\t\t TPM2B_AUTH*     auth,       // IN: authValue\n\t\t\t TPMI_DH_OBJECT* newHandle   // OUT: HMAC sequence object handle\n\t\t\t );\n#endif\n\n//*** ObjectCreateHashSequence()\n// This function creates a hash sequence object.\n//  Return Type: TPM_RC\n//      TPM_RC_OBJECT_MEMORY        if there is no free slot for an object\nTPM_RC\nObjectCreateHashSequence(TPMI_ALG_HASH   hashAlg,   // IN: hash algorithm\n\t\t\t TPM2B_AUTH*     auth,      // IN: authValue\n\t\t\t TPMI_DH_OBJECT* newHandle  // OUT: sequence object handle\n\t\t\t );\n\n//*** ObjectCreateEventSequence()\n// This function creates an event sequence object.\n//  Return Type: TPM_RC\n//      TPM_RC_OBJECT_MEMORY        if there is no free slot for an object\nTPM_RC\nObjectCreateEventSequence(TPM2B_AUTH*     auth,      // IN: authValue\n\t\t\t  TPMI_DH_OBJECT* newHandle  // OUT: sequence object handle\n\t\t\t  );\n\n//*** ObjectTerminateEvent()\n// This function is called to close out the event sequence and clean up the hash\n// context states.\nvoid ObjectTerminateEvent(void);\n\n//*** ObjectContextLoad()\n// This function loads an object from a saved object context.\n//  Return Type: OBJECT *\n//      NULL        if there is no free slot for an object\n//      != NULL     points to the loaded object\nOBJECT* ObjectContextLoad(\n\t\t\t  ANY_OBJECT_BUFFER* object,  // IN: pointer to object structure in saved\n\t\t\t  //     context\n\t\t\t  TPMI_DH_OBJECT* handle      // OUT: object handle\n\t\t\t  );\n\n//*** FlushObject()\n// This function frees an object slot.\n//\n// This function requires that the object is loaded.\nvoid FlushObject(TPMI_DH_OBJECT handle  // IN: handle to be freed\n\t\t );\n\n//*** ObjectFlushHierarchy()\n// This function is called to flush all the loaded transient objects associated\n// with a hierarchy when the hierarchy is disabled.\nvoid ObjectFlushHierarchy(TPMI_RH_HIERARCHY hierarchy  // IN: hierarchy to be flush\n\t\t\t  );\n\n//*** ObjectLoadEvict()\n// This function loads a persistent object into a transient object slot.\n//\n// This function requires that 'handle' is associated with a persistent object.\n//  Return Type: TPM_RC\n//      TPM_RC_HANDLE               the persistent object does not exist\n//                                  or the associated hierarchy is disabled.\n//      TPM_RC_OBJECT_MEMORY        no object slot\nTPM_RC\nObjectLoadEvict(TPM_HANDLE* handle,  // IN:OUT: evict object handle.  If success, it\n\t\t// will be replace by the loaded object handle\n\t\tCOMMAND_INDEX commandIndex  // IN: the command being processed\n\t\t);\n\n//*** ObjectComputeName()\n// This does the name computation from a public area (can be marshaled or not).\nTPM2B_NAME* ObjectComputeName(UINT32     size,  // IN: the size of the area to digest\n\t\t\t      BYTE*      publicArea,  // IN: the public area to digest\n\t\t\t      TPM_ALG_ID nameAlg,     // IN: the hash algorithm to use\n\t\t\t      TPM2B_NAME* name        // OUT: Computed name\n\t\t\t      );\n\n//*** PublicMarshalAndComputeName()\n// This function computes the Name of an object from its public area.\nTPM2B_NAME* PublicMarshalAndComputeName(\n\t\t\t\t\tTPMT_PUBLIC* publicArea,  // IN: public area of an object\n\t\t\t\t\tTPM2B_NAME*  name         // OUT: name of the object\n\t\t\t\t\t);\n\n//*** ComputeQualifiedName()\n// This function computes the qualified name of an object.\nvoid ComputeQualifiedName(\n\t\t\t  TPM_HANDLE  parentHandle,  // IN: parent's handle\n\t\t\t  TPM_ALG_ID  nameAlg,       // IN: name hash\n\t\t\t  TPM2B_NAME* name,          // IN: name of the object\n\t\t\t  TPM2B_NAME* qualifiedName  // OUT: qualified name of the object\n\t\t\t  );\n\n//*** ObjectIsStorage()\n// This function determines if an object has the attributes associated\n// with a parent. A parent is an asymmetric or symmetric block cipher key\n// that has its 'restricted' and 'decrypt' attributes SET, and 'sign' CLEAR.\n//  Return Type: BOOL\n//      TRUE(1)         object is a storage key\n//      FALSE(0)        object is not a storage key\nBOOL ObjectIsStorage(TPMI_DH_OBJECT handle  // IN: object handle\n\t\t     );\n\n//*** ObjectCapGetLoaded()\n// This function returns a list of handles of loaded object, starting from\n// 'handle'. 'Handle' must be in the range of valid transient object handles,\n// but does not have to be the handle of a loaded transient object.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles available\n//      NO          all the available handles has been returned\nTPMI_YES_NO\nObjectCapGetLoaded(TPMI_DH_OBJECT handle,     // IN: start handle\n\t\t   UINT32         count,      // IN: count of returned handles\n\t\t   TPML_HANDLE*   handleList  // OUT: list of handle\n\t\t   );\n\n//*** ObjectCapGetOneLoaded()\n// This function returns whether a handle is loaded.\nBOOL ObjectCapGetOneLoaded(TPMI_DH_OBJECT handle  // IN: handle\n\t\t\t   );\n\n//*** ObjectCapGetTransientAvail()\n// This function returns an estimate of the number of additional transient\n// objects that could be loaded into the TPM.\nUINT32\nObjectCapGetTransientAvail(void);\n\n//*** ObjectGetPublicAttributes()\n// Returns the attributes associated with an object handles.\nTPMA_OBJECT\nObjectGetPublicAttributes(TPM_HANDLE handle);\n\nOBJECT_ATTRIBUTES\nObjectGetProperties(TPM_HANDLE handle);\n\n#endif  // _OBJECT_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Object_spt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Object Command Support   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar  7, 2020  Time: 07:06:44PM\n */\n\n#ifndef _OBJECT_SPT_FP_H_\n#define _OBJECT_SPT_FP_H_\n\n//*** AdjustAuthSize()\n// This function will validate that the input authValue is no larger than the\n// digestSize for the nameAlg. It will then pad with zeros to the size of the\n// digest.\nBOOL AdjustAuthSize(TPM2B_AUTH*   auth,    // IN/OUT: value to adjust\n\t\t    TPMI_ALG_HASH nameAlg  // IN:\n\t\t    );\n\n//*** AreAttributesForParent()\n// This function is called by create, load, and import functions.\n//\n// Note: The 'isParent' attribute is SET when an object is loaded and it has\n// attributes that are suitable for a parent object.\n//  Return Type: BOOL\n//      TRUE(1)         properties are those of a parent\n//      FALSE(0)        properties are not those of a parent\nBOOL ObjectIsParent(OBJECT* parentObject  // IN: parent handle\n\t\t    );\n\n//*** CreateChecks()\n// Attribute checks that are unique to creation.\n// If parentObject is not NULL, then this function checks the object's\n// attributes as an Ordinary or Derived Object with the given parent.\n// If parentObject is NULL, and primaryHandle is not 0, then this function\n// checks the object's attributes as a Primary Object in the given hierarchy.\n// If parentObject is NULL, and primaryHandle is 0, then this function checks\n// the object's attributes as an External Object.\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES       sensitiveDataOrigin is not consistent with the\n//                              object type\n//      other                   returns from PublicAttributesValidation()\nTPM_RC\nCreateChecks(OBJECT*           parentObject,\n\t     TPMI_RH_HIERARCHY primaryHierarchy,\n\t     TPMT_PUBLIC*      publicArea,\n\t     UINT16            sensitiveDataSize);\n\n//*** SchemeChecks\n// This function is called by TPM2_LoadExternal() and PublicAttributesValidation().\n// This function validates the schemes in the public area of an object.\n//  Return Type: TPM_RC\n//      TPM_RC_HASH         non-duplicable storage key and its parent have different\n//                          name algorithm\n//      TPM_RC_KDF          incorrect KDF specified for decrypting keyed hash object\n//      TPM_RC_KEY          invalid key size values in an asymmetric key public area\n//      TPM_RCS_SCHEME       inconsistent attributes 'decrypt', 'sign', 'restricted'\n//                          and key's scheme ID; or hash algorithm is inconsistent\n//                          with the scheme ID for keyed hash object\n//      TPM_RC_SYMMETRIC    a storage key with no symmetric algorithm specified; or\n//                          non-storage key with symmetric algorithm different from\n//                          TPM_ALG_NULL\nTPM_RC\nSchemeChecks(OBJECT*      parentObject,  // IN: parent (null if primary seed)\n\t     TPMT_PUBLIC* publicArea     // IN: public area of the object\n\t     );\n\n//*** PublicAttributesValidation()\n// This function validates the values in the public area of an object.\n// This function is used in the processing of TPM2_Create, TPM2_CreatePrimary,\n// TPM2_CreateLoaded(), TPM2_Load(),  TPM2_Import(), and TPM2_LoadExternal().\n// For TPM2_Import() this is only used if the new parent has fixedTPM SET. For\n// TPM2_LoadExternal(), this is not used for a public-only key.\n// If parentObject is not NULL, then primaryHandle is not used.\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES   'fixedTPM', 'fixedParent', or 'encryptedDuplication'\n//                          attributes are inconsistent between themselves or with\n//                          those of the parent object;\n//                          inconsistent 'restricted', 'decrypt' and 'sign'\n//                          attributes;\n//                          attempt to inject sensitive data for an asymmetric key;\n//                          attempt to create a symmetric cipher key that is not\n//                          a decryption key\n//      TPM_RC_HASH         nameAlg is TPM_ALG_NULL\n//      TPM_RC_SIZE         'authPolicy' size does not match digest size of the name\n//                          algorithm in 'publicArea'\n//   other                  returns from SchemeChecks()\nTPM_RC\nPublicAttributesValidation(\n\t\t\t   // IN: input parent object (if ordinary or derived object; NULL otherwise)\n\t\t\t   OBJECT* parentObject,\n\t\t\t   // IN: hierarchy (if primary object; 0 otherwise)\n\t\t\t   TPMI_RH_HIERARCHY primaryHierarchy,\n\t\t\t   // IN: public area of the object\n\t\t\t   TPMT_PUBLIC* publicArea);\n\n//*** FillInCreationData()\n// Fill in creation data for an object.\n//  Return Type: void\nvoid FillInCreationData(\n\t\t\tTPMI_DH_OBJECT       parentHandle,   // IN: handle of parent\n\t\t\tTPMI_ALG_HASH        nameHashAlg,    // IN: name hash algorithm\n\t\t\tTPML_PCR_SELECTION*  creationPCR,    // IN: PCR selection\n\t\t\tTPM2B_DATA*          outsideData,    // IN: outside data\n\t\t\tTPM2B_CREATION_DATA* outCreation,    // OUT: creation data for output\n\t\t\tTPM2B_DIGEST*        creationDigest  // OUT: creation digest\n\t\t\t);\n\n//*** GetSeedForKDF()\n// Get a seed for KDF.  The KDF for encryption and HMAC key use the same seed.\nconst TPM2B* GetSeedForKDF(OBJECT* protector  // IN: the protector handle\n\t\t\t   );\n\n//*** ProduceOuterWrap()\n// This function produce outer wrap for a buffer containing the sensitive data.\n// It requires the sensitive data being marshaled to the outerBuffer, with the\n// leading bytes reserved for integrity hash.  If iv is used, iv space should\n// be reserved at the beginning of the buffer.  It assumes the sensitive data\n// starts at address (outerBuffer + integrity size @).\n// This function:\n//  a) adds IV before sensitive area if required;\n//  b) encrypts sensitive data with IV or a NULL IV as required;\n//  c) adds HMAC integrity at the beginning of the buffer; and\n//  d) returns the total size of blob with outer wrap.\nUINT16\nProduceOuterWrap(OBJECT* protector,   // IN: The handle of the object that provides\n\t\t //     protection.  For object, it is parent\n\t\t //     handle. For credential, it is the handle\n\t\t //     of encrypt object.\n\t\t TPM2B*     name,     // IN: the name of the object\n\t\t TPM_ALG_ID hashAlg,  // IN: hash algorithm for outer wrap\n\t\t TPM2B*     seed,     // IN: an external seed may be provided for\n\t\t //     duplication blob. For non duplication\n\t\t //     blob, this parameter should be NULL\n\t\t BOOL   useIV,        // IN: indicate if an IV is used\n\t\t UINT16 dataSize,     // IN: the size of sensitive data, excluding the\n\t\t //     leading integrity buffer size or the\n\t\t //     optional iv size\n\t\t BYTE* outerBuffer    // IN/OUT: outer buffer with sensitive data in\n\t\t //     it\n\t\t );\n\n//*** UnwrapOuter()\n// This function remove the outer wrap of a blob containing sensitive data\n// This function:\n//  a) checks integrity of outer blob; and\n//  b) decrypts the outer blob.\n//\n//  Return Type: TPM_RC\n//      TPM_RCS_INSUFFICIENT     error during sensitive data unmarshaling\n//      TPM_RCS_INTEGRITY        sensitive data integrity is broken\n//      TPM_RCS_SIZE             error during sensitive data unmarshaling\n//      TPM_RCS_VALUE            IV size for CFB does not match the encryption\n//                               algorithm block size\nTPM_RC\nUnwrapOuter(OBJECT* protector,   // IN: The object that provides\n\t    //     protection.  For object, it is parent\n\t    //     handle. For credential, it is the\n\t    //     encrypt object.\n\t    TPM2B*     name,     // IN: the name of the object\n\t    TPM_ALG_ID hashAlg,  // IN: hash algorithm for outer wrap\n\t    TPM2B*     seed,     // IN: an external seed may be provided for\n\t    //     duplication blob. For non duplication\n\t    //     blob, this parameter should be NULL.\n\t    BOOL   useIV,        // IN: indicates if an IV is used\n\t    UINT16 dataSize,     // IN: size of sensitive data in outerBuffer,\n\t    //     including the leading integrity buffer\n\t    //     size, and an optional iv area\n\t    BYTE* outerBuffer    // IN/OUT: sensitive data\n\t    );\n\n//*** SensitiveToPrivate()\n// This function prepare the private blob for off the chip storage\n// This function:\n//  a) marshals TPM2B_SENSITIVE structure into the buffer of TPM2B_PRIVATE\n//  b) applies encryption to the sensitive area; and\n//  c) applies outer integrity computation.\nvoid SensitiveToPrivate(\n\t\t\tTPMT_SENSITIVE* sensitive,  // IN: sensitive structure\n\t\t\tTPM2B_NAME*     name,       // IN: the name of the object\n\t\t\tOBJECT*         parent,     // IN: The parent object\n\t\t\tTPM_ALG_ID      nameAlg,    // IN: hash algorithm in public area.  This\n\t\t\t//     parameter is used when parentHandle is\n\t\t\t//     NULL, in which case the object is\n\t\t\t//     temporary.\n\t\t\tTPM2B_PRIVATE* outPrivate   // OUT: output private structure\n\t\t\t);\n\n//*** PrivateToSensitive()\n// Unwrap a input private area.  Check the integrity, decrypt and retrieve data\n// to a sensitive structure.\n// This function:\n//  a) checks the integrity HMAC of the input private area;\n//  b) decrypts the private buffer; and\n//  c) unmarshals TPMT_SENSITIVE structure into the buffer of TPMT_SENSITIVE.\n//  Return Type: TPM_RC\n//      TPM_RCS_INTEGRITY       if the private area integrity is bad\n//      TPM_RC_SENSITIVE        unmarshal errors while unmarshaling TPMS_ENCRYPT\n//                              from input private\n//      TPM_RCS_SIZE            error during sensitive data unmarshaling\n//      TPM_RCS_VALUE           outer wrapper does not have an iV of the correct\n//                              size\nTPM_RC\nPrivateToSensitive(TPM2B*     inPrivate,  // IN: input private structure\n\t\t   TPM2B*     name,       // IN: the name of the object\n\t\t   OBJECT*    parent,     // IN: parent object\n\t\t   TPM_ALG_ID nameAlg,    // IN: hash algorithm in public area.  It is\n\t\t   //     passed separately because we only pass\n\t\t   //     name, rather than the whole public area\n\t\t   //     of the object.  This parameter is used in\n\t\t   //     the following two cases: 1. primary\n\t\t   //     objects. 2. duplication blob with inner\n\t\t   //     wrap.  In other cases, this parameter\n\t\t   //     will be ignored\n\t\t   TPMT_SENSITIVE* sensitive  // OUT: sensitive structure\n\t\t   );\n\n//*** SensitiveToDuplicate()\n// This function prepare the duplication blob from the sensitive area.\n// This function:\n//  a) marshals TPMT_SENSITIVE structure into the buffer of TPM2B_PRIVATE;\n//  b) applies inner wrap to the sensitive area if required; and\n//  c) applies outer wrap if required.\nvoid SensitiveToDuplicate(\n\t\t\t  TPMT_SENSITIVE* sensitive,    // IN: sensitive structure\n\t\t\t  TPM2B*          name,         // IN: the name of the object\n\t\t\t  OBJECT*         parent,       // IN: The new parent object\n\t\t\t  TPM_ALG_ID      nameAlg,      // IN: hash algorithm in public area. It\n\t\t\t  //     is passed separately because we\n\t\t\t  //     only pass name, rather than the\n\t\t\t  //     whole public area of the object.\n\t\t\t  TPM2B* seed,                  // IN: the external seed. If external\n\t\t\t  //     seed is provided with size of 0,\n\t\t\t  //     no outer wrap should be applied\n\t\t\t  //     to duplication blob.\n\t\t\t  TPMT_SYM_DEF_OBJECT* symDef,  // IN: Symmetric key definition. If the\n\t\t\t  //     symmetric key algorithm is NULL,\n\t\t\t  //     no inner wrap should be applied.\n\t\t\t  TPM2B_DATA* innerSymKey,      // IN/OUT: a symmetric key may be\n\t\t\t  //     provided to encrypt the inner\n\t\t\t  //     wrap of a duplication blob. May\n\t\t\t  //     be generated here if needed.\n\t\t\t  TPM2B_PRIVATE* outPrivate     // OUT: output private structure\n\t\t\t  );\n\n//*** DuplicateToSensitive()\n// Unwrap a duplication blob.  Check the integrity, decrypt and retrieve data\n// to a sensitive structure.\n// This function:\n//  a) checks the integrity HMAC of the input private area;\n//  b) decrypts the private buffer; and\n//  c) unmarshals TPMT_SENSITIVE structure into the buffer of TPMT_SENSITIVE.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_INSUFFICIENT      unmarshaling sensitive data from 'inPrivate' failed\n//      TPM_RC_INTEGRITY         'inPrivate' data integrity is broken\n//      TPM_RC_SIZE              unmarshaling sensitive data from 'inPrivate' failed\nTPM_RC\nDuplicateToSensitive(\n\t\t     TPM2B*     inPrivate,         // IN: input private structure\n\t\t     TPM2B*     name,              // IN: the name of the object\n\t\t     OBJECT*    parent,            // IN: the parent\n\t\t     TPM_ALG_ID nameAlg,           // IN: hash algorithm in public area.\n\t\t     TPM2B*     seed,              // IN: an external seed may be provided.\n\t\t     //     If external seed is provided with\n\t\t     //     size of 0, no outer wrap is\n\t\t     //     applied\n\t\t     TPMT_SYM_DEF_OBJECT* symDef,  // IN: Symmetric key definition. If the\n\t\t     //     symmetric key algorithm is NULL,\n\t\t     //     no inner wrap is applied\n\t\t     TPM2B* innerSymKey,           // IN: a symmetric key may be provided\n\t\t     //     to decrypt the inner wrap of a\n\t\t     //     duplication blob.\n\t\t     TPMT_SENSITIVE* sensitive     // OUT: sensitive structure\n\t\t     );\n\n//*** SecretToCredential()\n// This function prepare the credential blob from a secret (a TPM2B_DIGEST)\n// This function:\n//  a) marshals TPM2B_DIGEST structure into the buffer of TPM2B_ID_OBJECT;\n//  b) encrypts the private buffer, excluding the leading integrity HMAC area;\n//  c) computes integrity HMAC and append to the beginning of the buffer; and\n//  d) sets the total size of TPM2B_ID_OBJECT buffer.\nvoid SecretToCredential(TPM2B_DIGEST*    secret,      // IN: secret information\n\t\t\tTPM2B*           name,        // IN: the name of the object\n\t\t\tTPM2B*           seed,        // IN: an external seed.\n\t\t\tOBJECT*          protector,   // IN: the protector\n\t\t\tTPM2B_ID_OBJECT* outIDObject  // OUT: output credential\n\t\t\t);\n\n//*** CredentialToSecret()\n// Unwrap a credential.  Check the integrity, decrypt and retrieve data\n// to a TPM2B_DIGEST structure.\n// This function:\n//  a) checks the integrity HMAC of the input credential area;\n//  b) decrypts the credential buffer; and\n//  c) unmarshals TPM2B_DIGEST structure into the buffer of TPM2B_DIGEST.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_INSUFFICIENT      error during credential unmarshaling\n//      TPM_RC_INTEGRITY         credential integrity is broken\n//      TPM_RC_SIZE              error during credential unmarshaling\n//      TPM_RC_VALUE             IV size does not match the encryption algorithm\n//                               block size\nTPM_RC\nCredentialToSecret(TPM2B*        inIDObject,  // IN: input credential blob\n\t\t   TPM2B*        name,        // IN: the name of the object\n\t\t   TPM2B*        seed,        // IN: an external seed.\n\t\t   OBJECT*       protector,   // IN: the protector\n\t\t   TPM2B_DIGEST* secret       // OUT: secret information\n\t\t   );\n\n//*** MemoryRemoveTrailingZeros()\n// This function is used to adjust the length of an authorization value.\n// It adjusts the size of the TPM2B so that it does not include octets\n// at the end of the buffer that contain zero.\n//\n// This function returns the number of non-zero octets in the buffer.\nUINT16\nMemoryRemoveTrailingZeros(TPM2B_AUTH* auth  // IN/OUT: value to adjust\n\t\t\t  );\n\n//*** SetLabelAndContext()\n// This function sets the label and context for a derived key. It is possible\n// that 'label' or 'context' can end up being an Empty Buffer.\nTPM_RC\nSetLabelAndContext(TPMS_DERIVE* labelContext,       // IN/OUT: the recovered label and\n\t\t   //      context\n\t\t   TPM2B_SENSITIVE_DATA* sensitive  // IN: the sensitive data\n\t\t   );\n\n//*** UnmarshalToPublic()\n// Support function to unmarshal the template. This is used because the\n// Input may be a TPMT_TEMPLATE and that structure does not have the same\n// size as a TPMT_PUBLIC because of the difference between the 'unique' and\n// 'seed' fields.\n//\n// If 'derive' is not NULL, then the 'seed' field is assumed to contain\n// a 'label' and 'context' that are unmarshaled into 'derive'.\nTPM_RC\nUnmarshalToPublic(TPMT_PUBLIC*    tOut,  // OUT: output\n\t\t  TPM2B_TEMPLATE* tIn,   // IN:\n\t\t  BOOL derivation,       // IN: indicates if this is for a derivation\n\t\t  TPMS_DERIVE* labelContext  // OUT: label and context if derivation\n\t\t  );\n\n//*** ObjectSetExternal()\n// Set the external attributes for an object.\nvoid ObjectSetExternal(OBJECT* object);\n\n#endif  // _OBJECT_SPT_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PCR_Allocate_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PCR_Allocate_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef PCR_ALLOCATE_FP_H\n#define PCR_ALLOCATE_FP_H\n\ntypedef struct {\n    TPMI_RH_PLATFORM\tauthHandle;\n    TPML_PCR_SELECTION\tpcrAllocation;\n} PCR_Allocate_In;\n\n#define RC_PCR_Allocate_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_PCR_Allocate_pcrAllocation\t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPMI_YES_NO\tallocationSuccess;\n    UINT32\tmaxPCR;\n    UINT32\tsizeNeeded;\n    UINT32\tsizeAvailable;\n} PCR_Allocate_Out;\n\nTPM_RC\nTPM2_PCR_Allocate(\n\t\t  PCR_Allocate_In     *in,            // IN: input parameter list\n\t\t  PCR_Allocate_Out    *out            // OUT: output parameter list\n\t\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PCR_Event_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PCR_Event_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef PCR_EVENT_FP_H\n#define PCR_EVENT_FP_H\n\ntypedef struct {\n    TPMI_DH_PCR\t\tpcrHandle;\n    TPM2B_EVENT\t\teventData;\n} PCR_Event_In;\n\n#define RC_PCR_Event_pcrHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_PCR_Event_eventData\t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPML_DIGEST_VALUES\tdigests;\n} PCR_Event_Out;\n\nTPM_RC\nTPM2_PCR_Event(\n\t       PCR_Event_In    *in,            // IN: input parameter list\n\t       PCR_Event_Out   *out            // OUT: output parameter list\n\t       );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PCR_Extend_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PCR_Extend_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef PCR_EXTEND_FP_H\n#define PCR_EXTEND_FP_H\n\ntypedef struct {\n    TPMI_DH_PCR\t\tpcrHandle;\n    TPML_DIGEST_VALUES\tdigests;\n} PCR_Extend_In;\n\n#define RC_PCR_Extend_pcrHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_PCR_Extend_digests\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PCR_Extend(\n\t\tPCR_Extend_In   *in             // IN: input parameter list\n\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PCR_Read_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PCR_Read_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef PCR_READ_FP_H\n#define PCR_READ_FP_H\n\ntypedef struct {\n    TPML_PCR_SELECTION\tpcrSelectionIn;\n} PCR_Read_In;\n\n#define RC_PCR_Read_pcrSelectionIn\t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    UINT32\t\tpcrUpdateCounter;\n    TPML_PCR_SELECTION\tpcrSelectionOut;\n    TPML_DIGEST\t\tpcrValues;\n} PCR_Read_Out;\n\nTPM_RC\nTPM2_PCR_Read(\n\t      PCR_Read_In     *in,            // IN: input parameter list\n\t      PCR_Read_Out    *out            // OUT: output parameter list\n\t      );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PCR_Reset_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PCR_Reset_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef PCR_RESET_FP_H\n#define PCR_RESET_FP_H\n\ntypedef struct {\n    TPMI_DH_PCR\tpcrHandle;\n} PCR_Reset_In;\n\n#define RC_PCR_Reset__pcrHandle\t(TPM_RC_H + TPM_RC_1)\n\nTPM_RC\nTPM2_PCR_Reset(\n\t       PCR_Reset_In    *in             // IN: input parameter list\n\t       );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PCR_SetAuthPolicy_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PCR_SetAuthPolicy_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef PCR_SETAUTHPOLICY_FP_H\n#define PCR_SETAUTHPOLICY_FP_H\n\ntypedef struct {\n    TPMI_RH_PLATFORM\tauthHandle;\n    TPM2B_DIGEST\tauthPolicy;\n    TPMI_ALG_HASH\thashAlg;\n    TPMI_DH_PCR\t\tpcrNum;\n} PCR_SetAuthPolicy_In;\n\n#define RC_PCR_SetAuthPolicy_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_PCR_SetAuthPolicy_authPolicy (TPM_RC_P + TPM_RC_1)\n#define RC_PCR_SetAuthPolicy_hashAlg\t(TPM_RC_P + TPM_RC_2)\n#define RC_PCR_SetAuthPolicy_pcrNum \t(TPM_RC_P + TPM_RC_3)\n\nTPM_RC\nTPM2_PCR_SetAuthPolicy(\n\t\t       PCR_SetAuthPolicy_In    *in             // IN: input parameter list\n\t\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PCR_SetAuthValue_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PCR_SetAuthValue_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef PCR_SETAUTHVALUE_FP_H\n#define PCR_SETAUTHVALUE_FP_H\n\ntypedef struct {\n    TPMI_DH_PCR\t\tpcrHandle;\n    TPM2B_DIGEST\tauth;\n} PCR_SetAuthValue_In;\n\n#define RC_PCR_SetAuthValue_pcrHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_PCR_SetAuthValue_auth\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PCR_SetAuthValue(\n\t\t      PCR_SetAuthValue_In     *in             // IN: input parameter list\n\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PCR_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tFunctions Needed for PCR Access and Manipulation\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar  4, 2020  Time: 02:36:44PM\n */\n\n#ifndef _PCR_FP_H_\n#define _PCR_FP_H_\n\n//*** PCRBelongsAuthGroup()\n// This function indicates if a PCR belongs to a group that requires an authValue\n// in order to modify the PCR.  If it does, 'groupIndex' is set to value of\n// the group index.  This feature of PCR is decided by the platform specification.\n//\n//  Return Type: BOOL\n//      TRUE(1)         PCR belongs an authorization group\n//      FALSE(0)        PCR does not belong an authorization group\nBOOL PCRBelongsAuthGroup(TPMI_DH_PCR handle,     // IN: handle of PCR\n\t\t\t UINT32*     groupIndex  // OUT: group index if PCR belongs a\n\t\t\t //      group that allows authValue.  If PCR\n\t\t\t //      does not belong to an authorization\n\t\t\t //      group, the value in this parameter is\n\t\t\t //      invalid\n\t\t\t );\n\n//*** PCRBelongsPolicyGroup()\n// This function indicates if a PCR belongs to a group that requires a policy\n// authorization in order to modify the PCR.  If it does, 'groupIndex' is set\n// to value of the group index.  This feature of PCR is decided by the platform\n// specification.\n//\n//  Return Type: BOOL\n//      TRUE(1)         PCR belongs to a policy group\n//      FALSE(0)        PCR does not belong to a policy group\nBOOL PCRBelongsPolicyGroup(\n\t\t\t   TPMI_DH_PCR handle,     // IN: handle of PCR\n\t\t\t   UINT32*     groupIndex  // OUT: group index if PCR belongs a group that\n\t\t\t   //     allows policy.  If PCR does not belong to\n\t\t\t   //     a policy group, the value in this\n\t\t\t   //     parameter is invalid\n\t\t\t   );\n\n//*** PCRPolicyIsAvailable()\n// This function indicates if a policy is available for a PCR.\n//\n//  Return Type: BOOL\n//      TRUE(1)         the PCR may be authorized by policy\n//      FALSE(0)        the PCR does not allow policy\nBOOL PCRPolicyIsAvailable(TPMI_DH_PCR handle  // IN: PCR handle\n\t\t\t  );\n\n//*** PCRGetAuthValue()\n// This function is used to access the authValue of a PCR.  If PCR does not\n// belong to an authValue group, an EmptyAuth will be returned.\nTPM2B_AUTH* PCRGetAuthValue(TPMI_DH_PCR handle  // IN: PCR handle\n\t\t\t    );\n\n//*** PCRGetAuthPolicy()\n// This function is used to access the authorization policy of a PCR. It sets\n// 'policy' to the authorization policy and returns the hash algorithm for policy\n//  If the PCR does not allow a policy, TPM_ALG_NULL is returned.\nTPMI_ALG_HASH\nPCRGetAuthPolicy(TPMI_DH_PCR   handle,  // IN: PCR handle\n\t\t TPM2B_DIGEST* policy   // OUT: policy of PCR\n\t\t );\n\n//*** PCRManufacture()\n// This function is used to initialize the policies when a TPM is manufactured.\n// This function would only be called in a manufacturing environment or in\n// a TPM simulator.\nvoid PCRManufacture(void);\n\n//*** PcrIsAllocated()\n// This function indicates if a PCR number for the particular hash algorithm\n// is allocated.\n//  Return Type: BOOL\n//      TRUE(1)         PCR is allocated\n//      FALSE(0)        PCR is not allocated\nBOOL PcrIsAllocated(UINT32        pcr,     // IN: The number of the PCR\n\t\t    TPMI_ALG_HASH hashAlg  // IN: The PCR algorithm\n\t\t    );\n\n//*** PcrDrtm()\n// This function does the DRTM and H-CRTM processing it is called from\n// _TPM_Hash_End.\nvoid PcrDrtm(const TPMI_DH_PCR pcrHandle,  // IN: the index of the PCR to be\n\t     //     modified\n\t     const TPMI_ALG_HASH hash,     // IN: the bank identifier\n\t     const TPM2B_DIGEST* digest    // IN: the digest to modify the PCR\n\t     );\n\n//*** PCR_ClearAuth()\n// This function is used to reset the PCR authorization values. It is called\n// on TPM2_Startup(CLEAR) and TPM2_Clear().\nvoid PCR_ClearAuth(void);\n\n//*** PCRStartup()\n// This function initializes the PCR subsystem at TPM2_Startup().\nBOOL PCRStartup(STARTUP_TYPE type,     // IN: startup type\n\t\tBYTE         locality  // IN: startup locality\n\t\t);\n\n//*** PCRStateSave()\n// This function is used to save the PCR values that will be restored on TPM Resume.\nvoid PCRStateSave(TPM_SU type  // IN: startup type\n\t\t  );\n\n//*** PCRIsStateSaved()\n// This function indicates if the selected PCR is a PCR that is state saved\n// on TPM2_Shutdown(STATE). The return value is based on PCR attributes.\n//  Return Type: BOOL\n//      TRUE(1)         PCR is state saved\n//      FALSE(0)        PCR is not state saved\nBOOL PCRIsStateSaved(TPMI_DH_PCR handle  // IN: PCR handle to be extended\n\t\t     );\n\n//*** PCRIsResetAllowed()\n// This function indicates if a PCR may be reset by the current command locality.\n// The return value is based on PCR attributes, and not the PCR allocation.\n//  Return Type: BOOL\n//      TRUE(1)         TPM2_PCR_Reset is allowed\n//      FALSE(0)        TPM2_PCR_Reset is not allowed\nBOOL PCRIsResetAllowed(TPMI_DH_PCR handle  // IN: PCR handle to be extended\n\t\t       );\n\n//*** PCRChanged()\n// This function checks a PCR handle to see if the attributes for the PCR are set\n// so that any change to the PCR causes an increment of the pcrCounter. If it does,\n// then the function increments the counter. Will also bump the counter if the\n// handle is zero which means that PCR 0 can not be in the TCB group. Bump on zero\n// is used by TPM2_Clear().\nvoid PCRChanged(TPM_HANDLE pcrHandle  // IN: the handle of the PCR that changed.\n\t\t);\n\n//*** PCRIsExtendAllowed()\n// This function indicates a PCR may be extended at the current command locality.\n// The return value is based on PCR attributes, and not the PCR allocation.\n//  Return Type: BOOL\n//      TRUE(1)         extend is allowed\n//      FALSE(0)        extend is not allowed\nBOOL PCRIsExtendAllowed(TPMI_DH_PCR handle  // IN: PCR handle to be extended\n\t\t\t);\n\n//*** PCRExtend()\n// This function is used to extend a PCR in a specific bank.\nvoid PCRExtend(TPMI_DH_PCR   handle,  // IN: PCR handle to be extended\n\t       TPMI_ALG_HASH hash,    // IN: hash algorithm of PCR\n\t       UINT32        size,    // IN: size of data to be extended\n\t       BYTE*         data     // IN: data to be extended\n\t       );\n\n//*** PCRComputeCurrentDigest()\n// This function computes the digest of the selected PCR.\n//\n// As a side-effect, 'selection' is modified so that only the implemented PCR\n// will have their bits still set.\nvoid PCRComputeCurrentDigest(\n\t\t\t     TPMI_ALG_HASH       hashAlg,    // IN: hash algorithm to compute digest\n\t\t\t     TPML_PCR_SELECTION* selection,  // IN/OUT: PCR selection (filtered on\n\t\t\t     //     output)\n\t\t\t     TPM2B_DIGEST* digest            // OUT: digest\n\t\t\t     );\n\n//*** PCRRead()\n// This function is used to read a list of selected PCR.  If the requested PCR\n// number exceeds the maximum number that can be output, the 'selection' is\n// adjusted to reflect the actual output PCR.\nvoid PCRRead(TPML_PCR_SELECTION* selection,  // IN/OUT: PCR selection (filtered on\n\t     //     output)\n\t     TPML_DIGEST* digest,            // OUT: digest\n\t     UINT32*      pcrCounter  // OUT: the current value of PCR generation\n\t     //     number\n\t     );\n\n//*** PCRAllocate()\n// This function is used to change the PCR allocation.\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        allocate failed\n//      TPM_RC_PCR              improper allocation\nTPM_RC\nPCRAllocate(TPML_PCR_SELECTION* allocate,      // IN: required allocation\n\t    UINT32*             maxPCR,        // OUT: Maximum number of PCR\n\t    UINT32*             sizeNeeded,    // OUT: required space\n\t    UINT32*             sizeAvailable  // OUT: available space\n\t    );\n\n//*** PCRSetValue()\n// This function is used to set the designated PCR in all banks to an initial value.\n// The initial value is signed and will be sign extended into the entire PCR.\n//\nvoid PCRSetValue(TPM_HANDLE handle,       // IN: the handle of the PCR to set\n\t\t INT8       initialValue  // IN: the value to set\n\t\t );\n\n//*** PCRResetDynamics\n// This function is used to reset a dynamic PCR to 0.  This function is used in\n// DRTM sequence.\nvoid PCRResetDynamics(void);\n\n//*** PCRCapGetAllocation()\n// This function is used to get the current allocation of PCR banks.\n//  Return Type: TPMI_YES_NO\n//      YES         if the return count is 0\n//      NO          if the return count is not 0\nTPMI_YES_NO\nPCRCapGetAllocation(UINT32              count,        // IN: count of return\n\t\t    TPML_PCR_SELECTION* pcrSelection  // OUT: PCR allocation list\n\t\t    );\n\n//*** PCRCapGetProperties()\n// This function returns a list of PCR properties starting at 'property'.\n//  Return Type: TPMI_YES_NO\n//      YES         if no more property is available\n//      NO          if there are more properties not reported\nTPMI_YES_NO\nPCRCapGetProperties(TPM_PT_PCR property,  // IN: the starting PCR property\n\t\t    UINT32     count,     // IN: count of returned properties\n\t\t    TPML_TAGGED_PCR_PROPERTY* select  // OUT: PCR select\n\t\t    );\n\n//*** PCRGetProperty()\n// This function returns the selected PCR property.\n//  Return Type: BOOL\n//      TRUE(1)         the property type is implemented\n//      FALSE(0)        the property type is not implemented\nBOOL PCRGetProperty(TPM_PT_PCR property, TPMS_TAGGED_PCR_SELECT* select);\n\n//*** PCRCapGetHandles()\n// This function is used to get a list of handles of PCR, started from 'handle'.\n// If 'handle' exceeds the maximum PCR handle range, an empty list will be\n// returned and the return value will be NO.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles available\n//      NO          all the available handles has been returned\nTPMI_YES_NO\nPCRCapGetHandles(TPMI_DH_PCR  handle,     // IN: start handle\n\t\t UINT32       count,      // IN: count of returned handles\n\t\t TPML_HANDLE* handleList  // OUT: list of handle\n\t\t );\n\n//*** PCRCapGetOneHandle()\n// This function is used to check whether a PCR handle exists.\nBOOL PCRCapGetOneHandle(TPMI_DH_PCR handle  // IN: handle\n\t\t\t);\n\n#endif  // _PCR_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PP_Commands_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PP_Commands_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef PP_COMMANDS_FP_H\n#define PP_COMMANDS_FP_H\n\ntypedef struct {\n    TPMI_RH_PLATFORM\tauth;\n    TPML_CC\t\tsetList;\n    TPML_CC\t\tclearList;\n} PP_Commands_In;\n\n#define RC_PP_Commands_auth\t\t(TPM_RC_H + TPM_RC_1)\n#define RC_PP_Commands_setList\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_PP_Commands_clearList\t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_PP_Commands(\n\t\t PP_Commands_In  *in             // IN: input parameter list\n\t\t );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PP_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef PP_FP_H\n#define PP_FP_H\n\nvoid\nPhysicalPresencePreInstall_Init(\n\t\t\t\tvoid\n\t\t\t\t);\nvoid\nPhysicalPresenceCommandSet(\n\t\t\t   TPM_CC           commandCode    // IN: command code\n\t\t\t   );\nvoid\nPhysicalPresenceCommandClear(\n\t\t\t     TPM_CC           commandCode    // IN: command code\n\t\t\t     );\nBOOL\nPhysicalPresenceIsRequired(\n\t\t\t   COMMAND_INDEX    commandIndex   // IN: command index\n\t\t\t   );\nTPMI_YES_NO\nPhysicalPresenceCapGetCCList(\n\t\t\t     TPM_CC           commandCode,   // IN: start command code\n\t\t\t     UINT32           count,         // IN: count of returned TPM_CC\n\t\t\t     TPML_CC         *commandList    // OUT: list of TPM_CC\n\t\t\t     );\nBOOL PhysicalPresenceCapGetOneCC(TPM_CC commandCode  // IN: command code\n\t\t\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PRNG_TestVectors.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PRNG Test Vectors \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PRNG_TestVectors.h 1529 2019-11-21 23:29:01Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 10.1.17\tPRNG_TestVectors.h */\n\n#ifndef     _MSBN_DRBG_TEST_VECTORS_H\n#define     _MSBN_DRBG_TEST_VECTORS_H\n//#if DRBG_ALGORITHM == TPM_ALG_AES && DRBG_KEY_BITS == 256\n#if DRBG_KEY_SIZE_BITS == 256\n\n/* Entropy is the size of the state. The state is the size of the key plus the IV. The IV is a\n   block. If Key = 256 and Block = 128 then State = 384 */\n\n#define DRBG_TEST_INITIATE_ENTROPY\t\t\t\t\\\n        0x0d, 0x15, 0xaa, 0x80, 0xb1, 0x6c, 0x3a, 0x10,\t\t\\\n\t0x90, 0x6c, 0xfe, 0xdb, 0x79, 0x5d, 0xae, 0x0b,\t\t\\\n\t0x5b, 0x81, 0x04, 0x1c, 0x5c, 0x5b, 0xfa, 0xcb,\t\t\\\n\t0x37, 0x3d, 0x44, 0x40, 0xd9, 0x12, 0x0f, 0x7e,\t\t\\\n\t0x3d, 0x6c, 0xf9, 0x09, 0x86, 0xcf, 0x52, 0xd8,\t\t\\\n\t0x5d, 0x3e, 0x94, 0x7d, 0x8c, 0x06, 0x1f, 0x91\n#define DRBG_TEST_RESEED_ENTROPY\t\t\t\t\\\n        0x6e, 0xe7, 0x93, 0xa3, 0x39, 0x55, 0xd7, 0x2a,\t\t\\\n\t0xd1, 0x2f, 0xd8, 0x0a, 0x8a, 0x3f, 0xcf, 0x95,\t\t\\\n\t0xed, 0x3b, 0x4d, 0xac, 0x57, 0x95, 0xfe, 0x25,\t\t\\\n\t0xcf, 0x86, 0x9f, 0x7c, 0x27, 0x57, 0x3b, 0xbc,\t\t\\\n\t0x56, 0xf1, 0xac, 0xae, 0x13, 0xa6, 0x50, 0x42,\t\t\\\n\t0xb3, 0x40, 0x09, 0x3c, 0x46, 0x4a, 0x7a, 0x22\n#define DRBG_TEST_GENERATED_INTERM\t\t\t\t\\\n        0x28, 0xe0, 0xeb, 0xb8, 0x21, 0x01, 0x66, 0x50,\t\t\\\n\t0x8c, 0x8f, 0x65, 0xf2, 0x20, 0x7b, 0xd0, 0xa3\n#define DRBG_TEST_GENERATED\t\t\t\t\t\\\n        0x94, 0x6f, 0x51, 0x82, 0xd5, 0x45, 0x10, 0xb9,\t\t\\\n\t0x46, 0x12, 0x48, 0xf5, 0x71, 0xca, 0x06, 0xc9\n#elif DRBG_KEY_SIZE_BITS == 128\n#define DRBG_TEST_INITIATE_ENTROPY\t\t\t\t\\\n        0x8f, 0xc1, 0x1b, 0xdb, 0x5a, 0xab, 0xb7, 0xe0,\t\t\\\n\t0x93, 0xb6, 0x14, 0x28, 0xe0, 0x90, 0x73, 0x03,\t\t\\\n\t0xcb, 0x45, 0x9f, 0x3b, 0x60, 0x0d, 0xad, 0x87,\t\t\\\n\t0x09, 0x55, 0xf2, 0x2d, 0xa8, 0x0a, 0x44, 0xf8\n#define DRBG_TEST_RESEED_ENTROPY\t\t\t\t\\\n        0x0c, 0xd5, 0x3c, 0xd5, 0xec, 0xcd, 0x5a, 0x10,\t\t\\\n\t0xd7, 0xea, 0x26, 0x61, 0x11, 0x25, 0x9b, 0x05,\t\t\\\n\t0x57, 0x4f, 0xc6, 0xdd, 0xd8, 0xbe, 0xd8, 0xbd,\t\t\\\n\t0x72, 0x37, 0x8c, 0xf8, 0x2f, 0x1d, 0xba, 0x2a\n#define DRBG_TEST_GENERATED_INTERM\t\t\t\t\\\n        0xdc, 0x3c, 0xf6, 0xbf, 0x5b, 0xd3, 0x41, 0x13,\t\t\\\n\t0x5f, 0x2c, 0x68, 0x11, 0xa1, 0x07, 0x1c, 0x87\n#define DRBG_TEST_GENERATED\t\t\t\t\t\\\n        0xb6, 0x18, 0x50, 0xde, 0xcf, 0xd7, 0x10, 0x6d,\t\t\\\n\t0x44, 0x76, 0x9a, 0x8e, 0x6e, 0x8c, 0x1a, 0xd4\n#endif\n#endif      //     _MSBN_DRBG_TEST_VECTORS_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Platform.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.14\tPlatform.h */\n\n#ifndef    _PLATFORM_H_\n#define    _PLATFORM_H_\n#include \"TpmBuildSwitches.h\"\n#include \"TpmProfile.h\"\n#include \"BaseTypes.h\"\n#include \"TPMB.h\"\n#include \"MinMax.h\"\n#include \"PlatformACT.h\"\n#include \"PlatformClock.h\"\n#include \"PlatformData.h\"\n#include \"platform_public_interface.h\"\n#include \"tpm_to_platform_interface.h\"\n#include \"platform_to_tpm_interface.h\"\n#define GLOBAL_C\n#define NV_C\n#include \"pcrstruct.h\"\n#include \"platform_pcr_fp.h\"\n\n#endif  // _PLATFORM_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PlatformACT.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tPlatform Authenticated Countdown Timer\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PlatformACT.h 1531 2019-11-21 23:54:38Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019.\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.15\tPlatformACT.h */\n\n// This file contains the definitions for the ACT macros and data types used in the ACT\n// implementation.\n\n#ifndef PLATFORMACT_H\n#define PLATFORMACT_H\n\ntypedef struct ACT_DATA\n{\n    uint32_t            remaining;\n    uint32_t            newValue;\n    uint8_t             signaled;\n    uint8_t             pending;\n    uint8_t             number;\n} ACT_DATA, *P_ACT_DATA;\n\n#if !(defined RH_ACT_0) || (RH_ACT_0 != YES)\n#   undef   RH_ACT_0\n#   define  RH_ACT_0 NO \n#   define IF_ACT_0_IMPLEMENTED(op)\n#else\n#   define IF_ACT_0_IMPLEMENTED(op) op(0)\n#endif \n#if !(defined RH_ACT_1) || (RH_ACT_1 != YES)\n#   undef   RH_ACT_1\n#   define  RH_ACT_1 NO \n#   define IF_ACT_1_IMPLEMENTED(op)\n#else\n#   define IF_ACT_1_IMPLEMENTED(op) op(1)\n#endif \n#if !(defined RH_ACT_2) || (RH_ACT_2 != YES)\n#   undef   RH_ACT_2\n#   define  RH_ACT_2 NO \n#   define IF_ACT_2_IMPLEMENTED(op)\n#else\n#   define IF_ACT_2_IMPLEMENTED(op) op(2)\n#endif \n#if !(defined RH_ACT_3) || (RH_ACT_3 != YES)\n#   undef   RH_ACT_3\n#   define  RH_ACT_3 NO \n#   define IF_ACT_3_IMPLEMENTED(op)\n#else\n#   define IF_ACT_3_IMPLEMENTED(op) op(3)\n#endif \n#if !(defined RH_ACT_4) || (RH_ACT_4 != YES)\n#   undef   RH_ACT_4\n#   define  RH_ACT_4 NO \n#   define IF_ACT_4_IMPLEMENTED(op)\n#else\n#   define IF_ACT_4_IMPLEMENTED(op) op(4)\n#endif \n#if !(defined RH_ACT_5) || (RH_ACT_5 != YES)\n#   undef   RH_ACT_5\n#   define  RH_ACT_5 NO \n#   define IF_ACT_5_IMPLEMENTED(op)\n#else\n#   define IF_ACT_5_IMPLEMENTED(op) op(5)\n#endif \n#if !(defined RH_ACT_6) || (RH_ACT_6 != YES)\n#   undef   RH_ACT_6\n#   define  RH_ACT_6 NO \n#   define IF_ACT_6_IMPLEMENTED(op)\n#else\n#   define IF_ACT_6_IMPLEMENTED(op) op(6)\n#endif \n#if !(defined RH_ACT_7) || (RH_ACT_7 != YES)\n#   undef   RH_ACT_7\n#   define  RH_ACT_7 NO \n#   define IF_ACT_7_IMPLEMENTED(op)\n#else\n#   define IF_ACT_7_IMPLEMENTED(op) op(7)\n#endif \n#if !(defined RH_ACT_8) || (RH_ACT_8 != YES)\n#   undef   RH_ACT_8\n#   define  RH_ACT_8 NO \n#   define IF_ACT_8_IMPLEMENTED(op)\n#else\n#   define IF_ACT_8_IMPLEMENTED(op) op(8)\n#endif \n#if !(defined RH_ACT_9) || (RH_ACT_9 != YES)\n#   undef   RH_ACT_9\n#   define  RH_ACT_9 NO \n#   define IF_ACT_9_IMPLEMENTED(op)\n#else\n#   define IF_ACT_9_IMPLEMENTED(op) op(9)\n#endif \n#if !(defined RH_ACT_A) || (RH_ACT_A != YES)\n#   undef   RH_ACT_A\n#   define  RH_ACT_A NO \n#   define IF_ACT_A_IMPLEMENTED(op)\n#else\n#   define IF_ACT_A_IMPLEMENTED(op) op(A)\n#endif \n#if !(defined RH_ACT_B) || (RH_ACT_B != YES)\n#   undef   RH_ACT_B\n#   define  RH_ACT_B NO \n#   define IF_ACT_B_IMPLEMENTED(op)\n#else\n#   define IF_ACT_B_IMPLEMENTED(op) op(B)\n#endif \n#if !(defined RH_ACT_C) || (RH_ACT_C != YES)\n#   undef   RH_ACT_C\n#   define  RH_ACT_C NO \n#   define IF_ACT_C_IMPLEMENTED(op)\n#else\n#   define IF_ACT_C_IMPLEMENTED(op) op(C)\n#endif \n#if !(defined RH_ACT_D) || (RH_ACT_D != YES)\n#   undef   RH_ACT_D\n#   define  RH_ACT_D NO \n#   define IF_ACT_D_IMPLEMENTED(op)\n#else\n#   define IF_ACT_D_IMPLEMENTED(op) op(D)\n#endif \n#if !(defined RH_ACT_E) || (RH_ACT_E != YES)\n#   undef   RH_ACT_E\n#   define  RH_ACT_E NO \n#   define IF_ACT_E_IMPLEMENTED(op)\n#else\n#   define IF_ACT_E_IMPLEMENTED(op) op(E)\n#endif \n#if !(defined RH_ACT_F) || (RH_ACT_F != YES)\n#   undef   RH_ACT_F\n#   define  RH_ACT_F NO \n#   define IF_ACT_F_IMPLEMENTED(op)\n#else\n#   define IF_ACT_F_IMPLEMENTED(op) op(F)\n#endif\n\n#define FOR_EACH_ACT(op)\t\t\t\\\n    IF_ACT_0_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_1_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_2_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_3_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_4_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_5_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_6_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_7_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_8_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_9_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_A_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_B_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_C_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_D_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_E_IMPLEMENTED(op)\t\t\t\\\n    IF_ACT_F_IMPLEMENTED(op)\n\n#endif // _PLATFORM_ACT_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PlatformACT_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tPlatform Authenticated Countdown Timer\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PlatformACT_fp.h 1531 2019-11-21 23:54:38Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef PLATFORMACT_FP_H\n#define PLATFORMACT_FP_H\n\nLIB_EXPORT int\n_plat__ACT_GetImplemented(\n\t\t\t  uint32_t            act\n\t\t\t  );\nLIB_EXPORT uint32_t\n_plat__ACT_GetRemaining(\n\t\t\tuint32_t            act             //IN: the ACT selector\n\t\t\t);\nLIB_EXPORT int\n_plat__ACT_GetSignaled(\n\t\t       uint32_t            act         //IN: number of ACT to check\n\t\t       );\nLIB_EXPORT void\n_plat__ACT_SetSignaled(\n\t\t       uint32_t            act,\n\t\t       int                 on\n\t\t       );\nLIB_EXPORT int\n_plat__ACT_GetPending(\n\t\t      uint32_t            act         //IN: number of ACT to check\n\t\t      );\nLIB_EXPORT int\n_plat__ACT_UpdateCounter(\n\t\t\t uint32_t            act,        // IN: ACT to update\n\t\t\t uint32_t            newValue   // IN: the value to post\n\t\t\t );\nLIB_EXPORT void\n_plat__ACT_EnableTicks(\n\t\t       int\tenable\n\t\t       );\nLIB_EXPORT void\n_plat__ACT_Tick(\n\t\tvoid\n\t\t);\nLIB_EXPORT int\n_plat__ACT_Initialize(\n\t\t      void\n\t\t      );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PlatformClock.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\tPlatform Clock\t\t\t.     \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PlatformClock.h 1594 2020-03-26 22:15:48Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// C.16 PlatformClock.h This file contains the instance data for the Platform module. It is\n// collected in this file so that the state of the module is easier to manage.\n#ifndef _PLATFORM_CLOCK_H_\n#define _PLATFORM_CLOCK_H_\n#ifdef _MSC_VER\n#include <sys/types.h>\n#include <sys/timeb.h>\n#else\n#include <sys/time.h>\n#include <time.h>\n#endif\n// CLOCK_NOMINAL is the number of hardware ticks per mS. A value of 300000 means that the nominal\n// clock rate used to drive the hardware clock is 30 MHz. The adjustment rates are used to determine\n// the conversion of the hardware ticks to internal hardware clock value. In practice, we would\n// expect that there would be a hardware register will accumulated mS. It would be incremented by\n// the output of a pre-scaler. The pre-scaler would divide the ticks from the clock by some value\n// that would compensate for the difference between clock time and real time. The code in Clock does\n// the emulation of this function.\n#define     CLOCK_NOMINAL           30000\n// A 1% change in rate is 300 counts\n#define     CLOCK_ADJUST_COARSE     300\n// A 0.1% change in rate is 30 counts\n#define     CLOCK_ADJUST_MEDIUM     30\n// A minimum change in rate is 1 count\n#define     CLOCK_ADJUST_FINE       1\n// The clock tolerance is +/-15% (4500 counts) Allow some guard band (16.7%)\n#define     CLOCK_ADJUST_LIMIT      5000\n#endif // _PLATFORM_CLOCK_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PlatformData.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tInstance data for the Platform module. \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PlatformData.h 1529 2019-11-21 23:29:01Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* c.8 PlatformData.h */\n/* This file contains the instance data for the Platform module. It is collected in this file so\n   that the state of the module is easier to manage. */\n\n#ifndef _PLATFORM_DATA_H_\n#define _PLATFORM_DATA_H_\n#ifdef  _PLATFORM_DATA_C_\n#define EXTERN\n#else\n#define EXTERN  extern\n#endif\n\n/* From Cancel.c Cancel flag.  It is initialized as FALSE, which indicate the command is not being\n   canceled */\nEXTERN int     s_isCanceled;\n\n#ifndef HARDWARE_CLOCK\ntypedef uint64_t     clock64_t;\n// This is the value returned the last time that the system clock was read. This is only relevant\n// for a simulator or virtual TPM.\nEXTERN clock64_t        s_realTimePrevious;\n// These values are used to try to synthesize a long lived version of clock().\nEXTERN clock64_t        s_lastSystemTime;\nEXTERN clock64_t        s_lastReportedTime;\n// This is the rate adjusted value that is the equivalent of what would be read from a hardware\n// register that produced rate adjusted time.\nEXTERN clock64_t        s_tpmTime;\n#endif // HARDWARE_CLOCK\n\n/* This value indicates that the timer was reset */\nEXTERN int              s_timerReset;\n/* This value indicates that the timer was stopped. It causes a clock discontinuity. */\nEXTERN int              s_timerStopped;\n/* This variable records the time when _plat__TimerReset() is called.  This mechanism allow us to\n   subtract the time when TPM is power off from the total time reported by clock() function */\nEXTERN uint64_t         s_initClock;\n/* This variable records the timer adjustment factor. */\nEXTERN unsigned int     s_adjustRate;\n/* From LocalityPlat.c Locality of current command */\nEXTERN unsigned char s_locality;\n/* From NVMem.c Choose if the NV memory should be backed by RAM or by file. If this macro is\n   defined, then a file is used as NV.  If it is not defined, then RAM is used to back NV\n   memory. Comment out to use RAM. */\n#if (!defined VTPM) || ((VTPM != NO) && (VTPM != YES))\n#   undef VTPM\n#   define      VTPM            YES                 // Default: Either YES or NO\n#endif\n\n// For a simulation, use a file to back up the NV\n\n#if (!defined FILE_BACKED_NV) || ((FILE_BACKED_NV != NO) && (FILE_BACKED_NV != YES))\n#   undef   FILE_BACKED_NV\n#   define  FILE_BACKED_NV          (VTPM && YES)     // Default: Either YES or NO\n#endif\n#if SIMULATION\n#   undef       FILE_BACKED_NV\n#   define      FILE_BACKED_NV          YES\n#endif // SIMULATION\n\n#undef       FILE_BACKED_NV\n\n#if defined(PLATFORM_TYPE) && (PLATFORM_TYPE == 1)\n#define  FILE_BACKED_NV  NO\n#elif defined(PLATFORM_TYPE) && (PLATFORM_TYPE == 2)\n#define  FILE_BACKED_NV  YES\n#endif\n\n\nEXTERN unsigned char    s_NV[NV_MEMORY_SIZE];\nEXTERN unsigned char    s_NV_ENC[NV_MEMORY_SIZE];\nEXTERN int              s_NvIsAvailable;\nEXTERN int              s_NV_unrecoverable;\nEXTERN int              s_NV_recoverable;\n\n/* From PPPlat.c Physical presence. */\n/* It is initialized to FALSE */\n\nEXTERN int        s_physicalPresence;\n\n/* From Power */\nEXTERN int        s_powerLost;\n\n/* From Entropy.c */\nEXTERN uint32_t        lastEntropy;\n\n#define DEFINE_ACT(N)   EXTERN ACT_DATA ACT_##N;\nFOR_EACH_ACT(DEFINE_ACT)\nEXTERN int             actTicksAllowed;\n\n#endif // _PLATFORM_DATA_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Platform_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tNV read and write access methods     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyAuthValue_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyAuthValue_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYAUTHVALUE_FP_H\n#define POLICYAUTHVALUE_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n} PolicyAuthValue_In;\n\n#define RC_PolicyAuthValue_policySession\t(TPM_RC_H + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyAuthValue(\n\t\t     PolicyAuthValue_In  *in             // IN: input parameter list\n\t\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyAuthorizeNV_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyAuthorizeNV_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015, 2016\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 136 */\n\n#ifndef POLICYAUTHORIZENV_FP_H\n#define POLICYAUTHORIZENV_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n    TPMI_SH_POLICY\tpolicySession;\n} PolicyAuthorizeNV_In;\n\n#define RC_PolicyAuthorizeNV_authHandle\t\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyAuthorizeNV_nvIndex\t\t(TPM_RC_H + TPM_RC_2)\n#define RC_PolicyAuthorizeNV_policySession\t(TPM_RC_H + TPM_RC_3)\n\nTPM_RC\nTPM2_PolicyAuthorizeNV(\n\t\t       PolicyAuthorizeNV_In     *in             // IN: input parameter list\n\t\t       );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyAuthorize_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyAuthorize_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYAUTHORIZE_FP_H\n#define POLICYAUTHORIZE_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_DIGEST\tapprovedPolicy;\n    TPM2B_NONCE\t\tpolicyRef;\n    TPM2B_NAME\t\tkeySign;\n    TPMT_TK_VERIFIED\tcheckTicket;\n} PolicyAuthorize_In;\n\n#define RC_PolicyAuthorize_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyAuthorize_approvedPolicy \t(TPM_RC_P + TPM_RC_1)\n#define RC_PolicyAuthorize_policyRef\t\t(TPM_RC_P + TPM_RC_2)\n#define RC_PolicyAuthorize_keySign \t\t(TPM_RC_P + TPM_RC_3)\n#define RC_PolicyAuthorize_checkTicket \t\t(TPM_RC_P + TPM_RC_4)\n\nTPM_RC\nTPM2_PolicyAuthorize(\n\t\t     PolicyAuthorize_In  *in             // IN: input parameter list\n\t\t     );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyCapability_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t        */\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#if CC_PolicyCapability  // Command must be enabled\n\n#ifndef POLICYCAPABILITY_FP_H\n#define POLICYCAPABILITY_FP_H\n\ntypedef struct\n{\n    TPMI_SH_POLICY policySession;\n    TPM2B_OPERAND  operandB;\n    UINT16         offset;\n    TPM_EO         operation;\n    TPM_CAP        capability;\n    UINT32         property;\n} PolicyCapability_In;\n\n#define RC_PolicyCapability_policySession (TPM_RC_H + TPM_RC_1)\n#define RC_PolicyCapability_operandB      (TPM_RC_P + TPM_RC_1)\n#define RC_PolicyCapability_offset        (TPM_RC_P + TPM_RC_2)\n#define RC_PolicyCapability_operation     (TPM_RC_P + TPM_RC_3)\n#define RC_PolicyCapability_capability    (TPM_RC_P + TPM_RC_4)\n#define RC_PolicyCapability_property      (TPM_RC_P + TPM_RC_5)\n\nTPM_RC\nTPM2_PolicyCapability(PolicyCapability_In* in);\n\n#endif  // POLICYCAPABILITY_FP_H\n#endif  // CC_PolicyCapability\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyCommandCode_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyCommandCode_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYCOMMANDCODE_FP_H\n#define POLICYCOMMANDCODE_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPM_CC\t\tcode;\n} PolicyCommandCode_In;\n\n#define RC_PolicyCommandCode_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyCommandCode_code \t\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyCommandCode(\n\t\t       PolicyCommandCode_In    *in             // IN: input parameter list\n\t\t       );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyCounterTimer_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyCounterTimer_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYCOUNTERTIMER_FP_H\n#define POLICYCOUNTERTIMER_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_OPERAND\toperandB;\n    UINT16\t\toffset;\n    TPM_EO\t\toperation;\n} PolicyCounterTimer_In;\n\n#define RC_PolicyCounterTimer_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyCounterTimer_operandB\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_PolicyCounterTimer_offset\t\t(TPM_RC_P + TPM_RC_2)\n#define RC_PolicyCounterTimer_operation\t\t(TPM_RC_P + TPM_RC_3)\n\nTPM_RC\nTPM2_PolicyCounterTimer(\n\t\t\tPolicyCounterTimer_In   *in             // IN: input parameter list\n\t\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyCpHash_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyCpHash_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYCPHASH_FP_H\n#define POLICYCPHASH_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_DIGEST\tcpHashA;\n} PolicyCpHash_In;\n\n#define RC_PolicyCpHash_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyCpHash_cpHashA \t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyCpHash(\n\t\t  PolicyCpHash_In     *in             // IN: input parameter list\n\t\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyDuplicationSelect_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t$Id: PolicyDuplicationSelect_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYDUPLICATIONSELECT_FP_H\n#define POLICYDUPLICATIONSELECT_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_NAME\t\tobjectName;\n    TPM2B_NAME\t\tnewParentName;\n    TPMI_YES_NO\t\tincludeObject;\n} PolicyDuplicationSelect_In;\n\n#define RC_PolicyDuplicationSelect_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyDuplicationSelect_objectName\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_PolicyDuplicationSelect_newParentName\t(TPM_RC_P + TPM_RC_2)\n#define RC_PolicyDuplicationSelect_includeObject\t(TPM_RC_P + TPM_RC_3)\n\nTPM_RC\nTPM2_PolicyDuplicationSelect(\n\t\t\t     PolicyDuplicationSelect_In  *in             // IN: input parameter list\n\t\t\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyGetDigest_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyGetDigest_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYGETDIGEST_FP_H\n#define POLICYGETDIGEST_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n} PolicyGetDigest_In;\n\n#define RC_PolicyGetDigest_policySession\t(TPM_RC_P + TPM_RC_1)\n\ntypedef struct {\n    TPM2B_DIGEST\tpolicyDigest;\n} PolicyGetDigest_Out;\n\nTPM_RC\nTPM2_PolicyGetDigest(\n\t\t     PolicyGetDigest_In      *in,            // IN: input parameter list\n\t\t     PolicyGetDigest_Out     *out            // OUT: output parameter list\n\t\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyLocality_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyLocality_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYLOCALITY_FP_H\n#define POLICYLOCALITY_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPMA_LOCALITY\tlocality;\n} PolicyLocality_In;\n\n#define RC_PolicyLocality_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyLocality_locality \t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyLocality(\n\t\t    PolicyLocality_In   *in             // IN: input parameter list\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyNV_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyNV_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYNV_FP_H\n#define POLICYNV_FP_H\n\ntypedef struct {\n    TPMI_RH_NV_AUTH\tauthHandle;\n    TPMI_RH_NV_INDEX\tnvIndex;\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_OPERAND\toperandB;\n    UINT16\t\toffset;\n    TPM_EO\t\toperation;\n} PolicyNV_In;\n\n#define RC_PolicyNV_authHandle\t\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyNV_nvIndex\t\t(TPM_RC_H + TPM_RC_2)\n#define RC_PolicyNV_policySession\t(TPM_RC_H + TPM_RC_3)\n#define RC_PolicyNV_operandB \t\t(TPM_RC_P + TPM_RC_1)\n#define RC_PolicyNV_offset \t\t(TPM_RC_P + TPM_RC_2)\n#define RC_PolicyNV_operation\t\t(TPM_RC_P + TPM_RC_3)\n\nTPM_RC\nTPM2_PolicyNV(\n\t      PolicyNV_In     *in             // IN: input parameter list\n\t      );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyNameHash_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyNameHash_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYNAMEHASH_FP_H\n#define POLICYNAMEHASH_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_DIGEST\tnameHash;\n} PolicyNameHash_In;\n\n#define RC_PolicyNameHash_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyNameHash_nameHash \t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyNameHash(\n\t\t    PolicyNameHash_In   *in             // IN: input parameter list\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyNvWritten_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyNvWritten_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYNVWRITTEN_FP_H\n#define POLICYNVWRITTEN_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPMI_YES_NO\t\twrittenSet;\n} PolicyNvWritten_In;\n\n#define RC_PolicyNvWritten_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyNvWritten_writtenSet \t\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyNvWritten(\n\t\t     PolicyNvWritten_In  *in             // IN: input parameter list\n\t\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyOR_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyOR_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYOR_FP_H\n#define POLICYOR_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPML_DIGEST\t\tpHashList;\n} PolicyOR_In;\n\n#define RC_PolicyOR_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyOR_pHashList \t\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyOR(\n\t      PolicyOR_In     *in             // IN: input parameter list\n\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyPCR_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyPCR_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYPCR_FP_H\n#define POLICYPCR_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_DIGEST\tpcrDigest;\n    TPML_PCR_SELECTION\tpcrs;\n} PolicyPCR_In;\n\n#define RC_PolicyPCR_policySession \t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyPCR_pcrDigest\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_PolicyPCR_pcrs\t\t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_PolicyPCR(\n\t       PolicyPCR_In    *in             // IN: input parameter list\n\t       );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyParameters_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t        */\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#if CC_PolicyParameters  // Command must be enabled\n\n#ifndef POLICYPARAMETERS_FP_H_\n#define POLICYPARAMETERS_FP_H_\n\ntypedef struct\n{\n    TPMI_SH_POLICY policySession;\n    TPM2B_DIGEST   pHash;\n} PolicyParameters_In;\n\n#define RC_PolicyParameters_policySession (TPM_RC_H + TPM_RC_1)\n#define RC_PolicyParameters_pHash         (TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyParameters(PolicyParameters_In* in);\n\n#endif\n#endif    // CC_PolicyParameters\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyPassword_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyPassword_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYPASSWORD_FP_H\n#define POLICYPASSWORD_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n} PolicyPassword_In;\n\n#define RC_PolicyPassword_policySession\t(TPM_RC_H + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyPassword(\n\t\t    PolicyPassword_In   *in             // IN: input parameter list\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyPhysicalPresence_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t$Id: PolicyPhysicalPresence_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYPHYSICALPRESENCE_FP_H\n#define POLICYPHYSICALPRESENCE_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n} PolicyPhysicalPresence_In;\n\n#define RC_PolicyPhysicalPresence_policySession\t(TPM_RC_H + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyPhysicalPresence(\n\t\t\t    PolicyPhysicalPresence_In   *in             // IN: input parameter list\n\t\t\t    );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyRestart_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyRestart_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYRESTART_FP_H\n#define POLICYRESTART_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tsessionHandle;\n} PolicyRestart_In;\n\n#define RC_PolicyRestart_sessionHandle\t(TPM_RC_H + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyRestart(\n\t\t   PolicyRestart_In    *in             // IN: input parameter list\n\t\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicySecret_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicySecret_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 124 */\n\n#ifndef POLICYSECRET_FP_H\n#define POLICYSECRET_FP_H\n\ntypedef struct {\n    TPMI_DH_ENTITY\tauthHandle;\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_NONCE\t\tnonceTPM;\n    TPM2B_DIGEST\tcpHashA;\n    TPM2B_NONCE\t\tpolicyRef;\n    INT32\t\texpiration;\n} PolicySecret_In;\n\n#define RC_PolicySecret_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicySecret_policySession\t(TPM_RC_H + TPM_RC_2)\n#define RC_PolicySecret_nonceTPM\t(TPM_RC_P + TPM_RC_1)\n#define RC_PolicySecret_cpHashA\t\t(TPM_RC_P + TPM_RC_2)\n#define RC_PolicySecret_policyRef\t(TPM_RC_P + TPM_RC_3)\n#define RC_PolicySecret_expiration\t(TPM_RC_P + TPM_RC_4)\n\ntypedef struct {\n    TPM2B_TIMEOUT\ttimeout;\n    TPMT_TK_AUTH\tpolicyTicket;\n} PolicySecret_Out;\n\nTPM_RC\nTPM2_PolicySecret(\n\t\t  PolicySecret_In     *in,            // IN: input parameter list\n\t\t  PolicySecret_Out    *out            // OUT: output parameter list\n\t\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicySigned_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicySigned_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYSIGNED_FP_H\n#define POLICYSIGNED_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tauthObject;\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_NONCE\t\tnonceTPM;\n    TPM2B_DIGEST\tcpHashA;\n    TPM2B_NONCE\t\tpolicyRef;\n    INT32\t\texpiration;\n    TPMT_SIGNATURE\tauth;\n} PolicySigned_In;\n\n#define RC_PolicySigned_authObject\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicySigned_policySession\t(TPM_RC_H + TPM_RC_2)\n#define RC_PolicySigned_nonceTPM\t(TPM_RC_P + TPM_RC_1)\n#define RC_PolicySigned_cpHashA\t\t(TPM_RC_P + TPM_RC_2)\n#define RC_PolicySigned_policyRef\t(TPM_RC_P + TPM_RC_3)\n#define RC_PolicySigned_expiration\t(TPM_RC_P + TPM_RC_4)\n#define RC_PolicySigned_auth \t\t(TPM_RC_P + TPM_RC_5)\n\ntypedef struct {\n    TPM2B_TIMEOUT\ttimeout;\n    TPMT_TK_AUTH\tpolicyTicket;\n} PolicySigned_Out;\n\nTPM_RC\nTPM2_PolicySigned(\n\t\t  PolicySigned_In     *in,            // IN: input parameter list\n\t\t  PolicySigned_Out    *out            // OUT: output parameter list\n\t\t  );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyTemplate_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyTemplate_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015, 2016\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYTEMPLATE_FP_H\n#define POLICYTEMPLATE_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_DIGEST\ttemplateHash;\n} PolicyTemplate_In;\n\n#define RC_PolicyTemplate_policySession\t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyTemplate_templateHash \t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_PolicyTemplate(\n\t\t    PolicyTemplate_In     *in             // IN: input parameter list\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PolicyTicket_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PolicyTicket_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef POLICYTICKET_FP_H\n#define POLICYTICKET_FP_H\n\ntypedef struct {\n    TPMI_SH_POLICY\tpolicySession;\n    TPM2B_TIMEOUT\ttimeout;\n    TPM2B_DIGEST\tcpHashA;\n    TPM2B_NONCE\t\tpolicyRef;\n    TPM2B_NAME\t\tauthName;\n    TPMT_TK_AUTH\tticket;\n} PolicyTicket_In;\n\n#define RC_PolicyTicket_policySession \t(TPM_RC_H + TPM_RC_1)\n#define RC_PolicyTicket_timeout \t(TPM_RC_P + TPM_RC_1)\n#define RC_PolicyTicket_cpHashA \t(TPM_RC_P + TPM_RC_2)\n#define RC_PolicyTicket_policyRef\t(TPM_RC_P + TPM_RC_3)\n#define RC_PolicyTicket_authName\t(TPM_RC_P + TPM_RC_4)\n#define RC_PolicyTicket_ticket \t\t(TPM_RC_P + TPM_RC_5)\n\nTPM_RC\nTPM2_PolicyTicket(\n\t\t  PolicyTicket_In     *in             // IN: input parameter list\n\t\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Policy_spt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Policy_spt_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef POLICY_SPT_FP_H\n#define POLICY_SPT_FP_H\n\nTPM_RC\nPolicyParameterChecks(\n\t\t      SESSION         *session,\n\t\t      UINT64           authTimeout,\n\t\t      TPM2B_DIGEST    *cpHashA,\n\t\t      TPM2B_NONCE     *nonce,\n\t\t      TPM_RC           blameNonce,\n\t\t      TPM_RC           blameCpHash,\n\t\t      TPM_RC           blameExpiration\n\t\t      );\nvoid\nPolicyContextUpdate(\n\t\t    TPM_CC           commandCode,   // IN: command code\n\t\t    TPM2B_NAME      *name,          // IN: name of entity\n\t\t    TPM2B_NONCE     *ref,           // IN: the reference data\n\t\t    TPM2B_DIGEST    *cpHash,        // IN: the cpHash (optional)\n\t\t    UINT64           policyTimeout, // IN: the timeout value for the policy\n\t\t    SESSION         *session        // IN/OUT: policy session to be updated\n\t\t    );\nUINT64\nComputeAuthTimeout(\n\t\t   SESSION         *session,               // IN: the session containing the time\n\t\t   //     values\n\t\t   INT32            expiration,            // IN: either the number of seconds from\n\t\t   //     the start of the session or the\n\t\t   //     time in g_timer;\n\t\t   TPM2B_NONCE     *nonce                  // IN: indicator of the time base\n\t\t   );\nvoid\nPolicyDigestClear(\n\t\t  SESSION         *session\n\t\t  );\nBOOL\nPolicySptCheckCondition(\n\t\t\tTPM_EO          operation,\n\t\t\tBYTE            *opA,\n\t\t\tBYTE            *opB,\n\t\t\tUINT16           size\n\t\t\t);\n\n\n\n\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Power_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tFunctions That Receive the Simulated Power State Transitions of the TPM\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Power_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef POWER_FP_H\n#define POWER_FP_H\n\nvoid\nTPMInit(\n\tvoid\n\t);\nBOOL\nTPMRegisterStartup(\n\t\t   void\n\t\t   );\nBOOL\nTPMIsStarted(\n\t     void\n\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/PropertyCap_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef PROPERTYCAP_FP_H\n#define PROPERTYCAP_FP_H\n\nTPMI_YES_NO\nTPMCapGetProperties(\n\t\t    TPM_PT                       property,      // IN: the starting TPM property\n\t\t    UINT32                       count,         // IN: maximum number of returned\n\t\t    //     properties\n\t\t    TPML_TAGGED_TPM_PROPERTY    *propertyList   // OUT: property list\n\t\t    );\nBOOL TPMCapGetOneProperty(TPM_PT                pt,       // IN: the TPM property\n\t\t\t  TPMS_TAGGED_PROPERTY* property  // OUT: tagged property\n\t\t\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Quote_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Quote_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef QUOTE_FP_H\n#define QUOTE_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tsignHandle;\n    TPM2B_DATA\t\tqualifyingData;\n    TPMT_SIG_SCHEME\tinScheme;\n    TPML_PCR_SELECTION\tPCRselect;\n} Quote_In;\n\n#define RC_Quote_signHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_Quote_qualifyingData\t(TPM_RC_P + TPM_RC_1)\n#define RC_Quote_inScheme\t(TPM_RC_P + TPM_RC_2)\n#define RC_Quote_PCRselect\t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPM2B_ATTEST\tquoted;\n    TPMT_SIGNATURE\tsignature;\n} Quote_Out;\n\nTPM_RC\nTPM2_Quote(\n\t   Quote_In        *in,            // IN: input parameter list\n\t   Quote_Out       *out            // OUT: output parameter list\n\t   );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/RSA_Decrypt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: RSA_Decrypt_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef RSA_DECRYPT_FP_H\n#define RSA_DECRYPT_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tkeyHandle;\n    TPM2B_PUBLIC_KEY_RSA\tcipherText; \n    TPMT_RSA_DECRYPT\t\tinScheme;\n    TPM2B_DATA\t\t\tlabel;\n} RSA_Decrypt_In;\n\n#define RC_RSA_Decrypt_keyHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_RSA_Decrypt_cipherText\t(TPM_RC_P + TPM_RC_1)\n#define RC_RSA_Decrypt_inScheme \t(TPM_RC_P + TPM_RC_2)\n#define RC_RSA_Decrypt_label \t\t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPM2B_PUBLIC_KEY_RSA\tmessage;\n} RSA_Decrypt_Out;\n\nTPM_RC\nTPM2_RSA_Decrypt(\n\t\t RSA_Decrypt_In      *in,            // IN: input parameter list\n\t\t RSA_Decrypt_Out     *out            // OUT: output parameter list\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/RSA_Encrypt_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: RSA_Encrypt_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef RSA_ENCRYPT_FP_H\n#define RSA_ENCRYPT_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tkeyHandle;\n    TPM2B_PUBLIC_KEY_RSA\tmessage;\n    TPMT_RSA_DECRYPT\t\tinScheme;\n    TPM2B_DATA\t\t\tlabel;\n} RSA_Encrypt_In;\n\n#define RC_RSA_Encrypt_keyHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_RSA_Encrypt_message\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_RSA_Encrypt_inScheme \t(TPM_RC_P + TPM_RC_2)\n#define RC_RSA_Encrypt_label \t\t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPM2B_PUBLIC_KEY_RSA\toutData;\n} RSA_Encrypt_Out;\n\nTPM_RC\nTPM2_RSA_Encrypt(\n\t\t RSA_Encrypt_In      *in,            // IN: input parameter list\n\t\t RSA_Encrypt_Out     *out            // OUT: output parameter list\n\t\t );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/RTPM.h",
    "content": "#ifndef RTPM_H\n#define RTPM_H\n#include <stdint.h>\n\nstruct rtpm_cmd {\n  uint32_t length;\n  uint8_t buffer[];\n};\n\n\nint rtpm_cmd_handler(struct rtpm_cmd *cmd);\n\nint fake_main(uint64_t dummy, uint64_t dramAddr, uint64_t dramSize, uint64_t freeAddr, uint64_t utmAddr, uint64_t utmSize);\n\n#endif"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ReadClock_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ReadClock_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef READCLOCK_FP_H\n#define READCLOCK_FP_H\n\ntypedef struct {\n    TPMS_TIME_INFO\tcurrentTime;\n} ReadClock_Out;\n\nTPM_RC\nTPM2_ReadClock(\n\t       ReadClock_Out   *out            // OUT: output parameter list\n\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ReadPublic_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ReadPublic_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef READPUBLIC_FP_H\n#define READPUBLIC_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tobjectHandle;\n} ReadPublic_In;\n\n#define RC_ReadPublic_objectHandle\t(TPM_RC_H + TPM_RC_1)\n\ntypedef struct {\n    TPM2B_PUBLIC\toutPublic;\n    TPM2B_NAME\t\tname;\n    TPM2B_NAME\t\tqualifiedName;\n} ReadPublic_Out;\n\nTPM_RC\nTPM2_ReadPublic(\n\t\tReadPublic_In   *in,            // IN: input parameter list\n\t\tReadPublic_Out  *out            // OUT: output parameter list\n\t\t);\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ResponseCodeProcessing_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ResponseCodeProcessing_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef RESPONSECODEPROCESSING_FP_H\n#define RESPONSECODEPROCESSING_FP_H\n\nTPM_RC\nRcSafeAddToResult(\n\t\t  TPM_RC          responseCode,\n\t\t  TPM_RC          modifier\n\t\t  );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Response_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Response_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef RESPONSE_FP_H\n#define RESPONSE_FP_H\n\nvoid\nBuildResponseHeader(\n\t\t    COMMAND         *command,       // IN: main control structure\n\t\t    BYTE            *buffer,        // OUT: the output buffer\n\t\t    TPM_RC           result         // IN: the response code\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Rewrap_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Rewrap_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef REWRAP_FP_H\n#define REWRAP_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\toldParent;\n    TPMI_DH_OBJECT\t\tnewParent;\n    TPM2B_PRIVATE\t\tinDuplicate;\n    TPM2B_NAME\t\t\tname;\n    TPM2B_ENCRYPTED_SECRET\tinSymSeed;\n} Rewrap_In;\n\n#define RC_Rewrap_oldParent \t(TPM_RC_H + TPM_RC_1)\n#define RC_Rewrap_newParent \t(TPM_RC_H + TPM_RC_2)\n#define RC_Rewrap_inDuplicate \t(TPM_RC_P + TPM_RC_1)\n#define RC_Rewrap_name\t\t(TPM_RC_P + TPM_RC_2)\n#define RC_Rewrap_inSymSeed \t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPM2B_PRIVATE\t\toutDuplicate;\n    TPM2B_ENCRYPTED_SECRET\toutSymSeed;\n} Rewrap_Out;\n\nTPM_RC\nTPM2_Rewrap(\n\t    Rewrap_In       *in,            // IN: input parameter list\n\t    Rewrap_Out      *out            // OUT: output parameter list\n\t    );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/RsaKeyCache_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     The RSA key cache \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: RsaKeyCache_fp.h 953 2017-03-06 20:31:40Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2017\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef RSAKEYCACHE_FP_H\n#define RSAKEYCACHE_FP_H\n\nLIB_EXPORT void\nRsaKeyCacheControl(\n\t\t   int             state\n\t\t   );\nBOOL\nGetCachedRsaKey(\n\t\tOBJECT              *key,\n\t\tRAND_STATE          *rand               // IN: if not NULL, the deterministic\n\t\t//     RNG state\n\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/RsaTestData.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     RSA Test Vectors\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: RsaTestData.h 1259 2018-07-10 19:11:09Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef RSATESTDATA_H\n#define RSATESTDATA_H\n\n\n/* 10.1.9 RsaTestData.h */\n/* RSA Test Vectors */\n#define RSA_TEST_KEY_SIZE   256\ntypedef struct\n{\n    UINT16      size;\n    BYTE        buffer[RSA_TEST_KEY_SIZE];\n} TPM2B_RSA_TEST_KEY;\ntypedef TPM2B_RSA_TEST_KEY  TPM2B_RSA_TEST_VALUE;\ntypedef struct\n{\n    UINT16       size;\n    BYTE        buffer[RSA_TEST_KEY_SIZE / 2];\n} TPM2B_RSA_TEST_PRIME;\nconst TPM2B_RSA_TEST_KEY    c_rsaPublicModulus = {256, {\n\t0x91,0x12,0xf5,0x07,0x9d,0x5f,0x6b,0x1c,0x90,0xf6,0xcc,0x87,0xde,0x3a,0x7a,0x15,\n\t0xdc,0x54,0x07,0x6c,0x26,0x8f,0x25,0xef,0x7e,0x66,0xc0,0xe3,0x82,0x12,0x2f,0xab,\n\t0x52,0x82,0x1e,0x85,0xbc,0x53,0xba,0x2b,0x01,0xad,0x01,0xc7,0x8d,0x46,0x4f,0x7d,\n\t0xdd,0x7e,0xdc,0xb0,0xad,0xf6,0x0c,0xa1,0x62,0x92,0x97,0x8a,0x3e,0x6f,0x7e,0x3e,\n\t0xf6,0x9a,0xcc,0xf9,0xa9,0x86,0x77,0xb6,0x85,0x43,0x42,0x04,0x13,0x65,0xe2,0xad,\n\t0x36,0xc9,0xbf,0xc1,0x97,0x84,0x6f,0xee,0x7c,0xda,0x58,0xd2,0xae,0x07,0x00,0xaf,\n\t0xc5,0x5f,0x4d,0x3a,0x98,0xb0,0xed,0x27,0x7c,0xc2,0xce,0x26,0x5d,0x87,0xe1,0xe3,\n\t0xa9,0x69,0x88,0x4f,0x8c,0x08,0x31,0x18,0xae,0x93,0x16,0xe3,0x74,0xde,0xd3,0xf6,\n\t0x16,0xaf,0xa3,0xac,0x37,0x91,0x8d,0x10,0xc6,0x6b,0x64,0x14,0x3a,0xd9,0xfc,0xe4,\n\t0xa0,0xf2,0xd1,0x01,0x37,0x4f,0x4a,0xeb,0xe5,0xec,0x98,0xc5,0xd9,0x4b,0x30,0xd2,\n\t0x80,0x2a,0x5a,0x18,0x5a,0x7d,0xd4,0x3d,0xb7,0x62,0x98,0xce,0x6d,0xa2,0x02,0x6e,\n\t0x45,0xaa,0x95,0x73,0xe0,0xaa,0x75,0x57,0xb1,0x3d,0x1b,0x05,0x75,0x23,0x6b,0x20,\n\t0x69,0x9e,0x14,0xb0,0x7f,0xac,0xae,0xd2,0xc7,0x48,0x3b,0xe4,0x56,0x11,0x34,0x1e,\n\t0x05,0x1a,0x30,0x20,0xef,0x68,0x93,0x6b,0x9d,0x7e,0xdd,0xba,0x96,0x50,0xcc,0x1c,\n\t0x81,0xb4,0x59,0xb9,0x74,0x36,0xd9,0x97,0xdc,0x8f,0x17,0x82,0x72,0xb3,0x59,0xf6,\n\t0x23,0xfa,0x84,0xf7,0x6d,0xf2,0x05,0xff,0xf1,0xb9,0xcc,0xe9,0xa2,0x82,0x01,0xfb}};\nconst TPM2B_RSA_TEST_PRIME    c_rsaPrivatePrime = {RSA_TEST_KEY_SIZE / 2, {\n\t0xb7,0xa0,0x90,0xc7,0x92,0x09,0xde,0x71,0x03,0x37,0x4a,0xb5,0x2f,0xda,0x61,0xb8,\n\t0x09,0x1b,0xba,0x99,0x70,0x45,0xc1,0x0b,0x15,0x12,0x71,0x8a,0xb3,0x2a,0x4d,0x5a,\n\t0x41,0x9b,0x73,0x89,0x80,0x0a,0x8f,0x18,0x4c,0x8b,0xa2,0x5b,0xda,0xbd,0x43,0xbe,\n\t0xdc,0x76,0x4d,0x71,0x0f,0xb9,0xfc,0x7a,0x09,0xfe,0x4f,0xac,0x63,0xd9,0x2e,0x50,\n\t0x3a,0xa1,0x37,0xc6,0xf2,0xa1,0x89,0x12,0xe7,0x72,0x64,0x2b,0xba,0xc1,0x1f,0xca,\n\t0x9d,0xb7,0xaa,0x3a,0xa9,0xd3,0xa6,0x6f,0x73,0x02,0xbb,0x85,0x5d,0x9a,0xb9,0x5c,\n\t0x08,0x83,0x22,0x20,0x49,0x91,0x5f,0x4b,0x86,0xbc,0x3f,0x76,0x43,0x08,0x97,0xbf,\n\t0x82,0x55,0x36,0x2d,0x8b,0x6e,0x9e,0xfb,0xc1,0x67,0x6a,0x43,0xa2,0x46,0x81,0x71}};\nconst BYTE        c_RsaTestValue[RSA_TEST_KEY_SIZE] = {\n    0x2a,0x24,0x3a,0xbb,0x50,0x1d,0xd4,0x2a,0xf9,0x18,0x32,0x34,0xa2,0x0f,0xea,0x5c,\n    0x91,0x77,0xe9,0xe1,0x09,0x83,0xdc,0x5f,0x71,0x64,0x5b,0xeb,0x57,0x79,0xa0,0x41,\n    0xc9,0xe4,0x5a,0x0b,0xf4,0x9f,0xdb,0x84,0x04,0xa6,0x48,0x24,0xf6,0x3f,0x66,0x1f,\n    0xa8,0x04,0x5c,0xf0,0x7a,0x6b,0x4a,0x9c,0x7e,0x21,0xb6,0xda,0x6b,0x65,0x9c,0x3a,\n    0x68,0x50,0x13,0x1e,0xa4,0xb7,0xca,0xec,0xd3,0xcc,0xb2,0x9b,0x8c,0x87,0xa4,0x6a,\n    0xba,0xc2,0x06,0x3f,0x40,0x48,0x7b,0xa8,0xb8,0x2c,0x03,0x14,0x33,0xf3,0x1d,0xe9,\n    0xbd,0x6f,0x54,0x66,0xb4,0x69,0x5e,0xbc,0x80,0x7c,0xe9,0x6a,0x43,0x7f,0xb8,0x6a,\n    0xa0,0x5f,0x5d,0x7a,0x20,0xfd,0x7a,0x39,0xe1,0xea,0x0e,0x94,0x91,0x28,0x63,0x7a,\n    0xac,0xc9,0xa5,0x3a,0x6d,0x31,0x7b,0x7c,0x54,0x56,0x99,0x56,0xbb,0xb7,0xa1,0x2d,\n    0xd2,0x5c,0x91,0x5f,0x1c,0xd3,0x06,0x7f,0x34,0x53,0x2f,0x4c,0xd1,0x8b,0xd2,0x9e,\n    0xdc,0xc3,0x94,0x0a,0xe1,0x0f,0xa5,0x15,0x46,0x2a,0x8e,0x10,0xc2,0xfe,0xb7,0x5e,\n    0x2d,0x0d,0xd1,0x25,0xfc,0xe4,0xf7,0x02,0x19,0xfe,0xb6,0xe4,0x95,0x9c,0x17,0x4a,\n    0x9b,0xdb,0xab,0xc7,0x79,0xe3,0x5e,0x40,0xd0,0x56,0x6d,0x25,0x0a,0x72,0x65,0x80,\n    0x92,0x9a,0xa8,0x07,0x70,0x32,0x14,0xfb,0xfe,0x08,0xeb,0x13,0xb4,0x07,0x68,0xb4,\n    0x58,0x39,0xbe,0x8e,0x78,0x3a,0x59,0x3f,0x9c,0x4c,0xe9,0xa8,0x64,0x68,0xf7,0xb9,\n    0x6e,0x20,0xf5,0xcb,0xca,0x47,0xf2,0x17,0xaa,0x8b,0xbc,0x13,0x14,0x84,0xf6,0xab};\nconst TPM2B_RSA_TEST_VALUE    c_RsaepKvt = {RSA_TEST_KEY_SIZE, {\n\t0x73,0xbd,0x65,0x49,0xda,0x7b,0xb8,0x50,0x9e,0x87,0xf0,0x0a,0x8a,0x9a,0x07,0xb6,\n\t0x00,0x82,0x10,0x14,0x60,0xd8,0x01,0xfc,0xc5,0x18,0xea,0x49,0x5f,0x13,0xcf,0x65,\n\t0x66,0x30,0x6c,0x60,0x3f,0x24,0x3c,0xfb,0xe2,0x31,0x16,0x99,0x7e,0x31,0x98,0xab,\n\t0x93,0xb8,0x07,0x53,0xcc,0xdb,0x7f,0x44,0xd9,0xee,0x5d,0xe8,0x5f,0x97,0x5f,0xe8,\n\t0x1f,0x88,0x52,0x24,0x7b,0xac,0x62,0x95,0xb7,0x7d,0xf5,0xf8,0x9f,0x5a,0xa8,0x24,\n\t0x9a,0x76,0x71,0x2a,0x35,0x2a,0xa1,0x08,0xbb,0x95,0xe3,0x64,0xdc,0xdb,0xc2,0x33,\n\t0xa9,0x5f,0xbe,0x4c,0xc4,0xcc,0x28,0xc9,0x25,0xff,0xee,0x17,0x15,0x9a,0x50,0x90,\n\t0x0e,0x15,0xb4,0xea,0x6a,0x09,0xe6,0xff,0xa4,0xee,0xc7,0x7e,0xce,0xa9,0x73,0xe4,\n\t0xa0,0x56,0xbd,0x53,0x2a,0xe4,0xc0,0x2b,0xa8,0x9b,0x09,0x30,0x72,0x62,0x0f,0xf9,\n\t0xf6,0xa1,0x52,0xd2,0x8a,0x37,0xee,0xa5,0xc8,0x47,0xe1,0x99,0x21,0x47,0xeb,0xdd,\n\t0x37,0xaa,0xe4,0xbd,0x55,0x46,0x5a,0x5a,0x5d,0xfb,0x7b,0xfc,0xff,0xbf,0x26,0x71,\n\t0xf6,0x1e,0xad,0xbc,0xbf,0x33,0xca,0xe1,0x92,0x8f,0x2a,0x89,0x6c,0x45,0x24,0xd1,\n\t0xa6,0x52,0x56,0x24,0x5e,0x90,0x47,0xe5,0xcb,0x12,0xb0,0x32,0xf9,0xa6,0xbb,0xea,\n\t0x37,0xa9,0xbd,0xef,0x23,0xef,0x63,0x07,0x6c,0xc4,0x4e,0x64,0x3c,0xc6,0x11,0x84,\n\t0x7d,0x65,0xd6,0x5d,0x7a,0x17,0x58,0xa5,0xf7,0x74,0x3b,0x42,0xe3,0xd2,0xda,0x5f,\n\t0x6f,0xe0,0x1e,0x4b,0xcf,0x46,0xe2,0xdf,0x3e,0x41,0x8e,0x0e,0xb0,0x3f,0x8b,0x65}};\n\n#define    OAEP_TEST_LABEL     \"OAEP Test Value\"\n\n#if ALG_SHA1_VALUE == DEFAULT_TEST_HASH\n\nconst TPM2B_RSA_TEST_VALUE    c_OaepKvt = {RSA_TEST_KEY_SIZE, {\n\t0x32,0x68,0x84,0x0b,0x9c,0xc9,0x25,0x26,0xd9,0xc0,0xd0,0xb1,0xde,0x60,0x55,0xae,\n\t0x33,0xe5,0xcf,0x6c,0x85,0xbe,0x0d,0x71,0x11,0xe1,0x45,0x60,0xbb,0x42,0x3d,0xf3,\n\t0xb1,0x18,0x84,0x7b,0xc6,0x5d,0xce,0x1d,0x5f,0x9a,0x97,0xcf,0xb1,0x97,0x9a,0x85,\n\t0x7c,0xa7,0xa1,0x63,0x23,0xb6,0x74,0x0f,0x1a,0xee,0x29,0x51,0xeb,0x50,0x8f,0x3c,\n\t0x8e,0x4e,0x31,0x38,0xdc,0x11,0xfc,0x9a,0x4e,0xaf,0x93,0xc9,0x7f,0x6e,0x35,0xf3,\n\t0xc9,0xe4,0x89,0x14,0x53,0xe2,0xc2,0x1a,0xf7,0x6b,0x9b,0xf0,0x7a,0xa4,0x69,0x52,\n\t0xe0,0x24,0x8f,0xea,0x31,0xa7,0x5c,0x43,0xb0,0x65,0xc9,0xfe,0xba,0xfe,0x80,0x9e,\n\t0xa5,0xc0,0xf5,0x8d,0xce,0x41,0xf9,0x83,0x0d,0x8e,0x0f,0xef,0x3d,0x1f,0x6a,0xcc,\n\t0x8a,0x3d,0x3b,0xdf,0x22,0x38,0xd7,0x34,0x58,0x7b,0x55,0xc9,0xf6,0xbc,0x7c,0x4c,\n\t0x3f,0xd7,0xde,0x4e,0x30,0xa9,0x69,0xf3,0x5f,0x56,0x8f,0xc2,0xe7,0x75,0x79,0xb8,\n\t0xa5,0xc8,0x0d,0xc0,0xcd,0xb6,0xc9,0x63,0xad,0x7c,0xe4,0x8f,0x39,0x60,0x4d,0x7d,\n\t0xdb,0x34,0x49,0x2a,0x47,0xde,0xc0,0x42,0x4a,0x19,0x94,0x2e,0x50,0x21,0x03,0x47,\n\t0xff,0x73,0xb3,0xb7,0x89,0xcc,0x7b,0x2c,0xeb,0x03,0xa7,0x9a,0x06,0xfd,0xed,0x19,\n\t0xbb,0x82,0xa0,0x13,0xe9,0xfa,0xac,0x06,0x5f,0xc5,0xa9,0x2b,0xda,0x88,0x23,0xa2,\n\t0x5d,0xc2,0x7f,0xda,0xc8,0x5a,0x94,0x31,0xc1,0x21,0xd7,0x1e,0x6b,0xd7,0x89,0xb1,\n\t0x93,0x80,0xab,0xd1,0x37,0xf2,0x6f,0x50,0xcd,0x2a,0xea,0xb1,0xc4,0xcd,0xcb,0xb5}};\nconst TPM2B_RSA_TEST_VALUE    c_RsaesKvt = {RSA_TEST_KEY_SIZE, {\n\t0x29,0xa4,0x2f,0xbb,0x8a,0x14,0x05,0x1e,0x3c,0x72,0x76,0x77,0x38,0xe7,0x73,0xe3,\n\t0x6e,0x24,0x4b,0x38,0xd2,0x1a,0xcf,0x23,0x58,0x78,0x36,0x82,0x23,0x6e,0x6b,0xef,\n\t0x2c,0x3d,0xf2,0xe8,0xd6,0xc6,0x87,0x8e,0x78,0x9b,0x27,0x39,0xc0,0xd6,0xef,0x4d,\n\t0x0b,0xfc,0x51,0x27,0x18,0xf3,0x51,0x5e,0x4d,0x96,0x3a,0xe2,0x15,0xe2,0x7e,0x42,\n\t0xf4,0x16,0xd5,0xc6,0x52,0x5d,0x17,0x44,0x76,0x09,0x7a,0xcf,0xe3,0x30,0xe3,0x84,\n\t0xf6,0x6f,0x3a,0x33,0xfb,0x32,0x0d,0x1d,0xe7,0x7c,0x80,0x82,0x4f,0xed,0xda,0x87,\n\t0x11,0x9c,0xc3,0x7e,0x85,0xbd,0x18,0x58,0x08,0x2b,0x23,0x37,0xe7,0x9d,0xd0,0xd1,\n\t0x79,0xe2,0x05,0xbd,0xf5,0x4f,0x0e,0x0f,0xdb,0x4a,0x74,0xeb,0x09,0x01,0xb3,0xca,\n\t0xbd,0xa6,0x7b,0x09,0xb1,0x13,0x77,0x30,0x4d,0x87,0x41,0x06,0x57,0x2e,0x5f,0x36,\n\t0x6e,0xfc,0x35,0x69,0xfe,0x0a,0x24,0x6c,0x98,0x8c,0xda,0x97,0xf4,0xfb,0xc7,0x83,\n\t0x2d,0x3e,0x7d,0xc0,0x5c,0x34,0xfd,0x11,0x2a,0x12,0xa7,0xae,0x4a,0xde,0xc8,0x4e,\n\t0xcf,0xf4,0x85,0x63,0x77,0xc6,0x33,0x34,0xe0,0x27,0xe4,0x9e,0x91,0x0b,0x4b,0x85,\n\t0xf0,0xb0,0x79,0xaa,0x7c,0xc6,0xff,0x3b,0xbc,0x04,0x73,0xb8,0x95,0xd7,0x31,0x54,\n\t0x3b,0x56,0xec,0x52,0x15,0xd7,0x3e,0x62,0xf5,0x82,0x99,0x3e,0x2a,0xc0,0x4b,0x2e,\n\t0x06,0x57,0x6d,0x3f,0x3e,0x77,0x1f,0x2b,0x2d,0xc5,0xb9,0x3b,0x68,0x56,0x73,0x70,\n\t0x32,0x6b,0x6b,0x65,0x25,0x76,0x45,0x6c,0x45,0xf1,0x6c,0x59,0xfc,0x94,0xa7,0x15}};\nconst TPM2B_RSA_TEST_VALUE    c_RsapssKvt = {RSA_TEST_KEY_SIZE, {\n\t0x01,0xfe,0xd5,0x83,0x0b,0x15,0xba,0x90,0x2c,0xdf,0xf7,0x26,0xb7,0x8f,0xb1,0xd7,\n\t0x0b,0xfd,0x83,0xf9,0x95,0xd5,0xd7,0xb5,0xc5,0xc5,0x4a,0xde,0xd5,0xe6,0x20,0x78,\n\t0xca,0x73,0x77,0x3d,0x61,0x36,0x48,0xae,0x3e,0x8f,0xee,0x43,0x29,0x96,0xdf,0x3f,\n\t0x1c,0x97,0x5a,0xbe,0xe5,0xa2,0x7e,0x5b,0xd0,0xc0,0x29,0x39,0x83,0x81,0x77,0x24,\n\t0x43,0xdb,0x3c,0x64,0x4d,0xf0,0x23,0xe4,0xae,0x0f,0x78,0x31,0x8c,0xda,0x0c,0xec,\n\t0xf1,0xdf,0x09,0xf2,0x14,0x6a,0x4d,0xaf,0x36,0x81,0x6e,0xbd,0xbe,0x36,0x79,0x88,\n\t0x98,0xb6,0x6f,0x5a,0xad,0xcf,0x7c,0xee,0xe0,0xdd,0x00,0xbe,0x59,0x97,0x88,0x00,\n\t0x34,0xc0,0x8b,0x48,0x42,0x05,0x04,0x5a,0xb7,0x85,0x38,0xa0,0x35,0xd7,0x3b,0x51,\n\t0xb8,0x7b,0x81,0x83,0xee,0xff,0x76,0x6f,0x50,0x39,0x4d,0xab,0x89,0x63,0x07,0x6d,\n\t0xf5,0xe5,0x01,0x10,0x56,0xfe,0x93,0x06,0x8f,0xd3,0xc9,0x41,0xab,0xc9,0xdf,0x6e,\n\t0x59,0xa8,0xc3,0x1d,0xbf,0x96,0x4a,0x59,0x80,0x3c,0x90,0x3a,0x59,0x56,0x4c,0x6d,\n\t0x44,0x6d,0xeb,0xdc,0x73,0xcd,0xc1,0xec,0xb8,0x41,0xbf,0x89,0x8c,0x03,0x69,0x4c,\n\t0xaf,0x3f,0xc1,0xc5,0xc7,0xe7,0x7d,0xa7,0x83,0x39,0x70,0xa2,0x6b,0x83,0xbc,0xbe,\n\t0xf5,0xbf,0x1c,0xee,0x6e,0xa3,0x22,0x1e,0x25,0x2f,0x16,0x68,0x69,0x5a,0x1d,0xfa,\n\t0x2c,0x3a,0x0f,0x67,0xe1,0x77,0x12,0xe8,0x3d,0xba,0xaa,0xef,0x96,0x9c,0x1f,0x64,\n\t0x32,0xf4,0xa7,0xb3,0x3f,0x7d,0x61,0xbb,0x9a,0x27,0xad,0xfb,0x2f,0x33,0xc4,0x70}};\nconst TPM2B_RSA_TEST_VALUE    c_RsassaKvt = {RSA_TEST_KEY_SIZE, {\n\t0x67,0x4e,0xdd,0xc2,0xd2,0x6d,0xe0,0x03,0xc4,0xc2,0x41,0xd3,0xd4,0x61,0x30,0xd0,\n\t0xe1,0x68,0x31,0x4a,0xda,0xd9,0xc2,0x5d,0xaa,0xa2,0x7b,0xfb,0x44,0x02,0xf5,0xd6,\n\t0xd8,0x2e,0xcd,0x13,0x36,0xc9,0x4b,0xdb,0x1a,0x4b,0x66,0x1b,0x4f,0x9c,0xb7,0x17,\n\t0xac,0x53,0x37,0x4f,0x21,0xbd,0x0c,0x66,0xac,0x06,0x65,0x52,0x9f,0x04,0xf6,0xa5,\n\t0x22,0x5b,0xf7,0xe6,0x0d,0x3c,0x9f,0x41,0x19,0x09,0x88,0x7c,0x41,0x4c,0x2f,0x9c,\n\t0x8b,0x3c,0xdd,0x7c,0x28,0x78,0x24,0xd2,0x09,0xa6,0x5b,0xf7,0x3c,0x88,0x7e,0x73,\n\t0x5a,0x2d,0x36,0x02,0x4f,0x65,0xb0,0xcb,0xc8,0xdc,0xac,0xa2,0xda,0x8b,0x84,0x91,\n\t0x71,0xe4,0x30,0x8b,0xb6,0x12,0xf2,0xf0,0xd0,0xa0,0x38,0xcf,0x75,0xb7,0x20,0xcb,\n\t0x35,0x51,0x52,0x6b,0xc4,0xf4,0x21,0x95,0xc2,0xf7,0x9a,0x13,0xc1,0x1a,0x7b,0x8f,\n\t0x77,0xda,0x19,0x48,0xbb,0x6d,0x14,0x5d,0xba,0x65,0xb4,0x9e,0x43,0x42,0x58,0x98,\n\t0x0b,0x91,0x46,0xd8,0x4c,0xf3,0x4c,0xaf,0x2e,0x02,0xa6,0xb2,0x49,0x12,0x62,0x43,\n\t0x4e,0xa8,0xac,0xbf,0xfd,0xfa,0x37,0x24,0xea,0x69,0x1c,0xf5,0xae,0xfa,0x08,0x82,\n\t0x30,0xc3,0xc0,0xf8,0x9a,0x89,0x33,0xe1,0x40,0x6d,0x18,0x5c,0x7b,0x90,0x48,0xbf,\n\t0x37,0xdb,0xea,0xfb,0x0e,0xd4,0x2e,0x11,0xfa,0xa9,0x86,0xff,0x00,0x0b,0x7b,0xca,\n\t0x09,0x64,0x6a,0x8f,0x0c,0x0e,0x09,0x14,0x36,0x4a,0x74,0x31,0x18,0x5b,0x18,0xeb,\n\t0xea,0x83,0xc3,0x66,0x68,0xa6,0x7d,0x43,0x06,0x0f,0x99,0x60,0xce,0x65,0x08,0xf6}};\n#endif // SHA1\n#if ALG_SHA256_VALUE == DEFAULT_TEST_HASH\nconst TPM2B_RSA_TEST_VALUE    c_OaepKvt = {RSA_TEST_KEY_SIZE, {\n\t0x33,0x20,0x6e,0x21,0xc3,0xf6,0xcd,0xf8,0xd7,0x5d,0x9f,0xe9,0x05,0x14,0x8c,0x7c,\n\t0xbb,0x69,0x24,0x9e,0x52,0x8f,0xaf,0x84,0x73,0x21,0x2c,0x85,0xa5,0x30,0x4d,0xb6,\n\t0xb8,0xfa,0x15,0x9b,0xc7,0x8f,0xc9,0x7a,0x72,0x4b,0x85,0xa4,0x1c,0xc5,0xd8,0xe4,\n\t0x92,0xb3,0xec,0xd9,0xa8,0xca,0x5e,0x74,0x73,0x89,0x7f,0xb4,0xac,0x7e,0x68,0x12,\n\t0xb2,0x53,0x27,0x4b,0xbf,0xd0,0x71,0x69,0x46,0x9f,0xef,0xf4,0x70,0x60,0xf8,0xd7,\n\t0xae,0xc7,0x5a,0x27,0x38,0x25,0x2d,0x25,0xab,0x96,0x56,0x66,0x3a,0x23,0x40,0xa8,\n\t0xdb,0xbc,0x86,0xe8,0xf3,0xd2,0x58,0x0b,0x44,0xfc,0x94,0x1e,0xb7,0x5d,0xb4,0x57,\n\t0xb5,0xf3,0x56,0xee,0x9b,0xcf,0x97,0x91,0x29,0x36,0xe3,0x06,0x13,0xa2,0xea,0xd6,\n\t0xd6,0x0b,0x86,0x0b,0x1a,0x27,0xe6,0x22,0xc4,0x7b,0xff,0xde,0x0f,0xbf,0x79,0xc8,\n\t0x1b,0xed,0xf1,0x27,0x62,0xb5,0x8b,0xf9,0xd9,0x76,0x90,0xf6,0xcc,0x83,0x0f,0xce,\n\t0xce,0x2e,0x63,0x7a,0x9b,0xf4,0x48,0x5b,0xd7,0x81,0x2c,0x3a,0xdb,0x59,0x0d,0x4d,\n\t0x9e,0x46,0xe9,0x9e,0x92,0x22,0x27,0x1c,0xb0,0x67,0x8a,0xe6,0x8a,0x16,0x8a,0xdf,\n\t0x95,0x76,0x24,0x82,0xad,0xf1,0xbc,0x97,0xbf,0xd3,0x5e,0x6e,0x14,0x0c,0x5b,0x25,\n\t0xfe,0x58,0xfa,0x64,0xe5,0x14,0x46,0xb7,0x58,0xc6,0x3f,0x7f,0x42,0xd2,0x8e,0x45,\n\t0x13,0x41,0x85,0x12,0x2e,0x96,0x19,0xd0,0x5e,0x7d,0x34,0x06,0x32,0x2b,0xc8,0xd9,\n\t0x0d,0x6c,0x06,0x36,0xa0,0xff,0x47,0x57,0x2c,0x25,0xbc,0x8a,0xa5,0xe2,0xc7,0xe3}};\nconst TPM2B_RSA_TEST_VALUE    c_RsaesKvt = {RSA_TEST_KEY_SIZE, {\n\t0x39,0xfc,0x10,0x5d,0xf4,0x45,0x3d,0x94,0x53,0x06,0x89,0x24,0xe7,0xe8,0xfd,0x03,\n\t0xac,0xfd,0xbd,0xb2,0x28,0xd3,0x4a,0x52,0xc5,0xd4,0xdb,0x17,0xd4,0x24,0x05,0xc4,\n\t0xeb,0x6a,0xce,0x1d,0xbb,0x37,0xcb,0x09,0xd8,0x6c,0x83,0x19,0x93,0xd4,0xe2,0x88,\n\t0x88,0x9b,0xaf,0x92,0x16,0xc4,0x15,0xbd,0x49,0x13,0x22,0xb7,0x84,0xcf,0x23,0xf2,\n\t0x6f,0x0c,0x3e,0x8f,0xde,0x04,0x09,0x31,0x2d,0x99,0xdf,0xe6,0x74,0x70,0x30,0xde,\n\t0x8c,0xad,0x32,0x86,0xe2,0x7c,0x12,0x90,0x21,0xf3,0x86,0xb7,0xe2,0x64,0xca,0x98,\n\t0xcc,0x64,0x4b,0xef,0x57,0x4f,0x5a,0x16,0x6e,0xd7,0x2f,0x5b,0xf6,0x07,0xad,0x33,\n\t0xb4,0x8f,0x3b,0x3a,0x8b,0xd9,0x06,0x2b,0xed,0x3c,0x3c,0x76,0xf6,0x21,0x31,0xe3,\n\t0xfb,0x2c,0x45,0x61,0x42,0xba,0xe0,0xc3,0x72,0x63,0xd0,0x6b,0x8f,0x36,0x26,0xfb,\n\t0x9e,0x89,0x0e,0x44,0x9a,0xc1,0x84,0x5e,0x84,0x8d,0xb6,0xea,0xf1,0x0d,0x66,0xc7,\n\t0xdb,0x44,0xbd,0x19,0x7c,0x05,0xbe,0xc4,0xab,0x88,0x32,0xbe,0xc7,0x63,0x31,0xe6,\n\t0x38,0xd4,0xe5,0xb8,0x4b,0xf5,0x0e,0x55,0x9a,0x3a,0xe6,0x0a,0xec,0xee,0xe2,0xa8,\n\t0x88,0x04,0xf2,0xb8,0xaa,0x5a,0xd8,0x97,0x5d,0xa0,0xa8,0x42,0xfb,0xd9,0xde,0x80,\n\t0xae,0x4c,0xb3,0xa1,0x90,0x47,0x57,0x03,0x10,0x78,0xa6,0x8f,0x11,0xba,0x4b,0xce,\n\t0x2d,0x56,0xa4,0xe1,0xbd,0xf8,0xa0,0xa4,0xd5,0x48,0x3c,0x63,0x20,0x00,0x38,0xa0,\n\t0xd1,0xe6,0x12,0xe9,0x1d,0xd8,0x49,0xe3,0xd5,0x24,0xb5,0xc5,0x3a,0x1f,0xb0,0xd4}};\nconst TPM2B_RSA_TEST_VALUE    c_RsapssKvt = {RSA_TEST_KEY_SIZE, {\n\t0x74,0x89,0x29,0x3e,0x1b,0xac,0xc6,0x85,0xca,0xf0,0x63,0x43,0x30,0x7d,0x1c,0x9b,\n\t0x2f,0xbd,0x4d,0x69,0x39,0x5e,0x85,0xe2,0xef,0x86,0x0a,0xc6,0x6b,0xa6,0x08,0x19,\n\t0x6c,0x56,0x38,0x24,0x55,0x92,0x84,0x9b,0x1b,0x8b,0x04,0xcf,0x24,0x14,0x24,0x13,\n\t0x0e,0x8b,0x82,0x6f,0x96,0xc8,0x9a,0x68,0xfc,0x4c,0x02,0xf0,0xdc,0xcd,0x36,0x25,\n\t0x31,0xd5,0x82,0xcf,0xc9,0x69,0x72,0xf6,0x1d,0xab,0x68,0x20,0x2e,0x2d,0x19,0x49,\n\t0xf0,0x2e,0xad,0xd2,0xda,0xaf,0xff,0xb6,0x92,0x83,0x5b,0x8a,0x06,0x2d,0x0c,0x32,\n\t0x11,0x32,0x3b,0x77,0x17,0xf6,0x50,0xfb,0xf8,0x57,0xc9,0xc7,0x9b,0x9e,0xc6,0xd1,\n\t0xa9,0x55,0xf0,0x22,0x35,0xda,0xca,0x3c,0x8e,0xc6,0x9a,0xd8,0x25,0xc8,0x5e,0x93,\n\t0x0d,0xaa,0xa7,0x06,0xaf,0x11,0x29,0x99,0xe7,0x7c,0xee,0x49,0x82,0x30,0xba,0x2c,\n\t0xe2,0x40,0x8f,0x0a,0xa6,0x7b,0x24,0x75,0xc5,0xcd,0x03,0x12,0xf4,0xb2,0x4b,0x3a,\n\t0xd1,0x91,0x3c,0x20,0x0e,0x58,0x2b,0x31,0xf8,0x8b,0xee,0xbc,0x1f,0x95,0x35,0x58,\n\t0x6a,0x73,0xee,0x99,0xb0,0x01,0x42,0x4f,0x66,0xc0,0x66,0xbb,0x35,0x86,0xeb,0xd9,\n\t0x7b,0x55,0x77,0x2d,0x54,0x78,0x19,0x49,0xe8,0xcc,0xfd,0xb1,0xcb,0x49,0xc9,0xea,\n\t0x20,0xab,0xed,0xb5,0xed,0xfe,0xb2,0xb5,0xa8,0xcf,0x05,0x06,0xd5,0x7d,0x2b,0xbb,\n\t0x0b,0x65,0x6b,0x2b,0x6d,0x55,0x95,0x85,0x44,0x8b,0x12,0x05,0xf3,0x4b,0xd4,0x8e,\n\t0x3d,0x68,0x2d,0x29,0x9c,0x05,0x79,0xd6,0xfc,0x72,0x90,0x6a,0xab,0x46,0x38,0x81}};\nconst TPM2B_RSA_TEST_VALUE    c_RsassaKvt = {RSA_TEST_KEY_SIZE, {\n\t0x8a,0xb1,0x0a,0xb5,0xe4,0x02,0xf7,0xdd,0x45,0x2a,0xcc,0x2b,0x6b,0x8c,0x0e,0x9a,\n\t0x92,0x4f,0x9b,0xc5,0xe4,0x8b,0x82,0xb9,0xb0,0xd9,0x87,0x8c,0xcb,0xf0,0xb0,0x59,\n\t0xa5,0x92,0x21,0xa0,0xa7,0x61,0x5c,0xed,0xa8,0x6e,0x22,0x29,0x46,0xc7,0x86,0x37,\n\t0x4b,0x1b,0x1e,0x94,0x93,0xc8,0x4c,0x17,0x7a,0xae,0x59,0x91,0xf8,0x83,0x84,0xc4,\n\t0x8c,0x38,0xc2,0x35,0x0e,0x7e,0x50,0x67,0x76,0xe7,0xd3,0xec,0x6f,0x0d,0xa0,0x5c,\n\t0x2f,0x0a,0x80,0x28,0xd3,0xc5,0x7d,0x2d,0x1a,0x0b,0x96,0xd6,0xe5,0x98,0x05,0x8c,\n\t0x4d,0xa0,0x1f,0x8c,0xb6,0xfb,0xb1,0xcf,0xe9,0xcb,0x38,0x27,0x60,0x64,0x17,0xca,\n\t0xf4,0x8b,0x61,0xb7,0x1d,0xb6,0x20,0x9d,0x40,0x2a,0x1c,0xfd,0x55,0x40,0x4b,0x95,\n\t0x39,0x52,0x18,0x3b,0xab,0x44,0xe8,0x83,0x4b,0x7c,0x47,0xfb,0xed,0x06,0x9c,0xcd,\n\t0x4f,0xba,0x81,0xd6,0xb7,0x31,0xcf,0x5c,0x23,0xf8,0x25,0xab,0x95,0x77,0x0a,0x8f,\n\t0x46,0xef,0xfb,0x59,0xb8,0x04,0xd7,0x1e,0xf5,0xaf,0x6a,0x1a,0x26,0x9b,0xae,0xf4,\n\t0xf5,0x7f,0x84,0x6f,0x3c,0xed,0xf8,0x24,0x0b,0x43,0xd1,0xba,0x74,0x89,0x4e,0x39,\n\t0xfe,0xab,0xa5,0x16,0xa5,0x28,0xee,0x96,0x84,0x3e,0x16,0x6d,0x5f,0x4e,0x0b,0x7d,\n\t0x94,0x16,0x1b,0x8c,0xf9,0xaa,0x9b,0xc0,0x49,0x02,0x4c,0x3e,0x62,0xff,0xfe,0xa2,\n\t0x20,0x33,0x5e,0xa6,0xdd,0xda,0x15,0x2d,0xb7,0xcd,0xda,0xff,0xb1,0x0b,0x45,0x7b,\n\t0xd3,0xa0,0x42,0x29,0xab,0xa9,0x73,0xe9,0xa4,0xd9,0x8d,0xac,0xa1,0x88,0x2c,0x2d}};\n#endif // SHA256\n#if ALG_SHA384_VALUE == DEFAULT_TEST_HASH\nconst TPM2B_RSA_TEST_VALUE    c_OaepKvt = {RSA_TEST_KEY_SIZE, {\n\t0x0f,0x3c,0x42,0x4d,0x8c,0x91,0x96,0x05,0x3c,0xfd,0x59,0x3b,0x7f,0x29,0xbc,0x03,\n\t0x67,0xc1,0xff,0x74,0xe7,0x09,0xf4,0x13,0x45,0xbe,0x13,0x1d,0xc9,0x86,0x94,0xfe,\n\t0xed,0xa6,0xe8,0x3a,0xcb,0x89,0x4d,0xec,0x86,0x63,0x4c,0xdb,0xf1,0x95,0xee,0xc1,\n\t0x46,0xc5,0x3b,0xd8,0xf8,0xa2,0x41,0x6a,0x60,0x8b,0x9e,0x5e,0x7f,0x20,0x16,0xe3,\n\t0x69,0xb6,0x2d,0x92,0xfc,0x60,0xa2,0x74,0x88,0xd5,0xc7,0xa6,0xd1,0xff,0xe3,0x45,\n\t0x02,0x51,0x39,0xd9,0xf3,0x56,0x0b,0x91,0x80,0xe0,0x6c,0xa8,0xc3,0x78,0xef,0x34,\n\t0x22,0x8c,0xf5,0xfb,0x47,0x98,0x5d,0x57,0x8e,0x3a,0xb9,0xff,0x92,0x04,0xc7,0xc2,\n\t0x6e,0xfa,0x14,0xc1,0xb9,0x68,0x15,0x5c,0x12,0xe8,0xa8,0xbe,0xea,0xe8,0x8d,0x9b,\n\t0x48,0x28,0x35,0xdb,0x4b,0x52,0xc1,0x2d,0x85,0x47,0x83,0xd0,0xe9,0xae,0x90,0x6e,\n\t0x65,0xd4,0x34,0x7f,0x81,0xce,0x69,0xf0,0x96,0x62,0xf7,0xec,0x41,0xd5,0xc2,0xe3,\n\t0x4b,0xba,0x9c,0x8a,0x02,0xce,0xf0,0x5d,0x14,0xf7,0x09,0x42,0x8e,0x4a,0x27,0xfe,\n\t0x3e,0x66,0x42,0x99,0x03,0xe1,0x69,0xbd,0xdb,0x7f,0x9b,0x70,0xeb,0x4e,0x9c,0xac,\n\t0x45,0x67,0x91,0x9f,0x75,0x10,0xc6,0xfc,0x14,0xe1,0x28,0xc1,0x0e,0xe0,0x7e,0xc0,\n\t0x5c,0x1d,0xee,0xe8,0xff,0x45,0x79,0x51,0x86,0x08,0xe6,0x39,0xac,0xb5,0xfd,0xb8,\n\t0xf1,0xdd,0x2e,0xf4,0xb2,0x1a,0x69,0x0d,0xd9,0x98,0x8e,0xdb,0x85,0x61,0x70,0x20,\n\t0x82,0x91,0x26,0x87,0x80,0xc4,0x6a,0xd8,0x3b,0x91,0x4d,0xd3,0x33,0x84,0xad,0xb7}};\nconst TPM2B_RSA_TEST_VALUE    c_RsaesKvt = {RSA_TEST_KEY_SIZE, {\n\t0x44,0xd5,0x9f,0xbc,0x48,0x03,0x3d,0x9f,0x22,0x91,0x2a,0xab,0x3c,0x31,0x71,0xab,\n\t0x86,0x3f,0x0f,0x6f,0x59,0x5b,0x93,0x27,0xbc,0xbc,0xcd,0x29,0x38,0x43,0x2a,0x3b,\n\t0x3b,0xd2,0xb3,0x45,0x40,0xba,0x15,0xb4,0x45,0xe3,0x56,0xab,0xff,0xb3,0x20,0x26,\n\t0x39,0xcc,0x48,0xc5,0x5d,0x41,0x0d,0x2f,0x57,0x7f,0x9d,0x16,0x2e,0x26,0x57,0xc7,\n\t0x6b,0xf3,0x36,0x54,0xbd,0xb6,0x1d,0x46,0x4e,0x13,0x50,0xd7,0x61,0x9d,0x8d,0x7b,\n\t0xeb,0x21,0x9f,0x79,0xf3,0xfd,0xe0,0x1b,0xa8,0xed,0x6d,0x29,0x33,0x0d,0x65,0x94,\n\t0x24,0x1e,0x62,0x88,0x6b,0x2b,0x4e,0x39,0xf5,0x80,0x39,0xca,0x76,0x95,0xbc,0x7c,\n\t0x27,0x1d,0xdd,0x3a,0x11,0xf1,0x3e,0x54,0x03,0xb7,0x43,0x91,0x99,0x33,0xfe,0x9d,\n\t0x14,0x2c,0x87,0x9a,0x95,0x18,0x1f,0x02,0x04,0x6a,0xe2,0xb7,0x81,0x14,0x13,0x45,\n\t0x16,0xfb,0xe4,0xb7,0x8f,0xab,0x2b,0xd7,0x60,0x34,0x8a,0x55,0xbc,0x01,0x8c,0x49,\n\t0x02,0x29,0xf1,0x9c,0x94,0x98,0x44,0xd0,0x94,0xcb,0xd4,0x85,0x4c,0x3b,0x77,0x72,\n\t0x99,0xd5,0x4b,0xc6,0x3b,0xe4,0xd2,0xc8,0xe9,0x6a,0x23,0x18,0x3b,0x3b,0x5e,0x32,\n\t0xec,0x70,0x84,0x5d,0xbb,0x6a,0x8f,0x0c,0x5f,0x55,0xa5,0x30,0x34,0x48,0xbb,0xc2,\n\t0xdf,0x12,0xb9,0x81,0xad,0x36,0x3f,0xf0,0x24,0x16,0x48,0x04,0x4a,0x7f,0xfd,0x9f,\n\t0x4c,0xea,0xfe,0x1d,0x83,0xd0,0x81,0xad,0x25,0x6c,0x5f,0x45,0x36,0x91,0xf0,0xd5,\n\t0x8b,0x53,0x0a,0xdf,0xec,0x9f,0x04,0x58,0xc4,0x35,0xa0,0x78,0x1f,0x68,0xe0,0x22}};\nconst TPM2B_RSA_TEST_VALUE    c_RsapssKvt = {RSA_TEST_KEY_SIZE, {\n\t0x3f,0x3a,0x82,0x6d,0x42,0xe3,0x8b,0x4f,0x45,0x9c,0xda,0x6c,0xbe,0xbe,0xcd,0x00,\n\t0x98,0xfb,0xbe,0x59,0x30,0xc6,0x3c,0xaa,0xb3,0x06,0x27,0xb5,0xda,0xfa,0xb2,0xc3,\n\t0x43,0xb7,0xbd,0xe9,0xd3,0x23,0xed,0x80,0xce,0x74,0xb3,0xb8,0x77,0x8d,0xe6,0x8d,\n\t0x3c,0xe5,0xf5,0xd7,0x80,0xcf,0x38,0x55,0x76,0xd7,0x87,0xa8,0xd6,0x3a,0xcf,0xfd,\n\t0xd8,0x91,0x65,0xab,0x43,0x66,0x50,0xb7,0x9a,0x13,0x6b,0x45,0x80,0x76,0x86,0x22,\n\t0x27,0x72,0xf7,0xbb,0x65,0x22,0x5c,0x55,0x60,0xd8,0x84,0x9f,0xf2,0x61,0x52,0xac,\n\t0xf2,0x4f,0x5b,0x7b,0x21,0xe1,0xf5,0x4b,0x8f,0x01,0xf2,0x4b,0xcf,0xd3,0xfb,0x74,\n\t0x5e,0x6e,0x96,0xb4,0xa8,0x0f,0x01,0x9b,0x26,0x54,0x0a,0x70,0x55,0x26,0xb7,0x0b,\n\t0xe8,0x01,0x68,0x66,0x0d,0x6f,0xb5,0xfc,0x66,0xbd,0x9e,0x44,0xed,0x6a,0x1e,0x3c,\n\t0x3b,0x61,0x5d,0xe8,0xdb,0x99,0x5b,0x67,0xbf,0x94,0xfb,0xe6,0x8c,0x4b,0x07,0xcb,\n\t0x43,0x3a,0x0d,0xb1,0x1b,0x10,0x66,0x81,0xe2,0x0d,0xe7,0xd1,0xca,0x85,0xa7,0x50,\n\t0x82,0x2d,0xbf,0xed,0xcf,0x43,0x6d,0xdb,0x2c,0x7b,0x73,0x20,0xfe,0x73,0x3f,0x19,\n\t0xc6,0xdb,0x69,0xb8,0xc3,0xd3,0xf4,0xe5,0x64,0xf8,0x36,0x8e,0xd5,0xd8,0x09,0x2a,\n\t0x5f,0x26,0x70,0xa1,0xd9,0x5b,0x14,0xf8,0x22,0xe9,0x9d,0x22,0x51,0xf4,0x52,0xc1,\n\t0x6f,0x53,0xf5,0xca,0x0d,0xda,0x39,0x8c,0x29,0x42,0xe8,0x58,0x89,0xbb,0xd1,0x2e,\n\t0xc5,0xdb,0x86,0x8d,0xaf,0xec,0x58,0x36,0x8d,0x8d,0x57,0x23,0xd5,0xdd,0xb9,0x24}};\nconst TPM2B_RSA_TEST_VALUE    c_RsassaKvt = {RSA_TEST_KEY_SIZE, {\n\t0x39,0x10,0x58,0x7d,0x6d,0xa8,0xd5,0x90,0x07,0xd6,0x2b,0x13,0xe9,0xd8,0x93,0x7e,\n\t0xf3,0x5d,0x71,0xe0,0xf0,0x33,0x3a,0x4a,0x22,0xf3,0xe6,0x95,0xd3,0x8e,0x8c,0x41,\n\t0xe7,0xb3,0x13,0xde,0x4a,0x45,0xd3,0xd1,0xfb,0xb1,0x3f,0x9b,0x39,0xa5,0x50,0x58,\n\t0xef,0xb6,0x3a,0x43,0xdd,0x54,0xab,0xda,0x9d,0x32,0x49,0xe4,0x57,0x96,0xe5,0x1b,\n\t0x1d,0x8f,0x33,0x8e,0x07,0x67,0x56,0x14,0xc1,0x18,0x78,0xa2,0x52,0xe6,0x2e,0x07,\n\t0x81,0xbe,0xd8,0xca,0x76,0x63,0x68,0xc5,0x47,0xa2,0x92,0x5e,0x4c,0xfd,0x14,0xc7,\n\t0x46,0x14,0xbe,0xc7,0x85,0xef,0xe6,0xb8,0x46,0xcb,0x3a,0x67,0x66,0x89,0xc6,0xee,\n\t0x9d,0x64,0xf5,0x0d,0x09,0x80,0x9a,0x6f,0x0e,0xeb,0xe4,0xb9,0xe9,0xab,0x90,0x4f,\n\t0xe7,0x5a,0xc8,0xca,0xf6,0x16,0x0a,0x82,0xbd,0xb7,0x76,0x59,0x08,0x2d,0xd9,0x40,\n\t0x5d,0xaa,0xa5,0xef,0xfb,0xe3,0x81,0x2c,0x2c,0x5c,0xa8,0x16,0xbd,0x63,0x20,0xc2,\n\t0x4d,0x3b,0x51,0xaa,0x62,0x1f,0x06,0xe5,0xbb,0x78,0x44,0x04,0x0c,0x5c,0xe1,0x1b,\n\t0x6b,0x9d,0x21,0x10,0xaf,0x48,0x48,0x98,0x97,0x77,0xc2,0x73,0xb4,0x98,0x64,0xcc,\n\t0x94,0x2c,0x29,0x28,0x45,0x36,0xd1,0xc5,0xd0,0x2f,0x97,0x27,0x92,0x65,0x22,0xbb,\n\t0x63,0x79,0xea,0xf5,0xff,0x77,0x0f,0x4b,0x56,0x8a,0x9f,0xad,0x1a,0x97,0x67,0x39,\n\t0x69,0xb8,0x4c,0x6c,0xc2,0x56,0xc5,0x7a,0xa8,0x14,0x5a,0x24,0x7a,0xa4,0x6e,0x55,\n\t0xb2,0x86,0x1d,0xf4,0x62,0x5a,0x2d,0x87,0x6d,0xde,0x99,0x78,0x2d,0xef,0xd7,0xdc}};\n#endif // SHA384\n#if ALG_SHA512_VALUE == DEFAULT_TEST_HASH\nconst TPM2B_RSA_TEST_VALUE    c_OaepKvt = {RSA_TEST_KEY_SIZE, {\n\t0x48,0x45,0xa7,0x70,0xb2,0x41,0xb7,0x48,0x5e,0x79,0x8c,0xdf,0x1c,0xc6,0x7e,0xbb,\n\t0x11,0x80,0x82,0x52,0xbf,0x40,0x3d,0x90,0x03,0x6e,0x20,0x3a,0xb9,0x65,0xc8,0x51,\n\t0x4c,0xbd,0x9c,0xa9,0x43,0x89,0xd0,0x57,0x0c,0xa3,0x69,0x22,0x7e,0x82,0x2a,0x1c,\n\t0x1d,0x5a,0x80,0x84,0x81,0xbb,0x5e,0x5e,0xd0,0xc1,0x66,0x9a,0xac,0x00,0xba,0x14,\n\t0xa2,0xe9,0xd0,0x3a,0x89,0x5a,0x63,0xe2,0xec,0x92,0x05,0xf4,0x47,0x66,0x12,0x7f,\n\t0xdb,0xa7,0x3c,0x5b,0x67,0xe1,0x55,0xca,0x0a,0x27,0xbf,0x39,0x89,0x11,0x05,0xba,\n\t0x9b,0x5a,0x9b,0x65,0x44,0xad,0x78,0xcf,0x8f,0x94,0xf6,0x9a,0xb4,0x52,0x39,0x0e,\n\t0x00,0xba,0xbc,0xe0,0xbd,0x6f,0x81,0x2d,0x76,0x42,0x66,0x70,0x07,0x77,0xbf,0x09,\n\t0x88,0x2a,0x0c,0xb1,0x56,0x3e,0xee,0xfd,0xdc,0xb6,0x3c,0x0d,0xc5,0xa4,0x0d,0x10,\n\t0x32,0x80,0x3e,0x1e,0xfe,0x36,0x8f,0xb5,0x42,0xc1,0x21,0x7b,0xdf,0xdf,0x4a,0xd2,\n\t0x68,0x0c,0x01,0x9f,0x4a,0xfd,0xd4,0xec,0xf7,0x49,0x06,0xab,0xed,0xc6,0xd5,0x1b,\n\t0x63,0x76,0x38,0xc8,0x6c,0xc7,0x4f,0xcb,0x29,0x8a,0x0e,0x6f,0x33,0xaf,0x69,0x31,\n\t0x8e,0xa7,0xdd,0x9a,0x36,0xde,0x9b,0xf1,0x0b,0xfb,0x20,0xa0,0x6d,0x33,0x31,0xc9,\n\t0x9e,0xb4,0x2e,0xc5,0x40,0x0e,0x60,0x71,0x36,0x75,0x05,0xf9,0x37,0xe0,0xca,0x8e,\n\t0x8f,0x56,0xe0,0xea,0x9b,0xeb,0x17,0xf3,0xca,0x40,0xc3,0x48,0x01,0xba,0xdc,0xc6,\n\t0x4b,0x2b,0x5b,0x7b,0x5c,0x81,0xa6,0xbb,0xc7,0x43,0xc0,0xbe,0xc0,0x30,0x7b,0x55}};\nconst TPM2B_RSA_TEST_VALUE    c_RsaesKvt = {RSA_TEST_KEY_SIZE, {\n\t0x74,0x83,0xfa,0x52,0x65,0x50,0x68,0xd0,0x82,0x05,0x72,0x70,0x78,0x1c,0xac,0x10,\n\t0x23,0xc5,0x07,0xf8,0x93,0xd2,0xeb,0x65,0x87,0xbb,0x47,0xc2,0xfb,0x30,0x9e,0x61,\n\t0x4c,0xac,0x04,0x57,0x5a,0x7c,0xeb,0x29,0x08,0x84,0x86,0x89,0x1e,0x8f,0x07,0x32,\n\t0xa3,0x8b,0x70,0xe7,0xa2,0x9f,0x9c,0x42,0x71,0x3d,0x23,0x59,0x82,0x5e,0x8a,0xde,\n\t0xd6,0xfb,0xd8,0xc5,0x8b,0xc0,0xdb,0x10,0x38,0x87,0xd3,0xbf,0x04,0xb0,0x66,0xb9,\n\t0x85,0x81,0x54,0x4c,0x69,0xdc,0xba,0x78,0xf3,0x4a,0xdb,0x25,0xa2,0xf2,0x34,0x55,\n\t0xdd,0xaa,0xa5,0xc4,0xed,0x55,0x06,0x0e,0x2a,0x30,0x77,0xab,0x82,0x79,0xf0,0xcd,\n\t0x9d,0x6f,0x09,0xa0,0xc8,0x82,0xc9,0xe0,0x61,0xda,0x40,0xcd,0x17,0x59,0xc0,0xef,\n\t0x95,0x6d,0xa3,0x6d,0x1c,0x2b,0xee,0x24,0xef,0xd8,0x4a,0x55,0x6c,0xd6,0x26,0x42,\n\t0x32,0x17,0xfd,0x6a,0xb3,0x4f,0xde,0x07,0x2f,0x10,0xd4,0xac,0x14,0xea,0x89,0x68,\n\t0xcc,0xd3,0x07,0xb7,0xcf,0xba,0x39,0x20,0x63,0x20,0x7b,0x44,0x8b,0x48,0x60,0x5d,\n\t0x3a,0x2a,0x0a,0xe9,0x68,0xab,0x15,0x46,0x27,0x64,0xb5,0x82,0x06,0x29,0xe7,0x25,\n\t0xca,0x46,0x48,0x6e,0x2a,0x34,0x57,0x4b,0x81,0x75,0xae,0xb6,0xfd,0x6f,0x51,0x5f,\n\t0x04,0x59,0xc7,0x15,0x1f,0xe0,0x68,0xf7,0x36,0x2d,0xdf,0xc8,0x9d,0x05,0x27,0x2d,\n\t0x3f,0x2b,0x59,0x5d,0xcb,0xf3,0xc4,0x92,0x6e,0x00,0xa8,0x8d,0xd0,0x69,0xe5,0x59,\n\t0xda,0xba,0x4f,0x38,0xf5,0xa0,0x8b,0xf1,0x73,0xe9,0x0d,0xee,0x64,0xe5,0xa2,0xd8}};\nconst TPM2B_RSA_TEST_VALUE    c_RsapssKvt = {RSA_TEST_KEY_SIZE, {\n\t0x1b,0xca,0x8b,0x18,0x15,0x3b,0x95,0x5b,0x0a,0x89,0x10,0x03,0x7f,0x7c,0xa0,0xc9,\n\t0x66,0x57,0x86,0x6a,0xc9,0xeb,0x82,0x71,0xf3,0x8d,0x6f,0xa9,0xa4,0x2d,0xd0,0x22,\n\t0xdf,0xe9,0xc6,0x71,0x5b,0xf4,0x27,0x38,0x5b,0x2c,0x8a,0x54,0xcc,0x85,0x11,0x69,\n\t0x6d,0x6f,0x42,0xe7,0x22,0xcb,0xd6,0xad,0x1a,0xc5,0xab,0x6a,0xa5,0xfc,0xa5,0x70,\n\t0x72,0x4a,0x62,0x25,0xd0,0xa2,0x16,0x61,0xab,0xac,0x31,0xa0,0x46,0x24,0x4f,0xdd,\n\t0x9a,0x36,0x55,0xb6,0x00,0x9e,0x23,0x50,0x0d,0x53,0x01,0xb3,0x46,0x56,0xb2,0x1d,\n\t0x33,0x5b,0xca,0x41,0x7f,0x65,0x7e,0x00,0x5c,0x12,0xff,0x0a,0x70,0x5d,0x8c,0x69,\n\t0x4a,0x02,0xee,0x72,0x30,0xa7,0x5c,0xa4,0xbb,0xbe,0x03,0x0c,0xe4,0x5f,0x33,0xb6,\n\t0x78,0x91,0x9d,0xd8,0xec,0x34,0x03,0x2e,0x63,0x32,0xc7,0x2a,0x36,0x50,0xd5,0x8b,\n\t0x0e,0x7f,0x54,0x4e,0xf4,0x29,0x11,0x1b,0xcd,0x0f,0x37,0xa5,0xbc,0x61,0x83,0x50,\n\t0xfa,0x18,0x75,0xd9,0xfe,0xa7,0xe8,0x9b,0xc1,0x4f,0x96,0x37,0x81,0x71,0xdf,0x71,\n\t0x8b,0x89,0x81,0xf4,0x95,0xb5,0x29,0x66,0x41,0x0c,0x73,0xd7,0x0b,0x21,0xb4,0xfb,\n\t0xf9,0x63,0x2f,0xe9,0x7b,0x38,0xaa,0x20,0xc3,0x96,0xcc,0xb7,0xb2,0x24,0xa1,0xe0,\n\t0x59,0x9c,0x10,0x9e,0x5a,0xf7,0xe3,0x02,0xe6,0x23,0xe2,0x44,0x21,0x3f,0x6e,0x5e,\n\t0x79,0xb2,0x93,0x7d,0xce,0xed,0xe2,0xe1,0xab,0x98,0x07,0xa7,0xbd,0xbc,0xd8,0xf7,\n\t0x06,0xeb,0xc5,0xa6,0x37,0x18,0x11,0x88,0xf7,0x63,0x39,0xb9,0x57,0x29,0xdc,0x03}};\nconst TPM2B_RSA_TEST_VALUE    c_RsassaKvt = {RSA_TEST_KEY_SIZE, {\n\t0x05,0x55,0x00,0x62,0x01,0xc6,0x04,0x31,0x55,0x73,0x3f,0x2a,0xf9,0xd4,0x0f,0xc1,\n\t0x2b,0xeb,0xd8,0xc8,0xdb,0xb2,0xab,0x6c,0x26,0xde,0x2d,0x89,0xc2,0x2d,0x36,0x62,\n\t0xc8,0x22,0x5d,0x58,0x03,0xb1,0x46,0x14,0xa5,0xd4,0xbc,0x25,0x6b,0x7f,0x8f,0x14,\n\t0x7e,0x03,0x2f,0x3d,0xb8,0x39,0xa5,0x79,0x13,0x7e,0x22,0x2a,0xb9,0x3e,0x8f,0xaa,\n\t0x01,0x7c,0x03,0x12,0x21,0x6c,0x2a,0xb4,0x39,0x98,0x6d,0xff,0x08,0x6c,0x59,0x2d,\n\t0xdc,0xc6,0xf1,0x77,0x62,0x10,0xa6,0xcc,0xe2,0x71,0x8e,0x97,0x00,0x87,0x5b,0x0e,\n\t0x20,0x00,0x3f,0x18,0x63,0x83,0xf0,0xe4,0x0a,0x64,0x8c,0xe9,0x8c,0x91,0xe7,0x89,\n\t0x04,0x64,0x2c,0x8b,0x41,0xc8,0xac,0xf6,0x5a,0x75,0xe6,0xa5,0x76,0x43,0xcb,0xa5,\n\t0x33,0x8b,0x07,0xc9,0x73,0x0f,0x45,0xa4,0xc3,0xac,0xc1,0xc3,0xe6,0xe7,0x21,0x66,\n\t0x1c,0xba,0xbf,0xea,0x3e,0x39,0xfa,0xb2,0xe2,0x8f,0xfe,0x9c,0xb4,0x85,0x89,0x33,\n\t0x2a,0x0c,0xc8,0x5d,0x58,0xe1,0x89,0x12,0xe9,0x4d,0x42,0xb3,0x1f,0x99,0x0c,0x3e,\n\t0xd8,0xb2,0xeb,0xf5,0x88,0xfb,0xe1,0x4b,0x8e,0xdc,0xd3,0xa8,0xda,0xbe,0x04,0x45,\n\t0xbf,0x56,0xc6,0x54,0x70,0x00,0xb8,0x66,0x46,0x3a,0xa3,0x1e,0xb6,0xeb,0x1a,0xa0,\n\t0x0b,0xd3,0x9a,0x9a,0x52,0xda,0x60,0x69,0xb7,0xef,0x93,0x47,0x38,0xab,0x1a,0xa0,\n\t0x22,0x6e,0x76,0x06,0xb6,0x74,0xaf,0x74,0x8f,0x51,0xc0,0x89,0x5a,0x4b,0xbe,0x6a,\n\t0x91,0x18,0x25,0x7d,0xa6,0x77,0xe6,0xfd,0xc2,0x62,0x36,0x07,0xc6,0xef,0x79,0xc9}};\n#endif // SHA512\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SelfTest.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tStructure definitions for the self-test\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the structure definitions for the self-test. It also contains\n// macros for use when the self-test is implemented.\n#ifndef _SELF_TEST_H_\n#define _SELF_TEST_H_\n\n//** Defines\n\n// Was typing this a lot\n#define SELF_TEST_FAILURE FAIL(FATAL_ERROR_SELF_TEST)\n\n// Use the definition of key sizes to set algorithm values for key size.\n#define AES_ENTRIES      (AES_128 + AES_192 + AES_256)\n#define SM4_ENTRIES      (SM4_128)\n#define CAMELLIA_ENTRIES (CAMELLIA_128 + CAMELLIA_192 + CAMELLIA_256)\n\n#define NUM_SYMS (AES_ENTRIES + SM4_ENTRIES + CAMELLIA_ENTRIES)\n\ntypedef UINT32 SYM_INDEX;\n\n// These two defines deal with the fact that the TPM_ALG_ID table does not delimit\n// the symmetric mode values with a SYM_MODE_FIRST and SYM_MODE_LAST\n#define SYM_MODE_FIRST ALG_CTR_VALUE\n#define SYM_MODE_LAST  ALG_ECB_VALUE\n\n#define NUM_SYM_MODES (SYM_MODE_LAST - SYM_MODE_FIRST + 1)\n\n// Define a type to hold a bit vector for the modes.\n#if NUM_SYM_MODES <= 0\n#  error \"No symmetric modes implemented\"\n#elif NUM_SYM_MODES <= 8\ntypedef BYTE SYM_MODES;\n#elif NUM_SYM_MODES <= 16\ntypedef UINT16 SYM_MODES;\n#elif NUM_SYM_MODES <= 32\ntypedef UINT32 SYM_MODES;\n#else\n#  error \"Too many symmetric modes\"\n#endif\n\ntypedef struct SYMMETRIC_TEST_VECTOR\n{\n    const TPM_ALG_ID alg;                     // the algorithm\n    const UINT16     keyBits;                 // bits in the key\n    const BYTE*      key;                     // The test key\n    const UINT32     ivSize;                  // block size of the algorithm\n    const UINT32     dataInOutSize;           // size  to encrypt/decrypt\n    const BYTE*      dataIn;                  // data to encrypt\n    const BYTE*      dataOut[NUM_SYM_MODES];  // data to decrypt\n} SYMMETRIC_TEST_VECTOR;\n\n#if ALG_SHA512\n#  define DEFAULT_TEST_HASH            ALG_SHA512_VALUE\n#  define DEFAULT_TEST_DIGEST_SIZE     SHA512_DIGEST_SIZE\n#  define DEFAULT_TEST_HASH_BLOCK_SIZE SHA512_BLOCK_SIZE\n#elif ALG_SHA384\n#  define DEFAULT_TEST_HASH            ALG_SHA384_VALUE\n#  define DEFAULT_TEST_DIGEST_SIZE     SHA384_DIGEST_SIZE\n#  define DEFAULT_TEST_HASH_BLOCK_SIZE SHA384_BLOCK_SIZE\n#elif ALG_SHA256\n#  define DEFAULT_TEST_HASH            ALG_SHA256_VALUE\n#  define DEFAULT_TEST_DIGEST_SIZE     SHA256_DIGEST_SIZE\n#  define DEFAULT_TEST_HASH_BLOCK_SIZE SHA256_BLOCK_SIZE\n#elif ALG_SHA1\n#  define DEFAULT_TEST_HASH            ALG_SHA1_VALUE\n#  define DEFAULT_TEST_DIGEST_SIZE     SHA1_DIGEST_SIZE\n#  define DEFAULT_TEST_HASH_BLOCK_SIZE SHA1_BLOCK_SIZE\n#endif\n\n#endif  // _SELF_TEST_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SelfTest_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: SelfTest_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef SELFTEST_FP_H\n#define SELFTEST_FP_H\n\ntypedef struct{\n    TPMI_YES_NO\tfullTest;\n} SelfTest_In;     \n\n#define RC_SelfTest_fullTest \t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_SelfTest(\n\t      SelfTest_In     *in             // IN: input parameter list\n\t      );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SequenceComplete_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: SequenceComplete_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef SEQUENCECOMPLETE_FP_H\n#define SEQUENCECOMPLETE_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tsequenceHandle;\n    TPM2B_MAX_BUFFER\tbuffer;\n    TPMI_RH_HIERARCHY\thierarchy;\n} SequenceComplete_In;\n\n#define RC_SequenceComplete_sequenceHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_SequenceComplete_buffer\t\t(TPM_RC_P + TPM_RC_1)\n#define RC_SequenceComplete_hierarchy\t\t(TPM_RC_P + TPM_RC_2)\n\n\ntypedef struct {\n    TPM2B_DIGEST\tresult;\n    TPMT_TK_HASHCHECK\tvalidation;\n} SequenceComplete_Out;\n\n\n\nTPM_RC\nTPM2_SequenceComplete(\n\t\t      SequenceComplete_In     *in,            // IN: input parameter list\n\t\t      SequenceComplete_Out    *out            // OUT: output parameter list\n\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SequenceUpdate_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: SequenceUpdate_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef SEQUENCEUPDATE_FP_H\n#define SEQUENCEUPDATE_FP_H\n\n\ntypedef struct {\n    TPMI_DH_OBJECT\tsequenceHandle;\n    TPM2B_MAX_BUFFER\tbuffer;\n} SequenceUpdate_In;\n\n#define RC_SequenceUpdate_sequenceHandle \t(TPM_RC_P + TPM_RC_1)\n#define RC_SequenceUpdate_buffer\t\t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_SequenceUpdate(\n\t\t    SequenceUpdate_In   *in             // IN: input parameter list\n\t\t    );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SessionProcess_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef SESSIONPROCESS_FP_H\n#define SESSIONPROCESS_FP_H\n\nBOOL\nIsDAExempted(\n\t     TPM_HANDLE       handle         // IN: entity handle\n\t     );\nvoid\nClearCpRpHashes(\n\t\tCOMMAND         *command\n\t\t);\nBOOL\nCompareNameHash(\n\t\tCOMMAND         *command,       // IN: main parsing structure\n\t\tSESSION         *session        // IN: session structure with nameHash\n\t\t);\nBOOL CompareParametersHash(COMMAND* command,  // IN: main parsing structure\n\t\t\t   SESSION* session   // IN: session structure with pHash\n\t\t\t   );\nTPM_RC\nParseSessionBuffer(\n\t\t   COMMAND         *command        // IN: the structure that contains\n\t\t   );\nTPM_RC\nCheckAuthNoSession(\n\t\t   COMMAND         *command        // IN: command parsing structure\n\t\t   );\nTPM_RC\nBuildResponseSession(\n\t\t     COMMAND         *command        // IN: structure that has relevant command\n\t\t     //     information\n\t\t     );\nvoid\nSessionRemoveAssociationToHandle(\n\t\t\t\t TPM_HANDLE       handle\n\t\t\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Session_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef SESSION_FP_H\n#define SESSION_FP_H\n\nBOOL\nSessionStartup(\n\t       STARTUP_TYPE     type\n\t       );\nBOOL\nSessionIsLoaded(\n\t\tTPM_HANDLE       handle         // IN: session handle\n\t\t);\nBOOL\nSessionIsSaved(\n\t       TPM_HANDLE       handle         // IN: session handle\n\t       );\nBOOL\nSequenceNumberForSavedContextIsValid(\n\t\t\t\t      TPMS_CONTEXT    *context        // IN: pointer to a context structure to be\n\t\t\t\t      //     validated\n\t\t\t\t      );\nBOOL\nSessionPCRValueIsCurrent(\n\t\t\t SESSION         *session        // IN: session structure\n\t\t\t );\nSESSION *\nSessionGet(\n\t   TPM_HANDLE       handle         // IN: session handle\n\t   );\nTPM_RC\nSessionCreate(\n\t      TPM_SE           sessionType,   // IN: the session type\n\t      TPMI_ALG_HASH    authHash,      // IN: the hash algorithm\n\t      TPM2B_NONCE     *nonceCaller,   // IN: initial nonceCaller\n\t      TPMT_SYM_DEF    *symmetric,     // IN: the symmetric algorithm\n\t      TPMI_DH_ENTITY   bind,          // IN: the bind object\n\t      TPM2B_DATA      *seed,          // IN: seed data\n\t      TPM_HANDLE      *sessionHandle, // OUT: the session handle\n\t      TPM2B_NONCE     *nonceTpm       // OUT: the session nonce\n\t      );\nTPM_RC\nSessionContextSave(\n\t\t   TPM_HANDLE           handle,        // IN: session handle\n\t\t   CONTEXT_COUNTER     *contextID      // OUT: assigned contextID\n\t\t   );\nTPM_RC\nSessionContextLoad(\n\t\t   SESSION_BUF     *session,       // IN: session structure from saved context\n\t\t   TPM_HANDLE      *handle         // IN/OUT: session handle\n\t\t   );\nvoid\nSessionFlush(\n\t     TPM_HANDLE       handle         // IN: loaded or saved session handle\n\t     );\nvoid\nSessionComputeBoundEntity(\n\t\t\t  TPMI_DH_ENTITY       entityHandle,  // IN: handle of entity\n\t\t\t  TPM2B_NAME          *bind           // OUT: binding value\n\t\t\t  );\nvoid\nSessionSetStartTime(\n\t\t    SESSION         *session        // IN: the session to update\n\t\t    );\nvoid\nSessionResetPolicyData(\n\t\t       SESSION         *session        // IN: the session to reset\n\t\t       );\nTPMI_YES_NO\nSessionCapGetLoaded(\n\t\t    TPMI_SH_POLICY   handle,        // IN: start handle\n\t\t    UINT32           count,         // IN: count of returned handles\n\t\t    TPML_HANDLE     *handleList     // OUT: list of handle\n\t\t    );\nBOOL SessionCapGetOneLoaded(TPMI_SH_POLICY handle  // IN: handle\n\t\t\t    );\nTPMI_YES_NO\nSessionCapGetSaved(\n\t\t   TPMI_SH_HMAC     handle,        // IN: start handle\n\t\t   UINT32           count,         // IN: count of returned handles\n\t\t   TPML_HANDLE     *handleList     // OUT: list of handle\n\t\t   );\nBOOL SessionCapGetOneSaved(TPMI_SH_HMAC handle  // IN: handle\n\t\t\t   );\n\nUINT32\nSessionCapGetLoadedNumber(\n\t\t\t  void\n\t\t\t  );\nUINT32\nSessionCapGetLoadedAvail(\n\t\t\t void\n\t\t\t );\nUINT32\nSessionCapGetActiveNumber(\n\t\t\t  void\n\t\t\t  );\nUINT32\nSessionCapGetActiveAvail(\n\t\t\t void\n\t\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SetAlgorithmSet_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: SetAlgorithmSet_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef SETALGORITHMSET_FP_H\n#define SETALGORITHMSET_FP_H\n\ntypedef struct {\n    TPMI_RH_PLATFORM\tauthHandle;\n    UINT32\t\talgorithmSet;\n} SetAlgorithmSet_In;\n\n#define RC_SetAlgorithmSet_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_SetAlgorithmSet_algorithmSet\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_SetAlgorithmSet(\n\t\t     SetAlgorithmSet_In  *in             // IN: input parameter list\n\t\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SetCapability_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#if CC_SetCapability  // Command must be enabled\n\n#  ifndef SETCAPABILITY_FP_H\n#    define SETCAPABILITY_FP_H\n\n// Input structure definition\ntypedef struct\n{\n    TPMI_RH_HIERARCHY authHandle;\n    TPM2B_SET_CAPABILITY_DATA setCapabilityData;\n} SetCapability_In;\n\n// Response code modifiers\n#    define SetCapability_authHandle (TPM_RC_H + TPM_RC_1)\n#    define SetCapability_setCapabilityData (TPM_RC_P + TPM_RC_1)\n\n// Function prototype\nTPM_RC TPM2_SetCapability(SetCapability_In* in);\n\n#  endif  // SETCAPABILITY_FP_H\n#endif    // CC_SetCapability\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SetCommandCodeAuditStatus_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t$Id: SetCommandCodeAuditStatus_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef SETCOMMANDCODEAUDITSTATUS_FP_H\n#define SETCOMMANDCODEAUDITSTATUS_FP_H\n\ntypedef struct {\n    TPMI_RH_PROVISION\tauth;\n    TPMI_ALG_HASH\tauditAlg;\n    TPML_CC\t\tsetList;\n    TPML_CC\t\tclearList;\n} SetCommandCodeAuditStatus_In;\n\n#define RC_SetCommandCodeAuditStatus_auth\t(TPM_RC_H + TPM_RC_1)\n#define RC_SetCommandCodeAuditStatus_auditAlg \t(TPM_RC_P + TPM_RC_1)\n#define RC_SetCommandCodeAuditStatus_setList\t(TPM_RC_P + TPM_RC_2)\n#define RC_SetCommandCodeAuditStatus_clearList\t(TPM_RC_P + TPM_RC_3)\n\nTPM_RC\nTPM2_SetCommandCodeAuditStatus(\n\t\t\t       SetCommandCodeAuditStatus_In    *in             // IN: input parameter list\n\t\t\t       );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SetPrimaryPolicy_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t \t\tTPM2_SetPrimaryPolicy Command Header\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: SetPrimaryPolicy_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef SETPRIMARYPOLICY_FP_H\n#define SETPRIMARYPOLICY_FP_H\n\ntypedef struct {\n    TPMI_RH_HIERARCHY_POLICY\tauthHandle;\n    TPM2B_DIGEST\t\tauthPolicy;\n    TPMI_ALG_HASH\t\thashAlg;\n} SetPrimaryPolicy_In;\n\n#define RC_SetPrimaryPolicy_authHandle\t(TPM_RC_H + TPM_RC_1)\n#define RC_SetPrimaryPolicy_authPolicy \t(TPM_RC_P + TPM_RC_1)\n#define RC_SetPrimaryPolicy_hashAlg\t(TPM_RC_P + TPM_RC_2)\n\nTPM_RC\nTPM2_SetPrimaryPolicy(\n\t\t      SetPrimaryPolicy_In     *in             // IN: input parameter list\n\t\t      );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Shutdown_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Shutdown_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef SHUTDOWN_FP_H\n#define SHUTDOWN_FP_H\n\ntypedef struct{\n    TPM_SU shutdownType;\n} Shutdown_In;\n\n#define RC_Shutdown_shutdownType  (TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_Shutdown(\n\t      Shutdown_In     *in             // IN: input parameter list\n\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Sign_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Sign_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef SIGN_FP_H\n#define SIGN_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tkeyHandle;\n    TPM2B_DIGEST\tdigest;\n    TPMT_SIG_SCHEME\tinScheme;\n    TPMT_TK_HASHCHECK\tvalidation;\n} Sign_In;\n\n#define RC_Sign_keyHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_Sign_digest \t\t(TPM_RC_P + TPM_RC_1)\n#define RC_Sign_inScheme \t(TPM_RC_P + TPM_RC_2)\n#define RC_Sign_validation \t(TPM_RC_P + TPM_RC_3)\n\ntypedef struct {\n    TPMT_SIGNATURE\tsignature;\n} Sign_Out;\n\nTPM_RC\nTPM2_Sign(\n\t  Sign_In         *in,            // IN: input parameter list\n\t  Sign_Out        *out            // OUT: output parameter list\n\t  );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Simulator_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar  4, 2020  Time: 02:36:45PM\n */\n\n#ifndef _SIMULATOR_FP_H_\n#define _SIMULATOR_FP_H_\n\n//** From TcpServer.c\n\n#ifdef _MSC_VER\n#elif defined(__unix__) || defined(__APPLE__)\n#endif\n\n//*** PlatformServer()\n// This function processes incoming platform requests.\nbool PlatformServer(SOCKET s);\n\n//*** PlatformSvcRoutine()\n// This function is called to set up the socket interfaces to listen for\n// commands.\n// int  PlatformSvcRoutine(LPVOID port);\n\n//*** PlatformSignalService()\n// This function starts a new thread waiting for platform signals.\n// Platform signals are processed one at a time in the order in which they are\n// received.\n// If PickPorts is true, the server finds the next available port if the specified\n// port was unavailable.\nint PlatformSignalService(int *PortNumberPlatform);\n\n//*** RegularCommandService()\n// This function services regular commands.\n// If PickPorts is true, the server finds the next available port if the specified\n// port was unavailable.\nint RegularCommandService(int *PortNumber);\n\n//*** StartTcpServer()\n// This is the main entry-point to the TCP server.  The server listens on the port\n// specified.\n// If PickPorts is true, the server finds the next available port if the specified\n// port was unavailable.\n//\n// Note that there is no way to specify the network interface in this implementation.\nint StartTcpServer(int *PortNumber, int *PortNumberPlatform);\n\n\n//*** ReadBytes()\n// This function reads the indicated number of bytes ('NumBytes') into buffer\n// from the indicated socket.\n// bool ReadBytes(SOCKET s, char* buffer, int NumBytes);\nbool ReadBytes(uintptr_t *s, char* buffer, int NumBytes);\n\n//*** WriteBytes()\n// This function will send the indicated number of bytes ('NumBytes') to the\n// indicated socket\n// bool WriteBytes(SOCKET s, char* buffer, int NumBytes);\nbool WriteBytes(uintptr_t *s, char* buffer, int NumBytes);\n\n//*** WriteUINT32()\n// Send 4 byte integer\n// bool WriteUINT32(SOCKET s, uint32_t val);\nbool WriteUINT32(uintptr_t *s, uint32_t val);\n\n//*** ReadUINT32()\n// Function to read 4 byte integer from socket.\nbool ReadUINT32(SOCKET s, uint32_t* val);\n\n//*** ReadVarBytes()\n// Get a uint32-length-prepended binary array.  Note that the 4-byte length is\n// in network byte order (big-endian).\n// bool ReadVarBytes(SOCKET s, char* buffer, uint32_t* BytesReceived, int MaxLen);\nbool ReadVarBytes(uintptr_t *s, char* buffer, uint32_t* BytesReceived, int MaxLen);\n\n//*** WriteVarBytes()\n// Send a UINT32-length-prepended binary array.  Note that the 4-byte length is\n// in network byte order (big-endian).\n// bool WriteVarBytes(SOCKET s, char* buffer, int BytesToSend);\nbool WriteVarBytes(uintptr_t *s, char* buffer, int BytesToSend);\n\n//*** TpmServer()\n// Processing incoming TPM command requests using the protocol / interface\n// defined above.\nbool TpmServer(SOCKET s);\n\n//** From TPMCmdp.c\n\n#ifdef _MSC_VER\n#elif defined(__unix__) || defined(__APPLE__)\n#endif\n\n//*** Signal_PowerOn()\n// This function processes a power-on indication. Among other things, it\n// calls the _TPM_Init() handler.\nvoid _rpc__Signal_PowerOn(bool isReset);\n\n//*** Signal_Restart()\n// This function processes the clock restart indication. All it does is call\n// the platform function.\nvoid _rpc__Signal_Restart(void);\n\n//***Signal_PowerOff()\n// This function processes the power off indication. Its primary function is\n// to set a flag indicating that the next power on indication should cause\n// _TPM_Init() to be called.\nvoid _rpc__Signal_PowerOff(void);\n\n//*** _rpc__ForceFailureMode()\n// This function is used to debug the Failure Mode logic of the TPM. It will set\n// a flag in the TPM code such that the next call to TPM2_SelfTest() will result\n// in a failure, putting the TPM into Failure Mode.\nvoid _rpc__ForceFailureMode(void);\n\n//*** _rpc__Signal_PhysicalPresenceOn()\n// This function is called to simulate activation of the physical presence \"pin\".\nvoid _rpc__Signal_PhysicalPresenceOn(void);\n\n//*** _rpc__Signal_PhysicalPresenceOff()\n// This function is called to simulate deactivation of the physical presence \"pin\".\nvoid _rpc__Signal_PhysicalPresenceOff(void);\n\n//*** _rpc__Signal_Hash_Start()\n// This function is called to simulate a _TPM_Hash_Start event. It will call\n//\nvoid _rpc__Signal_Hash_Start(void);\n\n//*** _rpc__Signal_Hash_Data()\n// This function is called to simulate a _TPM_Hash_Data event.\nvoid _rpc__Signal_Hash_Data(_IN_BUFFER input);\n\n//*** _rpc__Signal_HashEnd()\n// This function is called to simulate a _TPM_Hash_End event.\nvoid _rpc__Signal_HashEnd(void);\n\n//*** _rpc__Send_Command()\n// This is the interface to the TPM code.\n//  Return Type: void\nvoid _rpc__Send_Command(\n\t\t\tunsigned char locality, _IN_BUFFER request, _OUT_BUFFER* response);\n\n//*** _rpc__Signal_CancelOn()\n// This function is used to turn on the indication to cancel a command in process.\n// An executing command is not interrupted. The command code may periodically check\n// this indication to see if it should abort the current command processing and\n// returned TPM_RC_CANCELLED.\nvoid _rpc__Signal_CancelOn(void);\n\n//*** _rpc__Signal_CancelOff()\n// This function is used to turn off the indication to cancel a command in process.\nvoid _rpc__Signal_CancelOff(void);\n\n//*** _rpc__Signal_NvOn()\n// In a system where the NV memory used by the TPM is not within the TPM, the\n// NV may not always be available. This function turns on the indicator that\n// indicates that NV is available.\nvoid _rpc__Signal_NvOn(void);\n\n//*** _rpc__Signal_NvOff()\n// This function is used to set the indication that NV memory is no\n// longer available.\nvoid _rpc__Signal_NvOff(void);\n\n//*** _rpc__RsaKeyCacheControl()\n// This function is used to enable/disable the use of the RSA key cache during\n// simulation.\nvoid _rpc__RsaKeyCacheControl(int state);\n\n//*** _rpc__ACT_GetSignaled()\n// This function is used to count the ACT second tick.\nbool _rpc__ACT_GetSignaled(uint32_t actHandle);\n\n//*** _rpc__SetTpmFirmwareHash()\n// This function is used to modify the firmware's hash during simulation.\nvoid _rpc__SetTpmFirmwareHash(uint32_t hash);\n\n//*** _rpc__SetTpmFirmwareSvn()\n// This function is used to modify the firmware's SVN during simulation.\nvoid _rpc__SetTpmFirmwareSvn(uint16_t svn);\n\n//** From TPMCmds.c\n\n//*** main()\n// This is the main entry point for the simulator.\n// It registers the interface and starts listening for clients\nint main(int argc, char* argv[]);\n\n#endif  // _SIMULATOR_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/StartAuthSession_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: StartAuthSession_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef STARTAUTHSESSION_FP_H\n#define STARTAUTHSESSION_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\ttpmKey;\n    TPMI_DH_ENTITY\t\tbind;\n    TPM2B_NONCE\t\t\tnonceCaller;\n    TPM2B_ENCRYPTED_SECRET\tencryptedSalt;\n    TPM_SE\t\t\tsessionType;\n    TPMT_SYM_DEF\t\tsymmetric;\n    TPMI_ALG_HASH\t\tauthHash;\n} StartAuthSession_In;\n\ntypedef struct {\n    TPMI_SH_AUTH_SESSION\tsessionHandle;\n    TPM2B_NONCE\t\t\tnonceTPM;\n} StartAuthSession_Out;  \n\n#define RC_StartAuthSession_tpmKey \t\t(TPM_RC_H + TPM_RC_1)\n#define RC_StartAuthSession_bind \t\t(TPM_RC_H + TPM_RC_2)\n#define RC_StartAuthSession_nonceCaller \t(TPM_RC_P + TPM_RC_1)\n#define RC_StartAuthSession_encryptedSalt \t(TPM_RC_P + TPM_RC_2)\n#define RC_StartAuthSession_sessionType \t(TPM_RC_P + TPM_RC_3)\n#define RC_StartAuthSession_symmetric \t\t(TPM_RC_P + TPM_RC_4)\n#define RC_StartAuthSession_authHash \t\t(TPM_RC_P + TPM_RC_5)\n\nTPM_RC\nTPM2_StartAuthSession(\n\t\t      StartAuthSession_In     *in,            // IN: input parameter buffer\n\t\t      StartAuthSession_Out    *out            // OUT: output parameter buffer\n\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Startup_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Startup_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef STARTUP_FP_H\n#define STARTUP_FP_H\n\nvoid\n_TPM_Init(\n\t  void\n\t  );\n\n\ntypedef struct {\n    TPM_SU startupType; \n} Startup_In;\n\n#define RC_Startup_startupType \t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_Startup(\n\t     Startup_In      *in             // IN: input parameter list\n\t     );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/StirRandom_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: StirRandom_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef STIRRANDOM_FP_H\n#define STIRRANDOM_FP_H\n\ntypedef struct {\n    TPM2B_SENSITIVE_DATA\tinData;\n} StirRandom_In;\n\n#define RC_StirRandom_inData\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_StirRandom(\n\t\tStirRandom_In   *in             // IN: input parameter list\n\t\t);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SymmetricTest.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n\n// This file contains the structures and data definitions for the symmetric tests.\n// This file references the header file that contains the actual test vectors. This\n// organization was chosen so that the program that is used to generate the test\n// vector values does not have to also re-generate this data.\n#ifndef SELF_TEST_DATA\n#  error \"This file may only be included in AlgorithmTests.c\"\n#endif\n\n#ifndef _SYMMETRIC_TEST_H\n#  define _SYMMETRIC_TEST_H\n#  include \"SymmetricTestData.h\"\n\n//** Symmetric Test Structures\n\nconst SYMMETRIC_TEST_VECTOR c_symTestValues[NUM_SYMS + 1] = {\n#  if ALG_AES && AES_128\n    {TPM_ALG_AES,\n     128,\n     key_AES128,\n     16,\n     sizeof(dataIn_AES128),\n     dataIn_AES128,\n     {dataOut_AES128_CTR,\n      dataOut_AES128_OFB,\n      dataOut_AES128_CBC,\n      dataOut_AES128_CFB,\n      dataOut_AES128_ECB}},\n#  endif\n#  if ALG_AES && AES_192\n    {TPM_ALG_AES,\n     192,\n     key_AES192,\n     16,\n     sizeof(dataIn_AES192),\n     dataIn_AES192,\n     {dataOut_AES192_CTR,\n      dataOut_AES192_OFB,\n      dataOut_AES192_CBC,\n      dataOut_AES192_CFB,\n      dataOut_AES192_ECB}},\n#  endif\n#  if ALG_AES && AES_256\n    {TPM_ALG_AES,\n     256,\n     key_AES256,\n     16,\n     sizeof(dataIn_AES256),\n     dataIn_AES256,\n     {dataOut_AES256_CTR,\n      dataOut_AES256_OFB,\n      dataOut_AES256_CBC,\n      dataOut_AES256_CFB,\n      dataOut_AES256_ECB}},\n#  endif\n    // There are no SM4 test values yet so...\n#  if ALG_SM4 && SM4_128 && 0\n    {TPM_ALG_SM4,\n     128,\n     key_SM4128,\n     16,\n     sizeof(dataIn_SM4128),\n     dataIn_SM4128,\n     {dataOut_SM4128_CTR,\n      dataOut_SM4128_OFB,\n      dataOut_SM4128_CBC,\n      dataOut_SM4128_CFB,\n      dataOut_AES128_ECB}},\n#  endif\n    {0}};\n\n#endif  // _SYMMETRIC_TEST_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/SymmetricTestData.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t Vector for testing Either Encrypt or Decrypt    \t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This is a vector for testing either encrypt or decrypt. The premise for decrypt\n// is that the IV for decryption is the same as the IV for encryption. However,\n// the ivOut value may be different for encryption and decryption. We will encrypt\n// at least two blocks. This means that the chaining value will be used for each\n// of the schemes (if any) and that implicitly checks that the chaining value\n// is handled properly.\n\n#if AES_128\n\nconst BYTE key_AES128[]         = {0x2b,\n\t\t\t\t   0x7e,\n\t\t\t\t   0x15,\n\t\t\t\t   0x16,\n\t\t\t\t   0x28,\n\t\t\t\t   0xae,\n\t\t\t\t   0xd2,\n\t\t\t\t   0xa6,\n\t\t\t\t   0xab,\n\t\t\t\t   0xf7,\n\t\t\t\t   0x15,\n\t\t\t\t   0x88,\n\t\t\t\t   0x09,\n\t\t\t\t   0xcf,\n\t\t\t\t   0x4f,\n\t\t\t\t   0x3c};\n\nconst BYTE dataIn_AES128[]      = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,\n\t\t\t\t   0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,\n\t\t\t\t   0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,\n\t\t\t\t   0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51};\n\nconst BYTE dataOut_AES128_ECB[] = {0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60,\n\t\t\t\t   0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97,\n\t\t\t\t   0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d,\n\t\t\t\t   0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf};\n\nconst BYTE dataOut_AES128_CBC[] = {0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46,\n\t\t\t\t   0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d,\n\t\t\t\t   0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee,\n\t\t\t\t   0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2};\n\nconst BYTE dataOut_AES128_CFB[] = {0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20,\n\t\t\t\t   0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a,\n\t\t\t\t   0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f,\n\t\t\t\t   0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b};\n\nconst BYTE dataOut_AES128_OFB[] = {0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20,\n\t\t\t\t   0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a,\n\t\t\t\t   0x77, 0x89, 0x50, 0x8d, 0x16, 0x91, 0x8f, 0x03,\n\t\t\t\t   0xf5, 0x3c, 0x52, 0xda, 0xc5, 0x4e, 0xd8, 0x25};\n\nconst BYTE dataOut_AES128_CTR[] = {0x87, 0x4d, 0x61, 0x91, 0xb6, 0x20, 0xe3, 0x26,\n\t\t\t\t   0x1b, 0xef, 0x68, 0x64, 0x99, 0x0d, 0xb6, 0xce,\n\t\t\t\t   0x98, 0x06, 0xf6, 0x6b, 0x79, 0x70, 0xfd, 0xff,\n\t\t\t\t   0x86, 0x17, 0x18, 0x7b, 0xb9, 0xff, 0xfd, 0xff};\n#endif\n\n#if AES_192\n\nconst BYTE key_AES192[]         = {0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,\n\t\t\t\t   0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,\n\t\t\t\t   0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b};\n\nconst BYTE dataIn_AES192[]      = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,\n\t\t\t\t   0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,\n\t\t\t\t   0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,\n\t\t\t\t   0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51};\n\nconst BYTE dataOut_AES192_ECB[] = {0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f,\n\t\t\t\t   0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc,\n\t\t\t\t   0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad,\n\t\t\t\t   0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef};\n\nconst BYTE dataOut_AES192_CBC[] = {0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d,\n\t\t\t\t   0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8,\n\t\t\t\t   0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4,\n\t\t\t\t   0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a};\n\nconst BYTE dataOut_AES192_CFB[] = {0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab,\n\t\t\t\t   0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74,\n\t\t\t\t   0x67, 0xce, 0x7f, 0x7f, 0x81, 0x17, 0x36, 0x21,\n\t\t\t\t   0x96, 0x1a, 0x2b, 0x70, 0x17, 0x1d, 0x3d, 0x7a};\n\nconst BYTE dataOut_AES192_OFB[] = {0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab,\n\t\t\t\t   0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74,\n\t\t\t\t   0xfc, 0xc2, 0x8b, 0x8d, 0x4c, 0x63, 0x83, 0x7c,\n\t\t\t\t   0x09, 0xe8, 0x17, 0x00, 0xc1, 0x10, 0x04, 0x01};\n\nconst BYTE dataOut_AES192_CTR[] = {0x1a, 0xbc, 0x93, 0x24, 0x17, 0x52, 0x1c, 0xa2,\n\t\t\t\t   0x4f, 0x2b, 0x04, 0x59, 0xfe, 0x7e, 0x6e, 0x0b,\n\t\t\t\t   0x09, 0x03, 0x39, 0xec, 0x0a, 0xa6, 0xfa, 0xef,\n\t\t\t\t   0xd5, 0xcc, 0xc2, 0xc6, 0xf4, 0xce, 0x8e, 0x94};\n#endif\n\n#if AES_256\n\nconst BYTE key_AES256[]         = {0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,\n\t\t\t\t   0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,\n\t\t\t\t   0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,\n\t\t\t\t   0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4};\n\nconst BYTE dataIn_AES256[]      = {0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,\n\t\t\t\t   0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,\n\t\t\t\t   0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,\n\t\t\t\t   0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51};\n\nconst BYTE dataOut_AES256_ECB[] = {0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c,\n\t\t\t\t   0x06, 0x4b, 0x5a, 0x7e, 0x3d, 0xb1, 0x81, 0xf8,\n\t\t\t\t   0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26,\n\t\t\t\t   0xdc, 0x5b, 0xa7, 0x4a, 0x31, 0x36, 0x28, 0x70};\n\nconst BYTE dataOut_AES256_CBC[] = {0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba,\n\t\t\t\t   0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6,\n\t\t\t\t   0x9c, 0xfc, 0x4e, 0x96, 0x7e, 0xdb, 0x80, 0x8d,\n\t\t\t\t   0x67, 0x9f, 0x77, 0x7b, 0xc6, 0x70, 0x2c, 0x7d};\n\nconst BYTE dataOut_AES256_CFB[] = {0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b,\n\t\t\t\t   0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60,\n\t\t\t\t   0x39, 0xff, 0xed, 0x14, 0x3b, 0x28, 0xb1, 0xc8,\n\t\t\t\t   0x32, 0x11, 0x3c, 0x63, 0x31, 0xe5, 0x40, 0x7b};\n\nconst BYTE dataOut_AES256_OFB[] = {0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b,\n\t\t\t\t   0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60,\n\t\t\t\t   0x4f, 0xeb, 0xdc, 0x67, 0x40, 0xd2, 0x0b, 0x3a,\n\t\t\t\t   0xc8, 0x8f, 0x6a, 0xd8, 0x2a, 0x4f, 0xb0, 0x8d};\n\nconst BYTE dataOut_AES256_CTR[] = {0x60, 0x1e, 0xc3, 0x13, 0x77, 0x57, 0x89, 0xa5,\n\t\t\t\t   0xb7, 0xa7, 0xf5, 0x04, 0xbb, 0xf3, 0xd2, 0x28,\n\t\t\t\t   0xf4, 0x43, 0xe3, 0xca, 0x4d, 0x62, 0xb5, 0x9a,\n\t\t\t\t   0xca, 0x84, 0xe9, 0x90, 0xca, 0xca, 0xf5, 0xc5};\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TPMB.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tThis file contains extra TPM2B structures\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//\n// This file contains extra TPM2B structures\n//\n\n#ifndef _TPMB_H\n#define _TPMB_H\n\n//*** Size Types\n// These types are used to differentiate the two different size values used.\n//\n// NUMBYTES is used when a size is a number of bytes (usually a TPM2B)\ntypedef UINT16 NUMBYTES;\n\n// TPM2B Types\ntypedef struct\n{\n    NUMBYTES size;\n    BYTE     buffer[1];\n} TPM2B, *P2B;\ntypedef const TPM2B* PC2B;\n\n// This macro helps avoid having to type in the structure in order to create\n// a new TPM2B type that is used in a function.\n#define TPM2B_TYPE(name, bytes)\t\t\\\n    typedef union\t\t\t\\\n    {\t\t\t\t\t\\\n\tstruct\t\t\t\t\t\\\n\t{\t\t\t\t\t\\\n\t    NUMBYTES size;\t\t\t\\\n\t    BYTE     buffer[(bytes)];\t\t\\\n\t} t;\t\t\t\t\t\\\n\tTPM2B b;\t\t\t\t\\\n    } TPM2B_##name\n\n// This macro defines a TPM2B with a constant character value. This macro\n// sets the size of the string to the size minus the terminating zero byte.\n// This lets the user of the label add their terminating 0. This method\n// is chosen so that existing code that provides a label will continue\n// to work correctly.\n\n// Macro to instance and initialize a TPM2B value\n#define TPM2B_INIT(TYPE, name) TPM2B_##TYPE name = {sizeof(name.t.buffer), {0}}\n\n#define TPM2B_BYTE_VALUE(bytes) TPM2B_TYPE(bytes##_BYTE_VALUE, bytes)\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TableMarshal.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tTable Marshal\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TABLE_MARSHAL_H_\n#define _TABLE_MARSHAL_H_\n\n// These are the basic unmarshaling types. This is in the first byte of\n// each structure descriptor that is passed to Marshal()/Unmarshal() for processing.\n#define UINT_MTYPE       0\n#define VALUES_MTYPE     (UINT_MTYPE + 1)\n#define TABLE_MTYPE      (VALUES_MTYPE + 1)\n#define MIN_MAX_MTYPE    (TABLE_MTYPE + 1)\n#define ATTRIBUTES_MTYPE (MIN_MAX_MTYPE + 1)\n#define STRUCTURE_MTYPE  (ATTRIBUTES_MTYPE + 1)\n#define TPM2B_MTYPE      (STRUCTURE_MTYPE + 1)\n#define TPM2BS_MTYPE     (TPM2B_MTYPE + 1)\n#define LIST_MTYPE       (TPM2BS_MTYPE + 1)  // TPML\n#define ERROR_MTYPE      (LIST_MTYPE + 1)\n#define NULL_MTYPE       (ERROR_MTYPE + 1)\n#define COMPOSITE_MTYPE  (NULL_MTYPE + 1)\n\n//*** The Marshal Index\n// A structure is used to hold the values that guide the marshaling/unmarshaling of\n// each of the types. Each structure has a name and an address. For a structure to\n// define a TPMS_name, the structure is a TPMS_name_MARSHAL_STRUCT and its\n// index is TPMS_name_MARSHAL_INDEX. So, to get the proper structure, use the\n// associated marshal index. The marshal index is passed to Marshal() or Unmarshal()\n// and those functions look up the proper structure.\n//\n// To handle structures that allow a null value, the upper bit of each marshal\n// index indicates if the null value is allowed. This is the NULL_FLAG. It is defined\n// in TableMarshalIndex.h because it is needed by code outside of the marshaling\n// code.\n\n// A structure will have a list of marshal indexes to indicate what to unmarshal. When\n// that index appears in a structure/union, the value will contain a flag to indicate\n// that the NULL_FLAG should be SET on the call to Unmarshal() to unmarshal the type.\n// The caller simply takes the entry and passes it to Unmarshal() to indicate that the\n// NULL_FLAG is SET. There is also the opportunity to SET the NULL_FLAG in the called\n// structure if the NULL_FLAG was set in the call to the calling structure. This is\n// indicated by:\n#define NULL_MASK ~(NULL_FLAG)\n\n// When looking up the value to marshal, the upper bit of the marshal index is\n// masked to yield the actual index. The MSb is the flag bit that indicates if a\n// null flag is set. Code does not verify that the bit is clear when the called object\n// does not take a flag as this is a benign error.\n\n// the modifier byte as used by each MTYPE shown as a structure. They are expressed\n// as a bit maps below. However, the code uses masking and not bit fields. The types\n// show below are just to help in understanding.\n// NOTE: LSb0 bit numbering is assumed in these typedefs.\n//\n// When used in an UINT_MTYPE\ntypedef struct integerModifier\n{\n    unsigned size   : 2;\n    unsigned sign   : 1;\n    unsigned unused : 7;\n} integerModifier;\n\n// When used in a VALUES_MTYPE\ntypedef struct valuesModifier\n{\n    unsigned size      : 2;\n    unsigned sign      : 1;\n    unsigned unused    : 5;\n    unsigned takesNull : 1;\n} valuesModifier;\n\n// When used in a TABLE_MTYPE\ntypedef struct tableModifier\n{\n    unsigned size      : 2;\n    unsigned sign      : 1;\n    unsigned unused    : 3;\n    unsigned hasBits   : 1;\n    unsigned takesNull : 1;\n} tableModifier;\n\n// the modifier byte for MIN_MAX_MTYPE\ntypedef struct minMaxModifier\n{\n    unsigned size      : 2;\n    unsigned sign      : 1;\n    unsigned unused    : 3;\n    unsigned hasBits   : 1;\n    unsigned takesNull : 1;\n} minMaxModifier;\n\n// the modifier byte for ATTRIBUTES_MTYPE\ntypedef struct attributesModifier\n{\n    unsigned size   : 2;\n    unsigned sign   : 1;\n    unsigned unused : 5;\n} attributesModifier;\n\n// the modifier byte is not present in a STRUCTURE_MTYPE or an TPM2B_MTYPE\n\n// the modifier byte for a TPM2BS_MTYPE\ntypedef struct tpm2bsModifier\n{\n    unsigned offset        : 4;\n    unsigned unused        : 2;\n    unsigned sizeEqual     : 1;\n    unsigned propigateNull : 1;\n} tpm2bsModifier;\n\n// the modifier byte for a LIST_MTYPE\ntypedef struct listModifier\n{\n    unsigned offset        : 4;\n    unsigned unused        : 2;\n    unsigned sizeEqual     : 1;\n    unsigned propigateNull : 1;\n} listModifier;\n\n//*** Modifier Octet Values\n// These are in used in anything that is an integer value. Theses would not be in\n// structure modifier bytes (they would be used in values in structures but not the\n// STRUCTURE_MTYPE header.\n#define ONE_BYTES   (0)\n#define TWO_BYTES   (1)\n#define FOUR_BYTES  (2)\n#define EIGHT_BYTES (3)\n#define SIZE_MASK   (0x3)\n#define IS_SIGNED   (1 << 2)  // when the unmarshaled type is a signed value\n#define SIGNED_MASK (SIZE_MASK | IS_SIGNED)\n\n// This may be used for any type except a UINT_MTYPE\n#define TAKES_NULL (1 << 7)  // when the type takes a null\n\n// When referencing a structure, this flag indicates if a null is to be propagated\n// to the referenced structure or type.\n#define PROPAGATE_NULL (TAKES_NULL)\n\n// Can be used in min-max or table structures.\n#define HAS_BITS (1 << 6)  // when bit mask is present\n\n// In a union, we need to know if this is a union of constant arrays.\n#define IS_ARRAY_UNION (1 << 6)\n\n// In a TPM2BS_MTYPE\n#define SIZE_EQUAL  (1 << 6)\n#define OFFSET_MASK (0xF)\n\n// Right now, there are three spare bits in the modifiers field.\n\n// Within the descriptor word of each entry in a StructMarsh_mst, there is a selector\n// field to determine which of the sub-types the entry represents and a field that is\n// used to reference another structure entry. This is a 6-bit field allowing a\n// structure to have 64 entries. This should be more than enough as the structures are\n// not that long. As of now, only 10-bits of the descriptor word leaving room for\n// expansion.\n\n// These are the values used in a STRUCTURE_MTYPE to identify the sub-type of the\n// thing being processed\n#define SIMPLE_STYPE 0\n#define UNION_STYPE  1\n#define ARRAY_STYPE  2\n\n// The code used GET_ to get the element type and the compiler uses SET_ to initialize\n// the value. The element type is the three bits (2:0).\n#define GET_ELEMENT_TYPE(val) (val & 7)\n#define SET_ELEMENT_TYPE(val) (val & 7)\n\n// When an entry is an array or union, this references the structure entry that\n// contains the dimension or selector value. The code then uses this number to look up\n// the structure entry for that element to find out what it and where is it in memory.\n// When this is not a reference, it is a simple type and it could be used as an array\n// value or a union selector. When a simple value, this field contains the size\n// of the associated value (ONE_BYTES, TWO_BYTES ...)\n//\n// The entry size/number is 6 bits (13:8).\n#define GET_ELEMENT_NUMBER(val) (((val) >> 8) & 0x3F)\n#define SET_ELEMENT_NUMBER(val) (((val)&0x3F) << 8)\n#define GET_ELEMENT_SIZE(val)   GET_ELEMENT_NUMBER(val)\n#define SET_ELEMENT_SIZE(val)   SET_ELEMENT_NUMBER(val)\n// This determines if the null flag is propagated to this type. If generate, the\n// NULL_FLAG is SET in the index value. This flag is one bit (7)\n#define ELEMENT_PROPAGATE (PROPAGATE_NULL)\n\n#define INDEX_MASK ((UINT16)NULL_MASK)\n\n// This is used in all bit-field checks. These are used when a value that is checked\n// is conditional (dependent on the compilation). For example, if AES_128 is (NO),\n// then the bit associated with AES_128 will be 0. In some cases, the bit value is\n// found by checking that the input is within the range of the table, and then using\n// the (val - min) value to index the bit. This would be used when verifying that\n// a particular algorithm is implemented. In other cases, there is a bit for each\n// value in a table. For example, if checking the key sizes, there is a list of\n// possible key sizes allowed by the algorithm registry and a bit field to indicate\n// if that key size is allowed in the implementation. The smallest bit field has\n// 32-bits because it is implemented as part of the 'values' array in structures\n// that allow bit fields.\n#define IS_BIT_SET32(bit, bits)\t\t\t\t\t\\\n    ((((UINT32*)bits)[bit >> 5] & (1 << (bit & 0x1F))) != 0)\n\n// For a COMPOSITE_MTYPE, the qualifiers byte has an element size and count.\n#define SET_ELEMENT_COUNT(count) ((count & 0x1F) << 3)\n#define GET_ELEMENT_COUNT(val)   ((val >> 3) & 0x1F)\n\n#endif  // _TABLE_MARSHAL_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TableMarshalDefines.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tTable Marshal Defines\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TableMarshalDefines.h 1594 2020-03-26 22:15:48Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.10.7.3\tTableMarshalDefines.h */\n\n#ifndef _TABLE_MARSHAL_DEFINES_H_\n#define _TABLE_MARSHAL_DEFINES_H_\n#define NULL_SHIFT  15\n#define NULL_FLAG   (1 << NULL_SHIFT)\n\n/* The range macro processes a min, max value and produces a values that is used in the computation\n   to see if something is within a range. The max value is (max-min). This lets the check for\n   something (val) within a range become: if((val - min) <= max) / passes if in range if((val - min)\n   > max) / passes if not in range This works because all values are converted to UINT32 values\n   before the compare. For (val - min), all values greater than or equal to val will become positive\n   values with a value equal to min being zero. This means that in an unsigned compare against\n   'max,' any value that is outside the range will appear to be a number greater than max. The\n   benefit of this operation is that this will work even if the input value is a signed number as\n   long as the input is sign extended. */\n\n#define RANGE(_min_, _max_, _base_)\t\t\t\t\t\\\n    (UINT32)_min_, (UINT32)((_base_)(_max_ - _min_))\n\n/* This macro is like the offsetof macro but, instead of computing the offset of a structure\n   element, it computes the stride between elements that are in a structure array. This is used\n   instead of sizeof() because the sizeof() operator on a structure can return an implementation\n   dependent value. */\n\n#define STRIDE(s)   ((UINT16)(size_t)&(((s *)0)[1]))\n#define MARSHAL_REF(TYPE)   ((UINT16)(offsetof(MARSHAL_DATA, TYPE)))\n\n/* This macro creates the entry in the array lookup table */\n\n#define ARRAY_MARSHAL_ENTRY(TYPE)\t\t\t\t\t\\\n    {(marshalIndex_t)TYPE##_MARSHAL_REF, (UINT16)STRIDE(TYPE)}\n\n/* Defines for array lookup */\n\n#define UINT8_ARRAY_MARSHAL_INDEX                   0   // 0x00\n#define TPM_CC_ARRAY_MARSHAL_INDEX                  1   // 0x01\n#define TPMA_CC_ARRAY_MARSHAL_INDEX                 2   // 0x02\n#define TPM_ALG_ID_ARRAY_MARSHAL_INDEX              3   // 0x03\n#define TPM_HANDLE_ARRAY_MARSHAL_INDEX              4   // 0x04\n#define TPM2B_DIGEST_ARRAY_MARSHAL_INDEX            5   // 0x05\n#define TPMT_HA_ARRAY_MARSHAL_INDEX                 6   // 0x06\n#define TPMS_PCR_SELECTION_ARRAY_MARSHAL_INDEX      7   // 0x07\n#define TPMS_ALG_PROPERTY_ARRAY_MARSHAL_INDEX       8   // 0x08\n#define TPMS_TAGGED_PROPERTY_ARRAY_MARSHAL_INDEX    9   // 0x09\n#define TPMS_TAGGED_PCR_SELECT_ARRAY_MARSHAL_INDEX  10  // 0x0A\n#define TPM_ECC_CURVE_ARRAY_MARSHAL_INDEX           11  // 0x0B\n#define TPMS_TAGGED_POLICY_ARRAY_MARSHAL_INDEX      12  // 0x0C\n#define TPMS_ACT_DATA_ARRAY_MARSHAL_INDEX           13  // 0x0D\n#define TPMS_AC_OUTPUT_ARRAY_MARSHAL_INDEX          14  // 0x0E\n\n/* Defines for referencing a type by offset */\n\n#define UINT8_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, UINT8_DATA)))\n#define BYTE_MARSHAL_REF                            UINT8_MARSHAL_REF\n#define TPM_HT_MARSHAL_REF                          UINT8_MARSHAL_REF\n#define TPMA_LOCALITY_MARSHAL_REF                   UINT8_MARSHAL_REF\n#define UINT16_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, UINT16_DATA)))\n#define TPM_KEY_SIZE_MARSHAL_REF                    UINT16_MARSHAL_REF\n#define TPM_KEY_BITS_MARSHAL_REF                    UINT16_MARSHAL_REF\n#define TPM_ALG_ID_MARSHAL_REF                      UINT16_MARSHAL_REF\n#define TPM_ST_MARSHAL_REF                          UINT16_MARSHAL_REF\n#define UINT32_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, UINT32_DATA)))\n#define TPM_ALGORITHM_ID_MARSHAL_REF                UINT32_MARSHAL_REF\n#define TPM_MODIFIER_INDICATOR_MARSHAL_REF          UINT32_MARSHAL_REF\n#define TPM_AUTHORIZATION_SIZE_MARSHAL_REF          UINT32_MARSHAL_REF\n#define TPM_PARAMETER_SIZE_MARSHAL_REF              UINT32_MARSHAL_REF\n#define TPM_SPEC_MARSHAL_REF                        UINT32_MARSHAL_REF\n#define TPM_CONSTANTS32_MARSHAL_REF                 UINT32_MARSHAL_REF\n#define TPM_CC_MARSHAL_REF                          UINT32_MARSHAL_REF\n#define TPM_RC_MARSHAL_REF                          UINT32_MARSHAL_REF\n#define TPM_PT_MARSHAL_REF                          UINT32_MARSHAL_REF\n#define TPM_PT_PCR_MARSHAL_REF                      UINT32_MARSHAL_REF\n#define TPM_PS_MARSHAL_REF                          UINT32_MARSHAL_REF\n#define TPM_HANDLE_MARSHAL_REF                      UINT32_MARSHAL_REF\n#define TPM_RH_MARSHAL_REF                          UINT32_MARSHAL_REF\n#define TPM_HC_MARSHAL_REF                          UINT32_MARSHAL_REF\n#define TPMA_PERMANENT_MARSHAL_REF                  UINT32_MARSHAL_REF\n#define TPMA_STARTUP_CLEAR_MARSHAL_REF              UINT32_MARSHAL_REF\n#define TPMA_MEMORY_MARSHAL_REF                     UINT32_MARSHAL_REF\n#define TPMA_CC_MARSHAL_REF                         UINT32_MARSHAL_REF\n#define TPMA_MODES_MARSHAL_REF                      UINT32_MARSHAL_REF\n#define TPMA_X509_KEY_USAGE_MARSHAL_REF             UINT32_MARSHAL_REF\n#define TPM_NV_INDEX_MARSHAL_REF                    UINT32_MARSHAL_REF\n#define TPM_AE_MARSHAL_REF                          UINT32_MARSHAL_REF\n#define UINT64_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, UINT64_DATA)))\n#define INT8_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, INT8_DATA)))\n#define INT16_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, INT16_DATA)))\n#define INT32_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, INT32_DATA)))\n#define INT64_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, INT64_DATA)))\n#define UINT0_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, UINT0_DATA)))\n#define TPM_ECC_CURVE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM_ECC_CURVE_DATA)))\n#define TPM_CLOCK_ADJUST_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM_CLOCK_ADJUST_DATA)))\n#define TPM_EO_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM_EO_DATA)))\n#define TPM_SU_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM_SU_DATA)))\n#define TPM_SE_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM_SE_DATA)))\n#define TPM_CAP_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM_CAP_DATA)))\n#define TPMA_ALGORITHM_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMA_ALGORITHM_DATA)))\n#define TPMA_OBJECT_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMA_OBJECT_DATA)))\n#define TPMA_SESSION_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMA_SESSION_DATA)))\n#define TPMA_ACT_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMA_ACT_DATA)))\n#define TPMI_YES_NO_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_YES_NO_DATA)))\n#define TPMI_DH_OBJECT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_DH_OBJECT_DATA)))\n#define TPMI_DH_PARENT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_DH_PARENT_DATA)))\n#define TPMI_DH_PERSISTENT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_DH_PERSISTENT_DATA)))\n#define TPMI_DH_ENTITY_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_DH_ENTITY_DATA)))\n#define TPMI_DH_PCR_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_DH_PCR_DATA)))\n#define TPMI_SH_AUTH_SESSION_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_SH_AUTH_SESSION_DATA)))\n#define TPMI_SH_HMAC_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_SH_HMAC_DATA)))\n#define TPMI_SH_POLICY_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_SH_POLICY_DATA)))\n#define TPMI_DH_CONTEXT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_DH_CONTEXT_DATA)))\n#define TPMI_DH_SAVED_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_DH_SAVED_DATA)))\n#define TPMI_RH_HIERARCHY_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_HIERARCHY_DATA)))\n#define TPMI_RH_ENABLES_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_ENABLES_DATA)))\n#define TPMI_RH_HIERARCHY_AUTH_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_HIERARCHY_AUTH_DATA)))\n#define TPMI_RH_HIERARCHY_POLICY_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_HIERARCHY_POLICY_DATA)))\n#define TPMI_RH_PLATFORM_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_PLATFORM_DATA)))\n#define TPMI_RH_OWNER_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_OWNER_DATA)))\n#define TPMI_RH_ENDORSEMENT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_ENDORSEMENT_DATA)))\n#define TPMI_RH_PROVISION_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_PROVISION_DATA)))\n#define TPMI_RH_CLEAR_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_CLEAR_DATA)))\n#define TPMI_RH_NV_AUTH_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_NV_AUTH_DATA)))\n#define TPMI_RH_LOCKOUT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_LOCKOUT_DATA)))\n#define TPMI_RH_NV_INDEX_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_NV_INDEX_DATA)))\n#define TPMI_RH_AC_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_AC_DATA)))\n#define TPMI_RH_ACT_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RH_ACT_DATA)))\n#define TPMI_ALG_HASH_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_HASH_DATA)))\n#define TPMI_ALG_ASYM_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_ASYM_DATA)))\n#define TPMI_ALG_SYM_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_SYM_DATA)))\n#define TPMI_ALG_SYM_OBJECT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_SYM_OBJECT_DATA)))\n#define TPMI_ALG_SYM_MODE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_SYM_MODE_DATA)))\n#define TPMI_ALG_KDF_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_KDF_DATA)))\n#define TPMI_ALG_SIG_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_SIG_SCHEME_DATA)))\n#define TPMI_ECC_KEY_EXCHANGE_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ECC_KEY_EXCHANGE_DATA)))\n#define TPMI_ST_COMMAND_TAG_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ST_COMMAND_TAG_DATA)))\n#define TPMI_ALG_MAC_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_MAC_SCHEME_DATA)))\n#define TPMI_ALG_CIPHER_MODE_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_CIPHER_MODE_DATA)))\n#define TPMS_EMPTY_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_EMPTY_DATA)))\n#define TPMS_ENC_SCHEME_RSAES_MARSHAL_REF           TPMS_EMPTY_MARSHAL_REF\n#define TPMS_ALGORITHM_DESCRIPTION_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_ALGORITHM_DESCRIPTION_DATA)))\n#define TPMU_HA_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_HA_DATA)))\n#define TPMT_HA_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_HA_DATA)))\n#define TPM2B_DIGEST_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_DIGEST_DATA)))\n#define TPM2B_NONCE_MARSHAL_REF                     TPM2B_DIGEST_MARSHAL_REF\n#define TPM2B_AUTH_MARSHAL_REF                      TPM2B_DIGEST_MARSHAL_REF\n#define TPM2B_OPERAND_MARSHAL_REF                   TPM2B_DIGEST_MARSHAL_REF\n#define TPM2B_DATA_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_DATA_DATA)))\n#define TPM2B_EVENT_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_EVENT_DATA)))\n#define TPM2B_MAX_BUFFER_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_MAX_BUFFER_DATA)))\n#define TPM2B_MAX_NV_BUFFER_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_MAX_NV_BUFFER_DATA)))\n#define TPM2B_TIMEOUT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_TIMEOUT_DATA)))\n#define TPM2B_IV_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_IV_DATA)))\n#define NULL_UNION_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, NULL_UNION_DATA)))\n#define TPMU_NAME_MARSHAL_REF                       NULL_UNION_MARSHAL_REF\n#define TPMU_SENSITIVE_CREATE_MARSHAL_REF           NULL_UNION_MARSHAL_REF\n#define TPM2B_NAME_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_NAME_DATA)))\n#define TPMS_PCR_SELECT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_PCR_SELECT_DATA)))\n#define TPMS_PCR_SELECTION_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_PCR_SELECTION_DATA)))\n#define TPMT_TK_CREATION_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_TK_CREATION_DATA)))\n#define TPMT_TK_VERIFIED_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_TK_VERIFIED_DATA)))\n#define TPMT_TK_AUTH_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_TK_AUTH_DATA)))\n#define TPMT_TK_HASHCHECK_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_TK_HASHCHECK_DATA)))\n#define TPMS_ALG_PROPERTY_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_ALG_PROPERTY_DATA)))\n#define TPMS_TAGGED_PROPERTY_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_TAGGED_PROPERTY_DATA)))\n#define TPMS_TAGGED_PCR_SELECT_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_TAGGED_PCR_SELECT_DATA)))\n#define TPMS_TAGGED_POLICY_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_TAGGED_POLICY_DATA)))\n#define TPMS_ACT_DATA_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_ACT_DATA_DATA)))\n#define TPML_CC_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_CC_DATA)))\n#define TPML_CCA_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_CCA_DATA)))\n#define TPML_ALG_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_ALG_DATA)))\n#define TPML_HANDLE_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_HANDLE_DATA)))\n#define TPML_DIGEST_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_DIGEST_DATA)))\n#define TPML_DIGEST_VALUES_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_DIGEST_VALUES_DATA)))\n#define TPML_PCR_SELECTION_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_PCR_SELECTION_DATA)))\n#define TPML_ALG_PROPERTY_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_ALG_PROPERTY_DATA)))\n#define TPML_TAGGED_TPM_PROPERTY_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_TAGGED_TPM_PROPERTY_DATA)))\n#define TPML_TAGGED_PCR_PROPERTY_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_TAGGED_PCR_PROPERTY_DATA)))\n#define TPML_ECC_CURVE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_ECC_CURVE_DATA)))\n#define TPML_TAGGED_POLICY_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_TAGGED_POLICY_DATA)))\n#define TPML_ACT_DATA_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_ACT_DATA_DATA)))\n#define TPMU_CAPABILITIES_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_CAPABILITIES_DATA)))\n#define TPMS_CAPABILITY_DATA_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_CAPABILITY_DATA_DATA)))\n#define TPMS_CLOCK_INFO_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_CLOCK_INFO_DATA)))\n#define TPMS_TIME_INFO_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_TIME_INFO_DATA)))\n#define TPMS_TIME_ATTEST_INFO_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_TIME_ATTEST_INFO_DATA)))\n#define TPMS_CERTIFY_INFO_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_CERTIFY_INFO_DATA)))\n#define TPMS_QUOTE_INFO_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_QUOTE_INFO_DATA)))\n#define TPMS_COMMAND_AUDIT_INFO_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_COMMAND_AUDIT_INFO_DATA)))\n#define TPMS_SESSION_AUDIT_INFO_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_SESSION_AUDIT_INFO_DATA)))\n#define TPMS_CREATION_INFO_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_CREATION_INFO_DATA)))\n#define TPMS_NV_CERTIFY_INFO_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_NV_CERTIFY_INFO_DATA)))\n#define TPMS_NV_DIGEST_CERTIFY_INFO_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_NV_DIGEST_CERTIFY_INFO_DATA)))\n#define TPMI_ST_ATTEST_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ST_ATTEST_DATA)))\n#define TPMU_ATTEST_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_ATTEST_DATA)))\n#define TPMS_ATTEST_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_ATTEST_DATA)))\n#define TPM2B_ATTEST_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_ATTEST_DATA)))\n#define TPMS_AUTH_COMMAND_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_AUTH_COMMAND_DATA)))\n#define TPMS_AUTH_RESPONSE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_AUTH_RESPONSE_DATA)))\n#define TPMI_TDES_KEY_BITS_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_TDES_KEY_BITS_DATA)))\n#define TPMI_AES_KEY_BITS_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_AES_KEY_BITS_DATA)))\n#define TPMI_SM4_KEY_BITS_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_SM4_KEY_BITS_DATA)))\n#define TPMI_CAMELLIA_KEY_BITS_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_CAMELLIA_KEY_BITS_DATA)))\n#define TPMU_SYM_KEY_BITS_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_SYM_KEY_BITS_DATA)))\n#define TPMU_SYM_MODE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_SYM_MODE_DATA)))\n#define TPMT_SYM_DEF_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_SYM_DEF_DATA)))\n#define TPMT_SYM_DEF_OBJECT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_SYM_DEF_OBJECT_DATA)))\n#define TPM2B_SYM_KEY_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_SYM_KEY_DATA)))\n#define TPMS_SYMCIPHER_PARMS_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_SYMCIPHER_PARMS_DATA)))\n#define TPM2B_LABEL_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_LABEL_DATA)))\n#define TPMS_DERIVE_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_DERIVE_DATA)))\n#define TPM2B_DERIVE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_DERIVE_DATA)))\n#define TPM2B_SENSITIVE_DATA_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_SENSITIVE_DATA_DATA)))\n#define TPMS_SENSITIVE_CREATE_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_SENSITIVE_CREATE_DATA)))\n#define TPM2B_SENSITIVE_CREATE_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_SENSITIVE_CREATE_DATA)))\n#define TPMS_SCHEME_HASH_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_SCHEME_HASH_DATA)))\n#define TPMS_SCHEME_HMAC_MARSHAL_REF                TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_SIG_SCHEME_RSASSA_MARSHAL_REF          TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_SIG_SCHEME_RSAPSS_MARSHAL_REF          TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_SIG_SCHEME_ECDSA_MARSHAL_REF           TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_SIG_SCHEME_SM2_MARSHAL_REF             TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_SIG_SCHEME_ECSCHNORR_MARSHAL_REF       TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_ENC_SCHEME_OAEP_MARSHAL_REF            TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_KEY_SCHEME_ECDH_MARSHAL_REF            TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_KEY_SCHEME_ECMQV_MARSHAL_REF           TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_KDF_SCHEME_MGF1_MARSHAL_REF            TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_KDF_SCHEME_KDF1_SP800_56A_MARSHAL_REF  TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_KDF_SCHEME_KDF2_MARSHAL_REF            TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_KDF_SCHEME_KDF1_SP800_108_MARSHAL_REF  TPMS_SCHEME_HASH_MARSHAL_REF\n#define TPMS_SCHEME_ECDAA_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_SCHEME_ECDAA_DATA)))\n#define TPMS_SIG_SCHEME_ECDAA_MARSHAL_REF           TPMS_SCHEME_ECDAA_MARSHAL_REF\n#define TPMI_ALG_KEYEDHASH_SCHEME_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_KEYEDHASH_SCHEME_DATA)))\n#define TPMS_SCHEME_XOR_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_SCHEME_XOR_DATA)))\n#define TPMU_SCHEME_KEYEDHASH_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_SCHEME_KEYEDHASH_DATA)))\n#define TPMT_KEYEDHASH_SCHEME_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_KEYEDHASH_SCHEME_DATA)))\n#define TPMU_SIG_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_SIG_SCHEME_DATA)))\n#define TPMT_SIG_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_SIG_SCHEME_DATA)))\n#define TPMU_KDF_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_KDF_SCHEME_DATA)))\n#define TPMT_KDF_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_KDF_SCHEME_DATA)))\n#define TPMI_ALG_ASYM_SCHEME_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_ASYM_SCHEME_DATA)))\n#define TPMU_ASYM_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_ASYM_SCHEME_DATA)))\n#define TPMI_ALG_RSA_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_RSA_SCHEME_DATA)))\n#define TPMT_RSA_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_RSA_SCHEME_DATA)))\n#define TPMI_ALG_RSA_DECRYPT_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_RSA_DECRYPT_DATA)))\n#define TPMT_RSA_DECRYPT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_RSA_DECRYPT_DATA)))\n#define TPM2B_PUBLIC_KEY_RSA_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_PUBLIC_KEY_RSA_DATA)))\n#define TPMI_RSA_KEY_BITS_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_RSA_KEY_BITS_DATA)))\n#define TPM2B_PRIVATE_KEY_RSA_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_PRIVATE_KEY_RSA_DATA)))\n#define TPM2B_ECC_PARAMETER_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_ECC_PARAMETER_DATA)))\n#define TPMS_ECC_POINT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_ECC_POINT_DATA)))\n#define TPM2B_ECC_POINT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_ECC_POINT_DATA)))\n#define TPMI_ALG_ECC_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_ECC_SCHEME_DATA)))\n#define TPMI_ECC_CURVE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ECC_CURVE_DATA)))\n#define TPMT_ECC_SCHEME_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_ECC_SCHEME_DATA)))\n#define TPMS_ALGORITHM_DETAIL_ECC_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_ALGORITHM_DETAIL_ECC_DATA)))\n#define TPMS_SIGNATURE_RSA_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_SIGNATURE_RSA_DATA)))\n#define TPMS_SIGNATURE_RSASSA_MARSHAL_REF           TPMS_SIGNATURE_RSA_MARSHAL_REF\n#define TPMS_SIGNATURE_RSAPSS_MARSHAL_REF           TPMS_SIGNATURE_RSA_MARSHAL_REF\n#define TPMS_SIGNATURE_ECC_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_SIGNATURE_ECC_DATA)))\n#define TPMS_SIGNATURE_ECDAA_MARSHAL_REF            TPMS_SIGNATURE_ECC_MARSHAL_REF\n#define TPMS_SIGNATURE_ECDSA_MARSHAL_REF            TPMS_SIGNATURE_ECC_MARSHAL_REF\n#define TPMS_SIGNATURE_SM2_MARSHAL_REF              TPMS_SIGNATURE_ECC_MARSHAL_REF\n#define TPMS_SIGNATURE_ECSCHNORR_MARSHAL_REF        TPMS_SIGNATURE_ECC_MARSHAL_REF\n#define TPMU_SIGNATURE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_SIGNATURE_DATA)))\n#define TPMT_SIGNATURE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_SIGNATURE_DATA)))\n#define TPMU_ENCRYPTED_SECRET_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_ENCRYPTED_SECRET_DATA)))\n#define TPM2B_ENCRYPTED_SECRET_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_ENCRYPTED_SECRET_DATA)))\n#define TPMI_ALG_PUBLIC_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMI_ALG_PUBLIC_DATA)))\n#define TPMU_PUBLIC_ID_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_PUBLIC_ID_DATA)))\n#define TPMS_KEYEDHASH_PARMS_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_KEYEDHASH_PARMS_DATA)))\n#define TPMS_RSA_PARMS_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_RSA_PARMS_DATA)))\n#define TPMS_ECC_PARMS_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_ECC_PARMS_DATA)))\n#define TPMU_PUBLIC_PARMS_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_PUBLIC_PARMS_DATA)))\n#define TPMT_PUBLIC_PARMS_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_PUBLIC_PARMS_DATA)))\n#define TPMT_PUBLIC_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_PUBLIC_DATA)))\n#define TPM2B_PUBLIC_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_PUBLIC_DATA)))\n#define TPM2B_TEMPLATE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_TEMPLATE_DATA)))\n#define TPM2B_PRIVATE_VENDOR_SPECIFIC_MARSHAL_REF\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_PRIVATE_VENDOR_SPECIFIC_DATA)))\n#define TPMU_SENSITIVE_COMPOSITE_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMU_SENSITIVE_COMPOSITE_DATA)))\n#define TPMT_SENSITIVE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMT_SENSITIVE_DATA)))\n#define TPM2B_SENSITIVE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_SENSITIVE_DATA)))\n#define TPM2B_PRIVATE_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_PRIVATE_DATA)))\n#define TPM2B_ID_OBJECT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_ID_OBJECT_DATA)))\n#define TPMS_NV_PIN_COUNTER_PARAMETERS_MARSHAL_REF\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_NV_PIN_COUNTER_PARAMETERS_DATA)))\n#define TPMA_NV_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMA_NV_DATA)))\n#define TPMS_NV_PUBLIC_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_NV_PUBLIC_DATA)))\n#define TPM2B_NV_PUBLIC_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_NV_PUBLIC_DATA)))\n#define TPM2B_CONTEXT_SENSITIVE_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_CONTEXT_SENSITIVE_DATA)))\n#define TPMS_CONTEXT_DATA_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_CONTEXT_DATA_DATA)))\n#define TPM2B_CONTEXT_DATA_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_CONTEXT_DATA_DATA)))\n#define TPMS_CONTEXT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_CONTEXT_DATA)))\n#define TPMS_CREATION_DATA_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_CREATION_DATA_DATA)))\n#define TPM2B_CREATION_DATA_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM2B_CREATION_DATA_DATA)))\n#define TPM_AT_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPM_AT_DATA)))\n#define TPMS_AC_OUTPUT_MARSHAL_REF\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPMS_AC_OUTPUT_DATA)))\n#define TPML_AC_CAPABILITIES_MARSHAL_REF\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, TPML_AC_CAPABILITIES_DATA)))\n#define Type00_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type00_DATA)))\n#define Type01_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type01_DATA)))\n#define Type02_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type02_DATA)))\n#define Type03_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type03_DATA)))\n#define Type04_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type04_DATA)))\n#define Type05_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type05_DATA)))\n#define Type06_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type06_DATA)))\n#define Type07_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type07_DATA)))\n#define Type08_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type08_DATA)))\n#define Type09_MARSHAL_REF                          Type08_MARSHAL_REF\n#define Type14_MARSHAL_REF                          Type08_MARSHAL_REF\n#define Type10_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type10_DATA)))\n#define Type11_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type11_DATA)))\n#define Type12_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type12_DATA)))\n#define Type13_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type13_DATA)))\n#define Type15_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type15_DATA)))\n#define Type16_MARSHAL_REF                          Type15_MARSHAL_REF\n#define Type17_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type17_DATA)))\n#define Type18_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type18_DATA)))\n#define Type19_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type19_DATA)))\n#define Type20_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type20_DATA)))\n#define Type21_MARSHAL_REF                          Type20_MARSHAL_REF\n#define Type22_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type22_DATA)))\n#define Type23_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type23_DATA)))\n#define Type24_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type24_DATA)))\n#define Type25_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type25_DATA)))\n#define Type26_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type26_DATA)))\n#define Type27_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type27_DATA)))\n#define Type28_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type28_DATA)))\n#define Type29_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type29_DATA)))\n#define Type30_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type30_DATA)))\n#define Type31_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type31_DATA)))\n#define Type32_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type32_DATA)))\n#define Type33_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type33_DATA)))\n#define Type34_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type34_DATA)))\n#define Type35_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type35_DATA)))\n#define Type36_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type36_DATA)))\n#define Type37_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type37_DATA)))\n#define Type38_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type38_DATA)))\n#define Type39_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type39_DATA)))\n#define Type40_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type40_DATA)))\n#define Type41_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type41_DATA)))\n#define Type42_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type42_DATA)))\n#define Type43_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type43_DATA)))\n#define Type44_MARSHAL_REF\t\t\t\t\t\t\\\n    ((UINT16)(offsetof(MarshalData_st, Type44_DATA)))\n//#defines to change calling sequence for code using marshaling\n\n#define UINT8_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(UINT8_MARSHAL_REF, (target), (buffer), (size))\n#define UINT8_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(UINT8_MARSHAL_REF, (source), (buffer), (size))\n#define BYTE_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(UINT8_MARSHAL_REF, (target), (buffer), (size))\n#define BYTE_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(UINT8_MARSHAL_REF, (source), (buffer), (size))\n#define INT8_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(INT8_MARSHAL_REF, (target), (buffer), (size))\n#define INT8_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(INT8_MARSHAL_REF, (source), (buffer), (size))\n#define UINT16_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(UINT16_MARSHAL_REF, (target), (buffer), (size))\n#define UINT16_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(UINT16_MARSHAL_REF, (source), (buffer), (size))\n#define INT16_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(INT16_MARSHAL_REF, (target), (buffer), (size))\n#define INT16_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(INT16_MARSHAL_REF, (source), (buffer), (size))\n#define UINT32_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(UINT32_MARSHAL_REF, (target), (buffer), (size))\n#define UINT32_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(UINT32_MARSHAL_REF, (source), (buffer), (size))\n#define INT32_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(INT32_MARSHAL_REF, (target), (buffer), (size))\n#define INT32_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(INT32_MARSHAL_REF, (source), (buffer), (size))\n#define UINT64_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(UINT64_MARSHAL_REF, (target), (buffer), (size))\n#define UINT64_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(UINT64_MARSHAL_REF, (source), (buffer), (size))\n#define INT64_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(INT64_MARSHAL_REF, (target), (buffer), (size))\n#define INT64_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(INT64_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_ALGORITHM_ID_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM_ALGORITHM_ID_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_ALGORITHM_ID_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM_ALGORITHM_ID_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_MODIFIER_INDICATOR_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM_MODIFIER_INDICATOR_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_MODIFIER_INDICATOR_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM_MODIFIER_INDICATOR_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_AUTHORIZATION_SIZE_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM_AUTHORIZATION_SIZE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_AUTHORIZATION_SIZE_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM_AUTHORIZATION_SIZE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_PARAMETER_SIZE_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM_PARAMETER_SIZE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_PARAMETER_SIZE_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM_PARAMETER_SIZE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_KEY_SIZE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM_KEY_SIZE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_KEY_SIZE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM_KEY_SIZE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_KEY_BITS_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM_KEY_BITS_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_KEY_BITS_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM_KEY_BITS_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_CONSTANTS32_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM_CONSTANTS32_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_ALG_ID_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM_ALG_ID_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_ALG_ID_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM_ALG_ID_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_ECC_CURVE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM_ECC_CURVE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_ECC_CURVE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM_ECC_CURVE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_CC_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_CC_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_CC_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_CC_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_RC_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_RC_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_CLOCK_ADJUST_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM_CLOCK_ADJUST_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_EO_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_EO_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_EO_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_EO_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_ST_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_ST_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_ST_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_ST_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_SU_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_SU_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_SE_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_SE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_CAP_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_CAP_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_CAP_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_CAP_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_PT_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_PT_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_PT_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_PT_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_PT_PCR_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM_PT_PCR_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_PT_PCR_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM_PT_PCR_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_PS_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_PS_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_HANDLE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM_HANDLE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_HANDLE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM_HANDLE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_HT_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_HT_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_HT_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_HT_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_RH_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_RH_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_RH_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_RH_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_HC_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_HC_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_HC_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_HC_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_ALGORITHM_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMA_ALGORITHM_MARSHAL_REF, (target), (buffer), (size))\n#define TPMA_ALGORITHM_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMA_ALGORITHM_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_OBJECT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMA_OBJECT_MARSHAL_REF, (target), (buffer), (size))\n#define TPMA_OBJECT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMA_OBJECT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_SESSION_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMA_SESSION_MARSHAL_REF, (target), (buffer), (size))\n#define TPMA_SESSION_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMA_SESSION_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_LOCALITY_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMA_LOCALITY_MARSHAL_REF, (target), (buffer), (size))\n#define TPMA_LOCALITY_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMA_LOCALITY_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_PERMANENT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMA_PERMANENT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_STARTUP_CLEAR_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMA_STARTUP_CLEAR_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_MEMORY_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMA_MEMORY_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_CC_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPMA_CC_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_MODES_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMA_MODES_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_X509_KEY_USAGE_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMA_X509_KEY_USAGE_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_ACT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMA_ACT_MARSHAL_REF, (target), (buffer), (size))\n#define TPMA_ACT_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPMA_ACT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_YES_NO_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_YES_NO_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_YES_NO_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_YES_NO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_DH_OBJECT_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_DH_OBJECT_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMI_DH_OBJECT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_DH_OBJECT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_DH_PARENT_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_DH_PARENT_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMI_DH_PARENT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_DH_PARENT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_DH_PERSISTENT_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_DH_PERSISTENT_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_DH_PERSISTENT_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_DH_PERSISTENT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_DH_ENTITY_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_DH_ENTITY_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMI_DH_PCR_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_DH_PCR_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMI_SH_AUTH_SESSION_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_SH_AUTH_SESSION_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMI_SH_AUTH_SESSION_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_SH_AUTH_SESSION_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_SH_HMAC_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_SH_HMAC_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_SH_HMAC_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_SH_HMAC_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_SH_POLICY_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_SH_POLICY_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_SH_POLICY_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_SH_POLICY_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_DH_CONTEXT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_DH_CONTEXT_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_DH_CONTEXT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_DH_CONTEXT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_DH_SAVED_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_DH_SAVED_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_DH_SAVED_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_DH_SAVED_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_RH_HIERARCHY_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_RH_HIERARCHY_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMI_RH_HIERARCHY_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_RH_HIERARCHY_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_RH_ENABLES_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_RH_ENABLES_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMI_RH_ENABLES_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_RH_ENABLES_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_RH_HIERARCHY_AUTH_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_RH_HIERARCHY_AUTH_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_HIERARCHY_POLICY_Unmarshal(target, buffer, size)\t\\\n    Unmarshal(TPMI_RH_HIERARCHY_POLICY_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_PLATFORM_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_RH_PLATFORM_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_OWNER_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_RH_OWNER_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMI_RH_ENDORSEMENT_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_RH_ENDORSEMENT_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target),\t\\\n\t      (buffer), (size))\n#define TPMI_RH_PROVISION_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_RH_PROVISION_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_CLEAR_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_RH_CLEAR_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_NV_AUTH_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_RH_NV_AUTH_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_LOCKOUT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_RH_LOCKOUT_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_NV_INDEX_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_RH_NV_INDEX_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_NV_INDEX_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_RH_NV_INDEX_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_RH_AC_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_RH_AC_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_ACT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_RH_ACT_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RH_ACT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_RH_ACT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_HASH_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_ALG_HASH_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMI_ALG_HASH_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_ALG_HASH_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_ASYM_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_ALG_ASYM_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMI_ALG_ASYM_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_ALG_ASYM_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_SYM_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_ALG_SYM_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMI_ALG_SYM_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_ALG_SYM_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_SYM_OBJECT_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ALG_SYM_OBJECT_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target),\t\\\n\t      (buffer), (size))\n#define TPMI_ALG_SYM_OBJECT_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ALG_SYM_OBJECT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_SYM_MODE_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_ALG_SYM_MODE_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMI_ALG_SYM_MODE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_ALG_SYM_MODE_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_KDF_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMI_ALG_KDF_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMI_ALG_KDF_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_ALG_KDF_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_SIG_SCHEME_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ALG_SIG_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target),\t\\\n\t      (buffer), (size))\n#define TPMI_ALG_SIG_SCHEME_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ALG_SIG_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ECC_KEY_EXCHANGE_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ECC_KEY_EXCHANGE_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMI_ECC_KEY_EXCHANGE_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ECC_KEY_EXCHANGE_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ST_COMMAND_TAG_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_ST_COMMAND_TAG_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_ST_COMMAND_TAG_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ST_COMMAND_TAG_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_MAC_SCHEME_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ALG_MAC_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target),\t\\\n\t      (buffer), (size))\n#define TPMI_ALG_MAC_SCHEME_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ALG_MAC_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_CIPHER_MODE_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ALG_CIPHER_MODE_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMI_ALG_CIPHER_MODE_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ALG_CIPHER_MODE_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_EMPTY_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_EMPTY_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_EMPTY_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_EMPTY_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_ALGORITHM_DESCRIPTION_Marshal(source, buffer, size)\t\\\n    Marshal(TPMS_ALGORITHM_DESCRIPTION_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_HA_Unmarshal(target, buffer, size, selector)\t\t\\\n    UnmarshalUnion(TPMU_HA_MARSHAL_REF, (target), (buffer), (size), (selector))\n#define TPMU_HA_Marshal(source, buffer, size, selector)\t\t\t\\\n    MarshalUnion(TPMU_HA_MARSHAL_REF, (source), (buffer), (size), (selector))\n#define TPMT_HA_Unmarshal(target, buffer, size, flag)\t\t\t\\\n    Unmarshal(TPMT_HA_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMT_HA_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPMT_HA_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_DIGEST_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_DIGEST_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_DIGEST_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_DIGEST_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_DATA_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_DATA_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_DATA_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_DATA_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_NONCE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_NONCE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_NONCE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_NONCE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_AUTH_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_AUTH_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_AUTH_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_AUTH_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_OPERAND_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_OPERAND_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_OPERAND_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_OPERAND_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_EVENT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_EVENT_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_EVENT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_EVENT_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_MAX_BUFFER_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_MAX_BUFFER_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_MAX_BUFFER_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_MAX_BUFFER_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_MAX_NV_BUFFER_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_MAX_NV_BUFFER_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_MAX_NV_BUFFER_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM2B_MAX_NV_BUFFER_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_TIMEOUT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_TIMEOUT_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_TIMEOUT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_TIMEOUT_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_IV_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_IV_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_IV_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM2B_IV_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_NAME_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_NAME_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_NAME_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_NAME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_PCR_SELECT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_PCR_SELECT_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_PCR_SELECT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_PCR_SELECT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_PCR_SELECTION_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_PCR_SELECTION_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_PCR_SELECTION_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_PCR_SELECTION_MARSHAL_REF, (source), (buffer), (size))\n#define TPMT_TK_CREATION_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMT_TK_CREATION_MARSHAL_REF, (target), (buffer), (size))\n#define TPMT_TK_CREATION_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_TK_CREATION_MARSHAL_REF, (source), (buffer), (size))\n#define TPMT_TK_VERIFIED_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMT_TK_VERIFIED_MARSHAL_REF, (target), (buffer), (size))\n#define TPMT_TK_VERIFIED_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_TK_VERIFIED_MARSHAL_REF, (source), (buffer), (size))\n#define TPMT_TK_AUTH_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMT_TK_AUTH_MARSHAL_REF, (target), (buffer), (size))\n#define TPMT_TK_AUTH_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_TK_AUTH_MARSHAL_REF, (source), (buffer), (size))\n#define TPMT_TK_HASHCHECK_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMT_TK_HASHCHECK_MARSHAL_REF, (target), (buffer), (size))\n#define TPMT_TK_HASHCHECK_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_TK_HASHCHECK_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_ALG_PROPERTY_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_ALG_PROPERTY_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_TAGGED_PROPERTY_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_TAGGED_PROPERTY_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_TAGGED_PCR_SELECT_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_TAGGED_PCR_SELECT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_TAGGED_POLICY_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_TAGGED_POLICY_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_ACT_DATA_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_ACT_DATA_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_CC_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPML_CC_MARSHAL_REF, (target), (buffer), (size))\n#define TPML_CC_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPML_CC_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_CCA_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPML_CCA_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_ALG_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPML_ALG_MARSHAL_REF, (target), (buffer), (size))\n#define TPML_ALG_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPML_ALG_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_HANDLE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPML_HANDLE_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_DIGEST_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPML_DIGEST_MARSHAL_REF, (target), (buffer), (size))\n#define TPML_DIGEST_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPML_DIGEST_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_DIGEST_VALUES_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPML_DIGEST_VALUES_MARSHAL_REF, (target), (buffer), (size))\n#define TPML_DIGEST_VALUES_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPML_DIGEST_VALUES_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_PCR_SELECTION_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPML_PCR_SELECTION_MARSHAL_REF, (target), (buffer), (size))\n#define TPML_PCR_SELECTION_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPML_PCR_SELECTION_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_ALG_PROPERTY_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPML_ALG_PROPERTY_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_TAGGED_TPM_PROPERTY_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPML_TAGGED_TPM_PROPERTY_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_TAGGED_PCR_PROPERTY_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPML_TAGGED_PCR_PROPERTY_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_ECC_CURVE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPML_ECC_CURVE_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_TAGGED_POLICY_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPML_TAGGED_POLICY_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_ACT_DATA_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPML_ACT_DATA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_CAPABILITIES_Marshal(source, buffer, size, selector)\t\\\n    MarshalUnion(TPMU_CAPABILITIES_MARSHAL_REF, (source), (buffer), (size), \\\n\t\t (selector))\n#define TPMS_CAPABILITY_DATA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_CAPABILITY_DATA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_CLOCK_INFO_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_CLOCK_INFO_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_CLOCK_INFO_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_CLOCK_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_TIME_INFO_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_TIME_INFO_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_TIME_INFO_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_TIME_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_TIME_ATTEST_INFO_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_TIME_ATTEST_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_CERTIFY_INFO_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_CERTIFY_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_QUOTE_INFO_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_QUOTE_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_COMMAND_AUDIT_INFO_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_COMMAND_AUDIT_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SESSION_AUDIT_INFO_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SESSION_AUDIT_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_CREATION_INFO_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_CREATION_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_NV_CERTIFY_INFO_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_NV_CERTIFY_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_NV_DIGEST_CERTIFY_INFO_Marshal(source, buffer, size)\t\\\n    Marshal(TPMS_NV_DIGEST_CERTIFY_INFO_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ST_ATTEST_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_ST_ATTEST_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_ATTEST_Marshal(source, buffer, size, selector)\t\t\\\n    MarshalUnion(TPMU_ATTEST_MARSHAL_REF, (source), (buffer), (size), (selector))\n#define TPMS_ATTEST_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_ATTEST_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_ATTEST_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_ATTEST_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_AUTH_COMMAND_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_AUTH_COMMAND_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_AUTH_RESPONSE_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_AUTH_RESPONSE_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_TDES_KEY_BITS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_TDES_KEY_BITS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_TDES_KEY_BITS_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_TDES_KEY_BITS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_AES_KEY_BITS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_AES_KEY_BITS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_AES_KEY_BITS_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_AES_KEY_BITS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_SM4_KEY_BITS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_SM4_KEY_BITS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_SM4_KEY_BITS_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_SM4_KEY_BITS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_CAMELLIA_KEY_BITS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_CAMELLIA_KEY_BITS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_CAMELLIA_KEY_BITS_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_CAMELLIA_KEY_BITS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_SYM_KEY_BITS_Unmarshal(target, buffer, size, selector)\t\\\n    UnmarshalUnion(TPMU_SYM_KEY_BITS_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_SYM_KEY_BITS_Marshal(source, buffer, size, selector)\t\\\n    MarshalUnion(TPMU_SYM_KEY_BITS_MARSHAL_REF, (source), (buffer), (size), \\\n\t\t (selector))\n#define TPMU_SYM_MODE_Unmarshal(target, buffer, size, selector)\t\t\\\n    UnmarshalUnion(TPMU_SYM_MODE_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_SYM_MODE_Marshal(source, buffer, size, selector)\t\t\\\n    MarshalUnion(TPMU_SYM_MODE_MARSHAL_REF, (source), (buffer), (size), (selector))\n#define TPMT_SYM_DEF_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMT_SYM_DEF_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMT_SYM_DEF_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_SYM_DEF_MARSHAL_REF, (source), (buffer), (size))\n#define TPMT_SYM_DEF_OBJECT_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMT_SYM_DEF_OBJECT_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target),\t\\\n\t      (buffer), (size))\n#define TPMT_SYM_DEF_OBJECT_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMT_SYM_DEF_OBJECT_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_SYM_KEY_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_SYM_KEY_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_SYM_KEY_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_SYM_KEY_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SYMCIPHER_PARMS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SYMCIPHER_PARMS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SYMCIPHER_PARMS_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SYMCIPHER_PARMS_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_LABEL_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_LABEL_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_LABEL_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_LABEL_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_DERIVE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_DERIVE_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_DERIVE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_DERIVE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_DERIVE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_DERIVE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_DERIVE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_DERIVE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_SENSITIVE_DATA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_SENSITIVE_DATA_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_SENSITIVE_DATA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM2B_SENSITIVE_DATA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SENSITIVE_CREATE_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SENSITIVE_CREATE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_SENSITIVE_CREATE_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_SENSITIVE_CREATE_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SCHEME_HASH_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SCHEME_HASH_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SCHEME_HASH_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_SCHEME_HASH_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SCHEME_ECDAA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SCHEME_ECDAA_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SCHEME_ECDAA_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_SCHEME_ECDAA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_KEYEDHASH_SCHEME_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ALG_KEYEDHASH_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), \\\n\t      (target), (buffer), (size))\n#define TPMI_ALG_KEYEDHASH_SCHEME_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ALG_KEYEDHASH_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SCHEME_HMAC_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SCHEME_HMAC_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SCHEME_HMAC_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_SCHEME_HMAC_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SCHEME_XOR_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_SCHEME_XOR_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SCHEME_XOR_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_SCHEME_XOR_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_SCHEME_KEYEDHASH_Unmarshal(target, buffer, size, selector)\t\\\n    UnmarshalUnion(TPMU_SCHEME_KEYEDHASH_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_SCHEME_KEYEDHASH_Marshal(source, buffer, size, selector)\t\\\n    MarshalUnion(TPMU_SCHEME_KEYEDHASH_MARSHAL_REF, (source), (buffer), (size),\t\\\n\t\t (selector))\n#define TPMT_KEYEDHASH_SCHEME_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMT_KEYEDHASH_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMT_KEYEDHASH_SCHEME_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMT_KEYEDHASH_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIG_SCHEME_RSASSA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIG_SCHEME_RSASSA_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIG_SCHEME_RSASSA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIG_SCHEME_RSASSA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIG_SCHEME_RSAPSS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIG_SCHEME_RSAPSS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIG_SCHEME_RSAPSS_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIG_SCHEME_RSAPSS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIG_SCHEME_ECDSA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIG_SCHEME_ECDSA_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIG_SCHEME_ECDSA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIG_SCHEME_ECDSA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIG_SCHEME_SM2_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIG_SCHEME_SM2_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIG_SCHEME_SM2_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIG_SCHEME_SM2_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIG_SCHEME_ECSCHNORR_Unmarshal(target, buffer, size)\t\\\n    Unmarshal(TPMS_SIG_SCHEME_ECSCHNORR_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIG_SCHEME_ECSCHNORR_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIG_SCHEME_ECSCHNORR_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIG_SCHEME_ECDAA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIG_SCHEME_ECDAA_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIG_SCHEME_ECDAA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIG_SCHEME_ECDAA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_SIG_SCHEME_Unmarshal(target, buffer, size, selector)\t\\\n    UnmarshalUnion(TPMU_SIG_SCHEME_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_SIG_SCHEME_Marshal(source, buffer, size, selector)\t\t\\\n    MarshalUnion(TPMU_SIG_SCHEME_MARSHAL_REF, (source), (buffer), (size), \\\n\t\t (selector))\n#define TPMT_SIG_SCHEME_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMT_SIG_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMT_SIG_SCHEME_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_SIG_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_ENC_SCHEME_OAEP_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_ENC_SCHEME_OAEP_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_ENC_SCHEME_OAEP_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_ENC_SCHEME_OAEP_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_ENC_SCHEME_RSAES_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_ENC_SCHEME_RSAES_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_ENC_SCHEME_RSAES_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_ENC_SCHEME_RSAES_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_KEY_SCHEME_ECDH_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_KEY_SCHEME_ECDH_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_KEY_SCHEME_ECDH_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_KEY_SCHEME_ECDH_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_KEY_SCHEME_ECMQV_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_KEY_SCHEME_ECMQV_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_KEY_SCHEME_ECMQV_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_KEY_SCHEME_ECMQV_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_KDF_SCHEME_MGF1_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_KDF_SCHEME_MGF1_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_KDF_SCHEME_MGF1_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_KDF_SCHEME_MGF1_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_KDF_SCHEME_KDF1_SP800_56A_Unmarshal(target, buffer, size)\t\\\n    Unmarshal(TPMS_KDF_SCHEME_KDF1_SP800_56A_MARSHAL_REF, (target), (buffer), \\\n\t      (size))\n#define TPMS_KDF_SCHEME_KDF1_SP800_56A_Marshal(source, buffer, size)\t\\\n    Marshal(TPMS_KDF_SCHEME_KDF1_SP800_56A_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_KDF_SCHEME_KDF2_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_KDF_SCHEME_KDF2_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_KDF_SCHEME_KDF2_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_KDF_SCHEME_KDF2_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_KDF_SCHEME_KDF1_SP800_108_Unmarshal(target, buffer, size)\t\\\n    Unmarshal(TPMS_KDF_SCHEME_KDF1_SP800_108_MARSHAL_REF, (target), (buffer), \\\n\t      (size))\n#define TPMS_KDF_SCHEME_KDF1_SP800_108_Marshal(source, buffer, size)\t\\\n    Marshal(TPMS_KDF_SCHEME_KDF1_SP800_108_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_KDF_SCHEME_Unmarshal(target, buffer, size, selector)\t\\\n    UnmarshalUnion(TPMU_KDF_SCHEME_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_KDF_SCHEME_Marshal(source, buffer, size, selector)\t\t\\\n    MarshalUnion(TPMU_KDF_SCHEME_MARSHAL_REF, (source), (buffer), (size), \\\n\t\t (selector))\n#define TPMT_KDF_SCHEME_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMT_KDF_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMT_KDF_SCHEME_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_KDF_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_ASYM_SCHEME_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ALG_ASYM_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMI_ALG_ASYM_SCHEME_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ALG_ASYM_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_ASYM_SCHEME_Unmarshal(target, buffer, size, selector)\t\\\n    UnmarshalUnion(TPMU_ASYM_SCHEME_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_ASYM_SCHEME_Marshal(source, buffer, size, selector)\t\\\n    MarshalUnion(TPMU_ASYM_SCHEME_MARSHAL_REF, (source), (buffer), (size), \\\n\t\t (selector))\n#define TPMI_ALG_RSA_SCHEME_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ALG_RSA_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target),\t\\\n\t      (buffer), (size))\n#define TPMI_ALG_RSA_SCHEME_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ALG_RSA_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMT_RSA_SCHEME_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMT_RSA_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMT_RSA_SCHEME_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_RSA_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_RSA_DECRYPT_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ALG_RSA_DECRYPT_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMI_ALG_RSA_DECRYPT_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ALG_RSA_DECRYPT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMT_RSA_DECRYPT_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMT_RSA_DECRYPT_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMT_RSA_DECRYPT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_RSA_DECRYPT_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_PUBLIC_KEY_RSA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_PUBLIC_KEY_RSA_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_PUBLIC_KEY_RSA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM2B_PUBLIC_KEY_RSA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_RSA_KEY_BITS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMI_RSA_KEY_BITS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_RSA_KEY_BITS_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_RSA_KEY_BITS_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_PRIVATE_KEY_RSA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_PRIVATE_KEY_RSA_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_PRIVATE_KEY_RSA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM2B_PRIVATE_KEY_RSA_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_ECC_PARAMETER_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_ECC_PARAMETER_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_ECC_PARAMETER_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM2B_ECC_PARAMETER_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_ECC_POINT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_ECC_POINT_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_ECC_POINT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_ECC_POINT_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_ECC_POINT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_ECC_POINT_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_ECC_POINT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_ECC_POINT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_ECC_SCHEME_Unmarshal(target, buffer, size, flag)\t\\\n    Unmarshal(TPMI_ALG_ECC_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target),\t\\\n\t      (buffer), (size))\n#define TPMI_ALG_ECC_SCHEME_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMI_ALG_ECC_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ECC_CURVE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_ECC_CURVE_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_ECC_CURVE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_ECC_CURVE_MARSHAL_REF, (source), (buffer), (size))\n#define TPMT_ECC_SCHEME_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMT_ECC_SCHEME_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), \\\n\t      (buffer), (size))\n#define TPMT_ECC_SCHEME_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_ECC_SCHEME_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_ALGORITHM_DETAIL_ECC_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_ALGORITHM_DETAIL_ECC_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIGNATURE_RSA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIGNATURE_RSA_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIGNATURE_RSA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIGNATURE_RSA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIGNATURE_RSASSA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIGNATURE_RSASSA_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIGNATURE_RSASSA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIGNATURE_RSASSA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIGNATURE_RSAPSS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIGNATURE_RSAPSS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIGNATURE_RSAPSS_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIGNATURE_RSAPSS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIGNATURE_ECC_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIGNATURE_ECC_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIGNATURE_ECC_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIGNATURE_ECC_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIGNATURE_ECDAA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIGNATURE_ECDAA_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIGNATURE_ECDAA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIGNATURE_ECDAA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIGNATURE_ECDSA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIGNATURE_ECDSA_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIGNATURE_ECDSA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIGNATURE_ECDSA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIGNATURE_SM2_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_SIGNATURE_SM2_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIGNATURE_SM2_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIGNATURE_SM2_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_SIGNATURE_ECSCHNORR_Unmarshal(target, buffer, size)\t\\\n    Unmarshal(TPMS_SIGNATURE_ECSCHNORR_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_SIGNATURE_ECSCHNORR_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_SIGNATURE_ECSCHNORR_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_SIGNATURE_Unmarshal(target, buffer, size, selector)\t\\\n    UnmarshalUnion(TPMU_SIGNATURE_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_SIGNATURE_Marshal(source, buffer, size, selector)\t\t\\\n    MarshalUnion(TPMU_SIGNATURE_MARSHAL_REF, (source), (buffer), (size), (selector))\n#define TPMT_SIGNATURE_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMT_SIGNATURE_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMT_SIGNATURE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_SIGNATURE_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_ENCRYPTED_SECRET_Unmarshal(target, buffer, size, selector)\t\\\n    UnmarshalUnion(TPMU_ENCRYPTED_SECRET_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_ENCRYPTED_SECRET_Marshal(source, buffer, size, selector)\t\\\n    MarshalUnion(TPMU_ENCRYPTED_SECRET_MARSHAL_REF, (source), (buffer), (size),\t\\\n\t\t (selector))\n#define TPM2B_ENCRYPTED_SECRET_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_ENCRYPTED_SECRET_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_ENCRYPTED_SECRET_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM2B_ENCRYPTED_SECRET_MARSHAL_REF, (source), (buffer), (size))\n#define TPMI_ALG_PUBLIC_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMI_ALG_PUBLIC_MARSHAL_REF, (target), (buffer), (size))\n#define TPMI_ALG_PUBLIC_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMI_ALG_PUBLIC_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_PUBLIC_ID_Unmarshal(target, buffer, size, selector)\t\\\n    UnmarshalUnion(TPMU_PUBLIC_ID_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_PUBLIC_ID_Marshal(source, buffer, size, selector)\t\t\\\n    MarshalUnion(TPMU_PUBLIC_ID_MARSHAL_REF, (source), (buffer), (size), (selector))\n#define TPMS_KEYEDHASH_PARMS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_KEYEDHASH_PARMS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_KEYEDHASH_PARMS_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_KEYEDHASH_PARMS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_RSA_PARMS_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_RSA_PARMS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_RSA_PARMS_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_RSA_PARMS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_ECC_PARMS_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_ECC_PARMS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_ECC_PARMS_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_ECC_PARMS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_PUBLIC_PARMS_Unmarshal(target, buffer, size, selector)\t\\\n    UnmarshalUnion(TPMU_PUBLIC_PARMS_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_PUBLIC_PARMS_Marshal(source, buffer, size, selector)\t\\\n    MarshalUnion(TPMU_PUBLIC_PARMS_MARSHAL_REF, (source), (buffer), (size), \\\n\t\t (selector))\n#define TPMT_PUBLIC_PARMS_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMT_PUBLIC_PARMS_MARSHAL_REF, (target), (buffer), (size))\n#define TPMT_PUBLIC_PARMS_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_PUBLIC_PARMS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMT_PUBLIC_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPMT_PUBLIC_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPMT_PUBLIC_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_PUBLIC_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_PUBLIC_Unmarshal(target, buffer, size, flag)\t\t\\\n    Unmarshal(TPM2B_PUBLIC_MARSHAL_REF|(flag ? NULL_FLAG : 0), (target), (buffer), \\\n\t      (size))\n#define TPM2B_PUBLIC_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_PUBLIC_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_TEMPLATE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_TEMPLATE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_TEMPLATE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_TEMPLATE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_PRIVATE_VENDOR_SPECIFIC_Unmarshal(target, buffer, size)\t\\\n    Unmarshal(TPM2B_PRIVATE_VENDOR_SPECIFIC_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_PRIVATE_VENDOR_SPECIFIC_Marshal(source, buffer, size)\t\\\n    Marshal(TPM2B_PRIVATE_VENDOR_SPECIFIC_MARSHAL_REF, (source), (buffer), (size))\n#define TPMU_SENSITIVE_COMPOSITE_Unmarshal(target, buffer, size, selector) \\\n    UnmarshalUnion(TPMU_SENSITIVE_COMPOSITE_MARSHAL_REF, (target), (buffer), (size), \\\n\t\t   (selector))\n#define TPMU_SENSITIVE_COMPOSITE_Marshal(source, buffer, size, selector) \\\n    MarshalUnion(TPMU_SENSITIVE_COMPOSITE_MARSHAL_REF, (source), (buffer), (size), \\\n\t\t (selector))\n#define TPMT_SENSITIVE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMT_SENSITIVE_MARSHAL_REF, (target), (buffer), (size))\n#define TPMT_SENSITIVE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMT_SENSITIVE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_SENSITIVE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_SENSITIVE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_SENSITIVE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_SENSITIVE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_PRIVATE_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_PRIVATE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_PRIVATE_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_PRIVATE_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_ID_OBJECT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_ID_OBJECT_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_ID_OBJECT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_ID_OBJECT_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_NV_INDEX_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM_NV_INDEX_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_NV_PIN_COUNTER_PARAMETERS_Unmarshal(target, buffer, size)\t\\\n    Unmarshal(TPMS_NV_PIN_COUNTER_PARAMETERS_MARSHAL_REF, (target), (buffer), \\\n\t      (size))\n#define TPMS_NV_PIN_COUNTER_PARAMETERS_Marshal(source, buffer, size)\t\\\n    Marshal(TPMS_NV_PIN_COUNTER_PARAMETERS_MARSHAL_REF, (source), (buffer), (size))\n#define TPMA_NV_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPMA_NV_MARSHAL_REF, (target), (buffer), (size))\n#define TPMA_NV_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPMA_NV_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_NV_PUBLIC_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_NV_PUBLIC_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_NV_PUBLIC_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_NV_PUBLIC_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_NV_PUBLIC_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPM2B_NV_PUBLIC_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_NV_PUBLIC_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPM2B_NV_PUBLIC_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_CONTEXT_SENSITIVE_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_CONTEXT_SENSITIVE_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_CONTEXT_SENSITIVE_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM2B_CONTEXT_SENSITIVE_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_CONTEXT_DATA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPMS_CONTEXT_DATA_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_CONTEXT_DATA_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_CONTEXT_DATA_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_CONTEXT_DATA_Unmarshal(target, buffer, size)\t\t\\\n    Unmarshal(TPM2B_CONTEXT_DATA_MARSHAL_REF, (target), (buffer), (size))\n#define TPM2B_CONTEXT_DATA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM2B_CONTEXT_DATA_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_CONTEXT_Unmarshal(target, buffer, size)\t\t\t\\\n    Unmarshal(TPMS_CONTEXT_MARSHAL_REF, (target), (buffer), (size))\n#define TPMS_CONTEXT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_CONTEXT_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_CREATION_DATA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPMS_CREATION_DATA_MARSHAL_REF, (source), (buffer), (size))\n#define TPM2B_CREATION_DATA_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPM2B_CREATION_DATA_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_AT_Unmarshal(target, buffer, size)\t\t\t\t\\\n    Unmarshal(TPM_AT_MARSHAL_REF, (target), (buffer), (size))\n#define TPM_AT_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_AT_MARSHAL_REF, (source), (buffer), (size))\n#define TPM_AE_Marshal(source, buffer, size)\t\t\t\t\\\n    Marshal(TPM_AE_MARSHAL_REF, (source), (buffer), (size))\n#define TPMS_AC_OUTPUT_Marshal(source, buffer, size)\t\t\t\\\n    Marshal(TPMS_AC_OUTPUT_MARSHAL_REF, (source), (buffer), (size))\n#define TPML_AC_CAPABILITIES_Marshal(source, buffer, size)\t\t\\\n    Marshal(TPML_AC_CAPABILITIES_MARSHAL_REF, (source), (buffer), (size))\n\n#endif // _TABLE_MARSHAL_DEFINES_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TableMarshalTypes.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tTable Marshal Types\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// clang-format off\n/*(Auto-generated)\n *  Created by NewMarshal; Version 1.4 Apr 7, 2019\n *  Date: Mar  6, 2020  Time: 01:50:10PM\n */\n\n#ifndef _TABLE_MARSHAL_TYPES_H_\n#define _TABLE_MARSHAL_TYPES_H_\n\ntypedef UINT16      marshalIndex_t;\n\n//*** Structure Entries\n// A structure contains a list of elements to unmarshal. Each of the entries is a\n// UINT16. The structure descriptor is:\n\n// The 'values' array contains indicators for the things to marshal. The 'elements'\n// parameter indicates how many different entities are unmarshaled. This number\n// nominally corresponds to the number of rows in the Part 2 table that describes\n// the structure (the number of rows minus the title row and any error code rows).\n\n// A schematic of a simple structure entry is shown here but the values are not\n// actually in a structure. As shown, the third value is the offset in the structure\n// where the value is placed when unmarshaled, or fetched from when marshaling. This\n// is sufficient when the element type indicated by 'index' is always a simple type\n// and never a union or array.This is just shown for illustrative purposes.\ntypedef struct simpleStructureEntry_t {\n    UINT16          qualifiers;         // indicates the type of entry (array, union\n    // etc.)\n    marshalIndex_t  index;              // the index into the appropriate array of\n    //  the descriptor of this type\n    UINT16          offset;             // where this comes from or is placed\n} simpleStructureEntry_t;\n\ntypedef const struct UintMarshal_mst\n{\n    UINT8           marshalType;        // UINT_MTYPE\n    UINT8           modifiers;          // size and signed indicator.\n} UintMarshal_mst;\n\ntypedef struct UnionMarshal_mst\n{\n    UINT8           countOfselectors;\n    UINT8           modifiers;          // NULL_SELECTOR\n    UINT16          offsetOfUnmarshalTypes;\n    UINT32          selectors[1];\n    //    UINT16          marshalingTypes[1]; // This is not part of the prototypical\n    //    entry. It is here to show where the\n    //    marshaling types will be in a union\n} UnionMarshal_mst;\n\ntypedef struct NullUnionMarshal_mst\n{\n    UINT8           count;\n} NullUnionMarshal_mst;\n\ntypedef struct MarshalHeader_mst\n{\n    UINT8           marshalType;        // VALUES_MTYPE\n    UINT8           modifiers;\n    UINT8           errorCode;\n} MarshalHeader_mst;\n\ntypedef const struct ArrayMarshal_mst   // used in a structure\n{\n    marshalIndex_t  type;\n    UINT16          stride;\n} ArrayMarshal_mst;\n\ntypedef const struct StructMarshal_mst\n{\n    UINT8           marshalType;        // STRUCTURE_MTYPE\n    UINT8           elements;\n    UINT16          values[1];          // three times elements\n} StructMarshal_mst;\n\ntypedef const struct ValuesMarshal_mst\n{\n    UINT8           marshalType;        // VALUES_MTYPE\n    UINT8           modifiers;\n    UINT8           errorCode;\n    UINT8           ranges;\n    UINT8           singles;\n    UINT32          values[1];\n} ValuesMarshal_mst;\n\ntypedef const struct TableMarshal_mst\n{\n    UINT8           marshalType;        // TABLE_MTYPE\n    UINT8           modifiers;\n    UINT8           errorCode;\n    UINT8           singles;\n    UINT32          values[1];\n} TableMarshal_mst;\n\ntypedef const struct MinMaxMarshal_mst\n{\n    UINT8           marshalType;        // MIN_MAX_MTYPE\n    UINT8           modifiers;\n    UINT8           errorCode;\n    UINT32          values[2];\n} MinMaxMarshal_mst;\n\ntypedef const struct Tpm2bMarshal_mst\n{\n    UINT8           unmarshalType;      // TPM2B_MTYPE\n    UINT16          sizeIndex;          // reference to type for this size value\n} Tpm2bMarshal_mst;\n\ntypedef const struct Tpm2bsMarshal_mst\n{\n    UINT8           unmarshalType;      // TPM2BS_MTYPE\n    UINT8           modifiers;          // size= and offset (2 - 7)\n    UINT16          sizeIndex;          // index of the size value;\n    UINT16          dataIndex;          // the structure\n} Tpm2bsMarshal_mst;\n\ntypedef const struct ListMarshal_mst\n{\n    UINT8           unmarshalType;      // LIST_MTYPE (for TPML)\n    UINT8           modifiers;          // size offset 2-7\n    UINT16          sizeIndex;          // reference to the minmax structure that\n    //      unmarshals the size parameter\n    UINT16          arrayRef;           // reference to an array definition (type\n    //  and stride)\n} ListMarshal_mst;\n\ntypedef const struct AttributesMarshal_mst\n{\n    UINT8           unmarashalType;     // ATTRIBUTE_MTYPE\n    UINT8           modifiers;          // size (ONE_BYTES, TWO_BYTES, or FOUR_BYTES\n    UINT32          attributeMask;      // the values that must be zero.\n} AttributesMarshal_mst;\n\ntypedef const struct CompositeMarshal_mst\n{\n    UINT8           unmashalType;       // COMPOSITE_MTYPE\n    UINT8           modifiers;          // number of entries and size\n    marshalIndex_t  types[1];           // array of unmarshaling types\n} CompositeMarshal_mst;\n\ntypedef const struct TPM_ECC_CURVE_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPM_ECC_CURVE_mst;\n\ntypedef const struct TPM_CLOCK_ADJUST_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} TPM_CLOCK_ADJUST_mst;\n\ntypedef const struct TPM_EO_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} TPM_EO_mst;\n\ntypedef const struct TPM_SU_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[2];\n} TPM_SU_mst;\n\ntypedef const struct TPM_SE_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[3];\n} TPM_SE_mst;\n\ntypedef const struct TPM_CAP_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[3];\n} TPM_CAP_mst;\n\ntypedef const struct TPMI_YES_NO_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[2];\n} TPMI_YES_NO_mst;\n\ntypedef const struct TPMI_DH_OBJECT_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[5];\n} TPMI_DH_OBJECT_mst;\n\ntypedef const struct TPMI_DH_PARENT_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[20];\n} TPMI_DH_PARENT_mst;\n\ntypedef const struct TPMI_DH_PERSISTENT_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} TPMI_DH_PERSISTENT_mst;\n\ntypedef const struct TPMI_DH_ENTITY_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[15];\n} TPMI_DH_ENTITY_mst;\n\ntypedef const struct TPMI_DH_PCR_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[3];\n} TPMI_DH_PCR_mst;\n\ntypedef const struct TPMI_SH_AUTH_SESSION_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[5];\n} TPMI_SH_AUTH_SESSION_mst;\n\ntypedef const struct TPMI_SH_HMAC_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} TPMI_SH_HMAC_mst;\n\ntypedef const struct TPMI_SH_POLICY_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} TPMI_SH_POLICY_mst;\n\ntypedef const struct TPMI_DH_CONTEXT_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[6];\n} TPMI_DH_CONTEXT_mst;\n\ntypedef const struct TPMI_DH_SAVED_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[7];\n} TPMI_DH_SAVED_mst;\n\ntypedef const struct TPMI_RH_HIERARCHY_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[16];\n} TPMI_RH_HIERARCHY_mst;\n\ntypedef const struct TPMI_RH_ENABLES_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[5];\n} TPMI_RH_ENABLES_mst;\n\ntypedef const struct TPMI_RH_HIERARCHY_AUTH_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[4];\n} TPMI_RH_HIERARCHY_AUTH_mst;\n\ntypedef const struct TPMI_RH_HIERARCHY_POLICY_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[6];\n} TPMI_RH_HIERARCHY_POLICY_mst;\n\ntypedef const struct TPMI_RH_BASE_HIERARCHY_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[3];\n} TPMI_RH_BASE_HIERARCHY_mst;\n\ntypedef const struct TPMI_RH_PLATFORM_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[1];\n} TPMI_RH_PLATFORM_mst;\n\ntypedef const struct TPMI_RH_OWNER_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[2];\n} TPMI_RH_OWNER_mst;\n\ntypedef const struct TPMI_RH_ENDORSEMENT_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[2];\n} TPMI_RH_ENDORSEMENT_mst;\n\ntypedef const struct TPMI_RH_PROVISION_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[2];\n} TPMI_RH_PROVISION_mst;\n\ntypedef const struct TPMI_RH_CLEAR_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[2];\n} TPMI_RH_CLEAR_mst;\n\ntypedef const struct TPMI_RH_NV_AUTH_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[4];\n} TPMI_RH_NV_AUTH_mst;\n\ntypedef const struct TPMI_RH_LOCKOUT_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[1];\n} TPMI_RH_LOCKOUT_mst;\n\ntypedef const struct TPMI_RH_NV_INDEX_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} TPMI_RH_NV_INDEX_mst;\n\ntypedef const struct TPMI_RH_AC_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} TPMI_RH_AC_mst;\n\ntypedef const struct TPMI_RH_ACT_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} TPMI_RH_ACT_mst;\n\ntypedef const struct TPMI_ALG_HASH_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[5];\n} TPMI_ALG_HASH_mst;\n\ntypedef const struct TPMI_ALG_ASYM_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[5];\n} TPMI_ALG_ASYM_mst;\n\ntypedef const struct TPMI_ALG_SYM_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[5];\n} TPMI_ALG_SYM_mst;\n\ntypedef const struct TPMI_ALG_SYM_OBJECT_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[5];\n} TPMI_ALG_SYM_OBJECT_mst;\n\ntypedef const struct TPMI_ALG_SYM_MODE_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_SYM_MODE_mst;\n\ntypedef const struct TPMI_ALG_KDF_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_KDF_mst;\n\ntypedef const struct TPMI_ALG_SIG_SCHEME_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_SIG_SCHEME_mst;\n\ntypedef const struct TPMI_ECC_KEY_EXCHANGE_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ECC_KEY_EXCHANGE_mst;\n\ntypedef const struct TPMI_ST_COMMAND_TAG_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[2];\n} TPMI_ST_COMMAND_TAG_mst;\n\ntypedef const struct TPMI_ALG_MAC_SCHEME_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[5];\n} TPMI_ALG_MAC_SCHEME_mst;\n\ntypedef const struct TPMI_ALG_CIPHER_MODE_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_CIPHER_MODE_mst;\n\ntypedef const struct TPMS_EMPTY_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[3];\n} TPMS_EMPTY_mst;\n\ntypedef const struct TPMS_ALGORITHM_DESCRIPTION_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_ALGORITHM_DESCRIPTION_mst;\n\ntypedef struct TPMU_HA_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[9];\n    UINT16        marshalingTypes[9];\n} TPMU_HA_mst;\n\ntypedef const struct TPMT_HA_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMT_HA_mst;\n\ntypedef const struct TPMS_PCR_SELECT_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_PCR_SELECT_mst;\n\ntypedef const struct TPMS_PCR_SELECTION_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMS_PCR_SELECTION_mst;\n\ntypedef const struct TPMT_TK_CREATION_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMT_TK_CREATION_mst;\n\ntypedef const struct TPMT_TK_VERIFIED_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMT_TK_VERIFIED_mst;\n\ntypedef const struct TPMT_TK_AUTH_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMT_TK_AUTH_mst;\n\ntypedef const struct TPMT_TK_HASHCHECK_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMT_TK_HASHCHECK_mst;\n\ntypedef const struct TPMS_ALG_PROPERTY_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_ALG_PROPERTY_mst;\n\ntypedef const struct TPMS_TAGGED_PROPERTY_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_TAGGED_PROPERTY_mst;\n\ntypedef const struct TPMS_TAGGED_PCR_SELECT_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMS_TAGGED_PCR_SELECT_mst;\n\ntypedef const struct TPMS_TAGGED_POLICY_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_TAGGED_POLICY_mst;\n\ntypedef const struct TPMS_ACT_DATA_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMS_ACT_DATA_mst;\n\ntypedef struct TPMU_CAPABILITIES_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[11];\n    UINT16        marshalingTypes[11];\n} TPMU_CAPABILITIES_mst;\n\ntypedef const struct TPMS_CAPABILITY_DATA_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_CAPABILITY_DATA_mst;\n\ntypedef const struct TPMS_CLOCK_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[12];\n} TPMS_CLOCK_INFO_mst;\n\ntypedef const struct TPMS_TIME_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_TIME_INFO_mst;\n\ntypedef const struct TPMS_TIME_ATTEST_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_TIME_ATTEST_INFO_mst;\n\ntypedef const struct TPMS_CERTIFY_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_CERTIFY_INFO_mst;\n\ntypedef const struct TPMS_QUOTE_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_QUOTE_INFO_mst;\n\ntypedef const struct TPMS_COMMAND_AUDIT_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[12];\n} TPMS_COMMAND_AUDIT_INFO_mst;\n\ntypedef const struct TPMS_SESSION_AUDIT_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_SESSION_AUDIT_INFO_mst;\n\ntypedef const struct TPMS_CREATION_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_CREATION_INFO_mst;\n\ntypedef const struct TPMS_NV_CERTIFY_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMS_NV_CERTIFY_INFO_mst;\n\ntypedef const struct TPMS_NV_DIGEST_CERTIFY_INFO_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_NV_DIGEST_CERTIFY_INFO_mst;\n\ntypedef const struct TPMI_ST_ATTEST_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         ranges;\n    UINT8         singles;\n    UINT32        values[3];\n} TPMI_ST_ATTEST_mst;\n\ntypedef struct TPMU_ATTEST_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[8];\n    UINT16        marshalingTypes[8];\n} TPMU_ATTEST_mst;\n\ntypedef const struct TPMS_ATTEST_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[21];\n} TPMS_ATTEST_mst;\n\ntypedef const struct TPMS_AUTH_COMMAND_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[12];\n} TPMS_AUTH_COMMAND_mst;\n\ntypedef const struct TPMS_AUTH_RESPONSE_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMS_AUTH_RESPONSE_mst;\n\ntypedef const struct TPMI_AES_KEY_BITS_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[3];\n} TPMI_AES_KEY_BITS_mst;\n\ntypedef const struct TPMI_SM4_KEY_BITS_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[1];\n} TPMI_SM4_KEY_BITS_mst;\n\ntypedef const struct TPMI_CAMELLIA_KEY_BITS_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[3];\n} TPMI_CAMELLIA_KEY_BITS_mst;\n\ntypedef struct TPMU_SYM_KEY_BITS_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[6];\n    UINT16        marshalingTypes[6];\n} TPMU_SYM_KEY_BITS_mst;\n\ntypedef struct TPMU_SYM_MODE_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[6];\n    UINT16        marshalingTypes[6];\n} TPMU_SYM_MODE_mst;\n\ntypedef const struct TPMT_SYM_DEF_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMT_SYM_DEF_mst;\n\ntypedef const struct TPMT_SYM_DEF_OBJECT_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMT_SYM_DEF_OBJECT_mst;\n\ntypedef const struct TPMS_SYMCIPHER_PARMS_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[3];\n} TPMS_SYMCIPHER_PARMS_mst;\n\ntypedef const struct TPMS_DERIVE_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_DERIVE_mst;\n\ntypedef const struct TPMS_SENSITIVE_CREATE_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_SENSITIVE_CREATE_mst;\n\ntypedef const struct TPMS_SCHEME_HASH_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[3];\n} TPMS_SCHEME_HASH_mst;\n\ntypedef const struct TPMS_SCHEME_ECDAA_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_SCHEME_ECDAA_mst;\n\ntypedef const struct TPMI_ALG_KEYEDHASH_SCHEME_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_KEYEDHASH_SCHEME_mst;\n\ntypedef const struct TPMS_SCHEME_XOR_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_SCHEME_XOR_mst;\n\ntypedef struct TPMU_SCHEME_KEYEDHASH_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[3];\n    UINT16        marshalingTypes[3];\n} TPMU_SCHEME_KEYEDHASH_mst;\n\ntypedef const struct TPMT_KEYEDHASH_SCHEME_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMT_KEYEDHASH_SCHEME_mst;\n\ntypedef struct TPMU_SIG_SCHEME_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[8];\n    UINT16        marshalingTypes[8];\n} TPMU_SIG_SCHEME_mst;\n\ntypedef const struct TPMT_SIG_SCHEME_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMT_SIG_SCHEME_mst;\n\ntypedef struct TPMU_KDF_SCHEME_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[5];\n    UINT16        marshalingTypes[5];\n} TPMU_KDF_SCHEME_mst;\n\ntypedef const struct TPMT_KDF_SCHEME_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMT_KDF_SCHEME_mst;\n\ntypedef const struct TPMI_ALG_ASYM_SCHEME_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_ASYM_SCHEME_mst;\n\ntypedef struct TPMU_ASYM_SCHEME_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[11];\n    UINT16        marshalingTypes[11];\n} TPMU_ASYM_SCHEME_mst;\n\ntypedef const struct TPMI_ALG_RSA_SCHEME_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_RSA_SCHEME_mst;\n\ntypedef const struct TPMT_RSA_SCHEME_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMT_RSA_SCHEME_mst;\n\ntypedef const struct TPMI_ALG_RSA_DECRYPT_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_RSA_DECRYPT_mst;\n\ntypedef const struct TPMT_RSA_DECRYPT_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMT_RSA_DECRYPT_mst;\n\ntypedef const struct TPMI_RSA_KEY_BITS_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[3];\n} TPMI_RSA_KEY_BITS_mst;\n\ntypedef const struct TPMS_ECC_POINT_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_ECC_POINT_mst;\n\ntypedef const struct TPMI_ALG_ECC_SCHEME_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_ECC_SCHEME_mst;\n\ntypedef const struct TPMI_ECC_CURVE_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[3];\n} TPMI_ECC_CURVE_mst;\n\ntypedef const struct TPMT_ECC_SCHEME_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMT_ECC_SCHEME_mst;\n\ntypedef const struct TPMS_ALGORITHM_DETAIL_ECC_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[33];\n} TPMS_ALGORITHM_DETAIL_ECC_mst;\n\ntypedef const struct TPMS_SIGNATURE_RSA_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_SIGNATURE_RSA_mst;\n\ntypedef const struct TPMS_SIGNATURE_ECC_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[9];\n} TPMS_SIGNATURE_ECC_mst;\n\ntypedef struct TPMU_SIGNATURE_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[8];\n    UINT16        marshalingTypes[8];\n} TPMU_SIGNATURE_mst;\n\ntypedef const struct TPMT_SIGNATURE_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMT_SIGNATURE_mst;\n\ntypedef struct TPMU_ENCRYPTED_SECRET_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[4];\n    UINT16        marshalingTypes[4];\n} TPMU_ENCRYPTED_SECRET_mst;\n\ntypedef const struct TPMI_ALG_PUBLIC_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[4];\n} TPMI_ALG_PUBLIC_mst;\n\ntypedef struct TPMU_PUBLIC_ID_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[4];\n    UINT16        marshalingTypes[4];\n} TPMU_PUBLIC_ID_mst;\n\ntypedef const struct TPMS_KEYEDHASH_PARMS_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[3];\n} TPMS_KEYEDHASH_PARMS_mst;\n\ntypedef const struct TPMS_RSA_PARMS_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[12];\n} TPMS_RSA_PARMS_mst;\n\ntypedef const struct TPMS_ECC_PARMS_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[12];\n} TPMS_ECC_PARMS_mst;\n\ntypedef struct TPMU_PUBLIC_PARMS_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[4];\n    UINT16        marshalingTypes[4];\n} TPMU_PUBLIC_PARMS_mst;\n\ntypedef const struct TPMT_PUBLIC_PARMS_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMT_PUBLIC_PARMS_mst;\n\ntypedef const struct TPMT_PUBLIC_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[18];\n} TPMT_PUBLIC_mst;\n\ntypedef struct TPMU_SENSITIVE_COMPOSITE_mst\n{\n    BYTE            countOfselectors;\n    BYTE            modifiers;\n    UINT16        offsetOfUnmarshalTypes;\n    UINT32        selectors[4];\n    UINT16        marshalingTypes[4];\n} TPMU_SENSITIVE_COMPOSITE_mst;\n\ntypedef const struct TPMT_SENSITIVE_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[12];\n} TPMT_SENSITIVE_mst;\n\ntypedef const struct TPMS_NV_PIN_COUNTER_PARAMETERS_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_NV_PIN_COUNTER_PARAMETERS_mst;\n\ntypedef const struct TPMS_NV_PUBLIC_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[15];\n} TPMS_NV_PUBLIC_mst;\n\ntypedef const struct TPMS_CONTEXT_DATA_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_CONTEXT_DATA_mst;\n\ntypedef const struct TPMS_CONTEXT_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[12];\n} TPMS_CONTEXT_mst;\n\ntypedef const struct TPMS_CREATION_DATA_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[21];\n} TPMS_CREATION_DATA_mst;\n\ntypedef const struct TPM_AT_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[4];\n} TPM_AT_mst;\n\ntypedef const struct TPMS_AC_OUTPUT_mst\n{\n    UINT8     marshalType;\n    UINT8     elements;\n    UINT16    values[6];\n} TPMS_AC_OUTPUT_mst;\n\ntypedef const struct Type02_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type02_mst;\n\ntypedef const struct Type03_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type03_mst;\n\ntypedef const struct Type04_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type04_mst;\n\ntypedef const struct Type06_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type06_mst;\n\ntypedef const struct Type08_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type08_mst;\n\ntypedef const struct Type10_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[1];\n} Type10_mst;\n\ntypedef const struct Type11_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[1];\n} Type11_mst;\n\ntypedef const struct Type12_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[2];\n} Type12_mst;\n\ntypedef const struct Type13_mst {\n    UINT8         marshalType;\n    UINT8         modifiers;\n    UINT8         errorCode;\n    UINT8         entries;\n    UINT32        values[1];\n} Type13_mst;\n\ntypedef const struct Type15_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type15_mst;\n\ntypedef const struct Type17_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type17_mst;\n\ntypedef const struct Type18_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type18_mst;\n\ntypedef const struct Type19_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type19_mst;\n\ntypedef const struct Type20_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type20_mst;\n\ntypedef const struct Type22_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type22_mst;\n\ntypedef const struct Type23_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type23_mst;\n\ntypedef const struct Type24_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type24_mst;\n\ntypedef const struct Type25_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type25_mst;\n\ntypedef const struct Type26_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type26_mst;\n\ntypedef const struct Type27_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type27_mst;\n\ntypedef const struct Type29_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type29_mst;\n\ntypedef const struct Type30_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type30_mst;\n\ntypedef const struct Type33_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type33_mst;\n\ntypedef const struct Type34_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type34_mst;\n\ntypedef const struct Type35_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type35_mst;\n\ntypedef const struct Type38_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type38_mst;\n\ntypedef const struct Type41_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type41_mst;\n\ntypedef const struct Type42_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type42_mst;\n\ntypedef const struct Type44_mst {\n    UINT8       marshalType;\n    UINT8       modifiers;\n    UINT8       errorCode;\n    UINT32      values[2];\n} Type44_mst;\n\n// This structure combines all the individual marshaling structures to build\n// something that can be referenced by offset rather than full address\ntypedef const struct MarshalData_st {\n    UintMarshal_mst                 UINT8_DATA;\n    UintMarshal_mst                 UINT16_DATA;\n    UintMarshal_mst                 UINT32_DATA;\n    UintMarshal_mst                 UINT64_DATA;\n    UintMarshal_mst                 INT8_DATA;\n    UintMarshal_mst                 INT16_DATA;\n    UintMarshal_mst                 INT32_DATA;\n    UintMarshal_mst                 INT64_DATA;\n    UintMarshal_mst                 UINT0_DATA;\n    TPM_ECC_CURVE_mst               TPM_ECC_CURVE_DATA;\n    TPM_CLOCK_ADJUST_mst            TPM_CLOCK_ADJUST_DATA;\n    TPM_EO_mst                      TPM_EO_DATA;\n    TPM_SU_mst                      TPM_SU_DATA;\n    TPM_SE_mst                      TPM_SE_DATA;\n    TPM_CAP_mst                     TPM_CAP_DATA;\n    AttributesMarshal_mst           TPMA_ALGORITHM_DATA;\n    AttributesMarshal_mst           TPMA_OBJECT_DATA;\n    AttributesMarshal_mst           TPMA_SESSION_DATA;\n    AttributesMarshal_mst           TPMA_ACT_DATA;\n    TPMI_YES_NO_mst                 TPMI_YES_NO_DATA;\n    TPMI_DH_OBJECT_mst              TPMI_DH_OBJECT_DATA;\n    TPMI_DH_PARENT_mst              TPMI_DH_PARENT_DATA;\n    TPMI_DH_PERSISTENT_mst          TPMI_DH_PERSISTENT_DATA;\n    TPMI_DH_ENTITY_mst              TPMI_DH_ENTITY_DATA;\n    TPMI_DH_PCR_mst                 TPMI_DH_PCR_DATA;\n    TPMI_SH_AUTH_SESSION_mst        TPMI_SH_AUTH_SESSION_DATA;\n    TPMI_SH_HMAC_mst                TPMI_SH_HMAC_DATA;\n    TPMI_SH_POLICY_mst              TPMI_SH_POLICY_DATA;\n    TPMI_DH_CONTEXT_mst             TPMI_DH_CONTEXT_DATA;\n    TPMI_DH_SAVED_mst               TPMI_DH_SAVED_DATA;\n    TPMI_RH_HIERARCHY_mst           TPMI_RH_HIERARCHY_DATA;\n    TPMI_RH_ENABLES_mst             TPMI_RH_ENABLES_DATA;\n    TPMI_RH_HIERARCHY_AUTH_mst      TPMI_RH_HIERARCHY_AUTH_DATA;\n    TPMI_RH_HIERARCHY_POLICY_mst    TPMI_RH_HIERARCHY_POLICY_DATA;\n    TPMI_RH_BASE_HIERARCHY_mst      TPMI_RH_BASE_HIERARCHY_DATA;\n    TPMI_RH_PLATFORM_mst            TPMI_RH_PLATFORM_DATA;\n    TPMI_RH_OWNER_mst               TPMI_RH_OWNER_DATA;\n    TPMI_RH_ENDORSEMENT_mst         TPMI_RH_ENDORSEMENT_DATA;\n    TPMI_RH_PROVISION_mst           TPMI_RH_PROVISION_DATA;\n    TPMI_RH_CLEAR_mst               TPMI_RH_CLEAR_DATA;\n    TPMI_RH_NV_AUTH_mst             TPMI_RH_NV_AUTH_DATA;\n    TPMI_RH_LOCKOUT_mst             TPMI_RH_LOCKOUT_DATA;\n    TPMI_RH_NV_INDEX_mst            TPMI_RH_NV_INDEX_DATA;\n    TPMI_RH_AC_mst                  TPMI_RH_AC_DATA;\n    TPMI_RH_ACT_mst                 TPMI_RH_ACT_DATA;\n    TPMI_ALG_HASH_mst               TPMI_ALG_HASH_DATA;\n    TPMI_ALG_ASYM_mst               TPMI_ALG_ASYM_DATA;\n    TPMI_ALG_SYM_mst                TPMI_ALG_SYM_DATA;\n    TPMI_ALG_SYM_OBJECT_mst         TPMI_ALG_SYM_OBJECT_DATA;\n    TPMI_ALG_SYM_MODE_mst           TPMI_ALG_SYM_MODE_DATA;\n    TPMI_ALG_KDF_mst                TPMI_ALG_KDF_DATA;\n    TPMI_ALG_SIG_SCHEME_mst         TPMI_ALG_SIG_SCHEME_DATA;\n    TPMI_ECC_KEY_EXCHANGE_mst       TPMI_ECC_KEY_EXCHANGE_DATA;\n    TPMI_ST_COMMAND_TAG_mst         TPMI_ST_COMMAND_TAG_DATA;\n    TPMI_ALG_MAC_SCHEME_mst         TPMI_ALG_MAC_SCHEME_DATA;\n    TPMI_ALG_CIPHER_MODE_mst        TPMI_ALG_CIPHER_MODE_DATA;\n    TPMS_EMPTY_mst                  TPMS_EMPTY_DATA;\n    TPMS_ALGORITHM_DESCRIPTION_mst  TPMS_ALGORITHM_DESCRIPTION_DATA;\n    TPMU_HA_mst                     TPMU_HA_DATA;\n    TPMT_HA_mst                     TPMT_HA_DATA;\n    Tpm2bMarshal_mst                TPM2B_DIGEST_DATA;\n    Tpm2bMarshal_mst                TPM2B_DATA_DATA;\n    Tpm2bMarshal_mst                TPM2B_EVENT_DATA;\n    Tpm2bMarshal_mst                TPM2B_MAX_BUFFER_DATA;\n    Tpm2bMarshal_mst                TPM2B_MAX_NV_BUFFER_DATA;\n    Tpm2bMarshal_mst                TPM2B_TIMEOUT_DATA;\n    Tpm2bMarshal_mst                TPM2B_IV_DATA;\n    NullUnionMarshal_mst            NULL_UNION_DATA;\n    Tpm2bMarshal_mst                TPM2B_NAME_DATA;\n    TPMS_PCR_SELECT_mst             TPMS_PCR_SELECT_DATA;\n    TPMS_PCR_SELECTION_mst          TPMS_PCR_SELECTION_DATA;\n    TPMT_TK_CREATION_mst            TPMT_TK_CREATION_DATA;\n    TPMT_TK_VERIFIED_mst            TPMT_TK_VERIFIED_DATA;\n    TPMT_TK_AUTH_mst                TPMT_TK_AUTH_DATA;\n    TPMT_TK_HASHCHECK_mst           TPMT_TK_HASHCHECK_DATA;\n    TPMS_ALG_PROPERTY_mst           TPMS_ALG_PROPERTY_DATA;\n    TPMS_TAGGED_PROPERTY_mst        TPMS_TAGGED_PROPERTY_DATA;\n    TPMS_TAGGED_PCR_SELECT_mst      TPMS_TAGGED_PCR_SELECT_DATA;\n    TPMS_TAGGED_POLICY_mst          TPMS_TAGGED_POLICY_DATA;\n    TPMS_ACT_DATA_mst               TPMS_ACT_DATA_DATA;\n    ListMarshal_mst                 TPML_CC_DATA;\n    ListMarshal_mst                 TPML_CCA_DATA;\n    ListMarshal_mst                 TPML_ALG_DATA;\n    ListMarshal_mst                 TPML_HANDLE_DATA;\n    ListMarshal_mst                 TPML_DIGEST_DATA;\n    ListMarshal_mst                 TPML_DIGEST_VALUES_DATA;\n    ListMarshal_mst                 TPML_PCR_SELECTION_DATA;\n    ListMarshal_mst                 TPML_ALG_PROPERTY_DATA;\n    ListMarshal_mst                 TPML_TAGGED_TPM_PROPERTY_DATA;\n    ListMarshal_mst                 TPML_TAGGED_PCR_PROPERTY_DATA;\n    ListMarshal_mst                 TPML_ECC_CURVE_DATA;\n    ListMarshal_mst                 TPML_TAGGED_POLICY_DATA;\n    ListMarshal_mst                 TPML_ACT_DATA_DATA;\n    TPMU_CAPABILITIES_mst           TPMU_CAPABILITIES_DATA;\n    TPMS_CAPABILITY_DATA_mst        TPMS_CAPABILITY_DATA_DATA;\n    TPMS_CLOCK_INFO_mst             TPMS_CLOCK_INFO_DATA;\n    TPMS_TIME_INFO_mst              TPMS_TIME_INFO_DATA;\n    TPMS_TIME_ATTEST_INFO_mst       TPMS_TIME_ATTEST_INFO_DATA;\n    TPMS_CERTIFY_INFO_mst           TPMS_CERTIFY_INFO_DATA;\n    TPMS_QUOTE_INFO_mst             TPMS_QUOTE_INFO_DATA;\n    TPMS_COMMAND_AUDIT_INFO_mst     TPMS_COMMAND_AUDIT_INFO_DATA;\n    TPMS_SESSION_AUDIT_INFO_mst     TPMS_SESSION_AUDIT_INFO_DATA;\n    TPMS_CREATION_INFO_mst          TPMS_CREATION_INFO_DATA;\n    TPMS_NV_CERTIFY_INFO_mst        TPMS_NV_CERTIFY_INFO_DATA;\n    TPMS_NV_DIGEST_CERTIFY_INFO_mst TPMS_NV_DIGEST_CERTIFY_INFO_DATA;\n    TPMI_ST_ATTEST_mst              TPMI_ST_ATTEST_DATA;\n    TPMU_ATTEST_mst                 TPMU_ATTEST_DATA;\n    TPMS_ATTEST_mst                 TPMS_ATTEST_DATA;\n    Tpm2bMarshal_mst                TPM2B_ATTEST_DATA;\n    TPMS_AUTH_COMMAND_mst           TPMS_AUTH_COMMAND_DATA;\n    TPMS_AUTH_RESPONSE_mst          TPMS_AUTH_RESPONSE_DATA;\n    TPMI_AES_KEY_BITS_mst           TPMI_AES_KEY_BITS_DATA;\n    TPMI_SM4_KEY_BITS_mst           TPMI_SM4_KEY_BITS_DATA;\n    TPMI_CAMELLIA_KEY_BITS_mst      TPMI_CAMELLIA_KEY_BITS_DATA;\n    TPMU_SYM_KEY_BITS_mst           TPMU_SYM_KEY_BITS_DATA;\n    TPMU_SYM_MODE_mst               TPMU_SYM_MODE_DATA;\n    TPMT_SYM_DEF_mst                TPMT_SYM_DEF_DATA;\n    TPMT_SYM_DEF_OBJECT_mst         TPMT_SYM_DEF_OBJECT_DATA;\n    Tpm2bMarshal_mst                TPM2B_SYM_KEY_DATA;\n    TPMS_SYMCIPHER_PARMS_mst        TPMS_SYMCIPHER_PARMS_DATA;\n    Tpm2bMarshal_mst                TPM2B_LABEL_DATA;\n    TPMS_DERIVE_mst                 TPMS_DERIVE_DATA;\n    Tpm2bMarshal_mst                TPM2B_DERIVE_DATA;\n    Tpm2bMarshal_mst                TPM2B_SENSITIVE_DATA_DATA;\n    TPMS_SENSITIVE_CREATE_mst       TPMS_SENSITIVE_CREATE_DATA;\n    Tpm2bsMarshal_mst               TPM2B_SENSITIVE_CREATE_DATA;\n    TPMS_SCHEME_HASH_mst            TPMS_SCHEME_HASH_DATA;\n    TPMS_SCHEME_ECDAA_mst           TPMS_SCHEME_ECDAA_DATA;\n    TPMI_ALG_KEYEDHASH_SCHEME_mst   TPMI_ALG_KEYEDHASH_SCHEME_DATA;\n    TPMS_SCHEME_XOR_mst             TPMS_SCHEME_XOR_DATA;\n    TPMU_SCHEME_KEYEDHASH_mst       TPMU_SCHEME_KEYEDHASH_DATA;\n    TPMT_KEYEDHASH_SCHEME_mst       TPMT_KEYEDHASH_SCHEME_DATA;\n    TPMU_SIG_SCHEME_mst             TPMU_SIG_SCHEME_DATA;\n    TPMT_SIG_SCHEME_mst             TPMT_SIG_SCHEME_DATA;\n    TPMU_KDF_SCHEME_mst             TPMU_KDF_SCHEME_DATA;\n    TPMT_KDF_SCHEME_mst             TPMT_KDF_SCHEME_DATA;\n    TPMI_ALG_ASYM_SCHEME_mst        TPMI_ALG_ASYM_SCHEME_DATA;\n    TPMU_ASYM_SCHEME_mst            TPMU_ASYM_SCHEME_DATA;\n    TPMI_ALG_RSA_SCHEME_mst         TPMI_ALG_RSA_SCHEME_DATA;\n    TPMT_RSA_SCHEME_mst             TPMT_RSA_SCHEME_DATA;\n    TPMI_ALG_RSA_DECRYPT_mst        TPMI_ALG_RSA_DECRYPT_DATA;\n    TPMT_RSA_DECRYPT_mst            TPMT_RSA_DECRYPT_DATA;\n    Tpm2bMarshal_mst                TPM2B_PUBLIC_KEY_RSA_DATA;\n    TPMI_RSA_KEY_BITS_mst           TPMI_RSA_KEY_BITS_DATA;\n    Tpm2bMarshal_mst                TPM2B_PRIVATE_KEY_RSA_DATA;\n    Tpm2bMarshal_mst                TPM2B_ECC_PARAMETER_DATA;\n    TPMS_ECC_POINT_mst              TPMS_ECC_POINT_DATA;\n    Tpm2bsMarshal_mst               TPM2B_ECC_POINT_DATA;\n    TPMI_ALG_ECC_SCHEME_mst         TPMI_ALG_ECC_SCHEME_DATA;\n    TPMI_ECC_CURVE_mst              TPMI_ECC_CURVE_DATA;\n    TPMT_ECC_SCHEME_mst             TPMT_ECC_SCHEME_DATA;\n    TPMS_ALGORITHM_DETAIL_ECC_mst   TPMS_ALGORITHM_DETAIL_ECC_DATA;\n    TPMS_SIGNATURE_RSA_mst          TPMS_SIGNATURE_RSA_DATA;\n    TPMS_SIGNATURE_ECC_mst          TPMS_SIGNATURE_ECC_DATA;\n    TPMU_SIGNATURE_mst              TPMU_SIGNATURE_DATA;\n    TPMT_SIGNATURE_mst              TPMT_SIGNATURE_DATA;\n    TPMU_ENCRYPTED_SECRET_mst       TPMU_ENCRYPTED_SECRET_DATA;\n    Tpm2bMarshal_mst                TPM2B_ENCRYPTED_SECRET_DATA;\n    TPMI_ALG_PUBLIC_mst             TPMI_ALG_PUBLIC_DATA;\n    TPMU_PUBLIC_ID_mst              TPMU_PUBLIC_ID_DATA;\n    TPMS_KEYEDHASH_PARMS_mst        TPMS_KEYEDHASH_PARMS_DATA;\n    TPMS_RSA_PARMS_mst              TPMS_RSA_PARMS_DATA;\n    TPMS_ECC_PARMS_mst              TPMS_ECC_PARMS_DATA;\n    TPMU_PUBLIC_PARMS_mst           TPMU_PUBLIC_PARMS_DATA;\n    TPMT_PUBLIC_PARMS_mst           TPMT_PUBLIC_PARMS_DATA;\n    TPMT_PUBLIC_mst                 TPMT_PUBLIC_DATA;\n    Tpm2bsMarshal_mst               TPM2B_PUBLIC_DATA;\n    Tpm2bMarshal_mst                TPM2B_TEMPLATE_DATA;\n    Tpm2bMarshal_mst                TPM2B_PRIVATE_VENDOR_SPECIFIC_DATA;\n    TPMU_SENSITIVE_COMPOSITE_mst    TPMU_SENSITIVE_COMPOSITE_DATA;\n    TPMT_SENSITIVE_mst              TPMT_SENSITIVE_DATA;\n    Tpm2bsMarshal_mst               TPM2B_SENSITIVE_DATA;\n    Tpm2bMarshal_mst                TPM2B_PRIVATE_DATA;\n    Tpm2bMarshal_mst                TPM2B_ID_OBJECT_DATA;\n    TPMS_NV_PIN_COUNTER_PARAMETERS_mst TPMS_NV_PIN_COUNTER_PARAMETERS_DATA;\n    AttributesMarshal_mst           TPMA_NV_DATA;\n    TPMS_NV_PUBLIC_mst              TPMS_NV_PUBLIC_DATA;\n    Tpm2bsMarshal_mst               TPM2B_NV_PUBLIC_DATA;\n    Tpm2bMarshal_mst                TPM2B_CONTEXT_SENSITIVE_DATA;\n    TPMS_CONTEXT_DATA_mst           TPMS_CONTEXT_DATA_DATA;\n    Tpm2bMarshal_mst                TPM2B_CONTEXT_DATA_DATA;\n    TPMS_CONTEXT_mst                TPMS_CONTEXT_DATA;\n    TPMS_CREATION_DATA_mst          TPMS_CREATION_DATA_DATA;\n    Tpm2bsMarshal_mst               TPM2B_CREATION_DATA_DATA;\n    TPM_AT_mst                      TPM_AT_DATA;\n    TPMS_AC_OUTPUT_mst              TPMS_AC_OUTPUT_DATA;\n    ListMarshal_mst                 TPML_AC_CAPABILITIES_DATA;\n    MinMaxMarshal_mst               Type00_DATA;\n    MinMaxMarshal_mst               Type01_DATA;\n    Type02_mst                      Type02_DATA;\n    Type03_mst                      Type03_DATA;\n    Type04_mst                      Type04_DATA;\n    MinMaxMarshal_mst               Type05_DATA;\n    Type06_mst                      Type06_DATA;\n    MinMaxMarshal_mst               Type07_DATA;\n    Type08_mst                      Type08_DATA;\n    Type10_mst                      Type10_DATA;\n    Type11_mst                      Type11_DATA;\n    Type12_mst                      Type12_DATA;\n    Type13_mst                      Type13_DATA;\n    Type15_mst                      Type15_DATA;\n    Type17_mst                      Type17_DATA;\n    Type18_mst                      Type18_DATA;\n    Type19_mst                      Type19_DATA;\n    Type20_mst                      Type20_DATA;\n    Type22_mst                      Type22_DATA;\n    Type23_mst                      Type23_DATA;\n    Type24_mst                      Type24_DATA;\n    Type25_mst                      Type25_DATA;\n    Type26_mst                      Type26_DATA;\n    Type27_mst                      Type27_DATA;\n    MinMaxMarshal_mst               Type28_DATA;\n    Type29_mst                      Type29_DATA;\n    Type30_mst                      Type30_DATA;\n    MinMaxMarshal_mst               Type31_DATA;\n    MinMaxMarshal_mst               Type32_DATA;\n    Type33_mst                      Type33_DATA;\n    Type34_mst                      Type34_DATA;\n    Type35_mst                      Type35_DATA;\n    MinMaxMarshal_mst               Type36_DATA;\n    MinMaxMarshal_mst               Type37_DATA;\n    Type38_mst                      Type38_DATA;\n    MinMaxMarshal_mst               Type39_DATA;\n    MinMaxMarshal_mst               Type40_DATA;\n    Type41_mst                      Type41_DATA;\n    Type42_mst                      Type42_DATA;\n    MinMaxMarshal_mst               Type43_DATA;\n    Type44_mst                      Type44_DATA;\n} MarshalData_st;\n\n#endif // _TABLE_MARSHAL_TYPES_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TcpServerPosix_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tSocket Interface to a TPM Simulator\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TcpServerPosix_fp.h 1658 2021-01-22 23:14:01Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef TCPSERVERPOSIX_FP_H\n#define TCPSERVERPOSIX_FP_H\n\n#include <unistd.h>\n#include <sys/types.h>\n#include <sys/socket.h>\n#include <netinet/in.h>\n#include <pthread.h>\n\n#include \"CompilerDependencies.h\"\n#include \"BaseTypes.h\"\n\nbool\nPlatformServer(\n\t       SOCKET           s\n\t       );\nint\nPlatformSvcRoutine(\n\t\t   void *port\n\t\t   );\nint\nPlatformSignalService(\n\t\t      int              *PortNumberPlatform\n\t\t      );\nint\nRegularCommandService(\n\t\t      int              *PortNumber\n\t\t      );\nint\nStartTcpServer(\n\t       int              *PortNumber,\n\t       int              *PortNumberPlatform\n\t       );\n// bool\n// ReadBytes(\n// \t  SOCKET           s,\n// \t  char            *buffer,\n// \t  int              NumBytes\n// \t  );\n\n// bool\n// WriteBytes(\n// \t   SOCKET           s,\n// \t   char            *buffer,\n// \t   int              NumBytes\n// \t   );\n// bool\n// WriteUINT32(\n// \t    SOCKET           s,\n// \t    UINT32           val\n// \t    );\n// bool\n// ReadVarBytes(\n// \t     SOCKET           s,\n// \t     char            *buffer,\n// \t     UINT32          *BytesReceived,\n// \t     int              MaxLen\n// \t     );\n\n// bool\n// WriteVarBytes(\n// \t      SOCKET           s,\n// \t      char            *buffer,\n// \t      int              BytesToSend\n// \t      );\nbool\nTpmServer(\n\t  SOCKET           s\n\t  );\n\n\nbool\nReadBytes(\n\t  uintptr_t       *s,\n\t  char            *buffer,\n\t  int              NumBytes\n\t  );\nbool\nReadVarBytes(\n\t     uintptr_t       *s,\n\t     char            *buffer,\n\t     UINT32          *BytesReceived,\n\t     int              MaxLen\n\t     );\nbool\nWriteBytes(\n\t   uintptr_t       *s,\n\t   char            *buffer,\n\t   int              NumBytes\n\t   );\nbool\nWriteUINT32(\n\t    uintptr_t       *s,\n\t    UINT32           val\n\t    );\n\nbool\nWriteVarBytes(\n\t      uintptr_t       *s,\n\t      char            *buffer,\n\t      int              BytesToSend\n\t      );\nbool\nTpmServerHandler(uintptr_t s);\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TcpServer_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TcpServer Header\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TcpServer_fp.h 1658 2021-01-22 23:14:01Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef TCPSERVER_FP_H\n#define TCPSERVER_FP_H\n\n#include <stdbool.h>\n\nbool\nPlatformServer(\n\t       SOCKET           s\n\t       );\nint\nPlatformSvcRoutine(\n\t\t   void *port\n\t\t   );\nint\nPlatformSignalService(\n\t\t      int              *PortNumber\n\t\t      );\nint\nRegularCommandService(\n\t\t      int              *PortNumber\n\t\t      );\nint\nStartTcpServer(\n\t       int              *PortNumber,\n\t       int              *PortNumberPlatform\n\t       );\nbool\nReadBytes(\n\t  SOCKET           s,\n\t  char            *buffer,\n\t  int              NumBytes\n\t  );\nbool\nWriteBytes(\n\t   SOCKET           s,\n\t   char            *buffer,\n\t   int              NumBytes\n\t   );\nbool\nWriteUINT32(\n\t    SOCKET           s,\n\t    uint32_t         val\n\t    );\nbool\nReadUINT32(\n\t   SOCKET           s,\n\t   UINT32          *val\n\t   );\nbool\nReadVarBytes(\n\t     SOCKET           s,\n\t     char            *buffer,\n\t     uint32_t        *BytesReceived,\n\t     int              MaxLen\n\t     );\nbool\nWriteVarBytes(\n\t      SOCKET           s,\n\t      char            *buffer,\n\t      int              BytesToSend\n\t      );\nbool\nTpmServer(\n\t  SOCKET           s\n\t  );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TestParms_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TestParms_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef TESTPARMS_FP_H\n#define TESTPARMS_FP_H\n\ntypedef struct {\n    TPMT_PUBLIC_PARMS\tparameters;\n} TestParms_In;\n\n#define RC_TestParms_parameters\t(TPM_RC_P + TPM_RC_1)\n\nTPM_RC\nTPM2_TestParms(\n\t       TestParms_In    *in             // IN: input parameter list\n\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Ticket_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef TICKET_FP_H\n#define TICKET_FP_H\n\nBOOL\nTicketIsSafe(\n\t     TPM2B           *buffer\n\t     );\nTPM_RC\nTicketComputeVerified(\n\t\t      TPMI_RH_HIERARCHY    hierarchy,     // IN: hierarchy constant for ticket\n\t\t      TPM2B_DIGEST        *digest,        // IN: digest\n\t\t      TPM2B_NAME          *keyName,       // IN: name of key that signed the values\n\t\t      TPMT_TK_VERIFIED    *ticket         // OUT: verified ticket\n\t\t      );\nTPM_RC\nTicketComputeAuth(\n\t\t  TPM_ST               type,          // IN: the type of ticket.\n\t\t  TPMI_RH_HIERARCHY    hierarchy,     // IN: hierarchy constant for ticket\n\t\t  UINT64               timeout,       // IN: timeout\n\t\t  BOOL                 expiresOnReset,// IN: flag to indicate if ticket expires on\n\t\t  //      TPM Reset\n\t\t  TPM2B_DIGEST        *cpHashA,       // IN: input cpHashA\n\t\t  TPM2B_NONCE         *policyRef,     // IN: input policyRef\n\t\t  TPM2B_NAME          *entityName,    // IN: name of entity\n\t\t  TPMT_TK_AUTH        *ticket         // OUT: Created ticket\n\t\t  );\nTPM_RC\nTicketComputeHashCheck(\n\t\t       TPMI_RH_HIERARCHY    hierarchy,     // IN: hierarchy constant for ticket\n\t\t       TPM_ALG_ID           hashAlg,       // IN: the hash algorithm for 'digest'\n\t\t       TPM2B_DIGEST        *digest,        // IN: input digest\n\t\t       TPMT_TK_HASHCHECK   *ticket         // OUT: Created ticket\n\t\t       );\nTPM_RC\nTicketComputeCreation(\n\t\t      TPMI_RH_HIERARCHY    hierarchy,     // IN: hierarchy for ticket\n\t\t      TPM2B_NAME          *name,          // IN: object name\n\t\t      TPM2B_DIGEST        *creation,      // IN: creation hash\n\t\t      TPMT_TK_CREATION    *ticket         // OUT: created ticket\n\t\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Time_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tFunctions relating to the TPM's time functions \t \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Apr  2, 2019  Time: 04:23:27PM\n */\n\n#ifndef _TIME_FP_H_\n#define _TIME_FP_H_\n\n//*** TimePowerOn()\n// This function initialize time info at _TPM_Init().\n//\n// This function is called at _TPM_Init() so that the TPM time can start counting\n// as soon as the TPM comes out of reset and doesn't have to wait until\n// TPM2_Startup() in order to begin the new time epoch. This could be significant\n// for systems that could get powered up but not run any TPM commands for some\n// period of time.\n//\nvoid TimePowerOn(void);\n\n//*** TimeStartup()\n// This function updates the resetCount and restartCount components of\n// TPMS_CLOCK_INFO structure at TPM2_Startup().\n//\n// This function will deal with the deferred creation of a new epoch.\n// TimeUpdateToCurrent() will not start a new epoch even if one is due when\n// TPM_Startup() has not been run. This is because the state of NV is not known\n// until startup completes. When Startup is done, then it will create the epoch\n// nonce to complete the initializations by calling this function.\nBOOL TimeStartup(STARTUP_TYPE type  // IN: start up type\n\t\t );\n\n//*** TimeClockUpdate()\n// This function updates go.clock. If 'newTime' requires an update of NV, then\n// NV is checked for availability. If it is not available or is rate limiting, then\n// go.clock is not updated and the function returns an error. If 'newTime' would\n// not cause an NV write, then go.clock is updated. If an NV write occurs, then\n// go.safe is SET.\nvoid TimeClockUpdate(UINT64 newTime  // IN: New time value in mS.\n\t\t     );\n\n//*** TimeUpdate()\n// This function is used to update the time and clock values. If the TPM\n// has run TPM2_Startup(), this function is called at the start of each command.\n// If the TPM has not run TPM2_Startup(), this is called from TPM2_Startup() to\n// get the clock values initialized. It is not called on command entry because, in\n// this implementation, the go structure is not read from NV until TPM2_Startup().\n// The reason for this is that the initialization code (_TPM_Init()) may run before\n// NV is accessible.\nvoid TimeUpdate(void);\n\n//*** TimeUpdateToCurrent()\n// This function updates the 'Time' and 'Clock' in the global\n// TPMS_TIME_INFO structure.\n//\n// In this implementation, 'Time' and 'Clock' are updated at the beginning\n// of each command and the values are unchanged for the duration of the\n// command.\n//\n// Because 'Clock' updates may require a write to NV memory, 'Time' and 'Clock'\n// are not allowed to advance if NV is not available. When clock is not advancing,\n// any function that uses 'Clock' will fail and return TPM_RC_NV_UNAVAILABLE or\n// TPM_RC_NV_RATE.\n//\n// This implementation does not do rate limiting. If the implementation does do\n// rate limiting, then the 'Clock' update should not be inhibited even when doing\n// rate limiting.\nvoid TimeUpdateToCurrent(void);\n\n//*** TimeSetAdjustRate()\n// This function is used to perform rate adjustment on 'Time' and 'Clock'.\nvoid TimeSetAdjustRate(TPM_CLOCK_ADJUST adjust  // IN: adjust constant\n\t\t       );\n\n//*** TimeGetMarshaled()\n// This function is used to access TPMS_TIME_INFO in canonical form.\n// The function collects the time information and marshals it into 'dataBuffer'\n// and returns the marshaled size\nUINT16\nTimeGetMarshaled(TIME_INFO* dataBuffer  // OUT: result buffer\n\t\t );\n\n//*** TimeFillInfo\n// This function gathers information to fill in a TPMS_CLOCK_INFO structure.\nvoid TimeFillInfo(TPMS_CLOCK_INFO* clockInfo);\n\n#endif  // _TIME_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Tpm.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tRoot header file for building any TPM.lib code\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// Root header file for building any TPM.lib code\n\n#ifndef _TPM_H_\n#define _TPM_H_\n\nint sbi_printf(const char *format, ...);\n// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers\n#include \"tpm_public.h\"\n\n#include \"TpmAlgorithmDefines.h\"\n#include \"LibSupport.h\"        // Types from the library. These need to come before\n// Global.h because some of the structures in\n// that file depend on the structures used by the\n// cryptographic libraries.\n#include \"GpMacros.h\"          // Define additional macros\n#include \"Global.h\"            // Define other TPM types\n#include \"InternalRoutines.h\"  // Function prototypes\n\n\n\n\n#endif  // _TPM_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmASN1.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tMacro and Structure Definitions for the X509 Commands and Functions.\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the macro and structure definitions for the X509 commands and\n// functions.\n\n#ifndef _TPMASN1_H_\n#define _TPMASN1_H_\n\n//** Includes\n\n#include \"Tpm.h\"\n#include \"OIDs.h\"\n\n//** Defined Constants\n//*** ASN.1 Universal Types (Class 00b)\n#define ASN1_EOC               0x00\n#define ASN1_BOOLEAN           0x01\n#define ASN1_INTEGER           0x02\n#define ASN1_BITSTRING         0x03\n#define ASN1_OCTET_STRING      0x04\n#define ASN1_NULL              0x05\n#define ASN1_OBJECT_IDENTIFIER 0x06\n#define ASN1_OBJECT_DESCRIPTOR 0x07\n#define ASN1_EXTERNAL          0x08\n#define ASN1_REAL              0x09\n#define ASN1_ENUMERATED        0x0A\n#define ASN1_EMBEDDED          0x0B\n#define ASN1_UTF8String        0x0C\n#define ASN1_RELATIVE_OID      0x0D\n#define ASN1_SEQUENCE          0x10  // Primitive + Constructed + 0x10\n#define ASN1_SET               0x11  // Primitive + Constructed + 0x11\n#define ASN1_NumericString     0x12\n#define ASN1_PrintableString   0x13\n#define ASN1_T61String         0x14\n#define ASN1_VideoString       0x15\n#define ASN1_IA5String         0x16\n#define ASN1_UTCTime           0x17\n#define ASN1_GeneralizeTime    0x18\n#define ASN1_VisibleString     0x1A\n#define ASN1_GeneralString     0x1B\n#define ASN1_UniversalString   0x1C\n#define ASN1_CHARACTER         STRING 0x1D\n#define ASN1_BMPString         0x1E\n#define ASN1_CONSTRUCTED       0x20\n\n#define ASN1_APPLICAIION_SPECIFIC 0xA0\n\n#define ASN1_CONSTRUCTED_SEQUENCE (ASN1_SEQUENCE + ASN1_CONSTRUCTED)\n\n#define MAX_DEPTH 10  // maximum push depth for marshaling context.\n\n//** Macros\n\n//*** Unmarshaling Macros\n#ifndef GOTO_ERROR_UNLESS\n#  error missing GOTO_ERROR_UNLESS definition\n#endif\n\n// Checks the validity of the size making sure that there is no wrap around\n#define CHECK_SIZE(context, length)\t\t\t\t\t\\\n    GOTO_ERROR_UNLESS((((length) + (context)->offset) >= (context)->offset) \\\n\t\t      && (((length) + (context)->offset) <= (context)->size))\n#define NEXT_OCTET(context) ((context)->buffer[(context)->offset++])\n#define PEEK_NEXT(context)  ((context)->buffer[(context)->offset])\n\n//*** Marshaling Macros\n\n// Marshaling works in reverse order. The offset is set to the top of the buffer and,\n// as the buffer is filled, 'offset' counts down to zero. When the full thing is\n// encoded it can be moved to the top of the buffer. This happens when the last\n// context is closed.\n\n#define CHECK_SPACE(context, length) GOTO_ERROR_UNLESS(context->offset > length)\n\n//** Structures\n\ntypedef struct ASN1UnmarshalContext\n{\n    BYTE* buffer;  // pointer to the buffer\n    INT16 size;    // size of the buffer (a negative number indicates\n    // a parsing failure).\n    INT16 offset;  // current offset into the buffer (a negative number\n    // indicates a parsing failure). Not used\n    BYTE tag;      // The last unmarshaled tag\n} ASN1UnmarshalContext;\n\ntypedef struct ASN1MarshalContext\n{\n    BYTE* buffer;  // pointer to the start of the buffer\n    INT16 offset;  // place on the top where the last entry was added\n    // items are added from the bottom up.\n    INT16 end;     // the end offset of the current value\n    INT16 depth;   // how many pushed end values.\n    INT16 ends[MAX_DEPTH];\n} ASN1MarshalContext;\n\n#endif  // _TPMASN1_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmASN1_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t      TPM ASN.1\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Aug 30, 2019  Time: 02:11:54PM\n */\n\n#ifndef _TPM_ASN1_FP_H_\n#define _TPM_ASN1_FP_H_\n\n//*** ASN1UnmarshalContextInitialize()\n// Function does standard initialization of a context.\n//  Return Type: BOOL\n//      TRUE(1)     success\n//      FALSE(0)    failure\nBOOL ASN1UnmarshalContextInitialize(\n\t\t\t\t    ASN1UnmarshalContext* ctx, INT16 size, BYTE* buffer);\n\n//***ASN1DecodeLength()\n// This function extracts the length of an element from 'buffer' starting at 'offset'.\n// Return Type: UINT16\n//      >=0         the extracted length\n//      <0          an error\nINT16\nASN1DecodeLength(ASN1UnmarshalContext* ctx);\n\n//***ASN1NextTag()\n// This function extracts the next type from 'buffer' starting at 'offset'.\n// It advances 'offset' as it parses the type and the length of the type. It returns\n// the length of the type. On return, the 'length' octets starting at 'offset' are the\n// octets of the type.\n// Return Type: UINT\n//     >=0          the number of octets in 'type'\n//     <0           an error\nINT16\nASN1NextTag(ASN1UnmarshalContext* ctx);\n\n//*** ASN1GetBitStringValue()\n// Try to parse a bit string of up to 32 bits from a value that is expected to be\n// a bit string. The bit string is left justified so that the MSb of the input is\n// the MSb of the returned value.\n// If there is a general parsing error, the context->size is set to -1.\n//  Return Type: BOOL\n//      TRUE(1)     success\n//      FALSE(0)    failure\nBOOL ASN1GetBitStringValue(ASN1UnmarshalContext* ctx, UINT32* val);\n\n//*** ASN1InitialializeMarshalContext()\n// This creates a structure for handling marshaling of an ASN.1 formatted data\n// structure.\nvoid ASN1InitialializeMarshalContext(\n\t\t\t\t     ASN1MarshalContext* ctx, INT16 length, BYTE* buffer);\n\n//*** ASN1StartMarshalContext()\n// This starts a new constructed element. It is constructed on 'top' of the value\n// that was previously placed in the structure.\nvoid ASN1StartMarshalContext(ASN1MarshalContext* ctx);\n\n//*** ASN1EndMarshalContext()\n// This function restores the end pointer for an encapsulating structure.\n//  Return Type: INT16\n//      > 0             the size of the encapsulated structure that was just ended\n//      <= 0            an error\nINT16\nASN1EndMarshalContext(ASN1MarshalContext* ctx);\n\n//***ASN1EndEncapsulation()\n// This function puts a tag and length in the buffer. In this function, an embedded\n// BIT_STRING is assumed to be a collection of octets. To indicate that all bits\n// are used, a byte of zero is prepended. If a raw bit-string is needed, a new\n// function like ASN1PushInteger() would be needed.\n//  Return Type: INT16\n//      > 0         number of octets in the encapsulation\n//      == 0        failure\nUINT16\nASN1EndEncapsulation(ASN1MarshalContext* ctx, BYTE tag);\n\n//*** ASN1PushByte()\nBOOL ASN1PushByte(ASN1MarshalContext* ctx, BYTE b);\n\n//*** ASN1PushBytes()\n// Push some raw bytes onto the buffer. 'count' cannot be zero.\n//  Return Type: IN16\n//      > 0             count bytes\n//      == 0            failure unless count was zero\nINT16\nASN1PushBytes(ASN1MarshalContext* ctx, INT16 count, const BYTE* buffer);\n\n//*** ASN1PushNull()\n//  Return Type: IN16\n//      > 0             count bytes\n//      == 0            failure unless count was zero\nINT16\nASN1PushNull(ASN1MarshalContext* ctx);\n\n//*** ASN1PushLength()\n// Push a length value. This will only handle length values that fit in an INT16.\n//  Return Type: UINT16\n//      > 0         number of bytes added\n//      == 0        failure\nINT16\nASN1PushLength(ASN1MarshalContext* ctx, INT16 len);\n\n//*** ASN1PushTagAndLength()\n//  Return Type: INT16\n//      > 0         number of bytes added\n//      == 0        failure\nINT16\nASN1PushTagAndLength(ASN1MarshalContext* ctx, BYTE tag, INT16 length);\n\n//*** ASN1PushTaggedOctetString()\n// This function will push a random octet string.\n//  Return Type: INT16\n//      > 0         number of bytes added\n//      == 0        failure\nINT16\nASN1PushTaggedOctetString(\n\t\t\t  ASN1MarshalContext* ctx, INT16 size, const BYTE* string, BYTE tag);\n\n//*** ASN1PushUINT()\n// This function pushes an native-endian integer value. This just changes a\n// native-endian integer into a big-endian byte string and calls ASN1PushInteger().\n// That function will remove leading zeros and make sure that the number is positive.\n//  Return Type: IN16\n//      > 0             count bytes\n//      == 0            failure unless count was zero\nINT16\nASN1PushUINT(ASN1MarshalContext* ctx, UINT32 integer);\n\n//*** ASN1PushInteger\n// Push a big-endian integer on the end of the buffer\n//  Return Type: UINT16\n//      > 0         the number of bytes marshaled for the integer\n//      == 0        failure\nINT16\nASN1PushInteger(ASN1MarshalContext* ctx,     // IN/OUT: buffer context\n\t\tINT16               iLen,    // IN: octets of the integer\n\t\tBYTE*               integer  // IN: big-endian integer\n\t\t);\n\n//*** ASN1PushOID()\n// This function is used to add an OID. An OID is 0x06 followed by a byte of size\n// followed by size bytes. This is used to avoid having to do anything special in the\n// definition of an OID.\n//  Return Type: UINT16\n//      > 0         the number of bytes marshaled for the integer\n//      == 0        failure\nINT16\nASN1PushOID(ASN1MarshalContext* ctx, const BYTE* OID);\n\n#endif  // _TPM_ASN1_FP_H_\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmAlgorithmDefines.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tAlgorithm Values from the TCG Algorithm Registry \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// 10.1.18\tTpmAlgorithmDefines.h\n// This file contains the algorithm values from the TCG Algorithm Registry.\n#ifndef _TPM_ALGORITHM_DEFINES_H_\n#define _TPM_ALGORITHM_DEFINES_H_\n// Table 2:3 - Definition of Base Types\n#define ECC_CURVES\t\t\t\t\t\t\t\\\n    {TPM_ECC_BN_P256,   TPM_ECC_BN_P638,   TPM_ECC_NIST_P192,\t\t\\\n     TPM_ECC_NIST_P224, TPM_ECC_NIST_P256, TPM_ECC_NIST_P384,\t\t\\\n     TPM_ECC_NIST_P521, TPM_ECC_SM2_P256}\n#define ECC_CURVE_COUNT\t\t\t\t\t\t\t\\\n    (ECC_BN_P256   + ECC_BN_P638   + ECC_NIST_P192 + ECC_NIST_P224 +\t\\\n     ECC_NIST_P256 + ECC_NIST_P384 + ECC_NIST_P521 + ECC_SM2_P256)\n#define MAX_ECC_KEY_BITS\t\t\t\t\t\t\\\n    MAX(ECC_BN_P256 * 256,   MAX(ECC_BN_P638 * 638,\t\t\t\\\n    MAX(ECC_NIST_P192 * 192, MAX(ECC_NIST_P224 * 224, \\\n    MAX(ECC_NIST_P256 * 256, MAX(ECC_NIST_P384 * 384, \\\n    MAX(ECC_NIST_P521 * 521, MAX(ECC_SM2_P256 * 256, \\\n    0))))))))\n#define MAX_ECC_KEY_BYTES               BITS_TO_BYTES(MAX_ECC_KEY_BITS)\n\n// Table 1:12 - Defines for SHA1 Hash Values\n#define SHA1_DIGEST_SIZE    20\n#define SHA1_BLOCK_SIZE     64\n// Table 1:13 - Defines for SHA256 Hash Values\n#define SHA256_DIGEST_SIZE  32\n#define SHA256_BLOCK_SIZE   64\n// Table 1:14 - Defines for SHA384 Hash Values\n#define SHA384_DIGEST_SIZE  48\n#define SHA384_BLOCK_SIZE   128\n// Table 1:15 - Defines for SHA512 Hash Values\n#define SHA512_DIGEST_SIZE  64\n#define SHA512_BLOCK_SIZE   128\n// Table 1:16 - Defines for SM3_256 Hash Values\n#define SM3_256_DIGEST_SIZE     32\n#define SM3_256_BLOCK_SIZE      64\n// Table 1:16 - Defines for SHA3_256 Hash Values\n#define SHA3_256_DIGEST_SIZE    32\n#define SHA3_256_BLOCK_SIZE     136\n// Table 1:16 - Defines for SHA3_384 Hash Values\n#define SHA3_384_DIGEST_SIZE    48\n#define SHA3_384_BLOCK_SIZE     104\n// Table 1:16 - Defines for SHA3_512 Hash Values\n#define SHA3_512_DIGEST_SIZE    64\n#define SHA3_512_BLOCK_SIZE     72\n// Table 1:00 - Defines for RSA Asymmetric Cipher Algorithm Constants\n#define RSA_KEY_SIZES_BITS\t\t\t\t\t\t\\\n    (1024 * RSA_1024),  (2048 * RSA_2048), (3072 * RSA_3072),\t\t\\\n\t(4096 * RSA_4096), (16384 * RSA_16384)\n#if   RSA_16384\n#   define RSA_MAX_KEY_SIZE_BITS    16384\n#elif   RSA_4096\n#   define RSA_MAX_KEY_SIZE_BITS    4096\n#elif RSA_3072\n#   define RSA_MAX_KEY_SIZE_BITS    3072\n#elif RSA_2048\n#   define RSA_MAX_KEY_SIZE_BITS    2048\n#elif RSA_1024\n#   define RSA_MAX_KEY_SIZE_BITS    1024\n#else\n#   define RSA_MAX_KEY_SIZE_BITS    0\n#endif\n#define MAX_RSA_KEY_BITS            RSA_MAX_KEY_SIZE_BITS\n#define MAX_RSA_KEY_BYTES           ((RSA_MAX_KEY_SIZE_BITS + 7) / 8)\n// Table 1:17 - Defines for AES Symmetric Cipher Algorithm Constants\n#define AES_KEY_SIZES_BITS\t\t\t\t\t\t\\\n    (128 * AES_128), (192 * AES_192), (256 * AES_256)\n#if   AES_256\n#   define AES_MAX_KEY_SIZE_BITS    256\n#elif AES_192\n#   define AES_MAX_KEY_SIZE_BITS    192\n#elif AES_128\n#   define AES_MAX_KEY_SIZE_BITS    128\n#else\n#   define AES_MAX_KEY_SIZE_BITS    0\n#endif\n#define MAX_AES_KEY_BITS            AES_MAX_KEY_SIZE_BITS\n#define MAX_AES_KEY_BYTES           ((AES_MAX_KEY_SIZE_BITS + 7) / 8)\n#define AES_128_BLOCK_SIZE_BYTES    (AES_128 * 16)\n#define AES_192_BLOCK_SIZE_BYTES    (AES_192 * 16)\n#define AES_256_BLOCK_SIZE_BYTES    (AES_256 * 16)\n#define AES_BLOCK_SIZES\t\t\t\t\t\t\t\\\n    AES_128_BLOCK_SIZE_BYTES, AES_192_BLOCK_SIZE_BYTES,\t\t\t\\\n\tAES_256_BLOCK_SIZE_BYTES\n#if   ALG_AES\n#   define AES_MAX_BLOCK_SIZE       16\n#else\n#   define AES_MAX_BLOCK_SIZE       0\n#endif\n#define MAX_AES_BLOCK_SIZE_BYTES    AES_MAX_BLOCK_SIZE\n// 1:18 - Defines for SM4 Symmetric Cipher Algorithm Constants\n#define SM4_KEY_SIZES_BITS          (128 * SM4_128)\n#if   SM4_128\n#   define SM4_MAX_KEY_SIZE_BITS    128\n#else\n#   define SM4_MAX_KEY_SIZE_BITS    0\n#endif\n#define MAX_SM4_KEY_BITS            SM4_MAX_KEY_SIZE_BITS\n#define MAX_SM4_KEY_BYTES           ((SM4_MAX_KEY_SIZE_BITS + 7) / 8)\n#define SM4_128_BLOCK_SIZE_BYTES    (SM4_128 * 16)\n#define SM4_BLOCK_SIZES             SM4_128_BLOCK_SIZE_BYTES\n#if   ALG_SM4\n#   define SM4_MAX_BLOCK_SIZE       16\n#else\n#   define SM4_MAX_BLOCK_SIZE       0\n#endif\n#define MAX_SM4_BLOCK_SIZE_BYTES    SM4_MAX_BLOCK_SIZE\n// 1:19 - Defines for CAMELLIA Symmetric Cipher Algorithm Constants\n#define CAMELLIA_KEY_SIZES_BITS\t\t\t\t\t\t\\\n\t(128 * CAMELLIA_128), (192 * CAMELLIA_192), (256 * CAMELLIA_256)\n#if   CAMELLIA_256\n#   define CAMELLIA_MAX_KEY_SIZE_BITS   256\n#elif CAMELLIA_192\n#   define CAMELLIA_MAX_KEY_SIZE_BITS   192\n#elif CAMELLIA_128\n#   define CAMELLIA_MAX_KEY_SIZE_BITS   128\n#else\n#   define CAMELLIA_MAX_KEY_SIZE_BITS   0\n#endif\n#define MAX_CAMELLIA_KEY_BITS           CAMELLIA_MAX_KEY_SIZE_BITS\n#define MAX_CAMELLIA_KEY_BYTES          ((CAMELLIA_MAX_KEY_SIZE_BITS + 7) / 8)\n#define CAMELLIA_128_BLOCK_SIZE_BYTES   (CAMELLIA_128 * 16)\n#define CAMELLIA_192_BLOCK_SIZE_BYTES   (CAMELLIA_192 * 16)\n#define CAMELLIA_256_BLOCK_SIZE_BYTES   (CAMELLIA_256 * 16)\n#define CAMELLIA_BLOCK_SIZES\t\t\t\t\t\t\\\n\tCAMELLIA_128_BLOCK_SIZE_BYTES, CAMELLIA_192_BLOCK_SIZE_BYTES,\t\\\n\t    CAMELLIA_256_BLOCK_SIZE_BYTES\n#if   ALG_CAMELLIA\n#   define CAMELLIA_MAX_BLOCK_SIZE      16\n#else\n#   define CAMELLIA_MAX_BLOCK_SIZE      0\n#endif\n#define MAX_CAMELLIA_BLOCK_SIZE_BYTES   CAMELLIA_MAX_BLOCK_SIZE\n// 1:17 - Defines for TDES Symmetric Cipher Algorithm Constants\n#define TDES_KEY_SIZES_BITS         (128 * TDES_128), (192 * TDES_192)\n#if   TDES_192\n#   define TDES_MAX_KEY_SIZE_BITS   192\n#elif TDES_128\n#   define TDES_MAX_KEY_SIZE_BITS   128\n#else\n#   define TDES_MAX_KEY_SIZE_BITS   0\n#endif\n#define MAX_TDES_KEY_BITS           TDES_MAX_KEY_SIZE_BITS\n#define MAX_TDES_KEY_BYTES          ((TDES_MAX_KEY_SIZE_BITS + 7) / 8)\n#define TDES_128_BLOCK_SIZE_BYTES   (TDES_128 * 8)\n#define TDES_192_BLOCK_SIZE_BYTES   (TDES_192 * 8)\n#define TDES_BLOCK_SIZES\t\t\t\t\t\t\\\n    TDES_128_BLOCK_SIZE_BYTES, TDES_192_BLOCK_SIZE_BYTES\n#if   ALG_TDES\n#   define TDES_MAX_BLOCK_SIZE      8\n#else\n#   define TDES_MAX_BLOCK_SIZE      0\n#endif\n#define MAX_TDES_BLOCK_SIZE_BYTES   TDES_MAX_BLOCK_SIZE\n// Additional values for benefit of code\n#if COMPRESSED_LISTS\n#define ADD_FILL            0\n#else\n#define ADD_FILL            1\n#endif\n// Size the array of library commands based on whether or not the array is packed (only defined\n// commands) or dense (having entries for unimplemented commands)\n#define LIBRARY_COMMAND_ARRAY_SIZE       (0\t\t\t\t\\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_UndefineSpaceSpecial)              /* 0x0000011F */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_EvictControl)                         /* 0x00000120 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_HierarchyControl)                     /* 0x00000121 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_UndefineSpace)                     /* 0x00000122 */ \\\n\t\t\t\t\t  +  ADD_FILL                                             /* 0x00000123 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ChangeEPS)                            /* 0x00000124 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ChangePPS)                            /* 0x00000125 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Clear)                                /* 0x00000126 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ClearControl)                         /* 0x00000127 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ClockSet)                             /* 0x00000128 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_HierarchyChangeAuth)                  /* 0x00000129 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_DefineSpace)                       /* 0x0000012A */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PCR_Allocate)                         /* 0x0000012B */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PCR_SetAuthPolicy)                    /* 0x0000012C */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PP_Commands)                          /* 0x0000012D */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_SetPrimaryPolicy)                     /* 0x0000012E */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_FieldUpgradeStart)                    /* 0x0000012F */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ClockRateAdjust)                      /* 0x00000130 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_CreatePrimary)                        /* 0x00000131 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_GlobalWriteLock)                   /* 0x00000132 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_GetCommandAuditDigest)                /* 0x00000133 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_Increment)                         /* 0x00000134 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_SetBits)                           /* 0x00000135 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_Extend)                            /* 0x00000136 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_Write)                             /* 0x00000137 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_WriteLock)                         /* 0x00000138 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_DictionaryAttackLockReset)            /* 0x00000139 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_DictionaryAttackParameters)           /* 0x0000013A */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_ChangeAuth)                        /* 0x0000013B */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PCR_Event)                            /* 0x0000013C */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PCR_Reset)                            /* 0x0000013D */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_SequenceComplete)                     /* 0x0000013E */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_SetAlgorithmSet)                      /* 0x0000013F */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_SetCommandCodeAuditStatus)            /* 0x00000140 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_FieldUpgradeData)                     /* 0x00000141 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_IncrementalSelfTest)                  /* 0x00000142 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_SelfTest)                             /* 0x00000143 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Startup)                              /* 0x00000144 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Shutdown)                             /* 0x00000145 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_StirRandom)                           /* 0x00000146 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ActivateCredential)                   /* 0x00000147 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Certify)                              /* 0x00000148 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyNV)                             /* 0x00000149 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_CertifyCreation)                      /* 0x0000014A */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Duplicate)                            /* 0x0000014B */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_GetTime)                              /* 0x0000014C */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_GetSessionAuditDigest)                /* 0x0000014D */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_Read)                              /* 0x0000014E */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_ReadLock)                          /* 0x0000014F */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ObjectChangeAuth)                     /* 0x00000150 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicySecret)                         /* 0x00000151 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Rewrap)                               /* 0x00000152 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Create)                               /* 0x00000153 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ECDH_ZGen)                            /* 0x00000154 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_HMAC || CC_MAC)                       /* 0x00000155 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Import)                               /* 0x00000156 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Load)                                 /* 0x00000157 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Quote)                                /* 0x00000158 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_RSA_Decrypt)                          /* 0x00000159 */ \\\n\t\t\t\t\t  +  ADD_FILL                                             /* 0x0000015A */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_HMAC_Start || CC_MAC_Start)           /* 0x0000015B */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_SequenceUpdate)                       /* 0x0000015C */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Sign)                                 /* 0x0000015D */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Unseal)                               /* 0x0000015E */ \\\n\t\t\t\t\t  +  ADD_FILL                                             /* 0x0000015F */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicySigned)                         /* 0x00000160 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ContextLoad)                          /* 0x00000161 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ContextSave)                          /* 0x00000162 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ECDH_KeyGen)                          /* 0x00000163 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_EncryptDecrypt)                       /* 0x00000164 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_FlushContext)                         /* 0x00000165 */ \\\n\t\t\t\t\t  +  ADD_FILL                                             /* 0x00000166 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_LoadExternal)                         /* 0x00000167 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_MakeCredential)                       /* 0x00000168 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_ReadPublic)                        /* 0x00000169 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyAuthorize)                      /* 0x0000016A */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyAuthValue)                      /* 0x0000016B */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyCommandCode)                    /* 0x0000016C */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyCounterTimer)                   /* 0x0000016D */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyCpHash)                         /* 0x0000016E */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyLocality)                       /* 0x0000016F */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyNameHash)                       /* 0x00000170 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyOR)                             /* 0x00000171 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyTicket)                         /* 0x00000172 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ReadPublic)                           /* 0x00000173 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_RSA_Encrypt)                          /* 0x00000174 */ \\\n\t\t\t\t\t  +  ADD_FILL                                             /* 0x00000175 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_StartAuthSession)                     /* 0x00000176 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_VerifySignature)                      /* 0x00000177 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ECC_Parameters)                       /* 0x00000178 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_FirmwareRead)                         /* 0x00000179 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_GetCapability)                        /* 0x0000017A */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_GetRandom)                            /* 0x0000017B */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_GetTestResult)                        /* 0x0000017C */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Hash)                                 /* 0x0000017D */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PCR_Read)                             /* 0x0000017E */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyPCR)                            /* 0x0000017F */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyRestart)                        /* 0x00000180 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ReadClock)                            /* 0x00000181 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PCR_Extend)                           /* 0x00000182 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PCR_SetAuthValue)                     /* 0x00000183 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_Certify)                           /* 0x00000184 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_EventSequenceComplete)                /* 0x00000185 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_HashSequenceStart)                    /* 0x00000186 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyPhysicalPresence)               /* 0x00000187 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyDuplicationSelect)              /* 0x00000188 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyGetDigest)                      /* 0x00000189 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_TestParms)                            /* 0x0000018A */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Commit)                               /* 0x0000018B */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyPassword)                       /* 0x0000018C */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ZGen_2Phase)                          /* 0x0000018D */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_EC_Ephemeral)                         /* 0x0000018E */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyNvWritten)                      /* 0x0000018F */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyTemplate)                       /* 0x00000190 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_CreateLoaded)                         /* 0x00000191 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyAuthorizeNV)                    /* 0x00000192 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_EncryptDecrypt2)                      /* 0x00000193 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_AC_GetCapability)                     /* 0x00000194 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_AC_Send)                              /* 0x00000195 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_Policy_AC_SendSelect)                 /* 0x00000196 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_CertifyX509)                          /* 0x00000197 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ACT_SetTimeout)                       /* 0x00000198 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ECC_Encrypt)                          /* 0x00000199 */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_ECC_Decrypt)                          /* 0x0000019A */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyCapability)                     /* 0x0000019B */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_PolicyParameters)                     /* 0x0000019C */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_DefineSpace2)                      /* 0x0000019D */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_NV_ReadPublic2)                       /* 0x0000019E */ \\\n\t\t\t\t\t  + (ADD_FILL || CC_SetCapability)                        /* 0x0000019F */ \\\n\t\t\t\t\t  )\n#ifndef TPM_NUVOTON\n#define VENDOR_COMMAND_ARRAY_SIZE   (0 + CC_Vendor_TCG_Test)\n#endif\n\n#ifdef TPM_NUVOTON\n#define VENDOR_COMMAND_ARRAY_SIZE   ( 0\t\t\t\t\\\n\t\t\t\t      + CC_Vendor_TCG_Test\t\\\n\t\t\t\t      + CC_NTC2_PreConfig\t\\\n\t\t\t\t      + CC_NTC2_LockPreConfig\t\\\n\t\t\t\t      + CC_NTC2_GetConfig\t\\\n\t\t\t\t      )\n#endif\n\n\n#define COMMAND_COUNT       (LIBRARY_COMMAND_ARRAY_SIZE + VENDOR_COMMAND_ARRAY_SIZE)\n#define HASH_COUNT\t\t\t\t\t\t\t\\\n    (ALG_SHA1     + ALG_SHA256   + ALG_SHA384   + ALG_SHA3_256 +\t\\\n     ALG_SHA3_384 + ALG_SHA3_512 + ALG_SHA512   + ALG_SM3_256)\n#define MAX_HASH_BLOCK_SIZE\t\t\t\t\t\t\\\n    (MAX(ALG_SHA1     * SHA1_BLOCK_SIZE,\t\t\t\t\\\n\t MAX(ALG_SHA256   * SHA256_BLOCK_SIZE,\t\t\t\t\\\n\t     MAX(ALG_SHA384   * SHA384_BLOCK_SIZE,\t\t\t\\\n\t\t MAX(ALG_SHA3_256 * SHA3_256_BLOCK_SIZE,\t\t\\\n\t\t     MAX(ALG_SHA3_384 * SHA3_384_BLOCK_SIZE,\t\t\\\n\t\t\t MAX(ALG_SHA3_512 * SHA3_512_BLOCK_SIZE,\t\\\n\t\t\t     MAX(ALG_SHA512   * SHA512_BLOCK_SIZE,\t\\\n\t\t\t\t MAX(ALG_SM3_256  * SM3_256_BLOCK_SIZE, \\\n\t\t\t\t     0)))))))))\n#define MAX_DIGEST_SIZE\t\t\t\t\t\t\t\\\n    (MAX(ALG_SHA1     * SHA1_DIGEST_SIZE,\t\t\t\t\\\n\t MAX(ALG_SHA256   * SHA256_DIGEST_SIZE,\t\t\t\t\\\n\t     MAX(ALG_SHA384   * SHA384_DIGEST_SIZE,\t\t\t\\\n\t\t MAX(ALG_SHA3_256 * SHA3_256_DIGEST_SIZE,\t\t\\\n\t\t     MAX(ALG_SHA3_384 * SHA3_384_DIGEST_SIZE,\t\t\\\n\t\t\t MAX(ALG_SHA3_512 * SHA3_512_DIGEST_SIZE,\t\\\n\t\t\t     MAX(ALG_SHA512   * SHA512_DIGEST_SIZE,\t\\\n\t\t\t\t MAX(ALG_SM3_256  * SM3_256_DIGEST_SIZE, \\\n\t\t\t\t     0)))))))))\n#if MAX_DIGEST_SIZE == 0 || MAX_HASH_BLOCK_SIZE == 0\n#error \"Hash data not valid\"\n#endif\n// Define the 2B structure that would hold any hash block\nTPM2B_TYPE(MAX_HASH_BLOCK, MAX_HASH_BLOCK_SIZE);\n// Following typedef is for some old code\ntypedef TPM2B_MAX_HASH_BLOCK    TPM2B_HASH_BLOCK;\n\n#define MAX_SYM_KEY_BITS\t\t\t\t\t\t\\\n    (MAX(AES_MAX_KEY_SIZE_BITS,      MAX(CAMELLIA_MAX_KEY_SIZE_BITS,\t\\\n\t\t\t\t\t MAX(SM4_MAX_KEY_SIZE_BITS,      MAX(TDES_MAX_KEY_SIZE_BITS, \\\n\t\t\t\t\t\t\t\t\t     0)))))\n#define MAX_SYM_KEY_BYTES       ((MAX_SYM_KEY_BITS + 7) / 8)\n#define MAX_SYM_BLOCK_SIZE\t\t\t\t\t\t\\\n    (MAX(AES_MAX_BLOCK_SIZE,      MAX(CAMELLIA_MAX_BLOCK_SIZE,\t\t\\\n\t\t\t\t      MAX(SM4_MAX_BLOCK_SIZE,      MAX(TDES_MAX_BLOCK_SIZE, \\\n\t\t\t\t\t\t\t\t       0)))))\n#if MAX_SYM_KEY_BITS == 0 || MAX_SYM_BLOCK_SIZE == 0\n#   error Bad size for MAX_SYM_KEY_BITS or MAX_SYM_BLOCK\n#endif\n#endif // _TPM_ALGORITHM_DEFINES_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmBigNum.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the headers necessary to build the tpm big num library.\n// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers\n#include \"tpm_public.h\"\n#include \"TpmFail_fp.h\"\n// TODO_RENAME_INC_FOLDER: private refers to the TPM_CoreLib private(protected) headers\n#include \"TpmAlgorithmDefines.h\"\n#include \"GpMacros.h\"  // required for TpmFail_fp.h\n#include \"Capabilities.h\"\n#include \"TpmTypes.h\"  // requires capabilities & GpMacros\n#include \"TpmToTpmBigNumMath.h\"\n#include \"BnSupport_Interface.h\"\n#include \"BnConvert_fp.h\"\n#include \"BnMemory_fp.h\"\n#include \"BnMath_fp.h\"\n#include \"BnUtil_fp.h\"\n#include \"MathLibraryInterface.h\"\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmBuildSwitches.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Build Switches\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This file contains the build switches. This contains switches for multiple\n// versions of the crypto-library so some may not apply to your environment.\n// Each switch has an accompanying description below.\n//\n// clang-format off\n#ifndef _TPM_BUILD_SWITCHES_H_\n#define _TPM_BUILD_SWITCHES_H_\n\n#if defined(YES) || defined(NO)\n#  error YES and NO should be defined in TpmBuildSwitches.h\n#endif\n#if defined(SET) || defined(CLEAR)\n#  error SET and CLEAR should be defined in TpmBuildSwitches.h\n#endif\n\n#define YES   1\n#define SET   1\n#define NO    0\n#define CLEAR 0\n\n// TRUE/FALSE may be coming from system headers, but if not, provide them.\n#ifndef TRUE\n#  define TRUE 1\n#endif\n#ifndef FALSE\n#  define FALSE 0\n#endif\n\n\n#define NDEBUG\n// Need an unambiguous definition for DEBUG. Do not change this\n#ifndef DEBUG\n#  ifdef NDEBUG\n#    define DEBUG NO\n#  else\n#    define DEBUG YES\n#  endif\n#elif(DEBUG != NO) && (DEBUG != YES)\n#  error DEBUG should be 0 or 1\n#endif\n\n////////////////////////////////////////////////////////////////\n// DEBUG OPTIONS\n////////////////////////////////////////////////////////////////\n\n// The SIMULATION switch allows certain other macros to be enabled. The things that\n// can be enabled in a simulation include key caching, reproducible \"random\"\n// sequences, instrumentation of the RSA key generation process, and certain other\n// debug code. SIMULATION Needs to be defined as either YES or NO. This grouping of\n// macros will make sure that it is set correctly. A simulated TPM would include a\n// Virtual TPM. The interfaces for a Virtual TPM should be modified from the standard\n// ones in the Simulator project.\n// #define SIMULATION                  YES\n#define SIMULATION                  NO\n\n// If doing debug, can set the DRBG to print out the intermediate test values.\n// Before enabling this, make sure that the dbgDumpMemBlock() function\n// has been added someplace (preferably, somewhere in CryptRand.c)\n#define DRBG_DEBUG_PRINT            (NO  * DEBUG)\n\n// This define is used to control the debug for the CertifyX509 command.\n#define CERTIFYX509_DEBUG           (YES * DEBUG)\n\n// This provides fixed seeding of the RNG when doing debug on a simulator. This\n// should allow consistent results on test runs as long as the input parameters\n// to the functions remains the same.\n#define USE_DEBUG_RNG               (NO  * DEBUG)\n\n////////////////////////////////////////////////////////////////\n// RSA DEBUG OPTIONS\n////////////////////////////////////////////////////////////////\n\n// Enable the instrumentation of the sieve process. This is used to tune the sieve\n// variables.\n#define RSA_INSTRUMENT              (NO  * DEBUG)\n\n// Enables use of the key cache. Default is YES\n#define USE_RSA_KEY_CACHE           (NO  * DEBUG)\n\n// Enables use of a file to store the key cache values so that the TPM will start\n// faster during debug. Default for this is YES\n#define USE_KEY_CACHE_FILE          (NO  * DEBUG)\n\n////////////////////////////////////////////////////////////////\n// TEST OPTIONS\n////////////////////////////////////////////////////////////////\n// The SIMULATION flag can enable test crypto behaviors and caching that\n// significantly change the behavior of the code.  This flag controls only the\n// g_forceFailureMode flag in the TPM library while leaving the rest of the TPM\n// behavior alone.  Useful for testing when the full set of options controlled by\n// SIMULATION may not be desired.\n#define ALLOW_FORCE_FAILURE_MODE    YES\n\n////////////////////////////////////////////////////////////////\n// Internal checks\n////////////////////////////////////////////////////////////////\n\n// Define this to run the function that checks the compatibility between the\n// chosen big number math library and the TPM code. Not all ports use this.\n#define LIBRARY_COMPATIBILITY_CHECK YES\n\n// In some cases, the relationship between two values may be dependent on things that\n// change based on various selections like the chosen cryptographic libraries. It is\n// possible that these selections will result in incompatible settings. These are often\n// detectable by the compiler but it is not always possible to do the check in the\n// preprocessor code. For example, when the check requires use of 'sizeof'() then the\n// preprocessor can't do the comparison. For these cases, we include a special macro\n// that, depending on the compiler will generate a warning to indicate if the check\n// always passes or always fails because it involves fixed constants.\n//\n// In modern compilers this is now commonly known as a static_assert, but the precise\n// implementation varies by compiler. CompilerDependencies.h defines MUST_BE as a macro\n// that abstracts out the differences, and COMPILER_CHECKS can remove the checks where\n// the current compiler doesn't support it.  COMPILER_CHECKS should be enabled if the\n// compiler supports some form of static_assert.\n// See the CompilerDependencies_*.h files for specific implementations per compiler.\n#define COMPILER_CHECKS             YES\n\n// Some of the values (such as sizes) are the result of different options set in\n// TpmProfile.h. The combination might not be consistent. A function is defined\n// (TpmSizeChecks()) that is used to verify the sizes at run time. To enable the\n// function, define this parameter.\n#define RUNTIME_SIZE_CHECKS         YES\n\n////////////////////////////////////////////////////////////////\n// Compliance options\n////////////////////////////////////////////////////////////////\n\n// Enable extra behaviors to meet FIPS compliance requirements\n#define FIPS_COMPLIANT              YES\n\n// Indicates if the implementation is to compute the sizes of the proof and primary\n// seed size values based on the implemented algorithms.\n#define USE_SPEC_COMPLIANT_PROOFS   YES\n\n// Set this to allow compile to continue even though the chosen proof values\n// do not match the compliant values. This is written so that someone would\n// have to proactively ignore errors.\n#define SKIP_PROOF_ERRORS           NO\n\n////////////////////////////////////////////////////////////////\n// Implementation alternatives - don't  change external behavior\n////////////////////////////////////////////////////////////////\n\n// Define TABLE_DRIVEN_DISPATCH to use tables rather than case statements\n// for command dispatch and handle unmarshaling\n#define TABLE_DRIVEN_DISPATCH       YES\n\n// This define is used to enable the new table-driven marshaling code.\n#define TABLE_DRIVEN_MARSHAL        NO\n\n// This switch allows use of #defines in place of pass-through marshaling or\n// unmarshaling code. A pass-through function just calls another function to do\n// the required function and does no parameter checking of its own. The\n// table-driven dispatcher calls directly to the lowest level\n// marshaling/unmarshaling code and by-passes any pass-through functions.\n#define USE_MARSHALING_DEFINES      YES\n\n// Switch added to support packed lists that leave out space associated with\n// unimplemented commands. Comment this out to use linear lists.\n// Note: if vendor specific commands are present, the associated list is always\n// in compressed form.\n#define COMPRESSED_LISTS            YES\n\n// This define is used to eliminate the use of bit-fields. It can be enabled for big-\n// or little-endian machines. For big-endian architectures that numbers bits in\n// registers from left to right (MSb0) this must be enabled. Little-endian machines\n// number from right to left with the least significant bit having assigned a bit\n// number of 0. These are LSb0 machines (they are also little-endian so they are also\n// least-significant byte 0 (LSB0) machines. Big-endian (MSB0) machines may number in\n// either direction (MSb0 or LSb0). For an MSB0+MSb0 machine this value is required to\n// be 'NO'\n#define USE_BIT_FIELD_STRUCTURES    NO\n\n// Enable the generation of RSA primes using a sieve.\n#define RSA_KEY_SIEVE               YES\n\n////////////////////////////////////////////////////////////////\n// Implementation alternatives - changes external behavior\n////////////////////////////////////////////////////////////////\n\n// This switch enables the RNG state save and restore\n#define _DRBG_STATE_SAVE            YES\n\n// Definition to allow alternate behavior for non-orderly startup. If there is a\n// chance that the TPM could not update 'failedTries'\n#define USE_DA_USED                 NO\n\n// This switch is used to enable the self-test capability in AlgorithmTests.c\n#define ENABLE_SELF_TESTS                   YES\n\n// This switch indicates where clock epoch value should be stored. If this value\n// defined, then it is assumed that the timer will change at any time so the\n// nonce should be a random number kept in RAM. When it is not defined, then the\n// timer only stops during power outages.\n#define CLOCK_STOPS                 NO\n\n// Indicate if the implementation is going to give lockout time credit for time up to\n// the last orderly shutdown.\n#define ACCUMULATE_SELF_HEAL_TIMER  YES\n\n// If an assertion event is not going to produce any trace information (function and\n// line number) then make FAIL_TRACE == NO\n#define FAIL_TRACE                  YES\n\n// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers\n#include \"CompilerDependencies.h\"\n\n#endif  // _TPM_BUILD_SWITCHES_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmCalculatedAttributes.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPM_CALCULATED_ATTRIBUTES_H_\n#define _TPM_CALCULATED_ATTRIBUTES_H_\n\n#include \"TpmAlgorithmDefines.h\"\n#include \"GpMacros.h\"\n\n#define JOIN(x, y)       x##y\n#define JOIN3(x, y, z)   x##y##z\n#define CONCAT(x, y)     JOIN(x, y)\n#define CONCAT3(x, y, z) JOIN3(x, y, z)\n\n//** Derived from Vendor-specific values\n// Values derived from vendor specific settings in TpmProfile.h\n#define PCR_SELECT_MIN    ((PLATFORM_PCR + 7) / 8)\n#define PCR_SELECT_MAX    ((IMPLEMENTATION_PCR + 7) / 8)\n#define MAX_ORDERLY_COUNT ((1 << ORDERLY_BITS) - 1)\n#define RSA_MAX_PRIME     (MAX_RSA_KEY_BYTES / 2)\n#define RSA_PRIVATE_SIZE  (RSA_MAX_PRIME * 5)\n\n// If CONTEXT_INTEGRITY_HASH_ALG is defined, then the vendor is using the old style\n// table. Otherwise, pick the \"strongest\" implemented hash algorithm as the context\n// hash.\n#ifndef CONTEXT_HASH_ALGORITHM\n#  if defined ALG_SHA3_512 && ALG_SHA3_512 == YES\n#    define CONTEXT_HASH_ALGORITHM SHA3_512\n#  elif defined ALG_SHA512 && ALG_SHA512 == YES\n#    define CONTEXT_HASH_ALGORITHM SHA512\n#  elif defined ALG_SHA3_384 && ALG_SHA3_384 == YES\n#    define CONTEXT_HASH_ALGORITHM SHA3_384\n#  elif defined ALG_SHA384 && ALG_SHA384 == YES\n#    define CONTEXT_HASH_ALGORITHM SHA384\n#  elif defined ALG_SHA3_256 && ALG_SHA3_256 == YES\n#    define CONTEXT_HASH_ALGORITHM SHA3_256\n#  elif defined ALG_SHA256 && ALG_SHA256 == YES\n#    define CONTEXT_HASH_ALGORITHM SHA256\n#  elif defined ALG_SM3_256 && ALG_SM3_256 == YES\n#    define CONTEXT_HASH_ALGORITHM SM3_256\n#  elif defined ALG_SHA1 && ALG_SHA1 == YES\n#    define CONTEXT_HASH_ALGORITHM SHA1\n#  endif\n#  define CONTEXT_INTEGRITY_HASH_ALG CONCAT(TPM_ALG_, CONTEXT_HASH_ALGORITHM)\n#endif\n\n#ifndef CONTEXT_INTEGRITY_HASH_SIZE\n#  define CONTEXT_INTEGRITY_HASH_SIZE CONCAT(CONTEXT_HASH_ALGORITHM, _DIGEST_SIZE)\n#endif\n#if ALG_RSA\n#  define RSA_SECURITY_STRENGTH\t\t\t\t     \\\n    (MAX_RSA_KEY_BITS >= 15360\t\t\t\t\t\t\\\n     ? 256\t\t\t\t\t\t\t\t\\\n     : (MAX_RSA_KEY_BITS >= 7680\t\t\t\t\t\\\n\t? 192\t\t\t\t\t\t\t\t\\\n\t: (MAX_RSA_KEY_BITS >= 3072\t\t\t\t\t\\\n\t   ? 128\t\t\t\t\t\t\t\\\n\t   : (MAX_RSA_KEY_BITS >= 2048\t\t\t\t\t\\\n\t      ? 112\t\t\t\t\t\t\t\\\n\t      : (MAX_RSA_KEY_BITS >= 1024 ? 80 : 0)))))\n#else\n#  define RSA_SECURITY_STRENGTH 0\n#endif  // ALG_RSA\n\n#if ALG_ECC\n#  define ECC_SECURITY_STRENGTH\t\t\\\n    (MAX_ECC_KEY_BITS >= 521\t\t\t\t\\\n     ? 256\t\t\t\t\t\t\t\t\\\n     : (MAX_ECC_KEY_BITS >= 384 ? 192 : (MAX_ECC_KEY_BITS >= 256 ? 128 : 0)))\n#else\n#  define ECC_SECURITY_STRENGTH 0\n#endif  // ALG_ECC\n\n#define MAX_ASYM_SECURITY_STRENGTH MAX(RSA_SECURITY_STRENGTH, ECC_SECURITY_STRENGTH)\n\n#define MAX_HASH_SECURITY_STRENGTH ((CONTEXT_INTEGRITY_HASH_SIZE * 8) / 2)\n\n// Unless some algorithm is broken...\n#define MAX_SYM_SECURITY_STRENGTH MAX_SYM_KEY_BITS\n\n#define MAX_SECURITY_STRENGTH_BITS\t    \\\n    MAX(MAX_ASYM_SECURITY_STRENGTH,\t\t\t\t\t\\\n\tMAX(MAX_SYM_SECURITY_STRENGTH, MAX_HASH_SECURITY_STRENGTH))\n\n// This is the size that was used before the 1.38 errata requiring that P1.14.4 be\n// followed\n#define PROOF_SIZE CONTEXT_INTEGRITY_HASH_SIZE\n\n// As required by P1.14.4\n#define COMPLIANT_PROOF_SIZE\t\t\t\t\t\t\\\n    (MAX(CONTEXT_INTEGRITY_HASH_SIZE, (2 * MAX_SYM_KEY_BYTES)))\n\n// As required by P1.14.3.1\n#define COMPLIANT_PRIMARY_SEED_SIZE BITS_TO_BYTES(MAX_SECURITY_STRENGTH_BITS * 2)\n\n// This is the pre-errata version\n#ifndef PRIMARY_SEED_SIZE\n#  define PRIMARY_SEED_SIZE PROOF_SIZE\n#endif\n\n#if USE_SPEC_COMPLIANT_PROOFS\n#  undef PROOF_SIZE\n#  define PROOF_SIZE COMPLIANT_PROOF_SIZE\n#  undef PRIMARY_SEED_SIZE\n#  define PRIMARY_SEED_SIZE COMPLIANT_PRIMARY_SEED_SIZE\n#endif  // USE_SPEC_COMPLIANT_PROOFS\n\n#if !SKIP_PROOF_ERRORS\n#  if PROOF_SIZE < COMPLIANT_PROOF_SIZE\n#    error \"PROOF_SIZE is not compliant with TPM specification\"\n#  endif\n#  if PRIMARY_SEED_SIZE < COMPLIANT_PRIMARY_SEED_SIZE\n#    error Non-compliant PRIMARY_SEED_SIZE\n#  endif\n#endif  // !SKIP_PROOF_ERRORS\n\n// If CONTEXT_ENCRYPT_ALG is defined, then the vendor is using the old style table\n#if defined CONTEXT_ENCRYPT_ALG\n#  undef CONTEXT_ENCRYPT_ALGORITHM\n#  if CONTEXT_ENCRYPT_ALG == ALG_AES_VALUE\n#    define CONTEXT_ENCRYPT_ALGORITHM AES\n#  elif CONTEXT_ENCRYPT_ALG == ALG_SM4_VALUE\n#    define CONTEXT_ENCRYPT_ALGORITHM SM4\n#  elif CONTEXT_ENCRYPT_ALG == ALG_CAMELLIA_VALUE\n#    define CONTEXT_ENCRYPT_ALGORITHM CAMELLIA\n#  else\n#    error Unknown value for CONTEXT_ENCRYPT_ALG\n#  endif  // CONTEXT_ENCRYPT_ALG == ALG_AES_VALUE\n#else\n#  define CONTEXT_ENCRYPT_ALG CONCAT3(ALG_, CONTEXT_ENCRYPT_ALGORITHM, _VALUE)\n#endif  // CONTEXT_ENCRYPT_ALG\n#define CONTEXT_ENCRYPT_KEY_BITS  CONCAT(CONTEXT_ENCRYPT_ALGORITHM, _MAX_KEY_SIZE_BITS)\n#define CONTEXT_ENCRYPT_KEY_BYTES ((CONTEXT_ENCRYPT_KEY_BITS + 7) / 8)\n\n// This is updated to follow the requirement of P2 that the label not be larger\n// than 32 bytes.\n#ifndef LABEL_MAX_BUFFER\n#  define LABEL_MAX_BUFFER MIN(32, MAX(MAX_ECC_KEY_BYTES, MAX_DIGEST_SIZE))\n#endif\n\n// This bit is used to indicate that an authorization ticket expires on TPM Reset\n// and TPM Restart. It is added to the timeout value returned by TPM2_PoliySigned()\n// and TPM2_PolicySecret() and used by TPM2_PolicyTicket(). The timeout value is\n// relative to Time (g_time). Time is reset whenever the TPM loses power and cannot\n// be moved forward by the user (as can Clock). 'g_time' is a 64-bit value expressing\n// time in ms. Stealing the MSb for a flag means that the TPM needs to be reset\n// at least once every 292,471,208 years rather than once every 584,942,417 years.\n#define EXPIRATION_BIT ((UINT64)1 << 63)\n\n// This definition is moved from TpmProfile.h because it is not actually vendor-\n// specific. It has to be the same size as the 'sequence' parameter of a TPMS_CONTEXT\n// and that is a UINT64. So, this is an invariant value\n#define CONTEXT_COUNTER UINT64\n#endif  // _TPM_CALCULATED_ATTRIBUTES_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmEcc_Signature_ECDAA_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPMECC_SIGNATURE_ECDAA_FP_H_\n#define _TPMECC_SIGNATURE_ECDAA_FP_H_\n#if ALG_ECC && ALG_ECDAA\n\n//*** TpmEcc_SignEcdaa()\n//\n// This function performs 's' = 'r' + 'T' * 'd' mod 'q' where\n// 1) 'r' is a random, or pseudo-random value created in the commit phase\n// 2) 'nonceK' is a TPM-generated, random value 0 < 'nonceK' < 'n'\n// 3) 'T' is mod 'q' of \"Hash\"('nonceK' || 'digest'), and\n// 4) 'd' is a private key.\n//\n// The signature is the tuple ('nonceK', 's')\n//\n// Regrettably, the parameters in this function kind of collide with the parameter\n// names used in ECSCHNORR making for a lot of confusion.\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME       unsupported hash algorithm\n//      TPM_RC_NO_RESULT    cannot get values from random number generator\nTPM_RC TpmEcc_SignEcdaa(\n\t\t\tTPM2B_ECC_PARAMETER*  nonceK,  // OUT: 'nonce' component of the signature\n\t\t\tCrypt_Int*            bnS,     // OUT: 's' component of the signature\n\t\t\tconst Crypt_EccCurve* E,       // IN: the curve used in signing\n\t\t\tCrypt_Int*            bnD,     // IN: the private key\n\t\t\tconst TPM2B_DIGEST*   digest,  // IN: the value to sign (mod 'q')\n\t\t\tTPMT_ECC_SCHEME*      scheme,  // IN: signing scheme (contains the\n\t\t\t//      commit count value).\n\t\t\tOBJECT*     eccKey,            // IN: The signing key\n\t\t\tRAND_STATE* rand               // IN: a random number state\n\t\t\t);\n\n#endif  // ALG_ECC && ALG_ECDAA\n#endif  // _TPMECC_SIGNATURE_ECDAA_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmEcc_Signature_ECDSA_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPMECC_SIGNATURE_ECDSA_FP_H_\n#define _TPMECC_SIGNATURE_ECDSA_FP_H_\n#if ALG_ECC && ALG_ECDSA\n\n//*** TpmEcc_SignEcdsa()\n// This function implements the ECDSA signing algorithm. The method is described\n// in the comments below.\nTPM_RC\nTpmEcc_SignEcdsa(Crypt_Int*            bnR,   // OUT: 'r' component of the signature\n\t\t Crypt_Int*            bnS,   // OUT: 's' component of the signature\n\t\t const Crypt_EccCurve* E,     // IN: the curve used in the signature\n\t\t //     process\n\t\t Crypt_Int*          bnD,     // IN: private signing key\n\t\t const TPM2B_DIGEST* digest,  // IN: the digest to sign\n\t\t RAND_STATE*         rand     // IN: used in debug of signing\n\t\t );\n\n//*** TpmEcc_ValidateSignatureEcdsa()\n// This function validates an ECDSA signature. rIn and sIn should have been checked\n// to make sure that they are in the range 0 < 'v' < 'n'\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE           signature not valid\nTPM_RC\nTpmEcc_ValidateSignatureEcdsa(\n\t\t\t      Crypt_Int*            bnR,  // IN: 'r' component of the signature\n\t\t\t      Crypt_Int*            bnS,  // IN: 's' component of the signature\n\t\t\t      const Crypt_EccCurve* E,    // IN: the curve used in the signature\n\t\t\t      //     process\n\t\t\t      const Crypt_Point*  ecQ,    // IN: the public point of the key\n\t\t\t      const TPM2B_DIGEST* digest  // IN: the digest that was signed\n\t\t\t      );\n\n#endif  // ALG_ECC && ALG_ECDSA\n#endif  // _TPMECC_SIGNATURE_ECDSA_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmEcc_Signature_SM2_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPMECC_SIGNATURE_SM2_FP_H_\n#define _TPMECC_SIGNATURE_SM2_FP_H_\n\n#if ALG_ECC && ALG_SM2\n//*** TpmEcc_SignEcSm2()\n// This function signs a digest using the method defined in SM2 Part 2. The method\n// in the standard will add a header to the message to be signed that is a hash of\n// the values that define the key. This then hashed with the message to produce a\n// digest ('e'). This function signs 'e'.\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE         bad curve\nTPM_RC TpmEcc_SignEcSm2(Crypt_Int* bnR,  // OUT: 'r' component of the signature\n\t\t\tCrypt_Int* bnS,  // OUT: 's' component of the signature\n\t\t\tconst Crypt_EccCurve* E,    // IN: the curve used in signing\n\t\t\tCrypt_Int*            bnD,  // IN: the private key\n\t\t\tconst TPM2B_DIGEST*   digest,  // IN: the digest to sign\n\t\t\tRAND_STATE* rand  // IN: random number generator (mostly for\n\t\t\t//     debug)\n\t\t\t);\n\n//*** TpmEcc_ValidateSignatureEcSm2()\n// This function is used to validate an SM2 signature.\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE            signature not valid\nTPM_RC TpmEcc_ValidateSignatureEcSm2(\n\t\t\t\t     Crypt_Int*            bnR,  // IN: 'r' component of the signature\n\t\t\t\t     Crypt_Int*            bnS,  // IN: 's' component of the signature\n\t\t\t\t     const Crypt_EccCurve* E,    // IN: the curve used in the signature\n\t\t\t\t     //     process\n\t\t\t\t     Crypt_Point*        ecQ,    // IN: the public point of the key\n\t\t\t\t     const TPM2B_DIGEST* digest  // IN: the digest that was signed\n\t\t\t\t     );\n\n#endif  // ALG_ECC && ALG_SM2\n#endif  // _TPMECC_SIGNATURE_SM2_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmEcc_Signature_Schnorr_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPMECC_SIGNATURE_SCHNORR_FP_H_\n#define _TPMECC_SIGNATURE_SCHNORR_FP_H_\n\n#if ALG_ECC && ALG_ECSCHNORR\nTPM_RC TpmEcc_SignEcSchnorr(\n\t\t\t    Crypt_Int*            bnR,      // OUT: 'r' component of the signature\n\t\t\t    Crypt_Int*            bnS,      // OUT: 's' component of the signature\n\t\t\t    const Crypt_EccCurve* E,        // IN: the curve used in signing\n\t\t\t    Crypt_Int*            bnD,      // IN: the signing key\n\t\t\t    const TPM2B_DIGEST*   digest,   // IN: the digest to sign\n\t\t\t    TPM_ALG_ID            hashAlg,  // IN: signing scheme (contains a hash)\n\t\t\t    RAND_STATE*           rand      // IN: non-NULL when testing\n\t\t\t    );\n\n//*** TpmEcc_ValidateSignatureEcSchnorr()\n// This function is used to validate an EC Schnorr signature.\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE        signature not valid\nTPM_RC TpmEcc_ValidateSignatureEcSchnorr(\n\t\t\t\t\t Crypt_Int*            bnR,      // IN: 'r' component of the signature\n\t\t\t\t\t Crypt_Int*            bnS,      // IN: 's' component of the signature\n\t\t\t\t\t TPM_ALG_ID            hashAlg,  // IN: hash algorithm of the signature\n\t\t\t\t\t const Crypt_EccCurve* E,        // IN: the curve used in the signature\n\t\t\t\t\t //     process\n\t\t\t\t\t Crypt_Point*        ecQ,        // IN: the public point of the key\n\t\t\t\t\t const TPM2B_DIGEST* digest      // IN: the digest that was signed\n\t\t\t\t\t );\n\n#endif  // ALG_ECC && ALG_ECSCHNORR\n#endif  // _TPMECC_SIGNATURE_SCHNORR_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmEcc_Signature_Util_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// functions shared by multiple signature algorithms\n#ifndef _TPMECC_SIGNATURE_UTIL_FP_H_\n#define _TPMECC_SIGNATURE_UTIL_FP_H_\n\n#if ALG_ECC\n//*** TpmEcc_SchnorrCalculateS()\n// This contains the Schnorr signature (S) computation. It is used by both ECDSA and\n// Schnorr signing. The result is computed as: ['s' = 'k' + 'r' * 'd' (mod 'n')]\n// where\n// 1) 's' is the signature\n// 2) 'k' is a random value\n// 3) 'r' is the value to sign\n// 4) 'd' is the private EC key\n// 5) 'n' is the order of the curve\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        the result of the operation was zero or 'r' (mod 'n')\n//                              is zero\nTPM_RC TpmEcc_SchnorrCalculateS(\n\t\t\t\tCrypt_Int*       bnS,  // OUT: 's' component of the signature\n\t\t\t\tconst Crypt_Int* bnK,  // IN: a random value\n\t\t\t\tCrypt_Int*       bnR,  // IN: the signature 'r' value\n\t\t\t\tconst Crypt_Int* bnD,  // IN: the private key\n\t\t\t\tconst Crypt_Int* bnN   // IN: the order of the curve\n\t\t\t\t);\n\n#endif  // ALG_ECC\n#endif  // _TPMECC_SIGNATURE_UTIL_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmEcc_Util_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPMECC_UTIL_FP_H_\n#define _TPMECC_UTIL_FP_H_\n\n#if ALG_ECC\n\n//*** TpmEcc_PointFrom2B()\n// Function to create a Crypt_Point structure from a 2B point.\n// This function doesn't take an Crypt_EccCurve for legacy reasons -\n// this should probably be changed.\n// returns NULL if the input value is invalid or doesn't fit.\nLIB_EXPORT Crypt_Point* TpmEcc_PointFrom2B(\n\t\t\t\t\t   Crypt_Point*    ecP,  // OUT: the preallocated point structure\n\t\t\t\t\t   TPMS_ECC_POINT* p     // IN: the number to convert\n\t\t\t\t\t   );\n\n//*** TpmEcc_PointTo2B()\n// This function converts a Crypt_Point into a TPMS_ECC_POINT. A TPMS_ECC_POINT\n// contains two TPM2B_ECC_PARAMETER values. The maximum size of the parameters\n// is dependent on the maximum EC key size used in an implementation.\n// The presumption is that the TPMS_ECC_POINT is large enough to hold 2 TPM2B\n// values, each as large as a MAX_ECC_PARAMETER_BYTES\nLIB_EXPORT BOOL TpmEcc_PointTo2B(\n\t\t\t\t TPMS_ECC_POINT*       p,    // OUT: the converted 2B structure\n\t\t\t\t const Crypt_Point*    ecP,  // IN: the values to be converted\n\t\t\t\t const Crypt_EccCurve* E     // IN: curve descriptor for the point\n\t\t\t\t );\n\n#endif  // ALG_ECC\n#endif  // _TPMECC_UTIL_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmError.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TpmError.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef TPMERROR_H\n#define TPMERROR_H\n\n/* 5.23\tTpmError.h */\n\n#define     FATAL_ERROR_ALLOCATION              (1)\n#define     FATAL_ERROR_DIVIDE_ZERO             (2)\n#define     FATAL_ERROR_INTERNAL                (3)\n#define     FATAL_ERROR_PARAMETER               (4)\n#define     FATAL_ERROR_ENTROPY                 (5)\n#define     FATAL_ERROR_SELF_TEST               (6)\n#define     FATAL_ERROR_CRYPTO                  (7)\n#define     FATAL_ERROR_NV_UNRECOVERABLE        (8)\n#define     FATAL_ERROR_REMANUFACTURED          (9) // indicates that the TPM has\n                                                    // been re-manufactured after an\n                                                    // unrecoverable NV error\n#define     FATAL_ERROR_DRBG                    (10)\n#define     FATAL_ERROR_MOVE_SIZE               (11)\n#define     FATAL_ERROR_COUNTER_OVERFLOW        (12)\n#define     FATAL_ERROR_SUBTRACT                (13)\n#define     FATAL_ERROR_FORCED                  (666)\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmFail_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Failure Mode Handling\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Apr  2, 2019  Time: 03:18:00PM\n */\n\n#ifndef _TPM_FAIL_FP_H_\n#define _TPM_FAIL_FP_H_\n\n//*** SetForceFailureMode()\n// This function is called by the simulator to enable failure mode testing.\n#if SIMULATION\nLIB_EXPORT void SetForceFailureMode(void);\n#endif\n\n//*** TpmFail()\n// This function is called by TPM.lib when a failure occurs. It will set up the\n// failure values to be returned on TPM2_GetTestResult().\n// NORETURN void TpmFail(\nvoid TpmFail(\n#if FAIL_TRACE\n\t\t      const char* function,\n\t\t      int         line,\n#else\n\t\t      uint64_t locationCode,\n#endif\n\t\t      int failureCode);\n\n//*** TpmFailureMode(\n// This function is called by the interface code when the platform is in failure\n// mode.\nvoid TpmFailureMode(uint32_t        inRequestSize,    // IN: command buffer size\n\t\t    unsigned char*  inRequest,        // IN: command buffer\n\t\t    uint32_t*       outResponseSize,  // OUT: response buffer size\n\t\t    unsigned char** outResponse       // OUT: response buffer\n\t\t    );\n\n//*** UnmarshalFail()\n// This is a stub that is used to catch an attempt to unmarshal an entry\n// that is not defined. Don't ever expect this to be called but...\nvoid UnmarshalFail(void* type, BYTE** buffer, INT32* size);\n\n#endif  // _TPM_FAIL_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmMath_Debug_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//\n// debug and test utilities.  Not expected to be compiled into final products\n#ifndef _TPMMATH_DEBUG_FP_H_\n#define _TPMMATH_DEBUG_FP_H_\n\n#if ALG_ECC || ALG_RSA\n\n//*** TpmEccDebug_HexEqual()\n// This function compares a bignum value to a hex string.\n// using TpmEcc namespace because code assumes the max size\n// is correct for ECC.\n//  Return Type: BOOL\n//      TRUE(1)         values equal\n//      FALSE(0)        values not equal\nBOOL TpmMath_Debug_HexEqual(const Crypt_Int* bn,  //IN: big number value\n\t\t\t    const char*      c    //IN: character string number\n\t\t\t    );\n\nLIB_EXPORT Crypt_Int* TpmMath_Debug_FromHex(\n\t\t\t\t\t    Crypt_Int*           bn,         // OUT:\n\t\t\t\t\t    const unsigned char* hex,        // IN:\n\t\t\t\t\t    size_t               maxsizeHex  // IN: maximum size of hex\n\t\t\t\t\t    );\n\n#endif  // ALG_ECC or ALG_RSA\n#endif  //_TPMMATH_DEBUG_FP_H_"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmMath_Util_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPM_MATH_FP_H_\n#define _TPM_MATH_FP_H_\n\n//*** TpmMath_IntFrom2B()\n// Convert an TPM2B to a Crypt_Int.\n// If the input value does not exist, or the output does not exist, or the input\n// will not fit into the output the function returns NULL\nLIB_EXPORT Crypt_Int* TpmMath_IntFrom2B(Crypt_Int*   value,  // OUT:\n\t\t\t\t\tconst TPM2B* a2B     // IN: number to convert\n\t\t\t\t\t);\n\n//*** TpmMath_IntTo2B()\n//\n// Function to convert a Crypt_Int to TPM2B. The TPM2B bytes are\n// always in big-endian ordering (most significant byte first). If 'size' is\n// non-zero and less than required by `value` then an error is returned. If\n// `size` is non-zero and larger than `value`, the result buffer is padded\n// with zeros. If `size` is zero, then the TPM2B is assumed to be large enough\n// for the data and a2b->size will be adjusted accordingly.\nLIB_EXPORT BOOL TpmMath_IntTo2B(\n\t\t\t\tconst Crypt_Int* value,  // IN: value to convert\n\t\t\t\tTPM2B*           a2B,    // OUT: buffer for output\n\t\t\t\tNUMBYTES         size    // IN: Size of output buffer - see comments.\n\t\t\t\t);\n\n//*** TpmMath_GetRandomBits()\n// This function gets random bits for use in various places.\n//\n// One consequence of the generation scheme is that, if the number of bits requested\n// is not a multiple of 8, then the high-order bits are set to zero. This would come\n// into play when generating a 521-bit ECC key. A 66-byte (528-bit) value is\n// generated and the high order 7 bits are masked off (CLEAR).\n// In this situation, the highest order byte is the first byte (big-endian/TPM2B format)\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure\nLIB_EXPORT BOOL TpmMath_GetRandomBits(\n\t\t\t\t      BYTE*       pBuffer,  // OUT: buffer to set\n\t\t\t\t      size_t      bits,     // IN: number of bits to generate (see remarks)\n\t\t\t\t      RAND_STATE* rand      // IN: random engine\n\t\t\t\t      );\n\n//*** TpmMath_GetRandomInteger\n// This function generates a random integer with the requested number of bits.\n// Except for size, no range checking is performed.\n// The maximum size that can be created is LARGEST_NUMBER + 64 bits.\n// if either more bits, or the Crypt_Int* is too small to contain the requested bits\n// the TPM enters failure mode and this function returns FALSE.\nLIB_EXPORT BOOL TpmMath_GetRandomInteger(Crypt_Int* bn,  // OUT: integer buffer to set\n\t\t\t\t\t size_t     bits,  // IN: size of output,\n\t\t\t\t\t RAND_STATE* rand  // IN: random engine\n\t\t\t\t\t );\n\n//*** TpmMath_GetRandomInRange()\n// This function is used to generate a random number r in the range 1 <= r < limit.\n// The function gets a random number of bits that is the size of limit. There is some\n// some probability that the returned number is going to be greater than or equal\n// to the limit. If it is, try again. There is no more than 50% chance that the\n// next number is also greater, so try again. We keep trying until we get a\n// value that meets the criteria. Since limit is very often a number with a LOT of\n// high order ones, this rarely would need a second try.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure ('limit' is too small)\nLIB_EXPORT BOOL TpmMath_GetRandomInRange(\n\t\t\t\t\t Crypt_Int*       dest,   // OUT: integer buffer to set\n\t\t\t\t\t const Crypt_Int* limit,  // IN: limit (see remarks)\n\t\t\t\t\t RAND_STATE*      rand    // IN: random engine\n\t\t\t\t\t );\n\n#endif  //_TPM_MATH_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmProfile.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tConstants Reflecting a Particular TPM Implementation (e.g. PC Client)\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// The primary configuration file that collects all configuration options for a\n// TPM build.\n#ifndef _TPM_PROFILE_H_\n#define _TPM_PROFILE_H_\n\n#include \"TpmBuildSwitches.h\"\n#include \"TpmProfile_Common.h\"\n#include \"TpmProfile_CommandList.h\"\n#include \"TpmProfile_Misc.h\"\n#include \"TpmProfile_ErrorCodes.h\"\n#include \"VendorInfo.h\"\n\n#endif  // _TPM_PROFILE_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmProfile_CommandList.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// this file defines the desired command list that should be built into the\n// Tpm Core Lib.\n\n#ifndef _TPM_PROFILE_COMMAND_LIST_H_\n#define _TPM_PROFILE_COMMAND_LIST_H_\n\n#if(YES != 1 || NO != 0)\n#  error YES and NO must be correctly set before including TpmProfile_CommandList.h\n#endif\n#if defined(CC_YES) || defined(CC_NO)\n#  error CC_YES and CC_NO should be defined by the command line file, not before\n#endif\n\n#define CC_YES YES\n#define CC_NO  NO\n\n//\n// Defines for Implemented Commands\n//\n\n// Commands that are defined in the spec, but not implemented for various\n// reasons:\n\n// The TPM reference implementation does not implement attached-component\n// features, and the Compliance test suite has no test cases.\n#define CC_AC_GetCapability CC_NO\n#define CC_AC_Send          CC_NO\n\n// The TPM reference implementation does not implement firmware upgrade.\n#define CC_FieldUpgradeData  CC_NO\n#define CC_FieldUpgradeStart CC_NO\n#define CC_FirmwareRead      CC_NO\n\n// A prototype of CertifyX509 is provided here for informative purposes only.\n// While all of the TPM reference implementation is provided \"AS IS\" without any\n// warranty, the current design and implementation of CertifyX509 are considered\n// to be especially unsuitable for product use.\n#define CC_CertifyX509 CC_YES\n\n// Normal commands:\n\n#define CC_ACT_SetTimeout             (CC_YES && ACT_SUPPORT)\n#define CC_ActivateCredential         CC_YES\n#define CC_Certify                    CC_YES\n#define CC_CertifyCreation            CC_YES\n#define CC_ChangeEPS                  CC_YES\n#define CC_ChangePPS                  CC_YES\n#define CC_Clear                      CC_YES\n#define CC_ClearControl               CC_YES\n#define CC_ClockRateAdjust            CC_YES\n#define CC_ClockSet                   CC_YES\n#define CC_Commit                     (CC_YES && ALG_ECC)\n#define CC_ContextLoad                CC_YES\n#define CC_ContextSave                CC_YES\n#define CC_Create                     CC_YES\n#define CC_CreateLoaded               CC_YES\n#define CC_CreatePrimary              CC_YES\n#define CC_DictionaryAttackLockReset  CC_YES\n#define CC_DictionaryAttackParameters CC_YES\n#define CC_Duplicate                  CC_YES\n#define CC_ECC_Decrypt                (CC_YES && ALG_ECC)\n#define CC_ECC_Encrypt                (CC_YES && ALG_ECC)\n#define CC_ECC_Parameters             (CC_YES && ALG_ECC)\n#define CC_ECDH_KeyGen                (CC_YES && ALG_ECC)\n#define CC_ECDH_ZGen                  (CC_YES && ALG_ECC)\n#define CC_EC_Ephemeral               (CC_YES && ALG_ECC)\n#define CC_EncryptDecrypt             CC_YES\n#define CC_EncryptDecrypt2            CC_YES\n#define CC_EventSequenceComplete      CC_YES\n#define CC_EvictControl               CC_YES\n#define CC_FlushContext               CC_YES\n#define CC_GetCapability              CC_YES\n#define CC_GetCommandAuditDigest      CC_YES\n#define CC_GetRandom                  CC_YES\n#define CC_GetSessionAuditDigest      CC_YES\n#define CC_GetTestResult              CC_YES\n#define CC_GetTime                    CC_YES\n#define CC_HMAC                       (CC_YES && !ALG_CMAC)\n#define CC_HMAC_Start                 (CC_YES && !ALG_CMAC)\n#define CC_Hash                       CC_YES\n#define CC_HashSequenceStart          CC_YES\n#define CC_HierarchyChangeAuth        CC_YES\n#define CC_HierarchyControl           CC_YES\n#define CC_Import                     CC_YES\n#define CC_IncrementalSelfTest        CC_YES\n#define CC_Load                       CC_YES\n#define CC_LoadExternal               CC_YES\n#define CC_MAC                        (CC_YES && ALG_CMAC)\n#define CC_MAC_Start                  (CC_YES && ALG_CMAC)\n#define CC_MakeCredential             CC_YES\n#define CC_NV_Certify                 CC_YES\n#define CC_NV_ChangeAuth              CC_YES\n#define CC_NV_DefineSpace             CC_YES\n#define CC_NV_Extend                  CC_YES\n#define CC_NV_GlobalWriteLock         CC_YES\n#define CC_NV_Increment               CC_YES\n#define CC_NV_Read                    CC_YES\n#define CC_NV_ReadLock                CC_YES\n#define CC_NV_ReadPublic              CC_YES\n#define CC_NV_SetBits                 CC_YES\n#define CC_NV_UndefineSpace           CC_YES\n#define CC_NV_UndefineSpaceSpecial    CC_YES\n#define CC_NV_Write                   CC_YES\n#define CC_NV_WriteLock               CC_YES\n#define CC_ObjectChangeAuth           CC_YES\n#define CC_PCR_Allocate               CC_YES\n#define CC_PCR_Event                  CC_YES\n#define CC_PCR_Extend                 CC_YES\n#define CC_PCR_Read                   CC_YES\n#define CC_PCR_Reset                  CC_YES\n#define CC_PCR_SetAuthPolicy          CC_YES\n#define CC_PCR_SetAuthValue           CC_YES\n#define CC_PP_Commands                CC_YES\n#define CC_PolicyAuthValue            CC_YES\n#define CC_PolicyAuthorize            CC_YES\n#define CC_PolicyAuthorizeNV          CC_YES\n#define CC_PolicyCapability           CC_YES\n#define CC_PolicyCommandCode          CC_YES\n#define CC_PolicyCounterTimer         CC_YES\n#define CC_PolicyCpHash               CC_YES\n#define CC_PolicyDuplicationSelect    CC_YES\n#define CC_PolicyGetDigest            CC_YES\n#define CC_PolicyLocality             CC_YES\n#define CC_PolicyNV                   CC_YES\n#define CC_PolicyNameHash             CC_YES\n#define CC_PolicyNvWritten            CC_YES\n#define CC_PolicyOR                   CC_YES\n#define CC_PolicyPCR                  CC_YES\n#define CC_PolicyPassword             CC_YES\n#define CC_PolicyParameters           CC_YES\n#define CC_PolicyPhysicalPresence     CC_YES\n#define CC_PolicyRestart              CC_YES\n#define CC_PolicySecret               CC_YES\n#define CC_PolicySigned               CC_YES\n#define CC_PolicyTemplate             CC_YES\n#define CC_PolicyTicket               CC_YES\n#define CC_Policy_AC_SendSelect       CC_NO\t/* kgold */\n#define CC_Quote                      CC_YES\n#define CC_RSA_Decrypt                (CC_YES && ALG_RSA)\n#define CC_RSA_Encrypt                (CC_YES && ALG_RSA)\n#define CC_ReadClock                  CC_YES\n#define CC_ReadPublic                 CC_YES\n#define CC_Rewrap                     CC_YES\n#define CC_SelfTest                   CC_YES\n#define CC_SequenceComplete           CC_YES\n#define CC_SequenceUpdate             CC_YES\n#define CC_SetAlgorithmSet            CC_YES\n#define CC_SetCommandCodeAuditStatus  CC_YES\n#define CC_SetPrimaryPolicy           CC_YES\n#define CC_Shutdown                   CC_YES\n#define CC_Sign                       CC_YES\n#define CC_StartAuthSession           CC_YES\n#define CC_Startup                    CC_YES\n#define CC_StirRandom                 CC_YES\n#define CC_TestParms                  CC_YES\n#define CC_Unseal                     CC_YES\n#define CC_Vendor_TCG_Test            CC_YES\n#define CC_VerifySignature            CC_YES\n#define CC_ZGen_2Phase                (CC_YES && ALG_ECC)\n#define CC_NV_DefineSpace2            CC_YES\n#define CC_NV_ReadPublic2             CC_YES\n#define CC_SetCapability              CC_NO\n\n/* kgold */\n#define CC_NTC2_PreConfig             CC_YES\n#define CC_NTC2_LockPreConfig         CC_YES\n#define CC_NTC2_GetConfig             CC_YES\n\n#endif  // _TPM_PROFILE_COMMAND_LIST_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmProfile_Common.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// clang-format off\n// clang-format off to preserve define alignment breaking sections.\n\n// this file defines the common optional selections for the TPM library build\n// Requires basic YES/NO defines are already set (by TpmBuildSwitches.h)\n// Less frequently changed items are in other TpmProfile Headers.\n\n#ifndef _TPM_PROFILE_COMMON_H_\n#define _TPM_PROFILE_COMMON_H_\n// YES & NO defined by TpmBuildSwitches.h\n#if (YES != 1 || NO != 0)\n#  error YES or NO incorrectly set\n#endif\n#if defined(ALG_YES) || defined(ALG_NO)\n#  error ALG_YES and ALG_NO should only be defined by the TpmProfile_Common.h file\n#endif\n\n// Change these definitions to turn all algorithms ON or OFF. That is, to turn\n// all algorithms on, set ALG_NO to YES. This is intended as a debug feature.\n#define  ALG_YES                    YES\n#define  ALG_NO                     NO\n\n// Defines according to the processor being built for.\n// Are building for a BIG_ENDIAN processor?\n#ifndef BIG_ENDIAN_TPM\n#define  BIG_ENDIAN_TPM             NO\n#endif\n#define  LITTLE_ENDIAN_TPM          !BIG_ENDIAN_TPM\n// Does the processor put the most-significant bit at bit position 0?\n#define MOST_SIGNIFICANT_BIT_0      NO\n#define LEAST_SIGNIFICANT_BIT_0     !MOST_SIGNIFICANT_BIT_0\n// Does processor support Auto align?\n#define  AUTO_ALIGN                 NO\n\n//***********************************************\n// Defines for Symmetric Algorithms\n//***********************************************\n\n#define ALG_AES                     ALG_YES\n\n#define     AES_128                     (YES * ALG_AES)\n#define     AES_192                     (NO  * ALG_AES)\n#define     AES_256                     (YES * ALG_AES)\n\n#define ALG_SM4                     ALG_NO\n\n#define     SM4_128                     (NO  * ALG_SM4)\n\n#define ALG_CAMELLIA                ALG_YES\n\n#define     CAMELLIA_128                (YES * ALG_CAMELLIA)\n#define     CAMELLIA_192                (NO  * ALG_CAMELLIA)\n#define     CAMELLIA_256                (YES * ALG_CAMELLIA)\n\n// must be yes if any above are yes.\n#define ALG_SYMCIPHER               (ALG_AES || ALG_SM4 || ALG_CAMELLIA)\n#define ALG_CMAC                    (YES * ALG_SYMCIPHER)\n\n// block cipher modes\n#define ALG_CTR                     ALG_YES\n#define ALG_OFB                     ALG_YES\n#define ALG_CBC                     ALG_YES\n#define ALG_CFB                     ALG_YES\n#define ALG_ECB                     ALG_YES\n\n//***********************************************\n// Defines for RSA Asymmetric Algorithms\n//***********************************************\n#define ALG_RSA                     ALG_YES\n#define     RSA_1024                        (YES * ALG_RSA)\n#define     RSA_2048                        (YES * ALG_RSA)\n#define     RSA_3072                        (YES * ALG_RSA)\n#define     RSA_4096                        (YES * ALG_RSA)\n#define     RSA_16384                       (NO  * ALG_RSA)\n\n#define     ALG_RSASSA                      (YES * ALG_RSA)\n#define     ALG_RSAES                       (YES * ALG_RSA)\n#define     ALG_RSAPSS                      (YES * ALG_RSA)\n#define     ALG_OAEP                        (YES * ALG_RSA)\n\n// RSA Implementation Styles\n// use Chinese Remainder Theorem (5 prime) format for private key ?\n#define CRT_FORMAT_RSA                  YES\n#define RSA_DEFAULT_PUBLIC_EXPONENT     0x00010001\n\n//***********************************************\n// Defines for ECC Asymmetric Algorithms\n//***********************************************\n#define ALG_ECC                     ALG_YES\n#define     ALG_ECDH                        (YES * ALG_ECC)\n#define     ALG_ECDSA                       (YES * ALG_ECC)\n#define     ALG_ECDAA                       (YES * ALG_ECC)\n#define     ALG_SM2                         (YES * ALG_ECC)\n#define     ALG_ECSCHNORR                   (YES * ALG_ECC)\n#define     ALG_ECMQV                       (YES * ALG_ECC)\n#define     ALG_KDF1_SP800_56A              (YES * ALG_ECC)\n#define     ALG_EDDSA                       (NO  * ALG_ECC)\n#define     ALG_EDDSA_PH                    (NO  * ALG_ECC)\n\n#define     ECC_NIST_P192                   (YES * ALG_ECC)\n#define     ECC_NIST_P224                   (YES * ALG_ECC)\n#define     ECC_NIST_P256                   (YES * ALG_ECC)\n#define     ECC_NIST_P384                   (YES * ALG_ECC)\n#define     ECC_NIST_P521                   (YES * ALG_ECC)\n#define     ECC_BN_P256                     (YES * ALG_ECC)\n#define     ECC_BN_P638                     (YES * ALG_ECC)\n#define     ECC_SM2_P256                    (YES * ALG_ECC)\n\n#define     ECC_BP_P256_R1                  (NO * ALG_ECC)\n#define     ECC_BP_P384_R1                  (NO * ALG_ECC)\n#define     ECC_BP_P512_R1                  (NO * ALG_ECC)\n#define     ECC_CURVE_25519                 (NO * ALG_ECC)\n#define     ECC_CURVE_448                   (NO * ALG_ECC)\n\n//***********************************************\n// Defines for Hash/XOF Algorithms\n//***********************************************\n#define ALG_MGF1                            ALG_YES\n#define ALG_SHA1                            ALG_YES\n#define ALG_SHA256                          ALG_YES\n#define ALG_SHA256_192                      ALG_NO\n#define ALG_SHA384                          ALG_YES\n#define ALG_SHA512                          ALG_YES\n\n#define ALG_SHA3_256                        ALG_NO\n#define ALG_SHA3_384                        ALG_NO\n#define ALG_SHA3_512                        ALG_NO\n\n#define ALG_SM3_256                         ALG_NO\n\n#define ALG_SHAKE256_192                    ALG_NO\n#define ALG_SHAKE256_256                    ALG_NO\n#define ALG_SHAKE256_512                    ALG_NO\n\n//***********************************************\n// Defines for Stateful Signature Algorithms\n//***********************************************\n#define ALG_LMS                             ALG_NO\n#define ALG_XMSS                            ALG_NO\n\n//***********************************************\n// Defines for Keyed Hashes\n//***********************************************\n#define ALG_KEYEDHASH                       ALG_YES\n#define ALG_HMAC                            ALG_YES\n\n//***********************************************\n// Defines for KDFs\n//***********************************************\n#define ALG_KDF2                            ALG_YES\n#define ALG_KDF1_SP800_108                  ALG_YES\n\n//***********************************************\n// Defines for Obscuration/MISC/compatibility\n//***********************************************\n#define ALG_XOR                             ALG_YES\n\n//***********************************************\n// Defines controlling ACT\n//***********************************************\n#define ACT_SUPPORT                         NO\n// #define ACT_SUPPORT                         YES\n#define RH_ACT_0                                (YES * ACT_SUPPORT)\n#define RH_ACT_1                                ( NO * ACT_SUPPORT)\n#define RH_ACT_2                                ( NO * ACT_SUPPORT)\n#define RH_ACT_3                                ( NO * ACT_SUPPORT)\n#define RH_ACT_4                                ( NO * ACT_SUPPORT)\n#define RH_ACT_5                                ( NO * ACT_SUPPORT)\n#define RH_ACT_6                                ( NO * ACT_SUPPORT)\n#define RH_ACT_7                                ( NO * ACT_SUPPORT)\n#define RH_ACT_8                                ( NO * ACT_SUPPORT)\n#define RH_ACT_9                                ( NO * ACT_SUPPORT)\n#define RH_ACT_A                                (YES * ACT_SUPPORT)\n#define RH_ACT_B                                ( NO * ACT_SUPPORT)\n#define RH_ACT_C                                ( NO * ACT_SUPPORT)\n#define RH_ACT_D                                ( NO * ACT_SUPPORT)\n#define RH_ACT_E                                ( NO * ACT_SUPPORT)\n#define RH_ACT_F                                ( NO * ACT_SUPPORT)\n\n\n//***********************************************\n// Enable VENDOR_PERMANENT_AUTH_HANDLE?\n//***********************************************\n#define VENDOR_PERMANENT_AUTH_ENABLED       NO\n// if YES, this must be valid per Part2 (TPM_RH_AUTH_00 - TPM_RH_AUTH_FF)\n// if NO, this must be #undef\n#undef  VENDOR_PERMANENT_AUTH_HANDLE\n\n//***********************************************\n// Defines controlling optional implementation\n//***********************************************\n#define FIELD_UPGRADE_IMPLEMENTED           NO\n\n//***********************************************\n// Buffer Sizes based on implementation\n//***********************************************\n// When using PC CRB, the page size for both commands and\n// control registers is 4k.  The command buffer starts at\n// offset 0x80, so the net size available is:\n#define  MAX_COMMAND_SIZE               (4096-0x80)\n#define  MAX_RESPONSE_SIZE              (4096-0x80)\n\n//***********************************************\n// Vendor Info\n//***********************************************\n// max buffer for vendor commands\n// Max data buffer leaving space for TPM2B size prefix\n#define VENDOR_COMMAND_COUNT          0\n#define MAX_VENDOR_BUFFER_SIZE         (MAX_RESPONSE_SIZE-2)\n#define PRIVATE_VENDOR_SPECIFIC_BYTES RSA_PRIVATE_SIZE\n\n//***********************************************\n// Defines controlling Firmware- and SVN-limited objects\n//***********************************************\n#define FW_LIMITED_SUPPORT                    YES\n#define SVN_LIMITED_SUPPORT                   YES\n\n//***********************************************\n// Defines controlling External NV\n//***********************************************\n// This is a software reference implementation of the TPM: there is no\n// \"external NV\" as such. This #define configures the TPM to implement\n// \"external NV\" that is stored in the same place as \"internal NV.\"\n// NOTE: enabling this doesn't necessarily mean that the expanded\n// (external-NV-specific) attributes are supported.\n#define EXTERNAL_NV                           YES\n\n#endif // _TPM_PROFILE_COMMON_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmProfile_ErrorCodes.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file defines error codes used in failure macros in the TPM Core Library.\n// This file is part of TpmConfiguration because the Platform library can add error\n// codes of it's own, and ultimately the specific error codes are a vendor decision\n// because TPM2_GetTestResult returns manufacturer-defined data in failure mode.\n// The only thing in this file that must be consistent with a vendor's implementation\n// are the _names_ of error codes used by the core library.  Even the values can\n// change and are only a suggestion.\n\n#ifndef _TPMPROFILE_ERRORCODES_H\n#define _TPMPROFILE_ERRORCODES_H\n\n// turn off clang-format because alignment doesn't persist across comments\n// with current settings\n// clang-format off\n\n#define FATAL_ERROR_ALLOCATION       (1)\n#define FATAL_ERROR_DIVIDE_ZERO      (2)\n#define FATAL_ERROR_INTERNAL         (3)\n#define FATAL_ERROR_PARAMETER        (4)\n#define FATAL_ERROR_ENTROPY          (5)\n#define FATAL_ERROR_SELF_TEST        (6)\n#define FATAL_ERROR_CRYPTO           (7)\n#define FATAL_ERROR_NV_UNRECOVERABLE (8)\n\n// indicates that the TPM has been re-manufactured after an\n// unrecoverable NV error\n#define FATAL_ERROR_REMANUFACTURED   (9)\n#define FATAL_ERROR_DRBG             (10)\n#define FATAL_ERROR_MOVE_SIZE        (11)\n#define FATAL_ERROR_COUNTER_OVERFLOW (12)\n#define FATAL_ERROR_SUBTRACT         (13)\n#define FATAL_ERROR_MATHLIBRARY      (14)\n// end of codes defined through v1.52\n\n// leave space for numbers that may have been used by vendors or platforms.\n// Ultimately this file and these ranges are only a suggestion because\n// TPM2_GetTestResult returns manufacturer-defined data in failure mode.\n// Reserve 15-499\n#define FATAL_ERROR_RESERVED_START   (15)\n#define FATAL_ERROR_RESERVED_END     (499)\n\n// Additional error codes defined by TPM library:\n#define FATAL_ERROR_ASSERT           (500)\n// Platform library violated interface contract.\n#define FATAL_ERROR_PLATFORM         (600)\n\n// Test/Simulator errors 1000+\n#define FATAL_ERROR_FORCED           (1000)\n\n#endif  // _TPMPROFILE_ERRORCODES_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmProfile_Misc.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// Misc profile settings that don't currently have a better home.\n// These are rarely changed, but available for vendor customization.\n\n#ifndef _TPM_PROFILE_MISC_H_\n#define _TPM_PROFILE_MISC_H_\n\n// YES & NO defined by TpmBuildSwitches.h\n#if(YES != 1 || NO != 0)\n#  error YES or NO incorrectly set\n#endif\n\n// clang-format off\n// clang-format off to preserve horizontal spacing\n#define IMPLEMENTATION_PCR         24\n#define PLATFORM_PCR               24\n#define DRTM_PCR                   17\n#define HCRTM_PCR                  0\n#define NUM_LOCALITIES             5\n#define MAX_HANDLE_NUM             3\n#define MAX_ACTIVE_SESSIONS        64\n#define MAX_LOADED_SESSIONS        3\n#define MAX_SESSION_NUM            3\n#define MAX_LOADED_OBJECTS         3\n#define MIN_EVICT_OBJECTS          7\t/* kgold for PC client */\n#define NUM_POLICY_PCR_GROUP       1\n#define NUM_AUTHVALUE_PCR_GROUP    1\n//#define MAX_CONTEXT_SIZE           2168\n#define MAX_CONTEXT_SIZE           2680\t/* kgold for RSA-3072 */\n#define MAX_DIGEST_BUFFER          1024\n#define MAX_NV_INDEX_SIZE          2048\n#define MAX_NV_BUFFER_SIZE         1024\n#define MAX_CAP_BUFFER             1024\n#define NV_MEMORY_SIZE             32768 /* kgold */\n#define MIN_COUNTER_INDICES        8\n#define NUM_STATIC_PCR             16\n#define MAX_ALG_LIST_SIZE          64\n#define PRIMARY_SEED_SIZE          32\n#define CONTEXT_ENCRYPT_ALGORITHM  AES\n#define NV_CLOCK_UPDATE_INTERVAL   22\n#define NUM_POLICY_PCR             1\n\n#define ORDERLY_BITS               8\n#define MAX_SYM_DATA               128\n#define MAX_RNG_ENTROPY_SIZE       64\n#define RAM_INDEX_SPACE            512\n#define ENABLE_PCR_NO_INCREMENT    YES\n\n#define SIZE_OF_X509_SERIAL_NUMBER 20\n\n// amount of space the platform can provide in PERSISTENT_DATA during\n// manufacture\n#define PERSISTENT_DATA_PLATFORM_SPACE  16\n\n// structure padding space for these structures.  Used if a\n// particular configuration needs them to be aligned to a\n// specific size\n#define ORDERLY_DATA_PADDING            0\n#define STATE_CLEAR_DATA_PADDING        0\n#define STATE_RESET_DATA_PADDING        0\n\n// configuration values that may vary by SIMULATION/DEBUG\n#if SIMULATION && DEBUG\n// This forces the use of a smaller context slot size. This reduction reduces the\n// range of the epoch allowing the tester to force the epoch to occur faster than\n// the normal production size\n#  define CONTEXT_SLOT UINT8\n#else\n#  define CONTEXT_SLOT UINT16\n#endif\n\n#endif  // _TPM_PROFILE_MISC_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmSizeChecks_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Check COmpiler Options   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TpmSizeChecks_fp.h 1519 2019-11-15 20:43:51Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef TPMSIZECHECKS_FP_H\n#define TPMSIZECHECKS_FP_H\n\nBOOL TpmSizeChecks(void);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmTcpProtocol.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tTPM commands are communicated as BYTE streams on a TCP connection\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TpmTcpProtocol.h 1658 2021-01-22 23:14:01Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* D.3 TpmTcpProtocol.h */\n/* D.3.1. Introduction */\n/* TPM commands are communicated as uint8_t streams on a TCP connection.  The TPM command protocol is\n   enveloped with the interface protocol described in this file. The command is indicated by a\n   uint32_t with one of the values below.  Most commands take no parameters and return no TPM errors. In\n   these cases the TPM interface protocol acknowledges that command processing is completed by\n   returning a uint32_t = 0. The command TPM_SIGNAL_HASH_DATA takes a uint32_t-prepended variable length\n   byte array and the interface protocol acknowledges command completion with a uint32_t = 0. Most TPM\n   commands are enveloped using the TPM_SEND_COMMAND interface command. The parameters are as\n   indicated below.  The interface layer also appends a uin32_t = 0 to the TPM response for\n   regularity. */\n/* D.3.2. Typedefs and Defines */\n#ifndef     TCP_TPM_PROTOCOL_H\n#define     TCP_TPM_PROTOCOL_H\n/* D.3.3. TPM Commands All commands acknowledge processing by returning a uint32_t = 0 except where\n   noted */\n#define TPM_SIGNAL_POWER_ON         1\n#define TPM_SIGNAL_POWER_OFF        2\n#define TPM_SIGNAL_PHYS_PRES_ON     3\n#define TPM_SIGNAL_PHYS_PRES_OFF    4\n#define TPM_SIGNAL_HASH_START       5\n#define TPM_SIGNAL_HASH_DATA        6\n    // {uint32_t BufferSize, uint8_t[BufferSize] Buffer}\n#define TPM_SIGNAL_HASH_END         7\n#define TPM_SEND_COMMAND            8\n// {uint8_t Locality, uint32_t InBufferSize, uint8_t[InBufferSize] InBuffer} ->\n//     {uint32_t OutBufferSize, uint8_t[OutBufferSize] OutBuffer}\n#define TPM_SIGNAL_CANCEL_ON        9\n#define TPM_SIGNAL_CANCEL_OFF       10\n#define TPM_SIGNAL_NV_ON            11\n#define TPM_SIGNAL_NV_OFF           12\n#define TPM_SIGNAL_KEY_CACHE_ON     13\n#define TPM_SIGNAL_KEY_CACHE_OFF    14\n#define TPM_REMOTE_HANDSHAKE        15\n#define TPM_SET_ALTERNATIVE_RESULT  16\n#define TPM_SIGNAL_RESET            17\n#define TPM_SIGNAL_RESTART          18\n#define TPM_SESSION_END             20\n#define TPM_STOP                    21\n#define TPM_GET_COMMAND_RESPONSE_SIZES  25\n#define TPM_ACT_GET_SIGNALED        26\n#define TPM_TEST_FAILURE_MODE       30\n\n// D.3.4.\tEnumerations and Structures\n\nenum TpmEndPointInfo\n    {\n\ttpmPlatformAvailable = 0x01,\n\ttpmUsesTbs = 0x02,\n\ttpmInRawMode = 0x04,\n\ttpmSupportsPP = 0x08\n    };\n\n#ifdef _MSC_VER\n#   pragma warning(push, 3)\n#endif\n\n// Existing RPC interface type definitions retained so that the implementation\n// can be re-used\ntypedef struct in_buffer\n{\n    unsigned long BufferSize;\n    unsigned char *Buffer;\n} _IN_BUFFER;\ntypedef unsigned char *_OUTPUT_BUFFER;\ntypedef struct out_buffer\n{\n    uint32_t         BufferSize;\n    _OUTPUT_BUFFER   Buffer;\n} _OUT_BUFFER;\n#ifdef _MSC_VER\n#   pragma warning(pop)\n#endif\n#ifndef WIN32\n// typedef unsigned long        DWORD;\n// typedef void                *LPVOID;\n#undef WINAPI\n#endif\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmToOsslHash.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// This header file is used to 'splice' the OpenSSL hash code into the TPM code.\n//\n#ifndef HASH_LIB_DEFINED\n#define HASH_LIB_DEFINED\n\n#define HASH_LIB_OSSL\n\n#include <openssl/evp.h>\n#include <openssl/sha.h>\n\n#if ALG_SM3_256\n#  if defined(OPENSSL_NO_SM3) || OPENSSL_VERSION_NUMBER < 0x10101010L\n#    error \"Current version of OpenSSL doesn't support SM3\"\n#  elif OPENSSL_VERSION_NUMBER >= 0x10200000L\n#    include <openssl/sm3.h>\n#  else\n// OpenSSL 1.1.1 keeps smX.h headers in the include/crypto directory,\n// and they do not get installed as part of the libssl package\n#    define SM3_LBLOCK (64 / 4)\n\ntypedef struct SM3state_st\n{\n    unsigned int A, B, C, D, E, F, G, H;\n    unsigned int Nl, Nh;\n    unsigned int data[SM3_LBLOCK];\n    unsigned int num;\n} SM3_CTX;\n\nint sm3_init(SM3_CTX* c);\nint sm3_update(SM3_CTX* c, const void* data, size_t len);\nint sm3_final(unsigned char* md, SM3_CTX* c);\n#  endif  // OpenSSL < 1.2\n#endif    // ALG_SM3_256\n\n#include <openssl/ossl_typ.h>\n\n//***************************************************************\n//** Links to the OpenSSL HASH code\n//***************************************************************\n\n// Redefine the internal name used for each of the hash state structures to the\n// name used by the library.\n// These defines need to be known in all parts of the TPM so that the structure\n// sizes can be properly computed when needed.\n#define tpmHashStateSHA1_t    SHA_CTX\n#define tpmHashStateSHA256_t  SHA256_CTX\n#define tpmHashStateSHA384_t  SHA512_CTX\n#define tpmHashStateSHA512_t  SHA512_CTX\n#define tpmHashStateSM3_256_t SM3_CTX\n\n// The defines below are only needed when compiling CryptHash.c or CryptSmac.c.\n// This isolation is primarily to avoid name space collision. However, if there\n// is a real collision, it will likely show up when the linker tries to put things\n// together.\n\n#ifdef _CRYPT_HASH_C_\n\ntypedef BYTE*       PBYTE;\ntypedef const BYTE* PCBYTE;\n\n// Define the interface between CryptHash.c to the functions provided by the\n// library. For each method, define the calling parameters of the method and then\n// define how the method is invoked in CryptHash.c.\n//\n// All hashes are required to have the same calling sequence. If they don't, create\n// a simple adaptation function that converts from the \"standard\" form of the call\n// to the form used by the specific hash (and then send a nasty letter to the\n// person who wrote the hash function for the library).\n//\n// The macro that calls the method also defines how the\n// parameters get swizzled between the default form (in CryptHash.c)and the\n// library form.\n//\n// Initialize the hash context\n#  define HASH_START_METHOD_DEF void(HASH_START_METHOD)(PANY_HASH_STATE state)\n#  define HASH_START(hashState) ((hashState)->def->method.start)(&(hashState)->state);\n\n// Add data to the hash\n#  define HASH_DATA_METHOD_DEF\t\t\t\t\t\t\\\n    void(HASH_DATA_METHOD)(PANY_HASH_STATE state, PCBYTE buffer, size_t size)\n#  define HASH_DATA(hashState, dInSize, dIn)\t\t\t\t\\\n    ((hashState)->def->method.data)(&(hashState)->state, dIn, dInSize)\n\n// Finalize the hash and get the digest\n#  define HASH_END_METHOD_DEF\t\t\t\t\t\t\\\n    void(HASH_END_METHOD)(BYTE * buffer, PANY_HASH_STATE state)\n#  define HASH_END(hashState, buffer)\t\t\t\t\t\\\n    ((hashState)->def->method.end)(buffer, &(hashState)->state)\n\n// Copy the hash context\n// Note: For import, export, and copy, memcpy() is used since there is no\n// reformatting necessary between the internal and external forms.\n#  define HASH_STATE_COPY_METHOD_DEF\t     \\\n    void(HASH_STATE_COPY_METHOD)(\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\tPANY_HASH_STATE to, PCANY_HASH_STATE from, size_t size)\n#  define HASH_STATE_COPY(hashStateOut, hashStateIn)\t\t      \\\n    ((hashStateIn)->def->method.copy)(&(hashStateOut)->state,\t\t\\\n\t\t\t\t      &(hashStateIn)->state,\t\t\\\n\t\t\t\t      (hashStateIn)->def->contextSize)\n\n// Copy (with reformatting when necessary) an internal hash structure to an\n// external blob\n#  define HASH_STATE_EXPORT_METHOD_DEF\t\t\t\t\t\\\n    void(HASH_STATE_EXPORT_METHOD)(BYTE * to, PCANY_HASH_STATE from, size_t size)\n#  define HASH_STATE_EXPORT(to, hashStateFrom)\t\t       \\\n    ((hashStateFrom)->def->method.copyOut)(\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t&(((BYTE*)(to))[offsetof(HASH_STATE, state)]), \\\n\t\t\t\t\t\t\t\t\t&(hashStateFrom)->state, \\\n\t\t\t\t\t\t\t\t\t(hashStateFrom)->def->contextSize)\n\n// Copy from an external blob to an internal formate (with reformatting when\n// necessary\n#  define HASH_STATE_IMPORT_METHOD_DEF\t\t\t\t\t\\\n    void(HASH_STATE_IMPORT_METHOD)(PANY_HASH_STATE to, const BYTE* from, size_t size)\n#  define HASH_STATE_IMPORT(hashStateTo, from)\t\t\t       \\\n    ((hashStateTo)->def->method.copyIn)(\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t&(hashStateTo)->state, \\\n\t\t\t\t\t\t\t\t\t&(((const BYTE*)(from))[offsetof(HASH_STATE, state)]), \\\n\t\t\t\t\t\t\t\t\t(hashStateTo)->def->contextSize)\n\n// Function aliases. The code in CryptHash.c uses the internal designation for the\n// functions. These need to be translated to the function names of the library.\n#  define tpmHashStart_SHA1          SHA1_Init\n#  define tpmHashData_SHA1           SHA1_Update\n#  define tpmHashEnd_SHA1            SHA1_Final\n#  define tpmHashStateCopy_SHA1      memcpy\n#  define tpmHashStateExport_SHA1    memcpy\n#  define tpmHashStateImport_SHA1    memcpy\n#  define tpmHashStart_SHA256        SHA256_Init\n#  define tpmHashData_SHA256         SHA256_Update\n#  define tpmHashEnd_SHA256          SHA256_Final\n#  define tpmHashStateCopy_SHA256    memcpy\n#  define tpmHashStateExport_SHA256  memcpy\n#  define tpmHashStateImport_SHA256  memcpy\n#  define tpmHashStart_SHA384        SHA384_Init\n#  define tpmHashData_SHA384         SHA384_Update\n#  define tpmHashEnd_SHA384          SHA384_Final\n#  define tpmHashStateCopy_SHA384    memcpy\n#  define tpmHashStateExport_SHA384  memcpy\n#  define tpmHashStateImport_SHA384  memcpy\n#  define tpmHashStart_SHA512        SHA512_Init\n#  define tpmHashData_SHA512         SHA512_Update\n#  define tpmHashEnd_SHA512          SHA512_Final\n#  define tpmHashStateCopy_SHA512    memcpy\n#  define tpmHashStateExport_SHA512  memcpy\n#  define tpmHashStateImport_SHA512  memcpy\n#  define tpmHashStart_SM3_256       sm3_init\n#  define tpmHashData_SM3_256        sm3_update\n#  define tpmHashEnd_SM3_256         sm3_final\n#  define tpmHashStateCopy_SM3_256   memcpy\n#  define tpmHashStateExport_SM3_256 memcpy\n#  define tpmHashStateImport_SM3_256 memcpy\n\n#endif  // _CRYPT_HASH_C_\n\n#define LibHashInit()\n// This definition would change if there were something to report\n#define HashLibSimulationEnd()\n\n#endif  // HASH_LIB_DEFINED\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmToOsslSupport_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tInitialization of the Interface to the OpenSSL Library\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmPrototypes; Version 3.0 July 18, 2017\n *  Date: Mar 28, 2019  Time: 08:25:19PM\n */\n\n#ifndef _TPM_TO_OSSL_SUPPORT_FP_H_\n#define _TPM_TO_OSSL_SUPPORT_FP_H_\n\n#if defined(HASH_LIB_OSSL) || defined(MATH_LIB_OSSL) || defined(SYM_LIB_OSSL)\n\n//*** BnSupportLibInit()\n// This does any initialization required by the support library.\nLIB_EXPORT int BnSupportLibInit(void);\n\n//*** OsslContextEnter()\n// This function is used to initialize an OpenSSL context at the start of a function\n// that will call to an OpenSSL math function.\nBN_CTX* OsslContextEnter(void);\n\n//*** OsslContextLeave()\n// This is the companion function to OsslContextEnter().\nvoid OsslContextLeave(BN_CTX* CTX);\n\n//*** OsslPushContext()\n// This function is used to create a frame in a context. All values allocated within\n// this context after the frame is started will be automatically freed when the\n// context (OsslPopContext()\nBN_CTX* OsslPushContext(BN_CTX* CTX);\n\n//*** OsslPopContext()\n// This is the companion function to OsslPushContext().\nvoid OsslPopContext(BN_CTX* CTX);\n#endif  // HASH_LIB_OSSL || MATH_LIB_OSSL || SYM_LIB_OSSL\n\n#endif  // _TPM_TO_OSSL_SUPPORT_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmToOsslSym.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tSplice the OpenSSL() library into the TPM code.    \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// This header file is used to 'splice' the OpenSSL library into the TPM code.\n//\n// The support required of a library are a hash module, a block cipher module and\n// portions of a big number library.\n\n// All of the library-dependent headers should have the same guard to that only the\n// first one gets defined.\n#ifndef SYM_LIB_DEFINED\n#define SYM_LIB_DEFINED\n\n#define SYM_LIB_OSSL\n\n#include <openssl/aes.h>\n\n#if ALG_SM4\n#  if defined(OPENSSL_NO_SM4) || OPENSSL_VERSION_NUMBER < 0x10101010L\n#    error \"Current version of OpenSSL doesn't support SM4\"\n#  elif OPENSSL_VERSION_NUMBER >= 0x10200000L\n#    include <openssl/sm4.h>\n#  else\n// OpenSSL 1.1.1 keeps smX.h headers in the include/crypto directory,\n// and they do not get installed as part of the libssl package\n\n#    define SM4_KEY_SCHEDULE 32\n\ntypedef struct SM4_KEY_st\n{\n    uint32_t rk[SM4_KEY_SCHEDULE];\n} SM4_KEY;\n\nint  SM4_set_key(const uint8_t* key, SM4_KEY* ks);\nvoid SM4_encrypt(const uint8_t* in, uint8_t* out, const SM4_KEY* ks);\nvoid SM4_decrypt(const uint8_t* in, uint8_t* out, const SM4_KEY* ks);\n#  endif  // OpenSSL < 1.2\n#endif    // ALG_SM4\n\n#if ALG_CAMELLIA\n#  include <openssl/camellia.h>\n#endif\n\n#include <openssl/bn.h>\n#include <openssl/ossl_typ.h>\n\n//***************************************************************\n//** Links to the OpenSSL symmetric algorithms.\n//***************************************************************\n\n// The Crypt functions that call the block encryption function use the parameters\n// in the order:\n//  1) keySchedule\n//  2) in buffer\n//  3) out buffer\n// Since open SSL uses the order in encryptoCall_t above, need to swizzle the\n// values to the order required by the library.\n#define SWIZZLE(keySchedule, in, out)\t\t\t\t\\\n    (const BYTE*)(in), (BYTE*)(out), (void*)(keySchedule)\n\n// Define the order of parameters to the library functions that do block encryption\n// and decryption.\ntypedef void (*TpmCryptSetSymKeyCall_t)(const BYTE* in, BYTE* out, void* keySchedule);\n\n//***************************************************************\n//** Links to the OpenSSL AES code\n//***************************************************************\n// Macros to set up the encryption/decryption key schedules\n//\n// AES:\n#define TpmCryptSetEncryptKeyAES(key, keySizeInBits, schedule)\t\t\\\n    AES_set_encrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES*)(schedule))\n#define TpmCryptSetDecryptKeyAES(key, keySizeInBits, schedule)\t\t\\\n    AES_set_decrypt_key((key), (keySizeInBits), (tpmKeyScheduleAES*)(schedule))\n\n// Macros to alias encryption calls to specific algorithms. This should be used\n// sparingly. Currently, only used by CryptSym.c and CryptRand.c\n//\n// When using these calls, to call the AES block encryption code, the caller\n// should use:\n//      TpmCryptEncryptAES(SWIZZLE(keySchedule, in, out));\n#define TpmCryptEncryptAES AES_encrypt\n#define TpmCryptDecryptAES AES_decrypt\n#define tpmKeyScheduleAES  AES_KEY\n\n//***************************************************************\n//** Links to the OpenSSL SM4 code\n//***************************************************************\n// Macros to set up the encryption/decryption key schedules\n#define TpmCryptSetEncryptKeySM4(key, keySizeInBits, schedule)\t\\\n    SM4_set_key((key), (tpmKeyScheduleSM4*)(schedule))\n#define TpmCryptSetDecryptKeySM4(key, keySizeInBits, schedule)\t\\\n    SM4_set_key((key), (tpmKeyScheduleSM4*)(schedule))\n\n// Macros to alias encryption calls to specific algorithms. This should be used\n// sparingly.\n#define TpmCryptEncryptSM4 SM4_encrypt\n#define TpmCryptDecryptSM4 SM4_decrypt\n#define tpmKeyScheduleSM4  SM4_KEY\n\n//***************************************************************\n//** Links to the OpenSSL CAMELLIA code\n//***************************************************************\n// Macros to set up the encryption/decryption key schedules\n#define TpmCryptSetEncryptKeyCAMELLIA(key, keySizeInBits, schedule)\t\\\n    Camellia_set_key((key), (keySizeInBits), (tpmKeyScheduleCAMELLIA*)(schedule))\n#define TpmCryptSetDecryptKeyCAMELLIA(key, keySizeInBits, schedule)\t\\\n    Camellia_set_key((key), (keySizeInBits), (tpmKeyScheduleCAMELLIA*)(schedule))\n\n// Macros to alias encryption calls to specific algorithms. This should be used\n// sparingly.\n#define TpmCryptEncryptCAMELLIA Camellia_encrypt\n#define TpmCryptDecryptCAMELLIA Camellia_decrypt\n#define tpmKeyScheduleCAMELLIA  CAMELLIA_KEY\n\n// Forward reference\n\ntypedef union tpmCryptKeySchedule_t tpmCryptKeySchedule_t;\n\n// This definition would change if there were something to report\n#define SymLibSimulationEnd()\n\n#endif  // SYM_LIB_DEFINED\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmToTpmBigNumMath.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains OpenSSL specific functions called by TpmBigNum library to provide\n// the TpmBigNum + OpenSSL math support.\n\n#ifndef _TPM_TO_TPMBIGNUM_MATH_H_\n#define _TPM_TO_TPMBIGNUM_MATH_H_\n\n#ifdef MATH_LIB_DEFINED\n#  error only one primary math library allowed\n#endif\n#define MATH_LIB_DEFINED\n\n// indicate the TPMBIGNUM library is active\n#define MATH_LIB_TPMBIGNUM\n\n// TODO_RENAME_INC_FOLDER: private refers to the TPM_CoreLib private headers\n#include \"GpMacros.h\"  // required for TpmFail_fp.h\n#include \"Capabilities.h\"\n#include \"TpmTypes.h\"  // requires capabilities & GpMacros\n#include \"BnValues.h\"\n\n#ifndef LIB_INCLUDE\n#  error include ordering error, LIB_INCLUDE not defined\n#endif\n#ifndef BN_MATH_LIB\n#  error BN_MATH_LIB not defined, required to provide BN library functions.\n#endif\n\n#if defined(CRYPT_CURVE_INITIALIZED) || defined(CRYPT_CURVE_FREE)\n#error include ordering error, expected CRYPT_CURVE_INITIALIZED & CRYPT_CURVE_FREE to be undefined.\n#endif\n\n// Add support library dependent definitions.\n// For TpmBigNum, we expect bigCurveData to be a defined type.\n#include LIB_INCLUDE(BnTo, BN_MATH_LIB, Math)\n\n#include \"BnConvert_fp.h\"\n#include \"BnMath_fp.h\"\n#include \"BnMemory_fp.h\"\n#include \"BnSupport_Interface.h\"\n\n// Define macros and types necessary for the math library abstraction layer\n// Create a data object backing a Crypt_Int big enough for the given number of\n// data bits\n#define CRYPT_INT_BUF(buftypename, bits) BN_STRUCT(buftypename, bits)\n\n// Create a data object backing a Crypt_Point big enough for the given number of\n// data bits, per coordinate\n#define CRYPT_POINT_BUF(buftypename, bits) BN_POINT_BUF(buftypename, bits)\n\n// Create an instance of a data object underlying Crypt_EccCurve on the stack\n// sufficient for given bit size.  In our case, all are the same size.\n#define CRYPT_CURVE_BUF(buftypename, max_size_in_bits) bigCurveData\n\n// now include the math library functional interface and instantiate the\n// Crypt_Int & related types\n// TODO_RENAME_INC_FOLDER: This should have a Tpm_Cryptolib_Common component prefix.\n#include \"MathLibraryInterface.h\"\n\n#endif  // _TPM_TO_TPMBIGNUM_MATH_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/TpmTypes.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  TPM Part 2 Headers\t   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 5.21\tTpmTypes.h */\n\n#ifndef TPMTYPES_H\n#define TPMTYPES_H\n\n#ifndef MAX_CAP_BUFFER\n#  error MAX_CAP_BUFFER must be defined before this file so it can calculate maximum capability sizes\n#endif\n#include \"Capabilities.h\"\n#include \"TpmAlgorithmDefines.h\"\n#include \"TpmCalculatedAttributes.h\"\n#include \"GpMacros.h\"\n\n/* TCG Algorithm Registry: Table 1:2 - Definition of TPM_ALG_ID Constants */\n\ntypedef UINT16                          TPM_ALG_ID;\n#define TYPE_OF_TPM_ALG_ID              UINT16\n#define     ALG_ERROR_VALUE             0x0000\n#define TPM_ALG_ERROR                   (TPM_ALG_ID)(ALG_ERROR_VALUE)\n#define     ALG_RSA_VALUE               0x0001\n#define TPM_ALG_RSA                     (TPM_ALG_ID)(ALG_RSA_VALUE)\n#define     ALG_TDES_VALUE              0x0003\n#define TPM_ALG_TDES                    (TPM_ALG_ID)(ALG_TDES_VALUE)\n#define     ALG_SHA_VALUE               0x0004\n#define TPM_ALG_SHA                     (TPM_ALG_ID)(ALG_SHA_VALUE)\n#define     ALG_SHA1_VALUE              0x0004\n#define TPM_ALG_SHA1                    (TPM_ALG_ID)(ALG_SHA1_VALUE)\n#define     ALG_HMAC_VALUE              0x0005\n#define TPM_ALG_HMAC                    (TPM_ALG_ID)(ALG_HMAC_VALUE)\n#define     ALG_AES_VALUE               0x0006\n#define TPM_ALG_AES                     (TPM_ALG_ID)(ALG_AES_VALUE)\n#define     ALG_MGF1_VALUE              0x0007\n#define TPM_ALG_MGF1                    (TPM_ALG_ID)(ALG_MGF1_VALUE)\n#define     ALG_KEYEDHASH_VALUE         0x0008\n#define TPM_ALG_KEYEDHASH               (TPM_ALG_ID)(ALG_KEYEDHASH_VALUE)\n#define     ALG_XOR_VALUE               0x000A\n#define TPM_ALG_XOR                     (TPM_ALG_ID)(ALG_XOR_VALUE)\n#define     ALG_SHA256_VALUE            0x000B\n#define TPM_ALG_SHA256                  (TPM_ALG_ID)(ALG_SHA256_VALUE)\n#define     ALG_SHA384_VALUE            0x000C\n#define TPM_ALG_SHA384                  (TPM_ALG_ID)(ALG_SHA384_VALUE)\n#define     ALG_SHA512_VALUE            0x000D\n#define TPM_ALG_SHA512                  (TPM_ALG_ID)(ALG_SHA512_VALUE)\n#define     ALG_NULL_VALUE              0x0010\n#define TPM_ALG_NULL                    (TPM_ALG_ID)(ALG_NULL_VALUE)\n#define     ALG_SM3_256_VALUE           0x0012\n#define TPM_ALG_SM3_256                 (TPM_ALG_ID)(ALG_SM3_256_VALUE)\n#define     ALG_SM4_VALUE               0x0013\n#define TPM_ALG_SM4                     (TPM_ALG_ID)(ALG_SM4_VALUE)\n#define     ALG_RSASSA_VALUE            0x0014\n#define TPM_ALG_RSASSA                  (TPM_ALG_ID)(ALG_RSASSA_VALUE)\n#define     ALG_RSAES_VALUE             0x0015\n#define TPM_ALG_RSAES                   (TPM_ALG_ID)(ALG_RSAES_VALUE)\n#define     ALG_RSAPSS_VALUE            0x0016\n#define TPM_ALG_RSAPSS                  (TPM_ALG_ID)(ALG_RSAPSS_VALUE)\n#define     ALG_OAEP_VALUE              0x0017\n#define TPM_ALG_OAEP                    (TPM_ALG_ID)(ALG_OAEP_VALUE)\n#define     ALG_ECDSA_VALUE             0x0018\n#define TPM_ALG_ECDSA                   (TPM_ALG_ID)(ALG_ECDSA_VALUE)\n#define     ALG_ECDH_VALUE              0x0019\n#define TPM_ALG_ECDH                    (TPM_ALG_ID)(ALG_ECDH_VALUE)\n#define     ALG_ECDAA_VALUE             0x001A\n#define TPM_ALG_ECDAA                   (TPM_ALG_ID)(ALG_ECDAA_VALUE)\n#define     ALG_SM2_VALUE               0x001B\n#define TPM_ALG_SM2                     (TPM_ALG_ID)(ALG_SM2_VALUE)\n#define     ALG_ECSCHNORR_VALUE         0x001C\n#define TPM_ALG_ECSCHNORR               (TPM_ALG_ID)(ALG_ECSCHNORR_VALUE)\n#define     ALG_ECMQV_VALUE             0x001D\n#define TPM_ALG_ECMQV                   (TPM_ALG_ID)(ALG_ECMQV_VALUE)\n#define     ALG_KDF1_SP800_56A_VALUE    0x0020\n#define TPM_ALG_KDF1_SP800_56A          (TPM_ALG_ID)(ALG_KDF1_SP800_56A_VALUE)\n#define     ALG_KDF2_VALUE              0x0021\n#define TPM_ALG_KDF2                    (TPM_ALG_ID)(ALG_KDF2_VALUE)\n#define     ALG_KDF1_SP800_108_VALUE    0x0022\n#define TPM_ALG_KDF1_SP800_108          (TPM_ALG_ID)(ALG_KDF1_SP800_108_VALUE)\n#define     ALG_ECC_VALUE               0x0023\n#define TPM_ALG_ECC                     (TPM_ALG_ID)(ALG_ECC_VALUE)\n#define     ALG_SYMCIPHER_VALUE         0x0025\n#define TPM_ALG_SYMCIPHER               (TPM_ALG_ID)(ALG_SYMCIPHER_VALUE)\n#define     ALG_CAMELLIA_VALUE          0x0026\n#define TPM_ALG_CAMELLIA                (TPM_ALG_ID)(ALG_CAMELLIA_VALUE)\n#define     ALG_SHA3_256_VALUE          0x0027\n#define TPM_ALG_SHA3_256                (TPM_ALG_ID)(ALG_SHA3_256_VALUE)\n#define     ALG_SHA3_384_VALUE          0x0028\n#define TPM_ALG_SHA3_384                (TPM_ALG_ID)(ALG_SHA3_384_VALUE)\n#define     ALG_SHA3_512_VALUE          0x0029\n#define TPM_ALG_SHA3_512                (TPM_ALG_ID)(ALG_SHA3_512_VALUE)\n#define     ALG_CMAC_VALUE              0x003F\n#define TPM_ALG_CMAC                    (TPM_ALG_ID)(ALG_CMAC_VALUE)\n#define     ALG_CTR_VALUE               0x0040\n#define TPM_ALG_CTR                     (TPM_ALG_ID)(ALG_CTR_VALUE)\n#define     ALG_OFB_VALUE               0x0041\n#define TPM_ALG_OFB                     (TPM_ALG_ID)(ALG_OFB_VALUE)\n#define     ALG_CBC_VALUE               0x0042\n#define TPM_ALG_CBC                     (TPM_ALG_ID)(ALG_CBC_VALUE)\n#define     ALG_CFB_VALUE               0x0043\n#define TPM_ALG_CFB                     (TPM_ALG_ID)(ALG_CFB_VALUE)\n#define     ALG_ECB_VALUE               0x0044\n#define TPM_ALG_ECB                     (TPM_ALG_ID)(ALG_ECB_VALUE)\n\n/* Values derived from Table 1:2 */\n#define     ALG_FIRST_VALUE             0x0001\n#define TPM_ALG_FIRST                   (TPM_ALG_ID)(ALG_FIRST_VALUE)\n#define     ALG_LAST_VALUE              0x0044\n#define TPM_ALG_LAST                    (TPM_ALG_ID)(ALG_LAST_VALUE)\n\n/* TCG Algorithm Registry: Table 1:3 - Definition of TPM_ECC_CURVE Constants */\ntypedef UINT16              TPM_ECC_CURVE;\n#define TYPE_OF_TPM_ECC_CURVE   UINT16\n#define TPM_ECC_NONE        (TPM_ECC_CURVE)(0x0000)\n#define TPM_ECC_NIST_P192   (TPM_ECC_CURVE)(0x0001)\n#define TPM_ECC_NIST_P224   (TPM_ECC_CURVE)(0x0002)\n#define TPM_ECC_NIST_P256   (TPM_ECC_CURVE)(0x0003)\n#define TPM_ECC_NIST_P384   (TPM_ECC_CURVE)(0x0004)\n#define TPM_ECC_NIST_P521   (TPM_ECC_CURVE)(0x0005)\n#define TPM_ECC_BN_P256     (TPM_ECC_CURVE)(0x0010)\n#define TPM_ECC_BN_P638     (TPM_ECC_CURVE)(0x0011)\n#define TPM_ECC_SM2_P256    (TPM_ECC_CURVE)(0x0020)\n\n/* TPM 2.0 Part 2: Table 2:12 - Definition of TPM_CC Constants */\ntypedef UINT32                              TPM_CC;\n#define TYPE_OF_TPM_CC                      UINT32\n#define TPM_CC_FIRST                        (TPM_CC)(0x0000011F)\n#define TPM_CC_NV_UndefineSpaceSpecial      (TPM_CC)(0x0000011F)\n#define TPM_CC_EvictControl                 (TPM_CC)(0x00000120)\n#define TPM_CC_HierarchyControl             (TPM_CC)(0x00000121)\n#define TPM_CC_NV_UndefineSpace             (TPM_CC)(0x00000122)\n#define TPM_CC_ChangeEPS                    (TPM_CC)(0x00000124)\n#define TPM_CC_ChangePPS                    (TPM_CC)(0x00000125)\n#define TPM_CC_Clear                        (TPM_CC)(0x00000126)\n#define TPM_CC_ClearControl                 (TPM_CC)(0x00000127)\n#define TPM_CC_ClockSet                     (TPM_CC)(0x00000128)\n#define TPM_CC_HierarchyChangeAuth          (TPM_CC)(0x00000129)\n#define TPM_CC_NV_DefineSpace               (TPM_CC)(0x0000012A)\n#define TPM_CC_PCR_Allocate                 (TPM_CC)(0x0000012B)\n#define TPM_CC_PCR_SetAuthPolicy            (TPM_CC)(0x0000012C)\n#define TPM_CC_PP_Commands                  (TPM_CC)(0x0000012D)\n#define TPM_CC_SetPrimaryPolicy             (TPM_CC)(0x0000012E)\n#define TPM_CC_FieldUpgradeStart            (TPM_CC)(0x0000012F)\n#define TPM_CC_ClockRateAdjust              (TPM_CC)(0x00000130)\n#define TPM_CC_CreatePrimary                (TPM_CC)(0x00000131)\n#define TPM_CC_NV_GlobalWriteLock           (TPM_CC)(0x00000132)\n#define TPM_CC_GetCommandAuditDigest        (TPM_CC)(0x00000133)\n#define TPM_CC_NV_Increment                 (TPM_CC)(0x00000134)\n#define TPM_CC_NV_SetBits                   (TPM_CC)(0x00000135)\n#define TPM_CC_NV_Extend                    (TPM_CC)(0x00000136)\n#define TPM_CC_NV_Write                     (TPM_CC)(0x00000137)\n#define TPM_CC_NV_WriteLock                 (TPM_CC)(0x00000138)\n#define TPM_CC_DictionaryAttackLockReset    (TPM_CC)(0x00000139)\n#define TPM_CC_DictionaryAttackParameters   (TPM_CC)(0x0000013A)\n#define TPM_CC_NV_ChangeAuth                (TPM_CC)(0x0000013B)\n#define TPM_CC_PCR_Event                    (TPM_CC)(0x0000013C)\n#define TPM_CC_PCR_Reset                    (TPM_CC)(0x0000013D)\n#define TPM_CC_SequenceComplete             (TPM_CC)(0x0000013E)\n#define TPM_CC_SetAlgorithmSet              (TPM_CC)(0x0000013F)\n#define TPM_CC_SetCommandCodeAuditStatus    (TPM_CC)(0x00000140)\n#define TPM_CC_FieldUpgradeData             (TPM_CC)(0x00000141)\n#define TPM_CC_IncrementalSelfTest          (TPM_CC)(0x00000142)\n#define TPM_CC_SelfTest                     (TPM_CC)(0x00000143)\n#define TPM_CC_Startup                      (TPM_CC)(0x00000144)\n#define TPM_CC_Shutdown                     (TPM_CC)(0x00000145)\n#define TPM_CC_StirRandom                   (TPM_CC)(0x00000146)\n#define TPM_CC_ActivateCredential           (TPM_CC)(0x00000147)\n#define TPM_CC_Certify                      (TPM_CC)(0x00000148)\n#define TPM_CC_PolicyNV                     (TPM_CC)(0x00000149)\n#define TPM_CC_CertifyCreation              (TPM_CC)(0x0000014A)\n#define TPM_CC_Duplicate                    (TPM_CC)(0x0000014B)\n#define TPM_CC_GetTime                      (TPM_CC)(0x0000014C)\n#define TPM_CC_GetSessionAuditDigest        (TPM_CC)(0x0000014D)\n#define TPM_CC_NV_Read                      (TPM_CC)(0x0000014E)\n#define TPM_CC_NV_ReadLock                  (TPM_CC)(0x0000014F)\n#define TPM_CC_ObjectChangeAuth             (TPM_CC)(0x00000150)\n#define TPM_CC_PolicySecret                 (TPM_CC)(0x00000151)\n#define TPM_CC_Rewrap                       (TPM_CC)(0x00000152)\n#define TPM_CC_Create                       (TPM_CC)(0x00000153)\n#define TPM_CC_ECDH_ZGen                    (TPM_CC)(0x00000154)\n#define TPM_CC_HMAC                         (TPM_CC)(0x00000155)\n#define TPM_CC_MAC                          (TPM_CC)(0x00000155)\n#define TPM_CC_Import                       (TPM_CC)(0x00000156)\n#define TPM_CC_Load                         (TPM_CC)(0x00000157)\n#define TPM_CC_Quote                        (TPM_CC)(0x00000158)\n#define TPM_CC_RSA_Decrypt                  (TPM_CC)(0x00000159)\n#define TPM_CC_HMAC_Start                   (TPM_CC)(0x0000015B)\n#define TPM_CC_MAC_Start                    (TPM_CC)(0x0000015B)\n#define TPM_CC_SequenceUpdate               (TPM_CC)(0x0000015C)\n#define TPM_CC_Sign                         (TPM_CC)(0x0000015D)\n#define TPM_CC_Unseal                       (TPM_CC)(0x0000015E)\n#define TPM_CC_PolicySigned                 (TPM_CC)(0x00000160)\n#define TPM_CC_ContextLoad                  (TPM_CC)(0x00000161)\n#define TPM_CC_ContextSave                  (TPM_CC)(0x00000162)\n#define TPM_CC_ECDH_KeyGen                  (TPM_CC)(0x00000163)\n#define TPM_CC_EncryptDecrypt               (TPM_CC)(0x00000164)\n#define TPM_CC_FlushContext                 (TPM_CC)(0x00000165)\n#define TPM_CC_LoadExternal                 (TPM_CC)(0x00000167)\n#define TPM_CC_MakeCredential               (TPM_CC)(0x00000168)\n#define TPM_CC_NV_ReadPublic                (TPM_CC)(0x00000169)\n#define TPM_CC_PolicyAuthorize              (TPM_CC)(0x0000016A)\n#define TPM_CC_PolicyAuthValue              (TPM_CC)(0x0000016B)\n#define TPM_CC_PolicyCommandCode            (TPM_CC)(0x0000016C)\n#define TPM_CC_PolicyCounterTimer           (TPM_CC)(0x0000016D)\n#define TPM_CC_PolicyCpHash                 (TPM_CC)(0x0000016E)\n#define TPM_CC_PolicyLocality               (TPM_CC)(0x0000016F)\n#define TPM_CC_PolicyNameHash               (TPM_CC)(0x00000170)\n#define TPM_CC_PolicyOR                     (TPM_CC)(0x00000171)\n#define TPM_CC_PolicyTicket                 (TPM_CC)(0x00000172)\n#define TPM_CC_ReadPublic                   (TPM_CC)(0x00000173)\n#define TPM_CC_RSA_Encrypt                  (TPM_CC)(0x00000174)\n#define TPM_CC_StartAuthSession             (TPM_CC)(0x00000176)\n#define TPM_CC_VerifySignature              (TPM_CC)(0x00000177)\n#define TPM_CC_ECC_Parameters               (TPM_CC)(0x00000178)\n#define TPM_CC_FirmwareRead                 (TPM_CC)(0x00000179)\n#define TPM_CC_GetCapability                (TPM_CC)(0x0000017A)\n#define TPM_CC_GetRandom                    (TPM_CC)(0x0000017B)\n#define TPM_CC_GetTestResult                (TPM_CC)(0x0000017C)\n#define TPM_CC_Hash                         (TPM_CC)(0x0000017D)\n#define TPM_CC_PCR_Read                     (TPM_CC)(0x0000017E)\n#define TPM_CC_PolicyPCR                    (TPM_CC)(0x0000017F)\n#define TPM_CC_PolicyRestart                (TPM_CC)(0x00000180)\n#define TPM_CC_ReadClock                    (TPM_CC)(0x00000181)\n#define TPM_CC_PCR_Extend                   (TPM_CC)(0x00000182)\n#define TPM_CC_PCR_SetAuthValue             (TPM_CC)(0x00000183)\n#define TPM_CC_NV_Certify                   (TPM_CC)(0x00000184)\n#define TPM_CC_EventSequenceComplete        (TPM_CC)(0x00000185)\n#define TPM_CC_HashSequenceStart            (TPM_CC)(0x00000186)\n#define TPM_CC_PolicyPhysicalPresence       (TPM_CC)(0x00000187)\n#define TPM_CC_PolicyDuplicationSelect      (TPM_CC)(0x00000188)\n#define TPM_CC_PolicyGetDigest              (TPM_CC)(0x00000189)\n#define TPM_CC_TestParms                    (TPM_CC)(0x0000018A)\n#define TPM_CC_Commit                       (TPM_CC)(0x0000018B)\n#define TPM_CC_PolicyPassword               (TPM_CC)(0x0000018C)\n#define TPM_CC_ZGen_2Phase                  (TPM_CC)(0x0000018D)\n#define TPM_CC_EC_Ephemeral                 (TPM_CC)(0x0000018E)\n#define TPM_CC_PolicyNvWritten              (TPM_CC)(0x0000018F)\n#define TPM_CC_PolicyTemplate               (TPM_CC)(0x00000190)\n#define TPM_CC_CreateLoaded                 (TPM_CC)(0x00000191)\n#define TPM_CC_PolicyAuthorizeNV            (TPM_CC)(0x00000192)\n#define TPM_CC_EncryptDecrypt2              (TPM_CC)(0x00000193)\n#define TPM_CC_AC_GetCapability             (TPM_CC)(0x00000194)\n#define TPM_CC_AC_Send                      (TPM_CC)(0x00000195)\n#define TPM_CC_Policy_AC_SendSelect         (TPM_CC)(0x00000196)\n#define TPM_CC_CertifyX509                  (TPM_CC)(0x00000197)\n#define TPM_CC_ACT_SetTimeout               (TPM_CC)(0x00000198)\n#define TPM_CC_ECC_Encrypt\t\t    (TPM_CC)(0x00000199)\n#define TPM_CC_ECC_Decrypt\t\t    (TPM_CC)(0x0000019A)\n#define TPM_CC_PolicyCapability             (TPM_CC)(0x0000019B)\n#define TPM_CC_PolicyParameters             (TPM_CC)(0x0000019C)\n#define TPM_CC_NV_DefineSpace2              (TPM_CC)(0x0000019D)\n#define TPM_CC_NV_ReadPublic2               (TPM_CC)(0x0000019E)\n#define TPM_CC_SetCapability                (TPM_CC)(0x0000019F)\n#define TPM_CC_LAST                         (TPM_CC)(0x0000019F)\n#define CC_VEND                             0x20000000\n#define TPM_CC_Vendor_TCG_Test              (TPM_CC)(0x20000000)\n\n#define NTC2_CC_PreConfig\t\t    (TPM_CC)(0x20000211)\n#define NTC2_CC_LockPreConfig               (TPM_CC)(0x20000212)\n#define NTC2_CC_GetConfig                   (TPM_CC)(0x20000213)\n\n/* Table 2:5 - Definition of Types for Documentation Clarity */\ntypedef UINT32              TPM_ALGORITHM_ID;\n#define TYPE_OF_TPM_ALGORITHM_ID    UINT32\ntypedef UINT32              TPM_MODIFIER_INDICATOR;\n#define TYPE_OF_TPM_MODIFIER_INDICATOR  UINT32\ntypedef UINT32              TPM_AUTHORIZATION_SIZE;\n#define TYPE_OF_TPM_AUTHORIZATION_SIZE  UINT32\ntypedef UINT32              TPM_PARAMETER_SIZE;\n#define TYPE_OF_TPM_PARAMETER_SIZE  UINT32\ntypedef UINT16              TPM_KEY_SIZE;\n#define TYPE_OF_TPM_KEY_SIZE    UINT16\ntypedef UINT16              TPM_KEY_BITS;\n#define TYPE_OF_TPM_KEY_BITS    UINT16\n\n/* Table 2:7 - Definition of TPM_CONSTANTS32 Constants */\n\ntypedef UINT32\t\t\tTPM_CONSTANTS32;\n#define TYPE_OF_TPM_CONSTANTS32 UINT32\n#define TPM_GENERATED_VALUE     (TPM_CONSTANTS32)(0xFF544347)\n#define TPM_MAX_DERIVATION_BITS\t(TPM_CONSTANTS32)8192\n\n/* Table 2:16 - Definition of TPM_RC Constants */\ntypedef UINT32             TPM_RC;\n#define TYPE_OF_TPM_RC              UINT32\n#define TPM_RC_SUCCESS              (TPM_RC)(0x000)\n#define TPM_RC_BAD_TAG              (TPM_RC)(0x01E)\n#define RC_VER1                     (TPM_RC)(0x100)\n#define TPM_RC_INITIALIZE           (TPM_RC)(RC_VER1+0x000)\n#define TPM_RC_FAILURE              (TPM_RC)(RC_VER1+0x001)\n#define TPM_RC_SEQUENCE             (TPM_RC)(RC_VER1+0x003)\n#define TPM_RC_PRIVATE              (TPM_RC)(RC_VER1+0x00B)\n#define TPM_RC_HMAC                 (TPM_RC)(RC_VER1+0x019)\n#define TPM_RC_DISABLED             (TPM_RC)(RC_VER1+0x020)\n#define TPM_RC_EXCLUSIVE            (TPM_RC)(RC_VER1+0x021)\n#define TPM_RC_AUTH_TYPE            (TPM_RC)(RC_VER1+0x024)\n#define TPM_RC_AUTH_MISSING         (TPM_RC)(RC_VER1+0x025)\n#define TPM_RC_POLICY               (TPM_RC)(RC_VER1+0x026)\n#define TPM_RC_PCR                  (TPM_RC)(RC_VER1+0x027)\n#define TPM_RC_PCR_CHANGED          (TPM_RC)(RC_VER1+0x028)\n#define TPM_RC_UPGRADE              (TPM_RC)(RC_VER1+0x02D)\n#define TPM_RC_TOO_MANY_CONTEXTS    (TPM_RC)(RC_VER1+0x02E)\n#define TPM_RC_AUTH_UNAVAILABLE     (TPM_RC)(RC_VER1+0x02F)\n#define TPM_RC_REBOOT               (TPM_RC)(RC_VER1+0x030)\n#define TPM_RC_UNBALANCED           (TPM_RC)(RC_VER1+0x031)\n#define TPM_RC_COMMAND_SIZE         (TPM_RC)(RC_VER1+0x042)\n#define TPM_RC_COMMAND_CODE         (TPM_RC)(RC_VER1+0x043)\n#define TPM_RC_AUTHSIZE             (TPM_RC)(RC_VER1+0x044)\n#define TPM_RC_AUTH_CONTEXT         (TPM_RC)(RC_VER1+0x045)\n#define TPM_RC_NV_RANGE             (TPM_RC)(RC_VER1+0x046)\n#define TPM_RC_NV_SIZE              (TPM_RC)(RC_VER1+0x047)\n#define TPM_RC_NV_LOCKED            (TPM_RC)(RC_VER1+0x048)\n#define TPM_RC_NV_AUTHORIZATION     (TPM_RC)(RC_VER1+0x049)\n#define TPM_RC_NV_UNINITIALIZED     (TPM_RC)(RC_VER1+0x04A)\n#define TPM_RC_NV_SPACE             (TPM_RC)(RC_VER1+0x04B)\n#define TPM_RC_NV_DEFINED           (TPM_RC)(RC_VER1+0x04C)\n#define TPM_RC_BAD_CONTEXT          (TPM_RC)(RC_VER1+0x050)\n#define TPM_RC_CPHASH               (TPM_RC)(RC_VER1+0x051)\n#define TPM_RC_PARENT               (TPM_RC)(RC_VER1+0x052)\n#define TPM_RC_NEEDS_TEST           (TPM_RC)(RC_VER1+0x053)\n#define TPM_RC_NO_RESULT            (TPM_RC)(RC_VER1+0x054)\n#define TPM_RC_SENSITIVE            (TPM_RC)(RC_VER1+0x055)\n#define RC_MAX_FM0                  (TPM_RC)(RC_VER1+0x07F)\n#define RC_FMT1                     (TPM_RC)(0x080)\n#define TPM_RC_ASYMMETRIC           (TPM_RC)(RC_FMT1+0x001)\n#define TPM_RCS_ASYMMETRIC          (TPM_RC)(RC_FMT1+0x001)\n#define TPM_RC_ATTRIBUTES           (TPM_RC)(RC_FMT1+0x002)\n#define TPM_RCS_ATTRIBUTES          (TPM_RC)(RC_FMT1+0x002)\n#define TPM_RC_HASH                 (TPM_RC)(RC_FMT1+0x003)\n#define TPM_RCS_HASH                (TPM_RC)(RC_FMT1+0x003)\n#define TPM_RC_VALUE                (TPM_RC)(RC_FMT1+0x004)\n#define TPM_RCS_VALUE               (TPM_RC)(RC_FMT1+0x004)\n#define TPM_RC_HIERARCHY            (TPM_RC)(RC_FMT1+0x005)\n#define TPM_RCS_HIERARCHY           (TPM_RC)(RC_FMT1+0x005)\n#define TPM_RC_KEY_SIZE             (TPM_RC)(RC_FMT1+0x007)\n#define TPM_RCS_KEY_SIZE            (TPM_RC)(RC_FMT1+0x007)\n#define TPM_RC_MGF                  (TPM_RC)(RC_FMT1+0x008)\n#define TPM_RCS_MGF                 (TPM_RC)(RC_FMT1+0x008)\n#define TPM_RC_MODE                 (TPM_RC)(RC_FMT1+0x009)\n#define TPM_RCS_MODE                (TPM_RC)(RC_FMT1+0x009)\n#define TPM_RC_TYPE                 (TPM_RC)(RC_FMT1+0x00A)\n#define TPM_RCS_TYPE                (TPM_RC)(RC_FMT1+0x00A)\n#define TPM_RC_HANDLE               (TPM_RC)(RC_FMT1+0x00B)\n#define TPM_RCS_HANDLE              (TPM_RC)(RC_FMT1+0x00B)\n#define TPM_RC_KDF                  (TPM_RC)(RC_FMT1+0x00C)\n#define TPM_RCS_KDF                 (TPM_RC)(RC_FMT1+0x00C)\n#define TPM_RC_RANGE                (TPM_RC)(RC_FMT1+0x00D)\n#define TPM_RCS_RANGE               (TPM_RC)(RC_FMT1+0x00D)\n#define TPM_RC_AUTH_FAIL            (TPM_RC)(RC_FMT1+0x00E)\n#define TPM_RCS_AUTH_FAIL           (TPM_RC)(RC_FMT1+0x00E)\n#define TPM_RC_NONCE                (TPM_RC)(RC_FMT1+0x00F)\n#define TPM_RCS_NONCE               (TPM_RC)(RC_FMT1+0x00F)\n#define TPM_RC_PP                   (TPM_RC)(RC_FMT1+0x010)\n#define TPM_RCS_PP                  (TPM_RC)(RC_FMT1+0x010)\n#define TPM_RC_SCHEME               (TPM_RC)(RC_FMT1+0x012)\n#define TPM_RCS_SCHEME              (TPM_RC)(RC_FMT1+0x012)\n#define TPM_RC_SIZE                 (TPM_RC)(RC_FMT1+0x015)\n#define TPM_RCS_SIZE                (TPM_RC)(RC_FMT1+0x015)\n#define TPM_RC_SYMMETRIC            (TPM_RC)(RC_FMT1+0x016)\n#define TPM_RCS_SYMMETRIC           (TPM_RC)(RC_FMT1+0x016)\n#define TPM_RC_TAG                  (TPM_RC)(RC_FMT1+0x017)\n#define TPM_RCS_TAG                 (TPM_RC)(RC_FMT1+0x017)\n#define TPM_RC_SELECTOR             (TPM_RC)(RC_FMT1+0x018)\n#define TPM_RCS_SELECTOR            (TPM_RC)(RC_FMT1+0x018)\n#define TPM_RC_INSUFFICIENT         (TPM_RC)(RC_FMT1+0x01A)\n#define TPM_RCS_INSUFFICIENT        (TPM_RC)(RC_FMT1+0x01A)\n#define TPM_RC_SIGNATURE            (TPM_RC)(RC_FMT1+0x01B)\n#define TPM_RCS_SIGNATURE           (TPM_RC)(RC_FMT1+0x01B)\n#define TPM_RC_KEY                  (TPM_RC)(RC_FMT1+0x01C)\n#define TPM_RCS_KEY                 (TPM_RC)(RC_FMT1+0x01C)\n#define TPM_RC_POLICY_FAIL          (TPM_RC)(RC_FMT1+0x01D)\n#define TPM_RCS_POLICY_FAIL         (TPM_RC)(RC_FMT1+0x01D)\n#define TPM_RC_INTEGRITY            (TPM_RC)(RC_FMT1+0x01F)\n#define TPM_RCS_INTEGRITY           (TPM_RC)(RC_FMT1+0x01F)\n#define TPM_RC_TICKET               (TPM_RC)(RC_FMT1+0x020)\n#define TPM_RCS_TICKET              (TPM_RC)(RC_FMT1+0x020)\n#define TPM_RC_RESERVED_BITS        (TPM_RC)(RC_FMT1+0x021)\n#define TPM_RCS_RESERVED_BITS       (TPM_RC)(RC_FMT1+0x021)\n#define TPM_RC_BAD_AUTH             (TPM_RC)(RC_FMT1+0x022)\n#define TPM_RCS_BAD_AUTH            (TPM_RC)(RC_FMT1+0x022)\n#define TPM_RC_EXPIRED              (TPM_RC)(RC_FMT1+0x023)\n#define TPM_RCS_EXPIRED             (TPM_RC)(RC_FMT1+0x023)\n#define TPM_RC_POLICY_CC            (TPM_RC)(RC_FMT1+0x024)\n#define TPM_RCS_POLICY_CC           (TPM_RC)(RC_FMT1+0x024)\n#define TPM_RC_BINDING              (TPM_RC)(RC_FMT1+0x025)\n#define TPM_RCS_BINDING             (TPM_RC)(RC_FMT1+0x025)\n#define TPM_RC_CURVE                (TPM_RC)(RC_FMT1+0x026)\n#define TPM_RCS_CURVE               (TPM_RC)(RC_FMT1+0x026)\n#define TPM_RC_ECC_POINT            (TPM_RC)(RC_FMT1+0x027)\n#define TPM_RCS_ECC_POINT           (TPM_RC)(RC_FMT1+0x027)\n#define TPM_RC_FW_LIMITED           (TPM_RC)(RC_FMT1 + 0x028)\n#define TPM_RC_SVN_LIMITED          (TPM_RC)(RC_FMT1 + 0x029)\n#define RC_WARN                     (TPM_RC)(0x900)\n#define TPM_RC_CONTEXT_GAP          (TPM_RC)(RC_WARN+0x001)\n#define TPM_RC_OBJECT_MEMORY        (TPM_RC)(RC_WARN+0x002)\n#define TPM_RC_SESSION_MEMORY       (TPM_RC)(RC_WARN+0x003)\n#define TPM_RC_MEMORY               (TPM_RC)(RC_WARN+0x004)\n#define TPM_RC_SESSION_HANDLES      (TPM_RC)(RC_WARN+0x005)\n#define TPM_RC_OBJECT_HANDLES       (TPM_RC)(RC_WARN+0x006)\n#define TPM_RC_LOCALITY             (TPM_RC)(RC_WARN+0x007)\n#define TPM_RC_YIELDED              (TPM_RC)(RC_WARN+0x008)\n#define TPM_RC_CANCELED             (TPM_RC)(RC_WARN+0x009)\n#define TPM_RC_TESTING              (TPM_RC)(RC_WARN+0x00A)\n#define TPM_RC_REFERENCE_H0         (TPM_RC)(RC_WARN+0x010)\n#define TPM_RC_REFERENCE_H1         (TPM_RC)(RC_WARN+0x011)\n#define TPM_RC_REFERENCE_H2         (TPM_RC)(RC_WARN+0x012)\n#define TPM_RC_REFERENCE_H3         (TPM_RC)(RC_WARN+0x013)\n#define TPM_RC_REFERENCE_H4         (TPM_RC)(RC_WARN+0x014)\n#define TPM_RC_REFERENCE_H5         (TPM_RC)(RC_WARN+0x015)\n#define TPM_RC_REFERENCE_H6         (TPM_RC)(RC_WARN+0x016)\n#define TPM_RC_REFERENCE_S0         (TPM_RC)(RC_WARN+0x018)\n#define TPM_RC_REFERENCE_S1         (TPM_RC)(RC_WARN+0x019)\n#define TPM_RC_REFERENCE_S2         (TPM_RC)(RC_WARN+0x01A)\n#define TPM_RC_REFERENCE_S3         (TPM_RC)(RC_WARN+0x01B)\n#define TPM_RC_REFERENCE_S4         (TPM_RC)(RC_WARN+0x01C)\n#define TPM_RC_REFERENCE_S5         (TPM_RC)(RC_WARN+0x01D)\n#define TPM_RC_REFERENCE_S6         (TPM_RC)(RC_WARN+0x01E)\n#define TPM_RC_NV_RATE              (TPM_RC)(RC_WARN+0x020)\n#define TPM_RC_LOCKOUT              (TPM_RC)(RC_WARN+0x021)\n#define TPM_RC_RETRY                (TPM_RC)(RC_WARN+0x022)\n#define TPM_RC_NV_UNAVAILABLE       (TPM_RC)(RC_WARN+0x023)\n#define TPM_RC_NOT_USED             (TPM_RC)(RC_WARN+0x7F)\n#define TPM_RC_H                    (TPM_RC)(0x000)\n#define TPM_RC_P                    (TPM_RC)(0x040)\n#define TPM_RC_S                    (TPM_RC)(0x800)\n#define TPM_RC_1                    (TPM_RC)(0x100)\n#define TPM_RC_2                    (TPM_RC)(0x200)\n#define TPM_RC_3                    (TPM_RC)(0x300)\n#define TPM_RC_4                    (TPM_RC)(0x400)\n#define TPM_RC_5                    (TPM_RC)(0x500)\n#define TPM_RC_6                    (TPM_RC)(0x600)\n#define TPM_RC_7                    (TPM_RC)(0x700)\n#define TPM_RC_8                    (TPM_RC)(0x800)\n#define TPM_RC_9                    (TPM_RC)(0x900)\n#define TPM_RC_A                    (TPM_RC)(0xA00)\n#define TPM_RC_B                    (TPM_RC)(0xB00)\n#define TPM_RC_C                    (TPM_RC)(0xC00)\n#define TPM_RC_D                    (TPM_RC)(0xD00)\n#define TPM_RC_E                    (TPM_RC)(0xE00)\n#define TPM_RC_F                    (TPM_RC)(0xF00)\n#define TPM_RC_N_MASK               (TPM_RC)(0xF00)\n\n/* Table 2:17 - Definition of TPM_CLOCK_ADJUST Constants */\ntypedef  INT8               TPM_CLOCK_ADJUST;\n#define TYPE_OF_TPM_CLOCK_ADJUST    UINT8\n#define TPM_CLOCK_COARSE_SLOWER    (TPM_CLOCK_ADJUST)(-3)\n#define TPM_CLOCK_MEDIUM_SLOWER    (TPM_CLOCK_ADJUST)(-2)\n#define TPM_CLOCK_FINE_SLOWER      (TPM_CLOCK_ADJUST)(-1)\n#define TPM_CLOCK_NO_CHANGE        (TPM_CLOCK_ADJUST)(0)\n#define TPM_CLOCK_FINE_FASTER      (TPM_CLOCK_ADJUST)(1)\n#define TPM_CLOCK_MEDIUM_FASTER    (TPM_CLOCK_ADJUST)(2)\n#define TPM_CLOCK_COARSE_FASTER    (TPM_CLOCK_ADJUST)(3)\n\n/* Table 2:18 - Definition of TPM_EO Constants */\ntypedef  UINT16             TPM_EO;\n#define TYPE_OF_TPM_EO      UINT16\n#define TPM_EO_EQ             (TPM_EO)(0x0000)\n#define TPM_EO_NEQ            (TPM_EO)(0x0001)\n#define TPM_EO_SIGNED_GT      (TPM_EO)(0x0002)\n#define TPM_EO_UNSIGNED_GT    (TPM_EO)(0x0003)\n#define TPM_EO_SIGNED_LT      (TPM_EO)(0x0004)\n#define TPM_EO_UNSIGNED_LT    (TPM_EO)(0x0005)\n#define TPM_EO_SIGNED_GE      (TPM_EO)(0x0006)\n#define TPM_EO_UNSIGNED_GE    (TPM_EO)(0x0007)\n#define TPM_EO_SIGNED_LE      (TPM_EO)(0x0008)\n#define TPM_EO_UNSIGNED_LE    (TPM_EO)(0x0009)\n#define TPM_EO_BITSET         (TPM_EO)(0x000A)\n#define TPM_EO_BITCLEAR       (TPM_EO)(0x000B)\n/* Table 2:19 - Definition of TPM_ST Constants */\n\ntypedef  UINT16             TPM_ST;\n#define TYPE_OF_TPM_ST                  UINT16\n#define TPM_ST_RSP_COMMAND             (TPM_ST)(0x00C4)\n#define TPM_ST_NULL                    (TPM_ST)(0x8000)\n#define TPM_ST_NO_SESSIONS             (TPM_ST)(0x8001)\n#define TPM_ST_SESSIONS                (TPM_ST)(0x8002)\n#define TPM_ST_ATTEST_NV               (TPM_ST)(0x8014)\n#define TPM_ST_ATTEST_COMMAND_AUDIT    (TPM_ST)(0x8015)\n#define TPM_ST_ATTEST_SESSION_AUDIT    (TPM_ST)(0x8016)\n#define TPM_ST_ATTEST_CERTIFY          (TPM_ST)(0x8017)\n#define TPM_ST_ATTEST_QUOTE            (TPM_ST)(0x8018)\n#define TPM_ST_ATTEST_TIME             (TPM_ST)(0x8019)\n#define TPM_ST_ATTEST_CREATION         (TPM_ST)(0x801A)\n#define TPM_ST_ATTEST_NV_DIGEST\t       (TPM_ST)(0x801C)\n#define TPM_ST_CREATION                (TPM_ST)(0x8021)\n#define TPM_ST_VERIFIED                (TPM_ST)(0x8022)\n#define TPM_ST_AUTH_SECRET             (TPM_ST)(0x8023)\n#define TPM_ST_HASHCHECK               (TPM_ST)(0x8024)\n#define TPM_ST_AUTH_SIGNED             (TPM_ST)(0x8025)\n#define TPM_ST_FU_MANIFEST             (TPM_ST)(0x8029)\n\n/* Table 2:20 - Definition of TPM_SU Constants */\ntypedef UINT16             TPM_SU;\n#define TYPE_OF_TPM_SU      UINT16\n#define TPM_SU_CLEAR    (TPM_SU)(0x0000)\n#define TPM_SU_STATE    (TPM_SU)(0x0001)\n\n/* Table 2:21 - Definition of TPM_SE Constants */\ntypedef UINT8              TPM_SE;\n#define TYPE_OF_TPM_SE      UINT8\n#define TPM_SE_HMAC      (TPM_SE)(0x00)\n#define TPM_SE_POLICY    (TPM_SE)(0x01)\n#define TPM_SE_TRIAL     (TPM_SE)(0x03)\n\n/* Table 2:22 - Definition of TPM_CAP Constants */\ntypedef UINT32             TPM_CAP;\n#define TYPE_OF_TPM_CAP             UINT32\n#define TPM_CAP_FIRST              (TPM_CAP)(0x00000000)\n#define TPM_CAP_ALGS               (TPM_CAP)(0x00000000)\n#define TPM_CAP_HANDLES            (TPM_CAP)(0x00000001)\n#define TPM_CAP_COMMANDS           (TPM_CAP)(0x00000002)\n#define TPM_CAP_PP_COMMANDS        (TPM_CAP)(0x00000003)\n#define TPM_CAP_AUDIT_COMMANDS     (TPM_CAP)(0x00000004)\n#define TPM_CAP_PCRS               (TPM_CAP)(0x00000005)\n#define TPM_CAP_TPM_PROPERTIES     (TPM_CAP)(0x00000006)\n#define TPM_CAP_PCR_PROPERTIES     (TPM_CAP)(0x00000007)\n#define TPM_CAP_ECC_CURVES         (TPM_CAP)(0x00000008)\n#define TPM_CAP_AUTH_POLICIES      (TPM_CAP)(0x00000009)\n#define TPM_CAP_ACT \t\t   (TPM_CAP)(0x0000000a)\n#define TPM_CAP_LAST               (TPM_CAP)(0x0000000a)\n#define TPM_CAP_VENDOR_PROPERTY    (TPM_CAP)(0x00000100)\n\n/* Table 2:23 - Definition of TPM_PT Constants */\ntypedef  UINT32             TPM_PT;\n#define TYPE_OF_TPM_PT              UINT32\n#define TPM_PT_NONE                   (TPM_PT)(0x00000000)\n#define PT_GROUP                      (TPM_PT)(0x00000100)\n#define PT_FIXED                      (TPM_PT)(PT_GROUP*1)\n#define TPM_PT_FAMILY_INDICATOR       (TPM_PT)(PT_FIXED+0)\n#define TPM_PT_LEVEL                  (TPM_PT)(PT_FIXED+1)\n#define TPM_PT_REVISION               (TPM_PT)(PT_FIXED+2)\n#define TPM_PT_DAY_OF_YEAR            (TPM_PT)(PT_FIXED+3)\n#define TPM_PT_YEAR                   (TPM_PT)(PT_FIXED+4)\n#define TPM_PT_MANUFACTURER           (TPM_PT)(PT_FIXED+5)\n#define TPM_PT_VENDOR_STRING_1        (TPM_PT)(PT_FIXED+6)\n#define TPM_PT_VENDOR_STRING_2        (TPM_PT)(PT_FIXED+7)\n#define TPM_PT_VENDOR_STRING_3        (TPM_PT)(PT_FIXED+8)\n#define TPM_PT_VENDOR_STRING_4        (TPM_PT)(PT_FIXED+9)\n#define TPM_PT_VENDOR_TPM_TYPE        (TPM_PT)(PT_FIXED+10)\n#define TPM_PT_FIRMWARE_VERSION_1     (TPM_PT)(PT_FIXED+11)\n#define TPM_PT_FIRMWARE_VERSION_2     (TPM_PT)(PT_FIXED+12)\n#define TPM_PT_INPUT_BUFFER           (TPM_PT)(PT_FIXED+13)\n#define TPM_PT_HR_TRANSIENT_MIN       (TPM_PT)(PT_FIXED+14)\n#define TPM_PT_HR_PERSISTENT_MIN      (TPM_PT)(PT_FIXED+15)\n#define TPM_PT_HR_LOADED_MIN          (TPM_PT)(PT_FIXED+16)\n#define TPM_PT_ACTIVE_SESSIONS_MAX    (TPM_PT)(PT_FIXED+17)\n#define TPM_PT_PCR_COUNT              (TPM_PT)(PT_FIXED+18)\n#define TPM_PT_PCR_SELECT_MIN         (TPM_PT)(PT_FIXED+19)\n#define TPM_PT_CONTEXT_GAP_MAX        (TPM_PT)(PT_FIXED+20)\n#define TPM_PT_NV_COUNTERS_MAX        (TPM_PT)(PT_FIXED+22)\n#define TPM_PT_NV_INDEX_MAX           (TPM_PT)(PT_FIXED+23)\n#define TPM_PT_MEMORY                 (TPM_PT)(PT_FIXED+24)\n#define TPM_PT_CLOCK_UPDATE           (TPM_PT)(PT_FIXED+25)\n#define TPM_PT_CONTEXT_HASH           (TPM_PT)(PT_FIXED+26)\n#define TPM_PT_CONTEXT_SYM            (TPM_PT)(PT_FIXED+27)\n#define TPM_PT_CONTEXT_SYM_SIZE       (TPM_PT)(PT_FIXED+28)\n#define TPM_PT_ORDERLY_COUNT          (TPM_PT)(PT_FIXED+29)\n#define TPM_PT_MAX_COMMAND_SIZE       (TPM_PT)(PT_FIXED+30)\n#define TPM_PT_MAX_RESPONSE_SIZE      (TPM_PT)(PT_FIXED+31)\n#define TPM_PT_MAX_DIGEST             (TPM_PT)(PT_FIXED+32)\n#define TPM_PT_MAX_OBJECT_CONTEXT     (TPM_PT)(PT_FIXED+33)\n#define TPM_PT_MAX_SESSION_CONTEXT    (TPM_PT)(PT_FIXED+34)\n#define TPM_PT_PS_FAMILY_INDICATOR    (TPM_PT)(PT_FIXED+35)\n#define TPM_PT_PS_LEVEL               (TPM_PT)(PT_FIXED+36)\n#define TPM_PT_PS_REVISION            (TPM_PT)(PT_FIXED+37)\n#define TPM_PT_PS_DAY_OF_YEAR         (TPM_PT)(PT_FIXED+38)\n#define TPM_PT_PS_YEAR                (TPM_PT)(PT_FIXED+39)\n#define TPM_PT_SPLIT_MAX              (TPM_PT)(PT_FIXED+40)\n#define TPM_PT_TOTAL_COMMANDS         (TPM_PT)(PT_FIXED+41)\n#define TPM_PT_LIBRARY_COMMANDS       (TPM_PT)(PT_FIXED+42)\n#define TPM_PT_VENDOR_COMMANDS        (TPM_PT)(PT_FIXED+43)\n#define TPM_PT_NV_BUFFER_MAX          (TPM_PT)(PT_FIXED+44)\n#define TPM_PT_MODES                  (TPM_PT)(PT_FIXED+45)\n#define TPM_PT_MAX_CAP_BUFFER         (TPM_PT)(PT_FIXED+46)\n#define PT_VAR                        (TPM_PT)(PT_GROUP*2)\n#define TPM_PT_PERMANENT              (TPM_PT)(PT_VAR+0)\n#define TPM_PT_STARTUP_CLEAR          (TPM_PT)(PT_VAR+1)\n#define TPM_PT_HR_NV_INDEX            (TPM_PT)(PT_VAR+2)\n#define TPM_PT_HR_LOADED              (TPM_PT)(PT_VAR+3)\n#define TPM_PT_HR_LOADED_AVAIL        (TPM_PT)(PT_VAR+4)\n#define TPM_PT_HR_ACTIVE              (TPM_PT)(PT_VAR+5)\n#define TPM_PT_HR_ACTIVE_AVAIL        (TPM_PT)(PT_VAR+6)\n#define TPM_PT_HR_TRANSIENT_AVAIL     (TPM_PT)(PT_VAR+7)\n#define TPM_PT_HR_PERSISTENT          (TPM_PT)(PT_VAR+8)\n#define TPM_PT_HR_PERSISTENT_AVAIL    (TPM_PT)(PT_VAR+9)\n#define TPM_PT_NV_COUNTERS            (TPM_PT)(PT_VAR+10)\n#define TPM_PT_NV_COUNTERS_AVAIL      (TPM_PT)(PT_VAR+11)\n#define TPM_PT_ALGORITHM_SET          (TPM_PT)(PT_VAR+12)\n#define TPM_PT_LOADED_CURVES          (TPM_PT)(PT_VAR+13)\n#define TPM_PT_LOCKOUT_COUNTER        (TPM_PT)(PT_VAR+14)\n#define TPM_PT_MAX_AUTH_FAIL          (TPM_PT)(PT_VAR+15)\n#define TPM_PT_LOCKOUT_INTERVAL       (TPM_PT)(PT_VAR+16)\n#define TPM_PT_LOCKOUT_RECOVERY       (TPM_PT)(PT_VAR+17)\n#define TPM_PT_NV_WRITE_RECOVERY      (TPM_PT)(PT_VAR+18)\n#define TPM_PT_AUDIT_COUNTER_0        (TPM_PT)(PT_VAR+19)\n#define TPM_PT_AUDIT_COUNTER_1        (TPM_PT)(PT_VAR+20)\n\n/* Table 2:24 - Definition of TPM_PT_PCR Constants */\ntypedef UINT32             TPM_PT_PCR;\n#define TYPE_OF_TPM_PT_PCR          UINT32\n#define TPM_PT_PCR_FIRST           (TPM_PT_PCR)(0x00000000)\n#define TPM_PT_PCR_SAVE            (TPM_PT_PCR)(0x00000000)\n#define TPM_PT_PCR_EXTEND_L0       (TPM_PT_PCR)(0x00000001)\n#define TPM_PT_PCR_RESET_L0        (TPM_PT_PCR)(0x00000002)\n#define TPM_PT_PCR_EXTEND_L1       (TPM_PT_PCR)(0x00000003)\n#define TPM_PT_PCR_RESET_L1        (TPM_PT_PCR)(0x00000004)\n#define TPM_PT_PCR_EXTEND_L2       (TPM_PT_PCR)(0x00000005)\n#define TPM_PT_PCR_RESET_L2        (TPM_PT_PCR)(0x00000006)\n#define TPM_PT_PCR_EXTEND_L3       (TPM_PT_PCR)(0x00000007)\n#define TPM_PT_PCR_RESET_L3        (TPM_PT_PCR)(0x00000008)\n#define TPM_PT_PCR_EXTEND_L4       (TPM_PT_PCR)(0x00000009)\n#define TPM_PT_PCR_RESET_L4        (TPM_PT_PCR)(0x0000000A)\n#define TPM_PT_PCR_NO_INCREMENT    (TPM_PT_PCR)(0x00000011)\n#define TPM_PT_PCR_DRTM_RESET      (TPM_PT_PCR)(0x00000012)\n#define TPM_PT_PCR_POLICY          (TPM_PT_PCR)(0x00000013)\n#define TPM_PT_PCR_AUTH            (TPM_PT_PCR)(0x00000014)\n#define TPM_PT_PCR_LAST            (TPM_PT_PCR)(0x00000014)\n\n/* Table 2:25 - Definition of TPM_PS Constants  */\ntypedef UINT32             TPM_PS;\n#define TYPE_OF_TPM_PS          UINT32\n#define TPM_PS_MAIN              (TPM_PS)(0x00000000)\n#define TPM_PS_PC                (TPM_PS)(0x00000001)\n#define TPM_PS_PDA               (TPM_PS)(0x00000002)\n#define TPM_PS_CELL_PHONE        (TPM_PS)(0x00000003)\n#define TPM_PS_SERVER            (TPM_PS)(0x00000004)\n#define TPM_PS_PERIPHERAL        (TPM_PS)(0x00000005)\n#define TPM_PS_TSS               (TPM_PS)(0x00000006)\n#define TPM_PS_STORAGE           (TPM_PS)(0x00000007)\n#define TPM_PS_AUTHENTICATION    (TPM_PS)(0x00000008)\n#define TPM_PS_EMBEDDED          (TPM_PS)(0x00000009)\n#define TPM_PS_HARDCOPY          (TPM_PS)(0x0000000A)\n#define TPM_PS_INFRASTRUCTURE    (TPM_PS)(0x0000000B)\n#define TPM_PS_VIRTUALIZATION    (TPM_PS)(0x0000000C)\n#define TPM_PS_TNC               (TPM_PS)(0x0000000D)\n#define TPM_PS_MULTI_TENANT      (TPM_PS)(0x0000000E)\n#define TPM_PS_TC                (TPM_PS)(0x0000000F)\n\n/* Table 2:26 - Definition of Types for Handles */\ntypedef UINT32             TPM_HANDLE;\n#define TYPE_OF_TPM_HANDLE  UINT32\n\n/* Table 2:27 - Definition of TPM_HT Constants  */\ntypedef UINT8              TPM_HT;\n#define TYPE_OF_TPM_HT          UINT8\n#define TPM_HT_PCR               (TPM_HT)(0x00)\n#define TPM_HT_NV_INDEX          (TPM_HT)(0x01)\n#define TPM_HT_HMAC_SESSION      (TPM_HT)(0x02)\n#define TPM_HT_LOADED_SESSION    (TPM_HT)(0x02)\n#define TPM_HT_POLICY_SESSION    (TPM_HT)(0x03)\n#define TPM_HT_SAVED_SESSION     (TPM_HT)(0x03)\n#define TPM_HT_EXTERNAL_NV       (TPM_HT)(0x11)\n#define TPM_HT_PERMANENT_NV      (TPM_HT)(0x12)\n#define TPM_HT_PERMANENT         (TPM_HT)(0x40)\n#define TPM_HT_TRANSIENT         (TPM_HT)(0x80)\n#define TPM_HT_PERSISTENT        (TPM_HT)(0x81)\n#define TPM_HT_AC                (TPM_HT)(0x90)\n\n/* Table 2:28 - Definition of TPM_RH Constants  */\ntypedef  TPM_HANDLE         TPM_RH;\n#define  TYPE_OF_TPM_RH              TPM_HANDLE\n#define  TPM_RH_FIRST          (TPM_RH)(0x40000000)\n#define  TPM_RH_SRK            (TPM_RH)(0x40000000)\n#define  TPM_RH_OWNER          (TPM_RH)(0x40000001)\n#define  TPM_RH_REVOKE         (TPM_RH)(0x40000002)\n#define  TPM_RH_TRANSPORT      (TPM_RH)(0x40000003)\n#define  TPM_RH_OPERATOR       (TPM_RH)(0x40000004)\n#define  TPM_RH_ADMIN          (TPM_RH)(0x40000005)\n#define  TPM_RH_EK             (TPM_RH)(0x40000006)\n#define  TPM_RH_NULL           (TPM_RH)(0x40000007)\n#define  TPM_RH_UNASSIGNED     (TPM_RH)(0x40000008)\n#define  TPM_RS_PW             (TPM_RH)(0x40000009)\n#define  TPM_RH_LOCKOUT        (TPM_RH)(0x4000000A)\n#define  TPM_RH_ENDORSEMENT    (TPM_RH)(0x4000000B)\n#define  TPM_RH_PLATFORM       (TPM_RH)(0x4000000C)\n#define  TPM_RH_PLATFORM_NV    (TPM_RH)(0x4000000D)\n#define  TPM_RH_AUTH_00        (TPM_RH)(0x40000010)\n#define  TPM_RH_AUTH_FF        (TPM_RH)(0x4000010F)\n#define  TPM_RH_ACT_0          (TPM_RH)(0x40000110)\n#define  TPM_RH_ACT_F          (TPM_RH)(0x4000011F)\n#define TPM_RH_FW_OWNER             (TPM_RH)(0x40000140)\n#define TPM_RH_FW_ENDORSEMENT       (TPM_RH)(0x40000141)\n#define TPM_RH_FW_PLATFORM          (TPM_RH)(0x40000142)\n#define TPM_RH_FW_NULL              (TPM_RH)(0x40000143)\n#define TPM_RH_SVN_OWNER_BASE       (TPM_RH)(0x40010000)\n#define TPM_RH_SVN_ENDORSEMENT_BASE (TPM_RH)(0x40020000)\n#define TPM_RH_SVN_PLATFORM_BASE    (TPM_RH)(0x40030000)\n#define TPM_RH_SVN_NULL_BASE        (TPM_RH)(0x40040000)\n#define TPM_RH_LAST                 (TPM_RH)(0x4004FFFF)\n\n/* Table 2:29 - Definition of TPM_HC Constants  */\ntypedef  TPM_HANDLE         TPM_HC;\n#define  HR_HANDLE_MASK          (TPM_HC)(0x00FFFFFF)\n#define  HR_RANGE_MASK           (TPM_HC)(0xFF000000)\n#define  HR_SHIFT                (TPM_HC)(24)\n#define  HR_PCR                  (TPM_HC)((TPM_HT_PCR<<HR_SHIFT))\n#define  HR_HMAC_SESSION         (TPM_HC)((TPM_HT_HMAC_SESSION<<HR_SHIFT))\n#define  HR_POLICY_SESSION       (TPM_HC)((TPM_HT_POLICY_SESSION<<HR_SHIFT))\n#define  HR_TRANSIENT\t\t (TPM_HC)((((UINT32)TPM_HT_TRANSIENT) << HR_SHIFT))\n#define  HR_PERSISTENT           (TPM_HC)((((UINT32)TPM_HT_PERSISTENT) << HR_SHIFT))\n#define  HR_NV_INDEX             (TPM_HC)((TPM_HT_NV_INDEX << HR_SHIFT))\n#define  HR_EXTERNAL_NV          (TPM_HC)((TPM_HT_EXTERNAL_NV << HR_SHIFT))\n#define  HR_PERMANENT_NV         (TPM_HC)((TPM_HT_PERMANENT_NV << HR_SHIFT))\n#define  HR_PERMANENT            (TPM_HC)((TPM_HT_PERMANENT << HR_SHIFT))\n#define  PCR_FIRST               (TPM_HC)((HR_PCR+0))\n#define  PCR_LAST                (TPM_HC)((PCR_FIRST+IMPLEMENTATION_PCR-1))\n#define  HMAC_SESSION_FIRST      (TPM_HC)((HR_HMAC_SESSION+0))\n#define  HMAC_SESSION_LAST       (TPM_HC)((HMAC_SESSION_FIRST + MAX_ACTIVE_SESSIONS-1))\n#define  LOADED_SESSION_FIRST    (TPM_HC)(HMAC_SESSION_FIRST)\n#define  LOADED_SESSION_LAST     (TPM_HC)(HMAC_SESSION_LAST)\n#define  POLICY_SESSION_FIRST    (TPM_HC)((HR_POLICY_SESSION+0))\n#define  POLICY_SESSION_LAST\t (TPM_HC)((POLICY_SESSION_FIRST + MAX_ACTIVE_SESSIONS-1))\n#define  TRANSIENT_FIRST         (TPM_HC)((HR_TRANSIENT+0))\n#define  ACTIVE_SESSION_FIRST    (TPM_HC)(POLICY_SESSION_FIRST)\n#define  ACTIVE_SESSION_LAST     (TPM_HC)(POLICY_SESSION_LAST)\n#define  TRANSIENT_LAST          (TPM_HC)((TRANSIENT_FIRST+MAX_LOADED_OBJECTS-1))\n#define  PERSISTENT_FIRST        (TPM_HC)((HR_PERSISTENT+0))\n#define  PERSISTENT_LAST         (TPM_HC)((PERSISTENT_FIRST+0x00FFFFFF))\n#define  SVN_OWNER_FIRST         (TPM_HC)((TPM_RH_SVN_OWNER_BASE + 0x0000))\n#define  SVN_OWNER_LAST          (TPM_HC)((TPM_RH_SVN_OWNER_BASE + 0xFFFF))\n#define  SVN_ENDORSEMENT_FIRST   (TPM_HC)((TPM_RH_SVN_ENDORSEMENT_BASE + 0x0000))\n#define  SVN_ENDORSEMENT_LAST    (TPM_HC)((TPM_RH_SVN_ENDORSEMENT_BASE + 0xFFFF))\n#define  SVN_PLATFORM_FIRST      (TPM_HC)((TPM_RH_SVN_PLATFORM_BASE + 0x0000))\n#define  SVN_PLATFORM_LAST       (TPM_HC)((TPM_RH_SVN_PLATFORM_BASE + 0xFFFF))\n#define  SVN_NULL_FIRST          (TPM_HC)((TPM_RH_SVN_NULL_BASE + 0x0000))\n#define  SVN_NULL_LAST           (TPM_HC)((TPM_RH_SVN_NULL_BASE + 0xFFFF))\n#define  PLATFORM_PERSISTENT     (TPM_HC)((PERSISTENT_FIRST+0x00800000))\n#define  NV_INDEX_FIRST          (TPM_HC)((HR_NV_INDEX+0))\n#define  NV_INDEX_LAST           (TPM_HC)((NV_INDEX_FIRST+0x00FFFFFF))\n#define  EXTERNAL_NV_FIRST       (TPM_HC)((HR_EXTERNAL_NV + 0))\n#define  EXTERNAL_NV_LAST        (TPM_HC)((EXTERNAL_NV_FIRST + 0x00FFFFFF))\n#define  PERMANENT_NV_FIRST      (TPM_HC)((HR_PERMANENT_NV + 0))\n#define  PERMANENT_NV_LAST       (TPM_HC)((PERMANENT_NV_FIRST + 0x00FFFFFF))\n#define  PERMANENT_FIRST         (TPM_HC)(TPM_RH_FIRST)\n#define  PERMANENT_LAST          (TPM_HC)(TPM_RH_LAST)\n#define  HR_NV_AC                (TPM_HC)(((TPM_HT_NV_INDEX<<HR_SHIFT)+0xD00000))\n#define  NV_AC_FIRST             (TPM_HC)((HR_NV_AC+0))\n#define  NV_AC_LAST              (TPM_HC)((HR_NV_AC+0x0000FFFF))\n#define  HR_AC                   (TPM_HC)((TPM_HT_AC<<HR_SHIFT))\n#define  AC_FIRST                (TPM_HC)((HR_AC+0))\n#define  AC_LAST                 (TPM_HC)((HR_AC+0x0000FFFF))\n\n#define TYPE_OF_TPMA_ALGORITHM  UINT32\n#define TPMA_ALGORITHM_TO_UINT32(a)  (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_ALGORITHM(a)  (*((TPMA_ALGORITHM *)&(a)))\n\n#define TPMA_ALGORITHM_TO_BYTE_ARRAY(i, a)\t\t\t\t\\\n\t            UINT32_TO_BYTE_ARRAY((TPMA_ALGORITHM_TO_UINT32(i)), (a))\n\n#define BYTE_ARRAY_TO_TPMA_ALGORITHM(i, a)\t\t\t\t\\\n    {UINT32 x = BYTE_ARRAY_TO_UINT32(a);\t\t\t\t\\\n\ti = UINT32_TO_TPMA_ALGORITHM(x);\t\t\t\t\\\n    }\n\n/* Table 2:30 - Definition of TPMA_ALGORITHM Bits */\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_ALGORITHM{\n    unsigned    asymmetric           : 1 ;\n    unsigned    symmetric            : 1 ;\n    unsigned    hash                 : 1 ;\n    unsigned    object               : 1 ;\n    unsigned    Reserved_bits_at_4   : 4 ;\n    unsigned    signing              : 1 ;\n    unsigned    encrypting           : 1 ;\n    unsigned    method               : 1 ;\n    unsigned    Reserved_bits_at_11  : 21;\n} TPMA_ALGORITHM;\n/* This is the initializer for a TPMA_ALGORITHM structure. */\n#define TPMA_ALGORITHM_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t   asymmetric, symmetric,  hash,       object,     bits_at_4, \\\n\t\t\t\t   signing,    encrypting, method,     bits_at_11) \\\n    {asymmetric, symmetric,  hash,       object,     bits_at_4,\t\t\\\n\t    signing,    encrypting, method,     bits_at_11}\n#else // USE_BIT_FIELD_STRUCTURES\n\ntypedef UINT32 TPMA_ALGORITHM;\n#define TYPE_OF_TPMA_ALGORITHM      UINT32\n#define TPMA_ALGORITHM_asymmetric        ((TPMA_ALGORITHM)1 << 0)\n#define TPMA_ALGORITHM_symmetric         ((TPMA_ALGORITHM)1 << 1)\n#define TPMA_ALGORITHM_hash              ((TPMA_ALGORITHM)1 << 2)\n#define TPMA_ALGORITHM_object            ((TPMA_ALGORITHM)1 << 3)\n#define TPMA_ALGORITHM_signing           ((TPMA_ALGORITHM)1 << 8)\n#define TPMA_ALGORITHM_encrypting        ((TPMA_ALGORITHM)1 << 9)\n#define TPMA_ALGORITHM_method            ((TPMA_ALGORITHM)1 << 10)\n#define TPMA_ALGORITHM_reserved\t\t 0xfffff8f0\n\n// This is the initializer for a TPMA_ALGORITHM bit array.\n#define TPMA_ALGORITHM_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t   asymmetric, symmetric,  hash,       object,     bits_at_4, \\\n\t\t\t\t   signing,    encrypting, method,     bits_at_11) \\\n    (TPMA_ALGORITHM) (\t\t\t\t\t\t\t\t\\\n            (asymmetric << 0) + (symmetric << 1)  + (hash << 2)       +\t\\\n\t    (object << 3)     + (signing << 8)    + (encrypting << 9) +\t\\\n\t    (method << 10))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_OBJECT UINT32\n#define TPMA_OBJECT_TO_UINT32(a)     (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_OBJECT(a)     (*((TPMA_OBJECT *)&(a)))\n#define TPMA_OBJECT_TO_BYTE_ARRAY(i, a)\t\t\t\t\\\n    UINT32_TO_BYTE_ARRAY((TPMA_OBJECT_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_OBJECT(i, a)\t\t\t\t\t\\\n    { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_OBJECT(x); }\n\n/* This is the initializer for a TPMA_OBJECT structure. */\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_OBJECT {                        // Table 2:31\n    unsigned    Reserved_bit_at_0        : 1;\n    unsigned    fixedTPM                 : 1;\n    unsigned    stClear                  : 1;\n    unsigned    Reserved_bit_at_3        : 1;\n    unsigned    fixedParent              : 1;\n    unsigned    sensitiveDataOrigin      : 1;\n    unsigned    userWithAuth             : 1;\n    unsigned    adminWithPolicy          : 1;\n    unsigned    firmwareLimited          : 1;\n    unsigned    svnLimited               : 1;\n    unsigned    noDA                     : 1;\n    unsigned    encryptedDuplication     : 1;\n    unsigned    Reserved_bits_at_12      : 4;\n    unsigned    restricted               : 1;\n    unsigned    decrypt                  : 1;\n    unsigned    sign                     : 1;\n    unsigned    x509sign                 : 1;\n    unsigned    Reserved_bits_at_20      : 12;\n} TPMA_OBJECT;\n// This is the initializer for a TPMA_OBJECT structure\n#define TPMA_OBJECT_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\tbit_at_0,             fixedtpm,             stclear, \\\n\t\t\t\tbit_at_3,             fixedparent,          sensitivedataorigin, \\\n\t\t\t\tuserwithauth,         adminwithpolicy,      firmwareLimited, \\\n\t\t\t\tsvnLimited,\t\t\\\n\t\t\t\tnoda,                 encryptedduplication, bits_at_12, \\\n\t\t\t\trestricted,           decrypt,              sign, \\\n\t\t\t\tx509sign,             bits_at_20)\t\\\n\t   {bit_at_0,             fixedtpm,             stclear,\t\t\\\n\t    bit_at_3,             fixedparent,          sensitivedataorigin, \\\n\t    userwithauth,         adminwithpolicy,      bits_at_8,\t\\\n\t    noda,                 encryptedduplication, bits_at_12,\t\\\n\t    restricted,           decrypt,              sign,\t\t\\\n\t    x509sign,             bits_at_20}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:31 TPMA_OBJECT using bit masking\ntypedef UINT32                              TPMA_OBJECT;\n#define TYPE_OF_TPMA_OBJECT                 UINT32\n#define TPMA_OBJECT_Reserved_bit_at_0       ((TPMA_OBJECT)(1 << 0))\n#define TPMA_OBJECT_fixedTPM                ((TPMA_OBJECT)(1 << 1))\n#define TPMA_OBJECT_stClear                 ((TPMA_OBJECT)(1 << 2))\n#define TPMA_OBJECT_fixedParent             ((TPMA_OBJECT)(1 << 4))\n#define TPMA_OBJECT_sensitiveDataOrigin     ((TPMA_OBJECT)(1 << 5))\n#define TPMA_OBJECT_userWithAuth            ((TPMA_OBJECT)(1 << 6))\n#define TPMA_OBJECT_adminWithPolicy         ((TPMA_OBJECT)(1 << 7))\n#define TPMA_OBJECT_firmwareLimited         ((TPMA_OBJECT)(1 << 8))\n#define TPMA_OBJECT_svnLimited              ((TPMA_OBJECT)(1 << 9))\n#define TPMA_OBJECT_noDA                    ((TPMA_OBJECT)(1 << 10))\n#define TPMA_OBJECT_encryptedDuplication    ((TPMA_OBJECT)(1 << 11))\n#define TPMA_OBJECT_restricted              ((TPMA_OBJECT)(1 << 16))\n#define TPMA_OBJECT_decrypt                 ((TPMA_OBJECT)(1 << 17))\n#define TPMA_OBJECT_sign                    ((TPMA_OBJECT)(1 << 18))\n#define TPMA_OBJECT_x509sign                ((TPMA_OBJECT)(1 << 19))\n#define TPMA_OBJECT_reserved\t\t    ((TPMA_OBJECT)0xfff0f009)\n//  This is the initializer for a TPMA_OBJECT bit array.\n#define TPMA_OBJECT_INITIALIZER(                                                   \\\n             bit_at_0,             fixedtpm,             stclear,                  \\\n             bit_at_3,             fixedparent,          sensitivedataorigin,      \\\n             userwithauth,         adminwithpolicy,      bits_at_8,                \\\n             noda,                 encryptedduplication, bits_at_12,               \\\n             restricted,           decrypt,              sign,                     \\\n             x509sign,             bits_at_20)\t\t\t\t\t   \\\n      (TPMA_OBJECT)(\t\t\t\t\t\t\t\t   \\\n\t     (fixedtpm << 1)              + (stclear << 2)               +         \\\n             (fixedparent << 4)           + (sensitivedataorigin << 5)   +         \\\n             (userwithauth << 6)          + (adminwithpolicy << 7)       +         \\\n             (noda << 10)                 + (encryptedduplication << 11) +         \\\n             (restricted << 16)           + (decrypt << 17)              +         \\\n             (sign << 18)                 + (x509sign << 19))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_SESSION    UINT8\n#define TPMA_SESSION_TO_UINT8(a)     (*((UINT8 *)&(a)))\n#define UINT8_TO_TPMA_SESSION(a)     (*((TPMA_SESSION *)&(a)))\n#define TPMA_SESSION_TO_BYTE_ARRAY(i, a)                                           \\\n            UINT8_TO_BYTE_ARRAY((TPMA_SESSION_TO_UINT8(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_SESSION(i, a)                                           \\\n            { UINT8 x = BYTE_ARRAY_TO_UINT8(a); i = UINT8_TO_TPMA_SESSION(x); }\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_SESSION {                       // Table 2:32\n    unsigned    continueSession      : 1;\n    unsigned    auditExclusive       : 1;\n    unsigned    auditReset           : 1;\n    unsigned    Reserved_bits_at_3   : 2;\n    unsigned    decrypt              : 1;\n    unsigned    encrypt              : 1;\n    unsigned    audit                : 1;\n} TPMA_SESSION;\n// This is the initializer for a TPMA_SESSION structure\n#define TPMA_SESSION_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t continuesession, auditexclusive,  auditreset,      bits_at_3, \\\n\t\t\t\t decrypt,         encrypt,         audit) \\\n    {continuesession, auditexclusive,  auditreset,      bits_at_3,\t\\\n\t    decrypt,         encrypt,         audit}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:32 TPMA_SESSION using bit masking\ntypedef UINT8                           TPMA_SESSION;\n#define TYPE_OF_TPMA_SESSION            UINT8\n#define TPMA_SESSION_continueSession    ((TPMA_SESSION)1 << 0)\n#define TPMA_SESSION_auditExclusive     ((TPMA_SESSION)1 << 1)\n#define TPMA_SESSION_auditReset         ((TPMA_SESSION)1 << 2)\n#define TPMA_SESSION_decrypt            ((TPMA_SESSION)1 << 5)\n#define TPMA_SESSION_encrypt            ((TPMA_SESSION)1 << 6)\n#define TPMA_SESSION_audit              ((TPMA_SESSION)1 << 7)\n#define TPMA_SESSION_reserved\t\t    0x18\n// This is the initializer for a TPMA_SESSION bit array.\n#define TPMA_SESSION_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t continuesession, auditexclusive,  auditreset,      bits_at_3, \\\n\t\t\t\t decrypt,         encrypt,         audit) \\\n        (TPMA_SESSION) (\t\t\t\t\t\t\t\\\n            (continuesession << 0) + (auditexclusive << 1)  +\t\t\t\\\n\t    (auditreset << 2)      + (decrypt << 5)         +\t\t\\\n\t    (encrypt << 6)         + (audit << 7))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_LOCALITY   UINT8\n#define TPMA_LOCALITY_TO_UINT8(a)    (*((UINT8 *)&(a)))\n#define UINT8_TO_TPMA_LOCALITY(a)    (*((TPMA_LOCALITY *)&(a)))\n#define TPMA_LOCALITY_TO_BYTE_ARRAY(i, a)                                          \\\n            UINT8_TO_BYTE_ARRAY((TPMA_LOCALITY_TO_UINT8(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_LOCALITY(i, a)                                          \\\n            { UINT8 x = BYTE_ARRAY_TO_UINT8(a); i = UINT8_TO_TPMA_LOCALITY(x); }\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_LOCALITY {                      // Table 2:33\n    unsigned    TPM_LOC_ZERO         : 1;\n    unsigned    TPM_LOC_ONE          : 1;\n    unsigned    TPM_LOC_TWO          : 1;\n    unsigned    TPM_LOC_THREE        : 1;\n    unsigned    TPM_LOC_FOUR         : 1;\n    unsigned    Extended             : 3;\n} TPMA_LOCALITY;\n// This is the initializer for a TPMA_LOCALITY structure\n#define TPMA_LOCALITY_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t  tpm_loc_zero,  tpm_loc_one,   tpm_loc_two,   tpm_loc_three, \\\n\t\t\t\t  tpm_loc_four,  extended)\t\t\\\n    {tpm_loc_zero,  tpm_loc_one,   tpm_loc_two,   tpm_loc_three,\t\\\n\t    tpm_loc_four,  extended}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:33 TPMA_LOCALITY using bit masking\ntypedef UINT8                           TPMA_LOCALITY;\n#define TYPE_OF_TPMA_LOCALITY           UINT8\n#define TPMA_LOCALITY_TPM_LOC_ZERO      ((TPMA_LOCALITY)1 << 0)\n#define TPMA_LOCALITY_TPM_LOC_ONE       ((TPMA_LOCALITY)1 << 1)\n#define TPMA_LOCALITY_TPM_LOC_TWO       ((TPMA_LOCALITY)1 << 2)\n#define TPMA_LOCALITY_TPM_LOC_THREE     ((TPMA_LOCALITY)1 << 3)\n#define TPMA_LOCALITY_TPM_LOC_FOUR      ((TPMA_LOCALITY)1 << 4)\n#define TPMA_LOCALITY_Extended_SHIFT    5\n#define TPMA_LOCALITY_Extended          ((TPMA_LOCALITY)0x7 << 5)\n// This is the initializer for a TPMA_LOCALITY bit array.\n#define TPMA_LOCALITY_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t  tpm_loc_zero,  tpm_loc_one,   tpm_loc_two,   tpm_loc_three, \\\n\t\t\t\t  tpm_loc_four,  extended)\t\t\\\n     (TPMA_LOCALITY)(                  \t\t\t\t\t\\\n            (tpm_loc_zero << 0)  + (tpm_loc_one << 1)   + (tpm_loc_two << 2)   + \\\n\t    (tpm_loc_three << 3) + (tpm_loc_four << 4)  + (extended << 5))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_PERMANENT  UINT32\n#define TPMA_PERMANENT_TO_UINT32(a)  (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_PERMANENT(a)  (*((TPMA_PERMANENT *)&(a)))\n#define TPMA_PERMANENT_TO_BYTE_ARRAY(i, a)\t\t\t\t\\\n\t            UINT32_TO_BYTE_ARRAY((TPMA_PERMANENT_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_PERMANENT(i, a)\t\t\t\t\\\n    {UINT32 x = BYTE_ARRAY_TO_UINT32(a);\t\t\t\t\\\n\ti = UINT32_TO_TPMA_PERMANENT(x);\t\t\t\t\\\n    }\n\n/* Table 2:34 - Definition of TPMA_PERMANENT Bits (BitsTable()) */\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_PERMANENT {                     // Table 2:34\n    unsigned    ownerAuthSet         : 1;\n    unsigned    endorsementAuthSet   : 1;\n    unsigned    lockoutAuthSet       : 1;\n    unsigned    Reserved_bits_at_3   : 5;\n    unsigned    disableClear         : 1;\n    unsigned    inLockout            : 1;\n    unsigned    tpmGeneratedEPS      : 1;\n    unsigned    Reserved_bits_at_11  : 21;\n} TPMA_PERMANENT;\n// This is the initializer for a TPMA_PERMANENT structure\n#define TPMA_PERMANENT_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t   ownerauthset,       endorsementauthset, lockoutauthset, \\\n\t\t\t\t   bits_at_3,          disableclear,       inlockout, \\\n\t\t\t\t   tpmgeneratedeps,    bits_at_11)\t\\\n    {ownerauthset,       endorsementauthset, lockoutauthset,\t\t\\\n\t    bits_at_3,          disableclear,       inlockout,\t\t\\\n\t    tpmgeneratedeps,    bits_at_11}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:34 TPMA_PERMANENT using bit masking\ntypedef UINT32                              TPMA_PERMANENT;\n#define TYPE_OF_TPMA_PERMANENT              UINT32\n#define TPMA_PERMANENT_ownerAuthSet         ((TPMA_PERMANENT)1 << 0)\n#define TPMA_PERMANENT_endorsementAuthSet   ((TPMA_PERMANENT)1 << 1)\n#define TPMA_PERMANENT_lockoutAuthSet       ((TPMA_PERMANENT)1 << 2)\n#define TPMA_PERMANENT_disableClear         ((TPMA_PERMANENT)1 << 8)\n#define TPMA_PERMANENT_inLockout            ((TPMA_PERMANENT)1 << 9)\n#define TPMA_PERMANENT_tpmGeneratedEPS      ((TPMA_PERMANENT)1 << 10)\n// This is the initializer for a TPMA_PERMANENT bit array.\n#define TPMA_PERMANENT_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t   ownerauthset,       endorsementauthset, lockoutauthset, \\\n\t\t\t\t   bits_at_3,          disableclear,       inlockout, \\\n\t\t\t\t   tpmgeneratedeps,    bits_at_11)\t\\\n    (TPMA_PERMANENT) (\t\t\t\t\t\t\t\\\n            (ownerauthset << 0)       + (endorsementauthset << 1) +\t\t\\\n\t    (lockoutauthset << 2)     + (disableclear << 8)       +\t\\\n\t    (inlockout << 9)          + (tpmgeneratedeps << 10))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_STARTUP_CLEAR  UINT32\n#define TPMA_STARTUP_CLEAR_TO_UINT32(a)  (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_STARTUP_CLEAR(a)  (*((TPMA_STARTUP_CLEAR *)&(a)))\n#define TPMA_STARTUP_CLEAR_TO_BYTE_ARRAY(i, a)\t\t\t\t\\\n    UINT32_TO_BYTE_ARRAY((TPMA_STARTUP_CLEAR_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_STARTUP_CLEAR(i, a)\t\t\t\t\\\n    {UINT32 x = BYTE_ARRAY_TO_UINT32(a);\t\t\t\t\\\n\ti = UINT32_TO_TPMA_STARTUP_CLEAR(x);\t\t\t\t\\\n    }\n\n/* Table 2:35 - Definition of TPMA_STARTUP_CLEAR Bits */\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_STARTUP_CLEAR {                 // Table 2:35\n    unsigned    phEnable             : 1;\n    unsigned    shEnable             : 1;\n    unsigned    ehEnable             : 1;\n    unsigned    phEnableNV           : 1;\n    unsigned    Reserved_bits_at_4   : 27;\n    unsigned    orderly              : 1;\n} TPMA_STARTUP_CLEAR;\n// This is the initializer for a TPMA_STARTUP_CLEAR structure\n#define TPMA_STARTUP_CLEAR_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t       phenable, shenable, ehenable, phenablenv, bits_at_4, orderly) \\\n    {phenable, shenable, ehenable, phenablenv, bits_at_4, orderly}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:35 TPMA_STARTUP_CLEAR using bit masking\ntypedef UINT32                          TPMA_STARTUP_CLEAR;\n#define TYPE_OF_TPMA_STARTUP_CLEAR      UINT32\n#define TPMA_STARTUP_CLEAR_phEnable     ((TPMA_STARTUP_CLEAR)1 << 0)\n#define TPMA_STARTUP_CLEAR_shEnable     ((TPMA_STARTUP_CLEAR)1 << 1)\n#define TPMA_STARTUP_CLEAR_ehEnable     ((TPMA_STARTUP_CLEAR)1 << 2)\n#define TPMA_STARTUP_CLEAR_phEnableNV   ((TPMA_STARTUP_CLEAR)1 << 3)\n#define TPMA_STARTUP_CLEAR_orderly      ((TPMA_STARTUP_CLEAR)1 << 31)\n// This is the initializer for a TPMA_STARTUP_CLEAR bit array.\n#define TPMA_STARTUP_CLEAR_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\t       phenable, shenable, ehenable, phenablenv, bits_at_4, orderly) \\\n    (TPMA_STARTUP_CLEAR) (\t\t\t\t\t\t\\\n\t(phenable << 0)   + (shenable << 1)   + (ehenable << 2)   +\t\\\n\t(phenablenv << 3) + (orderly << 31))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_MEMORY UINT32\n#define TPMA_MEMORY_TO_UINT32(a)     (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_MEMORY(a)     (*((TPMA_MEMORY *)&(a)))\n#define TPMA_MEMORY_TO_BYTE_ARRAY(i, a)                                            \\\n            UINT32_TO_BYTE_ARRAY((TPMA_MEMORY_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_MEMORY(i, a)                                            \\\n            { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_MEMORY(x); }\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_MEMORY {                        // Table 2:36\n    unsigned    sharedRAM            : 1;\n    unsigned    sharedNV             : 1;\n    unsigned    objectCopiedToRam    : 1;\n    unsigned    Reserved_bits_at_3   : 29;\n} TPMA_MEMORY;\n// This is the initializer for a TPMA_MEMORY structure\n#define TPMA_MEMORY_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\tsharedram, sharednv, objectcopiedtoram, bits_at_3) \\\n    {sharedram, sharednv, objectcopiedtoram, bits_at_3}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:36 TPMA_MEMORY using bit masking\ntypedef UINT32                          TPMA_MEMORY;\n#define TYPE_OF_TPMA_MEMORY             UINT32\n#define TPMA_MEMORY_sharedRAM           ((TPMA_MEMORY)1 << 0)\n#define TPMA_MEMORY_sharedNV            ((TPMA_MEMORY)1 << 1)\n#define TPMA_MEMORY_objectCopiedToRam   ((TPMA_MEMORY)1 << 2)\n// This is the initializer for a TPMA_MEMORY bit array.\n#define TPMA_MEMORY_INITIALIZER(\t\t\t\t\t\\\n\t\t\t\tsharedram, sharednv, objectcopiedtoram, bits_at_3) \\\n    (TPMA_MEMORY)(                                                                 \\\n\t\t  (sharedram << 0) + (sharednv << 1) + (objectcopiedtoram << 2))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_CC     UINT32\n#define TPMA_CC_TO_UINT32(a)     (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_CC(a)     (*((TPMA_CC *)&(a)))\n#define TPMA_CC_TO_BYTE_ARRAY(i, a)                                                \\\n            UINT32_TO_BYTE_ARRAY((TPMA_CC_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_CC(i, a)                                                \\\n            { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_CC(x); }\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_CC {                            // Table 2:37\n    unsigned    commandIndex         : 16;\n    unsigned    Reserved_bits_at_16  : 6;\n    unsigned    nv                   : 1;\n    unsigned    extensive            : 1;\n    unsigned    flushed              : 1;\n    unsigned    cHandles             : 3;\n    unsigned    rHandle              : 1;\n    unsigned    V                    : 1;\n    unsigned    Reserved_bits_at_30  : 2;\n} TPMA_CC;\n// This is the initializer for a TPMA_CC structure\n#define TPMA_CC_INITIALIZER(\t\t\t\t\t\t\\\n\t\t\t    commandindex, bits_at_16,   nv,           extensive,    flushed, \\\n\t\t\t    chandles,     rhandle,      v,            bits_at_30) \\\n    {commandindex, bits_at_16,   nv,           extensive,    flushed,\t\\\n\t    chandles,     rhandle,      v,            bits_at_30}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:37 TPMA_CC using bit masking\ntypedef UINT32                      TPMA_CC;\n#define TYPE_OF_TPMA_CC             UINT32\n#define TPMA_CC_commandIndex_SHIFT  0\n#define TPMA_CC_commandIndex        ((TPMA_CC)0xffff << 0)\n#define TPMA_CC_nv                  ((TPMA_CC)1 << 22)\n#define TPMA_CC_extensive           ((TPMA_CC)1 << 23)\n#define TPMA_CC_flushed             ((TPMA_CC)1 << 24)\n#define TPMA_CC_cHandles_SHIFT      25\n#define TPMA_CC_cHandles            ((TPMA_CC)0x7 << 25)\n#define TPMA_CC_rHandle             ((TPMA_CC)1 << 28)\n#define TPMA_CC_V                   ((TPMA_CC)1 << 29)\n#define TPMA_CC_reserved\t    0xc03f0000\n// This is the initializer for a TPMA_CC bit array.\n#define TPMA_CC_INITIALIZER(\t\t\t\t\t\t\\\n\t\t\t    commandindex, bits_at_16,   nv,           extensive,    flushed, \\\n\t\t\t    chandles,     rhandle,      v,            bits_at_30) \\\n    (TPMA_CC)(\t\t\t\t\t\t\t\t\\\n    (commandindex << 0) + (nv << 22)          + (extensive << 23)   +\t\\\n    (flushed << 24)     + (chandles << 25)    + (rhandle << 28)     +\t\\\n    (v << 29))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_MODES  UINT32\n#define TPMA_MODES_TO_UINT32(a)  (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_MODES(a)  (*((TPMA_MODES *)&(a)))\n#define TPMA_MODES_TO_BYTE_ARRAY(i, a)                                             \\\n            UINT32_TO_BYTE_ARRAY((TPMA_MODES_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_MODES(i, a)                                             \\\n            { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_MODES(x); }\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_MODES {                         // Table 2:38\n    unsigned    FIPS_140_2           : 1;\n    unsigned    Reserved_bits_at_1   : 31;\n} TPMA_MODES;\n// This is the initializer for a TPMA_MODES structure\n#define TPMA_MODES_INITIALIZER(fips_140_2, bits_at_1) {fips_140_2, bits_at_1}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:38 TPMA_MODES using bit masking\ntypedef UINT32                  TPMA_MODES;\n#define TYPE_OF_TPMA_MODES      UINT32\n#define TPMA_MODES_FIPS_140_2   ((TPMA_MODES)1 << 0)\n// This is the initializer for a TPMA_MODES bit array.\n#define TPMA_MODES_INITIALIZER(fips_140_2, bits_at_1) \t\\\n    (TPMA_MODES)(\t\t\t\t\t\\\n    ((fips_140_2 << 0))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_X509_KEY_USAGE UINT32\n#define TPMA_X509_KEY_USAGE_TO_UINT32(a)     (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_X509_KEY_USAGE(a)     (*((TPMA_X509_KEY_USAGE *)&(a)))\n#define TPMA_X509_KEY_USAGE_TO_BYTE_ARRAY(i, a)\t\t\t\t\\\n    UINT32_TO_BYTE_ARRAY((TPMA_X509_KEY_USAGE_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_X509_KEY_USAGE(i, a)\t\t\t\t\\\n    {UINT32 x = BYTE_ARRAY_TO_UINT32(a);\t\t\t\t\\\n\ti = UINT32_TO_TPMA_X509_KEY_USAGE(x);\t\t\t\t\\\n    }\n#define TPMA_X509_KEY_USAGE_ALLOWED_BITS (0xff800000)\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_X509_KEY_USAGE {                // Table 2:39\n    unsigned    Reserved_bits_at_0   : 23;\n    unsigned    decipherOnly         : 1;\n    unsigned    encipherOnly         : 1;\n    unsigned    cRLSign              : 1;\n    unsigned    keyCertSign          : 1;\n    unsigned    keyAgreement         : 1;\n    unsigned    dataEncipherment     : 1;\n    unsigned    keyEncipherment      : 1;\n    unsigned    nonrepudiation       : 1;\n    unsigned    digitalSignature     : 1;\n} TPMA_X509_KEY_USAGE;                              /* Bits */\n// This is the initializer for a TPMA_X509_KEY_USAGE structure\n#define TPMA_X509_KEY_USAGE_INITIALIZER(                                           \\\n             bits_at_0,        decipheronly,     encipheronly,                     \\\n             cRLSign,          keycertsign,      keyagreement,                     \\\n             dataencipherment, keyencipherment,  nonrepudiation,                   \\\n             digitalsignature)                                                     \\\n            {bits_at_0,        decipheronly,     encipheronly,                     \\\n             cRLSign,          keycertsign,      keyagreement,                     \\\n             dataencipherment, keyencipherment,  nonrepudiation,                   \\\n             digitalsignature}\n#else // USE_BIT_FIELD_STRUCTURES\n/* This implements Table 2:39 TPMA_X509_KEY_USAGE using bit masking */\ntypedef UINT32                                  TPMA_X509_KEY_USAGE;\n#define TYPE_OF_TPMA_X509_KEY_USAGE             UINT32\n#define TPMA_X509_KEY_USAGE_decipherOnly        ((TPMA_X509_KEY_USAGE)1 << 23)\n#define TPMA_X509_KEY_USAGE_encipherOnly        ((TPMA_X509_KEY_USAGE)1 << 24)\n#define TPMA_X509_KEY_USAGE_cRLSign             ((TPMA_X509_KEY_USAGE)1 << 25)\n#define TPMA_X509_KEY_USAGE_keyCertSign         ((TPMA_X509_KEY_USAGE)1 << 26)\n#define TPMA_X509_KEY_USAGE_keyAgreement        ((TPMA_X509_KEY_USAGE)1 << 27)\n#define TPMA_X509_KEY_USAGE_dataEncipherment    ((TPMA_X509_KEY_USAGE)1 << 28)\n#define TPMA_X509_KEY_USAGE_keyEncipherment     ((TPMA_X509_KEY_USAGE)1 << 29)\n#define TPMA_X509_KEY_USAGE_nonrepudiation      ((TPMA_X509_KEY_USAGE)1 << 30)\n#define TPMA_X509_KEY_USAGE_digitalSignature    ((TPMA_X509_KEY_USAGE)1 << 31)\n//  This is the initializer for a TPMA_X509_KEY_USAGE bit array.\n#define TPMA_X509_KEY_USAGE_INITIALIZER(                                           \\\n             bits_at_0,        decipheronly,     encipheronly,                     \\\n             cRLSign,          keycertsign,      keyagreement,                     \\\n             dataencipherment, keyencipherment,  nonrepudiation,                   \\\n             digitalsignature)                                                     \\\n    (TPMA_X509_KEY_USAGE)(\t\t\t\t\t\t\\\n     (decipheronly << 23)     + (encipheronly << 24)     +\t\t\\\n     (cRLSign << 25)          + (keycertsign << 26)      +\t\t\\\n     (keyagreement << 27)     + (dataencipherment << 28) +\t\t\\\n     (keyencipherment << 29)  + (nonrepudiation << 30)   +\t\t\\\n     (digitalsignature << 31))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n#define TYPE_OF_TPMA_ACT    UINT32\n#define TPMA_ACT_TO_UINT32(a)    (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_ACT(a)    (*((TPMA_ACT *)&(a)))\n#define TPMA_ACT_TO_BYTE_ARRAY(i, a)\t\t\t\t\t\\\n    UINT32_TO_BYTE_ARRAY((TPMA_ACT_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_ACT(i, a)\t\t\t\t\t\\\n    { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_ACT(x); }\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_ACT {                           // Table 2:40\n    unsigned    signaled             : 1;\n    unsigned    preserveSignaled     : 1;\n    unsigned    Reserved_bits_at_2   : 30;\n} TPMA_ACT;                                         /* Bits */\n// This is the initializer for a TPMA_ACT structure\n#define TPMA_ACT_INITIALIZER(signaled, preservesignaled, bits_at_2)\t\\\n    {signaled, preservesignaled, bits_at_2}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:40 TPMA_ACT using bit masking\ntypedef UINT32                      TPMA_ACT;\n#define TYPE_OF_TPMA_ACT            UINT32\n#define TPMA_ACT_signaled           ((TPMA_ACT)1 << 0)\n#define TPMA_ACT_preserveSignaled   ((TPMA_ACT)1 << 1)\n// This is the initializer for a TPMA_ACT bit array.\n#define TPMA_ACT_INITIALIZER(signaled, preservesignaled, bits_at_2)\t\\\n    (TPMA_ACT)(\t\t\t\t\t\t\t\t\\\n\t       (signaled << 0) + (preservesignaled << 1))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n/* Table 2:39 - Definition of TPMI_YES_NO Type  */\ntypedef  BYTE               TPMI_YES_NO;\n/* Table 2:40 - Definition of TPMI_DH_OBJECT Type  */\ntypedef  TPM_HANDLE         TPMI_DH_OBJECT;\n/* Table 2:41 - Definition of TPMI_DH_PARENT Type  */\ntypedef  TPM_HANDLE         TPMI_DH_PARENT;\n/* Table 2:42 - Definition of TPMI_DH_PERSISTENT Type  */\ntypedef  TPM_HANDLE         TPMI_DH_PERSISTENT;\n/* Table 2:43 - Definition of TPMI_DH_ENTITY Type  */\ntypedef  TPM_HANDLE         TPMI_DH_ENTITY;\n/* Table 2:44 - Definition of TPMI_DH_PCR Type  */\ntypedef  TPM_HANDLE         TPMI_DH_PCR;\n/* Table 2:45 - Definition of TPMI_SH_AUTH_SESSION Type  */\ntypedef  TPM_HANDLE         TPMI_SH_AUTH_SESSION;\n/* Table 2:46 - Definition of TPMI_SH_HMAC Type  */\ntypedef  TPM_HANDLE         TPMI_SH_HMAC;\n/* Table 2:47 - Definition of TPMI_SH_POLICY Type  */\ntypedef  TPM_HANDLE         TPMI_SH_POLICY;\n/* Table 2:48 - Definition of TPMI_DH_CONTEXT Type  */\ntypedef  TPM_HANDLE         TPMI_DH_CONTEXT;\n/* Table 49 - Definition of (TPM_HANDLE) TPMI_DH_SAVED Type  */\ntypedef  TPM_HANDLE         TPMI_DH_SAVED;\n/* Table 2:49 - Definition of TPMI_RH_HIERARCHY Type  */\ntypedef  TPM_HANDLE         TPMI_RH_HIERARCHY;\n/* Table 2:50 - Definition of TPMI_RH_ENABLES Type  */\ntypedef  TPM_HANDLE         TPMI_RH_ENABLES;\n/* Table 2:51 - Definition of TPMI_RH_HIERARCHY_AUTH Type  */\ntypedef  TPM_HANDLE         TPMI_RH_HIERARCHY_AUTH;\n/* Table 2:55 - Definition of TPMI_RH_HIERARCHY_POLICY Type  */\ntypedef  TPM_HANDLE         TPMI_RH_HIERARCHY_POLICY;\n/* Table 2:52 - Definition of TPMI_RH_PLATFORM Type  */\ntypedef  TPM_HANDLE         TPMI_RH_PLATFORM;\n/* Table 2:53 - Definition of TPMI_RH_OWNER Type  */\ntypedef  TPM_HANDLE         TPMI_RH_OWNER;\n/* Table 2:54 - Definition of TPMI_RH_ENDORSEMENT Type  */\ntypedef  TPM_HANDLE         TPMI_RH_ENDORSEMENT;\n/* Table 2:55 - Definition of TPMI_RH_PROVISION Type  */\ntypedef  TPM_HANDLE         TPMI_RH_PROVISION;\n/* Table 2:56 - Definition of TPMI_RH_CLEAR Type  */\ntypedef  TPM_HANDLE         TPMI_RH_CLEAR;\n/* Table 2:57 - Definition of TPMI_RH_NV_AUTH Type  */\ntypedef  TPM_HANDLE         TPMI_RH_NV_AUTH;\n/* Table 2:58 - Definition of TPMI_RH_LOCKOUT Type  */\ntypedef  TPM_HANDLE         TPMI_RH_LOCKOUT;\n/* Table 2:59 - Definition of TPMI_RH_NV_INDEX Type  */\ntypedef  TPM_HANDLE         TPMI_RH_NV_INDEX;\n\ntypedef TPM_HANDLE \t    TPMI_RH_NV_DEFINED_INDEX;\ntypedef TPM_HANDLE \t    TPMI_RH_NV_LEGACY_INDEX;\ntypedef TPM_HANDLE \t    TPMI_RH_NV_EXP_INDEX;\n\n/* Table 2:60 - Definition of TPMI_RH_AC Type  */\ntypedef  TPM_HANDLE         TPMI_RH_AC;\n/* Table 2:65 - Definition of TPMI_RH_ACT Type  */\ntypedef  TPM_HANDLE         TPMI_RH_ACT;\n/* Table 2:61 - Definition of TPMI_ALG_HASH Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_HASH;\n/* Table 2:62 - Definition of TPMI_ALG_ASYM Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_ASYM;\n/* Table 2:63 - Definition of TPMI_ALG_SYM Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_SYM;\n/* Table 2:64 - Definition of TPMI_ALG_SYM_OBJECT Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_SYM_OBJECT;\n/* Table 2:65 - Definition of TPMI_ALG_SYM_MODE Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_SYM_MODE;\n/* Table 2:66 - Definition of TPMI_ALG_KDF Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_KDF;\n/* Table 2:67 - Definition of TPMI_ALG_SIG_SCHEME Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_SIG_SCHEME;\n/* Table 2:68 - Definition of TPMI_ECC_KEY_EXCHANGE Type  */\ntypedef  TPM_ALG_ID         TPMI_ECC_KEY_EXCHANGE;\n/* Table 2:69 - Definition of TPMI_ST_COMMAND_TAG Type  */\ntypedef  TPM_ST             TPMI_ST_COMMAND_TAG;\n/* Table 2:70 - Definition of TPMI_ALG_MAC_SCHEME Type */\ntypedef  TPM_ALG_ID         TPMI_ALG_MAC_SCHEME;\n/* le 2:70 - Definition of TPMI_ALG_CIPHER_MODE Type */\ntypedef  TPM_ALG_ID         TPMI_ALG_CIPHER_MODE;\n/* Table 2:70 - Definition of TPMS_EMPTY Structure  */\ntypedef BYTE TPMS_EMPTY;\n/* Table 2:71 - Definition of TPMS_ALGORITHM_DESCRIPTION Structure  */\ntypedef struct {\n    TPM_ALG_ID              alg;\n    TPMA_ALGORITHM          attributes;\n} TPMS_ALGORITHM_DESCRIPTION;\n/* Table 2:71 - Definition of TPMU_HA Union  */\ntypedef union {\n#if \tALG_SHA1\n    BYTE                    sha1[SHA1_DIGEST_SIZE];\n#endif   // ALG_SHA1\n#if \tALG_SHA256\n    BYTE                    sha256[SHA256_DIGEST_SIZE];\n#endif   // ALG_SHA256\n#if \tALG_SHA384\n    BYTE                    sha384[SHA384_DIGEST_SIZE];\n#endif   // ALG_SHA384\n#if \tALG_SHA512\n    BYTE                    sha512[SHA512_DIGEST_SIZE];\n#endif   // ALG_SHA512\n#if \tALG_SM3_256\n    BYTE                    sm3_256[SM3_256_DIGEST_SIZE];\n#endif   // ALG_SM3_256\n#if ALG_SHA3_256\n    BYTE                    sha3_256[SHA3_256_DIGEST_SIZE];\n#endif // ALG_SHA3_256\n#if ALG_SHA3_384\n    BYTE                    sha3_384[SHA3_384_DIGEST_SIZE];\n#endif // ALG_SHA3_384\n#if ALG_SHA3_512\n    BYTE                    sha3_512[SHA3_512_DIGEST_SIZE];\n#endif // ALG_SHA3_512\n} TPMU_HA;\n/* Table 2:72 - Definition of TPMT_HA Structure  */\ntypedef struct {\n    TPMI_ALG_HASH           hashAlg;\n    TPMU_HA                 digest;\n} TPMT_HA;\n/* Table 2:73 - Definition of TPM2B_DIGEST Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[sizeof(TPMU_HA)];\n    }            t;\n    TPM2B        b;\n} TPM2B_DIGEST;\n/* Table 2:74 - Definition of TPM2B_DATA Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[sizeof(TPMT_HA)];\n    }            t;\n    TPM2B        b;\n} TPM2B_DATA;\n/* Table 2:75 - Definition of Types for TPM2B_NONCE */\ntypedef  TPM2B_DIGEST       TPM2B_NONCE;\n/* Table 2:76 - Definition of Types for TPM2B_AUTH */\ntypedef  TPM2B_DIGEST       TPM2B_AUTH;\n/* Table 2:77 - Definition of Types for TPM2B_OPERAND */\ntypedef  TPM2B_DIGEST       TPM2B_OPERAND;\n/* Table 2:78 - Definition of TPM2B_EVENT Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[1024];\n    }            t;\n    TPM2B        b;\n} TPM2B_EVENT;\n/* Table 2:79 - Definition of TPM2B_MAX_BUFFER Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[MAX_DIGEST_BUFFER];\n    }            t;\n    TPM2B        b;\n} TPM2B_MAX_BUFFER;\n/* Table 2:80 - Definition of TPM2B_MAX_NV_BUFFER Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[MAX_NV_BUFFER_SIZE];\n    }            t;\n    TPM2B        b;\n} TPM2B_MAX_NV_BUFFER;\n/* Table 2:82 - Definition of TPM2B_TIMEOUT Structure */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[sizeof(UINT64)];\n    }            t;\n    TPM2B        b;\n} TPM2B_TIMEOUT;\n/* Table 2:82 - Definition of TPM2B_IV Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[MAX_SYM_BLOCK_SIZE];\n    }            t;\n    TPM2B        b;\n} TPM2B_IV;\n/* Table 2:83 - Definition of TPMU_NAME Union  */\ntypedef union {\n    TPMT_HA                 digest;\n    TPM_HANDLE              handle;\n} TPMU_NAME;\n/* Table 2:84 - Definition of TPM2B_NAME Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    name[sizeof(TPMU_NAME)];\n    }            t;\n    TPM2B        b;\n} TPM2B_NAME;\n/* Table 2:85 - Definition of TPMS_PCR_SELECT Structure  */\ntypedef struct {\n    UINT8                   sizeofSelect;\n    BYTE                    pcrSelect[PCR_SELECT_MAX];\n} TPMS_PCR_SELECT;\n/* Table 2:86 - Definition of TPMS_PCR_SELECTION Structure  */\ntypedef struct {\n    TPMI_ALG_HASH           hash;\n    UINT8                   sizeofSelect;\n    BYTE                    pcrSelect[PCR_SELECT_MAX];\n} TPMS_PCR_SELECTION;\n/* Table 2:89 - Definition of TPMT_TK_CREATION Structure  */\ntypedef struct {\n    TPM_ST                  tag;\n    TPMI_RH_HIERARCHY       hierarchy;\n    TPM2B_DIGEST            digest;\n} TPMT_TK_CREATION;\n/* Table 2:90 - Definition of TPMT_TK_VERIFIED Structure  */\ntypedef struct {\n    TPM_ST                  tag;\n    TPMI_RH_HIERARCHY       hierarchy;\n    TPM2B_DIGEST            digest;\n} TPMT_TK_VERIFIED;\n/* Table 2:91 - Definition of TPMT_TK_AUTH Structure  */\ntypedef struct {\n    TPM_ST                  tag;\n    TPMI_RH_HIERARCHY       hierarchy;\n    TPM2B_DIGEST            digest;\n} TPMT_TK_AUTH;\n/* Table 2:92 - Definition of TPMT_TK_HASHCHECK Structure  */\ntypedef struct {\n    TPM_ST                  tag;\n    TPMI_RH_HIERARCHY       hierarchy;\n    TPM2B_DIGEST            digest;\n} TPMT_TK_HASHCHECK;\n/* Table 2:93 - Definition of TPMS_ALG_PROPERTY Structure  */\ntypedef struct {\n    TPM_ALG_ID              alg;\n    TPMA_ALGORITHM          algProperties;\n} TPMS_ALG_PROPERTY;\n/* Table 2:94 - Definition of TPMS_TAGGED_PROPERTY Structure  */\ntypedef struct {\n    TPM_PT                  property;\n    UINT32                  value;\n} TPMS_TAGGED_PROPERTY;\n/* Table 2:95 - Definition of TPMS_TAGGED_PCR_SELECT Structure  */\ntypedef struct {\n    TPM_PT_PCR              tag;\n    UINT8                   sizeofSelect;\n    BYTE                    pcrSelect[PCR_SELECT_MAX];\n} TPMS_TAGGED_PCR_SELECT;\n/* Table 2:96 - Definition of TPMS_TAGGED_POLICY Structure  */\ntypedef struct {\n    TPM_HANDLE              handle;\n    TPMT_HA                 policyHash;\n} TPMS_TAGGED_POLICY;\n/* Table 105 - Definition of TPMS_ACT_DATA Structure <OUT> */\ntypedef struct {\n    TPM_HANDLE\t\t    handle;\n    UINT32\t\t    timeout;\n    TPMA_ACT\t\t    attributes;\n} TPMS_ACT_DATA;\n/* Table 2:97 - Definition of TPML_CC Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPM_CC                  commandCodes[MAX_CAP_CC];\n} TPML_CC;\n/* Table 2:98 - Definition of TPML_CCA Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPMA_CC                 commandAttributes[MAX_CAP_CC];\n} TPML_CCA;\n/* Table 2:99 - Definition of TPML_ALG Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPM_ALG_ID              algorithms[MAX_ALG_LIST_SIZE];\n} TPML_ALG;\n/* Table 2:100 - Definition of TPML_HANDLE Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPM_HANDLE              handle[MAX_CAP_HANDLES];\n} TPML_HANDLE;\n/* Table 2:101 - Definition of TPML_DIGEST Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPM2B_DIGEST            digests[8];\n} TPML_DIGEST;\n/* Table 2:102 - Definition of TPML_DIGEST_VALUES Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPMT_HA                 digests[HASH_COUNT];\n} TPML_DIGEST_VALUES;\n/* Table 2:104 - Definition of TPML_PCR_SELECTION Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPMS_PCR_SELECTION      pcrSelections[HASH_COUNT];\n} TPML_PCR_SELECTION;\n/* Table 2:105 - Definition of TPML_ALG_PROPERTY Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPMS_ALG_PROPERTY       algProperties[MAX_CAP_ALGS];\n} TPML_ALG_PROPERTY;\n/* Table 2:106 - Definition of TPML_TAGGED_TPM_PROPERTY Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPMS_TAGGED_PROPERTY    tpmProperty[MAX_TPM_PROPERTIES];\n} TPML_TAGGED_TPM_PROPERTY;\n/* Table 2:107 - Definition of TPML_TAGGED_PCR_PROPERTY Structure  */\ntypedef struct {\n    UINT32                    count;\n    TPMS_TAGGED_PCR_SELECT    pcrProperty[MAX_PCR_PROPERTIES];\n} TPML_TAGGED_PCR_PROPERTY;\n/* Table 2:108 - Definition of TPML_ECC_CURVE Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPM_ECC_CURVE           eccCurves[MAX_ECC_CURVES];\n} TPML_ECC_CURVE;\n/* Table 2:109 - Definition of TPML_TAGGED_POLICY Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPMS_TAGGED_POLICY      policies[MAX_TAGGED_POLICIES];\n} TPML_TAGGED_POLICY;\n/* Table 2:118 - Definition of TPML_ACT_DATA Structure <OUT> */\ntypedef struct {\n    UINT32\t\tcount;\n    TPMS_ACT_DATA\tactData[MAX_ACT_DATA];\n} TPML_ACT_DATA;\n/* Table 2:110 - Definition of TPMU_CAPABILITIES Union  */\ntypedef union {\n    TPML_ALG_PROPERTY           algorithms;\n    TPML_HANDLE                 handles;\n    TPML_CCA                    command;\n    TPML_CC                     ppCommands;\n    TPML_CC                     auditCommands;\n    TPML_PCR_SELECTION          assignedPCR;\n    TPML_TAGGED_TPM_PROPERTY    tpmProperties;\n    TPML_TAGGED_PCR_PROPERTY    pcrProperties;\n#if \tALG_ECC\n    TPML_ECC_CURVE              eccCurves;\n#endif   // ALG_ECC\n    TPML_TAGGED_POLICY          authPolicies;\n    TPML_ACT_DATA \t\tactData;\n} TPMU_CAPABILITIES;\n/* NOTE The TPMU_SET_CAPABILITIES structure may be defined by a TCG Registry. */\ntypedef struct {\n    UINT32\tplatformSpecific;\n} TPMU_SET_CAPABILITIES;\n/* Table 2:111 - Definition of TPMS_CAPABILITY_DATA Structure  */\ntypedef struct {\n    TPM_CAP                 capability;\n    TPMU_CAPABILITIES       data;\n} TPMS_CAPABILITY_DATA;\n/* Table 129 - Definition of TPMS_SET_CAPABILITY_DATA Structure <IN> */\ntypedef struct {\n    TPM_CAP\t\t\tsetCapability;\n    TPMU_SET_CAPABILITIES\tdata;\n} TPMS_SET_CAPABILITY_DATA;\n/* Table 130 - Definition of TPM2B_SET_CAPABILITY_DATA Structure <IN> */\ntypedef struct {\n    UINT16\t\t\tsize;\n    TPMS_SET_CAPABILITY_DATA\tsetCapabilityData;\n} TPM2B_SET_CAPABILITY_DATA;\n/* Table 2:112 - Definition of TPMS_CLOCK_INFO Structure  */\ntypedef struct {\n    UINT64                  clock;\n    UINT32                  resetCount;\n    UINT32                  restartCount;\n    TPMI_YES_NO             safe;\n} TPMS_CLOCK_INFO;\n/* Table 2:113 - Definition of TPMS_TIME_INFO Structure  */\ntypedef struct {\n    UINT64                  time;\n    TPMS_CLOCK_INFO         clockInfo;\n} TPMS_TIME_INFO;\n/* Table 2:114 - Definition of TPMS_TIME_ATTEST_INFO Structure  */\ntypedef struct {\n    TPMS_TIME_INFO          time;\n    UINT64                  firmwareVersion;\n} TPMS_TIME_ATTEST_INFO;\n/* Table 2:115 - Definition of TPMS_CERTIFY_INFO Structure  */\ntypedef struct {\n    TPM2B_NAME              name;\n    TPM2B_NAME              qualifiedName;\n} TPMS_CERTIFY_INFO;\n/* Table 2:116 - Definition of TPMS_QUOTE_INFO Structure  */\ntypedef struct {\n    TPML_PCR_SELECTION      pcrSelect;\n    TPM2B_DIGEST            pcrDigest;\n} TPMS_QUOTE_INFO;\n/* Table 2:117 - Definition of TPMS_COMMAND_AUDIT_INFO Structure  */\ntypedef struct {\n    UINT64                  auditCounter;\n    TPM_ALG_ID              digestAlg;\n    TPM2B_DIGEST            auditDigest;\n    TPM2B_DIGEST            commandDigest;\n} TPMS_COMMAND_AUDIT_INFO;\n/* Table 2:118 - Definition of TPMS_SESSION_AUDIT_INFO Structure  */\ntypedef struct {\n    TPMI_YES_NO             exclusiveSession;\n    TPM2B_DIGEST            sessionDigest;\n} TPMS_SESSION_AUDIT_INFO;\n/* Table 2:119 - Definition of TPMS_CREATION_INFO Structure  */\ntypedef struct {\n    TPM2B_NAME              objectName;\n    TPM2B_DIGEST            creationHash;\n} TPMS_CREATION_INFO;\n/* Table 2:120 - Definition of TPMS_NV_CERTIFY_INFO Structure  */\ntypedef struct {\n    TPM2B_NAME              indexName;\n    UINT16                  offset;\n    TPM2B_MAX_NV_BUFFER     nvContents;\n} TPMS_NV_CERTIFY_INFO;\n/* Table 125 - Definition of TPMS_NV_DIGEST_CERTIFY_INFO Structure <OUT> */\ntypedef struct {\n    TPM2B_NAME\t\tindexName;\n    TPM2B_DIGEST\tnvDigest;\n} TPMS_NV_DIGEST_CERTIFY_INFO; \n/* Table 2:121 - Definition of TPMI_ST_ATTEST Type  */\ntypedef  TPM_ST             TPMI_ST_ATTEST;\n/* Table 2:122 - Definition of TPMU_ATTEST Union  */\ntypedef union {\n    TPMS_CERTIFY_INFO          certify;\n    TPMS_CREATION_INFO         creation;\n    TPMS_QUOTE_INFO            quote;\n    TPMS_COMMAND_AUDIT_INFO    commandAudit;\n    TPMS_SESSION_AUDIT_INFO    sessionAudit;\n    TPMS_TIME_ATTEST_INFO      time;\n    TPMS_NV_CERTIFY_INFO       nv;\n    TPMS_NV_DIGEST_CERTIFY_INFO\tnvDigest;\n} TPMU_ATTEST;\n/* Table 2:123 - Definition of TPMS_ATTEST Structure  */\ntypedef struct {\n    TPM_CONSTANTS32         magic;\n    TPMI_ST_ATTEST          type;\n    TPM2B_NAME              qualifiedSigner;\n    TPM2B_DATA              extraData;\n    TPMS_CLOCK_INFO         clockInfo;\n    UINT64                  firmwareVersion;\n    TPMU_ATTEST             attested;\n} TPMS_ATTEST;\n/* Table 2:124 - Definition of TPM2B_ATTEST Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    attestationData[sizeof(TPMS_ATTEST)];\n    }            t;\n    TPM2B        b;\n} TPM2B_ATTEST;\n/* Table 2:125 - Definition of TPMS_AUTH_COMMAND Structure  */\ntypedef struct {\n    TPMI_SH_AUTH_SESSION     sessionHandle;\n    TPM2B_NONCE              nonce;\n    TPMA_SESSION             sessionAttributes;\n    TPM2B_AUTH               hmac;\n} TPMS_AUTH_COMMAND;\n/* Table 2:126 - Definition of TPMS_AUTH_RESPONSE Structure  */\ntypedef struct {\n    TPM2B_NONCE             nonce;\n    TPMA_SESSION            sessionAttributes;\n    TPM2B_AUTH              hmac;\n} TPMS_AUTH_RESPONSE;\n/* Table 2:127 - Definition of TPMI_TDES_KEY_BITS Type  */\ntypedef  TPM_KEY_BITS       TPMI_TDES_KEY_BITS;\n/* Table 2:127 - Definition of TPMI_AES_KEY_BITS Type  */\ntypedef  TPM_KEY_BITS       TPMI_AES_KEY_BITS;\n/* Table 2:127 - Definition of TPMI_SM4_KEY_BITS Type  */\ntypedef  TPM_KEY_BITS       TPMI_SM4_KEY_BITS;\n/* Table 2:127 - Definition of TPMI_CAMELLIA_KEY_BITS Type  */\ntypedef  TPM_KEY_BITS       TPMI_CAMELLIA_KEY_BITS;\n/* Table 2:128 - Definition of TPMU_SYM_KEY_BITS Union  */\ntypedef union {\n#if \tALG_TDES\n    TPMI_TDES_KEY_BITS        tdes;\n#endif   // ALG_TDES\n#if \tALG_AES\n    TPMI_AES_KEY_BITS         aes;\n#endif   // ALG_AES\n#if \tALG_SM4\n    TPMI_SM4_KEY_BITS         sm4;\n#endif   // ALG_SM4\n#if \tALG_CAMELLIA\n    TPMI_CAMELLIA_KEY_BITS    camellia;\n#endif   // ALG_CAMELLIA\n    TPM_KEY_BITS              sym;\n#if \tALG_XOR\n    TPMI_ALG_HASH             xorr;\n#endif   // ALG_XOR\n} TPMU_SYM_KEY_BITS;\n/* Table 2:129 - Definition of TPMU_SYM_MODE Union  */\ntypedef union {\n#if \tALG_TDES\n    TPMI_ALG_SYM_MODE       tdes;\n#endif   // ALG_TDES\n#if \tALG_AES\n    TPMI_ALG_SYM_MODE       aes;\n#endif   // ALG_AES\n#if \tALG_SM4\n    TPMI_ALG_SYM_MODE       sm4;\n#endif   // ALG_SM4\n#if \tALG_CAMELLIA\n    TPMI_ALG_SYM_MODE       camellia;\n#endif   // ALG_CAMELLIA\n    TPMI_ALG_SYM_MODE       sym;\n} TPMU_SYM_MODE;\n/* Table 2:131 - Definition of TPMT_SYM_DEF Structure  */\ntypedef struct {\n    TPMI_ALG_SYM            algorithm;\n    TPMU_SYM_KEY_BITS       keyBits;\n    TPMU_SYM_MODE           mode;\n} TPMT_SYM_DEF;\n/* Table 2:132 - Definition of TPMT_SYM_DEF_OBJECT Structure  */\ntypedef struct {\n    TPMI_ALG_SYM_OBJECT     algorithm;\n    TPMU_SYM_KEY_BITS       keyBits;\n    TPMU_SYM_MODE           mode;\n} TPMT_SYM_DEF_OBJECT;\n/* Table 2:133 - Definition of TPM2B_SYM_KEY Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[MAX_SYM_KEY_BYTES];\n    }            t;\n    TPM2B        b;\n} TPM2B_SYM_KEY;\n/* Table 2:134 - Definition of TPMS_SYMCIPHER_PARMS Structure  */\ntypedef struct {\n    TPMT_SYM_DEF_OBJECT     sym;\n} TPMS_SYMCIPHER_PARMS;\n/* Table 2:135 - Definition of TPM2B_LABEL Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[LABEL_MAX_BUFFER];\n    }            t;\n    TPM2B        b;\n} TPM2B_LABEL;\n/* Table 2:136 - Definition of TPMS_DERIVE Structure  */\ntypedef struct {\n    TPM2B_LABEL             label;\n    TPM2B_LABEL             context;\n} TPMS_DERIVE;\n/* Table 2:137 - Definition of TPM2B_DERIVE Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[sizeof(TPMS_DERIVE)];\n    }            t;\n    TPM2B        b;\n} TPM2B_DERIVE;\n/* Table 2:138 - Definition of TPMU_SENSITIVE_CREATE Union  */\ntypedef union {\n    BYTE                    create[MAX_SYM_DATA];\n    TPMS_DERIVE             derive;\n} TPMU_SENSITIVE_CREATE;\n/* Table 2:139 - Definition of TPM2B_SENSITIVE_DATA Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[sizeof(TPMU_SENSITIVE_CREATE)];\n    }            t;\n    TPM2B        b;\n} TPM2B_SENSITIVE_DATA;\n/* Table 2:140 - Definition of TPMS_SENSITIVE_CREATE Structure  */\ntypedef struct {\n    TPM2B_AUTH              userAuth;\n    TPM2B_SENSITIVE_DATA    data;\n} TPMS_SENSITIVE_CREATE;\n/* Table 2:141 - Definition of TPM2B_SENSITIVE_CREATE Structure  */\ntypedef struct {\n    UINT16                   size;\n    TPMS_SENSITIVE_CREATE    sensitive;\n} TPM2B_SENSITIVE_CREATE;\n/* Table 2:142 - Definition of TPMS_SCHEME_HASH Structure  */\ntypedef struct {\n    TPMI_ALG_HASH           hashAlg;\n} TPMS_SCHEME_HASH;\n/* Table 2:143 - Definition of TPMS_SCHEME_ECDAA Structure  */\ntypedef struct {\n    TPMI_ALG_HASH           hashAlg;\n    UINT16                  count;\n} TPMS_SCHEME_ECDAA;\n/* Table 2:144 - Definition of TPMI_ALG_KEYEDHASH_SCHEME Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_KEYEDHASH_SCHEME;\n/* Table 2:145 - Definition of Types for HMAC_SIG_SCHEME */\ntypedef  TPMS_SCHEME_HASH    TPMS_SCHEME_HMAC;\n/* Table 2:146 - Definition of TPMS_SCHEME_XOR Structure  */\ntypedef struct {\n    TPMI_ALG_HASH           hashAlg;\n    TPMI_ALG_KDF            kdf;\n} TPMS_SCHEME_XOR;\n/* Table 2:147 - Definition of TPMU_SCHEME_KEYEDHASH Union  */\ntypedef union {\n#if \tALG_HMAC\n    TPMS_SCHEME_HMAC        hmac;\n#endif   // ALG_HMAC\n#if \tALG_XOR\n    TPMS_SCHEME_XOR         xorr;\n#endif   // ALG_XOR\n} TPMU_SCHEME_KEYEDHASH;\n/* Table 2:148 - Definition of TPMT_KEYEDHASH_SCHEME Structure  */\ntypedef struct {\n    TPMI_ALG_KEYEDHASH_SCHEME     scheme;\n    TPMU_SCHEME_KEYEDHASH         details;\n} TPMT_KEYEDHASH_SCHEME;\n/* Table 2:149 - Definition of Types for RSA Signature Schemes */\ntypedef  TPMS_SCHEME_HASH    TPMS_SIG_SCHEME_RSASSA;\ntypedef  TPMS_SCHEME_HASH    TPMS_SIG_SCHEME_RSAPSS;\n/* Table 2:150 - Definition of Types for ECC Signature Schemes */\ntypedef  TPMS_SCHEME_HASH     TPMS_SIG_SCHEME_ECDSA;\ntypedef  TPMS_SCHEME_HASH     TPMS_SIG_SCHEME_SM2;\ntypedef  TPMS_SCHEME_HASH     TPMS_SIG_SCHEME_ECSCHNORR;\ntypedef  TPMS_SCHEME_ECDAA    TPMS_SIG_SCHEME_ECDAA;\n/* Table 2:151 - Definition of TPMU_SIG_SCHEME Union  */\ntypedef union {\n#if \tALG_ECC\n    TPMS_SIG_SCHEME_ECDAA        ecdaa;\n#endif   // ALG_ECC\n#if \tALG_RSASSA\n    TPMS_SIG_SCHEME_RSASSA       rsassa;\n#endif   // ALG_RSASSA\n#if \tALG_RSAPSS\n    TPMS_SIG_SCHEME_RSAPSS       rsapss;\n#endif   // ALG_RSAPSS\n#if \tALG_ECDSA\n    TPMS_SIG_SCHEME_ECDSA        ecdsa;\n#endif   // ALG_ECDSA\n#if \tALG_SM2\n    TPMS_SIG_SCHEME_SM2          sm2;\n#endif   // ALG_SM2\n#if \tALG_ECSCHNORR\n    TPMS_SIG_SCHEME_ECSCHNORR    ecschnorr;\n#endif   // ALG_ECSCHNORR\n#if \tALG_HMAC\n    TPMS_SCHEME_HMAC             hmac;\n#endif   // ALG_HMAC\n    TPMS_SCHEME_HASH             any;\n} TPMU_SIG_SCHEME;\n/* Table 2:152 - Definition of TPMT_SIG_SCHEME Structure  */\ntypedef struct {\n    TPMI_ALG_SIG_SCHEME     scheme;\n    TPMU_SIG_SCHEME         details;\n} TPMT_SIG_SCHEME;\n/* Table 2:153 - Definition of Types for Encryption Schemes */\ntypedef  TPMS_SCHEME_HASH    TPMS_ENC_SCHEME_OAEP;\ntypedef  TPMS_EMPTY          TPMS_ENC_SCHEME_RSAES;\n/* Table 2:154 - Definition of Types for ECC Key Exchange */\ntypedef  TPMS_SCHEME_HASH    TPMS_KEY_SCHEME_ECDH;\ntypedef  TPMS_SCHEME_HASH    TPMS_KEY_SCHEME_ECMQV;\n/* Table 2:155 - Definition of Types for KDF Schemes */\ntypedef  TPMS_SCHEME_HASH    TPMS_KDF_SCHEME_MGF1;\ntypedef  TPMS_SCHEME_HASH    TPMS_KDF_SCHEME_KDF1_SP800_56A;\ntypedef  TPMS_SCHEME_HASH    TPMS_KDF_SCHEME_KDF2;\ntypedef  TPMS_SCHEME_HASH    TPMS_KDF_SCHEME_KDF1_SP800_108;\n/* Table 2:156 - Definition of TPMU_KDF_SCHEME Union  */\ntypedef union {\n#if \tALG_MGF1\n    TPMS_KDF_SCHEME_MGF1              mgf1;\n#endif   // ALG_MGF1\n#if \tALG_KDF1_SP800_56A\n    TPMS_KDF_SCHEME_KDF1_SP800_56A    kdf1_sp800_56a;\n#endif   // ALG_KDF1_SP800_56A\n#if \tALG_KDF2\n    TPMS_KDF_SCHEME_KDF2              kdf2;\n#endif   // ALG_KDF2\n#if \tALG_KDF1_SP800_108\n    TPMS_KDF_SCHEME_KDF1_SP800_108    kdf1_sp800_108;\n#endif   // ALG_KDF1_SP800_108\n    TPMS_SCHEME_HASH                    anyKdf;\n} TPMU_KDF_SCHEME;\n/* Table 2:157 - Definition of TPMT_KDF_SCHEME Structure  */\ntypedef struct {\n    TPMI_ALG_KDF            scheme;\n    TPMU_KDF_SCHEME         details;\n} TPMT_KDF_SCHEME;\n/* Table 2:158 - Definition of TPMI_ALG_ASYM_SCHEME Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_ASYM_SCHEME;\n/* Table 2:159 - Definition of TPMU_ASYM_SCHEME Union  */\ntypedef union {\n#if \tALG_ECDH\n    TPMS_KEY_SCHEME_ECDH         ecdh;\n#endif   // ALG_ECDH\n#if \tALG_ECMQV\n    TPMS_KEY_SCHEME_ECMQV        ecmqv;\n#endif   // ALG_ECMQV\n#if \tALG_ECC\n    TPMS_SIG_SCHEME_ECDAA        ecdaa;\n#endif   // ALG_ECC\n#if \tALG_RSASSA\n    TPMS_SIG_SCHEME_RSASSA       rsassa;\n#endif   // ALG_RSASSA\n#if \tALG_RSAPSS\n    TPMS_SIG_SCHEME_RSAPSS       rsapss;\n#endif   // ALG_RSAPSS\n#if \tALG_ECDSA\n    TPMS_SIG_SCHEME_ECDSA        ecdsa;\n#endif   // ALG_ECDSA\n#if \tALG_SM2\n    TPMS_SIG_SCHEME_SM2          sm2;\n#endif   // ALG_SM2\n#if \tALG_ECSCHNORR\n    TPMS_SIG_SCHEME_ECSCHNORR    ecschnorr;\n#endif   // ALG_ECSCHNORR\n#if \tALG_RSAES\n    TPMS_ENC_SCHEME_RSAES        rsaes;\n#endif   // ALG_RSAES\n#if \tALG_OAEP\n    TPMS_ENC_SCHEME_OAEP         oaep;\n#endif   // ALG_OAEP\n    TPMS_SCHEME_HASH             anySig;\n} TPMU_ASYM_SCHEME;\n/* Table 2:160 - Definition of TPMT_ASYM_SCHEME Structure  */\ntypedef struct {\n    TPMI_ALG_ASYM_SCHEME     scheme;\n    TPMU_ASYM_SCHEME         details;\n} TPMT_ASYM_SCHEME;\n/* Table 2:161 - Definition of TPMI_ALG_RSA_SCHEME Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_RSA_SCHEME;\n/* Table 2:162 - Definition of TPMT_RSA_SCHEME Structure  */\ntypedef struct {\n    TPMI_ALG_RSA_SCHEME     scheme;\n    TPMU_ASYM_SCHEME        details;\n} TPMT_RSA_SCHEME;\n/* Table 2:163 - Definition of TPMI_ALG_RSA_DECRYPT Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_RSA_DECRYPT;\n/* Table 2:164 - Definition of TPMT_RSA_DECRYPT Structure  */\ntypedef struct {\n    TPMI_ALG_RSA_DECRYPT     scheme;\n    TPMU_ASYM_SCHEME         details;\n} TPMT_RSA_DECRYPT;\n/* Table 2:165 - Definition of TPM2B_PUBLIC_KEY_RSA Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[MAX_RSA_KEY_BYTES];\n    }            t;\n    TPM2B        b;\n} TPM2B_PUBLIC_KEY_RSA;\n/* Table 2:166 - Definition of TPMI_RSA_KEY_BITS Type  */\ntypedef  TPM_KEY_BITS       TPMI_RSA_KEY_BITS;\n/* Table 2:167 - Definition of TPM2B_PRIVATE_KEY_RSA Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[RSA_PRIVATE_SIZE];\n    }            t;\n    TPM2B        b;\n} TPM2B_PRIVATE_KEY_RSA;\n/* Table 2:168 - Definition of TPM2B_ECC_PARAMETER Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[MAX_ECC_KEY_BYTES];\n    }            t;\n    TPM2B        b;\n} TPM2B_ECC_PARAMETER;\n/* Table 2:169 - Definition of TPMS_ECC_POINT Structure  */\ntypedef struct {\n    TPM2B_ECC_PARAMETER     x;\n    TPM2B_ECC_PARAMETER     y;\n} TPMS_ECC_POINT;\n/* Table 2:170 - Definition of TPM2B_ECC_POINT Structure  */\ntypedef struct {\n    UINT16                  size;\n    TPMS_ECC_POINT          point;\n} TPM2B_ECC_POINT;\n/* Table 2:171 - Definition of TPMI_ALG_ECC_SCHEME Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_ECC_SCHEME;\n/* Table 2:172 - Definition of TPMI_ECC_CURVE Type  */\ntypedef  TPM_ECC_CURVE      TPMI_ECC_CURVE;\n/* Table 2:173 - Definition of TPMT_ECC_SCHEME Structure  */\ntypedef struct {\n    TPMI_ALG_ECC_SCHEME     scheme;\n    TPMU_ASYM_SCHEME        details;\n} TPMT_ECC_SCHEME;\n/* Table 2:174 - Definition of TPMS_ALGORITHM_DETAIL_ECC Structure  */\ntypedef struct {\n    TPM_ECC_CURVE           curveID;\n    UINT16                  keySize;\n    TPMT_KDF_SCHEME         kdf;\n    TPMT_ECC_SCHEME         sign;\n    TPM2B_ECC_PARAMETER     p;\n    TPM2B_ECC_PARAMETER     a;\n    TPM2B_ECC_PARAMETER     b;\n    TPM2B_ECC_PARAMETER     gX;\n    TPM2B_ECC_PARAMETER     gY;\n    TPM2B_ECC_PARAMETER     n;\n    TPM2B_ECC_PARAMETER     h;\n} TPMS_ALGORITHM_DETAIL_ECC;\n/* Table 2:175 - Definition of TPMS_SIGNATURE_RSA Structure  */\ntypedef struct {\n    TPMI_ALG_HASH           hash;\n    TPM2B_PUBLIC_KEY_RSA    sig;\n} TPMS_SIGNATURE_RSA;\n/* Table 2:176 - Definition of Types for Signature */\ntypedef  TPMS_SIGNATURE_RSA    TPMS_SIGNATURE_RSASSA;\ntypedef  TPMS_SIGNATURE_RSA    TPMS_SIGNATURE_RSAPSS;\n/* Table 2:177 - Definition of TPMS_SIGNATURE_ECC Structure  */\ntypedef struct {\n    TPMI_ALG_HASH           hash;\n    TPM2B_ECC_PARAMETER     signatureR;\n    TPM2B_ECC_PARAMETER     signatureS;\n} TPMS_SIGNATURE_ECC;\n/* Table 2:178 - Definition of Types for TPMS_SIGNATURE_ECC */\ntypedef  TPMS_SIGNATURE_ECC    TPMS_SIGNATURE_ECDAA;\ntypedef  TPMS_SIGNATURE_ECC    TPMS_SIGNATURE_ECDSA;\ntypedef  TPMS_SIGNATURE_ECC    TPMS_SIGNATURE_SM2;\ntypedef  TPMS_SIGNATURE_ECC    TPMS_SIGNATURE_ECSCHNORR;\n/* Table 2:179 - Definition of TPMU_SIGNATURE Union  */\ntypedef union {\n#if \tALG_ECC\n    TPMS_SIGNATURE_ECDAA        ecdaa;\n#endif   // ALG_ECC\n#if \tALG_RSA\n    TPMS_SIGNATURE_RSASSA       rsassa;\n#endif   // ALG_RSA\n#if \tALG_RSA\n    TPMS_SIGNATURE_RSAPSS       rsapss;\n#endif   // ALG_RSA\n#if \tALG_ECC\n    TPMS_SIGNATURE_ECDSA        ecdsa;\n#endif   // ALG_ECC\n#if \tALG_ECC\n    TPMS_SIGNATURE_SM2          sm2;\n#endif   // ALG_ECC\n#if \tALG_ECC\n    TPMS_SIGNATURE_ECSCHNORR    ecschnorr;\n#endif   // ALG_ECC\n#if \tALG_HMAC\n    TPMT_HA                     hmac;\n#endif   // ALG_HMAC\n    TPMS_SCHEME_HASH            any;\n} TPMU_SIGNATURE;\n/* Table 2:180 - Definition of TPMT_SIGNATURE Structure  */\ntypedef struct {\n    TPMI_ALG_SIG_SCHEME     sigAlg;\n    TPMU_SIGNATURE          signature;\n} TPMT_SIGNATURE;\n/* Table 2:181 - Definition of TPMU_ENCRYPTED_SECRET Union  */\ntypedef union {\n#if \tALG_ECC\n    BYTE                    ecc[sizeof(TPMS_ECC_POINT)];\n#endif   // ALG_ECC\n#if \tALG_RSA\n    BYTE                    rsa[MAX_RSA_KEY_BYTES];\n#endif   // ALG_RSA\n#if \tALG_SYMCIPHER\n    BYTE                    symmetric[sizeof(TPM2B_DIGEST)];\n#endif   // ALG_SYMCIPHER\n#if \tALG_KEYEDHASH\n    BYTE                    keyedHash[sizeof(TPM2B_DIGEST)];\n#endif   // ALG_KEYEDHASH\n} TPMU_ENCRYPTED_SECRET;\n/* Table 2:182 - Definition of TPM2B_ENCRYPTED_SECRET Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    secret[sizeof(TPMU_ENCRYPTED_SECRET)];\n    }            t;\n    TPM2B        b;\n} TPM2B_ENCRYPTED_SECRET;\n/* Table 2:183 - Definition of TPMI_ALG_PUBLIC Type  */\ntypedef  TPM_ALG_ID         TPMI_ALG_PUBLIC;\n/* Table 2:184 - Definition of TPMU_PUBLIC_ID Union  */\ntypedef union {\n#if \tALG_KEYEDHASH\n    TPM2B_DIGEST            keyedHash;\n#endif   // ALG_KEYEDHASH\n#if \tALG_SYMCIPHER\n    TPM2B_DIGEST            sym;\n#endif   // ALG_SYMCIPHER\n#if \tALG_RSA\n    TPM2B_PUBLIC_KEY_RSA    rsa;\n#endif   // ALG_RSA\n#if \tALG_ECC\n    TPMS_ECC_POINT          ecc;\n#endif   // ALG_ECC\n    TPMS_DERIVE             derive;\n} TPMU_PUBLIC_ID;\n/* Table 2:185 - Definition of TPMS_KEYEDHASH_PARMS Structure  */\ntypedef struct {\n    TPMT_KEYEDHASH_SCHEME     scheme;\n} TPMS_KEYEDHASH_PARMS;\n/* Table 2:186 - Definition of TPMS_ASYM_PARMS Structure  */\ntypedef struct {\n    TPMT_SYM_DEF_OBJECT     symmetric;\n    TPMT_ASYM_SCHEME        scheme;\n} TPMS_ASYM_PARMS;\n/* Table 2:187 - Definition of TPMS_RSA_PARMS Structure  */\ntypedef struct {\n    TPMT_SYM_DEF_OBJECT     symmetric;\n    TPMT_RSA_SCHEME         scheme;\n    TPMI_RSA_KEY_BITS       keyBits;\n    UINT32                  exponent;\n} TPMS_RSA_PARMS;\n/* Table 2:188 - Definition of TPMS_ECC_PARMS Structure  */\ntypedef struct {\n    TPMT_SYM_DEF_OBJECT     symmetric;\n    TPMT_ECC_SCHEME         scheme;\n    TPMI_ECC_CURVE          curveID;\n    TPMT_KDF_SCHEME         kdf;\n} TPMS_ECC_PARMS;\n/* Table 2:189 - Definition of TPMU_PUBLIC_PARMS Union  */\ntypedef union {\n#if \tALG_KEYEDHASH\n    TPMS_KEYEDHASH_PARMS    keyedHashDetail;\n#endif   // ALG_KEYEDHASH\n#if \tALG_SYMCIPHER\n    TPMS_SYMCIPHER_PARMS    symDetail;\n#endif   // ALG_SYMCIPHER\n#if \tALG_RSA\n    TPMS_RSA_PARMS          rsaDetail;\n#endif   // ALG_RSA\n#if \tALG_ECC\n    TPMS_ECC_PARMS          eccDetail;\n#endif   // ALG_ECC\n    TPMS_ASYM_PARMS         asymDetail;\n} TPMU_PUBLIC_PARMS;\n/* Table 2:190 - Definition of TPMT_PUBLIC_PARMS Structure  */\ntypedef struct {\n    TPMI_ALG_PUBLIC         type;\n    TPMU_PUBLIC_PARMS       parameters;\n} TPMT_PUBLIC_PARMS;\n/* Table 2:191 - Definition of TPMT_PUBLIC Structure  */\ntypedef struct {\n    TPMI_ALG_PUBLIC         type;\n    TPMI_ALG_HASH           nameAlg;\n    TPMA_OBJECT             objectAttributes;\n    TPM2B_DIGEST            authPolicy;\n    TPMU_PUBLIC_PARMS       parameters;\n    TPMU_PUBLIC_ID          unique;\n} TPMT_PUBLIC;\n/* Table 2:192 - Definition of TPM2B_PUBLIC Structure  */\ntypedef struct {\n    UINT16                  size;\n    TPMT_PUBLIC             publicArea;\n} TPM2B_PUBLIC;\n/* Table 2:193 - Definition of TPM2B_TEMPLATE Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[sizeof(TPMT_PUBLIC)];\n    }            t;\n    TPM2B        b;\n} TPM2B_TEMPLATE;\n/* Table 2:194 - Definition of TPM2B_PRIVATE_VENDOR_SPECIFIC Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[PRIVATE_VENDOR_SPECIFIC_BYTES];\n    }            t;\n    TPM2B        b;\n} TPM2B_PRIVATE_VENDOR_SPECIFIC;\n/* Table 2:195 - Definition of TPMU_SENSITIVE_COMPOSITE Union  */\ntypedef union {\n#if \tALG_RSA\n    TPM2B_PRIVATE_KEY_RSA            rsa;\n#endif   // ALG_RSA\n#if \tALG_ECC\n    TPM2B_ECC_PARAMETER              ecc;\n#endif   // ALG_ECC\n#if \tALG_KEYEDHASH\n    TPM2B_SENSITIVE_DATA             bits;\n#endif   // ALG_KEYEDHASH\n#if \tALG_SYMCIPHER\n    TPM2B_SYM_KEY                    sym;\n#endif   // ALG_SYMCIPHER\n    TPM2B_PRIVATE_VENDOR_SPECIFIC    any;\n} TPMU_SENSITIVE_COMPOSITE;\n/* Table 2:196 - Definition of TPMT_SENSITIVE Structure  */\ntypedef struct {\n    TPMI_ALG_PUBLIC             sensitiveType;\n    TPM2B_AUTH                  authValue;\n    TPM2B_DIGEST                seedValue;\n    TPMU_SENSITIVE_COMPOSITE    sensitive;\n} TPMT_SENSITIVE;\n/* Table 2:197 - Definition of TPM2B_SENSITIVE Structure  */\ntypedef struct {\n    UINT16                  size;\n    TPMT_SENSITIVE          sensitiveArea;\n} TPM2B_SENSITIVE;\n/* Table 2:198 - Definition of _PRIVATE Structure  */\ntypedef struct {\n    TPM2B_DIGEST            integrityOuter;\n    TPM2B_DIGEST            integrityInner;\n    TPM2B_SENSITIVE         sensitive;\n} _PRIVATE;\n/* Table 2:199 - Definition of TPM2B_PRIVATE Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[sizeof(_PRIVATE)];\n    }            t;\n    TPM2B        b;\n} TPM2B_PRIVATE;\n/* Table 2:203 - Definition of TPMS_ID_OBJECT Structure  */\ntypedef struct {\n    TPM2B_DIGEST            integrityHMAC;\n    TPM2B_DIGEST            encIdentity;\n} TPMS_ID_OBJECT;\n/* Table 204 - Definition of TPM2B_ID_OBJECT Structure <IN/OUT> */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    credential[sizeof(TPMS_ID_OBJECT)];\n    }            t;\n    TPM2B        b;\n} TPM2B_ID_OBJECT;\n\n#define TYPE_OF_TPM_NV_INDEX    UINT32\n#define TPM_NV_INDEX_TO_UINT32(a)    (*((UINT32 *)&(a)))\n#define UINT32_TO_TPM_NV_INDEX(a)    (*((TPM_NV_INDEX *)&(a)))\n#define TPM_NV_INDEX_TO_BYTE_ARRAY(i, a)                                           \\\n            UINT32_TO_BYTE_ARRAY((TPM_NV_INDEX_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPM_NV_INDEX(i, a)                                           \\\n            { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPM_NV_INDEX(x); }\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPM_NV_INDEX {                       // Table 2:205\n    unsigned    index                : 24;\n    unsigned    RH_NV                : 8;\n} TPM_NV_INDEX;\n// This is the initializer for a TPM_NV_INDEX structure\n#define TPM_NV_INDEX_INITIALIZER(index, rh_nv) {index, rh_nv}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:205 TPM_NV_INDEX using bit masking\ntypedef UINT32                      TPM_NV_INDEX;\n#define TPM_NV_INDEX_index_SHIFT    0\n#define TPM_NV_INDEX_index          ((TPM_NV_INDEX)0xffffff << 0)\n#define TPM_NV_INDEX_RH_NV_SHIFT    24\n#define TPM_NV_INDEX_RH_NV          ((TPM_NV_INDEX)0xff << 24)\n// This is the initializer for a TPM_NV_INDEX bit array.\n#define TPM_NV_INDEX_INITIALIZER(index, rh_nv)\t\t\t\t\\\n    (TPM_NV_INDEX)(\t\t\t\t\t\t\t\\\n\t\t   (index << 0) + (rh_nv << 24))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n// Table 2:206 - Definition of TPM_NT Constants\ntypedef UINT32              TPM_NT;\n#define TYPE_OF_TPM_NT      UINT32\n#define TPM_NT_ORDINARY     (TPM_NT)(0x0)\n#define TPM_NT_COUNTER      (TPM_NT)(0x1)\n#define TPM_NT_BITS         (TPM_NT)(0x2)\n#define TPM_NT_EXTEND       (TPM_NT)(0x4)\n#define TPM_NT_PIN_FAIL     (TPM_NT)(0x8)\n#define TPM_NT_PIN_PASS     (TPM_NT)(0x9)\n// Table 2:207\ntypedef struct {\n    UINT32                  pinCount;\n    UINT32                  pinLimit;\n} TPMS_NV_PIN_COUNTER_PARAMETERS;\n\n#define TYPE_OF_TPMA_NV     UINT32\n#define TPMA_NV_TO_UINT32(a)     (*((UINT32 *)&(a)))\n#define UINT32_TO_TPMA_NV(a)     (*((TPMA_NV *)&(a)))\n#define TPMA_NV_TO_BYTE_ARRAY(i, a)                                                \\\n            UINT32_TO_BYTE_ARRAY((TPMA_NV_TO_UINT32(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_NV(i, a)                                                \\\n            { UINT32 x = BYTE_ARRAY_TO_UINT32(a); i = UINT32_TO_TPMA_NV(x); }\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct TPMA_NV {                            // Table 2:208\n    unsigned    PPWRITE              : 1;\n    unsigned    OWNERWRITE           : 1;\n    unsigned    AUTHWRITE            : 1;\n    unsigned    POLICYWRITE          : 1;\n    unsigned    TPM_NT               : 4;\n    unsigned    Reserved_bits_at_8   : 2;\n    unsigned    POLICY_DELETE        : 1;\n    unsigned    WRITELOCKED          : 1;\n    unsigned    WRITEALL             : 1;\n    unsigned    WRITEDEFINE          : 1;\n    unsigned    WRITE_STCLEAR        : 1;\n    unsigned    GLOBALLOCK           : 1;\n    unsigned    PPREAD               : 1;\n    unsigned    OWNERREAD            : 1;\n    unsigned    AUTHREAD             : 1;\n    unsigned    POLICYREAD           : 1;\n    unsigned    Reserved_bits_at_20  : 5;\n    unsigned    NO_DA                : 1;\n    unsigned    ORDERLY              : 1;\n    unsigned    CLEAR_STCLEAR        : 1;\n    unsigned    READLOCKED           : 1;\n    unsigned    WRITTEN              : 1;\n    unsigned    PLATFORMCREATE       : 1;\n    unsigned    READ_STCLEAR         : 1;\n} TPMA_NV;\n// This is the initializer for a TPMA_NV structure\n#define TPMA_NV_INITIALIZER(\t\t\t\t\t\t\\\n\t\t\t    ppwrite,        ownerwrite,     authwrite,      policywrite, \\\n\t\t\t    tpm_nt,         bits_at_8,      policy_delete,  writelocked, \\\n\t\t\t    writeall,       writedefine,    write_stclear,  globallock, \\\n\t\t\t    ppread,         ownerread,      authread,       policyread, \\\n\t\t\t    bits_at_20,     no_da,          orderly,        clear_stclear, \\\n\t\t\t    readlocked,     written,        platformcreate, read_stclear) \\\n    {ppwrite,        ownerwrite,     authwrite,      policywrite,\t\\\n\t    tpm_nt,         bits_at_8,      policy_delete,  writelocked, \\\n\t    writeall,       writedefine,    write_stclear,  globallock, \\\n\t    ppread,         ownerread,      authread,       policyread, \\\n\t    bits_at_20,     no_da,          orderly,        clear_stclear, \\\n\t    readlocked,     written,        platformcreate, read_stclear}\n#else // USE_BIT_FIELD_STRUCTURES\n// This implements Table 2:208 TPMA_NV using bit masking\ntypedef UINT32                  TPMA_NV;\n#define TYPE_OF_TPMA_NV         UINT32\n#define TPMA_NV_PPWRITE         ((TPMA_NV)1 << 0)\n#define TPMA_NV_OWNERWRITE      ((TPMA_NV)1 << 1)\n#define TPMA_NV_AUTHWRITE       ((TPMA_NV)1 << 2)\n#define TPMA_NV_POLICYWRITE     ((TPMA_NV)1 << 3)\n#define TPMA_NV_TPM_NT_SHIFT    4\n#define TPMA_NV_TPM_NT          ((TPMA_NV)0xf << 4)\n#define TPMA_NV_POLICY_DELETE   ((TPMA_NV)1 << 10)\n#define TPMA_NV_WRITELOCKED     ((TPMA_NV)1 << 11)\n#define TPMA_NV_WRITEALL        ((TPMA_NV)1 << 12)\n#define TPMA_NV_WRITEDEFINE     ((TPMA_NV)1 << 13)\n#define TPMA_NV_WRITE_STCLEAR   ((TPMA_NV)1 << 14)\n#define TPMA_NV_GLOBALLOCK      ((TPMA_NV)1 << 15)\n#define TPMA_NV_PPREAD          ((TPMA_NV)1 << 16)\n#define TPMA_NV_OWNERREAD       ((TPMA_NV)1 << 17)\n#define TPMA_NV_AUTHREAD        ((TPMA_NV)1 << 18)\n#define TPMA_NV_POLICYREAD      ((TPMA_NV)1 << 19)\n#define TPMA_NV_NO_DA           ((TPMA_NV)1 << 25)\n#define TPMA_NV_ORDERLY         ((TPMA_NV)1 << 26)\n#define TPMA_NV_CLEAR_STCLEAR   ((TPMA_NV)1 << 27)\n#define TPMA_NV_READLOCKED      ((TPMA_NV)1 << 28)\n#define TPMA_NV_WRITTEN         ((TPMA_NV)1 << 29)\n#define TPMA_NV_PLATFORMCREATE  ((TPMA_NV)1 << 30)\n#define TPMA_NV_READ_STCLEAR    ((TPMA_NV)1 << 31)\n#define TPMA_NV_RESERVED        (0x00000300 | 0x01f00000)\n// This is the initializer for a TPMA_NV bit array.\n#define TPMA_NV_INITIALIZER(\t\t\t\t\t\t\\\n\t\t\t    ppwrite,        ownerwrite,     authwrite,      policywrite, \\\n\t\t\t    tpm_nt,         bits_at_8,      policy_delete,  writelocked, \\\n\t\t\t    writeall,       writedefine,    write_stclear,  globallock, \\\n\t\t\t    ppread,         ownerread,      authread,       policyread, \\\n\t\t\t    bits_at_20,     no_da,          orderly,        clear_stclear, \\\n\t\t\t    readlocked,     written,        platformcreate, read_stclear) \\\n    (TPMA_NV)(\t\t\t\t\t\t\t\t\\\n     (ppwrite << 0)         + (ownerwrite << 1)      +\t\t\t\\\n     (authwrite << 2)       + (policywrite << 3)     +\t\t\t\\\n     (tpm_nt << 4)          + (policy_delete << 10)  +\t\t\t\\\n     (writelocked << 11)    + (writeall << 12)       +\t\t\t\\\n     (writedefine << 13)    + (write_stclear << 14)  +\t\t\t\\\n     (globallock << 15)     + (ppread << 16)         +\t\t\t\\\n     (ownerread << 17)      + (authread << 18)       +\t\t\t\\\n     (policyread << 19)     + (no_da << 25)          +\t\t\t\\\n     (orderly << 26)        + (clear_stclear << 27)  +\t\t\t\\\n     (readlocked << 28)     + (written << 29)        +\t\t\t\\\n     (platformcreate << 30) + (read_stclear << 31))\n#endif // USE_BIT_FIELD_STRUCTURES\n\n// Table \"Definition of TPMA_NV_EXP Bits\" (Part 2: Structures)\n#define TYPE_OF_TPMA_NV_EXP      UINT64\n#define TPMA_NV_EXP_TO_UINT64(a) (*((UINT64*)&(a)))\n#define UINT64_TO_TPMA_NV_EXP(a) (*((TPMA_NV_EXP*)&(a)))\n#define TPMA_NV_EXP_TO_BYTE_ARRAY(i, a)\t\t\t\t\t\\\n    UINT64_TO_BYTE_ARRAY((TPMA_NV_EXP_TO_UINT64(i)), (a))\n#define BYTE_ARRAY_TO_TPMA_NV_EXP(i, a)\t\t     \\\n    {\t\t\t\t\t\t\t     \\\n\tUINT64 x = BYTE_ARRAY_TO_UINT64(a);\t\t     \\\n\ti        = UINT64_TO_TPMA_NV_EXP(x);\t\t     \\\n    }\n#if USE_BIT_FIELD_STRUCTURES\ntypedef struct\n{\n    unsigned TPMA_NV_PPWRITE               : 1;\n    unsigned TPMA_NV_OWNERWRITE            : 1;\n    unsigned TPMA_NV_AUTHWRITE             : 1;\n    unsigned TPMA_NV_POLICYWRITE           : 1;\n    unsigned TPM_NT                        : 4;\n    unsigned Reserved_bits_at_8            : 2;\n    unsigned TPMA_NV_POLICY_DELETE         : 1;\n    unsigned TPMA_NV_WRITELOCKED           : 1;\n    unsigned TPMA_NV_WRITEALL              : 1;\n    unsigned TPMA_NV_WRITEDEFINE           : 1;\n    unsigned TPMA_NV_WRITE_STCLEAR         : 1;\n    unsigned TPMA_NV_GLOBALLOCK            : 1;\n    unsigned TPMA_NV_PPREAD                : 1;\n    unsigned TPMA_NV_OWNERREAD             : 1;\n    unsigned TPMA_NV_AUTHREAD              : 1;\n    unsigned TPMA_NV_POLICYREAD            : 1;\n    unsigned Reserved_bits_at_20           : 5;\n    unsigned TPMA_NV_NO_DA                 : 1;\n    unsigned TPMA_NV_ORDERLY               : 1;\n    unsigned TPMA_NV_CLEAR_STCLEAR         : 1;\n    unsigned TPMA_NV_READLOCKED            : 1;\n    unsigned TPMA_NV_WRITTEN               : 1;\n    unsigned TPMA_NV_PLATFORMCREATE        : 1;\n    unsigned TPMA_NV_READ_STCLEAR          : 1;\n    unsigned TPMA_EXTERNAL_NV_ENCRYPTION   : 1;\n    unsigned TPMA_EXTERNAL_NV_INTEGRITY    : 1;\n    unsigned TPMA_EXTERNAL_NV_ANTIROLLBACK : 1;\n    unsigned Reserved_bits_at_35           : 29;\n} TPMA_NV_EXP;\n\n// Initializer for the bit-field structure\n#  define TPMA_NV_EXP_INITIALIZER(tpma_nv_ppwrite,\t\t\t\\\n\t\t\t\t  tpma_nv_ownerwrite,\t\t\t\\\n\t\t\t\t  tpma_nv_authwrite,\t\t\t\\\n\t\t\t\t  tpma_nv_policywrite,\t\t\t\\\n\t\t\t\t  tpm_nt,\t\t\t\t\\\n\t\t\t\t  bits_at_8,\t\t\t\t\\\n\t\t\t\t  tpma_nv_policy_delete,\t\t\\\n\t\t\t\t  tpma_nv_writelocked,\t\t\t\\\n\t\t\t\t  tpma_nv_writeall,\t\t\t\\\n\t\t\t\t  tpma_nv_writedefine,\t\t\t\\\n\t\t\t\t  tpma_nv_write_stclear,\t\t\\\n\t\t\t\t  tpma_nv_globallock,\t\t\t\\\n\t\t\t\t  tpma_nv_ppread,\t\t\t\\\n\t\t\t\t  tpma_nv_ownerread,\t\t\t\\\n\t\t\t\t  tpma_nv_authread,\t\t\t\\\n\t\t\t\t  tpma_nv_policyread,\t\t\t\\\n\t\t\t\t  bits_at_20,\t\t\t\t\\\n\t\t\t\t  tpma_nv_no_da,\t\t\t\\\n\t\t\t\t  tpma_nv_orderly,\t\t\t\\\n\t\t\t\t  tpma_nv_clear_stclear,\t\t\\\n\t\t\t\t  tpma_nv_readlocked,\t\t\t\\\n\t\t\t\t  tpma_nv_written,\t\t\t\\\n\t\t\t\t  tpma_nv_platformcreate,\t\t\\\n\t\t\t\t  tpma_nv_read_stclear,\t\t\t\\\n\t\t\t\t  tpma_external_nv_encryption,\t\t\\\n\t\t\t\t  tpma_external_nv_integrity,\t\t\\\n\t\t\t\t  tpma_external_nv_antirollback,\t\\\n\t\t\t\t  bits_at_35)\t\t\t\t\\\n    {\t\t\t\t\t\t\t\t\t\\\n\ttpma_nv_ppwrite, tpma_nv_ownerwrite, tpma_nv_authwrite,\t\t\\\n\t    tpma_nv_policywrite, tpm_nt, bits_at_8, tpma_nv_policy_delete, \\\n\t    tpma_nv_writelocked, tpma_nv_writeall, tpma_nv_writedefine, \\\n\t    tpma_nv_write_stclear, tpma_nv_globallock, tpma_nv_ppread,\t\\\n\t    tpma_nv_ownerread, tpma_nv_authread, tpma_nv_policyread, bits_at_20, \\\n\t    tpma_nv_no_da, tpma_nv_orderly, tpma_nv_clear_stclear,\t\\\n\t    tpma_nv_readlocked, tpma_nv_written, tpma_nv_platformcreate, \\\n\t    tpma_nv_read_stclear, tpma_external_nv_encryption,\t\t\\\n\t    tpma_external_nv_integrity, tpma_external_nv_antirollback, bits_at_35 \\\n\t    }\n#else  // USE_BIT_FIELD_STRUCTURES\n\n// This implements Table \"Definition of TPMA_NV_EXP Bits\" (Part 2: Structures) using bit masking\ntypedef UINT64 TPMA_NV_EXP;\n#  define TPMA_NV_EXP_TPMA_NV_PPWRITE               (TPMA_NV_EXP)(1 << 0)\n#  define TPMA_NV_EXP_TPMA_NV_OWNERWRITE            (TPMA_NV_EXP)(1 << 1)\n#  define TPMA_NV_EXP_TPMA_NV_AUTHWRITE             (TPMA_NV_EXP)(1 << 2)\n#  define TPMA_NV_EXP_TPMA_NV_POLICYWRITE           (TPMA_NV_EXP)(1 << 3)\n#  define TPMA_NV_EXP_TPM_NT                        (TPMA_NV_EXP)(0xF << 4)\n#  define TPMA_NV_EXP_TPM_NT_SHIFT                  4\n#  define TPMA_NV_EXP_TPMA_NV_POLICY_DELETE         (TPMA_NV_EXP)(1 << 10)\n#  define TPMA_NV_EXP_TPMA_NV_WRITELOCKED           (TPMA_NV_EXP)(1 << 11)\n#  define TPMA_NV_EXP_TPMA_NV_WRITEALL              (TPMA_NV_EXP)(1 << 12)\n#  define TPMA_NV_EXP_TPMA_NV_WRITEDEFINE           (TPMA_NV_EXP)(1 << 13)\n#  define TPMA_NV_EXP_TPMA_NV_WRITE_STCLEAR         (TPMA_NV_EXP)(1 << 14)\n#  define TPMA_NV_EXP_TPMA_NV_GLOBALLOCK            (TPMA_NV_EXP)(1 << 15)\n#  define TPMA_NV_EXP_TPMA_NV_PPREAD                (TPMA_NV_EXP)(1 << 16)\n#  define TPMA_NV_EXP_TPMA_NV_OWNERREAD             (TPMA_NV_EXP)(1 << 17)\n#  define TPMA_NV_EXP_TPMA_NV_AUTHREAD              (TPMA_NV_EXP)(1 << 18)\n#  define TPMA_NV_EXP_TPMA_NV_POLICYREAD            (TPMA_NV_EXP)(1 << 19)\n#  define TPMA_NV_EXP_TPMA_NV_NO_DA                 (TPMA_NV_EXP)(1 << 25)\n#  define TPMA_NV_EXP_TPMA_NV_ORDERLY               (TPMA_NV_EXP)(1 << 26)\n#  define TPMA_NV_EXP_TPMA_NV_CLEAR_STCLEAR         (TPMA_NV_EXP)(1 << 27)\n#  define TPMA_NV_EXP_TPMA_NV_READLOCKED            (TPMA_NV_EXP)(1 << 28)\n#  define TPMA_NV_EXP_TPMA_NV_WRITTEN               (TPMA_NV_EXP)(1 << 29)\n#  define TPMA_NV_EXP_TPMA_NV_PLATFORMCREATE        (TPMA_NV_EXP)(1 << 30)\n#  define TPMA_NV_EXP_TPMA_NV_READ_STCLEAR          (TPMA_NV_EXP)(1 << 31)\n#  define TPMA_NV_EXP_TPMA_EXTERNAL_NV_ENCRYPTION   (TPMA_NV_EXP)(1 << 32)\n#  define TPMA_NV_EXP_TPMA_EXTERNAL_NV_INTEGRITY    (TPMA_NV_EXP)(1 << 33)\n#  define TPMA_NV_EXP_TPMA_EXTERNAL_NV_ANTIROLLBACK (TPMA_NV_EXP)(1 << 34)\n#  define TPMA_NV_EXP_reserved\t\t            0xfffffff800000000L\n\n//  This is the initializer for a TPMA_NV_EXP bit array.\n#  define TPMA_NV_EXP_INITIALIZER(tpma_nv_ppwrite,\t\t\t\\\n\t\t\t\t  tpma_nv_ownerwrite,\t\t\t\\\n\t\t\t\t  tpma_nv_authwrite,\t\t\t\\\n\t\t\t\t  tpma_nv_policywrite,\t\t\t\\\n\t\t\t\t  tpm_nt,\t\t\t\t\\\n\t\t\t\t  bits_at_8,\t\t\t\t\\\n\t\t\t\t  tpma_nv_policy_delete,\t\t\\\n\t\t\t\t  tpma_nv_writelocked,\t\t\t\\\n\t\t\t\t  tpma_nv_writeall,\t\t\t\\\n\t\t\t\t  tpma_nv_writedefine,\t\t\t\\\n\t\t\t\t  tpma_nv_write_stclear,\t\t\\\n\t\t\t\t  tpma_nv_globallock,\t\t\t\\\n\t\t\t\t  tpma_nv_ppread,\t\t\t\\\n\t\t\t\t  tpma_nv_ownerread,\t\t\t\\\n\t\t\t\t  tpma_nv_authread,\t\t\t\\\n\t\t\t\t  tpma_nv_policyread,\t\t\t\\\n\t\t\t\t  bits_at_20,\t\t\t\t\\\n\t\t\t\t  tpma_nv_no_da,\t\t\t\\\n\t\t\t\t  tpma_nv_orderly,\t\t\t\\\n\t\t\t\t  tpma_nv_clear_stclear,\t\t\\\n\t\t\t\t  tpma_nv_readlocked,\t\t\t\\\n\t\t\t\t  tpma_nv_written,\t\t\t\\\n\t\t\t\t  tpma_nv_platformcreate,\t\t\\\n\t\t\t\t  tpma_nv_read_stclear,\t\t\t\\\n\t\t\t\t  tpma_external_nv_encryption,\t\t\\\n\t\t\t\t  tpma_external_nv_integrity,\t\t\\\n\t\t\t\t  tpma_external_nv_antirollback,\t\\\n\t\t\t\t  bits_at_35)\t\t\t\t\\\n    (TPMA_NV_EXP)((tpma_nv_ppwrite << 0) + (tpma_nv_ownerwrite << 1)\t\\\n\t\t  + (tpma_nv_authwrite << 2) + (tpma_nv_policywrite << 3) \\\n\t\t  + (tpm_nt << 4) + (tpma_nv_policy_delete << 10)\t\\\n\t\t  + (tpma_nv_writelocked << 11) + (tpma_nv_writeall << 12) \\\n\t\t  + (tpma_nv_writedefine << 13) + (tpma_nv_write_stclear << 14) \\\n\t\t  + (tpma_nv_globallock << 15) + (tpma_nv_ppread << 16) \\\n\t\t  + (tpma_nv_ownerread << 17) + (tpma_nv_authread << 18) \\\n\t\t  + (tpma_nv_policyread << 19) + (tpma_nv_no_da << 25)\t\\\n\t\t  + (tpma_nv_orderly << 26) + (tpma_nv_clear_stclear << 27) \\\n\t\t  + (tpma_nv_readlocked << 28) + (tpma_nv_written << 29) \\\n\t\t  + (tpma_nv_platformcreate << 30) + (tpma_nv_read_stclear << 31) \\\n\t\t  + (tpma_external_nv_encryption << 32)\t\t\t\\\n\t\t  + (tpma_external_nv_integrity << 33)\t\t\t\\\n\t\t  + (tpma_external_nv_antirollback << 34))\n\n#endif  // USE_BIT_FIELD_STRUCTURES\n\n/* Table 2:209 - Definition of TPMS_NV_PUBLIC Structure  */\ntypedef struct {\n    TPMI_RH_NV_INDEX        nvIndex;\n    TPMI_ALG_HASH           nameAlg;\n    TPMA_NV                 attributes;\n    TPM2B_DIGEST            authPolicy;\n    UINT16                  dataSize;\n} TPMS_NV_PUBLIC;\n/* Table 2:207 - Definition of TPM2B_NV_PUBLIC Structure  */\ntypedef struct {\n    UINT16                  size;\n    TPMS_NV_PUBLIC          nvPublic;\n} TPM2B_NV_PUBLIC;\ntypedef struct\n{\n    TPMI_RH_NV_EXP_INDEX nvIndex;\n    TPMI_ALG_HASH        nameAlg;\n    TPMA_NV_EXP          attributes;\n    TPM2B_DIGEST         authPolicy;\n    UINT16               dataSize;\n} TPMS_NV_PUBLIC_EXP_ATTR;\ntypedef union\n{\n    TPMS_NV_PUBLIC          nvIndex;\n    TPMS_NV_PUBLIC_EXP_ATTR externalNV;\n    TPMS_NV_PUBLIC          permanentNV;\n} TPMU_NV_PUBLIC_2;\ntypedef struct\n{\n    TPM_HT           handleType;\n    TPMU_NV_PUBLIC_2 nvPublic2;\n} TPMT_NV_PUBLIC_2;\ntypedef struct\n{\n    UINT16           size;\n    TPMT_NV_PUBLIC_2 nvPublic2;\n} TPM2B_NV_PUBLIC_2;\n/* Table 2:208 - Definition of TPM2B_CONTEXT_SENSITIVE Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[MAX_CONTEXT_SIZE];\n    }            t;\n    TPM2B        b;\n} TPM2B_CONTEXT_SENSITIVE;\n/* Table 2:209 - Definition of TPMS_CONTEXT_DATA Structure  */\ntypedef struct {\n    TPM2B_DIGEST               integrity;\n    TPM2B_CONTEXT_SENSITIVE    encrypted;\n} TPMS_CONTEXT_DATA;\n/* Table 2:210 - Definition of TPM2B_CONTEXT_DATA Structure  */\ntypedef union {\n    struct {\n\tUINT16                  size;\n\tBYTE                    buffer[sizeof(TPMS_CONTEXT_DATA)];\n    }            t;\n    TPM2B        b;\n} TPM2B_CONTEXT_DATA;\n/* Table 2:211 - Definition of TPMS_CONTEXT Structure  */\ntypedef struct {\n    UINT64                  sequence;\n    TPMI_DH_SAVED           savedHandle;\n    TPMI_RH_HIERARCHY       hierarchy;\n    TPM2B_CONTEXT_DATA      contextBlob;\n} TPMS_CONTEXT;\n/* Table 2:213 - Definition of TPMS_CREATION_DATA Structure  */\ntypedef struct {\n    TPML_PCR_SELECTION      pcrSelect;\n    TPM2B_DIGEST            pcrDigest;\n    TPMA_LOCALITY           locality;\n    TPM_ALG_ID              parentNameAlg;\n    TPM2B_NAME              parentName;\n    TPM2B_NAME              parentQualifiedName;\n    TPM2B_DATA              outsideInfo;\n} TPMS_CREATION_DATA;\n/* Table 2:214 - Definition of TPM2B_CREATION_DATA Structure  */\ntypedef struct {\n    UINT16                  size;\n    TPMS_CREATION_DATA      creationData;\n} TPM2B_CREATION_DATA;                              /* Structure */\n\n// Table 2:220 - Definition of TPM_AT Constants\ntypedef UINT32              TPM_AT;\n#define TYPE_OF_TPM_AT      UINT32\n#define TPM_AT_ANY          (TPM_AT)(0x00000000)\n#define TPM_AT_ERROR        (TPM_AT)(0x00000001)\n#define TPM_AT_PV1          (TPM_AT)(0x00000002)\n#define TPM_AT_VEND         (TPM_AT)(0x80000000)\n\n// Table 2:221 - Definition of TPM_AE Constants\ntypedef UINT32              TPM_AE;\n#define TYPE_OF_TPM_AE      UINT32\n#define TPM_AE_NONE         (TPM_AE)(0x00000000)\n\ntypedef struct {                                    // Table 2:222\n    TPM_AT                  tag;\n    UINT32                  data;\n} TPMS_AC_OUTPUT;\n\n/* Table 2:218 - Definition of TPML_AC_CAPABILITIES Structure  */\ntypedef struct {\n    UINT32                  count;\n    TPMS_AC_OUTPUT          acCapabilities[MAX_AC_CAPABILITIES];\n} TPML_AC_CAPABILITIES;\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Unmarshal_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Unmarshal Prototypes\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 136 */\n\n#ifndef UNMARSHAL_FP_H\n#define UNMARSHAL_FP_H\n\n#include \"Tpm.h\"\n#include \"TpmTypes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n    LIB_EXPORT TPM_RC\n    UINT8_Unmarshal(UINT8 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    INT8_Unmarshal(INT8 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    UINT16_Unmarshal(UINT16 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    UINT32_Unmarshal(UINT32 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    UINT64_Unmarshal(UINT64 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    Array_Unmarshal(BYTE *targetBuffer, UINT16 targetSize, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_Unmarshal(TPM2B *target, UINT16 targetSize, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_KEY_BITS_Unmarshal(TPM_KEY_BITS *target, BYTE **buffer, INT32 *size);\n#if 0\n    LIB_EXPORT TPM_RC\n    TPM_GENERATED_Unmarshal(TPM_GENERATED *target, BYTE **buffer, INT32 *size);\n#endif\n    LIB_EXPORT TPM_RC\n    TPM_ALG_ID_Unmarshal(TPM_ALG_ID *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_ECC_CURVE_Unmarshal(TPM_ECC_CURVE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_CC_Unmarshal(TPM_RC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_CLOCK_ADJUST_Unmarshal(TPM_CLOCK_ADJUST *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_EO_Unmarshal(TPM_EO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_ST_Unmarshal(TPM_ST *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_SU_Unmarshal(TPM_SU *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_SE_Unmarshal(TPM_SE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_CAP_Unmarshal(TPM_CAP *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_PT_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_PT_PCR_Unmarshal(TPM_PT_PCR *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_HANDLE_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMA_ALGORITHM_Unmarshal(TPMA_ALGORITHM *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMA_OBJECT_Unmarshal(TPMA_OBJECT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMA_SESSION_Unmarshal(TPMA_SESSION *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMA_LOCALITY_Unmarshal(TPMA_LOCALITY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMA_CC_Unmarshal(TPMA_CC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_YES_NO_Unmarshal(TPMI_YES_NO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_DH_OBJECT_Unmarshal(TPMI_DH_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_DH_PARENT_Unmarshal(TPMI_DH_PARENT *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_DH_PERSISTENT_Unmarshal(TPMI_DH_PERSISTENT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_DH_ENTITY_Unmarshal(TPMI_DH_ENTITY *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_DH_PCR_Unmarshal(TPMI_DH_PCR *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_SH_AUTH_SESSION_Unmarshal(TPMI_SH_AUTH_SESSION *target, BYTE **buffer, INT32 *size, BOOL allowPwd);\n    LIB_EXPORT TPM_RC\n    TPMI_SH_HMAC_Unmarshal(TPMI_SH_HMAC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_SH_POLICY_Unmarshal(TPMI_SH_POLICY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_DH_CONTEXT_Unmarshal(TPMI_DH_CONTEXT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_DH_SAVED_Unmarshal(TPMI_DH_SAVED *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_HIERARCHY_Unmarshal(TPMI_RH_HIERARCHY *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_ENABLES_Unmarshal(TPMI_RH_ENABLES *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_HIERARCHY_AUTH_Unmarshal(TPMI_RH_HIERARCHY_AUTH *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_HIERARCHY_POLICY_Unmarshal(TPMI_RH_HIERARCHY_POLICY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_PLATFORM_Unmarshal(TPMI_RH_PLATFORM *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_ENDORSEMENT_Unmarshal(TPMI_RH_ENDORSEMENT *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_PROVISION_Unmarshal(TPMI_RH_PROVISION *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_CLEAR_Unmarshal(TPMI_RH_CLEAR *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_NV_AUTH_Unmarshal(TPMI_RH_NV_AUTH *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_LOCKOUT_Unmarshal(TPMI_RH_LOCKOUT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_NV_DEFINED_INDEX_Unmarshal(TPMI_RH_NV_DEFINED_INDEX *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_NV_LEGACY_INDEX_Unmarshal(TPMI_RH_NV_LEGACY_INDEX *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_NV_EXP_INDEX_Unmarshal(TPMI_RH_NV_EXP_INDEX *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_EXP_INDEX *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_AC_Unmarshal(TPMI_RH_AC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RH_ACT_Unmarshal(TPMI_RH_ACT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_HASH_Unmarshal(TPMI_ALG_HASH *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_SYM_Unmarshal(TPMI_ALG_SYM *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_SYM_OBJECT_Unmarshal(TPMI_ALG_SYM_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_SYM_MODE_Unmarshal(TPMI_ALG_SYM_MODE *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_KDF_Unmarshal(TPMI_ALG_KDF *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_SIG_SCHEME_Unmarshal(TPMI_ALG_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ECC_KEY_EXCHANGE_Unmarshal(TPMI_ECC_KEY_EXCHANGE *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ST_COMMAND_TAG_Unmarshal(TPMI_ST_COMMAND_TAG *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_MAC_SCHEME_Unmarshal(TPMI_ALG_MAC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_CIPHER_MODE_Unmarshal(TPMI_ALG_CIPHER_MODE*target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMS_EMPTY_Unmarshal(TPMS_EMPTY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_HA_Unmarshal(TPMU_HA *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMT_HA_Unmarshal(TPMT_HA *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPM2B_DIGEST_Unmarshal(TPM2B_DIGEST *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_DATA_Unmarshal(TPM2B_DATA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_NONCE_Unmarshal(TPM2B_NONCE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_AUTH_Unmarshal(TPM2B_AUTH *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_EVENT_Unmarshal(TPM2B_EVENT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_MAX_BUFFER_Unmarshal(TPM2B_MAX_BUFFER *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_MAX_NV_BUFFER_Unmarshal(TPM2B_MAX_NV_BUFFER *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_TIMEOUT_Unmarshal(TPM2B_TIMEOUT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_IV_Unmarshal(TPM2B_IV *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_NAME_Unmarshal(TPM2B_NAME *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_PCR_SELECTION_Unmarshal(TPMS_PCR_SELECTION *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMT_TK_CREATION_Unmarshal(TPMT_TK_CREATION *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMT_TK_VERIFIED_Unmarshal(TPMT_TK_VERIFIED *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMT_TK_AUTH_Unmarshal(TPMT_TK_AUTH *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMT_TK_HASHCHECK_Unmarshal(TPMT_TK_HASHCHECK *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_ALG_PROPERTY_Unmarshal(TPMS_ALG_PROPERTY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_TAGGED_PROPERTY_Unmarshal(TPMS_TAGGED_PROPERTY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_TAGGED_PCR_SELECT_Unmarshal(TPMS_TAGGED_PCR_SELECT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_CC_Unmarshal(TPML_CC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_TAGGED_POLICY_Unmarshal(TPMS_TAGGED_POLICY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_CCA_Unmarshal(TPML_CCA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_ALG_Unmarshal(TPML_ALG *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_HANDLE_Unmarshal(TPML_HANDLE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_DIGEST_Unmarshal(TPML_DIGEST *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_DIGEST_VALUES_Unmarshal(TPML_DIGEST_VALUES *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_PCR_SELECTION_Unmarshal(TPML_PCR_SELECTION *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_ALG_PROPERTY_Unmarshal(TPML_ALG_PROPERTY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_TAGGED_TPM_PROPERTY_Unmarshal(TPML_TAGGED_TPM_PROPERTY  *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_TAGGED_PCR_PROPERTY_Unmarshal(TPML_TAGGED_PCR_PROPERTY  *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_ECC_CURVE_Unmarshal(TPML_ECC_CURVE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPML_TAGGED_POLICY_Unmarshal(TPML_TAGGED_POLICY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_CAPABILITIES_Unmarshal(TPMU_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMS_CLOCK_INFO_Unmarshal(TPMS_CLOCK_INFO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_TIME_INFO_Unmarshal(TPMS_TIME_INFO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_TIME_ATTEST_INFO_Unmarshal(TPMS_TIME_ATTEST_INFO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_CERTIFY_INFO_Unmarshal(TPMS_CERTIFY_INFO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_QUOTE_INFO_Unmarshal(TPMS_QUOTE_INFO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_COMMAND_AUDIT_INFO_Unmarshal(TPMS_COMMAND_AUDIT_INFO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SESSION_AUDIT_INFO_Unmarshal(TPMS_SESSION_AUDIT_INFO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_CREATION_INFO_Unmarshal(TPMS_CREATION_INFO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_NV_CERTIFY_INFO_Unmarshal(TPMS_NV_CERTIFY_INFO *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_ST_ATTEST_Unmarshal(TPMI_ST_ATTEST *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_ATTEST_Unmarshal(TPMU_ATTEST *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMS_ATTEST_Unmarshal(TPMS_ATTEST *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_ATTEST_Unmarshal(TPM2B_ATTEST *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_CAPABILITY_DATA_Unmarshal(TPMS_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_SET_CAPABILITIES_Unmarshal(TPMU_SET_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMS_SET_CAPABILITY_DATA_Unmarshal(TPMS_SET_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_SET_CAPABILITY_DATA_Unmarshal(TPM2B_SET_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_AES_KEY_BITS_Unmarshal(TPMI_AES_KEY_BITS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_CAMELLIA_KEY_BITS_Unmarshal(TPMI_CAMELLIA_KEY_BITS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_SYM_KEY_BITS_Unmarshal(TPMU_SYM_KEY_BITS *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMU_SYM_MODE_Unmarshal(TPMU_SYM_MODE *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMT_SYM_DEF_Unmarshal(TPMT_SYM_DEF *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMT_SYM_DEF_OBJECT_Unmarshal(TPMT_SYM_DEF_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPM2B_SYM_KEY_Unmarshal(TPM2B_SYM_KEY *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SYMCIPHER_PARMS_Unmarshal(TPMS_SYMCIPHER_PARMS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_LABEL_Unmarshal(TPM2B_LABEL *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_DERIVE_Unmarshal(TPMS_DERIVE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_SENSITIVE_DATA_Unmarshal(TPM2B_SENSITIVE_DATA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SENSITIVE_CREATE_Unmarshal(TPMS_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_SENSITIVE_CREATE_Unmarshal(TPM2B_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SCHEME_HASH_Unmarshal(TPMS_SCHEME_HASH *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SCHEME_ECDAA_Unmarshal(TPMS_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size) ;\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_KEYEDHASH_SCHEME_Unmarshal(TPMI_ALG_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMS_SCHEME_HMAC_Unmarshal(TPMS_SCHEME_HMAC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SCHEME_XOR_Unmarshal(TPMS_SCHEME_XOR *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_SCHEME_KEYEDHASH_Unmarshal(TPMU_SCHEME_KEYEDHASH *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMT_KEYEDHASH_SCHEME_Unmarshal(TPMT_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMS_SIG_SCHEME_ECDAA_Unmarshal(TPMS_SIG_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIG_SCHEME_ECDSA_Unmarshal(TPMS_SIG_SCHEME_ECDSA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIG_SCHEME_ECSCHNORR_Unmarshal(TPMS_SIG_SCHEME_ECSCHNORR *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIG_SCHEME_RSAPSS_Unmarshal(TPMS_SIG_SCHEME_RSAPSS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIG_SCHEME_RSASSA_Unmarshal(TPMS_SIG_SCHEME_RSASSA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIG_SCHEME_SM2_Unmarshal(TPMS_SIG_SCHEME_SM2 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_SIG_SCHEME_Unmarshal(TPMU_SIG_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMT_SIG_SCHEME_Unmarshal(TPMT_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMS_ENC_SCHEME_OAEP_Unmarshal(TPMS_ENC_SCHEME_OAEP *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_ENC_SCHEME_RSAES_Unmarshal(TPMS_ENC_SCHEME_RSAES *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_KEY_SCHEME_ECDH_Unmarshal(TPMS_KEY_SCHEME_ECDH *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_KEY_SCHEME_ECMQV_Unmarshal(TPMS_KEY_SCHEME_ECMQV *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_KDF_SCHEME_KDF1_SP800_108_Unmarshal(TPMS_KDF_SCHEME_KDF1_SP800_108 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_KDF_SCHEME_KDF1_SP800_56A_Unmarshal(TPMS_KDF_SCHEME_KDF1_SP800_56A *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_KDF_SCHEME_KDF2_Unmarshal(TPMS_KDF_SCHEME_KDF2 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_KDF_SCHEME_MGF1_Unmarshal(TPMS_KDF_SCHEME_MGF1 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_KDF_SCHEME_Unmarshal(TPMU_KDF_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMT_KDF_SCHEME_Unmarshal(TPMT_KDF_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_ASYM_SCHEME_Unmarshal(TPMI_ALG_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMU_ASYM_SCHEME_Unmarshal(TPMU_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_RSA_SCHEME_Unmarshal(TPMI_ALG_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMT_RSA_SCHEME_Unmarshal(TPMT_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_RSA_DECRYPT_Unmarshal(TPMI_ALG_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMT_RSA_DECRYPT_Unmarshal(TPMT_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPM2B_PUBLIC_KEY_RSA_Unmarshal(TPM2B_PUBLIC_KEY_RSA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_RSA_KEY_BITS_Unmarshal(TPMI_RSA_KEY_BITS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_PRIVATE_KEY_RSA_Unmarshal(TPM2B_PRIVATE_KEY_RSA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_ECC_PARAMETER_Unmarshal(TPM2B_ECC_PARAMETER *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_ECC_POINT_Unmarshal(TPMS_ECC_POINT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_ECC_POINT_Unmarshal(TPM2B_ECC_POINT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_ECC_SCHEME_Unmarshal(TPMI_ALG_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMI_ECC_CURVE_Unmarshal(TPMI_ECC_CURVE *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMT_ECC_SCHEME_Unmarshal(TPMT_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPMS_SIGNATURE_RSA_Unmarshal(TPMS_SIGNATURE_RSA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIGNATURE_RSASSA_Unmarshal(TPMS_SIGNATURE_RSASSA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIGNATURE_RSAPSS_Unmarshal(TPMS_SIGNATURE_RSAPSS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIGNATURE_ECC_Unmarshal(TPMS_SIGNATURE_ECC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIGNATURE_ECDSA_Unmarshal(TPMS_SIGNATURE_ECDSA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIGNATURE_ECDAA_Unmarshal(TPMS_SIGNATURE_ECDAA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIGNATURE_SM2_Unmarshal(TPMS_SIGNATURE_SM2 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_SIGNATURE_ECSCHNORR_Unmarshal(TPMS_SIGNATURE_ECSCHNORR *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_SIGNATURE_Unmarshal(TPMU_SIGNATURE *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMT_SIGNATURE_Unmarshal(TPMT_SIGNATURE *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPM2B_ENCRYPTED_SECRET_Unmarshal(TPM2B_ENCRYPTED_SECRET *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMI_ALG_PUBLIC_Unmarshal(TPMI_ALG_PUBLIC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_PUBLIC_ID_Unmarshal(TPMU_PUBLIC_ID *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMS_KEYEDHASH_PARMS_Unmarshal(TPMS_KEYEDHASH_PARMS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_RSA_PARMS_Unmarshal(TPMS_RSA_PARMS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_ECC_PARMS_Unmarshal(TPMS_ECC_PARMS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_PUBLIC_PARMS_Unmarshal(TPMU_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMT_PUBLIC_PARMS_Unmarshal(TPMT_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMT_PUBLIC_Unmarshal(TPMT_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPM2B_PUBLIC_Unmarshal(TPM2B_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull);\n    LIB_EXPORT TPM_RC\n    TPM2B_TEMPLATE_Unmarshal(TPM2B_TEMPLATE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_SENSITIVE_COMPOSITE_Unmarshal(TPMU_SENSITIVE_COMPOSITE *target, BYTE **buffer, INT32 *size, UINT32 selector);\n    LIB_EXPORT TPM_RC\n    TPMT_SENSITIVE_Unmarshal(TPMT_SENSITIVE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_SENSITIVE_Unmarshal(TPM2B_SENSITIVE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_PRIVATE_Unmarshal(TPM2B_PRIVATE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_ID_OBJECT_Unmarshal(TPM2B_ID_OBJECT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMA_NV_Unmarshal(TPMA_NV *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_NV_PUBLIC_Unmarshal(TPMS_NV_PUBLIC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMA_NV_EXP_Unmarshal(TPMA_NV_EXP *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_NV_PUBLIC_EXP_ATTR_Unmarshal(TPMS_NV_PUBLIC_EXP_ATTR *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMU_NV_PUBLIC_2_Unmarshal( TPMU_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size, UINT8 selector);\n    LIB_EXPORT TPM_RC\n    TPMT_NV_PUBLIC_2_Unmarshal(TPMT_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_NV_PUBLIC_Unmarshal(TPM2B_NV_PUBLIC *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_NV_PUBLIC_2_Unmarshal(TPM2B_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_CONTEXT_SENSITIVE_Unmarshal(TPM2B_CONTEXT_SENSITIVE *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM2B_CONTEXT_DATA_Unmarshal(TPM2B_CONTEXT_DATA *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPMS_CONTEXT_Unmarshal(TPMS_CONTEXT *target, BYTE **buffer, INT32 *size);\n    LIB_EXPORT TPM_RC\n    TPM_AT_Unmarshal(TPM_AT *target, BYTE **buffer, INT32 *size);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Unseal_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Unseal_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef UNSEAL_FP_H\n#define UNSEAL_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\titemHandle;\n} Unseal_In;\n\n#define RC_Unseal_itemHandle \t(TPM_RC_H + TPM_RC_1)\n\ntypedef struct {\n    TPM2B_SENSITIVE_DATA\toutData;\n} Unseal_Out;\n\nTPM_RC\nTPM2_Unseal(\n\t    Unseal_In       *in,\n\t    Unseal_Out      *out\n\t    );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/VendorInfo.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \tVendor Info\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023-2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _VENDORINFO_H\n#define _VENDORINFO_H\n\n// Define the TPM specification-specific capability values.\n#define TPM_SPEC_FAMILY      (0x322E3000)\n#define TPM_SPEC_LEVEL       (00)\n#define TPM_SPEC_VERSION     (183)\n#define TPM_SPEC_YEAR        (2024)\n#define TPM_SPEC_DAY_OF_YEAR (25)\n#define MAX_VENDOR_PROPERTY  (1)\n\n// Define the platform specification-specific capability values.\n#define PLATFORM_FAMILY      (1)\t\t/* kgold changed for PC Client */\n#define PLATFORM_LEVEL       (0)\n#define PLATFORM_VERSION     (0x00000106)\n#define PLATFORM_YEAR        (0)\n#define PLATFORM_DAY_OF_YEAR (0)\n\n#endif\n\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/Vendor_TCG_Test_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t Sample Vendor Specific Command\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Vendor_TCG_Test_fp.h 1635 2020-06-12 21:48:27Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef VENDOR_TCG_TEST_FP_H\n#define VENDOR_TCG_TEST_FP_H\n\ntypedef struct {\n    TPM2B_DATA inputData;\n} Vendor_TCG_Test_In;\n\ntypedef struct {\n    TPM2B_DATA outputData;\n} Vendor_TCG_Test_Out;\n\nTPM_RC\nTPM2_Vendor_TCG_Test(\n\t\t     Vendor_TCG_Test_In        *in,            // IN: input parameter list\n\t\t     Vendor_TCG_Test_Out       *out            // OUT: output parameter list\n\t\t     );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/VerifyConfiguration.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//\n// This verifies that information expected from the consumer's TpmConfiguration is\n// set properly and consistently.\n//\n#ifndef _VERIFY_CONFIGURATION_H\n#define _VERIFY_CONFIGURATION_H\n\n// verify these defines are either YES or NO.\n#define MUST_BE_0_OR_1(x) MUST_BE(((x) == 0) || ((x) == 1))\n\n// Debug Options\nMUST_BE_0_OR_1(DEBUG);\nMUST_BE_0_OR_1(SIMULATION);\nMUST_BE_0_OR_1(DRBG_DEBUG_PRINT);\nMUST_BE_0_OR_1(CERTIFYX509_DEBUG);\nMUST_BE_0_OR_1(USE_DEBUG_RNG);\n\n// RSA Debug Options\nMUST_BE_0_OR_1(RSA_INSTRUMENT);\nMUST_BE_0_OR_1(USE_RSA_KEY_CACHE);\nMUST_BE_0_OR_1(USE_KEY_CACHE_FILE);\n\n// Test Options\nMUST_BE_0_OR_1(ALLOW_FORCE_FAILURE_MODE);\n\n// Internal checks\nMUST_BE_0_OR_1(LIBRARY_COMPATIBILITY_CHECK);\nMUST_BE_0_OR_1(COMPILER_CHECKS);\nMUST_BE_0_OR_1(RUNTIME_SIZE_CHECKS);\n\n// Compliance options\nMUST_BE_0_OR_1(FIPS_COMPLIANT);\nMUST_BE_0_OR_1(USE_SPEC_COMPLIANT_PROOFS);\nMUST_BE_0_OR_1(SKIP_PROOF_ERRORS);\n\n// Implementation alternatives - should not change external behavior\nMUST_BE_0_OR_1(TABLE_DRIVEN_DISPATCH);\nMUST_BE_0_OR_1(TABLE_DRIVEN_MARSHAL);\nMUST_BE_0_OR_1(USE_MARSHALING_DEFINES);\nMUST_BE_0_OR_1(COMPRESSED_LISTS);\nMUST_BE_0_OR_1(USE_BIT_FIELD_STRUCTURES);\nMUST_BE_0_OR_1(RSA_KEY_SIEVE);\n\n// Implementation alternatives - changes external behavior\nMUST_BE_0_OR_1(_DRBG_STATE_SAVE);\nMUST_BE_0_OR_1(USE_DA_USED);\nMUST_BE_0_OR_1(ENABLE_SELF_TESTS);\nMUST_BE_0_OR_1(CLOCK_STOPS);\nMUST_BE_0_OR_1(ACCUMULATE_SELF_HEAL_TIMER);\nMUST_BE_0_OR_1(FAIL_TRACE);\n\n// Vendor alternatives\n// Check VENDOR_PERMANENT_AUTH_ENABLED & VENDOR_PERMANENT_AUTH_HANDLE are consistent\nMUST_BE_0_OR_1(VENDOR_PERMANENT_AUTH_ENABLED);\n\n#if VENDOR_PERMANENT_AUTH_ENABLED == YES\n#  if !defined(VENDOR_PERMANENT_AUTH_HANDLE)\t\t       \\\n    || VENDOR_PERMANENT_AUTH_HANDLE < TPM_RH_AUTH_00\t\t\t\\\n    || VENDOR_PERMANENT_AUTH_HANDLE > TPM_RH_AUTH_FF\n#    error VENDOR_PERMANENT_AUTH_ENABLED requires a valid definition for VENDOR_PERMANENT_AUTH_HANDLE, see Part2\n#  endif\n#else\n#  if defined(VENDOR_PERMANENT_AUTH_HANDLE)\n#    error VENDOR_PERMANENT_AUTH_HANDLE requires VENDOR_PERMANENT_AUTH_ENABLED to be YES\n#  endif\n#endif\n\n// now check for inconsistent combinations of options\n#if USE_KEY_CACHE_FILE && !USE_RSA_KEY_CACHE\n#  error cannot use USE_KEY_CACHE_FILE if not using USE_RSA_KEY_CACHE\n#endif\n\n#if !DEBUG\n#  if USE_KEY_CACHE_FILE || USE_RSA_KEY_CACHE || DRBG_DEBUG_PRINT\t\\\n    || CERTIFYX509_DEBUG || USE_DEBUG_RNG\n#    error using insecure options not in DEBUG mode.\n#  endif\n#endif\n\n#if !SIMULATION\n#  if USE_KEY_CACHE_FILE\n#    error USE_KEY_CACHE_FILE requires SIMULATION\n#  endif\n#  if RSA_INSTRUMENT\n#    error RSA_INSTRUMENT requires SIMULATION\n#  endif\n#  if USE_DEBUG_RNG\n#    error USE_DEBUG_RNG requires SIMULATION\n#  endif\n#endif\n\n#endif  // _VERIFY_CONFIGURATION_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/VerifySignature_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: VerifySignature_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef VERIFYSIGNATURE_FP_H\n#define VERIFYSIGNATURE_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\tkeyHandle;\n    TPM2B_DIGEST\tdigest;\n    TPMT_SIGNATURE\tsignature;\n} VerifySignature_In;\n\n#define RC_VerifySignature_keyHandle \t(TPM_RC_H + TPM_RC_1)\n#define RC_VerifySignature_digest\t(TPM_RC_P + TPM_RC_1)\n#define RC_VerifySignature_signature \t(TPM_RC_P + TPM_RC_2)\n\ntypedef struct {\n    TPMT_TK_VERIFIED\tvalidation;\n} VerifySignature_Out;\n\nTPM_RC\nTPM2_VerifySignature(\n\t\t     VerifySignature_In      *in,            // IN: input parameter list\n\t\t     VerifySignature_Out     *out            // OUT: output parameter list\n\t\t     );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/X509.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tMacro and Structure Definitions for the X509 Commands and Functions.\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: X509.h 1658 2021-01-22 23:14:01Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// 10.1.16\tX509.h\n// 10.1.16.1\tIntroduction\n// This file contains the macro and structure definitions for the X509 commands and functions.\n#ifndef _X509_H_\n#define _X509_H_\n// 10.1.16.2\tIncludes\n#include \"Tpm.h\"\n#include \"TpmASN1.h\"\n// 10.1.16.3\tDefined Constants\n// 10.1.16.3.1\tX509 Application-specific types\n#define X509_SELECTION          0xA0\n#define X509_ISSUER_UNIQUE_ID   0xA1\n#define X509_SUBJECT_UNIQUE_ID  0xA2\n#define X509_EXTENSIONS         0xA3\n// These defines give the order in which values appear in the TBScertificate of an x.509\n// certificate. These values are used to index into an array of\n#define ENCODED_SIZE_REF        0\n#define VERSION_REF             (ENCODED_SIZE_REF + 1)\n#define SERIAL_NUMBER_REF       (VERSION_REF + 1)\n#define SIGNATURE_REF           (SERIAL_NUMBER_REF + 1)\n#define ISSUER_REF              (SIGNATURE_REF + 1)\n#define VALIDITY_REF            (ISSUER_REF + 1)\n#define SUBJECT_KEY_REF         (VALIDITY_REF + 1)\n#define SUBJECT_PUBLIC_KEY_REF  (SUBJECT_KEY_REF + 1)\n#define EXTENSIONS_REF          (SUBJECT_PUBLIC_KEY_REF + 1)\n#define REF_COUNT               (EXTENSIONS_REF + 1)\n\n// 10.1.16.4 Structures Used to access the fields of a TBSsignature some of which are in the\n// in_CertifyX509 structure and some of which are in the out_CertifyX509 structure.\ntypedef struct stringRef\n{\n    BYTE        *buf;\n    INT16        len;\n} stringRef;\n// This is defined to avoid bit by bit comparisons within a UINT32\ntypedef union x509KeyUsageUnion {\n    TPMA_X509_KEY_USAGE     x509;\n    UINT32                  integer;\n} x509KeyUsageUnion;\n\n// 10.1.16.5\tGlobal X509 Constants\n\n// These values are instanced by X509_spt.c and referenced by other X509-related files. This is the\n// DER-encoded value for the Key Usage OID (2.5.29.15). This is the full OID, not just the numeric\n// value\n\n#define OID_KEY_USAGE_EXTENSION_VALUE  0x06, 0x03, 0x55, 0x1D, 0x0F\nMAKE_OID(_KEY_USAGE_EXTENSION);\n\n// This is the DER-encoded value for the TCG-defined TPMA_OBJECT OID (2.23.133.10.1.1.1)\n\n#define OID_TCG_TPMA_OBJECT_VALUE       0x06, 0x07, 0x67, 0x81, 0x05, 0x0a, 0x01, \\\n\t0x01, 0x01\nMAKE_OID(_TCG_TPMA_OBJECT);\n\n#ifdef _X509_SPT_\n\n// If a bit is SET in KEY_USAGE_SIGN is also SET in keyUsage then the associated key has to have\n// sign SET.\n\nconst x509KeyUsageUnion KEY_USAGE_SIGN =\n    {TPMA_X509_KEY_USAGE_INITIALIZER(\n\t\t\t\t    /* bits_at_0        */ 0, /* decipheronly    */ 0,  /* encipheronly   */ 0,\n\t\t\t\t    /* crlsign          */ 1, /* keycertsign     */ 1,  /* keyagreement   */ 0,\n\t\t\t\t    /* dataencipherment */ 0, /* keyencipherment */ 0,  /* nonrepudiation */ 0,\n\t\t\t\t    /* digitalsignature */ 1)};\n\n// If a bit is SET in KEY_USAGE_DECRYPT is also SET in keyUsage then the associated key has to have decrypt SET.\n\nconst x509KeyUsageUnion KEY_USAGE_DECRYPT =\n    {TPMA_X509_KEY_USAGE_INITIALIZER(\n\t\t\t\t    /* bits_at_0        */ 0, /* decipheronly    */ 1,  /* encipheronly   */ 1,\n\t\t\t\t    /* crlsign          */ 0, /* keycertsign     */ 0,  /* keyagreement   */ 1,\n\t\t\t\t    /* dataencipherment */ 1, /* keyencipherment */ 1,  /* nonrepudiation */ 0,\n\t\t\t\t    /* digitalsignature */ 0)};\n#else\nextern x509KeyUsageUnion KEY_USAGE_SIGN;\nextern x509KeyUsageUnion KEY_USAGE_DECRYPT;\n#endif\n\n#endif // _X509_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/X509_ECC_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM X509 ECC\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: X509_ECC_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef X509_ECC_FP_H\n#define X509_ECC_FP_H\n\nINT16\nX509PushPoint(\n\t      ASN1MarshalContext      *ctx,\n\t      TPMS_ECC_POINT          *p\n\t      );\nINT16\nX509AddSigningAlgorithmECC(\n\t\t\t   OBJECT              *signKey,\n\t\t\t   TPMT_SIG_SCHEME     *scheme,\n\t\t\t   ASN1MarshalContext  *ctx\n\t\t\t   );\nINT16\nX509AddPublicECC(\n\t\t OBJECT                *object,\n\t\t ASN1MarshalContext    *ctx\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/X509_RSA_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM X509 RSA\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: X509_RSA_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef X509_RSA_FP_H\n#define X509_RSA_FP_H\n\nINT16\nX509AddSigningAlgorithmRSA(\n\t\t\t   OBJECT              *signKey,\n\t\t\t   TPMT_SIG_SCHEME     *scheme,\n\t\t\t   ASN1MarshalContext  *ctx\n\t\t\t   );\nINT16\nX509AddPublicRSA(\n\t\t OBJECT                  *object,\n\t\t ASN1MarshalContext    *ctx\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/X509_spt_fp.h",
    "content": "/********************************************************************************/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*\t\t\tX509 Support \t\t \t\t\t\t*/\r\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\r\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\r\n/*            $Id: X509_spt_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\r\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\r\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\r\n/*    derivative works, distribute, display and perform the Source Code and\t*/\r\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - The TCG grants to the user of the other parts of the specification \t*/\r\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\r\n/*    display, and perform the specification solely for the purpose of \t\t*/\r\n/*    developing products based on such documents.\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\r\n/*    this list of conditions and the following disclaimers.\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\r\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\r\n/*    documentation and/or other materials provided with the distribution.\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\r\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\r\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\r\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\r\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\r\n/*  information on specification licensing rights available through TCG \t*/\r\n/*  membership agreements.\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\r\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\r\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\r\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\r\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\r\n/*    liability, including liability for infringement of any proprietary \t*/\r\n/*    rights, relating to use of information in this specification and to the\t*/\r\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\r\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\r\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\r\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\r\n/*    arising in any way out of use or reliance upon this specification or any \t*/\r\n/*    information herein.\t\t\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/*  (c) Copyright IBM Corp. and others, 2019.\t\t\t\t\t*/\r\n/*\t\t\t\t\t\t\t\t\t\t*/\r\n/********************************************************************************/\r\n\r\n#ifndef X509_SPT_FP_H\r\n#define X509_SPT_FP_H\r\n\r\nBOOL\r\nX509FindExtensionByOID(\r\n\t\t       ASN1UnmarshalContext    *ctxIn,         // IN: the context to search\r\n\t\t       ASN1UnmarshalContext    *ctx,           // OUT: the extension context\r\n\t\t       const BYTE              *OID            // IN: oid to search for\r\n\t\t       );\r\nUINT32\r\nX509GetExtensionBits(\r\n\t\t     ASN1UnmarshalContext            *ctx,\r\n\t\t     UINT32                          *value\r\n\t\t     );\r\nTPM_RC\r\nX509ProcessExtensions(\r\n\t\t      OBJECT              *object,        // IN: The object with the attributes to\r\n\t\t      //      check\r\n\t\t      stringRef           *extension      // IN: The start and length of the extensions\r\n\t\t      );\r\nINT16\r\nX509AddSigningAlgorithm(\r\n\t\t\tASN1MarshalContext  *ctx,\r\n\t\t\tOBJECT              *signKey,\r\n\t\t\tTPMT_SIG_SCHEME     *scheme\r\n\t\t\t);\r\nINT16\r\nX509AddPublicKey(\r\n\t\t ASN1MarshalContext  *ctx,\r\n\t\t OBJECT              *object\r\n\t\t );\r\nINT16\r\nX509PushAlgorithmIdentifierSequence(\r\n\t\t\t\t    ASN1MarshalContext          *ctx,\r\n\t\t\t\t    const BYTE                  *OID\r\n\t\t\t\t    );\r\n#endif\r\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ZGen_2Phase_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ZGen_2Phase_fp.h 809 2016-11-16 18:31:54Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012-2015\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* rev 119 */\n\n#ifndef ZGEN_2PHASE_FP_H\n#define ZGEN_2PHASE_FP_H\n\ntypedef struct {\n    TPMI_DH_OBJECT\t\tkeyA;\n    TPM2B_ECC_POINT\t\tinQsB;\n    TPM2B_ECC_POINT\t\tinQeB;\n    TPMI_ECC_KEY_EXCHANGE\tinScheme;\n    UINT16\t\t\tcounter;\n} ZGen_2Phase_In;\n\n#define RC_ZGen_2Phase_keyA\t(TPM_RC_H + TPM_RC_1)\n#define RC_ZGen_2Phase_inQsB\t(TPM_RC_P + TPM_RC_1)\n#define RC_ZGen_2Phase_inQeB\t(TPM_RC_P + TPM_RC_2)\n#define RC_ZGen_2Phase_inScheme\t(TPM_RC_P + TPM_RC_3)\n#define RC_ZGen_2Phase_counter\t(TPM_RC_P + TPM_RC_4)\n\ntypedef struct {\n    TPM2B_ECC_POINT\toutZ1;\n    TPM2B_ECC_POINT\toutZ2;\n} ZGen_2Phase_Out;\n\nTPM_RC\nTPM2_ZGen_2Phase(\n\t\t ZGen_2Phase_In      *in,            // IN: input parameter list\n\t\t ZGen_2Phase_Out     *out            // OUT: output parameter list\n\t\t );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/_TPM_Hash_Data_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: _TPM_Hash_Data_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPM_HASH_DATA_FP_H\n#define _TPM_HASH_DATA_FP_H\n\nLIB_EXPORT void\n_TPM_Hash_Data(\n\t       uint32_t         dataSize,      // IN: size of data to be extend\n\t       unsigned char   *data           // IN: data buffer\n\t       );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/_TPM_Hash_End_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: _TPM_Hash_End_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPM_HASH_END_FP_H\n#define _TPM_HASH_END_FP_H\n\nLIB_EXPORT void\n_TPM_Hash_End(\n\t      void\n\t      );\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/_TPM_Hash_Start_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: _TPM_Hash_Start_fp.h 1521 2019-11-15 21:00:47Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPM_HASH_START_FP_H\n#define _TPM_HASH_START_FP_H\n\nLIB_EXPORT void\n_TPM_Hash_Start(\n\t\tvoid\n\t\t);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/_TPM_Init_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: _TPM_Init_fp.h 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _TPM_INIT_FP_H\n#define _TPM_INIT_FP_H\n\nLIB_EXPORT void\n_TPM_Init(\n\t  void\n\t  );\n\n\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/endian_swap.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \tSwap\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _ENDIAN_SWAP_H\n#define _ENDIAN_SWAP_H\n\n#if LITTLE_ENDIAN_TPM\n#define TO_BIG_ENDIAN_UINT16(i)     REVERSE_ENDIAN_16(i)\n#define FROM_BIG_ENDIAN_UINT16(i)   REVERSE_ENDIAN_16(i)\n#define TO_BIG_ENDIAN_UINT32(i)     REVERSE_ENDIAN_32(i)\n#define FROM_BIG_ENDIAN_UINT32(i)   REVERSE_ENDIAN_32(i)\n#define TO_BIG_ENDIAN_UINT64(i)     REVERSE_ENDIAN_64(i)\n#define FROM_BIG_ENDIAN_UINT64(i)   REVERSE_ENDIAN_64(i)\n#else\n#define TO_BIG_ENDIAN_UINT16(i)     (i)\n#define FROM_BIG_ENDIAN_UINT16(i)   (i)\n#define TO_BIG_ENDIAN_UINT32(i)     (i)\n#define FROM_BIG_ENDIAN_UINT32(i)   (i)\n#define TO_BIG_ENDIAN_UINT64(i)     (i)\n#define FROM_BIG_ENDIAN_UINT64(i)   (i)\n#endif\n#if   AUTO_ALIGN == NO\n/* The aggregation macros for machines that do not allow unaligned access or for little-endian\n   machines. Aggregate bytes into an UINT */\n#define BYTE_ARRAY_TO_UINT8(b)  (uint8_t)((b)[0])\n#define BYTE_ARRAY_TO_UINT16(b) ByteArrayToUint16((BYTE *)(b))\n#define BYTE_ARRAY_TO_UINT32(b) ByteArrayToUint32((BYTE *)(b))\n#define BYTE_ARRAY_TO_UINT64(b) ByteArrayToUint64((BYTE *)(b))\n#define UINT8_TO_BYTE_ARRAY(i, b) ((b)[0] = (uint8_t)(i))\n#define UINT16_TO_BYTE_ARRAY(i, b)  Uint16ToByteArray((i), (BYTE *)(b))\n#define UINT32_TO_BYTE_ARRAY(i, b)  Uint32ToByteArray((i), (BYTE *)(b))\n#define UINT64_TO_BYTE_ARRAY(i, b)  Uint64ToByteArray((i), (BYTE *)(b))\n#else // AUTO_ALIGN\n#if BIG_ENDIAN_TPM\n/* The big-endian macros for machines that allow unaligned memory access Aggregate a byte\n   array into a UINT */\n#define BYTE_ARRAY_TO_UINT8(b)        *((uint8_t  *)(b))\n#define BYTE_ARRAY_TO_UINT16(b)       *((uint16_t *)(b))\n#define BYTE_ARRAY_TO_UINT32(b)       *((uint32_t *)(b))\n#define BYTE_ARRAY_TO_UINT64(b)       *((uint64_t *)(b))\n/* Disaggregate a UINT into a byte array */\n#define UINT8_TO_BYTE_ARRAY(i, b) {*((uint8_t *)(b)) = (i);}\n#define UINT16_TO_BYTE_ARRAY(i, b) {*((uint16_t *)(b)) = (i);}\n#define UINT32_TO_BYTE_ARRAY(i, b) {*((uint32_t *)(b)) = (i);}\n#define UINT64_TO_BYTE_ARRAY(i, b)  {*((uint64_t *)(b)) = (i);}\n#else\n/* the little endian macros for machines that allow unaligned memory access the big-endian macros\n   for machines that allow unaligned memory access Aggregate a byte array into a UINT */\n#define BYTE_ARRAY_TO_UINT8(b)        *((uint8_t  *)(b))\n#define BYTE_ARRAY_TO_UINT16(b)       REVERSE_ENDIAN_16(*((uint16_t *)(b)))\n#define BYTE_ARRAY_TO_UINT32(b)       REVERSE_ENDIAN_32(*((uint32_t *)(b)))\n#define BYTE_ARRAY_TO_UINT64(b)       REVERSE_ENDIAN_64(*((uint64_t *)(b)))\n/* Disaggregate a UINT into a byte array */\n#define UINT8_TO_BYTE_ARRAY(i, b)   {*((uint8_t  *)(b)) = (i);}\n#define UINT16_TO_BYTE_ARRAY(i, b)  {*((uint16_t *)(b)) = REVERSE_ENDIAN_16(i);}\n#define UINT32_TO_BYTE_ARRAY(i, b)  {*((uint32_t *)(b)) = REVERSE_ENDIAN_32(i);}\n#define UINT64_TO_BYTE_ARRAY(i, b)  {*((uint64_t *)(b)) = REVERSE_ENDIAN_64(i);}\n#endif   // BIG_ENDIAN_TPM\n#endif  // AUTO_ALIGN == NO\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ftpm.h",
    "content": "#ifndef _FTPM_H_\n#define _FTPM_H_\n\n#include \"openssl/aes.h\"\n#include \"openssl/rand.h\"\n\nstruct tss_ftpm_context {\n    uintptr_t commandBuffer;\n    uint32_t written;\n    uintptr_t responseBuffer;\n    uint32_t read;\n};\n\nextern struct sbi_ecall_extension ecall_ftpm;\n\nextern unsigned char nv_key[128];\nextern unsigned char nv_iv[128];\n\nextern AES_KEY nv_enc_key, nv_dec_key;\n\nvoid uart_putc(char ch);\n\nint uart_getc(void);\n\nvoid ftpm_init(void);\n\nunsigned long sbi_ftpm_run_command(unsigned long out, unsigned long args);\n\nint ftpm_cmd_handler(struct tss_ftpm_context* cnx);\n\nvoid aes_cbc_encrypt_decrypt(AES_KEY *key, unsigned char *input, unsigned char *output,\n                             unsigned char *iv, size_t len, int encrypt);\n\nvoid* _sbrk(ptrdiff_t incr);\n\n\n\n#endif"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/intercept.h",
    "content": "//#include <sbi/sbi_console.h>\n#include <stdio.h>\n#include \"fatfs/ff.h\"\n\n#define clock_gettime intercept_clock_gettime\n#define rand    intercept_rand\n\n#define fopen intercept_fopen\n#define fread intercept_fread\n#define fwrite intercept_fwrite\n#define fclose intercept_fclose\n#define frewind intercept_frewind\n#define fsize intercept_fsize\n#define ftell intercept_ftell\n#define fflush intercept_fflush\n\n\nint intercept_clock_gettime(clockid_t __clock_id, struct timespec *__tp);\nint intercept_rand(void);\n\nFILE *intercept_fopen(const char *pathname, BYTE mode);\nsize_t intercept_fread(void *ptr, size_t size, size_t count, FILE *stream);\nsize_t intercept_fwrite(const void *ptr, size_t size, size_t count, FILE *stream);\nint intercept_fclose(FILE *stream);\nint intercept_frewind(FILE *stream);\nlong intercept_fsize(FILE *stream);\nlong intercept_ftell(FILE *stream);\nint intercept_fflush(FILE *stream);\n\n\n\n// int f_flush(FILE *stream);\n\n\n// FILE *ff_fopen(const char *filename, const char *mode);\n// size_t ff_fread(void *ptr, size_t size, size_t count, FILE *stream);\n// size_t ff_fwrite(const void *ptr, size_t size, size_t count, FILE *stream);\n// int ff_fseek(FILE *stream, long int offset, int whence);\n// int ff_fflush(FILE *stream);"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/mprv.h",
    "content": "#pragma once\n#include <sbi/sbi_types.h>\n\ntypedef struct { size_t words[8]; } mprv_block;\n\nint copy1_from_sm(uintptr_t dst, const uint8_t *src);\nint copy_word_from_sm(uintptr_t dst, const uintptr_t *src);\nint copy_block_from_sm(uintptr_t dst, const mprv_block *src);\n\nint copy1_to_sm(uint8_t *dst, uintptr_t src);\nint copy_word_to_sm(uintptr_t *dst, uintptr_t src);\nint copy_block_to_sm(mprv_block *dst, uintptr_t src);\n\n#if __riscv_xlen == 64\n# define STORE    sd\n# define LOAD     ld\n# define LOG_REGBYTES 3\n#elif __riscv_xlen == 32\n# define STORE    sw\n# define LOAD     lw\n# define LOG_REGBYTES 2\n#endif\n\n#define REGBYTES (1 << LOG_REGBYTES)\n#define MPRV_BLOCK (REGBYTES * 8)\n\nstatic inline int copy_from_sm(uintptr_t dst, void *src_buf, size_t len)\n{\n    uintptr_t src = (uintptr_t)src_buf;\n\n    if (src % REGBYTES  == 0 && dst % REGBYTES == 0) {\n        while (len >= MPRV_BLOCK) {\n            int res = copy_block_from_sm(dst, (mprv_block *)src);\n            if (res)\n                return res;\n\n            src += MPRV_BLOCK;\n            dst += MPRV_BLOCK;\n            len -= MPRV_BLOCK;\n        }\n\n        while (len >= REGBYTES) {\n            int res = copy_word_from_sm(dst, (uintptr_t *)src);\n            if (res)\n                return res;\n\n            src += REGBYTES;\n            dst += REGBYTES;\n            len -= REGBYTES;\n        }\n    }\n\n    while (len > 0) {\n        int res = copy1_from_sm(dst, (uint8_t *)src);\n        if (res)\n            return res;\n\n        src++;\n        dst++;\n        len--;\n    }\n\n    return 0;\n}\n\nstatic inline int copy_to_sm(void *dst_buf, uintptr_t src, size_t len)\n{\n    uintptr_t dst = (uintptr_t)dst_buf;\n\n    if (src % REGBYTES == 0 && dst % REGBYTES == 0) {\n        while (len >= MPRV_BLOCK) {\n            int res = copy_block_to_sm((mprv_block *)dst, src);\n            if (res)\n                return res;\n\n            src += MPRV_BLOCK;\n            dst += MPRV_BLOCK;\n            len -= MPRV_BLOCK;\n        }\n\n        while (len >= REGBYTES) {\n            int res = copy_word_to_sm((uintptr_t *)dst, src);\n            if (res)\n                return res;\n\n            src += REGBYTES;\n            dst += REGBYTES;\n            len -= REGBYTES;\n        }\n    }\n\n    while (len > 0) {\n        int res = copy1_to_sm((uint8_t *)dst, src);\n        if (res)\n            return res;\n\n        src++;\n        dst++;\n        len--;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ntc2_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tNuvoton Proprietary Command Emulation\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: ntc2_fp.h 927 2017-01-26 14:42:59Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015, 2017\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#ifndef NTC2_FP_H\n#define NTC2_FP_H\n\n#include \"ntc2lib.h\"\n\nTPM_RC\nNTC2_PreConfig(NTC2_PreConfig_In *in);\nTPM_RC\nNTC2_LockPreConfig(void);\nTPM_RC\nNTC2_GetConfig(NTC2_GetConfig_Out *out);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/ntc2lib.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t     \tTPM2 Novoton Proprietary Command Utilities\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: ntc2lib.h 1476 2019-06-10 19:32:03Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015, 2017\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#ifndef NTC2LIB_H\n#define NTC2LIB_H\n\n#include <stdint.h>\n\n#include \"Tpm.h\"\n#include \"TpmTypes.h\"\n\ntypedef struct tdNTC2_CFG_STRUCT {\n    uint8_t i2cLoc1_2;\n    uint8_t i2cLoc3_4;\n    uint8_t AltCfg;\n    uint8_t Direction;\n    uint8_t PullUp;\n    uint8_t PushPull;\n    uint8_t CFG_A;\n    uint8_t CFG_B;\n    uint8_t CFG_C;\n    uint8_t CFG_D;\n    uint8_t CFG_E;\n    uint8_t CFG_F;\n    uint8_t CFG_G;\n    uint8_t CFG_H;\n    uint8_t CFG_I;\n    uint8_t CFG_J;\n    uint8_t IsValid;\t/* Must be AAh */\n    uint8_t IsLocked;\t/* Ignored on NTC2_PreConfig, NTC2_GetConfig returns AAh once configuration\n\t\t\t   is locked. */\n} NTC2_CFG_STRUCT;\n\ntypedef struct {\n    NTC2_CFG_STRUCT preConfig;\n} NTC2_PreConfig_In;     \n\ntypedef struct {\n    NTC2_CFG_STRUCT preConfig;\n} NTC2_GetConfig_Out;     \n\n\nTPM_RC\nNTC2_CFG_STRUCT_Unmarshal(NTC2_CFG_STRUCT *target, BYTE **buffer, INT32 *size);\nUINT16\nNTC2_CFG_STRUCT_Marshal(NTC2_CFG_STRUCT *source, BYTE **buffer, INT32 *size);\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/pcrstruct.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//\n// This file defines the PCR and PCR_Attributes structures and\n// related interface functions\n//\n\n#ifndef _PCRSTRUCT_H_\n#define _PCRSTRUCT_H_\n\n#include \"BaseTypes.h\"\n#include \"TpmAlgorithmDefines.h\"\n#include \"TpmTypes.h\"\n\n// a single PCR\ntypedef struct\n{\n#if ALG_SHA1\n    BYTE Sha1Pcr[SHA1_DIGEST_SIZE];\n#endif\n#if ALG_SHA256\n    BYTE Sha256Pcr[SHA256_DIGEST_SIZE];\n#endif\n#if ALG_SHA384\n    BYTE Sha384[SHA384_DIGEST_SIZE];\n#endif\n#if ALG_SHA512\n    BYTE Sha512[SHA512_DIGEST_SIZE];\n#endif\n#if ALG_SM3_256\n    BYTE Sm3_256[SM3_256_DIGEST_SIZE];\n#endif\n#if ALG_SHA3_256\n    BYTE Sha3_256[SHA3_256_DIGEST_SIZE];\n#endif\n#if ALG_SHA3_384\n    BYTE Sha3_384[SHA3_384_DIGEST_SIZE];\n#endif\n#if ALG_SHA3_512\n    BYTE Sha3_512[SHA3_512_DIGEST_SIZE];\n#endif\n} PCR;\n\n// see the comments below for supportsPolicyAuth to explain this\n#define MAX_PCR_GROUP_BITS 3\n\ntypedef struct\n{\n    // SET if the PCR value should be saved in state save\n    unsigned int stateSave : 1;\n\n    // SET if the PCR is part of the \"TCB group\", causes the PCR counter not to increment\n    unsigned int doNotIncrementPcrCounter : 1;\n\n    // PCRs may support policy or auth-value authorization.\n    //\n    // Such authorization values, if supported, are set by\n    // TPM2_PCR_SetAuthPolicy and/or TPM2_PCR_SetAuthValue.\n    //\n    // PCRs that share the same policy/auth value are said to be in a \"group\".\n    // PCRs that don't support authorization are said to be in group Zero.\n    //\n    // Group numbers are only used internally to indicate which PCRs share an\n    // authorization value.  IOW the TPM client cannot refer to PCRs by group\n    // number; the range of group numbers is implementation defined. zero\n    // indicates the PCR doesn't support policy or auth verification.\n    //\n    // The size of this field must be large enough to support\n    // NUM_POLICY_PCR_GROUP & NUM_AUTHVALUE_PCR_GROUP; the maximum number of groups\n    // actually supported by this build of the core library.\n    //\n    // The number of bits allocated here does not control the number of groups,\n    // but there is a static assert that the number of bits here is large\n    // enough.\n    unsigned int policyAuthGroup : MAX_PCR_GROUP_BITS;\n    unsigned int authValuesGroup : MAX_PCR_GROUP_BITS;\n\n    // these bitfields indicating the localities that can\n    // reset or extend this PCR. A SET bit indicates the PCR can\n    // be extended or reset from that locality.  The low-order bit in\n    // each field is locality zero, and the high-order bit is locality 4.\n    unsigned int resetLocality  : 5;\n    unsigned int extendLocality : 5;\n} PCR_Attributes;\n\n// Get pointer to particular PCR from array if that PCR is allocated.\n// otherwise returns NULL\nBYTE* GetPcrPointerIfAllocated(PCR*       pPcrArray,\n\t\t\t       TPM_ALG_ID alg,       // IN: algorithm for bank\n\t\t\t       UINT32     pcrNumber  // IN: PCR number\n\t\t\t       );\n\n// get a PCR pointer from the TPM's internal list, if it's allocated\n// otherwise NULL\nBYTE* GetPcrPointer(TPM_ALG_ID alg,       // IN: algorithm for bank\n\t\t    UINT32     pcrNumber  // IN: PCR number\n\t\t    );\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/platform_pcr_fp.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _PLATFORM_PCR_FP_H_\n#define _PLATFORM_PCR_FP_H_\n\n#include \"BaseTypes.h\"\n#include \"TpmTypes.h\"\n#include \"pcrstruct.h\"\n\n// return the number of PCRs the platform recognizes for GetPcrInitializationAttributes.\n// PCRs are numbered starting at zero.\n// Note: The TPM Library will enter failure mode if this number doesn't match\n// IMPLEMENTATION_PCR.\nUINT32 _platPcr__NumberOfPcrs(void);\n\n// return the initialization attributes of a given PCR.\n// pcrNumber expected to be in [0, _platPcr__NumberOfPcrs)\n// returns the attributes for PCR[0] if the requested pcrNumber is out of range.\n// Note this returns a structure by-value, which is fast because the structure is\n// a bitfield.\nPCR_Attributes _platPcr__GetPcrInitializationAttributes(UINT32 pcrNumber);\n\n// Fill a given buffer with the PCR initialization value for a particular PCR and hash\n// combination, and return its length.  If the platform doesn't have a value, then\n// the result size is expected to be zero, and the rfunction will return TPM_RC_PCR.\n// If a valid is not available, then the core TPM library will ignore the value and\n// treat it as non-existant and provide a default.\n// If the buffer is not large enough for a pcr consistent with pcrAlg, then the\n// platform will return TPM_RC_FAILURE.\nTPM_RC _platPcr__GetInitialValueForPcr(\n\t\t\t\t       UINT32     pcrNumber,        // IN: PCR to be initialized\n\t\t\t\t       TPM_ALG_ID pcrAlg,           // IN: Algorithm of the PCR Bank being initialized\n\t\t\t\t       BYTE       startupLocality,  // IN: locality where startup is being called from\n\t\t\t\t       BYTE*      pcrBuffer,        // OUT: buffer to put PCR initialization value into\n\t\t\t\t       uint16_t   bufferSize,       // IN: maximum size of value buffer can hold\n\t\t\t\t       uint16_t*  pcrLength);  // OUT: size of initialization value returned in pcrBuffer\n\n// should the given PCR algorithm default to active in a new TPM?\nBOOL _platPcr_IsPcrBankDefaultActive(TPM_ALG_ID pcrAlg);\n\n#endif  // _PLATFORM_PCR_FP_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/platform_public_interface.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This file contains the interface into the platform layer from external callers.\n// External callers are expected to be implementation specific, and may be a simulator\n// or some other implementation\n\n#ifndef _PLATFORM_PUBLIC_INTERFACE_H_\n#define _PLATFORM_PUBLIC_INTERFACE_H_\n\n#include <stddef.h>\n\n//** From Cancel.c\n\n// Set cancel flag.\nLIB_EXPORT void _plat__SetCancel(void);\n\n//***_plat__ClearCancel()\n// Clear cancel flag\nLIB_EXPORT void _plat__ClearCancel(void);\n\n//** From Clock.c\n\n//***_plat__TimerReset()\n// This function sets current system clock time as t0 for counting TPM time.\n// This function is called at a power on event to reset the clock. When the clock\n// is reset, the indication that the clock was stopped is also set.\nLIB_EXPORT void _plat__TimerReset(void);\n\n//*** _plat__TimerRestart()\n// This function should be called in order to simulate the restart of the timer\n// should it be stopped while power is still applied.\nLIB_EXPORT void _plat__TimerRestart(void);\n\n//*** _plat__RealTime()\n// This is another, probably futile, attempt to define a portable function\n// that will return a 64-bit clock value that has mSec resolution.\nLIB_EXPORT uint64_t _plat__RealTime(void);\n\n//** From LocalityPlat.c\n\n//***_plat__LocalitySet()\n// Set the most recent command locality in locality value form\nLIB_EXPORT void _plat__LocalitySet(unsigned char locality);\n\n//** From NVMem.c\n\n//*** _plat__NvErrors()\n// This function is used by the simulator to set the error flags in the NV\n// subsystem to simulate an error in the NV loading process\nLIB_EXPORT void _plat__NvErrors(int recoverable, int unrecoverable);\n\n//***_plat__NVDisable()\n// Disable NV memory\nLIB_EXPORT void _plat__NVDisable(\n\t\t\t\t void*  platParameter,  // platform specific parameter\n\t\t\t\t size_t paramSize       // size of parameter. If size == 0, then\n\t\t\t\t // parameter is a sizeof(void*) scalar and should\n\t\t\t\t // be cast to an integer (intptr_t), not dereferenced.\n\t\t\t\t );\n\n//***_plat__SetNvAvail()\n// Set the current NV state to available.  This function is for testing purpose\n// only.  It is not part of the platform NV logic\nLIB_EXPORT void _plat__SetNvAvail(void);\n\n//***_plat__ClearNvAvail()\n// Set the current NV state to unavailable.  This function is for testing purpose\n// only.  It is not part of the platform NV logic\nLIB_EXPORT void _plat__ClearNvAvail(void);\n\n//*** _plat__NVNeedsManufacture()\n// This function is used by the simulator to determine when the TPM's NV state\n// needs to be manufactured.\nLIB_EXPORT int _plat__NVNeedsManufacture(void);\n\n//** From PlatformACT.c\n\n//*** _plat__ACT_GetPending()\nLIB_EXPORT int _plat__ACT_GetPending(uint32_t act  //IN: number of ACT to check\n\t\t\t\t     );\n\n//*** _plat__ACT_Tick()\n// This processes the once-per-second clock tick from the hardware. This is set up\n// for the simulator to use the control interface to send ticks to the TPM. These\n// ticks do not have to be on a per second basis. They can be as slow or as fast as\n// desired so that the simulation can be tested.\nLIB_EXPORT void _plat__ACT_Tick(void);\n\n//** From PowerPlat.c\n\n//***_plat__Signal_PowerOn()\n// Signal platform power on\nLIB_EXPORT int _plat__Signal_PowerOn(void);\n\n//*** _plat_Signal_Reset()\n// This a TPM reset without a power loss.\nLIB_EXPORT int _plat__Signal_Reset(void);\n\n//***_plat__Signal_PowerOff()\n// Signal platform power off\nLIB_EXPORT void _plat__Signal_PowerOff(void);\n\n//** From PPPlat.c\n\n//***_plat__Signal_PhysicalPresenceOn()\n// Signal physical presence on\nLIB_EXPORT void _plat__Signal_PhysicalPresenceOn(void);\n\n//***_plat__Signal_PhysicalPresenceOff()\n// Signal physical presence off\nLIB_EXPORT void _plat__Signal_PhysicalPresenceOff(void);\n\n//*** _plat__SetTpmFirmwareHash()\n// Called by the simulator to set the TPM Firmware hash used for\n// firmware-bound hierarchies. Not a cryptographically-strong hash.\n#if SIMULATION\nLIB_EXPORT void _plat__SetTpmFirmwareHash(uint32_t hash);\n#endif\n\n//*** _plat__SetTpmFirmwareSvn()\n// Called by the simulator to set the TPM Firmware SVN reported by\n// getCapability.\n#if SIMULATION\nLIB_EXPORT void _plat__SetTpmFirmwareSvn(uint16_t svn);\n#endif\n\n//** From RunCommand.c\n\n//***_plat__RunCommand()\n// This version of RunCommand will set up a jum_buf and call ExecuteCommand(). If\n// the command executes without failing, it will return and RunCommand will return.\n// If there is a failure in the command, then _plat__Fail() is called and it will\n// longjump back to RunCommand which will call ExecuteCommand again. However, this\n// time, the TPM will be in failure mode so ExecuteCommand will simply build\n// a failure response and return.\nLIB_EXPORT void _plat__RunCommand(\n\t\t\t\t  uint32_t        requestSize,   // IN: command buffer size\n\t\t\t\t  unsigned char*  request,       // IN: command buffer\n\t\t\t\t  uint32_t*       responseSize,  // IN/OUT: response buffer size\n\t\t\t\t  unsigned char** response       // IN/OUT: response buffer\n\t\t\t\t  );\n\n#endif  // _PLATFORM_PUBLIC_INTERFACE_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/platform_to_tpm_interface.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#ifndef _PLATFORM_TO_TPM_INTERFACE_H_\n#define _PLATFORM_TO_TPM_INTERFACE_H_\n\n#include \"_TPM_Hash_Data_fp.h\"\n#include \"_TPM_Hash_End_fp.h\"\n#include \"_TPM_Hash_Start_fp.h\"\n#include \"_TPM_Init_fp.h\"\n#include \"ExecCommand_fp.h\"\n#include \"Manufacture_fp.h\"\n// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers\n#include \"TpmFail_fp.h\"\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/simulatorPrivate.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// common headers for simulator implementation files\n\n#ifndef SIMULATOR_PRIVATE_H\n#define SIMULATOR_PRIVATE_H\n\n//** Includes, Locals, Defines and Function Prototypes\n#include \"tpm_public.h\"\n\n#include \"simulator_sysheaders.h\"\n\n// TODO_RENAME_INC_FOLDER:prototypes refers to the platform library\n#include \"platform_public_interface.h\"\n// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface\n#include \"tpm_to_platform_interface.h\"\n#include \"platform_to_tpm_interface.h\"\n\n#include \"TpmTcpProtocol.h\"\n#include \"Simulator_fp.h\"\n\n#endif  // SIMULATOR_PRIVATE_H\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/simulator_sysheaders.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// system headers for the simulator, both Windows and Linux\n\n#ifndef _SIMULATOR_SYSHEADERS_H_\n#define _SIMULATOR_SYSHEADERS_H_\n// include the system headers silencing warnings that occur with /Wall\n#include <stdio.h>\n#include <stdbool.h>\n#include <stdint.h>\n#include <stdlib.h>\n#include <ctype.h>\n#include <string.h>\n\n// #ifdef TPM_WINDOWS\n// #ifdef _MSC_VER\n// #  pragma warning(push, 3)\n// // C4668 is supposed to be level 4, but this is still necessary to suppress the\n// // error.  We don't want to suppress it globally because the same error can\n// // happen in the TPM code and it shouldn't be ignored in those cases because it\n// // generally means a configuration header is missing.\n// //\n// // X is not defined as a preprocessor macro, assuming 0 for #if\n// #  pragma warning(disable : 4668)\n// #endif\n// #  include <windows.h>\n// #  include <winsock.h>\n// #ifdef _MSC_VER\n// #  pragma warning(pop)\n// #endif\n// typedef int socklen_t;\n// #elif defined(__unix__) || defined(__APPLE__)\n// #  include <unistd.h>\n// #  include <errno.h>\n// #  include <netinet/in.h>\n// #  include <sys/socket.h>\n// #  include <pthread.h>\n// // simulate certain windows APIs\n// #  define ZeroMemory(ptr, sz) (memset((ptr), 0, (sz)))\n// #  define closesocket(x)      close(x)\n// #  define INVALID_SOCKET      (-1)\n// #  define SOCKET_ERROR        (-1)\n// #  define WSAGetLastError()   (errno)\n// #  define WSAEADDRINUSE       EADDRINUSE\n// #  define INT_PTR             intptr_t\n// typedef int SOCKET;\n// #  define _strcmpi            strcasecmp\n// #else\n// #  error \"Unsupported platform.\"\n// #endif  // _MSC_VER\n#endif  // _SIMULATOR_SYSHEADERS_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/tpm_public.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"TpmBuildSwitches.h\"\n#include \"TpmProfile.h\"\n\n#include \"VerifyConfiguration.h\"\n#include \"BaseTypes.h\"\n#include \"TPMB.h\"\n#include \"MinMax.h\"\n#include \"tpm_radix.h\"\n#include \"TpmTypes.h\"\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/tpm_radix.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// Common defines for supporting large numbers and cryptographic buffer sizing.\n//*********************\n#ifndef RADIX_BITS\n#  if defined(__x86_64__) || defined(__x86_64) || defined(__amd64__)\t\\\n    || defined(__amd64) || defined(_WIN64) || defined(_M_X64) || defined(_M_ARM64) \\\n    || defined(__aarch64__) || defined(__PPC64__) || defined(__s390x__) \\\n    || defined(__powerpc64__) || defined(__ppc64__)\n#    define RADIX_BITS 64\n#  elif defined(__i386__) || defined(__i386) || defined(i386) || defined(_WIN32) \\\n    || defined(_M_IX86)\n#    define RADIX_BITS 32\n#  elif defined(_M_ARM) || defined(__arm__) || defined(__thumb__)\n#    define RADIX_BITS 32\n#  elif defined(__riscv)\n// __riscv and __riscv_xlen are standardized by the RISC-V community and should be available\n// on any compliant compiler.\n//\n// https://github.com/riscv-non-isa/riscv-toolchain-conventions\n#    define RADIX_BITS __riscv_xlen\n#  else\n#    error Unable to determine RADIX_BITS from compiler environment\n#  endif\n#endif  // RADIX_BITS\n\n#if RADIX_BITS == 64\n#  define RADIX_BYTES 8\n#  define RADIX_LOG2  6\n#elif RADIX_BITS == 32\n#  define RADIX_BYTES 4\n#  define RADIX_LOG2  5\n#else\n#  error \"RADIX_BITS must either be 32 or 64\"\n#endif\n\n#define HASH_ALIGNMENT      RADIX_BYTES\n#define SYMMETRIC_ALIGNMENT RADIX_BYTES\n\n#define RADIX_MOD(x) ((x) & ((1 << RADIX_LOG2) - 1))\n#define RADIX_DIV(x) ((x) >> RADIX_LOG2)\n#define RADIX_MASK   ((((crypt_uword_t)1) << RADIX_LOG2) - 1)\n\n#define BITS_TO_CRYPT_WORDS(bits)   RADIX_DIV((bits) + (RADIX_BITS - 1))\n#define BYTES_TO_CRYPT_WORDS(bytes) BITS_TO_CRYPT_WORDS(bytes * 8)\n#define SIZE_IN_CRYPT_WORDS(thing)  BYTES_TO_CRYPT_WORDS(sizeof(thing))\n\n#if RADIX_BITS == 64\n#  define SWAP_CRYPT_WORD(x) REVERSE_ENDIAN_64(x)\ntypedef uint64_t crypt_uword_t;\ntypedef int64_t  crypt_word_t;\n#  define TO_CRYPT_WORD_64             BIG_ENDIAN_BYTES_TO_UINT64\n#  define TO_CRYPT_WORD_32(a, b, c, d) TO_CRYPT_WORD_64(0, 0, 0, 0, a, b, c, d)\n#elif RADIX_BITS == 32\n#  define SWAP_CRYPT_WORD(x) REVERSE_ENDIAN_32((x))\ntypedef uint32_t crypt_uword_t;\ntypedef int32_t  crypt_word_t;\n#  define TO_CRYPT_WORD_64(a, b, c, d, e, f, g, h)\t\t\t\\\n    BIG_ENDIAN_BYTES_TO_UINT32(e, f, g, h), BIG_ENDIAN_BYTES_TO_UINT32(a, b, c, d)\n#endif\n\n#define MAX_CRYPT_UWORD (~((crypt_uword_t)0))\n#define MAX_CRYPT_WORD  ((crypt_word_t)(MAX_CRYPT_UWORD >> 1))\n#define MIN_CRYPT_WORD  (~MAX_CRYPT_WORD)\n\n// Avoid expanding LARGEST_NUMBER into a long expression that inlines 3 other long expressions.\n// TODO: Decrease the size of each of the MAX_* expressions with improvements to the code generator.\n#if ALG_RSA == ALG_YES\n// The smallest supported RSA key (1024 bits) is larger than\n// the largest supported ECC curve (628 bits)\n// or the largest supported digest (512 bits)\n#  define LARGEST_NUMBER MAX_RSA_KEY_BYTES\n#elif ALG_ECC == ALG_YES\n#  define LARGEST_NUMBER MAX(MAX_ECC_KEY_BYTES, MAX_DIGEST_SIZE)\n#else\n#  define LARGEST_NUMBER MAX_DIGEST_SIZE\n#endif  // ALG_RSA == YES\n\n#define LARGEST_NUMBER_BITS (LARGEST_NUMBER * 8)\n\n#define MAX_ECC_PARAMETER_BYTES (MAX_ECC_KEY_BYTES * ALG_ECC)\n\n// These macros use the selected libraries to get the proper include files.\n// clang-format off\n#define LIB_QUOTE(_STRING_)                    #_STRING_\n/* kgold removed subdirectory */\n#define LIB_INCLUDE2(_PREFIX_, _LIB_, _TYPE_)  LIB_QUOTE(_PREFIX_##_LIB_##_TYPE_.h)\n#define LIB_INCLUDE(_PREFIX_, _LIB_, _TYPE_)   LIB_INCLUDE2(_PREFIX_,_LIB_, _TYPE_)\n// clang-format on\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/tpm_to_platform_interface.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tNV read and write access methods     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// This file represents the functional interface that all platform libraries must\n// provide because they are called by the Core TPM library.\n#ifndef _TPM_TO_PLATFORM_INTERFACE_H_\n#define _TPM_TO_PLATFORM_INTERFACE_H_\n\n// need to read configuration for ACT_SUPPORT flag check below\n#include \"TpmBuildSwitches.h\"\n#include \"TpmProfile.h\"\n#include <stddef.h>\n\n//** From Cancel.c\n\n//***_plat__IsCanceled()\n// Check if the cancel flag is set\n//  Return Type: int\n//      TRUE(1)         if cancel flag is set\n//      FALSE(0)        if cancel flag is not set\nLIB_EXPORT int _plat__IsCanceled(void);\n\n//***_plat__TimerRead()\n// This function provides access to the tick timer of the platform. The TPM code\n// uses this value to drive the TPM Clock.\n//\n// The tick timer is supposed to run when power is applied to the device. This timer\n// should not be reset by time events including _TPM_Init. It should only be reset\n// when TPM power is re-applied.\n//\n// If the TPM is run in a protected environment, that environment may provide the\n// tick time to the TPM as long as the time provided by the environment is not\n// allowed to go backwards. If the time provided by the system can go backwards\n// during a power discontinuity, then the _plat__Signal_PowerOn should call\n// _plat__TimerReset().\nLIB_EXPORT uint64_t _plat__TimerRead(void);\n\n//*** _plat__TimerWasReset()\n// This function is used to interrogate the flag indicating if the tick timer has\n// been reset.\n//\n// If the resetFlag parameter is SET, then the flag will be CLEAR before the\n// function returns.\nLIB_EXPORT int _plat__TimerWasReset(void);\n\n//*** _plat__TimerWasStopped()\n// This function is used to interrogate the flag indicating if the tick timer has\n// been stopped. If so, this is typically a reason to roll the nonce.\n//\n// This function will CLEAR the s_timerStopped flag before returning. This provides\n// functionality that is similar to status register that is cleared when read. This\n// is the model used here because it is the one that has the most impact on the TPM\n// code as the flag can only be accessed by one entity in the TPM. Any other\n// implementation of the hardware can be made to look like a read-once register.\nLIB_EXPORT int _plat__TimerWasStopped(void);\n\n//***_plat__ClockRateAdjust()\n// Adjust the clock rate\n// the old function name is ClockAdjustRate, and took a value which was an absolute\n// number of ticks.\n//\n// ClockRateAdjust uses predefined signal values and encapsulates the platform\n// specifics regarding the number of ticks the underlying clock is running at.\n//\n// The adjustment must be one of these values. A COARSE adjustment is 1%, MEDIUM\n// is 0.1%, and FINE is the smallest amount supported by the platform.  The\n// total (cumulative) adjustment is limited to ~15% total.  Attempts to adjust\n// the clock further are silently ignored as are any invalid values.  These\n// values are defined here to insulate them from spec changes and to avoid\n// needing visibility to the doc-generated structure headers.\ntypedef enum _plat__ClockAdjustStep\n    {\n\tPLAT_TPM_CLOCK_ADJUST_COARSE_SLOWER = -3,\n\tPLAT_TPM_CLOCK_ADJUST_MEDIUM_SLOWER = -2,\n\tPLAT_TPM_CLOCK_ADJUST_FINE_SLOWER   = -1,\n\tPLAT_TPM_CLOCK_ADJUST_FINE_FASTER   = 1,\n\tPLAT_TPM_CLOCK_ADJUST_MEDIUM_FASTER = 2,\n\tPLAT_TPM_CLOCK_ADJUST_COARSE_FASTER = 3\n    } _plat__ClockAdjustStep;\nLIB_EXPORT void _plat__ClockRateAdjust(_plat__ClockAdjustStep adjustment);\n\n//** From DebugHelpers.c\n\n#if CERTIFYX509_DEBUG\n\n//*** DebugFileInit()\n// This function opens the file used to hold the debug data.\n//  Return Type: int\n//   0        success\n//  != 0          error\nint DebugFileInit(void);\n\n//*** DebugDumpBuffer()\nvoid DebugDumpBuffer(int size, unsigned char* buf, const char* identifier);\n#endif  // CERTIFYX509_DEBUG\n\n\t//** From Entropy.c\n\n\t//*** _plat__GetEntropy()\n\t// This function is used to get available hardware entropy. In a hardware\n\t// implementation of this function, there would be no call to the system\n\t// to get entropy.\n\t//  Return Type: int32_t\n\t//  < 0        hardware failure of the entropy generator, this is sticky\n\t// >= 0        the returned amount of entropy (bytes)\n\t//\nLIB_EXPORT int32_t _plat__GetEntropy(unsigned char* entropy,  // output buffer\n\t\t\t\t     uint32_t       amount    // amount requested\n\t\t\t\t     );\n\n//** From LocalityPlat.c\n\n//***_plat__LocalityGet()\n// Get the most recent command locality in locality value form.\n// This is an integer value for locality and not a locality structure\n// The locality can be 0-4 or 32-255. 5-31 is not allowed.\nLIB_EXPORT unsigned char _plat__LocalityGet(void);\n\n//***_plat__NVEnable()\n// Enable NV memory.\n//\n// This version just pulls in data from a file. In a real TPM, with NV on chip,\n// this function would verify the integrity of the saved context. If the NV\n// memory was not on chip but was in something like RPMB, the NV state would be\n// read in, decrypted and integrity checked.\n//\n// The recovery from an integrity failure depends on where the error occurred. It\n// it was in the state that is discarded by TPM Reset, then the error is\n// recoverable if the TPM is reset. Otherwise, the TPM must go into failure mode.\n//\n//  Return Type: int\n//      0           if success\n//      >0          if recoverable error\n//      <0          if unrecoverable error\nLIB_EXPORT int _plat__NVEnable(\n\t\t\t       void*  platParameter,  // platform specific parameter\n\t\t\t       size_t paramSize       // size of parameter. If size == 0, then\n\t\t\t       // parameter is a sizeof(void*) scalar and should\n\t\t\t       // be cast to an integer (intptr_t), not dereferenced.\n\t\t\t       );\n\n//***_plat__GetNvReadyState()\n// Check if NV is available\n//  Return Type: int\n//      0               NV is available\n//      1               NV is not available due to write failure\n//      2               NV is not available due to rate limit\n#define NV_READY        0\n#define NV_WRITEFAILURE 1\n#define NV_RATE_LIMIT   2\nLIB_EXPORT int _plat__GetNvReadyState(void);\n\n//***_plat__NvMemoryRead()\n// Function: Read a chunk of NV memory\n//  Return Type: int\n//      TRUE(1)         offset and size is within available NV size\n//      FALSE(0)        otherwise; also trigger failure mode\nLIB_EXPORT int _plat__NvMemoryRead(unsigned int startOffset,  // IN: read start\n\t\t\t\t   unsigned int size,  // IN: size of bytes to read\n\t\t\t\t   void*        data   // OUT: data buffer\n\t\t\t\t   );\n\n//*** _plat__NvGetChangedStatus()\n// This function checks to see if the NV is different from the test value. This is\n// so that NV will not be written if it has not changed.\n//  Return Type: int\n//      NV_HAS_CHANGED(1)       the NV location is different from the test value\n//      NV_IS_SAME(0)           the NV location is the same as the test value\n//      NV_INVALID_LOCATION(-1) the NV location is invalid; also triggers failure mode\n#define NV_HAS_CHANGED      (1)\n#define NV_IS_SAME          (0)\n#define NV_INVALID_LOCATION (-1)\nLIB_EXPORT int _plat__NvGetChangedStatus(\n\t\t\t\t\t unsigned int startOffset,  // IN: read start\n\t\t\t\t\t unsigned int size,         // IN: size of bytes to read\n\t\t\t\t\t void*        data          // IN: data buffer\n\t\t\t\t\t );\n\n//***_plat__NvMemoryWrite()\n// This function is used to update NV memory. The \"write\" is to a memory copy of\n// NV. At the end of the current command, any changes are written to\n// the actual NV memory.\n// NOTE: A useful optimization would be for this code to compare the current\n// contents of NV with the local copy and note the blocks that have changed. Then\n// only write those blocks when _plat__NvCommit() is called.\n//  Return Type: int\n//      TRUE(1)         offset and size is within available NV size\n//      FALSE(0)        otherwise; also trigger failure mode\nLIB_EXPORT int _plat__NvMemoryWrite(unsigned int startOffset,  // IN: write start\n\t\t\t\t    unsigned int size,  // IN: size of bytes to write\n\t\t\t\t    void*        data   // OUT: data buffer\n\t\t\t\t    );\n\n//***_plat__NvMemoryClear()\n// Function is used to set a range of NV memory bytes to an implementation-dependent\n// value. The value represents the erase state of the memory.\nLIB_EXPORT int _plat__NvMemoryClear(unsigned int startOffset,  // IN: clear start\n\t\t\t\t    unsigned int size  // IN: number of bytes to clear\n\t\t\t\t    );\n\n//***_plat__NvMemoryMove()\n// Function: Move a chunk of NV memory from source to destination\n//      This function should ensure that if there overlap, the original data is\n//      copied before it is written\nLIB_EXPORT int _plat__NvMemoryMove(unsigned int sourceOffset,  // IN: source offset\n\t\t\t\t   unsigned int destOffset,  // IN: destination offset\n\t\t\t\t   unsigned int size  // IN: size of data being moved\n\t\t\t\t   );\n\n//***_plat__NvCommit()\n// This function writes the local copy of NV to NV for permanent store. It will write\n// NV_MEMORY_SIZE bytes to NV. If a file is use, the entire file is written.\n//  Return Type: int\n//  0       NV write success\n//  non-0   NV write fail\nLIB_EXPORT int _plat__NvCommit(void);\n\n//***_plat__TearDown\n// notify platform that TPM_TearDown was called so platform can cleanup or\n// zeroize anything in the Platform.  This should zeroize NV as well.\nLIB_EXPORT void _plat__TearDown(void);\n\n//** From PlatformACT.c\n\n#if ACT_SUPPORT\n//*** _plat__ACT_GetImplemented()\n// This function tests to see if an ACT is implemented. It is a belt and suspenders\n// function because the TPM should not be calling to manipulate an ACT that is not\n// implemented. However, this could help the simulator code which doesn't necessarily\n// know if an ACT is implemented or not.\nLIB_EXPORT int _plat__ACT_GetImplemented(uint32_t act);\n\n//*** _plat__ACT_GetRemaining()\n// This function returns the remaining time. If an update is pending, 'newValue' is\n// returned. Otherwise, the current counter value is returned. Note that since the\n// timers keep running, the returned value can get stale immediately. The actual count\n// value will be no greater than the returned value.\nLIB_EXPORT uint32_t _plat__ACT_GetRemaining(uint32_t act  //IN: the ACT selector\n\t\t\t\t\t    );\n\n//*** _plat__ACT_GetSignaled()\nLIB_EXPORT int _plat__ACT_GetSignaled(uint32_t act  //IN: number of ACT to check\n\t\t\t\t      );\n\n//*** _plat__ACT_SetSignaled()\nLIB_EXPORT void _plat__ACT_SetSignaled(uint32_t act, int on);\n\n//*** _plat__ACT_UpdateCounter()\n// This function is used to write the newValue for the counter. If an update is\n// pending, then no update occurs and the function returns FALSE. If 'setSignaled'\n// is TRUE, then the ACT signaled state is SET and if 'newValue' is 0, nothing\n// is posted.\nLIB_EXPORT int _plat__ACT_UpdateCounter(uint32_t act,      // IN: ACT to update\n\t\t\t\t\tuint32_t newValue  // IN: the value to post\n\t\t\t\t\t);\n\n//***_plat__ACT_EnableTicks()\n// This enables and disables the processing of the once-per-second ticks. This should\n// be turned off ('enable' = FALSE) by _TPM_Init and turned on ('enable' = TRUE) by\n// TPM2_Startup() after all the initializations have completed.\nLIB_EXPORT void _plat__ACT_EnableTicks(int enable);\n\n//***_plat__ACT_Initialize()\n// This function initializes the ACT hardware and data structures\nLIB_EXPORT int _plat__ACT_Initialize(void);\n\n#endif  // ACT_SUPPORT\n\n\t//** From PowerPlat.c\n\n\t//*** _plat__WasPowerLost()\n\t// Test whether power was lost before a _TPM_Init.\n\t//\n\t// This function will clear the \"hardware\" indication of power loss before return.\n\t// This means that there can only be one spot in the TPM code where this value\n\t// gets read. This method is used here as it is the most difficult to manage in the\n\t// TPM code and, if the hardware actually works this way, it is hard to make it\n\t// look like anything else. So, the burden is placed on the TPM code rather than the\n\t// platform code\n\t//  Return Type: int\n\t//      TRUE(1)         power was lost\n\t//      FALSE(0)        power was not lost\nLIB_EXPORT int _plat__WasPowerLost(void);\n\n//** From PPPlat.c\n\n//***_plat__PhysicalPresenceAsserted()\n// Check if physical presence is signaled\n//  Return Type: int\n//      TRUE(1)         if physical presence is signaled\n//      FALSE(0)        if physical presence is not signaled\nLIB_EXPORT int _plat__PhysicalPresenceAsserted(void);\n\n//***_plat__Fail()\n// This is the platform depended failure exit for the TPM.\nLIB_EXPORT NORETURN void _plat__Fail(void);\n\n//** From Unique.c\n\n#if VENDOR_PERMANENT_AUTH_ENABLED == YES\n//** _plat__GetUnique()\n// This function is used to access the platform-specific unique values.\n// This function places the unique value in the provided buffer ('b')\n// and returns the number of bytes transferred. The function will not\n// copy more data than 'bSize'.\n// zero indicates value does not exist or an error occurred.\n//\n// 'which' indicates the unique value to return:\n// 0 = RESERVED, do not use\n// 1 = the VENDOR_PERMANENT_AUTH_HANDLE authorization value for this device\nLIB_EXPORT uint32_t _plat__GetUnique(uint32_t       which,\n\t\t\t\t     uint32_t       bSize,  // size of the buffer\n\t\t\t\t     unsigned char* b       // output buffer\n\t\t\t\t     );\n#endif\n\n//** _plat__GetPlatformManufactureData\n// This function allows the platform to provide a small amount of data to be\n// stored as part of the TPM's PERSISTENT_DATA structure during manufacture.  Of\n// course the platform can store data separately as well, but this allows a\n// simple platform implementation to store a few bytes of data without\n// implementing a multi-layer storage system.  This function is called on\n// manufacture and CLEAR.  The buffer will contain the last value provided\n// to the Core library.\nLIB_EXPORT void _plat__GetPlatformManufactureData(uint8_t* pPlatformPersistentData,\n\t\t\t\t\t\t  uint32_t bufferSize);\n\n// return the 4 character Manufacturer Capability code.  This\n// should come from the platform library since that is provided by the manufacturer\nLIB_EXPORT uint32_t _plat__GetManufacturerCapabilityCode(void);\n\n// return the 4 character VendorStrings for Capabilities.\n// Index is ONE-BASED, and may be in the range [1,4] inclusive.\n// Any other index returns all zeros. The return value will be interpreted\n// as an array of 4 ASCII characters (with no null terminator)\nLIB_EXPORT uint32_t _plat__GetVendorCapabilityCode(int index);\n\n// return the most-significant 32-bits of the TPM Firmware Version reported by\n// getCapability.\nLIB_EXPORT uint32_t _plat__GetTpmFirmwareVersionHigh(void);\n\n// return the least-significant 32-bits of the TPM Firmware Version reported by\n// getCapability.\nLIB_EXPORT uint32_t _plat__GetTpmFirmwareVersionLow(void);\n\n// return the TPM Firmware's current SVN.\nLIB_EXPORT uint16_t _plat__GetTpmFirmwareSvn(void);\n\n// return the maximum value that the TPM Firmware SVN may take.\nLIB_EXPORT uint16_t _plat__GetTpmFirmwareMaxSvn(void);\n\n#if SVN_LIMITED_SUPPORT\n//***_plat__GetTpmFirmwareSvnSecret()\n// Function: Obtain a Firmware SVN Secret bound to the given SVN. Fails if the\n// given SVN is greater than the firmware's current SVN.\n// size must equal PRIMARY_SEED_SIZE.\n// Return Type: int\n//  0           success\n//  != 0        error\nLIB_EXPORT int _plat__GetTpmFirmwareSvnSecret(\n\t\t\t\t\t      uint16_t  svn,              // IN: specified SVN\n\t\t\t\t\t      uint16_t  secret_buf_size,  // IN: size of secret buffer\n\t\t\t\t\t      uint8_t*  secret_buf,       // OUT: secret buffer\n\t\t\t\t\t      uint16_t* secret_size       // OUT: secret buffer\n\t\t\t\t\t      );\n#endif  // SVN_LIMITED_SUPPORT\n\n#if FW_LIMITED_SUPPORT\n//***_plat__GetTpmFirmwareSecret()\n// Function: Obtain a Firmware Secret bound to the current firmware image.\n// Return Type: int\n//  0           success\n//  != 0        error\nLIB_EXPORT int _plat__GetTpmFirmwareSecret(\n\t\t\t\t\t   uint16_t  secret_buf_size,  // IN: size of secret buffer\n\t\t\t\t\t   uint8_t*  secret_buf,       // OUT: secret buffer\n\t\t\t\t\t   uint16_t* secret_size       // OUT: secret buffer\n\t\t\t\t\t   );\n#endif  // FW_LIMITED_SUPPORT\n\n\t// return the TPM Type returned by TPM_PT_VENDOR_TPM_TYPE\nLIB_EXPORT uint32_t _plat__GetTpmType(void);\n\n// platform PCR initialization functions\n#include \"platform_pcr_fp.h\"\n\n#endif  // _TPM_TO_PLATFORM_INTERFACE_H_\n"
  },
  {
    "path": "ftpm-opensbi/include/ftpm/tpm_to_tpm_interface.h",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tNV read and write access methods     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"_TPM_Hash_Data_fp.h\"\n#include \"_TPM_Hash_End_fp.h\"\n#include \"_TPM_Hash_Start_fp.h\"\n#include \"_TPM_Init_fp.h\"\n#include \"ExecCommand_fp.h\"\n#include \"Manufacture_fp.h\"\n// TODO_RENAME_INC_FOLDER: public refers to the TPM_CoreLib public headers\n#include \"TpmFail_fp.h\"\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/fw_dynamic.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __FW_DYNAMIC_H__\n#define __FW_DYNAMIC_H__\n\n#include <sbi/riscv_asm.h>\n\n/* clang-format off */\n\n/** Offset of magic member in fw_dynamic_info */\n#define FW_DYNAMIC_INFO_MAGIC_OFFSET\t\t(0 * __SIZEOF_LONG__)\n/** Offset of version member in fw_dynamic_info */\n#define FW_DYNAMIC_INFO_VERSION_OFFSET\t\t(1 * __SIZEOF_LONG__)\n/** Offset of next_addr member in fw_dynamic_info (version >= 1) */\n#define FW_DYNAMIC_INFO_NEXT_ADDR_OFFSET\t(2 * __SIZEOF_LONG__)\n/** Offset of next_mode member in fw_dynamic_info  (version >= 1) */\n#define FW_DYNAMIC_INFO_NEXT_MODE_OFFSET\t(3 * __SIZEOF_LONG__)\n/** Offset of options member in fw_dynamic_info  (version >= 1) */\n#define FW_DYNAMIC_INFO_OPTIONS_OFFSET\t\t(4 * __SIZEOF_LONG__)\n/** Offset of boot_hart member in fw_dynamic_info  (version >= 2) */\n#define FW_DYNAMIC_INFO_BOOT_HART_OFFSET\t(5 * __SIZEOF_LONG__)\n\n/** Expected value of info magic ('OSBI' ascii string in hex) */\n#define FW_DYNAMIC_INFO_MAGIC_VALUE\t\t0x4942534f\n\n/** Maximum supported info version */\n#define FW_DYNAMIC_INFO_VERSION_2\t\t0x2\n#define FW_DYNAMIC_INFO_VERSION_MAX\t\tFW_DYNAMIC_INFO_VERSION_2\n\n/** Possible next mode values */\n#define FW_DYNAMIC_INFO_NEXT_MODE_U\t\t0x0\n#define FW_DYNAMIC_INFO_NEXT_MODE_S\t\t0x1\n#define FW_DYNAMIC_INFO_NEXT_MODE_M\t\t0x3\n\n/* clang-format on */\n\n#ifndef __ASSEMBLER__\n\n#include <sbi/sbi_types.h>\n\n/** Representation dynamic info passed by previous booting stage */\nstruct fw_dynamic_info {\n\t/** Info magic */\n\tunsigned long magic;\n\t/** Info version */\n\tunsigned long version;\n\t/** Next booting stage address */\n\tunsigned long next_addr;\n\t/** Next booting stage mode */\n\tunsigned long next_mode;\n\t/** Options for OpenSBI library */\n\tunsigned long options;\n\t/**\n\t * Preferred boot HART id\n\t *\n\t * It is possible that the previous booting stage uses same link\n\t * address as the FW_DYNAMIC firmware. In this case, the relocation\n\t * lottery mechanism can potentially overwrite the previous booting\n\t * stage while other HARTs are still running in the previous booting\n\t * stage leading to boot-time crash. To avoid this boot-time crash,\n\t * the previous booting stage can specify last HART that will jump\n\t * to the FW_DYNAMIC firmware as the preferred boot HART.\n\t *\n\t * To avoid specifying a preferred boot HART, the previous booting\n\t * stage can set it to -1UL which will force the FW_DYNAMIC firmware\n\t * to use the relocation lottery mechanism.\n\t */\n\tunsigned long boot_hart;\n} __packed;\n\n/**\n * Prevent modification of struct fw_dynamic_info from affecting\n * FW_DYNAMIC_INFO_xxx_OFFSET\n */\n_Static_assert(\n\toffsetof(struct fw_dynamic_info, magic)\n\t\t== FW_DYNAMIC_INFO_MAGIC_OFFSET,\n\t\"struct fw_dynamic_info definition has changed, please redefine \"\n\t\"FW_DYNAMIC_INFO_MAGIC_OFFSET\");\n_Static_assert(\n\toffsetof(struct fw_dynamic_info, version)\n\t\t== FW_DYNAMIC_INFO_VERSION_OFFSET,\n\t\"struct fw_dynamic_info definition has changed, please redefine \"\n\t\"FW_DYNAMIC_INFO_VERSION_OFFSET\");\n_Static_assert(\n\toffsetof(struct fw_dynamic_info, next_addr)\n\t\t== FW_DYNAMIC_INFO_NEXT_ADDR_OFFSET,\n\t\"struct fw_dynamic_info definition has changed, please redefine \"\n\t\"FW_DYNAMIC_INFO_NEXT_ADDR_OFFSET\");\n_Static_assert(\n\toffsetof(struct fw_dynamic_info, next_mode)\n\t\t== FW_DYNAMIC_INFO_NEXT_MODE_OFFSET,\n\t\"struct fw_dynamic_info definition has changed, please redefine \"\n\t\"FW_DYNAMIC_INFO_NEXT_MODE_OFFSET\");\n_Static_assert(\n\toffsetof(struct fw_dynamic_info, options)\n\t\t== FW_DYNAMIC_INFO_OPTIONS_OFFSET,\n\t\"struct fw_dynamic_info definition has changed, please redefine \"\n\t\"FW_DYNAMIC_INFO_OPTIONS_OFFSET\");\n_Static_assert(\n\toffsetof(struct fw_dynamic_info, boot_hart)\n\t\t== FW_DYNAMIC_INFO_BOOT_HART_OFFSET,\n\t\"struct fw_dynamic_info definition has changed, please redefine \"\n\t\"FW_DYNAMIC_INFO_BOOT_HART_OFFSET\");\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/riscv_asm.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __RISCV_ASM_H__\n#define __RISCV_ASM_H__\n\n#include <sbi/riscv_encoding.h>\n\n/* clang-format off */\n\n#ifdef __ASSEMBLER__\n#define __ASM_STR(x)\tx\n#else\n#define __ASM_STR(x)\t#x\n#endif\n\n#if __riscv_xlen == 64\n#define __REG_SEL(a, b)\t__ASM_STR(a)\n#elif __riscv_xlen == 32\n#define __REG_SEL(a, b)\t__ASM_STR(b)\n#else\n#error \"Unexpected __riscv_xlen\"\n#endif\n\n#define PAGE_SHIFT\t(12)\n#define PAGE_SIZE\t(_AC(1, UL) << PAGE_SHIFT)\n#define PAGE_MASK\t(~(PAGE_SIZE - 1))\n\n#define REG_L\t\t__REG_SEL(ld, lw)\n#define REG_S\t\t__REG_SEL(sd, sw)\n#define SZREG\t\t__REG_SEL(8, 4)\n#define LGREG\t\t__REG_SEL(3, 2)\n\n#if __SIZEOF_POINTER__ == 8\n#ifdef __ASSEMBLER__\n#define RISCV_PTR\t\t.dword\n#define RISCV_SZPTR\t\t8\n#define RISCV_LGPTR\t\t3\n#else\n#define RISCV_PTR\t\t\".dword\"\n#define RISCV_SZPTR\t\t\"8\"\n#define RISCV_LGPTR\t\t\"3\"\n#endif\n#elif __SIZEOF_POINTER__ == 4\n#ifdef __ASSEMBLER__\n#define RISCV_PTR\t\t.word\n#define RISCV_SZPTR\t\t4\n#define RISCV_LGPTR\t\t2\n#else\n#define RISCV_PTR\t\t\".word\"\n#define RISCV_SZPTR\t\t\"4\"\n#define RISCV_LGPTR\t\t\"2\"\n#endif\n#else\n#error \"Unexpected __SIZEOF_POINTER__\"\n#endif\n\n#if (__SIZEOF_INT__ == 4)\n#define RISCV_INT\t\t__ASM_STR(.word)\n#define RISCV_SZINT\t\t__ASM_STR(4)\n#define RISCV_LGINT\t\t__ASM_STR(2)\n#else\n#error \"Unexpected __SIZEOF_INT__\"\n#endif\n\n#if (__SIZEOF_SHORT__ == 2)\n#define RISCV_SHORT\t\t__ASM_STR(.half)\n#define RISCV_SZSHORT\t\t__ASM_STR(2)\n#define RISCV_LGSHORT\t\t__ASM_STR(1)\n#else\n#error \"Unexpected __SIZEOF_SHORT__\"\n#endif\n\n/* clang-format on */\n\n#ifndef __ASSEMBLER__\n\n#define csr_swap(csr, val)                                              \\\n\t({                                                              \\\n\t\tunsigned long __v = (unsigned long)(val);               \\\n\t\t__asm__ __volatile__(\"csrrw %0, \" __ASM_STR(csr) \", %1\" \\\n\t\t\t\t     : \"=r\"(__v)                        \\\n\t\t\t\t     : \"rK\"(__v)                        \\\n\t\t\t\t     : \"memory\");                       \\\n\t\t__v;                                                    \\\n\t})\n\n#define csr_read(csr)                                           \\\n\t({                                                      \\\n\t\tregister unsigned long __v;                     \\\n\t\t__asm__ __volatile__(\"csrr %0, \" __ASM_STR(csr) \\\n\t\t\t\t     : \"=r\"(__v)                \\\n\t\t\t\t     :                          \\\n\t\t\t\t     : \"memory\");               \\\n\t\t__v;                                            \\\n\t})\n\n#define csr_write(csr, val)                                        \\\n\t({                                                         \\\n\t\tunsigned long __v = (unsigned long)(val);          \\\n\t\t__asm__ __volatile__(\"csrw \" __ASM_STR(csr) \", %0\" \\\n\t\t\t\t     :                             \\\n\t\t\t\t     : \"rK\"(__v)                   \\\n\t\t\t\t     : \"memory\");                  \\\n\t})\n\n#define csr_read_set(csr, val)                                          \\\n\t({                                                              \\\n\t\tunsigned long __v = (unsigned long)(val);               \\\n\t\t__asm__ __volatile__(\"csrrs %0, \" __ASM_STR(csr) \", %1\" \\\n\t\t\t\t     : \"=r\"(__v)                        \\\n\t\t\t\t     : \"rK\"(__v)                        \\\n\t\t\t\t     : \"memory\");                       \\\n\t\t__v;                                                    \\\n\t})\n\n#define csr_set(csr, val)                                          \\\n\t({                                                         \\\n\t\tunsigned long __v = (unsigned long)(val);          \\\n\t\t__asm__ __volatile__(\"csrs \" __ASM_STR(csr) \", %0\" \\\n\t\t\t\t     :                             \\\n\t\t\t\t     : \"rK\"(__v)                   \\\n\t\t\t\t     : \"memory\");                  \\\n\t})\n\n#define csr_read_clear(csr, val)                                        \\\n\t({                                                              \\\n\t\tunsigned long __v = (unsigned long)(val);               \\\n\t\t__asm__ __volatile__(\"csrrc %0, \" __ASM_STR(csr) \", %1\" \\\n\t\t\t\t     : \"=r\"(__v)                        \\\n\t\t\t\t     : \"rK\"(__v)                        \\\n\t\t\t\t     : \"memory\");                       \\\n\t\t__v;                                                    \\\n\t})\n\n#define csr_clear(csr, val)                                        \\\n\t({                                                         \\\n\t\tunsigned long __v = (unsigned long)(val);          \\\n\t\t__asm__ __volatile__(\"csrc \" __ASM_STR(csr) \", %0\" \\\n\t\t\t\t     :                             \\\n\t\t\t\t     : \"rK\"(__v)                   \\\n\t\t\t\t     : \"memory\");                  \\\n\t})\n\nunsigned long csr_read_num(int csr_num);\n\nvoid csr_write_num(int csr_num, unsigned long val);\n\n#define wfi()                                             \\\n\tdo {                                              \\\n\t\t__asm__ __volatile__(\"wfi\" ::: \"memory\"); \\\n\t} while (0)\n\n#define ebreak()                                             \\\n\tdo {                                              \\\n\t\t__asm__ __volatile__(\"ebreak\" ::: \"memory\"); \\\n\t} while (0)\n\n/* Get current HART id */\n#define current_hartid()\t((unsigned int)csr_read(CSR_MHARTID))\n\n/* determine CPU extension, return non-zero support */\nint misa_extension_imp(char ext);\n\n#define misa_extension(c)\\\n({\\\n\t_Static_assert(((c >= 'A') && (c <= 'Z')),\\\n\t\t\"The parameter of misa_extension must be [A-Z]\");\\\n\tmisa_extension_imp(c);\\\n})\n\n/* Get MXL field of misa, return -1 on error */\nint misa_xlen(void);\n\n/* Get RISC-V ISA string representation */\nvoid misa_string(int xlen, char *out, unsigned int out_sz);\n\nint pmp_set(unsigned int n, unsigned long prot, unsigned long addr,\n\t    unsigned long log2len);\n\nint pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,\n\t    unsigned long *log2len);\n\n#endif /* !__ASSEMBLER__ */\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/riscv_atomic.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __RISCV_ATOMIC_H__\n#define __RISCV_ATOMIC_H__\n\ntypedef struct {\n\tvolatile long counter;\n} atomic_t;\n\n#define ATOMIC_INIT(_lptr, val) (_lptr)->counter = (val)\n\n#define ATOMIC_INITIALIZER(val)   \\\n\t{                         \\\n\t\t.counter = (val), \\\n\t}\n\nlong atomic_read(atomic_t *atom);\n\nvoid atomic_write(atomic_t *atom, long value);\n\nlong atomic_add_return(atomic_t *atom, long value);\n\nlong atomic_sub_return(atomic_t *atom, long value);\n\nlong atomic_cmpxchg(atomic_t *atom, long oldval, long newval);\n\nlong atomic_xchg(atomic_t *atom, long newval);\n\nunsigned int atomic_raw_xchg_uint(volatile unsigned int *ptr,\n\t\t\t\t  unsigned int newval);\n\nunsigned long atomic_raw_xchg_ulong(volatile unsigned long *ptr,\n\t\t\t\t    unsigned long newval);\n/**\n * Set a bit in an atomic variable and return the new value.\n * @nr : Bit to set.\n * @atom: atomic variable to modify\n */\nint atomic_set_bit(int nr, atomic_t *atom);\n\n/**\n * Clear a bit in an atomic variable and return the new value.\n * @nr : Bit to set.\n * @atom: atomic variable to modify\n */\n\nint atomic_clear_bit(int nr, atomic_t *atom);\n\n/**\n * Set a bit in any address and return the new value .\n * @nr : Bit to set.\n * @addr: Address to modify\n */\nint atomic_raw_set_bit(int nr, volatile unsigned long *addr);\n\n/**\n * Clear a bit in any address and return the new value .\n * @nr : Bit to set.\n * @addr: Address to modify\n */\nint atomic_raw_clear_bit(int nr, volatile unsigned long *addr);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/riscv_barrier.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __RISCV_BARRIER_H__\n#define __RISCV_BARRIER_H__\n\n/* clang-format off */\n\n#define RISCV_ACQUIRE_BARRIER\t\t\"\\tfence r , rw\\n\"\n#define RISCV_RELEASE_BARRIER\t\t\"\\tfence rw,  w\\n\"\n\n#define RISCV_FENCE(p, s) \\\n\t__asm__ __volatile__ (\"fence \" #p \",\" #s : : : \"memory\")\n\n#define RISCV_FENCE_I \\\n\t__asm__ __volatile__ (\"fence.i\" : : : \"memory\")\n\n/* Read & Write Memory barrier */\n#define mb()\t\t\tRISCV_FENCE(iorw,iorw)\n\n/* Read Memory barrier */\n#define rmb()\t\t\tRISCV_FENCE(ir,ir)\n\n/* Write Memory barrier */\n#define wmb()\t\t\tRISCV_FENCE(ow,ow)\n\n/* SMP Read & Write Memory barrier */\n#define smp_mb()\t\tRISCV_FENCE(rw,rw)\n\n/* SMP Read Memory barrier */\n#define smp_rmb()\t\tRISCV_FENCE(r,r)\n\n/* SMP Write Memory barrier */\n#define smp_wmb()\t\tRISCV_FENCE(w,w)\n\n/* CPU relax for busy loop */\n#define cpu_relax()\t\tasm volatile (\"\" : : : \"memory\")\n\n/* clang-format on */\n\n#define __smp_store_release(p, v)   \\\n\tdo {                        \\\n\t\tRISCV_FENCE(rw, w); \\\n\t\t*(p) = (v);         \\\n\t} while (0)\n\n#define __smp_load_acquire(p)            \\\n\t({                               \\\n\t\ttypeof(*p) ___p1 = *(p); \\\n\t\tRISCV_FENCE(r, rw);      \\\n\t\t___p1;                   \\\n\t})\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/riscv_elf.h",
    "content": "#ifndef __RISCV_ELF_H__\n#define __RISCV_ELF_H__\n\n#include <sbi/riscv_asm.h>\n\n#define R_RISCV_32\t\t1\n#define R_RISCV_64\t\t2\n#define R_RISCV_RELATIVE\t3\n\n#define RELOC_TYPE\t\t__REG_SEL(R_RISCV_64, R_RISCV_32)\n#define SYM_INDEX\t\t__REG_SEL(0x20,\t0x8)\n#define SYM_SIZE\t\t__REG_SEL(0x18,0x10)\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/riscv_encoding.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __RISCV_ENCODING_H__\n#define __RISCV_ENCODING_H__\n\n#include <sbi/sbi_const.h>\n\n/* clang-format off */\n#define MSTATUS_SIE\t\t\t_UL(0x00000002)\n#define MSTATUS_MIE\t\t\t_UL(0x00000008)\n#define MSTATUS_SPIE_SHIFT\t\t5\n#define MSTATUS_SPIE\t\t\t(_UL(1) << MSTATUS_SPIE_SHIFT)\n#define MSTATUS_UBE\t\t\t_UL(0x00000040)\n#define MSTATUS_MPIE\t\t\t_UL(0x00000080)\n#define MSTATUS_SPP_SHIFT\t\t8\n#define MSTATUS_SPP\t\t\t(_UL(1) << MSTATUS_SPP_SHIFT)\n#define MSTATUS_MPP_SHIFT\t\t11\n#define MSTATUS_MPP\t\t\t(_UL(3) << MSTATUS_MPP_SHIFT)\n#define MSTATUS_FS\t\t\t_UL(0x00006000)\n#define MSTATUS_XS\t\t\t_UL(0x00018000)\n#define MSTATUS_VS\t\t\t_UL(0x00000600)\n#define MSTATUS_MPRV\t\t\t_UL(0x00020000)\n#define MSTATUS_SUM\t\t\t_UL(0x00040000)\n#define MSTATUS_MXR\t\t\t_UL(0x00080000)\n#define MSTATUS_TVM\t\t\t_UL(0x00100000)\n#define MSTATUS_TW\t\t\t_UL(0x00200000)\n#define MSTATUS_TSR\t\t\t_UL(0x00400000)\n#define MSTATUS32_SD\t\t\t_UL(0x80000000)\n#if __riscv_xlen == 64\n#define MSTATUS_UXL\t\t\t_ULL(0x0000000300000000)\n#define MSTATUS_SXL\t\t\t_ULL(0x0000000C00000000)\n#define MSTATUS_SBE\t\t\t_ULL(0x0000001000000000)\n#define MSTATUS_MBE\t\t\t_ULL(0x0000002000000000)\n#define MSTATUS_GVA\t\t\t_ULL(0x0000004000000000)\n#define MSTATUS_GVA_SHIFT\t\t38\n#define MSTATUS_MPV\t\t\t_ULL(0x0000008000000000)\n#else\n#define MSTATUSH_SBE\t\t\t_UL(0x00000010)\n#define MSTATUSH_MBE\t\t\t_UL(0x00000020)\n#define MSTATUSH_GVA\t\t\t_UL(0x00000040)\n#define MSTATUSH_GVA_SHIFT\t\t6\n#define MSTATUSH_MPV\t\t\t_UL(0x00000080)\n#endif\n#define MSTATUS32_SD\t\t\t_UL(0x80000000)\n#define MSTATUS64_SD\t\t\t_ULL(0x8000000000000000)\n\n#define SSTATUS_SIE\t\t\tMSTATUS_SIE\n#define SSTATUS_SPIE_SHIFT\t\tMSTATUS_SPIE_SHIFT\n#define SSTATUS_SPIE\t\t\tMSTATUS_SPIE\n#define SSTATUS_SPP_SHIFT\t\tMSTATUS_SPP_SHIFT\n#define SSTATUS_SPP\t\t\tMSTATUS_SPP\n#define SSTATUS_FS\t\t\tMSTATUS_FS\n#define SSTATUS_XS\t\t\tMSTATUS_XS\n#define SSTATUS_VS\t\t\tMSTATUS_VS\n#define SSTATUS_SUM\t\t\tMSTATUS_SUM\n#define SSTATUS_MXR\t\t\tMSTATUS_MXR\n#define SSTATUS32_SD\t\t\tMSTATUS32_SD\n#define SSTATUS64_UXL\t\t\tMSTATUS_UXL\n#define SSTATUS64_SD\t\t\tMSTATUS64_SD\n\n#if __riscv_xlen == 64\n#define HSTATUS_VSXL\t\t\t_UL(0x300000000)\n#define HSTATUS_VSXL_SHIFT\t\t32\n#endif\n#define HSTATUS_VTSR\t\t\t_UL(0x00400000)\n#define HSTATUS_VTW\t\t\t_UL(0x00200000)\n#define HSTATUS_VTVM\t\t\t_UL(0x00100000)\n#define HSTATUS_VGEIN\t\t\t_UL(0x0003f000)\n#define HSTATUS_VGEIN_SHIFT\t\t12\n#define HSTATUS_HU\t\t\t_UL(0x00000200)\n#define HSTATUS_SPVP\t\t\t_UL(0x00000100)\n#define HSTATUS_SPV\t\t\t_UL(0x00000080)\n#define HSTATUS_GVA\t\t\t_UL(0x00000040)\n#define HSTATUS_VSBE\t\t\t_UL(0x00000020)\n\n#define IRQ_S_SOFT\t\t\t1\n#define IRQ_VS_SOFT\t\t\t2\n#define IRQ_M_SOFT\t\t\t3\n#define IRQ_S_TIMER\t\t\t5\n#define IRQ_VS_TIMER\t\t\t6\n#define IRQ_M_TIMER\t\t\t7\n#define IRQ_S_EXT\t\t\t9\n#define IRQ_VS_EXT\t\t\t10\n#define IRQ_M_EXT\t\t\t11\n#define IRQ_S_GEXT\t\t\t12\n#define IRQ_PMU_OVF\t\t\t13\n\n#define MIP_SSIP\t\t\t(_UL(1) << IRQ_S_SOFT)\n#define MIP_VSSIP\t\t\t(_UL(1) << IRQ_VS_SOFT)\n#define MIP_MSIP\t\t\t(_UL(1) << IRQ_M_SOFT)\n#define MIP_STIP\t\t\t(_UL(1) << IRQ_S_TIMER)\n#define MIP_VSTIP\t\t\t(_UL(1) << IRQ_VS_TIMER)\n#define MIP_MTIP\t\t\t(_UL(1) << IRQ_M_TIMER)\n#define MIP_SEIP\t\t\t(_UL(1) << IRQ_S_EXT)\n#define MIP_VSEIP\t\t\t(_UL(1) << IRQ_VS_EXT)\n#define MIP_MEIP\t\t\t(_UL(1) << IRQ_M_EXT)\n#define MIP_SGEIP\t\t\t(_UL(1) << IRQ_S_GEXT)\n#define MIP_LCOFIP\t\t\t(_UL(1) << IRQ_PMU_OVF)\n\n#define SIP_SSIP\t\t\tMIP_SSIP\n#define SIP_STIP\t\t\tMIP_STIP\n\n#define PRV_U\t\t\t\t_UL(0)\n#define PRV_S\t\t\t\t_UL(1)\n#define PRV_M\t\t\t\t_UL(3)\n\n#define SATP32_MODE\t\t\t_UL(0x80000000)\n#define SATP32_ASID\t\t\t_UL(0x7FC00000)\n#define SATP32_PPN\t\t\t_UL(0x003FFFFF)\n#define SATP64_MODE\t\t\t_ULL(0xF000000000000000)\n#define SATP64_ASID\t\t\t_ULL(0x0FFFF00000000000)\n#define SATP64_PPN\t\t\t_ULL(0x00000FFFFFFFFFFF)\n\n#define SATP_MODE_OFF\t\t\t_UL(0)\n#define SATP_MODE_SV32\t\t\t_UL(1)\n#define SATP_MODE_SV39\t\t\t_UL(8)\n#define SATP_MODE_SV48\t\t\t_UL(9)\n#define SATP_MODE_SV57\t\t\t_UL(10)\n#define SATP_MODE_SV64\t\t\t_UL(11)\n\n#define HGATP_MODE_OFF\t\t\t_UL(0)\n#define HGATP_MODE_SV32X4\t\t_UL(1)\n#define HGATP_MODE_SV39X4\t\t_UL(8)\n#define HGATP_MODE_SV48X4\t\t_UL(9)\n\n#define HGATP32_MODE_SHIFT\t\t31\n#define HGATP32_VMID_SHIFT\t\t22\n#define HGATP32_VMID_MASK\t\t_UL(0x1FC00000)\n#define HGATP32_PPN\t\t\t_UL(0x003FFFFF)\n\n#define HGATP64_MODE_SHIFT\t\t60\n#define HGATP64_VMID_SHIFT\t\t44\n#define HGATP64_VMID_MASK\t\t_ULL(0x03FFF00000000000)\n#define HGATP64_PPN\t\t\t_ULL(0x00000FFFFFFFFFFF)\n\n#define PMP_R\t\t\t\t_UL(0x01)\n#define PMP_W\t\t\t\t_UL(0x02)\n#define PMP_X\t\t\t\t_UL(0x04)\n#define PMP_A\t\t\t\t_UL(0x18)\n#define PMP_A_TOR\t\t\t_UL(0x08)\n#define PMP_A_NA4\t\t\t_UL(0x10)\n#define PMP_A_NAPOT\t\t\t_UL(0x18)\n#define PMP_L\t\t\t\t_UL(0x80)\n\n#define PMP_SHIFT\t\t\t2\n#define PMP_COUNT\t\t\t64\n#if __riscv_xlen == 64\n#define PMP_ADDR_MASK\t\t\t((_ULL(0x1) << 54) - 1)\n#else\n#define PMP_ADDR_MASK\t\t\t_UL(0xFFFFFFFF)\n#endif\n\n#if __riscv_xlen == 64\n#define MSTATUS_SD\t\t\tMSTATUS64_SD\n#define SSTATUS_SD\t\t\tSSTATUS64_SD\n#define SATP_MODE\t\t\tSATP64_MODE\n\n#define HGATP_PPN\t\t\tHGATP64_PPN\n#define HGATP_VMID_SHIFT\t\tHGATP64_VMID_SHIFT\n#define HGATP_VMID_MASK\t\t\tHGATP64_VMID_MASK\n#define HGATP_MODE_SHIFT\t\tHGATP64_MODE_SHIFT\n#else\n#define MSTATUS_SD\t\t\tMSTATUS32_SD\n#define SSTATUS_SD\t\t\tSSTATUS32_SD\n#define SATP_MODE\t\t\tSATP32_MODE\n\n#define HGATP_PPN\t\t\tHGATP32_PPN\n#define HGATP_VMID_SHIFT\t\tHGATP32_VMID_SHIFT\n#define HGATP_VMID_MASK\t\t\tHGATP32_VMID_MASK\n#define HGATP_MODE_SHIFT\t\tHGATP32_MODE_SHIFT\n#endif\n\n#define TOPI_IID_SHIFT\t\t\t16\n#define TOPI_IID_MASK\t\t\t0xfff\n#define TOPI_IPRIO_MASK\t\t0xff\n\n#if __riscv_xlen == 64\n#define MHPMEVENT_OF\t\t\t(_UL(1) << 63)\n#define MHPMEVENT_MINH\t\t\t(_UL(1) << 62)\n#define MHPMEVENT_SINH\t\t\t(_UL(1) << 61)\n#define MHPMEVENT_UINH\t\t\t(_UL(1) << 60)\n#define MHPMEVENT_VSINH\t\t\t(_UL(1) << 59)\n#define MHPMEVENT_VUINH\t\t\t(_UL(1) << 58)\n#else\n#define MHPMEVENTH_OF\t\t\t(_ULL(1) << 31)\n#define MHPMEVENTH_MINH\t\t\t(_ULL(1) << 30)\n#define MHPMEVENTH_SINH\t\t\t(_ULL(1) << 29)\n#define MHPMEVENTH_UINH\t\t\t(_ULL(1) << 28)\n#define MHPMEVENTH_VSINH\t\t(_ULL(1) << 27)\n#define MHPMEVENTH_VUINH\t\t(_ULL(1) << 26)\n\n#define MHPMEVENT_OF\t\t\t(MHPMEVENTH_OF << 32)\n#define MHPMEVENT_MINH\t\t\t(MHPMEVENTH_MINH << 32)\n#define MHPMEVENT_SINH\t\t\t(MHPMEVENTH_SINH << 32)\n#define MHPMEVENT_UINH\t\t\t(MHPMEVENTH_UINH << 32)\n#define MHPMEVENT_VSINH\t\t\t(MHPMEVENTH_VSINH << 32)\n#define MHPMEVENT_VUINH\t\t\t(MHPMEVENTH_VUINH << 32)\n\n#endif\n\n#define MHPMEVENT_SSCOF_MASK\t\t_ULL(0xFFFF000000000000)\n\n#if __riscv_xlen > 32\n#define ENVCFG_STCE\t\t\t(_ULL(1) << 63)\n#define ENVCFG_PBMTE\t\t\t(_ULL(1) << 62)\n#else\n#define ENVCFGH_STCE\t\t\t(_UL(1) << 31)\n#define ENVCFGH_PBMTE\t\t\t(_UL(1) << 30)\n#endif\n#define ENVCFG_CBZE\t\t\t(_UL(1) << 7)\n#define ENVCFG_CBCFE\t\t\t(_UL(1) << 6)\n#define ENVCFG_CBIE_SHIFT\t\t4\n#define ENVCFG_CBIE\t\t\t(_UL(0x3) << ENVCFG_CBIE_SHIFT)\n#define ENVCFG_CBIE_ILL\t\t\t_UL(0x0)\n#define ENVCFG_CBIE_FLUSH\t\t_UL(0x1)\n#define ENVCFG_CBIE_INV\t\t\t_UL(0x3)\n#define ENVCFG_FIOM\t\t\t_UL(0x1)\n\n/* ===== User-level CSRs ===== */\n\n/* User Trap Setup (N-extension) */\n#define CSR_USTATUS\t\t\t0x000\n#define CSR_UIE\t\t\t\t0x004\n#define CSR_UTVEC\t\t\t0x005\n\n/* User Trap Handling (N-extension) */\n#define CSR_USCRATCH\t\t\t0x040\n#define CSR_UEPC\t\t\t0x041\n#define CSR_UCAUSE\t\t\t0x042\n#define CSR_UTVAL\t\t\t0x043\n#define CSR_UIP\t\t\t\t0x044\n\n/* User Floating-point CSRs */\n#define CSR_FFLAGS\t\t\t0x001\n#define CSR_FRM\t\t\t\t0x002\n#define CSR_FCSR\t\t\t0x003\n\n/* User Counters/Timers */\n#define CSR_CYCLE\t\t\t0xc00\n#define CSR_TIME\t\t\t0xc01\n#define CSR_INSTRET\t\t\t0xc02\n#define CSR_HPMCOUNTER3\t\t\t0xc03\n#define CSR_HPMCOUNTER4\t\t\t0xc04\n#define CSR_HPMCOUNTER5\t\t\t0xc05\n#define CSR_HPMCOUNTER6\t\t\t0xc06\n#define CSR_HPMCOUNTER7\t\t\t0xc07\n#define CSR_HPMCOUNTER8\t\t\t0xc08\n#define CSR_HPMCOUNTER9\t\t\t0xc09\n#define CSR_HPMCOUNTER10\t\t0xc0a\n#define CSR_HPMCOUNTER11\t\t0xc0b\n#define CSR_HPMCOUNTER12\t\t0xc0c\n#define CSR_HPMCOUNTER13\t\t0xc0d\n#define CSR_HPMCOUNTER14\t\t0xc0e\n#define CSR_HPMCOUNTER15\t\t0xc0f\n#define CSR_HPMCOUNTER16\t\t0xc10\n#define CSR_HPMCOUNTER17\t\t0xc11\n#define CSR_HPMCOUNTER18\t\t0xc12\n#define CSR_HPMCOUNTER19\t\t0xc13\n#define CSR_HPMCOUNTER20\t\t0xc14\n#define CSR_HPMCOUNTER21\t\t0xc15\n#define CSR_HPMCOUNTER22\t\t0xc16\n#define CSR_HPMCOUNTER23\t\t0xc17\n#define CSR_HPMCOUNTER24\t\t0xc18\n#define CSR_HPMCOUNTER25\t\t0xc19\n#define CSR_HPMCOUNTER26\t\t0xc1a\n#define CSR_HPMCOUNTER27\t\t0xc1b\n#define CSR_HPMCOUNTER28\t\t0xc1c\n#define CSR_HPMCOUNTER29\t\t0xc1d\n#define CSR_HPMCOUNTER30\t\t0xc1e\n#define CSR_HPMCOUNTER31\t\t0xc1f\n#define CSR_CYCLEH\t\t\t0xc80\n#define CSR_TIMEH\t\t\t0xc81\n#define CSR_INSTRETH\t\t\t0xc82\n#define CSR_HPMCOUNTER3H\t\t0xc83\n#define CSR_HPMCOUNTER4H\t\t0xc84\n#define CSR_HPMCOUNTER5H\t\t0xc85\n#define CSR_HPMCOUNTER6H\t\t0xc86\n#define CSR_HPMCOUNTER7H\t\t0xc87\n#define CSR_HPMCOUNTER8H\t\t0xc88\n#define CSR_HPMCOUNTER9H\t\t0xc89\n#define CSR_HPMCOUNTER10H\t\t0xc8a\n#define CSR_HPMCOUNTER11H\t\t0xc8b\n#define CSR_HPMCOUNTER12H\t\t0xc8c\n#define CSR_HPMCOUNTER13H\t\t0xc8d\n#define CSR_HPMCOUNTER14H\t\t0xc8e\n#define CSR_HPMCOUNTER15H\t\t0xc8f\n#define CSR_HPMCOUNTER16H\t\t0xc90\n#define CSR_HPMCOUNTER17H\t\t0xc91\n#define CSR_HPMCOUNTER18H\t\t0xc92\n#define CSR_HPMCOUNTER19H\t\t0xc93\n#define CSR_HPMCOUNTER20H\t\t0xc94\n#define CSR_HPMCOUNTER21H\t\t0xc95\n#define CSR_HPMCOUNTER22H\t\t0xc96\n#define CSR_HPMCOUNTER23H\t\t0xc97\n#define CSR_HPMCOUNTER24H\t\t0xc98\n#define CSR_HPMCOUNTER25H\t\t0xc99\n#define CSR_HPMCOUNTER26H\t\t0xc9a\n#define CSR_HPMCOUNTER27H\t\t0xc9b\n#define CSR_HPMCOUNTER28H\t\t0xc9c\n#define CSR_HPMCOUNTER29H\t\t0xc9d\n#define CSR_HPMCOUNTER30H\t\t0xc9e\n#define CSR_HPMCOUNTER31H\t\t0xc9f\n\n/* ===== Supervisor-level CSRs ===== */\n\n/* Supervisor Trap Setup */\n#define CSR_SSTATUS\t\t\t0x100\n#define CSR_SIE\t\t\t\t0x104\n#define CSR_STVEC\t\t\t0x105\n#define CSR_SCOUNTEREN\t\t\t0x106\n\n/* Supervisor Configuration */\n#define CSR_SENVCFG\t\t\t0x10a\n\n/* Supervisor Trap Handling */\n#define CSR_SSCRATCH\t\t\t0x140\n#define CSR_SEPC\t\t\t0x141\n#define CSR_SCAUSE\t\t\t0x142\n#define CSR_STVAL\t\t\t0x143\n#define CSR_SIP\t\t\t\t0x144\n\n/* Sstc extension */\n#define CSR_STIMECMP\t\t\t0x14D\n#define CSR_STIMECMPH\t\t\t0x15D\n\n/* Supervisor Protection and Translation */\n#define CSR_SATP\t\t\t0x180\n\n/* Supervisor-Level Window to Indirectly Accessed Registers (AIA) */\n#define CSR_SISELECT\t\t\t0x150\n#define CSR_SIREG\t\t\t0x151\n\n/* Supervisor-Level Interrupts (AIA) */\n#define CSR_STOPEI\t\t\t0x15c\n#define CSR_STOPI\t\t\t0xdb0\n\n/* Supervisor-Level High-Half CSRs (AIA) */\n#define CSR_SIEH\t\t\t0x114\n#define CSR_SIPH\t\t\t0x154\n\n/* Supervisor stateen CSRs */\n#define CSR_SSTATEEN0\t\t\t0x10C\n#define CSR_SSTATEEN1\t\t\t0x10D\n#define CSR_SSTATEEN2\t\t\t0x10E\n#define CSR_SSTATEEN3\t\t\t0x10F\n\n/* ===== Hypervisor-level CSRs ===== */\n\n/* Hypervisor Trap Setup (H-extension) */\n#define CSR_HSTATUS\t\t\t0x600\n#define CSR_HEDELEG\t\t\t0x602\n#define CSR_HIDELEG\t\t\t0x603\n#define CSR_HIE\t\t\t\t0x604\n#define CSR_HCOUNTEREN\t\t\t0x606\n#define CSR_HGEIE\t\t\t0x607\n\n/* Hypervisor Configuration */\n#define CSR_HENVCFG\t\t\t0x60a\n#define CSR_HENVCFGH\t\t\t0x61a\n\n/* Hypervisor Trap Handling (H-extension) */\n#define CSR_HTVAL\t\t\t0x643\n#define CSR_HIP\t\t\t\t0x644\n#define CSR_HVIP\t\t\t0x645\n#define CSR_HTINST\t\t\t0x64a\n#define CSR_HGEIP\t\t\t0xe12\n\n/* Hypervisor Protection and Translation (H-extension) */\n#define CSR_HGATP\t\t\t0x680\n\n/* Hypervisor Counter/Timer Virtualization Registers (H-extension) */\n#define CSR_HTIMEDELTA\t\t\t0x605\n#define CSR_HTIMEDELTAH\t\t\t0x615\n\n/* Virtual Supervisor Registers (H-extension) */\n#define CSR_VSSTATUS\t\t\t0x200\n#define CSR_VSIE\t\t\t0x204\n#define CSR_VSTVEC\t\t\t0x205\n#define CSR_VSSCRATCH\t\t\t0x240\n#define CSR_VSEPC\t\t\t0x241\n#define CSR_VSCAUSE\t\t\t0x242\n#define CSR_VSTVAL\t\t\t0x243\n#define CSR_VSIP\t\t\t0x244\n#define CSR_VSATP\t\t\t0x280\n\n/* Virtual Interrupts and Interrupt Priorities (H-extension with AIA) */\n#define CSR_HVIEN\t\t\t0x608\n#define CSR_HVICTL\t\t\t0x609\n#define CSR_HVIPRIO1\t\t\t0x646\n#define CSR_HVIPRIO2\t\t\t0x647\n\n/* VS-Level Window to Indirectly Accessed Registers (H-extension with AIA) */\n#define CSR_VSISELECT\t\t\t0x250\n#define CSR_VSIREG\t\t\t0x251\n\n/* VS-Level Interrupts (H-extension with AIA) */\n#define CSR_VSTOPEI\t\t\t0x25c\n#define CSR_VSTOPI\t\t\t0xeb0\n\n/* Hypervisor and VS-Level High-Half CSRs (H-extension with AIA) */\n#define CSR_HIDELEGH\t\t\t0x613\n#define CSR_HVIENH\t\t\t0x618\n#define CSR_HVIPH\t\t\t0x655\n#define CSR_HVIPRIO1H\t\t\t0x656\n#define CSR_HVIPRIO2H\t\t\t0x657\n#define CSR_VSIEH\t\t\t0x214\n#define CSR_VSIPH\t\t\t0x254\n\n/* Hypervisor stateen CSRs */\n#define CSR_HSTATEEN0\t\t\t0x60C\n#define CSR_HSTATEEN0H\t\t\t0x61C\n#define CSR_HSTATEEN1\t\t\t0x60D\n#define CSR_HSTATEEN1H\t\t\t0x61D\n#define CSR_HSTATEEN2\t\t\t0x60E\n#define CSR_HSTATEEN2H\t\t\t0x61E\n#define CSR_HSTATEEN3\t\t\t0x60F\n#define CSR_HSTATEEN3H\t\t\t0x61F\n\n/* ===== Machine-level CSRs ===== */\n\n/* Machine Information Registers */\n#define CSR_MVENDORID\t\t\t0xf11\n#define CSR_MARCHID\t\t\t0xf12\n#define CSR_MIMPID\t\t\t0xf13\n#define CSR_MHARTID\t\t\t0xf14\n\n/* Machine Trap Setup */\n#define CSR_MSTATUS\t\t\t0x300\n#define CSR_MISA\t\t\t0x301\n#define CSR_MEDELEG\t\t\t0x302\n#define CSR_MIDELEG\t\t\t0x303\n#define CSR_MIE\t\t\t\t0x304\n#define CSR_MTVEC\t\t\t0x305\n#define CSR_MCOUNTEREN\t\t\t0x306\n#define CSR_MSTATUSH\t\t\t0x310\n\n/* Machine Configuration */\n#define CSR_MENVCFG\t\t\t0x30a\n#define CSR_MENVCFGH\t\t\t0x31a\n\n/* Machine Trap Handling */\n#define CSR_MSCRATCH\t\t\t0x340\n#define CSR_MEPC\t\t\t0x341\n#define CSR_MCAUSE\t\t\t0x342\n#define CSR_MTVAL\t\t\t0x343\n#define CSR_MIP\t\t\t\t0x344\n#define CSR_MTINST\t\t\t0x34a\n#define CSR_MTVAL2\t\t\t0x34b\n\n/* Machine Memory Protection */\n#define CSR_PMPCFG0\t\t\t0x3a0\n#define CSR_PMPCFG1\t\t\t0x3a1\n#define CSR_PMPCFG2\t\t\t0x3a2\n#define CSR_PMPCFG3\t\t\t0x3a3\n#define CSR_PMPCFG4\t\t\t0x3a4\n#define CSR_PMPCFG5\t\t\t0x3a5\n#define CSR_PMPCFG6\t\t\t0x3a6\n#define CSR_PMPCFG7\t\t\t0x3a7\n#define CSR_PMPCFG8\t\t\t0x3a8\n#define CSR_PMPCFG9\t\t\t0x3a9\n#define CSR_PMPCFG10\t\t\t0x3aa\n#define CSR_PMPCFG11\t\t\t0x3ab\n#define CSR_PMPCFG12\t\t\t0x3ac\n#define CSR_PMPCFG13\t\t\t0x3ad\n#define CSR_PMPCFG14\t\t\t0x3ae\n#define CSR_PMPCFG15\t\t\t0x3af\n#define CSR_PMPADDR0\t\t\t0x3b0\n#define CSR_PMPADDR1\t\t\t0x3b1\n#define CSR_PMPADDR2\t\t\t0x3b2\n#define CSR_PMPADDR3\t\t\t0x3b3\n#define CSR_PMPADDR4\t\t\t0x3b4\n#define CSR_PMPADDR5\t\t\t0x3b5\n#define CSR_PMPADDR6\t\t\t0x3b6\n#define CSR_PMPADDR7\t\t\t0x3b7\n#define CSR_PMPADDR8\t\t\t0x3b8\n#define CSR_PMPADDR9\t\t\t0x3b9\n#define CSR_PMPADDR10\t\t\t0x3ba\n#define CSR_PMPADDR11\t\t\t0x3bb\n#define CSR_PMPADDR12\t\t\t0x3bc\n#define CSR_PMPADDR13\t\t\t0x3bd\n#define CSR_PMPADDR14\t\t\t0x3be\n#define CSR_PMPADDR15\t\t\t0x3bf\n#define CSR_PMPADDR16\t\t\t0x3c0\n#define CSR_PMPADDR17\t\t\t0x3c1\n#define CSR_PMPADDR18\t\t\t0x3c2\n#define CSR_PMPADDR19\t\t\t0x3c3\n#define CSR_PMPADDR20\t\t\t0x3c4\n#define CSR_PMPADDR21\t\t\t0x3c5\n#define CSR_PMPADDR22\t\t\t0x3c6\n#define CSR_PMPADDR23\t\t\t0x3c7\n#define CSR_PMPADDR24\t\t\t0x3c8\n#define CSR_PMPADDR25\t\t\t0x3c9\n#define CSR_PMPADDR26\t\t\t0x3ca\n#define CSR_PMPADDR27\t\t\t0x3cb\n#define CSR_PMPADDR28\t\t\t0x3cc\n#define CSR_PMPADDR29\t\t\t0x3cd\n#define CSR_PMPADDR30\t\t\t0x3ce\n#define CSR_PMPADDR31\t\t\t0x3cf\n#define CSR_PMPADDR32\t\t\t0x3d0\n#define CSR_PMPADDR33\t\t\t0x3d1\n#define CSR_PMPADDR34\t\t\t0x3d2\n#define CSR_PMPADDR35\t\t\t0x3d3\n#define CSR_PMPADDR36\t\t\t0x3d4\n#define CSR_PMPADDR37\t\t\t0x3d5\n#define CSR_PMPADDR38\t\t\t0x3d6\n#define CSR_PMPADDR39\t\t\t0x3d7\n#define CSR_PMPADDR40\t\t\t0x3d8\n#define CSR_PMPADDR41\t\t\t0x3d9\n#define CSR_PMPADDR42\t\t\t0x3da\n#define CSR_PMPADDR43\t\t\t0x3db\n#define CSR_PMPADDR44\t\t\t0x3dc\n#define CSR_PMPADDR45\t\t\t0x3dd\n#define CSR_PMPADDR46\t\t\t0x3de\n#define CSR_PMPADDR47\t\t\t0x3df\n#define CSR_PMPADDR48\t\t\t0x3e0\n#define CSR_PMPADDR49\t\t\t0x3e1\n#define CSR_PMPADDR50\t\t\t0x3e2\n#define CSR_PMPADDR51\t\t\t0x3e3\n#define CSR_PMPADDR52\t\t\t0x3e4\n#define CSR_PMPADDR53\t\t\t0x3e5\n#define CSR_PMPADDR54\t\t\t0x3e6\n#define CSR_PMPADDR55\t\t\t0x3e7\n#define CSR_PMPADDR56\t\t\t0x3e8\n#define CSR_PMPADDR57\t\t\t0x3e9\n#define CSR_PMPADDR58\t\t\t0x3ea\n#define CSR_PMPADDR59\t\t\t0x3eb\n#define CSR_PMPADDR60\t\t\t0x3ec\n#define CSR_PMPADDR61\t\t\t0x3ed\n#define CSR_PMPADDR62\t\t\t0x3ee\n#define CSR_PMPADDR63\t\t\t0x3ef\n\n/* Machine Counters/Timers */\n#define CSR_MCYCLE\t\t\t0xb00\n#define CSR_MINSTRET\t\t\t0xb02\n#define CSR_MHPMCOUNTER3\t\t0xb03\n#define CSR_MHPMCOUNTER4\t\t0xb04\n#define CSR_MHPMCOUNTER5\t\t0xb05\n#define CSR_MHPMCOUNTER6\t\t0xb06\n#define CSR_MHPMCOUNTER7\t\t0xb07\n#define CSR_MHPMCOUNTER8\t\t0xb08\n#define CSR_MHPMCOUNTER9\t\t0xb09\n#define CSR_MHPMCOUNTER10\t\t0xb0a\n#define CSR_MHPMCOUNTER11\t\t0xb0b\n#define CSR_MHPMCOUNTER12\t\t0xb0c\n#define CSR_MHPMCOUNTER13\t\t0xb0d\n#define CSR_MHPMCOUNTER14\t\t0xb0e\n#define CSR_MHPMCOUNTER15\t\t0xb0f\n#define CSR_MHPMCOUNTER16\t\t0xb10\n#define CSR_MHPMCOUNTER17\t\t0xb11\n#define CSR_MHPMCOUNTER18\t\t0xb12\n#define CSR_MHPMCOUNTER19\t\t0xb13\n#define CSR_MHPMCOUNTER20\t\t0xb14\n#define CSR_MHPMCOUNTER21\t\t0xb15\n#define CSR_MHPMCOUNTER22\t\t0xb16\n#define CSR_MHPMCOUNTER23\t\t0xb17\n#define CSR_MHPMCOUNTER24\t\t0xb18\n#define CSR_MHPMCOUNTER25\t\t0xb19\n#define CSR_MHPMCOUNTER26\t\t0xb1a\n#define CSR_MHPMCOUNTER27\t\t0xb1b\n#define CSR_MHPMCOUNTER28\t\t0xb1c\n#define CSR_MHPMCOUNTER29\t\t0xb1d\n#define CSR_MHPMCOUNTER30\t\t0xb1e\n#define CSR_MHPMCOUNTER31\t\t0xb1f\n#define CSR_MCYCLEH\t\t\t0xb80\n#define CSR_MINSTRETH\t\t\t0xb82\n#define CSR_MHPMCOUNTER3H\t\t0xb83\n#define CSR_MHPMCOUNTER4H\t\t0xb84\n#define CSR_MHPMCOUNTER5H\t\t0xb85\n#define CSR_MHPMCOUNTER6H\t\t0xb86\n#define CSR_MHPMCOUNTER7H\t\t0xb87\n#define CSR_MHPMCOUNTER8H\t\t0xb88\n#define CSR_MHPMCOUNTER9H\t\t0xb89\n#define CSR_MHPMCOUNTER10H\t\t0xb8a\n#define CSR_MHPMCOUNTER11H\t\t0xb8b\n#define CSR_MHPMCOUNTER12H\t\t0xb8c\n#define CSR_MHPMCOUNTER13H\t\t0xb8d\n#define CSR_MHPMCOUNTER14H\t\t0xb8e\n#define CSR_MHPMCOUNTER15H\t\t0xb8f\n#define CSR_MHPMCOUNTER16H\t\t0xb90\n#define CSR_MHPMCOUNTER17H\t\t0xb91\n#define CSR_MHPMCOUNTER18H\t\t0xb92\n#define CSR_MHPMCOUNTER19H\t\t0xb93\n#define CSR_MHPMCOUNTER20H\t\t0xb94\n#define CSR_MHPMCOUNTER21H\t\t0xb95\n#define CSR_MHPMCOUNTER22H\t\t0xb96\n#define CSR_MHPMCOUNTER23H\t\t0xb97\n#define CSR_MHPMCOUNTER24H\t\t0xb98\n#define CSR_MHPMCOUNTER25H\t\t0xb99\n#define CSR_MHPMCOUNTER26H\t\t0xb9a\n#define CSR_MHPMCOUNTER27H\t\t0xb9b\n#define CSR_MHPMCOUNTER28H\t\t0xb9c\n#define CSR_MHPMCOUNTER29H\t\t0xb9d\n#define CSR_MHPMCOUNTER30H\t\t0xb9e\n#define CSR_MHPMCOUNTER31H\t\t0xb9f\n\n/* Machine Counter Setup */\n#define CSR_MCOUNTINHIBIT\t\t0x320\n#define CSR_MHPMEVENT3\t\t\t0x323\n#define CSR_MHPMEVENT4\t\t\t0x324\n#define CSR_MHPMEVENT5\t\t\t0x325\n#define CSR_MHPMEVENT6\t\t\t0x326\n#define CSR_MHPMEVENT7\t\t\t0x327\n#define CSR_MHPMEVENT8\t\t\t0x328\n#define CSR_MHPMEVENT9\t\t\t0x329\n#define CSR_MHPMEVENT10\t\t\t0x32a\n#define CSR_MHPMEVENT11\t\t\t0x32b\n#define CSR_MHPMEVENT12\t\t\t0x32c\n#define CSR_MHPMEVENT13\t\t\t0x32d\n#define CSR_MHPMEVENT14\t\t\t0x32e\n#define CSR_MHPMEVENT15\t\t\t0x32f\n#define CSR_MHPMEVENT16\t\t\t0x330\n#define CSR_MHPMEVENT17\t\t\t0x331\n#define CSR_MHPMEVENT18\t\t\t0x332\n#define CSR_MHPMEVENT19\t\t\t0x333\n#define CSR_MHPMEVENT20\t\t\t0x334\n#define CSR_MHPMEVENT21\t\t\t0x335\n#define CSR_MHPMEVENT22\t\t\t0x336\n#define CSR_MHPMEVENT23\t\t\t0x337\n#define CSR_MHPMEVENT24\t\t\t0x338\n#define CSR_MHPMEVENT25\t\t\t0x339\n#define CSR_MHPMEVENT26\t\t\t0x33a\n#define CSR_MHPMEVENT27\t\t\t0x33b\n#define CSR_MHPMEVENT28\t\t\t0x33c\n#define CSR_MHPMEVENT29\t\t\t0x33d\n#define CSR_MHPMEVENT30\t\t\t0x33e\n#define CSR_MHPMEVENT31\t\t\t0x33f\n\n/* For RV32 */\n#define CSR_MHPMEVENT3H\t\t\t0x723\n#define CSR_MHPMEVENT4H\t\t\t0x724\n#define CSR_MHPMEVENT5H\t\t\t0x725\n#define CSR_MHPMEVENT6H\t\t\t0x726\n#define CSR_MHPMEVENT7H\t\t\t0x727\n#define CSR_MHPMEVENT8H\t\t\t0x728\n#define CSR_MHPMEVENT9H\t\t\t0x729\n#define CSR_MHPMEVENT10H\t\t0x72a\n#define CSR_MHPMEVENT11H\t\t0x72b\n#define CSR_MHPMEVENT12H\t\t0x72c\n#define CSR_MHPMEVENT13H\t\t0x72d\n#define CSR_MHPMEVENT14H\t\t0x72e\n#define CSR_MHPMEVENT15H\t\t0x72f\n#define CSR_MHPMEVENT16H\t\t0x730\n#define CSR_MHPMEVENT17H\t\t0x731\n#define CSR_MHPMEVENT18H\t\t0x732\n#define CSR_MHPMEVENT19H\t\t0x733\n#define CSR_MHPMEVENT20H\t\t0x734\n#define CSR_MHPMEVENT21H\t\t0x735\n#define CSR_MHPMEVENT22H\t\t0x736\n#define CSR_MHPMEVENT23H\t\t0x737\n#define CSR_MHPMEVENT24H\t\t0x738\n#define CSR_MHPMEVENT25H\t\t0x739\n#define CSR_MHPMEVENT26H\t\t0x73a\n#define CSR_MHPMEVENT27H\t\t0x73b\n#define CSR_MHPMEVENT28H\t\t0x73c\n#define CSR_MHPMEVENT29H\t\t0x73d\n#define CSR_MHPMEVENT30H\t\t0x73e\n#define CSR_MHPMEVENT31H\t\t0x73f\n\n/* Counter Overflow CSR */\n#define CSR_SCOUNTOVF\t\t\t0xda0\n\n/* Debug/Trace Registers */\n#define CSR_TSELECT\t\t\t0x7a0\n#define CSR_TDATA1\t\t\t0x7a1\n#define CSR_TDATA2\t\t\t0x7a2\n#define CSR_TDATA3\t\t\t0x7a3\n\n/* Debug Mode Registers */\n#define CSR_DCSR\t\t\t0x7b0\n#define CSR_DPC\t\t\t\t0x7b1\n#define CSR_DSCRATCH0\t\t\t0x7b2\n#define CSR_DSCRATCH1\t\t\t0x7b3\n\n/* Machine-Level Window to Indirectly Accessed Registers (AIA) */\n#define CSR_MISELECT\t\t\t0x350\n#define CSR_MIREG\t\t\t0x351\n\n/* Machine-Level Interrupts (AIA) */\n#define CSR_MTOPEI\t\t\t0x35c\n#define CSR_MTOPI\t\t\t0xfb0\n\n/* Virtual Interrupts for Supervisor Level (AIA) */\n#define CSR_MVIEN\t\t\t0x308\n#define CSR_MVIP\t\t\t0x309\n\n/* Smstateen extension registers */\n/* Machine stateen CSRs */\n#define CSR_MSTATEEN0\t\t\t0x30C\n#define CSR_MSTATEEN0H\t\t\t0x31C\n#define CSR_MSTATEEN1\t\t\t0x30D\n#define CSR_MSTATEEN1H\t\t\t0x31D\n#define CSR_MSTATEEN2\t\t\t0x30E\n#define CSR_MSTATEEN2H\t\t\t0x31E\n#define CSR_MSTATEEN3\t\t\t0x30F\n#define CSR_MSTATEEN3H\t\t\t0x31F\n\n/* Machine-Level High-Half CSRs (AIA) */\n#define CSR_MIDELEGH\t\t\t0x313\n#define CSR_MIEH\t\t\t0x314\n#define CSR_MVIENH\t\t\t0x318\n#define CSR_MVIPH\t\t\t0x319\n#define CSR_MIPH\t\t\t0x354\n\n/* ===== Trap/Exception Causes ===== */\n\n#define CAUSE_MISALIGNED_FETCH\t\t0x0\n#define CAUSE_FETCH_ACCESS\t\t0x1\n#define CAUSE_ILLEGAL_INSTRUCTION\t0x2\n#define CAUSE_BREAKPOINT\t\t0x3\n#define CAUSE_MISALIGNED_LOAD\t\t0x4\n#define CAUSE_LOAD_ACCESS\t\t0x5\n#define CAUSE_MISALIGNED_STORE\t\t0x6\n#define CAUSE_STORE_ACCESS\t\t0x7\n#define CAUSE_USER_ECALL\t\t0x8\n#define CAUSE_SUPERVISOR_ECALL\t\t0x9\n#define CAUSE_VIRTUAL_SUPERVISOR_ECALL\t0xa\n#define CAUSE_MACHINE_ECALL\t\t0xb\n#define CAUSE_FETCH_PAGE_FAULT\t\t0xc\n#define CAUSE_LOAD_PAGE_FAULT\t\t0xd\n#define CAUSE_STORE_PAGE_FAULT\t\t0xf\n#define CAUSE_FETCH_GUEST_PAGE_FAULT\t0x14\n#define CAUSE_LOAD_GUEST_PAGE_FAULT\t0x15\n#define CAUSE_VIRTUAL_INST_FAULT\t0x16\n#define CAUSE_STORE_GUEST_PAGE_FAULT\t0x17\n\n/* Common defines for all smstateen */\n#define SMSTATEEN_MAX_COUNT\t\t4\n#define SMSTATEEN0_CS_SHIFT\t\t0\n#define SMSTATEEN0_CS\t\t\t(_ULL(1) << SMSTATEEN0_CS_SHIFT)\n#define SMSTATEEN0_FCSR_SHIFT\t\t1\n#define SMSTATEEN0_FCSR\t\t\t(_ULL(1) << SMSTATEEN0_FCSR_SHIFT)\n#define SMSTATEEN0_IMSIC_SHIFT\t\t58\n#define SMSTATEEN0_IMSIC\t\t(_ULL(1) << SMSTATEEN0_IMSIC_SHIFT)\n#define SMSTATEEN0_AIA_SHIFT\t\t59\n#define SMSTATEEN0_AIA\t\t\t(_ULL(1) << SMSTATEEN0_AIA_SHIFT)\n#define SMSTATEEN0_SVSLCT_SHIFT\t\t60\n#define SMSTATEEN0_SVSLCT\t\t(_ULL(1) << SMSTATEEN0_SVSLCT_SHIFT)\n#define SMSTATEEN0_HSENVCFG_SHIFT\t62\n#define SMSTATEEN0_HSENVCFG\t\t(_ULL(1) << SMSTATEEN0_HSENVCFG_SHIFT)\n#define SMSTATEEN_STATEN_SHIFT\t\t63\n#define SMSTATEEN_STATEN\t\t(_ULL(1) << SMSTATEEN_STATEN_SHIFT)\n\n/* ===== Instruction Encodings ===== */\n\n#define INSN_MATCH_LB\t\t\t0x3\n#define INSN_MASK_LB\t\t\t0x707f\n#define INSN_MATCH_LH\t\t\t0x1003\n#define INSN_MASK_LH\t\t\t0x707f\n#define INSN_MATCH_LW\t\t\t0x2003\n#define INSN_MASK_LW\t\t\t0x707f\n#define INSN_MATCH_LD\t\t\t0x3003\n#define INSN_MASK_LD\t\t\t0x707f\n#define INSN_MATCH_LBU\t\t\t0x4003\n#define INSN_MASK_LBU\t\t\t0x707f\n#define INSN_MATCH_LHU\t\t\t0x5003\n#define INSN_MASK_LHU\t\t\t0x707f\n#define INSN_MATCH_LWU\t\t\t0x6003\n#define INSN_MASK_LWU\t\t\t0x707f\n#define INSN_MATCH_SB\t\t\t0x23\n#define INSN_MASK_SB\t\t\t0x707f\n#define INSN_MATCH_SH\t\t\t0x1023\n#define INSN_MASK_SH\t\t\t0x707f\n#define INSN_MATCH_SW\t\t\t0x2023\n#define INSN_MASK_SW\t\t\t0x707f\n#define INSN_MATCH_SD\t\t\t0x3023\n#define INSN_MASK_SD\t\t\t0x707f\n\n#define INSN_MATCH_FLW\t\t\t0x2007\n#define INSN_MASK_FLW\t\t\t0x707f\n#define INSN_MATCH_FLD\t\t\t0x3007\n#define INSN_MASK_FLD\t\t\t0x707f\n#define INSN_MATCH_FLQ\t\t\t0x4007\n#define INSN_MASK_FLQ\t\t\t0x707f\n#define INSN_MATCH_FSW\t\t\t0x2027\n#define INSN_MASK_FSW\t\t\t0x707f\n#define INSN_MATCH_FSD\t\t\t0x3027\n#define INSN_MASK_FSD\t\t\t0x707f\n#define INSN_MATCH_FSQ\t\t\t0x4027\n#define INSN_MASK_FSQ\t\t\t0x707f\n\n#define INSN_MATCH_C_LD\t\t\t0x6000\n#define INSN_MASK_C_LD\t\t\t0xe003\n#define INSN_MATCH_C_SD\t\t\t0xe000\n#define INSN_MASK_C_SD\t\t\t0xe003\n#define INSN_MATCH_C_LW\t\t\t0x4000\n#define INSN_MASK_C_LW\t\t\t0xe003\n#define INSN_MATCH_C_SW\t\t\t0xc000\n#define INSN_MASK_C_SW\t\t\t0xe003\n#define INSN_MATCH_C_LDSP\t\t0x6002\n#define INSN_MASK_C_LDSP\t\t0xe003\n#define INSN_MATCH_C_SDSP\t\t0xe002\n#define INSN_MASK_C_SDSP\t\t0xe003\n#define INSN_MATCH_C_LWSP\t\t0x4002\n#define INSN_MASK_C_LWSP\t\t0xe003\n#define INSN_MATCH_C_SWSP\t\t0xc002\n#define INSN_MASK_C_SWSP\t\t0xe003\n\n#define INSN_MATCH_C_FLD\t\t0x2000\n#define INSN_MASK_C_FLD\t\t\t0xe003\n#define INSN_MATCH_C_FLW\t\t0x6000\n#define INSN_MASK_C_FLW\t\t\t0xe003\n#define INSN_MATCH_C_FSD\t\t0xa000\n#define INSN_MASK_C_FSD\t\t\t0xe003\n#define INSN_MATCH_C_FSW\t\t0xe000\n#define INSN_MASK_C_FSW\t\t\t0xe003\n#define INSN_MATCH_C_FLDSP\t\t0x2002\n#define INSN_MASK_C_FLDSP\t\t0xe003\n#define INSN_MATCH_C_FSDSP\t\t0xa002\n#define INSN_MASK_C_FSDSP\t\t0xe003\n#define INSN_MATCH_C_FLWSP\t\t0x6002\n#define INSN_MASK_C_FLWSP\t\t0xe003\n#define INSN_MATCH_C_FSWSP\t\t0xe002\n#define INSN_MASK_C_FSWSP\t\t0xe003\n\n#define INSN_MASK_WFI\t\t\t0xffffff00\n#define INSN_MATCH_WFI\t\t\t0x10500000\n\n#define INSN_MASK_FENCE_TSO\t\t0xffffffff\n#define INSN_MATCH_FENCE_TSO\t\t0x8330000f\n\n#if __riscv_xlen == 64\n\n/* 64-bit read for VS-stage address translation (RV64) */\n#define INSN_PSEUDO_VS_LOAD\t\t0x00003000\n\n/* 64-bit write for VS-stage address translation (RV64) */\n#define INSN_PSEUDO_VS_STORE\t0x00003020\n\n#elif __riscv_xlen == 32\n\n/* 32-bit read for VS-stage address translation (RV32) */\n#define INSN_PSEUDO_VS_LOAD\t\t0x00002000\n\n/* 32-bit write for VS-stage address translation (RV32) */\n#define INSN_PSEUDO_VS_STORE\t0x00002020\n\n#else\n#error \"Unexpected __riscv_xlen\"\n#endif\n\n#define INSN_16BIT_MASK\t\t\t0x3\n#define INSN_32BIT_MASK\t\t\t0x1c\n\n#define INSN_IS_16BIT(insn)\t\t\\\n\t(((insn) & INSN_16BIT_MASK) != INSN_16BIT_MASK)\n#define INSN_IS_32BIT(insn)\t\t\\\n\t(((insn) & INSN_16BIT_MASK) == INSN_16BIT_MASK && \\\n\t ((insn) & INSN_32BIT_MASK) != INSN_32BIT_MASK)\n\n#define INSN_LEN(insn)\t\t\t(INSN_IS_16BIT(insn) ? 2 : 4)\n\n#if __riscv_xlen == 64\n#define LOG_REGBYTES\t\t\t3\n#else\n#define LOG_REGBYTES\t\t\t2\n#endif\n#define REGBYTES\t\t\t(1 << LOG_REGBYTES)\n\n#define SH_RD\t\t\t\t7\n#define SH_RS1\t\t\t\t15\n#define SH_RS2\t\t\t\t20\n#define SH_RS2C\t\t\t\t2\n\n#define RV_X(x, s, n)\t\t\t(((x) >> (s)) & ((1 << (n)) - 1))\n#define RVC_LW_IMM(x)\t\t\t((RV_X(x, 6, 1) << 2) | \\\n\t\t\t\t\t (RV_X(x, 10, 3) << 3) | \\\n\t\t\t\t\t (RV_X(x, 5, 1) << 6))\n#define RVC_LD_IMM(x)\t\t\t((RV_X(x, 10, 3) << 3) | \\\n\t\t\t\t\t (RV_X(x, 5, 2) << 6))\n#define RVC_LWSP_IMM(x)\t\t\t((RV_X(x, 4, 3) << 2) | \\\n\t\t\t\t\t (RV_X(x, 12, 1) << 5) | \\\n\t\t\t\t\t (RV_X(x, 2, 2) << 6))\n#define RVC_LDSP_IMM(x)\t\t\t((RV_X(x, 5, 2) << 3) | \\\n\t\t\t\t\t (RV_X(x, 12, 1) << 5) | \\\n\t\t\t\t\t (RV_X(x, 2, 3) << 6))\n#define RVC_SWSP_IMM(x)\t\t\t((RV_X(x, 9, 4) << 2) | \\\n\t\t\t\t\t (RV_X(x, 7, 2) << 6))\n#define RVC_SDSP_IMM(x)\t\t\t((RV_X(x, 10, 3) << 3) | \\\n\t\t\t\t\t (RV_X(x, 7, 3) << 6))\n#define RVC_RS1S(insn)\t\t\t(8 + RV_X(insn, SH_RD, 3))\n#define RVC_RS2S(insn)\t\t\t(8 + RV_X(insn, SH_RS2C, 3))\n#define RVC_RS2(insn)\t\t\tRV_X(insn, SH_RS2C, 5)\n\n#define SHIFT_RIGHT(x, y)\t\t\\\n\t((y) < 0 ? ((x) << -(y)) : ((x) >> (y)))\n\n#define REG_MASK\t\t\t\\\n\t((1 << (5 + LOG_REGBYTES)) - (1 << LOG_REGBYTES))\n\n#define REG_OFFSET(insn, pos)\t\t\\\n\t(SHIFT_RIGHT((insn), (pos) - LOG_REGBYTES) & REG_MASK)\n\n#define REG_PTR(insn, pos, regs)\t\\\n\t(ulong *)((ulong)(regs) + REG_OFFSET(insn, pos))\n\n#define GET_RM(insn)\t\t\t(((insn) >> 12) & 7)\n\n#define GET_RS1(insn, regs)\t\t(*REG_PTR(insn, SH_RS1, regs))\n#define GET_RS2(insn, regs)\t\t(*REG_PTR(insn, SH_RS2, regs))\n#define GET_RS1S(insn, regs)\t\t(*REG_PTR(RVC_RS1S(insn), 0, regs))\n#define GET_RS2S(insn, regs)\t\t(*REG_PTR(RVC_RS2S(insn), 0, regs))\n#define GET_RS2C(insn, regs)\t\t(*REG_PTR(insn, SH_RS2C, regs))\n#define GET_SP(regs)\t\t\t(*REG_PTR(2, 0, regs))\n#define SET_RD(insn, regs, val)\t\t(*REG_PTR(insn, SH_RD, regs) = (val))\n#define IMM_I(insn)\t\t\t((s32)(insn) >> 20)\n#define IMM_S(insn)\t\t\t(((s32)(insn) >> 25 << 5) | \\\n\t\t\t\t\t (s32)(((insn) >> 7) & 0x1f))\n#define MASK_FUNCT3\t\t\t0x7000\n\n/* clang-format on */\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/riscv_fp.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __RISCV_FP_H__\n#define __RISCV_FP_H__\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_types.h>\n\n#define GET_PRECISION(insn) (((insn) >> 25) & 3)\n#define GET_RM(insn) (((insn) >> 12) & 7)\n#define PRECISION_S 0\n#define PRECISION_D 1\n\n#ifdef __riscv_flen\n\n#define GET_F32_REG(insn, pos, regs)                                                                    \\\n\t({                                                                                              \\\n\t\tregister s32 value asm(\"a0\") =                                                          \\\n\t\t\tSHIFT_RIGHT(insn, (pos)-3) & 0xf8;                                              \\\n\t\tulong tmp;                                                                              \\\n\t\tasm(\"1: auipc %0, %%pcrel_hi(get_f32_reg); add %0, %0, %1; jalr t0, %0, %%pcrel_lo(1b)\" \\\n\t\t    : \"=&r\"(tmp), \"+&r\"(value)::\"t0\");                                                  \\\n\t\tvalue;                                                                                  \\\n\t})\n#define SET_F32_REG(insn, pos, regs, val)                                                                   \\\n\t({                                                                                                  \\\n\t\tregister u32 value asm(\"a0\") = (val);                                                       \\\n\t\tulong offset = SHIFT_RIGHT(insn, (pos)-3) & 0xf8;                                           \\\n\t\tulong tmp;                                                                                  \\\n\t\tasm volatile(                                                                               \\\n\t\t\t\"1: auipc %0, %%pcrel_hi(put_f32_reg); add %0, %0, %2; jalr t0, %0, %%pcrel_lo(1b)\" \\\n\t\t\t: \"=&r\"(tmp)                                                                        \\\n\t\t\t: \"r\"(value), \"r\"(offset)                                                           \\\n\t\t\t: \"t0\");                                                                            \\\n\t})\n#define init_fp_reg(i) SET_F32_REG((i) << 3, 3, 0, 0)\n\n#if __riscv_xlen == 64\n#define GET_F64_REG(insn, pos, regs)                                                                    \\\n\t({                                                                                              \\\n\t\tregister ulong value asm(\"a0\") = SHIFT_RIGHT(insn, (pos)-3) & 0xf8;                     \\\n\t\tulong tmp;                                                                              \\\n\t\tasm(\"1: auipc %0, %%pcrel_hi(get_f64_reg); add %0, %0, %1; jalr t0, %0, %%pcrel_lo(1b)\" \\\n\t\t    : \"=&r\"(tmp), \"+&r\"(value)::\"t0\");                                                  \\\n\t\tvalue;                                                                                  \\\n\t})\n#else\n#define GET_F64_REG(insn, pos, regs)                                                                     \\\n\t({                                                                                               \\\n\t\tu64 value;                                                                               \\\n\t\tulong offset = SHIFT_RIGHT(insn, (pos)-3) & 0xf8;                                        \\\n\t\tregister ulong ptr asm(\"a0\") = (ulong)&value;                                            \\\n\t\tasm (\"1: auipc t1, %%pcrel_hi(get_f64_reg); add t1, t1, %2; jalr t0, t1, %%pcrel_lo(1b)\" \\\n\t\t    : \"=m\"(value) : \"r\"(ptr), \"r\"(offset) : \"t0\", \"t1\");                                 \\\n\t\tvalue;                                                                                   \\\n\t})\n#endif\n\n#define SET_F64_REG(insn, pos, regs, val)                                                                   \\\n\t({                                                                                                  \\\n\t\tuint64_t __val = (val);                                                                     \\\n\t\tregister ulong value asm(\"a0\") =                                                            \\\n\t\t\tsizeof(ulong) == 4 ? (ulong)&__val : (ulong)__val;                                  \\\n\t\tulong offset = SHIFT_RIGHT(insn, (pos)-3) & 0xf8;                                           \\\n\t\tulong tmp;                                                                                  \\\n\t\tasm volatile(                                                                               \\\n\t\t\t\"1: auipc %0, %%pcrel_hi(put_f64_reg); add %0, %0, %2; jalr t0, %0, %%pcrel_lo(1b)\" \\\n\t\t\t: \"=&r\"(tmp)                                                                        \\\n\t\t\t: \"r\"(value), \"r\"(offset)                                                           \\\n\t\t\t: \"t0\");                                                                            \\\n\t})\n#define GET_FCSR() csr_read(CSR_FCSR)\n#define SET_FCSR(value) csr_write(CSR_FCSR, (value))\n#define GET_FRM() csr_read(CSR_FRM)\n#define SET_FRM(value) csr_write(CSR_FRM, (value))\n#define GET_FFLAGS() csr_read(CSR_FFLAGS)\n#define SET_FFLAGS(value) csr_write(CSR_FFLAGS, (value))\n\n#define SET_FS_DIRTY() ((void)0)\n\n#define GET_F32_RS1(insn, regs) (GET_F32_REG(insn, 15, regs))\n#define GET_F32_RS2(insn, regs) (GET_F32_REG(insn, 20, regs))\n#define GET_F32_RS3(insn, regs) (GET_F32_REG(insn, 27, regs))\n#define GET_F64_RS1(insn, regs) (GET_F64_REG(insn, 15, regs))\n#define GET_F64_RS2(insn, regs) (GET_F64_REG(insn, 20, regs))\n#define GET_F64_RS3(insn, regs) (GET_F64_REG(insn, 27, regs))\n#define SET_F32_RD(insn, regs, val) \\\n\t(SET_F32_REG(insn, 7, regs, val), SET_FS_DIRTY())\n#define SET_F64_RD(insn, regs, val) \\\n\t(SET_F64_REG(insn, 7, regs, val), SET_FS_DIRTY())\n\n#define GET_F32_RS2C(insn, regs) (GET_F32_REG(insn, 2, regs))\n#define GET_F32_RS2S(insn, regs) (GET_F32_REG(RVC_RS2S(insn), 0, regs))\n#define GET_F64_RS2C(insn, regs) (GET_F64_REG(insn, 2, regs))\n#define GET_F64_RS2S(insn, regs) (GET_F64_REG(RVC_RS2S(insn), 0, regs))\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/riscv_io.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __RISCV_IO_H__\n#define __RISCV_IO_H__\n\n#include <sbi/riscv_barrier.h>\n#include <sbi/sbi_types.h>\n\nstatic inline void __raw_writeb(u8 val, volatile void *addr)\n{\n\tasm volatile(\"sb %0, 0(%1)\" : : \"r\"(val), \"r\"(addr));\n}\n\nstatic inline void __raw_writew(u16 val, volatile void *addr)\n{\n\tasm volatile(\"sh %0, 0(%1)\" : : \"r\"(val), \"r\"(addr));\n}\n\nstatic inline void __raw_writel(u32 val, volatile void *addr)\n{\n\tasm volatile(\"sw %0, 0(%1)\" : : \"r\"(val), \"r\"(addr));\n}\n\n#if __riscv_xlen != 32\nstatic inline void __raw_writeq(u64 val, volatile void *addr)\n{\n\tasm volatile(\"sd %0, 0(%1)\" : : \"r\"(val), \"r\"(addr));\n}\n#endif\n\nstatic inline u8 __raw_readb(const volatile void *addr)\n{\n\tu8 val;\n\n\tasm volatile(\"lb %0, 0(%1)\" : \"=r\"(val) : \"r\"(addr));\n\treturn val;\n}\n\nstatic inline u16 __raw_readw(const volatile void *addr)\n{\n\tu16 val;\n\n\tasm volatile(\"lh %0, 0(%1)\" : \"=r\"(val) : \"r\"(addr));\n\treturn val;\n}\n\nstatic inline u32 __raw_readl(const volatile void *addr)\n{\n\tu32 val;\n\n\tasm volatile(\"lw %0, 0(%1)\" : \"=r\"(val) : \"r\"(addr));\n\treturn val;\n}\n\n#if __riscv_xlen != 32\nstatic inline u64 __raw_readq(const volatile void *addr)\n{\n\tu64 val;\n\n\tasm volatile(\"ld %0, 0(%1)\" : \"=r\"(val) : \"r\"(addr));\n\treturn val;\n}\n#endif\n\n/* FIXME: These are now the same as asm-generic */\n\n/* clang-format off */\n\n#define __io_rbr()\t\tdo {} while (0)\n#define __io_rar()\t\tdo {} while (0)\n#define __io_rbw()\t\tdo {} while (0)\n#define __io_raw()\t\tdo {} while (0)\n\n#define readb_relaxed(c)\t({ u8  __v; __io_rbr(); __v = __raw_readb(c); __io_rar(); __v; })\n#define readw_relaxed(c)\t({ u16 __v; __io_rbr(); __v = __raw_readw(c); __io_rar(); __v; })\n#define readl_relaxed(c)\t({ u32 __v; __io_rbr(); __v = __raw_readl(c); __io_rar(); __v; })\n\n#define writeb_relaxed(v,c)\t({ __io_rbw(); __raw_writeb((v),(c)); __io_raw(); })\n#define writew_relaxed(v,c)\t({ __io_rbw(); __raw_writew((v),(c)); __io_raw(); })\n#define writel_relaxed(v,c)\t({ __io_rbw(); __raw_writel((v),(c)); __io_raw(); })\n\n#if __riscv_xlen != 32\n#define readq_relaxed(c)\t({ u64 __v; __io_rbr(); __v = __raw_readq(c); __io_rar(); __v; })\n#define writeq_relaxed(v,c)\t({ __io_rbw(); __raw_writeq((v),(c)); __io_raw(); })\n#endif\n\n#define __io_br()\tdo {} while (0)\n#define __io_ar()\t__asm__ __volatile__ (\"fence i,r\" : : : \"memory\");\n#define __io_bw()\t__asm__ __volatile__ (\"fence w,o\" : : : \"memory\");\n#define __io_aw()\tdo {} while (0)\n\n#define readb(c)\t({ u8  __v; __io_br(); __v = __raw_readb(c); __io_ar(); __v; })\n#define readw(c)\t({ u16 __v; __io_br(); __v = __raw_readw(c); __io_ar(); __v; })\n#define readl(c)\t({ u32 __v; __io_br(); __v = __raw_readl(c); __io_ar(); __v; })\n\n#define writeb(v,c)\t({ __io_bw(); __raw_writeb((v),(c)); __io_aw(); })\n#define writew(v,c)\t({ __io_bw(); __raw_writew((v),(c)); __io_aw(); })\n#define writel(v,c)\t({ __io_bw(); __raw_writel((v),(c)); __io_aw(); })\n\n#if __riscv_xlen != 32\n#define readq(c)\t({ u64 __v; __io_br(); __v = __raw_readq(c); __io_ar(); __v; })\n#define writeq(v,c)\t({ __io_bw(); __raw_writeq((v),(c)); __io_aw(); })\n#endif\n\n/* clang-format on */\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/riscv_locks.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n * Copyright (c) 2021 Christoph Müllner <cmuellner@linux.com>\n */\n\n#ifndef __RISCV_LOCKS_H__\n#define __RISCV_LOCKS_H__\n\n#include <sbi/sbi_types.h>\n\n#define TICKET_SHIFT\t16\n\ntypedef struct {\n#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\n       u16 next;\n       u16 owner;\n#else\n       u16 owner;\n       u16 next;\n#endif\n} __aligned(4) spinlock_t;\n\n#define __SPIN_LOCK_UNLOCKED\t\\\n\t(spinlock_t) { 0, 0 }\n\n#define SPIN_LOCK_INIT(x)\t\\\n\tx = __SPIN_LOCK_UNLOCKED\n\n#define SPIN_LOCK_INITIALIZER\t\\\n\t__SPIN_LOCK_UNLOCKED\n\n#define DEFINE_SPIN_LOCK(x)\t\\\n\tspinlock_t SPIN_LOCK_INIT(x)\n\nbool spin_lock_check(spinlock_t *lock);\n\nbool spin_trylock(spinlock_t *lock);\n\nvoid spin_lock(spinlock_t *lock);\n\nvoid spin_unlock(spinlock_t *lock);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_bitmap.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_BITMAP_H__\n#define __SBI_BITMAP_H__\n\n#include <sbi/sbi_bitops.h>\n\n#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))\n#define BITMAP_LAST_WORD_MASK(nbits)\t\t\t\t\t\\\n(\t\t\t\t\t\t\t\t\t\\\n\t((nbits) % BITS_PER_LONG) ?\t\t\t\t\t\\\n\t\t((1UL << ((nbits) % BITS_PER_LONG)) - 1) : ~0UL\t\t\\\n)\n\n#define small_const_nbits(nbits) \\\n\t(__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG)\n\n#define DECLARE_BITMAP(name, nbits)\tunsigned long name[BITS_TO_LONGS(nbits)]\n#define DEFINE_BITMAP(name)\t\textern unsigned long name[]\n\nstatic inline unsigned long bitmap_estimate_size(int nbits)\n{\n\treturn (BITS_TO_LONGS(nbits) * sizeof(unsigned long));\n}\n\nvoid __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,\n\t\t  const unsigned long *bitmap2, int bits);\nvoid __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,\n\t\t const unsigned long *bitmap2, int bits);\nvoid __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,\n\t\t  const unsigned long *bitmap2, int bits);\n\nstatic inline void bitmap_set(unsigned long *bmap, int start, int len)\n{\n\tint bit;\n\tfor (bit = start; bit < (start + len); bit++)\n\t\tbmap[BIT_WORD(bit)] |= (0x1UL << BIT_WORD_OFFSET(bit));\n}\n\nstatic inline void bitmap_clear(unsigned long *bmap, int start, int len)\n{\n\tint bit;\n\tfor (bit = start; bit < (start + len); bit++)\n\t\tbmap[BIT_WORD(bit)] &= ~(0x1UL << BIT_WORD_OFFSET(bit));\n}\n\nstatic inline void bitmap_zero(unsigned long *dst, int nbits)\n{\n\tif (small_const_nbits(nbits))\n\t\t*dst = 0UL;\n\telse {\n\t\tsize_t i, len = BITS_TO_LONGS(nbits);\n\t\tfor (i = 0; i < len; i++)\n\t\t\tdst[i] = 0;\n\t}\n}\n\nstatic inline void bitmap_zero_except(unsigned long *dst,\n\t\t\t\t      int exception, int nbits)\n{\n\tif (small_const_nbits(nbits))\n\t\t*dst = 0UL;\n\telse {\n\t\tsize_t i, len = BITS_TO_LONGS(nbits);\n\t\tfor (i = 0; i < len; i++)\n\t\t\tdst[i] = 0;\n\t}\n\tif (exception < nbits)\n\t\t__set_bit(exception, dst);\n}\n\nstatic inline void bitmap_fill(unsigned long *dst, int nbits)\n{\n\tsize_t i, nlongs = BITS_TO_LONGS(nbits);\n\tif (!small_const_nbits(nbits)) {\n\t\tfor (i = 0; i < (nlongs - 1); i++)\n\t\t\tdst[i] = -1UL;\n\t}\n\tdst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits);\n}\n\nstatic inline void bitmap_copy(unsigned long *dst,\n\t\t\t       const unsigned long *src, int nbits)\n{\n\tif (small_const_nbits(nbits))\n\t\t*dst = *src;\n\telse {\n\t\tsize_t i, len = BITS_TO_LONGS(nbits);\n\t\tfor (i = 0; i < len; i++)\n\t\t\tdst[i] = src[i];\n\t}\n}\n\nstatic inline void bitmap_and(unsigned long *dst, const unsigned long *src1,\n\t\t\t      const unsigned long *src2, int nbits)\n{\n\tif (small_const_nbits(nbits))\n\t\t*dst = *src1 & *src2;\n\telse\n\t\t__bitmap_and(dst, src1, src2, nbits);\n}\n\nstatic inline void bitmap_or(unsigned long *dst, const unsigned long *src1,\n\t\t\t     const unsigned long *src2, int nbits)\n{\n\tif (small_const_nbits(nbits))\n\t\t*dst = *src1 | *src2;\n\telse\n\t\t__bitmap_or(dst, src1, src2, nbits);\n}\n\nstatic inline void bitmap_xor(unsigned long *dst, const unsigned long *src1,\n\t\t\t      const unsigned long *src2, int nbits)\n{\n\tif (small_const_nbits(nbits))\n\t\t*dst = *src1 ^ *src2;\n\telse\n\t\t__bitmap_xor(dst, src1, src2, nbits);\n}\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_bitops.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#ifndef __SBI_BITOPS_H__\n#define __SBI_BITOPS_H__\n\n#include <sbi/sbi_types.h>\n\n#if __SIZEOF_POINTER__ == 8\n#define BITS_PER_LONG\t\t64\n#elif __SIZEOF_POINTER__ == 4\n#define BITS_PER_LONG\t\t32\n#else\n#error \"Unexpected __SIZEOF_POINTER__\"\n#endif\n\n#define EXTRACT_FIELD(val, which) \\\n\t(((val) & (which)) / ((which) & ~((which)-1)))\n#define INSERT_FIELD(val, which, fieldval) \\\n\t(((val) & ~(which)) | ((fieldval) * ((which) & ~((which)-1))))\n\n#define BITS_TO_LONGS(nbits)\t(((nbits) + BITS_PER_LONG - 1) / \\\n\t\t\t\t BITS_PER_LONG)\n\n#define BIT(nr)\t\t\t(1UL << (nr))\n#define BIT_MASK(nr)\t\t(1UL << ((nr) % BITS_PER_LONG))\n#define BIT_WORD(bit)\t\t((bit) / BITS_PER_LONG)\n#define BIT_WORD_OFFSET(bit)\t((bit) & (BITS_PER_LONG - 1))\n\n#define GENMASK(h, l) \\\n\t(((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))\n\n/**\n * sbi_ffs - find first (less-significant) set bit in a long word.\n * @word: The word to search\n *\n * Undefined if no bit exists, so code should check against 0 first.\n */\nstatic inline int sbi_ffs(unsigned long word)\n{\n\tint num = 0;\n\n#if BITS_PER_LONG == 64\n\tif ((word & 0xffffffff) == 0) {\n\t\tnum += 32;\n\t\tword >>= 32;\n\t}\n#endif\n\tif ((word & 0xffff) == 0) {\n\t\tnum += 16;\n\t\tword >>= 16;\n\t}\n\tif ((word & 0xff) == 0) {\n\t\tnum += 8;\n\t\tword >>= 8;\n\t}\n\tif ((word & 0xf) == 0) {\n\t\tnum += 4;\n\t\tword >>= 4;\n\t}\n\tif ((word & 0x3) == 0) {\n\t\tnum += 2;\n\t\tword >>= 2;\n\t}\n\tif ((word & 0x1) == 0)\n\t\tnum += 1;\n\treturn num;\n}\n\n/*\n * sbi_ffz - find first zero in word.\n * @word: The word to search\n *\n * Undefined if no zero exists, so code should check against ~0UL first.\n */\n#define sbi_ffz(x) sbi_ffs(~(x))\n\n/**\n * sbi_fls - find last (most-significant) set bit in a long word\n * @word: the word to search\n *\n * Undefined if no set bit exists, so code should check against 0 first.\n */\nstatic inline unsigned long sbi_fls(unsigned long word)\n{\n\tint num = BITS_PER_LONG - 1;\n\n#if BITS_PER_LONG == 64\n\tif (!(word & (~0ul << 32))) {\n\t\tnum -= 32;\n\t\tword <<= 32;\n\t}\n#endif\n\tif (!(word & (~0ul << (BITS_PER_LONG-16)))) {\n\t\tnum -= 16;\n\t\tword <<= 16;\n\t}\n\tif (!(word & (~0ul << (BITS_PER_LONG-8)))) {\n\t\tnum -= 8;\n\t\tword <<= 8;\n\t}\n\tif (!(word & (~0ul << (BITS_PER_LONG-4)))) {\n\t\tnum -= 4;\n\t\tword <<= 4;\n\t}\n\tif (!(word & (~0ul << (BITS_PER_LONG-2)))) {\n\t\tnum -= 2;\n\t\tword <<= 2;\n\t}\n\tif (!(word & (~0ul << (BITS_PER_LONG-1))))\n\t\tnum -= 1;\n\treturn num;\n}\n\n#define for_each_set_bit(bit, addr, size) \\\n\tfor ((bit) = find_first_bit((addr), (size));\t\t\\\n\t     (bit) < (size);\t\t\t\t\t\\\n\t     (bit) = find_next_bit((addr), (size), (bit) + 1))\n\n/* same as for_each_set_bit() but use bit as value to start with */\n#define for_each_set_bit_from(bit, addr, size) \\\n\tfor ((bit) = find_next_bit((addr), (size), (bit));\t\\\n\t     (bit) < (size);\t\t\t\t\t\\\n\t     (bit) = find_next_bit((addr), (size), (bit) + 1))\n\n#define for_each_clear_bit(bit, addr, size) \\\n\tfor ((bit) = find_first_zero_bit((addr), (size));\t\\\n\t     (bit) < (size);\t\t\t\t\t\\\n\t     (bit) = find_next_zero_bit((addr), (size), (bit) + 1))\n\n/* same as for_each_clear_bit() but use bit as value to start with */\n#define for_each_clear_bit_from(bit, addr, size) \\\n\tfor ((bit) = find_next_zero_bit((addr), (size), (bit));\t\\\n\t     (bit) < (size);\t\t\t\t\t\\\n\t     (bit) = find_next_zero_bit((addr), (size), (bit) + 1))\n\nunsigned long find_first_bit(const unsigned long *addr,\n\t\t\t     unsigned long size);\n\nunsigned long find_first_zero_bit(const unsigned long *addr,\n\t\t\t\t  unsigned long size);\n\nunsigned long find_last_bit(const unsigned long *addr,\n\t\t\t    unsigned long size);\n\nunsigned long find_next_bit(const unsigned long *addr,\n\t\t\t    unsigned long size, unsigned long offset);\n\nunsigned long find_next_zero_bit(const unsigned long *addr,\n\t\t\t\t unsigned long size,\n\t\t\t\t unsigned long offset);\n\n/**\n * __set_bit - Set a bit in memory\n * @nr: the bit to set\n * @addr: the address to start counting from\n *\n * This function is non-atomic and may be reordered.\n */\nstatic inline void __set_bit(int nr, volatile unsigned long *addr)\n{\n\tunsigned long mask = BIT_MASK(nr);\n\tunsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);\n\n\t*p |= mask;\n}\n\n/**\n * __clear_bit - Clear a bit in memory\n * @nr: the bit to clear\n * @addr: the address to start counting from\n *\n * This function is non-atomic and may be reordered.\n */\nstatic inline void __clear_bit(int nr, volatile unsigned long *addr)\n{\n\tunsigned long mask = BIT_MASK(nr);\n\tunsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);\n\n\t*p &= ~mask;\n}\n\n/**\n * __change_bit - Toggle a bit in memory\n * @nr: the bit to change\n * @addr: the address to start counting from\n *\n * This function is non-atomic and may be reordered.\n */\nstatic inline void __change_bit(int nr, volatile unsigned long *addr)\n{\n\tunsigned long mask = BIT_MASK(nr);\n\tunsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);\n\n\t*p ^= mask;\n}\n\n/**\n * __test_and_set_bit - Set a bit and return its old value\n * @nr: Bit to set\n * @addr: Address to count from\n *\n * This operation is non-atomic and can be reordered.\n */\nstatic inline int __test_and_set_bit(int nr, volatile unsigned long *addr)\n{\n\tunsigned long mask = BIT_MASK(nr);\n\tunsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);\n\tunsigned long old = *p;\n\n\t*p = old | mask;\n\treturn (old & mask) != 0;\n}\n\n/**\n * __test_and_clear_bit - Clear a bit and return its old value\n * @nr: Bit to clear\n * @addr: Address to count from\n *\n * This operation is non-atomic and can be reordered.\n */\nstatic inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)\n{\n\tunsigned long mask = BIT_MASK(nr);\n\tunsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);\n\tunsigned long old = *p;\n\n\t*p = old & ~mask;\n\treturn (old & mask) != 0;\n}\n\n/**\n * __test_bit - Determine whether a bit is set\n * @nr: bit number to test\n * @addr: Address to start counting from\n *\n * This operation is non-atomic and can be reordered.\n */\nstatic inline int __test_bit(int nr, const volatile unsigned long *addr)\n{\n\treturn 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));\n}\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_console.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_CONSOLE_H__\n#define __SBI_CONSOLE_H__\n\n#include <sbi/sbi_types.h>\n\nstruct sbi_console_device {\n\t/** Name of the console device */\n\tchar name[32];\n\n\t/** Write a character to the console output */\n\tvoid (*console_putc)(char ch);\n\n\t/** Read a character from the console input */\n\tint (*console_getc)(void);\n};\n\n#define __printf(a, b) __attribute__((format(printf, a, b)))\n\nbool sbi_isprintable(char ch);\n\nint sbi_getc(void);\n\nvoid sbi_putc(char ch);\n\nvoid sbi_puts(const char *str);\n\nvoid sbi_gets(char *s, int maxwidth, char endchar);\n\nint __printf(2, 3) sbi_sprintf(char *out, const char *format, ...);\n\nint __printf(3, 4) sbi_snprintf(char *out, u32 out_sz, const char *format, ...);\n\nint __printf(1, 2) sbi_printf(const char *format, ...);\n\nint __printf(1, 2) sbi_dprintf(const char *format, ...);\n\nvoid __printf(1, 2) __attribute__((noreturn)) sbi_panic(const char *format, ...);\n\nconst struct sbi_console_device *sbi_console_get_device(void);\n\nvoid sbi_console_set_device(const struct sbi_console_device *dev);\n\nstruct sbi_scratch;\n\nint sbi_console_init(struct sbi_scratch *scratch);\n\n#define SBI_ASSERT(cond, args) do { \\\n\tif (unlikely(!(cond))) \\\n\t\tsbi_panic args; \\\n} while (0)\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_const.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_CONST_H__\n#define __SBI_CONST_H__\n\n/*\n * Some constant macros are used in both assembler and\n * C code.  Therefore we cannot annotate them always with\n * 'UL' and other type specifiers unilaterally.  We\n * use the following macros to deal with this.\n *\n * Similarly, _AT() will cast an expression with a type in C, but\n * leave it unchanged in asm.\n */\n\n/* clang-format off */\n\n#ifdef __ASSEMBLER__\n#define _AC(X,Y)\tX\n#define _AT(T,X)\tX\n#else\n#define __AC(X,Y)\t(X##Y)\n#define _AC(X,Y)\t__AC(X,Y)\n#define _AT(T,X)\t((T)(X))\n#endif\n\n#define _UL(x)\t\t(_AC(x, UL))\n#define _ULL(x)\t\t(_AC(x, ULL))\n\n#define _BITUL(x)\t(_UL(1) << (x))\n#define _BITULL(x)\t(_ULL(1) << (x))\n\n#define UL(x)\t\t(_UL(x))\n#define ULL(x)\t\t(_ULL(x))\n\n#define __STR(s)\t#s\n#define STRINGIFY(s)\t__STR(s)\n\n/* clang-format on */\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_csr_detect.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#ifndef __SBI_CSR_DETECT__H\n#define __SBI_CSR_DETECT__H\n\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_trap.h>\n\n#define csr_read_allowed(csr_num, trap)\t\t\t\t\t\\\n\t({\t\t\t\t\t\t\t\t\\\n\tregister ulong tinfo asm(\"a3\") = (ulong)trap;\t\t\t\\\n\tregister ulong ttmp asm(\"a4\");\t\t\t\t\t\\\n\tregister ulong mtvec = sbi_hart_expected_trap_addr();\t\t\\\n\tregister ulong ret = 0;\t\t\t\t\t\t\\\n\t((struct sbi_trap_info *)(trap))->cause = 0;\t\t\t\\\n\tasm volatile(\t\t\t\t\t\t\t\\\n\t\t\"add %[ttmp], %[tinfo], zero\\n\"\t\t\t\t\\\n\t\t\"csrrw %[mtvec], \" STR(CSR_MTVEC) \", %[mtvec]\\n\"\t\\\n\t\t\"csrr %[ret], %[csr]\\n\"\t\t\t\t\t\\\n\t\t\"csrw \" STR(CSR_MTVEC) \", %[mtvec]\"\t\t\t\\\n\t    : [mtvec] \"+&r\"(mtvec), [tinfo] \"+&r\"(tinfo),\t\t\\\n\t      [ttmp] \"+&r\"(ttmp), [ret] \"=&r\" (ret)\t\t\t\\\n\t    : [csr] \"i\" (csr_num)\t\t\t\t\t\\\n\t    : \"memory\");\t\t\t\t\t\t\\\n\tret;\t\t\t\t\t\t\t\t\\\n\t})\t\t\t\t\t\t\t\t\\\n\n#define csr_write_allowed(csr_num, trap, value)\t\t\t\t\\\n\t({\t\t\t\t\t\t\t\t\\\n\tregister ulong tinfo asm(\"a3\") = (ulong)trap;\t\t\t\\\n\tregister ulong ttmp asm(\"a4\");\t\t\t\t\t\\\n\tregister ulong mtvec = sbi_hart_expected_trap_addr();\t\t\\\n\t((struct sbi_trap_info *)(trap))->cause = 0;\t\t\t\\\n\tasm volatile(\t\t\t\t\t\t\t\\\n\t\t\"add %[ttmp], %[tinfo], zero\\n\"\t\t\t\t\\\n\t\t\"csrrw %[mtvec], \" STR(CSR_MTVEC) \", %[mtvec]\\n\"\t\\\n\t\t\"csrw %[csr], %[val]\\n\"\t\t\t\t\t\\\n\t\t\"csrw \" STR(CSR_MTVEC) \", %[mtvec]\"\t\t\t\\\n\t    : [mtvec] \"+&r\"(mtvec),\t\t\t\t\t\\\n\t      [tinfo] \"+&r\"(tinfo), [ttmp] \"+&r\"(ttmp)\t\t\t\\\n\t    : [csr] \"i\" (csr_num), [val] \"r\" (value)\t\t\t\\\n\t    : \"memory\");\t\t\t\t\t\t\\\n\t})\t\t\t\t\t\t\t\t\\\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_domain.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_DOMAIN_H__\n#define __SBI_DOMAIN_H__\n\n#include <sbi/sbi_types.h>\n#include <sbi/sbi_hartmask.h>\n\nstruct sbi_scratch;\n\n/** Domain access types */\nenum sbi_domain_access {\n\tSBI_DOMAIN_READ = (1UL << 0),\n\tSBI_DOMAIN_WRITE = (1UL << 1),\n\tSBI_DOMAIN_EXECUTE = (1UL << 2),\n\tSBI_DOMAIN_MMIO = (1UL << 3)\n};\n\n/** Representation of OpenSBI domain memory region */\nstruct sbi_domain_memregion {\n\t/**\n\t * Size of memory region as power of 2\n\t * It has to be minimum 3 and maximum __riscv_xlen\n\t */\n\tunsigned long order;\n\t/**\n\t * Base address of memory region\n\t * It must be 2^order aligned address\n\t */\n\tunsigned long base;\n\t/** Flags representing memory region attributes */\n#define SBI_DOMAIN_MEMREGION_READABLE\t\t(1UL << 0)\n#define SBI_DOMAIN_MEMREGION_WRITEABLE\t\t(1UL << 1)\n#define SBI_DOMAIN_MEMREGION_EXECUTABLE\t\t(1UL << 2)\n#define SBI_DOMAIN_MEMREGION_MMODE\t\t(1UL << 3)\n#define SBI_DOMAIN_MEMREGION_ACCESS_MASK\t(0xfUL)\n\n#define SBI_DOMAIN_MEMREGION_MMIO\t\t(1UL << 31)\n\tunsigned long flags;\n};\n\n/** Maximum number of domains */\n#define SBI_DOMAIN_MAX_INDEX\t\t\t32\n\n/** Representation of OpenSBI domain */\nstruct sbi_domain {\n\t/**\n\t * Logical index of this domain\n\t * Note: This set by sbi_domain_finalize() in the coldboot path\n\t */\n\tu32 index;\n\t/**\n\t * HARTs assigned to this domain\n\t * Note: This set by sbi_domain_init() and sbi_domain_finalize()\n\t * in the coldboot path\n\t */\n\tstruct sbi_hartmask assigned_harts;\n\t/** Name of this domain */\n\tchar name[64];\n\t/** Possible HARTs in this domain */\n\tconst struct sbi_hartmask *possible_harts;\n\t/** Array of memory regions terminated by a region with order zero */\n\tstruct sbi_domain_memregion *regions;\n\t/** HART id of the HART booting this domain */\n\tu32 boot_hartid;\n\t/** Arg1 (or 'a1' register) of next booting stage for this domain */\n\tunsigned long next_arg1;\n\t/** Address of next booting stage for this domain */\n\tunsigned long next_addr;\n\t/** Privilege mode of next booting stage for this domain */\n\tunsigned long next_mode;\n\t/** Is domain allowed to reset the system */\n\tbool system_reset_allowed;\n};\n\n/** The root domain instance */\nextern struct sbi_domain root;\n\n/** HART id to domain table */\nextern struct sbi_domain *hartid_to_domain_table[];\n\n/** Get pointer to sbi_domain from HART id */\n#define sbi_hartid_to_domain(__hartid) \\\n\thartid_to_domain_table[__hartid]\n\n/** Get pointer to sbi_domain for current HART */\n#define sbi_domain_thishart_ptr() \\\n\tsbi_hartid_to_domain(current_hartid())\n\n/** Index to domain table */\nextern struct sbi_domain *domidx_to_domain_table[];\n\n/** Get pointer to sbi_domain from index */\n#define sbi_index_to_domain(__index) \\\n\tdomidx_to_domain_table[__index]\n\n/** Iterate over each domain */\n#define sbi_domain_for_each(__i, __d) \\\n\tfor ((__i) = 0; ((__d) = sbi_index_to_domain(__i)); (__i)++)\n\n/** Iterate over each memory region of a domain */\n#define sbi_domain_for_each_memregion(__d, __r) \\\n\tfor ((__r) = (__d)->regions; (__r)->order; (__r)++)\n\n/**\n * Check whether given HART is assigned to specified domain\n * @param dom pointer to domain\n * @param hartid the HART ID\n * @return TRUE if HART is assigned to domain otherwise FALSE\n */\nbool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartid);\n\n/**\n * Get ulong assigned HART mask for given domain and HART base ID\n * @param dom pointer to domain\n * @param hbase the HART base ID\n * @return ulong possible HART mask\n * Note: the return ulong mask will be set to zero on failure.\n */\nulong sbi_domain_get_assigned_hartmask(const struct sbi_domain *dom,\n\t\t\t\t       ulong hbase);\n\n/**\n * Initialize a domain memory region based on it's physical\n * address and size.\n *\n * @param addr start physical address of memory region\n * @param size physical size of memory region\n * @param flags memory region flags\n * @param reg pointer to memory region being initialized\n */\nvoid sbi_domain_memregion_init(unsigned long addr,\n\t\t\t\tunsigned long size,\n\t\t\t\tunsigned long flags,\n\t\t\t\tstruct sbi_domain_memregion *reg);\n\n/**\n * Check whether we can access specified address for given mode and\n * memory region flags under a domain\n * @param dom pointer to domain\n * @param addr the address to be checked\n * @param mode the privilege mode of access\n * @param access_flags bitmask of domain access types (enum sbi_domain_access)\n * @return TRUE if access allowed otherwise FALSE\n */\nbool sbi_domain_check_addr(const struct sbi_domain *dom,\n\t\t\t   unsigned long addr, unsigned long mode,\n\t\t\t   unsigned long access_flags);\n\n/** Dump domain details on the console */\nvoid sbi_domain_dump(const struct sbi_domain *dom, const char *suffix);\n\n/** Dump all domain details on the console */\nvoid sbi_domain_dump_all(const char *suffix);\n\n/**\n * Register a new domain\n * @param dom pointer to domain\n * @param assign_mask pointer to HART mask of HARTs assigned to the domain\n *\n * @return 0 on success and negative error code on failure\n */\nint sbi_domain_register(struct sbi_domain *dom,\n\t\t\tconst struct sbi_hartmask *assign_mask);\n\n/**\n * Add a memory region to the root domain\n * @param reg pointer to the memory region to be added\n *\n * @return 0 on success\n * @return SBI_EALREADY if memory region conflicts with the existing one\n * @return SBI_EINVAL otherwise\n */\nint sbi_domain_root_add_memregion(const struct sbi_domain_memregion *reg);\n\n/**\n * Add a memory range with its flags to the root domain\n * @param addr start physical address of memory range\n * @param size physical size of memory range\n * @param align alignment of memory region\n * @param region_flags memory range flags\n *\n * @return 0 on success\n * @return SBI_EALREADY if memory region conflicts with the existing one\n * @return SBI_EINVAL otherwise\n */\nint sbi_domain_root_add_memrange(unsigned long addr, unsigned long size,\n\t\t\t   unsigned long align, unsigned long region_flags);\n\n/** Finalize domain tables and startup non-root domains */\nint sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid);\n\n/** Initialize domains */\nint sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_ecall.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_ECALL_H__\n#define __SBI_ECALL_H__\n\n#include <sbi/sbi_types.h>\n#include <sbi/sbi_list.h>\n\n#define SBI_ECALL_VERSION_MAJOR\t\t1\n#define SBI_ECALL_VERSION_MINOR\t\t0\n#define SBI_OPENSBI_IMPID\t\t1\n\nstruct sbi_trap_regs;\nstruct sbi_trap_info;\n\nstruct sbi_ecall_extension {\n\tstruct sbi_dlist head;\n\tunsigned long extid_start;\n\tunsigned long extid_end;\n\tint (* probe)(unsigned long extid, unsigned long *out_val);\n\tint (* handle)(unsigned long extid, unsigned long funcid,\n\t\t       const struct sbi_trap_regs *regs,\n\t\t       unsigned long *out_val,\n\t\t       struct sbi_trap_info *out_trap);\n};\n\nu16 sbi_ecall_version_major(void);\n\nu16 sbi_ecall_version_minor(void);\n\nunsigned long sbi_ecall_get_impid(void);\n\nvoid sbi_ecall_set_impid(unsigned long impid);\n\nstruct sbi_ecall_extension *sbi_ecall_find_extension(unsigned long extid);\n\nint sbi_ecall_register_extension(struct sbi_ecall_extension *ext);\n\nvoid sbi_ecall_unregister_extension(struct sbi_ecall_extension *ext);\n\nint sbi_ecall_handler(struct sbi_trap_regs *regs);\n\nint sbi_ecall_init(void);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_ecall_interface.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_ECALL_INTERFACE_H__\n#define __SBI_ECALL_INTERFACE_H__\n\n/* clang-format off */\n\n/* SBI Extension IDs */\n#define SBI_EXT_0_1_SET_TIMER\t\t\t0x0\n#define SBI_EXT_0_1_CONSOLE_PUTCHAR\t\t0x1\n#define SBI_EXT_0_1_CONSOLE_GETCHAR\t\t0x2\n#define SBI_EXT_0_1_CLEAR_IPI\t\t\t0x3\n#define SBI_EXT_0_1_SEND_IPI\t\t\t0x4\n#define SBI_EXT_0_1_REMOTE_FENCE_I\t\t0x5\n#define SBI_EXT_0_1_REMOTE_SFENCE_VMA\t\t0x6\n#define SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID\t0x7\n#define SBI_EXT_0_1_SHUTDOWN\t\t\t0x8\n#define SBI_EXT_BASE\t\t\t\t0x10\n#define SBI_EXT_TIME\t\t\t\t0x54494D45\n#define SBI_EXT_IPI\t\t\t\t0x735049\n#define SBI_EXT_RFENCE\t\t\t\t0x52464E43\n#define SBI_EXT_HSM\t\t\t\t0x48534D\n#define SBI_EXT_SRST\t\t\t\t0x53525354\n#define SBI_EXT_PMU\t\t\t\t0x504D55\n\n/* SBI function IDs for BASE extension*/\n#define SBI_EXT_BASE_GET_SPEC_VERSION\t\t0x0\n#define SBI_EXT_BASE_GET_IMP_ID\t\t\t0x1\n#define SBI_EXT_BASE_GET_IMP_VERSION\t\t0x2\n#define SBI_EXT_BASE_PROBE_EXT\t\t\t0x3\n#define SBI_EXT_BASE_GET_MVENDORID\t\t0x4\n#define SBI_EXT_BASE_GET_MARCHID\t\t0x5\n#define SBI_EXT_BASE_GET_MIMPID\t\t\t0x6\n\n/* SBI function IDs for TIME extension*/\n#define SBI_EXT_TIME_SET_TIMER\t\t\t0x0\n\n/* SBI function IDs for IPI extension*/\n#define SBI_EXT_IPI_SEND_IPI\t\t\t0x0\n\n/* SBI function IDs for RFENCE extension*/\n#define SBI_EXT_RFENCE_REMOTE_FENCE_I\t\t0x0\n#define SBI_EXT_RFENCE_REMOTE_SFENCE_VMA\t0x1\n#define SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID\t0x2\n#define SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID\t0x3\n#define SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA\t0x4\n#define SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID\t0x5\n#define SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA\t0x6\n\n/* SBI function IDs for HSM extension */\n#define SBI_EXT_HSM_HART_START\t\t\t0x0\n#define SBI_EXT_HSM_HART_STOP\t\t\t0x1\n#define SBI_EXT_HSM_HART_GET_STATUS\t\t0x2\n#define SBI_EXT_HSM_HART_SUSPEND\t\t0x3\n\n#define SBI_HSM_STATE_STARTED\t\t\t0x0\n#define SBI_HSM_STATE_STOPPED\t\t\t0x1\n#define SBI_HSM_STATE_START_PENDING\t\t0x2\n#define SBI_HSM_STATE_STOP_PENDING\t\t0x3\n#define SBI_HSM_STATE_SUSPENDED\t\t\t0x4\n#define SBI_HSM_STATE_SUSPEND_PENDING\t\t0x5\n#define SBI_HSM_STATE_RESUME_PENDING\t\t0x6\n\n#define SBI_HSM_SUSP_BASE_MASK\t\t\t0x7fffffff\n#define SBI_HSM_SUSP_NON_RET_BIT\t\t0x80000000\n#define SBI_HSM_SUSP_PLAT_BASE\t\t\t0x10000000\n\n#define SBI_HSM_SUSPEND_RET_DEFAULT\t\t0x00000000\n#define SBI_HSM_SUSPEND_RET_PLATFORM\t\tSBI_HSM_SUSP_PLAT_BASE\n#define SBI_HSM_SUSPEND_RET_LAST\t\tSBI_HSM_SUSP_BASE_MASK\n#define SBI_HSM_SUSPEND_NON_RET_DEFAULT\t\tSBI_HSM_SUSP_NON_RET_BIT\n#define SBI_HSM_SUSPEND_NON_RET_PLATFORM\t(SBI_HSM_SUSP_NON_RET_BIT | \\\n\t\t\t\t\t\t SBI_HSM_SUSP_PLAT_BASE)\n#define SBI_HSM_SUSPEND_NON_RET_LAST\t\t(SBI_HSM_SUSP_NON_RET_BIT | \\\n\t\t\t\t\t\t SBI_HSM_SUSP_BASE_MASK)\n\n/* SBI function IDs for SRST extension */\n#define SBI_EXT_SRST_RESET\t\t\t0x0\n\n#define SBI_SRST_RESET_TYPE_SHUTDOWN\t\t0x0\n#define SBI_SRST_RESET_TYPE_COLD_REBOOT\t0x1\n#define SBI_SRST_RESET_TYPE_WARM_REBOOT\t0x2\n#define SBI_SRST_RESET_TYPE_LAST\tSBI_SRST_RESET_TYPE_WARM_REBOOT\n\n#define SBI_SRST_RESET_REASON_NONE\t0x0\n#define SBI_SRST_RESET_REASON_SYSFAIL\t0x1\n\n/* SBI function IDs for PMU extension */\n#define SBI_EXT_PMU_NUM_COUNTERS\t0x0\n#define SBI_EXT_PMU_COUNTER_GET_INFO\t0x1\n#define SBI_EXT_PMU_COUNTER_CFG_MATCH\t0x2\n#define SBI_EXT_PMU_COUNTER_START\t0x3\n#define SBI_EXT_PMU_COUNTER_STOP\t0x4\n#define SBI_EXT_PMU_COUNTER_FW_READ\t0x5\n\n/** General pmu event codes specified in SBI PMU extension */\nenum sbi_pmu_hw_generic_events_t {\n\tSBI_PMU_HW_NO_EVENT\t\t\t= 0,\n\tSBI_PMU_HW_CPU_CYCLES\t\t\t= 1,\n\tSBI_PMU_HW_INSTRUCTIONS\t\t\t= 2,\n\tSBI_PMU_HW_CACHE_REFERENCES\t\t= 3,\n\tSBI_PMU_HW_CACHE_MISSES\t\t\t= 4,\n\tSBI_PMU_HW_BRANCH_INSTRUCTIONS\t\t= 5,\n\tSBI_PMU_HW_BRANCH_MISSES\t\t= 6,\n\tSBI_PMU_HW_BUS_CYCLES\t\t\t= 7,\n\tSBI_PMU_HW_STALLED_CYCLES_FRONTEND\t= 8,\n\tSBI_PMU_HW_STALLED_CYCLES_BACKEND\t= 9,\n\tSBI_PMU_HW_REF_CPU_CYCLES\t\t= 10,\n\n\tSBI_PMU_HW_GENERAL_MAX,\n};\n\n/**\n * Generalized hardware cache events:\n *\n *       { L1-D, L1-I, LLC, ITLB, DTLB, BPU, NODE } x\n *       { read, write, prefetch } x\n *       { accesses, misses }\n */\nenum sbi_pmu_hw_cache_id {\n\tSBI_PMU_HW_CACHE_L1D\t\t= 0,\n\tSBI_PMU_HW_CACHE_L1I\t\t= 1,\n\tSBI_PMU_HW_CACHE_LL\t\t= 2,\n\tSBI_PMU_HW_CACHE_DTLB\t\t= 3,\n\tSBI_PMU_HW_CACHE_ITLB\t\t= 4,\n\tSBI_PMU_HW_CACHE_BPU\t\t= 5,\n\tSBI_PMU_HW_CACHE_NODE\t\t= 6,\n\n\tSBI_PMU_HW_CACHE_MAX,\n};\n\nenum sbi_pmu_hw_cache_op_id {\n\tSBI_PMU_HW_CACHE_OP_READ\t= 0,\n\tSBI_PMU_HW_CACHE_OP_WRITE\t= 1,\n\tSBI_PMU_HW_CACHE_OP_PREFETCH\t= 2,\n\n\tSBI_PMU_HW_CACHE_OP_MAX,\n};\n\nenum sbi_pmu_hw_cache_op_result_id {\n\tSBI_PMU_HW_CACHE_RESULT_ACCESS\t= 0,\n\tSBI_PMU_HW_CACHE_RESULT_MISS\t= 1,\n\n\tSBI_PMU_HW_CACHE_RESULT_MAX,\n};\n\n/**\n * Special \"firmware\" events provided by the OpenSBI, even if the hardware\n * does not support performance events. These events are encoded as a raw\n * event type in Linux kernel perf framework.\n */\nenum sbi_pmu_fw_event_code_id {\n\tSBI_PMU_FW_MISALIGNED_LOAD\t= 0,\n\tSBI_PMU_FW_MISALIGNED_STORE\t= 1,\n\tSBI_PMU_FW_ACCESS_LOAD\t\t= 2,\n\tSBI_PMU_FW_ACCESS_STORE\t\t= 3,\n\tSBI_PMU_FW_ILLEGAL_INSN\t\t= 4,\n\tSBI_PMU_FW_SET_TIMER\t\t= 5,\n\tSBI_PMU_FW_IPI_SENT\t\t= 6,\n\tSBI_PMU_FW_IPI_RECVD\t\t= 7,\n\tSBI_PMU_FW_FENCE_I_SENT\t\t= 8,\n\tSBI_PMU_FW_FENCE_I_RECVD\t= 9,\n\tSBI_PMU_FW_SFENCE_VMA_SENT\t= 10,\n\tSBI_PMU_FW_SFENCE_VMA_RCVD\t= 11,\n\tSBI_PMU_FW_SFENCE_VMA_ASID_SENT\t= 12,\n\tSBI_PMU_FW_SFENCE_VMA_ASID_RCVD\t= 13,\n\n\tSBI_PMU_FW_HFENCE_GVMA_SENT\t= 14,\n\tSBI_PMU_FW_HFENCE_GVMA_RCVD\t= 15,\n\tSBI_PMU_FW_HFENCE_GVMA_VMID_SENT = 16,\n\tSBI_PMU_FW_HFENCE_GVMA_VMID_RCVD = 17,\n\n\tSBI_PMU_FW_HFENCE_VVMA_SENT\t= 18,\n\tSBI_PMU_FW_HFENCE_VVMA_RCVD\t= 19,\n\tSBI_PMU_FW_HFENCE_VVMA_ASID_SENT = 20,\n\tSBI_PMU_FW_HFENCE_VVMA_ASID_RCVD = 21,\n\tSBI_PMU_FW_MAX,\n};\n\n/** SBI PMU event idx type */\nenum sbi_pmu_event_type_id {\n\tSBI_PMU_EVENT_TYPE_HW\t\t\t\t= 0x0,\n\tSBI_PMU_EVENT_TYPE_HW_CACHE\t\t\t= 0x1,\n\tSBI_PMU_EVENT_TYPE_HW_RAW\t\t\t= 0x2,\n\tSBI_PMU_EVENT_TYPE_FW\t\t\t\t= 0xf,\n\tSBI_PMU_EVENT_TYPE_MAX,\n};\n\n/** SBI PMU counter type */\nenum sbi_pmu_ctr_type {\n\tSBI_PMU_CTR_TYPE_HW = 0,\n\tSBI_PMU_CTR_TYPE_FW,\n};\n\n/* Helper macros to decode event idx */\n#define SBI_PMU_EVENT_IDX_OFFSET 20\n#define SBI_PMU_EVENT_IDX_MASK 0xFFFFF\n#define SBI_PMU_EVENT_IDX_CODE_MASK 0xFFFF\n#define SBI_PMU_EVENT_IDX_TYPE_MASK 0xF0000\n#define SBI_PMU_EVENT_RAW_IDX 0x20000\n\n#define SBI_PMU_EVENT_IDX_INVALID 0xFFFFFFFF\n\n#define SBI_PMU_EVENT_HW_CACHE_OPS_RESULT\t0x1\n#define SBI_PMU_EVENT_HW_CACHE_OPS_ID_MASK\t0x6\n#define SBI_PMU_EVENT_HW_CACHE_OPS_ID_OFFSET\t1\n#define SBI_PMU_EVENT_HW_CACHE_ID_MASK\t\t0xfff8\n#define SBI_PMU_EVENT_HW_CACHE_ID_OFFSET\t3\n\n/* Flags defined for config matching function */\n#define SBI_PMU_CFG_FLAG_SKIP_MATCH\t(1 << 0)\n#define SBI_PMU_CFG_FLAG_CLEAR_VALUE\t(1 << 1)\n#define SBI_PMU_CFG_FLAG_AUTO_START\t(1 << 2)\n#define SBI_PMU_CFG_FLAG_SET_VUINH\t(1 << 3)\n#define SBI_PMU_CFG_FLAG_SET_VSINH\t(1 << 4)\n#define SBI_PMU_CFG_FLAG_SET_UINH\t(1 << 5)\n#define SBI_PMU_CFG_FLAG_SET_SINH\t(1 << 6)\n#define SBI_PMU_CFG_FLAG_SET_MINH\t(1 << 7)\n\n/* Flags defined for counter start function */\n#define SBI_PMU_START_FLAG_SET_INIT_VALUE (1 << 0)\n\n/* Flags defined for counter stop function */\n#define SBI_PMU_STOP_FLAG_RESET (1 << 0)\n\n/* SBI base specification related macros */\n#define SBI_SPEC_VERSION_MAJOR_OFFSET\t\t24\n#define SBI_SPEC_VERSION_MAJOR_MASK\t\t0x7f\n#define SBI_SPEC_VERSION_MINOR_MASK\t\t0xffffff\n#define SBI_EXT_VENDOR_START\t\t\t0x09000000\n#define SBI_EXT_VENDOR_END\t\t\t0x09FFFFFF\n#define SBI_EXT_FIRMWARE_START\t\t\t0x0A000000\n#define SBI_EXT_FIRMWARE_END\t\t\t0x0AFFFFFF\n\n/* SBI return error codes */\n#define SBI_SUCCESS\t\t\t\t0\n#define SBI_ERR_FAILED\t\t\t\t-1\n#define SBI_ERR_NOT_SUPPORTED\t\t\t-2\n#define SBI_ERR_INVALID_PARAM\t\t\t-3\n#define SBI_ERR_DENIED\t\t\t\t-4\n#define SBI_ERR_INVALID_ADDRESS\t\t\t-5\n#define SBI_ERR_ALREADY_AVAILABLE\t\t-6\n#define SBI_ERR_ALREADY_STARTED\t\t\t-7\n#define SBI_ERR_ALREADY_STOPPED\t\t\t-8\n\n#define SBI_LAST_ERR\t\t\t\tSBI_ERR_ALREADY_STOPPED\n\n/* clang-format on */\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_emulate_csr.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_EMULATE_CSR_H__\n#define __SBI_EMULATE_CSR_H__\n\n#include <sbi/sbi_types.h>\n\nstruct sbi_trap_regs;\n\nint sbi_emulate_csr_read(int csr_num, struct sbi_trap_regs *regs,\n\t\t\t ulong *csr_val);\n\nint sbi_emulate_csr_write(int csr_num, struct sbi_trap_regs *regs,\n\t\t\t  ulong csr_val);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_error.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_ERROR_H__\n#define __SBI_ERROR_H__\n\n#include <sbi/sbi_ecall_interface.h>\n\n/* clang-format off */\n\n#define SBI_OK\t\t\t0\n#define SBI_EFAIL\t\tSBI_ERR_FAILED\n#define SBI_ENOTSUPP\t\tSBI_ERR_NOT_SUPPORTED\n#define SBI_EINVAL\t\tSBI_ERR_INVALID_PARAM\n#define SBI_EDENIED\t\tSBI_ERR_DENIED\n#define SBI_EINVALID_ADDR\tSBI_ERR_INVALID_ADDRESS\n#define SBI_EALREADY\t\tSBI_ERR_ALREADY_AVAILABLE\n#define SBI_EALREADY_STARTED\tSBI_ERR_ALREADY_STARTED\n#define SBI_EALREADY_STOPPED\tSBI_ERR_ALREADY_STOPPED\n\n#define SBI_ENODEV\t\t-1000\n#define SBI_ENOSYS\t\t-1001\n#define SBI_ETIMEDOUT\t\t-1002\n#define SBI_EIO\t\t\t-1003\n#define SBI_EILL\t\t-1004\n#define SBI_ENOSPC\t\t-1005\n#define SBI_ENOMEM\t\t-1006\n#define SBI_ETRAP\t\t-1007\n#define SBI_EUNKNOWN\t\t-1008\n#define SBI_ENOENT\t\t-1009\n\n/* clang-format on */\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_fifo.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra<atish.patra@wdc.com>\n *\n */\n\n#ifndef __SBI_FIFO_H__\n#define __SBI_FIFO_H__\n\n#include <sbi/riscv_locks.h>\n#include <sbi/sbi_types.h>\n\nstruct sbi_fifo {\n\tvoid *queue;\n\tspinlock_t qlock;\n\tu16 entry_size;\n\tu16 num_entries;\n\tu16 avail;\n\tu16 tail;\n};\n\nenum sbi_fifo_inplace_update_types {\n\tSBI_FIFO_SKIP,\n\tSBI_FIFO_UPDATED,\n\tSBI_FIFO_UNCHANGED,\n};\n\nint sbi_fifo_dequeue(struct sbi_fifo *fifo, void *data);\nint sbi_fifo_enqueue(struct sbi_fifo *fifo, void *data);\nvoid sbi_fifo_init(struct sbi_fifo *fifo, void *queue_mem, u16 entries,\n\t\t   u16 entry_size);\nint sbi_fifo_is_empty(struct sbi_fifo *fifo);\nint sbi_fifo_is_full(struct sbi_fifo *fifo);\nint sbi_fifo_inplace_update(struct sbi_fifo *fifo, void *in,\n\t\t\t    int (*fptr)(void *in, void *data));\nu16 sbi_fifo_avail(struct sbi_fifo *fifo);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_hart.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_HART_H__\n#define __SBI_HART_H__\n\n#include <sbi/sbi_types.h>\n\n/** Possible privileged specification versions of a hart */\nenum sbi_hart_priv_versions {\n\t/** Unknown privileged specification */\n\tSBI_HART_PRIV_VER_UNKNOWN = 0,\n\t/** Privileged specification v1.10 */\n\tSBI_HART_PRIV_VER_1_10 = 1,\n\t/** Privileged specification v1.11 */\n\tSBI_HART_PRIV_VER_1_11 = 2,\n\t/** Privileged specification v1.12 */\n\tSBI_HART_PRIV_VER_1_12 = 3,\n};\n\n/** Possible ISA extensions of a hart */\nenum sbi_hart_extensions {\n\t/** Hart has Sscofpmt extension */\n\tSBI_HART_EXT_SSCOFPMF = 0,\n\t/** HART has HW time CSR (extension name not available) */\n\tSBI_HART_EXT_TIME,\n\t/** HART has AIA M-mode CSRs */\n\tSBI_HART_EXT_SMAIA,\n\t/** HART has Smstateen CSR **/\n\tSBI_HART_EXT_SMSTATEEN,\n\t/** HART has Sstc extension */\n\tSBI_HART_EXT_SSTC,\n\n\t/** Maximum index of Hart extension */\n\tSBI_HART_EXT_MAX,\n};\n\nstruct sbi_hart_features {\n\tbool detected;\n\tint priv_version;\n\tunsigned long extensions;\n\tunsigned int pmp_count;\n\tunsigned int pmp_addr_bits;\n\tunsigned long pmp_gran;\n\tunsigned int mhpm_count;\n\tunsigned int mhpm_bits;\n};\n\nstruct sbi_scratch;\n\nint sbi_hart_reinit(struct sbi_scratch *scratch);\nint sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot);\n\nextern void (*sbi_hart_expected_trap)(void);\nstatic inline ulong sbi_hart_expected_trap_addr(void)\n{\n\treturn (ulong)sbi_hart_expected_trap;\n}\n\nunsigned int sbi_hart_mhpm_count(struct sbi_scratch *scratch);\nvoid sbi_hart_delegation_dump(struct sbi_scratch *scratch,\n\t\t\t      const char *prefix, const char *suffix);\nunsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch);\nunsigned long sbi_hart_pmp_granularity(struct sbi_scratch *scratch);\nunsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch);\nunsigned int sbi_hart_mhpm_bits(struct sbi_scratch *scratch);\nint sbi_hart_pmp_configure(struct sbi_scratch *scratch);\nint sbi_hart_priv_version(struct sbi_scratch *scratch);\nvoid sbi_hart_get_priv_version_str(struct sbi_scratch *scratch,\n\t\t\t\t   char *version_str, int nvstr);\nvoid sbi_hart_update_extension(struct sbi_scratch *scratch,\n\t\t\t       enum sbi_hart_extensions ext,\n\t\t\t       bool enable);\nbool sbi_hart_has_extension(struct sbi_scratch *scratch,\n\t\t\t    enum sbi_hart_extensions ext);\nvoid sbi_hart_get_extensions_str(struct sbi_scratch *scratch,\n\t\t\t\t char *extension_str, int nestr);\n\nvoid __attribute__((noreturn)) sbi_hart_hang(void);\n\nvoid __attribute__((noreturn))\nsbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,\n\t\t     unsigned long next_addr, unsigned long next_mode,\n\t\t     bool next_virt);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_hartmask.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_HARTMASK_H__\n#define __SBI_HARTMASK_H__\n\n#include <sbi/sbi_bitmap.h>\n\n/**\n * Maximum number of bits in a hartmask\n *\n * The hartmask is indexed using physical HART id so this define\n * also represents the maximum number of HART ids generic OpenSBI\n * can handle.\n */\n#define SBI_HARTMASK_MAX_BITS\t\t128\n\n/** Representation of hartmask */\nstruct sbi_hartmask {\n\tDECLARE_BITMAP(bits, SBI_HARTMASK_MAX_BITS);\n};\n\n/** Initialize hartmask to zero */\n#define SBI_HARTMASK_INIT(__m)\t\t\\\n\tbitmap_zero(((__m)->bits), SBI_HARTMASK_MAX_BITS)\n\n/** Initialize hartmask to zero except a particular HART id */\n#define SBI_HARTMASK_INIT_EXCEPT(__m, __h)\t\\\n\tbitmap_zero_except(((__m)->bits), (__h), SBI_HARTMASK_MAX_BITS)\n\n/**\n * Get underlying bitmap of hartmask\n * @param m the hartmask pointer\n */\n#define sbi_hartmask_bits(__m)\t\t((__m)->bits)\n\n/**\n * Set a HART in hartmask\n * @param h HART id to set\n * @param m the hartmask pointer\n */\nstatic inline void sbi_hartmask_set_hart(u32 h, struct sbi_hartmask *m)\n{\n\tif (h < SBI_HARTMASK_MAX_BITS)\n\t\t__set_bit(h, m->bits);\n}\n\n/**\n * Clear a HART in hartmask\n * @param h HART id to clear\n * @param m the hartmask pointer\n */\nstatic inline void sbi_hartmask_clear_hart(u32 h, struct sbi_hartmask *m)\n{\n\tif (h < SBI_HARTMASK_MAX_BITS)\n\t\t__clear_bit(h, m->bits);\n}\n\n/**\n * Test a HART in hartmask\n * @param h HART id to test\n * @param m the hartmask pointer\n */\nstatic inline int sbi_hartmask_test_hart(u32 h, const struct sbi_hartmask *m)\n{\n\tif (h < SBI_HARTMASK_MAX_BITS)\n\t\treturn __test_bit(h, m->bits);\n\treturn 0;\n}\n\n/**\n * Set all HARTs in a hartmask\n * @param dstp the hartmask pointer\n */\nstatic inline void sbi_hartmask_set_all(struct sbi_hartmask *dstp)\n{\n\tbitmap_fill(sbi_hartmask_bits(dstp), SBI_HARTMASK_MAX_BITS);\n}\n\n/**\n * Clear all HARTs in a hartmask\n * @param dstp the hartmask pointer\n */\nstatic inline void sbi_hartmask_clear_all(struct sbi_hartmask *dstp)\n{\n\tbitmap_zero(sbi_hartmask_bits(dstp), SBI_HARTMASK_MAX_BITS);\n}\n\n/**\n * *dstp = *src1p & *src2p\n * @param dstp the hartmask result\n * @param src1p the first input\n * @param src2p the second input\n */\nstatic inline void sbi_hartmask_and(struct sbi_hartmask *dstp,\n\t\t\t\t    const struct sbi_hartmask *src1p,\n\t\t\t\t    const struct sbi_hartmask *src2p)\n{\n\tbitmap_and(sbi_hartmask_bits(dstp), sbi_hartmask_bits(src1p),\n\t\t   sbi_hartmask_bits(src2p), SBI_HARTMASK_MAX_BITS);\n}\n\n/**\n * *dstp = *src1p | *src2p\n * @param dstp the hartmask result\n * @param src1p the first input\n * @param src2p the second input\n */\nstatic inline void sbi_hartmask_or(struct sbi_hartmask *dstp,\n\t\t\t\t   const struct sbi_hartmask *src1p,\n\t\t\t\t   const struct sbi_hartmask *src2p)\n{\n\tbitmap_or(sbi_hartmask_bits(dstp), sbi_hartmask_bits(src1p),\n\t\t  sbi_hartmask_bits(src2p), SBI_HARTMASK_MAX_BITS);\n}\n\n/**\n * *dstp = *src1p ^ *src2p\n * @param dstp the hartmask result\n * @param src1p the first input\n * @param src2p the second input\n */\nstatic inline void sbi_hartmask_xor(struct sbi_hartmask *dstp,\n\t\t\t\t    const struct sbi_hartmask *src1p,\n\t\t\t\t    const struct sbi_hartmask *src2p)\n{\n\tbitmap_xor(sbi_hartmask_bits(dstp), sbi_hartmask_bits(src1p),\n\t\t   sbi_hartmask_bits(src2p), SBI_HARTMASK_MAX_BITS);\n}\n\n/** Iterate over each HART in hartmask */\n#define sbi_hartmask_for_each_hart(__h, __m)\t\\\n\tfor_each_set_bit(__h, (__m)->bits, SBI_HARTMASK_MAX_BITS)\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_hfence.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_FENCE_H__\n#define __SBI_FENCE_H__\n\n/** Invalidate Stage2 TLBs for given VMID and guest physical address */\nvoid __sbi_hfence_gvma_vmid_gpa(unsigned long gpa_divby_4,\n\t\t\t\tunsigned long vmid);\n\n/** Invalidate Stage2 TLBs for given VMID */\nvoid __sbi_hfence_gvma_vmid(unsigned long vmid);\n\n/** Invalidate Stage2 TLBs for given guest physical address */\nvoid __sbi_hfence_gvma_gpa(unsigned long gpa_divby_4);\n\n/** Invalidate all possible Stage2 TLBs */\nvoid __sbi_hfence_gvma_all(void);\n\n/** Invalidate unified TLB entries for given asid and guest virtual address */\nvoid __sbi_hfence_vvma_asid_va(unsigned long va, unsigned long asid);\n\n/** Invalidate unified TLB entries for given ASID for a guest*/\nvoid __sbi_hfence_vvma_asid(unsigned long asid);\n\n/** Invalidate unified TLB entries for a given guest virtual address */\nvoid __sbi_hfence_vvma_va(unsigned long va);\n\n/** Invalidate all possible Stage2 TLBs */\nvoid __sbi_hfence_vvma_all(void);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_hsm.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#ifndef __SBI_HSM_H__\n#define __SBI_HSM_H__\n\n#include <sbi/sbi_types.h>\n\n/** Hart state managment device */\nstruct sbi_hsm_device {\n\t/** Name of the hart state managment device */\n\tchar name[32];\n\n\t/** Start (or power-up) the given hart */\n\tint (*hart_start)(u32 hartid, ulong saddr);\n\n\t/**\n\t * Stop (or power-down) the current hart from running. This call\n\t * doesn't expect to return if success.\n\t */\n\tint (*hart_stop)(void);\n\n\t/**\n\t * Put the current hart in platform specific suspend (or low-power)\n\t * state.\n\t *\n\t * For successful retentive suspend, the call will return 0 when\n\t * the hart resumes normal execution.\n\t *\n\t * For successful non-retentive suspend, the hart will resume from\n\t * the warm boot entry point.\n\t */\n\tint (*hart_suspend)(u32 suspend_type);\n\n\t/**\n\t * Perform platform-specific actions to resume from a suspended state.\n\t *\n\t * This includes restoring any platform state that was lost during\n\t * non-retentive suspend.\n\t */\n\tvoid (*hart_resume)(void);\n};\n\nstruct sbi_domain;\nstruct sbi_scratch;\n\nconst struct sbi_hsm_device *sbi_hsm_get_device(void);\n\nvoid sbi_hsm_set_device(const struct sbi_hsm_device *dev);\n\nint sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot);\nvoid __noreturn sbi_hsm_exit(struct sbi_scratch *scratch);\n\nint sbi_hsm_hart_start(struct sbi_scratch *scratch,\n\t\t       const struct sbi_domain *dom,\n\t\t       u32 hartid, ulong saddr, ulong smode, ulong priv);\nint sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow);\nvoid sbi_hsm_hart_resume_start(struct sbi_scratch *scratch);\nvoid sbi_hsm_hart_resume_finish(struct sbi_scratch *scratch);\nint sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,\n\t\t\t ulong raddr, ulong rmode, ulong priv);\nint sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid);\nint sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,\n\t\t\t\t    ulong hbase, ulong *out_hmask);\nvoid sbi_hsm_prepare_next_jump(struct sbi_scratch *scratch, u32 hartid);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_illegal_insn.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_ILLEGAl_INSN_H__\n#define __SBI_ILLEGAl_INSN_H__\n\n#include <sbi/sbi_types.h>\n\nstruct sbi_trap_regs;\n\nint sbi_illegal_insn_handler(ulong insn, struct sbi_trap_regs *regs);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_init.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_INIT_H__\n#define __SBI_INIT_H__\n\n#include <sbi/sbi_types.h>\n\nstruct sbi_scratch;\n\nvoid __noreturn sbi_init(struct sbi_scratch *scratch);\n\nunsigned long sbi_init_count(u32 hartid);\n\nvoid __noreturn sbi_exit(struct sbi_scratch *scratch);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_ipi.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_IPI_H__\n#define __SBI_IPI_H__\n\n#include <sbi/sbi_types.h>\n\n/* clang-format off */\n\n#define SBI_IPI_EVENT_MAX\t\t\t__riscv_xlen\n\n/* clang-format on */\n\n/** IPI hardware device */\nstruct sbi_ipi_device {\n\t/** Name of the IPI device */\n\tchar name[32];\n\n\t/** Send IPI to a target HART */\n\tvoid (*ipi_send)(u32 target_hart);\n\n\t/** Clear IPI for a target HART */\n\tvoid (*ipi_clear)(u32 target_hart);\n};\n\nstruct sbi_scratch;\n\n/** IPI event operations or callbacks */\nstruct sbi_ipi_event_ops {\n\t/** Name of the IPI event operations */\n\tchar name[32];\n\n\t/**\n\t * Update callback to save/enqueue data for remote HART\n\t * Note: This is an optional callback and it is called just before\n\t * triggering IPI to remote HART.\n\t */\n\tint (* update)(struct sbi_scratch *scratch,\n\t\t\tstruct sbi_scratch *remote_scratch,\n\t\t\tu32 remote_hartid, void *data);\n\n\t/**\n\t * Sync callback to wait for remote HART\n\t * Note: This is an optional callback and it is called just after\n\t * triggering IPI to remote HART.\n\t */\n\tvoid (* sync)(struct sbi_scratch *scratch);\n\n\t/**\n\t * Process callback to handle IPI event\n\t * Note: This is a mandatory callback and it is called on the\n\t * remote HART after IPI is triggered.\n\t */\n\tvoid (* process)(struct sbi_scratch *scratch);\n};\n\nint sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data);\n\nint sbi_ipi_event_create(const struct sbi_ipi_event_ops *ops);\n\nvoid sbi_ipi_event_destroy(u32 event);\n\nint sbi_ipi_send_smode(ulong hmask, ulong hbase);\n\nvoid sbi_ipi_clear_smode(void);\n\nint sbi_ipi_send_halt(ulong hmask, ulong hbase);\n\nvoid sbi_ipi_process(void);\n\nint sbi_ipi_raw_send(u32 target_hart);\n\nconst struct sbi_ipi_device *sbi_ipi_get_device(void);\n\nvoid sbi_ipi_set_device(const struct sbi_ipi_device *dev);\n\nint sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot);\n\nvoid sbi_ipi_exit(struct sbi_scratch *scratch);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_irqchip.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <apatel@ventanamicro.com>\n */\n\n#ifndef __SBI_IRQCHIP_H__\n#define __SBI_IRQCHIP_H__\n\n#include <sbi/sbi_types.h>\n\nstruct sbi_scratch;\nstruct sbi_trap_regs;\n\n/**\n * Set external interrupt handling function\n *\n * This function is called by OpenSBI platform code to set a handler for\n * external interrupts\n *\n * @param fn function pointer for handling external irqs\n */\nvoid sbi_irqchip_set_irqfn(int (*fn)(struct sbi_trap_regs *regs));\n\n/**\n * Process external interrupts\n *\n * This function is called by sbi_trap_handler() to handle external\n * interrupts.\n *\n * @param regs pointer for trap registers\n */\nint sbi_irqchip_process(struct sbi_trap_regs *regs);\n\n/** Initialize interrupt controllers */\nint sbi_irqchip_init(struct sbi_scratch *scratch, bool cold_boot);\n\n/** Exit interrupt controllers */\nvoid sbi_irqchip_exit(struct sbi_scratch *scratch);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_list.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Simple doubly-linked list library.\n *\n * Adapted from Xvisor source file libs/include/libs/list.h\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_LIST_H__\n#define __SBI_LIST_H__\n\n#include <sbi/sbi_types.h>\n\n#define SBI_LIST_POISON_PREV\t0xDEADBEEF\n#define SBI_LIST_POISON_NEXT\t0xFADEBABE\n\nstruct sbi_dlist {\n\tstruct sbi_dlist *next, *prev;\n};\n\n#define SBI_LIST_HEAD_INIT(__lname)\t{ &(__lname), &(__lname) }\n\n#define SBI_LIST_HEAD(_lname)\t\\\nstruct sbi_dlist _lname = SBI_LIST_HEAD_INIT(_lname)\n\n#define SBI_INIT_LIST_HEAD(ptr)\t\\\ndo { \\\n\t(ptr)->next = ptr; (ptr)->prev = ptr; \\\n} while (0);\n\nstatic inline void __sbi_list_add(struct sbi_dlist *new,\n\t\t\t\t  struct sbi_dlist *prev,\n\t\t\t\t  struct sbi_dlist *next)\n{\n\tnew->prev = prev;\n\tnew->next = next;\n\tprev->next = new;\n\tnext->prev = new;\n}\n\n/**\n * Checks if the list is empty or not.\n * @param head List head\n *\n * Retruns TRUE if list is empty, FALSE otherwise.\n */\nstatic inline bool sbi_list_empty(struct sbi_dlist *head)\n{\n\treturn head->next == head;\n}\n\n/**\n * Adds the new node after the given head.\n * @param new New node that needs to be added to list.\n * @param head List head after which the \"new\" node should be added.\n * Note: the new node is added after the head.\n */\nstatic inline void sbi_list_add(struct sbi_dlist *new, struct sbi_dlist *head)\n{\n\t__sbi_list_add(new, head, head->next);\n}\n\n/**\n * Adds a node at the tail where tnode points to tail node.\n * @param new The new node to be added before tail.\n * @param tnode The current tail node.\n * Note: the new node is added before tail node.\n */\nstatic inline void sbi_list_add_tail(struct sbi_dlist *new,\n\t\t\t\t     struct sbi_dlist *tnode)\n{\n\t__sbi_list_add(new, tnode->prev, tnode);\n}\n\nstatic inline void __sbi_list_del(struct sbi_dlist *prev,\n\t\t\t\t  struct sbi_dlist *next)\n{\n\tprev->next = next;\n\tnext->prev = prev;\n}\n\nstatic inline void __sbi_list_del_entry(struct sbi_dlist *entry)\n{\n\t__sbi_list_del(entry->prev, entry->next);\n}\n\n/**\n * Deletes a given entry from list.\n * @param node Node to be deleted.\n */\nstatic inline void sbi_list_del(struct sbi_dlist *entry)\n{\n\t__sbi_list_del(entry->prev, entry->next);\n\tentry->next = (void *)SBI_LIST_POISON_NEXT;\n\tentry->prev = (void *)SBI_LIST_POISON_PREV;\n}\n\n/**\n * Deletes entry from list and reinitialize it.\n * @param entry the element to delete from the list.\n */\nstatic inline void sbi_list_del_init(struct sbi_dlist *entry)\n{\n\t__sbi_list_del_entry(entry);\n\tSBI_INIT_LIST_HEAD(entry);\n}\n\n/**\n * Get the struct for this entry\n * @param ptr the &struct list_head pointer.\n * @param type the type of the struct this is embedded in.\n * @param member the name of the list_struct within the struct.\n */\n#define sbi_list_entry(ptr, type, member) \\\n\tcontainer_of(ptr, type, member)\n\n/**\n * Get the first element from a list\n * @param ptr the list head to take the element from.\n * @param type the type of the struct this is embedded in.\n * @param member the name of the list_struct within the struct.\n *\n * Note: that list is expected to be not empty.\n */\n#define sbi_list_first_entry(ptr, type, member) \\\n\tsbi_list_entry((ptr)->next, type, member)\n\n/**\n * Get the last element from a list\n * @param ptr the list head to take the element from.\n * @param type the type of the struct this is embedded in.\n * @param member the name of the list_head within the struct.\n *\n * Note: that list is expected to be not empty.\n */\n#define sbi_list_last_entry(ptr, type, member) \\\n\tsbi_list_entry((ptr)->prev, type, member)\n\n/**\n * Iterate over a list\n * @param pos the &struct list_head to use as a loop cursor.\n * @param head the head for your list.\n */\n#define sbi_list_for_each(pos, head) \\\n\tfor (pos = (head)->next; pos != (head); pos = pos->next)\n\n/**\n * Iterate over list of given type\n * @param pos the type * to use as a loop cursor.\n * @param head the head for your list.\n * @param member the name of the list_struct within the struct.\n */\n#define sbi_list_for_each_entry(pos, head, member) \\\n\tfor (pos = sbi_list_entry((head)->next, typeof(*pos), member);\t\\\n\t     &pos->member != (head); \t\\\n\t     pos = sbi_list_entry(pos->member.next, typeof(*pos), member))\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_math.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#ifndef __SBI_MATH_H__\n#define __SBI_MATH_H__\n\nunsigned long log2roundup(unsigned long x);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_misaligned_ldst.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_MISALIGNED_LDST_H__\n#define __SBI_MISALIGNED_LDST_H__\n\n#include <sbi/sbi_types.h>\n\nstruct sbi_trap_regs;\n\nint sbi_misaligned_load_handler(ulong addr, ulong tval2, ulong tinst,\n\t\t\t\tstruct sbi_trap_regs *regs);\n\nint sbi_misaligned_store_handler(ulong addr, ulong tval2, ulong tinst,\n\t\t\t\t struct sbi_trap_regs *regs);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_platform.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_PLATFORM_H__\n#define __SBI_PLATFORM_H__\n\n/**\n * OpenSBI 32-bit platform version with:\n * 1. upper 16-bits as major number\n * 2. lower 16-bits as minor number\n */\n#define SBI_PLATFORM_VERSION(Major, Minor) ((Major << 16) | Minor)\n\n/** Offset of opensbi_version in struct sbi_platform */\n#define SBI_PLATFORM_OPENSBI_VERSION_OFFSET (0x00)\n/** Offset of platform_version in struct sbi_platform */\n#define SBI_PLATFORM_VERSION_OFFSET (0x04)\n/** Offset of name in struct sbi_platform */\n#define SBI_PLATFORM_NAME_OFFSET (0x08)\n/** Offset of features in struct sbi_platform */\n#define SBI_PLATFORM_FEATURES_OFFSET (0x48)\n/** Offset of hart_count in struct sbi_platform */\n#define SBI_PLATFORM_HART_COUNT_OFFSET (0x50)\n/** Offset of hart_stack_size in struct sbi_platform */\n#define SBI_PLATFORM_HART_STACK_SIZE_OFFSET (0x54)\n/** Offset of platform_ops_addr in struct sbi_platform */\n#define SBI_PLATFORM_OPS_OFFSET (0x58)\n/** Offset of firmware_context in struct sbi_platform */\n#define SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET (0x58 + __SIZEOF_POINTER__)\n/** Offset of hart_index2id in struct sbi_platform */\n#define SBI_PLATFORM_HART_INDEX2ID_OFFSET (0x58 + (__SIZEOF_POINTER__ * 2))\n\n#define SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT\t\t(1UL << 12)\n\n#ifndef __ASSEMBLER__\n\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_version.h>\n\nstruct sbi_domain_memregion;\nstruct sbi_trap_info;\nstruct sbi_trap_regs;\nstruct sbi_hart_features;\n\n/** Possible feature flags of a platform */\nenum sbi_platform_features {\n\t/** Platform has fault delegation support */\n\tSBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 1),\n\n\t/** Last index of Platform features*/\n\tSBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_MFAULTS_DELEGATION,\n};\n\n/** Default feature set for a platform */\n#define SBI_PLATFORM_DEFAULT_FEATURES                                \\\n\t(SBI_PLATFORM_HAS_MFAULTS_DELEGATION)\n\n/** Platform functions */\nstruct sbi_platform_operations {\n\t/* Platform nascent initialization */\n\tint (*nascent_init)(void);\n\n\t/** Platform early initialization */\n\tint (*early_init)(bool cold_boot);\n\t/** Platform final initialization */\n\tint (*final_init)(bool cold_boot);\n\n\t/** Platform early exit */\n\tvoid (*early_exit)(void);\n\t/** Platform final exit */\n\tvoid (*final_exit)(void);\n\n\t/**\n\t * For platforms that do not implement misa, non-standard\n\t * methods are needed to determine cpu extension.\n\t */\n\tint (*misa_check_extension)(char ext);\n\n\t/**\n\t * For platforms that do not implement misa, non-standard\n\t * methods are needed to get MXL field of misa.\n\t */\n\tint (*misa_get_xlen)(void);\n\n\t/** Initialize (or populate) HART extensions for the platform */\n\tint (*extensions_init)(struct sbi_hart_features *hfeatures);\n\n\t/** Initialize (or populate) domains for the platform */\n\tint (*domains_init)(void);\n\n\t/** Initialize hw performance counters */\n\tint (*pmu_init)(void);\n\n\t/** Get platform specific mhpmevent value */\n\tuint64_t (*pmu_xlate_to_mhpmevent)(uint32_t event_idx, uint64_t data);\n\n\t/** Initialize the platform console */\n\tint (*console_init)(void);\n\n\t/** Initialize the platform interrupt controller for current HART */\n\tint (*irqchip_init)(bool cold_boot);\n\t/** Exit the platform interrupt controller for current HART */\n\tvoid (*irqchip_exit)(void);\n\n\t/** Initialize IPI for current HART */\n\tint (*ipi_init)(bool cold_boot);\n\t/** Exit IPI for current HART */\n\tvoid (*ipi_exit)(void);\n\n\t/** Get tlb flush limit value **/\n\tu64 (*get_tlbr_flush_limit)(void);\n\n\t/** Initialize platform timer for current HART */\n\tint (*timer_init)(bool cold_boot);\n\t/** Exit platform timer for current HART */\n\tvoid (*timer_exit)(void);\n\n\t/** platform specific SBI extension implementation probe function */\n\tint (*vendor_ext_check)(long extid);\n\t/** platform specific SBI extension implementation provider */\n\tint (*vendor_ext_provider)(long extid, long funcid,\n\t\t\t\t   const struct sbi_trap_regs *regs,\n\t\t\t\t   unsigned long *out_value,\n\t\t\t\t   struct sbi_trap_info *out_trap);\n};\n\n/** Platform default per-HART stack size for exception/interrupt handling */\n#define SBI_PLATFORM_DEFAULT_HART_STACK_SIZE\t8192\n\n/** Representation of a platform */\nstruct sbi_platform {\n\t/**\n\t * OpenSBI version this sbi_platform is based on.\n\t * It's a 32-bit value where upper 16-bits are major number\n\t * and lower 16-bits are minor number\n\t */\n\tu32 opensbi_version;\n\t/**\n\t * OpenSBI platform version released by vendor.\n\t * It's a 32-bit value where upper 16-bits are major number\n\t * and lower 16-bits are minor number\n\t */\n\tu32 platform_version;\n\t/** Name of the platform */\n\tchar name[64];\n\t/** Supported features */\n\tu64 features;\n\t/** Total number of HARTs */\n\tu32 hart_count;\n\t/** Per-HART stack size for exception/interrupt handling */\n\tu32 hart_stack_size;\n\t/** Pointer to sbi platform operations */\n\tunsigned long platform_ops_addr;\n\t/** Pointer to system firmware specific context */\n\tunsigned long firmware_context;\n\t/**\n\t * HART index to HART id table\n\t *\n\t * For used HART index <abc>:\n\t *     hart_index2id[<abc>] = some HART id\n\t * For unused HART index <abc>:\n\t *     hart_index2id[<abc>] = -1U\n\t *\n\t * If hart_index2id == NULL then we assume identity mapping\n\t *     hart_index2id[<abc>] = <abc>\n\t *\n\t * We have only two restrictions:\n\t * 1. HART index < sbi_platform hart_count\n\t * 2. HART id < SBI_HARTMASK_MAX_BITS\n\t */\n\tconst u32 *hart_index2id;\n};\n\n/**\n * Prevent modification of struct sbi_platform from affecting\n * SBI_PLATFORM_xxx_OFFSET\n */\n_Static_assert(\n\toffsetof(struct sbi_platform, opensbi_version)\n\t\t== SBI_PLATFORM_OPENSBI_VERSION_OFFSET,\n\t\"struct sbi_platform definition has changed, please redefine \"\n\t\"SBI_PLATFORM_OPENSBI_VERSION_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_platform, platform_version)\n\t\t== SBI_PLATFORM_VERSION_OFFSET,\n\t\"struct sbi_platform definition has changed, please redefine \"\n\t\"SBI_PLATFORM_VERSION_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_platform, name)\n\t\t== SBI_PLATFORM_NAME_OFFSET,\n\t\"struct sbi_platform definition has changed, please redefine \"\n\t\"SBI_PLATFORM_NAME_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_platform, features)\n\t\t== SBI_PLATFORM_FEATURES_OFFSET,\n\t\"struct sbi_platform definition has changed, please redefine \"\n\t\"SBI_PLATFORM_FEATURES_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_platform, hart_count)\n\t\t== SBI_PLATFORM_HART_COUNT_OFFSET,\n\t\"struct sbi_platform definition has changed, please redefine \"\n\t\"SBI_PLATFORM_HART_COUNT_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_platform, hart_stack_size)\n\t\t== SBI_PLATFORM_HART_STACK_SIZE_OFFSET,\n\t\"struct sbi_platform definition has changed, please redefine \"\n\t\"SBI_PLATFORM_HART_STACK_SIZE_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_platform, platform_ops_addr)\n\t\t== SBI_PLATFORM_OPS_OFFSET,\n\t\"struct sbi_platform definition has changed, please redefine \"\n\t\"SBI_PLATFORM_OPS_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_platform, firmware_context)\n\t\t== SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET,\n\t\"struct sbi_platform definition has changed, please redefine \"\n\t\"SBI_PLATFORM_FIRMWARE_CONTEXT_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_platform, hart_index2id)\n\t\t== SBI_PLATFORM_HART_INDEX2ID_OFFSET,\n\t\"struct sbi_platform definition has changed, please redefine \"\n\t\"SBI_PLATFORM_HART_INDEX2ID_OFFSET\");\n\n/** Get pointer to sbi_platform for sbi_scratch pointer */\n#define sbi_platform_ptr(__s) \\\n\t((const struct sbi_platform *)((__s)->platform_addr))\n/** Get pointer to sbi_platform for current HART */\n#define sbi_platform_thishart_ptr() ((const struct sbi_platform *) \\\n\t(sbi_scratch_thishart_ptr()->platform_addr))\n/** Get pointer to platform_ops_addr from platform pointer **/\n#define sbi_platform_ops(__p) \\\n\t((const struct sbi_platform_operations *)(__p)->platform_ops_addr)\n\n/** Check whether the platform supports fault delegation */\n#define sbi_platform_has_mfaults_delegation(__p) \\\n\t((__p)->features & SBI_PLATFORM_HAS_MFAULTS_DELEGATION)\n\n/**\n * Get HART index for the given HART\n *\n * @param plat pointer to struct sbi_platform\n * @param hartid HART ID\n *\n * @return 0 <= value < hart_count for valid HART otherwise -1U\n */\nu32 sbi_platform_hart_index(const struct sbi_platform *plat, u32 hartid);\n\n/**\n * Get the platform features in string format\n *\n * @param plat pointer to struct sbi_platform\n * @param features_str pointer to a char array where the features string will be\n *\t\t       updated\n * @param nfstr length of the features_str. The feature string will be truncated\n *\t\tif nfstr is not long enough.\n */\nvoid sbi_platform_get_features_str(const struct sbi_platform *plat,\n\t\t\t\t   char *features_str, int nfstr);\n\n/**\n * Get name of the platform\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return pointer to platform name on success and \"Unknown\" on failure\n */\nstatic inline const char *sbi_platform_name(const struct sbi_platform *plat)\n{\n\tif (plat)\n\t\treturn plat->name;\n\treturn \"Unknown\";\n}\n\n/**\n * Get the platform features\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return the features value currently set for the given platform\n */\nstatic inline unsigned long sbi_platform_get_features(\n\t\t\t\t\t\tconst struct sbi_platform *plat)\n{\n\tif (plat)\n\t\treturn plat->features;\n\treturn 0;\n}\n\n/**\n * Get platform specific tlb range flush maximum value. Any request with size\n * higher than this is upgraded to a full flush.\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return tlb range flush limit value. Returns a default (page size) if not\n * defined by platform.\n */\nstatic inline u64 sbi_platform_tlbr_flush_limit(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->get_tlbr_flush_limit)\n\t\treturn sbi_platform_ops(plat)->get_tlbr_flush_limit();\n\treturn SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT;\n}\n\n/**\n * Get total number of HARTs supported by the platform\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return total number of HARTs\n */\nstatic inline u32 sbi_platform_hart_count(const struct sbi_platform *plat)\n{\n\tif (plat)\n\t\treturn plat->hart_count;\n\treturn 0;\n}\n\n/**\n * Get per-HART stack size for exception/interrupt handling\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return stack size in bytes\n */\nstatic inline u32 sbi_platform_hart_stack_size(const struct sbi_platform *plat)\n{\n\tif (plat)\n\t\treturn plat->hart_stack_size;\n\treturn 0;\n}\n\n/**\n * Check whether given HART is invalid\n *\n * @param plat pointer to struct sbi_platform\n * @param hartid HART ID\n *\n * @return TRUE if HART is invalid and FALSE otherwise\n */\nstatic inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat,\n\t\t\t\t\t     u32 hartid)\n{\n\tif (!plat)\n\t\treturn TRUE;\n\tif (plat->hart_count <= sbi_platform_hart_index(plat, hartid))\n\t\treturn TRUE;\n\treturn FALSE;\n}\n\n/**\n * Nascent (very early) initialization for current HART\n *\n * NOTE: This function can be used to do very early initialization of\n * platform specific per-HART CSRs and devices.\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_nascent_init(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->nascent_init)\n\t\treturn sbi_platform_ops(plat)->nascent_init();\n\treturn 0;\n}\n\n/**\n * Early initialization for current HART\n *\n * @param plat pointer to struct sbi_platform\n * @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_early_init(const struct sbi_platform *plat,\n\t\t\t\t\t  bool cold_boot)\n{\n\tif (plat && sbi_platform_ops(plat)->early_init)\n\t\treturn sbi_platform_ops(plat)->early_init(cold_boot);\n\treturn 0;\n}\n\n/**\n * Final initialization for current HART\n *\n * @param plat pointer to struct sbi_platform\n * @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_final_init(const struct sbi_platform *plat,\n\t\t\t\t\t  bool cold_boot)\n{\n\tif (plat && sbi_platform_ops(plat)->final_init)\n\t\treturn sbi_platform_ops(plat)->final_init(cold_boot);\n\treturn 0;\n}\n\n/**\n * Early exit for current HART\n *\n * @param plat pointer to struct sbi_platform\n */\nstatic inline void sbi_platform_early_exit(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->early_exit)\n\t\tsbi_platform_ops(plat)->early_exit();\n}\n\n/**\n * Final exit for current HART\n *\n * @param plat pointer to struct sbi_platform\n */\nstatic inline void sbi_platform_final_exit(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->final_exit)\n\t\tsbi_platform_ops(plat)->final_exit();\n}\n\n/**\n * Check CPU extension in MISA\n *\n * @param plat pointer to struct sbi_platform\n * @param ext shorthand letter for CPU extensions\n *\n * @return zero for not-supported and non-zero for supported\n */\nstatic inline int sbi_platform_misa_extension(const struct sbi_platform *plat,\n\t\t\t\t\t      char ext)\n{\n\tif (plat && sbi_platform_ops(plat)->misa_check_extension)\n\t\treturn sbi_platform_ops(plat)->misa_check_extension(ext);\n\treturn 0;\n}\n\n/**\n * Get MXL field of MISA\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return 1/2/3 on success and error code on failure\n */\nstatic inline int sbi_platform_misa_xlen(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->misa_get_xlen)\n\t\treturn sbi_platform_ops(plat)->misa_get_xlen();\n\treturn -1;\n}\n\n/**\n * Initialize (or populate) HART extensions for the platform\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_extensions_init(\n\t\t\t\t\tconst struct sbi_platform *plat,\n\t\t\t\t\tstruct sbi_hart_features *hfeatures)\n{\n\tif (plat && sbi_platform_ops(plat)->extensions_init)\n\t\treturn sbi_platform_ops(plat)->extensions_init(hfeatures);\n\treturn 0;\n}\n\n/**\n * Initialize (or populate) domains for the platform\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_domains_init(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->domains_init)\n\t\treturn sbi_platform_ops(plat)->domains_init();\n\treturn 0;\n}\n\n/**\n * Setup hw PMU events for the platform\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_pmu_init(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->pmu_init)\n\t\treturn sbi_platform_ops(plat)->pmu_init();\n\treturn 0;\n}\n\n/**\n * Get the value to be written in mhpmeventx for event_idx\n *\n * @param plat pointer to struct sbi_platform\n * @param event_idx ID of the PMU event\n * @param data Additional configuration data passed from supervisor software\n *\n * @return expected value by the platform or 0 if platform doesn't know about\n * the event\n */\nstatic inline uint64_t sbi_platform_pmu_xlate_to_mhpmevent(const struct sbi_platform *plat,\n\t\t\t\t\t\t      uint32_t event_idx, uint64_t data)\n{\n\tif (plat && sbi_platform_ops(plat)->pmu_xlate_to_mhpmevent)\n\t\treturn sbi_platform_ops(plat)->pmu_xlate_to_mhpmevent(event_idx,\n\t\t\t\t\t\t\t\t      data);\n\treturn 0;\n}\n\n/**\n * Initialize the platform console\n *\n * @param plat pointer to struct sbi_platform\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_console_init(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->console_init)\n\t\treturn sbi_platform_ops(plat)->console_init();\n\treturn 0;\n}\n\n/**\n * Initialize the platform interrupt controller for current HART\n *\n * @param plat pointer to struct sbi_platform\n * @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_irqchip_init(const struct sbi_platform *plat,\n\t\t\t\t\t    bool cold_boot)\n{\n\tif (plat && sbi_platform_ops(plat)->irqchip_init)\n\t\treturn sbi_platform_ops(plat)->irqchip_init(cold_boot);\n\treturn 0;\n}\n\n/**\n * Exit the platform interrupt controller for current HART\n *\n * @param plat pointer to struct sbi_platform\n */\nstatic inline void sbi_platform_irqchip_exit(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->irqchip_exit)\n\t\tsbi_platform_ops(plat)->irqchip_exit();\n}\n\n/**\n * Initialize the platform IPI support for current HART\n *\n * @param plat pointer to struct sbi_platform\n * @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_ipi_init(const struct sbi_platform *plat,\n\t\t\t\t\tbool cold_boot)\n{\n\tif (plat && sbi_platform_ops(plat)->ipi_init)\n\t\treturn sbi_platform_ops(plat)->ipi_init(cold_boot);\n\treturn 0;\n}\n\n/**\n * Exit the platform IPI support for current HART\n *\n * @param plat pointer to struct sbi_platform\n */\nstatic inline void sbi_platform_ipi_exit(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->ipi_exit)\n\t\tsbi_platform_ops(plat)->ipi_exit();\n}\n\n/**\n * Initialize the platform timer for current HART\n *\n * @param plat pointer to struct sbi_platform\n * @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_timer_init(const struct sbi_platform *plat,\n\t\t\t\t\t  bool cold_boot)\n{\n\tif (plat && sbi_platform_ops(plat)->timer_init)\n\t\treturn sbi_platform_ops(plat)->timer_init(cold_boot);\n\treturn 0;\n}\n\n/**\n * Exit the platform timer for current HART\n *\n * @param plat pointer to struct sbi_platform\n */\nstatic inline void sbi_platform_timer_exit(const struct sbi_platform *plat)\n{\n\tif (plat && sbi_platform_ops(plat)->timer_exit)\n\t\tsbi_platform_ops(plat)->timer_exit();\n}\n\n/**\n * Check if a vendor extension is implemented or not.\n *\n * @param plat pointer to struct sbi_platform\n * @param extid\tvendor SBI extension id\n *\n * @return 0 if extid is not implemented and 1 if implemented\n */\nstatic inline int sbi_platform_vendor_ext_check(const struct sbi_platform *plat,\n\t\t\t\t\t\tlong extid)\n{\n\tif (plat && sbi_platform_ops(plat)->vendor_ext_check)\n\t\treturn sbi_platform_ops(plat)->vendor_ext_check(extid);\n\n\treturn 0;\n}\n\n/**\n * Invoke platform specific vendor SBI extension implementation.\n *\n * @param plat pointer to struct sbi_platform\n * @param extid\tvendor SBI extension id\n * @param funcid SBI function id within the extension id\n * @param regs pointer to trap registers passed by the caller\n * @param out_value output value that can be filled by the callee\n * @param out_trap trap info that can be filled by the callee\n *\n * @return 0 on success and negative error code on failure\n */\nstatic inline int sbi_platform_vendor_ext_provider(\n\t\t\t\t\tconst struct sbi_platform *plat,\n\t\t\t\t\tlong extid, long funcid,\n\t\t\t\t\tconst struct sbi_trap_regs *regs,\n\t\t\t\t\tunsigned long *out_value,\n\t\t\t\t\tstruct sbi_trap_info *out_trap)\n{\n\tif (plat && sbi_platform_ops(plat)->vendor_ext_provider) {\n\t\treturn sbi_platform_ops(plat)->vendor_ext_provider(extid,\n\t\t\t\t\t\t\t\tfuncid, regs,\n\t\t\t\t\t\t\t\tout_value,\n\t\t\t\t\t\t\t\tout_trap);\n\t}\n\n\treturn SBI_ENOTSUPP;\n}\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_pmu.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#ifndef __SBI_PMU_H__\n#define __SBI_PMU_H__\n\n#include <sbi/sbi_types.h>\n\nstruct sbi_scratch;\n\n/* Event related macros */\n/* Maximum number of hardware events that can mapped by OpenSBI */\n#define SBI_PMU_HW_EVENT_MAX 256\n\n/* Counter related macros */\n#define SBI_PMU_FW_CTR_MAX 16\n#define SBI_PMU_HW_CTR_MAX 32\n#define SBI_PMU_CTR_MAX\t   (SBI_PMU_HW_CTR_MAX + SBI_PMU_FW_CTR_MAX)\n#define SBI_PMU_FIXED_CTR_MASK 0x07\n\nstruct sbi_pmu_device {\n\t/** Name of the PMU platform device */\n\tchar name[32];\n\n\t/**\n\t * Validate event code of custom firmware event\n\t * Note: SBI_PMU_FW_MAX <= event_idx_code\n\t */\n\tint (*fw_event_validate_code)(uint32_t event_idx_code);\n\n\t/**\n\t * Match custom firmware counter with custom firmware event\n\t * Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX\n\t */\n\tbool (*fw_counter_match_code)(uint32_t counter_index,\n\t\t\t\t      uint32_t event_idx_code);\n\n\t/**\n\t * Read value of custom firmware counter\n\t * Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX\n\t */\n\tuint64_t (*fw_counter_read_value)(uint32_t counter_index);\n\n\t/**\n\t * Start custom firmware counter\n\t * Note: SBI_PMU_FW_MAX <= event_idx_code\n\t * Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX\n\t */\n\tint (*fw_counter_start)(uint32_t counter_index,\n\t\t\t\tuint32_t event_idx_code,\n\t\t\t\tuint64_t init_val, bool init_val_update);\n\n\t/**\n\t * Stop custom firmware counter\n\t * Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX\n\t */\n\tint (*fw_counter_stop)(uint32_t counter_index);\n\n\t/**\n\t * Custom enable irq for hardware counter\n\t * Note: 0 <= counter_index < SBI_PMU_HW_CTR_MAX\n\t */\n\tvoid (*hw_counter_enable_irq)(uint32_t counter_index);\n\n\t/**\n\t * Custom disable irq for hardware counter\n\t * Note: 0 <= counter_index < SBI_PMU_HW_CTR_MAX\n\t */\n\tvoid (*hw_counter_disable_irq)(uint32_t counter_index);\n\n\t/**\n\t * Custom function returning the machine-specific irq-bit.\n\t */\n\tint (*hw_counter_irq_bit)(void);\n};\n\n/** Get the PMU platform device */\nconst struct sbi_pmu_device *sbi_pmu_get_device(void);\n\n/** Set the PMU platform device */\nvoid sbi_pmu_set_device(const struct sbi_pmu_device *dev);\n\n/** Initialize PMU */\nint sbi_pmu_init(struct sbi_scratch *scratch, bool cold_boot);\n\n/** Reset PMU during hart exit */\nvoid sbi_pmu_exit(struct sbi_scratch *scratch);\n\n/** Return the pmu irq bit depending on extension existence */\nint sbi_pmu_irq_bit(void);\n\n/**\n * Add the hardware event to counter mapping information. This should be called\n * from the platform code to update the mapping table.\n * @param eidx_start Start of the event idx range for supported counters\n * @param eidx_end   End of the event idx range for supported counters\n * @param cmap       A bitmap representing counters supporting the event range\n * @return 0 on success, error otherwise.\n */\nint sbi_pmu_add_hw_event_counter_map(u32 eidx_start, u32 eidx_end, u32 cmap);\n\n/**\n * Add the raw hardware event selector and supported counter information. This\n * should be called from the platform code to update the mapping table.\n * @param info  a pointer to the hardware event info\n * @return 0 on success, error otherwise.\n */\n\nint sbi_pmu_add_raw_event_counter_map(uint64_t select, uint64_t select_mask, u32 cmap);\n\nint sbi_pmu_ctr_fw_read(uint32_t cidx, uint64_t *cval);\n\nint sbi_pmu_ctr_stop(unsigned long cidx_base, unsigned long cidx_mask,\n\t\t     unsigned long flag);\n\nint sbi_pmu_ctr_start(unsigned long cidx_base, unsigned long cidx_mask,\n\t\t      unsigned long flags, uint64_t ival);\n\nint sbi_pmu_ctr_get_info(uint32_t cidx, unsigned long *ctr_info);\n\nunsigned long sbi_pmu_num_ctr(void);\n\nint sbi_pmu_ctr_cfg_match(unsigned long cidx_base, unsigned long cidx_mask,\n\t\t\t  unsigned long flags, unsigned long event_idx,\n\t\t\t  uint64_t event_data);\n\nint sbi_pmu_ctr_incr_fw(enum sbi_pmu_fw_event_code_id fw_id);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_scratch.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_SCRATCH_H__\n#define __SBI_SCRATCH_H__\n\n#include <sbi/riscv_asm.h>\n\n/* clang-format off */\n\n/** Offset of fw_start member in sbi_scratch */\n#define SBI_SCRATCH_FW_START_OFFSET\t\t(0 * __SIZEOF_POINTER__)\n/** Offset of fw_size member in sbi_scratch */\n#define SBI_SCRATCH_FW_SIZE_OFFSET\t\t(1 * __SIZEOF_POINTER__)\n/** Offset of next_arg1 member in sbi_scratch */\n#define SBI_SCRATCH_NEXT_ARG1_OFFSET\t\t(2 * __SIZEOF_POINTER__)\n/** Offset of next_addr member in sbi_scratch */\n#define SBI_SCRATCH_NEXT_ADDR_OFFSET\t\t(3 * __SIZEOF_POINTER__)\n/** Offset of next_mode member in sbi_scratch */\n#define SBI_SCRATCH_NEXT_MODE_OFFSET\t\t(4 * __SIZEOF_POINTER__)\n/** Offset of warmboot_addr member in sbi_scratch */\n#define SBI_SCRATCH_WARMBOOT_ADDR_OFFSET\t(5 * __SIZEOF_POINTER__)\n/** Offset of platform_addr member in sbi_scratch */\n#define SBI_SCRATCH_PLATFORM_ADDR_OFFSET\t(6 * __SIZEOF_POINTER__)\n/** Offset of hartid_to_scratch member in sbi_scratch */\n#define SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET\t(7 * __SIZEOF_POINTER__)\n/** Offset of trap_exit member in sbi_scratch */\n#define SBI_SCRATCH_TRAP_EXIT_OFFSET\t\t(8 * __SIZEOF_POINTER__)\n/** Offset of tmp0 member in sbi_scratch */\n#define SBI_SCRATCH_TMP0_OFFSET\t\t\t(9 * __SIZEOF_POINTER__)\n/** Offset of options member in sbi_scratch */\n#define SBI_SCRATCH_OPTIONS_OFFSET\t\t(10 * __SIZEOF_POINTER__)\n/** Offset of extra space in sbi_scratch */\n#define SBI_SCRATCH_EXTRA_SPACE_OFFSET\t\t(11 * __SIZEOF_POINTER__)\n/** Maximum size of sbi_scratch (4KB) */\n#define SBI_SCRATCH_SIZE\t\t\t(0x1000)\n\n/* clang-format on */\n\n#ifndef __ASSEMBLER__\n\n#include <sbi/sbi_types.h>\n\n/** Representation of per-HART scratch space */\nstruct sbi_scratch {\n\t/** Start (or base) address of firmware linked to OpenSBI library */\n\tunsigned long fw_start;\n\t/** Size (in bytes) of firmware linked to OpenSBI library */\n\tunsigned long fw_size;\n\t/** Arg1 (or 'a1' register) of next booting stage for this HART */\n\tunsigned long next_arg1;\n\t/** Address of next booting stage for this HART */\n\tunsigned long next_addr;\n\t/** Privilege mode of next booting stage for this HART */\n\tunsigned long next_mode;\n\t/** Warm boot entry point address for this HART */\n\tunsigned long warmboot_addr;\n\t/** Address of sbi_platform */\n\tunsigned long platform_addr;\n\t/** Address of HART ID to sbi_scratch conversion function */\n\tunsigned long hartid_to_scratch;\n\t/** Address of trap exit function */\n\tunsigned long trap_exit;\n\t/** Temporary storage */\n\tunsigned long tmp0;\n\t/** Options for OpenSBI library */\n\tunsigned long options;\n};\n\n/**\n * Prevent modification of struct sbi_scratch from affecting\n * SBI_SCRATCH_xxx_OFFSET\n */\n_Static_assert(\n\toffsetof(struct sbi_scratch, fw_start)\n\t\t== SBI_SCRATCH_FW_START_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_FW_START_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, fw_size)\n\t\t== SBI_SCRATCH_FW_SIZE_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_FW_SIZE_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, next_arg1)\n\t\t== SBI_SCRATCH_NEXT_ARG1_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_NEXT_ARG1_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, next_addr)\n\t\t== SBI_SCRATCH_NEXT_ADDR_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_NEXT_ADDR_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, next_mode)\n\t\t== SBI_SCRATCH_NEXT_MODE_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_NEXT_MODE_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, warmboot_addr)\n\t\t== SBI_SCRATCH_WARMBOOT_ADDR_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_WARMBOOT_ADDR_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, platform_addr)\n\t\t== SBI_SCRATCH_PLATFORM_ADDR_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_PLATFORM_ADDR_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, hartid_to_scratch)\n\t\t== SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, trap_exit)\n\t\t== SBI_SCRATCH_TRAP_EXIT_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_TRAP_EXIT_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, tmp0)\n\t\t== SBI_SCRATCH_TMP0_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_TMP0_OFFSET\");\n_Static_assert(\n\toffsetof(struct sbi_scratch, options)\n\t\t== SBI_SCRATCH_OPTIONS_OFFSET,\n\t\"struct sbi_scratch definition has changed, please redefine \"\n\t\"SBI_SCRATCH_OPTIONS_OFFSET\");\n\n/** Possible options for OpenSBI library */\nenum sbi_scratch_options {\n\t/** Disable prints during boot */\n\tSBI_SCRATCH_NO_BOOT_PRINTS = (1 << 0),\n\t/** Enable runtime debug prints */\n\tSBI_SCRATCH_DEBUG_PRINTS = (1 << 1),\n};\n\n/** Get pointer to sbi_scratch for current HART */\n#define sbi_scratch_thishart_ptr() \\\n\t((struct sbi_scratch *)csr_read(CSR_MSCRATCH))\n\n/** Get Arg1 of next booting stage for current HART */\n#define sbi_scratch_thishart_arg1_ptr() \\\n\t((void *)(sbi_scratch_thishart_ptr()->next_arg1))\n\n/** Initialize scratch table and allocator */\nint sbi_scratch_init(struct sbi_scratch *scratch);\n\n/**\n * Allocate from extra space in sbi_scratch\n *\n * @return zero on failure and non-zero (>= SBI_SCRATCH_EXTRA_SPACE_OFFSET)\n * on success\n */\nunsigned long sbi_scratch_alloc_offset(unsigned long size);\n\n/** Free-up extra space in sbi_scratch */\nvoid sbi_scratch_free_offset(unsigned long offset);\n\n/** Get pointer from offset in sbi_scratch */\n#define sbi_scratch_offset_ptr(scratch, offset)\t(void *)((char *)(scratch) + (offset))\n\n/** Get pointer from offset in sbi_scratch for current HART */\n#define sbi_scratch_thishart_offset_ptr(offset)\t\\\n\t(void *)((char *)sbi_scratch_thishart_ptr() + (offset))\n\n/** HART id to scratch table */\nextern struct sbi_scratch *hartid_to_scratch_table[];\n\n/** Get sbi_scratch from HART id */\n#define sbi_hartid_to_scratch(__hartid) \\\n\thartid_to_scratch_table[__hartid]\n\n/** Last HART id having a sbi_scratch pointer */\nextern u32 last_hartid_having_scratch;\n\n/** Get last HART id having a sbi_scratch pointer */\n#define sbi_scratch_last_hartid()\tlast_hartid_having_scratch\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_string.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#ifndef __STRING_H__\n#define __STRING_H__\n\n#include <sbi/sbi_types.h>\n\n/*\n  Provides sbi_strcmp for the completeness of supporting string functions.\n  it is not recommended to use sbi_strcmp() but use sbi_strncmp instead.\n*/\n\nint sbi_strcmp(const char *a, const char *b);\n\nint sbi_strncmp(const char *a, const char *b, size_t count);\n\nsize_t sbi_strlen(const char *str);\n\nsize_t sbi_strnlen(const char *str, size_t count);\n\nchar *sbi_strcpy(char *dest, const char *src);\n\nchar *sbi_strncpy(char *dest, const char *src, size_t count);\n\nchar *sbi_strchr(const char *s, int c);\n\nchar *sbi_strrchr(const char *s, int c);\n\nvoid *sbi_memset(void *s, int c, size_t count);\n\nvoid *sbi_memcpy(void *dest, const void *src, size_t count);\n\nvoid *sbi_memmove(void *dest, const void *src, size_t count);\n\nint sbi_memcmp(const void *s1, const void *s2, size_t count);\n\nvoid *sbi_memchr(const void *s, int c, size_t count);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_system.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_SYSTEM_H__\n#define __SBI_SYSTEM_H__\n\n#include <sbi/sbi_types.h>\n#include <sbi/sbi_list.h>\n\n/** System reset hardware device */\nstruct sbi_system_reset_device {\n\t/** Name of the system reset device */\n\tchar name[32];\n\n\t/* Check whether reset type and reason supported by the device */\n\tint (*system_reset_check)(u32 reset_type, u32 reset_reason);\n\n\t/** Reset the system */\n\tvoid (*system_reset)(u32 reset_type, u32 reset_reason);\n\n\t/** List */\n\tstruct sbi_dlist node;\n};\n\nstatic inline struct sbi_system_reset_device *to_system_reset_device(\n\t\t\t\t\t\tstruct sbi_dlist *node)\n{\n\treturn container_of(node, struct sbi_system_reset_device, node);\n}\n\nconst struct sbi_system_reset_device *sbi_system_reset_get_device(\n\t\t\t\t\tu32 reset_type, u32 reset_reason);\n\nvoid sbi_system_reset_add_device(struct sbi_system_reset_device *dev);\n\nbool sbi_system_reset_supported(u32 reset_type, u32 reset_reason);\n\nvoid __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_timer.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_TIMER_H__\n#define __SBI_TIMER_H__\n\n#include <sbi/sbi_types.h>\n\n/** Timer hardware device */\nstruct sbi_timer_device {\n\t/** Name of the timer operations */\n\tchar name[32];\n\n\t/** Frequency of timer in HZ */\n\tunsigned long timer_freq;\n\n\t/** Get free-running timer value */\n\tu64 (*timer_value)(void);\n\n\t/** Start timer event for current HART */\n\tvoid (*timer_event_start)(u64 next_event);\n\n\t/** Stop timer event for current HART */\n\tvoid (*timer_event_stop)(void);\n};\n\nstruct sbi_scratch;\n\n/** Generic delay loop of desired granularity */\nvoid sbi_timer_delay_loop(ulong units, u64 unit_freq,\n\t\t\t  void (*delay_fn)(void *), void *opaque);\n\n/** Provide delay in terms of milliseconds */\nstatic inline void sbi_timer_mdelay(ulong msecs)\n{\n\tsbi_timer_delay_loop(msecs, 1000, NULL, NULL);\n}\n\n/** Provide delay in terms of microseconds */\nstatic inline void sbi_timer_udelay(ulong usecs)\n{\n\tsbi_timer_delay_loop(usecs, 1000000, NULL, NULL);\n}\n\n/**\n * A blocking function that will wait until @p predicate returns true or\n * @p timeout_ms milliseconds elapsed. @p arg will be passed as argument to\n * @p predicate function.\n *\n * @param predicate Pointer to a function that returns true if certain\n * condition is met. It shouldn't block the code execution.\n * @param arg Argument to pass to @p predicate.\n * @param timeout_ms Timeout value in milliseconds. The function will return\n * false if @p timeout_ms time period elapsed but still @p predicate doesn't\n * return true.\n *\n * @return true if @p predicate returns true within @p timeout_ms, false\n * otherwise.\n */\nbool sbi_timer_waitms_until(bool (*predicate)(void *), void *arg,\n\t\t\t    uint64_t timeout_ms);\n\n/** Get timer value for current HART */\nu64 sbi_timer_value(void);\n\n/** Get virtualized timer value for current HART */\nu64 sbi_timer_virt_value(void);\n\n/** Get timer delta value for current HART */\nu64 sbi_timer_get_delta(void);\n\n/** Set timer delta value for current HART */\nvoid sbi_timer_set_delta(ulong delta);\n\n/** Set upper 32-bits of timer delta value for current HART */\nvoid sbi_timer_set_delta_upper(ulong delta_upper);\n\n/** Start timer event for current HART */\nvoid sbi_timer_event_start(u64 next_event);\n\n/** Process timer event for current HART */\nvoid sbi_timer_process(void);\n\n/** Get current timer device */\nconst struct sbi_timer_device *sbi_timer_get_device(void);\n\n/** Register timer device */\nvoid sbi_timer_set_device(const struct sbi_timer_device *dev);\n\n/* Initialize timer */\nint sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot);\n\n/* Exit timer */\nvoid sbi_timer_exit(struct sbi_scratch *scratch);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_tlb.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_TLB_H__\n#define __SBI_TLB_H__\n\n#include <sbi/sbi_types.h>\n#include <sbi/sbi_hartmask.h>\n\n/* clang-format off */\n\n#define SBI_TLB_FLUSH_ALL\t\t\t((unsigned long)-1)\n\n/* clang-format on */\n\n#define SBI_TLB_FIFO_NUM_ENTRIES\t\t8\n\nstruct sbi_scratch;\n\nstruct sbi_tlb_info {\n\tunsigned long start;\n\tunsigned long size;\n\tunsigned long asid;\n\tunsigned long vmid;\n\tvoid (*local_fn)(struct sbi_tlb_info *tinfo);\n\tstruct sbi_hartmask smask;\n};\n\nvoid sbi_tlb_local_hfence_vvma(struct sbi_tlb_info *tinfo);\nvoid sbi_tlb_local_hfence_gvma(struct sbi_tlb_info *tinfo);\nvoid sbi_tlb_local_sfence_vma(struct sbi_tlb_info *tinfo);\nvoid sbi_tlb_local_hfence_vvma_asid(struct sbi_tlb_info *tinfo);\nvoid sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo);\nvoid sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo);\nvoid sbi_tlb_local_fence_i(struct sbi_tlb_info *tinfo);\n\n#define SBI_TLB_INFO_INIT(__p, __start, __size, __asid, __vmid, __lfn, __src) \\\ndo { \\\n\t(__p)->start = (__start); \\\n\t(__p)->size = (__size); \\\n\t(__p)->asid = (__asid); \\\n\t(__p)->vmid = (__vmid); \\\n\t(__p)->local_fn = (__lfn); \\\n\tSBI_HARTMASK_INIT_EXCEPT(&(__p)->smask, (__src)); \\\n} while (0)\n\n#define SBI_TLB_INFO_SIZE\t\tsizeof(struct sbi_tlb_info)\n\nint sbi_tlb_request(ulong hmask, ulong hbase, struct sbi_tlb_info *tinfo);\n\nint sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_trap.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_TRAP_H__\n#define __SBI_TRAP_H__\n\n#include <sbi/riscv_encoding.h>\n\n/* clang-format off */\n\n/** Index of zero member in sbi_trap_regs */\n#define SBI_TRAP_REGS_zero\t\t\t0\n/** Index of ra member in sbi_trap_regs */\n#define SBI_TRAP_REGS_ra\t\t\t1\n/** Index of sp member in sbi_trap_regs */\n#define SBI_TRAP_REGS_sp\t\t\t2\n/** Index of gp member in sbi_trap_regs */\n#define SBI_TRAP_REGS_gp\t\t\t3\n/** Index of tp member in sbi_trap_regs */\n#define SBI_TRAP_REGS_tp\t\t\t4\n/** Index of t0 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_t0\t\t\t5\n/** Index of t1 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_t1\t\t\t6\n/** Index of t2 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_t2\t\t\t7\n/** Index of s0 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s0\t\t\t8\n/** Index of s1 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s1\t\t\t9\n/** Index of a0 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_a0\t\t\t10\n/** Index of a1 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_a1\t\t\t11\n/** Index of a2 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_a2\t\t\t12\n/** Index of a3 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_a3\t\t\t13\n/** Index of a4 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_a4\t\t\t14\n/** Index of a5 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_a5\t\t\t15\n/** Index of a6 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_a6\t\t\t16\n/** Index of a7 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_a7\t\t\t17\n/** Index of s2 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s2\t\t\t18\n/** Index of s3 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s3\t\t\t19\n/** Index of s4 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s4\t\t\t20\n/** Index of s5 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s5\t\t\t21\n/** Index of s6 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s6\t\t\t22\n/** Index of s7 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s7\t\t\t23\n/** Index of s8 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s8\t\t\t24\n/** Index of s9 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s9\t\t\t25\n/** Index of s10 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s10\t\t\t26\n/** Index of s11 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_s11\t\t\t27\n/** Index of t3 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_t3\t\t\t28\n/** Index of t4 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_t4\t\t\t29\n/** Index of t5 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_t5\t\t\t30\n/** Index of t6 member in sbi_trap_regs */\n#define SBI_TRAP_REGS_t6\t\t\t31\n/** Index of mepc member in sbi_trap_regs */\n#define SBI_TRAP_REGS_mepc\t\t\t32\n/** Index of mstatus member in sbi_trap_regs */\n#define SBI_TRAP_REGS_mstatus\t\t\t33\n/** Index of mstatusH member in sbi_trap_regs */\n#define SBI_TRAP_REGS_mstatusH\t\t\t34\n/** Last member index in sbi_trap_regs */\n#define SBI_TRAP_REGS_last\t\t\t35\n\n/** Index of epc member in sbi_trap_info */\n#define SBI_TRAP_INFO_epc\t\t\t0\n/** Index of cause member in sbi_trap_info */\n#define SBI_TRAP_INFO_cause\t\t\t1\n/** Index of tval member in sbi_trap_info */\n#define SBI_TRAP_INFO_tval\t\t\t2\n/** Index of tval2 member in sbi_trap_info */\n#define SBI_TRAP_INFO_tval2\t\t\t3\n/** Index of tinst member in sbi_trap_info */\n#define SBI_TRAP_INFO_tinst\t\t\t4\n/** Index of gva member in sbi_trap_info */\n#define SBI_TRAP_INFO_gva\t\t\t5\n/** Last member index in sbi_trap_info */\n#define SBI_TRAP_INFO_last\t\t\t6\n\n/* clang-format on */\n\n/** Get offset of member with name 'x' in sbi_trap_regs */\n#define SBI_TRAP_REGS_OFFSET(x) ((SBI_TRAP_REGS_##x) * __SIZEOF_POINTER__)\n/** Size (in bytes) of sbi_trap_regs */\n#define SBI_TRAP_REGS_SIZE SBI_TRAP_REGS_OFFSET(last)\n\n/** Get offset of member with name 'x' in sbi_trap_info */\n#define SBI_TRAP_INFO_OFFSET(x) ((SBI_TRAP_INFO_##x) * __SIZEOF_POINTER__)\n/** Size (in bytes) of sbi_trap_info */\n#define SBI_TRAP_INFO_SIZE SBI_TRAP_INFO_OFFSET(last)\n\n#ifndef __ASSEMBLER__\n\n#include <sbi/sbi_types.h>\n\n/** Representation of register state at time of trap/interrupt */\nstruct sbi_trap_regs {\n\t/** zero register state */\n\tunsigned long zero;\n\t/** ra register state */\n\tunsigned long ra;\n\t/** sp register state */\n\tunsigned long sp;\n\t/** gp register state */\n\tunsigned long gp;\n\t/** tp register state */\n\tunsigned long tp;\n\t/** t0 register state */\n\tunsigned long t0;\n\t/** t1 register state */\n\tunsigned long t1;\n\t/** t2 register state */\n\tunsigned long t2;\n\t/** s0 register state */\n\tunsigned long s0;\n\t/** s1 register state */\n\tunsigned long s1;\n\t/** a0 register state */\n\tunsigned long a0;\n\t/** a1 register state */\n\tunsigned long a1;\n\t/** a2 register state */\n\tunsigned long a2;\n\t/** a3 register state */\n\tunsigned long a3;\n\t/** a4 register state */\n\tunsigned long a4;\n\t/** a5 register state */\n\tunsigned long a5;\n\t/** a6 register state */\n\tunsigned long a6;\n\t/** a7 register state */\n\tunsigned long a7;\n\t/** s2 register state */\n\tunsigned long s2;\n\t/** s3 register state */\n\tunsigned long s3;\n\t/** s4 register state */\n\tunsigned long s4;\n\t/** s5 register state */\n\tunsigned long s5;\n\t/** s6 register state */\n\tunsigned long s6;\n\t/** s7 register state */\n\tunsigned long s7;\n\t/** s8 register state */\n\tunsigned long s8;\n\t/** s9 register state */\n\tunsigned long s9;\n\t/** s10 register state */\n\tunsigned long s10;\n\t/** s11 register state */\n\tunsigned long s11;\n\t/** t3 register state */\n\tunsigned long t3;\n\t/** t4 register state */\n\tunsigned long t4;\n\t/** t5 register state */\n\tunsigned long t5;\n\t/** t6 register state */\n\tunsigned long t6;\n\t/** mepc register state */\n\tunsigned long mepc;\n\t/** mstatus register state */\n\tunsigned long mstatus;\n\t/** mstatusH register state (only for 32-bit) */\n\tunsigned long mstatusH;\n};\n\n/** Representation of trap details */\nstruct sbi_trap_info {\n\t/** epc Trap program counter */\n\tunsigned long epc;\n\t/** cause Trap exception cause */\n\tunsigned long cause;\n\t/** tval Trap value */\n\tunsigned long tval;\n\t/** tval2 Trap value 2 */\n\tunsigned long tval2;\n\t/** tinst Trap instruction */\n\tunsigned long tinst;\n\t/** gva Guest virtual address in tval flag */\n\tunsigned long gva;\n};\n\nstatic inline unsigned long sbi_regs_gva(const struct sbi_trap_regs *regs)\n{\n\t/*\n\t * If the hypervisor extension is not implemented, mstatus[h].GVA is a\n\t * WPRI field, which is guaranteed to read as zero. In addition, in this\n\t * case we don't read mstatush and instead pretend it is zero, which\n\t * handles privileged spec version < 1.12.\n\t */\n\n#if __riscv_xlen == 32\n\treturn (regs->mstatusH & MSTATUSH_GVA) ? 1 : 0;\n#else\n\treturn (regs->mstatus & MSTATUS_GVA) ? 1 : 0;\n#endif\n}\n\nint sbi_trap_redirect(struct sbi_trap_regs *regs,\n\t\t      struct sbi_trap_info *trap);\n\nstruct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs);\n\nvoid __noreturn sbi_trap_exit(const struct sbi_trap_regs *regs);\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_types.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_TYPES_H__\n#define __SBI_TYPES_H__\n\n#ifndef OPENSBI_EXTERNAL_SBI_TYPES\n\n/* clang-format off */\n\ntypedef char\t\t\ts8;\ntypedef unsigned char\t\tu8;\ntypedef unsigned char\t\tuint8_t;\n\ntypedef short\t\t\ts16;\ntypedef unsigned short\t\tu16;\ntypedef short\t\t\tint16_t;\ntypedef unsigned short\t\tuint16_t;\n\ntypedef int\t\t\ts32;\ntypedef unsigned int\t\tu32;\ntypedef int\t\t\tint32_t;\ntypedef unsigned int\t\tuint32_t;\n\n#if __riscv_xlen == 64\ntypedef long\t\t\ts64;\ntypedef unsigned long\t\tu64;\ntypedef long\t\t\tint64_t;\ntypedef unsigned long\t\tuint64_t;\n#define PRILX\t\t\t\"016lx\"\n#elif __riscv_xlen == 32\ntypedef long long\t\ts64;\ntypedef unsigned long long\tu64;\ntypedef long long\t\tint64_t;\ntypedef unsigned long long\tuint64_t;\n#define PRILX\t\t\t\"08lx\"\n#else\n#error \"Unexpected __riscv_xlen\"\n#endif\n\ntypedef int\t\t\tbool;\ntypedef unsigned long\t\tulong;\ntypedef unsigned long\t\tuintptr_t;\ntypedef unsigned long\t\tsize_t;\ntypedef long\t\t\tssize_t;\ntypedef unsigned long\t\tvirtual_addr_t;\ntypedef unsigned long\t\tvirtual_size_t;\ntypedef unsigned long\t\tphysical_addr_t;\ntypedef unsigned long\t\tphysical_size_t;\n\n#define TRUE\t\t\t1\n#define FALSE\t\t\t0\n#define true\t\t\tTRUE\n#define false\t\t\tFALSE\n\n#define NULL\t\t\t((void *)0)\n\n#define __packed\t\t__attribute__((packed))\n#define __noreturn\t\t__attribute__((noreturn))\n#define __aligned(x)\t\t__attribute__((aligned(x)))\n\n#define likely(x) __builtin_expect((x), 1)\n#define unlikely(x) __builtin_expect((x), 0)\n\n#ifndef __has_builtin\n#define __has_builtin(...) 0\n#endif\n\n#undef offsetof\n#if __has_builtin(__builtin_offsetof)\n#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE,MEMBER)\n#elif defined(__compiler_offsetof)\n#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE,MEMBER)\n#else\n#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)\n#endif\n\n#define container_of(ptr, type, member) ({\t\t\t\\\n\tconst typeof(((type *)0)->member) * __mptr = (ptr);\t\\\n\t(type *)((char *)__mptr - offsetof(type, member)); })\n\n#define array_size(x) \t(sizeof(x) / sizeof((x)[0]))\n\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define CLAMP(a, lo, hi) MIN(MAX(a, lo), hi)\n\n#define STR(x) XSTR(x)\n#define XSTR(x) #x\n\n#define ROUNDUP(a, b) ((((a)-1) / (b) + 1) * (b))\n#define ROUNDDOWN(a, b) ((a) / (b) * (b))\n\n/* clang-format on */\n\n#else\n/*\n * OPENSBI_EXTERNAL_SBI_TYPES could be defined in CFLAGS for using the\n * external definitions of data types and common macros.\n * OPENSBI_EXTERNAL_SBI_TYPES is the file name to external header file,\n * the external build system should address the additional include\n * directory ccordingly.\n */\n\n#define XSTR(x) #x\n#define STR(x) XSTR(x)\n#include STR(OPENSBI_EXTERNAL_SBI_TYPES)\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_unpriv.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_UNPRIV_H__\n#define __SBI_UNPRIV_H__\n\n#include <sbi/sbi_types.h>\n\nstruct sbi_scratch;\nstruct sbi_trap_info;\n\n#define DECLARE_UNPRIVILEGED_LOAD_FUNCTION(type)           \\\n\ttype sbi_load_##type(const type *addr,             \\\n\t\t\t     struct sbi_trap_info *trap);\n\n#define DECLARE_UNPRIVILEGED_STORE_FUNCTION(type)          \\\n\tvoid sbi_store_##type(type *addr, type val,        \\\n\t\t\t      struct sbi_trap_info *trap);\n\nDECLARE_UNPRIVILEGED_LOAD_FUNCTION(u8)\nDECLARE_UNPRIVILEGED_LOAD_FUNCTION(u16)\nDECLARE_UNPRIVILEGED_LOAD_FUNCTION(s8)\nDECLARE_UNPRIVILEGED_LOAD_FUNCTION(s16)\nDECLARE_UNPRIVILEGED_LOAD_FUNCTION(s32)\nDECLARE_UNPRIVILEGED_STORE_FUNCTION(u8)\nDECLARE_UNPRIVILEGED_STORE_FUNCTION(u16)\nDECLARE_UNPRIVILEGED_STORE_FUNCTION(u32)\nDECLARE_UNPRIVILEGED_LOAD_FUNCTION(u32)\nDECLARE_UNPRIVILEGED_LOAD_FUNCTION(u64)\nDECLARE_UNPRIVILEGED_STORE_FUNCTION(u64)\nDECLARE_UNPRIVILEGED_LOAD_FUNCTION(ulong)\n\nulong sbi_get_insn(ulong mepc, struct sbi_trap_info *trap);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi/sbi_version.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SBI_VERSION_H__\n#define __SBI_VERSION_H__\n\n#define OPENSBI_VERSION_MAJOR 1\n#define OPENSBI_VERSION_MINOR 2\n\n/**\n * OpenSBI 32-bit version with:\n * 1. upper 16-bits as major number\n * 2. lower 16-bits as minor number\n */\n#define OPENSBI_VERSION ((OPENSBI_VERSION_MAJOR << 16) | \\\n\t\t\t (OPENSBI_VERSION_MINOR))\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/fdt/fdt_domain.h",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * fdt_domain.c - Flat Device Tree Domain helper routines\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __FDT_DOMAIN_H__\n#define __FDT_DOMAIN_H__\n\n#include <sbi/sbi_types.h>\n\n#ifdef CONFIG_FDT_DOMAIN\n\nstruct sbi_domain;\n\n/**\n * Iterate over each domains in device tree\n *\n * @param fdt device tree blob\n * @param opaque private pointer for each iteration\n * @param fn callback function for each iteration\n *\n * @return 0 on success and negative error code on failure\n */\nint fdt_iterate_each_domain(void *fdt, void *opaque,\n\t\t\t    int (*fn)(void *fdt, int domain_offset,\n\t\t\t\t      void *opaque));\n\n/**\n * Iterate over each memregion of a domain in device tree\n *\n * @param fdt device tree blob\n * @param domain_offset domain DT node offset\n * @param opaque private pointer for each iteration\n * @param fn callback function for each iteration\n *\n * @return 0 on success and negative error code on failure\n */\nint fdt_iterate_each_memregion(void *fdt, int domain_offset, void *opaque,\n\t\t\t       int (*fn)(void *fdt, int domain_offset,\n\t\t\t\t\t int region_offset, u32 region_access,\n\t\t\t\t\t void *opaque));\n\n/**\n * Fix up the domain configuration in the device tree\n *\n * This routine:\n * 1. Disables MMIO devices not accessible to the coldboot HART domain\n * 2. Removes \"opensbi-domain\" DT property from CPU DT nodes\n * 3. Removes domain configuration DT node under /chosen DT node\n *\n * It is recommended that platform support call this function in\n * their final_init() platform operation.\n *\n * @param fdt device tree blob\n */\nvoid fdt_domain_fixup(void *fdt);\n\n/**\n * Populate domains from device tree\n *\n * It is recommended that platform support call this function in\n * their domains_init() platform operation.\n *\n * @param fdt device tree blob\n *\n * @return 0 on success and negative error code on failure\n */\nint fdt_domains_populate(void *fdt);\n\n#else\n\nstatic inline void fdt_domain_fixup(void *fdt) { }\nstatic inline int fdt_domains_populate(void *fdt) { return 0; }\n\n#endif\n\n#endif /* __FDT_DOMAIN_H__ */\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/fdt/fdt_fixup.h",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * fdt_fixup.h - Flat Device Tree manipulation helper routines\n * Implement platform specific DT fixups on top of libfdt. \n *\n * Copyright (C) 2020 Bin Meng <bmeng.cn@gmail.com>\n */\n\n#ifndef __FDT_FIXUP_H__\n#define __FDT_FIXUP_H__\n\n/**\n * Fix up the CPU node in the device tree\n *\n * This routine updates the \"status\" property of a CPU node in the device tree\n * to \"disabled\" if that hart is in disabled state in OpenSBI.\n *\n * It is recommended that platform codes call this helper in their final_init()\n *\n * @param fdt: device tree blob\n */\nvoid fdt_cpu_fixup(void *fdt);\n\n/**\n * Fix up the APLIC nodes in the device tree\n *\n * This routine disables APLIC nodes which are not accessible to the next\n * booting stage based on currently assigned domain.\n *\n * It is recommended that platform codes call this helper in their final_init()\n *\n * @param fdt: device tree blob\n */\nvoid fdt_aplic_fixup(void *fdt);\n\n/**\n * Fix up the IMSIC nodes in the device tree\n *\n * This routine disables IMSIC nodes which are not accessible to the next\n * booting stage based on currently assigned domain.\n *\n * It is recommended that platform codes call this helper in their final_init()\n *\n * @param fdt: device tree blob\n */\nvoid fdt_imsic_fixup(void *fdt);\n\n/**\n * Fix up the PLIC node in the device tree\n *\n * This routine updates the \"interrupt-extended\" property of the PLIC node in\n * the device tree to hide the M-mode external interrupt from CPUs.\n *\n * It is recommended that platform codes call this helper in their final_init()\n *\n * @param fdt: device tree blob\n */\nvoid fdt_plic_fixup(void *fdt);\n\n/**\n * Fix up the reserved memory node in the device tree\n *\n * This routine inserts a child node of the reserved memory node in the device\n * tree that describes the protected memory region done by OpenSBI via PMP.\n *\n * It is recommended that platform codes call this helper in their final_init()\n *\n * @param fdt: device tree blob\n * @return zero on success and -ve on failure\n */\nint fdt_reserved_memory_fixup(void *fdt);\n\n/**\n * Fix up the reserved memory subnodes in the device tree\n *\n * This routine adds the no-map property to the reserved memory subnodes so\n * that the OS does not map those PMP protected memory regions.\n *\n * Platform codes must call this helper in their final_init() after fdt_fixups()\n * if the OS should not map the PMP protected reserved regions.\n *\n * @param fdt: device tree blob\n * @return zero on success and -ve on failure\n */\nint fdt_reserved_memory_nomap_fixup(void *fdt);\n\n/**\n * General device tree fix-up\n *\n * This routine do all required device tree fix-ups for a typical platform.\n * It fixes up the PLIC node, IMSIC nodes, APLIC nodes, and the reserved\n * memory node in the device tree by calling the corresponding helper\n * routines to accomplish the task.\n *\n * It is recommended that platform codes call this helper in their final_init()\n *\n * @param fdt: device tree blob\n */\nvoid fdt_fixups(void *fdt);\n\n#endif /* __FDT_FIXUP_H__ */\n\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/fdt/fdt_helper.h",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * fdt_helper.h - Flat Device Tree parsing helper routines\n * Implement helper routines to parse FDT nodes on top of\n * libfdt for OpenSBI usage\n *\n * Copyright (C) 2020 Bin Meng <bmeng.cn@gmail.com>\n */\n\n#ifndef __FDT_HELPER_H__\n#define __FDT_HELPER_H__\n\n#include <sbi/sbi_types.h>\n#include <sbi/sbi_scratch.h>\n\nstruct fdt_match {\n\tconst char *compatible;\n\tconst void *data;\n};\n\n#define FDT_MAX_PHANDLE_ARGS 16\nstruct fdt_phandle_args {\n\tint node_offset;\n\tint args_count;\n\tu32 args[FDT_MAX_PHANDLE_ARGS];\n};\n\nstruct platform_uart_data {\n\tunsigned long addr;\n\tunsigned long freq;\n\tunsigned long baud;\n\tunsigned long reg_shift;\n\tunsigned long reg_io_width;\n\tunsigned long reg_offset;\n};\n\nconst struct fdt_match *fdt_match_node(void *fdt, int nodeoff,\n\t\t\t\t       const struct fdt_match *match_table);\n\nint fdt_find_match(void *fdt, int startoff,\n\t\t   const struct fdt_match *match_table,\n\t\t   const struct fdt_match **out_match);\n\nint fdt_parse_phandle_with_args(void *fdt, int nodeoff,\n\t\t\t\tconst char *prop, const char *cells_prop,\n\t\t\t\tint index, struct fdt_phandle_args *out_args);\n\nint fdt_get_node_addr_size(void *fdt, int node, int index,\n\t\t\t   uint64_t *addr, uint64_t *size);\n\nbool fdt_node_is_enabled(void *fdt, int nodeoff);\n\nint fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid);\n\nint fdt_parse_max_enabled_hart_id(void *fdt, u32 *max_hartid);\n\nint fdt_parse_timebase_frequency(void *fdt, unsigned long *freq);\n\nint fdt_parse_gaisler_uart_node(void *fdt, int nodeoffset,\n\t\t\t\tstruct platform_uart_data *uart);\n\nint fdt_parse_renesas_scif_node(void *fdt, int nodeoffset,\n\t\t\t\tstruct platform_uart_data *uart);\n\nint fdt_parse_shakti_uart_node(void *fdt, int nodeoffset,\n\t\t\t       struct platform_uart_data *uart);\n\nint fdt_parse_sifive_uart_node(void *fdt, int nodeoffset,\n\t\t\t       struct platform_uart_data *uart);\n\nint fdt_parse_uart_node(void *fdt, int nodeoffset,\n\t\t\tstruct platform_uart_data *uart);\n\nint fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,\n\t\t       const char *compatible);\n\nint fdt_parse_xlnx_uartlite_node(void *fdt, int nodeoffset,\n\t\t\t       struct platform_uart_data *uart);\n\nstruct aplic_data;\n\nint fdt_parse_aplic_node(void *fdt, int nodeoff, struct aplic_data *aplic);\n\nstruct imsic_data;\n\nbool fdt_check_imsic_mlevel(void *fdt);\n\nint fdt_parse_imsic_node(void *fdt, int nodeoff, struct imsic_data *imsic);\n\nstruct plic_data;\n\nint fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic);\n\nint fdt_parse_plic(void *fdt, struct plic_data *plic, const char *compat);\n\nint fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,\n\t\t\t  unsigned long *out_addr1, unsigned long *out_size1,\n\t\t\t  unsigned long *out_addr2, unsigned long *out_size2,\n\t\t\t  u32 *out_first_hartid, u32 *out_hart_count);\n\nint fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,\n\t\t\t  unsigned long *plmt_size, u32 *hart_count);\n\nint fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,\n\t\t\t  unsigned long *size, u32 *hart_count);\n\nint fdt_parse_compat_addr(void *fdt, uint64_t *addr,\n\t\t\t  const char *compatible);\n\nstatic inline void *fdt_get_address(void)\n{\n\treturn sbi_scratch_thishart_arg1_ptr();\n}\n\n#endif /* __FDT_HELPER_H__ */\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/fdt/fdt_pmu.h",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * fdt_pmu.c - Flat Device Tree PMU helper routines\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#ifndef __FDT_PMU_H__\n#define __FDT_PMU_H__\n\n#include <sbi/sbi_types.h>\n\n#ifdef CONFIG_FDT_PMU\n\n/**\n * Fix up the PMU node in the device tree\n *\n * This routine:\n * 1. Disables opensbi specific properties from the DT\n *\n * It is recommended that platform support call this function in\n * their final_init() platform operation.\n *\n * @param fdt device tree blob\n */\nvoid fdt_pmu_fixup(void *fdt);\n\n/**\n * Setup PMU data from device tree\n *\n * @param fdt device tree blob\n *\n * @return 0 on success and negative error code on failure\n */\nint fdt_pmu_setup(void *fdt);\n\n/**\n * Get the mhpmevent select value read from DT for a given event\n * @param event_idx Event ID of the given event\n *\n * @return The select value read from DT or 0 if given index was not found\n */\nuint64_t fdt_pmu_get_select_value(uint32_t event_idx);\n\n#else\n\nstatic inline void fdt_pmu_fixup(void *fdt) { }\nstatic inline int fdt_pmu_setup(void *fdt) { return 0; }\nstatic inline uint64_t fdt_pmu_get_select_value(uint32_t event_idx) { return 0; }\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/gpio/fdt_gpio.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __FDT_GPIO_H__\n#define __FDT_GPIO_H__\n\n#include <sbi_utils/gpio/gpio.h>\n\nstruct fdt_phandle_args;\n\n/** FDT based GPIO driver */\nstruct fdt_gpio {\n\tconst struct fdt_match *match_table;\n\tint (*xlate)(struct gpio_chip *chip,\n\t\t     const struct fdt_phandle_args *pargs,\n\t\t     struct gpio_pin *out_pin);\n\tint (*init)(void *fdt, int nodeoff, u32 phandle,\n\t\t    const struct fdt_match *match);\n};\n\n/** Get a GPIO pin using \"gpios\" DT property of client DT node */\nint fdt_gpio_pin_get(void *fdt, int nodeoff, int index,\n\t\t     struct gpio_pin *out_pin);\n\n/** Simple xlate function to convert two GPIO FDT cells into GPIO pin */\nint fdt_gpio_simple_xlate(struct gpio_chip *chip,\n\t\t\t  const struct fdt_phandle_args *pargs,\n\t\t\t  struct gpio_pin *out_pin);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/gpio/gpio.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __GPIO_H__\n#define __GPIO_H__\n\n#include <sbi/sbi_types.h>\n#include <sbi/sbi_list.h>\n\n#define GPIO_LINE_DIRECTION_IN\t1\n#define GPIO_LINE_DIRECTION_OUT\t0\n\n/** Representation of a GPIO pin */\nstruct gpio_pin {\n\t/** Pointer to the GPIO chip */\n\tstruct gpio_chip *chip;\n\t/** Identification of GPIO pin within GPIO chip */\n\tunsigned int offset;\n\t/**\n\t * Additional configuration flags of the GPIO pin desired\n\t * by GPIO clients.\n\t *\n\t * NOTE: GPIO chip can have custom configuration flags.\n\t */\n\tunsigned int flags;\n#define GPIO_FLAG_ACTIVE_LOW\t0x1\n#define GPIO_FLAG_SINGLE_ENDED\t0x2\n#define GPIO_FLAG_OPEN_DRAIN\t0x4\n#define GPIO_FLAG_TRANSITORY\t0x8\n#define GPIO_FLAG_PULL_UP\t0x10\n#define GPIO_FLAG_PULL_DOWN\t0x20\n};\n\n/** Representation of a GPIO chip */\nstruct gpio_chip {\n\t/** Pointer to GPIO driver owning this GPIO chip */\n\tvoid *driver;\n\t/** Uniquie ID of the GPIO chip assigned by the driver */\n\tunsigned int id;\n\t/** Number of GPIOs supported by the GPIO chip */\n\tunsigned int ngpio;\n\t/**\n\t * Get current direction of GPIO pin\n\t *\n\t * @return 0=output, 1=input, or negative error\n\t */\n\tint (*get_direction)(struct gpio_pin *gp);\n\t/**\n\t * Set input direction of GPIO pin\n\t *\n\t * @return 0 on success and negative error code on failure\n\t */\n\tint (*direction_input)(struct gpio_pin *gp);\n\t/**\n\t * Set output direction of GPIO pin with given output value\n\t *\n\t * @return 0 on success and negative error code on failure\n\t */\n\tint (*direction_output)(struct gpio_pin *gp, int value);\n\t/**\n\t * Get current value of GPIO pin\n\t *\n\t * @return 0=low, 1=high, or negative error\n\t */\n\tint (*get)(struct gpio_pin *gp);\n\t/** Set output value for GPIO pin */\n\tvoid (*set)(struct gpio_pin *gp, int value);\n\t/** List */\n\tstruct sbi_dlist node;\n};\n\nstatic inline struct gpio_chip *to_gpio_chip(struct sbi_dlist *node)\n{\n\treturn container_of(node, struct gpio_chip, node);\n}\n\n/** Find a registered GPIO chip */\nstruct gpio_chip *gpio_chip_find(unsigned int id);\n\n/** Register GPIO chip */\nint gpio_chip_add(struct gpio_chip *gc);\n\n/** Un-register GPIO chip */\nvoid gpio_chip_remove(struct gpio_chip *gc);\n\n/** Get current direction of GPIO pin */\nint gpio_get_direction(struct gpio_pin *gp);\n\n/** Set input direction of GPIO pin */\nint gpio_direction_input(struct gpio_pin *gp);\n\n/** Set output direction of GPIO pin */\nint gpio_direction_output(struct gpio_pin *gp, int value);\n\n/** Get current value of GPIO pin */\nint gpio_get(struct gpio_pin *gp);\n\n/** Set output value of GPIO pin */\nint gpio_set(struct gpio_pin *gp, int value);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/i2c/fdt_i2c.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 YADRO\n *\n * Authors:\n *   Nikita Shubin <n.shubin@yadro.com>\n */\n\n#ifndef __FDT_I2C_H__\n#define __FDT_I2C_H__\n\n#include <sbi_utils/i2c/i2c.h>\n\n/** FDT based I2C adapter driver */\nstruct fdt_i2c_adapter {\n\tconst struct fdt_match *match_table;\n\tint (*init)(void *fdt, int nodeoff,\n\t\t    const struct fdt_match *match);\n};\n\n/** Get I2C adapter identified by nodeoff */\nint fdt_i2c_adapter_get(void *fdt, int nodeoff,\n\t\t\tstruct i2c_adapter **out_adapter);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/i2c/i2c.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 YADRO\n *\n * Authors:\n *   Nikita Shubin <n.shubin@yadro.com>\n */\n\n#ifndef __I2C_H__\n#define __I2C_H__\n\n#include <sbi/sbi_types.h>\n#include <sbi/sbi_list.h>\n\n/** Representation of a I2C adapter */\nstruct i2c_adapter {\n\t/** Pointer to I2C driver owning this I2C adapter */\n\tvoid *driver;\n\n\t/** Unique ID of the I2C adapter assigned by the driver */\n\tint id;\n\n\t/**\n\t * Send buffer to given address, register\n\t *\n\t * @return 0 on success and negative error code on failure\n\t */\n\tint (*write)(struct i2c_adapter *ia, uint8_t addr, uint8_t reg,\n\t\t    uint8_t *buffer, int len);\n\n\t/**\n\t * Read buffer from given address, register\n\t *\n\t * @return 0 on success and negative error code on failure\n\t */\n\tint (*read)(struct i2c_adapter *ia, uint8_t addr, uint8_t reg,\n\t\t    uint8_t *buffer, int len);\n\n\t/** List */\n\tstruct sbi_dlist node;\n};\n\nstatic inline struct i2c_adapter *to_i2c_adapter(struct sbi_dlist *node)\n{\n\treturn container_of(node, struct i2c_adapter, node);\n}\n\n/** Find a registered I2C adapter */\nstruct i2c_adapter *i2c_adapter_find(int id);\n\n/** Register I2C adapter */\nint i2c_adapter_add(struct i2c_adapter *ia);\n\n/** Un-register I2C adapter */\nvoid i2c_adapter_remove(struct i2c_adapter *ia);\n\n/** Send to device on I2C adapter bus */\nint i2c_adapter_write(struct i2c_adapter *ia, uint8_t addr, uint8_t reg,\n\t\t      uint8_t *buffer, int len);\n\n/** Read from device on I2C adapter bus */\nint i2c_adapter_read(struct i2c_adapter *ia, uint8_t addr, uint8_t reg,\n\t\t     uint8_t *buffer, int len);\n\nstatic inline int i2c_adapter_reg_write(struct i2c_adapter *ia, uint8_t addr,\n\t\t\t\t uint8_t reg, uint8_t val)\n{\n\treturn i2c_adapter_write(ia, addr, reg, &val, 1);\n}\n\nstatic inline int i2c_adapter_reg_read(struct i2c_adapter *ia, uint8_t addr,\n\t\t\t\t       uint8_t reg, uint8_t *val)\n{\n\tuint8_t buf;\n\tint ret = i2c_adapter_read(ia, addr, reg, &buf, 1);\n\n\tif (ret)\n\t\treturn ret;\n\n\t*val = buf;\n\treturn 0;\n}\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/ipi/aclint_mswi.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __IPI_ACLINT_MSWI_H__\n#define __IPI_ACLINT_MSWI_H__\n\n#include <sbi/sbi_types.h>\n\n#define ACLINT_MSWI_ALIGN\t\t0x1000\n#define ACLINT_MSWI_SIZE\t\t0x4000\n#define ACLINT_MSWI_MAX_HARTS\t\t4095\n\n#define CLINT_MSWI_OFFSET\t\t0x0000\n\nstruct aclint_mswi_data {\n\t/* Public details */\n\tunsigned long addr;\n\tunsigned long size;\n\tu32 first_hartid;\n\tu32 hart_count;\n};\n\nint aclint_mswi_warm_init(void);\n\nint aclint_mswi_cold_init(struct aclint_mswi_data *mswi);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/ipi/andes_plicsw.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Andes Technology Corporation\n *\n * Authors:\n *   Zong Li <zong@andestech.com>\n *   Nylon Chen <nylon7@andestech.com>\n *   Leo Yu-Chi Liang <ycliang@andestech.com>\n *   Yu Chien Peter Lin <peterlin@andestech.com>\n */\n\n#ifndef _IPI_ANDES_PLICSW_H_\n#define _IPI_ANDES_PLICSW_H_\n\n#define PLICSW_PRIORITY_BASE 0x4\n\n#define PLICSW_PENDING_BASE 0x1000\n#define PLICSW_PENDING_STRIDE 0x8\n\n#define PLICSW_ENABLE_BASE 0x2000\n#define PLICSW_ENABLE_STRIDE 0x80\n\n#define PLICSW_CONTEXT_BASE 0x200000\n#define PLICSW_CONTEXT_STRIDE 0x1000\n#define PLICSW_CONTEXT_CLAIM 0x4\n\n#define PLICSW_HART_MASK 0x01010101\n\n#define PLICSW_HART_MAX_NR 8\n\n#define PLICSW_REGION_ALIGN 0x1000\n\nstruct plicsw_data {\n\tunsigned long addr;\n\tunsigned long size;\n\tuint32_t hart_count;\n\t/* hart id to source id table */\n\tuint32_t source_id[PLICSW_HART_MAX_NR];\n};\n\nint plicsw_warm_ipi_init(void);\n\nint plicsw_cold_ipi_init(struct plicsw_data *plicsw);\n\n#endif /* _IPI_ANDES_PLICSW_H_ */\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/ipi/fdt_ipi.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __FDT_IPI_H__\n#define __FDT_IPI_H__\n\n#include <sbi/sbi_types.h>\n\n#ifdef CONFIG_FDT_IPI\n\nstruct fdt_ipi {\n\tconst struct fdt_match *match_table;\n\tint (*cold_init)(void *fdt, int nodeoff, const struct fdt_match *match);\n\tint (*warm_init)(void);\n\tvoid (*exit)(void);\n};\n\nvoid fdt_ipi_exit(void);\n\nint fdt_ipi_init(bool cold_boot);\n\n#else\n\nstatic inline void fdt_ipi_exit(void) { }\nstatic inline int fdt_ipi_init(bool cold_boot) { return 0; }\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/irqchip/aplic.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __IRQCHIP_APLIC_H__\n#define __IRQCHIP_APLIC_H__\n\n#include <sbi/sbi_types.h>\n\n#define APLIC_MAX_DELEGATE\t16\n\nstruct aplic_msicfg_data {\n\tunsigned long lhxs;\n\tunsigned long lhxw;\n\tunsigned long hhxs;\n\tunsigned long hhxw;\n\tunsigned long base_addr;\n};\n\nstruct aplic_delegate_data {\n\tu32 first_irq;\n\tu32 last_irq;\n\tu32 child_index;\n};\n\nstruct aplic_data {\n\tunsigned long addr;\n\tunsigned long size;\n\tunsigned long num_idc;\n\tunsigned long num_source;\n\tbool targets_mmode;\n\tbool has_msicfg_mmode;\n\tstruct aplic_msicfg_data msicfg_mmode;\n\tbool has_msicfg_smode;\n\tstruct aplic_msicfg_data msicfg_smode;\n\tstruct aplic_delegate_data delegate[APLIC_MAX_DELEGATE];\n};\n\nint aplic_cold_irqchip_init(struct aplic_data *aplic);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/irqchip/fdt_irqchip.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __FDT_IRQCHIP_H__\n#define __FDT_IRQCHIP_H__\n\n#include <sbi/sbi_types.h>\n\n#ifdef CONFIG_FDT_IRQCHIP\n\nstruct fdt_irqchip {\n\tconst struct fdt_match *match_table;\n\tint (*cold_init)(void *fdt, int nodeoff, const struct fdt_match *match);\n\tint (*warm_init)(void);\n\tvoid (*exit)(void);\n};\n\nvoid fdt_irqchip_exit(void);\n\nint fdt_irqchip_init(bool cold_boot);\n\n#else\n\nstatic inline void fdt_irqchip_exit(void) { }\n\nstatic inline int fdt_irqchip_init(bool cold_boot) { return 0; }\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/irqchip/fdt_irqchip_plic.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Samuel Holland <samuel@sholland.org>\n */\n\n#ifndef __IRQCHIP_FDT_IRQCHIP_PLIC_H__\n#define __IRQCHIP_FDT_IRQCHIP_PLIC_H__\n\n#include <sbi/sbi_types.h>\n\n/**\n * Save the PLIC priority state\n * @param priority pointer to the memory region for the saved priority\n * @param num size of the memory region including interrupt source 0\n */\nvoid fdt_plic_priority_save(u8 *priority, u32 num);\n\n/**\n * Restore the PLIC priority state\n * @param priority pointer to the memory region for the saved priority\n * @param num size of the memory region including interrupt source 0\n */\nvoid fdt_plic_priority_restore(const u8 *priority, u32 num);\n\nvoid fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold, u32 num);\n\nvoid fdt_plic_context_restore(bool smode, const u32 *enable, u32 threshold,\n\t\t\t      u32 num);\n\nvoid thead_plic_restore(void);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/irqchip/imsic.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __IRQCHIP_IMSIC_H__\n#define __IRQCHIP_IMSIC_H__\n\n#include <sbi/sbi_types.h>\n\n#define IMSIC_MMIO_PAGE_SHIFT\t\t12\n#define IMSIC_MMIO_PAGE_SZ\t\t(1UL << IMSIC_MMIO_PAGE_SHIFT)\n\n#define IMSIC_MAX_REGS\t\t\t16\n\nstruct imsic_regs {\n\tunsigned long addr;\n\tunsigned long size;\n};\n\nstruct imsic_data {\n\tbool targets_mmode;\n\tu32 guest_index_bits;\n\tu32 hart_index_bits;\n\tu32 group_index_bits;\n\tu32 group_index_shift;\n\tunsigned long num_ids;\n\tstruct imsic_regs regs[IMSIC_MAX_REGS];\n};\n\n#ifdef CONFIG_IRQCHIP_IMSIC\n\nint imsic_map_hartid_to_data(u32 hartid, struct imsic_data *imsic, int file);\n\nstruct imsic_data *imsic_get_data(u32 hartid);\n\nint imsic_get_target_file(u32 hartid);\n\nvoid imsic_local_irqchip_init(void);\n\nint imsic_warm_irqchip_init(void);\n\nint imsic_data_check(struct imsic_data *imsic);\n\nint imsic_cold_irqchip_init(struct imsic_data *imsic);\n\n#else\n\nstatic inline void imsic_local_irqchip_init(void) { }\n\nstatic inline int imsic_data_check(struct imsic_data *imsic) { return 0; }\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/irqchip/plic.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __IRQCHIP_PLIC_H__\n#define __IRQCHIP_PLIC_H__\n\n#include <sbi/sbi_types.h>\n\nstruct plic_data {\n\tunsigned long addr;\n\tunsigned long num_src;\n};\n\n/* So far, priorities on all consumers of these functions fit in 8 bits. */\nvoid plic_priority_save(const struct plic_data *plic, u8 *priority, u32 num);\n\nvoid plic_priority_restore(const struct plic_data *plic, const u8 *priority,\n\t\t\t   u32 num);\n\nvoid plic_context_save(const struct plic_data *plic, int context_id,\n\t\t       u32 *enable, u32 *threshold, u32 num);\n\nvoid plic_context_restore(const struct plic_data *plic, int context_id,\n\t\t\t  const u32 *enable, u32 threshold, u32 num);\n\nint plic_context_init(const struct plic_data *plic, int context_id,\n\t\t      bool enable, u32 threshold);\n\nint plic_warm_irqchip_init(const struct plic_data *plic,\n\t\t\t   int m_cntx_id, int s_cntx_id);\n\nint plic_cold_irqchip_init(const struct plic_data *plic);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/reset/fdt_reset.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __FDT_RESET_H__\n#define __FDT_RESET_H__\n\n#include <sbi/sbi_types.h>\n\nstruct fdt_reset {\n\tconst struct fdt_match *match_table;\n\tint (*init)(void *fdt, int nodeoff, const struct fdt_match *match);\n};\n\n#ifdef CONFIG_FDT_RESET\n\n/**\n * fdt_reset_driver_init() - initialize reset driver based on the device-tree\n */\nint fdt_reset_driver_init(void *fdt, struct fdt_reset *drv);\n\n/**\n * fdt_reset_init() - initialize reset drivers based on the device-tree\n *\n * This function shall be invoked in final init.\n */\nvoid fdt_reset_init(void);\n\n#else\n\nstatic inline int fdt_reset_driver_init(void *fdt, struct fdt_reset *drv)\n{\n\treturn 0;\n}\nstatic inline void fdt_reset_init(void) { }\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/cadence-uart.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 StarFive Technology Co., Ltd.\n *\n * Author: Jun Liang Tan <junliang.tan@linux.starfivetech.com>\n */\n\n#ifndef __SERIAL_CADENCE_UART_H__\n#define __SERIAL_CADENCE_UART_H__\n\n#include <sbi/sbi_types.h>\n\nint cadence_uart_init(unsigned long base, u32 in_freq, u32 baudrate);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/fdt_serial.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __FDT_SERIAL_H__\n#define __FDT_SERIAL_H__\n\n#include <sbi/sbi_types.h>\n\n#ifdef CONFIG_FDT_SERIAL\n\nstruct fdt_serial {\n\tconst struct fdt_match *match_table;\n\tint (*init)(void *fdt, int nodeoff, const struct fdt_match *match);\n};\n\nint fdt_serial_init(void);\n\n#else\n\nstatic inline int fdt_serial_init(void) { return 0; }\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/gaisler-uart.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Cobham Gaisler AB.\n *\n * Authors:\n *   Daniel Cederman <cederman@gaisler.com>\n */\n\n#ifndef __SERIAL_GAISLER_APBUART_H__\n#define __SERIAL_GAISLER_APBUART_H__\n\n#include <sbi/sbi_types.h>\n\nint gaisler_uart_init(unsigned long base, u32 in_freq, u32 baudrate);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/litex-uart.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Gabriel Somlo\n *\n * Authors:\n *   Gabriel Somlo <gsomlo@gmail.com>\n */\n\n#ifndef __SERIAL_LITEX_UART_H__\n#define __SERIAL_LITEX_UART_H__\n\n#include <sbi/sbi_types.h>\n\nint litex_uart_init(unsigned long base);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/renesas-scif.h",
    "content": "/* SPDX-License-Identifier: BSD-2-Clause */\n/*\n * Copyright (C) 2022 Renesas Electronics Corporation\n */\n\n#ifndef __SERIAL_RENESAS_SCIF_H__\n#define __SERIAL_RENESAS_SCIF_H__\n\nint renesas_scif_init(unsigned long base, u32 in_freq, u32 baudrate);\n\n#endif /* __SERIAL_RENESAS_SCIF_H__ */\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/semihosting.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <apatel@ventanamicro.com>\n *   Kautuk Consul <kconsul@ventanamicro.com>\n */\n\n#ifndef __SERIAL_SEMIHOSTING_H__\n#define __SERIAL_SEMIHOSTING_H__\n\n#include <sbi/sbi_types.h>\n\n/**\n * enum semihosting_open_mode - Numeric file modes for use with semihosting_open()\n * MODE_READ: 'r'\n * MODE_BINARY: 'b'\n * MODE_PLUS: '+'\n * MODE_WRITE: 'w'\n * MODE_APPEND: 'a'\n *\n * These modes represent the mode string used by fopen(3) in a form which can\n * be passed to semihosting_open(). These do NOT correspond directly to %O_RDONLY,\n * %O_CREAT, etc; see fopen(3) for details. In particular, @MODE_PLUS\n * effectively results in adding %O_RDWR, and @MODE_WRITE will add %O_TRUNC.\n * For compatibility, @MODE_BINARY should be added when opening non-text files\n * (such as images).\n */\nenum semihosting_open_mode {\n\tMODE_READ\t= 0x0,\n\tMODE_BINARY\t= 0x1,\n\tMODE_PLUS\t= 0x2,\n\tMODE_WRITE\t= 0x4,\n\tMODE_APPEND\t= 0x8,\n};\n\n#ifdef CONFIG_SERIAL_SEMIHOSTING\nint semihosting_init(void);\nint semihosting_enabled(void);\n#else\nstatic inline int semihosting_init(void) { return SBI_ENODEV; }\nstatic inline int semihosting_enabled(void) { return 0; }\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/shakti-uart.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Vijai Kumar K <vijai@behindbytes.com>\n */\n\n#ifndef __SERIAL_SHAKTI_UART_H__\n#define __SERIAL_SHAKTI_UART_H__\n\n#include <sbi/sbi_types.h>\n\nint shakti_uart_init(unsigned long base, u32 in_freq, u32 baudrate);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/sifive-uart.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SERIAL_SIFIVE_UART_H__\n#define __SERIAL_SIFIVE_UART_H__\n\n#include <sbi/sbi_types.h>\n\nint sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/uart8250.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SERIAL_UART8250_H__\n#define __SERIAL_UART8250_H__\n\n#include <sbi/sbi_types.h>\n\nint uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,\n\t\t  u32 reg_width, u32 reg_offset);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/serial/xlnx_uartlite.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Alistair Francis <alistair.francis@wdc.com>\n */\n#ifndef __SERIAL_XLNX_UARTLITE_H__\n#define __SERIAL_XLNX_UARTLITE_H__\n\n#include <sbi/sbi_types.h>\n\nint xlnx_uartlite_init(unsigned long base);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/sys/htif.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 2010-2020, The Regents of the University of California\n * (Regents).  All Rights Reserved.\n */\n\n#ifndef __SYS_HTIF_H__\n#define __SYS_HTIF_H__\n\n#include <sbi/sbi_types.h>\n\nint htif_serial_init(bool custom_addr,\n\t\t     unsigned long custom_fromhost_addr,\n\t\t     unsigned long custom_tohost_addr);\n\nint htif_system_reset_init(bool custom_addr,\n\t\t\t   unsigned long custom_fromhost_addr,\n\t\t\t   unsigned long custom_tohost_addr);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/sys/sifive_test.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __SYS_SIFIVE_TEST_H__\n#define __SYS_SIFIVE_TEST_H__\n\n#include <sbi/sbi_types.h>\n\nint sifive_test_init(unsigned long base);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/timer/aclint_mtimer.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __TIMER_ACLINT_MTIMER_H__\n#define __TIMER_ACLINT_MTIMER_H__\n\n#include <sbi/sbi_types.h>\n\n#define ACLINT_MTIMER_ALIGN\t\t0x8\n#define ACLINT_MTIMER_MAX_HARTS\t\t4095\n\n#define ACLINT_DEFAULT_MTIME_OFFSET\t0x7ff8\n#define ACLINT_DEFAULT_MTIME_SIZE\t0x8\n#define ACLINT_DEFAULT_MTIMECMP_OFFSET\t0x0000\n#define ACLINT_DEFAULT_MTIMECMP_SIZE\t0x7ff8\n\n#define CLINT_MTIMER_OFFSET\t\t0x4000\n\n#define MTIMER_REGION_ALIGN\t\t0x1000\n\nstruct aclint_mtimer_data {\n\t/* Public details */\n\tunsigned long mtime_freq;\n\tunsigned long mtime_addr;\n\tunsigned long mtime_size;\n\tunsigned long mtimecmp_addr;\n\tunsigned long mtimecmp_size;\n\tu32 first_hartid;\n\tu32 hart_count;\n\tbool has_64bit_mmio;\n\tbool has_shared_mtime;\n\t/* Private details (initialized and used by ACLINT MTIMER library) */\n\tstruct aclint_mtimer_data *time_delta_reference;\n\tunsigned long time_delta_computed;\n\tu64 (*time_rd)(volatile u64 *addr);\n\tvoid (*time_wr)(bool timecmp, u64 value, volatile u64 *addr);\n};\n\nvoid aclint_mtimer_sync(struct aclint_mtimer_data *mt);\n\nvoid aclint_mtimer_set_reference(struct aclint_mtimer_data *mt,\n\t\t\t\t struct aclint_mtimer_data *ref);\n\nint aclint_mtimer_warm_init(void);\n\nint aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,\n\t\t\t    struct aclint_mtimer_data *reference);\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/timer/andes_plmt.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Andes Technology Corporation\n *\n * Authors:\n *   Zong Li <zong@andestech.com>\n *   Nylon Chen <nylon7@andestech.com>\n *   Yu Chien Peter Lin <peterlin@andestech.com>\n */\n\n#ifndef __TIMER_ANDES_PLMT_H__\n#define __TIMER_ANDES_PLMT_H__\n\n#define DEFAULT_AE350_PLMT_FREQ 60000000\n#define PLMT_REGION_ALIGN 0x1000\n\nstruct plmt_data {\n\tu32 hart_count;\n\tunsigned long size;\n\tunsigned long timer_freq;\n\tvolatile u64 *time_val;\n\tvolatile u64 *time_cmp;\n};\n\nint plmt_cold_timer_init(struct plmt_data *plmt);\nint plmt_warm_timer_init(void);\n\n#endif /* __TIMER_ANDES_PLMT_H__ */\n"
  },
  {
    "path": "ftpm-opensbi/include/sbi_utils/timer/fdt_timer.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __FDT_TIMER_H__\n#define __FDT_TIMER_H__\n\n#include <sbi/sbi_types.h>\n\n#ifdef CONFIG_FDT_TIMER\n\nstruct fdt_timer {\n\tconst struct fdt_match *match_table;\n\tint (*cold_init)(void *fdt, int nodeoff, const struct fdt_match *match);\n\tint (*warm_init)(void);\n\tvoid (*exit)(void);\n};\n\nvoid fdt_timer_exit(void);\n\nint fdt_timer_init(bool cold_boot);\n\n#else\n\nstatic inline void fdt_timer_exit(void) { }\nstatic inline int fdt_timer_init(bool cold_boot) { return 0; }\n\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"SBI Extension Support\"\n\nconfig SBI_ECALL_TIME\n\tbool \"Timer extension\"\n\tdefault y\n\nconfig SBI_ECALL_RFENCE\n\tbool \"RFENCE extension\"\n\tdefault y\n\nconfig SBI_ECALL_IPI\n\tbool \"IPI extension\"\n\tdefault y\n\nconfig SBI_ECALL_HSM\n\tbool \"Hart State Management extension\"\n\tdefault y\n\nconfig SBI_ECALL_SRST\n\tbool \"System Reset extension\"\n\tdefault y\n\nconfig SBI_ECALL_PMU\n\tbool \"Performance Monitoring Unit extension\"\n\tdefault y\n\nconfig SBI_ECALL_LEGACY\n\tbool \"SBI v0.1 legacy extensions\"\n\tdefault y\n\nconfig SBI_ECALL_VENDOR\n\tbool \"Platform-defined vendor extensions\"\n\tdefault y\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nlibsbi-objs-y += riscv_asm.o\nlibsbi-objs-y += riscv_atomic.o\nlibsbi-objs-y += riscv_hardfp.o\nlibsbi-objs-y += riscv_locks.o\n\nlibsbi-objs-y += sbi_ecall.o\nlibsbi-objs-y += sbi_ecall_exts.o\n\n# The order of below extensions is performance optimized\ncarray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_TIME) += ecall_time\nlibsbi-objs-$(CONFIG_SBI_ECALL_TIME) += sbi_ecall_time.o\n\ncarray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_RFENCE) += ecall_rfence\nlibsbi-objs-$(CONFIG_SBI_ECALL_RFENCE) += sbi_ecall_rfence.o\n\ncarray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_IPI) += ecall_ipi\nlibsbi-objs-$(CONFIG_SBI_ECALL_IPI) += sbi_ecall_ipi.o\n\ncarray-sbi_ecall_exts-y += ecall_base\nlibsbi-objs-y += sbi_ecall_base.o\n\ncarray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_HSM) += ecall_hsm\nlibsbi-objs-$(CONFIG_SBI_ECALL_HSM) += sbi_ecall_hsm.o\n\ncarray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_SRST) += ecall_srst\nlibsbi-objs-$(CONFIG_SBI_ECALL_SRST) += sbi_ecall_srst.o\n\ncarray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_PMU) += ecall_pmu\nlibsbi-objs-$(CONFIG_SBI_ECALL_PMU) += sbi_ecall_pmu.o\n\ncarray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_LEGACY) += ecall_legacy\nlibsbi-objs-$(CONFIG_SBI_ECALL_LEGACY) += sbi_ecall_legacy.o\n\ncarray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_VENDOR) += ecall_vendor\nlibsbi-objs-$(CONFIG_SBI_ECALL_VENDOR) += sbi_ecall_vendor.o\n\nlibsbi-objs-y += sbi_bitmap.o\nlibsbi-objs-y += sbi_bitops.o\nlibsbi-objs-y += sbi_console.o\nlibsbi-objs-y += sbi_domain.o\nlibsbi-objs-y += sbi_emulate_csr.o\nlibsbi-objs-y += sbi_fifo.o\nlibsbi-objs-y += sbi_hart.o\nlibsbi-objs-y += sbi_math.o\nlibsbi-objs-y += sbi_hfence.o\nlibsbi-objs-y += sbi_hsm.o\nlibsbi-objs-y += sbi_illegal_insn.o\nlibsbi-objs-y += sbi_init.o\nlibsbi-objs-y += sbi_ipi.o\nlibsbi-objs-y += sbi_irqchip.o\nlibsbi-objs-y += sbi_misaligned_ldst.o\nlibsbi-objs-y += sbi_platform.o\nlibsbi-objs-y += sbi_pmu.o\nlibsbi-objs-y += sbi_scratch.o\nlibsbi-objs-y += sbi_string.o\nlibsbi-objs-y += sbi_system.o\nlibsbi-objs-y += sbi_timer.o\nlibsbi-objs-y += sbi_tlb.o\nlibsbi-objs-y += sbi_trap.o\nlibsbi-objs-y += sbi_unpriv.o\nlibsbi-objs-y += sbi_expected_trap.o\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/riscv_asm.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_console.h>\n\n/* determine CPU extension, return non-zero support */\nint misa_extension_imp(char ext)\n{\n\tunsigned long misa = csr_read(CSR_MISA);\n\n\tif (misa) {\n\t\tif ('A' <= ext && ext <= 'Z')\n\t\t\treturn misa & (1 << (ext - 'A'));\n\t\tif ('a' <= ext && ext <= 'z')\n\t\t\treturn misa & (1 << (ext - 'a'));\n\t\treturn 0;\n\t}\n\n\treturn sbi_platform_misa_extension(sbi_platform_thishart_ptr(), ext);\n}\n\nint misa_xlen(void)\n{\n\tlong r;\n\n\tif (csr_read(CSR_MISA) == 0)\n\t\treturn sbi_platform_misa_xlen(sbi_platform_thishart_ptr());\n\n\t__asm__ __volatile__(\n\t\t\"csrr   t0, misa\\n\\t\"\n\t\t\"slti   t1, t0, 0\\n\\t\"\n\t\t\"slli   t1, t1, 1\\n\\t\"\n\t\t\"slli   t0, t0, 1\\n\\t\"\n\t\t\"slti   t0, t0, 0\\n\\t\"\n\t\t\"add    %0, t0, t1\"\n\t\t: \"=r\"(r)\n\t\t:\n\t\t: \"t0\", \"t1\");\n\n\treturn r ? r : -1;\n}\n\nvoid misa_string(int xlen, char *out, unsigned int out_sz)\n{\n\tunsigned int i, pos = 0;\n\tconst char valid_isa_order[] = \"iemafdqclbjtpvnhkorwxyzg\";\n\n\tif (!out)\n\t\treturn;\n\n\tif (5 <= (out_sz - pos)) {\n\t\tout[pos++] = 'r';\n\t\tout[pos++] = 'v';\n\t\tswitch (xlen) {\n\t\tcase 1:\n\t\t\tout[pos++] = '3';\n\t\t\tout[pos++] = '2';\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tout[pos++] = '6';\n\t\t\tout[pos++] = '4';\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tout[pos++] = '1';\n\t\t\tout[pos++] = '2';\n\t\t\tout[pos++] = '8';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tsbi_panic(\"%s: Unknown misa.MXL encoding %d\",\n\t\t\t\t   __func__, xlen);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tfor (i = 0; i < array_size(valid_isa_order) && (pos < out_sz); i++) {\n\t\tif (misa_extension_imp(valid_isa_order[i]))\n\t\t\tout[pos++] = valid_isa_order[i];\n\t}\n\n\tif (pos < out_sz)\n\t\tout[pos++] = '\\0';\n}\n\nunsigned long csr_read_num(int csr_num)\n{\n#define switchcase_csr_read(__csr_num, __val)\t\t\\\n\tcase __csr_num:\t\t\t\t\t\\\n\t\t__val = csr_read(__csr_num);\t\t\\\n\t\tbreak;\n#define switchcase_csr_read_2(__csr_num, __val)\t\\\n\tswitchcase_csr_read(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_read(__csr_num + 1, __val)\n#define switchcase_csr_read_4(__csr_num, __val)\t\\\n\tswitchcase_csr_read_2(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_read_2(__csr_num + 2, __val)\n#define switchcase_csr_read_8(__csr_num, __val)\t\\\n\tswitchcase_csr_read_4(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_read_4(__csr_num + 4, __val)\n#define switchcase_csr_read_16(__csr_num, __val)\t\\\n\tswitchcase_csr_read_8(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_read_8(__csr_num + 8, __val)\n#define switchcase_csr_read_32(__csr_num, __val)\t\\\n\tswitchcase_csr_read_16(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_read_16(__csr_num + 16, __val)\n#define switchcase_csr_read_64(__csr_num, __val)\t\\\n\tswitchcase_csr_read_32(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_read_32(__csr_num + 32, __val)\n\n\tunsigned long ret = 0;\n\n\tswitch (csr_num) {\n\tswitchcase_csr_read_16(CSR_PMPCFG0, ret)\n\tswitchcase_csr_read_64(CSR_PMPADDR0, ret)\n\tswitchcase_csr_read(CSR_MCYCLE, ret)\n\tswitchcase_csr_read(CSR_MINSTRET, ret)\n\tswitchcase_csr_read(CSR_MHPMCOUNTER3, ret)\n\tswitchcase_csr_read_4(CSR_MHPMCOUNTER4, ret)\n\tswitchcase_csr_read_8(CSR_MHPMCOUNTER8, ret)\n\tswitchcase_csr_read_16(CSR_MHPMCOUNTER16, ret)\n\tswitchcase_csr_read(CSR_MCOUNTINHIBIT, ret)\n\tswitchcase_csr_read(CSR_MHPMEVENT3, ret)\n\tswitchcase_csr_read_4(CSR_MHPMEVENT4, ret)\n\tswitchcase_csr_read_8(CSR_MHPMEVENT8, ret)\n\tswitchcase_csr_read_16(CSR_MHPMEVENT16, ret)\n#if __riscv_xlen == 32\n\tswitchcase_csr_read(CSR_MCYCLEH, ret)\n\tswitchcase_csr_read(CSR_MINSTRETH, ret)\n\tswitchcase_csr_read(CSR_MHPMCOUNTER3H, ret)\n\tswitchcase_csr_read_4(CSR_MHPMCOUNTER4H, ret)\n\tswitchcase_csr_read_8(CSR_MHPMCOUNTER8H, ret)\n\tswitchcase_csr_read_16(CSR_MHPMCOUNTER16H, ret)\n\t/**\n\t * The CSR range MHPMEVENT[3-16]H are available only if sscofpmf\n\t * extension is present. The caller must ensure that.\n\t */\n\tswitchcase_csr_read(CSR_MHPMEVENT3H, ret)\n\tswitchcase_csr_read_4(CSR_MHPMEVENT4H, ret)\n\tswitchcase_csr_read_8(CSR_MHPMEVENT8H, ret)\n\tswitchcase_csr_read_16(CSR_MHPMEVENT16H, ret)\n#endif\n\n\tdefault:\n\t\tsbi_panic(\"%s: Unknown CSR %#x\", __func__, csr_num);\n\t\tbreak;\n\t};\n\n\treturn ret;\n\n#undef switchcase_csr_read_64\n#undef switchcase_csr_read_32\n#undef switchcase_csr_read_16\n#undef switchcase_csr_read_8\n#undef switchcase_csr_read_4\n#undef switchcase_csr_read_2\n#undef switchcase_csr_read\n}\n\nvoid csr_write_num(int csr_num, unsigned long val)\n{\n#define switchcase_csr_write(__csr_num, __val)\t\t\\\n\tcase __csr_num:\t\t\t\t\t\\\n\t\tcsr_write(__csr_num, __val);\t\t\\\n\t\tbreak;\n#define switchcase_csr_write_2(__csr_num, __val)\t\\\n\tswitchcase_csr_write(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_write(__csr_num + 1, __val)\n#define switchcase_csr_write_4(__csr_num, __val)\t\\\n\tswitchcase_csr_write_2(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_write_2(__csr_num + 2, __val)\n#define switchcase_csr_write_8(__csr_num, __val)\t\\\n\tswitchcase_csr_write_4(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_write_4(__csr_num + 4, __val)\n#define switchcase_csr_write_16(__csr_num, __val)\t\\\n\tswitchcase_csr_write_8(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_write_8(__csr_num + 8, __val)\n#define switchcase_csr_write_32(__csr_num, __val)\t\\\n\tswitchcase_csr_write_16(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_write_16(__csr_num + 16, __val)\n#define switchcase_csr_write_64(__csr_num, __val)\t\\\n\tswitchcase_csr_write_32(__csr_num + 0, __val)\t\\\n\tswitchcase_csr_write_32(__csr_num + 32, __val)\n\n\tswitch (csr_num) {\n\tswitchcase_csr_write_16(CSR_PMPCFG0, val)\n\tswitchcase_csr_write_64(CSR_PMPADDR0, val)\n\tswitchcase_csr_write(CSR_MCYCLE, val)\n\tswitchcase_csr_write(CSR_MINSTRET, val)\n\tswitchcase_csr_write(CSR_MHPMCOUNTER3, val)\n\tswitchcase_csr_write_4(CSR_MHPMCOUNTER4, val)\n\tswitchcase_csr_write_8(CSR_MHPMCOUNTER8, val)\n\tswitchcase_csr_write_16(CSR_MHPMCOUNTER16, val)\n#if __riscv_xlen == 32\n\tswitchcase_csr_write(CSR_MCYCLEH, val)\n\tswitchcase_csr_write(CSR_MINSTRETH, val)\n\tswitchcase_csr_write(CSR_MHPMCOUNTER3H, val)\n\tswitchcase_csr_write_4(CSR_MHPMCOUNTER4H, val)\n\tswitchcase_csr_write_8(CSR_MHPMCOUNTER8H, val)\n\tswitchcase_csr_write_16(CSR_MHPMCOUNTER16H, val)\n\tswitchcase_csr_write(CSR_MHPMEVENT3H, val)\n\tswitchcase_csr_write_4(CSR_MHPMEVENT4H, val)\n\tswitchcase_csr_write_8(CSR_MHPMEVENT8H, val)\n\tswitchcase_csr_write_16(CSR_MHPMEVENT16H, val)\n#endif\n\tswitchcase_csr_write(CSR_MCOUNTINHIBIT, val)\n\tswitchcase_csr_write(CSR_MHPMEVENT3, val)\n\tswitchcase_csr_write_4(CSR_MHPMEVENT4, val)\n\tswitchcase_csr_write_8(CSR_MHPMEVENT8, val)\n\tswitchcase_csr_write_16(CSR_MHPMEVENT16, val)\n\n\tdefault:\n\t\tsbi_panic(\"%s: Unknown CSR %#x\", __func__, csr_num);\n\t\tbreak;\n\t};\n\n#undef switchcase_csr_write_64\n#undef switchcase_csr_write_32\n#undef switchcase_csr_write_16\n#undef switchcase_csr_write_8\n#undef switchcase_csr_write_4\n#undef switchcase_csr_write_2\n#undef switchcase_csr_write\n}\n\nstatic unsigned long ctz(unsigned long x)\n{\n\tunsigned long ret = 0;\n\n\tif (x == 0)\n\t\treturn 8 * sizeof(x);\n\n\twhile (!(x & 1UL)) {\n\t\tret++;\n\t\tx = x >> 1;\n\t}\n\n\treturn ret;\n}\n\nint pmp_set(unsigned int n, unsigned long prot, unsigned long addr,\n\t    unsigned long log2len)\n{\n\tint pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;\n\tunsigned long cfgmask, pmpcfg;\n\tunsigned long addrmask, pmpaddr;\n\n\t/* check parameters */\n\tif (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)\n\t\treturn SBI_EINVAL;\n\n\t/* calculate PMP register and offset */\n#if __riscv_xlen == 32\n\tpmpcfg_csr   = CSR_PMPCFG0 + (n >> 2);\n\tpmpcfg_shift = (n & 3) << 3;\n#elif __riscv_xlen == 64\n\tpmpcfg_csr   = (CSR_PMPCFG0 + (n >> 2)) & ~1;\n\tpmpcfg_shift = (n & 7) << 3;\n#else\n# error \"Unexpected __riscv_xlen\"\n#endif\n\tpmpaddr_csr = CSR_PMPADDR0 + n;\n\n\t/* encode PMP config */\n\tprot &= ~PMP_A;\n\tprot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;\n\tcfgmask = ~(0xffUL << pmpcfg_shift);\n\tpmpcfg\t= (csr_read_num(pmpcfg_csr) & cfgmask);\n\tpmpcfg |= ((prot << pmpcfg_shift) & ~cfgmask);\n\n\t/* encode PMP address */\n\tif (log2len == PMP_SHIFT) {\n\t\tpmpaddr = (addr >> PMP_SHIFT);\n\t} else {\n\t\tif (log2len == __riscv_xlen) {\n\t\t\tpmpaddr = -1UL;\n\t\t} else {\n\t\t\taddrmask = (1UL << (log2len - PMP_SHIFT)) - 1;\n\t\t\tpmpaddr\t = ((addr >> PMP_SHIFT) & ~addrmask);\n\t\t\tpmpaddr |= (addrmask >> 1);\n\t\t}\n\t}\n\n\t/* write csrs */\n\tcsr_write_num(pmpaddr_csr, pmpaddr);\n\tcsr_write_num(pmpcfg_csr, pmpcfg);\n\n\treturn 0;\n}\n\nint pmp_get(unsigned int n, unsigned long *prot_out, unsigned long *addr_out,\n\t    unsigned long *log2len)\n{\n\tint pmpcfg_csr, pmpcfg_shift, pmpaddr_csr;\n\tunsigned long cfgmask, pmpcfg, prot;\n\tunsigned long t1, addr, len;\n\n\t/* check parameters */\n\tif (n >= PMP_COUNT || !prot_out || !addr_out || !log2len)\n\t\treturn SBI_EINVAL;\n\t*prot_out = *addr_out = *log2len = 0;\n\n\t/* calculate PMP register and offset */\n#if __riscv_xlen == 32\n\tpmpcfg_csr   = CSR_PMPCFG0 + (n >> 2);\n\tpmpcfg_shift = (n & 3) << 3;\n#elif __riscv_xlen == 64\n\tpmpcfg_csr   = (CSR_PMPCFG0 + (n >> 2)) & ~1;\n\tpmpcfg_shift = (n & 7) << 3;\n#else\n# error \"Unexpected __riscv_xlen\"\n#endif\n\tpmpaddr_csr = CSR_PMPADDR0 + n;\n\n\t/* decode PMP config */\n\tcfgmask = (0xffUL << pmpcfg_shift);\n\tpmpcfg\t= csr_read_num(pmpcfg_csr) & cfgmask;\n\tprot\t= pmpcfg >> pmpcfg_shift;\n\n\t/* decode PMP address */\n\tif ((prot & PMP_A) == PMP_A_NAPOT) {\n\t\taddr = csr_read_num(pmpaddr_csr);\n\t\tif (addr == -1UL) {\n\t\t\taddr\t= 0;\n\t\t\tlen\t= __riscv_xlen;\n\t\t} else {\n\t\t\tt1\t= ctz(~addr);\n\t\t\taddr\t= (addr & ~((1UL << t1) - 1)) << PMP_SHIFT;\n\t\t\tlen\t= (t1 + PMP_SHIFT + 1);\n\t\t}\n\t} else {\n\t\taddr\t= csr_read_num(pmpaddr_csr) << PMP_SHIFT;\n\t\tlen\t= PMP_SHIFT;\n\t}\n\n\t/* return details */\n\t*prot_out    = prot;\n\t*addr_out    = addr;\n\t*log2len     = len;\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/riscv_atomic.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_bitops.h>\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_atomic.h>\n#include <sbi/riscv_barrier.h>\n\nlong atomic_read(atomic_t *atom)\n{\n\tlong ret = atom->counter;\n\trmb();\n\treturn ret;\n}\n\nvoid atomic_write(atomic_t *atom, long value)\n{\n\tatom->counter = value;\n\twmb();\n}\n\nlong atomic_add_return(atomic_t *atom, long value)\n{\n\tlong ret;\n#if __SIZEOF_LONG__ == 4\n\t__asm__ __volatile__(\"\tamoadd.w.aqrl  %1, %2, %0\"\n\t\t\t     : \"+A\"(atom->counter), \"=r\"(ret)\n\t\t\t     : \"r\"(value)\n\t\t\t     : \"memory\");\n#elif __SIZEOF_LONG__ == 8\n\t__asm__ __volatile__(\"\tamoadd.d.aqrl  %1, %2, %0\"\n\t\t\t     : \"+A\"(atom->counter), \"=r\"(ret)\n\t\t\t     : \"r\"(value)\n\t\t\t     : \"memory\");\n#endif\n\treturn ret + value;\n}\n\nlong atomic_sub_return(atomic_t *atom, long value)\n{\n\treturn atomic_add_return(atom, -value);\n}\n\n#define __axchg(ptr, new, size)\t\t\t\t\t\t\t\\\n\t({\t\t\t\t\t\t\t\t\t\\\n\t\t__typeof__(ptr) __ptr = (ptr);\t\t\t\t\t\\\n\t\t__typeof__(new) __new = (new);\t\t\t\t\t\\\n\t\t__typeof__(*(ptr)) __ret;\t\t\t\t\t\\\n\t\tswitch (size) {\t\t\t\t\t\t\t\\\n\t\tcase 4:\t\t\t\t\t\t\t\t\\\n\t\t\t__asm__ __volatile__ (\t\t\t\t\t\\\n\t\t\t\t\"\tamoswap.w.aqrl %0, %2, %1\\n\"\t\t\\\n\t\t\t\t: \"=r\" (__ret), \"+A\" (*__ptr)\t\t\t\\\n\t\t\t\t: \"r\" (__new)\t\t\t\t\t\\\n\t\t\t\t: \"memory\");\t\t\t\t\t\\\n\t\t\tbreak;\t\t\t\t\t\t\t\\\n\t\tcase 8:\t\t\t\t\t\t\t\t\\\n\t\t\t__asm__ __volatile__ (\t\t\t\t\t\\\n\t\t\t\t\"\tamoswap.d.aqrl %0, %2, %1\\n\"\t\t\\\n\t\t\t\t: \"=r\" (__ret), \"+A\" (*__ptr)\t\t\t\\\n\t\t\t\t: \"r\" (__new)\t\t\t\t\t\\\n\t\t\t\t: \"memory\");\t\t\t\t\t\\\n\t\t\tbreak;\t\t\t\t\t\t\t\\\n\t\tdefault:\t\t\t\t\t\t\t\\\n\t\t\tbreak;\t\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\t\\\n\t\t__ret;\t\t\t\t\t\t\t\t\\\n\t})\n\n#define axchg(ptr, x)\t\t\t\t\t\t\t\t\\\n\t({\t\t\t\t\t\t\t\t\t\\\n\t\t__typeof__(*(ptr)) _x_ = (x);\t\t\t\t\t\\\n\t\t(__typeof__(*(ptr))) __axchg((ptr), _x_, sizeof(*(ptr)));\t\\\n\t})\n\n\n#define __xchg(ptr, new, size)                                            \\\n\t({                                                                \\\n\t\t__typeof__(ptr) __ptr\t = (ptr);                         \\\n\t\t__typeof__(*(ptr)) __new = (new);                         \\\n\t\t__typeof__(*(ptr)) __ret;                                 \\\n\t\tregister unsigned int __rc;                               \\\n\t\tswitch (size) {                                           \\\n\t\tcase 4:                                                   \\\n\t\t\t__asm__ __volatile__(\"0:\tlr.w %0, %2\\n\"    \\\n\t\t\t\t\t     \"\tsc.w.rl %1, %z3, %2\\n\"    \\\n\t\t\t\t\t     \"\tbnez %1, 0b\\n\"            \\\n\t\t\t\t\t     \"\tfence rw, rw\\n\"           \\\n\t\t\t\t\t     : \"=&r\"(__ret), \"=&r\"(__rc), \\\n\t\t\t\t\t       \"+A\"(*__ptr)               \\\n\t\t\t\t\t     : \"rJ\"(__new)                \\\n\t\t\t\t\t     : \"memory\");                 \\\n\t\t\tbreak;                                            \\\n\t\tcase 8:                                                   \\\n\t\t\t__asm__ __volatile__(\"0:\tlr.d %0, %2\\n\"    \\\n\t\t\t\t\t     \"\tsc.d.rl %1, %z3, %2\\n\"    \\\n\t\t\t\t\t     \"\tbnez %1, 0b\\n\"            \\\n\t\t\t\t\t     \"\tfence rw, rw\\n\"           \\\n\t\t\t\t\t     : \"=&r\"(__ret), \"=&r\"(__rc), \\\n\t\t\t\t\t       \"+A\"(*__ptr)               \\\n\t\t\t\t\t     : \"rJ\"(__new)                \\\n\t\t\t\t\t     : \"memory\");                 \\\n\t\t\tbreak;                                            \\\n\t\tdefault:                                                  \\\n\t\t\tbreak;                                            \\\n\t\t}                                                         \\\n\t\t__ret;                                                    \\\n\t})\n\n#define xchg(ptr, n)                                                     \\\n\t({                                                               \\\n\t\t__typeof__(*(ptr)) _n_ = (n);                            \\\n\t\t(__typeof__(*(ptr))) __xchg((ptr), _n_, sizeof(*(ptr))); \\\n\t})\n\n#define __cmpxchg(ptr, old, new, size)                                    \\\n\t({                                                                \\\n\t\t__typeof__(ptr) __ptr\t = (ptr);                         \\\n\t\t__typeof__(*(ptr)) __old = (old);                         \\\n\t\t__typeof__(*(ptr)) __new = (new);                         \\\n\t\t__typeof__(*(ptr)) __ret;                                 \\\n\t\tregister unsigned int __rc;                               \\\n\t\tswitch (size) {                                           \\\n\t\tcase 4:                                                   \\\n\t\t\t__asm__ __volatile__(\"0:\tlr.w %0, %2\\n\"    \\\n\t\t\t\t\t     \"\tbne  %0, %z3, 1f\\n\"       \\\n\t\t\t\t\t     \"\tsc.w.rl %1, %z4, %2\\n\"    \\\n\t\t\t\t\t     \"\tbnez %1, 0b\\n\"            \\\n\t\t\t\t\t     \"\tfence rw, rw\\n\"           \\\n\t\t\t\t\t     \"1:\\n\"                       \\\n\t\t\t\t\t     : \"=&r\"(__ret), \"=&r\"(__rc), \\\n\t\t\t\t\t       \"+A\"(*__ptr)               \\\n\t\t\t\t\t     : \"rJ\"(__old), \"rJ\"(__new)   \\\n\t\t\t\t\t     : \"memory\");                 \\\n\t\t\tbreak;                                            \\\n\t\tcase 8:                                                   \\\n\t\t\t__asm__ __volatile__(\"0:\tlr.d %0, %2\\n\"    \\\n\t\t\t\t\t     \"\tbne %0, %z3, 1f\\n\"        \\\n\t\t\t\t\t     \"\tsc.d.rl %1, %z4, %2\\n\"    \\\n\t\t\t\t\t     \"\tbnez %1, 0b\\n\"            \\\n\t\t\t\t\t     \"\tfence rw, rw\\n\"           \\\n\t\t\t\t\t     \"1:\\n\"                       \\\n\t\t\t\t\t     : \"=&r\"(__ret), \"=&r\"(__rc), \\\n\t\t\t\t\t       \"+A\"(*__ptr)               \\\n\t\t\t\t\t     : \"rJ\"(__old), \"rJ\"(__new)   \\\n\t\t\t\t\t     : \"memory\");                 \\\n\t\t\tbreak;                                            \\\n\t\tdefault:                                                  \\\n\t\t\tbreak;                                            \\\n\t\t}                                                         \\\n\t\t__ret;                                                    \\\n\t})\n\n#define cmpxchg(ptr, o, n)                                          \\\n\t({                                                          \\\n\t\t__typeof__(*(ptr)) _o_ = (o);                       \\\n\t\t__typeof__(*(ptr)) _n_ = (n);                       \\\n\t\t(__typeof__(*(ptr)))                                \\\n\t\t\t__cmpxchg((ptr), _o_, _n_, sizeof(*(ptr))); \\\n\t})\n\nlong atomic_cmpxchg(atomic_t *atom, long oldval, long newval)\n{\n#ifdef __riscv_atomic\n\treturn __sync_val_compare_and_swap(&atom->counter, oldval, newval);\n#else\n\treturn cmpxchg(&atom->counter, oldval, newval);\n#endif\n}\n\nlong atomic_xchg(atomic_t *atom, long newval)\n{\n\t/* Atomically set new value and return old value. */\n#ifdef __riscv_atomic\n\treturn axchg(&atom->counter, newval);\n#else\n\treturn xchg(&atom->counter, newval);\n#endif\n}\n\nunsigned int atomic_raw_xchg_uint(volatile unsigned int *ptr,\n\t\t\t\t  unsigned int newval)\n{\n\t/* Atomically set new value and return old value. */\n#ifdef __riscv_atomic\n\treturn axchg(ptr, newval);\n#else\n\treturn xchg(ptr, newval);\n#endif\n}\n\nunsigned long atomic_raw_xchg_ulong(volatile unsigned long *ptr,\n\t\t\t\t    unsigned long newval)\n{\n\t/* Atomically set new value and return old value. */\n#ifdef __riscv_atomic\n\treturn axchg(ptr, newval);\n#else\n\treturn xchg(ptr, newval);\n#endif\n}\n\n#if (__SIZEOF_POINTER__ == 8)\n#define __AMO(op) \"amo\" #op \".d\"\n#elif (__SIZEOF_POINTER__ == 4)\n#define __AMO(op) \"amo\" #op \".w\"\n#else\n#error \"Unexpected __SIZEOF_POINTER__\"\n#endif\n\n#define __atomic_op_bit_ord(op, mod, nr, addr, ord)                          \\\n\t({                                                                   \\\n\t\tunsigned long __res, __mask;                                 \\\n\t\t__mask = BIT_MASK(nr);                                       \\\n\t\t__asm__ __volatile__(__AMO(op) #ord \" %0, %2, %1\"            \\\n\t\t\t\t     : \"=r\"(__res), \"+A\"(addr[BIT_WORD(nr)]) \\\n\t\t\t\t     : \"r\"(mod(__mask))                      \\\n\t\t\t\t     : \"memory\");                            \\\n\t\t__res;                                                       \\\n\t})\n\n#define __atomic_op_bit(op, mod, nr, addr) \\\n\t__atomic_op_bit_ord(op, mod, nr, addr, .aqrl)\n\n/* Bitmask modifiers */\n#define __NOP(x) (x)\n#define __NOT(x) (~(x))\n\ninline int atomic_raw_set_bit(int nr, volatile unsigned long *addr)\n{\n\treturn __atomic_op_bit(or, __NOP, nr, addr);\n}\n\ninline int atomic_raw_clear_bit(int nr, volatile unsigned long *addr)\n{\n\treturn __atomic_op_bit(and, __NOT, nr, addr);\n}\n\ninline int atomic_set_bit(int nr, atomic_t *atom)\n{\n\treturn atomic_raw_set_bit(nr, (unsigned long *)&atom->counter);\n}\n\ninline int atomic_clear_bit(int nr, atomic_t *atom)\n{\n\treturn atomic_raw_clear_bit(nr, (unsigned long *)&atom->counter);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/riscv_hardfp.S",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifdef __riscv_flen\n\n#if __riscv_flen != 64\n# error single-float only is not supported\n#endif\n\n#define get_f32(which) fmv.x.s a0, which; jr t0\n#define put_f32(which) fmv.s.x which, a0; jr t0\n#if __riscv_xlen == 64\n# define get_f64(which) fmv.x.d a0, which; jr t0\n# define put_f64(which) fmv.d.x which, a0; jr t0\n#else\n# define get_f64(which) fsd which, 0(a0); jr t0\n# define put_f64(which) fld which, 0(a0); jr t0\n#endif\n\n\t.text\n\t.option norvc\n\t.globl get_f32_reg\n\tget_f32_reg:\n\t\tget_f32(f0)\n\t\tget_f32(f1)\n\t\tget_f32(f2)\n\t\tget_f32(f3)\n\t\tget_f32(f4)\n\t\tget_f32(f5)\n\t\tget_f32(f6)\n\t\tget_f32(f7)\n\t\tget_f32(f8)\n\t\tget_f32(f9)\n\t\tget_f32(f10)\n\t\tget_f32(f11)\n\t\tget_f32(f12)\n\t\tget_f32(f13)\n\t\tget_f32(f14)\n\t\tget_f32(f15)\n\t\tget_f32(f16)\n\t\tget_f32(f17)\n\t\tget_f32(f18)\n\t\tget_f32(f19)\n\t\tget_f32(f20)\n\t\tget_f32(f21)\n\t\tget_f32(f22)\n\t\tget_f32(f23)\n\t\tget_f32(f24)\n\t\tget_f32(f25)\n\t\tget_f32(f26)\n\t\tget_f32(f27)\n\t\tget_f32(f28)\n\t\tget_f32(f29)\n\t\tget_f32(f30)\n\t\tget_f32(f31)\n\n\t.text\n\t.globl put_f32_reg\n\tput_f32_reg:\n\t\tput_f32(f0)\n\t\tput_f32(f1)\n\t\tput_f32(f2)\n\t\tput_f32(f3)\n\t\tput_f32(f4)\n\t\tput_f32(f5)\n\t\tput_f32(f6)\n\t\tput_f32(f7)\n\t\tput_f32(f8)\n\t\tput_f32(f9)\n\t\tput_f32(f10)\n\t\tput_f32(f11)\n\t\tput_f32(f12)\n\t\tput_f32(f13)\n\t\tput_f32(f14)\n\t\tput_f32(f15)\n\t\tput_f32(f16)\n\t\tput_f32(f17)\n\t\tput_f32(f18)\n\t\tput_f32(f19)\n\t\tput_f32(f20)\n\t\tput_f32(f21)\n\t\tput_f32(f22)\n\t\tput_f32(f23)\n\t\tput_f32(f24)\n\t\tput_f32(f25)\n\t\tput_f32(f26)\n\t\tput_f32(f27)\n\t\tput_f32(f28)\n\t\tput_f32(f29)\n\t\tput_f32(f30)\n\t\tput_f32(f31)\n\n\t.text\n\t.globl get_f64_reg\n\tget_f64_reg:\n\t\tget_f64(f0)\n\t\tget_f64(f1)\n\t\tget_f64(f2)\n\t\tget_f64(f3)\n\t\tget_f64(f4)\n\t\tget_f64(f5)\n\t\tget_f64(f6)\n\t\tget_f64(f7)\n\t\tget_f64(f8)\n\t\tget_f64(f9)\n\t\tget_f64(f10)\n\t\tget_f64(f11)\n\t\tget_f64(f12)\n\t\tget_f64(f13)\n\t\tget_f64(f14)\n\t\tget_f64(f15)\n\t\tget_f64(f16)\n\t\tget_f64(f17)\n\t\tget_f64(f18)\n\t\tget_f64(f19)\n\t\tget_f64(f20)\n\t\tget_f64(f21)\n\t\tget_f64(f22)\n\t\tget_f64(f23)\n\t\tget_f64(f24)\n\t\tget_f64(f25)\n\t\tget_f64(f26)\n\t\tget_f64(f27)\n\t\tget_f64(f28)\n\t\tget_f64(f29)\n\t\tget_f64(f30)\n\t\tget_f64(f31)\n\n\t.text\n\t.globl put_f64_reg\n\tput_f64_reg:\n\t\tput_f64(f0)\n\t\tput_f64(f1)\n\t\tput_f64(f2)\n\t\tput_f64(f3)\n\t\tput_f64(f4)\n\t\tput_f64(f5)\n\t\tput_f64(f6)\n\t\tput_f64(f7)\n\t\tput_f64(f8)\n\t\tput_f64(f9)\n\t\tput_f64(f10)\n\t\tput_f64(f11)\n\t\tput_f64(f12)\n\t\tput_f64(f13)\n\t\tput_f64(f14)\n\t\tput_f64(f15)\n\t\tput_f64(f16)\n\t\tput_f64(f17)\n\t\tput_f64(f18)\n\t\tput_f64(f19)\n\t\tput_f64(f20)\n\t\tput_f64(f21)\n\t\tput_f64(f22)\n\t\tput_f64(f23)\n\t\tput_f64(f24)\n\t\tput_f64(f25)\n\t\tput_f64(f26)\n\t\tput_f64(f27)\n\t\tput_f64(f28)\n\t\tput_f64(f29)\n\t\tput_f64(f30)\n\t\tput_f64(f31)\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/riscv_locks.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n * Copyright (c) 2021 Christoph Müllner <cmuellner@linux.com>\n */\n\n#include <sbi/riscv_barrier.h>\n#include <sbi/riscv_locks.h>\n\nstatic inline bool spin_lock_unlocked(spinlock_t lock)\n{\n\treturn lock.owner == lock.next;\n}\n\nbool spin_lock_check(spinlock_t *lock)\n{\n\tRISCV_FENCE(r, rw);\n\treturn !spin_lock_unlocked(*lock);\n}\n\nbool spin_trylock(spinlock_t *lock)\n{\n\tunsigned long inc = 1u << TICKET_SHIFT;\n\tunsigned long mask = 0xffffu << TICKET_SHIFT;\n\tu32 l0, tmp1, tmp2;\n\n\t__asm__ __volatile__(\n\t\t/* Get the current lock counters. */\n\t\t\"1:\tlr.w.aq\t%0, %3\\n\"\n\t\t\"\tslli\t%2, %0, %6\\n\"\n\t\t\"\tand\t%2, %2, %5\\n\"\n\t\t\"\tand\t%1, %0, %5\\n\"\n\t\t/* Is the lock free right now? */\n\t\t\"\tbne\t%1, %2, 2f\\n\"\n\t\t\"\tadd\t%0, %0, %4\\n\"\n\t\t/* Acquire the lock. */\n\t\t\"\tsc.w.rl\t%0, %0, %3\\n\"\n\t\t\"\tbnez\t%0, 1b\\n\"\n\t\t\"2:\"\n\t\t: \"=&r\"(l0), \"=&r\"(tmp1), \"=&r\"(tmp2), \"+A\"(*lock)\n\t\t: \"r\"(inc), \"r\"(mask), \"I\"(TICKET_SHIFT)\n\t\t: \"memory\");\n\n\treturn l0 == 0;\n}\n\nvoid spin_lock(spinlock_t *lock)\n{\n\tunsigned long inc = 1u << TICKET_SHIFT;\n\tunsigned long mask = 0xffffu;\n\tu32 l0, tmp1, tmp2;\n\n\t__asm__ __volatile__(\n\t\t/* Atomically increment the next ticket. */\n\t\t\"\tamoadd.w.aqrl\t%0, %4, %3\\n\"\n\n\t\t/* Did we get the lock? */\n\t\t\"\tsrli\t%1, %0, %6\\n\"\n\t\t\"\tand\t%1, %1, %5\\n\"\n\t\t\"1:\tand\t%2, %0, %5\\n\"\n\t\t\"\tbeq\t%1, %2, 2f\\n\"\n\n\t\t/* If not, then spin on the lock. */\n\t\t\"\tlw\t%0, %3\\n\"\n\t\tRISCV_ACQUIRE_BARRIER\n\t\t\"\tj\t1b\\n\"\n\t\t\"2:\"\n\t\t: \"=&r\"(l0), \"=&r\"(tmp1), \"=&r\"(tmp2), \"+A\"(*lock)\n\t\t: \"r\"(inc), \"r\"(mask), \"I\"(TICKET_SHIFT)\n\t\t: \"memory\");\n}\n\nvoid spin_unlock(spinlock_t *lock)\n{\n\t__smp_store_release(&lock->owner, lock->owner + 1);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_bitmap.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_bitmap.h>\n\nvoid __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,\n\t\t  const unsigned long *bitmap2, int bits)\n{\n\tint k;\n\tint nr = BITS_TO_LONGS(bits);\n\n\tfor (k = 0; k < nr; k++)\n\t\tdst[k] = bitmap1[k] & bitmap2[k];\n}\n\nvoid __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,\n\t\t const unsigned long *bitmap2, int bits)\n{\n\tint k;\n\tint nr = BITS_TO_LONGS(bits);\n\n\tfor (k = 0; k < nr; k++)\n\t\tdst[k] = bitmap1[k] | bitmap2[k];\n}\n\nvoid __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,\n\t\t  const unsigned long *bitmap2, int bits)\n{\n\tint k;\n\tint nr = BITS_TO_LONGS(bits);\n\n\tfor (k = 0; k < nr; k++)\n\t\tdst[k] = bitmap1[k] ^ bitmap2[k];\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_bitops.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_bitops.h>\n\n#define BITOP_WORD(nr)\t\t((nr) / BITS_PER_LONG)\n\n/**\n * find_first_bit - find the first set bit in a memory region\n * @addr: The address to start the search at\n * @size: The maximum size to search\n *\n * Returns the bit number of the first set bit.\n */\nunsigned long find_first_bit(const unsigned long *addr,\n\t\t\t     unsigned long size)\n{\n\tconst unsigned long *p = addr;\n\tunsigned long result = 0;\n\tunsigned long tmp;\n\n\twhile (size & ~(BITS_PER_LONG-1)) {\n\t\tif ((tmp = *(p++)))\n\t\t\tgoto found;\n\t\tresult += BITS_PER_LONG;\n\t\tsize -= BITS_PER_LONG;\n\t}\n\tif (!size)\n\t\treturn result;\n\n\ttmp = (*p) & (~0UL >> (BITS_PER_LONG - size));\n\tif (tmp == 0UL)\t\t/* Are any bits set? */\n\t\treturn result + size;\t/* Nope. */\nfound:\n\treturn result + sbi_ffs(tmp);\n}\n\n/**\n * find_first_zero_bit - find the first cleared bit in a memory region\n * @addr: The address to start the search at\n * @size: The maximum size to search\n *\n * Returns the bit number of the first cleared bit.\n */\nunsigned long find_first_zero_bit(const unsigned long *addr,\n\t\t\t\t  unsigned long size)\n{\n\tconst unsigned long *p = addr;\n\tunsigned long result = 0;\n\tunsigned long tmp;\n\n\twhile (size & ~(BITS_PER_LONG-1)) {\n\t\tif (~(tmp = *(p++)))\n\t\t\tgoto found;\n\t\tresult += BITS_PER_LONG;\n\t\tsize -= BITS_PER_LONG;\n\t}\n\tif (!size)\n\t\treturn result;\n\n\ttmp = (*p) | (~0UL << size);\n\tif (tmp == ~0UL)\t/* Are any bits zero? */\n\t\treturn result + size;\t/* Nope. */\nfound:\n\treturn result + sbi_ffz(tmp);\n}\n\n/**\n * find_last_bit - find the last set bit in a memory region\n * @addr: The address to start the search at\n * @size: The maximum size to search\n *\n * Returns the bit number of the first set bit, or size.\n */\nunsigned long find_last_bit(const unsigned long *addr,\n\t\t\t    unsigned long size)\n{\n\tunsigned long words;\n\tunsigned long tmp;\n\n\t/* Start at final word. */\n\twords = size / BITS_PER_LONG;\n\n\t/* Partial final word? */\n\tif (size & (BITS_PER_LONG-1)) {\n\t\ttmp = (addr[words] & (~0UL >> (BITS_PER_LONG\n\t\t\t\t\t - (size & (BITS_PER_LONG-1)))));\n\t\tif (tmp)\n\t\t\tgoto found;\n\t}\n\n\twhile (words) {\n\t\ttmp = addr[--words];\n\t\tif (tmp) {\nfound:\n\t\t\treturn words * BITS_PER_LONG + sbi_fls(tmp);\n\t\t}\n\t}\n\n\t/* Not found */\n\treturn size;\n}\n\n/**\n * find_next_bit - find the next set bit in a memory region\n * @addr: The address to base the search on\n * @offset: The bitnumber to start searching at\n * @size: The bitmap size in bits\n */\nunsigned long find_next_bit(const unsigned long *addr,\n\t\t\t    unsigned long size, unsigned long offset)\n{\n\tconst unsigned long *p = addr + BITOP_WORD(offset);\n\tunsigned long result = offset & ~(BITS_PER_LONG-1);\n\tunsigned long tmp;\n\n\tif (offset >= size)\n\t\treturn size;\n\tsize -= result;\n\toffset %= BITS_PER_LONG;\n\tif (offset) {\n\t\ttmp = *(p++);\n\t\ttmp &= (~0UL << offset);\n\t\tif (size < BITS_PER_LONG)\n\t\t\tgoto found_first;\n\t\tif (tmp)\n\t\t\tgoto found_middle;\n\t\tsize -= BITS_PER_LONG;\n\t\tresult += BITS_PER_LONG;\n\t}\n\twhile (size & ~(BITS_PER_LONG-1)) {\n\t\tif ((tmp = *(p++)))\n\t\t\tgoto found_middle;\n\t\tresult += BITS_PER_LONG;\n\t\tsize -= BITS_PER_LONG;\n\t}\n\tif (!size)\n\t\treturn result;\n\ttmp = *p;\n\nfound_first:\n\ttmp &= (~0UL >> (BITS_PER_LONG - size));\n\tif (tmp == 0UL)\t\t/* Are any bits set? */\n\t\treturn result + size;\t/* Nope. */\nfound_middle:\n\treturn result + sbi_ffs(tmp);\n}\n\n/**\n * find_next_zero_bit - find the next cleared bit in a memory region\n * @addr: The address to base the search on\n * @offset: The bitnumber to start searching at\n * @size: The bitmap size in bits\n */\nunsigned long find_next_zero_bit(const unsigned long *addr,\n\t\t\t\t unsigned long size,\n\t\t\t\t unsigned long offset)\n{\n\tconst unsigned long *p = addr + BITOP_WORD(offset);\n\tunsigned long result = offset & ~(BITS_PER_LONG-1);\n\tunsigned long tmp;\n\n\tif (offset >= size)\n\t\treturn size;\n\tsize -= result;\n\toffset %= BITS_PER_LONG;\n\tif (offset) {\n\t\ttmp = *(p++);\n\t\ttmp |= ~0UL >> (BITS_PER_LONG - offset);\n\t\tif (size < BITS_PER_LONG)\n\t\t\tgoto found_first;\n\t\tif (~tmp)\n\t\t\tgoto found_middle;\n\t\tsize -= BITS_PER_LONG;\n\t\tresult += BITS_PER_LONG;\n\t}\n\twhile (size & ~(BITS_PER_LONG-1)) {\n\t\tif (~(tmp = *(p++)))\n\t\t\tgoto found_middle;\n\t\tresult += BITS_PER_LONG;\n\t\tsize -= BITS_PER_LONG;\n\t}\n\tif (!size)\n\t\treturn result;\n\ttmp = *p;\n\nfound_first:\n\ttmp |= ~0UL << size;\n\tif (tmp == ~0UL)\t/* Are any bits zero? */\n\t\treturn result + size;\t/* Nope. */\nfound_middle:\n\treturn result + sbi_ffz(tmp);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_console.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_locks.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_scratch.h>\n\nstatic const struct sbi_console_device *console_dev = NULL;\nstatic spinlock_t console_out_lock\t       = SPIN_LOCK_INITIALIZER;\n\nbool sbi_isprintable(char c)\n{\n\tif (((31 < c) && (c < 127)) || (c == '\\f') || (c == '\\r') ||\n\t    (c == '\\n') || (c == '\\t')) {\n\t\treturn TRUE;\n\t}\n\treturn FALSE;\n}\n\nint sbi_getc(void)\n{\n\tif (console_dev && console_dev->console_getc)\n\t\treturn console_dev->console_getc();\n\treturn -1;\n}\n\nvoid sbi_putc(char ch)\n{\n\tif (console_dev && console_dev->console_putc) {\n\t\tif (ch == '\\n')\n\t\t\tconsole_dev->console_putc('\\r');\n\t\tconsole_dev->console_putc(ch);\n\t}\n}\n\nvoid sbi_puts(const char *str)\n{\n\tspin_lock(&console_out_lock);\n\twhile (*str) {\n\t\tsbi_putc(*str);\n\t\tstr++;\n\t}\n\tspin_unlock(&console_out_lock);\n}\n\nvoid sbi_gets(char *s, int maxwidth, char endchar)\n{\n\tint ch;\n\tchar *retval = s;\n\n\twhile ((ch = sbi_getc()) != endchar && ch >= 0 && maxwidth > 1) {\n\t\t*retval = (char)ch;\n\t\tretval++;\n\t\tmaxwidth--;\n\t}\n\t*retval = '\\0';\n}\n\n#define PAD_RIGHT 1\n#define PAD_ZERO 2\n#define PAD_ALTERNATE 4\n#define PRINT_BUF_LEN 64\n\n#define va_start(v, l) __builtin_va_start((v), l)\n#define va_end __builtin_va_end\n#define va_arg __builtin_va_arg\ntypedef __builtin_va_list va_list;\n\nstatic void printc(char **out, u32 *out_len, char ch)\n{\n\tif (!out) {\n\t\tsbi_putc(ch);\n\t\treturn;\n\t}\n\n\t/*\n\t * The *printf entry point functions have enforced that (*out) can\n\t * only be null when out_len is non-null and its value is zero.\n\t */\n\tif (!out_len || *out_len > 1) {\n\t\t*(*out)++ = ch;\n\t\t**out = '\\0';\n\t}\n\n\tif (out_len && *out_len > 0)\n\t\t--(*out_len);\n}\n\nstatic int prints(char **out, u32 *out_len, const char *string, int width,\n\t\t  int flags)\n{\n\tint pc\t     = 0;\n\tchar padchar = ' ';\n\n\tif (width > 0) {\n\t\tint len = 0;\n\t\tconst char *ptr;\n\t\tfor (ptr = string; *ptr; ++ptr)\n\t\t\t++len;\n\t\tif (len >= width)\n\t\t\twidth = 0;\n\t\telse\n\t\t\twidth -= len;\n\t\tif (flags & PAD_ZERO)\n\t\t\tpadchar = '0';\n\t}\n\tif (!(flags & PAD_RIGHT)) {\n\t\tfor (; width > 0; --width) {\n\t\t\tprintc(out, out_len, padchar);\n\t\t\t++pc;\n\t\t}\n\t}\n\tfor (; *string; ++string) {\n\t\tprintc(out, out_len, *string);\n\t\t++pc;\n\t}\n\tfor (; width > 0; --width) {\n\t\tprintc(out, out_len, padchar);\n\t\t++pc;\n\t}\n\n\treturn pc;\n}\n\nstatic int printi(char **out, u32 *out_len, long long i, int b, int sg,\n\t\t  int width, int flags, int letbase)\n{\n\tchar print_buf[PRINT_BUF_LEN];\n\tchar *s;\n\tint neg = 0, pc = 0;\n\tu64 t;\n\tunsigned long long u = i;\n\n\tif (sg && b == 10 && i < 0) {\n\t\tneg = 1;\n\t\tu   = -i;\n\t}\n\n\ts  = print_buf + PRINT_BUF_LEN - 1;\n\t*s = '\\0';\n\n\tif (!u) {\n\t\t*--s = '0';\n\t} else {\n\t\twhile (u) {\n\t\t\tt = u % b;\n\t\t\tu = u / b;\n\t\t\tif (t >= 10)\n\t\t\t\tt += letbase - '0' - 10;\n\t\t\t*--s = t + '0';\n\t\t}\n\t}\n\n\tif (flags & PAD_ALTERNATE) {\n\t\tif ((b == 16) && (letbase == 'A')) {\n\t\t\t*--s = 'X';\n\t\t} else if ((b == 16) && (letbase == 'a')) {\n\t\t\t*--s = 'x';\n\t\t}\n\t\t*--s = '0';\n\t}\n\n\tif (neg) {\n\t\tif (width && (flags & PAD_ZERO)) {\n\t\t\tprintc(out, out_len, '-');\n\t\t\t++pc;\n\t\t\t--width;\n\t\t} else {\n\t\t\t*--s = '-';\n\t\t}\n\t}\n\n\treturn pc + prints(out, out_len, s, width, flags);\n}\n\nstatic int print(char **out, u32 *out_len, const char *format, va_list args)\n{\n\tint width, flags;\n\tint pc = 0;\n\tchar scr[2];\n\tunsigned long long tmp;\n\n\tfor (; *format != 0; ++format) {\n\t\tif (*format == '%') {\n\t\t\t++format;\n\t\t\twidth = flags = 0;\n\t\t\tif (*format == '\\0')\n\t\t\t\tbreak;\n\t\t\tif (*format == '%')\n\t\t\t\tgoto literal;\n\t\t\t/* Get flags */\n\t\t\tif (*format == '-') {\n\t\t\t\t++format;\n\t\t\t\tflags = PAD_RIGHT;\n\t\t\t}\n\t\t\tif (*format == '#') {\n\t\t\t\t++format;\n\t\t\t\tflags |= PAD_ALTERNATE;\n\t\t\t}\n\t\t\twhile (*format == '0') {\n\t\t\t\t++format;\n\t\t\t\tflags |= PAD_ZERO;\n\t\t\t}\n\t\t\t/* Get width */\n\t\t\tfor (; *format >= '0' && *format <= '9'; ++format) {\n\t\t\t\twidth *= 10;\n\t\t\t\twidth += *format - '0';\n\t\t\t}\n\t\t\tif (*format == 's') {\n\t\t\t\tchar *s = va_arg(args, char *);\n\t\t\t\tpc += prints(out, out_len, s ? s : \"(null)\",\n\t\t\t\t\t     width, flags);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((*format == 'd') || (*format == 'i')) {\n\t\t\t\tpc += printi(out, out_len, va_arg(args, int),\n\t\t\t\t\t     10, 1, width, flags, '0');\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (*format == 'x') {\n\t\t\t\tpc += printi(out, out_len,\n\t\t\t\t\t     va_arg(args, unsigned int), 16, 0,\n\t\t\t\t\t     width, flags, 'a');\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (*format == 'X') {\n\t\t\t\tpc += printi(out, out_len,\n\t\t\t\t\t     va_arg(args, unsigned int), 16, 0,\n\t\t\t\t\t     width, flags, 'A');\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (*format == 'u') {\n\t\t\t\tpc += printi(out, out_len,\n\t\t\t\t\t     va_arg(args, unsigned int), 10, 0,\n\t\t\t\t\t     width, flags, 'a');\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (*format == 'p') {\n\t\t\t\tpc += printi(out, out_len,\n\t\t\t\t\t     va_arg(args, unsigned long), 16, 0,\n\t\t\t\t\t     width, flags, 'a');\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (*format == 'P') {\n\t\t\t\tpc += printi(out, out_len,\n\t\t\t\t\t     va_arg(args, unsigned long), 16, 0,\n\t\t\t\t\t     width, flags, 'A');\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (*format == 'l' && *(format + 1) == 'l') {\n\t\t\t\ttmp = va_arg(args, unsigned long long);\n\t\t\t\tif (*(format + 2) == 'u') {\n\t\t\t\t\tformat += 2;\n\t\t\t\t\tpc += printi(out, out_len, tmp, 10, 0,\n\t\t\t\t\t\t     width, flags, 'a');\n\t\t\t\t} else if (*(format + 2) == 'x') {\n\t\t\t\t\tformat += 2;\n\t\t\t\t\tpc += printi(out, out_len, tmp, 16, 0,\n\t\t\t\t\t\t     width, flags, 'a');\n\t\t\t\t} else if (*(format + 2) == 'X') {\n\t\t\t\t\tformat += 2;\n\t\t\t\t\tpc += printi(out, out_len, tmp, 16, 0,\n\t\t\t\t\t\t     width, flags, 'A');\n\t\t\t\t} else {\n\t\t\t\t\tformat += 1;\n\t\t\t\t\tpc += printi(out, out_len, tmp, 10, 1,\n\t\t\t\t\t\t     width, flags, '0');\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t} else if (*format == 'l') {\n\t\t\t\tif (*(format + 1) == 'u') {\n\t\t\t\t\tformat += 1;\n\t\t\t\t\tpc += printi(\n\t\t\t\t\t\tout, out_len,\n\t\t\t\t\t\tva_arg(args, unsigned long), 10,\n\t\t\t\t\t\t0, width, flags, 'a');\n\t\t\t\t} else if (*(format + 1) == 'x') {\n\t\t\t\t\tformat += 1;\n\t\t\t\t\tpc += printi(\n\t\t\t\t\t\tout, out_len,\n\t\t\t\t\t\tva_arg(args, unsigned long), 16,\n\t\t\t\t\t\t0, width, flags, 'a');\n\t\t\t\t} else if (*(format + 1) == 'X') {\n\t\t\t\t\tformat += 1;\n\t\t\t\t\tpc += printi(\n\t\t\t\t\t\tout, out_len,\n\t\t\t\t\t\tva_arg(args, unsigned long), 16,\n\t\t\t\t\t\t0, width, flags, 'A');\n\t\t\t\t} else {\n\t\t\t\t\tpc += printi(out, out_len,\n\t\t\t\t\t\t     va_arg(args, long), 10, 1,\n\t\t\t\t\t\t     width, flags, '0');\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (*format == 'c') {\n\t\t\t\t/* char are converted to int then pushed on the stack */\n\t\t\t\tscr[0] = va_arg(args, int);\n\t\t\t\tscr[1] = '\\0';\n\t\t\t\tpc += prints(out, out_len, scr, width, flags);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else {\nliteral:\n\t\t\tprintc(out, out_len, *format);\n\t\t\t++pc;\n\t\t}\n\t}\n\n\treturn pc;\n}\n\nint sbi_sprintf(char *out, const char *format, ...)\n{\n\tva_list args;\n\tint retval;\n\n\tif (unlikely(!out))\n\t\tsbi_panic(\"sbi_sprintf called with NULL output string\\n\");\n\n\tva_start(args, format);\n\tretval = print(&out, NULL, format, args);\n\tva_end(args);\n\n\treturn retval;\n}\n\nint sbi_snprintf(char *out, u32 out_sz, const char *format, ...)\n{\n\tva_list args;\n\tint retval;\n\n\tif (unlikely(!out && out_sz != 0))\n\t\tsbi_panic(\"sbi_snprintf called with NULL output string and \"\n\t\t\t  \"output size is not zero\\n\");\n\n\tva_start(args, format);\n\tretval = print(&out, &out_sz, format, args);\n\tva_end(args);\n\n\treturn retval;\n}\n\nint sbi_printf(const char *format, ...)\n{\n\tva_list args;\n\tint retval;\n\n\tspin_lock(&console_out_lock);\n\tva_start(args, format);\n\tretval = print(NULL, NULL, format, args);\n\tva_end(args);\n\tspin_unlock(&console_out_lock);\n\n\treturn retval;\n}\n\nint sbi_dprintf(const char *format, ...)\n{\n\tva_list args;\n\tint retval = 0;\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\n\tva_start(args, format);\n\tif (scratch->options & SBI_SCRATCH_DEBUG_PRINTS) {\n\t\tspin_lock(&console_out_lock);\n\t\tretval = print(NULL, NULL, format, args);\n\t\tspin_unlock(&console_out_lock);\n\t}\n\tva_end(args);\n\n\treturn retval;\n}\n\nvoid sbi_panic(const char *format, ...)\n{\n\tva_list args;\n\n\tspin_lock(&console_out_lock);\n\tva_start(args, format);\n\tprint(NULL, NULL, format, args);\n\tva_end(args);\n\tspin_unlock(&console_out_lock);\n\n\tsbi_hart_hang();\n}\n\nconst struct sbi_console_device *sbi_console_get_device(void)\n{\n\treturn console_dev;\n}\n\nvoid sbi_console_set_device(const struct sbi_console_device *dev)\n{\n\tif (!dev || console_dev)\n\t\treturn;\n\n\tconsole_dev = dev;\n}\n\nint sbi_console_init(struct sbi_scratch *scratch)\n{\n\treturn sbi_platform_console_init(sbi_platform_ptr(scratch));\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_domain.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_hsm.h>\n#include <sbi/sbi_math.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_string.h>\n\nstruct sbi_domain *hartid_to_domain_table[SBI_HARTMASK_MAX_BITS] = { 0 };\nstruct sbi_domain *domidx_to_domain_table[SBI_DOMAIN_MAX_INDEX] = { 0 };\nstatic u32 domain_count = 0;\nstatic bool domain_finalized = false;\n\nstatic struct sbi_hartmask root_hmask = { 0 };\n\n#define ROOT_REGION_MAX\t16\nstatic u32 root_memregs_count = 0;\nstatic struct sbi_domain_memregion root_fw_region;\nstatic struct sbi_domain_memregion root_memregs[ROOT_REGION_MAX + 1] = { 0 };\n\nstruct sbi_domain root = {\n\t.name = \"root\",\n\t.possible_harts = &root_hmask,\n\t.regions = root_memregs,\n\t.system_reset_allowed = TRUE,\n};\n\nbool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartid)\n{\n\tif (dom)\n\t\treturn sbi_hartmask_test_hart(hartid, &dom->assigned_harts);\n\n\treturn FALSE;\n}\n\nulong sbi_domain_get_assigned_hartmask(const struct sbi_domain *dom,\n\t\t\t\t       ulong hbase)\n{\n\tulong ret, bword, boff;\n\n\tif (!dom)\n\t\treturn 0;\n\n\tbword = BIT_WORD(hbase);\n\tboff = BIT_WORD_OFFSET(hbase);\n\n\tret = sbi_hartmask_bits(&dom->assigned_harts)[bword++] >> boff;\n\tif (boff && bword < BIT_WORD(SBI_HARTMASK_MAX_BITS)) {\n\t\tret |= (sbi_hartmask_bits(&dom->assigned_harts)[bword] &\n\t\t\t(BIT(boff) - 1UL)) << (BITS_PER_LONG - boff);\n\t}\n\n\treturn ret;\n}\n\nstatic void domain_memregion_initfw(struct sbi_domain_memregion *reg)\n{\n\tif (!reg)\n\t\treturn;\n\n\tsbi_memcpy(reg, &root_fw_region, sizeof(*reg));\n}\n\nvoid sbi_domain_memregion_init(unsigned long addr,\n\t\t\t\tunsigned long size,\n\t\t\t\tunsigned long flags,\n\t\t\t\tstruct sbi_domain_memregion *reg)\n{\n\tunsigned long base = 0, order;\n\n\tfor (order = log2roundup(size) ; order <= __riscv_xlen; order++) {\n\t\tif (order < __riscv_xlen) {\n\t\t\tbase = addr & ~((1UL << order) - 1UL);\n\t\t\tif ((base <= addr) &&\n\t\t\t    (addr < (base + (1UL << order))) &&\n\t\t\t    (base <= (addr + size - 1UL)) &&\n\t\t\t    ((addr + size - 1UL) < (base + (1UL << order))))\n\t\t\t\tbreak;\n\t\t} else {\n\t\t\tbase = 0;\n\t\t\tbreak;\n\t\t}\n\n\t}\n\n\tif (reg) {\n\t\treg->base = base;\n\t\treg->order = order;\n\t\treg->flags = flags;\n\t}\n}\n\nbool sbi_domain_check_addr(const struct sbi_domain *dom,\n\t\t\t   unsigned long addr, unsigned long mode,\n\t\t\t   unsigned long access_flags)\n{\n\tbool rmmio, mmio = FALSE;\n\tstruct sbi_domain_memregion *reg;\n\tunsigned long rstart, rend, rflags, rwx = 0;\n\n\tif (!dom)\n\t\treturn FALSE;\n\n\tif (access_flags & SBI_DOMAIN_READ)\n\t\trwx |= SBI_DOMAIN_MEMREGION_READABLE;\n\tif (access_flags & SBI_DOMAIN_WRITE)\n\t\trwx |= SBI_DOMAIN_MEMREGION_WRITEABLE;\n\tif (access_flags & SBI_DOMAIN_EXECUTE)\n\t\trwx |= SBI_DOMAIN_MEMREGION_EXECUTABLE;\n\tif (access_flags & SBI_DOMAIN_MMIO)\n\t\tmmio = TRUE;\n\n\tsbi_domain_for_each_memregion(dom, reg) {\n\t\trflags = reg->flags;\n\t\tif (mode == PRV_M && !(rflags & SBI_DOMAIN_MEMREGION_MMODE))\n\t\t\tcontinue;\n\n\t\trstart = reg->base;\n\t\trend = (reg->order < __riscv_xlen) ?\n\t\t\trstart + ((1UL << reg->order) - 1) : -1UL;\n\t\tif (rstart <= addr && addr <= rend) {\n\t\t\trmmio = (rflags & SBI_DOMAIN_MEMREGION_MMIO) ? TRUE : FALSE;\n\t\t\tif (mmio != rmmio)\n\t\t\t\treturn FALSE;\n\t\t\treturn ((rflags & rwx) == rwx) ? TRUE : FALSE;\n\t\t}\n\t}\n\n\treturn (mode == PRV_M) ? TRUE : FALSE;\n}\n\n/* Check if region complies with constraints */\nstatic bool is_region_valid(const struct sbi_domain_memregion *reg)\n{\n\tif (reg->order < 3 || __riscv_xlen < reg->order)\n\t\treturn FALSE;\n\n\tif (reg->order == __riscv_xlen && reg->base != 0)\n\t\treturn FALSE;\n\n\tif (reg->order < __riscv_xlen && (reg->base & (BIT(reg->order) - 1)))\n\t\treturn FALSE;\n\n\treturn TRUE;\n}\n\n/** Check if regionA is sub-region of regionB */\nstatic bool is_region_subset(const struct sbi_domain_memregion *regA,\n\t\t\t     const struct sbi_domain_memregion *regB)\n{\n\tulong regA_start = regA->base;\n\tulong regA_end = regA->base + (BIT(regA->order) - 1);\n\tulong regB_start = regB->base;\n\tulong regB_end = regB->base + (BIT(regB->order) - 1);\n\n\tif ((regB_start <= regA_start) &&\n\t    (regA_start < regB_end) &&\n\t    (regB_start < regA_end) &&\n\t    (regA_end <= regB_end))\n\t\treturn TRUE;\n\n\treturn FALSE;\n}\n\n/** Check if regionA conflicts regionB */\nstatic bool is_region_conflict(const struct sbi_domain_memregion *regA,\n\t\t\t\tconst struct sbi_domain_memregion *regB)\n{\n\tif ((is_region_subset(regA, regB) || is_region_subset(regB, regA)) &&\n\t    regA->flags == regB->flags)\n\t\treturn TRUE;\n\n\treturn FALSE;\n}\n\n/** Check if regionA should be placed before regionB */\nstatic bool is_region_before(const struct sbi_domain_memregion *regA,\n\t\t\t     const struct sbi_domain_memregion *regB)\n{\n\tif (regA->order < regB->order)\n\t\treturn TRUE;\n\n\tif ((regA->order == regB->order) &&\n\t    (regA->base < regB->base))\n\t\treturn TRUE;\n\n\treturn FALSE;\n}\n\nstatic int sanitize_domain(const struct sbi_platform *plat,\n\t\t\t   struct sbi_domain *dom)\n{\n\tu32 i, j, count;\n\tbool have_fw_reg;\n\tstruct sbi_domain_memregion treg, *reg, *reg1;\n\n\t/* Check possible HARTs */\n\tif (!dom->possible_harts) {\n\t\tsbi_printf(\"%s: %s possible HART mask is NULL\\n\",\n\t\t\t   __func__, dom->name);\n\t\treturn SBI_EINVAL;\n\t}\n\tsbi_hartmask_for_each_hart(i, dom->possible_harts) {\n\t\tif (sbi_platform_hart_invalid(plat, i)) {\n\t\t\tsbi_printf(\"%s: %s possible HART mask has invalid \"\n\t\t\t\t   \"hart %d\\n\", __func__, dom->name, i);\n\t\t\treturn SBI_EINVAL;\n\t\t}\n\t};\n\n\t/* Check memory regions */\n\tif (!dom->regions) {\n\t\tsbi_printf(\"%s: %s regions is NULL\\n\",\n\t\t\t   __func__, dom->name);\n\t\treturn SBI_EINVAL;\n\t}\n\tsbi_domain_for_each_memregion(dom, reg) {\n\t\tif (!is_region_valid(reg)) {\n\t\t\tsbi_printf(\"%s: %s has invalid region base=0x%lx \"\n\t\t\t\t   \"order=%lu flags=0x%lx\\n\", __func__,\n\t\t\t\t   dom->name, reg->base, reg->order,\n\t\t\t\t   reg->flags);\n\t\t\treturn SBI_EINVAL;\n\t\t}\n\t}\n\n\t/* Count memory regions and check presence of firmware region */\n\tcount = 0;\n\thave_fw_reg = FALSE;\n\tsbi_domain_for_each_memregion(dom, reg) {\n\t\tif (reg->order == root_fw_region.order &&\n\t\t    reg->base == root_fw_region.base &&\n\t\t    reg->flags == root_fw_region.flags)\n\t\t\thave_fw_reg = TRUE;\n\t\tcount++;\n\t}\n\tif (!have_fw_reg) {\n\t\tsbi_printf(\"%s: %s does not have firmware region\\n\",\n\t\t\t   __func__, dom->name);\n\t\treturn SBI_EINVAL;\n\t}\n\n\t/* Sort the memory regions */\n\tfor (i = 0; i < (count - 1); i++) {\n\t\treg = &dom->regions[i];\n\t\tfor (j = i + 1; j < count; j++) {\n\t\t\treg1 = &dom->regions[j];\n\n\t\t\tif (is_region_conflict(reg1, reg)) {\n\t\t\t\tsbi_printf(\"%s: %s conflict between regions \"\n\t\t\t\t\t\"(base=0x%lx order=%lu flags=0x%lx) and \"\n\t\t\t\t\t\"(base=0x%lx order=%lu flags=0x%lx)\\n\",\n\t\t\t\t\t__func__, dom->name,\n\t\t\t\t\treg->base, reg->order, reg->flags,\n\t\t\t\t\treg1->base, reg1->order, reg1->flags);\n\t\t\t\treturn SBI_EINVAL;\n\t\t\t}\n\n\t\t\tif (!is_region_before(reg1, reg))\n\t\t\t\tcontinue;\n\n\t\t\tsbi_memcpy(&treg, reg1, sizeof(treg));\n\t\t\tsbi_memcpy(reg1, reg, sizeof(treg));\n\t\t\tsbi_memcpy(reg, &treg, sizeof(treg));\n\t\t}\n\t}\n\n\t/*\n\t * We don't need to check boot HART id of domain because if boot\n\t * HART id is not possible/assigned to this domain then it won't\n\t * be started at boot-time by sbi_domain_finalize().\n\t */\n\n\t/*\n\t * Check next mode\n\t *\n\t * We only allow next mode to be S-mode or U-mode.so that we can\n\t * protect M-mode context and enforce checks on memory accesses.\n\t */\n\tif (dom->next_mode != PRV_S &&\n\t    dom->next_mode != PRV_U) {\n\t\tsbi_printf(\"%s: %s invalid next booting stage mode 0x%lx\\n\",\n\t\t\t   __func__, dom->name, dom->next_mode);\n\t\treturn SBI_EINVAL;\n\t}\n\n\t/* Check next address and next mode*/\n\tif (!sbi_domain_check_addr(dom, dom->next_addr, dom->next_mode,\n\t\t\t\t   SBI_DOMAIN_EXECUTE)) {\n\t\tsbi_printf(\"%s: %s next booting stage address 0x%lx can't \"\n\t\t\t   \"execute\\n\", __func__, dom->name, dom->next_addr);\n\t\treturn SBI_EINVAL;\n\t}\n\n\treturn 0;\n}\n\nvoid sbi_domain_dump(const struct sbi_domain *dom, const char *suffix)\n{\n\tu32 i, k;\n\tunsigned long rstart, rend;\n\tstruct sbi_domain_memregion *reg;\n\n\tsbi_printf(\"Domain%d Name        %s: %s\\n\",\n\t\t   dom->index, suffix, dom->name);\n\n\tsbi_printf(\"Domain%d Boot HART   %s: %d\\n\",\n\t\t   dom->index, suffix, dom->boot_hartid);\n\n\tk = 0;\n\tsbi_printf(\"Domain%d HARTs       %s: \", dom->index, suffix);\n\tsbi_hartmask_for_each_hart(i, dom->possible_harts)\n\t\tsbi_printf(\"%s%d%s\", (k++) ? \",\" : \"\",\n\t\t\t   i, sbi_domain_is_assigned_hart(dom, i) ? \"*\" : \"\");\n\tsbi_printf(\"\\n\");\n\n\ti = 0;\n\tsbi_domain_for_each_memregion(dom, reg) {\n\t\trstart = reg->base;\n\t\trend = (reg->order < __riscv_xlen) ?\n\t\t\trstart + ((1UL << reg->order) - 1) : -1UL;\n\n\t\tsbi_printf(\"Domain%d Region%02d    %s: 0x%\" PRILX \"-0x%\" PRILX \" \",\n\t\t\t   dom->index, i, suffix, rstart, rend);\n\n\t\tk = 0;\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_MMODE)\n\t\t\tsbi_printf(\"%cM\", (k++) ? ',' : '(');\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_MMIO)\n\t\t\tsbi_printf(\"%cI\", (k++) ? ',' : '(');\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_READABLE)\n\t\t\tsbi_printf(\"%cR\", (k++) ? ',' : '(');\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_WRITEABLE)\n\t\t\tsbi_printf(\"%cW\", (k++) ? ',' : '(');\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_EXECUTABLE)\n\t\t\tsbi_printf(\"%cX\", (k++) ? ',' : '(');\n\t\tsbi_printf(\"%s\\n\", (k++) ? \")\" : \"()\");\n\n\t\ti++;\n\t}\n\n\tsbi_printf(\"Domain%d Next Address%s: 0x%\" PRILX \"\\n\",\n\t\t   dom->index, suffix, dom->next_addr);\n\n\tsbi_printf(\"Domain%d Next Arg1   %s: 0x%\" PRILX \"\\n\",\n\t\t   dom->index, suffix, dom->next_arg1);\n\n\tsbi_printf(\"Domain%d Next Mode   %s: \", dom->index, suffix);\n\tswitch (dom->next_mode) {\n\tcase PRV_M:\n\t\tsbi_printf(\"M-mode\\n\");\n\t\tbreak;\n\tcase PRV_S:\n\t\tsbi_printf(\"S-mode\\n\");\n\t\tbreak;\n\tcase PRV_U:\n\t\tsbi_printf(\"U-mode\\n\");\n\t\tbreak;\n\tdefault:\n\t\tsbi_printf(\"Unknown\\n\");\n\t\tbreak;\n\t};\n\n\tsbi_printf(\"Domain%d SysReset    %s: %s\\n\",\n\t\t   dom->index, suffix, (dom->system_reset_allowed) ? \"yes\" : \"no\");\n}\n\nvoid sbi_domain_dump_all(const char *suffix)\n{\n\tu32 i;\n\tconst struct sbi_domain *dom;\n\n\tsbi_domain_for_each(i, dom) {\n\t\tsbi_domain_dump(dom, suffix);\n\t\tsbi_printf(\"\\n\");\n\t}\n}\n\nint sbi_domain_register(struct sbi_domain *dom,\n\t\t\tconst struct sbi_hartmask *assign_mask)\n{\n\tu32 i;\n\tint rc;\n\tstruct sbi_domain *tdom;\n\tu32 cold_hartid = current_hartid();\n\tconst struct sbi_platform *plat = sbi_platform_thishart_ptr();\n\n\t/* Sanity checks */\n\tif (!dom || !assign_mask || domain_finalized)\n\t\treturn SBI_EINVAL;\n\n\t/* Check if domain already discovered */\n\tsbi_domain_for_each(i, tdom) {\n\t\tif (tdom == dom)\n\t\t\treturn SBI_EALREADY;\n\t}\n\n\t/*\n\t * Ensure that we have room for Domain Index to\n\t * HART ID mapping\n\t */\n\tif (SBI_DOMAIN_MAX_INDEX <= domain_count) {\n\t\tsbi_printf(\"%s: No room for %s\\n\",\n\t\t\t   __func__, dom->name);\n\t\treturn SBI_ENOSPC;\n\t}\n\n\t/* Sanitize discovered domain */\n\trc = sanitize_domain(plat, dom);\n\tif (rc) {\n\t\tsbi_printf(\"%s: sanity checks failed for\"\n\t\t\t   \" %s (error %d)\\n\", __func__,\n\t\t\t   dom->name, rc);\n\t\treturn rc;\n\t}\n\n\t/* Assign index to domain */\n\tdom->index = domain_count++;\n\tdomidx_to_domain_table[dom->index] = dom;\n\n\t/* Clear assigned HARTs of domain */\n\tsbi_hartmask_clear_all(&dom->assigned_harts);\n\n\t/* Assign domain to HART if HART is a possible HART */\n\tsbi_hartmask_for_each_hart(i, assign_mask) {\n\t\tif (!sbi_hartmask_test_hart(i, dom->possible_harts))\n\t\t\tcontinue;\n\n\t\ttdom = hartid_to_domain_table[i];\n\t\tif (tdom)\n\t\t\tsbi_hartmask_clear_hart(i,\n\t\t\t\t\t&tdom->assigned_harts);\n\t\thartid_to_domain_table[i] = dom;\n\t\tsbi_hartmask_set_hart(i, &dom->assigned_harts);\n\n\t\t/*\n\t\t * If cold boot HART is assigned to this domain then\n\t\t * override boot HART of this domain.\n\t\t */\n\t\tif (i == cold_hartid &&\n\t\t    dom->boot_hartid != cold_hartid) {\n\t\t\tsbi_printf(\"Domain%d Boot HARTID forced to\"\n\t\t\t\t   \" %d\\n\", dom->index, cold_hartid);\n\t\t\tdom->boot_hartid = cold_hartid;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nint sbi_domain_root_add_memregion(const struct sbi_domain_memregion *reg)\n{\n\tint rc;\n\tbool reg_merged;\n\tstruct sbi_domain_memregion *nreg, *nreg1, *nreg2;\n\tconst struct sbi_platform *plat = sbi_platform_thishart_ptr();\n\n\t/* Sanity checks */\n\tif (!reg || domain_finalized ||\n\t    (root.regions != root_memregs) ||\n\t    (ROOT_REGION_MAX <= root_memregs_count))\n\t\treturn SBI_EINVAL;\n\n\t/* Check for conflicts */\n\tsbi_domain_for_each_memregion(&root, nreg) {\n\t\tif (is_region_conflict(reg, nreg)) {\n\t\t\tsbi_printf(\"%s: is_region_conflict check failed\"\n\t\t\t\" 0x%lx conflicts existing 0x%lx\\n\", __func__,\n\t\t\t\t   reg->base, nreg->base);\n\t\t\treturn SBI_EALREADY;\n\t\t}\n\t}\n\n\t/* Append the memregion to root memregions */\n\tnreg = &root_memregs[root_memregs_count];\n\tsbi_memcpy(nreg, reg, sizeof(*reg));\n\troot_memregs_count++;\n\troot_memregs[root_memregs_count].order = 0;\n\n\t/* Sort and optimize root regions */\n\tdo {\n\t\t/* Sanitize the root domain so that memregions are sorted */\n\t\trc = sanitize_domain(plat, &root);\n\t\tif (rc) {\n\t\t\tsbi_printf(\"%s: sanity checks failed for\"\n\t\t\t\t   \" %s (error %d)\\n\", __func__,\n\t\t\t\t   root.name, rc);\n\t\t\treturn rc;\n\t\t}\n\n\t\t/* Merge consecutive memregions with same order and flags */\n\t\treg_merged = false;\n\t\tsbi_domain_for_each_memregion(&root, nreg) {\n\t\t\tnreg1 = nreg + 1;\n\t\t\tif (!nreg1->order)\n\t\t\t\tcontinue;\n\n\t\t\tif (!(nreg->base & (BIT(nreg->order + 1) - 1)) &&\n\t\t\t    (nreg->base + BIT(nreg->order)) == nreg1->base &&\n\t\t\t    nreg->order == nreg1->order &&\n\t\t\t    nreg->flags == nreg1->flags) {\n\t\t\t\tnreg->order++;\n\t\t\t\twhile (nreg1->order) {\n\t\t\t\t\tnreg2 = nreg1 + 1;\n\t\t\t\t\tsbi_memcpy(nreg1, nreg2, sizeof(*nreg1));\n\t\t\t\t\tnreg1++;\n\t\t\t\t}\n\t\t\t\treg_merged = true;\n\t\t\t\troot_memregs_count--;\n\t\t\t}\n\t\t}\n\t} while (reg_merged);\n\n\treturn 0;\n}\n\nint sbi_domain_root_add_memrange(unsigned long addr, unsigned long size,\n\t\t\t   unsigned long align, unsigned long region_flags)\n{\n\tint rc;\n\tunsigned long pos, end, rsize;\n\tstruct sbi_domain_memregion reg;\n\n\tpos = addr;\n\tend = addr + size;\n\twhile (pos < end) {\n\t\trsize = pos & (align - 1);\n\t\tif (rsize)\n\t\t\trsize = 1UL << sbi_ffs(pos);\n\t\telse\n\t\t\trsize = ((end - pos) < align) ?\n\t\t\t\t(end - pos) : align;\n\n\t\tsbi_domain_memregion_init(pos, rsize, region_flags, &reg);\n\t\trc = sbi_domain_root_add_memregion(&reg);\n\t\tif (rc)\n\t\t\treturn rc;\n\t\tpos += rsize;\n\t}\n\n\treturn 0;\n}\n\nint sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid)\n{\n\tint rc;\n\tu32 i, dhart;\n\tstruct sbi_domain *dom;\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\t/* Initialize and populate domains for the platform */\n\trc = sbi_platform_domains_init(plat);\n\tif (rc) {\n\t\tsbi_printf(\"%s: platform domains_init() failed (error %d)\\n\",\n\t\t\t   __func__, rc);\n\t\treturn rc;\n\t}\n\n\t/* Startup boot HART of domains */\n\tsbi_domain_for_each(i, dom) {\n\t\t/* Domain boot HART */\n\t\tdhart = dom->boot_hartid;\n\n\t\t/* Ignore of boot HART is off limits */\n\t\tif (SBI_HARTMASK_MAX_BITS <= dhart)\n\t\t\tcontinue;\n\n\t\t/* Ignore if boot HART not possible for this domain */\n\t\tif (!sbi_hartmask_test_hart(dhart, dom->possible_harts))\n\t\t\tcontinue;\n\n\t\t/* Ignore if boot HART assigned different domain */\n\t\tif (sbi_hartid_to_domain(dhart) != dom ||\n\t\t    !sbi_hartmask_test_hart(dhart, &dom->assigned_harts))\n\t\t\tcontinue;\n\n\t\t/* Startup boot HART of domain */\n\t\tif (dhart == cold_hartid) {\n\t\t\tscratch->next_addr = dom->next_addr;\n\t\t\tscratch->next_mode = dom->next_mode;\n\t\t\tscratch->next_arg1 = dom->next_arg1;\n\t\t} else {\n\t\t\trc = sbi_hsm_hart_start(scratch, NULL, dhart,\n\t\t\t\t\t\tdom->next_addr,\n\t\t\t\t\t\tdom->next_mode,\n\t\t\t\t\t\tdom->next_arg1);\n\t\t\tif (rc) {\n\t\t\t\tsbi_printf(\"%s: failed to start boot HART %d\"\n\t\t\t\t\t   \" for %s (error %d)\\n\", __func__,\n\t\t\t\t\t   dhart, dom->name, rc);\n\t\t\t\treturn rc;\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t * Set the finalized flag so that the root domain\n\t * regions can't be changed.\n\t */\n\tdomain_finalized = true;\n\n\treturn 0;\n}\n\nint sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid)\n{\n\tu32 i;\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\t/* Root domain firmware memory region */\n\tsbi_domain_memregion_init(scratch->fw_start, scratch->fw_size, 0,\n\t\t\t\t  &root_fw_region);\n\tdomain_memregion_initfw(&root_memregs[root_memregs_count++]);\n\n\t/* Root domain allow everything memory region */\n\tsbi_domain_memregion_init(0, ~0UL,\n\t\t\t\t  (SBI_DOMAIN_MEMREGION_READABLE |\n\t\t\t\t   SBI_DOMAIN_MEMREGION_WRITEABLE |\n\t\t\t\t   SBI_DOMAIN_MEMREGION_EXECUTABLE),\n\t\t\t\t  &root_memregs[root_memregs_count++]);\n\n\t/* Root domain memory region end */\n\troot_memregs[root_memregs_count].order = 0;\n\n\t/* Root domain boot HART id is same as coldboot HART id */\n\troot.boot_hartid = cold_hartid;\n\n\t/* Root domain next booting stage details */\n\troot.next_arg1 = scratch->next_arg1;\n\troot.next_addr = scratch->next_addr;\n\troot.next_mode = scratch->next_mode;\n\n\t/* Root domain possible and assigned HARTs */\n\tfor (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {\n\t\tif (sbi_platform_hart_invalid(plat, i))\n\t\t\tcontinue;\n\t\tsbi_hartmask_set_hart(i, &root_hmask);\n\t}\n\n\treturn sbi_domain_register(&root, &root_hmask);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_trap.h>\n\nextern struct sbi_ecall_extension *sbi_ecall_exts[];\nextern unsigned long sbi_ecall_exts_size;\n\nu16 sbi_ecall_version_major(void)\n{\n\treturn SBI_ECALL_VERSION_MAJOR;\n}\n\nu16 sbi_ecall_version_minor(void)\n{\n\treturn SBI_ECALL_VERSION_MINOR;\n}\n\nstatic unsigned long ecall_impid = SBI_OPENSBI_IMPID;\n\nunsigned long sbi_ecall_get_impid(void)\n{\n\treturn ecall_impid;\n}\n\nvoid sbi_ecall_set_impid(unsigned long impid)\n{\n\tecall_impid = impid;\n}\n\nstatic SBI_LIST_HEAD(ecall_exts_list);\n\nstruct sbi_ecall_extension *sbi_ecall_find_extension(unsigned long extid)\n{\n\tstruct sbi_ecall_extension *t, *ret = NULL;\n\n\tsbi_list_for_each_entry(t, &ecall_exts_list, head) {\n\t\tif (t->extid_start <= extid && extid <= t->extid_end) {\n\t\t\tret = t;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn ret;\n}\n\nint sbi_ecall_register_extension(struct sbi_ecall_extension *ext)\n{\n\tstruct sbi_ecall_extension *t;\n\n\tif (!ext || (ext->extid_end < ext->extid_start) || !ext->handle)\n\t\treturn SBI_EINVAL;\n\n\tsbi_list_for_each_entry(t, &ecall_exts_list, head) {\n\t\tunsigned long start = t->extid_start;\n\t\tunsigned long end = t->extid_end;\n\t\tif (end < ext->extid_start || ext->extid_end < start)\n\t\t\t/* no overlap */;\n\t\telse\n\t\t\treturn SBI_EINVAL;\n\t}\n\n\tSBI_INIT_LIST_HEAD(&ext->head);\n\tsbi_list_add_tail(&ext->head, &ecall_exts_list);\n\n\treturn 0;\n}\n\nvoid sbi_ecall_unregister_extension(struct sbi_ecall_extension *ext)\n{\n\tbool found = FALSE;\n\tstruct sbi_ecall_extension *t;\n\n\tif (!ext)\n\t\treturn;\n\n\tsbi_list_for_each_entry(t, &ecall_exts_list, head) {\n\t\tif (t == ext) {\n\t\t\tfound = TRUE;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (found)\n\t\tsbi_list_del_init(&ext->head);\n}\n\nint sbi_ecall_handler(struct sbi_trap_regs *regs)\n{\n\tint ret = 0;\n\tstruct sbi_ecall_extension *ext;\n\tunsigned long extension_id = regs->a7;\n\tunsigned long func_id = regs->a6;\n\tstruct sbi_trap_info trap = {0};\n\tunsigned long out_val = 0;\n\tbool is_0_1_spec = 0;\n\n\text = sbi_ecall_find_extension(extension_id);\n\tif (ext && ext->handle) {\n\t\tret = ext->handle(extension_id, func_id,\n\t\t\t\t  regs, &out_val, &trap);\n\t\tif (extension_id >= SBI_EXT_0_1_SET_TIMER &&\n\t\t    extension_id <= SBI_EXT_0_1_SHUTDOWN)\n\t\t\tis_0_1_spec = 1;\n\t} else {\n\t\tret = SBI_ENOTSUPP;\n\t}\n\n\tif (ret == SBI_ETRAP) {\n\t\ttrap.epc = regs->mepc;\n\t\tsbi_trap_redirect(regs, &trap);\n\t} else {\n\t\tif (ret < SBI_LAST_ERR) {\n\t\t\tsbi_printf(\"%s: Invalid error %d for ext=0x%lx \"\n\t\t\t\t   \"func=0x%lx\\n\", __func__, ret,\n\t\t\t\t   extension_id, func_id);\n\t\t\tret = SBI_ERR_FAILED;\n\t\t}\n\n\t\t/*\n\t\t * This function should return non-zero value only in case of\n\t\t * fatal error. However, there is no good way to distinguish\n\t\t * between a fatal and non-fatal errors yet. That's why we treat\n\t\t * every return value except ETRAP as non-fatal and just return\n\t\t * accordingly for now. Once fatal errors are defined, that\n\t\t * case should be handled differently.\n\t\t */\n\t\tregs->mepc += 4;\n\t\tregs->a0 = ret;\n\t\tif (!is_0_1_spec)\n\t\t\tregs->a1 = out_val;\n\t}\n\n\treturn 0;\n}\n\nint sbi_ecall_init(void)\n{\n\tint ret;\n\tstruct sbi_ecall_extension *ext;\n\tunsigned long i;\n\n\tfor (i = 0; i < sbi_ecall_exts_size; i++) {\n\t\text = sbi_ecall_exts[i];\n\t\tret = sbi_ecall_register_extension(ext);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_base.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_version.h>\n#include <sbi/riscv_asm.h>\n\nstatic int sbi_ecall_base_probe(unsigned long extid, unsigned long *out_val)\n{\n\tstruct sbi_ecall_extension *ext;\n\n\text = sbi_ecall_find_extension(extid);\n\tif (!ext) {\n\t\t*out_val = 0;\n\t\treturn 0;\n\t}\n\n\tif (ext->probe)\n\t\treturn ext->probe(extid, out_val);\n\n\t*out_val = 1;\n\treturn 0;\n}\n\nstatic int sbi_ecall_base_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t  const struct sbi_trap_regs *regs,\n\t\t\t\t  unsigned long *out_val,\n\t\t\t\t  struct sbi_trap_info *out_trap)\n{\n\tint ret = 0;\n\n\tswitch (funcid) {\n\tcase SBI_EXT_BASE_GET_SPEC_VERSION:\n\t\t*out_val = (SBI_ECALL_VERSION_MAJOR <<\n\t\t\t   SBI_SPEC_VERSION_MAJOR_OFFSET) &\n\t\t\t   (SBI_SPEC_VERSION_MAJOR_MASK <<\n\t\t\t    SBI_SPEC_VERSION_MAJOR_OFFSET);\n\t\t*out_val = *out_val | SBI_ECALL_VERSION_MINOR;\n\t\tbreak;\n\tcase SBI_EXT_BASE_GET_IMP_ID:\n\t\t*out_val = sbi_ecall_get_impid();\n\t\tbreak;\n\tcase SBI_EXT_BASE_GET_IMP_VERSION:\n\t\t*out_val = OPENSBI_VERSION;\n\t\tbreak;\n\tcase SBI_EXT_BASE_GET_MVENDORID:\n\t\t*out_val = csr_read(CSR_MVENDORID);\n\t\tbreak;\n\tcase SBI_EXT_BASE_GET_MARCHID:\n\t\t*out_val = csr_read(CSR_MARCHID);\n\t\tbreak;\n\tcase SBI_EXT_BASE_GET_MIMPID:\n\t\t*out_val = csr_read(CSR_MIMPID);\n\t\tbreak;\n\tcase SBI_EXT_BASE_PROBE_EXT:\n\t\tret = sbi_ecall_base_probe(regs->a0, out_val);\n\t\tbreak;\n\tdefault:\n\t\tret = SBI_ENOTSUPP;\n\t}\n\n\treturn ret;\n}\n\nstruct sbi_ecall_extension ecall_base = {\n\t.extid_start = SBI_EXT_BASE,\n\t.extid_end = SBI_EXT_BASE,\n\t.handle = sbi_ecall_base_handler,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_exts.carray",
    "content": "HEADER: sbi/sbi_ecall.h\nTYPE: struct sbi_ecall_extension\nNAME: sbi_ecall_exts\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_hsm.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_version.h>\n#include <sbi/sbi_hsm.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/riscv_asm.h>\n\nstatic int sbi_ecall_hsm_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t const struct sbi_trap_regs *regs,\n\t\t\t\t unsigned long *out_val,\n\t\t\t\t struct sbi_trap_info *out_trap)\n{\n\tint ret = 0;\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\tulong smode = (csr_read(CSR_MSTATUS) & MSTATUS_MPP) >>\n\t\t\tMSTATUS_MPP_SHIFT;\n\n\tswitch (funcid) {\n\tcase SBI_EXT_HSM_HART_START:\n\t\tret = sbi_hsm_hart_start(scratch, sbi_domain_thishart_ptr(),\n\t\t\t\t\t regs->a0, regs->a1, smode, regs->a2);\n\t\tbreak;\n\tcase SBI_EXT_HSM_HART_STOP:\n\t\tret = sbi_hsm_hart_stop(scratch, TRUE);\n\t\tbreak;\n\tcase SBI_EXT_HSM_HART_GET_STATUS:\n\t\tret = sbi_hsm_hart_get_state(sbi_domain_thishart_ptr(),\n\t\t\t\t\t     regs->a0);\n\t\tbreak;\n\tcase SBI_EXT_HSM_HART_SUSPEND:\n\t\tret = sbi_hsm_hart_suspend(scratch, regs->a0, regs->a1,\n\t\t\t\t\t   smode, regs->a2);\n\t\tbreak;\n\tdefault:\n\t\tret = SBI_ENOTSUPP;\n\t};\n\tif (ret >= 0) {\n\t\t*out_val = ret;\n\t\tret = 0;\n\t}\n\n\treturn ret;\n}\n\nstruct sbi_ecall_extension ecall_hsm = {\n\t.extid_start = SBI_EXT_HSM,\n\t.extid_end = SBI_EXT_HSM,\n\t.handle = sbi_ecall_hsm_handler,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_ipi.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_ipi.h>\n\nstatic int sbi_ecall_ipi_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t const struct sbi_trap_regs *regs,\n\t\t\t\t unsigned long *out_val,\n\t\t\t\t struct sbi_trap_info *out_trap)\n{\n\tint ret = 0;\n\n\tif (funcid == SBI_EXT_IPI_SEND_IPI)\n\t\tret = sbi_ipi_send_smode(regs->a0, regs->a1);\n\telse\n\t\tret = SBI_ENOTSUPP;\n\n\treturn ret;\n}\n\nstruct sbi_ecall_extension ecall_ipi = {\n\t.extid_start = SBI_EXT_IPI,\n\t.extid_end = SBI_EXT_IPI,\n\t.handle = sbi_ecall_ipi_handler,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_legacy.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hsm.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_system.h>\n#include <sbi/sbi_timer.h>\n#include <sbi/sbi_tlb.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_unpriv.h>\n#include <sbi/sbi_hart.h>\n\nstatic int sbi_load_hart_mask_unpriv(ulong *pmask, ulong *hmask,\n\t\t\t\t     struct sbi_trap_info *uptrap)\n{\n\tulong mask = 0;\n\n\tif (pmask) {\n\t\tmask = sbi_load_ulong(pmask, uptrap);\n\t\tif (uptrap->cause)\n\t\t\treturn SBI_ETRAP;\n\t} else {\n\t\tsbi_hsm_hart_interruptible_mask(sbi_domain_thishart_ptr(),\n\t\t\t\t\t\t0, &mask);\n\t}\n\t*hmask = mask;\n\n\treturn 0;\n}\n\nstatic int sbi_ecall_legacy_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t    const struct sbi_trap_regs *regs,\n\t\t\t\t    unsigned long *out_val,\n\t\t\t\t    struct sbi_trap_info *out_trap)\n{\n\tint ret = 0;\n\tstruct sbi_tlb_info tlb_info;\n\tu32 source_hart = current_hartid();\n\tulong hmask = 0;\n\n\tswitch (extid) {\n\tcase SBI_EXT_0_1_SET_TIMER:\n#if __riscv_xlen == 32\n\t\tsbi_timer_event_start((((u64)regs->a1 << 32) | (u64)regs->a0));\n#else\n\t\tsbi_timer_event_start((u64)regs->a0);\n#endif\n\t\tbreak;\n\tcase SBI_EXT_0_1_CONSOLE_PUTCHAR:\n\t\tsbi_putc(regs->a0);\n\t\tbreak;\n\tcase SBI_EXT_0_1_CONSOLE_GETCHAR:\n\t\tret = sbi_getc();\n\t\tbreak;\n\tcase SBI_EXT_0_1_CLEAR_IPI:\n\t\tsbi_ipi_clear_smode();\n\t\tbreak;\n\tcase SBI_EXT_0_1_SEND_IPI:\n\t\tret = sbi_load_hart_mask_unpriv((ulong *)regs->a0,\n\t\t\t\t\t\t&hmask, out_trap);\n\t\tif (ret != SBI_ETRAP)\n\t\t\tret = sbi_ipi_send_smode(hmask, 0);\n\t\tbreak;\n\tcase SBI_EXT_0_1_REMOTE_FENCE_I:\n\t\tret = sbi_load_hart_mask_unpriv((ulong *)regs->a0,\n\t\t\t\t\t\t&hmask, out_trap);\n\t\tif (ret != SBI_ETRAP) {\n\t\t\tSBI_TLB_INFO_INIT(&tlb_info, 0, 0, 0, 0,\n\t\t\t\t\t  sbi_tlb_local_fence_i,\n\t\t\t\t\t  source_hart);\n\t\t\tret = sbi_tlb_request(hmask, 0, &tlb_info);\n\t\t}\n\t\tbreak;\n\tcase SBI_EXT_0_1_REMOTE_SFENCE_VMA:\n\t\tret = sbi_load_hart_mask_unpriv((ulong *)regs->a0,\n\t\t\t\t\t\t&hmask, out_trap);\n\t\tif (ret != SBI_ETRAP) {\n\t\t\tSBI_TLB_INFO_INIT(&tlb_info, regs->a1, regs->a2, 0, 0,\n\t\t\t\t\t  sbi_tlb_local_sfence_vma,\n\t\t\t\t\t  source_hart);\n\t\t\tret = sbi_tlb_request(hmask, 0, &tlb_info);\n\t\t}\n\t\tbreak;\n\tcase SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID:\n\t\tret = sbi_load_hart_mask_unpriv((ulong *)regs->a0,\n\t\t\t\t\t\t&hmask, out_trap);\n\t\tif (ret != SBI_ETRAP) {\n\t\t\tSBI_TLB_INFO_INIT(&tlb_info, regs->a1,\n\t\t\t\t\t  regs->a2, regs->a3, 0,\n\t\t\t\t\t  sbi_tlb_local_sfence_vma_asid,\n\t\t\t\t\t  source_hart);\n\t\t\tret = sbi_tlb_request(hmask, 0, &tlb_info);\n\t\t}\n\t\tbreak;\n\tcase SBI_EXT_0_1_SHUTDOWN:\n\t\tsbi_system_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,\n\t\t\t\t SBI_SRST_RESET_REASON_NONE);\n\t\tbreak;\n\tdefault:\n\t\tret = SBI_ENOTSUPP;\n\t};\n\n\treturn ret;\n}\n\nstruct sbi_ecall_extension ecall_legacy = {\n\t.extid_start = SBI_EXT_0_1_SET_TIMER,\n\t.extid_end = SBI_EXT_0_1_SHUTDOWN,\n\t.handle = sbi_ecall_legacy_handler,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_pmu.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_version.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/riscv_asm.h>\n\nstatic int sbi_ecall_pmu_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t const struct sbi_trap_regs *regs,\n\t\t\t\t unsigned long *out_val,\n\t\t\t\t struct sbi_trap_info *out_trap)\n{\n\tint ret = 0;\n\tuint64_t temp;\n\n\tswitch (funcid) {\n\tcase SBI_EXT_PMU_NUM_COUNTERS:\n\t\tret = sbi_pmu_num_ctr();\n\t\tif (ret >= 0) {\n\t\t\t*out_val = ret;\n\t\t\tret = 0;\n\t\t}\n\t\tbreak;\n\tcase SBI_EXT_PMU_COUNTER_GET_INFO:\n\t\tret = sbi_pmu_ctr_get_info(regs->a0, out_val);\n\t\tbreak;\n\tcase SBI_EXT_PMU_COUNTER_CFG_MATCH:\n#if __riscv_xlen == 32\n\t\ttemp = ((uint64_t)regs->a5 << 32) | regs->a4;\n#else\n\t\ttemp = regs->a4;\n#endif\n\t\tret = sbi_pmu_ctr_cfg_match(regs->a0, regs->a1, regs->a2,\n\t\t\t\t\t    regs->a3, temp);\n\t\tif (ret >= 0) {\n\t\t\t*out_val = ret;\n\t\t\tret = 0;\n\t\t}\n\n\t\tbreak;\n\tcase SBI_EXT_PMU_COUNTER_FW_READ:\n\t\tret = sbi_pmu_ctr_fw_read(regs->a0, &temp);\n\t\t*out_val = temp;\n\t\tbreak;\n\tcase SBI_EXT_PMU_COUNTER_START:\n\n#if __riscv_xlen == 32\n\t\ttemp = ((uint64_t)regs->a4 << 32) | regs->a3;\n#else\n\t\ttemp = regs->a3;\n#endif\n\t\tret = sbi_pmu_ctr_start(regs->a0, regs->a1, regs->a2, temp);\n\t\tbreak;\n\tcase SBI_EXT_PMU_COUNTER_STOP:\n\t\tret = sbi_pmu_ctr_stop(regs->a0, regs->a1, regs->a2);\n\t\tbreak;\n\tdefault:\n\t\tret = SBI_ENOTSUPP;\n\t};\n\n\treturn ret;\n}\n\nstatic int sbi_ecall_pmu_probe(unsigned long extid, unsigned long *out_val)\n{\n\t/* PMU extension is always enabled */\n\t*out_val = 1;\n\treturn 0;\n}\n\nstruct sbi_ecall_extension ecall_pmu = {\n\t.extid_start = SBI_EXT_PMU,\n\t.extid_end = SBI_EXT_PMU,\n\t.handle = sbi_ecall_pmu_handler,\n\t.probe = sbi_ecall_pmu_probe,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_rfence.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_tlb.h>\n\nstatic int sbi_ecall_rfence_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t    const struct sbi_trap_regs *regs,\n\t\t\t\t    unsigned long *out_val,\n\t\t\t\t    struct sbi_trap_info *out_trap)\n{\n\tint ret = 0;\n\tunsigned long vmid;\n\tstruct sbi_tlb_info tlb_info;\n\tu32 source_hart = current_hartid();\n\n\tif (funcid >= SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID &&\n\t    funcid <= SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA)\n\t\tif (!misa_extension('H'))\n\t\t\treturn SBI_ENOTSUPP;\n\n\tswitch (funcid) {\n\tcase SBI_EXT_RFENCE_REMOTE_FENCE_I:\n\t\tSBI_TLB_INFO_INIT(&tlb_info, 0, 0, 0, 0,\n\t\t\t\t  sbi_tlb_local_fence_i, source_hart);\n\t\tret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info);\n\t\tbreak;\n\tcase SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA:\n\t\tSBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, 0, 0,\n\t\t\t\t  sbi_tlb_local_hfence_gvma, source_hart);\n\t\tret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info);\n\t\tbreak;\n\tcase SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID:\n\t\tSBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, 0, regs->a4,\n\t\t\t\t  sbi_tlb_local_hfence_gvma_vmid,\n\t\t\t\t  source_hart);\n\t\tret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info);\n\t\tbreak;\n\tcase SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA:\n\t\tvmid = (csr_read(CSR_HGATP) & HGATP_VMID_MASK);\n\t\tvmid = vmid >> HGATP_VMID_SHIFT;\n\t\tSBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, 0, vmid,\n\t\t\t\t  sbi_tlb_local_hfence_vvma, source_hart);\n\t\tret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info);\n\t\tbreak;\n\tcase SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID:\n\t\tvmid = (csr_read(CSR_HGATP) & HGATP_VMID_MASK);\n\t\tvmid = vmid >> HGATP_VMID_SHIFT;\n\t\tSBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, regs->a4,\n\t\t\t\t  vmid, sbi_tlb_local_hfence_vvma_asid,\n\t\t\t\t  source_hart);\n\t\tret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info);\n\t\tbreak;\n\tcase SBI_EXT_RFENCE_REMOTE_SFENCE_VMA:\n\t\tSBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, 0, 0,\n\t\t\t\t  sbi_tlb_local_sfence_vma, source_hart);\n\t\tret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info);\n\t\tbreak;\n\tcase SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID:\n\t\tSBI_TLB_INFO_INIT(&tlb_info, regs->a2, regs->a3, regs->a4, 0,\n\t\t\t\t  sbi_tlb_local_sfence_vma_asid, source_hart);\n\t\tret = sbi_tlb_request(regs->a0, regs->a1, &tlb_info);\n\t\tbreak;\n\tdefault:\n\t\tret = SBI_ENOTSUPP;\n\t};\n\n\treturn ret;\n}\n\nstruct sbi_ecall_extension ecall_rfence = {\n\t.extid_start = SBI_EXT_RFENCE,\n\t.extid_end = SBI_EXT_RFENCE,\n\t.handle = sbi_ecall_rfence_handler,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_srst.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_system.h>\n\nstatic int sbi_ecall_srst_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t  const struct sbi_trap_regs *regs,\n\t\t\t\t  unsigned long *out_val,\n\t\t\t\t  struct sbi_trap_info *out_trap)\n{\n\tif (funcid == SBI_EXT_SRST_RESET) {\n\t\tif ((((u32)-1U) <= ((u64)regs->a0)) ||\n\t\t    (((u32)-1U) <= ((u64)regs->a1)))\n\t\t\treturn SBI_EINVAL;\n\n\t\tswitch (regs->a0) {\n\t\tcase SBI_SRST_RESET_TYPE_SHUTDOWN:\n\t\tcase SBI_SRST_RESET_TYPE_COLD_REBOOT:\n\t\tcase SBI_SRST_RESET_TYPE_WARM_REBOOT:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn SBI_EINVAL;\n\t\t}\n\n\t\tswitch (regs->a1) {\n\t\tcase SBI_SRST_RESET_REASON_NONE:\n\t\tcase SBI_SRST_RESET_REASON_SYSFAIL:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn SBI_EINVAL;\n\t\t}\n\n\t\tif (sbi_system_reset_supported(regs->a0, regs->a1))\n\t\t\tsbi_system_reset(regs->a0, regs->a1);\n\t}\n\n\treturn SBI_ENOTSUPP;\n}\n\nstatic int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val)\n{\n\tu32 type, count = 0;\n\n\t/*\n\t * At least one standard reset types should be supported by\n\t * the platform for SBI SRST extension to be usable.\n\t */\n\n\tfor (type = 0; type <= SBI_SRST_RESET_TYPE_LAST; type++) {\n\t\tif (sbi_system_reset_supported(type,\n\t\t\t\t\tSBI_SRST_RESET_REASON_NONE))\n\t\t\tcount++;\n\t}\n\n\t*out_val = (count) ? 1 : 0;\n\treturn 0;\n}\n\nstruct sbi_ecall_extension ecall_srst = {\n\t.extid_start = SBI_EXT_SRST,\n\t.extid_end = SBI_EXT_SRST,\n\t.handle = sbi_ecall_srst_handler,\n\t.probe = sbi_ecall_srst_probe,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_time.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_timer.h>\n\nstatic int sbi_ecall_time_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t  const struct sbi_trap_regs *regs,\n\t\t\t\t  unsigned long *out_val,\n\t\t\t\t  struct sbi_trap_info *out_trap)\n{\n\tint ret = 0;\n\n\tif (funcid == SBI_EXT_TIME_SET_TIMER) {\n#if __riscv_xlen == 32\n\t\tsbi_timer_event_start((((u64)regs->a1 << 32) | (u64)regs->a0));\n#else\n\t\tsbi_timer_event_start((u64)regs->a0);\n#endif\n\t} else\n\t\tret = SBI_ENOTSUPP;\n\n\treturn ret;\n}\n\nstruct sbi_ecall_extension ecall_time = {\n\t.extid_start = SBI_EXT_TIME,\n\t.extid_end = SBI_EXT_TIME,\n\t.handle = sbi_ecall_time_handler,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ecall_vendor.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_trap.h>\n\nstatic int sbi_ecall_vendor_probe(unsigned long extid,\n\t\t\t\t  unsigned long *out_val)\n{\n\t*out_val = sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr(),\n\t\t\t\t\t\t extid);\n\treturn 0;\n}\n\nstatic int sbi_ecall_vendor_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t    const struct sbi_trap_regs *regs,\n\t\t\t\t    unsigned long *out_val,\n\t\t\t\t    struct sbi_trap_info *out_trap)\n{\n\treturn sbi_platform_vendor_ext_provider(sbi_platform_thishart_ptr(),\n\t\t\t\t\t\textid, funcid, regs,\n\t\t\t\t\t\tout_val, out_trap);\n}\n\nstruct sbi_ecall_extension ecall_vendor = {\n\t.extid_start = SBI_EXT_VENDOR_START,\n\t.extid_end = SBI_EXT_VENDOR_END,\n\t.probe = sbi_ecall_vendor_probe,\n\t.handle = sbi_ecall_vendor_handler,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_emulate_csr.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_emulate_csr.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_timer.h>\n#include <sbi/sbi_trap.h>\n\nstatic bool hpm_allowed(int hpm_num, ulong prev_mode, bool virt)\n{\n\tulong cen = -1UL;\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\n\tif (prev_mode <= PRV_S) {\n\t\tif (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_10) {\n\t\t\tcen &= csr_read(CSR_MCOUNTEREN);\n\t\t\tif (virt)\n\t\t\t\tcen &= csr_read(CSR_HCOUNTEREN);\n\t\t} else {\n\t\t\tcen = 0;\n\t\t}\n\t}\n\tif (prev_mode == PRV_U) {\n\t\tif (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_10)\n\t\t\tcen &= csr_read(CSR_SCOUNTEREN);\n\t\telse\n\t\t\tcen = 0;\n\t}\n\n\treturn ((cen >> hpm_num) & 1) ? TRUE : FALSE;\n}\n\nint sbi_emulate_csr_read(int csr_num, struct sbi_trap_regs *regs,\n\t\t\t ulong *csr_val)\n{\n\tint ret = 0;\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\tulong prev_mode = (regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT;\n#if __riscv_xlen == 32\n\tbool virt = (regs->mstatusH & MSTATUSH_MPV) ? TRUE : FALSE;\n#else\n\tbool virt = (regs->mstatus & MSTATUS_MPV) ? TRUE : FALSE;\n#endif\n\n\tswitch (csr_num) {\n\tcase CSR_HTIMEDELTA:\n\t\tif (prev_mode == PRV_S && !virt)\n\t\t\t*csr_val = sbi_timer_get_delta();\n\t\telse\n\t\t\tret = SBI_ENOTSUPP;\n\t\tbreak;\n\tcase CSR_CYCLE:\n\t\tif (!hpm_allowed(csr_num - CSR_CYCLE, prev_mode, virt))\n\t\t\treturn SBI_ENOTSUPP;\n\t\t*csr_val = csr_read(CSR_MCYCLE);\n\t\tbreak;\n\tcase CSR_TIME:\n\t\t/*\n\t\t * We emulate TIME CSR for both Host (HS/U-mode) and\n\t\t * Guest (VS/VU-mode).\n\t\t *\n\t\t * Faster TIME CSR reads are critical for good performance\n\t\t * in S-mode software so we don't check CSR permissions.\n\t\t */\n\t\t*csr_val = (virt) ? sbi_timer_virt_value():\n\t\t\t\t    sbi_timer_value();\n\t\tbreak;\n\tcase CSR_INSTRET:\n\t\tif (!hpm_allowed(csr_num - CSR_CYCLE, prev_mode, virt))\n\t\t\treturn SBI_ENOTSUPP;\n\t\t*csr_val = csr_read(CSR_MINSTRET);\n\t\tbreak;\n\n#if __riscv_xlen == 32\n\tcase CSR_HTIMEDELTAH:\n\t\tif (prev_mode == PRV_S && !virt)\n\t\t\t*csr_val = sbi_timer_get_delta() >> 32;\n\t\telse\n\t\t\tret = SBI_ENOTSUPP;\n\t\tbreak;\n\tcase CSR_CYCLEH:\n\t\tif (!hpm_allowed(csr_num - CSR_CYCLEH, prev_mode, virt))\n\t\t\treturn SBI_ENOTSUPP;\n\t\t*csr_val = csr_read(CSR_MCYCLEH);\n\t\tbreak;\n\tcase CSR_TIMEH:\n\t\t/* Refer comments on TIME CSR above. */\n\t\t*csr_val = (virt) ? sbi_timer_virt_value() >> 32:\n\t\t\t\t    sbi_timer_value() >> 32;\n\t\tbreak;\n\tcase CSR_INSTRETH:\n\t\tif (!hpm_allowed(csr_num - CSR_CYCLEH, prev_mode, virt))\n\t\t\treturn SBI_ENOTSUPP;\n\t\t*csr_val = csr_read(CSR_MINSTRETH);\n\t\tbreak;\n#endif\n\n#define switchcase_hpm(__uref, __mref, __csr)\t\t\t\t\\\n\tcase __csr:\t\t\t\t\t\t\t\\\n\t\tif ((sbi_hart_mhpm_count(scratch) + 3) <= (__csr - __uref))\\\n\t\t\treturn SBI_ENOTSUPP;\t\t\t\t\\\n\t\tif (!hpm_allowed(__csr - __uref, prev_mode, virt))\t\\\n\t\t\treturn SBI_ENOTSUPP;\t\t\t\t\\\n\t\t*csr_val = csr_read(__mref + __csr - __uref);\t\t\\\n\t\tbreak;\n#define switchcase_hpm_2(__uref, __mref, __csr)\t\t\t\\\n\tswitchcase_hpm(__uref, __mref, __csr + 0)\t\t\t\\\n\tswitchcase_hpm(__uref, __mref, __csr + 1)\n#define switchcase_hpm_4(__uref, __mref, __csr)\t\t\t\\\n\tswitchcase_hpm_2(__uref, __mref, __csr + 0)\t\t\t\\\n\tswitchcase_hpm_2(__uref, __mref, __csr + 2)\n#define switchcase_hpm_8(__uref, __mref, __csr)\t\t\t\\\n\tswitchcase_hpm_4(__uref, __mref, __csr + 0)\t\t\t\\\n\tswitchcase_hpm_4(__uref, __mref, __csr + 4)\n#define switchcase_hpm_16(__uref, __mref, __csr)\t\t\t\\\n\tswitchcase_hpm_8(__uref, __mref, __csr + 0)\t\t\t\\\n\tswitchcase_hpm_8(__uref, __mref, __csr + 8)\n\n\tswitchcase_hpm(CSR_CYCLE, CSR_MCYCLE, CSR_HPMCOUNTER3)\n\tswitchcase_hpm_4(CSR_CYCLE, CSR_MCYCLE, CSR_HPMCOUNTER4)\n\tswitchcase_hpm_8(CSR_CYCLE, CSR_MCYCLE, CSR_HPMCOUNTER8)\n\tswitchcase_hpm_16(CSR_CYCLE, CSR_MCYCLE, CSR_HPMCOUNTER16)\n\n#if __riscv_xlen == 32\n\tswitchcase_hpm(CSR_CYCLEH, CSR_MCYCLEH, CSR_HPMCOUNTER3H)\n\tswitchcase_hpm_4(CSR_CYCLEH, CSR_MCYCLEH, CSR_HPMCOUNTER4H)\n\tswitchcase_hpm_8(CSR_CYCLEH, CSR_MCYCLEH, CSR_HPMCOUNTER8H)\n\tswitchcase_hpm_16(CSR_CYCLEH, CSR_MCYCLEH, CSR_HPMCOUNTER16H)\n#endif\n\n#undef switchcase_hpm_16\n#undef switchcase_hpm_8\n#undef switchcase_hpm_4\n#undef switchcase_hpm_2\n#undef switchcase_hpm\n\n\tdefault:\n\t\tret = SBI_ENOTSUPP;\n\t\tbreak;\n\t};\n\n\tif (ret)\n\t\tsbi_dprintf(\"%s: hartid%d: invalid csr_num=0x%x\\n\",\n\t\t\t    __func__, current_hartid(), csr_num);\n\n\treturn ret;\n}\n\nint sbi_emulate_csr_write(int csr_num, struct sbi_trap_regs *regs,\n\t\t\t  ulong csr_val)\n{\n\tint ret = 0;\n\tulong prev_mode = (regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT;\n#if __riscv_xlen == 32\n\tbool virt = (regs->mstatusH & MSTATUSH_MPV) ? TRUE : FALSE;\n#else\n\tbool virt = (regs->mstatus & MSTATUS_MPV) ? TRUE : FALSE;\n#endif\n\n\tswitch (csr_num) {\n\tcase CSR_HTIMEDELTA:\n\t\tif (prev_mode == PRV_S && !virt)\n\t\t\tsbi_timer_set_delta(csr_val);\n\t\telse\n\t\t\tret = SBI_ENOTSUPP;\n\t\tbreak;\n#if __riscv_xlen == 32\n\tcase CSR_HTIMEDELTAH:\n\t\tif (prev_mode == PRV_S && !virt)\n\t\t\tsbi_timer_set_delta_upper(csr_val);\n\t\telse\n\t\t\tret = SBI_ENOTSUPP;\n\t\tbreak;\n#endif\n\tdefault:\n\t\tret = SBI_ENOTSUPP;\n\t\tbreak;\n\t};\n\n\tif (ret)\n\t\tsbi_dprintf(\"%s: hartid%d: invalid csr_num=0x%x\\n\",\n\t\t\t    __func__, current_hartid(), csr_num);\n\n\treturn ret;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_expected_trap.S",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_trap.h>\n\n\t/*\n\t * We assume that faulting instruction is 4-byte long and blindly\n\t * increment SEPC by 4.\n\t *\n\t * The trap info will be saved as follows:\n\t * A3 <- pointer struct sbi_trap_info\n\t * A4 <- temporary\n\t */\n\n\t.align 3\n\t.global __sbi_expected_trap\n__sbi_expected_trap:\n\t/* Without H-extension so, MTVAL2 and MTINST CSRs and GVA not available */\n\tcsrr\ta4, CSR_MEPC\n\tREG_S\ta4, SBI_TRAP_INFO_OFFSET(epc)(a3)\n\tcsrr\ta4, CSR_MCAUSE\n\tREG_S\ta4, SBI_TRAP_INFO_OFFSET(cause)(a3)\n\tcsrr\ta4, CSR_MTVAL\n\tREG_S\ta4, SBI_TRAP_INFO_OFFSET(tval)(a3)\n\tREG_S\tzero, SBI_TRAP_INFO_OFFSET(tval2)(a3)\n\tREG_S\tzero, SBI_TRAP_INFO_OFFSET(tinst)(a3)\n\tREG_S\tzero, SBI_TRAP_INFO_OFFSET(gva)(a3)\n\tcsrr\ta4, CSR_MEPC\n\taddi\ta4, a4, 4\n\tcsrw\tCSR_MEPC, a4\n\tmret\n\n\t.align 3\n\t.global __sbi_expected_trap_hext\n__sbi_expected_trap_hext:\n\t/* With H-extension so, MTVAL2 and MTINST CSRs and GVA available */\n\tcsrr\ta4, CSR_MEPC\n\tREG_S\ta4, SBI_TRAP_INFO_OFFSET(epc)(a3)\n\tcsrr\ta4, CSR_MCAUSE\n\tREG_S\ta4, SBI_TRAP_INFO_OFFSET(cause)(a3)\n\tcsrr\ta4, CSR_MTVAL\n\tREG_S\ta4, SBI_TRAP_INFO_OFFSET(tval)(a3)\n\tcsrr\ta4, CSR_MTVAL2\n\tREG_S\ta4, SBI_TRAP_INFO_OFFSET(tval2)(a3)\n\tcsrr\ta4, CSR_MTINST\n\tREG_S\ta4, SBI_TRAP_INFO_OFFSET(tinst)(a3)\n\n\t/* Extract GVA bit from MSTATUS or MSTATUSH */\n#if __riscv_xlen == 32\n\tcsrr\ta4, CSR_MSTATUSH\n\tsrli\ta4, a4, MSTATUSH_GVA_SHIFT\n#else\n\tcsrr\ta4, CSR_MSTATUS\n\tsrli\ta4, a4, MSTATUS_GVA_SHIFT\n#endif\n\tandi\ta4, a4, 1\n\tREG_S\ta4, SBI_TRAP_INFO_OFFSET(gva)(a3)\n\n\tcsrr\ta4, CSR_MEPC\n\taddi\ta4, a4, 4\n\tcsrw\tCSR_MEPC, a4\n\tmret\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_fifo.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra<atish.patra@wdc.com>\n *\n */\n#include <sbi/riscv_locks.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_fifo.h>\n#include <sbi/sbi_string.h>\n\nvoid sbi_fifo_init(struct sbi_fifo *fifo, void *queue_mem, u16 entries,\n\t\t   u16 entry_size)\n{\n\tfifo->queue\t  = queue_mem;\n\tfifo->num_entries = entries;\n\tfifo->entry_size  = entry_size;\n\tSPIN_LOCK_INIT(fifo->qlock);\n\tfifo->avail = fifo->tail = 0;\n\tsbi_memset(fifo->queue, 0, (size_t)entries * entry_size);\n}\n\n/* Note: must be called with fifo->qlock held */\nstatic inline bool __sbi_fifo_is_full(struct sbi_fifo *fifo)\n{\n\treturn (fifo->avail == fifo->num_entries) ? TRUE : FALSE;\n}\n\nu16 sbi_fifo_avail(struct sbi_fifo *fifo)\n{\n\tu16 ret;\n\n\tif (!fifo)\n\t\treturn 0;\n\n\tspin_lock(&fifo->qlock);\n\tret = fifo->avail;\n\tspin_unlock(&fifo->qlock);\n\n\treturn ret;\n}\n\nint sbi_fifo_is_full(struct sbi_fifo *fifo)\n{\n\tbool ret;\n\n\tif (!fifo)\n\t\treturn SBI_EINVAL;\n\n\tspin_lock(&fifo->qlock);\n\tret = __sbi_fifo_is_full(fifo);\n\tspin_unlock(&fifo->qlock);\n\n\treturn ret;\n}\n\n/* Note: must be called with fifo->qlock held */\nstatic inline void  __sbi_fifo_enqueue(struct sbi_fifo *fifo, void *data)\n{\n\tu32 head;\n\n\thead = (u32)fifo->tail + fifo->avail;\n\tif (head >= fifo->num_entries)\n\t\thead = head - fifo->num_entries;\n\n\tsbi_memcpy((char *)fifo->queue + head * fifo->entry_size, data, fifo->entry_size);\n\n\tfifo->avail++;\n}\n\n\n/* Note: must be called with fifo->qlock held */\nstatic inline bool __sbi_fifo_is_empty(struct sbi_fifo *fifo)\n{\n\treturn (fifo->avail == 0) ? TRUE : FALSE;\n}\n\nint sbi_fifo_is_empty(struct sbi_fifo *fifo)\n{\n\tbool ret;\n\n\tif (!fifo)\n\t\treturn SBI_EINVAL;\n\n\tspin_lock(&fifo->qlock);\n\tret = __sbi_fifo_is_empty(fifo);\n\tspin_unlock(&fifo->qlock);\n\n\treturn ret;\n}\n\n/* Note: must be called with fifo->qlock held */\nstatic inline void __sbi_fifo_reset(struct sbi_fifo *fifo)\n{\n\tsize_t size = (size_t)fifo->num_entries * fifo->entry_size;\n\n\tfifo->avail = 0;\n\tfifo->tail  = 0;\n\tsbi_memset(fifo->queue, 0, size);\n}\n\nbool sbi_fifo_reset(struct sbi_fifo *fifo)\n{\n\tif (!fifo)\n\t\treturn FALSE;\n\n\tspin_lock(&fifo->qlock);\n\t__sbi_fifo_reset(fifo);\n\tspin_unlock(&fifo->qlock);\n\n\treturn TRUE;\n}\n\n/**\n * Provide a helper function to do inplace update to the fifo.\n * Note: The callback function is called with lock being held.\n *\n * **Do not** invoke any other fifo function from callback. Otherwise, it will\n * lead to deadlock.\n */\nint sbi_fifo_inplace_update(struct sbi_fifo *fifo, void *in,\n\t\t\t    int (*fptr)(void *in, void *data))\n{\n\tint i, index;\n\tint ret = SBI_FIFO_UNCHANGED;\n\tvoid *entry;\n\n\tif (!fifo || !in)\n\t\treturn ret;\n\n\tspin_lock(&fifo->qlock);\n\n\tif (__sbi_fifo_is_empty(fifo)) {\n\t\tspin_unlock(&fifo->qlock);\n\t\treturn ret;\n\t}\n\n\tfor (i = 0; i < fifo->avail; i++) {\n\t\tindex = fifo->tail + i;\n\t\tif (index >= fifo->num_entries)\n\t\t\tindex -= fifo->num_entries;\n\t\tentry = (char *)fifo->queue + (u32)index * fifo->entry_size;\n\t\tret = fptr(in, entry);\n\n\t\tif (ret == SBI_FIFO_SKIP || ret == SBI_FIFO_UPDATED) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tspin_unlock(&fifo->qlock);\n\n\treturn ret;\n}\n\nint sbi_fifo_enqueue(struct sbi_fifo *fifo, void *data)\n{\n\tif (!fifo || !data)\n\t\treturn SBI_EINVAL;\n\n\tspin_lock(&fifo->qlock);\n\n\tif (__sbi_fifo_is_full(fifo)) {\n\t\tspin_unlock(&fifo->qlock);\n\t\treturn SBI_ENOSPC;\n\t}\n\t__sbi_fifo_enqueue(fifo, data);\n\n\tspin_unlock(&fifo->qlock);\n\n\treturn 0;\n}\n\nint sbi_fifo_dequeue(struct sbi_fifo *fifo, void *data)\n{\n\tif (!fifo || !data)\n\t\treturn SBI_EINVAL;\n\n\tspin_lock(&fifo->qlock);\n\n\tif (__sbi_fifo_is_empty(fifo)) {\n\t\tspin_unlock(&fifo->qlock);\n\t\treturn SBI_ENOENT;\n\t}\n\n\tsbi_memcpy(data, (char *)fifo->queue + (u32)fifo->tail * fifo->entry_size,\n\t       fifo->entry_size);\n\n\tfifo->avail--;\n\tfifo->tail++;\n\tif (fifo->tail >= fifo->num_entries)\n\t\tfifo->tail = 0;\n\n\tspin_unlock(&fifo->qlock);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_hart.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_barrier.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/riscv_fp.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_csr_detect.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_math.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi/sbi_string.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_hfence.h>\n\nextern void __sbi_expected_trap(void);\nextern void __sbi_expected_trap_hext(void);\n\nvoid (*sbi_hart_expected_trap)(void) = &__sbi_expected_trap;\n\nstatic unsigned long hart_features_offset;\n\nstatic void mstatus_init(struct sbi_scratch *scratch)\n{\n\tunsigned long menvcfg_val, mstatus_val = 0;\n\tint cidx;\n\tunsigned int num_mhpm = sbi_hart_mhpm_count(scratch);\n\tuint64_t mhpmevent_init_val = 0;\n\tuint64_t mstateen_val;\n\n\t/* Enable FPU */\n\tif (misa_extension('D') || misa_extension('F'))\n\t\tmstatus_val |=  MSTATUS_FS;\n\n\t/* Enable Vector context */\n\tif (misa_extension('V'))\n\t\tmstatus_val |=  MSTATUS_VS;\n\n\tcsr_write(CSR_MSTATUS, mstatus_val);\n\n\t/* Disable user mode usage of all perf counters except default ones (CY, TM, IR) */\n\tif (misa_extension('S') &&\n\t    sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_10)\n\t\tcsr_write(CSR_SCOUNTEREN, 7);\n\n\t/**\n\t * OpenSBI doesn't use any PMU counters in M-mode.\n\t * Supervisor mode usage for all counters are enabled by default\n\t * But counters will not run until mcountinhibit is set.\n\t */\n\tif (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_10)\n\t\tcsr_write(CSR_MCOUNTEREN, -1);\n\n\t/* All programmable counters will start running at runtime after S-mode request */\n\tif (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_11)\n\t\tcsr_write(CSR_MCOUNTINHIBIT, 0xFFFFFFF8);\n\n\t/**\n\t * The mhpmeventn[h] CSR should be initialized with interrupt disabled\n\t * and inhibited running in M-mode during init.\n\t * To keep it simple, only contiguous mhpmcounters are supported as a\n\t * platform with discontiguous mhpmcounters may not make much sense.\n\t */\n\tmhpmevent_init_val |= (MHPMEVENT_OF | MHPMEVENT_MINH);\n\tfor (cidx = 0; cidx < num_mhpm; cidx++) {\n#if __riscv_xlen == 32\n\t\tcsr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val & 0xFFFFFFFF);\n\t\tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))\n\t\t\tcsr_write_num(CSR_MHPMEVENT3H + cidx,\n\t\t\t\t      mhpmevent_init_val >> BITS_PER_LONG);\n#else\n\t\tcsr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val);\n#endif\n\t}\n\n\tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMSTATEEN)) {\n\t\tmstateen_val = csr_read(CSR_MSTATEEN0);\n#if __riscv_xlen == 32\n\t\tmstateen_val |= ((uint64_t)csr_read(CSR_MSTATEEN0H)) << 32;\n#endif\n\t\tmstateen_val |= SMSTATEEN_STATEN;\n\t\tmstateen_val |= SMSTATEEN0_HSENVCFG;\n\n\t\tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMAIA))\n\t\t\tmstateen_val |= (SMSTATEEN0_AIA | SMSTATEEN0_SVSLCT |\n\t\t\t\t\tSMSTATEEN0_IMSIC);\n\t\telse\n\t\t\tmstateen_val &= ~(SMSTATEEN0_AIA | SMSTATEEN0_SVSLCT |\n\t\t\t\t\tSMSTATEEN0_IMSIC);\n\t\tcsr_write(CSR_MSTATEEN0, mstateen_val);\n#if __riscv_xlen == 32\n\t\tcsr_write(CSR_MSTATEEN0H, mstateen_val >> 32);\n#endif\n\t}\n\n\tif (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_12) {\n\t\tmenvcfg_val = csr_read(CSR_MENVCFG);\n\n\t\t/*\n\t\t * Set menvcfg.CBZE == 1\n\t\t *\n\t\t * If Zicboz extension is not available then writes to\n\t\t * menvcfg.CBZE will be ignored because it is a WARL field.\n\t\t */\n\t\tmenvcfg_val |= ENVCFG_CBZE;\n\n\t\t/*\n\t\t * Set menvcfg.CBCFE == 1\n\t\t *\n\t\t * If Zicbom extension is not available then writes to\n\t\t * menvcfg.CBCFE will be ignored because it is a WARL field.\n\t\t */\n\t\tmenvcfg_val |= ENVCFG_CBCFE;\n\n\t\t/*\n\t\t * Set menvcfg.CBIE == 3\n\t\t *\n\t\t * If Zicbom extension is not available then writes to\n\t\t * menvcfg.CBIE will be ignored because it is a WARL field.\n\t\t */\n\t\tmenvcfg_val |= ENVCFG_CBIE_INV << ENVCFG_CBIE_SHIFT;\n\n\t\t/*\n\t\t * Set menvcfg.PBMTE == 1 for RV64 or RV128\n\t\t *\n\t\t * If Svpbmt extension is not available then menvcfg.PBMTE\n\t\t * will be read-only zero.\n\t\t */\n#if __riscv_xlen > 32\n\t\tmenvcfg_val |= ENVCFG_PBMTE;\n#endif\n\n\t\t/*\n\t\t * The spec doesn't explicitly describe the reset value of menvcfg.\n\t\t * Enable access to stimecmp if sstc extension is present in the\n\t\t * hardware.\n\t\t */\n\t\tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSTC)) {\n#if __riscv_xlen == 32\n\t\t\tunsigned long menvcfgh_val;\n\t\t\tmenvcfgh_val = csr_read(CSR_MENVCFGH);\n\t\t\tmenvcfgh_val |= ENVCFGH_STCE;\n\t\t\tcsr_write(CSR_MENVCFGH, menvcfgh_val);\n#else\n\t\t\tmenvcfg_val |= ENVCFG_STCE;\n#endif\n\t\t}\n\n\t\tcsr_write(CSR_MENVCFG, menvcfg_val);\n\t}\n\n\t/* Disable all interrupts */\n\tcsr_write(CSR_MIE, 0);\n\n\t/* Disable S-mode paging */\n\tif (misa_extension('S'))\n\t\tcsr_write(CSR_SATP, 0);\n}\n\nstatic int fp_init(struct sbi_scratch *scratch)\n{\n#ifdef __riscv_flen\n\tint i;\n#endif\n\n\tif (!misa_extension('D') && !misa_extension('F'))\n\t\treturn 0;\n\n\tif (!(csr_read(CSR_MSTATUS) & MSTATUS_FS))\n\t\treturn SBI_EINVAL;\n\n#ifdef __riscv_flen\n\tfor (i = 0; i < 32; i++)\n\t\tinit_fp_reg(i);\n\tcsr_write(CSR_FCSR, 0);\n#endif\n\n\treturn 0;\n}\n\nstatic int delegate_traps(struct sbi_scratch *scratch)\n{\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\tunsigned long interrupts, exceptions;\n\n\tif (!misa_extension('S'))\n\t\t/* No delegation possible as mideleg does not exist */\n\t\treturn 0;\n\n\t/* Send M-mode interrupts and most exceptions to S-mode */\n\tinterrupts = MIP_SSIP | MIP_STIP | MIP_SEIP;\n\tinterrupts |= sbi_pmu_irq_bit();\n\n\texceptions = (1U << CAUSE_MISALIGNED_FETCH) | (1U << CAUSE_BREAKPOINT) |\n\t\t     (1U << CAUSE_USER_ECALL);\n\tif (sbi_platform_has_mfaults_delegation(plat))\n\t\texceptions |= (1U << CAUSE_FETCH_PAGE_FAULT) |\n\t\t\t      (1U << CAUSE_LOAD_PAGE_FAULT) |\n\t\t\t      (1U << CAUSE_STORE_PAGE_FAULT);\n\n\t/*\n\t * If hypervisor extension available then we only handle hypervisor\n\t * calls (i.e. ecalls from HS-mode) in M-mode.\n\t *\n\t * The HS-mode will additionally handle supervisor calls (i.e. ecalls\n\t * from VS-mode), Guest page faults and Virtual interrupts.\n\t */\n\tif (misa_extension('H')) {\n\t\texceptions |= (1U << CAUSE_VIRTUAL_SUPERVISOR_ECALL);\n\t\texceptions |= (1U << CAUSE_FETCH_GUEST_PAGE_FAULT);\n\t\texceptions |= (1U << CAUSE_LOAD_GUEST_PAGE_FAULT);\n\t\texceptions |= (1U << CAUSE_VIRTUAL_INST_FAULT);\n\t\texceptions |= (1U << CAUSE_STORE_GUEST_PAGE_FAULT);\n\t}\n\n\tcsr_write(CSR_MIDELEG, interrupts);\n\tcsr_write(CSR_MEDELEG, exceptions);\n\n\treturn 0;\n}\n\nvoid sbi_hart_delegation_dump(struct sbi_scratch *scratch,\n\t\t\t      const char *prefix, const char *suffix)\n{\n\tif (!misa_extension('S'))\n\t\t/* No delegation possible as mideleg does not exist*/\n\t\treturn;\n\n\tsbi_printf(\"%sMIDELEG%s: 0x%\" PRILX \"\\n\",\n\t\t   prefix, suffix, csr_read(CSR_MIDELEG));\n\tsbi_printf(\"%sMEDELEG%s: 0x%\" PRILX \"\\n\",\n\t\t   prefix, suffix, csr_read(CSR_MEDELEG));\n}\n\nunsigned int sbi_hart_mhpm_count(struct sbi_scratch *scratch)\n{\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\n\treturn hfeatures->mhpm_count;\n}\n\nunsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch)\n{\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\n\treturn hfeatures->pmp_count;\n}\n\nunsigned long sbi_hart_pmp_granularity(struct sbi_scratch *scratch)\n{\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\n\treturn hfeatures->pmp_gran;\n}\n\nunsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch)\n{\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\n\treturn hfeatures->pmp_addr_bits;\n}\n\nunsigned int sbi_hart_mhpm_bits(struct sbi_scratch *scratch)\n{\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\n\treturn hfeatures->mhpm_bits;\n}\n\nint sbi_hart_pmp_configure(struct sbi_scratch *scratch)\n{\n\tstruct sbi_domain_memregion *reg;\n\tstruct sbi_domain *dom = sbi_domain_thishart_ptr();\n\tunsigned int pmp_idx = 0, pmp_flags, pmp_bits, pmp_gran_log2;\n\tunsigned int pmp_count = sbi_hart_pmp_count(scratch);\n\tunsigned long pmp_addr = 0, pmp_addr_max = 0;\n\n\tif (!pmp_count)\n\t\treturn 0;\n\n\tpmp_gran_log2 = log2roundup(sbi_hart_pmp_granularity(scratch));\n\tpmp_bits = sbi_hart_pmp_addrbits(scratch) - 1;\n\tpmp_addr_max = (1UL << pmp_bits) | ((1UL << pmp_bits) - 1);\n\n\tsbi_domain_for_each_memregion(dom, reg) {\n\t\tif (pmp_count <= pmp_idx)\n\t\t\tbreak;\n\n\t\tpmp_flags = 0;\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_READABLE)\n\t\t\tpmp_flags |= PMP_R;\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_WRITEABLE)\n\t\t\tpmp_flags |= PMP_W;\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_EXECUTABLE)\n\t\t\tpmp_flags |= PMP_X;\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_MMODE)\n\t\t\tpmp_flags |= PMP_L;\n\n\t\tpmp_addr =  reg->base >> PMP_SHIFT;\n\t\tif (pmp_gran_log2 <= reg->order && pmp_addr < pmp_addr_max)\n\t\t\tpmp_set(pmp_idx++, pmp_flags, reg->base, reg->order);\n\t\telse {\n\t\t\tsbi_printf(\"Can not configure pmp for domain %s\", dom->name);\n\t\t\tsbi_printf(\" because memory region address %lx or size %lx is not in range\\n\",\n\t\t\t\t    reg->base, reg->order);\n\t\t}\n\t}\n\n\t/*\n\t * As per section 3.7.2 of privileged specification v1.12,\n\t * virtual address translations can be speculatively performed\n\t * (even before actual access). These, along with PMP traslations,\n\t * can be cached. This can pose a problem with CPU hotplug\n\t * and non-retentive suspend scenario because PMP states are\n\t * not preserved.\n\t * It is advisable to flush the caching structures under such\n\t * conditions.\n\t */\n\tif (misa_extension('S')) {\n\t\t__asm__ __volatile__(\"sfence.vma\");\n\n\t\t/*\n\t\t * If hypervisor mode is supported, flush caching\n\t\t * structures in guest mode too.\n\t\t */\n\t\tif (misa_extension('H'))\n\t\t\t__sbi_hfence_gvma_all();\n\t}\n\n\treturn 0;\n}\n\nint sbi_hart_priv_version(struct sbi_scratch *scratch)\n{\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\n\treturn hfeatures->priv_version;\n}\n\nvoid sbi_hart_get_priv_version_str(struct sbi_scratch *scratch,\n\t\t\t\t   char *version_str, int nvstr)\n{\n\tchar *temp;\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\n\tswitch (hfeatures->priv_version) {\n\tcase SBI_HART_PRIV_VER_1_10:\n\t\ttemp = \"v1.10\";\n\t\tbreak;\n\tcase SBI_HART_PRIV_VER_1_11:\n\t\ttemp = \"v1.11\";\n\t\tbreak;\n\tcase SBI_HART_PRIV_VER_1_12:\n\t\ttemp = \"v1.12\";\n\t\tbreak;\n\tdefault:\n\t\ttemp = \"unknown\";\n\t\tbreak;\n\t}\n\n\tsbi_snprintf(version_str, nvstr, \"%s\", temp);\n}\n\nstatic inline void __sbi_hart_update_extension(\n\t\t\t\t\tstruct sbi_hart_features *hfeatures,\n\t\t\t\t\tenum sbi_hart_extensions ext,\n\t\t\t\t\tbool enable)\n{\n\tif (enable)\n\t\thfeatures->extensions |= BIT(ext);\n\telse\n\t\thfeatures->extensions &= ~BIT(ext);\n}\n\n/**\n * Enable/Disable a particular hart extension\n *\n * @param scratch pointer to the HART scratch space\n * @param ext the extension number to check\n * @param enable new state of hart extension\n */\nvoid sbi_hart_update_extension(struct sbi_scratch *scratch,\n\t\t\t       enum sbi_hart_extensions ext,\n\t\t\t       bool enable)\n{\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\n\t__sbi_hart_update_extension(hfeatures, ext, enable);\n}\n\n/**\n * Check whether a particular hart extension is available\n *\n * @param scratch pointer to the HART scratch space\n * @param ext the extension number to check\n * @returns true (available) or false (not available)\n */\nbool sbi_hart_has_extension(struct sbi_scratch *scratch,\n\t\t\t    enum sbi_hart_extensions ext)\n{\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\n\tif (hfeatures->extensions & BIT(ext))\n\t\treturn true;\n\telse\n\t\treturn false;\n}\n\nstatic inline char *sbi_hart_extension_id2string(int ext)\n{\n\tchar *estr = NULL;\n\n\tswitch (ext) {\n\tcase SBI_HART_EXT_SSCOFPMF:\n\t\testr = \"sscofpmf\";\n\t\tbreak;\n\tcase SBI_HART_EXT_TIME:\n\t\testr = \"time\";\n\t\tbreak;\n\tcase SBI_HART_EXT_SMAIA:\n\t\testr = \"smaia\";\n\t\tbreak;\n\tcase SBI_HART_EXT_SSTC:\n\t\testr = \"sstc\";\n\t\tbreak;\n\tcase SBI_HART_EXT_SMSTATEEN:\n\t\testr = \"smstateen\";\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn estr;\n}\n\n/**\n * Get the hart extensions in string format\n *\n * @param scratch pointer to the HART scratch space\n * @param extensions_str pointer to a char array where the extensions string\n *\t\t\t will be updated\n * @param nestr length of the features_str. The feature string will be\n *\t\ttruncated if nestr is not long enough.\n */\nvoid sbi_hart_get_extensions_str(struct sbi_scratch *scratch,\n\t\t\t\t char *extensions_str, int nestr)\n{\n\tstruct sbi_hart_features *hfeatures =\n\t\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\tint offset = 0, ext = 0;\n\tchar *temp;\n\n\tif (!extensions_str || nestr <= 0)\n\t\treturn;\n\tsbi_memset(extensions_str, 0, nestr);\n\n\tif (!hfeatures->extensions)\n\t\tgoto done;\n\n\tdo {\n\t\tif (hfeatures->extensions & BIT(ext)) {\n\t\t\ttemp = sbi_hart_extension_id2string(ext);\n\t\t\tif (temp) {\n\t\t\t\tsbi_snprintf(extensions_str + offset,\n\t\t\t\t\t     nestr - offset,\n\t\t\t\t\t     \"%s,\", temp);\n\t\t\t\toffset = offset + sbi_strlen(temp) + 1;\n\t\t\t}\n\t\t}\n\n\t\text++;\n\t} while (ext < SBI_HART_EXT_MAX);\n\ndone:\n\tif (offset)\n\t\textensions_str[offset - 1] = '\\0';\n\telse\n\t\tsbi_strncpy(extensions_str, \"none\", nestr);\n}\n\nstatic unsigned long hart_pmp_get_allowed_addr(void)\n{\n\tunsigned long val = 0;\n\tstruct sbi_trap_info trap = {0};\n\n\tcsr_write_allowed(CSR_PMPCFG0, (ulong)&trap, 0);\n\tif (trap.cause)\n\t\treturn 0;\n\n\tcsr_write_allowed(CSR_PMPADDR0, (ulong)&trap, PMP_ADDR_MASK);\n\tif (!trap.cause) {\n\t\tval = csr_read_allowed(CSR_PMPADDR0, (ulong)&trap);\n\t\tif (trap.cause)\n\t\t\tval = 0;\n\t}\n\n\treturn val;\n}\n\nstatic int hart_pmu_get_allowed_bits(void)\n{\n\tunsigned long val = ~(0UL);\n\tstruct sbi_trap_info trap = {0};\n\tint num_bits = 0;\n\n\t/**\n\t * It is assumed that platforms will implement same number of bits for\n\t * all the performance counters including mcycle/minstret.\n\t */\n\tcsr_write_allowed(CSR_MHPMCOUNTER3, (ulong)&trap, val);\n\tif (!trap.cause) {\n\t\tval = csr_read_allowed(CSR_MHPMCOUNTER3, (ulong)&trap);\n\t\tif (trap.cause)\n\t\t\treturn 0;\n\t}\n\tnum_bits = sbi_fls(val) + 1;\n#if __riscv_xlen == 32\n\tcsr_write_allowed(CSR_MHPMCOUNTER3H, (ulong)&trap, val);\n\tif (!trap.cause) {\n\t\tval = csr_read_allowed(CSR_MHPMCOUNTER3H, (ulong)&trap);\n\t\tif (trap.cause)\n\t\t\treturn num_bits;\n\t}\n\tnum_bits += sbi_fls(val) + 1;\n\n#endif\n\n\treturn num_bits;\n}\n\nstatic int hart_detect_features(struct sbi_scratch *scratch)\n{\n\tstruct sbi_trap_info trap = {0};\n\tstruct sbi_hart_features *hfeatures =\n\t\tsbi_scratch_offset_ptr(scratch, hart_features_offset);\n\tunsigned long val, oldval;\n\tint rc;\n\n\t/* If hart features already detected then do nothing */\n\tif (hfeatures->detected)\n\t\treturn 0;\n\n\t/* Clear hart features */\n\thfeatures->extensions = 0;\n\thfeatures->pmp_count = 0;\n\thfeatures->mhpm_count = 0;\n\n#define __check_csr(__csr, __rdonly, __wrval, __field, __skip)\t\\\n\toldval = csr_read_allowed(__csr, (ulong)&trap);\t\t\t\\\n\tif (!trap.cause) {\t\t\t\t\t\t\\\n\t\tif (__rdonly) {\t\t\t\t\t\t\\\n\t\t\t(hfeatures->__field)++;\t\t\t\t\\\n\t\t} else {\t\t\t\t\t\t\\\n\t\t\tcsr_write_allowed(__csr, (ulong)&trap, __wrval);\\\n\t\t\tif (!trap.cause) {\t\t\t\t\\\n\t\t\t\tif (csr_swap(__csr, oldval) == __wrval)\t\\\n\t\t\t\t\t(hfeatures->__field)++;\t\t\\\n\t\t\t\telse\t\t\t\t\t\\\n\t\t\t\t\tgoto __skip;\t\t\t\\\n\t\t\t} else {\t\t\t\t\t\\\n\t\t\t\tgoto __skip;\t\t\t\t\\\n\t\t\t}\t\t\t\t\t\t\\\n\t\t}\t\t\t\t\t\t\t\\\n\t} else {\t\t\t\t\t\t\t\\\n\t\tgoto __skip;\t\t\t\t\t\t\\\n\t}\n#define __check_csr_2(__csr, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr(__csr + 0, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr(__csr + 1, __rdonly, __wrval, __field, __skip)\n#define __check_csr_4(__csr, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_2(__csr + 0, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_2(__csr + 2, __rdonly, __wrval, __field, __skip)\n#define __check_csr_8(__csr, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_4(__csr + 0, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_4(__csr + 4, __rdonly, __wrval, __field, __skip)\n#define __check_csr_16(__csr, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_8(__csr + 0, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_8(__csr + 8, __rdonly, __wrval, __field, __skip)\n#define __check_csr_32(__csr, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_16(__csr + 0, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_16(__csr + 16, __rdonly, __wrval, __field, __skip)\n#define __check_csr_64(__csr, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_32(__csr + 0, __rdonly, __wrval, __field, __skip)\t\\\n\t__check_csr_32(__csr + 32, __rdonly, __wrval, __field, __skip)\n\n\t/**\n\t * Detect the allowed address bits & granularity. At least PMPADDR0\n\t * should be implemented.\n\t */\n\tval = hart_pmp_get_allowed_addr();\n\tif (val) {\n\t\thfeatures->pmp_gran =  1 << (sbi_ffs(val) + 2);\n\t\thfeatures->pmp_addr_bits = sbi_fls(val) + 1;\n\t\t/* Detect number of PMP regions. At least PMPADDR0 should be implemented*/\n\t\t__check_csr_64(CSR_PMPADDR0, 0, val, pmp_count, __pmp_skip);\n\t}\n__pmp_skip:\n\n\t/* Detect number of MHPM counters */\n\t__check_csr(CSR_MHPMCOUNTER3, 0, 1UL, mhpm_count, __mhpm_skip);\n\thfeatures->mhpm_bits = hart_pmu_get_allowed_bits();\n\n\t__check_csr_4(CSR_MHPMCOUNTER4, 0, 1UL, mhpm_count, __mhpm_skip);\n\t__check_csr_8(CSR_MHPMCOUNTER8, 0, 1UL, mhpm_count, __mhpm_skip);\n\t__check_csr_16(CSR_MHPMCOUNTER16, 0, 1UL, mhpm_count, __mhpm_skip);\n\n\t/**\n\t * No need to check for MHPMCOUNTERH for RV32 as they are expected to be\n\t * implemented if MHPMCOUNTER is implemented.\n\t */\n\n__mhpm_skip:\n\n#undef __check_csr_64\n#undef __check_csr_32\n#undef __check_csr_16\n#undef __check_csr_8\n#undef __check_csr_4\n#undef __check_csr_2\n#undef __check_csr\n\n\t/* Detect if hart supports Priv v1.10 */\n\tval = csr_read_allowed(CSR_MCOUNTEREN, (unsigned long)&trap);\n\tif (!trap.cause)\n\t\thfeatures->priv_version = SBI_HART_PRIV_VER_1_10;\n\n\t/* Detect if hart supports Priv v1.11 */\n\tval = csr_read_allowed(CSR_MCOUNTINHIBIT, (unsigned long)&trap);\n\tif (!trap.cause &&\n\t    (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_10))\n\t\thfeatures->priv_version = SBI_HART_PRIV_VER_1_11;\n\n\t/* Detect if hart supports Priv v1.12 */\n\tcsr_read_allowed(CSR_MENVCFG, (unsigned long)&trap);\n\tif (!trap.cause &&\n\t    (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_11))\n\t\thfeatures->priv_version = SBI_HART_PRIV_VER_1_12;\n\n\t/* Counter overflow/filtering is not useful without mcounter/inhibit */\n\tif (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_12) {\n\t\t/* Detect if hart supports sscofpmf */\n\t\tcsr_read_allowed(CSR_SCOUNTOVF, (unsigned long)&trap);\n\t\tif (!trap.cause)\n\t\t\t__sbi_hart_update_extension(hfeatures,\n\t\t\t\t\tSBI_HART_EXT_SSCOFPMF, true);\n\t}\n\n\t/* Detect if hart supports time CSR */\n\tcsr_read_allowed(CSR_TIME, (unsigned long)&trap);\n\tif (!trap.cause)\n\t\t__sbi_hart_update_extension(hfeatures,\n\t\t\t\t\tSBI_HART_EXT_TIME, true);\n\n\t/* Detect if hart has AIA local interrupt CSRs */\n\tcsr_read_allowed(CSR_MTOPI, (unsigned long)&trap);\n\tif (!trap.cause)\n\t\t__sbi_hart_update_extension(hfeatures,\n\t\t\t\t\tSBI_HART_EXT_SMAIA, true);\n\n\t/* Detect if hart supports stimecmp CSR(Sstc extension) */\n\tif (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_12) {\n\t\tcsr_read_allowed(CSR_STIMECMP, (unsigned long)&trap);\n\t\tif (!trap.cause)\n\t\t\t__sbi_hart_update_extension(hfeatures,\n\t\t\t\t\tSBI_HART_EXT_SSTC, true);\n\t}\n\n\t/* Detect if hart supports mstateen CSRs */\n\tif (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_12) {\n\t\tval = csr_read_allowed(CSR_MSTATEEN0, (unsigned long)&trap);\n\t\tif (!trap.cause)\n\t\t\t__sbi_hart_update_extension(hfeatures,\n\t\t\t\t\tSBI_HART_EXT_SMSTATEEN, true);\n\t}\n\n\t/* Let platform populate extensions */\n\trc = sbi_platform_extensions_init(sbi_platform_thishart_ptr(),\n\t\t\t\t\t  hfeatures);\n\tif (rc)\n\t\treturn rc;\n\n\t/* Mark hart feature detection done */\n\thfeatures->detected = true;\n\n\treturn 0;\n}\n\nint sbi_hart_reinit(struct sbi_scratch *scratch)\n{\n\tint rc;\n\n\tmstatus_init(scratch);\n\n\trc = fp_init(scratch);\n\tif (rc)\n\t\treturn rc;\n\n\trc = delegate_traps(scratch);\n\tif (rc)\n\t\treturn rc;\n\n\treturn 0;\n}\n\nint sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot)\n{\n\tint rc;\n\n\tif (cold_boot) {\n\t\tif (misa_extension('H'))\n\t\t\tsbi_hart_expected_trap = &__sbi_expected_trap_hext;\n\n\t\thart_features_offset = sbi_scratch_alloc_offset(\n\t\t\t\t\tsizeof(struct sbi_hart_features));\n\t\tif (!hart_features_offset)\n\t\t\treturn SBI_ENOMEM;\n\t}\n\n\trc = hart_detect_features(scratch);\n\tif (rc)\n\t\treturn rc;\n\n\treturn sbi_hart_reinit(scratch);\n}\n\nvoid __attribute__((noreturn)) sbi_hart_hang(void)\n{\n\twhile (1)\n\t\twfi();\n\t__builtin_unreachable();\n}\n\nvoid __attribute__((noreturn))\nsbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,\n\t\t     unsigned long next_addr, unsigned long next_mode,\n\t\t     bool next_virt)\n{\n#if __riscv_xlen == 32\n\tunsigned long val, valH;\n#else\n\tunsigned long val;\n#endif\n\n\tswitch (next_mode) {\n\tcase PRV_M:\n\t\tbreak;\n\tcase PRV_S:\n\t\tif (!misa_extension('S'))\n\t\t\tsbi_hart_hang();\n\t\tbreak;\n\tcase PRV_U:\n\t\tif (!misa_extension('U'))\n\t\t\tsbi_hart_hang();\n\t\tbreak;\n\tdefault:\n\t\tsbi_hart_hang();\n\t}\n\n\tval = csr_read(CSR_MSTATUS);\n\tval = INSERT_FIELD(val, MSTATUS_MPP, next_mode);\n\tval = INSERT_FIELD(val, MSTATUS_MPIE, 0);\n#if __riscv_xlen == 32\n\tif (misa_extension('H')) {\n\t\tvalH = csr_read(CSR_MSTATUSH);\n\t\tvalH = INSERT_FIELD(valH, MSTATUSH_MPV, next_virt);\n\t\tcsr_write(CSR_MSTATUSH, valH);\n\t}\n#else\n\tif (misa_extension('H'))\n\t\tval = INSERT_FIELD(val, MSTATUS_MPV, next_virt);\n#endif\n\tcsr_write(CSR_MSTATUS, val);\n\tcsr_write(CSR_MEPC, next_addr);\n\n\tif (next_mode == PRV_S) {\n\t\tcsr_write(CSR_STVEC, next_addr);\n\t\tcsr_write(CSR_SSCRATCH, 0);\n\t\tcsr_write(CSR_SIE, 0);\n\t\tcsr_write(CSR_SATP, 0);\n\t} else if (next_mode == PRV_U) {\n\t\tif (misa_extension('N')) {\n\t\t\tcsr_write(CSR_UTVEC, next_addr);\n\t\t\tcsr_write(CSR_USCRATCH, 0);\n\t\t\tcsr_write(CSR_UIE, 0);\n\t\t}\n\t}\n\n\tregister unsigned long a0 asm(\"a0\") = arg0;\n\tregister unsigned long a1 asm(\"a1\") = arg1;\n\t__asm__ __volatile__(\"mret\" : : \"r\"(a0), \"r\"(a1));\n\t__builtin_unreachable();\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_hfence.S",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Atish Patra <anup.patel@wdc.com>\n */\n\n\t/*\n\t * HFENCE.GVMA rs1, rs2\n\t * HFENCE.GVMA zero, rs2\n\t * HFENCE.GVMA rs1\n\t * HFENCE.GVMA\n\t *\n\t * rs1!=zero and rs2!=zero ==> HFENCE.GVMA rs1, rs2\n\t * rs1==zero and rs2!=zero ==> HFENCE.GVMA zero, rs2\n\t * rs1!=zero and rs2==zero ==> HFENCE.GVMA rs1\n\t * rs1==zero and rs2==zero ==> HFENCE.GVMA\n\t *\n\t * Instruction encoding of HFENCE.GVMA is:\n\t * 0110001 rs2(5) rs1(5) 000 00000 1110011\n\t */\n\n\t.align 3\n\t.global __sbi_hfence_gvma_vmid_gpa\n__sbi_hfence_gvma_vmid_gpa:\n\t/*\n\t * rs1 = a0 (GPA >> 2)\n\t * rs2 = a1 (VMID)\n\t * HFENCE.GVMA a0, a1\n\t * 0110001 01011 01010 000 00000 1110011\n\t */\n\t.word 0x62b50073\n\tret\n\n\t.align 3\n\t.global __sbi_hfence_gvma_vmid\n__sbi_hfence_gvma_vmid:\n\t/*\n\t * rs1 = zero\n\t * rs2 = a0 (VMID)\n\t * HFENCE.GVMA zero, a0\n\t * 0110001 01010 00000 000 00000 1110011\n\t */\n\t.word 0x62a00073\n\tret\n\n\t.align 3\n\t.global __sbi_hfence_gvma_gpa\n__sbi_hfence_gvma_gpa:\n\t/*\n\t * rs1 = a0 (GPA >> 2)\n\t * rs2 = zero\n\t * HFENCE.GVMA a0\n\t * 0110001 00000 01010 000 00000 1110011\n\t */\n\t.word 0x62050073\n\tret\n\n\t.align 3\n\t.global __sbi_hfence_gvma_all\n__sbi_hfence_gvma_all:\n\t/*\n\t * rs1 = zero\n\t * rs2 = zero\n\t * HFENCE.GVMA\n\t * 0110001 00000 00000 000 00000 1110011\n\t */\n\t.word 0x62000073\n\tret\n\n\t/*\n\t * HFENCE.VVMA rs1, rs2\n\t * HFENCE.VVMA zero, rs2\n\t * HFENCE.VVMA rs1\n\t * HFENCE.VVMA\n\t *\n\t * rs1!=zero and rs2!=zero ==> HFENCE.VVMA rs1, rs2\n\t * rs1==zero and rs2!=zero ==> HFENCE.VVMA zero, rs2\n\t * rs1!=zero and rs2==zero ==> HFENCE.VVMA rs1\n\t * rs1==zero and rs2==zero ==> HFENCE.vVMA\n\t *\n\t * Instruction encoding of HFENCE.VVMA is:\n\t * 0010001 rs2(5) rs1(5) 000 00000 1110011\n\t */\n\n\t.align 3\n\t.global __sbi_hfence_vvma_asid_va\n__sbi_hfence_vvma_asid_va:\n\t/*\n\t * rs1 = a0 (VA)\n\t * rs2 = a1 (ASID)\n\t * HFENCE.VVMA a0, a1\n\t * 0010001 01011 01010 000 00000 1110011\n\t */\n\t.word 0x22b50073\n\tret\n\n\t.align 3\n\t.global __sbi_hfence_vvma_asid\n__sbi_hfence_vvma_asid:\n\t/*\n\t * rs1 = zero\n\t * rs2 = a0 (ASID)\n\t * HFENCE.VVMA zero, a0\n\t * 0010001 01010 00000 000 00000 1110011\n\t */\n\t.word 0x22a00073\n\tret\n\n\t.align 3\n\t.global __sbi_hfence_vvma_va\n__sbi_hfence_vvma_va:\n\t/*\n\t * rs1 = a0 (VA)\n\t * rs2 = zero\n\t * HFENCE.VVMA zero, a0\n\t * 0010001 00000 01010 000 00000 1110011\n\t */\n\t.word 0x22050073\n\tret\n\n\t.align 3\n\t.global __sbi_hfence_vvma_all\n__sbi_hfence_vvma_all:\n\t/*\n\t * rs1 = zero\n\t * rs2 = zero\n\t * HFENCE.VVMA\n\t * 0010001 00000 00000 000 00000 1110011\n\t */\n\t.word 0x22000073\n\tret\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_hsm.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_barrier.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/riscv_atomic.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_hsm.h>\n#include <sbi/sbi_init.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_system.h>\n#include <sbi/sbi_timer.h>\n#include <sbi/sbi_console.h>\n\nstatic const struct sbi_hsm_device *hsm_dev = NULL;\nstatic unsigned long hart_data_offset;\n\n/** Per hart specific data to manage state transition **/\nstruct sbi_hsm_data {\n\tatomic_t state;\n\tunsigned long suspend_type;\n\tunsigned long saved_mie;\n\tunsigned long saved_mip;\n};\n\nstatic inline int __sbi_hsm_hart_get_state(u32 hartid)\n{\n\tstruct sbi_hsm_data *hdata;\n\tstruct sbi_scratch *scratch;\n\n\tscratch = sbi_hartid_to_scratch(hartid);\n\tif (!scratch)\n\t\treturn SBI_EINVAL;\n\n\thdata = sbi_scratch_offset_ptr(scratch, hart_data_offset);\n\treturn atomic_read(&hdata->state);\n}\n\nint sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid)\n{\n\tif (!sbi_domain_is_assigned_hart(dom, hartid))\n\t\treturn SBI_EINVAL;\n\n\treturn __sbi_hsm_hart_get_state(hartid);\n}\n\n/**\n * Get ulong HART mask for given HART base ID\n * @param dom the domain to be used for output HART mask\n * @param hbase the HART base ID\n * @param out_hmask the output ulong HART mask\n * @return 0 on success and SBI_Exxx (< 0) on failure\n * Note: the output HART mask will be set to zero on failure as well.\n */\nint sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,\n\t\t\t\t    ulong hbase, ulong *out_hmask)\n{\n\tint hstate;\n\tulong i, hmask, dmask;\n\tulong hend = sbi_scratch_last_hartid() + 1;\n\n\t*out_hmask = 0;\n\tif (hend <= hbase)\n\t\treturn SBI_EINVAL;\n\tif (BITS_PER_LONG < (hend - hbase))\n\t\thend = hbase + BITS_PER_LONG;\n\n\tdmask = sbi_domain_get_assigned_hartmask(dom, hbase);\n\tfor (i = hbase; i < hend; i++) {\n\t\thmask = 1UL << (i - hbase);\n\t\tif (dmask & hmask) {\n\t\t\thstate = __sbi_hsm_hart_get_state(i);\n\t\t\tif (hstate == SBI_HSM_STATE_STARTED ||\n\t\t\t    hstate == SBI_HSM_STATE_SUSPENDED)\n\t\t\t\t*out_hmask |= hmask;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nvoid sbi_hsm_prepare_next_jump(struct sbi_scratch *scratch, u32 hartid)\n{\n\tu32 oldstate;\n\tstruct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,\n\t\t\t\t\t\t\t    hart_data_offset);\n\n\toldstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_START_PENDING,\n\t\t\t\t  SBI_HSM_STATE_STARTED);\n\tif (oldstate != SBI_HSM_STATE_START_PENDING)\n\t\tsbi_hart_hang();\n}\n\nstatic void sbi_hsm_hart_wait(struct sbi_scratch *scratch, u32 hartid)\n{\n\tunsigned long saved_mie;\n\tstruct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,\n\t\t\t\t\t\t\t    hart_data_offset);\n\t/* Save MIE CSR */\n\tsaved_mie = csr_read(CSR_MIE);\n\n\t/* Set MSIE and MEIE bits to receive IPI */\n\tcsr_set(CSR_MIE, MIP_MSIP | MIP_MEIP);\n\n\t/* Wait for hart_add call*/\n\twhile (atomic_read(&hdata->state) != SBI_HSM_STATE_START_PENDING) {\n\t\twfi();\n\t};\n\n\t/* Restore MIE CSR */\n\tcsr_write(CSR_MIE, saved_mie);\n\n\t/*\n\t * No need to clear IPI here because the sbi_ipi_init() will\n\t * clear it for current HART via sbi_platform_ipi_init().\n\t */\n}\n\nconst struct sbi_hsm_device *sbi_hsm_get_device(void)\n{\n\treturn hsm_dev;\n}\n\nvoid sbi_hsm_set_device(const struct sbi_hsm_device *dev)\n{\n\tif (!dev || hsm_dev)\n\t\treturn;\n\n\thsm_dev = dev;\n}\n\nstatic bool hsm_device_has_hart_hotplug(void)\n{\n\tif (hsm_dev && hsm_dev->hart_start && hsm_dev->hart_stop)\n\t\treturn true;\n\treturn false;\n}\n\nstatic bool hsm_device_has_hart_secondary_boot(void)\n{\n\tif (hsm_dev && hsm_dev->hart_start && !hsm_dev->hart_stop)\n\t\treturn true;\n\treturn false;\n}\n\nstatic int hsm_device_hart_start(u32 hartid, ulong saddr)\n{\n\tif (hsm_dev && hsm_dev->hart_start)\n\t\treturn hsm_dev->hart_start(hartid, saddr);\n\treturn SBI_ENOTSUPP;\n}\n\nstatic int hsm_device_hart_stop(void)\n{\n\tif (hsm_dev && hsm_dev->hart_stop)\n\t\treturn hsm_dev->hart_stop();\n\treturn SBI_ENOTSUPP;\n}\n\nstatic int hsm_device_hart_suspend(u32 suspend_type)\n{\n\tif (hsm_dev && hsm_dev->hart_suspend)\n\t\treturn hsm_dev->hart_suspend(suspend_type);\n\treturn SBI_ENOTSUPP;\n}\n\nstatic void hsm_device_hart_resume(void)\n{\n\tif (hsm_dev && hsm_dev->hart_resume)\n\t\thsm_dev->hart_resume();\n}\n\nint sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot)\n{\n\tu32 i;\n\tstruct sbi_scratch *rscratch;\n\tstruct sbi_hsm_data *hdata;\n\n\tif (cold_boot) {\n\t\thart_data_offset = sbi_scratch_alloc_offset(sizeof(*hdata));\n\t\tif (!hart_data_offset)\n\t\t\treturn SBI_ENOMEM;\n\n\t\t/* Initialize hart state data for every hart */\n\t\tfor (i = 0; i <= sbi_scratch_last_hartid(); i++) {\n\t\t\trscratch = sbi_hartid_to_scratch(i);\n\t\t\tif (!rscratch)\n\t\t\t\tcontinue;\n\n\t\t\thdata = sbi_scratch_offset_ptr(rscratch,\n\t\t\t\t\t\t       hart_data_offset);\n\t\t\tATOMIC_INIT(&hdata->state,\n\t\t\t\t    (i == hartid) ?\n\t\t\t\t    SBI_HSM_STATE_START_PENDING :\n\t\t\t\t    SBI_HSM_STATE_STOPPED);\n\t\t}\n\t} else {\n\t\tsbi_hsm_hart_wait(scratch, hartid);\n\t}\n\n\treturn 0;\n}\n\nvoid __noreturn sbi_hsm_exit(struct sbi_scratch *scratch)\n{\n\tu32 hstate;\n\tstruct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,\n\t\t\t\t\t\t\t    hart_data_offset);\n\tvoid (*jump_warmboot)(void) = (void (*)(void))scratch->warmboot_addr;\n\n\thstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_STOP_PENDING,\n\t\t\t\tSBI_HSM_STATE_STOPPED);\n\tif (hstate != SBI_HSM_STATE_STOP_PENDING)\n\t\tgoto fail_exit;\n\n\tif (hsm_device_has_hart_hotplug()) {\n\t\thsm_device_hart_stop();\n\t\t/* It should never reach here */\n\t\tgoto fail_exit;\n\t}\n\n\t/**\n\t * As platform is lacking support for hotplug, directly jump to warmboot\n\t * and wait for interrupts in warmboot. We do it preemptively in order\n\t * preserve the hart states and reuse the code path for hotplug.\n\t */\n\tjump_warmboot();\n\nfail_exit:\n\t/* It should never reach here */\n\tsbi_printf(\"ERR: Failed stop hart [%u]\\n\", current_hartid());\n\tsbi_hart_hang();\n}\n\nint sbi_hsm_hart_start(struct sbi_scratch *scratch,\n\t\t       const struct sbi_domain *dom,\n\t\t       u32 hartid, ulong saddr, ulong smode, ulong priv)\n{\n\tunsigned long init_count;\n\tunsigned int hstate;\n\tstruct sbi_scratch *rscratch;\n\tstruct sbi_hsm_data *hdata;\n\n\t/* For now, we only allow start mode to be S-mode or U-mode. */\n\tif (smode != PRV_S && smode != PRV_U)\n\t\treturn SBI_EINVAL;\n\tif (dom && !sbi_domain_is_assigned_hart(dom, hartid))\n\t\treturn SBI_EINVAL;\n\tif (dom && !sbi_domain_check_addr(dom, saddr, smode,\n\t\t\t\t\t  SBI_DOMAIN_EXECUTE))\n\t\treturn SBI_EINVALID_ADDR;\n\n\trscratch = sbi_hartid_to_scratch(hartid);\n\tif (!rscratch)\n\t\treturn SBI_EINVAL;\n\thdata = sbi_scratch_offset_ptr(rscratch, hart_data_offset);\n\thstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_STOPPED,\n\t\t\t\tSBI_HSM_STATE_START_PENDING);\n\tif (hstate == SBI_HSM_STATE_STARTED)\n\t\treturn SBI_EALREADY;\n\n\t/**\n\t * if a hart is already transition to start or stop, another start call\n\t * is considered as invalid request.\n\t */\n\tif (hstate != SBI_HSM_STATE_STOPPED)\n\t\treturn SBI_EINVAL;\n\n\tinit_count = sbi_init_count(hartid);\n\trscratch->next_arg1 = priv;\n\trscratch->next_addr = saddr;\n\trscratch->next_mode = smode;\n\n\tif (hsm_device_has_hart_hotplug() ||\n\t   (hsm_device_has_hart_secondary_boot() && !init_count)) {\n\t\treturn hsm_device_hart_start(hartid, scratch->warmboot_addr);\n\t} else {\n\t\tint rc = sbi_ipi_raw_send(hartid);\n\t\tif (rc)\n\t\t    return rc;\n\t}\n\n\treturn 0;\n}\n\nint sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow)\n{\n\tint oldstate;\n\tconst struct sbi_domain *dom = sbi_domain_thishart_ptr();\n\tstruct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,\n\t\t\t\t\t\t\t    hart_data_offset);\n\n\tif (!dom)\n\t\treturn SBI_EFAIL;\n\n\toldstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_STARTED,\n\t\t\t\t  SBI_HSM_STATE_STOP_PENDING);\n\tif (oldstate != SBI_HSM_STATE_STARTED) {\n\t\tsbi_printf(\"%s: ERR: The hart is in invalid state [%u]\\n\",\n\t\t\t   __func__, oldstate);\n\t\treturn SBI_EFAIL;\n\t}\n\n\tif (exitnow)\n\t\tsbi_exit(scratch);\n\n\treturn 0;\n}\n\nstatic int __sbi_hsm_suspend_default(struct sbi_scratch *scratch)\n{\n\t/* Wait for interrupt */\n\twfi();\n\n\treturn 0;\n}\n\nstatic void __sbi_hsm_suspend_non_ret_save(struct sbi_scratch *scratch)\n{\n\tstruct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,\n\t\t\t\t\t\t\t    hart_data_offset);\n\n\t/*\n\t * We will be resuming in warm-boot path so the MIE and MIP CSRs\n\t * will be back to initial state. It is possible that HART has\n\t * configured timer event before going to suspend state so we\n\t * should save MIE and MIP CSRs and restore it after resuming.\n\t *\n\t * Further, the M-mode bits in MIP CSR are read-only and set by\n\t * external devices (such as interrupt controller) whereas all\n\t * VS-mode bits in MIP are read-only alias of bits in HVIP CSR.\n\t *\n\t * This means we should only save/restore S-mode bits of MIP CSR\n\t * such as MIP.SSIP and MIP.STIP.\n\t */\n\n\thdata->saved_mie = csr_read(CSR_MIE);\n\thdata->saved_mip = csr_read(CSR_MIP) & (MIP_SSIP | MIP_STIP);\n}\n\nstatic void __sbi_hsm_suspend_non_ret_restore(struct sbi_scratch *scratch)\n{\n\tstruct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,\n\t\t\t\t\t\t\t    hart_data_offset);\n\n\tcsr_write(CSR_MIE, hdata->saved_mie);\n\tcsr_write(CSR_MIP, (hdata->saved_mip & (MIP_SSIP | MIP_STIP)));\n}\n\nvoid sbi_hsm_hart_resume_start(struct sbi_scratch *scratch)\n{\n\tint oldstate;\n\tstruct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,\n\t\t\t\t\t\t\t    hart_data_offset);\n\n\t/* If current HART was SUSPENDED then set RESUME_PENDING state */\n\toldstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_SUSPENDED,\n\t\t\tSBI_HSM_STATE_RESUME_PENDING);\n\tif (oldstate != SBI_HSM_STATE_SUSPENDED) {\n\t\tsbi_printf(\"%s: ERR: The hart is in invalid state [%u]\\n\",\n\t\t\t   __func__, oldstate);\n\t\tsbi_hart_hang();\n\t}\n\n\thsm_device_hart_resume();\n}\n\nvoid sbi_hsm_hart_resume_finish(struct sbi_scratch *scratch)\n{\n\tu32 oldstate;\n\tstruct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,\n\t\t\t\t\t\t\t    hart_data_offset);\n\n\t/* If current HART was RESUME_PENDING then set STARTED state */\n\toldstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_RESUME_PENDING,\n\t\t\t\t  SBI_HSM_STATE_STARTED);\n\tif (oldstate != SBI_HSM_STATE_RESUME_PENDING) {\n\t\tsbi_printf(\"%s: ERR: The hart is in invalid state [%u]\\n\",\n\t\t\t   __func__, oldstate);\n\t\tsbi_hart_hang();\n\t}\n\n\t/*\n\t * Restore some of the M-mode CSRs which we are re-configured by\n\t * the warm-boot sequence.\n\t */\n\t__sbi_hsm_suspend_non_ret_restore(scratch);\n}\n\nint sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,\n\t\t\t ulong raddr, ulong rmode, ulong priv)\n{\n\tint oldstate, ret;\n\tconst struct sbi_domain *dom = sbi_domain_thishart_ptr();\n\tstruct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,\n\t\t\t\t\t\t\t    hart_data_offset);\n\n\t/* For now, we only allow suspend from S-mode or U-mode. */\n\n\t/* Sanity check on domain assigned to current HART */\n\tif (!dom)\n\t\treturn SBI_EINVAL;\n\n\t/* Sanity check on suspend type */\n\tif (SBI_HSM_SUSPEND_RET_DEFAULT < suspend_type &&\n\t    suspend_type < SBI_HSM_SUSPEND_RET_PLATFORM)\n\t\treturn SBI_EINVAL;\n\tif (SBI_HSM_SUSPEND_NON_RET_DEFAULT < suspend_type &&\n\t    suspend_type < SBI_HSM_SUSPEND_NON_RET_PLATFORM)\n\t\treturn SBI_EINVAL;\n\n\t/* Additional sanity check for non-retentive suspend */\n\tif (suspend_type & SBI_HSM_SUSP_NON_RET_BIT) {\n\t\tif (rmode != PRV_S && rmode != PRV_U)\n\t\t\treturn SBI_EINVAL;\n\t\tif (dom && !sbi_domain_check_addr(dom, raddr, rmode,\n\t\t\t\t\t\t  SBI_DOMAIN_EXECUTE))\n\t\t\treturn SBI_EINVALID_ADDR;\n\t}\n\n\t/* Save the resume address and resume mode */\n\tscratch->next_arg1 = priv;\n\tscratch->next_addr = raddr;\n\tscratch->next_mode = rmode;\n\n\t/* Directly move from STARTED to SUSPENDED state */\n\toldstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_STARTED,\n\t\t\t\t  SBI_HSM_STATE_SUSPENDED);\n\tif (oldstate != SBI_HSM_STATE_STARTED) {\n\t\tsbi_printf(\"%s: ERR: The hart is in invalid state [%u]\\n\",\n\t\t\t   __func__, oldstate);\n\t\tret = SBI_EDENIED;\n\t\tgoto fail_restore_state;\n\t}\n\n\t/* Save the suspend type */\n\thdata->suspend_type = suspend_type;\n\n\t/*\n\t * Save context which will be restored after resuming from\n\t * non-retentive suspend.\n\t */\n\tif (suspend_type & SBI_HSM_SUSP_NON_RET_BIT)\n\t\t__sbi_hsm_suspend_non_ret_save(scratch);\n\n\t/* Try platform specific suspend */\n\tret = hsm_device_hart_suspend(suspend_type);\n\tif (ret == SBI_ENOTSUPP) {\n\t\t/* Try generic implementation of default suspend types */\n\t\tif (suspend_type == SBI_HSM_SUSPEND_RET_DEFAULT ||\n\t\t    suspend_type == SBI_HSM_SUSPEND_NON_RET_DEFAULT) {\n\t\t\tret = __sbi_hsm_suspend_default(scratch);\n\t\t}\n\t}\n\n\t/*\n\t * The platform may have coordinated a retentive suspend, or it may\n\t * have exited early from a non-retentive suspend. Either way, the\n\t * caller is not expecting a successful return, so jump to the warm\n\t * boot entry point to simulate resume from a non-retentive suspend.\n\t */\n\tif (ret == 0 && (suspend_type & SBI_HSM_SUSP_NON_RET_BIT)) {\n\t\tvoid (*jump_warmboot)(void) =\n\t\t\t(void (*)(void))scratch->warmboot_addr;\n\n\t\tjump_warmboot();\n\t}\n\nfail_restore_state:\n\t/*\n\t * We might have successfully resumed from retentive suspend\n\t * or suspend failed. In both cases, we restore state of hart.\n\t */\n\toldstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_SUSPENDED,\n\t\t\t\t  SBI_HSM_STATE_STARTED);\n\tif (oldstate != SBI_HSM_STATE_SUSPENDED) {\n\t\tsbi_printf(\"%s: ERR: The hart is in invalid state [%u]\\n\",\n\t\t\t   __func__, oldstate);\n\t\tsbi_hart_hang();\n\t}\n\n\treturn ret;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_illegal_insn.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_barrier.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_emulate_csr.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_illegal_insn.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_unpriv.h>\n#include <sbi/sbi_console.h>\n\ntypedef int (*illegal_insn_func)(ulong insn, struct sbi_trap_regs *regs);\n\nstatic int truly_illegal_insn(ulong insn, struct sbi_trap_regs *regs)\n{\n\tstruct sbi_trap_info trap;\n\n\ttrap.epc = regs->mepc;\n\ttrap.cause = CAUSE_ILLEGAL_INSTRUCTION;\n\ttrap.tval = insn;\n\ttrap.tval2 = 0;\n\ttrap.tinst = 0;\n\ttrap.gva   = 0;\n\n\treturn sbi_trap_redirect(regs, &trap);\n}\n\nstatic int misc_mem_opcode_insn(ulong insn, struct sbi_trap_regs *regs)\n{\n\t/* Errata workaround: emulate `fence.tso` as `fence rw, rw`. */\n\tif ((insn & INSN_MASK_FENCE_TSO) == INSN_MATCH_FENCE_TSO) {\n\t\tsmp_mb();\n\t\tregs->mepc += 4;\n\t\treturn 0;\n\t}\n\n\treturn truly_illegal_insn(insn, regs);\n}\n\nstatic int system_opcode_insn(ulong insn, struct sbi_trap_regs *regs)\n{\n\tint do_write, rs1_num = (insn >> 15) & 0x1f;\n\tulong rs1_val = GET_RS1(insn, regs);\n\tint csr_num   = (u32)insn >> 20;\n\tulong prev_mode = (regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT;\n\tulong csr_val, new_csr_val;\n\n\tif (prev_mode == PRV_M) {\n\t\tsbi_printf(\"%s: Failed to access CSR %#x from M-mode\",\n\t\t\t__func__, csr_num);\n\t\treturn SBI_EFAIL;\n\t}\n\n\t/* TODO: Ensure that we got CSR read/write instruction */\n\n\tif (sbi_emulate_csr_read(csr_num, regs, &csr_val))\n\t\treturn truly_illegal_insn(insn, regs);\n\n\tdo_write = rs1_num;\n\tswitch (GET_RM(insn)) {\n\tcase 1:\n\t\tnew_csr_val = rs1_val;\n\t\tdo_write    = 1;\n\t\tbreak;\n\tcase 2:\n\t\tnew_csr_val = csr_val | rs1_val;\n\t\tbreak;\n\tcase 3:\n\t\tnew_csr_val = csr_val & ~rs1_val;\n\t\tbreak;\n\tcase 5:\n\t\tnew_csr_val = rs1_num;\n\t\tdo_write    = 1;\n\t\tbreak;\n\tcase 6:\n\t\tnew_csr_val = csr_val | rs1_num;\n\t\tbreak;\n\tcase 7:\n\t\tnew_csr_val = csr_val & ~rs1_num;\n\t\tbreak;\n\tdefault:\n\t\treturn truly_illegal_insn(insn, regs);\n\t};\n\n\tif (do_write && sbi_emulate_csr_write(csr_num, regs, new_csr_val))\n\t\treturn truly_illegal_insn(insn, regs);\n\n\tSET_RD(insn, regs, csr_val);\n\n\tregs->mepc += 4;\n\n\treturn 0;\n}\n\nstatic const illegal_insn_func illegal_insn_table[32] = {\n\ttruly_illegal_insn, /* 0 */\n\ttruly_illegal_insn, /* 1 */\n\ttruly_illegal_insn, /* 2 */\n\tmisc_mem_opcode_insn, /* 3 */\n\ttruly_illegal_insn, /* 4 */\n\ttruly_illegal_insn, /* 5 */\n\ttruly_illegal_insn, /* 6 */\n\ttruly_illegal_insn, /* 7 */\n\ttruly_illegal_insn, /* 8 */\n\ttruly_illegal_insn, /* 9 */\n\ttruly_illegal_insn, /* 10 */\n\ttruly_illegal_insn, /* 11 */\n\ttruly_illegal_insn, /* 12 */\n\ttruly_illegal_insn, /* 13 */\n\ttruly_illegal_insn, /* 14 */\n\ttruly_illegal_insn, /* 15 */\n\ttruly_illegal_insn, /* 16 */\n\ttruly_illegal_insn, /* 17 */\n\ttruly_illegal_insn, /* 18 */\n\ttruly_illegal_insn, /* 19 */\n\ttruly_illegal_insn, /* 20 */\n\ttruly_illegal_insn, /* 21 */\n\ttruly_illegal_insn, /* 22 */\n\ttruly_illegal_insn, /* 23 */\n\ttruly_illegal_insn, /* 24 */\n\ttruly_illegal_insn, /* 25 */\n\ttruly_illegal_insn, /* 26 */\n\ttruly_illegal_insn, /* 27 */\n\tsystem_opcode_insn, /* 28 */\n\ttruly_illegal_insn, /* 29 */\n\ttruly_illegal_insn, /* 30 */\n\ttruly_illegal_insn  /* 31 */\n};\n\nint sbi_illegal_insn_handler(ulong insn, struct sbi_trap_regs *regs)\n{\n\tstruct sbi_trap_info uptrap;\n\n\t/*\n\t * We only deal with 32-bit (or longer) illegal instructions. If we\n\t * see instruction is zero OR instruction is 16-bit then we fetch and\n\t * check the instruction encoding using unprivilege access.\n\t *\n\t * The program counter (PC) in RISC-V world is always 2-byte aligned\n\t * so handling only 32-bit (or longer) illegal instructions also help\n\t * the case where MTVAL CSR contains instruction address for illegal\n\t * instruction trap.\n\t */\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_ILLEGAL_INSN);\n\tif (unlikely((insn & 3) != 3)) {\n\t\tinsn = sbi_get_insn(regs->mepc, &uptrap);\n\t\tif (uptrap.cause) {\n\t\t\tuptrap.epc = regs->mepc;\n\t\t\treturn sbi_trap_redirect(regs, &uptrap);\n\t\t}\n\t\tif ((insn & 3) != 3)\n\t\t\treturn truly_illegal_insn(insn, regs);\n\t}\n\n\treturn illegal_insn_table[(insn & 0x7c) >> 2](insn, regs);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_init.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_atomic.h>\n#include <sbi/riscv_barrier.h>\n#include <sbi/riscv_locks.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_hsm.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_irqchip.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi/sbi_system.h>\n#include <sbi/sbi_string.h>\n#include <sbi/sbi_timer.h>\n#include <sbi/sbi_tlb.h>\n#include <sbi/sbi_version.h>\n\n#define BANNER                                              \\\n\t\"   ____                    _____ ____ _____\\n\"     \\\n\t\"  / __ \\\\                  / ____|  _ \\\\_   _|\\n\"  \\\n\t\" | |  | |_ __   ___ _ __ | (___ | |_) || |\\n\"      \\\n\t\" | |  | | '_ \\\\ / _ \\\\ '_ \\\\ \\\\___ \\\\|  _ < | |\\n\" \\\n\t\" | |__| | |_) |  __/ | | |____) | |_) || |_\\n\"     \\\n\t\"  \\\\____/| .__/ \\\\___|_| |_|_____/|____/_____|\\n\"  \\\n\t\"        | |\\n\"                                     \\\n\t\"        |_|\\n\\n\"\n\nstatic void sbi_boot_print_banner(struct sbi_scratch *scratch)\n{\n\tif (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)\n\t\treturn;\n\n#ifdef OPENSBI_VERSION_GIT\n\tsbi_printf(\"\\nOpenSBI %s\\n\", OPENSBI_VERSION_GIT);\n#else\n\tsbi_printf(\"\\nOpenSBI v%d.%d\\n\", OPENSBI_VERSION_MAJOR,\n\t\t   OPENSBI_VERSION_MINOR);\n#endif\n\n#ifdef OPENSBI_BUILD_TIME_STAMP\n\tsbi_printf(\"Build time: %s\\n\", OPENSBI_BUILD_TIME_STAMP);\n#endif\n\n#ifdef OPENSBI_BUILD_COMPILER_VERSION\n\tsbi_printf(\"Build compiler: %s\\n\", OPENSBI_BUILD_COMPILER_VERSION);\n#endif\n\n\tsbi_printf(BANNER);\n}\n\nstatic void sbi_boot_print_general(struct sbi_scratch *scratch)\n{\n\tchar str[128];\n\tconst struct sbi_pmu_device *pdev;\n\tconst struct sbi_hsm_device *hdev;\n\tconst struct sbi_ipi_device *idev;\n\tconst struct sbi_timer_device *tdev;\n\tconst struct sbi_console_device *cdev;\n\tconst struct sbi_system_reset_device *srdev;\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\tif (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)\n\t\treturn;\n\n\t/* Platform details */\n\tsbi_printf(\"Platform Name             : %s\\n\",\n\t\t   sbi_platform_name(plat));\n\tsbi_platform_get_features_str(plat, str, sizeof(str));\n\tsbi_printf(\"Platform Features         : %s\\n\", str);\n\tsbi_printf(\"Platform HART Count       : %u\\n\",\n\t\t   sbi_platform_hart_count(plat));\n\tidev = sbi_ipi_get_device();\n\tsbi_printf(\"Platform IPI Device       : %s\\n\",\n\t\t   (idev) ? idev->name : \"---\");\n\ttdev = sbi_timer_get_device();\n\tsbi_printf(\"Platform Timer Device     : %s @ %luHz\\n\",\n\t\t   (tdev) ? tdev->name : \"---\",\n\t\t   (tdev) ? tdev->timer_freq : 0);\n\tcdev = sbi_console_get_device();\n\tsbi_printf(\"Platform Console Device   : %s\\n\",\n\t\t   (cdev) ? cdev->name : \"---\");\n\thdev = sbi_hsm_get_device();\n\tsbi_printf(\"Platform HSM Device       : %s\\n\",\n\t\t   (hdev) ? hdev->name : \"---\");\n\tpdev = sbi_pmu_get_device();\n\tsbi_printf(\"Platform PMU Device       : %s\\n\",\n\t\t   (pdev) ? pdev->name : \"---\");\n\tsrdev = sbi_system_reset_get_device(SBI_SRST_RESET_TYPE_COLD_REBOOT, 0);\n\tsbi_printf(\"Platform Reboot Device    : %s\\n\",\n\t\t   (srdev) ? srdev->name : \"---\");\n\tsrdev = sbi_system_reset_get_device(SBI_SRST_RESET_TYPE_SHUTDOWN, 0);\n\tsbi_printf(\"Platform Shutdown Device  : %s\\n\",\n\t\t   (srdev) ? srdev->name : \"---\");\n\n\t/* Firmware details */\n\tsbi_printf(\"Firmware Base             : 0x%lx\\n\", scratch->fw_start);\n\tsbi_printf(\"Firmware Size             : %d KB\\n\",\n\t\t   (u32)(scratch->fw_size / 1024));\n\n\t/* SBI details */\n\tsbi_printf(\"Runtime SBI Version       : %d.%d\\n\",\n\t\t   sbi_ecall_version_major(), sbi_ecall_version_minor());\n\tsbi_printf(\"\\n\");\n}\n\nstatic void sbi_boot_print_domains(struct sbi_scratch *scratch)\n{\n\tif (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)\n\t\treturn;\n\n\t/* Domain details */\n\tsbi_domain_dump_all(\"      \");\n}\n\nstatic void sbi_boot_print_hart(struct sbi_scratch *scratch, u32 hartid)\n{\n\tint xlen;\n\tchar str[128];\n\tconst struct sbi_domain *dom = sbi_domain_thishart_ptr();\n\n\tif (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS)\n\t\treturn;\n\n\t/* Determine MISA XLEN and MISA string */\n\txlen = misa_xlen();\n\tif (xlen < 1) {\n\t\tsbi_printf(\"Error %d getting MISA XLEN\\n\", xlen);\n\t\tsbi_hart_hang();\n\t}\n\n\t/* Boot HART details */\n\tsbi_printf(\"Boot HART ID              : %u\\n\", hartid);\n\tsbi_printf(\"Boot HART Domain          : %s\\n\", dom->name);\n\tsbi_hart_get_priv_version_str(scratch, str, sizeof(str));\n\tsbi_printf(\"Boot HART Priv Version    : %s\\n\", str);\n\tmisa_string(xlen, str, sizeof(str));\n\tsbi_printf(\"Boot HART Base ISA        : %s\\n\", str);\n\tsbi_hart_get_extensions_str(scratch, str, sizeof(str));\n\tsbi_printf(\"Boot HART ISA Extensions  : %s\\n\", str);\n\tsbi_printf(\"Boot HART PMP Count       : %d\\n\",\n\t\t   sbi_hart_pmp_count(scratch));\n\tsbi_printf(\"Boot HART PMP Granularity : %lu\\n\",\n\t\t   sbi_hart_pmp_granularity(scratch));\n\tsbi_printf(\"Boot HART PMP Address Bits: %d\\n\",\n\t\t   sbi_hart_pmp_addrbits(scratch));\n\tsbi_printf(\"Boot HART MHPM Count      : %d\\n\",\n\t\t   sbi_hart_mhpm_count(scratch));\n\tsbi_hart_delegation_dump(scratch, \"Boot HART \", \"         \");\n}\n\nstatic spinlock_t coldboot_lock = SPIN_LOCK_INITIALIZER;\nstatic struct sbi_hartmask coldboot_wait_hmask = { 0 };\n\nstatic unsigned long coldboot_done;\n\nstatic void wait_for_coldboot(struct sbi_scratch *scratch, u32 hartid)\n{\n\tunsigned long saved_mie, cmip;\n\n\t/* Save MIE CSR */\n\tsaved_mie = csr_read(CSR_MIE);\n\n\t/* Set MSIE and MEIE bits to receive IPI */\n\tcsr_set(CSR_MIE, MIP_MSIP | MIP_MEIP);\n\n\t/* Acquire coldboot lock */\n\tspin_lock(&coldboot_lock);\n\n\t/* Mark current HART as waiting */\n\tsbi_hartmask_set_hart(hartid, &coldboot_wait_hmask);\n\n\t/* Release coldboot lock */\n\tspin_unlock(&coldboot_lock);\n\n\t/* Wait for coldboot to finish using WFI */\n\twhile (!__smp_load_acquire(&coldboot_done)) {\n\t\tdo {\n\t\t\twfi();\n\t\t\tcmip = csr_read(CSR_MIP);\n\t\t } while (!(cmip & (MIP_MSIP | MIP_MEIP)));\n\t};\n\n\t/* Acquire coldboot lock */\n\tspin_lock(&coldboot_lock);\n\n\t/* Unmark current HART as waiting */\n\tsbi_hartmask_clear_hart(hartid, &coldboot_wait_hmask);\n\n\t/* Release coldboot lock */\n\tspin_unlock(&coldboot_lock);\n\n\t/* Restore MIE CSR */\n\tcsr_write(CSR_MIE, saved_mie);\n\n\t/*\n\t * The wait for coldboot is common for both warm startup and\n\t * warm resume path so clearing IPI here would result in losing\n\t * an IPI in warm resume path.\n\t *\n\t * Also, the sbi_platform_ipi_init() called from sbi_ipi_init()\n\t * will automatically clear IPI for current HART.\n\t */\n}\n\nstatic void wake_coldboot_harts(struct sbi_scratch *scratch, u32 hartid)\n{\n\t/* Mark coldboot done */\n\t__smp_store_release(&coldboot_done, 1);\n\n\t/* Acquire coldboot lock */\n\tspin_lock(&coldboot_lock);\n\n\t/* Send an IPI to all HARTs waiting for coldboot */\n\tfor (u32 i = 0; i <= sbi_scratch_last_hartid(); i++) {\n\t\tif ((i != hartid) &&\n\t\t    sbi_hartmask_test_hart(i, &coldboot_wait_hmask))\n\t\t\tsbi_ipi_raw_send(i);\n\t}\n\n\t/* Release coldboot lock */\n\tspin_unlock(&coldboot_lock);\n}\n\nstatic unsigned long init_count_offset;\n\nstatic void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)\n{\n\tint rc;\n\tunsigned long *init_count;\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\t/* Note: This has to be first thing in coldboot init sequence */\n\trc = sbi_scratch_init(scratch);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\t/* Note: This has to be second thing in coldboot init sequence */\n\trc = sbi_domain_init(scratch, hartid);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\tinit_count_offset = sbi_scratch_alloc_offset(__SIZEOF_POINTER__);\n\tif (!init_count_offset)\n\t\tsbi_hart_hang();\n\n\trc = sbi_hsm_init(scratch, hartid, TRUE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_platform_early_init(plat, TRUE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_hart_init(scratch, TRUE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_console_init(scratch);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_pmu_init(scratch, TRUE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\tsbi_boot_print_banner(scratch);\n\n\trc = sbi_irqchip_init(scratch, TRUE);\n\tif (rc) {\n\t\tsbi_printf(\"%s: irqchip init failed (error %d)\\n\",\n\t\t\t   __func__, rc);\n\t\tsbi_hart_hang();\n\t}\n\n\trc = sbi_ipi_init(scratch, TRUE);\n\tif (rc) {\n\t\tsbi_printf(\"%s: ipi init failed (error %d)\\n\", __func__, rc);\n\t\tsbi_hart_hang();\n\t}\n\n\trc = sbi_tlb_init(scratch, TRUE);\n\tif (rc) {\n\t\tsbi_printf(\"%s: tlb init failed (error %d)\\n\", __func__, rc);\n\t\tsbi_hart_hang();\n\t}\n\n\trc = sbi_timer_init(scratch, TRUE);\n\tif (rc) {\n\t\tsbi_printf(\"%s: timer init failed (error %d)\\n\", __func__, rc);\n\t\tsbi_hart_hang();\n\t}\n\n\trc = sbi_ecall_init();\n\tif (rc) {\n\t\tsbi_printf(\"%s: ecall init failed (error %d)\\n\", __func__, rc);\n\t\tsbi_hart_hang();\n\t}\n\n\t/*\n\t * Note: Finalize domains after HSM initialization so that we\n\t * can startup non-root domains.\n\t * Note: Finalize domains before HART PMP configuration so\n\t * that we use correct domain for configuring PMP.\n\t */\n\trc = sbi_domain_finalize(scratch, hartid);\n\tif (rc) {\n\t\tsbi_printf(\"%s: domain finalize failed (error %d)\\n\",\n\t\t\t   __func__, rc);\n\t\tsbi_hart_hang();\n\t}\n\n\trc = sbi_hart_pmp_configure(scratch);\n\tif (rc) {\n\t\tsbi_printf(\"%s: PMP configure failed (error %d)\\n\",\n\t\t\t   __func__, rc);\n\t\tsbi_hart_hang();\n\t}\n\n\t/*\n\t * Note: Platform final initialization should be last so that\n\t * it sees correct domain assignment and PMP configuration.\n\t */\n\trc = sbi_platform_final_init(plat, TRUE);\n\tif (rc) {\n\t\tsbi_printf(\"%s: platform final init failed (error %d)\\n\",\n\t\t\t   __func__, rc);\n\t\tsbi_hart_hang();\n\t}\n\n\tsbi_boot_print_general(scratch);\n\n\tsbi_boot_print_domains(scratch);\n\n\tsbi_boot_print_hart(scratch, hartid);\n\n\twake_coldboot_harts(scratch, hartid);\n\n\tinit_count = sbi_scratch_offset_ptr(scratch, init_count_offset);\n\t(*init_count)++;\n\n\tsbi_hsm_prepare_next_jump(scratch, hartid);\n\tsbi_hart_switch_mode(hartid, scratch->next_arg1, scratch->next_addr,\n\t\t\t     scratch->next_mode, FALSE);\n}\n\nstatic void init_warm_startup(struct sbi_scratch *scratch, u32 hartid)\n{\n\tint rc;\n\tunsigned long *init_count;\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\tif (!init_count_offset)\n\t\tsbi_hart_hang();\n\n\trc = sbi_hsm_init(scratch, hartid, FALSE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_platform_early_init(plat, FALSE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_hart_init(scratch, FALSE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_pmu_init(scratch, FALSE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_irqchip_init(scratch, FALSE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_ipi_init(scratch, FALSE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_tlb_init(scratch, FALSE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_timer_init(scratch, FALSE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_hart_pmp_configure(scratch);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_platform_final_init(plat, FALSE);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\tinit_count = sbi_scratch_offset_ptr(scratch, init_count_offset);\n\t(*init_count)++;\n\n\tsbi_hsm_prepare_next_jump(scratch, hartid);\n}\n\nstatic void init_warm_resume(struct sbi_scratch *scratch)\n{\n\tint rc;\n\n\tsbi_hsm_hart_resume_start(scratch);\n\n\trc = sbi_hart_reinit(scratch);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\trc = sbi_hart_pmp_configure(scratch);\n\tif (rc)\n\t\tsbi_hart_hang();\n\n\tsbi_hsm_hart_resume_finish(scratch);\n}\n\nstatic void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid)\n{\n\tint hstate;\n\n\twait_for_coldboot(scratch, hartid);\n\n\thstate = sbi_hsm_hart_get_state(sbi_domain_thishart_ptr(), hartid);\n\tif (hstate < 0)\n\t\tsbi_hart_hang();\n\n\tif (hstate == SBI_HSM_STATE_SUSPENDED)\n\t\tinit_warm_resume(scratch);\n\telse\n\t\tinit_warm_startup(scratch, hartid);\n\n\tsbi_hart_switch_mode(hartid, scratch->next_arg1,\n\t\t\t     scratch->next_addr,\n\t\t\t     scratch->next_mode, FALSE);\n}\n\nstatic atomic_t coldboot_lottery = ATOMIC_INITIALIZER(0);\n\n/**\n * Initialize OpenSBI library for current HART and jump to next\n * booting stage.\n *\n * The function expects following:\n * 1. The 'mscratch' CSR is pointing to sbi_scratch of current HART\n * 2. Stack pointer (SP) is setup for current HART\n * 3. Interrupts are disabled in MSTATUS CSR\n * 4. All interrupts are disabled in MIE CSR\n *\n * @param scratch pointer to sbi_scratch of current HART\n */\nvoid __noreturn sbi_init(struct sbi_scratch *scratch)\n{\n\tbool next_mode_supported\t= FALSE;\n\tbool coldboot\t\t\t= FALSE;\n\tu32 hartid\t\t\t= current_hartid();\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\tif ((SBI_HARTMASK_MAX_BITS <= hartid) ||\n\t    sbi_platform_hart_invalid(plat, hartid))\n\t\tsbi_hart_hang();\n\n\tswitch (scratch->next_mode) {\n\tcase PRV_M:\n\t\tnext_mode_supported = TRUE;\n\t\tbreak;\n\tcase PRV_S:\n\t\tif (misa_extension('S'))\n\t\t\tnext_mode_supported = TRUE;\n\t\tbreak;\n\tcase PRV_U:\n\t\tif (misa_extension('U'))\n\t\t\tnext_mode_supported = TRUE;\n\t\tbreak;\n\tdefault:\n\t\tsbi_hart_hang();\n\t}\n\n\t/*\n\t * Only the HART supporting privilege mode specified in the\n\t * scratch->next_mode should be allowed to become the coldboot\n\t * HART because the coldboot HART will be directly jumping to\n\t * the next booting stage.\n\t *\n\t * We use a lottery mechanism to select coldboot HART among\n\t * HARTs which satisfy above condition.\n\t */\n\n\tif (next_mode_supported && atomic_xchg(&coldboot_lottery, 1) == 0)\n\t\tcoldboot = TRUE;\n\n\t/*\n\t * Do platform specific nascent (very early) initialization so\n\t * that platform can initialize platform specific per-HART CSRs\n\t * or per-HART devices.\n\t */\n\tif (sbi_platform_nascent_init(plat))\n\t\tsbi_hart_hang();\n\n\tif (coldboot)\n\t\tinit_coldboot(scratch, hartid);\n\telse\n\t\tinit_warmboot(scratch, hartid);\n}\n\nunsigned long sbi_init_count(u32 hartid)\n{\n\tstruct sbi_scratch *scratch;\n\tunsigned long *init_count;\n\n\tif (!init_count_offset)\n\t\treturn 0;\n\n\tscratch = sbi_hartid_to_scratch(hartid);\n\tif (!scratch)\n\t\treturn 0;\n\n\tinit_count = sbi_scratch_offset_ptr(scratch, init_count_offset);\n\n\treturn *init_count;\n}\n\n/**\n * Exit OpenSBI library for current HART and stop HART\n *\n * The function expects following:\n * 1. The 'mscratch' CSR is pointing to sbi_scratch of current HART\n * 2. Stack pointer (SP) is setup for current HART\n *\n * @param scratch pointer to sbi_scratch of current HART\n */\nvoid __noreturn sbi_exit(struct sbi_scratch *scratch)\n{\n\tu32 hartid\t\t\t= current_hartid();\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\tif (sbi_platform_hart_invalid(plat, hartid))\n\t\tsbi_hart_hang();\n\n\tsbi_platform_early_exit(plat);\n\n\tsbi_pmu_exit(scratch);\n\n\tsbi_timer_exit(scratch);\n\n\tsbi_ipi_exit(scratch);\n\n\tsbi_irqchip_exit(scratch);\n\n\tsbi_platform_final_exit(plat);\n\n\tsbi_hsm_exit(scratch);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_ipi.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Nick Kossifidis <mick@ics.forth.gr>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_atomic.h>\n#include <sbi/riscv_barrier.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_hsm.h>\n#include <sbi/sbi_init.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi/sbi_string.h>\n#include <sbi/sbi_tlb.h>\n\nstruct sbi_ipi_data {\n\tunsigned long ipi_type;\n};\n\nstatic unsigned long ipi_data_off;\nstatic const struct sbi_ipi_device *ipi_dev = NULL;\nstatic const struct sbi_ipi_event_ops *ipi_ops_array[SBI_IPI_EVENT_MAX];\n\nstatic int sbi_ipi_send(struct sbi_scratch *scratch, u32 remote_hartid,\n\t\t\tu32 event, void *data)\n{\n\tint ret;\n\tstruct sbi_scratch *remote_scratch = NULL;\n\tstruct sbi_ipi_data *ipi_data;\n\tconst struct sbi_ipi_event_ops *ipi_ops;\n\n\tif ((SBI_IPI_EVENT_MAX <= event) ||\n\t    !ipi_ops_array[event])\n\t\treturn SBI_EINVAL;\n\tipi_ops = ipi_ops_array[event];\n\n\tremote_scratch = sbi_hartid_to_scratch(remote_hartid);\n\tif (!remote_scratch)\n\t\treturn SBI_EINVAL;\n\n\tipi_data = sbi_scratch_offset_ptr(remote_scratch, ipi_data_off);\n\n\tif (ipi_ops->update) {\n\t\tret = ipi_ops->update(scratch, remote_scratch,\n\t\t\t\t      remote_hartid, data);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t}\n\n\t/*\n\t * Set IPI type on remote hart's scratch area and\n\t * trigger the interrupt\n\t */\n\tatomic_raw_set_bit(event, &ipi_data->ipi_type);\n\tsmp_wmb();\n\n\tif (ipi_dev && ipi_dev->ipi_send)\n\t\tipi_dev->ipi_send(remote_hartid);\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_IPI_SENT);\n\n\tif (ipi_ops->sync)\n\t\tipi_ops->sync(scratch);\n\n\treturn 0;\n}\n\n/**\n * As this this function only handlers scalar values of hart mask, it must be\n * set to all online harts if the intention is to send IPIs to all the harts.\n * If hmask is zero, no IPIs will be sent.\n */\nint sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data)\n{\n\tint rc;\n\tulong i, m;\n\tstruct sbi_domain *dom = sbi_domain_thishart_ptr();\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\n\tif (hbase != -1UL) {\n\t\trc = sbi_hsm_hart_interruptible_mask(dom, hbase, &m);\n\t\tif (rc)\n\t\t\treturn rc;\n\t\tm &= hmask;\n\n\t\t/* Send IPIs */\n\t\tfor (i = hbase; m; i++, m >>= 1) {\n\t\t\tif (m & 1UL)\n\t\t\t\tsbi_ipi_send(scratch, i, event, data);\n\t\t}\n\t} else {\n\t\thbase = 0;\n\t\twhile (!sbi_hsm_hart_interruptible_mask(dom, hbase, &m)) {\n\t\t\t/* Send IPIs */\n\t\t\tfor (i = hbase; m; i++, m >>= 1) {\n\t\t\t\tif (m & 1UL)\n\t\t\t\t\tsbi_ipi_send(scratch, i, event, data);\n\t\t\t}\n\t\t\thbase += BITS_PER_LONG;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nint sbi_ipi_event_create(const struct sbi_ipi_event_ops *ops)\n{\n\tint i, ret = SBI_ENOSPC;\n\n\tif (!ops || !ops->process)\n\t\treturn SBI_EINVAL;\n\n\tfor (i = 0; i < SBI_IPI_EVENT_MAX; i++) {\n\t\tif (!ipi_ops_array[i]) {\n\t\t\tret = i;\n\t\t\tipi_ops_array[i] = ops;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn ret;\n}\n\nvoid sbi_ipi_event_destroy(u32 event)\n{\n\tif (SBI_IPI_EVENT_MAX <= event)\n\t\treturn;\n\n\tipi_ops_array[event] = NULL;\n}\n\nstatic void sbi_ipi_process_smode(struct sbi_scratch *scratch)\n{\n\tcsr_set(CSR_MIP, MIP_SSIP);\n}\n\nstatic struct sbi_ipi_event_ops ipi_smode_ops = {\n\t.name = \"IPI_SMODE\",\n\t.process = sbi_ipi_process_smode,\n};\n\nstatic u32 ipi_smode_event = SBI_IPI_EVENT_MAX;\n\nint sbi_ipi_send_smode(ulong hmask, ulong hbase)\n{\n\treturn sbi_ipi_send_many(hmask, hbase, ipi_smode_event, NULL);\n}\n\nvoid sbi_ipi_clear_smode(void)\n{\n\tcsr_clear(CSR_MIP, MIP_SSIP);\n}\n\nstatic void sbi_ipi_process_halt(struct sbi_scratch *scratch)\n{\n\tsbi_hsm_hart_stop(scratch, TRUE);\n}\n\nstatic struct sbi_ipi_event_ops ipi_halt_ops = {\n\t.name = \"IPI_HALT\",\n\t.process = sbi_ipi_process_halt,\n};\n\nstatic u32 ipi_halt_event = SBI_IPI_EVENT_MAX;\n\nint sbi_ipi_send_halt(ulong hmask, ulong hbase)\n{\n\treturn sbi_ipi_send_many(hmask, hbase, ipi_halt_event, NULL);\n}\n\nvoid sbi_ipi_process(void)\n{\n\tunsigned long ipi_type;\n\tunsigned int ipi_event;\n\tconst struct sbi_ipi_event_ops *ipi_ops;\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\tstruct sbi_ipi_data *ipi_data =\n\t\t\tsbi_scratch_offset_ptr(scratch, ipi_data_off);\n\tu32 hartid = current_hartid();\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_IPI_RECVD);\n\tif (ipi_dev && ipi_dev->ipi_clear)\n\t\tipi_dev->ipi_clear(hartid);\n\n\tipi_type = atomic_raw_xchg_ulong(&ipi_data->ipi_type, 0);\n\tipi_event = 0;\n\twhile (ipi_type) {\n\t\tif (!(ipi_type & 1UL))\n\t\t\tgoto skip;\n\n\t\tipi_ops = ipi_ops_array[ipi_event];\n\t\tif (ipi_ops && ipi_ops->process)\n\t\t\tipi_ops->process(scratch);\n\nskip:\n\t\tipi_type = ipi_type >> 1;\n\t\tipi_event++;\n\t};\n}\n\nint sbi_ipi_raw_send(u32 target_hart)\n{\n\tif (!ipi_dev || !ipi_dev->ipi_send)\n\t\treturn SBI_EINVAL;\n\n\tipi_dev->ipi_send(target_hart);\n\treturn 0;\n}\n\nconst struct sbi_ipi_device *sbi_ipi_get_device(void)\n{\n\treturn ipi_dev;\n}\n\nvoid sbi_ipi_set_device(const struct sbi_ipi_device *dev)\n{\n\tif (!dev || ipi_dev)\n\t\treturn;\n\n\tipi_dev = dev;\n}\n\nint sbi_ipi_init(struct sbi_scratch *scratch, bool cold_boot)\n{\n\tint ret;\n\tstruct sbi_ipi_data *ipi_data;\n\n\tif (cold_boot) {\n\t\tipi_data_off = sbi_scratch_alloc_offset(sizeof(*ipi_data));\n\t\tif (!ipi_data_off)\n\t\t\treturn SBI_ENOMEM;\n\t\tret = sbi_ipi_event_create(&ipi_smode_ops);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t\tipi_smode_event = ret;\n\t\tret = sbi_ipi_event_create(&ipi_halt_ops);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t\tipi_halt_event = ret;\n\t} else {\n\t\tif (!ipi_data_off)\n\t\t\treturn SBI_ENOMEM;\n\t\tif (SBI_IPI_EVENT_MAX <= ipi_smode_event ||\n\t\t    SBI_IPI_EVENT_MAX <= ipi_halt_event)\n\t\t\treturn SBI_ENOSPC;\n\t}\n\n\tipi_data = sbi_scratch_offset_ptr(scratch, ipi_data_off);\n\tipi_data->ipi_type = 0x00;\n\n\t/*\n\t * Initialize platform IPI support. This will also clear any\n\t * pending IPIs for current/calling HART.\n\t */\n\tret = sbi_platform_ipi_init(sbi_platform_ptr(scratch), cold_boot);\n\tif (ret)\n\t\treturn ret;\n\n\t/* Enable software interrupts */\n\tcsr_set(CSR_MIE, MIP_MSIP);\n\n\treturn 0;\n}\n\nvoid sbi_ipi_exit(struct sbi_scratch *scratch)\n{\n\t/* Disable software interrupts */\n\tcsr_clear(CSR_MIE, MIP_MSIP);\n\n\t/* Process pending IPIs */\n\tsbi_ipi_process();\n\n\t/* Platform exit */\n\tsbi_platform_ipi_exit(sbi_platform_ptr(scratch));\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_irqchip.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <apatel@ventanamicro.com>\n */\n\n#include <sbi/sbi_irqchip.h>\n#include <sbi/sbi_platform.h>\n\nstatic int default_irqfn(struct sbi_trap_regs *regs)\n{\n\treturn SBI_ENODEV;\n}\n\nstatic int (*ext_irqfn)(struct sbi_trap_regs *regs) = default_irqfn;\n\nvoid sbi_irqchip_set_irqfn(int (*fn)(struct sbi_trap_regs *regs))\n{\n\tif (fn)\n\t\text_irqfn = fn;\n}\n\nint sbi_irqchip_process(struct sbi_trap_regs *regs)\n{\n\treturn ext_irqfn(regs);\n}\n\nint sbi_irqchip_init(struct sbi_scratch *scratch, bool cold_boot)\n{\n\tint rc;\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\trc = sbi_platform_irqchip_init(plat, cold_boot);\n\tif (rc)\n\t\treturn rc;\n\n\tif (ext_irqfn != default_irqfn)\n\t\tcsr_set(CSR_MIE, MIP_MEIP);\n\n\treturn 0;\n}\n\nvoid sbi_irqchip_exit(struct sbi_scratch *scratch)\n{\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\tif (ext_irqfn != default_irqfn)\n\t\tcsr_clear(CSR_MIE, MIP_MEIP);\n\n\tsbi_platform_irqchip_exit(plat);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_math.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Common helper functions used across OpenSBI project.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\nunsigned long log2roundup(unsigned long x)\n{\n\tunsigned long ret = 0;\n\n\twhile (ret < __riscv_xlen) {\n\t\tif (x <= (1UL << ret))\n\t\t\tbreak;\n\t\tret++;\n\t}\n\n\treturn ret;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_misaligned_ldst.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/riscv_fp.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_misaligned_ldst.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_unpriv.h>\n\nunion reg_data {\n\tu8 data_bytes[8];\n\tulong data_ulong;\n\tu64 data_u64;\n};\n\nstatic ulong sbi_misaligned_tinst_fixup(ulong orig_tinst, ulong new_tinst,\n\t\t\t\t\tulong addr_offset)\n{\n\tif (new_tinst == INSN_PSEUDO_VS_LOAD ||\n\t    new_tinst == INSN_PSEUDO_VS_STORE)\n\t\treturn new_tinst;\n\telse if (orig_tinst == 0)\n\t\treturn 0UL;\n\telse\n\t\treturn orig_tinst | (addr_offset << SH_RS1);\n}\n\nint sbi_misaligned_load_handler(ulong addr, ulong tval2, ulong tinst,\n\t\t\t\tstruct sbi_trap_regs *regs)\n{\n\tulong insn, insn_len;\n\tunion reg_data val;\n\tstruct sbi_trap_info uptrap;\n\tint i, fp = 0, shift = 0, len = 0;\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_MISALIGNED_LOAD);\n\n\tif (tinst & 0x1) {\n\t\t/*\n\t\t * Bit[0] == 1 implies trapped instruction value is\n\t\t * transformed instruction or custom instruction.\n\t\t */\n\t\tinsn = tinst | INSN_16BIT_MASK;\n\t\tinsn_len = (tinst & 0x2) ? INSN_LEN(insn) : 2;\n\t} else {\n\t\t/*\n\t\t * Bit[0] == 0 implies trapped instruction value is\n\t\t * zero or special value.\n\t\t */\n\t\tinsn = sbi_get_insn(regs->mepc, &uptrap);\n\t\tif (uptrap.cause) {\n\t\t\tuptrap.epc = regs->mepc;\n\t\t\treturn sbi_trap_redirect(regs, &uptrap);\n\t\t}\n\t\tinsn_len = INSN_LEN(insn);\n\t}\n\n\tif ((insn & INSN_MASK_LW) == INSN_MATCH_LW) {\n\t\tlen   = 4;\n\t\tshift = 8 * (sizeof(ulong) - len);\n#if __riscv_xlen == 64\n\t} else if ((insn & INSN_MASK_LD) == INSN_MATCH_LD) {\n\t\tlen   = 8;\n\t\tshift = 8 * (sizeof(ulong) - len);\n\t} else if ((insn & INSN_MASK_LWU) == INSN_MATCH_LWU) {\n\t\tlen = 4;\n#endif\n#ifdef __riscv_flen\n\t} else if ((insn & INSN_MASK_FLD) == INSN_MATCH_FLD) {\n\t\tfp  = 1;\n\t\tlen = 8;\n\t} else if ((insn & INSN_MASK_FLW) == INSN_MATCH_FLW) {\n\t\tfp  = 1;\n\t\tlen = 4;\n#endif\n\t} else if ((insn & INSN_MASK_LH) == INSN_MATCH_LH) {\n\t\tlen   = 2;\n\t\tshift = 8 * (sizeof(ulong) - len);\n\t} else if ((insn & INSN_MASK_LHU) == INSN_MATCH_LHU) {\n\t\tlen = 2;\n#if __riscv_xlen >= 64\n\t} else if ((insn & INSN_MASK_C_LD) == INSN_MATCH_C_LD) {\n\t\tlen   = 8;\n\t\tshift = 8 * (sizeof(ulong) - len);\n\t\tinsn  = RVC_RS2S(insn) << SH_RD;\n\t} else if ((insn & INSN_MASK_C_LDSP) == INSN_MATCH_C_LDSP &&\n\t\t   ((insn >> SH_RD) & 0x1f)) {\n\t\tlen   = 8;\n\t\tshift = 8 * (sizeof(ulong) - len);\n#endif\n\t} else if ((insn & INSN_MASK_C_LW) == INSN_MATCH_C_LW) {\n\t\tlen   = 4;\n\t\tshift = 8 * (sizeof(ulong) - len);\n\t\tinsn  = RVC_RS2S(insn) << SH_RD;\n\t} else if ((insn & INSN_MASK_C_LWSP) == INSN_MATCH_C_LWSP &&\n\t\t   ((insn >> SH_RD) & 0x1f)) {\n\t\tlen   = 4;\n\t\tshift = 8 * (sizeof(ulong) - len);\n#ifdef __riscv_flen\n\t} else if ((insn & INSN_MASK_C_FLD) == INSN_MATCH_C_FLD) {\n\t\tfp   = 1;\n\t\tlen  = 8;\n\t\tinsn = RVC_RS2S(insn) << SH_RD;\n\t} else if ((insn & INSN_MASK_C_FLDSP) == INSN_MATCH_C_FLDSP) {\n\t\tfp  = 1;\n\t\tlen = 8;\n#if __riscv_xlen == 32\n\t} else if ((insn & INSN_MASK_C_FLW) == INSN_MATCH_C_FLW) {\n\t\tfp   = 1;\n\t\tlen  = 4;\n\t\tinsn = RVC_RS2S(insn) << SH_RD;\n\t} else if ((insn & INSN_MASK_C_FLWSP) == INSN_MATCH_C_FLWSP) {\n\t\tfp  = 1;\n\t\tlen = 4;\n#endif\n#endif\n\t} else {\n\t\tuptrap.epc = regs->mepc;\n\t\tuptrap.cause = CAUSE_MISALIGNED_LOAD;\n\t\tuptrap.tval = addr;\n\t\tuptrap.tval2 = tval2;\n\t\tuptrap.tinst = tinst;\n\t\tuptrap.gva   = sbi_regs_gva(regs);\n\t\treturn sbi_trap_redirect(regs, &uptrap);\n\t}\n\n\tval.data_u64 = 0;\n\tfor (i = 0; i < len; i++) {\n\t\tval.data_bytes[i] = sbi_load_u8((void *)(addr + i),\n\t\t\t\t\t\t&uptrap);\n\t\tif (uptrap.cause) {\n\t\t\tuptrap.epc = regs->mepc;\n\t\t\tuptrap.tinst = sbi_misaligned_tinst_fixup(\n\t\t\t\ttinst, uptrap.tinst, i);\n\t\t\treturn sbi_trap_redirect(regs, &uptrap);\n\t\t}\n\t}\n\n\tif (!fp)\n\t\tSET_RD(insn, regs, ((long)(val.data_ulong << shift)) >> shift);\n#ifdef __riscv_flen\n\telse if (len == 8)\n\t\tSET_F64_RD(insn, regs, val.data_u64);\n\telse\n\t\tSET_F32_RD(insn, regs, val.data_ulong);\n#endif\n\n\tregs->mepc += insn_len;\n\n\treturn 0;\n}\n\nint sbi_misaligned_store_handler(ulong addr, ulong tval2, ulong tinst,\n\t\t\t\t struct sbi_trap_regs *regs)\n{\n\tulong insn, insn_len;\n\tunion reg_data val;\n\tstruct sbi_trap_info uptrap;\n\tint i, len = 0;\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_MISALIGNED_STORE);\n\n\tif (tinst & 0x1) {\n\t\t/*\n\t\t * Bit[0] == 1 implies trapped instruction value is\n\t\t * transformed instruction or custom instruction.\n\t\t */\n\t\tinsn = tinst | INSN_16BIT_MASK;\n\t\tinsn_len = (tinst & 0x2) ? INSN_LEN(insn) : 2;\n\t} else {\n\t\t/*\n\t\t * Bit[0] == 0 implies trapped instruction value is\n\t\t * zero or special value.\n\t\t */\n\t\tinsn = sbi_get_insn(regs->mepc, &uptrap);\n\t\tif (uptrap.cause) {\n\t\t\tuptrap.epc = regs->mepc;\n\t\t\treturn sbi_trap_redirect(regs, &uptrap);\n\t\t}\n\t\tinsn_len = INSN_LEN(insn);\n\t}\n\n\tval.data_ulong = GET_RS2(insn, regs);\n\n\tif ((insn & INSN_MASK_SW) == INSN_MATCH_SW) {\n\t\tlen = 4;\n#if __riscv_xlen == 64\n\t} else if ((insn & INSN_MASK_SD) == INSN_MATCH_SD) {\n\t\tlen = 8;\n#endif\n#ifdef __riscv_flen\n\t} else if ((insn & INSN_MASK_FSD) == INSN_MATCH_FSD) {\n\t\tlen\t     = 8;\n\t\tval.data_u64 = GET_F64_RS2(insn, regs);\n\t} else if ((insn & INSN_MASK_FSW) == INSN_MATCH_FSW) {\n\t\tlen\t       = 4;\n\t\tval.data_ulong = GET_F32_RS2(insn, regs);\n#endif\n\t} else if ((insn & INSN_MASK_SH) == INSN_MATCH_SH) {\n\t\tlen = 2;\n#if __riscv_xlen >= 64\n\t} else if ((insn & INSN_MASK_C_SD) == INSN_MATCH_C_SD) {\n\t\tlen\t       = 8;\n\t\tval.data_ulong = GET_RS2S(insn, regs);\n\t} else if ((insn & INSN_MASK_C_SDSP) == INSN_MATCH_C_SDSP &&\n\t\t   ((insn >> SH_RD) & 0x1f)) {\n\t\tlen\t       = 8;\n\t\tval.data_ulong = GET_RS2C(insn, regs);\n#endif\n\t} else if ((insn & INSN_MASK_C_SW) == INSN_MATCH_C_SW) {\n\t\tlen\t       = 4;\n\t\tval.data_ulong = GET_RS2S(insn, regs);\n\t} else if ((insn & INSN_MASK_C_SWSP) == INSN_MATCH_C_SWSP &&\n\t\t   ((insn >> SH_RD) & 0x1f)) {\n\t\tlen\t       = 4;\n\t\tval.data_ulong = GET_RS2C(insn, regs);\n#ifdef __riscv_flen\n\t} else if ((insn & INSN_MASK_C_FSD) == INSN_MATCH_C_FSD) {\n\t\tlen\t     = 8;\n\t\tval.data_u64 = GET_F64_RS2S(insn, regs);\n\t} else if ((insn & INSN_MASK_C_FSDSP) == INSN_MATCH_C_FSDSP) {\n\t\tlen\t     = 8;\n\t\tval.data_u64 = GET_F64_RS2C(insn, regs);\n#if __riscv_xlen == 32\n\t} else if ((insn & INSN_MASK_C_FSW) == INSN_MATCH_C_FSW) {\n\t\tlen\t       = 4;\n\t\tval.data_ulong = GET_F32_RS2S(insn, regs);\n\t} else if ((insn & INSN_MASK_C_FSWSP) == INSN_MATCH_C_FSWSP) {\n\t\tlen\t       = 4;\n\t\tval.data_ulong = GET_F32_RS2C(insn, regs);\n#endif\n#endif\n\t} else {\n\t\tuptrap.epc = regs->mepc;\n\t\tuptrap.cause = CAUSE_MISALIGNED_STORE;\n\t\tuptrap.tval = addr;\n\t\tuptrap.tval2 = tval2;\n\t\tuptrap.tinst = tinst;\n\t\tuptrap.gva   = sbi_regs_gva(regs);\n\t\treturn sbi_trap_redirect(regs, &uptrap);\n\t}\n\n\tfor (i = 0; i < len; i++) {\n\t\tsbi_store_u8((void *)(addr + i), val.data_bytes[i],\n\t\t\t     &uptrap);\n\t\tif (uptrap.cause) {\n\t\t\tuptrap.epc = regs->mepc;\n\t\t\tuptrap.tinst = sbi_misaligned_tinst_fixup(\n\t\t\t\ttinst, uptrap.tinst, i);\n\t\t\treturn sbi_trap_redirect(regs, &uptrap);\n\t\t}\n\t}\n\n\tregs->mepc += insn_len;\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_platform.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_string.h>\n\nstatic inline char *sbi_platform_feature_id2string(unsigned long feature)\n{\n\tchar *fstr = NULL;\n\n\tif (!feature)\n\t\treturn NULL;\n\n\tswitch (feature) {\n\tcase SBI_PLATFORM_HAS_MFAULTS_DELEGATION:\n\t\tfstr = \"medeleg\";\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn fstr;\n}\n\nvoid sbi_platform_get_features_str(const struct sbi_platform *plat,\n\t\t\t\t   char *features_str, int nfstr)\n{\n\tunsigned long features, feat = 1UL;\n\tchar *temp;\n\tint offset = 0;\n\n\tif (!plat || !features_str || !nfstr)\n\t\treturn;\n\tsbi_memset(features_str, 0, nfstr);\n\n\tfeatures = sbi_platform_get_features(plat);\n\tif (!features)\n\t\tgoto done;\n\n\tdo {\n\t\tif (features & feat) {\n\t\t\ttemp = sbi_platform_feature_id2string(feat);\n\t\t\tif (temp) {\n\t\t\t\tint len = sbi_snprintf(features_str + offset,\n\t\t\t\t\t\t       nfstr - offset,\n\t\t\t\t\t\t       \"%s,\", temp);\n\t\t\t\tif (len < 0)\n\t\t\t\t\tbreak;\n\n\t\t\t\tif (offset + len >= nfstr) {\n\t\t\t\t\t/* No more space for features */\n\t\t\t\t\toffset = nfstr;\n\t\t\t\t\tbreak;\n\t\t\t\t} else\n\t\t\t\t\toffset = offset + len;\n\t\t\t}\n\t\t}\n\t\tfeat = feat << 1;\n\t} while (feat <= SBI_PLATFORM_HAS_LAST_FEATURE);\n\ndone:\n\tif (offset)\n\t\tfeatures_str[offset - 1] = '\\0';\n\telse\n\t\tsbi_strncpy(features_str, \"none\", nfstr);\n}\n\nu32 sbi_platform_hart_index(const struct sbi_platform *plat, u32 hartid)\n{\n\tu32 i;\n\n\tif (!plat)\n\t\treturn -1U;\n\tif (plat->hart_index2id) {\n\t\tfor (i = 0; i < plat->hart_count; i++) {\n\t\t\tif (plat->hart_index2id[i] == hartid)\n\t\t\t\treturn i;\n\t\t}\n\t\treturn -1U;\n\t}\n\n\treturn hartid;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_pmu.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_string.h>\n\n/** Information about hardware counters */\nstruct sbi_pmu_hw_event {\n\tuint32_t counters;\n\tuint32_t start_idx;\n\tuint32_t end_idx;\n\t/* Event selector value used only for raw events. The event select value\n\t * can be a even id or a selector value for set of events encoded in few\n\t * bits. In case latter, the bits used for encoding of the events should\n\t * be zeroed out in the select value.\n\t */\n\tuint64_t select;\n\t /**\n\t  * The select_mask indicates which bits are encoded for the event(s).\n\t  */\n\tuint64_t select_mask;\n};\n\n/* Information about PMU counters as per SBI specification */\nunion sbi_pmu_ctr_info {\n\tunsigned long value;\n\tstruct {\n\t\tunsigned long csr:12;\n\t\tunsigned long width:6;\n#if __riscv_xlen == 32\n\t\tunsigned long reserved:13;\n#else\n\t\tunsigned long reserved:45;\n#endif\n\t\tunsigned long type:1;\n\t};\n};\n\n/* Platform specific PMU device */\nstatic const struct sbi_pmu_device *pmu_dev = NULL;\n\n/* Mapping between event range and possible counters  */\nstatic struct sbi_pmu_hw_event hw_event_map[SBI_PMU_HW_EVENT_MAX] = {0};\n\n/* counter to enabled event mapping */\nstatic uint32_t active_events[SBI_HARTMASK_MAX_BITS][SBI_PMU_HW_CTR_MAX + SBI_PMU_FW_CTR_MAX];\n\n/* Bitmap of firmware counters started on each HART */\n#if SBI_PMU_FW_CTR_MAX >= BITS_PER_LONG\n#error \"Can't handle firmware counters beyond BITS_PER_LONG\"\n#endif\nstatic unsigned long fw_counters_started[SBI_HARTMASK_MAX_BITS];\n\n/* Values of firmwares counters on each HART */\nstatic uint64_t fw_counters_value[SBI_HARTMASK_MAX_BITS][SBI_PMU_FW_CTR_MAX] = {0};\n\n/* Maximum number of hardware events available */\nstatic uint32_t num_hw_events;\n/* Maximum number of hardware counters available */\nstatic uint32_t num_hw_ctrs;\n\n/* Maximum number of counters available */\nstatic uint32_t total_ctrs;\n\n/* Helper macros to retrieve event idx and code type */\n#define get_cidx_type(x) ((x & SBI_PMU_EVENT_IDX_TYPE_MASK) >> 16)\n#define get_cidx_code(x) (x & SBI_PMU_EVENT_IDX_CODE_MASK)\n\n/**\n * Perform a sanity check on event & counter mappings with event range overlap check\n * @param evtA Pointer to the existing hw event structure\n * @param evtB Pointer to the new hw event structure\n *\n * Return FALSE if the range doesn't overlap, TRUE otherwise\n */\nstatic bool pmu_event_range_overlap(struct sbi_pmu_hw_event *evtA,\n\t\t\t\t    struct sbi_pmu_hw_event *evtB)\n{\n\t/* check if the range of events overlap with a previous entry */\n\tif (((evtA->end_idx < evtB->start_idx) && (evtA->end_idx < evtB->end_idx)) ||\n\t   ((evtA->start_idx > evtB->start_idx) && (evtA->start_idx > evtB->end_idx)))\n\t\treturn FALSE;\n\treturn TRUE;\n}\n\nstatic bool pmu_event_select_overlap(struct sbi_pmu_hw_event *evt,\n\t\t\t\t     uint64_t select_val, uint64_t select_mask)\n{\n\tif ((evt->select == select_val) && (evt->select_mask == select_mask))\n\t\treturn TRUE;\n\n\treturn FALSE;\n}\n\nstatic int pmu_event_validate(unsigned long event_idx)\n{\n\tuint32_t event_idx_type = get_cidx_type(event_idx);\n\tuint32_t event_idx_code = get_cidx_code(event_idx);\n\tuint32_t event_idx_code_max = -1;\n\tuint32_t cache_ops_result, cache_ops_id, cache_id;\n\n\tswitch(event_idx_type) {\n\tcase SBI_PMU_EVENT_TYPE_HW:\n\t\tevent_idx_code_max = SBI_PMU_HW_GENERAL_MAX;\n\t\tbreak;\n\tcase SBI_PMU_EVENT_TYPE_FW:\n\t\tif (SBI_PMU_FW_MAX <= event_idx_code &&\n\t\t    pmu_dev && pmu_dev->fw_event_validate_code)\n\t\t\treturn pmu_dev->fw_event_validate_code(event_idx_code);\n\t\telse\n\t\t\tevent_idx_code_max = SBI_PMU_FW_MAX;\n\t\tbreak;\n\tcase SBI_PMU_EVENT_TYPE_HW_CACHE:\n\t\tcache_ops_result = event_idx_code &\n\t\t\t\t\tSBI_PMU_EVENT_HW_CACHE_OPS_RESULT;\n\t\tcache_ops_id = (event_idx_code &\n\t\t\t\tSBI_PMU_EVENT_HW_CACHE_OPS_ID_MASK) >>\n\t\t\t\tSBI_PMU_EVENT_HW_CACHE_OPS_ID_OFFSET;\n\t\tcache_id = (event_idx_code &\n\t\t\t    SBI_PMU_EVENT_HW_CACHE_ID_MASK) >>\n\t\t\t    SBI_PMU_EVENT_HW_CACHE_ID_OFFSET;\n\t\tif ((cache_ops_result < SBI_PMU_HW_CACHE_RESULT_MAX) &&\n\t\t    (cache_ops_id < SBI_PMU_HW_CACHE_OP_MAX) &&\n\t\t    (cache_id < SBI_PMU_HW_CACHE_MAX))\n\t\t\treturn event_idx_type;\n\t\telse\n\t\t\treturn SBI_EINVAL;\n\t\tbreak;\n\tcase SBI_PMU_EVENT_TYPE_HW_RAW:\n\t\tevent_idx_code_max = 1; // event_idx.code should be zero\n\t\tbreak;\n\tdefault:\n\t\treturn SBI_EINVAL;\n\t}\n\n\tif (event_idx_code < event_idx_code_max)\n\t\treturn event_idx_type;\n\n\treturn SBI_EINVAL;\n}\n\nstatic int pmu_ctr_validate(uint32_t cidx, uint32_t *event_idx_code)\n{\n\tuint32_t event_idx_val;\n\tuint32_t event_idx_type;\n\tu32 hartid = current_hartid();\n\n\tif (cidx >= total_ctrs)\n\t\treturn SBI_EINVAL;\n\n\tevent_idx_val = active_events[hartid][cidx];\n\tevent_idx_type = get_cidx_type(event_idx_val);\n\tif (event_idx_val == SBI_PMU_EVENT_IDX_INVALID ||\n\t    event_idx_type >= SBI_PMU_EVENT_TYPE_MAX)\n\t\treturn SBI_EINVAL;\n\n\t*event_idx_code = get_cidx_code(event_idx_val);\n\n\treturn event_idx_type;\n}\n\nint sbi_pmu_ctr_fw_read(uint32_t cidx, uint64_t *cval)\n{\n\tint event_idx_type;\n\tuint32_t event_code;\n\tu32 hartid = current_hartid();\n\n\tevent_idx_type = pmu_ctr_validate(cidx, &event_code);\n\tif (event_idx_type != SBI_PMU_EVENT_TYPE_FW)\n\t\treturn SBI_EINVAL;\n\n\tif (SBI_PMU_FW_MAX <= event_code &&\n\t    pmu_dev && pmu_dev->fw_counter_read_value)\n\t\tfw_counters_value[hartid][cidx - num_hw_ctrs] =\n\t\t\tpmu_dev->fw_counter_read_value(cidx - num_hw_ctrs);\n\n\t*cval = fw_counters_value[hartid][cidx - num_hw_ctrs];\n\n\treturn 0;\n}\n\nstatic int pmu_add_hw_event_map(u32 eidx_start, u32 eidx_end, u32 cmap,\n\t\t\t\tuint64_t select, uint64_t select_mask)\n{\n\tint i = 0;\n\tbool is_overlap;\n\tstruct sbi_pmu_hw_event *event = &hw_event_map[num_hw_events];\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\tint hw_ctr_avail = sbi_hart_mhpm_count(scratch);\n\tuint32_t ctr_avail_mask = ((uint32_t)(~0) >> (32 - (hw_ctr_avail + 3)));\n\n\t/* The first two counters are reserved by priv spec */\n\tif (eidx_start > SBI_PMU_HW_INSTRUCTIONS && (cmap & SBI_PMU_FIXED_CTR_MASK))\n\t\treturn SBI_EDENIED;\n\n\tif (num_hw_events >= SBI_PMU_HW_EVENT_MAX - 1) {\n\t\tsbi_printf(\"Can not handle more than %d perf events\\n\",\n\t\t\t    SBI_PMU_HW_EVENT_MAX);\n\t\treturn SBI_EFAIL;\n\t}\n\n\tevent->start_idx = eidx_start;\n\tevent->end_idx = eidx_end;\n\n\t/* Sanity check */\n\tfor (i = 0; i < num_hw_events; i++) {\n\t\tif (eidx_start == SBI_PMU_EVENT_RAW_IDX)\n\t\t/* All raw events have same event idx. Just do sanity check on select */\n\t\t\tis_overlap = pmu_event_select_overlap(&hw_event_map[i],\n\t\t\t\t\t\t\t      select, select_mask);\n\t\telse\n\t\t\tis_overlap = pmu_event_range_overlap(&hw_event_map[i], event);\n\t\tif (is_overlap)\n\t\t\tgoto reset_event;\n\t}\n\n\tevent->select_mask = select_mask;\n\t/* Map the only the counters that are available in the hardware */\n\tevent->counters = cmap & ctr_avail_mask;\n\tevent->select = select;\n\tnum_hw_events++;\n\n\treturn 0;\n\nreset_event:\n\tevent->start_idx = 0;\n\tevent->end_idx = 0;\n\treturn SBI_EINVAL;\n}\n\n/**\n * Logical counter ids are assigned to hardware counters are assigned consecutively.\n * E.g. counter0 must count MCYCLE where counter2 must count minstret. Similarly,\n * counterX will mhpmcounterX.\n */\nint sbi_pmu_add_hw_event_counter_map(u32 eidx_start, u32 eidx_end, u32 cmap)\n{\n\tif ((eidx_start > eidx_end) || eidx_start == SBI_PMU_EVENT_RAW_IDX ||\n\t     eidx_end == SBI_PMU_EVENT_RAW_IDX)\n\t\treturn SBI_EINVAL;\n\n\treturn pmu_add_hw_event_map(eidx_start, eidx_end, cmap, 0, 0);\n}\n\nint sbi_pmu_add_raw_event_counter_map(uint64_t select, uint64_t select_mask, u32 cmap)\n{\n\treturn pmu_add_hw_event_map(SBI_PMU_EVENT_RAW_IDX,\n\t\t\t\t    SBI_PMU_EVENT_RAW_IDX, cmap, select, select_mask);\n}\n\nstatic int pmu_ctr_enable_irq_hw(int ctr_idx)\n{\n\tunsigned long mhpmevent_csr;\n\tunsigned long mhpmevent_curr;\n\tunsigned long mip_val;\n\tunsigned long of_mask;\n\n\tif (ctr_idx < 3 || ctr_idx >= SBI_PMU_HW_CTR_MAX)\n\t\treturn SBI_EFAIL;\n\n#if __riscv_xlen == 32\n\tmhpmevent_csr = CSR_MHPMEVENT3H  + ctr_idx - 3;\n\tof_mask = (uint32_t)~MHPMEVENTH_OF;\n#else\n\tmhpmevent_csr = CSR_MHPMEVENT3 + ctr_idx - 3;\n\tof_mask = ~MHPMEVENT_OF;\n#endif\n\n\tmhpmevent_curr = csr_read_num(mhpmevent_csr);\n\tmip_val = csr_read(CSR_MIP);\n\t/**\n\t * Clear out the OF bit so that next interrupt can be enabled.\n\t * This should be done only when the corresponding overflow interrupt\n\t * bit is cleared. That indicates that software has already handled the\n\t * previous interrupts or the hardware yet to set an overflow interrupt.\n\t * Otherwise, there will be race conditions where we may clear the bit\n\t * the software is yet to handle the interrupt.\n\t */\n\tif (!(mip_val & MIP_LCOFIP)) {\n\t\tmhpmevent_curr &= of_mask;\n\t\tcsr_write_num(mhpmevent_csr, mhpmevent_curr);\n\t}\n\n\treturn 0;\n}\n\nstatic void pmu_ctr_write_hw(uint32_t cidx, uint64_t ival)\n{\n#if __riscv_xlen == 32\n\tcsr_write_num(CSR_MCYCLE + cidx, 0);\n\tcsr_write_num(CSR_MCYCLE + cidx, ival & 0xFFFFFFFF);\n\tcsr_write_num(CSR_MCYCLEH + cidx, ival >> BITS_PER_LONG);\n#else\n\tcsr_write_num(CSR_MCYCLE + cidx, ival);\n#endif\n}\n\nstatic int pmu_ctr_start_hw(uint32_t cidx, uint64_t ival, bool ival_update)\n{\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\tunsigned long mctr_inhbt;\n\n\t/* Make sure the counter index lies within the range and is not TM bit */\n\tif (cidx >= num_hw_ctrs || cidx == 1)\n\t\treturn SBI_EINVAL;\n\n\tif (sbi_hart_priv_version(scratch) < SBI_HART_PRIV_VER_1_11)\n\t\tgoto skip_inhibit_update;\n\n\t/*\n\t * Some of the hardware may not support mcountinhibit but perf stat\n\t * still can work if supervisor mode programs the initial value.\n\t */\n\tmctr_inhbt = csr_read(CSR_MCOUNTINHIBIT);\n\tif (!__test_bit(cidx, &mctr_inhbt))\n\t\treturn SBI_EALREADY_STARTED;\n\n\t__clear_bit(cidx, &mctr_inhbt);\n\n\tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))\n\t\tpmu_ctr_enable_irq_hw(cidx);\n\tif (pmu_dev && pmu_dev->hw_counter_enable_irq)\n\t\tpmu_dev->hw_counter_enable_irq(cidx);\n\tcsr_write(CSR_MCOUNTINHIBIT, mctr_inhbt);\n\nskip_inhibit_update:\n\tif (ival_update)\n\t\tpmu_ctr_write_hw(cidx, ival);\n\n\treturn 0;\n}\n\nint sbi_pmu_irq_bit(void)\n{\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\n\tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))\n\t\treturn MIP_LCOFIP;\n\tif (pmu_dev && pmu_dev->hw_counter_irq_bit)\n\t\treturn pmu_dev->hw_counter_irq_bit();\n\n\treturn 0;\n}\n\nstatic int pmu_ctr_start_fw(uint32_t cidx, uint32_t event_code,\n\t\t\t    uint64_t ival, bool ival_update)\n{\n\tint ret;\n\tu32 hartid = current_hartid();\n\n\tif (SBI_PMU_FW_MAX <= event_code &&\n\t    pmu_dev && pmu_dev->fw_counter_start) {\n\t\tret = pmu_dev->fw_counter_start(cidx - num_hw_ctrs,\n\t\t\t\t\t\tevent_code,\n\t\t\t\t\t\tival, ival_update);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tif (ival_update)\n\t\tfw_counters_value[hartid][cidx - num_hw_ctrs] = ival;\n\tfw_counters_started[hartid] |= BIT(cidx - num_hw_ctrs);\n\n\treturn 0;\n}\n\nint sbi_pmu_ctr_start(unsigned long cbase, unsigned long cmask,\n\t\t      unsigned long flags, uint64_t ival)\n{\n\tint event_idx_type;\n\tuint32_t event_code;\n\tint ret = SBI_EINVAL;\n\tbool bUpdate = FALSE;\n\tint i, cidx;\n\n\tif ((cbase + sbi_fls(cmask)) >= total_ctrs)\n\t\treturn ret;\n\n\tif (flags & SBI_PMU_START_FLAG_SET_INIT_VALUE)\n\t\tbUpdate = TRUE;\n\n\tfor_each_set_bit(i, &cmask, total_ctrs) {\n\t\tcidx = i + cbase;\n\t\tevent_idx_type = pmu_ctr_validate(cidx, &event_code);\n\t\tif (event_idx_type < 0)\n\t\t\t/* Continue the start operation for other counters */\n\t\t\tcontinue;\n\t\telse if (event_idx_type == SBI_PMU_EVENT_TYPE_FW)\n\t\t\tret = pmu_ctr_start_fw(cidx, event_code, ival, bUpdate);\n\t\telse\n\t\t\tret = pmu_ctr_start_hw(cidx, ival, bUpdate);\n\t}\n\n\treturn ret;\n}\n\nstatic int pmu_ctr_stop_hw(uint32_t cidx)\n{\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\tunsigned long mctr_inhbt;\n\n\tif (sbi_hart_priv_version(scratch) < SBI_HART_PRIV_VER_1_11)\n\t\treturn 0;\n\n\tmctr_inhbt = csr_read(CSR_MCOUNTINHIBIT);\n\n\t/* Make sure the counter index lies within the range and is not TM bit */\n\tif (cidx >= num_hw_ctrs || cidx == 1)\n\t\treturn SBI_EINVAL;\n\n\tif (!__test_bit(cidx, &mctr_inhbt)) {\n\t\t__set_bit(cidx, &mctr_inhbt);\n\t\tcsr_write(CSR_MCOUNTINHIBIT, mctr_inhbt);\n\t\treturn 0;\n\t} else\n\t\treturn SBI_EALREADY_STOPPED;\n}\n\nstatic int pmu_ctr_stop_fw(uint32_t cidx, uint32_t event_code)\n{\n\tint ret;\n\n\tif (SBI_PMU_FW_MAX <= event_code &&\n\t    pmu_dev && pmu_dev->fw_counter_stop) {\n\t\tret = pmu_dev->fw_counter_stop(cidx - num_hw_ctrs);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tfw_counters_started[current_hartid()] &= ~BIT(cidx - num_hw_ctrs);\n\n\treturn 0;\n}\n\nstatic int pmu_reset_hw_mhpmevent(int ctr_idx)\n{\n\tif (ctr_idx < 3 || ctr_idx >= SBI_PMU_HW_CTR_MAX)\n\t\treturn SBI_EFAIL;\n#if __riscv_xlen == 32\n\tcsr_write_num(CSR_MHPMEVENT3 + ctr_idx - 3, 0);\n\tif (sbi_hart_has_extension(sbi_scratch_thishart_ptr(),\n\t\t\t\t   SBI_HART_EXT_SSCOFPMF))\n\t\tcsr_write_num(CSR_MHPMEVENT3H + ctr_idx - 3, 0);\n#else\n\tcsr_write_num(CSR_MHPMEVENT3 + ctr_idx - 3, 0);\n#endif\n\n\treturn 0;\n}\n\nint sbi_pmu_ctr_stop(unsigned long cbase, unsigned long cmask,\n\t\t     unsigned long flag)\n{\n\tu32 hartid = current_hartid();\n\tint ret = SBI_EINVAL;\n\tint event_idx_type;\n\tuint32_t event_code;\n\tint i, cidx;\n\n\tif ((cbase + sbi_fls(cmask)) >= total_ctrs)\n\t\treturn SBI_EINVAL;\n\n\tfor_each_set_bit(i, &cmask, total_ctrs) {\n\t\tcidx = i + cbase;\n\t\tevent_idx_type = pmu_ctr_validate(cidx, &event_code);\n\t\tif (event_idx_type < 0)\n\t\t\t/* Continue the stop operation for other counters */\n\t\t\tcontinue;\n\n\t\telse if (event_idx_type == SBI_PMU_EVENT_TYPE_FW)\n\t\t\tret = pmu_ctr_stop_fw(cidx, event_code);\n\t\telse\n\t\t\tret = pmu_ctr_stop_hw(cidx);\n\n\t\tif (flag & SBI_PMU_STOP_FLAG_RESET) {\n\t\t\tactive_events[hartid][cidx] = SBI_PMU_EVENT_IDX_INVALID;\n\t\t\tpmu_reset_hw_mhpmevent(cidx);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\nstatic void pmu_update_inhibit_flags(unsigned long flags, uint64_t *mhpmevent_val)\n{\n\tif (flags & SBI_PMU_CFG_FLAG_SET_VUINH)\n\t\t*mhpmevent_val |= MHPMEVENT_VUINH;\n\tif (flags & SBI_PMU_CFG_FLAG_SET_VSINH)\n\t\t*mhpmevent_val |= MHPMEVENT_VSINH;\n\tif (flags & SBI_PMU_CFG_FLAG_SET_UINH)\n\t\t*mhpmevent_val |= MHPMEVENT_UINH;\n\tif (flags & SBI_PMU_CFG_FLAG_SET_SINH)\n\t\t*mhpmevent_val |= MHPMEVENT_SINH;\n}\n\nstatic int pmu_update_hw_mhpmevent(struct sbi_pmu_hw_event *hw_evt, int ctr_idx,\n\t\t\t\t   unsigned long flags, unsigned long eindex,\n\t\t\t\t   uint64_t data)\n{\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\tuint64_t mhpmevent_val;\n\n\t/* Get the final mhpmevent value to be written from platform */\n\tmhpmevent_val = sbi_platform_pmu_xlate_to_mhpmevent(plat, eindex, data);\n\n\tif (!mhpmevent_val || ctr_idx < 3 || ctr_idx >= SBI_PMU_HW_CTR_MAX)\n\t\treturn SBI_EFAIL;\n\n\t/**\n\t * Always set the OVF bit(disable interrupts) and inhibit counting of\n\t * events in M-mode. The OVF bit should be enabled during the start call.\n\t */\n\tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))\n\t\tmhpmevent_val = (mhpmevent_val & ~MHPMEVENT_SSCOF_MASK) |\n\t\t\t\t MHPMEVENT_MINH | MHPMEVENT_OF;\n\n\tif (pmu_dev && pmu_dev->hw_counter_disable_irq)\n\t\tpmu_dev->hw_counter_disable_irq(ctr_idx);\n\n\t/* Update the inhibit flags based on inhibit flags received from supervisor */\n\tpmu_update_inhibit_flags(flags, &mhpmevent_val);\n\n#if __riscv_xlen == 32\n\tcsr_write_num(CSR_MHPMEVENT3 + ctr_idx - 3, mhpmevent_val & 0xFFFFFFFF);\n\tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))\n\t\tcsr_write_num(CSR_MHPMEVENT3H + ctr_idx - 3,\n\t\t\t      mhpmevent_val >> BITS_PER_LONG);\n#else\n\tcsr_write_num(CSR_MHPMEVENT3 + ctr_idx - 3, mhpmevent_val);\n#endif\n\n\treturn 0;\n}\n\nstatic int pmu_ctr_find_fixed_fw(unsigned long evt_idx_code)\n{\n\t/* Non-programmables counters are enabled always. No need to do lookup */\n\tif (evt_idx_code == SBI_PMU_HW_CPU_CYCLES)\n\t\treturn 0;\n\telse if (evt_idx_code == SBI_PMU_HW_INSTRUCTIONS)\n\t\treturn 2;\n\telse\n\t\treturn SBI_EINVAL;\n}\n\nstatic int pmu_ctr_find_hw(unsigned long cbase, unsigned long cmask, unsigned long flags,\n\t\t\t   unsigned long event_idx, uint64_t data)\n{\n\tunsigned long ctr_mask;\n\tint i, ret = 0, fixed_ctr, ctr_idx = SBI_ENOTSUPP;\n\tstruct sbi_pmu_hw_event *temp;\n\tunsigned long mctr_inhbt = 0;\n\tu32 hartid = current_hartid();\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\n\tif (cbase >= num_hw_ctrs)\n\t\treturn SBI_EINVAL;\n\n\t/**\n\t * If Sscof is present try to find the programmable counter for\n\t * cycle/instret as well.\n\t */\n\tfixed_ctr = pmu_ctr_find_fixed_fw(event_idx);\n\tif (fixed_ctr >= 0 &&\n\t    !sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))\n\t\treturn fixed_ctr;\n\n\tif (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_11)\n\t\tmctr_inhbt = csr_read(CSR_MCOUNTINHIBIT);\n\tfor (i = 0; i < num_hw_events; i++) {\n\t\ttemp = &hw_event_map[i];\n\t\tif ((temp->start_idx > event_idx && event_idx < temp->end_idx) ||\n\t\t    (temp->start_idx < event_idx && event_idx > temp->end_idx))\n\t\t\tcontinue;\n\n\t\t/* For raw events, event data is used as the select value */\n\t\tif (event_idx == SBI_PMU_EVENT_RAW_IDX) {\n\t\t\tuint64_t select_mask = temp->select_mask;\n\n\t\t\t/* The non-event map bits of data should match the selector */\n\t\t\tif (temp->select != (data & select_mask))\n\t\t\t\tcontinue;\n\t\t}\n\t\t/* Fixed counters should not be part of the search */\n\t\tctr_mask = temp->counters & (cmask << cbase) &\n\t\t\t   (~SBI_PMU_FIXED_CTR_MASK);\n\t\tfor_each_set_bit_from(cbase, &ctr_mask, SBI_PMU_HW_CTR_MAX) {\n\t\t\t/**\n\t\t\t * Some of the platform may not support mcountinhibit.\n\t\t\t * Checking the active_events is enough for them\n\t\t\t */\n\t\t\tif (active_events[hartid][cbase] != SBI_PMU_EVENT_IDX_INVALID)\n\t\t\t\tcontinue;\n\t\t\t/* If mcountinhibit is supported, the bit must be enabled */\n\t\t\tif ((sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_11) &&\n\t\t\t    !__test_bit(cbase, &mctr_inhbt))\n\t\t\t\tcontinue;\n\t\t\t/* We found a valid counter that is not started yet */\n\t\t\tctr_idx = cbase;\n\t\t}\n\t}\n\n\tif (ctr_idx == SBI_ENOTSUPP) {\n\t\t/**\n\t\t * We can't find any programmable counters for cycle/instret.\n\t\t * Return the fixed counter as they are mandatory anyways.\n\t\t */\n\t\tif (fixed_ctr >= 0)\n\t\t\treturn fixed_ctr;\n\t\telse\n\t\t\treturn SBI_EFAIL;\n\t}\n\tret = pmu_update_hw_mhpmevent(temp, ctr_idx, flags, event_idx, data);\n\n\tif (!ret)\n\t\tret = ctr_idx;\n\n\treturn ret;\n}\n\n\n/**\n * Any firmware counter can map to any firmware event.\n * Thus, select the first available fw counter after sanity\n * check.\n */\nstatic int pmu_ctr_find_fw(unsigned long cbase, unsigned long cmask,\n\t\t\t   uint32_t event_code, u32 hartid)\n{\n\tint i, cidx;\n\n\tfor_each_set_bit(i, &cmask, BITS_PER_LONG) {\n\t\tcidx = i + cbase;\n\t\tif (cidx < num_hw_ctrs || total_ctrs <= cidx)\n\t\t\tcontinue;\n\t\tif (active_events[hartid][i] != SBI_PMU_EVENT_IDX_INVALID)\n\t\t\tcontinue;\n\t\tif (SBI_PMU_FW_MAX <= event_code &&\n\t\t    pmu_dev && pmu_dev->fw_counter_match_code) {\n\t\t\tif (!pmu_dev->fw_counter_match_code(cidx - num_hw_ctrs,\n\t\t\t\t\t\t\t    event_code))\n\t\t\t\tcontinue;\n\t\t}\n\n\t\treturn i;\n\t}\n\n\treturn SBI_ENOTSUPP;\n}\n\nint sbi_pmu_ctr_cfg_match(unsigned long cidx_base, unsigned long cidx_mask,\n\t\t\t  unsigned long flags, unsigned long event_idx,\n\t\t\t  uint64_t event_data)\n{\n\tint ret, ctr_idx = SBI_ENOTSUPP;\n\tu32 event_code, hartid = current_hartid();\n\tint event_type;\n\n\t/* Do a basic sanity check of counter base & mask */\n\tif ((cidx_base + sbi_fls(cidx_mask)) >= total_ctrs)\n\t\treturn SBI_EINVAL;\n\n\tevent_type = pmu_event_validate(event_idx);\n\tif (event_type < 0)\n\t\treturn SBI_EINVAL;\n\tevent_code = get_cidx_code(event_idx);\n\n\tif (flags & SBI_PMU_CFG_FLAG_SKIP_MATCH) {\n\t\t/* The caller wants to skip the match because it already knows the\n\t\t * counter idx for the given event. Verify that the counter idx\n\t\t * is still valid.\n\t\t */\n\t\tif (active_events[hartid][cidx_base] == SBI_PMU_EVENT_IDX_INVALID)\n\t\t\treturn SBI_EINVAL;\n\t\tctr_idx = cidx_base;\n\t\tgoto skip_match;\n\t}\n\n\tif (event_type == SBI_PMU_EVENT_TYPE_FW) {\n\t\t/* Any firmware counter can be used track any firmware event */\n\t\tctr_idx = pmu_ctr_find_fw(cidx_base, cidx_mask, event_code, hartid);\n\t} else {\n\t\tctr_idx = pmu_ctr_find_hw(cidx_base, cidx_mask, flags, event_idx,\n\t\t\t\t\t  event_data);\n\t}\n\n\tif (ctr_idx < 0)\n\t\treturn SBI_ENOTSUPP;\n\n\tactive_events[hartid][ctr_idx] = event_idx;\nskip_match:\n\tif (event_type == SBI_PMU_EVENT_TYPE_HW) {\n\t\tif (flags & SBI_PMU_CFG_FLAG_CLEAR_VALUE)\n\t\t\tpmu_ctr_write_hw(ctr_idx, 0);\n\t\tif (flags & SBI_PMU_CFG_FLAG_AUTO_START)\n\t\t\tpmu_ctr_start_hw(ctr_idx, 0, false);\n\t} else if (event_type == SBI_PMU_EVENT_TYPE_FW) {\n\t\tif (flags & SBI_PMU_CFG_FLAG_CLEAR_VALUE)\n\t\t\tfw_counters_value[hartid][ctr_idx - num_hw_ctrs] = 0;\n\t\tif (flags & SBI_PMU_CFG_FLAG_AUTO_START) {\n\t\t\tif (SBI_PMU_FW_MAX <= event_code &&\n\t\t\t    pmu_dev && pmu_dev->fw_counter_start) {\n\t\t\t\tret = pmu_dev->fw_counter_start(\n\t\t\t\t\tctr_idx - num_hw_ctrs, event_code,\n\t\t\t\t\tfw_counters_value[hartid][ctr_idx - num_hw_ctrs],\n\t\t\t\t\ttrue);\n\t\t\t\tif (ret)\n\t\t\t\t\treturn ret;\n\t\t\t}\n\t\t\tfw_counters_started[hartid] |= BIT(ctr_idx - num_hw_ctrs);\n\t\t}\n\t}\n\n\treturn ctr_idx;\n}\n\nint sbi_pmu_ctr_incr_fw(enum sbi_pmu_fw_event_code_id fw_id)\n{\n\tu32 cidx, hartid = current_hartid();\n\tuint64_t *fcounter = NULL;\n\n\tif (likely(!fw_counters_started[hartid]))\n\t\treturn 0;\n\n\tif (unlikely(fw_id >= SBI_PMU_FW_MAX))\n\t\treturn SBI_EINVAL;\n\n\tfor (cidx = num_hw_ctrs; cidx < total_ctrs; cidx++) {\n\t\tif (get_cidx_code(active_events[hartid][cidx]) == fw_id &&\n\t\t    (fw_counters_started[hartid] & BIT(cidx - num_hw_ctrs))) {\n\t\t\tfcounter = &fw_counters_value[hartid][cidx - num_hw_ctrs];\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (fcounter)\n\t\t(*fcounter)++;\n\n\treturn 0;\n}\n\nunsigned long sbi_pmu_num_ctr(void)\n{\n\treturn (num_hw_ctrs + SBI_PMU_FW_CTR_MAX);\n}\n\nint sbi_pmu_ctr_get_info(uint32_t cidx, unsigned long *ctr_info)\n{\n\tunion sbi_pmu_ctr_info cinfo = {0};\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\n\t/* Sanity check. Counter1 is not mapped at all */\n\tif (cidx >= total_ctrs || cidx == 1)\n\t\treturn SBI_EINVAL;\n\n\t/* We have 31 HW counters with 31 being the last index(MHPMCOUNTER31) */\n\tif (cidx < num_hw_ctrs) {\n\t\tcinfo.type = SBI_PMU_CTR_TYPE_HW;\n\t\tcinfo.csr = CSR_CYCLE + cidx;\n\t\t/* mcycle & minstret are always 64 bit */\n\t\tif (cidx == 0 || cidx == 2)\n\t\t\tcinfo.width = 63;\n\t\telse\n\t\t\tcinfo.width = sbi_hart_mhpm_bits(scratch) - 1;\n\t} else {\n\t\t/* it's a firmware counter */\n\t\tcinfo.type = SBI_PMU_CTR_TYPE_FW;\n\t\t/* Firmware counters are always 64 bits wide */\n\t\tcinfo.width = 63;\n\t}\n\n\t*ctr_info = cinfo.value;\n\n\treturn 0;\n}\n\nstatic void pmu_reset_event_map(u32 hartid)\n{\n\tint j;\n\n\t/* Initialize the counter to event mapping table */\n\tfor (j = 3; j < total_ctrs; j++)\n\t\tactive_events[hartid][j] = SBI_PMU_EVENT_IDX_INVALID;\n\tfor (j = 0; j < SBI_PMU_FW_CTR_MAX; j++)\n\t\tfw_counters_value[hartid][j] = 0;\n\tfw_counters_started[hartid] = 0;\n}\n\nconst struct sbi_pmu_device *sbi_pmu_get_device(void)\n{\n\treturn pmu_dev;\n}\n\nvoid sbi_pmu_set_device(const struct sbi_pmu_device *dev)\n{\n\tif (!dev || pmu_dev)\n\t\treturn;\n\n\tpmu_dev = dev;\n}\n\nvoid sbi_pmu_exit(struct sbi_scratch *scratch)\n{\n\tu32 hartid = current_hartid();\n\n\tif (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_11)\n\t\tcsr_write(CSR_MCOUNTINHIBIT, 0xFFFFFFF8);\n\n\tif (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_10)\n\t\tcsr_write(CSR_MCOUNTEREN, -1);\n\tpmu_reset_event_map(hartid);\n}\n\nint sbi_pmu_init(struct sbi_scratch *scratch, bool cold_boot)\n{\n\tconst struct sbi_platform *plat;\n\tu32 hartid = current_hartid();\n\n\tif (cold_boot) {\n\t\tplat = sbi_platform_ptr(scratch);\n\t\t/* Initialize hw pmu events */\n\t\tsbi_platform_pmu_init(plat);\n\n\t\t/* mcycle & minstret is available always */\n\t\tnum_hw_ctrs = sbi_hart_mhpm_count(scratch) + 3;\n\t\ttotal_ctrs = num_hw_ctrs + SBI_PMU_FW_CTR_MAX;\n\t}\n\n\tpmu_reset_event_map(hartid);\n\n\t/* First three counters are fixed by the priv spec and we enable it by default */\n\tactive_events[hartid][0] = SBI_PMU_EVENT_TYPE_HW << SBI_PMU_EVENT_IDX_OFFSET |\n\t\t\t\t   SBI_PMU_HW_CPU_CYCLES;\n\tactive_events[hartid][1] = SBI_PMU_EVENT_IDX_INVALID;\n\tactive_events[hartid][2] = SBI_PMU_EVENT_TYPE_HW << SBI_PMU_EVENT_IDX_OFFSET |\n\t\t\t\t   SBI_PMU_HW_INSTRUCTIONS;\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_scratch.c",
    "content": " /*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_locks.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_string.h>\n\nu32 last_hartid_having_scratch = SBI_HARTMASK_MAX_BITS - 1;\nstruct sbi_scratch *hartid_to_scratch_table[SBI_HARTMASK_MAX_BITS] = { 0 };\n\nstatic spinlock_t extra_lock = SPIN_LOCK_INITIALIZER;\nstatic unsigned long extra_offset = SBI_SCRATCH_EXTRA_SPACE_OFFSET;\n\ntypedef struct sbi_scratch *(*hartid2scratch)(ulong hartid, ulong hartindex);\n\nint sbi_scratch_init(struct sbi_scratch *scratch)\n{\n\tu32 i;\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\tfor (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {\n\t\tif (sbi_platform_hart_invalid(plat, i))\n\t\t\tcontinue;\n\t\thartid_to_scratch_table[i] =\n\t\t\t((hartid2scratch)scratch->hartid_to_scratch)(i,\n\t\t\t\t\tsbi_platform_hart_index(plat, i));\n\t\tif (hartid_to_scratch_table[i])\n\t\t\tlast_hartid_having_scratch = i;\n\t}\n\n\treturn 0;\n}\n\nunsigned long sbi_scratch_alloc_offset(unsigned long size)\n{\n\tu32 i;\n\tvoid *ptr;\n\tunsigned long ret = 0;\n\tstruct sbi_scratch *rscratch;\n\n\t/*\n\t * We have a simple brain-dead allocator which never expects\n\t * anything to be free-ed hence it keeps incrementing the\n\t * next allocation offset until it runs-out of space.\n\t *\n\t * In future, we will have more sophisticated allocator which\n\t * will allow us to re-claim free-ed space.\n\t */\n\n\tif (!size)\n\t\treturn 0;\n\n\tif (size & (__SIZEOF_POINTER__ - 1))\n\t\tsize = (size & ~(__SIZEOF_POINTER__ - 1)) + __SIZEOF_POINTER__;\n\n\tspin_lock(&extra_lock);\n\n\tif (SBI_SCRATCH_SIZE < (extra_offset + size))\n\t\tgoto done;\n\n\tret = extra_offset;\n\textra_offset += size;\n\ndone:\n\tspin_unlock(&extra_lock);\n\n\tif (ret) {\n\t\tfor (i = 0; i <= sbi_scratch_last_hartid(); i++) {\n\t\t\trscratch = sbi_hartid_to_scratch(i);\n\t\t\tif (!rscratch)\n\t\t\t\tcontinue;\n\t\t\tptr = sbi_scratch_offset_ptr(rscratch, ret);\n\t\t\tsbi_memset(ptr, 0, size);\n\t\t}\n\t}\n\n\treturn ret;\n}\n\nvoid sbi_scratch_free_offset(unsigned long offset)\n{\n\tif ((offset < SBI_SCRATCH_EXTRA_SPACE_OFFSET) ||\n\t    (SBI_SCRATCH_SIZE <= offset))\n\t\treturn;\n\n\t/*\n\t * We don't actually free-up because it's a simple\n\t * brain-dead allocator.\n\t */\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_string.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n */\n\n/*\n * Simple libc functions. These are not optimized at all and might have some\n * bugs as well. Use any optimized routines from newlib or glibc if required.\n */\n\n#include <sbi/sbi_string.h>\n\n/*\n  Provides sbi_strcmp for the completeness of supporting string functions.\n  it is not recommended to use sbi_strcmp() but use sbi_strncmp instead.\n*/\nint sbi_strcmp(const char *a, const char *b)\n{\n\t/* search first diff or end of string */\n\tfor (; *a == *b && *a != '\\0'; a++, b++)\n\t\t;\n\n\treturn *a - *b;\n}\n\nint sbi_strncmp(const char *a, const char *b, size_t count)\n{\n\t/* search first diff or end of string */\n\tfor (; count > 0 && *a == *b && *a != '\\0'; a++, b++, count--)\n\t\t;\n\n\t/* No difference till the end */\n\tif (!count)\n\t\treturn 0;\n\n\treturn *a - *b;\n}\n\nsize_t sbi_strlen(const char *str)\n{\n\tunsigned long ret = 0;\n\n\twhile (*str != '\\0') {\n\t\tret++;\n\t\tstr++;\n\t}\n\n\treturn ret;\n}\n\nsize_t sbi_strnlen(const char *str, size_t count)\n{\n\tunsigned long ret = 0;\n\n\twhile (*str != '\\0' && ret < count) {\n\t\tret++;\n\t\tstr++;\n\t}\n\n\treturn ret;\n}\n\nchar *sbi_strcpy(char *dest, const char *src)\n{\n\tchar *ret = dest;\n\n\twhile (*src != '\\0') {\n\t\t*dest++ = *src++;\n\t}\n\n\treturn ret;\n}\n\nchar *sbi_strncpy(char *dest, const char *src, size_t count)\n{\n\tchar *ret = dest;\n\n\twhile (count-- && *src != '\\0') {\n\t\t*dest++ = *src++;\n\t}\n\n\treturn ret;\n}\n\nchar *sbi_strchr(const char *s, int c)\n{\n\twhile (*s != '\\0' && *s != (char)c)\n\t\ts++;\n\n\tif (*s == '\\0')\n\t\treturn NULL;\n\telse\n\t\treturn (char *)s;\n}\n\nchar *sbi_strrchr(const char *s, int c)\n{\n\tconst char *last = s + sbi_strlen(s);\n\n\twhile (last > s && *last != (char)c)\n\t\tlast--;\n\n\tif (*last != (char)c)\n\t\treturn NULL;\n\telse\n\t\treturn (char *)last;\n}\nvoid *sbi_memset(void *s, int c, size_t count)\n{\n\tchar *temp = s;\n\n\twhile (count > 0) {\n\t\tcount--;\n\t\t*temp++ = c;\n\t}\n\n\treturn s;\n}\n\nvoid *sbi_memcpy(void *dest, const void *src, size_t count)\n{\n\tchar *temp1\t  = dest;\n\tconst char *temp2 = src;\n\n\twhile (count > 0) {\n\t\t*temp1++ = *temp2++;\n\t\tcount--;\n\t}\n\n\treturn dest;\n}\n\nvoid *sbi_memmove(void *dest, const void *src, size_t count)\n{\n\tchar *temp1\t  = (char *)dest;\n\tconst char *temp2 = (char *)src;\n\n\tif (src == dest)\n\t\treturn dest;\n\n\tif (dest < src) {\n\t\twhile (count > 0) {\n\t\t\t*temp1++ = *temp2++;\n\t\t\tcount--;\n\t\t}\n\t} else {\n\t\ttemp1 = (char *)dest + count - 1;\n\t\ttemp2 = (char *)src + count - 1;\n\n\t\twhile (count > 0) {\n\t\t\t*temp1-- = *temp2--;\n\t\t\tcount--;\n\t\t}\n\t}\n\n\treturn dest;\n}\n\nint sbi_memcmp(const void *s1, const void *s2, size_t count)\n{\n\tconst char *temp1 = s1;\n\tconst char *temp2 = s2;\n\n\tfor (; count > 0 && (*temp1 == *temp2); count--) {\n\t\ttemp1++;\n\t\ttemp2++;\n\t}\n\n\tif (count > 0)\n\t\treturn *(unsigned char *)temp1 - *(unsigned char *)temp2;\n\telse\n\t\treturn 0;\n}\n\nvoid *sbi_memchr(const void *s, int c, size_t count)\n{\n\tconst unsigned char *temp = s;\n\n\twhile (count > 0) {\n\t\tif ((unsigned char)c == *temp++) {\n\t\t\treturn (void *)(temp - 1);\n\t\t}\n\t\tcount--;\n\t}\n\n\treturn NULL;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_system.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Nick Kossifidis <mick@ics.forth.gr>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_hsm.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_system.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_init.h>\n\nstatic SBI_LIST_HEAD(reset_devices_list);\n\nconst struct sbi_system_reset_device *sbi_system_reset_get_device(\n\t\t\t\t\tu32 reset_type, u32 reset_reason)\n{\n\tstruct sbi_system_reset_device *reset_dev = NULL;\n\tstruct sbi_dlist *pos;\n\t/** lowest priority - any non zero is our candidate */\n\tint priority = 0;\n\n\t/* Check each reset device registered for supported reset type */\n\tsbi_list_for_each(pos, &(reset_devices_list)) {\n\t\tstruct sbi_system_reset_device *dev =\n\t\t\tto_system_reset_device(pos);\n\t\tif (dev->system_reset_check) {\n\t\t\tint status = dev->system_reset_check(reset_type,\n\t\t\t\t\t\t\t     reset_reason);\n\t\t\t/** reset_type not supported */\n\t\t\tif (status == 0)\n\t\t\t\tcontinue;\n\n\t\t\tif (status > priority) {\n\t\t\t\treset_dev = dev;\n\t\t\t\tpriority = status;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn reset_dev;\n}\n\nvoid sbi_system_reset_add_device(struct sbi_system_reset_device *dev)\n{\n\tif (!dev || !dev->system_reset_check)\n\t\treturn;\n\n\tsbi_list_add(&(dev->node), &(reset_devices_list));\n}\n\nbool sbi_system_reset_supported(u32 reset_type, u32 reset_reason)\n{\n\treturn !!sbi_system_reset_get_device(reset_type, reset_reason);\n}\n\nvoid __noreturn sbi_system_reset(u32 reset_type, u32 reset_reason)\n{\n\tulong hbase = 0, hmask;\n\tu32 cur_hartid = current_hartid();\n\tstruct sbi_domain *dom = sbi_domain_thishart_ptr();\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\n\t/* Send HALT IPI to every hart other than the current hart */\n\twhile (!sbi_hsm_hart_interruptible_mask(dom, hbase, &hmask)) {\n\t\tif (hbase <= cur_hartid)\n\t\t\thmask &= ~(1UL << (cur_hartid - hbase));\n\t\tif (hmask)\n\t\t\tsbi_ipi_send_halt(hmask, hbase);\n\t\thbase += BITS_PER_LONG;\n\t}\n\n\t/* Stop current HART */\n\tsbi_hsm_hart_stop(scratch, FALSE);\n\n\t/* Platform specific reset if domain allowed system reset */\n\tif (dom->system_reset_allowed) {\n\t\tconst struct sbi_system_reset_device *dev =\n\t\t\tsbi_system_reset_get_device(reset_type, reset_reason);\n\t\tif (dev)\n\t\t\tdev->system_reset(reset_type, reset_reason);\n\t}\n\n\t/* If platform specific reset did not work then do sbi_exit() */\n\tsbi_exit(scratch);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_timer.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_barrier.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_timer.h>\n\nstatic unsigned long time_delta_off;\nstatic u64 (*get_time_val)(void);\nstatic const struct sbi_timer_device *timer_dev = NULL;\n\n#if __riscv_xlen == 32\nstatic u64 get_ticks(void)\n{\n\tu32 lo, hi, tmp;\n\t__asm__ __volatile__(\"1:\\n\"\n\t\t\t     \"rdtimeh %0\\n\"\n\t\t\t     \"rdtime %1\\n\"\n\t\t\t     \"rdtimeh %2\\n\"\n\t\t\t     \"bne %0, %2, 1b\"\n\t\t\t     : \"=&r\"(hi), \"=&r\"(lo), \"=&r\"(tmp));\n\treturn ((u64)hi << 32) | lo;\n}\n#else\nstatic u64 get_ticks(void)\n{\n\tunsigned long n;\n\n\t__asm__ __volatile__(\"rdtime %0\" : \"=r\"(n));\n\treturn n;\n}\n#endif\n\nstatic void nop_delay_fn(void *opaque)\n{\n\tcpu_relax();\n}\n\nvoid sbi_timer_delay_loop(ulong units, u64 unit_freq,\n\t\t\t  void (*delay_fn)(void *), void *opaque)\n{\n\tu64 start_val, delta;\n\n\t/* Do nothing if we don't have timer device */\n\tif (!timer_dev || !get_time_val) {\n\t\tsbi_printf(\"%s: called without timer device\\n\", __func__);\n\t\treturn;\n\t}\n\n\t/* Save starting timer value */\n\tstart_val = get_time_val();\n\n\t/* Compute desired timer value delta */\n\tdelta = ((u64)timer_dev->timer_freq * (u64)units);\n\tdelta = delta / unit_freq;\n\n\t/* Use NOP delay function if delay function not available */\n\tif (!delay_fn)\n\t\tdelay_fn = nop_delay_fn;\n\n\t/* Busy loop until desired timer value delta reached */\n\twhile ((get_time_val() - start_val) < delta)\n\t\tdelay_fn(opaque);\n}\n\nbool sbi_timer_waitms_until(bool (*predicate)(void *), void *arg,\n\t\t\t    uint64_t timeout_ms)\n{\n\tuint64_t start_time = sbi_timer_value();\n\tuint64_t ticks =\n\t\t(sbi_timer_get_device()->timer_freq / 1000) *\n\t\ttimeout_ms;\n\twhile(!predicate(arg))\n\t\tif (sbi_timer_value() - start_time  >= ticks)\n\t\t\treturn false;\n\treturn true;\n}\n\nu64 sbi_timer_value(void)\n{\n\tif (get_time_val)\n\t\treturn get_time_val();\n\treturn 0;\n}\n\nu64 sbi_timer_virt_value(void)\n{\n\tu64 *time_delta = sbi_scratch_offset_ptr(sbi_scratch_thishart_ptr(),\n\t\t\t\t\t\t time_delta_off);\n\n\treturn sbi_timer_value() + *time_delta;\n}\n\nu64 sbi_timer_get_delta(void)\n{\n\tu64 *time_delta = sbi_scratch_offset_ptr(sbi_scratch_thishart_ptr(),\n\t\t\t\t\t\t time_delta_off);\n\n\treturn *time_delta;\n}\n\nvoid sbi_timer_set_delta(ulong delta)\n{\n\tu64 *time_delta = sbi_scratch_offset_ptr(sbi_scratch_thishart_ptr(),\n\t\t\t\t\t\t time_delta_off);\n\n\t*time_delta = (u64)delta;\n}\n\nvoid sbi_timer_set_delta_upper(ulong delta_upper)\n{\n\tu64 *time_delta = sbi_scratch_offset_ptr(sbi_scratch_thishart_ptr(),\n\t\t\t\t\t\t time_delta_off);\n\n\t*time_delta &= 0xffffffffULL;\n\t*time_delta |= ((u64)delta_upper << 32);\n}\n\nvoid sbi_timer_event_start(u64 next_event)\n{\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_SET_TIMER);\n\n\t/**\n\t * Update the stimecmp directly if available. This allows\n\t * the older software to leverage sstc extension on newer hardware.\n\t */\n\tif (sbi_hart_has_extension(sbi_scratch_thishart_ptr(), SBI_HART_EXT_SSTC)) {\n#if __riscv_xlen == 32\n\t\tcsr_write(CSR_STIMECMP, next_event & 0xFFFFFFFF);\n\t\tcsr_write(CSR_STIMECMPH, next_event >> 32);\n#else\n\t\tcsr_write(CSR_STIMECMP, next_event);\n#endif\n\t} else if (timer_dev && timer_dev->timer_event_start) {\n\t\ttimer_dev->timer_event_start(next_event);\n\t\tcsr_clear(CSR_MIP, MIP_STIP);\n\t}\n\tcsr_set(CSR_MIE, MIP_MTIP);\n}\n\nvoid sbi_timer_process(void)\n{\n\tcsr_clear(CSR_MIE, MIP_MTIP);\n\t/*\n\t * If sstc extension is available, supervisor can receive the timer\n\t * directly without M-mode come in between. This function should\n\t * only invoked if M-mode programs the timer for its own purpose.\n\t */\n\tif (!sbi_hart_has_extension(sbi_scratch_thishart_ptr(), SBI_HART_EXT_SSTC))\n\t\tcsr_set(CSR_MIP, MIP_STIP);\n}\n\nconst struct sbi_timer_device *sbi_timer_get_device(void)\n{\n\treturn timer_dev;\n}\n\nvoid sbi_timer_set_device(const struct sbi_timer_device *dev)\n{\n\tif (!dev || timer_dev)\n\t\treturn;\n\n\ttimer_dev = dev;\n\tif (!get_time_val && timer_dev->timer_value)\n\t\tget_time_val = timer_dev->timer_value;\n}\n\nint sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot)\n{\n\tu64 *time_delta;\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\tif (cold_boot) {\n\t\ttime_delta_off = sbi_scratch_alloc_offset(sizeof(*time_delta));\n\t\tif (!time_delta_off)\n\t\t\treturn SBI_ENOMEM;\n\n\t\tif (sbi_hart_has_extension(scratch, SBI_HART_EXT_TIME))\n\t\t\tget_time_val = get_ticks;\n\t} else {\n\t\tif (!time_delta_off)\n\t\t\treturn SBI_ENOMEM;\n\t}\n\n\ttime_delta = sbi_scratch_offset_ptr(scratch, time_delta_off);\n\t*time_delta = 0;\n\n\treturn sbi_platform_timer_init(plat, cold_boot);\n}\n\nvoid sbi_timer_exit(struct sbi_scratch *scratch)\n{\n\tif (timer_dev && timer_dev->timer_event_stop)\n\t\ttimer_dev->timer_event_stop();\n\n\tcsr_clear(CSR_MIP, MIP_STIP);\n\tcsr_clear(CSR_MIE, MIP_MTIP);\n\n\tsbi_platform_timer_exit(sbi_platform_ptr(scratch));\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_tlb.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Atish Patra <atish.patra@wdc.com>\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_atomic.h>\n#include <sbi/riscv_barrier.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_fifo.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_tlb.h>\n#include <sbi/sbi_hfence.h>\n#include <sbi/sbi_string.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_pmu.h>\n\nstatic unsigned long tlb_sync_off;\nstatic unsigned long tlb_fifo_off;\nstatic unsigned long tlb_fifo_mem_off;\nstatic unsigned long tlb_range_flush_limit;\n\nstatic void tlb_flush_all(void)\n{\n\t__asm__ __volatile(\"sfence.vma\");\n}\n\nvoid sbi_tlb_local_hfence_vvma(struct sbi_tlb_info *tinfo)\n{\n\tunsigned long start = tinfo->start;\n\tunsigned long size  = tinfo->size;\n\tunsigned long vmid  = tinfo->vmid;\n\tunsigned long i, hgatp;\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_VVMA_RCVD);\n\n\thgatp = csr_swap(CSR_HGATP,\n\t\t\t (vmid << HGATP_VMID_SHIFT) & HGATP_VMID_MASK);\n\n\tif ((start == 0 && size == 0) || (size == SBI_TLB_FLUSH_ALL)) {\n\t\t__sbi_hfence_vvma_all();\n\t\tgoto done;\n\t}\n\n\tfor (i = 0; i < size; i += PAGE_SIZE) {\n\t\t__sbi_hfence_vvma_va(start+i);\n\t}\n\ndone:\n\tcsr_write(CSR_HGATP, hgatp);\n}\n\nvoid sbi_tlb_local_hfence_gvma(struct sbi_tlb_info *tinfo)\n{\n\tunsigned long start = tinfo->start;\n\tunsigned long size  = tinfo->size;\n\tunsigned long i;\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_GVMA_RCVD);\n\n\tif ((start == 0 && size == 0) || (size == SBI_TLB_FLUSH_ALL)) {\n\t\t__sbi_hfence_gvma_all();\n\t\treturn;\n\t}\n\n\tfor (i = 0; i < size; i += PAGE_SIZE) {\n\t\t__sbi_hfence_gvma_gpa((start + i) >> 2);\n\t}\n}\n\nvoid sbi_tlb_local_sfence_vma(struct sbi_tlb_info *tinfo)\n{\n\tunsigned long start = tinfo->start;\n\tunsigned long size  = tinfo->size;\n\tunsigned long i;\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_RCVD);\n\n\tif ((start == 0 && size == 0) || (size == SBI_TLB_FLUSH_ALL)) {\n\t\ttlb_flush_all();\n\t\treturn;\n\t}\n\n\tfor (i = 0; i < size; i += PAGE_SIZE) {\n\t\t__asm__ __volatile__(\"sfence.vma %0\"\n\t\t\t\t     :\n\t\t\t\t     : \"r\"(start + i)\n\t\t\t\t     : \"memory\");\n\t}\n}\n\nvoid sbi_tlb_local_hfence_vvma_asid(struct sbi_tlb_info *tinfo)\n{\n\tunsigned long start = tinfo->start;\n\tunsigned long size  = tinfo->size;\n\tunsigned long asid  = tinfo->asid;\n\tunsigned long vmid  = tinfo->vmid;\n\tunsigned long i, hgatp;\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_VVMA_ASID_RCVD);\n\n\thgatp = csr_swap(CSR_HGATP,\n\t\t\t (vmid << HGATP_VMID_SHIFT) & HGATP_VMID_MASK);\n\n\tif (start == 0 && size == 0) {\n\t\t__sbi_hfence_vvma_all();\n\t\tgoto done;\n\t}\n\n\tif (size == SBI_TLB_FLUSH_ALL) {\n\t\t__sbi_hfence_vvma_asid(asid);\n\t\tgoto done;\n\t}\n\n\tfor (i = 0; i < size; i += PAGE_SIZE) {\n\t\t__sbi_hfence_vvma_asid_va(start + i, asid);\n\t}\n\ndone:\n\tcsr_write(CSR_HGATP, hgatp);\n}\n\nvoid sbi_tlb_local_hfence_gvma_vmid(struct sbi_tlb_info *tinfo)\n{\n\tunsigned long start = tinfo->start;\n\tunsigned long size  = tinfo->size;\n\tunsigned long vmid  = tinfo->vmid;\n\tunsigned long i;\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_GVMA_VMID_RCVD);\n\n\tif (start == 0 && size == 0) {\n\t\t__sbi_hfence_gvma_all();\n\t\treturn;\n\t}\n\n\tif (size == SBI_TLB_FLUSH_ALL) {\n\t\t__sbi_hfence_gvma_vmid(vmid);\n\t\treturn;\n\t}\n\n\tfor (i = 0; i < size; i += PAGE_SIZE) {\n\t\t__sbi_hfence_gvma_vmid_gpa((start + i) >> 2, vmid);\n\t}\n}\n\nvoid sbi_tlb_local_sfence_vma_asid(struct sbi_tlb_info *tinfo)\n{\n\tunsigned long start = tinfo->start;\n\tunsigned long size  = tinfo->size;\n\tunsigned long asid  = tinfo->asid;\n\tunsigned long i;\n\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_ASID_RCVD);\n\n\tif (start == 0 && size == 0) {\n\t\ttlb_flush_all();\n\t\treturn;\n\t}\n\n\t/* Flush entire MM context for a given ASID */\n\tif (size == SBI_TLB_FLUSH_ALL) {\n\t\t__asm__ __volatile__(\"sfence.vma x0, %0\"\n\t\t\t\t     :\n\t\t\t\t     : \"r\"(asid)\n\t\t\t\t     : \"memory\");\n\t\treturn;\n\t}\n\n\tfor (i = 0; i < size; i += PAGE_SIZE) {\n\t\t__asm__ __volatile__(\"sfence.vma %0, %1\"\n\t\t\t\t     :\n\t\t\t\t     : \"r\"(start + i), \"r\"(asid)\n\t\t\t\t     : \"memory\");\n\t}\n}\n\nvoid sbi_tlb_local_fence_i(struct sbi_tlb_info *tinfo)\n{\n\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_FENCE_I_RECVD);\n\n\t__asm__ __volatile(\"fence.i\");\n}\n\nstatic void tlb_pmu_incr_fw_ctr(struct sbi_tlb_info *data)\n{\n\tif (unlikely(!data))\n\t\treturn;\n\n\tif (data->local_fn == sbi_tlb_local_fence_i)\n\t\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_FENCE_I_SENT);\n\telse if (data->local_fn == sbi_tlb_local_sfence_vma)\n\t\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_SENT);\n\telse if (data->local_fn == sbi_tlb_local_sfence_vma_asid)\n\t\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_SFENCE_VMA_ASID_SENT);\n\telse if (data->local_fn == sbi_tlb_local_hfence_gvma)\n\t\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_GVMA_SENT);\n\telse if (data->local_fn == sbi_tlb_local_hfence_gvma_vmid)\n\t\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_GVMA_VMID_SENT);\n\telse if (data->local_fn == sbi_tlb_local_hfence_vvma)\n\t\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_VVMA_SENT);\n\telse if (data->local_fn == sbi_tlb_local_hfence_vvma_asid)\n\t\tsbi_pmu_ctr_incr_fw(SBI_PMU_FW_HFENCE_VVMA_ASID_SENT);\n}\n\nstatic void tlb_entry_process(struct sbi_tlb_info *tinfo)\n{\n\tu32 rhartid;\n\tstruct sbi_scratch *rscratch = NULL;\n\tunsigned long *rtlb_sync = NULL;\n\n\ttinfo->local_fn(tinfo);\n\n\tsbi_hartmask_for_each_hart(rhartid, &tinfo->smask) {\n\t\trscratch = sbi_hartid_to_scratch(rhartid);\n\t\tif (!rscratch)\n\t\t\tcontinue;\n\n\t\trtlb_sync = sbi_scratch_offset_ptr(rscratch, tlb_sync_off);\n\t\twhile (atomic_raw_xchg_ulong(rtlb_sync, 1)) ;\n\t}\n}\n\nstatic void tlb_process_count(struct sbi_scratch *scratch, int count)\n{\n\tstruct sbi_tlb_info tinfo;\n\tunsigned int deq_count = 0;\n\tstruct sbi_fifo *tlb_fifo =\n\t\t\tsbi_scratch_offset_ptr(scratch, tlb_fifo_off);\n\n\twhile (!sbi_fifo_dequeue(tlb_fifo, &tinfo)) {\n\t\ttlb_entry_process(&tinfo);\n\t\tdeq_count++;\n\t\tif (deq_count > count)\n\t\t\tbreak;\n\n\t}\n}\n\nstatic void tlb_process(struct sbi_scratch *scratch)\n{\n\tstruct sbi_tlb_info tinfo;\n\tstruct sbi_fifo *tlb_fifo =\n\t\t\tsbi_scratch_offset_ptr(scratch, tlb_fifo_off);\n\n\twhile (!sbi_fifo_dequeue(tlb_fifo, &tinfo))\n\t\ttlb_entry_process(&tinfo);\n}\n\nstatic void tlb_sync(struct sbi_scratch *scratch)\n{\n\tunsigned long *tlb_sync =\n\t\t\tsbi_scratch_offset_ptr(scratch, tlb_sync_off);\n\n\twhile (!atomic_raw_xchg_ulong(tlb_sync, 0)) {\n\t\t/*\n\t\t * While we are waiting for remote hart to set the sync,\n\t\t * consume fifo requests to avoid deadlock.\n\t\t */\n\t\ttlb_process_count(scratch, 1);\n\t}\n\n\treturn;\n}\n\nstatic inline int tlb_range_check(struct sbi_tlb_info *curr,\n\t\t\t\t\tstruct sbi_tlb_info *next)\n{\n\tunsigned long curr_end;\n\tunsigned long next_end;\n\tint ret = SBI_FIFO_UNCHANGED;\n\n\tif (!curr || !next)\n\t\treturn ret;\n\n\tnext_end = next->start + next->size;\n\tcurr_end = curr->start + curr->size;\n\tif (next->start <= curr->start && next_end > curr_end) {\n\t\tcurr->start = next->start;\n\t\tcurr->size  = next->size;\n\t\tsbi_hartmask_or(&curr->smask, &curr->smask, &next->smask);\n\t\tret = SBI_FIFO_UPDATED;\n\t} else if (next->start >= curr->start && next_end <= curr_end) {\n\t\tsbi_hartmask_or(&curr->smask, &curr->smask, &next->smask);\n\t\tret = SBI_FIFO_SKIP;\n\t}\n\n\treturn ret;\n}\n\n/**\n * Call back to decide if an inplace fifo update is required or next entry can\n * can be skipped. Here are the different cases that are being handled.\n *\n * Case1:\n *\tif next flush request range lies within one of the existing entry, skip\n *\tthe next entry.\n * Case2:\n *\tif flush request range in current fifo entry lies within next flush\n *\trequest, update the current entry.\n *\n * Note:\n *\tWe can not issue a fifo reset anymore if a complete vma flush is requested.\n *\tThis is because we are queueing FENCE.I requests as well now.\n *\tTo ease up the pressure in enqueue/fifo sync path, try to dequeue 1 element\n *\tbefore continuing the while loop. This method is preferred over wfi/ipi because\n *\tof MMIO cost involved in later method.\n */\nstatic int tlb_update_cb(void *in, void *data)\n{\n\tstruct sbi_tlb_info *curr;\n\tstruct sbi_tlb_info *next;\n\tint ret = SBI_FIFO_UNCHANGED;\n\n\tif (!in || !data)\n\t\treturn ret;\n\n\tcurr = (struct sbi_tlb_info *)data;\n\tnext = (struct sbi_tlb_info *)in;\n\n\tif (next->local_fn == sbi_tlb_local_sfence_vma_asid &&\n\t    curr->local_fn == sbi_tlb_local_sfence_vma_asid) {\n\t\tif (next->asid == curr->asid)\n\t\t\tret = tlb_range_check(curr, next);\n\t} else if (next->local_fn == sbi_tlb_local_sfence_vma &&\n\t\t   curr->local_fn == sbi_tlb_local_sfence_vma) {\n\t\tret = tlb_range_check(curr, next);\n\t}\n\n\treturn ret;\n}\n\nstatic int tlb_update(struct sbi_scratch *scratch,\n\t\t\t  struct sbi_scratch *remote_scratch,\n\t\t\t  u32 remote_hartid, void *data)\n{\n\tint ret;\n\tstruct sbi_fifo *tlb_fifo_r;\n\tstruct sbi_tlb_info *tinfo = data;\n\tu32 curr_hartid = current_hartid();\n\n\t/*\n\t * If address range to flush is too big then simply\n\t * upgrade it to flush all because we can only flush\n\t * 4KB at a time.\n\t */\n\tif (tinfo->size > tlb_range_flush_limit) {\n\t\ttinfo->start = 0;\n\t\ttinfo->size = SBI_TLB_FLUSH_ALL;\n\t}\n\n\t/*\n\t * If the request is to queue a tlb flush entry for itself\n\t * then just do a local flush and return;\n\t */\n\tif (remote_hartid == curr_hartid) {\n\t\ttinfo->local_fn(tinfo);\n\t\treturn -1;\n\t}\n\n\ttlb_fifo_r = sbi_scratch_offset_ptr(remote_scratch, tlb_fifo_off);\n\n\tret = sbi_fifo_inplace_update(tlb_fifo_r, data, tlb_update_cb);\n\tif (ret != SBI_FIFO_UNCHANGED) {\n\t\treturn 1;\n\t}\n\n\twhile (sbi_fifo_enqueue(tlb_fifo_r, data) < 0) {\n\t\t/**\n\t\t * For now, Busy loop until there is space in the fifo.\n\t\t * There may be case where target hart is also\n\t\t * enqueue in source hart's fifo. Both hart may busy\n\t\t * loop leading to a deadlock.\n\t\t * TODO: Introduce a wait/wakeup event mechanism to handle\n\t\t * this properly.\n\t\t */\n\t\ttlb_process_count(scratch, 1);\n\t\tsbi_dprintf(\"hart%d: hart%d tlb fifo full\\n\",\n\t\t\t    curr_hartid, remote_hartid);\n\t}\n\n\treturn 0;\n}\n\nstatic struct sbi_ipi_event_ops tlb_ops = {\n\t.name = \"IPI_TLB\",\n\t.update = tlb_update,\n\t.sync = tlb_sync,\n\t.process = tlb_process,\n};\n\nstatic u32 tlb_event = SBI_IPI_EVENT_MAX;\n\nint sbi_tlb_request(ulong hmask, ulong hbase, struct sbi_tlb_info *tinfo)\n{\n\tif (!tinfo->local_fn)\n\t\treturn SBI_EINVAL;\n\n\ttlb_pmu_incr_fw_ctr(tinfo);\n\n\treturn sbi_ipi_send_many(hmask, hbase, tlb_event, tinfo);\n}\n\nint sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot)\n{\n\tint ret;\n\tvoid *tlb_mem;\n\tunsigned long *tlb_sync;\n\tstruct sbi_fifo *tlb_q;\n\tconst struct sbi_platform *plat = sbi_platform_ptr(scratch);\n\n\tif (cold_boot) {\n\t\ttlb_sync_off = sbi_scratch_alloc_offset(sizeof(*tlb_sync));\n\t\tif (!tlb_sync_off)\n\t\t\treturn SBI_ENOMEM;\n\t\ttlb_fifo_off = sbi_scratch_alloc_offset(sizeof(*tlb_q));\n\t\tif (!tlb_fifo_off) {\n\t\t\tsbi_scratch_free_offset(tlb_sync_off);\n\t\t\treturn SBI_ENOMEM;\n\t\t}\n\t\ttlb_fifo_mem_off = sbi_scratch_alloc_offset(\n\t\t\t\tSBI_TLB_FIFO_NUM_ENTRIES * SBI_TLB_INFO_SIZE);\n\t\tif (!tlb_fifo_mem_off) {\n\t\t\tsbi_scratch_free_offset(tlb_fifo_off);\n\t\t\tsbi_scratch_free_offset(tlb_sync_off);\n\t\t\treturn SBI_ENOMEM;\n\t\t}\n\t\tret = sbi_ipi_event_create(&tlb_ops);\n\t\tif (ret < 0) {\n\t\t\tsbi_scratch_free_offset(tlb_fifo_mem_off);\n\t\t\tsbi_scratch_free_offset(tlb_fifo_off);\n\t\t\tsbi_scratch_free_offset(tlb_sync_off);\n\t\t\treturn ret;\n\t\t}\n\t\ttlb_event = ret;\n\t\ttlb_range_flush_limit = sbi_platform_tlbr_flush_limit(plat);\n\t} else {\n\t\tif (!tlb_sync_off ||\n\t\t    !tlb_fifo_off ||\n\t\t    !tlb_fifo_mem_off)\n\t\t\treturn SBI_ENOMEM;\n\t\tif (SBI_IPI_EVENT_MAX <= tlb_event)\n\t\t\treturn SBI_ENOSPC;\n\t}\n\n\ttlb_sync = sbi_scratch_offset_ptr(scratch, tlb_sync_off);\n\ttlb_q = sbi_scratch_offset_ptr(scratch, tlb_fifo_off);\n\ttlb_mem = sbi_scratch_offset_ptr(scratch, tlb_fifo_mem_off);\n\n\t*tlb_sync = 0;\n\n\tsbi_fifo_init(tlb_q, tlb_mem,\n\t\t      SBI_TLB_FIFO_NUM_ENTRIES, SBI_TLB_INFO_SIZE);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_trap.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_illegal_insn.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_irqchip.h>\n#include <sbi/sbi_misaligned_ldst.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_timer.h>\n#include <sbi/sbi_trap.h>\n\nstatic void __noreturn sbi_trap_error(const char *msg, int rc,\n\t\t\t\t      ulong mcause, ulong mtval, ulong mtval2,\n\t\t\t\t      ulong mtinst, struct sbi_trap_regs *regs)\n{\n\tu32 hartid = current_hartid();\n\n\tsbi_printf(\"%s: hart%d: %s (error %d)\\n\", __func__, hartid, msg, rc);\n\tsbi_printf(\"%s: hart%d: mcause=0x%\" PRILX \" mtval=0x%\" PRILX \"\\n\",\n\t\t   __func__, hartid, mcause, mtval);\n\tif (misa_extension('H')) {\n\t\tsbi_printf(\"%s: hart%d: mtval2=0x%\" PRILX\n\t\t\t   \" mtinst=0x%\" PRILX \"\\n\",\n\t\t\t   __func__, hartid, mtval2, mtinst);\n\t}\n\tsbi_printf(\"%s: hart%d: mepc=0x%\" PRILX \" mstatus=0x%\" PRILX \"\\n\",\n\t\t   __func__, hartid, regs->mepc, regs->mstatus);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"ra\", regs->ra, \"sp\", regs->sp);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"gp\", regs->gp, \"tp\", regs->tp);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"s0\", regs->s0, \"s1\", regs->s1);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"a0\", regs->a0, \"a1\", regs->a1);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"a2\", regs->a2, \"a3\", regs->a3);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"a4\", regs->a4, \"a5\", regs->a5);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"a6\", regs->a6, \"a7\", regs->a7);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"s2\", regs->s2, \"s3\", regs->s3);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"s4\", regs->s4, \"s5\", regs->s5);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"s6\", regs->s6, \"s7\", regs->s7);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"s8\", regs->s8, \"s9\", regs->s9);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"s10\", regs->s10, \"s11\", regs->s11);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"t0\", regs->t0, \"t1\", regs->t1);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"t2\", regs->t2, \"t3\", regs->t3);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \" %s=0x%\" PRILX \"\\n\", __func__,\n\t\t   hartid, \"t4\", regs->t4, \"t5\", regs->t5);\n\tsbi_printf(\"%s: hart%d: %s=0x%\" PRILX \"\\n\", __func__, hartid, \"t6\",\n\t\t   regs->t6);\n\n\tsbi_hart_hang();\n}\n\n/**\n * Redirect trap to lower privledge mode (S-mode or U-mode)\n *\n * @param regs pointer to register state\n * @param trap pointer to trap details\n *\n * @return 0 on success and negative error code on failure\n */\nint sbi_trap_redirect(struct sbi_trap_regs *regs,\n\t\t      struct sbi_trap_info *trap)\n{\n\tulong hstatus, vsstatus, prev_mode;\n#if __riscv_xlen == 32\n\tbool prev_virt = (regs->mstatusH & MSTATUSH_MPV) ? TRUE : FALSE;\n#else\n\tbool prev_virt = (regs->mstatus & MSTATUS_MPV) ? TRUE : FALSE;\n#endif\n\t/* By default, we redirect to HS-mode */\n\tbool next_virt = FALSE;\n\n\t/* Sanity check on previous mode */\n\tprev_mode = (regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT;\n\tif (prev_mode != PRV_S && prev_mode != PRV_U)\n\t\treturn SBI_ENOTSUPP;\n\n\t/* If exceptions came from VS/VU-mode, redirect to VS-mode if\n\t * delegated in hedeleg\n\t */\n\tif (misa_extension('H') && prev_virt) {\n\t\tif ((trap->cause < __riscv_xlen) &&\n\t\t    (csr_read(CSR_HEDELEG) & BIT(trap->cause))) {\n\t\t\tnext_virt = TRUE;\n\t\t}\n\t}\n\n\t/* Update MSTATUS MPV bits */\n#if __riscv_xlen == 32\n\tregs->mstatusH &= ~MSTATUSH_MPV;\n\tregs->mstatusH |= (next_virt) ? MSTATUSH_MPV : 0UL;\n#else\n\tregs->mstatus &= ~MSTATUS_MPV;\n\tregs->mstatus |= (next_virt) ? MSTATUS_MPV : 0UL;\n#endif\n\n\t/* Update hypervisor CSRs if going to HS-mode */\n\tif (misa_extension('H') && !next_virt) {\n\t\thstatus = csr_read(CSR_HSTATUS);\n\t\tif (prev_virt) {\n\t\t\t/* hstatus.SPVP is only updated if coming from VS/VU-mode */\n\t\t\thstatus &= ~HSTATUS_SPVP;\n\t\t\thstatus |= (prev_mode == PRV_S) ? HSTATUS_SPVP : 0;\n\t\t}\n\t\thstatus &= ~HSTATUS_SPV;\n\t\thstatus |= (prev_virt) ? HSTATUS_SPV : 0;\n\t\thstatus &= ~HSTATUS_GVA;\n\t\thstatus |= (trap->gva) ? HSTATUS_GVA : 0;\n\t\tcsr_write(CSR_HSTATUS, hstatus);\n\t\tcsr_write(CSR_HTVAL, trap->tval2);\n\t\tcsr_write(CSR_HTINST, trap->tinst);\n\t}\n\n\t/* Update exception related CSRs */\n\tif (next_virt) {\n\t\t/* Update VS-mode exception info */\n\t\tcsr_write(CSR_VSTVAL, trap->tval);\n\t\tcsr_write(CSR_VSEPC, trap->epc);\n\t\tcsr_write(CSR_VSCAUSE, trap->cause);\n\n\t\t/* Set MEPC to VS-mode exception vector base */\n\t\tregs->mepc = csr_read(CSR_VSTVEC);\n\n\t\t/* Set MPP to VS-mode */\n\t\tregs->mstatus &= ~MSTATUS_MPP;\n\t\tregs->mstatus |= (PRV_S << MSTATUS_MPP_SHIFT);\n\n\t\t/* Get VS-mode SSTATUS CSR */\n\t\tvsstatus = csr_read(CSR_VSSTATUS);\n\n\t\t/* Set SPP for VS-mode */\n\t\tvsstatus &= ~SSTATUS_SPP;\n\t\tif (prev_mode == PRV_S)\n\t\t\tvsstatus |= (1UL << SSTATUS_SPP_SHIFT);\n\n\t\t/* Set SPIE for VS-mode */\n\t\tvsstatus &= ~SSTATUS_SPIE;\n\t\tif (vsstatus & SSTATUS_SIE)\n\t\t\tvsstatus |= (1UL << SSTATUS_SPIE_SHIFT);\n\n\t\t/* Clear SIE for VS-mode */\n\t\tvsstatus &= ~SSTATUS_SIE;\n\n\t\t/* Update VS-mode SSTATUS CSR */\n\t\tcsr_write(CSR_VSSTATUS, vsstatus);\n\t} else {\n\t\t/* Update S-mode exception info */\n\t\tcsr_write(CSR_STVAL, trap->tval);\n\t\tcsr_write(CSR_SEPC, trap->epc);\n\t\tcsr_write(CSR_SCAUSE, trap->cause);\n\n\t\t/* Set MEPC to S-mode exception vector base */\n\t\tregs->mepc = csr_read(CSR_STVEC);\n\n\t\t/* Set MPP to S-mode */\n\t\tregs->mstatus &= ~MSTATUS_MPP;\n\t\tregs->mstatus |= (PRV_S << MSTATUS_MPP_SHIFT);\n\n\t\t/* Set SPP for S-mode */\n\t\tregs->mstatus &= ~MSTATUS_SPP;\n\t\tif (prev_mode == PRV_S)\n\t\t\tregs->mstatus |= (1UL << MSTATUS_SPP_SHIFT);\n\n\t\t/* Set SPIE for S-mode */\n\t\tregs->mstatus &= ~MSTATUS_SPIE;\n\t\tif (regs->mstatus & MSTATUS_SIE)\n\t\t\tregs->mstatus |= (1UL << MSTATUS_SPIE_SHIFT);\n\n\t\t/* Clear SIE for S-mode */\n\t\tregs->mstatus &= ~MSTATUS_SIE;\n\t}\n\n\treturn 0;\n}\n\nstatic int sbi_trap_nonaia_irq(struct sbi_trap_regs *regs, ulong mcause)\n{\n\tmcause &= ~(1UL << (__riscv_xlen - 1));\n\tswitch (mcause) {\n\tcase IRQ_M_TIMER:\n\t\tsbi_timer_process();\n\t\tbreak;\n\tcase IRQ_M_SOFT:\n\t\tsbi_ipi_process();\n\t\tbreak;\n\tcase IRQ_M_EXT:\n\t\treturn sbi_irqchip_process(regs);\n\tdefault:\n\t\treturn SBI_ENOENT;\n\t};\n\n\treturn 0;\n}\n\nstatic int sbi_trap_aia_irq(struct sbi_trap_regs *regs, ulong mcause)\n{\n\tint rc;\n\tunsigned long mtopi;\n\n\twhile ((mtopi = csr_read(CSR_MTOPI))) {\n\t\tmtopi = mtopi >> TOPI_IID_SHIFT;\n\t\tswitch (mtopi) {\n\t\tcase IRQ_M_TIMER:\n\t\t\tsbi_timer_process();\n\t\t\tbreak;\n\t\tcase IRQ_M_SOFT:\n\t\t\tsbi_ipi_process();\n\t\t\tbreak;\n\t\tcase IRQ_M_EXT:\n\t\t\trc = sbi_irqchip_process(regs);\n\t\t\tif (rc)\n\t\t\t\treturn rc;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn SBI_ENOENT;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/**\n * Handle trap/interrupt\n *\n * This function is called by firmware linked to OpenSBI\n * library for handling trap/interrupt. It expects the\n * following:\n * 1. The 'mscratch' CSR is pointing to sbi_scratch of current HART\n * 2. The 'mcause' CSR is having exception/interrupt cause\n * 3. The 'mtval' CSR is having additional trap information\n * 4. The 'mtval2' CSR is having additional trap information\n * 5. The 'mtinst' CSR is having decoded trap instruction\n * 6. Stack pointer (SP) is setup for current HART\n * 7. Interrupts are disabled in MSTATUS CSR\n *\n * @param regs pointer to register state\n */\nstruct sbi_trap_regs *sbi_trap_handler(struct sbi_trap_regs *regs)\n{\n\tint rc = SBI_ENOTSUPP;\n\tconst char *msg = \"trap handler failed\";\n\tulong mcause = csr_read(CSR_MCAUSE);\n\tulong mtval = csr_read(CSR_MTVAL), mtval2 = 0, mtinst = 0;\n\tstruct sbi_trap_info trap;\n\n\tif (misa_extension('H')) {\n\t\tmtval2 = csr_read(CSR_MTVAL2);\n\t\tmtinst = csr_read(CSR_MTINST);\n\t}\n\n\tif (mcause & (1UL << (__riscv_xlen - 1))) {\n\t\tif (sbi_hart_has_extension(sbi_scratch_thishart_ptr(),\n\t\t\t\t\t   SBI_HART_EXT_SMAIA))\n\t\t\trc = sbi_trap_aia_irq(regs, mcause);\n\t\telse\n\t\t\trc = sbi_trap_nonaia_irq(regs, mcause);\n\t\tif (rc) {\n\t\t\tmsg = \"unhandled local interrupt\";\n\t\t\tgoto trap_error;\n\t\t}\n\t\treturn regs;\n\t}\n\n\tswitch (mcause) {\n\tcase CAUSE_ILLEGAL_INSTRUCTION:\n\t\trc  = sbi_illegal_insn_handler(mtval, regs);\n\t\tmsg = \"illegal instruction handler failed\";\n\t\tbreak;\n\tcase CAUSE_MISALIGNED_LOAD:\n\t\trc = sbi_misaligned_load_handler(mtval, mtval2, mtinst, regs);\n\t\tmsg = \"misaligned load handler failed\";\n\t\tbreak;\n\tcase CAUSE_MISALIGNED_STORE:\n\t\trc  = sbi_misaligned_store_handler(mtval, mtval2, mtinst, regs);\n\t\tmsg = \"misaligned store handler failed\";\n\t\tbreak;\n\tcase CAUSE_SUPERVISOR_ECALL:\n\tcase CAUSE_MACHINE_ECALL:\n\t\trc  = sbi_ecall_handler(regs);\n\t\tmsg = \"ecall handler failed\";\n\t\tbreak;\n\tcase CAUSE_LOAD_ACCESS:\n\tcase CAUSE_STORE_ACCESS:\n\t\tsbi_pmu_ctr_incr_fw(mcause == CAUSE_LOAD_ACCESS ?\n\t\t\tSBI_PMU_FW_ACCESS_LOAD : SBI_PMU_FW_ACCESS_STORE);\n\t\t/* fallthrough */\n\tdefault:\n\t\t/* If the trap came from S or U mode, redirect it there */\n\t\ttrap.epc = regs->mepc;\n\t\ttrap.cause = mcause;\n\t\ttrap.tval = mtval;\n\t\ttrap.tval2 = mtval2;\n\t\ttrap.tinst = mtinst;\n\t\ttrap.gva   = sbi_regs_gva(regs);\n\n\t\trc = sbi_trap_redirect(regs, &trap);\n\t\tbreak;\n\t};\n\ntrap_error:\n\tif (rc)\n\t\tsbi_trap_error(msg, rc, mcause, mtval, mtval2, mtinst, regs);\n\treturn regs;\n}\n\ntypedef void (*trap_exit_t)(const struct sbi_trap_regs *regs);\n\n/**\n * Exit trap/interrupt handling\n *\n * This function is called by non-firmware code to abruptly exit\n * trap/interrupt handling and resume execution at context pointed\n * by given register state.\n *\n * @param regs pointer to register state\n */\nvoid __noreturn sbi_trap_exit(const struct sbi_trap_regs *regs)\n{\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\n\t((trap_exit_t)scratch->trap_exit)(regs);\n\t__builtin_unreachable();\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/sbi/sbi_unpriv.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_trap.h>\n#include <sbi/sbi_unpriv.h>\n\n/**\n * a3 must a pointer to the sbi_trap_info and a4 is used as a temporary\n * register in the trap handler. Make sure that compiler doesn't use a3 & a4.\n */\n#define DEFINE_UNPRIVILEGED_LOAD_FUNCTION(type, insn)                         \\\n\ttype sbi_load_##type(const type *addr,                                \\\n\t\t\t     struct sbi_trap_info *trap)                      \\\n\t{                                                                     \\\n\t\tregister ulong tinfo asm(\"a3\");                               \\\n\t\tregister ulong mstatus = 0;                                   \\\n\t\tregister ulong mtvec = sbi_hart_expected_trap_addr();         \\\n\t\ttype ret = 0;                                                 \\\n\t\ttrap->cause = 0;                                              \\\n\t\tasm volatile(                                                 \\\n\t\t\t\"add %[tinfo], %[taddr], zero\\n\"                      \\\n\t\t\t\"csrrw %[mtvec], \" STR(CSR_MTVEC) \", %[mtvec]\\n\"      \\\n\t\t\t\"csrrs %[mstatus], \" STR(CSR_MSTATUS) \", %[mprv]\\n\"   \\\n\t\t\t\".option push\\n\"                                      \\\n\t\t\t\".option norvc\\n\"                                     \\\n\t\t\t#insn \" %[ret], %[addr]\\n\"                            \\\n\t\t\t\".option pop\\n\"                                       \\\n\t\t\t\"csrw \" STR(CSR_MSTATUS) \", %[mstatus]\\n\"             \\\n\t\t\t\"csrw \" STR(CSR_MTVEC) \", %[mtvec]\"                   \\\n\t\t    : [mstatus] \"+&r\"(mstatus), [mtvec] \"+&r\"(mtvec),         \\\n\t\t      [tinfo] \"+&r\"(tinfo), [ret] \"=&r\"(ret)                  \\\n\t\t    : [addr] \"m\"(*addr), [mprv] \"r\"(MSTATUS_MPRV),            \\\n\t\t      [taddr] \"r\"((ulong)trap)                                \\\n\t\t    : \"a4\", \"memory\");                                        \\\n\t\treturn ret;                                                   \\\n\t}\n\n#define DEFINE_UNPRIVILEGED_STORE_FUNCTION(type, insn)                        \\\n\tvoid sbi_store_##type(type *addr, type val,                           \\\n\t\t\t      struct sbi_trap_info *trap)                     \\\n\t{                                                                     \\\n\t\tregister ulong tinfo asm(\"a3\") = (ulong)trap;                 \\\n\t\tregister ulong mstatus = 0;                                   \\\n\t\tregister ulong mtvec = sbi_hart_expected_trap_addr();         \\\n\t\ttrap->cause = 0;                                              \\\n\t\tasm volatile(                                                 \\\n\t\t\t\"add %[tinfo], %[taddr], zero\\n\"                      \\\n\t\t\t\"csrrw %[mtvec], \" STR(CSR_MTVEC) \", %[mtvec]\\n\"      \\\n\t\t\t\"csrrs %[mstatus], \" STR(CSR_MSTATUS) \", %[mprv]\\n\"   \\\n\t\t\t\".option push\\n\"                                      \\\n\t\t\t\".option norvc\\n\"                                     \\\n\t\t\t#insn \" %[val], %[addr]\\n\"                            \\\n\t\t\t\".option pop\\n\"                                       \\\n\t\t\t\"csrw \" STR(CSR_MSTATUS) \", %[mstatus]\\n\"             \\\n\t\t\t\"csrw \" STR(CSR_MTVEC) \", %[mtvec]\"                   \\\n\t\t    : [mstatus] \"+&r\"(mstatus), [mtvec] \"+&r\"(mtvec),         \\\n\t\t      [tinfo] \"+&r\"(tinfo)                                    \\\n\t\t    : [addr] \"m\"(*addr), [mprv] \"r\"(MSTATUS_MPRV),            \\\n\t\t      [val] \"r\"(val), [taddr] \"r\"((ulong)trap)                \\\n\t\t    : \"a4\", \"memory\");                                        \\\n\t}\n\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(u8, lbu)\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(u16, lhu)\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(s8, lb)\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(s16, lh)\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(s32, lw)\nDEFINE_UNPRIVILEGED_STORE_FUNCTION(u8, sb)\nDEFINE_UNPRIVILEGED_STORE_FUNCTION(u16, sh)\nDEFINE_UNPRIVILEGED_STORE_FUNCTION(u32, sw)\n#if __riscv_xlen == 64\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(u32, lwu)\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(u64, ld)\nDEFINE_UNPRIVILEGED_STORE_FUNCTION(u64, sd)\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(ulong, ld)\n#elif __riscv_xlen == 32\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(u32, lw)\nDEFINE_UNPRIVILEGED_LOAD_FUNCTION(ulong, lw)\n\nu64 sbi_load_u64(const u64 *addr,\n\t\t struct sbi_trap_info *trap)\n{\n\tu64 ret = sbi_load_u32((u32 *)addr, trap);\n\n\tif (trap->cause)\n\t\treturn 0;\n\tret |= ((u64)sbi_load_u32((u32 *)addr + 1, trap) << 32);\n\tif (trap->cause)\n\t\treturn 0;\n\n\treturn ret;\n}\n\nvoid sbi_store_u64(u64 *addr, u64 val,\n\t\t   struct sbi_trap_info *trap)\n{\n\tsbi_store_u32((u32 *)addr, val, trap);\n\tif (trap->cause)\n\t\treturn;\n\n\tsbi_store_u32((u32 *)addr + 1, val >> 32, trap);\n\tif (trap->cause)\n\t\treturn;\n}\n#else\n# error \"Unexpected __riscv_xlen\"\n#endif\n\nulong sbi_get_insn(ulong mepc, struct sbi_trap_info *trap)\n{\n\tregister ulong tinfo asm(\"a3\");\n\tregister ulong ttmp asm(\"a4\");\n\tregister ulong mstatus = 0;\n\tregister ulong mtvec = sbi_hart_expected_trap_addr();\n\tulong insn = 0;\n\n\ttrap->cause = 0;\n\n\tasm volatile(\n\t    \"add %[tinfo], %[taddr], zero\\n\"\n\t    \"csrrw %[mtvec], \" STR(CSR_MTVEC) \", %[mtvec]\\n\"\n\t    \"csrrs %[mstatus], \" STR(CSR_MSTATUS) \", %[mprv]\\n\"\n\t    \"lhu %[insn], (%[addr])\\n\"\n\t    \"andi %[ttmp], %[insn], 3\\n\"\n\t    \"addi %[ttmp], %[ttmp], -3\\n\"\n\t    \"bne %[ttmp], zero, 2f\\n\"\n\t    \"lhu %[ttmp], 2(%[addr])\\n\"\n\t    \"sll %[ttmp], %[ttmp], 16\\n\"\n\t    \"add %[insn], %[insn], %[ttmp]\\n\"\n\t    \"2: csrw \" STR(CSR_MSTATUS) \", %[mstatus]\\n\"\n\t    \"csrw \" STR(CSR_MTVEC) \", %[mtvec]\"\n\t    : [mstatus] \"+&r\"(mstatus), [mtvec] \"+&r\"(mtvec),\n\t      [tinfo] \"+&r\"(tinfo), [ttmp] \"+&r\"(ttmp),\n\t      [insn] \"=&r\"(insn)\n\t    : [mprv] \"r\"(MSTATUS_MPRV | MSTATUS_MXR),\n\t      [taddr] \"r\"((ulong)trap), [addr] \"r\"(mepc)\n\t    : \"memory\");\n\n\tswitch (trap->cause) {\n\tcase CAUSE_LOAD_ACCESS:\n\t\ttrap->cause = CAUSE_FETCH_ACCESS;\n\t\ttrap->tinst = 0UL;\n\t\tbreak;\n\tcase CAUSE_LOAD_PAGE_FAULT:\n\t\ttrap->cause = CAUSE_FETCH_PAGE_FAULT;\n\t\ttrap->tinst = 0UL;\n\t\tbreak;\n\tcase CAUSE_LOAD_GUEST_PAGE_FAULT:\n\t\ttrap->cause = CAUSE_FETCH_GUEST_PAGE_FAULT;\n\t\tif (trap->tinst != INSN_PSEUDO_VS_LOAD &&\n\t\t    trap->tinst != INSN_PSEUDO_VS_STORE)\n\t\t\ttrap->tinst = 0UL;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t};\n\n\treturn insn;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"Utils and Drivers Support\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/fdt/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/gpio/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/i2c/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/ipi/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/irqchip/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/libfdt/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/reset/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/serial/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/sys/Kconfig\"\n\nsource \"$(OPENSBI_SRC_DIR)/lib/utils/timer/Kconfig\"\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/fdt/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenuconfig FDT\n\tbool \"Flattened Device Tree (FDT) support\"\n\tselect LIBFDT\n\tdefault n\n\nif FDT\n\nconfig FDT_DOMAIN\n\tbool \"FDT domain support\"\n\tdefault n\n\nconfig FDT_PMU\n\tbool \"FDT performance monitoring unit (PMU) support\"\n\tdefault n\n\nendif\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/fdt/fdt_domain.c",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * fdt_domain.c - Flat Device Tree Domain helper routines\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <libfdt_env.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi_utils/fdt/fdt_domain.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n\nint fdt_iterate_each_domain(void *fdt, void *opaque,\n\t\t\t    int (*fn)(void *fdt, int domain_offset,\n\t\t\t\t       void *opaque))\n{\n\tint rc, doffset, poffset;\n\n\tif (!fdt || !fn)\n\t\treturn SBI_EINVAL;\n\n\tpoffset = fdt_path_offset(fdt, \"/chosen\");\n\tif (poffset < 0)\n\t\treturn 0;\n\tpoffset = fdt_node_offset_by_compatible(fdt, poffset,\n\t\t\t\t\t\t\"opensbi,domain,config\");\n\tif (poffset < 0)\n\t\treturn 0;\n\n\tfdt_for_each_subnode(doffset, fdt, poffset) {\n\t\tif (fdt_node_check_compatible(fdt, doffset,\n\t\t\t\t\t      \"opensbi,domain,instance\"))\n\t\t\tcontinue;\n\n\t\trc = fn(fdt, doffset, opaque);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn 0;\n}\n\nint fdt_iterate_each_memregion(void *fdt, int domain_offset, void *opaque,\n\t\t\t       int (*fn)(void *fdt, int domain_offset,\n\t\t\t\t\t int region_offset, u32 region_access,\n\t\t\t\t\t void *opaque))\n{\n\tu32 i, rcount;\n\tint rc, len, region_offset;\n\tconst u32 *regions;\n\n\tif (!fdt || (domain_offset < 0) || !fn)\n\t\treturn SBI_EINVAL;\n\n\tif (fdt_node_check_compatible(fdt, domain_offset,\n\t\t\t\t      \"opensbi,domain,instance\"))\n\t\treturn SBI_EINVAL;\n\n\tregions = fdt_getprop(fdt, domain_offset, \"regions\", &len);\n\tif (!regions)\n\t\treturn 0;\n\n\trcount = (u32)len / (sizeof(u32) * 2);\n\tfor (i = 0; i < rcount; i++) {\n\t\tregion_offset = fdt_node_offset_by_phandle(fdt,\n\t\t\t\t\t\tfdt32_to_cpu(regions[2 * i]));\n\t\tif (region_offset < 0)\n\t\t\treturn region_offset;\n\n\t\tif (fdt_node_check_compatible(fdt, region_offset,\n\t\t\t\t\t      \"opensbi,domain,memregion\"))\n\t\t\treturn SBI_EINVAL;\n\n\t\trc = fn(fdt, domain_offset, region_offset,\n\t\t\tfdt32_to_cpu(regions[(2 * i) + 1]), opaque);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn 0;\n}\n\nstruct __fixup_find_domain_offset_info {\n\tconst char *name;\n\tint *doffset;\n};\n\nstatic int __fixup_find_domain_offset(void *fdt, int doff, void *p)\n{\n\tstruct __fixup_find_domain_offset_info *fdo = p;\n\n\tif (!strncmp(fdo->name, fdt_get_name(fdt, doff, NULL), strlen(fdo->name)))\n\t\t*fdo->doffset = doff;\n\n\treturn 0;\n}\n\n#define DISABLE_DEVICES_MASK\t(SBI_DOMAIN_MEMREGION_READABLE | \\\n\t\t\t\t SBI_DOMAIN_MEMREGION_WRITEABLE | \\\n\t\t\t\t SBI_DOMAIN_MEMREGION_EXECUTABLE)\n\nstatic int __fixup_count_disable_devices(void *fdt, int doff, int roff,\n\t\t\t\t\t u32 perm, void *p)\n{\n\tint len;\n\tu32 *dcount = p;\n\n\tif (perm & DISABLE_DEVICES_MASK)\n\t\treturn 0;\n\n\tlen = 0;\n\tif (fdt_getprop(fdt, roff, \"devices\", &len))\n\t\t*dcount += len / sizeof(u32);\n\n\treturn 0;\n}\n\nstatic int __fixup_disable_devices(void *fdt, int doff, int roff,\n\t\t\t\t   u32 raccess, void *p)\n{\n\tint i, len, coff;\n\tconst u32 *devices;\n\n\tif (raccess & DISABLE_DEVICES_MASK)\n\t\treturn 0;\n\n\tlen = 0;\n\tdevices = fdt_getprop(fdt, roff, \"devices\", &len);\n\tif (!devices)\n\t\treturn 0;\n\tlen = len / sizeof(u32);\n\n\tfor (i = 0; i < len; i++) {\n\t\tcoff = fdt_node_offset_by_phandle(fdt,\n\t\t\t\t\tfdt32_to_cpu(devices[i]));\n\t\tif (coff < 0)\n\t\t\treturn coff;\n\n\t\tfdt_setprop_string(fdt, coff, \"status\", \"disabled\");\n\t}\n\n\treturn 0;\n}\n\nvoid fdt_domain_fixup(void *fdt)\n{\n\tu32 i, dcount;\n\tint err, poffset, doffset;\n\tstruct sbi_domain *dom = sbi_domain_thishart_ptr();\n\tstruct __fixup_find_domain_offset_info fdo;\n\n\t/* Remove the domain assignment DT property from CPU DT nodes */\n\tpoffset = fdt_path_offset(fdt, \"/cpus\");\n\tif (poffset < 0)\n\t\treturn;\n\tfdt_for_each_subnode(doffset, fdt, poffset) {\n\t\terr = fdt_parse_hart_id(fdt, doffset, &i);\n\t\tif (err)\n\t\t\tcontinue;\n\n\t\tif (!fdt_node_is_enabled(fdt, doffset))\n\t\t\tcontinue;\n\n\t\tfdt_nop_property(fdt, doffset, \"opensbi-domain\");\n\t}\n\n\t/* Skip device disable for root domain */\n\tif (!dom->index)\n\t\tgoto skip_device_disable;\n\n\t/* Find current domain DT node */\n\tdoffset = -1;\n\tfdo.name = dom->name;\n\tfdo.doffset = &doffset;\n\tfdt_iterate_each_domain(fdt, &fdo, __fixup_find_domain_offset);\n\tif (doffset < 0)\n\t\tgoto skip_device_disable;\n\n\t/* Count current domain device DT nodes to be disabled */\n\tdcount = 0;\n\tfdt_iterate_each_memregion(fdt, doffset, &dcount,\n\t\t\t\t   __fixup_count_disable_devices);\n\tif (!dcount)\n\t\tgoto skip_device_disable;\n\n\t/* Expand FDT based on device DT nodes to be disabled */\n\terr = fdt_open_into(fdt, fdt, fdt_totalsize(fdt) + dcount * 32);\n\tif (err < 0)\n\t\treturn;\n\n\t/* Again find current domain DT node */\n\tdoffset = -1;\n\tfdo.name = dom->name;\n\tfdo.doffset = &doffset;\n\tfdt_iterate_each_domain(fdt, &fdo, __fixup_find_domain_offset);\n\tif (doffset < 0)\n\t\tgoto skip_device_disable;\n\n\t/* Disable device DT nodes for current domain */\n\tfdt_iterate_each_memregion(fdt, doffset, NULL,\n\t\t\t\t   __fixup_disable_devices);\nskip_device_disable:\n\n\t/* Remove the OpenSBI domain config DT node */\n\tpoffset = fdt_path_offset(fdt, \"/chosen\");\n\tif (poffset < 0)\n\t\treturn;\n\tpoffset = fdt_node_offset_by_compatible(fdt, poffset,\n\t\t\t\t\t\t\"opensbi,domain,config\");\n\tif (poffset < 0)\n\t\treturn;\n\tfdt_nop_node(fdt, poffset);\n}\n\n#define FDT_DOMAIN_MAX_COUNT\t\t8\n#define FDT_DOMAIN_REGION_MAX_COUNT\t16\n\nstatic u32 fdt_domains_count;\nstatic struct sbi_domain fdt_domains[FDT_DOMAIN_MAX_COUNT];\nstatic struct sbi_hartmask fdt_masks[FDT_DOMAIN_MAX_COUNT];\nstatic struct sbi_domain_memregion\n\tfdt_regions[FDT_DOMAIN_MAX_COUNT][FDT_DOMAIN_REGION_MAX_COUNT + 1];\n\nstatic int __fdt_parse_region(void *fdt, int domain_offset,\n\t\t\t      int region_offset, u32 region_access,\n\t\t\t      void *opaque)\n{\n\tint len;\n\tu32 val32;\n\tu64 val64;\n\tconst u32 *val;\n\tu32 *region_count = opaque;\n\tstruct sbi_domain_memregion *region;\n\n\t/* Find next region of the domain */\n\tif (FDT_DOMAIN_REGION_MAX_COUNT <= *region_count)\n\t\treturn SBI_EINVAL;\n\tregion = &fdt_regions[fdt_domains_count][*region_count];\n\n\t/* Read \"base\" DT property */\n\tval = fdt_getprop(fdt, region_offset, \"base\", &len);\n\tif (!val || len != 8)\n\t\treturn SBI_EINVAL;\n\tval64 = fdt32_to_cpu(val[0]);\n\tval64 = (val64 << 32) | fdt32_to_cpu(val[1]);\n\tregion->base = val64;\n\n\t/* Read \"order\" DT property */\n\tval = fdt_getprop(fdt, region_offset, \"order\", &len);\n\tif (!val || len != 4)\n\t\treturn SBI_EINVAL;\n\tval32 = fdt32_to_cpu(*val);\n\tif (val32 < 3 || __riscv_xlen < val32)\n\t\treturn SBI_EINVAL;\n\tregion->order = val32;\n\n\t/* Read \"mmio\" DT property */\n\tregion->flags = region_access & SBI_DOMAIN_MEMREGION_ACCESS_MASK;\n\tif (fdt_get_property(fdt, region_offset, \"mmio\", NULL))\n\t\tregion->flags |= SBI_DOMAIN_MEMREGION_MMIO;\n\n\t(*region_count)++;\n\n\treturn 0;\n}\n\nstatic int __fdt_parse_domain(void *fdt, int domain_offset, void *opaque)\n{\n\tu32 val32;\n\tu64 val64;\n\tconst u32 *val;\n\tstruct sbi_domain *dom;\n\tstruct sbi_hartmask *mask;\n\tstruct sbi_hartmask assign_mask;\n\tint *cold_domain_offset = opaque;\n\tstruct sbi_domain_memregion *reg, *regions;\n\tint i, err, len, cpus_offset, cpu_offset, doffset;\n\n\t/* Sanity check on maximum domains we can handle */\n\tif (FDT_DOMAIN_MAX_COUNT <= fdt_domains_count)\n\t\treturn SBI_EINVAL;\n\tdom = &fdt_domains[fdt_domains_count];\n\tmask = &fdt_masks[fdt_domains_count];\n\tregions = &fdt_regions[fdt_domains_count][0];\n\n\t/* Read DT node name */\n\tstrncpy(dom->name, fdt_get_name(fdt, domain_offset, NULL),\n\t\t    sizeof(dom->name));\n\tdom->name[sizeof(dom->name) - 1] = '\\0';\n\n\t/* Setup possible HARTs mask */\n\tSBI_HARTMASK_INIT(mask);\n\tdom->possible_harts = mask;\n\tval = fdt_getprop(fdt, domain_offset, \"possible-harts\", &len);\n\tlen = len / sizeof(u32);\n\tif (val && len) {\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tcpu_offset = fdt_node_offset_by_phandle(fdt,\n\t\t\t\t\t\t\tfdt32_to_cpu(val[i]));\n\t\t\tif (cpu_offset < 0)\n\t\t\t\treturn cpu_offset;\n\n\t\t\terr = fdt_parse_hart_id(fdt, cpu_offset, &val32);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\n\t\t\tif (!fdt_node_is_enabled(fdt, cpu_offset))\n\t\t\t\tcontinue;\n\n\t\t\tsbi_hartmask_set_hart(val32, mask);\n\t\t}\n\t}\n\n\t/* Setup memregions from DT */\n\tval32 = 0;\n\tmemset(regions, 0,\n\t\t   sizeof(*regions) * (FDT_DOMAIN_REGION_MAX_COUNT + 1));\n\tdom->regions = regions;\n\terr = fdt_iterate_each_memregion(fdt, domain_offset, &val32,\n\t\t\t\t\t __fdt_parse_region);\n\tif (err)\n\t\treturn err;\n\n\t/*\n\t * Copy over root domain memregions which don't allow\n\t * read, write and execute from lower privilege modes.\n\t *\n\t * These root domain memregions without read, write,\n\t * and execute permissions include:\n\t * 1) firmware region protecting the firmware memory\n\t * 2) mmio regions protecting M-mode only mmio devices\n\t */\n\tsbi_domain_for_each_memregion(&root, reg) {\n\t\tif ((reg->flags & SBI_DOMAIN_MEMREGION_READABLE) ||\n\t\t    (reg->flags & SBI_DOMAIN_MEMREGION_WRITEABLE) ||\n\t\t    (reg->flags & SBI_DOMAIN_MEMREGION_EXECUTABLE))\n\t\t\tcontinue;\n\t\tif (FDT_DOMAIN_REGION_MAX_COUNT <= val32)\n\t\t\treturn SBI_EINVAL;\n\t\tmemcpy(&regions[val32++], reg, sizeof(*reg));\n\t}\n\n\t/* Read \"boot-hart\" DT property */\n\tval32 = -1U;\n\tval = fdt_getprop(fdt, domain_offset, \"boot-hart\", &len);\n\tif (val && len >= 4) {\n\t\tcpu_offset = fdt_node_offset_by_phandle(fdt,\n\t\t\t\t\t\t\t fdt32_to_cpu(*val));\n\t\tif (cpu_offset >= 0 && fdt_node_is_enabled(fdt, cpu_offset))\n\t\t\tfdt_parse_hart_id(fdt, cpu_offset, &val32);\n\t} else {\n\t\tif (domain_offset == *cold_domain_offset)\n\t\t\tval32 = current_hartid();\n\t}\n\tdom->boot_hartid = val32;\n\n\t/* Read \"next-arg1\" DT property */\n\tval64 = 0;\n\tval = fdt_getprop(fdt, domain_offset, \"next-arg1\", &len);\n\tif (val && len >= 8) {\n\t\tval64 = fdt32_to_cpu(val[0]);\n\t\tval64 = (val64 << 32) | fdt32_to_cpu(val[1]);\n\t} else {\n\t\tif (domain_offset == *cold_domain_offset)\n\t\t\tval64 = sbi_scratch_thishart_ptr()->next_arg1;\n\t}\n\tdom->next_arg1 = val64;\n\n\t/* Read \"next-addr\" DT property */\n\tval64 = 0;\n\tval = fdt_getprop(fdt, domain_offset, \"next-addr\", &len);\n\tif (val && len >= 8) {\n\t\tval64 = fdt32_to_cpu(val[0]);\n\t\tval64 = (val64 << 32) | fdt32_to_cpu(val[1]);\n\t} else {\n\t\tif (domain_offset == *cold_domain_offset)\n\t\t\tval64 = sbi_scratch_thishart_ptr()->next_addr;\n\t}\n\tdom->next_addr = val64;\n\n\t/* Read \"next-mode\" DT property */\n\tval32 = 0x1;\n\tval = fdt_getprop(fdt, domain_offset, \"next-mode\", &len);\n\tif (val && len >= 4) {\n\t\tval32 = fdt32_to_cpu(val[0]);\n\t\tif (val32 != 0x0 && val32 != 0x1)\n\t\t\tval32 = 0x1;\n\t} else {\n\t\tif (domain_offset == *cold_domain_offset)\n\t\t\tval32 = sbi_scratch_thishart_ptr()->next_mode;\n\t}\n\tdom->next_mode = val32;\n\n\t/* Read \"system-reset-allowed\" DT property */\n\tif (fdt_get_property(fdt, domain_offset,\n\t\t\t     \"system-reset-allowed\", NULL))\n\t\tdom->system_reset_allowed = TRUE;\n\telse\n\t\tdom->system_reset_allowed = FALSE;\n\n\t/* Find /cpus DT node */\n\tcpus_offset = fdt_path_offset(fdt, \"/cpus\");\n\tif (cpus_offset < 0)\n\t\treturn cpus_offset;\n\n\t/* HART to domain assignment mask based on CPU DT nodes */\n\tsbi_hartmask_clear_all(&assign_mask);\n\tfdt_for_each_subnode(cpu_offset, fdt, cpus_offset) {\n\t\terr = fdt_parse_hart_id(fdt, cpu_offset, &val32);\n\t\tif (err)\n\t\t\tcontinue;\n\n\t\tif (SBI_HARTMASK_MAX_BITS <= val32)\n\t\t\tcontinue;\n\n\t\tif (!fdt_node_is_enabled(fdt, cpu_offset))\n\t\t\tcontinue;\n\n\t\tval = fdt_getprop(fdt, cpu_offset, \"opensbi-domain\", &len);\n\t\tif (!val || len < 4)\n\t\t\treturn SBI_EINVAL;\n\n\t\tdoffset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*val));\n\t\tif (doffset < 0)\n\t\t\treturn doffset;\n\n\t\tif (doffset == domain_offset)\n\t\t\tsbi_hartmask_set_hart(val32, &assign_mask);\n\t}\n\n\t/* Increment domains count */\n\tfdt_domains_count++;\n\n\t/* Register the domain */\n\treturn sbi_domain_register(dom, &assign_mask);\n}\n\nint fdt_domains_populate(void *fdt)\n{\n\tconst u32 *val;\n\tint cold_domain_offset;\n\tu32 hartid, cold_hartid;\n\tint err, len, cpus_offset, cpu_offset;\n\n\t/* Sanity checks */\n\tif (!fdt)\n\t\treturn SBI_EINVAL;\n\n\t/* Find /cpus DT node */\n\tcpus_offset = fdt_path_offset(fdt, \"/cpus\");\n\tif (cpus_offset < 0)\n\t\treturn cpus_offset;\n\n\t/* Find coldboot HART domain DT node offset */\n\tcold_domain_offset = -1;\n\tcold_hartid = current_hartid();\n\tfdt_for_each_subnode(cpu_offset, fdt, cpus_offset) {\n\t\terr = fdt_parse_hart_id(fdt, cpu_offset, &hartid);\n\t\tif (err)\n\t\t\tcontinue;\n\n\t\tif (hartid != cold_hartid)\n\t\t\tcontinue;\n\n\t\tif (!fdt_node_is_enabled(fdt, cpu_offset))\n\t\t\tcontinue;\n\n\t\tval = fdt_getprop(fdt, cpu_offset, \"opensbi-domain\", &len);\n\t\tif (val && len >= 4)\n\t\t\tcold_domain_offset = fdt_node_offset_by_phandle(fdt,\n\t\t\t\t\t\t\t   fdt32_to_cpu(*val));\n\n\t\tbreak;\n\t}\n\n\t/* Iterate over each domain in FDT and populate details */\n\treturn fdt_iterate_each_domain(fdt, &cold_domain_offset,\n\t\t\t\t       __fdt_parse_domain);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/fdt/fdt_fixup.c",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * fdt_fixup.c - Flat Device Tree parsing helper routines\n * Implement helper routines to parse FDT nodes on top of\n * libfdt for OpenSBI usage\n *\n * Copyright (C) 2020 Bin Meng <bmeng.cn@gmail.com>\n */\n\n#include <libfdt.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_math.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_string.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n#include <sbi_utils/fdt/fdt_pmu.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n\nvoid fdt_cpu_fixup(void *fdt)\n{\n\tstruct sbi_domain *dom = sbi_domain_thishart_ptr();\n\tint err, cpu_offset, cpus_offset, len;\n\tconst char *mmu_type;\n\tu32 hartid;\n\n\terr = fdt_open_into(fdt, fdt, fdt_totalsize(fdt) + 32);\n\tif (err < 0)\n\t\treturn;\n\n\tcpus_offset = fdt_path_offset(fdt, \"/cpus\");\n\tif (cpus_offset < 0)\n\t\treturn;\n\n\tfdt_for_each_subnode(cpu_offset, fdt, cpus_offset) {\n\t\terr = fdt_parse_hart_id(fdt, cpu_offset, &hartid);\n\t\tif (err)\n\t\t\tcontinue;\n\n\t\tif (!fdt_node_is_enabled(fdt, cpu_offset))\n\t\t\tcontinue;\n\n\t\t/*\n\t\t * Disable a HART DT node if one of the following is true:\n\t\t * 1. The HART is not assigned to the current domain\n\t\t * 2. MMU is not available for the HART\n\t\t */\n\n\t\tmmu_type = fdt_getprop(fdt, cpu_offset, \"mmu-type\", &len);\n\t\tif (!sbi_domain_is_assigned_hart(dom, hartid) ||\n\t\t    !mmu_type || !len)\n\t\t\tfdt_setprop_string(fdt, cpu_offset, \"status\",\n\t\t\t\t\t   \"disabled\");\n\t}\n}\n\nstatic void fdt_domain_based_fixup_one(void *fdt, int nodeoff)\n{\n\tint rc;\n\tuint64_t reg_addr, reg_size;\n\tstruct sbi_domain *dom = sbi_domain_thishart_ptr();\n\n\trc = fdt_get_node_addr_size(fdt, nodeoff, 0, &reg_addr, &reg_size);\n\tif (rc < 0 || !reg_addr || !reg_size)\n\t\treturn;\n\n\tif (!sbi_domain_check_addr(dom, reg_addr, dom->next_mode,\n\t\t\t\t    SBI_DOMAIN_READ | SBI_DOMAIN_WRITE)) {\n\t\trc = fdt_open_into(fdt, fdt, fdt_totalsize(fdt) + 32);\n\t\tif (rc < 0)\n\t\t\treturn;\n\t\tfdt_setprop_string(fdt, nodeoff, \"status\", \"disabled\");\n\t}\n}\n\nstatic void fdt_fixup_node(void *fdt, const char *compatible)\n{\n\tint noff = 0;\n\n\twhile ((noff = fdt_node_offset_by_compatible(fdt, noff,\n\t\t\t\t\t\t     compatible)) >= 0)\n\t\tfdt_domain_based_fixup_one(fdt, noff);\n}\n\nvoid fdt_aplic_fixup(void *fdt)\n{\n\tfdt_fixup_node(fdt, \"riscv,aplic\");\n}\n\nvoid fdt_imsic_fixup(void *fdt)\n{\n\tfdt_fixup_node(fdt, \"riscv,imsics\");\n}\n\nvoid fdt_plic_fixup(void *fdt)\n{\n\tu32 *cells;\n\tint i, cells_count;\n\tint plic_off;\n\n\tplic_off = fdt_node_offset_by_compatible(fdt, 0, \"sifive,plic-1.0.0\");\n\tif (plic_off < 0) {\n\t\tplic_off = fdt_node_offset_by_compatible(fdt, 0, \"riscv,plic0\");\n\t\tif (plic_off < 0)\n\t\t\treturn;\n\t}\n\n\tcells = (u32 *)fdt_getprop(fdt, plic_off,\n\t\t\t\t   \"interrupts-extended\", &cells_count);\n\tif (!cells)\n\t\treturn;\n\n\tcells_count = cells_count / sizeof(u32);\n\tif (!cells_count)\n\t\treturn;\n\n\tfor (i = 0; i < (cells_count / 2); i++) {\n\t\tif (fdt32_to_cpu(cells[2 * i + 1]) == IRQ_M_EXT)\n\t\t\tcells[2 * i + 1] = cpu_to_fdt32(0xffffffff);\n\t}\n}\n\nstatic int fdt_resv_memory_update_node(void *fdt, unsigned long addr,\n\t\t\t\t       unsigned long size, int index,\n\t\t\t\t       int parent, bool no_map)\n{\n\tint na = fdt_address_cells(fdt, 0);\n\tint ns = fdt_size_cells(fdt, 0);\n\tfdt32_t addr_high, addr_low;\n\tfdt32_t size_high, size_low;\n\tint subnode, err;\n\tfdt32_t reg[4];\n\tfdt32_t *val;\n\tchar name[32];\n\n\taddr_high = (u64)addr >> 32;\n\taddr_low = addr;\n\tsize_high = (u64)size >> 32;\n\tsize_low = size;\n\n\tif (na > 1 && addr_high)\n\t\tsbi_snprintf(name, sizeof(name),\n\t\t\t     \"mmode_resv%d@%x,%x\", index,\n\t\t\t     addr_high, addr_low);\n\telse\n\t\tsbi_snprintf(name, sizeof(name),\n\t\t\t     \"mmode_resv%d@%x\", index,\n\t\t\t     addr_low);\n\n\tsubnode = fdt_add_subnode(fdt, parent, name);\n\tif (subnode < 0)\n\t\treturn subnode;\n\n\tif (no_map) {\n\t\t/*\n\t\t * Tell operating system not to create a virtual\n\t\t * mapping of the region as part of its standard\n\t\t * mapping of system memory.\n\t\t */\n\t\terr = fdt_setprop_empty(fdt, subnode, \"no-map\");\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\t/* encode the <reg> property value */\n\tval = reg;\n\tif (na > 1)\n\t\t*val++ = cpu_to_fdt32(addr_high);\n\t*val++ = cpu_to_fdt32(addr_low);\n\tif (ns > 1)\n\t\t*val++ = cpu_to_fdt32(size_high);\n\t*val++ = cpu_to_fdt32(size_low);\n\n\terr = fdt_setprop(fdt, subnode, \"reg\", reg,\n\t\t\t  (na + ns) * sizeof(fdt32_t));\n\tif (err < 0)\n\t\treturn err;\n\n\treturn 0;\n}\n\n/**\n * We use PMP to protect OpenSBI firmware to safe-guard it from buggy S-mode\n * software, see pmp_init() in lib/sbi/sbi_hart.c. The protected memory region\n * information needs to be conveyed to S-mode software (e.g.: operating system)\n * via some well-known method.\n *\n * With device tree, this can be done by inserting a child node of the reserved\n * memory node which is used to specify one or more regions of reserved memory.\n *\n * For the reserved memory node bindings, see Linux kernel documentation at\n * Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt\n *\n * Some additional memory spaces may be protected by platform codes via PMP as\n * well, and corresponding child nodes will be inserted.\n */\nint fdt_reserved_memory_fixup(void *fdt)\n{\n\tstruct sbi_domain_memregion *reg;\n\tstruct sbi_domain *dom = sbi_domain_thishart_ptr();\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\tunsigned long addr, size;\n\tint err, parent, i;\n\tint na = fdt_address_cells(fdt, 0);\n\tint ns = fdt_size_cells(fdt, 0);\n\n\t/*\n\t * Expand the device tree to accommodate new node\n\t * by the following estimated size:\n\t *\n\t * Each PMP memory region entry occupies 64 bytes.\n\t * With 16 PMP memory regions we need 64 * 16 = 1024 bytes.\n\t */\n\terr = fdt_open_into(fdt, fdt, fdt_totalsize(fdt) + 1024);\n\tif (err < 0)\n\t\treturn err;\n\n\t/* try to locate the reserved memory node */\n\tparent = fdt_path_offset(fdt, \"/reserved-memory\");\n\tif (parent < 0) {\n\t\t/* if such node does not exist, create one */\n\t\tparent = fdt_add_subnode(fdt, 0, \"reserved-memory\");\n\t\tif (parent < 0)\n\t\t\treturn parent;\n\n\t\t/*\n\t\t * reserved-memory node has 3 required properties:\n\t\t * - #address-cells: the same value as the root node\n\t\t * - #size-cells: the same value as the root node\n\t\t * - ranges: should be empty\n\t\t */\n\n\t\terr = fdt_setprop_empty(fdt, parent, \"ranges\");\n\t\tif (err < 0)\n\t\t\treturn err;\n\n\t\terr = fdt_setprop_u32(fdt, parent, \"#size-cells\", ns);\n\t\tif (err < 0)\n\t\t\treturn err;\n\n\t\terr = fdt_setprop_u32(fdt, parent, \"#address-cells\", na);\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\t/*\n\t * We assume the given device tree does not contain any memory region\n\t * child node protected by PMP. Normally PMP programming happens at\n\t * M-mode firmware. The memory space used by OpenSBI is protected.\n\t * Some additional memory spaces may be protected by domain memory\n\t * regions.\n\t *\n\t * With above assumption, we create child nodes directly.\n\t */\n\n\ti = 0;\n\tsbi_domain_for_each_memregion(dom, reg) {\n\t\t/* Ignore MMIO or READABLE or WRITABLE or EXECUTABLE regions */\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_MMIO)\n\t\t\tcontinue;\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_READABLE)\n\t\t\tcontinue;\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_WRITEABLE)\n\t\t\tcontinue;\n\t\tif (reg->flags & SBI_DOMAIN_MEMREGION_EXECUTABLE)\n\t\t\tcontinue;\n\n\t\taddr = reg->base;\n\t\tsize = 1UL << reg->order;\n\t\tfdt_resv_memory_update_node(fdt, addr, size, i, parent,\n\t\t\t(sbi_hart_pmp_count(scratch)) ? false : true);\n\t\ti++;\n\t}\n\n\treturn 0;\n}\n\nint fdt_reserved_memory_nomap_fixup(void *fdt)\n{\n\tint parent, subnode;\n\tint err;\n\n\t/* Locate the reserved memory node */\n\tparent = fdt_path_offset(fdt, \"/reserved-memory\");\n\tif (parent < 0)\n\t\treturn parent;\n\n\tfdt_for_each_subnode(subnode, fdt, parent) {\n\t\t/*\n\t\t * Tell operating system not to create a virtual\n\t\t * mapping of the region as part of its standard\n\t\t * mapping of system memory.\n\t\t */\n\t\terr = fdt_setprop_empty(fdt, subnode, \"no-map\");\n\t\tif (err < 0)\n\t\t\treturn err;\n\t}\n\n\treturn 0;\n}\n\nvoid fdt_fixups(void *fdt)\n{\n\tfdt_aplic_fixup(fdt);\n\n\tfdt_imsic_fixup(fdt);\n\n\tfdt_plic_fixup(fdt);\n\n\tfdt_reserved_memory_fixup(fdt);\n\tfdt_pmu_fixup(fdt);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/fdt/fdt_helper.c",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * fdt_helper.c - Flat Device Tree manipulation helper routines\n * Implement helper routines on top of libfdt for OpenSBI usage\n *\n * Copyright (C) 2020 Bin Meng <bmeng.cn@gmail.com>\n */\n\n#include <libfdt.h>\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/irqchip/aplic.h>\n#include <sbi_utils/irqchip/imsic.h>\n#include <sbi_utils/irqchip/plic.h>\n\n#define DEFAULT_UART_FREQ\t\t0\n#define DEFAULT_UART_BAUD\t\t115200\n#define DEFAULT_UART_REG_SHIFT\t\t0\n#define DEFAULT_UART_REG_IO_WIDTH\t1\n#define DEFAULT_UART_REG_OFFSET\t\t0\n\n#define DEFAULT_RENESAS_SCIF_FREQ\t\t100000000\n#define DEFAULT_RENESAS_SCIF_BAUD\t\t115200\n\n#define DEFAULT_SIFIVE_UART_FREQ\t\t0\n#define DEFAULT_SIFIVE_UART_BAUD\t\t115200\n\n#define DEFAULT_SHAKTI_UART_FREQ\t\t50000000\n#define DEFAULT_SHAKTI_UART_BAUD\t\t115200\n\nconst struct fdt_match *fdt_match_node(void *fdt, int nodeoff,\n\t\t\t\t       const struct fdt_match *match_table)\n{\n\tint ret;\n\n\tif (!fdt || nodeoff < 0 || !match_table)\n\t\treturn NULL;\n\n\twhile (match_table->compatible) {\n\t\tret = fdt_node_check_compatible(fdt, nodeoff,\n\t\t\t\t\t\tmatch_table->compatible);\n\t\tif (!ret)\n\t\t\treturn match_table;\n\t\tmatch_table++;\n\t}\n\n\treturn NULL;\n}\n\nint fdt_find_match(void *fdt, int startoff,\n\t\t   const struct fdt_match *match_table,\n\t\t   const struct fdt_match **out_match)\n{\n\tint nodeoff;\n\n\tif (!fdt || !match_table)\n\t\treturn SBI_ENODEV;\n\n\twhile (match_table->compatible) {\n\t\tnodeoff = fdt_node_offset_by_compatible(fdt, startoff,\n\t\t\t\t\t\tmatch_table->compatible);\n\t\tif (nodeoff >= 0) {\n\t\t\tif (out_match)\n\t\t\t\t*out_match = match_table;\n\t\t\treturn nodeoff;\n\t\t}\n\t\tmatch_table++;\n\t}\n\n\treturn SBI_ENODEV;\n}\n\nint fdt_parse_phandle_with_args(void *fdt, int nodeoff,\n\t\t\t\tconst char *prop, const char *cells_prop,\n\t\t\t\tint index, struct fdt_phandle_args *out_args)\n{\n\tu32 i, pcells;\n\tint len, pnodeoff;\n\tconst fdt32_t *list, *list_end, *val;\n\n\tif (!fdt || (nodeoff < 0) || !prop || !cells_prop || !out_args)\n\t\treturn SBI_EINVAL;\n\n\tlist = fdt_getprop(fdt, nodeoff, prop, &len);\n\tif (!list)\n\t\treturn SBI_ENOENT;\n\tlist_end = list + (len / sizeof(*list));\n\n\twhile (list < list_end) {\n\t\tpnodeoff = fdt_node_offset_by_phandle(fdt,\n\t\t\t\t\t\tfdt32_to_cpu(*list));\n\t\tif (pnodeoff < 0)\n\t\t\treturn pnodeoff;\n\t\tlist++;\n\n\t\tval = fdt_getprop(fdt, pnodeoff, cells_prop, &len);\n\t\tif (!val)\n\t\t\treturn SBI_ENOENT;\n\t\tpcells = fdt32_to_cpu(*val);\n\t\tif (FDT_MAX_PHANDLE_ARGS < pcells)\n\t\t\treturn SBI_EINVAL;\n\t\tif (list + pcells > list_end)\n\t\t\treturn SBI_ENOENT;\n\n\t\tif (index > 0) {\n\t\t\tlist += pcells;\n\t\t\tindex--;\n\t\t} else {\n\t\t\tout_args->node_offset = pnodeoff;\n\t\t\tout_args->args_count = pcells;\n\t\t\tfor (i = 0; i < pcells; i++)\n\t\t\t\tout_args->args[i] = fdt32_to_cpu(list[i]);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn SBI_ENOENT;\n}\n\nstatic int fdt_translate_address(void *fdt, uint64_t reg, int parent,\n\t\t\t\t uint64_t *addr)\n{\n\tint i, rlen;\n\tint cell_addr, cell_size;\n\tconst fdt32_t *ranges;\n\tuint64_t offset, caddr = 0, paddr = 0, rsize = 0;\n\n\tcell_addr = fdt_address_cells(fdt, parent);\n\tif (cell_addr < 1)\n\t\treturn SBI_ENODEV;\n\n\tcell_size = fdt_size_cells(fdt, parent);\n\tif (cell_size < 0)\n\t\treturn SBI_ENODEV;\n\n\tranges = fdt_getprop(fdt, parent, \"ranges\", &rlen);\n\tif (ranges && rlen > 0) {\n\t\tfor (i = 0; i < cell_addr; i++)\n\t\t\tcaddr = (caddr << 32) | fdt32_to_cpu(*ranges++);\n\t\tfor (i = 0; i < cell_addr; i++)\n\t\t\tpaddr = (paddr << 32) | fdt32_to_cpu(*ranges++);\n\t\tfor (i = 0; i < cell_size; i++)\n\t\t\trsize = (rsize << 32) | fdt32_to_cpu(*ranges++);\n\t\tif (reg < caddr || caddr >= (reg + rsize )) {\n\t\t\tsbi_printf(\"invalid address translation\\n\");\n\t\t\treturn SBI_ENODEV;\n\t\t}\n\t\toffset = reg - caddr;\n\t\t*addr = paddr + offset;\n\t} else {\n\t\t/* No translation required */\n\t\t*addr = reg;\n\t}\n\n\treturn 0;\n}\n\nint fdt_get_node_addr_size(void *fdt, int node, int index,\n\t\t\t   uint64_t *addr, uint64_t *size)\n{\n\tint parent, len, i, rc;\n\tint cell_addr, cell_size;\n\tconst fdt32_t *prop_addr, *prop_size;\n\tuint64_t temp = 0;\n\n\tif (!fdt || node < 0 || index < 0)\n\t\treturn SBI_EINVAL;\n\n\tparent = fdt_parent_offset(fdt, node);\n\tif (parent < 0)\n\t\treturn parent;\n\tcell_addr = fdt_address_cells(fdt, parent);\n\tif (cell_addr < 1)\n\t\treturn SBI_ENODEV;\n\n\tcell_size = fdt_size_cells(fdt, parent);\n\tif (cell_size < 0)\n\t\treturn SBI_ENODEV;\n\n\tprop_addr = fdt_getprop(fdt, node, \"reg\", &len);\n\tif (!prop_addr)\n\t\treturn SBI_ENODEV;\n\n\tif ((len / sizeof(u32)) <= (index * (cell_addr + cell_size)))\n\t\treturn SBI_EINVAL;\n\n\tprop_addr = prop_addr + (index * (cell_addr + cell_size));\n\tprop_size = prop_addr + cell_addr;\n\n\tif (addr) {\n\t\tfor (i = 0; i < cell_addr; i++)\n\t\t\ttemp = (temp << 32) | fdt32_to_cpu(*prop_addr++);\n\t\tdo {\n\t\t\tif (parent < 0)\n\t\t\t\tbreak;\n\t\t\trc  = fdt_translate_address(fdt, temp, parent, addr);\n\t\t\tif (rc)\n\t\t\t\tbreak;\n\t\t\tparent = fdt_parent_offset(fdt, parent);\n\t\t\ttemp = *addr;\n\t\t} while (1);\n\t}\n\ttemp = 0;\n\n\tif (size) {\n\t\tfor (i = 0; i < cell_size; i++)\n\t\t\ttemp = (temp << 32) | fdt32_to_cpu(*prop_size++);\n\t\t*size = temp;\n\t}\n\n\treturn 0;\n}\n\nbool fdt_node_is_enabled(void *fdt, int nodeoff)\n{\n\tint len;\n\tconst void *prop;\n\n\tprop = fdt_getprop(fdt, nodeoff, \"status\", &len);\n\tif (!prop)\n\t\treturn true;\n\n\tif (!strncmp(prop, \"okay\", strlen(\"okay\")))\n\t\treturn true;\n\n\tif (!strncmp(prop, \"ok\", strlen(\"ok\")))\n\t\treturn true;\n\n\treturn false;\n}\n\nint fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid)\n{\n\tint len;\n\tconst void *prop;\n\tconst fdt32_t *val;\n\n\tif (!fdt || cpu_offset < 0)\n\t\treturn SBI_EINVAL;\n\n\tprop = fdt_getprop(fdt, cpu_offset, \"device_type\", &len);\n\tif (!prop || !len)\n\t\treturn SBI_EINVAL;\n\tif (strncmp (prop, \"cpu\", strlen (\"cpu\")))\n\t\treturn SBI_EINVAL;\n\n\tval = fdt_getprop(fdt, cpu_offset, \"reg\", &len);\n\tif (!val || len < sizeof(fdt32_t))\n\t\treturn SBI_EINVAL;\n\n\tif (len > sizeof(fdt32_t))\n\t\tval++;\n\n\tif (hartid)\n\t\t*hartid = fdt32_to_cpu(*val);\n\n\treturn 0;\n}\n\nint fdt_parse_max_enabled_hart_id(void *fdt, u32 *max_hartid)\n{\n\tu32 hartid;\n\tint err, cpu_offset, cpus_offset;\n\n\tif (!fdt)\n\t\treturn SBI_EINVAL;\n\tif (!max_hartid)\n\t\treturn 0;\n\n\t*max_hartid = 0;\n\n\tcpus_offset = fdt_path_offset(fdt, \"/cpus\");\n\tif (cpus_offset < 0)\n\t\treturn cpus_offset;\n\n\tfdt_for_each_subnode(cpu_offset, fdt, cpus_offset) {\n\t\terr = fdt_parse_hart_id(fdt, cpu_offset, &hartid);\n\t\tif (err)\n\t\t\tcontinue;\n\n\t\tif (!fdt_node_is_enabled(fdt, cpu_offset))\n\t\t\tcontinue;\n\n\t\tif (hartid > *max_hartid)\n\t\t\t*max_hartid = hartid;\n\t}\n\n\treturn 0;\n}\n\nint fdt_parse_timebase_frequency(void *fdt, unsigned long *freq)\n{\n\tconst fdt32_t *val;\n\tint len, cpus_offset;\n\n\tif (!fdt || !freq)\n\t\treturn SBI_EINVAL;\n\n\tcpus_offset = fdt_path_offset(fdt, \"/cpus\");\n\tif (cpus_offset < 0)\n\t\treturn cpus_offset;\n\n\tval = fdt_getprop(fdt, cpus_offset, \"timebase-frequency\", &len);\n\tif (len > 0 && val)\n\t\t*freq = fdt32_to_cpu(*val);\n\telse\n\t\treturn SBI_ENOENT;\n\n\treturn 0;\n}\n\nstatic int fdt_parse_uart_node_common(void *fdt, int nodeoffset,\n\t\t\t\t      struct platform_uart_data *uart,\n\t\t\t\t      unsigned long default_freq,\n\t\t\t\t      unsigned long default_baud)\n{\n\tint len, rc;\n\tconst fdt32_t *val;\n\tuint64_t reg_addr, reg_size;\n\n\tif (nodeoffset < 0 || !uart || !fdt)\n\t\treturn SBI_ENODEV;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoffset, 0,\n\t\t\t\t    &reg_addr, &reg_size);\n\tif (rc < 0 || !reg_addr || !reg_size)\n\t\treturn SBI_ENODEV;\n\tuart->addr = reg_addr;\n\n\t/**\n\t * UART address is mandatory. clock-frequency and current-speed\n\t * may not be present. Don't return error.\n\t */\n\tval = (fdt32_t *)fdt_getprop(fdt, nodeoffset, \"clock-frequency\", &len);\n\tif (len > 0 && val)\n\t\tuart->freq = fdt32_to_cpu(*val);\n\telse\n\t\tuart->freq = default_freq;\n\n\tval = (fdt32_t *)fdt_getprop(fdt, nodeoffset, \"current-speed\", &len);\n\tif (len > 0 && val)\n\t\tuart->baud = fdt32_to_cpu(*val);\n\telse\n\t\tuart->baud = default_baud;\n\n\treturn 0;\n}\n\nint fdt_parse_gaisler_uart_node(void *fdt, int nodeoffset,\n\t\t\t\tstruct platform_uart_data *uart)\n{\n\treturn fdt_parse_uart_node_common(fdt, nodeoffset, uart,\n\t\t\t\t\tDEFAULT_UART_FREQ,\n\t\t\t\t\tDEFAULT_UART_BAUD);\n}\n\nint fdt_parse_renesas_scif_node(void *fdt, int nodeoffset,\n\t\t\t\tstruct platform_uart_data *uart)\n{\n\treturn fdt_parse_uart_node_common(fdt, nodeoffset, uart,\n\t\t\t\t\t  DEFAULT_RENESAS_SCIF_FREQ,\n\t\t\t\t\t  DEFAULT_RENESAS_SCIF_BAUD);\n}\n\nint fdt_parse_shakti_uart_node(void *fdt, int nodeoffset,\n\t\t\t       struct platform_uart_data *uart)\n{\n\treturn fdt_parse_uart_node_common(fdt, nodeoffset, uart,\n\t\t\t\t\tDEFAULT_SHAKTI_UART_FREQ,\n\t\t\t\t\tDEFAULT_SHAKTI_UART_BAUD);\n}\n\nint fdt_parse_sifive_uart_node(void *fdt, int nodeoffset,\n\t\t\t       struct platform_uart_data *uart)\n{\n\treturn fdt_parse_uart_node_common(fdt, nodeoffset, uart,\n\t\t\t\t\tDEFAULT_SIFIVE_UART_FREQ,\n\t\t\t\t\tDEFAULT_SIFIVE_UART_BAUD);\n}\n\nint fdt_parse_uart_node(void *fdt, int nodeoffset,\n\t\t\tstruct platform_uart_data *uart)\n{\n\tint len, rc;\n\tconst fdt32_t *val;\n\n\trc = fdt_parse_uart_node_common(fdt, nodeoffset, uart,\n\t\t\t\t\tDEFAULT_UART_FREQ,\n\t\t\t\t\tDEFAULT_UART_BAUD);\n\tif (rc)\n\t\treturn rc;\n\n\tval = (fdt32_t *)fdt_getprop(fdt, nodeoffset, \"reg-shift\", &len);\n\tif (len > 0 && val)\n\t\tuart->reg_shift = fdt32_to_cpu(*val);\n\telse\n\t\tuart->reg_shift = DEFAULT_UART_REG_SHIFT;\n\n\tval = (fdt32_t *)fdt_getprop(fdt, nodeoffset, \"reg-io-width\", &len);\n\tif (len > 0 && val)\n\t\tuart->reg_io_width = fdt32_to_cpu(*val);\n\telse\n\t\tuart->reg_io_width = DEFAULT_UART_REG_IO_WIDTH;\n\n\tval = (fdt32_t *)fdt_getprop(fdt, nodeoffset, \"reg-offset\", &len);\n\tif (len > 0 && val)\n\t\tuart->reg_offset = fdt32_to_cpu(*val);\n\telse\n\t\tuart->reg_offset = DEFAULT_UART_REG_OFFSET;\n\n\treturn 0;\n}\n\nint fdt_parse_uart8250(void *fdt, struct platform_uart_data *uart,\n\t\t   const char *compatible)\n{\n\tint nodeoffset;\n\n\tif (!compatible || !uart || !fdt)\n\t\treturn SBI_ENODEV;\n\n\tnodeoffset = fdt_node_offset_by_compatible(fdt, -1, compatible);\n\tif (nodeoffset < 0)\n\t\treturn nodeoffset;\n\n\treturn fdt_parse_uart_node(fdt, nodeoffset, uart);\n}\n\nint fdt_parse_xlnx_uartlite_node(void *fdt, int nodeoffset,\n\t\t\t       struct platform_uart_data *uart)\n{\n\treturn fdt_parse_uart_node_common(fdt, nodeoffset, uart, 0, 0);\n}\n\nint fdt_parse_aplic_node(void *fdt, int nodeoff, struct aplic_data *aplic)\n{\n\tbool child_found;\n\tconst fdt32_t *val;\n\tconst fdt32_t *del;\n\tstruct imsic_data imsic;\n\tint i, j, d, dcnt, len, noff, rc;\n\tuint64_t reg_addr, reg_size;\n\tstruct aplic_delegate_data *deleg;\n\n\tif (nodeoff < 0 || !aplic || !fdt)\n\t\treturn SBI_ENODEV;\n\tmemset(aplic, 0, sizeof(*aplic));\n\n\trc = fdt_get_node_addr_size(fdt, nodeoff, 0, &reg_addr, &reg_size);\n\tif (rc < 0 || !reg_addr || !reg_size)\n\t\treturn SBI_ENODEV;\n\taplic->addr = reg_addr;\n\taplic->size = reg_size;\n\n\tval = fdt_getprop(fdt, nodeoff, \"riscv,num-sources\", &len);\n\tif (len > 0)\n\t\taplic->num_source = fdt32_to_cpu(*val);\n\n\tval = fdt_getprop(fdt, nodeoff, \"interrupts-extended\", &len);\n\tif (val && len > sizeof(fdt32_t)) {\n\t\tlen = len / sizeof(fdt32_t);\n\t\tfor (i = 0; i < len; i += 2) {\n\t\t\tif (fdt32_to_cpu(val[i + 1]) == IRQ_M_EXT) {\n\t\t\t\taplic->targets_mmode = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\taplic->num_idc = len / 2;\n\t\tgoto aplic_msi_parent_done;\n\t}\n\n\tval = fdt_getprop(fdt, nodeoff, \"msi-parent\", &len);\n\tif (val && len >= sizeof(fdt32_t)) {\n\t\tnoff = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*val));\n\t\tif (noff < 0)\n\t\t\treturn noff;\n\n\t\trc = fdt_parse_imsic_node(fdt, noff, &imsic);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\trc = imsic_data_check(&imsic);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\taplic->targets_mmode = imsic.targets_mmode;\n\n\t\tif (imsic.targets_mmode) {\n\t\t\taplic->has_msicfg_mmode = true;\n\t\t\taplic->msicfg_mmode.lhxs = imsic.guest_index_bits;\n\t\t\taplic->msicfg_mmode.lhxw = imsic.hart_index_bits;\n\t\t\taplic->msicfg_mmode.hhxw = imsic.group_index_bits;\n\t\t\taplic->msicfg_mmode.hhxs = imsic.group_index_shift;\n\t\t\tif (aplic->msicfg_mmode.hhxs <\n\t\t\t\t\t(2 * IMSIC_MMIO_PAGE_SHIFT))\n\t\t\t\treturn SBI_EINVAL;\n\t\t\taplic->msicfg_mmode.hhxs -= 24;\n\t\t\taplic->msicfg_mmode.base_addr = imsic.regs[0].addr;\n\t\t} else {\n\t\t\tgoto aplic_msi_parent_done;\n\t\t}\n\n\t\tval = fdt_getprop(fdt, nodeoff, \"riscv,children\", &len);\n\t\tif (!val || len < sizeof(fdt32_t))\n\t\t\tgoto aplic_msi_parent_done;\n\n\t\tnoff = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*val));\n\t\tif (noff < 0)\n\t\t\treturn noff;\n\n\t\tval = fdt_getprop(fdt, noff, \"msi-parent\", &len);\n\t\tif (!val || len < sizeof(fdt32_t))\n\t\t\tgoto aplic_msi_parent_done;\n\n\t\tnoff = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*val));\n\t\tif (noff < 0)\n\t\t\treturn noff;\n\n\t\trc = fdt_parse_imsic_node(fdt, noff, &imsic);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\trc = imsic_data_check(&imsic);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\tif (!imsic.targets_mmode) {\n\t\t\taplic->has_msicfg_smode = true;\n\t\t\taplic->msicfg_smode.lhxs = imsic.guest_index_bits;\n\t\t\taplic->msicfg_smode.lhxw = imsic.hart_index_bits;\n\t\t\taplic->msicfg_smode.hhxw = imsic.group_index_bits;\n\t\t\taplic->msicfg_smode.hhxs = imsic.group_index_shift;\n\t\t\tif (aplic->msicfg_smode.hhxs <\n\t\t\t\t\t(2 * IMSIC_MMIO_PAGE_SHIFT))\n\t\t\t\treturn SBI_EINVAL;\n\t\t\taplic->msicfg_smode.hhxs -= 24;\n\t\t\taplic->msicfg_smode.base_addr = imsic.regs[0].addr;\n\t\t}\n\t}\naplic_msi_parent_done:\n\n\tfor (d = 0; d < APLIC_MAX_DELEGATE; d++) {\n\t\tdeleg = &aplic->delegate[d];\n\t\tdeleg->first_irq = 0;\n\t\tdeleg->last_irq = 0;\n\t\tdeleg->child_index = 0;\n\t}\n\n\tdel = fdt_getprop(fdt, nodeoff, \"riscv,delegate\", &len);\n\tif (!del || len < (3 * sizeof(fdt32_t)))\n\t\tgoto skip_delegate_parse;\n\td = 0;\n\tdcnt = len / sizeof(fdt32_t);\n\tfor (i = 0; i < dcnt; i += 3) {\n\t\tif (d >= APLIC_MAX_DELEGATE)\n\t\t\tbreak;\n\t\tdeleg = &aplic->delegate[d];\n\n\t\tdeleg->first_irq = fdt32_to_cpu(del[i + 1]);\n\t\tdeleg->last_irq = fdt32_to_cpu(del[i + 2]);\n\t\tdeleg->child_index = 0;\n\n\t\tchild_found = false;\n\t\tval = fdt_getprop(fdt, nodeoff, \"riscv,children\", &len);\n\t\tif (!val || len < sizeof(fdt32_t)) {\n\t\t\tdeleg->first_irq = 0;\n\t\t\tdeleg->last_irq = 0;\n\t\t\tdeleg->child_index = 0;\n\t\t\tcontinue;\n\t\t}\n\t\tlen = len / sizeof(fdt32_t);\n\t\tfor (j = 0; j < len; j++) {\n\t\t\tif (del[i] != val[j])\n\t\t\t\tcontinue;\n\t\t\tdeleg->child_index = j;\n\t\t\tchild_found = true;\n\t\t\tbreak;\n\t\t}\n\n\t\tif (child_found) {\n\t\t\td++;\n\t\t} else {\n\t\t\tdeleg->first_irq = 0;\n\t\t\tdeleg->last_irq = 0;\n\t\t\tdeleg->child_index = 0;\n\t\t}\n\t}\nskip_delegate_parse:\n\n\treturn 0;\n}\n\nbool fdt_check_imsic_mlevel(void *fdt)\n{\n\tconst fdt32_t *val;\n\tint i, len, noff = 0;\n\n\tif (!fdt)\n\t\treturn false;\n\n\twhile ((noff = fdt_node_offset_by_compatible(fdt, noff,\n\t\t\t\t\t\t     \"riscv,imsics\")) >= 0) {\n\t\tval = fdt_getprop(fdt, noff, \"interrupts-extended\", &len);\n\t\tif (val && len > sizeof(fdt32_t)) {\n\t\t\tlen = len / sizeof(fdt32_t);\n\t\t\tfor (i = 0; i < len; i += 2) {\n\t\t\t\tif (fdt32_to_cpu(val[i + 1]) == IRQ_M_EXT)\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn false;\n}\n\nint fdt_parse_imsic_node(void *fdt, int nodeoff, struct imsic_data *imsic)\n{\n\tconst fdt32_t *val;\n\tstruct imsic_regs *regs;\n\tuint64_t reg_addr, reg_size;\n\tint i, rc, len, nr_parent_irqs;\n\n\tif (nodeoff < 0 || !imsic || !fdt)\n\t\treturn SBI_ENODEV;\n\n\timsic->targets_mmode = false;\n\tval = fdt_getprop(fdt, nodeoff, \"interrupts-extended\", &len);\n\tif (val && len > sizeof(fdt32_t)) {\n\t\tlen = len / sizeof(fdt32_t);\n\t\tnr_parent_irqs = len / 2;\n\t\tfor (i = 0; i < len; i += 2) {\n\t\t\tif (fdt32_to_cpu(val[i + 1]) == IRQ_M_EXT) {\n\t\t\t\timsic->targets_mmode = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else\n\t\treturn SBI_EINVAL;\n\n\tval = fdt_getprop(fdt, nodeoff, \"riscv,guest-index-bits\", &len);\n\tif (val && len > 0)\n\t\timsic->guest_index_bits = fdt32_to_cpu(*val);\n\telse\n\t\timsic->guest_index_bits = 0;\n\n\tval = fdt_getprop(fdt, nodeoff, \"riscv,hart-index-bits\", &len);\n\tif (val && len > 0) {\n\t\timsic->hart_index_bits = fdt32_to_cpu(*val);\n\t} else {\n\t\timsic->hart_index_bits = sbi_fls(nr_parent_irqs);\n\t\tif ((1UL << imsic->hart_index_bits) < nr_parent_irqs)\n\t\t\timsic->hart_index_bits++;\n\t}\n\n\tval = fdt_getprop(fdt, nodeoff, \"riscv,group-index-bits\", &len);\n\tif (val && len > 0)\n\t\timsic->group_index_bits = fdt32_to_cpu(*val);\n\telse\n\t\timsic->group_index_bits = 0;\n\n\tval = fdt_getprop(fdt, nodeoff, \"riscv,group-index-shift\", &len);\n\tif (val && len > 0)\n\t\timsic->group_index_shift = fdt32_to_cpu(*val);\n\telse\n\t\timsic->group_index_shift = 2 * IMSIC_MMIO_PAGE_SHIFT;\n\n\tval = fdt_getprop(fdt, nodeoff, \"riscv,num-ids\", &len);\n\tif (val && len > 0)\n\t\timsic->num_ids = fdt32_to_cpu(*val);\n\telse\n\t\treturn SBI_EINVAL;\n\n\tfor (i = 0; i < IMSIC_MAX_REGS; i++) {\n\t\tregs = &imsic->regs[i];\n\t\tregs->addr = 0;\n\t\tregs->size = 0;\n\t}\n\n\tfor (i = 0; i < (IMSIC_MAX_REGS - 1); i++) {\n\t\tregs = &imsic->regs[i];\n\n\t\trc = fdt_get_node_addr_size(fdt, nodeoff, i,\n\t\t\t\t\t    &reg_addr, &reg_size);\n\t\tif (rc < 0 || !reg_addr || !reg_size)\n\t\t\tbreak;\n\t\tregs->addr = reg_addr;\n\t\tregs->size = reg_size;\n\t};\n\tif (!imsic->regs[0].size)\n\t\treturn SBI_EINVAL;\n\n\treturn 0;\n}\n\nint fdt_parse_plic_node(void *fdt, int nodeoffset, struct plic_data *plic)\n{\n\tint len, rc;\n\tconst fdt32_t *val;\n\tuint64_t reg_addr, reg_size;\n\n\tif (nodeoffset < 0 || !plic || !fdt)\n\t\treturn SBI_ENODEV;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoffset, 0,\n\t\t\t\t    &reg_addr, &reg_size);\n\tif (rc < 0 || !reg_addr || !reg_size)\n\t\treturn SBI_ENODEV;\n\tplic->addr = reg_addr;\n\n\tval = fdt_getprop(fdt, nodeoffset, \"riscv,ndev\", &len);\n\tif (len > 0)\n\t\tplic->num_src = fdt32_to_cpu(*val);\n\n\treturn 0;\n}\n\nint fdt_parse_plic(void *fdt, struct plic_data *plic, const char *compat)\n{\n\tint nodeoffset;\n\n\tif (!compat || !plic || !fdt)\n\t\treturn SBI_ENODEV;\n\n\tnodeoffset = fdt_node_offset_by_compatible(fdt, -1, compat);\n\tif (nodeoffset < 0)\n\t\treturn nodeoffset;\n\n\treturn fdt_parse_plic_node(fdt, nodeoffset, plic);\n}\n\nint fdt_parse_aclint_node(void *fdt, int nodeoffset, bool for_timer,\n\t\t\t  unsigned long *out_addr1, unsigned long *out_size1,\n\t\t\t  unsigned long *out_addr2, unsigned long *out_size2,\n\t\t\t  u32 *out_first_hartid, u32 *out_hart_count)\n{\n\tconst fdt32_t *val;\n\tuint64_t reg_addr, reg_size;\n\tint i, rc, count, cpu_offset, cpu_intc_offset;\n\tu32 phandle, hwirq, hartid, first_hartid, last_hartid, hart_count;\n\tu32 match_hwirq = (for_timer) ? IRQ_M_TIMER : IRQ_M_SOFT;\n\n\tif (nodeoffset < 0 || !fdt ||\n\t    !out_addr1 || !out_size1 ||\n\t    !out_first_hartid || !out_hart_count)\n\t\treturn SBI_EINVAL;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoffset, 0,\n\t\t\t\t    &reg_addr, &reg_size);\n\tif (rc < 0 || !reg_size)\n\t\treturn SBI_ENODEV;\n\t*out_addr1 = reg_addr;\n\t*out_size1 = reg_size;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoffset, 1,\n\t\t\t\t    &reg_addr, &reg_size);\n\tif (rc < 0 || !reg_size)\n\t\treg_addr = reg_size = 0;\n\tif (out_addr2)\n\t\t*out_addr2 = reg_addr;\n\tif (out_size2)\n\t\t*out_size2 = reg_size;\n\n\t*out_first_hartid = 0;\n\t*out_hart_count = 0;\n\n\tval = fdt_getprop(fdt, nodeoffset, \"interrupts-extended\", &count);\n\tif (!val || count < sizeof(fdt32_t))\n\t\treturn 0;\n\tcount = count / sizeof(fdt32_t);\n\n\tfirst_hartid = -1U;\n\thart_count = last_hartid = 0;\n\tfor (i = 0; i < (count / 2); i++) {\n\t\tphandle = fdt32_to_cpu(val[2 * i]);\n\t\thwirq = fdt32_to_cpu(val[(2 * i) + 1]);\n\n\t\tcpu_intc_offset = fdt_node_offset_by_phandle(fdt, phandle);\n\t\tif (cpu_intc_offset < 0)\n\t\t\tcontinue;\n\n\t\tcpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);\n\t\tif (cpu_offset < 0)\n\t\t\tcontinue;\n\n\t\trc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);\n\t\tif (rc)\n\t\t\tcontinue;\n\n\t\tif (SBI_HARTMASK_MAX_BITS <= hartid)\n\t\t\tcontinue;\n\n\t\tif (match_hwirq == hwirq) {\n\t\t\tif (hartid < first_hartid)\n\t\t\t\tfirst_hartid = hartid;\n\t\t\tif (hartid > last_hartid)\n\t\t\t\tlast_hartid = hartid;\n\t\t\thart_count++;\n\t\t}\n\t}\n\n\tif ((last_hartid >= first_hartid) && first_hartid != -1U) {\n\t\t*out_first_hartid = first_hartid;\n\t\tcount = last_hartid - first_hartid + 1;\n\t\t*out_hart_count = (hart_count < count) ? hart_count : count;\n\t}\n\n\treturn 0;\n}\n\nint fdt_parse_plmt_node(void *fdt, int nodeoffset, unsigned long *plmt_base,\n\t\t\t  unsigned long *plmt_size, u32 *hart_count)\n{\n\tconst fdt32_t *val;\n\tint rc, i, count;\n\tuint64_t reg_addr, reg_size;\n\tu32 phandle, hwirq, hartid, hcount;\n\n\tif (nodeoffset < 0 || !fdt || !plmt_base ||\n\t    !hart_count || !plmt_size)\n\t\treturn SBI_EINVAL;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoffset, 0,\n\t\t\t\t    &reg_addr, &reg_size);\n\tif (rc < 0)\n\t\treturn SBI_ENODEV;\n\t*plmt_base = reg_addr;\n\t*plmt_size = reg_size;\n\n\tval = fdt_getprop(fdt, nodeoffset, \"interrupts-extended\", &count);\n\tif (!val || count < sizeof(fdt32_t))\n\t\treturn 0;\n\tcount = count / sizeof(fdt32_t);\n\n\thcount = 0;\n\tfor (i = 0; i < (count / 2); i++) {\n\t\tint cpu_offset, cpu_intc_offset;\n\n\t\tphandle = fdt32_to_cpu(val[2 * i]);\n\t\thwirq = fdt32_to_cpu(val[2 * i + 1]);\n\n\t\tcpu_intc_offset = fdt_node_offset_by_phandle(fdt, phandle);\n\t\tif (cpu_intc_offset < 0)\n\t\t\tcontinue;\n\n\t\tcpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);\n\t\tif (cpu_offset < 0)\n\t\t\tcontinue;\n\n\t\trc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);\n\n\t\tif (rc)\n\t\t\tcontinue;\n\n\t\tif (SBI_HARTMASK_MAX_BITS <= hartid)\n\t\t\tcontinue;\n\n\t\tif (hwirq == IRQ_M_TIMER)\n\t\t\thcount++;\n\t}\n\n\t*hart_count = hcount;\n\n\treturn 0;\n}\n\nint fdt_parse_plicsw_node(void *fdt, int nodeoffset, unsigned long *plicsw_base,\n\t\t\t  unsigned long *size, u32 *hart_count)\n{\n\tconst fdt32_t *val;\n\tint rc, i, count;\n\tuint64_t reg_addr, reg_size;\n\tu32 phandle, hwirq, hartid, hcount;\n\n\tif (nodeoffset < 0 || !fdt || !plicsw_base ||\n\t    !hart_count || !size)\n\t\treturn SBI_EINVAL;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoffset, 0,\n\t\t\t\t    &reg_addr, &reg_size);\n\tif (rc < 0)\n\t\treturn SBI_ENODEV;\n\t*plicsw_base = reg_addr;\n\t*size = reg_size;\n\n\tval = fdt_getprop(fdt, nodeoffset, \"interrupts-extended\", &count);\n\tif (!val || count < sizeof(fdt32_t))\n\t\treturn 0;\n\tcount = count / sizeof(fdt32_t);\n\n\thcount = 0;\n\tfor (i = 0; i < (count / 2); i++) {\n\t\tint cpu_offset, cpu_intc_offset;\n\n\t\tphandle = fdt32_to_cpu(val[2 * i]);\n\t\thwirq = fdt32_to_cpu(val[2 * i + 1]);\n\n\t\tcpu_intc_offset = fdt_node_offset_by_phandle(fdt, phandle);\n\t\tif (cpu_intc_offset < 0)\n\t\t\tcontinue;\n\n\t\tcpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);\n\t\tif (cpu_offset < 0)\n\t\t\tcontinue;\n\n\t\trc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);\n\n\t\tif (rc)\n\t\t\tcontinue;\n\n\t\tif (SBI_HARTMASK_MAX_BITS <= hartid)\n\t\t\tcontinue;\n\n\t\tif (hwirq == IRQ_M_SOFT)\n\t\t\thcount++;\n\t}\n\n\t*hart_count = hcount;\n\n\treturn 0;\n}\n\nint fdt_parse_compat_addr(void *fdt, uint64_t *addr,\n\t\t\t  const char *compatible)\n{\n\tint nodeoffset, rc;\n\n\tnodeoffset = fdt_node_offset_by_compatible(fdt, -1, compatible);\n\tif (nodeoffset < 0)\n\t\treturn nodeoffset;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoffset, 0, addr, NULL);\n\tif (rc < 0 || !addr)\n\t\treturn SBI_ENODEV;\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/fdt/fdt_pmu.c",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * fdt_pmu.c - Flat Device Tree PMU helper routines\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *\tAtish Patra <atish.patra@wdc.com>\n */\n\n#include <libfdt.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n\n#define FDT_PMU_HW_EVENT_MAX (SBI_PMU_HW_EVENT_MAX * 2)\n\nstruct fdt_pmu_hw_event_select {\n\tuint32_t eidx;\n\tuint64_t select;\n};\n\nstatic struct fdt_pmu_hw_event_select fdt_pmu_evt_select[FDT_PMU_HW_EVENT_MAX] = {0};\nstatic uint32_t hw_event_count;\n\nuint64_t fdt_pmu_get_select_value(uint32_t event_idx)\n{\n\tint i;\n\tstruct fdt_pmu_hw_event_select *event;\n\n\tfor (i = 0; i < SBI_PMU_HW_EVENT_MAX; i++) {\n\t\tevent = &fdt_pmu_evt_select[i];\n\t\tif (event->eidx == event_idx)\n\t\t\treturn event->select;\n\t}\n\n\treturn 0;\n}\n\nint fdt_pmu_fixup(void *fdt)\n{\n\tint pmu_offset;\n\tstruct sbi_scratch *scratch = sbi_scratch_thishart_ptr();\n\n\tif (!fdt)\n\t\treturn SBI_EINVAL;\n\n\tpmu_offset = fdt_node_offset_by_compatible(fdt, -1, \"riscv,pmu\");\n\tif (pmu_offset < 0)\n\t\treturn SBI_EFAIL;\n\n\tfdt_delprop(fdt, pmu_offset, \"riscv,event-to-mhpmcounters\");\n\tfdt_delprop(fdt, pmu_offset, \"riscv,event-to-mhpmevent\");\n\tfdt_delprop(fdt, pmu_offset, \"riscv,raw-event-to-mhpmcounters\");\n\tif (!sbi_hart_has_extension(scratch, SBI_HART_EXT_SSCOFPMF))\n\t\tfdt_delprop(fdt, pmu_offset, \"interrupts-extended\");\n\n\treturn 0;\n}\n\nint fdt_pmu_setup(void *fdt)\n{\n\tint i, pmu_offset, len, result;\n\tconst u32 *event_val;\n\tconst u32 *event_ctr_map;\n\tstruct fdt_pmu_hw_event_select *event;\n\tuint64_t raw_selector, select_mask;\n\tu32 event_idx_start, event_idx_end, ctr_map;\n\n\tif (!fdt)\n\t\treturn SBI_EINVAL;\n\n\tpmu_offset = fdt_node_offset_by_compatible(fdt, -1, \"riscv,pmu\");\n\tif (pmu_offset < 0)\n\t\treturn SBI_EFAIL;\n\n\tevent_ctr_map = fdt_getprop(fdt, pmu_offset,\n\t\t\t\t    \"riscv,event-to-mhpmcounters\", &len);\n\tif (event_ctr_map && len >= 8) {\n\t\tlen = len / (sizeof(u32) * 3);\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tevent_idx_start = fdt32_to_cpu(event_ctr_map[3 * i]);\n\t\t\tevent_idx_end = fdt32_to_cpu(event_ctr_map[3 * i + 1]);\n\t\t\tctr_map = fdt32_to_cpu(event_ctr_map[3 * i + 2]);\n\t\t\tresult = sbi_pmu_add_hw_event_counter_map(\n\t\t\t\tevent_idx_start, event_idx_end, ctr_map);\n\t\t\tif (result)\n\t\t\t\treturn result;\n\t\t}\n\t}\n\n\tevent_val = fdt_getprop(fdt, pmu_offset,\n\t\t\t\t\"riscv,event-to-mhpmevent\", &len);\n\tif (event_val && len >= 8) {\n\t\tlen = len / (sizeof(u32) * 3);\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tevent = &fdt_pmu_evt_select[hw_event_count];\n\t\t\tevent->eidx = fdt32_to_cpu(event_val[3 * i]);\n\t\t\tevent->select = fdt32_to_cpu(event_val[3 * i + 1]);\n\t\t\tevent->select = (event->select << 32) |\n\t\t\t\t\tfdt32_to_cpu(event_val[3 * i + 2]);\n\t\t\thw_event_count++;\n\t\t}\n\t}\n\n\tevent_val = fdt_getprop(fdt, pmu_offset,\n\t\t\t\t\"riscv,raw-event-to-mhpmcounters\", &len);\n\tif (event_val && len >= 20) {\n\t\tlen = len / (sizeof(u32) * 5);\n\t\tfor (i = 0; i < len; i++) {\n\t\t\traw_selector = fdt32_to_cpu(event_val[5 * i]);\n\t\t\traw_selector = (raw_selector << 32) |\n\t\t\t\t\tfdt32_to_cpu(event_val[5 * i + 1]);\n\t\t\tselect_mask = fdt32_to_cpu(event_val[5 * i + 2]);\n\t\t\tselect_mask = (select_mask  << 32) |\n\t\t\t\t\tfdt32_to_cpu(event_val[5 * i + 3]);\n\t\t\tctr_map = fdt32_to_cpu(event_val[5 * i + 4]);\n\t\t\tresult = sbi_pmu_add_raw_event_counter_map(\n\t\t\t\t\traw_selector, select_mask, ctr_map);\n\t\t\tif (result)\n\t\t\t\treturn result;\n\t\t}\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/fdt/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (C) 2020 Bin Meng <bmeng.cn@gmail.com>\n#\n\nlibsbiutils-objs-$(CONFIG_FDT_DOMAIN) += fdt/fdt_domain.o\nlibsbiutils-objs-$(CONFIG_FDT_PMU) += fdt/fdt_pmu.o\nlibsbiutils-objs-$(CONFIG_FDT) += fdt/fdt_helper.o\nlibsbiutils-objs-$(CONFIG_FDT) += fdt/fdt_fixup.o\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/gpio/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"GPIO Support\"\n\nconfig FDT_GPIO\n\tbool \"FDT based GPIO drivers\"\n\tdepends on FDT\n\tselect GPIO\n\tdefault n\n\nif FDT_GPIO\n\nconfig FDT_GPIO_SIFIVE\n\tbool \"SiFive GPIO FDT driver\"\n\tdefault n\n\nendif\n\nconfig GPIO\n\tbool \"GPIO support\"\n\tdefault n\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/gpio/fdt_gpio.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <sbi/sbi_error.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/gpio/fdt_gpio.h>\n\n/* List of FDT gpio drivers generated at compile time */\nextern struct fdt_gpio *fdt_gpio_drivers[];\nextern unsigned long fdt_gpio_drivers_size;\n\nstatic struct fdt_gpio *fdt_gpio_driver(struct gpio_chip *chip)\n{\n\tint pos;\n\n\tif (!chip)\n\t\treturn NULL;\n\n\tfor (pos = 0; pos < fdt_gpio_drivers_size; pos++) {\n\t\tif (chip->driver == fdt_gpio_drivers[pos])\n\t\t\treturn fdt_gpio_drivers[pos];\n\t}\n\n\treturn NULL;\n}\n\nstatic int fdt_gpio_init(void *fdt, u32 phandle)\n{\n\tint pos, nodeoff, rc;\n\tstruct fdt_gpio *drv;\n\tconst struct fdt_match *match;\n\n\t/* Find node offset */\n\tnodeoff = fdt_node_offset_by_phandle(fdt, phandle);\n\tif (nodeoff < 0)\n\t\treturn nodeoff;\n\n\t/* Check \"gpio-controller\" property */\n\tif (!fdt_getprop(fdt, nodeoff, \"gpio-controller\", &rc))\n\t\treturn SBI_EINVAL;\n\n\t/* Try all GPIO drivers one-by-one */\n\tfor (pos = 0; pos < fdt_gpio_drivers_size; pos++) {\n\t\tdrv = fdt_gpio_drivers[pos];\n\n\t\tmatch = fdt_match_node(fdt, nodeoff, drv->match_table);\n\t\tif (match && drv->init) {\n\t\t\trc = drv->init(fdt, nodeoff, phandle, match);\n\t\t\tif (rc == SBI_ENODEV)\n\t\t\t\tcontinue;\n\t\t\tif (rc)\n\t\t\t\treturn rc;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn SBI_ENOSYS;\n}\n\nstatic int fdt_gpio_chip_find(void *fdt, u32 phandle,\n\t\t\t      struct gpio_chip **out_chip)\n{\n\tint rc;\n\tstruct gpio_chip *chip = gpio_chip_find(phandle);\n\n\tif (!chip) {\n\t\t/* GPIO chip not found so initialize matching driver */\n\t\trc = fdt_gpio_init(fdt, phandle);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\t/* Try to find GPIO chip again */\n\t\tchip = gpio_chip_find(phandle);\n\t\tif (!chip)\n\t\t\treturn SBI_ENOSYS;\n\t}\n\n\tif (out_chip)\n\t\t*out_chip = chip;\n\n\treturn 0;\n}\n\nint fdt_gpio_pin_get(void *fdt, int nodeoff, int index,\n\t\t     struct gpio_pin *out_pin)\n{\n\tint rc;\n\tu32 phandle;\n\tstruct fdt_gpio *drv;\n\tstruct gpio_chip *chip = NULL;\n\tstruct fdt_phandle_args pargs;\n\n\tif (!fdt || (nodeoff < 0) || (index < 0) || !out_pin)\n\t\treturn SBI_EINVAL;\n\n\tpargs.node_offset = pargs.args_count = 0;\n\trc = fdt_parse_phandle_with_args(fdt, nodeoff,\n\t\t\t\t\t \"gpios\", \"#gpio-cells\",\n\t\t\t\t\t index, &pargs);\n\tif (rc)\n\t\treturn rc;\n\n\tphandle = fdt_get_phandle(fdt, pargs.node_offset);\n\trc = fdt_gpio_chip_find(fdt, phandle, &chip);\n\tif (rc)\n\t\treturn rc;\n\n\tdrv = fdt_gpio_driver(chip);\n\tif (!drv || !drv->xlate)\n\t\treturn SBI_ENOSYS;\n\n\treturn drv->xlate(chip, &pargs, out_pin);\n}\n\nint fdt_gpio_simple_xlate(struct gpio_chip *chip,\n\t\t\t  const struct fdt_phandle_args *pargs,\n\t\t\t  struct gpio_pin *out_pin)\n{\n\tif ((pargs->args_count < 2) || (chip->ngpio <= pargs->args[0]))\n\t\treturn SBI_EINVAL;\n\n\tout_pin->chip = chip;\n\tout_pin->offset = pargs->args[0];\n\tout_pin->flags = pargs->args[1];\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/gpio/fdt_gpio_drivers.carray",
    "content": "HEADER: sbi_utils/gpio/fdt_gpio.h\nTYPE: struct fdt_gpio\nNAME: fdt_gpio_drivers\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/gpio/fdt_gpio_sifive.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 SiFive\n *\n * Authors:\n *   Green Wan <green.wan@sifive.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_error.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/gpio/fdt_gpio.h>\n\n#define SIFIVE_GPIO_CHIP_MAX\t2\n\n#define SIFIVE_GPIO_PINS_MIN\t1\n#define SIFIVE_GPIO_PINS_MAX\t32\n#define SIFIVE_GPIO_PINS_DEF\t16\n\n#define SIFIVE_GPIO_OUTEN\t0x8\n#define SIFIVE_GPIO_OUTVAL\t0xc\n#define SIFIVE_GPIO_BIT(b)\t(1U << (b))\n\nstruct sifive_gpio_chip {\n\tunsigned long addr;\n\tstruct gpio_chip chip;\n};\n\nstatic unsigned int sifive_gpio_chip_count;\nstatic struct sifive_gpio_chip sifive_gpio_chip_array[SIFIVE_GPIO_CHIP_MAX];\n\nstatic int sifive_gpio_direction_output(struct gpio_pin *gp, int value)\n{\n\tunsigned int v;\n\tstruct sifive_gpio_chip *chip =\n\t\tcontainer_of(gp->chip, struct sifive_gpio_chip, chip);\n\n\tv = readl((volatile void *)(chip->addr + SIFIVE_GPIO_OUTEN));\n\tv |= SIFIVE_GPIO_BIT(gp->offset);\n\twritel(v, (volatile void *)(chip->addr + SIFIVE_GPIO_OUTEN));\n\n\tv = readl((volatile void *)(chip->addr + SIFIVE_GPIO_OUTVAL));\n\tif (!value)\n\t\tv &= ~SIFIVE_GPIO_BIT(gp->offset);\n\telse\n\t\tv |= SIFIVE_GPIO_BIT(gp->offset);\n\twritel(v, (volatile void *)(chip->addr + SIFIVE_GPIO_OUTVAL));\n\n\treturn 0;\n}\n\nstatic void sifive_gpio_set(struct gpio_pin *gp, int value)\n{\n\tunsigned int v;\n\tstruct sifive_gpio_chip *chip =\n\t\tcontainer_of(gp->chip, struct sifive_gpio_chip, chip);\n\n\tv = readl((volatile void *)(chip->addr + SIFIVE_GPIO_OUTVAL));\n\tif (!value)\n\t\tv &= ~SIFIVE_GPIO_BIT(gp->offset);\n\telse\n\t\tv |= SIFIVE_GPIO_BIT(gp->offset);\n\twritel(v, (volatile void *)(chip->addr + SIFIVE_GPIO_OUTVAL));\n}\n\nextern struct fdt_gpio fdt_gpio_sifive;\n\nstatic int sifive_gpio_init(void *fdt, int nodeoff, u32 phandle,\n\t\t\t    const struct fdt_match *match)\n{\n\tint rc;\n\tstruct sifive_gpio_chip *chip;\n\tuint64_t addr;\n\n\tif (SIFIVE_GPIO_CHIP_MAX <= sifive_gpio_chip_count)\n\t\treturn SBI_ENOSPC;\n\tchip = &sifive_gpio_chip_array[sifive_gpio_chip_count];\n\n\trc = fdt_get_node_addr_size(fdt, nodeoff, 0, &addr, NULL);\n\tif (rc)\n\t\treturn rc;\n\n\tchip->addr = addr;\n\tchip->chip.driver = &fdt_gpio_sifive;\n\tchip->chip.id = phandle;\n\tchip->chip.ngpio = SIFIVE_GPIO_PINS_DEF;\n\tchip->chip.direction_output = sifive_gpio_direction_output;\n\tchip->chip.set = sifive_gpio_set;\n\trc = gpio_chip_add(&chip->chip);\n\tif (rc)\n\t\treturn rc;\n\n\tsifive_gpio_chip_count++;\n\treturn 0;\n}\n\nstatic const struct fdt_match sifive_gpio_match[] = {\n\t{ .compatible = \"sifive,gpio0\" },\n\t{ },\n};\n\nstruct fdt_gpio fdt_gpio_sifive = {\n\t.match_table = sifive_gpio_match,\n\t.xlate = fdt_gpio_simple_xlate,\n\t.init = sifive_gpio_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/gpio/gpio.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi_utils/gpio/gpio.h>\n\nstatic SBI_LIST_HEAD(gpio_chip_list);\n\nstruct gpio_chip *gpio_chip_find(unsigned int id)\n{\n\tstruct sbi_dlist *pos;\n\n\tsbi_list_for_each(pos, &(gpio_chip_list)) {\n\t\tstruct gpio_chip *chip = to_gpio_chip(pos);\n\n\t\tif (chip->id == id)\n\t\t\treturn chip;\n\t}\n\n\treturn NULL;\n}\n\nint gpio_chip_add(struct gpio_chip *gc)\n{\n\tif (!gc)\n\t\treturn SBI_EINVAL;\n\tif (gpio_chip_find(gc->id))\n\t\treturn SBI_EALREADY;\n\n\tsbi_list_add(&(gc->node), &(gpio_chip_list));\n\n\treturn 0;\n}\n\nvoid gpio_chip_remove(struct gpio_chip *gc)\n{\n\tif (!gc)\n\t\treturn;\n\n\tsbi_list_del(&(gc->node));\n}\n\nint gpio_get_direction(struct gpio_pin *gp)\n{\n\tif (!gp || !gp->chip || (gp->chip->ngpio <= gp->offset))\n\t\treturn SBI_EINVAL;\n\tif (!gp->chip->get_direction)\n\t\treturn SBI_ENOSYS;\n\n\treturn gp->chip->get_direction(gp);\n}\n\nint gpio_direction_input(struct gpio_pin *gp)\n{\n\tif (!gp || !gp->chip || (gp->chip->ngpio <= gp->offset))\n\t\treturn SBI_EINVAL;\n\tif (!gp->chip->direction_input)\n\t\treturn SBI_ENOSYS;\n\n\treturn gp->chip->direction_input(gp);\n}\n\nint gpio_direction_output(struct gpio_pin *gp, int value)\n{\n\tif (!gp || !gp->chip || (gp->chip->ngpio <= gp->offset))\n\t\treturn SBI_EINVAL;\n\tif (!gp->chip->direction_output)\n\t\treturn SBI_ENOSYS;\n\n\treturn gp->chip->direction_output(gp, value);\n}\n\nint gpio_get(struct gpio_pin *gp)\n{\n\tif (!gp || !gp->chip || (gp->chip->ngpio <= gp->offset))\n\t\treturn SBI_EINVAL;\n\tif (!gp->chip->get)\n\t\treturn SBI_ENOSYS;\n\n\treturn gp->chip->get(gp);\n}\n\nint gpio_set(struct gpio_pin *gp, int value)\n{\n\tif (!gp || !gp->chip || (gp->chip->ngpio <= gp->offset))\n\t\treturn SBI_EINVAL;\n\tif (!gp->chip->set)\n\t\treturn SBI_ENOSYS;\n\n\tgp->chip->set(gp, value);\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/gpio/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2021 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nlibsbiutils-objs-$(CONFIG_FDT_GPIO) += gpio/fdt_gpio.o\nlibsbiutils-objs-$(CONFIG_FDT_GPIO) += gpio/fdt_gpio_drivers.o\n\ncarray-fdt_gpio_drivers-$(CONFIG_FDT_GPIO_SIFIVE) += fdt_gpio_sifive\nlibsbiutils-objs-$(CONFIG_FDT_GPIO_SIFIVE) += gpio/fdt_gpio_sifive.o\n\nlibsbiutils-objs-$(CONFIG_GPIO) += gpio/gpio.o\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/i2c/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"I2C Support\"\n\nconfig FDT_I2C\n\tbool \"FDT based I2C drivers\"\n\tdepends on FDT\n\tselect I2C\n\tdefault n\n\nif FDT_I2C\n\nconfig FDT_I2C_SIFIVE\n\tbool \"SiFive I2C FDT driver\"\n\tdefault n\n\nendif\n\nconfig I2C\n\tbool \"I2C support\"\n\tdefault n\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/i2c/fdt_i2c.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 YADRO\n *\n * Authors:\n *   Nikita Shubin <n.shubin@yadro.com>\n *\n * derivate: lib/utils/gpio/fdt_gpio.c\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <sbi/sbi_error.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/i2c/fdt_i2c.h>\n\n/* List of FDT i2c adapter drivers generated at compile time */\nextern struct fdt_i2c_adapter *fdt_i2c_adapter_drivers[];\nextern unsigned long fdt_i2c_adapter_drivers_size;\n\nstatic int fdt_i2c_adapter_init(void *fdt, int nodeoff)\n{\n\tint pos, rc;\n\tstruct fdt_i2c_adapter *drv;\n\tconst struct fdt_match *match;\n\n\t/* Try all I2C drivers one-by-one */\n\tfor (pos = 0; pos < fdt_i2c_adapter_drivers_size; pos++) {\n\t\tdrv = fdt_i2c_adapter_drivers[pos];\n\t\tmatch = fdt_match_node(fdt, nodeoff, drv->match_table);\n\t\tif (match && drv->init) {\n\t\t\trc = drv->init(fdt, nodeoff, match);\n\t\t\tif (rc == SBI_ENODEV)\n\t\t\t\tcontinue;\n\t\t\tif (rc)\n\t\t\t\treturn rc;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn SBI_ENOSYS;\n}\n\nstatic int fdt_i2c_adapter_find(void *fdt, int nodeoff,\n\t\t\t\tstruct i2c_adapter **out_adapter)\n{\n\tint rc;\n\tstruct i2c_adapter *adapter = i2c_adapter_find(nodeoff);\n\n\tif (!adapter) {\n\t\t/* I2C adapter not found so initialize matching driver */\n\t\trc = fdt_i2c_adapter_init(fdt, nodeoff);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\t/* Try to find I2C adapter again */\n\t\tadapter = i2c_adapter_find(nodeoff);\n\t\tif (!adapter)\n\t\t\treturn SBI_ENOSYS;\n\t}\n\n\tif (out_adapter)\n\t\t*out_adapter = adapter;\n\n\treturn 0;\n}\n\nint fdt_i2c_adapter_get(void *fdt, int nodeoff,\n\t\t\tstruct i2c_adapter **out_adapter)\n{\n\tint rc;\n\tstruct i2c_adapter *adapter;\n\n\tif (!fdt || (nodeoff < 0) || !out_adapter)\n\t\treturn SBI_EINVAL;\n\n\trc = fdt_i2c_adapter_find(fdt, nodeoff, &adapter);\n\tif (rc)\n\t\treturn rc;\n\n\t*out_adapter = adapter;\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/i2c/fdt_i2c_adapter_drivers.carray",
    "content": "HEADER: sbi_utils/i2c/fdt_i2c.h\nTYPE: struct fdt_i2c_adapter\nNAME: fdt_i2c_adapter_drivers\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/i2c/fdt_i2c_sifive.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 YADRO\n *\n * Authors:\n *   Nikita Shubin <n.shubin@yadro.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_timer.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/i2c/fdt_i2c.h>\n\n#define SIFIVE_I2C_ADAPTER_MAX\t2\n\n#define SIFIVE_I2C_PRELO\t0x00\n#define SIFIVE_I2C_PREHI\t0x04\n#define SIFIVE_I2C_CTR\t\t0x08\n#define SIFIVE_I2C_TXR\t\t0x00c\n#define SIFIVE_I2C_RXR\t\tSIFIVE_I2C_TXR\n#define SIFIVE_I2C_CR\t\t0x010\n#define SIFIVE_I2C_SR\t\tSIFIVE_I2C_CR\n\n#define SIFIVE_I2C_CTR_IEN\t(1 << 6)\n#define SIFIVE_I2C_CTR_EN\t(1 << 7)\n\n#define SIFIVE_I2C_CMD_IACK\t(1 << 0)\n#define SIFIVE_I2C_CMD_ACK\t(1 << 3)\n#define SIFIVE_I2C_CMD_WR\t(1 << 4)\n#define SIFIVE_I2C_CMD_RD\t(1 << 5)\n#define SIFIVE_I2C_CMD_STO\t(1 << 6)\n#define SIFIVE_I2C_CMD_STA\t(1 << 7)\n\n#define SIFIVE_I2C_STATUS_IF\t(1 << 0)\n#define SIFIVE_I2C_STATUS_TIP\t(1 << 1)\n#define SIFIVE_I2C_STATUS_AL\t(1 << 5)\n#define SIFIVE_I2C_STATUS_BUSY\t(1 << 6)\n#define SIFIVE_I2C_STATUS_RXACK\t(1 << 7)\n\n#define SIFIVE_I2C_WRITE_BIT\t(0 << 0)\n#define SIFIVE_I2C_READ_BIT\t(1 << 0)\n\nstruct sifive_i2c_adapter {\n\tunsigned long addr;\n\tstruct i2c_adapter adapter;\n};\n\nstatic unsigned int sifive_i2c_adapter_count;\nstatic struct sifive_i2c_adapter\n\tsifive_i2c_adapter_array[SIFIVE_I2C_ADAPTER_MAX];\n\nextern struct fdt_i2c_adapter fdt_i2c_adapter_sifive;\n\nstatic inline void sifive_i2c_setreg(struct sifive_i2c_adapter *adap,\n\t\t\t\t     uint8_t reg, uint8_t value)\n{\n\twritel(value, (volatile char *)adap->addr + reg);\n}\n\nstatic inline uint8_t sifive_i2c_getreg(struct sifive_i2c_adapter *adap,\n\t\t\t\t\tuint8_t reg)\n{\n\treturn readl((volatile char *)adap->addr + reg);\n}\n\nstatic int sifive_i2c_adapter_rxack(struct sifive_i2c_adapter *adap)\n{\n\tuint8_t val = sifive_i2c_getreg(adap, SIFIVE_I2C_SR);\n\n\tif (val & SIFIVE_I2C_STATUS_RXACK)\n\t\treturn SBI_EIO;\n\n\treturn 0;\n}\n\nstatic int sifive_i2c_adapter_poll(struct sifive_i2c_adapter *adap,\n\t\t\t\t   uint32_t mask)\n{\n\tunsigned int timeout = 1; // [msec]\n\tint count = 0;\n\tuint8_t val;\n\n\tsbi_timer_udelay(80); // worst case if bus speed is 100 kHz\n\n\tdo {\n\t\tval = sifive_i2c_getreg(adap, SIFIVE_I2C_SR);\n\t\tif (!(val & mask))\n\t\t\treturn 0;\n\n\t\tsbi_timer_udelay(1);\n\t\tcount += 1;\n\t\tif (count == (timeout * 1000))\n\t\t\treturn SBI_ETIMEDOUT;\n\t} while (1);\n}\n\n#define sifive_i2c_adapter_poll_tip(adap)\t\\\n\tsifive_i2c_adapter_poll(adap, SIFIVE_I2C_STATUS_TIP)\n#define sifive_i2c_adapter_poll_busy(adap)\t\\\nsifive_i2c_adapter_poll(adap, SIFIVE_I2C_STATUS_BUSY)\n\nstatic int sifive_i2c_adapter_start(struct sifive_i2c_adapter *adap,\n\t\t\t\t    uint8_t addr, uint8_t bit)\n{\n\tuint8_t val = (addr << 1) | bit;\n\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_TXR, val);\n\tval = SIFIVE_I2C_CMD_STA | SIFIVE_I2C_CMD_WR | SIFIVE_I2C_CMD_IACK;\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR, val);\n\n\treturn sifive_i2c_adapter_poll_tip(adap);\n}\n\nstatic int sifive_i2c_adapter_write(struct i2c_adapter *ia, uint8_t addr,\n\t\t\t\t    uint8_t reg, uint8_t *buffer, int len)\n{\n\tstruct sifive_i2c_adapter *adap =\n\t\tcontainer_of(ia, struct sifive_i2c_adapter, adapter);\n\tint rc = sifive_i2c_adapter_start(adap, addr, SIFIVE_I2C_WRITE_BIT);\n\n\tif (rc)\n\t\treturn rc;\n\n\trc = sifive_i2c_adapter_rxack(adap);\n\tif (rc)\n\t\treturn rc;\n\n\t/* set register address */\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_TXR, reg);\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR, SIFIVE_I2C_CMD_WR |\n\t\t\t\tSIFIVE_I2C_CMD_IACK);\n\trc = sifive_i2c_adapter_poll_tip(adap);\n\tif (rc)\n\t\treturn rc;\n\n\trc = sifive_i2c_adapter_rxack(adap);\n\tif (rc)\n\t\treturn rc;\n\n\t/* set value */\n\twhile (len) {\n\t\tsifive_i2c_setreg(adap, SIFIVE_I2C_TXR, *buffer);\n\t\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR, SIFIVE_I2C_CMD_WR |\n\t\t\t\t\t\t       SIFIVE_I2C_CMD_IACK);\n\n\t\trc = sifive_i2c_adapter_poll_tip(adap);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\trc = sifive_i2c_adapter_rxack(adap);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\tbuffer++;\n\t\tlen--;\n\t}\n\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR, SIFIVE_I2C_CMD_STO |\n\t\t\t\t\t       SIFIVE_I2C_CMD_IACK);\n\n\t/* poll BUSY instead of ACK*/\n\trc = sifive_i2c_adapter_poll_busy(adap);\n\tif (rc)\n\t\treturn rc;\n\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR, SIFIVE_I2C_CMD_IACK);\n\n\treturn 0;\n}\n\nstatic int sifive_i2c_adapter_read(struct i2c_adapter *ia, uint8_t addr,\n\t\t\t\t   uint8_t reg, uint8_t *buffer, int len)\n{\n\tstruct sifive_i2c_adapter *adap =\n\t\tcontainer_of(ia, struct sifive_i2c_adapter, adapter);\n\tint rc;\n\n\trc = sifive_i2c_adapter_start(adap, addr, SIFIVE_I2C_WRITE_BIT);\n\tif (rc)\n\t\treturn rc;\n\n\trc = sifive_i2c_adapter_rxack(adap);\n\tif (rc)\n\t\treturn rc;\n\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_TXR, reg);\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR, SIFIVE_I2C_CMD_WR |\n\t\t\t\t\t       SIFIVE_I2C_CMD_IACK);\n\n\trc = sifive_i2c_adapter_poll_tip(adap);\n\tif (rc)\n\t\treturn rc;\n\n\trc = sifive_i2c_adapter_rxack(adap);\n\tif (rc)\n\t\treturn rc;\n\n\t/* setting addr with high 0 bit */\n\trc = sifive_i2c_adapter_start(adap, addr, SIFIVE_I2C_READ_BIT);\n\tif (rc)\n\t\treturn rc;\n\n\trc = sifive_i2c_adapter_rxack(adap);\n\tif (rc)\n\t\treturn rc;\n\n\twhile (len) {\n\t\tif (len == 1)\n\t\t\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR,\n\t\t\t\t\t  SIFIVE_I2C_CMD_ACK |\n\t\t\t\t\t  SIFIVE_I2C_CMD_RD |\n\t\t\t\t\t  SIFIVE_I2C_CMD_IACK);\n\t\telse\n\t\t\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR,\n\t\t\t\t\t  SIFIVE_I2C_CMD_RD |\n\t\t\t\t\t  SIFIVE_I2C_CMD_IACK);\n\n\t\trc = sifive_i2c_adapter_poll_tip(adap);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\t*buffer = sifive_i2c_getreg(adap, SIFIVE_I2C_RXR);\n\t\tbuffer++;\n\t\tlen--;\n\t}\n\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR, SIFIVE_I2C_CMD_STO |\n\t\t\t\t\t       SIFIVE_I2C_CMD_IACK);\n\trc = sifive_i2c_adapter_poll_busy(adap);\n\tif (rc)\n\t\treturn rc;\n\n\tsifive_i2c_setreg(adap, SIFIVE_I2C_CR, SIFIVE_I2C_CMD_IACK);\n\n\treturn 0;\n}\n\nstatic int sifive_i2c_init(void *fdt, int nodeoff,\n\t\t\t    const struct fdt_match *match)\n{\n\tint rc;\n\tstruct sifive_i2c_adapter *adapter;\n\tuint64_t addr;\n\n\tif (sifive_i2c_adapter_count >= SIFIVE_I2C_ADAPTER_MAX)\n\t\treturn SBI_ENOSPC;\n\n\tadapter = &sifive_i2c_adapter_array[sifive_i2c_adapter_count];\n\n\trc = fdt_get_node_addr_size(fdt, nodeoff, 0, &addr, NULL);\n\tif (rc)\n\t\treturn rc;\n\n\tadapter->addr = addr;\n\tadapter->adapter.driver = &fdt_i2c_adapter_sifive;\n\tadapter->adapter.id = nodeoff;\n\tadapter->adapter.write = sifive_i2c_adapter_write;\n\tadapter->adapter.read = sifive_i2c_adapter_read;\n\trc = i2c_adapter_add(&adapter->adapter);\n\tif (rc)\n\t\treturn rc;\n\n\tsifive_i2c_adapter_count++;\n\treturn 0;\n}\n\nstatic const struct fdt_match sifive_i2c_match[] = {\n\t{ .compatible = \"sifive,i2c0\" },\n\t{ },\n};\n\nstruct fdt_i2c_adapter fdt_i2c_adapter_sifive = {\n\t.match_table = sifive_i2c_match,\n\t.init = sifive_i2c_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/i2c/i2c.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 YADRO\n *\n * Authors:\n *   Nikita Shubin <n.shubin@yadro.com>\n *\n * derivate: lib/utils/gpio/gpio.c\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi_utils/i2c/i2c.h>\n\nstatic SBI_LIST_HEAD(i2c_adapters_list);\n\nstruct i2c_adapter *i2c_adapter_find(int id)\n{\n\tstruct sbi_dlist *pos;\n\n\tsbi_list_for_each(pos, &(i2c_adapters_list)) {\n\t\tstruct i2c_adapter *adap = to_i2c_adapter(pos);\n\n\t\tif (adap->id == id)\n\t\t\treturn adap;\n\t}\n\n\treturn NULL;\n}\n\nint i2c_adapter_add(struct i2c_adapter *ia)\n{\n\tif (!ia)\n\t\treturn SBI_EINVAL;\n\n\tif (i2c_adapter_find(ia->id))\n\t\treturn SBI_EALREADY;\n\n\tsbi_list_add(&(ia->node), &(i2c_adapters_list));\n\n\treturn 0;\n}\n\nvoid i2c_adapter_remove(struct i2c_adapter *ia)\n{\n\tif (!ia)\n\t\treturn;\n\n\tsbi_list_del(&(ia->node));\n}\n\nint i2c_adapter_write(struct i2c_adapter *ia, uint8_t addr, uint8_t reg,\n\t\t     uint8_t *buffer, int len)\n{\n\tif (!ia)\n\t\treturn SBI_EINVAL;\n\tif (!ia->write)\n\t\treturn SBI_ENOSYS;\n\n\treturn ia->write(ia, addr, reg, buffer, len);\n}\n\n\nint i2c_adapter_read(struct i2c_adapter *ia, uint8_t addr, uint8_t reg,\n\t\t     uint8_t *buffer, int len)\n{\n\tif (!ia)\n\t\treturn SBI_EINVAL;\n\tif (!ia->read)\n\t\treturn SBI_ENOSYS;\n\n\treturn ia->read(ia, addr, reg, buffer, len);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/i2c/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2021 YADRO\n#\n# Authors:\n#   Nikita Shubin <n.shubin@yadro.com>\n#\n\nlibsbiutils-objs-$(CONFIG_I2C) += i2c/i2c.o\n\nlibsbiutils-objs-$(CONFIG_FDT_I2C) += i2c/fdt_i2c.o\nlibsbiutils-objs-$(CONFIG_FDT_I2C) += i2c/fdt_i2c_adapter_drivers.o\n\ncarray-fdt_i2c_adapter_drivers-$(CONFIG_FDT_I2C_SIFIVE) += fdt_i2c_adapter_sifive\nlibsbiutils-objs-$(CONFIG_FDT_I2C_SIFIVE) += i2c/fdt_i2c_sifive.o\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/ipi/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"IPI Device Support\"\n\nconfig FDT_IPI\n\tbool \"FDT based ipi drivers\"\n\tdepends on FDT\n\tdefault n\n\nif FDT_IPI\n\nconfig FDT_IPI_MSWI\n\tbool \"ACLINT MSWI FDT driver\"\n\tselect IPI_MSWI\n\tdefault n\n\nconfig FDT_IPI_PLICSW\n\tbool \"Andes PLICSW FDT driver\"\n\tselect IPI_PLICSW\n\tdefault n\n\nendif\n\nconfig IPI_MSWI\n\tbool \"ACLINT MSWI support\"\n\tdefault n\n\nconfig IPI_PLICSW\n\tbool \"Andes PLICSW support\"\n\tdefault n\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/ipi/aclint_mswi.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_atomic.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_timer.h>\n#include <sbi_utils/ipi/aclint_mswi.h>\n\nstatic struct aclint_mswi_data *mswi_hartid2data[SBI_HARTMASK_MAX_BITS];\n\nstatic void mswi_ipi_send(u32 target_hart)\n{\n\tu32 *msip;\n\tstruct aclint_mswi_data *mswi;\n\n\tif (SBI_HARTMASK_MAX_BITS <= target_hart)\n\t\treturn;\n\tmswi = mswi_hartid2data[target_hart];\n\tif (!mswi)\n\t\treturn;\n\n\t/* Set ACLINT IPI */\n\tmsip = (void *)mswi->addr;\n\twritel(1, &msip[target_hart - mswi->first_hartid]);\n}\n\nstatic void mswi_ipi_clear(u32 target_hart)\n{\n\tu32 *msip;\n\tstruct aclint_mswi_data *mswi;\n\n\tif (SBI_HARTMASK_MAX_BITS <= target_hart)\n\t\treturn;\n\tmswi = mswi_hartid2data[target_hart];\n\tif (!mswi)\n\t\treturn;\n\n\t/* Clear ACLINT IPI */\n\tmsip = (void *)mswi->addr;\n\twritel(0, &msip[target_hart - mswi->first_hartid]);\n}\n\nstatic struct sbi_ipi_device aclint_mswi = {\n\t.name = \"aclint-mswi\",\n\t.ipi_send = mswi_ipi_send,\n\t.ipi_clear = mswi_ipi_clear\n};\n\nint aclint_mswi_warm_init(void)\n{\n\t/* Clear IPI for current HART */\n\tmswi_ipi_clear(current_hartid());\n\n\treturn 0;\n}\n\nint aclint_mswi_cold_init(struct aclint_mswi_data *mswi)\n{\n\tu32 i;\n\tint rc;\n\tunsigned long pos, region_size;\n\tstruct sbi_domain_memregion reg;\n\n\t/* Sanity checks */\n\tif (!mswi || (mswi->addr & (ACLINT_MSWI_ALIGN - 1)) ||\n\t    (mswi->size < (mswi->hart_count * sizeof(u32))) ||\n\t    (mswi->first_hartid >= SBI_HARTMASK_MAX_BITS) ||\n\t    (mswi->hart_count > ACLINT_MSWI_MAX_HARTS))\n\t\treturn SBI_EINVAL;\n\n\t/* Update MSWI hartid table */\n\tfor (i = 0; i < mswi->hart_count; i++)\n\t\tmswi_hartid2data[mswi->first_hartid + i] = mswi;\n\n\t/* Add MSWI regions to the root domain */\n\tfor (pos = 0; pos < mswi->size; pos += ACLINT_MSWI_ALIGN) {\n\t\tregion_size = ((mswi->size - pos) < ACLINT_MSWI_ALIGN) ?\n\t\t\t      (mswi->size - pos) : ACLINT_MSWI_ALIGN;\n\t\tsbi_domain_memregion_init(mswi->addr + pos, region_size,\n\t\t\t\t\t  SBI_DOMAIN_MEMREGION_MMIO, &reg);\n\t\trc = sbi_domain_root_add_memregion(&reg);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\tsbi_ipi_set_device(&aclint_mswi);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/ipi/andes_plicsw.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Andes Technology Corporation\n *\n * Authors:\n *   Zong Li <zong@andestech.com>\n *   Nylon Chen <nylon7@andestech.com>\n *   Leo Yu-Chi Liang <ycliang@andestech.com>\n *   Yu Chien Peter Lin <peterlin@andestech.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi_utils/ipi/andes_plicsw.h>\n\nstruct plicsw_data plicsw;\n\nstatic inline void plicsw_claim(void)\n{\n\tu32 hartid = current_hartid();\n\n\tif (plicsw.hart_count <= hartid)\n\t\tebreak();\n\n\tplicsw.source_id[hartid] =\n\t\treadl((void *)plicsw.addr + PLICSW_CONTEXT_BASE +\n\t\t      PLICSW_CONTEXT_CLAIM + PLICSW_CONTEXT_STRIDE * hartid);\n}\n\nstatic inline void plicsw_complete(void)\n{\n\tu32 hartid = current_hartid();\n\tu32 source = plicsw.source_id[hartid];\n\n\twritel(source, (void *)plicsw.addr + PLICSW_CONTEXT_BASE +\n\t\t\t       PLICSW_CONTEXT_CLAIM +\n\t\t\t       PLICSW_CONTEXT_STRIDE * hartid);\n}\n\nstatic inline void plic_sw_pending(u32 target_hart)\n{\n\t/*\n\t * The pending array registers are w1s type.\n\t * IPI pending array mapping as following:\n\t *\n\t * Pending array start address: base + 0x1000\n\t * ---------------------------------\n\t * | hart3 | hart2 | hart1 | hart0 |\n\t * ---------------------------------\n\t * Each hartX can send IPI to another hart by setting the\n\t * bitY to its own region (see the below).\n\t *\n\t * In each hartX region:\n\t * <---------- PICSW_PENDING_STRIDE -------->\n\t * | bit7 | ... | bit3 | bit2 | bit1 | bit0 |\n\t * ------------------------------------------\n\t * The bitY of hartX region indicates that hartX sends an\n\t * IPI to hartY.\n\t */\n\tu32 hartid\t    = current_hartid();\n\tu32 word_index\t    = hartid / 4;\n\tu32 per_hart_offset = PLICSW_PENDING_STRIDE * hartid;\n\tu32 val\t\t    = 1 << target_hart << per_hart_offset;\n\n\twritel(val, (void *)plicsw.addr + PLICSW_PENDING_BASE + word_index * 4);\n}\n\nstatic void plicsw_ipi_send(u32 target_hart)\n{\n\tif (plicsw.hart_count <= target_hart)\n\t\tebreak();\n\n\t/* Set PLICSW IPI */\n\tplic_sw_pending(target_hart);\n}\n\nstatic void plicsw_ipi_clear(u32 target_hart)\n{\n\tif (plicsw.hart_count <= target_hart)\n\t\tebreak();\n\n\t/* Clear PLICSW IPI */\n\tplicsw_claim();\n\tplicsw_complete();\n}\n\nstatic struct sbi_ipi_device plicsw_ipi = {\n\t.name      = \"andes_plicsw\",\n\t.ipi_send  = plicsw_ipi_send,\n\t.ipi_clear = plicsw_ipi_clear\n};\n\nint plicsw_warm_ipi_init(void)\n{\n\tu32 hartid = current_hartid();\n\n\t/* Clear PLICSW IPI */\n\tplicsw_ipi_clear(hartid);\n\n\treturn 0;\n}\n\nint plicsw_cold_ipi_init(struct plicsw_data *plicsw)\n{\n\tint rc;\n\n\t/* Setup source priority */\n\tuint32_t *priority = (void *)plicsw->addr + PLICSW_PRIORITY_BASE;\n\n\tfor (int i = 0; i < plicsw->hart_count; i++)\n\t\twritel(1, &priority[i]);\n\n\t/* Setup target enable */\n\tuint32_t enable_mask = PLICSW_HART_MASK;\n\n\tfor (int i = 0; i < plicsw->hart_count; i++) {\n\t\tuint32_t *enable = (void *)plicsw->addr + PLICSW_ENABLE_BASE +\n\t\t\t\t   PLICSW_ENABLE_STRIDE * i;\n\t\twritel(enable_mask, enable);\n\t\twritel(enable_mask, enable + 1);\n\t\tenable_mask <<= 1;\n\t}\n\n\t/* Add PLICSW region to the root domain */\n\trc = sbi_domain_root_add_memrange(plicsw->addr, plicsw->size,\n\t\t\t\t\t  PLICSW_REGION_ALIGN,\n\t\t\t\t\t  SBI_DOMAIN_MEMREGION_MMIO);\n\tif (rc)\n\t\treturn rc;\n\n\tsbi_ipi_set_device(&plicsw_ipi);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/ipi/fdt_ipi.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/ipi/fdt_ipi.h>\n\n/* List of FDT ipi drivers generated at compile time */\nextern struct fdt_ipi *fdt_ipi_drivers[];\nextern unsigned long fdt_ipi_drivers_size;\n\nstatic struct fdt_ipi dummy = {\n\t.match_table = NULL,\n\t.cold_init = NULL,\n\t.warm_init = NULL,\n\t.exit = NULL,\n};\n\nstatic struct fdt_ipi *current_driver = &dummy;\n\nvoid fdt_ipi_exit(void)\n{\n\tif (current_driver->exit)\n\t\tcurrent_driver->exit();\n}\n\nstatic int fdt_ipi_warm_init(void)\n{\n\tif (current_driver->warm_init)\n\t\treturn current_driver->warm_init();\n\treturn 0;\n}\n\nstatic int fdt_ipi_cold_init(void)\n{\n\tint pos, noff, rc;\n\tstruct fdt_ipi *drv;\n\tconst struct fdt_match *match;\n\tvoid *fdt = fdt_get_address();\n\n\tfor (pos = 0; pos < fdt_ipi_drivers_size; pos++) {\n\t\tdrv = fdt_ipi_drivers[pos];\n\n\t\tnoff = -1;\n\t\twhile ((noff = fdt_find_match(fdt, noff,\n\t\t\t\t\tdrv->match_table, &match)) >= 0) {\n\t\t\tif (drv->cold_init) {\n\t\t\t\trc = drv->cold_init(fdt, noff, match);\n\t\t\t\tif (rc == SBI_ENODEV)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (rc)\n\t\t\t\t\treturn rc;\n\t\t\t}\n\t\t\tcurrent_driver = drv;\n\t\t}\n\n\t\tif (current_driver != &dummy)\n\t\t\tbreak;\n\t}\n\n\treturn 0;\n}\n\nint fdt_ipi_init(bool cold_boot)\n{\n\tint rc;\n\n\tif (cold_boot) {\n\t\trc = fdt_ipi_cold_init();\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn fdt_ipi_warm_init();\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/ipi/fdt_ipi_drivers.carray",
    "content": "HEADER: sbi_utils/ipi/fdt_ipi.h\nTYPE: struct fdt_ipi\nNAME: fdt_ipi_drivers\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/ipi/fdt_ipi_mswi.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/ipi/fdt_ipi.h>\n#include <sbi_utils/ipi/aclint_mswi.h>\n\n#define MSWI_MAX_NR\t\t\t16\n\nstatic unsigned long mswi_count = 0;\nstatic struct aclint_mswi_data mswi[MSWI_MAX_NR];\n\nstatic int ipi_mswi_cold_init(void *fdt, int nodeoff,\n\t\t\t      const struct fdt_match *match)\n{\n\tint rc;\n\tunsigned long offset;\n\tstruct aclint_mswi_data *ms;\n\n\tif (MSWI_MAX_NR <= mswi_count)\n\t\treturn SBI_ENOSPC;\n\tms = &mswi[mswi_count];\n\n\trc = fdt_parse_aclint_node(fdt, nodeoff, false,\n\t\t\t\t   &ms->addr, &ms->size, NULL, NULL,\n\t\t\t\t   &ms->first_hartid, &ms->hart_count);\n\tif (rc)\n\t\treturn rc;\n\n\tif (match->data) {\n\t\t/* Adjust MSWI address and size for CLINT device */\n\t\toffset = *((unsigned long *)match->data);\n\t\tms->addr += offset;\n\t\tif ((ms->size - offset) < ACLINT_MSWI_SIZE)\n\t\t\treturn SBI_EINVAL;\n\t\tms->size = ACLINT_MSWI_SIZE;\n\t}\n\n\trc = aclint_mswi_cold_init(ms);\n\tif (rc)\n\t\treturn rc;\n\n\tmswi_count++;\n\treturn 0;\n}\n\nstatic const unsigned long clint_offset = CLINT_MSWI_OFFSET;\n\nstatic const struct fdt_match ipi_mswi_match[] = {\n\t{ .compatible = \"riscv,clint0\", .data = &clint_offset },\n\t{ .compatible = \"sifive,clint0\", .data = &clint_offset },\n\t{ .compatible = \"thead,c900-clint\", .data = &clint_offset },\n\t{ .compatible = \"riscv,aclint-mswi\" },\n\t{ },\n};\n\nstruct fdt_ipi fdt_ipi_mswi = {\n\t.match_table = ipi_mswi_match,\n\t.cold_init = ipi_mswi_cold_init,\n\t.warm_init = aclint_mswi_warm_init,\n\t.exit = NULL,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/ipi/fdt_ipi_plicsw.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Andes Technology Corporation\n *\n * Authors:\n *   Zong Li <zong@andestech.com>\n *   Nylon Chen <nylon7@andestech.com>\n *   Leo Yu-Chi Liang <ycliang@andestech.com>\n *   Yu Chien Peter Lin <peterlin@andestech.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/ipi/fdt_ipi.h>\n#include <sbi_utils/ipi/andes_plicsw.h>\n\nextern struct plicsw_data plicsw;\n\nint fdt_plicsw_cold_ipi_init(void *fdt, int nodeoff,\n\t\t\t\tconst struct fdt_match *match)\n{\n\tint rc;\n\n\trc = fdt_parse_plicsw_node(fdt, nodeoff, &plicsw.addr, &plicsw.size,\n\t\t\t\t   &plicsw.hart_count);\n\tif (rc)\n\t\treturn rc;\n\n\trc = plicsw_cold_ipi_init(&plicsw);\n\tif (rc)\n\t\treturn rc;\n\n\treturn 0;\n}\n\nstatic const struct fdt_match ipi_plicsw_match[] = {\n\t{ .compatible = \"andestech,plicsw\" },\n\t{},\n};\n\nstruct fdt_ipi fdt_ipi_plicsw = {\n\t.match_table = ipi_plicsw_match,\n\t.cold_init   = fdt_plicsw_cold_ipi_init,\n\t.warm_init   = plicsw_warm_ipi_init,\n\t.exit\t     = NULL,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/ipi/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2020 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nlibsbiutils-objs-$(CONFIG_IPI_MSWI) += ipi/aclint_mswi.o\nlibsbiutils-objs-$(CONFIG_IPI_PLICSW) += ipi/andes_plicsw.o\n\nlibsbiutils-objs-$(CONFIG_FDT_IPI) += ipi/fdt_ipi.o\nlibsbiutils-objs-$(CONFIG_FDT_IPI) += ipi/fdt_ipi_drivers.o\n\ncarray-fdt_ipi_drivers-$(CONFIG_FDT_IPI_MSWI) += fdt_ipi_mswi\nlibsbiutils-objs-$(CONFIG_FDT_IPI_MSWI) += ipi/fdt_ipi_mswi.o\n\ncarray-fdt_ipi_drivers-$(CONFIG_FDT_IPI_PLICSW) += fdt_ipi_plicsw\nlibsbiutils-objs-$(CONFIG_FDT_IPI_PLICSW) += ipi/fdt_ipi_plicsw.o\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"Interrupt Controller Support\"\n\nconfig FDT_IRQCHIP\n\tbool \"FDT based interrupt controller drivers\"\n\tdepends on FDT\n\tdefault n\n\nif FDT_IRQCHIP\n\nconfig FDT_IRQCHIP_APLIC\n\tbool \"Advanced Platform Level Interrupt Controller (APLIC) FDT driver\"\n\tselect IRQCHIP_APLIC\n\tdefault n\n\nconfig FDT_IRQCHIP_IMSIC\n\tbool \"Incoming Message Signalled Interrupt Controller (IMSIC) FDT driver\"\n\tselect IRQCHIP_IMSIC\n\tdefault n\n\nconfig FDT_IRQCHIP_PLIC\n\tbool \"Platform Level Interrupt Controller (PLIC) FDT driver\"\n\tselect IRQCHIP_PLIC\n\tdefault n\n\nendif\n\nconfig IRQCHIP_APLIC\n\tbool \"Advanced Platform Level Interrupt Controller (APLIC) support\"\n\tdefault n\n\nconfig IRQCHIP_IMSIC\n\tbool \"Incoming Message Signalled Interrupt Controller (IMSIC) support\"\n\tdefault n\n\nconfig IRQCHIP_PLIC\n\tbool \"Platform Level Interrupt Controller (PLIC) support\"\n\tdefault n\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/aplic.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_error.h>\n#include <sbi_utils/irqchip/aplic.h>\n\n#define APLIC_MAX_IDC\t\t\t(1UL << 14)\n#define APLIC_MAX_SOURCE\t\t1024\n\n#define APLIC_DOMAINCFG\t\t0x0000\n#define APLIC_DOMAINCFG_IE\t\t(1 << 8)\n#define APLIC_DOMAINCFG_DM\t\t(1 << 2)\n#define APLIC_DOMAINCFG_BE\t\t(1 << 0)\n\n#define APLIC_SOURCECFG_BASE\t\t0x0004\n#define APLIC_SOURCECFG_D\t\t(1 << 10)\n#define APLIC_SOURCECFG_CHILDIDX_MASK\t0x000003ff\n#define APLIC_SOURCECFG_SM_MASK\t0x00000007\n#define APLIC_SOURCECFG_SM_INACTIVE\t0x0\n#define APLIC_SOURCECFG_SM_DETACH\t0x1\n#define APLIC_SOURCECFG_SM_EDGE_RISE\t0x4\n#define APLIC_SOURCECFG_SM_EDGE_FALL\t0x5\n#define APLIC_SOURCECFG_SM_LEVEL_HIGH\t0x6\n#define APLIC_SOURCECFG_SM_LEVEL_LOW\t0x7\n\n#define APLIC_MMSICFGADDR\t\t0x1bc0\n#define APLIC_MMSICFGADDRH\t\t0x1bc4\n#define APLIC_SMSICFGADDR\t\t0x1bc8\n#define APLIC_SMSICFGADDRH\t\t0x1bcc\n\n#define APLIC_xMSICFGADDRH_L\t\t(1UL << 31)\n#define APLIC_xMSICFGADDRH_HHXS_MASK\t0x1f\n#define APLIC_xMSICFGADDRH_HHXS_SHIFT\t24\n#define APLIC_xMSICFGADDRH_LHXS_MASK\t0x7\n#define APLIC_xMSICFGADDRH_LHXS_SHIFT\t20\n#define APLIC_xMSICFGADDRH_HHXW_MASK\t0x7\n#define APLIC_xMSICFGADDRH_HHXW_SHIFT\t16\n#define APLIC_xMSICFGADDRH_LHXW_MASK\t0xf\n#define APLIC_xMSICFGADDRH_LHXW_SHIFT\t12\n#define APLIC_xMSICFGADDRH_BAPPN_MASK\t0xfff\n\n#define APLIC_xMSICFGADDR_PPN_SHIFT\t12\n\n#define APLIC_xMSICFGADDR_PPN_HART(__lhxs) \\\n\t((1UL << (__lhxs)) - 1)\n\n#define APLIC_xMSICFGADDR_PPN_LHX_MASK(__lhxw) \\\n\t((1UL << (__lhxw)) - 1)\n#define APLIC_xMSICFGADDR_PPN_LHX_SHIFT(__lhxs) \\\n\t((__lhxs))\n#define APLIC_xMSICFGADDR_PPN_LHX(__lhxw, __lhxs) \\\n\t(APLIC_xMSICFGADDR_PPN_LHX_MASK(__lhxw) << \\\n\t APLIC_xMSICFGADDR_PPN_LHX_SHIFT(__lhxs))\n\n#define APLIC_xMSICFGADDR_PPN_HHX_MASK(__hhxw) \\\n\t((1UL << (__hhxw)) - 1)\n#define APLIC_xMSICFGADDR_PPN_HHX_SHIFT(__hhxs) \\\n\t((__hhxs) + APLIC_xMSICFGADDR_PPN_SHIFT)\n#define APLIC_xMSICFGADDR_PPN_HHX(__hhxw, __hhxs) \\\n\t(APLIC_xMSICFGADDR_PPN_HHX_MASK(__hhxw) << \\\n\t APLIC_xMSICFGADDR_PPN_HHX_SHIFT(__hhxs))\n\n#define APLIC_SETIP_BASE\t\t0x1c00\n#define APLIC_SETIPNUM\t\t\t0x1cdc\n\n#define APLIC_CLRIP_BASE\t\t0x1d00\n#define APLIC_CLRIPNUM\t\t\t0x1ddc\n\n#define APLIC_SETIE_BASE\t\t0x1e00\n#define APLIC_SETIENUM\t\t\t0x1edc\n\n#define APLIC_CLRIE_BASE\t\t0x1f00\n#define APLIC_CLRIENUM\t\t\t0x1fdc\n\n#define APLIC_SETIPNUM_LE\t\t0x2000\n#define APLIC_SETIPNUM_BE\t\t0x2004\n\n#define APLIC_TARGET_BASE\t\t0x3004\n#define APLIC_TARGET_HART_IDX_SHIFT\t18\n#define APLIC_TARGET_HART_IDX_MASK\t0x3fff\n#define APLIC_TARGET_GUEST_IDX_SHIFT\t12\n#define APLIC_TARGET_GUEST_IDX_MASK\t0x3f\n#define APLIC_TARGET_IPRIO_MASK\t0xff\n#define APLIC_TARGET_EIID_MASK\t0x7ff\n\n#define APLIC_IDC_BASE\t\t\t0x4000\n#define APLIC_IDC_SIZE\t\t\t32\n\n#define APLIC_IDC_IDELIVERY\t\t0x00\n\n#define APLIC_IDC_IFORCE\t\t0x04\n\n#define APLIC_IDC_ITHRESHOLD\t\t0x08\n\n#define APLIC_IDC_TOPI\t\t\t0x18\n#define APLIC_IDC_TOPI_ID_SHIFT\t16\n#define APLIC_IDC_TOPI_ID_MASK\t0x3ff\n#define APLIC_IDC_TOPI_PRIO_MASK\t0xff\n\n#define APLIC_IDC_CLAIMI\t\t0x1c\n\n#define APLIC_DEFAULT_PRIORITY\t\t1\n#define APLIC_DISABLE_IDELIVERY\t\t0\n#define APLIC_ENABLE_IDELIVERY\t\t1\n#define APLIC_DISABLE_ITHRESHOLD\t1\n#define APLIC_ENABLE_ITHRESHOLD\t\t0\n\nstatic void aplic_writel_msicfg(struct aplic_msicfg_data *msicfg,\n\t\t\t\tvoid *msicfgaddr, void *msicfgaddrH)\n{\n\tu32 val;\n\tunsigned long base_ppn;\n\n\t/* Check if MSI config is already locked */\n\tif (readl(msicfgaddrH) & APLIC_xMSICFGADDRH_L)\n\t\treturn;\n\n\t/* Compute the MSI base PPN */\n\tbase_ppn = msicfg->base_addr >> APLIC_xMSICFGADDR_PPN_SHIFT;\n\tbase_ppn &= ~APLIC_xMSICFGADDR_PPN_HART(msicfg->lhxs);\n\tbase_ppn &= ~APLIC_xMSICFGADDR_PPN_LHX(msicfg->lhxw, msicfg->lhxs);\n\tbase_ppn &= ~APLIC_xMSICFGADDR_PPN_HHX(msicfg->hhxw, msicfg->hhxs);\n\n\t/* Write the lower MSI config register */\n\twritel((u32)base_ppn, msicfgaddr);\n\n\t/* Write the upper MSI config register */\n\tval = (((u64)base_ppn) >> 32) &\n\t\tAPLIC_xMSICFGADDRH_BAPPN_MASK;\n\tval |= (msicfg->lhxw & APLIC_xMSICFGADDRH_LHXW_MASK)\n\t\t<< APLIC_xMSICFGADDRH_LHXW_SHIFT;\n\tval |= (msicfg->hhxw & APLIC_xMSICFGADDRH_HHXW_MASK)\n\t\t<< APLIC_xMSICFGADDRH_HHXW_SHIFT;\n\tval |= (msicfg->lhxs & APLIC_xMSICFGADDRH_LHXS_MASK)\n\t\t<< APLIC_xMSICFGADDRH_LHXS_SHIFT;\n\tval |= (msicfg->hhxs & APLIC_xMSICFGADDRH_HHXS_MASK)\n\t\t<< APLIC_xMSICFGADDRH_HHXS_SHIFT;\n\twritel(val, msicfgaddrH);\n}\n\nstatic int aplic_check_msicfg(struct aplic_msicfg_data *msicfg)\n{\n\tif (APLIC_xMSICFGADDRH_LHXS_MASK < msicfg->lhxs)\n\t\treturn SBI_EINVAL;\n\n\tif (APLIC_xMSICFGADDRH_LHXW_MASK < msicfg->lhxw)\n\t\treturn SBI_EINVAL;\n\n\tif (APLIC_xMSICFGADDRH_HHXS_MASK < msicfg->hhxs)\n\t\treturn SBI_EINVAL;\n\n\tif (APLIC_xMSICFGADDRH_HHXW_MASK < msicfg->hhxw)\n\t\treturn SBI_EINVAL;\n\n\treturn 0;\n}\n\nint aplic_cold_irqchip_init(struct aplic_data *aplic)\n{\n\tint rc;\n\tu32 i, j, tmp;\n\tstruct sbi_domain_memregion reg;\n\tstruct aplic_delegate_data *deleg;\n\tu32 first_deleg_irq, last_deleg_irq;\n\n\t/* Sanity checks */\n\tif (!aplic ||\n\t    !aplic->num_source || APLIC_MAX_SOURCE <= aplic->num_source ||\n\t    APLIC_MAX_IDC <= aplic->num_idc)\n\t\treturn SBI_EINVAL;\n\tif (aplic->targets_mmode && aplic->has_msicfg_mmode) {\n\t\trc = aplic_check_msicfg(&aplic->msicfg_mmode);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\tif (aplic->targets_mmode && aplic->has_msicfg_smode) {\n\t\trc = aplic_check_msicfg(&aplic->msicfg_smode);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\t/* Set domain configuration to 0 */\n\twritel(0, (void *)(aplic->addr + APLIC_DOMAINCFG));\n\n\t/* Disable all interrupts */\n\tfor (i = 0; i <= aplic->num_source; i++)\n\t\twritel(-1U, (void *)(aplic->addr + APLIC_CLRIE_BASE +\n\t\t\t\t     (i / 32) * sizeof(u32)));\n\n\t/* Set interrupt type and priority for all interrupts */\n\tfor (i = 1; i <= aplic->num_source; i++) {\n\t\t/* Set IRQ source configuration to 0 */\n\t\twritel(0, (void *)(aplic->addr + APLIC_SOURCECFG_BASE +\n\t\t\t  (i - 1) * sizeof(u32)));\n\t\t/* Set IRQ target hart index and priority to 1 */\n\t\twritel(APLIC_DEFAULT_PRIORITY, (void *)(aplic->addr +\n\t\t\t\t\t\tAPLIC_TARGET_BASE +\n\t\t\t\t\t\t(i - 1) * sizeof(u32)));\n\t}\n\n\t/* Configure IRQ delegation */\n\tfirst_deleg_irq = -1U;\n\tlast_deleg_irq = 0;\n\tfor (i = 0; i < APLIC_MAX_DELEGATE; i++) {\n\t\tdeleg = &aplic->delegate[i];\n\t\tif (!deleg->first_irq || !deleg->last_irq)\n\t\t\tcontinue;\n\t\tif (aplic->num_source < deleg->first_irq ||\n\t\t    aplic->num_source < deleg->last_irq)\n\t\t\tcontinue;\n\t\tif (APLIC_SOURCECFG_CHILDIDX_MASK < deleg->child_index)\n\t\t\tcontinue;\n\t\tif (deleg->first_irq > deleg->last_irq) {\n\t\t\ttmp = deleg->first_irq;\n\t\t\tdeleg->first_irq = deleg->last_irq;\n\t\t\tdeleg->last_irq = tmp;\n\t\t}\n\t\tif (deleg->first_irq < first_deleg_irq)\n\t\t\tfirst_deleg_irq = deleg->first_irq;\n\t\tif (last_deleg_irq < deleg->last_irq)\n\t\t\tlast_deleg_irq = deleg->last_irq;\n\t\tfor (j = deleg->first_irq; j <= deleg->last_irq; j++)\n\t\t\twritel(APLIC_SOURCECFG_D | deleg->child_index,\n\t\t\t\t(void *)(aplic->addr + APLIC_SOURCECFG_BASE +\n\t\t\t\t(j - 1) * sizeof(u32)));\n\t}\n\n\t/* Default initialization of IDC structures */\n\tfor (i = 0; i < aplic->num_idc; i++) {\n\t\twritel(0, (void *)(aplic->addr + APLIC_IDC_BASE +\n\t\t\t  i * APLIC_IDC_SIZE + APLIC_IDC_IDELIVERY));\n\t\twritel(0, (void *)(aplic->addr + APLIC_IDC_BASE +\n\t\t\t  i * APLIC_IDC_SIZE + APLIC_IDC_IFORCE));\n\t\twritel(APLIC_DISABLE_ITHRESHOLD, (void *)(aplic->addr +\n\t\t\t\t\t\t  APLIC_IDC_BASE +\n\t\t\t\t\t\t  (i * APLIC_IDC_SIZE) +\n\t\t\t\t\t\t  APLIC_IDC_ITHRESHOLD));\n\t}\n\n\t/* MSI configuration */\n\tif (aplic->targets_mmode && aplic->has_msicfg_mmode) {\n\t\taplic_writel_msicfg(&aplic->msicfg_mmode,\n\t\t\t\t(void *)(aplic->addr + APLIC_MMSICFGADDR),\n\t\t\t\t(void *)(aplic->addr + APLIC_MMSICFGADDRH));\n\t}\n\tif (aplic->targets_mmode && aplic->has_msicfg_smode) {\n\t\taplic_writel_msicfg(&aplic->msicfg_smode,\n\t\t\t\t(void *)(aplic->addr + APLIC_SMSICFGADDR),\n\t\t\t\t(void *)(aplic->addr + APLIC_SMSICFGADDRH));\n\t}\n\n\t/*\n\t * Add APLIC region to the root domain if:\n\t * 1) It targets M-mode of any HART directly or via MSIs\n\t * 2) All interrupts are delegated to some child APLIC\n\t */\n\tif (aplic->targets_mmode ||\n\t    ((first_deleg_irq < last_deleg_irq) &&\n\t    (last_deleg_irq == aplic->num_source) &&\n\t    (first_deleg_irq == 1))) {\n\t\tsbi_domain_memregion_init(aplic->addr, aplic->size,\n\t\t\t\t\t  SBI_DOMAIN_MEMREGION_MMIO, &reg);\n\t\trc = sbi_domain_root_add_memregion(&reg);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/fdt_irqchip.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/irqchip/fdt_irqchip.h>\n\n/* List of FDT irqchip drivers generated at compile time */\nextern struct fdt_irqchip *fdt_irqchip_drivers[];\nextern unsigned long fdt_irqchip_drivers_size;\n\n#define FDT_IRQCHIP_MAX_DRIVERS\t8\n\nstatic struct fdt_irqchip *current_drivers[FDT_IRQCHIP_MAX_DRIVERS] = {0};\nstatic int current_drivers_count;\n\nvoid fdt_irqchip_exit(void)\n{\n\tint i;\n\n\tfor (i = 0; i < current_drivers_count; i++) {\n\t\tif (!current_drivers[i] || !current_drivers[i]->exit)\n\t\t\tcontinue;\n\t\tcurrent_drivers[i]->exit();\n\t}\n}\n\nstatic int fdt_irqchip_warm_init(void)\n{\n\tint i, rc;\n\n\tfor (i = 0; i < current_drivers_count; i++) {\n\t\tif (!current_drivers[i] || !current_drivers[i]->warm_init)\n\t\t\tcontinue;\n\t\trc = current_drivers[i]->warm_init();\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn 0;\n}\n\nstatic int fdt_irqchip_cold_init(void)\n{\n\tbool drv_added;\n\tint pos, noff, rc;\n\tstruct fdt_irqchip *drv;\n\tconst struct fdt_match *match;\n\tvoid *fdt = fdt_get_address();\n\n\tfor (pos = 0; pos < fdt_irqchip_drivers_size; pos++) {\n\t\tdrv = fdt_irqchip_drivers[pos];\n\n\t\tnoff = -1;\n\t\tdrv_added = false;\n\t\twhile ((noff = fdt_find_match(fdt, noff,\n\t\t\t\t\tdrv->match_table, &match)) >= 0) {\n\t\t\tif (drv->cold_init) {\n\t\t\t\trc = drv->cold_init(fdt, noff, match);\n\t\t\t\tif (rc == SBI_ENODEV)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (rc)\n\t\t\t\t\treturn rc;\n\t\t\t}\n\n\t\t\tif (drv_added)\n\t\t\t\tcontinue;\n\n\t\t\tcurrent_drivers[current_drivers_count++] = drv;\n\t\t\tdrv_added = true;\n\t\t}\n\n\t\tif (FDT_IRQCHIP_MAX_DRIVERS <= current_drivers_count)\n\t\t\tbreak;\n\t}\n\n\treturn 0;\n}\n\nint fdt_irqchip_init(bool cold_boot)\n{\n\tint rc;\n\n\tif (cold_boot) {\n\t\trc = fdt_irqchip_cold_init();\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn fdt_irqchip_warm_init();\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/fdt_irqchip_aplic.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_error.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/irqchip/fdt_irqchip.h>\n#include <sbi_utils/irqchip/aplic.h>\n\n#define APLIC_MAX_NR\t\t\t16\n\nstatic unsigned long aplic_count = 0;\nstatic struct aplic_data aplic[APLIC_MAX_NR];\n\nstatic int irqchip_aplic_warm_init(void)\n{\n\t/* Nothing to do here. */\n\treturn 0;\n}\n\nstatic int irqchip_aplic_cold_init(void *fdt, int nodeoff,\n\t\t\t\t  const struct fdt_match *match)\n{\n\tint rc;\n\tstruct aplic_data *pd;\n\n\tif (APLIC_MAX_NR <= aplic_count)\n\t\treturn SBI_ENOSPC;\n\tpd = &aplic[aplic_count++];\n\n\trc = fdt_parse_aplic_node(fdt, nodeoff, pd);\n\tif (rc)\n\t\treturn rc;\n\n\treturn aplic_cold_irqchip_init(pd);\n}\n\nstatic const struct fdt_match irqchip_aplic_match[] = {\n\t{ .compatible = \"riscv,aplic\" },\n\t{ },\n};\n\nstruct fdt_irqchip fdt_irqchip_aplic = {\n\t.match_table = irqchip_aplic_match,\n\t.cold_init = irqchip_aplic_cold_init,\n\t.warm_init = irqchip_aplic_warm_init,\n\t.exit = NULL,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/fdt_irqchip_drivers.carray",
    "content": "HEADER: sbi_utils/irqchip/fdt_irqchip.h\nTYPE: struct fdt_irqchip\nNAME: fdt_irqchip_drivers\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/fdt_irqchip_imsic.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/irqchip/fdt_irqchip.h>\n#include <sbi_utils/irqchip/imsic.h>\n\n#define IMSIC_MAX_NR\t\t\t16\n\nstatic unsigned long imsic_count = 0;\nstatic struct imsic_data imsic[IMSIC_MAX_NR];\n\nstatic int irqchip_imsic_update_hartid_table(void *fdt, int nodeoff,\n\t\t\t\t\t     struct imsic_data *id)\n{\n\tconst fdt32_t *val;\n\tu32 phandle, hwirq, hartid;\n\tint i, err, count, cpu_offset, cpu_intc_offset;\n\n\tval = fdt_getprop(fdt, nodeoff, \"interrupts-extended\", &count);\n\tif (!val || count < sizeof(fdt32_t))\n\t\treturn SBI_EINVAL;\n\tcount = count / sizeof(fdt32_t);\n\n\tfor (i = 0; i < count; i += 2) {\n\t\tphandle = fdt32_to_cpu(val[i]);\n\t\thwirq = fdt32_to_cpu(val[i + 1]);\n\n\t\tcpu_intc_offset = fdt_node_offset_by_phandle(fdt, phandle);\n\t\tif (cpu_intc_offset < 0)\n\t\t\tcontinue;\n\n\t\tcpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);\n\t\tif (cpu_offset < 0)\n\t\t\tcontinue;\n\n\t\terr = fdt_parse_hart_id(fdt, cpu_offset, &hartid);\n\t\tif (err)\n\t\t\treturn SBI_EINVAL;\n\t\tif (SBI_HARTMASK_MAX_BITS <= hartid)\n\t\t\treturn SBI_EINVAL;\n\n\t\tswitch (hwirq) {\n\t\tcase IRQ_M_EXT:\n\t\t\terr = imsic_map_hartid_to_data(hartid, id, i / 2);\n\t\t\tif (err)\n\t\t\t\treturn err;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nstatic int irqchip_imsic_cold_init(void *fdt, int nodeoff,\n\t\t\t\t    const struct fdt_match *match)\n{\n\tint rc;\n\tstruct imsic_data *id;\n\n\tif (IMSIC_MAX_NR <= imsic_count)\n\t\treturn SBI_ENOSPC;\n\tid = &imsic[imsic_count];\n\n\trc = fdt_parse_imsic_node(fdt, nodeoff, id);\n\tif (rc)\n\t\treturn rc;\n\tif (!id->targets_mmode)\n\t\treturn 0;\n\n\trc = irqchip_imsic_update_hartid_table(fdt, nodeoff, id);\n\tif (rc)\n\t\treturn rc;\n\n\trc = imsic_cold_irqchip_init(id);\n\tif (rc)\n\t\treturn rc;\n\n\timsic_count++;\n\n\treturn 0;\n}\n\nstatic const struct fdt_match irqchip_imsic_match[] = {\n\t{ .compatible = \"riscv,imsics\" },\n\t{ },\n};\n\nstruct fdt_irqchip fdt_irqchip_imsic = {\n\t.match_table = irqchip_imsic_match,\n\t.cold_init = irqchip_imsic_cold_init,\n\t.warm_init = imsic_warm_irqchip_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/fdt_irqchip_plic.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/irqchip/fdt_irqchip.h>\n#include <sbi_utils/irqchip/plic.h>\n\n#define PLIC_MAX_NR\t\t\t16\n\nstatic unsigned long plic_count = 0;\nstatic struct plic_data plic[PLIC_MAX_NR];\n\nstatic struct plic_data *plic_hartid2data[SBI_HARTMASK_MAX_BITS];\nstatic int plic_hartid2context[SBI_HARTMASK_MAX_BITS][2];\n\nvoid fdt_plic_priority_save(u8 *priority, u32 num)\n{\n\tstruct plic_data *plic = plic_hartid2data[current_hartid()];\n\n\tplic_priority_save(plic, priority, num);\n}\n\nvoid fdt_plic_priority_restore(const u8 *priority, u32 num)\n{\n\tstruct plic_data *plic = plic_hartid2data[current_hartid()];\n\n\tplic_priority_restore(plic, priority, num);\n}\n\nvoid fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold, u32 num)\n{\n\tu32 hartid = current_hartid();\n\n\tplic_context_save(plic_hartid2data[hartid],\n\t\t\t  plic_hartid2context[hartid][smode],\n\t\t\t  enable, threshold, num);\n}\n\nvoid fdt_plic_context_restore(bool smode, const u32 *enable, u32 threshold,\n\t\t\t      u32 num)\n{\n\tu32 hartid = current_hartid();\n\n\tplic_context_restore(plic_hartid2data[hartid],\n\t\t\t     plic_hartid2context[hartid][smode],\n\t\t\t     enable, threshold, num);\n}\n\nstatic int irqchip_plic_warm_init(void)\n{\n\tu32 hartid = current_hartid();\n\n\treturn plic_warm_irqchip_init(plic_hartid2data[hartid],\n\t\t\t\t      plic_hartid2context[hartid][0],\n\t\t\t\t      plic_hartid2context[hartid][1]);\n}\n\nstatic int irqchip_plic_update_hartid_table(void *fdt, int nodeoff,\n\t\t\t\t\t    struct plic_data *pd)\n{\n\tconst fdt32_t *val;\n\tu32 phandle, hwirq, hartid;\n\tint i, err, count, cpu_offset, cpu_intc_offset;\n\n\tval = fdt_getprop(fdt, nodeoff, \"interrupts-extended\", &count);\n\tif (!val || count < sizeof(fdt32_t))\n\t\treturn SBI_EINVAL;\n\tcount = count / sizeof(fdt32_t);\n\n\tfor (i = 0; i < count; i += 2) {\n\t\tphandle = fdt32_to_cpu(val[i]);\n\t\thwirq = fdt32_to_cpu(val[i + 1]);\n\n\t\tcpu_intc_offset = fdt_node_offset_by_phandle(fdt, phandle);\n\t\tif (cpu_intc_offset < 0)\n\t\t\tcontinue;\n\n\t\tcpu_offset = fdt_parent_offset(fdt, cpu_intc_offset);\n\t\tif (cpu_offset < 0)\n\t\t\tcontinue;\n\n\t\terr = fdt_parse_hart_id(fdt, cpu_offset, &hartid);\n\t\tif (err)\n\t\t\tcontinue;\n\n\t\tif (SBI_HARTMASK_MAX_BITS <= hartid)\n\t\t\tcontinue;\n\n\t\tplic_hartid2data[hartid] = pd;\n\t\tswitch (hwirq) {\n\t\tcase IRQ_M_EXT:\n\t\t\tplic_hartid2context[hartid][0] = i / 2;\n\t\t\tbreak;\n\t\tcase IRQ_S_EXT:\n\t\t\tplic_hartid2context[hartid][1] = i / 2;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nstatic int irqchip_plic_cold_init(void *fdt, int nodeoff,\n\t\t\t\t  const struct fdt_match *match)\n{\n\tint i, rc;\n\tstruct plic_data *pd;\n\n\tif (PLIC_MAX_NR <= plic_count)\n\t\treturn SBI_ENOSPC;\n\tpd = &plic[plic_count++];\n\n\trc = fdt_parse_plic_node(fdt, nodeoff, pd);\n\tif (rc)\n\t\treturn rc;\n\n\tif (match->data) {\n\t\tvoid (*plic_plat_init)(struct plic_data *) = match->data;\n\t\tplic_plat_init(pd);\n\t}\n\n\trc = plic_cold_irqchip_init(pd);\n\tif (rc)\n\t\treturn rc;\n\n\tif (plic_count == 1) {\n\t\tfor (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) {\n\t\t\tplic_hartid2data[i] = NULL;\n\t\t\tplic_hartid2context[i][0] = -1;\n\t\t\tplic_hartid2context[i][1] = -1;\n\t\t}\n\t}\n\n\treturn irqchip_plic_update_hartid_table(fdt, nodeoff, pd);\n}\n\n#define THEAD_PLIC_CTRL_REG 0x1ffffc\n\nstatic void thead_plic_plat_init(struct plic_data *pd)\n{\n\twritel_relaxed(BIT(0), (char *)pd->addr + THEAD_PLIC_CTRL_REG);\n}\n\nvoid thead_plic_restore(void)\n{\n\tstruct plic_data *plic = plic_hartid2data[current_hartid()];\n\n\tthead_plic_plat_init(plic);\n}\n\nstatic const struct fdt_match irqchip_plic_match[] = {\n\t{ .compatible = \"andestech,nceplic100\" },\n\t{ .compatible = \"riscv,plic0\" },\n\t{ .compatible = \"sifive,plic-1.0.0\" },\n\t{ .compatible = \"thead,c900-plic\",\n\t  .data = thead_plic_plat_init },\n\t{ /* sentinel */ }\n};\n\nstruct fdt_irqchip fdt_irqchip_plic = {\n\t.match_table = irqchip_plic_match,\n\t.cold_init = irqchip_plic_cold_init,\n\t.warm_init = irqchip_plic_warm_init,\n\t.exit = NULL,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/imsic.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_io.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_irqchip.h>\n#include <sbi/sbi_error.h>\n#include <sbi_utils/irqchip/imsic.h>\n\n#define IMSIC_MMIO_PAGE_LE\t\t0x00\n#define IMSIC_MMIO_PAGE_BE\t\t0x04\n\n#define IMSIC_MIN_ID\t\t\t63\n#define IMSIC_MAX_ID\t\t\t2047\n\n#define IMSIC_EIDELIVERY\t\t0x70\n\n#define IMSIC_EITHRESHOLD\t\t0x72\n\n#define IMSIC_TOPEI\t\t\t0x76\n#define IMSIC_TOPEI_ID_SHIFT\t\t16\n#define IMSIC_TOPEI_ID_MASK\t\t0x7ff\n#define IMSIC_TOPEI_PRIO_MASK\t\t0x7ff\n\n#define IMSIC_EIP0\t\t\t0x80\n\n#define IMSIC_EIP63\t\t\t0xbf\n\n#define IMSIC_EIPx_BITS\t\t\t32\n\n#define IMSIC_EIE0\t\t\t0xc0\n\n#define IMSIC_EIE63\t\t\t0xff\n\n#define IMSIC_EIEx_BITS\t\t\t32\n\n#define IMSIC_DISABLE_EIDELIVERY\t0\n#define IMSIC_ENABLE_EIDELIVERY\t\t1\n#define IMSIC_DISABLE_EITHRESHOLD\t1\n#define IMSIC_ENABLE_EITHRESHOLD\t0\n\n#define IMSIC_IPI_ID\t\t\t1\n\n#define imsic_csr_write(__c, __v)\t\\\ndo { \\\n\tcsr_write(CSR_MISELECT, __c); \\\n\tcsr_write(CSR_MIREG, __v); \\\n} while (0)\n\n#define imsic_csr_read(__c)\t\\\n({ \\\n\tunsigned long __v; \\\n\tcsr_write(CSR_MISELECT, __c); \\\n\t__v = csr_read(CSR_MIREG); \\\n\t__v; \\\n})\n\n#define imsic_csr_set(__c, __v)\t\t\\\ndo { \\\n\tcsr_write(CSR_MISELECT, __c); \\\n\tcsr_set(CSR_MIREG, __v); \\\n} while (0)\n\n#define imsic_csr_clear(__c, __v)\t\\\ndo { \\\n\tcsr_write(CSR_MISELECT, __c); \\\n\tcsr_clear(CSR_MIREG, __v); \\\n} while (0)\n\nstatic struct imsic_data *imsic_hartid2data[SBI_HARTMASK_MAX_BITS];\nstatic int imsic_hartid2file[SBI_HARTMASK_MAX_BITS];\n\nint imsic_map_hartid_to_data(u32 hartid, struct imsic_data *imsic, int file)\n{\n\tif (!imsic || !imsic->targets_mmode ||\n\t    (SBI_HARTMASK_MAX_BITS <= hartid))\n\t\treturn SBI_EINVAL;\n\n\timsic_hartid2data[hartid] = imsic;\n\timsic_hartid2file[hartid] = file;\n\treturn 0;\n}\n\nstruct imsic_data *imsic_get_data(u32 hartid)\n{\n\tif (SBI_HARTMASK_MAX_BITS <= hartid)\n\t\treturn NULL;\n\treturn imsic_hartid2data[hartid];\n}\n\nint imsic_get_target_file(u32 hartid)\n{\n\tif ((SBI_HARTMASK_MAX_BITS <= hartid) ||\n\t    !imsic_hartid2data[hartid])\n\t\treturn SBI_ENOENT;\n\treturn imsic_hartid2file[hartid];\n}\n\nstatic int imsic_external_irqfn(struct sbi_trap_regs *regs)\n{\n\tulong mirq;\n\n\twhile ((mirq = csr_swap(CSR_MTOPEI, 0))) {\n\t\tmirq = (mirq >> IMSIC_TOPEI_ID_SHIFT);\n\n\t\tswitch (mirq) {\n\t\tcase IMSIC_IPI_ID:\n\t\t\tsbi_ipi_process();\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tsbi_printf(\"%s: unhandled IRQ%d\\n\",\n\t\t\t\t   __func__, (u32)mirq);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nstatic void imsic_ipi_send(u32 target_hart)\n{\n\tunsigned long reloff;\n\tstruct imsic_regs *regs;\n\tstruct imsic_data *data = imsic_hartid2data[target_hart];\n\tint file = imsic_hartid2file[target_hart];\n\n\tif (!data || !data->targets_mmode)\n\t\treturn;\n\n\tregs = &data->regs[0];\n\treloff = file * (1UL << data->guest_index_bits) * IMSIC_MMIO_PAGE_SZ;\n\twhile (regs->size && (regs->size <= reloff)) {\n\t\treloff -= regs->size;\n\t\tregs++;\n\t}\n\n\tif (regs->size && (reloff < regs->size))\n\t\twritel(IMSIC_IPI_ID,\n\t\t       (void *)(regs->addr + reloff + IMSIC_MMIO_PAGE_LE));\n}\n\nstatic struct sbi_ipi_device imsic_ipi_device = {\n\t.name\t\t= \"aia-imsic\",\n\t.ipi_send\t= imsic_ipi_send\n};\n\nstatic void imsic_local_eix_update(unsigned long base_id,\n\t\t\t\t   unsigned long num_id, bool pend, bool val)\n{\n\tunsigned long i, isel, ireg;\n\tunsigned long id = base_id, last_id = base_id + num_id;\n\n\twhile (id < last_id) {\n\t\tisel = id / __riscv_xlen;\n\t\tisel *= __riscv_xlen / IMSIC_EIPx_BITS;\n\t\tisel += (pend) ? IMSIC_EIP0 : IMSIC_EIE0;\n\n\t\tireg = 0;\n\t\tfor (i = id & (__riscv_xlen - 1);\n\t\t     (id < last_id) && (i < __riscv_xlen); i++) {\n\t\t\tireg |= BIT(i);\n\t\t\tid++;\n\t\t}\n\n\t\tif (val)\n\t\t\timsic_csr_set(isel, ireg);\n\t\telse\n\t\t\timsic_csr_clear(isel, ireg);\n\t}\n}\n\nvoid imsic_local_irqchip_init(void)\n{\n\t/*\n\t * This function is expected to be called from:\n\t * 1) nascent_init() platform callback which is called\n\t *    very early on each HART in boot-up path and and\n\t *    HSM resume path.\n\t * 2) irqchip_init() platform callback which is called\n\t *    in boot-up path.\n\t */\n\n\t/* Setup threshold to allow all enabled interrupts */\n\timsic_csr_write(IMSIC_EITHRESHOLD, IMSIC_ENABLE_EITHRESHOLD);\n\n\t/* Enable interrupt delivery */\n\timsic_csr_write(IMSIC_EIDELIVERY, IMSIC_ENABLE_EIDELIVERY);\n\n\t/* Enable IPI */\n\timsic_local_eix_update(IMSIC_IPI_ID, 1, false, true);\n}\n\nint imsic_warm_irqchip_init(void)\n{\n\tstruct imsic_data *imsic = imsic_hartid2data[current_hartid()];\n\n\t/* Sanity checks */\n\tif (!imsic || !imsic->targets_mmode)\n\t\treturn SBI_EINVAL;\n\n\t/* Disable all interrupts */\n\timsic_local_eix_update(1, imsic->num_ids, false, false);\n\n\t/* Clear IPI pending */\n\timsic_local_eix_update(IMSIC_IPI_ID, 1, true, false);\n\n\t/* Local IMSIC initialization */\n\timsic_local_irqchip_init();\n\n\treturn 0;\n}\n\nint imsic_data_check(struct imsic_data *imsic)\n{\n\tu32 i, tmp;\n\tunsigned long base_addr, addr, mask;\n\n\t/* Sanity checks */\n\tif (!imsic ||\n\t    (imsic->num_ids < IMSIC_MIN_ID) ||\n\t    (IMSIC_MAX_ID < imsic->num_ids))\n\t\treturn SBI_EINVAL;\n\n\ttmp = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT;\n\tif (tmp < imsic->guest_index_bits)\n\t\treturn SBI_EINVAL;\n\n\ttmp = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT -\n\t      imsic->guest_index_bits;\n\tif (tmp < imsic->hart_index_bits)\n\t\treturn SBI_EINVAL;\n\n\ttmp = BITS_PER_LONG - IMSIC_MMIO_PAGE_SHIFT -\n\t      imsic->guest_index_bits - imsic->hart_index_bits;\n\tif (tmp < imsic->group_index_bits)\n\t\treturn SBI_EINVAL;\n\n\ttmp = IMSIC_MMIO_PAGE_SHIFT + imsic->guest_index_bits +\n\t      imsic->hart_index_bits;\n\tif (imsic->group_index_shift < tmp)\n\t\treturn SBI_EINVAL;\n\ttmp = imsic->group_index_bits + imsic->group_index_shift - 1;\n\tif (tmp >= BITS_PER_LONG)\n\t\treturn SBI_EINVAL;\n\n\t/*\n\t * Number of interrupt identities should be 1 less than\n\t * multiple of 63\n\t */\n\tif ((imsic->num_ids & IMSIC_MIN_ID) != IMSIC_MIN_ID)\n\t\treturn SBI_EINVAL;\n\n\t/* We should have at least one regset */\n\tif (!imsic->regs[0].size)\n\t\treturn SBI_EINVAL;\n\n\t/* Match patter of each regset */\n\tbase_addr = imsic->regs[0].addr;\n\tbase_addr &= ~((1UL << (imsic->guest_index_bits +\n\t\t\t\t imsic->hart_index_bits +\n\t\t\t\t IMSIC_MMIO_PAGE_SHIFT)) - 1);\n\tbase_addr &= ~(((1UL << imsic->group_index_bits) - 1) <<\n\t\t\timsic->group_index_shift);\n\tfor (i = 0; i < IMSIC_MAX_REGS && imsic->regs[i].size; i++) {\n\t\tmask = (1UL << imsic->guest_index_bits) * IMSIC_MMIO_PAGE_SZ;\n\t\tmask -= 1UL;\n\t\tif (imsic->regs[i].size & mask)\n\t\t\treturn SBI_EINVAL;\n\n\t\taddr = imsic->regs[i].addr;\n\t\taddr &= ~((1UL << (imsic->guest_index_bits +\n\t\t\t\t\t imsic->hart_index_bits +\n\t\t\t\t\t IMSIC_MMIO_PAGE_SHIFT)) - 1);\n\t\taddr &= ~(((1UL << imsic->group_index_bits) - 1) <<\n\t\t\t\timsic->group_index_shift);\n\t\tif (base_addr != addr)\n\t\t\treturn SBI_EINVAL;\n\t}\n\n\treturn 0;\n}\n\nint imsic_cold_irqchip_init(struct imsic_data *imsic)\n{\n\tint i, rc;\n\tstruct sbi_domain_memregion reg;\n\n\t/* Sanity checks */\n\trc = imsic_data_check(imsic);\n\tif (rc)\n\t\treturn rc;\n\n\t/* We only initialize M-mode IMSIC */\n\tif (!imsic->targets_mmode)\n\t\treturn SBI_EINVAL;\n\n\t/* Setup external interrupt function for IMSIC */\n\tsbi_irqchip_set_irqfn(imsic_external_irqfn);\n\n\t/* Add IMSIC regions to the root domain */\n\tfor (i = 0; i < IMSIC_MAX_REGS && imsic->regs[i].size; i++) {\n\t\tsbi_domain_memregion_init(imsic->regs[i].addr,\n\t\t\t\t\t  imsic->regs[i].size,\n\t\t\t\t\t  SBI_DOMAIN_MEMREGION_MMIO, &reg);\n\t\trc = sbi_domain_root_add_memregion(&reg);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\t/* Register IPI device */\n\tsbi_ipi_set_device(&imsic_ipi_device);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nlibsbiutils-objs-$(CONFIG_FDT_IRQCHIP) += irqchip/fdt_irqchip.o\nlibsbiutils-objs-$(CONFIG_FDT_IRQCHIP) += irqchip/fdt_irqchip_drivers.o\n\ncarray-fdt_irqchip_drivers-$(CONFIG_FDT_IRQCHIP_APLIC) += fdt_irqchip_aplic\nlibsbiutils-objs-$(CONFIG_FDT_IRQCHIP_APLIC) += irqchip/fdt_irqchip_aplic.o\n\ncarray-fdt_irqchip_drivers-$(CONFIG_FDT_IRQCHIP_IMSIC) += fdt_irqchip_imsic\nlibsbiutils-objs-$(CONFIG_FDT_IRQCHIP_IMSIC) += irqchip/fdt_irqchip_imsic.o\n\ncarray-fdt_irqchip_drivers-$(CONFIG_FDT_IRQCHIP_PLIC) += fdt_irqchip_plic\nlibsbiutils-objs-$(CONFIG_FDT_IRQCHIP_PLIC) += irqchip/fdt_irqchip_plic.o\n\nlibsbiutils-objs-$(CONFIG_IRQCHIP_APLIC) += irqchip/aplic.o\nlibsbiutils-objs-$(CONFIG_IRQCHIP_IMSIC) += irqchip/imsic.o\nlibsbiutils-objs-$(CONFIG_IRQCHIP_PLIC) += irqchip/plic.o\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/irqchip/plic.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n *   Samuel Holland <samuel@sholland.org>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_string.h>\n#include <sbi_utils/irqchip/plic.h>\n\n#define PLIC_PRIORITY_BASE 0x0\n#define PLIC_PENDING_BASE 0x1000\n#define PLIC_ENABLE_BASE 0x2000\n#define PLIC_ENABLE_STRIDE 0x80\n#define PLIC_CONTEXT_BASE 0x200000\n#define PLIC_CONTEXT_STRIDE 0x1000\n\nstatic u32 plic_get_priority(const struct plic_data *plic, u32 source)\n{\n\tvolatile void *plic_priority = (char *)plic->addr +\n\t\t\tPLIC_PRIORITY_BASE + 4 * source;\n\treturn readl(plic_priority);\n}\n\nstatic void plic_set_priority(const struct plic_data *plic, u32 source, u32 val)\n{\n\tvolatile void *plic_priority = (char *)plic->addr +\n\t\t\tPLIC_PRIORITY_BASE + 4 * source;\n\twritel(val, plic_priority);\n}\n\nvoid plic_priority_save(const struct plic_data *plic, u8 *priority, u32 num)\n{\n\tfor (u32 i = 1; i <= num; i++)\n\t\tpriority[i] = plic_get_priority(plic, i);\n}\n\nvoid plic_priority_restore(const struct plic_data *plic, const u8 *priority,\n\t\t\t   u32 num)\n{\n\tfor (u32 i = 1; i <= num; i++)\n\t\tplic_set_priority(plic, i, priority[i]);\n}\n\nstatic u32 plic_get_thresh(const struct plic_data *plic, u32 cntxid)\n{\n\tvolatile void *plic_thresh;\n\n\tplic_thresh = (char *)plic->addr +\n\t\t      PLIC_CONTEXT_BASE + PLIC_CONTEXT_STRIDE * cntxid;\n\n\treturn readl(plic_thresh);\n}\n\nstatic void plic_set_thresh(const struct plic_data *plic, u32 cntxid, u32 val)\n{\n\tvolatile void *plic_thresh;\n\n\tplic_thresh = (char *)plic->addr +\n\t\t      PLIC_CONTEXT_BASE + PLIC_CONTEXT_STRIDE * cntxid;\n\twritel(val, plic_thresh);\n}\n\nstatic u32 plic_get_ie(const struct plic_data *plic, u32 cntxid,\n\t\t       u32 word_index)\n{\n\tvolatile void *plic_ie;\n\n\tplic_ie = (char *)plic->addr +\n\t\t   PLIC_ENABLE_BASE + PLIC_ENABLE_STRIDE * cntxid +\n\t\t   4 * word_index;\n\n\treturn readl(plic_ie);\n}\n\nstatic void plic_set_ie(const struct plic_data *plic, u32 cntxid,\n\t\t\tu32 word_index, u32 val)\n{\n\tvolatile void *plic_ie;\n\n\tplic_ie = (char *)plic->addr +\n\t\t   PLIC_ENABLE_BASE + PLIC_ENABLE_STRIDE * cntxid +\n\t\t   4 * word_index;\n\twritel(val, plic_ie);\n}\n\nvoid plic_context_save(const struct plic_data *plic, int context_id,\n\t\t       u32 *enable, u32 *threshold, u32 num)\n{\n\tu32 ie_words = plic->num_src / 32 + 1;\n\n\tif (num > ie_words)\n\t\tnum = ie_words;\n\n\tfor (u32 i = 0; i < num; i++)\n\t\tenable[i] = plic_get_ie(plic, context_id, i);\n\n\t*threshold = plic_get_thresh(plic, context_id);\n}\n\nvoid plic_context_restore(const struct plic_data *plic, int context_id,\n\t\t\t  const u32 *enable, u32 threshold, u32 num)\n{\n\tu32 ie_words = plic->num_src / 32 + 1;\n\n\tif (num > ie_words)\n\t\tnum = ie_words;\n\n\tfor (u32 i = 0; i < num; i++)\n\t\tplic_set_ie(plic, context_id, i, enable[i]);\n\n\tplic_set_thresh(plic, context_id, threshold);\n}\n\nint plic_context_init(const struct plic_data *plic, int context_id,\n\t\t      bool enable, u32 threshold)\n{\n\tu32 ie_words, ie_value;\n\n\tif (!plic || context_id < 0)\n\t\treturn SBI_EINVAL;\n\n\tie_words = plic->num_src / 32 + 1;\n\tie_value = enable ? 0xffffffffU : 0U;\n\n\tfor (u32 i = 0; i < ie_words; i++)\n\t\tplic_set_ie(plic, context_id, i, ie_value);\n\n\tplic_set_thresh(plic, context_id, threshold);\n\n\treturn 0;\n}\n\nint plic_warm_irqchip_init(const struct plic_data *plic,\n\t\t\t   int m_cntx_id, int s_cntx_id)\n{\n\tint ret;\n\n\t/* By default, disable all IRQs for M-mode of target HART */\n\tif (m_cntx_id > -1) {\n\t\tret = plic_context_init(plic, m_cntx_id, false, 0x7);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\t/* By default, disable all IRQs for S-mode of target HART */\n\tif (s_cntx_id > -1) {\n\t\tret = plic_context_init(plic, s_cntx_id, false, 0x7);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\nint plic_cold_irqchip_init(const struct plic_data *plic)\n{\n\tint i;\n\n\tif (!plic)\n\t\treturn SBI_EINVAL;\n\n\t/* Configure default priorities of all IRQs */\n\tfor (i = 1; i <= plic->num_src; i++)\n\t\tplic_set_priority(plic, i, 0);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/.clang-format",
    "content": "DisableFormat: true\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nconfig LIBFDT\n\tbool\n\tdefault n\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/Makefile.libfdt",
    "content": "# SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n# Makefile.libfdt\n#\n# This is not a complete Makefile of itself.  Instead, it is designed to\n# be easily embeddable into other systems of Makefiles.\n#\nLIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1\nLIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h\nLIBFDT_VERSION = version.lds\nLIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \\\n\tfdt_addresses.c fdt_overlay.c fdt_check.c\nLIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)\nLIBFDT_LIB = libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT)\n\nlibfdt_clean:\n\t@$(VECHO) CLEAN \"(libfdt)\"\n\trm -f $(STD_CLEANFILES:%=$(LIBFDT_dir)/%)\n\trm -f $(LIBFDT_dir)/$(LIBFDT_soname)\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/TODO",
    "content": "- Tree traversal functions\n- Graft function\n- Complete libfdt.h documenting comments\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\n/*\n * Minimal sanity check for a read-only tree. fdt_ro_probe_() checks\n * that the given buffer contains what appears to be a flattened\n * device tree with sane information in its header.\n */\nint32_t fdt_ro_probe_(const void *fdt)\n{\n\tuint32_t totalsize = fdt_totalsize(fdt);\n\n\tif (can_assume(VALID_DTB))\n\t\treturn totalsize;\n\n\t/* The device tree must be at an 8-byte aligned address */\n\tif ((uintptr_t)fdt & 7)\n\t\treturn -FDT_ERR_ALIGNMENT;\n\n\tif (fdt_magic(fdt) == FDT_MAGIC) {\n\t\t/* Complete tree */\n\t\tif (!can_assume(LATEST)) {\n\t\t\tif (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)\n\t\t\t\treturn -FDT_ERR_BADVERSION;\n\t\t\tif (fdt_last_comp_version(fdt) >\n\t\t\t\t\tFDT_LAST_SUPPORTED_VERSION)\n\t\t\t\treturn -FDT_ERR_BADVERSION;\n\t\t}\n\t} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {\n\t\t/* Unfinished sequential-write blob */\n\t\tif (!can_assume(VALID_INPUT) && fdt_size_dt_struct(fdt) == 0)\n\t\t\treturn -FDT_ERR_BADSTATE;\n\t} else {\n\t\treturn -FDT_ERR_BADMAGIC;\n\t}\n\n\tif (totalsize < INT32_MAX)\n\t\treturn totalsize;\n\telse\n\t\treturn -FDT_ERR_TRUNCATED;\n}\n\nstatic int check_off_(uint32_t hdrsize, uint32_t totalsize, uint32_t off)\n{\n\treturn (off >= hdrsize) && (off <= totalsize);\n}\n\nstatic int check_block_(uint32_t hdrsize, uint32_t totalsize,\n\t\t\tuint32_t base, uint32_t size)\n{\n\tif (!check_off_(hdrsize, totalsize, base))\n\t\treturn 0; /* block start out of bounds */\n\tif ((base + size) < base)\n\t\treturn 0; /* overflow */\n\tif (!check_off_(hdrsize, totalsize, base + size))\n\t\treturn 0; /* block end out of bounds */\n\treturn 1;\n}\n\nsize_t fdt_header_size_(uint32_t version)\n{\n\tif (version <= 1)\n\t\treturn FDT_V1_SIZE;\n\telse if (version <= 2)\n\t\treturn FDT_V2_SIZE;\n\telse if (version <= 3)\n\t\treturn FDT_V3_SIZE;\n\telse if (version <= 16)\n\t\treturn FDT_V16_SIZE;\n\telse\n\t\treturn FDT_V17_SIZE;\n}\n\nsize_t fdt_header_size(const void *fdt)\n{\n\treturn can_assume(LATEST) ? FDT_V17_SIZE :\n\t\tfdt_header_size_(fdt_version(fdt));\n}\n\nint fdt_check_header(const void *fdt)\n{\n\tsize_t hdrsize;\n\n\t/* The device tree must be at an 8-byte aligned address */\n\tif ((uintptr_t)fdt & 7)\n\t\treturn -FDT_ERR_ALIGNMENT;\n\n\tif (fdt_magic(fdt) != FDT_MAGIC)\n\t\treturn -FDT_ERR_BADMAGIC;\n\tif (!can_assume(LATEST)) {\n\t\tif ((fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)\n\t\t    || (fdt_last_comp_version(fdt) >\n\t\t\tFDT_LAST_SUPPORTED_VERSION))\n\t\t\treturn -FDT_ERR_BADVERSION;\n\t\tif (fdt_version(fdt) < fdt_last_comp_version(fdt))\n\t\t\treturn -FDT_ERR_BADVERSION;\n\t}\n\thdrsize = fdt_header_size(fdt);\n\tif (!can_assume(VALID_DTB)) {\n\n\t\tif ((fdt_totalsize(fdt) < hdrsize)\n\t\t    || (fdt_totalsize(fdt) > INT_MAX))\n\t\t\treturn -FDT_ERR_TRUNCATED;\n\n\t\t/* Bounds check memrsv block */\n\t\tif (!check_off_(hdrsize, fdt_totalsize(fdt),\n\t\t\t\tfdt_off_mem_rsvmap(fdt)))\n\t\t\treturn -FDT_ERR_TRUNCATED;\n\t}\n\n\tif (!can_assume(VALID_DTB)) {\n\t\t/* Bounds check structure block */\n\t\tif (!can_assume(LATEST) && fdt_version(fdt) < 17) {\n\t\t\tif (!check_off_(hdrsize, fdt_totalsize(fdt),\n\t\t\t\t\tfdt_off_dt_struct(fdt)))\n\t\t\t\treturn -FDT_ERR_TRUNCATED;\n\t\t} else {\n\t\t\tif (!check_block_(hdrsize, fdt_totalsize(fdt),\n\t\t\t\t\t  fdt_off_dt_struct(fdt),\n\t\t\t\t\t  fdt_size_dt_struct(fdt)))\n\t\t\t\treturn -FDT_ERR_TRUNCATED;\n\t\t}\n\n\t\t/* Bounds check strings block */\n\t\tif (!check_block_(hdrsize, fdt_totalsize(fdt),\n\t\t\t\t  fdt_off_dt_strings(fdt),\n\t\t\t\t  fdt_size_dt_strings(fdt)))\n\t\t\treturn -FDT_ERR_TRUNCATED;\n\t}\n\n\treturn 0;\n}\n\nconst void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)\n{\n\tunsigned int uoffset = offset;\n\tunsigned int absoffset = offset + fdt_off_dt_struct(fdt);\n\n\tif (offset < 0)\n\t\treturn NULL;\n\n\tif (!can_assume(VALID_INPUT))\n\t\tif ((absoffset < uoffset)\n\t\t    || ((absoffset + len) < absoffset)\n\t\t    || (absoffset + len) > fdt_totalsize(fdt))\n\t\t\treturn NULL;\n\n\tif (can_assume(LATEST) || fdt_version(fdt) >= 0x11)\n\t\tif (((uoffset + len) < uoffset)\n\t\t    || ((offset + len) > fdt_size_dt_struct(fdt)))\n\t\t\treturn NULL;\n\n\treturn fdt_offset_ptr_(fdt, offset);\n}\n\nuint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)\n{\n\tconst fdt32_t *tagp, *lenp;\n\tuint32_t tag;\n\tint offset = startoffset;\n\tconst char *p;\n\n\t*nextoffset = -FDT_ERR_TRUNCATED;\n\ttagp = fdt_offset_ptr(fdt, offset, FDT_TAGSIZE);\n\tif (!can_assume(VALID_DTB) && !tagp)\n\t\treturn FDT_END; /* premature end */\n\ttag = fdt32_to_cpu(*tagp);\n\toffset += FDT_TAGSIZE;\n\n\t*nextoffset = -FDT_ERR_BADSTRUCTURE;\n\tswitch (tag) {\n\tcase FDT_BEGIN_NODE:\n\t\t/* skip name */\n\t\tdo {\n\t\t\tp = fdt_offset_ptr(fdt, offset++, 1);\n\t\t} while (p && (*p != '\\0'));\n\t\tif (!can_assume(VALID_DTB) && !p)\n\t\t\treturn FDT_END; /* premature end */\n\t\tbreak;\n\n\tcase FDT_PROP:\n\t\tlenp = fdt_offset_ptr(fdt, offset, sizeof(*lenp));\n\t\tif (!can_assume(VALID_DTB) && !lenp)\n\t\t\treturn FDT_END; /* premature end */\n\t\t/* skip-name offset, length and value */\n\t\toffset += sizeof(struct fdt_property) - FDT_TAGSIZE\n\t\t\t+ fdt32_to_cpu(*lenp);\n\t\tif (!can_assume(LATEST) &&\n\t\t    fdt_version(fdt) < 0x10 && fdt32_to_cpu(*lenp) >= 8 &&\n\t\t    ((offset - fdt32_to_cpu(*lenp)) % 8) != 0)\n\t\t\toffset += 4;\n\t\tbreak;\n\n\tcase FDT_END:\n\tcase FDT_END_NODE:\n\tcase FDT_NOP:\n\t\tbreak;\n\n\tdefault:\n\t\treturn FDT_END;\n\t}\n\n\tif (!fdt_offset_ptr(fdt, startoffset, offset - startoffset))\n\t\treturn FDT_END; /* premature end */\n\n\t*nextoffset = FDT_TAGALIGN(offset);\n\treturn tag;\n}\n\nint fdt_check_node_offset_(const void *fdt, int offset)\n{\n\tif (!can_assume(VALID_INPUT)\n\t    && ((offset < 0) || (offset % FDT_TAGSIZE)))\n\t\treturn -FDT_ERR_BADOFFSET;\n\n\tif (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE)\n\t\treturn -FDT_ERR_BADOFFSET;\n\n\treturn offset;\n}\n\nint fdt_check_prop_offset_(const void *fdt, int offset)\n{\n\tif (!can_assume(VALID_INPUT)\n\t    && ((offset < 0) || (offset % FDT_TAGSIZE)))\n\t\treturn -FDT_ERR_BADOFFSET;\n\n\tif (fdt_next_tag(fdt, offset, &offset) != FDT_PROP)\n\t\treturn -FDT_ERR_BADOFFSET;\n\n\treturn offset;\n}\n\nint fdt_next_node(const void *fdt, int offset, int *depth)\n{\n\tint nextoffset = 0;\n\tuint32_t tag;\n\n\tif (offset >= 0)\n\t\tif ((nextoffset = fdt_check_node_offset_(fdt, offset)) < 0)\n\t\t\treturn nextoffset;\n\n\tdo {\n\t\toffset = nextoffset;\n\t\ttag = fdt_next_tag(fdt, offset, &nextoffset);\n\n\t\tswitch (tag) {\n\t\tcase FDT_PROP:\n\t\tcase FDT_NOP:\n\t\t\tbreak;\n\n\t\tcase FDT_BEGIN_NODE:\n\t\t\tif (depth)\n\t\t\t\t(*depth)++;\n\t\t\tbreak;\n\n\t\tcase FDT_END_NODE:\n\t\t\tif (depth && ((--(*depth)) < 0))\n\t\t\t\treturn nextoffset;\n\t\t\tbreak;\n\n\t\tcase FDT_END:\n\t\t\tif ((nextoffset >= 0)\n\t\t\t    || ((nextoffset == -FDT_ERR_TRUNCATED) && !depth))\n\t\t\t\treturn -FDT_ERR_NOTFOUND;\n\t\t\telse\n\t\t\t\treturn nextoffset;\n\t\t}\n\t} while (tag != FDT_BEGIN_NODE);\n\n\treturn offset;\n}\n\nint fdt_first_subnode(const void *fdt, int offset)\n{\n\tint depth = 0;\n\n\toffset = fdt_next_node(fdt, offset, &depth);\n\tif (offset < 0 || depth != 1)\n\t\treturn -FDT_ERR_NOTFOUND;\n\n\treturn offset;\n}\n\nint fdt_next_subnode(const void *fdt, int offset)\n{\n\tint depth = 1;\n\n\t/*\n\t * With respect to the parent, the depth of the next subnode will be\n\t * the same as the last.\n\t */\n\tdo {\n\t\toffset = fdt_next_node(fdt, offset, &depth);\n\t\tif (offset < 0 || depth < 1)\n\t\t\treturn -FDT_ERR_NOTFOUND;\n\t} while (depth > 1);\n\n\treturn offset;\n}\n\nconst char *fdt_find_string_(const char *strtab, int tabsize, const char *s)\n{\n\tint len = strlen(s) + 1;\n\tconst char *last = strtab + tabsize - len;\n\tconst char *p;\n\n\tfor (p = strtab; p <= last; p++)\n\t\tif (memcmp(p, s, len) == 0)\n\t\t\treturn p;\n\treturn NULL;\n}\n\nint fdt_move(const void *fdt, void *buf, int bufsize)\n{\n\tif (!can_assume(VALID_INPUT) && bufsize < 0)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\tFDT_RO_PROBE(fdt);\n\n\tif (fdt_totalsize(fdt) > (unsigned int)bufsize)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\tmemmove(buf, fdt, fdt_totalsize(fdt));\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt.h",
    "content": "/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */\n#ifndef FDT_H\n#define FDT_H\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n * Copyright 2012 Kim Phillips, Freescale Semiconductor.\n */\n\n#ifndef __ASSEMBLY__\n\nstruct fdt_header {\n\tfdt32_t magic;\t\t\t /* magic word FDT_MAGIC */\n\tfdt32_t totalsize;\t\t /* total size of DT block */\n\tfdt32_t off_dt_struct;\t\t /* offset to structure */\n\tfdt32_t off_dt_strings;\t\t /* offset to strings */\n\tfdt32_t off_mem_rsvmap;\t\t /* offset to memory reserve map */\n\tfdt32_t version;\t\t /* format version */\n\tfdt32_t last_comp_version;\t /* last compatible version */\n\n\t/* version 2 fields below */\n\tfdt32_t boot_cpuid_phys;\t /* Which physical CPU id we're\n\t\t\t\t\t    booting on */\n\t/* version 3 fields below */\n\tfdt32_t size_dt_strings;\t /* size of the strings block */\n\n\t/* version 17 fields below */\n\tfdt32_t size_dt_struct;\t\t /* size of the structure block */\n};\n\nstruct fdt_reserve_entry {\n\tfdt64_t address;\n\tfdt64_t size;\n};\n\nstruct fdt_node_header {\n\tfdt32_t tag;\n\tchar name[0];\n};\n\nstruct fdt_property {\n\tfdt32_t tag;\n\tfdt32_t len;\n\tfdt32_t nameoff;\n\tchar data[0];\n};\n\n#endif /* !__ASSEMBLY */\n\n#define FDT_MAGIC\t0xd00dfeed\t/* 4: version, 4: total size */\n#define FDT_TAGSIZE\tsizeof(fdt32_t)\n\n#define FDT_BEGIN_NODE\t0x1\t\t/* Start node: full name */\n#define FDT_END_NODE\t0x2\t\t/* End node */\n#define FDT_PROP\t0x3\t\t/* Property: name off,\n\t\t\t\t\t   size, content */\n#define FDT_NOP\t\t0x4\t\t/* nop */\n#define FDT_END\t\t0x9\n\n#define FDT_V1_SIZE\t(7*sizeof(fdt32_t))\n#define FDT_V2_SIZE\t(FDT_V1_SIZE + sizeof(fdt32_t))\n#define FDT_V3_SIZE\t(FDT_V2_SIZE + sizeof(fdt32_t))\n#define FDT_V16_SIZE\tFDT_V3_SIZE\n#define FDT_V17_SIZE\t(FDT_V16_SIZE + sizeof(fdt32_t))\n\n#endif /* FDT_H */\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt_addresses.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au>\n * Copyright (C) 2018 embedded brains GmbH\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\nstatic int fdt_cells(const void *fdt, int nodeoffset, const char *name)\n{\n\tconst fdt32_t *c;\n\tuint32_t val;\n\tint len;\n\n\tc = fdt_getprop(fdt, nodeoffset, name, &len);\n\tif (!c)\n\t\treturn len;\n\n\tif (len != sizeof(*c))\n\t\treturn -FDT_ERR_BADNCELLS;\n\n\tval = fdt32_to_cpu(*c);\n\tif (val > FDT_MAX_NCELLS)\n\t\treturn -FDT_ERR_BADNCELLS;\n\n\treturn (int)val;\n}\n\nint fdt_address_cells(const void *fdt, int nodeoffset)\n{\n\tint val;\n\n\tval = fdt_cells(fdt, nodeoffset, \"#address-cells\");\n\tif (val == 0)\n\t\treturn -FDT_ERR_BADNCELLS;\n\tif (val == -FDT_ERR_NOTFOUND)\n\t\treturn 2;\n\treturn val;\n}\n\nint fdt_size_cells(const void *fdt, int nodeoffset)\n{\n\tint val;\n\n\tval = fdt_cells(fdt, nodeoffset, \"#size-cells\");\n\tif (val == -FDT_ERR_NOTFOUND)\n\t\treturn 1;\n\treturn val;\n}\n\n/* This function assumes that [address|size]_cells is 1 or 2 */\nint fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset,\n\t\t\t     const char *name, uint64_t addr, uint64_t size)\n{\n\tint addr_cells, size_cells, ret;\n\tuint8_t data[sizeof(fdt64_t) * 2], *prop;\n\n\tret = fdt_address_cells(fdt, parent);\n\tif (ret < 0)\n\t\treturn ret;\n\taddr_cells = ret;\n\n\tret = fdt_size_cells(fdt, parent);\n\tif (ret < 0)\n\t\treturn ret;\n\tsize_cells = ret;\n\n\t/* check validity of address */\n\tprop = data;\n\tif (addr_cells == 1) {\n\t\tif ((addr > UINT32_MAX) || ((UINT32_MAX + 1 - addr) < size))\n\t\t\treturn -FDT_ERR_BADVALUE;\n\n\t\tfdt32_st(prop, (uint32_t)addr);\n\t} else if (addr_cells == 2) {\n\t\tfdt64_st(prop, addr);\n\t} else {\n\t\treturn -FDT_ERR_BADNCELLS;\n\t}\n\n\t/* check validity of size */\n\tprop += addr_cells * sizeof(fdt32_t);\n\tif (size_cells == 1) {\n\t\tif (size > UINT32_MAX)\n\t\t\treturn -FDT_ERR_BADVALUE;\n\n\t\tfdt32_st(prop, (uint32_t)size);\n\t} else if (size_cells == 2) {\n\t\tfdt64_st(prop, size);\n\t} else {\n\t\treturn -FDT_ERR_BADNCELLS;\n\t}\n\n\treturn fdt_appendprop(fdt, nodeoffset, name, data,\n\t\t\t      (addr_cells + size_cells) * sizeof(fdt32_t));\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt_check.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\nint fdt_check_full(const void *fdt, size_t bufsize)\n{\n\tint err;\n\tint num_memrsv;\n\tint offset, nextoffset = 0;\n\tuint32_t tag;\n\tunsigned int depth = 0;\n\tconst void *prop;\n\tconst char *propname;\n\tbool expect_end = false;\n\n\tif (bufsize < FDT_V1_SIZE)\n\t\treturn -FDT_ERR_TRUNCATED;\n\tif (bufsize < fdt_header_size(fdt))\n\t\treturn -FDT_ERR_TRUNCATED;\n\terr = fdt_check_header(fdt);\n\tif (err != 0)\n\t\treturn err;\n\tif (bufsize < fdt_totalsize(fdt))\n\t\treturn -FDT_ERR_TRUNCATED;\n\n\tnum_memrsv = fdt_num_mem_rsv(fdt);\n\tif (num_memrsv < 0)\n\t\treturn num_memrsv;\n\n\twhile (1) {\n\t\toffset = nextoffset;\n\t\ttag = fdt_next_tag(fdt, offset, &nextoffset);\n\n\t\tif (nextoffset < 0)\n\t\t\treturn nextoffset;\n\n\t\t/* If we see two root nodes, something is wrong */\n\t\tif (expect_end && tag != FDT_END)\n\t\t\treturn -FDT_ERR_BADSTRUCTURE;\n\n\t\tswitch (tag) {\n\t\tcase FDT_NOP:\n\t\t\tbreak;\n\n\t\tcase FDT_END:\n\t\t\tif (depth != 0)\n\t\t\t\treturn -FDT_ERR_BADSTRUCTURE;\n\t\t\treturn 0;\n\n\t\tcase FDT_BEGIN_NODE:\n\t\t\tdepth++;\n\t\t\tif (depth > INT_MAX)\n\t\t\t\treturn -FDT_ERR_BADSTRUCTURE;\n\n\t\t\t/* The root node must have an empty name */\n\t\t\tif (depth == 1) {\n\t\t\t\tconst char *name;\n\t\t\t\tint len;\n\n\t\t\t\tname = fdt_get_name(fdt, offset, &len);\n\t\t\t\tif (*name || len)\n\t\t\t\t\treturn -FDT_ERR_BADSTRUCTURE;\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase FDT_END_NODE:\n\t\t\tif (depth == 0)\n\t\t\t\treturn -FDT_ERR_BADSTRUCTURE;\n\t\t\tdepth--;\n\t\t\tif (depth == 0)\n\t\t\t\texpect_end = true;\n\t\t\tbreak;\n\n\t\tcase FDT_PROP:\n\t\t\tprop = fdt_getprop_by_offset(fdt, offset, &propname,\n\t\t\t\t\t\t     &err);\n\t\t\tif (!prop)\n\t\t\t\treturn err;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\treturn -FDT_ERR_INTERNAL;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt_empty_tree.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2012 David Gibson, IBM Corporation.\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\nint fdt_create_empty_tree(void *buf, int bufsize)\n{\n\tint err;\n\n\terr = fdt_create(buf, bufsize);\n\tif (err)\n\t\treturn err;\n\n\terr = fdt_finish_reservemap(buf);\n\tif (err)\n\t\treturn err;\n\n\terr = fdt_begin_node(buf, \"\");\n\tif (err)\n\t\treturn err;\n\n\terr =  fdt_end_node(buf);\n\tif (err)\n\t\treturn err;\n\n\terr = fdt_finish(buf);\n\tif (err)\n\t\treturn err;\n\n\treturn fdt_open_into(buf, buf, bufsize);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt_overlay.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2016 Free Electrons\n * Copyright (C) 2016 NextThing Co.\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\n/**\n * overlay_get_target_phandle - retrieves the target phandle of a fragment\n * @fdto: pointer to the device tree overlay blob\n * @fragment: node offset of the fragment in the overlay\n *\n * overlay_get_target_phandle() retrieves the target phandle of an\n * overlay fragment when that fragment uses a phandle (target\n * property) instead of a path (target-path property).\n *\n * returns:\n *      the phandle pointed by the target property\n *      0, if the phandle was not found\n *\t-1, if the phandle was malformed\n */\nstatic uint32_t overlay_get_target_phandle(const void *fdto, int fragment)\n{\n\tconst fdt32_t *val;\n\tint len;\n\n\tval = fdt_getprop(fdto, fragment, \"target\", &len);\n\tif (!val)\n\t\treturn 0;\n\n\tif ((len != sizeof(*val)) || (fdt32_to_cpu(*val) == (uint32_t)-1))\n\t\treturn (uint32_t)-1;\n\n\treturn fdt32_to_cpu(*val);\n}\n\n/**\n * overlay_get_target - retrieves the offset of a fragment's target\n * @fdt: Base device tree blob\n * @fdto: Device tree overlay blob\n * @fragment: node offset of the fragment in the overlay\n * @pathp: pointer which receives the path of the target (or NULL)\n *\n * overlay_get_target() retrieves the target offset in the base\n * device tree of a fragment, no matter how the actual targeting is\n * done (through a phandle or a path)\n *\n * returns:\n *      the targeted node offset in the base device tree\n *      Negative error code on error\n */\nstatic int overlay_get_target(const void *fdt, const void *fdto,\n\t\t\t      int fragment, char const **pathp)\n{\n\tuint32_t phandle;\n\tconst char *path = NULL;\n\tint path_len = 0, ret;\n\n\t/* Try first to do a phandle based lookup */\n\tphandle = overlay_get_target_phandle(fdto, fragment);\n\tif (phandle == (uint32_t)-1)\n\t\treturn -FDT_ERR_BADPHANDLE;\n\n\t/* no phandle, try path */\n\tif (!phandle) {\n\t\t/* And then a path based lookup */\n\t\tpath = fdt_getprop(fdto, fragment, \"target-path\", &path_len);\n\t\tif (path)\n\t\t\tret = fdt_path_offset(fdt, path);\n\t\telse\n\t\t\tret = path_len;\n\t} else\n\t\tret = fdt_node_offset_by_phandle(fdt, phandle);\n\n\t/*\n\t* If we haven't found either a target or a\n\t* target-path property in a node that contains a\n\t* __overlay__ subnode (we wouldn't be called\n\t* otherwise), consider it a improperly written\n\t* overlay\n\t*/\n\tif (ret < 0 && path_len == -FDT_ERR_NOTFOUND)\n\t\tret = -FDT_ERR_BADOVERLAY;\n\n\t/* return on error */\n\tif (ret < 0)\n\t\treturn ret;\n\n\t/* return pointer to path (if available) */\n\tif (pathp)\n\t\t*pathp = path ? path : NULL;\n\n\treturn ret;\n}\n\n/**\n * overlay_phandle_add_offset - Increases a phandle by an offset\n * @fdt: Base device tree blob\n * @node: Device tree overlay blob\n * @name: Name of the property to modify (phandle or linux,phandle)\n * @delta: offset to apply\n *\n * overlay_phandle_add_offset() increments a node phandle by a given\n * offset.\n *\n * returns:\n *      0 on success.\n *      Negative error code on error\n */\nstatic int overlay_phandle_add_offset(void *fdt, int node,\n\t\t\t\t      const char *name, uint32_t delta)\n{\n\tconst fdt32_t *val;\n\tuint32_t adj_val;\n\tint len;\n\n\tval = fdt_getprop(fdt, node, name, &len);\n\tif (!val)\n\t\treturn len;\n\n\tif (len != sizeof(*val))\n\t\treturn -FDT_ERR_BADPHANDLE;\n\n\tadj_val = fdt32_to_cpu(*val);\n\tif ((adj_val + delta) < adj_val)\n\t\treturn -FDT_ERR_NOPHANDLES;\n\n\tadj_val += delta;\n\tif (adj_val == (uint32_t)-1)\n\t\treturn -FDT_ERR_NOPHANDLES;\n\n\treturn fdt_setprop_inplace_u32(fdt, node, name, adj_val);\n}\n\n/**\n * overlay_adjust_node_phandles - Offsets the phandles of a node\n * @fdto: Device tree overlay blob\n * @node: Offset of the node we want to adjust\n * @delta: Offset to shift the phandles of\n *\n * overlay_adjust_node_phandles() adds a constant to all the phandles\n * of a given node. This is mainly use as part of the overlay\n * application process, when we want to update all the overlay\n * phandles to not conflict with the overlays of the base device tree.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_adjust_node_phandles(void *fdto, int node,\n\t\t\t\t\tuint32_t delta)\n{\n\tint child;\n\tint ret;\n\n\tret = overlay_phandle_add_offset(fdto, node, \"phandle\", delta);\n\tif (ret && ret != -FDT_ERR_NOTFOUND)\n\t\treturn ret;\n\n\tret = overlay_phandle_add_offset(fdto, node, \"linux,phandle\", delta);\n\tif (ret && ret != -FDT_ERR_NOTFOUND)\n\t\treturn ret;\n\n\tfdt_for_each_subnode(child, fdto, node) {\n\t\tret = overlay_adjust_node_phandles(fdto, child, delta);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\n/**\n * overlay_adjust_local_phandles - Adjust the phandles of a whole overlay\n * @fdto: Device tree overlay blob\n * @delta: Offset to shift the phandles of\n *\n * overlay_adjust_local_phandles() adds a constant to all the\n * phandles of an overlay. This is mainly use as part of the overlay\n * application process, when we want to update all the overlay\n * phandles to not conflict with the overlays of the base device tree.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_adjust_local_phandles(void *fdto, uint32_t delta)\n{\n\t/*\n\t * Start adjusting the phandles from the overlay root\n\t */\n\treturn overlay_adjust_node_phandles(fdto, 0, delta);\n}\n\n/**\n * overlay_update_local_node_references - Adjust the overlay references\n * @fdto: Device tree overlay blob\n * @tree_node: Node offset of the node to operate on\n * @fixup_node: Node offset of the matching local fixups node\n * @delta: Offset to shift the phandles of\n *\n * overlay_update_local_nodes_references() update the phandles\n * pointing to a node within the device tree overlay by adding a\n * constant delta.\n *\n * This is mainly used as part of a device tree application process,\n * where you want the device tree overlays phandles to not conflict\n * with the ones from the base device tree before merging them.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_update_local_node_references(void *fdto,\n\t\t\t\t\t\tint tree_node,\n\t\t\t\t\t\tint fixup_node,\n\t\t\t\t\t\tuint32_t delta)\n{\n\tint fixup_prop;\n\tint fixup_child;\n\tint ret;\n\n\tfdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {\n\t\tconst fdt32_t *fixup_val;\n\t\tconst char *tree_val;\n\t\tconst char *name;\n\t\tint fixup_len;\n\t\tint tree_len;\n\t\tint i;\n\n\t\tfixup_val = fdt_getprop_by_offset(fdto, fixup_prop,\n\t\t\t\t\t\t  &name, &fixup_len);\n\t\tif (!fixup_val)\n\t\t\treturn fixup_len;\n\n\t\tif (fixup_len % sizeof(uint32_t))\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\t\tfixup_len /= sizeof(uint32_t);\n\n\t\ttree_val = fdt_getprop(fdto, tree_node, name, &tree_len);\n\t\tif (!tree_val) {\n\t\t\tif (tree_len == -FDT_ERR_NOTFOUND)\n\t\t\t\treturn -FDT_ERR_BADOVERLAY;\n\n\t\t\treturn tree_len;\n\t\t}\n\n\t\tfor (i = 0; i < fixup_len; i++) {\n\t\t\tfdt32_t adj_val;\n\t\t\tuint32_t poffset;\n\n\t\t\tpoffset = fdt32_to_cpu(fixup_val[i]);\n\n\t\t\t/*\n\t\t\t * phandles to fixup can be unaligned.\n\t\t\t *\n\t\t\t * Use a memcpy for the architectures that do\n\t\t\t * not support unaligned accesses.\n\t\t\t */\n\t\t\tmemcpy(&adj_val, tree_val + poffset, sizeof(adj_val));\n\n\t\t\tadj_val = cpu_to_fdt32(fdt32_to_cpu(adj_val) + delta);\n\n\t\t\tret = fdt_setprop_inplace_namelen_partial(fdto,\n\t\t\t\t\t\t\t\t  tree_node,\n\t\t\t\t\t\t\t\t  name,\n\t\t\t\t\t\t\t\t  strlen(name),\n\t\t\t\t\t\t\t\t  poffset,\n\t\t\t\t\t\t\t\t  &adj_val,\n\t\t\t\t\t\t\t\t  sizeof(adj_val));\n\t\t\tif (ret == -FDT_ERR_NOSPACE)\n\t\t\t\treturn -FDT_ERR_BADOVERLAY;\n\n\t\t\tif (ret)\n\t\t\t\treturn ret;\n\t\t}\n\t}\n\n\tfdt_for_each_subnode(fixup_child, fdto, fixup_node) {\n\t\tconst char *fixup_child_name = fdt_get_name(fdto, fixup_child,\n\t\t\t\t\t\t\t    NULL);\n\t\tint tree_child;\n\n\t\ttree_child = fdt_subnode_offset(fdto, tree_node,\n\t\t\t\t\t\tfixup_child_name);\n\t\tif (tree_child == -FDT_ERR_NOTFOUND)\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\t\tif (tree_child < 0)\n\t\t\treturn tree_child;\n\n\t\tret = overlay_update_local_node_references(fdto,\n\t\t\t\t\t\t\t   tree_child,\n\t\t\t\t\t\t\t   fixup_child,\n\t\t\t\t\t\t\t   delta);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\n/**\n * overlay_update_local_references - Adjust the overlay references\n * @fdto: Device tree overlay blob\n * @delta: Offset to shift the phandles of\n *\n * overlay_update_local_references() update all the phandles pointing\n * to a node within the device tree overlay by adding a constant\n * delta to not conflict with the base overlay.\n *\n * This is mainly used as part of a device tree application process,\n * where you want the device tree overlays phandles to not conflict\n * with the ones from the base device tree before merging them.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_update_local_references(void *fdto, uint32_t delta)\n{\n\tint fixups;\n\n\tfixups = fdt_path_offset(fdto, \"/__local_fixups__\");\n\tif (fixups < 0) {\n\t\t/* There's no local phandles to adjust, bail out */\n\t\tif (fixups == -FDT_ERR_NOTFOUND)\n\t\t\treturn 0;\n\n\t\treturn fixups;\n\t}\n\n\t/*\n\t * Update our local references from the root of the tree\n\t */\n\treturn overlay_update_local_node_references(fdto, 0, fixups,\n\t\t\t\t\t\t    delta);\n}\n\n/**\n * overlay_fixup_one_phandle - Set an overlay phandle to the base one\n * @fdt: Base Device Tree blob\n * @fdto: Device tree overlay blob\n * @symbols_off: Node offset of the symbols node in the base device tree\n * @path: Path to a node holding a phandle in the overlay\n * @path_len: number of path characters to consider\n * @name: Name of the property holding the phandle reference in the overlay\n * @name_len: number of name characters to consider\n * @poffset: Offset within the overlay property where the phandle is stored\n * @label: Label of the node referenced by the phandle\n *\n * overlay_fixup_one_phandle() resolves an overlay phandle pointing to\n * a node in the base device tree.\n *\n * This is part of the device tree overlay application process, when\n * you want all the phandles in the overlay to point to the actual\n * base dt nodes.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_fixup_one_phandle(void *fdt, void *fdto,\n\t\t\t\t     int symbols_off,\n\t\t\t\t     const char *path, uint32_t path_len,\n\t\t\t\t     const char *name, uint32_t name_len,\n\t\t\t\t     int poffset, const char *label)\n{\n\tconst char *symbol_path;\n\tuint32_t phandle;\n\tfdt32_t phandle_prop;\n\tint symbol_off, fixup_off;\n\tint prop_len;\n\n\tif (symbols_off < 0)\n\t\treturn symbols_off;\n\n\tsymbol_path = fdt_getprop(fdt, symbols_off, label,\n\t\t\t\t  &prop_len);\n\tif (!symbol_path)\n\t\treturn prop_len;\n\n\tsymbol_off = fdt_path_offset(fdt, symbol_path);\n\tif (symbol_off < 0)\n\t\treturn symbol_off;\n\n\tphandle = fdt_get_phandle(fdt, symbol_off);\n\tif (!phandle)\n\t\treturn -FDT_ERR_NOTFOUND;\n\n\tfixup_off = fdt_path_offset_namelen(fdto, path, path_len);\n\tif (fixup_off == -FDT_ERR_NOTFOUND)\n\t\treturn -FDT_ERR_BADOVERLAY;\n\tif (fixup_off < 0)\n\t\treturn fixup_off;\n\n\tphandle_prop = cpu_to_fdt32(phandle);\n\treturn fdt_setprop_inplace_namelen_partial(fdto, fixup_off,\n\t\t\t\t\t\t   name, name_len, poffset,\n\t\t\t\t\t\t   &phandle_prop,\n\t\t\t\t\t\t   sizeof(phandle_prop));\n};\n\n/**\n * overlay_fixup_phandle - Set an overlay phandle to the base one\n * @fdt: Base Device Tree blob\n * @fdto: Device tree overlay blob\n * @symbols_off: Node offset of the symbols node in the base device tree\n * @property: Property offset in the overlay holding the list of fixups\n *\n * overlay_fixup_phandle() resolves all the overlay phandles pointed\n * to in a __fixups__ property, and updates them to match the phandles\n * in use in the base device tree.\n *\n * This is part of the device tree overlay application process, when\n * you want all the phandles in the overlay to point to the actual\n * base dt nodes.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,\n\t\t\t\t int property)\n{\n\tconst char *value;\n\tconst char *label;\n\tint len;\n\n\tvalue = fdt_getprop_by_offset(fdto, property,\n\t\t\t\t      &label, &len);\n\tif (!value) {\n\t\tif (len == -FDT_ERR_NOTFOUND)\n\t\t\treturn -FDT_ERR_INTERNAL;\n\n\t\treturn len;\n\t}\n\n\tdo {\n\t\tconst char *path, *name, *fixup_end;\n\t\tconst char *fixup_str = value;\n\t\tuint32_t path_len, name_len;\n\t\tuint32_t fixup_len;\n\t\tchar *sep, *endptr;\n\t\tint poffset, ret;\n\n\t\tfixup_end = memchr(value, '\\0', len);\n\t\tif (!fixup_end)\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\t\tfixup_len = fixup_end - fixup_str;\n\n\t\tlen -= fixup_len + 1;\n\t\tvalue += fixup_len + 1;\n\n\t\tpath = fixup_str;\n\t\tsep = memchr(fixup_str, ':', fixup_len);\n\t\tif (!sep || *sep != ':')\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\n\t\tpath_len = sep - path;\n\t\tif (path_len == (fixup_len - 1))\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\n\t\tfixup_len -= path_len + 1;\n\t\tname = sep + 1;\n\t\tsep = memchr(name, ':', fixup_len);\n\t\tif (!sep || *sep != ':')\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\n\t\tname_len = sep - name;\n\t\tif (!name_len)\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\n\t\tpoffset = strtoul(sep + 1, &endptr, 10);\n\t\tif ((*endptr != '\\0') || (endptr <= (sep + 1)))\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\n\t\tret = overlay_fixup_one_phandle(fdt, fdto, symbols_off,\n\t\t\t\t\t\tpath, path_len, name, name_len,\n\t\t\t\t\t\tpoffset, label);\n\t\tif (ret)\n\t\t\treturn ret;\n\t} while (len > 0);\n\n\treturn 0;\n}\n\n/**\n * overlay_fixup_phandles - Resolve the overlay phandles to the base\n *                          device tree\n * @fdt: Base Device Tree blob\n * @fdto: Device tree overlay blob\n *\n * overlay_fixup_phandles() resolves all the overlay phandles pointing\n * to nodes in the base device tree.\n *\n * This is one of the steps of the device tree overlay application\n * process, when you want all the phandles in the overlay to point to\n * the actual base dt nodes.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_fixup_phandles(void *fdt, void *fdto)\n{\n\tint fixups_off, symbols_off;\n\tint property;\n\n\t/* We can have overlays without any fixups */\n\tfixups_off = fdt_path_offset(fdto, \"/__fixups__\");\n\tif (fixups_off == -FDT_ERR_NOTFOUND)\n\t\treturn 0; /* nothing to do */\n\tif (fixups_off < 0)\n\t\treturn fixups_off;\n\n\t/* And base DTs without symbols */\n\tsymbols_off = fdt_path_offset(fdt, \"/__symbols__\");\n\tif ((symbols_off < 0 && (symbols_off != -FDT_ERR_NOTFOUND)))\n\t\treturn symbols_off;\n\n\tfdt_for_each_property_offset(property, fdto, fixups_off) {\n\t\tint ret;\n\n\t\tret = overlay_fixup_phandle(fdt, fdto, symbols_off, property);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\n/**\n * overlay_apply_node - Merges a node into the base device tree\n * @fdt: Base Device Tree blob\n * @target: Node offset in the base device tree to apply the fragment to\n * @fdto: Device tree overlay blob\n * @node: Node offset in the overlay holding the changes to merge\n *\n * overlay_apply_node() merges a node into a target base device tree\n * node pointed.\n *\n * This is part of the final step in the device tree overlay\n * application process, when all the phandles have been adjusted and\n * resolved and you just have to merge overlay into the base device\n * tree.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_apply_node(void *fdt, int target,\n\t\t\t      void *fdto, int node)\n{\n\tint property;\n\tint subnode;\n\n\tfdt_for_each_property_offset(property, fdto, node) {\n\t\tconst char *name;\n\t\tconst void *prop;\n\t\tint prop_len;\n\t\tint ret;\n\n\t\tprop = fdt_getprop_by_offset(fdto, property, &name,\n\t\t\t\t\t     &prop_len);\n\t\tif (prop_len == -FDT_ERR_NOTFOUND)\n\t\t\treturn -FDT_ERR_INTERNAL;\n\t\tif (prop_len < 0)\n\t\t\treturn prop_len;\n\n\t\tret = fdt_setprop(fdt, target, name, prop, prop_len);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\tfdt_for_each_subnode(subnode, fdto, node) {\n\t\tconst char *name = fdt_get_name(fdto, subnode, NULL);\n\t\tint nnode;\n\t\tint ret;\n\n\t\tnnode = fdt_add_subnode(fdt, target, name);\n\t\tif (nnode == -FDT_ERR_EXISTS) {\n\t\t\tnnode = fdt_subnode_offset(fdt, target, name);\n\t\t\tif (nnode == -FDT_ERR_NOTFOUND)\n\t\t\t\treturn -FDT_ERR_INTERNAL;\n\t\t}\n\n\t\tif (nnode < 0)\n\t\t\treturn nnode;\n\n\t\tret = overlay_apply_node(fdt, nnode, fdto, subnode);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\n/**\n * overlay_merge - Merge an overlay into its base device tree\n * @fdt: Base Device Tree blob\n * @fdto: Device tree overlay blob\n *\n * overlay_merge() merges an overlay into its base device tree.\n *\n * This is the next to last step in the device tree overlay application\n * process, when all the phandles have been adjusted and resolved and\n * you just have to merge overlay into the base device tree.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_merge(void *fdt, void *fdto)\n{\n\tint fragment;\n\n\tfdt_for_each_subnode(fragment, fdto, 0) {\n\t\tint overlay;\n\t\tint target;\n\t\tint ret;\n\n\t\t/*\n\t\t * Each fragments will have an __overlay__ node. If\n\t\t * they don't, it's not supposed to be merged\n\t\t */\n\t\toverlay = fdt_subnode_offset(fdto, fragment, \"__overlay__\");\n\t\tif (overlay == -FDT_ERR_NOTFOUND)\n\t\t\tcontinue;\n\n\t\tif (overlay < 0)\n\t\t\treturn overlay;\n\n\t\ttarget = overlay_get_target(fdt, fdto, fragment, NULL);\n\t\tif (target < 0)\n\t\t\treturn target;\n\n\t\tret = overlay_apply_node(fdt, target, fdto, overlay);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\nstatic int get_path_len(const void *fdt, int nodeoffset)\n{\n\tint len = 0, namelen;\n\tconst char *name;\n\n\tFDT_RO_PROBE(fdt);\n\n\tfor (;;) {\n\t\tname = fdt_get_name(fdt, nodeoffset, &namelen);\n\t\tif (!name)\n\t\t\treturn namelen;\n\n\t\t/* root? we're done */\n\t\tif (namelen == 0)\n\t\t\tbreak;\n\n\t\tnodeoffset = fdt_parent_offset(fdt, nodeoffset);\n\t\tif (nodeoffset < 0)\n\t\t\treturn nodeoffset;\n\t\tlen += namelen + 1;\n\t}\n\n\t/* in case of root pretend it's \"/\" */\n\tif (len == 0)\n\t\tlen++;\n\treturn len;\n}\n\n/**\n * overlay_symbol_update - Update the symbols of base tree after a merge\n * @fdt: Base Device Tree blob\n * @fdto: Device tree overlay blob\n *\n * overlay_symbol_update() updates the symbols of the base tree with the\n * symbols of the applied overlay\n *\n * This is the last step in the device tree overlay application\n * process, allowing the reference of overlay symbols by subsequent\n * overlay operations.\n *\n * returns:\n *      0 on success\n *      Negative error code on failure\n */\nstatic int overlay_symbol_update(void *fdt, void *fdto)\n{\n\tint root_sym, ov_sym, prop, path_len, fragment, target;\n\tint len, frag_name_len, ret, rel_path_len;\n\tconst char *s, *e;\n\tconst char *path;\n\tconst char *name;\n\tconst char *frag_name;\n\tconst char *rel_path;\n\tconst char *target_path;\n\tchar *buf;\n\tvoid *p;\n\n\tov_sym = fdt_subnode_offset(fdto, 0, \"__symbols__\");\n\n\t/* if no overlay symbols exist no problem */\n\tif (ov_sym < 0)\n\t\treturn 0;\n\n\troot_sym = fdt_subnode_offset(fdt, 0, \"__symbols__\");\n\n\t/* it no root symbols exist we should create them */\n\tif (root_sym == -FDT_ERR_NOTFOUND)\n\t\troot_sym = fdt_add_subnode(fdt, 0, \"__symbols__\");\n\n\t/* any error is fatal now */\n\tif (root_sym < 0)\n\t\treturn root_sym;\n\n\t/* iterate over each overlay symbol */\n\tfdt_for_each_property_offset(prop, fdto, ov_sym) {\n\t\tpath = fdt_getprop_by_offset(fdto, prop, &name, &path_len);\n\t\tif (!path)\n\t\t\treturn path_len;\n\n\t\t/* verify it's a string property (terminated by a single \\0) */\n\t\tif (path_len < 1 || memchr(path, '\\0', path_len) != &path[path_len - 1])\n\t\t\treturn -FDT_ERR_BADVALUE;\n\n\t\t/* keep end marker to avoid strlen() */\n\t\te = path + path_len;\n\n\t\tif (*path != '/')\n\t\t\treturn -FDT_ERR_BADVALUE;\n\n\t\t/* get fragment name first */\n\t\ts = strchr(path + 1, '/');\n\t\tif (!s) {\n\t\t\t/* Symbol refers to something that won't end\n\t\t\t * up in the target tree */\n\t\t\tcontinue;\n\t\t}\n\n\t\tfrag_name = path + 1;\n\t\tfrag_name_len = s - path - 1;\n\n\t\t/* verify format; safe since \"s\" lies in \\0 terminated prop */\n\t\tlen = sizeof(\"/__overlay__/\") - 1;\n\t\tif ((e - s) > len && (memcmp(s, \"/__overlay__/\", len) == 0)) {\n\t\t\t/* /<fragment-name>/__overlay__/<relative-subnode-path> */\n\t\t\trel_path = s + len;\n\t\t\trel_path_len = e - rel_path - 1;\n\t\t} else if ((e - s) == len\n\t\t\t   && (memcmp(s, \"/__overlay__\", len - 1) == 0)) {\n\t\t\t/* /<fragment-name>/__overlay__ */\n\t\t\trel_path = \"\";\n\t\t\trel_path_len = 0;\n\t\t} else {\n\t\t\t/* Symbol refers to something that won't end\n\t\t\t * up in the target tree */\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* find the fragment index in which the symbol lies */\n\t\tret = fdt_subnode_offset_namelen(fdto, 0, frag_name,\n\t\t\t\t\t       frag_name_len);\n\t\t/* not found? */\n\t\tif (ret < 0)\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\t\tfragment = ret;\n\n\t\t/* an __overlay__ subnode must exist */\n\t\tret = fdt_subnode_offset(fdto, fragment, \"__overlay__\");\n\t\tif (ret < 0)\n\t\t\treturn -FDT_ERR_BADOVERLAY;\n\n\t\t/* get the target of the fragment */\n\t\tret = overlay_get_target(fdt, fdto, fragment, &target_path);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t\ttarget = ret;\n\n\t\t/* if we have a target path use */\n\t\tif (!target_path) {\n\t\t\tret = get_path_len(fdt, target);\n\t\t\tif (ret < 0)\n\t\t\t\treturn ret;\n\t\t\tlen = ret;\n\t\t} else {\n\t\t\tlen = strlen(target_path);\n\t\t}\n\n\t\tret = fdt_setprop_placeholder(fdt, root_sym, name,\n\t\t\t\tlen + (len > 1) + rel_path_len + 1, &p);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\n\t\tif (!target_path) {\n\t\t\t/* again in case setprop_placeholder changed it */\n\t\t\tret = overlay_get_target(fdt, fdto, fragment, &target_path);\n\t\t\tif (ret < 0)\n\t\t\t\treturn ret;\n\t\t\ttarget = ret;\n\t\t}\n\n\t\tbuf = p;\n\t\tif (len > 1) { /* target is not root */\n\t\t\tif (!target_path) {\n\t\t\t\tret = fdt_get_path(fdt, target, buf, len + 1);\n\t\t\t\tif (ret < 0)\n\t\t\t\t\treturn ret;\n\t\t\t} else\n\t\t\t\tmemcpy(buf, target_path, len + 1);\n\n\t\t} else\n\t\t\tlen--;\n\n\t\tbuf[len] = '/';\n\t\tmemcpy(buf + len + 1, rel_path, rel_path_len);\n\t\tbuf[len + 1 + rel_path_len] = '\\0';\n\t}\n\n\treturn 0;\n}\n\nint fdt_overlay_apply(void *fdt, void *fdto)\n{\n\tuint32_t delta;\n\tint ret;\n\n\tFDT_RO_PROBE(fdt);\n\tFDT_RO_PROBE(fdto);\n\n\tret = fdt_find_max_phandle(fdt, &delta);\n\tif (ret)\n\t\tgoto err;\n\n\tret = overlay_adjust_local_phandles(fdto, delta);\n\tif (ret)\n\t\tgoto err;\n\n\tret = overlay_update_local_references(fdto, delta);\n\tif (ret)\n\t\tgoto err;\n\n\tret = overlay_fixup_phandles(fdt, fdto);\n\tif (ret)\n\t\tgoto err;\n\n\tret = overlay_merge(fdt, fdto);\n\tif (ret)\n\t\tgoto err;\n\n\tret = overlay_symbol_update(fdt, fdto);\n\tif (ret)\n\t\tgoto err;\n\n\t/*\n\t * The overlay has been damaged, erase its magic.\n\t */\n\tfdt_set_magic(fdto, ~0);\n\n\treturn 0;\n\nerr:\n\t/*\n\t * The overlay might have been damaged, erase its magic.\n\t */\n\tfdt_set_magic(fdto, ~0);\n\n\t/*\n\t * The base device tree might have been damaged, erase its\n\t * magic.\n\t */\n\tfdt_set_magic(fdt, ~0);\n\n\treturn ret;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt_ro.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\nstatic int fdt_nodename_eq_(const void *fdt, int offset,\n\t\t\t    const char *s, int len)\n{\n\tint olen;\n\tconst char *p = fdt_get_name(fdt, offset, &olen);\n\n\tif (!p || olen < len)\n\t\t/* short match */\n\t\treturn 0;\n\n\tif (memcmp(p, s, len) != 0)\n\t\treturn 0;\n\n\tif (p[len] == '\\0')\n\t\treturn 1;\n\telse if (!memchr(s, '@', len) && (p[len] == '@'))\n\t\treturn 1;\n\telse\n\t\treturn 0;\n}\n\nconst char *fdt_get_string(const void *fdt, int stroffset, int *lenp)\n{\n\tint32_t totalsize;\n\tuint32_t absoffset;\n\tsize_t len;\n\tint err;\n\tconst char *s, *n;\n\n\tif (can_assume(VALID_INPUT)) {\n\t\ts = (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;\n\n\t\tif (lenp)\n\t\t\t*lenp = strlen(s);\n\t\treturn s;\n\t}\n\ttotalsize = fdt_ro_probe_(fdt);\n\terr = totalsize;\n\tif (totalsize < 0)\n\t\tgoto fail;\n\n\terr = -FDT_ERR_BADOFFSET;\n\tabsoffset = stroffset + fdt_off_dt_strings(fdt);\n\tif (absoffset >= (unsigned)totalsize)\n\t\tgoto fail;\n\tlen = totalsize - absoffset;\n\n\tif (fdt_magic(fdt) == FDT_MAGIC) {\n\t\tif (stroffset < 0)\n\t\t\tgoto fail;\n\t\tif (can_assume(LATEST) || fdt_version(fdt) >= 17) {\n\t\t\tif ((unsigned)stroffset >= fdt_size_dt_strings(fdt))\n\t\t\t\tgoto fail;\n\t\t\tif ((fdt_size_dt_strings(fdt) - stroffset) < len)\n\t\t\t\tlen = fdt_size_dt_strings(fdt) - stroffset;\n\t\t}\n\t} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {\n\t\tunsigned int sw_stroffset = -stroffset;\n\n\t\tif ((stroffset >= 0) ||\n\t\t    (sw_stroffset > fdt_size_dt_strings(fdt)))\n\t\t\tgoto fail;\n\t\tif (sw_stroffset < len)\n\t\t\tlen = sw_stroffset;\n\t} else {\n\t\terr = -FDT_ERR_INTERNAL;\n\t\tgoto fail;\n\t}\n\n\ts = (const char *)fdt + absoffset;\n\tn = memchr(s, '\\0', len);\n\tif (!n) {\n\t\t/* missing terminating NULL */\n\t\terr = -FDT_ERR_TRUNCATED;\n\t\tgoto fail;\n\t}\n\n\tif (lenp)\n\t\t*lenp = n - s;\n\treturn s;\n\nfail:\n\tif (lenp)\n\t\t*lenp = err;\n\treturn NULL;\n}\n\nconst char *fdt_string(const void *fdt, int stroffset)\n{\n\treturn fdt_get_string(fdt, stroffset, NULL);\n}\n\nstatic int fdt_string_eq_(const void *fdt, int stroffset,\n\t\t\t  const char *s, int len)\n{\n\tint slen;\n\tconst char *p = fdt_get_string(fdt, stroffset, &slen);\n\n\treturn p && (slen == len) && (memcmp(p, s, len) == 0);\n}\n\nint fdt_find_max_phandle(const void *fdt, uint32_t *phandle)\n{\n\tuint32_t max = 0;\n\tint offset = -1;\n\n\twhile (true) {\n\t\tuint32_t value;\n\n\t\toffset = fdt_next_node(fdt, offset, NULL);\n\t\tif (offset < 0) {\n\t\t\tif (offset == -FDT_ERR_NOTFOUND)\n\t\t\t\tbreak;\n\n\t\t\treturn offset;\n\t\t}\n\n\t\tvalue = fdt_get_phandle(fdt, offset);\n\n\t\tif (value > max)\n\t\t\tmax = value;\n\t}\n\n\tif (phandle)\n\t\t*phandle = max;\n\n\treturn 0;\n}\n\nint fdt_generate_phandle(const void *fdt, uint32_t *phandle)\n{\n\tuint32_t max;\n\tint err;\n\n\terr = fdt_find_max_phandle(fdt, &max);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (max == FDT_MAX_PHANDLE)\n\t\treturn -FDT_ERR_NOPHANDLES;\n\n\tif (phandle)\n\t\t*phandle = max + 1;\n\n\treturn 0;\n}\n\nstatic const struct fdt_reserve_entry *fdt_mem_rsv(const void *fdt, int n)\n{\n\tunsigned int offset = n * sizeof(struct fdt_reserve_entry);\n\tunsigned int absoffset = fdt_off_mem_rsvmap(fdt) + offset;\n\n\tif (!can_assume(VALID_INPUT)) {\n\t\tif (absoffset < fdt_off_mem_rsvmap(fdt))\n\t\t\treturn NULL;\n\t\tif (absoffset > fdt_totalsize(fdt) -\n\t\t    sizeof(struct fdt_reserve_entry))\n\t\t\treturn NULL;\n\t}\n\treturn fdt_mem_rsv_(fdt, n);\n}\n\nint fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)\n{\n\tconst struct fdt_reserve_entry *re;\n\n\tFDT_RO_PROBE(fdt);\n\tre = fdt_mem_rsv(fdt, n);\n\tif (!can_assume(VALID_INPUT) && !re)\n\t\treturn -FDT_ERR_BADOFFSET;\n\n\t*address = fdt64_ld_(&re->address);\n\t*size = fdt64_ld_(&re->size);\n\treturn 0;\n}\n\nint fdt_num_mem_rsv(const void *fdt)\n{\n\tint i;\n\tconst struct fdt_reserve_entry *re;\n\n\tfor (i = 0; (re = fdt_mem_rsv(fdt, i)) != NULL; i++) {\n\t\tif (fdt64_ld_(&re->size) == 0)\n\t\t\treturn i;\n\t}\n\treturn -FDT_ERR_TRUNCATED;\n}\n\nstatic int nextprop_(const void *fdt, int offset)\n{\n\tuint32_t tag;\n\tint nextoffset;\n\n\tdo {\n\t\ttag = fdt_next_tag(fdt, offset, &nextoffset);\n\n\t\tswitch (tag) {\n\t\tcase FDT_END:\n\t\t\tif (nextoffset >= 0)\n\t\t\t\treturn -FDT_ERR_BADSTRUCTURE;\n\t\t\telse\n\t\t\t\treturn nextoffset;\n\n\t\tcase FDT_PROP:\n\t\t\treturn offset;\n\t\t}\n\t\toffset = nextoffset;\n\t} while (tag == FDT_NOP);\n\n\treturn -FDT_ERR_NOTFOUND;\n}\n\nint fdt_subnode_offset_namelen(const void *fdt, int offset,\n\t\t\t       const char *name, int namelen)\n{\n\tint depth;\n\n\tFDT_RO_PROBE(fdt);\n\n\tfor (depth = 0;\n\t     (offset >= 0) && (depth >= 0);\n\t     offset = fdt_next_node(fdt, offset, &depth))\n\t\tif ((depth == 1)\n\t\t    && fdt_nodename_eq_(fdt, offset, name, namelen))\n\t\t\treturn offset;\n\n\tif (depth < 0)\n\t\treturn -FDT_ERR_NOTFOUND;\n\treturn offset; /* error */\n}\n\nint fdt_subnode_offset(const void *fdt, int parentoffset,\n\t\t       const char *name)\n{\n\treturn fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name));\n}\n\nint fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)\n{\n\tconst char *end = path + namelen;\n\tconst char *p = path;\n\tint offset = 0;\n\n\tFDT_RO_PROBE(fdt);\n\n\t/* see if we have an alias */\n\tif (*path != '/') {\n\t\tconst char *q = memchr(path, '/', end - p);\n\n\t\tif (!q)\n\t\t\tq = end;\n\n\t\tp = fdt_get_alias_namelen(fdt, p, q - p);\n\t\tif (!p)\n\t\t\treturn -FDT_ERR_BADPATH;\n\t\toffset = fdt_path_offset(fdt, p);\n\n\t\tp = q;\n\t}\n\n\twhile (p < end) {\n\t\tconst char *q;\n\n\t\twhile (*p == '/') {\n\t\t\tp++;\n\t\t\tif (p == end)\n\t\t\t\treturn offset;\n\t\t}\n\t\tq = memchr(p, '/', end - p);\n\t\tif (! q)\n\t\t\tq = end;\n\n\t\toffset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);\n\t\tif (offset < 0)\n\t\t\treturn offset;\n\n\t\tp = q;\n\t}\n\n\treturn offset;\n}\n\nint fdt_path_offset(const void *fdt, const char *path)\n{\n\treturn fdt_path_offset_namelen(fdt, path, strlen(path));\n}\n\nconst char *fdt_get_name(const void *fdt, int nodeoffset, int *len)\n{\n\tconst struct fdt_node_header *nh = fdt_offset_ptr_(fdt, nodeoffset);\n\tconst char *nameptr;\n\tint err;\n\n\tif (((err = fdt_ro_probe_(fdt)) < 0)\n\t    || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0))\n\t\t\tgoto fail;\n\n\tnameptr = nh->name;\n\n\tif (!can_assume(LATEST) && fdt_version(fdt) < 0x10) {\n\t\t/*\n\t\t * For old FDT versions, match the naming conventions of V16:\n\t\t * give only the leaf name (after all /). The actual tree\n\t\t * contents are loosely checked.\n\t\t */\n\t\tconst char *leaf;\n\t\tleaf = strrchr(nameptr, '/');\n\t\tif (leaf == NULL) {\n\t\t\terr = -FDT_ERR_BADSTRUCTURE;\n\t\t\tgoto fail;\n\t\t}\n\t\tnameptr = leaf+1;\n\t}\n\n\tif (len)\n\t\t*len = strlen(nameptr);\n\n\treturn nameptr;\n\n fail:\n\tif (len)\n\t\t*len = err;\n\treturn NULL;\n}\n\nint fdt_first_property_offset(const void *fdt, int nodeoffset)\n{\n\tint offset;\n\n\tif ((offset = fdt_check_node_offset_(fdt, nodeoffset)) < 0)\n\t\treturn offset;\n\n\treturn nextprop_(fdt, offset);\n}\n\nint fdt_next_property_offset(const void *fdt, int offset)\n{\n\tif ((offset = fdt_check_prop_offset_(fdt, offset)) < 0)\n\t\treturn offset;\n\n\treturn nextprop_(fdt, offset);\n}\n\nstatic const struct fdt_property *fdt_get_property_by_offset_(const void *fdt,\n\t\t\t\t\t\t              int offset,\n\t\t\t\t\t\t              int *lenp)\n{\n\tint err;\n\tconst struct fdt_property *prop;\n\n\tif (!can_assume(VALID_INPUT) &&\n\t    (err = fdt_check_prop_offset_(fdt, offset)) < 0) {\n\t\tif (lenp)\n\t\t\t*lenp = err;\n\t\treturn NULL;\n\t}\n\n\tprop = fdt_offset_ptr_(fdt, offset);\n\n\tif (lenp)\n\t\t*lenp = fdt32_ld_(&prop->len);\n\n\treturn prop;\n}\n\nconst struct fdt_property *fdt_get_property_by_offset(const void *fdt,\n\t\t\t\t\t\t      int offset,\n\t\t\t\t\t\t      int *lenp)\n{\n\t/* Prior to version 16, properties may need realignment\n\t * and this API does not work. fdt_getprop_*() will, however. */\n\n\tif (!can_assume(LATEST) && fdt_version(fdt) < 0x10) {\n\t\tif (lenp)\n\t\t\t*lenp = -FDT_ERR_BADVERSION;\n\t\treturn NULL;\n\t}\n\n\treturn fdt_get_property_by_offset_(fdt, offset, lenp);\n}\n\nstatic const struct fdt_property *fdt_get_property_namelen_(const void *fdt,\n\t\t\t\t\t\t            int offset,\n\t\t\t\t\t\t            const char *name,\n\t\t\t\t\t\t            int namelen,\n\t\t\t\t\t\t\t    int *lenp,\n\t\t\t\t\t\t\t    int *poffset)\n{\n\tfor (offset = fdt_first_property_offset(fdt, offset);\n\t     (offset >= 0);\n\t     (offset = fdt_next_property_offset(fdt, offset))) {\n\t\tconst struct fdt_property *prop;\n\n\t\tprop = fdt_get_property_by_offset_(fdt, offset, lenp);\n\t\tif (!can_assume(LIBFDT_FLAWLESS) && !prop) {\n\t\t\toffset = -FDT_ERR_INTERNAL;\n\t\t\tbreak;\n\t\t}\n\t\tif (fdt_string_eq_(fdt, fdt32_ld_(&prop->nameoff),\n\t\t\t\t   name, namelen)) {\n\t\t\tif (poffset)\n\t\t\t\t*poffset = offset;\n\t\t\treturn prop;\n\t\t}\n\t}\n\n\tif (lenp)\n\t\t*lenp = offset;\n\treturn NULL;\n}\n\n\nconst struct fdt_property *fdt_get_property_namelen(const void *fdt,\n\t\t\t\t\t\t    int offset,\n\t\t\t\t\t\t    const char *name,\n\t\t\t\t\t\t    int namelen, int *lenp)\n{\n\t/* Prior to version 16, properties may need realignment\n\t * and this API does not work. fdt_getprop_*() will, however. */\n\tif (!can_assume(LATEST) && fdt_version(fdt) < 0x10) {\n\t\tif (lenp)\n\t\t\t*lenp = -FDT_ERR_BADVERSION;\n\t\treturn NULL;\n\t}\n\n\treturn fdt_get_property_namelen_(fdt, offset, name, namelen, lenp,\n\t\t\t\t\t NULL);\n}\n\n\nconst struct fdt_property *fdt_get_property(const void *fdt,\n\t\t\t\t\t    int nodeoffset,\n\t\t\t\t\t    const char *name, int *lenp)\n{\n\treturn fdt_get_property_namelen(fdt, nodeoffset, name,\n\t\t\t\t\tstrlen(name), lenp);\n}\n\nconst void *fdt_getprop_namelen(const void *fdt, int nodeoffset,\n\t\t\t\tconst char *name, int namelen, int *lenp)\n{\n\tint poffset;\n\tconst struct fdt_property *prop;\n\n\tprop = fdt_get_property_namelen_(fdt, nodeoffset, name, namelen, lenp,\n\t\t\t\t\t &poffset);\n\tif (!prop)\n\t\treturn NULL;\n\n\t/* Handle realignment */\n\tif (!can_assume(LATEST) && fdt_version(fdt) < 0x10 &&\n\t    (poffset + sizeof(*prop)) % 8 && fdt32_ld_(&prop->len) >= 8)\n\t\treturn prop->data + 4;\n\treturn prop->data;\n}\n\nconst void *fdt_getprop_by_offset(const void *fdt, int offset,\n\t\t\t\t  const char **namep, int *lenp)\n{\n\tconst struct fdt_property *prop;\n\n\tprop = fdt_get_property_by_offset_(fdt, offset, lenp);\n\tif (!prop)\n\t\treturn NULL;\n\tif (namep) {\n\t\tconst char *name;\n\t\tint namelen;\n\n\t\tif (!can_assume(VALID_INPUT)) {\n\t\t\tname = fdt_get_string(fdt, fdt32_ld_(&prop->nameoff),\n\t\t\t\t\t      &namelen);\n\t\t\tif (!name) {\n\t\t\t\tif (lenp)\n\t\t\t\t\t*lenp = namelen;\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\t*namep = name;\n\t\t} else {\n\t\t\t*namep = fdt_string(fdt, fdt32_ld_(&prop->nameoff));\n\t\t}\n\t}\n\n\t/* Handle realignment */\n\tif (!can_assume(LATEST) && fdt_version(fdt) < 0x10 &&\n\t    (offset + sizeof(*prop)) % 8 && fdt32_ld_(&prop->len) >= 8)\n\t\treturn prop->data + 4;\n\treturn prop->data;\n}\n\nconst void *fdt_getprop(const void *fdt, int nodeoffset,\n\t\t\tconst char *name, int *lenp)\n{\n\treturn fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp);\n}\n\nuint32_t fdt_get_phandle(const void *fdt, int nodeoffset)\n{\n\tconst fdt32_t *php;\n\tint len;\n\n\t/* FIXME: This is a bit sub-optimal, since we potentially scan\n\t * over all the properties twice. */\n\tphp = fdt_getprop(fdt, nodeoffset, \"phandle\", &len);\n\tif (!php || (len != sizeof(*php))) {\n\t\tphp = fdt_getprop(fdt, nodeoffset, \"linux,phandle\", &len);\n\t\tif (!php || (len != sizeof(*php)))\n\t\t\treturn 0;\n\t}\n\n\treturn fdt32_ld_(php);\n}\n\nconst char *fdt_get_alias_namelen(const void *fdt,\n\t\t\t\t  const char *name, int namelen)\n{\n\tint aliasoffset;\n\n\taliasoffset = fdt_path_offset(fdt, \"/aliases\");\n\tif (aliasoffset < 0)\n\t\treturn NULL;\n\n\treturn fdt_getprop_namelen(fdt, aliasoffset, name, namelen, NULL);\n}\n\nconst char *fdt_get_alias(const void *fdt, const char *name)\n{\n\treturn fdt_get_alias_namelen(fdt, name, strlen(name));\n}\n\nint fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)\n{\n\tint pdepth = 0, p = 0;\n\tint offset, depth, namelen;\n\tconst char *name;\n\n\tFDT_RO_PROBE(fdt);\n\n\tif (buflen < 2)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\tfor (offset = 0, depth = 0;\n\t     (offset >= 0) && (offset <= nodeoffset);\n\t     offset = fdt_next_node(fdt, offset, &depth)) {\n\t\twhile (pdepth > depth) {\n\t\t\tdo {\n\t\t\t\tp--;\n\t\t\t} while (buf[p-1] != '/');\n\t\t\tpdepth--;\n\t\t}\n\n\t\tif (pdepth >= depth) {\n\t\t\tname = fdt_get_name(fdt, offset, &namelen);\n\t\t\tif (!name)\n\t\t\t\treturn namelen;\n\t\t\tif ((p + namelen + 1) <= buflen) {\n\t\t\t\tmemcpy(buf + p, name, namelen);\n\t\t\t\tp += namelen;\n\t\t\t\tbuf[p++] = '/';\n\t\t\t\tpdepth++;\n\t\t\t}\n\t\t}\n\n\t\tif (offset == nodeoffset) {\n\t\t\tif (pdepth < (depth + 1))\n\t\t\t\treturn -FDT_ERR_NOSPACE;\n\n\t\t\tif (p > 1) /* special case so that root path is \"/\", not \"\" */\n\t\t\t\tp--;\n\t\t\tbuf[p] = '\\0';\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tif ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0))\n\t\treturn -FDT_ERR_BADOFFSET;\n\telse if (offset == -FDT_ERR_BADOFFSET)\n\t\treturn -FDT_ERR_BADSTRUCTURE;\n\n\treturn offset; /* error from fdt_next_node() */\n}\n\nint fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,\n\t\t\t\t int supernodedepth, int *nodedepth)\n{\n\tint offset, depth;\n\tint supernodeoffset = -FDT_ERR_INTERNAL;\n\n\tFDT_RO_PROBE(fdt);\n\n\tif (supernodedepth < 0)\n\t\treturn -FDT_ERR_NOTFOUND;\n\n\tfor (offset = 0, depth = 0;\n\t     (offset >= 0) && (offset <= nodeoffset);\n\t     offset = fdt_next_node(fdt, offset, &depth)) {\n\t\tif (depth == supernodedepth)\n\t\t\tsupernodeoffset = offset;\n\n\t\tif (offset == nodeoffset) {\n\t\t\tif (nodedepth)\n\t\t\t\t*nodedepth = depth;\n\n\t\t\tif (supernodedepth > depth)\n\t\t\t\treturn -FDT_ERR_NOTFOUND;\n\t\t\telse\n\t\t\t\treturn supernodeoffset;\n\t\t}\n\t}\n\n\tif (!can_assume(VALID_INPUT)) {\n\t\tif ((offset == -FDT_ERR_NOTFOUND) || (offset >= 0))\n\t\t\treturn -FDT_ERR_BADOFFSET;\n\t\telse if (offset == -FDT_ERR_BADOFFSET)\n\t\t\treturn -FDT_ERR_BADSTRUCTURE;\n\t}\n\n\treturn offset; /* error from fdt_next_node() */\n}\n\nint fdt_node_depth(const void *fdt, int nodeoffset)\n{\n\tint nodedepth;\n\tint err;\n\n\terr = fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, &nodedepth);\n\tif (err)\n\t\treturn (can_assume(LIBFDT_FLAWLESS) || err < 0) ? err :\n\t\t\t-FDT_ERR_INTERNAL;\n\treturn nodedepth;\n}\n\nint fdt_parent_offset(const void *fdt, int nodeoffset)\n{\n\tint nodedepth = fdt_node_depth(fdt, nodeoffset);\n\n\tif (nodedepth < 0)\n\t\treturn nodedepth;\n\treturn fdt_supernode_atdepth_offset(fdt, nodeoffset,\n\t\t\t\t\t    nodedepth - 1, NULL);\n}\n\nint fdt_node_offset_by_prop_value(const void *fdt, int startoffset,\n\t\t\t\t  const char *propname,\n\t\t\t\t  const void *propval, int proplen)\n{\n\tint offset;\n\tconst void *val;\n\tint len;\n\n\tFDT_RO_PROBE(fdt);\n\n\t/* FIXME: The algorithm here is pretty horrible: we scan each\n\t * property of a node in fdt_getprop(), then if that didn't\n\t * find what we want, we scan over them again making our way\n\t * to the next node.  Still it's the easiest to implement\n\t * approach; performance can come later. */\n\tfor (offset = fdt_next_node(fdt, startoffset, NULL);\n\t     offset >= 0;\n\t     offset = fdt_next_node(fdt, offset, NULL)) {\n\t\tval = fdt_getprop(fdt, offset, propname, &len);\n\t\tif (val && (len == proplen)\n\t\t    && (memcmp(val, propval, len) == 0))\n\t\t\treturn offset;\n\t}\n\n\treturn offset; /* error from fdt_next_node() */\n}\n\nint fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)\n{\n\tint offset;\n\n\tif ((phandle == 0) || (phandle == ~0U))\n\t\treturn -FDT_ERR_BADPHANDLE;\n\n\tFDT_RO_PROBE(fdt);\n\n\t/* FIXME: The algorithm here is pretty horrible: we\n\t * potentially scan each property of a node in\n\t * fdt_get_phandle(), then if that didn't find what\n\t * we want, we scan over them again making our way to the next\n\t * node.  Still it's the easiest to implement approach;\n\t * performance can come later. */\n\tfor (offset = fdt_next_node(fdt, -1, NULL);\n\t     offset >= 0;\n\t     offset = fdt_next_node(fdt, offset, NULL)) {\n\t\tif (fdt_get_phandle(fdt, offset) == phandle)\n\t\t\treturn offset;\n\t}\n\n\treturn offset; /* error from fdt_next_node() */\n}\n\nint fdt_stringlist_contains(const char *strlist, int listlen, const char *str)\n{\n\tint len = strlen(str);\n\tconst char *p;\n\n\twhile (listlen >= len) {\n\t\tif (memcmp(str, strlist, len+1) == 0)\n\t\t\treturn 1;\n\t\tp = memchr(strlist, '\\0', listlen);\n\t\tif (!p)\n\t\t\treturn 0; /* malformed strlist.. */\n\t\tlistlen -= (p-strlist) + 1;\n\t\tstrlist = p + 1;\n\t}\n\treturn 0;\n}\n\nint fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property)\n{\n\tconst char *list, *end;\n\tint length, count = 0;\n\n\tlist = fdt_getprop(fdt, nodeoffset, property, &length);\n\tif (!list)\n\t\treturn length;\n\n\tend = list + length;\n\n\twhile (list < end) {\n\t\tlength = strnlen(list, end - list) + 1;\n\n\t\t/* Abort if the last string isn't properly NUL-terminated. */\n\t\tif (list + length > end)\n\t\t\treturn -FDT_ERR_BADVALUE;\n\n\t\tlist += length;\n\t\tcount++;\n\t}\n\n\treturn count;\n}\n\nint fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property,\n\t\t\t  const char *string)\n{\n\tint length, len, idx = 0;\n\tconst char *list, *end;\n\n\tlist = fdt_getprop(fdt, nodeoffset, property, &length);\n\tif (!list)\n\t\treturn length;\n\n\tlen = strlen(string) + 1;\n\tend = list + length;\n\n\twhile (list < end) {\n\t\tlength = strnlen(list, end - list) + 1;\n\n\t\t/* Abort if the last string isn't properly NUL-terminated. */\n\t\tif (list + length > end)\n\t\t\treturn -FDT_ERR_BADVALUE;\n\n\t\tif (length == len && memcmp(list, string, length) == 0)\n\t\t\treturn idx;\n\n\t\tlist += length;\n\t\tidx++;\n\t}\n\n\treturn -FDT_ERR_NOTFOUND;\n}\n\nconst char *fdt_stringlist_get(const void *fdt, int nodeoffset,\n\t\t\t       const char *property, int idx,\n\t\t\t       int *lenp)\n{\n\tconst char *list, *end;\n\tint length;\n\n\tlist = fdt_getprop(fdt, nodeoffset, property, &length);\n\tif (!list) {\n\t\tif (lenp)\n\t\t\t*lenp = length;\n\n\t\treturn NULL;\n\t}\n\n\tend = list + length;\n\n\twhile (list < end) {\n\t\tlength = strnlen(list, end - list) + 1;\n\n\t\t/* Abort if the last string isn't properly NUL-terminated. */\n\t\tif (list + length > end) {\n\t\t\tif (lenp)\n\t\t\t\t*lenp = -FDT_ERR_BADVALUE;\n\n\t\t\treturn NULL;\n\t\t}\n\n\t\tif (idx == 0) {\n\t\t\tif (lenp)\n\t\t\t\t*lenp = length - 1;\n\n\t\t\treturn list;\n\t\t}\n\n\t\tlist += length;\n\t\tidx--;\n\t}\n\n\tif (lenp)\n\t\t*lenp = -FDT_ERR_NOTFOUND;\n\n\treturn NULL;\n}\n\nint fdt_node_check_compatible(const void *fdt, int nodeoffset,\n\t\t\t      const char *compatible)\n{\n\tconst void *prop;\n\tint len;\n\n\tprop = fdt_getprop(fdt, nodeoffset, \"compatible\", &len);\n\tif (!prop)\n\t\treturn len;\n\n\treturn !fdt_stringlist_contains(prop, len, compatible);\n}\n\nint fdt_node_offset_by_compatible(const void *fdt, int startoffset,\n\t\t\t\t  const char *compatible)\n{\n\tint offset, err;\n\n\tFDT_RO_PROBE(fdt);\n\n\t/* FIXME: The algorithm here is pretty horrible: we scan each\n\t * property of a node in fdt_node_check_compatible(), then if\n\t * that didn't find what we want, we scan over them again\n\t * making our way to the next node.  Still it's the easiest to\n\t * implement approach; performance can come later. */\n\tfor (offset = fdt_next_node(fdt, startoffset, NULL);\n\t     offset >= 0;\n\t     offset = fdt_next_node(fdt, offset, NULL)) {\n\t\terr = fdt_node_check_compatible(fdt, offset, compatible);\n\t\tif ((err < 0) && (err != -FDT_ERR_NOTFOUND))\n\t\t\treturn err;\n\t\telse if (err == 0)\n\t\t\treturn offset;\n\t}\n\n\treturn offset; /* error from fdt_next_node() */\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt_rw.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\nstatic int fdt_blocks_misordered_(const void *fdt,\n\t\t\t\t  int mem_rsv_size, int struct_size)\n{\n\treturn (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8))\n\t\t|| (fdt_off_dt_struct(fdt) <\n\t\t    (fdt_off_mem_rsvmap(fdt) + mem_rsv_size))\n\t\t|| (fdt_off_dt_strings(fdt) <\n\t\t    (fdt_off_dt_struct(fdt) + struct_size))\n\t\t|| (fdt_totalsize(fdt) <\n\t\t    (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)));\n}\n\nstatic int fdt_rw_probe_(void *fdt)\n{\n\tif (can_assume(VALID_DTB))\n\t\treturn 0;\n\tFDT_RO_PROBE(fdt);\n\n\tif (!can_assume(LATEST) && fdt_version(fdt) < 17)\n\t\treturn -FDT_ERR_BADVERSION;\n\tif (fdt_blocks_misordered_(fdt, sizeof(struct fdt_reserve_entry),\n\t\t\t\t   fdt_size_dt_struct(fdt)))\n\t\treturn -FDT_ERR_BADLAYOUT;\n\tif (!can_assume(LATEST) && fdt_version(fdt) > 17)\n\t\tfdt_set_version(fdt, 17);\n\n\treturn 0;\n}\n\n#define FDT_RW_PROBE(fdt) \\\n\t{ \\\n\t\tint err_; \\\n\t\tif ((err_ = fdt_rw_probe_(fdt)) != 0) \\\n\t\t\treturn err_; \\\n\t}\n\nstatic inline unsigned int fdt_data_size_(void *fdt)\n{\n\treturn fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);\n}\n\nstatic int fdt_splice_(void *fdt, void *splicepoint, int oldlen, int newlen)\n{\n\tchar *p = splicepoint;\n\tunsigned int dsize = fdt_data_size_(fdt);\n\tsize_t soff = p - (char *)fdt;\n\n\tif ((oldlen < 0) || (soff + oldlen < soff) || (soff + oldlen > dsize))\n\t\treturn -FDT_ERR_BADOFFSET;\n\tif ((p < (char *)fdt) || (dsize + newlen < (unsigned)oldlen))\n\t\treturn -FDT_ERR_BADOFFSET;\n\tif (dsize - oldlen + newlen > fdt_totalsize(fdt))\n\t\treturn -FDT_ERR_NOSPACE;\n\tmemmove(p + newlen, p + oldlen, ((char *)fdt + dsize) - (p + oldlen));\n\treturn 0;\n}\n\nstatic int fdt_splice_mem_rsv_(void *fdt, struct fdt_reserve_entry *p,\n\t\t\t       int oldn, int newn)\n{\n\tint delta = (newn - oldn) * sizeof(*p);\n\tint err;\n\terr = fdt_splice_(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));\n\tif (err)\n\t\treturn err;\n\tfdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta);\n\tfdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);\n\treturn 0;\n}\n\nstatic int fdt_splice_struct_(void *fdt, void *p,\n\t\t\t      int oldlen, int newlen)\n{\n\tint delta = newlen - oldlen;\n\tint err;\n\n\tif ((err = fdt_splice_(fdt, p, oldlen, newlen)))\n\t\treturn err;\n\n\tfdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);\n\tfdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);\n\treturn 0;\n}\n\n/* Must only be used to roll back in case of error */\nstatic void fdt_del_last_string_(void *fdt, const char *s)\n{\n\tint newlen = strlen(s) + 1;\n\n\tfdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) - newlen);\n}\n\nstatic int fdt_splice_string_(void *fdt, int newlen)\n{\n\tvoid *p = (char *)fdt\n\t\t+ fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);\n\tint err;\n\n\tif ((err = fdt_splice_(fdt, p, 0, newlen)))\n\t\treturn err;\n\n\tfdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);\n\treturn 0;\n}\n\n/**\n * fdt_find_add_string_() - Find or allocate a string\n *\n * @fdt: pointer to the device tree to check/adjust\n * @s: string to find/add\n * @allocated: Set to 0 if the string was found, 1 if not found and so\n *\tallocated. Ignored if can_assume(NO_ROLLBACK)\n * @return offset of string in the string table (whether found or added)\n */\nstatic int fdt_find_add_string_(void *fdt, const char *s, int *allocated)\n{\n\tchar *strtab = (char *)fdt + fdt_off_dt_strings(fdt);\n\tconst char *p;\n\tchar *new;\n\tint len = strlen(s) + 1;\n\tint err;\n\n\tif (!can_assume(NO_ROLLBACK))\n\t\t*allocated = 0;\n\n\tp = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s);\n\tif (p)\n\t\t/* found it */\n\t\treturn (p - strtab);\n\n\tnew = strtab + fdt_size_dt_strings(fdt);\n\terr = fdt_splice_string_(fdt, len);\n\tif (err)\n\t\treturn err;\n\n\tif (!can_assume(NO_ROLLBACK))\n\t\t*allocated = 1;\n\n\tmemcpy(new, s, len);\n\treturn (new - strtab);\n}\n\nint fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)\n{\n\tstruct fdt_reserve_entry *re;\n\tint err;\n\n\tFDT_RW_PROBE(fdt);\n\n\tre = fdt_mem_rsv_w_(fdt, fdt_num_mem_rsv(fdt));\n\terr = fdt_splice_mem_rsv_(fdt, re, 0, 1);\n\tif (err)\n\t\treturn err;\n\n\tre->address = cpu_to_fdt64(address);\n\tre->size = cpu_to_fdt64(size);\n\treturn 0;\n}\n\nint fdt_del_mem_rsv(void *fdt, int n)\n{\n\tstruct fdt_reserve_entry *re = fdt_mem_rsv_w_(fdt, n);\n\n\tFDT_RW_PROBE(fdt);\n\n\tif (n >= fdt_num_mem_rsv(fdt))\n\t\treturn -FDT_ERR_NOTFOUND;\n\n\treturn fdt_splice_mem_rsv_(fdt, re, 1, 0);\n}\n\nstatic int fdt_resize_property_(void *fdt, int nodeoffset, const char *name,\n\t\t\t\tint len, struct fdt_property **prop)\n{\n\tint oldlen;\n\tint err;\n\n\t*prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);\n\tif (!*prop)\n\t\treturn oldlen;\n\n\tif ((err = fdt_splice_struct_(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),\n\t\t\t\t      FDT_TAGALIGN(len))))\n\t\treturn err;\n\n\t(*prop)->len = cpu_to_fdt32(len);\n\treturn 0;\n}\n\nstatic int fdt_add_property_(void *fdt, int nodeoffset, const char *name,\n\t\t\t     int len, struct fdt_property **prop)\n{\n\tint proplen;\n\tint nextoffset;\n\tint namestroff;\n\tint err;\n\tint allocated;\n\n\tif ((nextoffset = fdt_check_node_offset_(fdt, nodeoffset)) < 0)\n\t\treturn nextoffset;\n\n\tnamestroff = fdt_find_add_string_(fdt, name, &allocated);\n\tif (namestroff < 0)\n\t\treturn namestroff;\n\n\t*prop = fdt_offset_ptr_w_(fdt, nextoffset);\n\tproplen = sizeof(**prop) + FDT_TAGALIGN(len);\n\n\terr = fdt_splice_struct_(fdt, *prop, 0, proplen);\n\tif (err) {\n\t\t/* Delete the string if we failed to add it */\n\t\tif (!can_assume(NO_ROLLBACK) && allocated)\n\t\t\tfdt_del_last_string_(fdt, name);\n\t\treturn err;\n\t}\n\n\t(*prop)->tag = cpu_to_fdt32(FDT_PROP);\n\t(*prop)->nameoff = cpu_to_fdt32(namestroff);\n\t(*prop)->len = cpu_to_fdt32(len);\n\treturn 0;\n}\n\nint fdt_set_name(void *fdt, int nodeoffset, const char *name)\n{\n\tchar *namep;\n\tint oldlen, newlen;\n\tint err;\n\n\tFDT_RW_PROBE(fdt);\n\n\tnamep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen);\n\tif (!namep)\n\t\treturn oldlen;\n\n\tnewlen = strlen(name);\n\n\terr = fdt_splice_struct_(fdt, namep, FDT_TAGALIGN(oldlen+1),\n\t\t\t\t FDT_TAGALIGN(newlen+1));\n\tif (err)\n\t\treturn err;\n\n\tmemcpy(namep, name, newlen+1);\n\treturn 0;\n}\n\nint fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,\n\t\t\t    int len, void **prop_data)\n{\n\tstruct fdt_property *prop;\n\tint err;\n\n\tFDT_RW_PROBE(fdt);\n\n\terr = fdt_resize_property_(fdt, nodeoffset, name, len, &prop);\n\tif (err == -FDT_ERR_NOTFOUND)\n\t\terr = fdt_add_property_(fdt, nodeoffset, name, len, &prop);\n\tif (err)\n\t\treturn err;\n\n\t*prop_data = prop->data;\n\treturn 0;\n}\n\nint fdt_setprop(void *fdt, int nodeoffset, const char *name,\n\t\tconst void *val, int len)\n{\n\tvoid *prop_data;\n\tint err;\n\n\terr = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data);\n\tif (err)\n\t\treturn err;\n\n\tif (len)\n\t\tmemcpy(prop_data, val, len);\n\treturn 0;\n}\n\nint fdt_appendprop(void *fdt, int nodeoffset, const char *name,\n\t\t   const void *val, int len)\n{\n\tstruct fdt_property *prop;\n\tint err, oldlen, newlen;\n\n\tFDT_RW_PROBE(fdt);\n\n\tprop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);\n\tif (prop) {\n\t\tnewlen = len + oldlen;\n\t\terr = fdt_splice_struct_(fdt, prop->data,\n\t\t\t\t\t FDT_TAGALIGN(oldlen),\n\t\t\t\t\t FDT_TAGALIGN(newlen));\n\t\tif (err)\n\t\t\treturn err;\n\t\tprop->len = cpu_to_fdt32(newlen);\n\t\tmemcpy(prop->data + oldlen, val, len);\n\t} else {\n\t\terr = fdt_add_property_(fdt, nodeoffset, name, len, &prop);\n\t\tif (err)\n\t\t\treturn err;\n\t\tmemcpy(prop->data, val, len);\n\t}\n\treturn 0;\n}\n\nint fdt_delprop(void *fdt, int nodeoffset, const char *name)\n{\n\tstruct fdt_property *prop;\n\tint len, proplen;\n\n\tFDT_RW_PROBE(fdt);\n\n\tprop = fdt_get_property_w(fdt, nodeoffset, name, &len);\n\tif (!prop)\n\t\treturn len;\n\n\tproplen = sizeof(*prop) + FDT_TAGALIGN(len);\n\treturn fdt_splice_struct_(fdt, prop, proplen, 0);\n}\n\nint fdt_add_subnode_namelen(void *fdt, int parentoffset,\n\t\t\t    const char *name, int namelen)\n{\n\tstruct fdt_node_header *nh;\n\tint offset, nextoffset;\n\tint nodelen;\n\tint err;\n\tuint32_t tag;\n\tfdt32_t *endtag;\n\n\tFDT_RW_PROBE(fdt);\n\n\toffset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen);\n\tif (offset >= 0)\n\t\treturn -FDT_ERR_EXISTS;\n\telse if (offset != -FDT_ERR_NOTFOUND)\n\t\treturn offset;\n\n\t/* Try to place the new node after the parent's properties */\n\ttag = fdt_next_tag(fdt, parentoffset, &nextoffset);\n\t/* the fdt_subnode_offset_namelen() should ensure this never hits */\n\tif (!can_assume(LIBFDT_FLAWLESS) && (tag != FDT_BEGIN_NODE))\n\t\treturn -FDT_ERR_INTERNAL;\n\tdo {\n\t\toffset = nextoffset;\n\t\ttag = fdt_next_tag(fdt, offset, &nextoffset);\n\t} while ((tag == FDT_PROP) || (tag == FDT_NOP));\n\n\tnh = fdt_offset_ptr_w_(fdt, offset);\n\tnodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE;\n\n\terr = fdt_splice_struct_(fdt, nh, 0, nodelen);\n\tif (err)\n\t\treturn err;\n\n\tnh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);\n\tmemset(nh->name, 0, FDT_TAGALIGN(namelen+1));\n\tmemcpy(nh->name, name, namelen);\n\tendtag = (fdt32_t *)((char *)nh + nodelen - FDT_TAGSIZE);\n\t*endtag = cpu_to_fdt32(FDT_END_NODE);\n\n\treturn offset;\n}\n\nint fdt_add_subnode(void *fdt, int parentoffset, const char *name)\n{\n\treturn fdt_add_subnode_namelen(fdt, parentoffset, name, strlen(name));\n}\n\nint fdt_del_node(void *fdt, int nodeoffset)\n{\n\tint endoffset;\n\n\tFDT_RW_PROBE(fdt);\n\n\tendoffset = fdt_node_end_offset_(fdt, nodeoffset);\n\tif (endoffset < 0)\n\t\treturn endoffset;\n\n\treturn fdt_splice_struct_(fdt, fdt_offset_ptr_w_(fdt, nodeoffset),\n\t\t\t\t  endoffset - nodeoffset, 0);\n}\n\nstatic void fdt_packblocks_(const char *old, char *new,\n\t\t\t    int mem_rsv_size,\n\t\t\t    int struct_size,\n\t\t\t    int strings_size)\n{\n\tint mem_rsv_off, struct_off, strings_off;\n\n\tmem_rsv_off = FDT_ALIGN(sizeof(struct fdt_header), 8);\n\tstruct_off = mem_rsv_off + mem_rsv_size;\n\tstrings_off = struct_off + struct_size;\n\n\tmemmove(new + mem_rsv_off, old + fdt_off_mem_rsvmap(old), mem_rsv_size);\n\tfdt_set_off_mem_rsvmap(new, mem_rsv_off);\n\n\tmemmove(new + struct_off, old + fdt_off_dt_struct(old), struct_size);\n\tfdt_set_off_dt_struct(new, struct_off);\n\tfdt_set_size_dt_struct(new, struct_size);\n\n\tmemmove(new + strings_off, old + fdt_off_dt_strings(old), strings_size);\n\tfdt_set_off_dt_strings(new, strings_off);\n\tfdt_set_size_dt_strings(new, fdt_size_dt_strings(old));\n}\n\nint fdt_open_into(const void *fdt, void *buf, int bufsize)\n{\n\tint err;\n\tint mem_rsv_size, struct_size;\n\tint newsize;\n\tconst char *fdtstart = fdt;\n\tconst char *fdtend = fdtstart + fdt_totalsize(fdt);\n\tchar *tmp;\n\n\tFDT_RO_PROBE(fdt);\n\n\tmem_rsv_size = (fdt_num_mem_rsv(fdt)+1)\n\t\t* sizeof(struct fdt_reserve_entry);\n\n\tif (can_assume(LATEST) || fdt_version(fdt) >= 17) {\n\t\tstruct_size = fdt_size_dt_struct(fdt);\n\t} else if (fdt_version(fdt) == 16) {\n\t\tstruct_size = 0;\n\t\twhile (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END)\n\t\t\t;\n\t\tif (struct_size < 0)\n\t\t\treturn struct_size;\n\t} else {\n\t\treturn -FDT_ERR_BADVERSION;\n\t}\n\n\tif (can_assume(LIBFDT_ORDER) ||\n\t    !fdt_blocks_misordered_(fdt, mem_rsv_size, struct_size)) {\n\t\t/* no further work necessary */\n\t\terr = fdt_move(fdt, buf, bufsize);\n\t\tif (err)\n\t\t\treturn err;\n\t\tfdt_set_version(buf, 17);\n\t\tfdt_set_size_dt_struct(buf, struct_size);\n\t\tfdt_set_totalsize(buf, bufsize);\n\t\treturn 0;\n\t}\n\n\t/* Need to reorder */\n\tnewsize = FDT_ALIGN(sizeof(struct fdt_header), 8) + mem_rsv_size\n\t\t+ struct_size + fdt_size_dt_strings(fdt);\n\n\tif (bufsize < newsize)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\t/* First attempt to build converted tree at beginning of buffer */\n\ttmp = buf;\n\t/* But if that overlaps with the old tree... */\n\tif (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {\n\t\t/* Try right after the old tree instead */\n\t\ttmp = (char *)(uintptr_t)fdtend;\n\t\tif ((tmp + newsize) > ((char *)buf + bufsize))\n\t\t\treturn -FDT_ERR_NOSPACE;\n\t}\n\n\tfdt_packblocks_(fdt, tmp, mem_rsv_size, struct_size,\n\t\t\tfdt_size_dt_strings(fdt));\n\tmemmove(buf, tmp, newsize);\n\n\tfdt_set_magic(buf, FDT_MAGIC);\n\tfdt_set_totalsize(buf, bufsize);\n\tfdt_set_version(buf, 17);\n\tfdt_set_last_comp_version(buf, 16);\n\tfdt_set_boot_cpuid_phys(buf, fdt_boot_cpuid_phys(fdt));\n\n\treturn 0;\n}\n\nint fdt_pack(void *fdt)\n{\n\tint mem_rsv_size;\n\n\tFDT_RW_PROBE(fdt);\n\n\tmem_rsv_size = (fdt_num_mem_rsv(fdt)+1)\n\t\t* sizeof(struct fdt_reserve_entry);\n\tfdt_packblocks_(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt),\n\t\t\tfdt_size_dt_strings(fdt));\n\tfdt_set_totalsize(fdt, fdt_data_size_(fdt));\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt_strerror.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\nstruct fdt_errtabent {\n\tconst char *str;\n};\n\n#define FDT_ERRTABENT(val) \\\n\t[(val)] = { .str = #val, }\n\nstatic struct fdt_errtabent fdt_errtable[] = {\n\tFDT_ERRTABENT(FDT_ERR_NOTFOUND),\n\tFDT_ERRTABENT(FDT_ERR_EXISTS),\n\tFDT_ERRTABENT(FDT_ERR_NOSPACE),\n\n\tFDT_ERRTABENT(FDT_ERR_BADOFFSET),\n\tFDT_ERRTABENT(FDT_ERR_BADPATH),\n\tFDT_ERRTABENT(FDT_ERR_BADPHANDLE),\n\tFDT_ERRTABENT(FDT_ERR_BADSTATE),\n\n\tFDT_ERRTABENT(FDT_ERR_TRUNCATED),\n\tFDT_ERRTABENT(FDT_ERR_BADMAGIC),\n\tFDT_ERRTABENT(FDT_ERR_BADVERSION),\n\tFDT_ERRTABENT(FDT_ERR_BADSTRUCTURE),\n\tFDT_ERRTABENT(FDT_ERR_BADLAYOUT),\n\tFDT_ERRTABENT(FDT_ERR_INTERNAL),\n\tFDT_ERRTABENT(FDT_ERR_BADNCELLS),\n\tFDT_ERRTABENT(FDT_ERR_BADVALUE),\n\tFDT_ERRTABENT(FDT_ERR_BADOVERLAY),\n\tFDT_ERRTABENT(FDT_ERR_NOPHANDLES),\n\tFDT_ERRTABENT(FDT_ERR_BADFLAGS),\n};\n#define FDT_ERRTABSIZE\t((int)(sizeof(fdt_errtable) / sizeof(fdt_errtable[0])))\n\nconst char *fdt_strerror(int errval)\n{\n\tif (errval > 0)\n\t\treturn \"<valid offset/length>\";\n\telse if (errval == 0)\n\t\treturn \"<no error>\";\n\telse if (-errval < FDT_ERRTABSIZE) {\n\t\tconst char *s = fdt_errtable[-errval].str;\n\n\t\tif (s)\n\t\t\treturn s;\n\t}\n\n\treturn \"<unknown error>\";\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt_sw.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\nstatic int fdt_sw_probe_(void *fdt)\n{\n\tif (!can_assume(VALID_INPUT)) {\n\t\tif (fdt_magic(fdt) == FDT_MAGIC)\n\t\t\treturn -FDT_ERR_BADSTATE;\n\t\telse if (fdt_magic(fdt) != FDT_SW_MAGIC)\n\t\t\treturn -FDT_ERR_BADMAGIC;\n\t}\n\n\treturn 0;\n}\n\n#define FDT_SW_PROBE(fdt) \\\n\t{ \\\n\t\tint err; \\\n\t\tif ((err = fdt_sw_probe_(fdt)) != 0) \\\n\t\t\treturn err; \\\n\t}\n\n/* 'memrsv' state:\tInitial state after fdt_create()\n *\n * Allowed functions:\n *\tfdt_add_reservemap_entry()\n *\tfdt_finish_reservemap()\t\t[moves to 'struct' state]\n */\nstatic int fdt_sw_probe_memrsv_(void *fdt)\n{\n\tint err = fdt_sw_probe_(fdt);\n\tif (err)\n\t\treturn err;\n\n\tif (!can_assume(VALID_INPUT) && fdt_off_dt_strings(fdt) != 0)\n\t\treturn -FDT_ERR_BADSTATE;\n\treturn 0;\n}\n\n#define FDT_SW_PROBE_MEMRSV(fdt) \\\n\t{ \\\n\t\tint err; \\\n\t\tif ((err = fdt_sw_probe_memrsv_(fdt)) != 0) \\\n\t\t\treturn err; \\\n\t}\n\n/* 'struct' state:\tEnter this state after fdt_finish_reservemap()\n *\n * Allowed functions:\n *\tfdt_begin_node()\n *\tfdt_end_node()\n *\tfdt_property*()\n *\tfdt_finish()\t\t\t[moves to 'complete' state]\n */\nstatic int fdt_sw_probe_struct_(void *fdt)\n{\n\tint err = fdt_sw_probe_(fdt);\n\tif (err)\n\t\treturn err;\n\n\tif (!can_assume(VALID_INPUT) &&\n\t    fdt_off_dt_strings(fdt) != fdt_totalsize(fdt))\n\t\treturn -FDT_ERR_BADSTATE;\n\treturn 0;\n}\n\n#define FDT_SW_PROBE_STRUCT(fdt) \\\n\t{ \\\n\t\tint err; \\\n\t\tif ((err = fdt_sw_probe_struct_(fdt)) != 0) \\\n\t\t\treturn err; \\\n\t}\n\nstatic inline uint32_t sw_flags(void *fdt)\n{\n\t/* assert: (fdt_magic(fdt) == FDT_SW_MAGIC) */\n\treturn fdt_last_comp_version(fdt);\n}\n\n/* 'complete' state:\tEnter this state after fdt_finish()\n *\n * Allowed functions: none\n */\n\nstatic void *fdt_grab_space_(void *fdt, size_t len)\n{\n\tunsigned int offset = fdt_size_dt_struct(fdt);\n\tunsigned int spaceleft;\n\n\tspaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt)\n\t\t- fdt_size_dt_strings(fdt);\n\n\tif ((offset + len < offset) || (offset + len > spaceleft))\n\t\treturn NULL;\n\n\tfdt_set_size_dt_struct(fdt, offset + len);\n\treturn fdt_offset_ptr_w_(fdt, offset);\n}\n\nint fdt_create_with_flags(void *buf, int bufsize, uint32_t flags)\n{\n\tconst int hdrsize = FDT_ALIGN(sizeof(struct fdt_header),\n\t\t\t\t      sizeof(struct fdt_reserve_entry));\n\tvoid *fdt = buf;\n\n\tif (bufsize < hdrsize)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\tif (flags & ~FDT_CREATE_FLAGS_ALL)\n\t\treturn -FDT_ERR_BADFLAGS;\n\n\tmemset(buf, 0, bufsize);\n\n\t/*\n\t * magic and last_comp_version keep intermediate state during the fdt\n\t * creation process, which is replaced with the proper FDT format by\n\t * fdt_finish().\n\t *\n\t * flags should be accessed with sw_flags().\n\t */\n\tfdt_set_magic(fdt, FDT_SW_MAGIC);\n\tfdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION);\n\tfdt_set_last_comp_version(fdt, flags);\n\n\tfdt_set_totalsize(fdt,  bufsize);\n\n\tfdt_set_off_mem_rsvmap(fdt, hdrsize);\n\tfdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt));\n\tfdt_set_off_dt_strings(fdt, 0);\n\n\treturn 0;\n}\n\nint fdt_create(void *buf, int bufsize)\n{\n\treturn fdt_create_with_flags(buf, bufsize, 0);\n}\n\nint fdt_resize(void *fdt, void *buf, int bufsize)\n{\n\tsize_t headsize, tailsize;\n\tchar *oldtail, *newtail;\n\n\tFDT_SW_PROBE(fdt);\n\n\tif (bufsize < 0)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\theadsize = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);\n\ttailsize = fdt_size_dt_strings(fdt);\n\n\tif (!can_assume(VALID_DTB) &&\n\t    headsize + tailsize > fdt_totalsize(fdt))\n\t\treturn -FDT_ERR_INTERNAL;\n\n\tif ((headsize + tailsize) > (unsigned)bufsize)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\toldtail = (char *)fdt + fdt_totalsize(fdt) - tailsize;\n\tnewtail = (char *)buf + bufsize - tailsize;\n\n\t/* Two cases to avoid clobbering data if the old and new\n\t * buffers partially overlap */\n\tif (buf <= fdt) {\n\t\tmemmove(buf, fdt, headsize);\n\t\tmemmove(newtail, oldtail, tailsize);\n\t} else {\n\t\tmemmove(newtail, oldtail, tailsize);\n\t\tmemmove(buf, fdt, headsize);\n\t}\n\n\tfdt_set_totalsize(buf, bufsize);\n\tif (fdt_off_dt_strings(buf))\n\t\tfdt_set_off_dt_strings(buf, bufsize);\n\n\treturn 0;\n}\n\nint fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)\n{\n\tstruct fdt_reserve_entry *re;\n\tint offset;\n\n\tFDT_SW_PROBE_MEMRSV(fdt);\n\n\toffset = fdt_off_dt_struct(fdt);\n\tif ((offset + sizeof(*re)) > fdt_totalsize(fdt))\n\t\treturn -FDT_ERR_NOSPACE;\n\n\tre = (struct fdt_reserve_entry *)((char *)fdt + offset);\n\tre->address = cpu_to_fdt64(addr);\n\tre->size = cpu_to_fdt64(size);\n\n\tfdt_set_off_dt_struct(fdt, offset + sizeof(*re));\n\n\treturn 0;\n}\n\nint fdt_finish_reservemap(void *fdt)\n{\n\tint err = fdt_add_reservemap_entry(fdt, 0, 0);\n\n\tif (err)\n\t\treturn err;\n\n\tfdt_set_off_dt_strings(fdt, fdt_totalsize(fdt));\n\treturn 0;\n}\n\nint fdt_begin_node(void *fdt, const char *name)\n{\n\tstruct fdt_node_header *nh;\n\tint namelen;\n\n\tFDT_SW_PROBE_STRUCT(fdt);\n\n\tnamelen = strlen(name) + 1;\n\tnh = fdt_grab_space_(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));\n\tif (! nh)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\tnh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);\n\tmemcpy(nh->name, name, namelen);\n\treturn 0;\n}\n\nint fdt_end_node(void *fdt)\n{\n\tfdt32_t *en;\n\n\tFDT_SW_PROBE_STRUCT(fdt);\n\n\ten = fdt_grab_space_(fdt, FDT_TAGSIZE);\n\tif (! en)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\t*en = cpu_to_fdt32(FDT_END_NODE);\n\treturn 0;\n}\n\nstatic int fdt_add_string_(void *fdt, const char *s)\n{\n\tchar *strtab = (char *)fdt + fdt_totalsize(fdt);\n\tunsigned int strtabsize = fdt_size_dt_strings(fdt);\n\tunsigned int len = strlen(s) + 1;\n\tunsigned int struct_top, offset;\n\n\toffset = strtabsize + len;\n\tstruct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);\n\tif (fdt_totalsize(fdt) - offset < struct_top)\n\t\treturn 0; /* no more room :( */\n\n\tmemcpy(strtab - offset, s, len);\n\tfdt_set_size_dt_strings(fdt, strtabsize + len);\n\treturn -offset;\n}\n\n/* Must only be used to roll back in case of error */\nstatic void fdt_del_last_string_(void *fdt, const char *s)\n{\n\tint strtabsize = fdt_size_dt_strings(fdt);\n\tint len = strlen(s) + 1;\n\n\tfdt_set_size_dt_strings(fdt, strtabsize - len);\n}\n\nstatic int fdt_find_add_string_(void *fdt, const char *s, int *allocated)\n{\n\tchar *strtab = (char *)fdt + fdt_totalsize(fdt);\n\tint strtabsize = fdt_size_dt_strings(fdt);\n\tconst char *p;\n\n\t*allocated = 0;\n\n\tp = fdt_find_string_(strtab - strtabsize, strtabsize, s);\n\tif (p)\n\t\treturn p - strtab;\n\n\t*allocated = 1;\n\n\treturn fdt_add_string_(fdt, s);\n}\n\nint fdt_property_placeholder(void *fdt, const char *name, int len, void **valp)\n{\n\tstruct fdt_property *prop;\n\tint nameoff;\n\tint allocated;\n\n\tFDT_SW_PROBE_STRUCT(fdt);\n\n\t/* String de-duplication can be slow, _NO_NAME_DEDUP skips it */\n\tif (sw_flags(fdt) & FDT_CREATE_FLAG_NO_NAME_DEDUP) {\n\t\tallocated = 1;\n\t\tnameoff = fdt_add_string_(fdt, name);\n\t} else {\n\t\tnameoff = fdt_find_add_string_(fdt, name, &allocated);\n\t}\n\tif (nameoff == 0)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\tprop = fdt_grab_space_(fdt, sizeof(*prop) + FDT_TAGALIGN(len));\n\tif (! prop) {\n\t\tif (allocated)\n\t\t\tfdt_del_last_string_(fdt, name);\n\t\treturn -FDT_ERR_NOSPACE;\n\t}\n\n\tprop->tag = cpu_to_fdt32(FDT_PROP);\n\tprop->nameoff = cpu_to_fdt32(nameoff);\n\tprop->len = cpu_to_fdt32(len);\n\t*valp = prop->data;\n\treturn 0;\n}\n\nint fdt_property(void *fdt, const char *name, const void *val, int len)\n{\n\tvoid *ptr;\n\tint ret;\n\n\tret = fdt_property_placeholder(fdt, name, len, &ptr);\n\tif (ret)\n\t\treturn ret;\n\tmemcpy(ptr, val, len);\n\treturn 0;\n}\n\nint fdt_finish(void *fdt)\n{\n\tchar *p = (char *)fdt;\n\tfdt32_t *end;\n\tint oldstroffset, newstroffset;\n\tuint32_t tag;\n\tint offset, nextoffset;\n\n\tFDT_SW_PROBE_STRUCT(fdt);\n\n\t/* Add terminator */\n\tend = fdt_grab_space_(fdt, sizeof(*end));\n\tif (! end)\n\t\treturn -FDT_ERR_NOSPACE;\n\t*end = cpu_to_fdt32(FDT_END);\n\n\t/* Relocate the string table */\n\toldstroffset = fdt_totalsize(fdt) - fdt_size_dt_strings(fdt);\n\tnewstroffset = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);\n\tmemmove(p + newstroffset, p + oldstroffset, fdt_size_dt_strings(fdt));\n\tfdt_set_off_dt_strings(fdt, newstroffset);\n\n\t/* Walk the structure, correcting string offsets */\n\toffset = 0;\n\twhile ((tag = fdt_next_tag(fdt, offset, &nextoffset)) != FDT_END) {\n\t\tif (tag == FDT_PROP) {\n\t\t\tstruct fdt_property *prop =\n\t\t\t\tfdt_offset_ptr_w_(fdt, offset);\n\t\t\tint nameoff;\n\n\t\t\tnameoff = fdt32_to_cpu(prop->nameoff);\n\t\t\tnameoff += fdt_size_dt_strings(fdt);\n\t\t\tprop->nameoff = cpu_to_fdt32(nameoff);\n\t\t}\n\t\toffset = nextoffset;\n\t}\n\tif (nextoffset < 0)\n\t\treturn nextoffset;\n\n\t/* Finally, adjust the header */\n\tfdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt));\n\n\t/* And fix up fields that were keeping intermediate state. */\n\tfdt_set_last_comp_version(fdt, FDT_LAST_COMPATIBLE_VERSION);\n\tfdt_set_magic(fdt, FDT_MAGIC);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/fdt_wip.c",
    "content": "// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n */\n#include \"libfdt_env.h\"\n\n#include <fdt.h>\n#include <libfdt.h>\n\n#include \"libfdt_internal.h\"\n\nint fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,\n\t\t\t\t\tconst char *name, int namelen,\n\t\t\t\t\tuint32_t idx, const void *val,\n\t\t\t\t\tint len)\n{\n\tvoid *propval;\n\tint proplen;\n\n\tpropval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen,\n\t\t\t\t\t&proplen);\n\tif (!propval)\n\t\treturn proplen;\n\n\tif ((unsigned)proplen < (len + idx))\n\t\treturn -FDT_ERR_NOSPACE;\n\n\tmemcpy((char *)propval + idx, val, len);\n\treturn 0;\n}\n\nint fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,\n\t\t\tconst void *val, int len)\n{\n\tconst void *propval;\n\tint proplen;\n\n\tpropval = fdt_getprop(fdt, nodeoffset, name, &proplen);\n\tif (!propval)\n\t\treturn proplen;\n\n\tif (proplen != len)\n\t\treturn -FDT_ERR_NOSPACE;\n\n\treturn fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name,\n\t\t\t\t\t\t   strlen(name), 0,\n\t\t\t\t\t\t   val, len);\n}\n\nstatic void fdt_nop_region_(void *start, int len)\n{\n\tfdt32_t *p;\n\n\tfor (p = start; (char *)p < ((char *)start + len); p++)\n\t\t*p = cpu_to_fdt32(FDT_NOP);\n}\n\nint fdt_nop_property(void *fdt, int nodeoffset, const char *name)\n{\n\tstruct fdt_property *prop;\n\tint len;\n\n\tprop = fdt_get_property_w(fdt, nodeoffset, name, &len);\n\tif (!prop)\n\t\treturn len;\n\n\tfdt_nop_region_(prop, len + sizeof(*prop));\n\n\treturn 0;\n}\n\nint fdt_node_end_offset_(void *fdt, int offset)\n{\n\tint depth = 0;\n\n\twhile ((offset >= 0) && (depth >= 0))\n\t\toffset = fdt_next_node(fdt, offset, &depth);\n\n\treturn offset;\n}\n\nint fdt_nop_node(void *fdt, int nodeoffset)\n{\n\tint endoffset;\n\n\tendoffset = fdt_node_end_offset_(fdt, nodeoffset);\n\tif (endoffset < 0)\n\t\treturn endoffset;\n\n\tfdt_nop_region_(fdt_offset_ptr_w(fdt, nodeoffset, 0),\n\t\t\tendoffset - nodeoffset);\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/libfdt.h",
    "content": "/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */\n#ifndef LIBFDT_H\n#define LIBFDT_H\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n */\n\n#include <libfdt_env.h>\n#include <fdt.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define FDT_FIRST_SUPPORTED_VERSION\t0x02\n#define FDT_LAST_COMPATIBLE_VERSION 0x10\n#define FDT_LAST_SUPPORTED_VERSION\t0x11\n\n/* Error codes: informative error codes */\n#define FDT_ERR_NOTFOUND\t1\n\t/* FDT_ERR_NOTFOUND: The requested node or property does not exist */\n#define FDT_ERR_EXISTS\t\t2\n\t/* FDT_ERR_EXISTS: Attempted to create a node or property which\n\t * already exists */\n#define FDT_ERR_NOSPACE\t\t3\n\t/* FDT_ERR_NOSPACE: Operation needed to expand the device\n\t * tree, but its buffer did not have sufficient space to\n\t * contain the expanded tree. Use fdt_open_into() to move the\n\t * device tree to a buffer with more space. */\n\n/* Error codes: codes for bad parameters */\n#define FDT_ERR_BADOFFSET\t4\n\t/* FDT_ERR_BADOFFSET: Function was passed a structure block\n\t * offset which is out-of-bounds, or which points to an\n\t * unsuitable part of the structure for the operation. */\n#define FDT_ERR_BADPATH\t\t5\n\t/* FDT_ERR_BADPATH: Function was passed a badly formatted path\n\t * (e.g. missing a leading / for a function which requires an\n\t * absolute path) */\n#define FDT_ERR_BADPHANDLE\t6\n\t/* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle.\n\t * This can be caused either by an invalid phandle property\n\t * length, or the phandle value was either 0 or -1, which are\n\t * not permitted. */\n#define FDT_ERR_BADSTATE\t7\n\t/* FDT_ERR_BADSTATE: Function was passed an incomplete device\n\t * tree created by the sequential-write functions, which is\n\t * not sufficiently complete for the requested operation. */\n\n/* Error codes: codes for bad device tree blobs */\n#define FDT_ERR_TRUNCATED\t8\n\t/* FDT_ERR_TRUNCATED: FDT or a sub-block is improperly\n\t * terminated (overflows, goes outside allowed bounds, or\n\t * isn't properly terminated).  */\n#define FDT_ERR_BADMAGIC\t9\n\t/* FDT_ERR_BADMAGIC: Given \"device tree\" appears not to be a\n\t * device tree at all - it is missing the flattened device\n\t * tree magic number. */\n#define FDT_ERR_BADVERSION\t10\n\t/* FDT_ERR_BADVERSION: Given device tree has a version which\n\t * can't be handled by the requested operation.  For\n\t * read-write functions, this may mean that fdt_open_into() is\n\t * required to convert the tree to the expected version. */\n#define FDT_ERR_BADSTRUCTURE\t11\n\t/* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt\n\t * structure block or other serious error (e.g. misnested\n\t * nodes, or subnodes preceding properties). */\n#define FDT_ERR_BADLAYOUT\t12\n\t/* FDT_ERR_BADLAYOUT: For read-write functions, the given\n\t * device tree has it's sub-blocks in an order that the\n\t * function can't handle (memory reserve map, then structure,\n\t * then strings).  Use fdt_open_into() to reorganize the tree\n\t * into a form suitable for the read-write operations. */\n\n/* \"Can't happen\" error indicating a bug in libfdt */\n#define FDT_ERR_INTERNAL\t13\n\t/* FDT_ERR_INTERNAL: libfdt has failed an internal assertion.\n\t * Should never be returned, if it is, it indicates a bug in\n\t * libfdt itself. */\n\n/* Errors in device tree content */\n#define FDT_ERR_BADNCELLS\t14\n\t/* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells\n\t * or similar property with a bad format or value */\n\n#define FDT_ERR_BADVALUE\t15\n\t/* FDT_ERR_BADVALUE: Device tree has a property with an unexpected\n\t * value. For example: a property expected to contain a string list\n\t * is not NUL-terminated within the length of its value. */\n\n#define FDT_ERR_BADOVERLAY\t16\n\t/* FDT_ERR_BADOVERLAY: The device tree overlay, while\n\t * correctly structured, cannot be applied due to some\n\t * unexpected or missing value, property or node. */\n\n#define FDT_ERR_NOPHANDLES\t17\n\t/* FDT_ERR_NOPHANDLES: The device tree doesn't have any\n\t * phandle available anymore without causing an overflow */\n\n#define FDT_ERR_BADFLAGS\t18\n\t/* FDT_ERR_BADFLAGS: The function was passed a flags field that\n\t * contains invalid flags or an invalid combination of flags. */\n\n#define FDT_ERR_ALIGNMENT\t19\n\t/* FDT_ERR_ALIGNMENT: The device tree base address is not 8-byte\n\t * aligned. */\n\n#define FDT_ERR_MAX\t\t19\n\n/* constants */\n#define FDT_MAX_PHANDLE 0xfffffffe\n\t/* Valid values for phandles range from 1 to 2^32-2. */\n\n/**********************************************************************/\n/* Low-level functions (you probably don't need these)                */\n/**********************************************************************/\n\n#ifndef SWIG /* This function is not useful in Python */\nconst void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);\n#endif\nstatic inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)\n{\n\treturn (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);\n}\n\nuint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);\n\n/*\n * External helpers to access words from a device tree blob. They're built\n * to work even with unaligned pointers on platforms (such as ARMv5) that don't\n * like unaligned loads and stores.\n */\nstatic inline uint32_t fdt32_ld(const fdt32_t *p)\n{\n\tconst uint8_t *bp = (const uint8_t *)p;\n\n\treturn ((uint32_t)bp[0] << 24)\n\t\t| ((uint32_t)bp[1] << 16)\n\t\t| ((uint32_t)bp[2] << 8)\n\t\t| bp[3];\n}\n\nstatic inline void fdt32_st(void *property, uint32_t value)\n{\n\tuint8_t *bp = (uint8_t *)property;\n\n\tbp[0] = value >> 24;\n\tbp[1] = (value >> 16) & 0xff;\n\tbp[2] = (value >> 8) & 0xff;\n\tbp[3] = value & 0xff;\n}\n\nstatic inline uint64_t fdt64_ld(const fdt64_t *p)\n{\n\tconst uint8_t *bp = (const uint8_t *)p;\n\n\treturn ((uint64_t)bp[0] << 56)\n\t\t| ((uint64_t)bp[1] << 48)\n\t\t| ((uint64_t)bp[2] << 40)\n\t\t| ((uint64_t)bp[3] << 32)\n\t\t| ((uint64_t)bp[4] << 24)\n\t\t| ((uint64_t)bp[5] << 16)\n\t\t| ((uint64_t)bp[6] << 8)\n\t\t| bp[7];\n}\n\nstatic inline void fdt64_st(void *property, uint64_t value)\n{\n\tuint8_t *bp = (uint8_t *)property;\n\n\tbp[0] = value >> 56;\n\tbp[1] = (value >> 48) & 0xff;\n\tbp[2] = (value >> 40) & 0xff;\n\tbp[3] = (value >> 32) & 0xff;\n\tbp[4] = (value >> 24) & 0xff;\n\tbp[5] = (value >> 16) & 0xff;\n\tbp[6] = (value >> 8) & 0xff;\n\tbp[7] = value & 0xff;\n}\n\n/**********************************************************************/\n/* Traversal functions                                                */\n/**********************************************************************/\n\nint fdt_next_node(const void *fdt, int offset, int *depth);\n\n/**\n * fdt_first_subnode() - get offset of first direct subnode\n * @fdt:\tFDT blob\n * @offset:\tOffset of node to check\n *\n * Return: offset of first subnode, or -FDT_ERR_NOTFOUND if there is none\n */\nint fdt_first_subnode(const void *fdt, int offset);\n\n/**\n * fdt_next_subnode() - get offset of next direct subnode\n * @fdt:\tFDT blob\n * @offset:\tOffset of previous subnode\n *\n * After first calling fdt_first_subnode(), call this function repeatedly to\n * get direct subnodes of a parent node.\n *\n * Return: offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more\n *         subnodes\n */\nint fdt_next_subnode(const void *fdt, int offset);\n\n/**\n * fdt_for_each_subnode - iterate over all subnodes of a parent\n *\n * @node:\tchild node (int, lvalue)\n * @fdt:\tFDT blob (const void *)\n * @parent:\tparent node (int)\n *\n * This is actually a wrapper around a for loop and would be used like so:\n *\n *\tfdt_for_each_subnode(node, fdt, parent) {\n *\t\tUse node\n *\t\t...\n *\t}\n *\n *\tif ((node < 0) && (node != -FDT_ERR_NOTFOUND)) {\n *\t\tError handling\n *\t}\n *\n * Note that this is implemented as a macro and @node is used as\n * iterator in the loop. The parent variable be constant or even a\n * literal.\n */\n#define fdt_for_each_subnode(node, fdt, parent)\t\t\\\n\tfor (node = fdt_first_subnode(fdt, parent);\t\\\n\t     node >= 0;\t\t\t\t\t\\\n\t     node = fdt_next_subnode(fdt, node))\n\n/**********************************************************************/\n/* General functions                                                  */\n/**********************************************************************/\n#define fdt_get_header(fdt, field) \\\n\t(fdt32_ld(&((const struct fdt_header *)(fdt))->field))\n#define fdt_magic(fdt)\t\t\t(fdt_get_header(fdt, magic))\n#define fdt_totalsize(fdt)\t\t(fdt_get_header(fdt, totalsize))\n#define fdt_off_dt_struct(fdt)\t\t(fdt_get_header(fdt, off_dt_struct))\n#define fdt_off_dt_strings(fdt)\t\t(fdt_get_header(fdt, off_dt_strings))\n#define fdt_off_mem_rsvmap(fdt)\t\t(fdt_get_header(fdt, off_mem_rsvmap))\n#define fdt_version(fdt)\t\t(fdt_get_header(fdt, version))\n#define fdt_last_comp_version(fdt)\t(fdt_get_header(fdt, last_comp_version))\n#define fdt_boot_cpuid_phys(fdt)\t(fdt_get_header(fdt, boot_cpuid_phys))\n#define fdt_size_dt_strings(fdt)\t(fdt_get_header(fdt, size_dt_strings))\n#define fdt_size_dt_struct(fdt)\t\t(fdt_get_header(fdt, size_dt_struct))\n\n#define fdt_set_hdr_(name) \\\n\tstatic inline void fdt_set_##name(void *fdt, uint32_t val) \\\n\t{ \\\n\t\tstruct fdt_header *fdth = (struct fdt_header *)fdt; \\\n\t\tfdth->name = cpu_to_fdt32(val); \\\n\t}\nfdt_set_hdr_(magic);\nfdt_set_hdr_(totalsize);\nfdt_set_hdr_(off_dt_struct);\nfdt_set_hdr_(off_dt_strings);\nfdt_set_hdr_(off_mem_rsvmap);\nfdt_set_hdr_(version);\nfdt_set_hdr_(last_comp_version);\nfdt_set_hdr_(boot_cpuid_phys);\nfdt_set_hdr_(size_dt_strings);\nfdt_set_hdr_(size_dt_struct);\n#undef fdt_set_hdr_\n\n/**\n * fdt_header_size - return the size of the tree's header\n * @fdt: pointer to a flattened device tree\n *\n * Return: size of DTB header in bytes\n */\nsize_t fdt_header_size(const void *fdt);\n\n/**\n * fdt_header_size_ - internal function to get header size from a version number\n * @version: devicetree version number\n *\n * Return: size of DTB header in bytes\n */\nsize_t fdt_header_size_(uint32_t version);\n\n/**\n * fdt_check_header - sanity check a device tree header\n * @fdt: pointer to data which might be a flattened device tree\n *\n * fdt_check_header() checks that the given buffer contains what\n * appears to be a flattened device tree, and that the header contains\n * valid information (to the extent that can be determined from the\n * header alone).\n *\n * returns:\n *     0, if the buffer appears to contain a valid device tree\n *     -FDT_ERR_BADMAGIC,\n *     -FDT_ERR_BADVERSION,\n *     -FDT_ERR_BADSTATE,\n *     -FDT_ERR_TRUNCATED, standard meanings, as above\n */\nint fdt_check_header(const void *fdt);\n\n/**\n * fdt_move - move a device tree around in memory\n * @fdt: pointer to the device tree to move\n * @buf: pointer to memory where the device is to be moved\n * @bufsize: size of the memory space at buf\n *\n * fdt_move() relocates, if possible, the device tree blob located at\n * fdt to the buffer at buf of size bufsize.  The buffer may overlap\n * with the existing device tree blob at fdt.  Therefore,\n *     fdt_move(fdt, fdt, fdt_totalsize(fdt))\n * should always succeed.\n *\n * returns:\n *     0, on success\n *     -FDT_ERR_NOSPACE, bufsize is insufficient to contain the device tree\n *     -FDT_ERR_BADMAGIC,\n *     -FDT_ERR_BADVERSION,\n *     -FDT_ERR_BADSTATE, standard meanings\n */\nint fdt_move(const void *fdt, void *buf, int bufsize);\n\n/**********************************************************************/\n/* Read-only functions                                                */\n/**********************************************************************/\n\nint fdt_check_full(const void *fdt, size_t bufsize);\n\n/**\n * fdt_get_string - retrieve a string from the strings block of a device tree\n * @fdt: pointer to the device tree blob\n * @stroffset: offset of the string within the strings block (native endian)\n * @lenp: optional pointer to return the string's length\n *\n * fdt_get_string() retrieves a pointer to a single string from the\n * strings block of the device tree blob at fdt, and optionally also\n * returns the string's length in *lenp.\n *\n * returns:\n *     a pointer to the string, on success\n *     NULL, if stroffset is out of bounds, or doesn't point to a valid string\n */\nconst char *fdt_get_string(const void *fdt, int stroffset, int *lenp);\n\n/**\n * fdt_string - retrieve a string from the strings block of a device tree\n * @fdt: pointer to the device tree blob\n * @stroffset: offset of the string within the strings block (native endian)\n *\n * fdt_string() retrieves a pointer to a single string from the\n * strings block of the device tree blob at fdt.\n *\n * returns:\n *     a pointer to the string, on success\n *     NULL, if stroffset is out of bounds, or doesn't point to a valid string\n */\nconst char *fdt_string(const void *fdt, int stroffset);\n\n/**\n * fdt_find_max_phandle - find and return the highest phandle in a tree\n * @fdt: pointer to the device tree blob\n * @phandle: return location for the highest phandle value found in the tree\n *\n * fdt_find_max_phandle() finds the highest phandle value in the given device\n * tree. The value returned in @phandle is only valid if the function returns\n * success.\n *\n * returns:\n *     0 on success or a negative error code on failure\n */\nint fdt_find_max_phandle(const void *fdt, uint32_t *phandle);\n\n/**\n * fdt_get_max_phandle - retrieves the highest phandle in a tree\n * @fdt: pointer to the device tree blob\n *\n * fdt_get_max_phandle retrieves the highest phandle in the given\n * device tree. This will ignore badly formatted phandles, or phandles\n * with a value of 0 or -1.\n *\n * This function is deprecated in favour of fdt_find_max_phandle().\n *\n * returns:\n *      the highest phandle on success\n *      0, if no phandle was found in the device tree\n *      -1, if an error occurred\n */\nstatic inline uint32_t fdt_get_max_phandle(const void *fdt)\n{\n\tuint32_t phandle;\n\tint err;\n\n\terr = fdt_find_max_phandle(fdt, &phandle);\n\tif (err < 0)\n\t\treturn (uint32_t)-1;\n\n\treturn phandle;\n}\n\n/**\n * fdt_generate_phandle - return a new, unused phandle for a device tree blob\n * @fdt: pointer to the device tree blob\n * @phandle: return location for the new phandle\n *\n * Walks the device tree blob and looks for the highest phandle value. On\n * success, the new, unused phandle value (one higher than the previously\n * highest phandle value in the device tree blob) will be returned in the\n * @phandle parameter.\n *\n * Return: 0 on success or a negative error-code on failure\n */\nint fdt_generate_phandle(const void *fdt, uint32_t *phandle);\n\n/**\n * fdt_num_mem_rsv - retrieve the number of memory reserve map entries\n * @fdt: pointer to the device tree blob\n *\n * Returns the number of entries in the device tree blob's memory\n * reservation map.  This does not include the terminating 0,0 entry\n * or any other (0,0) entries reserved for expansion.\n *\n * returns:\n *     the number of entries\n */\nint fdt_num_mem_rsv(const void *fdt);\n\n/**\n * fdt_get_mem_rsv - retrieve one memory reserve map entry\n * @fdt: pointer to the device tree blob\n * @n: index of reserve map entry\n * @address: pointer to 64-bit variable to hold the start address\n * @size: pointer to 64-bit variable to hold the size of the entry\n *\n * On success, @address and @size will contain the address and size of\n * the n-th reserve map entry from the device tree blob, in\n * native-endian format.\n *\n * returns:\n *     0, on success\n *     -FDT_ERR_BADMAGIC,\n *     -FDT_ERR_BADVERSION,\n *     -FDT_ERR_BADSTATE, standard meanings\n */\nint fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);\n\n/**\n * fdt_subnode_offset_namelen - find a subnode based on substring\n * @fdt: pointer to the device tree blob\n * @parentoffset: structure block offset of a node\n * @name: name of the subnode to locate\n * @namelen: number of characters of name to consider\n *\n * Identical to fdt_subnode_offset(), but only examine the first\n * namelen characters of name for matching the subnode name.  This is\n * useful for finding subnodes based on a portion of a larger string,\n * such as a full path.\n *\n * Return: offset of the subnode or -FDT_ERR_NOTFOUND if name not found.\n */\n#ifndef SWIG /* Not available in Python */\nint fdt_subnode_offset_namelen(const void *fdt, int parentoffset,\n\t\t\t       const char *name, int namelen);\n#endif\n/**\n * fdt_subnode_offset - find a subnode of a given node\n * @fdt: pointer to the device tree blob\n * @parentoffset: structure block offset of a node\n * @name: name of the subnode to locate\n *\n * fdt_subnode_offset() finds a subnode of the node at structure block\n * offset parentoffset with the given name.  name may include a unit\n * address, in which case fdt_subnode_offset() will find the subnode\n * with that unit address, or the unit address may be omitted, in\n * which case fdt_subnode_offset() will find an arbitrary subnode\n * whose name excluding unit address matches the given name.\n *\n * returns:\n *\tstructure block offset of the requested subnode (>=0), on success\n *\t-FDT_ERR_NOTFOUND, if the requested subnode does not exist\n *\t-FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE\n *\t\ttag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings.\n */\nint fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);\n\n/**\n * fdt_path_offset_namelen - find a tree node by its full path\n * @fdt: pointer to the device tree blob\n * @path: full path of the node to locate\n * @namelen: number of characters of path to consider\n *\n * Identical to fdt_path_offset(), but only consider the first namelen\n * characters of path as the path name.\n *\n * Return: offset of the node or negative libfdt error value otherwise\n */\n#ifndef SWIG /* Not available in Python */\nint fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);\n#endif\n\n/**\n * fdt_path_offset - find a tree node by its full path\n * @fdt: pointer to the device tree blob\n * @path: full path of the node to locate\n *\n * fdt_path_offset() finds a node of a given path in the device tree.\n * Each path component may omit the unit address portion, but the\n * results of this are undefined if any such path component is\n * ambiguous (that is if there are multiple nodes at the relevant\n * level matching the given component, differentiated only by unit\n * address).\n *\n * returns:\n *\tstructure block offset of the node with the requested path (>=0), on\n *\t\tsuccess\n *\t-FDT_ERR_BADPATH, given path does not begin with '/' or is invalid\n *\t-FDT_ERR_NOTFOUND, if the requested node does not exist\n *      -FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings.\n */\nint fdt_path_offset(const void *fdt, const char *path);\n\n/**\n * fdt_get_name - retrieve the name of a given node\n * @fdt: pointer to the device tree blob\n * @nodeoffset: structure block offset of the starting node\n * @lenp: pointer to an integer variable (will be overwritten) or NULL\n *\n * fdt_get_name() retrieves the name (including unit address) of the\n * device tree node at structure block offset nodeoffset.  If lenp is\n * non-NULL, the length of this name is also returned, in the integer\n * pointed to by lenp.\n *\n * returns:\n *\tpointer to the node's name, on success\n *\t\tIf lenp is non-NULL, *lenp contains the length of that name\n *\t\t\t(>=0)\n *\tNULL, on error\n *\t\tif lenp is non-NULL *lenp contains an error code (<0):\n *\t\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE\n *\t\t\ttag\n *\t\t-FDT_ERR_BADMAGIC,\n *\t\t-FDT_ERR_BADVERSION,\n *\t\t-FDT_ERR_BADSTATE, standard meanings\n */\nconst char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);\n\n/**\n * fdt_first_property_offset - find the offset of a node's first property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: structure block offset of a node\n *\n * fdt_first_property_offset() finds the first property of the node at\n * the given structure block offset.\n *\n * returns:\n *\tstructure block offset of the property (>=0), on success\n *\t-FDT_ERR_NOTFOUND, if the requested node has no properties\n *\t-FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag\n *      -FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings.\n */\nint fdt_first_property_offset(const void *fdt, int nodeoffset);\n\n/**\n * fdt_next_property_offset - step through a node's properties\n * @fdt: pointer to the device tree blob\n * @offset: structure block offset of a property\n *\n * fdt_next_property_offset() finds the property immediately after the\n * one at the given structure block offset.  This will be a property\n * of the same node as the given property.\n *\n * returns:\n *\tstructure block offset of the next property (>=0), on success\n *\t-FDT_ERR_NOTFOUND, if the given property is the last in its node\n *\t-FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag\n *      -FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings.\n */\nint fdt_next_property_offset(const void *fdt, int offset);\n\n/**\n * fdt_for_each_property_offset - iterate over all properties of a node\n *\n * @property:\tproperty offset (int, lvalue)\n * @fdt:\tFDT blob (const void *)\n * @node:\tnode offset (int)\n *\n * This is actually a wrapper around a for loop and would be used like so:\n *\n *\tfdt_for_each_property_offset(property, fdt, node) {\n *\t\tUse property\n *\t\t...\n *\t}\n *\n *\tif ((property < 0) && (property != -FDT_ERR_NOTFOUND)) {\n *\t\tError handling\n *\t}\n *\n * Note that this is implemented as a macro and property is used as\n * iterator in the loop. The node variable can be constant or even a\n * literal.\n */\n#define fdt_for_each_property_offset(property, fdt, node)\t\\\n\tfor (property = fdt_first_property_offset(fdt, node);\t\\\n\t     property >= 0;\t\t\t\t\t\\\n\t     property = fdt_next_property_offset(fdt, property))\n\n/**\n * fdt_get_property_by_offset - retrieve the property at a given offset\n * @fdt: pointer to the device tree blob\n * @offset: offset of the property to retrieve\n * @lenp: pointer to an integer variable (will be overwritten) or NULL\n *\n * fdt_get_property_by_offset() retrieves a pointer to the\n * fdt_property structure within the device tree blob at the given\n * offset.  If lenp is non-NULL, the length of the property value is\n * also returned, in the integer pointed to by lenp.\n *\n * Note that this code only works on device tree versions >= 16. fdt_getprop()\n * works on all versions.\n *\n * returns:\n *\tpointer to the structure representing the property\n *\t\tif lenp is non-NULL, *lenp contains the length of the property\n *\t\tvalue (>=0)\n *\tNULL, on error\n *\t\tif lenp is non-NULL, *lenp contains an error code (<0):\n *\t\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag\n *\t\t-FDT_ERR_BADMAGIC,\n *\t\t-FDT_ERR_BADVERSION,\n *\t\t-FDT_ERR_BADSTATE,\n *\t\t-FDT_ERR_BADSTRUCTURE,\n *\t\t-FDT_ERR_TRUNCATED, standard meanings\n */\nconst struct fdt_property *fdt_get_property_by_offset(const void *fdt,\n\t\t\t\t\t\t      int offset,\n\t\t\t\t\t\t      int *lenp);\n\n/**\n * fdt_get_property_namelen - find a property based on substring\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to find\n * @name: name of the property to find\n * @namelen: number of characters of name to consider\n * @lenp: pointer to an integer variable (will be overwritten) or NULL\n *\n * Identical to fdt_get_property(), but only examine the first namelen\n * characters of name for matching the property name.\n *\n * Return: pointer to the structure representing the property, or NULL\n *         if not found\n */\n#ifndef SWIG /* Not available in Python */\nconst struct fdt_property *fdt_get_property_namelen(const void *fdt,\n\t\t\t\t\t\t    int nodeoffset,\n\t\t\t\t\t\t    const char *name,\n\t\t\t\t\t\t    int namelen, int *lenp);\n#endif\n\n/**\n * fdt_get_property - find a given property in a given node\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to find\n * @name: name of the property to find\n * @lenp: pointer to an integer variable (will be overwritten) or NULL\n *\n * fdt_get_property() retrieves a pointer to the fdt_property\n * structure within the device tree blob corresponding to the property\n * named 'name' of the node at offset nodeoffset.  If lenp is\n * non-NULL, the length of the property value is also returned, in the\n * integer pointed to by lenp.\n *\n * returns:\n *\tpointer to the structure representing the property\n *\t\tif lenp is non-NULL, *lenp contains the length of the property\n *\t\tvalue (>=0)\n *\tNULL, on error\n *\t\tif lenp is non-NULL, *lenp contains an error code (<0):\n *\t\t-FDT_ERR_NOTFOUND, node does not have named property\n *\t\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE\n *\t\t\ttag\n *\t\t-FDT_ERR_BADMAGIC,\n *\t\t-FDT_ERR_BADVERSION,\n *\t\t-FDT_ERR_BADSTATE,\n *\t\t-FDT_ERR_BADSTRUCTURE,\n *\t\t-FDT_ERR_TRUNCATED, standard meanings\n */\nconst struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset,\n\t\t\t\t\t    const char *name, int *lenp);\nstatic inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,\n\t\t\t\t\t\t      const char *name,\n\t\t\t\t\t\t      int *lenp)\n{\n\treturn (struct fdt_property *)(uintptr_t)\n\t\tfdt_get_property(fdt, nodeoffset, name, lenp);\n}\n\n/**\n * fdt_getprop_by_offset - retrieve the value of a property at a given offset\n * @fdt: pointer to the device tree blob\n * @offset: offset of the property to read\n * @namep: pointer to a string variable (will be overwritten) or NULL\n * @lenp: pointer to an integer variable (will be overwritten) or NULL\n *\n * fdt_getprop_by_offset() retrieves a pointer to the value of the\n * property at structure block offset 'offset' (this will be a pointer\n * to within the device blob itself, not a copy of the value).  If\n * lenp is non-NULL, the length of the property value is also\n * returned, in the integer pointed to by lenp.  If namep is non-NULL,\n * the property's namne will also be returned in the char * pointed to\n * by namep (this will be a pointer to within the device tree's string\n * block, not a new copy of the name).\n *\n * returns:\n *\tpointer to the property's value\n *\t\tif lenp is non-NULL, *lenp contains the length of the property\n *\t\tvalue (>=0)\n *\t\tif namep is non-NULL *namep contiains a pointer to the property\n *\t\tname.\n *\tNULL, on error\n *\t\tif lenp is non-NULL, *lenp contains an error code (<0):\n *\t\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag\n *\t\t-FDT_ERR_BADMAGIC,\n *\t\t-FDT_ERR_BADVERSION,\n *\t\t-FDT_ERR_BADSTATE,\n *\t\t-FDT_ERR_BADSTRUCTURE,\n *\t\t-FDT_ERR_TRUNCATED, standard meanings\n */\n#ifndef SWIG /* This function is not useful in Python */\nconst void *fdt_getprop_by_offset(const void *fdt, int offset,\n\t\t\t\t  const char **namep, int *lenp);\n#endif\n\n/**\n * fdt_getprop_namelen - get property value based on substring\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to find\n * @name: name of the property to find\n * @namelen: number of characters of name to consider\n * @lenp: pointer to an integer variable (will be overwritten) or NULL\n *\n * Identical to fdt_getprop(), but only examine the first namelen\n * characters of name for matching the property name.\n *\n * Return: pointer to the property's value or NULL on error\n */\n#ifndef SWIG /* Not available in Python */\nconst void *fdt_getprop_namelen(const void *fdt, int nodeoffset,\n\t\t\t\tconst char *name, int namelen, int *lenp);\nstatic inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,\n\t\t\t\t\t  const char *name, int namelen,\n\t\t\t\t\t  int *lenp)\n{\n\treturn (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,\n\t\t\t\t\t\t      namelen, lenp);\n}\n#endif\n\n/**\n * fdt_getprop - retrieve the value of a given property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to find\n * @name: name of the property to find\n * @lenp: pointer to an integer variable (will be overwritten) or NULL\n *\n * fdt_getprop() retrieves a pointer to the value of the property\n * named @name of the node at offset @nodeoffset (this will be a\n * pointer to within the device blob itself, not a copy of the value).\n * If @lenp is non-NULL, the length of the property value is also\n * returned, in the integer pointed to by @lenp.\n *\n * returns:\n *\tpointer to the property's value\n *\t\tif lenp is non-NULL, *lenp contains the length of the property\n *\t\tvalue (>=0)\n *\tNULL, on error\n *\t\tif lenp is non-NULL, *lenp contains an error code (<0):\n *\t\t-FDT_ERR_NOTFOUND, node does not have named property\n *\t\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE\n *\t\t\ttag\n *\t\t-FDT_ERR_BADMAGIC,\n *\t\t-FDT_ERR_BADVERSION,\n *\t\t-FDT_ERR_BADSTATE,\n *\t\t-FDT_ERR_BADSTRUCTURE,\n *\t\t-FDT_ERR_TRUNCATED, standard meanings\n */\nconst void *fdt_getprop(const void *fdt, int nodeoffset,\n\t\t\tconst char *name, int *lenp);\nstatic inline void *fdt_getprop_w(void *fdt, int nodeoffset,\n\t\t\t\t  const char *name, int *lenp)\n{\n\treturn (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);\n}\n\n/**\n * fdt_get_phandle - retrieve the phandle of a given node\n * @fdt: pointer to the device tree blob\n * @nodeoffset: structure block offset of the node\n *\n * fdt_get_phandle() retrieves the phandle of the device tree node at\n * structure block offset nodeoffset.\n *\n * returns:\n *\tthe phandle of the node at nodeoffset, on success (!= 0, != -1)\n *\t0, if the node has no phandle, or another error occurs\n */\nuint32_t fdt_get_phandle(const void *fdt, int nodeoffset);\n\n/**\n * fdt_get_alias_namelen - get alias based on substring\n * @fdt: pointer to the device tree blob\n * @name: name of the alias th look up\n * @namelen: number of characters of name to consider\n *\n * Identical to fdt_get_alias(), but only examine the first @namelen\n * characters of @name for matching the alias name.\n *\n * Return: a pointer to the expansion of the alias named @name, if it exists,\n *\t   NULL otherwise\n */\n#ifndef SWIG /* Not available in Python */\nconst char *fdt_get_alias_namelen(const void *fdt,\n\t\t\t\t  const char *name, int namelen);\n#endif\n\n/**\n * fdt_get_alias - retrieve the path referenced by a given alias\n * @fdt: pointer to the device tree blob\n * @name: name of the alias th look up\n *\n * fdt_get_alias() retrieves the value of a given alias.  That is, the\n * value of the property named @name in the node /aliases.\n *\n * returns:\n *\ta pointer to the expansion of the alias named 'name', if it exists\n *\tNULL, if the given alias or the /aliases node does not exist\n */\nconst char *fdt_get_alias(const void *fdt, const char *name);\n\n/**\n * fdt_get_path - determine the full path of a node\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose path to find\n * @buf: character buffer to contain the returned path (will be overwritten)\n * @buflen: size of the character buffer at buf\n *\n * fdt_get_path() computes the full path of the node at offset\n * nodeoffset, and records that path in the buffer at buf.\n *\n * NOTE: This function is expensive, as it must scan the device tree\n * structure from the start to nodeoffset.\n *\n * returns:\n *\t0, on success\n *\t\tbuf contains the absolute path of the node at\n *\t\tnodeoffset, as a NUL-terminated string.\n *\t-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\n *\t-FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1)\n *\t\tcharacters and will not fit in the given buffer.\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE, standard meanings\n */\nint fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen);\n\n/**\n * fdt_supernode_atdepth_offset - find a specific ancestor of a node\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose parent to find\n * @supernodedepth: depth of the ancestor to find\n * @nodedepth: pointer to an integer variable (will be overwritten) or NULL\n *\n * fdt_supernode_atdepth_offset() finds an ancestor of the given node\n * at a specific depth from the root (where the root itself has depth\n * 0, its immediate subnodes depth 1 and so forth).  So\n *\tfdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL);\n * will always return 0, the offset of the root node.  If the node at\n * nodeoffset has depth D, then:\n *\tfdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL);\n * will return nodeoffset itself.\n *\n * NOTE: This function is expensive, as it must scan the device tree\n * structure from the start to nodeoffset.\n *\n * returns:\n *\tstructure block offset of the node at node offset's ancestor\n *\t\tof depth supernodedepth (>=0), on success\n *\t-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\n *\t-FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of\n *\t\tnodeoffset\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE, standard meanings\n */\nint fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,\n\t\t\t\t int supernodedepth, int *nodedepth);\n\n/**\n * fdt_node_depth - find the depth of a given node\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose parent to find\n *\n * fdt_node_depth() finds the depth of a given node.  The root node\n * has depth 0, its immediate subnodes depth 1 and so forth.\n *\n * NOTE: This function is expensive, as it must scan the device tree\n * structure from the start to nodeoffset.\n *\n * returns:\n *\tdepth of the node at nodeoffset (>=0), on success\n *\t-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE, standard meanings\n */\nint fdt_node_depth(const void *fdt, int nodeoffset);\n\n/**\n * fdt_parent_offset - find the parent of a given node\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose parent to find\n *\n * fdt_parent_offset() locates the parent node of a given node (that\n * is, it finds the offset of the node which contains the node at\n * nodeoffset as a subnode).\n *\n * NOTE: This function is expensive, as it must scan the device tree\n * structure from the start to nodeoffset, *twice*.\n *\n * returns:\n *\tstructure block offset of the parent of the node at nodeoffset\n *\t\t(>=0), on success\n *\t-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE, standard meanings\n */\nint fdt_parent_offset(const void *fdt, int nodeoffset);\n\n/**\n * fdt_node_offset_by_prop_value - find nodes with a given property value\n * @fdt: pointer to the device tree blob\n * @startoffset: only find nodes after this offset\n * @propname: property name to check\n * @propval: property value to search for\n * @proplen: length of the value in propval\n *\n * fdt_node_offset_by_prop_value() returns the offset of the first\n * node after startoffset, which has a property named propname whose\n * value is of length proplen and has value equal to propval; or if\n * startoffset is -1, the very first such node in the tree.\n *\n * To iterate through all nodes matching the criterion, the following\n * idiom can be used:\n *\toffset = fdt_node_offset_by_prop_value(fdt, -1, propname,\n *\t\t\t\t\t       propval, proplen);\n *\twhile (offset != -FDT_ERR_NOTFOUND) {\n *\t\t// other code here\n *\t\toffset = fdt_node_offset_by_prop_value(fdt, offset, propname,\n *\t\t\t\t\t\t       propval, proplen);\n *\t}\n *\n * Note the -1 in the first call to the function, if 0 is used here\n * instead, the function will never locate the root node, even if it\n * matches the criterion.\n *\n * returns:\n *\tstructure block offset of the located node (>= 0, >startoffset),\n *\t\t on success\n *\t-FDT_ERR_NOTFOUND, no node matching the criterion exists in the\n *\t\ttree after startoffset\n *\t-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE, standard meanings\n */\nint fdt_node_offset_by_prop_value(const void *fdt, int startoffset,\n\t\t\t\t  const char *propname,\n\t\t\t\t  const void *propval, int proplen);\n\n/**\n * fdt_node_offset_by_phandle - find the node with a given phandle\n * @fdt: pointer to the device tree blob\n * @phandle: phandle value\n *\n * fdt_node_offset_by_phandle() returns the offset of the node\n * which has the given phandle value.  If there is more than one node\n * in the tree with the given phandle (an invalid tree), results are\n * undefined.\n *\n * returns:\n *\tstructure block offset of the located node (>= 0), on success\n *\t-FDT_ERR_NOTFOUND, no node with that phandle exists\n *\t-FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1)\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE, standard meanings\n */\nint fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);\n\n/**\n * fdt_node_check_compatible - check a node's compatible property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of a tree node\n * @compatible: string to match against\n *\n * fdt_node_check_compatible() returns 0 if the given node contains a\n * @compatible property with the given string as one of its elements,\n * it returns non-zero otherwise, or on error.\n *\n * returns:\n *\t0, if the node has a 'compatible' property listing the given string\n *\t1, if the node has a 'compatible' property, but it does not list\n *\t\tthe given string\n *\t-FDT_ERR_NOTFOUND, if the given node has no 'compatible' property\n *\t-FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE, standard meanings\n */\nint fdt_node_check_compatible(const void *fdt, int nodeoffset,\n\t\t\t      const char *compatible);\n\n/**\n * fdt_node_offset_by_compatible - find nodes with a given 'compatible' value\n * @fdt: pointer to the device tree blob\n * @startoffset: only find nodes after this offset\n * @compatible: 'compatible' string to match against\n *\n * fdt_node_offset_by_compatible() returns the offset of the first\n * node after startoffset, which has a 'compatible' property which\n * lists the given compatible string; or if startoffset is -1, the\n * very first such node in the tree.\n *\n * To iterate through all nodes matching the criterion, the following\n * idiom can be used:\n *\toffset = fdt_node_offset_by_compatible(fdt, -1, compatible);\n *\twhile (offset != -FDT_ERR_NOTFOUND) {\n *\t\t// other code here\n *\t\toffset = fdt_node_offset_by_compatible(fdt, offset, compatible);\n *\t}\n *\n * Note the -1 in the first call to the function, if 0 is used here\n * instead, the function will never locate the root node, even if it\n * matches the criterion.\n *\n * returns:\n *\tstructure block offset of the located node (>= 0, >startoffset),\n *\t\t on success\n *\t-FDT_ERR_NOTFOUND, no node matching the criterion exists in the\n *\t\ttree after startoffset\n *\t-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE, standard meanings\n */\nint fdt_node_offset_by_compatible(const void *fdt, int startoffset,\n\t\t\t\t  const char *compatible);\n\n/**\n * fdt_stringlist_contains - check a string list property for a string\n * @strlist: Property containing a list of strings to check\n * @listlen: Length of property\n * @str: String to search for\n *\n * This is a utility function provided for convenience. The list contains\n * one or more strings, each terminated by \\0, as is found in a device tree\n * \"compatible\" property.\n *\n * Return: 1 if the string is found in the list, 0 not found, or invalid list\n */\nint fdt_stringlist_contains(const char *strlist, int listlen, const char *str);\n\n/**\n * fdt_stringlist_count - count the number of strings in a string list\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of a tree node\n * @property: name of the property containing the string list\n *\n * Return:\n *   the number of strings in the given property\n *   -FDT_ERR_BADVALUE if the property value is not NUL-terminated\n *   -FDT_ERR_NOTFOUND if the property does not exist\n */\nint fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property);\n\n/**\n * fdt_stringlist_search - find a string in a string list and return its index\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of a tree node\n * @property: name of the property containing the string list\n * @string: string to look up in the string list\n *\n * Note that it is possible for this function to succeed on property values\n * that are not NUL-terminated. That's because the function will stop after\n * finding the first occurrence of @string. This can for example happen with\n * small-valued cell properties, such as #address-cells, when searching for\n * the empty string.\n *\n * return:\n *   the index of the string in the list of strings\n *   -FDT_ERR_BADVALUE if the property value is not NUL-terminated\n *   -FDT_ERR_NOTFOUND if the property does not exist or does not contain\n *                     the given string\n */\nint fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property,\n\t\t\t  const char *string);\n\n/**\n * fdt_stringlist_get() - obtain the string at a given index in a string list\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of a tree node\n * @property: name of the property containing the string list\n * @index: index of the string to return\n * @lenp: return location for the string length or an error code on failure\n *\n * Note that this will successfully extract strings from properties with\n * non-NUL-terminated values. For example on small-valued cell properties\n * this function will return the empty string.\n *\n * If non-NULL, the length of the string (on success) or a negative error-code\n * (on failure) will be stored in the integer pointer to by lenp.\n *\n * Return:\n *   A pointer to the string at the given index in the string list or NULL on\n *   failure. On success the length of the string will be stored in the memory\n *   location pointed to by the lenp parameter, if non-NULL. On failure one of\n *   the following negative error codes will be returned in the lenp parameter\n *   (if non-NULL):\n *     -FDT_ERR_BADVALUE if the property value is not NUL-terminated\n *     -FDT_ERR_NOTFOUND if the property does not exist\n */\nconst char *fdt_stringlist_get(const void *fdt, int nodeoffset,\n\t\t\t       const char *property, int index,\n\t\t\t       int *lenp);\n\n/**********************************************************************/\n/* Read-only functions (addressing related)                           */\n/**********************************************************************/\n\n/**\n * FDT_MAX_NCELLS - maximum value for #address-cells and #size-cells\n *\n * This is the maximum value for #address-cells, #size-cells and\n * similar properties that will be processed by libfdt.  IEE1275\n * requires that OF implementations handle values up to 4.\n * Implementations may support larger values, but in practice higher\n * values aren't used.\n */\n#define FDT_MAX_NCELLS\t\t4\n\n/**\n * fdt_address_cells - retrieve address size for a bus represented in the tree\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node to find the address size for\n *\n * When the node has a valid #address-cells property, returns its value.\n *\n * returns:\n *\t0 <= n < FDT_MAX_NCELLS, on success\n *      2, if the node has no #address-cells property\n *      -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid\n *\t\t#address-cells property\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_address_cells(const void *fdt, int nodeoffset);\n\n/**\n * fdt_size_cells - retrieve address range size for a bus represented in the\n *                  tree\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node to find the address range size for\n *\n * When the node has a valid #size-cells property, returns its value.\n *\n * returns:\n *\t0 <= n < FDT_MAX_NCELLS, on success\n *      1, if the node has no #size-cells property\n *      -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid\n *\t\t#size-cells property\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_size_cells(const void *fdt, int nodeoffset);\n\n\n/**********************************************************************/\n/* Write-in-place functions                                           */\n/**********************************************************************/\n\n/**\n * fdt_setprop_inplace_namelen_partial - change a property's value,\n *                                       but not its size\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @namelen: number of characters of name to consider\n * @idx: index of the property to change in the array\n * @val: pointer to data to replace the property value with\n * @len: length of the property value\n *\n * Identical to fdt_setprop_inplace(), but modifies the given property\n * starting from the given index, and using only the first characters\n * of the name. It is useful when you want to manipulate only one value of\n * an array and you have a string that doesn't end with \\0.\n *\n * Return: 0 on success, negative libfdt error value otherwise\n */\n#ifndef SWIG /* Not available in Python */\nint fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,\n\t\t\t\t\tconst char *name, int namelen,\n\t\t\t\t\tuint32_t idx, const void *val,\n\t\t\t\t\tint len);\n#endif\n\n/**\n * fdt_setprop_inplace - change a property's value, but not its size\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: pointer to data to replace the property value with\n * @len: length of the property value\n *\n * fdt_setprop_inplace() replaces the value of a given property with\n * the data in val, of length len.  This function cannot change the\n * size of a property, and so will only work if len is equal to the\n * current length of the property.\n *\n * This function will alter only the bytes in the blob which contain\n * the given property value, and will not alter or move any other part\n * of the tree.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, if len is not equal to the property's current length\n *\t-FDT_ERR_NOTFOUND, node does not have the named property\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\n#ifndef SWIG /* Not available in Python */\nint fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,\n\t\t\tconst void *val, int len);\n#endif\n\n/**\n * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: 32-bit integer value to replace the property with\n *\n * fdt_setprop_inplace_u32() replaces the value of a given property\n * with the 32-bit integer value in val, converting val to big-endian\n * if necessary.  This function cannot change the size of a property,\n * and so will only work if the property already exists and has length\n * 4.\n *\n * This function will alter only the bytes in the blob which contain\n * the given property value, and will not alter or move any other part\n * of the tree.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, if the property's length is not equal to 4\n *\t-FDT_ERR_NOTFOUND, node does not have the named property\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nstatic inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset,\n\t\t\t\t\t  const char *name, uint32_t val)\n{\n\tfdt32_t tmp = cpu_to_fdt32(val);\n\treturn fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));\n}\n\n/**\n * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: 64-bit integer value to replace the property with\n *\n * fdt_setprop_inplace_u64() replaces the value of a given property\n * with the 64-bit integer value in val, converting val to big-endian\n * if necessary.  This function cannot change the size of a property,\n * and so will only work if the property already exists and has length\n * 8.\n *\n * This function will alter only the bytes in the blob which contain\n * the given property value, and will not alter or move any other part\n * of the tree.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, if the property's length is not equal to 8\n *\t-FDT_ERR_NOTFOUND, node does not have the named property\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nstatic inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,\n\t\t\t\t\t  const char *name, uint64_t val)\n{\n\tfdt64_t tmp = cpu_to_fdt64(val);\n\treturn fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp));\n}\n\n/**\n * fdt_setprop_inplace_cell - change the value of a single-cell property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node containing the property\n * @name: name of the property to change the value of\n * @val: new value of the 32-bit cell\n *\n * This is an alternative name for fdt_setprop_inplace_u32()\n * Return: 0 on success, negative libfdt error number otherwise.\n */\nstatic inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,\n\t\t\t\t\t   const char *name, uint32_t val)\n{\n\treturn fdt_setprop_inplace_u32(fdt, nodeoffset, name, val);\n}\n\n/**\n * fdt_nop_property - replace a property with nop tags\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to nop\n * @name: name of the property to nop\n *\n * fdt_nop_property() will replace a given property's representation\n * in the blob with FDT_NOP tags, effectively removing it from the\n * tree.\n *\n * This function will alter only the bytes in the blob which contain\n * the property, and will not alter or move any other part of the\n * tree.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOTFOUND, node does not have the named property\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_nop_property(void *fdt, int nodeoffset, const char *name);\n\n/**\n * fdt_nop_node - replace a node (subtree) with nop tags\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node to nop\n *\n * fdt_nop_node() will replace a given node's representation in the\n * blob, including all its subnodes, if any, with FDT_NOP tags,\n * effectively removing it from the tree.\n *\n * This function will alter only the bytes in the blob which contain\n * the node and its properties and subnodes, and will not alter or\n * move any other part of the tree.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_nop_node(void *fdt, int nodeoffset);\n\n/**********************************************************************/\n/* Sequential write functions                                         */\n/**********************************************************************/\n\n/* fdt_create_with_flags flags */\n#define FDT_CREATE_FLAG_NO_NAME_DEDUP 0x1\n\t/* FDT_CREATE_FLAG_NO_NAME_DEDUP: Do not try to de-duplicate property\n\t * names in the fdt. This can result in faster creation times, but\n\t * a larger fdt. */\n\n#define FDT_CREATE_FLAGS_ALL\t(FDT_CREATE_FLAG_NO_NAME_DEDUP)\n\n/**\n * fdt_create_with_flags - begin creation of a new fdt\n * @buf: pointer to memory allocated where fdt will be created\n * @bufsize: size of the memory space at fdt\n * @flags: a valid combination of FDT_CREATE_FLAG_ flags, or 0.\n *\n * fdt_create_with_flags() begins the process of creating a new fdt with\n * the sequential write interface.\n *\n * fdt creation process must end with fdt_finished() to produce a valid fdt.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, bufsize is insufficient for a minimal fdt\n *\t-FDT_ERR_BADFLAGS, flags is not valid\n */\nint fdt_create_with_flags(void *buf, int bufsize, uint32_t flags);\n\n/**\n * fdt_create - begin creation of a new fdt\n * @buf: pointer to memory allocated where fdt will be created\n * @bufsize: size of the memory space at fdt\n *\n * fdt_create() is equivalent to fdt_create_with_flags() with flags=0.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, bufsize is insufficient for a minimal fdt\n */\nint fdt_create(void *buf, int bufsize);\n\nint fdt_resize(void *fdt, void *buf, int bufsize);\nint fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size);\nint fdt_finish_reservemap(void *fdt);\nint fdt_begin_node(void *fdt, const char *name);\nint fdt_property(void *fdt, const char *name, const void *val, int len);\nstatic inline int fdt_property_u32(void *fdt, const char *name, uint32_t val)\n{\n\tfdt32_t tmp = cpu_to_fdt32(val);\n\treturn fdt_property(fdt, name, &tmp, sizeof(tmp));\n}\nstatic inline int fdt_property_u64(void *fdt, const char *name, uint64_t val)\n{\n\tfdt64_t tmp = cpu_to_fdt64(val);\n\treturn fdt_property(fdt, name, &tmp, sizeof(tmp));\n}\n\n#ifndef SWIG /* Not available in Python */\nstatic inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)\n{\n\treturn fdt_property_u32(fdt, name, val);\n}\n#endif\n\n/**\n * fdt_property_placeholder - add a new property and return a ptr to its value\n *\n * @fdt: pointer to the device tree blob\n * @name: name of property to add\n * @len: length of property value in bytes\n * @valp: returns a pointer to where where the value should be placed\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_NOSPACE, standard meanings\n */\nint fdt_property_placeholder(void *fdt, const char *name, int len, void **valp);\n\n#define fdt_property_string(fdt, name, str) \\\n\tfdt_property(fdt, name, str, strlen(str)+1)\nint fdt_end_node(void *fdt);\nint fdt_finish(void *fdt);\n\n/**********************************************************************/\n/* Read-write functions                                               */\n/**********************************************************************/\n\nint fdt_create_empty_tree(void *buf, int bufsize);\nint fdt_open_into(const void *fdt, void *buf, int bufsize);\nint fdt_pack(void *fdt);\n\n/**\n * fdt_add_mem_rsv - add one memory reserve map entry\n * @fdt: pointer to the device tree blob\n * @address: 64-bit start address of the reserve map entry\n * @size: 64-bit size of the reserved region\n *\n * Adds a reserve map entry to the given blob reserving a region at\n * address address of length size.\n *\n * This function will insert data into the reserve map and will\n * therefore change the indexes of some entries in the table.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new reservation entry\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);\n\n/**\n * fdt_del_mem_rsv - remove a memory reserve map entry\n * @fdt: pointer to the device tree blob\n * @n: entry to remove\n *\n * fdt_del_mem_rsv() removes the n-th memory reserve map entry from\n * the blob.\n *\n * This function will delete data from the reservation table and will\n * therefore change the indexes of some entries in the table.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there\n *\t\tare less than n+1 reserve map entries)\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_del_mem_rsv(void *fdt, int n);\n\n/**\n * fdt_set_name - change the name of a given node\n * @fdt: pointer to the device tree blob\n * @nodeoffset: structure block offset of a node\n * @name: name to give the node\n *\n * fdt_set_name() replaces the name (including unit address, if any)\n * of the given node with the given string.  NOTE: this function can't\n * efficiently check if the new name is unique amongst the given\n * node's siblings; results are undefined if this function is invoked\n * with a name equal to one of the given node's siblings.\n *\n * This function may insert or delete data from the blob, and will\n * therefore change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob\n *\t\tto contain the new name\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE, standard meanings\n */\nint fdt_set_name(void *fdt, int nodeoffset, const char *name);\n\n/**\n * fdt_setprop - create or change a property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: pointer to data to set the property value to\n * @len: length of the property value\n *\n * fdt_setprop() sets the value of the named property in the given\n * node to the given value and length, creating the property if it\n * does not already exist.\n *\n * This function may insert or delete data from the blob, and will\n * therefore change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_setprop(void *fdt, int nodeoffset, const char *name,\n\t\tconst void *val, int len);\n\n/**\n * fdt_setprop_placeholder - allocate space for a property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @len: length of the property value\n * @prop_data: return pointer to property data\n *\n * fdt_setprop_placeholer() allocates the named property in the given node.\n * If the property exists it is resized. In either case a pointer to the\n * property data is returned.\n *\n * This function may insert or delete data from the blob, and will\n * therefore change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,\n\t\t\t    int len, void **prop_data);\n\n/**\n * fdt_setprop_u32 - set a property to a 32-bit integer\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: 32-bit integer value for the property (native endian)\n *\n * fdt_setprop_u32() sets the value of the named property in the given\n * node to the given 32-bit integer value (converting to big-endian if\n * necessary), or creates a new property with that value if it does\n * not already exist.\n *\n * This function may insert or delete data from the blob, and will\n * therefore change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nstatic inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name,\n\t\t\t\t  uint32_t val)\n{\n\tfdt32_t tmp = cpu_to_fdt32(val);\n\treturn fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));\n}\n\n/**\n * fdt_setprop_u64 - set a property to a 64-bit integer\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: 64-bit integer value for the property (native endian)\n *\n * fdt_setprop_u64() sets the value of the named property in the given\n * node to the given 64-bit integer value (converting to big-endian if\n * necessary), or creates a new property with that value if it does\n * not already exist.\n *\n * This function may insert or delete data from the blob, and will\n * therefore change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nstatic inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,\n\t\t\t\t  uint64_t val)\n{\n\tfdt64_t tmp = cpu_to_fdt64(val);\n\treturn fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));\n}\n\n/**\n * fdt_setprop_cell - set a property to a single cell value\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: 32-bit integer value for the property (native endian)\n *\n * This is an alternative name for fdt_setprop_u32()\n *\n * Return: 0 on success, negative libfdt error value otherwise.\n */\nstatic inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,\n\t\t\t\t   uint32_t val)\n{\n\treturn fdt_setprop_u32(fdt, nodeoffset, name, val);\n}\n\n/**\n * fdt_setprop_string - set a property to a string value\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @str: string value for the property\n *\n * fdt_setprop_string() sets the value of the named property in the\n * given node to the given string value (using the length of the\n * string to determine the new length of the property), or creates a\n * new property with that value if it does not already exist.\n *\n * This function may insert or delete data from the blob, and will\n * therefore change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\n#define fdt_setprop_string(fdt, nodeoffset, name, str) \\\n\tfdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)\n\n\n/**\n * fdt_setprop_empty - set a property to an empty value\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n *\n * fdt_setprop_empty() sets the value of the named property in the\n * given node to an empty (zero length) value, or creates a new empty\n * property if it does not already exist.\n *\n * This function may insert or delete data from the blob, and will\n * therefore change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\n#define fdt_setprop_empty(fdt, nodeoffset, name) \\\n\tfdt_setprop((fdt), (nodeoffset), (name), NULL, 0)\n\n/**\n * fdt_appendprop - append to or create a property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to append to\n * @val: pointer to data to append to the property value\n * @len: length of the data to append to the property value\n *\n * fdt_appendprop() appends the value to the named property in the\n * given node, creating the property if it does not already exist.\n *\n * This function may insert data into the blob, and will therefore\n * change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_appendprop(void *fdt, int nodeoffset, const char *name,\n\t\t   const void *val, int len);\n\n/**\n * fdt_appendprop_u32 - append a 32-bit integer value to a property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: 32-bit integer value to append to the property (native endian)\n *\n * fdt_appendprop_u32() appends the given 32-bit integer value\n * (converting to big-endian if necessary) to the value of the named\n * property in the given node, or creates a new property with that\n * value if it does not already exist.\n *\n * This function may insert data into the blob, and will therefore\n * change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nstatic inline int fdt_appendprop_u32(void *fdt, int nodeoffset,\n\t\t\t\t     const char *name, uint32_t val)\n{\n\tfdt32_t tmp = cpu_to_fdt32(val);\n\treturn fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));\n}\n\n/**\n * fdt_appendprop_u64 - append a 64-bit integer value to a property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: 64-bit integer value to append to the property (native endian)\n *\n * fdt_appendprop_u64() appends the given 64-bit integer value\n * (converting to big-endian if necessary) to the value of the named\n * property in the given node, or creates a new property with that\n * value if it does not already exist.\n *\n * This function may insert data into the blob, and will therefore\n * change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nstatic inline int fdt_appendprop_u64(void *fdt, int nodeoffset,\n\t\t\t\t     const char *name, uint64_t val)\n{\n\tfdt64_t tmp = cpu_to_fdt64(val);\n\treturn fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp));\n}\n\n/**\n * fdt_appendprop_cell - append a single cell value to a property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @val: 32-bit integer value to append to the property (native endian)\n *\n * This is an alternative name for fdt_appendprop_u32()\n *\n * Return: 0 on success, negative libfdt error value otherwise.\n */\nstatic inline int fdt_appendprop_cell(void *fdt, int nodeoffset,\n\t\t\t\t      const char *name, uint32_t val)\n{\n\treturn fdt_appendprop_u32(fdt, nodeoffset, name, val);\n}\n\n/**\n * fdt_appendprop_string - append a string to a property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to change\n * @name: name of the property to change\n * @str: string value to append to the property\n *\n * fdt_appendprop_string() appends the given string to the value of\n * the named property in the given node, or creates a new property\n * with that value if it does not already exist.\n *\n * This function may insert data into the blob, and will therefore\n * change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain the new property value\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\n#define fdt_appendprop_string(fdt, nodeoffset, name, str) \\\n\tfdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)\n\n/**\n * fdt_appendprop_addrrange - append a address range property\n * @fdt: pointer to the device tree blob\n * @parent: offset of the parent node\n * @nodeoffset: offset of the node to add a property at\n * @name: name of property\n * @addr: start address of a given range\n * @size: size of a given range\n *\n * fdt_appendprop_addrrange() appends an address range value (start\n * address and size) to the value of the named property in the given\n * node, or creates a new property with that value if it does not\n * already exist.\n * If \"name\" is not specified, a default \"reg\" is used.\n * Cell sizes are determined by parent's #address-cells and #size-cells.\n *\n * This function may insert data into the blob, and will therefore\n * change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid\n *\t\t#address-cells property\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADVALUE, addr or size doesn't fit to respective cells size\n *\t-FDT_ERR_NOSPACE, there is insufficient free space in the blob to\n *\t\tcontain a new property\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset,\n\t\t\t     const char *name, uint64_t addr, uint64_t size);\n\n/**\n * fdt_delprop - delete a property\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node whose property to nop\n * @name: name of the property to nop\n *\n * fdt_del_property() will delete the given property.\n *\n * This function will delete data from the blob, and will therefore\n * change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOTFOUND, node does not have the named property\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_delprop(void *fdt, int nodeoffset, const char *name);\n\n/**\n * fdt_add_subnode_namelen - creates a new node based on substring\n * @fdt: pointer to the device tree blob\n * @parentoffset: structure block offset of a node\n * @name: name of the subnode to create\n * @namelen: number of characters of name to consider\n *\n * Identical to fdt_add_subnode(), but use only the first @namelen\n * characters of @name as the name of the new node.  This is useful for\n * creating subnodes based on a portion of a larger string, such as a\n * full path.\n *\n * Return: structure block offset of the created subnode (>=0),\n *\t   negative libfdt error value otherwise\n */\n#ifndef SWIG /* Not available in Python */\nint fdt_add_subnode_namelen(void *fdt, int parentoffset,\n\t\t\t    const char *name, int namelen);\n#endif\n\n/**\n * fdt_add_subnode - creates a new node\n * @fdt: pointer to the device tree blob\n * @parentoffset: structure block offset of a node\n * @name: name of the subnode to locate\n *\n * fdt_add_subnode() creates a new node as a subnode of the node at\n * structure block offset parentoffset, with the given name (which\n * should include the unit address, if any).\n *\n * This function will insert data into the blob, and will therefore\n * change the offsets of some existing nodes.\n *\n * returns:\n *\tstructure block offset of the created nodeequested subnode (>=0), on\n *\t\tsuccess\n *\t-FDT_ERR_NOTFOUND, if the requested subnode does not exist\n *\t-FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE\n *\t\ttag\n *\t-FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of\n *\t\tthe given name\n *\t-FDT_ERR_NOSPACE, if there is insufficient free space in the\n *\t\tblob to contain the new node\n *\t-FDT_ERR_NOSPACE\n *\t-FDT_ERR_BADLAYOUT\n *      -FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings.\n */\nint fdt_add_subnode(void *fdt, int parentoffset, const char *name);\n\n/**\n * fdt_del_node - delete a node (subtree)\n * @fdt: pointer to the device tree blob\n * @nodeoffset: offset of the node to nop\n *\n * fdt_del_node() will remove the given node, including all its\n * subnodes if any, from the blob.\n *\n * This function will delete data from the blob, and will therefore\n * change the offsets of some existing nodes.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_del_node(void *fdt, int nodeoffset);\n\n/**\n * fdt_overlay_apply - Applies a DT overlay on a base DT\n * @fdt: pointer to the base device tree blob\n * @fdto: pointer to the device tree overlay blob\n *\n * fdt_overlay_apply() will apply the given device tree overlay on the\n * given base device tree.\n *\n * Expect the base device tree to be modified, even if the function\n * returns an error.\n *\n * returns:\n *\t0, on success\n *\t-FDT_ERR_NOSPACE, there's not enough space in the base device tree\n *\t-FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or\n *\t\tproperties in the base DT\n *\t-FDT_ERR_BADPHANDLE,\n *\t-FDT_ERR_BADOVERLAY,\n *\t-FDT_ERR_NOPHANDLES,\n *\t-FDT_ERR_INTERNAL,\n *\t-FDT_ERR_BADLAYOUT,\n *\t-FDT_ERR_BADMAGIC,\n *\t-FDT_ERR_BADOFFSET,\n *\t-FDT_ERR_BADPATH,\n *\t-FDT_ERR_BADVERSION,\n *\t-FDT_ERR_BADSTRUCTURE,\n *\t-FDT_ERR_BADSTATE,\n *\t-FDT_ERR_TRUNCATED, standard meanings\n */\nint fdt_overlay_apply(void *fdt, void *fdto);\n\n/**********************************************************************/\n/* Debugging / informational functions                                */\n/**********************************************************************/\n\nconst char *fdt_strerror(int errval);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBFDT_H */\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/libfdt_env.h",
    "content": "/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */\n#ifndef LIBFDT_ENV_H\n#define LIBFDT_ENV_H\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n * Copyright 2012 Kim Phillips, Freescale Semiconductor.\n */\n\n#include <sbi/sbi_string.h>\n#include <sbi/sbi_types.h>\n\n#define INT_MAX\t\t((int)(~0U >> 1))\n#define UINT_MAX\t((unsigned int)~0U)\n#define INT32_MAX\tINT_MAX\n#define UINT32_MAX\tUINT_MAX\n\n#ifdef __CHECKER__\n#define FDT_FORCE __attribute__((force))\n#define FDT_BITWISE __attribute__((bitwise))\n#else\n#define FDT_FORCE\n#define FDT_BITWISE\n#endif\n\n#define memmove\t\tsbi_memmove\n#define memcpy\t\tsbi_memcpy\n#define memcmp\t\tsbi_memcmp\n#define memchr\t\tsbi_memchr\n#define memset\t\tsbi_memset\n#define strchr\t\tsbi_strchr\n#define strrchr\t\tsbi_strrchr\n#define strcpy\t\tsbi_strcpy\n#define strncpy\t\tsbi_strncpy\n#define strcmp\t\tsbi_strcmp\n#define strncmp\t\tsbi_strncmp\n#define strlen\t\tsbi_strlen\n#define strnlen\t\tsbi_strnlen\n\ntypedef uint16_t FDT_BITWISE fdt16_t;\ntypedef uint32_t FDT_BITWISE fdt32_t;\ntypedef uint64_t FDT_BITWISE fdt64_t;\n\n#define EXTRACT_BYTE(x, n)\t((unsigned long long)((uint8_t *)&x)[n])\n#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))\n#define CPU_TO_FDT32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \\\n\t\t\t (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3))\n#define CPU_TO_FDT64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \\\n\t\t\t (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \\\n\t\t\t (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \\\n\t\t\t (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7))\n\nstatic inline uint16_t fdt16_to_cpu(fdt16_t x)\n{\n\treturn (FDT_FORCE uint16_t)CPU_TO_FDT16(x);\n}\nstatic inline fdt16_t cpu_to_fdt16(uint16_t x)\n{\n\treturn (FDT_FORCE fdt16_t)CPU_TO_FDT16(x);\n}\n\nstatic inline uint32_t fdt32_to_cpu(fdt32_t x)\n{\n\treturn (FDT_FORCE uint32_t)CPU_TO_FDT32(x);\n}\nstatic inline fdt32_t cpu_to_fdt32(uint32_t x)\n{\n\treturn (FDT_FORCE fdt32_t)CPU_TO_FDT32(x);\n}\n\nstatic inline uint64_t fdt64_to_cpu(fdt64_t x)\n{\n\treturn (FDT_FORCE uint64_t)CPU_TO_FDT64(x);\n}\nstatic inline fdt64_t cpu_to_fdt64(uint64_t x)\n{\n\treturn (FDT_FORCE fdt64_t)CPU_TO_FDT64(x);\n}\n#undef CPU_TO_FDT64\n#undef CPU_TO_FDT32\n#undef CPU_TO_FDT16\n#undef EXTRACT_BYTE\n\n#ifdef __APPLE__\n#include <AvailabilityMacros.h>\n\n/* strnlen() is not available on Mac OS < 10.7 */\n# if !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED < \\\n                                         MAC_OS_X_VERSION_10_7)\n\n#define strnlen fdt_strnlen\n\n/*\n * fdt_strnlen: returns the length of a string or max_count - which ever is\n * smallest.\n * Input 1 string: the string whose size is to be determined\n * Input 2 max_count: the maximum value returned by this function\n * Output: length of the string or max_count (the smallest of the two)\n */\nstatic inline size_t fdt_strnlen(const char *string, size_t max_count)\n{\n    const char *p = memchr(string, 0, max_count);\n    return p ? p - string : max_count;\n}\n\n#endif /* !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED <\n          MAC_OS_X_VERSION_10_7) */\n\n#endif /* __APPLE__ */\n\n#endif /* LIBFDT_ENV_H */\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/libfdt_internal.h",
    "content": "/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */\n#ifndef LIBFDT_INTERNAL_H\n#define LIBFDT_INTERNAL_H\n/*\n * libfdt - Flat Device Tree manipulation\n * Copyright (C) 2006 David Gibson, IBM Corporation.\n */\n#include <fdt.h>\n\n#define FDT_ALIGN(x, a)\t\t(((x) + (a) - 1) & ~((a) - 1))\n#define FDT_TAGALIGN(x)\t\t(FDT_ALIGN((x), FDT_TAGSIZE))\n\nint32_t fdt_ro_probe_(const void *fdt);\n#define FDT_RO_PROBE(fdt)\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\\\n\t\tint32_t totalsize_;\t\t\t\t\\\n\t\tif ((totalsize_ = fdt_ro_probe_(fdt)) < 0)\t\\\n\t\t\treturn totalsize_;\t\t\t\\\n\t}\n\nint fdt_check_node_offset_(const void *fdt, int offset);\nint fdt_check_prop_offset_(const void *fdt, int offset);\nconst char *fdt_find_string_(const char *strtab, int tabsize, const char *s);\nint fdt_node_end_offset_(void *fdt, int nodeoffset);\n\nstatic inline const void *fdt_offset_ptr_(const void *fdt, int offset)\n{\n\treturn (const char *)fdt + fdt_off_dt_struct(fdt) + offset;\n}\n\nstatic inline void *fdt_offset_ptr_w_(void *fdt, int offset)\n{\n\treturn (void *)(uintptr_t)fdt_offset_ptr_(fdt, offset);\n}\n\nstatic inline const struct fdt_reserve_entry *fdt_mem_rsv_(const void *fdt, int n)\n{\n\tconst struct fdt_reserve_entry *rsv_table =\n\t\t(const struct fdt_reserve_entry *)\n\t\t((const char *)fdt + fdt_off_mem_rsvmap(fdt));\n\n\treturn rsv_table + n;\n}\nstatic inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n)\n{\n\treturn (void *)(uintptr_t)fdt_mem_rsv_(fdt, n);\n}\n\n/*\n * Internal helpers to access tructural elements of the device tree\n * blob (rather than for exaple reading integers from within property\n * values).  We assume that we are either given a naturally aligned\n * address for the platform or if we are not, we are on a platform\n * where unaligned memory reads will be handled in a graceful manner.\n * If not the external helpers fdtXX_ld() from libfdt.h can be used\n * instead.\n */\nstatic inline uint32_t fdt32_ld_(const fdt32_t *p)\n{\n\treturn fdt32_to_cpu(*p);\n}\n\nstatic inline uint64_t fdt64_ld_(const fdt64_t *p)\n{\n\treturn fdt64_to_cpu(*p);\n}\n\n#define FDT_SW_MAGIC\t\t(~FDT_MAGIC)\n\n/**********************************************************************/\n/* Checking controls                                                  */\n/**********************************************************************/\n\n#ifndef FDT_ASSUME_MASK\n#define FDT_ASSUME_MASK 0\n#endif\n\n/*\n * Defines assumptions which can be enabled. Each of these can be enabled\n * individually. For maximum safety, don't enable any assumptions!\n *\n * For minimal code size and no safety, use ASSUME_PERFECT at your own risk.\n * You should have another method of validating the device tree, such as a\n * signature or hash check before using libfdt.\n *\n * For situations where security is not a concern it may be safe to enable\n * ASSUME_SANE.\n */\nenum {\n\t/*\n\t * This does essentially no checks. Only the latest device-tree\n\t * version is correctly handled. Inconsistencies or errors in the device\n\t * tree may cause undefined behaviour or crashes. Invalid parameters\n\t * passed to libfdt may do the same.\n\t *\n\t * If an error occurs when modifying the tree it may leave the tree in\n\t * an intermediate (but valid) state. As an example, adding a property\n\t * where there is insufficient space may result in the property name\n\t * being added to the string table even though the property itself is\n\t * not added to the struct section.\n\t *\n\t * Only use this if you have a fully validated device tree with\n\t * the latest supported version and wish to minimise code size.\n\t */\n\tASSUME_PERFECT\t\t= 0xff,\n\n\t/*\n\t * This assumes that the device tree is sane. i.e. header metadata\n\t * and basic hierarchy are correct.\n\t *\n\t * With this assumption enabled, normal device trees produced by libfdt\n\t * and the compiler should be handled safely. Malicious device trees and\n\t * complete garbage may cause libfdt to behave badly or crash. Truncated\n\t * device trees (e.g. those only partially loaded) can also cause\n\t * problems.\n\t *\n\t * Note: Only checks that relate exclusively to the device tree itself\n\t * (not the parameters passed to libfdt) are disabled by this\n\t * assumption. This includes checking headers, tags and the like.\n\t */\n\tASSUME_VALID_DTB\t= 1 << 0,\n\n\t/*\n\t * This builds on ASSUME_VALID_DTB and further assumes that libfdt\n\t * functions are called with valid parameters, i.e. not trigger\n\t * FDT_ERR_BADOFFSET or offsets that are out of bounds. It disables any\n\t * extensive checking of parameters and the device tree, making various\n\t * assumptions about correctness.\n\t *\n\t * It doesn't make sense to enable this assumption unless\n\t * ASSUME_VALID_DTB is also enabled.\n\t */\n\tASSUME_VALID_INPUT\t= 1 << 1,\n\n\t/*\n\t * This disables checks for device-tree version and removes all code\n\t * which handles older versions.\n\t *\n\t * Only enable this if you know you have a device tree with the latest\n\t * version.\n\t */\n\tASSUME_LATEST\t\t= 1 << 2,\n\n\t/*\n\t * This assumes that it is OK for a failed addition to the device tree,\n\t * due to lack of space or some other problem, to skip any rollback\n\t * steps (such as dropping the property name from the string table).\n\t * This is safe to enable in most circumstances, even though it may\n\t * leave the tree in a sub-optimal state.\n\t */\n\tASSUME_NO_ROLLBACK\t= 1 << 3,\n\n\t/*\n\t * This assumes that the device tree components appear in a 'convenient'\n\t * order, i.e. the memory reservation block first, then the structure\n\t * block and finally the string block.\n\t *\n\t * This order is not specified by the device-tree specification,\n\t * but is expected by libfdt. The device-tree compiler always created\n\t * device trees with this order.\n\t *\n\t * This assumption disables a check in fdt_open_into() and removes the\n\t * ability to fix the problem there. This is safe if you know that the\n\t * device tree is correctly ordered. See fdt_blocks_misordered_().\n\t */\n\tASSUME_LIBFDT_ORDER\t= 1 << 4,\n\n\t/*\n\t * This assumes that libfdt itself does not have any internal bugs. It\n\t * drops certain checks that should never be needed unless libfdt has an\n\t * undiscovered bug.\n\t *\n\t * This can generally be considered safe to enable.\n\t */\n\tASSUME_LIBFDT_FLAWLESS\t= 1 << 5,\n};\n\n/**\n * can_assume_() - check if a particular assumption is enabled\n *\n * @mask: Mask to check (ASSUME_...)\n * @return true if that assumption is enabled, else false\n */\nstatic inline bool can_assume_(int mask)\n{\n\treturn FDT_ASSUME_MASK & mask;\n}\n\n/** helper macros for checking assumptions */\n#define can_assume(_assume)\tcan_assume_(ASSUME_ ## _assume)\n\n#endif /* LIBFDT_INTERNAL_H */\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Atish Patra<atish.patra@wdc.com>\n#\n\nlibfdt_files = fdt.o fdt_addresses.o fdt_check.o fdt_empty_tree.o fdt_ro.o fdt_rw.o \\\n               fdt_strerror.o fdt_sw.o fdt_wip.o\n$(foreach file, $(libfdt_files), \\\n        $(eval CFLAGS_$(file) = -I$(src)/../../utils/libfdt))\n\nlibsbiutils-objs-$(CONFIG_LIBFDT) += $(addprefix libfdt/,$(libfdt_files))\nlibsbiutils-genflags-y  += -I$(libsbiutils_dir)/libfdt/\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libfdt/version.lds",
    "content": "/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */\nLIBFDT_1.2 {\n\tglobal:\n\t\tfdt_next_node;\n\t\tfdt_check_header;\n\t\tfdt_move;\n\t\tfdt_string;\n\t\tfdt_num_mem_rsv;\n\t\tfdt_get_mem_rsv;\n\t\tfdt_subnode_offset_namelen;\n\t\tfdt_subnode_offset;\n\t\tfdt_path_offset_namelen;\n\t\tfdt_path_offset;\n\t\tfdt_get_name;\n\t\tfdt_get_property_namelen;\n\t\tfdt_get_property;\n\t\tfdt_getprop_namelen;\n\t\tfdt_getprop;\n\t\tfdt_get_phandle;\n\t\tfdt_get_alias_namelen;\n\t\tfdt_get_alias;\n\t\tfdt_get_path;\n                fdt_header_size;\n\t\tfdt_supernode_atdepth_offset;\n\t\tfdt_node_depth;\n\t\tfdt_parent_offset;\n\t\tfdt_node_offset_by_prop_value;\n\t\tfdt_node_offset_by_phandle;\n\t\tfdt_node_check_compatible;\n\t\tfdt_node_offset_by_compatible;\n\t\tfdt_setprop_inplace;\n\t\tfdt_nop_property;\n\t\tfdt_nop_node;\n\t\tfdt_create;\n\t\tfdt_add_reservemap_entry;\n\t\tfdt_finish_reservemap;\n\t\tfdt_begin_node;\n\t\tfdt_property;\n\t\tfdt_end_node;\n\t\tfdt_finish;\n\t\tfdt_open_into;\n\t\tfdt_pack;\n\t\tfdt_add_mem_rsv;\n\t\tfdt_del_mem_rsv;\n\t\tfdt_set_name;\n\t\tfdt_setprop;\n\t\tfdt_delprop;\n\t\tfdt_add_subnode_namelen;\n\t\tfdt_add_subnode;\n\t\tfdt_del_node;\n\t\tfdt_strerror;\n\t\tfdt_offset_ptr;\n\t\tfdt_next_tag;\n\t\tfdt_appendprop;\n\t\tfdt_create_empty_tree;\n\t\tfdt_first_property_offset;\n\t\tfdt_get_property_by_offset;\n\t\tfdt_getprop_by_offset;\n\t\tfdt_next_property_offset;\n\t\tfdt_first_subnode;\n\t\tfdt_next_subnode;\n\t\tfdt_address_cells;\n\t\tfdt_size_cells;\n\t\tfdt_stringlist_contains;\n\t\tfdt_stringlist_count;\n\t\tfdt_stringlist_search;\n\t\tfdt_stringlist_get;\n\t\tfdt_resize;\n\t\tfdt_overlay_apply;\n\t\tfdt_get_string;\n\t\tfdt_find_max_phandle;\n\t\tfdt_generate_phandle;\n\t\tfdt_check_full;\n\t\tfdt_setprop_placeholder;\n\t\tfdt_property_placeholder;\n\t\tfdt_header_size_;\n\t\tfdt_appendprop_addrrange;\n\t\tfdt_setprop_inplace_namelen_partial;\n\t\tfdt_create_with_flags;\n\tlocal:\n\t\t*;\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/divdi3.c",
    "content": "/*-\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 1992, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * This software was developed by the Computer Systems Engineering group\n * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and\n * contributed to Berkeley.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n */\n\n#if defined(LIBC_SCCS) && !defined(lint)\nstatic char sccsid[] = \"@(#)divdi3.c\t8.1 (Berkeley) 6/4/93\";\n#endif /* LIBC_SCCS and not lint */\n#include <sys/cdefs.h>\n__FBSDID(\"$FreeBSD$\");\n\n#include \"quad.h\"\n\n/*\n * Divide two signed quads.\n * ??? if -1/2 should produce -1 on this machine, this code is wrong\n */\nquad_t\n__divdi3(quad_t a, quad_t b)\n{\n\tu_quad_t ua, ub, uq;\n\tint neg;\n\n\tif (a < 0)\n\t\tua = -(u_quad_t)a, neg = 1;\n\telse\n\t\tua = a, neg = 0;\n\tif (b < 0)\n\t\tub = -(u_quad_t)b, neg ^= 1;\n\telse\n\t\tub = b;\n\tuq = __qdivrem(ua, ub, (u_quad_t *)0);\n\treturn (neg ? -uq : uq);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/include/limits.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Jessica Clarke <jrtc27@jrtc27.com>\n */\n\n#ifndef __LIMITS_H__\n#define __LIMITS_H__\n\n#define CHAR_BIT 8\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/include/sys/cdefs.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Jessica Clarke <jrtc27@jrtc27.com>\n */\n\n#ifndef __SYS_CDEFS_H__\n#define __SYS_CDEFS_H__\n\n#define __FBSDID(s) struct __hack\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/include/sys/types.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Jessica Clarke <jrtc27@jrtc27.com>\n */\n\n#ifndef __SYS_TYPES_H__\n#define __SYS_TYPES_H__\n\n#include <sbi/sbi_types.h>\n\ntypedef unsigned long u_long;\n\ntypedef int64_t quad_t;\ntypedef uint64_t u_quad_t;\n\n#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\n#define _QUAD_LOWWORD 1\n#define _QUAD_HIGHWORD 0\n#else\n#define _QUAD_LOWWORD 0\n#define _QUAD_HIGHWORD 1\n#endif\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/moddi3.c",
    "content": "/*-\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 1992, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * This software was developed by the Computer Systems Engineering group\n * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and\n * contributed to Berkeley.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n */\n\n#if defined(LIBC_SCCS) && !defined(lint)\nstatic char sccsid[] = \"@(#)moddi3.c\t8.1 (Berkeley) 6/4/93\";\n#endif /* LIBC_SCCS and not lint */\n#include <sys/cdefs.h>\n__FBSDID(\"$FreeBSD$\");\n\n#include \"quad.h\"\n\n/*\n * Return remainder after dividing two signed quads.\n *\n * XXX\n * If -1/2 should produce -1 on this machine, this code is wrong.\n */\nquad_t\n__moddi3(quad_t a, quad_t b)\n{\n\tu_quad_t ua, ub, ur;\n\tint neg;\n\n\tif (a < 0)\n\t\tua = -(u_quad_t)a, neg = 1;\n\telse\n\t\tua = a, neg = 0;\n\tif (b < 0)\n\t\tub = -(u_quad_t)b;\n\telse\n\t\tub = b;\n\t(void)__qdivrem(ua, ub, &ur);\n\treturn (neg ? -ur : ur);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2021 Jessica Clarke <jrtc27@jrtc27.com>\n#\n\nifeq ($(PLATFORM_RISCV_XLEN),32)\nlibsbiutils-objs-y += libquad/divdi3.o\nlibsbiutils-objs-y += libquad/moddi3.o\nlibsbiutils-objs-y += libquad/qdivrem.o\nlibsbiutils-objs-y += libquad/udivdi3.o\nlibsbiutils-objs-y += libquad/umoddi3.o\nlibsbiutils-genflags-y += -I$(libsbiutils_dir)/libquad/include\nendif\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/qdivrem.c",
    "content": "/*-\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 1992, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * This software was developed by the Computer Systems Engineering group\n * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and\n * contributed to Berkeley.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n */\n\n#if defined(LIBC_SCCS) && !defined(lint)\nstatic char sccsid[] = \"@(#)qdivrem.c\t8.1 (Berkeley) 6/4/93\";\n#endif /* LIBC_SCCS and not lint */\n#include <sys/cdefs.h>\n__FBSDID(\"$FreeBSD$\");\n\n/*\n * Multiprecision divide.  This algorithm is from Knuth vol. 2 (2nd ed),\n * section 4.3.1, pp. 257--259.\n */\n\n#include \"quad.h\"\n\n#define\tB\t(1L << HALF_BITS)\t/* digit base */\n\n/* Combine two `digits' to make a single two-digit number. */\n#define\tCOMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b))\n\n/* select a type for digits in base B: use unsigned short if they fit */\n#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff\ntypedef unsigned short digit;\n#else\ntypedef u_long digit;\n#endif\n\n/*\n * Shift p[0]..p[len] left `sh' bits, ignoring any bits that\n * `fall out' the left (there never will be any such anyway).\n * We may assume len >= 0.  NOTE THAT THIS WRITES len+1 DIGITS.\n */\nstatic void\nshl(digit *p, int len, int sh)\n{\n\tint i;\n\n\tfor (i = 0; i < len; i++)\n\t\tp[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh));\n\tp[i] = LHALF(p[i] << sh);\n}\n\n/*\n * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v.\n *\n * We do this in base 2-sup-HALF_BITS, so that all intermediate products\n * fit within u_long.  As a consequence, the maximum length dividend and\n * divisor are 4 `digits' in this base (they are shorter if they have\n * leading zeros).\n */\nu_quad_t\n__qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq)\n{\n\tunion uu tmp;\n\tdigit *u, *v, *q;\n\tdigit v1, v2;\n\tu_long qhat, rhat, t;\n\tint m, n, d, j, i;\n\tdigit uspace[5], vspace[5], qspace[5];\n\n\t/*\n\t * Take care of special cases: divide by zero, and u < v.\n\t */\n\tif (vq == 0) {\n\t\t/* divide by zero. */\n\t\tstatic volatile const unsigned int zero = 0;\n\n\t\ttmp.ul[H] = tmp.ul[L] = 1 / zero;\n\t\tif (arq)\n\t\t\t*arq = uq;\n\t\treturn (tmp.q);\n\t}\n\tif (uq < vq) {\n\t\tif (arq)\n\t\t\t*arq = uq;\n\t\treturn (0);\n\t}\n\tu = &uspace[0];\n\tv = &vspace[0];\n\tq = &qspace[0];\n\n\t/*\n\t * Break dividend and divisor into digits in base B, then\n\t * count leading zeros to determine m and n.  When done, we\n\t * will have:\n\t *\tu = (u[1]u[2]...u[m+n]) sub B\n\t *\tv = (v[1]v[2]...v[n]) sub B\n\t *\tv[1] != 0\n\t *\t1 < n <= 4 (if n = 1, we use a different division algorithm)\n\t *\tm >= 0 (otherwise u < v, which we already checked)\n\t *\tm + n = 4\n\t * and thus\n\t *\tm = 4 - n <= 2\n\t */\n\ttmp.uq = uq;\n\tu[0] = 0;\n\tu[1] = HHALF(tmp.ul[H]);\n\tu[2] = LHALF(tmp.ul[H]);\n\tu[3] = HHALF(tmp.ul[L]);\n\tu[4] = LHALF(tmp.ul[L]);\n\ttmp.uq = vq;\n\tv[1] = HHALF(tmp.ul[H]);\n\tv[2] = LHALF(tmp.ul[H]);\n\tv[3] = HHALF(tmp.ul[L]);\n\tv[4] = LHALF(tmp.ul[L]);\n\tfor (n = 4; v[1] == 0; v++) {\n\t\tif (--n == 1) {\n\t\t\tu_long rbj;\t/* r*B+u[j] (not root boy jim) */\n\t\t\tdigit q1, q2, q3, q4;\n\n\t\t\t/*\n\t\t\t * Change of plan, per exercise 16.\n\t\t\t *\tr = 0;\n\t\t\t *\tfor j = 1..4:\n\t\t\t *\t\tq[j] = floor((r*B + u[j]) / v),\n\t\t\t *\t\tr = (r*B + u[j]) % v;\n\t\t\t * We unroll this completely here.\n\t\t\t */\n\t\t\tt = v[2];\t/* nonzero, by definition */\n\t\t\tq1 = u[1] / t;\n\t\t\trbj = COMBINE(u[1] % t, u[2]);\n\t\t\tq2 = rbj / t;\n\t\t\trbj = COMBINE(rbj % t, u[3]);\n\t\t\tq3 = rbj / t;\n\t\t\trbj = COMBINE(rbj % t, u[4]);\n\t\t\tq4 = rbj / t;\n\t\t\tif (arq)\n\t\t\t\t*arq = rbj % t;\n\t\t\ttmp.ul[H] = COMBINE(q1, q2);\n\t\t\ttmp.ul[L] = COMBINE(q3, q4);\n\t\t\treturn (tmp.q);\n\t\t}\n\t}\n\n\t/*\n\t * By adjusting q once we determine m, we can guarantee that\n\t * there is a complete four-digit quotient at &qspace[1] when\n\t * we finally stop.\n\t */\n\tfor (m = 4 - n; u[1] == 0; u++)\n\t\tm--;\n\tfor (i = 4 - m; --i >= 0;)\n\t\tq[i] = 0;\n\tq += 4 - m;\n\n\t/*\n\t * Here we run Program D, translated from MIX to C and acquiring\n\t * a few minor changes.\n\t *\n\t * D1: choose multiplier 1 << d to ensure v[1] >= B/2.\n\t */\n\td = 0;\n\tfor (t = v[1]; t < B / 2; t <<= 1)\n\t\td++;\n\tif (d > 0) {\n\t\tshl(&u[0], m + n, d);\t\t/* u <<= d */\n\t\tshl(&v[1], n - 1, d);\t\t/* v <<= d */\n\t}\n\t/*\n\t * D2: j = 0.\n\t */\n\tj = 0;\n\tv1 = v[1];\t/* for D3 -- note that v[1..n] are constant */\n\tv2 = v[2];\t/* for D3 */\n\tdo {\n\t\tdigit uj0, uj1, uj2;\n\n\t\t/*\n\t\t * D3: Calculate qhat (\\^q, in TeX notation).\n\t\t * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and\n\t\t * let rhat = (u[j]*B + u[j+1]) mod v[1].\n\t\t * While rhat < B and v[2]*qhat > rhat*B+u[j+2],\n\t\t * decrement qhat and increase rhat correspondingly.\n\t\t * Note that if rhat >= B, v[2]*qhat < rhat*B.\n\t\t */\n\t\tuj0 = u[j + 0];\t/* for D3 only -- note that u[j+...] change */\n\t\tuj1 = u[j + 1];\t/* for D3 only */\n\t\tuj2 = u[j + 2];\t/* for D3 only */\n\t\tif (uj0 == v1) {\n\t\t\tqhat = B;\n\t\t\trhat = uj1;\n\t\t\tgoto qhat_too_big;\n\t\t} else {\n\t\t\tu_long n = COMBINE(uj0, uj1);\n\t\t\tqhat = n / v1;\n\t\t\trhat = n % v1;\n\t\t}\n\t\twhile (v2 * qhat > COMBINE(rhat, uj2)) {\n\tqhat_too_big:\n\t\t\tqhat--;\n\t\t\tif ((rhat += v1) >= B)\n\t\t\t\tbreak;\n\t\t}\n\t\t/*\n\t\t * D4: Multiply and subtract.\n\t\t * The variable `t' holds any borrows across the loop.\n\t\t * We split this up so that we do not require v[0] = 0,\n\t\t * and to eliminate a final special case.\n\t\t */\n\t\tfor (t = 0, i = n; i > 0; i--) {\n\t\t\tt = u[i + j] - v[i] * qhat - t;\n\t\t\tu[i + j] = LHALF(t);\n\t\t\tt = (B - HHALF(t)) & (B - 1);\n\t\t}\n\t\tt = u[j] - t;\n\t\tu[j] = LHALF(t);\n\t\t/*\n\t\t * D5: test remainder.\n\t\t * There is a borrow if and only if HHALF(t) is nonzero;\n\t\t * in that (rare) case, qhat was too large (by exactly 1).\n\t\t * Fix it by adding v[1..n] to u[j..j+n].\n\t\t */\n\t\tif (HHALF(t)) {\n\t\t\tqhat--;\n\t\t\tfor (t = 0, i = n; i > 0; i--) { /* D6: add back. */\n\t\t\t\tt += u[i + j] + v[i];\n\t\t\t\tu[i + j] = LHALF(t);\n\t\t\t\tt = HHALF(t);\n\t\t\t}\n\t\t\tu[j] = LHALF(u[j] + t);\n\t\t}\n\t\tq[j] = qhat;\n\t} while (++j <= m);\t\t/* D7: loop on j. */\n\n\t/*\n\t * If caller wants the remainder, we have to calculate it as\n\t * u[m..m+n] >> d (this is at most n digits and thus fits in\n\t * u[m+1..m+n], but we may need more source digits).\n\t */\n\tif (arq) {\n\t\tif (d) {\n\t\t\tfor (i = m + n; i > m; --i)\n\t\t\t\tu[i] = (u[i] >> d) |\n\t\t\t\t    LHALF(u[i - 1] << (HALF_BITS - d));\n\t\t\tu[i] = 0;\n\t\t}\n\t\ttmp.ul[H] = COMBINE(uspace[1], uspace[2]);\n\t\ttmp.ul[L] = COMBINE(uspace[3], uspace[4]);\n\t\t*arq = tmp.q;\n\t}\n\n\ttmp.ul[H] = COMBINE(qspace[1], qspace[2]);\n\ttmp.ul[L] = COMBINE(qspace[3], qspace[4]);\n\treturn (tmp.q);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/quad.h",
    "content": "/*-\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 1992, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * This software was developed by the Computer Systems Engineering group\n * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and\n * contributed to Berkeley.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n *\t@(#)quad.h\t8.1 (Berkeley) 6/4/93\n * $FreeBSD$\n */\n\n/*\n * Quad arithmetic.\n *\n * This library makes the following assumptions:\n *\n *  - The type long long (aka quad_t) exists.\n *\n *  - A quad variable is exactly twice as long as `long'.\n *\n *  - The machine's arithmetic is two's complement.\n *\n * This library can provide 128-bit arithmetic on a machine with 128-bit\n * quads and 64-bit longs, for instance, or 96-bit arithmetic on machines\n * with 48-bit longs.\n */\n\n#include <sys/types.h>\n#include <limits.h>\n\n/*\n * Depending on the desired operation, we view a `long long' (aka quad_t) in\n * one or more of the following formats.\n */\nunion uu {\n\tquad_t\tq;\t\t/* as a (signed) quad */\n\tquad_t\tuq;\t\t/* as an unsigned quad */\n\tlong\tsl[2];\t\t/* as two signed longs */\n\tu_long\tul[2];\t\t/* as two unsigned longs */\n};\n\n/*\n * Define high and low longwords.\n */\n#define\tH\t\t_QUAD_HIGHWORD\n#define\tL\t\t_QUAD_LOWWORD\n\n/*\n * Total number of bits in a quad_t and in the pieces that make it up.\n * These are used for shifting, and also below for halfword extraction\n * and assembly.\n */\n#define\tQUAD_BITS\t(sizeof(quad_t) * CHAR_BIT)\n#define\tLONG_BITS\t(sizeof(long) * CHAR_BIT)\n#define\tHALF_BITS\t(sizeof(long) * CHAR_BIT / 2)\n\n/*\n * Extract high and low shortwords from longword, and move low shortword of\n * longword to upper half of long, i.e., produce the upper longword of\n * ((quad_t)(x) << (number_of_bits_in_long/2)).  (`x' must actually be u_long.)\n *\n * These are used in the multiply code, to split a longword into upper\n * and lower halves, and to reassemble a product as a quad_t, shifted left\n * (sizeof(long)*CHAR_BIT/2).\n */\n#define\tHHALF(x)\t((x) >> HALF_BITS)\n#define\tLHALF(x)\t((x) & ((1L << HALF_BITS) - 1))\n#define\tLHUP(x)\t\t((x) << HALF_BITS)\n\nint\t\t__cmpdi2(quad_t a, quad_t b);\nquad_t\t\t__divdi3(quad_t a, quad_t b);\nquad_t\t\t__moddi3(quad_t a, quad_t b);\nu_quad_t\t__qdivrem(u_quad_t u, u_quad_t v, u_quad_t *rem);\nint\t\t__ucmpdi2(u_quad_t a, u_quad_t b);\nu_quad_t\t__udivdi3(u_quad_t a, u_quad_t b);\nu_quad_t\t__umoddi3(u_quad_t a, u_quad_t b);\n\ntypedef unsigned int\tqshift_t;\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/udivdi3.c",
    "content": "/*-\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 1992, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * This software was developed by the Computer Systems Engineering group\n * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and\n * contributed to Berkeley.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n */\n\n#if defined(LIBC_SCCS) && !defined(lint)\nstatic char sccsid[] = \"@(#)udivdi3.c\t8.1 (Berkeley) 6/4/93\";\n#endif /* LIBC_SCCS and not lint */\n#include <sys/cdefs.h>\n__FBSDID(\"$FreeBSD$\");\n\n#include \"quad.h\"\n\n/*\n * Divide two unsigned quads.\n */\nu_quad_t\n__udivdi3(u_quad_t a, u_quad_t b)\n{\n\n\treturn (__qdivrem(a, b, (u_quad_t *)0));\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/libquad/umoddi3.c",
    "content": "/*-\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 1992, 1993\n *\tThe Regents of the University of California.  All rights reserved.\n *\n * This software was developed by the Computer Systems Engineering group\n * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and\n * contributed to Berkeley.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n *    notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n *    notice, this list of conditions and the following disclaimer in the\n *    documentation and/or other materials provided with the distribution.\n * 3. Neither the name of the University nor the names of its contributors\n *    may be used to endorse or promote products derived from this software\n *    without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n */\n\n#if defined(LIBC_SCCS) && !defined(lint)\nstatic char sccsid[] = \"@(#)umoddi3.c\t8.1 (Berkeley) 6/4/93\";\n#endif /* LIBC_SCCS and not lint */\n#include <sys/cdefs.h>\n__FBSDID(\"$FreeBSD$\");\n\n#include \"quad.h\"\n\n/*\n * Return remainder after dividing two unsigned quads.\n */\nu_quad_t\n__umoddi3(u_quad_t a, u_quad_t b)\n{\n\tu_quad_t r;\n\n\t(void)__qdivrem(a, b, &r);\n\treturn (r);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"System Reset Support\"\n\nconfig FDT_RESET\n\tbool \"FDT based reset drivers\"\n\tdepends on FDT\n\tdefault n\n\nif FDT_RESET\n\nconfig FDT_RESET_ATCWDT200\n\tbool \"Andes WDT FDT reset driver\"\n\tdefault n\n\nconfig FDT_RESET_GPIO\n\tbool \"GPIO FDT reset driver\"\n\tdepends on FDT_GPIO\n\tdefault n\n\nconfig FDT_RESET_HTIF\n\tbool \"Host transfer interface (HTIF) FDT reset driver\"\n\tselect SYS_HTIF\n\tdefault n\n\nconfig FDT_RESET_SIFIVE_TEST\n\tbool \"SiFive Test FDT reset driver\"\n\tselect SYS_SIFIVE_TEST\n\tdefault n\n\nconfig FDT_RESET_SUNXI_WDT\n\tbool \"Sunxi WDT FDT reset driver\"\n\tdefault n\n\nconfig FDT_RESET_THEAD\n\tbool \"T-HEAD FDT reset driver\"\n\tdefault n\n\nendif\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/reset/fdt_reset.h>\n\n/* List of FDT reset drivers generated at compile time */\nextern struct fdt_reset *fdt_reset_drivers[];\nextern unsigned long fdt_reset_drivers_size;\n\nint fdt_reset_driver_init(void *fdt, struct fdt_reset *drv)\n{\n\tint noff, rc = SBI_ENODEV;\n\tconst struct fdt_match *match;\n\n\tnoff = fdt_find_match(fdt, -1, drv->match_table, &match);\n\tif (noff < 0)\n\t\treturn SBI_ENODEV;\n\n\tif (drv->init) {\n\t\trc = drv->init(fdt, noff, match);\n\t\tif (rc && rc != SBI_ENODEV) {\n\t\t\tsbi_printf(\"%s: %s init failed, %d\\n\",\n\t\t\t\t   __func__, match->compatible, rc);\n\t\t}\n\t}\n\n\treturn rc;\n}\n\nvoid fdt_reset_init(void)\n{\n\tint pos;\n\tvoid *fdt = fdt_get_address();\n\n\tfor (pos = 0; pos < fdt_reset_drivers_size; pos++)\n\t\tfdt_reset_driver_init(fdt, fdt_reset_drivers[pos]);\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset_atcwdt200.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Andes Technology Corporation\n *\n * Authors:\n *   Yu Chien Peter Lin <peterlin@andestech.com>\n */\n\n#include <libfdt.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_system.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/reset/fdt_reset.h>\n\n#define ATCWDT200_WP_NUM 0x5aa5\n#define WREN_REG 0x18\n#define CTRL_REG 0x10\n#define RST_TIME_OFF 8\n#define RST_TIME_MSK (0x3 << RST_TIME_OFF)\n#define RST_CLK_128 (0 << RST_TIME_OFF)\n#define RST_CLK_256 (1 << RST_TIME_OFF)\n#define RST_CLK_512 (2 << RST_TIME_OFF)\n#define RST_CLK_1024 (3 << RST_TIME_OFF)\n#define INT_TIME_OFF 4\n#define INT_TIME_MSK (0xf << INT_TIME_OFF)\n#define INT_CLK_64 (0 << INT_TIME_OFF)\n#define INT_CLK_256 (1 << INT_TIME_OFF)\n#define INT_CLK_1024 (2 << INT_TIME_OFF)\n#define INT_CLK_2048 (3 << INT_TIME_OFF)\n#define INT_CLK_4096 (4 << INT_TIME_OFF)\n#define INT_CLK_8192 (5 << INT_TIME_OFF)\n#define INT_CLK_16384 (6 << INT_TIME_OFF)\n#define INT_CLK_32768 (7 << INT_TIME_OFF)\n#define RST_EN (1 << 3)\n#define INT_EN (1 << 2)\n#define CLK_PCLK (1 << 1)\n#define WDT_EN (1 << 0)\n\n#define FLASH_BASE 0x80000000ULL\n#define SMU_RESET_VEC_LO_OFF 0x50\n#define SMU_RESET_VEC_HI_OFF 0x60\n#define SMU_HARTn_RESET_VEC_LO(n) (SMU_RESET_VEC_LO_OFF + (n * 0x4))\n#define SMU_HARTn_RESET_VEC_HI(n) (SMU_RESET_VEC_HI_OFF + (n * 0x4))\n\nstatic volatile char *wdt_addr;\nstatic volatile char *smu_addr;\n\nstatic int ae350_system_reset_check(u32 type, u32 reason)\n{\n\tswitch (type) {\n\tcase SBI_SRST_RESET_TYPE_COLD_REBOOT:\n\t\treturn 1;\n\tcase SBI_SRST_RESET_TYPE_SHUTDOWN:\n\tcase SBI_SRST_RESET_TYPE_WARM_REBOOT:\n\tdefault:\n\t\treturn 0;\n\t}\n}\n\nstatic void ae350_system_reset(u32 type, u32 reason)\n{\n\tconst struct sbi_platform *plat = sbi_platform_thishart_ptr();\n\n\tfor (int i = 0; i < sbi_platform_hart_count(plat); i++) {\n\t\twritel(FLASH_BASE, smu_addr + SMU_HARTn_RESET_VEC_LO(i));\n\t\twritel(FLASH_BASE >> 32, smu_addr + SMU_HARTn_RESET_VEC_HI(i));\n\t}\n\n\t/* Program WDT control register  */\n\twritew(ATCWDT200_WP_NUM, wdt_addr + WREN_REG);\n\twritel(INT_CLK_32768 | INT_EN | RST_CLK_128 | RST_EN | WDT_EN,\n\t       wdt_addr + CTRL_REG);\n\n\tsbi_hart_hang();\n}\n\nstatic struct sbi_system_reset_device atcwdt200_reset = {\n\t.name\t\t    = \"atcwdt200\",\n\t.system_reset_check = ae350_system_reset_check,\n\t.system_reset\t    = ae350_system_reset,\n};\n\nstatic int atcwdt200_reset_init(void *fdt, int nodeoff,\n\t\t\t\tconst struct fdt_match *match)\n{\n\tuint64_t reg_addr;\n\tint rc;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoff, 0, &reg_addr, NULL);\n\tif (rc < 0 || !reg_addr)\n\t\treturn SBI_ENODEV;\n\n\twdt_addr = (volatile char *)(unsigned long)reg_addr;\n\n\t/*\n\t * The reset device requires smu to program the reset\n\t * vector for each hart.\n\t */\n\tif (fdt_parse_compat_addr(fdt, &reg_addr, \"andestech,atcsmu\"))\n\t\treturn SBI_ENODEV;\n\n\tsmu_addr = (volatile char *)(unsigned long)reg_addr;\n\n\tsbi_system_reset_add_device(&atcwdt200_reset);\n\n\treturn 0;\n}\n\nstatic const struct fdt_match atcwdt200_reset_match[] = {\n\t{ .compatible = \"andestech,atcwdt200\" },\n\t{},\n};\n\nstruct fdt_reset fdt_reset_atcwdt200 = {\n\t.match_table = atcwdt200_reset_match,\n\t.init\t     = atcwdt200_reset_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset_drivers.carray",
    "content": "HEADER: sbi_utils/reset/fdt_reset.h\nTYPE: struct fdt_reset\nNAME: fdt_reset_drivers\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset_gpio.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 SiFive\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Green Wan <green.wan@sifive.com>\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_system.h>\n#include <sbi/sbi_timer.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/gpio/fdt_gpio.h>\n#include <sbi_utils/reset/fdt_reset.h>\n\nstruct gpio_reset {\n\tstruct gpio_pin pin;\n\tu32 active_delay;\n\tu32 inactive_delay;\n};\n\nstatic struct gpio_reset poweroff = {\n\t.active_delay = 100,\n\t.inactive_delay = 100\n};\n\nstatic struct gpio_reset restart = {\n\t.active_delay = 100,\n\t.inactive_delay = 100\n};\n\nstatic struct gpio_reset *gpio_reset_get(bool is_restart, u32 type)\n{\n\tstruct gpio_reset *reset = NULL;\n\n\tswitch (type) {\n\tcase SBI_SRST_RESET_TYPE_SHUTDOWN:\n\t\tif (!is_restart)\n\t\t\treset = &poweroff;\n\t\tbreak;\n\tcase SBI_SRST_RESET_TYPE_COLD_REBOOT:\n\tcase SBI_SRST_RESET_TYPE_WARM_REBOOT:\n\t\tif (is_restart)\n\t\t\treset = &restart;\n\t\tbreak;\n\t}\n\n\tif (reset && !reset->pin.chip)\n\t\treset = NULL;\n\n\treturn reset;\n}\n\nstatic void gpio_reset_exec(struct gpio_reset *reset)\n{\n\tif (reset) {\n\t\t/* drive it active, also inactive->active edge */\n\t\tgpio_direction_output(&reset->pin, 1);\n\t\tsbi_timer_mdelay(reset->active_delay);\n\n\t\t/* drive inactive, also active->inactive edge */\n\t\tgpio_set(&reset->pin, 0);\n\t\tsbi_timer_mdelay(reset->inactive_delay);\n\n\t\t/* drive it active, also inactive->active edge */\n\t\tgpio_set(&reset->pin, 1);\n\t}\n\t/* hang !!! */\n\tsbi_hart_hang();\n}\n\nstatic int gpio_system_poweroff_check(u32 type, u32 reason)\n{\n\tif (gpio_reset_get(FALSE, type))\n\t\treturn 128;\n\n\treturn 0;\n}\n\nstatic void gpio_system_poweroff(u32 type, u32 reason)\n{\n\tgpio_reset_exec(gpio_reset_get(FALSE, type));\n}\n\nstatic struct sbi_system_reset_device gpio_poweroff = {\n\t.name = \"gpio-poweroff\",\n\t.system_reset_check = gpio_system_poweroff_check,\n\t.system_reset = gpio_system_poweroff\n};\n\nstatic int gpio_system_restart_check(u32 type, u32 reason)\n{\n\tif (gpio_reset_get(TRUE, type))\n\t\treturn 128;\n\n\treturn 0;\n}\n\nstatic void gpio_system_restart(u32 type, u32 reason)\n{\n\tgpio_reset_exec(gpio_reset_get(TRUE, type));\n}\n\nstatic struct sbi_system_reset_device gpio_restart = {\n\t.name = \"gpio-restart\",\n\t.system_reset_check = gpio_system_restart_check,\n\t.system_reset = gpio_system_restart\n};\n\nstatic int gpio_reset_init(void *fdt, int nodeoff,\n\t\t\t   const struct fdt_match *match)\n{\n\tint rc, len;\n\tconst fdt32_t *val;\n\tbool is_restart = (ulong)match->data;\n\tconst char *dir_prop = (is_restart) ? \"open-source\" : \"input\";\n\tstruct gpio_reset *reset = (is_restart) ? &restart : &poweroff;\n\n\trc = fdt_gpio_pin_get(fdt, nodeoff, 0, &reset->pin);\n\tif (rc)\n\t\treturn rc;\n\n\tif (fdt_getprop(fdt, nodeoff, dir_prop, &len)) {\n\t\trc = gpio_direction_input(&reset->pin);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\tval = fdt_getprop(fdt, nodeoff, \"active-delay-ms\", &len);\n\tif (len > 0)\n\t\treset->active_delay = fdt32_to_cpu(*val);\n\n\tval = fdt_getprop(fdt, nodeoff, \"inactive-delay-ms\", &len);\n\tif (len > 0)\n\t\treset->inactive_delay = fdt32_to_cpu(*val);\n\n\tif (is_restart)\n\t\tsbi_system_reset_add_device(&gpio_restart);\n\telse\n\t\tsbi_system_reset_add_device(&gpio_poweroff);\n\n\treturn 0;\n}\n\nstatic const struct fdt_match gpio_poweroff_match[] = {\n\t{ .compatible = \"gpio-poweroff\", .data = (const void *)FALSE },\n\t{ },\n};\n\nstruct fdt_reset fdt_poweroff_gpio = {\n\t.match_table = gpio_poweroff_match,\n\t.init = gpio_reset_init,\n};\n\nstatic const struct fdt_match gpio_reset_match[] = {\n\t{ .compatible = \"gpio-restart\", .data = (const void *)TRUE },\n\t{ },\n};\n\nstruct fdt_reset fdt_reset_gpio = {\n\t.match_table = gpio_reset_match,\n\t.init = gpio_reset_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset_htif.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi_utils/reset/fdt_reset.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/sys/htif.h>\n\nstatic int htif_reset_init(void *fdt, int nodeoff,\n\t\t\t   const struct fdt_match *match)\n{\n\tbool custom = false;\n\tuint64_t fromhost_addr = 0, tohost_addr = 0;\n\n\tif (!fdt_get_node_addr_size(fdt, nodeoff, 0, &fromhost_addr, NULL)) {\n\t\tcustom = true;\n\t\ttohost_addr = fromhost_addr + sizeof(uint64_t);\n\t}\n\n\tfdt_get_node_addr_size(fdt, nodeoff, 1, &tohost_addr, NULL);\n\n\treturn htif_system_reset_init(custom, fromhost_addr, tohost_addr);\n}\n\nstatic const struct fdt_match htif_reset_match[] = {\n\t{ .compatible = \"ucb,htif0\" },\n\t{ },\n};\n\nstruct fdt_reset fdt_reset_htif = {\n\t.match_table = htif_reset_match,\n\t.init = htif_reset_init\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset_sifive_test.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_scratch.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/reset/fdt_reset.h>\n#include <sbi_utils/sys/sifive_test.h>\n\nstatic int sifive_test_reset_init(void *fdt, int nodeoff,\n\t\t\t\t  const struct fdt_match *match)\n{\n\tint rc;\n\tuint64_t addr;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoff, 0, &addr, NULL);\n\tif (rc)\n\t\treturn rc;\n\n\treturn sifive_test_init(addr);\n}\n\nstatic const struct fdt_match sifive_test_reset_match[] = {\n\t{ .compatible = \"sifive,test1\" },\n\t{ },\n};\n\nstruct fdt_reset fdt_reset_sifive_test = {\n\t.match_table = sifive_test_reset_match,\n\t.init = sifive_test_reset_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset_sunxi_wdt.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Samuel Holland <samuel@sholland.org>\n */\n\n#include <libfdt.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_system.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/reset/fdt_reset.h>\n\n#define WDT_KEY_VAL\t\t\t0x16aa0000\n\n#define WDT_SOFT_RST_REG\t\t0x08\n#define WDT_SOFT_RST_EN\t\t\tBIT(0)\n\n#define WDT_MODE_REG\t\t\t0x18\n\nstatic volatile char *sunxi_wdt_base;\n\nstatic int sunxi_wdt_system_reset_check(u32 type, u32 reason)\n{\n\tswitch (type) {\n\tcase SBI_SRST_RESET_TYPE_COLD_REBOOT:\n\tcase SBI_SRST_RESET_TYPE_WARM_REBOOT:\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\nstatic void sunxi_wdt_system_reset(u32 type, u32 reason)\n{\n\t/* Disable the watchdog. */\n\twritel_relaxed(WDT_KEY_VAL,\n\t\t       sunxi_wdt_base + WDT_MODE_REG);\n\n\t/* Trigger soft reset. */\n\twritel_relaxed(WDT_KEY_VAL | WDT_SOFT_RST_EN,\n\t\t       sunxi_wdt_base + WDT_SOFT_RST_REG);\n}\n\nstatic struct sbi_system_reset_device sunxi_wdt_reset = {\n\t.name = \"sunxi-wdt-reset\",\n\t.system_reset_check = sunxi_wdt_system_reset_check,\n\t.system_reset = sunxi_wdt_system_reset,\n};\n\nstatic int sunxi_wdt_reset_init(void *fdt, int nodeoff,\n\t\t\t\tconst struct fdt_match *match)\n{\n\tuint64_t reg_addr;\n\tint rc;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoff, 0, &reg_addr, NULL);\n\tif (rc < 0 || !reg_addr)\n\t\treturn SBI_ENODEV;\n\n\tsunxi_wdt_base = (volatile char *)(unsigned long)reg_addr;\n\n\tsbi_system_reset_add_device(&sunxi_wdt_reset);\n\n\treturn 0;\n}\n\nstatic const struct fdt_match sunxi_wdt_reset_match[] = {\n\t{ .compatible = \"allwinner,sun20i-d1-wdt-reset\" },\n\t{ },\n};\n\nstruct fdt_reset fdt_reset_sunxi_wdt = {\n\t.match_table = sunxi_wdt_reset_match,\n\t.init = sunxi_wdt_reset_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset_thead.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n */\n\n#include <libfdt.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/sbi_system.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/reset/fdt_reset.h>\n\n#include \"fdt_reset_thead.h\"\n\nstruct custom_csr custom_csr[MAX_CUSTOM_CSR];\n\n#define CSR_OPCODE 0x39073\nstatic void clone_csrs(int cnt)\n{\n\tunsigned long i;\n\n\tfor (i = 0; i < cnt; i++) {\n\t\t/* Write csr BIT[31 - 20] to stub */\n\t\t__reset_thead_csr_stub[3*i + 1] =\n\t\t\t\tCSR_OPCODE | (custom_csr[i].index << 20);\n\n\t\t/* Mask csr BIT[31 - 20] */\n\t\t*(u32 *)&__fdt_reset_thead_csrr &= BIT(20) - 1;\n\t\tsmp_mb();\n\n\t\t/* Write csr BIT[31 - 20] to __fdt_reset_thead_csrr */\n\t\t*(u32 *)&__fdt_reset_thead_csrr |= custom_csr[i].index << 20;\n\t\tsmp_mb();\n\n\t\tRISCV_FENCE_I;\n\n\t\tcustom_csr[i].value = __fdt_reset_thead_csrr();\n\t}\n}\n\nstatic int thead_system_reset_check(u32 type, u32 reason)\n{\n\treturn 1;\n}\n\nstatic void thead_system_reset(u32 type, u32 reason)\n{\n\tebreak();\n}\n\nstatic struct sbi_system_reset_device thead_reset = {\n\t.name = \"thead_reset\",\n\t.system_reset_check = thead_system_reset_check,\n\t.system_reset = thead_system_reset\n};\n\nextern void __thead_pre_start_warm(void);\nstatic int thead_reset_init(void *fdt, int nodeoff,\n\t\t\t\t const struct fdt_match *match)\n{\n\tchar *p;\n\tconst fdt64_t *val;\n\tconst fdt32_t *val_w;\n\tint len, i;\n\tu32 t, tmp = 0;\n\n\t/* Prepare clone csrs */\n\tval_w = fdt_getprop(fdt, nodeoff, \"csr-copy\", &len);\n\tif (len > 0 && val_w) {\n\t\tint cnt;\n\n\t\tcnt = len / sizeof(fdt32_t);\n\t\tif (cnt > MAX_CUSTOM_CSR)\n\t\t\tsbi_hart_hang();\n\n\t\tfor (i = 0; i < cnt; i++) {\n\t\t\tcustom_csr[i].index = fdt32_to_cpu(val_w[i]);\n\t\t}\n\n\t\tif (cnt)\n\t\t\tclone_csrs(cnt);\n\t}\n\n\t/* Old reset method for secondary harts */\n\tif (fdt_getprop(fdt, nodeoff, \"using-csr-reset\", &len)) {\n\t\tcsr_write(0x7c7, (ulong)&__thead_pre_start_warm);\n\t\tcsr_write(0x7c6, -1);\n\t}\n\n\t/* Custom reset method for secondary harts */\n\tval = fdt_getprop(fdt, nodeoff, \"entry-reg\", &len);\n\tif (len > 0 && val) {\n          p = (char *)(ulong)fdt64_to_cpu(*val);\n\n\t\tval_w = fdt_getprop(fdt, nodeoff, \"entry-cnt\", &len);\n\t\tif (len > 0 && val_w) {\n\t\t\ttmp = fdt32_to_cpu(*val_w);\n\n\t\t\tfor (i = 0; i < tmp; i++) {\n\t\t\t\tt = (ulong)&__thead_pre_start_warm;\n\t\t\t\twritel(t, p + (8 * i));\n\t\t\t\tt = (u64)(ulong)&__thead_pre_start_warm >> 32;\n\t\t\t\twritel(t, p + (8 * i) + 4);\n\t\t\t}\n\t\t}\n\n\t\tval = fdt_getprop(fdt, nodeoff, \"control-reg\", &len);\n\t\tif (len > 0 && val) {\n\t\t\tp = (void *)(ulong)fdt64_to_cpu(*val);\n\n\t\t\tval_w = fdt_getprop(fdt, nodeoff, \"control-val\", &len);\n\t\t\tif (len > 0 && val_w) {\n\t\t\t\ttmp = fdt32_to_cpu(*val_w);\n\t\t\t\ttmp |= readl(p);\n\t\t\t\twritel(tmp, p);\n\t\t\t}\n\t\t}\n\t}\n\n\tsbi_system_reset_add_device(&thead_reset);\n\n\treturn 0;\n}\n\nstatic const struct fdt_match thead_reset_match[] = {\n\t{ .compatible = \"thead,reset-sample\" },\n\t{ },\n};\n\nstruct fdt_reset fdt_reset_thead = {\n\t.match_table = thead_reset_match,\n\t.init = thead_reset_init\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset_thead.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n */\n\n#ifndef __FDT_RESET_THEAD_H__\n#define __FDT_RESET_THEAD_H__\n\n#define MAX_CUSTOM_CSR\t32\n\n#ifndef __ASSEMBLER__\nstruct custom_csr {\n\tunsigned long index;\n\tunsigned long value;\n};\n\nu64  __fdt_reset_thead_csrr(void);\n\nextern struct custom_csr custom_csr[MAX_CUSTOM_CSR];\nextern u32 __reset_thead_csr_stub[];\n\n#endif /* __ASSEMBLER__ */\n\n#endif /* __FDT_RESET_THEAD_H__ */\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/fdt_reset_thead_asm.S",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n */\n\n#include <sbi/riscv_asm.h>\n#include \"fdt_reset_thead.h\"\n\n/*\n * csrrs rd, csr, rs1\n * |31   20|19   15|14   12|11  7|6       0|\n *    csr     rs1     010     rd   1110011\n */\n#define CSR_STUB\taddi    x0, x0, 0\n\n\t.option norvc\n\t.align 3\n\t.global __fdt_reset_thead_csrr\n__fdt_reset_thead_csrr:\n\tcsrrs a0, 0, x0\n\tret\n\n\t.align 3\n\t.global __thead_pre_start_warm\n__thead_pre_start_warm:\n\t/*\n\t * Clear L1 cache & BTB & BHT ...\n\t */\n\tli\tt1, 0x70013\n\tcsrw\t0x7c2, t1\n\tfence rw,rw\n\n\tlla\tt1, custom_csr\n\n\t.global __reset_thead_csr_stub\n__reset_thead_csr_stub:\n.rept\tMAX_CUSTOM_CSR\n\tREG_L\tt2, 8(t1)\n\tCSR_STUB\n\taddi\tt1, t1, 16\n.endr\n\t/*\n\t * Clear L1 cache & BTB & BHT ...\n\t */\n\tli\tt1, 0x70013\n\tcsrw\t0x7c2, t1\n\tfence rw,rw\n\tj _start_warm\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/reset/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2020 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nlibsbiutils-objs-$(CONFIG_FDT_RESET) += reset/fdt_reset.o\nlibsbiutils-objs-$(CONFIG_FDT_RESET) += reset/fdt_reset_drivers.o\n\ncarray-fdt_reset_drivers-$(CONFIG_FDT_RESET_ATCWDT200) += fdt_reset_atcwdt200\nlibsbiutils-objs-$(CONFIG_FDT_RESET_ATCWDT200) += reset/fdt_reset_atcwdt200.o\n\ncarray-fdt_reset_drivers-$(CONFIG_FDT_RESET_GPIO) += fdt_poweroff_gpio\ncarray-fdt_reset_drivers-$(CONFIG_FDT_RESET_GPIO) += fdt_reset_gpio\nlibsbiutils-objs-$(CONFIG_FDT_RESET_GPIO) += reset/fdt_reset_gpio.o\n\ncarray-fdt_reset_drivers-$(CONFIG_FDT_RESET_HTIF) += fdt_reset_htif\nlibsbiutils-objs-$(CONFIG_FDT_RESET_HTIF) += reset/fdt_reset_htif.o\n\ncarray-fdt_reset_drivers-$(CONFIG_FDT_RESET_SIFIVE_TEST) += fdt_reset_sifive_test\nlibsbiutils-objs-$(CONFIG_FDT_RESET_SIFIVE_TEST) += reset/fdt_reset_sifive_test.o\n\ncarray-fdt_reset_drivers-$(CONFIG_FDT_RESET_SUNXI_WDT) += fdt_reset_sunxi_wdt\nlibsbiutils-objs-$(CONFIG_FDT_RESET_SUNXI_WDT) += reset/fdt_reset_sunxi_wdt.o\n\ncarray-fdt_reset_drivers-$(CONFIG_FDT_RESET_THEAD) += fdt_reset_thead\nlibsbiutils-objs-$(CONFIG_FDT_RESET_THEAD) += reset/fdt_reset_thead.o\nlibsbiutils-objs-$(CONFIG_FDT_RESET_THEAD) += reset/fdt_reset_thead_asm.o\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"Serial Device Support\"\n\nconfig FDT_SERIAL\n\tbool \"FDT based serial drivers\"\n\tdepends on FDT\n\tdefault n\n\nif FDT_SERIAL\n\nconfig FDT_SERIAL_CADENCE\n\tbool \"Cadence UART FDT driver\"\n\tselect SERIAL_CADENCE\n\tdefault n\n\nconfig FDT_SERIAL_GAISLER\n\tbool \"Gaisler UART FDT driver\"\n\tselect SERIAL_GAISLER\n\tdefault n\n\nconfig FDT_SERIAL_HTIF\n\tbool \"Host transfer interface (HTIF) UART FDT driver\"\n\tselect SYS_HTIF\n\tdefault n\n\nconfig FDT_SERIAL_RENESAS_SCIF\n\tbool \"Renesas SCIF FDT driver\"\n\tselect SERIAL_RENESAS_SCIF\n\tdefault n\n\nconfig FDT_SERIAL_SHAKTI\n\tbool \"Shakti UART FDT driver\"\n\tselect SERIAL_SHAKTI\n\tdefault n\n\nconfig FDT_SERIAL_SIFIVE\n\tbool \"SiFive UART FDT driver\"\n\tselect SERIAL_SIFIVE\n\tdefault n\n\nconfig FDT_SERIAL_LITEX\n\tbool \"LiteX UART FDT driver\"\n\tselect SERIAL_LITEX\n\tdefault n\n\nconfig FDT_SERIAL_UART8250\n\tbool \"8250 UART FDT driver\"\n\tselect SERIAL_UART8250\n\tdefault n\n\nconfig FDT_SERIAL_XILINX_UARTLITE\n\tbool \"Xilinx UART Lite FDT driver\"\n\tselect SERIAL_XILINX_UARTLITE\n\tdefault n\n\nendif\n\nconfig SERIAL_CADENCE\n\tbool \"Cadence UART support\"\n\tdefault n\n\nconfig SERIAL_GAISLER\n\tbool \"Gaisler UART support\"\n\tdefault n\n\nconfig SERIAL_RENESAS_SCIF\n\tbool \"Renesas SCIF support\"\n\tdefault n\n\nconfig SERIAL_SHAKTI\n\tbool \"Shakti UART support\"\n\tdefault n\n\nconfig SERIAL_SIFIVE\n\tbool \"SiFive UART support\"\n\tdefault n\n\nconfig SERIAL_LITEX\n\tbool \"LiteX UART support\"\n\tdefault n\n\nconfig SERIAL_UART8250\n\tbool \"8250 UART support\"\n\tdefault n\n\nconfig SERIAL_XILINX_UARTLITE\n\tbool \"Xilinx UART Lite support\"\n\tdefault n\n\nconfig SERIAL_SEMIHOSTING\n\tbool \"Semihosting support\"\n\tdefault n\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/cadence-uart.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 StarFive Technology Co., Ltd.\n *\n * Author: Jun Liang Tan <junliang.tan@linux.starfivetech.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi_utils/serial/cadence-uart.h>\n\n/* clang-format off */\n\n#define UART_REG_CTRL\t\t0x00\n#define UART_REG_MODE\t\t0x04\n#define UART_REG_IDR\t\t0x0C\n#define UART_REG_BRGR\t\t0x18\n#define UART_REG_CSR\t\t0x2C\n#define UART_REG_RFIFO_TFIFO\t0x30\n#define UART_REG_BDIVR\t\t0x34\n\n#define UART_CTRL_RXRES\t\t0x00000001\n#define UART_CTRL_TXRES\t\t0x00000002\n#define UART_CTRL_RXEN\t\t0x00000004\n#define UART_CTRL_RXDIS\t\t0x00000008\n#define UART_CTRL_TXEN\t\t0x00000010\n#define UART_CTRL_TXDIS\t\t0x00000020\n\n#define UART_MODE_PAR_NONE\t0x00000020\t/* No parity set */\n\n#define UART_BRGR_CD_CLKDIVISOR\t0x00000001\t/* baud_sample = sel_clk */\n\n#define\tUART_CSR_REMPTY\t\t0x00000002\n#define\tUART_CSR_TFUL\t\t0x00000010\n\n/* clang-format on */\n\nstatic volatile void *uart_base;\nstatic u32 uart_in_freq;\nstatic u32 uart_baudrate;\n\n/*\n * Find minimum divisor divides in_freq to max_target_hz;\n * Based on SiFive UART driver (sifive-uart.c)\n */\nstatic inline unsigned int uart_min_clk_divisor(uint64_t in_freq,\n\t\t\t\t\t\tuint64_t max_target_hz)\n{\n\tuint64_t quotient = (in_freq + max_target_hz - 1) / (max_target_hz);\n\n\t/* Avoid underflow */\n\tif (quotient == 0)\n\t\treturn 0;\n\telse\n\t\treturn quotient - 1;\n}\n\nstatic u32 get_reg(u32 offset)\n{\n\treturn readl(uart_base + offset);\n}\n\nstatic void set_reg(u32 offset, u32 val)\n{\n\twritel(val, uart_base + offset);\n}\n\nstatic void cadence_uart_putc(char ch)\n{\n\twhile (get_reg(UART_REG_CSR) & UART_CSR_TFUL)\n\t\t;\n\n\tset_reg(UART_REG_RFIFO_TFIFO, ch);\n}\n\nstatic int cadence_uart_getc(void)\n{\n\tu32 ret = get_reg(UART_REG_CSR);\n\n\tif (!(ret & UART_CSR_REMPTY))\n\t\treturn get_reg(UART_REG_RFIFO_TFIFO);\n\n\treturn -1;\n}\n\nstatic struct sbi_console_device cadence_console = {\n\t.name = \"cadence_uart\",\n\t.console_putc = cadence_uart_putc,\n\t.console_getc = cadence_uart_getc\n};\n\nint cadence_uart_init(unsigned long base, u32 in_freq, u32 baudrate)\n{\n\tuart_base     = (volatile void *)base;\n\tuart_in_freq  = in_freq;\n\tuart_baudrate = baudrate;\n\n\t/* Disable interrupts */\n\tset_reg(UART_REG_IDR, 0xFFFFFFFF);\n\n\t/* Disable TX RX */\n\tset_reg(UART_REG_CTRL, UART_CTRL_TXDIS | UART_CTRL_RXDIS);\n\n\t/* Configure baudrate */\n\tif (in_freq && baudrate) {\n\t\tset_reg(UART_REG_BRGR, UART_BRGR_CD_CLKDIVISOR);\n\t\tset_reg(UART_REG_BDIVR,\n\t\t\tuart_min_clk_divisor(in_freq, baudrate));\n\t}\n\n\t/* Software reset TX RX data path and enable TX RX */\n\tset_reg(UART_REG_CTRL, UART_CTRL_TXRES | UART_CTRL_RXRES\n\t\t| UART_CTRL_TXEN | UART_CTRL_RXEN);\n\n\t/*\n\t * Set:\n\t * 1 stop bit, bits[07:06] = 0x00,\n\t * no parity set, bits[05:03] = 0x100,\n\t * 8 bits character length, bits[02:01] = 0x00,\n\t * sel_clk = uart_clk, bit[0] = 0x0\n\t */\n\tset_reg(UART_REG_MODE, UART_MODE_PAR_NONE);\n\n\tsbi_console_set_device(&cadence_console);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n\n/* List of FDT serial drivers generated at compile time */\nextern struct fdt_serial *fdt_serial_drivers[];\nextern unsigned long fdt_serial_drivers_size;\n\nstatic struct fdt_serial dummy = {\n\t.match_table = NULL,\n\t.init = NULL,\n};\n\nstatic struct fdt_serial *current_driver = &dummy;\n\nint fdt_serial_init(void)\n{\n\tconst void *prop;\n\tstruct fdt_serial *drv;\n\tconst struct fdt_match *match;\n\tint pos, noff = -1, len, coff, rc;\n\tvoid *fdt = fdt_get_address();\n\n\t/* Find offset of node pointed to by stdout-path */\n\tcoff = fdt_path_offset(fdt, \"/chosen\");\n\tif (-1 < coff) {\n\t\tprop = fdt_getprop(fdt, coff, \"stdout-path\", &len);\n\t\tif (prop && len) {\n\t\t\tconst char *sep, *start = prop;\n\n\t\t\t/* The device path may be followed by ':' */\n\t\t\tsep = strchr(start, ':');\n\t\t\tif (sep)\n\t\t\t\tnoff = fdt_path_offset_namelen(fdt, prop,\n\t\t\t\t\t\t\t       sep - start);\n\t\t\telse\n\t\t\t\tnoff = fdt_path_offset(fdt, prop);\n\t\t}\n\t}\n\n\t/* First check DT node pointed by stdout-path */\n\tfor (pos = 0; pos < fdt_serial_drivers_size && -1 < noff; pos++) {\n\t\tdrv = fdt_serial_drivers[pos];\n\n\t\tmatch = fdt_match_node(fdt, noff, drv->match_table);\n\t\tif (!match)\n\t\t\tcontinue;\n\n\t\tif (drv->init) {\n\t\t\trc = drv->init(fdt, noff, match);\n\t\t\tif (rc == SBI_ENODEV)\n\t\t\t\tcontinue;\n\t\t\tif (rc)\n\t\t\t\treturn rc;\n\t\t}\n\t\tcurrent_driver = drv;\n\t\tbreak;\n\t}\n\n\t/* Check if we found desired driver */\n\tif (current_driver != &dummy)\n\t\tgoto done;\n\n\t/* Lastly check all DT nodes */\n\tfor (pos = 0; pos < fdt_serial_drivers_size; pos++) {\n\t\tdrv = fdt_serial_drivers[pos];\n\n\t\tnoff = fdt_find_match(fdt, -1, drv->match_table, &match);\n\t\tif (noff < 0)\n\t\t\tcontinue;\n\n\t\tif (drv->init) {\n\t\t\trc = drv->init(fdt, noff, match);\n\t\t\tif (rc == SBI_ENODEV)\n\t\t\t\tcontinue;\n\t\t\tif (rc)\n\t\t\t\treturn rc;\n\t\t}\n\t\tcurrent_driver = drv;\n\t\tbreak;\n\t}\n\ndone:\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_cadence.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 StarFive Technology Co., Ltd.\n *\n * Author: Jun Liang Tan <junliang.tan@linux.starfivetech.com>\n */\n\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/serial/cadence-uart.h>\n\nstatic int serial_cadence_init(void *fdt, int nodeoff,\n\t\t\t       const struct fdt_match *match)\n{\n\tint rc;\n\tstruct platform_uart_data uart = { 0 };\n\n\trc = fdt_parse_uart_node(fdt, nodeoff, &uart);\n\tif (rc)\n\t\treturn rc;\n\n\treturn cadence_uart_init(uart.addr, uart.freq, uart.baud);\n}\n\nstatic const struct fdt_match serial_cadence_match[] = {\n\t{ .compatible = \"cdns,uart-r1p12\" },\n\t{ .compatible = \"starfive,jh8100-uart\" },\n\t{ },\n};\n\nstruct fdt_serial fdt_serial_cadence = {\n\t.match_table = serial_cadence_match,\n\t.init = serial_cadence_init\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_drivers.carray",
    "content": "HEADER: sbi_utils/serial/fdt_serial.h\nTYPE: struct fdt_serial\nNAME: fdt_serial_drivers\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_gaisler.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Cobham Gaisler AB.\n *\n * Authors:\n *   Daniel Cederman <cederman@gaisler.com>\n */\n\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/serial/gaisler-uart.h>\n\nstatic int serial_gaisler_init(void *fdt, int nodeoff,\n\t\t\t       const struct fdt_match *match)\n{\n\tint rc;\n\tstruct platform_uart_data uart = { 0 };\n\n\trc = fdt_parse_gaisler_uart_node(fdt, nodeoff, &uart);\n\tif (rc)\n\t\treturn rc;\n\n\treturn gaisler_uart_init(uart.addr, uart.freq, uart.baud);\n}\n\nstatic const struct fdt_match serial_gaisler_match[] = {\n\t{ .compatible = \"gaisler,apbuart\" },\n\t{},\n};\n\nstruct fdt_serial fdt_serial_gaisler = {\n\t.match_table = serial_gaisler_match,\n\t.init = serial_gaisler_init\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_htif.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/sys/htif.h>\n\nstatic const struct fdt_match serial_htif_match[] = {\n\t{ .compatible = \"ucb,htif0\" },\n\t{ },\n};\n\nstatic int serial_htif_init(void *fdt, int nodeoff,\n\t\t\t    const struct fdt_match *match)\n{\n\tbool custom = false;\n\tuint64_t fromhost_addr = 0, tohost_addr = 0;\n\n\tif (!fdt_get_node_addr_size(fdt, nodeoff, 0, &fromhost_addr, NULL)) {\n\t\tcustom = true;\n\t\ttohost_addr = fromhost_addr + sizeof(uint64_t);\n\t}\n\n\tfdt_get_node_addr_size(fdt, nodeoff, 1, &tohost_addr, NULL);\n\n\treturn htif_serial_init(custom, fromhost_addr, tohost_addr);\n}\n\nstruct fdt_serial fdt_serial_htif = {\n\t.match_table = serial_htif_match,\n\t.init = serial_htif_init\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_litex.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Gabriel Somlo\n *\n * Authors:\n *   Gabriel Somlo <gsomlo@gmail.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/serial/litex-uart.h>\n\nstatic int serial_litex_init(void *fdt, int nodeoff,\n\t\t\t     const struct fdt_match *match)\n{\n\tuint64_t reg_addr, reg_size;\n\tint rc;\n\n\tif (nodeoff < 0 || !fdt)\n\t\treturn SBI_ENODEV;\n\n\trc = fdt_get_node_addr_size(fdt, nodeoff, 0, &reg_addr, &reg_size);\n\tif (rc < 0 || !reg_addr || !reg_size)\n\t\treturn SBI_ENODEV;\n\n\treturn litex_uart_init(reg_addr);\n}\n\nstatic const struct fdt_match serial_litex_match[] = {\n\t{ .compatible = \"litex,liteuart\" },\n\t{ },\n};\n\nstruct fdt_serial fdt_serial_litex = {\n\t.match_table = serial_litex_match,\n\t.init = serial_litex_init\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_renesas_scif.c",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * Copyright (C) 2022 Renesas Electronics Corporation\n */\n\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/serial/renesas-scif.h>\n\nstatic int serial_renesas_scif_init(void *fdt, int nodeoff,\n\t\t\t\t    const struct fdt_match *match)\n{\n\tstruct platform_uart_data uart = { 0 };\n\tint ret;\n\n\tret = fdt_parse_renesas_scif_node(fdt, nodeoff, &uart);\n\tif (ret)\n\t\treturn ret;\n\n\treturn renesas_scif_init(uart.addr, uart.freq, uart.baud);\n}\n\nstatic const struct fdt_match serial_renesas_scif_match[] = {\n\t{ .compatible = \"renesas,scif-r9a07g043\" },\n\t{ /* sentinel */ }\n};\n\nstruct fdt_serial fdt_serial_renesas_scif = {\n\t.match_table = serial_renesas_scif_match,\n\t.init = serial_renesas_scif_init\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_shakti.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Vijai Kumar K <vijai@behindbytes.com>\n *\n */\n\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/serial/shakti-uart.h>\n\nstatic int serial_shakti_init(void *fdt, int nodeoff,\n\t\t\t\tconst struct fdt_match *match)\n{\n\tint rc;\n\tstruct platform_uart_data uart = { 0 };\n\n\trc = fdt_parse_shakti_uart_node(fdt, nodeoff, &uart);\n\tif (rc)\n\t\treturn rc;\n\n\treturn shakti_uart_init(uart.addr, uart.freq, uart.baud);\n}\n\nstatic const struct fdt_match serial_shakti_match[] = {\n\t{ .compatible = \"shakti,uart0\" },\n\t{ },\n};\n\nstruct fdt_serial fdt_serial_shakti = {\n\t.match_table = serial_shakti_match,\n\t.init = serial_shakti_init\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_sifive.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/serial/sifive-uart.h>\n\nstatic int serial_sifive_init(void *fdt, int nodeoff,\n\t\t\t\tconst struct fdt_match *match)\n{\n\tint rc;\n\tstruct platform_uart_data uart = { 0 };\n\n\trc = fdt_parse_sifive_uart_node(fdt, nodeoff, &uart);\n\tif (rc)\n\t\treturn rc;\n\n\treturn sifive_uart_init(uart.addr, uart.freq, uart.baud);\n}\n\nstatic const struct fdt_match serial_sifive_match[] = {\n\t{ .compatible = \"sifive,fu540-c000-uart\" },\n\t{ .compatible = \"sifive,uart0\" },\n\t{ },\n};\n\nstruct fdt_serial fdt_serial_sifive = {\n\t.match_table = serial_sifive_match,\n\t.init = serial_sifive_init\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_uart8250.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/serial/uart8250.h>\n\nstatic int serial_uart8250_init(void *fdt, int nodeoff,\n\t\t\t\tconst struct fdt_match *match)\n{\n\tint rc;\n\tstruct platform_uart_data uart = { 0 };\n\n\trc = fdt_parse_uart_node(fdt, nodeoff, &uart);\n\tif (rc)\n\t\treturn rc;\n\n\treturn uart8250_init(uart.addr, uart.freq, uart.baud,\n\t\t\t     uart.reg_shift, uart.reg_io_width,\n\t\t\t     uart.reg_offset);\n}\n\nstatic const struct fdt_match serial_uart8250_match[] = {\n\t{ .compatible = \"ns16550\" },\n\t{ .compatible = \"ns16550a\" },\n\t{ .compatible = \"snps,dw-apb-uart\" },\n\t{ },\n};\n\nstruct fdt_serial fdt_serial_uart8250 = {\n\t.match_table = serial_uart8250_match,\n\t.init = serial_uart8250_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/fdt_serial_xlnx_uartlite.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Alistair Francis <alistair.francis@wdc.com>\n */\n\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/serial/xlnx_uartlite.h>\n\nstatic int serial_xlnx_uartlite_init(void *fdt, int nodeoff,\n\t\t\t\tconst struct fdt_match *match)\n{\n\tint rc;\n\tstruct platform_uart_data uart = { 0 };\n\n\trc = fdt_parse_xlnx_uartlite_node(fdt, nodeoff, &uart);\n\tif (rc)\n\t\treturn rc;\n\n\treturn xlnx_uartlite_init(uart.addr);\n}\n\nstatic const struct fdt_match serial_xlnx_uartlite_match[] = {\n\t{ .compatible = \"xlnx,xps-uartlite-1.00.a\" },\n\t{ },\n};\n\nstruct fdt_serial fdt_serial_xlnx_uartlite = {\n\t.match_table = serial_xlnx_uartlite_match,\n\t.init = serial_xlnx_uartlite_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/gaisler-uart.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Cobham Gaisler AB.\n *\n * Authors:\n *   Daniel Cederman <cederman@gaisler.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi_utils/serial/gaisler-uart.h>\n\n/* clang-format off */\n\n#define UART_REG_DATA\t\t0\n#define UART_REG_STATUS\t\t1\n#define UART_REG_CTRL\t\t2\n#define UART_REG_SCALER\t\t3\n\n#define UART_DATA_DATA\t\t0x000000ff\n#define UART_STATUS_FIFOFULL\t0x00000200\n#define UART_STATUS_DATAREADY\t0x00000001\n\n#define UART_CTRL_DB\t\t(1<<11)\n#define UART_CTRL_FL\t\t(1<<6)\n#define UART_CTRL_TE\t\t(1<<1)\n#define UART_CTRL_RE\t\t(1<<0)\n\n/* clang-format on */\n\nstatic volatile char *uart_base;\n\nstatic u32 get_reg(u32 num)\n{\n\treturn readl(uart_base + (num * 0x4));\n}\n\nstatic void set_reg(u32 num, u32 val)\n{\n\twritel(val, uart_base + (num * 0x4));\n}\n\nstatic void gaisler_uart_putc(char ch)\n{\n\twhile (get_reg(UART_REG_STATUS) & UART_STATUS_FIFOFULL)\n\t\t;\n\n\tset_reg(UART_REG_DATA, ch);\n}\n\nstatic int gaisler_uart_getc(void)\n{\n\tu32 ret = get_reg(UART_REG_STATUS);\n\tif (!(ret & UART_STATUS_DATAREADY))\n\t\treturn -1;\n\treturn get_reg(UART_REG_DATA) & UART_DATA_DATA;\n}\n\nstatic struct sbi_console_device gaisler_console = {\n\t.name\t      = \"gaisler_uart\",\n\t.console_putc = gaisler_uart_putc,\n\t.console_getc = gaisler_uart_getc\n};\n\nint gaisler_uart_init(unsigned long base, u32 in_freq, u32 baudrate)\n{\n\tu32 ctrl;\n\n\tuart_base = (volatile char *)base;\n\n\t/* Configure baudrate */\n\tif (in_freq && baudrate)\n\t\tset_reg(UART_REG_SCALER, in_freq / (baudrate * 8 + 7));\n\n\tctrl = get_reg(UART_REG_CTRL);\n\t/* Preserve debug mode and flow control */\n\tctrl &= (UART_CTRL_DB | UART_CTRL_FL);\n\t/* Enable TX and RX */\n\tctrl |= UART_CTRL_TE | UART_CTRL_RE;\n\tset_reg(UART_REG_CTRL, ctrl);\n\n\tsbi_console_set_device(&gaisler_console);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/litex-uart.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Gabriel Somlo\n *\n * Authors:\n *   Gabriel Somlo <gsomlo@gmail.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi_utils/serial/litex-uart.h>\n\n/* clang-format off */\n\n#define UART_REG_RXTX\t\t0\n#define UART_REG_TXFULL\t\t1\n#define UART_REG_RXEMPTY\t2\n#define UART_REG_EV_STATUS\t3\n#define UART_REG_EV_PENDING\t4\n#define UART_REG_EV_ENABLE\t5\n\n/* clang-format on */\n\nstatic volatile u32 *uart_base;\n\nstatic u8 get_reg(u8 reg)\n{\n\treturn readb(uart_base + reg);\n}\n\nstatic void set_reg(u8 reg, u8 val)\n{\n\twriteb(val, uart_base + reg);\n}\n\nstatic void litex_uart_putc(char ch)\n{\n\twhile (get_reg(UART_REG_TXFULL));\n\tset_reg(UART_REG_RXTX, ch);\n}\n\nstatic int litex_uart_getc(void)\n{\n\tif (get_reg(UART_REG_RXEMPTY))\n\t\treturn -1;\n\telse\n\t\treturn get_reg(UART_REG_RXTX);\n}\n\nstatic struct sbi_console_device litex_console = {\n\t.name = \"litex_uart\",\n\t.console_putc = litex_uart_putc,\n\t.console_getc = litex_uart_getc\n};\n\nint litex_uart_init(unsigned long base)\n{\n\tuart_base = (volatile u32 *)base;\n\tset_reg(UART_REG_EV_ENABLE, 0); /* UART in polling mode: disable IRQ */\n\tsbi_console_set_device(&litex_console);\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL) += serial/fdt_serial.o\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL) += serial/fdt_serial_drivers.o\n\ncarray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_CADENCE) += fdt_serial_cadence\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL_CADENCE) += serial/fdt_serial_cadence.o\n\ncarray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_GAISLER) += fdt_serial_gaisler\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL_GAISLER) += serial/fdt_serial_gaisler.o\n\ncarray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_HTIF) += fdt_serial_htif\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL_HTIF) += serial/fdt_serial_htif.o\n\ncarray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_RENESAS_SCIF) += fdt_serial_renesas_scif\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL_RENESAS_SCIF) += serial/fdt_serial_renesas_scif.o\n\ncarray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_SHAKTI) += fdt_serial_shakti\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL_SHAKTI) += serial/fdt_serial_shakti.o\n\ncarray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_SIFIVE) += fdt_serial_sifive\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL_SIFIVE) += serial/fdt_serial_sifive.o\n\ncarray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_LITEX) += fdt_serial_litex\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL_LITEX) += serial/fdt_serial_litex.o\n\ncarray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_UART8250) += fdt_serial_uart8250\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL_UART8250) += serial/fdt_serial_uart8250.o\n\ncarray-fdt_serial_drivers-$(CONFIG_FDT_SERIAL_XILINX_UARTLITE) += fdt_serial_xlnx_uartlite\nlibsbiutils-objs-$(CONFIG_FDT_SERIAL_XILINX_UARTLITE) += serial/fdt_serial_xlnx_uartlite.o\n\nlibsbiutils-objs-$(CONFIG_SERIAL_CADENCE) += serial/cadence-uart.o\nlibsbiutils-objs-$(CONFIG_SERIAL_GAISLER) += serial/gaisler-uart.o\nlibsbiutils-objs-$(CONFIG_SERIAL_RENESAS_SCIF) += serial/renesas_scif.o\nlibsbiutils-objs-$(CONFIG_SERIAL_SHAKTI) += serial/shakti-uart.o\nlibsbiutils-objs-$(CONFIG_SERIAL_SIFIVE) += serial/sifive-uart.o\nlibsbiutils-objs-$(CONFIG_SERIAL_LITEX) += serial/litex-uart.o\nlibsbiutils-objs-$(CONFIG_SERIAL_UART8250) += serial/uart8250.o\nlibsbiutils-objs-$(CONFIG_SERIAL_XILINX_UARTLITE) += serial/xlnx-uartlite.o\nlibsbiutils-objs-$(CONFIG_SERIAL_SEMIHOSTING) += serial/semihosting.o\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/renesas_scif.c",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * Copyright (C) 2022 Renesas Electronics Corporation\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_timer.h>\n#include <sbi_utils/serial/renesas-scif.h>\n\n/* clang-format off */\n\n#define SCIF_REG_SMR\t\t0x0\n#define SCIF_REG_BRR\t\t0x2\n#define SCIF_REG_SCR\t\t0x4\n#define SCIF_REG_FTDR\t\t0x6\n#define SCIF_REG_FSR\t\t0x8\n#define SCIF_REG_FCR\t\t0xc\n#define SCIF_REG_LSR\t\t0x12\n#define SCIF_REG_SEMR\t\t0x14\n\n#define SCIF_FCR_RFRST\t\t0x2 /* Reset assert receive-FIFO (bit[1]) */\n#define SCIF_FCR_TFRST\t\t0x4 /* Reset assert transmit-FIFO(bit[2]) */\n\n#define SCIF_FCR_RST_ASSRT_RFTF\t(SCIF_FCR_RFRST | SCIF_FCR_TFRST) /* Reset assert tx-FIFO & rx-FIFO */\n#define SCIF_FCR_RST_NGATE_RFTF\t0x0 /* Reset negate tx-FIFO & rx-FIFO */\n\n#define SCIF_SCR_RE\t\t0x10 /* Enable receive (bit[4]) */\n#define SCIF_SCR_TE\t\t0x20 /* Enable transmit(bit[5]) */\n#define SCIF_SCR_RCV_TRN_EN\t(SCIF_SCR_RE | SCIF_SCR_TE) /* Enable receive & transmit */\n#define SCIF_SCR_RCV_TRN_DIS\t0x0 /* Disable receive & transmit */\n\n#define SCIF_FSR_ER\t\t0x80 /* Receive error flag */\n#define SCIF_FSR_TEND\t\t0x40 /* Transmit End Flag */\n#define SCIF_FSR_TDFE\t\t0x20 /* Transmit FIFO Data Empty Flag */\n#define SCIF_FSR_BRK\t\t0x10 /* Detect break flag */\n#define SCIF_FSR_DR\t\t0x1  /* Receive data ready flag */\n\n#define SCIF_FSR_TXD_CHK\t(SCIF_FSR_TEND | SCIF_FSR_TDFE)\n\n#define SCIF_SEMR_MDDRS\t\t0x10 /* MDDR access enable */\n\n#define SCIF_REG_8BIT(reg)\t((reg == SCIF_REG_BRR) || \\\n\t\t\t\t (reg == SCIF_REG_FTDR) || \\\n\t\t\t\t (reg == SCIF_REG_SEMR))\n\n#define SCBRR_VALUE(clk, baudrate) ((clk) / (32 * (baudrate)) - 1)\n\n/* clang-format on */\n\nstatic volatile char *scif_base;\n\nstatic u32 get_reg(u32 offset)\n{\n\tif (SCIF_REG_8BIT(offset))\n\t\treturn readb(scif_base + offset);\n\n\treturn readw(scif_base + offset);\n}\n\nstatic void set_reg(u32 offset, u32 val)\n{\n\tif (SCIF_REG_8BIT(offset))\n\t\twriteb(val, scif_base + offset);\n\telse\n\t\twritew(val, scif_base + offset);\n}\n\nstatic void renesas_scif_putc(char ch)\n{\n\tuint16_t reg;\n\n\twhile (!(SCIF_FSR_TXD_CHK & get_reg(SCIF_REG_FSR)))\n\t\t;\n\n\tset_reg(SCIF_REG_FTDR, ch);\n\treg = get_reg(SCIF_REG_FSR);\n\treg &= ~SCIF_FSR_TXD_CHK;\n\tset_reg(SCIF_REG_FSR, reg);\n}\n\nstatic struct sbi_console_device renesas_scif_console = {\n\t.name\t\t= \"renesas_scif\",\n\t.console_putc\t= renesas_scif_putc,\n};\n\nint renesas_scif_init(unsigned long base, u32 in_freq, u32 baudrate)\n{\n\tuint16_t data16;\n\n\tscif_base = (volatile char *)base;\n\n\tset_reg(SCIF_REG_SCR, SCIF_SCR_RCV_TRN_DIS);\n\tset_reg(SCIF_REG_FCR, SCIF_FCR_RST_ASSRT_RFTF);\n\n\tdata16 = get_reg(SCIF_REG_FSR); /* Dummy read */\n\tset_reg(SCIF_REG_FSR, 0x0); /* Clear all error bit */\n\n\tdata16 = get_reg(SCIF_REG_LSR); /* Dummy read */\n\tset_reg(SCIF_REG_LSR, 0x0); /* Clear ORER bit */\n\n\tset_reg(SCIF_REG_SCR, 0x0);\n\n\tset_reg(SCIF_REG_SMR, 0x0);\n\n\tdata16 = get_reg(SCIF_REG_SEMR);\n\tset_reg(SCIF_REG_SEMR, data16 & (~SCIF_SEMR_MDDRS));\n\tset_reg(SCIF_REG_BRR, SCBRR_VALUE(in_freq, baudrate));\n\n\tset_reg(SCIF_REG_FCR, SCIF_FCR_RST_NGATE_RFTF);\n\tset_reg(SCIF_REG_SCR, SCIF_SCR_RCV_TRN_EN);\n\n\tsbi_console_set_device(&renesas_scif_console);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/semihosting.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Ventana Micro Systems Inc.\n *\n * Authors:\n *   Anup Patel <apatel@ventanamicro.com>\n *   Kautuk Consul <kconsul@ventanamicro.com>\n */\n\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_string.h>\n#include <sbi/sbi_error.h>\n#include <sbi_utils/serial/semihosting.h>\n\n#define SYSOPEN     0x01\n#define SYSWRITEC   0x03\n#define SYSREAD     0x06\n#define SYSREADC    0x07\n#define SYSERRNO\t0x13\n\nstatic long semihosting_trap(int sysnum, void *addr)\n{\n\tregister int ret asm (\"a0\") = sysnum;\n\tregister void *param0 asm (\"a1\") = addr;\n\n\tasm volatile (\n\t\t\"\t.align 4\\n\"\n\t\t\"\t.option push\\n\"\n\t\t\"\t.option norvc\\n\"\n\n\t\t\"\tslli zero, zero, 0x1f\\n\"\n\t\t\"\tebreak\\n\"\n\t\t\"\tsrai zero, zero, 7\\n\"\n\n\t\t\"\t.option pop\\n\"\n\t\t: \"+r\" (ret) : \"r\" (param0) : \"memory\");\n\n\treturn ret;\n}\n\nstatic bool _semihosting_enabled = true;\nstatic bool try_semihosting = true;\n\nbool semihosting_enabled(void)\n{\n\tregister int ret asm (\"a0\") = SYSERRNO;\n\tregister void *param0 asm (\"a1\") = NULL;\n\tunsigned long tmp = 0;\n\n\tif (!try_semihosting)\n\t\treturn _semihosting_enabled;\n\n\tasm volatile (\n\t\t\"\t.align 4\\n\"\n\t\t\"\t.option push\\n\"\n\t\t\"\t.option norvc\\n\"\n\n\t\t\"\tj _semihost_test_vector_next\\n\"\n\t\t\"\t.align 4\\n\"\n\t\t\"_semihost_test_vector:\\n\"\n\t\t\"\tcsrr %[en], mepc\\n\"\n\t\t\"\taddi %[en], %[en], 4\\n\"\n\t\t\"\tcsrw mepc, %[en]\\n\"\n\t\t\"\tadd %[en], zero, zero\\n\"\n\t\t\"\tmret\\n\"\n\t\t\"_semihost_test_vector_next:\\n\"\n\n\t\t\"\tla %[tmp], _semihost_test_vector\\n\"\n\t\t\"\tcsrrw %[tmp], mtvec, %[tmp]\\n\"\n\t\t\"\t.align 4\\n\"\n\t\t\"\tslli zero, zero, 0x1f\\n\"\n\t\t\"\tebreak\\n\"\n\t\t\"\tsrai zero, zero, 7\\n\"\n\t\t\"\tcsrw mtvec, %[tmp]\\n\"\n\n\t\t\"\t.option pop\\n\"\n\t\t: [tmp] \"+r\" (tmp), [en] \"+r\" (_semihosting_enabled),\n\t\t  [ret] \"+r\" (ret)\n\t\t: \"r\" (param0) : \"memory\");\n\n\ttry_semihosting = false;\n\treturn _semihosting_enabled;\n}\n\nstatic int semihosting_errno(void)\n{\n\tlong ret = semihosting_trap(SYSERRNO, NULL);\n\n\tif (ret > 0)\n\t\treturn -ret;\n\treturn SBI_EIO;\n}\n\nstatic int semihosting_infd = SBI_ENODEV;\n\nstatic long semihosting_open(const char *fname, enum semihosting_open_mode mode)\n{\n\tlong fd;\n\tstruct semihosting_open_s {\n\t\tconst char *fname;\n\t\tunsigned long mode;\n\t\tsize_t len;\n\t} open;\n\n\topen.fname = fname;\n\topen.len = sbi_strlen(fname);\n\topen.mode = mode;\n\n\t/* Open the file on the host */\n\tfd = semihosting_trap(SYSOPEN, &open);\n\tif (fd == -1)\n\t\treturn semihosting_errno();\n\treturn fd;\n}\n\n/**\n * struct semihosting_rdwr_s - Arguments for read and write\n * @fd: A file descriptor returned from semihosting_open()\n * @memp: Pointer to a buffer of memory of at least @len bytes\n * @len: The number of bytes to read or write\n */\nstruct semihosting_rdwr_s {\n\tlong fd;\n\tvoid *memp;\n\tsize_t len;\n};\n\nstatic long semihosting_read(long fd, void *memp, size_t len)\n{\n\tlong ret;\n\tstruct semihosting_rdwr_s read;\n\n\tread.fd = fd;\n\tread.memp = memp;\n\tread.len = len;\n\n\tret = semihosting_trap(SYSREAD, &read);\n\tif (ret < 0)\n\t\treturn semihosting_errno();\n\treturn len - ret;\n}\n\n/* clang-format on */\n\nstatic void semihosting_putc(char ch)\n{\n\tsemihosting_trap(SYSWRITEC, &ch);\n}\n\nstatic int semihosting_getc(void)\n{\n\tchar ch = 0;\n\tint ret;\n\n\tif (semihosting_infd < 0)  {\n\t\tret = semihosting_trap(SYSREADC, NULL);\n\t\tret = ret < 0 ? -1 : ret;\n\t} else\n\t\tret = semihosting_read(semihosting_infd, &ch, 1) > 0 ? ch : -1;\n\n\treturn ret;\n}\n\nstatic struct sbi_console_device semihosting_console = {\n\t.name = \"semihosting\",\n\t.console_putc = semihosting_putc,\n\t.console_getc = semihosting_getc\n};\n\nint semihosting_init(void)\n{\n\tsemihosting_infd = semihosting_open(\":tt\", MODE_READ);\n\n\tsbi_console_set_device(&semihosting_console);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/shakti-uart.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Vijai Kumar K <vijai@behindbytes.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi_utils/serial/shakti-uart.h>\n\n#define REG_BAUD\t0x00\n#define REG_TX\t\t0x04\n#define REG_RX\t\t0x08\n#define REG_STATUS\t0x0C\n#define REG_DELAY\t0x10\n#define REG_CONTROL\t0x14\n#define REG_INT_EN\t0x18\n#define REG_IQ_CYCLES\t0x1C\n#define REG_RX_THRES\t0x20\n\n#define UART_TX_FULL  0x2\n#define UART_RX_NOT_EMPTY 0x4\n#define UART_RX_FULL  0x8\n\nstatic volatile char *uart_base;\n\nstatic void shakti_uart_putc(char ch)\n{\n\twhile ((readb(uart_base + REG_STATUS) & UART_TX_FULL))\n\t\t;\n\twriteb(ch, uart_base + REG_TX);\n}\n\nstatic int shakti_uart_getc(void)\n{\n\tif (readb(uart_base + REG_STATUS) & UART_RX_NOT_EMPTY)\n\t\treturn readb(uart_base + REG_RX);\n\treturn -1;\n}\n\nstatic struct sbi_console_device shakti_console = {\n\t.name = \"shakti_uart\",\n\t.console_putc = shakti_uart_putc,\n\t.console_getc = shakti_uart_getc\n};\n\nint shakti_uart_init(unsigned long base, u32 in_freq, u32 baudrate)\n{\n\tuart_base = (volatile char *)base;\n\tu16 baud;\n\n\tif (baudrate) {\n\t\tbaud = (u16)(in_freq / (16 * baudrate));\n\t\twritew(baud, uart_base + REG_BAUD);\n\t}\n\n\tsbi_console_set_device(&shakti_console);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/sifive-uart.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi_utils/serial/sifive-uart.h>\n\n/* clang-format off */\n\n#define UART_REG_TXFIFO\t\t0\n#define UART_REG_RXFIFO\t\t1\n#define UART_REG_TXCTRL\t\t2\n#define UART_REG_RXCTRL\t\t3\n#define UART_REG_IE\t\t4\n#define UART_REG_IP\t\t5\n#define UART_REG_DIV\t\t6\n\n#define UART_TXFIFO_FULL\t0x80000000\n#define UART_RXFIFO_EMPTY\t0x80000000\n#define UART_RXFIFO_DATA\t0x000000ff\n#define UART_TXCTRL_TXEN\t0x1\n#define UART_RXCTRL_RXEN\t0x1\n\n/* clang-format on */\n\nstatic volatile char *uart_base;\nstatic u32 uart_in_freq;\nstatic u32 uart_baudrate;\n\n/**\n * Find minimum divisor divides in_freq to max_target_hz;\n * Based on uart driver n SiFive FSBL.\n *\n * f_baud = f_in / (div + 1) => div = (f_in / f_baud) - 1\n * The nearest integer solution requires rounding up as to not exceed max_target_hz.\n * div  = ceil(f_in / f_baud) - 1\n *\t= floor((f_in - 1 + f_baud) / f_baud) - 1\n * This should not overflow as long as (f_in - 1 + f_baud) does not exceed\n * 2^32 - 1, which is unlikely since we represent frequencies in kHz.\n */\nstatic inline unsigned int uart_min_clk_divisor(uint64_t in_freq,\n\t\t\t\t\t\tuint64_t max_target_hz)\n{\n\tuint64_t quotient = (in_freq + max_target_hz - 1) / (max_target_hz);\n\n\t/* Avoid underflow */\n\tif (quotient == 0)\n\t\treturn 0;\n\telse\n\t\treturn quotient - 1;\n}\n\nstatic u32 get_reg(u32 num)\n{\n\treturn readl(uart_base + (num * 0x4));\n}\n\nstatic void set_reg(u32 num, u32 val)\n{\n\twritel(val, uart_base + (num * 0x4));\n}\n\nstatic void sifive_uart_putc(char ch)\n{\n\twhile (get_reg(UART_REG_TXFIFO) & UART_TXFIFO_FULL)\n\t\t;\n\n\tset_reg(UART_REG_TXFIFO, ch);\n}\n\nstatic int sifive_uart_getc(void)\n{\n\tu32 ret = get_reg(UART_REG_RXFIFO);\n\n\tif (!(ret & UART_RXFIFO_EMPTY))\n\t\treturn ret & UART_RXFIFO_DATA;\n\n\treturn -1;\n}\n\nstatic struct sbi_console_device sifive_console = {\n\t.name = \"sifive_uart\",\n\t.console_putc = sifive_uart_putc,\n\t.console_getc = sifive_uart_getc\n};\n\nint sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate)\n{\n\tuart_base     = (volatile char *)base;\n\tuart_in_freq  = in_freq;\n\tuart_baudrate = baudrate;\n\n\t/* Configure baudrate */\n\tif (in_freq && baudrate)\n\t\tset_reg(UART_REG_DIV, uart_min_clk_divisor(in_freq, baudrate));\n\n\t/* Disable interrupts */\n\tset_reg(UART_REG_IE, 0);\n\n\t/* Enable TX */\n\tset_reg(UART_REG_TXCTRL, UART_TXCTRL_TXEN);\n\n\t/* Enable Rx */\n\tset_reg(UART_REG_RXCTRL, UART_RXCTRL_RXEN);\n\n\tsbi_console_set_device(&sifive_console);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/uart8250.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi_utils/serial/uart8250.h>\n\n/* clang-format off */\n\n#define UART_RBR_OFFSET\t\t0\t/* In:  Recieve Buffer Register */\n#define UART_THR_OFFSET\t\t0\t/* Out: Transmitter Holding Register */\n#define UART_DLL_OFFSET\t\t0\t/* Out: Divisor Latch Low */\n#define UART_IER_OFFSET\t\t1\t/* I/O: Interrupt Enable Register */\n#define UART_DLM_OFFSET\t\t1\t/* Out: Divisor Latch High */\n#define UART_FCR_OFFSET\t\t2\t/* Out: FIFO Control Register */\n#define UART_IIR_OFFSET\t\t2\t/* I/O: Interrupt Identification Register */\n#define UART_LCR_OFFSET\t\t3\t/* Out: Line Control Register */\n#define UART_MCR_OFFSET\t\t4\t/* Out: Modem Control Register */\n#define UART_LSR_OFFSET\t\t5\t/* In:  Line Status Register */\n#define UART_MSR_OFFSET\t\t6\t/* In:  Modem Status Register */\n#define UART_SCR_OFFSET\t\t7\t/* I/O: Scratch Register */\n#define UART_MDR1_OFFSET\t8\t/* I/O:  Mode Register */\n\n#define UART_LSR_FIFOE\t\t0x80\t/* Fifo error */\n#define UART_LSR_TEMT\t\t0x40\t/* Transmitter empty */\n#define UART_LSR_THRE\t\t0x20\t/* Transmit-hold-register empty */\n#define UART_LSR_BI\t\t0x10\t/* Break interrupt indicator */\n#define UART_LSR_FE\t\t0x08\t/* Frame error indicator */\n#define UART_LSR_PE\t\t0x04\t/* Parity error indicator */\n#define UART_LSR_OE\t\t0x02\t/* Overrun error indicator */\n#define UART_LSR_DR\t\t0x01\t/* Receiver data ready */\n#define UART_LSR_BRK_ERROR_BITS\t0x1E\t/* BI, FE, PE, OE bits */\n\n/* clang-format on */\n\nstatic volatile char *uart8250_base;\nstatic u32 uart8250_in_freq;\nstatic u32 uart8250_baudrate;\nstatic u32 uart8250_reg_width;\nstatic u32 uart8250_reg_shift;\n\nstatic u32 get_reg(u32 num)\n{\n\tu32 offset = num << uart8250_reg_shift;\n\n\tif (uart8250_reg_width == 1)\n\t\treturn readb(uart8250_base + offset);\n\telse if (uart8250_reg_width == 2)\n\t\treturn readw(uart8250_base + offset);\n\telse\n\t\treturn readl(uart8250_base + offset);\n}\n\nstatic void set_reg(u32 num, u32 val)\n{\n\tu32 offset = num << uart8250_reg_shift;\n\n\tif (uart8250_reg_width == 1)\n\t\twriteb(val, uart8250_base + offset);\n\telse if (uart8250_reg_width == 2)\n\t\twritew(val, uart8250_base + offset);\n\telse\n\t\twritel(val, uart8250_base + offset);\n}\n\nstatic void uart8250_putc(char ch)\n{\n\twhile ((get_reg(UART_LSR_OFFSET) & UART_LSR_THRE) == 0)\n\t\t;\n\n\tset_reg(UART_THR_OFFSET, ch);\n}\n\nstatic int uart8250_getc(void)\n{\n\tif (get_reg(UART_LSR_OFFSET) & UART_LSR_DR)\n\t\treturn get_reg(UART_RBR_OFFSET);\n\treturn -1;\n}\n\nstatic struct sbi_console_device uart8250_console = {\n\t.name = \"uart8250\",\n\t.console_putc = uart8250_putc,\n\t.console_getc = uart8250_getc\n};\n\nint uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,\n\t\t  u32 reg_width, u32 reg_offset)\n{\n\tu16 bdiv = 0;\n\n\tuart8250_base      = (volatile char *)base + reg_offset;\n\tuart8250_reg_shift = reg_shift;\n\tuart8250_reg_width = reg_width;\n\tuart8250_in_freq   = in_freq;\n\tuart8250_baudrate  = baudrate;\n\n\tif (uart8250_baudrate) {\n\t\tbdiv = (uart8250_in_freq + 8 * uart8250_baudrate) /\n\t\t       (16 * uart8250_baudrate);\n\t}\n\n\t/* Disable all interrupts */\n\tset_reg(UART_IER_OFFSET, 0x00);\n\t/* Enable DLAB */\n\tset_reg(UART_LCR_OFFSET, 0x80);\n\n\tif (bdiv) {\n\t\t/* Set divisor low byte */\n\t\tset_reg(UART_DLL_OFFSET, bdiv & 0xff);\n\t\t/* Set divisor high byte */\n\t\tset_reg(UART_DLM_OFFSET, (bdiv >> 8) & 0xff);\n\t}\n\n\t/* 8 bits, no parity, one stop bit */\n\tset_reg(UART_LCR_OFFSET, 0x03);\n\t/* Enable FIFO */\n\tset_reg(UART_FCR_OFFSET, 0x01);\n\t/* No modem control DTR RTS */\n\tset_reg(UART_MCR_OFFSET, 0x00);\n\t/* Clear line status */\n\tget_reg(UART_LSR_OFFSET);\n\t/* Read receive buffer */\n\tget_reg(UART_RBR_OFFSET);\n\t/* Set scratchpad */\n\tset_reg(UART_SCR_OFFSET, 0x00);\n\n\tsbi_console_set_device(&uart8250_console);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/serial/xlnx-uartlite.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Alistair Francis <alistair.francis@wdc.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi_utils/serial/xlnx_uartlite.h>\n\n/* clang-format off */\n\n#define UART_RX_OFFSET\t\t0x00\n#define UART_TX_OFFSET\t\t0x04\n#define UART_STATUS_OFFSET\t0x08\n# define UART_STATUS_RXVALID\t0x01\n# define UART_STATUS_RXFULL\t0x02\n# define UART_STATUS_TXEMPTY\t0x04\n# define UART_STATUS_TXFULL\t0x08\n# define UART_STATUS_IE\t0x10\n# define UART_STATUS_OVERRUN\t0x20\n# define UART_STATUS_FRAME\t0x40\n# define UART_STATUS_PARITY\t0x80\n#define UART_CTRL_OFFSET\t0x0C\n# define UART_CTRL_RST_TX\t0x01\n# define UART_CTRL_RST_RX\t0x02\n# define UART_CTRL_IE\t\t0x10\n\n/* clang-format on */\n\nstatic volatile char *xlnx_uartlite_base;\n\nstatic void xlnx_uartlite_putc(char ch)\n{\n\twhile((readb(xlnx_uartlite_base + UART_STATUS_OFFSET) & UART_STATUS_TXFULL))\n\t\t;\n\n\twriteb(ch, xlnx_uartlite_base + UART_TX_OFFSET);\n}\n\nstatic int xlnx_uartlite_getc(void)\n{\n\tu16 status = readb(xlnx_uartlite_base + UART_STATUS_OFFSET);\n\n\tif (status & UART_STATUS_RXVALID)\n\t\treturn readb(xlnx_uartlite_base + UART_RX_OFFSET);\n\n\treturn -1;\n}\n\nstatic struct sbi_console_device xlnx_uartlite_console = {\n\t.name = \"xlnx-uartlite\",\n\t.console_putc = xlnx_uartlite_putc,\n\t.console_getc = xlnx_uartlite_getc\n};\n\nint xlnx_uartlite_init(unsigned long base)\n{\n\txlnx_uartlite_base = (volatile char *)base;\n\n\tsbi_console_set_device(&xlnx_uartlite_console);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/sys/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"System Device Support\"\n\nconfig SYS_HTIF\n\tbool \"Host transfere interface (HTIF) support\"\n\tdefault n\n\nconfig SYS_SIFIVE_TEST\n\tbool \"SiFive test support\"\n\tdefault n\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/sys/htif.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 2010-2020, The Regents of the University of California\n * (Regents).  All Rights Reserved.\n */\n\n#include <sbi/riscv_locks.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_system.h>\n#include <sbi_utils/sys/htif.h>\n\n#define HTIF_DATA_BITS\t\t48\n#define HTIF_DATA_MASK\t\t((1ULL << HTIF_DATA_BITS) - 1)\n#define HTIF_DATA_SHIFT\t\t0\n#define HTIF_CMD_BITS\t\t8\n#define HTIF_CMD_MASK\t\t((1ULL << HTIF_CMD_BITS) - 1)\n#define HTIF_CMD_SHIFT\t\t48\n#define HTIF_DEV_BITS\t\t8\n#define HTIF_DEV_MASK\t\t((1ULL << HTIF_DEV_BITS) - 1)\n#define HTIF_DEV_SHIFT\t\t56\n\n#define HTIF_DEV_SYSTEM\t\t0\n#define HTIF_DEV_CONSOLE\t1\n\n#define HTIF_CONSOLE_CMD_GETC\t0\n#define HTIF_CONSOLE_CMD_PUTC\t1\n\n#if __riscv_xlen == 64\n# define TOHOST_CMD(dev, cmd, payload) \\\n\t(((uint64_t)(dev) << HTIF_DEV_SHIFT) | \\\n\t ((uint64_t)(cmd) << HTIF_CMD_SHIFT) | \\\n\t (uint64_t)(payload))\n#else\n# define TOHOST_CMD(dev, cmd, payload) ({ \\\n  if ((dev) || (cmd)) __builtin_trap(); \\\n  (payload); })\n#endif\n#define FROMHOST_DEV(fromhost_value) \\\n\t((uint64_t)((fromhost_value) >> HTIF_DEV_SHIFT) & HTIF_DEV_MASK)\n#define FROMHOST_CMD(fromhost_value) \\\n\t((uint64_t)((fromhost_value) >> HTIF_CMD_SHIFT) & HTIF_CMD_MASK)\n#define FROMHOST_DATA(fromhost_value) \\\n\t((uint64_t)((fromhost_value) >> HTIF_DATA_SHIFT) & HTIF_DATA_MASK)\n\n#define PK_SYS_write 64\n\nvolatile uint64_t tohost __attribute__((section(\".htif\")));\nvolatile uint64_t fromhost __attribute__((section(\".htif\")));\n\nstatic uint64_t *htif_fromhost = NULL;\nstatic uint64_t *htif_tohost = NULL;\nstatic bool htif_custom = false;\n\nstatic int htif_console_buf;\nstatic spinlock_t htif_lock = SPIN_LOCK_INITIALIZER;\n\nstatic inline uint64_t __read_tohost(void)\n{\n\treturn (htif_custom) ? *htif_tohost : tohost;\n}\n\nstatic inline void __write_tohost(uint64_t val)\n{\n\tif (htif_custom)\n\t\t*htif_tohost = val;\n\telse\n\t\ttohost = val;\n}\n\nstatic inline uint64_t __read_fromhost(void)\n{\n\treturn (htif_custom) ? *htif_fromhost : fromhost;\n}\n\nstatic inline void __write_fromhost(uint64_t val)\n{\n\tif (htif_custom)\n\t\t*htif_fromhost = val;\n\telse\n\t\tfromhost = val;\n}\n\nstatic void __check_fromhost()\n{\n\tuint64_t fh = __read_fromhost();\n\tif (!fh)\n\t\treturn;\n\t__write_fromhost(0);\n\n\t/* this should be from the console */\n\tif (FROMHOST_DEV(fh) != HTIF_DEV_CONSOLE)\n\t\t__builtin_trap();\n\tswitch (FROMHOST_CMD(fh)) {\n\t\tcase HTIF_CONSOLE_CMD_GETC:\n\t\t\thtif_console_buf = 1 + (uint8_t)FROMHOST_DATA(fh);\n\t\t\tbreak;\n\t\tcase HTIF_CONSOLE_CMD_PUTC:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t__builtin_trap();\n\t}\n}\n\nstatic void __set_tohost(uint64_t dev, uint64_t cmd, uint64_t data)\n{\n\twhile (__read_tohost())\n\t\t__check_fromhost();\n\t__write_tohost(TOHOST_CMD(dev, cmd, data));\n}\n\nstatic int set_custom_addr(bool custom_addr,\n\t\t\t   unsigned long custom_fromhost_addr,\n\t\t\t   unsigned long custom_tohost_addr)\n{\n\tif (custom_addr) {\n\t\tif (htif_custom &&\n\t\t    ((custom_fromhost_addr != (unsigned long)htif_fromhost) ||\n\t\t     (custom_tohost_addr != (unsigned long)htif_tohost)))\n\t\t\treturn SBI_EINVAL;\n\t\thtif_fromhost = (uint64_t *)custom_fromhost_addr;\n\t\thtif_tohost = (uint64_t *)custom_tohost_addr;\n\t\thtif_custom = true;\n\t}\n\n\treturn 0;\n}\n\n#if __riscv_xlen == 32\nstatic void do_tohost_fromhost(uint64_t dev, uint64_t cmd, uint64_t data)\n{\n\tspin_lock(&htif_lock);\n\n\t__set_tohost(HTIF_DEV_SYSTEM, cmd, data);\n\n\twhile (1) {\n\t\tuint64_t fh = fromhost;\n\t\tif (fh) {\n\t\t\tif (FROMHOST_DEV(fh) == HTIF_DEV_SYSTEM &&\n\t\t\t    FROMHOST_CMD(fh) == cmd) {\n\t\t\t\tfromhost = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t__check_fromhost();\n\t\t}\n\t}\n\n\tspin_unlock(&htif_lock);\n}\n\nstatic void htif_putc(char ch)\n{\n\t/* HTIF devices are not supported on RV32, so do a proxy write call */\n\tvolatile uint64_t magic_mem[8];\n\tmagic_mem[0] = PK_SYS_write;\n\tmagic_mem[1] = HTIF_DEV_CONSOLE;\n\tmagic_mem[2] = (uint64_t)(uintptr_t)&ch;\n\tmagic_mem[3] = HTIF_CONSOLE_CMD_PUTC;\n\tdo_tohost_fromhost(HTIF_DEV_SYSTEM, 0, (uint64_t)(uintptr_t)magic_mem);\n}\n#else\nstatic void htif_putc(char ch)\n{\n\tspin_lock(&htif_lock);\n\t__set_tohost(HTIF_DEV_CONSOLE, HTIF_CONSOLE_CMD_PUTC, ch);\n\tspin_unlock(&htif_lock);\n}\n#endif\n\nstatic int htif_getc(void)\n{\n\tint ch;\n\n#if __riscv_xlen == 32\n\t/* HTIF devices are not supported on RV32 */\n\treturn -1;\n#endif\n\n\tspin_lock(&htif_lock);\n\n\t__check_fromhost();\n\tch = htif_console_buf;\n\tif (ch >= 0) {\n\t\thtif_console_buf = -1;\n\t\t__set_tohost(HTIF_DEV_CONSOLE, HTIF_CONSOLE_CMD_GETC, 0);\n\t}\n\n\tspin_unlock(&htif_lock);\n\n\treturn ch - 1;\n}\n\nstatic struct sbi_console_device htif_console = {\n\t.name = \"htif\",\n\t.console_putc = htif_putc,\n\t.console_getc = htif_getc\n};\n\nint htif_serial_init(bool custom_addr,\n\t\t     unsigned long custom_fromhost_addr,\n\t\t     unsigned long custom_tohost_addr)\n{\n\tint rc;\n\n\trc = set_custom_addr(custom_addr, custom_fromhost_addr,\n\t\t\t     custom_tohost_addr);\n\tif (rc)\n\t\treturn rc;\n\n\tsbi_console_set_device(&htif_console);\n\treturn 0;\n}\n\nstatic int htif_system_reset_check(u32 type, u32 reason)\n{\n\treturn 1;\n}\n\nstatic void htif_system_reset(u32 type, u32 reason)\n{\n\twhile (1) {\n\t\t__write_fromhost(0);\n\t\t__write_tohost(1);\n\t}\n}\n\nstatic struct sbi_system_reset_device htif_reset = {\n\t.name = \"htif\",\n\t.system_reset_check = htif_system_reset_check,\n\t.system_reset = htif_system_reset\n};\n\nint htif_system_reset_init(bool custom_addr,\n\t\t\t   unsigned long custom_fromhost_addr,\n\t\t\t   unsigned long custom_tohost_addr)\n{\n\tint rc;\n\n\trc = set_custom_addr(custom_addr, custom_fromhost_addr,\n\t\t\t     custom_tohost_addr);\n\tif (rc)\n\t\treturn rc;\n\n\tsbi_system_reset_add_device(&htif_reset);\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/sys/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nlibsbiutils-objs-$(CONFIG_SYS_HTIF) += sys/htif.o\nlibsbiutils-objs-$(CONFIG_SYS_SIFIVE_TEST) += sys/sifive_test.o\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/sys/sifive_test.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-3-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_system.h>\n#include <sbi_utils/sys/sifive_test.h>\n\n#define FINISHER_FAIL\t\t0x3333\n#define FINISHER_PASS\t\t0x5555\n#define FINISHER_RESET\t\t0x7777\n\nstatic void *sifive_test_base;\n\nstatic int sifive_test_system_reset_check(u32 type, u32 reason)\n{\n\tswitch (type) {\n\tcase SBI_SRST_RESET_TYPE_SHUTDOWN:\n\tcase SBI_SRST_RESET_TYPE_COLD_REBOOT:\n\tcase SBI_SRST_RESET_TYPE_WARM_REBOOT:\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\nstatic void sifive_test_system_reset(u32 type, u32 reason)\n{\n\t/*\n\t * Tell the \"finisher\" that the simulation\n\t * was successful so that QEMU exits\n\t */\n\tswitch (type) {\n\tcase SBI_SRST_RESET_TYPE_SHUTDOWN:\n\t\tif (reason == SBI_SRST_RESET_REASON_NONE)\n\t\t\twritew(FINISHER_PASS, sifive_test_base);\n\t\telse\n\t\t\twritew(FINISHER_FAIL, sifive_test_base);\n\t\tbreak;\n\tcase SBI_SRST_RESET_TYPE_COLD_REBOOT:\n\tcase SBI_SRST_RESET_TYPE_WARM_REBOOT:\n\t\twritew(FINISHER_RESET, sifive_test_base);\n\t\tbreak;\n\t}\n}\n\nstatic struct sbi_system_reset_device sifive_test_reset = {\n\t.name = \"sifive_test\",\n\t.system_reset_check = sifive_test_system_reset_check,\n\t.system_reset = sifive_test_system_reset\n};\n\nint sifive_test_init(unsigned long base)\n{\n\tsifive_test_base = (void *)base;\n\tsbi_system_reset_add_device(&sifive_test_reset);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/timer/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nmenu \"Timer Device Support\"\n\nconfig FDT_TIMER\n\tbool \"FDT based timer drivers\"\n\tdepends on FDT\n\tdefault n\n\nif FDT_TIMER\n\nconfig FDT_TIMER_MTIMER\n\tbool \"ACLINT MTIMER FDT driver\"\n\tselect TIMER_MTIMER\n\tdefault n\n\nconfig FDT_TIMER_PLMT\n\tbool \"Andes PLMT FDT driver\"\n\tselect TIMER_PLMT\n\tdefault n\n\nendif\n\nconfig TIMER_MTIMER\n\tbool \"ACLINT MTIMER support\"\n\tdefault n\n\nconfig TIMER_PLMT\n\tbool \"Andes PLMT support\"\n\tdefault n\n\nendmenu\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/timer/aclint_mtimer.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_atomic.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_timer.h>\n#include <sbi_utils/timer/aclint_mtimer.h>\n\nstatic struct aclint_mtimer_data *mtimer_hartid2data[SBI_HARTMASK_MAX_BITS];\n\n#if __riscv_xlen != 32\nstatic u64 mtimer_time_rd64(volatile u64 *addr)\n{\n\treturn readq_relaxed(addr);\n}\n\nstatic void mtimer_time_wr64(bool timecmp, u64 value, volatile u64 *addr)\n{\n\twriteq_relaxed(value, addr);\n}\n#endif\n\nstatic u64 mtimer_time_rd32(volatile u64 *addr)\n{\n\tu32 lo, hi;\n\n\tdo {\n\t\thi = readl_relaxed((u32 *)addr + 1);\n\t\tlo = readl_relaxed((u32 *)addr);\n\t} while (hi != readl_relaxed((u32 *)addr + 1));\n\n\treturn ((u64)hi << 32) | (u64)lo;\n}\n\nstatic void mtimer_time_wr32(bool timecmp, u64 value, volatile u64 *addr)\n{\n\twritel_relaxed((timecmp) ? -1U : 0U, (void *)(addr));\n\twritel_relaxed((u32)(value >> 32), (char *)(addr) + 0x04);\n\twritel_relaxed((u32)value, (void *)(addr));\n}\n\nstatic u64 mtimer_value(void)\n{\n\tstruct aclint_mtimer_data *mt = mtimer_hartid2data[current_hartid()];\n\tu64 *time_val = (void *)mt->mtime_addr;\n\n\t/* Read MTIMER Time Value */\n\treturn mt->time_rd(time_val);\n}\n\nstatic void mtimer_event_stop(void)\n{\n\tu32 target_hart = current_hartid();\n\tstruct aclint_mtimer_data *mt = mtimer_hartid2data[target_hart];\n\tu64 *time_cmp = (void *)mt->mtimecmp_addr;\n\n\t/* Clear MTIMER Time Compare */\n\tmt->time_wr(true, -1ULL, &time_cmp[target_hart - mt->first_hartid]);\n}\n\nstatic void mtimer_event_start(u64 next_event)\n{\n\tu32 target_hart = current_hartid();\n\tstruct aclint_mtimer_data *mt = mtimer_hartid2data[target_hart];\n\tu64 *time_cmp = (void *)mt->mtimecmp_addr;\n\n\t/* Program MTIMER Time Compare */\n\tmt->time_wr(true, next_event,\n\t\t    &time_cmp[target_hart - mt->first_hartid]);\n}\n\nstatic struct sbi_timer_device mtimer = {\n\t.name = \"aclint-mtimer\",\n\t.timer_value = mtimer_value,\n\t.timer_event_start = mtimer_event_start,\n\t.timer_event_stop = mtimer_event_stop\n};\n\nvoid aclint_mtimer_sync(struct aclint_mtimer_data *mt)\n{\n\tu64 v1, v2, mv, delta;\n\tu64 *mt_time_val, *ref_time_val;\n\tstruct aclint_mtimer_data *reference;\n\n\t/* Sync-up non-shared MTIME if reference is available */\n\tif (mt->has_shared_mtime || !mt->time_delta_reference)\n\t\treturn;\n\n\treference = mt->time_delta_reference;\n\tmt_time_val = (void *)mt->mtime_addr;\n\tref_time_val = (void *)reference->mtime_addr;\n\tif (!atomic_raw_xchg_ulong(&mt->time_delta_computed, 1)) {\n\t\tv1 = mt->time_rd(mt_time_val);\n\t\tmv = reference->time_rd(ref_time_val);\n\t\tv2 = mt->time_rd(mt_time_val);\n\t\tdelta = mv - ((v1 / 2) + (v2 / 2));\n\t\tmt->time_wr(false, mt->time_rd(mt_time_val) + delta,\n\t\t\t    mt_time_val);\n\t}\n\n}\n\nvoid aclint_mtimer_set_reference(struct aclint_mtimer_data *mt,\n\t\t\t\t struct aclint_mtimer_data *ref)\n{\n\tif (!mt || !ref || mt == ref)\n\t\treturn;\n\n\tmt->time_delta_reference = ref;\n\tmt->time_delta_computed = 0;\n}\n\nint aclint_mtimer_warm_init(void)\n{\n\tu64 *mt_time_cmp;\n\tu32 target_hart = current_hartid();\n\tstruct aclint_mtimer_data *mt = mtimer_hartid2data[target_hart];\n\n\tif (!mt)\n\t\treturn SBI_ENODEV;\n\n\t/* Sync-up MTIME register */\n\taclint_mtimer_sync(mt);\n\n\t/* Clear Time Compare */\n\tmt_time_cmp = (void *)mt->mtimecmp_addr;\n\tmt->time_wr(true, -1ULL,\n\t\t    &mt_time_cmp[target_hart - mt->first_hartid]);\n\n\treturn 0;\n}\n\nint aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,\n\t\t\t    struct aclint_mtimer_data *reference)\n{\n\tu32 i;\n\tint rc;\n\n\t/* Sanity checks */\n\tif (!mt ||\n\t    (mt->hart_count && !mt->mtimecmp_size) ||\n\t    (mt->mtime_size && (mt->mtime_addr & (ACLINT_MTIMER_ALIGN - 1))) ||\n\t    (mt->mtime_size && (mt->mtime_size & (ACLINT_MTIMER_ALIGN - 1))) ||\n\t    (mt->mtimecmp_addr & (ACLINT_MTIMER_ALIGN - 1)) ||\n\t    (mt->mtimecmp_size & (ACLINT_MTIMER_ALIGN - 1)) ||\n\t    (mt->first_hartid >= SBI_HARTMASK_MAX_BITS) ||\n\t    (mt->hart_count > ACLINT_MTIMER_MAX_HARTS))\n\t\treturn SBI_EINVAL;\n\tif (reference && mt->mtime_freq != reference->mtime_freq)\n\t\treturn SBI_EINVAL;\n\n\t/* Initialize private data */\n\taclint_mtimer_set_reference(mt, reference);\n\tmt->time_rd = mtimer_time_rd32;\n\tmt->time_wr = mtimer_time_wr32;\n\n\t/* Override read/write accessors for 64bit MMIO */\n#if __riscv_xlen != 32\n\tif (mt->has_64bit_mmio) {\n\t\tmt->time_rd = mtimer_time_rd64;\n\t\tmt->time_wr = mtimer_time_wr64;\n\t}\n#endif\n\n\t/* Update MTIMER hartid table */\n\tfor (i = 0; i < mt->hart_count; i++)\n\t\tmtimer_hartid2data[mt->first_hartid + i] = mt;\n\n\tif (!mt->mtime_size) {\n\t\t/* Disable reading mtime when mtime is not available */\n\t\tmtimer.timer_value = NULL;\n\t}\n\n\t/* Add MTIMER regions to the root domain */\n\tif (mt->mtime_addr == (mt->mtimecmp_addr + mt->mtimecmp_size)) {\n\t\trc = sbi_domain_root_add_memrange(mt->mtimecmp_addr,\n\t\t\t\t\tmt->mtime_size + mt->mtimecmp_size,\n\t\t\t\t\tMTIMER_REGION_ALIGN,\n\t\t\t\t\tSBI_DOMAIN_MEMREGION_MMIO);\n\t\tif (rc)\n\t\t\treturn rc;\n\t} else if (mt->mtimecmp_addr == (mt->mtime_addr + mt->mtime_size)) {\n\t\trc = sbi_domain_root_add_memrange(mt->mtime_addr,\n\t\t\t\t\tmt->mtime_size + mt->mtimecmp_size,\n\t\t\t\t\tMTIMER_REGION_ALIGN,\n\t\t\t\t\tSBI_DOMAIN_MEMREGION_MMIO);\n\t\tif (rc)\n\t\t\treturn rc;\n\t} else {\n\t\trc = sbi_domain_root_add_memrange(mt->mtime_addr,\n\t\t\t\t\t\tmt->mtime_size, MTIMER_REGION_ALIGN,\n\t\t\t\t\t\tSBI_DOMAIN_MEMREGION_MMIO);\n\t\tif (rc)\n\t\t\treturn rc;\n\n\t\trc = sbi_domain_root_add_memrange(mt->mtimecmp_addr,\n\t\t\t\t\t\tmt->mtimecmp_size, MTIMER_REGION_ALIGN,\n\t\t\t\t\t\tSBI_DOMAIN_MEMREGION_MMIO);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\tmtimer.timer_freq = mt->mtime_freq;\n\tsbi_timer_set_device(&mtimer);\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/timer/andes_plmt.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Andes Technology Corporation\n *\n * Authors:\n *   Yu Chien Peter Lin <peterlin@andestech.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_domain.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_timer.h>\n#include <sbi_utils/timer/andes_plmt.h>\n\nstruct plmt_data plmt;\n\nstatic u64 plmt_timer_value(void)\n{\n#if __riscv_xlen == 64\n\treturn readq_relaxed(plmt.time_val);\n#else\n\tu32 lo, hi;\n\n\tdo {\n\t\thi = readl_relaxed((void *)plmt.time_val + 0x04);\n\t\tlo = readl_relaxed(plmt.time_val);\n\t} while (hi != readl_relaxed((void *)plmt.time_val + 0x04));\n\n\treturn ((u64)hi << 32) | (u64)lo;\n#endif\n}\n\nstatic void plmt_timer_event_stop(void)\n{\n\tu32 target_hart = current_hartid();\n\n\tif (plmt.hart_count <= target_hart)\n\t\tebreak();\n\n\t/* Clear PLMT Time Compare */\n#if __riscv_xlen == 64\n\twriteq_relaxed(-1ULL, &plmt.time_cmp[target_hart]);\n#else\n\twritel_relaxed(-1UL, &plmt.time_cmp[target_hart]);\n\twritel_relaxed(-1UL, (void *)(&plmt.time_cmp[target_hart]) + 0x04);\n#endif\n}\n\nstatic void plmt_timer_event_start(u64 next_event)\n{\n\tu32 target_hart = current_hartid();\n\n\tif (plmt.hart_count <= target_hart)\n\t\tebreak();\n\n\t/* Program PLMT Time Compare */\n#if __riscv_xlen == 64\n\twriteq_relaxed(next_event, &plmt.time_cmp[target_hart]);\n#else\n\tu32 mask = -1UL;\n\n\twritel_relaxed(next_event & mask, &plmt.time_cmp[target_hart]);\n\twritel_relaxed(next_event >> 32,\n\t\t       (void *)(&plmt.time_cmp[target_hart]) + 0x04);\n#endif\n}\n\nstatic struct sbi_timer_device plmt_timer = {\n\t.name\t\t   = \"andes_plmt\",\n\t.timer_freq\t   = DEFAULT_AE350_PLMT_FREQ,\n\t.timer_value\t   = plmt_timer_value,\n\t.timer_event_start = plmt_timer_event_start,\n\t.timer_event_stop  = plmt_timer_event_stop\n};\n\nint plmt_cold_timer_init(struct plmt_data *plmt)\n{\n\tint rc;\n\n\t/* Add PLMT region to the root domain */\n\trc = sbi_domain_root_add_memrange(\n\t\t(unsigned long)plmt->time_val, plmt->size, PLMT_REGION_ALIGN,\n\t\tSBI_DOMAIN_MEMREGION_MMIO | SBI_DOMAIN_MEMREGION_READABLE);\n\tif (rc)\n\t\treturn rc;\n\n\tplmt_timer.timer_freq = plmt->timer_freq;\n\n\tsbi_timer_set_device(&plmt_timer);\n\n\treturn 0;\n}\n\nint plmt_warm_timer_init(void)\n{\n\tif (!plmt.time_val)\n\t\treturn SBI_ENODEV;\n\n\tplmt_timer_event_stop();\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/timer/fdt_timer.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/timer/fdt_timer.h>\n\n/* List of FDT timer drivers generated at compile time */\nextern struct fdt_timer *fdt_timer_drivers[];\nextern unsigned long fdt_timer_drivers_size;\n\nstatic struct fdt_timer dummy = {\n\t.match_table = NULL,\n\t.cold_init = NULL,\n\t.warm_init = NULL,\n\t.exit = NULL,\n};\n\nstatic struct fdt_timer *current_driver = &dummy;\n\nvoid fdt_timer_exit(void)\n{\n\tif (current_driver->exit)\n\t\tcurrent_driver->exit();\n}\n\nstatic int fdt_timer_warm_init(void)\n{\n\tif (current_driver->warm_init)\n\t\treturn current_driver->warm_init();\n\treturn 0;\n}\n\nstatic int fdt_timer_cold_init(void)\n{\n\tint pos, noff, rc;\n\tstruct fdt_timer *drv;\n\tconst struct fdt_match *match;\n\tvoid *fdt = fdt_get_address();\n\n\tfor (pos = 0; pos < fdt_timer_drivers_size; pos++) {\n\t\tdrv = fdt_timer_drivers[pos];\n\n\t\tnoff = -1;\n\t\twhile ((noff = fdt_find_match(fdt, noff,\n\t\t\t\t\tdrv->match_table, &match)) >= 0) {\n\t\t\tif (drv->cold_init) {\n\t\t\t\trc = drv->cold_init(fdt, noff, match);\n\t\t\t\tif (rc == SBI_ENODEV)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (rc)\n\t\t\t\t\treturn rc;\n\t\t\t}\n\t\t\tcurrent_driver = drv;\n\t\t}\n\n\t\tif (current_driver != &dummy)\n\t\t\tbreak;\n\t}\n\n\treturn 0;\n}\n\nint fdt_timer_init(bool cold_boot)\n{\n\tint rc;\n\n\tif (cold_boot) {\n\t\trc = fdt_timer_cold_init();\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn fdt_timer_warm_init();\n}\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/timer/fdt_timer_drivers.carray",
    "content": "HEADER: sbi_utils/timer/fdt_timer.h\nTYPE: struct fdt_timer\nNAME: fdt_timer_drivers\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/timer/fdt_timer_mtimer.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <sbi/sbi_error.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/timer/fdt_timer.h>\n#include <sbi_utils/timer/aclint_mtimer.h>\n\n#define MTIMER_MAX_NR\t\t\t16\n\nstruct timer_mtimer_quirks {\n\tunsigned int\tmtime_offset;\n\tbool\t\thas_64bit_mmio;\n\tbool\t\twithout_mtime;\n};\n\nstatic unsigned long mtimer_count = 0;\nstatic struct aclint_mtimer_data mtimer[MTIMER_MAX_NR];\nstatic struct aclint_mtimer_data *mt_reference = NULL;\n\nstatic int timer_mtimer_cold_init(void *fdt, int nodeoff,\n\t\t\t\t  const struct fdt_match *match)\n{\n\tint i, rc;\n\tunsigned long addr[2], size[2];\n\tstruct aclint_mtimer_data *mt;\n\n\tif (MTIMER_MAX_NR <= mtimer_count)\n\t\treturn SBI_ENOSPC;\n\tmt = &mtimer[mtimer_count];\n\n\trc = fdt_parse_aclint_node(fdt, nodeoff, true,\n\t\t\t\t   &addr[0], &size[0], &addr[1], &size[1],\n\t\t\t\t   &mt->first_hartid, &mt->hart_count);\n\tif (rc)\n\t\treturn rc;\n\tmt->has_64bit_mmio = true;\n\tmt->has_shared_mtime = false;\n\n\trc = fdt_parse_timebase_frequency(fdt, &mt->mtime_freq);\n\tif (rc)\n\t\treturn rc;\n\n\tif (match->data) { /* SiFive CLINT */\n\t\tconst struct timer_mtimer_quirks *quirks = match->data;\n\n\t\t/* Set CLINT addresses */\n\t\tmt->mtimecmp_addr = addr[0] + ACLINT_DEFAULT_MTIMECMP_OFFSET;\n\t\tmt->mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE;\n\t\tif (!quirks->without_mtime) {\n\t\t\tmt->mtime_addr = addr[0] + ACLINT_DEFAULT_MTIME_OFFSET;\n\t\t\tmt->mtime_size = size[0] - mt->mtimecmp_size;\n\t\t\t/* Adjust MTIMER address and size for CLINT device */\n\t\t\tmt->mtime_addr += quirks->mtime_offset;\n\t\t\tmt->mtime_size -= quirks->mtime_offset;\n\t\t} else {\n\t\t\tmt->mtime_addr = mt->mtime_size = 0;\n\t\t}\n\t\tmt->mtimecmp_addr += quirks->mtime_offset;\n\t\t/* Apply additional CLINT quirks */\n\t\tmt->has_64bit_mmio = quirks->has_64bit_mmio;\n\t} else { /* RISC-V ACLINT MTIMER */\n\t\t/* Set ACLINT MTIMER addresses */\n\t\tmt->mtime_addr = addr[0];\n\t\tmt->mtime_size = size[0];\n\t\tmt->mtimecmp_addr = addr[1];\n\t\tmt->mtimecmp_size = size[1];\n\t}\n\n\t/* Check if MTIMER device has shared MTIME address */\n\tif (mt->mtime_size) {\n\t\tmt->has_shared_mtime = false;\n\t\tfor (i = 0; i < mtimer_count; i++) {\n\t\t\tif (mtimer[i].mtime_addr == mt->mtime_addr) {\n\t\t\t\tmt->has_shared_mtime = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t/* Assume shared time CSR */\n\t\tmt->has_shared_mtime = true;\n\t}\n\n\t/* Initialize the MTIMER device */\n\trc = aclint_mtimer_cold_init(mt, mt_reference);\n\tif (rc)\n\t\treturn rc;\n\n\t/*\n\t * Select first MTIMER device with no associated HARTs as our\n\t * reference MTIMER device. This is only a temporary strategy\n\t * of selecting reference MTIMER device. In future, we might\n\t * define an optional DT property or some other mechanism to\n\t * help us select the reference MTIMER device.\n\t */\n\tif (!mt->hart_count && !mt_reference) {\n\t\tmt_reference = mt;\n\t\t/*\n\t\t * Set reference for already propbed MTIMER devices\n\t\t * with non-shared MTIME\n\t\t */\n\t\tfor (i = 0; i < mtimer_count; i++)\n\t\t\tif (!mtimer[i].has_shared_mtime)\n\t\t\t\taclint_mtimer_set_reference(&mtimer[i], mt);\n\t}\n\n\t/* Explicitly sync-up MTIMER devices not associated with any HARTs */\n\tif (!mt->hart_count)\n\t\taclint_mtimer_sync(mt);\n\n\tmtimer_count++;\n\treturn 0;\n}\n\nstatic const struct timer_mtimer_quirks sifive_clint_quirks = {\n\t.mtime_offset\t= CLINT_MTIMER_OFFSET,\n\t.has_64bit_mmio\t= true,\n};\n\nstatic const struct timer_mtimer_quirks thead_clint_quirks = {\n\t.mtime_offset\t= CLINT_MTIMER_OFFSET,\n\t.without_mtime  = true,\n};\n\nstatic const struct fdt_match timer_mtimer_match[] = {\n\t{ .compatible = \"riscv,clint0\", .data = &sifive_clint_quirks },\n\t{ .compatible = \"sifive,clint0\", .data = &sifive_clint_quirks },\n\t{ .compatible = \"thead,c900-clint\", .data = &thead_clint_quirks },\n\t{ .compatible = \"riscv,aclint-mtimer\" },\n\t{ },\n};\n\nstruct fdt_timer fdt_timer_mtimer = {\n\t.match_table = timer_mtimer_match,\n\t.cold_init = timer_mtimer_cold_init,\n\t.warm_init = aclint_mtimer_warm_init,\n\t.exit = NULL,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/timer/fdt_timer_plmt.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Andes Technology Corporation\n *\n * Authors:\n *   Yu Chien Peter Lin <peterlin@andestech.com>\n */\n\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/timer/fdt_timer.h>\n#include <sbi_utils/timer/andes_plmt.h>\n\nextern struct plmt_data plmt;\n\nstatic int fdt_plmt_cold_timer_init(void *fdt, int nodeoff,\n\t\t\t\t    const struct fdt_match *match)\n{\n\tint rc;\n\tunsigned long plmt_base;\n\n\trc = fdt_parse_plmt_node(fdt, nodeoff, &plmt_base, &plmt.size,\n\t\t\t\t &plmt.hart_count);\n\tif (rc)\n\t\treturn rc;\n\n\tplmt.time_val = (u64 *)plmt_base;\n\tplmt.time_cmp = (u64 *)(plmt_base + 0x8);\n\n\trc = fdt_parse_timebase_frequency(fdt, &plmt.timer_freq);\n\tif (rc)\n\t\treturn rc;\n\n\trc = plmt_cold_timer_init(&plmt);\n\tif (rc)\n\t\treturn rc;\n\n\treturn 0;\n}\n\nstatic const struct fdt_match timer_plmt_match[] = {\n\t{ .compatible = \"andestech,plmt0\" },\n\t{},\n};\n\nstruct fdt_timer fdt_timer_plmt = {\n\t.match_table = timer_plmt_match,\n\t.cold_init   = fdt_plmt_cold_timer_init,\n\t.warm_init   = plmt_warm_timer_init,\n\t.exit\t     = NULL,\n};\n"
  },
  {
    "path": "ftpm-opensbi/lib/utils/timer/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2020 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\nlibsbiutils-objs-$(CONFIG_TIMER_MTIMER) += timer/aclint_mtimer.o\nlibsbiutils-objs-$(CONFIG_TIMER_PLMT) += timer/andes_plmt.o\n\nlibsbiutils-objs-$(CONFIG_FDT_TIMER) += timer/fdt_timer.o\nlibsbiutils-objs-$(CONFIG_FDT_TIMER) += timer/fdt_timer_drivers.o\n\ncarray-fdt_timer_drivers-$(CONFIG_FDT_TIMER_MTIMER) += fdt_timer_mtimer\nlibsbiutils-objs-$(CONFIG_FDT_TIMER_MTIMER) += timer/fdt_timer_mtimer.o\n\ncarray-fdt_timer_drivers-$(CONFIG_FDT_TIMER_PLMT) += fdt_timer_plmt\nlibsbiutils-objs-$(CONFIG_FDT_TIMER_PLMT) += timer/fdt_timer_plmt.o\n"
  },
  {
    "path": "ftpm-opensbi/platform/fpga/ariane/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nconfig PLATFORM_ARIANE_FPGA\n\tbool\n\tselect FDT\n\tselect IPI_MSWI\n\tselect IRQCHIP_PLIC\n\tselect SERIAL_UART8250\n\tselect TIMER_MTIMER\n\tdefault y\n"
  },
  {
    "path": "ftpm-opensbi/platform/fpga/ariane/configs/defconfig",
    "content": ""
  },
  {
    "path": "ftpm-opensbi/platform/fpga/ariane/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (C) 2019 FORTH-ICS/CARV\n#\t\tPanagiotis Peristerakis <perister@ics.forth.gr>\n#\n\n# Compiler flags\nplatform-cppflags-y =\nplatform-cflags-y =\nplatform-asflags-y =\nplatform-ldflags-y =\n\n# Object to build\nplatform-objs-y += platform.o\n\nPLATFORM_RISCV_XLEN = 64\n\n# Blobs to build\nFW_TEXT_START=0x80000000\nFW_JUMP=n\n\nifeq ($(PLATFORM_RISCV_XLEN), 32)\n # This needs to be 4MB aligned for 32-bit support\n FW_JUMP_ADDR=0x80400000\n else\n # This needs to be 2MB aligned for 64-bit support\n FW_JUMP_ADDR=0x80200000\n endif\nFW_JUMP_FDT_ADDR=0x82200000\n\n# Firmware with payload configuration.\nFW_PAYLOAD=y\n\nifeq ($(PLATFORM_RISCV_XLEN), 32)\n# This needs to be 4MB aligned for 32-bit support\n  FW_PAYLOAD_OFFSET=0x400000\nelse\n# This needs to be 2MB aligned for 64-bit support\n  FW_PAYLOAD_OFFSET=0x200000\nendif\nFW_PAYLOAD_FDT_ADDR=0x82200000\nFW_PAYLOAD_ALIGN=0x1000\n"
  },
  {
    "path": "ftpm-opensbi/platform/fpga/ariane/platform.c",
    "content": "/* SPDX-License-Identifier: BSD-2-Clause */\n/*\n * Copyright (C) 2019 FORTH-ICS/CARV\n *\t\t\t\tPanagiotis Peristerakis <perister@ics.forth.gr>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_const.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_platform.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n#include <sbi_utils/ipi/aclint_mswi.h>\n#include <sbi_utils/irqchip/plic.h>\n#include <sbi_utils/serial/uart8250.h>\n#include <sbi_utils/timer/aclint_mtimer.h>\n\n#define ARIANE_UART_ADDR\t\t\t0x10000000\n#define ARIANE_UART_FREQ\t\t\t50000000\n#define ARIANE_UART_BAUDRATE\t\t\t115200\n#define ARIANE_UART_REG_SHIFT\t\t\t2\n#define ARIANE_UART_REG_WIDTH\t\t\t4\n#define ARIANE_UART_REG_OFFSET\t\t\t0\n#define ARIANE_PLIC_ADDR\t\t\t0xc000000\n#define ARIANE_PLIC_NUM_SOURCES\t\t\t3\n#define ARIANE_HART_COUNT\t\t\t1\n#define ARIANE_CLINT_ADDR\t\t\t0x2000000\n#define ARIANE_ACLINT_MTIMER_FREQ\t\t1000000\n#define ARIANE_ACLINT_MSWI_ADDR\t\t\t(ARIANE_CLINT_ADDR + \\\n\t\t\t\t\t\t CLINT_MSWI_OFFSET)\n#define ARIANE_ACLINT_MTIMER_ADDR\t\t(ARIANE_CLINT_ADDR + \\\n\t\t\t\t\t\t CLINT_MTIMER_OFFSET)\n\nstatic struct plic_data plic = {\n\t.addr = ARIANE_PLIC_ADDR,\n\t.num_src = ARIANE_PLIC_NUM_SOURCES,\n};\n\nstatic struct aclint_mswi_data mswi = {\n\t.addr = ARIANE_ACLINT_MSWI_ADDR,\n\t.size = ACLINT_MSWI_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = ARIANE_HART_COUNT,\n};\n\nstatic struct aclint_mtimer_data mtimer = {\n\t.mtime_freq = ARIANE_ACLINT_MTIMER_FREQ,\n\t.mtime_addr = ARIANE_ACLINT_MTIMER_ADDR +\n\t\t      ACLINT_DEFAULT_MTIME_OFFSET,\n\t.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,\n\t.mtimecmp_addr = ARIANE_ACLINT_MTIMER_ADDR +\n\t\t\t ACLINT_DEFAULT_MTIMECMP_OFFSET,\n\t.mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = ARIANE_HART_COUNT,\n\t.has_64bit_mmio = TRUE,\n};\n\n/*\n * Ariane platform early initialization.\n */\nstatic int ariane_early_init(bool cold_boot)\n{\n\t/* For now nothing to do. */\n\treturn 0;\n}\n\n/*\n * Ariane platform final initialization.\n */\nstatic int ariane_final_init(bool cold_boot)\n{\n\tvoid *fdt;\n\n\tif (!cold_boot)\n\t\treturn 0;\n\n\tfdt = fdt_get_address();\n\tfdt_fixups(fdt);\n\n\treturn 0;\n}\n\n/*\n * Initialize the ariane console.\n */\nstatic int ariane_console_init(void)\n{\n\treturn uart8250_init(ARIANE_UART_ADDR,\n\t\t\t     ARIANE_UART_FREQ,\n\t\t\t     ARIANE_UART_BAUDRATE,\n\t\t\t     ARIANE_UART_REG_SHIFT,\n\t\t\t     ARIANE_UART_REG_WIDTH,\n\t\t\t     ARIANE_UART_REG_OFFSET);\n}\n\nstatic int plic_ariane_warm_irqchip_init(int m_cntx_id, int s_cntx_id)\n{\n\tint ret;\n\n\t/* By default, enable all IRQs for M-mode of target HART */\n\tif (m_cntx_id > -1) {\n\t\tret = plic_context_init(&plic, m_cntx_id, true, 0x1);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\t/* Enable all IRQs for S-mode of target HART */\n\tif (s_cntx_id > -1) {\n\t\tret = plic_context_init(&plic, s_cntx_id, true, 0x0);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\n/*\n * Initialize the ariane interrupt controller for current HART.\n */\nstatic int ariane_irqchip_init(bool cold_boot)\n{\n\tu32 hartid = current_hartid();\n\tint ret;\n\n\tif (cold_boot) {\n\t\tret = plic_cold_irqchip_init(&plic);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\treturn plic_ariane_warm_irqchip_init(2 * hartid, 2 * hartid + 1);\n}\n\n/*\n * Initialize IPI for current HART.\n */\nstatic int ariane_ipi_init(bool cold_boot)\n{\n\tint ret;\n\n\tif (cold_boot) {\n\t\tret = aclint_mswi_cold_init(&mswi);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn aclint_mswi_warm_init();\n}\n\n/*\n * Initialize ariane timer for current HART.\n */\nstatic int ariane_timer_init(bool cold_boot)\n{\n\tint ret;\n\n\tif (cold_boot) {\n\t\tret = aclint_mtimer_cold_init(&mtimer, NULL);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn aclint_mtimer_warm_init();\n}\n\n/*\n * Platform descriptor.\n */\nconst struct sbi_platform_operations platform_ops = {\n\t.early_init = ariane_early_init,\n\t.final_init = ariane_final_init,\n\t.console_init = ariane_console_init,\n\t.irqchip_init = ariane_irqchip_init,\n\t.ipi_init = ariane_ipi_init,\n\t.timer_init = ariane_timer_init,\n};\n\nconst struct sbi_platform platform = {\n\t.opensbi_version = OPENSBI_VERSION,\n\t.platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),\n\t.name = \"ARIANE RISC-V\",\n\t.features = SBI_PLATFORM_DEFAULT_FEATURES,\n\t.hart_count = ARIANE_HART_COUNT,\n\t.hart_stack_size = SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,\n\t.platform_ops_addr = (unsigned long)&platform_ops\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/fpga/openpiton/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nconfig PLATFORM_OPENPITON_FPGA\n\tbool\n\tselect FDT\n\tselect IPI_MSWI\n\tselect IRQCHIP_PLIC\n\tselect SERIAL_UART8250\n\tselect TIMER_MTIMER\n\tdefault y\n"
  },
  {
    "path": "ftpm-opensbi/platform/fpga/openpiton/configs/defconfig",
    "content": ""
  },
  {
    "path": "ftpm-opensbi/platform/fpga/openpiton/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2020 Western Digital Corporation or its affiliates.\n#\n\n# Compiler flags\nplatform-cppflags-y =\nplatform-cflags-y =\nplatform-asflags-y =\nplatform-ldflags-y =\n\n# Objects to build\nplatform-objs-y += platform.o\n\nPLATFORM_RISCV_XLEN = 64\n\n# Blobs to build\nFW_TEXT_START=0x80000000\nFW_JUMP=n\n\nifeq ($(PLATFORM_RISCV_XLEN), 32)\n # This needs to be 4MB aligned for 32-bit support\n FW_JUMP_ADDR=0x80400000\n else\n # This needs to be 2MB aligned for 64-bit support\n FW_JUMP_ADDR=0x80200000\n endif\nFW_JUMP_FDT_ADDR=0x82200000\n\n# Firmware with payload configuration.\nFW_PAYLOAD=y\n\nifeq ($(PLATFORM_RISCV_XLEN), 32)\n# This needs to be 4MB aligned for 32-bit support\n  FW_PAYLOAD_OFFSET=0x400000\nelse\n# This needs to be 2MB aligned for 64-bit support\n  FW_PAYLOAD_OFFSET=0x200000\nendif\nFW_PAYLOAD_FDT_ADDR=0x82200000\nFW_PAYLOAD_ALIGN=0x1000\n"
  },
  {
    "path": "ftpm-opensbi/platform/fpga/openpiton/platform.c",
    "content": "// SPDX-License-Identifier: BSD-2-Clause\n/*\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_const.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_platform.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n#include <sbi_utils/ipi/aclint_mswi.h>\n#include <sbi_utils/irqchip/plic.h>\n#include <sbi_utils/serial/uart8250.h>\n#include <sbi_utils/timer/aclint_mtimer.h>\n\n#define OPENPITON_DEFAULT_UART_ADDR\t\t0xfff0c2c000\n#define OPENPITON_DEFAULT_UART_FREQ\t\t60000000\n#define OPENPITON_DEFAULT_UART_BAUDRATE\t\t115200\n#define OPENPITON_DEFAULT_UART_REG_SHIFT\t0\n#define OPENPITON_DEFAULT_UART_REG_WIDTH\t1\n#define OPENPITON_DEFAULT_UART_REG_OFFSET\t0\n#define OPENPITON_DEFAULT_PLIC_ADDR\t\t0xfff1100000\n#define OPENPITON_DEFAULT_PLIC_NUM_SOURCES\t2\n#define OPENPITON_DEFAULT_HART_COUNT\t\t3\n#define OPENPITON_DEFAULT_CLINT_ADDR\t\t0xfff1020000\n#define OPENPITON_DEFAULT_ACLINT_MTIMER_FREQ\t1000000\n#define OPENPITON_DEFAULT_ACLINT_MSWI_ADDR\t\\\n\t\t(OPENPITON_DEFAULT_CLINT_ADDR + CLINT_MSWI_OFFSET)\n#define OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR\t\\\n\t\t(OPENPITON_DEFAULT_CLINT_ADDR + CLINT_MTIMER_OFFSET)\n\nstatic struct platform_uart_data uart = {\n\tOPENPITON_DEFAULT_UART_ADDR,\n\tOPENPITON_DEFAULT_UART_FREQ,\n\tOPENPITON_DEFAULT_UART_BAUDRATE,\n};\nstatic struct plic_data plic = {\n\t.addr = OPENPITON_DEFAULT_PLIC_ADDR,\n\t.num_src = OPENPITON_DEFAULT_PLIC_NUM_SOURCES,\n};\n\nstatic struct aclint_mswi_data mswi = {\n\t.addr = OPENPITON_DEFAULT_ACLINT_MSWI_ADDR,\n\t.size = ACLINT_MSWI_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = OPENPITON_DEFAULT_HART_COUNT,\n};\n\nstatic struct aclint_mtimer_data mtimer = {\n\t.mtime_freq = OPENPITON_DEFAULT_ACLINT_MTIMER_FREQ,\n\t.mtime_addr = OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR +\n\t\t      ACLINT_DEFAULT_MTIME_OFFSET,\n\t.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,\n\t.mtimecmp_addr = OPENPITON_DEFAULT_ACLINT_MTIMER_ADDR +\n\t\t\t ACLINT_DEFAULT_MTIMECMP_OFFSET,\n\t.mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = OPENPITON_DEFAULT_HART_COUNT,\n\t.has_64bit_mmio = TRUE,\n};\n\n/*\n * OpenPiton platform early initialization.\n */\nstatic int openpiton_early_init(bool cold_boot)\n{\n\tvoid *fdt;\n\tstruct platform_uart_data uart_data = { 0 };\n\tstruct plic_data plic_data;\n\tunsigned long aclint_freq;\n\tuint64_t clint_addr;\n\tint rc;\n\n\tif (!cold_boot)\n\t\treturn 0;\n\tfdt = fdt_get_address();\n\n\trc = fdt_parse_uart8250(fdt, &uart_data, \"ns16550\");\n\tif (!rc)\n\t\tuart = uart_data;\n\n\trc = fdt_parse_plic(fdt, &plic_data, \"riscv,plic0\");\n\tif (!rc)\n\t\tplic = plic_data;\n\n\trc = fdt_parse_timebase_frequency(fdt, &aclint_freq);\n\tif (!rc)\n\t\tmtimer.mtime_freq = aclint_freq;\n\n\trc = fdt_parse_compat_addr(fdt, &clint_addr, \"riscv,clint0\");\n\tif (!rc) {\n\t\tmswi.addr = clint_addr;\n\t\tmtimer.mtime_addr = clint_addr + CLINT_MTIMER_OFFSET +\n\t\t\t\t    ACLINT_DEFAULT_MTIME_OFFSET;\n\t\tmtimer.mtimecmp_addr = clint_addr + CLINT_MTIMER_OFFSET +\n\t\t\t\t    ACLINT_DEFAULT_MTIMECMP_OFFSET;\n\t}\n\n\treturn 0;\n}\n\n/*\n * OpenPiton platform final initialization.\n */\nstatic int openpiton_final_init(bool cold_boot)\n{\n\tvoid *fdt;\n\n\tif (!cold_boot)\n\t\treturn 0;\n\n\tfdt = fdt_get_address();\n\tfdt_fixups(fdt);\n\n\treturn 0;\n}\n\n/*\n * Initialize the openpiton console.\n */\nstatic int openpiton_console_init(void)\n{\n\treturn uart8250_init(uart.addr,\n\t\t\t     uart.freq,\n\t\t\t     uart.baud,\n\t\t\t     OPENPITON_DEFAULT_UART_REG_SHIFT,\n\t\t\t     OPENPITON_DEFAULT_UART_REG_WIDTH,\n\t\t\t     OPENPITON_DEFAULT_UART_REG_OFFSET);\n}\n\nstatic int plic_openpiton_warm_irqchip_init(int m_cntx_id, int s_cntx_id)\n{\n\tint ret;\n\n\t/* By default, enable all IRQs for M-mode of target HART */\n\tif (m_cntx_id > -1) {\n\t\tret = plic_context_init(&plic, m_cntx_id, true, 0x1);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\t/* Enable all IRQs for S-mode of target HART */\n\tif (s_cntx_id > -1) {\n\t\tret = plic_context_init(&plic, s_cntx_id, true, 0x0);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}\n\n/*\n * Initialize the openpiton interrupt controller for current HART.\n */\nstatic int openpiton_irqchip_init(bool cold_boot)\n{\n\tu32 hartid = current_hartid();\n\tint ret;\n\n\tif (cold_boot) {\n\t\tret = plic_cold_irqchip_init(&plic);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\treturn plic_openpiton_warm_irqchip_init(2 * hartid, 2 * hartid + 1);\n}\n\n/*\n * Initialize IPI for current HART.\n */\nstatic int openpiton_ipi_init(bool cold_boot)\n{\n\tint ret;\n\n\tif (cold_boot) {\n\t\tret = aclint_mswi_cold_init(&mswi);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn aclint_mswi_warm_init();\n}\n\n/*\n * Initialize openpiton timer for current HART.\n */\nstatic int openpiton_timer_init(bool cold_boot)\n{\n\tint ret;\n\n\tif (cold_boot) {\n\t\tret = aclint_mtimer_cold_init(&mtimer, NULL);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn aclint_mtimer_warm_init();\n}\n\n/*\n * Platform descriptor.\n */\nconst struct sbi_platform_operations platform_ops = {\n\t.early_init = openpiton_early_init,\n\t.final_init = openpiton_final_init,\n\t.console_init = openpiton_console_init,\n\t.irqchip_init = openpiton_irqchip_init,\n\t.ipi_init = openpiton_ipi_init,\n\t.timer_init = openpiton_timer_init,\n};\n\nconst struct sbi_platform platform = {\n\t.opensbi_version = OPENSBI_VERSION,\n\t.platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),\n\t.name = \"OPENPITON RISC-V\",\n\t.features = SBI_PLATFORM_DEFAULT_FEATURES,\n\t.hart_count = OPENPITON_DEFAULT_HART_COUNT,\n\t.hart_stack_size = SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,\n\t.platform_ops_addr = (unsigned long)&platform_ops\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nconfig PLATFORM_GENERIC\n\tbool\n\tselect FDT\n\tselect FDT_DOMAIN\n\tselect FDT_PMU\n\tdefault y\n\nif PLATFORM_GENERIC\n\nconfig PLATFORM_GENERIC_NAME\n\tstring \"Platform default name\"\n\tdefault \"Generic\"\n\nconfig PLATFORM_GENERIC_MAJOR_VER\n\tint \"Platform major version\"\n\trange 0 65535\n\tdefault 0\n\nconfig PLATFORM_GENERIC_MINOR_VER\n\tint \"Platform minor version\"\n\trange 0 65535\n\tdefault 1\n\nconfig PLATFORM_ALLWINNER_D1\n\tbool \"Allwinner D1 support\"\n\tdepends on FDT_IRQCHIP_PLIC\n\tdefault n\n\nconfig PLATFORM_ANDES_AE350\n\tbool \"Andes AE350 support\"\n\tdefault n\n\nconfig PLATFORM_RENESAS_RZFIVE\n\tbool \"Renesas RZ/Five support\"\n\tdefault n\n\nconfig PLATFORM_SIFIVE_FU540\n\tbool \"SiFive FU540 support\"\n\tdefault n\n\nconfig PLATFORM_SIFIVE_FU740\n\tbool \"SiFive FU740 support\"\n\tdepends on FDT_RESET && FDT_I2C\n\tdefault n\n\nconfig PLATFORM_VIVADO_RISC_V\n\tbool\n\tselect FDT\n\tselect IPI_MSWI\n\tselect IRQCHIP_PLIC\n\tselect TIMER_MTIMER\n        select FDT_TIMER\n\tdefault y\n\nendif\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/allwinner/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n\ncarray-platform_override_modules-$(CONFIG_PLATFORM_ALLWINNER_D1) += sun20i_d1\nplatform-objs-$(CONFIG_PLATFORM_ALLWINNER_D1) += allwinner/sun20i-d1.o\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/allwinner/sun20i-d1.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Samuel Holland <samuel@sholland.org>\n */\n\n#include <platform_override.h>\n#include <thead_c9xx.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_bitops.h>\n#include <sbi/sbi_ecall_interface.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hsm.h>\n#include <sbi/sbi_pmu.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/irqchip/fdt_irqchip_plic.h>\n\n#define SUN20I_D1_CCU_BASE\t\t((void *)0x02001000)\n#define SUN20I_D1_RISCV_CFG_BASE\t((void *)0x06010000)\n#define SUN20I_D1_PPU_BASE\t\t((void *)0x07001000)\n#define SUN20I_D1_PRCM_BASE\t\t((void *)0x07010000)\n\n/*\n * CCU\n */\n\n#define CCU_BGR_ENABLE\t\t\t(BIT(16) | BIT(0))\n\n#define RISCV_CFG_BGR_REG\t\t0xd0c\n#define PPU_BGR_REG\t\t\t0x1ac\n\n/*\n * CSRs\n */\n\n#define CSR_MXSTATUS\t\t\t0x7c0\n#define CSR_MHCR\t\t\t0x7c1\n#define CSR_MCOR\t\t\t0x7c2\n#define CSR_MHINT\t\t\t0x7c5\n\nstatic unsigned long csr_mxstatus;\nstatic unsigned long csr_mhcr;\nstatic unsigned long csr_mhint;\n\nstatic void sun20i_d1_csr_save(void)\n{\n\t/* Save custom CSRs. */\n\tcsr_mxstatus\t= csr_read(CSR_MXSTATUS);\n\tcsr_mhcr\t= csr_read(CSR_MHCR);\n\tcsr_mhint\t= csr_read(CSR_MHINT);\n\n\t/* Flush and disable caches. */\n\tcsr_write(CSR_MCOR, 0x22);\n\tcsr_write(CSR_MHCR, 0x0);\n}\n\nstatic void sun20i_d1_csr_restore(void)\n{\n\t/* Invalidate caches and the branch predictor. */\n\tcsr_write(CSR_MCOR, 0x70013);\n\n\t/* Restore custom CSRs, including the cache state. */\n\tcsr_write(CSR_MXSTATUS,\tcsr_mxstatus);\n\tcsr_write(CSR_MHCR,\tcsr_mhcr);\n\tcsr_write(CSR_MHINT,\tcsr_mhint);\n}\n\n/*\n * PLIC\n */\n\n#define PLIC_SOURCES\t\t\t176\n#define PLIC_IE_WORDS\t\t\t((PLIC_SOURCES + 31) / 32)\n\nstatic u8 plic_priority[PLIC_SOURCES];\nstatic u32 plic_sie[PLIC_IE_WORDS];\nstatic u32 plic_threshold;\n\nstatic void sun20i_d1_plic_save(void)\n{\n\tfdt_plic_context_save(true, plic_sie, &plic_threshold, PLIC_IE_WORDS);\n\tfdt_plic_priority_save(plic_priority, PLIC_SOURCES);\n}\n\nstatic void sun20i_d1_plic_restore(void)\n{\n\tthead_plic_restore();\n\tfdt_plic_priority_restore(plic_priority, PLIC_SOURCES);\n\tfdt_plic_context_restore(true, plic_sie, plic_threshold,\n\t\t\t\t PLIC_IE_WORDS);\n}\n\n/*\n * PPU\n */\n\n#define PPU_PD_ACTIVE_CTRL\t\t0x2c\n\nstatic void sun20i_d1_ppu_save(void)\n{\n\t/* Enable MMIO access. Do not assume S-mode leaves the clock enabled. */\n\twritel_relaxed(CCU_BGR_ENABLE, SUN20I_D1_PRCM_BASE + PPU_BGR_REG);\n\n\t/* Activate automatic power-down during the next WFI. */\n\twritel_relaxed(1, SUN20I_D1_PPU_BASE + PPU_PD_ACTIVE_CTRL);\n}\n\nstatic void sun20i_d1_ppu_restore(void)\n{\n\t/* Disable automatic power-down. */\n\twritel_relaxed(0, SUN20I_D1_PPU_BASE + PPU_PD_ACTIVE_CTRL);\n}\n\n/*\n * RISCV_CFG\n */\n\n#define RESET_ENTRY_LO_REG\t\t0x0004\n#define RESET_ENTRY_HI_REG\t\t0x0008\n#define WAKEUP_EN_REG\t\t\t0x0020\n#define WAKEUP_MASK_REG(i)\t\t(0x0024 + 4 * (i))\n\nstatic void sun20i_d1_riscv_cfg_save(void)\n{\n\t/* Enable MMIO access. Do not assume S-mode leaves the clock enabled. */\n\twritel_relaxed(CCU_BGR_ENABLE, SUN20I_D1_CCU_BASE + RISCV_CFG_BGR_REG);\n\n\t/*\n\t * Copy the SIE bits to the wakeup registers. D1 has 160 \"real\"\n\t * interrupt sources, numbered 16-175. These are the ones that map to\n\t * the wakeup mask registers (the offset is for GIC compatibility). So\n\t * copying SIE to the wakeup mask needs some bit manipulation.\n\t */\n\tfor (int i = 0; i < PLIC_IE_WORDS - 1; i++)\n\t\twritel_relaxed(plic_sie[i] >> 16 | plic_sie[i + 1] << 16,\n\t\t\t       SUN20I_D1_RISCV_CFG_BASE + WAKEUP_MASK_REG(i));\n\n\t/* Enable PPU wakeup for interrupts. */\n\twritel_relaxed(1, SUN20I_D1_RISCV_CFG_BASE + WAKEUP_EN_REG);\n}\n\nstatic void sun20i_d1_riscv_cfg_restore(void)\n{\n\t/* Disable PPU wakeup for interrupts. */\n\twritel_relaxed(0, SUN20I_D1_RISCV_CFG_BASE + WAKEUP_EN_REG);\n}\n\nstatic void sun20i_d1_riscv_cfg_init(void)\n{\n\tu64 entry = sbi_hartid_to_scratch(0)->warmboot_addr;\n\n\t/* Enable MMIO access. */\n\twritel_relaxed(CCU_BGR_ENABLE, SUN20I_D1_CCU_BASE + RISCV_CFG_BGR_REG);\n\n\t/* Program the reset entry address. */\n\twritel_relaxed(entry, SUN20I_D1_RISCV_CFG_BASE + RESET_ENTRY_LO_REG);\n\twritel_relaxed(entry >> 32, SUN20I_D1_RISCV_CFG_BASE + RESET_ENTRY_HI_REG);\n}\n\nstatic int sun20i_d1_hart_suspend(u32 suspend_type)\n{\n\t/* Use the generic code for retentive suspend. */\n\tif (!(suspend_type & SBI_HSM_SUSP_NON_RET_BIT))\n\t\treturn SBI_ENOTSUPP;\n\n\tsun20i_d1_plic_save();\n\tsun20i_d1_ppu_save();\n\tsun20i_d1_riscv_cfg_save();\n\tsun20i_d1_csr_save();\n\n\t/*\n\t * If no interrupt is pending, this will power down the CPU power\n\t * domain. Otherwise, this will fall through, and the generic HSM\n\t * code will jump to the resume address.\n\t */\n\twfi();\n\n\treturn 0;\n}\n\nstatic void sun20i_d1_hart_resume(void)\n{\n\tsun20i_d1_csr_restore();\n\tsun20i_d1_riscv_cfg_restore();\n\tsun20i_d1_ppu_restore();\n\tsun20i_d1_plic_restore();\n}\n\nstatic const struct sbi_hsm_device sun20i_d1_ppu = {\n\t.name\t\t= \"sun20i-d1-ppu\",\n\t.hart_suspend\t= sun20i_d1_hart_suspend,\n\t.hart_resume\t= sun20i_d1_hart_resume,\n};\n\nstatic int sun20i_d1_final_init(bool cold_boot, const struct fdt_match *match)\n{\n\tif (cold_boot) {\n\t\tsun20i_d1_riscv_cfg_init();\n\t\tsbi_hsm_set_device(&sun20i_d1_ppu);\n\t}\n\n\treturn 0;\n}\n\nstatic void thead_c9xx_pmu_ctr_enable_irq(uint32_t ctr_idx)\n{\n\tunsigned long mip_val;\n\n\tif (ctr_idx >= SBI_PMU_HW_CTR_MAX)\n\t\treturn;\n\n\tmip_val = csr_read(CSR_MIP);\n\t/**\n\t * Clear out the OF bit so that next interrupt can be enabled.\n\t * This should be done only when the corresponding overflow interrupt\n\t * bit is cleared. That indicates that software has already handled the\n\t * previous interrupts or the hardware yet to set an overflow interrupt.\n\t * Otherwise, there will be race conditions where we may clear the bit\n\t * the software is yet to handle the interrupt.\n\t */\n\tif (!(mip_val & THEAD_C9XX_MIP_MOIP))\n\t\tcsr_clear(THEAD_C9XX_CSR_MCOUNTEROF, BIT(ctr_idx));\n\n\t/**\n\t * SSCOFPMF uses the OF bit for enabling/disabling the interrupt,\n\t * while the C9XX has designated enable bits.\n\t * So enable per-counter interrupt on C9xx here.\n\t */\n\tcsr_set(THEAD_C9XX_CSR_MCOUNTERINTEN, BIT(ctr_idx));\n}\n\nstatic void thead_c9xx_pmu_ctr_disable_irq(uint32_t ctr_idx)\n{\n\tcsr_clear(THEAD_C9XX_CSR_MCOUNTERINTEN, BIT(ctr_idx));\n}\n\nstatic int thead_c9xx_pmu_irq_bit(void)\n{\n\treturn THEAD_C9XX_MIP_MOIP;\n}\n\nconst struct sbi_pmu_device thead_c9xx_pmu_device = {\n\t.hw_counter_enable_irq = thead_c9xx_pmu_ctr_enable_irq,\n\t.hw_counter_disable_irq = thead_c9xx_pmu_ctr_disable_irq,\n\t.hw_counter_irq_bit = thead_c9xx_pmu_irq_bit,\n};\n\nstatic int sun20i_d1_extensions_init(const struct fdt_match *match,\n\t\t\t\t     struct sbi_hart_features *hfeatures)\n{\n\tsbi_pmu_set_device(&thead_c9xx_pmu_device);\n\n\t/* auto-detection doesn't work on t-head c9xx cores */\n\thfeatures->mhpm_count = 29;\n\thfeatures->mhpm_bits = 64;\n\n\treturn 0;\n}\n\nstatic const struct fdt_match sun20i_d1_match[] = {\n\t{ .compatible = \"allwinner,sun20i-d1\" },\n\t{ },\n};\n\nconst struct platform_override sun20i_d1 = {\n\t.match_table\t= sun20i_d1_match,\n\t.final_init\t= sun20i_d1_final_init,\n\t.extensions_init = sun20i_d1_extensions_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/andes/ae350.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2022 Andes Technology Corporation\n *\n * Authors:\n *   Yu Chien Peter Lin <peterlin@andestech.com>\n */\n\n#include <platform_override.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n\nstatic const struct fdt_match andes_ae350_match[] = {\n\t{ .compatible = \"andestech,ae350\" },\n\t{ },\n};\n\nconst struct platform_override andes_ae350 = {\n\t.match_table = andes_ae350_match,\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/andes/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n\ncarray-platform_override_modules-$(CONFIG_PLATFORM_ANDES_AE350) += andes_ae350\nplatform-objs-$(CONFIG_PLATFORM_ANDES_AE350) += andes/ae350.o\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/configs/defconfig",
    "content": "CONFIG_PLATFORM_ALLWINNER_D1=y\nCONFIG_PLATFORM_ANDES_AE350=y\nCONFIG_PLATFORM_RENESAS_RZFIVE=y\nCONFIG_PLATFORM_SIFIVE_FU540=y\nCONFIG_PLATFORM_SIFIVE_FU740=y\nCONFIG_FDT_GPIO=y\nCONFIG_FDT_GPIO_SIFIVE=y\nCONFIG_FDT_I2C=y\nCONFIG_FDT_I2C_SIFIVE=y\nCONFIG_FDT_IPI=y\nCONFIG_FDT_IPI_MSWI=y\nCONFIG_FDT_IPI_PLICSW=y\nCONFIG_FDT_IRQCHIP=y\nCONFIG_FDT_IRQCHIP_APLIC=y\nCONFIG_FDT_IRQCHIP_IMSIC=y\nCONFIG_FDT_IRQCHIP_PLIC=y\nCONFIG_FDT_RESET=y\nCONFIG_FDT_RESET_ATCWDT200=y\nCONFIG_FDT_RESET_GPIO=y\nCONFIG_FDT_RESET_HTIF=y\nCONFIG_FDT_RESET_SIFIVE_TEST=y\nCONFIG_FDT_RESET_SUNXI_WDT=y\nCONFIG_FDT_RESET_THEAD=y\nCONFIG_FDT_SERIAL=y\nCONFIG_FDT_SERIAL_CADENCE=y\nCONFIG_FDT_SERIAL_GAISLER=y\nCONFIG_FDT_SERIAL_HTIF=y\nCONFIG_FDT_SERIAL_RENESAS_SCIF=y\nCONFIG_FDT_SERIAL_SHAKTI=y\nCONFIG_FDT_SERIAL_SIFIVE=y\nCONFIG_FDT_SERIAL_LITEX=y\nCONFIG_FDT_SERIAL_UART8250=y\nCONFIG_FDT_SERIAL_XILINX_UARTLITE=y\nCONFIG_FDT_TIMER=y\nCONFIG_FDT_TIMER_MTIMER=y\nCONFIG_FDT_TIMER_PLMT=y\nCONFIG_SERIAL_SEMIHOSTING=y\n\n# \nCONFIG_PLATFORM_VIVADO_RISC_V=y\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/include/platform_override.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#ifndef __PLATFORM_OVERRIDE_H__\n#define __PLATFORM_OVERRIDE_H__\n\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_types.h>\n#include <sbi/sbi_trap.h>\n\nstruct platform_override {\n\tconst struct fdt_match *match_table;\n\tu64 (*features)(const struct fdt_match *match);\n\tu64 (*tlbr_flush_limit)(const struct fdt_match *match);\n\tint (*early_init)(bool cold_boot, const struct fdt_match *match);\n\tint (*final_init)(bool cold_boot, const struct fdt_match *match);\n\tvoid (*early_exit)(const struct fdt_match *match);\n\tvoid (*final_exit)(const struct fdt_match *match);\n\tint (*fdt_fixup)(void *fdt, const struct fdt_match *match);\n\tint (*extensions_init)(const struct fdt_match *match,\n\t\t\t       struct sbi_hart_features *hfeatures);\n\tint (*vendor_ext_check)(long extid, const struct fdt_match *match);\n\tint (*vendor_ext_provider)(long extid, long funcid,\n\t\t\t\t   const struct sbi_trap_regs *regs,\n\t\t\t\t   unsigned long *out_value,\n\t\t\t\t   struct sbi_trap_info *out_trap,\n\t\t\t\t   const struct fdt_match *match);\n};\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/include/thead_c9xx.h",
    "content": "#ifndef __RISCV_THEAD_C9XX_H____\n#define __RISCV_THEAD_C9XX_H____\n\n/* T-HEAD C9xx M mode CSR.  */\n#define THEAD_C9XX_CSR_MXSTATUS\t\t0x7c0\n#define THEAD_C9XX_CSR_MHCR\t\t0x7c1\n#define THEAD_C9XX_CSR_MCOR\t\t0x7c2\n#define THEAD_C9XX_CSR_MCCR2\t\t0x7c3\n#define THEAD_C9XX_CSR_MCER2\t\t0x7c4\n#define THEAD_C9XX_CSR_MHINT\t\t0x7c5\n#define THEAD_C9XX_CSR_MRMR\t\t0x7c6\n#define THEAD_C9XX_CSR_MRVBR\t\t0x7c7\n#define THEAD_C9XX_CSR_MCER\t\t0x7c8\n#define THEAD_C9XX_CSR_MCOUNTERWEN\t0x7c9\n#define THEAD_C9XX_CSR_MCOUNTERINTEN\t0x7ca\n#define THEAD_C9XX_CSR_MCOUNTEROF\t0x7cb\n#define THEAD_C9XX_CSR_MHINT2\t\t0x7cc\n#define THEAD_C9XX_CSR_MHINT3\t\t0x7cd\n#define THEAD_C9XX_CSR_MRADDR\t\t0x7e0\n#define THEAD_C9XX_CSR_MEXSTATUS\t0x7e1\n#define THEAD_C9XX_CSR_MNMICAUSE\t0x7e2\n#define THEAD_C9XX_CSR_MNMIPC\t\t0x7e3\n#define THEAD_C9XX_CSR_MHPMCR\t\t0x7f0\n#define THEAD_C9XX_CSR_MHPMSR\t\t0x7f1\n#define THEAD_C9XX_CSR_MHPMER\t\t0x7f2\n#define THEAD_C9XX_CSR_MSMPR\t\t0x7f3\n#define THEAD_C9XX_CSR_MTEECFG\t\t0x7f4\n#define THEAD_C9XX_CSR_MZONEID\t\t0x7f5\n#define THEAD_C9XX_CSR_ML2CPID\t\t0x7f6\n#define THEAD_C9XX_CSR_ML2WP\t\t0x7f7\n#define THEAD_C9XX_CSR_MDTCMCR\t\t0x7f8\n#define THEAD_C9XX_CSR_USP\t\t0x7d1\n#define THEAD_C9XX_CSR_MCINS\t\t0x7d2\n#define THEAD_C9XX_CSR_MCINDEX\t\t0x7d3\n#define THEAD_C9XX_CSR_MCDATA0\t\t0x7d4\n#define THEAD_C9XX_CSR_MCDATA1\t\t0x7d5\n#define THEAD_C9XX_CSR_MEICR\t\t0x7d6\n#define THEAD_C9XX_CSR_MEICR2\t\t0x7d7\n#define THEAD_C9XX_CSR_MBEADDR\t\t0x7d8\n#define THEAD_C9XX_CSR_MCPUID\t\t0xfc0\n#define THEAD_C9XX_CSR_MAPBADDR\t\t0xfc1\n#define THEAD_C9XX_CSR_MWMSR\t\t0xfc2\n#define THEAD_C9XX_CSR_MHALTCAUSE\t0xfe0\n#define THEAD_C9XX_CSR_MDBGINFO\t\t0xfe1\n#define THEAD_C9XX_CSR_MPCFIFO\t\t0xfe2\n\n/* T-HEAD C9xx S mode CSR.  */\n#define THEAD_C9XX_CSR_SXSTATUS\t\t0x5c0\n#define THEAD_C9XX_CSR_SHCR\t\t0x5c1\n#define THEAD_C9XX_CSR_SCER2\t\t0x5c2\n#define THEAD_C9XX_CSR_SCER\t\t0x5c3\n#define THEAD_C9XX_CSR_SCOUNTERINTEN\t0x5c4\n#define THEAD_C9XX_CSR_SCOUNTEROF\t0x5c5\n#define THEAD_C9XX_CSR_SHINT\t\t0x5c6\n#define THEAD_C9XX_CSR_SHINT2\t\t0x5c7\n#define THEAD_C9XX_CSR_SHPMINHIBIT\t0x5c8\n#define THEAD_C9XX_CSR_SHPMCR\t\t0x5c9\n#define THEAD_C9XX_CSR_SHPMSR\t\t0x5ca\n#define THEAD_C9XX_CSR_SHPMER\t\t0x5cb\n#define THEAD_C9XX_CSR_SL2CPID\t\t0x5cc\n#define THEAD_C9XX_CSR_SL2WP\t\t0x5cd\n#define THEAD_C9XX_CSR_SBEADDR\t\t0x5d0\n#define THEAD_C9XX_CSR_SCYCLE\t\t0x5e0\n#define THEAD_C9XX_CSR_SHPMCOUNTER1\t0x5e1\n#define THEAD_C9XX_CSR_SHPMCOUNTER2\t0x5e2\n#define THEAD_C9XX_CSR_SHPMCOUNTER3\t0x5e3\n#define THEAD_C9XX_CSR_SHPMCOUNTER4\t0x5e4\n#define THEAD_C9XX_CSR_SHPMCOUNTER5\t0x5e5\n#define THEAD_C9XX_CSR_SHPMCOUNTER6\t0x5e6\n#define THEAD_C9XX_CSR_SHPMCOUNTER7\t0x5e7\n#define THEAD_C9XX_CSR_SHPMCOUNTER8\t0x5e8\n#define THEAD_C9XX_CSR_SHPMCOUNTER9\t0x5e9\n#define THEAD_C9XX_CSR_SHPMCOUNTER10\t0x5ea\n#define THEAD_C9XX_CSR_SHPMCOUNTER11\t0x5eb\n#define THEAD_C9XX_CSR_SHPMCOUNTER12\t0x5ec\n#define THEAD_C9XX_CSR_SHPMCOUNTER13\t0x5ed\n#define THEAD_C9XX_CSR_SHPMCOUNTER14\t0x5ee\n#define THEAD_C9XX_CSR_SHPMCOUNTER15\t0x5ef\n#define THEAD_C9XX_CSR_SHPMCOUNTER16\t0x5f0\n#define THEAD_C9XX_CSR_SHPMCOUNTER17\t0x5f1\n#define THEAD_C9XX_CSR_SHPMCOUNTER18\t0x5f2\n#define THEAD_C9XX_CSR_SHPMCOUNTER19\t0x5f3\n#define THEAD_C9XX_CSR_SHPMCOUNTER20\t0x5f4\n#define THEAD_C9XX_CSR_SHPMCOUNTER21\t0x5f5\n#define THEAD_C9XX_CSR_SHPMCOUNTER22\t0x5f6\n#define THEAD_C9XX_CSR_SHPMCOUNTER23\t0x5f7\n#define THEAD_C9XX_CSR_SHPMCOUNTER24\t0x5f8\n#define THEAD_C9XX_CSR_SHPMCOUNTER25\t0x5f9\n#define THEAD_C9XX_CSR_SHPMCOUNTER26\t0x5fa\n#define THEAD_C9XX_CSR_SHPMCOUNTER27\t0x5fb\n#define THEAD_C9XX_CSR_SHPMCOUNTER28\t0x5fc\n#define THEAD_C9XX_CSR_SHPMCOUNTER29\t0x5fd\n#define THEAD_C9XX_CSR_SHPMCOUNTER30\t0x5fe\n#define THEAD_C9XX_CSR_SHPMCOUNTER31\t0x5ff\n\n/* T-HEAD C9xx U mode CSR.  */\n#define THEAD_C9XX_CSR_FXCR\t\t0x800\n\n/* T-HEAD C9xx MMU extentions.  */\n#define THEAD_C9XX_CSR_SMIR\t\t0x9c0\n#define THEAD_C9XX_CSR_SMEL\t\t0x9c1\n#define THEAD_C9XX_CSR_SMEH\t\t0x9c2\n#define THEAD_C9XX_CSR_SMCIR\t\t0x9c3\n\n/* T-HEAD C9xx Security CSR(May be droped).  */\n#define THEAD_C9XX_CSR_MEBR\t\t0xbe0\n#define THEAD_C9XX_CSR_NT_MSTATUS\t0xbe1\n#define THEAD_C9XX_CSR_NT_MIE\t\t0xbe2\n#define THEAD_C9XX_CSR_NT_MTVEC\t\t0xbe3\n#define THEAD_C9XX_CSR_NT_MTVT\t\t0xbe4\n#define THEAD_C9XX_CSR_NT_MEPC\t\t0xbe5\n#define THEAD_C9XX_CSR_NT_MCAUSE\t0xbe6\n#define THEAD_C9XX_CSR_NT_MIP\t\t0xbe7\n#define THEAD_C9XX_CSR_NT_MINTSTATE\t0xbe8\n#define THEAD_C9XX_CSR_NT_MXSTATUS\t0xbe9\n#define THEAD_C9XX_CSR_NT_MEBR\t\t0xbea\n#define THEAD_C9XX_CSR_NT_MSP\t\t0xbeb\n#define THEAD_C9XX_CSR_T_USP\t\t0xbec\n#define THEAD_C9XX_CSR_T_MDCR\t\t0xbed\n#define THEAD_C9XX_CSR_T_MPCR\t\t0xbee\n#define THEAD_C9XX_CSR_PMPTEECFG\t0xbef\n\n/* T-HEAD C9xx MIP CSR extension */\n#define THEAD_C9XX_IRQ_PMU_OVF\t\t17\n#define THEAD_C9XX_MIP_MOIP\t\t(_UL(1) << THEAD_C9XX_IRQ_PMU_OVF)\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2020 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Anup Patel <anup.patel@wdc.com>\n#\n\n# Compiler flags\nplatform-cppflags-y =\nplatform-cflags-y =\nplatform-asflags-y =\nplatform-ldflags-y =\n\n# Command for platform specific \"make run\"\nplatform-runcmd = qemu-system-riscv$(PLATFORM_RISCV_XLEN) -M virt -m 256M \\\n  -nographic -bios $(build_dir)/platform/generic/firmware/fw_payload.elf\n\n# Objects to build\nplatform-objs-y += platform.o\nplatform-objs-y += platform_override_modules.o\n\n# Blobs to build\nFW_TEXT_START=0x80000000\nFW_DYNAMIC=y\nFW_JUMP=y\nifeq ($(PLATFORM_RISCV_XLEN), 32)\n  # This needs to be 4MB aligned for 32-bit system\n  FW_JUMP_ADDR=$(shell printf \"0x%X\" $$(($(FW_TEXT_START) + 0x400000)))\nelse\n  # This needs to be 2MB aligned for 64-bit system\n  FW_JUMP_ADDR=$(shell printf \"0x%X\" $$(($(FW_TEXT_START) + 0x200000)))\nendif\nFW_JUMP_FDT_ADDR=$(shell printf \"0x%X\" $$(($(FW_TEXT_START) + 0x2200000)))\nFW_PAYLOAD=y\nifeq ($(PLATFORM_RISCV_XLEN), 32)\n  # This needs to be 4MB aligned for 32-bit system\n  FW_PAYLOAD_OFFSET=0x400000\nelse\n  # This needs to be 2MB aligned for 64-bit system\n  FW_PAYLOAD_OFFSET=0x200000\nendif\nFW_PAYLOAD_FDT_ADDR=$(FW_JUMP_FDT_ADDR)\n\n\n\n##################################   FTPM   ###############################\n\nCRYPTO_MINI = \n\nFTPM_OBJS = \\\n\t../../src/ACT_spt.o\t\t\t\\\n\t../../src/ACTCommands.o\t\t\t\\\n\t../../src/AlgorithmCap.o\t\t\t\\\n\t../../src/AlgorithmTests.o\t\t\\\n\t../../src/AsymmetricCommands.o\t\t\\\n\t../../src/Attest_spt.o\t\t\t\\\n\t../../src/AttestationCommands.o\t\t\\\n\t../../src/AuditCommands.o\t\t\t\\\n\t../../src/Bits.o\t\t\t\t\\\n\t../../src/BnConvert.o\t\t\t\\\n  ../../src/BnEccConstants.o  \\\n\t../../src/BnMath.o\t\t\t\\\n  ../../src/BnMemory.o\t\t\t\\\n  ../../src/BnToOsslMath.o\t\t\t\\\n\t../../src/BnUtil.o\t\t\t\\\n\t../../src/Cancel.o\t\t\t\\\n\t../../src/CapabilityCommands.o\t\t\\\n\t../../src/Clock.o\t\t\t\t\\\n\t../../src/ClockCommands.o\t\t\t\\\n\t../../src/CommandAudit.o\t\t\t\\\n\t../../src/CommandCodeAttributes.o\t\t\\\n\t../../src/CommandDispatcher.o\t\t\\\n\t../../src/Context_spt.o\t\t\t\\\n\t../../src/ContextCommands.o\t\t\\\n\t../../src/CryptCmac.o\t\t\t\\\n\t../../src/CryptDes.o\t\t\t\\\n\t../../src/CryptEccCrypt.o\t\t\t\\\n\t../../src/CryptEccData.o\t\t\t\\\n\t../../src/CryptEccKeyExchange.o\t\t\\\n\t../../src/CryptEccMain.o\t\t\t\\\n\t../../src/CryptEccSignature.o\t\t\\\n\t../../src/CryptHash.o\t\t\t\\\n\t../../src/CryptPrime.o\t\t\t\\\n\t../../src/CryptPrimeSieve.o\t\t\\\n\t../../src/CryptRand.o\t\t\t\\\n\t../../src/CryptRsa.o\t\t\t\\\n\t../../src/CryptSelfTest.o\t\t\t\\\n\t../../src/CryptSmac.o\t\t\t\\\n\t../../src/CryptSym.o\t\t\t\\\n\t../../src/CryptUtil.o\t\t\t\\\n\t../../src/DA.o\t\t\t\t\\\n\t../../src/DebugHelpers.o\t\t\t\\\n\t../../src/DictionaryCommands.o\t\t\\\n\t../../src/DuplicationCommands.o\t\t\\\n\t../../src/EACommands.o\t\t\t\\\n\t../../src/EncryptDecrypt_spt.o\t\t\\\n\t../../src/Entity.o\t\t\t\\\n\t../../src/Entropy.o\t\t\t\\\n\t../../src/EphemeralCommands.o\t\t\\\n\t../../src/ExecCommand.o\t\t\t\\\n\t../../src/ExtraData.o\t\t\t\\\n\t../../src/Global.o\t\t\t\\\n\t../../src/Handle.o\t\t\t\\\n\t../../src/HashCommands.o\t\t\t\\\n\t../../src/Hierarchy.o\t\t\t\\\n\t../../src/HierarchyCommands.o\t\t\\\n\t../../src/IoBuffers.o\t\t\t\\\n\t../../src/IntegrityCommands.o\t\t\\\n\t../../src/Locality.o\t\t\t\\\n\t../../src/LocalityPlat.o\t\t\t\\\n\t../../src/ManagementCommands.o\t\t\\\n\t../../src/Manufacture.o\t\t\t\\\n\t../../src/Marshal.o\t\t\t\\\n\t../../src/MathOnByteBuffers.o\t\t\\\n\t../../src/Memory.o\t\t\t\\\n\t../../src/NV_spt.o\t\t\t\\\n\t../../src/NVCommands.o\t\t\t\\\n\t../../src/NVDynamic.o\t\t\t\\\n\t../../src/NVMem.o\t\t\t\t\\\n\t../../src/NVReserved.o\t\t\t\\\n\t../../src/Object_spt.o\t\t\t\\\n\t../../src/Object.o\t\t\t\\\n\t../../src/ObjectCommands.o\t\t\\\n\t../../src/PCR.o\t\t\t\t\\\n\t../../src/PP.o\t\t\t\t\\\n\t../../src/PPPlat.o\t\t\t\\\n\t../../src/PlatformACT.o\t\t\t\\\n\t../../src/PlatformData.o\t\t\t\\\n\t../../src/PlatformPCR.o\t\t\t\\\n\t../../src/Policy_spt.o\t\t\t\\\n\t../../src/Power.o\t\t\t\t\\\n\t../../src/PowerPlat.o\t\t\t\\\n\t../../src/PrimeData.o\t\t\t\\\n\t../../src/PropertyCap.o\t\t\t\\\n\t../../src/RandomCommands.o\t\t\\\n\t../../src/Response.o\t\t\t\\\n\t../../src/ResponseCodeProcessing.o\t\\\n\t../../src/RsaKeyCache.o\t\t\t\\\n\t../../src/RunCommand.o\t\t\t\\\n\t../../src/Session.o\t\t\t\\\n\t../../src/SessionCommands.o\t\t\\\n\t../../src/SessionProcess.o\t\t\\\n\t../../src/SigningCommands.o\t\t\\\n\t../../src/StartupCommands.o\t\t\\\n\t../../src/SymmetricCommands.o\t\t\\\n\t../../src/TestingCommands.o\t\t\\\n\t../../src/Ticket.o\t\t\t\\\n\t../../src/Time.o\t\t\t\t\\\n\t../../src/TpmAsn1.o\t\t\t\\\n\t../../src/TpmBigNumThunks.o\t\t\t\\\n\t../../src/TpmEcc_Signature_ECDAA.o\t\t\t\\\n\t../../src/TpmEcc_Signature_ECDSA.o\t\t\t\\\n  ../../src/TpmEcc_Signature_Schnorr.o\t\t\t\\\n  ../../src/TpmEcc_Signature_SM2.o\t\t\t\\\n  ../../src/TpmEcc_Signature_Util.o\t\t\t\\\n  ../../src/TpmEcc_Util.o\t\t\t\\\n\t../../src/TpmFail.o\t\t\t\\\n\t../../src/TpmMath_Debug.o\t\t\t\\\n  ../../src/TpmMath_Util.o\t\t\t\\\n\t../../src/TpmSizeChecks.o\t\t\t\\\n\t../../src/TpmToOsslSupport.o\t\t\\\n\t../../src/Unique.o\t\t\t\\\n\t../../src/Unmarshal.o\t\t\t\\\n\t../../src/Vendor_TCG_Test.o\t\t\\\n  ../../src/VendorInfo.o\t\t\\\n\t../../src/X509_ECC.o\t\t\t\\\n\t../../src/X509_RSA.o\t\t\t\\\n\t../../src/X509_spt.o\t\t\t\\\n\t../../src/ntc2lib.o\t\t\t\\\n\t../../src/ntc2.o\t\t\t\\\n\t../../src/TPMCmdp.o\t\t\t\\\n\t../../src/mprv.o\t\t\t\\\n\t../../src/intercept.o\t\t\\\n\t../../src/ftpm-sbi-opensbi.o   \t\\\n\t../../src/ftpm.o\n\n#../../src/ftpm-sbi-opensbi.o\t\n\n\n\n#!!!v1.4 开gc-section无输出\n\n# 支持硬件双浮点数\nPLATFORM_RISCV_ABI = lp64d\n\n# FTPM_CFLAGS =  -ffunction-sections -fdata-sections\t\\\n#   \t-Wall  \t\t\t\\\n# \t-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \\\n# \t-Wno-deprecated-declarations\t\\\n# \t-Wno-unused-function\t-Wno-unused-variable\t\\\n# \t-Wno-error=missing-prototypes\t-Wno-error=maybe-uninitialized \\\n# \t-Wno-error=switch-unreachable\t-Wno-error=stringop-overflow= \\\n# \t-ggdb -O0 \t\t\t\\\n# \t-DTPM_POSIX\t\t\t\\\n# \t-D_POSIX_\t\t\t\\\n# \t-DTPM_NUVOTON\t\n\nFTPM_CFLAGS = \t\\\n  \t-Wall  \t\t\t\\\n\t-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \\\n\t-Wno-deprecated-declarations\t\\\n\t-Wno-unused-function\t-Wno-unused-variable\t\\\n\t-Wno-error=missing-prototypes\t-Wno-error=maybe-uninitialized \\\n\t-Wno-error=switch-unreachable\t-Wno-error=stringop-overflow= \\\n\t-ggdb -O0 \t\t\t\\\n\t-DTPM_POSIX\t\t\t\\\n\t-D_POSIX_\t\t\t\\\n\t-DTPM_NUVOTON\t\t\\\n\t-DPLATFORM_TYPE=1\n\nFTPM_CFLAGS += -DUSE_BIT_FIELD_STRUCTURES=NO -DSYM_LIB=Ossl -DHASH_LIB=Ossl -DMATH_LIB=TpmBigNum -DBN_MATH_LIB=Ossl\n\n\nplatform-cflags-y += $(FTPM_CFLAGS) -I$(CURDIR)/include/ftpm/ -I$(CRYPTO_MINI)/include\n# platform-ldflags-y = -lcryptomini -L${CRYPTO_MINI} \n\n# -lc -lgcc需要重复，保证cryptomini中的memset等函数能链接到libc\n# platform-ldflags-y = -lcryptomini -lc -lgcc -Wl,--start-group -lc -lgcc -Wl,--end-group -L${CRYPTO_MINI}\n\n\n\n# platform-ldflags-y = -Wl,-Map=output.map -Wl,-gc-sections -lcryptomini -lc -lgloss -lgcc\t-Wl,--start-group -lc -lgloss -Wl,--end-group -lgcc -L${CRYPTO_MINI}\nplatform-ldflags-y =  -lcryptomini -lc -lgloss -lgcc\t-Wl,--start-group -lc -lgloss -Wl,--end-group -lgcc -L${CRYPTO_MINI}\n# platform-ldflags-y = -Wl,-gc-sections -lcryptomini\t-Wl,--start-group -lc -lgcc -Wl,--end-group -L${CRYPTO_MINI}\n\n# platform-ldflags-y = -Wl,-gc-sections\t-lcryptomini\t\t\t\n# \t-lc -lgcc -Wl,--start-group -lc -Wl,--end-group -lgcc\t\n# \t-L${CRYPTO_MINI}\t\n\nplatform-objs-y += $(FTPM_OBJS)\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/platform.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <libfdt.h>\n#include <platform_override.h>\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_hartmask.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_string.h>\n#include <sbi_utils/fdt/fdt_domain.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/fdt/fdt_pmu.h>\n#include <sbi_utils/irqchip/fdt_irqchip.h>\n#include <sbi_utils/irqchip/imsic.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/timer/fdt_timer.h>\n#include <sbi_utils/ipi/fdt_ipi.h>\n#include <sbi_utils/reset/fdt_reset.h>\n#include <sbi_utils/serial/semihosting.h>\n\n#include \"ftpm.h\"\n\n/* List of platform override modules generated at compile time */\nextern const struct platform_override *platform_override_modules[];\nextern unsigned long platform_override_modules_size;\n\nstatic const struct platform_override *generic_plat = NULL;\nstatic const struct fdt_match *generic_plat_match = NULL;\n\nstatic void fw_platform_lookup_special(void *fdt, int root_offset)\n{\n\tconst struct platform_override *plat;\n\tconst struct fdt_match *match;\n\tint pos;\n\n\tfor (pos = 0; pos < platform_override_modules_size; pos++) {\n\t\tplat = platform_override_modules[pos];\n\t\tif (!plat->match_table)\n\t\t\tcontinue;\n\n\t\tmatch = fdt_match_node(fdt, root_offset, plat->match_table);\n\t\tif (!match)\n\t\t\tcontinue;\n\n\t\tgeneric_plat = plat;\n\t\tgeneric_plat_match = match;\n\t\tbreak;\n\t}\n}\n\nextern struct sbi_platform platform;\nstatic bool platform_has_mlevel_imsic = false;\nstatic u32 generic_hart_index2id[SBI_HARTMASK_MAX_BITS] = { 0 };\n\n/*\n * The fw_platform_init() function is called very early on the boot HART\n * OpenSBI reference firmwares so that platform specific code get chance\n * to update \"platform\" instance before it is used.\n *\n * The arguments passed to fw_platform_init() function are boot time state\n * of A0 to A4 register. The \"arg0\" will be boot HART id and \"arg1\" will\n * be address of FDT passed by previous booting stage.\n *\n * The return value of fw_platform_init() function is the FDT location. If\n * FDT is unchanged (or FDT is modified in-place) then fw_platform_init()\n * can always return the original FDT location (i.e. 'arg1') unmodified.\n */\nunsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,\n\t\t\t\tunsigned long arg2, unsigned long arg3,\n\t\t\t\tunsigned long arg4)\n{\n\tconst char *model;\n\tvoid *fdt = (void *)arg1;\n\tu32 hartid, hart_count = 0;\n\tint rc, root_offset, cpus_offset, cpu_offset, len;\n\n\troot_offset = fdt_path_offset(fdt, \"/\");\n\tif (root_offset < 0)\n\t\tgoto fail;\n\n\tfw_platform_lookup_special(fdt, root_offset);\n\n\tmodel = fdt_getprop(fdt, root_offset, \"model\", &len);\n\tif (model)\n\t\tsbi_strncpy(platform.name, model, sizeof(platform.name) - 1);\n\n\tif (generic_plat && generic_plat->features)\n\t\tplatform.features = generic_plat->features(generic_plat_match);\n\n\tcpus_offset = fdt_path_offset(fdt, \"/cpus\");\n\tif (cpus_offset < 0)\n\t\tgoto fail;\n\n\tfdt_for_each_subnode(cpu_offset, fdt, cpus_offset) {\n\t\trc = fdt_parse_hart_id(fdt, cpu_offset, &hartid);\n\t\tif (rc)\n\t\t\tcontinue;\n\n\t\tif (SBI_HARTMASK_MAX_BITS <= hartid)\n\t\t\tcontinue;\n\n\t\tif (!fdt_node_is_enabled(fdt, cpu_offset))\n\t\t\tcontinue;\n\n\t\tgeneric_hart_index2id[hart_count++] = hartid;\n\t}\n\n\tplatform.hart_count = hart_count;\n\n\tplatform_has_mlevel_imsic = fdt_check_imsic_mlevel(fdt);\n\n\t/* Return original FDT pointer */\n\treturn arg1;\n\nfail:\n\twhile (1)\n\t\twfi();\n}\n\nstatic int generic_nascent_init(void)\n{\n\tif (platform_has_mlevel_imsic)\n\t\timsic_local_irqchip_init();\n\treturn 0;\n}\n\nstatic int generic_early_init(bool cold_boot)\n{\n\tif (!generic_plat || !generic_plat->early_init)\n\t\treturn 0;\n\n\treturn generic_plat->early_init(cold_boot, generic_plat_match);\n}\n\nstatic int generic_final_init(bool cold_boot)\n{\n\tvoid *fdt;\n\tint rc;\n\n\tif (cold_boot)\n\t\tfdt_reset_init();\n\n\tif (generic_plat && generic_plat->final_init) {\n\t\trc = generic_plat->final_init(cold_boot, generic_plat_match);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\tif (!cold_boot)\n\t\treturn 0;\n\n\tfdt = fdt_get_address();\n\n\tfdt_cpu_fixup(fdt);\n\tfdt_fixups(fdt);\n\tfdt_domain_fixup(fdt);\n\n\tif (generic_plat && generic_plat->fdt_fixup) {\n\t\trc = generic_plat->fdt_fixup(fdt, generic_plat_match);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\tftpm_init();\n\n\treturn 0;\n}\n\nstatic int generic_vendor_ext_check(long extid)\n{\n\tif (generic_plat && generic_plat->vendor_ext_check)\n\t\treturn generic_plat->vendor_ext_check(extid,\n\t\t\t\t\t\t      generic_plat_match);\n\n\treturn 0;\n}\n\nstatic int generic_vendor_ext_provider(long extid, long funcid,\n\t\t\t\t       const struct sbi_trap_regs *regs,\n\t\t\t\t       unsigned long *out_value,\n\t\t\t\t       struct sbi_trap_info *out_trap)\n{\n\tif (generic_plat && generic_plat->vendor_ext_provider) {\n\t\treturn generic_plat->vendor_ext_provider(extid, funcid, regs,\n\t\t\t\t\t\t\t out_value, out_trap,\n\t\t\t\t\t\t\t generic_plat_match);\n\t}\n\n\treturn SBI_ENOTSUPP;\n}\n\nstatic void generic_early_exit(void)\n{\n\tif (generic_plat && generic_plat->early_exit)\n\t\tgeneric_plat->early_exit(generic_plat_match);\n}\n\nstatic void generic_final_exit(void)\n{\n\tif (generic_plat && generic_plat->final_exit)\n\t\tgeneric_plat->final_exit(generic_plat_match);\n}\n\nstatic int generic_extensions_init(struct sbi_hart_features *hfeatures)\n{\n\tif (generic_plat && generic_plat->extensions_init)\n\t\treturn generic_plat->extensions_init(generic_plat_match,\n\t\t\t\t\t\t     hfeatures);\n\n\treturn 0;\n}\n\nstatic int generic_domains_init(void)\n{\n\treturn fdt_domains_populate(fdt_get_address());\n}\n\nstatic u64 generic_tlbr_flush_limit(void)\n{\n\tif (generic_plat && generic_plat->tlbr_flush_limit)\n\t\treturn generic_plat->tlbr_flush_limit(generic_plat_match);\n\treturn SBI_PLATFORM_TLB_RANGE_FLUSH_LIMIT_DEFAULT;\n}\n\nstatic int generic_pmu_init(void)\n{\n\treturn fdt_pmu_setup(fdt_get_address());\n}\n\nstatic uint64_t generic_pmu_xlate_to_mhpmevent(uint32_t event_idx,\n\t\t\t\t\t       uint64_t data)\n{\n\tuint64_t evt_val = 0;\n\n\t/* data is valid only for raw events and is equal to event selector */\n\tif (event_idx == SBI_PMU_EVENT_RAW_IDX)\n\t\tevt_val = data;\n\telse {\n\t\t/**\n\t\t * Generic platform follows the SBI specification recommendation\n\t\t * i.e. zero extended event_idx is used as mhpmevent value for\n\t\t * hardware general/cache events if platform does't define one.\n\t\t */\n\t\tevt_val = fdt_pmu_get_select_value(event_idx);\n\t\tif (!evt_val)\n\t\t\tevt_val = (uint64_t)event_idx;\n\t}\n\n\treturn evt_val;\n}\n\nstatic int generic_console_init(void)\n{\n\tif (semihosting_enabled())\n\t\treturn semihosting_init();\n\telse\n\t\treturn fdt_serial_init();\n}\n\nconst struct sbi_platform_operations platform_ops = {\n\t.nascent_init\t\t= generic_nascent_init,\n\t.early_init\t\t= generic_early_init,\n\t.final_init\t\t= generic_final_init,\n\t.early_exit\t\t= generic_early_exit,\n\t.final_exit\t\t= generic_final_exit,\n\t.extensions_init\t= generic_extensions_init,\n\t.domains_init\t\t= generic_domains_init,\n\t.console_init\t\t= generic_console_init,\n\t.irqchip_init\t\t= fdt_irqchip_init,\n\t.irqchip_exit\t\t= fdt_irqchip_exit,\n\t.ipi_init\t\t= fdt_ipi_init,\n\t.ipi_exit\t\t= fdt_ipi_exit,\n\t.pmu_init\t\t= generic_pmu_init,\n\t.pmu_xlate_to_mhpmevent = generic_pmu_xlate_to_mhpmevent,\n\t.get_tlbr_flush_limit\t= generic_tlbr_flush_limit,\n\t.timer_init\t\t= fdt_timer_init,\n\t.timer_exit\t\t= fdt_timer_exit,\n\t.vendor_ext_check\t= generic_vendor_ext_check,\n\t.vendor_ext_provider\t= generic_vendor_ext_provider,\n};\n\nstruct sbi_platform platform = {\n\t.opensbi_version\t= OPENSBI_VERSION,\n\t.platform_version\t=\n\t\tSBI_PLATFORM_VERSION(CONFIG_PLATFORM_GENERIC_MAJOR_VER,\n\t\t\t\t     CONFIG_PLATFORM_GENERIC_MINOR_VER),\n\t.name\t\t\t= CONFIG_PLATFORM_GENERIC_NAME,\n\t.features\t\t= SBI_PLATFORM_DEFAULT_FEATURES,\n\t.hart_count\t\t= SBI_HARTMASK_MAX_BITS,\n\t.hart_index2id\t\t= generic_hart_index2id,\n\t.hart_stack_size\t= SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,\n\t.platform_ops_addr\t= (unsigned long)&platform_ops\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/platform_override_modules.carray",
    "content": "HEADER: platform_override.h\nTYPE: const struct platform_override\nNAME: platform_override_modules\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/renesas/rzfive/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (C) 2022 Renesas Electronics Corp.\n#\n\ncarray-platform_override_modules-$(CONFIG_PLATFORM_RENESAS_RZFIVE) += renesas_rzfive\nplatform-objs-$(CONFIG_PLATFORM_RENESAS_RZFIVE) += renesas/rzfive/rzfive.o\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/renesas/rzfive/rzfive.c",
    "content": "// SPDX-License-Identifier: GPL-2.0\n/*\n * Copyright (C) 2022 Renesas Electronics Corp.\n *\n */\n\n#include <platform_override.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n\nstatic const struct fdt_match renesas_rzfive_match[] = {\n\t{ .compatible = \"renesas,r9a07g043f01\" },\n\t{ /* sentinel */ }\n};\n\nconst struct platform_override renesas_rzfive = {\n\t.match_table = renesas_rzfive_match,\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/sifive/fu540.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2020 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Anup Patel <anup.patel@wdc.com>\n */\n\n#include <platform_override.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n\nstatic u64 sifive_fu540_tlbr_flush_limit(const struct fdt_match *match)\n{\n\t/*\n\t * The sfence.vma by virtual address does not work on\n\t * SiFive FU540 so we return remote TLB flush limit as zero.\n\t */\n\treturn 0;\n}\n\nstatic int sifive_fu540_fdt_fixup(void *fdt, const struct fdt_match *match)\n{\n\t/*\n\t * SiFive Freedom U540 has an erratum that prevents S-mode software\n\t * to access a PMP protected region using 1GB page table mapping, so\n\t * always add the no-map attribute on this platform.\n\t */\n\tfdt_reserved_memory_nomap_fixup(fdt);\n\n\treturn 0;\n}\n\nstatic const struct fdt_match sifive_fu540_match[] = {\n\t{ .compatible = \"sifive,fu540\" },\n\t{ .compatible = \"sifive,fu540g\" },\n\t{ .compatible = \"sifive,fu540-c000\" },\n\t{ .compatible = \"sifive,hifive-unleashed-a00\" },\n\t{ },\n};\n\nconst struct platform_override sifive_fu540 = {\n\t.match_table = sifive_fu540_match,\n\t.tlbr_flush_limit = sifive_fu540_tlbr_flush_limit,\n\t.fdt_fixup = sifive_fu540_fdt_fixup,\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/sifive/fu740.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2021 SiFive\n * Copyright (c) 2021 YADRO\n *\n * Authors:\n *   David Abdurachmanov <david.abdurachmanov@sifive.com>\n *   Nikita Shubin <n.shubin@yadro.com>\n */\n\n#include <platform_override.h>\n#include <libfdt.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_system.h>\n#include <sbi/sbi_console.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n#include <sbi_utils/reset/fdt_reset.h>\n#include <sbi_utils/i2c/fdt_i2c.h>\n\n#define DA9063_REG_PAGE_CON\t\t0x00\n#define DA9063_REG_CONTROL_A\t\t0x0e\n#define DA9063_REG_CONTROL_D\t\t0x11\n#define DA9063_REG_CONTROL_F\t\t0x13\n#define DA9063_REG_DEVICE_ID\t\t0x81\n\n#define DA9063_CONTROL_A_M_POWER1_EN\t(1 << 6)\n#define DA9063_CONTROL_A_M_POWER_EN\t(1 << 5)\n#define DA9063_CONTROL_A_STANDBY\t(1 << 3)\n\n#define DA9063_CONTROL_D_TWDSCALE_MASK\t0x07\n\n#define DA9063_CONTROL_F_WAKEUP\t(1 << 2)\n#define DA9063_CONTROL_F_SHUTDOWN\t(1 << 1)\n\n#define PMIC_CHIP_ID_DA9063\t\t0x61\n\nstatic struct {\n\tstruct i2c_adapter *adapter;\n\tuint32_t reg;\n} da9063;\n\nstatic int da9063_system_reset_check(u32 type, u32 reason)\n{\n\tswitch (type) {\n\tcase SBI_SRST_RESET_TYPE_SHUTDOWN:\n\t\treturn 1;\n\tcase SBI_SRST_RESET_TYPE_COLD_REBOOT:\n\tcase SBI_SRST_RESET_TYPE_WARM_REBOOT:\n\t\treturn 255;\n\t}\n\n\treturn 0;\n}\n\nstatic inline int da9063_sanity_check(struct i2c_adapter *adap, uint32_t reg)\n{\n\tuint8_t val;\n\tint rc = i2c_adapter_reg_write(adap, reg, DA9063_REG_PAGE_CON, 0x02);\n\n\tif (rc)\n\t\treturn rc;\n\n\t/* check set page*/\n\trc = i2c_adapter_reg_read(adap, reg, 0x0, &val);\n\tif (rc)\n\t\treturn rc;\n\n\tif (val != 0x02)\n\t\treturn SBI_ENODEV;\n\n\t/* read and check device id */\n\trc = i2c_adapter_reg_read(adap, reg, DA9063_REG_DEVICE_ID, &val);\n\tif (rc)\n\t\treturn rc;\n\n\tif (val != PMIC_CHIP_ID_DA9063)\n\t\treturn SBI_ENODEV;\n\n\treturn 0;\n}\n\nstatic inline int da9063_stop_watchdog(struct i2c_adapter *adap, uint32_t reg)\n{\n\tuint8_t val;\n\tint rc = i2c_adapter_reg_write(adap, reg,\n\t\t\t\t\tDA9063_REG_PAGE_CON, 0x00);\n\n\tif (rc)\n\t\treturn rc;\n\n\trc = i2c_adapter_reg_read(adap, reg, DA9063_REG_CONTROL_D, &val);\n\tif (rc)\n\t\treturn rc;\n\n\tif ((val & DA9063_CONTROL_D_TWDSCALE_MASK) == 0)\n\t\treturn 0;\n\n\tval &= ~DA9063_CONTROL_D_TWDSCALE_MASK;\n\n\treturn i2c_adapter_reg_write(adap, reg, DA9063_REG_CONTROL_D, val);\n}\n\nstatic inline int da9063_shutdown(struct i2c_adapter *adap, uint32_t reg)\n{\n\tint rc = i2c_adapter_reg_write(adap, reg,\n\t\t\t\t\tDA9063_REG_PAGE_CON, 0x00);\n\n\tif (rc)\n\t\treturn rc;\n\n\treturn i2c_adapter_reg_write(adap, reg,\n\t\t\t\t     DA9063_REG_CONTROL_F,\n\t\t\t\t     DA9063_CONTROL_F_SHUTDOWN);\n}\n\nstatic inline int da9063_reset(struct i2c_adapter *adap, uint32_t reg)\n{\n\tint rc = i2c_adapter_reg_write(adap, reg,\n\t\t\t\t\tDA9063_REG_PAGE_CON, 0x00);\n\n\tif (rc)\n\t\treturn rc;\n\n\trc = i2c_adapter_reg_write(adap, reg,\n\t\t\t\t   DA9063_REG_CONTROL_F,\n\t\t\t\t   DA9063_CONTROL_F_WAKEUP);\n\tif (rc)\n\t\treturn rc;\n\n\treturn i2c_adapter_reg_write(adap, reg,\n\t\t\t\tDA9063_REG_CONTROL_A,\n\t\t\t\tDA9063_CONTROL_A_M_POWER1_EN |\n\t\t\t\tDA9063_CONTROL_A_M_POWER_EN |\n\t\t\t\tDA9063_CONTROL_A_STANDBY);\n}\n\nstatic void da9063_system_reset(u32 type, u32 reason)\n{\n\tstruct i2c_adapter *adap = da9063.adapter;\n\tuint32_t reg = da9063.reg;\n\tint rc;\n\n\tif (adap) {\n\t\t/* sanity check */\n\t\trc = da9063_sanity_check(adap, reg);\n\t\tif (rc) {\n\t\t\tsbi_printf(\"%s: chip is not da9063 PMIC\\n\", __func__);\n\t\t\tgoto skip_reset;\n\t\t}\n\n\t\tswitch (type) {\n\t\tcase SBI_SRST_RESET_TYPE_SHUTDOWN:\n\t\t\tda9063_shutdown(adap, reg);\n\t\t\tbreak;\n\t\tcase SBI_SRST_RESET_TYPE_COLD_REBOOT:\n\t\tcase SBI_SRST_RESET_TYPE_WARM_REBOOT:\n\t\t\tda9063_stop_watchdog(adap, reg);\n\t\t\tda9063_reset(adap, reg);\n\t\t\tbreak;\n\t\t}\n\t}\n\nskip_reset:\n\tsbi_hart_hang();\n}\n\nstatic struct sbi_system_reset_device da9063_reset_i2c = {\n\t.name = \"da9063-reset\",\n\t.system_reset_check = da9063_system_reset_check,\n\t.system_reset = da9063_system_reset\n};\n\nstatic int da9063_reset_init(void *fdt, int nodeoff,\n\t\t\t     const struct fdt_match *match)\n{\n\tint rc, i2c_bus;\n\tstruct i2c_adapter *adapter;\n\tuint64_t addr;\n\n\t/* we are dlg,da9063 node */\n\trc = fdt_get_node_addr_size(fdt, nodeoff, 0, &addr, NULL);\n\tif (rc)\n\t\treturn rc;\n\n\tda9063.reg = addr;\n\n\t/* find i2c bus parent node */\n\ti2c_bus = fdt_parent_offset(fdt, nodeoff);\n\tif (i2c_bus < 0)\n\t\treturn i2c_bus;\n\n\t/* i2c adapter get */\n\trc = fdt_i2c_adapter_get(fdt, i2c_bus, &adapter);\n\tif (rc)\n\t\treturn rc;\n\n\tda9063.adapter = adapter;\n\n\tsbi_system_reset_add_device(&da9063_reset_i2c);\n\n\treturn 0;\n}\n\nstatic const struct fdt_match da9063_reset_match[] = {\n\t{ .compatible = \"dlg,da9063\", .data = (void *)TRUE },\n\t{ },\n};\n\nstruct fdt_reset fdt_reset_da9063 = {\n\t.match_table = da9063_reset_match,\n\t.init = da9063_reset_init,\n};\n\nstatic u64 sifive_fu740_tlbr_flush_limit(const struct fdt_match *match)\n{\n\t/*\n\t * Needed to address CIP-1200 errata on SiFive FU740\n\t * Title: Instruction TLB can fail to respect a non-global SFENCE\n\t * Workaround: Flush the TLB using SFENCE.VMA x0, x0\n\t * See Errata_FU740-C000_20210205 from\n\t * https://www.sifive.com/boards/hifive-unmatched\n\t */\n\treturn 0;\n}\n\nstatic int sifive_fu740_final_init(bool cold_boot,\n\t\t\t\t   const struct fdt_match *match)\n{\n\tint rc;\n\tvoid *fdt = fdt_get_address();\n\n\tif (cold_boot) {\n\t\trc = fdt_reset_driver_init(fdt, &fdt_reset_da9063);\n\t\tif (rc)\n\t\t\tsbi_printf(\"%s: failed to find da9063 for reset\\n\",\n\t\t\t\t   __func__);\n\t}\n\n\treturn 0;\n}\n\nstatic const struct fdt_match sifive_fu740_match[] = {\n\t{ .compatible = \"sifive,fu740\" },\n\t{ .compatible = \"sifive,fu740-c000\" },\n\t{ .compatible = \"sifive,hifive-unmatched-a00\" },\n\t{ },\n};\n\nconst struct platform_override sifive_fu740 = {\n\t.match_table = sifive_fu740_match,\n\t.tlbr_flush_limit = sifive_fu740_tlbr_flush_limit,\n\t.final_init = sifive_fu740_final_init,\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/generic/sifive/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n\ncarray-platform_override_modules-$(CONFIG_PLATFORM_SIFIVE_FU540) += sifive_fu540\nplatform-objs-$(CONFIG_PLATFORM_SIFIVE_FU540) += sifive/fu540.o\n\ncarray-platform_override_modules-$(CONFIG_PLATFORM_SIFIVE_FU740) += sifive_fu740\nplatform-objs-$(CONFIG_PLATFORM_SIFIVE_FU740) += sifive/fu740.o\n"
  },
  {
    "path": "ftpm-opensbi/platform/kendryte/k210/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nconfig PLATFORM_KENDRYTE_K210\n\tbool\n\tselect FDT\n\tselect IPI_MSWI\n\tselect IRQCHIP_PLIC\n\tselect SERIAL_SIFIVE\n\tselect TIMER_MTIMER\n\tdefault y\n"
  },
  {
    "path": "ftpm-opensbi/platform/kendryte/k210/configs/defconfig",
    "content": ""
  },
  {
    "path": "ftpm-opensbi/platform/kendryte/k210/k210.dts",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Damien Le Moal <damien.lemoal@wdc.com>\n */\n\n/dts-v1/;\n/ {\n\t#address-cells = <2>;\n\t#size-cells = <2>;\n\tcompatible = \"kendryte,k210\";\n\n\tchosen {\n                bootargs = \"console=hvc0 earlycon=sbi\";\n\t};\n\n\tcpus {\n\t\t#address-cells = <1>;\n\t\t#size-cells = <0>;\n\t\tcpu0: cpu@0 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\tclock-frequency = <390000000>;\n\t\t\ti-cache-size = <32768>;\n\t\t\td-cache-size = <32768>;\n\t\t\tmmu-type = \"none\";\n\t\t\treg = <0>;\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\tstatus = \"okay\";\n\t\t\tcpu0_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t\tinterrupt-controller;\n\t\t\t};\n\t\t};\n\t\tcpu1: cpu@1 {\n\t\t\tdevice_type = \"cpu\";\n\t\t\tclock-frequency = <390000000>;\n\t\t\td-cache-size = <32768>;\n\t\t\ti-cache-size = <32768>;\n\t\t\tmmu-type = \"none\";\n\t\t\treg = <1>;\n\t\t\triscv,isa = \"rv64imafdc\";\n\t\t\tstatus = \"okay\";\n\t\t\tcpu1_intc: interrupt-controller {\n\t\t\t\t#interrupt-cells = <1>;\n\t\t\t\tcompatible = \"riscv,cpu-intc\";\n\t\t\t\tinterrupt-controller;\n\t\t\t};\n\t\t};\n\t};\n\n\tmemory@80000000 {\n\t\t/* Bank 0: 4 MB, Bank 1: 2 MB, AI chip SRAM: 2MB */\n\t\tdevice_type = \"memory\";\n\t\treg = <0x00000000 0x80000000 0x00000000 0x00800000>;\n\t};\n\n\tplic0: interrupt-controller@C000000 {\n\t\t#interrupt-cells = <1>;\n\t\tcompatible = \"riscv,plic0\";\n\t\tinterrupt-controller;\n\t\tinterrupts-extended =\n\t\t\t<&cpu0_intc 11 &cpu0_intc 9\n\t\t\t &cpu1_intc 11 &cpu1_intc 9>;\n\t\treg = <0x0 0xc000000 0x0 0x4000000>;\n\t};\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/kendryte/k210/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n# Authors:\n#   Damien Le Moal <damien.lemoal@wdc.com>\n#\n\n# Compiler flags\nplatform-cppflags-y =\nplatform-cflags-y =\nplatform-asflags-y =\nplatform-ldflags-y =\n\n# Objects to build\nplatform-objs-y += platform.o\n\nplatform-objs-y += k210.o\nplatform-varprefix-k210.o = dt_k210\nplatform-padding-k210.o = 2048\n\n# Blobs to build\nFW_TEXT_START=0x80000000\nFW_PAYLOAD=y\nFW_PAYLOAD_ALIGN=0x1000\n"
  },
  {
    "path": "ftpm-opensbi/platform/kendryte/k210/platform.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Damien Le Moal <damien.lemoal@wdc.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_const.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_system.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n#include <sbi_utils/ipi/aclint_mswi.h>\n#include <sbi_utils/irqchip/plic.h>\n#include <sbi_utils/serial/sifive-uart.h>\n#include <sbi_utils/timer/aclint_mtimer.h>\n#include \"platform.h\"\n\nextern const char dt_k210_start[];\n\nunsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,\n\t\t\t\tunsigned long arg2, unsigned long arg3,\n\t\t\t\tunsigned long arg4)\n{\n\treturn (unsigned long)&dt_k210_start[0];\n}\n\nstatic struct plic_data plic = {\n\t.addr = K210_PLIC_BASE_ADDR,\n\t.num_src = K210_PLIC_NUM_SOURCES,\n};\n\nstatic struct aclint_mswi_data mswi = {\n\t.addr = K210_ACLINT_MSWI_ADDR,\n\t.size = ACLINT_MSWI_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = K210_HART_COUNT,\n};\n\nstatic struct aclint_mtimer_data mtimer = {\n\t.mtime_freq = K210_ACLINT_MTIMER_FREQ,\n\t.mtime_addr = K210_ACLINT_MTIMER_ADDR +\n\t\t      ACLINT_DEFAULT_MTIME_OFFSET,\n\t.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,\n\t.mtimecmp_addr = K210_ACLINT_MTIMER_ADDR +\n\t\t\t ACLINT_DEFAULT_MTIMECMP_OFFSET,\n\t.mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = K210_HART_COUNT,\n\t.has_64bit_mmio = TRUE,\n};\n\nstatic u32 k210_get_clk_freq(void)\n{\n\tu32 clksel0, pll0;\n\tu64 pll0_freq, clkr0, clkf0, clkod0, div;\n\n\t/*\n\t * If the clock selector is not set, use the base frequency.\n\t * Otherwise, use PLL0 frequency with a frequency divisor.\n\t */\n\tclksel0 = k210_read_sysreg(K210_CLKSEL0);\n\tif (!(clksel0 & 0x1))\n\t\treturn K210_CLK0_FREQ;\n\n\t/*\n\t * Get PLL0 frequency:\n\t * freq = base frequency * clkf0 / (clkr0 * clkod0)\n\t */\n\tpll0 = k210_read_sysreg(K210_PLL0);\n\tclkr0 = 1 + (pll0 & 0x0000000f);\n\tclkf0 = 1 + ((pll0 & 0x000003f0) >> 4);\n\tclkod0 = 1 + ((pll0 & 0x00003c00) >> 10);\n\tpll0_freq = clkf0 * K210_CLK0_FREQ / (clkr0 * clkod0);\n\n\t/* Get the frequency divisor from the clock selector */\n\tdiv = 2ULL << ((clksel0 & 0x00000006) >> 1);\n\n\treturn pll0_freq / div;\n}\n\nstatic int k210_system_reset_check(u32 type, u32 reason)\n{\n\treturn 1;\n}\n\nstatic void k210_system_reset(u32 type, u32 reason)\n{\n\tu32 val;\n\n\tval = k210_read_sysreg(K210_RESET);\n\tval |= K210_RESET_MASK;\n\tk210_write_sysreg(val, K210_RESET);\n\n\twhile (1);\n}\n\nstatic struct sbi_system_reset_device k210_reset = {\n\t.name = \"kendryte_k210_reset\",\n\t.system_reset_check = k210_system_reset_check,\n\t.system_reset = k210_system_reset\n};\n\nstatic int k210_early_init(bool cold_boot)\n{\n\tif (cold_boot)\n\t\tsbi_system_reset_add_device(&k210_reset);\n\n\treturn 0;\n}\n\nstatic int k210_final_init(bool cold_boot)\n{\n\tvoid *fdt;\n\n\tif (!cold_boot)\n\t\treturn 0;\n\n\tfdt = fdt_get_address();\n\n\tfdt_cpu_fixup(fdt);\n\tfdt_fixups(fdt);\n\n\treturn 0;\n}\n\nstatic int k210_console_init(void)\n{\n\treturn sifive_uart_init(K210_UART_BASE_ADDR, k210_get_clk_freq(),\n\t\t\t\tK210_UART_BAUDRATE);\n}\n\nstatic int k210_irqchip_init(bool cold_boot)\n{\n\tint rc;\n\tu32 hartid = current_hartid();\n\n\tif (cold_boot) {\n\t\trc = plic_cold_irqchip_init(&plic);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn plic_warm_irqchip_init(&plic, hartid * 2, hartid * 2 + 1);\n}\n\nstatic int k210_ipi_init(bool cold_boot)\n{\n\tint rc;\n\n\tif (cold_boot) {\n\t\trc = aclint_mswi_cold_init(&mswi);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn aclint_mswi_warm_init();\n}\n\nstatic int k210_timer_init(bool cold_boot)\n{\n\tint rc;\n\n\tif (cold_boot) {\n\t\trc = aclint_mtimer_cold_init(&mtimer, NULL);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn aclint_mtimer_warm_init();\n}\n\nconst struct sbi_platform_operations platform_ops = {\n\t.early_init\t= k210_early_init,\n\n\t.final_init\t= k210_final_init,\n\n\t.console_init\t= k210_console_init,\n\n\t.irqchip_init = k210_irqchip_init,\n\n\t.ipi_init  = k210_ipi_init,\n\n\t.timer_init\t   = k210_timer_init,\n};\n\nconst struct sbi_platform platform = {\n\t.opensbi_version\t= OPENSBI_VERSION,\n\t.platform_version   \t= SBI_PLATFORM_VERSION(0x0, 0x01),\n\t.name\t\t\t= \"Kendryte K210\",\n\t.features\t\t= 0,\n\t.hart_count\t\t= K210_HART_COUNT,\n\t.hart_stack_size\t= SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,\n\t.platform_ops_addr\t= (unsigned long)&platform_ops\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/kendryte/k210/platform.h",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n *\n * Authors:\n *   Damien Le Moal <damien.lemoal@wdc.com>\n */\n#ifndef _K210_PLATFORM_H_\n#define _K210_PLATFORM_H_\n\n#include <sbi/riscv_io.h>\n\n#define K210_HART_COUNT\t\t2\n\n#define K210_UART_BAUDRATE\t115200\n#define K210_ACLINT_MTIMER_FREQ\t7800000\n#define K210_CLK0_FREQ\t\t26000000UL\n#define K210_PLIC_NUM_SOURCES\t65\n\n/* Registers base address */\n#define K210_SYSCTL_BASE_ADDR\t0x50440000ULL\n#define K210_UART_BASE_ADDR\t0x38000000ULL\n#define K210_CLINT_BASE_ADDR\t0x02000000ULL\n#define K210_ACLINT_MSWI_ADDR\t\\\n\t\t(K210_CLINT_BASE_ADDR + CLINT_MSWI_OFFSET)\n#define K210_ACLINT_MTIMER_ADDR \\\n\t\t(K210_CLINT_BASE_ADDR + CLINT_MTIMER_OFFSET)\n#define K210_PLIC_BASE_ADDR\t0x0C000000ULL\n\n/* Registers */\n#define K210_PLL0\t\t0x08\n#define K210_CLKSEL0\t\t0x20\n#define K210_RESET\t\t0x30\n\n/* Register bit masks */\n#define K210_RESET_MASK\t\t0x01\n\nstatic inline u32 k210_read_sysreg(u32 reg)\n{\n\treturn readl((volatile void *)(K210_SYSCTL_BASE_ADDR + reg));\n}\n\nstatic inline void k210_write_sysreg(u32 val, u32 reg)\n{\n\twritel(val, (volatile void *)(K210_SYSCTL_BASE_ADDR + reg));\n}\n\n#endif /* _K210_PLATFORM_H_ */\n"
  },
  {
    "path": "ftpm-opensbi/platform/nuclei/ux600/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nconfig PLATFORM_NUCLEI_UX600\n\tbool\n\tselect FDT\n\tselect IPI_MSWI\n\tselect IRQCHIP_PLIC\n\tselect SERIAL_SIFIVE\n\tselect TIMER_MTIMER\n\tdefault y\n"
  },
  {
    "path": "ftpm-opensbi/platform/nuclei/ux600/configs/defconfig",
    "content": ""
  },
  {
    "path": "ftpm-opensbi/platform/nuclei/ux600/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2020 Nuclei Corporation or its affiliates.\n#\n# Authors:\n#   lujun <lujun@nuclesys.com>\n#   hqfang <578567190@qq.com>\n#\n\n# Compiler flags\nplatform-cppflags-y =\nplatform-cflags-y =\nplatform-asflags-y =\nplatform-ldflags-y =\n\n# Command for platform specific \"make run\"\nplatform-runcmd = xl_spike \\\n  $(build_dir)/platform/nuclei/ux600/firmware/fw_payload.elf\n\n# Objects to build\nplatform-objs-y += platform.o\n\n# Blobs to build\nFW_TEXT_START=0xA0000000\nFW_DYNAMIC=y\nFW_JUMP=y\n\nFW_JUMP_ADDR=0xA0200000\nFW_JUMP_FDT_ADDR=0xA8000000\nFW_PAYLOAD=y\nFW_PAYLOAD_OFFSET=0x200000\nFW_PAYLOAD_FDT_ADDR=0xA8000000\n"
  },
  {
    "path": "ftpm-opensbi/platform/nuclei/ux600/platform.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) Nuclei Corporation or its affiliates.\n *\n * Authors:\n *   lujun <lujun@nucleisys.com>\n *   hqfang <578567190@qq.com>\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_io.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_const.h>\n#include <sbi/sbi_platform.h>\n#include <sbi/sbi_system.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n#include <sbi_utils/ipi/aclint_mswi.h>\n#include <sbi_utils/irqchip/plic.h>\n#include <sbi_utils/serial/sifive-uart.h>\n#include <sbi_utils/timer/aclint_mtimer.h>\n\n/* clang-format off */\n\n#define UX600_HART_COUNT\t\t1\n#define UX600_TIMER_FREQ\t\t32768\n\n/* Nuclei timer base address */\n#define UX600_NUCLEI_TIMER_ADDR\t\t0x2000000\n#define UX600_NUCLEI_TIMER_MSFTRST_OFS\t0xFF0\n#define UX600_NUCLEI_TIMER_MSFTRST_KEY\t0x80000A5F\n/* The clint compatiable timer offset is 0x1000 against nuclei timer */\n#define UX600_CLINT_TIMER_ADDR\t\t(UX600_NUCLEI_TIMER_ADDR + 0x1000)\n#define UX600_ACLINT_MSWI_ADDR\t\t(UX600_CLINT_TIMER_ADDR + \\\n\t\t\t\t\t CLINT_MSWI_OFFSET)\n#define UX600_ACLINT_MTIMER_ADDR\t(UX600_CLINT_TIMER_ADDR + \\\n\t\t\t\t\t CLINT_MTIMER_OFFSET)\n\n#define UX600_PLIC_ADDR\t\t\t0x8000000\n#define UX600_PLIC_NUM_SOURCES\t\t0x35\n#define UX600_PLIC_NUM_PRIORITIES\t7\n\n#define UX600_UART0_ADDR\t\t0x10013000\n#define UX600_UART1_ADDR\t\t0x10023000\n\n#define UX600_DEBUG_UART\t\tUX600_UART0_ADDR\n\n#ifndef UX600_UART_BAUDRATE\n#define UX600_UART_BAUDRATE\t\t57600\n#endif\n\n#define UX600_GPIO_ADDR\t\t\t0x10012000\n#define UX600_GPIO_IOF_EN_OFS\t\t0x38\n#define UX600_GPIO_IOF_SEL_OFS\t\t0x3C\n#define UX600_GPIO_IOF_UART0_MASK\t0x00030000\n\n#define UX600_TIMER_VALUE()\t\treadl((void *)UX600_NUCLEI_TIMER_ADDR)\n\n/* clang-format on */\nstatic u32 ux600_clk_freq = 8000000;\n\nstatic struct plic_data plic = {\n\t.addr = UX600_PLIC_ADDR,\n\t.num_src = UX600_PLIC_NUM_SOURCES,\n};\n\nstatic struct aclint_mswi_data mswi = {\n\t.addr = UX600_ACLINT_MSWI_ADDR,\n\t.size = ACLINT_MSWI_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = UX600_HART_COUNT,\n};\n\nstatic struct aclint_mtimer_data mtimer = {\n\t.mtime_freq = UX600_TIMER_FREQ,\n\t.mtime_addr = UX600_ACLINT_MTIMER_ADDR +\n\t\t      ACLINT_DEFAULT_MTIME_OFFSET,\n\t.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,\n\t.mtimecmp_addr = UX600_ACLINT_MTIMER_ADDR +\n\t\t\t ACLINT_DEFAULT_MTIMECMP_OFFSET,\n\t.mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = UX600_HART_COUNT,\n\t.has_64bit_mmio = TRUE,\n};\n\nstatic u32 measure_cpu_freq(u32 n)\n{\n\tu32 start_mtime, delta_mtime;\n\tu32 mtime_freq = UX600_TIMER_FREQ;\n\tu32 tmp = (u32)UX600_TIMER_VALUE();\n\tu32 start_mcycle, delta_mcycle, freq;\n\n\t/* Don't start measuring until we see an mtime tick */\n\tdo {\n\t\tstart_mtime = (u32)UX600_TIMER_VALUE();\n\t} while (start_mtime == tmp);\n\n\tstart_mcycle = csr_read(mcycle);\n\n\tdo {\n\t\tdelta_mtime = (u32)UX600_TIMER_VALUE() - start_mtime;\n\t} while (delta_mtime < n);\n\n\tdelta_mcycle = csr_read(mcycle) - start_mcycle;\n\n\tfreq = (delta_mcycle / delta_mtime) * mtime_freq\n\t\t+ ((delta_mcycle % delta_mtime) * mtime_freq) / delta_mtime;\n\n\treturn freq;\n}\n\nstatic u32 ux600_get_clk_freq(void)\n{\n\tu32 cpu_freq;\n\n\t/* warm up */\n\tmeasure_cpu_freq(1);\n\t/* measure for real */\n\tcpu_freq = measure_cpu_freq(100);\n\n\treturn cpu_freq;\n}\n\nstatic int ux600_system_reset_check(u32 type, u32 reason)\n{\n\treturn 1;\n}\n\nstatic void ux600_system_reset(u32 type, u32 reason)\n{\n\t/* Reset system using MSFTRST register in Nuclei Timer. */\n\twritel(UX600_NUCLEI_TIMER_MSFTRST_KEY, (void *)(UX600_NUCLEI_TIMER_ADDR\n\t\t\t\t\t+ UX600_NUCLEI_TIMER_MSFTRST_OFS));\n\twhile(1);\n}\n\nstatic struct sbi_system_reset_device ux600_reset = {\n\t.name = \"nuclei_ux600_reset\",\n\t.system_reset_check = ux600_system_reset_check,\n\t.system_reset = ux600_system_reset\n};\n\nstatic int ux600_early_init(bool cold_boot)\n{\n\tu32 regval;\n\n\tif (cold_boot)\n\t\tsbi_system_reset_add_device(&ux600_reset);\n\n\t/* Measure CPU Frequency using Timer */\n\tux600_clk_freq = ux600_get_clk_freq();\n\n\t/* Init GPIO UART pinmux */\n\tregval = readl((void *)(UX600_GPIO_ADDR + UX600_GPIO_IOF_SEL_OFS)) &\n\t\t ~UX600_GPIO_IOF_UART0_MASK;\n\twritel(regval, (void *)(UX600_GPIO_ADDR + UX600_GPIO_IOF_SEL_OFS));\n\tregval = readl((void *)(UX600_GPIO_ADDR + UX600_GPIO_IOF_EN_OFS)) |\n\t\tUX600_GPIO_IOF_UART0_MASK;\n\twritel(regval, (void *)(UX600_GPIO_ADDR + UX600_GPIO_IOF_EN_OFS));\n\treturn 0;\n}\n\nstatic void ux600_modify_dt(void *fdt)\n{\n\tfdt_fixups(fdt);\n}\n\nstatic int ux600_final_init(bool cold_boot)\n{\n\tvoid *fdt;\n\n\tif (!cold_boot)\n\t\treturn 0;\n\n\tfdt = fdt_get_address();\n\tux600_modify_dt(fdt);\n\n\treturn 0;\n}\n\nstatic int ux600_console_init(void)\n{\n\treturn sifive_uart_init(UX600_DEBUG_UART, ux600_clk_freq,\n\t\t\t\tUX600_UART_BAUDRATE);\n}\n\nstatic int ux600_irqchip_init(bool cold_boot)\n{\n\tint rc;\n\tu32 hartid = current_hartid();\n\n\tif (cold_boot) {\n\t\trc = plic_cold_irqchip_init(&plic);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn plic_warm_irqchip_init(&plic, (hartid) ? (2 * hartid - 1) : 0,\n\t\t\t\t      (hartid) ? (2 * hartid) : -1);\n}\n\nstatic int ux600_ipi_init(bool cold_boot)\n{\n\tint rc;\n\n\tif (cold_boot) {\n\t\trc = aclint_mswi_cold_init(&mswi);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn aclint_mswi_warm_init();\n}\n\nstatic int ux600_timer_init(bool cold_boot)\n{\n\tint rc;\n\n\tif (cold_boot) {\n\t\trc = aclint_mtimer_cold_init(&mtimer, NULL);\n\t\tif (rc)\n\t\t\treturn rc;\n\t}\n\n\treturn aclint_mtimer_warm_init();\n}\n\nconst struct sbi_platform_operations platform_ops = {\n\t.early_init\t\t= ux600_early_init,\n\t.final_init\t\t= ux600_final_init,\n\t.console_init\t\t= ux600_console_init,\n\t.irqchip_init\t\t= ux600_irqchip_init,\n\t.ipi_init\t\t= ux600_ipi_init,\n\t.timer_init\t\t= ux600_timer_init,\n};\n\nconst struct sbi_platform platform = {\n\t.opensbi_version\t= OPENSBI_VERSION,\n\t.platform_version\t= SBI_PLATFORM_VERSION(0x0U, 0x01U),\n\t.name\t\t\t= \"Nuclei UX600\",\n\t.features\t\t= SBI_PLATFORM_DEFAULT_FEATURES,\n\t.hart_count\t\t= UX600_HART_COUNT,\n\t.hart_stack_size\t= SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,\n\t.platform_ops_addr\t= (unsigned long)&platform_ops\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/template/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\n#\n# All mandatory drivers or libraries for this platform should\n# be directly selected by the PLATFORM_xyz kconfig symbol.\n#\n# All optional drivers or libraries for this platform should\n# be enabled via configs/defconfig of this platform.\n#\nconfig PLATFORM_TEMPLATE\n\tbool\n\tselect IPI_MSWI\n\tselect IRQCHIP_PLIC\n\tselect SERIAL_UART8250\n\tselect TIMER_MTIMER\n\tdefault y\n"
  },
  {
    "path": "ftpm-opensbi/platform/template/configs/defconfig",
    "content": ""
  },
  {
    "path": "ftpm-opensbi/platform/template/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Copyright (c) 2019 Western Digital Corporation or its affiliates.\n#\n\n# Compiler pre-processor flags\nplatform-cppflags-y =\n\n# C Compiler and assembler flags.\nplatform-cflags-y =\nplatform-asflags-y =\n\n# Linker flags: additional libraries and object files that the platform\n# code needs can be added here\nplatform-ldflags-y =\n\n#\n# Command for platform specific \"make run\"\n# Useful for development and debugging on plaftform simulator (such as QEMU)\n#\n# platform-runcmd = your_platform_run.sh\n\n#\n# Platform RISC-V XLEN, ABI, ISA and Code Model configuration.\n# These are optional parameters but platforms can optionaly provide it.\n# Some of these are guessed based on GCC compiler capabilities\n#\n# PLATFORM_RISCV_XLEN = 64\n# PLATFORM_RISCV_ABI = lp64\n# PLATFORM_RISCV_ISA = rv64imafdc\n# PLATFORM_RISCV_CODE_MODEL = medany\n\n# Space separated list of object file names to be compiled for the platform\nplatform-objs-y += platform.o\n\n#\n# If the platform support requires a builtin device tree file, the name of\n# the device tree compiled file should be specified here. The device tree\n# source file be in the form <dt file name>.dts\n#\n# platform-objs-y += <dt file name>.o\n\n# Firmware load address configuration. This is mandatory.\nFW_TEXT_START=0x80000000\n\n# Optional parameter for path to external FDT\n# FW_FDT_PATH=\"path to platform flattened device tree file\"\n\n#\n# Dynamic firmware configuration.\n# Optional parameters are commented out. Uncomment and define these parameters\n# as needed.\n#\nFW_DYNAMIC=<y|n>\n\n#\n# Jump firmware configuration.\n# Optional parameters are commented out. Uncomment and define these parameters\n# as needed.\n#\nFW_JUMP=<y|n>\n# This needs to be 4MB aligned for 32-bit support\n# This needs to be 2MB aligned for 64-bit support\n# ifeq ($(PLATFORM_RISCV_XLEN), 32)\n# FW_JUMP_ADDR=0x80400000\n# else\n# FW_JUMP_ADDR=0x80200000\n# endif\n# FW_JUMP_FDT_ADDR=0x82200000\n\n#\n# Firmware with payload configuration.\n# Optional parameters are commented out. Uncomment and define these parameters\n# as needed.\n#\nFW_PAYLOAD=<y|n>\n# This needs to be 4MB aligned for 32-bit support\n# This needs to be 2MB aligned for 64-bit support\nifeq ($(PLATFORM_RISCV_XLEN), 32)\nFW_PAYLOAD_OFFSET=0x400000\nelse\nFW_PAYLOAD_OFFSET=0x200000\nendif\n# FW_PAYLOAD_ALIGN=0x1000\n# FW_PAYLOAD_PATH=\"path to next boot stage binary image file\"\n# FW_PAYLOAD_FDT_ADDR=0x82200000\n"
  },
  {
    "path": "ftpm-opensbi/platform/template/platform.c",
    "content": "/*\n * SPDX-License-Identifier: BSD-2-Clause\n *\n * Copyright (c) 2019 Western Digital Corporation or its affiliates.\n */\n\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/sbi_const.h>\n#include <sbi/sbi_platform.h>\n\n/*\n * Include these files as needed.\n * See objects.mk PLATFORM_xxx configuration parameters.\n */\n#include <sbi_utils/ipi/aclint_mswi.h>\n#include <sbi_utils/irqchip/plic.h>\n#include <sbi_utils/serial/uart8250.h>\n#include <sbi_utils/timer/aclint_mtimer.h>\n\n#define PLATFORM_PLIC_ADDR\t\t0xc000000\n#define PLATFORM_PLIC_NUM_SOURCES\t128\n#define PLATFORM_HART_COUNT\t\t4\n#define PLATFORM_CLINT_ADDR\t\t0x2000000\n#define PLATFORM_ACLINT_MTIMER_FREQ\t10000000\n#define PLATFORM_ACLINT_MSWI_ADDR\t(PLATFORM_CLINT_ADDR + \\\n\t\t\t\t\t CLINT_MSWI_OFFSET)\n#define PLATFORM_ACLINT_MTIMER_ADDR\t(PLATFORM_CLINT_ADDR + \\\n\t\t\t\t\t CLINT_MTIMER_OFFSET)\n#define PLATFORM_UART_ADDR\t\t0x09000000\n#define PLATFORM_UART_INPUT_FREQ\t10000000\n#define PLATFORM_UART_BAUDRATE\t\t115200\n\nstatic struct plic_data plic = {\n\t.addr = PLATFORM_PLIC_ADDR,\n\t.num_src = PLATFORM_PLIC_NUM_SOURCES,\n};\n\nstatic struct aclint_mswi_data mswi = {\n\t.addr = PLATFORM_ACLINT_MSWI_ADDR,\n\t.size = ACLINT_MSWI_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = PLATFORM_HART_COUNT,\n};\n\nstatic struct aclint_mtimer_data mtimer = {\n\t.mtime_freq = PLATFORM_ACLINT_MTIMER_FREQ,\n\t.mtime_addr = PLATFORM_ACLINT_MTIMER_ADDR +\n\t\t      ACLINT_DEFAULT_MTIME_OFFSET,\n\t.mtime_size = ACLINT_DEFAULT_MTIME_SIZE,\n\t.mtimecmp_addr = PLATFORM_ACLINT_MTIMER_ADDR +\n\t\t\t ACLINT_DEFAULT_MTIMECMP_OFFSET,\n\t.mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE,\n\t.first_hartid = 0,\n\t.hart_count = PLATFORM_HART_COUNT,\n\t.has_64bit_mmio = TRUE,\n};\n\n/*\n * Platform early initialization.\n */\nstatic int platform_early_init(bool cold_boot)\n{\n\treturn 0;\n}\n\n/*\n * Platform final initialization.\n */\nstatic int platform_final_init(bool cold_boot)\n{\n\treturn 0;\n}\n\n/*\n * Initialize the platform console.\n */\nstatic int platform_console_init(void)\n{\n\t/* Example if the generic UART8250 driver is used */\n\treturn uart8250_init(PLATFORM_UART_ADDR, PLATFORM_UART_INPUT_FREQ,\n\t\t\t     PLATFORM_UART_BAUDRATE, 0, 1, 0);\n}\n\n/*\n * Initialize the platform interrupt controller for current HART.\n */\nstatic int platform_irqchip_init(bool cold_boot)\n{\n\tu32 hartid = current_hartid();\n\tint ret;\n\n\t/* Example if the generic PLIC driver is used */\n\tif (cold_boot) {\n\t\tret = plic_cold_irqchip_init(&plic);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn plic_warm_irqchip_init(&plic, 2 * hartid, 2 * hartid + 1);\n}\n\n/*\n * Initialize IPI for current HART.\n */\nstatic int platform_ipi_init(bool cold_boot)\n{\n\tint ret;\n\n\t/* Example if the generic ACLINT driver is used */\n\tif (cold_boot) {\n\t\tret = aclint_mswi_cold_init(&mswi);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn aclint_mswi_warm_init();\n}\n\n/*\n * Initialize platform timer for current HART.\n */\nstatic int platform_timer_init(bool cold_boot)\n{\n\tint ret;\n\n\t/* Example if the generic ACLINT driver is used */\n\tif (cold_boot) {\n\t\tret = aclint_mtimer_cold_init(&mtimer, NULL);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\n\treturn aclint_mtimer_warm_init();\n}\n\n/*\n * Platform descriptor.\n */\nconst struct sbi_platform_operations platform_ops = {\n\t.early_init\t\t= platform_early_init,\n\t.final_init\t\t= platform_final_init,\n\t.console_init\t\t= platform_console_init,\n\t.irqchip_init\t\t= platform_irqchip_init,\n\t.ipi_init\t\t= platform_ipi_init,\n\t.timer_init\t\t= platform_timer_init\n};\nconst struct sbi_platform platform = {\n\t.opensbi_version\t= OPENSBI_VERSION,\n\t.platform_version\t= SBI_PLATFORM_VERSION(0x0, 0x00),\n\t.name\t\t\t= \"platform-name\",\n\t.features\t\t= SBI_PLATFORM_DEFAULT_FEATURES,\n\t.hart_count\t\t= 1,\n\t.hart_stack_size\t= SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,\n\t.platform_ops_addr\t= (unsigned long)&platform_ops\n};\n"
  },
  {
    "path": "ftpm-opensbi/platform/vivado-risc-v/Kconfig",
    "content": "# SPDX-License-Identifier: BSD-2-Clause\n\nconfig PLATFORM_VIVADO_RISC_V\n\tbool\n\tselect FDT\n\tselect IPI_MSWI\n\tselect IRQCHIP_PLIC\n\tselect TIMER_MTIMER\n        select FDT_TIMER\n\tdefault y\n"
  },
  {
    "path": "ftpm-opensbi/platform/vivado-risc-v/configs/defconfig",
    "content": "CONFIG_PLATFORM_VIVADO_RISC_V=y\nCONFIG_FDT_IPI=y\nCONFIG_FDT_IPI_MSWI=y\nCONFIG_FDT_IPI_PLICSW=y\nCONFIG_FDT_IRQCHIP=y\nCONFIG_FDT_IRQCHIP_APLIC=y\nCONFIG_FDT_IRQCHIP_IMSIC=y\nCONFIG_FDT_IRQCHIP_PLIC=y\nCONFIG_FDT_TIMER=y\nCONFIG_FDT_TIMER_MTIMER=y\nCONFIG_FDT_TIMER_PLMT=y\n"
  },
  {
    "path": "ftpm-opensbi/platform/vivado-risc-v/fatfs/diskio.c",
    "content": "\r\n#include <sbi/sbi_console.h>\r\n\r\n#include \"fatfs/ff.h\"\t\t\t/* Obtains integer types */\r\n#include \"fatfs/diskio.h\"\t\t/* Declarations of disk functions */\r\n\r\n/* Definitions of physical drive number for each drive */\r\n#define DEV_RAM\t\t0\t/* Example: Map Ramdisk to physical drive 0 */\r\n#define DEV_MMC\t\t1\t/* Example: Map MMC/SD card to physical drive 1 */\r\n#define DEV_USB\t\t2\t/* Example: Map USB MSD to physical drive 2 */\r\n\r\n/*--------------------------------------------------------------------------------------------*/\r\n\r\n/* Card type flags (card_type) */\r\n#define CT_MMC          0x01            /* MMC ver 3 */\r\n#define CT_SD1          0x02            /* SD ver 1 */\r\n#define CT_SD2          0x04            /* SD ver 2 */\r\n#define CT_SDC          (CT_SD1|CT_SD2) /* SD */\r\n#define CT_BLOCK        0x08            /* Block addressing */\r\n\r\n#define CMD0    (0)             /* GO_IDLE_STATE */\r\n#define CMD1    (1)             /* SEND_OP_COND */\r\n#define CMD2    (2)             /* SEND_CID */\r\n#define CMD3    (3)             /* RELATIVE_ADDR */\r\n#define CMD4    (4)\r\n#define CMD5    (5)             /* SLEEP_WAKE (SDC) */\r\n#define CMD6    (6)             /* SWITCH_FUNC */\r\n#define CMD7    (7)             /* SELECT */\r\n#define CMD8    (8)             /* SEND_IF_COND */\r\n#define CMD9    (9)             /* SEND_CSD */\r\n#define CMD10   (10)            /* SEND_CID */\r\n#define CMD11   (11)\r\n#define CMD12   (12)            /* STOP_TRANSMISSION */\r\n#define CMD13   (13)\r\n#define CMD15   (15)\r\n#define CMD16   (16)            /* SET_BLOCKLEN */\r\n#define CMD17   (17)            /* READ_SINGLE_BLOCK */\r\n#define CMD18   (18)            /* READ_MULTIPLE_BLOCK */\r\n#define CMD19   (19)\r\n#define CMD20   (20)\r\n#define CMD23   (23)\r\n#define CMD24   (24)\r\n#define CMD25   (25)\r\n#define CMD27   (27)\r\n#define CMD28   (28)\r\n#define CMD29   (29)\r\n#define CMD30   (30)\r\n#define CMD32   (32)\r\n#define CMD33   (33)\r\n#define CMD38   (38)\r\n#define CMD42   (42)\r\n#define CMD55   (55)            /* APP_CMD */\r\n#define CMD56   (56)\r\n#define ACMD6   (0x80+6)        /* define the data bus width */\r\n#define ACMD41  (0x80+41)       /* SEND_OP_COND (ACMD) */\r\n\r\n// Capability bits\r\n#define SDC_CAPABILITY_SD_4BIT  0x0001\r\n#define SDC_CAPABILITY_SD_RESET 0x0002\r\n#define SDC_CAPABILITY_ADDR     0xff00\r\n\r\n// Control bits\r\n#define SDC_CONTROL_SD_4BIT     0x0001\r\n#define SDC_CONTROL_SD_RESET    0x0002\r\n\r\n// Card detect bits\r\n#define SDC_CARD_INSERT_INT_EN  0x0001\r\n#define SDC_CARD_INSERT_INT_REQ 0x0002\r\n#define SDC_CARD_REMOVE_INT_EN  0x0004\r\n#define SDC_CARD_REMOVE_INT_REQ 0x0008\r\n\r\n// Command status bits\r\n#define SDC_CMD_INT_STATUS_CC   0x0001  // Command complete\r\n#define SDC_CMD_INT_STATUS_EI   0x0002  // Any error\r\n#define SDC_CMD_INT_STATUS_CTE  0x0004  // Timeout\r\n#define SDC_CMD_INT_STATUS_CCRC 0x0008  // CRC error\r\n#define SDC_CMD_INT_STATUS_CIE  0x0010  // Command code check error\r\n\r\n// Data status bits\r\n#define SDC_DAT_INT_STATUS_TRS  0x0001  // Transfer complete\r\n#define SDC_DAT_INT_STATUS_ERR  0x0002  // Any error\r\n#define SDC_DAT_INT_STATUS_CTE  0x0004  // Timeout\r\n#define SDC_DAT_INT_STATUS_CRC  0x0008  // CRC error\r\n#define SDC_DAT_INT_STATUS_CFE  0x0010  // Data FIFO underrun or overrun\r\n\r\n#define ERR_EOF             30\r\n#define ERR_NOT_ELF         31\r\n#define ERR_ELF_BITS        32\r\n#define ERR_ELF_ENDIANNESS  33\r\n#define ERR_CMD_CRC         34\r\n#define ERR_CMD_CHECK       35\r\n#define ERR_DATA_CRC        36\r\n#define ERR_DATA_FIFO       37\r\n#define ERR_BUF_ALIGNMENT   38\r\n\r\nstruct sdc_regs {\r\n    volatile uint32_t argument;\r\n    volatile uint32_t command;\r\n    volatile uint32_t response1;\r\n    volatile uint32_t response2;\r\n    volatile uint32_t response3;\r\n    volatile uint32_t response4;\r\n    volatile uint32_t data_timeout;\r\n    volatile uint32_t control;\r\n    volatile uint32_t cmd_timeout;\r\n    volatile uint32_t clock_divider;\r\n    volatile uint32_t software_reset;\r\n    volatile uint32_t power_control;\r\n    volatile uint32_t capability;\r\n    volatile uint32_t cmd_int_status;\r\n    volatile uint32_t cmd_int_enable;\r\n    volatile uint32_t dat_int_status;\r\n    volatile uint32_t dat_int_enable;\r\n    volatile uint32_t block_size;\r\n    volatile uint32_t block_count;\r\n    volatile uint32_t card_detect;\r\n    volatile uint32_t res_50;\r\n    volatile uint32_t res_54;\r\n    volatile uint32_t res_58;\r\n    volatile uint32_t res_5c;\r\n    volatile uint64_t dma_addres;\r\n};\r\n\r\n#define MAX_BLOCK_CNT 0x1000\r\n\r\n/* Note: .data section not supported in BootROM */\r\n\r\nstatic struct sdc_regs * const regs __attribute__((section(\".rodata\"))) = (struct sdc_regs *)0x60000000;\r\n\r\nint errno __attribute__((section(\".bss\")));\r\nstatic DSTATUS drv_status __attribute__((section(\".bss\")));\r\nstatic BYTE card_type __attribute__((section(\".bss\")));\r\nstatic uint32_t response[4] __attribute__((section(\".bss\")));\r\nstatic FATFS fatfs __attribute__((section(\".bss\")));\r\nstatic int alt_mem __attribute__((section(\".bss\")));\r\nstatic FIL fd __attribute__((section(\".bss\")));\r\n\r\n\r\nconst char * errno_to_str(void) {\r\n    switch (errno) {\r\n    case FR_OK: return \"No error\";\r\n    case FR_DISK_ERR: return \"Disk I/O error\";\r\n    case FR_INT_ERR: return \"Assertion failed\";\r\n    case FR_NOT_READY: return \"Disk not ready\";\r\n    case FR_NO_FILE: return \"File not found\";\r\n    case FR_NO_PATH: return \"Path not found\";\r\n    case FR_INVALID_NAME: return \"Invalid path\";\r\n    case FR_DENIED: return \"Access denied\";\r\n    case FR_EXIST: return \"Already exist\";\r\n    case FR_INVALID_OBJECT: return \"The FS object is invalid\";\r\n    case FR_WRITE_PROTECTED: return \"The drive is write protected\";\r\n    case FR_INVALID_DRIVE: return \"The drive number is invalid\";\r\n    case FR_NOT_ENABLED: return \"The volume has no work area\";\r\n    case FR_NO_FILESYSTEM: return \"Not a valid FAT volume\";\r\n    case FR_MKFS_ABORTED: return \"The f_mkfs() aborted\";\r\n    case FR_TIMEOUT: return \"Timeout\";\r\n    case FR_LOCKED: return \"Locked\";\r\n    case FR_NOT_ENOUGH_CORE: return \"Not enough memory\";\r\n    case FR_TOO_MANY_OPEN_FILES: return \"Too many open files\";\r\n    case ERR_EOF: return \"Unexpected EOF\";\r\n    case ERR_NOT_ELF: return \"Not an ELF file\";\r\n    case ERR_ELF_BITS: return \"Wrong ELF word size\";\r\n    case ERR_ELF_ENDIANNESS: return \"Wrong ELF endianness\";\r\n    case ERR_CMD_CRC: return \"Command CRC error\";\r\n    case ERR_CMD_CHECK: return \"Command code check error\";\r\n    case ERR_DATA_CRC: return \"Data CRC error\";\r\n    case ERR_DATA_FIFO: return \"Data FIFO error\";\r\n    case ERR_BUF_ALIGNMENT: return \"Bad buffer alignment\";\r\n    }\r\n    return \"Unknown error code\";\r\n}\r\n\r\nstatic void usleep(unsigned us) {\r\n    uintptr_t cycles0;\r\n    uintptr_t cycles1;\r\n    asm volatile (\"csrr %0, 0xB00\" : \"=r\" (cycles0));\r\n    for (;;) {\r\n        asm volatile (\"csrr %0, 0xB00\" : \"=r\" (cycles1));\r\n        if (cycles1 - cycles0 >= us * 100) break;\r\n    }\r\n}\r\n\r\nstatic int sdc_cmd_finish(unsigned cmd) {\r\n    while (1) {\r\n        unsigned status = regs->cmd_int_status;\r\n        if (status) {\r\n            // clear interrupts\r\n            regs->cmd_int_status = 0;\r\n            while (regs->software_reset != 0) {}\r\n            if (status == SDC_CMD_INT_STATUS_CC) {\r\n                // get response\r\n                response[0] = regs->response1;\r\n                response[1] = regs->response2;\r\n                response[2] = regs->response3;\r\n                response[3] = regs->response4;\r\n                return 0;\r\n            }\r\n            errno = FR_DISK_ERR;\r\n            if (status & SDC_CMD_INT_STATUS_CTE) errno = FR_TIMEOUT;\r\n            if (status & SDC_CMD_INT_STATUS_CCRC) errno = ERR_CMD_CRC;\r\n            if (status & SDC_CMD_INT_STATUS_CIE) errno = ERR_CMD_CHECK;\r\n            break;\r\n        }\r\n    }\r\n    return -1;\r\n}\r\n\r\nstatic int sdc_data_finish(void) {\r\n    int status;\r\n\r\n    while ((status = regs->dat_int_status) == 0) {}\r\n    regs->dat_int_status = 0;\r\n    while (regs->software_reset != 0) {}\r\n\r\n    if (status == SDC_DAT_INT_STATUS_TRS) return 0;\r\n    errno = FR_DISK_ERR;\r\n    if (status & SDC_DAT_INT_STATUS_CTE) errno = FR_TIMEOUT;\r\n    if (status & SDC_DAT_INT_STATUS_CRC) errno = ERR_DATA_CRC;\r\n    if (status & SDC_DAT_INT_STATUS_CFE) errno = ERR_DATA_FIFO;\r\n    return -1;\r\n}\r\n\r\n\r\nstatic int send_data_cmd(unsigned cmd, unsigned arg, void * buf, unsigned blocks) {\r\n    unsigned command = (cmd & 0x3f) << 8;\r\n    switch (cmd) {\r\n    case CMD0:\r\n    case CMD4:\r\n    case CMD15:\r\n        // No responce\r\n        break;\r\n    case CMD11:\r\n    case CMD13:\r\n    case CMD16:\r\n    case CMD17:\r\n    case CMD18:\r\n    case CMD19:\r\n    case CMD23:\r\n    case CMD24:\r\n    case CMD25:\r\n    case CMD27:\r\n    case CMD30:\r\n    case CMD32:\r\n    case CMD33:\r\n    case CMD42:\r\n    case CMD55:\r\n    case CMD56:\r\n    case ACMD6:\r\n        // R1\r\n        command |= 1; // 48 bits\r\n        command |= 1 << 3; // resp CRC\r\n        command |= 1 << 4; // resp OPCODE\r\n        break;\r\n    case CMD7:\r\n    case CMD12:\r\n    case CMD20:\r\n    case CMD28:\r\n    case CMD29:\r\n    case CMD38:\r\n        // R1b\r\n        command |= 1; // 48 bits\r\n        command |= 1 << 2; // busy\r\n        command |= 1 << 3; // resp CRC\r\n        command |= 1 << 4; // resp OPCODE\r\n        break;\r\n    case CMD2:\r\n    case CMD9:\r\n    case CMD10:\r\n        // R2\r\n        command |= 2; // 136 bits\r\n        command |= 1 << 3; // resp CRC\r\n        break;\r\n    case ACMD41:\r\n        // R3\r\n        command |= 1; // 48 bits\r\n        break;\r\n    case CMD3:\r\n        // R6\r\n        command |= 1; // 48 bits\r\n        command |= 1 << 2; // busy\r\n        command |= 1 << 3; // resp CRC\r\n        command |= 1 << 4; // resp OPCODE\r\n        break;\r\n    case CMD8:\r\n        // R7\r\n        command |= 1; // 48 bits\r\n        command |= 1 << 3; // resp CRC\r\n        command |= 1 << 4; // resp OPCODE\r\n        break;\r\n    }\r\n\r\n    if (blocks) {\r\n        command |= 1 << 5;\r\n        if ((intptr_t)buf & 3) {\r\n            errno = ERR_BUF_ALIGNMENT;\r\n            return -1;\r\n        }\r\n        regs->dma_addres = (uint64_t)(intptr_t)buf;\r\n        regs->block_size = 511;\r\n        regs->block_count = blocks - 1;\r\n        regs->data_timeout = 0xFFFFFF;\r\n    }\r\n\r\n    regs->command = command;\r\n    regs->cmd_timeout = 0xFFFFF;\r\n    regs->argument = arg;\r\n\r\n    if (sdc_cmd_finish(cmd) < 0) return -1;\r\n    if (blocks) return sdc_data_finish();\r\n\r\n    return 0;\r\n}\r\n\r\n\r\nstatic int send_data_cmd_r(unsigned cmd, unsigned arg, void * buf, unsigned blocks) {\r\n    unsigned command = (cmd & 0x3f) << 8;\r\n\r\n    // R1\r\n    command |= 1; // 48 bits\r\n    command |= 1 << 3; // resp CRC\r\n    command |= 1 << 4; // resp OPCODE\r\n\r\n    if (blocks) {\r\n        command |= 1 << 5;\r\n        \r\n        if ((intptr_t)buf & 3) {\r\n            errno = ERR_BUF_ALIGNMENT;\r\n            return -1;\r\n        }\r\n        regs->dma_addres = (uint64_t)(intptr_t)buf;\r\n        regs->block_size = 511;\r\n        regs->block_count = blocks - 1;\r\n        regs->data_timeout = 0xFFFFFF;\r\n    }\r\n\r\n    regs->command = command;\r\n    regs->cmd_timeout = 0xFFFFF;\r\n    regs->argument = arg;\r\n\r\n    if (sdc_cmd_finish(cmd) < 0) return -1;\r\n    if (blocks) return sdc_data_finish();\r\n\r\n    return 0;\r\n}\r\n\r\nstatic int send_data_cmd_w(unsigned cmd, unsigned arg, const void * buf, unsigned blocks) {\r\n    unsigned command = (cmd & 0x3f) << 8;\r\n\r\n    // R1\r\n    command |= 1; // 48 bits\r\n    // command |= 1 << 2;\r\n    command |= 1 << 3; // resp CRC\r\n    command |= 1 << 4; // resp OPCODE\r\n\r\n    if (blocks) {\r\n        command |= 1 << 6;\r\n        \r\n        if ((intptr_t)buf & 3) {\r\n            errno = ERR_BUF_ALIGNMENT;\r\n            sbi_printf(\"[fTPM] send_data_cmd_w(): ERR_BUF_ALIGNMENT!!!\\n\");\r\n            return -1;\r\n        }\r\n        regs->dma_addres = (uint64_t)(intptr_t)buf;\r\n        regs->block_size = 511;\r\n        regs->block_count = blocks - 1;\r\n\r\n        // uint64_t timeout = (uint64_t)blocks * 512 * 8 / 1;\r\n        // timeout += (uint64_t)25000000 / 1000 * blocks;\r\n        // timeout += (uint64_t)25000000 / 100; // 10ms\r\n        // if (timeout > 0xffffff) timeout = 0;\r\n\r\n        // regs->data_timeout = timeout;\r\n\r\n        regs->data_timeout = 0xFFFFFF;\r\n    }\r\n\r\n    regs->command = command;\r\n    regs->cmd_timeout = 0xFFFFF;\r\n    regs->argument = arg;\r\n\r\n    if (sdc_cmd_finish(cmd) < 0) return -1;\r\n    if (blocks) return sdc_data_finish();\r\n\r\n    return 0;\r\n}\r\n\r\n#define send_cmd(cmd, arg) send_data_cmd(cmd, arg, NULL, 0)\r\n\r\n\r\n\r\nstatic int ini_sd(void) {\r\n    unsigned rca;\r\n\r\n    /* Reset controller */\r\n    regs->software_reset = 1;\r\n    while ((regs->software_reset & 1) == 0) {}\r\n    regs->clock_divider = 0x7c;\r\n    regs->software_reset = 0;\r\n    while (regs->software_reset) {}\r\n    usleep(5000);\r\n\r\n    card_type = 0;\r\n    drv_status = STA_NOINIT;\r\n\r\n    if (regs->capability & SDC_CAPABILITY_SD_RESET) {\r\n        /* Power cycle SD card */\r\n        regs->control |= SDC_CONTROL_SD_RESET;\r\n        usleep(1000000);\r\n        regs->control &= ~SDC_CONTROL_SD_RESET;\r\n        usleep(100000);\r\n    }\r\n\r\n    /* Enter Idle state */\r\n    send_cmd(CMD0, 0);\r\n\r\n    card_type = CT_SD1;\r\n    if (send_cmd(CMD8, 0x1AA) == 0) {\r\n        if ((response[0] & 0xfff) != 0x1AA) {\r\n            errno = ERR_CMD_CHECK;\r\n            return -1;\r\n        }\r\n        card_type = CT_SD2;\r\n    }\r\n\r\n    /* Wait for leaving idle state (ACMD41 with HCS bit) */\r\n    while (1) {\r\n        /* ACMD41, Set Operating Conditions: Host High Capacity & 3.3V */\r\n        if (send_cmd(CMD55, 0) < 0 || send_cmd(ACMD41, 0x40300000) < 0) return -1;\r\n        if (response[0] & (1 << 31)) {\r\n            if (response[0] & (1 << 30)) card_type |= CT_BLOCK;\r\n            break;\r\n        }\r\n    }\r\n\r\n    /* Enter Identification state */\r\n    if (send_cmd(CMD2, 0) < 0) return -1;\r\n\r\n    /* Get RCA (Relative Card Address) */\r\n    rca = 0x1234;\r\n    if (send_cmd(CMD3, rca << 16) < 0) return -1;\r\n    rca = response[0] >> 16;\r\n\r\n    /* Select card */\r\n    if (send_cmd(CMD7, rca << 16) < 0) return -1;\r\n\r\n    /* Clock 25MHz */\r\n    regs->clock_divider = 3;\r\n    usleep(10000);\r\n\r\n    /* Bus width 1-bit */\r\n    regs->control = 0;\r\n    if (send_cmd(CMD55, rca << 16) < 0 || send_cmd(ACMD6, 0) < 0) return -1;\r\n\r\n    /* Set R/W block length to 512 */\r\n    if (send_cmd(CMD16, 512) < 0) return -1;\r\n\r\n    drv_status &= ~STA_NOINIT;\r\n    return 0;\r\n}\r\n\r\n\r\n\r\nDSTATUS disk_initialize (\r\n\tBYTE pdrv\t\t\t\t/* Physical drive nmuber to identify the drive */\r\n)\r\n{\r\n\t// DSTATUS stat;\r\n\t// int result;\r\n\r\n\t// switch (pdrv) {\r\n\t// case DEV_RAM :\r\n\t// \tresult = RAM_disk_initialize();\r\n\r\n\t// \t// translate the reslut code here\r\n\r\n\t// \treturn stat;\r\n\r\n\t// case DEV_MMC :\r\n\t// \tresult = MMC_disk_initialize();\r\n\r\n\t// \t// translate the reslut code here\r\n\r\n\t// \treturn stat;\r\n\r\n\t// case DEV_USB :\r\n\t// \tresult = USB_disk_initialize();\r\n\r\n\t// \t// translate the reslut code here\r\n\r\n\t// \treturn stat;\r\n\t// }\r\n\t// return STA_NOINIT;\r\n\r\n    if (ini_sd() < 0) sbi_printf(\"Cannot access SD: %s\\n\", errno_to_str());\r\n    return drv_status;\r\n}\r\n\r\nDSTATUS disk_status(BYTE drv) {\r\n    return drv_status;\r\n}\r\n\r\n\r\n\r\n/*-----------------------------------------------------------------------*/\r\n/* Read Sector(s)                                                        */\r\n/*-----------------------------------------------------------------------*/\r\n\r\nDRESULT disk_read (\r\n\tBYTE pdrv,\t\t/* Physical drive nmuber to identify the drive */\r\n\tBYTE *buff,\t\t/* Data buffer to store read data */\r\n\tLBA_t sector,\t/* Start sector in LBA */\r\n\tUINT count\t\t/* Number of sectors to read */\r\n)\r\n{\r\n\t// DRESULT res;\r\n\t// int result;\r\n\r\n\t// switch (pdrv) {\r\n\t// case DEV_RAM :\r\n\t// \t// translate the arguments here\r\n\r\n\t// \tresult = RAM_disk_read(buff, sector, count);\r\n\r\n\t// \t// translate the reslut code here\r\n\r\n\t// \treturn res;\r\n\r\n\t// case DEV_MMC :\r\n\t// \t// translate the arguments here\r\n\r\n\t// \tresult = MMC_disk_read(buff, sector, count);\r\n\r\n\t// \t// translate the reslut code here\r\n\r\n\t// \treturn res;\r\n\r\n\t// case DEV_USB :\r\n\t// \t// translate the arguments here\r\n\r\n\t// \tresult = USB_disk_read(buff, sector, count);\r\n\r\n\t// \t// translate the reslut code here\r\n\r\n\t// \treturn res;\r\n\t// }\r\n\r\n\t// return RES_PARERR;\r\n\r\n    if (!count) return RES_PARERR;\r\n    if (drv_status & STA_NOINIT) return RES_NOTRDY;\r\n\r\n    // sbi_printf(\"[fTPM] disk_read(): buff=%p, sector=%x, count=%x\\n\", buff, sector, count);\r\n    /* Convert LBA to byte address if needed */\r\n    if (!(card_type & CT_BLOCK)) sector *= 512;\r\n    while (count > 0) {\r\n        UINT bcnt = count > MAX_BLOCK_CNT ? MAX_BLOCK_CNT : count;\r\n        unsigned bytes = bcnt * 512;\r\n        if (send_data_cmd_r(bcnt == 1 ? CMD17 : CMD18, sector, buff, bcnt) < 0) return RES_ERROR;\r\n        if (bcnt > 1 && send_cmd(CMD12, 0) < 0) return RES_ERROR;\r\n        sector += (card_type & CT_BLOCK) ? bcnt : bytes;\r\n        count -= bcnt;\r\n        buff += bytes;\r\n    }\r\n\r\n    return RES_OK;\r\n}\r\n\r\n\r\n\r\n/*-----------------------------------------------------------------------*/\r\n/* Write Sector(s)                                                       */\r\n/*-----------------------------------------------------------------------*/\r\n\r\n#if FF_FS_READONLY == 0\r\n\r\nDRESULT disk_write (\r\n\tBYTE pdrv,\t\t\t/* Physical drive nmuber to identify the drive */\r\n\tconst BYTE *buff,\t/* Data to be written */\r\n\tLBA_t sector,\t\t/* Start sector in LBA */\r\n\tUINT count\t\t\t/* Number of sectors to write */\r\n)\r\n{\r\n\t// DRESULT res;\r\n\t// int result;\r\n\r\n\t// switch (pdrv) {\r\n\t// case DEV_RAM :\r\n\t// \t// translate the arguments here\r\n\r\n\t// \tresult = RAM_disk_write(buff, sector, count);\r\n\r\n\t// \t// translate the reslut code here\r\n\r\n\t// \treturn res;\r\n\r\n\t// case DEV_MMC :\r\n\t// \t// translate the arguments here\r\n\r\n\t// \tresult = MMC_disk_write(buff, sector, count);\r\n\r\n\t// \t// translate the reslut code here\r\n\r\n\t// \treturn res;\r\n\r\n\t// case DEV_USB :\r\n\t// \t// translate the arguments here\r\n\r\n\t// \tresult = USB_disk_write(buff, sector, count);\r\n\r\n\t// \t// translate the reslut code here\r\n\r\n\t// \treturn res;\r\n\t// }\r\n\r\n\t// return RES_PARERR;\r\n\r\n    if (!count) return RES_PARERR;\r\n    if (drv_status & STA_NOINIT) return RES_NOTRDY;\r\n\r\n    // sbi_printf(\"[fTPM] disk_write(): buff=%p, sector=%x, count=%x\\n\", buff, sector, count);\r\n\r\n    /* Convert LBA to byte address if needed */\r\n    if (!(card_type & CT_BLOCK)) sector *= 512;\r\n    for (UINT i = 0; i < count; ++i) {\r\n        UINT bcnt = count > MAX_BLOCK_CNT ? MAX_BLOCK_CNT : count;\r\n        unsigned bytes = bcnt * 512;\r\n        if (send_data_cmd_w(bcnt == 1 ? CMD24 : CMD25, sector, buff, bcnt) < 0) return RES_ERROR;\r\n        if (bcnt > 1 && send_cmd(CMD12, 0) < 0) return RES_ERROR;\r\n        sector += (card_type & CT_BLOCK) ? bcnt : bytes;\r\n        count -= bcnt;\r\n        buff += bytes;\r\n    }\r\n\r\n    return RES_OK; // Successfully written\r\n}\r\n\r\n#endif\r\n\r\n\r\n/*-----------------------------------------------------------------------*/\r\n/* Miscellaneous Functions                                               */\r\n/*-----------------------------------------------------------------------*/\r\n\r\nDRESULT disk_ioctl (\r\n\tBYTE pdrv,\t\t/* Physical drive nmuber (0..) */\r\n\tBYTE cmd,\t\t/* Control code */\r\n\tvoid *buff\t\t/* Buffer to send/receive control data */\r\n)\r\n{\r\n\tDRESULT res;\r\n\tint result;\r\n\r\n    sbi_printf(\"[FATFS] disk_ioctl(): cmd=%x\\n\", cmd);\r\n\r\n\tswitch (pdrv) {\r\n\tcase DEV_RAM :\r\n\r\n\t\t// Process of the command for the RAM drive\r\n\r\n\t\treturn res;\r\n\r\n\tcase DEV_MMC :\r\n\r\n\t\t// Process of the command for the MMC/SD card\r\n\r\n\t\treturn res;\r\n\r\n\tcase DEV_USB :\r\n\r\n\t\t// Process of the command the USB drive\r\n\r\n\t\treturn res;\r\n\t}\r\n\r\n\treturn RES_PARERR;\r\n}\r\n\r\n"
  },
  {
    "path": "ftpm-opensbi/platform/vivado-risc-v/fatfs/ffsystem.c",
    "content": "/*------------------------------------------------------------------------*/\r\n/* A Sample Code of User Provided OS Dependent Functions for FatFs        */\r\n/*------------------------------------------------------------------------*/\r\n\r\n#include \"fatfs/ff.h\"\r\n\r\n\r\n#if FF_USE_LFN == 3\t/* Use dynamic memory allocation */\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* Allocate/Free a Memory Block                                           */\r\n/*------------------------------------------------------------------------*/\r\n\r\n#include <stdlib.h>\t\t/* with POSIX API */\r\n\r\n\r\nvoid* ff_memalloc (\t/* Returns pointer to the allocated memory block (null if not enough core) */\r\n\tUINT msize\t\t/* Number of bytes to allocate */\r\n)\r\n{\r\n\treturn malloc((size_t)msize);\t/* Allocate a new memory block */\r\n}\r\n\r\n\r\nvoid ff_memfree (\r\n\tvoid* mblock\t/* Pointer to the memory block to free (no effect if null) */\r\n)\r\n{\r\n\tfree(mblock);\t/* Free the memory block */\r\n}\r\n\r\n#endif\r\n\r\n\r\n\r\n\r\n#if FF_FS_REENTRANT\t/* Mutal exclusion */\r\n/*------------------------------------------------------------------------*/\r\n/* Definitions of Mutex                                                   */\r\n/*------------------------------------------------------------------------*/\r\n\r\n#define OS_TYPE\t0\t/* 0:Win32, 1:uITRON4.0, 2:uC/OS-II, 3:FreeRTOS, 4:CMSIS-RTOS */\r\n\r\n\r\n#if   OS_TYPE == 0\t/* Win32 */\r\n#include <windows.h>\r\nstatic HANDLE Mutex[FF_VOLUMES + 1];\t/* Table of mutex handle */\r\n\r\n#elif OS_TYPE == 1\t/* uITRON */\r\n#include \"itron.h\"\r\n#include \"kernel.h\"\r\nstatic mtxid Mutex[FF_VOLUMES + 1];\t\t/* Table of mutex ID */\r\n\r\n#elif OS_TYPE == 2\t/* uc/OS-II */\r\n#include \"includes.h\"\r\nstatic OS_EVENT *Mutex[FF_VOLUMES + 1];\t/* Table of mutex pinter */\r\n\r\n#elif OS_TYPE == 3\t/* FreeRTOS */\r\n#include \"FreeRTOS.h\"\r\n#include \"semphr.h\"\r\nstatic SemaphoreHandle_t Mutex[FF_VOLUMES + 1];\t/* Table of mutex handle */\r\n\r\n#elif OS_TYPE == 4\t/* CMSIS-RTOS */\r\n#include \"cmsis_os.h\"\r\nstatic osMutexId Mutex[FF_VOLUMES + 1];\t/* Table of mutex ID */\r\n\r\n#endif\r\n\r\n\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* Create a Mutex                                                         */\r\n/*------------------------------------------------------------------------*/\r\n/* This function is called in f_mount function to create a new mutex\r\n/  or semaphore for the volume. When a 0 is returned, the f_mount function\r\n/  fails with FR_INT_ERR.\r\n*/\r\n\r\nint ff_mutex_create (\t/* Returns 1:Function succeeded or 0:Could not create the mutex */\r\n\tint vol\t\t\t\t/* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */\r\n)\r\n{\r\n#if OS_TYPE == 0\t/* Win32 */\r\n\tMutex[vol] = CreateMutex(NULL, FALSE, NULL);\r\n\treturn (int)(Mutex[vol] != INVALID_HANDLE_VALUE);\r\n\r\n#elif OS_TYPE == 1\t/* uITRON */\r\n\tT_CMTX cmtx = {TA_TPRI,1};\r\n\r\n\tMutex[vol] = acre_mtx(&cmtx);\r\n\treturn (int)(Mutex[vol] > 0);\r\n\r\n#elif OS_TYPE == 2\t/* uC/OS-II */\r\n\tOS_ERR err;\r\n\r\n\tMutex[vol] = OSMutexCreate(0, &err);\r\n\treturn (int)(err == OS_NO_ERR);\r\n\r\n#elif OS_TYPE == 3\t/* FreeRTOS */\r\n\tMutex[vol] = xSemaphoreCreateMutex();\r\n\treturn (int)(Mutex[vol] != NULL);\r\n\r\n#elif OS_TYPE == 4\t/* CMSIS-RTOS */\r\n\tosMutexDef(cmsis_os_mutex);\r\n\r\n\tMutex[vol] = osMutexCreate(osMutex(cmsis_os_mutex));\r\n\treturn (int)(Mutex[vol] != NULL);\r\n\r\n#endif\r\n}\r\n\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* Delete a Mutex                                                         */\r\n/*------------------------------------------------------------------------*/\r\n/* This function is called in f_mount function to delete a mutex or\r\n/  semaphore of the volume created with ff_mutex_create function.\r\n*/\r\n\r\nvoid ff_mutex_delete (\t/* Returns 1:Function succeeded or 0:Could not delete due to an error */\r\n\tint vol\t\t\t\t/* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */\r\n)\r\n{\r\n#if OS_TYPE == 0\t/* Win32 */\r\n\tCloseHandle(Mutex[vol]);\r\n\r\n#elif OS_TYPE == 1\t/* uITRON */\r\n\tdel_mtx(Mutex[vol]);\r\n\r\n#elif OS_TYPE == 2\t/* uC/OS-II */\r\n\tOS_ERR err;\r\n\r\n\tOSMutexDel(Mutex[vol], OS_DEL_ALWAYS, &err);\r\n\r\n#elif OS_TYPE == 3\t/* FreeRTOS */\r\n\tvSemaphoreDelete(Mutex[vol]);\r\n\r\n#elif OS_TYPE == 4\t/* CMSIS-RTOS */\r\n\tosMutexDelete(Mutex[vol]);\r\n\r\n#endif\r\n}\r\n\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* Request a Grant to Access the Volume                                   */\r\n/*------------------------------------------------------------------------*/\r\n/* This function is called on enter file functions to lock the volume.\r\n/  When a 0 is returned, the file function fails with FR_TIMEOUT.\r\n*/\r\n\r\nint ff_mutex_take (\t/* Returns 1:Succeeded or 0:Timeout */\r\n\tint vol\t\t\t/* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */\r\n)\r\n{\r\n#if OS_TYPE == 0\t/* Win32 */\r\n\treturn (int)(WaitForSingleObject(Mutex[vol], FF_FS_TIMEOUT) == WAIT_OBJECT_0);\r\n\r\n#elif OS_TYPE == 1\t/* uITRON */\r\n\treturn (int)(tloc_mtx(Mutex[vol], FF_FS_TIMEOUT) == E_OK);\r\n\r\n#elif OS_TYPE == 2\t/* uC/OS-II */\r\n\tOS_ERR err;\r\n\r\n\tOSMutexPend(Mutex[vol], FF_FS_TIMEOUT, &err));\r\n\treturn (int)(err == OS_NO_ERR);\r\n\r\n#elif OS_TYPE == 3\t/* FreeRTOS */\r\n\treturn (int)(xSemaphoreTake(Mutex[vol], FF_FS_TIMEOUT) == pdTRUE);\r\n\r\n#elif OS_TYPE == 4\t/* CMSIS-RTOS */\r\n\treturn (int)(osMutexWait(Mutex[vol], FF_FS_TIMEOUT) == osOK);\r\n\r\n#endif\r\n}\r\n\r\n\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* Release a Grant to Access the Volume                                   */\r\n/*------------------------------------------------------------------------*/\r\n/* This function is called on leave file functions to unlock the volume.\r\n*/\r\n\r\nvoid ff_mutex_give (\r\n\tint vol\t\t\t/* Mutex ID: Volume mutex (0 to FF_VOLUMES - 1) or system mutex (FF_VOLUMES) */\r\n)\r\n{\r\n#if OS_TYPE == 0\t/* Win32 */\r\n\tReleaseMutex(Mutex[vol]);\r\n\r\n#elif OS_TYPE == 1\t/* uITRON */\r\n\tunl_mtx(Mutex[vol]);\r\n\r\n#elif OS_TYPE == 2\t/* uC/OS-II */\r\n\tOSMutexPost(Mutex[vol]);\r\n\r\n#elif OS_TYPE == 3\t/* FreeRTOS */\r\n\txSemaphoreGive(Mutex[vol]);\r\n\r\n#elif OS_TYPE == 4\t/* CMSIS-RTOS */\r\n\tosMutexRelease(Mutex[vol]);\r\n\r\n#endif\r\n}\r\n\r\n#endif\t/* FF_FS_REENTRANT */\r\n\r\n"
  },
  {
    "path": "ftpm-opensbi/platform/vivado-risc-v/fatfs/ffunicode.c",
    "content": "/*------------------------------------------------------------------------*/\r\n/* Unicode Handling Functions for FatFs R0.13 and Later                   */\r\n/*------------------------------------------------------------------------*/\r\n/* This module will occupy a huge memory in the .rodata section when the  */\r\n/* FatFs is configured for LFN with DBCS. If the system has a Unicode     */\r\n/* library for the code conversion, this module should be modified to use */\r\n/* it to avoid silly memory consumption.                                  */\r\n/*------------------------------------------------------------------------*/\r\n/*\r\n/ Copyright (C) 2022, ChaN, all right reserved.\r\n/\r\n/ FatFs module is an open source software. Redistribution and use of FatFs in\r\n/ source and binary forms, with or without modification, are permitted provided\r\n/ that the following condition is met:\r\n/\r\n/ 1. Redistributions of source code must retain the above copyright notice,\r\n/    this condition and the following disclaimer.\r\n/\r\n/ This software is provided by the copyright holder and contributors \"AS IS\"\r\n/ and any warranties related to this software are DISCLAIMED.\r\n/ The copyright owner or contributors be NOT LIABLE for any damages caused\r\n/ by use of this software.\r\n*/\r\n\r\n\r\n#include \"fatfs/ff.h\"\r\n\r\n#if FF_USE_LFN != 0\t/* This module will be blanked if in non-LFN configuration */\r\n\r\n#define MERGE2(a, b) a ## b\r\n#define CVTBL(tbl, cp) MERGE2(tbl, cp)\r\n\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* Code Conversion Tables                                                 */\r\n/*------------------------------------------------------------------------*/\r\n\r\n#if FF_CODE_PAGE == 932 || FF_CODE_PAGE == 0\t/* Japanese */\r\nstatic const WCHAR uni2oem932[] = {\t/* Unicode --> Shift_JIS pairs */\r\n\t0x00A7, 0x8198, 0x00A8, 0x814E, 0x00B0, 0x818B, 0x00B1, 0x817D,\t0x00B4, 0x814C, 0x00B6, 0x81F7, 0x00D7, 0x817E, 0x00F7, 0x8180,\r\n\t0x0391, 0x839F, 0x0392, 0x83A0, 0x0393, 0x83A1, 0x0394, 0x83A2,\t0x0395, 0x83A3, 0x0396, 0x83A4, 0x0397, 0x83A5, 0x0398, 0x83A6,\r\n\t0x0399, 0x83A7, 0x039A, 0x83A8, 0x039B, 0x83A9, 0x039C, 0x83AA,\t0x039D, 0x83AB, 0x039E, 0x83AC, 0x039F, 0x83AD, 0x03A0, 0x83AE,\r\n\t0x03A1, 0x83AF, 0x03A3, 0x83B0, 0x03A4, 0x83B1, 0x03A5, 0x83B2,\t0x03A6, 0x83B3, 0x03A7, 0x83B4, 0x03A8, 0x83B5, 0x03A9, 0x83B6,\r\n\t0x03B1, 0x83BF, 0x03B2, 0x83C0, 0x03B3, 0x83C1, 0x03B4, 0x83C2,\t0x03B5, 0x83C3, 0x03B6, 0x83C4, 0x03B7, 0x83C5, 0x03B8, 0x83C6,\r\n\t0x03B9, 0x83C7, 0x03BA, 0x83C8, 0x03BB, 0x83C9, 0x03BC, 0x83CA,\t0x03BD, 0x83CB, 0x03BE, 0x83CC, 0x03BF, 0x83CD, 0x03C0, 0x83CE,\r\n\t0x03C1, 0x83CF, 0x03C3, 0x83D0, 0x03C4, 0x83D1, 0x03C5, 0x83D2,\t0x03C6, 0x83D3, 0x03C7, 0x83D4, 0x03C8, 0x83D5, 0x03C9, 0x83D6,\r\n\t0x0401, 0x8446, 0x0410, 0x8440, 0x0411, 0x8441, 0x0412, 0x8442,\t0x0413, 0x8443, 0x0414, 0x8444, 0x0415, 0x8445, 0x0416, 0x8447,\r\n\t0x0417, 0x8448, 0x0418, 0x8449, 0x0419, 0x844A, 0x041A, 0x844B,\t0x041B, 0x844C, 0x041C, 0x844D, 0x041D, 0x844E, 0x041E, 0x844F,\r\n\t0x041F, 0x8450, 0x0420, 0x8451, 0x0421, 0x8452, 0x0422, 0x8453,\t0x0423, 0x8454, 0x0424, 0x8455, 0x0425, 0x8456, 0x0426, 0x8457,\r\n\t0x0427, 0x8458, 0x0428, 0x8459, 0x0429, 0x845A, 0x042A, 0x845B,\t0x042B, 0x845C, 0x042C, 0x845D, 0x042D, 0x845E, 0x042E, 0x845F,\r\n\t0x042F, 0x8460, 0x0430, 0x8470, 0x0431, 0x8471, 0x0432, 0x8472,\t0x0433, 0x8473, 0x0434, 0x8474, 0x0435, 0x8475, 0x0436, 0x8477,\r\n\t0x0437, 0x8478, 0x0438, 0x8479, 0x0439, 0x847A, 0x043A, 0x847B,\t0x043B, 0x847C, 0x043C, 0x847D, 0x043D, 0x847E, 0x043E, 0x8480,\r\n\t0x043F, 0x8481, 0x0440, 0x8482, 0x0441, 0x8483, 0x0442, 0x8484,\t0x0443, 0x8485, 0x0444, 0x8486, 0x0445, 0x8487, 0x0446, 0x8488,\r\n\t0x0447, 0x8489, 0x0448, 0x848A, 0x0449, 0x848B, 0x044A, 0x848C,\t0x044B, 0x848D, 0x044C, 0x848E, 0x044D, 0x848F, 0x044E, 0x8490,\r\n\t0x044F, 0x8491, 0x0451, 0x8476, 0x2010, 0x815D, 0x2015, 0x815C,\t0x2018, 0x8165, 0x2019, 0x8166, 0x201C, 0x8167, 0x201D, 0x8168,\r\n\t0x2020, 0x81F5, 0x2021, 0x81F6, 0x2025, 0x8164, 0x2026, 0x8163,\t0x2030, 0x81F1, 0x2032, 0x818C, 0x2033, 0x818D, 0x203B, 0x81A6,\r\n\t0x2103, 0x818E, 0x2116, 0x8782, 0x2121, 0x8784, 0x212B, 0x81F0,\t0x2160, 0x8754, 0x2161, 0x8755, 0x2162, 0x8756, 0x2163, 0x8757,\r\n\t0x2164, 0x8758, 0x2165, 0x8759, 0x2166, 0x875A, 0x2167, 0x875B,\t0x2168, 0x875C, 0x2169, 0x875D, 0x2170, 0xFA40, 0x2171, 0xFA41,\r\n\t0x2172, 0xFA42, 0x2173, 0xFA43, 0x2174, 0xFA44, 0x2175, 0xFA45,\t0x2176, 0xFA46, 0x2177, 0xFA47, 0x2178, 0xFA48, 0x2179, 0xFA49,\r\n\t0x2190, 0x81A9, 0x2191, 0x81AA, 0x2192, 0x81A8, 0x2193, 0x81AB,\t0x21D2, 0x81CB, 0x21D4, 0x81CC, 0x2200, 0x81CD, 0x2202, 0x81DD,\r\n\t0x2203, 0x81CE, 0x2207, 0x81DE, 0x2208, 0x81B8, 0x220B, 0x81B9,\t0x2211, 0x8794, 0x221A, 0x81E3, 0x221D, 0x81E5, 0x221E, 0x8187,\r\n\t0x221F, 0x8798, 0x2220, 0x81DA, 0x2225, 0x8161, 0x2227, 0x81C8,\t0x2228, 0x81C9, 0x2229, 0x81BF, 0x222A, 0x81BE, 0x222B, 0x81E7,\r\n\t0x222C, 0x81E8, 0x222E, 0x8793, 0x2234, 0x8188, 0x2235, 0x81E6,\t0x223D, 0x81E4, 0x2252, 0x81E0, 0x2260, 0x8182, 0x2261, 0x81DF,\r\n\t0x2266, 0x8185, 0x2267, 0x8186, 0x226A, 0x81E1, 0x226B, 0x81E2,\t0x2282, 0x81BC, 0x2283, 0x81BD, 0x2286, 0x81BA, 0x2287, 0x81BB,\r\n\t0x22A5, 0x81DB, 0x22BF, 0x8799, 0x2312, 0x81DC, 0x2460, 0x8740,\t0x2461, 0x8741, 0x2462, 0x8742, 0x2463, 0x8743, 0x2464, 0x8744,\r\n\t0x2465, 0x8745, 0x2466, 0x8746, 0x2467, 0x8747, 0x2468, 0x8748,\t0x2469, 0x8749, 0x246A, 0x874A, 0x246B, 0x874B, 0x246C, 0x874C,\r\n\t0x246D, 0x874D, 0x246E, 0x874E, 0x246F, 0x874F, 0x2470, 0x8750,\t0x2471, 0x8751, 0x2472, 0x8752, 0x2473, 0x8753, 0x2500, 0x849F,\r\n\t0x2501, 0x84AA, 0x2502, 0x84A0, 0x2503, 0x84AB, 0x250C, 0x84A1,\t0x250F, 0x84AC, 0x2510, 0x84A2, 0x2513, 0x84AD, 0x2514, 0x84A4,\r\n\t0x2517, 0x84AF, 0x2518, 0x84A3, 0x251B, 0x84AE, 0x251C, 0x84A5,\t0x251D, 0x84BA, 0x2520, 0x84B5, 0x2523, 0x84B0, 0x2524, 0x84A7,\r\n\t0x2525, 0x84BC, 0x2528, 0x84B7, 0x252B, 0x84B2, 0x252C, 0x84A6,\t0x252F, 0x84B6, 0x2530, 0x84BB, 0x2533, 0x84B1, 0x2534, 0x84A8,\r\n\t0x2537, 0x84B8, 0x2538, 0x84BD, 0x253B, 0x84B3, 0x253C, 0x84A9,\t0x253F, 0x84B9, 0x2542, 0x84BE, 0x254B, 0x84B4, 0x25A0, 0x81A1,\r\n\t0x25A1, 0x81A0, 0x25B2, 0x81A3, 0x25B3, 0x81A2, 0x25BC, 0x81A5,\t0x25BD, 0x81A4, 0x25C6, 0x819F, 0x25C7, 0x819E, 0x25CB, 0x819B,\r\n\t0x25CE, 0x819D, 0x25CF, 0x819C, 0x25EF, 0x81FC, 0x2605, 0x819A,\t0x2606, 0x8199, 0x2640, 0x818A, 0x2642, 0x8189, 0x266A, 0x81F4,\r\n\t0x266D, 0x81F3, 0x266F, 0x81F2, 0x3000, 0x8140, 0x3001, 0x8141,\t0x3002, 0x8142, 0x3003, 0x8156, 0x3005, 0x8158, 0x3006, 0x8159,\r\n\t0x3007, 0x815A, 0x3008, 0x8171, 0x3009, 0x8172, 0x300A, 0x8173,\t0x300B, 0x8174, 0x300C, 0x8175, 0x300D, 0x8176, 0x300E, 0x8177,\r\n\t0x300F, 0x8178, 0x3010, 0x8179, 0x3011, 0x817A, 0x3012, 0x81A7,\t0x3013, 0x81AC, 0x3014, 0x816B, 0x3015, 0x816C, 0x301D, 0x8780,\r\n\t0x301F, 0x8781, 0x3041, 0x829F, 0x3042, 0x82A0, 0x3043, 0x82A1,\t0x3044, 0x82A2, 0x3045, 0x82A3, 0x3046, 0x82A4, 0x3047, 0x82A5,\r\n\t0x3048, 0x82A6, 0x3049, 0x82A7, 0x304A, 0x82A8, 0x304B, 0x82A9,\t0x304C, 0x82AA, 0x304D, 0x82AB, 0x304E, 0x82AC, 0x304F, 0x82AD,\r\n\t0x3050, 0x82AE, 0x3051, 0x82AF, 0x3052, 0x82B0, 0x3053, 0x82B1,\t0x3054, 0x82B2, 0x3055, 0x82B3, 0x3056, 0x82B4, 0x3057, 0x82B5,\r\n\t0x3058, 0x82B6, 0x3059, 0x82B7, 0x305A, 0x82B8, 0x305B, 0x82B9,\t0x305C, 0x82BA, 0x305D, 0x82BB, 0x305E, 0x82BC, 0x305F, 0x82BD,\r\n\t0x3060, 0x82BE, 0x3061, 0x82BF, 0x3062, 0x82C0, 0x3063, 0x82C1,\t0x3064, 0x82C2, 0x3065, 0x82C3, 0x3066, 0x82C4, 0x3067, 0x82C5,\r\n\t0x3068, 0x82C6, 0x3069, 0x82C7, 0x306A, 0x82C8, 0x306B, 0x82C9,\t0x306C, 0x82CA, 0x306D, 0x82CB, 0x306E, 0x82CC, 0x306F, 0x82CD,\r\n\t0x3070, 0x82CE, 0x3071, 0x82CF, 0x3072, 0x82D0, 0x3073, 0x82D1,\t0x3074, 0x82D2, 0x3075, 0x82D3, 0x3076, 0x82D4, 0x3077, 0x82D5,\r\n\t0x3078, 0x82D6, 0x3079, 0x82D7, 0x307A, 0x82D8, 0x307B, 0x82D9,\t0x307C, 0x82DA, 0x307D, 0x82DB, 0x307E, 0x82DC, 0x307F, 0x82DD,\r\n\t0x3080, 0x82DE, 0x3081, 0x82DF, 0x3082, 0x82E0, 0x3083, 0x82E1,\t0x3084, 0x82E2, 0x3085, 0x82E3, 0x3086, 0x82E4, 0x3087, 0x82E5,\r\n\t0x3088, 0x82E6, 0x3089, 0x82E7, 0x308A, 0x82E8, 0x308B, 0x82E9,\t0x308C, 0x82EA, 0x308D, 0x82EB, 0x308E, 0x82EC, 0x308F, 0x82ED,\r\n\t0x3090, 0x82EE, 0x3091, 0x82EF, 0x3092, 0x82F0, 0x3093, 0x82F1,\t0x309B, 0x814A, 0x309C, 0x814B, 0x309D, 0x8154, 0x309E, 0x8155,\r\n\t0x30A1, 0x8340, 0x30A2, 0x8341, 0x30A3, 0x8342, 0x30A4, 0x8343,\t0x30A5, 0x8344, 0x30A6, 0x8345, 0x30A7, 0x8346, 0x30A8, 0x8347,\r\n\t0x30A9, 0x8348, 0x30AA, 0x8349, 0x30AB, 0x834A, 0x30AC, 0x834B,\t0x30AD, 0x834C, 0x30AE, 0x834D, 0x30AF, 0x834E, 0x30B0, 0x834F,\r\n\t0x30B1, 0x8350, 0x30B2, 0x8351, 0x30B3, 0x8352, 0x30B4, 0x8353,\t0x30B5, 0x8354, 0x30B6, 0x8355, 0x30B7, 0x8356, 0x30B8, 0x8357,\r\n\t0x30B9, 0x8358, 0x30BA, 0x8359, 0x30BB, 0x835A, 0x30BC, 0x835B,\t0x30BD, 0x835C, 0x30BE, 0x835D, 0x30BF, 0x835E, 0x30C0, 0x835F,\r\n\t0x30C1, 0x8360, 0x30C2, 0x8361, 0x30C3, 0x8362, 0x30C4, 0x8363,\t0x30C5, 0x8364, 0x30C6, 0x8365, 0x30C7, 0x8366, 0x30C8, 0x8367,\r\n\t0x30C9, 0x8368, 0x30CA, 0x8369, 0x30CB, 0x836A, 0x30CC, 0x836B,\t0x30CD, 0x836C, 0x30CE, 0x836D, 0x30CF, 0x836E, 0x30D0, 0x836F,\r\n\t0x30D1, 0x8370, 0x30D2, 0x8371, 0x30D3, 0x8372, 0x30D4, 0x8373,\t0x30D5, 0x8374, 0x30D6, 0x8375, 0x30D7, 0x8376, 0x30D8, 0x8377,\r\n\t0x30D9, 0x8378, 0x30DA, 0x8379, 0x30DB, 0x837A, 0x30DC, 0x837B,\t0x30DD, 0x837C, 0x30DE, 0x837D, 0x30DF, 0x837E, 0x30E0, 0x8380,\r\n\t0x30E1, 0x8381, 0x30E2, 0x8382, 0x30E3, 0x8383, 0x30E4, 0x8384,\t0x30E5, 0x8385, 0x30E6, 0x8386, 0x30E7, 0x8387, 0x30E8, 0x8388,\r\n\t0x30E9, 0x8389, 0x30EA, 0x838A, 0x30EB, 0x838B, 0x30EC, 0x838C,\t0x30ED, 0x838D, 0x30EE, 0x838E, 0x30EF, 0x838F, 0x30F0, 0x8390,\r\n\t0x30F1, 0x8391, 0x30F2, 0x8392, 0x30F3, 0x8393, 0x30F4, 0x8394,\t0x30F5, 0x8395, 0x30F6, 0x8396, 0x30FB, 0x8145, 0x30FC, 0x815B,\r\n\t0x30FD, 0x8152, 0x30FE, 0x8153, 0x3231, 0x878A, 0x3232, 0x878B,\t0x3239, 0x878C, 0x32A4, 0x8785, 0x32A5, 0x8786, 0x32A6, 0x8787,\r\n\t0x32A7, 0x8788, 0x32A8, 0x8789, 0x3303, 0x8765, 0x330D, 0x8769,\t0x3314, 0x8760, 0x3318, 0x8763, 0x3322, 0x8761, 0x3323, 0x876B,\r\n\t0x3326, 0x876A, 0x3327, 0x8764, 0x332B, 0x876C, 0x3336, 0x8766,\t0x333B, 0x876E, 0x3349, 0x875F, 0x334A, 0x876D, 0x334D, 0x8762,\r\n\t0x3351, 0x8767, 0x3357, 0x8768, 0x337B, 0x877E, 0x337C, 0x878F,\t0x337D, 0x878E, 0x337E, 0x878D, 0x338E, 0x8772, 0x338F, 0x8773,\r\n\t0x339C, 0x876F, 0x339D, 0x8770, 0x339E, 0x8771, 0x33A1, 0x8775,\t0x33C4, 0x8774, 0x33CD, 0x8783, 0x4E00, 0x88EA, 0x4E01, 0x929A,\r\n\t0x4E03, 0x8EB5, 0x4E07, 0x969C, 0x4E08, 0x8FE4, 0x4E09, 0x8E4F,\t0x4E0A, 0x8FE3, 0x4E0B, 0x89BA, 0x4E0D, 0x9573, 0x4E0E, 0x975E,\r\n\t0x4E10, 0x98A0, 0x4E11, 0x894E, 0x4E14, 0x8A8E, 0x4E15, 0x98A1,\t0x4E16, 0x90A2, 0x4E17, 0x99C0, 0x4E18, 0x8B75, 0x4E19, 0x95B8,\r\n\t0x4E1E, 0x8FE5, 0x4E21, 0x97BC, 0x4E26, 0x95C0, 0x4E28, 0xFA68,\t0x4E2A, 0x98A2, 0x4E2D, 0x9286, 0x4E31, 0x98A3, 0x4E32, 0x8BF8,\r\n\t0x4E36, 0x98A4, 0x4E38, 0x8ADB, 0x4E39, 0x924F, 0x4E3B, 0x8EE5,\t0x4E3C, 0x98A5, 0x4E3F, 0x98A6, 0x4E42, 0x98A7, 0x4E43, 0x9454,\r\n\t0x4E45, 0x8B76, 0x4E4B, 0x9456, 0x4E4D, 0x93E1, 0x4E4E, 0x8CC1,\t0x4E4F, 0x9652, 0x4E55, 0xE568, 0x4E56, 0x98A8, 0x4E57, 0x8FE6,\r\n\t0x4E58, 0x98A9, 0x4E59, 0x89B3, 0x4E5D, 0x8BE3, 0x4E5E, 0x8CEE,\t0x4E5F, 0x96E7, 0x4E62, 0x9BA4, 0x4E71, 0x9790, 0x4E73, 0x93FB,\r\n\t0x4E7E, 0x8AA3, 0x4E80, 0x8B54, 0x4E82, 0x98AA, 0x4E85, 0x98AB,\t0x4E86, 0x97B9, 0x4E88, 0x975C, 0x4E89, 0x9188, 0x4E8A, 0x98AD,\r\n\t0x4E8B, 0x8E96, 0x4E8C, 0x93F1, 0x4E8E, 0x98B0, 0x4E91, 0x895D,\t0x4E92, 0x8CDD, 0x4E94, 0x8CDC, 0x4E95, 0x88E4, 0x4E98, 0x986A,\r\n\t0x4E99, 0x9869, 0x4E9B, 0x8DB1, 0x4E9C, 0x889F, 0x4E9E, 0x98B1,\t0x4E9F, 0x98B2, 0x4EA0, 0x98B3, 0x4EA1, 0x9653, 0x4EA2, 0x98B4,\r\n\t0x4EA4, 0x8CF0, 0x4EA5, 0x88E5, 0x4EA6, 0x9692, 0x4EA8, 0x8B9C,\t0x4EAB, 0x8B9D, 0x4EAC, 0x8B9E, 0x4EAD, 0x92E0, 0x4EAE, 0x97BA,\r\n\t0x4EB0, 0x98B5, 0x4EB3, 0x98B6, 0x4EB6, 0x98B7, 0x4EBA, 0x906C,\t0x4EC0, 0x8F59, 0x4EC1, 0x906D, 0x4EC2, 0x98BC, 0x4EC4, 0x98BA,\r\n\t0x4EC6, 0x98BB, 0x4EC7, 0x8B77, 0x4ECA, 0x8DA1, 0x4ECB, 0x89EE,\t0x4ECD, 0x98B9, 0x4ECE, 0x98B8, 0x4ECF, 0x95A7, 0x4ED4, 0x8E65,\r\n\t0x4ED5, 0x8E64, 0x4ED6, 0x91BC, 0x4ED7, 0x98BD, 0x4ED8, 0x9574,\t0x4ED9, 0x90E5, 0x4EDD, 0x8157, 0x4EDE, 0x98BE, 0x4EDF, 0x98C0,\r\n\t0x4EE1, 0xFA69, 0x4EE3, 0x91E3, 0x4EE4, 0x97DF, 0x4EE5, 0x88C8,\t0x4EED, 0x98BF, 0x4EEE, 0x89BC, 0x4EF0, 0x8BC2, 0x4EF2, 0x9287,\r\n\t0x4EF6, 0x8C8F, 0x4EF7, 0x98C1, 0x4EFB, 0x9443, 0x4EFC, 0xFA6A,\t0x4F00, 0xFA6B, 0x4F01, 0x8AE9, 0x4F03, 0xFA6C, 0x4F09, 0x98C2,\r\n\t0x4F0A, 0x88C9, 0x4F0D, 0x8CDE, 0x4F0E, 0x8AEA, 0x4F0F, 0x959A,\t0x4F10, 0x94B0, 0x4F11, 0x8B78, 0x4F1A, 0x89EF, 0x4F1C, 0x98E5,\r\n\t0x4F1D, 0x9360, 0x4F2F, 0x948C, 0x4F30, 0x98C4, 0x4F34, 0x94BA,\t0x4F36, 0x97E0, 0x4F38, 0x904C, 0x4F39, 0xFA6D, 0x4F3A, 0x8E66,\r\n\t0x4F3C, 0x8E97, 0x4F3D, 0x89BE, 0x4F43, 0x92CF, 0x4F46, 0x9241,\t0x4F47, 0x98C8, 0x4F4D, 0x88CA, 0x4F4E, 0x92E1, 0x4F4F, 0x8F5A,\r\n\t0x4F50, 0x8DB2, 0x4F51, 0x9743, 0x4F53, 0x91CC, 0x4F55, 0x89BD,\t0x4F56, 0xFA6E, 0x4F57, 0x98C7, 0x4F59, 0x975D, 0x4F5A, 0x98C3,\r\n\t0x4F5B, 0x98C5, 0x4F5C, 0x8DEC, 0x4F5D, 0x98C6, 0x4F5E, 0x9B43,\t0x4F69, 0x98CE, 0x4F6F, 0x98D1, 0x4F70, 0x98CF, 0x4F73, 0x89C0,\r\n\t0x4F75, 0x95B9, 0x4F76, 0x98C9, 0x4F7B, 0x98CD, 0x4F7C, 0x8CF1,\t0x4F7F, 0x8E67, 0x4F83, 0x8AA4, 0x4F86, 0x98D2, 0x4F88, 0x98CA,\r\n\t0x4F8A, 0xFA70, 0x4F8B, 0x97E1, 0x4F8D, 0x8E98, 0x4F8F, 0x98CB,\t0x4F91, 0x98D0, 0x4F92, 0xFA6F, 0x4F94, 0xFA72, 0x4F96, 0x98D3,\r\n\t0x4F98, 0x98CC, 0x4F9A, 0xFA71, 0x4F9B, 0x8B9F, 0x4F9D, 0x88CB,\t0x4FA0, 0x8BA0, 0x4FA1, 0x89BF, 0x4FAB, 0x9B44, 0x4FAD, 0x9699,\r\n\t0x4FAE, 0x958E, 0x4FAF, 0x8CF2, 0x4FB5, 0x904E, 0x4FB6, 0x97B5,\t0x4FBF, 0x95D6, 0x4FC2, 0x8C57, 0x4FC3, 0x91A3, 0x4FC4, 0x89E2,\r\n\t0x4FC9, 0xFA61, 0x4FCA, 0x8F72, 0x4FCD, 0xFA73, 0x4FCE, 0x98D7,\t0x4FD0, 0x98DC, 0x4FD1, 0x98DA, 0x4FD4, 0x98D5, 0x4FD7, 0x91AD,\r\n\t0x4FD8, 0x98D8, 0x4FDA, 0x98DB, 0x4FDB, 0x98D9, 0x4FDD, 0x95DB,\t0x4FDF, 0x98D6, 0x4FE1, 0x904D, 0x4FE3, 0x9693, 0x4FE4, 0x98DD,\r\n\t0x4FE5, 0x98DE, 0x4FEE, 0x8F43, 0x4FEF, 0x98EB, 0x4FF3, 0x946F,\t0x4FF5, 0x9555, 0x4FF6, 0x98E6, 0x4FF8, 0x95EE, 0x4FFA, 0x89B4,\r\n\t0x4FFE, 0x98EA, 0x4FFF, 0xFA76, 0x5005, 0x98E4, 0x5006, 0x98ED,\t0x5009, 0x9171, 0x500B, 0x8CC2, 0x500D, 0x947B, 0x500F, 0xE0C5,\r\n\t0x5011, 0x98EC, 0x5012, 0x937C, 0x5014, 0x98E1, 0x5016, 0x8CF4,\t0x5019, 0x8CF3, 0x501A, 0x98DF, 0x501E, 0xFA77, 0x501F, 0x8ED8,\r\n\t0x5021, 0x98E7, 0x5022, 0xFA75, 0x5023, 0x95ED, 0x5024, 0x926C,\t0x5025, 0x98E3, 0x5026, 0x8C91, 0x5028, 0x98E0, 0x5029, 0x98E8,\r\n\t0x502A, 0x98E2, 0x502B, 0x97CF, 0x502C, 0x98E9, 0x502D, 0x9860,\t0x5036, 0x8BE4, 0x5039, 0x8C90, 0x5040, 0xFA74, 0x5042, 0xFA7A,\r\n\t0x5043, 0x98EE, 0x5046, 0xFA78, 0x5047, 0x98EF, 0x5048, 0x98F3,\t0x5049, 0x88CC, 0x504F, 0x95CE, 0x5050, 0x98F2, 0x5055, 0x98F1,\r\n\t0x5056, 0x98F5, 0x505A, 0x98F4, 0x505C, 0x92E2, 0x5065, 0x8C92,\t0x506C, 0x98F6, 0x5070, 0xFA79, 0x5072, 0x8EC3, 0x5074, 0x91A4,\r\n\t0x5075, 0x92E3, 0x5076, 0x8BF4, 0x5078, 0x98F7, 0x507D, 0x8B55,\t0x5080, 0x98F8, 0x5085, 0x98FA, 0x508D, 0x9654, 0x5091, 0x8C86,\r\n\t0x5094, 0xFA7B, 0x5098, 0x8E50, 0x5099, 0x94F5, 0x509A, 0x98F9,\t0x50AC, 0x8DC3, 0x50AD, 0x9762, 0x50B2, 0x98FC, 0x50B3, 0x9942,\r\n\t0x50B4, 0x98FB, 0x50B5, 0x8DC2, 0x50B7, 0x8F9D, 0x50BE, 0x8C58,\t0x50C2, 0x9943, 0x50C5, 0x8BCD, 0x50C9, 0x9940, 0x50CA, 0x9941,\r\n\t0x50CD, 0x93AD, 0x50CF, 0x919C, 0x50D1, 0x8BA1, 0x50D5, 0x966C,\t0x50D6, 0x9944, 0x50D8, 0xFA7D, 0x50DA, 0x97BB, 0x50DE, 0x9945,\r\n\t0x50E3, 0x9948, 0x50E5, 0x9946, 0x50E7, 0x916D, 0x50ED, 0x9947,\t0x50EE, 0x9949, 0x50F4, 0xFA7C, 0x50F5, 0x994B, 0x50F9, 0x994A,\r\n\t0x50FB, 0x95C6, 0x5100, 0x8B56, 0x5101, 0x994D, 0x5102, 0x994E,\t0x5104, 0x89AD, 0x5109, 0x994C, 0x5112, 0x8EF2, 0x5114, 0x9951,\r\n\t0x5115, 0x9950, 0x5116, 0x994F, 0x5118, 0x98D4, 0x511A, 0x9952,\t0x511F, 0x8F9E, 0x5121, 0x9953, 0x512A, 0x9744, 0x5132, 0x96D7,\r\n\t0x5137, 0x9955, 0x513A, 0x9954, 0x513B, 0x9957, 0x513C, 0x9956,\t0x513F, 0x9958, 0x5140, 0x9959, 0x5141, 0x88F2, 0x5143, 0x8CB3,\r\n\t0x5144, 0x8C5A, 0x5145, 0x8F5B, 0x5146, 0x929B, 0x5147, 0x8BA2,\t0x5148, 0x90E6, 0x5149, 0x8CF5, 0x514A, 0xFA7E, 0x514B, 0x8D8E,\r\n\t0x514C, 0x995B, 0x514D, 0x96C6, 0x514E, 0x9365, 0x5150, 0x8E99,\t0x5152, 0x995A, 0x5154, 0x995C, 0x515A, 0x937D, 0x515C, 0x8A95,\r\n\t0x5162, 0x995D, 0x5164, 0xFA80, 0x5165, 0x93FC, 0x5168, 0x9153,\t0x5169, 0x995F, 0x516A, 0x9960, 0x516B, 0x94AA, 0x516C, 0x8CF6,\r\n\t0x516D, 0x985A, 0x516E, 0x9961, 0x5171, 0x8BA4, 0x5175, 0x95BA,\t0x5176, 0x91B4, 0x5177, 0x8BEF, 0x5178, 0x9354, 0x517C, 0x8C93,\r\n\t0x5180, 0x9962, 0x5182, 0x9963, 0x5185, 0x93E0, 0x5186, 0x897E,\t0x5189, 0x9966, 0x518A, 0x8DFB, 0x518C, 0x9965, 0x518D, 0x8DC4,\r\n\t0x518F, 0x9967, 0x5190, 0xE3EC, 0x5191, 0x9968, 0x5192, 0x9660,\t0x5193, 0x9969, 0x5195, 0x996A, 0x5196, 0x996B, 0x5197, 0x8FE7,\r\n\t0x5199, 0x8ECA, 0x519D, 0xFA81, 0x51A0, 0x8AA5, 0x51A2, 0x996E,\t0x51A4, 0x996C, 0x51A5, 0x96BB, 0x51A6, 0x996D, 0x51A8, 0x9579,\r\n\t0x51A9, 0x996F, 0x51AA, 0x9970, 0x51AB, 0x9971, 0x51AC, 0x937E,\t0x51B0, 0x9975, 0x51B1, 0x9973, 0x51B2, 0x9974, 0x51B3, 0x9972,\r\n\t0x51B4, 0x8DE1, 0x51B5, 0x9976, 0x51B6, 0x96E8, 0x51B7, 0x97E2,\t0x51BD, 0x9977, 0x51BE, 0xFA82, 0x51C4, 0x90A6, 0x51C5, 0x9978,\r\n\t0x51C6, 0x8F79, 0x51C9, 0x9979, 0x51CB, 0x929C, 0x51CC, 0x97BD,\t0x51CD, 0x9380, 0x51D6, 0x99C3, 0x51DB, 0x997A, 0x51DC, 0xEAA3,\r\n\t0x51DD, 0x8BC3, 0x51E0, 0x997B, 0x51E1, 0x967D, 0x51E6, 0x8F88,\t0x51E7, 0x91FA, 0x51E9, 0x997D, 0x51EA, 0x93E2, 0x51EC, 0xFA83,\r\n\t0x51ED, 0x997E, 0x51F0, 0x9980, 0x51F1, 0x8A4D, 0x51F5, 0x9981,\t0x51F6, 0x8BA5, 0x51F8, 0x93CA, 0x51F9, 0x899A, 0x51FA, 0x8F6F,\r\n\t0x51FD, 0x949F, 0x51FE, 0x9982, 0x5200, 0x9381, 0x5203, 0x906E,\t0x5204, 0x9983, 0x5206, 0x95AA, 0x5207, 0x90D8, 0x5208, 0x8AA0,\r\n\t0x520A, 0x8AA7, 0x520B, 0x9984, 0x520E, 0x9986, 0x5211, 0x8C59,\t0x5214, 0x9985, 0x5215, 0xFA84, 0x5217, 0x97F1, 0x521D, 0x8F89,\r\n\t0x5224, 0x94BB, 0x5225, 0x95CA, 0x5227, 0x9987, 0x5229, 0x9798,\t0x522A, 0x9988, 0x522E, 0x9989, 0x5230, 0x939E, 0x5233, 0x998A,\r\n\t0x5236, 0x90A7, 0x5237, 0x8DFC, 0x5238, 0x8C94, 0x5239, 0x998B,\t0x523A, 0x8E68, 0x523B, 0x8D8F, 0x5243, 0x92E4, 0x5244, 0x998D,\r\n\t0x5247, 0x91A5, 0x524A, 0x8DED, 0x524B, 0x998E, 0x524C, 0x998F,\t0x524D, 0x914F, 0x524F, 0x998C, 0x5254, 0x9991, 0x5256, 0x9655,\r\n\t0x525B, 0x8D84, 0x525E, 0x9990, 0x5263, 0x8C95, 0x5264, 0x8DDC,\t0x5265, 0x948D, 0x5269, 0x9994, 0x526A, 0x9992, 0x526F, 0x959B,\r\n\t0x5270, 0x8FE8, 0x5271, 0x999B, 0x5272, 0x8A84, 0x5273, 0x9995,\t0x5274, 0x9993, 0x5275, 0x916E, 0x527D, 0x9997, 0x527F, 0x9996,\r\n\t0x5283, 0x8A63, 0x5287, 0x8C80, 0x5288, 0x999C, 0x5289, 0x97AB,\t0x528D, 0x9998, 0x5291, 0x999D, 0x5292, 0x999A, 0x5294, 0x9999,\r\n\t0x529B, 0x97CD, 0x529C, 0xFA85, 0x529F, 0x8CF7, 0x52A0, 0x89C1,\t0x52A3, 0x97F2, 0x52A6, 0xFA86, 0x52A9, 0x8F95, 0x52AA, 0x9377,\r\n\t0x52AB, 0x8D85, 0x52AC, 0x99A0, 0x52AD, 0x99A1, 0x52AF, 0xFB77,\t0x52B1, 0x97E3, 0x52B4, 0x984A, 0x52B5, 0x99A3, 0x52B9, 0x8CF8,\r\n\t0x52BC, 0x99A2, 0x52BE, 0x8A4E, 0x52C0, 0xFA87, 0x52C1, 0x99A4,\t0x52C3, 0x9675, 0x52C5, 0x92BA, 0x52C7, 0x9745, 0x52C9, 0x95D7,\r\n\t0x52CD, 0x99A5, 0x52D2, 0xE8D3, 0x52D5, 0x93AE, 0x52D7, 0x99A6,\t0x52D8, 0x8AA8, 0x52D9, 0x96B1, 0x52DB, 0xFA88, 0x52DD, 0x8F9F,\r\n\t0x52DE, 0x99A7, 0x52DF, 0x95E5, 0x52E0, 0x99AB, 0x52E2, 0x90A8,\t0x52E3, 0x99A8, 0x52E4, 0x8BCE, 0x52E6, 0x99A9, 0x52E7, 0x8AA9,\r\n\t0x52F2, 0x8C4D, 0x52F3, 0x99AC, 0x52F5, 0x99AD, 0x52F8, 0x99AE,\t0x52F9, 0x99AF, 0x52FA, 0x8ED9, 0x52FE, 0x8CF9, 0x52FF, 0x96DC,\r\n\t0x5300, 0xFA89, 0x5301, 0x96E6, 0x5302, 0x93F5, 0x5305, 0x95EF,\t0x5306, 0x99B0, 0x5307, 0xFA8A, 0x5308, 0x99B1, 0x530D, 0x99B3,\r\n\t0x530F, 0x99B5, 0x5310, 0x99B4, 0x5315, 0x99B6, 0x5316, 0x89BB,\t0x5317, 0x966B, 0x5319, 0x8DFA, 0x531A, 0x99B7, 0x531D, 0x9178,\r\n\t0x5320, 0x8FA0, 0x5321, 0x8BA7, 0x5323, 0x99B8, 0x5324, 0xFA8B,\t0x532A, 0x94D9, 0x532F, 0x99B9, 0x5331, 0x99BA, 0x5333, 0x99BB,\r\n\t0x5338, 0x99BC, 0x5339, 0x9543, 0x533A, 0x8BE6, 0x533B, 0x88E3,\t0x533F, 0x93BD, 0x5340, 0x99BD, 0x5341, 0x8F5C, 0x5343, 0x90E7,\r\n\t0x5345, 0x99BF, 0x5346, 0x99BE, 0x5347, 0x8FA1, 0x5348, 0x8CDF,\t0x5349, 0x99C1, 0x534A, 0x94BC, 0x534D, 0x99C2, 0x5351, 0x94DA,\r\n\t0x5352, 0x91B2, 0x5353, 0x91EC, 0x5354, 0x8BA6, 0x5357, 0x93EC,\t0x5358, 0x9250, 0x535A, 0x948E, 0x535C, 0x966D, 0x535E, 0x99C4,\r\n\t0x5360, 0x90E8, 0x5366, 0x8C54, 0x5369, 0x99C5, 0x536E, 0x99C6,\t0x536F, 0x894B, 0x5370, 0x88F3, 0x5371, 0x8AEB, 0x5372, 0xFA8C,\r\n\t0x5373, 0x91A6, 0x5374, 0x8B70, 0x5375, 0x9791, 0x5377, 0x99C9,\t0x5378, 0x89B5, 0x537B, 0x99C8, 0x537F, 0x8BA8, 0x5382, 0x99CA,\r\n\t0x5384, 0x96EF, 0x5393, 0xFA8D, 0x5396, 0x99CB, 0x5398, 0x97D0,\t0x539A, 0x8CFA, 0x539F, 0x8CB4, 0x53A0, 0x99CC, 0x53A5, 0x99CE,\r\n\t0x53A6, 0x99CD, 0x53A8, 0x907E, 0x53A9, 0x8958, 0x53AD, 0x897D,\t0x53AE, 0x99CF, 0x53B0, 0x99D0, 0x53B2, 0xFA8E, 0x53B3, 0x8CB5,\r\n\t0x53B6, 0x99D1, 0x53BB, 0x8B8E, 0x53C2, 0x8E51, 0x53C3, 0x99D2,\t0x53C8, 0x9694, 0x53C9, 0x8DB3, 0x53CA, 0x8B79, 0x53CB, 0x9746,\r\n\t0x53CC, 0x916F, 0x53CD, 0x94BD, 0x53CE, 0x8EFB, 0x53D4, 0x8F66,\t0x53D6, 0x8EE6, 0x53D7, 0x8EF3, 0x53D9, 0x8F96, 0x53DB, 0x94BE,\r\n\t0x53DD, 0xFA8F, 0x53DF, 0x99D5, 0x53E1, 0x8962, 0x53E2, 0x9170,\t0x53E3, 0x8CFB, 0x53E4, 0x8CC3, 0x53E5, 0x8BE5, 0x53E8, 0x99D9,\r\n\t0x53E9, 0x9240, 0x53EA, 0x91FC, 0x53EB, 0x8BA9, 0x53EC, 0x8FA2,\t0x53ED, 0x99DA, 0x53EE, 0x99D8, 0x53EF, 0x89C2, 0x53F0, 0x91E4,\r\n\t0x53F1, 0x8EB6, 0x53F2, 0x8E6A, 0x53F3, 0x8945, 0x53F6, 0x8A90,\t0x53F7, 0x8D86, 0x53F8, 0x8E69, 0x53FA, 0x99DB, 0x5401, 0x99DC,\r\n\t0x5403, 0x8B68, 0x5404, 0x8A65, 0x5408, 0x8D87, 0x5409, 0x8B67,\t0x540A, 0x92DD, 0x540B, 0x8944, 0x540C, 0x93AF, 0x540D, 0x96BC,\r\n\t0x540E, 0x8D40, 0x540F, 0x9799, 0x5410, 0x9366, 0x5411, 0x8CFC,\t0x541B, 0x8C4E, 0x541D, 0x99E5, 0x541F, 0x8BE1, 0x5420, 0x9669,\r\n\t0x5426, 0x94DB, 0x5429, 0x99E4, 0x542B, 0x8ADC, 0x542C, 0x99DF,\t0x542D, 0x99E0, 0x542E, 0x99E2, 0x5436, 0x99E3, 0x5438, 0x8B7A,\r\n\t0x5439, 0x9081, 0x543B, 0x95AB, 0x543C, 0x99E1, 0x543D, 0x99DD,\t0x543E, 0x8CE1, 0x5440, 0x99DE, 0x5442, 0x9843, 0x5446, 0x95F0,\r\n\t0x5448, 0x92E6, 0x5449, 0x8CE0, 0x544A, 0x8D90, 0x544E, 0x99E6,\t0x5451, 0x93DB, 0x545F, 0x99EA, 0x5468, 0x8EFC, 0x546A, 0x8EF4,\r\n\t0x5470, 0x99ED, 0x5471, 0x99EB, 0x5473, 0x96A1, 0x5475, 0x99E8,\t0x5476, 0x99F1, 0x5477, 0x99EC, 0x547B, 0x99EF, 0x547C, 0x8CC4,\r\n\t0x547D, 0x96BD, 0x5480, 0x99F0, 0x5484, 0x99F2, 0x5486, 0x99F4,\t0x548A, 0xFA92, 0x548B, 0x8DEE, 0x548C, 0x9861, 0x548E, 0x99E9,\r\n\t0x548F, 0x99E7, 0x5490, 0x99F3, 0x5492, 0x99EE, 0x549C, 0xFA91,\t0x54A2, 0x99F6, 0x54A4, 0x9A42, 0x54A5, 0x99F8, 0x54A8, 0x99FC,\r\n\t0x54A9, 0xFA93, 0x54AB, 0x9A40, 0x54AC, 0x99F9, 0x54AF, 0x9A5D,\t0x54B2, 0x8DE7, 0x54B3, 0x8A50, 0x54B8, 0x99F7, 0x54BC, 0x9A44,\r\n\t0x54BD, 0x88F4, 0x54BE, 0x9A43, 0x54C0, 0x88A3, 0x54C1, 0x9569,\t0x54C2, 0x9A41, 0x54C4, 0x99FA, 0x54C7, 0x99F5, 0x54C8, 0x99FB,\r\n\t0x54C9, 0x8DC6, 0x54D8, 0x9A45, 0x54E1, 0x88F5, 0x54E2, 0x9A4E,\t0x54E5, 0x9A46, 0x54E6, 0x9A47, 0x54E8, 0x8FA3, 0x54E9, 0x9689,\r\n\t0x54ED, 0x9A4C, 0x54EE, 0x9A4B, 0x54F2, 0x934E, 0x54FA, 0x9A4D,\t0x54FD, 0x9A4A, 0x54FF, 0xFA94, 0x5504, 0x8953, 0x5506, 0x8DB4,\r\n\t0x5507, 0x904F, 0x550F, 0x9A48, 0x5510, 0x9382, 0x5514, 0x9A49,\t0x5516, 0x88A0, 0x552E, 0x9A53, 0x552F, 0x9742, 0x5531, 0x8FA5,\r\n\t0x5533, 0x9A59, 0x5538, 0x9A58, 0x5539, 0x9A4F, 0x553E, 0x91C1,\t0x5540, 0x9A50, 0x5544, 0x91ED, 0x5545, 0x9A55, 0x5546, 0x8FA4,\r\n\t0x554C, 0x9A52, 0x554F, 0x96E2, 0x5553, 0x8C5B, 0x5556, 0x9A56,\t0x5557, 0x9A57, 0x555C, 0x9A54, 0x555D, 0x9A5A, 0x5563, 0x9A51,\r\n\t0x557B, 0x9A60, 0x557C, 0x9A65, 0x557E, 0x9A61, 0x5580, 0x9A5C,\t0x5583, 0x9A66, 0x5584, 0x9150, 0x5586, 0xFA95, 0x5587, 0x9A68,\r\n\t0x5589, 0x8D41, 0x558A, 0x9A5E, 0x558B, 0x929D, 0x5598, 0x9A62,\t0x5599, 0x9A5B, 0x559A, 0x8AAB, 0x559C, 0x8AEC, 0x559D, 0x8A85,\r\n\t0x559E, 0x9A63, 0x559F, 0x9A5F, 0x55A7, 0x8C96, 0x55A8, 0x9A69,\t0x55A9, 0x9A67, 0x55AA, 0x9172, 0x55AB, 0x8B69, 0x55AC, 0x8BAA,\r\n\t0x55AE, 0x9A64, 0x55B0, 0x8BF2, 0x55B6, 0x8963, 0x55C4, 0x9A6D,\t0x55C5, 0x9A6B, 0x55C7, 0x9AA5, 0x55D4, 0x9A70, 0x55DA, 0x9A6A,\r\n\t0x55DC, 0x9A6E, 0x55DF, 0x9A6C, 0x55E3, 0x8E6B, 0x55E4, 0x9A6F,\t0x55F7, 0x9A72, 0x55F9, 0x9A77, 0x55FD, 0x9A75, 0x55FE, 0x9A74,\r\n\t0x5606, 0x9251, 0x5609, 0x89C3, 0x5614, 0x9A71, 0x5616, 0x9A73,\t0x5617, 0x8FA6, 0x5618, 0x8952, 0x561B, 0x9A76, 0x5629, 0x89DC,\r\n\t0x562F, 0x9A82, 0x5631, 0x8FFA, 0x5632, 0x9A7D, 0x5634, 0x9A7B,\t0x5636, 0x9A7C, 0x5638, 0x9A7E, 0x5642, 0x895C, 0x564C, 0x9158,\r\n\t0x564E, 0x9A78, 0x5650, 0x9A79, 0x565B, 0x8A9A, 0x5664, 0x9A81,\t0x5668, 0x8AED, 0x566A, 0x9A84, 0x566B, 0x9A80, 0x566C, 0x9A83,\r\n\t0x5674, 0x95AC, 0x5678, 0x93D3, 0x567A, 0x94B6, 0x5680, 0x9A86,\t0x5686, 0x9A85, 0x5687, 0x8A64, 0x568A, 0x9A87, 0x568F, 0x9A8A,\r\n\t0x5694, 0x9A89, 0x56A0, 0x9A88, 0x56A2, 0x9458, 0x56A5, 0x9A8B,\t0x56AE, 0x9A8C, 0x56B4, 0x9A8E, 0x56B6, 0x9A8D, 0x56BC, 0x9A90,\r\n\t0x56C0, 0x9A93, 0x56C1, 0x9A91, 0x56C2, 0x9A8F, 0x56C3, 0x9A92,\t0x56C8, 0x9A94, 0x56CE, 0x9A95, 0x56D1, 0x9A96, 0x56D3, 0x9A97,\r\n\t0x56D7, 0x9A98, 0x56D8, 0x9964, 0x56DA, 0x8EFA, 0x56DB, 0x8E6C,\t0x56DE, 0x89F1, 0x56E0, 0x88F6, 0x56E3, 0x9263, 0x56EE, 0x9A99,\r\n\t0x56F0, 0x8DA2, 0x56F2, 0x88CD, 0x56F3, 0x907D, 0x56F9, 0x9A9A,\t0x56FA, 0x8CC5, 0x56FD, 0x8D91, 0x56FF, 0x9A9C, 0x5700, 0x9A9B,\r\n\t0x5703, 0x95DE, 0x5704, 0x9A9D, 0x5708, 0x9A9F, 0x5709, 0x9A9E,\t0x570B, 0x9AA0, 0x570D, 0x9AA1, 0x570F, 0x8C97, 0x5712, 0x8980,\r\n\t0x5713, 0x9AA2, 0x5716, 0x9AA4, 0x5718, 0x9AA3, 0x571C, 0x9AA6,\t0x571F, 0x9379, 0x5726, 0x9AA7, 0x5727, 0x88B3, 0x5728, 0x8DDD,\r\n\t0x572D, 0x8C5C, 0x5730, 0x926E, 0x5737, 0x9AA8, 0x5738, 0x9AA9,\t0x573B, 0x9AAB, 0x5740, 0x9AAC, 0x5742, 0x8DE2, 0x5747, 0x8BCF,\r\n\t0x574A, 0x9656, 0x574E, 0x9AAA, 0x574F, 0x9AAD, 0x5750, 0x8DBF,\t0x5751, 0x8D42, 0x5759, 0xFA96, 0x5761, 0x9AB1, 0x5764, 0x8DA3,\r\n\t0x5765, 0xFA97, 0x5766, 0x9252, 0x5769, 0x9AAE, 0x576A, 0x92D8,\t0x577F, 0x9AB2, 0x5782, 0x9082, 0x5788, 0x9AB0, 0x5789, 0x9AB3,\r\n\t0x578B, 0x8C5E, 0x5793, 0x9AB4, 0x57A0, 0x9AB5, 0x57A2, 0x8D43,\t0x57A3, 0x8A5F, 0x57A4, 0x9AB7, 0x57AA, 0x9AB8, 0x57AC, 0xFA98,\r\n\t0x57B0, 0x9AB9, 0x57B3, 0x9AB6, 0x57C0, 0x9AAF, 0x57C3, 0x9ABA,\t0x57C6, 0x9ABB, 0x57C7, 0xFA9A, 0x57C8, 0xFA99, 0x57CB, 0x9684,\r\n\t0x57CE, 0x8FE9, 0x57D2, 0x9ABD, 0x57D3, 0x9ABE, 0x57D4, 0x9ABC,\t0x57D6, 0x9AC0, 0x57DC, 0x9457, 0x57DF, 0x88E6, 0x57E0, 0x9575,\r\n\t0x57E3, 0x9AC1, 0x57F4, 0x8FFB, 0x57F7, 0x8EB7, 0x57F9, 0x947C,\t0x57FA, 0x8AEE, 0x57FC, 0x8DE9, 0x5800, 0x9678, 0x5802, 0x93B0,\r\n\t0x5805, 0x8C98, 0x5806, 0x91CD, 0x580A, 0x9ABF, 0x580B, 0x9AC2,\t0x5815, 0x91C2, 0x5819, 0x9AC3, 0x581D, 0x9AC4, 0x5821, 0x9AC6,\r\n\t0x5824, 0x92E7, 0x582A, 0x8AAC, 0x582F, 0xEA9F, 0x5830, 0x8981,\t0x5831, 0x95F1, 0x5834, 0x8FEA, 0x5835, 0x9367, 0x583A, 0x8DE4,\r\n\t0x583D, 0x9ACC, 0x5840, 0x95BB, 0x5841, 0x97DB, 0x584A, 0x89F2,\t0x584B, 0x9AC8, 0x5851, 0x9159, 0x5852, 0x9ACB, 0x5854, 0x9383,\r\n\t0x5857, 0x9368, 0x5858, 0x9384, 0x5859, 0x94B7, 0x585A, 0x92CB,\t0x585E, 0x8DC7, 0x5862, 0x9AC7, 0x5869, 0x8996, 0x586B, 0x9355,\r\n\t0x5870, 0x9AC9, 0x5872, 0x9AC5, 0x5875, 0x906F, 0x5879, 0x9ACD,\t0x587E, 0x8F6D, 0x5883, 0x8BAB, 0x5885, 0x9ACE, 0x5893, 0x95E6,\r\n\t0x5897, 0x919D, 0x589C, 0x92C4, 0x589E, 0xFA9D, 0x589F, 0x9AD0,\t0x58A8, 0x966E, 0x58AB, 0x9AD1, 0x58AE, 0x9AD6, 0x58B2, 0xFA9E,\r\n\t0x58B3, 0x95AD, 0x58B8, 0x9AD5, 0x58B9, 0x9ACF, 0x58BA, 0x9AD2,\t0x58BB, 0x9AD4, 0x58BE, 0x8DA4, 0x58C1, 0x95C7, 0x58C5, 0x9AD7,\r\n\t0x58C7, 0x9264, 0x58CA, 0x89F3, 0x58CC, 0x8FEB, 0x58D1, 0x9AD9,\t0x58D3, 0x9AD8, 0x58D5, 0x8D88, 0x58D7, 0x9ADA, 0x58D8, 0x9ADC,\r\n\t0x58D9, 0x9ADB, 0x58DC, 0x9ADE, 0x58DE, 0x9AD3, 0x58DF, 0x9AE0,\t0x58E4, 0x9ADF, 0x58E5, 0x9ADD, 0x58EB, 0x8E6D, 0x58EC, 0x9070,\r\n\t0x58EE, 0x9173, 0x58EF, 0x9AE1, 0x58F0, 0x90BA, 0x58F1, 0x88EB,\t0x58F2, 0x9484, 0x58F7, 0x92D9, 0x58F9, 0x9AE3, 0x58FA, 0x9AE2,\r\n\t0x58FB, 0x9AE4, 0x58FC, 0x9AE5, 0x58FD, 0x9AE6, 0x5902, 0x9AE7,\t0x5909, 0x95CF, 0x590A, 0x9AE8, 0x590B, 0xFA9F, 0x590F, 0x89C4,\r\n\t0x5910, 0x9AE9, 0x5915, 0x975B, 0x5916, 0x8A4F, 0x5918, 0x99C7,\t0x5919, 0x8F67, 0x591A, 0x91BD, 0x591B, 0x9AEA, 0x591C, 0x96E9,\r\n\t0x5922, 0x96B2, 0x5925, 0x9AEC, 0x5927, 0x91E5, 0x5929, 0x9356,\t0x592A, 0x91BE, 0x592B, 0x9576, 0x592C, 0x9AED, 0x592D, 0x9AEE,\r\n\t0x592E, 0x899B, 0x5931, 0x8EB8, 0x5932, 0x9AEF, 0x5937, 0x88CE,\t0x5938, 0x9AF0, 0x593E, 0x9AF1, 0x5944, 0x8982, 0x5947, 0x8AEF,\r\n\t0x5948, 0x93DE, 0x5949, 0x95F2, 0x594E, 0x9AF5, 0x594F, 0x9174,\t0x5950, 0x9AF4, 0x5951, 0x8C5F, 0x5953, 0xFAA0, 0x5954, 0x967A,\r\n\t0x5955, 0x9AF3, 0x5957, 0x9385, 0x5958, 0x9AF7, 0x595A, 0x9AF6,\t0x595B, 0xFAA1, 0x595D, 0xFAA2, 0x5960, 0x9AF9, 0x5962, 0x9AF8,\r\n\t0x5963, 0xFAA3, 0x5965, 0x899C, 0x5967, 0x9AFA, 0x5968, 0x8FA7,\t0x5969, 0x9AFC, 0x596A, 0x9244, 0x596C, 0x9AFB, 0x596E, 0x95B1,\r\n\t0x5973, 0x8F97, 0x5974, 0x937A, 0x5978, 0x9B40, 0x597D, 0x8D44,\t0x5981, 0x9B41, 0x5982, 0x9440, 0x5983, 0x94DC, 0x5984, 0x96CF,\r\n\t0x598A, 0x9444, 0x598D, 0x9B4A, 0x5993, 0x8B57, 0x5996, 0x9764,\t0x5999, 0x96AD, 0x599B, 0x9BAA, 0x599D, 0x9B42, 0x59A3, 0x9B45,\r\n\t0x59A4, 0xFAA4, 0x59A5, 0x91C3, 0x59A8, 0x9657, 0x59AC, 0x9369,\t0x59B2, 0x9B46, 0x59B9, 0x9685, 0x59BA, 0xFAA5, 0x59BB, 0x8DC8,\r\n\t0x59BE, 0x8FA8, 0x59C6, 0x9B47, 0x59C9, 0x8E6F, 0x59CB, 0x8E6E,\t0x59D0, 0x88B7, 0x59D1, 0x8CC6, 0x59D3, 0x90A9, 0x59D4, 0x88CF,\r\n\t0x59D9, 0x9B4B, 0x59DA, 0x9B4C, 0x59DC, 0x9B49, 0x59E5, 0x8957,\t0x59E6, 0x8AAD, 0x59E8, 0x9B48, 0x59EA, 0x96C3, 0x59EB, 0x9550,\r\n\t0x59F6, 0x88A6, 0x59FB, 0x88F7, 0x59FF, 0x8E70, 0x5A01, 0x88D0,\t0x5A03, 0x88A1, 0x5A09, 0x9B51, 0x5A11, 0x9B4F, 0x5A18, 0x96BA,\r\n\t0x5A1A, 0x9B52, 0x5A1C, 0x9B50, 0x5A1F, 0x9B4E, 0x5A20, 0x9050,\t0x5A25, 0x9B4D, 0x5A29, 0x95D8, 0x5A2F, 0x8CE2, 0x5A35, 0x9B56,\r\n\t0x5A36, 0x9B57, 0x5A3C, 0x8FA9, 0x5A40, 0x9B53, 0x5A41, 0x984B,\t0x5A46, 0x946B, 0x5A49, 0x9B55, 0x5A5A, 0x8DA5, 0x5A62, 0x9B58,\r\n\t0x5A66, 0x9577, 0x5A6A, 0x9B59, 0x5A6C, 0x9B54, 0x5A7F, 0x96B9,\t0x5A92, 0x947D, 0x5A9A, 0x9B5A, 0x5A9B, 0x9551, 0x5ABC, 0x9B5B,\r\n\t0x5ABD, 0x9B5F, 0x5ABE, 0x9B5C, 0x5AC1, 0x89C5, 0x5AC2, 0x9B5E,\t0x5AC9, 0x8EB9, 0x5ACB, 0x9B5D, 0x5ACC, 0x8C99, 0x5AD0, 0x9B6B,\r\n\t0x5AD6, 0x9B64, 0x5AD7, 0x9B61, 0x5AE1, 0x9284, 0x5AE3, 0x9B60,\t0x5AE6, 0x9B62, 0x5AE9, 0x9B63, 0x5AFA, 0x9B65, 0x5AFB, 0x9B66,\r\n\t0x5B09, 0x8AF0, 0x5B0B, 0x9B68, 0x5B0C, 0x9B67, 0x5B16, 0x9B69,\t0x5B22, 0x8FEC, 0x5B2A, 0x9B6C, 0x5B2C, 0x92DA, 0x5B30, 0x8964,\r\n\t0x5B32, 0x9B6A, 0x5B36, 0x9B6D, 0x5B3E, 0x9B6E, 0x5B40, 0x9B71,\t0x5B43, 0x9B6F, 0x5B45, 0x9B70, 0x5B50, 0x8E71, 0x5B51, 0x9B72,\r\n\t0x5B54, 0x8D45, 0x5B55, 0x9B73, 0x5B56, 0xFAA6, 0x5B57, 0x8E9A,\t0x5B58, 0x91B6, 0x5B5A, 0x9B74, 0x5B5B, 0x9B75, 0x5B5C, 0x8E79,\r\n\t0x5B5D, 0x8D46, 0x5B5F, 0x96D0, 0x5B63, 0x8B47, 0x5B64, 0x8CC7,\t0x5B65, 0x9B76, 0x5B66, 0x8A77, 0x5B69, 0x9B77, 0x5B6B, 0x91B7,\r\n\t0x5B70, 0x9B78, 0x5B71, 0x9BA1, 0x5B73, 0x9B79, 0x5B75, 0x9B7A,\t0x5B78, 0x9B7B, 0x5B7A, 0x9B7D, 0x5B80, 0x9B7E, 0x5B83, 0x9B80,\r\n\t0x5B85, 0x91EE, 0x5B87, 0x8946, 0x5B88, 0x8EE7, 0x5B89, 0x88C0,\t0x5B8B, 0x9176, 0x5B8C, 0x8AAE, 0x5B8D, 0x8EB3, 0x5B8F, 0x8D47,\r\n\t0x5B95, 0x9386, 0x5B97, 0x8F40, 0x5B98, 0x8AAF, 0x5B99, 0x9288,\t0x5B9A, 0x92E8, 0x5B9B, 0x88B6, 0x5B9C, 0x8B58, 0x5B9D, 0x95F3,\r\n\t0x5B9F, 0x8EC0, 0x5BA2, 0x8B71, 0x5BA3, 0x90E9, 0x5BA4, 0x8EBA,\t0x5BA5, 0x9747, 0x5BA6, 0x9B81, 0x5BAE, 0x8B7B, 0x5BB0, 0x8DC9,\r\n\t0x5BB3, 0x8A51, 0x5BB4, 0x8983, 0x5BB5, 0x8FAA, 0x5BB6, 0x89C6,\t0x5BB8, 0x9B82, 0x5BB9, 0x9765, 0x5BBF, 0x8F68, 0x5BC0, 0xFAA7,\r\n\t0x5BC2, 0x8EE2, 0x5BC3, 0x9B83, 0x5BC4, 0x8AF1, 0x5BC5, 0x93D0,\t0x5BC6, 0x96A7, 0x5BC7, 0x9B84, 0x5BC9, 0x9B85, 0x5BCC, 0x9578,\r\n\t0x5BD0, 0x9B87, 0x5BD2, 0x8AA6, 0x5BD3, 0x8BF5, 0x5BD4, 0x9B86,\t0x5BD8, 0xFAA9, 0x5BDB, 0x8AB0, 0x5BDD, 0x9051, 0x5BDE, 0x9B8B,\r\n\t0x5BDF, 0x8E40, 0x5BE1, 0x89C7, 0x5BE2, 0x9B8A, 0x5BE4, 0x9B88,\t0x5BE5, 0x9B8C, 0x5BE6, 0x9B89, 0x5BE7, 0x944A, 0x5BE8, 0x9ECB,\r\n\t0x5BE9, 0x9052, 0x5BEB, 0x9B8D, 0x5BEC, 0xFAAA, 0x5BEE, 0x97BE,\t0x5BF0, 0x9B8E, 0x5BF3, 0x9B90, 0x5BF5, 0x929E, 0x5BF6, 0x9B8F,\r\n\t0x5BF8, 0x90A1, 0x5BFA, 0x8E9B, 0x5BFE, 0x91CE, 0x5BFF, 0x8EF5,\t0x5C01, 0x9595, 0x5C02, 0x90EA, 0x5C04, 0x8ECB, 0x5C05, 0x9B91,\r\n\t0x5C06, 0x8FAB, 0x5C07, 0x9B92, 0x5C08, 0x9B93, 0x5C09, 0x88D1,\t0x5C0A, 0x91B8, 0x5C0B, 0x9071, 0x5C0D, 0x9B94, 0x5C0E, 0x93B1,\r\n\t0x5C0F, 0x8FAC, 0x5C11, 0x8FAD, 0x5C13, 0x9B95, 0x5C16, 0x90EB,\t0x5C1A, 0x8FAE, 0x5C1E, 0xFAAB, 0x5C20, 0x9B96, 0x5C22, 0x9B97,\r\n\t0x5C24, 0x96DE, 0x5C28, 0x9B98, 0x5C2D, 0x8BC4, 0x5C31, 0x8F41,\t0x5C38, 0x9B99, 0x5C39, 0x9B9A, 0x5C3A, 0x8EDA, 0x5C3B, 0x904B,\r\n\t0x5C3C, 0x93F2, 0x5C3D, 0x9073, 0x5C3E, 0x94F6, 0x5C3F, 0x9441,\t0x5C40, 0x8BC7, 0x5C41, 0x9B9B, 0x5C45, 0x8B8F, 0x5C46, 0x9B9C,\r\n\t0x5C48, 0x8BFC, 0x5C4A, 0x93CD, 0x5C4B, 0x89AE, 0x5C4D, 0x8E72,\t0x5C4E, 0x9B9D, 0x5C4F, 0x9BA0, 0x5C50, 0x9B9F, 0x5C51, 0x8BFB,\r\n\t0x5C53, 0x9B9E, 0x5C55, 0x9357, 0x5C5E, 0x91AE, 0x5C60, 0x936A,\t0x5C61, 0x8EC6, 0x5C64, 0x9177, 0x5C65, 0x979A, 0x5C6C, 0x9BA2,\r\n\t0x5C6E, 0x9BA3, 0x5C6F, 0x93D4, 0x5C71, 0x8E52, 0x5C76, 0x9BA5,\t0x5C79, 0x9BA6, 0x5C8C, 0x9BA7, 0x5C90, 0x8AF2, 0x5C91, 0x9BA8,\r\n\t0x5C94, 0x9BA9, 0x5CA1, 0x89AA, 0x5CA6, 0xFAAC, 0x5CA8, 0x915A,\t0x5CA9, 0x8AE2, 0x5CAB, 0x9BAB, 0x5CAC, 0x96A6, 0x5CB1, 0x91D0,\r\n\t0x5CB3, 0x8A78, 0x5CB6, 0x9BAD, 0x5CB7, 0x9BAF, 0x5CB8, 0x8ADD,\t0x5CBA, 0xFAAD, 0x5CBB, 0x9BAC, 0x5CBC, 0x9BAE, 0x5CBE, 0x9BB1,\r\n\t0x5CC5, 0x9BB0, 0x5CC7, 0x9BB2, 0x5CD9, 0x9BB3, 0x5CE0, 0x93BB,\t0x5CE1, 0x8BAC, 0x5CE8, 0x89E3, 0x5CE9, 0x9BB4, 0x5CEA, 0x9BB9,\r\n\t0x5CED, 0x9BB7, 0x5CEF, 0x95F5, 0x5CF0, 0x95F4, 0x5CF5, 0xFAAE,\t0x5CF6, 0x9387, 0x5CFA, 0x9BB6, 0x5CFB, 0x8F73, 0x5CFD, 0x9BB5,\r\n\t0x5D07, 0x9092, 0x5D0B, 0x9BBA, 0x5D0E, 0x8DE8, 0x5D11, 0x9BC0,\t0x5D14, 0x9BC1, 0x5D15, 0x9BBB, 0x5D16, 0x8A52, 0x5D17, 0x9BBC,\r\n\t0x5D18, 0x9BC5, 0x5D19, 0x9BC4, 0x5D1A, 0x9BC3, 0x5D1B, 0x9BBF,\t0x5D1F, 0x9BBE, 0x5D22, 0x9BC2, 0x5D27, 0xFAAF, 0x5D29, 0x95F6,\r\n\t0x5D42, 0xFAB2, 0x5D4B, 0x9BC9, 0x5D4C, 0x9BC6, 0x5D4E, 0x9BC8,\t0x5D50, 0x9792, 0x5D52, 0x9BC7, 0x5D53, 0xFAB0, 0x5D5C, 0x9BBD,\r\n\t0x5D69, 0x9093, 0x5D6C, 0x9BCA, 0x5D6D, 0xFAB3, 0x5D6F, 0x8DB5,\t0x5D73, 0x9BCB, 0x5D76, 0x9BCC, 0x5D82, 0x9BCF, 0x5D84, 0x9BCE,\r\n\t0x5D87, 0x9BCD, 0x5D8B, 0x9388, 0x5D8C, 0x9BB8, 0x5D90, 0x9BD5,\t0x5D9D, 0x9BD1, 0x5DA2, 0x9BD0, 0x5DAC, 0x9BD2, 0x5DAE, 0x9BD3,\r\n\t0x5DB7, 0x9BD6, 0x5DB8, 0xFAB4, 0x5DB9, 0xFAB5, 0x5DBA, 0x97E4,\t0x5DBC, 0x9BD7, 0x5DBD, 0x9BD4, 0x5DC9, 0x9BD8, 0x5DCC, 0x8ADE,\r\n\t0x5DCD, 0x9BD9, 0x5DD0, 0xFAB6, 0x5DD2, 0x9BDB, 0x5DD3, 0x9BDA,\t0x5DD6, 0x9BDC, 0x5DDB, 0x9BDD, 0x5DDD, 0x90EC, 0x5DDE, 0x8F42,\r\n\t0x5DE1, 0x8F84, 0x5DE3, 0x9183, 0x5DE5, 0x8D48, 0x5DE6, 0x8DB6,\t0x5DE7, 0x8D49, 0x5DE8, 0x8B90, 0x5DEB, 0x9BDE, 0x5DEE, 0x8DB7,\r\n\t0x5DF1, 0x8CC8, 0x5DF2, 0x9BDF, 0x5DF3, 0x96A4, 0x5DF4, 0x9462,\t0x5DF5, 0x9BE0, 0x5DF7, 0x8D4A, 0x5DFB, 0x8AAA, 0x5DFD, 0x9246,\r\n\t0x5DFE, 0x8BD0, 0x5E02, 0x8E73, 0x5E03, 0x957A, 0x5E06, 0x94BF,\t0x5E0B, 0x9BE1, 0x5E0C, 0x8AF3, 0x5E11, 0x9BE4, 0x5E16, 0x929F,\r\n\t0x5E19, 0x9BE3, 0x5E1A, 0x9BE2, 0x5E1B, 0x9BE5, 0x5E1D, 0x92E9,\t0x5E25, 0x9083, 0x5E2B, 0x8E74, 0x5E2D, 0x90C8, 0x5E2F, 0x91D1,\r\n\t0x5E30, 0x8B41, 0x5E33, 0x92A0, 0x5E36, 0x9BE6, 0x5E37, 0x9BE7,\t0x5E38, 0x8FED, 0x5E3D, 0x9658, 0x5E40, 0x9BEA, 0x5E43, 0x9BE9,\r\n\t0x5E44, 0x9BE8, 0x5E45, 0x959D, 0x5E47, 0x9BF1, 0x5E4C, 0x9679,\t0x5E4E, 0x9BEB, 0x5E54, 0x9BED, 0x5E55, 0x968B, 0x5E57, 0x9BEC,\r\n\t0x5E5F, 0x9BEE, 0x5E61, 0x94A6, 0x5E62, 0x9BEF, 0x5E63, 0x95BC,\t0x5E64, 0x9BF0, 0x5E72, 0x8AB1, 0x5E73, 0x95BD, 0x5E74, 0x944E,\r\n\t0x5E75, 0x9BF2, 0x5E76, 0x9BF3, 0x5E78, 0x8D4B, 0x5E79, 0x8AB2,\t0x5E7A, 0x9BF4, 0x5E7B, 0x8CB6, 0x5E7C, 0x9763, 0x5E7D, 0x9748,\r\n\t0x5E7E, 0x8AF4, 0x5E7F, 0x9BF6, 0x5E81, 0x92A1, 0x5E83, 0x8D4C,\t0x5E84, 0x8FAF, 0x5E87, 0x94DD, 0x5E8A, 0x8FB0, 0x5E8F, 0x8F98,\r\n\t0x5E95, 0x92EA, 0x5E96, 0x95F7, 0x5E97, 0x9358, 0x5E9A, 0x8D4D,\t0x5E9C, 0x957B, 0x5EA0, 0x9BF7, 0x5EA6, 0x9378, 0x5EA7, 0x8DC0,\r\n\t0x5EAB, 0x8CC9, 0x5EAD, 0x92EB, 0x5EB5, 0x88C1, 0x5EB6, 0x8F8E,\t0x5EB7, 0x8D4E, 0x5EB8, 0x9766, 0x5EC1, 0x9BF8, 0x5EC2, 0x9BF9,\r\n\t0x5EC3, 0x9470, 0x5EC8, 0x9BFA, 0x5EC9, 0x97F5, 0x5ECA, 0x984C,\t0x5ECF, 0x9BFC, 0x5ED0, 0x9BFB, 0x5ED3, 0x8A66, 0x5ED6, 0x9C40,\r\n\t0x5EDA, 0x9C43, 0x5EDB, 0x9C44, 0x5EDD, 0x9C42, 0x5EDF, 0x955F,\t0x5EE0, 0x8FB1, 0x5EE1, 0x9C46, 0x5EE2, 0x9C45, 0x5EE3, 0x9C41,\r\n\t0x5EE8, 0x9C47, 0x5EE9, 0x9C48, 0x5EEC, 0x9C49, 0x5EF0, 0x9C4C,\t0x5EF1, 0x9C4A, 0x5EF3, 0x9C4B, 0x5EF4, 0x9C4D, 0x5EF6, 0x8984,\r\n\t0x5EF7, 0x92EC, 0x5EF8, 0x9C4E, 0x5EFA, 0x8C9A, 0x5EFB, 0x89F4,\t0x5EFC, 0x9455, 0x5EFE, 0x9C4F, 0x5EFF, 0x93F9, 0x5F01, 0x95D9,\r\n\t0x5F03, 0x9C50, 0x5F04, 0x984D, 0x5F09, 0x9C51, 0x5F0A, 0x95BE,\t0x5F0B, 0x9C54, 0x5F0C, 0x989F, 0x5F0D, 0x98AF, 0x5F0F, 0x8EAE,\r\n\t0x5F10, 0x93F3, 0x5F11, 0x9C55, 0x5F13, 0x8B7C, 0x5F14, 0x92A2,\t0x5F15, 0x88F8, 0x5F16, 0x9C56, 0x5F17, 0x95A4, 0x5F18, 0x8D4F,\r\n\t0x5F1B, 0x926F, 0x5F1F, 0x92ED, 0x5F21, 0xFAB7, 0x5F25, 0x96ED,\t0x5F26, 0x8CB7, 0x5F27, 0x8CCA, 0x5F29, 0x9C57, 0x5F2D, 0x9C58,\r\n\t0x5F2F, 0x9C5E, 0x5F31, 0x8EE3, 0x5F34, 0xFAB8, 0x5F35, 0x92A3,\t0x5F37, 0x8BAD, 0x5F38, 0x9C59, 0x5F3C, 0x954A, 0x5F3E, 0x9265,\r\n\t0x5F41, 0x9C5A, 0x5F45, 0xFA67, 0x5F48, 0x9C5B, 0x5F4A, 0x8BAE,\t0x5F4C, 0x9C5C, 0x5F4E, 0x9C5D, 0x5F51, 0x9C5F, 0x5F53, 0x9396,\r\n\t0x5F56, 0x9C60, 0x5F57, 0x9C61, 0x5F59, 0x9C62, 0x5F5C, 0x9C53,\t0x5F5D, 0x9C52, 0x5F61, 0x9C63, 0x5F62, 0x8C60, 0x5F66, 0x9546,\r\n\t0x5F67, 0xFAB9, 0x5F69, 0x8DCA, 0x5F6A, 0x9556, 0x5F6B, 0x92A4,\t0x5F6C, 0x956A, 0x5F6D, 0x9C64, 0x5F70, 0x8FB2, 0x5F71, 0x8965,\r\n\t0x5F73, 0x9C65, 0x5F77, 0x9C66, 0x5F79, 0x96F0, 0x5F7C, 0x94DE,\t0x5F7F, 0x9C69, 0x5F80, 0x899D, 0x5F81, 0x90AA, 0x5F82, 0x9C68,\r\n\t0x5F83, 0x9C67, 0x5F84, 0x8C61, 0x5F85, 0x91D2, 0x5F87, 0x9C6D,\t0x5F88, 0x9C6B, 0x5F8A, 0x9C6A, 0x5F8B, 0x97A5, 0x5F8C, 0x8CE3,\r\n\t0x5F90, 0x8F99, 0x5F91, 0x9C6C, 0x5F92, 0x936B, 0x5F93, 0x8F5D,\t0x5F97, 0x93BE, 0x5F98, 0x9C70, 0x5F99, 0x9C6F, 0x5F9E, 0x9C6E,\r\n\t0x5FA0, 0x9C71, 0x5FA1, 0x8CE4, 0x5FA8, 0x9C72, 0x5FA9, 0x959C,\t0x5FAA, 0x8F7A, 0x5FAD, 0x9C73, 0x5FAE, 0x94F7, 0x5FB3, 0x93BF,\r\n\t0x5FB4, 0x92A5, 0x5FB7, 0xFABA, 0x5FB9, 0x934F, 0x5FBC, 0x9C74,\t0x5FBD, 0x8B4A, 0x5FC3, 0x9053, 0x5FC5, 0x954B, 0x5FCC, 0x8AF5,\r\n\t0x5FCD, 0x9445, 0x5FD6, 0x9C75, 0x5FD7, 0x8E75, 0x5FD8, 0x9659,\t0x5FD9, 0x965A, 0x5FDC, 0x899E, 0x5FDD, 0x9C7A, 0x5FDE, 0xFABB,\r\n\t0x5FE0, 0x9289, 0x5FE4, 0x9C77, 0x5FEB, 0x89F5, 0x5FF0, 0x9CAB,\t0x5FF1, 0x9C79, 0x5FF5, 0x944F, 0x5FF8, 0x9C78, 0x5FFB, 0x9C76,\r\n\t0x5FFD, 0x8D9A, 0x5FFF, 0x9C7C, 0x600E, 0x9C83, 0x600F, 0x9C89,\t0x6010, 0x9C81, 0x6012, 0x937B, 0x6015, 0x9C86, 0x6016, 0x957C,\r\n\t0x6019, 0x9C80, 0x601B, 0x9C85, 0x601C, 0x97E5, 0x601D, 0x8E76,\t0x6020, 0x91D3, 0x6021, 0x9C7D, 0x6025, 0x8B7D, 0x6026, 0x9C88,\r\n\t0x6027, 0x90AB, 0x6028, 0x8985, 0x6029, 0x9C82, 0x602A, 0x89F6,\t0x602B, 0x9C87, 0x602F, 0x8BAF, 0x6031, 0x9C84, 0x603A, 0x9C8A,\r\n\t0x6041, 0x9C8C, 0x6042, 0x9C96, 0x6043, 0x9C94, 0x6046, 0x9C91,\t0x604A, 0x9C90, 0x604B, 0x97F6, 0x604D, 0x9C92, 0x6050, 0x8BB0,\r\n\t0x6052, 0x8D50, 0x6055, 0x8F9A, 0x6059, 0x9C99, 0x605A, 0x9C8B,\t0x605D, 0xFABC, 0x605F, 0x9C8F, 0x6060, 0x9C7E, 0x6062, 0x89F8,\r\n\t0x6063, 0x9C93, 0x6064, 0x9C95, 0x6065, 0x9270, 0x6068, 0x8DA6,\t0x6069, 0x89B6, 0x606A, 0x9C8D, 0x606B, 0x9C98, 0x606C, 0x9C97,\r\n\t0x606D, 0x8BB1, 0x606F, 0x91A7, 0x6070, 0x8A86, 0x6075, 0x8C62,\t0x6077, 0x9C8E, 0x6081, 0x9C9A, 0x6083, 0x9C9D, 0x6084, 0x9C9F,\r\n\t0x6085, 0xFABD, 0x6089, 0x8EBB, 0x608A, 0xFABE, 0x608B, 0x9CA5,\t0x608C, 0x92EE, 0x608D, 0x9C9B, 0x6092, 0x9CA3, 0x6094, 0x89F7,\r\n\t0x6096, 0x9CA1, 0x6097, 0x9CA2, 0x609A, 0x9C9E, 0x609B, 0x9CA0,\t0x609F, 0x8CE5, 0x60A0, 0x9749, 0x60A3, 0x8AB3, 0x60A6, 0x8978,\r\n\t0x60A7, 0x9CA4, 0x60A9, 0x9459, 0x60AA, 0x88AB, 0x60B2, 0x94DF,\t0x60B3, 0x9C7B, 0x60B4, 0x9CAA, 0x60B5, 0x9CAE, 0x60B6, 0x96E3,\r\n\t0x60B8, 0x9CA7, 0x60BC, 0x9389, 0x60BD, 0x9CAC, 0x60C5, 0x8FEE,\t0x60C6, 0x9CAD, 0x60C7, 0x93D5, 0x60D1, 0x9866, 0x60D3, 0x9CA9,\r\n\t0x60D5, 0xFAC0, 0x60D8, 0x9CAF, 0x60DA, 0x8D9B, 0x60DC, 0x90C9,\t0x60DE, 0xFABF, 0x60DF, 0x88D2, 0x60E0, 0x9CA8, 0x60E1, 0x9CA6,\r\n\t0x60E3, 0x9179, 0x60E7, 0x9C9C, 0x60E8, 0x8E53, 0x60F0, 0x91C4,\t0x60F1, 0x9CBB, 0x60F2, 0xFAC2, 0x60F3, 0x917A, 0x60F4, 0x9CB6,\r\n\t0x60F6, 0x9CB3, 0x60F7, 0x9CB4, 0x60F9, 0x8EE4, 0x60FA, 0x9CB7,\t0x60FB, 0x9CBA, 0x6100, 0x9CB5, 0x6101, 0x8F44, 0x6103, 0x9CB8,\r\n\t0x6106, 0x9CB2, 0x6108, 0x96FA, 0x6109, 0x96F9, 0x610D, 0x9CBC,\t0x610E, 0x9CBD, 0x610F, 0x88D3, 0x6111, 0xFAC3, 0x6115, 0x9CB1,\r\n\t0x611A, 0x8BF0, 0x611B, 0x88A4, 0x611F, 0x8AB4, 0x6120, 0xFAC1,\t0x6121, 0x9CB9, 0x6127, 0x9CC1, 0x6128, 0x9CC0, 0x612C, 0x9CC5,\r\n\t0x6130, 0xFAC5, 0x6134, 0x9CC6, 0x6137, 0xFAC4, 0x613C, 0x9CC4,\t0x613D, 0x9CC7, 0x613E, 0x9CBF, 0x613F, 0x9CC3, 0x6142, 0x9CC8,\r\n\t0x6144, 0x9CC9, 0x6147, 0x9CBE, 0x6148, 0x8E9C, 0x614A, 0x9CC2,\t0x614B, 0x91D4, 0x614C, 0x8D51, 0x614D, 0x9CB0, 0x614E, 0x9054,\r\n\t0x6153, 0x9CD6, 0x6155, 0x95E7, 0x6158, 0x9CCC, 0x6159, 0x9CCD,\t0x615A, 0x9CCE, 0x615D, 0x9CD5, 0x615F, 0x9CD4, 0x6162, 0x969D,\r\n\t0x6163, 0x8AB5, 0x6165, 0x9CD2, 0x6167, 0x8C64, 0x6168, 0x8A53,\t0x616B, 0x9CCF, 0x616E, 0x97B6, 0x616F, 0x9CD1, 0x6170, 0x88D4,\r\n\t0x6171, 0x9CD3, 0x6173, 0x9CCA, 0x6174, 0x9CD0, 0x6175, 0x9CD7,\t0x6176, 0x8C63, 0x6177, 0x9CCB, 0x617E, 0x977C, 0x6182, 0x974A,\r\n\t0x6187, 0x9CDA, 0x618A, 0x9CDE, 0x618E, 0x919E, 0x6190, 0x97F7,\t0x6191, 0x9CDF, 0x6194, 0x9CDC, 0x6196, 0x9CD9, 0x6198, 0xFAC6,\r\n\t0x6199, 0x9CD8, 0x619A, 0x9CDD, 0x61A4, 0x95AE, 0x61A7, 0x93B2,\t0x61A9, 0x8C65, 0x61AB, 0x9CE0, 0x61AC, 0x9CDB, 0x61AE, 0x9CE1,\r\n\t0x61B2, 0x8C9B, 0x61B6, 0x89AF, 0x61BA, 0x9CE9, 0x61BE, 0x8AB6,\t0x61C3, 0x9CE7, 0x61C6, 0x9CE8, 0x61C7, 0x8DA7, 0x61C8, 0x9CE6,\r\n\t0x61C9, 0x9CE4, 0x61CA, 0x9CE3, 0x61CB, 0x9CEA, 0x61CC, 0x9CE2,\t0x61CD, 0x9CEC, 0x61D0, 0x89F9, 0x61E3, 0x9CEE, 0x61E6, 0x9CED,\r\n\t0x61F2, 0x92A6, 0x61F4, 0x9CF1, 0x61F6, 0x9CEF, 0x61F7, 0x9CE5,\t0x61F8, 0x8C9C, 0x61FA, 0x9CF0, 0x61FC, 0x9CF4, 0x61FD, 0x9CF3,\r\n\t0x61FE, 0x9CF5, 0x61FF, 0x9CF2, 0x6200, 0x9CF6, 0x6208, 0x9CF7,\t0x6209, 0x9CF8, 0x620A, 0x95E8, 0x620C, 0x9CFA, 0x620D, 0x9CF9,\r\n\t0x620E, 0x8F5E, 0x6210, 0x90AC, 0x6211, 0x89E4, 0x6212, 0x89FA,\t0x6213, 0xFAC7, 0x6214, 0x9CFB, 0x6216, 0x88BD, 0x621A, 0x90CA,\r\n\t0x621B, 0x9CFC, 0x621D, 0xE6C1, 0x621E, 0x9D40, 0x621F, 0x8C81,\t0x6221, 0x9D41, 0x6226, 0x90ED, 0x622A, 0x9D42, 0x622E, 0x9D43,\r\n\t0x622F, 0x8B59, 0x6230, 0x9D44, 0x6232, 0x9D45, 0x6233, 0x9D46,\t0x6234, 0x91D5, 0x6238, 0x8CCB, 0x623B, 0x96DF, 0x623F, 0x965B,\r\n\t0x6240, 0x8F8A, 0x6241, 0x9D47, 0x6247, 0x90EE, 0x6248, 0xE7BB,\t0x6249, 0x94E0, 0x624B, 0x8EE8, 0x624D, 0x8DCB, 0x624E, 0x9D48,\r\n\t0x6253, 0x91C5, 0x6255, 0x95A5, 0x6258, 0x91EF, 0x625B, 0x9D4B,\t0x625E, 0x9D49, 0x6260, 0x9D4C, 0x6263, 0x9D4A, 0x6268, 0x9D4D,\r\n\t0x626E, 0x95AF, 0x6271, 0x88B5, 0x6276, 0x957D, 0x6279, 0x94E1,\t0x627C, 0x9D4E, 0x627E, 0x9D51, 0x627F, 0x8FB3, 0x6280, 0x8B5A,\r\n\t0x6282, 0x9D4F, 0x6283, 0x9D56, 0x6284, 0x8FB4, 0x6289, 0x9D50,\t0x628A, 0x9463, 0x6291, 0x977D, 0x6292, 0x9D52, 0x6293, 0x9D53,\r\n\t0x6294, 0x9D57, 0x6295, 0x938A, 0x6296, 0x9D54, 0x6297, 0x8D52,\t0x6298, 0x90DC, 0x629B, 0x9D65, 0x629C, 0x94B2, 0x629E, 0x91F0,\r\n\t0x62A6, 0xFAC8, 0x62AB, 0x94E2, 0x62AC, 0x9DAB, 0x62B1, 0x95F8,\t0x62B5, 0x92EF, 0x62B9, 0x9695, 0x62BB, 0x9D5A, 0x62BC, 0x899F,\r\n\t0x62BD, 0x928A, 0x62C2, 0x9D63, 0x62C5, 0x9253, 0x62C6, 0x9D5D,\t0x62C7, 0x9D64, 0x62C8, 0x9D5F, 0x62C9, 0x9D66, 0x62CA, 0x9D62,\r\n\t0x62CC, 0x9D61, 0x62CD, 0x948F, 0x62CF, 0x9D5B, 0x62D0, 0x89FB,\t0x62D1, 0x9D59, 0x62D2, 0x8B91, 0x62D3, 0x91F1, 0x62D4, 0x9D55,\r\n\t0x62D7, 0x9D58, 0x62D8, 0x8D53, 0x62D9, 0x90D9, 0x62DB, 0x8FB5,\t0x62DC, 0x9D60, 0x62DD, 0x9471, 0x62E0, 0x8B92, 0x62E1, 0x8A67,\r\n\t0x62EC, 0x8A87, 0x62ED, 0x9040, 0x62EE, 0x9D68, 0x62EF, 0x9D6D,\t0x62F1, 0x9D69, 0x62F3, 0x8C9D, 0x62F5, 0x9D6E, 0x62F6, 0x8E41,\r\n\t0x62F7, 0x8D89, 0x62FE, 0x8F45, 0x62FF, 0x9D5C, 0x6301, 0x8E9D,\t0x6302, 0x9D6B, 0x6307, 0x8E77, 0x6308, 0x9D6C, 0x6309, 0x88C2,\r\n\t0x630C, 0x9D67, 0x6311, 0x92A7, 0x6319, 0x8B93, 0x631F, 0x8BB2,\t0x6327, 0x9D6A, 0x6328, 0x88A5, 0x632B, 0x8DC1, 0x632F, 0x9055,\r\n\t0x633A, 0x92F0, 0x633D, 0x94D2, 0x633E, 0x9D70, 0x633F, 0x917D,\t0x6349, 0x91A8, 0x634C, 0x8E4A, 0x634D, 0x9D71, 0x634F, 0x9D73,\r\n\t0x6350, 0x9D6F, 0x6355, 0x95DF, 0x6357, 0x92BB, 0x635C, 0x917B,\t0x6367, 0x95F9, 0x6368, 0x8ECC, 0x6369, 0x9D80, 0x636B, 0x9D7E,\r\n\t0x636E, 0x9098, 0x6372, 0x8C9E, 0x6376, 0x9D78, 0x6377, 0x8FB7,\t0x637A, 0x93E6, 0x637B, 0x9450, 0x6380, 0x9D76, 0x6383, 0x917C,\r\n\t0x6388, 0x8EF6, 0x6389, 0x9D7B, 0x638C, 0x8FB6, 0x638E, 0x9D75,\t0x638F, 0x9D7A, 0x6392, 0x9472, 0x6396, 0x9D74, 0x6398, 0x8C40,\r\n\t0x639B, 0x8A7C, 0x639F, 0x9D7C, 0x63A0, 0x97A9, 0x63A1, 0x8DCC,\t0x63A2, 0x9254, 0x63A3, 0x9D79, 0x63A5, 0x90DA, 0x63A7, 0x8D54,\r\n\t0x63A8, 0x9084, 0x63A9, 0x8986, 0x63AA, 0x915B, 0x63AB, 0x9D77,\t0x63AC, 0x8B64, 0x63B2, 0x8C66, 0x63B4, 0x92CD, 0x63B5, 0x9D7D,\r\n\t0x63BB, 0x917E, 0x63BE, 0x9D81, 0x63C0, 0x9D83, 0x63C3, 0x91B5,\t0x63C4, 0x9D89, 0x63C6, 0x9D84, 0x63C9, 0x9D86, 0x63CF, 0x9560,\r\n\t0x63D0, 0x92F1, 0x63D2, 0x9D87, 0x63D6, 0x974B, 0x63DA, 0x9767,\t0x63DB, 0x8AB7, 0x63E1, 0x88AC, 0x63E3, 0x9D85, 0x63E9, 0x9D82,\r\n\t0x63EE, 0x8AF6, 0x63F4, 0x8987, 0x63F5, 0xFAC9, 0x63F6, 0x9D88,\t0x63FA, 0x9768, 0x6406, 0x9D8C, 0x640D, 0x91B9, 0x640F, 0x9D93,\r\n\t0x6413, 0x9D8D, 0x6416, 0x9D8A, 0x6417, 0x9D91, 0x641C, 0x9D72,\t0x6426, 0x9D8E, 0x6428, 0x9D92, 0x642C, 0x94C0, 0x642D, 0x938B,\r\n\t0x6434, 0x9D8B, 0x6436, 0x9D8F, 0x643A, 0x8C67, 0x643E, 0x8DEF,\t0x6442, 0x90DB, 0x644E, 0x9D97, 0x6458, 0x9345, 0x6460, 0xFACA,\r\n\t0x6467, 0x9D94, 0x6469, 0x9680, 0x646F, 0x9D95, 0x6476, 0x9D96,\t0x6478, 0x96CC, 0x647A, 0x90A0, 0x6483, 0x8C82, 0x6488, 0x9D9D,\r\n\t0x6492, 0x8E54, 0x6493, 0x9D9A, 0x6495, 0x9D99, 0x649A, 0x9451,\t0x649D, 0xFACB, 0x649E, 0x93B3, 0x64A4, 0x9350, 0x64A5, 0x9D9B,\r\n\t0x64A9, 0x9D9C, 0x64AB, 0x958F, 0x64AD, 0x9464, 0x64AE, 0x8E42,\t0x64B0, 0x90EF, 0x64B2, 0x966F, 0x64B9, 0x8A68, 0x64BB, 0x9DA3,\r\n\t0x64BC, 0x9D9E, 0x64C1, 0x9769, 0x64C2, 0x9DA5, 0x64C5, 0x9DA1,\t0x64C7, 0x9DA2, 0x64CD, 0x9180, 0x64CE, 0xFACC, 0x64D2, 0x9DA0,\r\n\t0x64D4, 0x9D5E, 0x64D8, 0x9DA4, 0x64DA, 0x9D9F, 0x64E0, 0x9DA9,\t0x64E1, 0x9DAA, 0x64E2, 0x9346, 0x64E3, 0x9DAC, 0x64E6, 0x8E43,\r\n\t0x64E7, 0x9DA7, 0x64EC, 0x8B5B, 0x64EF, 0x9DAD, 0x64F1, 0x9DA6,\t0x64F2, 0x9DB1, 0x64F4, 0x9DB0, 0x64F6, 0x9DAF, 0x64FA, 0x9DB2,\r\n\t0x64FD, 0x9DB4, 0x64FE, 0x8FEF, 0x6500, 0x9DB3, 0x6505, 0x9DB7,\t0x6518, 0x9DB5, 0x651C, 0x9DB6, 0x651D, 0x9D90, 0x6523, 0x9DB9,\r\n\t0x6524, 0x9DB8, 0x652A, 0x9D98, 0x652B, 0x9DBA, 0x652C, 0x9DAE,\t0x652F, 0x8E78, 0x6534, 0x9DBB, 0x6535, 0x9DBC, 0x6536, 0x9DBE,\r\n\t0x6537, 0x9DBD, 0x6538, 0x9DBF, 0x6539, 0x89FC, 0x653B, 0x8D55,\t0x653E, 0x95FA, 0x653F, 0x90AD, 0x6545, 0x8CCC, 0x6548, 0x9DC1,\r\n\t0x654D, 0x9DC4, 0x654E, 0xFACD, 0x654F, 0x9571, 0x6551, 0x8B7E,\t0x6555, 0x9DC3, 0x6556, 0x9DC2, 0x6557, 0x9473, 0x6558, 0x9DC5,\r\n\t0x6559, 0x8BB3, 0x655D, 0x9DC7, 0x655E, 0x9DC6, 0x6562, 0x8AB8,\t0x6563, 0x8E55, 0x6566, 0x93D6, 0x656C, 0x8C68, 0x6570, 0x9094,\r\n\t0x6572, 0x9DC8, 0x6574, 0x90AE, 0x6575, 0x9347, 0x6577, 0x957E,\t0x6578, 0x9DC9, 0x6582, 0x9DCA, 0x6583, 0x9DCB, 0x6587, 0x95B6,\r\n\t0x6588, 0x9B7C, 0x6589, 0x90C4, 0x658C, 0x956B, 0x658E, 0x8DD6,\t0x6590, 0x94E3, 0x6591, 0x94C1, 0x6597, 0x936C, 0x6599, 0x97BF,\r\n\t0x659B, 0x9DCD, 0x659C, 0x8ECE, 0x659F, 0x9DCE, 0x65A1, 0x88B4,\t0x65A4, 0x8BD2, 0x65A5, 0x90CB, 0x65A7, 0x9580, 0x65AB, 0x9DCF,\r\n\t0x65AC, 0x8E61, 0x65AD, 0x9266, 0x65AF, 0x8E7A, 0x65B0, 0x9056,\t0x65B7, 0x9DD0, 0x65B9, 0x95FB, 0x65BC, 0x8997, 0x65BD, 0x8E7B,\r\n\t0x65C1, 0x9DD3, 0x65C3, 0x9DD1, 0x65C4, 0x9DD4, 0x65C5, 0x97B7,\t0x65C6, 0x9DD2, 0x65CB, 0x90F9, 0x65CC, 0x9DD5, 0x65CF, 0x91B0,\r\n\t0x65D2, 0x9DD6, 0x65D7, 0x8AF8, 0x65D9, 0x9DD8, 0x65DB, 0x9DD7,\t0x65E0, 0x9DD9, 0x65E1, 0x9DDA, 0x65E2, 0x8AF9, 0x65E5, 0x93FA,\r\n\t0x65E6, 0x9255, 0x65E7, 0x8B8C, 0x65E8, 0x8E7C, 0x65E9, 0x9181,\t0x65EC, 0x8F7B, 0x65ED, 0x88AE, 0x65F1, 0x9DDB, 0x65FA, 0x89A0,\r\n\t0x65FB, 0x9DDF, 0x6600, 0xFACE, 0x6602, 0x8D56, 0x6603, 0x9DDE,\t0x6606, 0x8DA9, 0x6607, 0x8FB8, 0x6609, 0xFAD1, 0x660A, 0x9DDD,\r\n\t0x660C, 0x8FB9, 0x660E, 0x96BE, 0x660F, 0x8DA8, 0x6613, 0x88D5,\t0x6614, 0x90CC, 0x6615, 0xFACF, 0x661C, 0x9DE4, 0x661E, 0xFAD3,\r\n\t0x661F, 0x90AF, 0x6620, 0x8966, 0x6624, 0xFAD4, 0x6625, 0x8F74,\t0x6627, 0x9686, 0x6628, 0x8DF0, 0x662D, 0x8FBA, 0x662E, 0xFAD2,\r\n\t0x662F, 0x90A5, 0x6631, 0xFA63, 0x6634, 0x9DE3, 0x6635, 0x9DE1,\t0x6636, 0x9DE2, 0x663B, 0xFAD0, 0x663C, 0x928B, 0x663F, 0x9E45,\r\n\t0x6641, 0x9DE8, 0x6642, 0x8E9E, 0x6643, 0x8D57, 0x6644, 0x9DE6,\t0x6649, 0x9DE7, 0x664B, 0x9057, 0x664F, 0x9DE5, 0x6652, 0x8E4E,\r\n\t0x6657, 0xFAD6, 0x6659, 0xFAD7, 0x665D, 0x9DEA, 0x665E, 0x9DE9,\t0x665F, 0x9DEE, 0x6662, 0x9DEF, 0x6664, 0x9DEB, 0x6665, 0xFAD5,\r\n\t0x6666, 0x8A41, 0x6667, 0x9DEC, 0x6668, 0x9DED, 0x6669, 0x94D3,\t0x666E, 0x9581, 0x666F, 0x8C69, 0x6670, 0x9DF0, 0x6673, 0xFAD9,\r\n\t0x6674, 0x90B0, 0x6676, 0x8FBB, 0x667A, 0x9271, 0x6681, 0x8BC5,\t0x6683, 0x9DF1, 0x6684, 0x9DF5, 0x6687, 0x89C9, 0x6688, 0x9DF2,\r\n\t0x6689, 0x9DF4, 0x668E, 0x9DF3, 0x6691, 0x8F8B, 0x6696, 0x9267,\t0x6697, 0x88C3, 0x6698, 0x9DF6, 0x6699, 0xFADA, 0x669D, 0x9DF7,\r\n\t0x66A0, 0xFADB, 0x66A2, 0x92A8, 0x66A6, 0x97EF, 0x66AB, 0x8E62,\t0x66AE, 0x95E9, 0x66B2, 0xFADC, 0x66B4, 0x965C, 0x66B8, 0x9E41,\r\n\t0x66B9, 0x9DF9, 0x66BC, 0x9DFC, 0x66BE, 0x9DFB, 0x66BF, 0xFADD,\t0x66C1, 0x9DF8, 0x66C4, 0x9E40, 0x66C7, 0x93DC, 0x66C9, 0x9DFA,\r\n\t0x66D6, 0x9E42, 0x66D9, 0x8F8C, 0x66DA, 0x9E43, 0x66DC, 0x976A,\t0x66DD, 0x9498, 0x66E0, 0x9E44, 0x66E6, 0x9E46, 0x66E9, 0x9E47,\r\n\t0x66F0, 0x9E48, 0x66F2, 0x8BC8, 0x66F3, 0x8967, 0x66F4, 0x8D58,\t0x66F5, 0x9E49, 0x66F7, 0x9E4A, 0x66F8, 0x8F91, 0x66F9, 0x9182,\r\n\t0x66FA, 0xFADE, 0x66FB, 0xFA66, 0x66FC, 0x99D6, 0x66FD, 0x915D,\t0x66FE, 0x915C, 0x66FF, 0x91D6, 0x6700, 0x8DC5, 0x6703, 0x98F0,\r\n\t0x6708, 0x8C8E, 0x6709, 0x974C, 0x670B, 0x95FC, 0x670D, 0x959E,\t0x670E, 0xFADF, 0x670F, 0x9E4B, 0x6714, 0x8DF1, 0x6715, 0x92BD,\r\n\t0x6716, 0x9E4C, 0x6717, 0x984E, 0x671B, 0x965D, 0x671D, 0x92A9,\t0x671E, 0x9E4D, 0x671F, 0x8AFA, 0x6726, 0x9E4E, 0x6727, 0x9E4F,\r\n\t0x6728, 0x96D8, 0x672A, 0x96A2, 0x672B, 0x9696, 0x672C, 0x967B,\t0x672D, 0x8E44, 0x672E, 0x9E51, 0x6731, 0x8EE9, 0x6734, 0x9670,\r\n\t0x6736, 0x9E53, 0x6737, 0x9E56, 0x6738, 0x9E55, 0x673A, 0x8AF7,\t0x673D, 0x8B80, 0x673F, 0x9E52, 0x6741, 0x9E54, 0x6746, 0x9E57,\r\n\t0x6749, 0x9099, 0x674E, 0x979B, 0x674F, 0x88C7, 0x6750, 0x8DDE,\t0x6751, 0x91BA, 0x6753, 0x8EDB, 0x6756, 0x8FF1, 0x6759, 0x9E5A,\r\n\t0x675C, 0x936D, 0x675E, 0x9E58, 0x675F, 0x91A9, 0x6760, 0x9E59,\t0x6761, 0x8FF0, 0x6762, 0x96DB, 0x6763, 0x9E5B, 0x6764, 0x9E5C,\r\n\t0x6765, 0x9788, 0x6766, 0xFAE1, 0x676A, 0x9E61, 0x676D, 0x8D59,\t0x676F, 0x9474, 0x6770, 0x9E5E, 0x6771, 0x938C, 0x6772, 0x9DDC,\r\n\t0x6773, 0x9DE0, 0x6775, 0x8B6E, 0x6777, 0x9466, 0x677C, 0x9E60,\t0x677E, 0x8FBC, 0x677F, 0x94C2, 0x6785, 0x9E66, 0x6787, 0x94F8,\r\n\t0x6789, 0x9E5D, 0x678B, 0x9E63, 0x678C, 0x9E62, 0x6790, 0x90CD,\t0x6795, 0x968D, 0x6797, 0x97D1, 0x679A, 0x9687, 0x679C, 0x89CA,\r\n\t0x679D, 0x8E7D, 0x67A0, 0x9867, 0x67A1, 0x9E65, 0x67A2, 0x9095,\t0x67A6, 0x9E64, 0x67A9, 0x9E5F, 0x67AF, 0x8CCD, 0x67B3, 0x9E6B,\r\n\t0x67B4, 0x9E69, 0x67B6, 0x89CB, 0x67B7, 0x9E67, 0x67B8, 0x9E6D,\t0x67B9, 0x9E73, 0x67BB, 0xFAE2, 0x67C0, 0xFAE4, 0x67C1, 0x91C6,\r\n\t0x67C4, 0x95BF, 0x67C6, 0x9E75, 0x67CA, 0x9541, 0x67CE, 0x9E74,\t0x67CF, 0x9490, 0x67D0, 0x965E, 0x67D1, 0x8AB9, 0x67D3, 0x90F5,\r\n\t0x67D4, 0x8F5F, 0x67D8, 0x92D1, 0x67DA, 0x974D, 0x67DD, 0x9E70,\t0x67DE, 0x9E6F, 0x67E2, 0x9E71, 0x67E4, 0x9E6E, 0x67E7, 0x9E76,\r\n\t0x67E9, 0x9E6C, 0x67EC, 0x9E6A, 0x67EE, 0x9E72, 0x67EF, 0x9E68,\t0x67F1, 0x928C, 0x67F3, 0x96F6, 0x67F4, 0x8EC4, 0x67F5, 0x8DF2,\r\n\t0x67FB, 0x8DB8, 0x67FE, 0x968F, 0x67FF, 0x8A60, 0x6801, 0xFAE5,\t0x6802, 0x92CC, 0x6803, 0x93C8, 0x6804, 0x8968, 0x6813, 0x90F0,\r\n\t0x6816, 0x90B2, 0x6817, 0x8C49, 0x681E, 0x9E78, 0x6821, 0x8D5A,\t0x6822, 0x8A9C, 0x6829, 0x9E7A, 0x682A, 0x8A94, 0x682B, 0x9E81,\r\n\t0x6832, 0x9E7D, 0x6834, 0x90F1, 0x6838, 0x8A6A, 0x6839, 0x8DAA,\t0x683C, 0x8A69, 0x683D, 0x8DCD, 0x6840, 0x9E7B, 0x6841, 0x8C85,\r\n\t0x6842, 0x8C6A, 0x6843, 0x938D, 0x6844, 0xFAE6, 0x6846, 0x9E79,\t0x6848, 0x88C4, 0x684D, 0x9E7C, 0x684E, 0x9E7E, 0x6850, 0x8BCB,\r\n\t0x6851, 0x8C4B, 0x6852, 0xFAE3, 0x6853, 0x8ABA, 0x6854, 0x8B6A,\t0x6859, 0x9E82, 0x685C, 0x8DF7, 0x685D, 0x9691, 0x685F, 0x8E56,\r\n\t0x6863, 0x9E83, 0x6867, 0x954F, 0x6874, 0x9E8F, 0x6876, 0x89B1,\t0x6877, 0x9E84, 0x687E, 0x9E95, 0x687F, 0x9E85, 0x6881, 0x97C0,\r\n\t0x6883, 0x9E8C, 0x6885, 0x947E, 0x688D, 0x9E94, 0x688F, 0x9E87,\t0x6893, 0x88B2, 0x6894, 0x9E89, 0x6897, 0x8D5B, 0x689B, 0x9E8B,\r\n\t0x689D, 0x9E8A, 0x689F, 0x9E86, 0x68A0, 0x9E91, 0x68A2, 0x8FBD,\t0x68A6, 0x9AEB, 0x68A7, 0x8CE6, 0x68A8, 0x979C, 0x68AD, 0x9E88,\r\n\t0x68AF, 0x92F2, 0x68B0, 0x8A42, 0x68B1, 0x8DAB, 0x68B3, 0x9E80,\t0x68B5, 0x9E90, 0x68B6, 0x8A81, 0x68B9, 0x9E8E, 0x68BA, 0x9E92,\r\n\t0x68BC, 0x938E, 0x68C4, 0x8AFC, 0x68C6, 0x9EB0, 0x68C8, 0xFA64,\t0x68C9, 0x96C7, 0x68CA, 0x9E97, 0x68CB, 0x8AFB, 0x68CD, 0x9E9E,\r\n\t0x68CF, 0xFAE7, 0x68D2, 0x965F, 0x68D4, 0x9E9F, 0x68D5, 0x9EA1,\t0x68D7, 0x9EA5, 0x68D8, 0x9E99, 0x68DA, 0x9249, 0x68DF, 0x938F,\r\n\t0x68E0, 0x9EA9, 0x68E1, 0x9E9C, 0x68E3, 0x9EA6, 0x68E7, 0x9EA0,\t0x68EE, 0x9058, 0x68EF, 0x9EAA, 0x68F2, 0x90B1, 0x68F9, 0x9EA8,\r\n\t0x68FA, 0x8ABB, 0x6900, 0x986F, 0x6901, 0x9E96, 0x6904, 0x9EA4,\t0x6905, 0x88D6, 0x6908, 0x9E98, 0x690B, 0x96B8, 0x690C, 0x9E9D,\r\n\t0x690D, 0x9041, 0x690E, 0x92C5, 0x690F, 0x9E93, 0x6912, 0x9EA3,\t0x6919, 0x909A, 0x691A, 0x9EAD, 0x691B, 0x8A91, 0x691C, 0x8C9F,\r\n\t0x6921, 0x9EAF, 0x6922, 0x9E9A, 0x6923, 0x9EAE, 0x6925, 0x9EA7,\t0x6926, 0x9E9B, 0x6928, 0x9EAB, 0x692A, 0x9EAC, 0x6930, 0x9EBD,\r\n\t0x6934, 0x93CC, 0x6936, 0x9EA2, 0x6939, 0x9EB9, 0x693D, 0x9EBB,\t0x693F, 0x92D6, 0x694A, 0x976B, 0x6953, 0x9596, 0x6954, 0x9EB6,\r\n\t0x6955, 0x91C8, 0x6959, 0x9EBC, 0x695A, 0x915E, 0x695C, 0x9EB3,\t0x695D, 0x9EC0, 0x695E, 0x9EBF, 0x6960, 0x93ED, 0x6961, 0x9EBE,\r\n\t0x6962, 0x93E8, 0x6968, 0xFAE9, 0x696A, 0x9EC2, 0x696B, 0x9EB5,\t0x696D, 0x8BC6, 0x696E, 0x9EB8, 0x696F, 0x8F7C, 0x6973, 0x9480,\r\n\t0x6974, 0x9EBA, 0x6975, 0x8BC9, 0x6977, 0x9EB2, 0x6978, 0x9EB4,\t0x6979, 0x9EB1, 0x697C, 0x984F, 0x697D, 0x8A79, 0x697E, 0x9EB7,\r\n\t0x6981, 0x9EC1, 0x6982, 0x8A54, 0x698A, 0x8DE5, 0x698E, 0x897C,\t0x6991, 0x9ED2, 0x6994, 0x9850, 0x6995, 0x9ED5, 0x6998, 0xFAEB,\r\n\t0x699B, 0x9059, 0x699C, 0x9ED4, 0x69A0, 0x9ED3, 0x69A7, 0x9ED0,\t0x69AE, 0x9EC4, 0x69B1, 0x9EE1, 0x69B2, 0x9EC3, 0x69B4, 0x9ED6,\r\n\t0x69BB, 0x9ECE, 0x69BE, 0x9EC9, 0x69BF, 0x9EC6, 0x69C1, 0x9EC7,\t0x69C3, 0x9ECF, 0x69C7, 0xEAA0, 0x69CA, 0x9ECC, 0x69CB, 0x8D5C,\r\n\t0x69CC, 0x92C6, 0x69CD, 0x9184, 0x69CE, 0x9ECA, 0x69D0, 0x9EC5,\t0x69D3, 0x9EC8, 0x69D8, 0x976C, 0x69D9, 0x968A, 0x69DD, 0x9ECD,\r\n\t0x69DE, 0x9ED7, 0x69E2, 0xFAEC, 0x69E7, 0x9EDF, 0x69E8, 0x9ED8,\t0x69EB, 0x9EE5, 0x69ED, 0x9EE3, 0x69F2, 0x9EDE, 0x69F9, 0x9EDD,\r\n\t0x69FB, 0x92CE, 0x69FD, 0x9185, 0x69FF, 0x9EDB, 0x6A02, 0x9ED9,\t0x6A05, 0x9EE0, 0x6A0A, 0x9EE6, 0x6A0B, 0x94F3, 0x6A0C, 0x9EEC,\r\n\t0x6A12, 0x9EE7, 0x6A13, 0x9EEA, 0x6A14, 0x9EE4, 0x6A17, 0x9294,\t0x6A19, 0x9557, 0x6A1B, 0x9EDA, 0x6A1E, 0x9EE2, 0x6A1F, 0x8FBE,\r\n\t0x6A21, 0x96CD, 0x6A22, 0x9EF6, 0x6A23, 0x9EE9, 0x6A29, 0x8CA0,\t0x6A2A, 0x89A1, 0x6A2B, 0x8A7E, 0x6A2E, 0x9ED1, 0x6A30, 0xFAED,\r\n\t0x6A35, 0x8FBF, 0x6A36, 0x9EEE, 0x6A38, 0x9EF5, 0x6A39, 0x8EF7,\t0x6A3A, 0x8A92, 0x6A3D, 0x924D, 0x6A44, 0x9EEB, 0x6A46, 0xFAEF,\r\n\t0x6A47, 0x9EF0, 0x6A48, 0x9EF4, 0x6A4B, 0x8BB4, 0x6A58, 0x8B6B,\t0x6A59, 0x9EF2, 0x6A5F, 0x8B40, 0x6A61, 0x93C9, 0x6A62, 0x9EF1,\r\n\t0x6A66, 0x9EF3, 0x6A6B, 0xFAEE, 0x6A72, 0x9EED, 0x6A73, 0xFAF0,\t0x6A78, 0x9EEF, 0x6A7E, 0xFAF1, 0x6A7F, 0x8A80, 0x6A80, 0x9268,\r\n\t0x6A84, 0x9EFA, 0x6A8D, 0x9EF8, 0x6A8E, 0x8CE7, 0x6A90, 0x9EF7,\t0x6A97, 0x9F40, 0x6A9C, 0x9E77, 0x6AA0, 0x9EF9, 0x6AA2, 0x9EFB,\r\n\t0x6AA3, 0x9EFC, 0x6AAA, 0x9F4B, 0x6AAC, 0x9F47, 0x6AAE, 0x9E8D,\t0x6AB3, 0x9F46, 0x6AB8, 0x9F45, 0x6ABB, 0x9F42, 0x6AC1, 0x9EE8,\r\n\t0x6AC2, 0x9F44, 0x6AC3, 0x9F43, 0x6AD1, 0x9F49, 0x6AD3, 0x9845,\t0x6ADA, 0x9F4C, 0x6ADB, 0x8BF9, 0x6ADE, 0x9F48, 0x6ADF, 0x9F4A,\r\n\t0x6AE2, 0xFAF2, 0x6AE4, 0xFAF3, 0x6AE8, 0x94A5, 0x6AEA, 0x9F4D,\t0x6AFA, 0x9F51, 0x6AFB, 0x9F4E, 0x6B04, 0x9793, 0x6B05, 0x9F4F,\r\n\t0x6B0A, 0x9EDC, 0x6B12, 0x9F52, 0x6B16, 0x9F53, 0x6B1D, 0x8954,\t0x6B1F, 0x9F55, 0x6B20, 0x8C87, 0x6B21, 0x8E9F, 0x6B23, 0x8BD3,\r\n\t0x6B27, 0x89A2, 0x6B32, 0x977E, 0x6B37, 0x9F57, 0x6B38, 0x9F56,\t0x6B39, 0x9F59, 0x6B3A, 0x8B5C, 0x6B3D, 0x8BD4, 0x6B3E, 0x8ABC,\r\n\t0x6B43, 0x9F5C, 0x6B47, 0x9F5B, 0x6B49, 0x9F5D, 0x6B4C, 0x89CC,\t0x6B4E, 0x9256, 0x6B50, 0x9F5E, 0x6B53, 0x8ABD, 0x6B54, 0x9F60,\r\n\t0x6B59, 0x9F5F, 0x6B5B, 0x9F61, 0x6B5F, 0x9F62, 0x6B61, 0x9F63,\t0x6B62, 0x8E7E, 0x6B63, 0x90B3, 0x6B64, 0x8D9F, 0x6B66, 0x9590,\r\n\t0x6B69, 0x95E0, 0x6B6A, 0x9863, 0x6B6F, 0x8E95, 0x6B73, 0x8DCE,\t0x6B74, 0x97F0, 0x6B78, 0x9F64, 0x6B79, 0x9F65, 0x6B7B, 0x8E80,\r\n\t0x6B7F, 0x9F66, 0x6B80, 0x9F67, 0x6B83, 0x9F69, 0x6B84, 0x9F68,\t0x6B86, 0x9677, 0x6B89, 0x8F7D, 0x6B8A, 0x8EEA, 0x6B8B, 0x8E63,\r\n\t0x6B8D, 0x9F6A, 0x6B95, 0x9F6C, 0x6B96, 0x9042, 0x6B98, 0x9F6B,\t0x6B9E, 0x9F6D, 0x6BA4, 0x9F6E, 0x6BAA, 0x9F6F, 0x6BAB, 0x9F70,\r\n\t0x6BAF, 0x9F71, 0x6BB1, 0x9F73, 0x6BB2, 0x9F72, 0x6BB3, 0x9F74,\t0x6BB4, 0x89A3, 0x6BB5, 0x9269, 0x6BB7, 0x9F75, 0x6BBA, 0x8E45,\r\n\t0x6BBB, 0x8A6B, 0x6BBC, 0x9F76, 0x6BBF, 0x9361, 0x6BC0, 0x9ACA,\t0x6BC5, 0x8B42, 0x6BC6, 0x9F77, 0x6BCB, 0x9F78, 0x6BCD, 0x95EA,\r\n\t0x6BCE, 0x9688, 0x6BD2, 0x93C5, 0x6BD3, 0x9F79, 0x6BD4, 0x94E4,\t0x6BD6, 0xFAF4, 0x6BD8, 0x94F9, 0x6BDB, 0x96D1, 0x6BDF, 0x9F7A,\r\n\t0x6BEB, 0x9F7C, 0x6BEC, 0x9F7B, 0x6BEF, 0x9F7E, 0x6BF3, 0x9F7D,\t0x6C08, 0x9F81, 0x6C0F, 0x8E81, 0x6C11, 0x96AF, 0x6C13, 0x9F82,\r\n\t0x6C14, 0x9F83, 0x6C17, 0x8B43, 0x6C1B, 0x9F84, 0x6C23, 0x9F86,\t0x6C24, 0x9F85, 0x6C34, 0x9085, 0x6C37, 0x9558, 0x6C38, 0x8969,\r\n\t0x6C3E, 0x94C3, 0x6C3F, 0xFAF5, 0x6C40, 0x92F3, 0x6C41, 0x8F60,\t0x6C42, 0x8B81, 0x6C4E, 0x94C4, 0x6C50, 0x8EAC, 0x6C55, 0x9F88,\r\n\t0x6C57, 0x8ABE, 0x6C5A, 0x8998, 0x6C5C, 0xFAF6, 0x6C5D, 0x93F0,\t0x6C5E, 0x9F87, 0x6C5F, 0x8D5D, 0x6C60, 0x9272, 0x6C62, 0x9F89,\r\n\t0x6C68, 0x9F91, 0x6C6A, 0x9F8A, 0x6C6F, 0xFAF8, 0x6C70, 0x91BF,\t0x6C72, 0x8B82, 0x6C73, 0x9F92, 0x6C7A, 0x8C88, 0x6C7D, 0x8B44,\r\n\t0x6C7E, 0x9F90, 0x6C81, 0x9F8E, 0x6C82, 0x9F8B, 0x6C83, 0x9780,\t0x6C86, 0xFAF7, 0x6C88, 0x92BE, 0x6C8C, 0x93D7, 0x6C8D, 0x9F8C,\r\n\t0x6C90, 0x9F94, 0x6C92, 0x9F93, 0x6C93, 0x8C42, 0x6C96, 0x89AB,\t0x6C99, 0x8DB9, 0x6C9A, 0x9F8D, 0x6C9B, 0x9F8F, 0x6CA1, 0x9676,\r\n\t0x6CA2, 0x91F2, 0x6CAB, 0x9697, 0x6CAE, 0x9F9C, 0x6CB1, 0x9F9D,\t0x6CB3, 0x89CD, 0x6CB8, 0x95A6, 0x6CB9, 0x96FB, 0x6CBA, 0x9F9F,\r\n\t0x6CBB, 0x8EA1, 0x6CBC, 0x8FC0, 0x6CBD, 0x9F98, 0x6CBE, 0x9F9E,\t0x6CBF, 0x8988, 0x6CC1, 0x8BB5, 0x6CC4, 0x9F95, 0x6CC5, 0x9F9A,\r\n\t0x6CC9, 0x90F2, 0x6CCA, 0x9491, 0x6CCC, 0x94E5, 0x6CD3, 0x9F97,\t0x6CD5, 0x9640, 0x6CD7, 0x9F99, 0x6CD9, 0x9FA2, 0x6CDA, 0xFAF9,\r\n\t0x6CDB, 0x9FA0, 0x6CDD, 0x9F9B, 0x6CE1, 0x9641, 0x6CE2, 0x9467,\t0x6CE3, 0x8B83, 0x6CE5, 0x9344, 0x6CE8, 0x928D, 0x6CEA, 0x9FA3,\r\n\t0x6CEF, 0x9FA1, 0x6CF0, 0x91D7, 0x6CF1, 0x9F96, 0x6CF3, 0x896A,\t0x6D04, 0xFAFA, 0x6D0B, 0x976D, 0x6D0C, 0x9FAE, 0x6D12, 0x9FAD,\r\n\t0x6D17, 0x90F4, 0x6D19, 0x9FAA, 0x6D1B, 0x978C, 0x6D1E, 0x93B4,\t0x6D1F, 0x9FA4, 0x6D25, 0x92C3, 0x6D29, 0x896B, 0x6D2A, 0x8D5E,\r\n\t0x6D2B, 0x9FA7, 0x6D32, 0x8F46, 0x6D33, 0x9FAC, 0x6D35, 0x9FAB,\t0x6D36, 0x9FA6, 0x6D38, 0x9FA9, 0x6D3B, 0x8A88, 0x6D3D, 0x9FA8,\r\n\t0x6D3E, 0x9468, 0x6D41, 0x97AC, 0x6D44, 0x8FF2, 0x6D45, 0x90F3,\t0x6D59, 0x9FB4, 0x6D5A, 0x9FB2, 0x6D5C, 0x956C, 0x6D63, 0x9FAF,\r\n\t0x6D64, 0x9FB1, 0x6D66, 0x8959, 0x6D69, 0x8D5F, 0x6D6A, 0x9851,\t0x6D6C, 0x8A5C, 0x6D6E, 0x9582, 0x6D6F, 0xFAFC, 0x6D74, 0x9781,\r\n\t0x6D77, 0x8A43, 0x6D78, 0x905A, 0x6D79, 0x9FB3, 0x6D85, 0x9FB8,\t0x6D87, 0xFAFB, 0x6D88, 0x8FC1, 0x6D8C, 0x974F, 0x6D8E, 0x9FB5,\r\n\t0x6D93, 0x9FB0, 0x6D95, 0x9FB6, 0x6D96, 0xFB40, 0x6D99, 0x97DC,\t0x6D9B, 0x9393, 0x6D9C, 0x93C0, 0x6DAC, 0xFB41, 0x6DAF, 0x8A55,\r\n\t0x6DB2, 0x8974, 0x6DB5, 0x9FBC, 0x6DB8, 0x9FBF, 0x6DBC, 0x97C1,\t0x6DC0, 0x9784, 0x6DC5, 0x9FC6, 0x6DC6, 0x9FC0, 0x6DC7, 0x9FBD,\r\n\t0x6DCB, 0x97D2, 0x6DCC, 0x9FC3, 0x6DCF, 0xFB42, 0x6DD1, 0x8F69,\t0x6DD2, 0x9FC5, 0x6DD5, 0x9FCA, 0x6DD8, 0x9391, 0x6DD9, 0x9FC8,\r\n\t0x6DDE, 0x9FC2, 0x6DE1, 0x9257, 0x6DE4, 0x9FC9, 0x6DE6, 0x9FBE,\t0x6DE8, 0x9FC4, 0x6DEA, 0x9FCB, 0x6DEB, 0x88FA, 0x6DEC, 0x9FC1,\r\n\t0x6DEE, 0x9FCC, 0x6DF1, 0x905B, 0x6DF2, 0xFB44, 0x6DF3, 0x8F7E,\t0x6DF5, 0x95A3, 0x6DF7, 0x8DAC, 0x6DF8, 0xFB43, 0x6DF9, 0x9FB9,\r\n\t0x6DFA, 0x9FC7, 0x6DFB, 0x9359, 0x6DFC, 0xFB45, 0x6E05, 0x90B4,\t0x6E07, 0x8A89, 0x6E08, 0x8DCF, 0x6E09, 0x8FC2, 0x6E0A, 0x9FBB,\r\n\t0x6E0B, 0x8F61, 0x6E13, 0x8C6B, 0x6E15, 0x9FBA, 0x6E19, 0x9FD0,\t0x6E1A, 0x8F8D, 0x6E1B, 0x8CB8, 0x6E1D, 0x9FDF, 0x6E1F, 0x9FD9,\r\n\t0x6E20, 0x8B94, 0x6E21, 0x936E, 0x6E23, 0x9FD4, 0x6E24, 0x9FDD,\t0x6E25, 0x88AD, 0x6E26, 0x8951, 0x6E27, 0xFB48, 0x6E29, 0x89B7,\r\n\t0x6E2B, 0x9FD6, 0x6E2C, 0x91AA, 0x6E2D, 0x9FCD, 0x6E2E, 0x9FCF,\t0x6E2F, 0x8D60, 0x6E38, 0x9FE0, 0x6E39, 0xFB46, 0x6E3A, 0x9FDB,\r\n\t0x6E3C, 0xFB49, 0x6E3E, 0x9FD3, 0x6E43, 0x9FDA, 0x6E4A, 0x96A9,\t0x6E4D, 0x9FD8, 0x6E4E, 0x9FDC, 0x6E56, 0x8CCE, 0x6E58, 0x8FC3,\r\n\t0x6E5B, 0x9258, 0x6E5C, 0xFB47, 0x6E5F, 0x9FD2, 0x6E67, 0x974E,\t0x6E6B, 0x9FD5, 0x6E6E, 0x9FCE, 0x6E6F, 0x9392, 0x6E72, 0x9FD1,\r\n\t0x6E76, 0x9FD7, 0x6E7E, 0x9870, 0x6E7F, 0x8EBC, 0x6E80, 0x969E,\t0x6E82, 0x9FE1, 0x6E8C, 0x94AC, 0x6E8F, 0x9FED, 0x6E90, 0x8CB9,\r\n\t0x6E96, 0x8F80, 0x6E98, 0x9FE3, 0x6E9C, 0x97AD, 0x6E9D, 0x8D61,\t0x6E9F, 0x9FF0, 0x6EA2, 0x88EC, 0x6EA5, 0x9FEE, 0x6EAA, 0x9FE2,\r\n\t0x6EAF, 0x9FE8, 0x6EB2, 0x9FEA, 0x6EB6, 0x976E, 0x6EB7, 0x9FE5,\t0x6EBA, 0x934D, 0x6EBD, 0x9FE7, 0x6EBF, 0xFB4A, 0x6EC2, 0x9FEF,\r\n\t0x6EC4, 0x9FE9, 0x6EC5, 0x96C5, 0x6EC9, 0x9FE4, 0x6ECB, 0x8EA0,\t0x6ECC, 0x9FFC, 0x6ED1, 0x8A8A, 0x6ED3, 0x9FE6, 0x6ED4, 0x9FEB,\r\n\t0x6ED5, 0x9FEC, 0x6EDD, 0x91EA, 0x6EDE, 0x91D8, 0x6EEC, 0x9FF4,\t0x6EEF, 0x9FFA, 0x6EF2, 0x9FF8, 0x6EF4, 0x9348, 0x6EF7, 0xE042,\r\n\t0x6EF8, 0x9FF5, 0x6EFE, 0x9FF6, 0x6EFF, 0x9FDE, 0x6F01, 0x8B99,\t0x6F02, 0x9559, 0x6F06, 0x8EBD, 0x6F09, 0x8D97, 0x6F0F, 0x9852,\r\n\t0x6F11, 0x9FF2, 0x6F13, 0xE041, 0x6F14, 0x8989, 0x6F15, 0x9186,\t0x6F20, 0x9499, 0x6F22, 0x8ABF, 0x6F23, 0x97F8, 0x6F2B, 0x969F,\r\n\t0x6F2C, 0x92D0, 0x6F31, 0x9FF9, 0x6F32, 0x9FFB, 0x6F38, 0x9151,\t0x6F3E, 0xE040, 0x6F3F, 0x9FF7, 0x6F41, 0x9FF1, 0x6F45, 0x8AC1,\r\n\t0x6F54, 0x8C89, 0x6F58, 0xE04E, 0x6F5B, 0xE049, 0x6F5C, 0x90F6,\t0x6F5F, 0x8A83, 0x6F64, 0x8F81, 0x6F66, 0xE052, 0x6F6D, 0xE04B,\r\n\t0x6F6E, 0x92AA, 0x6F6F, 0xE048, 0x6F70, 0x92D7, 0x6F74, 0xE06B,\t0x6F78, 0xE045, 0x6F7A, 0xE044, 0x6F7C, 0xE04D, 0x6F80, 0xE047,\r\n\t0x6F81, 0xE046, 0x6F82, 0xE04C, 0x6F84, 0x909F, 0x6F86, 0xE043,\t0x6F88, 0xFB4B, 0x6F8E, 0xE04F, 0x6F91, 0xE050, 0x6F97, 0x8AC0,\r\n\t0x6FA1, 0xE055, 0x6FA3, 0xE054, 0x6FA4, 0xE056, 0x6FAA, 0xE059,\t0x6FB1, 0x9362, 0x6FB3, 0xE053, 0x6FB5, 0xFB4C, 0x6FB9, 0xE057,\r\n\t0x6FC0, 0x8C83, 0x6FC1, 0x91F7, 0x6FC2, 0xE051, 0x6FC3, 0x945A,\t0x6FC6, 0xE058, 0x6FD4, 0xE05D, 0x6FD5, 0xE05B, 0x6FD8, 0xE05E,\r\n\t0x6FDB, 0xE061, 0x6FDF, 0xE05A, 0x6FE0, 0x8D8A, 0x6FE1, 0x9447,\t0x6FE4, 0x9FB7, 0x6FEB, 0x9794, 0x6FEC, 0xE05C, 0x6FEE, 0xE060,\r\n\t0x6FEF, 0x91F3, 0x6FF1, 0xE05F, 0x6FF3, 0xE04A, 0x6FF5, 0xFB4D,\t0x6FF6, 0xE889, 0x6FFA, 0xE064, 0x6FFE, 0xE068, 0x7001, 0xE066,\r\n\t0x7005, 0xFB4E, 0x7007, 0xFB4F, 0x7009, 0xE062, 0x700B, 0xE063,\t0x700F, 0xE067, 0x7011, 0xE065, 0x7015, 0x956D, 0x7018, 0xE06D,\r\n\t0x701A, 0xE06A, 0x701B, 0xE069, 0x701D, 0xE06C, 0x701E, 0x93D2,\t0x701F, 0xE06E, 0x7026, 0x9295, 0x7027, 0x91EB, 0x7028, 0xFB50,\r\n\t0x702C, 0x90A3, 0x7030, 0xE06F, 0x7032, 0xE071, 0x703E, 0xE070,\t0x704C, 0x9FF3, 0x7051, 0xE072, 0x7058, 0x93E5, 0x7063, 0xE073,\r\n\t0x706B, 0x89CE, 0x706F, 0x9394, 0x7070, 0x8A44, 0x7078, 0x8B84,\t0x707C, 0x8EDC, 0x707D, 0x8DD0, 0x7085, 0xFB51, 0x7089, 0x9846,\r\n\t0x708A, 0x9086, 0x708E, 0x898A, 0x7092, 0xE075, 0x7099, 0xE074,\t0x70AB, 0xFB52, 0x70AC, 0xE078, 0x70AD, 0x9259, 0x70AE, 0xE07B,\r\n\t0x70AF, 0xE076, 0x70B3, 0xE07A, 0x70B8, 0xE079, 0x70B9, 0x935F,\t0x70BA, 0x88D7, 0x70BB, 0xFA62, 0x70C8, 0x97F3, 0x70CB, 0xE07D,\r\n\t0x70CF, 0x8947, 0x70D9, 0xE080, 0x70DD, 0xE07E, 0x70DF, 0xE07C,\t0x70F1, 0xE077, 0x70F9, 0x9642, 0x70FD, 0xE082, 0x7104, 0xFB54,\r\n\t0x7109, 0xE081, 0x710F, 0xFB53, 0x7114, 0x898B, 0x7119, 0xE084,\t0x711A, 0x95B0, 0x711C, 0xE083, 0x7121, 0x96B3, 0x7126, 0x8FC5,\r\n\t0x7136, 0x9152, 0x713C, 0x8FC4, 0x7146, 0xFB56, 0x7147, 0xFB57,\t0x7149, 0x97F9, 0x714C, 0xE08A, 0x714E, 0x90F7, 0x7155, 0xE086,\r\n\t0x7156, 0xE08B, 0x7159, 0x898C, 0x715C, 0xFB55, 0x7162, 0xE089,\t0x7164, 0x9481, 0x7165, 0xE085, 0x7166, 0xE088, 0x7167, 0x8FC6,\r\n\t0x7169, 0x94CF, 0x716C, 0xE08C, 0x716E, 0x8ECF, 0x717D, 0x90F8,\t0x7184, 0xE08F, 0x7188, 0xE087, 0x718A, 0x8C46, 0x718F, 0xE08D,\r\n\t0x7194, 0x976F, 0x7195, 0xE090, 0x7199, 0xEAA4, 0x719F, 0x8F6E,\t0x71A8, 0xE091, 0x71AC, 0xE092, 0x71B1, 0x944D, 0x71B9, 0xE094,\r\n\t0x71BE, 0xE095, 0x71C1, 0xFB59, 0x71C3, 0x9452, 0x71C8, 0x9395,\t0x71C9, 0xE097, 0x71CE, 0xE099, 0x71D0, 0x97D3, 0x71D2, 0xE096,\r\n\t0x71D4, 0xE098, 0x71D5, 0x898D, 0x71D7, 0xE093, 0x71DF, 0x9A7A,\t0x71E0, 0xE09A, 0x71E5, 0x9187, 0x71E6, 0x8E57, 0x71E7, 0xE09C,\r\n\t0x71EC, 0xE09B, 0x71ED, 0x9043, 0x71EE, 0x99D7, 0x71F5, 0xE09D,\t0x71F9, 0xE09F, 0x71FB, 0xE08E, 0x71FC, 0xE09E, 0x71FE, 0xFB5A,\r\n\t0x71FF, 0xE0A0, 0x7206, 0x949A, 0x720D, 0xE0A1, 0x7210, 0xE0A2,\t0x721B, 0xE0A3, 0x7228, 0xE0A4, 0x722A, 0x92DC, 0x722C, 0xE0A6,\r\n\t0x722D, 0xE0A5, 0x7230, 0xE0A7, 0x7232, 0xE0A8, 0x7235, 0x8EDD,\t0x7236, 0x9583, 0x723A, 0x96EA, 0x723B, 0xE0A9, 0x723C, 0xE0AA,\r\n\t0x723D, 0x9175, 0x723E, 0x8EA2, 0x723F, 0xE0AB, 0x7240, 0xE0AC,\t0x7246, 0xE0AD, 0x7247, 0x95D0, 0x7248, 0x94C5, 0x724B, 0xE0AE,\r\n\t0x724C, 0x9476, 0x7252, 0x92AB, 0x7258, 0xE0AF, 0x7259, 0x89E5,\t0x725B, 0x8B8D, 0x725D, 0x96C4, 0x725F, 0x96B4, 0x7261, 0x89B2,\r\n\t0x7262, 0x9853, 0x7267, 0x9671, 0x7269, 0x95A8, 0x7272, 0x90B5,\t0x7274, 0xE0B0, 0x7279, 0x93C1, 0x727D, 0x8CA1, 0x727E, 0xE0B1,\r\n\t0x7280, 0x8DD2, 0x7281, 0xE0B3, 0x7282, 0xE0B2, 0x7287, 0xE0B4,\t0x7292, 0xE0B5, 0x7296, 0xE0B6, 0x72A0, 0x8B5D, 0x72A2, 0xE0B7,\r\n\t0x72A7, 0xE0B8, 0x72AC, 0x8CA2, 0x72AF, 0x94C6, 0x72B1, 0xFB5B,\t0x72B2, 0xE0BA, 0x72B6, 0x8FF3, 0x72B9, 0xE0B9, 0x72BE, 0xFB5C,\r\n\t0x72C2, 0x8BB6, 0x72C3, 0xE0BB, 0x72C4, 0xE0BD, 0x72C6, 0xE0BC,\t0x72CE, 0xE0BE, 0x72D0, 0x8CCF, 0x72D2, 0xE0BF, 0x72D7, 0x8BE7,\r\n\t0x72D9, 0x915F, 0x72DB, 0x8D9D, 0x72E0, 0xE0C1, 0x72E1, 0xE0C2,\t0x72E2, 0xE0C0, 0x72E9, 0x8EEB, 0x72EC, 0x93C6, 0x72ED, 0x8BB7,\r\n\t0x72F7, 0xE0C4, 0x72F8, 0x924B, 0x72F9, 0xE0C3, 0x72FC, 0x9854,\t0x72FD, 0x9482, 0x730A, 0xE0C7, 0x7316, 0xE0C9, 0x7317, 0xE0C6,\r\n\t0x731B, 0x96D2, 0x731C, 0xE0C8, 0x731D, 0xE0CA, 0x731F, 0x97C2,\t0x7324, 0xFB5D, 0x7325, 0xE0CE, 0x7329, 0xE0CD, 0x732A, 0x9296,\r\n\t0x732B, 0x944C, 0x732E, 0x8CA3, 0x732F, 0xE0CC, 0x7334, 0xE0CB,\t0x7336, 0x9750, 0x7337, 0x9751, 0x733E, 0xE0CF, 0x733F, 0x898E,\r\n\t0x7344, 0x8D96, 0x7345, 0x8E82, 0x734E, 0xE0D0, 0x734F, 0xE0D1,\t0x7357, 0xE0D3, 0x7363, 0x8F62, 0x7368, 0xE0D5, 0x736A, 0xE0D4,\r\n\t0x7370, 0xE0D6, 0x7372, 0x8A6C, 0x7375, 0xE0D8, 0x7377, 0xFB5F,\t0x7378, 0xE0D7, 0x737A, 0xE0DA, 0x737B, 0xE0D9, 0x7384, 0x8CBA,\r\n\t0x7387, 0x97A6, 0x7389, 0x8BCA, 0x738B, 0x89A4, 0x7396, 0x8BE8,\t0x73A9, 0x8ADF, 0x73B2, 0x97E6, 0x73B3, 0xE0DC, 0x73BB, 0xE0DE,\r\n\t0x73BD, 0xFB60, 0x73C0, 0xE0DF, 0x73C2, 0x89CF, 0x73C8, 0xE0DB,\t0x73C9, 0xFB61, 0x73CA, 0x8E58, 0x73CD, 0x92BF, 0x73CE, 0xE0DD,\r\n\t0x73D2, 0xFB64, 0x73D6, 0xFB62, 0x73DE, 0xE0E2, 0x73E0, 0x8EEC,\t0x73E3, 0xFB63, 0x73E5, 0xE0E0, 0x73EA, 0x8C5D, 0x73ED, 0x94C7,\r\n\t0x73EE, 0xE0E1, 0x73F1, 0xE0FC, 0x73F5, 0xFB66, 0x73F8, 0xE0E7,\t0x73FE, 0x8CBB, 0x7403, 0x8B85, 0x7405, 0xE0E4, 0x7406, 0x979D,\r\n\t0x7407, 0xFB65, 0x7409, 0x97AE, 0x7422, 0x91F4, 0x7425, 0xE0E6,\t0x7426, 0xFB67, 0x7429, 0xFB69, 0x742A, 0xFB68, 0x742E, 0xFB6A,\r\n\t0x7432, 0xE0E8, 0x7433, 0x97D4, 0x7434, 0x8BD5, 0x7435, 0x94FA,\t0x7436, 0x9469, 0x743A, 0xE0E9, 0x743F, 0xE0EB, 0x7441, 0xE0EE,\r\n\t0x7455, 0xE0EA, 0x7459, 0xE0ED, 0x745A, 0x8CE8, 0x745B, 0x896C,\t0x745C, 0xE0EF, 0x745E, 0x9090, 0x745F, 0xE0EC, 0x7460, 0x97DA,\r\n\t0x7462, 0xFB6B, 0x7463, 0xE0F2, 0x7464, 0xEAA2, 0x7469, 0xE0F0,\t0x746A, 0xE0F3, 0x746F, 0xE0E5, 0x7470, 0xE0F1, 0x7473, 0x8DBA,\r\n\t0x7476, 0xE0F4, 0x747E, 0xE0F5, 0x7483, 0x979E, 0x7489, 0xFB6C,\t0x748B, 0xE0F6, 0x749E, 0xE0F7, 0x749F, 0xFB6D, 0x74A2, 0xE0E3,\r\n\t0x74A7, 0xE0F8, 0x74B0, 0x8AC2, 0x74BD, 0x8EA3, 0x74CA, 0xE0F9,\t0x74CF, 0xE0FA, 0x74D4, 0xE0FB, 0x74DC, 0x895A, 0x74E0, 0xE140,\r\n\t0x74E2, 0x955A, 0x74E3, 0xE141, 0x74E6, 0x8AA2, 0x74E7, 0xE142,\t0x74E9, 0xE143, 0x74EE, 0xE144, 0x74F0, 0xE146, 0x74F1, 0xE147,\r\n\t0x74F2, 0xE145, 0x74F6, 0x9572, 0x74F7, 0xE149, 0x74F8, 0xE148,\t0x7501, 0xFB6E, 0x7503, 0xE14B, 0x7504, 0xE14A, 0x7505, 0xE14C,\r\n\t0x750C, 0xE14D, 0x750D, 0xE14F, 0x750E, 0xE14E, 0x7511, 0x8D99,\t0x7513, 0xE151, 0x7515, 0xE150, 0x7518, 0x8AC3, 0x751A, 0x9072,\r\n\t0x751C, 0x935B, 0x751E, 0xE152, 0x751F, 0x90B6, 0x7523, 0x8E59,\t0x7525, 0x8999, 0x7526, 0xE153, 0x7528, 0x9770, 0x752B, 0x95E1,\r\n\t0x752C, 0xE154, 0x752F, 0xFAA8, 0x7530, 0x9363, 0x7531, 0x9752,\t0x7532, 0x8D62, 0x7533, 0x905C, 0x7537, 0x926A, 0x7538, 0x99B2,\r\n\t0x753A, 0x92AC, 0x753B, 0x89E6, 0x753C, 0xE155, 0x7544, 0xE156,\t0x7546, 0xE15B, 0x7549, 0xE159, 0x754A, 0xE158, 0x754B, 0x9DC0,\r\n\t0x754C, 0x8A45, 0x754D, 0xE157, 0x754F, 0x88D8, 0x7551, 0x94A8,\t0x7554, 0x94C8, 0x7559, 0x97AF, 0x755A, 0xE15C, 0x755B, 0xE15A,\r\n\t0x755C, 0x927B, 0x755D, 0x90A4, 0x7560, 0x94A9, 0x7562, 0x954C,\t0x7564, 0xE15E, 0x7565, 0x97AA, 0x7566, 0x8C6C, 0x7567, 0xE15F,\r\n\t0x7569, 0xE15D, 0x756A, 0x94D4, 0x756B, 0xE160, 0x756D, 0xE161,\t0x756F, 0xFB6F, 0x7570, 0x88D9, 0x7573, 0x8FF4, 0x7574, 0xE166,\r\n\t0x7576, 0xE163, 0x7577, 0x93EB, 0x7578, 0xE162, 0x757F, 0x8B45,\t0x7582, 0xE169, 0x7586, 0xE164, 0x7587, 0xE165, 0x7589, 0xE168,\r\n\t0x758A, 0xE167, 0x758B, 0x9544, 0x758E, 0x9161, 0x758F, 0x9160,\t0x7591, 0x8B5E, 0x7594, 0xE16A, 0x759A, 0xE16B, 0x759D, 0xE16C,\r\n\t0x75A3, 0xE16E, 0x75A5, 0xE16D, 0x75AB, 0x8975, 0x75B1, 0xE176,\t0x75B2, 0x94E6, 0x75B3, 0xE170, 0x75B5, 0xE172, 0x75B8, 0xE174,\r\n\t0x75B9, 0x905D, 0x75BC, 0xE175, 0x75BD, 0xE173, 0x75BE, 0x8EBE,\t0x75C2, 0xE16F, 0x75C3, 0xE171, 0x75C5, 0x9561, 0x75C7, 0x8FC7,\r\n\t0x75CA, 0xE178, 0x75CD, 0xE177, 0x75D2, 0xE179, 0x75D4, 0x8EA4,\t0x75D5, 0x8DAD, 0x75D8, 0x9397, 0x75D9, 0xE17A, 0x75DB, 0x92C9,\r\n\t0x75DE, 0xE17C, 0x75E2, 0x979F, 0x75E3, 0xE17B, 0x75E9, 0x9189,\t0x75F0, 0xE182, 0x75F2, 0xE184, 0x75F3, 0xE185, 0x75F4, 0x9273,\r\n\t0x75FA, 0xE183, 0x75FC, 0xE180, 0x75FE, 0xE17D, 0x75FF, 0xE17E,\t0x7601, 0xE181, 0x7609, 0xE188, 0x760B, 0xE186, 0x760D, 0xE187,\r\n\t0x761F, 0xE189, 0x7620, 0xE18B, 0x7621, 0xE18C, 0x7622, 0xE18D,\t0x7624, 0xE18E, 0x7627, 0xE18A, 0x7630, 0xE190, 0x7634, 0xE18F,\r\n\t0x763B, 0xE191, 0x7642, 0x97C3, 0x7646, 0xE194, 0x7647, 0xE192,\t0x7648, 0xE193, 0x764C, 0x8AE0, 0x7652, 0x96FC, 0x7656, 0x95C8,\r\n\t0x7658, 0xE196, 0x765C, 0xE195, 0x7661, 0xE197, 0x7662, 0xE198,\t0x7667, 0xE19C, 0x7668, 0xE199, 0x7669, 0xE19A, 0x766A, 0xE19B,\r\n\t0x766C, 0xE19D, 0x7670, 0xE19E, 0x7672, 0xE19F, 0x7676, 0xE1A0,\t0x7678, 0xE1A1, 0x767A, 0x94AD, 0x767B, 0x936F, 0x767C, 0xE1A2,\r\n\t0x767D, 0x9492, 0x767E, 0x9553, 0x7680, 0xE1A3, 0x7682, 0xFB70,\t0x7683, 0xE1A4, 0x7684, 0x9349, 0x7686, 0x8A46, 0x7687, 0x8D63,\r\n\t0x7688, 0xE1A5, 0x768B, 0xE1A6, 0x768E, 0xE1A7, 0x7690, 0x8E48,\t0x7693, 0xE1A9, 0x7696, 0xE1A8, 0x7699, 0xE1AA, 0x769A, 0xE1AB,\r\n\t0x769B, 0xFB73, 0x769C, 0xFB71, 0x769E, 0xFB72, 0x76A6, 0xFB74,\t0x76AE, 0x94E7, 0x76B0, 0xE1AC, 0x76B4, 0xE1AD, 0x76B7, 0xEA89,\r\n\t0x76B8, 0xE1AE, 0x76B9, 0xE1AF, 0x76BA, 0xE1B0, 0x76BF, 0x8E4D,\t0x76C2, 0xE1B1, 0x76C3, 0x9475, 0x76C6, 0x967E, 0x76C8, 0x896D,\r\n\t0x76CA, 0x8976, 0x76CD, 0xE1B2, 0x76D2, 0xE1B4, 0x76D6, 0xE1B3,\t0x76D7, 0x9390, 0x76DB, 0x90B7, 0x76DC, 0x9F58, 0x76DE, 0xE1B5,\r\n\t0x76DF, 0x96BF, 0x76E1, 0xE1B6, 0x76E3, 0x8AC4, 0x76E4, 0x94D5,\t0x76E5, 0xE1B7, 0x76E7, 0xE1B8, 0x76EA, 0xE1B9, 0x76EE, 0x96DA,\r\n\t0x76F2, 0x96D3, 0x76F4, 0x92BC, 0x76F8, 0x918A, 0x76FB, 0xE1BB,\t0x76FE, 0x8F82, 0x7701, 0x8FC8, 0x7704, 0xE1BE, 0x7707, 0xE1BD,\r\n\t0x7708, 0xE1BC, 0x7709, 0x94FB, 0x770B, 0x8AC5, 0x770C, 0x8CA7,\t0x771B, 0xE1C4, 0x771E, 0xE1C1, 0x771F, 0x905E, 0x7720, 0x96B0,\r\n\t0x7724, 0xE1C0, 0x7725, 0xE1C2, 0x7726, 0xE1C3, 0x7729, 0xE1BF,\t0x7737, 0xE1C5, 0x7738, 0xE1C6, 0x773A, 0x92AD, 0x773C, 0x8AE1,\r\n\t0x7740, 0x9285, 0x7746, 0xFB76, 0x7747, 0xE1C7, 0x775A, 0xE1C8,\t0x775B, 0xE1CB, 0x7761, 0x9087, 0x7763, 0x93C2, 0x7765, 0xE1CC,\r\n\t0x7766, 0x9672, 0x7768, 0xE1C9, 0x776B, 0xE1CA, 0x7779, 0xE1CF,\t0x777E, 0xE1CE, 0x777F, 0xE1CD, 0x778B, 0xE1D1, 0x778E, 0xE1D0,\r\n\t0x7791, 0xE1D2, 0x779E, 0xE1D4, 0x77A0, 0xE1D3, 0x77A5, 0x95CB,\t0x77AC, 0x8F75, 0x77AD, 0x97C4, 0x77B0, 0xE1D5, 0x77B3, 0x93B5,\r\n\t0x77B6, 0xE1D6, 0x77B9, 0xE1D7, 0x77BB, 0xE1DB, 0x77BC, 0xE1D9,\t0x77BD, 0xE1DA, 0x77BF, 0xE1D8, 0x77C7, 0xE1DC, 0x77CD, 0xE1DD,\r\n\t0x77D7, 0xE1DE, 0x77DA, 0xE1DF, 0x77DB, 0x96B5, 0x77DC, 0xE1E0,\t0x77E2, 0x96EE, 0x77E3, 0xE1E1, 0x77E5, 0x926D, 0x77E7, 0x948A,\r\n\t0x77E9, 0x8BE9, 0x77ED, 0x925A, 0x77EE, 0xE1E2, 0x77EF, 0x8BB8,\t0x77F3, 0x90CE, 0x77FC, 0xE1E3, 0x7802, 0x8DBB, 0x780C, 0xE1E4,\r\n\t0x7812, 0xE1E5, 0x7814, 0x8CA4, 0x7815, 0x8DD3, 0x7820, 0xE1E7,\t0x7821, 0xFB78, 0x7825, 0x9375, 0x7826, 0x8DD4, 0x7827, 0x8B6D,\r\n\t0x7832, 0x9643, 0x7834, 0x946A, 0x783A, 0x9376, 0x783F, 0x8D7B,\t0x7845, 0xE1E9, 0x784E, 0xFB79, 0x785D, 0x8FC9, 0x7864, 0xFB7A,\r\n\t0x786B, 0x97B0, 0x786C, 0x8D64, 0x786F, 0x8CA5, 0x7872, 0x94A1,\t0x7874, 0xE1EB, 0x787A, 0xFB7B, 0x787C, 0xE1ED, 0x7881, 0x8CE9,\r\n\t0x7886, 0xE1EC, 0x7887, 0x92F4, 0x788C, 0xE1EF, 0x788D, 0x8A56,\t0x788E, 0xE1EA, 0x7891, 0x94E8, 0x7893, 0x894F, 0x7895, 0x8DEA,\r\n\t0x7897, 0x9871, 0x789A, 0xE1EE, 0x78A3, 0xE1F0, 0x78A7, 0x95C9,\t0x78A9, 0x90D7, 0x78AA, 0xE1F2, 0x78AF, 0xE1F3, 0x78B5, 0xE1F1,\r\n\t0x78BA, 0x8A6D, 0x78BC, 0xE1F9, 0x78BE, 0xE1F8, 0x78C1, 0x8EA5,\t0x78C5, 0xE1FA, 0x78C6, 0xE1F5, 0x78CA, 0xE1FB, 0x78CB, 0xE1F6,\r\n\t0x78D0, 0x94D6, 0x78D1, 0xE1F4, 0x78D4, 0xE1F7, 0x78DA, 0xE241,\t0x78E7, 0xE240, 0x78E8, 0x9681, 0x78EC, 0xE1FC, 0x78EF, 0x88E9,\r\n\t0x78F4, 0xE243, 0x78FD, 0xE242, 0x7901, 0x8FCA, 0x7907, 0xE244,\t0x790E, 0x9162, 0x7911, 0xE246, 0x7912, 0xE245, 0x7919, 0xE247,\r\n\t0x7926, 0xE1E6, 0x792A, 0xE1E8, 0x792B, 0xE249, 0x792C, 0xE248,\t0x7930, 0xFB7C, 0x793A, 0x8EA6, 0x793C, 0x97E7, 0x793E, 0x8ED0,\r\n\t0x7940, 0xE24A, 0x7941, 0x8C56, 0x7947, 0x8B5F, 0x7948, 0x8B46,\t0x7949, 0x8E83, 0x7950, 0x9753, 0x7953, 0xE250, 0x7955, 0xE24F,\r\n\t0x7956, 0x9163, 0x7957, 0xE24C, 0x795A, 0xE24E, 0x795D, 0x8F6A,\t0x795E, 0x905F, 0x795F, 0xE24D, 0x7960, 0xE24B, 0x7962, 0x9449,\r\n\t0x7965, 0x8FCB, 0x7968, 0x955B, 0x796D, 0x8DD5, 0x7977, 0x9398,\t0x797A, 0xE251, 0x797F, 0xE252, 0x7980, 0xE268, 0x7981, 0x8BD6,\r\n\t0x7984, 0x985C, 0x7985, 0x9154, 0x798A, 0xE253, 0x798D, 0x89D0,\t0x798E, 0x92F5, 0x798F, 0x959F, 0x7994, 0xFB81, 0x799B, 0xFB83,\r\n\t0x799D, 0xE254, 0x79A6, 0x8B9A, 0x79A7, 0xE255, 0x79AA, 0xE257,\t0x79AE, 0xE258, 0x79B0, 0x9448, 0x79B3, 0xE259, 0x79B9, 0xE25A,\r\n\t0x79BA, 0xE25B, 0x79BD, 0x8BD7, 0x79BE, 0x89D1, 0x79BF, 0x93C3,\t0x79C0, 0x8F47, 0x79C1, 0x8E84, 0x79C9, 0xE25C, 0x79CB, 0x8F48,\r\n\t0x79D1, 0x89C8, 0x79D2, 0x9562, 0x79D5, 0xE25D, 0x79D8, 0x94E9,\t0x79DF, 0x9164, 0x79E1, 0xE260, 0x79E3, 0xE261, 0x79E4, 0x9489,\r\n\t0x79E6, 0x9060, 0x79E7, 0xE25E, 0x79E9, 0x9281, 0x79EC, 0xE25F,\t0x79F0, 0x8FCC, 0x79FB, 0x88DA, 0x7A00, 0x8B48, 0x7A08, 0xE262,\r\n\t0x7A0B, 0x92F6, 0x7A0D, 0xE263, 0x7A0E, 0x90C5, 0x7A14, 0x96AB,\t0x7A17, 0x9542, 0x7A18, 0xE264, 0x7A19, 0xE265, 0x7A1A, 0x9274,\r\n\t0x7A1C, 0x97C5, 0x7A1F, 0xE267, 0x7A20, 0xE266, 0x7A2E, 0x8EED,\t0x7A31, 0xE269, 0x7A32, 0x88EE, 0x7A37, 0xE26C, 0x7A3B, 0xE26A,\r\n\t0x7A3C, 0x89D2, 0x7A3D, 0x8C6D, 0x7A3E, 0xE26B, 0x7A3F, 0x8D65,\t0x7A40, 0x8D92, 0x7A42, 0x95E4, 0x7A43, 0xE26D, 0x7A46, 0x9673,\r\n\t0x7A49, 0xE26F, 0x7A4D, 0x90CF, 0x7A4E, 0x896E, 0x7A4F, 0x89B8,\t0x7A50, 0x88AA, 0x7A57, 0xE26E, 0x7A61, 0xE270, 0x7A62, 0xE271,\r\n\t0x7A63, 0x8FF5, 0x7A69, 0xE272, 0x7A6B, 0x8A6E, 0x7A70, 0xE274,\t0x7A74, 0x8C8A, 0x7A76, 0x8B86, 0x7A79, 0xE275, 0x7A7A, 0x8BF3,\r\n\t0x7A7D, 0xE276, 0x7A7F, 0x90FA, 0x7A81, 0x93CB, 0x7A83, 0x90DE,\t0x7A84, 0x8DF3, 0x7A88, 0xE277, 0x7A92, 0x9282, 0x7A93, 0x918B,\r\n\t0x7A95, 0xE279, 0x7A96, 0xE27B, 0x7A97, 0xE278, 0x7A98, 0xE27A,\t0x7A9F, 0x8C41, 0x7AA9, 0xE27C, 0x7AAA, 0x8C45, 0x7AAE, 0x8B87,\r\n\t0x7AAF, 0x9771, 0x7AB0, 0xE27E, 0x7AB6, 0xE280, 0x7ABA, 0x894D,\t0x7ABF, 0xE283, 0x7AC3, 0x8A96, 0x7AC4, 0xE282, 0x7AC5, 0xE281,\r\n\t0x7AC7, 0xE285, 0x7AC8, 0xE27D, 0x7ACA, 0xE286, 0x7ACB, 0x97A7,\t0x7ACD, 0xE287, 0x7ACF, 0xE288, 0x7AD1, 0xFB84, 0x7AD2, 0x9AF2,\r\n\t0x7AD3, 0xE28A, 0x7AD5, 0xE289, 0x7AD9, 0xE28B, 0x7ADA, 0xE28C,\t0x7ADC, 0x97B3, 0x7ADD, 0xE28D, 0x7ADF, 0xE8ED, 0x7AE0, 0x8FCD,\r\n\t0x7AE1, 0xE28E, 0x7AE2, 0xE28F, 0x7AE3, 0x8F76, 0x7AE5, 0x93B6,\t0x7AE6, 0xE290, 0x7AE7, 0xFB85, 0x7AEA, 0x9247, 0x7AEB, 0xFB87,\r\n\t0x7AED, 0xE291, 0x7AEF, 0x925B, 0x7AF0, 0xE292, 0x7AF6, 0x8BA3,\t0x7AF8, 0x995E, 0x7AF9, 0x927C, 0x7AFA, 0x8EB1, 0x7AFF, 0x8AC6,\r\n\t0x7B02, 0xE293, 0x7B04, 0xE2A0, 0x7B06, 0xE296, 0x7B08, 0x8B88,\t0x7B0A, 0xE295, 0x7B0B, 0xE2A2, 0x7B0F, 0xE294, 0x7B11, 0x8FCE,\r\n\t0x7B18, 0xE298, 0x7B19, 0xE299, 0x7B1B, 0x934A, 0x7B1E, 0xE29A,\t0x7B20, 0x8A7D, 0x7B25, 0x9079, 0x7B26, 0x9584, 0x7B28, 0xE29C,\r\n\t0x7B2C, 0x91E6, 0x7B33, 0xE297, 0x7B35, 0xE29B, 0x7B36, 0xE29D,\t0x7B39, 0x8DF9, 0x7B45, 0xE2A4, 0x7B46, 0x954D, 0x7B48, 0x94A4,\r\n\t0x7B49, 0x9399, 0x7B4B, 0x8BD8, 0x7B4C, 0xE2A3, 0x7B4D, 0xE2A1,\t0x7B4F, 0x94B3, 0x7B50, 0xE29E, 0x7B51, 0x927D, 0x7B52, 0x939B,\r\n\t0x7B54, 0x939A, 0x7B56, 0x8DF4, 0x7B5D, 0xE2B6, 0x7B65, 0xE2A6,\t0x7B67, 0xE2A8, 0x7B6C, 0xE2AB, 0x7B6E, 0xE2AC, 0x7B70, 0xE2A9,\r\n\t0x7B71, 0xE2AA, 0x7B74, 0xE2A7, 0x7B75, 0xE2A5, 0x7B7A, 0xE29F,\t0x7B86, 0x95CD, 0x7B87, 0x89D3, 0x7B8B, 0xE2B3, 0x7B8D, 0xE2B0,\r\n\t0x7B8F, 0xE2B5, 0x7B92, 0xE2B4, 0x7B94, 0x9493, 0x7B95, 0x96A5,\t0x7B97, 0x8E5A, 0x7B98, 0xE2AE, 0x7B99, 0xE2B7, 0x7B9A, 0xE2B2,\r\n\t0x7B9C, 0xE2B1, 0x7B9D, 0xE2AD, 0x7B9E, 0xFB88, 0x7B9F, 0xE2AF,\t0x7BA1, 0x8AC7, 0x7BAA, 0x925C, 0x7BAD, 0x90FB, 0x7BB1, 0x94A0,\r\n\t0x7BB4, 0xE2BC, 0x7BB8, 0x94A2, 0x7BC0, 0x90DF, 0x7BC1, 0xE2B9,\t0x7BC4, 0x94CD, 0x7BC6, 0xE2BD, 0x7BC7, 0x95D1, 0x7BC9, 0x927A,\r\n\t0x7BCB, 0xE2B8, 0x7BCC, 0xE2BA, 0x7BCF, 0xE2BB, 0x7BDD, 0xE2BE,\t0x7BE0, 0x8EC2, 0x7BE4, 0x93C4, 0x7BE5, 0xE2C3, 0x7BE6, 0xE2C2,\r\n\t0x7BE9, 0xE2BF, 0x7BED, 0x9855, 0x7BF3, 0xE2C8, 0x7BF6, 0xE2CC,\t0x7BF7, 0xE2C9, 0x7C00, 0xE2C5, 0x7C07, 0xE2C6, 0x7C0D, 0xE2CB,\r\n\t0x7C11, 0xE2C0, 0x7C12, 0x99D3, 0x7C13, 0xE2C7, 0x7C14, 0xE2C1,\t0x7C17, 0xE2CA, 0x7C1F, 0xE2D0, 0x7C21, 0x8AC8, 0x7C23, 0xE2CD,\r\n\t0x7C27, 0xE2CE, 0x7C2A, 0xE2CF, 0x7C2B, 0xE2D2, 0x7C37, 0xE2D1,\t0x7C38, 0x94F4, 0x7C3D, 0xE2D3, 0x7C3E, 0x97FA, 0x7C3F, 0x95EB,\r\n\t0x7C40, 0xE2D8, 0x7C43, 0xE2D5, 0x7C4C, 0xE2D4, 0x7C4D, 0x90D0,\t0x7C4F, 0xE2D7, 0x7C50, 0xE2D9, 0x7C54, 0xE2D6, 0x7C56, 0xE2DD,\r\n\t0x7C58, 0xE2DA, 0x7C5F, 0xE2DB, 0x7C60, 0xE2C4, 0x7C64, 0xE2DC,\t0x7C65, 0xE2DE, 0x7C6C, 0xE2DF, 0x7C73, 0x95C4, 0x7C75, 0xE2E0,\r\n\t0x7C7E, 0x96E0, 0x7C81, 0x8BCC, 0x7C82, 0x8C48, 0x7C83, 0xE2E1,\t0x7C89, 0x95B2, 0x7C8B, 0x9088, 0x7C8D, 0x96AE, 0x7C90, 0xE2E2,\r\n\t0x7C92, 0x97B1, 0x7C95, 0x9494, 0x7C97, 0x9165, 0x7C98, 0x9453,\t0x7C9B, 0x8F6C, 0x7C9F, 0x88BE, 0x7CA1, 0xE2E7, 0x7CA2, 0xE2E5,\r\n\t0x7CA4, 0xE2E3, 0x7CA5, 0x8A9F, 0x7CA7, 0x8FCF, 0x7CA8, 0xE2E8,\t0x7CAB, 0xE2E6, 0x7CAD, 0xE2E4, 0x7CAE, 0xE2EC, 0x7CB1, 0xE2EB,\r\n\t0x7CB2, 0xE2EA, 0x7CB3, 0xE2E9, 0x7CB9, 0xE2ED, 0x7CBD, 0xE2EE,\t0x7CBE, 0x90B8, 0x7CC0, 0xE2EF, 0x7CC2, 0xE2F1, 0x7CC5, 0xE2F0,\r\n\t0x7CCA, 0x8CD0, 0x7CCE, 0x9157, 0x7CD2, 0xE2F3, 0x7CD6, 0x939C,\t0x7CD8, 0xE2F2, 0x7CDC, 0xE2F4, 0x7CDE, 0x95B3, 0x7CDF, 0x918C,\r\n\t0x7CE0, 0x8D66, 0x7CE2, 0xE2F5, 0x7CE7, 0x97C6, 0x7CEF, 0xE2F7,\t0x7CF2, 0xE2F8, 0x7CF4, 0xE2F9, 0x7CF6, 0xE2FA, 0x7CF8, 0x8E85,\r\n\t0x7CFA, 0xE2FB, 0x7CFB, 0x8C6E, 0x7CFE, 0x8B8A, 0x7D00, 0x8B49,\t0x7D02, 0xE340, 0x7D04, 0x96F1, 0x7D05, 0x8D67, 0x7D06, 0xE2FC,\r\n\t0x7D0A, 0xE343, 0x7D0B, 0x96E4, 0x7D0D, 0x945B, 0x7D10, 0x9552,\t0x7D14, 0x8F83, 0x7D15, 0xE342, 0x7D17, 0x8ED1, 0x7D18, 0x8D68,\r\n\t0x7D19, 0x8E86, 0x7D1A, 0x8B89, 0x7D1B, 0x95B4, 0x7D1C, 0xE341,\t0x7D20, 0x9166, 0x7D21, 0x9661, 0x7D22, 0x8DF5, 0x7D2B, 0x8E87,\r\n\t0x7D2C, 0x92DB, 0x7D2E, 0xE346, 0x7D2F, 0x97DD, 0x7D30, 0x8DD7,\t0x7D32, 0xE347, 0x7D33, 0x9061, 0x7D35, 0xE349, 0x7D39, 0x8FD0,\r\n\t0x7D3A, 0x8DAE, 0x7D3F, 0xE348, 0x7D42, 0x8F49, 0x7D43, 0x8CBC,\t0x7D44, 0x9167, 0x7D45, 0xE344, 0x7D46, 0xE34A, 0x7D48, 0xFB8A,\r\n\t0x7D4B, 0xE345, 0x7D4C, 0x8C6F, 0x7D4E, 0xE34D, 0x7D4F, 0xE351,\t0x7D50, 0x8C8B, 0x7D56, 0xE34C, 0x7D5B, 0xE355, 0x7D5C, 0xFB8B,\r\n\t0x7D5E, 0x8D69, 0x7D61, 0x978D, 0x7D62, 0x88BA, 0x7D63, 0xE352,\t0x7D66, 0x8B8B, 0x7D68, 0xE34F, 0x7D6E, 0xE350, 0x7D71, 0x939D,\r\n\t0x7D72, 0xE34E, 0x7D73, 0xE34B, 0x7D75, 0x8A47, 0x7D76, 0x90E2,\t0x7D79, 0x8CA6, 0x7D7D, 0xE357, 0x7D89, 0xE354, 0x7D8F, 0xE356,\r\n\t0x7D93, 0xE353, 0x7D99, 0x8C70, 0x7D9A, 0x91B1, 0x7D9B, 0xE358,\t0x7D9C, 0x918E, 0x7D9F, 0xE365, 0x7DA0, 0xFB8D, 0x7DA2, 0xE361,\r\n\t0x7DA3, 0xE35B, 0x7DAB, 0xE35F, 0x7DAC, 0x8EF8, 0x7DAD, 0x88DB,\t0x7DAE, 0xE35A, 0x7DAF, 0xE362, 0x7DB0, 0xE366, 0x7DB1, 0x8D6A,\r\n\t0x7DB2, 0x96D4, 0x7DB4, 0x92D4, 0x7DB5, 0xE35C, 0x7DB7, 0xFB8C,\t0x7DB8, 0xE364, 0x7DBA, 0xE359, 0x7DBB, 0x925D, 0x7DBD, 0xE35E,\r\n\t0x7DBE, 0x88BB, 0x7DBF, 0x96C8, 0x7DC7, 0xE35D, 0x7DCA, 0x8BD9,\t0x7DCB, 0x94EA, 0x7DCF, 0x918D, 0x7DD1, 0x97CE, 0x7DD2, 0x8F8F,\r\n\t0x7DD5, 0xE38E, 0x7DD6, 0xFB8E, 0x7DD8, 0xE367, 0x7DDA, 0x90FC,\t0x7DDC, 0xE363, 0x7DDD, 0xE368, 0x7DDE, 0xE36A, 0x7DE0, 0x92F7,\r\n\t0x7DE1, 0xE36D, 0x7DE4, 0xE369, 0x7DE8, 0x95D2, 0x7DE9, 0x8AC9,\t0x7DEC, 0x96C9, 0x7DEF, 0x88DC, 0x7DF2, 0xE36C, 0x7DF4, 0x97FB,\r\n\t0x7DFB, 0xE36B, 0x7E01, 0x898F, 0x7E04, 0x93EA, 0x7E05, 0xE36E,\t0x7E09, 0xE375, 0x7E0A, 0xE36F, 0x7E0B, 0xE376, 0x7E12, 0xE372,\r\n\t0x7E1B, 0x949B, 0x7E1E, 0x8EC8, 0x7E1F, 0xE374, 0x7E21, 0xE371,\t0x7E22, 0xE377, 0x7E23, 0xE370, 0x7E26, 0x8F63, 0x7E2B, 0x9644,\r\n\t0x7E2E, 0x8F6B, 0x7E31, 0xE373, 0x7E32, 0xE380, 0x7E35, 0xE37B,\t0x7E37, 0xE37E, 0x7E39, 0xE37C, 0x7E3A, 0xE381, 0x7E3B, 0xE37A,\r\n\t0x7E3D, 0xE360, 0x7E3E, 0x90D1, 0x7E41, 0x94C9, 0x7E43, 0xE37D,\t0x7E46, 0xE378, 0x7E4A, 0x9140, 0x7E4B, 0x8C71, 0x7E4D, 0x8F4A,\r\n\t0x7E52, 0xFB8F, 0x7E54, 0x9044, 0x7E55, 0x9155, 0x7E56, 0xE384,\t0x7E59, 0xE386, 0x7E5A, 0xE387, 0x7E5D, 0xE383, 0x7E5E, 0xE385,\r\n\t0x7E66, 0xE379, 0x7E67, 0xE382, 0x7E69, 0xE38A, 0x7E6A, 0xE389,\t0x7E6D, 0x969A, 0x7E70, 0x8C4A, 0x7E79, 0xE388, 0x7E7B, 0xE38C,\r\n\t0x7E7C, 0xE38B, 0x7E7D, 0xE38F, 0x7E7F, 0xE391, 0x7E82, 0x8E5B,\t0x7E83, 0xE38D, 0x7E88, 0xE392, 0x7E89, 0xE393, 0x7E8A, 0xFA5C,\r\n\t0x7E8C, 0xE394, 0x7E8E, 0xE39A, 0x7E8F, 0x935A, 0x7E90, 0xE396,\t0x7E92, 0xE395, 0x7E93, 0xE397, 0x7E94, 0xE398, 0x7E96, 0xE399,\r\n\t0x7E9B, 0xE39B, 0x7E9C, 0xE39C, 0x7F36, 0x8ACA, 0x7F38, 0xE39D,\t0x7F3A, 0xE39E, 0x7F45, 0xE39F, 0x7F47, 0xFB90, 0x7F4C, 0xE3A0,\r\n\t0x7F4D, 0xE3A1, 0x7F4E, 0xE3A2, 0x7F50, 0xE3A3, 0x7F51, 0xE3A4,\t0x7F54, 0xE3A6, 0x7F55, 0xE3A5, 0x7F58, 0xE3A7, 0x7F5F, 0xE3A8,\r\n\t0x7F60, 0xE3A9, 0x7F67, 0xE3AC, 0x7F68, 0xE3AA, 0x7F69, 0xE3AB,\t0x7F6A, 0x8DDF, 0x7F6B, 0x8C72, 0x7F6E, 0x9275, 0x7F70, 0x94B1,\r\n\t0x7F72, 0x8F90, 0x7F75, 0x946C, 0x7F77, 0x94EB, 0x7F78, 0xE3AD,\t0x7F79, 0x9CEB, 0x7F82, 0xE3AE, 0x7F83, 0xE3B0, 0x7F85, 0x9785,\r\n\t0x7F86, 0xE3AF, 0x7F87, 0xE3B2, 0x7F88, 0xE3B1, 0x7F8A, 0x9772,\t0x7F8C, 0xE3B3, 0x7F8E, 0x94FC, 0x7F94, 0xE3B4, 0x7F9A, 0xE3B7,\r\n\t0x7F9D, 0xE3B6, 0x7F9E, 0xE3B5, 0x7FA1, 0xFB91, 0x7FA3, 0xE3B8,\t0x7FA4, 0x8C51, 0x7FA8, 0x9141, 0x7FA9, 0x8B60, 0x7FAE, 0xE3BC,\r\n\t0x7FAF, 0xE3B9, 0x7FB2, 0xE3BA, 0x7FB6, 0xE3BD, 0x7FB8, 0xE3BE,\t0x7FB9, 0xE3BB, 0x7FBD, 0x8948, 0x7FC1, 0x89A5, 0x7FC5, 0xE3C0,\r\n\t0x7FC6, 0xE3C1, 0x7FCA, 0xE3C2, 0x7FCC, 0x9782, 0x7FD2, 0x8F4B,\t0x7FD4, 0xE3C4, 0x7FD5, 0xE3C3, 0x7FE0, 0x9089, 0x7FE1, 0xE3C5,\r\n\t0x7FE6, 0xE3C6, 0x7FE9, 0xE3C7, 0x7FEB, 0x8AE3, 0x7FF0, 0x8ACB,\t0x7FF3, 0xE3C8, 0x7FF9, 0xE3C9, 0x7FFB, 0x967C, 0x7FFC, 0x9783,\r\n\t0x8000, 0x9773, 0x8001, 0x9856, 0x8003, 0x8D6C, 0x8004, 0xE3CC,\t0x8005, 0x8ED2, 0x8006, 0xE3CB, 0x800B, 0xE3CD, 0x800C, 0x8EA7,\r\n\t0x8010, 0x91CF, 0x8012, 0xE3CE, 0x8015, 0x8D6B, 0x8017, 0x96D5,\t0x8018, 0xE3CF, 0x8019, 0xE3D0, 0x801C, 0xE3D1, 0x8021, 0xE3D2,\r\n\t0x8028, 0xE3D3, 0x8033, 0x8EA8, 0x8036, 0x96EB, 0x803B, 0xE3D5,\t0x803D, 0x925E, 0x803F, 0xE3D4, 0x8046, 0xE3D7, 0x804A, 0xE3D6,\r\n\t0x8052, 0xE3D8, 0x8056, 0x90B9, 0x8058, 0xE3D9, 0x805A, 0xE3DA,\t0x805E, 0x95B7, 0x805F, 0xE3DB, 0x8061, 0x918F, 0x8062, 0xE3DC,\r\n\t0x8068, 0xE3DD, 0x806F, 0x97FC, 0x8070, 0xE3E0, 0x8072, 0xE3DF,\t0x8073, 0xE3DE, 0x8074, 0x92AE, 0x8076, 0xE3E1, 0x8077, 0x9045,\r\n\t0x8079, 0xE3E2, 0x807D, 0xE3E3, 0x807E, 0x9857, 0x807F, 0xE3E4,\t0x8084, 0xE3E5, 0x8085, 0xE3E7, 0x8086, 0xE3E6, 0x8087, 0x94A3,\r\n\t0x8089, 0x93F7, 0x808B, 0x985D, 0x808C, 0x94A7, 0x8093, 0xE3E9,\t0x8096, 0x8FD1, 0x8098, 0x9549, 0x809A, 0xE3EA, 0x809B, 0xE3E8,\r\n\t0x809D, 0x8ACC, 0x80A1, 0x8CD2, 0x80A2, 0x8E88, 0x80A5, 0x94EC,\t0x80A9, 0x8CA8, 0x80AA, 0x9662, 0x80AC, 0xE3ED, 0x80AD, 0xE3EB,\r\n\t0x80AF, 0x8D6D, 0x80B1, 0x8D6E, 0x80B2, 0x88E7, 0x80B4, 0x8DE6,\t0x80BA, 0x9478, 0x80C3, 0x88DD, 0x80C4, 0xE3F2, 0x80C6, 0x925F,\r\n\t0x80CC, 0x9477, 0x80CE, 0x91D9, 0x80D6, 0xE3F4, 0x80D9, 0xE3F0,\t0x80DA, 0xE3F3, 0x80DB, 0xE3EE, 0x80DD, 0xE3F1, 0x80DE, 0x9645,\r\n\t0x80E1, 0x8CD3, 0x80E4, 0x88FB, 0x80E5, 0xE3EF, 0x80EF, 0xE3F6,\t0x80F1, 0xE3F7, 0x80F4, 0x93B7, 0x80F8, 0x8BB9, 0x80FC, 0xE445,\r\n\t0x80FD, 0x945C, 0x8102, 0x8E89, 0x8105, 0x8BBA, 0x8106, 0x90C6,\t0x8107, 0x9865, 0x8108, 0x96AC, 0x8109, 0xE3F5, 0x810A, 0x90D2,\r\n\t0x811A, 0x8B72, 0x811B, 0xE3F8, 0x8123, 0xE3FA, 0x8129, 0xE3F9,\t0x812F, 0xE3FB, 0x8131, 0x9245, 0x8133, 0x945D, 0x8139, 0x92AF,\r\n\t0x813E, 0xE442, 0x8146, 0xE441, 0x814B, 0xE3FC, 0x814E, 0x9074,\t0x8150, 0x9585, 0x8151, 0xE444, 0x8153, 0xE443, 0x8154, 0x8D6F,\r\n\t0x8155, 0x9872, 0x815F, 0xE454, 0x8165, 0xE448, 0x8166, 0xE449,\t0x816B, 0x8EEE, 0x816E, 0xE447, 0x8170, 0x8D98, 0x8171, 0xE446,\r\n\t0x8174, 0xE44A, 0x8178, 0x92B0, 0x8179, 0x95A0, 0x817A, 0x9142,\t0x817F, 0x91DA, 0x8180, 0xE44E, 0x8182, 0xE44F, 0x8183, 0xE44B,\r\n\t0x8188, 0xE44C, 0x818A, 0xE44D, 0x818F, 0x8D70, 0x8193, 0xE455,\t0x8195, 0xE451, 0x819A, 0x9586, 0x819C, 0x968C, 0x819D, 0x9547,\r\n\t0x81A0, 0xE450, 0x81A3, 0xE453, 0x81A4, 0xE452, 0x81A8, 0x9663,\t0x81A9, 0xE456, 0x81B0, 0xE457, 0x81B3, 0x9156, 0x81B5, 0xE458,\r\n\t0x81B8, 0xE45A, 0x81BA, 0xE45E, 0x81BD, 0xE45B, 0x81BE, 0xE459,\t0x81BF, 0x945E, 0x81C0, 0xE45C, 0x81C2, 0xE45D, 0x81C6, 0x89B0,\r\n\t0x81C8, 0xE464, 0x81C9, 0xE45F, 0x81CD, 0xE460, 0x81D1, 0xE461,\t0x81D3, 0x919F, 0x81D8, 0xE463, 0x81D9, 0xE462, 0x81DA, 0xE465,\r\n\t0x81DF, 0xE466, 0x81E0, 0xE467, 0x81E3, 0x9062, 0x81E5, 0x89E7,\t0x81E7, 0xE468, 0x81E8, 0x97D5, 0x81EA, 0x8EA9, 0x81ED, 0x8F4C,\r\n\t0x81F3, 0x8E8A, 0x81F4, 0x9276, 0x81FA, 0xE469, 0x81FB, 0xE46A,\t0x81FC, 0x8950, 0x81FE, 0xE46B, 0x8201, 0xE46C, 0x8202, 0xE46D,\r\n\t0x8205, 0xE46E, 0x8207, 0xE46F, 0x8208, 0x8BBB, 0x8209, 0x9DA8,\t0x820A, 0xE470, 0x820C, 0x90E3, 0x820D, 0xE471, 0x820E, 0x8EC9,\r\n\t0x8210, 0xE472, 0x8212, 0x98AE, 0x8216, 0xE473, 0x8217, 0x95DC,\t0x8218, 0x8ADA, 0x821B, 0x9143, 0x821C, 0x8F77, 0x821E, 0x9591,\r\n\t0x821F, 0x8F4D, 0x8229, 0xE474, 0x822A, 0x8D71, 0x822B, 0xE475,\t0x822C, 0x94CA, 0x822E, 0xE484, 0x8233, 0xE477, 0x8235, 0x91C7,\r\n\t0x8236, 0x9495, 0x8237, 0x8CBD, 0x8238, 0xE476, 0x8239, 0x9144,\t0x8240, 0xE478, 0x8247, 0x92F8, 0x8258, 0xE47A, 0x8259, 0xE479,\r\n\t0x825A, 0xE47C, 0x825D, 0xE47B, 0x825F, 0xE47D, 0x8262, 0xE480,\t0x8264, 0xE47E, 0x8266, 0x8ACD, 0x8268, 0xE481, 0x826A, 0xE482,\r\n\t0x826B, 0xE483, 0x826E, 0x8DAF, 0x826F, 0x97C7, 0x8271, 0xE485,\t0x8272, 0x9046, 0x8276, 0x8990, 0x8277, 0xE486, 0x8278, 0xE487,\r\n\t0x827E, 0xE488, 0x828B, 0x88F0, 0x828D, 0xE489, 0x8292, 0xE48A,\t0x8299, 0x9587, 0x829D, 0x8EC5, 0x829F, 0xE48C, 0x82A5, 0x8A48,\r\n\t0x82A6, 0x88B0, 0x82AB, 0xE48B, 0x82AC, 0xE48E, 0x82AD, 0x946D,\t0x82AF, 0x9063, 0x82B1, 0x89D4, 0x82B3, 0x9646, 0x82B8, 0x8C7C,\r\n\t0x82B9, 0x8BDA, 0x82BB, 0xE48D, 0x82BD, 0x89E8, 0x82C5, 0x8AA1,\t0x82D1, 0x8991, 0x82D2, 0xE492, 0x82D3, 0x97E8, 0x82D4, 0x91DB,\r\n\t0x82D7, 0x9563, 0x82D9, 0xE49E, 0x82DB, 0x89D5, 0x82DC, 0xE49C,\t0x82DE, 0xE49A, 0x82DF, 0xE491, 0x82E1, 0xE48F, 0x82E3, 0xE490,\r\n\t0x82E5, 0x8EE1, 0x82E6, 0x8BEA, 0x82E7, 0x9297, 0x82EB, 0x93CF,\t0x82F1, 0x8970, 0x82F3, 0xE494, 0x82F4, 0xE493, 0x82F9, 0xE499,\r\n\t0x82FA, 0xE495, 0x82FB, 0xE498, 0x8301, 0xFB93, 0x8302, 0x96CE,\t0x8303, 0xE497, 0x8304, 0x89D6, 0x8305, 0x8A9D, 0x8306, 0xE49B,\r\n\t0x8309, 0xE49D, 0x830E, 0x8C73, 0x8316, 0xE4A1, 0x8317, 0xE4AA,\t0x8318, 0xE4AB, 0x831C, 0x88A9, 0x8323, 0xE4B2, 0x8328, 0x88EF,\r\n\t0x832B, 0xE4A9, 0x832F, 0xE4A8, 0x8331, 0xE4A3, 0x8332, 0xE4A2,\t0x8334, 0xE4A0, 0x8335, 0xE49F, 0x8336, 0x9283, 0x8338, 0x91F9,\r\n\t0x8339, 0xE4A5, 0x8340, 0xE4A4, 0x8345, 0xE4A7, 0x8349, 0x9190,\t0x834A, 0x8C74, 0x834F, 0x8960, 0x8350, 0xE4A6, 0x8352, 0x8D72,\r\n\t0x8358, 0x9191, 0x8362, 0xFB94, 0x8373, 0xE4B8, 0x8375, 0xE4B9,\t0x8377, 0x89D7, 0x837B, 0x89AC, 0x837C, 0xE4B6, 0x837F, 0xFB95,\r\n\t0x8385, 0xE4AC, 0x8387, 0xE4B4, 0x8389, 0xE4BB, 0x838A, 0xE4B5,\t0x838E, 0xE4B3, 0x8393, 0xE496, 0x8396, 0xE4B1, 0x839A, 0xE4AD,\r\n\t0x839E, 0x8ACE, 0x839F, 0xE4AF, 0x83A0, 0xE4BA, 0x83A2, 0xE4B0,\t0x83A8, 0xE4BC, 0x83AA, 0xE4AE, 0x83AB, 0x949C, 0x83B1, 0x9789,\r\n\t0x83B5, 0xE4B7, 0x83BD, 0xE4CD, 0x83C1, 0xE4C5, 0x83C5, 0x909B,\t0x83C7, 0xFB96, 0x83CA, 0x8B65, 0x83CC, 0x8BDB, 0x83CE, 0xE4C0,\r\n\t0x83D3, 0x89D9, 0x83D6, 0x8FD2, 0x83D8, 0xE4C3, 0x83DC, 0x8DD8,\t0x83DF, 0x9370, 0x83E0, 0xE4C8, 0x83E9, 0x95EC, 0x83EB, 0xE4BF,\r\n\t0x83EF, 0x89D8, 0x83F0, 0x8CD4, 0x83F1, 0x9548, 0x83F2, 0xE4C9,\t0x83F4, 0xE4BD, 0x83F6, 0xFB97, 0x83F7, 0xE4C6, 0x83FB, 0xE4D0,\r\n\t0x83FD, 0xE4C1, 0x8403, 0xE4C2, 0x8404, 0x93B8, 0x8407, 0xE4C7,\t0x840B, 0xE4C4, 0x840C, 0x9647, 0x840D, 0xE4CA, 0x840E, 0x88DE,\r\n\t0x8413, 0xE4BE, 0x8420, 0xE4CC, 0x8422, 0xE4CB, 0x8429, 0x948B,\t0x842A, 0xE4D2, 0x842C, 0xE4DD, 0x8431, 0x8A9E, 0x8435, 0xE4E0,\r\n\t0x8438, 0xE4CE, 0x843C, 0xE4D3, 0x843D, 0x978E, 0x8446, 0xE4DC,\t0x8448, 0xFB98, 0x8449, 0x9774, 0x844E, 0x97A8, 0x8457, 0x9298,\r\n\t0x845B, 0x8A8B, 0x8461, 0x9592, 0x8462, 0xE4E2, 0x8463, 0x939F,\t0x8466, 0x88AF, 0x8469, 0xE4DB, 0x846B, 0xE4D7, 0x846C, 0x9192,\r\n\t0x846D, 0xE4D1, 0x846E, 0xE4D9, 0x846F, 0xE4DE, 0x8471, 0x944B,\t0x8475, 0x88A8, 0x8477, 0xE4D6, 0x8479, 0xE4DF, 0x847A, 0x9598,\r\n\t0x8482, 0xE4DA, 0x8484, 0xE4D5, 0x848B, 0x8FD3, 0x8490, 0x8F4E,\t0x8494, 0x8EAA, 0x8499, 0x96D6, 0x849C, 0x9566, 0x849F, 0xE4E5,\r\n\t0x84A1, 0xE4EE, 0x84AD, 0xE4D8, 0x84B2, 0x8A97, 0x84B4, 0xFB99,\t0x84B8, 0x8FF6, 0x84B9, 0xE4E3, 0x84BB, 0xE4E8, 0x84BC, 0x9193,\r\n\t0x84BF, 0xE4E4, 0x84C1, 0xE4EB, 0x84C4, 0x927E, 0x84C6, 0xE4EC,\t0x84C9, 0x9775, 0x84CA, 0xE4E1, 0x84CB, 0x8A57, 0x84CD, 0xE4E7,\r\n\t0x84D0, 0xE4EA, 0x84D1, 0x96AA, 0x84D6, 0xE4ED, 0x84D9, 0xE4E6,\t0x84DA, 0xE4E9, 0x84DC, 0xFA60, 0x84EC, 0x9648, 0x84EE, 0x9840,\r\n\t0x84F4, 0xE4F1, 0x84FC, 0xE4F8, 0x84FF, 0xE4F0, 0x8500, 0x8EC1,\t0x8506, 0xE4CF, 0x8511, 0x95CC, 0x8513, 0x96A0, 0x8514, 0xE4F7,\r\n\t0x8515, 0xE4F6, 0x8517, 0xE4F2, 0x8518, 0xE4F3, 0x851A, 0x8955,\t0x851F, 0xE4F5, 0x8521, 0xE4EF, 0x8526, 0x92D3, 0x852C, 0xE4F4,\r\n\t0x852D, 0x88FC, 0x8535, 0x91A0, 0x853D, 0x95C1, 0x8540, 0xE4F9,\t0x8541, 0xE540, 0x8543, 0x94D7, 0x8548, 0xE4FC, 0x8549, 0x8FD4,\r\n\t0x854A, 0x8EC7, 0x854B, 0xE542, 0x854E, 0x8BBC, 0x8553, 0xFB9A,\t0x8555, 0xE543, 0x8557, 0x9599, 0x8558, 0xE4FB, 0x8559, 0xFB9B,\r\n\t0x855A, 0xE4D4, 0x8563, 0xE4FA, 0x8568, 0x986E, 0x8569, 0x93A0,\t0x856A, 0x9593, 0x856B, 0xFB9C, 0x856D, 0xE54A, 0x8577, 0xE550,\r\n\t0x857E, 0xE551, 0x8580, 0xE544, 0x8584, 0x9496, 0x8587, 0xE54E,\t0x8588, 0xE546, 0x858A, 0xE548, 0x8590, 0xE552, 0x8591, 0xE547,\r\n\t0x8594, 0xE54B, 0x8597, 0x8992, 0x8599, 0x93E3, 0x859B, 0xE54C,\t0x859C, 0xE54F, 0x85A4, 0xE545, 0x85A6, 0x9145, 0x85A8, 0xE549,\r\n\t0x85A9, 0x8E46, 0x85AA, 0x9064, 0x85AB, 0x8C4F, 0x85AC, 0x96F2,\t0x85AE, 0x96F7, 0x85AF, 0x8F92, 0x85B0, 0xFB9E, 0x85B9, 0xE556,\r\n\t0x85BA, 0xE554, 0x85C1, 0x986D, 0x85C9, 0xE553, 0x85CD, 0x9795,\t0x85CF, 0xE555, 0x85D0, 0xE557, 0x85D5, 0xE558, 0x85DC, 0xE55B,\r\n\t0x85DD, 0xE559, 0x85E4, 0x93A1, 0x85E5, 0xE55A, 0x85E9, 0x94CB,\t0x85EA, 0xE54D, 0x85F7, 0x8F93, 0x85F9, 0xE55C, 0x85FA, 0xE561,\r\n\t0x85FB, 0x9194, 0x85FE, 0xE560, 0x8602, 0xE541, 0x8606, 0xE562,\t0x8607, 0x9168, 0x860A, 0xE55D, 0x860B, 0xE55F, 0x8613, 0xE55E,\r\n\t0x8616, 0x9F50, 0x8617, 0x9F41, 0x861A, 0xE564, 0x8622, 0xE563,\t0x862D, 0x9796, 0x862F, 0xE1BA, 0x8630, 0xE565, 0x863F, 0xE566,\r\n\t0x864D, 0xE567, 0x864E, 0x8CD5, 0x8650, 0x8B73, 0x8654, 0xE569,\t0x8655, 0x997C, 0x865A, 0x8B95, 0x865C, 0x97B8, 0x865E, 0x8BF1,\r\n\t0x865F, 0xE56A, 0x8667, 0xE56B, 0x866B, 0x928E, 0x8671, 0xE56C,\t0x8679, 0x93F8, 0x867B, 0x88B8, 0x868A, 0x89E1, 0x868B, 0xE571,\r\n\t0x868C, 0xE572, 0x8693, 0xE56D, 0x8695, 0x8E5C, 0x86A3, 0xE56E,\t0x86A4, 0x9461, 0x86A9, 0xE56F, 0x86AA, 0xE570, 0x86AB, 0xE57A,\r\n\t0x86AF, 0xE574, 0x86B0, 0xE577, 0x86B6, 0xE573, 0x86C4, 0xE575,\t0x86C6, 0xE576, 0x86C7, 0x8ED6, 0x86C9, 0xE578, 0x86CB, 0x9260,\r\n\t0x86CD, 0x8C75, 0x86CE, 0x8A61, 0x86D4, 0xE57B, 0x86D9, 0x8A5E,\t0x86DB, 0xE581, 0x86DE, 0xE57C, 0x86DF, 0xE580, 0x86E4, 0x94B8,\r\n\t0x86E9, 0xE57D, 0x86EC, 0xE57E, 0x86ED, 0x9567, 0x86EE, 0x94D8,\t0x86EF, 0xE582, 0x86F8, 0x91FB, 0x86F9, 0xE58C, 0x86FB, 0xE588,\r\n\t0x86FE, 0x89E9, 0x8700, 0xE586, 0x8702, 0x9649, 0x8703, 0xE587,\t0x8706, 0xE584, 0x8708, 0xE585, 0x8709, 0xE58A, 0x870A, 0xE58D,\r\n\t0x870D, 0xE58B, 0x8711, 0xE589, 0x8712, 0xE583, 0x8718, 0x9277,\t0x871A, 0xE594, 0x871C, 0x96A8, 0x8725, 0xE592, 0x8729, 0xE593,\r\n\t0x8734, 0xE58E, 0x8737, 0xE590, 0x873B, 0xE591, 0x873F, 0xE58F,\t0x8749, 0x90E4, 0x874B, 0x9858, 0x874C, 0xE598, 0x874E, 0xE599,\r\n\t0x8753, 0xE59F, 0x8755, 0x9049, 0x8757, 0xE59B, 0x8759, 0xE59E,\t0x875F, 0xE596, 0x8760, 0xE595, 0x8763, 0xE5A0, 0x8766, 0x89DA,\r\n\t0x8768, 0xE59C, 0x876A, 0xE5A1, 0x876E, 0xE59D, 0x8774, 0xE59A,\t0x8776, 0x92B1, 0x8778, 0xE597, 0x877F, 0x9488, 0x8782, 0xE5A5,\r\n\t0x878D, 0x975A, 0x879F, 0xE5A4, 0x87A2, 0xE5A3, 0x87AB, 0xE5AC,\t0x87AF, 0xE5A6, 0x87B3, 0xE5AE, 0x87BA, 0x9786, 0x87BB, 0xE5B1,\r\n\t0x87BD, 0xE5A8, 0x87C0, 0xE5A9, 0x87C4, 0xE5AD, 0x87C6, 0xE5B0,\t0x87C7, 0xE5AF, 0x87CB, 0xE5A7, 0x87D0, 0xE5AA, 0x87D2, 0xE5BB,\r\n\t0x87E0, 0xE5B4, 0x87EF, 0xE5B2, 0x87F2, 0xE5B3, 0x87F6, 0xE5B8,\t0x87F7, 0xE5B9, 0x87F9, 0x8A49, 0x87FB, 0x8B61, 0x87FE, 0xE5B7,\r\n\t0x8805, 0xE5A2, 0x8807, 0xFBA1, 0x880D, 0xE5B6, 0x880E, 0xE5BA,\t0x880F, 0xE5B5, 0x8811, 0xE5BC, 0x8815, 0xE5BE, 0x8816, 0xE5BD,\r\n\t0x8821, 0xE5C0, 0x8822, 0xE5BF, 0x8823, 0xE579, 0x8827, 0xE5C4,\t0x8831, 0xE5C1, 0x8836, 0xE5C2, 0x8839, 0xE5C3, 0x883B, 0xE5C5,\r\n\t0x8840, 0x8C8C, 0x8842, 0xE5C7, 0x8844, 0xE5C6, 0x8846, 0x8F4F,\t0x884C, 0x8D73, 0x884D, 0x9FA5, 0x8852, 0xE5C8, 0x8853, 0x8F70,\r\n\t0x8857, 0x8A58, 0x8859, 0xE5C9, 0x885B, 0x8971, 0x885D, 0x8FD5,\t0x885E, 0xE5CA, 0x8861, 0x8D74, 0x8862, 0xE5CB, 0x8863, 0x88DF,\r\n\t0x8868, 0x955C, 0x886B, 0xE5CC, 0x8870, 0x908A, 0x8872, 0xE5D3,\t0x8875, 0xE5D0, 0x8877, 0x928F, 0x887D, 0xE5D1, 0x887E, 0xE5CE,\r\n\t0x887F, 0x8BDC, 0x8881, 0xE5CD, 0x8882, 0xE5D4, 0x8888, 0x8C55,\t0x888B, 0x91DC, 0x888D, 0xE5DA, 0x8892, 0xE5D6, 0x8896, 0x91B3,\r\n\t0x8897, 0xE5D5, 0x8899, 0xE5D8, 0x889E, 0xE5CF, 0x88A2, 0xE5D9,\t0x88A4, 0xE5DB, 0x88AB, 0x94ED, 0x88AE, 0xE5D7, 0x88B0, 0xE5DC,\r\n\t0x88B1, 0xE5DE, 0x88B4, 0x8CD1, 0x88B5, 0xE5D2, 0x88B7, 0x88BF,\t0x88BF, 0xE5DD, 0x88C1, 0x8DD9, 0x88C2, 0x97F4, 0x88C3, 0xE5DF,\r\n\t0x88C4, 0xE5E0, 0x88C5, 0x9195, 0x88CF, 0x97A0, 0x88D4, 0xE5E1,\t0x88D5, 0x9754, 0x88D8, 0xE5E2, 0x88D9, 0xE5E3, 0x88DC, 0x95E2,\r\n\t0x88DD, 0xE5E4, 0x88DF, 0x8DBE, 0x88E1, 0x97A1, 0x88E8, 0xE5E9,\t0x88F2, 0xE5EA, 0x88F3, 0x8FD6, 0x88F4, 0xE5E8, 0x88F5, 0xFBA2,\r\n\t0x88F8, 0x9787, 0x88F9, 0xE5E5, 0x88FC, 0xE5E7, 0x88FD, 0x90BB,\t0x88FE, 0x909E, 0x8902, 0xE5E6, 0x8904, 0xE5EB, 0x8907, 0x95A1,\r\n\t0x890A, 0xE5ED, 0x890C, 0xE5EC, 0x8910, 0x8A8C, 0x8912, 0x964A,\t0x8913, 0xE5EE, 0x891C, 0xFA5D, 0x891D, 0xE5FA, 0x891E, 0xE5F0,\r\n\t0x8925, 0xE5F1, 0x892A, 0xE5F2, 0x892B, 0xE5F3, 0x8936, 0xE5F7,\t0x8938, 0xE5F8, 0x893B, 0xE5F6, 0x8941, 0xE5F4, 0x8943, 0xE5EF,\r\n\t0x8944, 0xE5F5, 0x894C, 0xE5F9, 0x894D, 0xE8B5, 0x8956, 0x89A6,\t0x895E, 0xE5FC, 0x895F, 0x8BDD, 0x8960, 0xE5FB, 0x8964, 0xE641,\r\n\t0x8966, 0xE640, 0x896A, 0xE643, 0x896D, 0xE642, 0x896F, 0xE644,\t0x8972, 0x8F50, 0x8974, 0xE645, 0x8977, 0xE646, 0x897E, 0xE647,\r\n\t0x897F, 0x90BC, 0x8981, 0x9776, 0x8983, 0xE648, 0x8986, 0x95A2,\t0x8987, 0x9465, 0x8988, 0xE649, 0x898A, 0xE64A, 0x898B, 0x8CA9,\r\n\t0x898F, 0x8B4B, 0x8993, 0xE64B, 0x8996, 0x8E8B, 0x8997, 0x9460,\t0x8998, 0xE64C, 0x899A, 0x8A6F, 0x89A1, 0xE64D, 0x89A6, 0xE64F,\r\n\t0x89A7, 0x9797, 0x89A9, 0xE64E, 0x89AA, 0x9065, 0x89AC, 0xE650,\t0x89AF, 0xE651, 0x89B2, 0xE652, 0x89B3, 0x8ACF, 0x89BA, 0xE653,\r\n\t0x89BD, 0xE654, 0x89BF, 0xE655, 0x89C0, 0xE656, 0x89D2, 0x8A70,\t0x89DA, 0xE657, 0x89DC, 0xE658, 0x89DD, 0xE659, 0x89E3, 0x89F0,\r\n\t0x89E6, 0x9047, 0x89E7, 0xE65A, 0x89F4, 0xE65B, 0x89F8, 0xE65C,\t0x8A00, 0x8CBE, 0x8A02, 0x92F9, 0x8A03, 0xE65D, 0x8A08, 0x8C76,\r\n\t0x8A0A, 0x9075, 0x8A0C, 0xE660, 0x8A0E, 0x93A2, 0x8A10, 0xE65F,\t0x8A12, 0xFBA3, 0x8A13, 0x8C50, 0x8A16, 0xE65E, 0x8A17, 0x91F5,\r\n\t0x8A18, 0x8B4C, 0x8A1B, 0xE661, 0x8A1D, 0xE662, 0x8A1F, 0x8FD7,\t0x8A23, 0x8C8D, 0x8A25, 0xE663, 0x8A2A, 0x964B, 0x8A2D, 0x90DD,\r\n\t0x8A31, 0x8B96, 0x8A33, 0x96F3, 0x8A34, 0x9169, 0x8A36, 0xE664,\t0x8A37, 0xFBA4, 0x8A3A, 0x9066, 0x8A3B, 0x9290, 0x8A3C, 0x8FD8,\r\n\t0x8A41, 0xE665, 0x8A46, 0xE668, 0x8A48, 0xE669, 0x8A50, 0x8DBC,\t0x8A51, 0x91C0, 0x8A52, 0xE667, 0x8A54, 0x8FD9, 0x8A55, 0x955D,\r\n\t0x8A5B, 0xE666, 0x8A5E, 0x8E8C, 0x8A60, 0x8972, 0x8A62, 0xE66D,\t0x8A63, 0x8C77, 0x8A66, 0x8E8E, 0x8A69, 0x8E8D, 0x8A6B, 0x986C,\r\n\t0x8A6C, 0xE66C, 0x8A6D, 0xE66B, 0x8A6E, 0x9146, 0x8A70, 0x8B6C,\t0x8A71, 0x9862, 0x8A72, 0x8A59, 0x8A73, 0x8FDA, 0x8A79, 0xFBA5,\r\n\t0x8A7C, 0xE66A, 0x8A82, 0xE66F, 0x8A84, 0xE670, 0x8A85, 0xE66E,\t0x8A87, 0x8CD6, 0x8A89, 0x975F, 0x8A8C, 0x8E8F, 0x8A8D, 0x9446,\r\n\t0x8A91, 0xE673, 0x8A93, 0x90BE, 0x8A95, 0x9261, 0x8A98, 0x9755,\t0x8A9A, 0xE676, 0x8A9E, 0x8CEA, 0x8AA0, 0x90BD, 0x8AA1, 0xE672,\r\n\t0x8AA3, 0xE677, 0x8AA4, 0x8CEB, 0x8AA5, 0xE674, 0x8AA6, 0xE675,\t0x8AA7, 0xFBA6, 0x8AA8, 0xE671, 0x8AAC, 0x90E0, 0x8AAD, 0x93C7,\r\n\t0x8AB0, 0x924E, 0x8AB2, 0x89DB, 0x8AB9, 0x94EE, 0x8ABC, 0x8B62,\t0x8ABE, 0xFBA7, 0x8ABF, 0x92B2, 0x8AC2, 0xE67A, 0x8AC4, 0xE678,\r\n\t0x8AC7, 0x926B, 0x8ACB, 0x90BF, 0x8ACC, 0x8AD0, 0x8ACD, 0xE679,\t0x8ACF, 0x907A, 0x8AD2, 0x97C8, 0x8AD6, 0x985F, 0x8ADA, 0xE67B,\r\n\t0x8ADB, 0xE687, 0x8ADC, 0x92B3, 0x8ADE, 0xE686, 0x8ADF, 0xFBA8,\t0x8AE0, 0xE683, 0x8AE1, 0xE68B, 0x8AE2, 0xE684, 0x8AE4, 0xE680,\r\n\t0x8AE6, 0x92FA, 0x8AE7, 0xE67E, 0x8AEB, 0xE67C, 0x8AED, 0x9740,\t0x8AEE, 0x8E90, 0x8AF1, 0xE681, 0x8AF3, 0xE67D, 0x8AF6, 0xFBAA,\r\n\t0x8AF7, 0xE685, 0x8AF8, 0x8F94, 0x8AFA, 0x8CBF, 0x8AFE, 0x91F8,\t0x8B00, 0x9664, 0x8B01, 0x8979, 0x8B02, 0x88E0, 0x8B04, 0x93A3,\r\n\t0x8B07, 0xE689, 0x8B0C, 0xE688, 0x8B0E, 0x93E4, 0x8B10, 0xE68D,\t0x8B14, 0xE682, 0x8B16, 0xE68C, 0x8B17, 0xE68E, 0x8B19, 0x8CAA,\r\n\t0x8B1A, 0xE68A, 0x8B1B, 0x8D75, 0x8B1D, 0x8ED3, 0x8B20, 0xE68F,\t0x8B21, 0x9777, 0x8B26, 0xE692, 0x8B28, 0xE695, 0x8B2B, 0xE693,\r\n\t0x8B2C, 0x9554, 0x8B33, 0xE690, 0x8B39, 0x8BDE, 0x8B3E, 0xE694,\t0x8B41, 0xE696, 0x8B49, 0xE69A, 0x8B4C, 0xE697, 0x8B4E, 0xE699,\r\n\t0x8B4F, 0xE698, 0x8B53, 0xFBAB, 0x8B56, 0xE69B, 0x8B58, 0x8EAF,\t0x8B5A, 0xE69D, 0x8B5B, 0xE69C, 0x8B5C, 0x9588, 0x8B5F, 0xE69F,\r\n\t0x8B66, 0x8C78, 0x8B6B, 0xE69E, 0x8B6C, 0xE6A0, 0x8B6F, 0xE6A1,\t0x8B70, 0x8B63, 0x8B71, 0xE3BF, 0x8B72, 0x8FF7, 0x8B74, 0xE6A2,\r\n\t0x8B77, 0x8CEC, 0x8B7D, 0xE6A3, 0x8B7F, 0xFBAC, 0x8B80, 0xE6A4,\t0x8B83, 0x8E5D, 0x8B8A, 0x9DCC, 0x8B8C, 0xE6A5, 0x8B8E, 0xE6A6,\r\n\t0x8B90, 0x8F51, 0x8B92, 0xE6A7, 0x8B93, 0xE6A8, 0x8B96, 0xE6A9,\t0x8B99, 0xE6AA, 0x8B9A, 0xE6AB, 0x8C37, 0x924A, 0x8C3A, 0xE6AC,\r\n\t0x8C3F, 0xE6AE, 0x8C41, 0xE6AD, 0x8C46, 0x93A4, 0x8C48, 0xE6AF,\t0x8C4A, 0x964C, 0x8C4C, 0xE6B0, 0x8C4E, 0xE6B1, 0x8C50, 0xE6B2,\r\n\t0x8C55, 0xE6B3, 0x8C5A, 0x93D8, 0x8C61, 0x8FDB, 0x8C62, 0xE6B4,\t0x8C6A, 0x8D8B, 0x8C6B, 0x98AC, 0x8C6C, 0xE6B5, 0x8C78, 0xE6B6,\r\n\t0x8C79, 0x955E, 0x8C7A, 0xE6B7, 0x8C7C, 0xE6BF, 0x8C82, 0xE6B8,\t0x8C85, 0xE6BA, 0x8C89, 0xE6B9, 0x8C8A, 0xE6BB, 0x8C8C, 0x9665,\r\n\t0x8C8D, 0xE6BC, 0x8C8E, 0xE6BD, 0x8C94, 0xE6BE, 0x8C98, 0xE6C0,\t0x8C9D, 0x8A4C, 0x8C9E, 0x92E5, 0x8CA0, 0x9589, 0x8CA1, 0x8DE0,\r\n\t0x8CA2, 0x8D76, 0x8CA7, 0x956E, 0x8CA8, 0x89DD, 0x8CA9, 0x94CC,\t0x8CAA, 0xE6C3, 0x8CAB, 0x8AD1, 0x8CAC, 0x90D3, 0x8CAD, 0xE6C2,\r\n\t0x8CAE, 0xE6C7, 0x8CAF, 0x9299, 0x8CB0, 0x96E1, 0x8CB2, 0xE6C5,\t0x8CB3, 0xE6C6, 0x8CB4, 0x8B4D, 0x8CB6, 0xE6C8, 0x8CB7, 0x9483,\r\n\t0x8CB8, 0x91DD, 0x8CBB, 0x94EF, 0x8CBC, 0x935C, 0x8CBD, 0xE6C4,\t0x8CBF, 0x9666, 0x8CC0, 0x89EA, 0x8CC1, 0xE6CA, 0x8CC2, 0x9847,\r\n\t0x8CC3, 0x92C0, 0x8CC4, 0x9864, 0x8CC7, 0x8E91, 0x8CC8, 0xE6C9,\t0x8CCA, 0x91AF, 0x8CCD, 0xE6DA, 0x8CCE, 0x9147, 0x8CD1, 0x93F6,\r\n\t0x8CD3, 0x956F, 0x8CDA, 0xE6CD, 0x8CDB, 0x8E5E, 0x8CDC, 0x8E92,\t0x8CDE, 0x8FDC, 0x8CE0, 0x9485, 0x8CE2, 0x8CAB, 0x8CE3, 0xE6CC,\r\n\t0x8CE4, 0xE6CB, 0x8CE6, 0x958A, 0x8CEA, 0x8EBF, 0x8CED, 0x9371,\t0x8CF0, 0xFBAD, 0x8CF4, 0xFBAE, 0x8CFA, 0xE6CF, 0x8CFB, 0xE6D0,\r\n\t0x8CFC, 0x8D77, 0x8CFD, 0xE6CE, 0x8D04, 0xE6D1, 0x8D05, 0xE6D2,\t0x8D07, 0xE6D4, 0x8D08, 0x91A1, 0x8D0A, 0xE6D3, 0x8D0B, 0x8AE4,\r\n\t0x8D0D, 0xE6D6, 0x8D0F, 0xE6D5, 0x8D10, 0xE6D7, 0x8D12, 0xFBAF,\t0x8D13, 0xE6D9, 0x8D14, 0xE6DB, 0x8D16, 0xE6DC, 0x8D64, 0x90D4,\r\n\t0x8D66, 0x8ECD, 0x8D67, 0xE6DD, 0x8D6B, 0x8A71, 0x8D6D, 0xE6DE,\t0x8D70, 0x9196, 0x8D71, 0xE6DF, 0x8D73, 0xE6E0, 0x8D74, 0x958B,\r\n\t0x8D76, 0xFBB0, 0x8D77, 0x8B4E, 0x8D81, 0xE6E1, 0x8D85, 0x92B4,\t0x8D8A, 0x897A, 0x8D99, 0xE6E2, 0x8DA3, 0x8EEF, 0x8DA8, 0x9096,\r\n\t0x8DB3, 0x91AB, 0x8DBA, 0xE6E5, 0x8DBE, 0xE6E4, 0x8DC2, 0xE6E3,\t0x8DCB, 0xE6EB, 0x8DCC, 0xE6E9, 0x8DCF, 0xE6E6, 0x8DD6, 0xE6E8,\r\n\t0x8DDA, 0xE6E7, 0x8DDB, 0xE6EA, 0x8DDD, 0x8B97, 0x8DDF, 0xE6EE,\t0x8DE1, 0x90D5, 0x8DE3, 0xE6EF, 0x8DE8, 0x8CD7, 0x8DEA, 0xE6EC,\r\n\t0x8DEB, 0xE6ED, 0x8DEF, 0x9848, 0x8DF3, 0x92B5, 0x8DF5, 0x9148,\t0x8DFC, 0xE6F0, 0x8DFF, 0xE6F3, 0x8E08, 0xE6F1, 0x8E09, 0xE6F2,\r\n\t0x8E0A, 0x9778, 0x8E0F, 0x93A5, 0x8E10, 0xE6F6, 0x8E1D, 0xE6F4,\t0x8E1E, 0xE6F5, 0x8E1F, 0xE6F7, 0x8E2A, 0xE748, 0x8E30, 0xE6FA,\r\n\t0x8E34, 0xE6FB, 0x8E35, 0xE6F9, 0x8E42, 0xE6F8, 0x8E44, 0x92FB,\t0x8E47, 0xE740, 0x8E48, 0xE744, 0x8E49, 0xE741, 0x8E4A, 0xE6FC,\r\n\t0x8E4C, 0xE742, 0x8E50, 0xE743, 0x8E55, 0xE74A, 0x8E59, 0xE745,\t0x8E5F, 0x90D6, 0x8E60, 0xE747, 0x8E63, 0xE749, 0x8E64, 0xE746,\r\n\t0x8E72, 0xE74C, 0x8E74, 0x8F52, 0x8E76, 0xE74B, 0x8E7C, 0xE74D,\t0x8E81, 0xE74E, 0x8E84, 0xE751, 0x8E85, 0xE750, 0x8E87, 0xE74F,\r\n\t0x8E8A, 0xE753, 0x8E8B, 0xE752, 0x8E8D, 0x96F4, 0x8E91, 0xE755,\t0x8E93, 0xE754, 0x8E94, 0xE756, 0x8E99, 0xE757, 0x8EA1, 0xE759,\r\n\t0x8EAA, 0xE758, 0x8EAB, 0x9067, 0x8EAC, 0xE75A, 0x8EAF, 0x8BEB,\t0x8EB0, 0xE75B, 0x8EB1, 0xE75D, 0x8EBE, 0xE75E, 0x8EC5, 0xE75F,\r\n\t0x8EC6, 0xE75C, 0x8EC8, 0xE760, 0x8ECA, 0x8ED4, 0x8ECB, 0xE761,\t0x8ECC, 0x8B4F, 0x8ECD, 0x8C52, 0x8ECF, 0xFBB2, 0x8ED2, 0x8CAC,\r\n\t0x8EDB, 0xE762, 0x8EDF, 0x93EE, 0x8EE2, 0x935D, 0x8EE3, 0xE763,\t0x8EEB, 0xE766, 0x8EF8, 0x8EB2, 0x8EFB, 0xE765, 0x8EFC, 0xE764,\r\n\t0x8EFD, 0x8C79, 0x8EFE, 0xE767, 0x8F03, 0x8A72, 0x8F05, 0xE769,\t0x8F09, 0x8DDA, 0x8F0A, 0xE768, 0x8F0C, 0xE771, 0x8F12, 0xE76B,\r\n\t0x8F13, 0xE76D, 0x8F14, 0x95E3, 0x8F15, 0xE76A, 0x8F19, 0xE76C,\t0x8F1B, 0xE770, 0x8F1C, 0xE76E, 0x8F1D, 0x8B50, 0x8F1F, 0xE76F,\r\n\t0x8F26, 0xE772, 0x8F29, 0x9479, 0x8F2A, 0x97D6, 0x8F2F, 0x8F53,\t0x8F33, 0xE773, 0x8F38, 0x9741, 0x8F39, 0xE775, 0x8F3B, 0xE774,\r\n\t0x8F3E, 0xE778, 0x8F3F, 0x9760, 0x8F42, 0xE777, 0x8F44, 0x8A8D,\t0x8F45, 0xE776, 0x8F46, 0xE77B, 0x8F49, 0xE77A, 0x8F4C, 0xE779,\r\n\t0x8F4D, 0x9351, 0x8F4E, 0xE77C, 0x8F57, 0xE77D, 0x8F5C, 0xE77E,\t0x8F5F, 0x8D8C, 0x8F61, 0x8C44, 0x8F62, 0xE780, 0x8F63, 0xE781,\r\n\t0x8F64, 0xE782, 0x8F9B, 0x9068, 0x8F9C, 0xE783, 0x8F9E, 0x8EAB,\t0x8F9F, 0xE784, 0x8FA3, 0xE785, 0x8FA7, 0x999F, 0x8FA8, 0x999E,\r\n\t0x8FAD, 0xE786, 0x8FAE, 0xE390, 0x8FAF, 0xE787, 0x8FB0, 0x9243,\t0x8FB1, 0x904A, 0x8FB2, 0x945F, 0x8FB7, 0xE788, 0x8FBA, 0x95D3,\r\n\t0x8FBB, 0x92D2, 0x8FBC, 0x8D9E, 0x8FBF, 0x9248, 0x8FC2, 0x8949,\t0x8FC4, 0x9698, 0x8FC5, 0x9076, 0x8FCE, 0x8C7D, 0x8FD1, 0x8BDF,\r\n\t0x8FD4, 0x95D4, 0x8FDA, 0xE789, 0x8FE2, 0xE78B, 0x8FE5, 0xE78A,\t0x8FE6, 0x89DE, 0x8FE9, 0x93F4, 0x8FEA, 0xE78C, 0x8FEB, 0x9497,\r\n\t0x8FED, 0x9352, 0x8FEF, 0xE78D, 0x8FF0, 0x8F71, 0x8FF4, 0xE78F,\t0x8FF7, 0x96C0, 0x8FF8, 0xE79E, 0x8FF9, 0xE791, 0x8FFA, 0xE792,\r\n\t0x8FFD, 0x92C7, 0x9000, 0x91DE, 0x9001, 0x9197, 0x9003, 0x93A6,\t0x9005, 0xE790, 0x9006, 0x8B74, 0x900B, 0xE799, 0x900D, 0xE796,\r\n\t0x900E, 0xE7A3, 0x900F, 0x93A7, 0x9010, 0x9280, 0x9011, 0xE793,\t0x9013, 0x92FC, 0x9014, 0x9372, 0x9015, 0xE794, 0x9016, 0xE798,\r\n\t0x9017, 0x9080, 0x9019, 0x9487, 0x901A, 0x92CA, 0x901D, 0x90C0,\t0x901E, 0xE797, 0x901F, 0x91AC, 0x9020, 0x91A2, 0x9021, 0xE795,\r\n\t0x9022, 0x88A7, 0x9023, 0x9841, 0x9027, 0xE79A, 0x902E, 0x91DF,\t0x9031, 0x8F54, 0x9032, 0x9069, 0x9035, 0xE79C, 0x9036, 0xE79B,\r\n\t0x9038, 0x88ED, 0x9039, 0xE79D, 0x903C, 0x954E, 0x903E, 0xE7A5,\t0x9041, 0x93D9, 0x9042, 0x908B, 0x9045, 0x9278, 0x9047, 0x8BF6,\r\n\t0x9049, 0xE7A4, 0x904A, 0x9756, 0x904B, 0x895E, 0x904D, 0x95D5,\t0x904E, 0x89DF, 0x904F, 0xE79F, 0x9050, 0xE7A0, 0x9051, 0xE7A1,\r\n\t0x9052, 0xE7A2, 0x9053, 0x93B9, 0x9054, 0x9242, 0x9055, 0x88E1,\t0x9056, 0xE7A6, 0x9058, 0xE7A7, 0x9059, 0xEAA1, 0x905C, 0x91BB,\r\n\t0x905E, 0xE7A8, 0x9060, 0x8993, 0x9061, 0x916B, 0x9063, 0x8CAD,\t0x9065, 0x9779, 0x9067, 0xFBB5, 0x9068, 0xE7A9, 0x9069, 0x934B,\r\n\t0x906D, 0x9198, 0x906E, 0x8ED5, 0x906F, 0xE7AA, 0x9072, 0xE7AD,\t0x9075, 0x8F85, 0x9076, 0xE7AB, 0x9077, 0x914A, 0x9078, 0x9149,\r\n\t0x907A, 0x88E2, 0x907C, 0x97C9, 0x907D, 0xE7AF, 0x907F, 0x94F0,\t0x9080, 0xE7B1, 0x9081, 0xE7B0, 0x9082, 0xE7AE, 0x9083, 0xE284,\r\n\t0x9084, 0x8AD2, 0x9087, 0xE78E, 0x9089, 0xE7B3, 0x908A, 0xE7B2,\t0x908F, 0xE7B4, 0x9091, 0x9757, 0x90A3, 0x93DF, 0x90A6, 0x964D,\r\n\t0x90A8, 0xE7B5, 0x90AA, 0x8ED7, 0x90AF, 0xE7B6, 0x90B1, 0xE7B7,\t0x90B5, 0xE7B8, 0x90B8, 0x9340, 0x90C1, 0x88E8, 0x90CA, 0x8D78,\r\n\t0x90CE, 0x9859, 0x90DB, 0xE7BC, 0x90DE, 0xFBB6, 0x90E1, 0x8C53,\t0x90E2, 0xE7B9, 0x90E4, 0xE7BA, 0x90E8, 0x9594, 0x90ED, 0x8A73,\r\n\t0x90F5, 0x9758, 0x90F7, 0x8BBD, 0x90FD, 0x9373, 0x9102, 0xE7BD,\t0x9112, 0xE7BE, 0x9115, 0xFBB8, 0x9119, 0xE7BF, 0x9127, 0xFBB9,\r\n\t0x912D, 0x9341, 0x9130, 0xE7C1, 0x9132, 0xE7C0, 0x9149, 0x93D1,\t0x914A, 0xE7C2, 0x914B, 0x8F55, 0x914C, 0x8EDE, 0x914D, 0x947A,\r\n\t0x914E, 0x9291, 0x9152, 0x8EF0, 0x9154, 0x908C, 0x9156, 0xE7C3,\t0x9158, 0xE7C4, 0x9162, 0x907C, 0x9163, 0xE7C5, 0x9165, 0xE7C6,\r\n\t0x9169, 0xE7C7, 0x916A, 0x978F, 0x916C, 0x8F56, 0x9172, 0xE7C9,\t0x9173, 0xE7C8, 0x9175, 0x8D79, 0x9177, 0x8D93, 0x9178, 0x8E5F,\r\n\t0x9182, 0xE7CC, 0x9187, 0x8F86, 0x9189, 0xE7CB, 0x918B, 0xE7CA,\t0x918D, 0x91E7, 0x9190, 0x8CED, 0x9192, 0x90C1, 0x9197, 0x94AE,\r\n\t0x919C, 0x8F58, 0x91A2, 0xE7CD, 0x91A4, 0x8FDD, 0x91AA, 0xE7D0,\t0x91AB, 0xE7CE, 0x91AF, 0xE7CF, 0x91B4, 0xE7D2, 0x91B5, 0xE7D1,\r\n\t0x91B8, 0x8FF8, 0x91BA, 0xE7D3, 0x91C0, 0xE7D4, 0x91C1, 0xE7D5,\t0x91C6, 0x94CE, 0x91C7, 0x8DD1, 0x91C8, 0x8EDF, 0x91C9, 0xE7D6,\r\n\t0x91CB, 0xE7D7, 0x91CC, 0x97A2, 0x91CD, 0x8F64, 0x91CE, 0x96EC,\t0x91CF, 0x97CA, 0x91D0, 0xE7D8, 0x91D1, 0x8BE0, 0x91D6, 0xE7D9,\r\n\t0x91D7, 0xFBBB, 0x91D8, 0x9342, 0x91DA, 0xFBBA, 0x91DB, 0xE7DC,\t0x91DC, 0x8A98, 0x91DD, 0x906A, 0x91DE, 0xFBBC, 0x91DF, 0xE7DA,\r\n\t0x91E1, 0xE7DB, 0x91E3, 0x92DE, 0x91E4, 0xFBBF, 0x91E5, 0xFBC0,\t0x91E6, 0x9674, 0x91E7, 0x8BFA, 0x91ED, 0xFBBD, 0x91EE, 0xFBBE,\r\n\t0x91F5, 0xE7DE, 0x91F6, 0xE7DF, 0x91FC, 0xE7DD, 0x91FF, 0xE7E1,\t0x9206, 0xFBC1, 0x920A, 0xFBC3, 0x920D, 0x93DD, 0x920E, 0x8A62,\r\n\t0x9210, 0xFBC2, 0x9211, 0xE7E5, 0x9214, 0xE7E2, 0x9215, 0xE7E4,\t0x921E, 0xE7E0, 0x9229, 0xE86E, 0x922C, 0xE7E3, 0x9234, 0x97E9,\r\n\t0x9237, 0x8CD8, 0x9239, 0xFBCA, 0x923A, 0xFBC4, 0x923C, 0xFBC6,\t0x923F, 0xE7ED, 0x9240, 0xFBC5, 0x9244, 0x9353, 0x9245, 0xE7E8,\r\n\t0x9248, 0xE7EB, 0x9249, 0xE7E9, 0x924B, 0xE7EE, 0x924E, 0xFBC7,\t0x9250, 0xE7EF, 0x9251, 0xFBC9, 0x9257, 0xE7E7, 0x9259, 0xFBC8,\r\n\t0x925A, 0xE7F4, 0x925B, 0x8994, 0x925E, 0xE7E6, 0x9262, 0x94AB,\t0x9264, 0xE7EA, 0x9266, 0x8FDE, 0x9267, 0xFBCB, 0x9271, 0x8D7A,\r\n\t0x9277, 0xFBCD, 0x9278, 0xFBCE, 0x927E, 0x9667, 0x9280, 0x8BE2,\t0x9283, 0x8F65, 0x9285, 0x93BA, 0x9288, 0xFA5F, 0x9291, 0x914C,\r\n\t0x9293, 0xE7F2, 0x9295, 0xE7EC, 0x9296, 0xE7F1, 0x9298, 0x96C1,\t0x929A, 0x92B6, 0x929B, 0xE7F3, 0x929C, 0xE7F0, 0x92A7, 0xFBCC,\r\n\t0x92AD, 0x914B, 0x92B7, 0xE7F7, 0x92B9, 0xE7F6, 0x92CF, 0xE7F5,\t0x92D0, 0xFBD2, 0x92D2, 0x964E, 0x92D3, 0xFBD6, 0x92D5, 0xFBD4,\r\n\t0x92D7, 0xFBD0, 0x92D9, 0xFBD1, 0x92E0, 0xFBD5, 0x92E4, 0x8F9B,\t0x92E7, 0xFBCF, 0x92E9, 0xE7F8, 0x92EA, 0x95DD, 0x92ED, 0x8973,\r\n\t0x92F2, 0x9565, 0x92F3, 0x9292, 0x92F8, 0x8B98, 0x92F9, 0xFA65,\t0x92FA, 0xE7FA, 0x92FB, 0xFBD9, 0x92FC, 0x8D7C, 0x92FF, 0xFBDC,\r\n\t0x9302, 0xFBDE, 0x9306, 0x8E4B, 0x930F, 0xE7F9, 0x9310, 0x908D,\t0x9318, 0x908E, 0x9319, 0xE840, 0x931A, 0xE842, 0x931D, 0xFBDD,\r\n\t0x931E, 0xFBDB, 0x9320, 0x8FF9, 0x9321, 0xFBD8, 0x9322, 0xE841,\t0x9323, 0xE843, 0x9325, 0xFBD7, 0x9326, 0x8BD1, 0x9328, 0x9564,\r\n\t0x932B, 0x8EE0, 0x932C, 0x9842, 0x932E, 0xE7FC, 0x932F, 0x8DF6,\t0x9332, 0x985E, 0x9335, 0xE845, 0x933A, 0xE844, 0x933B, 0xE846,\r\n\t0x9344, 0xE7FB, 0x9348, 0xFA5E, 0x934B, 0x93E7, 0x934D, 0x9374,\t0x9354, 0x92D5, 0x9356, 0xE84B, 0x9357, 0xFBE0, 0x935B, 0x9262,\r\n\t0x935C, 0xE847, 0x9360, 0xE848, 0x936C, 0x8C4C, 0x936E, 0xE84A,\t0x9370, 0xFBDF, 0x9375, 0x8CAE, 0x937C, 0xE849, 0x937E, 0x8FDF,\r\n\t0x938C, 0x8A99, 0x9394, 0xE84F, 0x9396, 0x8DBD, 0x9397, 0x9199,\t0x939A, 0x92C8, 0x93A4, 0xFBE1, 0x93A7, 0x8A5A, 0x93AC, 0xE84D,\r\n\t0x93AD, 0xE84E, 0x93AE, 0x92C1, 0x93B0, 0xE84C, 0x93B9, 0xE850,\t0x93C3, 0xE856, 0x93C6, 0xFBE2, 0x93C8, 0xE859, 0x93D0, 0xE858,\r\n\t0x93D1, 0x934C, 0x93D6, 0xE851, 0x93D7, 0xE852, 0x93D8, 0xE855,\t0x93DD, 0xE857, 0x93DE, 0xFBE3, 0x93E1, 0x8BBE, 0x93E4, 0xE85A,\r\n\t0x93E5, 0xE854, 0x93E8, 0xE853, 0x93F8, 0xFBE4, 0x9403, 0xE85E,\t0x9407, 0xE85F, 0x9410, 0xE860, 0x9413, 0xE85D, 0x9414, 0xE85C,\r\n\t0x9418, 0x8FE0, 0x9419, 0x93A8, 0x941A, 0xE85B, 0x9421, 0xE864,\t0x942B, 0xE862, 0x9431, 0xFBE5, 0x9435, 0xE863, 0x9436, 0xE861,\r\n\t0x9438, 0x91F6, 0x943A, 0xE865, 0x9441, 0xE866, 0x9444, 0xE868,\t0x9445, 0xFBE6, 0x9448, 0xFBE7, 0x9451, 0x8AD3, 0x9452, 0xE867,\r\n\t0x9453, 0x96F8, 0x945A, 0xE873, 0x945B, 0xE869, 0x945E, 0xE86C,\t0x9460, 0xE86A, 0x9462, 0xE86B, 0x946A, 0xE86D, 0x9470, 0xE86F,\r\n\t0x9475, 0xE870, 0x9477, 0xE871, 0x947C, 0xE874, 0x947D, 0xE872,\t0x947E, 0xE875, 0x947F, 0xE877, 0x9481, 0xE876, 0x9577, 0x92B7,\r\n\t0x9580, 0x96E5, 0x9582, 0xE878, 0x9583, 0x914D, 0x9587, 0xE879,\t0x9589, 0x95C2, 0x958A, 0xE87A, 0x958B, 0x8A4A, 0x958F, 0x895B,\r\n\t0x9591, 0x8AD5, 0x9592, 0xFBE8, 0x9593, 0x8AD4, 0x9594, 0xE87B,\t0x9596, 0xE87C, 0x9598, 0xE87D, 0x9599, 0xE87E, 0x95A0, 0xE880,\r\n\t0x95A2, 0x8AD6, 0x95A3, 0x8A74, 0x95A4, 0x8D7D, 0x95A5, 0x94B4,\t0x95A7, 0xE882, 0x95A8, 0xE881, 0x95AD, 0xE883, 0x95B2, 0x897B,\r\n\t0x95B9, 0xE886, 0x95BB, 0xE885, 0x95BC, 0xE884, 0x95BE, 0xE887,\t0x95C3, 0xE88A, 0x95C7, 0x88C5, 0x95CA, 0xE888, 0x95CC, 0xE88C,\r\n\t0x95CD, 0xE88B, 0x95D4, 0xE88E, 0x95D5, 0xE88D, 0x95D6, 0xE88F,\t0x95D8, 0x93AC, 0x95DC, 0xE890, 0x95E1, 0xE891, 0x95E2, 0xE893,\r\n\t0x95E5, 0xE892, 0x961C, 0x958C, 0x9621, 0xE894, 0x9628, 0xE895,\t0x962A, 0x8DE3, 0x962E, 0xE896, 0x962F, 0xE897, 0x9632, 0x9668,\r\n\t0x963B, 0x916A, 0x963F, 0x88A2, 0x9640, 0x91C9, 0x9642, 0xE898,\t0x9644, 0x958D, 0x964B, 0xE89B, 0x964C, 0xE899, 0x964D, 0x8D7E,\r\n\t0x964F, 0xE89A, 0x9650, 0x8CC0, 0x965B, 0x95C3, 0x965C, 0xE89D,\t0x965D, 0xE89F, 0x965E, 0xE89E, 0x965F, 0xE8A0, 0x9662, 0x8940,\r\n\t0x9663, 0x9077, 0x9664, 0x8F9C, 0x9665, 0x8AD7, 0x9666, 0xE8A1,\t0x966A, 0x9486, 0x966C, 0xE8A3, 0x9670, 0x8941, 0x9672, 0xE8A2,\r\n\t0x9673, 0x92C2, 0x9675, 0x97CB, 0x9676, 0x93A9, 0x9677, 0xE89C,\t0x9678, 0x97A4, 0x967A, 0x8CAF, 0x967D, 0x977A, 0x9685, 0x8BF7,\r\n\t0x9686, 0x97B2, 0x9688, 0x8C47, 0x968A, 0x91E0, 0x968B, 0xE440,\t0x968D, 0xE8A4, 0x968E, 0x8A4B, 0x968F, 0x908F, 0x9694, 0x8A75,\r\n\t0x9695, 0xE8A6, 0x9697, 0xE8A7, 0x9698, 0xE8A5, 0x9699, 0x8C84,\t0x969B, 0x8DDB, 0x969C, 0x8FE1, 0x969D, 0xFBEB, 0x96A0, 0x8942,\r\n\t0x96A3, 0x97D7, 0x96A7, 0xE8A9, 0x96A8, 0xE7AC, 0x96AA, 0xE8A8,\t0x96AF, 0xFBEC, 0x96B0, 0xE8AC, 0x96B1, 0xE8AA, 0x96B2, 0xE8AB,\r\n\t0x96B4, 0xE8AD, 0x96B6, 0xE8AE, 0x96B7, 0x97EA, 0x96B8, 0xE8AF,\t0x96B9, 0xE8B0, 0x96BB, 0x90C7, 0x96BC, 0x94B9, 0x96C0, 0x909D,\r\n\t0x96C1, 0x8AE5, 0x96C4, 0x9759, 0x96C5, 0x89EB, 0x96C6, 0x8F57,\t0x96C7, 0x8CD9, 0x96C9, 0xE8B3, 0x96CB, 0xE8B2, 0x96CC, 0x8E93,\r\n\t0x96CD, 0xE8B4, 0x96CE, 0xE8B1, 0x96D1, 0x8E47, 0x96D5, 0xE8B8,\t0x96D6, 0xE5AB, 0x96D9, 0x99D4, 0x96DB, 0x9097, 0x96DC, 0xE8B6,\r\n\t0x96E2, 0x97A3, 0x96E3, 0x93EF, 0x96E8, 0x894A, 0x96EA, 0x90E1,\t0x96EB, 0x8EB4, 0x96F0, 0x95B5, 0x96F2, 0x895F, 0x96F6, 0x97EB,\r\n\t0x96F7, 0x978B, 0x96F9, 0xE8B9, 0x96FB, 0x9364, 0x9700, 0x8EF9,\t0x9704, 0xE8BA, 0x9706, 0xE8BB, 0x9707, 0x906B, 0x9708, 0xE8BC,\r\n\t0x970A, 0x97EC, 0x970D, 0xE8B7, 0x970E, 0xE8BE, 0x970F, 0xE8C0,\t0x9711, 0xE8BF, 0x9713, 0xE8BD, 0x9716, 0xE8C1, 0x9719, 0xE8C2,\r\n\t0x971C, 0x919A, 0x971E, 0x89E0, 0x9724, 0xE8C3, 0x9727, 0x96B6,\t0x972A, 0xE8C4, 0x9730, 0xE8C5, 0x9732, 0x9849, 0x9733, 0xFBED,\r\n\t0x9738, 0x9E50, 0x9739, 0xE8C6, 0x973B, 0xFBEE, 0x973D, 0xE8C7,\t0x973E, 0xE8C8, 0x9742, 0xE8CC, 0x9743, 0xFBEF, 0x9744, 0xE8C9,\r\n\t0x9746, 0xE8CA, 0x9748, 0xE8CB, 0x9749, 0xE8CD, 0x974D, 0xFBF0,\t0x974F, 0xFBF1, 0x9751, 0xFBF2, 0x9752, 0x90C2, 0x9755, 0xFBF3,\r\n\t0x9756, 0x96F5, 0x9759, 0x90C3, 0x975C, 0xE8CE, 0x975E, 0x94F1,\t0x9760, 0xE8CF, 0x9761, 0xEA72, 0x9762, 0x96CA, 0x9764, 0xE8D0,\r\n\t0x9766, 0xE8D1, 0x9768, 0xE8D2, 0x9769, 0x8A76, 0x976B, 0xE8D4,\t0x976D, 0x9078, 0x9771, 0xE8D5, 0x9774, 0x8C43, 0x9779, 0xE8D6,\r\n\t0x977A, 0xE8DA, 0x977C, 0xE8D8, 0x9781, 0xE8D9, 0x9784, 0x8A93,\t0x9785, 0xE8D7, 0x9786, 0xE8DB, 0x978B, 0xE8DC, 0x978D, 0x88C6,\r\n\t0x978F, 0xE8DD, 0x9790, 0xE8DE, 0x9798, 0x8FE2, 0x979C, 0xE8DF,\t0x97A0, 0x8B66, 0x97A3, 0xE8E2, 0x97A6, 0xE8E1, 0x97A8, 0xE8E0,\r\n\t0x97AB, 0xE691, 0x97AD, 0x95DA, 0x97B3, 0xE8E3, 0x97B4, 0xE8E4,\t0x97C3, 0xE8E5, 0x97C6, 0xE8E6, 0x97C8, 0xE8E7, 0x97CB, 0xE8E8,\r\n\t0x97D3, 0x8AD8, 0x97DC, 0xE8E9, 0x97ED, 0xE8EA, 0x97EE, 0x9442,\t0x97F2, 0xE8EC, 0x97F3, 0x89B9, 0x97F5, 0xE8EF, 0x97F6, 0xE8EE,\r\n\t0x97FB, 0x8943, 0x97FF, 0x8BBF, 0x9801, 0x95C5, 0x9802, 0x92B8,\t0x9803, 0x8DA0, 0x9805, 0x8D80, 0x9806, 0x8F87, 0x9808, 0x907B,\r\n\t0x980C, 0xE8F1, 0x980F, 0xE8F0, 0x9810, 0x9761, 0x9811, 0x8AE6,\t0x9812, 0x94D0, 0x9813, 0x93DA, 0x9817, 0x909C, 0x9818, 0x97CC,\r\n\t0x981A, 0x8C7A, 0x9821, 0xE8F4, 0x9824, 0xE8F3, 0x982C, 0x966A,\t0x982D, 0x93AA, 0x9834, 0x896F, 0x9837, 0xE8F5, 0x9838, 0xE8F2,\r\n\t0x983B, 0x9570, 0x983C, 0x978A, 0x983D, 0xE8F6, 0x9846, 0xE8F7,\t0x984B, 0xE8F9, 0x984C, 0x91E8, 0x984D, 0x8A7A, 0x984E, 0x8A7B,\r\n\t0x984F, 0xE8F8, 0x9854, 0x8AE7, 0x9855, 0x8CB0, 0x9857, 0xFBF4,\t0x9858, 0x8AE8, 0x985B, 0x935E, 0x985E, 0x97DE, 0x9865, 0xFBF5,\r\n\t0x9867, 0x8CDA, 0x986B, 0xE8FA, 0x986F, 0xE8FB, 0x9870, 0xE8FC,\t0x9871, 0xE940, 0x9873, 0xE942, 0x9874, 0xE941, 0x98A8, 0x9597,\r\n\t0x98AA, 0xE943, 0x98AF, 0xE944, 0x98B1, 0xE945, 0x98B6, 0xE946,\t0x98C3, 0xE948, 0x98C4, 0xE947, 0x98C6, 0xE949, 0x98DB, 0x94F2,\r\n\t0x98DC, 0xE3CA, 0x98DF, 0x9048, 0x98E2, 0x8B51, 0x98E9, 0xE94A,\t0x98EB, 0xE94B, 0x98ED, 0x99AA, 0x98EE, 0x9F5A, 0x98EF, 0x94D1,\r\n\t0x98F2, 0x88F9, 0x98F4, 0x88B9, 0x98FC, 0x8E94, 0x98FD, 0x964F,\t0x98FE, 0x8FFC, 0x9903, 0xE94C, 0x9905, 0x96DD, 0x9909, 0xE94D,\r\n\t0x990A, 0x977B, 0x990C, 0x8961, 0x9910, 0x8E60, 0x9912, 0xE94E,\t0x9913, 0x89EC, 0x9914, 0xE94F, 0x9918, 0xE950, 0x991D, 0xE952,\r\n\t0x991E, 0xE953, 0x9920, 0xE955, 0x9921, 0xE951, 0x9924, 0xE954,\t0x9927, 0xFBF8, 0x9928, 0x8AD9, 0x992C, 0xE956, 0x992E, 0xE957,\r\n\t0x993D, 0xE958, 0x993E, 0xE959, 0x9942, 0xE95A, 0x9945, 0xE95C,\t0x9949, 0xE95B, 0x994B, 0xE95E, 0x994C, 0xE961, 0x9950, 0xE95D,\r\n\t0x9951, 0xE95F, 0x9952, 0xE960, 0x9955, 0xE962, 0x9957, 0x8BC0,\t0x9996, 0x8EF1, 0x9997, 0xE963, 0x9998, 0xE964, 0x9999, 0x8D81,\r\n\t0x999E, 0xFBFA, 0x99A5, 0xE965, 0x99A8, 0x8A5D, 0x99AC, 0x946E,\t0x99AD, 0xE966, 0x99AE, 0xE967, 0x99B3, 0x9279, 0x99B4, 0x93E9,\r\n\t0x99BC, 0xE968, 0x99C1, 0x949D, 0x99C4, 0x91CA, 0x99C5, 0x8977,\t0x99C6, 0x8BEC, 0x99C8, 0x8BED, 0x99D0, 0x9293, 0x99D1, 0xE96D,\r\n\t0x99D2, 0x8BEE, 0x99D5, 0x89ED, 0x99D8, 0xE96C, 0x99DB, 0xE96A,\t0x99DD, 0xE96B, 0x99DF, 0xE969, 0x99E2, 0xE977, 0x99ED, 0xE96E,\r\n\t0x99EE, 0xE96F, 0x99F1, 0xE970, 0x99F2, 0xE971, 0x99F8, 0xE973,\t0x99FB, 0xE972, 0x99FF, 0x8F78, 0x9A01, 0xE974, 0x9A05, 0xE976,\r\n\t0x9A0E, 0x8B52, 0x9A0F, 0xE975, 0x9A12, 0x919B, 0x9A13, 0x8CB1,\t0x9A19, 0xE978, 0x9A28, 0x91CB, 0x9A2B, 0xE979, 0x9A30, 0x93AB,\r\n\t0x9A37, 0xE97A, 0x9A3E, 0xE980, 0x9A40, 0xE97D, 0x9A42, 0xE97C,\t0x9A43, 0xE97E, 0x9A45, 0xE97B, 0x9A4D, 0xE982, 0x9A4E, 0xFBFB,\r\n\t0x9A55, 0xE981, 0x9A57, 0xE984, 0x9A5A, 0x8BC1, 0x9A5B, 0xE983,\t0x9A5F, 0xE985, 0x9A62, 0xE986, 0x9A64, 0xE988, 0x9A65, 0xE987,\r\n\t0x9A69, 0xE989, 0x9A6A, 0xE98B, 0x9A6B, 0xE98A, 0x9AA8, 0x8D9C,\t0x9AAD, 0xE98C, 0x9AB0, 0xE98D, 0x9AB8, 0x8A5B, 0x9ABC, 0xE98E,\r\n\t0x9AC0, 0xE98F, 0x9AC4, 0x9091, 0x9ACF, 0xE990, 0x9AD1, 0xE991,\t0x9AD3, 0xE992, 0x9AD4, 0xE993, 0x9AD8, 0x8D82, 0x9AD9, 0xFBFC,\r\n\t0x9ADC, 0xFC40, 0x9ADE, 0xE994, 0x9ADF, 0xE995, 0x9AE2, 0xE996,\t0x9AE3, 0xE997, 0x9AE6, 0xE998, 0x9AEA, 0x94AF, 0x9AEB, 0xE99A,\r\n\t0x9AED, 0x9545, 0x9AEE, 0xE99B, 0x9AEF, 0xE999, 0x9AF1, 0xE99D,\t0x9AF4, 0xE99C, 0x9AF7, 0xE99E, 0x9AFB, 0xE99F, 0x9B06, 0xE9A0,\r\n\t0x9B18, 0xE9A1, 0x9B1A, 0xE9A2, 0x9B1F, 0xE9A3, 0x9B22, 0xE9A4,\t0x9B23, 0xE9A5, 0x9B25, 0xE9A6, 0x9B27, 0xE9A7, 0x9B28, 0xE9A8,\r\n\t0x9B29, 0xE9A9, 0x9B2A, 0xE9AA, 0x9B2E, 0xE9AB, 0x9B2F, 0xE9AC,\t0x9B31, 0x9F54, 0x9B32, 0xE9AD, 0x9B3B, 0xE2F6, 0x9B3C, 0x8B53,\r\n\t0x9B41, 0x8A40, 0x9B42, 0x8DB0, 0x9B43, 0xE9AF, 0x9B44, 0xE9AE,\t0x9B45, 0x96A3, 0x9B4D, 0xE9B1, 0x9B4E, 0xE9B2, 0x9B4F, 0xE9B0,\r\n\t0x9B51, 0xE9B3, 0x9B54, 0x9682, 0x9B58, 0xE9B4, 0x9B5A, 0x8B9B,\t0x9B6F, 0x9844, 0x9B72, 0xFC42, 0x9B74, 0xE9B5, 0x9B75, 0xFC41,\r\n\t0x9B83, 0xE9B7, 0x9B8E, 0x88BC, 0x9B8F, 0xFC43, 0x9B91, 0xE9B8,\t0x9B92, 0x95A9, 0x9B93, 0xE9B6, 0x9B96, 0xE9B9, 0x9B97, 0xE9BA,\r\n\t0x9B9F, 0xE9BB, 0x9BA0, 0xE9BC, 0x9BA8, 0xE9BD, 0x9BAA, 0x968E,\t0x9BAB, 0x8E4C, 0x9BAD, 0x8DF8, 0x9BAE, 0x914E, 0x9BB1, 0xFC44,\r\n\t0x9BB4, 0xE9BE, 0x9BB9, 0xE9C1, 0x9BBB, 0xFC45, 0x9BC0, 0xE9BF,\t0x9BC6, 0xE9C2, 0x9BC9, 0x8CEF, 0x9BCA, 0xE9C0, 0x9BCF, 0xE9C3,\r\n\t0x9BD1, 0xE9C4, 0x9BD2, 0xE9C5, 0x9BD4, 0xE9C9, 0x9BD6, 0x8E49,\t0x9BDB, 0x91E2, 0x9BE1, 0xE9CA, 0x9BE2, 0xE9C7, 0x9BE3, 0xE9C6,\r\n\t0x9BE4, 0xE9C8, 0x9BE8, 0x8C7E, 0x9BF0, 0xE9CE, 0x9BF1, 0xE9CD,\t0x9BF2, 0xE9CC, 0x9BF5, 0x88B1, 0x9C00, 0xFC46, 0x9C04, 0xE9D8,\r\n\t0x9C06, 0xE9D4, 0x9C08, 0xE9D5, 0x9C09, 0xE9D1, 0x9C0A, 0xE9D7,\t0x9C0C, 0xE9D3, 0x9C0D, 0x8A82, 0x9C10, 0x986B, 0x9C12, 0xE9D6,\r\n\t0x9C13, 0xE9D2, 0x9C14, 0xE9D0, 0x9C15, 0xE9CF, 0x9C1B, 0xE9DA,\t0x9C21, 0xE9DD, 0x9C24, 0xE9DC, 0x9C25, 0xE9DB, 0x9C2D, 0x9568,\r\n\t0x9C2E, 0xE9D9, 0x9C2F, 0x88F1, 0x9C30, 0xE9DE, 0x9C32, 0xE9E0,\t0x9C39, 0x8A8F, 0x9C3A, 0xE9CB, 0x9C3B, 0x8956, 0x9C3E, 0xE9E2,\r\n\t0x9C46, 0xE9E1, 0x9C47, 0xE9DF, 0x9C48, 0x924C, 0x9C52, 0x9690,\t0x9C57, 0x97D8, 0x9C5A, 0xE9E3, 0x9C60, 0xE9E4, 0x9C67, 0xE9E5,\r\n\t0x9C76, 0xE9E6, 0x9C78, 0xE9E7, 0x9CE5, 0x92B9, 0x9CE7, 0xE9E8,\t0x9CE9, 0x94B5, 0x9CEB, 0xE9ED, 0x9CEC, 0xE9E9, 0x9CF0, 0xE9EA,\r\n\t0x9CF3, 0x9650, 0x9CF4, 0x96C2, 0x9CF6, 0x93CE, 0x9D03, 0xE9EE,\t0x9D06, 0xE9EF, 0x9D07, 0x93BC, 0x9D08, 0xE9EC, 0x9D09, 0xE9EB,\r\n\t0x9D0E, 0x89A8, 0x9D12, 0xE9F7, 0x9D15, 0xE9F6, 0x9D1B, 0x8995,\t0x9D1F, 0xE9F4, 0x9D23, 0xE9F3, 0x9D26, 0xE9F1, 0x9D28, 0x8A9B,\r\n\t0x9D2A, 0xE9F0, 0x9D2B, 0x8EB0, 0x9D2C, 0x89A7, 0x9D3B, 0x8D83,\t0x9D3E, 0xE9FA, 0x9D3F, 0xE9F9, 0x9D41, 0xE9F8, 0x9D44, 0xE9F5,\r\n\t0x9D46, 0xE9FB, 0x9D48, 0xE9FC, 0x9D50, 0xEA44, 0x9D51, 0xEA43,\t0x9D59, 0xEA45, 0x9D5C, 0x894C, 0x9D5D, 0xEA40, 0x9D5E, 0xEA41,\r\n\t0x9D60, 0x8D94, 0x9D61, 0x96B7, 0x9D64, 0xEA42, 0x9D6B, 0xFC48,\t0x9D6C, 0x9651, 0x9D6F, 0xEA4A, 0x9D70, 0xFC47, 0x9D72, 0xEA46,\r\n\t0x9D7A, 0xEA4B, 0x9D87, 0xEA48, 0x9D89, 0xEA47, 0x9D8F, 0x8C7B,\t0x9D9A, 0xEA4C, 0x9DA4, 0xEA4D, 0x9DA9, 0xEA4E, 0x9DAB, 0xEA49,\r\n\t0x9DAF, 0xE9F2, 0x9DB2, 0xEA4F, 0x9DB4, 0x92DF, 0x9DB8, 0xEA53,\t0x9DBA, 0xEA54, 0x9DBB, 0xEA52, 0x9DC1, 0xEA51, 0x9DC2, 0xEA57,\r\n\t0x9DC4, 0xEA50, 0x9DC6, 0xEA55, 0x9DCF, 0xEA56, 0x9DD3, 0xEA59,\t0x9DD9, 0xEA58, 0x9DE6, 0xEA5B, 0x9DED, 0xEA5C, 0x9DEF, 0xEA5D,\r\n\t0x9DF2, 0x9868, 0x9DF8, 0xEA5A, 0x9DF9, 0x91E9, 0x9DFA, 0x8DEB,\t0x9DFD, 0xEA5E, 0x9E19, 0xFC4A, 0x9E1A, 0xEA5F, 0x9E1B, 0xEA60,\r\n\t0x9E1E, 0xEA61, 0x9E75, 0xEA62, 0x9E78, 0x8CB2, 0x9E79, 0xEA63,\t0x9E7D, 0xEA64, 0x9E7F, 0x8EAD, 0x9E81, 0xEA65, 0x9E88, 0xEA66,\r\n\t0x9E8B, 0xEA67, 0x9E8C, 0xEA68, 0x9E91, 0xEA6B, 0x9E92, 0xEA69,\t0x9E93, 0x985B, 0x9E95, 0xEA6A, 0x9E97, 0x97ED, 0x9E9D, 0xEA6C,\r\n\t0x9E9F, 0x97D9, 0x9EA5, 0xEA6D, 0x9EA6, 0x949E, 0x9EA9, 0xEA6E,\t0x9EAA, 0xEA70, 0x9EAD, 0xEA71, 0x9EB8, 0xEA6F, 0x9EB9, 0x8D8D,\r\n\t0x9EBA, 0x96CB, 0x9EBB, 0x9683, 0x9EBC, 0x9BF5, 0x9EBE, 0x9F80,\t0x9EBF, 0x969B, 0x9EC4, 0x89A9, 0x9ECC, 0xEA73, 0x9ECD, 0x8B6F,\r\n\t0x9ECE, 0xEA74, 0x9ECF, 0xEA75, 0x9ED0, 0xEA76, 0x9ED1, 0xFC4B,\t0x9ED2, 0x8D95, 0x9ED4, 0xEA77, 0x9ED8, 0xE0D2, 0x9ED9, 0x96D9,\r\n\t0x9EDB, 0x91E1, 0x9EDC, 0xEA78, 0x9EDD, 0xEA7A, 0x9EDE, 0xEA79,\t0x9EE0, 0xEA7B, 0x9EE5, 0xEA7C, 0x9EE8, 0xEA7D, 0x9EEF, 0xEA7E,\r\n\t0x9EF4, 0xEA80, 0x9EF6, 0xEA81, 0x9EF7, 0xEA82, 0x9EF9, 0xEA83,\t0x9EFB, 0xEA84, 0x9EFC, 0xEA85, 0x9EFD, 0xEA86, 0x9F07, 0xEA87,\r\n\t0x9F08, 0xEA88, 0x9F0E, 0x9343, 0x9F13, 0x8CDB, 0x9F15, 0xEA8A,\t0x9F20, 0x916C, 0x9F21, 0xEA8B, 0x9F2C, 0xEA8C, 0x9F3B, 0x9540,\r\n\t0x9F3E, 0xEA8D, 0x9F4A, 0xEA8E, 0x9F4B, 0xE256, 0x9F4E, 0xE6D8,\t0x9F4F, 0xE8EB, 0x9F52, 0xEA8F, 0x9F54, 0xEA90, 0x9F5F, 0xEA92,\r\n\t0x9F60, 0xEA93, 0x9F61, 0xEA94, 0x9F62, 0x97EE, 0x9F63, 0xEA91,\t0x9F66, 0xEA95, 0x9F67, 0xEA96, 0x9F6A, 0xEA98, 0x9F6C, 0xEA97,\r\n\t0x9F72, 0xEA9A, 0x9F76, 0xEA9B, 0x9F77, 0xEA99, 0x9F8D, 0x97B4,\t0x9F95, 0xEA9C, 0x9F9C, 0xEA9D, 0x9F9D, 0xE273, 0x9FA0, 0xEA9E,\r\n\t0xF929, 0xFAE0, 0xF9DC, 0xFBE9, 0xFA0E, 0xFA90, 0xFA0F, 0xFA9B,\t0xFA10, 0xFA9C, 0xFA11, 0xFAB1, 0xFA12, 0xFAD8, 0xFA13, 0xFAE8,\r\n\t0xFA14, 0xFAEA, 0xFA15, 0xFB58, 0xFA16, 0xFB5E, 0xFA17, 0xFB75,\t0xFA18, 0xFB7D, 0xFA19, 0xFB7E, 0xFA1A, 0xFB80, 0xFA1B, 0xFB82,\r\n\t0xFA1C, 0xFB86, 0xFA1D, 0xFB89, 0xFA1E, 0xFB92, 0xFA1F, 0xFB9D,\t0xFA20, 0xFB9F, 0xFA21, 0xFBA0, 0xFA22, 0xFBA9, 0xFA23, 0xFBB1,\r\n\t0xFA24, 0xFBB3, 0xFA25, 0xFBB4, 0xFA26, 0xFBB7, 0xFA27, 0xFBD3,\t0xFA28, 0xFBDA, 0xFA29, 0xFBEA, 0xFA2A, 0xFBF6, 0xFA2B, 0xFBF7,\r\n\t0xFA2C, 0xFBF9, 0xFA2D, 0xFC49, 0xFF01, 0x8149, 0xFF02, 0xFA57,\t0xFF03, 0x8194, 0xFF04, 0x8190, 0xFF05, 0x8193, 0xFF06, 0x8195,\r\n\t0xFF07, 0xFA56, 0xFF08, 0x8169, 0xFF09, 0x816A, 0xFF0A, 0x8196,\t0xFF0B, 0x817B, 0xFF0C, 0x8143, 0xFF0D, 0x817C, 0xFF0E, 0x8144,\r\n\t0xFF0F, 0x815E, 0xFF10, 0x824F, 0xFF11, 0x8250, 0xFF12, 0x8251,\t0xFF13, 0x8252, 0xFF14, 0x8253, 0xFF15, 0x8254, 0xFF16, 0x8255,\r\n\t0xFF17, 0x8256, 0xFF18, 0x8257, 0xFF19, 0x8258, 0xFF1A, 0x8146,\t0xFF1B, 0x8147, 0xFF1C, 0x8183, 0xFF1D, 0x8181, 0xFF1E, 0x8184,\r\n\t0xFF1F, 0x8148, 0xFF20, 0x8197, 0xFF21, 0x8260, 0xFF22, 0x8261,\t0xFF23, 0x8262, 0xFF24, 0x8263, 0xFF25, 0x8264, 0xFF26, 0x8265,\r\n\t0xFF27, 0x8266, 0xFF28, 0x8267, 0xFF29, 0x8268, 0xFF2A, 0x8269,\t0xFF2B, 0x826A, 0xFF2C, 0x826B, 0xFF2D, 0x826C, 0xFF2E, 0x826D,\r\n\t0xFF2F, 0x826E, 0xFF30, 0x826F, 0xFF31, 0x8270, 0xFF32, 0x8271,\t0xFF33, 0x8272, 0xFF34, 0x8273, 0xFF35, 0x8274, 0xFF36, 0x8275,\r\n\t0xFF37, 0x8276, 0xFF38, 0x8277, 0xFF39, 0x8278, 0xFF3A, 0x8279,\t0xFF3B, 0x816D, 0xFF3C, 0x815F, 0xFF3D, 0x816E, 0xFF3E, 0x814F,\r\n\t0xFF3F, 0x8151, 0xFF40, 0x814D, 0xFF41, 0x8281, 0xFF42, 0x8282,\t0xFF43, 0x8283, 0xFF44, 0x8284, 0xFF45, 0x8285, 0xFF46, 0x8286,\r\n\t0xFF47, 0x8287, 0xFF48, 0x8288, 0xFF49, 0x8289, 0xFF4A, 0x828A,\t0xFF4B, 0x828B, 0xFF4C, 0x828C, 0xFF4D, 0x828D, 0xFF4E, 0x828E,\r\n\t0xFF4F, 0x828F, 0xFF50, 0x8290, 0xFF51, 0x8291, 0xFF52, 0x8292,\t0xFF53, 0x8293, 0xFF54, 0x8294, 0xFF55, 0x8295, 0xFF56, 0x8296,\r\n\t0xFF57, 0x8297, 0xFF58, 0x8298, 0xFF59, 0x8299, 0xFF5A, 0x829A,\t0xFF5B, 0x816F, 0xFF5C, 0x8162, 0xFF5D, 0x8170, 0xFF5E, 0x8160,\r\n\t0xFF61, 0x00A1, 0xFF62, 0x00A2, 0xFF63, 0x00A3, 0xFF64, 0x00A4,\t0xFF65, 0x00A5, 0xFF66, 0x00A6, 0xFF67, 0x00A7, 0xFF68, 0x00A8,\r\n\t0xFF69, 0x00A9, 0xFF6A, 0x00AA, 0xFF6B, 0x00AB, 0xFF6C, 0x00AC,\t0xFF6D, 0x00AD, 0xFF6E, 0x00AE, 0xFF6F, 0x00AF, 0xFF70, 0x00B0,\r\n\t0xFF71, 0x00B1, 0xFF72, 0x00B2, 0xFF73, 0x00B3, 0xFF74, 0x00B4,\t0xFF75, 0x00B5, 0xFF76, 0x00B6, 0xFF77, 0x00B7, 0xFF78, 0x00B8,\r\n\t0xFF79, 0x00B9, 0xFF7A, 0x00BA, 0xFF7B, 0x00BB, 0xFF7C, 0x00BC,\t0xFF7D, 0x00BD, 0xFF7E, 0x00BE, 0xFF7F, 0x00BF, 0xFF80, 0x00C0,\r\n\t0xFF81, 0x00C1, 0xFF82, 0x00C2, 0xFF83, 0x00C3, 0xFF84, 0x00C4,\t0xFF85, 0x00C5, 0xFF86, 0x00C6, 0xFF87, 0x00C7, 0xFF88, 0x00C8,\r\n\t0xFF89, 0x00C9, 0xFF8A, 0x00CA, 0xFF8B, 0x00CB, 0xFF8C, 0x00CC,\t0xFF8D, 0x00CD, 0xFF8E, 0x00CE, 0xFF8F, 0x00CF, 0xFF90, 0x00D0,\r\n\t0xFF91, 0x00D1, 0xFF92, 0x00D2, 0xFF93, 0x00D3, 0xFF94, 0x00D4,\t0xFF95, 0x00D5, 0xFF96, 0x00D6, 0xFF97, 0x00D7, 0xFF98, 0x00D8,\r\n\t0xFF99, 0x00D9, 0xFF9A, 0x00DA, 0xFF9B, 0x00DB, 0xFF9C, 0x00DC,\t0xFF9D, 0x00DD, 0xFF9E, 0x00DE, 0xFF9F, 0x00DF, 0xFFE0, 0x8191,\r\n\t0xFFE1, 0x8192, 0xFFE2, 0x81CA, 0xFFE3, 0x8150, 0xFFE4, 0xFA55,\t0xFFE5, 0x818F, 0, 0\r\n};\r\n\r\nstatic const WCHAR oem2uni932[] = {\t/* Shift_JIS --> Unicode pairs */\r\n\t0x00A1, 0xFF61, 0x00A2, 0xFF62, 0x00A3, 0xFF63, 0x00A4, 0xFF64,\t0x00A5, 0xFF65, 0x00A6, 0xFF66, 0x00A7, 0xFF67, 0x00A8, 0xFF68,\r\n\t0x00A9, 0xFF69, 0x00AA, 0xFF6A, 0x00AB, 0xFF6B, 0x00AC, 0xFF6C,\t0x00AD, 0xFF6D, 0x00AE, 0xFF6E, 0x00AF, 0xFF6F, 0x00B0, 0xFF70,\r\n\t0x00B1, 0xFF71, 0x00B2, 0xFF72, 0x00B3, 0xFF73, 0x00B4, 0xFF74,\t0x00B5, 0xFF75, 0x00B6, 0xFF76, 0x00B7, 0xFF77, 0x00B8, 0xFF78,\r\n\t0x00B9, 0xFF79, 0x00BA, 0xFF7A, 0x00BB, 0xFF7B, 0x00BC, 0xFF7C,\t0x00BD, 0xFF7D, 0x00BE, 0xFF7E, 0x00BF, 0xFF7F, 0x00C0, 0xFF80,\r\n\t0x00C1, 0xFF81, 0x00C2, 0xFF82, 0x00C3, 0xFF83, 0x00C4, 0xFF84,\t0x00C5, 0xFF85, 0x00C6, 0xFF86, 0x00C7, 0xFF87, 0x00C8, 0xFF88,\r\n\t0x00C9, 0xFF89, 0x00CA, 0xFF8A, 0x00CB, 0xFF8B, 0x00CC, 0xFF8C,\t0x00CD, 0xFF8D, 0x00CE, 0xFF8E, 0x00CF, 0xFF8F, 0x00D0, 0xFF90,\r\n\t0x00D1, 0xFF91, 0x00D2, 0xFF92, 0x00D3, 0xFF93, 0x00D4, 0xFF94,\t0x00D5, 0xFF95, 0x00D6, 0xFF96, 0x00D7, 0xFF97, 0x00D8, 0xFF98,\r\n\t0x00D9, 0xFF99, 0x00DA, 0xFF9A, 0x00DB, 0xFF9B, 0x00DC, 0xFF9C,\t0x00DD, 0xFF9D, 0x00DE, 0xFF9E, 0x00DF, 0xFF9F, 0x8140, 0x3000,\r\n\t0x8141, 0x3001, 0x8142, 0x3002, 0x8143, 0xFF0C, 0x8144, 0xFF0E,\t0x8145, 0x30FB, 0x8146, 0xFF1A, 0x8147, 0xFF1B, 0x8148, 0xFF1F,\r\n\t0x8149, 0xFF01, 0x814A, 0x309B, 0x814B, 0x309C, 0x814C, 0x00B4,\t0x814D, 0xFF40, 0x814E, 0x00A8, 0x814F, 0xFF3E, 0x8150, 0xFFE3,\r\n\t0x8151, 0xFF3F, 0x8152, 0x30FD, 0x8153, 0x30FE, 0x8154, 0x309D,\t0x8155, 0x309E, 0x8156, 0x3003, 0x8157, 0x4EDD, 0x8158, 0x3005,\r\n\t0x8159, 0x3006, 0x815A, 0x3007, 0x815B, 0x30FC, 0x815C, 0x2015,\t0x815D, 0x2010, 0x815E, 0xFF0F, 0x815F, 0xFF3C, 0x8160, 0xFF5E,\r\n\t0x8161, 0x2225, 0x8162, 0xFF5C, 0x8163, 0x2026, 0x8164, 0x2025,\t0x8165, 0x2018, 0x8166, 0x2019, 0x8167, 0x201C, 0x8168, 0x201D,\r\n\t0x8169, 0xFF08, 0x816A, 0xFF09, 0x816B, 0x3014, 0x816C, 0x3015,\t0x816D, 0xFF3B, 0x816E, 0xFF3D, 0x816F, 0xFF5B, 0x8170, 0xFF5D,\r\n\t0x8171, 0x3008, 0x8172, 0x3009, 0x8173, 0x300A, 0x8174, 0x300B,\t0x8175, 0x300C, 0x8176, 0x300D, 0x8177, 0x300E, 0x8178, 0x300F,\r\n\t0x8179, 0x3010, 0x817A, 0x3011, 0x817B, 0xFF0B, 0x817C, 0xFF0D,\t0x817D, 0x00B1, 0x817E, 0x00D7, 0x8180, 0x00F7, 0x8181, 0xFF1D,\r\n\t0x8182, 0x2260, 0x8183, 0xFF1C, 0x8184, 0xFF1E, 0x8185, 0x2266,\t0x8186, 0x2267, 0x8187, 0x221E, 0x8188, 0x2234, 0x8189, 0x2642,\r\n\t0x818A, 0x2640, 0x818B, 0x00B0, 0x818C, 0x2032, 0x818D, 0x2033,\t0x818E, 0x2103, 0x818F, 0xFFE5, 0x8190, 0xFF04, 0x8191, 0xFFE0,\r\n\t0x8192, 0xFFE1, 0x8193, 0xFF05, 0x8194, 0xFF03, 0x8195, 0xFF06,\t0x8196, 0xFF0A, 0x8197, 0xFF20, 0x8198, 0x00A7, 0x8199, 0x2606,\r\n\t0x819A, 0x2605, 0x819B, 0x25CB, 0x819C, 0x25CF, 0x819D, 0x25CE,\t0x819E, 0x25C7, 0x819F, 0x25C6, 0x81A0, 0x25A1, 0x81A1, 0x25A0,\r\n\t0x81A2, 0x25B3, 0x81A3, 0x25B2, 0x81A4, 0x25BD, 0x81A5, 0x25BC,\t0x81A6, 0x203B, 0x81A7, 0x3012, 0x81A8, 0x2192, 0x81A9, 0x2190,\r\n\t0x81AA, 0x2191, 0x81AB, 0x2193, 0x81AC, 0x3013, 0x81B8, 0x2208,\t0x81B9, 0x220B, 0x81BA, 0x2286, 0x81BB, 0x2287, 0x81BC, 0x2282,\r\n\t0x81BD, 0x2283, 0x81BE, 0x222A, 0x81BF, 0x2229, 0x81C8, 0x2227,\t0x81C9, 0x2228, 0x81CA, 0xFFE2, 0x81CB, 0x21D2, 0x81CC, 0x21D4,\r\n\t0x81CD, 0x2200, 0x81CE, 0x2203, 0x81DA, 0x2220, 0x81DB, 0x22A5,\t0x81DC, 0x2312, 0x81DD, 0x2202, 0x81DE, 0x2207, 0x81DF, 0x2261,\r\n\t0x81E0, 0x2252, 0x81E1, 0x226A, 0x81E2, 0x226B, 0x81E3, 0x221A,\t0x81E4, 0x223D, 0x81E5, 0x221D, 0x81E6, 0x2235, 0x81E7, 0x222B,\r\n\t0x81E8, 0x222C, 0x81F0, 0x212B, 0x81F1, 0x2030, 0x81F2, 0x266F,\t0x81F3, 0x266D, 0x81F4, 0x266A, 0x81F5, 0x2020, 0x81F6, 0x2021,\r\n\t0x81F7, 0x00B6, 0x81FC, 0x25EF, 0x824F, 0xFF10, 0x8250, 0xFF11,\t0x8251, 0xFF12, 0x8252, 0xFF13, 0x8253, 0xFF14, 0x8254, 0xFF15,\r\n\t0x8255, 0xFF16, 0x8256, 0xFF17, 0x8257, 0xFF18, 0x8258, 0xFF19,\t0x8260, 0xFF21, 0x8261, 0xFF22, 0x8262, 0xFF23, 0x8263, 0xFF24,\r\n\t0x8264, 0xFF25, 0x8265, 0xFF26, 0x8266, 0xFF27, 0x8267, 0xFF28,\t0x8268, 0xFF29, 0x8269, 0xFF2A, 0x826A, 0xFF2B, 0x826B, 0xFF2C,\r\n\t0x826C, 0xFF2D, 0x826D, 0xFF2E, 0x826E, 0xFF2F, 0x826F, 0xFF30,\t0x8270, 0xFF31, 0x8271, 0xFF32, 0x8272, 0xFF33, 0x8273, 0xFF34,\r\n\t0x8274, 0xFF35, 0x8275, 0xFF36, 0x8276, 0xFF37, 0x8277, 0xFF38,\t0x8278, 0xFF39, 0x8279, 0xFF3A, 0x8281, 0xFF41, 0x8282, 0xFF42,\r\n\t0x8283, 0xFF43, 0x8284, 0xFF44, 0x8285, 0xFF45, 0x8286, 0xFF46,\t0x8287, 0xFF47, 0x8288, 0xFF48, 0x8289, 0xFF49, 0x828A, 0xFF4A,\r\n\t0x828B, 0xFF4B, 0x828C, 0xFF4C, 0x828D, 0xFF4D, 0x828E, 0xFF4E,\t0x828F, 0xFF4F, 0x8290, 0xFF50, 0x8291, 0xFF51, 0x8292, 0xFF52,\r\n\t0x8293, 0xFF53, 0x8294, 0xFF54, 0x8295, 0xFF55, 0x8296, 0xFF56,\t0x8297, 0xFF57, 0x8298, 0xFF58, 0x8299, 0xFF59, 0x829A, 0xFF5A,\r\n\t0x829F, 0x3041, 0x82A0, 0x3042, 0x82A1, 0x3043, 0x82A2, 0x3044,\t0x82A3, 0x3045, 0x82A4, 0x3046, 0x82A5, 0x3047, 0x82A6, 0x3048,\r\n\t0x82A7, 0x3049, 0x82A8, 0x304A, 0x82A9, 0x304B, 0x82AA, 0x304C,\t0x82AB, 0x304D, 0x82AC, 0x304E, 0x82AD, 0x304F, 0x82AE, 0x3050,\r\n\t0x82AF, 0x3051, 0x82B0, 0x3052, 0x82B1, 0x3053, 0x82B2, 0x3054,\t0x82B3, 0x3055, 0x82B4, 0x3056, 0x82B5, 0x3057, 0x82B6, 0x3058,\r\n\t0x82B7, 0x3059, 0x82B8, 0x305A, 0x82B9, 0x305B, 0x82BA, 0x305C,\t0x82BB, 0x305D, 0x82BC, 0x305E, 0x82BD, 0x305F, 0x82BE, 0x3060,\r\n\t0x82BF, 0x3061, 0x82C0, 0x3062, 0x82C1, 0x3063, 0x82C2, 0x3064,\t0x82C3, 0x3065, 0x82C4, 0x3066, 0x82C5, 0x3067, 0x82C6, 0x3068,\r\n\t0x82C7, 0x3069, 0x82C8, 0x306A, 0x82C9, 0x306B, 0x82CA, 0x306C,\t0x82CB, 0x306D, 0x82CC, 0x306E, 0x82CD, 0x306F, 0x82CE, 0x3070,\r\n\t0x82CF, 0x3071, 0x82D0, 0x3072, 0x82D1, 0x3073, 0x82D2, 0x3074,\t0x82D3, 0x3075, 0x82D4, 0x3076, 0x82D5, 0x3077, 0x82D6, 0x3078,\r\n\t0x82D7, 0x3079, 0x82D8, 0x307A, 0x82D9, 0x307B, 0x82DA, 0x307C,\t0x82DB, 0x307D, 0x82DC, 0x307E, 0x82DD, 0x307F, 0x82DE, 0x3080,\r\n\t0x82DF, 0x3081, 0x82E0, 0x3082, 0x82E1, 0x3083, 0x82E2, 0x3084,\t0x82E3, 0x3085, 0x82E4, 0x3086, 0x82E5, 0x3087, 0x82E6, 0x3088,\r\n\t0x82E7, 0x3089, 0x82E8, 0x308A, 0x82E9, 0x308B, 0x82EA, 0x308C,\t0x82EB, 0x308D, 0x82EC, 0x308E, 0x82ED, 0x308F, 0x82EE, 0x3090,\r\n\t0x82EF, 0x3091, 0x82F0, 0x3092, 0x82F1, 0x3093, 0x8340, 0x30A1,\t0x8341, 0x30A2, 0x8342, 0x30A3, 0x8343, 0x30A4, 0x8344, 0x30A5,\r\n\t0x8345, 0x30A6, 0x8346, 0x30A7, 0x8347, 0x30A8, 0x8348, 0x30A9,\t0x8349, 0x30AA, 0x834A, 0x30AB, 0x834B, 0x30AC, 0x834C, 0x30AD,\r\n\t0x834D, 0x30AE, 0x834E, 0x30AF, 0x834F, 0x30B0, 0x8350, 0x30B1,\t0x8351, 0x30B2, 0x8352, 0x30B3, 0x8353, 0x30B4, 0x8354, 0x30B5,\r\n\t0x8355, 0x30B6, 0x8356, 0x30B7, 0x8357, 0x30B8, 0x8358, 0x30B9,\t0x8359, 0x30BA, 0x835A, 0x30BB, 0x835B, 0x30BC, 0x835C, 0x30BD,\r\n\t0x835D, 0x30BE, 0x835E, 0x30BF, 0x835F, 0x30C0, 0x8360, 0x30C1,\t0x8361, 0x30C2, 0x8362, 0x30C3, 0x8363, 0x30C4, 0x8364, 0x30C5,\r\n\t0x8365, 0x30C6, 0x8366, 0x30C7, 0x8367, 0x30C8, 0x8368, 0x30C9,\t0x8369, 0x30CA, 0x836A, 0x30CB, 0x836B, 0x30CC, 0x836C, 0x30CD,\r\n\t0x836D, 0x30CE, 0x836E, 0x30CF, 0x836F, 0x30D0, 0x8370, 0x30D1,\t0x8371, 0x30D2, 0x8372, 0x30D3, 0x8373, 0x30D4, 0x8374, 0x30D5,\r\n\t0x8375, 0x30D6, 0x8376, 0x30D7, 0x8377, 0x30D8, 0x8378, 0x30D9,\t0x8379, 0x30DA, 0x837A, 0x30DB, 0x837B, 0x30DC, 0x837C, 0x30DD,\r\n\t0x837D, 0x30DE, 0x837E, 0x30DF, 0x8380, 0x30E0, 0x8381, 0x30E1,\t0x8382, 0x30E2, 0x8383, 0x30E3, 0x8384, 0x30E4, 0x8385, 0x30E5,\r\n\t0x8386, 0x30E6, 0x8387, 0x30E7, 0x8388, 0x30E8, 0x8389, 0x30E9,\t0x838A, 0x30EA, 0x838B, 0x30EB, 0x838C, 0x30EC, 0x838D, 0x30ED,\r\n\t0x838E, 0x30EE, 0x838F, 0x30EF, 0x8390, 0x30F0, 0x8391, 0x30F1,\t0x8392, 0x30F2, 0x8393, 0x30F3, 0x8394, 0x30F4, 0x8395, 0x30F5,\r\n\t0x8396, 0x30F6, 0x839F, 0x0391, 0x83A0, 0x0392, 0x83A1, 0x0393,\t0x83A2, 0x0394, 0x83A3, 0x0395, 0x83A4, 0x0396, 0x83A5, 0x0397,\r\n\t0x83A6, 0x0398, 0x83A7, 0x0399, 0x83A8, 0x039A, 0x83A9, 0x039B,\t0x83AA, 0x039C, 0x83AB, 0x039D, 0x83AC, 0x039E, 0x83AD, 0x039F,\r\n\t0x83AE, 0x03A0, 0x83AF, 0x03A1, 0x83B0, 0x03A3, 0x83B1, 0x03A4,\t0x83B2, 0x03A5, 0x83B3, 0x03A6, 0x83B4, 0x03A7, 0x83B5, 0x03A8,\r\n\t0x83B6, 0x03A9, 0x83BF, 0x03B1, 0x83C0, 0x03B2, 0x83C1, 0x03B3,\t0x83C2, 0x03B4, 0x83C3, 0x03B5, 0x83C4, 0x03B6, 0x83C5, 0x03B7,\r\n\t0x83C6, 0x03B8, 0x83C7, 0x03B9, 0x83C8, 0x03BA, 0x83C9, 0x03BB,\t0x83CA, 0x03BC, 0x83CB, 0x03BD, 0x83CC, 0x03BE, 0x83CD, 0x03BF,\r\n\t0x83CE, 0x03C0, 0x83CF, 0x03C1, 0x83D0, 0x03C3, 0x83D1, 0x03C4,\t0x83D2, 0x03C5, 0x83D3, 0x03C6, 0x83D4, 0x03C7, 0x83D5, 0x03C8,\r\n\t0x83D6, 0x03C9, 0x8440, 0x0410, 0x8441, 0x0411, 0x8442, 0x0412,\t0x8443, 0x0413, 0x8444, 0x0414, 0x8445, 0x0415, 0x8446, 0x0401,\r\n\t0x8447, 0x0416, 0x8448, 0x0417, 0x8449, 0x0418, 0x844A, 0x0419,\t0x844B, 0x041A, 0x844C, 0x041B, 0x844D, 0x041C, 0x844E, 0x041D,\r\n\t0x844F, 0x041E, 0x8450, 0x041F, 0x8451, 0x0420, 0x8452, 0x0421,\t0x8453, 0x0422, 0x8454, 0x0423, 0x8455, 0x0424, 0x8456, 0x0425,\r\n\t0x8457, 0x0426, 0x8458, 0x0427, 0x8459, 0x0428, 0x845A, 0x0429,\t0x845B, 0x042A, 0x845C, 0x042B, 0x845D, 0x042C, 0x845E, 0x042D,\r\n\t0x845F, 0x042E, 0x8460, 0x042F, 0x8470, 0x0430, 0x8471, 0x0431,\t0x8472, 0x0432, 0x8473, 0x0433, 0x8474, 0x0434, 0x8475, 0x0435,\r\n\t0x8476, 0x0451, 0x8477, 0x0436, 0x8478, 0x0437, 0x8479, 0x0438,\t0x847A, 0x0439, 0x847B, 0x043A, 0x847C, 0x043B, 0x847D, 0x043C,\r\n\t0x847E, 0x043D, 0x8480, 0x043E, 0x8481, 0x043F, 0x8482, 0x0440,\t0x8483, 0x0441, 0x8484, 0x0442, 0x8485, 0x0443, 0x8486, 0x0444,\r\n\t0x8487, 0x0445, 0x8488, 0x0446, 0x8489, 0x0447, 0x848A, 0x0448,\t0x848B, 0x0449, 0x848C, 0x044A, 0x848D, 0x044B, 0x848E, 0x044C,\r\n\t0x848F, 0x044D, 0x8490, 0x044E, 0x8491, 0x044F, 0x849F, 0x2500,\t0x84A0, 0x2502, 0x84A1, 0x250C, 0x84A2, 0x2510, 0x84A3, 0x2518,\r\n\t0x84A4, 0x2514, 0x84A5, 0x251C, 0x84A6, 0x252C, 0x84A7, 0x2524,\t0x84A8, 0x2534, 0x84A9, 0x253C, 0x84AA, 0x2501, 0x84AB, 0x2503,\r\n\t0x84AC, 0x250F, 0x84AD, 0x2513, 0x84AE, 0x251B, 0x84AF, 0x2517,\t0x84B0, 0x2523, 0x84B1, 0x2533, 0x84B2, 0x252B, 0x84B3, 0x253B,\r\n\t0x84B4, 0x254B, 0x84B5, 0x2520, 0x84B6, 0x252F, 0x84B7, 0x2528,\t0x84B8, 0x2537, 0x84B9, 0x253F, 0x84BA, 0x251D, 0x84BB, 0x2530,\r\n\t0x84BC, 0x2525, 0x84BD, 0x2538, 0x84BE, 0x2542, 0x8740, 0x2460,\t0x8741, 0x2461, 0x8742, 0x2462, 0x8743, 0x2463, 0x8744, 0x2464,\r\n\t0x8745, 0x2465, 0x8746, 0x2466, 0x8747, 0x2467, 0x8748, 0x2468,\t0x8749, 0x2469, 0x874A, 0x246A, 0x874B, 0x246B, 0x874C, 0x246C,\r\n\t0x874D, 0x246D, 0x874E, 0x246E, 0x874F, 0x246F, 0x8750, 0x2470,\t0x8751, 0x2471, 0x8752, 0x2472, 0x8753, 0x2473, 0x8754, 0x2160,\r\n\t0x8755, 0x2161, 0x8756, 0x2162, 0x8757, 0x2163, 0x8758, 0x2164,\t0x8759, 0x2165, 0x875A, 0x2166, 0x875B, 0x2167, 0x875C, 0x2168,\r\n\t0x875D, 0x2169, 0x875F, 0x3349, 0x8760, 0x3314, 0x8761, 0x3322,\t0x8762, 0x334D, 0x8763, 0x3318, 0x8764, 0x3327, 0x8765, 0x3303,\r\n\t0x8766, 0x3336, 0x8767, 0x3351, 0x8768, 0x3357, 0x8769, 0x330D,\t0x876A, 0x3326, 0x876B, 0x3323, 0x876C, 0x332B, 0x876D, 0x334A,\r\n\t0x876E, 0x333B, 0x876F, 0x339C, 0x8770, 0x339D, 0x8771, 0x339E,\t0x8772, 0x338E, 0x8773, 0x338F, 0x8774, 0x33C4, 0x8775, 0x33A1,\r\n\t0x877E, 0x337B, 0x8780, 0x301D, 0x8781, 0x301F, 0x8782, 0x2116,\t0x8783, 0x33CD, 0x8784, 0x2121, 0x8785, 0x32A4, 0x8786, 0x32A5,\r\n\t0x8787, 0x32A6, 0x8788, 0x32A7, 0x8789, 0x32A8, 0x878A, 0x3231,\t0x878B, 0x3232, 0x878C, 0x3239, 0x878D, 0x337E, 0x878E, 0x337D,\r\n\t0x878F, 0x337C, 0x8793, 0x222E, 0x8794, 0x2211, 0x8798, 0x221F,\t0x8799, 0x22BF, 0x889F, 0x4E9C, 0x88A0, 0x5516, 0x88A1, 0x5A03,\r\n\t0x88A2, 0x963F, 0x88A3, 0x54C0, 0x88A4, 0x611B, 0x88A5, 0x6328,\t0x88A6, 0x59F6, 0x88A7, 0x9022, 0x88A8, 0x8475, 0x88A9, 0x831C,\r\n\t0x88AA, 0x7A50, 0x88AB, 0x60AA, 0x88AC, 0x63E1, 0x88AD, 0x6E25,\t0x88AE, 0x65ED, 0x88AF, 0x8466, 0x88B0, 0x82A6, 0x88B1, 0x9BF5,\r\n\t0x88B2, 0x6893, 0x88B3, 0x5727, 0x88B4, 0x65A1, 0x88B5, 0x6271,\t0x88B6, 0x5B9B, 0x88B7, 0x59D0, 0x88B8, 0x867B, 0x88B9, 0x98F4,\r\n\t0x88BA, 0x7D62, 0x88BB, 0x7DBE, 0x88BC, 0x9B8E, 0x88BD, 0x6216,\t0x88BE, 0x7C9F, 0x88BF, 0x88B7, 0x88C0, 0x5B89, 0x88C1, 0x5EB5,\r\n\t0x88C2, 0x6309, 0x88C3, 0x6697, 0x88C4, 0x6848, 0x88C5, 0x95C7,\t0x88C6, 0x978D, 0x88C7, 0x674F, 0x88C8, 0x4EE5, 0x88C9, 0x4F0A,\r\n\t0x88CA, 0x4F4D, 0x88CB, 0x4F9D, 0x88CC, 0x5049, 0x88CD, 0x56F2,\t0x88CE, 0x5937, 0x88CF, 0x59D4, 0x88D0, 0x5A01, 0x88D1, 0x5C09,\r\n\t0x88D2, 0x60DF, 0x88D3, 0x610F, 0x88D4, 0x6170, 0x88D5, 0x6613,\t0x88D6, 0x6905, 0x88D7, 0x70BA, 0x88D8, 0x754F, 0x88D9, 0x7570,\r\n\t0x88DA, 0x79FB, 0x88DB, 0x7DAD, 0x88DC, 0x7DEF, 0x88DD, 0x80C3,\t0x88DE, 0x840E, 0x88DF, 0x8863, 0x88E0, 0x8B02, 0x88E1, 0x9055,\r\n\t0x88E2, 0x907A, 0x88E3, 0x533B, 0x88E4, 0x4E95, 0x88E5, 0x4EA5,\t0x88E6, 0x57DF, 0x88E7, 0x80B2, 0x88E8, 0x90C1, 0x88E9, 0x78EF,\r\n\t0x88EA, 0x4E00, 0x88EB, 0x58F1, 0x88EC, 0x6EA2, 0x88ED, 0x9038,\t0x88EE, 0x7A32, 0x88EF, 0x8328, 0x88F0, 0x828B, 0x88F1, 0x9C2F,\r\n\t0x88F2, 0x5141, 0x88F3, 0x5370, 0x88F4, 0x54BD, 0x88F5, 0x54E1,\t0x88F6, 0x56E0, 0x88F7, 0x59FB, 0x88F8, 0x5F15, 0x88F9, 0x98F2,\r\n\t0x88FA, 0x6DEB, 0x88FB, 0x80E4, 0x88FC, 0x852D, 0x8940, 0x9662,\t0x8941, 0x9670, 0x8942, 0x96A0, 0x8943, 0x97FB, 0x8944, 0x540B,\r\n\t0x8945, 0x53F3, 0x8946, 0x5B87, 0x8947, 0x70CF, 0x8948, 0x7FBD,\t0x8949, 0x8FC2, 0x894A, 0x96E8, 0x894B, 0x536F, 0x894C, 0x9D5C,\r\n\t0x894D, 0x7ABA, 0x894E, 0x4E11, 0x894F, 0x7893, 0x8950, 0x81FC,\t0x8951, 0x6E26, 0x8952, 0x5618, 0x8953, 0x5504, 0x8954, 0x6B1D,\r\n\t0x8955, 0x851A, 0x8956, 0x9C3B, 0x8957, 0x59E5, 0x8958, 0x53A9,\t0x8959, 0x6D66, 0x895A, 0x74DC, 0x895B, 0x958F, 0x895C, 0x5642,\r\n\t0x895D, 0x4E91, 0x895E, 0x904B, 0x895F, 0x96F2, 0x8960, 0x834F,\t0x8961, 0x990C, 0x8962, 0x53E1, 0x8963, 0x55B6, 0x8964, 0x5B30,\r\n\t0x8965, 0x5F71, 0x8966, 0x6620, 0x8967, 0x66F3, 0x8968, 0x6804,\t0x8969, 0x6C38, 0x896A, 0x6CF3, 0x896B, 0x6D29, 0x896C, 0x745B,\r\n\t0x896D, 0x76C8, 0x896E, 0x7A4E, 0x896F, 0x9834, 0x8970, 0x82F1,\t0x8971, 0x885B, 0x8972, 0x8A60, 0x8973, 0x92ED, 0x8974, 0x6DB2,\r\n\t0x8975, 0x75AB, 0x8976, 0x76CA, 0x8977, 0x99C5, 0x8978, 0x60A6,\t0x8979, 0x8B01, 0x897A, 0x8D8A, 0x897B, 0x95B2, 0x897C, 0x698E,\r\n\t0x897D, 0x53AD, 0x897E, 0x5186, 0x8980, 0x5712, 0x8981, 0x5830,\t0x8982, 0x5944, 0x8983, 0x5BB4, 0x8984, 0x5EF6, 0x8985, 0x6028,\r\n\t0x8986, 0x63A9, 0x8987, 0x63F4, 0x8988, 0x6CBF, 0x8989, 0x6F14,\t0x898A, 0x708E, 0x898B, 0x7114, 0x898C, 0x7159, 0x898D, 0x71D5,\r\n\t0x898E, 0x733F, 0x898F, 0x7E01, 0x8990, 0x8276, 0x8991, 0x82D1,\t0x8992, 0x8597, 0x8993, 0x9060, 0x8994, 0x925B, 0x8995, 0x9D1B,\r\n\t0x8996, 0x5869, 0x8997, 0x65BC, 0x8998, 0x6C5A, 0x8999, 0x7525,\t0x899A, 0x51F9, 0x899B, 0x592E, 0x899C, 0x5965, 0x899D, 0x5F80,\r\n\t0x899E, 0x5FDC, 0x899F, 0x62BC, 0x89A0, 0x65FA, 0x89A1, 0x6A2A,\t0x89A2, 0x6B27, 0x89A3, 0x6BB4, 0x89A4, 0x738B, 0x89A5, 0x7FC1,\r\n\t0x89A6, 0x8956, 0x89A7, 0x9D2C, 0x89A8, 0x9D0E, 0x89A9, 0x9EC4,\t0x89AA, 0x5CA1, 0x89AB, 0x6C96, 0x89AC, 0x837B, 0x89AD, 0x5104,\r\n\t0x89AE, 0x5C4B, 0x89AF, 0x61B6, 0x89B0, 0x81C6, 0x89B1, 0x6876,\t0x89B2, 0x7261, 0x89B3, 0x4E59, 0x89B4, 0x4FFA, 0x89B5, 0x5378,\r\n\t0x89B6, 0x6069, 0x89B7, 0x6E29, 0x89B8, 0x7A4F, 0x89B9, 0x97F3,\t0x89BA, 0x4E0B, 0x89BB, 0x5316, 0x89BC, 0x4EEE, 0x89BD, 0x4F55,\r\n\t0x89BE, 0x4F3D, 0x89BF, 0x4FA1, 0x89C0, 0x4F73, 0x89C1, 0x52A0,\t0x89C2, 0x53EF, 0x89C3, 0x5609, 0x89C4, 0x590F, 0x89C5, 0x5AC1,\r\n\t0x89C6, 0x5BB6, 0x89C7, 0x5BE1, 0x89C8, 0x79D1, 0x89C9, 0x6687,\t0x89CA, 0x679C, 0x89CB, 0x67B6, 0x89CC, 0x6B4C, 0x89CD, 0x6CB3,\r\n\t0x89CE, 0x706B, 0x89CF, 0x73C2, 0x89D0, 0x798D, 0x89D1, 0x79BE,\t0x89D2, 0x7A3C, 0x89D3, 0x7B87, 0x89D4, 0x82B1, 0x89D5, 0x82DB,\r\n\t0x89D6, 0x8304, 0x89D7, 0x8377, 0x89D8, 0x83EF, 0x89D9, 0x83D3,\t0x89DA, 0x8766, 0x89DB, 0x8AB2, 0x89DC, 0x5629, 0x89DD, 0x8CA8,\r\n\t0x89DE, 0x8FE6, 0x89DF, 0x904E, 0x89E0, 0x971E, 0x89E1, 0x868A,\t0x89E2, 0x4FC4, 0x89E3, 0x5CE8, 0x89E4, 0x6211, 0x89E5, 0x7259,\r\n\t0x89E6, 0x753B, 0x89E7, 0x81E5, 0x89E8, 0x82BD, 0x89E9, 0x86FE,\t0x89EA, 0x8CC0, 0x89EB, 0x96C5, 0x89EC, 0x9913, 0x89ED, 0x99D5,\r\n\t0x89EE, 0x4ECB, 0x89EF, 0x4F1A, 0x89F0, 0x89E3, 0x89F1, 0x56DE,\t0x89F2, 0x584A, 0x89F3, 0x58CA, 0x89F4, 0x5EFB, 0x89F5, 0x5FEB,\r\n\t0x89F6, 0x602A, 0x89F7, 0x6094, 0x89F8, 0x6062, 0x89F9, 0x61D0,\t0x89FA, 0x6212, 0x89FB, 0x62D0, 0x89FC, 0x6539, 0x8A40, 0x9B41,\r\n\t0x8A41, 0x6666, 0x8A42, 0x68B0, 0x8A43, 0x6D77, 0x8A44, 0x7070,\t0x8A45, 0x754C, 0x8A46, 0x7686, 0x8A47, 0x7D75, 0x8A48, 0x82A5,\r\n\t0x8A49, 0x87F9, 0x8A4A, 0x958B, 0x8A4B, 0x968E, 0x8A4C, 0x8C9D,\t0x8A4D, 0x51F1, 0x8A4E, 0x52BE, 0x8A4F, 0x5916, 0x8A50, 0x54B3,\r\n\t0x8A51, 0x5BB3, 0x8A52, 0x5D16, 0x8A53, 0x6168, 0x8A54, 0x6982,\t0x8A55, 0x6DAF, 0x8A56, 0x788D, 0x8A57, 0x84CB, 0x8A58, 0x8857,\r\n\t0x8A59, 0x8A72, 0x8A5A, 0x93A7, 0x8A5B, 0x9AB8, 0x8A5C, 0x6D6C,\t0x8A5D, 0x99A8, 0x8A5E, 0x86D9, 0x8A5F, 0x57A3, 0x8A60, 0x67FF,\r\n\t0x8A61, 0x86CE, 0x8A62, 0x920E, 0x8A63, 0x5283, 0x8A64, 0x5687,\t0x8A65, 0x5404, 0x8A66, 0x5ED3, 0x8A67, 0x62E1, 0x8A68, 0x64B9,\r\n\t0x8A69, 0x683C, 0x8A6A, 0x6838, 0x8A6B, 0x6BBB, 0x8A6C, 0x7372,\t0x8A6D, 0x78BA, 0x8A6E, 0x7A6B, 0x8A6F, 0x899A, 0x8A70, 0x89D2,\r\n\t0x8A71, 0x8D6B, 0x8A72, 0x8F03, 0x8A73, 0x90ED, 0x8A74, 0x95A3,\t0x8A75, 0x9694, 0x8A76, 0x9769, 0x8A77, 0x5B66, 0x8A78, 0x5CB3,\r\n\t0x8A79, 0x697D, 0x8A7A, 0x984D, 0x8A7B, 0x984E, 0x8A7C, 0x639B,\t0x8A7D, 0x7B20, 0x8A7E, 0x6A2B, 0x8A80, 0x6A7F, 0x8A81, 0x68B6,\r\n\t0x8A82, 0x9C0D, 0x8A83, 0x6F5F, 0x8A84, 0x5272, 0x8A85, 0x559D,\t0x8A86, 0x6070, 0x8A87, 0x62EC, 0x8A88, 0x6D3B, 0x8A89, 0x6E07,\r\n\t0x8A8A, 0x6ED1, 0x8A8B, 0x845B, 0x8A8C, 0x8910, 0x8A8D, 0x8F44,\t0x8A8E, 0x4E14, 0x8A8F, 0x9C39, 0x8A90, 0x53F6, 0x8A91, 0x691B,\r\n\t0x8A92, 0x6A3A, 0x8A93, 0x9784, 0x8A94, 0x682A, 0x8A95, 0x515C,\t0x8A96, 0x7AC3, 0x8A97, 0x84B2, 0x8A98, 0x91DC, 0x8A99, 0x938C,\r\n\t0x8A9A, 0x565B, 0x8A9B, 0x9D28, 0x8A9C, 0x6822, 0x8A9D, 0x8305,\t0x8A9E, 0x8431, 0x8A9F, 0x7CA5, 0x8AA0, 0x5208, 0x8AA1, 0x82C5,\r\n\t0x8AA2, 0x74E6, 0x8AA3, 0x4E7E, 0x8AA4, 0x4F83, 0x8AA5, 0x51A0,\t0x8AA6, 0x5BD2, 0x8AA7, 0x520A, 0x8AA8, 0x52D8, 0x8AA9, 0x52E7,\r\n\t0x8AAA, 0x5DFB, 0x8AAB, 0x559A, 0x8AAC, 0x582A, 0x8AAD, 0x59E6,\t0x8AAE, 0x5B8C, 0x8AAF, 0x5B98, 0x8AB0, 0x5BDB, 0x8AB1, 0x5E72,\r\n\t0x8AB2, 0x5E79, 0x8AB3, 0x60A3, 0x8AB4, 0x611F, 0x8AB5, 0x6163,\t0x8AB6, 0x61BE, 0x8AB7, 0x63DB, 0x8AB8, 0x6562, 0x8AB9, 0x67D1,\r\n\t0x8ABA, 0x6853, 0x8ABB, 0x68FA, 0x8ABC, 0x6B3E, 0x8ABD, 0x6B53,\t0x8ABE, 0x6C57, 0x8ABF, 0x6F22, 0x8AC0, 0x6F97, 0x8AC1, 0x6F45,\r\n\t0x8AC2, 0x74B0, 0x8AC3, 0x7518, 0x8AC4, 0x76E3, 0x8AC5, 0x770B,\t0x8AC6, 0x7AFF, 0x8AC7, 0x7BA1, 0x8AC8, 0x7C21, 0x8AC9, 0x7DE9,\r\n\t0x8ACA, 0x7F36, 0x8ACB, 0x7FF0, 0x8ACC, 0x809D, 0x8ACD, 0x8266,\t0x8ACE, 0x839E, 0x8ACF, 0x89B3, 0x8AD0, 0x8ACC, 0x8AD1, 0x8CAB,\r\n\t0x8AD2, 0x9084, 0x8AD3, 0x9451, 0x8AD4, 0x9593, 0x8AD5, 0x9591,\t0x8AD6, 0x95A2, 0x8AD7, 0x9665, 0x8AD8, 0x97D3, 0x8AD9, 0x9928,\r\n\t0x8ADA, 0x8218, 0x8ADB, 0x4E38, 0x8ADC, 0x542B, 0x8ADD, 0x5CB8,\t0x8ADE, 0x5DCC, 0x8ADF, 0x73A9, 0x8AE0, 0x764C, 0x8AE1, 0x773C,\r\n\t0x8AE2, 0x5CA9, 0x8AE3, 0x7FEB, 0x8AE4, 0x8D0B, 0x8AE5, 0x96C1,\t0x8AE6, 0x9811, 0x8AE7, 0x9854, 0x8AE8, 0x9858, 0x8AE9, 0x4F01,\r\n\t0x8AEA, 0x4F0E, 0x8AEB, 0x5371, 0x8AEC, 0x559C, 0x8AED, 0x5668,\t0x8AEE, 0x57FA, 0x8AEF, 0x5947, 0x8AF0, 0x5B09, 0x8AF1, 0x5BC4,\r\n\t0x8AF2, 0x5C90, 0x8AF3, 0x5E0C, 0x8AF4, 0x5E7E, 0x8AF5, 0x5FCC,\t0x8AF6, 0x63EE, 0x8AF7, 0x673A, 0x8AF8, 0x65D7, 0x8AF9, 0x65E2,\r\n\t0x8AFA, 0x671F, 0x8AFB, 0x68CB, 0x8AFC, 0x68C4, 0x8B40, 0x6A5F,\t0x8B41, 0x5E30, 0x8B42, 0x6BC5, 0x8B43, 0x6C17, 0x8B44, 0x6C7D,\r\n\t0x8B45, 0x757F, 0x8B46, 0x7948, 0x8B47, 0x5B63, 0x8B48, 0x7A00,\t0x8B49, 0x7D00, 0x8B4A, 0x5FBD, 0x8B4B, 0x898F, 0x8B4C, 0x8A18,\r\n\t0x8B4D, 0x8CB4, 0x8B4E, 0x8D77, 0x8B4F, 0x8ECC, 0x8B50, 0x8F1D,\t0x8B51, 0x98E2, 0x8B52, 0x9A0E, 0x8B53, 0x9B3C, 0x8B54, 0x4E80,\r\n\t0x8B55, 0x507D, 0x8B56, 0x5100, 0x8B57, 0x5993, 0x8B58, 0x5B9C,\t0x8B59, 0x622F, 0x8B5A, 0x6280, 0x8B5B, 0x64EC, 0x8B5C, 0x6B3A,\r\n\t0x8B5D, 0x72A0, 0x8B5E, 0x7591, 0x8B5F, 0x7947, 0x8B60, 0x7FA9,\t0x8B61, 0x87FB, 0x8B62, 0x8ABC, 0x8B63, 0x8B70, 0x8B64, 0x63AC,\r\n\t0x8B65, 0x83CA, 0x8B66, 0x97A0, 0x8B67, 0x5409, 0x8B68, 0x5403,\t0x8B69, 0x55AB, 0x8B6A, 0x6854, 0x8B6B, 0x6A58, 0x8B6C, 0x8A70,\r\n\t0x8B6D, 0x7827, 0x8B6E, 0x6775, 0x8B6F, 0x9ECD, 0x8B70, 0x5374,\t0x8B71, 0x5BA2, 0x8B72, 0x811A, 0x8B73, 0x8650, 0x8B74, 0x9006,\r\n\t0x8B75, 0x4E18, 0x8B76, 0x4E45, 0x8B77, 0x4EC7, 0x8B78, 0x4F11,\t0x8B79, 0x53CA, 0x8B7A, 0x5438, 0x8B7B, 0x5BAE, 0x8B7C, 0x5F13,\r\n\t0x8B7D, 0x6025, 0x8B7E, 0x6551, 0x8B80, 0x673D, 0x8B81, 0x6C42,\t0x8B82, 0x6C72, 0x8B83, 0x6CE3, 0x8B84, 0x7078, 0x8B85, 0x7403,\r\n\t0x8B86, 0x7A76, 0x8B87, 0x7AAE, 0x8B88, 0x7B08, 0x8B89, 0x7D1A,\t0x8B8A, 0x7CFE, 0x8B8B, 0x7D66, 0x8B8C, 0x65E7, 0x8B8D, 0x725B,\r\n\t0x8B8E, 0x53BB, 0x8B8F, 0x5C45, 0x8B90, 0x5DE8, 0x8B91, 0x62D2,\t0x8B92, 0x62E0, 0x8B93, 0x6319, 0x8B94, 0x6E20, 0x8B95, 0x865A,\r\n\t0x8B96, 0x8A31, 0x8B97, 0x8DDD, 0x8B98, 0x92F8, 0x8B99, 0x6F01,\t0x8B9A, 0x79A6, 0x8B9B, 0x9B5A, 0x8B9C, 0x4EA8, 0x8B9D, 0x4EAB,\r\n\t0x8B9E, 0x4EAC, 0x8B9F, 0x4F9B, 0x8BA0, 0x4FA0, 0x8BA1, 0x50D1,\t0x8BA2, 0x5147, 0x8BA3, 0x7AF6, 0x8BA4, 0x5171, 0x8BA5, 0x51F6,\r\n\t0x8BA6, 0x5354, 0x8BA7, 0x5321, 0x8BA8, 0x537F, 0x8BA9, 0x53EB,\t0x8BAA, 0x55AC, 0x8BAB, 0x5883, 0x8BAC, 0x5CE1, 0x8BAD, 0x5F37,\r\n\t0x8BAE, 0x5F4A, 0x8BAF, 0x602F, 0x8BB0, 0x6050, 0x8BB1, 0x606D,\t0x8BB2, 0x631F, 0x8BB3, 0x6559, 0x8BB4, 0x6A4B, 0x8BB5, 0x6CC1,\r\n\t0x8BB6, 0x72C2, 0x8BB7, 0x72ED, 0x8BB8, 0x77EF, 0x8BB9, 0x80F8,\t0x8BBA, 0x8105, 0x8BBB, 0x8208, 0x8BBC, 0x854E, 0x8BBD, 0x90F7,\r\n\t0x8BBE, 0x93E1, 0x8BBF, 0x97FF, 0x8BC0, 0x9957, 0x8BC1, 0x9A5A,\t0x8BC2, 0x4EF0, 0x8BC3, 0x51DD, 0x8BC4, 0x5C2D, 0x8BC5, 0x6681,\r\n\t0x8BC6, 0x696D, 0x8BC7, 0x5C40, 0x8BC8, 0x66F2, 0x8BC9, 0x6975,\t0x8BCA, 0x7389, 0x8BCB, 0x6850, 0x8BCC, 0x7C81, 0x8BCD, 0x50C5,\r\n\t0x8BCE, 0x52E4, 0x8BCF, 0x5747, 0x8BD0, 0x5DFE, 0x8BD1, 0x9326,\t0x8BD2, 0x65A4, 0x8BD3, 0x6B23, 0x8BD4, 0x6B3D, 0x8BD5, 0x7434,\r\n\t0x8BD6, 0x7981, 0x8BD7, 0x79BD, 0x8BD8, 0x7B4B, 0x8BD9, 0x7DCA,\t0x8BDA, 0x82B9, 0x8BDB, 0x83CC, 0x8BDC, 0x887F, 0x8BDD, 0x895F,\r\n\t0x8BDE, 0x8B39, 0x8BDF, 0x8FD1, 0x8BE0, 0x91D1, 0x8BE1, 0x541F,\t0x8BE2, 0x9280, 0x8BE3, 0x4E5D, 0x8BE4, 0x5036, 0x8BE5, 0x53E5,\r\n\t0x8BE6, 0x533A, 0x8BE7, 0x72D7, 0x8BE8, 0x7396, 0x8BE9, 0x77E9,\t0x8BEA, 0x82E6, 0x8BEB, 0x8EAF, 0x8BEC, 0x99C6, 0x8BED, 0x99C8,\r\n\t0x8BEE, 0x99D2, 0x8BEF, 0x5177, 0x8BF0, 0x611A, 0x8BF1, 0x865E,\t0x8BF2, 0x55B0, 0x8BF3, 0x7A7A, 0x8BF4, 0x5076, 0x8BF5, 0x5BD3,\r\n\t0x8BF6, 0x9047, 0x8BF7, 0x9685, 0x8BF8, 0x4E32, 0x8BF9, 0x6ADB,\t0x8BFA, 0x91E7, 0x8BFB, 0x5C51, 0x8BFC, 0x5C48, 0x8C40, 0x6398,\r\n\t0x8C41, 0x7A9F, 0x8C42, 0x6C93, 0x8C43, 0x9774, 0x8C44, 0x8F61,\t0x8C45, 0x7AAA, 0x8C46, 0x718A, 0x8C47, 0x9688, 0x8C48, 0x7C82,\r\n\t0x8C49, 0x6817, 0x8C4A, 0x7E70, 0x8C4B, 0x6851, 0x8C4C, 0x936C,\t0x8C4D, 0x52F2, 0x8C4E, 0x541B, 0x8C4F, 0x85AB, 0x8C50, 0x8A13,\r\n\t0x8C51, 0x7FA4, 0x8C52, 0x8ECD, 0x8C53, 0x90E1, 0x8C54, 0x5366,\t0x8C55, 0x8888, 0x8C56, 0x7941, 0x8C57, 0x4FC2, 0x8C58, 0x50BE,\r\n\t0x8C59, 0x5211, 0x8C5A, 0x5144, 0x8C5B, 0x5553, 0x8C5C, 0x572D,\t0x8C5D, 0x73EA, 0x8C5E, 0x578B, 0x8C5F, 0x5951, 0x8C60, 0x5F62,\r\n\t0x8C61, 0x5F84, 0x8C62, 0x6075, 0x8C63, 0x6176, 0x8C64, 0x6167,\t0x8C65, 0x61A9, 0x8C66, 0x63B2, 0x8C67, 0x643A, 0x8C68, 0x656C,\r\n\t0x8C69, 0x666F, 0x8C6A, 0x6842, 0x8C6B, 0x6E13, 0x8C6C, 0x7566,\t0x8C6D, 0x7A3D, 0x8C6E, 0x7CFB, 0x8C6F, 0x7D4C, 0x8C70, 0x7D99,\r\n\t0x8C71, 0x7E4B, 0x8C72, 0x7F6B, 0x8C73, 0x830E, 0x8C74, 0x834A,\t0x8C75, 0x86CD, 0x8C76, 0x8A08, 0x8C77, 0x8A63, 0x8C78, 0x8B66,\r\n\t0x8C79, 0x8EFD, 0x8C7A, 0x981A, 0x8C7B, 0x9D8F, 0x8C7C, 0x82B8,\t0x8C7D, 0x8FCE, 0x8C7E, 0x9BE8, 0x8C80, 0x5287, 0x8C81, 0x621F,\r\n\t0x8C82, 0x6483, 0x8C83, 0x6FC0, 0x8C84, 0x9699, 0x8C85, 0x6841,\t0x8C86, 0x5091, 0x8C87, 0x6B20, 0x8C88, 0x6C7A, 0x8C89, 0x6F54,\r\n\t0x8C8A, 0x7A74, 0x8C8B, 0x7D50, 0x8C8C, 0x8840, 0x8C8D, 0x8A23,\t0x8C8E, 0x6708, 0x8C8F, 0x4EF6, 0x8C90, 0x5039, 0x8C91, 0x5026,\r\n\t0x8C92, 0x5065, 0x8C93, 0x517C, 0x8C94, 0x5238, 0x8C95, 0x5263,\t0x8C96, 0x55A7, 0x8C97, 0x570F, 0x8C98, 0x5805, 0x8C99, 0x5ACC,\r\n\t0x8C9A, 0x5EFA, 0x8C9B, 0x61B2, 0x8C9C, 0x61F8, 0x8C9D, 0x62F3,\t0x8C9E, 0x6372, 0x8C9F, 0x691C, 0x8CA0, 0x6A29, 0x8CA1, 0x727D,\r\n\t0x8CA2, 0x72AC, 0x8CA3, 0x732E, 0x8CA4, 0x7814, 0x8CA5, 0x786F,\t0x8CA6, 0x7D79, 0x8CA7, 0x770C, 0x8CA8, 0x80A9, 0x8CA9, 0x898B,\r\n\t0x8CAA, 0x8B19, 0x8CAB, 0x8CE2, 0x8CAC, 0x8ED2, 0x8CAD, 0x9063,\t0x8CAE, 0x9375, 0x8CAF, 0x967A, 0x8CB0, 0x9855, 0x8CB1, 0x9A13,\r\n\t0x8CB2, 0x9E78, 0x8CB3, 0x5143, 0x8CB4, 0x539F, 0x8CB5, 0x53B3,\t0x8CB6, 0x5E7B, 0x8CB7, 0x5F26, 0x8CB8, 0x6E1B, 0x8CB9, 0x6E90,\r\n\t0x8CBA, 0x7384, 0x8CBB, 0x73FE, 0x8CBC, 0x7D43, 0x8CBD, 0x8237,\t0x8CBE, 0x8A00, 0x8CBF, 0x8AFA, 0x8CC0, 0x9650, 0x8CC1, 0x4E4E,\r\n\t0x8CC2, 0x500B, 0x8CC3, 0x53E4, 0x8CC4, 0x547C, 0x8CC5, 0x56FA,\t0x8CC6, 0x59D1, 0x8CC7, 0x5B64, 0x8CC8, 0x5DF1, 0x8CC9, 0x5EAB,\r\n\t0x8CCA, 0x5F27, 0x8CCB, 0x6238, 0x8CCC, 0x6545, 0x8CCD, 0x67AF,\t0x8CCE, 0x6E56, 0x8CCF, 0x72D0, 0x8CD0, 0x7CCA, 0x8CD1, 0x88B4,\r\n\t0x8CD2, 0x80A1, 0x8CD3, 0x80E1, 0x8CD4, 0x83F0, 0x8CD5, 0x864E,\t0x8CD6, 0x8A87, 0x8CD7, 0x8DE8, 0x8CD8, 0x9237, 0x8CD9, 0x96C7,\r\n\t0x8CDA, 0x9867, 0x8CDB, 0x9F13, 0x8CDC, 0x4E94, 0x8CDD, 0x4E92,\t0x8CDE, 0x4F0D, 0x8CDF, 0x5348, 0x8CE0, 0x5449, 0x8CE1, 0x543E,\r\n\t0x8CE2, 0x5A2F, 0x8CE3, 0x5F8C, 0x8CE4, 0x5FA1, 0x8CE5, 0x609F,\t0x8CE6, 0x68A7, 0x8CE7, 0x6A8E, 0x8CE8, 0x745A, 0x8CE9, 0x7881,\r\n\t0x8CEA, 0x8A9E, 0x8CEB, 0x8AA4, 0x8CEC, 0x8B77, 0x8CED, 0x9190,\t0x8CEE, 0x4E5E, 0x8CEF, 0x9BC9, 0x8CF0, 0x4EA4, 0x8CF1, 0x4F7C,\r\n\t0x8CF2, 0x4FAF, 0x8CF3, 0x5019, 0x8CF4, 0x5016, 0x8CF5, 0x5149,\t0x8CF6, 0x516C, 0x8CF7, 0x529F, 0x8CF8, 0x52B9, 0x8CF9, 0x52FE,\r\n\t0x8CFA, 0x539A, 0x8CFB, 0x53E3, 0x8CFC, 0x5411, 0x8D40, 0x540E,\t0x8D41, 0x5589, 0x8D42, 0x5751, 0x8D43, 0x57A2, 0x8D44, 0x597D,\r\n\t0x8D45, 0x5B54, 0x8D46, 0x5B5D, 0x8D47, 0x5B8F, 0x8D48, 0x5DE5,\t0x8D49, 0x5DE7, 0x8D4A, 0x5DF7, 0x8D4B, 0x5E78, 0x8D4C, 0x5E83,\r\n\t0x8D4D, 0x5E9A, 0x8D4E, 0x5EB7, 0x8D4F, 0x5F18, 0x8D50, 0x6052,\t0x8D51, 0x614C, 0x8D52, 0x6297, 0x8D53, 0x62D8, 0x8D54, 0x63A7,\r\n\t0x8D55, 0x653B, 0x8D56, 0x6602, 0x8D57, 0x6643, 0x8D58, 0x66F4,\t0x8D59, 0x676D, 0x8D5A, 0x6821, 0x8D5B, 0x6897, 0x8D5C, 0x69CB,\r\n\t0x8D5D, 0x6C5F, 0x8D5E, 0x6D2A, 0x8D5F, 0x6D69, 0x8D60, 0x6E2F,\t0x8D61, 0x6E9D, 0x8D62, 0x7532, 0x8D63, 0x7687, 0x8D64, 0x786C,\r\n\t0x8D65, 0x7A3F, 0x8D66, 0x7CE0, 0x8D67, 0x7D05, 0x8D68, 0x7D18,\t0x8D69, 0x7D5E, 0x8D6A, 0x7DB1, 0x8D6B, 0x8015, 0x8D6C, 0x8003,\r\n\t0x8D6D, 0x80AF, 0x8D6E, 0x80B1, 0x8D6F, 0x8154, 0x8D70, 0x818F,\t0x8D71, 0x822A, 0x8D72, 0x8352, 0x8D73, 0x884C, 0x8D74, 0x8861,\r\n\t0x8D75, 0x8B1B, 0x8D76, 0x8CA2, 0x8D77, 0x8CFC, 0x8D78, 0x90CA,\t0x8D79, 0x9175, 0x8D7A, 0x9271, 0x8D7B, 0x783F, 0x8D7C, 0x92FC,\r\n\t0x8D7D, 0x95A4, 0x8D7E, 0x964D, 0x8D80, 0x9805, 0x8D81, 0x9999,\t0x8D82, 0x9AD8, 0x8D83, 0x9D3B, 0x8D84, 0x525B, 0x8D85, 0x52AB,\r\n\t0x8D86, 0x53F7, 0x8D87, 0x5408, 0x8D88, 0x58D5, 0x8D89, 0x62F7,\t0x8D8A, 0x6FE0, 0x8D8B, 0x8C6A, 0x8D8C, 0x8F5F, 0x8D8D, 0x9EB9,\r\n\t0x8D8E, 0x514B, 0x8D8F, 0x523B, 0x8D90, 0x544A, 0x8D91, 0x56FD,\t0x8D92, 0x7A40, 0x8D93, 0x9177, 0x8D94, 0x9D60, 0x8D95, 0x9ED2,\r\n\t0x8D96, 0x7344, 0x8D97, 0x6F09, 0x8D98, 0x8170, 0x8D99, 0x7511,\t0x8D9A, 0x5FFD, 0x8D9B, 0x60DA, 0x8D9C, 0x9AA8, 0x8D9D, 0x72DB,\r\n\t0x8D9E, 0x8FBC, 0x8D9F, 0x6B64, 0x8DA0, 0x9803, 0x8DA1, 0x4ECA,\t0x8DA2, 0x56F0, 0x8DA3, 0x5764, 0x8DA4, 0x58BE, 0x8DA5, 0x5A5A,\r\n\t0x8DA6, 0x6068, 0x8DA7, 0x61C7, 0x8DA8, 0x660F, 0x8DA9, 0x6606,\t0x8DAA, 0x6839, 0x8DAB, 0x68B1, 0x8DAC, 0x6DF7, 0x8DAD, 0x75D5,\r\n\t0x8DAE, 0x7D3A, 0x8DAF, 0x826E, 0x8DB0, 0x9B42, 0x8DB1, 0x4E9B,\t0x8DB2, 0x4F50, 0x8DB3, 0x53C9, 0x8DB4, 0x5506, 0x8DB5, 0x5D6F,\r\n\t0x8DB6, 0x5DE6, 0x8DB7, 0x5DEE, 0x8DB8, 0x67FB, 0x8DB9, 0x6C99,\t0x8DBA, 0x7473, 0x8DBB, 0x7802, 0x8DBC, 0x8A50, 0x8DBD, 0x9396,\r\n\t0x8DBE, 0x88DF, 0x8DBF, 0x5750, 0x8DC0, 0x5EA7, 0x8DC1, 0x632B,\t0x8DC2, 0x50B5, 0x8DC3, 0x50AC, 0x8DC4, 0x518D, 0x8DC5, 0x6700,\r\n\t0x8DC6, 0x54C9, 0x8DC7, 0x585E, 0x8DC8, 0x59BB, 0x8DC9, 0x5BB0,\t0x8DCA, 0x5F69, 0x8DCB, 0x624D, 0x8DCC, 0x63A1, 0x8DCD, 0x683D,\r\n\t0x8DCE, 0x6B73, 0x8DCF, 0x6E08, 0x8DD0, 0x707D, 0x8DD1, 0x91C7,\t0x8DD2, 0x7280, 0x8DD3, 0x7815, 0x8DD4, 0x7826, 0x8DD5, 0x796D,\r\n\t0x8DD6, 0x658E, 0x8DD7, 0x7D30, 0x8DD8, 0x83DC, 0x8DD9, 0x88C1,\t0x8DDA, 0x8F09, 0x8DDB, 0x969B, 0x8DDC, 0x5264, 0x8DDD, 0x5728,\r\n\t0x8DDE, 0x6750, 0x8DDF, 0x7F6A, 0x8DE0, 0x8CA1, 0x8DE1, 0x51B4,\t0x8DE2, 0x5742, 0x8DE3, 0x962A, 0x8DE4, 0x583A, 0x8DE5, 0x698A,\r\n\t0x8DE6, 0x80B4, 0x8DE7, 0x54B2, 0x8DE8, 0x5D0E, 0x8DE9, 0x57FC,\t0x8DEA, 0x7895, 0x8DEB, 0x9DFA, 0x8DEC, 0x4F5C, 0x8DED, 0x524A,\r\n\t0x8DEE, 0x548B, 0x8DEF, 0x643E, 0x8DF0, 0x6628, 0x8DF1, 0x6714,\t0x8DF2, 0x67F5, 0x8DF3, 0x7A84, 0x8DF4, 0x7B56, 0x8DF5, 0x7D22,\r\n\t0x8DF6, 0x932F, 0x8DF7, 0x685C, 0x8DF8, 0x9BAD, 0x8DF9, 0x7B39,\t0x8DFA, 0x5319, 0x8DFB, 0x518A, 0x8DFC, 0x5237, 0x8E40, 0x5BDF,\r\n\t0x8E41, 0x62F6, 0x8E42, 0x64AE, 0x8E43, 0x64E6, 0x8E44, 0x672D,\t0x8E45, 0x6BBA, 0x8E46, 0x85A9, 0x8E47, 0x96D1, 0x8E48, 0x7690,\r\n\t0x8E49, 0x9BD6, 0x8E4A, 0x634C, 0x8E4B, 0x9306, 0x8E4C, 0x9BAB,\t0x8E4D, 0x76BF, 0x8E4E, 0x6652, 0x8E4F, 0x4E09, 0x8E50, 0x5098,\r\n\t0x8E51, 0x53C2, 0x8E52, 0x5C71, 0x8E53, 0x60E8, 0x8E54, 0x6492,\t0x8E55, 0x6563, 0x8E56, 0x685F, 0x8E57, 0x71E6, 0x8E58, 0x73CA,\r\n\t0x8E59, 0x7523, 0x8E5A, 0x7B97, 0x8E5B, 0x7E82, 0x8E5C, 0x8695,\t0x8E5D, 0x8B83, 0x8E5E, 0x8CDB, 0x8E5F, 0x9178, 0x8E60, 0x9910,\r\n\t0x8E61, 0x65AC, 0x8E62, 0x66AB, 0x8E63, 0x6B8B, 0x8E64, 0x4ED5,\t0x8E65, 0x4ED4, 0x8E66, 0x4F3A, 0x8E67, 0x4F7F, 0x8E68, 0x523A,\r\n\t0x8E69, 0x53F8, 0x8E6A, 0x53F2, 0x8E6B, 0x55E3, 0x8E6C, 0x56DB,\t0x8E6D, 0x58EB, 0x8E6E, 0x59CB, 0x8E6F, 0x59C9, 0x8E70, 0x59FF,\r\n\t0x8E71, 0x5B50, 0x8E72, 0x5C4D, 0x8E73, 0x5E02, 0x8E74, 0x5E2B,\t0x8E75, 0x5FD7, 0x8E76, 0x601D, 0x8E77, 0x6307, 0x8E78, 0x652F,\r\n\t0x8E79, 0x5B5C, 0x8E7A, 0x65AF, 0x8E7B, 0x65BD, 0x8E7C, 0x65E8,\t0x8E7D, 0x679D, 0x8E7E, 0x6B62, 0x8E80, 0x6B7B, 0x8E81, 0x6C0F,\r\n\t0x8E82, 0x7345, 0x8E83, 0x7949, 0x8E84, 0x79C1, 0x8E85, 0x7CF8,\t0x8E86, 0x7D19, 0x8E87, 0x7D2B, 0x8E88, 0x80A2, 0x8E89, 0x8102,\r\n\t0x8E8A, 0x81F3, 0x8E8B, 0x8996, 0x8E8C, 0x8A5E, 0x8E8D, 0x8A69,\t0x8E8E, 0x8A66, 0x8E8F, 0x8A8C, 0x8E90, 0x8AEE, 0x8E91, 0x8CC7,\r\n\t0x8E92, 0x8CDC, 0x8E93, 0x96CC, 0x8E94, 0x98FC, 0x8E95, 0x6B6F,\t0x8E96, 0x4E8B, 0x8E97, 0x4F3C, 0x8E98, 0x4F8D, 0x8E99, 0x5150,\r\n\t0x8E9A, 0x5B57, 0x8E9B, 0x5BFA, 0x8E9C, 0x6148, 0x8E9D, 0x6301,\t0x8E9E, 0x6642, 0x8E9F, 0x6B21, 0x8EA0, 0x6ECB, 0x8EA1, 0x6CBB,\r\n\t0x8EA2, 0x723E, 0x8EA3, 0x74BD, 0x8EA4, 0x75D4, 0x8EA5, 0x78C1,\t0x8EA6, 0x793A, 0x8EA7, 0x800C, 0x8EA8, 0x8033, 0x8EA9, 0x81EA,\r\n\t0x8EAA, 0x8494, 0x8EAB, 0x8F9E, 0x8EAC, 0x6C50, 0x8EAD, 0x9E7F,\t0x8EAE, 0x5F0F, 0x8EAF, 0x8B58, 0x8EB0, 0x9D2B, 0x8EB1, 0x7AFA,\r\n\t0x8EB2, 0x8EF8, 0x8EB3, 0x5B8D, 0x8EB4, 0x96EB, 0x8EB5, 0x4E03,\t0x8EB6, 0x53F1, 0x8EB7, 0x57F7, 0x8EB8, 0x5931, 0x8EB9, 0x5AC9,\r\n\t0x8EBA, 0x5BA4, 0x8EBB, 0x6089, 0x8EBC, 0x6E7F, 0x8EBD, 0x6F06,\t0x8EBE, 0x75BE, 0x8EBF, 0x8CEA, 0x8EC0, 0x5B9F, 0x8EC1, 0x8500,\r\n\t0x8EC2, 0x7BE0, 0x8EC3, 0x5072, 0x8EC4, 0x67F4, 0x8EC5, 0x829D,\t0x8EC6, 0x5C61, 0x8EC7, 0x854A, 0x8EC8, 0x7E1E, 0x8EC9, 0x820E,\r\n\t0x8ECA, 0x5199, 0x8ECB, 0x5C04, 0x8ECC, 0x6368, 0x8ECD, 0x8D66,\t0x8ECE, 0x659C, 0x8ECF, 0x716E, 0x8ED0, 0x793E, 0x8ED1, 0x7D17,\r\n\t0x8ED2, 0x8005, 0x8ED3, 0x8B1D, 0x8ED4, 0x8ECA, 0x8ED5, 0x906E,\t0x8ED6, 0x86C7, 0x8ED7, 0x90AA, 0x8ED8, 0x501F, 0x8ED9, 0x52FA,\r\n\t0x8EDA, 0x5C3A, 0x8EDB, 0x6753, 0x8EDC, 0x707C, 0x8EDD, 0x7235,\t0x8EDE, 0x914C, 0x8EDF, 0x91C8, 0x8EE0, 0x932B, 0x8EE1, 0x82E5,\r\n\t0x8EE2, 0x5BC2, 0x8EE3, 0x5F31, 0x8EE4, 0x60F9, 0x8EE5, 0x4E3B,\t0x8EE6, 0x53D6, 0x8EE7, 0x5B88, 0x8EE8, 0x624B, 0x8EE9, 0x6731,\r\n\t0x8EEA, 0x6B8A, 0x8EEB, 0x72E9, 0x8EEC, 0x73E0, 0x8EED, 0x7A2E,\t0x8EEE, 0x816B, 0x8EEF, 0x8DA3, 0x8EF0, 0x9152, 0x8EF1, 0x9996,\r\n\t0x8EF2, 0x5112, 0x8EF3, 0x53D7, 0x8EF4, 0x546A, 0x8EF5, 0x5BFF,\t0x8EF6, 0x6388, 0x8EF7, 0x6A39, 0x8EF8, 0x7DAC, 0x8EF9, 0x9700,\r\n\t0x8EFA, 0x56DA, 0x8EFB, 0x53CE, 0x8EFC, 0x5468, 0x8F40, 0x5B97,\t0x8F41, 0x5C31, 0x8F42, 0x5DDE, 0x8F43, 0x4FEE, 0x8F44, 0x6101,\r\n\t0x8F45, 0x62FE, 0x8F46, 0x6D32, 0x8F47, 0x79C0, 0x8F48, 0x79CB,\t0x8F49, 0x7D42, 0x8F4A, 0x7E4D, 0x8F4B, 0x7FD2, 0x8F4C, 0x81ED,\r\n\t0x8F4D, 0x821F, 0x8F4E, 0x8490, 0x8F4F, 0x8846, 0x8F50, 0x8972,\t0x8F51, 0x8B90, 0x8F52, 0x8E74, 0x8F53, 0x8F2F, 0x8F54, 0x9031,\r\n\t0x8F55, 0x914B, 0x8F56, 0x916C, 0x8F57, 0x96C6, 0x8F58, 0x919C,\t0x8F59, 0x4EC0, 0x8F5A, 0x4F4F, 0x8F5B, 0x5145, 0x8F5C, 0x5341,\r\n\t0x8F5D, 0x5F93, 0x8F5E, 0x620E, 0x8F5F, 0x67D4, 0x8F60, 0x6C41,\t0x8F61, 0x6E0B, 0x8F62, 0x7363, 0x8F63, 0x7E26, 0x8F64, 0x91CD,\r\n\t0x8F65, 0x9283, 0x8F66, 0x53D4, 0x8F67, 0x5919, 0x8F68, 0x5BBF,\t0x8F69, 0x6DD1, 0x8F6A, 0x795D, 0x8F6B, 0x7E2E, 0x8F6C, 0x7C9B,\r\n\t0x8F6D, 0x587E, 0x8F6E, 0x719F, 0x8F6F, 0x51FA, 0x8F70, 0x8853,\t0x8F71, 0x8FF0, 0x8F72, 0x4FCA, 0x8F73, 0x5CFB, 0x8F74, 0x6625,\r\n\t0x8F75, 0x77AC, 0x8F76, 0x7AE3, 0x8F77, 0x821C, 0x8F78, 0x99FF,\t0x8F79, 0x51C6, 0x8F7A, 0x5FAA, 0x8F7B, 0x65EC, 0x8F7C, 0x696F,\r\n\t0x8F7D, 0x6B89, 0x8F7E, 0x6DF3, 0x8F80, 0x6E96, 0x8F81, 0x6F64,\t0x8F82, 0x76FE, 0x8F83, 0x7D14, 0x8F84, 0x5DE1, 0x8F85, 0x9075,\r\n\t0x8F86, 0x9187, 0x8F87, 0x9806, 0x8F88, 0x51E6, 0x8F89, 0x521D,\t0x8F8A, 0x6240, 0x8F8B, 0x6691, 0x8F8C, 0x66D9, 0x8F8D, 0x6E1A,\r\n\t0x8F8E, 0x5EB6, 0x8F8F, 0x7DD2, 0x8F90, 0x7F72, 0x8F91, 0x66F8,\t0x8F92, 0x85AF, 0x8F93, 0x85F7, 0x8F94, 0x8AF8, 0x8F95, 0x52A9,\r\n\t0x8F96, 0x53D9, 0x8F97, 0x5973, 0x8F98, 0x5E8F, 0x8F99, 0x5F90,\t0x8F9A, 0x6055, 0x8F9B, 0x92E4, 0x8F9C, 0x9664, 0x8F9D, 0x50B7,\r\n\t0x8F9E, 0x511F, 0x8F9F, 0x52DD, 0x8FA0, 0x5320, 0x8FA1, 0x5347,\t0x8FA2, 0x53EC, 0x8FA3, 0x54E8, 0x8FA4, 0x5546, 0x8FA5, 0x5531,\r\n\t0x8FA6, 0x5617, 0x8FA7, 0x5968, 0x8FA8, 0x59BE, 0x8FA9, 0x5A3C,\t0x8FAA, 0x5BB5, 0x8FAB, 0x5C06, 0x8FAC, 0x5C0F, 0x8FAD, 0x5C11,\r\n\t0x8FAE, 0x5C1A, 0x8FAF, 0x5E84, 0x8FB0, 0x5E8A, 0x8FB1, 0x5EE0,\t0x8FB2, 0x5F70, 0x8FB3, 0x627F, 0x8FB4, 0x6284, 0x8FB5, 0x62DB,\r\n\t0x8FB6, 0x638C, 0x8FB7, 0x6377, 0x8FB8, 0x6607, 0x8FB9, 0x660C,\t0x8FBA, 0x662D, 0x8FBB, 0x6676, 0x8FBC, 0x677E, 0x8FBD, 0x68A2,\r\n\t0x8FBE, 0x6A1F, 0x8FBF, 0x6A35, 0x8FC0, 0x6CBC, 0x8FC1, 0x6D88,\t0x8FC2, 0x6E09, 0x8FC3, 0x6E58, 0x8FC4, 0x713C, 0x8FC5, 0x7126,\r\n\t0x8FC6, 0x7167, 0x8FC7, 0x75C7, 0x8FC8, 0x7701, 0x8FC9, 0x785D,\t0x8FCA, 0x7901, 0x8FCB, 0x7965, 0x8FCC, 0x79F0, 0x8FCD, 0x7AE0,\r\n\t0x8FCE, 0x7B11, 0x8FCF, 0x7CA7, 0x8FD0, 0x7D39, 0x8FD1, 0x8096,\t0x8FD2, 0x83D6, 0x8FD3, 0x848B, 0x8FD4, 0x8549, 0x8FD5, 0x885D,\r\n\t0x8FD6, 0x88F3, 0x8FD7, 0x8A1F, 0x8FD8, 0x8A3C, 0x8FD9, 0x8A54,\t0x8FDA, 0x8A73, 0x8FDB, 0x8C61, 0x8FDC, 0x8CDE, 0x8FDD, 0x91A4,\r\n\t0x8FDE, 0x9266, 0x8FDF, 0x937E, 0x8FE0, 0x9418, 0x8FE1, 0x969C,\t0x8FE2, 0x9798, 0x8FE3, 0x4E0A, 0x8FE4, 0x4E08, 0x8FE5, 0x4E1E,\r\n\t0x8FE6, 0x4E57, 0x8FE7, 0x5197, 0x8FE8, 0x5270, 0x8FE9, 0x57CE,\t0x8FEA, 0x5834, 0x8FEB, 0x58CC, 0x8FEC, 0x5B22, 0x8FED, 0x5E38,\r\n\t0x8FEE, 0x60C5, 0x8FEF, 0x64FE, 0x8FF0, 0x6761, 0x8FF1, 0x6756,\t0x8FF2, 0x6D44, 0x8FF3, 0x72B6, 0x8FF4, 0x7573, 0x8FF5, 0x7A63,\r\n\t0x8FF6, 0x84B8, 0x8FF7, 0x8B72, 0x8FF8, 0x91B8, 0x8FF9, 0x9320,\t0x8FFA, 0x5631, 0x8FFB, 0x57F4, 0x8FFC, 0x98FE, 0x9040, 0x62ED,\r\n\t0x9041, 0x690D, 0x9042, 0x6B96, 0x9043, 0x71ED, 0x9044, 0x7E54,\t0x9045, 0x8077, 0x9046, 0x8272, 0x9047, 0x89E6, 0x9048, 0x98DF,\r\n\t0x9049, 0x8755, 0x904A, 0x8FB1, 0x904B, 0x5C3B, 0x904C, 0x4F38,\t0x904D, 0x4FE1, 0x904E, 0x4FB5, 0x904F, 0x5507, 0x9050, 0x5A20,\r\n\t0x9051, 0x5BDD, 0x9052, 0x5BE9, 0x9053, 0x5FC3, 0x9054, 0x614E,\t0x9055, 0x632F, 0x9056, 0x65B0, 0x9057, 0x664B, 0x9058, 0x68EE,\r\n\t0x9059, 0x699B, 0x905A, 0x6D78, 0x905B, 0x6DF1, 0x905C, 0x7533,\t0x905D, 0x75B9, 0x905E, 0x771F, 0x905F, 0x795E, 0x9060, 0x79E6,\r\n\t0x9061, 0x7D33, 0x9062, 0x81E3, 0x9063, 0x82AF, 0x9064, 0x85AA,\t0x9065, 0x89AA, 0x9066, 0x8A3A, 0x9067, 0x8EAB, 0x9068, 0x8F9B,\r\n\t0x9069, 0x9032, 0x906A, 0x91DD, 0x906B, 0x9707, 0x906C, 0x4EBA,\t0x906D, 0x4EC1, 0x906E, 0x5203, 0x906F, 0x5875, 0x9070, 0x58EC,\r\n\t0x9071, 0x5C0B, 0x9072, 0x751A, 0x9073, 0x5C3D, 0x9074, 0x814E,\t0x9075, 0x8A0A, 0x9076, 0x8FC5, 0x9077, 0x9663, 0x9078, 0x976D,\r\n\t0x9079, 0x7B25, 0x907A, 0x8ACF, 0x907B, 0x9808, 0x907C, 0x9162,\t0x907D, 0x56F3, 0x907E, 0x53A8, 0x9080, 0x9017, 0x9081, 0x5439,\r\n\t0x9082, 0x5782, 0x9083, 0x5E25, 0x9084, 0x63A8, 0x9085, 0x6C34,\t0x9086, 0x708A, 0x9087, 0x7761, 0x9088, 0x7C8B, 0x9089, 0x7FE0,\r\n\t0x908A, 0x8870, 0x908B, 0x9042, 0x908C, 0x9154, 0x908D, 0x9310,\t0x908E, 0x9318, 0x908F, 0x968F, 0x9090, 0x745E, 0x9091, 0x9AC4,\r\n\t0x9092, 0x5D07, 0x9093, 0x5D69, 0x9094, 0x6570, 0x9095, 0x67A2,\t0x9096, 0x8DA8, 0x9097, 0x96DB, 0x9098, 0x636E, 0x9099, 0x6749,\r\n\t0x909A, 0x6919, 0x909B, 0x83C5, 0x909C, 0x9817, 0x909D, 0x96C0,\t0x909E, 0x88FE, 0x909F, 0x6F84, 0x90A0, 0x647A, 0x90A1, 0x5BF8,\r\n\t0x90A2, 0x4E16, 0x90A3, 0x702C, 0x90A4, 0x755D, 0x90A5, 0x662F,\t0x90A6, 0x51C4, 0x90A7, 0x5236, 0x90A8, 0x52E2, 0x90A9, 0x59D3,\r\n\t0x90AA, 0x5F81, 0x90AB, 0x6027, 0x90AC, 0x6210, 0x90AD, 0x653F,\t0x90AE, 0x6574, 0x90AF, 0x661F, 0x90B0, 0x6674, 0x90B1, 0x68F2,\r\n\t0x90B2, 0x6816, 0x90B3, 0x6B63, 0x90B4, 0x6E05, 0x90B5, 0x7272,\t0x90B6, 0x751F, 0x90B7, 0x76DB, 0x90B8, 0x7CBE, 0x90B9, 0x8056,\r\n\t0x90BA, 0x58F0, 0x90BB, 0x88FD, 0x90BC, 0x897F, 0x90BD, 0x8AA0,\t0x90BE, 0x8A93, 0x90BF, 0x8ACB, 0x90C0, 0x901D, 0x90C1, 0x9192,\r\n\t0x90C2, 0x9752, 0x90C3, 0x9759, 0x90C4, 0x6589, 0x90C5, 0x7A0E,\t0x90C6, 0x8106, 0x90C7, 0x96BB, 0x90C8, 0x5E2D, 0x90C9, 0x60DC,\r\n\t0x90CA, 0x621A, 0x90CB, 0x65A5, 0x90CC, 0x6614, 0x90CD, 0x6790,\t0x90CE, 0x77F3, 0x90CF, 0x7A4D, 0x90D0, 0x7C4D, 0x90D1, 0x7E3E,\r\n\t0x90D2, 0x810A, 0x90D3, 0x8CAC, 0x90D4, 0x8D64, 0x90D5, 0x8DE1,\t0x90D6, 0x8E5F, 0x90D7, 0x78A9, 0x90D8, 0x5207, 0x90D9, 0x62D9,\r\n\t0x90DA, 0x63A5, 0x90DB, 0x6442, 0x90DC, 0x6298, 0x90DD, 0x8A2D,\t0x90DE, 0x7A83, 0x90DF, 0x7BC0, 0x90E0, 0x8AAC, 0x90E1, 0x96EA,\r\n\t0x90E2, 0x7D76, 0x90E3, 0x820C, 0x90E4, 0x8749, 0x90E5, 0x4ED9,\t0x90E6, 0x5148, 0x90E7, 0x5343, 0x90E8, 0x5360, 0x90E9, 0x5BA3,\r\n\t0x90EA, 0x5C02, 0x90EB, 0x5C16, 0x90EC, 0x5DDD, 0x90ED, 0x6226,\t0x90EE, 0x6247, 0x90EF, 0x64B0, 0x90F0, 0x6813, 0x90F1, 0x6834,\r\n\t0x90F2, 0x6CC9, 0x90F3, 0x6D45, 0x90F4, 0x6D17, 0x90F5, 0x67D3,\t0x90F6, 0x6F5C, 0x90F7, 0x714E, 0x90F8, 0x717D, 0x90F9, 0x65CB,\r\n\t0x90FA, 0x7A7F, 0x90FB, 0x7BAD, 0x90FC, 0x7DDA, 0x9140, 0x7E4A,\t0x9141, 0x7FA8, 0x9142, 0x817A, 0x9143, 0x821B, 0x9144, 0x8239,\r\n\t0x9145, 0x85A6, 0x9146, 0x8A6E, 0x9147, 0x8CCE, 0x9148, 0x8DF5,\t0x9149, 0x9078, 0x914A, 0x9077, 0x914B, 0x92AD, 0x914C, 0x9291,\r\n\t0x914D, 0x9583, 0x914E, 0x9BAE, 0x914F, 0x524D, 0x9150, 0x5584,\t0x9151, 0x6F38, 0x9152, 0x7136, 0x9153, 0x5168, 0x9154, 0x7985,\r\n\t0x9155, 0x7E55, 0x9156, 0x81B3, 0x9157, 0x7CCE, 0x9158, 0x564C,\t0x9159, 0x5851, 0x915A, 0x5CA8, 0x915B, 0x63AA, 0x915C, 0x66FE,\r\n\t0x915D, 0x66FD, 0x915E, 0x695A, 0x915F, 0x72D9, 0x9160, 0x758F,\t0x9161, 0x758E, 0x9162, 0x790E, 0x9163, 0x7956, 0x9164, 0x79DF,\r\n\t0x9165, 0x7C97, 0x9166, 0x7D20, 0x9167, 0x7D44, 0x9168, 0x8607,\t0x9169, 0x8A34, 0x916A, 0x963B, 0x916B, 0x9061, 0x916C, 0x9F20,\r\n\t0x916D, 0x50E7, 0x916E, 0x5275, 0x916F, 0x53CC, 0x9170, 0x53E2,\t0x9171, 0x5009, 0x9172, 0x55AA, 0x9173, 0x58EE, 0x9174, 0x594F,\r\n\t0x9175, 0x723D, 0x9176, 0x5B8B, 0x9177, 0x5C64, 0x9178, 0x531D,\t0x9179, 0x60E3, 0x917A, 0x60F3, 0x917B, 0x635C, 0x917C, 0x6383,\r\n\t0x917D, 0x633F, 0x917E, 0x63BB, 0x9180, 0x64CD, 0x9181, 0x65E9,\t0x9182, 0x66F9, 0x9183, 0x5DE3, 0x9184, 0x69CD, 0x9185, 0x69FD,\r\n\t0x9186, 0x6F15, 0x9187, 0x71E5, 0x9188, 0x4E89, 0x9189, 0x75E9,\t0x918A, 0x76F8, 0x918B, 0x7A93, 0x918C, 0x7CDF, 0x918D, 0x7DCF,\r\n\t0x918E, 0x7D9C, 0x918F, 0x8061, 0x9190, 0x8349, 0x9191, 0x8358,\t0x9192, 0x846C, 0x9193, 0x84BC, 0x9194, 0x85FB, 0x9195, 0x88C5,\r\n\t0x9196, 0x8D70, 0x9197, 0x9001, 0x9198, 0x906D, 0x9199, 0x9397,\t0x919A, 0x971C, 0x919B, 0x9A12, 0x919C, 0x50CF, 0x919D, 0x5897,\r\n\t0x919E, 0x618E, 0x919F, 0x81D3, 0x91A0, 0x8535, 0x91A1, 0x8D08,\t0x91A2, 0x9020, 0x91A3, 0x4FC3, 0x91A4, 0x5074, 0x91A5, 0x5247,\r\n\t0x91A6, 0x5373, 0x91A7, 0x606F, 0x91A8, 0x6349, 0x91A9, 0x675F,\t0x91AA, 0x6E2C, 0x91AB, 0x8DB3, 0x91AC, 0x901F, 0x91AD, 0x4FD7,\r\n\t0x91AE, 0x5C5E, 0x91AF, 0x8CCA, 0x91B0, 0x65CF, 0x91B1, 0x7D9A,\t0x91B2, 0x5352, 0x91B3, 0x8896, 0x91B4, 0x5176, 0x91B5, 0x63C3,\r\n\t0x91B6, 0x5B58, 0x91B7, 0x5B6B, 0x91B8, 0x5C0A, 0x91B9, 0x640D,\t0x91BA, 0x6751, 0x91BB, 0x905C, 0x91BC, 0x4ED6, 0x91BD, 0x591A,\r\n\t0x91BE, 0x592A, 0x91BF, 0x6C70, 0x91C0, 0x8A51, 0x91C1, 0x553E,\t0x91C2, 0x5815, 0x91C3, 0x59A5, 0x91C4, 0x60F0, 0x91C5, 0x6253,\r\n\t0x91C6, 0x67C1, 0x91C7, 0x8235, 0x91C8, 0x6955, 0x91C9, 0x9640,\t0x91CA, 0x99C4, 0x91CB, 0x9A28, 0x91CC, 0x4F53, 0x91CD, 0x5806,\r\n\t0x91CE, 0x5BFE, 0x91CF, 0x8010, 0x91D0, 0x5CB1, 0x91D1, 0x5E2F,\t0x91D2, 0x5F85, 0x91D3, 0x6020, 0x91D4, 0x614B, 0x91D5, 0x6234,\r\n\t0x91D6, 0x66FF, 0x91D7, 0x6CF0, 0x91D8, 0x6EDE, 0x91D9, 0x80CE,\t0x91DA, 0x817F, 0x91DB, 0x82D4, 0x91DC, 0x888B, 0x91DD, 0x8CB8,\r\n\t0x91DE, 0x9000, 0x91DF, 0x902E, 0x91E0, 0x968A, 0x91E1, 0x9EDB,\t0x91E2, 0x9BDB, 0x91E3, 0x4EE3, 0x91E4, 0x53F0, 0x91E5, 0x5927,\r\n\t0x91E6, 0x7B2C, 0x91E7, 0x918D, 0x91E8, 0x984C, 0x91E9, 0x9DF9,\t0x91EA, 0x6EDD, 0x91EB, 0x7027, 0x91EC, 0x5353, 0x91ED, 0x5544,\r\n\t0x91EE, 0x5B85, 0x91EF, 0x6258, 0x91F0, 0x629E, 0x91F1, 0x62D3,\t0x91F2, 0x6CA2, 0x91F3, 0x6FEF, 0x91F4, 0x7422, 0x91F5, 0x8A17,\r\n\t0x91F6, 0x9438, 0x91F7, 0x6FC1, 0x91F8, 0x8AFE, 0x91F9, 0x8338,\t0x91FA, 0x51E7, 0x91FB, 0x86F8, 0x91FC, 0x53EA, 0x9240, 0x53E9,\r\n\t0x9241, 0x4F46, 0x9242, 0x9054, 0x9243, 0x8FB0, 0x9244, 0x596A,\t0x9245, 0x8131, 0x9246, 0x5DFD, 0x9247, 0x7AEA, 0x9248, 0x8FBF,\r\n\t0x9249, 0x68DA, 0x924A, 0x8C37, 0x924B, 0x72F8, 0x924C, 0x9C48,\t0x924D, 0x6A3D, 0x924E, 0x8AB0, 0x924F, 0x4E39, 0x9250, 0x5358,\r\n\t0x9251, 0x5606, 0x9252, 0x5766, 0x9253, 0x62C5, 0x9254, 0x63A2,\t0x9255, 0x65E6, 0x9256, 0x6B4E, 0x9257, 0x6DE1, 0x9258, 0x6E5B,\r\n\t0x9259, 0x70AD, 0x925A, 0x77ED, 0x925B, 0x7AEF, 0x925C, 0x7BAA,\t0x925D, 0x7DBB, 0x925E, 0x803D, 0x925F, 0x80C6, 0x9260, 0x86CB,\r\n\t0x9261, 0x8A95, 0x9262, 0x935B, 0x9263, 0x56E3, 0x9264, 0x58C7,\t0x9265, 0x5F3E, 0x9266, 0x65AD, 0x9267, 0x6696, 0x9268, 0x6A80,\r\n\t0x9269, 0x6BB5, 0x926A, 0x7537, 0x926B, 0x8AC7, 0x926C, 0x5024,\t0x926D, 0x77E5, 0x926E, 0x5730, 0x926F, 0x5F1B, 0x9270, 0x6065,\r\n\t0x9271, 0x667A, 0x9272, 0x6C60, 0x9273, 0x75F4, 0x9274, 0x7A1A,\t0x9275, 0x7F6E, 0x9276, 0x81F4, 0x9277, 0x8718, 0x9278, 0x9045,\r\n\t0x9279, 0x99B3, 0x927A, 0x7BC9, 0x927B, 0x755C, 0x927C, 0x7AF9,\t0x927D, 0x7B51, 0x927E, 0x84C4, 0x9280, 0x9010, 0x9281, 0x79E9,\r\n\t0x9282, 0x7A92, 0x9283, 0x8336, 0x9284, 0x5AE1, 0x9285, 0x7740,\t0x9286, 0x4E2D, 0x9287, 0x4EF2, 0x9288, 0x5B99, 0x9289, 0x5FE0,\r\n\t0x928A, 0x62BD, 0x928B, 0x663C, 0x928C, 0x67F1, 0x928D, 0x6CE8,\t0x928E, 0x866B, 0x928F, 0x8877, 0x9290, 0x8A3B, 0x9291, 0x914E,\r\n\t0x9292, 0x92F3, 0x9293, 0x99D0, 0x9294, 0x6A17, 0x9295, 0x7026,\t0x9296, 0x732A, 0x9297, 0x82E7, 0x9298, 0x8457, 0x9299, 0x8CAF,\r\n\t0x929A, 0x4E01, 0x929B, 0x5146, 0x929C, 0x51CB, 0x929D, 0x558B,\t0x929E, 0x5BF5, 0x929F, 0x5E16, 0x92A0, 0x5E33, 0x92A1, 0x5E81,\r\n\t0x92A2, 0x5F14, 0x92A3, 0x5F35, 0x92A4, 0x5F6B, 0x92A5, 0x5FB4,\t0x92A6, 0x61F2, 0x92A7, 0x6311, 0x92A8, 0x66A2, 0x92A9, 0x671D,\r\n\t0x92AA, 0x6F6E, 0x92AB, 0x7252, 0x92AC, 0x753A, 0x92AD, 0x773A,\t0x92AE, 0x8074, 0x92AF, 0x8139, 0x92B0, 0x8178, 0x92B1, 0x8776,\r\n\t0x92B2, 0x8ABF, 0x92B3, 0x8ADC, 0x92B4, 0x8D85, 0x92B5, 0x8DF3,\t0x92B6, 0x929A, 0x92B7, 0x9577, 0x92B8, 0x9802, 0x92B9, 0x9CE5,\r\n\t0x92BA, 0x52C5, 0x92BB, 0x6357, 0x92BC, 0x76F4, 0x92BD, 0x6715,\t0x92BE, 0x6C88, 0x92BF, 0x73CD, 0x92C0, 0x8CC3, 0x92C1, 0x93AE,\r\n\t0x92C2, 0x9673, 0x92C3, 0x6D25, 0x92C4, 0x589C, 0x92C5, 0x690E,\t0x92C6, 0x69CC, 0x92C7, 0x8FFD, 0x92C8, 0x939A, 0x92C9, 0x75DB,\r\n\t0x92CA, 0x901A, 0x92CB, 0x585A, 0x92CC, 0x6802, 0x92CD, 0x63B4,\t0x92CE, 0x69FB, 0x92CF, 0x4F43, 0x92D0, 0x6F2C, 0x92D1, 0x67D8,\r\n\t0x92D2, 0x8FBB, 0x92D3, 0x8526, 0x92D4, 0x7DB4, 0x92D5, 0x9354,\t0x92D6, 0x693F, 0x92D7, 0x6F70, 0x92D8, 0x576A, 0x92D9, 0x58F7,\r\n\t0x92DA, 0x5B2C, 0x92DB, 0x7D2C, 0x92DC, 0x722A, 0x92DD, 0x540A,\t0x92DE, 0x91E3, 0x92DF, 0x9DB4, 0x92E0, 0x4EAD, 0x92E1, 0x4F4E,\r\n\t0x92E2, 0x505C, 0x92E3, 0x5075, 0x92E4, 0x5243, 0x92E5, 0x8C9E,\t0x92E6, 0x5448, 0x92E7, 0x5824, 0x92E8, 0x5B9A, 0x92E9, 0x5E1D,\r\n\t0x92EA, 0x5E95, 0x92EB, 0x5EAD, 0x92EC, 0x5EF7, 0x92ED, 0x5F1F,\t0x92EE, 0x608C, 0x92EF, 0x62B5, 0x92F0, 0x633A, 0x92F1, 0x63D0,\r\n\t0x92F2, 0x68AF, 0x92F3, 0x6C40, 0x92F4, 0x7887, 0x92F5, 0x798E,\t0x92F6, 0x7A0B, 0x92F7, 0x7DE0, 0x92F8, 0x8247, 0x92F9, 0x8A02,\r\n\t0x92FA, 0x8AE6, 0x92FB, 0x8E44, 0x92FC, 0x9013, 0x9340, 0x90B8,\t0x9341, 0x912D, 0x9342, 0x91D8, 0x9343, 0x9F0E, 0x9344, 0x6CE5,\r\n\t0x9345, 0x6458, 0x9346, 0x64E2, 0x9347, 0x6575, 0x9348, 0x6EF4,\t0x9349, 0x7684, 0x934A, 0x7B1B, 0x934B, 0x9069, 0x934C, 0x93D1,\r\n\t0x934D, 0x6EBA, 0x934E, 0x54F2, 0x934F, 0x5FB9, 0x9350, 0x64A4,\t0x9351, 0x8F4D, 0x9352, 0x8FED, 0x9353, 0x9244, 0x9354, 0x5178,\r\n\t0x9355, 0x586B, 0x9356, 0x5929, 0x9357, 0x5C55, 0x9358, 0x5E97,\t0x9359, 0x6DFB, 0x935A, 0x7E8F, 0x935B, 0x751C, 0x935C, 0x8CBC,\r\n\t0x935D, 0x8EE2, 0x935E, 0x985B, 0x935F, 0x70B9, 0x9360, 0x4F1D,\t0x9361, 0x6BBF, 0x9362, 0x6FB1, 0x9363, 0x7530, 0x9364, 0x96FB,\r\n\t0x9365, 0x514E, 0x9366, 0x5410, 0x9367, 0x5835, 0x9368, 0x5857,\t0x9369, 0x59AC, 0x936A, 0x5C60, 0x936B, 0x5F92, 0x936C, 0x6597,\r\n\t0x936D, 0x675C, 0x936E, 0x6E21, 0x936F, 0x767B, 0x9370, 0x83DF,\t0x9371, 0x8CED, 0x9372, 0x9014, 0x9373, 0x90FD, 0x9374, 0x934D,\r\n\t0x9375, 0x7825, 0x9376, 0x783A, 0x9377, 0x52AA, 0x9378, 0x5EA6,\t0x9379, 0x571F, 0x937A, 0x5974, 0x937B, 0x6012, 0x937C, 0x5012,\r\n\t0x937D, 0x515A, 0x937E, 0x51AC, 0x9380, 0x51CD, 0x9381, 0x5200,\t0x9382, 0x5510, 0x9383, 0x5854, 0x9384, 0x5858, 0x9385, 0x5957,\r\n\t0x9386, 0x5B95, 0x9387, 0x5CF6, 0x9388, 0x5D8B, 0x9389, 0x60BC,\t0x938A, 0x6295, 0x938B, 0x642D, 0x938C, 0x6771, 0x938D, 0x6843,\r\n\t0x938E, 0x68BC, 0x938F, 0x68DF, 0x9390, 0x76D7, 0x9391, 0x6DD8,\t0x9392, 0x6E6F, 0x9393, 0x6D9B, 0x9394, 0x706F, 0x9395, 0x71C8,\r\n\t0x9396, 0x5F53, 0x9397, 0x75D8, 0x9398, 0x7977, 0x9399, 0x7B49,\t0x939A, 0x7B54, 0x939B, 0x7B52, 0x939C, 0x7CD6, 0x939D, 0x7D71,\r\n\t0x939E, 0x5230, 0x939F, 0x8463, 0x93A0, 0x8569, 0x93A1, 0x85E4,\t0x93A2, 0x8A0E, 0x93A3, 0x8B04, 0x93A4, 0x8C46, 0x93A5, 0x8E0F,\r\n\t0x93A6, 0x9003, 0x93A7, 0x900F, 0x93A8, 0x9419, 0x93A9, 0x9676,\t0x93AA, 0x982D, 0x93AB, 0x9A30, 0x93AC, 0x95D8, 0x93AD, 0x50CD,\r\n\t0x93AE, 0x52D5, 0x93AF, 0x540C, 0x93B0, 0x5802, 0x93B1, 0x5C0E,\t0x93B2, 0x61A7, 0x93B3, 0x649E, 0x93B4, 0x6D1E, 0x93B5, 0x77B3,\r\n\t0x93B6, 0x7AE5, 0x93B7, 0x80F4, 0x93B8, 0x8404, 0x93B9, 0x9053,\t0x93BA, 0x9285, 0x93BB, 0x5CE0, 0x93BC, 0x9D07, 0x93BD, 0x533F,\r\n\t0x93BE, 0x5F97, 0x93BF, 0x5FB3, 0x93C0, 0x6D9C, 0x93C1, 0x7279,\t0x93C2, 0x7763, 0x93C3, 0x79BF, 0x93C4, 0x7BE4, 0x93C5, 0x6BD2,\r\n\t0x93C6, 0x72EC, 0x93C7, 0x8AAD, 0x93C8, 0x6803, 0x93C9, 0x6A61,\t0x93CA, 0x51F8, 0x93CB, 0x7A81, 0x93CC, 0x6934, 0x93CD, 0x5C4A,\r\n\t0x93CE, 0x9CF6, 0x93CF, 0x82EB, 0x93D0, 0x5BC5, 0x93D1, 0x9149,\t0x93D2, 0x701E, 0x93D3, 0x5678, 0x93D4, 0x5C6F, 0x93D5, 0x60C7,\r\n\t0x93D6, 0x6566, 0x93D7, 0x6C8C, 0x93D8, 0x8C5A, 0x93D9, 0x9041,\t0x93DA, 0x9813, 0x93DB, 0x5451, 0x93DC, 0x66C7, 0x93DD, 0x920D,\r\n\t0x93DE, 0x5948, 0x93DF, 0x90A3, 0x93E0, 0x5185, 0x93E1, 0x4E4D,\t0x93E2, 0x51EA, 0x93E3, 0x8599, 0x93E4, 0x8B0E, 0x93E5, 0x7058,\r\n\t0x93E6, 0x637A, 0x93E7, 0x934B, 0x93E8, 0x6962, 0x93E9, 0x99B4,\t0x93EA, 0x7E04, 0x93EB, 0x7577, 0x93EC, 0x5357, 0x93ED, 0x6960,\r\n\t0x93EE, 0x8EDF, 0x93EF, 0x96E3, 0x93F0, 0x6C5D, 0x93F1, 0x4E8C,\t0x93F2, 0x5C3C, 0x93F3, 0x5F10, 0x93F4, 0x8FE9, 0x93F5, 0x5302,\r\n\t0x93F6, 0x8CD1, 0x93F7, 0x8089, 0x93F8, 0x8679, 0x93F9, 0x5EFF,\t0x93FA, 0x65E5, 0x93FB, 0x4E73, 0x93FC, 0x5165, 0x9440, 0x5982,\r\n\t0x9441, 0x5C3F, 0x9442, 0x97EE, 0x9443, 0x4EFB, 0x9444, 0x598A,\t0x9445, 0x5FCD, 0x9446, 0x8A8D, 0x9447, 0x6FE1, 0x9448, 0x79B0,\r\n\t0x9449, 0x7962, 0x944A, 0x5BE7, 0x944B, 0x8471, 0x944C, 0x732B,\t0x944D, 0x71B1, 0x944E, 0x5E74, 0x944F, 0x5FF5, 0x9450, 0x637B,\r\n\t0x9451, 0x649A, 0x9452, 0x71C3, 0x9453, 0x7C98, 0x9454, 0x4E43,\t0x9455, 0x5EFC, 0x9456, 0x4E4B, 0x9457, 0x57DC, 0x9458, 0x56A2,\r\n\t0x9459, 0x60A9, 0x945A, 0x6FC3, 0x945B, 0x7D0D, 0x945C, 0x80FD,\t0x945D, 0x8133, 0x945E, 0x81BF, 0x945F, 0x8FB2, 0x9460, 0x8997,\r\n\t0x9461, 0x86A4, 0x9462, 0x5DF4, 0x9463, 0x628A, 0x9464, 0x64AD,\t0x9465, 0x8987, 0x9466, 0x6777, 0x9467, 0x6CE2, 0x9468, 0x6D3E,\r\n\t0x9469, 0x7436, 0x946A, 0x7834, 0x946B, 0x5A46, 0x946C, 0x7F75,\t0x946D, 0x82AD, 0x946E, 0x99AC, 0x946F, 0x4FF3, 0x9470, 0x5EC3,\r\n\t0x9471, 0x62DD, 0x9472, 0x6392, 0x9473, 0x6557, 0x9474, 0x676F,\t0x9475, 0x76C3, 0x9476, 0x724C, 0x9477, 0x80CC, 0x9478, 0x80BA,\r\n\t0x9479, 0x8F29, 0x947A, 0x914D, 0x947B, 0x500D, 0x947C, 0x57F9,\t0x947D, 0x5A92, 0x947E, 0x6885, 0x9480, 0x6973, 0x9481, 0x7164,\r\n\t0x9482, 0x72FD, 0x9483, 0x8CB7, 0x9484, 0x58F2, 0x9485, 0x8CE0,\t0x9486, 0x966A, 0x9487, 0x9019, 0x9488, 0x877F, 0x9489, 0x79E4,\r\n\t0x948A, 0x77E7, 0x948B, 0x8429, 0x948C, 0x4F2F, 0x948D, 0x5265,\t0x948E, 0x535A, 0x948F, 0x62CD, 0x9490, 0x67CF, 0x9491, 0x6CCA,\r\n\t0x9492, 0x767D, 0x9493, 0x7B94, 0x9494, 0x7C95, 0x9495, 0x8236,\t0x9496, 0x8584, 0x9497, 0x8FEB, 0x9498, 0x66DD, 0x9499, 0x6F20,\r\n\t0x949A, 0x7206, 0x949B, 0x7E1B, 0x949C, 0x83AB, 0x949D, 0x99C1,\t0x949E, 0x9EA6, 0x949F, 0x51FD, 0x94A0, 0x7BB1, 0x94A1, 0x7872,\r\n\t0x94A2, 0x7BB8, 0x94A3, 0x8087, 0x94A4, 0x7B48, 0x94A5, 0x6AE8,\t0x94A6, 0x5E61, 0x94A7, 0x808C, 0x94A8, 0x7551, 0x94A9, 0x7560,\r\n\t0x94AA, 0x516B, 0x94AB, 0x9262, 0x94AC, 0x6E8C, 0x94AD, 0x767A,\t0x94AE, 0x9197, 0x94AF, 0x9AEA, 0x94B0, 0x4F10, 0x94B1, 0x7F70,\r\n\t0x94B2, 0x629C, 0x94B3, 0x7B4F, 0x94B4, 0x95A5, 0x94B5, 0x9CE9,\t0x94B6, 0x567A, 0x94B7, 0x5859, 0x94B8, 0x86E4, 0x94B9, 0x96BC,\r\n\t0x94BA, 0x4F34, 0x94BB, 0x5224, 0x94BC, 0x534A, 0x94BD, 0x53CD,\t0x94BE, 0x53DB, 0x94BF, 0x5E06, 0x94C0, 0x642C, 0x94C1, 0x6591,\r\n\t0x94C2, 0x677F, 0x94C3, 0x6C3E, 0x94C4, 0x6C4E, 0x94C5, 0x7248,\t0x94C6, 0x72AF, 0x94C7, 0x73ED, 0x94C8, 0x7554, 0x94C9, 0x7E41,\r\n\t0x94CA, 0x822C, 0x94CB, 0x85E9, 0x94CC, 0x8CA9, 0x94CD, 0x7BC4,\t0x94CE, 0x91C6, 0x94CF, 0x7169, 0x94D0, 0x9812, 0x94D1, 0x98EF,\r\n\t0x94D2, 0x633D, 0x94D3, 0x6669, 0x94D4, 0x756A, 0x94D5, 0x76E4,\t0x94D6, 0x78D0, 0x94D7, 0x8543, 0x94D8, 0x86EE, 0x94D9, 0x532A,\r\n\t0x94DA, 0x5351, 0x94DB, 0x5426, 0x94DC, 0x5983, 0x94DD, 0x5E87,\t0x94DE, 0x5F7C, 0x94DF, 0x60B2, 0x94E0, 0x6249, 0x94E1, 0x6279,\r\n\t0x94E2, 0x62AB, 0x94E3, 0x6590, 0x94E4, 0x6BD4, 0x94E5, 0x6CCC,\t0x94E6, 0x75B2, 0x94E7, 0x76AE, 0x94E8, 0x7891, 0x94E9, 0x79D8,\r\n\t0x94EA, 0x7DCB, 0x94EB, 0x7F77, 0x94EC, 0x80A5, 0x94ED, 0x88AB,\t0x94EE, 0x8AB9, 0x94EF, 0x8CBB, 0x94F0, 0x907F, 0x94F1, 0x975E,\r\n\t0x94F2, 0x98DB, 0x94F3, 0x6A0B, 0x94F4, 0x7C38, 0x94F5, 0x5099,\t0x94F6, 0x5C3E, 0x94F7, 0x5FAE, 0x94F8, 0x6787, 0x94F9, 0x6BD8,\r\n\t0x94FA, 0x7435, 0x94FB, 0x7709, 0x94FC, 0x7F8E, 0x9540, 0x9F3B,\t0x9541, 0x67CA, 0x9542, 0x7A17, 0x9543, 0x5339, 0x9544, 0x758B,\r\n\t0x9545, 0x9AED, 0x9546, 0x5F66, 0x9547, 0x819D, 0x9548, 0x83F1,\t0x9549, 0x8098, 0x954A, 0x5F3C, 0x954B, 0x5FC5, 0x954C, 0x7562,\r\n\t0x954D, 0x7B46, 0x954E, 0x903C, 0x954F, 0x6867, 0x9550, 0x59EB,\t0x9551, 0x5A9B, 0x9552, 0x7D10, 0x9553, 0x767E, 0x9554, 0x8B2C,\r\n\t0x9555, 0x4FF5, 0x9556, 0x5F6A, 0x9557, 0x6A19, 0x9558, 0x6C37,\t0x9559, 0x6F02, 0x955A, 0x74E2, 0x955B, 0x7968, 0x955C, 0x8868,\r\n\t0x955D, 0x8A55, 0x955E, 0x8C79, 0x955F, 0x5EDF, 0x9560, 0x63CF,\t0x9561, 0x75C5, 0x9562, 0x79D2, 0x9563, 0x82D7, 0x9564, 0x9328,\r\n\t0x9565, 0x92F2, 0x9566, 0x849C, 0x9567, 0x86ED, 0x9568, 0x9C2D,\t0x9569, 0x54C1, 0x956A, 0x5F6C, 0x956B, 0x658C, 0x956C, 0x6D5C,\r\n\t0x956D, 0x7015, 0x956E, 0x8CA7, 0x956F, 0x8CD3, 0x9570, 0x983B,\t0x9571, 0x654F, 0x9572, 0x74F6, 0x9573, 0x4E0D, 0x9574, 0x4ED8,\r\n\t0x9575, 0x57E0, 0x9576, 0x592B, 0x9577, 0x5A66, 0x9578, 0x5BCC,\t0x9579, 0x51A8, 0x957A, 0x5E03, 0x957B, 0x5E9C, 0x957C, 0x6016,\r\n\t0x957D, 0x6276, 0x957E, 0x6577, 0x9580, 0x65A7, 0x9581, 0x666E,\t0x9582, 0x6D6E, 0x9583, 0x7236, 0x9584, 0x7B26, 0x9585, 0x8150,\r\n\t0x9586, 0x819A, 0x9587, 0x8299, 0x9588, 0x8B5C, 0x9589, 0x8CA0,\t0x958A, 0x8CE6, 0x958B, 0x8D74, 0x958C, 0x961C, 0x958D, 0x9644,\r\n\t0x958E, 0x4FAE, 0x958F, 0x64AB, 0x9590, 0x6B66, 0x9591, 0x821E,\t0x9592, 0x8461, 0x9593, 0x856A, 0x9594, 0x90E8, 0x9595, 0x5C01,\r\n\t0x9596, 0x6953, 0x9597, 0x98A8, 0x9598, 0x847A, 0x9599, 0x8557,\t0x959A, 0x4F0F, 0x959B, 0x526F, 0x959C, 0x5FA9, 0x959D, 0x5E45,\r\n\t0x959E, 0x670D, 0x959F, 0x798F, 0x95A0, 0x8179, 0x95A1, 0x8907,\t0x95A2, 0x8986, 0x95A3, 0x6DF5, 0x95A4, 0x5F17, 0x95A5, 0x6255,\r\n\t0x95A6, 0x6CB8, 0x95A7, 0x4ECF, 0x95A8, 0x7269, 0x95A9, 0x9B92,\t0x95AA, 0x5206, 0x95AB, 0x543B, 0x95AC, 0x5674, 0x95AD, 0x58B3,\r\n\t0x95AE, 0x61A4, 0x95AF, 0x626E, 0x95B0, 0x711A, 0x95B1, 0x596E,\t0x95B2, 0x7C89, 0x95B3, 0x7CDE, 0x95B4, 0x7D1B, 0x95B5, 0x96F0,\r\n\t0x95B6, 0x6587, 0x95B7, 0x805E, 0x95B8, 0x4E19, 0x95B9, 0x4F75,\t0x95BA, 0x5175, 0x95BB, 0x5840, 0x95BC, 0x5E63, 0x95BD, 0x5E73,\r\n\t0x95BE, 0x5F0A, 0x95BF, 0x67C4, 0x95C0, 0x4E26, 0x95C1, 0x853D,\t0x95C2, 0x9589, 0x95C3, 0x965B, 0x95C4, 0x7C73, 0x95C5, 0x9801,\r\n\t0x95C6, 0x50FB, 0x95C7, 0x58C1, 0x95C8, 0x7656, 0x95C9, 0x78A7,\t0x95CA, 0x5225, 0x95CB, 0x77A5, 0x95CC, 0x8511, 0x95CD, 0x7B86,\r\n\t0x95CE, 0x504F, 0x95CF, 0x5909, 0x95D0, 0x7247, 0x95D1, 0x7BC7,\t0x95D2, 0x7DE8, 0x95D3, 0x8FBA, 0x95D4, 0x8FD4, 0x95D5, 0x904D,\r\n\t0x95D6, 0x4FBF, 0x95D7, 0x52C9, 0x95D8, 0x5A29, 0x95D9, 0x5F01,\t0x95DA, 0x97AD, 0x95DB, 0x4FDD, 0x95DC, 0x8217, 0x95DD, 0x92EA,\r\n\t0x95DE, 0x5703, 0x95DF, 0x6355, 0x95E0, 0x6B69, 0x95E1, 0x752B,\t0x95E2, 0x88DC, 0x95E3, 0x8F14, 0x95E4, 0x7A42, 0x95E5, 0x52DF,\r\n\t0x95E6, 0x5893, 0x95E7, 0x6155, 0x95E8, 0x620A, 0x95E9, 0x66AE,\t0x95EA, 0x6BCD, 0x95EB, 0x7C3F, 0x95EC, 0x83E9, 0x95ED, 0x5023,\r\n\t0x95EE, 0x4FF8, 0x95EF, 0x5305, 0x95F0, 0x5446, 0x95F1, 0x5831,\t0x95F2, 0x5949, 0x95F3, 0x5B9D, 0x95F4, 0x5CF0, 0x95F5, 0x5CEF,\r\n\t0x95F6, 0x5D29, 0x95F7, 0x5E96, 0x95F8, 0x62B1, 0x95F9, 0x6367,\t0x95FA, 0x653E, 0x95FB, 0x65B9, 0x95FC, 0x670B, 0x9640, 0x6CD5,\r\n\t0x9641, 0x6CE1, 0x9642, 0x70F9, 0x9643, 0x7832, 0x9644, 0x7E2B,\t0x9645, 0x80DE, 0x9646, 0x82B3, 0x9647, 0x840C, 0x9648, 0x84EC,\r\n\t0x9649, 0x8702, 0x964A, 0x8912, 0x964B, 0x8A2A, 0x964C, 0x8C4A,\t0x964D, 0x90A6, 0x964E, 0x92D2, 0x964F, 0x98FD, 0x9650, 0x9CF3,\r\n\t0x9651, 0x9D6C, 0x9652, 0x4E4F, 0x9653, 0x4EA1, 0x9654, 0x508D,\t0x9655, 0x5256, 0x9656, 0x574A, 0x9657, 0x59A8, 0x9658, 0x5E3D,\r\n\t0x9659, 0x5FD8, 0x965A, 0x5FD9, 0x965B, 0x623F, 0x965C, 0x66B4,\t0x965D, 0x671B, 0x965E, 0x67D0, 0x965F, 0x68D2, 0x9660, 0x5192,\r\n\t0x9661, 0x7D21, 0x9662, 0x80AA, 0x9663, 0x81A8, 0x9664, 0x8B00,\t0x9665, 0x8C8C, 0x9666, 0x8CBF, 0x9667, 0x927E, 0x9668, 0x9632,\r\n\t0x9669, 0x5420, 0x966A, 0x982C, 0x966B, 0x5317, 0x966C, 0x50D5,\t0x966D, 0x535C, 0x966E, 0x58A8, 0x966F, 0x64B2, 0x9670, 0x6734,\r\n\t0x9671, 0x7267, 0x9672, 0x7766, 0x9673, 0x7A46, 0x9674, 0x91E6,\t0x9675, 0x52C3, 0x9676, 0x6CA1, 0x9677, 0x6B86, 0x9678, 0x5800,\r\n\t0x9679, 0x5E4C, 0x967A, 0x5954, 0x967B, 0x672C, 0x967C, 0x7FFB,\t0x967D, 0x51E1, 0x967E, 0x76C6, 0x9680, 0x6469, 0x9681, 0x78E8,\r\n\t0x9682, 0x9B54, 0x9683, 0x9EBB, 0x9684, 0x57CB, 0x9685, 0x59B9,\t0x9686, 0x6627, 0x9687, 0x679A, 0x9688, 0x6BCE, 0x9689, 0x54E9,\r\n\t0x968A, 0x69D9, 0x968B, 0x5E55, 0x968C, 0x819C, 0x968D, 0x6795,\t0x968E, 0x9BAA, 0x968F, 0x67FE, 0x9690, 0x9C52, 0x9691, 0x685D,\r\n\t0x9692, 0x4EA6, 0x9693, 0x4FE3, 0x9694, 0x53C8, 0x9695, 0x62B9,\t0x9696, 0x672B, 0x9697, 0x6CAB, 0x9698, 0x8FC4, 0x9699, 0x4FAD,\r\n\t0x969A, 0x7E6D, 0x969B, 0x9EBF, 0x969C, 0x4E07, 0x969D, 0x6162,\t0x969E, 0x6E80, 0x969F, 0x6F2B, 0x96A0, 0x8513, 0x96A1, 0x5473,\r\n\t0x96A2, 0x672A, 0x96A3, 0x9B45, 0x96A4, 0x5DF3, 0x96A5, 0x7B95,\t0x96A6, 0x5CAC, 0x96A7, 0x5BC6, 0x96A8, 0x871C, 0x96A9, 0x6E4A,\r\n\t0x96AA, 0x84D1, 0x96AB, 0x7A14, 0x96AC, 0x8108, 0x96AD, 0x5999,\t0x96AE, 0x7C8D, 0x96AF, 0x6C11, 0x96B0, 0x7720, 0x96B1, 0x52D9,\r\n\t0x96B2, 0x5922, 0x96B3, 0x7121, 0x96B4, 0x725F, 0x96B5, 0x77DB,\t0x96B6, 0x9727, 0x96B7, 0x9D61, 0x96B8, 0x690B, 0x96B9, 0x5A7F,\r\n\t0x96BA, 0x5A18, 0x96BB, 0x51A5, 0x96BC, 0x540D, 0x96BD, 0x547D,\t0x96BE, 0x660E, 0x96BF, 0x76DF, 0x96C0, 0x8FF7, 0x96C1, 0x9298,\r\n\t0x96C2, 0x9CF4, 0x96C3, 0x59EA, 0x96C4, 0x725D, 0x96C5, 0x6EC5,\t0x96C6, 0x514D, 0x96C7, 0x68C9, 0x96C8, 0x7DBF, 0x96C9, 0x7DEC,\r\n\t0x96CA, 0x9762, 0x96CB, 0x9EBA, 0x96CC, 0x6478, 0x96CD, 0x6A21,\t0x96CE, 0x8302, 0x96CF, 0x5984, 0x96D0, 0x5B5F, 0x96D1, 0x6BDB,\r\n\t0x96D2, 0x731B, 0x96D3, 0x76F2, 0x96D4, 0x7DB2, 0x96D5, 0x8017,\t0x96D6, 0x8499, 0x96D7, 0x5132, 0x96D8, 0x6728, 0x96D9, 0x9ED9,\r\n\t0x96DA, 0x76EE, 0x96DB, 0x6762, 0x96DC, 0x52FF, 0x96DD, 0x9905,\t0x96DE, 0x5C24, 0x96DF, 0x623B, 0x96E0, 0x7C7E, 0x96E1, 0x8CB0,\r\n\t0x96E2, 0x554F, 0x96E3, 0x60B6, 0x96E4, 0x7D0B, 0x96E5, 0x9580,\t0x96E6, 0x5301, 0x96E7, 0x4E5F, 0x96E8, 0x51B6, 0x96E9, 0x591C,\r\n\t0x96EA, 0x723A, 0x96EB, 0x8036, 0x96EC, 0x91CE, 0x96ED, 0x5F25,\t0x96EE, 0x77E2, 0x96EF, 0x5384, 0x96F0, 0x5F79, 0x96F1, 0x7D04,\r\n\t0x96F2, 0x85AC, 0x96F3, 0x8A33, 0x96F4, 0x8E8D, 0x96F5, 0x9756,\t0x96F6, 0x67F3, 0x96F7, 0x85AE, 0x96F8, 0x9453, 0x96F9, 0x6109,\r\n\t0x96FA, 0x6108, 0x96FB, 0x6CB9, 0x96FC, 0x7652, 0x9740, 0x8AED,\t0x9741, 0x8F38, 0x9742, 0x552F, 0x9743, 0x4F51, 0x9744, 0x512A,\r\n\t0x9745, 0x52C7, 0x9746, 0x53CB, 0x9747, 0x5BA5, 0x9748, 0x5E7D,\t0x9749, 0x60A0, 0x974A, 0x6182, 0x974B, 0x63D6, 0x974C, 0x6709,\r\n\t0x974D, 0x67DA, 0x974E, 0x6E67, 0x974F, 0x6D8C, 0x9750, 0x7336,\t0x9751, 0x7337, 0x9752, 0x7531, 0x9753, 0x7950, 0x9754, 0x88D5,\r\n\t0x9755, 0x8A98, 0x9756, 0x904A, 0x9757, 0x9091, 0x9758, 0x90F5,\t0x9759, 0x96C4, 0x975A, 0x878D, 0x975B, 0x5915, 0x975C, 0x4E88,\r\n\t0x975D, 0x4F59, 0x975E, 0x4E0E, 0x975F, 0x8A89, 0x9760, 0x8F3F,\t0x9761, 0x9810, 0x9762, 0x50AD, 0x9763, 0x5E7C, 0x9764, 0x5996,\r\n\t0x9765, 0x5BB9, 0x9766, 0x5EB8, 0x9767, 0x63DA, 0x9768, 0x63FA,\t0x9769, 0x64C1, 0x976A, 0x66DC, 0x976B, 0x694A, 0x976C, 0x69D8,\r\n\t0x976D, 0x6D0B, 0x976E, 0x6EB6, 0x976F, 0x7194, 0x9770, 0x7528,\t0x9771, 0x7AAF, 0x9772, 0x7F8A, 0x9773, 0x8000, 0x9774, 0x8449,\r\n\t0x9775, 0x84C9, 0x9776, 0x8981, 0x9777, 0x8B21, 0x9778, 0x8E0A,\t0x9779, 0x9065, 0x977A, 0x967D, 0x977B, 0x990A, 0x977C, 0x617E,\r\n\t0x977D, 0x6291, 0x977E, 0x6B32, 0x9780, 0x6C83, 0x9781, 0x6D74,\t0x9782, 0x7FCC, 0x9783, 0x7FFC, 0x9784, 0x6DC0, 0x9785, 0x7F85,\r\n\t0x9786, 0x87BA, 0x9787, 0x88F8, 0x9788, 0x6765, 0x9789, 0x83B1,\t0x978A, 0x983C, 0x978B, 0x96F7, 0x978C, 0x6D1B, 0x978D, 0x7D61,\r\n\t0x978E, 0x843D, 0x978F, 0x916A, 0x9790, 0x4E71, 0x9791, 0x5375,\t0x9792, 0x5D50, 0x9793, 0x6B04, 0x9794, 0x6FEB, 0x9795, 0x85CD,\r\n\t0x9796, 0x862D, 0x9797, 0x89A7, 0x9798, 0x5229, 0x9799, 0x540F,\t0x979A, 0x5C65, 0x979B, 0x674E, 0x979C, 0x68A8, 0x979D, 0x7406,\r\n\t0x979E, 0x7483, 0x979F, 0x75E2, 0x97A0, 0x88CF, 0x97A1, 0x88E1,\t0x97A2, 0x91CC, 0x97A3, 0x96E2, 0x97A4, 0x9678, 0x97A5, 0x5F8B,\r\n\t0x97A6, 0x7387, 0x97A7, 0x7ACB, 0x97A8, 0x844E, 0x97A9, 0x63A0,\t0x97AA, 0x7565, 0x97AB, 0x5289, 0x97AC, 0x6D41, 0x97AD, 0x6E9C,\r\n\t0x97AE, 0x7409, 0x97AF, 0x7559, 0x97B0, 0x786B, 0x97B1, 0x7C92,\t0x97B2, 0x9686, 0x97B3, 0x7ADC, 0x97B4, 0x9F8D, 0x97B5, 0x4FB6,\r\n\t0x97B6, 0x616E, 0x97B7, 0x65C5, 0x97B8, 0x865C, 0x97B9, 0x4E86,\t0x97BA, 0x4EAE, 0x97BB, 0x50DA, 0x97BC, 0x4E21, 0x97BD, 0x51CC,\r\n\t0x97BE, 0x5BEE, 0x97BF, 0x6599, 0x97C0, 0x6881, 0x97C1, 0x6DBC,\t0x97C2, 0x731F, 0x97C3, 0x7642, 0x97C4, 0x77AD, 0x97C5, 0x7A1C,\r\n\t0x97C6, 0x7CE7, 0x97C7, 0x826F, 0x97C8, 0x8AD2, 0x97C9, 0x907C,\t0x97CA, 0x91CF, 0x97CB, 0x9675, 0x97CC, 0x9818, 0x97CD, 0x529B,\r\n\t0x97CE, 0x7DD1, 0x97CF, 0x502B, 0x97D0, 0x5398, 0x97D1, 0x6797,\t0x97D2, 0x6DCB, 0x97D3, 0x71D0, 0x97D4, 0x7433, 0x97D5, 0x81E8,\r\n\t0x97D6, 0x8F2A, 0x97D7, 0x96A3, 0x97D8, 0x9C57, 0x97D9, 0x9E9F,\t0x97DA, 0x7460, 0x97DB, 0x5841, 0x97DC, 0x6D99, 0x97DD, 0x7D2F,\r\n\t0x97DE, 0x985E, 0x97DF, 0x4EE4, 0x97E0, 0x4F36, 0x97E1, 0x4F8B,\t0x97E2, 0x51B7, 0x97E3, 0x52B1, 0x97E4, 0x5DBA, 0x97E5, 0x601C,\r\n\t0x97E6, 0x73B2, 0x97E7, 0x793C, 0x97E8, 0x82D3, 0x97E9, 0x9234,\t0x97EA, 0x96B7, 0x97EB, 0x96F6, 0x97EC, 0x970A, 0x97ED, 0x9E97,\r\n\t0x97EE, 0x9F62, 0x97EF, 0x66A6, 0x97F0, 0x6B74, 0x97F1, 0x5217,\t0x97F2, 0x52A3, 0x97F3, 0x70C8, 0x97F4, 0x88C2, 0x97F5, 0x5EC9,\r\n\t0x97F6, 0x604B, 0x97F7, 0x6190, 0x97F8, 0x6F23, 0x97F9, 0x7149,\t0x97FA, 0x7C3E, 0x97FB, 0x7DF4, 0x97FC, 0x806F, 0x9840, 0x84EE,\r\n\t0x9841, 0x9023, 0x9842, 0x932C, 0x9843, 0x5442, 0x9844, 0x9B6F,\t0x9845, 0x6AD3, 0x9846, 0x7089, 0x9847, 0x8CC2, 0x9848, 0x8DEF,\r\n\t0x9849, 0x9732, 0x984A, 0x52B4, 0x984B, 0x5A41, 0x984C, 0x5ECA,\t0x984D, 0x5F04, 0x984E, 0x6717, 0x984F, 0x697C, 0x9850, 0x6994,\r\n\t0x9851, 0x6D6A, 0x9852, 0x6F0F, 0x9853, 0x7262, 0x9854, 0x72FC,\t0x9855, 0x7BED, 0x9856, 0x8001, 0x9857, 0x807E, 0x9858, 0x874B,\r\n\t0x9859, 0x90CE, 0x985A, 0x516D, 0x985B, 0x9E93, 0x985C, 0x7984,\t0x985D, 0x808B, 0x985E, 0x9332, 0x985F, 0x8AD6, 0x9860, 0x502D,\r\n\t0x9861, 0x548C, 0x9862, 0x8A71, 0x9863, 0x6B6A, 0x9864, 0x8CC4,\t0x9865, 0x8107, 0x9866, 0x60D1, 0x9867, 0x67A0, 0x9868, 0x9DF2,\r\n\t0x9869, 0x4E99, 0x986A, 0x4E98, 0x986B, 0x9C10, 0x986C, 0x8A6B,\t0x986D, 0x85C1, 0x986E, 0x8568, 0x986F, 0x6900, 0x9870, 0x6E7E,\r\n\t0x9871, 0x7897, 0x9872, 0x8155, 0x989F, 0x5F0C, 0x98A0, 0x4E10,\t0x98A1, 0x4E15, 0x98A2, 0x4E2A, 0x98A3, 0x4E31, 0x98A4, 0x4E36,\r\n\t0x98A5, 0x4E3C, 0x98A6, 0x4E3F, 0x98A7, 0x4E42, 0x98A8, 0x4E56,\t0x98A9, 0x4E58, 0x98AA, 0x4E82, 0x98AB, 0x4E85, 0x98AC, 0x8C6B,\r\n\t0x98AD, 0x4E8A, 0x98AE, 0x8212, 0x98AF, 0x5F0D, 0x98B0, 0x4E8E,\t0x98B1, 0x4E9E, 0x98B2, 0x4E9F, 0x98B3, 0x4EA0, 0x98B4, 0x4EA2,\r\n\t0x98B5, 0x4EB0, 0x98B6, 0x4EB3, 0x98B7, 0x4EB6, 0x98B8, 0x4ECE,\t0x98B9, 0x4ECD, 0x98BA, 0x4EC4, 0x98BB, 0x4EC6, 0x98BC, 0x4EC2,\r\n\t0x98BD, 0x4ED7, 0x98BE, 0x4EDE, 0x98BF, 0x4EED, 0x98C0, 0x4EDF,\t0x98C1, 0x4EF7, 0x98C2, 0x4F09, 0x98C3, 0x4F5A, 0x98C4, 0x4F30,\r\n\t0x98C5, 0x4F5B, 0x98C6, 0x4F5D, 0x98C7, 0x4F57, 0x98C8, 0x4F47,\t0x98C9, 0x4F76, 0x98CA, 0x4F88, 0x98CB, 0x4F8F, 0x98CC, 0x4F98,\r\n\t0x98CD, 0x4F7B, 0x98CE, 0x4F69, 0x98CF, 0x4F70, 0x98D0, 0x4F91,\t0x98D1, 0x4F6F, 0x98D2, 0x4F86, 0x98D3, 0x4F96, 0x98D4, 0x5118,\r\n\t0x98D5, 0x4FD4, 0x98D6, 0x4FDF, 0x98D7, 0x4FCE, 0x98D8, 0x4FD8,\t0x98D9, 0x4FDB, 0x98DA, 0x4FD1, 0x98DB, 0x4FDA, 0x98DC, 0x4FD0,\r\n\t0x98DD, 0x4FE4, 0x98DE, 0x4FE5, 0x98DF, 0x501A, 0x98E0, 0x5028,\t0x98E1, 0x5014, 0x98E2, 0x502A, 0x98E3, 0x5025, 0x98E4, 0x5005,\r\n\t0x98E5, 0x4F1C, 0x98E6, 0x4FF6, 0x98E7, 0x5021, 0x98E8, 0x5029,\t0x98E9, 0x502C, 0x98EA, 0x4FFE, 0x98EB, 0x4FEF, 0x98EC, 0x5011,\r\n\t0x98ED, 0x5006, 0x98EE, 0x5043, 0x98EF, 0x5047, 0x98F0, 0x6703,\t0x98F1, 0x5055, 0x98F2, 0x5050, 0x98F3, 0x5048, 0x98F4, 0x505A,\r\n\t0x98F5, 0x5056, 0x98F6, 0x506C, 0x98F7, 0x5078, 0x98F8, 0x5080,\t0x98F9, 0x509A, 0x98FA, 0x5085, 0x98FB, 0x50B4, 0x98FC, 0x50B2,\r\n\t0x9940, 0x50C9, 0x9941, 0x50CA, 0x9942, 0x50B3, 0x9943, 0x50C2,\t0x9944, 0x50D6, 0x9945, 0x50DE, 0x9946, 0x50E5, 0x9947, 0x50ED,\r\n\t0x9948, 0x50E3, 0x9949, 0x50EE, 0x994A, 0x50F9, 0x994B, 0x50F5,\t0x994C, 0x5109, 0x994D, 0x5101, 0x994E, 0x5102, 0x994F, 0x5116,\r\n\t0x9950, 0x5115, 0x9951, 0x5114, 0x9952, 0x511A, 0x9953, 0x5121,\t0x9954, 0x513A, 0x9955, 0x5137, 0x9956, 0x513C, 0x9957, 0x513B,\r\n\t0x9958, 0x513F, 0x9959, 0x5140, 0x995A, 0x5152, 0x995B, 0x514C,\t0x995C, 0x5154, 0x995D, 0x5162, 0x995E, 0x7AF8, 0x995F, 0x5169,\r\n\t0x9960, 0x516A, 0x9961, 0x516E, 0x9962, 0x5180, 0x9963, 0x5182,\t0x9964, 0x56D8, 0x9965, 0x518C, 0x9966, 0x5189, 0x9967, 0x518F,\r\n\t0x9968, 0x5191, 0x9969, 0x5193, 0x996A, 0x5195, 0x996B, 0x5196,\t0x996C, 0x51A4, 0x996D, 0x51A6, 0x996E, 0x51A2, 0x996F, 0x51A9,\r\n\t0x9970, 0x51AA, 0x9971, 0x51AB, 0x9972, 0x51B3, 0x9973, 0x51B1,\t0x9974, 0x51B2, 0x9975, 0x51B0, 0x9976, 0x51B5, 0x9977, 0x51BD,\r\n\t0x9978, 0x51C5, 0x9979, 0x51C9, 0x997A, 0x51DB, 0x997B, 0x51E0,\t0x997C, 0x8655, 0x997D, 0x51E9, 0x997E, 0x51ED, 0x9980, 0x51F0,\r\n\t0x9981, 0x51F5, 0x9982, 0x51FE, 0x9983, 0x5204, 0x9984, 0x520B,\t0x9985, 0x5214, 0x9986, 0x520E, 0x9987, 0x5227, 0x9988, 0x522A,\r\n\t0x9989, 0x522E, 0x998A, 0x5233, 0x998B, 0x5239, 0x998C, 0x524F,\t0x998D, 0x5244, 0x998E, 0x524B, 0x998F, 0x524C, 0x9990, 0x525E,\r\n\t0x9991, 0x5254, 0x9992, 0x526A, 0x9993, 0x5274, 0x9994, 0x5269,\t0x9995, 0x5273, 0x9996, 0x527F, 0x9997, 0x527D, 0x9998, 0x528D,\r\n\t0x9999, 0x5294, 0x999A, 0x5292, 0x999B, 0x5271, 0x999C, 0x5288,\t0x999D, 0x5291, 0x999E, 0x8FA8, 0x999F, 0x8FA7, 0x99A0, 0x52AC,\r\n\t0x99A1, 0x52AD, 0x99A2, 0x52BC, 0x99A3, 0x52B5, 0x99A4, 0x52C1,\t0x99A5, 0x52CD, 0x99A6, 0x52D7, 0x99A7, 0x52DE, 0x99A8, 0x52E3,\r\n\t0x99A9, 0x52E6, 0x99AA, 0x98ED, 0x99AB, 0x52E0, 0x99AC, 0x52F3,\t0x99AD, 0x52F5, 0x99AE, 0x52F8, 0x99AF, 0x52F9, 0x99B0, 0x5306,\r\n\t0x99B1, 0x5308, 0x99B2, 0x7538, 0x99B3, 0x530D, 0x99B4, 0x5310,\t0x99B5, 0x530F, 0x99B6, 0x5315, 0x99B7, 0x531A, 0x99B8, 0x5323,\r\n\t0x99B9, 0x532F, 0x99BA, 0x5331, 0x99BB, 0x5333, 0x99BC, 0x5338,\t0x99BD, 0x5340, 0x99BE, 0x5346, 0x99BF, 0x5345, 0x99C0, 0x4E17,\r\n\t0x99C1, 0x5349, 0x99C2, 0x534D, 0x99C3, 0x51D6, 0x99C4, 0x535E,\t0x99C5, 0x5369, 0x99C6, 0x536E, 0x99C7, 0x5918, 0x99C8, 0x537B,\r\n\t0x99C9, 0x5377, 0x99CA, 0x5382, 0x99CB, 0x5396, 0x99CC, 0x53A0,\t0x99CD, 0x53A6, 0x99CE, 0x53A5, 0x99CF, 0x53AE, 0x99D0, 0x53B0,\r\n\t0x99D1, 0x53B6, 0x99D2, 0x53C3, 0x99D3, 0x7C12, 0x99D4, 0x96D9,\t0x99D5, 0x53DF, 0x99D6, 0x66FC, 0x99D7, 0x71EE, 0x99D8, 0x53EE,\r\n\t0x99D9, 0x53E8, 0x99DA, 0x53ED, 0x99DB, 0x53FA, 0x99DC, 0x5401,\t0x99DD, 0x543D, 0x99DE, 0x5440, 0x99DF, 0x542C, 0x99E0, 0x542D,\r\n\t0x99E1, 0x543C, 0x99E2, 0x542E, 0x99E3, 0x5436, 0x99E4, 0x5429,\t0x99E5, 0x541D, 0x99E6, 0x544E, 0x99E7, 0x548F, 0x99E8, 0x5475,\r\n\t0x99E9, 0x548E, 0x99EA, 0x545F, 0x99EB, 0x5471, 0x99EC, 0x5477,\t0x99ED, 0x5470, 0x99EE, 0x5492, 0x99EF, 0x547B, 0x99F0, 0x5480,\r\n\t0x99F1, 0x5476, 0x99F2, 0x5484, 0x99F3, 0x5490, 0x99F4, 0x5486,\t0x99F5, 0x54C7, 0x99F6, 0x54A2, 0x99F7, 0x54B8, 0x99F8, 0x54A5,\r\n\t0x99F9, 0x54AC, 0x99FA, 0x54C4, 0x99FB, 0x54C8, 0x99FC, 0x54A8,\t0x9A40, 0x54AB, 0x9A41, 0x54C2, 0x9A42, 0x54A4, 0x9A43, 0x54BE,\r\n\t0x9A44, 0x54BC, 0x9A45, 0x54D8, 0x9A46, 0x54E5, 0x9A47, 0x54E6,\t0x9A48, 0x550F, 0x9A49, 0x5514, 0x9A4A, 0x54FD, 0x9A4B, 0x54EE,\r\n\t0x9A4C, 0x54ED, 0x9A4D, 0x54FA, 0x9A4E, 0x54E2, 0x9A4F, 0x5539,\t0x9A50, 0x5540, 0x9A51, 0x5563, 0x9A52, 0x554C, 0x9A53, 0x552E,\r\n\t0x9A54, 0x555C, 0x9A55, 0x5545, 0x9A56, 0x5556, 0x9A57, 0x5557,\t0x9A58, 0x5538, 0x9A59, 0x5533, 0x9A5A, 0x555D, 0x9A5B, 0x5599,\r\n\t0x9A5C, 0x5580, 0x9A5D, 0x54AF, 0x9A5E, 0x558A, 0x9A5F, 0x559F,\t0x9A60, 0x557B, 0x9A61, 0x557E, 0x9A62, 0x5598, 0x9A63, 0x559E,\r\n\t0x9A64, 0x55AE, 0x9A65, 0x557C, 0x9A66, 0x5583, 0x9A67, 0x55A9,\t0x9A68, 0x5587, 0x9A69, 0x55A8, 0x9A6A, 0x55DA, 0x9A6B, 0x55C5,\r\n\t0x9A6C, 0x55DF, 0x9A6D, 0x55C4, 0x9A6E, 0x55DC, 0x9A6F, 0x55E4,\t0x9A70, 0x55D4, 0x9A71, 0x5614, 0x9A72, 0x55F7, 0x9A73, 0x5616,\r\n\t0x9A74, 0x55FE, 0x9A75, 0x55FD, 0x9A76, 0x561B, 0x9A77, 0x55F9,\t0x9A78, 0x564E, 0x9A79, 0x5650, 0x9A7A, 0x71DF, 0x9A7B, 0x5634,\r\n\t0x9A7C, 0x5636, 0x9A7D, 0x5632, 0x9A7E, 0x5638, 0x9A80, 0x566B,\t0x9A81, 0x5664, 0x9A82, 0x562F, 0x9A83, 0x566C, 0x9A84, 0x566A,\r\n\t0x9A85, 0x5686, 0x9A86, 0x5680, 0x9A87, 0x568A, 0x9A88, 0x56A0,\t0x9A89, 0x5694, 0x9A8A, 0x568F, 0x9A8B, 0x56A5, 0x9A8C, 0x56AE,\r\n\t0x9A8D, 0x56B6, 0x9A8E, 0x56B4, 0x9A8F, 0x56C2, 0x9A90, 0x56BC,\t0x9A91, 0x56C1, 0x9A92, 0x56C3, 0x9A93, 0x56C0, 0x9A94, 0x56C8,\r\n\t0x9A95, 0x56CE, 0x9A96, 0x56D1, 0x9A97, 0x56D3, 0x9A98, 0x56D7,\t0x9A99, 0x56EE, 0x9A9A, 0x56F9, 0x9A9B, 0x5700, 0x9A9C, 0x56FF,\r\n\t0x9A9D, 0x5704, 0x9A9E, 0x5709, 0x9A9F, 0x5708, 0x9AA0, 0x570B,\t0x9AA1, 0x570D, 0x9AA2, 0x5713, 0x9AA3, 0x5718, 0x9AA4, 0x5716,\r\n\t0x9AA5, 0x55C7, 0x9AA6, 0x571C, 0x9AA7, 0x5726, 0x9AA8, 0x5737,\t0x9AA9, 0x5738, 0x9AAA, 0x574E, 0x9AAB, 0x573B, 0x9AAC, 0x5740,\r\n\t0x9AAD, 0x574F, 0x9AAE, 0x5769, 0x9AAF, 0x57C0, 0x9AB0, 0x5788,\t0x9AB1, 0x5761, 0x9AB2, 0x577F, 0x9AB3, 0x5789, 0x9AB4, 0x5793,\r\n\t0x9AB5, 0x57A0, 0x9AB6, 0x57B3, 0x9AB7, 0x57A4, 0x9AB8, 0x57AA,\t0x9AB9, 0x57B0, 0x9ABA, 0x57C3, 0x9ABB, 0x57C6, 0x9ABC, 0x57D4,\r\n\t0x9ABD, 0x57D2, 0x9ABE, 0x57D3, 0x9ABF, 0x580A, 0x9AC0, 0x57D6,\t0x9AC1, 0x57E3, 0x9AC2, 0x580B, 0x9AC3, 0x5819, 0x9AC4, 0x581D,\r\n\t0x9AC5, 0x5872, 0x9AC6, 0x5821, 0x9AC7, 0x5862, 0x9AC8, 0x584B,\t0x9AC9, 0x5870, 0x9ACA, 0x6BC0, 0x9ACB, 0x5852, 0x9ACC, 0x583D,\r\n\t0x9ACD, 0x5879, 0x9ACE, 0x5885, 0x9ACF, 0x58B9, 0x9AD0, 0x589F,\t0x9AD1, 0x58AB, 0x9AD2, 0x58BA, 0x9AD3, 0x58DE, 0x9AD4, 0x58BB,\r\n\t0x9AD5, 0x58B8, 0x9AD6, 0x58AE, 0x9AD7, 0x58C5, 0x9AD8, 0x58D3,\t0x9AD9, 0x58D1, 0x9ADA, 0x58D7, 0x9ADB, 0x58D9, 0x9ADC, 0x58D8,\r\n\t0x9ADD, 0x58E5, 0x9ADE, 0x58DC, 0x9ADF, 0x58E4, 0x9AE0, 0x58DF,\t0x9AE1, 0x58EF, 0x9AE2, 0x58FA, 0x9AE3, 0x58F9, 0x9AE4, 0x58FB,\r\n\t0x9AE5, 0x58FC, 0x9AE6, 0x58FD, 0x9AE7, 0x5902, 0x9AE8, 0x590A,\t0x9AE9, 0x5910, 0x9AEA, 0x591B, 0x9AEB, 0x68A6, 0x9AEC, 0x5925,\r\n\t0x9AED, 0x592C, 0x9AEE, 0x592D, 0x9AEF, 0x5932, 0x9AF0, 0x5938,\t0x9AF1, 0x593E, 0x9AF2, 0x7AD2, 0x9AF3, 0x5955, 0x9AF4, 0x5950,\r\n\t0x9AF5, 0x594E, 0x9AF6, 0x595A, 0x9AF7, 0x5958, 0x9AF8, 0x5962,\t0x9AF9, 0x5960, 0x9AFA, 0x5967, 0x9AFB, 0x596C, 0x9AFC, 0x5969,\r\n\t0x9B40, 0x5978, 0x9B41, 0x5981, 0x9B42, 0x599D, 0x9B43, 0x4F5E,\t0x9B44, 0x4FAB, 0x9B45, 0x59A3, 0x9B46, 0x59B2, 0x9B47, 0x59C6,\r\n\t0x9B48, 0x59E8, 0x9B49, 0x59DC, 0x9B4A, 0x598D, 0x9B4B, 0x59D9,\t0x9B4C, 0x59DA, 0x9B4D, 0x5A25, 0x9B4E, 0x5A1F, 0x9B4F, 0x5A11,\r\n\t0x9B50, 0x5A1C, 0x9B51, 0x5A09, 0x9B52, 0x5A1A, 0x9B53, 0x5A40,\t0x9B54, 0x5A6C, 0x9B55, 0x5A49, 0x9B56, 0x5A35, 0x9B57, 0x5A36,\r\n\t0x9B58, 0x5A62, 0x9B59, 0x5A6A, 0x9B5A, 0x5A9A, 0x9B5B, 0x5ABC,\t0x9B5C, 0x5ABE, 0x9B5D, 0x5ACB, 0x9B5E, 0x5AC2, 0x9B5F, 0x5ABD,\r\n\t0x9B60, 0x5AE3, 0x9B61, 0x5AD7, 0x9B62, 0x5AE6, 0x9B63, 0x5AE9,\t0x9B64, 0x5AD6, 0x9B65, 0x5AFA, 0x9B66, 0x5AFB, 0x9B67, 0x5B0C,\r\n\t0x9B68, 0x5B0B, 0x9B69, 0x5B16, 0x9B6A, 0x5B32, 0x9B6B, 0x5AD0,\t0x9B6C, 0x5B2A, 0x9B6D, 0x5B36, 0x9B6E, 0x5B3E, 0x9B6F, 0x5B43,\r\n\t0x9B70, 0x5B45, 0x9B71, 0x5B40, 0x9B72, 0x5B51, 0x9B73, 0x5B55,\t0x9B74, 0x5B5A, 0x9B75, 0x5B5B, 0x9B76, 0x5B65, 0x9B77, 0x5B69,\r\n\t0x9B78, 0x5B70, 0x9B79, 0x5B73, 0x9B7A, 0x5B75, 0x9B7B, 0x5B78,\t0x9B7C, 0x6588, 0x9B7D, 0x5B7A, 0x9B7E, 0x5B80, 0x9B80, 0x5B83,\r\n\t0x9B81, 0x5BA6, 0x9B82, 0x5BB8, 0x9B83, 0x5BC3, 0x9B84, 0x5BC7,\t0x9B85, 0x5BC9, 0x9B86, 0x5BD4, 0x9B87, 0x5BD0, 0x9B88, 0x5BE4,\r\n\t0x9B89, 0x5BE6, 0x9B8A, 0x5BE2, 0x9B8B, 0x5BDE, 0x9B8C, 0x5BE5,\t0x9B8D, 0x5BEB, 0x9B8E, 0x5BF0, 0x9B8F, 0x5BF6, 0x9B90, 0x5BF3,\r\n\t0x9B91, 0x5C05, 0x9B92, 0x5C07, 0x9B93, 0x5C08, 0x9B94, 0x5C0D,\t0x9B95, 0x5C13, 0x9B96, 0x5C20, 0x9B97, 0x5C22, 0x9B98, 0x5C28,\r\n\t0x9B99, 0x5C38, 0x9B9A, 0x5C39, 0x9B9B, 0x5C41, 0x9B9C, 0x5C46,\t0x9B9D, 0x5C4E, 0x9B9E, 0x5C53, 0x9B9F, 0x5C50, 0x9BA0, 0x5C4F,\r\n\t0x9BA1, 0x5B71, 0x9BA2, 0x5C6C, 0x9BA3, 0x5C6E, 0x9BA4, 0x4E62,\t0x9BA5, 0x5C76, 0x9BA6, 0x5C79, 0x9BA7, 0x5C8C, 0x9BA8, 0x5C91,\r\n\t0x9BA9, 0x5C94, 0x9BAA, 0x599B, 0x9BAB, 0x5CAB, 0x9BAC, 0x5CBB,\t0x9BAD, 0x5CB6, 0x9BAE, 0x5CBC, 0x9BAF, 0x5CB7, 0x9BB0, 0x5CC5,\r\n\t0x9BB1, 0x5CBE, 0x9BB2, 0x5CC7, 0x9BB3, 0x5CD9, 0x9BB4, 0x5CE9,\t0x9BB5, 0x5CFD, 0x9BB6, 0x5CFA, 0x9BB7, 0x5CED, 0x9BB8, 0x5D8C,\r\n\t0x9BB9, 0x5CEA, 0x9BBA, 0x5D0B, 0x9BBB, 0x5D15, 0x9BBC, 0x5D17,\t0x9BBD, 0x5D5C, 0x9BBE, 0x5D1F, 0x9BBF, 0x5D1B, 0x9BC0, 0x5D11,\r\n\t0x9BC1, 0x5D14, 0x9BC2, 0x5D22, 0x9BC3, 0x5D1A, 0x9BC4, 0x5D19,\t0x9BC5, 0x5D18, 0x9BC6, 0x5D4C, 0x9BC7, 0x5D52, 0x9BC8, 0x5D4E,\r\n\t0x9BC9, 0x5D4B, 0x9BCA, 0x5D6C, 0x9BCB, 0x5D73, 0x9BCC, 0x5D76,\t0x9BCD, 0x5D87, 0x9BCE, 0x5D84, 0x9BCF, 0x5D82, 0x9BD0, 0x5DA2,\r\n\t0x9BD1, 0x5D9D, 0x9BD2, 0x5DAC, 0x9BD3, 0x5DAE, 0x9BD4, 0x5DBD,\t0x9BD5, 0x5D90, 0x9BD6, 0x5DB7, 0x9BD7, 0x5DBC, 0x9BD8, 0x5DC9,\r\n\t0x9BD9, 0x5DCD, 0x9BDA, 0x5DD3, 0x9BDB, 0x5DD2, 0x9BDC, 0x5DD6,\t0x9BDD, 0x5DDB, 0x9BDE, 0x5DEB, 0x9BDF, 0x5DF2, 0x9BE0, 0x5DF5,\r\n\t0x9BE1, 0x5E0B, 0x9BE2, 0x5E1A, 0x9BE3, 0x5E19, 0x9BE4, 0x5E11,\t0x9BE5, 0x5E1B, 0x9BE6, 0x5E36, 0x9BE7, 0x5E37, 0x9BE8, 0x5E44,\r\n\t0x9BE9, 0x5E43, 0x9BEA, 0x5E40, 0x9BEB, 0x5E4E, 0x9BEC, 0x5E57,\t0x9BED, 0x5E54, 0x9BEE, 0x5E5F, 0x9BEF, 0x5E62, 0x9BF0, 0x5E64,\r\n\t0x9BF1, 0x5E47, 0x9BF2, 0x5E75, 0x9BF3, 0x5E76, 0x9BF4, 0x5E7A,\t0x9BF5, 0x9EBC, 0x9BF6, 0x5E7F, 0x9BF7, 0x5EA0, 0x9BF8, 0x5EC1,\r\n\t0x9BF9, 0x5EC2, 0x9BFA, 0x5EC8, 0x9BFB, 0x5ED0, 0x9BFC, 0x5ECF,\t0x9C40, 0x5ED6, 0x9C41, 0x5EE3, 0x9C42, 0x5EDD, 0x9C43, 0x5EDA,\r\n\t0x9C44, 0x5EDB, 0x9C45, 0x5EE2, 0x9C46, 0x5EE1, 0x9C47, 0x5EE8,\t0x9C48, 0x5EE9, 0x9C49, 0x5EEC, 0x9C4A, 0x5EF1, 0x9C4B, 0x5EF3,\r\n\t0x9C4C, 0x5EF0, 0x9C4D, 0x5EF4, 0x9C4E, 0x5EF8, 0x9C4F, 0x5EFE,\t0x9C50, 0x5F03, 0x9C51, 0x5F09, 0x9C52, 0x5F5D, 0x9C53, 0x5F5C,\r\n\t0x9C54, 0x5F0B, 0x9C55, 0x5F11, 0x9C56, 0x5F16, 0x9C57, 0x5F29,\t0x9C58, 0x5F2D, 0x9C59, 0x5F38, 0x9C5A, 0x5F41, 0x9C5B, 0x5F48,\r\n\t0x9C5C, 0x5F4C, 0x9C5D, 0x5F4E, 0x9C5E, 0x5F2F, 0x9C5F, 0x5F51,\t0x9C60, 0x5F56, 0x9C61, 0x5F57, 0x9C62, 0x5F59, 0x9C63, 0x5F61,\r\n\t0x9C64, 0x5F6D, 0x9C65, 0x5F73, 0x9C66, 0x5F77, 0x9C67, 0x5F83,\t0x9C68, 0x5F82, 0x9C69, 0x5F7F, 0x9C6A, 0x5F8A, 0x9C6B, 0x5F88,\r\n\t0x9C6C, 0x5F91, 0x9C6D, 0x5F87, 0x9C6E, 0x5F9E, 0x9C6F, 0x5F99,\t0x9C70, 0x5F98, 0x9C71, 0x5FA0, 0x9C72, 0x5FA8, 0x9C73, 0x5FAD,\r\n\t0x9C74, 0x5FBC, 0x9C75, 0x5FD6, 0x9C76, 0x5FFB, 0x9C77, 0x5FE4,\t0x9C78, 0x5FF8, 0x9C79, 0x5FF1, 0x9C7A, 0x5FDD, 0x9C7B, 0x60B3,\r\n\t0x9C7C, 0x5FFF, 0x9C7D, 0x6021, 0x9C7E, 0x6060, 0x9C80, 0x6019,\t0x9C81, 0x6010, 0x9C82, 0x6029, 0x9C83, 0x600E, 0x9C84, 0x6031,\r\n\t0x9C85, 0x601B, 0x9C86, 0x6015, 0x9C87, 0x602B, 0x9C88, 0x6026,\t0x9C89, 0x600F, 0x9C8A, 0x603A, 0x9C8B, 0x605A, 0x9C8C, 0x6041,\r\n\t0x9C8D, 0x606A, 0x9C8E, 0x6077, 0x9C8F, 0x605F, 0x9C90, 0x604A,\t0x9C91, 0x6046, 0x9C92, 0x604D, 0x9C93, 0x6063, 0x9C94, 0x6043,\r\n\t0x9C95, 0x6064, 0x9C96, 0x6042, 0x9C97, 0x606C, 0x9C98, 0x606B,\t0x9C99, 0x6059, 0x9C9A, 0x6081, 0x9C9B, 0x608D, 0x9C9C, 0x60E7,\r\n\t0x9C9D, 0x6083, 0x9C9E, 0x609A, 0x9C9F, 0x6084, 0x9CA0, 0x609B,\t0x9CA1, 0x6096, 0x9CA2, 0x6097, 0x9CA3, 0x6092, 0x9CA4, 0x60A7,\r\n\t0x9CA5, 0x608B, 0x9CA6, 0x60E1, 0x9CA7, 0x60B8, 0x9CA8, 0x60E0,\t0x9CA9, 0x60D3, 0x9CAA, 0x60B4, 0x9CAB, 0x5FF0, 0x9CAC, 0x60BD,\r\n\t0x9CAD, 0x60C6, 0x9CAE, 0x60B5, 0x9CAF, 0x60D8, 0x9CB0, 0x614D,\t0x9CB1, 0x6115, 0x9CB2, 0x6106, 0x9CB3, 0x60F6, 0x9CB4, 0x60F7,\r\n\t0x9CB5, 0x6100, 0x9CB6, 0x60F4, 0x9CB7, 0x60FA, 0x9CB8, 0x6103,\t0x9CB9, 0x6121, 0x9CBA, 0x60FB, 0x9CBB, 0x60F1, 0x9CBC, 0x610D,\r\n\t0x9CBD, 0x610E, 0x9CBE, 0x6147, 0x9CBF, 0x613E, 0x9CC0, 0x6128,\t0x9CC1, 0x6127, 0x9CC2, 0x614A, 0x9CC3, 0x613F, 0x9CC4, 0x613C,\r\n\t0x9CC5, 0x612C, 0x9CC6, 0x6134, 0x9CC7, 0x613D, 0x9CC8, 0x6142,\t0x9CC9, 0x6144, 0x9CCA, 0x6173, 0x9CCB, 0x6177, 0x9CCC, 0x6158,\r\n\t0x9CCD, 0x6159, 0x9CCE, 0x615A, 0x9CCF, 0x616B, 0x9CD0, 0x6174,\t0x9CD1, 0x616F, 0x9CD2, 0x6165, 0x9CD3, 0x6171, 0x9CD4, 0x615F,\r\n\t0x9CD5, 0x615D, 0x9CD6, 0x6153, 0x9CD7, 0x6175, 0x9CD8, 0x6199,\t0x9CD9, 0x6196, 0x9CDA, 0x6187, 0x9CDB, 0x61AC, 0x9CDC, 0x6194,\r\n\t0x9CDD, 0x619A, 0x9CDE, 0x618A, 0x9CDF, 0x6191, 0x9CE0, 0x61AB,\t0x9CE1, 0x61AE, 0x9CE2, 0x61CC, 0x9CE3, 0x61CA, 0x9CE4, 0x61C9,\r\n\t0x9CE5, 0x61F7, 0x9CE6, 0x61C8, 0x9CE7, 0x61C3, 0x9CE8, 0x61C6,\t0x9CE9, 0x61BA, 0x9CEA, 0x61CB, 0x9CEB, 0x7F79, 0x9CEC, 0x61CD,\r\n\t0x9CED, 0x61E6, 0x9CEE, 0x61E3, 0x9CEF, 0x61F6, 0x9CF0, 0x61FA,\t0x9CF1, 0x61F4, 0x9CF2, 0x61FF, 0x9CF3, 0x61FD, 0x9CF4, 0x61FC,\r\n\t0x9CF5, 0x61FE, 0x9CF6, 0x6200, 0x9CF7, 0x6208, 0x9CF8, 0x6209,\t0x9CF9, 0x620D, 0x9CFA, 0x620C, 0x9CFB, 0x6214, 0x9CFC, 0x621B,\r\n\t0x9D40, 0x621E, 0x9D41, 0x6221, 0x9D42, 0x622A, 0x9D43, 0x622E,\t0x9D44, 0x6230, 0x9D45, 0x6232, 0x9D46, 0x6233, 0x9D47, 0x6241,\r\n\t0x9D48, 0x624E, 0x9D49, 0x625E, 0x9D4A, 0x6263, 0x9D4B, 0x625B,\t0x9D4C, 0x6260, 0x9D4D, 0x6268, 0x9D4E, 0x627C, 0x9D4F, 0x6282,\r\n\t0x9D50, 0x6289, 0x9D51, 0x627E, 0x9D52, 0x6292, 0x9D53, 0x6293,\t0x9D54, 0x6296, 0x9D55, 0x62D4, 0x9D56, 0x6283, 0x9D57, 0x6294,\r\n\t0x9D58, 0x62D7, 0x9D59, 0x62D1, 0x9D5A, 0x62BB, 0x9D5B, 0x62CF,\t0x9D5C, 0x62FF, 0x9D5D, 0x62C6, 0x9D5E, 0x64D4, 0x9D5F, 0x62C8,\r\n\t0x9D60, 0x62DC, 0x9D61, 0x62CC, 0x9D62, 0x62CA, 0x9D63, 0x62C2,\t0x9D64, 0x62C7, 0x9D65, 0x629B, 0x9D66, 0x62C9, 0x9D67, 0x630C,\r\n\t0x9D68, 0x62EE, 0x9D69, 0x62F1, 0x9D6A, 0x6327, 0x9D6B, 0x6302,\t0x9D6C, 0x6308, 0x9D6D, 0x62EF, 0x9D6E, 0x62F5, 0x9D6F, 0x6350,\r\n\t0x9D70, 0x633E, 0x9D71, 0x634D, 0x9D72, 0x641C, 0x9D73, 0x634F,\t0x9D74, 0x6396, 0x9D75, 0x638E, 0x9D76, 0x6380, 0x9D77, 0x63AB,\r\n\t0x9D78, 0x6376, 0x9D79, 0x63A3, 0x9D7A, 0x638F, 0x9D7B, 0x6389,\t0x9D7C, 0x639F, 0x9D7D, 0x63B5, 0x9D7E, 0x636B, 0x9D80, 0x6369,\r\n\t0x9D81, 0x63BE, 0x9D82, 0x63E9, 0x9D83, 0x63C0, 0x9D84, 0x63C6,\t0x9D85, 0x63E3, 0x9D86, 0x63C9, 0x9D87, 0x63D2, 0x9D88, 0x63F6,\r\n\t0x9D89, 0x63C4, 0x9D8A, 0x6416, 0x9D8B, 0x6434, 0x9D8C, 0x6406,\t0x9D8D, 0x6413, 0x9D8E, 0x6426, 0x9D8F, 0x6436, 0x9D90, 0x651D,\r\n\t0x9D91, 0x6417, 0x9D92, 0x6428, 0x9D93, 0x640F, 0x9D94, 0x6467,\t0x9D95, 0x646F, 0x9D96, 0x6476, 0x9D97, 0x644E, 0x9D98, 0x652A,\r\n\t0x9D99, 0x6495, 0x9D9A, 0x6493, 0x9D9B, 0x64A5, 0x9D9C, 0x64A9,\t0x9D9D, 0x6488, 0x9D9E, 0x64BC, 0x9D9F, 0x64DA, 0x9DA0, 0x64D2,\r\n\t0x9DA1, 0x64C5, 0x9DA2, 0x64C7, 0x9DA3, 0x64BB, 0x9DA4, 0x64D8,\t0x9DA5, 0x64C2, 0x9DA6, 0x64F1, 0x9DA7, 0x64E7, 0x9DA8, 0x8209,\r\n\t0x9DA9, 0x64E0, 0x9DAA, 0x64E1, 0x9DAB, 0x62AC, 0x9DAC, 0x64E3,\t0x9DAD, 0x64EF, 0x9DAE, 0x652C, 0x9DAF, 0x64F6, 0x9DB0, 0x64F4,\r\n\t0x9DB1, 0x64F2, 0x9DB2, 0x64FA, 0x9DB3, 0x6500, 0x9DB4, 0x64FD,\t0x9DB5, 0x6518, 0x9DB6, 0x651C, 0x9DB7, 0x6505, 0x9DB8, 0x6524,\r\n\t0x9DB9, 0x6523, 0x9DBA, 0x652B, 0x9DBB, 0x6534, 0x9DBC, 0x6535,\t0x9DBD, 0x6537, 0x9DBE, 0x6536, 0x9DBF, 0x6538, 0x9DC0, 0x754B,\r\n\t0x9DC1, 0x6548, 0x9DC2, 0x6556, 0x9DC3, 0x6555, 0x9DC4, 0x654D,\t0x9DC5, 0x6558, 0x9DC6, 0x655E, 0x9DC7, 0x655D, 0x9DC8, 0x6572,\r\n\t0x9DC9, 0x6578, 0x9DCA, 0x6582, 0x9DCB, 0x6583, 0x9DCC, 0x8B8A,\t0x9DCD, 0x659B, 0x9DCE, 0x659F, 0x9DCF, 0x65AB, 0x9DD0, 0x65B7,\r\n\t0x9DD1, 0x65C3, 0x9DD2, 0x65C6, 0x9DD3, 0x65C1, 0x9DD4, 0x65C4,\t0x9DD5, 0x65CC, 0x9DD6, 0x65D2, 0x9DD7, 0x65DB, 0x9DD8, 0x65D9,\r\n\t0x9DD9, 0x65E0, 0x9DDA, 0x65E1, 0x9DDB, 0x65F1, 0x9DDC, 0x6772,\t0x9DDD, 0x660A, 0x9DDE, 0x6603, 0x9DDF, 0x65FB, 0x9DE0, 0x6773,\r\n\t0x9DE1, 0x6635, 0x9DE2, 0x6636, 0x9DE3, 0x6634, 0x9DE4, 0x661C,\t0x9DE5, 0x664F, 0x9DE6, 0x6644, 0x9DE7, 0x6649, 0x9DE8, 0x6641,\r\n\t0x9DE9, 0x665E, 0x9DEA, 0x665D, 0x9DEB, 0x6664, 0x9DEC, 0x6667,\t0x9DED, 0x6668, 0x9DEE, 0x665F, 0x9DEF, 0x6662, 0x9DF0, 0x6670,\r\n\t0x9DF1, 0x6683, 0x9DF2, 0x6688, 0x9DF3, 0x668E, 0x9DF4, 0x6689,\t0x9DF5, 0x6684, 0x9DF6, 0x6698, 0x9DF7, 0x669D, 0x9DF8, 0x66C1,\r\n\t0x9DF9, 0x66B9, 0x9DFA, 0x66C9, 0x9DFB, 0x66BE, 0x9DFC, 0x66BC,\t0x9E40, 0x66C4, 0x9E41, 0x66B8, 0x9E42, 0x66D6, 0x9E43, 0x66DA,\r\n\t0x9E44, 0x66E0, 0x9E45, 0x663F, 0x9E46, 0x66E6, 0x9E47, 0x66E9,\t0x9E48, 0x66F0, 0x9E49, 0x66F5, 0x9E4A, 0x66F7, 0x9E4B, 0x670F,\r\n\t0x9E4C, 0x6716, 0x9E4D, 0x671E, 0x9E4E, 0x6726, 0x9E4F, 0x6727,\t0x9E50, 0x9738, 0x9E51, 0x672E, 0x9E52, 0x673F, 0x9E53, 0x6736,\r\n\t0x9E54, 0x6741, 0x9E55, 0x6738, 0x9E56, 0x6737, 0x9E57, 0x6746,\t0x9E58, 0x675E, 0x9E59, 0x6760, 0x9E5A, 0x6759, 0x9E5B, 0x6763,\r\n\t0x9E5C, 0x6764, 0x9E5D, 0x6789, 0x9E5E, 0x6770, 0x9E5F, 0x67A9,\t0x9E60, 0x677C, 0x9E61, 0x676A, 0x9E62, 0x678C, 0x9E63, 0x678B,\r\n\t0x9E64, 0x67A6, 0x9E65, 0x67A1, 0x9E66, 0x6785, 0x9E67, 0x67B7,\t0x9E68, 0x67EF, 0x9E69, 0x67B4, 0x9E6A, 0x67EC, 0x9E6B, 0x67B3,\r\n\t0x9E6C, 0x67E9, 0x9E6D, 0x67B8, 0x9E6E, 0x67E4, 0x9E6F, 0x67DE,\t0x9E70, 0x67DD, 0x9E71, 0x67E2, 0x9E72, 0x67EE, 0x9E73, 0x67B9,\r\n\t0x9E74, 0x67CE, 0x9E75, 0x67C6, 0x9E76, 0x67E7, 0x9E77, 0x6A9C,\t0x9E78, 0x681E, 0x9E79, 0x6846, 0x9E7A, 0x6829, 0x9E7B, 0x6840,\r\n\t0x9E7C, 0x684D, 0x9E7D, 0x6832, 0x9E7E, 0x684E, 0x9E80, 0x68B3,\t0x9E81, 0x682B, 0x9E82, 0x6859, 0x9E83, 0x6863, 0x9E84, 0x6877,\r\n\t0x9E85, 0x687F, 0x9E86, 0x689F, 0x9E87, 0x688F, 0x9E88, 0x68AD,\t0x9E89, 0x6894, 0x9E8A, 0x689D, 0x9E8B, 0x689B, 0x9E8C, 0x6883,\r\n\t0x9E8D, 0x6AAE, 0x9E8E, 0x68B9, 0x9E8F, 0x6874, 0x9E90, 0x68B5,\t0x9E91, 0x68A0, 0x9E92, 0x68BA, 0x9E93, 0x690F, 0x9E94, 0x688D,\r\n\t0x9E95, 0x687E, 0x9E96, 0x6901, 0x9E97, 0x68CA, 0x9E98, 0x6908,\t0x9E99, 0x68D8, 0x9E9A, 0x6922, 0x9E9B, 0x6926, 0x9E9C, 0x68E1,\r\n\t0x9E9D, 0x690C, 0x9E9E, 0x68CD, 0x9E9F, 0x68D4, 0x9EA0, 0x68E7,\t0x9EA1, 0x68D5, 0x9EA2, 0x6936, 0x9EA3, 0x6912, 0x9EA4, 0x6904,\r\n\t0x9EA5, 0x68D7, 0x9EA6, 0x68E3, 0x9EA7, 0x6925, 0x9EA8, 0x68F9,\t0x9EA9, 0x68E0, 0x9EAA, 0x68EF, 0x9EAB, 0x6928, 0x9EAC, 0x692A,\r\n\t0x9EAD, 0x691A, 0x9EAE, 0x6923, 0x9EAF, 0x6921, 0x9EB0, 0x68C6,\t0x9EB1, 0x6979, 0x9EB2, 0x6977, 0x9EB3, 0x695C, 0x9EB4, 0x6978,\r\n\t0x9EB5, 0x696B, 0x9EB6, 0x6954, 0x9EB7, 0x697E, 0x9EB8, 0x696E,\t0x9EB9, 0x6939, 0x9EBA, 0x6974, 0x9EBB, 0x693D, 0x9EBC, 0x6959,\r\n\t0x9EBD, 0x6930, 0x9EBE, 0x6961, 0x9EBF, 0x695E, 0x9EC0, 0x695D,\t0x9EC1, 0x6981, 0x9EC2, 0x696A, 0x9EC3, 0x69B2, 0x9EC4, 0x69AE,\r\n\t0x9EC5, 0x69D0, 0x9EC6, 0x69BF, 0x9EC7, 0x69C1, 0x9EC8, 0x69D3,\t0x9EC9, 0x69BE, 0x9ECA, 0x69CE, 0x9ECB, 0x5BE8, 0x9ECC, 0x69CA,\r\n\t0x9ECD, 0x69DD, 0x9ECE, 0x69BB, 0x9ECF, 0x69C3, 0x9ED0, 0x69A7,\t0x9ED1, 0x6A2E, 0x9ED2, 0x6991, 0x9ED3, 0x69A0, 0x9ED4, 0x699C,\r\n\t0x9ED5, 0x6995, 0x9ED6, 0x69B4, 0x9ED7, 0x69DE, 0x9ED8, 0x69E8,\t0x9ED9, 0x6A02, 0x9EDA, 0x6A1B, 0x9EDB, 0x69FF, 0x9EDC, 0x6B0A,\r\n\t0x9EDD, 0x69F9, 0x9EDE, 0x69F2, 0x9EDF, 0x69E7, 0x9EE0, 0x6A05,\t0x9EE1, 0x69B1, 0x9EE2, 0x6A1E, 0x9EE3, 0x69ED, 0x9EE4, 0x6A14,\r\n\t0x9EE5, 0x69EB, 0x9EE6, 0x6A0A, 0x9EE7, 0x6A12, 0x9EE8, 0x6AC1,\t0x9EE9, 0x6A23, 0x9EEA, 0x6A13, 0x9EEB, 0x6A44, 0x9EEC, 0x6A0C,\r\n\t0x9EED, 0x6A72, 0x9EEE, 0x6A36, 0x9EEF, 0x6A78, 0x9EF0, 0x6A47,\t0x9EF1, 0x6A62, 0x9EF2, 0x6A59, 0x9EF3, 0x6A66, 0x9EF4, 0x6A48,\r\n\t0x9EF5, 0x6A38, 0x9EF6, 0x6A22, 0x9EF7, 0x6A90, 0x9EF8, 0x6A8D,\t0x9EF9, 0x6AA0, 0x9EFA, 0x6A84, 0x9EFB, 0x6AA2, 0x9EFC, 0x6AA3,\r\n\t0x9F40, 0x6A97, 0x9F41, 0x8617, 0x9F42, 0x6ABB, 0x9F43, 0x6AC3,\t0x9F44, 0x6AC2, 0x9F45, 0x6AB8, 0x9F46, 0x6AB3, 0x9F47, 0x6AAC,\r\n\t0x9F48, 0x6ADE, 0x9F49, 0x6AD1, 0x9F4A, 0x6ADF, 0x9F4B, 0x6AAA,\t0x9F4C, 0x6ADA, 0x9F4D, 0x6AEA, 0x9F4E, 0x6AFB, 0x9F4F, 0x6B05,\r\n\t0x9F50, 0x8616, 0x9F51, 0x6AFA, 0x9F52, 0x6B12, 0x9F53, 0x6B16,\t0x9F54, 0x9B31, 0x9F55, 0x6B1F, 0x9F56, 0x6B38, 0x9F57, 0x6B37,\r\n\t0x9F58, 0x76DC, 0x9F59, 0x6B39, 0x9F5A, 0x98EE, 0x9F5B, 0x6B47,\t0x9F5C, 0x6B43, 0x9F5D, 0x6B49, 0x9F5E, 0x6B50, 0x9F5F, 0x6B59,\r\n\t0x9F60, 0x6B54, 0x9F61, 0x6B5B, 0x9F62, 0x6B5F, 0x9F63, 0x6B61,\t0x9F64, 0x6B78, 0x9F65, 0x6B79, 0x9F66, 0x6B7F, 0x9F67, 0x6B80,\r\n\t0x9F68, 0x6B84, 0x9F69, 0x6B83, 0x9F6A, 0x6B8D, 0x9F6B, 0x6B98,\t0x9F6C, 0x6B95, 0x9F6D, 0x6B9E, 0x9F6E, 0x6BA4, 0x9F6F, 0x6BAA,\r\n\t0x9F70, 0x6BAB, 0x9F71, 0x6BAF, 0x9F72, 0x6BB2, 0x9F73, 0x6BB1,\t0x9F74, 0x6BB3, 0x9F75, 0x6BB7, 0x9F76, 0x6BBC, 0x9F77, 0x6BC6,\r\n\t0x9F78, 0x6BCB, 0x9F79, 0x6BD3, 0x9F7A, 0x6BDF, 0x9F7B, 0x6BEC,\t0x9F7C, 0x6BEB, 0x9F7D, 0x6BF3, 0x9F7E, 0x6BEF, 0x9F80, 0x9EBE,\r\n\t0x9F81, 0x6C08, 0x9F82, 0x6C13, 0x9F83, 0x6C14, 0x9F84, 0x6C1B,\t0x9F85, 0x6C24, 0x9F86, 0x6C23, 0x9F87, 0x6C5E, 0x9F88, 0x6C55,\r\n\t0x9F89, 0x6C62, 0x9F8A, 0x6C6A, 0x9F8B, 0x6C82, 0x9F8C, 0x6C8D,\t0x9F8D, 0x6C9A, 0x9F8E, 0x6C81, 0x9F8F, 0x6C9B, 0x9F90, 0x6C7E,\r\n\t0x9F91, 0x6C68, 0x9F92, 0x6C73, 0x9F93, 0x6C92, 0x9F94, 0x6C90,\t0x9F95, 0x6CC4, 0x9F96, 0x6CF1, 0x9F97, 0x6CD3, 0x9F98, 0x6CBD,\r\n\t0x9F99, 0x6CD7, 0x9F9A, 0x6CC5, 0x9F9B, 0x6CDD, 0x9F9C, 0x6CAE,\t0x9F9D, 0x6CB1, 0x9F9E, 0x6CBE, 0x9F9F, 0x6CBA, 0x9FA0, 0x6CDB,\r\n\t0x9FA1, 0x6CEF, 0x9FA2, 0x6CD9, 0x9FA3, 0x6CEA, 0x9FA4, 0x6D1F,\t0x9FA5, 0x884D, 0x9FA6, 0x6D36, 0x9FA7, 0x6D2B, 0x9FA8, 0x6D3D,\r\n\t0x9FA9, 0x6D38, 0x9FAA, 0x6D19, 0x9FAB, 0x6D35, 0x9FAC, 0x6D33,\t0x9FAD, 0x6D12, 0x9FAE, 0x6D0C, 0x9FAF, 0x6D63, 0x9FB0, 0x6D93,\r\n\t0x9FB1, 0x6D64, 0x9FB2, 0x6D5A, 0x9FB3, 0x6D79, 0x9FB4, 0x6D59,\t0x9FB5, 0x6D8E, 0x9FB6, 0x6D95, 0x9FB7, 0x6FE4, 0x9FB8, 0x6D85,\r\n\t0x9FB9, 0x6DF9, 0x9FBA, 0x6E15, 0x9FBB, 0x6E0A, 0x9FBC, 0x6DB5,\t0x9FBD, 0x6DC7, 0x9FBE, 0x6DE6, 0x9FBF, 0x6DB8, 0x9FC0, 0x6DC6,\r\n\t0x9FC1, 0x6DEC, 0x9FC2, 0x6DDE, 0x9FC3, 0x6DCC, 0x9FC4, 0x6DE8,\t0x9FC5, 0x6DD2, 0x9FC6, 0x6DC5, 0x9FC7, 0x6DFA, 0x9FC8, 0x6DD9,\r\n\t0x9FC9, 0x6DE4, 0x9FCA, 0x6DD5, 0x9FCB, 0x6DEA, 0x9FCC, 0x6DEE,\t0x9FCD, 0x6E2D, 0x9FCE, 0x6E6E, 0x9FCF, 0x6E2E, 0x9FD0, 0x6E19,\r\n\t0x9FD1, 0x6E72, 0x9FD2, 0x6E5F, 0x9FD3, 0x6E3E, 0x9FD4, 0x6E23,\t0x9FD5, 0x6E6B, 0x9FD6, 0x6E2B, 0x9FD7, 0x6E76, 0x9FD8, 0x6E4D,\r\n\t0x9FD9, 0x6E1F, 0x9FDA, 0x6E43, 0x9FDB, 0x6E3A, 0x9FDC, 0x6E4E,\t0x9FDD, 0x6E24, 0x9FDE, 0x6EFF, 0x9FDF, 0x6E1D, 0x9FE0, 0x6E38,\r\n\t0x9FE1, 0x6E82, 0x9FE2, 0x6EAA, 0x9FE3, 0x6E98, 0x9FE4, 0x6EC9,\t0x9FE5, 0x6EB7, 0x9FE6, 0x6ED3, 0x9FE7, 0x6EBD, 0x9FE8, 0x6EAF,\r\n\t0x9FE9, 0x6EC4, 0x9FEA, 0x6EB2, 0x9FEB, 0x6ED4, 0x9FEC, 0x6ED5,\t0x9FED, 0x6E8F, 0x9FEE, 0x6EA5, 0x9FEF, 0x6EC2, 0x9FF0, 0x6E9F,\r\n\t0x9FF1, 0x6F41, 0x9FF2, 0x6F11, 0x9FF3, 0x704C, 0x9FF4, 0x6EEC,\t0x9FF5, 0x6EF8, 0x9FF6, 0x6EFE, 0x9FF7, 0x6F3F, 0x9FF8, 0x6EF2,\r\n\t0x9FF9, 0x6F31, 0x9FFA, 0x6EEF, 0x9FFB, 0x6F32, 0x9FFC, 0x6ECC,\t0xE040, 0x6F3E, 0xE041, 0x6F13, 0xE042, 0x6EF7, 0xE043, 0x6F86,\r\n\t0xE044, 0x6F7A, 0xE045, 0x6F78, 0xE046, 0x6F81, 0xE047, 0x6F80,\t0xE048, 0x6F6F, 0xE049, 0x6F5B, 0xE04A, 0x6FF3, 0xE04B, 0x6F6D,\r\n\t0xE04C, 0x6F82, 0xE04D, 0x6F7C, 0xE04E, 0x6F58, 0xE04F, 0x6F8E,\t0xE050, 0x6F91, 0xE051, 0x6FC2, 0xE052, 0x6F66, 0xE053, 0x6FB3,\r\n\t0xE054, 0x6FA3, 0xE055, 0x6FA1, 0xE056, 0x6FA4, 0xE057, 0x6FB9,\t0xE058, 0x6FC6, 0xE059, 0x6FAA, 0xE05A, 0x6FDF, 0xE05B, 0x6FD5,\r\n\t0xE05C, 0x6FEC, 0xE05D, 0x6FD4, 0xE05E, 0x6FD8, 0xE05F, 0x6FF1,\t0xE060, 0x6FEE, 0xE061, 0x6FDB, 0xE062, 0x7009, 0xE063, 0x700B,\r\n\t0xE064, 0x6FFA, 0xE065, 0x7011, 0xE066, 0x7001, 0xE067, 0x700F,\t0xE068, 0x6FFE, 0xE069, 0x701B, 0xE06A, 0x701A, 0xE06B, 0x6F74,\r\n\t0xE06C, 0x701D, 0xE06D, 0x7018, 0xE06E, 0x701F, 0xE06F, 0x7030,\t0xE070, 0x703E, 0xE071, 0x7032, 0xE072, 0x7051, 0xE073, 0x7063,\r\n\t0xE074, 0x7099, 0xE075, 0x7092, 0xE076, 0x70AF, 0xE077, 0x70F1,\t0xE078, 0x70AC, 0xE079, 0x70B8, 0xE07A, 0x70B3, 0xE07B, 0x70AE,\r\n\t0xE07C, 0x70DF, 0xE07D, 0x70CB, 0xE07E, 0x70DD, 0xE080, 0x70D9,\t0xE081, 0x7109, 0xE082, 0x70FD, 0xE083, 0x711C, 0xE084, 0x7119,\r\n\t0xE085, 0x7165, 0xE086, 0x7155, 0xE087, 0x7188, 0xE088, 0x7166,\t0xE089, 0x7162, 0xE08A, 0x714C, 0xE08B, 0x7156, 0xE08C, 0x716C,\r\n\t0xE08D, 0x718F, 0xE08E, 0x71FB, 0xE08F, 0x7184, 0xE090, 0x7195,\t0xE091, 0x71A8, 0xE092, 0x71AC, 0xE093, 0x71D7, 0xE094, 0x71B9,\r\n\t0xE095, 0x71BE, 0xE096, 0x71D2, 0xE097, 0x71C9, 0xE098, 0x71D4,\t0xE099, 0x71CE, 0xE09A, 0x71E0, 0xE09B, 0x71EC, 0xE09C, 0x71E7,\r\n\t0xE09D, 0x71F5, 0xE09E, 0x71FC, 0xE09F, 0x71F9, 0xE0A0, 0x71FF,\t0xE0A1, 0x720D, 0xE0A2, 0x7210, 0xE0A3, 0x721B, 0xE0A4, 0x7228,\r\n\t0xE0A5, 0x722D, 0xE0A6, 0x722C, 0xE0A7, 0x7230, 0xE0A8, 0x7232,\t0xE0A9, 0x723B, 0xE0AA, 0x723C, 0xE0AB, 0x723F, 0xE0AC, 0x7240,\r\n\t0xE0AD, 0x7246, 0xE0AE, 0x724B, 0xE0AF, 0x7258, 0xE0B0, 0x7274,\t0xE0B1, 0x727E, 0xE0B2, 0x7282, 0xE0B3, 0x7281, 0xE0B4, 0x7287,\r\n\t0xE0B5, 0x7292, 0xE0B6, 0x7296, 0xE0B7, 0x72A2, 0xE0B8, 0x72A7,\t0xE0B9, 0x72B9, 0xE0BA, 0x72B2, 0xE0BB, 0x72C3, 0xE0BC, 0x72C6,\r\n\t0xE0BD, 0x72C4, 0xE0BE, 0x72CE, 0xE0BF, 0x72D2, 0xE0C0, 0x72E2,\t0xE0C1, 0x72E0, 0xE0C2, 0x72E1, 0xE0C3, 0x72F9, 0xE0C4, 0x72F7,\r\n\t0xE0C5, 0x500F, 0xE0C6, 0x7317, 0xE0C7, 0x730A, 0xE0C8, 0x731C,\t0xE0C9, 0x7316, 0xE0CA, 0x731D, 0xE0CB, 0x7334, 0xE0CC, 0x732F,\r\n\t0xE0CD, 0x7329, 0xE0CE, 0x7325, 0xE0CF, 0x733E, 0xE0D0, 0x734E,\t0xE0D1, 0x734F, 0xE0D2, 0x9ED8, 0xE0D3, 0x7357, 0xE0D4, 0x736A,\r\n\t0xE0D5, 0x7368, 0xE0D6, 0x7370, 0xE0D7, 0x7378, 0xE0D8, 0x7375,\t0xE0D9, 0x737B, 0xE0DA, 0x737A, 0xE0DB, 0x73C8, 0xE0DC, 0x73B3,\r\n\t0xE0DD, 0x73CE, 0xE0DE, 0x73BB, 0xE0DF, 0x73C0, 0xE0E0, 0x73E5,\t0xE0E1, 0x73EE, 0xE0E2, 0x73DE, 0xE0E3, 0x74A2, 0xE0E4, 0x7405,\r\n\t0xE0E5, 0x746F, 0xE0E6, 0x7425, 0xE0E7, 0x73F8, 0xE0E8, 0x7432,\t0xE0E9, 0x743A, 0xE0EA, 0x7455, 0xE0EB, 0x743F, 0xE0EC, 0x745F,\r\n\t0xE0ED, 0x7459, 0xE0EE, 0x7441, 0xE0EF, 0x745C, 0xE0F0, 0x7469,\t0xE0F1, 0x7470, 0xE0F2, 0x7463, 0xE0F3, 0x746A, 0xE0F4, 0x7476,\r\n\t0xE0F5, 0x747E, 0xE0F6, 0x748B, 0xE0F7, 0x749E, 0xE0F8, 0x74A7,\t0xE0F9, 0x74CA, 0xE0FA, 0x74CF, 0xE0FB, 0x74D4, 0xE0FC, 0x73F1,\r\n\t0xE140, 0x74E0, 0xE141, 0x74E3, 0xE142, 0x74E7, 0xE143, 0x74E9,\t0xE144, 0x74EE, 0xE145, 0x74F2, 0xE146, 0x74F0, 0xE147, 0x74F1,\r\n\t0xE148, 0x74F8, 0xE149, 0x74F7, 0xE14A, 0x7504, 0xE14B, 0x7503,\t0xE14C, 0x7505, 0xE14D, 0x750C, 0xE14E, 0x750E, 0xE14F, 0x750D,\r\n\t0xE150, 0x7515, 0xE151, 0x7513, 0xE152, 0x751E, 0xE153, 0x7526,\t0xE154, 0x752C, 0xE155, 0x753C, 0xE156, 0x7544, 0xE157, 0x754D,\r\n\t0xE158, 0x754A, 0xE159, 0x7549, 0xE15A, 0x755B, 0xE15B, 0x7546,\t0xE15C, 0x755A, 0xE15D, 0x7569, 0xE15E, 0x7564, 0xE15F, 0x7567,\r\n\t0xE160, 0x756B, 0xE161, 0x756D, 0xE162, 0x7578, 0xE163, 0x7576,\t0xE164, 0x7586, 0xE165, 0x7587, 0xE166, 0x7574, 0xE167, 0x758A,\r\n\t0xE168, 0x7589, 0xE169, 0x7582, 0xE16A, 0x7594, 0xE16B, 0x759A,\t0xE16C, 0x759D, 0xE16D, 0x75A5, 0xE16E, 0x75A3, 0xE16F, 0x75C2,\r\n\t0xE170, 0x75B3, 0xE171, 0x75C3, 0xE172, 0x75B5, 0xE173, 0x75BD,\t0xE174, 0x75B8, 0xE175, 0x75BC, 0xE176, 0x75B1, 0xE177, 0x75CD,\r\n\t0xE178, 0x75CA, 0xE179, 0x75D2, 0xE17A, 0x75D9, 0xE17B, 0x75E3,\t0xE17C, 0x75DE, 0xE17D, 0x75FE, 0xE17E, 0x75FF, 0xE180, 0x75FC,\r\n\t0xE181, 0x7601, 0xE182, 0x75F0, 0xE183, 0x75FA, 0xE184, 0x75F2,\t0xE185, 0x75F3, 0xE186, 0x760B, 0xE187, 0x760D, 0xE188, 0x7609,\r\n\t0xE189, 0x761F, 0xE18A, 0x7627, 0xE18B, 0x7620, 0xE18C, 0x7621,\t0xE18D, 0x7622, 0xE18E, 0x7624, 0xE18F, 0x7634, 0xE190, 0x7630,\r\n\t0xE191, 0x763B, 0xE192, 0x7647, 0xE193, 0x7648, 0xE194, 0x7646,\t0xE195, 0x765C, 0xE196, 0x7658, 0xE197, 0x7661, 0xE198, 0x7662,\r\n\t0xE199, 0x7668, 0xE19A, 0x7669, 0xE19B, 0x766A, 0xE19C, 0x7667,\t0xE19D, 0x766C, 0xE19E, 0x7670, 0xE19F, 0x7672, 0xE1A0, 0x7676,\r\n\t0xE1A1, 0x7678, 0xE1A2, 0x767C, 0xE1A3, 0x7680, 0xE1A4, 0x7683,\t0xE1A5, 0x7688, 0xE1A6, 0x768B, 0xE1A7, 0x768E, 0xE1A8, 0x7696,\r\n\t0xE1A9, 0x7693, 0xE1AA, 0x7699, 0xE1AB, 0x769A, 0xE1AC, 0x76B0,\t0xE1AD, 0x76B4, 0xE1AE, 0x76B8, 0xE1AF, 0x76B9, 0xE1B0, 0x76BA,\r\n\t0xE1B1, 0x76C2, 0xE1B2, 0x76CD, 0xE1B3, 0x76D6, 0xE1B4, 0x76D2,\t0xE1B5, 0x76DE, 0xE1B6, 0x76E1, 0xE1B7, 0x76E5, 0xE1B8, 0x76E7,\r\n\t0xE1B9, 0x76EA, 0xE1BA, 0x862F, 0xE1BB, 0x76FB, 0xE1BC, 0x7708,\t0xE1BD, 0x7707, 0xE1BE, 0x7704, 0xE1BF, 0x7729, 0xE1C0, 0x7724,\r\n\t0xE1C1, 0x771E, 0xE1C2, 0x7725, 0xE1C3, 0x7726, 0xE1C4, 0x771B,\t0xE1C5, 0x7737, 0xE1C6, 0x7738, 0xE1C7, 0x7747, 0xE1C8, 0x775A,\r\n\t0xE1C9, 0x7768, 0xE1CA, 0x776B, 0xE1CB, 0x775B, 0xE1CC, 0x7765,\t0xE1CD, 0x777F, 0xE1CE, 0x777E, 0xE1CF, 0x7779, 0xE1D0, 0x778E,\r\n\t0xE1D1, 0x778B, 0xE1D2, 0x7791, 0xE1D3, 0x77A0, 0xE1D4, 0x779E,\t0xE1D5, 0x77B0, 0xE1D6, 0x77B6, 0xE1D7, 0x77B9, 0xE1D8, 0x77BF,\r\n\t0xE1D9, 0x77BC, 0xE1DA, 0x77BD, 0xE1DB, 0x77BB, 0xE1DC, 0x77C7,\t0xE1DD, 0x77CD, 0xE1DE, 0x77D7, 0xE1DF, 0x77DA, 0xE1E0, 0x77DC,\r\n\t0xE1E1, 0x77E3, 0xE1E2, 0x77EE, 0xE1E3, 0x77FC, 0xE1E4, 0x780C,\t0xE1E5, 0x7812, 0xE1E6, 0x7926, 0xE1E7, 0x7820, 0xE1E8, 0x792A,\r\n\t0xE1E9, 0x7845, 0xE1EA, 0x788E, 0xE1EB, 0x7874, 0xE1EC, 0x7886,\t0xE1ED, 0x787C, 0xE1EE, 0x789A, 0xE1EF, 0x788C, 0xE1F0, 0x78A3,\r\n\t0xE1F1, 0x78B5, 0xE1F2, 0x78AA, 0xE1F3, 0x78AF, 0xE1F4, 0x78D1,\t0xE1F5, 0x78C6, 0xE1F6, 0x78CB, 0xE1F7, 0x78D4, 0xE1F8, 0x78BE,\r\n\t0xE1F9, 0x78BC, 0xE1FA, 0x78C5, 0xE1FB, 0x78CA, 0xE1FC, 0x78EC,\t0xE240, 0x78E7, 0xE241, 0x78DA, 0xE242, 0x78FD, 0xE243, 0x78F4,\r\n\t0xE244, 0x7907, 0xE245, 0x7912, 0xE246, 0x7911, 0xE247, 0x7919,\t0xE248, 0x792C, 0xE249, 0x792B, 0xE24A, 0x7940, 0xE24B, 0x7960,\r\n\t0xE24C, 0x7957, 0xE24D, 0x795F, 0xE24E, 0x795A, 0xE24F, 0x7955,\t0xE250, 0x7953, 0xE251, 0x797A, 0xE252, 0x797F, 0xE253, 0x798A,\r\n\t0xE254, 0x799D, 0xE255, 0x79A7, 0xE256, 0x9F4B, 0xE257, 0x79AA,\t0xE258, 0x79AE, 0xE259, 0x79B3, 0xE25A, 0x79B9, 0xE25B, 0x79BA,\r\n\t0xE25C, 0x79C9, 0xE25D, 0x79D5, 0xE25E, 0x79E7, 0xE25F, 0x79EC,\t0xE260, 0x79E1, 0xE261, 0x79E3, 0xE262, 0x7A08, 0xE263, 0x7A0D,\r\n\t0xE264, 0x7A18, 0xE265, 0x7A19, 0xE266, 0x7A20, 0xE267, 0x7A1F,\t0xE268, 0x7980, 0xE269, 0x7A31, 0xE26A, 0x7A3B, 0xE26B, 0x7A3E,\r\n\t0xE26C, 0x7A37, 0xE26D, 0x7A43, 0xE26E, 0x7A57, 0xE26F, 0x7A49,\t0xE270, 0x7A61, 0xE271, 0x7A62, 0xE272, 0x7A69, 0xE273, 0x9F9D,\r\n\t0xE274, 0x7A70, 0xE275, 0x7A79, 0xE276, 0x7A7D, 0xE277, 0x7A88,\t0xE278, 0x7A97, 0xE279, 0x7A95, 0xE27A, 0x7A98, 0xE27B, 0x7A96,\r\n\t0xE27C, 0x7AA9, 0xE27D, 0x7AC8, 0xE27E, 0x7AB0, 0xE280, 0x7AB6,\t0xE281, 0x7AC5, 0xE282, 0x7AC4, 0xE283, 0x7ABF, 0xE284, 0x9083,\r\n\t0xE285, 0x7AC7, 0xE286, 0x7ACA, 0xE287, 0x7ACD, 0xE288, 0x7ACF,\t0xE289, 0x7AD5, 0xE28A, 0x7AD3, 0xE28B, 0x7AD9, 0xE28C, 0x7ADA,\r\n\t0xE28D, 0x7ADD, 0xE28E, 0x7AE1, 0xE28F, 0x7AE2, 0xE290, 0x7AE6,\t0xE291, 0x7AED, 0xE292, 0x7AF0, 0xE293, 0x7B02, 0xE294, 0x7B0F,\r\n\t0xE295, 0x7B0A, 0xE296, 0x7B06, 0xE297, 0x7B33, 0xE298, 0x7B18,\t0xE299, 0x7B19, 0xE29A, 0x7B1E, 0xE29B, 0x7B35, 0xE29C, 0x7B28,\r\n\t0xE29D, 0x7B36, 0xE29E, 0x7B50, 0xE29F, 0x7B7A, 0xE2A0, 0x7B04,\t0xE2A1, 0x7B4D, 0xE2A2, 0x7B0B, 0xE2A3, 0x7B4C, 0xE2A4, 0x7B45,\r\n\t0xE2A5, 0x7B75, 0xE2A6, 0x7B65, 0xE2A7, 0x7B74, 0xE2A8, 0x7B67,\t0xE2A9, 0x7B70, 0xE2AA, 0x7B71, 0xE2AB, 0x7B6C, 0xE2AC, 0x7B6E,\r\n\t0xE2AD, 0x7B9D, 0xE2AE, 0x7B98, 0xE2AF, 0x7B9F, 0xE2B0, 0x7B8D,\t0xE2B1, 0x7B9C, 0xE2B2, 0x7B9A, 0xE2B3, 0x7B8B, 0xE2B4, 0x7B92,\r\n\t0xE2B5, 0x7B8F, 0xE2B6, 0x7B5D, 0xE2B7, 0x7B99, 0xE2B8, 0x7BCB,\t0xE2B9, 0x7BC1, 0xE2BA, 0x7BCC, 0xE2BB, 0x7BCF, 0xE2BC, 0x7BB4,\r\n\t0xE2BD, 0x7BC6, 0xE2BE, 0x7BDD, 0xE2BF, 0x7BE9, 0xE2C0, 0x7C11,\t0xE2C1, 0x7C14, 0xE2C2, 0x7BE6, 0xE2C3, 0x7BE5, 0xE2C4, 0x7C60,\r\n\t0xE2C5, 0x7C00, 0xE2C6, 0x7C07, 0xE2C7, 0x7C13, 0xE2C8, 0x7BF3,\t0xE2C9, 0x7BF7, 0xE2CA, 0x7C17, 0xE2CB, 0x7C0D, 0xE2CC, 0x7BF6,\r\n\t0xE2CD, 0x7C23, 0xE2CE, 0x7C27, 0xE2CF, 0x7C2A, 0xE2D0, 0x7C1F,\t0xE2D1, 0x7C37, 0xE2D2, 0x7C2B, 0xE2D3, 0x7C3D, 0xE2D4, 0x7C4C,\r\n\t0xE2D5, 0x7C43, 0xE2D6, 0x7C54, 0xE2D7, 0x7C4F, 0xE2D8, 0x7C40,\t0xE2D9, 0x7C50, 0xE2DA, 0x7C58, 0xE2DB, 0x7C5F, 0xE2DC, 0x7C64,\r\n\t0xE2DD, 0x7C56, 0xE2DE, 0x7C65, 0xE2DF, 0x7C6C, 0xE2E0, 0x7C75,\t0xE2E1, 0x7C83, 0xE2E2, 0x7C90, 0xE2E3, 0x7CA4, 0xE2E4, 0x7CAD,\r\n\t0xE2E5, 0x7CA2, 0xE2E6, 0x7CAB, 0xE2E7, 0x7CA1, 0xE2E8, 0x7CA8,\t0xE2E9, 0x7CB3, 0xE2EA, 0x7CB2, 0xE2EB, 0x7CB1, 0xE2EC, 0x7CAE,\r\n\t0xE2ED, 0x7CB9, 0xE2EE, 0x7CBD, 0xE2EF, 0x7CC0, 0xE2F0, 0x7CC5,\t0xE2F1, 0x7CC2, 0xE2F2, 0x7CD8, 0xE2F3, 0x7CD2, 0xE2F4, 0x7CDC,\r\n\t0xE2F5, 0x7CE2, 0xE2F6, 0x9B3B, 0xE2F7, 0x7CEF, 0xE2F8, 0x7CF2,\t0xE2F9, 0x7CF4, 0xE2FA, 0x7CF6, 0xE2FB, 0x7CFA, 0xE2FC, 0x7D06,\r\n\t0xE340, 0x7D02, 0xE341, 0x7D1C, 0xE342, 0x7D15, 0xE343, 0x7D0A,\t0xE344, 0x7D45, 0xE345, 0x7D4B, 0xE346, 0x7D2E, 0xE347, 0x7D32,\r\n\t0xE348, 0x7D3F, 0xE349, 0x7D35, 0xE34A, 0x7D46, 0xE34B, 0x7D73,\t0xE34C, 0x7D56, 0xE34D, 0x7D4E, 0xE34E, 0x7D72, 0xE34F, 0x7D68,\r\n\t0xE350, 0x7D6E, 0xE351, 0x7D4F, 0xE352, 0x7D63, 0xE353, 0x7D93,\t0xE354, 0x7D89, 0xE355, 0x7D5B, 0xE356, 0x7D8F, 0xE357, 0x7D7D,\r\n\t0xE358, 0x7D9B, 0xE359, 0x7DBA, 0xE35A, 0x7DAE, 0xE35B, 0x7DA3,\t0xE35C, 0x7DB5, 0xE35D, 0x7DC7, 0xE35E, 0x7DBD, 0xE35F, 0x7DAB,\r\n\t0xE360, 0x7E3D, 0xE361, 0x7DA2, 0xE362, 0x7DAF, 0xE363, 0x7DDC,\t0xE364, 0x7DB8, 0xE365, 0x7D9F, 0xE366, 0x7DB0, 0xE367, 0x7DD8,\r\n\t0xE368, 0x7DDD, 0xE369, 0x7DE4, 0xE36A, 0x7DDE, 0xE36B, 0x7DFB,\t0xE36C, 0x7DF2, 0xE36D, 0x7DE1, 0xE36E, 0x7E05, 0xE36F, 0x7E0A,\r\n\t0xE370, 0x7E23, 0xE371, 0x7E21, 0xE372, 0x7E12, 0xE373, 0x7E31,\t0xE374, 0x7E1F, 0xE375, 0x7E09, 0xE376, 0x7E0B, 0xE377, 0x7E22,\r\n\t0xE378, 0x7E46, 0xE379, 0x7E66, 0xE37A, 0x7E3B, 0xE37B, 0x7E35,\t0xE37C, 0x7E39, 0xE37D, 0x7E43, 0xE37E, 0x7E37, 0xE380, 0x7E32,\r\n\t0xE381, 0x7E3A, 0xE382, 0x7E67, 0xE383, 0x7E5D, 0xE384, 0x7E56,\t0xE385, 0x7E5E, 0xE386, 0x7E59, 0xE387, 0x7E5A, 0xE388, 0x7E79,\r\n\t0xE389, 0x7E6A, 0xE38A, 0x7E69, 0xE38B, 0x7E7C, 0xE38C, 0x7E7B,\t0xE38D, 0x7E83, 0xE38E, 0x7DD5, 0xE38F, 0x7E7D, 0xE390, 0x8FAE,\r\n\t0xE391, 0x7E7F, 0xE392, 0x7E88, 0xE393, 0x7E89, 0xE394, 0x7E8C,\t0xE395, 0x7E92, 0xE396, 0x7E90, 0xE397, 0x7E93, 0xE398, 0x7E94,\r\n\t0xE399, 0x7E96, 0xE39A, 0x7E8E, 0xE39B, 0x7E9B, 0xE39C, 0x7E9C,\t0xE39D, 0x7F38, 0xE39E, 0x7F3A, 0xE39F, 0x7F45, 0xE3A0, 0x7F4C,\r\n\t0xE3A1, 0x7F4D, 0xE3A2, 0x7F4E, 0xE3A3, 0x7F50, 0xE3A4, 0x7F51,\t0xE3A5, 0x7F55, 0xE3A6, 0x7F54, 0xE3A7, 0x7F58, 0xE3A8, 0x7F5F,\r\n\t0xE3A9, 0x7F60, 0xE3AA, 0x7F68, 0xE3AB, 0x7F69, 0xE3AC, 0x7F67,\t0xE3AD, 0x7F78, 0xE3AE, 0x7F82, 0xE3AF, 0x7F86, 0xE3B0, 0x7F83,\r\n\t0xE3B1, 0x7F88, 0xE3B2, 0x7F87, 0xE3B3, 0x7F8C, 0xE3B4, 0x7F94,\t0xE3B5, 0x7F9E, 0xE3B6, 0x7F9D, 0xE3B7, 0x7F9A, 0xE3B8, 0x7FA3,\r\n\t0xE3B9, 0x7FAF, 0xE3BA, 0x7FB2, 0xE3BB, 0x7FB9, 0xE3BC, 0x7FAE,\t0xE3BD, 0x7FB6, 0xE3BE, 0x7FB8, 0xE3BF, 0x8B71, 0xE3C0, 0x7FC5,\r\n\t0xE3C1, 0x7FC6, 0xE3C2, 0x7FCA, 0xE3C3, 0x7FD5, 0xE3C4, 0x7FD4,\t0xE3C5, 0x7FE1, 0xE3C6, 0x7FE6, 0xE3C7, 0x7FE9, 0xE3C8, 0x7FF3,\r\n\t0xE3C9, 0x7FF9, 0xE3CA, 0x98DC, 0xE3CB, 0x8006, 0xE3CC, 0x8004,\t0xE3CD, 0x800B, 0xE3CE, 0x8012, 0xE3CF, 0x8018, 0xE3D0, 0x8019,\r\n\t0xE3D1, 0x801C, 0xE3D2, 0x8021, 0xE3D3, 0x8028, 0xE3D4, 0x803F,\t0xE3D5, 0x803B, 0xE3D6, 0x804A, 0xE3D7, 0x8046, 0xE3D8, 0x8052,\r\n\t0xE3D9, 0x8058, 0xE3DA, 0x805A, 0xE3DB, 0x805F, 0xE3DC, 0x8062,\t0xE3DD, 0x8068, 0xE3DE, 0x8073, 0xE3DF, 0x8072, 0xE3E0, 0x8070,\r\n\t0xE3E1, 0x8076, 0xE3E2, 0x8079, 0xE3E3, 0x807D, 0xE3E4, 0x807F,\t0xE3E5, 0x8084, 0xE3E6, 0x8086, 0xE3E7, 0x8085, 0xE3E8, 0x809B,\r\n\t0xE3E9, 0x8093, 0xE3EA, 0x809A, 0xE3EB, 0x80AD, 0xE3EC, 0x5190,\t0xE3ED, 0x80AC, 0xE3EE, 0x80DB, 0xE3EF, 0x80E5, 0xE3F0, 0x80D9,\r\n\t0xE3F1, 0x80DD, 0xE3F2, 0x80C4, 0xE3F3, 0x80DA, 0xE3F4, 0x80D6,\t0xE3F5, 0x8109, 0xE3F6, 0x80EF, 0xE3F7, 0x80F1, 0xE3F8, 0x811B,\r\n\t0xE3F9, 0x8129, 0xE3FA, 0x8123, 0xE3FB, 0x812F, 0xE3FC, 0x814B,\t0xE440, 0x968B, 0xE441, 0x8146, 0xE442, 0x813E, 0xE443, 0x8153,\r\n\t0xE444, 0x8151, 0xE445, 0x80FC, 0xE446, 0x8171, 0xE447, 0x816E,\t0xE448, 0x8165, 0xE449, 0x8166, 0xE44A, 0x8174, 0xE44B, 0x8183,\r\n\t0xE44C, 0x8188, 0xE44D, 0x818A, 0xE44E, 0x8180, 0xE44F, 0x8182,\t0xE450, 0x81A0, 0xE451, 0x8195, 0xE452, 0x81A4, 0xE453, 0x81A3,\r\n\t0xE454, 0x815F, 0xE455, 0x8193, 0xE456, 0x81A9, 0xE457, 0x81B0,\t0xE458, 0x81B5, 0xE459, 0x81BE, 0xE45A, 0x81B8, 0xE45B, 0x81BD,\r\n\t0xE45C, 0x81C0, 0xE45D, 0x81C2, 0xE45E, 0x81BA, 0xE45F, 0x81C9,\t0xE460, 0x81CD, 0xE461, 0x81D1, 0xE462, 0x81D9, 0xE463, 0x81D8,\r\n\t0xE464, 0x81C8, 0xE465, 0x81DA, 0xE466, 0x81DF, 0xE467, 0x81E0,\t0xE468, 0x81E7, 0xE469, 0x81FA, 0xE46A, 0x81FB, 0xE46B, 0x81FE,\r\n\t0xE46C, 0x8201, 0xE46D, 0x8202, 0xE46E, 0x8205, 0xE46F, 0x8207,\t0xE470, 0x820A, 0xE471, 0x820D, 0xE472, 0x8210, 0xE473, 0x8216,\r\n\t0xE474, 0x8229, 0xE475, 0x822B, 0xE476, 0x8238, 0xE477, 0x8233,\t0xE478, 0x8240, 0xE479, 0x8259, 0xE47A, 0x8258, 0xE47B, 0x825D,\r\n\t0xE47C, 0x825A, 0xE47D, 0x825F, 0xE47E, 0x8264, 0xE480, 0x8262,\t0xE481, 0x8268, 0xE482, 0x826A, 0xE483, 0x826B, 0xE484, 0x822E,\r\n\t0xE485, 0x8271, 0xE486, 0x8277, 0xE487, 0x8278, 0xE488, 0x827E,\t0xE489, 0x828D, 0xE48A, 0x8292, 0xE48B, 0x82AB, 0xE48C, 0x829F,\r\n\t0xE48D, 0x82BB, 0xE48E, 0x82AC, 0xE48F, 0x82E1, 0xE490, 0x82E3,\t0xE491, 0x82DF, 0xE492, 0x82D2, 0xE493, 0x82F4, 0xE494, 0x82F3,\r\n\t0xE495, 0x82FA, 0xE496, 0x8393, 0xE497, 0x8303, 0xE498, 0x82FB,\t0xE499, 0x82F9, 0xE49A, 0x82DE, 0xE49B, 0x8306, 0xE49C, 0x82DC,\r\n\t0xE49D, 0x8309, 0xE49E, 0x82D9, 0xE49F, 0x8335, 0xE4A0, 0x8334,\t0xE4A1, 0x8316, 0xE4A2, 0x8332, 0xE4A3, 0x8331, 0xE4A4, 0x8340,\r\n\t0xE4A5, 0x8339, 0xE4A6, 0x8350, 0xE4A7, 0x8345, 0xE4A8, 0x832F,\t0xE4A9, 0x832B, 0xE4AA, 0x8317, 0xE4AB, 0x8318, 0xE4AC, 0x8385,\r\n\t0xE4AD, 0x839A, 0xE4AE, 0x83AA, 0xE4AF, 0x839F, 0xE4B0, 0x83A2,\t0xE4B1, 0x8396, 0xE4B2, 0x8323, 0xE4B3, 0x838E, 0xE4B4, 0x8387,\r\n\t0xE4B5, 0x838A, 0xE4B6, 0x837C, 0xE4B7, 0x83B5, 0xE4B8, 0x8373,\t0xE4B9, 0x8375, 0xE4BA, 0x83A0, 0xE4BB, 0x8389, 0xE4BC, 0x83A8,\r\n\t0xE4BD, 0x83F4, 0xE4BE, 0x8413, 0xE4BF, 0x83EB, 0xE4C0, 0x83CE,\t0xE4C1, 0x83FD, 0xE4C2, 0x8403, 0xE4C3, 0x83D8, 0xE4C4, 0x840B,\r\n\t0xE4C5, 0x83C1, 0xE4C6, 0x83F7, 0xE4C7, 0x8407, 0xE4C8, 0x83E0,\t0xE4C9, 0x83F2, 0xE4CA, 0x840D, 0xE4CB, 0x8422, 0xE4CC, 0x8420,\r\n\t0xE4CD, 0x83BD, 0xE4CE, 0x8438, 0xE4CF, 0x8506, 0xE4D0, 0x83FB,\t0xE4D1, 0x846D, 0xE4D2, 0x842A, 0xE4D3, 0x843C, 0xE4D4, 0x855A,\r\n\t0xE4D5, 0x8484, 0xE4D6, 0x8477, 0xE4D7, 0x846B, 0xE4D8, 0x84AD,\t0xE4D9, 0x846E, 0xE4DA, 0x8482, 0xE4DB, 0x8469, 0xE4DC, 0x8446,\r\n\t0xE4DD, 0x842C, 0xE4DE, 0x846F, 0xE4DF, 0x8479, 0xE4E0, 0x8435,\t0xE4E1, 0x84CA, 0xE4E2, 0x8462, 0xE4E3, 0x84B9, 0xE4E4, 0x84BF,\r\n\t0xE4E5, 0x849F, 0xE4E6, 0x84D9, 0xE4E7, 0x84CD, 0xE4E8, 0x84BB,\t0xE4E9, 0x84DA, 0xE4EA, 0x84D0, 0xE4EB, 0x84C1, 0xE4EC, 0x84C6,\r\n\t0xE4ED, 0x84D6, 0xE4EE, 0x84A1, 0xE4EF, 0x8521, 0xE4F0, 0x84FF,\t0xE4F1, 0x84F4, 0xE4F2, 0x8517, 0xE4F3, 0x8518, 0xE4F4, 0x852C,\r\n\t0xE4F5, 0x851F, 0xE4F6, 0x8515, 0xE4F7, 0x8514, 0xE4F8, 0x84FC,\t0xE4F9, 0x8540, 0xE4FA, 0x8563, 0xE4FB, 0x8558, 0xE4FC, 0x8548,\r\n\t0xE540, 0x8541, 0xE541, 0x8602, 0xE542, 0x854B, 0xE543, 0x8555,\t0xE544, 0x8580, 0xE545, 0x85A4, 0xE546, 0x8588, 0xE547, 0x8591,\r\n\t0xE548, 0x858A, 0xE549, 0x85A8, 0xE54A, 0x856D, 0xE54B, 0x8594,\t0xE54C, 0x859B, 0xE54D, 0x85EA, 0xE54E, 0x8587, 0xE54F, 0x859C,\r\n\t0xE550, 0x8577, 0xE551, 0x857E, 0xE552, 0x8590, 0xE553, 0x85C9,\t0xE554, 0x85BA, 0xE555, 0x85CF, 0xE556, 0x85B9, 0xE557, 0x85D0,\r\n\t0xE558, 0x85D5, 0xE559, 0x85DD, 0xE55A, 0x85E5, 0xE55B, 0x85DC,\t0xE55C, 0x85F9, 0xE55D, 0x860A, 0xE55E, 0x8613, 0xE55F, 0x860B,\r\n\t0xE560, 0x85FE, 0xE561, 0x85FA, 0xE562, 0x8606, 0xE563, 0x8622,\t0xE564, 0x861A, 0xE565, 0x8630, 0xE566, 0x863F, 0xE567, 0x864D,\r\n\t0xE568, 0x4E55, 0xE569, 0x8654, 0xE56A, 0x865F, 0xE56B, 0x8667,\t0xE56C, 0x8671, 0xE56D, 0x8693, 0xE56E, 0x86A3, 0xE56F, 0x86A9,\r\n\t0xE570, 0x86AA, 0xE571, 0x868B, 0xE572, 0x868C, 0xE573, 0x86B6,\t0xE574, 0x86AF, 0xE575, 0x86C4, 0xE576, 0x86C6, 0xE577, 0x86B0,\r\n\t0xE578, 0x86C9, 0xE579, 0x8823, 0xE57A, 0x86AB, 0xE57B, 0x86D4,\t0xE57C, 0x86DE, 0xE57D, 0x86E9, 0xE57E, 0x86EC, 0xE580, 0x86DF,\r\n\t0xE581, 0x86DB, 0xE582, 0x86EF, 0xE583, 0x8712, 0xE584, 0x8706,\t0xE585, 0x8708, 0xE586, 0x8700, 0xE587, 0x8703, 0xE588, 0x86FB,\r\n\t0xE589, 0x8711, 0xE58A, 0x8709, 0xE58B, 0x870D, 0xE58C, 0x86F9,\t0xE58D, 0x870A, 0xE58E, 0x8734, 0xE58F, 0x873F, 0xE590, 0x8737,\r\n\t0xE591, 0x873B, 0xE592, 0x8725, 0xE593, 0x8729, 0xE594, 0x871A,\t0xE595, 0x8760, 0xE596, 0x875F, 0xE597, 0x8778, 0xE598, 0x874C,\r\n\t0xE599, 0x874E, 0xE59A, 0x8774, 0xE59B, 0x8757, 0xE59C, 0x8768,\t0xE59D, 0x876E, 0xE59E, 0x8759, 0xE59F, 0x8753, 0xE5A0, 0x8763,\r\n\t0xE5A1, 0x876A, 0xE5A2, 0x8805, 0xE5A3, 0x87A2, 0xE5A4, 0x879F,\t0xE5A5, 0x8782, 0xE5A6, 0x87AF, 0xE5A7, 0x87CB, 0xE5A8, 0x87BD,\r\n\t0xE5A9, 0x87C0, 0xE5AA, 0x87D0, 0xE5AB, 0x96D6, 0xE5AC, 0x87AB,\t0xE5AD, 0x87C4, 0xE5AE, 0x87B3, 0xE5AF, 0x87C7, 0xE5B0, 0x87C6,\r\n\t0xE5B1, 0x87BB, 0xE5B2, 0x87EF, 0xE5B3, 0x87F2, 0xE5B4, 0x87E0,\t0xE5B5, 0x880F, 0xE5B6, 0x880D, 0xE5B7, 0x87FE, 0xE5B8, 0x87F6,\r\n\t0xE5B9, 0x87F7, 0xE5BA, 0x880E, 0xE5BB, 0x87D2, 0xE5BC, 0x8811,\t0xE5BD, 0x8816, 0xE5BE, 0x8815, 0xE5BF, 0x8822, 0xE5C0, 0x8821,\r\n\t0xE5C1, 0x8831, 0xE5C2, 0x8836, 0xE5C3, 0x8839, 0xE5C4, 0x8827,\t0xE5C5, 0x883B, 0xE5C6, 0x8844, 0xE5C7, 0x8842, 0xE5C8, 0x8852,\r\n\t0xE5C9, 0x8859, 0xE5CA, 0x885E, 0xE5CB, 0x8862, 0xE5CC, 0x886B,\t0xE5CD, 0x8881, 0xE5CE, 0x887E, 0xE5CF, 0x889E, 0xE5D0, 0x8875,\r\n\t0xE5D1, 0x887D, 0xE5D2, 0x88B5, 0xE5D3, 0x8872, 0xE5D4, 0x8882,\t0xE5D5, 0x8897, 0xE5D6, 0x8892, 0xE5D7, 0x88AE, 0xE5D8, 0x8899,\r\n\t0xE5D9, 0x88A2, 0xE5DA, 0x888D, 0xE5DB, 0x88A4, 0xE5DC, 0x88B0,\t0xE5DD, 0x88BF, 0xE5DE, 0x88B1, 0xE5DF, 0x88C3, 0xE5E0, 0x88C4,\r\n\t0xE5E1, 0x88D4, 0xE5E2, 0x88D8, 0xE5E3, 0x88D9, 0xE5E4, 0x88DD,\t0xE5E5, 0x88F9, 0xE5E6, 0x8902, 0xE5E7, 0x88FC, 0xE5E8, 0x88F4,\r\n\t0xE5E9, 0x88E8, 0xE5EA, 0x88F2, 0xE5EB, 0x8904, 0xE5EC, 0x890C,\t0xE5ED, 0x890A, 0xE5EE, 0x8913, 0xE5EF, 0x8943, 0xE5F0, 0x891E,\r\n\t0xE5F1, 0x8925, 0xE5F2, 0x892A, 0xE5F3, 0x892B, 0xE5F4, 0x8941,\t0xE5F5, 0x8944, 0xE5F6, 0x893B, 0xE5F7, 0x8936, 0xE5F8, 0x8938,\r\n\t0xE5F9, 0x894C, 0xE5FA, 0x891D, 0xE5FB, 0x8960, 0xE5FC, 0x895E,\t0xE640, 0x8966, 0xE641, 0x8964, 0xE642, 0x896D, 0xE643, 0x896A,\r\n\t0xE644, 0x896F, 0xE645, 0x8974, 0xE646, 0x8977, 0xE647, 0x897E,\t0xE648, 0x8983, 0xE649, 0x8988, 0xE64A, 0x898A, 0xE64B, 0x8993,\r\n\t0xE64C, 0x8998, 0xE64D, 0x89A1, 0xE64E, 0x89A9, 0xE64F, 0x89A6,\t0xE650, 0x89AC, 0xE651, 0x89AF, 0xE652, 0x89B2, 0xE653, 0x89BA,\r\n\t0xE654, 0x89BD, 0xE655, 0x89BF, 0xE656, 0x89C0, 0xE657, 0x89DA,\t0xE658, 0x89DC, 0xE659, 0x89DD, 0xE65A, 0x89E7, 0xE65B, 0x89F4,\r\n\t0xE65C, 0x89F8, 0xE65D, 0x8A03, 0xE65E, 0x8A16, 0xE65F, 0x8A10,\t0xE660, 0x8A0C, 0xE661, 0x8A1B, 0xE662, 0x8A1D, 0xE663, 0x8A25,\r\n\t0xE664, 0x8A36, 0xE665, 0x8A41, 0xE666, 0x8A5B, 0xE667, 0x8A52,\t0xE668, 0x8A46, 0xE669, 0x8A48, 0xE66A, 0x8A7C, 0xE66B, 0x8A6D,\r\n\t0xE66C, 0x8A6C, 0xE66D, 0x8A62, 0xE66E, 0x8A85, 0xE66F, 0x8A82,\t0xE670, 0x8A84, 0xE671, 0x8AA8, 0xE672, 0x8AA1, 0xE673, 0x8A91,\r\n\t0xE674, 0x8AA5, 0xE675, 0x8AA6, 0xE676, 0x8A9A, 0xE677, 0x8AA3,\t0xE678, 0x8AC4, 0xE679, 0x8ACD, 0xE67A, 0x8AC2, 0xE67B, 0x8ADA,\r\n\t0xE67C, 0x8AEB, 0xE67D, 0x8AF3, 0xE67E, 0x8AE7, 0xE680, 0x8AE4,\t0xE681, 0x8AF1, 0xE682, 0x8B14, 0xE683, 0x8AE0, 0xE684, 0x8AE2,\r\n\t0xE685, 0x8AF7, 0xE686, 0x8ADE, 0xE687, 0x8ADB, 0xE688, 0x8B0C,\t0xE689, 0x8B07, 0xE68A, 0x8B1A, 0xE68B, 0x8AE1, 0xE68C, 0x8B16,\r\n\t0xE68D, 0x8B10, 0xE68E, 0x8B17, 0xE68F, 0x8B20, 0xE690, 0x8B33,\t0xE691, 0x97AB, 0xE692, 0x8B26, 0xE693, 0x8B2B, 0xE694, 0x8B3E,\r\n\t0xE695, 0x8B28, 0xE696, 0x8B41, 0xE697, 0x8B4C, 0xE698, 0x8B4F,\t0xE699, 0x8B4E, 0xE69A, 0x8B49, 0xE69B, 0x8B56, 0xE69C, 0x8B5B,\r\n\t0xE69D, 0x8B5A, 0xE69E, 0x8B6B, 0xE69F, 0x8B5F, 0xE6A0, 0x8B6C,\t0xE6A1, 0x8B6F, 0xE6A2, 0x8B74, 0xE6A3, 0x8B7D, 0xE6A4, 0x8B80,\r\n\t0xE6A5, 0x8B8C, 0xE6A6, 0x8B8E, 0xE6A7, 0x8B92, 0xE6A8, 0x8B93,\t0xE6A9, 0x8B96, 0xE6AA, 0x8B99, 0xE6AB, 0x8B9A, 0xE6AC, 0x8C3A,\r\n\t0xE6AD, 0x8C41, 0xE6AE, 0x8C3F, 0xE6AF, 0x8C48, 0xE6B0, 0x8C4C,\t0xE6B1, 0x8C4E, 0xE6B2, 0x8C50, 0xE6B3, 0x8C55, 0xE6B4, 0x8C62,\r\n\t0xE6B5, 0x8C6C, 0xE6B6, 0x8C78, 0xE6B7, 0x8C7A, 0xE6B8, 0x8C82,\t0xE6B9, 0x8C89, 0xE6BA, 0x8C85, 0xE6BB, 0x8C8A, 0xE6BC, 0x8C8D,\r\n\t0xE6BD, 0x8C8E, 0xE6BE, 0x8C94, 0xE6BF, 0x8C7C, 0xE6C0, 0x8C98,\t0xE6C1, 0x621D, 0xE6C2, 0x8CAD, 0xE6C3, 0x8CAA, 0xE6C4, 0x8CBD,\r\n\t0xE6C5, 0x8CB2, 0xE6C6, 0x8CB3, 0xE6C7, 0x8CAE, 0xE6C8, 0x8CB6,\t0xE6C9, 0x8CC8, 0xE6CA, 0x8CC1, 0xE6CB, 0x8CE4, 0xE6CC, 0x8CE3,\r\n\t0xE6CD, 0x8CDA, 0xE6CE, 0x8CFD, 0xE6CF, 0x8CFA, 0xE6D0, 0x8CFB,\t0xE6D1, 0x8D04, 0xE6D2, 0x8D05, 0xE6D3, 0x8D0A, 0xE6D4, 0x8D07,\r\n\t0xE6D5, 0x8D0F, 0xE6D6, 0x8D0D, 0xE6D7, 0x8D10, 0xE6D8, 0x9F4E,\t0xE6D9, 0x8D13, 0xE6DA, 0x8CCD, 0xE6DB, 0x8D14, 0xE6DC, 0x8D16,\r\n\t0xE6DD, 0x8D67, 0xE6DE, 0x8D6D, 0xE6DF, 0x8D71, 0xE6E0, 0x8D73,\t0xE6E1, 0x8D81, 0xE6E2, 0x8D99, 0xE6E3, 0x8DC2, 0xE6E4, 0x8DBE,\r\n\t0xE6E5, 0x8DBA, 0xE6E6, 0x8DCF, 0xE6E7, 0x8DDA, 0xE6E8, 0x8DD6,\t0xE6E9, 0x8DCC, 0xE6EA, 0x8DDB, 0xE6EB, 0x8DCB, 0xE6EC, 0x8DEA,\r\n\t0xE6ED, 0x8DEB, 0xE6EE, 0x8DDF, 0xE6EF, 0x8DE3, 0xE6F0, 0x8DFC,\t0xE6F1, 0x8E08, 0xE6F2, 0x8E09, 0xE6F3, 0x8DFF, 0xE6F4, 0x8E1D,\r\n\t0xE6F5, 0x8E1E, 0xE6F6, 0x8E10, 0xE6F7, 0x8E1F, 0xE6F8, 0x8E42,\t0xE6F9, 0x8E35, 0xE6FA, 0x8E30, 0xE6FB, 0x8E34, 0xE6FC, 0x8E4A,\r\n\t0xE740, 0x8E47, 0xE741, 0x8E49, 0xE742, 0x8E4C, 0xE743, 0x8E50,\t0xE744, 0x8E48, 0xE745, 0x8E59, 0xE746, 0x8E64, 0xE747, 0x8E60,\r\n\t0xE748, 0x8E2A, 0xE749, 0x8E63, 0xE74A, 0x8E55, 0xE74B, 0x8E76,\t0xE74C, 0x8E72, 0xE74D, 0x8E7C, 0xE74E, 0x8E81, 0xE74F, 0x8E87,\r\n\t0xE750, 0x8E85, 0xE751, 0x8E84, 0xE752, 0x8E8B, 0xE753, 0x8E8A,\t0xE754, 0x8E93, 0xE755, 0x8E91, 0xE756, 0x8E94, 0xE757, 0x8E99,\r\n\t0xE758, 0x8EAA, 0xE759, 0x8EA1, 0xE75A, 0x8EAC, 0xE75B, 0x8EB0,\t0xE75C, 0x8EC6, 0xE75D, 0x8EB1, 0xE75E, 0x8EBE, 0xE75F, 0x8EC5,\r\n\t0xE760, 0x8EC8, 0xE761, 0x8ECB, 0xE762, 0x8EDB, 0xE763, 0x8EE3,\t0xE764, 0x8EFC, 0xE765, 0x8EFB, 0xE766, 0x8EEB, 0xE767, 0x8EFE,\r\n\t0xE768, 0x8F0A, 0xE769, 0x8F05, 0xE76A, 0x8F15, 0xE76B, 0x8F12,\t0xE76C, 0x8F19, 0xE76D, 0x8F13, 0xE76E, 0x8F1C, 0xE76F, 0x8F1F,\r\n\t0xE770, 0x8F1B, 0xE771, 0x8F0C, 0xE772, 0x8F26, 0xE773, 0x8F33,\t0xE774, 0x8F3B, 0xE775, 0x8F39, 0xE776, 0x8F45, 0xE777, 0x8F42,\r\n\t0xE778, 0x8F3E, 0xE779, 0x8F4C, 0xE77A, 0x8F49, 0xE77B, 0x8F46,\t0xE77C, 0x8F4E, 0xE77D, 0x8F57, 0xE77E, 0x8F5C, 0xE780, 0x8F62,\r\n\t0xE781, 0x8F63, 0xE782, 0x8F64, 0xE783, 0x8F9C, 0xE784, 0x8F9F,\t0xE785, 0x8FA3, 0xE786, 0x8FAD, 0xE787, 0x8FAF, 0xE788, 0x8FB7,\r\n\t0xE789, 0x8FDA, 0xE78A, 0x8FE5, 0xE78B, 0x8FE2, 0xE78C, 0x8FEA,\t0xE78D, 0x8FEF, 0xE78E, 0x9087, 0xE78F, 0x8FF4, 0xE790, 0x9005,\r\n\t0xE791, 0x8FF9, 0xE792, 0x8FFA, 0xE793, 0x9011, 0xE794, 0x9015,\t0xE795, 0x9021, 0xE796, 0x900D, 0xE797, 0x901E, 0xE798, 0x9016,\r\n\t0xE799, 0x900B, 0xE79A, 0x9027, 0xE79B, 0x9036, 0xE79C, 0x9035,\t0xE79D, 0x9039, 0xE79E, 0x8FF8, 0xE79F, 0x904F, 0xE7A0, 0x9050,\r\n\t0xE7A1, 0x9051, 0xE7A2, 0x9052, 0xE7A3, 0x900E, 0xE7A4, 0x9049,\t0xE7A5, 0x903E, 0xE7A6, 0x9056, 0xE7A7, 0x9058, 0xE7A8, 0x905E,\r\n\t0xE7A9, 0x9068, 0xE7AA, 0x906F, 0xE7AB, 0x9076, 0xE7AC, 0x96A8,\t0xE7AD, 0x9072, 0xE7AE, 0x9082, 0xE7AF, 0x907D, 0xE7B0, 0x9081,\r\n\t0xE7B1, 0x9080, 0xE7B2, 0x908A, 0xE7B3, 0x9089, 0xE7B4, 0x908F,\t0xE7B5, 0x90A8, 0xE7B6, 0x90AF, 0xE7B7, 0x90B1, 0xE7B8, 0x90B5,\r\n\t0xE7B9, 0x90E2, 0xE7BA, 0x90E4, 0xE7BB, 0x6248, 0xE7BC, 0x90DB,\t0xE7BD, 0x9102, 0xE7BE, 0x9112, 0xE7BF, 0x9119, 0xE7C0, 0x9132,\r\n\t0xE7C1, 0x9130, 0xE7C2, 0x914A, 0xE7C3, 0x9156, 0xE7C4, 0x9158,\t0xE7C5, 0x9163, 0xE7C6, 0x9165, 0xE7C7, 0x9169, 0xE7C8, 0x9173,\r\n\t0xE7C9, 0x9172, 0xE7CA, 0x918B, 0xE7CB, 0x9189, 0xE7CC, 0x9182,\t0xE7CD, 0x91A2, 0xE7CE, 0x91AB, 0xE7CF, 0x91AF, 0xE7D0, 0x91AA,\r\n\t0xE7D1, 0x91B5, 0xE7D2, 0x91B4, 0xE7D3, 0x91BA, 0xE7D4, 0x91C0,\t0xE7D5, 0x91C1, 0xE7D6, 0x91C9, 0xE7D7, 0x91CB, 0xE7D8, 0x91D0,\r\n\t0xE7D9, 0x91D6, 0xE7DA, 0x91DF, 0xE7DB, 0x91E1, 0xE7DC, 0x91DB,\t0xE7DD, 0x91FC, 0xE7DE, 0x91F5, 0xE7DF, 0x91F6, 0xE7E0, 0x921E,\r\n\t0xE7E1, 0x91FF, 0xE7E2, 0x9214, 0xE7E3, 0x922C, 0xE7E4, 0x9215,\t0xE7E5, 0x9211, 0xE7E6, 0x925E, 0xE7E7, 0x9257, 0xE7E8, 0x9245,\r\n\t0xE7E9, 0x9249, 0xE7EA, 0x9264, 0xE7EB, 0x9248, 0xE7EC, 0x9295,\t0xE7ED, 0x923F, 0xE7EE, 0x924B, 0xE7EF, 0x9250, 0xE7F0, 0x929C,\r\n\t0xE7F1, 0x9296, 0xE7F2, 0x9293, 0xE7F3, 0x929B, 0xE7F4, 0x925A,\t0xE7F5, 0x92CF, 0xE7F6, 0x92B9, 0xE7F7, 0x92B7, 0xE7F8, 0x92E9,\r\n\t0xE7F9, 0x930F, 0xE7FA, 0x92FA, 0xE7FB, 0x9344, 0xE7FC, 0x932E,\t0xE840, 0x9319, 0xE841, 0x9322, 0xE842, 0x931A, 0xE843, 0x9323,\r\n\t0xE844, 0x933A, 0xE845, 0x9335, 0xE846, 0x933B, 0xE847, 0x935C,\t0xE848, 0x9360, 0xE849, 0x937C, 0xE84A, 0x936E, 0xE84B, 0x9356,\r\n\t0xE84C, 0x93B0, 0xE84D, 0x93AC, 0xE84E, 0x93AD, 0xE84F, 0x9394,\t0xE850, 0x93B9, 0xE851, 0x93D6, 0xE852, 0x93D7, 0xE853, 0x93E8,\r\n\t0xE854, 0x93E5, 0xE855, 0x93D8, 0xE856, 0x93C3, 0xE857, 0x93DD,\t0xE858, 0x93D0, 0xE859, 0x93C8, 0xE85A, 0x93E4, 0xE85B, 0x941A,\r\n\t0xE85C, 0x9414, 0xE85D, 0x9413, 0xE85E, 0x9403, 0xE85F, 0x9407,\t0xE860, 0x9410, 0xE861, 0x9436, 0xE862, 0x942B, 0xE863, 0x9435,\r\n\t0xE864, 0x9421, 0xE865, 0x943A, 0xE866, 0x9441, 0xE867, 0x9452,\t0xE868, 0x9444, 0xE869, 0x945B, 0xE86A, 0x9460, 0xE86B, 0x9462,\r\n\t0xE86C, 0x945E, 0xE86D, 0x946A, 0xE86E, 0x9229, 0xE86F, 0x9470,\t0xE870, 0x9475, 0xE871, 0x9477, 0xE872, 0x947D, 0xE873, 0x945A,\r\n\t0xE874, 0x947C, 0xE875, 0x947E, 0xE876, 0x9481, 0xE877, 0x947F,\t0xE878, 0x9582, 0xE879, 0x9587, 0xE87A, 0x958A, 0xE87B, 0x9594,\r\n\t0xE87C, 0x9596, 0xE87D, 0x9598, 0xE87E, 0x9599, 0xE880, 0x95A0,\t0xE881, 0x95A8, 0xE882, 0x95A7, 0xE883, 0x95AD, 0xE884, 0x95BC,\r\n\t0xE885, 0x95BB, 0xE886, 0x95B9, 0xE887, 0x95BE, 0xE888, 0x95CA,\t0xE889, 0x6FF6, 0xE88A, 0x95C3, 0xE88B, 0x95CD, 0xE88C, 0x95CC,\r\n\t0xE88D, 0x95D5, 0xE88E, 0x95D4, 0xE88F, 0x95D6, 0xE890, 0x95DC,\t0xE891, 0x95E1, 0xE892, 0x95E5, 0xE893, 0x95E2, 0xE894, 0x9621,\r\n\t0xE895, 0x9628, 0xE896, 0x962E, 0xE897, 0x962F, 0xE898, 0x9642,\t0xE899, 0x964C, 0xE89A, 0x964F, 0xE89B, 0x964B, 0xE89C, 0x9677,\r\n\t0xE89D, 0x965C, 0xE89E, 0x965E, 0xE89F, 0x965D, 0xE8A0, 0x965F,\t0xE8A1, 0x9666, 0xE8A2, 0x9672, 0xE8A3, 0x966C, 0xE8A4, 0x968D,\r\n\t0xE8A5, 0x9698, 0xE8A6, 0x9695, 0xE8A7, 0x9697, 0xE8A8, 0x96AA,\t0xE8A9, 0x96A7, 0xE8AA, 0x96B1, 0xE8AB, 0x96B2, 0xE8AC, 0x96B0,\r\n\t0xE8AD, 0x96B4, 0xE8AE, 0x96B6, 0xE8AF, 0x96B8, 0xE8B0, 0x96B9,\t0xE8B1, 0x96CE, 0xE8B2, 0x96CB, 0xE8B3, 0x96C9, 0xE8B4, 0x96CD,\r\n\t0xE8B5, 0x894D, 0xE8B6, 0x96DC, 0xE8B7, 0x970D, 0xE8B8, 0x96D5,\t0xE8B9, 0x96F9, 0xE8BA, 0x9704, 0xE8BB, 0x9706, 0xE8BC, 0x9708,\r\n\t0xE8BD, 0x9713, 0xE8BE, 0x970E, 0xE8BF, 0x9711, 0xE8C0, 0x970F,\t0xE8C1, 0x9716, 0xE8C2, 0x9719, 0xE8C3, 0x9724, 0xE8C4, 0x972A,\r\n\t0xE8C5, 0x9730, 0xE8C6, 0x9739, 0xE8C7, 0x973D, 0xE8C8, 0x973E,\t0xE8C9, 0x9744, 0xE8CA, 0x9746, 0xE8CB, 0x9748, 0xE8CC, 0x9742,\r\n\t0xE8CD, 0x9749, 0xE8CE, 0x975C, 0xE8CF, 0x9760, 0xE8D0, 0x9764,\t0xE8D1, 0x9766, 0xE8D2, 0x9768, 0xE8D3, 0x52D2, 0xE8D4, 0x976B,\r\n\t0xE8D5, 0x9771, 0xE8D6, 0x9779, 0xE8D7, 0x9785, 0xE8D8, 0x977C,\t0xE8D9, 0x9781, 0xE8DA, 0x977A, 0xE8DB, 0x9786, 0xE8DC, 0x978B,\r\n\t0xE8DD, 0x978F, 0xE8DE, 0x9790, 0xE8DF, 0x979C, 0xE8E0, 0x97A8,\t0xE8E1, 0x97A6, 0xE8E2, 0x97A3, 0xE8E3, 0x97B3, 0xE8E4, 0x97B4,\r\n\t0xE8E5, 0x97C3, 0xE8E6, 0x97C6, 0xE8E7, 0x97C8, 0xE8E8, 0x97CB,\t0xE8E9, 0x97DC, 0xE8EA, 0x97ED, 0xE8EB, 0x9F4F, 0xE8EC, 0x97F2,\r\n\t0xE8ED, 0x7ADF, 0xE8EE, 0x97F6, 0xE8EF, 0x97F5, 0xE8F0, 0x980F,\t0xE8F1, 0x980C, 0xE8F2, 0x9838, 0xE8F3, 0x9824, 0xE8F4, 0x9821,\r\n\t0xE8F5, 0x9837, 0xE8F6, 0x983D, 0xE8F7, 0x9846, 0xE8F8, 0x984F,\t0xE8F9, 0x984B, 0xE8FA, 0x986B, 0xE8FB, 0x986F, 0xE8FC, 0x9870,\r\n\t0xE940, 0x9871, 0xE941, 0x9874, 0xE942, 0x9873, 0xE943, 0x98AA,\t0xE944, 0x98AF, 0xE945, 0x98B1, 0xE946, 0x98B6, 0xE947, 0x98C4,\r\n\t0xE948, 0x98C3, 0xE949, 0x98C6, 0xE94A, 0x98E9, 0xE94B, 0x98EB,\t0xE94C, 0x9903, 0xE94D, 0x9909, 0xE94E, 0x9912, 0xE94F, 0x9914,\r\n\t0xE950, 0x9918, 0xE951, 0x9921, 0xE952, 0x991D, 0xE953, 0x991E,\t0xE954, 0x9924, 0xE955, 0x9920, 0xE956, 0x992C, 0xE957, 0x992E,\r\n\t0xE958, 0x993D, 0xE959, 0x993E, 0xE95A, 0x9942, 0xE95B, 0x9949,\t0xE95C, 0x9945, 0xE95D, 0x9950, 0xE95E, 0x994B, 0xE95F, 0x9951,\r\n\t0xE960, 0x9952, 0xE961, 0x994C, 0xE962, 0x9955, 0xE963, 0x9997,\t0xE964, 0x9998, 0xE965, 0x99A5, 0xE966, 0x99AD, 0xE967, 0x99AE,\r\n\t0xE968, 0x99BC, 0xE969, 0x99DF, 0xE96A, 0x99DB, 0xE96B, 0x99DD,\t0xE96C, 0x99D8, 0xE96D, 0x99D1, 0xE96E, 0x99ED, 0xE96F, 0x99EE,\r\n\t0xE970, 0x99F1, 0xE971, 0x99F2, 0xE972, 0x99FB, 0xE973, 0x99F8,\t0xE974, 0x9A01, 0xE975, 0x9A0F, 0xE976, 0x9A05, 0xE977, 0x99E2,\r\n\t0xE978, 0x9A19, 0xE979, 0x9A2B, 0xE97A, 0x9A37, 0xE97B, 0x9A45,\t0xE97C, 0x9A42, 0xE97D, 0x9A40, 0xE97E, 0x9A43, 0xE980, 0x9A3E,\r\n\t0xE981, 0x9A55, 0xE982, 0x9A4D, 0xE983, 0x9A5B, 0xE984, 0x9A57,\t0xE985, 0x9A5F, 0xE986, 0x9A62, 0xE987, 0x9A65, 0xE988, 0x9A64,\r\n\t0xE989, 0x9A69, 0xE98A, 0x9A6B, 0xE98B, 0x9A6A, 0xE98C, 0x9AAD,\t0xE98D, 0x9AB0, 0xE98E, 0x9ABC, 0xE98F, 0x9AC0, 0xE990, 0x9ACF,\r\n\t0xE991, 0x9AD1, 0xE992, 0x9AD3, 0xE993, 0x9AD4, 0xE994, 0x9ADE,\t0xE995, 0x9ADF, 0xE996, 0x9AE2, 0xE997, 0x9AE3, 0xE998, 0x9AE6,\r\n\t0xE999, 0x9AEF, 0xE99A, 0x9AEB, 0xE99B, 0x9AEE, 0xE99C, 0x9AF4,\t0xE99D, 0x9AF1, 0xE99E, 0x9AF7, 0xE99F, 0x9AFB, 0xE9A0, 0x9B06,\r\n\t0xE9A1, 0x9B18, 0xE9A2, 0x9B1A, 0xE9A3, 0x9B1F, 0xE9A4, 0x9B22,\t0xE9A5, 0x9B23, 0xE9A6, 0x9B25, 0xE9A7, 0x9B27, 0xE9A8, 0x9B28,\r\n\t0xE9A9, 0x9B29, 0xE9AA, 0x9B2A, 0xE9AB, 0x9B2E, 0xE9AC, 0x9B2F,\t0xE9AD, 0x9B32, 0xE9AE, 0x9B44, 0xE9AF, 0x9B43, 0xE9B0, 0x9B4F,\r\n\t0xE9B1, 0x9B4D, 0xE9B2, 0x9B4E, 0xE9B3, 0x9B51, 0xE9B4, 0x9B58,\t0xE9B5, 0x9B74, 0xE9B6, 0x9B93, 0xE9B7, 0x9B83, 0xE9B8, 0x9B91,\r\n\t0xE9B9, 0x9B96, 0xE9BA, 0x9B97, 0xE9BB, 0x9B9F, 0xE9BC, 0x9BA0,\t0xE9BD, 0x9BA8, 0xE9BE, 0x9BB4, 0xE9BF, 0x9BC0, 0xE9C0, 0x9BCA,\r\n\t0xE9C1, 0x9BB9, 0xE9C2, 0x9BC6, 0xE9C3, 0x9BCF, 0xE9C4, 0x9BD1,\t0xE9C5, 0x9BD2, 0xE9C6, 0x9BE3, 0xE9C7, 0x9BE2, 0xE9C8, 0x9BE4,\r\n\t0xE9C9, 0x9BD4, 0xE9CA, 0x9BE1, 0xE9CB, 0x9C3A, 0xE9CC, 0x9BF2,\t0xE9CD, 0x9BF1, 0xE9CE, 0x9BF0, 0xE9CF, 0x9C15, 0xE9D0, 0x9C14,\r\n\t0xE9D1, 0x9C09, 0xE9D2, 0x9C13, 0xE9D3, 0x9C0C, 0xE9D4, 0x9C06,\t0xE9D5, 0x9C08, 0xE9D6, 0x9C12, 0xE9D7, 0x9C0A, 0xE9D8, 0x9C04,\r\n\t0xE9D9, 0x9C2E, 0xE9DA, 0x9C1B, 0xE9DB, 0x9C25, 0xE9DC, 0x9C24,\t0xE9DD, 0x9C21, 0xE9DE, 0x9C30, 0xE9DF, 0x9C47, 0xE9E0, 0x9C32,\r\n\t0xE9E1, 0x9C46, 0xE9E2, 0x9C3E, 0xE9E3, 0x9C5A, 0xE9E4, 0x9C60,\t0xE9E5, 0x9C67, 0xE9E6, 0x9C76, 0xE9E7, 0x9C78, 0xE9E8, 0x9CE7,\r\n\t0xE9E9, 0x9CEC, 0xE9EA, 0x9CF0, 0xE9EB, 0x9D09, 0xE9EC, 0x9D08,\t0xE9ED, 0x9CEB, 0xE9EE, 0x9D03, 0xE9EF, 0x9D06, 0xE9F0, 0x9D2A,\r\n\t0xE9F1, 0x9D26, 0xE9F2, 0x9DAF, 0xE9F3, 0x9D23, 0xE9F4, 0x9D1F,\t0xE9F5, 0x9D44, 0xE9F6, 0x9D15, 0xE9F7, 0x9D12, 0xE9F8, 0x9D41,\r\n\t0xE9F9, 0x9D3F, 0xE9FA, 0x9D3E, 0xE9FB, 0x9D46, 0xE9FC, 0x9D48,\t0xEA40, 0x9D5D, 0xEA41, 0x9D5E, 0xEA42, 0x9D64, 0xEA43, 0x9D51,\r\n\t0xEA44, 0x9D50, 0xEA45, 0x9D59, 0xEA46, 0x9D72, 0xEA47, 0x9D89,\t0xEA48, 0x9D87, 0xEA49, 0x9DAB, 0xEA4A, 0x9D6F, 0xEA4B, 0x9D7A,\r\n\t0xEA4C, 0x9D9A, 0xEA4D, 0x9DA4, 0xEA4E, 0x9DA9, 0xEA4F, 0x9DB2,\t0xEA50, 0x9DC4, 0xEA51, 0x9DC1, 0xEA52, 0x9DBB, 0xEA53, 0x9DB8,\r\n\t0xEA54, 0x9DBA, 0xEA55, 0x9DC6, 0xEA56, 0x9DCF, 0xEA57, 0x9DC2,\t0xEA58, 0x9DD9, 0xEA59, 0x9DD3, 0xEA5A, 0x9DF8, 0xEA5B, 0x9DE6,\r\n\t0xEA5C, 0x9DED, 0xEA5D, 0x9DEF, 0xEA5E, 0x9DFD, 0xEA5F, 0x9E1A,\t0xEA60, 0x9E1B, 0xEA61, 0x9E1E, 0xEA62, 0x9E75, 0xEA63, 0x9E79,\r\n\t0xEA64, 0x9E7D, 0xEA65, 0x9E81, 0xEA66, 0x9E88, 0xEA67, 0x9E8B,\t0xEA68, 0x9E8C, 0xEA69, 0x9E92, 0xEA6A, 0x9E95, 0xEA6B, 0x9E91,\r\n\t0xEA6C, 0x9E9D, 0xEA6D, 0x9EA5, 0xEA6E, 0x9EA9, 0xEA6F, 0x9EB8,\t0xEA70, 0x9EAA, 0xEA71, 0x9EAD, 0xEA72, 0x9761, 0xEA73, 0x9ECC,\r\n\t0xEA74, 0x9ECE, 0xEA75, 0x9ECF, 0xEA76, 0x9ED0, 0xEA77, 0x9ED4,\t0xEA78, 0x9EDC, 0xEA79, 0x9EDE, 0xEA7A, 0x9EDD, 0xEA7B, 0x9EE0,\r\n\t0xEA7C, 0x9EE5, 0xEA7D, 0x9EE8, 0xEA7E, 0x9EEF, 0xEA80, 0x9EF4,\t0xEA81, 0x9EF6, 0xEA82, 0x9EF7, 0xEA83, 0x9EF9, 0xEA84, 0x9EFB,\r\n\t0xEA85, 0x9EFC, 0xEA86, 0x9EFD, 0xEA87, 0x9F07, 0xEA88, 0x9F08,\t0xEA89, 0x76B7, 0xEA8A, 0x9F15, 0xEA8B, 0x9F21, 0xEA8C, 0x9F2C,\r\n\t0xEA8D, 0x9F3E, 0xEA8E, 0x9F4A, 0xEA8F, 0x9F52, 0xEA90, 0x9F54,\t0xEA91, 0x9F63, 0xEA92, 0x9F5F, 0xEA93, 0x9F60, 0xEA94, 0x9F61,\r\n\t0xEA95, 0x9F66, 0xEA96, 0x9F67, 0xEA97, 0x9F6C, 0xEA98, 0x9F6A,\t0xEA99, 0x9F77, 0xEA9A, 0x9F72, 0xEA9B, 0x9F76, 0xEA9C, 0x9F95,\r\n\t0xEA9D, 0x9F9C, 0xEA9E, 0x9FA0, 0xEA9F, 0x582F, 0xEAA0, 0x69C7,\t0xEAA1, 0x9059, 0xEAA2, 0x7464, 0xEAA3, 0x51DC, 0xEAA4, 0x7199,\r\n\t0xFA40, 0x2170, 0xFA41, 0x2171, 0xFA42, 0x2172, 0xFA43, 0x2173,\t0xFA44, 0x2174, 0xFA45, 0x2175, 0xFA46, 0x2176, 0xFA47, 0x2177,\r\n\t0xFA48, 0x2178, 0xFA49, 0x2179, 0xFA55, 0xFFE4, 0xFA56, 0xFF07,\t0xFA57, 0xFF02, 0xFA5C, 0x7E8A, 0xFA5D, 0x891C, 0xFA5E, 0x9348,\r\n\t0xFA5F, 0x9288, 0xFA60, 0x84DC, 0xFA61, 0x4FC9, 0xFA62, 0x70BB,\t0xFA63, 0x6631, 0xFA64, 0x68C8, 0xFA65, 0x92F9, 0xFA66, 0x66FB,\r\n\t0xFA67, 0x5F45, 0xFA68, 0x4E28, 0xFA69, 0x4EE1, 0xFA6A, 0x4EFC,\t0xFA6B, 0x4F00, 0xFA6C, 0x4F03, 0xFA6D, 0x4F39, 0xFA6E, 0x4F56,\r\n\t0xFA6F, 0x4F92, 0xFA70, 0x4F8A, 0xFA71, 0x4F9A, 0xFA72, 0x4F94,\t0xFA73, 0x4FCD, 0xFA74, 0x5040, 0xFA75, 0x5022, 0xFA76, 0x4FFF,\r\n\t0xFA77, 0x501E, 0xFA78, 0x5046, 0xFA79, 0x5070, 0xFA7A, 0x5042,\t0xFA7B, 0x5094, 0xFA7C, 0x50F4, 0xFA7D, 0x50D8, 0xFA7E, 0x514A,\r\n\t0xFA80, 0x5164, 0xFA81, 0x519D, 0xFA82, 0x51BE, 0xFA83, 0x51EC,\t0xFA84, 0x5215, 0xFA85, 0x529C, 0xFA86, 0x52A6, 0xFA87, 0x52C0,\r\n\t0xFA88, 0x52DB, 0xFA89, 0x5300, 0xFA8A, 0x5307, 0xFA8B, 0x5324,\t0xFA8C, 0x5372, 0xFA8D, 0x5393, 0xFA8E, 0x53B2, 0xFA8F, 0x53DD,\r\n\t0xFA90, 0xFA0E, 0xFA91, 0x549C, 0xFA92, 0x548A, 0xFA93, 0x54A9,\t0xFA94, 0x54FF, 0xFA95, 0x5586, 0xFA96, 0x5759, 0xFA97, 0x5765,\r\n\t0xFA98, 0x57AC, 0xFA99, 0x57C8, 0xFA9A, 0x57C7, 0xFA9B, 0xFA0F,\t0xFA9C, 0xFA10, 0xFA9D, 0x589E, 0xFA9E, 0x58B2, 0xFA9F, 0x590B,\r\n\t0xFAA0, 0x5953, 0xFAA1, 0x595B, 0xFAA2, 0x595D, 0xFAA3, 0x5963,\t0xFAA4, 0x59A4, 0xFAA5, 0x59BA, 0xFAA6, 0x5B56, 0xFAA7, 0x5BC0,\r\n\t0xFAA8, 0x752F, 0xFAA9, 0x5BD8, 0xFAAA, 0x5BEC, 0xFAAB, 0x5C1E,\t0xFAAC, 0x5CA6, 0xFAAD, 0x5CBA, 0xFAAE, 0x5CF5, 0xFAAF, 0x5D27,\r\n\t0xFAB0, 0x5D53, 0xFAB1, 0xFA11, 0xFAB2, 0x5D42, 0xFAB3, 0x5D6D,\t0xFAB4, 0x5DB8, 0xFAB5, 0x5DB9, 0xFAB6, 0x5DD0, 0xFAB7, 0x5F21,\r\n\t0xFAB8, 0x5F34, 0xFAB9, 0x5F67, 0xFABA, 0x5FB7, 0xFABB, 0x5FDE,\t0xFABC, 0x605D, 0xFABD, 0x6085, 0xFABE, 0x608A, 0xFABF, 0x60DE,\r\n\t0xFAC0, 0x60D5, 0xFAC1, 0x6120, 0xFAC2, 0x60F2, 0xFAC3, 0x6111,\t0xFAC4, 0x6137, 0xFAC5, 0x6130, 0xFAC6, 0x6198, 0xFAC7, 0x6213,\r\n\t0xFAC8, 0x62A6, 0xFAC9, 0x63F5, 0xFACA, 0x6460, 0xFACB, 0x649D,\t0xFACC, 0x64CE, 0xFACD, 0x654E, 0xFACE, 0x6600, 0xFACF, 0x6615,\r\n\t0xFAD0, 0x663B, 0xFAD1, 0x6609, 0xFAD2, 0x662E, 0xFAD3, 0x661E,\t0xFAD4, 0x6624, 0xFAD5, 0x6665, 0xFAD6, 0x6657, 0xFAD7, 0x6659,\r\n\t0xFAD8, 0xFA12, 0xFAD9, 0x6673, 0xFADA, 0x6699, 0xFADB, 0x66A0,\t0xFADC, 0x66B2, 0xFADD, 0x66BF, 0xFADE, 0x66FA, 0xFADF, 0x670E,\r\n\t0xFAE0, 0xF929, 0xFAE1, 0x6766, 0xFAE2, 0x67BB, 0xFAE3, 0x6852,\t0xFAE4, 0x67C0, 0xFAE5, 0x6801, 0xFAE6, 0x6844, 0xFAE7, 0x68CF,\r\n\t0xFAE8, 0xFA13, 0xFAE9, 0x6968, 0xFAEA, 0xFA14, 0xFAEB, 0x6998,\t0xFAEC, 0x69E2, 0xFAED, 0x6A30, 0xFAEE, 0x6A6B, 0xFAEF, 0x6A46,\r\n\t0xFAF0, 0x6A73, 0xFAF1, 0x6A7E, 0xFAF2, 0x6AE2, 0xFAF3, 0x6AE4,\t0xFAF4, 0x6BD6, 0xFAF5, 0x6C3F, 0xFAF6, 0x6C5C, 0xFAF7, 0x6C86,\r\n\t0xFAF8, 0x6C6F, 0xFAF9, 0x6CDA, 0xFAFA, 0x6D04, 0xFAFB, 0x6D87,\t0xFAFC, 0x6D6F, 0xFB40, 0x6D96, 0xFB41, 0x6DAC, 0xFB42, 0x6DCF,\r\n\t0xFB43, 0x6DF8, 0xFB44, 0x6DF2, 0xFB45, 0x6DFC, 0xFB46, 0x6E39,\t0xFB47, 0x6E5C, 0xFB48, 0x6E27, 0xFB49, 0x6E3C, 0xFB4A, 0x6EBF,\r\n\t0xFB4B, 0x6F88, 0xFB4C, 0x6FB5, 0xFB4D, 0x6FF5, 0xFB4E, 0x7005,\t0xFB4F, 0x7007, 0xFB50, 0x7028, 0xFB51, 0x7085, 0xFB52, 0x70AB,\r\n\t0xFB53, 0x710F, 0xFB54, 0x7104, 0xFB55, 0x715C, 0xFB56, 0x7146,\t0xFB57, 0x7147, 0xFB58, 0xFA15, 0xFB59, 0x71C1, 0xFB5A, 0x71FE,\r\n\t0xFB5B, 0x72B1, 0xFB5C, 0x72BE, 0xFB5D, 0x7324, 0xFB5E, 0xFA16,\t0xFB5F, 0x7377, 0xFB60, 0x73BD, 0xFB61, 0x73C9, 0xFB62, 0x73D6,\r\n\t0xFB63, 0x73E3, 0xFB64, 0x73D2, 0xFB65, 0x7407, 0xFB66, 0x73F5,\t0xFB67, 0x7426, 0xFB68, 0x742A, 0xFB69, 0x7429, 0xFB6A, 0x742E,\r\n\t0xFB6B, 0x7462, 0xFB6C, 0x7489, 0xFB6D, 0x749F, 0xFB6E, 0x7501,\t0xFB6F, 0x756F, 0xFB70, 0x7682, 0xFB71, 0x769C, 0xFB72, 0x769E,\r\n\t0xFB73, 0x769B, 0xFB74, 0x76A6, 0xFB75, 0xFA17, 0xFB76, 0x7746,\t0xFB77, 0x52AF, 0xFB78, 0x7821, 0xFB79, 0x784E, 0xFB7A, 0x7864,\r\n\t0xFB7B, 0x787A, 0xFB7C, 0x7930, 0xFB7D, 0xFA18, 0xFB7E, 0xFA19,\t0xFB80, 0xFA1A, 0xFB81, 0x7994, 0xFB82, 0xFA1B, 0xFB83, 0x799B,\r\n\t0xFB84, 0x7AD1, 0xFB85, 0x7AE7, 0xFB86, 0xFA1C, 0xFB87, 0x7AEB,\t0xFB88, 0x7B9E, 0xFB89, 0xFA1D, 0xFB8A, 0x7D48, 0xFB8B, 0x7D5C,\r\n\t0xFB8C, 0x7DB7, 0xFB8D, 0x7DA0, 0xFB8E, 0x7DD6, 0xFB8F, 0x7E52,\t0xFB90, 0x7F47, 0xFB91, 0x7FA1, 0xFB92, 0xFA1E, 0xFB93, 0x8301,\r\n\t0xFB94, 0x8362, 0xFB95, 0x837F, 0xFB96, 0x83C7, 0xFB97, 0x83F6,\t0xFB98, 0x8448, 0xFB99, 0x84B4, 0xFB9A, 0x8553, 0xFB9B, 0x8559,\r\n\t0xFB9C, 0x856B, 0xFB9D, 0xFA1F, 0xFB9E, 0x85B0, 0xFB9F, 0xFA20,\t0xFBA0, 0xFA21, 0xFBA1, 0x8807, 0xFBA2, 0x88F5, 0xFBA3, 0x8A12,\r\n\t0xFBA4, 0x8A37, 0xFBA5, 0x8A79, 0xFBA6, 0x8AA7, 0xFBA7, 0x8ABE,\t0xFBA8, 0x8ADF, 0xFBA9, 0xFA22, 0xFBAA, 0x8AF6, 0xFBAB, 0x8B53,\r\n\t0xFBAC, 0x8B7F, 0xFBAD, 0x8CF0, 0xFBAE, 0x8CF4, 0xFBAF, 0x8D12,\t0xFBB0, 0x8D76, 0xFBB1, 0xFA23, 0xFBB2, 0x8ECF, 0xFBB3, 0xFA24,\r\n\t0xFBB4, 0xFA25, 0xFBB5, 0x9067, 0xFBB6, 0x90DE, 0xFBB7, 0xFA26,\t0xFBB8, 0x9115, 0xFBB9, 0x9127, 0xFBBA, 0x91DA, 0xFBBB, 0x91D7,\r\n\t0xFBBC, 0x91DE, 0xFBBD, 0x91ED, 0xFBBE, 0x91EE, 0xFBBF, 0x91E4,\t0xFBC0, 0x91E5, 0xFBC1, 0x9206, 0xFBC2, 0x9210, 0xFBC3, 0x920A,\r\n\t0xFBC4, 0x923A, 0xFBC5, 0x9240, 0xFBC6, 0x923C, 0xFBC7, 0x924E,\t0xFBC8, 0x9259, 0xFBC9, 0x9251, 0xFBCA, 0x9239, 0xFBCB, 0x9267,\r\n\t0xFBCC, 0x92A7, 0xFBCD, 0x9277, 0xFBCE, 0x9278, 0xFBCF, 0x92E7,\t0xFBD0, 0x92D7, 0xFBD1, 0x92D9, 0xFBD2, 0x92D0, 0xFBD3, 0xFA27,\r\n\t0xFBD4, 0x92D5, 0xFBD5, 0x92E0, 0xFBD6, 0x92D3, 0xFBD7, 0x9325,\t0xFBD8, 0x9321, 0xFBD9, 0x92FB, 0xFBDA, 0xFA28, 0xFBDB, 0x931E,\r\n\t0xFBDC, 0x92FF, 0xFBDD, 0x931D, 0xFBDE, 0x9302, 0xFBDF, 0x9370,\t0xFBE0, 0x9357, 0xFBE1, 0x93A4, 0xFBE2, 0x93C6, 0xFBE3, 0x93DE,\r\n\t0xFBE4, 0x93F8, 0xFBE5, 0x9431, 0xFBE6, 0x9445, 0xFBE7, 0x9448,\t0xFBE8, 0x9592, 0xFBE9, 0xF9DC, 0xFBEA, 0xFA29, 0xFBEB, 0x969D,\r\n\t0xFBEC, 0x96AF, 0xFBED, 0x9733, 0xFBEE, 0x973B, 0xFBEF, 0x9743,\t0xFBF0, 0x974D, 0xFBF1, 0x974F, 0xFBF2, 0x9751, 0xFBF3, 0x9755,\r\n\t0xFBF4, 0x9857, 0xFBF5, 0x9865, 0xFBF6, 0xFA2A, 0xFBF7, 0xFA2B,\t0xFBF8, 0x9927, 0xFBF9, 0xFA2C, 0xFBFA, 0x999E, 0xFBFB, 0x9A4E,\r\n\t0xFBFC, 0x9AD9, 0xFC40, 0x9ADC, 0xFC41, 0x9B75, 0xFC42, 0x9B72,\t0xFC43, 0x9B8F, 0xFC44, 0x9BB1, 0xFC45, 0x9BBB, 0xFC46, 0x9C00,\r\n\t0xFC47, 0x9D70, 0xFC48, 0x9D6B, 0xFC49, 0xFA2D, 0xFC4A, 0x9E19,\t0xFC4B, 0x9ED1, 0, 0\r\n};\r\n#endif\r\n\r\n#if FF_CODE_PAGE == 936 || FF_CODE_PAGE == 0\t/* Simplified Chinese */\r\nstatic const WCHAR uni2oem936[] = {\t/* Unicode --> GBK pairs */\r\n\t0x00A4, 0xA1E8, 0x00A7, 0xA1EC, 0x00A8, 0xA1A7, 0x00B0, 0xA1E3,\t0x00B1, 0xA1C0, 0x00B7, 0xA1A4, 0x00D7, 0xA1C1, 0x00E0, 0xA8A4,\r\n\t0x00E1, 0xA8A2, 0x00E8, 0xA8A8, 0x00E9, 0xA8A6, 0x00EA, 0xA8BA,\t0x00EC, 0xA8AC, 0x00ED, 0xA8AA, 0x00F2, 0xA8B0, 0x00F3, 0xA8AE,\r\n\t0x00F7, 0xA1C2, 0x00F9, 0xA8B4, 0x00FA, 0xA8B2, 0x00FC, 0xA8B9,\t0x0101, 0xA8A1, 0x0113, 0xA8A5, 0x011B, 0xA8A7, 0x012B, 0xA8A9,\r\n\t0x0144, 0xA8BD, 0x0148, 0xA8BE, 0x014D, 0xA8AD, 0x016B, 0xA8B1,\t0x01CE, 0xA8A3, 0x01D0, 0xA8AB, 0x01D2, 0xA8AF, 0x01D4, 0xA8B3,\r\n\t0x01D6, 0xA8B5, 0x01D8, 0xA8B6, 0x01DA, 0xA8B7, 0x01DC, 0xA8B8,\t0x0251, 0xA8BB, 0x0261, 0xA8C0, 0x02C7, 0xA1A6, 0x02C9, 0xA1A5,\r\n\t0x02CA, 0xA840, 0x02CB, 0xA841, 0x02D9, 0xA842, 0x0391, 0xA6A1,\t0x0392, 0xA6A2, 0x0393, 0xA6A3, 0x0394, 0xA6A4, 0x0395, 0xA6A5,\r\n\t0x0396, 0xA6A6, 0x0397, 0xA6A7, 0x0398, 0xA6A8, 0x0399, 0xA6A9,\t0x039A, 0xA6AA, 0x039B, 0xA6AB, 0x039C, 0xA6AC, 0x039D, 0xA6AD,\r\n\t0x039E, 0xA6AE, 0x039F, 0xA6AF, 0x03A0, 0xA6B0, 0x03A1, 0xA6B1,\t0x03A3, 0xA6B2, 0x03A4, 0xA6B3, 0x03A5, 0xA6B4, 0x03A6, 0xA6B5,\r\n\t0x03A7, 0xA6B6, 0x03A8, 0xA6B7, 0x03A9, 0xA6B8, 0x03B1, 0xA6C1,\t0x03B2, 0xA6C2, 0x03B3, 0xA6C3, 0x03B4, 0xA6C4, 0x03B5, 0xA6C5,\r\n\t0x03B6, 0xA6C6, 0x03B7, 0xA6C7, 0x03B8, 0xA6C8, 0x03B9, 0xA6C9,\t0x03BA, 0xA6CA, 0x03BB, 0xA6CB, 0x03BC, 0xA6CC, 0x03BD, 0xA6CD,\r\n\t0x03BE, 0xA6CE, 0x03BF, 0xA6CF, 0x03C0, 0xA6D0, 0x03C1, 0xA6D1,\t0x03C3, 0xA6D2, 0x03C4, 0xA6D3, 0x03C5, 0xA6D4, 0x03C6, 0xA6D5,\r\n\t0x03C7, 0xA6D6, 0x03C8, 0xA6D7, 0x03C9, 0xA6D8, 0x0401, 0xA7A7,\t0x0410, 0xA7A1, 0x0411, 0xA7A2, 0x0412, 0xA7A3, 0x0413, 0xA7A4,\r\n\t0x0414, 0xA7A5, 0x0415, 0xA7A6, 0x0416, 0xA7A8, 0x0417, 0xA7A9,\t0x0418, 0xA7AA, 0x0419, 0xA7AB, 0x041A, 0xA7AC, 0x041B, 0xA7AD,\r\n\t0x041C, 0xA7AE, 0x041D, 0xA7AF, 0x041E, 0xA7B0, 0x041F, 0xA7B1,\t0x0420, 0xA7B2, 0x0421, 0xA7B3, 0x0422, 0xA7B4, 0x0423, 0xA7B5,\r\n\t0x0424, 0xA7B6, 0x0425, 0xA7B7, 0x0426, 0xA7B8, 0x0427, 0xA7B9,\t0x0428, 0xA7BA, 0x0429, 0xA7BB, 0x042A, 0xA7BC, 0x042B, 0xA7BD,\r\n\t0x042C, 0xA7BE, 0x042D, 0xA7BF, 0x042E, 0xA7C0, 0x042F, 0xA7C1,\t0x0430, 0xA7D1, 0x0431, 0xA7D2, 0x0432, 0xA7D3, 0x0433, 0xA7D4,\r\n\t0x0434, 0xA7D5, 0x0435, 0xA7D6, 0x0436, 0xA7D8, 0x0437, 0xA7D9,\t0x0438, 0xA7DA, 0x0439, 0xA7DB, 0x043A, 0xA7DC, 0x043B, 0xA7DD,\r\n\t0x043C, 0xA7DE, 0x043D, 0xA7DF, 0x043E, 0xA7E0, 0x043F, 0xA7E1,\t0x0440, 0xA7E2, 0x0441, 0xA7E3, 0x0442, 0xA7E4, 0x0443, 0xA7E5,\r\n\t0x0444, 0xA7E6, 0x0445, 0xA7E7, 0x0446, 0xA7E8, 0x0447, 0xA7E9,\t0x0448, 0xA7EA, 0x0449, 0xA7EB, 0x044A, 0xA7EC, 0x044B, 0xA7ED,\r\n\t0x044C, 0xA7EE, 0x044D, 0xA7EF, 0x044E, 0xA7F0, 0x044F, 0xA7F1,\t0x0451, 0xA7D7, 0x2010, 0xA95C, 0x2013, 0xA843, 0x2014, 0xA1AA,\r\n\t0x2015, 0xA844, 0x2016, 0xA1AC, 0x2018, 0xA1AE, 0x2019, 0xA1AF,\t0x201C, 0xA1B0, 0x201D, 0xA1B1, 0x2025, 0xA845, 0x2026, 0xA1AD,\r\n\t0x2030, 0xA1EB, 0x2032, 0xA1E4, 0x2033, 0xA1E5, 0x2035, 0xA846,\t0x203B, 0xA1F9, 0x20AC, 0x0080, 0x2103, 0xA1E6, 0x2105, 0xA847,\r\n\t0x2109, 0xA848, 0x2116, 0xA1ED, 0x2121, 0xA959, 0x2160, 0xA2F1,\t0x2161, 0xA2F2, 0x2162, 0xA2F3, 0x2163, 0xA2F4, 0x2164, 0xA2F5,\r\n\t0x2165, 0xA2F6, 0x2166, 0xA2F7, 0x2167, 0xA2F8, 0x2168, 0xA2F9,\t0x2169, 0xA2FA, 0x216A, 0xA2FB, 0x216B, 0xA2FC, 0x2170, 0xA2A1,\r\n\t0x2171, 0xA2A2, 0x2172, 0xA2A3, 0x2173, 0xA2A4, 0x2174, 0xA2A5,\t0x2175, 0xA2A6, 0x2176, 0xA2A7, 0x2177, 0xA2A8, 0x2178, 0xA2A9,\r\n\t0x2179, 0xA2AA, 0x2190, 0xA1FB, 0x2191, 0xA1FC, 0x2192, 0xA1FA,\t0x2193, 0xA1FD, 0x2196, 0xA849, 0x2197, 0xA84A, 0x2198, 0xA84B,\r\n\t0x2199, 0xA84C, 0x2208, 0xA1CA, 0x220F, 0xA1C7, 0x2211, 0xA1C6,\t0x2215, 0xA84D, 0x221A, 0xA1CC, 0x221D, 0xA1D8, 0x221E, 0xA1DE,\r\n\t0x221F, 0xA84E, 0x2220, 0xA1CF, 0x2223, 0xA84F, 0x2225, 0xA1CE,\t0x2227, 0xA1C4, 0x2228, 0xA1C5, 0x2229, 0xA1C9, 0x222A, 0xA1C8,\r\n\t0x222B, 0xA1D2, 0x222E, 0xA1D3, 0x2234, 0xA1E0, 0x2235, 0xA1DF,\t0x2236, 0xA1C3, 0x2237, 0xA1CB, 0x223D, 0xA1D7, 0x2248, 0xA1D6,\r\n\t0x224C, 0xA1D5, 0x2252, 0xA850, 0x2260, 0xA1D9, 0x2261, 0xA1D4,\t0x2264, 0xA1DC, 0x2265, 0xA1DD, 0x2266, 0xA851, 0x2267, 0xA852,\r\n\t0x226E, 0xA1DA, 0x226F, 0xA1DB, 0x2295, 0xA892, 0x2299, 0xA1D1,\t0x22A5, 0xA1CD, 0x22BF, 0xA853, 0x2312, 0xA1D0, 0x2460, 0xA2D9,\r\n\t0x2461, 0xA2DA, 0x2462, 0xA2DB, 0x2463, 0xA2DC, 0x2464, 0xA2DD,\t0x2465, 0xA2DE, 0x2466, 0xA2DF, 0x2467, 0xA2E0, 0x2468, 0xA2E1,\r\n\t0x2469, 0xA2E2, 0x2474, 0xA2C5, 0x2475, 0xA2C6, 0x2476, 0xA2C7,\t0x2477, 0xA2C8, 0x2478, 0xA2C9, 0x2479, 0xA2CA, 0x247A, 0xA2CB,\r\n\t0x247B, 0xA2CC, 0x247C, 0xA2CD, 0x247D, 0xA2CE, 0x247E, 0xA2CF,\t0x247F, 0xA2D0, 0x2480, 0xA2D1, 0x2481, 0xA2D2, 0x2482, 0xA2D3,\r\n\t0x2483, 0xA2D4, 0x2484, 0xA2D5, 0x2485, 0xA2D6, 0x2486, 0xA2D7,\t0x2487, 0xA2D8, 0x2488, 0xA2B1, 0x2489, 0xA2B2, 0x248A, 0xA2B3,\r\n\t0x248B, 0xA2B4, 0x248C, 0xA2B5, 0x248D, 0xA2B6, 0x248E, 0xA2B7,\t0x248F, 0xA2B8, 0x2490, 0xA2B9, 0x2491, 0xA2BA, 0x2492, 0xA2BB,\r\n\t0x2493, 0xA2BC, 0x2494, 0xA2BD, 0x2495, 0xA2BE, 0x2496, 0xA2BF,\t0x2497, 0xA2C0, 0x2498, 0xA2C1, 0x2499, 0xA2C2, 0x249A, 0xA2C3,\r\n\t0x249B, 0xA2C4, 0x2500, 0xA9A4, 0x2501, 0xA9A5, 0x2502, 0xA9A6,\t0x2503, 0xA9A7, 0x2504, 0xA9A8, 0x2505, 0xA9A9, 0x2506, 0xA9AA,\r\n\t0x2507, 0xA9AB, 0x2508, 0xA9AC, 0x2509, 0xA9AD, 0x250A, 0xA9AE,\t0x250B, 0xA9AF, 0x250C, 0xA9B0, 0x250D, 0xA9B1, 0x250E, 0xA9B2,\r\n\t0x250F, 0xA9B3, 0x2510, 0xA9B4, 0x2511, 0xA9B5, 0x2512, 0xA9B6,\t0x2513, 0xA9B7, 0x2514, 0xA9B8, 0x2515, 0xA9B9, 0x2516, 0xA9BA,\r\n\t0x2517, 0xA9BB, 0x2518, 0xA9BC, 0x2519, 0xA9BD, 0x251A, 0xA9BE,\t0x251B, 0xA9BF, 0x251C, 0xA9C0, 0x251D, 0xA9C1, 0x251E, 0xA9C2,\r\n\t0x251F, 0xA9C3, 0x2520, 0xA9C4, 0x2521, 0xA9C5, 0x2522, 0xA9C6,\t0x2523, 0xA9C7, 0x2524, 0xA9C8, 0x2525, 0xA9C9, 0x2526, 0xA9CA,\r\n\t0x2527, 0xA9CB, 0x2528, 0xA9CC, 0x2529, 0xA9CD, 0x252A, 0xA9CE,\t0x252B, 0xA9CF, 0x252C, 0xA9D0, 0x252D, 0xA9D1, 0x252E, 0xA9D2,\r\n\t0x252F, 0xA9D3, 0x2530, 0xA9D4, 0x2531, 0xA9D5, 0x2532, 0xA9D6,\t0x2533, 0xA9D7, 0x2534, 0xA9D8, 0x2535, 0xA9D9, 0x2536, 0xA9DA,\r\n\t0x2537, 0xA9DB, 0x2538, 0xA9DC, 0x2539, 0xA9DD, 0x253A, 0xA9DE,\t0x253B, 0xA9DF, 0x253C, 0xA9E0, 0x253D, 0xA9E1, 0x253E, 0xA9E2,\r\n\t0x253F, 0xA9E3, 0x2540, 0xA9E4, 0x2541, 0xA9E5, 0x2542, 0xA9E6,\t0x2543, 0xA9E7, 0x2544, 0xA9E8, 0x2545, 0xA9E9, 0x2546, 0xA9EA,\r\n\t0x2547, 0xA9EB, 0x2548, 0xA9EC, 0x2549, 0xA9ED, 0x254A, 0xA9EE,\t0x254B, 0xA9EF, 0x2550, 0xA854, 0x2551, 0xA855, 0x2552, 0xA856,\r\n\t0x2553, 0xA857, 0x2554, 0xA858, 0x2555, 0xA859, 0x2556, 0xA85A,\t0x2557, 0xA85B, 0x2558, 0xA85C, 0x2559, 0xA85D, 0x255A, 0xA85E,\r\n\t0x255B, 0xA85F, 0x255C, 0xA860, 0x255D, 0xA861, 0x255E, 0xA862,\t0x255F, 0xA863, 0x2560, 0xA864, 0x2561, 0xA865, 0x2562, 0xA866,\r\n\t0x2563, 0xA867, 0x2564, 0xA868, 0x2565, 0xA869, 0x2566, 0xA86A,\t0x2567, 0xA86B, 0x2568, 0xA86C, 0x2569, 0xA86D, 0x256A, 0xA86E,\r\n\t0x256B, 0xA86F, 0x256C, 0xA870, 0x256D, 0xA871, 0x256E, 0xA872,\t0x256F, 0xA873, 0x2570, 0xA874, 0x2571, 0xA875, 0x2572, 0xA876,\r\n\t0x2573, 0xA877, 0x2581, 0xA878, 0x2582, 0xA879, 0x2583, 0xA87A,\t0x2584, 0xA87B, 0x2585, 0xA87C, 0x2586, 0xA87D, 0x2587, 0xA87E,\r\n\t0x2588, 0xA880, 0x2589, 0xA881, 0x258A, 0xA882, 0x258B, 0xA883,\t0x258C, 0xA884, 0x258D, 0xA885, 0x258E, 0xA886, 0x258F, 0xA887,\r\n\t0x2593, 0xA888, 0x2594, 0xA889, 0x2595, 0xA88A, 0x25A0, 0xA1F6,\t0x25A1, 0xA1F5, 0x25B2, 0xA1F8, 0x25B3, 0xA1F7, 0x25BC, 0xA88B,\r\n\t0x25BD, 0xA88C, 0x25C6, 0xA1F4, 0x25C7, 0xA1F3, 0x25CB, 0xA1F0,\t0x25CE, 0xA1F2, 0x25CF, 0xA1F1, 0x25E2, 0xA88D, 0x25E3, 0xA88E,\r\n\t0x25E4, 0xA88F, 0x25E5, 0xA890, 0x2605, 0xA1EF, 0x2606, 0xA1EE,\t0x2609, 0xA891, 0x2640, 0xA1E2, 0x2642, 0xA1E1, 0x3000, 0xA1A1,\r\n\t0x3001, 0xA1A2, 0x3002, 0xA1A3, 0x3003, 0xA1A8, 0x3005, 0xA1A9,\t0x3006, 0xA965, 0x3007, 0xA996, 0x3008, 0xA1B4, 0x3009, 0xA1B5,\r\n\t0x300A, 0xA1B6, 0x300B, 0xA1B7, 0x300C, 0xA1B8, 0x300D, 0xA1B9,\t0x300E, 0xA1BA, 0x300F, 0xA1BB, 0x3010, 0xA1BE, 0x3011, 0xA1BF,\r\n\t0x3012, 0xA893, 0x3013, 0xA1FE, 0x3014, 0xA1B2, 0x3015, 0xA1B3,\t0x3016, 0xA1BC, 0x3017, 0xA1BD, 0x301D, 0xA894, 0x301E, 0xA895,\r\n\t0x3021, 0xA940, 0x3022, 0xA941, 0x3023, 0xA942, 0x3024, 0xA943,\t0x3025, 0xA944, 0x3026, 0xA945, 0x3027, 0xA946, 0x3028, 0xA947,\r\n\t0x3029, 0xA948, 0x3041, 0xA4A1, 0x3042, 0xA4A2, 0x3043, 0xA4A3,\t0x3044, 0xA4A4, 0x3045, 0xA4A5, 0x3046, 0xA4A6, 0x3047, 0xA4A7,\r\n\t0x3048, 0xA4A8, 0x3049, 0xA4A9, 0x304A, 0xA4AA, 0x304B, 0xA4AB,\t0x304C, 0xA4AC, 0x304D, 0xA4AD, 0x304E, 0xA4AE, 0x304F, 0xA4AF,\r\n\t0x3050, 0xA4B0, 0x3051, 0xA4B1, 0x3052, 0xA4B2, 0x3053, 0xA4B3,\t0x3054, 0xA4B4, 0x3055, 0xA4B5, 0x3056, 0xA4B6, 0x3057, 0xA4B7,\r\n\t0x3058, 0xA4B8, 0x3059, 0xA4B9, 0x305A, 0xA4BA, 0x305B, 0xA4BB,\t0x305C, 0xA4BC, 0x305D, 0xA4BD, 0x305E, 0xA4BE, 0x305F, 0xA4BF,\r\n\t0x3060, 0xA4C0, 0x3061, 0xA4C1, 0x3062, 0xA4C2, 0x3063, 0xA4C3,\t0x3064, 0xA4C4, 0x3065, 0xA4C5, 0x3066, 0xA4C6, 0x3067, 0xA4C7,\r\n\t0x3068, 0xA4C8, 0x3069, 0xA4C9, 0x306A, 0xA4CA, 0x306B, 0xA4CB,\t0x306C, 0xA4CC, 0x306D, 0xA4CD, 0x306E, 0xA4CE, 0x306F, 0xA4CF,\r\n\t0x3070, 0xA4D0, 0x3071, 0xA4D1, 0x3072, 0xA4D2, 0x3073, 0xA4D3,\t0x3074, 0xA4D4, 0x3075, 0xA4D5, 0x3076, 0xA4D6, 0x3077, 0xA4D7,\r\n\t0x3078, 0xA4D8, 0x3079, 0xA4D9, 0x307A, 0xA4DA, 0x307B, 0xA4DB,\t0x307C, 0xA4DC, 0x307D, 0xA4DD, 0x307E, 0xA4DE, 0x307F, 0xA4DF,\r\n\t0x3080, 0xA4E0, 0x3081, 0xA4E1, 0x3082, 0xA4E2, 0x3083, 0xA4E3,\t0x3084, 0xA4E4, 0x3085, 0xA4E5, 0x3086, 0xA4E6, 0x3087, 0xA4E7,\r\n\t0x3088, 0xA4E8, 0x3089, 0xA4E9, 0x308A, 0xA4EA, 0x308B, 0xA4EB,\t0x308C, 0xA4EC, 0x308D, 0xA4ED, 0x308E, 0xA4EE, 0x308F, 0xA4EF,\r\n\t0x3090, 0xA4F0, 0x3091, 0xA4F1, 0x3092, 0xA4F2, 0x3093, 0xA4F3,\t0x309B, 0xA961, 0x309C, 0xA962, 0x309D, 0xA966, 0x309E, 0xA967,\r\n\t0x30A1, 0xA5A1, 0x30A2, 0xA5A2, 0x30A3, 0xA5A3, 0x30A4, 0xA5A4,\t0x30A5, 0xA5A5, 0x30A6, 0xA5A6, 0x30A7, 0xA5A7, 0x30A8, 0xA5A8,\r\n\t0x30A9, 0xA5A9, 0x30AA, 0xA5AA, 0x30AB, 0xA5AB, 0x30AC, 0xA5AC,\t0x30AD, 0xA5AD, 0x30AE, 0xA5AE, 0x30AF, 0xA5AF, 0x30B0, 0xA5B0,\r\n\t0x30B1, 0xA5B1, 0x30B2, 0xA5B2, 0x30B3, 0xA5B3, 0x30B4, 0xA5B4,\t0x30B5, 0xA5B5, 0x30B6, 0xA5B6, 0x30B7, 0xA5B7, 0x30B8, 0xA5B8,\r\n\t0x30B9, 0xA5B9, 0x30BA, 0xA5BA, 0x30BB, 0xA5BB, 0x30BC, 0xA5BC,\t0x30BD, 0xA5BD, 0x30BE, 0xA5BE, 0x30BF, 0xA5BF, 0x30C0, 0xA5C0,\r\n\t0x30C1, 0xA5C1, 0x30C2, 0xA5C2, 0x30C3, 0xA5C3, 0x30C4, 0xA5C4,\t0x30C5, 0xA5C5, 0x30C6, 0xA5C6, 0x30C7, 0xA5C7, 0x30C8, 0xA5C8,\r\n\t0x30C9, 0xA5C9, 0x30CA, 0xA5CA, 0x30CB, 0xA5CB, 0x30CC, 0xA5CC,\t0x30CD, 0xA5CD, 0x30CE, 0xA5CE, 0x30CF, 0xA5CF, 0x30D0, 0xA5D0,\r\n\t0x30D1, 0xA5D1, 0x30D2, 0xA5D2, 0x30D3, 0xA5D3, 0x30D4, 0xA5D4,\t0x30D5, 0xA5D5, 0x30D6, 0xA5D6, 0x30D7, 0xA5D7, 0x30D8, 0xA5D8,\r\n\t0x30D9, 0xA5D9, 0x30DA, 0xA5DA, 0x30DB, 0xA5DB, 0x30DC, 0xA5DC,\t0x30DD, 0xA5DD, 0x30DE, 0xA5DE, 0x30DF, 0xA5DF, 0x30E0, 0xA5E0,\r\n\t0x30E1, 0xA5E1, 0x30E2, 0xA5E2, 0x30E3, 0xA5E3, 0x30E4, 0xA5E4,\t0x30E5, 0xA5E5, 0x30E6, 0xA5E6, 0x30E7, 0xA5E7, 0x30E8, 0xA5E8,\r\n\t0x30E9, 0xA5E9, 0x30EA, 0xA5EA, 0x30EB, 0xA5EB, 0x30EC, 0xA5EC,\t0x30ED, 0xA5ED, 0x30EE, 0xA5EE, 0x30EF, 0xA5EF, 0x30F0, 0xA5F0,\r\n\t0x30F1, 0xA5F1, 0x30F2, 0xA5F2, 0x30F3, 0xA5F3, 0x30F4, 0xA5F4,\t0x30F5, 0xA5F5, 0x30F6, 0xA5F6, 0x30FC, 0xA960, 0x30FD, 0xA963,\r\n\t0x30FE, 0xA964, 0x3105, 0xA8C5, 0x3106, 0xA8C6, 0x3107, 0xA8C7,\t0x3108, 0xA8C8, 0x3109, 0xA8C9, 0x310A, 0xA8CA, 0x310B, 0xA8CB,\r\n\t0x310C, 0xA8CC, 0x310D, 0xA8CD, 0x310E, 0xA8CE, 0x310F, 0xA8CF,\t0x3110, 0xA8D0, 0x3111, 0xA8D1, 0x3112, 0xA8D2, 0x3113, 0xA8D3,\r\n\t0x3114, 0xA8D4, 0x3115, 0xA8D5, 0x3116, 0xA8D6, 0x3117, 0xA8D7,\t0x3118, 0xA8D8, 0x3119, 0xA8D9, 0x311A, 0xA8DA, 0x311B, 0xA8DB,\r\n\t0x311C, 0xA8DC, 0x311D, 0xA8DD, 0x311E, 0xA8DE, 0x311F, 0xA8DF,\t0x3120, 0xA8E0, 0x3121, 0xA8E1, 0x3122, 0xA8E2, 0x3123, 0xA8E3,\r\n\t0x3124, 0xA8E4, 0x3125, 0xA8E5, 0x3126, 0xA8E6, 0x3127, 0xA8E7,\t0x3128, 0xA8E8, 0x3129, 0xA8E9, 0x3220, 0xA2E5, 0x3221, 0xA2E6,\r\n\t0x3222, 0xA2E7, 0x3223, 0xA2E8, 0x3224, 0xA2E9, 0x3225, 0xA2EA,\t0x3226, 0xA2EB, 0x3227, 0xA2EC, 0x3228, 0xA2ED, 0x3229, 0xA2EE,\r\n\t0x3231, 0xA95A, 0x32A3, 0xA949, 0x338E, 0xA94A, 0x338F, 0xA94B,\t0x339C, 0xA94C, 0x339D, 0xA94D, 0x339E, 0xA94E, 0x33A1, 0xA94F,\r\n\t0x33C4, 0xA950, 0x33CE, 0xA951, 0x33D1, 0xA952, 0x33D2, 0xA953,\t0x33D5, 0xA954, 0x4E00, 0xD2BB, 0x4E01, 0xB6A1, 0x4E02, 0x8140,\r\n\t0x4E03, 0xC6DF, 0x4E04, 0x8141, 0x4E05, 0x8142, 0x4E06, 0x8143,\t0x4E07, 0xCDF2, 0x4E08, 0xD5C9, 0x4E09, 0xC8FD, 0x4E0A, 0xC9CF,\r\n\t0x4E0B, 0xCFC2, 0x4E0C, 0xD8A2, 0x4E0D, 0xB2BB, 0x4E0E, 0xD3EB,\t0x4E0F, 0x8144, 0x4E10, 0xD8A4, 0x4E11, 0xB3F3, 0x4E12, 0x8145,\r\n\t0x4E13, 0xD7A8, 0x4E14, 0xC7D2, 0x4E15, 0xD8A7, 0x4E16, 0xCAC0,\t0x4E17, 0x8146, 0x4E18, 0xC7F0, 0x4E19, 0xB1FB, 0x4E1A, 0xD2B5,\r\n\t0x4E1B, 0xB4D4, 0x4E1C, 0xB6AB, 0x4E1D, 0xCBBF, 0x4E1E, 0xD8A9,\t0x4E1F, 0x8147, 0x4E20, 0x8148, 0x4E21, 0x8149, 0x4E22, 0xB6AA,\r\n\t0x4E23, 0x814A, 0x4E24, 0xC1BD, 0x4E25, 0xD1CF, 0x4E26, 0x814B,\t0x4E27, 0xC9A5, 0x4E28, 0xD8AD, 0x4E29, 0x814C, 0x4E2A, 0xB8F6,\r\n\t0x4E2B, 0xD1BE, 0x4E2C, 0xE3DC, 0x4E2D, 0xD6D0, 0x4E2E, 0x814D,\t0x4E2F, 0x814E, 0x4E30, 0xB7E1, 0x4E31, 0x814F, 0x4E32, 0xB4AE,\r\n\t0x4E33, 0x8150, 0x4E34, 0xC1D9, 0x4E35, 0x8151, 0x4E36, 0xD8BC,\t0x4E37, 0x8152, 0x4E38, 0xCDE8, 0x4E39, 0xB5A4, 0x4E3A, 0xCEAA,\r\n\t0x4E3B, 0xD6F7, 0x4E3C, 0x8153, 0x4E3D, 0xC0F6, 0x4E3E, 0xBED9,\t0x4E3F, 0xD8AF, 0x4E40, 0x8154, 0x4E41, 0x8155, 0x4E42, 0x8156,\r\n\t0x4E43, 0xC4CB, 0x4E44, 0x8157, 0x4E45, 0xBEC3, 0x4E46, 0x8158,\t0x4E47, 0xD8B1, 0x4E48, 0xC3B4, 0x4E49, 0xD2E5, 0x4E4A, 0x8159,\r\n\t0x4E4B, 0xD6AE, 0x4E4C, 0xCEDA, 0x4E4D, 0xD5A7, 0x4E4E, 0xBAF5,\t0x4E4F, 0xB7A6, 0x4E50, 0xC0D6, 0x4E51, 0x815A, 0x4E52, 0xC6B9,\r\n\t0x4E53, 0xC5D2, 0x4E54, 0xC7C7, 0x4E55, 0x815B, 0x4E56, 0xB9D4,\t0x4E57, 0x815C, 0x4E58, 0xB3CB, 0x4E59, 0xD2D2, 0x4E5A, 0x815D,\r\n\t0x4E5B, 0x815E, 0x4E5C, 0xD8BF, 0x4E5D, 0xBEC5, 0x4E5E, 0xC6F2,\t0x4E5F, 0xD2B2, 0x4E60, 0xCFB0, 0x4E61, 0xCFE7, 0x4E62, 0x815F,\r\n\t0x4E63, 0x8160, 0x4E64, 0x8161, 0x4E65, 0x8162, 0x4E66, 0xCAE9,\t0x4E67, 0x8163, 0x4E68, 0x8164, 0x4E69, 0xD8C0, 0x4E6A, 0x8165,\r\n\t0x4E6B, 0x8166, 0x4E6C, 0x8167, 0x4E6D, 0x8168, 0x4E6E, 0x8169,\t0x4E6F, 0x816A, 0x4E70, 0xC2F2, 0x4E71, 0xC2D2, 0x4E72, 0x816B,\r\n\t0x4E73, 0xC8E9, 0x4E74, 0x816C, 0x4E75, 0x816D, 0x4E76, 0x816E,\t0x4E77, 0x816F, 0x4E78, 0x8170, 0x4E79, 0x8171, 0x4E7A, 0x8172,\r\n\t0x4E7B, 0x8173, 0x4E7C, 0x8174, 0x4E7D, 0x8175, 0x4E7E, 0xC7AC,\t0x4E7F, 0x8176, 0x4E80, 0x8177, 0x4E81, 0x8178, 0x4E82, 0x8179,\r\n\t0x4E83, 0x817A, 0x4E84, 0x817B, 0x4E85, 0x817C, 0x4E86, 0xC1CB,\t0x4E87, 0x817D, 0x4E88, 0xD3E8, 0x4E89, 0xD5F9, 0x4E8A, 0x817E,\r\n\t0x4E8B, 0xCAC2, 0x4E8C, 0xB6FE, 0x4E8D, 0xD8A1, 0x4E8E, 0xD3DA,\t0x4E8F, 0xBFF7, 0x4E90, 0x8180, 0x4E91, 0xD4C6, 0x4E92, 0xBBA5,\r\n\t0x4E93, 0xD8C1, 0x4E94, 0xCEE5, 0x4E95, 0xBEAE, 0x4E96, 0x8181,\t0x4E97, 0x8182, 0x4E98, 0xD8A8, 0x4E99, 0x8183, 0x4E9A, 0xD1C7,\r\n\t0x4E9B, 0xD0A9, 0x4E9C, 0x8184, 0x4E9D, 0x8185, 0x4E9E, 0x8186,\t0x4E9F, 0xD8BD, 0x4EA0, 0xD9EF, 0x4EA1, 0xCDF6, 0x4EA2, 0xBFBA,\r\n\t0x4EA3, 0x8187, 0x4EA4, 0xBDBB, 0x4EA5, 0xBAA5, 0x4EA6, 0xD2E0,\t0x4EA7, 0xB2FA, 0x4EA8, 0xBAE0, 0x4EA9, 0xC4B6, 0x4EAA, 0x8188,\r\n\t0x4EAB, 0xCFED, 0x4EAC, 0xBEA9, 0x4EAD, 0xCDA4, 0x4EAE, 0xC1C1,\t0x4EAF, 0x8189, 0x4EB0, 0x818A, 0x4EB1, 0x818B, 0x4EB2, 0xC7D7,\r\n\t0x4EB3, 0xD9F1, 0x4EB4, 0x818C, 0x4EB5, 0xD9F4, 0x4EB6, 0x818D,\t0x4EB7, 0x818E, 0x4EB8, 0x818F, 0x4EB9, 0x8190, 0x4EBA, 0xC8CB,\r\n\t0x4EBB, 0xD8E9, 0x4EBC, 0x8191, 0x4EBD, 0x8192, 0x4EBE, 0x8193,\t0x4EBF, 0xD2DA, 0x4EC0, 0xCAB2, 0x4EC1, 0xC8CA, 0x4EC2, 0xD8EC,\r\n\t0x4EC3, 0xD8EA, 0x4EC4, 0xD8C6, 0x4EC5, 0xBDF6, 0x4EC6, 0xC6CD,\t0x4EC7, 0xB3F0, 0x4EC8, 0x8194, 0x4EC9, 0xD8EB, 0x4ECA, 0xBDF1,\r\n\t0x4ECB, 0xBDE9, 0x4ECC, 0x8195, 0x4ECD, 0xC8D4, 0x4ECE, 0xB4D3,\t0x4ECF, 0x8196, 0x4ED0, 0x8197, 0x4ED1, 0xC2D8, 0x4ED2, 0x8198,\r\n\t0x4ED3, 0xB2D6, 0x4ED4, 0xD7D0, 0x4ED5, 0xCACB, 0x4ED6, 0xCBFB,\t0x4ED7, 0xD5CC, 0x4ED8, 0xB8B6, 0x4ED9, 0xCFC9, 0x4EDA, 0x8199,\r\n\t0x4EDB, 0x819A, 0x4EDC, 0x819B, 0x4EDD, 0xD9DA, 0x4EDE, 0xD8F0,\t0x4EDF, 0xC7AA, 0x4EE0, 0x819C, 0x4EE1, 0xD8EE, 0x4EE2, 0x819D,\r\n\t0x4EE3, 0xB4FA, 0x4EE4, 0xC1EE, 0x4EE5, 0xD2D4, 0x4EE6, 0x819E,\t0x4EE7, 0x819F, 0x4EE8, 0xD8ED, 0x4EE9, 0x81A0, 0x4EEA, 0xD2C7,\r\n\t0x4EEB, 0xD8EF, 0x4EEC, 0xC3C7, 0x4EED, 0x81A1, 0x4EEE, 0x81A2,\t0x4EEF, 0x81A3, 0x4EF0, 0xD1F6, 0x4EF1, 0x81A4, 0x4EF2, 0xD6D9,\r\n\t0x4EF3, 0xD8F2, 0x4EF4, 0x81A5, 0x4EF5, 0xD8F5, 0x4EF6, 0xBCFE,\t0x4EF7, 0xBCDB, 0x4EF8, 0x81A6, 0x4EF9, 0x81A7, 0x4EFA, 0x81A8,\r\n\t0x4EFB, 0xC8CE, 0x4EFC, 0x81A9, 0x4EFD, 0xB7DD, 0x4EFE, 0x81AA,\t0x4EFF, 0xB7C2, 0x4F00, 0x81AB, 0x4F01, 0xC6F3, 0x4F02, 0x81AC,\r\n\t0x4F03, 0x81AD, 0x4F04, 0x81AE, 0x4F05, 0x81AF, 0x4F06, 0x81B0,\t0x4F07, 0x81B1, 0x4F08, 0x81B2, 0x4F09, 0xD8F8, 0x4F0A, 0xD2C1,\r\n\t0x4F0B, 0x81B3, 0x4F0C, 0x81B4, 0x4F0D, 0xCEE9, 0x4F0E, 0xBCBF,\t0x4F0F, 0xB7FC, 0x4F10, 0xB7A5, 0x4F11, 0xD0DD, 0x4F12, 0x81B5,\r\n\t0x4F13, 0x81B6, 0x4F14, 0x81B7, 0x4F15, 0x81B8, 0x4F16, 0x81B9,\t0x4F17, 0xD6DA, 0x4F18, 0xD3C5, 0x4F19, 0xBBEF, 0x4F1A, 0xBBE1,\r\n\t0x4F1B, 0xD8F1, 0x4F1C, 0x81BA, 0x4F1D, 0x81BB, 0x4F1E, 0xC9A1,\t0x4F1F, 0xCEB0, 0x4F20, 0xB4AB, 0x4F21, 0x81BC, 0x4F22, 0xD8F3,\r\n\t0x4F23, 0x81BD, 0x4F24, 0xC9CB, 0x4F25, 0xD8F6, 0x4F26, 0xC2D7,\t0x4F27, 0xD8F7, 0x4F28, 0x81BE, 0x4F29, 0x81BF, 0x4F2A, 0xCEB1,\r\n\t0x4F2B, 0xD8F9, 0x4F2C, 0x81C0, 0x4F2D, 0x81C1, 0x4F2E, 0x81C2,\t0x4F2F, 0xB2AE, 0x4F30, 0xB9C0, 0x4F31, 0x81C3, 0x4F32, 0xD9A3,\r\n\t0x4F33, 0x81C4, 0x4F34, 0xB0E9, 0x4F35, 0x81C5, 0x4F36, 0xC1E6,\t0x4F37, 0x81C6, 0x4F38, 0xC9EC, 0x4F39, 0x81C7, 0x4F3A, 0xCBC5,\r\n\t0x4F3B, 0x81C8, 0x4F3C, 0xCBC6, 0x4F3D, 0xD9A4, 0x4F3E, 0x81C9,\t0x4F3F, 0x81CA, 0x4F40, 0x81CB, 0x4F41, 0x81CC, 0x4F42, 0x81CD,\r\n\t0x4F43, 0xB5E8, 0x4F44, 0x81CE, 0x4F45, 0x81CF, 0x4F46, 0xB5AB,\t0x4F47, 0x81D0, 0x4F48, 0x81D1, 0x4F49, 0x81D2, 0x4F4A, 0x81D3,\r\n\t0x4F4B, 0x81D4, 0x4F4C, 0x81D5, 0x4F4D, 0xCEBB, 0x4F4E, 0xB5CD,\t0x4F4F, 0xD7A1, 0x4F50, 0xD7F4, 0x4F51, 0xD3D3, 0x4F52, 0x81D6,\r\n\t0x4F53, 0xCCE5, 0x4F54, 0x81D7, 0x4F55, 0xBACE, 0x4F56, 0x81D8,\t0x4F57, 0xD9A2, 0x4F58, 0xD9DC, 0x4F59, 0xD3E0, 0x4F5A, 0xD8FD,\r\n\t0x4F5B, 0xB7F0, 0x4F5C, 0xD7F7, 0x4F5D, 0xD8FE, 0x4F5E, 0xD8FA,\t0x4F5F, 0xD9A1, 0x4F60, 0xC4E3, 0x4F61, 0x81D9, 0x4F62, 0x81DA,\r\n\t0x4F63, 0xD3B6, 0x4F64, 0xD8F4, 0x4F65, 0xD9DD, 0x4F66, 0x81DB,\t0x4F67, 0xD8FB, 0x4F68, 0x81DC, 0x4F69, 0xC5E5, 0x4F6A, 0x81DD,\r\n\t0x4F6B, 0x81DE, 0x4F6C, 0xC0D0, 0x4F6D, 0x81DF, 0x4F6E, 0x81E0,\t0x4F6F, 0xD1F0, 0x4F70, 0xB0DB, 0x4F71, 0x81E1, 0x4F72, 0x81E2,\r\n\t0x4F73, 0xBCD1, 0x4F74, 0xD9A6, 0x4F75, 0x81E3, 0x4F76, 0xD9A5,\t0x4F77, 0x81E4, 0x4F78, 0x81E5, 0x4F79, 0x81E6, 0x4F7A, 0x81E7,\r\n\t0x4F7B, 0xD9AC, 0x4F7C, 0xD9AE, 0x4F7D, 0x81E8, 0x4F7E, 0xD9AB,\t0x4F7F, 0xCAB9, 0x4F80, 0x81E9, 0x4F81, 0x81EA, 0x4F82, 0x81EB,\r\n\t0x4F83, 0xD9A9, 0x4F84, 0xD6B6, 0x4F85, 0x81EC, 0x4F86, 0x81ED,\t0x4F87, 0x81EE, 0x4F88, 0xB3DE, 0x4F89, 0xD9A8, 0x4F8A, 0x81EF,\r\n\t0x4F8B, 0xC0FD, 0x4F8C, 0x81F0, 0x4F8D, 0xCACC, 0x4F8E, 0x81F1,\t0x4F8F, 0xD9AA, 0x4F90, 0x81F2, 0x4F91, 0xD9A7, 0x4F92, 0x81F3,\r\n\t0x4F93, 0x81F4, 0x4F94, 0xD9B0, 0x4F95, 0x81F5, 0x4F96, 0x81F6,\t0x4F97, 0xB6B1, 0x4F98, 0x81F7, 0x4F99, 0x81F8, 0x4F9A, 0x81F9,\r\n\t0x4F9B, 0xB9A9, 0x4F9C, 0x81FA, 0x4F9D, 0xD2C0, 0x4F9E, 0x81FB,\t0x4F9F, 0x81FC, 0x4FA0, 0xCFC0, 0x4FA1, 0x81FD, 0x4FA2, 0x81FE,\r\n\t0x4FA3, 0xC2C2, 0x4FA4, 0x8240, 0x4FA5, 0xBDC4, 0x4FA6, 0xD5EC,\t0x4FA7, 0xB2E0, 0x4FA8, 0xC7C8, 0x4FA9, 0xBFEB, 0x4FAA, 0xD9AD,\r\n\t0x4FAB, 0x8241, 0x4FAC, 0xD9AF, 0x4FAD, 0x8242, 0x4FAE, 0xCEEA,\t0x4FAF, 0xBAEE, 0x4FB0, 0x8243, 0x4FB1, 0x8244, 0x4FB2, 0x8245,\r\n\t0x4FB3, 0x8246, 0x4FB4, 0x8247, 0x4FB5, 0xC7D6, 0x4FB6, 0x8248,\t0x4FB7, 0x8249, 0x4FB8, 0x824A, 0x4FB9, 0x824B, 0x4FBA, 0x824C,\r\n\t0x4FBB, 0x824D, 0x4FBC, 0x824E, 0x4FBD, 0x824F, 0x4FBE, 0x8250,\t0x4FBF, 0xB1E3, 0x4FC0, 0x8251, 0x4FC1, 0x8252, 0x4FC2, 0x8253,\r\n\t0x4FC3, 0xB4D9, 0x4FC4, 0xB6ED, 0x4FC5, 0xD9B4, 0x4FC6, 0x8254,\t0x4FC7, 0x8255, 0x4FC8, 0x8256, 0x4FC9, 0x8257, 0x4FCA, 0xBFA1,\r\n\t0x4FCB, 0x8258, 0x4FCC, 0x8259, 0x4FCD, 0x825A, 0x4FCE, 0xD9DE,\t0x4FCF, 0xC7CE, 0x4FD0, 0xC0FE, 0x4FD1, 0xD9B8, 0x4FD2, 0x825B,\r\n\t0x4FD3, 0x825C, 0x4FD4, 0x825D, 0x4FD5, 0x825E, 0x4FD6, 0x825F,\t0x4FD7, 0xCBD7, 0x4FD8, 0xB7FD, 0x4FD9, 0x8260, 0x4FDA, 0xD9B5,\r\n\t0x4FDB, 0x8261, 0x4FDC, 0xD9B7, 0x4FDD, 0xB1A3, 0x4FDE, 0xD3E1,\t0x4FDF, 0xD9B9, 0x4FE0, 0x8262, 0x4FE1, 0xD0C5, 0x4FE2, 0x8263,\r\n\t0x4FE3, 0xD9B6, 0x4FE4, 0x8264, 0x4FE5, 0x8265, 0x4FE6, 0xD9B1,\t0x4FE7, 0x8266, 0x4FE8, 0xD9B2, 0x4FE9, 0xC1A9, 0x4FEA, 0xD9B3,\r\n\t0x4FEB, 0x8267, 0x4FEC, 0x8268, 0x4FED, 0xBCF3, 0x4FEE, 0xD0DE,\t0x4FEF, 0xB8A9, 0x4FF0, 0x8269, 0x4FF1, 0xBEE3, 0x4FF2, 0x826A,\r\n\t0x4FF3, 0xD9BD, 0x4FF4, 0x826B, 0x4FF5, 0x826C, 0x4FF6, 0x826D,\t0x4FF7, 0x826E, 0x4FF8, 0xD9BA, 0x4FF9, 0x826F, 0x4FFA, 0xB0B3,\r\n\t0x4FFB, 0x8270, 0x4FFC, 0x8271, 0x4FFD, 0x8272, 0x4FFE, 0xD9C2,\t0x4FFF, 0x8273, 0x5000, 0x8274, 0x5001, 0x8275, 0x5002, 0x8276,\r\n\t0x5003, 0x8277, 0x5004, 0x8278, 0x5005, 0x8279, 0x5006, 0x827A,\t0x5007, 0x827B, 0x5008, 0x827C, 0x5009, 0x827D, 0x500A, 0x827E,\r\n\t0x500B, 0x8280, 0x500C, 0xD9C4, 0x500D, 0xB1B6, 0x500E, 0x8281,\t0x500F, 0xD9BF, 0x5010, 0x8282, 0x5011, 0x8283, 0x5012, 0xB5B9,\r\n\t0x5013, 0x8284, 0x5014, 0xBEF3, 0x5015, 0x8285, 0x5016, 0x8286,\t0x5017, 0x8287, 0x5018, 0xCCC8, 0x5019, 0xBAF2, 0x501A, 0xD2D0,\r\n\t0x501B, 0x8288, 0x501C, 0xD9C3, 0x501D, 0x8289, 0x501E, 0x828A,\t0x501F, 0xBDE8, 0x5020, 0x828B, 0x5021, 0xB3AB, 0x5022, 0x828C,\r\n\t0x5023, 0x828D, 0x5024, 0x828E, 0x5025, 0xD9C5, 0x5026, 0xBEEB,\t0x5027, 0x828F, 0x5028, 0xD9C6, 0x5029, 0xD9BB, 0x502A, 0xC4DF,\r\n\t0x502B, 0x8290, 0x502C, 0xD9BE, 0x502D, 0xD9C1, 0x502E, 0xD9C0,\t0x502F, 0x8291, 0x5030, 0x8292, 0x5031, 0x8293, 0x5032, 0x8294,\r\n\t0x5033, 0x8295, 0x5034, 0x8296, 0x5035, 0x8297, 0x5036, 0x8298,\t0x5037, 0x8299, 0x5038, 0x829A, 0x5039, 0x829B, 0x503A, 0xD5AE,\r\n\t0x503B, 0x829C, 0x503C, 0xD6B5, 0x503D, 0x829D, 0x503E, 0xC7E3,\t0x503F, 0x829E, 0x5040, 0x829F, 0x5041, 0x82A0, 0x5042, 0x82A1,\r\n\t0x5043, 0xD9C8, 0x5044, 0x82A2, 0x5045, 0x82A3, 0x5046, 0x82A4,\t0x5047, 0xBCD9, 0x5048, 0xD9CA, 0x5049, 0x82A5, 0x504A, 0x82A6,\r\n\t0x504B, 0x82A7, 0x504C, 0xD9BC, 0x504D, 0x82A8, 0x504E, 0xD9CB,\t0x504F, 0xC6AB, 0x5050, 0x82A9, 0x5051, 0x82AA, 0x5052, 0x82AB,\r\n\t0x5053, 0x82AC, 0x5054, 0x82AD, 0x5055, 0xD9C9, 0x5056, 0x82AE,\t0x5057, 0x82AF, 0x5058, 0x82B0, 0x5059, 0x82B1, 0x505A, 0xD7F6,\r\n\t0x505B, 0x82B2, 0x505C, 0xCDA3, 0x505D, 0x82B3, 0x505E, 0x82B4,\t0x505F, 0x82B5, 0x5060, 0x82B6, 0x5061, 0x82B7, 0x5062, 0x82B8,\r\n\t0x5063, 0x82B9, 0x5064, 0x82BA, 0x5065, 0xBDA1, 0x5066, 0x82BB,\t0x5067, 0x82BC, 0x5068, 0x82BD, 0x5069, 0x82BE, 0x506A, 0x82BF,\r\n\t0x506B, 0x82C0, 0x506C, 0xD9CC, 0x506D, 0x82C1, 0x506E, 0x82C2,\t0x506F, 0x82C3, 0x5070, 0x82C4, 0x5071, 0x82C5, 0x5072, 0x82C6,\r\n\t0x5073, 0x82C7, 0x5074, 0x82C8, 0x5075, 0x82C9, 0x5076, 0xC5BC,\t0x5077, 0xCDB5, 0x5078, 0x82CA, 0x5079, 0x82CB, 0x507A, 0x82CC,\r\n\t0x507B, 0xD9CD, 0x507C, 0x82CD, 0x507D, 0x82CE, 0x507E, 0xD9C7,\t0x507F, 0xB3A5, 0x5080, 0xBFFE, 0x5081, 0x82CF, 0x5082, 0x82D0,\r\n\t0x5083, 0x82D1, 0x5084, 0x82D2, 0x5085, 0xB8B5, 0x5086, 0x82D3,\t0x5087, 0x82D4, 0x5088, 0xC0FC, 0x5089, 0x82D5, 0x508A, 0x82D6,\r\n\t0x508B, 0x82D7, 0x508C, 0x82D8, 0x508D, 0xB0F8, 0x508E, 0x82D9,\t0x508F, 0x82DA, 0x5090, 0x82DB, 0x5091, 0x82DC, 0x5092, 0x82DD,\r\n\t0x5093, 0x82DE, 0x5094, 0x82DF, 0x5095, 0x82E0, 0x5096, 0x82E1,\t0x5097, 0x82E2, 0x5098, 0x82E3, 0x5099, 0x82E4, 0x509A, 0x82E5,\r\n\t0x509B, 0x82E6, 0x509C, 0x82E7, 0x509D, 0x82E8, 0x509E, 0x82E9,\t0x509F, 0x82EA, 0x50A0, 0x82EB, 0x50A1, 0x82EC, 0x50A2, 0x82ED,\r\n\t0x50A3, 0xB4F6, 0x50A4, 0x82EE, 0x50A5, 0xD9CE, 0x50A6, 0x82EF,\t0x50A7, 0xD9CF, 0x50A8, 0xB4A2, 0x50A9, 0xD9D0, 0x50AA, 0x82F0,\r\n\t0x50AB, 0x82F1, 0x50AC, 0xB4DF, 0x50AD, 0x82F2, 0x50AE, 0x82F3,\t0x50AF, 0x82F4, 0x50B0, 0x82F5, 0x50B1, 0x82F6, 0x50B2, 0xB0C1,\r\n\t0x50B3, 0x82F7, 0x50B4, 0x82F8, 0x50B5, 0x82F9, 0x50B6, 0x82FA,\t0x50B7, 0x82FB, 0x50B8, 0x82FC, 0x50B9, 0x82FD, 0x50BA, 0xD9D1,\r\n\t0x50BB, 0xC9B5, 0x50BC, 0x82FE, 0x50BD, 0x8340, 0x50BE, 0x8341,\t0x50BF, 0x8342, 0x50C0, 0x8343, 0x50C1, 0x8344, 0x50C2, 0x8345,\r\n\t0x50C3, 0x8346, 0x50C4, 0x8347, 0x50C5, 0x8348, 0x50C6, 0x8349,\t0x50C7, 0x834A, 0x50C8, 0x834B, 0x50C9, 0x834C, 0x50CA, 0x834D,\r\n\t0x50CB, 0x834E, 0x50CC, 0x834F, 0x50CD, 0x8350, 0x50CE, 0x8351,\t0x50CF, 0xCFF1, 0x50D0, 0x8352, 0x50D1, 0x8353, 0x50D2, 0x8354,\r\n\t0x50D3, 0x8355, 0x50D4, 0x8356, 0x50D5, 0x8357, 0x50D6, 0xD9D2,\t0x50D7, 0x8358, 0x50D8, 0x8359, 0x50D9, 0x835A, 0x50DA, 0xC1C5,\r\n\t0x50DB, 0x835B, 0x50DC, 0x835C, 0x50DD, 0x835D, 0x50DE, 0x835E,\t0x50DF, 0x835F, 0x50E0, 0x8360, 0x50E1, 0x8361, 0x50E2, 0x8362,\r\n\t0x50E3, 0x8363, 0x50E4, 0x8364, 0x50E5, 0x8365, 0x50E6, 0xD9D6,\t0x50E7, 0xC9AE, 0x50E8, 0x8366, 0x50E9, 0x8367, 0x50EA, 0x8368,\r\n\t0x50EB, 0x8369, 0x50EC, 0xD9D5, 0x50ED, 0xD9D4, 0x50EE, 0xD9D7,\t0x50EF, 0x836A, 0x50F0, 0x836B, 0x50F1, 0x836C, 0x50F2, 0x836D,\r\n\t0x50F3, 0xCBDB, 0x50F4, 0x836E, 0x50F5, 0xBDA9, 0x50F6, 0x836F,\t0x50F7, 0x8370, 0x50F8, 0x8371, 0x50F9, 0x8372, 0x50FA, 0x8373,\r\n\t0x50FB, 0xC6A7, 0x50FC, 0x8374, 0x50FD, 0x8375, 0x50FE, 0x8376,\t0x50FF, 0x8377, 0x5100, 0x8378, 0x5101, 0x8379, 0x5102, 0x837A,\r\n\t0x5103, 0x837B, 0x5104, 0x837C, 0x5105, 0x837D, 0x5106, 0xD9D3,\t0x5107, 0xD9D8, 0x5108, 0x837E, 0x5109, 0x8380, 0x510A, 0x8381,\r\n\t0x510B, 0xD9D9, 0x510C, 0x8382, 0x510D, 0x8383, 0x510E, 0x8384,\t0x510F, 0x8385, 0x5110, 0x8386, 0x5111, 0x8387, 0x5112, 0xC8E5,\r\n\t0x5113, 0x8388, 0x5114, 0x8389, 0x5115, 0x838A, 0x5116, 0x838B,\t0x5117, 0x838C, 0x5118, 0x838D, 0x5119, 0x838E, 0x511A, 0x838F,\r\n\t0x511B, 0x8390, 0x511C, 0x8391, 0x511D, 0x8392, 0x511E, 0x8393,\t0x511F, 0x8394, 0x5120, 0x8395, 0x5121, 0xC0DC, 0x5122, 0x8396,\r\n\t0x5123, 0x8397, 0x5124, 0x8398, 0x5125, 0x8399, 0x5126, 0x839A,\t0x5127, 0x839B, 0x5128, 0x839C, 0x5129, 0x839D, 0x512A, 0x839E,\r\n\t0x512B, 0x839F, 0x512C, 0x83A0, 0x512D, 0x83A1, 0x512E, 0x83A2,\t0x512F, 0x83A3, 0x5130, 0x83A4, 0x5131, 0x83A5, 0x5132, 0x83A6,\r\n\t0x5133, 0x83A7, 0x5134, 0x83A8, 0x5135, 0x83A9, 0x5136, 0x83AA,\t0x5137, 0x83AB, 0x5138, 0x83AC, 0x5139, 0x83AD, 0x513A, 0x83AE,\r\n\t0x513B, 0x83AF, 0x513C, 0x83B0, 0x513D, 0x83B1, 0x513E, 0x83B2,\t0x513F, 0xB6F9, 0x5140, 0xD8A3, 0x5141, 0xD4CA, 0x5142, 0x83B3,\r\n\t0x5143, 0xD4AA, 0x5144, 0xD0D6, 0x5145, 0xB3E4, 0x5146, 0xD5D7,\t0x5147, 0x83B4, 0x5148, 0xCFC8, 0x5149, 0xB9E2, 0x514A, 0x83B5,\r\n\t0x514B, 0xBFCB, 0x514C, 0x83B6, 0x514D, 0xC3E2, 0x514E, 0x83B7,\t0x514F, 0x83B8, 0x5150, 0x83B9, 0x5151, 0xB6D2, 0x5152, 0x83BA,\r\n\t0x5153, 0x83BB, 0x5154, 0xCDC3, 0x5155, 0xD9EE, 0x5156, 0xD9F0,\t0x5157, 0x83BC, 0x5158, 0x83BD, 0x5159, 0x83BE, 0x515A, 0xB5B3,\r\n\t0x515B, 0x83BF, 0x515C, 0xB6B5, 0x515D, 0x83C0, 0x515E, 0x83C1,\t0x515F, 0x83C2, 0x5160, 0x83C3, 0x5161, 0x83C4, 0x5162, 0xBEA4,\r\n\t0x5163, 0x83C5, 0x5164, 0x83C6, 0x5165, 0xC8EB, 0x5166, 0x83C7,\t0x5167, 0x83C8, 0x5168, 0xC8AB, 0x5169, 0x83C9, 0x516A, 0x83CA,\r\n\t0x516B, 0xB0CB, 0x516C, 0xB9AB, 0x516D, 0xC1F9, 0x516E, 0xD9E2,\t0x516F, 0x83CB, 0x5170, 0xC0BC, 0x5171, 0xB9B2, 0x5172, 0x83CC,\r\n\t0x5173, 0xB9D8, 0x5174, 0xD0CB, 0x5175, 0xB1F8, 0x5176, 0xC6E4,\t0x5177, 0xBEDF, 0x5178, 0xB5E4, 0x5179, 0xD7C8, 0x517A, 0x83CD,\r\n\t0x517B, 0xD1F8, 0x517C, 0xBCE6, 0x517D, 0xCADE, 0x517E, 0x83CE,\t0x517F, 0x83CF, 0x5180, 0xBCBD, 0x5181, 0xD9E6, 0x5182, 0xD8E7,\r\n\t0x5183, 0x83D0, 0x5184, 0x83D1, 0x5185, 0xC4DA, 0x5186, 0x83D2,\t0x5187, 0x83D3, 0x5188, 0xB8D4, 0x5189, 0xC8BD, 0x518A, 0x83D4,\r\n\t0x518B, 0x83D5, 0x518C, 0xB2E1, 0x518D, 0xD4D9, 0x518E, 0x83D6,\t0x518F, 0x83D7, 0x5190, 0x83D8, 0x5191, 0x83D9, 0x5192, 0xC3B0,\r\n\t0x5193, 0x83DA, 0x5194, 0x83DB, 0x5195, 0xC3E1, 0x5196, 0xDAA2,\t0x5197, 0xC8DF, 0x5198, 0x83DC, 0x5199, 0xD0B4, 0x519A, 0x83DD,\r\n\t0x519B, 0xBEFC, 0x519C, 0xC5A9, 0x519D, 0x83DE, 0x519E, 0x83DF,\t0x519F, 0x83E0, 0x51A0, 0xB9DA, 0x51A1, 0x83E1, 0x51A2, 0xDAA3,\r\n\t0x51A3, 0x83E2, 0x51A4, 0xD4A9, 0x51A5, 0xDAA4, 0x51A6, 0x83E3,\t0x51A7, 0x83E4, 0x51A8, 0x83E5, 0x51A9, 0x83E6, 0x51AA, 0x83E7,\r\n\t0x51AB, 0xD9FB, 0x51AC, 0xB6AC, 0x51AD, 0x83E8, 0x51AE, 0x83E9,\t0x51AF, 0xB7EB, 0x51B0, 0xB1F9, 0x51B1, 0xD9FC, 0x51B2, 0xB3E5,\r\n\t0x51B3, 0xBEF6, 0x51B4, 0x83EA, 0x51B5, 0xBFF6, 0x51B6, 0xD2B1,\t0x51B7, 0xC0E4, 0x51B8, 0x83EB, 0x51B9, 0x83EC, 0x51BA, 0x83ED,\r\n\t0x51BB, 0xB6B3, 0x51BC, 0xD9FE, 0x51BD, 0xD9FD, 0x51BE, 0x83EE,\t0x51BF, 0x83EF, 0x51C0, 0xBEBB, 0x51C1, 0x83F0, 0x51C2, 0x83F1,\r\n\t0x51C3, 0x83F2, 0x51C4, 0xC6E0, 0x51C5, 0x83F3, 0x51C6, 0xD7BC,\t0x51C7, 0xDAA1, 0x51C8, 0x83F4, 0x51C9, 0xC1B9, 0x51CA, 0x83F5,\r\n\t0x51CB, 0xB5F2, 0x51CC, 0xC1E8, 0x51CD, 0x83F6, 0x51CE, 0x83F7,\t0x51CF, 0xBCF5, 0x51D0, 0x83F8, 0x51D1, 0xB4D5, 0x51D2, 0x83F9,\r\n\t0x51D3, 0x83FA, 0x51D4, 0x83FB, 0x51D5, 0x83FC, 0x51D6, 0x83FD,\t0x51D7, 0x83FE, 0x51D8, 0x8440, 0x51D9, 0x8441, 0x51DA, 0x8442,\r\n\t0x51DB, 0xC1DD, 0x51DC, 0x8443, 0x51DD, 0xC4FD, 0x51DE, 0x8444,\t0x51DF, 0x8445, 0x51E0, 0xBCB8, 0x51E1, 0xB7B2, 0x51E2, 0x8446,\r\n\t0x51E3, 0x8447, 0x51E4, 0xB7EF, 0x51E5, 0x8448, 0x51E6, 0x8449,\t0x51E7, 0x844A, 0x51E8, 0x844B, 0x51E9, 0x844C, 0x51EA, 0x844D,\r\n\t0x51EB, 0xD9EC, 0x51EC, 0x844E, 0x51ED, 0xC6BE, 0x51EE, 0x844F,\t0x51EF, 0xBFAD, 0x51F0, 0xBBCB, 0x51F1, 0x8450, 0x51F2, 0x8451,\r\n\t0x51F3, 0xB5CA, 0x51F4, 0x8452, 0x51F5, 0xDBC9, 0x51F6, 0xD0D7,\t0x51F7, 0x8453, 0x51F8, 0xCDB9, 0x51F9, 0xB0BC, 0x51FA, 0xB3F6,\r\n\t0x51FB, 0xBBF7, 0x51FC, 0xDBCA, 0x51FD, 0xBAAF, 0x51FE, 0x8454,\t0x51FF, 0xD4E4, 0x5200, 0xB5B6, 0x5201, 0xB5F3, 0x5202, 0xD8D6,\r\n\t0x5203, 0xC8D0, 0x5204, 0x8455, 0x5205, 0x8456, 0x5206, 0xB7D6,\t0x5207, 0xC7D0, 0x5208, 0xD8D7, 0x5209, 0x8457, 0x520A, 0xBFAF,\r\n\t0x520B, 0x8458, 0x520C, 0x8459, 0x520D, 0xDBBB, 0x520E, 0xD8D8,\t0x520F, 0x845A, 0x5210, 0x845B, 0x5211, 0xD0CC, 0x5212, 0xBBAE,\r\n\t0x5213, 0x845C, 0x5214, 0x845D, 0x5215, 0x845E, 0x5216, 0xEBBE,\t0x5217, 0xC1D0, 0x5218, 0xC1F5, 0x5219, 0xD4F2, 0x521A, 0xB8D5,\r\n\t0x521B, 0xB4B4, 0x521C, 0x845F, 0x521D, 0xB3F5, 0x521E, 0x8460,\t0x521F, 0x8461, 0x5220, 0xC9BE, 0x5221, 0x8462, 0x5222, 0x8463,\r\n\t0x5223, 0x8464, 0x5224, 0xC5D0, 0x5225, 0x8465, 0x5226, 0x8466,\t0x5227, 0x8467, 0x5228, 0xC5D9, 0x5229, 0xC0FB, 0x522A, 0x8468,\r\n\t0x522B, 0xB1F0, 0x522C, 0x8469, 0x522D, 0xD8D9, 0x522E, 0xB9CE,\t0x522F, 0x846A, 0x5230, 0xB5BD, 0x5231, 0x846B, 0x5232, 0x846C,\r\n\t0x5233, 0xD8DA, 0x5234, 0x846D, 0x5235, 0x846E, 0x5236, 0xD6C6,\t0x5237, 0xCBA2, 0x5238, 0xC8AF, 0x5239, 0xC9B2, 0x523A, 0xB4CC,\r\n\t0x523B, 0xBFCC, 0x523C, 0x846F, 0x523D, 0xB9F4, 0x523E, 0x8470,\t0x523F, 0xD8DB, 0x5240, 0xD8DC, 0x5241, 0xB6E7, 0x5242, 0xBCC1,\r\n\t0x5243, 0xCCEA, 0x5244, 0x8471, 0x5245, 0x8472, 0x5246, 0x8473,\t0x5247, 0x8474, 0x5248, 0x8475, 0x5249, 0x8476, 0x524A, 0xCFF7,\r\n\t0x524B, 0x8477, 0x524C, 0xD8DD, 0x524D, 0xC7B0, 0x524E, 0x8478,\t0x524F, 0x8479, 0x5250, 0xB9D0, 0x5251, 0xBDA3, 0x5252, 0x847A,\r\n\t0x5253, 0x847B, 0x5254, 0xCCDE, 0x5255, 0x847C, 0x5256, 0xC6CA,\t0x5257, 0x847D, 0x5258, 0x847E, 0x5259, 0x8480, 0x525A, 0x8481,\r\n\t0x525B, 0x8482, 0x525C, 0xD8E0, 0x525D, 0x8483, 0x525E, 0xD8DE,\t0x525F, 0x8484, 0x5260, 0x8485, 0x5261, 0xD8DF, 0x5262, 0x8486,\r\n\t0x5263, 0x8487, 0x5264, 0x8488, 0x5265, 0xB0FE, 0x5266, 0x8489,\t0x5267, 0xBEE7, 0x5268, 0x848A, 0x5269, 0xCAA3, 0x526A, 0xBCF4,\r\n\t0x526B, 0x848B, 0x526C, 0x848C, 0x526D, 0x848D, 0x526E, 0x848E,\t0x526F, 0xB8B1, 0x5270, 0x848F, 0x5271, 0x8490, 0x5272, 0xB8EE,\r\n\t0x5273, 0x8491, 0x5274, 0x8492, 0x5275, 0x8493, 0x5276, 0x8494,\t0x5277, 0x8495, 0x5278, 0x8496, 0x5279, 0x8497, 0x527A, 0x8498,\r\n\t0x527B, 0x8499, 0x527C, 0x849A, 0x527D, 0xD8E2, 0x527E, 0x849B,\t0x527F, 0xBDCB, 0x5280, 0x849C, 0x5281, 0xD8E4, 0x5282, 0xD8E3,\r\n\t0x5283, 0x849D, 0x5284, 0x849E, 0x5285, 0x849F, 0x5286, 0x84A0,\t0x5287, 0x84A1, 0x5288, 0xC5FC, 0x5289, 0x84A2, 0x528A, 0x84A3,\r\n\t0x528B, 0x84A4, 0x528C, 0x84A5, 0x528D, 0x84A6, 0x528E, 0x84A7,\t0x528F, 0x84A8, 0x5290, 0xD8E5, 0x5291, 0x84A9, 0x5292, 0x84AA,\r\n\t0x5293, 0xD8E6, 0x5294, 0x84AB, 0x5295, 0x84AC, 0x5296, 0x84AD,\t0x5297, 0x84AE, 0x5298, 0x84AF, 0x5299, 0x84B0, 0x529A, 0x84B1,\r\n\t0x529B, 0xC1A6, 0x529C, 0x84B2, 0x529D, 0xC8B0, 0x529E, 0xB0EC,\t0x529F, 0xB9A6, 0x52A0, 0xBCD3, 0x52A1, 0xCEF1, 0x52A2, 0xDBBD,\r\n\t0x52A3, 0xC1D3, 0x52A4, 0x84B3, 0x52A5, 0x84B4, 0x52A6, 0x84B5,\t0x52A7, 0x84B6, 0x52A8, 0xB6AF, 0x52A9, 0xD6FA, 0x52AA, 0xC5AC,\r\n\t0x52AB, 0xBDD9, 0x52AC, 0xDBBE, 0x52AD, 0xDBBF, 0x52AE, 0x84B7,\t0x52AF, 0x84B8, 0x52B0, 0x84B9, 0x52B1, 0xC0F8, 0x52B2, 0xBEA2,\r\n\t0x52B3, 0xC0CD, 0x52B4, 0x84BA, 0x52B5, 0x84BB, 0x52B6, 0x84BC,\t0x52B7, 0x84BD, 0x52B8, 0x84BE, 0x52B9, 0x84BF, 0x52BA, 0x84C0,\r\n\t0x52BB, 0x84C1, 0x52BC, 0x84C2, 0x52BD, 0x84C3, 0x52BE, 0xDBC0,\t0x52BF, 0xCAC6, 0x52C0, 0x84C4, 0x52C1, 0x84C5, 0x52C2, 0x84C6,\r\n\t0x52C3, 0xB2AA, 0x52C4, 0x84C7, 0x52C5, 0x84C8, 0x52C6, 0x84C9,\t0x52C7, 0xD3C2, 0x52C8, 0x84CA, 0x52C9, 0xC3E3, 0x52CA, 0x84CB,\r\n\t0x52CB, 0xD1AB, 0x52CC, 0x84CC, 0x52CD, 0x84CD, 0x52CE, 0x84CE,\t0x52CF, 0x84CF, 0x52D0, 0xDBC2, 0x52D1, 0x84D0, 0x52D2, 0xC0D5,\r\n\t0x52D3, 0x84D1, 0x52D4, 0x84D2, 0x52D5, 0x84D3, 0x52D6, 0xDBC3,\t0x52D7, 0x84D4, 0x52D8, 0xBFB1, 0x52D9, 0x84D5, 0x52DA, 0x84D6,\r\n\t0x52DB, 0x84D7, 0x52DC, 0x84D8, 0x52DD, 0x84D9, 0x52DE, 0x84DA,\t0x52DF, 0xC4BC, 0x52E0, 0x84DB, 0x52E1, 0x84DC, 0x52E2, 0x84DD,\r\n\t0x52E3, 0x84DE, 0x52E4, 0xC7DA, 0x52E5, 0x84DF, 0x52E6, 0x84E0,\t0x52E7, 0x84E1, 0x52E8, 0x84E2, 0x52E9, 0x84E3, 0x52EA, 0x84E4,\r\n\t0x52EB, 0x84E5, 0x52EC, 0x84E6, 0x52ED, 0x84E7, 0x52EE, 0x84E8,\t0x52EF, 0x84E9, 0x52F0, 0xDBC4, 0x52F1, 0x84EA, 0x52F2, 0x84EB,\r\n\t0x52F3, 0x84EC, 0x52F4, 0x84ED, 0x52F5, 0x84EE, 0x52F6, 0x84EF,\t0x52F7, 0x84F0, 0x52F8, 0x84F1, 0x52F9, 0xD9E8, 0x52FA, 0xC9D7,\r\n\t0x52FB, 0x84F2, 0x52FC, 0x84F3, 0x52FD, 0x84F4, 0x52FE, 0xB9B4,\t0x52FF, 0xCEF0, 0x5300, 0xD4C8, 0x5301, 0x84F5, 0x5302, 0x84F6,\r\n\t0x5303, 0x84F7, 0x5304, 0x84F8, 0x5305, 0xB0FC, 0x5306, 0xB4D2,\t0x5307, 0x84F9, 0x5308, 0xD0D9, 0x5309, 0x84FA, 0x530A, 0x84FB,\r\n\t0x530B, 0x84FC, 0x530C, 0x84FD, 0x530D, 0xD9E9, 0x530E, 0x84FE,\t0x530F, 0xDECB, 0x5310, 0xD9EB, 0x5311, 0x8540, 0x5312, 0x8541,\r\n\t0x5313, 0x8542, 0x5314, 0x8543, 0x5315, 0xD8B0, 0x5316, 0xBBAF,\t0x5317, 0xB1B1, 0x5318, 0x8544, 0x5319, 0xB3D7, 0x531A, 0xD8CE,\r\n\t0x531B, 0x8545, 0x531C, 0x8546, 0x531D, 0xD4D1, 0x531E, 0x8547,\t0x531F, 0x8548, 0x5320, 0xBDB3, 0x5321, 0xBFEF, 0x5322, 0x8549,\r\n\t0x5323, 0xCFBB, 0x5324, 0x854A, 0x5325, 0x854B, 0x5326, 0xD8D0,\t0x5327, 0x854C, 0x5328, 0x854D, 0x5329, 0x854E, 0x532A, 0xB7CB,\r\n\t0x532B, 0x854F, 0x532C, 0x8550, 0x532D, 0x8551, 0x532E, 0xD8D1,\t0x532F, 0x8552, 0x5330, 0x8553, 0x5331, 0x8554, 0x5332, 0x8555,\r\n\t0x5333, 0x8556, 0x5334, 0x8557, 0x5335, 0x8558, 0x5336, 0x8559,\t0x5337, 0x855A, 0x5338, 0x855B, 0x5339, 0xC6A5, 0x533A, 0xC7F8,\r\n\t0x533B, 0xD2BD, 0x533C, 0x855C, 0x533D, 0x855D, 0x533E, 0xD8D2,\t0x533F, 0xC4E4, 0x5340, 0x855E, 0x5341, 0xCAAE, 0x5342, 0x855F,\r\n\t0x5343, 0xC7A7, 0x5344, 0x8560, 0x5345, 0xD8A6, 0x5346, 0x8561,\t0x5347, 0xC9FD, 0x5348, 0xCEE7, 0x5349, 0xBBDC, 0x534A, 0xB0EB,\r\n\t0x534B, 0x8562, 0x534C, 0x8563, 0x534D, 0x8564, 0x534E, 0xBBAA,\t0x534F, 0xD0AD, 0x5350, 0x8565, 0x5351, 0xB1B0, 0x5352, 0xD7E4,\r\n\t0x5353, 0xD7BF, 0x5354, 0x8566, 0x5355, 0xB5A5, 0x5356, 0xC2F4,\t0x5357, 0xC4CF, 0x5358, 0x8567, 0x5359, 0x8568, 0x535A, 0xB2A9,\r\n\t0x535B, 0x8569, 0x535C, 0xB2B7, 0x535D, 0x856A, 0x535E, 0xB1E5,\t0x535F, 0xDFB2, 0x5360, 0xD5BC, 0x5361, 0xBFA8, 0x5362, 0xC2AC,\r\n\t0x5363, 0xD8D5, 0x5364, 0xC2B1, 0x5365, 0x856B, 0x5366, 0xD8D4,\t0x5367, 0xCED4, 0x5368, 0x856C, 0x5369, 0xDAE0, 0x536A, 0x856D,\r\n\t0x536B, 0xCEC0, 0x536C, 0x856E, 0x536D, 0x856F, 0x536E, 0xD8B4,\t0x536F, 0xC3AE, 0x5370, 0xD3A1, 0x5371, 0xCEA3, 0x5372, 0x8570,\r\n\t0x5373, 0xBCB4, 0x5374, 0xC8B4, 0x5375, 0xC2D1, 0x5376, 0x8571,\t0x5377, 0xBEED, 0x5378, 0xD0B6, 0x5379, 0x8572, 0x537A, 0xDAE1,\r\n\t0x537B, 0x8573, 0x537C, 0x8574, 0x537D, 0x8575, 0x537E, 0x8576,\t0x537F, 0xC7E4, 0x5380, 0x8577, 0x5381, 0x8578, 0x5382, 0xB3A7,\r\n\t0x5383, 0x8579, 0x5384, 0xB6F2, 0x5385, 0xCCFC, 0x5386, 0xC0FA,\t0x5387, 0x857A, 0x5388, 0x857B, 0x5389, 0xC0F7, 0x538A, 0x857C,\r\n\t0x538B, 0xD1B9, 0x538C, 0xD1E1, 0x538D, 0xD8C7, 0x538E, 0x857D,\t0x538F, 0x857E, 0x5390, 0x8580, 0x5391, 0x8581, 0x5392, 0x8582,\r\n\t0x5393, 0x8583, 0x5394, 0x8584, 0x5395, 0xB2DE, 0x5396, 0x8585,\t0x5397, 0x8586, 0x5398, 0xC0E5, 0x5399, 0x8587, 0x539A, 0xBAF1,\r\n\t0x539B, 0x8588, 0x539C, 0x8589, 0x539D, 0xD8C8, 0x539E, 0x858A,\t0x539F, 0xD4AD, 0x53A0, 0x858B, 0x53A1, 0x858C, 0x53A2, 0xCFE1,\r\n\t0x53A3, 0xD8C9, 0x53A4, 0x858D, 0x53A5, 0xD8CA, 0x53A6, 0xCFC3,\t0x53A7, 0x858E, 0x53A8, 0xB3F8, 0x53A9, 0xBEC7, 0x53AA, 0x858F,\r\n\t0x53AB, 0x8590, 0x53AC, 0x8591, 0x53AD, 0x8592, 0x53AE, 0xD8CB,\t0x53AF, 0x8593, 0x53B0, 0x8594, 0x53B1, 0x8595, 0x53B2, 0x8596,\r\n\t0x53B3, 0x8597, 0x53B4, 0x8598, 0x53B5, 0x8599, 0x53B6, 0xDBCC,\t0x53B7, 0x859A, 0x53B8, 0x859B, 0x53B9, 0x859C, 0x53BA, 0x859D,\r\n\t0x53BB, 0xC8A5, 0x53BC, 0x859E, 0x53BD, 0x859F, 0x53BE, 0x85A0,\t0x53BF, 0xCFD8, 0x53C0, 0x85A1, 0x53C1, 0xC8FE, 0x53C2, 0xB2CE,\r\n\t0x53C3, 0x85A2, 0x53C4, 0x85A3, 0x53C5, 0x85A4, 0x53C6, 0x85A5,\t0x53C7, 0x85A6, 0x53C8, 0xD3D6, 0x53C9, 0xB2E6, 0x53CA, 0xBCB0,\r\n\t0x53CB, 0xD3D1, 0x53CC, 0xCBAB, 0x53CD, 0xB7B4, 0x53CE, 0x85A7,\t0x53CF, 0x85A8, 0x53D0, 0x85A9, 0x53D1, 0xB7A2, 0x53D2, 0x85AA,\r\n\t0x53D3, 0x85AB, 0x53D4, 0xCAE5, 0x53D5, 0x85AC, 0x53D6, 0xC8A1,\t0x53D7, 0xCADC, 0x53D8, 0xB1E4, 0x53D9, 0xD0F0, 0x53DA, 0x85AD,\r\n\t0x53DB, 0xC5D1, 0x53DC, 0x85AE, 0x53DD, 0x85AF, 0x53DE, 0x85B0,\t0x53DF, 0xDBC5, 0x53E0, 0xB5FE, 0x53E1, 0x85B1, 0x53E2, 0x85B2,\r\n\t0x53E3, 0xBFDA, 0x53E4, 0xB9C5, 0x53E5, 0xBEE4, 0x53E6, 0xC1ED,\t0x53E7, 0x85B3, 0x53E8, 0xDFB6, 0x53E9, 0xDFB5, 0x53EA, 0xD6BB,\r\n\t0x53EB, 0xBDD0, 0x53EC, 0xD5D9, 0x53ED, 0xB0C8, 0x53EE, 0xB6A3,\t0x53EF, 0xBFC9, 0x53F0, 0xCCA8, 0x53F1, 0xDFB3, 0x53F2, 0xCAB7,\r\n\t0x53F3, 0xD3D2, 0x53F4, 0x85B4, 0x53F5, 0xD8CF, 0x53F6, 0xD2B6,\t0x53F7, 0xBAC5, 0x53F8, 0xCBBE, 0x53F9, 0xCCBE, 0x53FA, 0x85B5,\r\n\t0x53FB, 0xDFB7, 0x53FC, 0xB5F0, 0x53FD, 0xDFB4, 0x53FE, 0x85B6,\t0x53FF, 0x85B7, 0x5400, 0x85B8, 0x5401, 0xD3F5, 0x5402, 0x85B9,\r\n\t0x5403, 0xB3D4, 0x5404, 0xB8F7, 0x5405, 0x85BA, 0x5406, 0xDFBA,\t0x5407, 0x85BB, 0x5408, 0xBACF, 0x5409, 0xBCAA, 0x540A, 0xB5F5,\r\n\t0x540B, 0x85BC, 0x540C, 0xCDAC, 0x540D, 0xC3FB, 0x540E, 0xBAF3,\t0x540F, 0xC0F4, 0x5410, 0xCDC2, 0x5411, 0xCFF2, 0x5412, 0xDFB8,\r\n\t0x5413, 0xCFC5, 0x5414, 0x85BD, 0x5415, 0xC2C0, 0x5416, 0xDFB9,\t0x5417, 0xC2F0, 0x5418, 0x85BE, 0x5419, 0x85BF, 0x541A, 0x85C0,\r\n\t0x541B, 0xBEFD, 0x541C, 0x85C1, 0x541D, 0xC1DF, 0x541E, 0xCDCC,\t0x541F, 0xD2F7, 0x5420, 0xB7CD, 0x5421, 0xDFC1, 0x5422, 0x85C2,\r\n\t0x5423, 0xDFC4, 0x5424, 0x85C3, 0x5425, 0x85C4, 0x5426, 0xB7F1,\t0x5427, 0xB0C9, 0x5428, 0xB6D6, 0x5429, 0xB7D4, 0x542A, 0x85C5,\r\n\t0x542B, 0xBAAC, 0x542C, 0xCCFD, 0x542D, 0xBFD4, 0x542E, 0xCBB1,\t0x542F, 0xC6F4, 0x5430, 0x85C6, 0x5431, 0xD6A8, 0x5432, 0xDFC5,\r\n\t0x5433, 0x85C7, 0x5434, 0xCEE2, 0x5435, 0xB3B3, 0x5436, 0x85C8,\t0x5437, 0x85C9, 0x5438, 0xCEFC, 0x5439, 0xB4B5, 0x543A, 0x85CA,\r\n\t0x543B, 0xCEC7, 0x543C, 0xBAF0, 0x543D, 0x85CB, 0x543E, 0xCEE1,\t0x543F, 0x85CC, 0x5440, 0xD1BD, 0x5441, 0x85CD, 0x5442, 0x85CE,\r\n\t0x5443, 0xDFC0, 0x5444, 0x85CF, 0x5445, 0x85D0, 0x5446, 0xB4F4,\t0x5447, 0x85D1, 0x5448, 0xB3CA, 0x5449, 0x85D2, 0x544A, 0xB8E6,\r\n\t0x544B, 0xDFBB, 0x544C, 0x85D3, 0x544D, 0x85D4, 0x544E, 0x85D5,\t0x544F, 0x85D6, 0x5450, 0xC4C5, 0x5451, 0x85D7, 0x5452, 0xDFBC,\r\n\t0x5453, 0xDFBD, 0x5454, 0xDFBE, 0x5455, 0xC5BB, 0x5456, 0xDFBF,\t0x5457, 0xDFC2, 0x5458, 0xD4B1, 0x5459, 0xDFC3, 0x545A, 0x85D8,\r\n\t0x545B, 0xC7BA, 0x545C, 0xCED8, 0x545D, 0x85D9, 0x545E, 0x85DA,\t0x545F, 0x85DB, 0x5460, 0x85DC, 0x5461, 0x85DD, 0x5462, 0xC4D8,\r\n\t0x5463, 0x85DE, 0x5464, 0xDFCA, 0x5465, 0x85DF, 0x5466, 0xDFCF,\t0x5467, 0x85E0, 0x5468, 0xD6DC, 0x5469, 0x85E1, 0x546A, 0x85E2,\r\n\t0x546B, 0x85E3, 0x546C, 0x85E4, 0x546D, 0x85E5, 0x546E, 0x85E6,\t0x546F, 0x85E7, 0x5470, 0x85E8, 0x5471, 0xDFC9, 0x5472, 0xDFDA,\r\n\t0x5473, 0xCEB6, 0x5474, 0x85E9, 0x5475, 0xBAC7, 0x5476, 0xDFCE,\t0x5477, 0xDFC8, 0x5478, 0xC5DE, 0x5479, 0x85EA, 0x547A, 0x85EB,\r\n\t0x547B, 0xC9EB, 0x547C, 0xBAF4, 0x547D, 0xC3FC, 0x547E, 0x85EC,\t0x547F, 0x85ED, 0x5480, 0xBED7, 0x5481, 0x85EE, 0x5482, 0xDFC6,\r\n\t0x5483, 0x85EF, 0x5484, 0xDFCD, 0x5485, 0x85F0, 0x5486, 0xC5D8,\t0x5487, 0x85F1, 0x5488, 0x85F2, 0x5489, 0x85F3, 0x548A, 0x85F4,\r\n\t0x548B, 0xD5A6, 0x548C, 0xBACD, 0x548D, 0x85F5, 0x548E, 0xBECC,\t0x548F, 0xD3BD, 0x5490, 0xB8C0, 0x5491, 0x85F6, 0x5492, 0xD6E4,\r\n\t0x5493, 0x85F7, 0x5494, 0xDFC7, 0x5495, 0xB9BE, 0x5496, 0xBFA7,\t0x5497, 0x85F8, 0x5498, 0x85F9, 0x5499, 0xC1FC, 0x549A, 0xDFCB,\r\n\t0x549B, 0xDFCC, 0x549C, 0x85FA, 0x549D, 0xDFD0, 0x549E, 0x85FB,\t0x549F, 0x85FC, 0x54A0, 0x85FD, 0x54A1, 0x85FE, 0x54A2, 0x8640,\r\n\t0x54A3, 0xDFDB, 0x54A4, 0xDFE5, 0x54A5, 0x8641, 0x54A6, 0xDFD7,\t0x54A7, 0xDFD6, 0x54A8, 0xD7C9, 0x54A9, 0xDFE3, 0x54AA, 0xDFE4,\r\n\t0x54AB, 0xE5EB, 0x54AC, 0xD2A7, 0x54AD, 0xDFD2, 0x54AE, 0x8642,\t0x54AF, 0xBFA9, 0x54B0, 0x8643, 0x54B1, 0xD4DB, 0x54B2, 0x8644,\r\n\t0x54B3, 0xBFC8, 0x54B4, 0xDFD4, 0x54B5, 0x8645, 0x54B6, 0x8646,\t0x54B7, 0x8647, 0x54B8, 0xCFCC, 0x54B9, 0x8648, 0x54BA, 0x8649,\r\n\t0x54BB, 0xDFDD, 0x54BC, 0x864A, 0x54BD, 0xD1CA, 0x54BE, 0x864B,\t0x54BF, 0xDFDE, 0x54C0, 0xB0A7, 0x54C1, 0xC6B7, 0x54C2, 0xDFD3,\r\n\t0x54C3, 0x864C, 0x54C4, 0xBAE5, 0x54C5, 0x864D, 0x54C6, 0xB6DF,\t0x54C7, 0xCDDB, 0x54C8, 0xB9FE, 0x54C9, 0xD4D5, 0x54CA, 0x864E,\r\n\t0x54CB, 0x864F, 0x54CC, 0xDFDF, 0x54CD, 0xCFEC, 0x54CE, 0xB0A5,\t0x54CF, 0xDFE7, 0x54D0, 0xDFD1, 0x54D1, 0xD1C6, 0x54D2, 0xDFD5,\r\n\t0x54D3, 0xDFD8, 0x54D4, 0xDFD9, 0x54D5, 0xDFDC, 0x54D6, 0x8650,\t0x54D7, 0xBBA9, 0x54D8, 0x8651, 0x54D9, 0xDFE0, 0x54DA, 0xDFE1,\r\n\t0x54DB, 0x8652, 0x54DC, 0xDFE2, 0x54DD, 0xDFE6, 0x54DE, 0xDFE8,\t0x54DF, 0xD3B4, 0x54E0, 0x8653, 0x54E1, 0x8654, 0x54E2, 0x8655,\r\n\t0x54E3, 0x8656, 0x54E4, 0x8657, 0x54E5, 0xB8E7, 0x54E6, 0xC5B6,\t0x54E7, 0xDFEA, 0x54E8, 0xC9DA, 0x54E9, 0xC1A8, 0x54EA, 0xC4C4,\r\n\t0x54EB, 0x8658, 0x54EC, 0x8659, 0x54ED, 0xBFDE, 0x54EE, 0xCFF8,\t0x54EF, 0x865A, 0x54F0, 0x865B, 0x54F1, 0x865C, 0x54F2, 0xD5DC,\r\n\t0x54F3, 0xDFEE, 0x54F4, 0x865D, 0x54F5, 0x865E, 0x54F6, 0x865F,\t0x54F7, 0x8660, 0x54F8, 0x8661, 0x54F9, 0x8662, 0x54FA, 0xB2B8,\r\n\t0x54FB, 0x8663, 0x54FC, 0xBADF, 0x54FD, 0xDFEC, 0x54FE, 0x8664,\t0x54FF, 0xDBC1, 0x5500, 0x8665, 0x5501, 0xD1E4, 0x5502, 0x8666,\r\n\t0x5503, 0x8667, 0x5504, 0x8668, 0x5505, 0x8669, 0x5506, 0xCBF4,\t0x5507, 0xB4BD, 0x5508, 0x866A, 0x5509, 0xB0A6, 0x550A, 0x866B,\r\n\t0x550B, 0x866C, 0x550C, 0x866D, 0x550D, 0x866E, 0x550E, 0x866F,\t0x550F, 0xDFF1, 0x5510, 0xCCC6, 0x5511, 0xDFF2, 0x5512, 0x8670,\r\n\t0x5513, 0x8671, 0x5514, 0xDFED, 0x5515, 0x8672, 0x5516, 0x8673,\t0x5517, 0x8674, 0x5518, 0x8675, 0x5519, 0x8676, 0x551A, 0x8677,\r\n\t0x551B, 0xDFE9, 0x551C, 0x8678, 0x551D, 0x8679, 0x551E, 0x867A,\t0x551F, 0x867B, 0x5520, 0xDFEB, 0x5521, 0x867C, 0x5522, 0xDFEF,\r\n\t0x5523, 0xDFF0, 0x5524, 0xBBBD, 0x5525, 0x867D, 0x5526, 0x867E,\t0x5527, 0xDFF3, 0x5528, 0x8680, 0x5529, 0x8681, 0x552A, 0xDFF4,\r\n\t0x552B, 0x8682, 0x552C, 0xBBA3, 0x552D, 0x8683, 0x552E, 0xCADB,\t0x552F, 0xCEA8, 0x5530, 0xE0A7, 0x5531, 0xB3AA, 0x5532, 0x8684,\r\n\t0x5533, 0xE0A6, 0x5534, 0x8685, 0x5535, 0x8686, 0x5536, 0x8687,\t0x5537, 0xE0A1, 0x5538, 0x8688, 0x5539, 0x8689, 0x553A, 0x868A,\r\n\t0x553B, 0x868B, 0x553C, 0xDFFE, 0x553D, 0x868C, 0x553E, 0xCDD9,\t0x553F, 0xDFFC, 0x5540, 0x868D, 0x5541, 0xDFFA, 0x5542, 0x868E,\r\n\t0x5543, 0xBFD0, 0x5544, 0xD7C4, 0x5545, 0x868F, 0x5546, 0xC9CC,\t0x5547, 0x8690, 0x5548, 0x8691, 0x5549, 0xDFF8, 0x554A, 0xB0A1,\r\n\t0x554B, 0x8692, 0x554C, 0x8693, 0x554D, 0x8694, 0x554E, 0x8695,\t0x554F, 0x8696, 0x5550, 0xDFFD, 0x5551, 0x8697, 0x5552, 0x8698,\r\n\t0x5553, 0x8699, 0x5554, 0x869A, 0x5555, 0xDFFB, 0x5556, 0xE0A2,\t0x5557, 0x869B, 0x5558, 0x869C, 0x5559, 0x869D, 0x555A, 0x869E,\r\n\t0x555B, 0x869F, 0x555C, 0xE0A8, 0x555D, 0x86A0, 0x555E, 0x86A1,\t0x555F, 0x86A2, 0x5560, 0x86A3, 0x5561, 0xB7C8, 0x5562, 0x86A4,\r\n\t0x5563, 0x86A5, 0x5564, 0xC6A1, 0x5565, 0xC9B6, 0x5566, 0xC0B2,\t0x5567, 0xDFF5, 0x5568, 0x86A6, 0x5569, 0x86A7, 0x556A, 0xC5BE,\r\n\t0x556B, 0x86A8, 0x556C, 0xD8C4, 0x556D, 0xDFF9, 0x556E, 0xC4F6,\t0x556F, 0x86A9, 0x5570, 0x86AA, 0x5571, 0x86AB, 0x5572, 0x86AC,\r\n\t0x5573, 0x86AD, 0x5574, 0x86AE, 0x5575, 0xE0A3, 0x5576, 0xE0A4,\t0x5577, 0xE0A5, 0x5578, 0xD0A5, 0x5579, 0x86AF, 0x557A, 0x86B0,\r\n\t0x557B, 0xE0B4, 0x557C, 0xCCE4, 0x557D, 0x86B1, 0x557E, 0xE0B1,\t0x557F, 0x86B2, 0x5580, 0xBFA6, 0x5581, 0xE0AF, 0x5582, 0xCEB9,\r\n\t0x5583, 0xE0AB, 0x5584, 0xC9C6, 0x5585, 0x86B3, 0x5586, 0x86B4,\t0x5587, 0xC0AE, 0x5588, 0xE0AE, 0x5589, 0xBAED, 0x558A, 0xBAB0,\r\n\t0x558B, 0xE0A9, 0x558C, 0x86B5, 0x558D, 0x86B6, 0x558E, 0x86B7,\t0x558F, 0xDFF6, 0x5590, 0x86B8, 0x5591, 0xE0B3, 0x5592, 0x86B9,\r\n\t0x5593, 0x86BA, 0x5594, 0xE0B8, 0x5595, 0x86BB, 0x5596, 0x86BC,\t0x5597, 0x86BD, 0x5598, 0xB4AD, 0x5599, 0xE0B9, 0x559A, 0x86BE,\r\n\t0x559B, 0x86BF, 0x559C, 0xCFB2, 0x559D, 0xBAC8, 0x559E, 0x86C0,\t0x559F, 0xE0B0, 0x55A0, 0x86C1, 0x55A1, 0x86C2, 0x55A2, 0x86C3,\r\n\t0x55A3, 0x86C4, 0x55A4, 0x86C5, 0x55A5, 0x86C6, 0x55A6, 0x86C7,\t0x55A7, 0xD0FA, 0x55A8, 0x86C8, 0x55A9, 0x86C9, 0x55AA, 0x86CA,\r\n\t0x55AB, 0x86CB, 0x55AC, 0x86CC, 0x55AD, 0x86CD, 0x55AE, 0x86CE,\t0x55AF, 0x86CF, 0x55B0, 0x86D0, 0x55B1, 0xE0AC, 0x55B2, 0x86D1,\r\n\t0x55B3, 0xD4FB, 0x55B4, 0x86D2, 0x55B5, 0xDFF7, 0x55B6, 0x86D3,\t0x55B7, 0xC5E7, 0x55B8, 0x86D4, 0x55B9, 0xE0AD, 0x55BA, 0x86D5,\r\n\t0x55BB, 0xD3F7, 0x55BC, 0x86D6, 0x55BD, 0xE0B6, 0x55BE, 0xE0B7,\t0x55BF, 0x86D7, 0x55C0, 0x86D8, 0x55C1, 0x86D9, 0x55C2, 0x86DA,\r\n\t0x55C3, 0x86DB, 0x55C4, 0xE0C4, 0x55C5, 0xD0E1, 0x55C6, 0x86DC,\t0x55C7, 0x86DD, 0x55C8, 0x86DE, 0x55C9, 0xE0BC, 0x55CA, 0x86DF,\r\n\t0x55CB, 0x86E0, 0x55CC, 0xE0C9, 0x55CD, 0xE0CA, 0x55CE, 0x86E1,\t0x55CF, 0x86E2, 0x55D0, 0x86E3, 0x55D1, 0xE0BE, 0x55D2, 0xE0AA,\r\n\t0x55D3, 0xC9A4, 0x55D4, 0xE0C1, 0x55D5, 0x86E4, 0x55D6, 0xE0B2,\t0x55D7, 0x86E5, 0x55D8, 0x86E6, 0x55D9, 0x86E7, 0x55DA, 0x86E8,\r\n\t0x55DB, 0x86E9, 0x55DC, 0xCAC8, 0x55DD, 0xE0C3, 0x55DE, 0x86EA,\t0x55DF, 0xE0B5, 0x55E0, 0x86EB, 0x55E1, 0xCECB, 0x55E2, 0x86EC,\r\n\t0x55E3, 0xCBC3, 0x55E4, 0xE0CD, 0x55E5, 0xE0C6, 0x55E6, 0xE0C2,\t0x55E7, 0x86ED, 0x55E8, 0xE0CB, 0x55E9, 0x86EE, 0x55EA, 0xE0BA,\r\n\t0x55EB, 0xE0BF, 0x55EC, 0xE0C0, 0x55ED, 0x86EF, 0x55EE, 0x86F0,\t0x55EF, 0xE0C5, 0x55F0, 0x86F1, 0x55F1, 0x86F2, 0x55F2, 0xE0C7,\r\n\t0x55F3, 0xE0C8, 0x55F4, 0x86F3, 0x55F5, 0xE0CC, 0x55F6, 0x86F4,\t0x55F7, 0xE0BB, 0x55F8, 0x86F5, 0x55F9, 0x86F6, 0x55FA, 0x86F7,\r\n\t0x55FB, 0x86F8, 0x55FC, 0x86F9, 0x55FD, 0xCBD4, 0x55FE, 0xE0D5,\t0x55FF, 0x86FA, 0x5600, 0xE0D6, 0x5601, 0xE0D2, 0x5602, 0x86FB,\r\n\t0x5603, 0x86FC, 0x5604, 0x86FD, 0x5605, 0x86FE, 0x5606, 0x8740,\t0x5607, 0x8741, 0x5608, 0xE0D0, 0x5609, 0xBCCE, 0x560A, 0x8742,\r\n\t0x560B, 0x8743, 0x560C, 0xE0D1, 0x560D, 0x8744, 0x560E, 0xB8C2,\t0x560F, 0xD8C5, 0x5610, 0x8745, 0x5611, 0x8746, 0x5612, 0x8747,\r\n\t0x5613, 0x8748, 0x5614, 0x8749, 0x5615, 0x874A, 0x5616, 0x874B,\t0x5617, 0x874C, 0x5618, 0xD0EA, 0x5619, 0x874D, 0x561A, 0x874E,\r\n\t0x561B, 0xC2EF, 0x561C, 0x874F, 0x561D, 0x8750, 0x561E, 0xE0CF,\t0x561F, 0xE0BD, 0x5620, 0x8751, 0x5621, 0x8752, 0x5622, 0x8753,\r\n\t0x5623, 0xE0D4, 0x5624, 0xE0D3, 0x5625, 0x8754, 0x5626, 0x8755,\t0x5627, 0xE0D7, 0x5628, 0x8756, 0x5629, 0x8757, 0x562A, 0x8758,\r\n\t0x562B, 0x8759, 0x562C, 0xE0DC, 0x562D, 0xE0D8, 0x562E, 0x875A,\t0x562F, 0x875B, 0x5630, 0x875C, 0x5631, 0xD6F6, 0x5632, 0xB3B0,\r\n\t0x5633, 0x875D, 0x5634, 0xD7EC, 0x5635, 0x875E, 0x5636, 0xCBBB,\t0x5637, 0x875F, 0x5638, 0x8760, 0x5639, 0xE0DA, 0x563A, 0x8761,\r\n\t0x563B, 0xCEFB, 0x563C, 0x8762, 0x563D, 0x8763, 0x563E, 0x8764,\t0x563F, 0xBAD9, 0x5640, 0x8765, 0x5641, 0x8766, 0x5642, 0x8767,\r\n\t0x5643, 0x8768, 0x5644, 0x8769, 0x5645, 0x876A, 0x5646, 0x876B,\t0x5647, 0x876C, 0x5648, 0x876D, 0x5649, 0x876E, 0x564A, 0x876F,\r\n\t0x564B, 0x8770, 0x564C, 0xE0E1, 0x564D, 0xE0DD, 0x564E, 0xD2AD,\t0x564F, 0x8771, 0x5650, 0x8772, 0x5651, 0x8773, 0x5652, 0x8774,\r\n\t0x5653, 0x8775, 0x5654, 0xE0E2, 0x5655, 0x8776, 0x5656, 0x8777,\t0x5657, 0xE0DB, 0x5658, 0xE0D9, 0x5659, 0xE0DF, 0x565A, 0x8778,\r\n\t0x565B, 0x8779, 0x565C, 0xE0E0, 0x565D, 0x877A, 0x565E, 0x877B,\t0x565F, 0x877C, 0x5660, 0x877D, 0x5661, 0x877E, 0x5662, 0xE0DE,\r\n\t0x5663, 0x8780, 0x5664, 0xE0E4, 0x5665, 0x8781, 0x5666, 0x8782,\t0x5667, 0x8783, 0x5668, 0xC6F7, 0x5669, 0xD8AC, 0x566A, 0xD4EB,\r\n\t0x566B, 0xE0E6, 0x566C, 0xCAC9, 0x566D, 0x8784, 0x566E, 0x8785,\t0x566F, 0x8786, 0x5670, 0x8787, 0x5671, 0xE0E5, 0x5672, 0x8788,\r\n\t0x5673, 0x8789, 0x5674, 0x878A, 0x5675, 0x878B, 0x5676, 0xB8C1,\t0x5677, 0x878C, 0x5678, 0x878D, 0x5679, 0x878E, 0x567A, 0x878F,\r\n\t0x567B, 0xE0E7, 0x567C, 0xE0E8, 0x567D, 0x8790, 0x567E, 0x8791,\t0x567F, 0x8792, 0x5680, 0x8793, 0x5681, 0x8794, 0x5682, 0x8795,\r\n\t0x5683, 0x8796, 0x5684, 0x8797, 0x5685, 0xE0E9, 0x5686, 0xE0E3,\t0x5687, 0x8798, 0x5688, 0x8799, 0x5689, 0x879A, 0x568A, 0x879B,\r\n\t0x568B, 0x879C, 0x568C, 0x879D, 0x568D, 0x879E, 0x568E, 0xBABF,\t0x568F, 0xCCE7, 0x5690, 0x879F, 0x5691, 0x87A0, 0x5692, 0x87A1,\r\n\t0x5693, 0xE0EA, 0x5694, 0x87A2, 0x5695, 0x87A3, 0x5696, 0x87A4,\t0x5697, 0x87A5, 0x5698, 0x87A6, 0x5699, 0x87A7, 0x569A, 0x87A8,\r\n\t0x569B, 0x87A9, 0x569C, 0x87AA, 0x569D, 0x87AB, 0x569E, 0x87AC,\t0x569F, 0x87AD, 0x56A0, 0x87AE, 0x56A1, 0x87AF, 0x56A2, 0x87B0,\r\n\t0x56A3, 0xCFF9, 0x56A4, 0x87B1, 0x56A5, 0x87B2, 0x56A6, 0x87B3,\t0x56A7, 0x87B4, 0x56A8, 0x87B5, 0x56A9, 0x87B6, 0x56AA, 0x87B7,\r\n\t0x56AB, 0x87B8, 0x56AC, 0x87B9, 0x56AD, 0x87BA, 0x56AE, 0x87BB,\t0x56AF, 0xE0EB, 0x56B0, 0x87BC, 0x56B1, 0x87BD, 0x56B2, 0x87BE,\r\n\t0x56B3, 0x87BF, 0x56B4, 0x87C0, 0x56B5, 0x87C1, 0x56B6, 0x87C2,\t0x56B7, 0xC8C2, 0x56B8, 0x87C3, 0x56B9, 0x87C4, 0x56BA, 0x87C5,\r\n\t0x56BB, 0x87C6, 0x56BC, 0xBDC0, 0x56BD, 0x87C7, 0x56BE, 0x87C8,\t0x56BF, 0x87C9, 0x56C0, 0x87CA, 0x56C1, 0x87CB, 0x56C2, 0x87CC,\r\n\t0x56C3, 0x87CD, 0x56C4, 0x87CE, 0x56C5, 0x87CF, 0x56C6, 0x87D0,\t0x56C7, 0x87D1, 0x56C8, 0x87D2, 0x56C9, 0x87D3, 0x56CA, 0xC4D2,\r\n\t0x56CB, 0x87D4, 0x56CC, 0x87D5, 0x56CD, 0x87D6, 0x56CE, 0x87D7,\t0x56CF, 0x87D8, 0x56D0, 0x87D9, 0x56D1, 0x87DA, 0x56D2, 0x87DB,\r\n\t0x56D3, 0x87DC, 0x56D4, 0xE0EC, 0x56D5, 0x87DD, 0x56D6, 0x87DE,\t0x56D7, 0xE0ED, 0x56D8, 0x87DF, 0x56D9, 0x87E0, 0x56DA, 0xC7F4,\r\n\t0x56DB, 0xCBC4, 0x56DC, 0x87E1, 0x56DD, 0xE0EE, 0x56DE, 0xBBD8,\t0x56DF, 0xD8B6, 0x56E0, 0xD2F2, 0x56E1, 0xE0EF, 0x56E2, 0xCDC5,\r\n\t0x56E3, 0x87E2, 0x56E4, 0xB6DA, 0x56E5, 0x87E3, 0x56E6, 0x87E4,\t0x56E7, 0x87E5, 0x56E8, 0x87E6, 0x56E9, 0x87E7, 0x56EA, 0x87E8,\r\n\t0x56EB, 0xE0F1, 0x56EC, 0x87E9, 0x56ED, 0xD4B0, 0x56EE, 0x87EA,\t0x56EF, 0x87EB, 0x56F0, 0xC0A7, 0x56F1, 0xB4D1, 0x56F2, 0x87EC,\r\n\t0x56F3, 0x87ED, 0x56F4, 0xCEA7, 0x56F5, 0xE0F0, 0x56F6, 0x87EE,\t0x56F7, 0x87EF, 0x56F8, 0x87F0, 0x56F9, 0xE0F2, 0x56FA, 0xB9CC,\r\n\t0x56FB, 0x87F1, 0x56FC, 0x87F2, 0x56FD, 0xB9FA, 0x56FE, 0xCDBC,\t0x56FF, 0xE0F3, 0x5700, 0x87F3, 0x5701, 0x87F4, 0x5702, 0x87F5,\r\n\t0x5703, 0xC6D4, 0x5704, 0xE0F4, 0x5705, 0x87F6, 0x5706, 0xD4B2,\t0x5707, 0x87F7, 0x5708, 0xC8A6, 0x5709, 0xE0F6, 0x570A, 0xE0F5,\r\n\t0x570B, 0x87F8, 0x570C, 0x87F9, 0x570D, 0x87FA, 0x570E, 0x87FB,\t0x570F, 0x87FC, 0x5710, 0x87FD, 0x5711, 0x87FE, 0x5712, 0x8840,\r\n\t0x5713, 0x8841, 0x5714, 0x8842, 0x5715, 0x8843, 0x5716, 0x8844,\t0x5717, 0x8845, 0x5718, 0x8846, 0x5719, 0x8847, 0x571A, 0x8848,\r\n\t0x571B, 0x8849, 0x571C, 0xE0F7, 0x571D, 0x884A, 0x571E, 0x884B,\t0x571F, 0xCDC1, 0x5720, 0x884C, 0x5721, 0x884D, 0x5722, 0x884E,\r\n\t0x5723, 0xCAA5, 0x5724, 0x884F, 0x5725, 0x8850, 0x5726, 0x8851,\t0x5727, 0x8852, 0x5728, 0xD4DA, 0x5729, 0xDBD7, 0x572A, 0xDBD9,\r\n\t0x572B, 0x8853, 0x572C, 0xDBD8, 0x572D, 0xB9E7, 0x572E, 0xDBDC,\t0x572F, 0xDBDD, 0x5730, 0xB5D8, 0x5731, 0x8854, 0x5732, 0x8855,\r\n\t0x5733, 0xDBDA, 0x5734, 0x8856, 0x5735, 0x8857, 0x5736, 0x8858,\t0x5737, 0x8859, 0x5738, 0x885A, 0x5739, 0xDBDB, 0x573A, 0xB3A1,\r\n\t0x573B, 0xDBDF, 0x573C, 0x885B, 0x573D, 0x885C, 0x573E, 0xBBF8,\t0x573F, 0x885D, 0x5740, 0xD6B7, 0x5741, 0x885E, 0x5742, 0xDBE0,\r\n\t0x5743, 0x885F, 0x5744, 0x8860, 0x5745, 0x8861, 0x5746, 0x8862,\t0x5747, 0xBEF9, 0x5748, 0x8863, 0x5749, 0x8864, 0x574A, 0xB7BB,\r\n\t0x574B, 0x8865, 0x574C, 0xDBD0, 0x574D, 0xCCAE, 0x574E, 0xBFB2,\t0x574F, 0xBBB5, 0x5750, 0xD7F8, 0x5751, 0xBFD3, 0x5752, 0x8866,\r\n\t0x5753, 0x8867, 0x5754, 0x8868, 0x5755, 0x8869, 0x5756, 0x886A,\t0x5757, 0xBFE9, 0x5758, 0x886B, 0x5759, 0x886C, 0x575A, 0xBCE1,\r\n\t0x575B, 0xCCB3, 0x575C, 0xDBDE, 0x575D, 0xB0D3, 0x575E, 0xCEEB,\t0x575F, 0xB7D8, 0x5760, 0xD7B9, 0x5761, 0xC6C2, 0x5762, 0x886D,\r\n\t0x5763, 0x886E, 0x5764, 0xC0A4, 0x5765, 0x886F, 0x5766, 0xCCB9,\t0x5767, 0x8870, 0x5768, 0xDBE7, 0x5769, 0xDBE1, 0x576A, 0xC6BA,\r\n\t0x576B, 0xDBE3, 0x576C, 0x8871, 0x576D, 0xDBE8, 0x576E, 0x8872,\t0x576F, 0xC5F7, 0x5770, 0x8873, 0x5771, 0x8874, 0x5772, 0x8875,\r\n\t0x5773, 0xDBEA, 0x5774, 0x8876, 0x5775, 0x8877, 0x5776, 0xDBE9,\t0x5777, 0xBFC0, 0x5778, 0x8878, 0x5779, 0x8879, 0x577A, 0x887A,\r\n\t0x577B, 0xDBE6, 0x577C, 0xDBE5, 0x577D, 0x887B, 0x577E, 0x887C,\t0x577F, 0x887D, 0x5780, 0x887E, 0x5781, 0x8880, 0x5782, 0xB4B9,\r\n\t0x5783, 0xC0AC, 0x5784, 0xC2A2, 0x5785, 0xDBE2, 0x5786, 0xDBE4,\t0x5787, 0x8881, 0x5788, 0x8882, 0x5789, 0x8883, 0x578A, 0x8884,\r\n\t0x578B, 0xD0CD, 0x578C, 0xDBED, 0x578D, 0x8885, 0x578E, 0x8886,\t0x578F, 0x8887, 0x5790, 0x8888, 0x5791, 0x8889, 0x5792, 0xC0DD,\r\n\t0x5793, 0xDBF2, 0x5794, 0x888A, 0x5795, 0x888B, 0x5796, 0x888C,\t0x5797, 0x888D, 0x5798, 0x888E, 0x5799, 0x888F, 0x579A, 0x8890,\r\n\t0x579B, 0xB6E2, 0x579C, 0x8891, 0x579D, 0x8892, 0x579E, 0x8893,\t0x579F, 0x8894, 0x57A0, 0xDBF3, 0x57A1, 0xDBD2, 0x57A2, 0xB9B8,\r\n\t0x57A3, 0xD4AB, 0x57A4, 0xDBEC, 0x57A5, 0x8895, 0x57A6, 0xBFD1,\t0x57A7, 0xDBF0, 0x57A8, 0x8896, 0x57A9, 0xDBD1, 0x57AA, 0x8897,\r\n\t0x57AB, 0xB5E6, 0x57AC, 0x8898, 0x57AD, 0xDBEB, 0x57AE, 0xBFE5,\t0x57AF, 0x8899, 0x57B0, 0x889A, 0x57B1, 0x889B, 0x57B2, 0xDBEE,\r\n\t0x57B3, 0x889C, 0x57B4, 0xDBF1, 0x57B5, 0x889D, 0x57B6, 0x889E,\t0x57B7, 0x889F, 0x57B8, 0xDBF9, 0x57B9, 0x88A0, 0x57BA, 0x88A1,\r\n\t0x57BB, 0x88A2, 0x57BC, 0x88A3, 0x57BD, 0x88A4, 0x57BE, 0x88A5,\t0x57BF, 0x88A6, 0x57C0, 0x88A7, 0x57C1, 0x88A8, 0x57C2, 0xB9A1,\r\n\t0x57C3, 0xB0A3, 0x57C4, 0x88A9, 0x57C5, 0x88AA, 0x57C6, 0x88AB,\t0x57C7, 0x88AC, 0x57C8, 0x88AD, 0x57C9, 0x88AE, 0x57CA, 0x88AF,\r\n\t0x57CB, 0xC2F1, 0x57CC, 0x88B0, 0x57CD, 0x88B1, 0x57CE, 0xB3C7,\t0x57CF, 0xDBEF, 0x57D0, 0x88B2, 0x57D1, 0x88B3, 0x57D2, 0xDBF8,\r\n\t0x57D3, 0x88B4, 0x57D4, 0xC6D2, 0x57D5, 0xDBF4, 0x57D6, 0x88B5,\t0x57D7, 0x88B6, 0x57D8, 0xDBF5, 0x57D9, 0xDBF7, 0x57DA, 0xDBF6,\r\n\t0x57DB, 0x88B7, 0x57DC, 0x88B8, 0x57DD, 0xDBFE, 0x57DE, 0x88B9,\t0x57DF, 0xD3F2, 0x57E0, 0xB2BA, 0x57E1, 0x88BA, 0x57E2, 0x88BB,\r\n\t0x57E3, 0x88BC, 0x57E4, 0xDBFD, 0x57E5, 0x88BD, 0x57E6, 0x88BE,\t0x57E7, 0x88BF, 0x57E8, 0x88C0, 0x57E9, 0x88C1, 0x57EA, 0x88C2,\r\n\t0x57EB, 0x88C3, 0x57EC, 0x88C4, 0x57ED, 0xDCA4, 0x57EE, 0x88C5,\t0x57EF, 0xDBFB, 0x57F0, 0x88C6, 0x57F1, 0x88C7, 0x57F2, 0x88C8,\r\n\t0x57F3, 0x88C9, 0x57F4, 0xDBFA, 0x57F5, 0x88CA, 0x57F6, 0x88CB,\t0x57F7, 0x88CC, 0x57F8, 0xDBFC, 0x57F9, 0xC5E0, 0x57FA, 0xBBF9,\r\n\t0x57FB, 0x88CD, 0x57FC, 0x88CE, 0x57FD, 0xDCA3, 0x57FE, 0x88CF,\t0x57FF, 0x88D0, 0x5800, 0xDCA5, 0x5801, 0x88D1, 0x5802, 0xCCC3,\r\n\t0x5803, 0x88D2, 0x5804, 0x88D3, 0x5805, 0x88D4, 0x5806, 0xB6D1,\t0x5807, 0xDDC0, 0x5808, 0x88D5, 0x5809, 0x88D6, 0x580A, 0x88D7,\r\n\t0x580B, 0xDCA1, 0x580C, 0x88D8, 0x580D, 0xDCA2, 0x580E, 0x88D9,\t0x580F, 0x88DA, 0x5810, 0x88DB, 0x5811, 0xC7B5, 0x5812, 0x88DC,\r\n\t0x5813, 0x88DD, 0x5814, 0x88DE, 0x5815, 0xB6E9, 0x5816, 0x88DF,\t0x5817, 0x88E0, 0x5818, 0x88E1, 0x5819, 0xDCA7, 0x581A, 0x88E2,\r\n\t0x581B, 0x88E3, 0x581C, 0x88E4, 0x581D, 0x88E5, 0x581E, 0xDCA6,\t0x581F, 0x88E6, 0x5820, 0xDCA9, 0x5821, 0xB1A4, 0x5822, 0x88E7,\r\n\t0x5823, 0x88E8, 0x5824, 0xB5CC, 0x5825, 0x88E9, 0x5826, 0x88EA,\t0x5827, 0x88EB, 0x5828, 0x88EC, 0x5829, 0x88ED, 0x582A, 0xBFB0,\r\n\t0x582B, 0x88EE, 0x582C, 0x88EF, 0x582D, 0x88F0, 0x582E, 0x88F1,\t0x582F, 0x88F2, 0x5830, 0xD1DF, 0x5831, 0x88F3, 0x5832, 0x88F4,\r\n\t0x5833, 0x88F5, 0x5834, 0x88F6, 0x5835, 0xB6C2, 0x5836, 0x88F7,\t0x5837, 0x88F8, 0x5838, 0x88F9, 0x5839, 0x88FA, 0x583A, 0x88FB,\r\n\t0x583B, 0x88FC, 0x583C, 0x88FD, 0x583D, 0x88FE, 0x583E, 0x8940,\t0x583F, 0x8941, 0x5840, 0x8942, 0x5841, 0x8943, 0x5842, 0x8944,\r\n\t0x5843, 0x8945, 0x5844, 0xDCA8, 0x5845, 0x8946, 0x5846, 0x8947,\t0x5847, 0x8948, 0x5848, 0x8949, 0x5849, 0x894A, 0x584A, 0x894B,\r\n\t0x584B, 0x894C, 0x584C, 0xCBFA, 0x584D, 0xEBF3, 0x584E, 0x894D,\t0x584F, 0x894E, 0x5850, 0x894F, 0x5851, 0xCBDC, 0x5852, 0x8950,\r\n\t0x5853, 0x8951, 0x5854, 0xCBFE, 0x5855, 0x8952, 0x5856, 0x8953,\t0x5857, 0x8954, 0x5858, 0xCCC1, 0x5859, 0x8955, 0x585A, 0x8956,\r\n\t0x585B, 0x8957, 0x585C, 0x8958, 0x585D, 0x8959, 0x585E, 0xC8FB,\t0x585F, 0x895A, 0x5860, 0x895B, 0x5861, 0x895C, 0x5862, 0x895D,\r\n\t0x5863, 0x895E, 0x5864, 0x895F, 0x5865, 0xDCAA, 0x5866, 0x8960,\t0x5867, 0x8961, 0x5868, 0x8962, 0x5869, 0x8963, 0x586A, 0x8964,\r\n\t0x586B, 0xCCEE, 0x586C, 0xDCAB, 0x586D, 0x8965, 0x586E, 0x8966,\t0x586F, 0x8967, 0x5870, 0x8968, 0x5871, 0x8969, 0x5872, 0x896A,\r\n\t0x5873, 0x896B, 0x5874, 0x896C, 0x5875, 0x896D, 0x5876, 0x896E,\t0x5877, 0x896F, 0x5878, 0x8970, 0x5879, 0x8971, 0x587A, 0x8972,\r\n\t0x587B, 0x8973, 0x587C, 0x8974, 0x587D, 0x8975, 0x587E, 0xDBD3,\t0x587F, 0x8976, 0x5880, 0xDCAF, 0x5881, 0xDCAC, 0x5882, 0x8977,\r\n\t0x5883, 0xBEB3, 0x5884, 0x8978, 0x5885, 0xCAFB, 0x5886, 0x8979,\t0x5887, 0x897A, 0x5888, 0x897B, 0x5889, 0xDCAD, 0x588A, 0x897C,\r\n\t0x588B, 0x897D, 0x588C, 0x897E, 0x588D, 0x8980, 0x588E, 0x8981,\t0x588F, 0x8982, 0x5890, 0x8983, 0x5891, 0x8984, 0x5892, 0xC9CA,\r\n\t0x5893, 0xC4B9, 0x5894, 0x8985, 0x5895, 0x8986, 0x5896, 0x8987,\t0x5897, 0x8988, 0x5898, 0x8989, 0x5899, 0xC7BD, 0x589A, 0xDCAE,\r\n\t0x589B, 0x898A, 0x589C, 0x898B, 0x589D, 0x898C, 0x589E, 0xD4F6,\t0x589F, 0xD0E6, 0x58A0, 0x898D, 0x58A1, 0x898E, 0x58A2, 0x898F,\r\n\t0x58A3, 0x8990, 0x58A4, 0x8991, 0x58A5, 0x8992, 0x58A6, 0x8993,\t0x58A7, 0x8994, 0x58A8, 0xC4AB, 0x58A9, 0xB6D5, 0x58AA, 0x8995,\r\n\t0x58AB, 0x8996, 0x58AC, 0x8997, 0x58AD, 0x8998, 0x58AE, 0x8999,\t0x58AF, 0x899A, 0x58B0, 0x899B, 0x58B1, 0x899C, 0x58B2, 0x899D,\r\n\t0x58B3, 0x899E, 0x58B4, 0x899F, 0x58B5, 0x89A0, 0x58B6, 0x89A1,\t0x58B7, 0x89A2, 0x58B8, 0x89A3, 0x58B9, 0x89A4, 0x58BA, 0x89A5,\r\n\t0x58BB, 0x89A6, 0x58BC, 0xDBD4, 0x58BD, 0x89A7, 0x58BE, 0x89A8,\t0x58BF, 0x89A9, 0x58C0, 0x89AA, 0x58C1, 0xB1DA, 0x58C2, 0x89AB,\r\n\t0x58C3, 0x89AC, 0x58C4, 0x89AD, 0x58C5, 0xDBD5, 0x58C6, 0x89AE,\t0x58C7, 0x89AF, 0x58C8, 0x89B0, 0x58C9, 0x89B1, 0x58CA, 0x89B2,\r\n\t0x58CB, 0x89B3, 0x58CC, 0x89B4, 0x58CD, 0x89B5, 0x58CE, 0x89B6,\t0x58CF, 0x89B7, 0x58D0, 0x89B8, 0x58D1, 0xDBD6, 0x58D2, 0x89B9,\r\n\t0x58D3, 0x89BA, 0x58D4, 0x89BB, 0x58D5, 0xBABE, 0x58D6, 0x89BC,\t0x58D7, 0x89BD, 0x58D8, 0x89BE, 0x58D9, 0x89BF, 0x58DA, 0x89C0,\r\n\t0x58DB, 0x89C1, 0x58DC, 0x89C2, 0x58DD, 0x89C3, 0x58DE, 0x89C4,\t0x58DF, 0x89C5, 0x58E0, 0x89C6, 0x58E1, 0x89C7, 0x58E2, 0x89C8,\r\n\t0x58E3, 0x89C9, 0x58E4, 0xC8C0, 0x58E5, 0x89CA, 0x58E6, 0x89CB,\t0x58E7, 0x89CC, 0x58E8, 0x89CD, 0x58E9, 0x89CE, 0x58EA, 0x89CF,\r\n\t0x58EB, 0xCABF, 0x58EC, 0xC8C9, 0x58ED, 0x89D0, 0x58EE, 0xD7B3,\t0x58EF, 0x89D1, 0x58F0, 0xC9F9, 0x58F1, 0x89D2, 0x58F2, 0x89D3,\r\n\t0x58F3, 0xBFC7, 0x58F4, 0x89D4, 0x58F5, 0x89D5, 0x58F6, 0xBAF8,\t0x58F7, 0x89D6, 0x58F8, 0x89D7, 0x58F9, 0xD2BC, 0x58FA, 0x89D8,\r\n\t0x58FB, 0x89D9, 0x58FC, 0x89DA, 0x58FD, 0x89DB, 0x58FE, 0x89DC,\t0x58FF, 0x89DD, 0x5900, 0x89DE, 0x5901, 0x89DF, 0x5902, 0xE2BA,\r\n\t0x5903, 0x89E0, 0x5904, 0xB4A6, 0x5905, 0x89E1, 0x5906, 0x89E2,\t0x5907, 0xB1B8, 0x5908, 0x89E3, 0x5909, 0x89E4, 0x590A, 0x89E5,\r\n\t0x590B, 0x89E6, 0x590C, 0x89E7, 0x590D, 0xB8B4, 0x590E, 0x89E8,\t0x590F, 0xCFC4, 0x5910, 0x89E9, 0x5911, 0x89EA, 0x5912, 0x89EB,\r\n\t0x5913, 0x89EC, 0x5914, 0xD9E7, 0x5915, 0xCFA6, 0x5916, 0xCDE2,\t0x5917, 0x89ED, 0x5918, 0x89EE, 0x5919, 0xD9ED, 0x591A, 0xB6E0,\r\n\t0x591B, 0x89EF, 0x591C, 0xD2B9, 0x591D, 0x89F0, 0x591E, 0x89F1,\t0x591F, 0xB9BB, 0x5920, 0x89F2, 0x5921, 0x89F3, 0x5922, 0x89F4,\r\n\t0x5923, 0x89F5, 0x5924, 0xE2B9, 0x5925, 0xE2B7, 0x5926, 0x89F6,\t0x5927, 0xB4F3, 0x5928, 0x89F7, 0x5929, 0xCCEC, 0x592A, 0xCCAB,\r\n\t0x592B, 0xB7F2, 0x592C, 0x89F8, 0x592D, 0xD8B2, 0x592E, 0xD1EB,\t0x592F, 0xBABB, 0x5930, 0x89F9, 0x5931, 0xCAA7, 0x5932, 0x89FA,\r\n\t0x5933, 0x89FB, 0x5934, 0xCDB7, 0x5935, 0x89FC, 0x5936, 0x89FD,\t0x5937, 0xD2C4, 0x5938, 0xBFE4, 0x5939, 0xBCD0, 0x593A, 0xB6E1,\r\n\t0x593B, 0x89FE, 0x593C, 0xDEC5, 0x593D, 0x8A40, 0x593E, 0x8A41,\t0x593F, 0x8A42, 0x5940, 0x8A43, 0x5941, 0xDEC6, 0x5942, 0xDBBC,\r\n\t0x5943, 0x8A44, 0x5944, 0xD1D9, 0x5945, 0x8A45, 0x5946, 0x8A46,\t0x5947, 0xC6E6, 0x5948, 0xC4CE, 0x5949, 0xB7EE, 0x594A, 0x8A47,\r\n\t0x594B, 0xB7DC, 0x594C, 0x8A48, 0x594D, 0x8A49, 0x594E, 0xBFFC,\t0x594F, 0xD7E0, 0x5950, 0x8A4A, 0x5951, 0xC6F5, 0x5952, 0x8A4B,\r\n\t0x5953, 0x8A4C, 0x5954, 0xB1BC, 0x5955, 0xDEC8, 0x5956, 0xBDB1,\t0x5957, 0xCCD7, 0x5958, 0xDECA, 0x5959, 0x8A4D, 0x595A, 0xDEC9,\r\n\t0x595B, 0x8A4E, 0x595C, 0x8A4F, 0x595D, 0x8A50, 0x595E, 0x8A51,\t0x595F, 0x8A52, 0x5960, 0xB5EC, 0x5961, 0x8A53, 0x5962, 0xC9DD,\r\n\t0x5963, 0x8A54, 0x5964, 0x8A55, 0x5965, 0xB0C2, 0x5966, 0x8A56,\t0x5967, 0x8A57, 0x5968, 0x8A58, 0x5969, 0x8A59, 0x596A, 0x8A5A,\r\n\t0x596B, 0x8A5B, 0x596C, 0x8A5C, 0x596D, 0x8A5D, 0x596E, 0x8A5E,\t0x596F, 0x8A5F, 0x5970, 0x8A60, 0x5971, 0x8A61, 0x5972, 0x8A62,\r\n\t0x5973, 0xC5AE, 0x5974, 0xC5AB, 0x5975, 0x8A63, 0x5976, 0xC4CC,\t0x5977, 0x8A64, 0x5978, 0xBCE9, 0x5979, 0xCBFD, 0x597A, 0x8A65,\r\n\t0x597B, 0x8A66, 0x597C, 0x8A67, 0x597D, 0xBAC3, 0x597E, 0x8A68,\t0x597F, 0x8A69, 0x5980, 0x8A6A, 0x5981, 0xE5F9, 0x5982, 0xC8E7,\r\n\t0x5983, 0xE5FA, 0x5984, 0xCDFD, 0x5985, 0x8A6B, 0x5986, 0xD7B1,\t0x5987, 0xB8BE, 0x5988, 0xC2E8, 0x5989, 0x8A6C, 0x598A, 0xC8D1,\r\n\t0x598B, 0x8A6D, 0x598C, 0x8A6E, 0x598D, 0xE5FB, 0x598E, 0x8A6F,\t0x598F, 0x8A70, 0x5990, 0x8A71, 0x5991, 0x8A72, 0x5992, 0xB6CA,\r\n\t0x5993, 0xBCCB, 0x5994, 0x8A73, 0x5995, 0x8A74, 0x5996, 0xD1FD,\t0x5997, 0xE6A1, 0x5998, 0x8A75, 0x5999, 0xC3EE, 0x599A, 0x8A76,\r\n\t0x599B, 0x8A77, 0x599C, 0x8A78, 0x599D, 0x8A79, 0x599E, 0xE6A4,\t0x599F, 0x8A7A, 0x59A0, 0x8A7B, 0x59A1, 0x8A7C, 0x59A2, 0x8A7D,\r\n\t0x59A3, 0xE5FE, 0x59A4, 0xE6A5, 0x59A5, 0xCDD7, 0x59A6, 0x8A7E,\t0x59A7, 0x8A80, 0x59A8, 0xB7C1, 0x59A9, 0xE5FC, 0x59AA, 0xE5FD,\r\n\t0x59AB, 0xE6A3, 0x59AC, 0x8A81, 0x59AD, 0x8A82, 0x59AE, 0xC4DD,\t0x59AF, 0xE6A8, 0x59B0, 0x8A83, 0x59B1, 0x8A84, 0x59B2, 0xE6A7,\r\n\t0x59B3, 0x8A85, 0x59B4, 0x8A86, 0x59B5, 0x8A87, 0x59B6, 0x8A88,\t0x59B7, 0x8A89, 0x59B8, 0x8A8A, 0x59B9, 0xC3C3, 0x59BA, 0x8A8B,\r\n\t0x59BB, 0xC6DE, 0x59BC, 0x8A8C, 0x59BD, 0x8A8D, 0x59BE, 0xE6AA,\t0x59BF, 0x8A8E, 0x59C0, 0x8A8F, 0x59C1, 0x8A90, 0x59C2, 0x8A91,\r\n\t0x59C3, 0x8A92, 0x59C4, 0x8A93, 0x59C5, 0x8A94, 0x59C6, 0xC4B7,\t0x59C7, 0x8A95, 0x59C8, 0x8A96, 0x59C9, 0x8A97, 0x59CA, 0xE6A2,\r\n\t0x59CB, 0xCABC, 0x59CC, 0x8A98, 0x59CD, 0x8A99, 0x59CE, 0x8A9A,\t0x59CF, 0x8A9B, 0x59D0, 0xBDE3, 0x59D1, 0xB9C3, 0x59D2, 0xE6A6,\r\n\t0x59D3, 0xD0D5, 0x59D4, 0xCEAF, 0x59D5, 0x8A9C, 0x59D6, 0x8A9D,\t0x59D7, 0xE6A9, 0x59D8, 0xE6B0, 0x59D9, 0x8A9E, 0x59DA, 0xD2A6,\r\n\t0x59DB, 0x8A9F, 0x59DC, 0xBDAA, 0x59DD, 0xE6AD, 0x59DE, 0x8AA0,\t0x59DF, 0x8AA1, 0x59E0, 0x8AA2, 0x59E1, 0x8AA3, 0x59E2, 0x8AA4,\r\n\t0x59E3, 0xE6AF, 0x59E4, 0x8AA5, 0x59E5, 0xC0D1, 0x59E6, 0x8AA6,\t0x59E7, 0x8AA7, 0x59E8, 0xD2CC, 0x59E9, 0x8AA8, 0x59EA, 0x8AA9,\r\n\t0x59EB, 0x8AAA, 0x59EC, 0xBCA7, 0x59ED, 0x8AAB, 0x59EE, 0x8AAC,\t0x59EF, 0x8AAD, 0x59F0, 0x8AAE, 0x59F1, 0x8AAF, 0x59F2, 0x8AB0,\r\n\t0x59F3, 0x8AB1, 0x59F4, 0x8AB2, 0x59F5, 0x8AB3, 0x59F6, 0x8AB4,\t0x59F7, 0x8AB5, 0x59F8, 0x8AB6, 0x59F9, 0xE6B1, 0x59FA, 0x8AB7,\r\n\t0x59FB, 0xD2F6, 0x59FC, 0x8AB8, 0x59FD, 0x8AB9, 0x59FE, 0x8ABA,\t0x59FF, 0xD7CB, 0x5A00, 0x8ABB, 0x5A01, 0xCDFE, 0x5A02, 0x8ABC,\r\n\t0x5A03, 0xCDDE, 0x5A04, 0xC2A6, 0x5A05, 0xE6AB, 0x5A06, 0xE6AC,\t0x5A07, 0xBDBF, 0x5A08, 0xE6AE, 0x5A09, 0xE6B3, 0x5A0A, 0x8ABD,\r\n\t0x5A0B, 0x8ABE, 0x5A0C, 0xE6B2, 0x5A0D, 0x8ABF, 0x5A0E, 0x8AC0,\t0x5A0F, 0x8AC1, 0x5A10, 0x8AC2, 0x5A11, 0xE6B6, 0x5A12, 0x8AC3,\r\n\t0x5A13, 0xE6B8, 0x5A14, 0x8AC4, 0x5A15, 0x8AC5, 0x5A16, 0x8AC6,\t0x5A17, 0x8AC7, 0x5A18, 0xC4EF, 0x5A19, 0x8AC8, 0x5A1A, 0x8AC9,\r\n\t0x5A1B, 0x8ACA, 0x5A1C, 0xC4C8, 0x5A1D, 0x8ACB, 0x5A1E, 0x8ACC,\t0x5A1F, 0xBEEA, 0x5A20, 0xC9EF, 0x5A21, 0x8ACD, 0x5A22, 0x8ACE,\r\n\t0x5A23, 0xE6B7, 0x5A24, 0x8ACF, 0x5A25, 0xB6F0, 0x5A26, 0x8AD0,\t0x5A27, 0x8AD1, 0x5A28, 0x8AD2, 0x5A29, 0xC3E4, 0x5A2A, 0x8AD3,\r\n\t0x5A2B, 0x8AD4, 0x5A2C, 0x8AD5, 0x5A2D, 0x8AD6, 0x5A2E, 0x8AD7,\t0x5A2F, 0x8AD8, 0x5A30, 0x8AD9, 0x5A31, 0xD3E9, 0x5A32, 0xE6B4,\r\n\t0x5A33, 0x8ADA, 0x5A34, 0xE6B5, 0x5A35, 0x8ADB, 0x5A36, 0xC8A2,\t0x5A37, 0x8ADC, 0x5A38, 0x8ADD, 0x5A39, 0x8ADE, 0x5A3A, 0x8ADF,\r\n\t0x5A3B, 0x8AE0, 0x5A3C, 0xE6BD, 0x5A3D, 0x8AE1, 0x5A3E, 0x8AE2,\t0x5A3F, 0x8AE3, 0x5A40, 0xE6B9, 0x5A41, 0x8AE4, 0x5A42, 0x8AE5,\r\n\t0x5A43, 0x8AE6, 0x5A44, 0x8AE7, 0x5A45, 0x8AE8, 0x5A46, 0xC6C5,\t0x5A47, 0x8AE9, 0x5A48, 0x8AEA, 0x5A49, 0xCDF1, 0x5A4A, 0xE6BB,\r\n\t0x5A4B, 0x8AEB, 0x5A4C, 0x8AEC, 0x5A4D, 0x8AED, 0x5A4E, 0x8AEE,\t0x5A4F, 0x8AEF, 0x5A50, 0x8AF0, 0x5A51, 0x8AF1, 0x5A52, 0x8AF2,\r\n\t0x5A53, 0x8AF3, 0x5A54, 0x8AF4, 0x5A55, 0xE6BC, 0x5A56, 0x8AF5,\t0x5A57, 0x8AF6, 0x5A58, 0x8AF7, 0x5A59, 0x8AF8, 0x5A5A, 0xBBE9,\r\n\t0x5A5B, 0x8AF9, 0x5A5C, 0x8AFA, 0x5A5D, 0x8AFB, 0x5A5E, 0x8AFC,\t0x5A5F, 0x8AFD, 0x5A60, 0x8AFE, 0x5A61, 0x8B40, 0x5A62, 0xE6BE,\r\n\t0x5A63, 0x8B41, 0x5A64, 0x8B42, 0x5A65, 0x8B43, 0x5A66, 0x8B44,\t0x5A67, 0xE6BA, 0x5A68, 0x8B45, 0x5A69, 0x8B46, 0x5A6A, 0xC0B7,\r\n\t0x5A6B, 0x8B47, 0x5A6C, 0x8B48, 0x5A6D, 0x8B49, 0x5A6E, 0x8B4A,\t0x5A6F, 0x8B4B, 0x5A70, 0x8B4C, 0x5A71, 0x8B4D, 0x5A72, 0x8B4E,\r\n\t0x5A73, 0x8B4F, 0x5A74, 0xD3A4, 0x5A75, 0xE6BF, 0x5A76, 0xC9F4,\t0x5A77, 0xE6C3, 0x5A78, 0x8B50, 0x5A79, 0x8B51, 0x5A7A, 0xE6C4,\r\n\t0x5A7B, 0x8B52, 0x5A7C, 0x8B53, 0x5A7D, 0x8B54, 0x5A7E, 0x8B55,\t0x5A7F, 0xD0F6, 0x5A80, 0x8B56, 0x5A81, 0x8B57, 0x5A82, 0x8B58,\r\n\t0x5A83, 0x8B59, 0x5A84, 0x8B5A, 0x5A85, 0x8B5B, 0x5A86, 0x8B5C,\t0x5A87, 0x8B5D, 0x5A88, 0x8B5E, 0x5A89, 0x8B5F, 0x5A8A, 0x8B60,\r\n\t0x5A8B, 0x8B61, 0x5A8C, 0x8B62, 0x5A8D, 0x8B63, 0x5A8E, 0x8B64,\t0x5A8F, 0x8B65, 0x5A90, 0x8B66, 0x5A91, 0x8B67, 0x5A92, 0xC3BD,\r\n\t0x5A93, 0x8B68, 0x5A94, 0x8B69, 0x5A95, 0x8B6A, 0x5A96, 0x8B6B,\t0x5A97, 0x8B6C, 0x5A98, 0x8B6D, 0x5A99, 0x8B6E, 0x5A9A, 0xC3C4,\r\n\t0x5A9B, 0xE6C2, 0x5A9C, 0x8B6F, 0x5A9D, 0x8B70, 0x5A9E, 0x8B71,\t0x5A9F, 0x8B72, 0x5AA0, 0x8B73, 0x5AA1, 0x8B74, 0x5AA2, 0x8B75,\r\n\t0x5AA3, 0x8B76, 0x5AA4, 0x8B77, 0x5AA5, 0x8B78, 0x5AA6, 0x8B79,\t0x5AA7, 0x8B7A, 0x5AA8, 0x8B7B, 0x5AA9, 0x8B7C, 0x5AAA, 0xE6C1,\r\n\t0x5AAB, 0x8B7D, 0x5AAC, 0x8B7E, 0x5AAD, 0x8B80, 0x5AAE, 0x8B81,\t0x5AAF, 0x8B82, 0x5AB0, 0x8B83, 0x5AB1, 0x8B84, 0x5AB2, 0xE6C7,\r\n\t0x5AB3, 0xCFB1, 0x5AB4, 0x8B85, 0x5AB5, 0xEBF4, 0x5AB6, 0x8B86,\t0x5AB7, 0x8B87, 0x5AB8, 0xE6CA, 0x5AB9, 0x8B88, 0x5ABA, 0x8B89,\r\n\t0x5ABB, 0x8B8A, 0x5ABC, 0x8B8B, 0x5ABD, 0x8B8C, 0x5ABE, 0xE6C5,\t0x5ABF, 0x8B8D, 0x5AC0, 0x8B8E, 0x5AC1, 0xBCDE, 0x5AC2, 0xC9A9,\r\n\t0x5AC3, 0x8B8F, 0x5AC4, 0x8B90, 0x5AC5, 0x8B91, 0x5AC6, 0x8B92,\t0x5AC7, 0x8B93, 0x5AC8, 0x8B94, 0x5AC9, 0xBCB5, 0x5ACA, 0x8B95,\r\n\t0x5ACB, 0x8B96, 0x5ACC, 0xCFD3, 0x5ACD, 0x8B97, 0x5ACE, 0x8B98,\t0x5ACF, 0x8B99, 0x5AD0, 0x8B9A, 0x5AD1, 0x8B9B, 0x5AD2, 0xE6C8,\r\n\t0x5AD3, 0x8B9C, 0x5AD4, 0xE6C9, 0x5AD5, 0x8B9D, 0x5AD6, 0xE6CE,\t0x5AD7, 0x8B9E, 0x5AD8, 0xE6D0, 0x5AD9, 0x8B9F, 0x5ADA, 0x8BA0,\r\n\t0x5ADB, 0x8BA1, 0x5ADC, 0xE6D1, 0x5ADD, 0x8BA2, 0x5ADE, 0x8BA3,\t0x5ADF, 0x8BA4, 0x5AE0, 0xE6CB, 0x5AE1, 0xB5D5, 0x5AE2, 0x8BA5,\r\n\t0x5AE3, 0xE6CC, 0x5AE4, 0x8BA6, 0x5AE5, 0x8BA7, 0x5AE6, 0xE6CF,\t0x5AE7, 0x8BA8, 0x5AE8, 0x8BA9, 0x5AE9, 0xC4DB, 0x5AEA, 0x8BAA,\r\n\t0x5AEB, 0xE6C6, 0x5AEC, 0x8BAB, 0x5AED, 0x8BAC, 0x5AEE, 0x8BAD,\t0x5AEF, 0x8BAE, 0x5AF0, 0x8BAF, 0x5AF1, 0xE6CD, 0x5AF2, 0x8BB0,\r\n\t0x5AF3, 0x8BB1, 0x5AF4, 0x8BB2, 0x5AF5, 0x8BB3, 0x5AF6, 0x8BB4,\t0x5AF7, 0x8BB5, 0x5AF8, 0x8BB6, 0x5AF9, 0x8BB7, 0x5AFA, 0x8BB8,\r\n\t0x5AFB, 0x8BB9, 0x5AFC, 0x8BBA, 0x5AFD, 0x8BBB, 0x5AFE, 0x8BBC,\t0x5AFF, 0x8BBD, 0x5B00, 0x8BBE, 0x5B01, 0x8BBF, 0x5B02, 0x8BC0,\r\n\t0x5B03, 0x8BC1, 0x5B04, 0x8BC2, 0x5B05, 0x8BC3, 0x5B06, 0x8BC4,\t0x5B07, 0x8BC5, 0x5B08, 0x8BC6, 0x5B09, 0xE6D2, 0x5B0A, 0x8BC7,\r\n\t0x5B0B, 0x8BC8, 0x5B0C, 0x8BC9, 0x5B0D, 0x8BCA, 0x5B0E, 0x8BCB,\t0x5B0F, 0x8BCC, 0x5B10, 0x8BCD, 0x5B11, 0x8BCE, 0x5B12, 0x8BCF,\r\n\t0x5B13, 0x8BD0, 0x5B14, 0x8BD1, 0x5B15, 0x8BD2, 0x5B16, 0xE6D4,\t0x5B17, 0xE6D3, 0x5B18, 0x8BD3, 0x5B19, 0x8BD4, 0x5B1A, 0x8BD5,\r\n\t0x5B1B, 0x8BD6, 0x5B1C, 0x8BD7, 0x5B1D, 0x8BD8, 0x5B1E, 0x8BD9,\t0x5B1F, 0x8BDA, 0x5B20, 0x8BDB, 0x5B21, 0x8BDC, 0x5B22, 0x8BDD,\r\n\t0x5B23, 0x8BDE, 0x5B24, 0x8BDF, 0x5B25, 0x8BE0, 0x5B26, 0x8BE1,\t0x5B27, 0x8BE2, 0x5B28, 0x8BE3, 0x5B29, 0x8BE4, 0x5B2A, 0x8BE5,\r\n\t0x5B2B, 0x8BE6, 0x5B2C, 0x8BE7, 0x5B2D, 0x8BE8, 0x5B2E, 0x8BE9,\t0x5B2F, 0x8BEA, 0x5B30, 0x8BEB, 0x5B31, 0x8BEC, 0x5B32, 0xE6D5,\r\n\t0x5B33, 0x8BED, 0x5B34, 0xD9F8, 0x5B35, 0x8BEE, 0x5B36, 0x8BEF,\t0x5B37, 0xE6D6, 0x5B38, 0x8BF0, 0x5B39, 0x8BF1, 0x5B3A, 0x8BF2,\r\n\t0x5B3B, 0x8BF3, 0x5B3C, 0x8BF4, 0x5B3D, 0x8BF5, 0x5B3E, 0x8BF6,\t0x5B3F, 0x8BF7, 0x5B40, 0xE6D7, 0x5B41, 0x8BF8, 0x5B42, 0x8BF9,\r\n\t0x5B43, 0x8BFA, 0x5B44, 0x8BFB, 0x5B45, 0x8BFC, 0x5B46, 0x8BFD,\t0x5B47, 0x8BFE, 0x5B48, 0x8C40, 0x5B49, 0x8C41, 0x5B4A, 0x8C42,\r\n\t0x5B4B, 0x8C43, 0x5B4C, 0x8C44, 0x5B4D, 0x8C45, 0x5B4E, 0x8C46,\t0x5B4F, 0x8C47, 0x5B50, 0xD7D3, 0x5B51, 0xE6DD, 0x5B52, 0x8C48,\r\n\t0x5B53, 0xE6DE, 0x5B54, 0xBFD7, 0x5B55, 0xD4D0, 0x5B56, 0x8C49,\t0x5B57, 0xD7D6, 0x5B58, 0xB4E6, 0x5B59, 0xCBEF, 0x5B5A, 0xE6DA,\r\n\t0x5B5B, 0xD8C3, 0x5B5C, 0xD7CE, 0x5B5D, 0xD0A2, 0x5B5E, 0x8C4A,\t0x5B5F, 0xC3CF, 0x5B60, 0x8C4B, 0x5B61, 0x8C4C, 0x5B62, 0xE6DF,\r\n\t0x5B63, 0xBCBE, 0x5B64, 0xB9C2, 0x5B65, 0xE6DB, 0x5B66, 0xD1A7,\t0x5B67, 0x8C4D, 0x5B68, 0x8C4E, 0x5B69, 0xBAA2, 0x5B6A, 0xC2CF,\r\n\t0x5B6B, 0x8C4F, 0x5B6C, 0xD8AB, 0x5B6D, 0x8C50, 0x5B6E, 0x8C51,\t0x5B6F, 0x8C52, 0x5B70, 0xCAEB, 0x5B71, 0xE5EE, 0x5B72, 0x8C53,\r\n\t0x5B73, 0xE6DC, 0x5B74, 0x8C54, 0x5B75, 0xB7F5, 0x5B76, 0x8C55,\t0x5B77, 0x8C56, 0x5B78, 0x8C57, 0x5B79, 0x8C58, 0x5B7A, 0xC8E6,\r\n\t0x5B7B, 0x8C59, 0x5B7C, 0x8C5A, 0x5B7D, 0xC4F5, 0x5B7E, 0x8C5B,\t0x5B7F, 0x8C5C, 0x5B80, 0xE5B2, 0x5B81, 0xC4FE, 0x5B82, 0x8C5D,\r\n\t0x5B83, 0xCBFC, 0x5B84, 0xE5B3, 0x5B85, 0xD5AC, 0x5B86, 0x8C5E,\t0x5B87, 0xD3EE, 0x5B88, 0xCAD8, 0x5B89, 0xB0B2, 0x5B8A, 0x8C5F,\r\n\t0x5B8B, 0xCBCE, 0x5B8C, 0xCDEA, 0x5B8D, 0x8C60, 0x5B8E, 0x8C61,\t0x5B8F, 0xBAEA, 0x5B90, 0x8C62, 0x5B91, 0x8C63, 0x5B92, 0x8C64,\r\n\t0x5B93, 0xE5B5, 0x5B94, 0x8C65, 0x5B95, 0xE5B4, 0x5B96, 0x8C66,\t0x5B97, 0xD7DA, 0x5B98, 0xB9D9, 0x5B99, 0xD6E6, 0x5B9A, 0xB6A8,\r\n\t0x5B9B, 0xCDF0, 0x5B9C, 0xD2CB, 0x5B9D, 0xB1A6, 0x5B9E, 0xCAB5,\t0x5B9F, 0x8C67, 0x5BA0, 0xB3E8, 0x5BA1, 0xC9F3, 0x5BA2, 0xBFCD,\r\n\t0x5BA3, 0xD0FB, 0x5BA4, 0xCAD2, 0x5BA5, 0xE5B6, 0x5BA6, 0xBBC2,\t0x5BA7, 0x8C68, 0x5BA8, 0x8C69, 0x5BA9, 0x8C6A, 0x5BAA, 0xCFDC,\r\n\t0x5BAB, 0xB9AC, 0x5BAC, 0x8C6B, 0x5BAD, 0x8C6C, 0x5BAE, 0x8C6D,\t0x5BAF, 0x8C6E, 0x5BB0, 0xD4D7, 0x5BB1, 0x8C6F, 0x5BB2, 0x8C70,\r\n\t0x5BB3, 0xBAA6, 0x5BB4, 0xD1E7, 0x5BB5, 0xCFFC, 0x5BB6, 0xBCD2,\t0x5BB7, 0x8C71, 0x5BB8, 0xE5B7, 0x5BB9, 0xC8DD, 0x5BBA, 0x8C72,\r\n\t0x5BBB, 0x8C73, 0x5BBC, 0x8C74, 0x5BBD, 0xBFED, 0x5BBE, 0xB1F6,\t0x5BBF, 0xCBDE, 0x5BC0, 0x8C75, 0x5BC1, 0x8C76, 0x5BC2, 0xBCC5,\r\n\t0x5BC3, 0x8C77, 0x5BC4, 0xBCC4, 0x5BC5, 0xD2FA, 0x5BC6, 0xC3DC,\t0x5BC7, 0xBFDC, 0x5BC8, 0x8C78, 0x5BC9, 0x8C79, 0x5BCA, 0x8C7A,\r\n\t0x5BCB, 0x8C7B, 0x5BCC, 0xB8BB, 0x5BCD, 0x8C7C, 0x5BCE, 0x8C7D,\t0x5BCF, 0x8C7E, 0x5BD0, 0xC3C2, 0x5BD1, 0x8C80, 0x5BD2, 0xBAAE,\r\n\t0x5BD3, 0xD4A2, 0x5BD4, 0x8C81, 0x5BD5, 0x8C82, 0x5BD6, 0x8C83,\t0x5BD7, 0x8C84, 0x5BD8, 0x8C85, 0x5BD9, 0x8C86, 0x5BDA, 0x8C87,\r\n\t0x5BDB, 0x8C88, 0x5BDC, 0x8C89, 0x5BDD, 0xC7DE, 0x5BDE, 0xC4AF,\t0x5BDF, 0xB2EC, 0x5BE0, 0x8C8A, 0x5BE1, 0xB9D1, 0x5BE2, 0x8C8B,\r\n\t0x5BE3, 0x8C8C, 0x5BE4, 0xE5BB, 0x5BE5, 0xC1C8, 0x5BE6, 0x8C8D,\t0x5BE7, 0x8C8E, 0x5BE8, 0xD5AF, 0x5BE9, 0x8C8F, 0x5BEA, 0x8C90,\r\n\t0x5BEB, 0x8C91, 0x5BEC, 0x8C92, 0x5BED, 0x8C93, 0x5BEE, 0xE5BC,\t0x5BEF, 0x8C94, 0x5BF0, 0xE5BE, 0x5BF1, 0x8C95, 0x5BF2, 0x8C96,\r\n\t0x5BF3, 0x8C97, 0x5BF4, 0x8C98, 0x5BF5, 0x8C99, 0x5BF6, 0x8C9A,\t0x5BF7, 0x8C9B, 0x5BF8, 0xB4E7, 0x5BF9, 0xB6D4, 0x5BFA, 0xCBC2,\r\n\t0x5BFB, 0xD1B0, 0x5BFC, 0xB5BC, 0x5BFD, 0x8C9C, 0x5BFE, 0x8C9D,\t0x5BFF, 0xCAD9, 0x5C00, 0x8C9E, 0x5C01, 0xB7E2, 0x5C02, 0x8C9F,\r\n\t0x5C03, 0x8CA0, 0x5C04, 0xC9E4, 0x5C05, 0x8CA1, 0x5C06, 0xBDAB,\t0x5C07, 0x8CA2, 0x5C08, 0x8CA3, 0x5C09, 0xCEBE, 0x5C0A, 0xD7F0,\r\n\t0x5C0B, 0x8CA4, 0x5C0C, 0x8CA5, 0x5C0D, 0x8CA6, 0x5C0E, 0x8CA7,\t0x5C0F, 0xD0A1, 0x5C10, 0x8CA8, 0x5C11, 0xC9D9, 0x5C12, 0x8CA9,\r\n\t0x5C13, 0x8CAA, 0x5C14, 0xB6FB, 0x5C15, 0xE6D8, 0x5C16, 0xBCE2,\t0x5C17, 0x8CAB, 0x5C18, 0xB3BE, 0x5C19, 0x8CAC, 0x5C1A, 0xC9D0,\r\n\t0x5C1B, 0x8CAD, 0x5C1C, 0xE6D9, 0x5C1D, 0xB3A2, 0x5C1E, 0x8CAE,\t0x5C1F, 0x8CAF, 0x5C20, 0x8CB0, 0x5C21, 0x8CB1, 0x5C22, 0xDECC,\r\n\t0x5C23, 0x8CB2, 0x5C24, 0xD3C8, 0x5C25, 0xDECD, 0x5C26, 0x8CB3,\t0x5C27, 0xD2A2, 0x5C28, 0x8CB4, 0x5C29, 0x8CB5, 0x5C2A, 0x8CB6,\r\n\t0x5C2B, 0x8CB7, 0x5C2C, 0xDECE, 0x5C2D, 0x8CB8, 0x5C2E, 0x8CB9,\t0x5C2F, 0x8CBA, 0x5C30, 0x8CBB, 0x5C31, 0xBECD, 0x5C32, 0x8CBC,\r\n\t0x5C33, 0x8CBD, 0x5C34, 0xDECF, 0x5C35, 0x8CBE, 0x5C36, 0x8CBF,\t0x5C37, 0x8CC0, 0x5C38, 0xCAAC, 0x5C39, 0xD2FC, 0x5C3A, 0xB3DF,\r\n\t0x5C3B, 0xE5EA, 0x5C3C, 0xC4E1, 0x5C3D, 0xBEA1, 0x5C3E, 0xCEB2,\t0x5C3F, 0xC4F2, 0x5C40, 0xBED6, 0x5C41, 0xC6A8, 0x5C42, 0xB2E3,\r\n\t0x5C43, 0x8CC1, 0x5C44, 0x8CC2, 0x5C45, 0xBED3, 0x5C46, 0x8CC3,\t0x5C47, 0x8CC4, 0x5C48, 0xC7FC, 0x5C49, 0xCCEB, 0x5C4A, 0xBDEC,\r\n\t0x5C4B, 0xCEDD, 0x5C4C, 0x8CC5, 0x5C4D, 0x8CC6, 0x5C4E, 0xCABA,\t0x5C4F, 0xC6C1, 0x5C50, 0xE5EC, 0x5C51, 0xD0BC, 0x5C52, 0x8CC7,\r\n\t0x5C53, 0x8CC8, 0x5C54, 0x8CC9, 0x5C55, 0xD5B9, 0x5C56, 0x8CCA,\t0x5C57, 0x8CCB, 0x5C58, 0x8CCC, 0x5C59, 0xE5ED, 0x5C5A, 0x8CCD,\r\n\t0x5C5B, 0x8CCE, 0x5C5C, 0x8CCF, 0x5C5D, 0x8CD0, 0x5C5E, 0xCAF4,\t0x5C5F, 0x8CD1, 0x5C60, 0xCDC0, 0x5C61, 0xC2C5, 0x5C62, 0x8CD2,\r\n\t0x5C63, 0xE5EF, 0x5C64, 0x8CD3, 0x5C65, 0xC2C4, 0x5C66, 0xE5F0,\t0x5C67, 0x8CD4, 0x5C68, 0x8CD5, 0x5C69, 0x8CD6, 0x5C6A, 0x8CD7,\r\n\t0x5C6B, 0x8CD8, 0x5C6C, 0x8CD9, 0x5C6D, 0x8CDA, 0x5C6E, 0xE5F8,\t0x5C6F, 0xCDCD, 0x5C70, 0x8CDB, 0x5C71, 0xC9BD, 0x5C72, 0x8CDC,\r\n\t0x5C73, 0x8CDD, 0x5C74, 0x8CDE, 0x5C75, 0x8CDF, 0x5C76, 0x8CE0,\t0x5C77, 0x8CE1, 0x5C78, 0x8CE2, 0x5C79, 0xD2D9, 0x5C7A, 0xE1A8,\r\n\t0x5C7B, 0x8CE3, 0x5C7C, 0x8CE4, 0x5C7D, 0x8CE5, 0x5C7E, 0x8CE6,\t0x5C7F, 0xD3EC, 0x5C80, 0x8CE7, 0x5C81, 0xCBEA, 0x5C82, 0xC6F1,\r\n\t0x5C83, 0x8CE8, 0x5C84, 0x8CE9, 0x5C85, 0x8CEA, 0x5C86, 0x8CEB,\t0x5C87, 0x8CEC, 0x5C88, 0xE1AC, 0x5C89, 0x8CED, 0x5C8A, 0x8CEE,\r\n\t0x5C8B, 0x8CEF, 0x5C8C, 0xE1A7, 0x5C8D, 0xE1A9, 0x5C8E, 0x8CF0,\t0x5C8F, 0x8CF1, 0x5C90, 0xE1AA, 0x5C91, 0xE1AF, 0x5C92, 0x8CF2,\r\n\t0x5C93, 0x8CF3, 0x5C94, 0xB2ED, 0x5C95, 0x8CF4, 0x5C96, 0xE1AB,\t0x5C97, 0xB8DA, 0x5C98, 0xE1AD, 0x5C99, 0xE1AE, 0x5C9A, 0xE1B0,\r\n\t0x5C9B, 0xB5BA, 0x5C9C, 0xE1B1, 0x5C9D, 0x8CF5, 0x5C9E, 0x8CF6,\t0x5C9F, 0x8CF7, 0x5CA0, 0x8CF8, 0x5CA1, 0x8CF9, 0x5CA2, 0xE1B3,\r\n\t0x5CA3, 0xE1B8, 0x5CA4, 0x8CFA, 0x5CA5, 0x8CFB, 0x5CA6, 0x8CFC,\t0x5CA7, 0x8CFD, 0x5CA8, 0x8CFE, 0x5CA9, 0xD1D2, 0x5CAA, 0x8D40,\r\n\t0x5CAB, 0xE1B6, 0x5CAC, 0xE1B5, 0x5CAD, 0xC1EB, 0x5CAE, 0x8D41,\t0x5CAF, 0x8D42, 0x5CB0, 0x8D43, 0x5CB1, 0xE1B7, 0x5CB2, 0x8D44,\r\n\t0x5CB3, 0xD4C0, 0x5CB4, 0x8D45, 0x5CB5, 0xE1B2, 0x5CB6, 0x8D46,\t0x5CB7, 0xE1BA, 0x5CB8, 0xB0B6, 0x5CB9, 0x8D47, 0x5CBA, 0x8D48,\r\n\t0x5CBB, 0x8D49, 0x5CBC, 0x8D4A, 0x5CBD, 0xE1B4, 0x5CBE, 0x8D4B,\t0x5CBF, 0xBFF9, 0x5CC0, 0x8D4C, 0x5CC1, 0xE1B9, 0x5CC2, 0x8D4D,\r\n\t0x5CC3, 0x8D4E, 0x5CC4, 0xE1BB, 0x5CC5, 0x8D4F, 0x5CC6, 0x8D50,\t0x5CC7, 0x8D51, 0x5CC8, 0x8D52, 0x5CC9, 0x8D53, 0x5CCA, 0x8D54,\r\n\t0x5CCB, 0xE1BE, 0x5CCC, 0x8D55, 0x5CCD, 0x8D56, 0x5CCE, 0x8D57,\t0x5CCF, 0x8D58, 0x5CD0, 0x8D59, 0x5CD1, 0x8D5A, 0x5CD2, 0xE1BC,\r\n\t0x5CD3, 0x8D5B, 0x5CD4, 0x8D5C, 0x5CD5, 0x8D5D, 0x5CD6, 0x8D5E,\t0x5CD7, 0x8D5F, 0x5CD8, 0x8D60, 0x5CD9, 0xD6C5, 0x5CDA, 0x8D61,\r\n\t0x5CDB, 0x8D62, 0x5CDC, 0x8D63, 0x5CDD, 0x8D64, 0x5CDE, 0x8D65,\t0x5CDF, 0x8D66, 0x5CE0, 0x8D67, 0x5CE1, 0xCFBF, 0x5CE2, 0x8D68,\r\n\t0x5CE3, 0x8D69, 0x5CE4, 0xE1BD, 0x5CE5, 0xE1BF, 0x5CE6, 0xC2CD,\t0x5CE7, 0x8D6A, 0x5CE8, 0xB6EB, 0x5CE9, 0x8D6B, 0x5CEA, 0xD3F8,\r\n\t0x5CEB, 0x8D6C, 0x5CEC, 0x8D6D, 0x5CED, 0xC7CD, 0x5CEE, 0x8D6E,\t0x5CEF, 0x8D6F, 0x5CF0, 0xB7E5, 0x5CF1, 0x8D70, 0x5CF2, 0x8D71,\r\n\t0x5CF3, 0x8D72, 0x5CF4, 0x8D73, 0x5CF5, 0x8D74, 0x5CF6, 0x8D75,\t0x5CF7, 0x8D76, 0x5CF8, 0x8D77, 0x5CF9, 0x8D78, 0x5CFA, 0x8D79,\r\n\t0x5CFB, 0xBEFE, 0x5CFC, 0x8D7A, 0x5CFD, 0x8D7B, 0x5CFE, 0x8D7C,\t0x5CFF, 0x8D7D, 0x5D00, 0x8D7E, 0x5D01, 0x8D80, 0x5D02, 0xE1C0,\r\n\t0x5D03, 0xE1C1, 0x5D04, 0x8D81, 0x5D05, 0x8D82, 0x5D06, 0xE1C7,\t0x5D07, 0xB3E7, 0x5D08, 0x8D83, 0x5D09, 0x8D84, 0x5D0A, 0x8D85,\r\n\t0x5D0B, 0x8D86, 0x5D0C, 0x8D87, 0x5D0D, 0x8D88, 0x5D0E, 0xC6E9,\t0x5D0F, 0x8D89, 0x5D10, 0x8D8A, 0x5D11, 0x8D8B, 0x5D12, 0x8D8C,\r\n\t0x5D13, 0x8D8D, 0x5D14, 0xB4DE, 0x5D15, 0x8D8E, 0x5D16, 0xD1C2,\t0x5D17, 0x8D8F, 0x5D18, 0x8D90, 0x5D19, 0x8D91, 0x5D1A, 0x8D92,\r\n\t0x5D1B, 0xE1C8, 0x5D1C, 0x8D93, 0x5D1D, 0x8D94, 0x5D1E, 0xE1C6,\t0x5D1F, 0x8D95, 0x5D20, 0x8D96, 0x5D21, 0x8D97, 0x5D22, 0x8D98,\r\n\t0x5D23, 0x8D99, 0x5D24, 0xE1C5, 0x5D25, 0x8D9A, 0x5D26, 0xE1C3,\t0x5D27, 0xE1C2, 0x5D28, 0x8D9B, 0x5D29, 0xB1C0, 0x5D2A, 0x8D9C,\r\n\t0x5D2B, 0x8D9D, 0x5D2C, 0x8D9E, 0x5D2D, 0xD5B8, 0x5D2E, 0xE1C4,\t0x5D2F, 0x8D9F, 0x5D30, 0x8DA0, 0x5D31, 0x8DA1, 0x5D32, 0x8DA2,\r\n\t0x5D33, 0x8DA3, 0x5D34, 0xE1CB, 0x5D35, 0x8DA4, 0x5D36, 0x8DA5,\t0x5D37, 0x8DA6, 0x5D38, 0x8DA7, 0x5D39, 0x8DA8, 0x5D3A, 0x8DA9,\r\n\t0x5D3B, 0x8DAA, 0x5D3C, 0x8DAB, 0x5D3D, 0xE1CC, 0x5D3E, 0xE1CA,\t0x5D3F, 0x8DAC, 0x5D40, 0x8DAD, 0x5D41, 0x8DAE, 0x5D42, 0x8DAF,\r\n\t0x5D43, 0x8DB0, 0x5D44, 0x8DB1, 0x5D45, 0x8DB2, 0x5D46, 0x8DB3,\t0x5D47, 0xEFFA, 0x5D48, 0x8DB4, 0x5D49, 0x8DB5, 0x5D4A, 0xE1D3,\r\n\t0x5D4B, 0xE1D2, 0x5D4C, 0xC7B6, 0x5D4D, 0x8DB6, 0x5D4E, 0x8DB7,\t0x5D4F, 0x8DB8, 0x5D50, 0x8DB9, 0x5D51, 0x8DBA, 0x5D52, 0x8DBB,\r\n\t0x5D53, 0x8DBC, 0x5D54, 0x8DBD, 0x5D55, 0x8DBE, 0x5D56, 0x8DBF,\t0x5D57, 0x8DC0, 0x5D58, 0xE1C9, 0x5D59, 0x8DC1, 0x5D5A, 0x8DC2,\r\n\t0x5D5B, 0xE1CE, 0x5D5C, 0x8DC3, 0x5D5D, 0xE1D0, 0x5D5E, 0x8DC4,\t0x5D5F, 0x8DC5, 0x5D60, 0x8DC6, 0x5D61, 0x8DC7, 0x5D62, 0x8DC8,\r\n\t0x5D63, 0x8DC9, 0x5D64, 0x8DCA, 0x5D65, 0x8DCB, 0x5D66, 0x8DCC,\t0x5D67, 0x8DCD, 0x5D68, 0x8DCE, 0x5D69, 0xE1D4, 0x5D6A, 0x8DCF,\r\n\t0x5D6B, 0xE1D1, 0x5D6C, 0xE1CD, 0x5D6D, 0x8DD0, 0x5D6E, 0x8DD1,\t0x5D6F, 0xE1CF, 0x5D70, 0x8DD2, 0x5D71, 0x8DD3, 0x5D72, 0x8DD4,\r\n\t0x5D73, 0x8DD5, 0x5D74, 0xE1D5, 0x5D75, 0x8DD6, 0x5D76, 0x8DD7,\t0x5D77, 0x8DD8, 0x5D78, 0x8DD9, 0x5D79, 0x8DDA, 0x5D7A, 0x8DDB,\r\n\t0x5D7B, 0x8DDC, 0x5D7C, 0x8DDD, 0x5D7D, 0x8DDE, 0x5D7E, 0x8DDF,\t0x5D7F, 0x8DE0, 0x5D80, 0x8DE1, 0x5D81, 0x8DE2, 0x5D82, 0xE1D6,\r\n\t0x5D83, 0x8DE3, 0x5D84, 0x8DE4, 0x5D85, 0x8DE5, 0x5D86, 0x8DE6,\t0x5D87, 0x8DE7, 0x5D88, 0x8DE8, 0x5D89, 0x8DE9, 0x5D8A, 0x8DEA,\r\n\t0x5D8B, 0x8DEB, 0x5D8C, 0x8DEC, 0x5D8D, 0x8DED, 0x5D8E, 0x8DEE,\t0x5D8F, 0x8DEF, 0x5D90, 0x8DF0, 0x5D91, 0x8DF1, 0x5D92, 0x8DF2,\r\n\t0x5D93, 0x8DF3, 0x5D94, 0x8DF4, 0x5D95, 0x8DF5, 0x5D96, 0x8DF6,\t0x5D97, 0x8DF7, 0x5D98, 0x8DF8, 0x5D99, 0xE1D7, 0x5D9A, 0x8DF9,\r\n\t0x5D9B, 0x8DFA, 0x5D9C, 0x8DFB, 0x5D9D, 0xE1D8, 0x5D9E, 0x8DFC,\t0x5D9F, 0x8DFD, 0x5DA0, 0x8DFE, 0x5DA1, 0x8E40, 0x5DA2, 0x8E41,\r\n\t0x5DA3, 0x8E42, 0x5DA4, 0x8E43, 0x5DA5, 0x8E44, 0x5DA6, 0x8E45,\t0x5DA7, 0x8E46, 0x5DA8, 0x8E47, 0x5DA9, 0x8E48, 0x5DAA, 0x8E49,\r\n\t0x5DAB, 0x8E4A, 0x5DAC, 0x8E4B, 0x5DAD, 0x8E4C, 0x5DAE, 0x8E4D,\t0x5DAF, 0x8E4E, 0x5DB0, 0x8E4F, 0x5DB1, 0x8E50, 0x5DB2, 0x8E51,\r\n\t0x5DB3, 0x8E52, 0x5DB4, 0x8E53, 0x5DB5, 0x8E54, 0x5DB6, 0x8E55,\t0x5DB7, 0xE1DA, 0x5DB8, 0x8E56, 0x5DB9, 0x8E57, 0x5DBA, 0x8E58,\r\n\t0x5DBB, 0x8E59, 0x5DBC, 0x8E5A, 0x5DBD, 0x8E5B, 0x5DBE, 0x8E5C,\t0x5DBF, 0x8E5D, 0x5DC0, 0x8E5E, 0x5DC1, 0x8E5F, 0x5DC2, 0x8E60,\r\n\t0x5DC3, 0x8E61, 0x5DC4, 0x8E62, 0x5DC5, 0xE1DB, 0x5DC6, 0x8E63,\t0x5DC7, 0x8E64, 0x5DC8, 0x8E65, 0x5DC9, 0x8E66, 0x5DCA, 0x8E67,\r\n\t0x5DCB, 0x8E68, 0x5DCC, 0x8E69, 0x5DCD, 0xCEA1, 0x5DCE, 0x8E6A,\t0x5DCF, 0x8E6B, 0x5DD0, 0x8E6C, 0x5DD1, 0x8E6D, 0x5DD2, 0x8E6E,\r\n\t0x5DD3, 0x8E6F, 0x5DD4, 0x8E70, 0x5DD5, 0x8E71, 0x5DD6, 0x8E72,\t0x5DD7, 0x8E73, 0x5DD8, 0x8E74, 0x5DD9, 0x8E75, 0x5DDA, 0x8E76,\r\n\t0x5DDB, 0xE7DD, 0x5DDC, 0x8E77, 0x5DDD, 0xB4A8, 0x5DDE, 0xD6DD,\t0x5DDF, 0x8E78, 0x5DE0, 0x8E79, 0x5DE1, 0xD1B2, 0x5DE2, 0xB3B2,\r\n\t0x5DE3, 0x8E7A, 0x5DE4, 0x8E7B, 0x5DE5, 0xB9A4, 0x5DE6, 0xD7F3,\t0x5DE7, 0xC7C9, 0x5DE8, 0xBEDE, 0x5DE9, 0xB9AE, 0x5DEA, 0x8E7C,\r\n\t0x5DEB, 0xCED7, 0x5DEC, 0x8E7D, 0x5DED, 0x8E7E, 0x5DEE, 0xB2EE,\t0x5DEF, 0xDBCF, 0x5DF0, 0x8E80, 0x5DF1, 0xBCBA, 0x5DF2, 0xD2D1,\r\n\t0x5DF3, 0xCBC8, 0x5DF4, 0xB0CD, 0x5DF5, 0x8E81, 0x5DF6, 0x8E82,\t0x5DF7, 0xCFEF, 0x5DF8, 0x8E83, 0x5DF9, 0x8E84, 0x5DFA, 0x8E85,\r\n\t0x5DFB, 0x8E86, 0x5DFC, 0x8E87, 0x5DFD, 0xD9E3, 0x5DFE, 0xBDED,\t0x5DFF, 0x8E88, 0x5E00, 0x8E89, 0x5E01, 0xB1D2, 0x5E02, 0xCAD0,\r\n\t0x5E03, 0xB2BC, 0x5E04, 0x8E8A, 0x5E05, 0xCBA7, 0x5E06, 0xB7AB,\t0x5E07, 0x8E8B, 0x5E08, 0xCAA6, 0x5E09, 0x8E8C, 0x5E0A, 0x8E8D,\r\n\t0x5E0B, 0x8E8E, 0x5E0C, 0xCFA3, 0x5E0D, 0x8E8F, 0x5E0E, 0x8E90,\t0x5E0F, 0xE0F8, 0x5E10, 0xD5CA, 0x5E11, 0xE0FB, 0x5E12, 0x8E91,\r\n\t0x5E13, 0x8E92, 0x5E14, 0xE0FA, 0x5E15, 0xC5C1, 0x5E16, 0xCCFB,\t0x5E17, 0x8E93, 0x5E18, 0xC1B1, 0x5E19, 0xE0F9, 0x5E1A, 0xD6E3,\r\n\t0x5E1B, 0xB2AF, 0x5E1C, 0xD6C4, 0x5E1D, 0xB5DB, 0x5E1E, 0x8E94,\t0x5E1F, 0x8E95, 0x5E20, 0x8E96, 0x5E21, 0x8E97, 0x5E22, 0x8E98,\r\n\t0x5E23, 0x8E99, 0x5E24, 0x8E9A, 0x5E25, 0x8E9B, 0x5E26, 0xB4F8,\t0x5E27, 0xD6A1, 0x5E28, 0x8E9C, 0x5E29, 0x8E9D, 0x5E2A, 0x8E9E,\r\n\t0x5E2B, 0x8E9F, 0x5E2C, 0x8EA0, 0x5E2D, 0xCFAF, 0x5E2E, 0xB0EF,\t0x5E2F, 0x8EA1, 0x5E30, 0x8EA2, 0x5E31, 0xE0FC, 0x5E32, 0x8EA3,\r\n\t0x5E33, 0x8EA4, 0x5E34, 0x8EA5, 0x5E35, 0x8EA6, 0x5E36, 0x8EA7,\t0x5E37, 0xE1A1, 0x5E38, 0xB3A3, 0x5E39, 0x8EA8, 0x5E3A, 0x8EA9,\r\n\t0x5E3B, 0xE0FD, 0x5E3C, 0xE0FE, 0x5E3D, 0xC3B1, 0x5E3E, 0x8EAA,\t0x5E3F, 0x8EAB, 0x5E40, 0x8EAC, 0x5E41, 0x8EAD, 0x5E42, 0xC3DD,\r\n\t0x5E43, 0x8EAE, 0x5E44, 0xE1A2, 0x5E45, 0xB7F9, 0x5E46, 0x8EAF,\t0x5E47, 0x8EB0, 0x5E48, 0x8EB1, 0x5E49, 0x8EB2, 0x5E4A, 0x8EB3,\r\n\t0x5E4B, 0x8EB4, 0x5E4C, 0xBBCF, 0x5E4D, 0x8EB5, 0x5E4E, 0x8EB6,\t0x5E4F, 0x8EB7, 0x5E50, 0x8EB8, 0x5E51, 0x8EB9, 0x5E52, 0x8EBA,\r\n\t0x5E53, 0x8EBB, 0x5E54, 0xE1A3, 0x5E55, 0xC4BB, 0x5E56, 0x8EBC,\t0x5E57, 0x8EBD, 0x5E58, 0x8EBE, 0x5E59, 0x8EBF, 0x5E5A, 0x8EC0,\r\n\t0x5E5B, 0xE1A4, 0x5E5C, 0x8EC1, 0x5E5D, 0x8EC2, 0x5E5E, 0xE1A5,\t0x5E5F, 0x8EC3, 0x5E60, 0x8EC4, 0x5E61, 0xE1A6, 0x5E62, 0xB4B1,\r\n\t0x5E63, 0x8EC5, 0x5E64, 0x8EC6, 0x5E65, 0x8EC7, 0x5E66, 0x8EC8,\t0x5E67, 0x8EC9, 0x5E68, 0x8ECA, 0x5E69, 0x8ECB, 0x5E6A, 0x8ECC,\r\n\t0x5E6B, 0x8ECD, 0x5E6C, 0x8ECE, 0x5E6D, 0x8ECF, 0x5E6E, 0x8ED0,\t0x5E6F, 0x8ED1, 0x5E70, 0x8ED2, 0x5E71, 0x8ED3, 0x5E72, 0xB8C9,\r\n\t0x5E73, 0xC6BD, 0x5E74, 0xC4EA, 0x5E75, 0x8ED4, 0x5E76, 0xB2A2,\t0x5E77, 0x8ED5, 0x5E78, 0xD0D2, 0x5E79, 0x8ED6, 0x5E7A, 0xE7DB,\r\n\t0x5E7B, 0xBBC3, 0x5E7C, 0xD3D7, 0x5E7D, 0xD3C4, 0x5E7E, 0x8ED7,\t0x5E7F, 0xB9E3, 0x5E80, 0xE2CF, 0x5E81, 0x8ED8, 0x5E82, 0x8ED9,\r\n\t0x5E83, 0x8EDA, 0x5E84, 0xD7AF, 0x5E85, 0x8EDB, 0x5E86, 0xC7EC,\t0x5E87, 0xB1D3, 0x5E88, 0x8EDC, 0x5E89, 0x8EDD, 0x5E8A, 0xB4B2,\r\n\t0x5E8B, 0xE2D1, 0x5E8C, 0x8EDE, 0x5E8D, 0x8EDF, 0x5E8E, 0x8EE0,\t0x5E8F, 0xD0F2, 0x5E90, 0xC2AE, 0x5E91, 0xE2D0, 0x5E92, 0x8EE1,\r\n\t0x5E93, 0xBFE2, 0x5E94, 0xD3A6, 0x5E95, 0xB5D7, 0x5E96, 0xE2D2,\t0x5E97, 0xB5EA, 0x5E98, 0x8EE2, 0x5E99, 0xC3ED, 0x5E9A, 0xB8FD,\r\n\t0x5E9B, 0x8EE3, 0x5E9C, 0xB8AE, 0x5E9D, 0x8EE4, 0x5E9E, 0xC5D3,\t0x5E9F, 0xB7CF, 0x5EA0, 0xE2D4, 0x5EA1, 0x8EE5, 0x5EA2, 0x8EE6,\r\n\t0x5EA3, 0x8EE7, 0x5EA4, 0x8EE8, 0x5EA5, 0xE2D3, 0x5EA6, 0xB6C8,\t0x5EA7, 0xD7F9, 0x5EA8, 0x8EE9, 0x5EA9, 0x8EEA, 0x5EAA, 0x8EEB,\r\n\t0x5EAB, 0x8EEC, 0x5EAC, 0x8EED, 0x5EAD, 0xCDA5, 0x5EAE, 0x8EEE,\t0x5EAF, 0x8EEF, 0x5EB0, 0x8EF0, 0x5EB1, 0x8EF1, 0x5EB2, 0x8EF2,\r\n\t0x5EB3, 0xE2D8, 0x5EB4, 0x8EF3, 0x5EB5, 0xE2D6, 0x5EB6, 0xCAFC,\t0x5EB7, 0xBFB5, 0x5EB8, 0xD3B9, 0x5EB9, 0xE2D5, 0x5EBA, 0x8EF4,\r\n\t0x5EBB, 0x8EF5, 0x5EBC, 0x8EF6, 0x5EBD, 0x8EF7, 0x5EBE, 0xE2D7,\t0x5EBF, 0x8EF8, 0x5EC0, 0x8EF9, 0x5EC1, 0x8EFA, 0x5EC2, 0x8EFB,\r\n\t0x5EC3, 0x8EFC, 0x5EC4, 0x8EFD, 0x5EC5, 0x8EFE, 0x5EC6, 0x8F40,\t0x5EC7, 0x8F41, 0x5EC8, 0x8F42, 0x5EC9, 0xC1AE, 0x5ECA, 0xC0C8,\r\n\t0x5ECB, 0x8F43, 0x5ECC, 0x8F44, 0x5ECD, 0x8F45, 0x5ECE, 0x8F46,\t0x5ECF, 0x8F47, 0x5ED0, 0x8F48, 0x5ED1, 0xE2DB, 0x5ED2, 0xE2DA,\r\n\t0x5ED3, 0xC0AA, 0x5ED4, 0x8F49, 0x5ED5, 0x8F4A, 0x5ED6, 0xC1CE,\t0x5ED7, 0x8F4B, 0x5ED8, 0x8F4C, 0x5ED9, 0x8F4D, 0x5EDA, 0x8F4E,\r\n\t0x5EDB, 0xE2DC, 0x5EDC, 0x8F4F, 0x5EDD, 0x8F50, 0x5EDE, 0x8F51,\t0x5EDF, 0x8F52, 0x5EE0, 0x8F53, 0x5EE1, 0x8F54, 0x5EE2, 0x8F55,\r\n\t0x5EE3, 0x8F56, 0x5EE4, 0x8F57, 0x5EE5, 0x8F58, 0x5EE6, 0x8F59,\t0x5EE7, 0x8F5A, 0x5EE8, 0xE2DD, 0x5EE9, 0x8F5B, 0x5EEA, 0xE2DE,\r\n\t0x5EEB, 0x8F5C, 0x5EEC, 0x8F5D, 0x5EED, 0x8F5E, 0x5EEE, 0x8F5F,\t0x5EEF, 0x8F60, 0x5EF0, 0x8F61, 0x5EF1, 0x8F62, 0x5EF2, 0x8F63,\r\n\t0x5EF3, 0x8F64, 0x5EF4, 0xDBC8, 0x5EF5, 0x8F65, 0x5EF6, 0xD1D3,\t0x5EF7, 0xCDA2, 0x5EF8, 0x8F66, 0x5EF9, 0x8F67, 0x5EFA, 0xBDA8,\r\n\t0x5EFB, 0x8F68, 0x5EFC, 0x8F69, 0x5EFD, 0x8F6A, 0x5EFE, 0xDEC3,\t0x5EFF, 0xD8A5, 0x5F00, 0xBFAA, 0x5F01, 0xDBCD, 0x5F02, 0xD2EC,\r\n\t0x5F03, 0xC6FA, 0x5F04, 0xC5AA, 0x5F05, 0x8F6B, 0x5F06, 0x8F6C,\t0x5F07, 0x8F6D, 0x5F08, 0xDEC4, 0x5F09, 0x8F6E, 0x5F0A, 0xB1D7,\r\n\t0x5F0B, 0xDFAE, 0x5F0C, 0x8F6F, 0x5F0D, 0x8F70, 0x5F0E, 0x8F71,\t0x5F0F, 0xCABD, 0x5F10, 0x8F72, 0x5F11, 0xDFB1, 0x5F12, 0x8F73,\r\n\t0x5F13, 0xB9AD, 0x5F14, 0x8F74, 0x5F15, 0xD2FD, 0x5F16, 0x8F75,\t0x5F17, 0xB8A5, 0x5F18, 0xBAEB, 0x5F19, 0x8F76, 0x5F1A, 0x8F77,\r\n\t0x5F1B, 0xB3DA, 0x5F1C, 0x8F78, 0x5F1D, 0x8F79, 0x5F1E, 0x8F7A,\t0x5F1F, 0xB5DC, 0x5F20, 0xD5C5, 0x5F21, 0x8F7B, 0x5F22, 0x8F7C,\r\n\t0x5F23, 0x8F7D, 0x5F24, 0x8F7E, 0x5F25, 0xC3D6, 0x5F26, 0xCFD2,\t0x5F27, 0xBBA1, 0x5F28, 0x8F80, 0x5F29, 0xE5F3, 0x5F2A, 0xE5F2,\r\n\t0x5F2B, 0x8F81, 0x5F2C, 0x8F82, 0x5F2D, 0xE5F4, 0x5F2E, 0x8F83,\t0x5F2F, 0xCDE4, 0x5F30, 0x8F84, 0x5F31, 0xC8F5, 0x5F32, 0x8F85,\r\n\t0x5F33, 0x8F86, 0x5F34, 0x8F87, 0x5F35, 0x8F88, 0x5F36, 0x8F89,\t0x5F37, 0x8F8A, 0x5F38, 0x8F8B, 0x5F39, 0xB5AF, 0x5F3A, 0xC7BF,\r\n\t0x5F3B, 0x8F8C, 0x5F3C, 0xE5F6, 0x5F3D, 0x8F8D, 0x5F3E, 0x8F8E,\t0x5F3F, 0x8F8F, 0x5F40, 0xECB0, 0x5F41, 0x8F90, 0x5F42, 0x8F91,\r\n\t0x5F43, 0x8F92, 0x5F44, 0x8F93, 0x5F45, 0x8F94, 0x5F46, 0x8F95,\t0x5F47, 0x8F96, 0x5F48, 0x8F97, 0x5F49, 0x8F98, 0x5F4A, 0x8F99,\r\n\t0x5F4B, 0x8F9A, 0x5F4C, 0x8F9B, 0x5F4D, 0x8F9C, 0x5F4E, 0x8F9D,\t0x5F4F, 0x8F9E, 0x5F50, 0xE5E6, 0x5F51, 0x8F9F, 0x5F52, 0xB9E9,\r\n\t0x5F53, 0xB5B1, 0x5F54, 0x8FA0, 0x5F55, 0xC2BC, 0x5F56, 0xE5E8,\t0x5F57, 0xE5E7, 0x5F58, 0xE5E9, 0x5F59, 0x8FA1, 0x5F5A, 0x8FA2,\r\n\t0x5F5B, 0x8FA3, 0x5F5C, 0x8FA4, 0x5F5D, 0xD2CD, 0x5F5E, 0x8FA5,\t0x5F5F, 0x8FA6, 0x5F60, 0x8FA7, 0x5F61, 0xE1EA, 0x5F62, 0xD0CE,\r\n\t0x5F63, 0x8FA8, 0x5F64, 0xCDAE, 0x5F65, 0x8FA9, 0x5F66, 0xD1E5,\t0x5F67, 0x8FAA, 0x5F68, 0x8FAB, 0x5F69, 0xB2CA, 0x5F6A, 0xB1EB,\r\n\t0x5F6B, 0x8FAC, 0x5F6C, 0xB1F2, 0x5F6D, 0xC5ED, 0x5F6E, 0x8FAD,\t0x5F6F, 0x8FAE, 0x5F70, 0xD5C3, 0x5F71, 0xD3B0, 0x5F72, 0x8FAF,\r\n\t0x5F73, 0xE1DC, 0x5F74, 0x8FB0, 0x5F75, 0x8FB1, 0x5F76, 0x8FB2,\t0x5F77, 0xE1DD, 0x5F78, 0x8FB3, 0x5F79, 0xD2DB, 0x5F7A, 0x8FB4,\r\n\t0x5F7B, 0xB3B9, 0x5F7C, 0xB1CB, 0x5F7D, 0x8FB5, 0x5F7E, 0x8FB6,\t0x5F7F, 0x8FB7, 0x5F80, 0xCDF9, 0x5F81, 0xD5F7, 0x5F82, 0xE1DE,\r\n\t0x5F83, 0x8FB8, 0x5F84, 0xBEB6, 0x5F85, 0xB4FD, 0x5F86, 0x8FB9,\t0x5F87, 0xE1DF, 0x5F88, 0xBADC, 0x5F89, 0xE1E0, 0x5F8A, 0xBBB2,\r\n\t0x5F8B, 0xC2C9, 0x5F8C, 0xE1E1, 0x5F8D, 0x8FBA, 0x5F8E, 0x8FBB,\t0x5F8F, 0x8FBC, 0x5F90, 0xD0EC, 0x5F91, 0x8FBD, 0x5F92, 0xCDBD,\r\n\t0x5F93, 0x8FBE, 0x5F94, 0x8FBF, 0x5F95, 0xE1E2, 0x5F96, 0x8FC0,\t0x5F97, 0xB5C3, 0x5F98, 0xC5C7, 0x5F99, 0xE1E3, 0x5F9A, 0x8FC1,\r\n\t0x5F9B, 0x8FC2, 0x5F9C, 0xE1E4, 0x5F9D, 0x8FC3, 0x5F9E, 0x8FC4,\t0x5F9F, 0x8FC5, 0x5FA0, 0x8FC6, 0x5FA1, 0xD3F9, 0x5FA2, 0x8FC7,\r\n\t0x5FA3, 0x8FC8, 0x5FA4, 0x8FC9, 0x5FA5, 0x8FCA, 0x5FA6, 0x8FCB,\t0x5FA7, 0x8FCC, 0x5FA8, 0xE1E5, 0x5FA9, 0x8FCD, 0x5FAA, 0xD1AD,\r\n\t0x5FAB, 0x8FCE, 0x5FAC, 0x8FCF, 0x5FAD, 0xE1E6, 0x5FAE, 0xCEA2,\t0x5FAF, 0x8FD0, 0x5FB0, 0x8FD1, 0x5FB1, 0x8FD2, 0x5FB2, 0x8FD3,\r\n\t0x5FB3, 0x8FD4, 0x5FB4, 0x8FD5, 0x5FB5, 0xE1E7, 0x5FB6, 0x8FD6,\t0x5FB7, 0xB5C2, 0x5FB8, 0x8FD7, 0x5FB9, 0x8FD8, 0x5FBA, 0x8FD9,\r\n\t0x5FBB, 0x8FDA, 0x5FBC, 0xE1E8, 0x5FBD, 0xBBD5, 0x5FBE, 0x8FDB,\t0x5FBF, 0x8FDC, 0x5FC0, 0x8FDD, 0x5FC1, 0x8FDE, 0x5FC2, 0x8FDF,\r\n\t0x5FC3, 0xD0C4, 0x5FC4, 0xE2E0, 0x5FC5, 0xB1D8, 0x5FC6, 0xD2E4,\t0x5FC7, 0x8FE0, 0x5FC8, 0x8FE1, 0x5FC9, 0xE2E1, 0x5FCA, 0x8FE2,\r\n\t0x5FCB, 0x8FE3, 0x5FCC, 0xBCC9, 0x5FCD, 0xC8CC, 0x5FCE, 0x8FE4,\t0x5FCF, 0xE2E3, 0x5FD0, 0xECFE, 0x5FD1, 0xECFD, 0x5FD2, 0xDFAF,\r\n\t0x5FD3, 0x8FE5, 0x5FD4, 0x8FE6, 0x5FD5, 0x8FE7, 0x5FD6, 0xE2E2,\t0x5FD7, 0xD6BE, 0x5FD8, 0xCDFC, 0x5FD9, 0xC3A6, 0x5FDA, 0x8FE8,\r\n\t0x5FDB, 0x8FE9, 0x5FDC, 0x8FEA, 0x5FDD, 0xE3C3, 0x5FDE, 0x8FEB,\t0x5FDF, 0x8FEC, 0x5FE0, 0xD6D2, 0x5FE1, 0xE2E7, 0x5FE2, 0x8FED,\r\n\t0x5FE3, 0x8FEE, 0x5FE4, 0xE2E8, 0x5FE5, 0x8FEF, 0x5FE6, 0x8FF0,\t0x5FE7, 0xD3C7, 0x5FE8, 0x8FF1, 0x5FE9, 0x8FF2, 0x5FEA, 0xE2EC,\r\n\t0x5FEB, 0xBFEC, 0x5FEC, 0x8FF3, 0x5FED, 0xE2ED, 0x5FEE, 0xE2E5,\t0x5FEF, 0x8FF4, 0x5FF0, 0x8FF5, 0x5FF1, 0xB3C0, 0x5FF2, 0x8FF6,\r\n\t0x5FF3, 0x8FF7, 0x5FF4, 0x8FF8, 0x5FF5, 0xC4EE, 0x5FF6, 0x8FF9,\t0x5FF7, 0x8FFA, 0x5FF8, 0xE2EE, 0x5FF9, 0x8FFB, 0x5FFA, 0x8FFC,\r\n\t0x5FFB, 0xD0C3, 0x5FFC, 0x8FFD, 0x5FFD, 0xBAF6, 0x5FFE, 0xE2E9,\t0x5FFF, 0xB7DE, 0x6000, 0xBBB3, 0x6001, 0xCCAC, 0x6002, 0xCBCB,\r\n\t0x6003, 0xE2E4, 0x6004, 0xE2E6, 0x6005, 0xE2EA, 0x6006, 0xE2EB,\t0x6007, 0x8FFE, 0x6008, 0x9040, 0x6009, 0x9041, 0x600A, 0xE2F7,\r\n\t0x600B, 0x9042, 0x600C, 0x9043, 0x600D, 0xE2F4, 0x600E, 0xD4F5,\t0x600F, 0xE2F3, 0x6010, 0x9044, 0x6011, 0x9045, 0x6012, 0xC5AD,\r\n\t0x6013, 0x9046, 0x6014, 0xD5FA, 0x6015, 0xC5C2, 0x6016, 0xB2C0,\t0x6017, 0x9047, 0x6018, 0x9048, 0x6019, 0xE2EF, 0x601A, 0x9049,\r\n\t0x601B, 0xE2F2, 0x601C, 0xC1AF, 0x601D, 0xCBBC, 0x601E, 0x904A,\t0x601F, 0x904B, 0x6020, 0xB5A1, 0x6021, 0xE2F9, 0x6022, 0x904C,\r\n\t0x6023, 0x904D, 0x6024, 0x904E, 0x6025, 0xBCB1, 0x6026, 0xE2F1,\t0x6027, 0xD0D4, 0x6028, 0xD4B9, 0x6029, 0xE2F5, 0x602A, 0xB9D6,\r\n\t0x602B, 0xE2F6, 0x602C, 0x904F, 0x602D, 0x9050, 0x602E, 0x9051,\t0x602F, 0xC7D3, 0x6030, 0x9052, 0x6031, 0x9053, 0x6032, 0x9054,\r\n\t0x6033, 0x9055, 0x6034, 0x9056, 0x6035, 0xE2F0, 0x6036, 0x9057,\t0x6037, 0x9058, 0x6038, 0x9059, 0x6039, 0x905A, 0x603A, 0x905B,\r\n\t0x603B, 0xD7DC, 0x603C, 0xEDA1, 0x603D, 0x905C, 0x603E, 0x905D,\t0x603F, 0xE2F8, 0x6040, 0x905E, 0x6041, 0xEDA5, 0x6042, 0xE2FE,\r\n\t0x6043, 0xCAD1, 0x6044, 0x905F, 0x6045, 0x9060, 0x6046, 0x9061,\t0x6047, 0x9062, 0x6048, 0x9063, 0x6049, 0x9064, 0x604A, 0x9065,\r\n\t0x604B, 0xC1B5, 0x604C, 0x9066, 0x604D, 0xBBD0, 0x604E, 0x9067,\t0x604F, 0x9068, 0x6050, 0xBFD6, 0x6051, 0x9069, 0x6052, 0xBAE3,\r\n\t0x6053, 0x906A, 0x6054, 0x906B, 0x6055, 0xCBA1, 0x6056, 0x906C,\t0x6057, 0x906D, 0x6058, 0x906E, 0x6059, 0xEDA6, 0x605A, 0xEDA3,\r\n\t0x605B, 0x906F, 0x605C, 0x9070, 0x605D, 0xEDA2, 0x605E, 0x9071,\t0x605F, 0x9072, 0x6060, 0x9073, 0x6061, 0x9074, 0x6062, 0xBBD6,\r\n\t0x6063, 0xEDA7, 0x6064, 0xD0F4, 0x6065, 0x9075, 0x6066, 0x9076,\t0x6067, 0xEDA4, 0x6068, 0xBADE, 0x6069, 0xB6F7, 0x606A, 0xE3A1,\r\n\t0x606B, 0xB6B2, 0x606C, 0xCCF1, 0x606D, 0xB9A7, 0x606E, 0x9077,\t0x606F, 0xCFA2, 0x6070, 0xC7A1, 0x6071, 0x9078, 0x6072, 0x9079,\r\n\t0x6073, 0xBFD2, 0x6074, 0x907A, 0x6075, 0x907B, 0x6076, 0xB6F1,\t0x6077, 0x907C, 0x6078, 0xE2FA, 0x6079, 0xE2FB, 0x607A, 0xE2FD,\r\n\t0x607B, 0xE2FC, 0x607C, 0xC4D5, 0x607D, 0xE3A2, 0x607E, 0x907D,\t0x607F, 0xD3C1, 0x6080, 0x907E, 0x6081, 0x9080, 0x6082, 0x9081,\r\n\t0x6083, 0xE3A7, 0x6084, 0xC7C4, 0x6085, 0x9082, 0x6086, 0x9083,\t0x6087, 0x9084, 0x6088, 0x9085, 0x6089, 0xCFA4, 0x608A, 0x9086,\r\n\t0x608B, 0x9087, 0x608C, 0xE3A9, 0x608D, 0xBAB7, 0x608E, 0x9088,\t0x608F, 0x9089, 0x6090, 0x908A, 0x6091, 0x908B, 0x6092, 0xE3A8,\r\n\t0x6093, 0x908C, 0x6094, 0xBBDA, 0x6095, 0x908D, 0x6096, 0xE3A3,\t0x6097, 0x908E, 0x6098, 0x908F, 0x6099, 0x9090, 0x609A, 0xE3A4,\r\n\t0x609B, 0xE3AA, 0x609C, 0x9091, 0x609D, 0xE3A6, 0x609E, 0x9092,\t0x609F, 0xCEF2, 0x60A0, 0xD3C6, 0x60A1, 0x9093, 0x60A2, 0x9094,\r\n\t0x60A3, 0xBBBC, 0x60A4, 0x9095, 0x60A5, 0x9096, 0x60A6, 0xD4C3,\t0x60A7, 0x9097, 0x60A8, 0xC4FA, 0x60A9, 0x9098, 0x60AA, 0x9099,\r\n\t0x60AB, 0xEDA8, 0x60AC, 0xD0FC, 0x60AD, 0xE3A5, 0x60AE, 0x909A,\t0x60AF, 0xC3F5, 0x60B0, 0x909B, 0x60B1, 0xE3AD, 0x60B2, 0xB1AF,\r\n\t0x60B3, 0x909C, 0x60B4, 0xE3B2, 0x60B5, 0x909D, 0x60B6, 0x909E,\t0x60B7, 0x909F, 0x60B8, 0xBCC2, 0x60B9, 0x90A0, 0x60BA, 0x90A1,\r\n\t0x60BB, 0xE3AC, 0x60BC, 0xB5BF, 0x60BD, 0x90A2, 0x60BE, 0x90A3,\t0x60BF, 0x90A4, 0x60C0, 0x90A5, 0x60C1, 0x90A6, 0x60C2, 0x90A7,\r\n\t0x60C3, 0x90A8, 0x60C4, 0x90A9, 0x60C5, 0xC7E9, 0x60C6, 0xE3B0,\t0x60C7, 0x90AA, 0x60C8, 0x90AB, 0x60C9, 0x90AC, 0x60CA, 0xBEAA,\r\n\t0x60CB, 0xCDEF, 0x60CC, 0x90AD, 0x60CD, 0x90AE, 0x60CE, 0x90AF,\t0x60CF, 0x90B0, 0x60D0, 0x90B1, 0x60D1, 0xBBF3, 0x60D2, 0x90B2,\r\n\t0x60D3, 0x90B3, 0x60D4, 0x90B4, 0x60D5, 0xCCE8, 0x60D6, 0x90B5,\t0x60D7, 0x90B6, 0x60D8, 0xE3AF, 0x60D9, 0x90B7, 0x60DA, 0xE3B1,\r\n\t0x60DB, 0x90B8, 0x60DC, 0xCFA7, 0x60DD, 0xE3AE, 0x60DE, 0x90B9,\t0x60DF, 0xCEA9, 0x60E0, 0xBBDD, 0x60E1, 0x90BA, 0x60E2, 0x90BB,\r\n\t0x60E3, 0x90BC, 0x60E4, 0x90BD, 0x60E5, 0x90BE, 0x60E6, 0xB5EB,\t0x60E7, 0xBEE5, 0x60E8, 0xB2D2, 0x60E9, 0xB3CD, 0x60EA, 0x90BF,\r\n\t0x60EB, 0xB1B9, 0x60EC, 0xE3AB, 0x60ED, 0xB2D1, 0x60EE, 0xB5AC,\t0x60EF, 0xB9DF, 0x60F0, 0xB6E8, 0x60F1, 0x90C0, 0x60F2, 0x90C1,\r\n\t0x60F3, 0xCFEB, 0x60F4, 0xE3B7, 0x60F5, 0x90C2, 0x60F6, 0xBBCC,\t0x60F7, 0x90C3, 0x60F8, 0x90C4, 0x60F9, 0xC8C7, 0x60FA, 0xD0CA,\r\n\t0x60FB, 0x90C5, 0x60FC, 0x90C6, 0x60FD, 0x90C7, 0x60FE, 0x90C8,\t0x60FF, 0x90C9, 0x6100, 0xE3B8, 0x6101, 0xB3EE, 0x6102, 0x90CA,\r\n\t0x6103, 0x90CB, 0x6104, 0x90CC, 0x6105, 0x90CD, 0x6106, 0xEDA9,\t0x6107, 0x90CE, 0x6108, 0xD3FA, 0x6109, 0xD3E4, 0x610A, 0x90CF,\r\n\t0x610B, 0x90D0, 0x610C, 0x90D1, 0x610D, 0xEDAA, 0x610E, 0xE3B9,\t0x610F, 0xD2E2, 0x6110, 0x90D2, 0x6111, 0x90D3, 0x6112, 0x90D4,\r\n\t0x6113, 0x90D5, 0x6114, 0x90D6, 0x6115, 0xE3B5, 0x6116, 0x90D7,\t0x6117, 0x90D8, 0x6118, 0x90D9, 0x6119, 0x90DA, 0x611A, 0xD3DE,\r\n\t0x611B, 0x90DB, 0x611C, 0x90DC, 0x611D, 0x90DD, 0x611E, 0x90DE,\t0x611F, 0xB8D0, 0x6120, 0xE3B3, 0x6121, 0x90DF, 0x6122, 0x90E0,\r\n\t0x6123, 0xE3B6, 0x6124, 0xB7DF, 0x6125, 0x90E1, 0x6126, 0xE3B4,\t0x6127, 0xC0A2, 0x6128, 0x90E2, 0x6129, 0x90E3, 0x612A, 0x90E4,\r\n\t0x612B, 0xE3BA, 0x612C, 0x90E5, 0x612D, 0x90E6, 0x612E, 0x90E7,\t0x612F, 0x90E8, 0x6130, 0x90E9, 0x6131, 0x90EA, 0x6132, 0x90EB,\r\n\t0x6133, 0x90EC, 0x6134, 0x90ED, 0x6135, 0x90EE, 0x6136, 0x90EF,\t0x6137, 0x90F0, 0x6138, 0x90F1, 0x6139, 0x90F2, 0x613A, 0x90F3,\r\n\t0x613B, 0x90F4, 0x613C, 0x90F5, 0x613D, 0x90F6, 0x613E, 0x90F7,\t0x613F, 0xD4B8, 0x6140, 0x90F8, 0x6141, 0x90F9, 0x6142, 0x90FA,\r\n\t0x6143, 0x90FB, 0x6144, 0x90FC, 0x6145, 0x90FD, 0x6146, 0x90FE,\t0x6147, 0x9140, 0x6148, 0xB4C8, 0x6149, 0x9141, 0x614A, 0xE3BB,\r\n\t0x614B, 0x9142, 0x614C, 0xBBC5, 0x614D, 0x9143, 0x614E, 0xC9F7,\t0x614F, 0x9144, 0x6150, 0x9145, 0x6151, 0xC9E5, 0x6152, 0x9146,\r\n\t0x6153, 0x9147, 0x6154, 0x9148, 0x6155, 0xC4BD, 0x6156, 0x9149,\t0x6157, 0x914A, 0x6158, 0x914B, 0x6159, 0x914C, 0x615A, 0x914D,\r\n\t0x615B, 0x914E, 0x615C, 0x914F, 0x615D, 0xEDAB, 0x615E, 0x9150,\t0x615F, 0x9151, 0x6160, 0x9152, 0x6161, 0x9153, 0x6162, 0xC2FD,\r\n\t0x6163, 0x9154, 0x6164, 0x9155, 0x6165, 0x9156, 0x6166, 0x9157,\t0x6167, 0xBBDB, 0x6168, 0xBFAE, 0x6169, 0x9158, 0x616A, 0x9159,\r\n\t0x616B, 0x915A, 0x616C, 0x915B, 0x616D, 0x915C, 0x616E, 0x915D,\t0x616F, 0x915E, 0x6170, 0xCEBF, 0x6171, 0x915F, 0x6172, 0x9160,\r\n\t0x6173, 0x9161, 0x6174, 0x9162, 0x6175, 0xE3BC, 0x6176, 0x9163,\t0x6177, 0xBFB6, 0x6178, 0x9164, 0x6179, 0x9165, 0x617A, 0x9166,\r\n\t0x617B, 0x9167, 0x617C, 0x9168, 0x617D, 0x9169, 0x617E, 0x916A,\t0x617F, 0x916B, 0x6180, 0x916C, 0x6181, 0x916D, 0x6182, 0x916E,\r\n\t0x6183, 0x916F, 0x6184, 0x9170, 0x6185, 0x9171, 0x6186, 0x9172,\t0x6187, 0x9173, 0x6188, 0x9174, 0x6189, 0x9175, 0x618A, 0x9176,\r\n\t0x618B, 0xB1EF, 0x618C, 0x9177, 0x618D, 0x9178, 0x618E, 0xD4F7,\t0x618F, 0x9179, 0x6190, 0x917A, 0x6191, 0x917B, 0x6192, 0x917C,\r\n\t0x6193, 0x917D, 0x6194, 0xE3BE, 0x6195, 0x917E, 0x6196, 0x9180,\t0x6197, 0x9181, 0x6198, 0x9182, 0x6199, 0x9183, 0x619A, 0x9184,\r\n\t0x619B, 0x9185, 0x619C, 0x9186, 0x619D, 0xEDAD, 0x619E, 0x9187,\t0x619F, 0x9188, 0x61A0, 0x9189, 0x61A1, 0x918A, 0x61A2, 0x918B,\r\n\t0x61A3, 0x918C, 0x61A4, 0x918D, 0x61A5, 0x918E, 0x61A6, 0x918F,\t0x61A7, 0xE3BF, 0x61A8, 0xBAA9, 0x61A9, 0xEDAC, 0x61AA, 0x9190,\r\n\t0x61AB, 0x9191, 0x61AC, 0xE3BD, 0x61AD, 0x9192, 0x61AE, 0x9193,\t0x61AF, 0x9194, 0x61B0, 0x9195, 0x61B1, 0x9196, 0x61B2, 0x9197,\r\n\t0x61B3, 0x9198, 0x61B4, 0x9199, 0x61B5, 0x919A, 0x61B6, 0x919B,\t0x61B7, 0xE3C0, 0x61B8, 0x919C, 0x61B9, 0x919D, 0x61BA, 0x919E,\r\n\t0x61BB, 0x919F, 0x61BC, 0x91A0, 0x61BD, 0x91A1, 0x61BE, 0xBAB6,\t0x61BF, 0x91A2, 0x61C0, 0x91A3, 0x61C1, 0x91A4, 0x61C2, 0xB6AE,\r\n\t0x61C3, 0x91A5, 0x61C4, 0x91A6, 0x61C5, 0x91A7, 0x61C6, 0x91A8,\t0x61C7, 0x91A9, 0x61C8, 0xD0B8, 0x61C9, 0x91AA, 0x61CA, 0xB0C3,\r\n\t0x61CB, 0xEDAE, 0x61CC, 0x91AB, 0x61CD, 0x91AC, 0x61CE, 0x91AD,\t0x61CF, 0x91AE, 0x61D0, 0x91AF, 0x61D1, 0xEDAF, 0x61D2, 0xC0C1,\r\n\t0x61D3, 0x91B0, 0x61D4, 0xE3C1, 0x61D5, 0x91B1, 0x61D6, 0x91B2,\t0x61D7, 0x91B3, 0x61D8, 0x91B4, 0x61D9, 0x91B5, 0x61DA, 0x91B6,\r\n\t0x61DB, 0x91B7, 0x61DC, 0x91B8, 0x61DD, 0x91B9, 0x61DE, 0x91BA,\t0x61DF, 0x91BB, 0x61E0, 0x91BC, 0x61E1, 0x91BD, 0x61E2, 0x91BE,\r\n\t0x61E3, 0x91BF, 0x61E4, 0x91C0, 0x61E5, 0x91C1, 0x61E6, 0xC5B3,\t0x61E7, 0x91C2, 0x61E8, 0x91C3, 0x61E9, 0x91C4, 0x61EA, 0x91C5,\r\n\t0x61EB, 0x91C6, 0x61EC, 0x91C7, 0x61ED, 0x91C8, 0x61EE, 0x91C9,\t0x61EF, 0x91CA, 0x61F0, 0x91CB, 0x61F1, 0x91CC, 0x61F2, 0x91CD,\r\n\t0x61F3, 0x91CE, 0x61F4, 0x91CF, 0x61F5, 0xE3C2, 0x61F6, 0x91D0,\t0x61F7, 0x91D1, 0x61F8, 0x91D2, 0x61F9, 0x91D3, 0x61FA, 0x91D4,\r\n\t0x61FB, 0x91D5, 0x61FC, 0x91D6, 0x61FD, 0x91D7, 0x61FE, 0x91D8,\t0x61FF, 0xDCB2, 0x6200, 0x91D9, 0x6201, 0x91DA, 0x6202, 0x91DB,\r\n\t0x6203, 0x91DC, 0x6204, 0x91DD, 0x6205, 0x91DE, 0x6206, 0xEDB0,\t0x6207, 0x91DF, 0x6208, 0xB8EA, 0x6209, 0x91E0, 0x620A, 0xCEEC,\r\n\t0x620B, 0xEAA7, 0x620C, 0xD0E7, 0x620D, 0xCAF9, 0x620E, 0xC8D6,\t0x620F, 0xCFB7, 0x6210, 0xB3C9, 0x6211, 0xCED2, 0x6212, 0xBDE4,\r\n\t0x6213, 0x91E1, 0x6214, 0x91E2, 0x6215, 0xE3DE, 0x6216, 0xBBF2,\t0x6217, 0xEAA8, 0x6218, 0xD5BD, 0x6219, 0x91E3, 0x621A, 0xC6DD,\r\n\t0x621B, 0xEAA9, 0x621C, 0x91E4, 0x621D, 0x91E5, 0x621E, 0x91E6,\t0x621F, 0xEAAA, 0x6220, 0x91E7, 0x6221, 0xEAAC, 0x6222, 0xEAAB,\r\n\t0x6223, 0x91E8, 0x6224, 0xEAAE, 0x6225, 0xEAAD, 0x6226, 0x91E9,\t0x6227, 0x91EA, 0x6228, 0x91EB, 0x6229, 0x91EC, 0x622A, 0xBDD8,\r\n\t0x622B, 0x91ED, 0x622C, 0xEAAF, 0x622D, 0x91EE, 0x622E, 0xC2BE,\t0x622F, 0x91EF, 0x6230, 0x91F0, 0x6231, 0x91F1, 0x6232, 0x91F2,\r\n\t0x6233, 0xB4C1, 0x6234, 0xB4F7, 0x6235, 0x91F3, 0x6236, 0x91F4,\t0x6237, 0xBBA7, 0x6238, 0x91F5, 0x6239, 0x91F6, 0x623A, 0x91F7,\r\n\t0x623B, 0x91F8, 0x623C, 0x91F9, 0x623D, 0xECE6, 0x623E, 0xECE5,\t0x623F, 0xB7BF, 0x6240, 0xCBF9, 0x6241, 0xB1E2, 0x6242, 0x91FA,\r\n\t0x6243, 0xECE7, 0x6244, 0x91FB, 0x6245, 0x91FC, 0x6246, 0x91FD,\t0x6247, 0xC9C8, 0x6248, 0xECE8, 0x6249, 0xECE9, 0x624A, 0x91FE,\r\n\t0x624B, 0xCAD6, 0x624C, 0xDED0, 0x624D, 0xB2C5, 0x624E, 0xD4FA,\t0x624F, 0x9240, 0x6250, 0x9241, 0x6251, 0xC6CB, 0x6252, 0xB0C7,\r\n\t0x6253, 0xB4F2, 0x6254, 0xC8D3, 0x6255, 0x9242, 0x6256, 0x9243,\t0x6257, 0x9244, 0x6258, 0xCDD0, 0x6259, 0x9245, 0x625A, 0x9246,\r\n\t0x625B, 0xBFB8, 0x625C, 0x9247, 0x625D, 0x9248, 0x625E, 0x9249,\t0x625F, 0x924A, 0x6260, 0x924B, 0x6261, 0x924C, 0x6262, 0x924D,\r\n\t0x6263, 0xBFDB, 0x6264, 0x924E, 0x6265, 0x924F, 0x6266, 0xC7A4,\t0x6267, 0xD6B4, 0x6268, 0x9250, 0x6269, 0xC0A9, 0x626A, 0xDED1,\r\n\t0x626B, 0xC9A8, 0x626C, 0xD1EF, 0x626D, 0xC5A4, 0x626E, 0xB0E7,\t0x626F, 0xB3B6, 0x6270, 0xC8C5, 0x6271, 0x9251, 0x6272, 0x9252,\r\n\t0x6273, 0xB0E2, 0x6274, 0x9253, 0x6275, 0x9254, 0x6276, 0xB7F6,\t0x6277, 0x9255, 0x6278, 0x9256, 0x6279, 0xC5FA, 0x627A, 0x9257,\r\n\t0x627B, 0x9258, 0x627C, 0xB6F3, 0x627D, 0x9259, 0x627E, 0xD5D2,\t0x627F, 0xB3D0, 0x6280, 0xBCBC, 0x6281, 0x925A, 0x6282, 0x925B,\r\n\t0x6283, 0x925C, 0x6284, 0xB3AD, 0x6285, 0x925D, 0x6286, 0x925E,\t0x6287, 0x925F, 0x6288, 0x9260, 0x6289, 0xBEF1, 0x628A, 0xB0D1,\r\n\t0x628B, 0x9261, 0x628C, 0x9262, 0x628D, 0x9263, 0x628E, 0x9264,\t0x628F, 0x9265, 0x6290, 0x9266, 0x6291, 0xD2D6, 0x6292, 0xCAE3,\r\n\t0x6293, 0xD7A5, 0x6294, 0x9267, 0x6295, 0xCDB6, 0x6296, 0xB6B6,\t0x6297, 0xBFB9, 0x6298, 0xD5DB, 0x6299, 0x9268, 0x629A, 0xB8A7,\r\n\t0x629B, 0xC5D7, 0x629C, 0x9269, 0x629D, 0x926A, 0x629E, 0x926B,\t0x629F, 0xDED2, 0x62A0, 0xBFD9, 0x62A1, 0xC2D5, 0x62A2, 0xC7C0,\r\n\t0x62A3, 0x926C, 0x62A4, 0xBBA4, 0x62A5, 0xB1A8, 0x62A6, 0x926D,\t0x62A7, 0x926E, 0x62A8, 0xC5EA, 0x62A9, 0x926F, 0x62AA, 0x9270,\r\n\t0x62AB, 0xC5FB, 0x62AC, 0xCCA7, 0x62AD, 0x9271, 0x62AE, 0x9272,\t0x62AF, 0x9273, 0x62B0, 0x9274, 0x62B1, 0xB1A7, 0x62B2, 0x9275,\r\n\t0x62B3, 0x9276, 0x62B4, 0x9277, 0x62B5, 0xB5D6, 0x62B6, 0x9278,\t0x62B7, 0x9279, 0x62B8, 0x927A, 0x62B9, 0xC4A8, 0x62BA, 0x927B,\r\n\t0x62BB, 0xDED3, 0x62BC, 0xD1BA, 0x62BD, 0xB3E9, 0x62BE, 0x927C,\t0x62BF, 0xC3F2, 0x62C0, 0x927D, 0x62C1, 0x927E, 0x62C2, 0xB7F7,\r\n\t0x62C3, 0x9280, 0x62C4, 0xD6F4, 0x62C5, 0xB5A3, 0x62C6, 0xB2F0,\t0x62C7, 0xC4B4, 0x62C8, 0xC4E9, 0x62C9, 0xC0AD, 0x62CA, 0xDED4,\r\n\t0x62CB, 0x9281, 0x62CC, 0xB0E8, 0x62CD, 0xC5C4, 0x62CE, 0xC1E0,\t0x62CF, 0x9282, 0x62D0, 0xB9D5, 0x62D1, 0x9283, 0x62D2, 0xBEDC,\r\n\t0x62D3, 0xCDD8, 0x62D4, 0xB0CE, 0x62D5, 0x9284, 0x62D6, 0xCDCF,\t0x62D7, 0xDED6, 0x62D8, 0xBED0, 0x62D9, 0xD7BE, 0x62DA, 0xDED5,\r\n\t0x62DB, 0xD5D0, 0x62DC, 0xB0DD, 0x62DD, 0x9285, 0x62DE, 0x9286,\t0x62DF, 0xC4E2, 0x62E0, 0x9287, 0x62E1, 0x9288, 0x62E2, 0xC2A3,\r\n\t0x62E3, 0xBCF0, 0x62E4, 0x9289, 0x62E5, 0xD3B5, 0x62E6, 0xC0B9,\t0x62E7, 0xC5A1, 0x62E8, 0xB2A6, 0x62E9, 0xD4F1, 0x62EA, 0x928A,\r\n\t0x62EB, 0x928B, 0x62EC, 0xC0A8, 0x62ED, 0xCAC3, 0x62EE, 0xDED7,\t0x62EF, 0xD5FC, 0x62F0, 0x928C, 0x62F1, 0xB9B0, 0x62F2, 0x928D,\r\n\t0x62F3, 0xC8AD, 0x62F4, 0xCBA9, 0x62F5, 0x928E, 0x62F6, 0xDED9,\t0x62F7, 0xBFBD, 0x62F8, 0x928F, 0x62F9, 0x9290, 0x62FA, 0x9291,\r\n\t0x62FB, 0x9292, 0x62FC, 0xC6B4, 0x62FD, 0xD7A7, 0x62FE, 0xCAB0,\t0x62FF, 0xC4C3, 0x6300, 0x9293, 0x6301, 0xB3D6, 0x6302, 0xB9D2,\r\n\t0x6303, 0x9294, 0x6304, 0x9295, 0x6305, 0x9296, 0x6306, 0x9297,\t0x6307, 0xD6B8, 0x6308, 0xEAFC, 0x6309, 0xB0B4, 0x630A, 0x9298,\r\n\t0x630B, 0x9299, 0x630C, 0x929A, 0x630D, 0x929B, 0x630E, 0xBFE6,\t0x630F, 0x929C, 0x6310, 0x929D, 0x6311, 0xCCF4, 0x6312, 0x929E,\r\n\t0x6313, 0x929F, 0x6314, 0x92A0, 0x6315, 0x92A1, 0x6316, 0xCDDA,\t0x6317, 0x92A2, 0x6318, 0x92A3, 0x6319, 0x92A4, 0x631A, 0xD6BF,\r\n\t0x631B, 0xC2CE, 0x631C, 0x92A5, 0x631D, 0xCECE, 0x631E, 0xCCA2,\t0x631F, 0xD0AE, 0x6320, 0xC4D3, 0x6321, 0xB5B2, 0x6322, 0xDED8,\r\n\t0x6323, 0xD5F5, 0x6324, 0xBCB7, 0x6325, 0xBBD3, 0x6326, 0x92A6,\t0x6327, 0x92A7, 0x6328, 0xB0A4, 0x6329, 0x92A8, 0x632A, 0xC5B2,\r\n\t0x632B, 0xB4EC, 0x632C, 0x92A9, 0x632D, 0x92AA, 0x632E, 0x92AB,\t0x632F, 0xD5F1, 0x6330, 0x92AC, 0x6331, 0x92AD, 0x6332, 0xEAFD,\r\n\t0x6333, 0x92AE, 0x6334, 0x92AF, 0x6335, 0x92B0, 0x6336, 0x92B1,\t0x6337, 0x92B2, 0x6338, 0x92B3, 0x6339, 0xDEDA, 0x633A, 0xCDA6,\r\n\t0x633B, 0x92B4, 0x633C, 0x92B5, 0x633D, 0xCDEC, 0x633E, 0x92B6,\t0x633F, 0x92B7, 0x6340, 0x92B8, 0x6341, 0x92B9, 0x6342, 0xCEE6,\r\n\t0x6343, 0xDEDC, 0x6344, 0x92BA, 0x6345, 0xCDB1, 0x6346, 0xC0A6,\t0x6347, 0x92BB, 0x6348, 0x92BC, 0x6349, 0xD7BD, 0x634A, 0x92BD,\r\n\t0x634B, 0xDEDB, 0x634C, 0xB0C6, 0x634D, 0xBAB4, 0x634E, 0xC9D3,\t0x634F, 0xC4F3, 0x6350, 0xBEE8, 0x6351, 0x92BE, 0x6352, 0x92BF,\r\n\t0x6353, 0x92C0, 0x6354, 0x92C1, 0x6355, 0xB2B6, 0x6356, 0x92C2,\t0x6357, 0x92C3, 0x6358, 0x92C4, 0x6359, 0x92C5, 0x635A, 0x92C6,\r\n\t0x635B, 0x92C7, 0x635C, 0x92C8, 0x635D, 0x92C9, 0x635E, 0xC0CC,\t0x635F, 0xCBF0, 0x6360, 0x92CA, 0x6361, 0xBCF1, 0x6362, 0xBBBB,\r\n\t0x6363, 0xB5B7, 0x6364, 0x92CB, 0x6365, 0x92CC, 0x6366, 0x92CD,\t0x6367, 0xC5F5, 0x6368, 0x92CE, 0x6369, 0xDEE6, 0x636A, 0x92CF,\r\n\t0x636B, 0x92D0, 0x636C, 0x92D1, 0x636D, 0xDEE3, 0x636E, 0xBEDD,\t0x636F, 0x92D2, 0x6370, 0x92D3, 0x6371, 0xDEDF, 0x6372, 0x92D4,\r\n\t0x6373, 0x92D5, 0x6374, 0x92D6, 0x6375, 0x92D7, 0x6376, 0xB4B7,\t0x6377, 0xBDDD, 0x6378, 0x92D8, 0x6379, 0x92D9, 0x637A, 0xDEE0,\r\n\t0x637B, 0xC4ED, 0x637C, 0x92DA, 0x637D, 0x92DB, 0x637E, 0x92DC,\t0x637F, 0x92DD, 0x6380, 0xCFC6, 0x6381, 0x92DE, 0x6382, 0xB5E0,\r\n\t0x6383, 0x92DF, 0x6384, 0x92E0, 0x6385, 0x92E1, 0x6386, 0x92E2,\t0x6387, 0xB6DE, 0x6388, 0xCADA, 0x6389, 0xB5F4, 0x638A, 0xDEE5,\r\n\t0x638B, 0x92E3, 0x638C, 0xD5C6, 0x638D, 0x92E4, 0x638E, 0xDEE1,\t0x638F, 0xCCCD, 0x6390, 0xC6FE, 0x6391, 0x92E5, 0x6392, 0xC5C5,\r\n\t0x6393, 0x92E6, 0x6394, 0x92E7, 0x6395, 0x92E8, 0x6396, 0xD2B4,\t0x6397, 0x92E9, 0x6398, 0xBEF2, 0x6399, 0x92EA, 0x639A, 0x92EB,\r\n\t0x639B, 0x92EC, 0x639C, 0x92ED, 0x639D, 0x92EE, 0x639E, 0x92EF,\t0x639F, 0x92F0, 0x63A0, 0xC2D3, 0x63A1, 0x92F1, 0x63A2, 0xCCBD,\r\n\t0x63A3, 0xB3B8, 0x63A4, 0x92F2, 0x63A5, 0xBDD3, 0x63A6, 0x92F3,\t0x63A7, 0xBFD8, 0x63A8, 0xCDC6, 0x63A9, 0xD1DA, 0x63AA, 0xB4EB,\r\n\t0x63AB, 0x92F4, 0x63AC, 0xDEE4, 0x63AD, 0xDEDD, 0x63AE, 0xDEE7,\t0x63AF, 0x92F5, 0x63B0, 0xEAFE, 0x63B1, 0x92F6, 0x63B2, 0x92F7,\r\n\t0x63B3, 0xC2B0, 0x63B4, 0xDEE2, 0x63B5, 0x92F8, 0x63B6, 0x92F9,\t0x63B7, 0xD6C0, 0x63B8, 0xB5A7, 0x63B9, 0x92FA, 0x63BA, 0xB2F4,\r\n\t0x63BB, 0x92FB, 0x63BC, 0xDEE8, 0x63BD, 0x92FC, 0x63BE, 0xDEF2,\t0x63BF, 0x92FD, 0x63C0, 0x92FE, 0x63C1, 0x9340, 0x63C2, 0x9341,\r\n\t0x63C3, 0x9342, 0x63C4, 0xDEED, 0x63C5, 0x9343, 0x63C6, 0xDEF1,\t0x63C7, 0x9344, 0x63C8, 0x9345, 0x63C9, 0xC8E0, 0x63CA, 0x9346,\r\n\t0x63CB, 0x9347, 0x63CC, 0x9348, 0x63CD, 0xD7E1, 0x63CE, 0xDEEF,\t0x63CF, 0xC3E8, 0x63D0, 0xCCE1, 0x63D1, 0x9349, 0x63D2, 0xB2E5,\r\n\t0x63D3, 0x934A, 0x63D4, 0x934B, 0x63D5, 0x934C, 0x63D6, 0xD2BE,\t0x63D7, 0x934D, 0x63D8, 0x934E, 0x63D9, 0x934F, 0x63DA, 0x9350,\r\n\t0x63DB, 0x9351, 0x63DC, 0x9352, 0x63DD, 0x9353, 0x63DE, 0xDEEE,\t0x63DF, 0x9354, 0x63E0, 0xDEEB, 0x63E1, 0xCED5, 0x63E2, 0x9355,\r\n\t0x63E3, 0xB4A7, 0x63E4, 0x9356, 0x63E5, 0x9357, 0x63E6, 0x9358,\t0x63E7, 0x9359, 0x63E8, 0x935A, 0x63E9, 0xBFAB, 0x63EA, 0xBEBE,\r\n\t0x63EB, 0x935B, 0x63EC, 0x935C, 0x63ED, 0xBDD2, 0x63EE, 0x935D,\t0x63EF, 0x935E, 0x63F0, 0x935F, 0x63F1, 0x9360, 0x63F2, 0xDEE9,\r\n\t0x63F3, 0x9361, 0x63F4, 0xD4AE, 0x63F5, 0x9362, 0x63F6, 0xDEDE,\t0x63F7, 0x9363, 0x63F8, 0xDEEA, 0x63F9, 0x9364, 0x63FA, 0x9365,\r\n\t0x63FB, 0x9366, 0x63FC, 0x9367, 0x63FD, 0xC0BF, 0x63FE, 0x9368,\t0x63FF, 0xDEEC, 0x6400, 0xB2F3, 0x6401, 0xB8E9, 0x6402, 0xC2A7,\r\n\t0x6403, 0x9369, 0x6404, 0x936A, 0x6405, 0xBDC1, 0x6406, 0x936B,\t0x6407, 0x936C, 0x6408, 0x936D, 0x6409, 0x936E, 0x640A, 0x936F,\r\n\t0x640B, 0xDEF5, 0x640C, 0xDEF8, 0x640D, 0x9370, 0x640E, 0x9371,\t0x640F, 0xB2AB, 0x6410, 0xB4A4, 0x6411, 0x9372, 0x6412, 0x9373,\r\n\t0x6413, 0xB4EA, 0x6414, 0xC9A6, 0x6415, 0x9374, 0x6416, 0x9375,\t0x6417, 0x9376, 0x6418, 0x9377, 0x6419, 0x9378, 0x641A, 0x9379,\r\n\t0x641B, 0xDEF6, 0x641C, 0xCBD1, 0x641D, 0x937A, 0x641E, 0xB8E3,\t0x641F, 0x937B, 0x6420, 0xDEF7, 0x6421, 0xDEFA, 0x6422, 0x937C,\r\n\t0x6423, 0x937D, 0x6424, 0x937E, 0x6425, 0x9380, 0x6426, 0xDEF9,\t0x6427, 0x9381, 0x6428, 0x9382, 0x6429, 0x9383, 0x642A, 0xCCC2,\r\n\t0x642B, 0x9384, 0x642C, 0xB0E1, 0x642D, 0xB4EE, 0x642E, 0x9385,\t0x642F, 0x9386, 0x6430, 0x9387, 0x6431, 0x9388, 0x6432, 0x9389,\r\n\t0x6433, 0x938A, 0x6434, 0xE5BA, 0x6435, 0x938B, 0x6436, 0x938C,\t0x6437, 0x938D, 0x6438, 0x938E, 0x6439, 0x938F, 0x643A, 0xD0AF,\r\n\t0x643B, 0x9390, 0x643C, 0x9391, 0x643D, 0xB2EB, 0x643E, 0x9392,\t0x643F, 0xEBA1, 0x6440, 0x9393, 0x6441, 0xDEF4, 0x6442, 0x9394,\r\n\t0x6443, 0x9395, 0x6444, 0xC9E3, 0x6445, 0xDEF3, 0x6446, 0xB0DA,\t0x6447, 0xD2A1, 0x6448, 0xB1F7, 0x6449, 0x9396, 0x644A, 0xCCAF,\r\n\t0x644B, 0x9397, 0x644C, 0x9398, 0x644D, 0x9399, 0x644E, 0x939A,\t0x644F, 0x939B, 0x6450, 0x939C, 0x6451, 0x939D, 0x6452, 0xDEF0,\r\n\t0x6453, 0x939E, 0x6454, 0xCBA4, 0x6455, 0x939F, 0x6456, 0x93A0,\t0x6457, 0x93A1, 0x6458, 0xD5AA, 0x6459, 0x93A2, 0x645A, 0x93A3,\r\n\t0x645B, 0x93A4, 0x645C, 0x93A5, 0x645D, 0x93A6, 0x645E, 0xDEFB,\t0x645F, 0x93A7, 0x6460, 0x93A8, 0x6461, 0x93A9, 0x6462, 0x93AA,\r\n\t0x6463, 0x93AB, 0x6464, 0x93AC, 0x6465, 0x93AD, 0x6466, 0x93AE,\t0x6467, 0xB4DD, 0x6468, 0x93AF, 0x6469, 0xC4A6, 0x646A, 0x93B0,\r\n\t0x646B, 0x93B1, 0x646C, 0x93B2, 0x646D, 0xDEFD, 0x646E, 0x93B3,\t0x646F, 0x93B4, 0x6470, 0x93B5, 0x6471, 0x93B6, 0x6472, 0x93B7,\r\n\t0x6473, 0x93B8, 0x6474, 0x93B9, 0x6475, 0x93BA, 0x6476, 0x93BB,\t0x6477, 0x93BC, 0x6478, 0xC3FE, 0x6479, 0xC4A1, 0x647A, 0xDFA1,\r\n\t0x647B, 0x93BD, 0x647C, 0x93BE, 0x647D, 0x93BF, 0x647E, 0x93C0,\t0x647F, 0x93C1, 0x6480, 0x93C2, 0x6481, 0x93C3, 0x6482, 0xC1CC,\r\n\t0x6483, 0x93C4, 0x6484, 0xDEFC, 0x6485, 0xBEEF, 0x6486, 0x93C5,\t0x6487, 0xC6B2, 0x6488, 0x93C6, 0x6489, 0x93C7, 0x648A, 0x93C8,\r\n\t0x648B, 0x93C9, 0x648C, 0x93CA, 0x648D, 0x93CB, 0x648E, 0x93CC,\t0x648F, 0x93CD, 0x6490, 0x93CE, 0x6491, 0xB3C5, 0x6492, 0xC8F6,\r\n\t0x6493, 0x93CF, 0x6494, 0x93D0, 0x6495, 0xCBBA, 0x6496, 0xDEFE,\t0x6497, 0x93D1, 0x6498, 0x93D2, 0x6499, 0xDFA4, 0x649A, 0x93D3,\r\n\t0x649B, 0x93D4, 0x649C, 0x93D5, 0x649D, 0x93D6, 0x649E, 0xD7B2,\t0x649F, 0x93D7, 0x64A0, 0x93D8, 0x64A1, 0x93D9, 0x64A2, 0x93DA,\r\n\t0x64A3, 0x93DB, 0x64A4, 0xB3B7, 0x64A5, 0x93DC, 0x64A6, 0x93DD,\t0x64A7, 0x93DE, 0x64A8, 0x93DF, 0x64A9, 0xC1C3, 0x64AA, 0x93E0,\r\n\t0x64AB, 0x93E1, 0x64AC, 0xC7CB, 0x64AD, 0xB2A5, 0x64AE, 0xB4E9,\t0x64AF, 0x93E2, 0x64B0, 0xD7AB, 0x64B1, 0x93E3, 0x64B2, 0x93E4,\r\n\t0x64B3, 0x93E5, 0x64B4, 0x93E6, 0x64B5, 0xC4EC, 0x64B6, 0x93E7,\t0x64B7, 0xDFA2, 0x64B8, 0xDFA3, 0x64B9, 0x93E8, 0x64BA, 0xDFA5,\r\n\t0x64BB, 0x93E9, 0x64BC, 0xBAB3, 0x64BD, 0x93EA, 0x64BE, 0x93EB,\t0x64BF, 0x93EC, 0x64C0, 0xDFA6, 0x64C1, 0x93ED, 0x64C2, 0xC0DE,\r\n\t0x64C3, 0x93EE, 0x64C4, 0x93EF, 0x64C5, 0xC9C3, 0x64C6, 0x93F0,\t0x64C7, 0x93F1, 0x64C8, 0x93F2, 0x64C9, 0x93F3, 0x64CA, 0x93F4,\r\n\t0x64CB, 0x93F5, 0x64CC, 0x93F6, 0x64CD, 0xB2D9, 0x64CE, 0xC7E6,\t0x64CF, 0x93F7, 0x64D0, 0xDFA7, 0x64D1, 0x93F8, 0x64D2, 0xC7DC,\r\n\t0x64D3, 0x93F9, 0x64D4, 0x93FA, 0x64D5, 0x93FB, 0x64D6, 0x93FC,\t0x64D7, 0xDFA8, 0x64D8, 0xEBA2, 0x64D9, 0x93FD, 0x64DA, 0x93FE,\r\n\t0x64DB, 0x9440, 0x64DC, 0x9441, 0x64DD, 0x9442, 0x64DE, 0xCBD3,\t0x64DF, 0x9443, 0x64E0, 0x9444, 0x64E1, 0x9445, 0x64E2, 0xDFAA,\r\n\t0x64E3, 0x9446, 0x64E4, 0xDFA9, 0x64E5, 0x9447, 0x64E6, 0xB2C1,\t0x64E7, 0x9448, 0x64E8, 0x9449, 0x64E9, 0x944A, 0x64EA, 0x944B,\r\n\t0x64EB, 0x944C, 0x64EC, 0x944D, 0x64ED, 0x944E, 0x64EE, 0x944F,\t0x64EF, 0x9450, 0x64F0, 0x9451, 0x64F1, 0x9452, 0x64F2, 0x9453,\r\n\t0x64F3, 0x9454, 0x64F4, 0x9455, 0x64F5, 0x9456, 0x64F6, 0x9457,\t0x64F7, 0x9458, 0x64F8, 0x9459, 0x64F9, 0x945A, 0x64FA, 0x945B,\r\n\t0x64FB, 0x945C, 0x64FC, 0x945D, 0x64FD, 0x945E, 0x64FE, 0x945F,\t0x64FF, 0x9460, 0x6500, 0xC5CA, 0x6501, 0x9461, 0x6502, 0x9462,\r\n\t0x6503, 0x9463, 0x6504, 0x9464, 0x6505, 0x9465, 0x6506, 0x9466,\t0x6507, 0x9467, 0x6508, 0x9468, 0x6509, 0xDFAB, 0x650A, 0x9469,\r\n\t0x650B, 0x946A, 0x650C, 0x946B, 0x650D, 0x946C, 0x650E, 0x946D,\t0x650F, 0x946E, 0x6510, 0x946F, 0x6511, 0x9470, 0x6512, 0xD4DC,\r\n\t0x6513, 0x9471, 0x6514, 0x9472, 0x6515, 0x9473, 0x6516, 0x9474,\t0x6517, 0x9475, 0x6518, 0xC8C1, 0x6519, 0x9476, 0x651A, 0x9477,\r\n\t0x651B, 0x9478, 0x651C, 0x9479, 0x651D, 0x947A, 0x651E, 0x947B,\t0x651F, 0x947C, 0x6520, 0x947D, 0x6521, 0x947E, 0x6522, 0x9480,\r\n\t0x6523, 0x9481, 0x6524, 0x9482, 0x6525, 0xDFAC, 0x6526, 0x9483,\t0x6527, 0x9484, 0x6528, 0x9485, 0x6529, 0x9486, 0x652A, 0x9487,\r\n\t0x652B, 0xBEF0, 0x652C, 0x9488, 0x652D, 0x9489, 0x652E, 0xDFAD,\t0x652F, 0xD6A7, 0x6530, 0x948A, 0x6531, 0x948B, 0x6532, 0x948C,\r\n\t0x6533, 0x948D, 0x6534, 0xEAB7, 0x6535, 0xEBB6, 0x6536, 0xCAD5,\t0x6537, 0x948E, 0x6538, 0xD8FC, 0x6539, 0xB8C4, 0x653A, 0x948F,\r\n\t0x653B, 0xB9A5, 0x653C, 0x9490, 0x653D, 0x9491, 0x653E, 0xB7C5,\t0x653F, 0xD5FE, 0x6540, 0x9492, 0x6541, 0x9493, 0x6542, 0x9494,\r\n\t0x6543, 0x9495, 0x6544, 0x9496, 0x6545, 0xB9CA, 0x6546, 0x9497,\t0x6547, 0x9498, 0x6548, 0xD0A7, 0x6549, 0xF4CD, 0x654A, 0x9499,\r\n\t0x654B, 0x949A, 0x654C, 0xB5D0, 0x654D, 0x949B, 0x654E, 0x949C,\t0x654F, 0xC3F4, 0x6550, 0x949D, 0x6551, 0xBEC8, 0x6552, 0x949E,\r\n\t0x6553, 0x949F, 0x6554, 0x94A0, 0x6555, 0xEBB7, 0x6556, 0xB0BD,\t0x6557, 0x94A1, 0x6558, 0x94A2, 0x6559, 0xBDCC, 0x655A, 0x94A3,\r\n\t0x655B, 0xC1B2, 0x655C, 0x94A4, 0x655D, 0xB1D6, 0x655E, 0xB3A8,\t0x655F, 0x94A5, 0x6560, 0x94A6, 0x6561, 0x94A7, 0x6562, 0xB8D2,\r\n\t0x6563, 0xC9A2, 0x6564, 0x94A8, 0x6565, 0x94A9, 0x6566, 0xB6D8,\t0x6567, 0x94AA, 0x6568, 0x94AB, 0x6569, 0x94AC, 0x656A, 0x94AD,\r\n\t0x656B, 0xEBB8, 0x656C, 0xBEB4, 0x656D, 0x94AE, 0x656E, 0x94AF,\t0x656F, 0x94B0, 0x6570, 0xCAFD, 0x6571, 0x94B1, 0x6572, 0xC7C3,\r\n\t0x6573, 0x94B2, 0x6574, 0xD5FB, 0x6575, 0x94B3, 0x6576, 0x94B4,\t0x6577, 0xB7F3, 0x6578, 0x94B5, 0x6579, 0x94B6, 0x657A, 0x94B7,\r\n\t0x657B, 0x94B8, 0x657C, 0x94B9, 0x657D, 0x94BA, 0x657E, 0x94BB,\t0x657F, 0x94BC, 0x6580, 0x94BD, 0x6581, 0x94BE, 0x6582, 0x94BF,\r\n\t0x6583, 0x94C0, 0x6584, 0x94C1, 0x6585, 0x94C2, 0x6586, 0x94C3,\t0x6587, 0xCEC4, 0x6588, 0x94C4, 0x6589, 0x94C5, 0x658A, 0x94C6,\r\n\t0x658B, 0xD5AB, 0x658C, 0xB1F3, 0x658D, 0x94C7, 0x658E, 0x94C8,\t0x658F, 0x94C9, 0x6590, 0xECB3, 0x6591, 0xB0DF, 0x6592, 0x94CA,\r\n\t0x6593, 0xECB5, 0x6594, 0x94CB, 0x6595, 0x94CC, 0x6596, 0x94CD,\t0x6597, 0xB6B7, 0x6598, 0x94CE, 0x6599, 0xC1CF, 0x659A, 0x94CF,\r\n\t0x659B, 0xF5FA, 0x659C, 0xD0B1, 0x659D, 0x94D0, 0x659E, 0x94D1,\t0x659F, 0xD5E5, 0x65A0, 0x94D2, 0x65A1, 0xCED3, 0x65A2, 0x94D3,\r\n\t0x65A3, 0x94D4, 0x65A4, 0xBDEF, 0x65A5, 0xB3E2, 0x65A6, 0x94D5,\t0x65A7, 0xB8AB, 0x65A8, 0x94D6, 0x65A9, 0xD5B6, 0x65AA, 0x94D7,\r\n\t0x65AB, 0xEDBD, 0x65AC, 0x94D8, 0x65AD, 0xB6CF, 0x65AE, 0x94D9,\t0x65AF, 0xCBB9, 0x65B0, 0xD0C2, 0x65B1, 0x94DA, 0x65B2, 0x94DB,\r\n\t0x65B3, 0x94DC, 0x65B4, 0x94DD, 0x65B5, 0x94DE, 0x65B6, 0x94DF,\t0x65B7, 0x94E0, 0x65B8, 0x94E1, 0x65B9, 0xB7BD, 0x65BA, 0x94E2,\r\n\t0x65BB, 0x94E3, 0x65BC, 0xECB6, 0x65BD, 0xCAA9, 0x65BE, 0x94E4,\t0x65BF, 0x94E5, 0x65C0, 0x94E6, 0x65C1, 0xC5D4, 0x65C2, 0x94E7,\r\n\t0x65C3, 0xECB9, 0x65C4, 0xECB8, 0x65C5, 0xC2C3, 0x65C6, 0xECB7,\t0x65C7, 0x94E8, 0x65C8, 0x94E9, 0x65C9, 0x94EA, 0x65CA, 0x94EB,\r\n\t0x65CB, 0xD0FD, 0x65CC, 0xECBA, 0x65CD, 0x94EC, 0x65CE, 0xECBB,\t0x65CF, 0xD7E5, 0x65D0, 0x94ED, 0x65D1, 0x94EE, 0x65D2, 0xECBC,\r\n\t0x65D3, 0x94EF, 0x65D4, 0x94F0, 0x65D5, 0x94F1, 0x65D6, 0xECBD,\t0x65D7, 0xC6EC, 0x65D8, 0x94F2, 0x65D9, 0x94F3, 0x65DA, 0x94F4,\r\n\t0x65DB, 0x94F5, 0x65DC, 0x94F6, 0x65DD, 0x94F7, 0x65DE, 0x94F8,\t0x65DF, 0x94F9, 0x65E0, 0xCEDE, 0x65E1, 0x94FA, 0x65E2, 0xBCC8,\r\n\t0x65E3, 0x94FB, 0x65E4, 0x94FC, 0x65E5, 0xC8D5, 0x65E6, 0xB5A9,\t0x65E7, 0xBEC9, 0x65E8, 0xD6BC, 0x65E9, 0xD4E7, 0x65EA, 0x94FD,\r\n\t0x65EB, 0x94FE, 0x65EC, 0xD1AE, 0x65ED, 0xD0F1, 0x65EE, 0xEAB8,\t0x65EF, 0xEAB9, 0x65F0, 0xEABA, 0x65F1, 0xBAB5, 0x65F2, 0x9540,\r\n\t0x65F3, 0x9541, 0x65F4, 0x9542, 0x65F5, 0x9543, 0x65F6, 0xCAB1,\t0x65F7, 0xBFF5, 0x65F8, 0x9544, 0x65F9, 0x9545, 0x65FA, 0xCDFA,\r\n\t0x65FB, 0x9546, 0x65FC, 0x9547, 0x65FD, 0x9548, 0x65FE, 0x9549,\t0x65FF, 0x954A, 0x6600, 0xEAC0, 0x6601, 0x954B, 0x6602, 0xB0BA,\r\n\t0x6603, 0xEABE, 0x6604, 0x954C, 0x6605, 0x954D, 0x6606, 0xC0A5,\t0x6607, 0x954E, 0x6608, 0x954F, 0x6609, 0x9550, 0x660A, 0xEABB,\r\n\t0x660B, 0x9551, 0x660C, 0xB2FD, 0x660D, 0x9552, 0x660E, 0xC3F7,\t0x660F, 0xBBE8, 0x6610, 0x9553, 0x6611, 0x9554, 0x6612, 0x9555,\r\n\t0x6613, 0xD2D7, 0x6614, 0xCEF4, 0x6615, 0xEABF, 0x6616, 0x9556,\t0x6617, 0x9557, 0x6618, 0x9558, 0x6619, 0xEABC, 0x661A, 0x9559,\r\n\t0x661B, 0x955A, 0x661C, 0x955B, 0x661D, 0xEAC3, 0x661E, 0x955C,\t0x661F, 0xD0C7, 0x6620, 0xD3B3, 0x6621, 0x955D, 0x6622, 0x955E,\r\n\t0x6623, 0x955F, 0x6624, 0x9560, 0x6625, 0xB4BA, 0x6626, 0x9561,\t0x6627, 0xC3C1, 0x6628, 0xD7F2, 0x6629, 0x9562, 0x662A, 0x9563,\r\n\t0x662B, 0x9564, 0x662C, 0x9565, 0x662D, 0xD5D1, 0x662E, 0x9566,\t0x662F, 0xCAC7, 0x6630, 0x9567, 0x6631, 0xEAC5, 0x6632, 0x9568,\r\n\t0x6633, 0x9569, 0x6634, 0xEAC4, 0x6635, 0xEAC7, 0x6636, 0xEAC6,\t0x6637, 0x956A, 0x6638, 0x956B, 0x6639, 0x956C, 0x663A, 0x956D,\r\n\t0x663B, 0x956E, 0x663C, 0xD6E7, 0x663D, 0x956F, 0x663E, 0xCFD4,\t0x663F, 0x9570, 0x6640, 0x9571, 0x6641, 0xEACB, 0x6642, 0x9572,\r\n\t0x6643, 0xBBCE, 0x6644, 0x9573, 0x6645, 0x9574, 0x6646, 0x9575,\t0x6647, 0x9576, 0x6648, 0x9577, 0x6649, 0x9578, 0x664A, 0x9579,\r\n\t0x664B, 0xBDFA, 0x664C, 0xC9CE, 0x664D, 0x957A, 0x664E, 0x957B,\t0x664F, 0xEACC, 0x6650, 0x957C, 0x6651, 0x957D, 0x6652, 0xC9B9,\r\n\t0x6653, 0xCFFE, 0x6654, 0xEACA, 0x6655, 0xD4CE, 0x6656, 0xEACD,\t0x6657, 0xEACF, 0x6658, 0x957E, 0x6659, 0x9580, 0x665A, 0xCDED,\r\n\t0x665B, 0x9581, 0x665C, 0x9582, 0x665D, 0x9583, 0x665E, 0x9584,\t0x665F, 0xEAC9, 0x6660, 0x9585, 0x6661, 0xEACE, 0x6662, 0x9586,\r\n\t0x6663, 0x9587, 0x6664, 0xCEEE, 0x6665, 0x9588, 0x6666, 0xBBDE,\t0x6667, 0x9589, 0x6668, 0xB3BF, 0x6669, 0x958A, 0x666A, 0x958B,\r\n\t0x666B, 0x958C, 0x666C, 0x958D, 0x666D, 0x958E, 0x666E, 0xC6D5,\t0x666F, 0xBEB0, 0x6670, 0xCEFA, 0x6671, 0x958F, 0x6672, 0x9590,\r\n\t0x6673, 0x9591, 0x6674, 0xC7E7, 0x6675, 0x9592, 0x6676, 0xBEA7,\t0x6677, 0xEAD0, 0x6678, 0x9593, 0x6679, 0x9594, 0x667A, 0xD6C7,\r\n\t0x667B, 0x9595, 0x667C, 0x9596, 0x667D, 0x9597, 0x667E, 0xC1C0,\t0x667F, 0x9598, 0x6680, 0x9599, 0x6681, 0x959A, 0x6682, 0xD4DD,\r\n\t0x6683, 0x959B, 0x6684, 0xEAD1, 0x6685, 0x959C, 0x6686, 0x959D,\t0x6687, 0xCFBE, 0x6688, 0x959E, 0x6689, 0x959F, 0x668A, 0x95A0,\r\n\t0x668B, 0x95A1, 0x668C, 0xEAD2, 0x668D, 0x95A2, 0x668E, 0x95A3,\t0x668F, 0x95A4, 0x6690, 0x95A5, 0x6691, 0xCAEE, 0x6692, 0x95A6,\r\n\t0x6693, 0x95A7, 0x6694, 0x95A8, 0x6695, 0x95A9, 0x6696, 0xC5AF,\t0x6697, 0xB0B5, 0x6698, 0x95AA, 0x6699, 0x95AB, 0x669A, 0x95AC,\r\n\t0x669B, 0x95AD, 0x669C, 0x95AE, 0x669D, 0xEAD4, 0x669E, 0x95AF,\t0x669F, 0x95B0, 0x66A0, 0x95B1, 0x66A1, 0x95B2, 0x66A2, 0x95B3,\r\n\t0x66A3, 0x95B4, 0x66A4, 0x95B5, 0x66A5, 0x95B6, 0x66A6, 0x95B7,\t0x66A7, 0xEAD3, 0x66A8, 0xF4DF, 0x66A9, 0x95B8, 0x66AA, 0x95B9,\r\n\t0x66AB, 0x95BA, 0x66AC, 0x95BB, 0x66AD, 0x95BC, 0x66AE, 0xC4BA,\t0x66AF, 0x95BD, 0x66B0, 0x95BE, 0x66B1, 0x95BF, 0x66B2, 0x95C0,\r\n\t0x66B3, 0x95C1, 0x66B4, 0xB1A9, 0x66B5, 0x95C2, 0x66B6, 0x95C3,\t0x66B7, 0x95C4, 0x66B8, 0x95C5, 0x66B9, 0xE5DF, 0x66BA, 0x95C6,\r\n\t0x66BB, 0x95C7, 0x66BC, 0x95C8, 0x66BD, 0x95C9, 0x66BE, 0xEAD5,\t0x66BF, 0x95CA, 0x66C0, 0x95CB, 0x66C1, 0x95CC, 0x66C2, 0x95CD,\r\n\t0x66C3, 0x95CE, 0x66C4, 0x95CF, 0x66C5, 0x95D0, 0x66C6, 0x95D1,\t0x66C7, 0x95D2, 0x66C8, 0x95D3, 0x66C9, 0x95D4, 0x66CA, 0x95D5,\r\n\t0x66CB, 0x95D6, 0x66CC, 0x95D7, 0x66CD, 0x95D8, 0x66CE, 0x95D9,\t0x66CF, 0x95DA, 0x66D0, 0x95DB, 0x66D1, 0x95DC, 0x66D2, 0x95DD,\r\n\t0x66D3, 0x95DE, 0x66D4, 0x95DF, 0x66D5, 0x95E0, 0x66D6, 0x95E1,\t0x66D7, 0x95E2, 0x66D8, 0x95E3, 0x66D9, 0xCAEF, 0x66DA, 0x95E4,\r\n\t0x66DB, 0xEAD6, 0x66DC, 0xEAD7, 0x66DD, 0xC6D8, 0x66DE, 0x95E5,\t0x66DF, 0x95E6, 0x66E0, 0x95E7, 0x66E1, 0x95E8, 0x66E2, 0x95E9,\r\n\t0x66E3, 0x95EA, 0x66E4, 0x95EB, 0x66E5, 0x95EC, 0x66E6, 0xEAD8,\t0x66E7, 0x95ED, 0x66E8, 0x95EE, 0x66E9, 0xEAD9, 0x66EA, 0x95EF,\r\n\t0x66EB, 0x95F0, 0x66EC, 0x95F1, 0x66ED, 0x95F2, 0x66EE, 0x95F3,\t0x66EF, 0x95F4, 0x66F0, 0xD4BB, 0x66F1, 0x95F5, 0x66F2, 0xC7FA,\r\n\t0x66F3, 0xD2B7, 0x66F4, 0xB8FC, 0x66F5, 0x95F6, 0x66F6, 0x95F7,\t0x66F7, 0xEAC2, 0x66F8, 0x95F8, 0x66F9, 0xB2DC, 0x66FA, 0x95F9,\r\n\t0x66FB, 0x95FA, 0x66FC, 0xC2FC, 0x66FD, 0x95FB, 0x66FE, 0xD4F8,\t0x66FF, 0xCCE6, 0x6700, 0xD7EE, 0x6701, 0x95FC, 0x6702, 0x95FD,\r\n\t0x6703, 0x95FE, 0x6704, 0x9640, 0x6705, 0x9641, 0x6706, 0x9642,\t0x6707, 0x9643, 0x6708, 0xD4C2, 0x6709, 0xD3D0, 0x670A, 0xEBC3,\r\n\t0x670B, 0xC5F3, 0x670C, 0x9644, 0x670D, 0xB7FE, 0x670E, 0x9645,\t0x670F, 0x9646, 0x6710, 0xEBD4, 0x6711, 0x9647, 0x6712, 0x9648,\r\n\t0x6713, 0x9649, 0x6714, 0xCBB7, 0x6715, 0xEBDE, 0x6716, 0x964A,\t0x6717, 0xC0CA, 0x6718, 0x964B, 0x6719, 0x964C, 0x671A, 0x964D,\r\n\t0x671B, 0xCDFB, 0x671C, 0x964E, 0x671D, 0xB3AF, 0x671E, 0x964F,\t0x671F, 0xC6DA, 0x6720, 0x9650, 0x6721, 0x9651, 0x6722, 0x9652,\r\n\t0x6723, 0x9653, 0x6724, 0x9654, 0x6725, 0x9655, 0x6726, 0xEBFC,\t0x6727, 0x9656, 0x6728, 0xC4BE, 0x6729, 0x9657, 0x672A, 0xCEB4,\r\n\t0x672B, 0xC4A9, 0x672C, 0xB1BE, 0x672D, 0xD4FD, 0x672E, 0x9658,\t0x672F, 0xCAF5, 0x6730, 0x9659, 0x6731, 0xD6EC, 0x6732, 0x965A,\r\n\t0x6733, 0x965B, 0x6734, 0xC6D3, 0x6735, 0xB6E4, 0x6736, 0x965C,\t0x6737, 0x965D, 0x6738, 0x965E, 0x6739, 0x965F, 0x673A, 0xBBFA,\r\n\t0x673B, 0x9660, 0x673C, 0x9661, 0x673D, 0xD0E0, 0x673E, 0x9662,\t0x673F, 0x9663, 0x6740, 0xC9B1, 0x6741, 0x9664, 0x6742, 0xD4D3,\r\n\t0x6743, 0xC8A8, 0x6744, 0x9665, 0x6745, 0x9666, 0x6746, 0xB8CB,\t0x6747, 0x9667, 0x6748, 0xE8BE, 0x6749, 0xC9BC, 0x674A, 0x9668,\r\n\t0x674B, 0x9669, 0x674C, 0xE8BB, 0x674D, 0x966A, 0x674E, 0xC0EE,\t0x674F, 0xD0D3, 0x6750, 0xB2C4, 0x6751, 0xB4E5, 0x6752, 0x966B,\r\n\t0x6753, 0xE8BC, 0x6754, 0x966C, 0x6755, 0x966D, 0x6756, 0xD5C8,\t0x6757, 0x966E, 0x6758, 0x966F, 0x6759, 0x9670, 0x675A, 0x9671,\r\n\t0x675B, 0x9672, 0x675C, 0xB6C5, 0x675D, 0x9673, 0x675E, 0xE8BD,\t0x675F, 0xCAF8, 0x6760, 0xB8DC, 0x6761, 0xCCF5, 0x6762, 0x9674,\r\n\t0x6763, 0x9675, 0x6764, 0x9676, 0x6765, 0xC0B4, 0x6766, 0x9677,\t0x6767, 0x9678, 0x6768, 0xD1EE, 0x6769, 0xE8BF, 0x676A, 0xE8C2,\r\n\t0x676B, 0x9679, 0x676C, 0x967A, 0x676D, 0xBABC, 0x676E, 0x967B,\t0x676F, 0xB1AD, 0x6770, 0xBDDC, 0x6771, 0x967C, 0x6772, 0xEABD,\r\n\t0x6773, 0xE8C3, 0x6774, 0x967D, 0x6775, 0xE8C6, 0x6776, 0x967E,\t0x6777, 0xE8CB, 0x6778, 0x9680, 0x6779, 0x9681, 0x677A, 0x9682,\r\n\t0x677B, 0x9683, 0x677C, 0xE8CC, 0x677D, 0x9684, 0x677E, 0xCBC9,\t0x677F, 0xB0E5, 0x6780, 0x9685, 0x6781, 0xBCAB, 0x6782, 0x9686,\r\n\t0x6783, 0x9687, 0x6784, 0xB9B9, 0x6785, 0x9688, 0x6786, 0x9689,\t0x6787, 0xE8C1, 0x6788, 0x968A, 0x6789, 0xCDF7, 0x678A, 0x968B,\r\n\t0x678B, 0xE8CA, 0x678C, 0x968C, 0x678D, 0x968D, 0x678E, 0x968E,\t0x678F, 0x968F, 0x6790, 0xCEF6, 0x6791, 0x9690, 0x6792, 0x9691,\r\n\t0x6793, 0x9692, 0x6794, 0x9693, 0x6795, 0xD5ED, 0x6796, 0x9694,\t0x6797, 0xC1D6, 0x6798, 0xE8C4, 0x6799, 0x9695, 0x679A, 0xC3B6,\r\n\t0x679B, 0x9696, 0x679C, 0xB9FB, 0x679D, 0xD6A6, 0x679E, 0xE8C8,\t0x679F, 0x9697, 0x67A0, 0x9698, 0x67A1, 0x9699, 0x67A2, 0xCAE0,\r\n\t0x67A3, 0xD4E6, 0x67A4, 0x969A, 0x67A5, 0xE8C0, 0x67A6, 0x969B,\t0x67A7, 0xE8C5, 0x67A8, 0xE8C7, 0x67A9, 0x969C, 0x67AA, 0xC7B9,\r\n\t0x67AB, 0xB7E3, 0x67AC, 0x969D, 0x67AD, 0xE8C9, 0x67AE, 0x969E,\t0x67AF, 0xBFDD, 0x67B0, 0xE8D2, 0x67B1, 0x969F, 0x67B2, 0x96A0,\r\n\t0x67B3, 0xE8D7, 0x67B4, 0x96A1, 0x67B5, 0xE8D5, 0x67B6, 0xBCDC,\t0x67B7, 0xBCCF, 0x67B8, 0xE8DB, 0x67B9, 0x96A2, 0x67BA, 0x96A3,\r\n\t0x67BB, 0x96A4, 0x67BC, 0x96A5, 0x67BD, 0x96A6, 0x67BE, 0x96A7,\t0x67BF, 0x96A8, 0x67C0, 0x96A9, 0x67C1, 0xE8DE, 0x67C2, 0x96AA,\r\n\t0x67C3, 0xE8DA, 0x67C4, 0xB1FA, 0x67C5, 0x96AB, 0x67C6, 0x96AC,\t0x67C7, 0x96AD, 0x67C8, 0x96AE, 0x67C9, 0x96AF, 0x67CA, 0x96B0,\r\n\t0x67CB, 0x96B1, 0x67CC, 0x96B2, 0x67CD, 0x96B3, 0x67CE, 0x96B4,\t0x67CF, 0xB0D8, 0x67D0, 0xC4B3, 0x67D1, 0xB8CC, 0x67D2, 0xC6E2,\r\n\t0x67D3, 0xC8BE, 0x67D4, 0xC8E1, 0x67D5, 0x96B5, 0x67D6, 0x96B6,\t0x67D7, 0x96B7, 0x67D8, 0xE8CF, 0x67D9, 0xE8D4, 0x67DA, 0xE8D6,\r\n\t0x67DB, 0x96B8, 0x67DC, 0xB9F1, 0x67DD, 0xE8D8, 0x67DE, 0xD7F5,\t0x67DF, 0x96B9, 0x67E0, 0xC4FB, 0x67E1, 0x96BA, 0x67E2, 0xE8DC,\r\n\t0x67E3, 0x96BB, 0x67E4, 0x96BC, 0x67E5, 0xB2E9, 0x67E6, 0x96BD,\t0x67E7, 0x96BE, 0x67E8, 0x96BF, 0x67E9, 0xE8D1, 0x67EA, 0x96C0,\r\n\t0x67EB, 0x96C1, 0x67EC, 0xBCED, 0x67ED, 0x96C2, 0x67EE, 0x96C3,\t0x67EF, 0xBFC2, 0x67F0, 0xE8CD, 0x67F1, 0xD6F9, 0x67F2, 0x96C4,\r\n\t0x67F3, 0xC1F8, 0x67F4, 0xB2F1, 0x67F5, 0x96C5, 0x67F6, 0x96C6,\t0x67F7, 0x96C7, 0x67F8, 0x96C8, 0x67F9, 0x96C9, 0x67FA, 0x96CA,\r\n\t0x67FB, 0x96CB, 0x67FC, 0x96CC, 0x67FD, 0xE8DF, 0x67FE, 0x96CD,\t0x67FF, 0xCAC1, 0x6800, 0xE8D9, 0x6801, 0x96CE, 0x6802, 0x96CF,\r\n\t0x6803, 0x96D0, 0x6804, 0x96D1, 0x6805, 0xD5A4, 0x6806, 0x96D2,\t0x6807, 0xB1EA, 0x6808, 0xD5BB, 0x6809, 0xE8CE, 0x680A, 0xE8D0,\r\n\t0x680B, 0xB6B0, 0x680C, 0xE8D3, 0x680D, 0x96D3, 0x680E, 0xE8DD,\t0x680F, 0xC0B8, 0x6810, 0x96D4, 0x6811, 0xCAF7, 0x6812, 0x96D5,\r\n\t0x6813, 0xCBA8, 0x6814, 0x96D6, 0x6815, 0x96D7, 0x6816, 0xC6DC,\t0x6817, 0xC0F5, 0x6818, 0x96D8, 0x6819, 0x96D9, 0x681A, 0x96DA,\r\n\t0x681B, 0x96DB, 0x681C, 0x96DC, 0x681D, 0xE8E9, 0x681E, 0x96DD,\t0x681F, 0x96DE, 0x6820, 0x96DF, 0x6821, 0xD0A3, 0x6822, 0x96E0,\r\n\t0x6823, 0x96E1, 0x6824, 0x96E2, 0x6825, 0x96E3, 0x6826, 0x96E4,\t0x6827, 0x96E5, 0x6828, 0x96E6, 0x6829, 0xE8F2, 0x682A, 0xD6EA,\r\n\t0x682B, 0x96E7, 0x682C, 0x96E8, 0x682D, 0x96E9, 0x682E, 0x96EA,\t0x682F, 0x96EB, 0x6830, 0x96EC, 0x6831, 0x96ED, 0x6832, 0xE8E0,\r\n\t0x6833, 0xE8E1, 0x6834, 0x96EE, 0x6835, 0x96EF, 0x6836, 0x96F0,\t0x6837, 0xD1F9, 0x6838, 0xBACB, 0x6839, 0xB8F9, 0x683A, 0x96F1,\r\n\t0x683B, 0x96F2, 0x683C, 0xB8F1, 0x683D, 0xD4D4, 0x683E, 0xE8EF,\t0x683F, 0x96F3, 0x6840, 0xE8EE, 0x6841, 0xE8EC, 0x6842, 0xB9F0,\r\n\t0x6843, 0xCCD2, 0x6844, 0xE8E6, 0x6845, 0xCEA6, 0x6846, 0xBFF2,\t0x6847, 0x96F4, 0x6848, 0xB0B8, 0x6849, 0xE8F1, 0x684A, 0xE8F0,\r\n\t0x684B, 0x96F5, 0x684C, 0xD7C0, 0x684D, 0x96F6, 0x684E, 0xE8E4,\t0x684F, 0x96F7, 0x6850, 0xCDA9, 0x6851, 0xC9A3, 0x6852, 0x96F8,\r\n\t0x6853, 0xBBB8, 0x6854, 0xBDDB, 0x6855, 0xE8EA, 0x6856, 0x96F9,\t0x6857, 0x96FA, 0x6858, 0x96FB, 0x6859, 0x96FC, 0x685A, 0x96FD,\r\n\t0x685B, 0x96FE, 0x685C, 0x9740, 0x685D, 0x9741, 0x685E, 0x9742,\t0x685F, 0x9743, 0x6860, 0xE8E2, 0x6861, 0xE8E3, 0x6862, 0xE8E5,\r\n\t0x6863, 0xB5B5, 0x6864, 0xE8E7, 0x6865, 0xC7C5, 0x6866, 0xE8EB,\t0x6867, 0xE8ED, 0x6868, 0xBDB0, 0x6869, 0xD7AE, 0x686A, 0x9744,\r\n\t0x686B, 0xE8F8, 0x686C, 0x9745, 0x686D, 0x9746, 0x686E, 0x9747,\t0x686F, 0x9748, 0x6870, 0x9749, 0x6871, 0x974A, 0x6872, 0x974B,\r\n\t0x6873, 0x974C, 0x6874, 0xE8F5, 0x6875, 0x974D, 0x6876, 0xCDB0,\t0x6877, 0xE8F6, 0x6878, 0x974E, 0x6879, 0x974F, 0x687A, 0x9750,\r\n\t0x687B, 0x9751, 0x687C, 0x9752, 0x687D, 0x9753, 0x687E, 0x9754,\t0x687F, 0x9755, 0x6880, 0x9756, 0x6881, 0xC1BA, 0x6882, 0x9757,\r\n\t0x6883, 0xE8E8, 0x6884, 0x9758, 0x6885, 0xC3B7, 0x6886, 0xB0F0,\t0x6887, 0x9759, 0x6888, 0x975A, 0x6889, 0x975B, 0x688A, 0x975C,\r\n\t0x688B, 0x975D, 0x688C, 0x975E, 0x688D, 0x975F, 0x688E, 0x9760,\t0x688F, 0xE8F4, 0x6890, 0x9761, 0x6891, 0x9762, 0x6892, 0x9763,\r\n\t0x6893, 0xE8F7, 0x6894, 0x9764, 0x6895, 0x9765, 0x6896, 0x9766,\t0x6897, 0xB9A3, 0x6898, 0x9767, 0x6899, 0x9768, 0x689A, 0x9769,\r\n\t0x689B, 0x976A, 0x689C, 0x976B, 0x689D, 0x976C, 0x689E, 0x976D,\t0x689F, 0x976E, 0x68A0, 0x976F, 0x68A1, 0x9770, 0x68A2, 0xC9D2,\r\n\t0x68A3, 0x9771, 0x68A4, 0x9772, 0x68A5, 0x9773, 0x68A6, 0xC3CE,\t0x68A7, 0xCEE0, 0x68A8, 0xC0E6, 0x68A9, 0x9774, 0x68AA, 0x9775,\r\n\t0x68AB, 0x9776, 0x68AC, 0x9777, 0x68AD, 0xCBF3, 0x68AE, 0x9778,\t0x68AF, 0xCCDD, 0x68B0, 0xD0B5, 0x68B1, 0x9779, 0x68B2, 0x977A,\r\n\t0x68B3, 0xCAE1, 0x68B4, 0x977B, 0x68B5, 0xE8F3, 0x68B6, 0x977C,\t0x68B7, 0x977D, 0x68B8, 0x977E, 0x68B9, 0x9780, 0x68BA, 0x9781,\r\n\t0x68BB, 0x9782, 0x68BC, 0x9783, 0x68BD, 0x9784, 0x68BE, 0x9785,\t0x68BF, 0x9786, 0x68C0, 0xBCEC, 0x68C1, 0x9787, 0x68C2, 0xE8F9,\r\n\t0x68C3, 0x9788, 0x68C4, 0x9789, 0x68C5, 0x978A, 0x68C6, 0x978B,\t0x68C7, 0x978C, 0x68C8, 0x978D, 0x68C9, 0xC3DE, 0x68CA, 0x978E,\r\n\t0x68CB, 0xC6E5, 0x68CC, 0x978F, 0x68CD, 0xB9F7, 0x68CE, 0x9790,\t0x68CF, 0x9791, 0x68D0, 0x9792, 0x68D1, 0x9793, 0x68D2, 0xB0F4,\r\n\t0x68D3, 0x9794, 0x68D4, 0x9795, 0x68D5, 0xD7D8, 0x68D6, 0x9796,\t0x68D7, 0x9797, 0x68D8, 0xBCAC, 0x68D9, 0x9798, 0x68DA, 0xC5EF,\r\n\t0x68DB, 0x9799, 0x68DC, 0x979A, 0x68DD, 0x979B, 0x68DE, 0x979C,\t0x68DF, 0x979D, 0x68E0, 0xCCC4, 0x68E1, 0x979E, 0x68E2, 0x979F,\r\n\t0x68E3, 0xE9A6, 0x68E4, 0x97A0, 0x68E5, 0x97A1, 0x68E6, 0x97A2,\t0x68E7, 0x97A3, 0x68E8, 0x97A4, 0x68E9, 0x97A5, 0x68EA, 0x97A6,\r\n\t0x68EB, 0x97A7, 0x68EC, 0x97A8, 0x68ED, 0x97A9, 0x68EE, 0xC9AD,\t0x68EF, 0x97AA, 0x68F0, 0xE9A2, 0x68F1, 0xC0E2, 0x68F2, 0x97AB,\r\n\t0x68F3, 0x97AC, 0x68F4, 0x97AD, 0x68F5, 0xBFC3, 0x68F6, 0x97AE,\t0x68F7, 0x97AF, 0x68F8, 0x97B0, 0x68F9, 0xE8FE, 0x68FA, 0xB9D7,\r\n\t0x68FB, 0x97B1, 0x68FC, 0xE8FB, 0x68FD, 0x97B2, 0x68FE, 0x97B3,\t0x68FF, 0x97B4, 0x6900, 0x97B5, 0x6901, 0xE9A4, 0x6902, 0x97B6,\r\n\t0x6903, 0x97B7, 0x6904, 0x97B8, 0x6905, 0xD2CE, 0x6906, 0x97B9,\t0x6907, 0x97BA, 0x6908, 0x97BB, 0x6909, 0x97BC, 0x690A, 0x97BD,\r\n\t0x690B, 0xE9A3, 0x690C, 0x97BE, 0x690D, 0xD6B2, 0x690E, 0xD7B5,\t0x690F, 0x97BF, 0x6910, 0xE9A7, 0x6911, 0x97C0, 0x6912, 0xBDB7,\r\n\t0x6913, 0x97C1, 0x6914, 0x97C2, 0x6915, 0x97C3, 0x6916, 0x97C4,\t0x6917, 0x97C5, 0x6918, 0x97C6, 0x6919, 0x97C7, 0x691A, 0x97C8,\r\n\t0x691B, 0x97C9, 0x691C, 0x97CA, 0x691D, 0x97CB, 0x691E, 0x97CC,\t0x691F, 0xE8FC, 0x6920, 0xE8FD, 0x6921, 0x97CD, 0x6922, 0x97CE,\r\n\t0x6923, 0x97CF, 0x6924, 0xE9A1, 0x6925, 0x97D0, 0x6926, 0x97D1,\t0x6927, 0x97D2, 0x6928, 0x97D3, 0x6929, 0x97D4, 0x692A, 0x97D5,\r\n\t0x692B, 0x97D6, 0x692C, 0x97D7, 0x692D, 0xCDD6, 0x692E, 0x97D8,\t0x692F, 0x97D9, 0x6930, 0xD2AC, 0x6931, 0x97DA, 0x6932, 0x97DB,\r\n\t0x6933, 0x97DC, 0x6934, 0xE9B2, 0x6935, 0x97DD, 0x6936, 0x97DE,\t0x6937, 0x97DF, 0x6938, 0x97E0, 0x6939, 0xE9A9, 0x693A, 0x97E1,\r\n\t0x693B, 0x97E2, 0x693C, 0x97E3, 0x693D, 0xB4AA, 0x693E, 0x97E4,\t0x693F, 0xB4BB, 0x6940, 0x97E5, 0x6941, 0x97E6, 0x6942, 0xE9AB,\r\n\t0x6943, 0x97E7, 0x6944, 0x97E8, 0x6945, 0x97E9, 0x6946, 0x97EA,\t0x6947, 0x97EB, 0x6948, 0x97EC, 0x6949, 0x97ED, 0x694A, 0x97EE,\r\n\t0x694B, 0x97EF, 0x694C, 0x97F0, 0x694D, 0x97F1, 0x694E, 0x97F2,\t0x694F, 0x97F3, 0x6950, 0x97F4, 0x6951, 0x97F5, 0x6952, 0x97F6,\r\n\t0x6953, 0x97F7, 0x6954, 0xD0A8, 0x6955, 0x97F8, 0x6956, 0x97F9,\t0x6957, 0xE9A5, 0x6958, 0x97FA, 0x6959, 0x97FB, 0x695A, 0xB3FE,\r\n\t0x695B, 0x97FC, 0x695C, 0x97FD, 0x695D, 0xE9AC, 0x695E, 0xC0E3,\t0x695F, 0x97FE, 0x6960, 0xE9AA, 0x6961, 0x9840, 0x6962, 0x9841,\r\n\t0x6963, 0xE9B9, 0x6964, 0x9842, 0x6965, 0x9843, 0x6966, 0xE9B8,\t0x6967, 0x9844, 0x6968, 0x9845, 0x6969, 0x9846, 0x696A, 0x9847,\r\n\t0x696B, 0xE9AE, 0x696C, 0x9848, 0x696D, 0x9849, 0x696E, 0xE8FA,\t0x696F, 0x984A, 0x6970, 0x984B, 0x6971, 0xE9A8, 0x6972, 0x984C,\r\n\t0x6973, 0x984D, 0x6974, 0x984E, 0x6975, 0x984F, 0x6976, 0x9850,\t0x6977, 0xBFAC, 0x6978, 0xE9B1, 0x6979, 0xE9BA, 0x697A, 0x9851,\r\n\t0x697B, 0x9852, 0x697C, 0xC2A5, 0x697D, 0x9853, 0x697E, 0x9854,\t0x697F, 0x9855, 0x6980, 0xE9AF, 0x6981, 0x9856, 0x6982, 0xB8C5,\r\n\t0x6983, 0x9857, 0x6984, 0xE9AD, 0x6985, 0x9858, 0x6986, 0xD3DC,\t0x6987, 0xE9B4, 0x6988, 0xE9B5, 0x6989, 0xE9B7, 0x698A, 0x9859,\r\n\t0x698B, 0x985A, 0x698C, 0x985B, 0x698D, 0xE9C7, 0x698E, 0x985C,\t0x698F, 0x985D, 0x6990, 0x985E, 0x6991, 0x985F, 0x6992, 0x9860,\r\n\t0x6993, 0x9861, 0x6994, 0xC0C6, 0x6995, 0xE9C5, 0x6996, 0x9862,\t0x6997, 0x9863, 0x6998, 0xE9B0, 0x6999, 0x9864, 0x699A, 0x9865,\r\n\t0x699B, 0xE9BB, 0x699C, 0xB0F1, 0x699D, 0x9866, 0x699E, 0x9867,\t0x699F, 0x9868, 0x69A0, 0x9869, 0x69A1, 0x986A, 0x69A2, 0x986B,\r\n\t0x69A3, 0x986C, 0x69A4, 0x986D, 0x69A5, 0x986E, 0x69A6, 0x986F,\t0x69A7, 0xE9BC, 0x69A8, 0xD5A5, 0x69A9, 0x9870, 0x69AA, 0x9871,\r\n\t0x69AB, 0xE9BE, 0x69AC, 0x9872, 0x69AD, 0xE9BF, 0x69AE, 0x9873,\t0x69AF, 0x9874, 0x69B0, 0x9875, 0x69B1, 0xE9C1, 0x69B2, 0x9876,\r\n\t0x69B3, 0x9877, 0x69B4, 0xC1F1, 0x69B5, 0x9878, 0x69B6, 0x9879,\t0x69B7, 0xC8B6, 0x69B8, 0x987A, 0x69B9, 0x987B, 0x69BA, 0x987C,\r\n\t0x69BB, 0xE9BD, 0x69BC, 0x987D, 0x69BD, 0x987E, 0x69BE, 0x9880,\t0x69BF, 0x9881, 0x69C0, 0x9882, 0x69C1, 0xE9C2, 0x69C2, 0x9883,\r\n\t0x69C3, 0x9884, 0x69C4, 0x9885, 0x69C5, 0x9886, 0x69C6, 0x9887,\t0x69C7, 0x9888, 0x69C8, 0x9889, 0x69C9, 0x988A, 0x69CA, 0xE9C3,\r\n\t0x69CB, 0x988B, 0x69CC, 0xE9B3, 0x69CD, 0x988C, 0x69CE, 0xE9B6,\t0x69CF, 0x988D, 0x69D0, 0xBBB1, 0x69D1, 0x988E, 0x69D2, 0x988F,\r\n\t0x69D3, 0x9890, 0x69D4, 0xE9C0, 0x69D5, 0x9891, 0x69D6, 0x9892,\t0x69D7, 0x9893, 0x69D8, 0x9894, 0x69D9, 0x9895, 0x69DA, 0x9896,\r\n\t0x69DB, 0xBCF7, 0x69DC, 0x9897, 0x69DD, 0x9898, 0x69DE, 0x9899,\t0x69DF, 0xE9C4, 0x69E0, 0xE9C6, 0x69E1, 0x989A, 0x69E2, 0x989B,\r\n\t0x69E3, 0x989C, 0x69E4, 0x989D, 0x69E5, 0x989E, 0x69E6, 0x989F,\t0x69E7, 0x98A0, 0x69E8, 0x98A1, 0x69E9, 0x98A2, 0x69EA, 0x98A3,\r\n\t0x69EB, 0x98A4, 0x69EC, 0x98A5, 0x69ED, 0xE9CA, 0x69EE, 0x98A6,\t0x69EF, 0x98A7, 0x69F0, 0x98A8, 0x69F1, 0x98A9, 0x69F2, 0xE9CE,\r\n\t0x69F3, 0x98AA, 0x69F4, 0x98AB, 0x69F5, 0x98AC, 0x69F6, 0x98AD,\t0x69F7, 0x98AE, 0x69F8, 0x98AF, 0x69F9, 0x98B0, 0x69FA, 0x98B1,\r\n\t0x69FB, 0x98B2, 0x69FC, 0x98B3, 0x69FD, 0xB2DB, 0x69FE, 0x98B4,\t0x69FF, 0xE9C8, 0x6A00, 0x98B5, 0x6A01, 0x98B6, 0x6A02, 0x98B7,\r\n\t0x6A03, 0x98B8, 0x6A04, 0x98B9, 0x6A05, 0x98BA, 0x6A06, 0x98BB,\t0x6A07, 0x98BC, 0x6A08, 0x98BD, 0x6A09, 0x98BE, 0x6A0A, 0xB7AE,\r\n\t0x6A0B, 0x98BF, 0x6A0C, 0x98C0, 0x6A0D, 0x98C1, 0x6A0E, 0x98C2,\t0x6A0F, 0x98C3, 0x6A10, 0x98C4, 0x6A11, 0x98C5, 0x6A12, 0x98C6,\r\n\t0x6A13, 0x98C7, 0x6A14, 0x98C8, 0x6A15, 0x98C9, 0x6A16, 0x98CA,\t0x6A17, 0xE9CB, 0x6A18, 0xE9CC, 0x6A19, 0x98CB, 0x6A1A, 0x98CC,\r\n\t0x6A1B, 0x98CD, 0x6A1C, 0x98CE, 0x6A1D, 0x98CF, 0x6A1E, 0x98D0,\t0x6A1F, 0xD5C1, 0x6A20, 0x98D1, 0x6A21, 0xC4A3, 0x6A22, 0x98D2,\r\n\t0x6A23, 0x98D3, 0x6A24, 0x98D4, 0x6A25, 0x98D5, 0x6A26, 0x98D6,\t0x6A27, 0x98D7, 0x6A28, 0xE9D8, 0x6A29, 0x98D8, 0x6A2A, 0xBAE1,\r\n\t0x6A2B, 0x98D9, 0x6A2C, 0x98DA, 0x6A2D, 0x98DB, 0x6A2E, 0x98DC,\t0x6A2F, 0xE9C9, 0x6A30, 0x98DD, 0x6A31, 0xD3A3, 0x6A32, 0x98DE,\r\n\t0x6A33, 0x98DF, 0x6A34, 0x98E0, 0x6A35, 0xE9D4, 0x6A36, 0x98E1,\t0x6A37, 0x98E2, 0x6A38, 0x98E3, 0x6A39, 0x98E4, 0x6A3A, 0x98E5,\r\n\t0x6A3B, 0x98E6, 0x6A3C, 0x98E7, 0x6A3D, 0xE9D7, 0x6A3E, 0xE9D0,\t0x6A3F, 0x98E8, 0x6A40, 0x98E9, 0x6A41, 0x98EA, 0x6A42, 0x98EB,\r\n\t0x6A43, 0x98EC, 0x6A44, 0xE9CF, 0x6A45, 0x98ED, 0x6A46, 0x98EE,\t0x6A47, 0xC7C1, 0x6A48, 0x98EF, 0x6A49, 0x98F0, 0x6A4A, 0x98F1,\r\n\t0x6A4B, 0x98F2, 0x6A4C, 0x98F3, 0x6A4D, 0x98F4, 0x6A4E, 0x98F5,\t0x6A4F, 0x98F6, 0x6A50, 0xE9D2, 0x6A51, 0x98F7, 0x6A52, 0x98F8,\r\n\t0x6A53, 0x98F9, 0x6A54, 0x98FA, 0x6A55, 0x98FB, 0x6A56, 0x98FC,\t0x6A57, 0x98FD, 0x6A58, 0xE9D9, 0x6A59, 0xB3C8, 0x6A5A, 0x98FE,\r\n\t0x6A5B, 0xE9D3, 0x6A5C, 0x9940, 0x6A5D, 0x9941, 0x6A5E, 0x9942,\t0x6A5F, 0x9943, 0x6A60, 0x9944, 0x6A61, 0xCFF0, 0x6A62, 0x9945,\r\n\t0x6A63, 0x9946, 0x6A64, 0x9947, 0x6A65, 0xE9CD, 0x6A66, 0x9948,\t0x6A67, 0x9949, 0x6A68, 0x994A, 0x6A69, 0x994B, 0x6A6A, 0x994C,\r\n\t0x6A6B, 0x994D, 0x6A6C, 0x994E, 0x6A6D, 0x994F, 0x6A6E, 0x9950,\t0x6A6F, 0x9951, 0x6A70, 0x9952, 0x6A71, 0xB3F7, 0x6A72, 0x9953,\r\n\t0x6A73, 0x9954, 0x6A74, 0x9955, 0x6A75, 0x9956, 0x6A76, 0x9957,\t0x6A77, 0x9958, 0x6A78, 0x9959, 0x6A79, 0xE9D6, 0x6A7A, 0x995A,\r\n\t0x6A7B, 0x995B, 0x6A7C, 0xE9DA, 0x6A7D, 0x995C, 0x6A7E, 0x995D,\t0x6A7F, 0x995E, 0x6A80, 0xCCB4, 0x6A81, 0x995F, 0x6A82, 0x9960,\r\n\t0x6A83, 0x9961, 0x6A84, 0xCFAD, 0x6A85, 0x9962, 0x6A86, 0x9963,\t0x6A87, 0x9964, 0x6A88, 0x9965, 0x6A89, 0x9966, 0x6A8A, 0x9967,\r\n\t0x6A8B, 0x9968, 0x6A8C, 0x9969, 0x6A8D, 0x996A, 0x6A8E, 0xE9D5,\t0x6A8F, 0x996B, 0x6A90, 0xE9DC, 0x6A91, 0xE9DB, 0x6A92, 0x996C,\r\n\t0x6A93, 0x996D, 0x6A94, 0x996E, 0x6A95, 0x996F, 0x6A96, 0x9970,\t0x6A97, 0xE9DE, 0x6A98, 0x9971, 0x6A99, 0x9972, 0x6A9A, 0x9973,\r\n\t0x6A9B, 0x9974, 0x6A9C, 0x9975, 0x6A9D, 0x9976, 0x6A9E, 0x9977,\t0x6A9F, 0x9978, 0x6AA0, 0xE9D1, 0x6AA1, 0x9979, 0x6AA2, 0x997A,\r\n\t0x6AA3, 0x997B, 0x6AA4, 0x997C, 0x6AA5, 0x997D, 0x6AA6, 0x997E,\t0x6AA7, 0x9980, 0x6AA8, 0x9981, 0x6AA9, 0xE9DD, 0x6AAA, 0x9982,\r\n\t0x6AAB, 0xE9DF, 0x6AAC, 0xC3CA, 0x6AAD, 0x9983, 0x6AAE, 0x9984,\t0x6AAF, 0x9985, 0x6AB0, 0x9986, 0x6AB1, 0x9987, 0x6AB2, 0x9988,\r\n\t0x6AB3, 0x9989, 0x6AB4, 0x998A, 0x6AB5, 0x998B, 0x6AB6, 0x998C,\t0x6AB7, 0x998D, 0x6AB8, 0x998E, 0x6AB9, 0x998F, 0x6ABA, 0x9990,\r\n\t0x6ABB, 0x9991, 0x6ABC, 0x9992, 0x6ABD, 0x9993, 0x6ABE, 0x9994,\t0x6ABF, 0x9995, 0x6AC0, 0x9996, 0x6AC1, 0x9997, 0x6AC2, 0x9998,\r\n\t0x6AC3, 0x9999, 0x6AC4, 0x999A, 0x6AC5, 0x999B, 0x6AC6, 0x999C,\t0x6AC7, 0x999D, 0x6AC8, 0x999E, 0x6AC9, 0x999F, 0x6ACA, 0x99A0,\r\n\t0x6ACB, 0x99A1, 0x6ACC, 0x99A2, 0x6ACD, 0x99A3, 0x6ACE, 0x99A4,\t0x6ACF, 0x99A5, 0x6AD0, 0x99A6, 0x6AD1, 0x99A7, 0x6AD2, 0x99A8,\r\n\t0x6AD3, 0x99A9, 0x6AD4, 0x99AA, 0x6AD5, 0x99AB, 0x6AD6, 0x99AC,\t0x6AD7, 0x99AD, 0x6AD8, 0x99AE, 0x6AD9, 0x99AF, 0x6ADA, 0x99B0,\r\n\t0x6ADB, 0x99B1, 0x6ADC, 0x99B2, 0x6ADD, 0x99B3, 0x6ADE, 0x99B4,\t0x6ADF, 0x99B5, 0x6AE0, 0x99B6, 0x6AE1, 0x99B7, 0x6AE2, 0x99B8,\r\n\t0x6AE3, 0x99B9, 0x6AE4, 0x99BA, 0x6AE5, 0x99BB, 0x6AE6, 0x99BC,\t0x6AE7, 0x99BD, 0x6AE8, 0x99BE, 0x6AE9, 0x99BF, 0x6AEA, 0x99C0,\r\n\t0x6AEB, 0x99C1, 0x6AEC, 0x99C2, 0x6AED, 0x99C3, 0x6AEE, 0x99C4,\t0x6AEF, 0x99C5, 0x6AF0, 0x99C6, 0x6AF1, 0x99C7, 0x6AF2, 0x99C8,\r\n\t0x6AF3, 0x99C9, 0x6AF4, 0x99CA, 0x6AF5, 0x99CB, 0x6AF6, 0x99CC,\t0x6AF7, 0x99CD, 0x6AF8, 0x99CE, 0x6AF9, 0x99CF, 0x6AFA, 0x99D0,\r\n\t0x6AFB, 0x99D1, 0x6AFC, 0x99D2, 0x6AFD, 0x99D3, 0x6AFE, 0x99D4,\t0x6AFF, 0x99D5, 0x6B00, 0x99D6, 0x6B01, 0x99D7, 0x6B02, 0x99D8,\r\n\t0x6B03, 0x99D9, 0x6B04, 0x99DA, 0x6B05, 0x99DB, 0x6B06, 0x99DC,\t0x6B07, 0x99DD, 0x6B08, 0x99DE, 0x6B09, 0x99DF, 0x6B0A, 0x99E0,\r\n\t0x6B0B, 0x99E1, 0x6B0C, 0x99E2, 0x6B0D, 0x99E3, 0x6B0E, 0x99E4,\t0x6B0F, 0x99E5, 0x6B10, 0x99E6, 0x6B11, 0x99E7, 0x6B12, 0x99E8,\r\n\t0x6B13, 0x99E9, 0x6B14, 0x99EA, 0x6B15, 0x99EB, 0x6B16, 0x99EC,\t0x6B17, 0x99ED, 0x6B18, 0x99EE, 0x6B19, 0x99EF, 0x6B1A, 0x99F0,\r\n\t0x6B1B, 0x99F1, 0x6B1C, 0x99F2, 0x6B1D, 0x99F3, 0x6B1E, 0x99F4,\t0x6B1F, 0x99F5, 0x6B20, 0xC7B7, 0x6B21, 0xB4CE, 0x6B22, 0xBBB6,\r\n\t0x6B23, 0xD0C0, 0x6B24, 0xECA3, 0x6B25, 0x99F6, 0x6B26, 0x99F7,\t0x6B27, 0xC5B7, 0x6B28, 0x99F8, 0x6B29, 0x99F9, 0x6B2A, 0x99FA,\r\n\t0x6B2B, 0x99FB, 0x6B2C, 0x99FC, 0x6B2D, 0x99FD, 0x6B2E, 0x99FE,\t0x6B2F, 0x9A40, 0x6B30, 0x9A41, 0x6B31, 0x9A42, 0x6B32, 0xD3FB,\r\n\t0x6B33, 0x9A43, 0x6B34, 0x9A44, 0x6B35, 0x9A45, 0x6B36, 0x9A46,\t0x6B37, 0xECA4, 0x6B38, 0x9A47, 0x6B39, 0xECA5, 0x6B3A, 0xC6DB,\r\n\t0x6B3B, 0x9A48, 0x6B3C, 0x9A49, 0x6B3D, 0x9A4A, 0x6B3E, 0xBFEE,\t0x6B3F, 0x9A4B, 0x6B40, 0x9A4C, 0x6B41, 0x9A4D, 0x6B42, 0x9A4E,\r\n\t0x6B43, 0xECA6, 0x6B44, 0x9A4F, 0x6B45, 0x9A50, 0x6B46, 0xECA7,\t0x6B47, 0xD0AA, 0x6B48, 0x9A51, 0x6B49, 0xC7B8, 0x6B4A, 0x9A52,\r\n\t0x6B4B, 0x9A53, 0x6B4C, 0xB8E8, 0x6B4D, 0x9A54, 0x6B4E, 0x9A55,\t0x6B4F, 0x9A56, 0x6B50, 0x9A57, 0x6B51, 0x9A58, 0x6B52, 0x9A59,\r\n\t0x6B53, 0x9A5A, 0x6B54, 0x9A5B, 0x6B55, 0x9A5C, 0x6B56, 0x9A5D,\t0x6B57, 0x9A5E, 0x6B58, 0x9A5F, 0x6B59, 0xECA8, 0x6B5A, 0x9A60,\r\n\t0x6B5B, 0x9A61, 0x6B5C, 0x9A62, 0x6B5D, 0x9A63, 0x6B5E, 0x9A64,\t0x6B5F, 0x9A65, 0x6B60, 0x9A66, 0x6B61, 0x9A67, 0x6B62, 0xD6B9,\r\n\t0x6B63, 0xD5FD, 0x6B64, 0xB4CB, 0x6B65, 0xB2BD, 0x6B66, 0xCEE4,\t0x6B67, 0xC6E7, 0x6B68, 0x9A68, 0x6B69, 0x9A69, 0x6B6A, 0xCDE1,\r\n\t0x6B6B, 0x9A6A, 0x6B6C, 0x9A6B, 0x6B6D, 0x9A6C, 0x6B6E, 0x9A6D,\t0x6B6F, 0x9A6E, 0x6B70, 0x9A6F, 0x6B71, 0x9A70, 0x6B72, 0x9A71,\r\n\t0x6B73, 0x9A72, 0x6B74, 0x9A73, 0x6B75, 0x9A74, 0x6B76, 0x9A75,\t0x6B77, 0x9A76, 0x6B78, 0x9A77, 0x6B79, 0xB4F5, 0x6B7A, 0x9A78,\r\n\t0x6B7B, 0xCBC0, 0x6B7C, 0xBCDF, 0x6B7D, 0x9A79, 0x6B7E, 0x9A7A,\t0x6B7F, 0x9A7B, 0x6B80, 0x9A7C, 0x6B81, 0xE9E2, 0x6B82, 0xE9E3,\r\n\t0x6B83, 0xD1EA, 0x6B84, 0xE9E5, 0x6B85, 0x9A7D, 0x6B86, 0xB4F9,\t0x6B87, 0xE9E4, 0x6B88, 0x9A7E, 0x6B89, 0xD1B3, 0x6B8A, 0xCAE2,\r\n\t0x6B8B, 0xB2D0, 0x6B8C, 0x9A80, 0x6B8D, 0xE9E8, 0x6B8E, 0x9A81,\t0x6B8F, 0x9A82, 0x6B90, 0x9A83, 0x6B91, 0x9A84, 0x6B92, 0xE9E6,\r\n\t0x6B93, 0xE9E7, 0x6B94, 0x9A85, 0x6B95, 0x9A86, 0x6B96, 0xD6B3,\t0x6B97, 0x9A87, 0x6B98, 0x9A88, 0x6B99, 0x9A89, 0x6B9A, 0xE9E9,\r\n\t0x6B9B, 0xE9EA, 0x6B9C, 0x9A8A, 0x6B9D, 0x9A8B, 0x6B9E, 0x9A8C,\t0x6B9F, 0x9A8D, 0x6BA0, 0x9A8E, 0x6BA1, 0xE9EB, 0x6BA2, 0x9A8F,\r\n\t0x6BA3, 0x9A90, 0x6BA4, 0x9A91, 0x6BA5, 0x9A92, 0x6BA6, 0x9A93,\t0x6BA7, 0x9A94, 0x6BA8, 0x9A95, 0x6BA9, 0x9A96, 0x6BAA, 0xE9EC,\r\n\t0x6BAB, 0x9A97, 0x6BAC, 0x9A98, 0x6BAD, 0x9A99, 0x6BAE, 0x9A9A,\t0x6BAF, 0x9A9B, 0x6BB0, 0x9A9C, 0x6BB1, 0x9A9D, 0x6BB2, 0x9A9E,\r\n\t0x6BB3, 0xECAF, 0x6BB4, 0xC5B9, 0x6BB5, 0xB6CE, 0x6BB6, 0x9A9F,\t0x6BB7, 0xD2F3, 0x6BB8, 0x9AA0, 0x6BB9, 0x9AA1, 0x6BBA, 0x9AA2,\r\n\t0x6BBB, 0x9AA3, 0x6BBC, 0x9AA4, 0x6BBD, 0x9AA5, 0x6BBE, 0x9AA6,\t0x6BBF, 0xB5EE, 0x6BC0, 0x9AA7, 0x6BC1, 0xBBD9, 0x6BC2, 0xECB1,\r\n\t0x6BC3, 0x9AA8, 0x6BC4, 0x9AA9, 0x6BC5, 0xD2E3, 0x6BC6, 0x9AAA,\t0x6BC7, 0x9AAB, 0x6BC8, 0x9AAC, 0x6BC9, 0x9AAD, 0x6BCA, 0x9AAE,\r\n\t0x6BCB, 0xCEE3, 0x6BCC, 0x9AAF, 0x6BCD, 0xC4B8, 0x6BCE, 0x9AB0,\t0x6BCF, 0xC3BF, 0x6BD0, 0x9AB1, 0x6BD1, 0x9AB2, 0x6BD2, 0xB6BE,\r\n\t0x6BD3, 0xD8B9, 0x6BD4, 0xB1C8, 0x6BD5, 0xB1CF, 0x6BD6, 0xB1D1,\t0x6BD7, 0xC5FE, 0x6BD8, 0x9AB3, 0x6BD9, 0xB1D0, 0x6BDA, 0x9AB4,\r\n\t0x6BDB, 0xC3AB, 0x6BDC, 0x9AB5, 0x6BDD, 0x9AB6, 0x6BDE, 0x9AB7,\t0x6BDF, 0x9AB8, 0x6BE0, 0x9AB9, 0x6BE1, 0xD5B1, 0x6BE2, 0x9ABA,\r\n\t0x6BE3, 0x9ABB, 0x6BE4, 0x9ABC, 0x6BE5, 0x9ABD, 0x6BE6, 0x9ABE,\t0x6BE7, 0x9ABF, 0x6BE8, 0x9AC0, 0x6BE9, 0x9AC1, 0x6BEA, 0xEBA4,\r\n\t0x6BEB, 0xBAC1, 0x6BEC, 0x9AC2, 0x6BED, 0x9AC3, 0x6BEE, 0x9AC4,\t0x6BEF, 0xCCBA, 0x6BF0, 0x9AC5, 0x6BF1, 0x9AC6, 0x6BF2, 0x9AC7,\r\n\t0x6BF3, 0xEBA5, 0x6BF4, 0x9AC8, 0x6BF5, 0xEBA7, 0x6BF6, 0x9AC9,\t0x6BF7, 0x9ACA, 0x6BF8, 0x9ACB, 0x6BF9, 0xEBA8, 0x6BFA, 0x9ACC,\r\n\t0x6BFB, 0x9ACD, 0x6BFC, 0x9ACE, 0x6BFD, 0xEBA6, 0x6BFE, 0x9ACF,\t0x6BFF, 0x9AD0, 0x6C00, 0x9AD1, 0x6C01, 0x9AD2, 0x6C02, 0x9AD3,\r\n\t0x6C03, 0x9AD4, 0x6C04, 0x9AD5, 0x6C05, 0xEBA9, 0x6C06, 0xEBAB,\t0x6C07, 0xEBAA, 0x6C08, 0x9AD6, 0x6C09, 0x9AD7, 0x6C0A, 0x9AD8,\r\n\t0x6C0B, 0x9AD9, 0x6C0C, 0x9ADA, 0x6C0D, 0xEBAC, 0x6C0E, 0x9ADB,\t0x6C0F, 0xCACF, 0x6C10, 0xD8B5, 0x6C11, 0xC3F1, 0x6C12, 0x9ADC,\r\n\t0x6C13, 0xC3A5, 0x6C14, 0xC6F8, 0x6C15, 0xEBAD, 0x6C16, 0xC4CA,\t0x6C17, 0x9ADD, 0x6C18, 0xEBAE, 0x6C19, 0xEBAF, 0x6C1A, 0xEBB0,\r\n\t0x6C1B, 0xB7D5, 0x6C1C, 0x9ADE, 0x6C1D, 0x9ADF, 0x6C1E, 0x9AE0,\t0x6C1F, 0xB7FA, 0x6C20, 0x9AE1, 0x6C21, 0xEBB1, 0x6C22, 0xC7E2,\r\n\t0x6C23, 0x9AE2, 0x6C24, 0xEBB3, 0x6C25, 0x9AE3, 0x6C26, 0xBAA4,\t0x6C27, 0xD1F5, 0x6C28, 0xB0B1, 0x6C29, 0xEBB2, 0x6C2A, 0xEBB4,\r\n\t0x6C2B, 0x9AE4, 0x6C2C, 0x9AE5, 0x6C2D, 0x9AE6, 0x6C2E, 0xB5AA,\t0x6C2F, 0xC2C8, 0x6C30, 0xC7E8, 0x6C31, 0x9AE7, 0x6C32, 0xEBB5,\r\n\t0x6C33, 0x9AE8, 0x6C34, 0xCBAE, 0x6C35, 0xE3DF, 0x6C36, 0x9AE9,\t0x6C37, 0x9AEA, 0x6C38, 0xD3C0, 0x6C39, 0x9AEB, 0x6C3A, 0x9AEC,\r\n\t0x6C3B, 0x9AED, 0x6C3C, 0x9AEE, 0x6C3D, 0xD9DB, 0x6C3E, 0x9AEF,\t0x6C3F, 0x9AF0, 0x6C40, 0xCDA1, 0x6C41, 0xD6AD, 0x6C42, 0xC7F3,\r\n\t0x6C43, 0x9AF1, 0x6C44, 0x9AF2, 0x6C45, 0x9AF3, 0x6C46, 0xD9E0,\t0x6C47, 0xBBE3, 0x6C48, 0x9AF4, 0x6C49, 0xBABA, 0x6C4A, 0xE3E2,\r\n\t0x6C4B, 0x9AF5, 0x6C4C, 0x9AF6, 0x6C4D, 0x9AF7, 0x6C4E, 0x9AF8,\t0x6C4F, 0x9AF9, 0x6C50, 0xCFAB, 0x6C51, 0x9AFA, 0x6C52, 0x9AFB,\r\n\t0x6C53, 0x9AFC, 0x6C54, 0xE3E0, 0x6C55, 0xC9C7, 0x6C56, 0x9AFD,\t0x6C57, 0xBAB9, 0x6C58, 0x9AFE, 0x6C59, 0x9B40, 0x6C5A, 0x9B41,\r\n\t0x6C5B, 0xD1B4, 0x6C5C, 0xE3E1, 0x6C5D, 0xC8EA, 0x6C5E, 0xB9AF,\t0x6C5F, 0xBDAD, 0x6C60, 0xB3D8, 0x6C61, 0xCEDB, 0x6C62, 0x9B42,\r\n\t0x6C63, 0x9B43, 0x6C64, 0xCCC0, 0x6C65, 0x9B44, 0x6C66, 0x9B45,\t0x6C67, 0x9B46, 0x6C68, 0xE3E8, 0x6C69, 0xE3E9, 0x6C6A, 0xCDF4,\r\n\t0x6C6B, 0x9B47, 0x6C6C, 0x9B48, 0x6C6D, 0x9B49, 0x6C6E, 0x9B4A,\t0x6C6F, 0x9B4B, 0x6C70, 0xCCAD, 0x6C71, 0x9B4C, 0x6C72, 0xBCB3,\r\n\t0x6C73, 0x9B4D, 0x6C74, 0xE3EA, 0x6C75, 0x9B4E, 0x6C76, 0xE3EB,\t0x6C77, 0x9B4F, 0x6C78, 0x9B50, 0x6C79, 0xD0DA, 0x6C7A, 0x9B51,\r\n\t0x6C7B, 0x9B52, 0x6C7C, 0x9B53, 0x6C7D, 0xC6FB, 0x6C7E, 0xB7DA,\t0x6C7F, 0x9B54, 0x6C80, 0x9B55, 0x6C81, 0xC7DF, 0x6C82, 0xD2CA,\r\n\t0x6C83, 0xCED6, 0x6C84, 0x9B56, 0x6C85, 0xE3E4, 0x6C86, 0xE3EC,\t0x6C87, 0x9B57, 0x6C88, 0xC9F2, 0x6C89, 0xB3C1, 0x6C8A, 0x9B58,\r\n\t0x6C8B, 0x9B59, 0x6C8C, 0xE3E7, 0x6C8D, 0x9B5A, 0x6C8E, 0x9B5B,\t0x6C8F, 0xC6E3, 0x6C90, 0xE3E5, 0x6C91, 0x9B5C, 0x6C92, 0x9B5D,\r\n\t0x6C93, 0xEDB3, 0x6C94, 0xE3E6, 0x6C95, 0x9B5E, 0x6C96, 0x9B5F,\t0x6C97, 0x9B60, 0x6C98, 0x9B61, 0x6C99, 0xC9B3, 0x6C9A, 0x9B62,\r\n\t0x6C9B, 0xC5E6, 0x6C9C, 0x9B63, 0x6C9D, 0x9B64, 0x6C9E, 0x9B65,\t0x6C9F, 0xB9B5, 0x6CA0, 0x9B66, 0x6CA1, 0xC3BB, 0x6CA2, 0x9B67,\r\n\t0x6CA3, 0xE3E3, 0x6CA4, 0xC5BD, 0x6CA5, 0xC1A4, 0x6CA6, 0xC2D9,\t0x6CA7, 0xB2D7, 0x6CA8, 0x9B68, 0x6CA9, 0xE3ED, 0x6CAA, 0xBBA6,\r\n\t0x6CAB, 0xC4AD, 0x6CAC, 0x9B69, 0x6CAD, 0xE3F0, 0x6CAE, 0xBEDA,\t0x6CAF, 0x9B6A, 0x6CB0, 0x9B6B, 0x6CB1, 0xE3FB, 0x6CB2, 0xE3F5,\r\n\t0x6CB3, 0xBAD3, 0x6CB4, 0x9B6C, 0x6CB5, 0x9B6D, 0x6CB6, 0x9B6E,\t0x6CB7, 0x9B6F, 0x6CB8, 0xB7D0, 0x6CB9, 0xD3CD, 0x6CBA, 0x9B70,\r\n\t0x6CBB, 0xD6CE, 0x6CBC, 0xD5D3, 0x6CBD, 0xB9C1, 0x6CBE, 0xD5B4,\t0x6CBF, 0xD1D8, 0x6CC0, 0x9B71, 0x6CC1, 0x9B72, 0x6CC2, 0x9B73,\r\n\t0x6CC3, 0x9B74, 0x6CC4, 0xD0B9, 0x6CC5, 0xC7F6, 0x6CC6, 0x9B75,\t0x6CC7, 0x9B76, 0x6CC8, 0x9B77, 0x6CC9, 0xC8AA, 0x6CCA, 0xB2B4,\r\n\t0x6CCB, 0x9B78, 0x6CCC, 0xC3DA, 0x6CCD, 0x9B79, 0x6CCE, 0x9B7A,\t0x6CCF, 0x9B7B, 0x6CD0, 0xE3EE, 0x6CD1, 0x9B7C, 0x6CD2, 0x9B7D,\r\n\t0x6CD3, 0xE3FC, 0x6CD4, 0xE3EF, 0x6CD5, 0xB7A8, 0x6CD6, 0xE3F7,\t0x6CD7, 0xE3F4, 0x6CD8, 0x9B7E, 0x6CD9, 0x9B80, 0x6CDA, 0x9B81,\r\n\t0x6CDB, 0xB7BA, 0x6CDC, 0x9B82, 0x6CDD, 0x9B83, 0x6CDE, 0xC5A2,\t0x6CDF, 0x9B84, 0x6CE0, 0xE3F6, 0x6CE1, 0xC5DD, 0x6CE2, 0xB2A8,\r\n\t0x6CE3, 0xC6FC, 0x6CE4, 0x9B85, 0x6CE5, 0xC4E0, 0x6CE6, 0x9B86,\t0x6CE7, 0x9B87, 0x6CE8, 0xD7A2, 0x6CE9, 0x9B88, 0x6CEA, 0xC0E1,\r\n\t0x6CEB, 0xE3F9, 0x6CEC, 0x9B89, 0x6CED, 0x9B8A, 0x6CEE, 0xE3FA,\t0x6CEF, 0xE3FD, 0x6CF0, 0xCCA9, 0x6CF1, 0xE3F3, 0x6CF2, 0x9B8B,\r\n\t0x6CF3, 0xD3BE, 0x6CF4, 0x9B8C, 0x6CF5, 0xB1C3, 0x6CF6, 0xEDB4,\t0x6CF7, 0xE3F1, 0x6CF8, 0xE3F2, 0x6CF9, 0x9B8D, 0x6CFA, 0xE3F8,\r\n\t0x6CFB, 0xD0BA, 0x6CFC, 0xC6C3, 0x6CFD, 0xD4F3, 0x6CFE, 0xE3FE,\t0x6CFF, 0x9B8E, 0x6D00, 0x9B8F, 0x6D01, 0xBDE0, 0x6D02, 0x9B90,\r\n\t0x6D03, 0x9B91, 0x6D04, 0xE4A7, 0x6D05, 0x9B92, 0x6D06, 0x9B93,\t0x6D07, 0xE4A6, 0x6D08, 0x9B94, 0x6D09, 0x9B95, 0x6D0A, 0x9B96,\r\n\t0x6D0B, 0xD1F3, 0x6D0C, 0xE4A3, 0x6D0D, 0x9B97, 0x6D0E, 0xE4A9,\t0x6D0F, 0x9B98, 0x6D10, 0x9B99, 0x6D11, 0x9B9A, 0x6D12, 0xC8F7,\r\n\t0x6D13, 0x9B9B, 0x6D14, 0x9B9C, 0x6D15, 0x9B9D, 0x6D16, 0x9B9E,\t0x6D17, 0xCFB4, 0x6D18, 0x9B9F, 0x6D19, 0xE4A8, 0x6D1A, 0xE4AE,\r\n\t0x6D1B, 0xC2E5, 0x6D1C, 0x9BA0, 0x6D1D, 0x9BA1, 0x6D1E, 0xB6B4,\t0x6D1F, 0x9BA2, 0x6D20, 0x9BA3, 0x6D21, 0x9BA4, 0x6D22, 0x9BA5,\r\n\t0x6D23, 0x9BA6, 0x6D24, 0x9BA7, 0x6D25, 0xBDF2, 0x6D26, 0x9BA8,\t0x6D27, 0xE4A2, 0x6D28, 0x9BA9, 0x6D29, 0x9BAA, 0x6D2A, 0xBAE9,\r\n\t0x6D2B, 0xE4AA, 0x6D2C, 0x9BAB, 0x6D2D, 0x9BAC, 0x6D2E, 0xE4AC,\t0x6D2F, 0x9BAD, 0x6D30, 0x9BAE, 0x6D31, 0xB6FD, 0x6D32, 0xD6DE,\r\n\t0x6D33, 0xE4B2, 0x6D34, 0x9BAF, 0x6D35, 0xE4AD, 0x6D36, 0x9BB0,\t0x6D37, 0x9BB1, 0x6D38, 0x9BB2, 0x6D39, 0xE4A1, 0x6D3A, 0x9BB3,\r\n\t0x6D3B, 0xBBEE, 0x6D3C, 0xCDDD, 0x6D3D, 0xC7A2, 0x6D3E, 0xC5C9,\t0x6D3F, 0x9BB4, 0x6D40, 0x9BB5, 0x6D41, 0xC1F7, 0x6D42, 0x9BB6,\r\n\t0x6D43, 0xE4A4, 0x6D44, 0x9BB7, 0x6D45, 0xC7B3, 0x6D46, 0xBDAC,\t0x6D47, 0xBDBD, 0x6D48, 0xE4A5, 0x6D49, 0x9BB8, 0x6D4A, 0xD7C7,\r\n\t0x6D4B, 0xB2E2, 0x6D4C, 0x9BB9, 0x6D4D, 0xE4AB, 0x6D4E, 0xBCC3,\t0x6D4F, 0xE4AF, 0x6D50, 0x9BBA, 0x6D51, 0xBBEB, 0x6D52, 0xE4B0,\r\n\t0x6D53, 0xC5A8, 0x6D54, 0xE4B1, 0x6D55, 0x9BBB, 0x6D56, 0x9BBC,\t0x6D57, 0x9BBD, 0x6D58, 0x9BBE, 0x6D59, 0xD5E3, 0x6D5A, 0xBFA3,\r\n\t0x6D5B, 0x9BBF, 0x6D5C, 0xE4BA, 0x6D5D, 0x9BC0, 0x6D5E, 0xE4B7,\t0x6D5F, 0x9BC1, 0x6D60, 0xE4BB, 0x6D61, 0x9BC2, 0x6D62, 0x9BC3,\r\n\t0x6D63, 0xE4BD, 0x6D64, 0x9BC4, 0x6D65, 0x9BC5, 0x6D66, 0xC6D6,\t0x6D67, 0x9BC6, 0x6D68, 0x9BC7, 0x6D69, 0xBAC6, 0x6D6A, 0xC0CB,\r\n\t0x6D6B, 0x9BC8, 0x6D6C, 0x9BC9, 0x6D6D, 0x9BCA, 0x6D6E, 0xB8A1,\t0x6D6F, 0xE4B4, 0x6D70, 0x9BCB, 0x6D71, 0x9BCC, 0x6D72, 0x9BCD,\r\n\t0x6D73, 0x9BCE, 0x6D74, 0xD4A1, 0x6D75, 0x9BCF, 0x6D76, 0x9BD0,\t0x6D77, 0xBAA3, 0x6D78, 0xBDFE, 0x6D79, 0x9BD1, 0x6D7A, 0x9BD2,\r\n\t0x6D7B, 0x9BD3, 0x6D7C, 0xE4BC, 0x6D7D, 0x9BD4, 0x6D7E, 0x9BD5,\t0x6D7F, 0x9BD6, 0x6D80, 0x9BD7, 0x6D81, 0x9BD8, 0x6D82, 0xCDBF,\r\n\t0x6D83, 0x9BD9, 0x6D84, 0x9BDA, 0x6D85, 0xC4F9, 0x6D86, 0x9BDB,\t0x6D87, 0x9BDC, 0x6D88, 0xCFFB, 0x6D89, 0xC9E6, 0x6D8A, 0x9BDD,\r\n\t0x6D8B, 0x9BDE, 0x6D8C, 0xD3BF, 0x6D8D, 0x9BDF, 0x6D8E, 0xCFD1,\t0x6D8F, 0x9BE0, 0x6D90, 0x9BE1, 0x6D91, 0xE4B3, 0x6D92, 0x9BE2,\r\n\t0x6D93, 0xE4B8, 0x6D94, 0xE4B9, 0x6D95, 0xCCE9, 0x6D96, 0x9BE3,\t0x6D97, 0x9BE4, 0x6D98, 0x9BE5, 0x6D99, 0x9BE6, 0x6D9A, 0x9BE7,\r\n\t0x6D9B, 0xCCCE, 0x6D9C, 0x9BE8, 0x6D9D, 0xC0D4, 0x6D9E, 0xE4B5,\t0x6D9F, 0xC1B0, 0x6DA0, 0xE4B6, 0x6DA1, 0xCED0, 0x6DA2, 0x9BE9,\r\n\t0x6DA3, 0xBBC1, 0x6DA4, 0xB5D3, 0x6DA5, 0x9BEA, 0x6DA6, 0xC8F3,\t0x6DA7, 0xBDA7, 0x6DA8, 0xD5C7, 0x6DA9, 0xC9AC, 0x6DAA, 0xB8A2,\r\n\t0x6DAB, 0xE4CA, 0x6DAC, 0x9BEB, 0x6DAD, 0x9BEC, 0x6DAE, 0xE4CC,\t0x6DAF, 0xD1C4, 0x6DB0, 0x9BED, 0x6DB1, 0x9BEE, 0x6DB2, 0xD2BA,\r\n\t0x6DB3, 0x9BEF, 0x6DB4, 0x9BF0, 0x6DB5, 0xBAAD, 0x6DB6, 0x9BF1,\t0x6DB7, 0x9BF2, 0x6DB8, 0xBAD4, 0x6DB9, 0x9BF3, 0x6DBA, 0x9BF4,\r\n\t0x6DBB, 0x9BF5, 0x6DBC, 0x9BF6, 0x6DBD, 0x9BF7, 0x6DBE, 0x9BF8,\t0x6DBF, 0xE4C3, 0x6DC0, 0xB5ED, 0x6DC1, 0x9BF9, 0x6DC2, 0x9BFA,\r\n\t0x6DC3, 0x9BFB, 0x6DC4, 0xD7CD, 0x6DC5, 0xE4C0, 0x6DC6, 0xCFFD,\t0x6DC7, 0xE4BF, 0x6DC8, 0x9BFC, 0x6DC9, 0x9BFD, 0x6DCA, 0x9BFE,\r\n\t0x6DCB, 0xC1DC, 0x6DCC, 0xCCCA, 0x6DCD, 0x9C40, 0x6DCE, 0x9C41,\t0x6DCF, 0x9C42, 0x6DD0, 0x9C43, 0x6DD1, 0xCAE7, 0x6DD2, 0x9C44,\r\n\t0x6DD3, 0x9C45, 0x6DD4, 0x9C46, 0x6DD5, 0x9C47, 0x6DD6, 0xC4D7,\t0x6DD7, 0x9C48, 0x6DD8, 0xCCD4, 0x6DD9, 0xE4C8, 0x6DDA, 0x9C49,\r\n\t0x6DDB, 0x9C4A, 0x6DDC, 0x9C4B, 0x6DDD, 0xE4C7, 0x6DDE, 0xE4C1,\t0x6DDF, 0x9C4C, 0x6DE0, 0xE4C4, 0x6DE1, 0xB5AD, 0x6DE2, 0x9C4D,\r\n\t0x6DE3, 0x9C4E, 0x6DE4, 0xD3D9, 0x6DE5, 0x9C4F, 0x6DE6, 0xE4C6,\t0x6DE7, 0x9C50, 0x6DE8, 0x9C51, 0x6DE9, 0x9C52, 0x6DEA, 0x9C53,\r\n\t0x6DEB, 0xD2F9, 0x6DEC, 0xB4E3, 0x6DED, 0x9C54, 0x6DEE, 0xBBB4,\t0x6DEF, 0x9C55, 0x6DF0, 0x9C56, 0x6DF1, 0xC9EE, 0x6DF2, 0x9C57,\r\n\t0x6DF3, 0xB4BE, 0x6DF4, 0x9C58, 0x6DF5, 0x9C59, 0x6DF6, 0x9C5A,\t0x6DF7, 0xBBEC, 0x6DF8, 0x9C5B, 0x6DF9, 0xD1CD, 0x6DFA, 0x9C5C,\r\n\t0x6DFB, 0xCCED, 0x6DFC, 0xEDB5, 0x6DFD, 0x9C5D, 0x6DFE, 0x9C5E,\t0x6DFF, 0x9C5F, 0x6E00, 0x9C60, 0x6E01, 0x9C61, 0x6E02, 0x9C62,\r\n\t0x6E03, 0x9C63, 0x6E04, 0x9C64, 0x6E05, 0xC7E5, 0x6E06, 0x9C65,\t0x6E07, 0x9C66, 0x6E08, 0x9C67, 0x6E09, 0x9C68, 0x6E0A, 0xD4A8,\r\n\t0x6E0B, 0x9C69, 0x6E0C, 0xE4CB, 0x6E0D, 0xD7D5, 0x6E0E, 0xE4C2,\t0x6E0F, 0x9C6A, 0x6E10, 0xBDA5, 0x6E11, 0xE4C5, 0x6E12, 0x9C6B,\r\n\t0x6E13, 0x9C6C, 0x6E14, 0xD3E6, 0x6E15, 0x9C6D, 0x6E16, 0xE4C9,\t0x6E17, 0xC9F8, 0x6E18, 0x9C6E, 0x6E19, 0x9C6F, 0x6E1A, 0xE4BE,\r\n\t0x6E1B, 0x9C70, 0x6E1C, 0x9C71, 0x6E1D, 0xD3E5, 0x6E1E, 0x9C72,\t0x6E1F, 0x9C73, 0x6E20, 0xC7FE, 0x6E21, 0xB6C9, 0x6E22, 0x9C74,\r\n\t0x6E23, 0xD4FC, 0x6E24, 0xB2B3, 0x6E25, 0xE4D7, 0x6E26, 0x9C75,\t0x6E27, 0x9C76, 0x6E28, 0x9C77, 0x6E29, 0xCEC2, 0x6E2A, 0x9C78,\r\n\t0x6E2B, 0xE4CD, 0x6E2C, 0x9C79, 0x6E2D, 0xCEBC, 0x6E2E, 0x9C7A,\t0x6E2F, 0xB8DB, 0x6E30, 0x9C7B, 0x6E31, 0x9C7C, 0x6E32, 0xE4D6,\r\n\t0x6E33, 0x9C7D, 0x6E34, 0xBFCA, 0x6E35, 0x9C7E, 0x6E36, 0x9C80,\t0x6E37, 0x9C81, 0x6E38, 0xD3CE, 0x6E39, 0x9C82, 0x6E3A, 0xC3EC,\r\n\t0x6E3B, 0x9C83, 0x6E3C, 0x9C84, 0x6E3D, 0x9C85, 0x6E3E, 0x9C86,\t0x6E3F, 0x9C87, 0x6E40, 0x9C88, 0x6E41, 0x9C89, 0x6E42, 0x9C8A,\r\n\t0x6E43, 0xC5C8, 0x6E44, 0xE4D8, 0x6E45, 0x9C8B, 0x6E46, 0x9C8C,\t0x6E47, 0x9C8D, 0x6E48, 0x9C8E, 0x6E49, 0x9C8F, 0x6E4A, 0x9C90,\r\n\t0x6E4B, 0x9C91, 0x6E4C, 0x9C92, 0x6E4D, 0xCDC4, 0x6E4E, 0xE4CF,\t0x6E4F, 0x9C93, 0x6E50, 0x9C94, 0x6E51, 0x9C95, 0x6E52, 0x9C96,\r\n\t0x6E53, 0xE4D4, 0x6E54, 0xE4D5, 0x6E55, 0x9C97, 0x6E56, 0xBAFE,\t0x6E57, 0x9C98, 0x6E58, 0xCFE6, 0x6E59, 0x9C99, 0x6E5A, 0x9C9A,\r\n\t0x6E5B, 0xD5BF, 0x6E5C, 0x9C9B, 0x6E5D, 0x9C9C, 0x6E5E, 0x9C9D,\t0x6E5F, 0xE4D2, 0x6E60, 0x9C9E, 0x6E61, 0x9C9F, 0x6E62, 0x9CA0,\r\n\t0x6E63, 0x9CA1, 0x6E64, 0x9CA2, 0x6E65, 0x9CA3, 0x6E66, 0x9CA4,\t0x6E67, 0x9CA5, 0x6E68, 0x9CA6, 0x6E69, 0x9CA7, 0x6E6A, 0x9CA8,\r\n\t0x6E6B, 0xE4D0, 0x6E6C, 0x9CA9, 0x6E6D, 0x9CAA, 0x6E6E, 0xE4CE,\t0x6E6F, 0x9CAB, 0x6E70, 0x9CAC, 0x6E71, 0x9CAD, 0x6E72, 0x9CAE,\r\n\t0x6E73, 0x9CAF, 0x6E74, 0x9CB0, 0x6E75, 0x9CB1, 0x6E76, 0x9CB2,\t0x6E77, 0x9CB3, 0x6E78, 0x9CB4, 0x6E79, 0x9CB5, 0x6E7A, 0x9CB6,\r\n\t0x6E7B, 0x9CB7, 0x6E7C, 0x9CB8, 0x6E7D, 0x9CB9, 0x6E7E, 0xCDE5,\t0x6E7F, 0xCAAA, 0x6E80, 0x9CBA, 0x6E81, 0x9CBB, 0x6E82, 0x9CBC,\r\n\t0x6E83, 0xC0A3, 0x6E84, 0x9CBD, 0x6E85, 0xBDA6, 0x6E86, 0xE4D3,\t0x6E87, 0x9CBE, 0x6E88, 0x9CBF, 0x6E89, 0xB8C8, 0x6E8A, 0x9CC0,\r\n\t0x6E8B, 0x9CC1, 0x6E8C, 0x9CC2, 0x6E8D, 0x9CC3, 0x6E8E, 0x9CC4,\t0x6E8F, 0xE4E7, 0x6E90, 0xD4B4, 0x6E91, 0x9CC5, 0x6E92, 0x9CC6,\r\n\t0x6E93, 0x9CC7, 0x6E94, 0x9CC8, 0x6E95, 0x9CC9, 0x6E96, 0x9CCA,\t0x6E97, 0x9CCB, 0x6E98, 0xE4DB, 0x6E99, 0x9CCC, 0x6E9A, 0x9CCD,\r\n\t0x6E9B, 0x9CCE, 0x6E9C, 0xC1EF, 0x6E9D, 0x9CCF, 0x6E9E, 0x9CD0,\t0x6E9F, 0xE4E9, 0x6EA0, 0x9CD1, 0x6EA1, 0x9CD2, 0x6EA2, 0xD2E7,\r\n\t0x6EA3, 0x9CD3, 0x6EA4, 0x9CD4, 0x6EA5, 0xE4DF, 0x6EA6, 0x9CD5,\t0x6EA7, 0xE4E0, 0x6EA8, 0x9CD6, 0x6EA9, 0x9CD7, 0x6EAA, 0xCFAA,\r\n\t0x6EAB, 0x9CD8, 0x6EAC, 0x9CD9, 0x6EAD, 0x9CDA, 0x6EAE, 0x9CDB,\t0x6EAF, 0xCBDD, 0x6EB0, 0x9CDC, 0x6EB1, 0xE4DA, 0x6EB2, 0xE4D1,\r\n\t0x6EB3, 0x9CDD, 0x6EB4, 0xE4E5, 0x6EB5, 0x9CDE, 0x6EB6, 0xC8DC,\t0x6EB7, 0xE4E3, 0x6EB8, 0x9CDF, 0x6EB9, 0x9CE0, 0x6EBA, 0xC4E7,\r\n\t0x6EBB, 0xE4E2, 0x6EBC, 0x9CE1, 0x6EBD, 0xE4E1, 0x6EBE, 0x9CE2,\t0x6EBF, 0x9CE3, 0x6EC0, 0x9CE4, 0x6EC1, 0xB3FC, 0x6EC2, 0xE4E8,\r\n\t0x6EC3, 0x9CE5, 0x6EC4, 0x9CE6, 0x6EC5, 0x9CE7, 0x6EC6, 0x9CE8,\t0x6EC7, 0xB5E1, 0x6EC8, 0x9CE9, 0x6EC9, 0x9CEA, 0x6ECA, 0x9CEB,\r\n\t0x6ECB, 0xD7CC, 0x6ECC, 0x9CEC, 0x6ECD, 0x9CED, 0x6ECE, 0x9CEE,\t0x6ECF, 0xE4E6, 0x6ED0, 0x9CEF, 0x6ED1, 0xBBAC, 0x6ED2, 0x9CF0,\r\n\t0x6ED3, 0xD7D2, 0x6ED4, 0xCCCF, 0x6ED5, 0xEBF8, 0x6ED6, 0x9CF1,\t0x6ED7, 0xE4E4, 0x6ED8, 0x9CF2, 0x6ED9, 0x9CF3, 0x6EDA, 0xB9F6,\r\n\t0x6EDB, 0x9CF4, 0x6EDC, 0x9CF5, 0x6EDD, 0x9CF6, 0x6EDE, 0xD6CD,\t0x6EDF, 0xE4D9, 0x6EE0, 0xE4DC, 0x6EE1, 0xC2FA, 0x6EE2, 0xE4DE,\r\n\t0x6EE3, 0x9CF7, 0x6EE4, 0xC2CB, 0x6EE5, 0xC0C4, 0x6EE6, 0xC2D0,\t0x6EE7, 0x9CF8, 0x6EE8, 0xB1F5, 0x6EE9, 0xCCB2, 0x6EEA, 0x9CF9,\r\n\t0x6EEB, 0x9CFA, 0x6EEC, 0x9CFB, 0x6EED, 0x9CFC, 0x6EEE, 0x9CFD,\t0x6EEF, 0x9CFE, 0x6EF0, 0x9D40, 0x6EF1, 0x9D41, 0x6EF2, 0x9D42,\r\n\t0x6EF3, 0x9D43, 0x6EF4, 0xB5CE, 0x6EF5, 0x9D44, 0x6EF6, 0x9D45,\t0x6EF7, 0x9D46, 0x6EF8, 0x9D47, 0x6EF9, 0xE4EF, 0x6EFA, 0x9D48,\r\n\t0x6EFB, 0x9D49, 0x6EFC, 0x9D4A, 0x6EFD, 0x9D4B, 0x6EFE, 0x9D4C,\t0x6EFF, 0x9D4D, 0x6F00, 0x9D4E, 0x6F01, 0x9D4F, 0x6F02, 0xC6AF,\r\n\t0x6F03, 0x9D50, 0x6F04, 0x9D51, 0x6F05, 0x9D52, 0x6F06, 0xC6E1,\t0x6F07, 0x9D53, 0x6F08, 0x9D54, 0x6F09, 0xE4F5, 0x6F0A, 0x9D55,\r\n\t0x6F0B, 0x9D56, 0x6F0C, 0x9D57, 0x6F0D, 0x9D58, 0x6F0E, 0x9D59,\t0x6F0F, 0xC2A9, 0x6F10, 0x9D5A, 0x6F11, 0x9D5B, 0x6F12, 0x9D5C,\r\n\t0x6F13, 0xC0EC, 0x6F14, 0xD1DD, 0x6F15, 0xE4EE, 0x6F16, 0x9D5D,\t0x6F17, 0x9D5E, 0x6F18, 0x9D5F, 0x6F19, 0x9D60, 0x6F1A, 0x9D61,\r\n\t0x6F1B, 0x9D62, 0x6F1C, 0x9D63, 0x6F1D, 0x9D64, 0x6F1E, 0x9D65,\t0x6F1F, 0x9D66, 0x6F20, 0xC4AE, 0x6F21, 0x9D67, 0x6F22, 0x9D68,\r\n\t0x6F23, 0x9D69, 0x6F24, 0xE4ED, 0x6F25, 0x9D6A, 0x6F26, 0x9D6B,\t0x6F27, 0x9D6C, 0x6F28, 0x9D6D, 0x6F29, 0xE4F6, 0x6F2A, 0xE4F4,\r\n\t0x6F2B, 0xC2FE, 0x6F2C, 0x9D6E, 0x6F2D, 0xE4DD, 0x6F2E, 0x9D6F,\t0x6F2F, 0xE4F0, 0x6F30, 0x9D70, 0x6F31, 0xCAFE, 0x6F32, 0x9D71,\r\n\t0x6F33, 0xD5C4, 0x6F34, 0x9D72, 0x6F35, 0x9D73, 0x6F36, 0xE4F1,\t0x6F37, 0x9D74, 0x6F38, 0x9D75, 0x6F39, 0x9D76, 0x6F3A, 0x9D77,\r\n\t0x6F3B, 0x9D78, 0x6F3C, 0x9D79, 0x6F3D, 0x9D7A, 0x6F3E, 0xD1FA,\t0x6F3F, 0x9D7B, 0x6F40, 0x9D7C, 0x6F41, 0x9D7D, 0x6F42, 0x9D7E,\r\n\t0x6F43, 0x9D80, 0x6F44, 0x9D81, 0x6F45, 0x9D82, 0x6F46, 0xE4EB,\t0x6F47, 0xE4EC, 0x6F48, 0x9D83, 0x6F49, 0x9D84, 0x6F4A, 0x9D85,\r\n\t0x6F4B, 0xE4F2, 0x6F4C, 0x9D86, 0x6F4D, 0xCEAB, 0x6F4E, 0x9D87,\t0x6F4F, 0x9D88, 0x6F50, 0x9D89, 0x6F51, 0x9D8A, 0x6F52, 0x9D8B,\r\n\t0x6F53, 0x9D8C, 0x6F54, 0x9D8D, 0x6F55, 0x9D8E, 0x6F56, 0x9D8F,\t0x6F57, 0x9D90, 0x6F58, 0xC5CB, 0x6F59, 0x9D91, 0x6F5A, 0x9D92,\r\n\t0x6F5B, 0x9D93, 0x6F5C, 0xC7B1, 0x6F5D, 0x9D94, 0x6F5E, 0xC2BA,\t0x6F5F, 0x9D95, 0x6F60, 0x9D96, 0x6F61, 0x9D97, 0x6F62, 0xE4EA,\r\n\t0x6F63, 0x9D98, 0x6F64, 0x9D99, 0x6F65, 0x9D9A, 0x6F66, 0xC1CA,\t0x6F67, 0x9D9B, 0x6F68, 0x9D9C, 0x6F69, 0x9D9D, 0x6F6A, 0x9D9E,\r\n\t0x6F6B, 0x9D9F, 0x6F6C, 0x9DA0, 0x6F6D, 0xCCB6, 0x6F6E, 0xB3B1,\t0x6F6F, 0x9DA1, 0x6F70, 0x9DA2, 0x6F71, 0x9DA3, 0x6F72, 0xE4FB,\r\n\t0x6F73, 0x9DA4, 0x6F74, 0xE4F3, 0x6F75, 0x9DA5, 0x6F76, 0x9DA6,\t0x6F77, 0x9DA7, 0x6F78, 0xE4FA, 0x6F79, 0x9DA8, 0x6F7A, 0xE4FD,\r\n\t0x6F7B, 0x9DA9, 0x6F7C, 0xE4FC, 0x6F7D, 0x9DAA, 0x6F7E, 0x9DAB,\t0x6F7F, 0x9DAC, 0x6F80, 0x9DAD, 0x6F81, 0x9DAE, 0x6F82, 0x9DAF,\r\n\t0x6F83, 0x9DB0, 0x6F84, 0xB3CE, 0x6F85, 0x9DB1, 0x6F86, 0x9DB2,\t0x6F87, 0x9DB3, 0x6F88, 0xB3BA, 0x6F89, 0xE4F7, 0x6F8A, 0x9DB4,\r\n\t0x6F8B, 0x9DB5, 0x6F8C, 0xE4F9, 0x6F8D, 0xE4F8, 0x6F8E, 0xC5EC,\t0x6F8F, 0x9DB6, 0x6F90, 0x9DB7, 0x6F91, 0x9DB8, 0x6F92, 0x9DB9,\r\n\t0x6F93, 0x9DBA, 0x6F94, 0x9DBB, 0x6F95, 0x9DBC, 0x6F96, 0x9DBD,\t0x6F97, 0x9DBE, 0x6F98, 0x9DBF, 0x6F99, 0x9DC0, 0x6F9A, 0x9DC1,\r\n\t0x6F9B, 0x9DC2, 0x6F9C, 0xC0BD, 0x6F9D, 0x9DC3, 0x6F9E, 0x9DC4,\t0x6F9F, 0x9DC5, 0x6FA0, 0x9DC6, 0x6FA1, 0xD4E8, 0x6FA2, 0x9DC7,\r\n\t0x6FA3, 0x9DC8, 0x6FA4, 0x9DC9, 0x6FA5, 0x9DCA, 0x6FA6, 0x9DCB,\t0x6FA7, 0xE5A2, 0x6FA8, 0x9DCC, 0x6FA9, 0x9DCD, 0x6FAA, 0x9DCE,\r\n\t0x6FAB, 0x9DCF, 0x6FAC, 0x9DD0, 0x6FAD, 0x9DD1, 0x6FAE, 0x9DD2,\t0x6FAF, 0x9DD3, 0x6FB0, 0x9DD4, 0x6FB1, 0x9DD5, 0x6FB2, 0x9DD6,\r\n\t0x6FB3, 0xB0C4, 0x6FB4, 0x9DD7, 0x6FB5, 0x9DD8, 0x6FB6, 0xE5A4,\t0x6FB7, 0x9DD9, 0x6FB8, 0x9DDA, 0x6FB9, 0xE5A3, 0x6FBA, 0x9DDB,\r\n\t0x6FBB, 0x9DDC, 0x6FBC, 0x9DDD, 0x6FBD, 0x9DDE, 0x6FBE, 0x9DDF,\t0x6FBF, 0x9DE0, 0x6FC0, 0xBCA4, 0x6FC1, 0x9DE1, 0x6FC2, 0xE5A5,\r\n\t0x6FC3, 0x9DE2, 0x6FC4, 0x9DE3, 0x6FC5, 0x9DE4, 0x6FC6, 0x9DE5,\t0x6FC7, 0x9DE6, 0x6FC8, 0x9DE7, 0x6FC9, 0xE5A1, 0x6FCA, 0x9DE8,\r\n\t0x6FCB, 0x9DE9, 0x6FCC, 0x9DEA, 0x6FCD, 0x9DEB, 0x6FCE, 0x9DEC,\t0x6FCF, 0x9DED, 0x6FD0, 0x9DEE, 0x6FD1, 0xE4FE, 0x6FD2, 0xB1F4,\r\n\t0x6FD3, 0x9DEF, 0x6FD4, 0x9DF0, 0x6FD5, 0x9DF1, 0x6FD6, 0x9DF2,\t0x6FD7, 0x9DF3, 0x6FD8, 0x9DF4, 0x6FD9, 0x9DF5, 0x6FDA, 0x9DF6,\r\n\t0x6FDB, 0x9DF7, 0x6FDC, 0x9DF8, 0x6FDD, 0x9DF9, 0x6FDE, 0xE5A8,\t0x6FDF, 0x9DFA, 0x6FE0, 0xE5A9, 0x6FE1, 0xE5A6, 0x6FE2, 0x9DFB,\r\n\t0x6FE3, 0x9DFC, 0x6FE4, 0x9DFD, 0x6FE5, 0x9DFE, 0x6FE6, 0x9E40,\t0x6FE7, 0x9E41, 0x6FE8, 0x9E42, 0x6FE9, 0x9E43, 0x6FEA, 0x9E44,\r\n\t0x6FEB, 0x9E45, 0x6FEC, 0x9E46, 0x6FED, 0x9E47, 0x6FEE, 0xE5A7,\t0x6FEF, 0xE5AA, 0x6FF0, 0x9E48, 0x6FF1, 0x9E49, 0x6FF2, 0x9E4A,\r\n\t0x6FF3, 0x9E4B, 0x6FF4, 0x9E4C, 0x6FF5, 0x9E4D, 0x6FF6, 0x9E4E,\t0x6FF7, 0x9E4F, 0x6FF8, 0x9E50, 0x6FF9, 0x9E51, 0x6FFA, 0x9E52,\r\n\t0x6FFB, 0x9E53, 0x6FFC, 0x9E54, 0x6FFD, 0x9E55, 0x6FFE, 0x9E56,\t0x6FFF, 0x9E57, 0x7000, 0x9E58, 0x7001, 0x9E59, 0x7002, 0x9E5A,\r\n\t0x7003, 0x9E5B, 0x7004, 0x9E5C, 0x7005, 0x9E5D, 0x7006, 0x9E5E,\t0x7007, 0x9E5F, 0x7008, 0x9E60, 0x7009, 0x9E61, 0x700A, 0x9E62,\r\n\t0x700B, 0x9E63, 0x700C, 0x9E64, 0x700D, 0x9E65, 0x700E, 0x9E66,\t0x700F, 0x9E67, 0x7010, 0x9E68, 0x7011, 0xC6D9, 0x7012, 0x9E69,\r\n\t0x7013, 0x9E6A, 0x7014, 0x9E6B, 0x7015, 0x9E6C, 0x7016, 0x9E6D,\t0x7017, 0x9E6E, 0x7018, 0x9E6F, 0x7019, 0x9E70, 0x701A, 0xE5AB,\r\n\t0x701B, 0xE5AD, 0x701C, 0x9E71, 0x701D, 0x9E72, 0x701E, 0x9E73,\t0x701F, 0x9E74, 0x7020, 0x9E75, 0x7021, 0x9E76, 0x7022, 0x9E77,\r\n\t0x7023, 0xE5AC, 0x7024, 0x9E78, 0x7025, 0x9E79, 0x7026, 0x9E7A,\t0x7027, 0x9E7B, 0x7028, 0x9E7C, 0x7029, 0x9E7D, 0x702A, 0x9E7E,\r\n\t0x702B, 0x9E80, 0x702C, 0x9E81, 0x702D, 0x9E82, 0x702E, 0x9E83,\t0x702F, 0x9E84, 0x7030, 0x9E85, 0x7031, 0x9E86, 0x7032, 0x9E87,\r\n\t0x7033, 0x9E88, 0x7034, 0x9E89, 0x7035, 0xE5AF, 0x7036, 0x9E8A,\t0x7037, 0x9E8B, 0x7038, 0x9E8C, 0x7039, 0xE5AE, 0x703A, 0x9E8D,\r\n\t0x703B, 0x9E8E, 0x703C, 0x9E8F, 0x703D, 0x9E90, 0x703E, 0x9E91,\t0x703F, 0x9E92, 0x7040, 0x9E93, 0x7041, 0x9E94, 0x7042, 0x9E95,\r\n\t0x7043, 0x9E96, 0x7044, 0x9E97, 0x7045, 0x9E98, 0x7046, 0x9E99,\t0x7047, 0x9E9A, 0x7048, 0x9E9B, 0x7049, 0x9E9C, 0x704A, 0x9E9D,\r\n\t0x704B, 0x9E9E, 0x704C, 0xB9E0, 0x704D, 0x9E9F, 0x704E, 0x9EA0,\t0x704F, 0xE5B0, 0x7050, 0x9EA1, 0x7051, 0x9EA2, 0x7052, 0x9EA3,\r\n\t0x7053, 0x9EA4, 0x7054, 0x9EA5, 0x7055, 0x9EA6, 0x7056, 0x9EA7,\t0x7057, 0x9EA8, 0x7058, 0x9EA9, 0x7059, 0x9EAA, 0x705A, 0x9EAB,\r\n\t0x705B, 0x9EAC, 0x705C, 0x9EAD, 0x705D, 0x9EAE, 0x705E, 0xE5B1,\t0x705F, 0x9EAF, 0x7060, 0x9EB0, 0x7061, 0x9EB1, 0x7062, 0x9EB2,\r\n\t0x7063, 0x9EB3, 0x7064, 0x9EB4, 0x7065, 0x9EB5, 0x7066, 0x9EB6,\t0x7067, 0x9EB7, 0x7068, 0x9EB8, 0x7069, 0x9EB9, 0x706A, 0x9EBA,\r\n\t0x706B, 0xBBF0, 0x706C, 0xECE1, 0x706D, 0xC3F0, 0x706E, 0x9EBB,\t0x706F, 0xB5C6, 0x7070, 0xBBD2, 0x7071, 0x9EBC, 0x7072, 0x9EBD,\r\n\t0x7073, 0x9EBE, 0x7074, 0x9EBF, 0x7075, 0xC1E9, 0x7076, 0xD4EE,\t0x7077, 0x9EC0, 0x7078, 0xBEC4, 0x7079, 0x9EC1, 0x707A, 0x9EC2,\r\n\t0x707B, 0x9EC3, 0x707C, 0xD7C6, 0x707D, 0x9EC4, 0x707E, 0xD4D6,\t0x707F, 0xB2D3, 0x7080, 0xECBE, 0x7081, 0x9EC5, 0x7082, 0x9EC6,\r\n\t0x7083, 0x9EC7, 0x7084, 0x9EC8, 0x7085, 0xEAC1, 0x7086, 0x9EC9,\t0x7087, 0x9ECA, 0x7088, 0x9ECB, 0x7089, 0xC2AF, 0x708A, 0xB4B6,\r\n\t0x708B, 0x9ECC, 0x708C, 0x9ECD, 0x708D, 0x9ECE, 0x708E, 0xD1D7,\t0x708F, 0x9ECF, 0x7090, 0x9ED0, 0x7091, 0x9ED1, 0x7092, 0xB3B4,\r\n\t0x7093, 0x9ED2, 0x7094, 0xC8B2, 0x7095, 0xBFBB, 0x7096, 0xECC0,\t0x7097, 0x9ED3, 0x7098, 0x9ED4, 0x7099, 0xD6CB, 0x709A, 0x9ED5,\r\n\t0x709B, 0x9ED6, 0x709C, 0xECBF, 0x709D, 0xECC1, 0x709E, 0x9ED7,\t0x709F, 0x9ED8, 0x70A0, 0x9ED9, 0x70A1, 0x9EDA, 0x70A2, 0x9EDB,\r\n\t0x70A3, 0x9EDC, 0x70A4, 0x9EDD, 0x70A5, 0x9EDE, 0x70A6, 0x9EDF,\t0x70A7, 0x9EE0, 0x70A8, 0x9EE1, 0x70A9, 0x9EE2, 0x70AA, 0x9EE3,\r\n\t0x70AB, 0xECC5, 0x70AC, 0xBEE6, 0x70AD, 0xCCBF, 0x70AE, 0xC5DA,\t0x70AF, 0xBEBC, 0x70B0, 0x9EE4, 0x70B1, 0xECC6, 0x70B2, 0x9EE5,\r\n\t0x70B3, 0xB1FE, 0x70B4, 0x9EE6, 0x70B5, 0x9EE7, 0x70B6, 0x9EE8,\t0x70B7, 0xECC4, 0x70B8, 0xD5A8, 0x70B9, 0xB5E3, 0x70BA, 0x9EE9,\r\n\t0x70BB, 0xECC2, 0x70BC, 0xC1B6, 0x70BD, 0xB3E3, 0x70BE, 0x9EEA,\t0x70BF, 0x9EEB, 0x70C0, 0xECC3, 0x70C1, 0xCBB8, 0x70C2, 0xC0C3,\r\n\t0x70C3, 0xCCFE, 0x70C4, 0x9EEC, 0x70C5, 0x9EED, 0x70C6, 0x9EEE,\t0x70C7, 0x9EEF, 0x70C8, 0xC1D2, 0x70C9, 0x9EF0, 0x70CA, 0xECC8,\r\n\t0x70CB, 0x9EF1, 0x70CC, 0x9EF2, 0x70CD, 0x9EF3, 0x70CE, 0x9EF4,\t0x70CF, 0x9EF5, 0x70D0, 0x9EF6, 0x70D1, 0x9EF7, 0x70D2, 0x9EF8,\r\n\t0x70D3, 0x9EF9, 0x70D4, 0x9EFA, 0x70D5, 0x9EFB, 0x70D6, 0x9EFC,\t0x70D7, 0x9EFD, 0x70D8, 0xBAE6, 0x70D9, 0xC0D3, 0x70DA, 0x9EFE,\r\n\t0x70DB, 0xD6F2, 0x70DC, 0x9F40, 0x70DD, 0x9F41, 0x70DE, 0x9F42,\t0x70DF, 0xD1CC, 0x70E0, 0x9F43, 0x70E1, 0x9F44, 0x70E2, 0x9F45,\r\n\t0x70E3, 0x9F46, 0x70E4, 0xBFBE, 0x70E5, 0x9F47, 0x70E6, 0xB7B3,\t0x70E7, 0xC9D5, 0x70E8, 0xECC7, 0x70E9, 0xBBE2, 0x70EA, 0x9F48,\r\n\t0x70EB, 0xCCCC, 0x70EC, 0xBDFD, 0x70ED, 0xC8C8, 0x70EE, 0x9F49,\t0x70EF, 0xCFA9, 0x70F0, 0x9F4A, 0x70F1, 0x9F4B, 0x70F2, 0x9F4C,\r\n\t0x70F3, 0x9F4D, 0x70F4, 0x9F4E, 0x70F5, 0x9F4F, 0x70F6, 0x9F50,\t0x70F7, 0xCDE9, 0x70F8, 0x9F51, 0x70F9, 0xC5EB, 0x70FA, 0x9F52,\r\n\t0x70FB, 0x9F53, 0x70FC, 0x9F54, 0x70FD, 0xB7E9, 0x70FE, 0x9F55,\t0x70FF, 0x9F56, 0x7100, 0x9F57, 0x7101, 0x9F58, 0x7102, 0x9F59,\r\n\t0x7103, 0x9F5A, 0x7104, 0x9F5B, 0x7105, 0x9F5C, 0x7106, 0x9F5D,\t0x7107, 0x9F5E, 0x7108, 0x9F5F, 0x7109, 0xD1C9, 0x710A, 0xBAB8,\r\n\t0x710B, 0x9F60, 0x710C, 0x9F61, 0x710D, 0x9F62, 0x710E, 0x9F63,\t0x710F, 0x9F64, 0x7110, 0xECC9, 0x7111, 0x9F65, 0x7112, 0x9F66,\r\n\t0x7113, 0xECCA, 0x7114, 0x9F67, 0x7115, 0xBBC0, 0x7116, 0xECCB,\t0x7117, 0x9F68, 0x7118, 0xECE2, 0x7119, 0xB1BA, 0x711A, 0xB7D9,\r\n\t0x711B, 0x9F69, 0x711C, 0x9F6A, 0x711D, 0x9F6B, 0x711E, 0x9F6C,\t0x711F, 0x9F6D, 0x7120, 0x9F6E, 0x7121, 0x9F6F, 0x7122, 0x9F70,\r\n\t0x7123, 0x9F71, 0x7124, 0x9F72, 0x7125, 0x9F73, 0x7126, 0xBDB9,\t0x7127, 0x9F74, 0x7128, 0x9F75, 0x7129, 0x9F76, 0x712A, 0x9F77,\r\n\t0x712B, 0x9F78, 0x712C, 0x9F79, 0x712D, 0x9F7A, 0x712E, 0x9F7B,\t0x712F, 0xECCC, 0x7130, 0xD1E6, 0x7131, 0xECCD, 0x7132, 0x9F7C,\r\n\t0x7133, 0x9F7D, 0x7134, 0x9F7E, 0x7135, 0x9F80, 0x7136, 0xC8BB,\t0x7137, 0x9F81, 0x7138, 0x9F82, 0x7139, 0x9F83, 0x713A, 0x9F84,\r\n\t0x713B, 0x9F85, 0x713C, 0x9F86, 0x713D, 0x9F87, 0x713E, 0x9F88,\t0x713F, 0x9F89, 0x7140, 0x9F8A, 0x7141, 0x9F8B, 0x7142, 0x9F8C,\r\n\t0x7143, 0x9F8D, 0x7144, 0x9F8E, 0x7145, 0xECD1, 0x7146, 0x9F8F,\t0x7147, 0x9F90, 0x7148, 0x9F91, 0x7149, 0x9F92, 0x714A, 0xECD3,\r\n\t0x714B, 0x9F93, 0x714C, 0xBBCD, 0x714D, 0x9F94, 0x714E, 0xBCE5,\t0x714F, 0x9F95, 0x7150, 0x9F96, 0x7151, 0x9F97, 0x7152, 0x9F98,\r\n\t0x7153, 0x9F99, 0x7154, 0x9F9A, 0x7155, 0x9F9B, 0x7156, 0x9F9C,\t0x7157, 0x9F9D, 0x7158, 0x9F9E, 0x7159, 0x9F9F, 0x715A, 0x9FA0,\r\n\t0x715B, 0x9FA1, 0x715C, 0xECCF, 0x715D, 0x9FA2, 0x715E, 0xC9B7,\t0x715F, 0x9FA3, 0x7160, 0x9FA4, 0x7161, 0x9FA5, 0x7162, 0x9FA6,\r\n\t0x7163, 0x9FA7, 0x7164, 0xC3BA, 0x7165, 0x9FA8, 0x7166, 0xECE3,\t0x7167, 0xD5D5, 0x7168, 0xECD0, 0x7169, 0x9FA9, 0x716A, 0x9FAA,\r\n\t0x716B, 0x9FAB, 0x716C, 0x9FAC, 0x716D, 0x9FAD, 0x716E, 0xD6F3,\t0x716F, 0x9FAE, 0x7170, 0x9FAF, 0x7171, 0x9FB0, 0x7172, 0xECD2,\r\n\t0x7173, 0xECCE, 0x7174, 0x9FB1, 0x7175, 0x9FB2, 0x7176, 0x9FB3,\t0x7177, 0x9FB4, 0x7178, 0xECD4, 0x7179, 0x9FB5, 0x717A, 0xECD5,\r\n\t0x717B, 0x9FB6, 0x717C, 0x9FB7, 0x717D, 0xC9BF, 0x717E, 0x9FB8,\t0x717F, 0x9FB9, 0x7180, 0x9FBA, 0x7181, 0x9FBB, 0x7182, 0x9FBC,\r\n\t0x7183, 0x9FBD, 0x7184, 0xCFA8, 0x7185, 0x9FBE, 0x7186, 0x9FBF,\t0x7187, 0x9FC0, 0x7188, 0x9FC1, 0x7189, 0x9FC2, 0x718A, 0xD0DC,\r\n\t0x718B, 0x9FC3, 0x718C, 0x9FC4, 0x718D, 0x9FC5, 0x718E, 0x9FC6,\t0x718F, 0xD1AC, 0x7190, 0x9FC7, 0x7191, 0x9FC8, 0x7192, 0x9FC9,\r\n\t0x7193, 0x9FCA, 0x7194, 0xC8DB, 0x7195, 0x9FCB, 0x7196, 0x9FCC,\t0x7197, 0x9FCD, 0x7198, 0xECD6, 0x7199, 0xCEF5, 0x719A, 0x9FCE,\r\n\t0x719B, 0x9FCF, 0x719C, 0x9FD0, 0x719D, 0x9FD1, 0x719E, 0x9FD2,\t0x719F, 0xCAEC, 0x71A0, 0xECDA, 0x71A1, 0x9FD3, 0x71A2, 0x9FD4,\r\n\t0x71A3, 0x9FD5, 0x71A4, 0x9FD6, 0x71A5, 0x9FD7, 0x71A6, 0x9FD8,\t0x71A7, 0x9FD9, 0x71A8, 0xECD9, 0x71A9, 0x9FDA, 0x71AA, 0x9FDB,\r\n\t0x71AB, 0x9FDC, 0x71AC, 0xB0BE, 0x71AD, 0x9FDD, 0x71AE, 0x9FDE,\t0x71AF, 0x9FDF, 0x71B0, 0x9FE0, 0x71B1, 0x9FE1, 0x71B2, 0x9FE2,\r\n\t0x71B3, 0xECD7, 0x71B4, 0x9FE3, 0x71B5, 0xECD8, 0x71B6, 0x9FE4,\t0x71B7, 0x9FE5, 0x71B8, 0x9FE6, 0x71B9, 0xECE4, 0x71BA, 0x9FE7,\r\n\t0x71BB, 0x9FE8, 0x71BC, 0x9FE9, 0x71BD, 0x9FEA, 0x71BE, 0x9FEB,\t0x71BF, 0x9FEC, 0x71C0, 0x9FED, 0x71C1, 0x9FEE, 0x71C2, 0x9FEF,\r\n\t0x71C3, 0xC8BC, 0x71C4, 0x9FF0, 0x71C5, 0x9FF1, 0x71C6, 0x9FF2,\t0x71C7, 0x9FF3, 0x71C8, 0x9FF4, 0x71C9, 0x9FF5, 0x71CA, 0x9FF6,\r\n\t0x71CB, 0x9FF7, 0x71CC, 0x9FF8, 0x71CD, 0x9FF9, 0x71CE, 0xC1C7,\t0x71CF, 0x9FFA, 0x71D0, 0x9FFB, 0x71D1, 0x9FFC, 0x71D2, 0x9FFD,\r\n\t0x71D3, 0x9FFE, 0x71D4, 0xECDC, 0x71D5, 0xD1E0, 0x71D6, 0xA040,\t0x71D7, 0xA041, 0x71D8, 0xA042, 0x71D9, 0xA043, 0x71DA, 0xA044,\r\n\t0x71DB, 0xA045, 0x71DC, 0xA046, 0x71DD, 0xA047, 0x71DE, 0xA048,\t0x71DF, 0xA049, 0x71E0, 0xECDB, 0x71E1, 0xA04A, 0x71E2, 0xA04B,\r\n\t0x71E3, 0xA04C, 0x71E4, 0xA04D, 0x71E5, 0xD4EF, 0x71E6, 0xA04E,\t0x71E7, 0xECDD, 0x71E8, 0xA04F, 0x71E9, 0xA050, 0x71EA, 0xA051,\r\n\t0x71EB, 0xA052, 0x71EC, 0xA053, 0x71ED, 0xA054, 0x71EE, 0xDBC6,\t0x71EF, 0xA055, 0x71F0, 0xA056, 0x71F1, 0xA057, 0x71F2, 0xA058,\r\n\t0x71F3, 0xA059, 0x71F4, 0xA05A, 0x71F5, 0xA05B, 0x71F6, 0xA05C,\t0x71F7, 0xA05D, 0x71F8, 0xA05E, 0x71F9, 0xECDE, 0x71FA, 0xA05F,\r\n\t0x71FB, 0xA060, 0x71FC, 0xA061, 0x71FD, 0xA062, 0x71FE, 0xA063,\t0x71FF, 0xA064, 0x7200, 0xA065, 0x7201, 0xA066, 0x7202, 0xA067,\r\n\t0x7203, 0xA068, 0x7204, 0xA069, 0x7205, 0xA06A, 0x7206, 0xB1AC,\t0x7207, 0xA06B, 0x7208, 0xA06C, 0x7209, 0xA06D, 0x720A, 0xA06E,\r\n\t0x720B, 0xA06F, 0x720C, 0xA070, 0x720D, 0xA071, 0x720E, 0xA072,\t0x720F, 0xA073, 0x7210, 0xA074, 0x7211, 0xA075, 0x7212, 0xA076,\r\n\t0x7213, 0xA077, 0x7214, 0xA078, 0x7215, 0xA079, 0x7216, 0xA07A,\t0x7217, 0xA07B, 0x7218, 0xA07C, 0x7219, 0xA07D, 0x721A, 0xA07E,\r\n\t0x721B, 0xA080, 0x721C, 0xA081, 0x721D, 0xECDF, 0x721E, 0xA082,\t0x721F, 0xA083, 0x7220, 0xA084, 0x7221, 0xA085, 0x7222, 0xA086,\r\n\t0x7223, 0xA087, 0x7224, 0xA088, 0x7225, 0xA089, 0x7226, 0xA08A,\t0x7227, 0xA08B, 0x7228, 0xECE0, 0x7229, 0xA08C, 0x722A, 0xD7A6,\r\n\t0x722B, 0xA08D, 0x722C, 0xC5C0, 0x722D, 0xA08E, 0x722E, 0xA08F,\t0x722F, 0xA090, 0x7230, 0xEBBC, 0x7231, 0xB0AE, 0x7232, 0xA091,\r\n\t0x7233, 0xA092, 0x7234, 0xA093, 0x7235, 0xBEF4, 0x7236, 0xB8B8,\t0x7237, 0xD2AF, 0x7238, 0xB0D6, 0x7239, 0xB5F9, 0x723A, 0xA094,\r\n\t0x723B, 0xD8B3, 0x723C, 0xA095, 0x723D, 0xCBAC, 0x723E, 0xA096,\t0x723F, 0xE3DD, 0x7240, 0xA097, 0x7241, 0xA098, 0x7242, 0xA099,\r\n\t0x7243, 0xA09A, 0x7244, 0xA09B, 0x7245, 0xA09C, 0x7246, 0xA09D,\t0x7247, 0xC6AC, 0x7248, 0xB0E6, 0x7249, 0xA09E, 0x724A, 0xA09F,\r\n\t0x724B, 0xA0A0, 0x724C, 0xC5C6, 0x724D, 0xEBB9, 0x724E, 0xA0A1,\t0x724F, 0xA0A2, 0x7250, 0xA0A3, 0x7251, 0xA0A4, 0x7252, 0xEBBA,\r\n\t0x7253, 0xA0A5, 0x7254, 0xA0A6, 0x7255, 0xA0A7, 0x7256, 0xEBBB,\t0x7257, 0xA0A8, 0x7258, 0xA0A9, 0x7259, 0xD1C0, 0x725A, 0xA0AA,\r\n\t0x725B, 0xC5A3, 0x725C, 0xA0AB, 0x725D, 0xEAF2, 0x725E, 0xA0AC,\t0x725F, 0xC4B2, 0x7260, 0xA0AD, 0x7261, 0xC4B5, 0x7262, 0xC0CE,\r\n\t0x7263, 0xA0AE, 0x7264, 0xA0AF, 0x7265, 0xA0B0, 0x7266, 0xEAF3,\t0x7267, 0xC4C1, 0x7268, 0xA0B1, 0x7269, 0xCEEF, 0x726A, 0xA0B2,\r\n\t0x726B, 0xA0B3, 0x726C, 0xA0B4, 0x726D, 0xA0B5, 0x726E, 0xEAF0,\t0x726F, 0xEAF4, 0x7270, 0xA0B6, 0x7271, 0xA0B7, 0x7272, 0xC9FC,\r\n\t0x7273, 0xA0B8, 0x7274, 0xA0B9, 0x7275, 0xC7A3, 0x7276, 0xA0BA,\t0x7277, 0xA0BB, 0x7278, 0xA0BC, 0x7279, 0xCCD8, 0x727A, 0xCEFE,\r\n\t0x727B, 0xA0BD, 0x727C, 0xA0BE, 0x727D, 0xA0BF, 0x727E, 0xEAF5,\t0x727F, 0xEAF6, 0x7280, 0xCFAC, 0x7281, 0xC0E7, 0x7282, 0xA0C0,\r\n\t0x7283, 0xA0C1, 0x7284, 0xEAF7, 0x7285, 0xA0C2, 0x7286, 0xA0C3,\t0x7287, 0xA0C4, 0x7288, 0xA0C5, 0x7289, 0xA0C6, 0x728A, 0xB6BF,\r\n\t0x728B, 0xEAF8, 0x728C, 0xA0C7, 0x728D, 0xEAF9, 0x728E, 0xA0C8,\t0x728F, 0xEAFA, 0x7290, 0xA0C9, 0x7291, 0xA0CA, 0x7292, 0xEAFB,\r\n\t0x7293, 0xA0CB, 0x7294, 0xA0CC, 0x7295, 0xA0CD, 0x7296, 0xA0CE,\t0x7297, 0xA0CF, 0x7298, 0xA0D0, 0x7299, 0xA0D1, 0x729A, 0xA0D2,\r\n\t0x729B, 0xA0D3, 0x729C, 0xA0D4, 0x729D, 0xA0D5, 0x729E, 0xA0D6,\t0x729F, 0xEAF1, 0x72A0, 0xA0D7, 0x72A1, 0xA0D8, 0x72A2, 0xA0D9,\r\n\t0x72A3, 0xA0DA, 0x72A4, 0xA0DB, 0x72A5, 0xA0DC, 0x72A6, 0xA0DD,\t0x72A7, 0xA0DE, 0x72A8, 0xA0DF, 0x72A9, 0xA0E0, 0x72AA, 0xA0E1,\r\n\t0x72AB, 0xA0E2, 0x72AC, 0xC8AE, 0x72AD, 0xE1EB, 0x72AE, 0xA0E3,\t0x72AF, 0xB7B8, 0x72B0, 0xE1EC, 0x72B1, 0xA0E4, 0x72B2, 0xA0E5,\r\n\t0x72B3, 0xA0E6, 0x72B4, 0xE1ED, 0x72B5, 0xA0E7, 0x72B6, 0xD7B4,\t0x72B7, 0xE1EE, 0x72B8, 0xE1EF, 0x72B9, 0xD3CC, 0x72BA, 0xA0E8,\r\n\t0x72BB, 0xA0E9, 0x72BC, 0xA0EA, 0x72BD, 0xA0EB, 0x72BE, 0xA0EC,\t0x72BF, 0xA0ED, 0x72C0, 0xA0EE, 0x72C1, 0xE1F1, 0x72C2, 0xBFF1,\r\n\t0x72C3, 0xE1F0, 0x72C4, 0xB5D2, 0x72C5, 0xA0EF, 0x72C6, 0xA0F0,\t0x72C7, 0xA0F1, 0x72C8, 0xB1B7, 0x72C9, 0xA0F2, 0x72CA, 0xA0F3,\r\n\t0x72CB, 0xA0F4, 0x72CC, 0xA0F5, 0x72CD, 0xE1F3, 0x72CE, 0xE1F2,\t0x72CF, 0xA0F6, 0x72D0, 0xBAFC, 0x72D1, 0xA0F7, 0x72D2, 0xE1F4,\r\n\t0x72D3, 0xA0F8, 0x72D4, 0xA0F9, 0x72D5, 0xA0FA, 0x72D6, 0xA0FB,\t0x72D7, 0xB9B7, 0x72D8, 0xA0FC, 0x72D9, 0xBED1, 0x72DA, 0xA0FD,\r\n\t0x72DB, 0xA0FE, 0x72DC, 0xAA40, 0x72DD, 0xAA41, 0x72DE, 0xC4FC,\t0x72DF, 0xAA42, 0x72E0, 0xBADD, 0x72E1, 0xBDC6, 0x72E2, 0xAA43,\r\n\t0x72E3, 0xAA44, 0x72E4, 0xAA45, 0x72E5, 0xAA46, 0x72E6, 0xAA47,\t0x72E7, 0xAA48, 0x72E8, 0xE1F5, 0x72E9, 0xE1F7, 0x72EA, 0xAA49,\r\n\t0x72EB, 0xAA4A, 0x72EC, 0xB6C0, 0x72ED, 0xCFC1, 0x72EE, 0xCAA8,\t0x72EF, 0xE1F6, 0x72F0, 0xD5F8, 0x72F1, 0xD3FC, 0x72F2, 0xE1F8,\r\n\t0x72F3, 0xE1FC, 0x72F4, 0xE1F9, 0x72F5, 0xAA4B, 0x72F6, 0xAA4C,\t0x72F7, 0xE1FA, 0x72F8, 0xC0EA, 0x72F9, 0xAA4D, 0x72FA, 0xE1FE,\r\n\t0x72FB, 0xE2A1, 0x72FC, 0xC0C7, 0x72FD, 0xAA4E, 0x72FE, 0xAA4F,\t0x72FF, 0xAA50, 0x7300, 0xAA51, 0x7301, 0xE1FB, 0x7302, 0xAA52,\r\n\t0x7303, 0xE1FD, 0x7304, 0xAA53, 0x7305, 0xAA54, 0x7306, 0xAA55,\t0x7307, 0xAA56, 0x7308, 0xAA57, 0x7309, 0xAA58, 0x730A, 0xE2A5,\r\n\t0x730B, 0xAA59, 0x730C, 0xAA5A, 0x730D, 0xAA5B, 0x730E, 0xC1D4,\t0x730F, 0xAA5C, 0x7310, 0xAA5D, 0x7311, 0xAA5E, 0x7312, 0xAA5F,\r\n\t0x7313, 0xE2A3, 0x7314, 0xAA60, 0x7315, 0xE2A8, 0x7316, 0xB2FE,\t0x7317, 0xE2A2, 0x7318, 0xAA61, 0x7319, 0xAA62, 0x731A, 0xAA63,\r\n\t0x731B, 0xC3CD, 0x731C, 0xB2C2, 0x731D, 0xE2A7, 0x731E, 0xE2A6,\t0x731F, 0xAA64, 0x7320, 0xAA65, 0x7321, 0xE2A4, 0x7322, 0xE2A9,\r\n\t0x7323, 0xAA66, 0x7324, 0xAA67, 0x7325, 0xE2AB, 0x7326, 0xAA68,\t0x7327, 0xAA69, 0x7328, 0xAA6A, 0x7329, 0xD0C9, 0x732A, 0xD6ED,\r\n\t0x732B, 0xC3A8, 0x732C, 0xE2AC, 0x732D, 0xAA6B, 0x732E, 0xCFD7,\t0x732F, 0xAA6C, 0x7330, 0xAA6D, 0x7331, 0xE2AE, 0x7332, 0xAA6E,\r\n\t0x7333, 0xAA6F, 0x7334, 0xBAEF, 0x7335, 0xAA70, 0x7336, 0xAA71,\t0x7337, 0xE9E0, 0x7338, 0xE2AD, 0x7339, 0xE2AA, 0x733A, 0xAA72,\r\n\t0x733B, 0xAA73, 0x733C, 0xAA74, 0x733D, 0xAA75, 0x733E, 0xBBAB,\t0x733F, 0xD4B3, 0x7340, 0xAA76, 0x7341, 0xAA77, 0x7342, 0xAA78,\r\n\t0x7343, 0xAA79, 0x7344, 0xAA7A, 0x7345, 0xAA7B, 0x7346, 0xAA7C,\t0x7347, 0xAA7D, 0x7348, 0xAA7E, 0x7349, 0xAA80, 0x734A, 0xAA81,\r\n\t0x734B, 0xAA82, 0x734C, 0xAA83, 0x734D, 0xE2B0, 0x734E, 0xAA84,\t0x734F, 0xAA85, 0x7350, 0xE2AF, 0x7351, 0xAA86, 0x7352, 0xE9E1,\r\n\t0x7353, 0xAA87, 0x7354, 0xAA88, 0x7355, 0xAA89, 0x7356, 0xAA8A,\t0x7357, 0xE2B1, 0x7358, 0xAA8B, 0x7359, 0xAA8C, 0x735A, 0xAA8D,\r\n\t0x735B, 0xAA8E, 0x735C, 0xAA8F, 0x735D, 0xAA90, 0x735E, 0xAA91,\t0x735F, 0xAA92, 0x7360, 0xE2B2, 0x7361, 0xAA93, 0x7362, 0xAA94,\r\n\t0x7363, 0xAA95, 0x7364, 0xAA96, 0x7365, 0xAA97, 0x7366, 0xAA98,\t0x7367, 0xAA99, 0x7368, 0xAA9A, 0x7369, 0xAA9B, 0x736A, 0xAA9C,\r\n\t0x736B, 0xAA9D, 0x736C, 0xE2B3, 0x736D, 0xCCA1, 0x736E, 0xAA9E,\t0x736F, 0xE2B4, 0x7370, 0xAA9F, 0x7371, 0xAAA0, 0x7372, 0xAB40,\r\n\t0x7373, 0xAB41, 0x7374, 0xAB42, 0x7375, 0xAB43, 0x7376, 0xAB44,\t0x7377, 0xAB45, 0x7378, 0xAB46, 0x7379, 0xAB47, 0x737A, 0xAB48,\r\n\t0x737B, 0xAB49, 0x737C, 0xAB4A, 0x737D, 0xAB4B, 0x737E, 0xE2B5,\t0x737F, 0xAB4C, 0x7380, 0xAB4D, 0x7381, 0xAB4E, 0x7382, 0xAB4F,\r\n\t0x7383, 0xAB50, 0x7384, 0xD0FE, 0x7385, 0xAB51, 0x7386, 0xAB52,\t0x7387, 0xC2CA, 0x7388, 0xAB53, 0x7389, 0xD3F1, 0x738A, 0xAB54,\r\n\t0x738B, 0xCDF5, 0x738C, 0xAB55, 0x738D, 0xAB56, 0x738E, 0xE7E0,\t0x738F, 0xAB57, 0x7390, 0xAB58, 0x7391, 0xE7E1, 0x7392, 0xAB59,\r\n\t0x7393, 0xAB5A, 0x7394, 0xAB5B, 0x7395, 0xAB5C, 0x7396, 0xBEC1,\t0x7397, 0xAB5D, 0x7398, 0xAB5E, 0x7399, 0xAB5F, 0x739A, 0xAB60,\r\n\t0x739B, 0xC2EA, 0x739C, 0xAB61, 0x739D, 0xAB62, 0x739E, 0xAB63,\t0x739F, 0xE7E4, 0x73A0, 0xAB64, 0x73A1, 0xAB65, 0x73A2, 0xE7E3,\r\n\t0x73A3, 0xAB66, 0x73A4, 0xAB67, 0x73A5, 0xAB68, 0x73A6, 0xAB69,\t0x73A7, 0xAB6A, 0x73A8, 0xAB6B, 0x73A9, 0xCDE6, 0x73AA, 0xAB6C,\r\n\t0x73AB, 0xC3B5, 0x73AC, 0xAB6D, 0x73AD, 0xAB6E, 0x73AE, 0xE7E2,\t0x73AF, 0xBBB7, 0x73B0, 0xCFD6, 0x73B1, 0xAB6F, 0x73B2, 0xC1E1,\r\n\t0x73B3, 0xE7E9, 0x73B4, 0xAB70, 0x73B5, 0xAB71, 0x73B6, 0xAB72,\t0x73B7, 0xE7E8, 0x73B8, 0xAB73, 0x73B9, 0xAB74, 0x73BA, 0xE7F4,\r\n\t0x73BB, 0xB2A3, 0x73BC, 0xAB75, 0x73BD, 0xAB76, 0x73BE, 0xAB77,\t0x73BF, 0xAB78, 0x73C0, 0xE7EA, 0x73C1, 0xAB79, 0x73C2, 0xE7E6,\r\n\t0x73C3, 0xAB7A, 0x73C4, 0xAB7B, 0x73C5, 0xAB7C, 0x73C6, 0xAB7D,\t0x73C7, 0xAB7E, 0x73C8, 0xE7EC, 0x73C9, 0xE7EB, 0x73CA, 0xC9BA,\r\n\t0x73CB, 0xAB80, 0x73CC, 0xAB81, 0x73CD, 0xD5E4, 0x73CE, 0xAB82,\t0x73CF, 0xE7E5, 0x73D0, 0xB7A9, 0x73D1, 0xE7E7, 0x73D2, 0xAB83,\r\n\t0x73D3, 0xAB84, 0x73D4, 0xAB85, 0x73D5, 0xAB86, 0x73D6, 0xAB87,\t0x73D7, 0xAB88, 0x73D8, 0xAB89, 0x73D9, 0xE7EE, 0x73DA, 0xAB8A,\r\n\t0x73DB, 0xAB8B, 0x73DC, 0xAB8C, 0x73DD, 0xAB8D, 0x73DE, 0xE7F3,\t0x73DF, 0xAB8E, 0x73E0, 0xD6E9, 0x73E1, 0xAB8F, 0x73E2, 0xAB90,\r\n\t0x73E3, 0xAB91, 0x73E4, 0xAB92, 0x73E5, 0xE7ED, 0x73E6, 0xAB93,\t0x73E7, 0xE7F2, 0x73E8, 0xAB94, 0x73E9, 0xE7F1, 0x73EA, 0xAB95,\r\n\t0x73EB, 0xAB96, 0x73EC, 0xAB97, 0x73ED, 0xB0E0, 0x73EE, 0xAB98,\t0x73EF, 0xAB99, 0x73F0, 0xAB9A, 0x73F1, 0xAB9B, 0x73F2, 0xE7F5,\r\n\t0x73F3, 0xAB9C, 0x73F4, 0xAB9D, 0x73F5, 0xAB9E, 0x73F6, 0xAB9F,\t0x73F7, 0xABA0, 0x73F8, 0xAC40, 0x73F9, 0xAC41, 0x73FA, 0xAC42,\r\n\t0x73FB, 0xAC43, 0x73FC, 0xAC44, 0x73FD, 0xAC45, 0x73FE, 0xAC46,\t0x73FF, 0xAC47, 0x7400, 0xAC48, 0x7401, 0xAC49, 0x7402, 0xAC4A,\r\n\t0x7403, 0xC7F2, 0x7404, 0xAC4B, 0x7405, 0xC0C5, 0x7406, 0xC0ED,\t0x7407, 0xAC4C, 0x7408, 0xAC4D, 0x7409, 0xC1F0, 0x740A, 0xE7F0,\r\n\t0x740B, 0xAC4E, 0x740C, 0xAC4F, 0x740D, 0xAC50, 0x740E, 0xAC51,\t0x740F, 0xE7F6, 0x7410, 0xCBF6, 0x7411, 0xAC52, 0x7412, 0xAC53,\r\n\t0x7413, 0xAC54, 0x7414, 0xAC55, 0x7415, 0xAC56, 0x7416, 0xAC57,\t0x7417, 0xAC58, 0x7418, 0xAC59, 0x7419, 0xAC5A, 0x741A, 0xE8A2,\r\n\t0x741B, 0xE8A1, 0x741C, 0xAC5B, 0x741D, 0xAC5C, 0x741E, 0xAC5D,\t0x741F, 0xAC5E, 0x7420, 0xAC5F, 0x7421, 0xAC60, 0x7422, 0xD7C1,\r\n\t0x7423, 0xAC61, 0x7424, 0xAC62, 0x7425, 0xE7FA, 0x7426, 0xE7F9,\t0x7427, 0xAC63, 0x7428, 0xE7FB, 0x7429, 0xAC64, 0x742A, 0xE7F7,\r\n\t0x742B, 0xAC65, 0x742C, 0xE7FE, 0x742D, 0xAC66, 0x742E, 0xE7FD,\t0x742F, 0xAC67, 0x7430, 0xE7FC, 0x7431, 0xAC68, 0x7432, 0xAC69,\r\n\t0x7433, 0xC1D5, 0x7434, 0xC7D9, 0x7435, 0xC5FD, 0x7436, 0xC5C3,\t0x7437, 0xAC6A, 0x7438, 0xAC6B, 0x7439, 0xAC6C, 0x743A, 0xAC6D,\r\n\t0x743B, 0xAC6E, 0x743C, 0xC7ED, 0x743D, 0xAC6F, 0x743E, 0xAC70,\t0x743F, 0xAC71, 0x7440, 0xAC72, 0x7441, 0xE8A3, 0x7442, 0xAC73,\r\n\t0x7443, 0xAC74, 0x7444, 0xAC75, 0x7445, 0xAC76, 0x7446, 0xAC77,\t0x7447, 0xAC78, 0x7448, 0xAC79, 0x7449, 0xAC7A, 0x744A, 0xAC7B,\r\n\t0x744B, 0xAC7C, 0x744C, 0xAC7D, 0x744D, 0xAC7E, 0x744E, 0xAC80,\t0x744F, 0xAC81, 0x7450, 0xAC82, 0x7451, 0xAC83, 0x7452, 0xAC84,\r\n\t0x7453, 0xAC85, 0x7454, 0xAC86, 0x7455, 0xE8A6, 0x7456, 0xAC87,\t0x7457, 0xE8A5, 0x7458, 0xAC88, 0x7459, 0xE8A7, 0x745A, 0xBAF7,\r\n\t0x745B, 0xE7F8, 0x745C, 0xE8A4, 0x745D, 0xAC89, 0x745E, 0xC8F0,\t0x745F, 0xC9AA, 0x7460, 0xAC8A, 0x7461, 0xAC8B, 0x7462, 0xAC8C,\r\n\t0x7463, 0xAC8D, 0x7464, 0xAC8E, 0x7465, 0xAC8F, 0x7466, 0xAC90,\t0x7467, 0xAC91, 0x7468, 0xAC92, 0x7469, 0xAC93, 0x746A, 0xAC94,\r\n\t0x746B, 0xAC95, 0x746C, 0xAC96, 0x746D, 0xE8A9, 0x746E, 0xAC97,\t0x746F, 0xAC98, 0x7470, 0xB9E5, 0x7471, 0xAC99, 0x7472, 0xAC9A,\r\n\t0x7473, 0xAC9B, 0x7474, 0xAC9C, 0x7475, 0xAC9D, 0x7476, 0xD1FE,\t0x7477, 0xE8A8, 0x7478, 0xAC9E, 0x7479, 0xAC9F, 0x747A, 0xACA0,\r\n\t0x747B, 0xAD40, 0x747C, 0xAD41, 0x747D, 0xAD42, 0x747E, 0xE8AA,\t0x747F, 0xAD43, 0x7480, 0xE8AD, 0x7481, 0xE8AE, 0x7482, 0xAD44,\r\n\t0x7483, 0xC1A7, 0x7484, 0xAD45, 0x7485, 0xAD46, 0x7486, 0xAD47,\t0x7487, 0xE8AF, 0x7488, 0xAD48, 0x7489, 0xAD49, 0x748A, 0xAD4A,\r\n\t0x748B, 0xE8B0, 0x748C, 0xAD4B, 0x748D, 0xAD4C, 0x748E, 0xE8AC,\t0x748F, 0xAD4D, 0x7490, 0xE8B4, 0x7491, 0xAD4E, 0x7492, 0xAD4F,\r\n\t0x7493, 0xAD50, 0x7494, 0xAD51, 0x7495, 0xAD52, 0x7496, 0xAD53,\t0x7497, 0xAD54, 0x7498, 0xAD55, 0x7499, 0xAD56, 0x749A, 0xAD57,\r\n\t0x749B, 0xAD58, 0x749C, 0xE8AB, 0x749D, 0xAD59, 0x749E, 0xE8B1,\t0x749F, 0xAD5A, 0x74A0, 0xAD5B, 0x74A1, 0xAD5C, 0x74A2, 0xAD5D,\r\n\t0x74A3, 0xAD5E, 0x74A4, 0xAD5F, 0x74A5, 0xAD60, 0x74A6, 0xAD61,\t0x74A7, 0xE8B5, 0x74A8, 0xE8B2, 0x74A9, 0xE8B3, 0x74AA, 0xAD62,\r\n\t0x74AB, 0xAD63, 0x74AC, 0xAD64, 0x74AD, 0xAD65, 0x74AE, 0xAD66,\t0x74AF, 0xAD67, 0x74B0, 0xAD68, 0x74B1, 0xAD69, 0x74B2, 0xAD6A,\r\n\t0x74B3, 0xAD6B, 0x74B4, 0xAD6C, 0x74B5, 0xAD6D, 0x74B6, 0xAD6E,\t0x74B7, 0xAD6F, 0x74B8, 0xAD70, 0x74B9, 0xAD71, 0x74BA, 0xE8B7,\r\n\t0x74BB, 0xAD72, 0x74BC, 0xAD73, 0x74BD, 0xAD74, 0x74BE, 0xAD75,\t0x74BF, 0xAD76, 0x74C0, 0xAD77, 0x74C1, 0xAD78, 0x74C2, 0xAD79,\r\n\t0x74C3, 0xAD7A, 0x74C4, 0xAD7B, 0x74C5, 0xAD7C, 0x74C6, 0xAD7D,\t0x74C7, 0xAD7E, 0x74C8, 0xAD80, 0x74C9, 0xAD81, 0x74CA, 0xAD82,\r\n\t0x74CB, 0xAD83, 0x74CC, 0xAD84, 0x74CD, 0xAD85, 0x74CE, 0xAD86,\t0x74CF, 0xAD87, 0x74D0, 0xAD88, 0x74D1, 0xAD89, 0x74D2, 0xE8B6,\r\n\t0x74D3, 0xAD8A, 0x74D4, 0xAD8B, 0x74D5, 0xAD8C, 0x74D6, 0xAD8D,\t0x74D7, 0xAD8E, 0x74D8, 0xAD8F, 0x74D9, 0xAD90, 0x74DA, 0xAD91,\r\n\t0x74DB, 0xAD92, 0x74DC, 0xB9CF, 0x74DD, 0xAD93, 0x74DE, 0xF0AC,\t0x74DF, 0xAD94, 0x74E0, 0xF0AD, 0x74E1, 0xAD95, 0x74E2, 0xC6B0,\r\n\t0x74E3, 0xB0EA, 0x74E4, 0xC8BF, 0x74E5, 0xAD96, 0x74E6, 0xCDDF,\t0x74E7, 0xAD97, 0x74E8, 0xAD98, 0x74E9, 0xAD99, 0x74EA, 0xAD9A,\r\n\t0x74EB, 0xAD9B, 0x74EC, 0xAD9C, 0x74ED, 0xAD9D, 0x74EE, 0xCECD,\t0x74EF, 0xEAB1, 0x74F0, 0xAD9E, 0x74F1, 0xAD9F, 0x74F2, 0xADA0,\r\n\t0x74F3, 0xAE40, 0x74F4, 0xEAB2, 0x74F5, 0xAE41, 0x74F6, 0xC6BF,\t0x74F7, 0xB4C9, 0x74F8, 0xAE42, 0x74F9, 0xAE43, 0x74FA, 0xAE44,\r\n\t0x74FB, 0xAE45, 0x74FC, 0xAE46, 0x74FD, 0xAE47, 0x74FE, 0xAE48,\t0x74FF, 0xEAB3, 0x7500, 0xAE49, 0x7501, 0xAE4A, 0x7502, 0xAE4B,\r\n\t0x7503, 0xAE4C, 0x7504, 0xD5E7, 0x7505, 0xAE4D, 0x7506, 0xAE4E,\t0x7507, 0xAE4F, 0x7508, 0xAE50, 0x7509, 0xAE51, 0x750A, 0xAE52,\r\n\t0x750B, 0xAE53, 0x750C, 0xAE54, 0x750D, 0xDDF9, 0x750E, 0xAE55,\t0x750F, 0xEAB4, 0x7510, 0xAE56, 0x7511, 0xEAB5, 0x7512, 0xAE57,\r\n\t0x7513, 0xEAB6, 0x7514, 0xAE58, 0x7515, 0xAE59, 0x7516, 0xAE5A,\t0x7517, 0xAE5B, 0x7518, 0xB8CA, 0x7519, 0xDFB0, 0x751A, 0xC9F5,\r\n\t0x751B, 0xAE5C, 0x751C, 0xCCF0, 0x751D, 0xAE5D, 0x751E, 0xAE5E,\t0x751F, 0xC9FA, 0x7520, 0xAE5F, 0x7521, 0xAE60, 0x7522, 0xAE61,\r\n\t0x7523, 0xAE62, 0x7524, 0xAE63, 0x7525, 0xC9FB, 0x7526, 0xAE64,\t0x7527, 0xAE65, 0x7528, 0xD3C3, 0x7529, 0xCBA6, 0x752A, 0xAE66,\r\n\t0x752B, 0xB8A6, 0x752C, 0xF0AE, 0x752D, 0xB1C2, 0x752E, 0xAE67,\t0x752F, 0xE5B8, 0x7530, 0xCCEF, 0x7531, 0xD3C9, 0x7532, 0xBCD7,\r\n\t0x7533, 0xC9EA, 0x7534, 0xAE68, 0x7535, 0xB5E7, 0x7536, 0xAE69,\t0x7537, 0xC4D0, 0x7538, 0xB5E9, 0x7539, 0xAE6A, 0x753A, 0xEEAE,\r\n\t0x753B, 0xBBAD, 0x753C, 0xAE6B, 0x753D, 0xAE6C, 0x753E, 0xE7DE,\t0x753F, 0xAE6D, 0x7540, 0xEEAF, 0x7541, 0xAE6E, 0x7542, 0xAE6F,\r\n\t0x7543, 0xAE70, 0x7544, 0xAE71, 0x7545, 0xB3A9, 0x7546, 0xAE72,\t0x7547, 0xAE73, 0x7548, 0xEEB2, 0x7549, 0xAE74, 0x754A, 0xAE75,\r\n\t0x754B, 0xEEB1, 0x754C, 0xBDE7, 0x754D, 0xAE76, 0x754E, 0xEEB0,\t0x754F, 0xCEB7, 0x7550, 0xAE77, 0x7551, 0xAE78, 0x7552, 0xAE79,\r\n\t0x7553, 0xAE7A, 0x7554, 0xC5CF, 0x7555, 0xAE7B, 0x7556, 0xAE7C,\t0x7557, 0xAE7D, 0x7558, 0xAE7E, 0x7559, 0xC1F4, 0x755A, 0xDBCE,\r\n\t0x755B, 0xEEB3, 0x755C, 0xD0F3, 0x755D, 0xAE80, 0x755E, 0xAE81,\t0x755F, 0xAE82, 0x7560, 0xAE83, 0x7561, 0xAE84, 0x7562, 0xAE85,\r\n\t0x7563, 0xAE86, 0x7564, 0xAE87, 0x7565, 0xC2D4, 0x7566, 0xC6E8,\t0x7567, 0xAE88, 0x7568, 0xAE89, 0x7569, 0xAE8A, 0x756A, 0xB7AC,\r\n\t0x756B, 0xAE8B, 0x756C, 0xAE8C, 0x756D, 0xAE8D, 0x756E, 0xAE8E,\t0x756F, 0xAE8F, 0x7570, 0xAE90, 0x7571, 0xAE91, 0x7572, 0xEEB4,\r\n\t0x7573, 0xAE92, 0x7574, 0xB3EB, 0x7575, 0xAE93, 0x7576, 0xAE94,\t0x7577, 0xAE95, 0x7578, 0xBBFB, 0x7579, 0xEEB5, 0x757A, 0xAE96,\r\n\t0x757B, 0xAE97, 0x757C, 0xAE98, 0x757D, 0xAE99, 0x757E, 0xAE9A,\t0x757F, 0xE7DC, 0x7580, 0xAE9B, 0x7581, 0xAE9C, 0x7582, 0xAE9D,\r\n\t0x7583, 0xEEB6, 0x7584, 0xAE9E, 0x7585, 0xAE9F, 0x7586, 0xBDAE,\t0x7587, 0xAEA0, 0x7588, 0xAF40, 0x7589, 0xAF41, 0x758A, 0xAF42,\r\n\t0x758B, 0xF1E2, 0x758C, 0xAF43, 0x758D, 0xAF44, 0x758E, 0xAF45,\t0x758F, 0xCAE8, 0x7590, 0xAF46, 0x7591, 0xD2C9, 0x7592, 0xF0DA,\r\n\t0x7593, 0xAF47, 0x7594, 0xF0DB, 0x7595, 0xAF48, 0x7596, 0xF0DC,\t0x7597, 0xC1C6, 0x7598, 0xAF49, 0x7599, 0xB8ED, 0x759A, 0xBECE,\r\n\t0x759B, 0xAF4A, 0x759C, 0xAF4B, 0x759D, 0xF0DE, 0x759E, 0xAF4C,\t0x759F, 0xC5B1, 0x75A0, 0xF0DD, 0x75A1, 0xD1F1, 0x75A2, 0xAF4D,\r\n\t0x75A3, 0xF0E0, 0x75A4, 0xB0CC, 0x75A5, 0xBDEA, 0x75A6, 0xAF4E,\t0x75A7, 0xAF4F, 0x75A8, 0xAF50, 0x75A9, 0xAF51, 0x75AA, 0xAF52,\r\n\t0x75AB, 0xD2DF, 0x75AC, 0xF0DF, 0x75AD, 0xAF53, 0x75AE, 0xB4AF,\t0x75AF, 0xB7E8, 0x75B0, 0xF0E6, 0x75B1, 0xF0E5, 0x75B2, 0xC6A3,\r\n\t0x75B3, 0xF0E1, 0x75B4, 0xF0E2, 0x75B5, 0xB4C3, 0x75B6, 0xAF54,\t0x75B7, 0xAF55, 0x75B8, 0xF0E3, 0x75B9, 0xD5EE, 0x75BA, 0xAF56,\r\n\t0x75BB, 0xAF57, 0x75BC, 0xCCDB, 0x75BD, 0xBED2, 0x75BE, 0xBCB2,\t0x75BF, 0xAF58, 0x75C0, 0xAF59, 0x75C1, 0xAF5A, 0x75C2, 0xF0E8,\r\n\t0x75C3, 0xF0E7, 0x75C4, 0xF0E4, 0x75C5, 0xB2A1, 0x75C6, 0xAF5B,\t0x75C7, 0xD6A2, 0x75C8, 0xD3B8, 0x75C9, 0xBEB7, 0x75CA, 0xC8AC,\r\n\t0x75CB, 0xAF5C, 0x75CC, 0xAF5D, 0x75CD, 0xF0EA, 0x75CE, 0xAF5E,\t0x75CF, 0xAF5F, 0x75D0, 0xAF60, 0x75D1, 0xAF61, 0x75D2, 0xD1F7,\r\n\t0x75D3, 0xAF62, 0x75D4, 0xD6CC, 0x75D5, 0xBADB, 0x75D6, 0xF0E9,\t0x75D7, 0xAF63, 0x75D8, 0xB6BB, 0x75D9, 0xAF64, 0x75DA, 0xAF65,\r\n\t0x75DB, 0xCDB4, 0x75DC, 0xAF66, 0x75DD, 0xAF67, 0x75DE, 0xC6A6,\t0x75DF, 0xAF68, 0x75E0, 0xAF69, 0x75E1, 0xAF6A, 0x75E2, 0xC1A1,\r\n\t0x75E3, 0xF0EB, 0x75E4, 0xF0EE, 0x75E5, 0xAF6B, 0x75E6, 0xF0ED,\t0x75E7, 0xF0F0, 0x75E8, 0xF0EC, 0x75E9, 0xAF6C, 0x75EA, 0xBBBE,\r\n\t0x75EB, 0xF0EF, 0x75EC, 0xAF6D, 0x75ED, 0xAF6E, 0x75EE, 0xAF6F,\t0x75EF, 0xAF70, 0x75F0, 0xCCB5, 0x75F1, 0xF0F2, 0x75F2, 0xAF71,\r\n\t0x75F3, 0xAF72, 0x75F4, 0xB3D5, 0x75F5, 0xAF73, 0x75F6, 0xAF74,\t0x75F7, 0xAF75, 0x75F8, 0xAF76, 0x75F9, 0xB1D4, 0x75FA, 0xAF77,\r\n\t0x75FB, 0xAF78, 0x75FC, 0xF0F3, 0x75FD, 0xAF79, 0x75FE, 0xAF7A,\t0x75FF, 0xF0F4, 0x7600, 0xF0F6, 0x7601, 0xB4E1, 0x7602, 0xAF7B,\r\n\t0x7603, 0xF0F1, 0x7604, 0xAF7C, 0x7605, 0xF0F7, 0x7606, 0xAF7D,\t0x7607, 0xAF7E, 0x7608, 0xAF80, 0x7609, 0xAF81, 0x760A, 0xF0FA,\r\n\t0x760B, 0xAF82, 0x760C, 0xF0F8, 0x760D, 0xAF83, 0x760E, 0xAF84,\t0x760F, 0xAF85, 0x7610, 0xF0F5, 0x7611, 0xAF86, 0x7612, 0xAF87,\r\n\t0x7613, 0xAF88, 0x7614, 0xAF89, 0x7615, 0xF0FD, 0x7616, 0xAF8A,\t0x7617, 0xF0F9, 0x7618, 0xF0FC, 0x7619, 0xF0FE, 0x761A, 0xAF8B,\r\n\t0x761B, 0xF1A1, 0x761C, 0xAF8C, 0x761D, 0xAF8D, 0x761E, 0xAF8E,\t0x761F, 0xCEC1, 0x7620, 0xF1A4, 0x7621, 0xAF8F, 0x7622, 0xF1A3,\r\n\t0x7623, 0xAF90, 0x7624, 0xC1F6, 0x7625, 0xF0FB, 0x7626, 0xCADD,\t0x7627, 0xAF91, 0x7628, 0xAF92, 0x7629, 0xB4F1, 0x762A, 0xB1F1,\r\n\t0x762B, 0xCCB1, 0x762C, 0xAF93, 0x762D, 0xF1A6, 0x762E, 0xAF94,\t0x762F, 0xAF95, 0x7630, 0xF1A7, 0x7631, 0xAF96, 0x7632, 0xAF97,\r\n\t0x7633, 0xF1AC, 0x7634, 0xD5CE, 0x7635, 0xF1A9, 0x7636, 0xAF98,\t0x7637, 0xAF99, 0x7638, 0xC8B3, 0x7639, 0xAF9A, 0x763A, 0xAF9B,\r\n\t0x763B, 0xAF9C, 0x763C, 0xF1A2, 0x763D, 0xAF9D, 0x763E, 0xF1AB,\t0x763F, 0xF1A8, 0x7640, 0xF1A5, 0x7641, 0xAF9E, 0x7642, 0xAF9F,\r\n\t0x7643, 0xF1AA, 0x7644, 0xAFA0, 0x7645, 0xB040, 0x7646, 0xB041,\t0x7647, 0xB042, 0x7648, 0xB043, 0x7649, 0xB044, 0x764A, 0xB045,\r\n\t0x764B, 0xB046, 0x764C, 0xB0A9, 0x764D, 0xF1AD, 0x764E, 0xB047,\t0x764F, 0xB048, 0x7650, 0xB049, 0x7651, 0xB04A, 0x7652, 0xB04B,\r\n\t0x7653, 0xB04C, 0x7654, 0xF1AF, 0x7655, 0xB04D, 0x7656, 0xF1B1,\t0x7657, 0xB04E, 0x7658, 0xB04F, 0x7659, 0xB050, 0x765A, 0xB051,\r\n\t0x765B, 0xB052, 0x765C, 0xF1B0, 0x765D, 0xB053, 0x765E, 0xF1AE,\t0x765F, 0xB054, 0x7660, 0xB055, 0x7661, 0xB056, 0x7662, 0xB057,\r\n\t0x7663, 0xD1A2, 0x7664, 0xB058, 0x7665, 0xB059, 0x7666, 0xB05A,\t0x7667, 0xB05B, 0x7668, 0xB05C, 0x7669, 0xB05D, 0x766A, 0xB05E,\r\n\t0x766B, 0xF1B2, 0x766C, 0xB05F, 0x766D, 0xB060, 0x766E, 0xB061,\t0x766F, 0xF1B3, 0x7670, 0xB062, 0x7671, 0xB063, 0x7672, 0xB064,\r\n\t0x7673, 0xB065, 0x7674, 0xB066, 0x7675, 0xB067, 0x7676, 0xB068,\t0x7677, 0xB069, 0x7678, 0xB9EF, 0x7679, 0xB06A, 0x767A, 0xB06B,\r\n\t0x767B, 0xB5C7, 0x767C, 0xB06C, 0x767D, 0xB0D7, 0x767E, 0xB0D9,\t0x767F, 0xB06D, 0x7680, 0xB06E, 0x7681, 0xB06F, 0x7682, 0xD4ED,\r\n\t0x7683, 0xB070, 0x7684, 0xB5C4, 0x7685, 0xB071, 0x7686, 0xBDD4,\t0x7687, 0xBBCA, 0x7688, 0xF0A7, 0x7689, 0xB072, 0x768A, 0xB073,\r\n\t0x768B, 0xB8DE, 0x768C, 0xB074, 0x768D, 0xB075, 0x768E, 0xF0A8,\t0x768F, 0xB076, 0x7690, 0xB077, 0x7691, 0xB0A8, 0x7692, 0xB078,\r\n\t0x7693, 0xF0A9, 0x7694, 0xB079, 0x7695, 0xB07A, 0x7696, 0xCDEE,\t0x7697, 0xB07B, 0x7698, 0xB07C, 0x7699, 0xF0AA, 0x769A, 0xB07D,\r\n\t0x769B, 0xB07E, 0x769C, 0xB080, 0x769D, 0xB081, 0x769E, 0xB082,\t0x769F, 0xB083, 0x76A0, 0xB084, 0x76A1, 0xB085, 0x76A2, 0xB086,\r\n\t0x76A3, 0xB087, 0x76A4, 0xF0AB, 0x76A5, 0xB088, 0x76A6, 0xB089,\t0x76A7, 0xB08A, 0x76A8, 0xB08B, 0x76A9, 0xB08C, 0x76AA, 0xB08D,\r\n\t0x76AB, 0xB08E, 0x76AC, 0xB08F, 0x76AD, 0xB090, 0x76AE, 0xC6A4,\t0x76AF, 0xB091, 0x76B0, 0xB092, 0x76B1, 0xD6E5, 0x76B2, 0xF1E4,\r\n\t0x76B3, 0xB093, 0x76B4, 0xF1E5, 0x76B5, 0xB094, 0x76B6, 0xB095,\t0x76B7, 0xB096, 0x76B8, 0xB097, 0x76B9, 0xB098, 0x76BA, 0xB099,\r\n\t0x76BB, 0xB09A, 0x76BC, 0xB09B, 0x76BD, 0xB09C, 0x76BE, 0xB09D,\t0x76BF, 0xC3F3, 0x76C0, 0xB09E, 0x76C1, 0xB09F, 0x76C2, 0xD3DB,\r\n\t0x76C3, 0xB0A0, 0x76C4, 0xB140, 0x76C5, 0xD6D1, 0x76C6, 0xC5E8,\t0x76C7, 0xB141, 0x76C8, 0xD3AF, 0x76C9, 0xB142, 0x76CA, 0xD2E6,\r\n\t0x76CB, 0xB143, 0x76CC, 0xB144, 0x76CD, 0xEEC1, 0x76CE, 0xB0BB,\t0x76CF, 0xD5B5, 0x76D0, 0xD1CE, 0x76D1, 0xBCE0, 0x76D2, 0xBAD0,\r\n\t0x76D3, 0xB145, 0x76D4, 0xBFF8, 0x76D5, 0xB146, 0x76D6, 0xB8C7,\t0x76D7, 0xB5C1, 0x76D8, 0xC5CC, 0x76D9, 0xB147, 0x76DA, 0xB148,\r\n\t0x76DB, 0xCAA2, 0x76DC, 0xB149, 0x76DD, 0xB14A, 0x76DE, 0xB14B,\t0x76DF, 0xC3CB, 0x76E0, 0xB14C, 0x76E1, 0xB14D, 0x76E2, 0xB14E,\r\n\t0x76E3, 0xB14F, 0x76E4, 0xB150, 0x76E5, 0xEEC2, 0x76E6, 0xB151,\t0x76E7, 0xB152, 0x76E8, 0xB153, 0x76E9, 0xB154, 0x76EA, 0xB155,\r\n\t0x76EB, 0xB156, 0x76EC, 0xB157, 0x76ED, 0xB158, 0x76EE, 0xC4BF,\t0x76EF, 0xB6A2, 0x76F0, 0xB159, 0x76F1, 0xEDEC, 0x76F2, 0xC3A4,\r\n\t0x76F3, 0xB15A, 0x76F4, 0xD6B1, 0x76F5, 0xB15B, 0x76F6, 0xB15C,\t0x76F7, 0xB15D, 0x76F8, 0xCFE0, 0x76F9, 0xEDEF, 0x76FA, 0xB15E,\r\n\t0x76FB, 0xB15F, 0x76FC, 0xC5CE, 0x76FD, 0xB160, 0x76FE, 0xB6DC,\t0x76FF, 0xB161, 0x7700, 0xB162, 0x7701, 0xCAA1, 0x7702, 0xB163,\r\n\t0x7703, 0xB164, 0x7704, 0xEDED, 0x7705, 0xB165, 0x7706, 0xB166,\t0x7707, 0xEDF0, 0x7708, 0xEDF1, 0x7709, 0xC3BC, 0x770A, 0xB167,\r\n\t0x770B, 0xBFB4, 0x770C, 0xB168, 0x770D, 0xEDEE, 0x770E, 0xB169,\t0x770F, 0xB16A, 0x7710, 0xB16B, 0x7711, 0xB16C, 0x7712, 0xB16D,\r\n\t0x7713, 0xB16E, 0x7714, 0xB16F, 0x7715, 0xB170, 0x7716, 0xB171,\t0x7717, 0xB172, 0x7718, 0xB173, 0x7719, 0xEDF4, 0x771A, 0xEDF2,\r\n\t0x771B, 0xB174, 0x771C, 0xB175, 0x771D, 0xB176, 0x771E, 0xB177,\t0x771F, 0xD5E6, 0x7720, 0xC3DF, 0x7721, 0xB178, 0x7722, 0xEDF3,\r\n\t0x7723, 0xB179, 0x7724, 0xB17A, 0x7725, 0xB17B, 0x7726, 0xEDF6,\t0x7727, 0xB17C, 0x7728, 0xD5A3, 0x7729, 0xD1A3, 0x772A, 0xB17D,\r\n\t0x772B, 0xB17E, 0x772C, 0xB180, 0x772D, 0xEDF5, 0x772E, 0xB181,\t0x772F, 0xC3D0, 0x7730, 0xB182, 0x7731, 0xB183, 0x7732, 0xB184,\r\n\t0x7733, 0xB185, 0x7734, 0xB186, 0x7735, 0xEDF7, 0x7736, 0xBFF4,\t0x7737, 0xBEEC, 0x7738, 0xEDF8, 0x7739, 0xB187, 0x773A, 0xCCF7,\r\n\t0x773B, 0xB188, 0x773C, 0xD1DB, 0x773D, 0xB189, 0x773E, 0xB18A,\t0x773F, 0xB18B, 0x7740, 0xD7C5, 0x7741, 0xD5F6, 0x7742, 0xB18C,\r\n\t0x7743, 0xEDFC, 0x7744, 0xB18D, 0x7745, 0xB18E, 0x7746, 0xB18F,\t0x7747, 0xEDFB, 0x7748, 0xB190, 0x7749, 0xB191, 0x774A, 0xB192,\r\n\t0x774B, 0xB193, 0x774C, 0xB194, 0x774D, 0xB195, 0x774E, 0xB196,\t0x774F, 0xB197, 0x7750, 0xEDF9, 0x7751, 0xEDFA, 0x7752, 0xB198,\r\n\t0x7753, 0xB199, 0x7754, 0xB19A, 0x7755, 0xB19B, 0x7756, 0xB19C,\t0x7757, 0xB19D, 0x7758, 0xB19E, 0x7759, 0xB19F, 0x775A, 0xEDFD,\r\n\t0x775B, 0xBEA6, 0x775C, 0xB1A0, 0x775D, 0xB240, 0x775E, 0xB241,\t0x775F, 0xB242, 0x7760, 0xB243, 0x7761, 0xCBAF, 0x7762, 0xEEA1,\r\n\t0x7763, 0xB6BD, 0x7764, 0xB244, 0x7765, 0xEEA2, 0x7766, 0xC4C0,\t0x7767, 0xB245, 0x7768, 0xEDFE, 0x7769, 0xB246, 0x776A, 0xB247,\r\n\t0x776B, 0xBDDE, 0x776C, 0xB2C7, 0x776D, 0xB248, 0x776E, 0xB249,\t0x776F, 0xB24A, 0x7770, 0xB24B, 0x7771, 0xB24C, 0x7772, 0xB24D,\r\n\t0x7773, 0xB24E, 0x7774, 0xB24F, 0x7775, 0xB250, 0x7776, 0xB251,\t0x7777, 0xB252, 0x7778, 0xB253, 0x7779, 0xB6C3, 0x777A, 0xB254,\r\n\t0x777B, 0xB255, 0x777C, 0xB256, 0x777D, 0xEEA5, 0x777E, 0xD8BA,\t0x777F, 0xEEA3, 0x7780, 0xEEA6, 0x7781, 0xB257, 0x7782, 0xB258,\r\n\t0x7783, 0xB259, 0x7784, 0xC3E9, 0x7785, 0xB3F2, 0x7786, 0xB25A,\t0x7787, 0xB25B, 0x7788, 0xB25C, 0x7789, 0xB25D, 0x778A, 0xB25E,\r\n\t0x778B, 0xB25F, 0x778C, 0xEEA7, 0x778D, 0xEEA4, 0x778E, 0xCFB9,\t0x778F, 0xB260, 0x7790, 0xB261, 0x7791, 0xEEA8, 0x7792, 0xC2F7,\r\n\t0x7793, 0xB262, 0x7794, 0xB263, 0x7795, 0xB264, 0x7796, 0xB265,\t0x7797, 0xB266, 0x7798, 0xB267, 0x7799, 0xB268, 0x779A, 0xB269,\r\n\t0x779B, 0xB26A, 0x779C, 0xB26B, 0x779D, 0xB26C, 0x779E, 0xB26D,\t0x779F, 0xEEA9, 0x77A0, 0xEEAA, 0x77A1, 0xB26E, 0x77A2, 0xDEAB,\r\n\t0x77A3, 0xB26F, 0x77A4, 0xB270, 0x77A5, 0xC6B3, 0x77A6, 0xB271,\t0x77A7, 0xC7C6, 0x77A8, 0xB272, 0x77A9, 0xD6F5, 0x77AA, 0xB5C9,\r\n\t0x77AB, 0xB273, 0x77AC, 0xCBB2, 0x77AD, 0xB274, 0x77AE, 0xB275,\t0x77AF, 0xB276, 0x77B0, 0xEEAB, 0x77B1, 0xB277, 0x77B2, 0xB278,\r\n\t0x77B3, 0xCDAB, 0x77B4, 0xB279, 0x77B5, 0xEEAC, 0x77B6, 0xB27A,\t0x77B7, 0xB27B, 0x77B8, 0xB27C, 0x77B9, 0xB27D, 0x77BA, 0xB27E,\r\n\t0x77BB, 0xD5B0, 0x77BC, 0xB280, 0x77BD, 0xEEAD, 0x77BE, 0xB281,\t0x77BF, 0xF6C4, 0x77C0, 0xB282, 0x77C1, 0xB283, 0x77C2, 0xB284,\r\n\t0x77C3, 0xB285, 0x77C4, 0xB286, 0x77C5, 0xB287, 0x77C6, 0xB288,\t0x77C7, 0xB289, 0x77C8, 0xB28A, 0x77C9, 0xB28B, 0x77CA, 0xB28C,\r\n\t0x77CB, 0xB28D, 0x77CC, 0xB28E, 0x77CD, 0xDBC7, 0x77CE, 0xB28F,\t0x77CF, 0xB290, 0x77D0, 0xB291, 0x77D1, 0xB292, 0x77D2, 0xB293,\r\n\t0x77D3, 0xB294, 0x77D4, 0xB295, 0x77D5, 0xB296, 0x77D6, 0xB297,\t0x77D7, 0xB4A3, 0x77D8, 0xB298, 0x77D9, 0xB299, 0x77DA, 0xB29A,\r\n\t0x77DB, 0xC3AC, 0x77DC, 0xF1E6, 0x77DD, 0xB29B, 0x77DE, 0xB29C,\t0x77DF, 0xB29D, 0x77E0, 0xB29E, 0x77E1, 0xB29F, 0x77E2, 0xCAB8,\r\n\t0x77E3, 0xD2D3, 0x77E4, 0xB2A0, 0x77E5, 0xD6AA, 0x77E6, 0xB340,\t0x77E7, 0xEFF2, 0x77E8, 0xB341, 0x77E9, 0xBED8, 0x77EA, 0xB342,\r\n\t0x77EB, 0xBDC3, 0x77EC, 0xEFF3, 0x77ED, 0xB6CC, 0x77EE, 0xB0AB,\t0x77EF, 0xB343, 0x77F0, 0xB344, 0x77F1, 0xB345, 0x77F2, 0xB346,\r\n\t0x77F3, 0xCAAF, 0x77F4, 0xB347, 0x77F5, 0xB348, 0x77F6, 0xEDB6,\t0x77F7, 0xB349, 0x77F8, 0xEDB7, 0x77F9, 0xB34A, 0x77FA, 0xB34B,\r\n\t0x77FB, 0xB34C, 0x77FC, 0xB34D, 0x77FD, 0xCEF9, 0x77FE, 0xB7AF,\t0x77FF, 0xBFF3, 0x7800, 0xEDB8, 0x7801, 0xC2EB, 0x7802, 0xC9B0,\r\n\t0x7803, 0xB34E, 0x7804, 0xB34F, 0x7805, 0xB350, 0x7806, 0xB351,\t0x7807, 0xB352, 0x7808, 0xB353, 0x7809, 0xEDB9, 0x780A, 0xB354,\r\n\t0x780B, 0xB355, 0x780C, 0xC6F6, 0x780D, 0xBFB3, 0x780E, 0xB356,\t0x780F, 0xB357, 0x7810, 0xB358, 0x7811, 0xEDBC, 0x7812, 0xC5F8,\r\n\t0x7813, 0xB359, 0x7814, 0xD1D0, 0x7815, 0xB35A, 0x7816, 0xD7A9,\t0x7817, 0xEDBA, 0x7818, 0xEDBB, 0x7819, 0xB35B, 0x781A, 0xD1E2,\r\n\t0x781B, 0xB35C, 0x781C, 0xEDBF, 0x781D, 0xEDC0, 0x781E, 0xB35D,\t0x781F, 0xEDC4, 0x7820, 0xB35E, 0x7821, 0xB35F, 0x7822, 0xB360,\r\n\t0x7823, 0xEDC8, 0x7824, 0xB361, 0x7825, 0xEDC6, 0x7826, 0xEDCE,\t0x7827, 0xD5E8, 0x7828, 0xB362, 0x7829, 0xEDC9, 0x782A, 0xB363,\r\n\t0x782B, 0xB364, 0x782C, 0xEDC7, 0x782D, 0xEDBE, 0x782E, 0xB365,\t0x782F, 0xB366, 0x7830, 0xC5E9, 0x7831, 0xB367, 0x7832, 0xB368,\r\n\t0x7833, 0xB369, 0x7834, 0xC6C6, 0x7835, 0xB36A, 0x7836, 0xB36B,\t0x7837, 0xC9E9, 0x7838, 0xD4D2, 0x7839, 0xEDC1, 0x783A, 0xEDC2,\r\n\t0x783B, 0xEDC3, 0x783C, 0xEDC5, 0x783D, 0xB36C, 0x783E, 0xC0F9,\t0x783F, 0xB36D, 0x7840, 0xB4A1, 0x7841, 0xB36E, 0x7842, 0xB36F,\r\n\t0x7843, 0xB370, 0x7844, 0xB371, 0x7845, 0xB9E8, 0x7846, 0xB372,\t0x7847, 0xEDD0, 0x7848, 0xB373, 0x7849, 0xB374, 0x784A, 0xB375,\r\n\t0x784B, 0xB376, 0x784C, 0xEDD1, 0x784D, 0xB377, 0x784E, 0xEDCA,\t0x784F, 0xB378, 0x7850, 0xEDCF, 0x7851, 0xB379, 0x7852, 0xCEF8,\r\n\t0x7853, 0xB37A, 0x7854, 0xB37B, 0x7855, 0xCBB6, 0x7856, 0xEDCC,\t0x7857, 0xEDCD, 0x7858, 0xB37C, 0x7859, 0xB37D, 0x785A, 0xB37E,\r\n\t0x785B, 0xB380, 0x785C, 0xB381, 0x785D, 0xCFF5, 0x785E, 0xB382,\t0x785F, 0xB383, 0x7860, 0xB384, 0x7861, 0xB385, 0x7862, 0xB386,\r\n\t0x7863, 0xB387, 0x7864, 0xB388, 0x7865, 0xB389, 0x7866, 0xB38A,\t0x7867, 0xB38B, 0x7868, 0xB38C, 0x7869, 0xB38D, 0x786A, 0xEDD2,\r\n\t0x786B, 0xC1F2, 0x786C, 0xD3B2, 0x786D, 0xEDCB, 0x786E, 0xC8B7,\t0x786F, 0xB38E, 0x7870, 0xB38F, 0x7871, 0xB390, 0x7872, 0xB391,\r\n\t0x7873, 0xB392, 0x7874, 0xB393, 0x7875, 0xB394, 0x7876, 0xB395,\t0x7877, 0xBCEF, 0x7878, 0xB396, 0x7879, 0xB397, 0x787A, 0xB398,\r\n\t0x787B, 0xB399, 0x787C, 0xC5F0, 0x787D, 0xB39A, 0x787E, 0xB39B,\t0x787F, 0xB39C, 0x7880, 0xB39D, 0x7881, 0xB39E, 0x7882, 0xB39F,\r\n\t0x7883, 0xB3A0, 0x7884, 0xB440, 0x7885, 0xB441, 0x7886, 0xB442,\t0x7887, 0xEDD6, 0x7888, 0xB443, 0x7889, 0xB5EF, 0x788A, 0xB444,\r\n\t0x788B, 0xB445, 0x788C, 0xC2B5, 0x788D, 0xB0AD, 0x788E, 0xCBE9,\t0x788F, 0xB446, 0x7890, 0xB447, 0x7891, 0xB1AE, 0x7892, 0xB448,\r\n\t0x7893, 0xEDD4, 0x7894, 0xB449, 0x7895, 0xB44A, 0x7896, 0xB44B,\t0x7897, 0xCDEB, 0x7898, 0xB5E2, 0x7899, 0xB44C, 0x789A, 0xEDD5,\r\n\t0x789B, 0xEDD3, 0x789C, 0xEDD7, 0x789D, 0xB44D, 0x789E, 0xB44E,\t0x789F, 0xB5FA, 0x78A0, 0xB44F, 0x78A1, 0xEDD8, 0x78A2, 0xB450,\r\n\t0x78A3, 0xEDD9, 0x78A4, 0xB451, 0x78A5, 0xEDDC, 0x78A6, 0xB452,\t0x78A7, 0xB1CC, 0x78A8, 0xB453, 0x78A9, 0xB454, 0x78AA, 0xB455,\r\n\t0x78AB, 0xB456, 0x78AC, 0xB457, 0x78AD, 0xB458, 0x78AE, 0xB459,\t0x78AF, 0xB45A, 0x78B0, 0xC5F6, 0x78B1, 0xBCEE, 0x78B2, 0xEDDA,\r\n\t0x78B3, 0xCCBC, 0x78B4, 0xB2EA, 0x78B5, 0xB45B, 0x78B6, 0xB45C,\t0x78B7, 0xB45D, 0x78B8, 0xB45E, 0x78B9, 0xEDDB, 0x78BA, 0xB45F,\r\n\t0x78BB, 0xB460, 0x78BC, 0xB461, 0x78BD, 0xB462, 0x78BE, 0xC4EB,\t0x78BF, 0xB463, 0x78C0, 0xB464, 0x78C1, 0xB4C5, 0x78C2, 0xB465,\r\n\t0x78C3, 0xB466, 0x78C4, 0xB467, 0x78C5, 0xB0F5, 0x78C6, 0xB468,\t0x78C7, 0xB469, 0x78C8, 0xB46A, 0x78C9, 0xEDDF, 0x78CA, 0xC0DA,\r\n\t0x78CB, 0xB4E8, 0x78CC, 0xB46B, 0x78CD, 0xB46C, 0x78CE, 0xB46D,\t0x78CF, 0xB46E, 0x78D0, 0xC5CD, 0x78D1, 0xB46F, 0x78D2, 0xB470,\r\n\t0x78D3, 0xB471, 0x78D4, 0xEDDD, 0x78D5, 0xBFC4, 0x78D6, 0xB472,\t0x78D7, 0xB473, 0x78D8, 0xB474, 0x78D9, 0xEDDE, 0x78DA, 0xB475,\r\n\t0x78DB, 0xB476, 0x78DC, 0xB477, 0x78DD, 0xB478, 0x78DE, 0xB479,\t0x78DF, 0xB47A, 0x78E0, 0xB47B, 0x78E1, 0xB47C, 0x78E2, 0xB47D,\r\n\t0x78E3, 0xB47E, 0x78E4, 0xB480, 0x78E5, 0xB481, 0x78E6, 0xB482,\t0x78E7, 0xB483, 0x78E8, 0xC4A5, 0x78E9, 0xB484, 0x78EA, 0xB485,\r\n\t0x78EB, 0xB486, 0x78EC, 0xEDE0, 0x78ED, 0xB487, 0x78EE, 0xB488,\t0x78EF, 0xB489, 0x78F0, 0xB48A, 0x78F1, 0xB48B, 0x78F2, 0xEDE1,\r\n\t0x78F3, 0xB48C, 0x78F4, 0xEDE3, 0x78F5, 0xB48D, 0x78F6, 0xB48E,\t0x78F7, 0xC1D7, 0x78F8, 0xB48F, 0x78F9, 0xB490, 0x78FA, 0xBBC7,\r\n\t0x78FB, 0xB491, 0x78FC, 0xB492, 0x78FD, 0xB493, 0x78FE, 0xB494,\t0x78FF, 0xB495, 0x7900, 0xB496, 0x7901, 0xBDB8, 0x7902, 0xB497,\r\n\t0x7903, 0xB498, 0x7904, 0xB499, 0x7905, 0xEDE2, 0x7906, 0xB49A,\t0x7907, 0xB49B, 0x7908, 0xB49C, 0x7909, 0xB49D, 0x790A, 0xB49E,\r\n\t0x790B, 0xB49F, 0x790C, 0xB4A0, 0x790D, 0xB540, 0x790E, 0xB541,\t0x790F, 0xB542, 0x7910, 0xB543, 0x7911, 0xB544, 0x7912, 0xB545,\r\n\t0x7913, 0xEDE4, 0x7914, 0xB546, 0x7915, 0xB547, 0x7916, 0xB548,\t0x7917, 0xB549, 0x7918, 0xB54A, 0x7919, 0xB54B, 0x791A, 0xB54C,\r\n\t0x791B, 0xB54D, 0x791C, 0xB54E, 0x791D, 0xB54F, 0x791E, 0xEDE6,\t0x791F, 0xB550, 0x7920, 0xB551, 0x7921, 0xB552, 0x7922, 0xB553,\r\n\t0x7923, 0xB554, 0x7924, 0xEDE5, 0x7925, 0xB555, 0x7926, 0xB556,\t0x7927, 0xB557, 0x7928, 0xB558, 0x7929, 0xB559, 0x792A, 0xB55A,\r\n\t0x792B, 0xB55B, 0x792C, 0xB55C, 0x792D, 0xB55D, 0x792E, 0xB55E,\t0x792F, 0xB55F, 0x7930, 0xB560, 0x7931, 0xB561, 0x7932, 0xB562,\r\n\t0x7933, 0xB563, 0x7934, 0xEDE7, 0x7935, 0xB564, 0x7936, 0xB565,\t0x7937, 0xB566, 0x7938, 0xB567, 0x7939, 0xB568, 0x793A, 0xCABE,\r\n\t0x793B, 0xECEA, 0x793C, 0xC0F1, 0x793D, 0xB569, 0x793E, 0xC9E7,\t0x793F, 0xB56A, 0x7940, 0xECEB, 0x7941, 0xC6EE, 0x7942, 0xB56B,\r\n\t0x7943, 0xB56C, 0x7944, 0xB56D, 0x7945, 0xB56E, 0x7946, 0xECEC,\t0x7947, 0xB56F, 0x7948, 0xC6ED, 0x7949, 0xECED, 0x794A, 0xB570,\r\n\t0x794B, 0xB571, 0x794C, 0xB572, 0x794D, 0xB573, 0x794E, 0xB574,\t0x794F, 0xB575, 0x7950, 0xB576, 0x7951, 0xB577, 0x7952, 0xB578,\r\n\t0x7953, 0xECF0, 0x7954, 0xB579, 0x7955, 0xB57A, 0x7956, 0xD7E6,\t0x7957, 0xECF3, 0x7958, 0xB57B, 0x7959, 0xB57C, 0x795A, 0xECF1,\r\n\t0x795B, 0xECEE, 0x795C, 0xECEF, 0x795D, 0xD7A3, 0x795E, 0xC9F1,\t0x795F, 0xCBEE, 0x7960, 0xECF4, 0x7961, 0xB57D, 0x7962, 0xECF2,\r\n\t0x7963, 0xB57E, 0x7964, 0xB580, 0x7965, 0xCFE9, 0x7966, 0xB581,\t0x7967, 0xECF6, 0x7968, 0xC6B1, 0x7969, 0xB582, 0x796A, 0xB583,\r\n\t0x796B, 0xB584, 0x796C, 0xB585, 0x796D, 0xBCC0, 0x796E, 0xB586,\t0x796F, 0xECF5, 0x7970, 0xB587, 0x7971, 0xB588, 0x7972, 0xB589,\r\n\t0x7973, 0xB58A, 0x7974, 0xB58B, 0x7975, 0xB58C, 0x7976, 0xB58D,\t0x7977, 0xB5BB, 0x7978, 0xBBF6, 0x7979, 0xB58E, 0x797A, 0xECF7,\r\n\t0x797B, 0xB58F, 0x797C, 0xB590, 0x797D, 0xB591, 0x797E, 0xB592,\t0x797F, 0xB593, 0x7980, 0xD9F7, 0x7981, 0xBDFB, 0x7982, 0xB594,\r\n\t0x7983, 0xB595, 0x7984, 0xC2BB, 0x7985, 0xECF8, 0x7986, 0xB596,\t0x7987, 0xB597, 0x7988, 0xB598, 0x7989, 0xB599, 0x798A, 0xECF9,\r\n\t0x798B, 0xB59A, 0x798C, 0xB59B, 0x798D, 0xB59C, 0x798E, 0xB59D,\t0x798F, 0xB8A3, 0x7990, 0xB59E, 0x7991, 0xB59F, 0x7992, 0xB5A0,\r\n\t0x7993, 0xB640, 0x7994, 0xB641, 0x7995, 0xB642, 0x7996, 0xB643,\t0x7997, 0xB644, 0x7998, 0xB645, 0x7999, 0xB646, 0x799A, 0xECFA,\r\n\t0x799B, 0xB647, 0x799C, 0xB648, 0x799D, 0xB649, 0x799E, 0xB64A,\t0x799F, 0xB64B, 0x79A0, 0xB64C, 0x79A1, 0xB64D, 0x79A2, 0xB64E,\r\n\t0x79A3, 0xB64F, 0x79A4, 0xB650, 0x79A5, 0xB651, 0x79A6, 0xB652,\t0x79A7, 0xECFB, 0x79A8, 0xB653, 0x79A9, 0xB654, 0x79AA, 0xB655,\r\n\t0x79AB, 0xB656, 0x79AC, 0xB657, 0x79AD, 0xB658, 0x79AE, 0xB659,\t0x79AF, 0xB65A, 0x79B0, 0xB65B, 0x79B1, 0xB65C, 0x79B2, 0xB65D,\r\n\t0x79B3, 0xECFC, 0x79B4, 0xB65E, 0x79B5, 0xB65F, 0x79B6, 0xB660,\t0x79B7, 0xB661, 0x79B8, 0xB662, 0x79B9, 0xD3ED, 0x79BA, 0xD8AE,\r\n\t0x79BB, 0xC0EB, 0x79BC, 0xB663, 0x79BD, 0xC7DD, 0x79BE, 0xBACC,\t0x79BF, 0xB664, 0x79C0, 0xD0E3, 0x79C1, 0xCBBD, 0x79C2, 0xB665,\r\n\t0x79C3, 0xCDBA, 0x79C4, 0xB666, 0x79C5, 0xB667, 0x79C6, 0xB8D1,\t0x79C7, 0xB668, 0x79C8, 0xB669, 0x79C9, 0xB1FC, 0x79CA, 0xB66A,\r\n\t0x79CB, 0xC7EF, 0x79CC, 0xB66B, 0x79CD, 0xD6D6, 0x79CE, 0xB66C,\t0x79CF, 0xB66D, 0x79D0, 0xB66E, 0x79D1, 0xBFC6, 0x79D2, 0xC3EB,\r\n\t0x79D3, 0xB66F, 0x79D4, 0xB670, 0x79D5, 0xEFF5, 0x79D6, 0xB671,\t0x79D7, 0xB672, 0x79D8, 0xC3D8, 0x79D9, 0xB673, 0x79DA, 0xB674,\r\n\t0x79DB, 0xB675, 0x79DC, 0xB676, 0x79DD, 0xB677, 0x79DE, 0xB678,\t0x79DF, 0xD7E2, 0x79E0, 0xB679, 0x79E1, 0xB67A, 0x79E2, 0xB67B,\r\n\t0x79E3, 0xEFF7, 0x79E4, 0xB3D3, 0x79E5, 0xB67C, 0x79E6, 0xC7D8,\t0x79E7, 0xD1ED, 0x79E8, 0xB67D, 0x79E9, 0xD6C8, 0x79EA, 0xB67E,\r\n\t0x79EB, 0xEFF8, 0x79EC, 0xB680, 0x79ED, 0xEFF6, 0x79EE, 0xB681,\t0x79EF, 0xBBFD, 0x79F0, 0xB3C6, 0x79F1, 0xB682, 0x79F2, 0xB683,\r\n\t0x79F3, 0xB684, 0x79F4, 0xB685, 0x79F5, 0xB686, 0x79F6, 0xB687,\t0x79F7, 0xB688, 0x79F8, 0xBDD5, 0x79F9, 0xB689, 0x79FA, 0xB68A,\r\n\t0x79FB, 0xD2C6, 0x79FC, 0xB68B, 0x79FD, 0xBBE0, 0x79FE, 0xB68C,\t0x79FF, 0xB68D, 0x7A00, 0xCFA1, 0x7A01, 0xB68E, 0x7A02, 0xEFFC,\r\n\t0x7A03, 0xEFFB, 0x7A04, 0xB68F, 0x7A05, 0xB690, 0x7A06, 0xEFF9,\t0x7A07, 0xB691, 0x7A08, 0xB692, 0x7A09, 0xB693, 0x7A0A, 0xB694,\r\n\t0x7A0B, 0xB3CC, 0x7A0C, 0xB695, 0x7A0D, 0xC9D4, 0x7A0E, 0xCBB0,\t0x7A0F, 0xB696, 0x7A10, 0xB697, 0x7A11, 0xB698, 0x7A12, 0xB699,\r\n\t0x7A13, 0xB69A, 0x7A14, 0xEFFE, 0x7A15, 0xB69B, 0x7A16, 0xB69C,\t0x7A17, 0xB0DE, 0x7A18, 0xB69D, 0x7A19, 0xB69E, 0x7A1A, 0xD6C9,\r\n\t0x7A1B, 0xB69F, 0x7A1C, 0xB6A0, 0x7A1D, 0xB740, 0x7A1E, 0xEFFD,\t0x7A1F, 0xB741, 0x7A20, 0xB3ED, 0x7A21, 0xB742, 0x7A22, 0xB743,\r\n\t0x7A23, 0xF6D5, 0x7A24, 0xB744, 0x7A25, 0xB745, 0x7A26, 0xB746,\t0x7A27, 0xB747, 0x7A28, 0xB748, 0x7A29, 0xB749, 0x7A2A, 0xB74A,\r\n\t0x7A2B, 0xB74B, 0x7A2C, 0xB74C, 0x7A2D, 0xB74D, 0x7A2E, 0xB74E,\t0x7A2F, 0xB74F, 0x7A30, 0xB750, 0x7A31, 0xB751, 0x7A32, 0xB752,\r\n\t0x7A33, 0xCEC8, 0x7A34, 0xB753, 0x7A35, 0xB754, 0x7A36, 0xB755,\t0x7A37, 0xF0A2, 0x7A38, 0xB756, 0x7A39, 0xF0A1, 0x7A3A, 0xB757,\r\n\t0x7A3B, 0xB5BE, 0x7A3C, 0xBCDA, 0x7A3D, 0xBBFC, 0x7A3E, 0xB758,\t0x7A3F, 0xB8E5, 0x7A40, 0xB759, 0x7A41, 0xB75A, 0x7A42, 0xB75B,\r\n\t0x7A43, 0xB75C, 0x7A44, 0xB75D, 0x7A45, 0xB75E, 0x7A46, 0xC4C2,\t0x7A47, 0xB75F, 0x7A48, 0xB760, 0x7A49, 0xB761, 0x7A4A, 0xB762,\r\n\t0x7A4B, 0xB763, 0x7A4C, 0xB764, 0x7A4D, 0xB765, 0x7A4E, 0xB766,\t0x7A4F, 0xB767, 0x7A50, 0xB768, 0x7A51, 0xF0A3, 0x7A52, 0xB769,\r\n\t0x7A53, 0xB76A, 0x7A54, 0xB76B, 0x7A55, 0xB76C, 0x7A56, 0xB76D,\t0x7A57, 0xCBEB, 0x7A58, 0xB76E, 0x7A59, 0xB76F, 0x7A5A, 0xB770,\r\n\t0x7A5B, 0xB771, 0x7A5C, 0xB772, 0x7A5D, 0xB773, 0x7A5E, 0xB774,\t0x7A5F, 0xB775, 0x7A60, 0xB776, 0x7A61, 0xB777, 0x7A62, 0xB778,\r\n\t0x7A63, 0xB779, 0x7A64, 0xB77A, 0x7A65, 0xB77B, 0x7A66, 0xB77C,\t0x7A67, 0xB77D, 0x7A68, 0xB77E, 0x7A69, 0xB780, 0x7A6A, 0xB781,\r\n\t0x7A6B, 0xB782, 0x7A6C, 0xB783, 0x7A6D, 0xB784, 0x7A6E, 0xB785,\t0x7A6F, 0xB786, 0x7A70, 0xF0A6, 0x7A71, 0xB787, 0x7A72, 0xB788,\r\n\t0x7A73, 0xB789, 0x7A74, 0xD1A8, 0x7A75, 0xB78A, 0x7A76, 0xBEBF,\t0x7A77, 0xC7EE, 0x7A78, 0xF1B6, 0x7A79, 0xF1B7, 0x7A7A, 0xBFD5,\r\n\t0x7A7B, 0xB78B, 0x7A7C, 0xB78C, 0x7A7D, 0xB78D, 0x7A7E, 0xB78E,\t0x7A7F, 0xB4A9, 0x7A80, 0xF1B8, 0x7A81, 0xCDBB, 0x7A82, 0xB78F,\r\n\t0x7A83, 0xC7D4, 0x7A84, 0xD5AD, 0x7A85, 0xB790, 0x7A86, 0xF1B9,\t0x7A87, 0xB791, 0x7A88, 0xF1BA, 0x7A89, 0xB792, 0x7A8A, 0xB793,\r\n\t0x7A8B, 0xB794, 0x7A8C, 0xB795, 0x7A8D, 0xC7CF, 0x7A8E, 0xB796,\t0x7A8F, 0xB797, 0x7A90, 0xB798, 0x7A91, 0xD2A4, 0x7A92, 0xD6CF,\r\n\t0x7A93, 0xB799, 0x7A94, 0xB79A, 0x7A95, 0xF1BB, 0x7A96, 0xBDD1,\t0x7A97, 0xB4B0, 0x7A98, 0xBEBD, 0x7A99, 0xB79B, 0x7A9A, 0xB79C,\r\n\t0x7A9B, 0xB79D, 0x7A9C, 0xB4DC, 0x7A9D, 0xCED1, 0x7A9E, 0xB79E,\t0x7A9F, 0xBFDF, 0x7AA0, 0xF1BD, 0x7AA1, 0xB79F, 0x7AA2, 0xB7A0,\r\n\t0x7AA3, 0xB840, 0x7AA4, 0xB841, 0x7AA5, 0xBFFA, 0x7AA6, 0xF1BC,\t0x7AA7, 0xB842, 0x7AA8, 0xF1BF, 0x7AA9, 0xB843, 0x7AAA, 0xB844,\r\n\t0x7AAB, 0xB845, 0x7AAC, 0xF1BE, 0x7AAD, 0xF1C0, 0x7AAE, 0xB846,\t0x7AAF, 0xB847, 0x7AB0, 0xB848, 0x7AB1, 0xB849, 0x7AB2, 0xB84A,\r\n\t0x7AB3, 0xF1C1, 0x7AB4, 0xB84B, 0x7AB5, 0xB84C, 0x7AB6, 0xB84D,\t0x7AB7, 0xB84E, 0x7AB8, 0xB84F, 0x7AB9, 0xB850, 0x7ABA, 0xB851,\r\n\t0x7ABB, 0xB852, 0x7ABC, 0xB853, 0x7ABD, 0xB854, 0x7ABE, 0xB855,\t0x7ABF, 0xC1FE, 0x7AC0, 0xB856, 0x7AC1, 0xB857, 0x7AC2, 0xB858,\r\n\t0x7AC3, 0xB859, 0x7AC4, 0xB85A, 0x7AC5, 0xB85B, 0x7AC6, 0xB85C,\t0x7AC7, 0xB85D, 0x7AC8, 0xB85E, 0x7AC9, 0xB85F, 0x7ACA, 0xB860,\r\n\t0x7ACB, 0xC1A2, 0x7ACC, 0xB861, 0x7ACD, 0xB862, 0x7ACE, 0xB863,\t0x7ACF, 0xB864, 0x7AD0, 0xB865, 0x7AD1, 0xB866, 0x7AD2, 0xB867,\r\n\t0x7AD3, 0xB868, 0x7AD4, 0xB869, 0x7AD5, 0xB86A, 0x7AD6, 0xCAFA,\t0x7AD7, 0xB86B, 0x7AD8, 0xB86C, 0x7AD9, 0xD5BE, 0x7ADA, 0xB86D,\r\n\t0x7ADB, 0xB86E, 0x7ADC, 0xB86F, 0x7ADD, 0xB870, 0x7ADE, 0xBEBA,\t0x7ADF, 0xBEB9, 0x7AE0, 0xD5C2, 0x7AE1, 0xB871, 0x7AE2, 0xB872,\r\n\t0x7AE3, 0xBFA2, 0x7AE4, 0xB873, 0x7AE5, 0xCDAF, 0x7AE6, 0xF1B5,\t0x7AE7, 0xB874, 0x7AE8, 0xB875, 0x7AE9, 0xB876, 0x7AEA, 0xB877,\r\n\t0x7AEB, 0xB878, 0x7AEC, 0xB879, 0x7AED, 0xBDDF, 0x7AEE, 0xB87A,\t0x7AEF, 0xB6CB, 0x7AF0, 0xB87B, 0x7AF1, 0xB87C, 0x7AF2, 0xB87D,\r\n\t0x7AF3, 0xB87E, 0x7AF4, 0xB880, 0x7AF5, 0xB881, 0x7AF6, 0xB882,\t0x7AF7, 0xB883, 0x7AF8, 0xB884, 0x7AF9, 0xD6F1, 0x7AFA, 0xF3C3,\r\n\t0x7AFB, 0xB885, 0x7AFC, 0xB886, 0x7AFD, 0xF3C4, 0x7AFE, 0xB887,\t0x7AFF, 0xB8CD, 0x7B00, 0xB888, 0x7B01, 0xB889, 0x7B02, 0xB88A,\r\n\t0x7B03, 0xF3C6, 0x7B04, 0xF3C7, 0x7B05, 0xB88B, 0x7B06, 0xB0CA,\t0x7B07, 0xB88C, 0x7B08, 0xF3C5, 0x7B09, 0xB88D, 0x7B0A, 0xF3C9,\r\n\t0x7B0B, 0xCBF1, 0x7B0C, 0xB88E, 0x7B0D, 0xB88F, 0x7B0E, 0xB890,\t0x7B0F, 0xF3CB, 0x7B10, 0xB891, 0x7B11, 0xD0A6, 0x7B12, 0xB892,\r\n\t0x7B13, 0xB893, 0x7B14, 0xB1CA, 0x7B15, 0xF3C8, 0x7B16, 0xB894,\t0x7B17, 0xB895, 0x7B18, 0xB896, 0x7B19, 0xF3CF, 0x7B1A, 0xB897,\r\n\t0x7B1B, 0xB5D1, 0x7B1C, 0xB898, 0x7B1D, 0xB899, 0x7B1E, 0xF3D7,\t0x7B1F, 0xB89A, 0x7B20, 0xF3D2, 0x7B21, 0xB89B, 0x7B22, 0xB89C,\r\n\t0x7B23, 0xB89D, 0x7B24, 0xF3D4, 0x7B25, 0xF3D3, 0x7B26, 0xB7FB,\t0x7B27, 0xB89E, 0x7B28, 0xB1BF, 0x7B29, 0xB89F, 0x7B2A, 0xF3CE,\r\n\t0x7B2B, 0xF3CA, 0x7B2C, 0xB5DA, 0x7B2D, 0xB8A0, 0x7B2E, 0xF3D0,\t0x7B2F, 0xB940, 0x7B30, 0xB941, 0x7B31, 0xF3D1, 0x7B32, 0xB942,\r\n\t0x7B33, 0xF3D5, 0x7B34, 0xB943, 0x7B35, 0xB944, 0x7B36, 0xB945,\t0x7B37, 0xB946, 0x7B38, 0xF3CD, 0x7B39, 0xB947, 0x7B3A, 0xBCE3,\r\n\t0x7B3B, 0xB948, 0x7B3C, 0xC1FD, 0x7B3D, 0xB949, 0x7B3E, 0xF3D6,\t0x7B3F, 0xB94A, 0x7B40, 0xB94B, 0x7B41, 0xB94C, 0x7B42, 0xB94D,\r\n\t0x7B43, 0xB94E, 0x7B44, 0xB94F, 0x7B45, 0xF3DA, 0x7B46, 0xB950,\t0x7B47, 0xF3CC, 0x7B48, 0xB951, 0x7B49, 0xB5C8, 0x7B4A, 0xB952,\r\n\t0x7B4B, 0xBDEE, 0x7B4C, 0xF3DC, 0x7B4D, 0xB953, 0x7B4E, 0xB954,\t0x7B4F, 0xB7A4, 0x7B50, 0xBFF0, 0x7B51, 0xD6FE, 0x7B52, 0xCDB2,\r\n\t0x7B53, 0xB955, 0x7B54, 0xB4F0, 0x7B55, 0xB956, 0x7B56, 0xB2DF,\t0x7B57, 0xB957, 0x7B58, 0xF3D8, 0x7B59, 0xB958, 0x7B5A, 0xF3D9,\r\n\t0x7B5B, 0xC9B8, 0x7B5C, 0xB959, 0x7B5D, 0xF3DD, 0x7B5E, 0xB95A,\t0x7B5F, 0xB95B, 0x7B60, 0xF3DE, 0x7B61, 0xB95C, 0x7B62, 0xF3E1,\r\n\t0x7B63, 0xB95D, 0x7B64, 0xB95E, 0x7B65, 0xB95F, 0x7B66, 0xB960,\t0x7B67, 0xB961, 0x7B68, 0xB962, 0x7B69, 0xB963, 0x7B6A, 0xB964,\r\n\t0x7B6B, 0xB965, 0x7B6C, 0xB966, 0x7B6D, 0xB967, 0x7B6E, 0xF3DF,\t0x7B6F, 0xB968, 0x7B70, 0xB969, 0x7B71, 0xF3E3, 0x7B72, 0xF3E2,\r\n\t0x7B73, 0xB96A, 0x7B74, 0xB96B, 0x7B75, 0xF3DB, 0x7B76, 0xB96C,\t0x7B77, 0xBFEA, 0x7B78, 0xB96D, 0x7B79, 0xB3EF, 0x7B7A, 0xB96E,\r\n\t0x7B7B, 0xF3E0, 0x7B7C, 0xB96F, 0x7B7D, 0xB970, 0x7B7E, 0xC7A9,\t0x7B7F, 0xB971, 0x7B80, 0xBCF2, 0x7B81, 0xB972, 0x7B82, 0xB973,\r\n\t0x7B83, 0xB974, 0x7B84, 0xB975, 0x7B85, 0xF3EB, 0x7B86, 0xB976,\t0x7B87, 0xB977, 0x7B88, 0xB978, 0x7B89, 0xB979, 0x7B8A, 0xB97A,\r\n\t0x7B8B, 0xB97B, 0x7B8C, 0xB97C, 0x7B8D, 0xB9BF, 0x7B8E, 0xB97D,\t0x7B8F, 0xB97E, 0x7B90, 0xF3E4, 0x7B91, 0xB980, 0x7B92, 0xB981,\r\n\t0x7B93, 0xB982, 0x7B94, 0xB2AD, 0x7B95, 0xBBFE, 0x7B96, 0xB983,\t0x7B97, 0xCBE3, 0x7B98, 0xB984, 0x7B99, 0xB985, 0x7B9A, 0xB986,\r\n\t0x7B9B, 0xB987, 0x7B9C, 0xF3ED, 0x7B9D, 0xF3E9, 0x7B9E, 0xB988,\t0x7B9F, 0xB989, 0x7BA0, 0xB98A, 0x7BA1, 0xB9DC, 0x7BA2, 0xF3EE,\r\n\t0x7BA3, 0xB98B, 0x7BA4, 0xB98C, 0x7BA5, 0xB98D, 0x7BA6, 0xF3E5,\t0x7BA7, 0xF3E6, 0x7BA8, 0xF3EA, 0x7BA9, 0xC2E1, 0x7BAA, 0xF3EC,\r\n\t0x7BAB, 0xF3EF, 0x7BAC, 0xF3E8, 0x7BAD, 0xBCFD, 0x7BAE, 0xB98E,\t0x7BAF, 0xB98F, 0x7BB0, 0xB990, 0x7BB1, 0xCFE4, 0x7BB2, 0xB991,\r\n\t0x7BB3, 0xB992, 0x7BB4, 0xF3F0, 0x7BB5, 0xB993, 0x7BB6, 0xB994,\t0x7BB7, 0xB995, 0x7BB8, 0xF3E7, 0x7BB9, 0xB996, 0x7BBA, 0xB997,\r\n\t0x7BBB, 0xB998, 0x7BBC, 0xB999, 0x7BBD, 0xB99A, 0x7BBE, 0xB99B,\t0x7BBF, 0xB99C, 0x7BC0, 0xB99D, 0x7BC1, 0xF3F2, 0x7BC2, 0xB99E,\r\n\t0x7BC3, 0xB99F, 0x7BC4, 0xB9A0, 0x7BC5, 0xBA40, 0x7BC6, 0xD7AD,\t0x7BC7, 0xC6AA, 0x7BC8, 0xBA41, 0x7BC9, 0xBA42, 0x7BCA, 0xBA43,\r\n\t0x7BCB, 0xBA44, 0x7BCC, 0xF3F3, 0x7BCD, 0xBA45, 0x7BCE, 0xBA46,\t0x7BCF, 0xBA47, 0x7BD0, 0xBA48, 0x7BD1, 0xF3F1, 0x7BD2, 0xBA49,\r\n\t0x7BD3, 0xC2A8, 0x7BD4, 0xBA4A, 0x7BD5, 0xBA4B, 0x7BD6, 0xBA4C,\t0x7BD7, 0xBA4D, 0x7BD8, 0xBA4E, 0x7BD9, 0xB8DD, 0x7BDA, 0xF3F5,\r\n\t0x7BDB, 0xBA4F, 0x7BDC, 0xBA50, 0x7BDD, 0xF3F4, 0x7BDE, 0xBA51,\t0x7BDF, 0xBA52, 0x7BE0, 0xBA53, 0x7BE1, 0xB4DB, 0x7BE2, 0xBA54,\r\n\t0x7BE3, 0xBA55, 0x7BE4, 0xBA56, 0x7BE5, 0xF3F6, 0x7BE6, 0xF3F7,\t0x7BE7, 0xBA57, 0x7BE8, 0xBA58, 0x7BE9, 0xBA59, 0x7BEA, 0xF3F8,\r\n\t0x7BEB, 0xBA5A, 0x7BEC, 0xBA5B, 0x7BED, 0xBA5C, 0x7BEE, 0xC0BA,\t0x7BEF, 0xBA5D, 0x7BF0, 0xBA5E, 0x7BF1, 0xC0E9, 0x7BF2, 0xBA5F,\r\n\t0x7BF3, 0xBA60, 0x7BF4, 0xBA61, 0x7BF5, 0xBA62, 0x7BF6, 0xBA63,\t0x7BF7, 0xC5F1, 0x7BF8, 0xBA64, 0x7BF9, 0xBA65, 0x7BFA, 0xBA66,\r\n\t0x7BFB, 0xBA67, 0x7BFC, 0xF3FB, 0x7BFD, 0xBA68, 0x7BFE, 0xF3FA,\t0x7BFF, 0xBA69, 0x7C00, 0xBA6A, 0x7C01, 0xBA6B, 0x7C02, 0xBA6C,\r\n\t0x7C03, 0xBA6D, 0x7C04, 0xBA6E, 0x7C05, 0xBA6F, 0x7C06, 0xBA70,\t0x7C07, 0xB4D8, 0x7C08, 0xBA71, 0x7C09, 0xBA72, 0x7C0A, 0xBA73,\r\n\t0x7C0B, 0xF3FE, 0x7C0C, 0xF3F9, 0x7C0D, 0xBA74, 0x7C0E, 0xBA75,\t0x7C0F, 0xF3FC, 0x7C10, 0xBA76, 0x7C11, 0xBA77, 0x7C12, 0xBA78,\r\n\t0x7C13, 0xBA79, 0x7C14, 0xBA7A, 0x7C15, 0xBA7B, 0x7C16, 0xF3FD,\t0x7C17, 0xBA7C, 0x7C18, 0xBA7D, 0x7C19, 0xBA7E, 0x7C1A, 0xBA80,\r\n\t0x7C1B, 0xBA81, 0x7C1C, 0xBA82, 0x7C1D, 0xBA83, 0x7C1E, 0xBA84,\t0x7C1F, 0xF4A1, 0x7C20, 0xBA85, 0x7C21, 0xBA86, 0x7C22, 0xBA87,\r\n\t0x7C23, 0xBA88, 0x7C24, 0xBA89, 0x7C25, 0xBA8A, 0x7C26, 0xF4A3,\t0x7C27, 0xBBC9, 0x7C28, 0xBA8B, 0x7C29, 0xBA8C, 0x7C2A, 0xF4A2,\r\n\t0x7C2B, 0xBA8D, 0x7C2C, 0xBA8E, 0x7C2D, 0xBA8F, 0x7C2E, 0xBA90,\t0x7C2F, 0xBA91, 0x7C30, 0xBA92, 0x7C31, 0xBA93, 0x7C32, 0xBA94,\r\n\t0x7C33, 0xBA95, 0x7C34, 0xBA96, 0x7C35, 0xBA97, 0x7C36, 0xBA98,\t0x7C37, 0xBA99, 0x7C38, 0xF4A4, 0x7C39, 0xBA9A, 0x7C3A, 0xBA9B,\r\n\t0x7C3B, 0xBA9C, 0x7C3C, 0xBA9D, 0x7C3D, 0xBA9E, 0x7C3E, 0xBA9F,\t0x7C3F, 0xB2BE, 0x7C40, 0xF4A6, 0x7C41, 0xF4A5, 0x7C42, 0xBAA0,\r\n\t0x7C43, 0xBB40, 0x7C44, 0xBB41, 0x7C45, 0xBB42, 0x7C46, 0xBB43,\t0x7C47, 0xBB44, 0x7C48, 0xBB45, 0x7C49, 0xBB46, 0x7C4A, 0xBB47,\r\n\t0x7C4B, 0xBB48, 0x7C4C, 0xBB49, 0x7C4D, 0xBCAE, 0x7C4E, 0xBB4A,\t0x7C4F, 0xBB4B, 0x7C50, 0xBB4C, 0x7C51, 0xBB4D, 0x7C52, 0xBB4E,\r\n\t0x7C53, 0xBB4F, 0x7C54, 0xBB50, 0x7C55, 0xBB51, 0x7C56, 0xBB52,\t0x7C57, 0xBB53, 0x7C58, 0xBB54, 0x7C59, 0xBB55, 0x7C5A, 0xBB56,\r\n\t0x7C5B, 0xBB57, 0x7C5C, 0xBB58, 0x7C5D, 0xBB59, 0x7C5E, 0xBB5A,\t0x7C5F, 0xBB5B, 0x7C60, 0xBB5C, 0x7C61, 0xBB5D, 0x7C62, 0xBB5E,\r\n\t0x7C63, 0xBB5F, 0x7C64, 0xBB60, 0x7C65, 0xBB61, 0x7C66, 0xBB62,\t0x7C67, 0xBB63, 0x7C68, 0xBB64, 0x7C69, 0xBB65, 0x7C6A, 0xBB66,\r\n\t0x7C6B, 0xBB67, 0x7C6C, 0xBB68, 0x7C6D, 0xBB69, 0x7C6E, 0xBB6A,\t0x7C6F, 0xBB6B, 0x7C70, 0xBB6C, 0x7C71, 0xBB6D, 0x7C72, 0xBB6E,\r\n\t0x7C73, 0xC3D7, 0x7C74, 0xD9E1, 0x7C75, 0xBB6F, 0x7C76, 0xBB70,\t0x7C77, 0xBB71, 0x7C78, 0xBB72, 0x7C79, 0xBB73, 0x7C7A, 0xBB74,\r\n\t0x7C7B, 0xC0E0, 0x7C7C, 0xF4CC, 0x7C7D, 0xD7D1, 0x7C7E, 0xBB75,\t0x7C7F, 0xBB76, 0x7C80, 0xBB77, 0x7C81, 0xBB78, 0x7C82, 0xBB79,\r\n\t0x7C83, 0xBB7A, 0x7C84, 0xBB7B, 0x7C85, 0xBB7C, 0x7C86, 0xBB7D,\t0x7C87, 0xBB7E, 0x7C88, 0xBB80, 0x7C89, 0xB7DB, 0x7C8A, 0xBB81,\r\n\t0x7C8B, 0xBB82, 0x7C8C, 0xBB83, 0x7C8D, 0xBB84, 0x7C8E, 0xBB85,\t0x7C8F, 0xBB86, 0x7C90, 0xBB87, 0x7C91, 0xF4CE, 0x7C92, 0xC1A3,\r\n\t0x7C93, 0xBB88, 0x7C94, 0xBB89, 0x7C95, 0xC6C9, 0x7C96, 0xBB8A,\t0x7C97, 0xB4D6, 0x7C98, 0xD5B3, 0x7C99, 0xBB8B, 0x7C9A, 0xBB8C,\r\n\t0x7C9B, 0xBB8D, 0x7C9C, 0xF4D0, 0x7C9D, 0xF4CF, 0x7C9E, 0xF4D1,\t0x7C9F, 0xCBDA, 0x7CA0, 0xBB8E, 0x7CA1, 0xBB8F, 0x7CA2, 0xF4D2,\r\n\t0x7CA3, 0xBB90, 0x7CA4, 0xD4C1, 0x7CA5, 0xD6E0, 0x7CA6, 0xBB91,\t0x7CA7, 0xBB92, 0x7CA8, 0xBB93, 0x7CA9, 0xBB94, 0x7CAA, 0xB7E0,\r\n\t0x7CAB, 0xBB95, 0x7CAC, 0xBB96, 0x7CAD, 0xBB97, 0x7CAE, 0xC1B8,\t0x7CAF, 0xBB98, 0x7CB0, 0xBB99, 0x7CB1, 0xC1BB, 0x7CB2, 0xF4D3,\r\n\t0x7CB3, 0xBEAC, 0x7CB4, 0xBB9A, 0x7CB5, 0xBB9B, 0x7CB6, 0xBB9C,\t0x7CB7, 0xBB9D, 0x7CB8, 0xBB9E, 0x7CB9, 0xB4E2, 0x7CBA, 0xBB9F,\r\n\t0x7CBB, 0xBBA0, 0x7CBC, 0xF4D4, 0x7CBD, 0xF4D5, 0x7CBE, 0xBEAB,\t0x7CBF, 0xBC40, 0x7CC0, 0xBC41, 0x7CC1, 0xF4D6, 0x7CC2, 0xBC42,\r\n\t0x7CC3, 0xBC43, 0x7CC4, 0xBC44, 0x7CC5, 0xF4DB, 0x7CC6, 0xBC45,\t0x7CC7, 0xF4D7, 0x7CC8, 0xF4DA, 0x7CC9, 0xBC46, 0x7CCA, 0xBAFD,\r\n\t0x7CCB, 0xBC47, 0x7CCC, 0xF4D8, 0x7CCD, 0xF4D9, 0x7CCE, 0xBC48,\t0x7CCF, 0xBC49, 0x7CD0, 0xBC4A, 0x7CD1, 0xBC4B, 0x7CD2, 0xBC4C,\r\n\t0x7CD3, 0xBC4D, 0x7CD4, 0xBC4E, 0x7CD5, 0xB8E2, 0x7CD6, 0xCCC7,\t0x7CD7, 0xF4DC, 0x7CD8, 0xBC4F, 0x7CD9, 0xB2DA, 0x7CDA, 0xBC50,\r\n\t0x7CDB, 0xBC51, 0x7CDC, 0xC3D3, 0x7CDD, 0xBC52, 0x7CDE, 0xBC53,\t0x7CDF, 0xD4E3, 0x7CE0, 0xBFB7, 0x7CE1, 0xBC54, 0x7CE2, 0xBC55,\r\n\t0x7CE3, 0xBC56, 0x7CE4, 0xBC57, 0x7CE5, 0xBC58, 0x7CE6, 0xBC59,\t0x7CE7, 0xBC5A, 0x7CE8, 0xF4DD, 0x7CE9, 0xBC5B, 0x7CEA, 0xBC5C,\r\n\t0x7CEB, 0xBC5D, 0x7CEC, 0xBC5E, 0x7CED, 0xBC5F, 0x7CEE, 0xBC60,\t0x7CEF, 0xC5B4, 0x7CF0, 0xBC61, 0x7CF1, 0xBC62, 0x7CF2, 0xBC63,\r\n\t0x7CF3, 0xBC64, 0x7CF4, 0xBC65, 0x7CF5, 0xBC66, 0x7CF6, 0xBC67,\t0x7CF7, 0xBC68, 0x7CF8, 0xF4E9, 0x7CF9, 0xBC69, 0x7CFA, 0xBC6A,\r\n\t0x7CFB, 0xCFB5, 0x7CFC, 0xBC6B, 0x7CFD, 0xBC6C, 0x7CFE, 0xBC6D,\t0x7CFF, 0xBC6E, 0x7D00, 0xBC6F, 0x7D01, 0xBC70, 0x7D02, 0xBC71,\r\n\t0x7D03, 0xBC72, 0x7D04, 0xBC73, 0x7D05, 0xBC74, 0x7D06, 0xBC75,\t0x7D07, 0xBC76, 0x7D08, 0xBC77, 0x7D09, 0xBC78, 0x7D0A, 0xCEC9,\r\n\t0x7D0B, 0xBC79, 0x7D0C, 0xBC7A, 0x7D0D, 0xBC7B, 0x7D0E, 0xBC7C,\t0x7D0F, 0xBC7D, 0x7D10, 0xBC7E, 0x7D11, 0xBC80, 0x7D12, 0xBC81,\r\n\t0x7D13, 0xBC82, 0x7D14, 0xBC83, 0x7D15, 0xBC84, 0x7D16, 0xBC85,\t0x7D17, 0xBC86, 0x7D18, 0xBC87, 0x7D19, 0xBC88, 0x7D1A, 0xBC89,\r\n\t0x7D1B, 0xBC8A, 0x7D1C, 0xBC8B, 0x7D1D, 0xBC8C, 0x7D1E, 0xBC8D,\t0x7D1F, 0xBC8E, 0x7D20, 0xCBD8, 0x7D21, 0xBC8F, 0x7D22, 0xCBF7,\r\n\t0x7D23, 0xBC90, 0x7D24, 0xBC91, 0x7D25, 0xBC92, 0x7D26, 0xBC93,\t0x7D27, 0xBDF4, 0x7D28, 0xBC94, 0x7D29, 0xBC95, 0x7D2A, 0xBC96,\r\n\t0x7D2B, 0xD7CF, 0x7D2C, 0xBC97, 0x7D2D, 0xBC98, 0x7D2E, 0xBC99,\t0x7D2F, 0xC0DB, 0x7D30, 0xBC9A, 0x7D31, 0xBC9B, 0x7D32, 0xBC9C,\r\n\t0x7D33, 0xBC9D, 0x7D34, 0xBC9E, 0x7D35, 0xBC9F, 0x7D36, 0xBCA0,\t0x7D37, 0xBD40, 0x7D38, 0xBD41, 0x7D39, 0xBD42, 0x7D3A, 0xBD43,\r\n\t0x7D3B, 0xBD44, 0x7D3C, 0xBD45, 0x7D3D, 0xBD46, 0x7D3E, 0xBD47,\t0x7D3F, 0xBD48, 0x7D40, 0xBD49, 0x7D41, 0xBD4A, 0x7D42, 0xBD4B,\r\n\t0x7D43, 0xBD4C, 0x7D44, 0xBD4D, 0x7D45, 0xBD4E, 0x7D46, 0xBD4F,\t0x7D47, 0xBD50, 0x7D48, 0xBD51, 0x7D49, 0xBD52, 0x7D4A, 0xBD53,\r\n\t0x7D4B, 0xBD54, 0x7D4C, 0xBD55, 0x7D4D, 0xBD56, 0x7D4E, 0xBD57,\t0x7D4F, 0xBD58, 0x7D50, 0xBD59, 0x7D51, 0xBD5A, 0x7D52, 0xBD5B,\r\n\t0x7D53, 0xBD5C, 0x7D54, 0xBD5D, 0x7D55, 0xBD5E, 0x7D56, 0xBD5F,\t0x7D57, 0xBD60, 0x7D58, 0xBD61, 0x7D59, 0xBD62, 0x7D5A, 0xBD63,\r\n\t0x7D5B, 0xBD64, 0x7D5C, 0xBD65, 0x7D5D, 0xBD66, 0x7D5E, 0xBD67,\t0x7D5F, 0xBD68, 0x7D60, 0xBD69, 0x7D61, 0xBD6A, 0x7D62, 0xBD6B,\r\n\t0x7D63, 0xBD6C, 0x7D64, 0xBD6D, 0x7D65, 0xBD6E, 0x7D66, 0xBD6F,\t0x7D67, 0xBD70, 0x7D68, 0xBD71, 0x7D69, 0xBD72, 0x7D6A, 0xBD73,\r\n\t0x7D6B, 0xBD74, 0x7D6C, 0xBD75, 0x7D6D, 0xBD76, 0x7D6E, 0xD0F5,\t0x7D6F, 0xBD77, 0x7D70, 0xBD78, 0x7D71, 0xBD79, 0x7D72, 0xBD7A,\r\n\t0x7D73, 0xBD7B, 0x7D74, 0xBD7C, 0x7D75, 0xBD7D, 0x7D76, 0xBD7E,\t0x7D77, 0xF4EA, 0x7D78, 0xBD80, 0x7D79, 0xBD81, 0x7D7A, 0xBD82,\r\n\t0x7D7B, 0xBD83, 0x7D7C, 0xBD84, 0x7D7D, 0xBD85, 0x7D7E, 0xBD86,\t0x7D7F, 0xBD87, 0x7D80, 0xBD88, 0x7D81, 0xBD89, 0x7D82, 0xBD8A,\r\n\t0x7D83, 0xBD8B, 0x7D84, 0xBD8C, 0x7D85, 0xBD8D, 0x7D86, 0xBD8E,\t0x7D87, 0xBD8F, 0x7D88, 0xBD90, 0x7D89, 0xBD91, 0x7D8A, 0xBD92,\r\n\t0x7D8B, 0xBD93, 0x7D8C, 0xBD94, 0x7D8D, 0xBD95, 0x7D8E, 0xBD96,\t0x7D8F, 0xBD97, 0x7D90, 0xBD98, 0x7D91, 0xBD99, 0x7D92, 0xBD9A,\r\n\t0x7D93, 0xBD9B, 0x7D94, 0xBD9C, 0x7D95, 0xBD9D, 0x7D96, 0xBD9E,\t0x7D97, 0xBD9F, 0x7D98, 0xBDA0, 0x7D99, 0xBE40, 0x7D9A, 0xBE41,\r\n\t0x7D9B, 0xBE42, 0x7D9C, 0xBE43, 0x7D9D, 0xBE44, 0x7D9E, 0xBE45,\t0x7D9F, 0xBE46, 0x7DA0, 0xBE47, 0x7DA1, 0xBE48, 0x7DA2, 0xBE49,\r\n\t0x7DA3, 0xBE4A, 0x7DA4, 0xBE4B, 0x7DA5, 0xBE4C, 0x7DA6, 0xF4EB,\t0x7DA7, 0xBE4D, 0x7DA8, 0xBE4E, 0x7DA9, 0xBE4F, 0x7DAA, 0xBE50,\r\n\t0x7DAB, 0xBE51, 0x7DAC, 0xBE52, 0x7DAD, 0xBE53, 0x7DAE, 0xF4EC,\t0x7DAF, 0xBE54, 0x7DB0, 0xBE55, 0x7DB1, 0xBE56, 0x7DB2, 0xBE57,\r\n\t0x7DB3, 0xBE58, 0x7DB4, 0xBE59, 0x7DB5, 0xBE5A, 0x7DB6, 0xBE5B,\t0x7DB7, 0xBE5C, 0x7DB8, 0xBE5D, 0x7DB9, 0xBE5E, 0x7DBA, 0xBE5F,\r\n\t0x7DBB, 0xBE60, 0x7DBC, 0xBE61, 0x7DBD, 0xBE62, 0x7DBE, 0xBE63,\t0x7DBF, 0xBE64, 0x7DC0, 0xBE65, 0x7DC1, 0xBE66, 0x7DC2, 0xBE67,\r\n\t0x7DC3, 0xBE68, 0x7DC4, 0xBE69, 0x7DC5, 0xBE6A, 0x7DC6, 0xBE6B,\t0x7DC7, 0xBE6C, 0x7DC8, 0xBE6D, 0x7DC9, 0xBE6E, 0x7DCA, 0xBE6F,\r\n\t0x7DCB, 0xBE70, 0x7DCC, 0xBE71, 0x7DCD, 0xBE72, 0x7DCE, 0xBE73,\t0x7DCF, 0xBE74, 0x7DD0, 0xBE75, 0x7DD1, 0xBE76, 0x7DD2, 0xBE77,\r\n\t0x7DD3, 0xBE78, 0x7DD4, 0xBE79, 0x7DD5, 0xBE7A, 0x7DD6, 0xBE7B,\t0x7DD7, 0xBE7C, 0x7DD8, 0xBE7D, 0x7DD9, 0xBE7E, 0x7DDA, 0xBE80,\r\n\t0x7DDB, 0xBE81, 0x7DDC, 0xBE82, 0x7DDD, 0xBE83, 0x7DDE, 0xBE84,\t0x7DDF, 0xBE85, 0x7DE0, 0xBE86, 0x7DE1, 0xBE87, 0x7DE2, 0xBE88,\r\n\t0x7DE3, 0xBE89, 0x7DE4, 0xBE8A, 0x7DE5, 0xBE8B, 0x7DE6, 0xBE8C,\t0x7DE7, 0xBE8D, 0x7DE8, 0xBE8E, 0x7DE9, 0xBE8F, 0x7DEA, 0xBE90,\r\n\t0x7DEB, 0xBE91, 0x7DEC, 0xBE92, 0x7DED, 0xBE93, 0x7DEE, 0xBE94,\t0x7DEF, 0xBE95, 0x7DF0, 0xBE96, 0x7DF1, 0xBE97, 0x7DF2, 0xBE98,\r\n\t0x7DF3, 0xBE99, 0x7DF4, 0xBE9A, 0x7DF5, 0xBE9B, 0x7DF6, 0xBE9C,\t0x7DF7, 0xBE9D, 0x7DF8, 0xBE9E, 0x7DF9, 0xBE9F, 0x7DFA, 0xBEA0,\r\n\t0x7DFB, 0xBF40, 0x7DFC, 0xBF41, 0x7DFD, 0xBF42, 0x7DFE, 0xBF43,\t0x7DFF, 0xBF44, 0x7E00, 0xBF45, 0x7E01, 0xBF46, 0x7E02, 0xBF47,\r\n\t0x7E03, 0xBF48, 0x7E04, 0xBF49, 0x7E05, 0xBF4A, 0x7E06, 0xBF4B,\t0x7E07, 0xBF4C, 0x7E08, 0xBF4D, 0x7E09, 0xBF4E, 0x7E0A, 0xBF4F,\r\n\t0x7E0B, 0xBF50, 0x7E0C, 0xBF51, 0x7E0D, 0xBF52, 0x7E0E, 0xBF53,\t0x7E0F, 0xBF54, 0x7E10, 0xBF55, 0x7E11, 0xBF56, 0x7E12, 0xBF57,\r\n\t0x7E13, 0xBF58, 0x7E14, 0xBF59, 0x7E15, 0xBF5A, 0x7E16, 0xBF5B,\t0x7E17, 0xBF5C, 0x7E18, 0xBF5D, 0x7E19, 0xBF5E, 0x7E1A, 0xBF5F,\r\n\t0x7E1B, 0xBF60, 0x7E1C, 0xBF61, 0x7E1D, 0xBF62, 0x7E1E, 0xBF63,\t0x7E1F, 0xBF64, 0x7E20, 0xBF65, 0x7E21, 0xBF66, 0x7E22, 0xBF67,\r\n\t0x7E23, 0xBF68, 0x7E24, 0xBF69, 0x7E25, 0xBF6A, 0x7E26, 0xBF6B,\t0x7E27, 0xBF6C, 0x7E28, 0xBF6D, 0x7E29, 0xBF6E, 0x7E2A, 0xBF6F,\r\n\t0x7E2B, 0xBF70, 0x7E2C, 0xBF71, 0x7E2D, 0xBF72, 0x7E2E, 0xBF73,\t0x7E2F, 0xBF74, 0x7E30, 0xBF75, 0x7E31, 0xBF76, 0x7E32, 0xBF77,\r\n\t0x7E33, 0xBF78, 0x7E34, 0xBF79, 0x7E35, 0xBF7A, 0x7E36, 0xBF7B,\t0x7E37, 0xBF7C, 0x7E38, 0xBF7D, 0x7E39, 0xBF7E, 0x7E3A, 0xBF80,\r\n\t0x7E3B, 0xF7E3, 0x7E3C, 0xBF81, 0x7E3D, 0xBF82, 0x7E3E, 0xBF83,\t0x7E3F, 0xBF84, 0x7E40, 0xBF85, 0x7E41, 0xB7B1, 0x7E42, 0xBF86,\r\n\t0x7E43, 0xBF87, 0x7E44, 0xBF88, 0x7E45, 0xBF89, 0x7E46, 0xBF8A,\t0x7E47, 0xF4ED, 0x7E48, 0xBF8B, 0x7E49, 0xBF8C, 0x7E4A, 0xBF8D,\r\n\t0x7E4B, 0xBF8E, 0x7E4C, 0xBF8F, 0x7E4D, 0xBF90, 0x7E4E, 0xBF91,\t0x7E4F, 0xBF92, 0x7E50, 0xBF93, 0x7E51, 0xBF94, 0x7E52, 0xBF95,\r\n\t0x7E53, 0xBF96, 0x7E54, 0xBF97, 0x7E55, 0xBF98, 0x7E56, 0xBF99,\t0x7E57, 0xBF9A, 0x7E58, 0xBF9B, 0x7E59, 0xBF9C, 0x7E5A, 0xBF9D,\r\n\t0x7E5B, 0xBF9E, 0x7E5C, 0xBF9F, 0x7E5D, 0xBFA0, 0x7E5E, 0xC040,\t0x7E5F, 0xC041, 0x7E60, 0xC042, 0x7E61, 0xC043, 0x7E62, 0xC044,\r\n\t0x7E63, 0xC045, 0x7E64, 0xC046, 0x7E65, 0xC047, 0x7E66, 0xC048,\t0x7E67, 0xC049, 0x7E68, 0xC04A, 0x7E69, 0xC04B, 0x7E6A, 0xC04C,\r\n\t0x7E6B, 0xC04D, 0x7E6C, 0xC04E, 0x7E6D, 0xC04F, 0x7E6E, 0xC050,\t0x7E6F, 0xC051, 0x7E70, 0xC052, 0x7E71, 0xC053, 0x7E72, 0xC054,\r\n\t0x7E73, 0xC055, 0x7E74, 0xC056, 0x7E75, 0xC057, 0x7E76, 0xC058,\t0x7E77, 0xC059, 0x7E78, 0xC05A, 0x7E79, 0xC05B, 0x7E7A, 0xC05C,\r\n\t0x7E7B, 0xC05D, 0x7E7C, 0xC05E, 0x7E7D, 0xC05F, 0x7E7E, 0xC060,\t0x7E7F, 0xC061, 0x7E80, 0xC062, 0x7E81, 0xC063, 0x7E82, 0xD7EB,\r\n\t0x7E83, 0xC064, 0x7E84, 0xC065, 0x7E85, 0xC066, 0x7E86, 0xC067,\t0x7E87, 0xC068, 0x7E88, 0xC069, 0x7E89, 0xC06A, 0x7E8A, 0xC06B,\r\n\t0x7E8B, 0xC06C, 0x7E8C, 0xC06D, 0x7E8D, 0xC06E, 0x7E8E, 0xC06F,\t0x7E8F, 0xC070, 0x7E90, 0xC071, 0x7E91, 0xC072, 0x7E92, 0xC073,\r\n\t0x7E93, 0xC074, 0x7E94, 0xC075, 0x7E95, 0xC076, 0x7E96, 0xC077,\t0x7E97, 0xC078, 0x7E98, 0xC079, 0x7E99, 0xC07A, 0x7E9A, 0xC07B,\r\n\t0x7E9B, 0xF4EE, 0x7E9C, 0xC07C, 0x7E9D, 0xC07D, 0x7E9E, 0xC07E,\t0x7E9F, 0xE6F9, 0x7EA0, 0xBEC0, 0x7EA1, 0xE6FA, 0x7EA2, 0xBAEC,\r\n\t0x7EA3, 0xE6FB, 0x7EA4, 0xCFCB, 0x7EA5, 0xE6FC, 0x7EA6, 0xD4BC,\t0x7EA7, 0xBCB6, 0x7EA8, 0xE6FD, 0x7EA9, 0xE6FE, 0x7EAA, 0xBCCD,\r\n\t0x7EAB, 0xC8D2, 0x7EAC, 0xCEB3, 0x7EAD, 0xE7A1, 0x7EAE, 0xC080,\t0x7EAF, 0xB4BF, 0x7EB0, 0xE7A2, 0x7EB1, 0xC9B4, 0x7EB2, 0xB8D9,\r\n\t0x7EB3, 0xC4C9, 0x7EB4, 0xC081, 0x7EB5, 0xD7DD, 0x7EB6, 0xC2DA,\t0x7EB7, 0xB7D7, 0x7EB8, 0xD6BD, 0x7EB9, 0xCEC6, 0x7EBA, 0xB7C4,\r\n\t0x7EBB, 0xC082, 0x7EBC, 0xC083, 0x7EBD, 0xC5A6, 0x7EBE, 0xE7A3,\t0x7EBF, 0xCFDF, 0x7EC0, 0xE7A4, 0x7EC1, 0xE7A5, 0x7EC2, 0xE7A6,\r\n\t0x7EC3, 0xC1B7, 0x7EC4, 0xD7E9, 0x7EC5, 0xC9F0, 0x7EC6, 0xCFB8,\t0x7EC7, 0xD6AF, 0x7EC8, 0xD6D5, 0x7EC9, 0xE7A7, 0x7ECA, 0xB0ED,\r\n\t0x7ECB, 0xE7A8, 0x7ECC, 0xE7A9, 0x7ECD, 0xC9DC, 0x7ECE, 0xD2EF,\t0x7ECF, 0xBEAD, 0x7ED0, 0xE7AA, 0x7ED1, 0xB0F3, 0x7ED2, 0xC8DE,\r\n\t0x7ED3, 0xBDE1, 0x7ED4, 0xE7AB, 0x7ED5, 0xC8C6, 0x7ED6, 0xC084,\t0x7ED7, 0xE7AC, 0x7ED8, 0xBBE6, 0x7ED9, 0xB8F8, 0x7EDA, 0xD1A4,\r\n\t0x7EDB, 0xE7AD, 0x7EDC, 0xC2E7, 0x7EDD, 0xBEF8, 0x7EDE, 0xBDCA,\t0x7EDF, 0xCDB3, 0x7EE0, 0xE7AE, 0x7EE1, 0xE7AF, 0x7EE2, 0xBEEE,\r\n\t0x7EE3, 0xD0E5, 0x7EE4, 0xC085, 0x7EE5, 0xCBE7, 0x7EE6, 0xCCD0,\t0x7EE7, 0xBCCC, 0x7EE8, 0xE7B0, 0x7EE9, 0xBCA8, 0x7EEA, 0xD0F7,\r\n\t0x7EEB, 0xE7B1, 0x7EEC, 0xC086, 0x7EED, 0xD0F8, 0x7EEE, 0xE7B2,\t0x7EEF, 0xE7B3, 0x7EF0, 0xB4C2, 0x7EF1, 0xE7B4, 0x7EF2, 0xE7B5,\r\n\t0x7EF3, 0xC9FE, 0x7EF4, 0xCEAC, 0x7EF5, 0xC3E0, 0x7EF6, 0xE7B7,\t0x7EF7, 0xB1C1, 0x7EF8, 0xB3F1, 0x7EF9, 0xC087, 0x7EFA, 0xE7B8,\r\n\t0x7EFB, 0xE7B9, 0x7EFC, 0xD7DB, 0x7EFD, 0xD5C0, 0x7EFE, 0xE7BA,\t0x7EFF, 0xC2CC, 0x7F00, 0xD7BA, 0x7F01, 0xE7BB, 0x7F02, 0xE7BC,\r\n\t0x7F03, 0xE7BD, 0x7F04, 0xBCEA, 0x7F05, 0xC3E5, 0x7F06, 0xC0C2,\t0x7F07, 0xE7BE, 0x7F08, 0xE7BF, 0x7F09, 0xBCA9, 0x7F0A, 0xC088,\r\n\t0x7F0B, 0xE7C0, 0x7F0C, 0xE7C1, 0x7F0D, 0xE7B6, 0x7F0E, 0xB6D0,\t0x7F0F, 0xE7C2, 0x7F10, 0xC089, 0x7F11, 0xE7C3, 0x7F12, 0xE7C4,\r\n\t0x7F13, 0xBBBA, 0x7F14, 0xB5DE, 0x7F15, 0xC2C6, 0x7F16, 0xB1E0,\t0x7F17, 0xE7C5, 0x7F18, 0xD4B5, 0x7F19, 0xE7C6, 0x7F1A, 0xB8BF,\r\n\t0x7F1B, 0xE7C8, 0x7F1C, 0xE7C7, 0x7F1D, 0xB7EC, 0x7F1E, 0xC08A,\t0x7F1F, 0xE7C9, 0x7F20, 0xB2F8, 0x7F21, 0xE7CA, 0x7F22, 0xE7CB,\r\n\t0x7F23, 0xE7CC, 0x7F24, 0xE7CD, 0x7F25, 0xE7CE, 0x7F26, 0xE7CF,\t0x7F27, 0xE7D0, 0x7F28, 0xD3A7, 0x7F29, 0xCBF5, 0x7F2A, 0xE7D1,\r\n\t0x7F2B, 0xE7D2, 0x7F2C, 0xE7D3, 0x7F2D, 0xE7D4, 0x7F2E, 0xC9C9,\t0x7F2F, 0xE7D5, 0x7F30, 0xE7D6, 0x7F31, 0xE7D7, 0x7F32, 0xE7D8,\r\n\t0x7F33, 0xE7D9, 0x7F34, 0xBDC9, 0x7F35, 0xE7DA, 0x7F36, 0xF3BE,\t0x7F37, 0xC08B, 0x7F38, 0xB8D7, 0x7F39, 0xC08C, 0x7F3A, 0xC8B1,\r\n\t0x7F3B, 0xC08D, 0x7F3C, 0xC08E, 0x7F3D, 0xC08F, 0x7F3E, 0xC090,\t0x7F3F, 0xC091, 0x7F40, 0xC092, 0x7F41, 0xC093, 0x7F42, 0xF3BF,\r\n\t0x7F43, 0xC094, 0x7F44, 0xF3C0, 0x7F45, 0xF3C1, 0x7F46, 0xC095,\t0x7F47, 0xC096, 0x7F48, 0xC097, 0x7F49, 0xC098, 0x7F4A, 0xC099,\r\n\t0x7F4B, 0xC09A, 0x7F4C, 0xC09B, 0x7F4D, 0xC09C, 0x7F4E, 0xC09D,\t0x7F4F, 0xC09E, 0x7F50, 0xB9DE, 0x7F51, 0xCDF8, 0x7F52, 0xC09F,\r\n\t0x7F53, 0xC0A0, 0x7F54, 0xD8E8, 0x7F55, 0xBAB1, 0x7F56, 0xC140,\t0x7F57, 0xC2DE, 0x7F58, 0xEEB7, 0x7F59, 0xC141, 0x7F5A, 0xB7A3,\r\n\t0x7F5B, 0xC142, 0x7F5C, 0xC143, 0x7F5D, 0xC144, 0x7F5E, 0xC145,\t0x7F5F, 0xEEB9, 0x7F60, 0xC146, 0x7F61, 0xEEB8, 0x7F62, 0xB0D5,\r\n\t0x7F63, 0xC147, 0x7F64, 0xC148, 0x7F65, 0xC149, 0x7F66, 0xC14A,\t0x7F67, 0xC14B, 0x7F68, 0xEEBB, 0x7F69, 0xD5D6, 0x7F6A, 0xD7EF,\r\n\t0x7F6B, 0xC14C, 0x7F6C, 0xC14D, 0x7F6D, 0xC14E, 0x7F6E, 0xD6C3,\t0x7F6F, 0xC14F, 0x7F70, 0xC150, 0x7F71, 0xEEBD, 0x7F72, 0xCAF0,\r\n\t0x7F73, 0xC151, 0x7F74, 0xEEBC, 0x7F75, 0xC152, 0x7F76, 0xC153,\t0x7F77, 0xC154, 0x7F78, 0xC155, 0x7F79, 0xEEBE, 0x7F7A, 0xC156,\r\n\t0x7F7B, 0xC157, 0x7F7C, 0xC158, 0x7F7D, 0xC159, 0x7F7E, 0xEEC0,\t0x7F7F, 0xC15A, 0x7F80, 0xC15B, 0x7F81, 0xEEBF, 0x7F82, 0xC15C,\r\n\t0x7F83, 0xC15D, 0x7F84, 0xC15E, 0x7F85, 0xC15F, 0x7F86, 0xC160,\t0x7F87, 0xC161, 0x7F88, 0xC162, 0x7F89, 0xC163, 0x7F8A, 0xD1F2,\r\n\t0x7F8B, 0xC164, 0x7F8C, 0xC7BC, 0x7F8D, 0xC165, 0x7F8E, 0xC3C0,\t0x7F8F, 0xC166, 0x7F90, 0xC167, 0x7F91, 0xC168, 0x7F92, 0xC169,\r\n\t0x7F93, 0xC16A, 0x7F94, 0xB8E1, 0x7F95, 0xC16B, 0x7F96, 0xC16C,\t0x7F97, 0xC16D, 0x7F98, 0xC16E, 0x7F99, 0xC16F, 0x7F9A, 0xC1E7,\r\n\t0x7F9B, 0xC170, 0x7F9C, 0xC171, 0x7F9D, 0xF4C6, 0x7F9E, 0xD0DF,\t0x7F9F, 0xF4C7, 0x7FA0, 0xC172, 0x7FA1, 0xCFDB, 0x7FA2, 0xC173,\r\n\t0x7FA3, 0xC174, 0x7FA4, 0xC8BA, 0x7FA5, 0xC175, 0x7FA6, 0xC176,\t0x7FA7, 0xF4C8, 0x7FA8, 0xC177, 0x7FA9, 0xC178, 0x7FAA, 0xC179,\r\n\t0x7FAB, 0xC17A, 0x7FAC, 0xC17B, 0x7FAD, 0xC17C, 0x7FAE, 0xC17D,\t0x7FAF, 0xF4C9, 0x7FB0, 0xF4CA, 0x7FB1, 0xC17E, 0x7FB2, 0xF4CB,\r\n\t0x7FB3, 0xC180, 0x7FB4, 0xC181, 0x7FB5, 0xC182, 0x7FB6, 0xC183,\t0x7FB7, 0xC184, 0x7FB8, 0xD9FA, 0x7FB9, 0xB8FE, 0x7FBA, 0xC185,\r\n\t0x7FBB, 0xC186, 0x7FBC, 0xE5F1, 0x7FBD, 0xD3F0, 0x7FBE, 0xC187,\t0x7FBF, 0xF4E0, 0x7FC0, 0xC188, 0x7FC1, 0xCECC, 0x7FC2, 0xC189,\r\n\t0x7FC3, 0xC18A, 0x7FC4, 0xC18B, 0x7FC5, 0xB3E1, 0x7FC6, 0xC18C,\t0x7FC7, 0xC18D, 0x7FC8, 0xC18E, 0x7FC9, 0xC18F, 0x7FCA, 0xF1B4,\r\n\t0x7FCB, 0xC190, 0x7FCC, 0xD2EE, 0x7FCD, 0xC191, 0x7FCE, 0xF4E1,\t0x7FCF, 0xC192, 0x7FD0, 0xC193, 0x7FD1, 0xC194, 0x7FD2, 0xC195,\r\n\t0x7FD3, 0xC196, 0x7FD4, 0xCFE8, 0x7FD5, 0xF4E2, 0x7FD6, 0xC197,\t0x7FD7, 0xC198, 0x7FD8, 0xC7CC, 0x7FD9, 0xC199, 0x7FDA, 0xC19A,\r\n\t0x7FDB, 0xC19B, 0x7FDC, 0xC19C, 0x7FDD, 0xC19D, 0x7FDE, 0xC19E,\t0x7FDF, 0xB5D4, 0x7FE0, 0xB4E4, 0x7FE1, 0xF4E4, 0x7FE2, 0xC19F,\r\n\t0x7FE3, 0xC1A0, 0x7FE4, 0xC240, 0x7FE5, 0xF4E3, 0x7FE6, 0xF4E5,\t0x7FE7, 0xC241, 0x7FE8, 0xC242, 0x7FE9, 0xF4E6, 0x7FEA, 0xC243,\r\n\t0x7FEB, 0xC244, 0x7FEC, 0xC245, 0x7FED, 0xC246, 0x7FEE, 0xF4E7,\t0x7FEF, 0xC247, 0x7FF0, 0xBAB2, 0x7FF1, 0xB0BF, 0x7FF2, 0xC248,\r\n\t0x7FF3, 0xF4E8, 0x7FF4, 0xC249, 0x7FF5, 0xC24A, 0x7FF6, 0xC24B,\t0x7FF7, 0xC24C, 0x7FF8, 0xC24D, 0x7FF9, 0xC24E, 0x7FFA, 0xC24F,\r\n\t0x7FFB, 0xB7AD, 0x7FFC, 0xD2ED, 0x7FFD, 0xC250, 0x7FFE, 0xC251,\t0x7FFF, 0xC252, 0x8000, 0xD2AB, 0x8001, 0xC0CF, 0x8002, 0xC253,\r\n\t0x8003, 0xBFBC, 0x8004, 0xEBA3, 0x8005, 0xD5DF, 0x8006, 0xEAC8,\t0x8007, 0xC254, 0x8008, 0xC255, 0x8009, 0xC256, 0x800A, 0xC257,\r\n\t0x800B, 0xF1F3, 0x800C, 0xB6F8, 0x800D, 0xCBA3, 0x800E, 0xC258,\t0x800F, 0xC259, 0x8010, 0xC4CD, 0x8011, 0xC25A, 0x8012, 0xF1E7,\r\n\t0x8013, 0xC25B, 0x8014, 0xF1E8, 0x8015, 0xB8FB, 0x8016, 0xF1E9,\t0x8017, 0xBAC4, 0x8018, 0xD4C5, 0x8019, 0xB0D2, 0x801A, 0xC25C,\r\n\t0x801B, 0xC25D, 0x801C, 0xF1EA, 0x801D, 0xC25E, 0x801E, 0xC25F,\t0x801F, 0xC260, 0x8020, 0xF1EB, 0x8021, 0xC261, 0x8022, 0xF1EC,\r\n\t0x8023, 0xC262, 0x8024, 0xC263, 0x8025, 0xF1ED, 0x8026, 0xF1EE,\t0x8027, 0xF1EF, 0x8028, 0xF1F1, 0x8029, 0xF1F0, 0x802A, 0xC5D5,\r\n\t0x802B, 0xC264, 0x802C, 0xC265, 0x802D, 0xC266, 0x802E, 0xC267,\t0x802F, 0xC268, 0x8030, 0xC269, 0x8031, 0xF1F2, 0x8032, 0xC26A,\r\n\t0x8033, 0xB6FA, 0x8034, 0xC26B, 0x8035, 0xF1F4, 0x8036, 0xD2AE,\t0x8037, 0xDEC7, 0x8038, 0xCBCA, 0x8039, 0xC26C, 0x803A, 0xC26D,\r\n\t0x803B, 0xB3DC, 0x803C, 0xC26E, 0x803D, 0xB5A2, 0x803E, 0xC26F,\t0x803F, 0xB9A2, 0x8040, 0xC270, 0x8041, 0xC271, 0x8042, 0xC4F4,\r\n\t0x8043, 0xF1F5, 0x8044, 0xC272, 0x8045, 0xC273, 0x8046, 0xF1F6,\t0x8047, 0xC274, 0x8048, 0xC275, 0x8049, 0xC276, 0x804A, 0xC1C4,\r\n\t0x804B, 0xC1FB, 0x804C, 0xD6B0, 0x804D, 0xF1F7, 0x804E, 0xC277,\t0x804F, 0xC278, 0x8050, 0xC279, 0x8051, 0xC27A, 0x8052, 0xF1F8,\r\n\t0x8053, 0xC27B, 0x8054, 0xC1AA, 0x8055, 0xC27C, 0x8056, 0xC27D,\t0x8057, 0xC27E, 0x8058, 0xC6B8, 0x8059, 0xC280, 0x805A, 0xBEDB,\r\n\t0x805B, 0xC281, 0x805C, 0xC282, 0x805D, 0xC283, 0x805E, 0xC284,\t0x805F, 0xC285, 0x8060, 0xC286, 0x8061, 0xC287, 0x8062, 0xC288,\r\n\t0x8063, 0xC289, 0x8064, 0xC28A, 0x8065, 0xC28B, 0x8066, 0xC28C,\t0x8067, 0xC28D, 0x8068, 0xC28E, 0x8069, 0xF1F9, 0x806A, 0xB4CF,\r\n\t0x806B, 0xC28F, 0x806C, 0xC290, 0x806D, 0xC291, 0x806E, 0xC292,\t0x806F, 0xC293, 0x8070, 0xC294, 0x8071, 0xF1FA, 0x8072, 0xC295,\r\n\t0x8073, 0xC296, 0x8074, 0xC297, 0x8075, 0xC298, 0x8076, 0xC299,\t0x8077, 0xC29A, 0x8078, 0xC29B, 0x8079, 0xC29C, 0x807A, 0xC29D,\r\n\t0x807B, 0xC29E, 0x807C, 0xC29F, 0x807D, 0xC2A0, 0x807E, 0xC340,\t0x807F, 0xEDB2, 0x8080, 0xEDB1, 0x8081, 0xC341, 0x8082, 0xC342,\r\n\t0x8083, 0xCBE0, 0x8084, 0xD2DE, 0x8085, 0xC343, 0x8086, 0xCBC1,\t0x8087, 0xD5D8, 0x8088, 0xC344, 0x8089, 0xC8E2, 0x808A, 0xC345,\r\n\t0x808B, 0xC0DF, 0x808C, 0xBCA1, 0x808D, 0xC346, 0x808E, 0xC347,\t0x808F, 0xC348, 0x8090, 0xC349, 0x8091, 0xC34A, 0x8092, 0xC34B,\r\n\t0x8093, 0xEBC1, 0x8094, 0xC34C, 0x8095, 0xC34D, 0x8096, 0xD0A4,\t0x8097, 0xC34E, 0x8098, 0xD6E2, 0x8099, 0xC34F, 0x809A, 0xB6C7,\r\n\t0x809B, 0xB8D8, 0x809C, 0xEBC0, 0x809D, 0xB8CE, 0x809E, 0xC350,\t0x809F, 0xEBBF, 0x80A0, 0xB3A6, 0x80A1, 0xB9C9, 0x80A2, 0xD6AB,\r\n\t0x80A3, 0xC351, 0x80A4, 0xB7F4, 0x80A5, 0xB7CA, 0x80A6, 0xC352,\t0x80A7, 0xC353, 0x80A8, 0xC354, 0x80A9, 0xBCE7, 0x80AA, 0xB7BE,\r\n\t0x80AB, 0xEBC6, 0x80AC, 0xC355, 0x80AD, 0xEBC7, 0x80AE, 0xB0B9,\t0x80AF, 0xBFCF, 0x80B0, 0xC356, 0x80B1, 0xEBC5, 0x80B2, 0xD3FD,\r\n\t0x80B3, 0xC357, 0x80B4, 0xEBC8, 0x80B5, 0xC358, 0x80B6, 0xC359,\t0x80B7, 0xEBC9, 0x80B8, 0xC35A, 0x80B9, 0xC35B, 0x80BA, 0xB7CE,\r\n\t0x80BB, 0xC35C, 0x80BC, 0xEBC2, 0x80BD, 0xEBC4, 0x80BE, 0xC9F6,\t0x80BF, 0xD6D7, 0x80C0, 0xD5CD, 0x80C1, 0xD0B2, 0x80C2, 0xEBCF,\r\n\t0x80C3, 0xCEB8, 0x80C4, 0xEBD0, 0x80C5, 0xC35D, 0x80C6, 0xB5A8,\t0x80C7, 0xC35E, 0x80C8, 0xC35F, 0x80C9, 0xC360, 0x80CA, 0xC361,\r\n\t0x80CB, 0xC362, 0x80CC, 0xB1B3, 0x80CD, 0xEBD2, 0x80CE, 0xCCA5,\t0x80CF, 0xC363, 0x80D0, 0xC364, 0x80D1, 0xC365, 0x80D2, 0xC366,\r\n\t0x80D3, 0xC367, 0x80D4, 0xC368, 0x80D5, 0xC369, 0x80D6, 0xC5D6,\t0x80D7, 0xEBD3, 0x80D8, 0xC36A, 0x80D9, 0xEBD1, 0x80DA, 0xC5DF,\r\n\t0x80DB, 0xEBCE, 0x80DC, 0xCAA4, 0x80DD, 0xEBD5, 0x80DE, 0xB0FB,\t0x80DF, 0xC36B, 0x80E0, 0xC36C, 0x80E1, 0xBAFA, 0x80E2, 0xC36D,\r\n\t0x80E3, 0xC36E, 0x80E4, 0xD8B7, 0x80E5, 0xF1E3, 0x80E6, 0xC36F,\t0x80E7, 0xEBCA, 0x80E8, 0xEBCB, 0x80E9, 0xEBCC, 0x80EA, 0xEBCD,\r\n\t0x80EB, 0xEBD6, 0x80EC, 0xE6C0, 0x80ED, 0xEBD9, 0x80EE, 0xC370,\t0x80EF, 0xBFE8, 0x80F0, 0xD2C8, 0x80F1, 0xEBD7, 0x80F2, 0xEBDC,\r\n\t0x80F3, 0xB8EC, 0x80F4, 0xEBD8, 0x80F5, 0xC371, 0x80F6, 0xBDBA,\t0x80F7, 0xC372, 0x80F8, 0xD0D8, 0x80F9, 0xC373, 0x80FA, 0xB0B7,\r\n\t0x80FB, 0xC374, 0x80FC, 0xEBDD, 0x80FD, 0xC4DC, 0x80FE, 0xC375,\t0x80FF, 0xC376, 0x8100, 0xC377, 0x8101, 0xC378, 0x8102, 0xD6AC,\r\n\t0x8103, 0xC379, 0x8104, 0xC37A, 0x8105, 0xC37B, 0x8106, 0xB4E0,\t0x8107, 0xC37C, 0x8108, 0xC37D, 0x8109, 0xC2F6, 0x810A, 0xBCB9,\r\n\t0x810B, 0xC37E, 0x810C, 0xC380, 0x810D, 0xEBDA, 0x810E, 0xEBDB,\t0x810F, 0xD4E0, 0x8110, 0xC6EA, 0x8111, 0xC4D4, 0x8112, 0xEBDF,\r\n\t0x8113, 0xC5A7, 0x8114, 0xD9F5, 0x8115, 0xC381, 0x8116, 0xB2B1,\t0x8117, 0xC382, 0x8118, 0xEBE4, 0x8119, 0xC383, 0x811A, 0xBDC5,\r\n\t0x811B, 0xC384, 0x811C, 0xC385, 0x811D, 0xC386, 0x811E, 0xEBE2,\t0x811F, 0xC387, 0x8120, 0xC388, 0x8121, 0xC389, 0x8122, 0xC38A,\r\n\t0x8123, 0xC38B, 0x8124, 0xC38C, 0x8125, 0xC38D, 0x8126, 0xC38E,\t0x8127, 0xC38F, 0x8128, 0xC390, 0x8129, 0xC391, 0x812A, 0xC392,\r\n\t0x812B, 0xC393, 0x812C, 0xEBE3, 0x812D, 0xC394, 0x812E, 0xC395,\t0x812F, 0xB8AC, 0x8130, 0xC396, 0x8131, 0xCDD1, 0x8132, 0xEBE5,\r\n\t0x8133, 0xC397, 0x8134, 0xC398, 0x8135, 0xC399, 0x8136, 0xEBE1,\t0x8137, 0xC39A, 0x8138, 0xC1B3, 0x8139, 0xC39B, 0x813A, 0xC39C,\r\n\t0x813B, 0xC39D, 0x813C, 0xC39E, 0x813D, 0xC39F, 0x813E, 0xC6A2,\t0x813F, 0xC3A0, 0x8140, 0xC440, 0x8141, 0xC441, 0x8142, 0xC442,\r\n\t0x8143, 0xC443, 0x8144, 0xC444, 0x8145, 0xC445, 0x8146, 0xCCF3,\t0x8147, 0xC446, 0x8148, 0xEBE6, 0x8149, 0xC447, 0x814A, 0xC0B0,\r\n\t0x814B, 0xD2B8, 0x814C, 0xEBE7, 0x814D, 0xC448, 0x814E, 0xC449,\t0x814F, 0xC44A, 0x8150, 0xB8AF, 0x8151, 0xB8AD, 0x8152, 0xC44B,\r\n\t0x8153, 0xEBE8, 0x8154, 0xC7BB, 0x8155, 0xCDF3, 0x8156, 0xC44C,\t0x8157, 0xC44D, 0x8158, 0xC44E, 0x8159, 0xEBEA, 0x815A, 0xEBEB,\r\n\t0x815B, 0xC44F, 0x815C, 0xC450, 0x815D, 0xC451, 0x815E, 0xC452,\t0x815F, 0xC453, 0x8160, 0xEBED, 0x8161, 0xC454, 0x8162, 0xC455,\r\n\t0x8163, 0xC456, 0x8164, 0xC457, 0x8165, 0xD0C8, 0x8166, 0xC458,\t0x8167, 0xEBF2, 0x8168, 0xC459, 0x8169, 0xEBEE, 0x816A, 0xC45A,\r\n\t0x816B, 0xC45B, 0x816C, 0xC45C, 0x816D, 0xEBF1, 0x816E, 0xC8F9,\t0x816F, 0xC45D, 0x8170, 0xD1FC, 0x8171, 0xEBEC, 0x8172, 0xC45E,\r\n\t0x8173, 0xC45F, 0x8174, 0xEBE9, 0x8175, 0xC460, 0x8176, 0xC461,\t0x8177, 0xC462, 0x8178, 0xC463, 0x8179, 0xB8B9, 0x817A, 0xCFD9,\r\n\t0x817B, 0xC4E5, 0x817C, 0xEBEF, 0x817D, 0xEBF0, 0x817E, 0xCCDA,\t0x817F, 0xCDC8, 0x8180, 0xB0F2, 0x8181, 0xC464, 0x8182, 0xEBF6,\r\n\t0x8183, 0xC465, 0x8184, 0xC466, 0x8185, 0xC467, 0x8186, 0xC468,\t0x8187, 0xC469, 0x8188, 0xEBF5, 0x8189, 0xC46A, 0x818A, 0xB2B2,\r\n\t0x818B, 0xC46B, 0x818C, 0xC46C, 0x818D, 0xC46D, 0x818E, 0xC46E,\t0x818F, 0xB8E0, 0x8190, 0xC46F, 0x8191, 0xEBF7, 0x8192, 0xC470,\r\n\t0x8193, 0xC471, 0x8194, 0xC472, 0x8195, 0xC473, 0x8196, 0xC474,\t0x8197, 0xC475, 0x8198, 0xB1EC, 0x8199, 0xC476, 0x819A, 0xC477,\r\n\t0x819B, 0xCCC5, 0x819C, 0xC4A4, 0x819D, 0xCFA5, 0x819E, 0xC478,\t0x819F, 0xC479, 0x81A0, 0xC47A, 0x81A1, 0xC47B, 0x81A2, 0xC47C,\r\n\t0x81A3, 0xEBF9, 0x81A4, 0xC47D, 0x81A5, 0xC47E, 0x81A6, 0xECA2,\t0x81A7, 0xC480, 0x81A8, 0xC5F2, 0x81A9, 0xC481, 0x81AA, 0xEBFA,\r\n\t0x81AB, 0xC482, 0x81AC, 0xC483, 0x81AD, 0xC484, 0x81AE, 0xC485,\t0x81AF, 0xC486, 0x81B0, 0xC487, 0x81B1, 0xC488, 0x81B2, 0xC489,\r\n\t0x81B3, 0xC9C5, 0x81B4, 0xC48A, 0x81B5, 0xC48B, 0x81B6, 0xC48C,\t0x81B7, 0xC48D, 0x81B8, 0xC48E, 0x81B9, 0xC48F, 0x81BA, 0xE2DF,\r\n\t0x81BB, 0xEBFE, 0x81BC, 0xC490, 0x81BD, 0xC491, 0x81BE, 0xC492,\t0x81BF, 0xC493, 0x81C0, 0xCDCE, 0x81C1, 0xECA1, 0x81C2, 0xB1DB,\r\n\t0x81C3, 0xD3B7, 0x81C4, 0xC494, 0x81C5, 0xC495, 0x81C6, 0xD2DC,\t0x81C7, 0xC496, 0x81C8, 0xC497, 0x81C9, 0xC498, 0x81CA, 0xEBFD,\r\n\t0x81CB, 0xC499, 0x81CC, 0xEBFB, 0x81CD, 0xC49A, 0x81CE, 0xC49B,\t0x81CF, 0xC49C, 0x81D0, 0xC49D, 0x81D1, 0xC49E, 0x81D2, 0xC49F,\r\n\t0x81D3, 0xC4A0, 0x81D4, 0xC540, 0x81D5, 0xC541, 0x81D6, 0xC542,\t0x81D7, 0xC543, 0x81D8, 0xC544, 0x81D9, 0xC545, 0x81DA, 0xC546,\r\n\t0x81DB, 0xC547, 0x81DC, 0xC548, 0x81DD, 0xC549, 0x81DE, 0xC54A,\t0x81DF, 0xC54B, 0x81E0, 0xC54C, 0x81E1, 0xC54D, 0x81E2, 0xC54E,\r\n\t0x81E3, 0xB3BC, 0x81E4, 0xC54F, 0x81E5, 0xC550, 0x81E6, 0xC551,\t0x81E7, 0xEAB0, 0x81E8, 0xC552, 0x81E9, 0xC553, 0x81EA, 0xD7D4,\r\n\t0x81EB, 0xC554, 0x81EC, 0xF4AB, 0x81ED, 0xB3F4, 0x81EE, 0xC555,\t0x81EF, 0xC556, 0x81F0, 0xC557, 0x81F1, 0xC558, 0x81F2, 0xC559,\r\n\t0x81F3, 0xD6C1, 0x81F4, 0xD6C2, 0x81F5, 0xC55A, 0x81F6, 0xC55B,\t0x81F7, 0xC55C, 0x81F8, 0xC55D, 0x81F9, 0xC55E, 0x81FA, 0xC55F,\r\n\t0x81FB, 0xD5E9, 0x81FC, 0xBECA, 0x81FD, 0xC560, 0x81FE, 0xF4A7,\t0x81FF, 0xC561, 0x8200, 0xD2A8, 0x8201, 0xF4A8, 0x8202, 0xF4A9,\r\n\t0x8203, 0xC562, 0x8204, 0xF4AA, 0x8205, 0xBECB, 0x8206, 0xD3DF,\t0x8207, 0xC563, 0x8208, 0xC564, 0x8209, 0xC565, 0x820A, 0xC566,\r\n\t0x820B, 0xC567, 0x820C, 0xC9E0, 0x820D, 0xC9E1, 0x820E, 0xC568,\t0x820F, 0xC569, 0x8210, 0xF3C2, 0x8211, 0xC56A, 0x8212, 0xCAE6,\r\n\t0x8213, 0xC56B, 0x8214, 0xCCF2, 0x8215, 0xC56C, 0x8216, 0xC56D,\t0x8217, 0xC56E, 0x8218, 0xC56F, 0x8219, 0xC570, 0x821A, 0xC571,\r\n\t0x821B, 0xE2B6, 0x821C, 0xCBB4, 0x821D, 0xC572, 0x821E, 0xCEE8,\t0x821F, 0xD6DB, 0x8220, 0xC573, 0x8221, 0xF4AD, 0x8222, 0xF4AE,\r\n\t0x8223, 0xF4AF, 0x8224, 0xC574, 0x8225, 0xC575, 0x8226, 0xC576,\t0x8227, 0xC577, 0x8228, 0xF4B2, 0x8229, 0xC578, 0x822A, 0xBABD,\r\n\t0x822B, 0xF4B3, 0x822C, 0xB0E3, 0x822D, 0xF4B0, 0x822E, 0xC579,\t0x822F, 0xF4B1, 0x8230, 0xBDA2, 0x8231, 0xB2D5, 0x8232, 0xC57A,\r\n\t0x8233, 0xF4B6, 0x8234, 0xF4B7, 0x8235, 0xB6E6, 0x8236, 0xB2B0,\t0x8237, 0xCFCF, 0x8238, 0xF4B4, 0x8239, 0xB4AC, 0x823A, 0xC57B,\r\n\t0x823B, 0xF4B5, 0x823C, 0xC57C, 0x823D, 0xC57D, 0x823E, 0xF4B8,\t0x823F, 0xC57E, 0x8240, 0xC580, 0x8241, 0xC581, 0x8242, 0xC582,\r\n\t0x8243, 0xC583, 0x8244, 0xF4B9, 0x8245, 0xC584, 0x8246, 0xC585,\t0x8247, 0xCDA7, 0x8248, 0xC586, 0x8249, 0xF4BA, 0x824A, 0xC587,\r\n\t0x824B, 0xF4BB, 0x824C, 0xC588, 0x824D, 0xC589, 0x824E, 0xC58A,\t0x824F, 0xF4BC, 0x8250, 0xC58B, 0x8251, 0xC58C, 0x8252, 0xC58D,\r\n\t0x8253, 0xC58E, 0x8254, 0xC58F, 0x8255, 0xC590, 0x8256, 0xC591,\t0x8257, 0xC592, 0x8258, 0xCBD2, 0x8259, 0xC593, 0x825A, 0xF4BD,\r\n\t0x825B, 0xC594, 0x825C, 0xC595, 0x825D, 0xC596, 0x825E, 0xC597,\t0x825F, 0xF4BE, 0x8260, 0xC598, 0x8261, 0xC599, 0x8262, 0xC59A,\r\n\t0x8263, 0xC59B, 0x8264, 0xC59C, 0x8265, 0xC59D, 0x8266, 0xC59E,\t0x8267, 0xC59F, 0x8268, 0xF4BF, 0x8269, 0xC5A0, 0x826A, 0xC640,\r\n\t0x826B, 0xC641, 0x826C, 0xC642, 0x826D, 0xC643, 0x826E, 0xF4DE,\t0x826F, 0xC1BC, 0x8270, 0xBCE8, 0x8271, 0xC644, 0x8272, 0xC9AB,\r\n\t0x8273, 0xD1DE, 0x8274, 0xE5F5, 0x8275, 0xC645, 0x8276, 0xC646,\t0x8277, 0xC647, 0x8278, 0xC648, 0x8279, 0xDCB3, 0x827A, 0xD2D5,\r\n\t0x827B, 0xC649, 0x827C, 0xC64A, 0x827D, 0xDCB4, 0x827E, 0xB0AC,\t0x827F, 0xDCB5, 0x8280, 0xC64B, 0x8281, 0xC64C, 0x8282, 0xBDDA,\r\n\t0x8283, 0xC64D, 0x8284, 0xDCB9, 0x8285, 0xC64E, 0x8286, 0xC64F,\t0x8287, 0xC650, 0x8288, 0xD8C2, 0x8289, 0xC651, 0x828A, 0xDCB7,\r\n\t0x828B, 0xD3F3, 0x828C, 0xC652, 0x828D, 0xC9D6, 0x828E, 0xDCBA,\t0x828F, 0xDCB6, 0x8290, 0xC653, 0x8291, 0xDCBB, 0x8292, 0xC3A2,\r\n\t0x8293, 0xC654, 0x8294, 0xC655, 0x8295, 0xC656, 0x8296, 0xC657,\t0x8297, 0xDCBC, 0x8298, 0xDCC5, 0x8299, 0xDCBD, 0x829A, 0xC658,\r\n\t0x829B, 0xC659, 0x829C, 0xCEDF, 0x829D, 0xD6A5, 0x829E, 0xC65A,\t0x829F, 0xDCCF, 0x82A0, 0xC65B, 0x82A1, 0xDCCD, 0x82A2, 0xC65C,\r\n\t0x82A3, 0xC65D, 0x82A4, 0xDCD2, 0x82A5, 0xBDE6, 0x82A6, 0xC2AB,\t0x82A7, 0xC65E, 0x82A8, 0xDCB8, 0x82A9, 0xDCCB, 0x82AA, 0xDCCE,\r\n\t0x82AB, 0xDCBE, 0x82AC, 0xB7D2, 0x82AD, 0xB0C5, 0x82AE, 0xDCC7,\t0x82AF, 0xD0BE, 0x82B0, 0xDCC1, 0x82B1, 0xBBA8, 0x82B2, 0xC65F,\r\n\t0x82B3, 0xB7BC, 0x82B4, 0xDCCC, 0x82B5, 0xC660, 0x82B6, 0xC661,\t0x82B7, 0xDCC6, 0x82B8, 0xDCBF, 0x82B9, 0xC7DB, 0x82BA, 0xC662,\r\n\t0x82BB, 0xC663, 0x82BC, 0xC664, 0x82BD, 0xD1BF, 0x82BE, 0xDCC0,\t0x82BF, 0xC665, 0x82C0, 0xC666, 0x82C1, 0xDCCA, 0x82C2, 0xC667,\r\n\t0x82C3, 0xC668, 0x82C4, 0xDCD0, 0x82C5, 0xC669, 0x82C6, 0xC66A,\t0x82C7, 0xCEAD, 0x82C8, 0xDCC2, 0x82C9, 0xC66B, 0x82CA, 0xDCC3,\r\n\t0x82CB, 0xDCC8, 0x82CC, 0xDCC9, 0x82CD, 0xB2D4, 0x82CE, 0xDCD1,\t0x82CF, 0xCBD5, 0x82D0, 0xC66C, 0x82D1, 0xD4B7, 0x82D2, 0xDCDB,\r\n\t0x82D3, 0xDCDF, 0x82D4, 0xCCA6, 0x82D5, 0xDCE6, 0x82D6, 0xC66D,\t0x82D7, 0xC3E7, 0x82D8, 0xDCDC, 0x82D9, 0xC66E, 0x82DA, 0xC66F,\r\n\t0x82DB, 0xBFC1, 0x82DC, 0xDCD9, 0x82DD, 0xC670, 0x82DE, 0xB0FA,\t0x82DF, 0xB9B6, 0x82E0, 0xDCE5, 0x82E1, 0xDCD3, 0x82E2, 0xC671,\r\n\t0x82E3, 0xDCC4, 0x82E4, 0xDCD6, 0x82E5, 0xC8F4, 0x82E6, 0xBFE0,\t0x82E7, 0xC672, 0x82E8, 0xC673, 0x82E9, 0xC674, 0x82EA, 0xC675,\r\n\t0x82EB, 0xC9BB, 0x82EC, 0xC676, 0x82ED, 0xC677, 0x82EE, 0xC678,\t0x82EF, 0xB1BD, 0x82F0, 0xC679, 0x82F1, 0xD3A2, 0x82F2, 0xC67A,\r\n\t0x82F3, 0xC67B, 0x82F4, 0xDCDA, 0x82F5, 0xC67C, 0x82F6, 0xC67D,\t0x82F7, 0xDCD5, 0x82F8, 0xC67E, 0x82F9, 0xC6BB, 0x82FA, 0xC680,\r\n\t0x82FB, 0xDCDE, 0x82FC, 0xC681, 0x82FD, 0xC682, 0x82FE, 0xC683,\t0x82FF, 0xC684, 0x8300, 0xC685, 0x8301, 0xD7C2, 0x8302, 0xC3AF,\r\n\t0x8303, 0xB7B6, 0x8304, 0xC7D1, 0x8305, 0xC3A9, 0x8306, 0xDCE2,\t0x8307, 0xDCD8, 0x8308, 0xDCEB, 0x8309, 0xDCD4, 0x830A, 0xC686,\r\n\t0x830B, 0xC687, 0x830C, 0xDCDD, 0x830D, 0xC688, 0x830E, 0xBEA5,\t0x830F, 0xDCD7, 0x8310, 0xC689, 0x8311, 0xDCE0, 0x8312, 0xC68A,\r\n\t0x8313, 0xC68B, 0x8314, 0xDCE3, 0x8315, 0xDCE4, 0x8316, 0xC68C,\t0x8317, 0xDCF8, 0x8318, 0xC68D, 0x8319, 0xC68E, 0x831A, 0xDCE1,\r\n\t0x831B, 0xDDA2, 0x831C, 0xDCE7, 0x831D, 0xC68F, 0x831E, 0xC690,\t0x831F, 0xC691, 0x8320, 0xC692, 0x8321, 0xC693, 0x8322, 0xC694,\r\n\t0x8323, 0xC695, 0x8324, 0xC696, 0x8325, 0xC697, 0x8326, 0xC698,\t0x8327, 0xBCEB, 0x8328, 0xB4C4, 0x8329, 0xC699, 0x832A, 0xC69A,\r\n\t0x832B, 0xC3A3, 0x832C, 0xB2E7, 0x832D, 0xDCFA, 0x832E, 0xC69B,\t0x832F, 0xDCF2, 0x8330, 0xC69C, 0x8331, 0xDCEF, 0x8332, 0xC69D,\r\n\t0x8333, 0xDCFC, 0x8334, 0xDCEE, 0x8335, 0xD2F0, 0x8336, 0xB2E8,\t0x8337, 0xC69E, 0x8338, 0xC8D7, 0x8339, 0xC8E3, 0x833A, 0xDCFB,\r\n\t0x833B, 0xC69F, 0x833C, 0xDCED, 0x833D, 0xC6A0, 0x833E, 0xC740,\t0x833F, 0xC741, 0x8340, 0xDCF7, 0x8341, 0xC742, 0x8342, 0xC743,\r\n\t0x8343, 0xDCF5, 0x8344, 0xC744, 0x8345, 0xC745, 0x8346, 0xBEA3,\t0x8347, 0xDCF4, 0x8348, 0xC746, 0x8349, 0xB2DD, 0x834A, 0xC747,\r\n\t0x834B, 0xC748, 0x834C, 0xC749, 0x834D, 0xC74A, 0x834E, 0xC74B,\t0x834F, 0xDCF3, 0x8350, 0xBCF6, 0x8351, 0xDCE8, 0x8352, 0xBBC4,\r\n\t0x8353, 0xC74C, 0x8354, 0xC0F3, 0x8355, 0xC74D, 0x8356, 0xC74E,\t0x8357, 0xC74F, 0x8358, 0xC750, 0x8359, 0xC751, 0x835A, 0xBCD4,\r\n\t0x835B, 0xDCE9, 0x835C, 0xDCEA, 0x835D, 0xC752, 0x835E, 0xDCF1,\t0x835F, 0xDCF6, 0x8360, 0xDCF9, 0x8361, 0xB5B4, 0x8362, 0xC753,\r\n\t0x8363, 0xC8D9, 0x8364, 0xBBE7, 0x8365, 0xDCFE, 0x8366, 0xDCFD,\t0x8367, 0xD3AB, 0x8368, 0xDDA1, 0x8369, 0xDDA3, 0x836A, 0xDDA5,\r\n\t0x836B, 0xD2F1, 0x836C, 0xDDA4, 0x836D, 0xDDA6, 0x836E, 0xDDA7,\t0x836F, 0xD2A9, 0x8370, 0xC754, 0x8371, 0xC755, 0x8372, 0xC756,\r\n\t0x8373, 0xC757, 0x8374, 0xC758, 0x8375, 0xC759, 0x8376, 0xC75A,\t0x8377, 0xBAC9, 0x8378, 0xDDA9, 0x8379, 0xC75B, 0x837A, 0xC75C,\r\n\t0x837B, 0xDDB6, 0x837C, 0xDDB1, 0x837D, 0xDDB4, 0x837E, 0xC75D,\t0x837F, 0xC75E, 0x8380, 0xC75F, 0x8381, 0xC760, 0x8382, 0xC761,\r\n\t0x8383, 0xC762, 0x8384, 0xC763, 0x8385, 0xDDB0, 0x8386, 0xC6CE,\t0x8387, 0xC764, 0x8388, 0xC765, 0x8389, 0xC0F2, 0x838A, 0xC766,\r\n\t0x838B, 0xC767, 0x838C, 0xC768, 0x838D, 0xC769, 0x838E, 0xC9AF,\t0x838F, 0xC76A, 0x8390, 0xC76B, 0x8391, 0xC76C, 0x8392, 0xDCEC,\r\n\t0x8393, 0xDDAE, 0x8394, 0xC76D, 0x8395, 0xC76E, 0x8396, 0xC76F,\t0x8397, 0xC770, 0x8398, 0xDDB7, 0x8399, 0xC771, 0x839A, 0xC772,\r\n\t0x839B, 0xDCF0, 0x839C, 0xDDAF, 0x839D, 0xC773, 0x839E, 0xDDB8,\t0x839F, 0xC774, 0x83A0, 0xDDAC, 0x83A1, 0xC775, 0x83A2, 0xC776,\r\n\t0x83A3, 0xC777, 0x83A4, 0xC778, 0x83A5, 0xC779, 0x83A6, 0xC77A,\t0x83A7, 0xC77B, 0x83A8, 0xDDB9, 0x83A9, 0xDDB3, 0x83AA, 0xDDAD,\r\n\t0x83AB, 0xC4AA, 0x83AC, 0xC77C, 0x83AD, 0xC77D, 0x83AE, 0xC77E,\t0x83AF, 0xC780, 0x83B0, 0xDDA8, 0x83B1, 0xC0B3, 0x83B2, 0xC1AB,\r\n\t0x83B3, 0xDDAA, 0x83B4, 0xDDAB, 0x83B5, 0xC781, 0x83B6, 0xDDB2,\t0x83B7, 0xBBF1, 0x83B8, 0xDDB5, 0x83B9, 0xD3A8, 0x83BA, 0xDDBA,\r\n\t0x83BB, 0xC782, 0x83BC, 0xDDBB, 0x83BD, 0xC3A7, 0x83BE, 0xC783,\t0x83BF, 0xC784, 0x83C0, 0xDDD2, 0x83C1, 0xDDBC, 0x83C2, 0xC785,\r\n\t0x83C3, 0xC786, 0x83C4, 0xC787, 0x83C5, 0xDDD1, 0x83C6, 0xC788,\t0x83C7, 0xB9BD, 0x83C8, 0xC789, 0x83C9, 0xC78A, 0x83CA, 0xBED5,\r\n\t0x83CB, 0xC78B, 0x83CC, 0xBEFA, 0x83CD, 0xC78C, 0x83CE, 0xC78D,\t0x83CF, 0xBACA, 0x83D0, 0xC78E, 0x83D1, 0xC78F, 0x83D2, 0xC790,\r\n\t0x83D3, 0xC791, 0x83D4, 0xDDCA, 0x83D5, 0xC792, 0x83D6, 0xDDC5,\t0x83D7, 0xC793, 0x83D8, 0xDDBF, 0x83D9, 0xC794, 0x83DA, 0xC795,\r\n\t0x83DB, 0xC796, 0x83DC, 0xB2CB, 0x83DD, 0xDDC3, 0x83DE, 0xC797,\t0x83DF, 0xDDCB, 0x83E0, 0xB2A4, 0x83E1, 0xDDD5, 0x83E2, 0xC798,\r\n\t0x83E3, 0xC799, 0x83E4, 0xC79A, 0x83E5, 0xDDBE, 0x83E6, 0xC79B,\t0x83E7, 0xC79C, 0x83E8, 0xC79D, 0x83E9, 0xC6D0, 0x83EA, 0xDDD0,\r\n\t0x83EB, 0xC79E, 0x83EC, 0xC79F, 0x83ED, 0xC7A0, 0x83EE, 0xC840,\t0x83EF, 0xC841, 0x83F0, 0xDDD4, 0x83F1, 0xC1E2, 0x83F2, 0xB7C6,\r\n\t0x83F3, 0xC842, 0x83F4, 0xC843, 0x83F5, 0xC844, 0x83F6, 0xC845,\t0x83F7, 0xC846, 0x83F8, 0xDDCE, 0x83F9, 0xDDCF, 0x83FA, 0xC847,\r\n\t0x83FB, 0xC848, 0x83FC, 0xC849, 0x83FD, 0xDDC4, 0x83FE, 0xC84A,\t0x83FF, 0xC84B, 0x8400, 0xC84C, 0x8401, 0xDDBD, 0x8402, 0xC84D,\r\n\t0x8403, 0xDDCD, 0x8404, 0xCCD1, 0x8405, 0xC84E, 0x8406, 0xDDC9,\t0x8407, 0xC84F, 0x8408, 0xC850, 0x8409, 0xC851, 0x840A, 0xC852,\r\n\t0x840B, 0xDDC2, 0x840C, 0xC3C8, 0x840D, 0xC6BC, 0x840E, 0xCEAE,\t0x840F, 0xDDCC, 0x8410, 0xC853, 0x8411, 0xDDC8, 0x8412, 0xC854,\r\n\t0x8413, 0xC855, 0x8414, 0xC856, 0x8415, 0xC857, 0x8416, 0xC858,\t0x8417, 0xC859, 0x8418, 0xDDC1, 0x8419, 0xC85A, 0x841A, 0xC85B,\r\n\t0x841B, 0xC85C, 0x841C, 0xDDC6, 0x841D, 0xC2DC, 0x841E, 0xC85D,\t0x841F, 0xC85E, 0x8420, 0xC85F, 0x8421, 0xC860, 0x8422, 0xC861,\r\n\t0x8423, 0xC862, 0x8424, 0xD3A9, 0x8425, 0xD3AA, 0x8426, 0xDDD3,\t0x8427, 0xCFF4, 0x8428, 0xC8F8, 0x8429, 0xC863, 0x842A, 0xC864,\r\n\t0x842B, 0xC865, 0x842C, 0xC866, 0x842D, 0xC867, 0x842E, 0xC868,\t0x842F, 0xC869, 0x8430, 0xC86A, 0x8431, 0xDDE6, 0x8432, 0xC86B,\r\n\t0x8433, 0xC86C, 0x8434, 0xC86D, 0x8435, 0xC86E, 0x8436, 0xC86F,\t0x8437, 0xC870, 0x8438, 0xDDC7, 0x8439, 0xC871, 0x843A, 0xC872,\r\n\t0x843B, 0xC873, 0x843C, 0xDDE0, 0x843D, 0xC2E4, 0x843E, 0xC874,\t0x843F, 0xC875, 0x8440, 0xC876, 0x8441, 0xC877, 0x8442, 0xC878,\r\n\t0x8443, 0xC879, 0x8444, 0xC87A, 0x8445, 0xC87B, 0x8446, 0xDDE1,\t0x8447, 0xC87C, 0x8448, 0xC87D, 0x8449, 0xC87E, 0x844A, 0xC880,\r\n\t0x844B, 0xC881, 0x844C, 0xC882, 0x844D, 0xC883, 0x844E, 0xC884,\t0x844F, 0xC885, 0x8450, 0xC886, 0x8451, 0xDDD7, 0x8452, 0xC887,\r\n\t0x8453, 0xC888, 0x8454, 0xC889, 0x8455, 0xC88A, 0x8456, 0xC88B,\t0x8457, 0xD6F8, 0x8458, 0xC88C, 0x8459, 0xDDD9, 0x845A, 0xDDD8,\r\n\t0x845B, 0xB8F0, 0x845C, 0xDDD6, 0x845D, 0xC88D, 0x845E, 0xC88E,\t0x845F, 0xC88F, 0x8460, 0xC890, 0x8461, 0xC6CF, 0x8462, 0xC891,\r\n\t0x8463, 0xB6AD, 0x8464, 0xC892, 0x8465, 0xC893, 0x8466, 0xC894,\t0x8467, 0xC895, 0x8468, 0xC896, 0x8469, 0xDDE2, 0x846A, 0xC897,\r\n\t0x846B, 0xBAF9, 0x846C, 0xD4E1, 0x846D, 0xDDE7, 0x846E, 0xC898,\t0x846F, 0xC899, 0x8470, 0xC89A, 0x8471, 0xB4D0, 0x8472, 0xC89B,\r\n\t0x8473, 0xDDDA, 0x8474, 0xC89C, 0x8475, 0xBFFB, 0x8476, 0xDDE3,\t0x8477, 0xC89D, 0x8478, 0xDDDF, 0x8479, 0xC89E, 0x847A, 0xDDDD,\r\n\t0x847B, 0xC89F, 0x847C, 0xC8A0, 0x847D, 0xC940, 0x847E, 0xC941,\t0x847F, 0xC942, 0x8480, 0xC943, 0x8481, 0xC944, 0x8482, 0xB5D9,\r\n\t0x8483, 0xC945, 0x8484, 0xC946, 0x8485, 0xC947, 0x8486, 0xC948,\t0x8487, 0xDDDB, 0x8488, 0xDDDC, 0x8489, 0xDDDE, 0x848A, 0xC949,\r\n\t0x848B, 0xBDAF, 0x848C, 0xDDE4, 0x848D, 0xC94A, 0x848E, 0xDDE5,\t0x848F, 0xC94B, 0x8490, 0xC94C, 0x8491, 0xC94D, 0x8492, 0xC94E,\r\n\t0x8493, 0xC94F, 0x8494, 0xC950, 0x8495, 0xC951, 0x8496, 0xC952,\t0x8497, 0xDDF5, 0x8498, 0xC953, 0x8499, 0xC3C9, 0x849A, 0xC954,\r\n\t0x849B, 0xC955, 0x849C, 0xCBE2, 0x849D, 0xC956, 0x849E, 0xC957,\t0x849F, 0xC958, 0x84A0, 0xC959, 0x84A1, 0xDDF2, 0x84A2, 0xC95A,\r\n\t0x84A3, 0xC95B, 0x84A4, 0xC95C, 0x84A5, 0xC95D, 0x84A6, 0xC95E,\t0x84A7, 0xC95F, 0x84A8, 0xC960, 0x84A9, 0xC961, 0x84AA, 0xC962,\r\n\t0x84AB, 0xC963, 0x84AC, 0xC964, 0x84AD, 0xC965, 0x84AE, 0xC966,\t0x84AF, 0xD8E1, 0x84B0, 0xC967, 0x84B1, 0xC968, 0x84B2, 0xC6D1,\r\n\t0x84B3, 0xC969, 0x84B4, 0xDDF4, 0x84B5, 0xC96A, 0x84B6, 0xC96B,\t0x84B7, 0xC96C, 0x84B8, 0xD5F4, 0x84B9, 0xDDF3, 0x84BA, 0xDDF0,\r\n\t0x84BB, 0xC96D, 0x84BC, 0xC96E, 0x84BD, 0xDDEC, 0x84BE, 0xC96F,\t0x84BF, 0xDDEF, 0x84C0, 0xC970, 0x84C1, 0xDDE8, 0x84C2, 0xC971,\r\n\t0x84C3, 0xC972, 0x84C4, 0xD0EE, 0x84C5, 0xC973, 0x84C6, 0xC974,\t0x84C7, 0xC975, 0x84C8, 0xC976, 0x84C9, 0xC8D8, 0x84CA, 0xDDEE,\r\n\t0x84CB, 0xC977, 0x84CC, 0xC978, 0x84CD, 0xDDE9, 0x84CE, 0xC979,\t0x84CF, 0xC97A, 0x84D0, 0xDDEA, 0x84D1, 0xCBF2, 0x84D2, 0xC97B,\r\n\t0x84D3, 0xDDED, 0x84D4, 0xC97C, 0x84D5, 0xC97D, 0x84D6, 0xB1CD,\t0x84D7, 0xC97E, 0x84D8, 0xC980, 0x84D9, 0xC981, 0x84DA, 0xC982,\r\n\t0x84DB, 0xC983, 0x84DC, 0xC984, 0x84DD, 0xC0B6, 0x84DE, 0xC985,\t0x84DF, 0xBCBB, 0x84E0, 0xDDF1, 0x84E1, 0xC986, 0x84E2, 0xC987,\r\n\t0x84E3, 0xDDF7, 0x84E4, 0xC988, 0x84E5, 0xDDF6, 0x84E6, 0xDDEB,\t0x84E7, 0xC989, 0x84E8, 0xC98A, 0x84E9, 0xC98B, 0x84EA, 0xC98C,\r\n\t0x84EB, 0xC98D, 0x84EC, 0xC5EE, 0x84ED, 0xC98E, 0x84EE, 0xC98F,\t0x84EF, 0xC990, 0x84F0, 0xDDFB, 0x84F1, 0xC991, 0x84F2, 0xC992,\r\n\t0x84F3, 0xC993, 0x84F4, 0xC994, 0x84F5, 0xC995, 0x84F6, 0xC996,\t0x84F7, 0xC997, 0x84F8, 0xC998, 0x84F9, 0xC999, 0x84FA, 0xC99A,\r\n\t0x84FB, 0xC99B, 0x84FC, 0xDEA4, 0x84FD, 0xC99C, 0x84FE, 0xC99D,\t0x84FF, 0xDEA3, 0x8500, 0xC99E, 0x8501, 0xC99F, 0x8502, 0xC9A0,\r\n\t0x8503, 0xCA40, 0x8504, 0xCA41, 0x8505, 0xCA42, 0x8506, 0xCA43,\t0x8507, 0xCA44, 0x8508, 0xCA45, 0x8509, 0xCA46, 0x850A, 0xCA47,\r\n\t0x850B, 0xCA48, 0x850C, 0xDDF8, 0x850D, 0xCA49, 0x850E, 0xCA4A,\t0x850F, 0xCA4B, 0x8510, 0xCA4C, 0x8511, 0xC3EF, 0x8512, 0xCA4D,\r\n\t0x8513, 0xC2FB, 0x8514, 0xCA4E, 0x8515, 0xCA4F, 0x8516, 0xCA50,\t0x8517, 0xD5E1, 0x8518, 0xCA51, 0x8519, 0xCA52, 0x851A, 0xCEB5,\r\n\t0x851B, 0xCA53, 0x851C, 0xCA54, 0x851D, 0xCA55, 0x851E, 0xCA56,\t0x851F, 0xDDFD, 0x8520, 0xCA57, 0x8521, 0xB2CC, 0x8522, 0xCA58,\r\n\t0x8523, 0xCA59, 0x8524, 0xCA5A, 0x8525, 0xCA5B, 0x8526, 0xCA5C,\t0x8527, 0xCA5D, 0x8528, 0xCA5E, 0x8529, 0xCA5F, 0x852A, 0xCA60,\r\n\t0x852B, 0xC4E8, 0x852C, 0xCADF, 0x852D, 0xCA61, 0x852E, 0xCA62,\t0x852F, 0xCA63, 0x8530, 0xCA64, 0x8531, 0xCA65, 0x8532, 0xCA66,\r\n\t0x8533, 0xCA67, 0x8534, 0xCA68, 0x8535, 0xCA69, 0x8536, 0xCA6A,\t0x8537, 0xC7BE, 0x8538, 0xDDFA, 0x8539, 0xDDFC, 0x853A, 0xDDFE,\r\n\t0x853B, 0xDEA2, 0x853C, 0xB0AA, 0x853D, 0xB1CE, 0x853E, 0xCA6B,\t0x853F, 0xCA6C, 0x8540, 0xCA6D, 0x8541, 0xCA6E, 0x8542, 0xCA6F,\r\n\t0x8543, 0xDEAC, 0x8544, 0xCA70, 0x8545, 0xCA71, 0x8546, 0xCA72,\t0x8547, 0xCA73, 0x8548, 0xDEA6, 0x8549, 0xBDB6, 0x854A, 0xC8EF,\r\n\t0x854B, 0xCA74, 0x854C, 0xCA75, 0x854D, 0xCA76, 0x854E, 0xCA77,\t0x854F, 0xCA78, 0x8550, 0xCA79, 0x8551, 0xCA7A, 0x8552, 0xCA7B,\r\n\t0x8553, 0xCA7C, 0x8554, 0xCA7D, 0x8555, 0xCA7E, 0x8556, 0xDEA1,\t0x8557, 0xCA80, 0x8558, 0xCA81, 0x8559, 0xDEA5, 0x855A, 0xCA82,\r\n\t0x855B, 0xCA83, 0x855C, 0xCA84, 0x855D, 0xCA85, 0x855E, 0xDEA9,\t0x855F, 0xCA86, 0x8560, 0xCA87, 0x8561, 0xCA88, 0x8562, 0xCA89,\r\n\t0x8563, 0xCA8A, 0x8564, 0xDEA8, 0x8565, 0xCA8B, 0x8566, 0xCA8C,\t0x8567, 0xCA8D, 0x8568, 0xDEA7, 0x8569, 0xCA8E, 0x856A, 0xCA8F,\r\n\t0x856B, 0xCA90, 0x856C, 0xCA91, 0x856D, 0xCA92, 0x856E, 0xCA93,\t0x856F, 0xCA94, 0x8570, 0xCA95, 0x8571, 0xCA96, 0x8572, 0xDEAD,\r\n\t0x8573, 0xCA97, 0x8574, 0xD4CC, 0x8575, 0xCA98, 0x8576, 0xCA99,\t0x8577, 0xCA9A, 0x8578, 0xCA9B, 0x8579, 0xDEB3, 0x857A, 0xDEAA,\r\n\t0x857B, 0xDEAE, 0x857C, 0xCA9C, 0x857D, 0xCA9D, 0x857E, 0xC0D9,\t0x857F, 0xCA9E, 0x8580, 0xCA9F, 0x8581, 0xCAA0, 0x8582, 0xCB40,\r\n\t0x8583, 0xCB41, 0x8584, 0xB1A1, 0x8585, 0xDEB6, 0x8586, 0xCB42,\t0x8587, 0xDEB1, 0x8588, 0xCB43, 0x8589, 0xCB44, 0x858A, 0xCB45,\r\n\t0x858B, 0xCB46, 0x858C, 0xCB47, 0x858D, 0xCB48, 0x858E, 0xCB49,\t0x858F, 0xDEB2, 0x8590, 0xCB4A, 0x8591, 0xCB4B, 0x8592, 0xCB4C,\r\n\t0x8593, 0xCB4D, 0x8594, 0xCB4E, 0x8595, 0xCB4F, 0x8596, 0xCB50,\t0x8597, 0xCB51, 0x8598, 0xCB52, 0x8599, 0xCB53, 0x859A, 0xCB54,\r\n\t0x859B, 0xD1A6, 0x859C, 0xDEB5, 0x859D, 0xCB55, 0x859E, 0xCB56,\t0x859F, 0xCB57, 0x85A0, 0xCB58, 0x85A1, 0xCB59, 0x85A2, 0xCB5A,\r\n\t0x85A3, 0xCB5B, 0x85A4, 0xDEAF, 0x85A5, 0xCB5C, 0x85A6, 0xCB5D,\t0x85A7, 0xCB5E, 0x85A8, 0xDEB0, 0x85A9, 0xCB5F, 0x85AA, 0xD0BD,\r\n\t0x85AB, 0xCB60, 0x85AC, 0xCB61, 0x85AD, 0xCB62, 0x85AE, 0xDEB4,\t0x85AF, 0xCAED, 0x85B0, 0xDEB9, 0x85B1, 0xCB63, 0x85B2, 0xCB64,\r\n\t0x85B3, 0xCB65, 0x85B4, 0xCB66, 0x85B5, 0xCB67, 0x85B6, 0xCB68,\t0x85B7, 0xDEB8, 0x85B8, 0xCB69, 0x85B9, 0xDEB7, 0x85BA, 0xCB6A,\r\n\t0x85BB, 0xCB6B, 0x85BC, 0xCB6C, 0x85BD, 0xCB6D, 0x85BE, 0xCB6E,\t0x85BF, 0xCB6F, 0x85C0, 0xCB70, 0x85C1, 0xDEBB, 0x85C2, 0xCB71,\r\n\t0x85C3, 0xCB72, 0x85C4, 0xCB73, 0x85C5, 0xCB74, 0x85C6, 0xCB75,\t0x85C7, 0xCB76, 0x85C8, 0xCB77, 0x85C9, 0xBDE5, 0x85CA, 0xCB78,\r\n\t0x85CB, 0xCB79, 0x85CC, 0xCB7A, 0x85CD, 0xCB7B, 0x85CE, 0xCB7C,\t0x85CF, 0xB2D8, 0x85D0, 0xC3EA, 0x85D1, 0xCB7D, 0x85D2, 0xCB7E,\r\n\t0x85D3, 0xDEBA, 0x85D4, 0xCB80, 0x85D5, 0xC5BA, 0x85D6, 0xCB81,\t0x85D7, 0xCB82, 0x85D8, 0xCB83, 0x85D9, 0xCB84, 0x85DA, 0xCB85,\r\n\t0x85DB, 0xCB86, 0x85DC, 0xDEBC, 0x85DD, 0xCB87, 0x85DE, 0xCB88,\t0x85DF, 0xCB89, 0x85E0, 0xCB8A, 0x85E1, 0xCB8B, 0x85E2, 0xCB8C,\r\n\t0x85E3, 0xCB8D, 0x85E4, 0xCCD9, 0x85E5, 0xCB8E, 0x85E6, 0xCB8F,\t0x85E7, 0xCB90, 0x85E8, 0xCB91, 0x85E9, 0xB7AA, 0x85EA, 0xCB92,\r\n\t0x85EB, 0xCB93, 0x85EC, 0xCB94, 0x85ED, 0xCB95, 0x85EE, 0xCB96,\t0x85EF, 0xCB97, 0x85F0, 0xCB98, 0x85F1, 0xCB99, 0x85F2, 0xCB9A,\r\n\t0x85F3, 0xCB9B, 0x85F4, 0xCB9C, 0x85F5, 0xCB9D, 0x85F6, 0xCB9E,\t0x85F7, 0xCB9F, 0x85F8, 0xCBA0, 0x85F9, 0xCC40, 0x85FA, 0xCC41,\r\n\t0x85FB, 0xD4E5, 0x85FC, 0xCC42, 0x85FD, 0xCC43, 0x85FE, 0xCC44,\t0x85FF, 0xDEBD, 0x8600, 0xCC45, 0x8601, 0xCC46, 0x8602, 0xCC47,\r\n\t0x8603, 0xCC48, 0x8604, 0xCC49, 0x8605, 0xDEBF, 0x8606, 0xCC4A,\t0x8607, 0xCC4B, 0x8608, 0xCC4C, 0x8609, 0xCC4D, 0x860A, 0xCC4E,\r\n\t0x860B, 0xCC4F, 0x860C, 0xCC50, 0x860D, 0xCC51, 0x860E, 0xCC52,\t0x860F, 0xCC53, 0x8610, 0xCC54, 0x8611, 0xC4A2, 0x8612, 0xCC55,\r\n\t0x8613, 0xCC56, 0x8614, 0xCC57, 0x8615, 0xCC58, 0x8616, 0xDEC1,\t0x8617, 0xCC59, 0x8618, 0xCC5A, 0x8619, 0xCC5B, 0x861A, 0xCC5C,\r\n\t0x861B, 0xCC5D, 0x861C, 0xCC5E, 0x861D, 0xCC5F, 0x861E, 0xCC60,\t0x861F, 0xCC61, 0x8620, 0xCC62, 0x8621, 0xCC63, 0x8622, 0xCC64,\r\n\t0x8623, 0xCC65, 0x8624, 0xCC66, 0x8625, 0xCC67, 0x8626, 0xCC68,\t0x8627, 0xDEBE, 0x8628, 0xCC69, 0x8629, 0xDEC0, 0x862A, 0xCC6A,\r\n\t0x862B, 0xCC6B, 0x862C, 0xCC6C, 0x862D, 0xCC6D, 0x862E, 0xCC6E,\t0x862F, 0xCC6F, 0x8630, 0xCC70, 0x8631, 0xCC71, 0x8632, 0xCC72,\r\n\t0x8633, 0xCC73, 0x8634, 0xCC74, 0x8635, 0xCC75, 0x8636, 0xCC76,\t0x8637, 0xCC77, 0x8638, 0xD5BA, 0x8639, 0xCC78, 0x863A, 0xCC79,\r\n\t0x863B, 0xCC7A, 0x863C, 0xDEC2, 0x863D, 0xCC7B, 0x863E, 0xCC7C,\t0x863F, 0xCC7D, 0x8640, 0xCC7E, 0x8641, 0xCC80, 0x8642, 0xCC81,\r\n\t0x8643, 0xCC82, 0x8644, 0xCC83, 0x8645, 0xCC84, 0x8646, 0xCC85,\t0x8647, 0xCC86, 0x8648, 0xCC87, 0x8649, 0xCC88, 0x864A, 0xCC89,\r\n\t0x864B, 0xCC8A, 0x864C, 0xCC8B, 0x864D, 0xF2AE, 0x864E, 0xBBA2,\t0x864F, 0xC2B2, 0x8650, 0xC5B0, 0x8651, 0xC2C7, 0x8652, 0xCC8C,\r\n\t0x8653, 0xCC8D, 0x8654, 0xF2AF, 0x8655, 0xCC8E, 0x8656, 0xCC8F,\t0x8657, 0xCC90, 0x8658, 0xCC91, 0x8659, 0xCC92, 0x865A, 0xD0E9,\r\n\t0x865B, 0xCC93, 0x865C, 0xCC94, 0x865D, 0xCC95, 0x865E, 0xD3DD,\t0x865F, 0xCC96, 0x8660, 0xCC97, 0x8661, 0xCC98, 0x8662, 0xEBBD,\r\n\t0x8663, 0xCC99, 0x8664, 0xCC9A, 0x8665, 0xCC9B, 0x8666, 0xCC9C,\t0x8667, 0xCC9D, 0x8668, 0xCC9E, 0x8669, 0xCC9F, 0x866A, 0xCCA0,\r\n\t0x866B, 0xB3E6, 0x866C, 0xF2B0, 0x866D, 0xCD40, 0x866E, 0xF2B1,\t0x866F, 0xCD41, 0x8670, 0xCD42, 0x8671, 0xCAAD, 0x8672, 0xCD43,\r\n\t0x8673, 0xCD44, 0x8674, 0xCD45, 0x8675, 0xCD46, 0x8676, 0xCD47,\t0x8677, 0xCD48, 0x8678, 0xCD49, 0x8679, 0xBAE7, 0x867A, 0xF2B3,\r\n\t0x867B, 0xF2B5, 0x867C, 0xF2B4, 0x867D, 0xCBE4, 0x867E, 0xCFBA,\t0x867F, 0xF2B2, 0x8680, 0xCAB4, 0x8681, 0xD2CF, 0x8682, 0xC2EC,\r\n\t0x8683, 0xCD4A, 0x8684, 0xCD4B, 0x8685, 0xCD4C, 0x8686, 0xCD4D,\t0x8687, 0xCD4E, 0x8688, 0xCD4F, 0x8689, 0xCD50, 0x868A, 0xCEC3,\r\n\t0x868B, 0xF2B8, 0x868C, 0xB0F6, 0x868D, 0xF2B7, 0x868E, 0xCD51,\t0x868F, 0xCD52, 0x8690, 0xCD53, 0x8691, 0xCD54, 0x8692, 0xCD55,\r\n\t0x8693, 0xF2BE, 0x8694, 0xCD56, 0x8695, 0xB2CF, 0x8696, 0xCD57,\t0x8697, 0xCD58, 0x8698, 0xCD59, 0x8699, 0xCD5A, 0x869A, 0xCD5B,\r\n\t0x869B, 0xCD5C, 0x869C, 0xD1C1, 0x869D, 0xF2BA, 0x869E, 0xCD5D,\t0x869F, 0xCD5E, 0x86A0, 0xCD5F, 0x86A1, 0xCD60, 0x86A2, 0xCD61,\r\n\t0x86A3, 0xF2BC, 0x86A4, 0xD4E9, 0x86A5, 0xCD62, 0x86A6, 0xCD63,\t0x86A7, 0xF2BB, 0x86A8, 0xF2B6, 0x86A9, 0xF2BF, 0x86AA, 0xF2BD,\r\n\t0x86AB, 0xCD64, 0x86AC, 0xF2B9, 0x86AD, 0xCD65, 0x86AE, 0xCD66,\t0x86AF, 0xF2C7, 0x86B0, 0xF2C4, 0x86B1, 0xF2C6, 0x86B2, 0xCD67,\r\n\t0x86B3, 0xCD68, 0x86B4, 0xF2CA, 0x86B5, 0xF2C2, 0x86B6, 0xF2C0,\t0x86B7, 0xCD69, 0x86B8, 0xCD6A, 0x86B9, 0xCD6B, 0x86BA, 0xF2C5,\r\n\t0x86BB, 0xCD6C, 0x86BC, 0xCD6D, 0x86BD, 0xCD6E, 0x86BE, 0xCD6F,\t0x86BF, 0xCD70, 0x86C0, 0xD6FB, 0x86C1, 0xCD71, 0x86C2, 0xCD72,\r\n\t0x86C3, 0xCD73, 0x86C4, 0xF2C1, 0x86C5, 0xCD74, 0x86C6, 0xC7F9,\t0x86C7, 0xC9DF, 0x86C8, 0xCD75, 0x86C9, 0xF2C8, 0x86CA, 0xB9C6,\r\n\t0x86CB, 0xB5B0, 0x86CC, 0xCD76, 0x86CD, 0xCD77, 0x86CE, 0xF2C3,\t0x86CF, 0xF2C9, 0x86D0, 0xF2D0, 0x86D1, 0xF2D6, 0x86D2, 0xCD78,\r\n\t0x86D3, 0xCD79, 0x86D4, 0xBBD7, 0x86D5, 0xCD7A, 0x86D6, 0xCD7B,\t0x86D7, 0xCD7C, 0x86D8, 0xF2D5, 0x86D9, 0xCDDC, 0x86DA, 0xCD7D,\r\n\t0x86DB, 0xD6EB, 0x86DC, 0xCD7E, 0x86DD, 0xCD80, 0x86DE, 0xF2D2,\t0x86DF, 0xF2D4, 0x86E0, 0xCD81, 0x86E1, 0xCD82, 0x86E2, 0xCD83,\r\n\t0x86E3, 0xCD84, 0x86E4, 0xB8F2, 0x86E5, 0xCD85, 0x86E6, 0xCD86,\t0x86E7, 0xCD87, 0x86E8, 0xCD88, 0x86E9, 0xF2CB, 0x86EA, 0xCD89,\r\n\t0x86EB, 0xCD8A, 0x86EC, 0xCD8B, 0x86ED, 0xF2CE, 0x86EE, 0xC2F9,\t0x86EF, 0xCD8C, 0x86F0, 0xD5DD, 0x86F1, 0xF2CC, 0x86F2, 0xF2CD,\r\n\t0x86F3, 0xF2CF, 0x86F4, 0xF2D3, 0x86F5, 0xCD8D, 0x86F6, 0xCD8E,\t0x86F7, 0xCD8F, 0x86F8, 0xF2D9, 0x86F9, 0xD3BC, 0x86FA, 0xCD90,\r\n\t0x86FB, 0xCD91, 0x86FC, 0xCD92, 0x86FD, 0xCD93, 0x86FE, 0xB6EA,\t0x86FF, 0xCD94, 0x8700, 0xCAF1, 0x8701, 0xCD95, 0x8702, 0xB7E4,\r\n\t0x8703, 0xF2D7, 0x8704, 0xCD96, 0x8705, 0xCD97, 0x8706, 0xCD98,\t0x8707, 0xF2D8, 0x8708, 0xF2DA, 0x8709, 0xF2DD, 0x870A, 0xF2DB,\r\n\t0x870B, 0xCD99, 0x870C, 0xCD9A, 0x870D, 0xF2DC, 0x870E, 0xCD9B,\t0x870F, 0xCD9C, 0x8710, 0xCD9D, 0x8711, 0xCD9E, 0x8712, 0xD1D1,\r\n\t0x8713, 0xF2D1, 0x8714, 0xCD9F, 0x8715, 0xCDC9, 0x8716, 0xCDA0,\t0x8717, 0xCECF, 0x8718, 0xD6A9, 0x8719, 0xCE40, 0x871A, 0xF2E3,\r\n\t0x871B, 0xCE41, 0x871C, 0xC3DB, 0x871D, 0xCE42, 0x871E, 0xF2E0,\t0x871F, 0xCE43, 0x8720, 0xCE44, 0x8721, 0xC0AF, 0x8722, 0xF2EC,\r\n\t0x8723, 0xF2DE, 0x8724, 0xCE45, 0x8725, 0xF2E1, 0x8726, 0xCE46,\t0x8727, 0xCE47, 0x8728, 0xCE48, 0x8729, 0xF2E8, 0x872A, 0xCE49,\r\n\t0x872B, 0xCE4A, 0x872C, 0xCE4B, 0x872D, 0xCE4C, 0x872E, 0xF2E2,\t0x872F, 0xCE4D, 0x8730, 0xCE4E, 0x8731, 0xF2E7, 0x8732, 0xCE4F,\r\n\t0x8733, 0xCE50, 0x8734, 0xF2E6, 0x8735, 0xCE51, 0x8736, 0xCE52,\t0x8737, 0xF2E9, 0x8738, 0xCE53, 0x8739, 0xCE54, 0x873A, 0xCE55,\r\n\t0x873B, 0xF2DF, 0x873C, 0xCE56, 0x873D, 0xCE57, 0x873E, 0xF2E4,\t0x873F, 0xF2EA, 0x8740, 0xCE58, 0x8741, 0xCE59, 0x8742, 0xCE5A,\r\n\t0x8743, 0xCE5B, 0x8744, 0xCE5C, 0x8745, 0xCE5D, 0x8746, 0xCE5E,\t0x8747, 0xD3AC, 0x8748, 0xF2E5, 0x8749, 0xB2F5, 0x874A, 0xCE5F,\r\n\t0x874B, 0xCE60, 0x874C, 0xF2F2, 0x874D, 0xCE61, 0x874E, 0xD0AB,\t0x874F, 0xCE62, 0x8750, 0xCE63, 0x8751, 0xCE64, 0x8752, 0xCE65,\r\n\t0x8753, 0xF2F5, 0x8754, 0xCE66, 0x8755, 0xCE67, 0x8756, 0xCE68,\t0x8757, 0xBBC8, 0x8758, 0xCE69, 0x8759, 0xF2F9, 0x875A, 0xCE6A,\r\n\t0x875B, 0xCE6B, 0x875C, 0xCE6C, 0x875D, 0xCE6D, 0x875E, 0xCE6E,\t0x875F, 0xCE6F, 0x8760, 0xF2F0, 0x8761, 0xCE70, 0x8762, 0xCE71,\r\n\t0x8763, 0xF2F6, 0x8764, 0xF2F8, 0x8765, 0xF2FA, 0x8766, 0xCE72,\t0x8767, 0xCE73, 0x8768, 0xCE74, 0x8769, 0xCE75, 0x876A, 0xCE76,\r\n\t0x876B, 0xCE77, 0x876C, 0xCE78, 0x876D, 0xCE79, 0x876E, 0xF2F3,\t0x876F, 0xCE7A, 0x8770, 0xF2F1, 0x8771, 0xCE7B, 0x8772, 0xCE7C,\r\n\t0x8773, 0xCE7D, 0x8774, 0xBAFB, 0x8775, 0xCE7E, 0x8776, 0xB5FB,\t0x8777, 0xCE80, 0x8778, 0xCE81, 0x8779, 0xCE82, 0x877A, 0xCE83,\r\n\t0x877B, 0xF2EF, 0x877C, 0xF2F7, 0x877D, 0xF2ED, 0x877E, 0xF2EE,\t0x877F, 0xCE84, 0x8780, 0xCE85, 0x8781, 0xCE86, 0x8782, 0xF2EB,\r\n\t0x8783, 0xF3A6, 0x8784, 0xCE87, 0x8785, 0xF3A3, 0x8786, 0xCE88,\t0x8787, 0xCE89, 0x8788, 0xF3A2, 0x8789, 0xCE8A, 0x878A, 0xCE8B,\r\n\t0x878B, 0xF2F4, 0x878C, 0xCE8C, 0x878D, 0xC8DA, 0x878E, 0xCE8D,\t0x878F, 0xCE8E, 0x8790, 0xCE8F, 0x8791, 0xCE90, 0x8792, 0xCE91,\r\n\t0x8793, 0xF2FB, 0x8794, 0xCE92, 0x8795, 0xCE93, 0x8796, 0xCE94,\t0x8797, 0xF3A5, 0x8798, 0xCE95, 0x8799, 0xCE96, 0x879A, 0xCE97,\r\n\t0x879B, 0xCE98, 0x879C, 0xCE99, 0x879D, 0xCE9A, 0x879E, 0xCE9B,\t0x879F, 0xC3F8, 0x87A0, 0xCE9C, 0x87A1, 0xCE9D, 0x87A2, 0xCE9E,\r\n\t0x87A3, 0xCE9F, 0x87A4, 0xCEA0, 0x87A5, 0xCF40, 0x87A6, 0xCF41,\t0x87A7, 0xCF42, 0x87A8, 0xF2FD, 0x87A9, 0xCF43, 0x87AA, 0xCF44,\r\n\t0x87AB, 0xF3A7, 0x87AC, 0xF3A9, 0x87AD, 0xF3A4, 0x87AE, 0xCF45,\t0x87AF, 0xF2FC, 0x87B0, 0xCF46, 0x87B1, 0xCF47, 0x87B2, 0xCF48,\r\n\t0x87B3, 0xF3AB, 0x87B4, 0xCF49, 0x87B5, 0xF3AA, 0x87B6, 0xCF4A,\t0x87B7, 0xCF4B, 0x87B8, 0xCF4C, 0x87B9, 0xCF4D, 0x87BA, 0xC2DD,\r\n\t0x87BB, 0xCF4E, 0x87BC, 0xCF4F, 0x87BD, 0xF3AE, 0x87BE, 0xCF50,\t0x87BF, 0xCF51, 0x87C0, 0xF3B0, 0x87C1, 0xCF52, 0x87C2, 0xCF53,\r\n\t0x87C3, 0xCF54, 0x87C4, 0xCF55, 0x87C5, 0xCF56, 0x87C6, 0xF3A1,\t0x87C7, 0xCF57, 0x87C8, 0xCF58, 0x87C9, 0xCF59, 0x87CA, 0xF3B1,\r\n\t0x87CB, 0xF3AC, 0x87CC, 0xCF5A, 0x87CD, 0xCF5B, 0x87CE, 0xCF5C,\t0x87CF, 0xCF5D, 0x87D0, 0xCF5E, 0x87D1, 0xF3AF, 0x87D2, 0xF2FE,\r\n\t0x87D3, 0xF3AD, 0x87D4, 0xCF5F, 0x87D5, 0xCF60, 0x87D6, 0xCF61,\t0x87D7, 0xCF62, 0x87D8, 0xCF63, 0x87D9, 0xCF64, 0x87DA, 0xCF65,\r\n\t0x87DB, 0xF3B2, 0x87DC, 0xCF66, 0x87DD, 0xCF67, 0x87DE, 0xCF68,\t0x87DF, 0xCF69, 0x87E0, 0xF3B4, 0x87E1, 0xCF6A, 0x87E2, 0xCF6B,\r\n\t0x87E3, 0xCF6C, 0x87E4, 0xCF6D, 0x87E5, 0xF3A8, 0x87E6, 0xCF6E,\t0x87E7, 0xCF6F, 0x87E8, 0xCF70, 0x87E9, 0xCF71, 0x87EA, 0xF3B3,\r\n\t0x87EB, 0xCF72, 0x87EC, 0xCF73, 0x87ED, 0xCF74, 0x87EE, 0xF3B5,\t0x87EF, 0xCF75, 0x87F0, 0xCF76, 0x87F1, 0xCF77, 0x87F2, 0xCF78,\r\n\t0x87F3, 0xCF79, 0x87F4, 0xCF7A, 0x87F5, 0xCF7B, 0x87F6, 0xCF7C,\t0x87F7, 0xCF7D, 0x87F8, 0xCF7E, 0x87F9, 0xD0B7, 0x87FA, 0xCF80,\r\n\t0x87FB, 0xCF81, 0x87FC, 0xCF82, 0x87FD, 0xCF83, 0x87FE, 0xF3B8,\t0x87FF, 0xCF84, 0x8800, 0xCF85, 0x8801, 0xCF86, 0x8802, 0xCF87,\r\n\t0x8803, 0xD9F9, 0x8804, 0xCF88, 0x8805, 0xCF89, 0x8806, 0xCF8A,\t0x8807, 0xCF8B, 0x8808, 0xCF8C, 0x8809, 0xCF8D, 0x880A, 0xF3B9,\r\n\t0x880B, 0xCF8E, 0x880C, 0xCF8F, 0x880D, 0xCF90, 0x880E, 0xCF91,\t0x880F, 0xCF92, 0x8810, 0xCF93, 0x8811, 0xCF94, 0x8812, 0xCF95,\r\n\t0x8813, 0xF3B7, 0x8814, 0xCF96, 0x8815, 0xC8E4, 0x8816, 0xF3B6,\t0x8817, 0xCF97, 0x8818, 0xCF98, 0x8819, 0xCF99, 0x881A, 0xCF9A,\r\n\t0x881B, 0xF3BA, 0x881C, 0xCF9B, 0x881D, 0xCF9C, 0x881E, 0xCF9D,\t0x881F, 0xCF9E, 0x8820, 0xCF9F, 0x8821, 0xF3BB, 0x8822, 0xB4C0,\r\n\t0x8823, 0xCFA0, 0x8824, 0xD040, 0x8825, 0xD041, 0x8826, 0xD042,\t0x8827, 0xD043, 0x8828, 0xD044, 0x8829, 0xD045, 0x882A, 0xD046,\r\n\t0x882B, 0xD047, 0x882C, 0xD048, 0x882D, 0xD049, 0x882E, 0xD04A,\t0x882F, 0xD04B, 0x8830, 0xD04C, 0x8831, 0xD04D, 0x8832, 0xEEC3,\r\n\t0x8833, 0xD04E, 0x8834, 0xD04F, 0x8835, 0xD050, 0x8836, 0xD051,\t0x8837, 0xD052, 0x8838, 0xD053, 0x8839, 0xF3BC, 0x883A, 0xD054,\r\n\t0x883B, 0xD055, 0x883C, 0xF3BD, 0x883D, 0xD056, 0x883E, 0xD057,\t0x883F, 0xD058, 0x8840, 0xD1AA, 0x8841, 0xD059, 0x8842, 0xD05A,\r\n\t0x8843, 0xD05B, 0x8844, 0xF4AC, 0x8845, 0xD0C6, 0x8846, 0xD05C,\t0x8847, 0xD05D, 0x8848, 0xD05E, 0x8849, 0xD05F, 0x884A, 0xD060,\r\n\t0x884B, 0xD061, 0x884C, 0xD0D0, 0x884D, 0xD1DC, 0x884E, 0xD062,\t0x884F, 0xD063, 0x8850, 0xD064, 0x8851, 0xD065, 0x8852, 0xD066,\r\n\t0x8853, 0xD067, 0x8854, 0xCFCE, 0x8855, 0xD068, 0x8856, 0xD069,\t0x8857, 0xBDD6, 0x8858, 0xD06A, 0x8859, 0xD1C3, 0x885A, 0xD06B,\r\n\t0x885B, 0xD06C, 0x885C, 0xD06D, 0x885D, 0xD06E, 0x885E, 0xD06F,\t0x885F, 0xD070, 0x8860, 0xD071, 0x8861, 0xBAE2, 0x8862, 0xE1E9,\r\n\t0x8863, 0xD2C2, 0x8864, 0xF1C2, 0x8865, 0xB2B9, 0x8866, 0xD072,\t0x8867, 0xD073, 0x8868, 0xB1ED, 0x8869, 0xF1C3, 0x886A, 0xD074,\r\n\t0x886B, 0xC9C0, 0x886C, 0xB3C4, 0x886D, 0xD075, 0x886E, 0xD9F2,\t0x886F, 0xD076, 0x8870, 0xCBA5, 0x8871, 0xD077, 0x8872, 0xF1C4,\r\n\t0x8873, 0xD078, 0x8874, 0xD079, 0x8875, 0xD07A, 0x8876, 0xD07B,\t0x8877, 0xD6D4, 0x8878, 0xD07C, 0x8879, 0xD07D, 0x887A, 0xD07E,\r\n\t0x887B, 0xD080, 0x887C, 0xD081, 0x887D, 0xF1C5, 0x887E, 0xF4C0,\t0x887F, 0xF1C6, 0x8880, 0xD082, 0x8881, 0xD4AC, 0x8882, 0xF1C7,\r\n\t0x8883, 0xD083, 0x8884, 0xB0C0, 0x8885, 0xF4C1, 0x8886, 0xD084,\t0x8887, 0xD085, 0x8888, 0xF4C2, 0x8889, 0xD086, 0x888A, 0xD087,\r\n\t0x888B, 0xB4FC, 0x888C, 0xD088, 0x888D, 0xC5DB, 0x888E, 0xD089,\t0x888F, 0xD08A, 0x8890, 0xD08B, 0x8891, 0xD08C, 0x8892, 0xCCBB,\r\n\t0x8893, 0xD08D, 0x8894, 0xD08E, 0x8895, 0xD08F, 0x8896, 0xD0E4,\t0x8897, 0xD090, 0x8898, 0xD091, 0x8899, 0xD092, 0x889A, 0xD093,\r\n\t0x889B, 0xD094, 0x889C, 0xCDE0, 0x889D, 0xD095, 0x889E, 0xD096,\t0x889F, 0xD097, 0x88A0, 0xD098, 0x88A1, 0xD099, 0x88A2, 0xF1C8,\r\n\t0x88A3, 0xD09A, 0x88A4, 0xD9F3, 0x88A5, 0xD09B, 0x88A6, 0xD09C,\t0x88A7, 0xD09D, 0x88A8, 0xD09E, 0x88A9, 0xD09F, 0x88AA, 0xD0A0,\r\n\t0x88AB, 0xB1BB, 0x88AC, 0xD140, 0x88AD, 0xCFAE, 0x88AE, 0xD141,\t0x88AF, 0xD142, 0x88B0, 0xD143, 0x88B1, 0xB8A4, 0x88B2, 0xD144,\r\n\t0x88B3, 0xD145, 0x88B4, 0xD146, 0x88B5, 0xD147, 0x88B6, 0xD148,\t0x88B7, 0xF1CA, 0x88B8, 0xD149, 0x88B9, 0xD14A, 0x88BA, 0xD14B,\r\n\t0x88BB, 0xD14C, 0x88BC, 0xF1CB, 0x88BD, 0xD14D, 0x88BE, 0xD14E,\t0x88BF, 0xD14F, 0x88C0, 0xD150, 0x88C1, 0xB2C3, 0x88C2, 0xC1D1,\r\n\t0x88C3, 0xD151, 0x88C4, 0xD152, 0x88C5, 0xD7B0, 0x88C6, 0xF1C9,\t0x88C7, 0xD153, 0x88C8, 0xD154, 0x88C9, 0xF1CC, 0x88CA, 0xD155,\r\n\t0x88CB, 0xD156, 0x88CC, 0xD157, 0x88CD, 0xD158, 0x88CE, 0xF1CE,\t0x88CF, 0xD159, 0x88D0, 0xD15A, 0x88D1, 0xD15B, 0x88D2, 0xD9F6,\r\n\t0x88D3, 0xD15C, 0x88D4, 0xD2E1, 0x88D5, 0xD4A3, 0x88D6, 0xD15D,\t0x88D7, 0xD15E, 0x88D8, 0xF4C3, 0x88D9, 0xC8B9, 0x88DA, 0xD15F,\r\n\t0x88DB, 0xD160, 0x88DC, 0xD161, 0x88DD, 0xD162, 0x88DE, 0xD163,\t0x88DF, 0xF4C4, 0x88E0, 0xD164, 0x88E1, 0xD165, 0x88E2, 0xF1CD,\r\n\t0x88E3, 0xF1CF, 0x88E4, 0xBFE3, 0x88E5, 0xF1D0, 0x88E6, 0xD166,\t0x88E7, 0xD167, 0x88E8, 0xF1D4, 0x88E9, 0xD168, 0x88EA, 0xD169,\r\n\t0x88EB, 0xD16A, 0x88EC, 0xD16B, 0x88ED, 0xD16C, 0x88EE, 0xD16D,\t0x88EF, 0xD16E, 0x88F0, 0xF1D6, 0x88F1, 0xF1D1, 0x88F2, 0xD16F,\r\n\t0x88F3, 0xC9D1, 0x88F4, 0xC5E1, 0x88F5, 0xD170, 0x88F6, 0xD171,\t0x88F7, 0xD172, 0x88F8, 0xC2E3, 0x88F9, 0xB9FC, 0x88FA, 0xD173,\r\n\t0x88FB, 0xD174, 0x88FC, 0xF1D3, 0x88FD, 0xD175, 0x88FE, 0xF1D5,\t0x88FF, 0xD176, 0x8900, 0xD177, 0x8901, 0xD178, 0x8902, 0xB9D3,\r\n\t0x8903, 0xD179, 0x8904, 0xD17A, 0x8905, 0xD17B, 0x8906, 0xD17C,\t0x8907, 0xD17D, 0x8908, 0xD17E, 0x8909, 0xD180, 0x890A, 0xF1DB,\r\n\t0x890B, 0xD181, 0x890C, 0xD182, 0x890D, 0xD183, 0x890E, 0xD184,\t0x890F, 0xD185, 0x8910, 0xBAD6, 0x8911, 0xD186, 0x8912, 0xB0FD,\r\n\t0x8913, 0xF1D9, 0x8914, 0xD187, 0x8915, 0xD188, 0x8916, 0xD189,\t0x8917, 0xD18A, 0x8918, 0xD18B, 0x8919, 0xF1D8, 0x891A, 0xF1D2,\r\n\t0x891B, 0xF1DA, 0x891C, 0xD18C, 0x891D, 0xD18D, 0x891E, 0xD18E,\t0x891F, 0xD18F, 0x8920, 0xD190, 0x8921, 0xF1D7, 0x8922, 0xD191,\r\n\t0x8923, 0xD192, 0x8924, 0xD193, 0x8925, 0xC8EC, 0x8926, 0xD194,\t0x8927, 0xD195, 0x8928, 0xD196, 0x8929, 0xD197, 0x892A, 0xCDCA,\r\n\t0x892B, 0xF1DD, 0x892C, 0xD198, 0x892D, 0xD199, 0x892E, 0xD19A,\t0x892F, 0xD19B, 0x8930, 0xE5BD, 0x8931, 0xD19C, 0x8932, 0xD19D,\r\n\t0x8933, 0xD19E, 0x8934, 0xF1DC, 0x8935, 0xD19F, 0x8936, 0xF1DE,\t0x8937, 0xD1A0, 0x8938, 0xD240, 0x8939, 0xD241, 0x893A, 0xD242,\r\n\t0x893B, 0xD243, 0x893C, 0xD244, 0x893D, 0xD245, 0x893E, 0xD246,\t0x893F, 0xD247, 0x8940, 0xD248, 0x8941, 0xF1DF, 0x8942, 0xD249,\r\n\t0x8943, 0xD24A, 0x8944, 0xCFE5, 0x8945, 0xD24B, 0x8946, 0xD24C,\t0x8947, 0xD24D, 0x8948, 0xD24E, 0x8949, 0xD24F, 0x894A, 0xD250,\r\n\t0x894B, 0xD251, 0x894C, 0xD252, 0x894D, 0xD253, 0x894E, 0xD254,\t0x894F, 0xD255, 0x8950, 0xD256, 0x8951, 0xD257, 0x8952, 0xD258,\r\n\t0x8953, 0xD259, 0x8954, 0xD25A, 0x8955, 0xD25B, 0x8956, 0xD25C,\t0x8957, 0xD25D, 0x8958, 0xD25E, 0x8959, 0xD25F, 0x895A, 0xD260,\r\n\t0x895B, 0xD261, 0x895C, 0xD262, 0x895D, 0xD263, 0x895E, 0xF4C5,\t0x895F, 0xBDF3, 0x8960, 0xD264, 0x8961, 0xD265, 0x8962, 0xD266,\r\n\t0x8963, 0xD267, 0x8964, 0xD268, 0x8965, 0xD269, 0x8966, 0xF1E0,\t0x8967, 0xD26A, 0x8968, 0xD26B, 0x8969, 0xD26C, 0x896A, 0xD26D,\r\n\t0x896B, 0xD26E, 0x896C, 0xD26F, 0x896D, 0xD270, 0x896E, 0xD271,\t0x896F, 0xD272, 0x8970, 0xD273, 0x8971, 0xD274, 0x8972, 0xD275,\r\n\t0x8973, 0xD276, 0x8974, 0xD277, 0x8975, 0xD278, 0x8976, 0xD279,\t0x8977, 0xD27A, 0x8978, 0xD27B, 0x8979, 0xD27C, 0x897A, 0xD27D,\r\n\t0x897B, 0xF1E1, 0x897C, 0xD27E, 0x897D, 0xD280, 0x897E, 0xD281,\t0x897F, 0xCEF7, 0x8980, 0xD282, 0x8981, 0xD2AA, 0x8982, 0xD283,\r\n\t0x8983, 0xF1FB, 0x8984, 0xD284, 0x8985, 0xD285, 0x8986, 0xB8B2,\t0x8987, 0xD286, 0x8988, 0xD287, 0x8989, 0xD288, 0x898A, 0xD289,\r\n\t0x898B, 0xD28A, 0x898C, 0xD28B, 0x898D, 0xD28C, 0x898E, 0xD28D,\t0x898F, 0xD28E, 0x8990, 0xD28F, 0x8991, 0xD290, 0x8992, 0xD291,\r\n\t0x8993, 0xD292, 0x8994, 0xD293, 0x8995, 0xD294, 0x8996, 0xD295,\t0x8997, 0xD296, 0x8998, 0xD297, 0x8999, 0xD298, 0x899A, 0xD299,\r\n\t0x899B, 0xD29A, 0x899C, 0xD29B, 0x899D, 0xD29C, 0x899E, 0xD29D,\t0x899F, 0xD29E, 0x89A0, 0xD29F, 0x89A1, 0xD2A0, 0x89A2, 0xD340,\r\n\t0x89A3, 0xD341, 0x89A4, 0xD342, 0x89A5, 0xD343, 0x89A6, 0xD344,\t0x89A7, 0xD345, 0x89A8, 0xD346, 0x89A9, 0xD347, 0x89AA, 0xD348,\r\n\t0x89AB, 0xD349, 0x89AC, 0xD34A, 0x89AD, 0xD34B, 0x89AE, 0xD34C,\t0x89AF, 0xD34D, 0x89B0, 0xD34E, 0x89B1, 0xD34F, 0x89B2, 0xD350,\r\n\t0x89B3, 0xD351, 0x89B4, 0xD352, 0x89B5, 0xD353, 0x89B6, 0xD354,\t0x89B7, 0xD355, 0x89B8, 0xD356, 0x89B9, 0xD357, 0x89BA, 0xD358,\r\n\t0x89BB, 0xD359, 0x89BC, 0xD35A, 0x89BD, 0xD35B, 0x89BE, 0xD35C,\t0x89BF, 0xD35D, 0x89C0, 0xD35E, 0x89C1, 0xBCFB, 0x89C2, 0xB9DB,\r\n\t0x89C3, 0xD35F, 0x89C4, 0xB9E6, 0x89C5, 0xC3D9, 0x89C6, 0xCAD3,\t0x89C7, 0xEAE8, 0x89C8, 0xC0C0, 0x89C9, 0xBEF5, 0x89CA, 0xEAE9,\r\n\t0x89CB, 0xEAEA, 0x89CC, 0xEAEB, 0x89CD, 0xD360, 0x89CE, 0xEAEC,\t0x89CF, 0xEAED, 0x89D0, 0xEAEE, 0x89D1, 0xEAEF, 0x89D2, 0xBDC7,\r\n\t0x89D3, 0xD361, 0x89D4, 0xD362, 0x89D5, 0xD363, 0x89D6, 0xF5FB,\t0x89D7, 0xD364, 0x89D8, 0xD365, 0x89D9, 0xD366, 0x89DA, 0xF5FD,\r\n\t0x89DB, 0xD367, 0x89DC, 0xF5FE, 0x89DD, 0xD368, 0x89DE, 0xF5FC,\t0x89DF, 0xD369, 0x89E0, 0xD36A, 0x89E1, 0xD36B, 0x89E2, 0xD36C,\r\n\t0x89E3, 0xBDE2, 0x89E4, 0xD36D, 0x89E5, 0xF6A1, 0x89E6, 0xB4A5,\t0x89E7, 0xD36E, 0x89E8, 0xD36F, 0x89E9, 0xD370, 0x89EA, 0xD371,\r\n\t0x89EB, 0xF6A2, 0x89EC, 0xD372, 0x89ED, 0xD373, 0x89EE, 0xD374,\t0x89EF, 0xF6A3, 0x89F0, 0xD375, 0x89F1, 0xD376, 0x89F2, 0xD377,\r\n\t0x89F3, 0xECB2, 0x89F4, 0xD378, 0x89F5, 0xD379, 0x89F6, 0xD37A,\t0x89F7, 0xD37B, 0x89F8, 0xD37C, 0x89F9, 0xD37D, 0x89FA, 0xD37E,\r\n\t0x89FB, 0xD380, 0x89FC, 0xD381, 0x89FD, 0xD382, 0x89FE, 0xD383,\t0x89FF, 0xD384, 0x8A00, 0xD1D4, 0x8A01, 0xD385, 0x8A02, 0xD386,\r\n\t0x8A03, 0xD387, 0x8A04, 0xD388, 0x8A05, 0xD389, 0x8A06, 0xD38A,\t0x8A07, 0xD9EA, 0x8A08, 0xD38B, 0x8A09, 0xD38C, 0x8A0A, 0xD38D,\r\n\t0x8A0B, 0xD38E, 0x8A0C, 0xD38F, 0x8A0D, 0xD390, 0x8A0E, 0xD391,\t0x8A0F, 0xD392, 0x8A10, 0xD393, 0x8A11, 0xD394, 0x8A12, 0xD395,\r\n\t0x8A13, 0xD396, 0x8A14, 0xD397, 0x8A15, 0xD398, 0x8A16, 0xD399,\t0x8A17, 0xD39A, 0x8A18, 0xD39B, 0x8A19, 0xD39C, 0x8A1A, 0xD39D,\r\n\t0x8A1B, 0xD39E, 0x8A1C, 0xD39F, 0x8A1D, 0xD3A0, 0x8A1E, 0xD440,\t0x8A1F, 0xD441, 0x8A20, 0xD442, 0x8A21, 0xD443, 0x8A22, 0xD444,\r\n\t0x8A23, 0xD445, 0x8A24, 0xD446, 0x8A25, 0xD447, 0x8A26, 0xD448,\t0x8A27, 0xD449, 0x8A28, 0xD44A, 0x8A29, 0xD44B, 0x8A2A, 0xD44C,\r\n\t0x8A2B, 0xD44D, 0x8A2C, 0xD44E, 0x8A2D, 0xD44F, 0x8A2E, 0xD450,\t0x8A2F, 0xD451, 0x8A30, 0xD452, 0x8A31, 0xD453, 0x8A32, 0xD454,\r\n\t0x8A33, 0xD455, 0x8A34, 0xD456, 0x8A35, 0xD457, 0x8A36, 0xD458,\t0x8A37, 0xD459, 0x8A38, 0xD45A, 0x8A39, 0xD45B, 0x8A3A, 0xD45C,\r\n\t0x8A3B, 0xD45D, 0x8A3C, 0xD45E, 0x8A3D, 0xD45F, 0x8A3E, 0xF6A4,\t0x8A3F, 0xD460, 0x8A40, 0xD461, 0x8A41, 0xD462, 0x8A42, 0xD463,\r\n\t0x8A43, 0xD464, 0x8A44, 0xD465, 0x8A45, 0xD466, 0x8A46, 0xD467,\t0x8A47, 0xD468, 0x8A48, 0xEEBA, 0x8A49, 0xD469, 0x8A4A, 0xD46A,\r\n\t0x8A4B, 0xD46B, 0x8A4C, 0xD46C, 0x8A4D, 0xD46D, 0x8A4E, 0xD46E,\t0x8A4F, 0xD46F, 0x8A50, 0xD470, 0x8A51, 0xD471, 0x8A52, 0xD472,\r\n\t0x8A53, 0xD473, 0x8A54, 0xD474, 0x8A55, 0xD475, 0x8A56, 0xD476,\t0x8A57, 0xD477, 0x8A58, 0xD478, 0x8A59, 0xD479, 0x8A5A, 0xD47A,\r\n\t0x8A5B, 0xD47B, 0x8A5C, 0xD47C, 0x8A5D, 0xD47D, 0x8A5E, 0xD47E,\t0x8A5F, 0xD480, 0x8A60, 0xD481, 0x8A61, 0xD482, 0x8A62, 0xD483,\r\n\t0x8A63, 0xD484, 0x8A64, 0xD485, 0x8A65, 0xD486, 0x8A66, 0xD487,\t0x8A67, 0xD488, 0x8A68, 0xD489, 0x8A69, 0xD48A, 0x8A6A, 0xD48B,\r\n\t0x8A6B, 0xD48C, 0x8A6C, 0xD48D, 0x8A6D, 0xD48E, 0x8A6E, 0xD48F,\t0x8A6F, 0xD490, 0x8A70, 0xD491, 0x8A71, 0xD492, 0x8A72, 0xD493,\r\n\t0x8A73, 0xD494, 0x8A74, 0xD495, 0x8A75, 0xD496, 0x8A76, 0xD497,\t0x8A77, 0xD498, 0x8A78, 0xD499, 0x8A79, 0xD5B2, 0x8A7A, 0xD49A,\r\n\t0x8A7B, 0xD49B, 0x8A7C, 0xD49C, 0x8A7D, 0xD49D, 0x8A7E, 0xD49E,\t0x8A7F, 0xD49F, 0x8A80, 0xD4A0, 0x8A81, 0xD540, 0x8A82, 0xD541,\r\n\t0x8A83, 0xD542, 0x8A84, 0xD543, 0x8A85, 0xD544, 0x8A86, 0xD545,\t0x8A87, 0xD546, 0x8A88, 0xD547, 0x8A89, 0xD3FE, 0x8A8A, 0xCCDC,\r\n\t0x8A8B, 0xD548, 0x8A8C, 0xD549, 0x8A8D, 0xD54A, 0x8A8E, 0xD54B,\t0x8A8F, 0xD54C, 0x8A90, 0xD54D, 0x8A91, 0xD54E, 0x8A92, 0xD54F,\r\n\t0x8A93, 0xCAC4, 0x8A94, 0xD550, 0x8A95, 0xD551, 0x8A96, 0xD552,\t0x8A97, 0xD553, 0x8A98, 0xD554, 0x8A99, 0xD555, 0x8A9A, 0xD556,\r\n\t0x8A9B, 0xD557, 0x8A9C, 0xD558, 0x8A9D, 0xD559, 0x8A9E, 0xD55A,\t0x8A9F, 0xD55B, 0x8AA0, 0xD55C, 0x8AA1, 0xD55D, 0x8AA2, 0xD55E,\r\n\t0x8AA3, 0xD55F, 0x8AA4, 0xD560, 0x8AA5, 0xD561, 0x8AA6, 0xD562,\t0x8AA7, 0xD563, 0x8AA8, 0xD564, 0x8AA9, 0xD565, 0x8AAA, 0xD566,\r\n\t0x8AAB, 0xD567, 0x8AAC, 0xD568, 0x8AAD, 0xD569, 0x8AAE, 0xD56A,\t0x8AAF, 0xD56B, 0x8AB0, 0xD56C, 0x8AB1, 0xD56D, 0x8AB2, 0xD56E,\r\n\t0x8AB3, 0xD56F, 0x8AB4, 0xD570, 0x8AB5, 0xD571, 0x8AB6, 0xD572,\t0x8AB7, 0xD573, 0x8AB8, 0xD574, 0x8AB9, 0xD575, 0x8ABA, 0xD576,\r\n\t0x8ABB, 0xD577, 0x8ABC, 0xD578, 0x8ABD, 0xD579, 0x8ABE, 0xD57A,\t0x8ABF, 0xD57B, 0x8AC0, 0xD57C, 0x8AC1, 0xD57D, 0x8AC2, 0xD57E,\r\n\t0x8AC3, 0xD580, 0x8AC4, 0xD581, 0x8AC5, 0xD582, 0x8AC6, 0xD583,\t0x8AC7, 0xD584, 0x8AC8, 0xD585, 0x8AC9, 0xD586, 0x8ACA, 0xD587,\r\n\t0x8ACB, 0xD588, 0x8ACC, 0xD589, 0x8ACD, 0xD58A, 0x8ACE, 0xD58B,\t0x8ACF, 0xD58C, 0x8AD0, 0xD58D, 0x8AD1, 0xD58E, 0x8AD2, 0xD58F,\r\n\t0x8AD3, 0xD590, 0x8AD4, 0xD591, 0x8AD5, 0xD592, 0x8AD6, 0xD593,\t0x8AD7, 0xD594, 0x8AD8, 0xD595, 0x8AD9, 0xD596, 0x8ADA, 0xD597,\r\n\t0x8ADB, 0xD598, 0x8ADC, 0xD599, 0x8ADD, 0xD59A, 0x8ADE, 0xD59B,\t0x8ADF, 0xD59C, 0x8AE0, 0xD59D, 0x8AE1, 0xD59E, 0x8AE2, 0xD59F,\r\n\t0x8AE3, 0xD5A0, 0x8AE4, 0xD640, 0x8AE5, 0xD641, 0x8AE6, 0xD642,\t0x8AE7, 0xD643, 0x8AE8, 0xD644, 0x8AE9, 0xD645, 0x8AEA, 0xD646,\r\n\t0x8AEB, 0xD647, 0x8AEC, 0xD648, 0x8AED, 0xD649, 0x8AEE, 0xD64A,\t0x8AEF, 0xD64B, 0x8AF0, 0xD64C, 0x8AF1, 0xD64D, 0x8AF2, 0xD64E,\r\n\t0x8AF3, 0xD64F, 0x8AF4, 0xD650, 0x8AF5, 0xD651, 0x8AF6, 0xD652,\t0x8AF7, 0xD653, 0x8AF8, 0xD654, 0x8AF9, 0xD655, 0x8AFA, 0xD656,\r\n\t0x8AFB, 0xD657, 0x8AFC, 0xD658, 0x8AFD, 0xD659, 0x8AFE, 0xD65A,\t0x8AFF, 0xD65B, 0x8B00, 0xD65C, 0x8B01, 0xD65D, 0x8B02, 0xD65E,\r\n\t0x8B03, 0xD65F, 0x8B04, 0xD660, 0x8B05, 0xD661, 0x8B06, 0xD662,\t0x8B07, 0xE5C0, 0x8B08, 0xD663, 0x8B09, 0xD664, 0x8B0A, 0xD665,\r\n\t0x8B0B, 0xD666, 0x8B0C, 0xD667, 0x8B0D, 0xD668, 0x8B0E, 0xD669,\t0x8B0F, 0xD66A, 0x8B10, 0xD66B, 0x8B11, 0xD66C, 0x8B12, 0xD66D,\r\n\t0x8B13, 0xD66E, 0x8B14, 0xD66F, 0x8B15, 0xD670, 0x8B16, 0xD671,\t0x8B17, 0xD672, 0x8B18, 0xD673, 0x8B19, 0xD674, 0x8B1A, 0xD675,\r\n\t0x8B1B, 0xD676, 0x8B1C, 0xD677, 0x8B1D, 0xD678, 0x8B1E, 0xD679,\t0x8B1F, 0xD67A, 0x8B20, 0xD67B, 0x8B21, 0xD67C, 0x8B22, 0xD67D,\r\n\t0x8B23, 0xD67E, 0x8B24, 0xD680, 0x8B25, 0xD681, 0x8B26, 0xF6A5,\t0x8B27, 0xD682, 0x8B28, 0xD683, 0x8B29, 0xD684, 0x8B2A, 0xD685,\r\n\t0x8B2B, 0xD686, 0x8B2C, 0xD687, 0x8B2D, 0xD688, 0x8B2E, 0xD689,\t0x8B2F, 0xD68A, 0x8B30, 0xD68B, 0x8B31, 0xD68C, 0x8B32, 0xD68D,\r\n\t0x8B33, 0xD68E, 0x8B34, 0xD68F, 0x8B35, 0xD690, 0x8B36, 0xD691,\t0x8B37, 0xD692, 0x8B38, 0xD693, 0x8B39, 0xD694, 0x8B3A, 0xD695,\r\n\t0x8B3B, 0xD696, 0x8B3C, 0xD697, 0x8B3D, 0xD698, 0x8B3E, 0xD699,\t0x8B3F, 0xD69A, 0x8B40, 0xD69B, 0x8B41, 0xD69C, 0x8B42, 0xD69D,\r\n\t0x8B43, 0xD69E, 0x8B44, 0xD69F, 0x8B45, 0xD6A0, 0x8B46, 0xD740,\t0x8B47, 0xD741, 0x8B48, 0xD742, 0x8B49, 0xD743, 0x8B4A, 0xD744,\r\n\t0x8B4B, 0xD745, 0x8B4C, 0xD746, 0x8B4D, 0xD747, 0x8B4E, 0xD748,\t0x8B4F, 0xD749, 0x8B50, 0xD74A, 0x8B51, 0xD74B, 0x8B52, 0xD74C,\r\n\t0x8B53, 0xD74D, 0x8B54, 0xD74E, 0x8B55, 0xD74F, 0x8B56, 0xD750,\t0x8B57, 0xD751, 0x8B58, 0xD752, 0x8B59, 0xD753, 0x8B5A, 0xD754,\r\n\t0x8B5B, 0xD755, 0x8B5C, 0xD756, 0x8B5D, 0xD757, 0x8B5E, 0xD758,\t0x8B5F, 0xD759, 0x8B60, 0xD75A, 0x8B61, 0xD75B, 0x8B62, 0xD75C,\r\n\t0x8B63, 0xD75D, 0x8B64, 0xD75E, 0x8B65, 0xD75F, 0x8B66, 0xBEAF,\t0x8B67, 0xD760, 0x8B68, 0xD761, 0x8B69, 0xD762, 0x8B6A, 0xD763,\r\n\t0x8B6B, 0xD764, 0x8B6C, 0xC6A9, 0x8B6D, 0xD765, 0x8B6E, 0xD766,\t0x8B6F, 0xD767, 0x8B70, 0xD768, 0x8B71, 0xD769, 0x8B72, 0xD76A,\r\n\t0x8B73, 0xD76B, 0x8B74, 0xD76C, 0x8B75, 0xD76D, 0x8B76, 0xD76E,\t0x8B77, 0xD76F, 0x8B78, 0xD770, 0x8B79, 0xD771, 0x8B7A, 0xD772,\r\n\t0x8B7B, 0xD773, 0x8B7C, 0xD774, 0x8B7D, 0xD775, 0x8B7E, 0xD776,\t0x8B7F, 0xD777, 0x8B80, 0xD778, 0x8B81, 0xD779, 0x8B82, 0xD77A,\r\n\t0x8B83, 0xD77B, 0x8B84, 0xD77C, 0x8B85, 0xD77D, 0x8B86, 0xD77E,\t0x8B87, 0xD780, 0x8B88, 0xD781, 0x8B89, 0xD782, 0x8B8A, 0xD783,\r\n\t0x8B8B, 0xD784, 0x8B8C, 0xD785, 0x8B8D, 0xD786, 0x8B8E, 0xD787,\t0x8B8F, 0xD788, 0x8B90, 0xD789, 0x8B91, 0xD78A, 0x8B92, 0xD78B,\r\n\t0x8B93, 0xD78C, 0x8B94, 0xD78D, 0x8B95, 0xD78E, 0x8B96, 0xD78F,\t0x8B97, 0xD790, 0x8B98, 0xD791, 0x8B99, 0xD792, 0x8B9A, 0xD793,\r\n\t0x8B9B, 0xD794, 0x8B9C, 0xD795, 0x8B9D, 0xD796, 0x8B9E, 0xD797,\t0x8B9F, 0xD798, 0x8BA0, 0xDAA5, 0x8BA1, 0xBCC6, 0x8BA2, 0xB6A9,\r\n\t0x8BA3, 0xB8BC, 0x8BA4, 0xC8CF, 0x8BA5, 0xBCA5, 0x8BA6, 0xDAA6,\t0x8BA7, 0xDAA7, 0x8BA8, 0xCCD6, 0x8BA9, 0xC8C3, 0x8BAA, 0xDAA8,\r\n\t0x8BAB, 0xC6FD, 0x8BAC, 0xD799, 0x8BAD, 0xD1B5, 0x8BAE, 0xD2E9,\t0x8BAF, 0xD1B6, 0x8BB0, 0xBCC7, 0x8BB1, 0xD79A, 0x8BB2, 0xBDB2,\r\n\t0x8BB3, 0xBBE4, 0x8BB4, 0xDAA9, 0x8BB5, 0xDAAA, 0x8BB6, 0xD1C8,\t0x8BB7, 0xDAAB, 0x8BB8, 0xD0ED, 0x8BB9, 0xB6EF, 0x8BBA, 0xC2DB,\r\n\t0x8BBB, 0xD79B, 0x8BBC, 0xCBCF, 0x8BBD, 0xB7ED, 0x8BBE, 0xC9E8,\t0x8BBF, 0xB7C3, 0x8BC0, 0xBEF7, 0x8BC1, 0xD6A4, 0x8BC2, 0xDAAC,\r\n\t0x8BC3, 0xDAAD, 0x8BC4, 0xC6C0, 0x8BC5, 0xD7E7, 0x8BC6, 0xCAB6,\t0x8BC7, 0xD79C, 0x8BC8, 0xD5A9, 0x8BC9, 0xCBDF, 0x8BCA, 0xD5EF,\r\n\t0x8BCB, 0xDAAE, 0x8BCC, 0xD6DF, 0x8BCD, 0xB4CA, 0x8BCE, 0xDAB0,\t0x8BCF, 0xDAAF, 0x8BD0, 0xD79D, 0x8BD1, 0xD2EB, 0x8BD2, 0xDAB1,\r\n\t0x8BD3, 0xDAB2, 0x8BD4, 0xDAB3, 0x8BD5, 0xCAD4, 0x8BD6, 0xDAB4,\t0x8BD7, 0xCAAB, 0x8BD8, 0xDAB5, 0x8BD9, 0xDAB6, 0x8BDA, 0xB3CF,\r\n\t0x8BDB, 0xD6EF, 0x8BDC, 0xDAB7, 0x8BDD, 0xBBB0, 0x8BDE, 0xB5AE,\t0x8BDF, 0xDAB8, 0x8BE0, 0xDAB9, 0x8BE1, 0xB9EE, 0x8BE2, 0xD1AF,\r\n\t0x8BE3, 0xD2E8, 0x8BE4, 0xDABA, 0x8BE5, 0xB8C3, 0x8BE6, 0xCFEA,\t0x8BE7, 0xB2EF, 0x8BE8, 0xDABB, 0x8BE9, 0xDABC, 0x8BEA, 0xD79E,\r\n\t0x8BEB, 0xBDEB, 0x8BEC, 0xCEDC, 0x8BED, 0xD3EF, 0x8BEE, 0xDABD,\t0x8BEF, 0xCEF3, 0x8BF0, 0xDABE, 0x8BF1, 0xD3D5, 0x8BF2, 0xBBE5,\r\n\t0x8BF3, 0xDABF, 0x8BF4, 0xCBB5, 0x8BF5, 0xCBD0, 0x8BF6, 0xDAC0,\t0x8BF7, 0xC7EB, 0x8BF8, 0xD6EE, 0x8BF9, 0xDAC1, 0x8BFA, 0xC5B5,\r\n\t0x8BFB, 0xB6C1, 0x8BFC, 0xDAC2, 0x8BFD, 0xB7CC, 0x8BFE, 0xBFCE,\t0x8BFF, 0xDAC3, 0x8C00, 0xDAC4, 0x8C01, 0xCBAD, 0x8C02, 0xDAC5,\r\n\t0x8C03, 0xB5F7, 0x8C04, 0xDAC6, 0x8C05, 0xC1C2, 0x8C06, 0xD7BB,\t0x8C07, 0xDAC7, 0x8C08, 0xCCB8, 0x8C09, 0xD79F, 0x8C0A, 0xD2EA,\r\n\t0x8C0B, 0xC4B1, 0x8C0C, 0xDAC8, 0x8C0D, 0xB5FD, 0x8C0E, 0xBBD1,\t0x8C0F, 0xDAC9, 0x8C10, 0xD0B3, 0x8C11, 0xDACA, 0x8C12, 0xDACB,\r\n\t0x8C13, 0xCEBD, 0x8C14, 0xDACC, 0x8C15, 0xDACD, 0x8C16, 0xDACE,\t0x8C17, 0xB2F7, 0x8C18, 0xDAD1, 0x8C19, 0xDACF, 0x8C1A, 0xD1E8,\r\n\t0x8C1B, 0xDAD0, 0x8C1C, 0xC3D5, 0x8C1D, 0xDAD2, 0x8C1E, 0xD7A0,\t0x8C1F, 0xDAD3, 0x8C20, 0xDAD4, 0x8C21, 0xDAD5, 0x8C22, 0xD0BB,\r\n\t0x8C23, 0xD2A5, 0x8C24, 0xB0F9, 0x8C25, 0xDAD6, 0x8C26, 0xC7AB,\t0x8C27, 0xDAD7, 0x8C28, 0xBDF7, 0x8C29, 0xC3A1, 0x8C2A, 0xDAD8,\r\n\t0x8C2B, 0xDAD9, 0x8C2C, 0xC3FD, 0x8C2D, 0xCCB7, 0x8C2E, 0xDADA,\t0x8C2F, 0xDADB, 0x8C30, 0xC0BE, 0x8C31, 0xC6D7, 0x8C32, 0xDADC,\r\n\t0x8C33, 0xDADD, 0x8C34, 0xC7B4, 0x8C35, 0xDADE, 0x8C36, 0xDADF,\t0x8C37, 0xB9C8, 0x8C38, 0xD840, 0x8C39, 0xD841, 0x8C3A, 0xD842,\r\n\t0x8C3B, 0xD843, 0x8C3C, 0xD844, 0x8C3D, 0xD845, 0x8C3E, 0xD846,\t0x8C3F, 0xD847, 0x8C40, 0xD848, 0x8C41, 0xBBED, 0x8C42, 0xD849,\r\n\t0x8C43, 0xD84A, 0x8C44, 0xD84B, 0x8C45, 0xD84C, 0x8C46, 0xB6B9,\t0x8C47, 0xF4F8, 0x8C48, 0xD84D, 0x8C49, 0xF4F9, 0x8C4A, 0xD84E,\r\n\t0x8C4B, 0xD84F, 0x8C4C, 0xCDE3, 0x8C4D, 0xD850, 0x8C4E, 0xD851,\t0x8C4F, 0xD852, 0x8C50, 0xD853, 0x8C51, 0xD854, 0x8C52, 0xD855,\r\n\t0x8C53, 0xD856, 0x8C54, 0xD857, 0x8C55, 0xF5B9, 0x8C56, 0xD858,\t0x8C57, 0xD859, 0x8C58, 0xD85A, 0x8C59, 0xD85B, 0x8C5A, 0xEBE0,\r\n\t0x8C5B, 0xD85C, 0x8C5C, 0xD85D, 0x8C5D, 0xD85E, 0x8C5E, 0xD85F,\t0x8C5F, 0xD860, 0x8C60, 0xD861, 0x8C61, 0xCFF3, 0x8C62, 0xBBBF,\r\n\t0x8C63, 0xD862, 0x8C64, 0xD863, 0x8C65, 0xD864, 0x8C66, 0xD865,\t0x8C67, 0xD866, 0x8C68, 0xD867, 0x8C69, 0xD868, 0x8C6A, 0xBAC0,\r\n\t0x8C6B, 0xD4A5, 0x8C6C, 0xD869, 0x8C6D, 0xD86A, 0x8C6E, 0xD86B,\t0x8C6F, 0xD86C, 0x8C70, 0xD86D, 0x8C71, 0xD86E, 0x8C72, 0xD86F,\r\n\t0x8C73, 0xE1D9, 0x8C74, 0xD870, 0x8C75, 0xD871, 0x8C76, 0xD872,\t0x8C77, 0xD873, 0x8C78, 0xF5F4, 0x8C79, 0xB1AA, 0x8C7A, 0xB2F2,\r\n\t0x8C7B, 0xD874, 0x8C7C, 0xD875, 0x8C7D, 0xD876, 0x8C7E, 0xD877,\t0x8C7F, 0xD878, 0x8C80, 0xD879, 0x8C81, 0xD87A, 0x8C82, 0xF5F5,\r\n\t0x8C83, 0xD87B, 0x8C84, 0xD87C, 0x8C85, 0xF5F7, 0x8C86, 0xD87D,\t0x8C87, 0xD87E, 0x8C88, 0xD880, 0x8C89, 0xBAD1, 0x8C8A, 0xF5F6,\r\n\t0x8C8B, 0xD881, 0x8C8C, 0xC3B2, 0x8C8D, 0xD882, 0x8C8E, 0xD883,\t0x8C8F, 0xD884, 0x8C90, 0xD885, 0x8C91, 0xD886, 0x8C92, 0xD887,\r\n\t0x8C93, 0xD888, 0x8C94, 0xF5F9, 0x8C95, 0xD889, 0x8C96, 0xD88A,\t0x8C97, 0xD88B, 0x8C98, 0xF5F8, 0x8C99, 0xD88C, 0x8C9A, 0xD88D,\r\n\t0x8C9B, 0xD88E, 0x8C9C, 0xD88F, 0x8C9D, 0xD890, 0x8C9E, 0xD891,\t0x8C9F, 0xD892, 0x8CA0, 0xD893, 0x8CA1, 0xD894, 0x8CA2, 0xD895,\r\n\t0x8CA3, 0xD896, 0x8CA4, 0xD897, 0x8CA5, 0xD898, 0x8CA6, 0xD899,\t0x8CA7, 0xD89A, 0x8CA8, 0xD89B, 0x8CA9, 0xD89C, 0x8CAA, 0xD89D,\r\n\t0x8CAB, 0xD89E, 0x8CAC, 0xD89F, 0x8CAD, 0xD8A0, 0x8CAE, 0xD940,\t0x8CAF, 0xD941, 0x8CB0, 0xD942, 0x8CB1, 0xD943, 0x8CB2, 0xD944,\r\n\t0x8CB3, 0xD945, 0x8CB4, 0xD946, 0x8CB5, 0xD947, 0x8CB6, 0xD948,\t0x8CB7, 0xD949, 0x8CB8, 0xD94A, 0x8CB9, 0xD94B, 0x8CBA, 0xD94C,\r\n\t0x8CBB, 0xD94D, 0x8CBC, 0xD94E, 0x8CBD, 0xD94F, 0x8CBE, 0xD950,\t0x8CBF, 0xD951, 0x8CC0, 0xD952, 0x8CC1, 0xD953, 0x8CC2, 0xD954,\r\n\t0x8CC3, 0xD955, 0x8CC4, 0xD956, 0x8CC5, 0xD957, 0x8CC6, 0xD958,\t0x8CC7, 0xD959, 0x8CC8, 0xD95A, 0x8CC9, 0xD95B, 0x8CCA, 0xD95C,\r\n\t0x8CCB, 0xD95D, 0x8CCC, 0xD95E, 0x8CCD, 0xD95F, 0x8CCE, 0xD960,\t0x8CCF, 0xD961, 0x8CD0, 0xD962, 0x8CD1, 0xD963, 0x8CD2, 0xD964,\r\n\t0x8CD3, 0xD965, 0x8CD4, 0xD966, 0x8CD5, 0xD967, 0x8CD6, 0xD968,\t0x8CD7, 0xD969, 0x8CD8, 0xD96A, 0x8CD9, 0xD96B, 0x8CDA, 0xD96C,\r\n\t0x8CDB, 0xD96D, 0x8CDC, 0xD96E, 0x8CDD, 0xD96F, 0x8CDE, 0xD970,\t0x8CDF, 0xD971, 0x8CE0, 0xD972, 0x8CE1, 0xD973, 0x8CE2, 0xD974,\r\n\t0x8CE3, 0xD975, 0x8CE4, 0xD976, 0x8CE5, 0xD977, 0x8CE6, 0xD978,\t0x8CE7, 0xD979, 0x8CE8, 0xD97A, 0x8CE9, 0xD97B, 0x8CEA, 0xD97C,\r\n\t0x8CEB, 0xD97D, 0x8CEC, 0xD97E, 0x8CED, 0xD980, 0x8CEE, 0xD981,\t0x8CEF, 0xD982, 0x8CF0, 0xD983, 0x8CF1, 0xD984, 0x8CF2, 0xD985,\r\n\t0x8CF3, 0xD986, 0x8CF4, 0xD987, 0x8CF5, 0xD988, 0x8CF6, 0xD989,\t0x8CF7, 0xD98A, 0x8CF8, 0xD98B, 0x8CF9, 0xD98C, 0x8CFA, 0xD98D,\r\n\t0x8CFB, 0xD98E, 0x8CFC, 0xD98F, 0x8CFD, 0xD990, 0x8CFE, 0xD991,\t0x8CFF, 0xD992, 0x8D00, 0xD993, 0x8D01, 0xD994, 0x8D02, 0xD995,\r\n\t0x8D03, 0xD996, 0x8D04, 0xD997, 0x8D05, 0xD998, 0x8D06, 0xD999,\t0x8D07, 0xD99A, 0x8D08, 0xD99B, 0x8D09, 0xD99C, 0x8D0A, 0xD99D,\r\n\t0x8D0B, 0xD99E, 0x8D0C, 0xD99F, 0x8D0D, 0xD9A0, 0x8D0E, 0xDA40,\t0x8D0F, 0xDA41, 0x8D10, 0xDA42, 0x8D11, 0xDA43, 0x8D12, 0xDA44,\r\n\t0x8D13, 0xDA45, 0x8D14, 0xDA46, 0x8D15, 0xDA47, 0x8D16, 0xDA48,\t0x8D17, 0xDA49, 0x8D18, 0xDA4A, 0x8D19, 0xDA4B, 0x8D1A, 0xDA4C,\r\n\t0x8D1B, 0xDA4D, 0x8D1C, 0xDA4E, 0x8D1D, 0xB1B4, 0x8D1E, 0xD5EA,\t0x8D1F, 0xB8BA, 0x8D20, 0xDA4F, 0x8D21, 0xB9B1, 0x8D22, 0xB2C6,\r\n\t0x8D23, 0xD4F0, 0x8D24, 0xCFCD, 0x8D25, 0xB0DC, 0x8D26, 0xD5CB,\t0x8D27, 0xBBF5, 0x8D28, 0xD6CA, 0x8D29, 0xB7B7, 0x8D2A, 0xCCB0,\r\n\t0x8D2B, 0xC6B6, 0x8D2C, 0xB1E1, 0x8D2D, 0xB9BA, 0x8D2E, 0xD6FC,\t0x8D2F, 0xB9E1, 0x8D30, 0xB7A1, 0x8D31, 0xBCFA, 0x8D32, 0xEADA,\r\n\t0x8D33, 0xEADB, 0x8D34, 0xCCF9, 0x8D35, 0xB9F3, 0x8D36, 0xEADC,\t0x8D37, 0xB4FB, 0x8D38, 0xC3B3, 0x8D39, 0xB7D1, 0x8D3A, 0xBAD8,\r\n\t0x8D3B, 0xEADD, 0x8D3C, 0xD4F4, 0x8D3D, 0xEADE, 0x8D3E, 0xBCD6,\t0x8D3F, 0xBBDF, 0x8D40, 0xEADF, 0x8D41, 0xC1DE, 0x8D42, 0xC2B8,\r\n\t0x8D43, 0xD4DF, 0x8D44, 0xD7CA, 0x8D45, 0xEAE0, 0x8D46, 0xEAE1,\t0x8D47, 0xEAE4, 0x8D48, 0xEAE2, 0x8D49, 0xEAE3, 0x8D4A, 0xC9DE,\r\n\t0x8D4B, 0xB8B3, 0x8D4C, 0xB6C4, 0x8D4D, 0xEAE5, 0x8D4E, 0xCAEA,\t0x8D4F, 0xC9CD, 0x8D50, 0xB4CD, 0x8D51, 0xDA50, 0x8D52, 0xDA51,\r\n\t0x8D53, 0xE2D9, 0x8D54, 0xC5E2, 0x8D55, 0xEAE6, 0x8D56, 0xC0B5,\t0x8D57, 0xDA52, 0x8D58, 0xD7B8, 0x8D59, 0xEAE7, 0x8D5A, 0xD7AC,\r\n\t0x8D5B, 0xC8FC, 0x8D5C, 0xD8D3, 0x8D5D, 0xD8CD, 0x8D5E, 0xD4DE,\t0x8D5F, 0xDA53, 0x8D60, 0xD4F9, 0x8D61, 0xC9C4, 0x8D62, 0xD3AE,\r\n\t0x8D63, 0xB8D3, 0x8D64, 0xB3E0, 0x8D65, 0xDA54, 0x8D66, 0xC9E2,\t0x8D67, 0xF4F6, 0x8D68, 0xDA55, 0x8D69, 0xDA56, 0x8D6A, 0xDA57,\r\n\t0x8D6B, 0xBAD5, 0x8D6C, 0xDA58, 0x8D6D, 0xF4F7, 0x8D6E, 0xDA59,\t0x8D6F, 0xDA5A, 0x8D70, 0xD7DF, 0x8D71, 0xDA5B, 0x8D72, 0xDA5C,\r\n\t0x8D73, 0xF4F1, 0x8D74, 0xB8B0, 0x8D75, 0xD5D4, 0x8D76, 0xB8CF,\t0x8D77, 0xC6F0, 0x8D78, 0xDA5D, 0x8D79, 0xDA5E, 0x8D7A, 0xDA5F,\r\n\t0x8D7B, 0xDA60, 0x8D7C, 0xDA61, 0x8D7D, 0xDA62, 0x8D7E, 0xDA63,\t0x8D7F, 0xDA64, 0x8D80, 0xDA65, 0x8D81, 0xB3C3, 0x8D82, 0xDA66,\r\n\t0x8D83, 0xDA67, 0x8D84, 0xF4F2, 0x8D85, 0xB3AC, 0x8D86, 0xDA68,\t0x8D87, 0xDA69, 0x8D88, 0xDA6A, 0x8D89, 0xDA6B, 0x8D8A, 0xD4BD,\r\n\t0x8D8B, 0xC7F7, 0x8D8C, 0xDA6C, 0x8D8D, 0xDA6D, 0x8D8E, 0xDA6E,\t0x8D8F, 0xDA6F, 0x8D90, 0xDA70, 0x8D91, 0xF4F4, 0x8D92, 0xDA71,\r\n\t0x8D93, 0xDA72, 0x8D94, 0xF4F3, 0x8D95, 0xDA73, 0x8D96, 0xDA74,\t0x8D97, 0xDA75, 0x8D98, 0xDA76, 0x8D99, 0xDA77, 0x8D9A, 0xDA78,\r\n\t0x8D9B, 0xDA79, 0x8D9C, 0xDA7A, 0x8D9D, 0xDA7B, 0x8D9E, 0xDA7C,\t0x8D9F, 0xCCCB, 0x8DA0, 0xDA7D, 0x8DA1, 0xDA7E, 0x8DA2, 0xDA80,\r\n\t0x8DA3, 0xC8A4, 0x8DA4, 0xDA81, 0x8DA5, 0xDA82, 0x8DA6, 0xDA83,\t0x8DA7, 0xDA84, 0x8DA8, 0xDA85, 0x8DA9, 0xDA86, 0x8DAA, 0xDA87,\r\n\t0x8DAB, 0xDA88, 0x8DAC, 0xDA89, 0x8DAD, 0xDA8A, 0x8DAE, 0xDA8B,\t0x8DAF, 0xDA8C, 0x8DB0, 0xDA8D, 0x8DB1, 0xF4F5, 0x8DB2, 0xDA8E,\r\n\t0x8DB3, 0xD7E3, 0x8DB4, 0xC5BF, 0x8DB5, 0xF5C0, 0x8DB6, 0xDA8F,\t0x8DB7, 0xDA90, 0x8DB8, 0xF5BB, 0x8DB9, 0xDA91, 0x8DBA, 0xF5C3,\r\n\t0x8DBB, 0xDA92, 0x8DBC, 0xF5C2, 0x8DBD, 0xDA93, 0x8DBE, 0xD6BA,\t0x8DBF, 0xF5C1, 0x8DC0, 0xDA94, 0x8DC1, 0xDA95, 0x8DC2, 0xDA96,\r\n\t0x8DC3, 0xD4BE, 0x8DC4, 0xF5C4, 0x8DC5, 0xDA97, 0x8DC6, 0xF5CC,\t0x8DC7, 0xDA98, 0x8DC8, 0xDA99, 0x8DC9, 0xDA9A, 0x8DCA, 0xDA9B,\r\n\t0x8DCB, 0xB0CF, 0x8DCC, 0xB5F8, 0x8DCD, 0xDA9C, 0x8DCE, 0xF5C9,\t0x8DCF, 0xF5CA, 0x8DD0, 0xDA9D, 0x8DD1, 0xC5DC, 0x8DD2, 0xDA9E,\r\n\t0x8DD3, 0xDA9F, 0x8DD4, 0xDAA0, 0x8DD5, 0xDB40, 0x8DD6, 0xF5C5,\t0x8DD7, 0xF5C6, 0x8DD8, 0xDB41, 0x8DD9, 0xDB42, 0x8DDA, 0xF5C7,\r\n\t0x8DDB, 0xF5CB, 0x8DDC, 0xDB43, 0x8DDD, 0xBEE0, 0x8DDE, 0xF5C8,\t0x8DDF, 0xB8FA, 0x8DE0, 0xDB44, 0x8DE1, 0xDB45, 0x8DE2, 0xDB46,\r\n\t0x8DE3, 0xF5D0, 0x8DE4, 0xF5D3, 0x8DE5, 0xDB47, 0x8DE6, 0xDB48,\t0x8DE7, 0xDB49, 0x8DE8, 0xBFE7, 0x8DE9, 0xDB4A, 0x8DEA, 0xB9F2,\r\n\t0x8DEB, 0xF5BC, 0x8DEC, 0xF5CD, 0x8DED, 0xDB4B, 0x8DEE, 0xDB4C,\t0x8DEF, 0xC2B7, 0x8DF0, 0xDB4D, 0x8DF1, 0xDB4E, 0x8DF2, 0xDB4F,\r\n\t0x8DF3, 0xCCF8, 0x8DF4, 0xDB50, 0x8DF5, 0xBCF9, 0x8DF6, 0xDB51,\t0x8DF7, 0xF5CE, 0x8DF8, 0xF5CF, 0x8DF9, 0xF5D1, 0x8DFA, 0xB6E5,\r\n\t0x8DFB, 0xF5D2, 0x8DFC, 0xDB52, 0x8DFD, 0xF5D5, 0x8DFE, 0xDB53,\t0x8DFF, 0xDB54, 0x8E00, 0xDB55, 0x8E01, 0xDB56, 0x8E02, 0xDB57,\r\n\t0x8E03, 0xDB58, 0x8E04, 0xDB59, 0x8E05, 0xF5BD, 0x8E06, 0xDB5A,\t0x8E07, 0xDB5B, 0x8E08, 0xDB5C, 0x8E09, 0xF5D4, 0x8E0A, 0xD3BB,\r\n\t0x8E0B, 0xDB5D, 0x8E0C, 0xB3EC, 0x8E0D, 0xDB5E, 0x8E0E, 0xDB5F,\t0x8E0F, 0xCCA4, 0x8E10, 0xDB60, 0x8E11, 0xDB61, 0x8E12, 0xDB62,\r\n\t0x8E13, 0xDB63, 0x8E14, 0xF5D6, 0x8E15, 0xDB64, 0x8E16, 0xDB65,\t0x8E17, 0xDB66, 0x8E18, 0xDB67, 0x8E19, 0xDB68, 0x8E1A, 0xDB69,\r\n\t0x8E1B, 0xDB6A, 0x8E1C, 0xDB6B, 0x8E1D, 0xF5D7, 0x8E1E, 0xBEE1,\t0x8E1F, 0xF5D8, 0x8E20, 0xDB6C, 0x8E21, 0xDB6D, 0x8E22, 0xCCDF,\r\n\t0x8E23, 0xF5DB, 0x8E24, 0xDB6E, 0x8E25, 0xDB6F, 0x8E26, 0xDB70,\t0x8E27, 0xDB71, 0x8E28, 0xDB72, 0x8E29, 0xB2C8, 0x8E2A, 0xD7D9,\r\n\t0x8E2B, 0xDB73, 0x8E2C, 0xF5D9, 0x8E2D, 0xDB74, 0x8E2E, 0xF5DA,\t0x8E2F, 0xF5DC, 0x8E30, 0xDB75, 0x8E31, 0xF5E2, 0x8E32, 0xDB76,\r\n\t0x8E33, 0xDB77, 0x8E34, 0xDB78, 0x8E35, 0xF5E0, 0x8E36, 0xDB79,\t0x8E37, 0xDB7A, 0x8E38, 0xDB7B, 0x8E39, 0xF5DF, 0x8E3A, 0xF5DD,\r\n\t0x8E3B, 0xDB7C, 0x8E3C, 0xDB7D, 0x8E3D, 0xF5E1, 0x8E3E, 0xDB7E,\t0x8E3F, 0xDB80, 0x8E40, 0xF5DE, 0x8E41, 0xF5E4, 0x8E42, 0xF5E5,\r\n\t0x8E43, 0xDB81, 0x8E44, 0xCCE3, 0x8E45, 0xDB82, 0x8E46, 0xDB83,\t0x8E47, 0xE5BF, 0x8E48, 0xB5B8, 0x8E49, 0xF5E3, 0x8E4A, 0xF5E8,\r\n\t0x8E4B, 0xCCA3, 0x8E4C, 0xDB84, 0x8E4D, 0xDB85, 0x8E4E, 0xDB86,\t0x8E4F, 0xDB87, 0x8E50, 0xDB88, 0x8E51, 0xF5E6, 0x8E52, 0xF5E7,\r\n\t0x8E53, 0xDB89, 0x8E54, 0xDB8A, 0x8E55, 0xDB8B, 0x8E56, 0xDB8C,\t0x8E57, 0xDB8D, 0x8E58, 0xDB8E, 0x8E59, 0xF5BE, 0x8E5A, 0xDB8F,\r\n\t0x8E5B, 0xDB90, 0x8E5C, 0xDB91, 0x8E5D, 0xDB92, 0x8E5E, 0xDB93,\t0x8E5F, 0xDB94, 0x8E60, 0xDB95, 0x8E61, 0xDB96, 0x8E62, 0xDB97,\r\n\t0x8E63, 0xDB98, 0x8E64, 0xDB99, 0x8E65, 0xDB9A, 0x8E66, 0xB1C4,\t0x8E67, 0xDB9B, 0x8E68, 0xDB9C, 0x8E69, 0xF5BF, 0x8E6A, 0xDB9D,\r\n\t0x8E6B, 0xDB9E, 0x8E6C, 0xB5C5, 0x8E6D, 0xB2E4, 0x8E6E, 0xDB9F,\t0x8E6F, 0xF5EC, 0x8E70, 0xF5E9, 0x8E71, 0xDBA0, 0x8E72, 0xB6D7,\r\n\t0x8E73, 0xDC40, 0x8E74, 0xF5ED, 0x8E75, 0xDC41, 0x8E76, 0xF5EA,\t0x8E77, 0xDC42, 0x8E78, 0xDC43, 0x8E79, 0xDC44, 0x8E7A, 0xDC45,\r\n\t0x8E7B, 0xDC46, 0x8E7C, 0xF5EB, 0x8E7D, 0xDC47, 0x8E7E, 0xDC48,\t0x8E7F, 0xB4DA, 0x8E80, 0xDC49, 0x8E81, 0xD4EA, 0x8E82, 0xDC4A,\r\n\t0x8E83, 0xDC4B, 0x8E84, 0xDC4C, 0x8E85, 0xF5EE, 0x8E86, 0xDC4D,\t0x8E87, 0xB3F9, 0x8E88, 0xDC4E, 0x8E89, 0xDC4F, 0x8E8A, 0xDC50,\r\n\t0x8E8B, 0xDC51, 0x8E8C, 0xDC52, 0x8E8D, 0xDC53, 0x8E8E, 0xDC54,\t0x8E8F, 0xF5EF, 0x8E90, 0xF5F1, 0x8E91, 0xDC55, 0x8E92, 0xDC56,\r\n\t0x8E93, 0xDC57, 0x8E94, 0xF5F0, 0x8E95, 0xDC58, 0x8E96, 0xDC59,\t0x8E97, 0xDC5A, 0x8E98, 0xDC5B, 0x8E99, 0xDC5C, 0x8E9A, 0xDC5D,\r\n\t0x8E9B, 0xDC5E, 0x8E9C, 0xF5F2, 0x8E9D, 0xDC5F, 0x8E9E, 0xF5F3,\t0x8E9F, 0xDC60, 0x8EA0, 0xDC61, 0x8EA1, 0xDC62, 0x8EA2, 0xDC63,\r\n\t0x8EA3, 0xDC64, 0x8EA4, 0xDC65, 0x8EA5, 0xDC66, 0x8EA6, 0xDC67,\t0x8EA7, 0xDC68, 0x8EA8, 0xDC69, 0x8EA9, 0xDC6A, 0x8EAA, 0xDC6B,\r\n\t0x8EAB, 0xC9ED, 0x8EAC, 0xB9AA, 0x8EAD, 0xDC6C, 0x8EAE, 0xDC6D,\t0x8EAF, 0xC7FB, 0x8EB0, 0xDC6E, 0x8EB1, 0xDC6F, 0x8EB2, 0xB6E3,\r\n\t0x8EB3, 0xDC70, 0x8EB4, 0xDC71, 0x8EB5, 0xDC72, 0x8EB6, 0xDC73,\t0x8EB7, 0xDC74, 0x8EB8, 0xDC75, 0x8EB9, 0xDC76, 0x8EBA, 0xCCC9,\r\n\t0x8EBB, 0xDC77, 0x8EBC, 0xDC78, 0x8EBD, 0xDC79, 0x8EBE, 0xDC7A,\t0x8EBF, 0xDC7B, 0x8EC0, 0xDC7C, 0x8EC1, 0xDC7D, 0x8EC2, 0xDC7E,\r\n\t0x8EC3, 0xDC80, 0x8EC4, 0xDC81, 0x8EC5, 0xDC82, 0x8EC6, 0xDC83,\t0x8EC7, 0xDC84, 0x8EC8, 0xDC85, 0x8EC9, 0xDC86, 0x8ECA, 0xDC87,\r\n\t0x8ECB, 0xDC88, 0x8ECC, 0xDC89, 0x8ECD, 0xDC8A, 0x8ECE, 0xEAA6,\t0x8ECF, 0xDC8B, 0x8ED0, 0xDC8C, 0x8ED1, 0xDC8D, 0x8ED2, 0xDC8E,\r\n\t0x8ED3, 0xDC8F, 0x8ED4, 0xDC90, 0x8ED5, 0xDC91, 0x8ED6, 0xDC92,\t0x8ED7, 0xDC93, 0x8ED8, 0xDC94, 0x8ED9, 0xDC95, 0x8EDA, 0xDC96,\r\n\t0x8EDB, 0xDC97, 0x8EDC, 0xDC98, 0x8EDD, 0xDC99, 0x8EDE, 0xDC9A,\t0x8EDF, 0xDC9B, 0x8EE0, 0xDC9C, 0x8EE1, 0xDC9D, 0x8EE2, 0xDC9E,\r\n\t0x8EE3, 0xDC9F, 0x8EE4, 0xDCA0, 0x8EE5, 0xDD40, 0x8EE6, 0xDD41,\t0x8EE7, 0xDD42, 0x8EE8, 0xDD43, 0x8EE9, 0xDD44, 0x8EEA, 0xDD45,\r\n\t0x8EEB, 0xDD46, 0x8EEC, 0xDD47, 0x8EED, 0xDD48, 0x8EEE, 0xDD49,\t0x8EEF, 0xDD4A, 0x8EF0, 0xDD4B, 0x8EF1, 0xDD4C, 0x8EF2, 0xDD4D,\r\n\t0x8EF3, 0xDD4E, 0x8EF4, 0xDD4F, 0x8EF5, 0xDD50, 0x8EF6, 0xDD51,\t0x8EF7, 0xDD52, 0x8EF8, 0xDD53, 0x8EF9, 0xDD54, 0x8EFA, 0xDD55,\r\n\t0x8EFB, 0xDD56, 0x8EFC, 0xDD57, 0x8EFD, 0xDD58, 0x8EFE, 0xDD59,\t0x8EFF, 0xDD5A, 0x8F00, 0xDD5B, 0x8F01, 0xDD5C, 0x8F02, 0xDD5D,\r\n\t0x8F03, 0xDD5E, 0x8F04, 0xDD5F, 0x8F05, 0xDD60, 0x8F06, 0xDD61,\t0x8F07, 0xDD62, 0x8F08, 0xDD63, 0x8F09, 0xDD64, 0x8F0A, 0xDD65,\r\n\t0x8F0B, 0xDD66, 0x8F0C, 0xDD67, 0x8F0D, 0xDD68, 0x8F0E, 0xDD69,\t0x8F0F, 0xDD6A, 0x8F10, 0xDD6B, 0x8F11, 0xDD6C, 0x8F12, 0xDD6D,\r\n\t0x8F13, 0xDD6E, 0x8F14, 0xDD6F, 0x8F15, 0xDD70, 0x8F16, 0xDD71,\t0x8F17, 0xDD72, 0x8F18, 0xDD73, 0x8F19, 0xDD74, 0x8F1A, 0xDD75,\r\n\t0x8F1B, 0xDD76, 0x8F1C, 0xDD77, 0x8F1D, 0xDD78, 0x8F1E, 0xDD79,\t0x8F1F, 0xDD7A, 0x8F20, 0xDD7B, 0x8F21, 0xDD7C, 0x8F22, 0xDD7D,\r\n\t0x8F23, 0xDD7E, 0x8F24, 0xDD80, 0x8F25, 0xDD81, 0x8F26, 0xDD82,\t0x8F27, 0xDD83, 0x8F28, 0xDD84, 0x8F29, 0xDD85, 0x8F2A, 0xDD86,\r\n\t0x8F2B, 0xDD87, 0x8F2C, 0xDD88, 0x8F2D, 0xDD89, 0x8F2E, 0xDD8A,\t0x8F2F, 0xDD8B, 0x8F30, 0xDD8C, 0x8F31, 0xDD8D, 0x8F32, 0xDD8E,\r\n\t0x8F33, 0xDD8F, 0x8F34, 0xDD90, 0x8F35, 0xDD91, 0x8F36, 0xDD92,\t0x8F37, 0xDD93, 0x8F38, 0xDD94, 0x8F39, 0xDD95, 0x8F3A, 0xDD96,\r\n\t0x8F3B, 0xDD97, 0x8F3C, 0xDD98, 0x8F3D, 0xDD99, 0x8F3E, 0xDD9A,\t0x8F3F, 0xDD9B, 0x8F40, 0xDD9C, 0x8F41, 0xDD9D, 0x8F42, 0xDD9E,\r\n\t0x8F43, 0xDD9F, 0x8F44, 0xDDA0, 0x8F45, 0xDE40, 0x8F46, 0xDE41,\t0x8F47, 0xDE42, 0x8F48, 0xDE43, 0x8F49, 0xDE44, 0x8F4A, 0xDE45,\r\n\t0x8F4B, 0xDE46, 0x8F4C, 0xDE47, 0x8F4D, 0xDE48, 0x8F4E, 0xDE49,\t0x8F4F, 0xDE4A, 0x8F50, 0xDE4B, 0x8F51, 0xDE4C, 0x8F52, 0xDE4D,\r\n\t0x8F53, 0xDE4E, 0x8F54, 0xDE4F, 0x8F55, 0xDE50, 0x8F56, 0xDE51,\t0x8F57, 0xDE52, 0x8F58, 0xDE53, 0x8F59, 0xDE54, 0x8F5A, 0xDE55,\r\n\t0x8F5B, 0xDE56, 0x8F5C, 0xDE57, 0x8F5D, 0xDE58, 0x8F5E, 0xDE59,\t0x8F5F, 0xDE5A, 0x8F60, 0xDE5B, 0x8F61, 0xDE5C, 0x8F62, 0xDE5D,\r\n\t0x8F63, 0xDE5E, 0x8F64, 0xDE5F, 0x8F65, 0xDE60, 0x8F66, 0xB3B5,\t0x8F67, 0xD4FE, 0x8F68, 0xB9EC, 0x8F69, 0xD0F9, 0x8F6A, 0xDE61,\r\n\t0x8F6B, 0xE9ED, 0x8F6C, 0xD7AA, 0x8F6D, 0xE9EE, 0x8F6E, 0xC2D6,\t0x8F6F, 0xC8ED, 0x8F70, 0xBAE4, 0x8F71, 0xE9EF, 0x8F72, 0xE9F0,\r\n\t0x8F73, 0xE9F1, 0x8F74, 0xD6E1, 0x8F75, 0xE9F2, 0x8F76, 0xE9F3,\t0x8F77, 0xE9F5, 0x8F78, 0xE9F4, 0x8F79, 0xE9F6, 0x8F7A, 0xE9F7,\r\n\t0x8F7B, 0xC7E1, 0x8F7C, 0xE9F8, 0x8F7D, 0xD4D8, 0x8F7E, 0xE9F9,\t0x8F7F, 0xBDCE, 0x8F80, 0xDE62, 0x8F81, 0xE9FA, 0x8F82, 0xE9FB,\r\n\t0x8F83, 0xBDCF, 0x8F84, 0xE9FC, 0x8F85, 0xB8A8, 0x8F86, 0xC1BE,\t0x8F87, 0xE9FD, 0x8F88, 0xB1B2, 0x8F89, 0xBBD4, 0x8F8A, 0xB9F5,\r\n\t0x8F8B, 0xE9FE, 0x8F8C, 0xDE63, 0x8F8D, 0xEAA1, 0x8F8E, 0xEAA2,\t0x8F8F, 0xEAA3, 0x8F90, 0xB7F8, 0x8F91, 0xBCAD, 0x8F92, 0xDE64,\r\n\t0x8F93, 0xCAE4, 0x8F94, 0xE0CE, 0x8F95, 0xD4AF, 0x8F96, 0xCFBD,\t0x8F97, 0xD5B7, 0x8F98, 0xEAA4, 0x8F99, 0xD5DE, 0x8F9A, 0xEAA5,\r\n\t0x8F9B, 0xD0C1, 0x8F9C, 0xB9BC, 0x8F9D, 0xDE65, 0x8F9E, 0xB4C7,\t0x8F9F, 0xB1D9, 0x8FA0, 0xDE66, 0x8FA1, 0xDE67, 0x8FA2, 0xDE68,\r\n\t0x8FA3, 0xC0B1, 0x8FA4, 0xDE69, 0x8FA5, 0xDE6A, 0x8FA6, 0xDE6B,\t0x8FA7, 0xDE6C, 0x8FA8, 0xB1E6, 0x8FA9, 0xB1E7, 0x8FAA, 0xDE6D,\r\n\t0x8FAB, 0xB1E8, 0x8FAC, 0xDE6E, 0x8FAD, 0xDE6F, 0x8FAE, 0xDE70,\t0x8FAF, 0xDE71, 0x8FB0, 0xB3BD, 0x8FB1, 0xC8E8, 0x8FB2, 0xDE72,\r\n\t0x8FB3, 0xDE73, 0x8FB4, 0xDE74, 0x8FB5, 0xDE75, 0x8FB6, 0xE5C1,\t0x8FB7, 0xDE76, 0x8FB8, 0xDE77, 0x8FB9, 0xB1DF, 0x8FBA, 0xDE78,\r\n\t0x8FBB, 0xDE79, 0x8FBC, 0xDE7A, 0x8FBD, 0xC1C9, 0x8FBE, 0xB4EF,\t0x8FBF, 0xDE7B, 0x8FC0, 0xDE7C, 0x8FC1, 0xC7A8, 0x8FC2, 0xD3D8,\r\n\t0x8FC3, 0xDE7D, 0x8FC4, 0xC6F9, 0x8FC5, 0xD1B8, 0x8FC6, 0xDE7E,\t0x8FC7, 0xB9FD, 0x8FC8, 0xC2F5, 0x8FC9, 0xDE80, 0x8FCA, 0xDE81,\r\n\t0x8FCB, 0xDE82, 0x8FCC, 0xDE83, 0x8FCD, 0xDE84, 0x8FCE, 0xD3AD,\t0x8FCF, 0xDE85, 0x8FD0, 0xD4CB, 0x8FD1, 0xBDFC, 0x8FD2, 0xDE86,\r\n\t0x8FD3, 0xE5C2, 0x8FD4, 0xB7B5, 0x8FD5, 0xE5C3, 0x8FD6, 0xDE87,\t0x8FD7, 0xDE88, 0x8FD8, 0xBBB9, 0x8FD9, 0xD5E2, 0x8FDA, 0xDE89,\r\n\t0x8FDB, 0xBDF8, 0x8FDC, 0xD4B6, 0x8FDD, 0xCEA5, 0x8FDE, 0xC1AC,\t0x8FDF, 0xB3D9, 0x8FE0, 0xDE8A, 0x8FE1, 0xDE8B, 0x8FE2, 0xCCF6,\r\n\t0x8FE3, 0xDE8C, 0x8FE4, 0xE5C6, 0x8FE5, 0xE5C4, 0x8FE6, 0xE5C8,\t0x8FE7, 0xDE8D, 0x8FE8, 0xE5CA, 0x8FE9, 0xE5C7, 0x8FEA, 0xB5CF,\r\n\t0x8FEB, 0xC6C8, 0x8FEC, 0xDE8E, 0x8FED, 0xB5FC, 0x8FEE, 0xE5C5,\t0x8FEF, 0xDE8F, 0x8FF0, 0xCAF6, 0x8FF1, 0xDE90, 0x8FF2, 0xDE91,\r\n\t0x8FF3, 0xE5C9, 0x8FF4, 0xDE92, 0x8FF5, 0xDE93, 0x8FF6, 0xDE94,\t0x8FF7, 0xC3D4, 0x8FF8, 0xB1C5, 0x8FF9, 0xBCA3, 0x8FFA, 0xDE95,\r\n\t0x8FFB, 0xDE96, 0x8FFC, 0xDE97, 0x8FFD, 0xD7B7, 0x8FFE, 0xDE98,\t0x8FFF, 0xDE99, 0x9000, 0xCDCB, 0x9001, 0xCBCD, 0x9002, 0xCACA,\r\n\t0x9003, 0xCCD3, 0x9004, 0xE5CC, 0x9005, 0xE5CB, 0x9006, 0xC4E6,\t0x9007, 0xDE9A, 0x9008, 0xDE9B, 0x9009, 0xD1A1, 0x900A, 0xD1B7,\r\n\t0x900B, 0xE5CD, 0x900C, 0xDE9C, 0x900D, 0xE5D0, 0x900E, 0xDE9D,\t0x900F, 0xCDB8, 0x9010, 0xD6F0, 0x9011, 0xE5CF, 0x9012, 0xB5DD,\r\n\t0x9013, 0xDE9E, 0x9014, 0xCDBE, 0x9015, 0xDE9F, 0x9016, 0xE5D1,\t0x9017, 0xB6BA, 0x9018, 0xDEA0, 0x9019, 0xDF40, 0x901A, 0xCDA8,\r\n\t0x901B, 0xB9E4, 0x901C, 0xDF41, 0x901D, 0xCAC5, 0x901E, 0xB3D1,\t0x901F, 0xCBD9, 0x9020, 0xD4EC, 0x9021, 0xE5D2, 0x9022, 0xB7EA,\r\n\t0x9023, 0xDF42, 0x9024, 0xDF43, 0x9025, 0xDF44, 0x9026, 0xE5CE,\t0x9027, 0xDF45, 0x9028, 0xDF46, 0x9029, 0xDF47, 0x902A, 0xDF48,\r\n\t0x902B, 0xDF49, 0x902C, 0xDF4A, 0x902D, 0xE5D5, 0x902E, 0xB4FE,\t0x902F, 0xE5D6, 0x9030, 0xDF4B, 0x9031, 0xDF4C, 0x9032, 0xDF4D,\r\n\t0x9033, 0xDF4E, 0x9034, 0xDF4F, 0x9035, 0xE5D3, 0x9036, 0xE5D4,\t0x9037, 0xDF50, 0x9038, 0xD2DD, 0x9039, 0xDF51, 0x903A, 0xDF52,\r\n\t0x903B, 0xC2DF, 0x903C, 0xB1C6, 0x903D, 0xDF53, 0x903E, 0xD3E2,\t0x903F, 0xDF54, 0x9040, 0xDF55, 0x9041, 0xB6DD, 0x9042, 0xCBEC,\r\n\t0x9043, 0xDF56, 0x9044, 0xE5D7, 0x9045, 0xDF57, 0x9046, 0xDF58,\t0x9047, 0xD3F6, 0x9048, 0xDF59, 0x9049, 0xDF5A, 0x904A, 0xDF5B,\r\n\t0x904B, 0xDF5C, 0x904C, 0xDF5D, 0x904D, 0xB1E9, 0x904E, 0xDF5E,\t0x904F, 0xB6F4, 0x9050, 0xE5DA, 0x9051, 0xE5D8, 0x9052, 0xE5D9,\r\n\t0x9053, 0xB5C0, 0x9054, 0xDF5F, 0x9055, 0xDF60, 0x9056, 0xDF61,\t0x9057, 0xD2C5, 0x9058, 0xE5DC, 0x9059, 0xDF62, 0x905A, 0xDF63,\r\n\t0x905B, 0xE5DE, 0x905C, 0xDF64, 0x905D, 0xDF65, 0x905E, 0xDF66,\t0x905F, 0xDF67, 0x9060, 0xDF68, 0x9061, 0xDF69, 0x9062, 0xE5DD,\r\n\t0x9063, 0xC7B2, 0x9064, 0xDF6A, 0x9065, 0xD2A3, 0x9066, 0xDF6B,\t0x9067, 0xDF6C, 0x9068, 0xE5DB, 0x9069, 0xDF6D, 0x906A, 0xDF6E,\r\n\t0x906B, 0xDF6F, 0x906C, 0xDF70, 0x906D, 0xD4E2, 0x906E, 0xD5DA,\t0x906F, 0xDF71, 0x9070, 0xDF72, 0x9071, 0xDF73, 0x9072, 0xDF74,\r\n\t0x9073, 0xDF75, 0x9074, 0xE5E0, 0x9075, 0xD7F1, 0x9076, 0xDF76,\t0x9077, 0xDF77, 0x9078, 0xDF78, 0x9079, 0xDF79, 0x907A, 0xDF7A,\r\n\t0x907B, 0xDF7B, 0x907C, 0xDF7C, 0x907D, 0xE5E1, 0x907E, 0xDF7D,\t0x907F, 0xB1DC, 0x9080, 0xD1FB, 0x9081, 0xDF7E, 0x9082, 0xE5E2,\r\n\t0x9083, 0xE5E4, 0x9084, 0xDF80, 0x9085, 0xDF81, 0x9086, 0xDF82,\t0x9087, 0xDF83, 0x9088, 0xE5E3, 0x9089, 0xDF84, 0x908A, 0xDF85,\r\n\t0x908B, 0xE5E5, 0x908C, 0xDF86, 0x908D, 0xDF87, 0x908E, 0xDF88,\t0x908F, 0xDF89, 0x9090, 0xDF8A, 0x9091, 0xD2D8, 0x9092, 0xDF8B,\r\n\t0x9093, 0xB5CB, 0x9094, 0xDF8C, 0x9095, 0xE7DF, 0x9096, 0xDF8D,\t0x9097, 0xDAF5, 0x9098, 0xDF8E, 0x9099, 0xDAF8, 0x909A, 0xDF8F,\r\n\t0x909B, 0xDAF6, 0x909C, 0xDF90, 0x909D, 0xDAF7, 0x909E, 0xDF91,\t0x909F, 0xDF92, 0x90A0, 0xDF93, 0x90A1, 0xDAFA, 0x90A2, 0xD0CF,\r\n\t0x90A3, 0xC4C7, 0x90A4, 0xDF94, 0x90A5, 0xDF95, 0x90A6, 0xB0EE,\t0x90A7, 0xDF96, 0x90A8, 0xDF97, 0x90A9, 0xDF98, 0x90AA, 0xD0B0,\r\n\t0x90AB, 0xDF99, 0x90AC, 0xDAF9, 0x90AD, 0xDF9A, 0x90AE, 0xD3CA,\t0x90AF, 0xBAAA, 0x90B0, 0xDBA2, 0x90B1, 0xC7F1, 0x90B2, 0xDF9B,\r\n\t0x90B3, 0xDAFC, 0x90B4, 0xDAFB, 0x90B5, 0xC9DB, 0x90B6, 0xDAFD,\t0x90B7, 0xDF9C, 0x90B8, 0xDBA1, 0x90B9, 0xD7DE, 0x90BA, 0xDAFE,\r\n\t0x90BB, 0xC1DA, 0x90BC, 0xDF9D, 0x90BD, 0xDF9E, 0x90BE, 0xDBA5,\t0x90BF, 0xDF9F, 0x90C0, 0xDFA0, 0x90C1, 0xD3F4, 0x90C2, 0xE040,\r\n\t0x90C3, 0xE041, 0x90C4, 0xDBA7, 0x90C5, 0xDBA4, 0x90C6, 0xE042,\t0x90C7, 0xDBA8, 0x90C8, 0xE043, 0x90C9, 0xE044, 0x90CA, 0xBDBC,\r\n\t0x90CB, 0xE045, 0x90CC, 0xE046, 0x90CD, 0xE047, 0x90CE, 0xC0C9,\t0x90CF, 0xDBA3, 0x90D0, 0xDBA6, 0x90D1, 0xD6A3, 0x90D2, 0xE048,\r\n\t0x90D3, 0xDBA9, 0x90D4, 0xE049, 0x90D5, 0xE04A, 0x90D6, 0xE04B,\t0x90D7, 0xDBAD, 0x90D8, 0xE04C, 0x90D9, 0xE04D, 0x90DA, 0xE04E,\r\n\t0x90DB, 0xDBAE, 0x90DC, 0xDBAC, 0x90DD, 0xBAC2, 0x90DE, 0xE04F,\t0x90DF, 0xE050, 0x90E0, 0xE051, 0x90E1, 0xBFA4, 0x90E2, 0xDBAB,\r\n\t0x90E3, 0xE052, 0x90E4, 0xE053, 0x90E5, 0xE054, 0x90E6, 0xDBAA,\t0x90E7, 0xD4C7, 0x90E8, 0xB2BF, 0x90E9, 0xE055, 0x90EA, 0xE056,\r\n\t0x90EB, 0xDBAF, 0x90EC, 0xE057, 0x90ED, 0xB9F9, 0x90EE, 0xE058,\t0x90EF, 0xDBB0, 0x90F0, 0xE059, 0x90F1, 0xE05A, 0x90F2, 0xE05B,\r\n\t0x90F3, 0xE05C, 0x90F4, 0xB3BB, 0x90F5, 0xE05D, 0x90F6, 0xE05E,\t0x90F7, 0xE05F, 0x90F8, 0xB5A6, 0x90F9, 0xE060, 0x90FA, 0xE061,\r\n\t0x90FB, 0xE062, 0x90FC, 0xE063, 0x90FD, 0xB6BC, 0x90FE, 0xDBB1,\t0x90FF, 0xE064, 0x9100, 0xE065, 0x9101, 0xE066, 0x9102, 0xB6F5,\r\n\t0x9103, 0xE067, 0x9104, 0xDBB2, 0x9105, 0xE068, 0x9106, 0xE069,\t0x9107, 0xE06A, 0x9108, 0xE06B, 0x9109, 0xE06C, 0x910A, 0xE06D,\r\n\t0x910B, 0xE06E, 0x910C, 0xE06F, 0x910D, 0xE070, 0x910E, 0xE071,\t0x910F, 0xE072, 0x9110, 0xE073, 0x9111, 0xE074, 0x9112, 0xE075,\r\n\t0x9113, 0xE076, 0x9114, 0xE077, 0x9115, 0xE078, 0x9116, 0xE079,\t0x9117, 0xE07A, 0x9118, 0xE07B, 0x9119, 0xB1C9, 0x911A, 0xE07C,\r\n\t0x911B, 0xE07D, 0x911C, 0xE07E, 0x911D, 0xE080, 0x911E, 0xDBB4,\t0x911F, 0xE081, 0x9120, 0xE082, 0x9121, 0xE083, 0x9122, 0xDBB3,\r\n\t0x9123, 0xDBB5, 0x9124, 0xE084, 0x9125, 0xE085, 0x9126, 0xE086,\t0x9127, 0xE087, 0x9128, 0xE088, 0x9129, 0xE089, 0x912A, 0xE08A,\r\n\t0x912B, 0xE08B, 0x912C, 0xE08C, 0x912D, 0xE08D, 0x912E, 0xE08E,\t0x912F, 0xDBB7, 0x9130, 0xE08F, 0x9131, 0xDBB6, 0x9132, 0xE090,\r\n\t0x9133, 0xE091, 0x9134, 0xE092, 0x9135, 0xE093, 0x9136, 0xE094,\t0x9137, 0xE095, 0x9138, 0xE096, 0x9139, 0xDBB8, 0x913A, 0xE097,\r\n\t0x913B, 0xE098, 0x913C, 0xE099, 0x913D, 0xE09A, 0x913E, 0xE09B,\t0x913F, 0xE09C, 0x9140, 0xE09D, 0x9141, 0xE09E, 0x9142, 0xE09F,\r\n\t0x9143, 0xDBB9, 0x9144, 0xE0A0, 0x9145, 0xE140, 0x9146, 0xDBBA,\t0x9147, 0xE141, 0x9148, 0xE142, 0x9149, 0xD3CF, 0x914A, 0xF4FA,\r\n\t0x914B, 0xC7F5, 0x914C, 0xD7C3, 0x914D, 0xC5E4, 0x914E, 0xF4FC,\t0x914F, 0xF4FD, 0x9150, 0xF4FB, 0x9151, 0xE143, 0x9152, 0xBEC6,\r\n\t0x9153, 0xE144, 0x9154, 0xE145, 0x9155, 0xE146, 0x9156, 0xE147,\t0x9157, 0xD0EF, 0x9158, 0xE148, 0x9159, 0xE149, 0x915A, 0xB7D3,\r\n\t0x915B, 0xE14A, 0x915C, 0xE14B, 0x915D, 0xD4CD, 0x915E, 0xCCAA,\t0x915F, 0xE14C, 0x9160, 0xE14D, 0x9161, 0xF5A2, 0x9162, 0xF5A1,\r\n\t0x9163, 0xBAA8, 0x9164, 0xF4FE, 0x9165, 0xCBD6, 0x9166, 0xE14E,\t0x9167, 0xE14F, 0x9168, 0xE150, 0x9169, 0xF5A4, 0x916A, 0xC0D2,\r\n\t0x916B, 0xE151, 0x916C, 0xB3EA, 0x916D, 0xE152, 0x916E, 0xCDAA,\t0x916F, 0xF5A5, 0x9170, 0xF5A3, 0x9171, 0xBDB4, 0x9172, 0xF5A8,\r\n\t0x9173, 0xE153, 0x9174, 0xF5A9, 0x9175, 0xBDCD, 0x9176, 0xC3B8,\t0x9177, 0xBFE1, 0x9178, 0xCBE1, 0x9179, 0xF5AA, 0x917A, 0xE154,\r\n\t0x917B, 0xE155, 0x917C, 0xE156, 0x917D, 0xF5A6, 0x917E, 0xF5A7,\t0x917F, 0xC4F0, 0x9180, 0xE157, 0x9181, 0xE158, 0x9182, 0xE159,\r\n\t0x9183, 0xE15A, 0x9184, 0xE15B, 0x9185, 0xF5AC, 0x9186, 0xE15C,\t0x9187, 0xB4BC, 0x9188, 0xE15D, 0x9189, 0xD7ED, 0x918A, 0xE15E,\r\n\t0x918B, 0xB4D7, 0x918C, 0xF5AB, 0x918D, 0xF5AE, 0x918E, 0xE15F,\t0x918F, 0xE160, 0x9190, 0xF5AD, 0x9191, 0xF5AF, 0x9192, 0xD0D1,\r\n\t0x9193, 0xE161, 0x9194, 0xE162, 0x9195, 0xE163, 0x9196, 0xE164,\t0x9197, 0xE165, 0x9198, 0xE166, 0x9199, 0xE167, 0x919A, 0xC3D1,\r\n\t0x919B, 0xC8A9, 0x919C, 0xE168, 0x919D, 0xE169, 0x919E, 0xE16A,\t0x919F, 0xE16B, 0x91A0, 0xE16C, 0x91A1, 0xE16D, 0x91A2, 0xF5B0,\r\n\t0x91A3, 0xF5B1, 0x91A4, 0xE16E, 0x91A5, 0xE16F, 0x91A6, 0xE170,\t0x91A7, 0xE171, 0x91A8, 0xE172, 0x91A9, 0xE173, 0x91AA, 0xF5B2,\r\n\t0x91AB, 0xE174, 0x91AC, 0xE175, 0x91AD, 0xF5B3, 0x91AE, 0xF5B4,\t0x91AF, 0xF5B5, 0x91B0, 0xE176, 0x91B1, 0xE177, 0x91B2, 0xE178,\r\n\t0x91B3, 0xE179, 0x91B4, 0xF5B7, 0x91B5, 0xF5B6, 0x91B6, 0xE17A,\t0x91B7, 0xE17B, 0x91B8, 0xE17C, 0x91B9, 0xE17D, 0x91BA, 0xF5B8,\r\n\t0x91BB, 0xE17E, 0x91BC, 0xE180, 0x91BD, 0xE181, 0x91BE, 0xE182,\t0x91BF, 0xE183, 0x91C0, 0xE184, 0x91C1, 0xE185, 0x91C2, 0xE186,\r\n\t0x91C3, 0xE187, 0x91C4, 0xE188, 0x91C5, 0xE189, 0x91C6, 0xE18A,\t0x91C7, 0xB2C9, 0x91C8, 0xE18B, 0x91C9, 0xD3D4, 0x91CA, 0xCACD,\r\n\t0x91CB, 0xE18C, 0x91CC, 0xC0EF, 0x91CD, 0xD6D8, 0x91CE, 0xD2B0,\t0x91CF, 0xC1BF, 0x91D0, 0xE18D, 0x91D1, 0xBDF0, 0x91D2, 0xE18E,\r\n\t0x91D3, 0xE18F, 0x91D4, 0xE190, 0x91D5, 0xE191, 0x91D6, 0xE192,\t0x91D7, 0xE193, 0x91D8, 0xE194, 0x91D9, 0xE195, 0x91DA, 0xE196,\r\n\t0x91DB, 0xE197, 0x91DC, 0xB8AA, 0x91DD, 0xE198, 0x91DE, 0xE199,\t0x91DF, 0xE19A, 0x91E0, 0xE19B, 0x91E1, 0xE19C, 0x91E2, 0xE19D,\r\n\t0x91E3, 0xE19E, 0x91E4, 0xE19F, 0x91E5, 0xE1A0, 0x91E6, 0xE240,\t0x91E7, 0xE241, 0x91E8, 0xE242, 0x91E9, 0xE243, 0x91EA, 0xE244,\r\n\t0x91EB, 0xE245, 0x91EC, 0xE246, 0x91ED, 0xE247, 0x91EE, 0xE248,\t0x91EF, 0xE249, 0x91F0, 0xE24A, 0x91F1, 0xE24B, 0x91F2, 0xE24C,\r\n\t0x91F3, 0xE24D, 0x91F4, 0xE24E, 0x91F5, 0xE24F, 0x91F6, 0xE250,\t0x91F7, 0xE251, 0x91F8, 0xE252, 0x91F9, 0xE253, 0x91FA, 0xE254,\r\n\t0x91FB, 0xE255, 0x91FC, 0xE256, 0x91FD, 0xE257, 0x91FE, 0xE258,\t0x91FF, 0xE259, 0x9200, 0xE25A, 0x9201, 0xE25B, 0x9202, 0xE25C,\r\n\t0x9203, 0xE25D, 0x9204, 0xE25E, 0x9205, 0xE25F, 0x9206, 0xE260,\t0x9207, 0xE261, 0x9208, 0xE262, 0x9209, 0xE263, 0x920A, 0xE264,\r\n\t0x920B, 0xE265, 0x920C, 0xE266, 0x920D, 0xE267, 0x920E, 0xE268,\t0x920F, 0xE269, 0x9210, 0xE26A, 0x9211, 0xE26B, 0x9212, 0xE26C,\r\n\t0x9213, 0xE26D, 0x9214, 0xE26E, 0x9215, 0xE26F, 0x9216, 0xE270,\t0x9217, 0xE271, 0x9218, 0xE272, 0x9219, 0xE273, 0x921A, 0xE274,\r\n\t0x921B, 0xE275, 0x921C, 0xE276, 0x921D, 0xE277, 0x921E, 0xE278,\t0x921F, 0xE279, 0x9220, 0xE27A, 0x9221, 0xE27B, 0x9222, 0xE27C,\r\n\t0x9223, 0xE27D, 0x9224, 0xE27E, 0x9225, 0xE280, 0x9226, 0xE281,\t0x9227, 0xE282, 0x9228, 0xE283, 0x9229, 0xE284, 0x922A, 0xE285,\r\n\t0x922B, 0xE286, 0x922C, 0xE287, 0x922D, 0xE288, 0x922E, 0xE289,\t0x922F, 0xE28A, 0x9230, 0xE28B, 0x9231, 0xE28C, 0x9232, 0xE28D,\r\n\t0x9233, 0xE28E, 0x9234, 0xE28F, 0x9235, 0xE290, 0x9236, 0xE291,\t0x9237, 0xE292, 0x9238, 0xE293, 0x9239, 0xE294, 0x923A, 0xE295,\r\n\t0x923B, 0xE296, 0x923C, 0xE297, 0x923D, 0xE298, 0x923E, 0xE299,\t0x923F, 0xE29A, 0x9240, 0xE29B, 0x9241, 0xE29C, 0x9242, 0xE29D,\r\n\t0x9243, 0xE29E, 0x9244, 0xE29F, 0x9245, 0xE2A0, 0x9246, 0xE340,\t0x9247, 0xE341, 0x9248, 0xE342, 0x9249, 0xE343, 0x924A, 0xE344,\r\n\t0x924B, 0xE345, 0x924C, 0xE346, 0x924D, 0xE347, 0x924E, 0xE348,\t0x924F, 0xE349, 0x9250, 0xE34A, 0x9251, 0xE34B, 0x9252, 0xE34C,\r\n\t0x9253, 0xE34D, 0x9254, 0xE34E, 0x9255, 0xE34F, 0x9256, 0xE350,\t0x9257, 0xE351, 0x9258, 0xE352, 0x9259, 0xE353, 0x925A, 0xE354,\r\n\t0x925B, 0xE355, 0x925C, 0xE356, 0x925D, 0xE357, 0x925E, 0xE358,\t0x925F, 0xE359, 0x9260, 0xE35A, 0x9261, 0xE35B, 0x9262, 0xE35C,\r\n\t0x9263, 0xE35D, 0x9264, 0xE35E, 0x9265, 0xE35F, 0x9266, 0xE360,\t0x9267, 0xE361, 0x9268, 0xE362, 0x9269, 0xE363, 0x926A, 0xE364,\r\n\t0x926B, 0xE365, 0x926C, 0xE366, 0x926D, 0xE367, 0x926E, 0xE368,\t0x926F, 0xE369, 0x9270, 0xE36A, 0x9271, 0xE36B, 0x9272, 0xE36C,\r\n\t0x9273, 0xE36D, 0x9274, 0xBCF8, 0x9275, 0xE36E, 0x9276, 0xE36F,\t0x9277, 0xE370, 0x9278, 0xE371, 0x9279, 0xE372, 0x927A, 0xE373,\r\n\t0x927B, 0xE374, 0x927C, 0xE375, 0x927D, 0xE376, 0x927E, 0xE377,\t0x927F, 0xE378, 0x9280, 0xE379, 0x9281, 0xE37A, 0x9282, 0xE37B,\r\n\t0x9283, 0xE37C, 0x9284, 0xE37D, 0x9285, 0xE37E, 0x9286, 0xE380,\t0x9287, 0xE381, 0x9288, 0xE382, 0x9289, 0xE383, 0x928A, 0xE384,\r\n\t0x928B, 0xE385, 0x928C, 0xE386, 0x928D, 0xE387, 0x928E, 0xF6C6,\t0x928F, 0xE388, 0x9290, 0xE389, 0x9291, 0xE38A, 0x9292, 0xE38B,\r\n\t0x9293, 0xE38C, 0x9294, 0xE38D, 0x9295, 0xE38E, 0x9296, 0xE38F,\t0x9297, 0xE390, 0x9298, 0xE391, 0x9299, 0xE392, 0x929A, 0xE393,\r\n\t0x929B, 0xE394, 0x929C, 0xE395, 0x929D, 0xE396, 0x929E, 0xE397,\t0x929F, 0xE398, 0x92A0, 0xE399, 0x92A1, 0xE39A, 0x92A2, 0xE39B,\r\n\t0x92A3, 0xE39C, 0x92A4, 0xE39D, 0x92A5, 0xE39E, 0x92A6, 0xE39F,\t0x92A7, 0xE3A0, 0x92A8, 0xE440, 0x92A9, 0xE441, 0x92AA, 0xE442,\r\n\t0x92AB, 0xE443, 0x92AC, 0xE444, 0x92AD, 0xE445, 0x92AE, 0xF6C7,\t0x92AF, 0xE446, 0x92B0, 0xE447, 0x92B1, 0xE448, 0x92B2, 0xE449,\r\n\t0x92B3, 0xE44A, 0x92B4, 0xE44B, 0x92B5, 0xE44C, 0x92B6, 0xE44D,\t0x92B7, 0xE44E, 0x92B8, 0xE44F, 0x92B9, 0xE450, 0x92BA, 0xE451,\r\n\t0x92BB, 0xE452, 0x92BC, 0xE453, 0x92BD, 0xE454, 0x92BE, 0xE455,\t0x92BF, 0xE456, 0x92C0, 0xE457, 0x92C1, 0xE458, 0x92C2, 0xE459,\r\n\t0x92C3, 0xE45A, 0x92C4, 0xE45B, 0x92C5, 0xE45C, 0x92C6, 0xE45D,\t0x92C7, 0xE45E, 0x92C8, 0xF6C8, 0x92C9, 0xE45F, 0x92CA, 0xE460,\r\n\t0x92CB, 0xE461, 0x92CC, 0xE462, 0x92CD, 0xE463, 0x92CE, 0xE464,\t0x92CF, 0xE465, 0x92D0, 0xE466, 0x92D1, 0xE467, 0x92D2, 0xE468,\r\n\t0x92D3, 0xE469, 0x92D4, 0xE46A, 0x92D5, 0xE46B, 0x92D6, 0xE46C,\t0x92D7, 0xE46D, 0x92D8, 0xE46E, 0x92D9, 0xE46F, 0x92DA, 0xE470,\r\n\t0x92DB, 0xE471, 0x92DC, 0xE472, 0x92DD, 0xE473, 0x92DE, 0xE474,\t0x92DF, 0xE475, 0x92E0, 0xE476, 0x92E1, 0xE477, 0x92E2, 0xE478,\r\n\t0x92E3, 0xE479, 0x92E4, 0xE47A, 0x92E5, 0xE47B, 0x92E6, 0xE47C,\t0x92E7, 0xE47D, 0x92E8, 0xE47E, 0x92E9, 0xE480, 0x92EA, 0xE481,\r\n\t0x92EB, 0xE482, 0x92EC, 0xE483, 0x92ED, 0xE484, 0x92EE, 0xE485,\t0x92EF, 0xE486, 0x92F0, 0xE487, 0x92F1, 0xE488, 0x92F2, 0xE489,\r\n\t0x92F3, 0xE48A, 0x92F4, 0xE48B, 0x92F5, 0xE48C, 0x92F6, 0xE48D,\t0x92F7, 0xE48E, 0x92F8, 0xE48F, 0x92F9, 0xE490, 0x92FA, 0xE491,\r\n\t0x92FB, 0xE492, 0x92FC, 0xE493, 0x92FD, 0xE494, 0x92FE, 0xE495,\t0x92FF, 0xE496, 0x9300, 0xE497, 0x9301, 0xE498, 0x9302, 0xE499,\r\n\t0x9303, 0xE49A, 0x9304, 0xE49B, 0x9305, 0xE49C, 0x9306, 0xE49D,\t0x9307, 0xE49E, 0x9308, 0xE49F, 0x9309, 0xE4A0, 0x930A, 0xE540,\r\n\t0x930B, 0xE541, 0x930C, 0xE542, 0x930D, 0xE543, 0x930E, 0xE544,\t0x930F, 0xE545, 0x9310, 0xE546, 0x9311, 0xE547, 0x9312, 0xE548,\r\n\t0x9313, 0xE549, 0x9314, 0xE54A, 0x9315, 0xE54B, 0x9316, 0xE54C,\t0x9317, 0xE54D, 0x9318, 0xE54E, 0x9319, 0xE54F, 0x931A, 0xE550,\r\n\t0x931B, 0xE551, 0x931C, 0xE552, 0x931D, 0xE553, 0x931E, 0xE554,\t0x931F, 0xE555, 0x9320, 0xE556, 0x9321, 0xE557, 0x9322, 0xE558,\r\n\t0x9323, 0xE559, 0x9324, 0xE55A, 0x9325, 0xE55B, 0x9326, 0xE55C,\t0x9327, 0xE55D, 0x9328, 0xE55E, 0x9329, 0xE55F, 0x932A, 0xE560,\r\n\t0x932B, 0xE561, 0x932C, 0xE562, 0x932D, 0xE563, 0x932E, 0xE564,\t0x932F, 0xE565, 0x9330, 0xE566, 0x9331, 0xE567, 0x9332, 0xE568,\r\n\t0x9333, 0xE569, 0x9334, 0xE56A, 0x9335, 0xE56B, 0x9336, 0xE56C,\t0x9337, 0xE56D, 0x9338, 0xE56E, 0x9339, 0xE56F, 0x933A, 0xE570,\r\n\t0x933B, 0xE571, 0x933C, 0xE572, 0x933D, 0xE573, 0x933E, 0xF6C9,\t0x933F, 0xE574, 0x9340, 0xE575, 0x9341, 0xE576, 0x9342, 0xE577,\r\n\t0x9343, 0xE578, 0x9344, 0xE579, 0x9345, 0xE57A, 0x9346, 0xE57B,\t0x9347, 0xE57C, 0x9348, 0xE57D, 0x9349, 0xE57E, 0x934A, 0xE580,\r\n\t0x934B, 0xE581, 0x934C, 0xE582, 0x934D, 0xE583, 0x934E, 0xE584,\t0x934F, 0xE585, 0x9350, 0xE586, 0x9351, 0xE587, 0x9352, 0xE588,\r\n\t0x9353, 0xE589, 0x9354, 0xE58A, 0x9355, 0xE58B, 0x9356, 0xE58C,\t0x9357, 0xE58D, 0x9358, 0xE58E, 0x9359, 0xE58F, 0x935A, 0xE590,\r\n\t0x935B, 0xE591, 0x935C, 0xE592, 0x935D, 0xE593, 0x935E, 0xE594,\t0x935F, 0xE595, 0x9360, 0xE596, 0x9361, 0xE597, 0x9362, 0xE598,\r\n\t0x9363, 0xE599, 0x9364, 0xE59A, 0x9365, 0xE59B, 0x9366, 0xE59C,\t0x9367, 0xE59D, 0x9368, 0xE59E, 0x9369, 0xE59F, 0x936A, 0xF6CA,\r\n\t0x936B, 0xE5A0, 0x936C, 0xE640, 0x936D, 0xE641, 0x936E, 0xE642,\t0x936F, 0xE643, 0x9370, 0xE644, 0x9371, 0xE645, 0x9372, 0xE646,\r\n\t0x9373, 0xE647, 0x9374, 0xE648, 0x9375, 0xE649, 0x9376, 0xE64A,\t0x9377, 0xE64B, 0x9378, 0xE64C, 0x9379, 0xE64D, 0x937A, 0xE64E,\r\n\t0x937B, 0xE64F, 0x937C, 0xE650, 0x937D, 0xE651, 0x937E, 0xE652,\t0x937F, 0xE653, 0x9380, 0xE654, 0x9381, 0xE655, 0x9382, 0xE656,\r\n\t0x9383, 0xE657, 0x9384, 0xE658, 0x9385, 0xE659, 0x9386, 0xE65A,\t0x9387, 0xE65B, 0x9388, 0xE65C, 0x9389, 0xE65D, 0x938A, 0xE65E,\r\n\t0x938B, 0xE65F, 0x938C, 0xE660, 0x938D, 0xE661, 0x938E, 0xE662,\t0x938F, 0xF6CC, 0x9390, 0xE663, 0x9391, 0xE664, 0x9392, 0xE665,\r\n\t0x9393, 0xE666, 0x9394, 0xE667, 0x9395, 0xE668, 0x9396, 0xE669,\t0x9397, 0xE66A, 0x9398, 0xE66B, 0x9399, 0xE66C, 0x939A, 0xE66D,\r\n\t0x939B, 0xE66E, 0x939C, 0xE66F, 0x939D, 0xE670, 0x939E, 0xE671,\t0x939F, 0xE672, 0x93A0, 0xE673, 0x93A1, 0xE674, 0x93A2, 0xE675,\r\n\t0x93A3, 0xE676, 0x93A4, 0xE677, 0x93A5, 0xE678, 0x93A6, 0xE679,\t0x93A7, 0xE67A, 0x93A8, 0xE67B, 0x93A9, 0xE67C, 0x93AA, 0xE67D,\r\n\t0x93AB, 0xE67E, 0x93AC, 0xE680, 0x93AD, 0xE681, 0x93AE, 0xE682,\t0x93AF, 0xE683, 0x93B0, 0xE684, 0x93B1, 0xE685, 0x93B2, 0xE686,\r\n\t0x93B3, 0xE687, 0x93B4, 0xE688, 0x93B5, 0xE689, 0x93B6, 0xE68A,\t0x93B7, 0xE68B, 0x93B8, 0xE68C, 0x93B9, 0xE68D, 0x93BA, 0xE68E,\r\n\t0x93BB, 0xE68F, 0x93BC, 0xE690, 0x93BD, 0xE691, 0x93BE, 0xE692,\t0x93BF, 0xE693, 0x93C0, 0xE694, 0x93C1, 0xE695, 0x93C2, 0xE696,\r\n\t0x93C3, 0xE697, 0x93C4, 0xE698, 0x93C5, 0xE699, 0x93C6, 0xE69A,\t0x93C7, 0xE69B, 0x93C8, 0xE69C, 0x93C9, 0xE69D, 0x93CA, 0xF6CB,\r\n\t0x93CB, 0xE69E, 0x93CC, 0xE69F, 0x93CD, 0xE6A0, 0x93CE, 0xE740,\t0x93CF, 0xE741, 0x93D0, 0xE742, 0x93D1, 0xE743, 0x93D2, 0xE744,\r\n\t0x93D3, 0xE745, 0x93D4, 0xE746, 0x93D5, 0xE747, 0x93D6, 0xF7E9,\t0x93D7, 0xE748, 0x93D8, 0xE749, 0x93D9, 0xE74A, 0x93DA, 0xE74B,\r\n\t0x93DB, 0xE74C, 0x93DC, 0xE74D, 0x93DD, 0xE74E, 0x93DE, 0xE74F,\t0x93DF, 0xE750, 0x93E0, 0xE751, 0x93E1, 0xE752, 0x93E2, 0xE753,\r\n\t0x93E3, 0xE754, 0x93E4, 0xE755, 0x93E5, 0xE756, 0x93E6, 0xE757,\t0x93E7, 0xE758, 0x93E8, 0xE759, 0x93E9, 0xE75A, 0x93EA, 0xE75B,\r\n\t0x93EB, 0xE75C, 0x93EC, 0xE75D, 0x93ED, 0xE75E, 0x93EE, 0xE75F,\t0x93EF, 0xE760, 0x93F0, 0xE761, 0x93F1, 0xE762, 0x93F2, 0xE763,\r\n\t0x93F3, 0xE764, 0x93F4, 0xE765, 0x93F5, 0xE766, 0x93F6, 0xE767,\t0x93F7, 0xE768, 0x93F8, 0xE769, 0x93F9, 0xE76A, 0x93FA, 0xE76B,\r\n\t0x93FB, 0xE76C, 0x93FC, 0xE76D, 0x93FD, 0xE76E, 0x93FE, 0xE76F,\t0x93FF, 0xE770, 0x9400, 0xE771, 0x9401, 0xE772, 0x9402, 0xE773,\r\n\t0x9403, 0xE774, 0x9404, 0xE775, 0x9405, 0xE776, 0x9406, 0xE777,\t0x9407, 0xE778, 0x9408, 0xE779, 0x9409, 0xE77A, 0x940A, 0xE77B,\r\n\t0x940B, 0xE77C, 0x940C, 0xE77D, 0x940D, 0xE77E, 0x940E, 0xE780,\t0x940F, 0xE781, 0x9410, 0xE782, 0x9411, 0xE783, 0x9412, 0xE784,\r\n\t0x9413, 0xE785, 0x9414, 0xE786, 0x9415, 0xE787, 0x9416, 0xE788,\t0x9417, 0xE789, 0x9418, 0xE78A, 0x9419, 0xE78B, 0x941A, 0xE78C,\r\n\t0x941B, 0xE78D, 0x941C, 0xE78E, 0x941D, 0xE78F, 0x941E, 0xE790,\t0x941F, 0xE791, 0x9420, 0xE792, 0x9421, 0xE793, 0x9422, 0xE794,\r\n\t0x9423, 0xE795, 0x9424, 0xE796, 0x9425, 0xE797, 0x9426, 0xE798,\t0x9427, 0xE799, 0x9428, 0xE79A, 0x9429, 0xE79B, 0x942A, 0xE79C,\r\n\t0x942B, 0xE79D, 0x942C, 0xE79E, 0x942D, 0xE79F, 0x942E, 0xE7A0,\t0x942F, 0xE840, 0x9430, 0xE841, 0x9431, 0xE842, 0x9432, 0xE843,\r\n\t0x9433, 0xE844, 0x9434, 0xE845, 0x9435, 0xE846, 0x9436, 0xE847,\t0x9437, 0xE848, 0x9438, 0xE849, 0x9439, 0xE84A, 0x943A, 0xE84B,\r\n\t0x943B, 0xE84C, 0x943C, 0xE84D, 0x943D, 0xE84E, 0x943E, 0xF6CD,\t0x943F, 0xE84F, 0x9440, 0xE850, 0x9441, 0xE851, 0x9442, 0xE852,\r\n\t0x9443, 0xE853, 0x9444, 0xE854, 0x9445, 0xE855, 0x9446, 0xE856,\t0x9447, 0xE857, 0x9448, 0xE858, 0x9449, 0xE859, 0x944A, 0xE85A,\r\n\t0x944B, 0xE85B, 0x944C, 0xE85C, 0x944D, 0xE85D, 0x944E, 0xE85E,\t0x944F, 0xE85F, 0x9450, 0xE860, 0x9451, 0xE861, 0x9452, 0xE862,\r\n\t0x9453, 0xE863, 0x9454, 0xE864, 0x9455, 0xE865, 0x9456, 0xE866,\t0x9457, 0xE867, 0x9458, 0xE868, 0x9459, 0xE869, 0x945A, 0xE86A,\r\n\t0x945B, 0xE86B, 0x945C, 0xE86C, 0x945D, 0xE86D, 0x945E, 0xE86E,\t0x945F, 0xE86F, 0x9460, 0xE870, 0x9461, 0xE871, 0x9462, 0xE872,\r\n\t0x9463, 0xE873, 0x9464, 0xE874, 0x9465, 0xE875, 0x9466, 0xE876,\t0x9467, 0xE877, 0x9468, 0xE878, 0x9469, 0xE879, 0x946A, 0xE87A,\r\n\t0x946B, 0xF6CE, 0x946C, 0xE87B, 0x946D, 0xE87C, 0x946E, 0xE87D,\t0x946F, 0xE87E, 0x9470, 0xE880, 0x9471, 0xE881, 0x9472, 0xE882,\r\n\t0x9473, 0xE883, 0x9474, 0xE884, 0x9475, 0xE885, 0x9476, 0xE886,\t0x9477, 0xE887, 0x9478, 0xE888, 0x9479, 0xE889, 0x947A, 0xE88A,\r\n\t0x947B, 0xE88B, 0x947C, 0xE88C, 0x947D, 0xE88D, 0x947E, 0xE88E,\t0x947F, 0xE88F, 0x9480, 0xE890, 0x9481, 0xE891, 0x9482, 0xE892,\r\n\t0x9483, 0xE893, 0x9484, 0xE894, 0x9485, 0xEEC4, 0x9486, 0xEEC5,\t0x9487, 0xEEC6, 0x9488, 0xD5EB, 0x9489, 0xB6A4, 0x948A, 0xEEC8,\r\n\t0x948B, 0xEEC7, 0x948C, 0xEEC9, 0x948D, 0xEECA, 0x948E, 0xC7A5,\t0x948F, 0xEECB, 0x9490, 0xEECC, 0x9491, 0xE895, 0x9492, 0xB7B0,\r\n\t0x9493, 0xB5F6, 0x9494, 0xEECD, 0x9495, 0xEECF, 0x9496, 0xE896,\t0x9497, 0xEECE, 0x9498, 0xE897, 0x9499, 0xB8C6, 0x949A, 0xEED0,\r\n\t0x949B, 0xEED1, 0x949C, 0xEED2, 0x949D, 0xB6DB, 0x949E, 0xB3AE,\t0x949F, 0xD6D3, 0x94A0, 0xC4C6, 0x94A1, 0xB1B5, 0x94A2, 0xB8D6,\r\n\t0x94A3, 0xEED3, 0x94A4, 0xEED4, 0x94A5, 0xD4BF, 0x94A6, 0xC7D5,\t0x94A7, 0xBEFB, 0x94A8, 0xCED9, 0x94A9, 0xB9B3, 0x94AA, 0xEED6,\r\n\t0x94AB, 0xEED5, 0x94AC, 0xEED8, 0x94AD, 0xEED7, 0x94AE, 0xC5A5,\t0x94AF, 0xEED9, 0x94B0, 0xEEDA, 0x94B1, 0xC7AE, 0x94B2, 0xEEDB,\r\n\t0x94B3, 0xC7AF, 0x94B4, 0xEEDC, 0x94B5, 0xB2A7, 0x94B6, 0xEEDD,\t0x94B7, 0xEEDE, 0x94B8, 0xEEDF, 0x94B9, 0xEEE0, 0x94BA, 0xEEE1,\r\n\t0x94BB, 0xD7EA, 0x94BC, 0xEEE2, 0x94BD, 0xEEE3, 0x94BE, 0xBCD8,\t0x94BF, 0xEEE4, 0x94C0, 0xD3CB, 0x94C1, 0xCCFA, 0x94C2, 0xB2AC,\r\n\t0x94C3, 0xC1E5, 0x94C4, 0xEEE5, 0x94C5, 0xC7A6, 0x94C6, 0xC3AD,\t0x94C7, 0xE898, 0x94C8, 0xEEE6, 0x94C9, 0xEEE7, 0x94CA, 0xEEE8,\r\n\t0x94CB, 0xEEE9, 0x94CC, 0xEEEA, 0x94CD, 0xEEEB, 0x94CE, 0xEEEC,\t0x94CF, 0xE899, 0x94D0, 0xEEED, 0x94D1, 0xEEEE, 0x94D2, 0xEEEF,\r\n\t0x94D3, 0xE89A, 0x94D4, 0xE89B, 0x94D5, 0xEEF0, 0x94D6, 0xEEF1,\t0x94D7, 0xEEF2, 0x94D8, 0xEEF4, 0x94D9, 0xEEF3, 0x94DA, 0xE89C,\r\n\t0x94DB, 0xEEF5, 0x94DC, 0xCDAD, 0x94DD, 0xC2C1, 0x94DE, 0xEEF6,\t0x94DF, 0xEEF7, 0x94E0, 0xEEF8, 0x94E1, 0xD5A1, 0x94E2, 0xEEF9,\r\n\t0x94E3, 0xCFB3, 0x94E4, 0xEEFA, 0x94E5, 0xEEFB, 0x94E6, 0xE89D,\t0x94E7, 0xEEFC, 0x94E8, 0xEEFD, 0x94E9, 0xEFA1, 0x94EA, 0xEEFE,\r\n\t0x94EB, 0xEFA2, 0x94EC, 0xB8F5, 0x94ED, 0xC3FA, 0x94EE, 0xEFA3,\t0x94EF, 0xEFA4, 0x94F0, 0xBDC2, 0x94F1, 0xD2BF, 0x94F2, 0xB2F9,\r\n\t0x94F3, 0xEFA5, 0x94F4, 0xEFA6, 0x94F5, 0xEFA7, 0x94F6, 0xD2F8,\t0x94F7, 0xEFA8, 0x94F8, 0xD6FD, 0x94F9, 0xEFA9, 0x94FA, 0xC6CC,\r\n\t0x94FB, 0xE89E, 0x94FC, 0xEFAA, 0x94FD, 0xEFAB, 0x94FE, 0xC1B4,\t0x94FF, 0xEFAC, 0x9500, 0xCFFA, 0x9501, 0xCBF8, 0x9502, 0xEFAE,\r\n\t0x9503, 0xEFAD, 0x9504, 0xB3FA, 0x9505, 0xB9F8, 0x9506, 0xEFAF,\t0x9507, 0xEFB0, 0x9508, 0xD0E2, 0x9509, 0xEFB1, 0x950A, 0xEFB2,\r\n\t0x950B, 0xB7E6, 0x950C, 0xD0BF, 0x950D, 0xEFB3, 0x950E, 0xEFB4,\t0x950F, 0xEFB5, 0x9510, 0xC8F1, 0x9511, 0xCCE0, 0x9512, 0xEFB6,\r\n\t0x9513, 0xEFB7, 0x9514, 0xEFB8, 0x9515, 0xEFB9, 0x9516, 0xEFBA,\t0x9517, 0xD5E0, 0x9518, 0xEFBB, 0x9519, 0xB4ED, 0x951A, 0xC3AA,\r\n\t0x951B, 0xEFBC, 0x951C, 0xE89F, 0x951D, 0xEFBD, 0x951E, 0xEFBE,\t0x951F, 0xEFBF, 0x9520, 0xE8A0, 0x9521, 0xCEFD, 0x9522, 0xEFC0,\r\n\t0x9523, 0xC2E0, 0x9524, 0xB4B8, 0x9525, 0xD7B6, 0x9526, 0xBDF5,\t0x9527, 0xE940, 0x9528, 0xCFC7, 0x9529, 0xEFC3, 0x952A, 0xEFC1,\r\n\t0x952B, 0xEFC2, 0x952C, 0xEFC4, 0x952D, 0xB6A7, 0x952E, 0xBCFC,\t0x952F, 0xBEE2, 0x9530, 0xC3CC, 0x9531, 0xEFC5, 0x9532, 0xEFC6,\r\n\t0x9533, 0xE941, 0x9534, 0xEFC7, 0x9535, 0xEFCF, 0x9536, 0xEFC8,\t0x9537, 0xEFC9, 0x9538, 0xEFCA, 0x9539, 0xC7C2, 0x953A, 0xEFF1,\r\n\t0x953B, 0xB6CD, 0x953C, 0xEFCB, 0x953D, 0xE942, 0x953E, 0xEFCC,\t0x953F, 0xEFCD, 0x9540, 0xB6C6, 0x9541, 0xC3BE, 0x9542, 0xEFCE,\r\n\t0x9543, 0xE943, 0x9544, 0xEFD0, 0x9545, 0xEFD1, 0x9546, 0xEFD2,\t0x9547, 0xD5F2, 0x9548, 0xE944, 0x9549, 0xEFD3, 0x954A, 0xC4F7,\r\n\t0x954B, 0xE945, 0x954C, 0xEFD4, 0x954D, 0xC4F8, 0x954E, 0xEFD5,\t0x954F, 0xEFD6, 0x9550, 0xB8E4, 0x9551, 0xB0F7, 0x9552, 0xEFD7,\r\n\t0x9553, 0xEFD8, 0x9554, 0xEFD9, 0x9555, 0xE946, 0x9556, 0xEFDA,\t0x9557, 0xEFDB, 0x9558, 0xEFDC, 0x9559, 0xEFDD, 0x955A, 0xE947,\r\n\t0x955B, 0xEFDE, 0x955C, 0xBEB5, 0x955D, 0xEFE1, 0x955E, 0xEFDF,\t0x955F, 0xEFE0, 0x9560, 0xE948, 0x9561, 0xEFE2, 0x9562, 0xEFE3,\r\n\t0x9563, 0xC1CD, 0x9564, 0xEFE4, 0x9565, 0xEFE5, 0x9566, 0xEFE6,\t0x9567, 0xEFE7, 0x9568, 0xEFE8, 0x9569, 0xEFE9, 0x956A, 0xEFEA,\r\n\t0x956B, 0xEFEB, 0x956C, 0xEFEC, 0x956D, 0xC0D8, 0x956E, 0xE949,\t0x956F, 0xEFED, 0x9570, 0xC1AD, 0x9571, 0xEFEE, 0x9572, 0xEFEF,\r\n\t0x9573, 0xEFF0, 0x9574, 0xE94A, 0x9575, 0xE94B, 0x9576, 0xCFE2,\t0x9577, 0xE94C, 0x9578, 0xE94D, 0x9579, 0xE94E, 0x957A, 0xE94F,\r\n\t0x957B, 0xE950, 0x957C, 0xE951, 0x957D, 0xE952, 0x957E, 0xE953,\t0x957F, 0xB3A4, 0x9580, 0xE954, 0x9581, 0xE955, 0x9582, 0xE956,\r\n\t0x9583, 0xE957, 0x9584, 0xE958, 0x9585, 0xE959, 0x9586, 0xE95A,\t0x9587, 0xE95B, 0x9588, 0xE95C, 0x9589, 0xE95D, 0x958A, 0xE95E,\r\n\t0x958B, 0xE95F, 0x958C, 0xE960, 0x958D, 0xE961, 0x958E, 0xE962,\t0x958F, 0xE963, 0x9590, 0xE964, 0x9591, 0xE965, 0x9592, 0xE966,\r\n\t0x9593, 0xE967, 0x9594, 0xE968, 0x9595, 0xE969, 0x9596, 0xE96A,\t0x9597, 0xE96B, 0x9598, 0xE96C, 0x9599, 0xE96D, 0x959A, 0xE96E,\r\n\t0x959B, 0xE96F, 0x959C, 0xE970, 0x959D, 0xE971, 0x959E, 0xE972,\t0x959F, 0xE973, 0x95A0, 0xE974, 0x95A1, 0xE975, 0x95A2, 0xE976,\r\n\t0x95A3, 0xE977, 0x95A4, 0xE978, 0x95A5, 0xE979, 0x95A6, 0xE97A,\t0x95A7, 0xE97B, 0x95A8, 0xE97C, 0x95A9, 0xE97D, 0x95AA, 0xE97E,\r\n\t0x95AB, 0xE980, 0x95AC, 0xE981, 0x95AD, 0xE982, 0x95AE, 0xE983,\t0x95AF, 0xE984, 0x95B0, 0xE985, 0x95B1, 0xE986, 0x95B2, 0xE987,\r\n\t0x95B3, 0xE988, 0x95B4, 0xE989, 0x95B5, 0xE98A, 0x95B6, 0xE98B,\t0x95B7, 0xE98C, 0x95B8, 0xE98D, 0x95B9, 0xE98E, 0x95BA, 0xE98F,\r\n\t0x95BB, 0xE990, 0x95BC, 0xE991, 0x95BD, 0xE992, 0x95BE, 0xE993,\t0x95BF, 0xE994, 0x95C0, 0xE995, 0x95C1, 0xE996, 0x95C2, 0xE997,\r\n\t0x95C3, 0xE998, 0x95C4, 0xE999, 0x95C5, 0xE99A, 0x95C6, 0xE99B,\t0x95C7, 0xE99C, 0x95C8, 0xE99D, 0x95C9, 0xE99E, 0x95CA, 0xE99F,\r\n\t0x95CB, 0xE9A0, 0x95CC, 0xEA40, 0x95CD, 0xEA41, 0x95CE, 0xEA42,\t0x95CF, 0xEA43, 0x95D0, 0xEA44, 0x95D1, 0xEA45, 0x95D2, 0xEA46,\r\n\t0x95D3, 0xEA47, 0x95D4, 0xEA48, 0x95D5, 0xEA49, 0x95D6, 0xEA4A,\t0x95D7, 0xEA4B, 0x95D8, 0xEA4C, 0x95D9, 0xEA4D, 0x95DA, 0xEA4E,\r\n\t0x95DB, 0xEA4F, 0x95DC, 0xEA50, 0x95DD, 0xEA51, 0x95DE, 0xEA52,\t0x95DF, 0xEA53, 0x95E0, 0xEA54, 0x95E1, 0xEA55, 0x95E2, 0xEA56,\r\n\t0x95E3, 0xEA57, 0x95E4, 0xEA58, 0x95E5, 0xEA59, 0x95E6, 0xEA5A,\t0x95E7, 0xEA5B, 0x95E8, 0xC3C5, 0x95E9, 0xE3C5, 0x95EA, 0xC9C1,\r\n\t0x95EB, 0xE3C6, 0x95EC, 0xEA5C, 0x95ED, 0xB1D5, 0x95EE, 0xCECA,\t0x95EF, 0xB4B3, 0x95F0, 0xC8F2, 0x95F1, 0xE3C7, 0x95F2, 0xCFD0,\r\n\t0x95F3, 0xE3C8, 0x95F4, 0xBCE4, 0x95F5, 0xE3C9, 0x95F6, 0xE3CA,\t0x95F7, 0xC3C6, 0x95F8, 0xD5A2, 0x95F9, 0xC4D6, 0x95FA, 0xB9EB,\r\n\t0x95FB, 0xCEC5, 0x95FC, 0xE3CB, 0x95FD, 0xC3F6, 0x95FE, 0xE3CC,\t0x95FF, 0xEA5D, 0x9600, 0xB7A7, 0x9601, 0xB8F3, 0x9602, 0xBAD2,\r\n\t0x9603, 0xE3CD, 0x9604, 0xE3CE, 0x9605, 0xD4C4, 0x9606, 0xE3CF,\t0x9607, 0xEA5E, 0x9608, 0xE3D0, 0x9609, 0xD1CB, 0x960A, 0xE3D1,\r\n\t0x960B, 0xE3D2, 0x960C, 0xE3D3, 0x960D, 0xE3D4, 0x960E, 0xD1D6,\t0x960F, 0xE3D5, 0x9610, 0xB2FB, 0x9611, 0xC0BB, 0x9612, 0xE3D6,\r\n\t0x9613, 0xEA5F, 0x9614, 0xC0AB, 0x9615, 0xE3D7, 0x9616, 0xE3D8,\t0x9617, 0xE3D9, 0x9618, 0xEA60, 0x9619, 0xE3DA, 0x961A, 0xE3DB,\r\n\t0x961B, 0xEA61, 0x961C, 0xB8B7, 0x961D, 0xDAE2, 0x961E, 0xEA62,\t0x961F, 0xB6D3, 0x9620, 0xEA63, 0x9621, 0xDAE4, 0x9622, 0xDAE3,\r\n\t0x9623, 0xEA64, 0x9624, 0xEA65, 0x9625, 0xEA66, 0x9626, 0xEA67,\t0x9627, 0xEA68, 0x9628, 0xEA69, 0x9629, 0xEA6A, 0x962A, 0xDAE6,\r\n\t0x962B, 0xEA6B, 0x962C, 0xEA6C, 0x962D, 0xEA6D, 0x962E, 0xC8EE,\t0x962F, 0xEA6E, 0x9630, 0xEA6F, 0x9631, 0xDAE5, 0x9632, 0xB7C0,\r\n\t0x9633, 0xD1F4, 0x9634, 0xD2F5, 0x9635, 0xD5F3, 0x9636, 0xBDD7,\t0x9637, 0xEA70, 0x9638, 0xEA71, 0x9639, 0xEA72, 0x963A, 0xEA73,\r\n\t0x963B, 0xD7E8, 0x963C, 0xDAE8, 0x963D, 0xDAE7, 0x963E, 0xEA74,\t0x963F, 0xB0A2, 0x9640, 0xCDD3, 0x9641, 0xEA75, 0x9642, 0xDAE9,\r\n\t0x9643, 0xEA76, 0x9644, 0xB8BD, 0x9645, 0xBCCA, 0x9646, 0xC2BD,\t0x9647, 0xC2A4, 0x9648, 0xB3C2, 0x9649, 0xDAEA, 0x964A, 0xEA77,\r\n\t0x964B, 0xC2AA, 0x964C, 0xC4B0, 0x964D, 0xBDB5, 0x964E, 0xEA78,\t0x964F, 0xEA79, 0x9650, 0xCFDE, 0x9651, 0xEA7A, 0x9652, 0xEA7B,\r\n\t0x9653, 0xEA7C, 0x9654, 0xDAEB, 0x9655, 0xC9C2, 0x9656, 0xEA7D,\t0x9657, 0xEA7E, 0x9658, 0xEA80, 0x9659, 0xEA81, 0x965A, 0xEA82,\r\n\t0x965B, 0xB1DD, 0x965C, 0xEA83, 0x965D, 0xEA84, 0x965E, 0xEA85,\t0x965F, 0xDAEC, 0x9660, 0xEA86, 0x9661, 0xB6B8, 0x9662, 0xD4BA,\r\n\t0x9663, 0xEA87, 0x9664, 0xB3FD, 0x9665, 0xEA88, 0x9666, 0xEA89,\t0x9667, 0xDAED, 0x9668, 0xD4C9, 0x9669, 0xCFD5, 0x966A, 0xC5E3,\r\n\t0x966B, 0xEA8A, 0x966C, 0xDAEE, 0x966D, 0xEA8B, 0x966E, 0xEA8C,\t0x966F, 0xEA8D, 0x9670, 0xEA8E, 0x9671, 0xEA8F, 0x9672, 0xDAEF,\r\n\t0x9673, 0xEA90, 0x9674, 0xDAF0, 0x9675, 0xC1EA, 0x9676, 0xCCD5,\t0x9677, 0xCFDD, 0x9678, 0xEA91, 0x9679, 0xEA92, 0x967A, 0xEA93,\r\n\t0x967B, 0xEA94, 0x967C, 0xEA95, 0x967D, 0xEA96, 0x967E, 0xEA97,\t0x967F, 0xEA98, 0x9680, 0xEA99, 0x9681, 0xEA9A, 0x9682, 0xEA9B,\r\n\t0x9683, 0xEA9C, 0x9684, 0xEA9D, 0x9685, 0xD3E7, 0x9686, 0xC2A1,\t0x9687, 0xEA9E, 0x9688, 0xDAF1, 0x9689, 0xEA9F, 0x968A, 0xEAA0,\r\n\t0x968B, 0xCBE5, 0x968C, 0xEB40, 0x968D, 0xDAF2, 0x968E, 0xEB41,\t0x968F, 0xCBE6, 0x9690, 0xD2FE, 0x9691, 0xEB42, 0x9692, 0xEB43,\r\n\t0x9693, 0xEB44, 0x9694, 0xB8F4, 0x9695, 0xEB45, 0x9696, 0xEB46,\t0x9697, 0xDAF3, 0x9698, 0xB0AF, 0x9699, 0xCFB6, 0x969A, 0xEB47,\r\n\t0x969B, 0xEB48, 0x969C, 0xD5CF, 0x969D, 0xEB49, 0x969E, 0xEB4A,\t0x969F, 0xEB4B, 0x96A0, 0xEB4C, 0x96A1, 0xEB4D, 0x96A2, 0xEB4E,\r\n\t0x96A3, 0xEB4F, 0x96A4, 0xEB50, 0x96A5, 0xEB51, 0x96A6, 0xEB52,\t0x96A7, 0xCBED, 0x96A8, 0xEB53, 0x96A9, 0xEB54, 0x96AA, 0xEB55,\r\n\t0x96AB, 0xEB56, 0x96AC, 0xEB57, 0x96AD, 0xEB58, 0x96AE, 0xEB59,\t0x96AF, 0xEB5A, 0x96B0, 0xDAF4, 0x96B1, 0xEB5B, 0x96B2, 0xEB5C,\r\n\t0x96B3, 0xE3C4, 0x96B4, 0xEB5D, 0x96B5, 0xEB5E, 0x96B6, 0xC1A5,\t0x96B7, 0xEB5F, 0x96B8, 0xEB60, 0x96B9, 0xF6BF, 0x96BA, 0xEB61,\r\n\t0x96BB, 0xEB62, 0x96BC, 0xF6C0, 0x96BD, 0xF6C1, 0x96BE, 0xC4D1,\t0x96BF, 0xEB63, 0x96C0, 0xC8B8, 0x96C1, 0xD1E3, 0x96C2, 0xEB64,\r\n\t0x96C3, 0xEB65, 0x96C4, 0xD0DB, 0x96C5, 0xD1C5, 0x96C6, 0xBCAF,\t0x96C7, 0xB9CD, 0x96C8, 0xEB66, 0x96C9, 0xEFF4, 0x96CA, 0xEB67,\r\n\t0x96CB, 0xEB68, 0x96CC, 0xB4C6, 0x96CD, 0xD3BA, 0x96CE, 0xF6C2,\t0x96CF, 0xB3FB, 0x96D0, 0xEB69, 0x96D1, 0xEB6A, 0x96D2, 0xF6C3,\r\n\t0x96D3, 0xEB6B, 0x96D4, 0xEB6C, 0x96D5, 0xB5F1, 0x96D6, 0xEB6D,\t0x96D7, 0xEB6E, 0x96D8, 0xEB6F, 0x96D9, 0xEB70, 0x96DA, 0xEB71,\r\n\t0x96DB, 0xEB72, 0x96DC, 0xEB73, 0x96DD, 0xEB74, 0x96DE, 0xEB75,\t0x96DF, 0xEB76, 0x96E0, 0xF6C5, 0x96E1, 0xEB77, 0x96E2, 0xEB78,\r\n\t0x96E3, 0xEB79, 0x96E4, 0xEB7A, 0x96E5, 0xEB7B, 0x96E6, 0xEB7C,\t0x96E7, 0xEB7D, 0x96E8, 0xD3EA, 0x96E9, 0xF6A7, 0x96EA, 0xD1A9,\r\n\t0x96EB, 0xEB7E, 0x96EC, 0xEB80, 0x96ED, 0xEB81, 0x96EE, 0xEB82,\t0x96EF, 0xF6A9, 0x96F0, 0xEB83, 0x96F1, 0xEB84, 0x96F2, 0xEB85,\r\n\t0x96F3, 0xF6A8, 0x96F4, 0xEB86, 0x96F5, 0xEB87, 0x96F6, 0xC1E3,\t0x96F7, 0xC0D7, 0x96F8, 0xEB88, 0x96F9, 0xB1A2, 0x96FA, 0xEB89,\r\n\t0x96FB, 0xEB8A, 0x96FC, 0xEB8B, 0x96FD, 0xEB8C, 0x96FE, 0xCEED,\t0x96FF, 0xEB8D, 0x9700, 0xD0E8, 0x9701, 0xF6AB, 0x9702, 0xEB8E,\r\n\t0x9703, 0xEB8F, 0x9704, 0xCFF6, 0x9705, 0xEB90, 0x9706, 0xF6AA,\t0x9707, 0xD5F0, 0x9708, 0xF6AC, 0x9709, 0xC3B9, 0x970A, 0xEB91,\r\n\t0x970B, 0xEB92, 0x970C, 0xEB93, 0x970D, 0xBBF4, 0x970E, 0xF6AE,\t0x970F, 0xF6AD, 0x9710, 0xEB94, 0x9711, 0xEB95, 0x9712, 0xEB96,\r\n\t0x9713, 0xC4DE, 0x9714, 0xEB97, 0x9715, 0xEB98, 0x9716, 0xC1D8,\t0x9717, 0xEB99, 0x9718, 0xEB9A, 0x9719, 0xEB9B, 0x971A, 0xEB9C,\r\n\t0x971B, 0xEB9D, 0x971C, 0xCBAA, 0x971D, 0xEB9E, 0x971E, 0xCFBC,\t0x971F, 0xEB9F, 0x9720, 0xEBA0, 0x9721, 0xEC40, 0x9722, 0xEC41,\r\n\t0x9723, 0xEC42, 0x9724, 0xEC43, 0x9725, 0xEC44, 0x9726, 0xEC45,\t0x9727, 0xEC46, 0x9728, 0xEC47, 0x9729, 0xEC48, 0x972A, 0xF6AF,\r\n\t0x972B, 0xEC49, 0x972C, 0xEC4A, 0x972D, 0xF6B0, 0x972E, 0xEC4B,\t0x972F, 0xEC4C, 0x9730, 0xF6B1, 0x9731, 0xEC4D, 0x9732, 0xC2B6,\r\n\t0x9733, 0xEC4E, 0x9734, 0xEC4F, 0x9735, 0xEC50, 0x9736, 0xEC51,\t0x9737, 0xEC52, 0x9738, 0xB0D4, 0x9739, 0xC5F9, 0x973A, 0xEC53,\r\n\t0x973B, 0xEC54, 0x973C, 0xEC55, 0x973D, 0xEC56, 0x973E, 0xF6B2,\t0x973F, 0xEC57, 0x9740, 0xEC58, 0x9741, 0xEC59, 0x9742, 0xEC5A,\r\n\t0x9743, 0xEC5B, 0x9744, 0xEC5C, 0x9745, 0xEC5D, 0x9746, 0xEC5E,\t0x9747, 0xEC5F, 0x9748, 0xEC60, 0x9749, 0xEC61, 0x974A, 0xEC62,\r\n\t0x974B, 0xEC63, 0x974C, 0xEC64, 0x974D, 0xEC65, 0x974E, 0xEC66,\t0x974F, 0xEC67, 0x9750, 0xEC68, 0x9751, 0xEC69, 0x9752, 0xC7E0,\r\n\t0x9753, 0xF6A6, 0x9754, 0xEC6A, 0x9755, 0xEC6B, 0x9756, 0xBEB8,\t0x9757, 0xEC6C, 0x9758, 0xEC6D, 0x9759, 0xBEB2, 0x975A, 0xEC6E,\r\n\t0x975B, 0xB5E5, 0x975C, 0xEC6F, 0x975D, 0xEC70, 0x975E, 0xB7C7,\t0x975F, 0xEC71, 0x9760, 0xBFBF, 0x9761, 0xC3D2, 0x9762, 0xC3E6,\r\n\t0x9763, 0xEC72, 0x9764, 0xEC73, 0x9765, 0xD8CC, 0x9766, 0xEC74,\t0x9767, 0xEC75, 0x9768, 0xEC76, 0x9769, 0xB8EF, 0x976A, 0xEC77,\r\n\t0x976B, 0xEC78, 0x976C, 0xEC79, 0x976D, 0xEC7A, 0x976E, 0xEC7B,\t0x976F, 0xEC7C, 0x9770, 0xEC7D, 0x9771, 0xEC7E, 0x9772, 0xEC80,\r\n\t0x9773, 0xBDF9, 0x9774, 0xD1A5, 0x9775, 0xEC81, 0x9776, 0xB0D0,\t0x9777, 0xEC82, 0x9778, 0xEC83, 0x9779, 0xEC84, 0x977A, 0xEC85,\r\n\t0x977B, 0xEC86, 0x977C, 0xF7B0, 0x977D, 0xEC87, 0x977E, 0xEC88,\t0x977F, 0xEC89, 0x9780, 0xEC8A, 0x9781, 0xEC8B, 0x9782, 0xEC8C,\r\n\t0x9783, 0xEC8D, 0x9784, 0xEC8E, 0x9785, 0xF7B1, 0x9786, 0xEC8F,\t0x9787, 0xEC90, 0x9788, 0xEC91, 0x9789, 0xEC92, 0x978A, 0xEC93,\r\n\t0x978B, 0xD0AC, 0x978C, 0xEC94, 0x978D, 0xB0B0, 0x978E, 0xEC95,\t0x978F, 0xEC96, 0x9790, 0xEC97, 0x9791, 0xF7B2, 0x9792, 0xF7B3,\r\n\t0x9793, 0xEC98, 0x9794, 0xF7B4, 0x9795, 0xEC99, 0x9796, 0xEC9A,\t0x9797, 0xEC9B, 0x9798, 0xC7CA, 0x9799, 0xEC9C, 0x979A, 0xEC9D,\r\n\t0x979B, 0xEC9E, 0x979C, 0xEC9F, 0x979D, 0xECA0, 0x979E, 0xED40,\t0x979F, 0xED41, 0x97A0, 0xBECF, 0x97A1, 0xED42, 0x97A2, 0xED43,\r\n\t0x97A3, 0xF7B7, 0x97A4, 0xED44, 0x97A5, 0xED45, 0x97A6, 0xED46,\t0x97A7, 0xED47, 0x97A8, 0xED48, 0x97A9, 0xED49, 0x97AA, 0xED4A,\r\n\t0x97AB, 0xF7B6, 0x97AC, 0xED4B, 0x97AD, 0xB1DE, 0x97AE, 0xED4C,\t0x97AF, 0xF7B5, 0x97B0, 0xED4D, 0x97B1, 0xED4E, 0x97B2, 0xF7B8,\r\n\t0x97B3, 0xED4F, 0x97B4, 0xF7B9, 0x97B5, 0xED50, 0x97B6, 0xED51,\t0x97B7, 0xED52, 0x97B8, 0xED53, 0x97B9, 0xED54, 0x97BA, 0xED55,\r\n\t0x97BB, 0xED56, 0x97BC, 0xED57, 0x97BD, 0xED58, 0x97BE, 0xED59,\t0x97BF, 0xED5A, 0x97C0, 0xED5B, 0x97C1, 0xED5C, 0x97C2, 0xED5D,\r\n\t0x97C3, 0xED5E, 0x97C4, 0xED5F, 0x97C5, 0xED60, 0x97C6, 0xED61,\t0x97C7, 0xED62, 0x97C8, 0xED63, 0x97C9, 0xED64, 0x97CA, 0xED65,\r\n\t0x97CB, 0xED66, 0x97CC, 0xED67, 0x97CD, 0xED68, 0x97CE, 0xED69,\t0x97CF, 0xED6A, 0x97D0, 0xED6B, 0x97D1, 0xED6C, 0x97D2, 0xED6D,\r\n\t0x97D3, 0xED6E, 0x97D4, 0xED6F, 0x97D5, 0xED70, 0x97D6, 0xED71,\t0x97D7, 0xED72, 0x97D8, 0xED73, 0x97D9, 0xED74, 0x97DA, 0xED75,\r\n\t0x97DB, 0xED76, 0x97DC, 0xED77, 0x97DD, 0xED78, 0x97DE, 0xED79,\t0x97DF, 0xED7A, 0x97E0, 0xED7B, 0x97E1, 0xED7C, 0x97E2, 0xED7D,\r\n\t0x97E3, 0xED7E, 0x97E4, 0xED80, 0x97E5, 0xED81, 0x97E6, 0xCEA4,\t0x97E7, 0xC8CD, 0x97E8, 0xED82, 0x97E9, 0xBAAB, 0x97EA, 0xE8B8,\r\n\t0x97EB, 0xE8B9, 0x97EC, 0xE8BA, 0x97ED, 0xBEC2, 0x97EE, 0xED83,\t0x97EF, 0xED84, 0x97F0, 0xED85, 0x97F1, 0xED86, 0x97F2, 0xED87,\r\n\t0x97F3, 0xD2F4, 0x97F4, 0xED88, 0x97F5, 0xD4CF, 0x97F6, 0xC9D8,\t0x97F7, 0xED89, 0x97F8, 0xED8A, 0x97F9, 0xED8B, 0x97FA, 0xED8C,\r\n\t0x97FB, 0xED8D, 0x97FC, 0xED8E, 0x97FD, 0xED8F, 0x97FE, 0xED90,\t0x97FF, 0xED91, 0x9800, 0xED92, 0x9801, 0xED93, 0x9802, 0xED94,\r\n\t0x9803, 0xED95, 0x9804, 0xED96, 0x9805, 0xED97, 0x9806, 0xED98,\t0x9807, 0xED99, 0x9808, 0xED9A, 0x9809, 0xED9B, 0x980A, 0xED9C,\r\n\t0x980B, 0xED9D, 0x980C, 0xED9E, 0x980D, 0xED9F, 0x980E, 0xEDA0,\t0x980F, 0xEE40, 0x9810, 0xEE41, 0x9811, 0xEE42, 0x9812, 0xEE43,\r\n\t0x9813, 0xEE44, 0x9814, 0xEE45, 0x9815, 0xEE46, 0x9816, 0xEE47,\t0x9817, 0xEE48, 0x9818, 0xEE49, 0x9819, 0xEE4A, 0x981A, 0xEE4B,\r\n\t0x981B, 0xEE4C, 0x981C, 0xEE4D, 0x981D, 0xEE4E, 0x981E, 0xEE4F,\t0x981F, 0xEE50, 0x9820, 0xEE51, 0x9821, 0xEE52, 0x9822, 0xEE53,\r\n\t0x9823, 0xEE54, 0x9824, 0xEE55, 0x9825, 0xEE56, 0x9826, 0xEE57,\t0x9827, 0xEE58, 0x9828, 0xEE59, 0x9829, 0xEE5A, 0x982A, 0xEE5B,\r\n\t0x982B, 0xEE5C, 0x982C, 0xEE5D, 0x982D, 0xEE5E, 0x982E, 0xEE5F,\t0x982F, 0xEE60, 0x9830, 0xEE61, 0x9831, 0xEE62, 0x9832, 0xEE63,\r\n\t0x9833, 0xEE64, 0x9834, 0xEE65, 0x9835, 0xEE66, 0x9836, 0xEE67,\t0x9837, 0xEE68, 0x9838, 0xEE69, 0x9839, 0xEE6A, 0x983A, 0xEE6B,\r\n\t0x983B, 0xEE6C, 0x983C, 0xEE6D, 0x983D, 0xEE6E, 0x983E, 0xEE6F,\t0x983F, 0xEE70, 0x9840, 0xEE71, 0x9841, 0xEE72, 0x9842, 0xEE73,\r\n\t0x9843, 0xEE74, 0x9844, 0xEE75, 0x9845, 0xEE76, 0x9846, 0xEE77,\t0x9847, 0xEE78, 0x9848, 0xEE79, 0x9849, 0xEE7A, 0x984A, 0xEE7B,\r\n\t0x984B, 0xEE7C, 0x984C, 0xEE7D, 0x984D, 0xEE7E, 0x984E, 0xEE80,\t0x984F, 0xEE81, 0x9850, 0xEE82, 0x9851, 0xEE83, 0x9852, 0xEE84,\r\n\t0x9853, 0xEE85, 0x9854, 0xEE86, 0x9855, 0xEE87, 0x9856, 0xEE88,\t0x9857, 0xEE89, 0x9858, 0xEE8A, 0x9859, 0xEE8B, 0x985A, 0xEE8C,\r\n\t0x985B, 0xEE8D, 0x985C, 0xEE8E, 0x985D, 0xEE8F, 0x985E, 0xEE90,\t0x985F, 0xEE91, 0x9860, 0xEE92, 0x9861, 0xEE93, 0x9862, 0xEE94,\r\n\t0x9863, 0xEE95, 0x9864, 0xEE96, 0x9865, 0xEE97, 0x9866, 0xEE98,\t0x9867, 0xEE99, 0x9868, 0xEE9A, 0x9869, 0xEE9B, 0x986A, 0xEE9C,\r\n\t0x986B, 0xEE9D, 0x986C, 0xEE9E, 0x986D, 0xEE9F, 0x986E, 0xEEA0,\t0x986F, 0xEF40, 0x9870, 0xEF41, 0x9871, 0xEF42, 0x9872, 0xEF43,\r\n\t0x9873, 0xEF44, 0x9874, 0xEF45, 0x9875, 0xD2B3, 0x9876, 0xB6A5,\t0x9877, 0xC7EA, 0x9878, 0xF1FC, 0x9879, 0xCFEE, 0x987A, 0xCBB3,\r\n\t0x987B, 0xD0EB, 0x987C, 0xE7EF, 0x987D, 0xCDE7, 0x987E, 0xB9CB,\t0x987F, 0xB6D9, 0x9880, 0xF1FD, 0x9881, 0xB0E4, 0x9882, 0xCBCC,\r\n\t0x9883, 0xF1FE, 0x9884, 0xD4A4, 0x9885, 0xC2AD, 0x9886, 0xC1EC,\t0x9887, 0xC6C4, 0x9888, 0xBEB1, 0x9889, 0xF2A1, 0x988A, 0xBCD5,\r\n\t0x988B, 0xEF46, 0x988C, 0xF2A2, 0x988D, 0xF2A3, 0x988E, 0xEF47,\t0x988F, 0xF2A4, 0x9890, 0xD2C3, 0x9891, 0xC6B5, 0x9892, 0xEF48,\r\n\t0x9893, 0xCDC7, 0x9894, 0xF2A5, 0x9895, 0xEF49, 0x9896, 0xD3B1,\t0x9897, 0xBFC5, 0x9898, 0xCCE2, 0x9899, 0xEF4A, 0x989A, 0xF2A6,\r\n\t0x989B, 0xF2A7, 0x989C, 0xD1D5, 0x989D, 0xB6EE, 0x989E, 0xF2A8,\t0x989F, 0xF2A9, 0x98A0, 0xB5DF, 0x98A1, 0xF2AA, 0x98A2, 0xF2AB,\r\n\t0x98A3, 0xEF4B, 0x98A4, 0xB2FC, 0x98A5, 0xF2AC, 0x98A6, 0xF2AD,\t0x98A7, 0xC8A7, 0x98A8, 0xEF4C, 0x98A9, 0xEF4D, 0x98AA, 0xEF4E,\r\n\t0x98AB, 0xEF4F, 0x98AC, 0xEF50, 0x98AD, 0xEF51, 0x98AE, 0xEF52,\t0x98AF, 0xEF53, 0x98B0, 0xEF54, 0x98B1, 0xEF55, 0x98B2, 0xEF56,\r\n\t0x98B3, 0xEF57, 0x98B4, 0xEF58, 0x98B5, 0xEF59, 0x98B6, 0xEF5A,\t0x98B7, 0xEF5B, 0x98B8, 0xEF5C, 0x98B9, 0xEF5D, 0x98BA, 0xEF5E,\r\n\t0x98BB, 0xEF5F, 0x98BC, 0xEF60, 0x98BD, 0xEF61, 0x98BE, 0xEF62,\t0x98BF, 0xEF63, 0x98C0, 0xEF64, 0x98C1, 0xEF65, 0x98C2, 0xEF66,\r\n\t0x98C3, 0xEF67, 0x98C4, 0xEF68, 0x98C5, 0xEF69, 0x98C6, 0xEF6A,\t0x98C7, 0xEF6B, 0x98C8, 0xEF6C, 0x98C9, 0xEF6D, 0x98CA, 0xEF6E,\r\n\t0x98CB, 0xEF6F, 0x98CC, 0xEF70, 0x98CD, 0xEF71, 0x98CE, 0xB7E7,\t0x98CF, 0xEF72, 0x98D0, 0xEF73, 0x98D1, 0xECA9, 0x98D2, 0xECAA,\r\n\t0x98D3, 0xECAB, 0x98D4, 0xEF74, 0x98D5, 0xECAC, 0x98D6, 0xEF75,\t0x98D7, 0xEF76, 0x98D8, 0xC6AE, 0x98D9, 0xECAD, 0x98DA, 0xECAE,\r\n\t0x98DB, 0xEF77, 0x98DC, 0xEF78, 0x98DD, 0xEF79, 0x98DE, 0xB7C9,\t0x98DF, 0xCAB3, 0x98E0, 0xEF7A, 0x98E1, 0xEF7B, 0x98E2, 0xEF7C,\r\n\t0x98E3, 0xEF7D, 0x98E4, 0xEF7E, 0x98E5, 0xEF80, 0x98E6, 0xEF81,\t0x98E7, 0xE2B8, 0x98E8, 0xF7CF, 0x98E9, 0xEF82, 0x98EA, 0xEF83,\r\n\t0x98EB, 0xEF84, 0x98EC, 0xEF85, 0x98ED, 0xEF86, 0x98EE, 0xEF87,\t0x98EF, 0xEF88, 0x98F0, 0xEF89, 0x98F1, 0xEF8A, 0x98F2, 0xEF8B,\r\n\t0x98F3, 0xEF8C, 0x98F4, 0xEF8D, 0x98F5, 0xEF8E, 0x98F6, 0xEF8F,\t0x98F7, 0xEF90, 0x98F8, 0xEF91, 0x98F9, 0xEF92, 0x98FA, 0xEF93,\r\n\t0x98FB, 0xEF94, 0x98FC, 0xEF95, 0x98FD, 0xEF96, 0x98FE, 0xEF97,\t0x98FF, 0xEF98, 0x9900, 0xEF99, 0x9901, 0xEF9A, 0x9902, 0xEF9B,\r\n\t0x9903, 0xEF9C, 0x9904, 0xEF9D, 0x9905, 0xEF9E, 0x9906, 0xEF9F,\t0x9907, 0xEFA0, 0x9908, 0xF040, 0x9909, 0xF041, 0x990A, 0xF042,\r\n\t0x990B, 0xF043, 0x990C, 0xF044, 0x990D, 0xF7D0, 0x990E, 0xF045,\t0x990F, 0xF046, 0x9910, 0xB2CD, 0x9911, 0xF047, 0x9912, 0xF048,\r\n\t0x9913, 0xF049, 0x9914, 0xF04A, 0x9915, 0xF04B, 0x9916, 0xF04C,\t0x9917, 0xF04D, 0x9918, 0xF04E, 0x9919, 0xF04F, 0x991A, 0xF050,\r\n\t0x991B, 0xF051, 0x991C, 0xF052, 0x991D, 0xF053, 0x991E, 0xF054,\t0x991F, 0xF055, 0x9920, 0xF056, 0x9921, 0xF057, 0x9922, 0xF058,\r\n\t0x9923, 0xF059, 0x9924, 0xF05A, 0x9925, 0xF05B, 0x9926, 0xF05C,\t0x9927, 0xF05D, 0x9928, 0xF05E, 0x9929, 0xF05F, 0x992A, 0xF060,\r\n\t0x992B, 0xF061, 0x992C, 0xF062, 0x992D, 0xF063, 0x992E, 0xF7D1,\t0x992F, 0xF064, 0x9930, 0xF065, 0x9931, 0xF066, 0x9932, 0xF067,\r\n\t0x9933, 0xF068, 0x9934, 0xF069, 0x9935, 0xF06A, 0x9936, 0xF06B,\t0x9937, 0xF06C, 0x9938, 0xF06D, 0x9939, 0xF06E, 0x993A, 0xF06F,\r\n\t0x993B, 0xF070, 0x993C, 0xF071, 0x993D, 0xF072, 0x993E, 0xF073,\t0x993F, 0xF074, 0x9940, 0xF075, 0x9941, 0xF076, 0x9942, 0xF077,\r\n\t0x9943, 0xF078, 0x9944, 0xF079, 0x9945, 0xF07A, 0x9946, 0xF07B,\t0x9947, 0xF07C, 0x9948, 0xF07D, 0x9949, 0xF07E, 0x994A, 0xF080,\r\n\t0x994B, 0xF081, 0x994C, 0xF082, 0x994D, 0xF083, 0x994E, 0xF084,\t0x994F, 0xF085, 0x9950, 0xF086, 0x9951, 0xF087, 0x9952, 0xF088,\r\n\t0x9953, 0xF089, 0x9954, 0xF7D3, 0x9955, 0xF7D2, 0x9956, 0xF08A,\t0x9957, 0xF08B, 0x9958, 0xF08C, 0x9959, 0xF08D, 0x995A, 0xF08E,\r\n\t0x995B, 0xF08F, 0x995C, 0xF090, 0x995D, 0xF091, 0x995E, 0xF092,\t0x995F, 0xF093, 0x9960, 0xF094, 0x9961, 0xF095, 0x9962, 0xF096,\r\n\t0x9963, 0xE2BB, 0x9964, 0xF097, 0x9965, 0xBCA2, 0x9966, 0xF098,\t0x9967, 0xE2BC, 0x9968, 0xE2BD, 0x9969, 0xE2BE, 0x996A, 0xE2BF,\r\n\t0x996B, 0xE2C0, 0x996C, 0xE2C1, 0x996D, 0xB7B9, 0x996E, 0xD2FB,\t0x996F, 0xBDA4, 0x9970, 0xCACE, 0x9971, 0xB1A5, 0x9972, 0xCBC7,\r\n\t0x9973, 0xF099, 0x9974, 0xE2C2, 0x9975, 0xB6FC, 0x9976, 0xC8C4,\t0x9977, 0xE2C3, 0x9978, 0xF09A, 0x9979, 0xF09B, 0x997A, 0xBDC8,\r\n\t0x997B, 0xF09C, 0x997C, 0xB1FD, 0x997D, 0xE2C4, 0x997E, 0xF09D,\t0x997F, 0xB6F6, 0x9980, 0xE2C5, 0x9981, 0xC4D9, 0x9982, 0xF09E,\r\n\t0x9983, 0xF09F, 0x9984, 0xE2C6, 0x9985, 0xCFDA, 0x9986, 0xB9DD,\t0x9987, 0xE2C7, 0x9988, 0xC0A1, 0x9989, 0xF0A0, 0x998A, 0xE2C8,\r\n\t0x998B, 0xB2F6, 0x998C, 0xF140, 0x998D, 0xE2C9, 0x998E, 0xF141,\t0x998F, 0xC1F3, 0x9990, 0xE2CA, 0x9991, 0xE2CB, 0x9992, 0xC2F8,\r\n\t0x9993, 0xE2CC, 0x9994, 0xE2CD, 0x9995, 0xE2CE, 0x9996, 0xCAD7,\t0x9997, 0xD8B8, 0x9998, 0xD9E5, 0x9999, 0xCFE3, 0x999A, 0xF142,\r\n\t0x999B, 0xF143, 0x999C, 0xF144, 0x999D, 0xF145, 0x999E, 0xF146,\t0x999F, 0xF147, 0x99A0, 0xF148, 0x99A1, 0xF149, 0x99A2, 0xF14A,\r\n\t0x99A3, 0xF14B, 0x99A4, 0xF14C, 0x99A5, 0xF0A5, 0x99A6, 0xF14D,\t0x99A7, 0xF14E, 0x99A8, 0xDCB0, 0x99A9, 0xF14F, 0x99AA, 0xF150,\r\n\t0x99AB, 0xF151, 0x99AC, 0xF152, 0x99AD, 0xF153, 0x99AE, 0xF154,\t0x99AF, 0xF155, 0x99B0, 0xF156, 0x99B1, 0xF157, 0x99B2, 0xF158,\r\n\t0x99B3, 0xF159, 0x99B4, 0xF15A, 0x99B5, 0xF15B, 0x99B6, 0xF15C,\t0x99B7, 0xF15D, 0x99B8, 0xF15E, 0x99B9, 0xF15F, 0x99BA, 0xF160,\r\n\t0x99BB, 0xF161, 0x99BC, 0xF162, 0x99BD, 0xF163, 0x99BE, 0xF164,\t0x99BF, 0xF165, 0x99C0, 0xF166, 0x99C1, 0xF167, 0x99C2, 0xF168,\r\n\t0x99C3, 0xF169, 0x99C4, 0xF16A, 0x99C5, 0xF16B, 0x99C6, 0xF16C,\t0x99C7, 0xF16D, 0x99C8, 0xF16E, 0x99C9, 0xF16F, 0x99CA, 0xF170,\r\n\t0x99CB, 0xF171, 0x99CC, 0xF172, 0x99CD, 0xF173, 0x99CE, 0xF174,\t0x99CF, 0xF175, 0x99D0, 0xF176, 0x99D1, 0xF177, 0x99D2, 0xF178,\r\n\t0x99D3, 0xF179, 0x99D4, 0xF17A, 0x99D5, 0xF17B, 0x99D6, 0xF17C,\t0x99D7, 0xF17D, 0x99D8, 0xF17E, 0x99D9, 0xF180, 0x99DA, 0xF181,\r\n\t0x99DB, 0xF182, 0x99DC, 0xF183, 0x99DD, 0xF184, 0x99DE, 0xF185,\t0x99DF, 0xF186, 0x99E0, 0xF187, 0x99E1, 0xF188, 0x99E2, 0xF189,\r\n\t0x99E3, 0xF18A, 0x99E4, 0xF18B, 0x99E5, 0xF18C, 0x99E6, 0xF18D,\t0x99E7, 0xF18E, 0x99E8, 0xF18F, 0x99E9, 0xF190, 0x99EA, 0xF191,\r\n\t0x99EB, 0xF192, 0x99EC, 0xF193, 0x99ED, 0xF194, 0x99EE, 0xF195,\t0x99EF, 0xF196, 0x99F0, 0xF197, 0x99F1, 0xF198, 0x99F2, 0xF199,\r\n\t0x99F3, 0xF19A, 0x99F4, 0xF19B, 0x99F5, 0xF19C, 0x99F6, 0xF19D,\t0x99F7, 0xF19E, 0x99F8, 0xF19F, 0x99F9, 0xF1A0, 0x99FA, 0xF240,\r\n\t0x99FB, 0xF241, 0x99FC, 0xF242, 0x99FD, 0xF243, 0x99FE, 0xF244,\t0x99FF, 0xF245, 0x9A00, 0xF246, 0x9A01, 0xF247, 0x9A02, 0xF248,\r\n\t0x9A03, 0xF249, 0x9A04, 0xF24A, 0x9A05, 0xF24B, 0x9A06, 0xF24C,\t0x9A07, 0xF24D, 0x9A08, 0xF24E, 0x9A09, 0xF24F, 0x9A0A, 0xF250,\r\n\t0x9A0B, 0xF251, 0x9A0C, 0xF252, 0x9A0D, 0xF253, 0x9A0E, 0xF254,\t0x9A0F, 0xF255, 0x9A10, 0xF256, 0x9A11, 0xF257, 0x9A12, 0xF258,\r\n\t0x9A13, 0xF259, 0x9A14, 0xF25A, 0x9A15, 0xF25B, 0x9A16, 0xF25C,\t0x9A17, 0xF25D, 0x9A18, 0xF25E, 0x9A19, 0xF25F, 0x9A1A, 0xF260,\r\n\t0x9A1B, 0xF261, 0x9A1C, 0xF262, 0x9A1D, 0xF263, 0x9A1E, 0xF264,\t0x9A1F, 0xF265, 0x9A20, 0xF266, 0x9A21, 0xF267, 0x9A22, 0xF268,\r\n\t0x9A23, 0xF269, 0x9A24, 0xF26A, 0x9A25, 0xF26B, 0x9A26, 0xF26C,\t0x9A27, 0xF26D, 0x9A28, 0xF26E, 0x9A29, 0xF26F, 0x9A2A, 0xF270,\r\n\t0x9A2B, 0xF271, 0x9A2C, 0xF272, 0x9A2D, 0xF273, 0x9A2E, 0xF274,\t0x9A2F, 0xF275, 0x9A30, 0xF276, 0x9A31, 0xF277, 0x9A32, 0xF278,\r\n\t0x9A33, 0xF279, 0x9A34, 0xF27A, 0x9A35, 0xF27B, 0x9A36, 0xF27C,\t0x9A37, 0xF27D, 0x9A38, 0xF27E, 0x9A39, 0xF280, 0x9A3A, 0xF281,\r\n\t0x9A3B, 0xF282, 0x9A3C, 0xF283, 0x9A3D, 0xF284, 0x9A3E, 0xF285,\t0x9A3F, 0xF286, 0x9A40, 0xF287, 0x9A41, 0xF288, 0x9A42, 0xF289,\r\n\t0x9A43, 0xF28A, 0x9A44, 0xF28B, 0x9A45, 0xF28C, 0x9A46, 0xF28D,\t0x9A47, 0xF28E, 0x9A48, 0xF28F, 0x9A49, 0xF290, 0x9A4A, 0xF291,\r\n\t0x9A4B, 0xF292, 0x9A4C, 0xF293, 0x9A4D, 0xF294, 0x9A4E, 0xF295,\t0x9A4F, 0xF296, 0x9A50, 0xF297, 0x9A51, 0xF298, 0x9A52, 0xF299,\r\n\t0x9A53, 0xF29A, 0x9A54, 0xF29B, 0x9A55, 0xF29C, 0x9A56, 0xF29D,\t0x9A57, 0xF29E, 0x9A58, 0xF29F, 0x9A59, 0xF2A0, 0x9A5A, 0xF340,\r\n\t0x9A5B, 0xF341, 0x9A5C, 0xF342, 0x9A5D, 0xF343, 0x9A5E, 0xF344,\t0x9A5F, 0xF345, 0x9A60, 0xF346, 0x9A61, 0xF347, 0x9A62, 0xF348,\r\n\t0x9A63, 0xF349, 0x9A64, 0xF34A, 0x9A65, 0xF34B, 0x9A66, 0xF34C,\t0x9A67, 0xF34D, 0x9A68, 0xF34E, 0x9A69, 0xF34F, 0x9A6A, 0xF350,\r\n\t0x9A6B, 0xF351, 0x9A6C, 0xC2ED, 0x9A6D, 0xD4A6, 0x9A6E, 0xCDD4,\t0x9A6F, 0xD1B1, 0x9A70, 0xB3DB, 0x9A71, 0xC7FD, 0x9A72, 0xF352,\r\n\t0x9A73, 0xB2B5, 0x9A74, 0xC2BF, 0x9A75, 0xE6E0, 0x9A76, 0xCABB,\t0x9A77, 0xE6E1, 0x9A78, 0xE6E2, 0x9A79, 0xBED4, 0x9A7A, 0xE6E3,\r\n\t0x9A7B, 0xD7A4, 0x9A7C, 0xCDD5, 0x9A7D, 0xE6E5, 0x9A7E, 0xBCDD,\t0x9A7F, 0xE6E4, 0x9A80, 0xE6E6, 0x9A81, 0xE6E7, 0x9A82, 0xC2EE,\r\n\t0x9A83, 0xF353, 0x9A84, 0xBDBE, 0x9A85, 0xE6E8, 0x9A86, 0xC2E6,\t0x9A87, 0xBAA7, 0x9A88, 0xE6E9, 0x9A89, 0xF354, 0x9A8A, 0xE6EA,\r\n\t0x9A8B, 0xB3D2, 0x9A8C, 0xD1E9, 0x9A8D, 0xF355, 0x9A8E, 0xF356,\t0x9A8F, 0xBFA5, 0x9A90, 0xE6EB, 0x9A91, 0xC6EF, 0x9A92, 0xE6EC,\r\n\t0x9A93, 0xE6ED, 0x9A94, 0xF357, 0x9A95, 0xF358, 0x9A96, 0xE6EE,\t0x9A97, 0xC6AD, 0x9A98, 0xE6EF, 0x9A99, 0xF359, 0x9A9A, 0xC9A7,\r\n\t0x9A9B, 0xE6F0, 0x9A9C, 0xE6F1, 0x9A9D, 0xE6F2, 0x9A9E, 0xE5B9,\t0x9A9F, 0xE6F3, 0x9AA0, 0xE6F4, 0x9AA1, 0xC2E2, 0x9AA2, 0xE6F5,\r\n\t0x9AA3, 0xE6F6, 0x9AA4, 0xD6E8, 0x9AA5, 0xE6F7, 0x9AA6, 0xF35A,\t0x9AA7, 0xE6F8, 0x9AA8, 0xB9C7, 0x9AA9, 0xF35B, 0x9AAA, 0xF35C,\r\n\t0x9AAB, 0xF35D, 0x9AAC, 0xF35E, 0x9AAD, 0xF35F, 0x9AAE, 0xF360,\t0x9AAF, 0xF361, 0x9AB0, 0xF7BB, 0x9AB1, 0xF7BA, 0x9AB2, 0xF362,\r\n\t0x9AB3, 0xF363, 0x9AB4, 0xF364, 0x9AB5, 0xF365, 0x9AB6, 0xF7BE,\t0x9AB7, 0xF7BC, 0x9AB8, 0xBAA1, 0x9AB9, 0xF366, 0x9ABA, 0xF7BF,\r\n\t0x9ABB, 0xF367, 0x9ABC, 0xF7C0, 0x9ABD, 0xF368, 0x9ABE, 0xF369,\t0x9ABF, 0xF36A, 0x9AC0, 0xF7C2, 0x9AC1, 0xF7C1, 0x9AC2, 0xF7C4,\r\n\t0x9AC3, 0xF36B, 0x9AC4, 0xF36C, 0x9AC5, 0xF7C3, 0x9AC6, 0xF36D,\t0x9AC7, 0xF36E, 0x9AC8, 0xF36F, 0x9AC9, 0xF370, 0x9ACA, 0xF371,\r\n\t0x9ACB, 0xF7C5, 0x9ACC, 0xF7C6, 0x9ACD, 0xF372, 0x9ACE, 0xF373,\t0x9ACF, 0xF374, 0x9AD0, 0xF375, 0x9AD1, 0xF7C7, 0x9AD2, 0xF376,\r\n\t0x9AD3, 0xCBE8, 0x9AD4, 0xF377, 0x9AD5, 0xF378, 0x9AD6, 0xF379,\t0x9AD7, 0xF37A, 0x9AD8, 0xB8DF, 0x9AD9, 0xF37B, 0x9ADA, 0xF37C,\r\n\t0x9ADB, 0xF37D, 0x9ADC, 0xF37E, 0x9ADD, 0xF380, 0x9ADE, 0xF381,\t0x9ADF, 0xF7D4, 0x9AE0, 0xF382, 0x9AE1, 0xF7D5, 0x9AE2, 0xF383,\r\n\t0x9AE3, 0xF384, 0x9AE4, 0xF385, 0x9AE5, 0xF386, 0x9AE6, 0xF7D6,\t0x9AE7, 0xF387, 0x9AE8, 0xF388, 0x9AE9, 0xF389, 0x9AEA, 0xF38A,\r\n\t0x9AEB, 0xF7D8, 0x9AEC, 0xF38B, 0x9AED, 0xF7DA, 0x9AEE, 0xF38C,\t0x9AEF, 0xF7D7, 0x9AF0, 0xF38D, 0x9AF1, 0xF38E, 0x9AF2, 0xF38F,\r\n\t0x9AF3, 0xF390, 0x9AF4, 0xF391, 0x9AF5, 0xF392, 0x9AF6, 0xF393,\t0x9AF7, 0xF394, 0x9AF8, 0xF395, 0x9AF9, 0xF7DB, 0x9AFA, 0xF396,\r\n\t0x9AFB, 0xF7D9, 0x9AFC, 0xF397, 0x9AFD, 0xF398, 0x9AFE, 0xF399,\t0x9AFF, 0xF39A, 0x9B00, 0xF39B, 0x9B01, 0xF39C, 0x9B02, 0xF39D,\r\n\t0x9B03, 0xD7D7, 0x9B04, 0xF39E, 0x9B05, 0xF39F, 0x9B06, 0xF3A0,\t0x9B07, 0xF440, 0x9B08, 0xF7DC, 0x9B09, 0xF441, 0x9B0A, 0xF442,\r\n\t0x9B0B, 0xF443, 0x9B0C, 0xF444, 0x9B0D, 0xF445, 0x9B0E, 0xF446,\t0x9B0F, 0xF7DD, 0x9B10, 0xF447, 0x9B11, 0xF448, 0x9B12, 0xF449,\r\n\t0x9B13, 0xF7DE, 0x9B14, 0xF44A, 0x9B15, 0xF44B, 0x9B16, 0xF44C,\t0x9B17, 0xF44D, 0x9B18, 0xF44E, 0x9B19, 0xF44F, 0x9B1A, 0xF450,\r\n\t0x9B1B, 0xF451, 0x9B1C, 0xF452, 0x9B1D, 0xF453, 0x9B1E, 0xF454,\t0x9B1F, 0xF7DF, 0x9B20, 0xF455, 0x9B21, 0xF456, 0x9B22, 0xF457,\r\n\t0x9B23, 0xF7E0, 0x9B24, 0xF458, 0x9B25, 0xF459, 0x9B26, 0xF45A,\t0x9B27, 0xF45B, 0x9B28, 0xF45C, 0x9B29, 0xF45D, 0x9B2A, 0xF45E,\r\n\t0x9B2B, 0xF45F, 0x9B2C, 0xF460, 0x9B2D, 0xF461, 0x9B2E, 0xF462,\t0x9B2F, 0xDBCB, 0x9B30, 0xF463, 0x9B31, 0xF464, 0x9B32, 0xD8AA,\r\n\t0x9B33, 0xF465, 0x9B34, 0xF466, 0x9B35, 0xF467, 0x9B36, 0xF468,\t0x9B37, 0xF469, 0x9B38, 0xF46A, 0x9B39, 0xF46B, 0x9B3A, 0xF46C,\r\n\t0x9B3B, 0xE5F7, 0x9B3C, 0xB9ED, 0x9B3D, 0xF46D, 0x9B3E, 0xF46E,\t0x9B3F, 0xF46F, 0x9B40, 0xF470, 0x9B41, 0xBFFD, 0x9B42, 0xBBEA,\r\n\t0x9B43, 0xF7C9, 0x9B44, 0xC6C7, 0x9B45, 0xF7C8, 0x9B46, 0xF471,\t0x9B47, 0xF7CA, 0x9B48, 0xF7CC, 0x9B49, 0xF7CB, 0x9B4A, 0xF472,\r\n\t0x9B4B, 0xF473, 0x9B4C, 0xF474, 0x9B4D, 0xF7CD, 0x9B4E, 0xF475,\t0x9B4F, 0xCEBA, 0x9B50, 0xF476, 0x9B51, 0xF7CE, 0x9B52, 0xF477,\r\n\t0x9B53, 0xF478, 0x9B54, 0xC4A7, 0x9B55, 0xF479, 0x9B56, 0xF47A,\t0x9B57, 0xF47B, 0x9B58, 0xF47C, 0x9B59, 0xF47D, 0x9B5A, 0xF47E,\r\n\t0x9B5B, 0xF480, 0x9B5C, 0xF481, 0x9B5D, 0xF482, 0x9B5E, 0xF483,\t0x9B5F, 0xF484, 0x9B60, 0xF485, 0x9B61, 0xF486, 0x9B62, 0xF487,\r\n\t0x9B63, 0xF488, 0x9B64, 0xF489, 0x9B65, 0xF48A, 0x9B66, 0xF48B,\t0x9B67, 0xF48C, 0x9B68, 0xF48D, 0x9B69, 0xF48E, 0x9B6A, 0xF48F,\r\n\t0x9B6B, 0xF490, 0x9B6C, 0xF491, 0x9B6D, 0xF492, 0x9B6E, 0xF493,\t0x9B6F, 0xF494, 0x9B70, 0xF495, 0x9B71, 0xF496, 0x9B72, 0xF497,\r\n\t0x9B73, 0xF498, 0x9B74, 0xF499, 0x9B75, 0xF49A, 0x9B76, 0xF49B,\t0x9B77, 0xF49C, 0x9B78, 0xF49D, 0x9B79, 0xF49E, 0x9B7A, 0xF49F,\r\n\t0x9B7B, 0xF4A0, 0x9B7C, 0xF540, 0x9B7D, 0xF541, 0x9B7E, 0xF542,\t0x9B7F, 0xF543, 0x9B80, 0xF544, 0x9B81, 0xF545, 0x9B82, 0xF546,\r\n\t0x9B83, 0xF547, 0x9B84, 0xF548, 0x9B85, 0xF549, 0x9B86, 0xF54A,\t0x9B87, 0xF54B, 0x9B88, 0xF54C, 0x9B89, 0xF54D, 0x9B8A, 0xF54E,\r\n\t0x9B8B, 0xF54F, 0x9B8C, 0xF550, 0x9B8D, 0xF551, 0x9B8E, 0xF552,\t0x9B8F, 0xF553, 0x9B90, 0xF554, 0x9B91, 0xF555, 0x9B92, 0xF556,\r\n\t0x9B93, 0xF557, 0x9B94, 0xF558, 0x9B95, 0xF559, 0x9B96, 0xF55A,\t0x9B97, 0xF55B, 0x9B98, 0xF55C, 0x9B99, 0xF55D, 0x9B9A, 0xF55E,\r\n\t0x9B9B, 0xF55F, 0x9B9C, 0xF560, 0x9B9D, 0xF561, 0x9B9E, 0xF562,\t0x9B9F, 0xF563, 0x9BA0, 0xF564, 0x9BA1, 0xF565, 0x9BA2, 0xF566,\r\n\t0x9BA3, 0xF567, 0x9BA4, 0xF568, 0x9BA5, 0xF569, 0x9BA6, 0xF56A,\t0x9BA7, 0xF56B, 0x9BA8, 0xF56C, 0x9BA9, 0xF56D, 0x9BAA, 0xF56E,\r\n\t0x9BAB, 0xF56F, 0x9BAC, 0xF570, 0x9BAD, 0xF571, 0x9BAE, 0xF572,\t0x9BAF, 0xF573, 0x9BB0, 0xF574, 0x9BB1, 0xF575, 0x9BB2, 0xF576,\r\n\t0x9BB3, 0xF577, 0x9BB4, 0xF578, 0x9BB5, 0xF579, 0x9BB6, 0xF57A,\t0x9BB7, 0xF57B, 0x9BB8, 0xF57C, 0x9BB9, 0xF57D, 0x9BBA, 0xF57E,\r\n\t0x9BBB, 0xF580, 0x9BBC, 0xF581, 0x9BBD, 0xF582, 0x9BBE, 0xF583,\t0x9BBF, 0xF584, 0x9BC0, 0xF585, 0x9BC1, 0xF586, 0x9BC2, 0xF587,\r\n\t0x9BC3, 0xF588, 0x9BC4, 0xF589, 0x9BC5, 0xF58A, 0x9BC6, 0xF58B,\t0x9BC7, 0xF58C, 0x9BC8, 0xF58D, 0x9BC9, 0xF58E, 0x9BCA, 0xF58F,\r\n\t0x9BCB, 0xF590, 0x9BCC, 0xF591, 0x9BCD, 0xF592, 0x9BCE, 0xF593,\t0x9BCF, 0xF594, 0x9BD0, 0xF595, 0x9BD1, 0xF596, 0x9BD2, 0xF597,\r\n\t0x9BD3, 0xF598, 0x9BD4, 0xF599, 0x9BD5, 0xF59A, 0x9BD6, 0xF59B,\t0x9BD7, 0xF59C, 0x9BD8, 0xF59D, 0x9BD9, 0xF59E, 0x9BDA, 0xF59F,\r\n\t0x9BDB, 0xF5A0, 0x9BDC, 0xF640, 0x9BDD, 0xF641, 0x9BDE, 0xF642,\t0x9BDF, 0xF643, 0x9BE0, 0xF644, 0x9BE1, 0xF645, 0x9BE2, 0xF646,\r\n\t0x9BE3, 0xF647, 0x9BE4, 0xF648, 0x9BE5, 0xF649, 0x9BE6, 0xF64A,\t0x9BE7, 0xF64B, 0x9BE8, 0xF64C, 0x9BE9, 0xF64D, 0x9BEA, 0xF64E,\r\n\t0x9BEB, 0xF64F, 0x9BEC, 0xF650, 0x9BED, 0xF651, 0x9BEE, 0xF652,\t0x9BEF, 0xF653, 0x9BF0, 0xF654, 0x9BF1, 0xF655, 0x9BF2, 0xF656,\r\n\t0x9BF3, 0xF657, 0x9BF4, 0xF658, 0x9BF5, 0xF659, 0x9BF6, 0xF65A,\t0x9BF7, 0xF65B, 0x9BF8, 0xF65C, 0x9BF9, 0xF65D, 0x9BFA, 0xF65E,\r\n\t0x9BFB, 0xF65F, 0x9BFC, 0xF660, 0x9BFD, 0xF661, 0x9BFE, 0xF662,\t0x9BFF, 0xF663, 0x9C00, 0xF664, 0x9C01, 0xF665, 0x9C02, 0xF666,\r\n\t0x9C03, 0xF667, 0x9C04, 0xF668, 0x9C05, 0xF669, 0x9C06, 0xF66A,\t0x9C07, 0xF66B, 0x9C08, 0xF66C, 0x9C09, 0xF66D, 0x9C0A, 0xF66E,\r\n\t0x9C0B, 0xF66F, 0x9C0C, 0xF670, 0x9C0D, 0xF671, 0x9C0E, 0xF672,\t0x9C0F, 0xF673, 0x9C10, 0xF674, 0x9C11, 0xF675, 0x9C12, 0xF676,\r\n\t0x9C13, 0xF677, 0x9C14, 0xF678, 0x9C15, 0xF679, 0x9C16, 0xF67A,\t0x9C17, 0xF67B, 0x9C18, 0xF67C, 0x9C19, 0xF67D, 0x9C1A, 0xF67E,\r\n\t0x9C1B, 0xF680, 0x9C1C, 0xF681, 0x9C1D, 0xF682, 0x9C1E, 0xF683,\t0x9C1F, 0xF684, 0x9C20, 0xF685, 0x9C21, 0xF686, 0x9C22, 0xF687,\r\n\t0x9C23, 0xF688, 0x9C24, 0xF689, 0x9C25, 0xF68A, 0x9C26, 0xF68B,\t0x9C27, 0xF68C, 0x9C28, 0xF68D, 0x9C29, 0xF68E, 0x9C2A, 0xF68F,\r\n\t0x9C2B, 0xF690, 0x9C2C, 0xF691, 0x9C2D, 0xF692, 0x9C2E, 0xF693,\t0x9C2F, 0xF694, 0x9C30, 0xF695, 0x9C31, 0xF696, 0x9C32, 0xF697,\r\n\t0x9C33, 0xF698, 0x9C34, 0xF699, 0x9C35, 0xF69A, 0x9C36, 0xF69B,\t0x9C37, 0xF69C, 0x9C38, 0xF69D, 0x9C39, 0xF69E, 0x9C3A, 0xF69F,\r\n\t0x9C3B, 0xF6A0, 0x9C3C, 0xF740, 0x9C3D, 0xF741, 0x9C3E, 0xF742,\t0x9C3F, 0xF743, 0x9C40, 0xF744, 0x9C41, 0xF745, 0x9C42, 0xF746,\r\n\t0x9C43, 0xF747, 0x9C44, 0xF748, 0x9C45, 0xF749, 0x9C46, 0xF74A,\t0x9C47, 0xF74B, 0x9C48, 0xF74C, 0x9C49, 0xF74D, 0x9C4A, 0xF74E,\r\n\t0x9C4B, 0xF74F, 0x9C4C, 0xF750, 0x9C4D, 0xF751, 0x9C4E, 0xF752,\t0x9C4F, 0xF753, 0x9C50, 0xF754, 0x9C51, 0xF755, 0x9C52, 0xF756,\r\n\t0x9C53, 0xF757, 0x9C54, 0xF758, 0x9C55, 0xF759, 0x9C56, 0xF75A,\t0x9C57, 0xF75B, 0x9C58, 0xF75C, 0x9C59, 0xF75D, 0x9C5A, 0xF75E,\r\n\t0x9C5B, 0xF75F, 0x9C5C, 0xF760, 0x9C5D, 0xF761, 0x9C5E, 0xF762,\t0x9C5F, 0xF763, 0x9C60, 0xF764, 0x9C61, 0xF765, 0x9C62, 0xF766,\r\n\t0x9C63, 0xF767, 0x9C64, 0xF768, 0x9C65, 0xF769, 0x9C66, 0xF76A,\t0x9C67, 0xF76B, 0x9C68, 0xF76C, 0x9C69, 0xF76D, 0x9C6A, 0xF76E,\r\n\t0x9C6B, 0xF76F, 0x9C6C, 0xF770, 0x9C6D, 0xF771, 0x9C6E, 0xF772,\t0x9C6F, 0xF773, 0x9C70, 0xF774, 0x9C71, 0xF775, 0x9C72, 0xF776,\r\n\t0x9C73, 0xF777, 0x9C74, 0xF778, 0x9C75, 0xF779, 0x9C76, 0xF77A,\t0x9C77, 0xF77B, 0x9C78, 0xF77C, 0x9C79, 0xF77D, 0x9C7A, 0xF77E,\r\n\t0x9C7B, 0xF780, 0x9C7C, 0xD3E3, 0x9C7D, 0xF781, 0x9C7E, 0xF782,\t0x9C7F, 0xF6CF, 0x9C80, 0xF783, 0x9C81, 0xC2B3, 0x9C82, 0xF6D0,\r\n\t0x9C83, 0xF784, 0x9C84, 0xF785, 0x9C85, 0xF6D1, 0x9C86, 0xF6D2,\t0x9C87, 0xF6D3, 0x9C88, 0xF6D4, 0x9C89, 0xF786, 0x9C8A, 0xF787,\r\n\t0x9C8B, 0xF6D6, 0x9C8C, 0xF788, 0x9C8D, 0xB1AB, 0x9C8E, 0xF6D7,\t0x9C8F, 0xF789, 0x9C90, 0xF6D8, 0x9C91, 0xF6D9, 0x9C92, 0xF6DA,\r\n\t0x9C93, 0xF78A, 0x9C94, 0xF6DB, 0x9C95, 0xF6DC, 0x9C96, 0xF78B,\t0x9C97, 0xF78C, 0x9C98, 0xF78D, 0x9C99, 0xF78E, 0x9C9A, 0xF6DD,\r\n\t0x9C9B, 0xF6DE, 0x9C9C, 0xCFCA, 0x9C9D, 0xF78F, 0x9C9E, 0xF6DF,\t0x9C9F, 0xF6E0, 0x9CA0, 0xF6E1, 0x9CA1, 0xF6E2, 0x9CA2, 0xF6E3,\r\n\t0x9CA3, 0xF6E4, 0x9CA4, 0xC0F0, 0x9CA5, 0xF6E5, 0x9CA6, 0xF6E6,\t0x9CA7, 0xF6E7, 0x9CA8, 0xF6E8, 0x9CA9, 0xF6E9, 0x9CAA, 0xF790,\r\n\t0x9CAB, 0xF6EA, 0x9CAC, 0xF791, 0x9CAD, 0xF6EB, 0x9CAE, 0xF6EC,\t0x9CAF, 0xF792, 0x9CB0, 0xF6ED, 0x9CB1, 0xF6EE, 0x9CB2, 0xF6EF,\r\n\t0x9CB3, 0xF6F0, 0x9CB4, 0xF6F1, 0x9CB5, 0xF6F2, 0x9CB6, 0xF6F3,\t0x9CB7, 0xF6F4, 0x9CB8, 0xBEA8, 0x9CB9, 0xF793, 0x9CBA, 0xF6F5,\r\n\t0x9CBB, 0xF6F6, 0x9CBC, 0xF6F7, 0x9CBD, 0xF6F8, 0x9CBE, 0xF794,\t0x9CBF, 0xF795, 0x9CC0, 0xF796, 0x9CC1, 0xF797, 0x9CC2, 0xF798,\r\n\t0x9CC3, 0xC8FA, 0x9CC4, 0xF6F9, 0x9CC5, 0xF6FA, 0x9CC6, 0xF6FB,\t0x9CC7, 0xF6FC, 0x9CC8, 0xF799, 0x9CC9, 0xF79A, 0x9CCA, 0xF6FD,\r\n\t0x9CCB, 0xF6FE, 0x9CCC, 0xF7A1, 0x9CCD, 0xF7A2, 0x9CCE, 0xF7A3,\t0x9CCF, 0xF7A4, 0x9CD0, 0xF7A5, 0x9CD1, 0xF79B, 0x9CD2, 0xF79C,\r\n\t0x9CD3, 0xF7A6, 0x9CD4, 0xF7A7, 0x9CD5, 0xF7A8, 0x9CD6, 0xB1EE,\t0x9CD7, 0xF7A9, 0x9CD8, 0xF7AA, 0x9CD9, 0xF7AB, 0x9CDA, 0xF79D,\r\n\t0x9CDB, 0xF79E, 0x9CDC, 0xF7AC, 0x9CDD, 0xF7AD, 0x9CDE, 0xC1DB,\t0x9CDF, 0xF7AE, 0x9CE0, 0xF79F, 0x9CE1, 0xF7A0, 0x9CE2, 0xF7AF,\r\n\t0x9CE3, 0xF840, 0x9CE4, 0xF841, 0x9CE5, 0xF842, 0x9CE6, 0xF843,\t0x9CE7, 0xF844, 0x9CE8, 0xF845, 0x9CE9, 0xF846, 0x9CEA, 0xF847,\r\n\t0x9CEB, 0xF848, 0x9CEC, 0xF849, 0x9CED, 0xF84A, 0x9CEE, 0xF84B,\t0x9CEF, 0xF84C, 0x9CF0, 0xF84D, 0x9CF1, 0xF84E, 0x9CF2, 0xF84F,\r\n\t0x9CF3, 0xF850, 0x9CF4, 0xF851, 0x9CF5, 0xF852, 0x9CF6, 0xF853,\t0x9CF7, 0xF854, 0x9CF8, 0xF855, 0x9CF9, 0xF856, 0x9CFA, 0xF857,\r\n\t0x9CFB, 0xF858, 0x9CFC, 0xF859, 0x9CFD, 0xF85A, 0x9CFE, 0xF85B,\t0x9CFF, 0xF85C, 0x9D00, 0xF85D, 0x9D01, 0xF85E, 0x9D02, 0xF85F,\r\n\t0x9D03, 0xF860, 0x9D04, 0xF861, 0x9D05, 0xF862, 0x9D06, 0xF863,\t0x9D07, 0xF864, 0x9D08, 0xF865, 0x9D09, 0xF866, 0x9D0A, 0xF867,\r\n\t0x9D0B, 0xF868, 0x9D0C, 0xF869, 0x9D0D, 0xF86A, 0x9D0E, 0xF86B,\t0x9D0F, 0xF86C, 0x9D10, 0xF86D, 0x9D11, 0xF86E, 0x9D12, 0xF86F,\r\n\t0x9D13, 0xF870, 0x9D14, 0xF871, 0x9D15, 0xF872, 0x9D16, 0xF873,\t0x9D17, 0xF874, 0x9D18, 0xF875, 0x9D19, 0xF876, 0x9D1A, 0xF877,\r\n\t0x9D1B, 0xF878, 0x9D1C, 0xF879, 0x9D1D, 0xF87A, 0x9D1E, 0xF87B,\t0x9D1F, 0xF87C, 0x9D20, 0xF87D, 0x9D21, 0xF87E, 0x9D22, 0xF880,\r\n\t0x9D23, 0xF881, 0x9D24, 0xF882, 0x9D25, 0xF883, 0x9D26, 0xF884,\t0x9D27, 0xF885, 0x9D28, 0xF886, 0x9D29, 0xF887, 0x9D2A, 0xF888,\r\n\t0x9D2B, 0xF889, 0x9D2C, 0xF88A, 0x9D2D, 0xF88B, 0x9D2E, 0xF88C,\t0x9D2F, 0xF88D, 0x9D30, 0xF88E, 0x9D31, 0xF88F, 0x9D32, 0xF890,\r\n\t0x9D33, 0xF891, 0x9D34, 0xF892, 0x9D35, 0xF893, 0x9D36, 0xF894,\t0x9D37, 0xF895, 0x9D38, 0xF896, 0x9D39, 0xF897, 0x9D3A, 0xF898,\r\n\t0x9D3B, 0xF899, 0x9D3C, 0xF89A, 0x9D3D, 0xF89B, 0x9D3E, 0xF89C,\t0x9D3F, 0xF89D, 0x9D40, 0xF89E, 0x9D41, 0xF89F, 0x9D42, 0xF8A0,\r\n\t0x9D43, 0xF940, 0x9D44, 0xF941, 0x9D45, 0xF942, 0x9D46, 0xF943,\t0x9D47, 0xF944, 0x9D48, 0xF945, 0x9D49, 0xF946, 0x9D4A, 0xF947,\r\n\t0x9D4B, 0xF948, 0x9D4C, 0xF949, 0x9D4D, 0xF94A, 0x9D4E, 0xF94B,\t0x9D4F, 0xF94C, 0x9D50, 0xF94D, 0x9D51, 0xF94E, 0x9D52, 0xF94F,\r\n\t0x9D53, 0xF950, 0x9D54, 0xF951, 0x9D55, 0xF952, 0x9D56, 0xF953,\t0x9D57, 0xF954, 0x9D58, 0xF955, 0x9D59, 0xF956, 0x9D5A, 0xF957,\r\n\t0x9D5B, 0xF958, 0x9D5C, 0xF959, 0x9D5D, 0xF95A, 0x9D5E, 0xF95B,\t0x9D5F, 0xF95C, 0x9D60, 0xF95D, 0x9D61, 0xF95E, 0x9D62, 0xF95F,\r\n\t0x9D63, 0xF960, 0x9D64, 0xF961, 0x9D65, 0xF962, 0x9D66, 0xF963,\t0x9D67, 0xF964, 0x9D68, 0xF965, 0x9D69, 0xF966, 0x9D6A, 0xF967,\r\n\t0x9D6B, 0xF968, 0x9D6C, 0xF969, 0x9D6D, 0xF96A, 0x9D6E, 0xF96B,\t0x9D6F, 0xF96C, 0x9D70, 0xF96D, 0x9D71, 0xF96E, 0x9D72, 0xF96F,\r\n\t0x9D73, 0xF970, 0x9D74, 0xF971, 0x9D75, 0xF972, 0x9D76, 0xF973,\t0x9D77, 0xF974, 0x9D78, 0xF975, 0x9D79, 0xF976, 0x9D7A, 0xF977,\r\n\t0x9D7B, 0xF978, 0x9D7C, 0xF979, 0x9D7D, 0xF97A, 0x9D7E, 0xF97B,\t0x9D7F, 0xF97C, 0x9D80, 0xF97D, 0x9D81, 0xF97E, 0x9D82, 0xF980,\r\n\t0x9D83, 0xF981, 0x9D84, 0xF982, 0x9D85, 0xF983, 0x9D86, 0xF984,\t0x9D87, 0xF985, 0x9D88, 0xF986, 0x9D89, 0xF987, 0x9D8A, 0xF988,\r\n\t0x9D8B, 0xF989, 0x9D8C, 0xF98A, 0x9D8D, 0xF98B, 0x9D8E, 0xF98C,\t0x9D8F, 0xF98D, 0x9D90, 0xF98E, 0x9D91, 0xF98F, 0x9D92, 0xF990,\r\n\t0x9D93, 0xF991, 0x9D94, 0xF992, 0x9D95, 0xF993, 0x9D96, 0xF994,\t0x9D97, 0xF995, 0x9D98, 0xF996, 0x9D99, 0xF997, 0x9D9A, 0xF998,\r\n\t0x9D9B, 0xF999, 0x9D9C, 0xF99A, 0x9D9D, 0xF99B, 0x9D9E, 0xF99C,\t0x9D9F, 0xF99D, 0x9DA0, 0xF99E, 0x9DA1, 0xF99F, 0x9DA2, 0xF9A0,\r\n\t0x9DA3, 0xFA40, 0x9DA4, 0xFA41, 0x9DA5, 0xFA42, 0x9DA6, 0xFA43,\t0x9DA7, 0xFA44, 0x9DA8, 0xFA45, 0x9DA9, 0xFA46, 0x9DAA, 0xFA47,\r\n\t0x9DAB, 0xFA48, 0x9DAC, 0xFA49, 0x9DAD, 0xFA4A, 0x9DAE, 0xFA4B,\t0x9DAF, 0xFA4C, 0x9DB0, 0xFA4D, 0x9DB1, 0xFA4E, 0x9DB2, 0xFA4F,\r\n\t0x9DB3, 0xFA50, 0x9DB4, 0xFA51, 0x9DB5, 0xFA52, 0x9DB6, 0xFA53,\t0x9DB7, 0xFA54, 0x9DB8, 0xFA55, 0x9DB9, 0xFA56, 0x9DBA, 0xFA57,\r\n\t0x9DBB, 0xFA58, 0x9DBC, 0xFA59, 0x9DBD, 0xFA5A, 0x9DBE, 0xFA5B,\t0x9DBF, 0xFA5C, 0x9DC0, 0xFA5D, 0x9DC1, 0xFA5E, 0x9DC2, 0xFA5F,\r\n\t0x9DC3, 0xFA60, 0x9DC4, 0xFA61, 0x9DC5, 0xFA62, 0x9DC6, 0xFA63,\t0x9DC7, 0xFA64, 0x9DC8, 0xFA65, 0x9DC9, 0xFA66, 0x9DCA, 0xFA67,\r\n\t0x9DCB, 0xFA68, 0x9DCC, 0xFA69, 0x9DCD, 0xFA6A, 0x9DCE, 0xFA6B,\t0x9DCF, 0xFA6C, 0x9DD0, 0xFA6D, 0x9DD1, 0xFA6E, 0x9DD2, 0xFA6F,\r\n\t0x9DD3, 0xFA70, 0x9DD4, 0xFA71, 0x9DD5, 0xFA72, 0x9DD6, 0xFA73,\t0x9DD7, 0xFA74, 0x9DD8, 0xFA75, 0x9DD9, 0xFA76, 0x9DDA, 0xFA77,\r\n\t0x9DDB, 0xFA78, 0x9DDC, 0xFA79, 0x9DDD, 0xFA7A, 0x9DDE, 0xFA7B,\t0x9DDF, 0xFA7C, 0x9DE0, 0xFA7D, 0x9DE1, 0xFA7E, 0x9DE2, 0xFA80,\r\n\t0x9DE3, 0xFA81, 0x9DE4, 0xFA82, 0x9DE5, 0xFA83, 0x9DE6, 0xFA84,\t0x9DE7, 0xFA85, 0x9DE8, 0xFA86, 0x9DE9, 0xFA87, 0x9DEA, 0xFA88,\r\n\t0x9DEB, 0xFA89, 0x9DEC, 0xFA8A, 0x9DED, 0xFA8B, 0x9DEE, 0xFA8C,\t0x9DEF, 0xFA8D, 0x9DF0, 0xFA8E, 0x9DF1, 0xFA8F, 0x9DF2, 0xFA90,\r\n\t0x9DF3, 0xFA91, 0x9DF4, 0xFA92, 0x9DF5, 0xFA93, 0x9DF6, 0xFA94,\t0x9DF7, 0xFA95, 0x9DF8, 0xFA96, 0x9DF9, 0xFA97, 0x9DFA, 0xFA98,\r\n\t0x9DFB, 0xFA99, 0x9DFC, 0xFA9A, 0x9DFD, 0xFA9B, 0x9DFE, 0xFA9C,\t0x9DFF, 0xFA9D, 0x9E00, 0xFA9E, 0x9E01, 0xFA9F, 0x9E02, 0xFAA0,\r\n\t0x9E03, 0xFB40, 0x9E04, 0xFB41, 0x9E05, 0xFB42, 0x9E06, 0xFB43,\t0x9E07, 0xFB44, 0x9E08, 0xFB45, 0x9E09, 0xFB46, 0x9E0A, 0xFB47,\r\n\t0x9E0B, 0xFB48, 0x9E0C, 0xFB49, 0x9E0D, 0xFB4A, 0x9E0E, 0xFB4B,\t0x9E0F, 0xFB4C, 0x9E10, 0xFB4D, 0x9E11, 0xFB4E, 0x9E12, 0xFB4F,\r\n\t0x9E13, 0xFB50, 0x9E14, 0xFB51, 0x9E15, 0xFB52, 0x9E16, 0xFB53,\t0x9E17, 0xFB54, 0x9E18, 0xFB55, 0x9E19, 0xFB56, 0x9E1A, 0xFB57,\r\n\t0x9E1B, 0xFB58, 0x9E1C, 0xFB59, 0x9E1D, 0xFB5A, 0x9E1E, 0xFB5B,\t0x9E1F, 0xC4F1, 0x9E20, 0xF0AF, 0x9E21, 0xBCA6, 0x9E22, 0xF0B0,\r\n\t0x9E23, 0xC3F9, 0x9E24, 0xFB5C, 0x9E25, 0xC5B8, 0x9E26, 0xD1BB,\t0x9E27, 0xFB5D, 0x9E28, 0xF0B1, 0x9E29, 0xF0B2, 0x9E2A, 0xF0B3,\r\n\t0x9E2B, 0xF0B4, 0x9E2C, 0xF0B5, 0x9E2D, 0xD1BC, 0x9E2E, 0xFB5E,\t0x9E2F, 0xD1EC, 0x9E30, 0xFB5F, 0x9E31, 0xF0B7, 0x9E32, 0xF0B6,\r\n\t0x9E33, 0xD4A7, 0x9E34, 0xFB60, 0x9E35, 0xCDD2, 0x9E36, 0xF0B8,\t0x9E37, 0xF0BA, 0x9E38, 0xF0B9, 0x9E39, 0xF0BB, 0x9E3A, 0xF0BC,\r\n\t0x9E3B, 0xFB61, 0x9E3C, 0xFB62, 0x9E3D, 0xB8EB, 0x9E3E, 0xF0BD,\t0x9E3F, 0xBAE8, 0x9E40, 0xFB63, 0x9E41, 0xF0BE, 0x9E42, 0xF0BF,\r\n\t0x9E43, 0xBEE9, 0x9E44, 0xF0C0, 0x9E45, 0xB6EC, 0x9E46, 0xF0C1,\t0x9E47, 0xF0C2, 0x9E48, 0xF0C3, 0x9E49, 0xF0C4, 0x9E4A, 0xC8B5,\r\n\t0x9E4B, 0xF0C5, 0x9E4C, 0xF0C6, 0x9E4D, 0xFB64, 0x9E4E, 0xF0C7,\t0x9E4F, 0xC5F4, 0x9E50, 0xFB65, 0x9E51, 0xF0C8, 0x9E52, 0xFB66,\r\n\t0x9E53, 0xFB67, 0x9E54, 0xFB68, 0x9E55, 0xF0C9, 0x9E56, 0xFB69,\t0x9E57, 0xF0CA, 0x9E58, 0xF7BD, 0x9E59, 0xFB6A, 0x9E5A, 0xF0CB,\r\n\t0x9E5B, 0xF0CC, 0x9E5C, 0xF0CD, 0x9E5D, 0xFB6B, 0x9E5E, 0xF0CE,\t0x9E5F, 0xFB6C, 0x9E60, 0xFB6D, 0x9E61, 0xFB6E, 0x9E62, 0xFB6F,\r\n\t0x9E63, 0xF0CF, 0x9E64, 0xBAD7, 0x9E65, 0xFB70, 0x9E66, 0xF0D0,\t0x9E67, 0xF0D1, 0x9E68, 0xF0D2, 0x9E69, 0xF0D3, 0x9E6A, 0xF0D4,\r\n\t0x9E6B, 0xF0D5, 0x9E6C, 0xF0D6, 0x9E6D, 0xF0D8, 0x9E6E, 0xFB71,\t0x9E6F, 0xFB72, 0x9E70, 0xD3A5, 0x9E71, 0xF0D7, 0x9E72, 0xFB73,\r\n\t0x9E73, 0xF0D9, 0x9E74, 0xFB74, 0x9E75, 0xFB75, 0x9E76, 0xFB76,\t0x9E77, 0xFB77, 0x9E78, 0xFB78, 0x9E79, 0xFB79, 0x9E7A, 0xFB7A,\r\n\t0x9E7B, 0xFB7B, 0x9E7C, 0xFB7C, 0x9E7D, 0xFB7D, 0x9E7E, 0xF5BA,\t0x9E7F, 0xC2B9, 0x9E80, 0xFB7E, 0x9E81, 0xFB80, 0x9E82, 0xF7E4,\r\n\t0x9E83, 0xFB81, 0x9E84, 0xFB82, 0x9E85, 0xFB83, 0x9E86, 0xFB84,\t0x9E87, 0xF7E5, 0x9E88, 0xF7E6, 0x9E89, 0xFB85, 0x9E8A, 0xFB86,\r\n\t0x9E8B, 0xF7E7, 0x9E8C, 0xFB87, 0x9E8D, 0xFB88, 0x9E8E, 0xFB89,\t0x9E8F, 0xFB8A, 0x9E90, 0xFB8B, 0x9E91, 0xFB8C, 0x9E92, 0xF7E8,\r\n\t0x9E93, 0xC2B4, 0x9E94, 0xFB8D, 0x9E95, 0xFB8E, 0x9E96, 0xFB8F,\t0x9E97, 0xFB90, 0x9E98, 0xFB91, 0x9E99, 0xFB92, 0x9E9A, 0xFB93,\r\n\t0x9E9B, 0xFB94, 0x9E9C, 0xFB95, 0x9E9D, 0xF7EA, 0x9E9E, 0xFB96,\t0x9E9F, 0xF7EB, 0x9EA0, 0xFB97, 0x9EA1, 0xFB98, 0x9EA2, 0xFB99,\r\n\t0x9EA3, 0xFB9A, 0x9EA4, 0xFB9B, 0x9EA5, 0xFB9C, 0x9EA6, 0xC2F3,\t0x9EA7, 0xFB9D, 0x9EA8, 0xFB9E, 0x9EA9, 0xFB9F, 0x9EAA, 0xFBA0,\r\n\t0x9EAB, 0xFC40, 0x9EAC, 0xFC41, 0x9EAD, 0xFC42, 0x9EAE, 0xFC43,\t0x9EAF, 0xFC44, 0x9EB0, 0xFC45, 0x9EB1, 0xFC46, 0x9EB2, 0xFC47,\r\n\t0x9EB3, 0xFC48, 0x9EB4, 0xF4F0, 0x9EB5, 0xFC49, 0x9EB6, 0xFC4A,\t0x9EB7, 0xFC4B, 0x9EB8, 0xF4EF, 0x9EB9, 0xFC4C, 0x9EBA, 0xFC4D,\r\n\t0x9EBB, 0xC2E9, 0x9EBC, 0xFC4E, 0x9EBD, 0xF7E1, 0x9EBE, 0xF7E2,\t0x9EBF, 0xFC4F, 0x9EC0, 0xFC50, 0x9EC1, 0xFC51, 0x9EC2, 0xFC52,\r\n\t0x9EC3, 0xFC53, 0x9EC4, 0xBBC6, 0x9EC5, 0xFC54, 0x9EC6, 0xFC55,\t0x9EC7, 0xFC56, 0x9EC8, 0xFC57, 0x9EC9, 0xD9E4, 0x9ECA, 0xFC58,\r\n\t0x9ECB, 0xFC59, 0x9ECC, 0xFC5A, 0x9ECD, 0xCAF2, 0x9ECE, 0xC0E8,\t0x9ECF, 0xF0A4, 0x9ED0, 0xFC5B, 0x9ED1, 0xBADA, 0x9ED2, 0xFC5C,\r\n\t0x9ED3, 0xFC5D, 0x9ED4, 0xC7AD, 0x9ED5, 0xFC5E, 0x9ED6, 0xFC5F,\t0x9ED7, 0xFC60, 0x9ED8, 0xC4AC, 0x9ED9, 0xFC61, 0x9EDA, 0xFC62,\r\n\t0x9EDB, 0xF7EC, 0x9EDC, 0xF7ED, 0x9EDD, 0xF7EE, 0x9EDE, 0xFC63,\t0x9EDF, 0xF7F0, 0x9EE0, 0xF7EF, 0x9EE1, 0xFC64, 0x9EE2, 0xF7F1,\r\n\t0x9EE3, 0xFC65, 0x9EE4, 0xFC66, 0x9EE5, 0xF7F4, 0x9EE6, 0xFC67,\t0x9EE7, 0xF7F3, 0x9EE8, 0xFC68, 0x9EE9, 0xF7F2, 0x9EEA, 0xF7F5,\r\n\t0x9EEB, 0xFC69, 0x9EEC, 0xFC6A, 0x9EED, 0xFC6B, 0x9EEE, 0xFC6C,\t0x9EEF, 0xF7F6, 0x9EF0, 0xFC6D, 0x9EF1, 0xFC6E, 0x9EF2, 0xFC6F,\r\n\t0x9EF3, 0xFC70, 0x9EF4, 0xFC71, 0x9EF5, 0xFC72, 0x9EF6, 0xFC73,\t0x9EF7, 0xFC74, 0x9EF8, 0xFC75, 0x9EF9, 0xEDE9, 0x9EFA, 0xFC76,\r\n\t0x9EFB, 0xEDEA, 0x9EFC, 0xEDEB, 0x9EFD, 0xFC77, 0x9EFE, 0xF6BC,\t0x9EFF, 0xFC78, 0x9F00, 0xFC79, 0x9F01, 0xFC7A, 0x9F02, 0xFC7B,\r\n\t0x9F03, 0xFC7C, 0x9F04, 0xFC7D, 0x9F05, 0xFC7E, 0x9F06, 0xFC80,\t0x9F07, 0xFC81, 0x9F08, 0xFC82, 0x9F09, 0xFC83, 0x9F0A, 0xFC84,\r\n\t0x9F0B, 0xF6BD, 0x9F0C, 0xFC85, 0x9F0D, 0xF6BE, 0x9F0E, 0xB6A6,\t0x9F0F, 0xFC86, 0x9F10, 0xD8BE, 0x9F11, 0xFC87, 0x9F12, 0xFC88,\r\n\t0x9F13, 0xB9C4, 0x9F14, 0xFC89, 0x9F15, 0xFC8A, 0x9F16, 0xFC8B,\t0x9F17, 0xD8BB, 0x9F18, 0xFC8C, 0x9F19, 0xDCB1, 0x9F1A, 0xFC8D,\r\n\t0x9F1B, 0xFC8E, 0x9F1C, 0xFC8F, 0x9F1D, 0xFC90, 0x9F1E, 0xFC91,\t0x9F1F, 0xFC92, 0x9F20, 0xCAF3, 0x9F21, 0xFC93, 0x9F22, 0xF7F7,\r\n\t0x9F23, 0xFC94, 0x9F24, 0xFC95, 0x9F25, 0xFC96, 0x9F26, 0xFC97,\t0x9F27, 0xFC98, 0x9F28, 0xFC99, 0x9F29, 0xFC9A, 0x9F2A, 0xFC9B,\r\n\t0x9F2B, 0xFC9C, 0x9F2C, 0xF7F8, 0x9F2D, 0xFC9D, 0x9F2E, 0xFC9E,\t0x9F2F, 0xF7F9, 0x9F30, 0xFC9F, 0x9F31, 0xFCA0, 0x9F32, 0xFD40,\r\n\t0x9F33, 0xFD41, 0x9F34, 0xFD42, 0x9F35, 0xFD43, 0x9F36, 0xFD44,\t0x9F37, 0xF7FB, 0x9F38, 0xFD45, 0x9F39, 0xF7FA, 0x9F3A, 0xFD46,\r\n\t0x9F3B, 0xB1C7, 0x9F3C, 0xFD47, 0x9F3D, 0xF7FC, 0x9F3E, 0xF7FD,\t0x9F3F, 0xFD48, 0x9F40, 0xFD49, 0x9F41, 0xFD4A, 0x9F42, 0xFD4B,\r\n\t0x9F43, 0xFD4C, 0x9F44, 0xF7FE, 0x9F45, 0xFD4D, 0x9F46, 0xFD4E,\t0x9F47, 0xFD4F, 0x9F48, 0xFD50, 0x9F49, 0xFD51, 0x9F4A, 0xFD52,\r\n\t0x9F4B, 0xFD53, 0x9F4C, 0xFD54, 0x9F4D, 0xFD55, 0x9F4E, 0xFD56,\t0x9F4F, 0xFD57, 0x9F50, 0xC6EB, 0x9F51, 0xECB4, 0x9F52, 0xFD58,\r\n\t0x9F53, 0xFD59, 0x9F54, 0xFD5A, 0x9F55, 0xFD5B, 0x9F56, 0xFD5C,\t0x9F57, 0xFD5D, 0x9F58, 0xFD5E, 0x9F59, 0xFD5F, 0x9F5A, 0xFD60,\r\n\t0x9F5B, 0xFD61, 0x9F5C, 0xFD62, 0x9F5D, 0xFD63, 0x9F5E, 0xFD64,\t0x9F5F, 0xFD65, 0x9F60, 0xFD66, 0x9F61, 0xFD67, 0x9F62, 0xFD68,\r\n\t0x9F63, 0xFD69, 0x9F64, 0xFD6A, 0x9F65, 0xFD6B, 0x9F66, 0xFD6C,\t0x9F67, 0xFD6D, 0x9F68, 0xFD6E, 0x9F69, 0xFD6F, 0x9F6A, 0xFD70,\r\n\t0x9F6B, 0xFD71, 0x9F6C, 0xFD72, 0x9F6D, 0xFD73, 0x9F6E, 0xFD74,\t0x9F6F, 0xFD75, 0x9F70, 0xFD76, 0x9F71, 0xFD77, 0x9F72, 0xFD78,\r\n\t0x9F73, 0xFD79, 0x9F74, 0xFD7A, 0x9F75, 0xFD7B, 0x9F76, 0xFD7C,\t0x9F77, 0xFD7D, 0x9F78, 0xFD7E, 0x9F79, 0xFD80, 0x9F7A, 0xFD81,\r\n\t0x9F7B, 0xFD82, 0x9F7C, 0xFD83, 0x9F7D, 0xFD84, 0x9F7E, 0xFD85,\t0x9F7F, 0xB3DD, 0x9F80, 0xF6B3, 0x9F81, 0xFD86, 0x9F82, 0xFD87,\r\n\t0x9F83, 0xF6B4, 0x9F84, 0xC1E4, 0x9F85, 0xF6B5, 0x9F86, 0xF6B6,\t0x9F87, 0xF6B7, 0x9F88, 0xF6B8, 0x9F89, 0xF6B9, 0x9F8A, 0xF6BA,\r\n\t0x9F8B, 0xC8A3, 0x9F8C, 0xF6BB, 0x9F8D, 0xFD88, 0x9F8E, 0xFD89,\t0x9F8F, 0xFD8A, 0x9F90, 0xFD8B, 0x9F91, 0xFD8C, 0x9F92, 0xFD8D,\r\n\t0x9F93, 0xFD8E, 0x9F94, 0xFD8F, 0x9F95, 0xFD90, 0x9F96, 0xFD91,\t0x9F97, 0xFD92, 0x9F98, 0xFD93, 0x9F99, 0xC1FA, 0x9F9A, 0xB9A8,\r\n\t0x9F9B, 0xEDE8, 0x9F9C, 0xFD94, 0x9F9D, 0xFD95, 0x9F9E, 0xFD96,\t0x9F9F, 0xB9EA, 0x9FA0, 0xD9DF, 0x9FA1, 0xFD97, 0x9FA2, 0xFD98,\r\n\t0x9FA3, 0xFD99, 0x9FA4, 0xFD9A, 0x9FA5, 0xFD9B, 0xF92C, 0xFD9C,\t0xF979, 0xFD9D, 0xF995, 0xFD9E, 0xF9E7, 0xFD9F, 0xF9F1, 0xFDA0,\r\n\t0xFA0C, 0xFE40, 0xFA0D, 0xFE41, 0xFA0E, 0xFE42, 0xFA0F, 0xFE43,\t0xFA11, 0xFE44, 0xFA13, 0xFE45, 0xFA14, 0xFE46, 0xFA18, 0xFE47,\r\n\t0xFA1F, 0xFE48, 0xFA20, 0xFE49, 0xFA21, 0xFE4A, 0xFA23, 0xFE4B,\t0xFA24, 0xFE4C, 0xFA27, 0xFE4D, 0xFA28, 0xFE4E, 0xFA29, 0xFE4F,\r\n\t0xFE30, 0xA955, 0xFE31, 0xA6F2, 0xFE33, 0xA6F4, 0xFE34, 0xA6F5,\t0xFE35, 0xA6E0, 0xFE36, 0xA6E1, 0xFE37, 0xA6F0, 0xFE38, 0xA6F1,\r\n\t0xFE39, 0xA6E2, 0xFE3A, 0xA6E3, 0xFE3B, 0xA6EE, 0xFE3C, 0xA6EF,\t0xFE3D, 0xA6E6, 0xFE3E, 0xA6E7, 0xFE3F, 0xA6E4, 0xFE40, 0xA6E5,\r\n\t0xFE41, 0xA6E8, 0xFE42, 0xA6E9, 0xFE43, 0xA6EA, 0xFE44, 0xA6EB,\t0xFE49, 0xA968, 0xFE4A, 0xA969, 0xFE4B, 0xA96A, 0xFE4C, 0xA96B,\r\n\t0xFE4D, 0xA96C, 0xFE4E, 0xA96D, 0xFE4F, 0xA96E, 0xFE50, 0xA96F,\t0xFE51, 0xA970, 0xFE52, 0xA971, 0xFE54, 0xA972, 0xFE55, 0xA973,\r\n\t0xFE56, 0xA974, 0xFE57, 0xA975, 0xFE59, 0xA976, 0xFE5A, 0xA977,\t0xFE5B, 0xA978, 0xFE5C, 0xA979, 0xFE5D, 0xA97A, 0xFE5E, 0xA97B,\r\n\t0xFE5F, 0xA97C, 0xFE60, 0xA97D, 0xFE61, 0xA97E, 0xFE62, 0xA980,\t0xFE63, 0xA981, 0xFE64, 0xA982, 0xFE65, 0xA983, 0xFE66, 0xA984,\r\n\t0xFE68, 0xA985, 0xFE69, 0xA986, 0xFE6A, 0xA987, 0xFE6B, 0xA988,\t0xFF01, 0xA3A1, 0xFF02, 0xA3A2, 0xFF03, 0xA3A3, 0xFF04, 0xA1E7,\r\n\t0xFF05, 0xA3A5, 0xFF06, 0xA3A6, 0xFF07, 0xA3A7, 0xFF08, 0xA3A8,\t0xFF09, 0xA3A9, 0xFF0A, 0xA3AA, 0xFF0B, 0xA3AB, 0xFF0C, 0xA3AC,\r\n\t0xFF0D, 0xA3AD, 0xFF0E, 0xA3AE, 0xFF0F, 0xA3AF, 0xFF10, 0xA3B0,\t0xFF11, 0xA3B1, 0xFF12, 0xA3B2, 0xFF13, 0xA3B3, 0xFF14, 0xA3B4,\r\n\t0xFF15, 0xA3B5, 0xFF16, 0xA3B6, 0xFF17, 0xA3B7, 0xFF18, 0xA3B8,\t0xFF19, 0xA3B9, 0xFF1A, 0xA3BA, 0xFF1B, 0xA3BB, 0xFF1C, 0xA3BC,\r\n\t0xFF1D, 0xA3BD, 0xFF1E, 0xA3BE, 0xFF1F, 0xA3BF, 0xFF20, 0xA3C0,\t0xFF21, 0xA3C1, 0xFF22, 0xA3C2, 0xFF23, 0xA3C3, 0xFF24, 0xA3C4,\r\n\t0xFF25, 0xA3C5, 0xFF26, 0xA3C6, 0xFF27, 0xA3C7, 0xFF28, 0xA3C8,\t0xFF29, 0xA3C9, 0xFF2A, 0xA3CA, 0xFF2B, 0xA3CB, 0xFF2C, 0xA3CC,\r\n\t0xFF2D, 0xA3CD, 0xFF2E, 0xA3CE, 0xFF2F, 0xA3CF, 0xFF30, 0xA3D0,\t0xFF31, 0xA3D1, 0xFF32, 0xA3D2, 0xFF33, 0xA3D3, 0xFF34, 0xA3D4,\r\n\t0xFF35, 0xA3D5, 0xFF36, 0xA3D6, 0xFF37, 0xA3D7, 0xFF38, 0xA3D8,\t0xFF39, 0xA3D9, 0xFF3A, 0xA3DA, 0xFF3B, 0xA3DB, 0xFF3C, 0xA3DC,\r\n\t0xFF3D, 0xA3DD, 0xFF3E, 0xA3DE, 0xFF3F, 0xA3DF, 0xFF40, 0xA3E0,\t0xFF41, 0xA3E1, 0xFF42, 0xA3E2, 0xFF43, 0xA3E3, 0xFF44, 0xA3E4,\r\n\t0xFF45, 0xA3E5, 0xFF46, 0xA3E6, 0xFF47, 0xA3E7, 0xFF48, 0xA3E8,\t0xFF49, 0xA3E9, 0xFF4A, 0xA3EA, 0xFF4B, 0xA3EB, 0xFF4C, 0xA3EC,\r\n\t0xFF4D, 0xA3ED, 0xFF4E, 0xA3EE, 0xFF4F, 0xA3EF, 0xFF50, 0xA3F0,\t0xFF51, 0xA3F1, 0xFF52, 0xA3F2, 0xFF53, 0xA3F3, 0xFF54, 0xA3F4,\r\n\t0xFF55, 0xA3F5, 0xFF56, 0xA3F6, 0xFF57, 0xA3F7, 0xFF58, 0xA3F8,\t0xFF59, 0xA3F9, 0xFF5A, 0xA3FA, 0xFF5B, 0xA3FB, 0xFF5C, 0xA3FC,\r\n\t0xFF5D, 0xA3FD, 0xFF5E, 0xA1AB, 0xFFE0, 0xA1E9, 0xFFE1, 0xA1EA,\t0xFFE2, 0xA956, 0xFFE3, 0xA3FE, 0xFFE4, 0xA957, 0xFFE5, 0xA3A4,\r\n\t0, 0\r\n};\r\n\r\nstatic const WCHAR oem2uni936[] = {\t/* GBK --> Unicode pairs */\r\n\t0x0080, 0x20AC, 0x8140, 0x4E02, 0x8141, 0x4E04, 0x8142, 0x4E05,\t0x8143, 0x4E06, 0x8144, 0x4E0F, 0x8145, 0x4E12, 0x8146, 0x4E17,\r\n\t0x8147, 0x4E1F, 0x8148, 0x4E20, 0x8149, 0x4E21, 0x814A, 0x4E23,\t0x814B, 0x4E26, 0x814C, 0x4E29, 0x814D, 0x4E2E, 0x814E, 0x4E2F,\r\n\t0x814F, 0x4E31, 0x8150, 0x4E33, 0x8151, 0x4E35, 0x8152, 0x4E37,\t0x8153, 0x4E3C, 0x8154, 0x4E40, 0x8155, 0x4E41, 0x8156, 0x4E42,\r\n\t0x8157, 0x4E44, 0x8158, 0x4E46, 0x8159, 0x4E4A, 0x815A, 0x4E51,\t0x815B, 0x4E55, 0x815C, 0x4E57, 0x815D, 0x4E5A, 0x815E, 0x4E5B,\r\n\t0x815F, 0x4E62, 0x8160, 0x4E63, 0x8161, 0x4E64, 0x8162, 0x4E65,\t0x8163, 0x4E67, 0x8164, 0x4E68, 0x8165, 0x4E6A, 0x8166, 0x4E6B,\r\n\t0x8167, 0x4E6C, 0x8168, 0x4E6D, 0x8169, 0x4E6E, 0x816A, 0x4E6F,\t0x816B, 0x4E72, 0x816C, 0x4E74, 0x816D, 0x4E75, 0x816E, 0x4E76,\r\n\t0x816F, 0x4E77, 0x8170, 0x4E78, 0x8171, 0x4E79, 0x8172, 0x4E7A,\t0x8173, 0x4E7B, 0x8174, 0x4E7C, 0x8175, 0x4E7D, 0x8176, 0x4E7F,\r\n\t0x8177, 0x4E80, 0x8178, 0x4E81, 0x8179, 0x4E82, 0x817A, 0x4E83,\t0x817B, 0x4E84, 0x817C, 0x4E85, 0x817D, 0x4E87, 0x817E, 0x4E8A,\r\n\t0x8180, 0x4E90, 0x8181, 0x4E96, 0x8182, 0x4E97, 0x8183, 0x4E99,\t0x8184, 0x4E9C, 0x8185, 0x4E9D, 0x8186, 0x4E9E, 0x8187, 0x4EA3,\r\n\t0x8188, 0x4EAA, 0x8189, 0x4EAF, 0x818A, 0x4EB0, 0x818B, 0x4EB1,\t0x818C, 0x4EB4, 0x818D, 0x4EB6, 0x818E, 0x4EB7, 0x818F, 0x4EB8,\r\n\t0x8190, 0x4EB9, 0x8191, 0x4EBC, 0x8192, 0x4EBD, 0x8193, 0x4EBE,\t0x8194, 0x4EC8, 0x8195, 0x4ECC, 0x8196, 0x4ECF, 0x8197, 0x4ED0,\r\n\t0x8198, 0x4ED2, 0x8199, 0x4EDA, 0x819A, 0x4EDB, 0x819B, 0x4EDC,\t0x819C, 0x4EE0, 0x819D, 0x4EE2, 0x819E, 0x4EE6, 0x819F, 0x4EE7,\r\n\t0x81A0, 0x4EE9, 0x81A1, 0x4EED, 0x81A2, 0x4EEE, 0x81A3, 0x4EEF,\t0x81A4, 0x4EF1, 0x81A5, 0x4EF4, 0x81A6, 0x4EF8, 0x81A7, 0x4EF9,\r\n\t0x81A8, 0x4EFA, 0x81A9, 0x4EFC, 0x81AA, 0x4EFE, 0x81AB, 0x4F00,\t0x81AC, 0x4F02, 0x81AD, 0x4F03, 0x81AE, 0x4F04, 0x81AF, 0x4F05,\r\n\t0x81B0, 0x4F06, 0x81B1, 0x4F07, 0x81B2, 0x4F08, 0x81B3, 0x4F0B,\t0x81B4, 0x4F0C, 0x81B5, 0x4F12, 0x81B6, 0x4F13, 0x81B7, 0x4F14,\r\n\t0x81B8, 0x4F15, 0x81B9, 0x4F16, 0x81BA, 0x4F1C, 0x81BB, 0x4F1D,\t0x81BC, 0x4F21, 0x81BD, 0x4F23, 0x81BE, 0x4F28, 0x81BF, 0x4F29,\r\n\t0x81C0, 0x4F2C, 0x81C1, 0x4F2D, 0x81C2, 0x4F2E, 0x81C3, 0x4F31,\t0x81C4, 0x4F33, 0x81C5, 0x4F35, 0x81C6, 0x4F37, 0x81C7, 0x4F39,\r\n\t0x81C8, 0x4F3B, 0x81C9, 0x4F3E, 0x81CA, 0x4F3F, 0x81CB, 0x4F40,\t0x81CC, 0x4F41, 0x81CD, 0x4F42, 0x81CE, 0x4F44, 0x81CF, 0x4F45,\r\n\t0x81D0, 0x4F47, 0x81D1, 0x4F48, 0x81D2, 0x4F49, 0x81D3, 0x4F4A,\t0x81D4, 0x4F4B, 0x81D5, 0x4F4C, 0x81D6, 0x4F52, 0x81D7, 0x4F54,\r\n\t0x81D8, 0x4F56, 0x81D9, 0x4F61, 0x81DA, 0x4F62, 0x81DB, 0x4F66,\t0x81DC, 0x4F68, 0x81DD, 0x4F6A, 0x81DE, 0x4F6B, 0x81DF, 0x4F6D,\r\n\t0x81E0, 0x4F6E, 0x81E1, 0x4F71, 0x81E2, 0x4F72, 0x81E3, 0x4F75,\t0x81E4, 0x4F77, 0x81E5, 0x4F78, 0x81E6, 0x4F79, 0x81E7, 0x4F7A,\r\n\t0x81E8, 0x4F7D, 0x81E9, 0x4F80, 0x81EA, 0x4F81, 0x81EB, 0x4F82,\t0x81EC, 0x4F85, 0x81ED, 0x4F86, 0x81EE, 0x4F87, 0x81EF, 0x4F8A,\r\n\t0x81F0, 0x4F8C, 0x81F1, 0x4F8E, 0x81F2, 0x4F90, 0x81F3, 0x4F92,\t0x81F4, 0x4F93, 0x81F5, 0x4F95, 0x81F6, 0x4F96, 0x81F7, 0x4F98,\r\n\t0x81F8, 0x4F99, 0x81F9, 0x4F9A, 0x81FA, 0x4F9C, 0x81FB, 0x4F9E,\t0x81FC, 0x4F9F, 0x81FD, 0x4FA1, 0x81FE, 0x4FA2, 0x8240, 0x4FA4,\r\n\t0x8241, 0x4FAB, 0x8242, 0x4FAD, 0x8243, 0x4FB0, 0x8244, 0x4FB1,\t0x8245, 0x4FB2, 0x8246, 0x4FB3, 0x8247, 0x4FB4, 0x8248, 0x4FB6,\r\n\t0x8249, 0x4FB7, 0x824A, 0x4FB8, 0x824B, 0x4FB9, 0x824C, 0x4FBA,\t0x824D, 0x4FBB, 0x824E, 0x4FBC, 0x824F, 0x4FBD, 0x8250, 0x4FBE,\r\n\t0x8251, 0x4FC0, 0x8252, 0x4FC1, 0x8253, 0x4FC2, 0x8254, 0x4FC6,\t0x8255, 0x4FC7, 0x8256, 0x4FC8, 0x8257, 0x4FC9, 0x8258, 0x4FCB,\r\n\t0x8259, 0x4FCC, 0x825A, 0x4FCD, 0x825B, 0x4FD2, 0x825C, 0x4FD3,\t0x825D, 0x4FD4, 0x825E, 0x4FD5, 0x825F, 0x4FD6, 0x8260, 0x4FD9,\r\n\t0x8261, 0x4FDB, 0x8262, 0x4FE0, 0x8263, 0x4FE2, 0x8264, 0x4FE4,\t0x8265, 0x4FE5, 0x8266, 0x4FE7, 0x8267, 0x4FEB, 0x8268, 0x4FEC,\r\n\t0x8269, 0x4FF0, 0x826A, 0x4FF2, 0x826B, 0x4FF4, 0x826C, 0x4FF5,\t0x826D, 0x4FF6, 0x826E, 0x4FF7, 0x826F, 0x4FF9, 0x8270, 0x4FFB,\r\n\t0x8271, 0x4FFC, 0x8272, 0x4FFD, 0x8273, 0x4FFF, 0x8274, 0x5000,\t0x8275, 0x5001, 0x8276, 0x5002, 0x8277, 0x5003, 0x8278, 0x5004,\r\n\t0x8279, 0x5005, 0x827A, 0x5006, 0x827B, 0x5007, 0x827C, 0x5008,\t0x827D, 0x5009, 0x827E, 0x500A, 0x8280, 0x500B, 0x8281, 0x500E,\r\n\t0x8282, 0x5010, 0x8283, 0x5011, 0x8284, 0x5013, 0x8285, 0x5015,\t0x8286, 0x5016, 0x8287, 0x5017, 0x8288, 0x501B, 0x8289, 0x501D,\r\n\t0x828A, 0x501E, 0x828B, 0x5020, 0x828C, 0x5022, 0x828D, 0x5023,\t0x828E, 0x5024, 0x828F, 0x5027, 0x8290, 0x502B, 0x8291, 0x502F,\r\n\t0x8292, 0x5030, 0x8293, 0x5031, 0x8294, 0x5032, 0x8295, 0x5033,\t0x8296, 0x5034, 0x8297, 0x5035, 0x8298, 0x5036, 0x8299, 0x5037,\r\n\t0x829A, 0x5038, 0x829B, 0x5039, 0x829C, 0x503B, 0x829D, 0x503D,\t0x829E, 0x503F, 0x829F, 0x5040, 0x82A0, 0x5041, 0x82A1, 0x5042,\r\n\t0x82A2, 0x5044, 0x82A3, 0x5045, 0x82A4, 0x5046, 0x82A5, 0x5049,\t0x82A6, 0x504A, 0x82A7, 0x504B, 0x82A8, 0x504D, 0x82A9, 0x5050,\r\n\t0x82AA, 0x5051, 0x82AB, 0x5052, 0x82AC, 0x5053, 0x82AD, 0x5054,\t0x82AE, 0x5056, 0x82AF, 0x5057, 0x82B0, 0x5058, 0x82B1, 0x5059,\r\n\t0x82B2, 0x505B, 0x82B3, 0x505D, 0x82B4, 0x505E, 0x82B5, 0x505F,\t0x82B6, 0x5060, 0x82B7, 0x5061, 0x82B8, 0x5062, 0x82B9, 0x5063,\r\n\t0x82BA, 0x5064, 0x82BB, 0x5066, 0x82BC, 0x5067, 0x82BD, 0x5068,\t0x82BE, 0x5069, 0x82BF, 0x506A, 0x82C0, 0x506B, 0x82C1, 0x506D,\r\n\t0x82C2, 0x506E, 0x82C3, 0x506F, 0x82C4, 0x5070, 0x82C5, 0x5071,\t0x82C6, 0x5072, 0x82C7, 0x5073, 0x82C8, 0x5074, 0x82C9, 0x5075,\r\n\t0x82CA, 0x5078, 0x82CB, 0x5079, 0x82CC, 0x507A, 0x82CD, 0x507C,\t0x82CE, 0x507D, 0x82CF, 0x5081, 0x82D0, 0x5082, 0x82D1, 0x5083,\r\n\t0x82D2, 0x5084, 0x82D3, 0x5086, 0x82D4, 0x5087, 0x82D5, 0x5089,\t0x82D6, 0x508A, 0x82D7, 0x508B, 0x82D8, 0x508C, 0x82D9, 0x508E,\r\n\t0x82DA, 0x508F, 0x82DB, 0x5090, 0x82DC, 0x5091, 0x82DD, 0x5092,\t0x82DE, 0x5093, 0x82DF, 0x5094, 0x82E0, 0x5095, 0x82E1, 0x5096,\r\n\t0x82E2, 0x5097, 0x82E3, 0x5098, 0x82E4, 0x5099, 0x82E5, 0x509A,\t0x82E6, 0x509B, 0x82E7, 0x509C, 0x82E8, 0x509D, 0x82E9, 0x509E,\r\n\t0x82EA, 0x509F, 0x82EB, 0x50A0, 0x82EC, 0x50A1, 0x82ED, 0x50A2,\t0x82EE, 0x50A4, 0x82EF, 0x50A6, 0x82F0, 0x50AA, 0x82F1, 0x50AB,\r\n\t0x82F2, 0x50AD, 0x82F3, 0x50AE, 0x82F4, 0x50AF, 0x82F5, 0x50B0,\t0x82F6, 0x50B1, 0x82F7, 0x50B3, 0x82F8, 0x50B4, 0x82F9, 0x50B5,\r\n\t0x82FA, 0x50B6, 0x82FB, 0x50B7, 0x82FC, 0x50B8, 0x82FD, 0x50B9,\t0x82FE, 0x50BC, 0x8340, 0x50BD, 0x8341, 0x50BE, 0x8342, 0x50BF,\r\n\t0x8343, 0x50C0, 0x8344, 0x50C1, 0x8345, 0x50C2, 0x8346, 0x50C3,\t0x8347, 0x50C4, 0x8348, 0x50C5, 0x8349, 0x50C6, 0x834A, 0x50C7,\r\n\t0x834B, 0x50C8, 0x834C, 0x50C9, 0x834D, 0x50CA, 0x834E, 0x50CB,\t0x834F, 0x50CC, 0x8350, 0x50CD, 0x8351, 0x50CE, 0x8352, 0x50D0,\r\n\t0x8353, 0x50D1, 0x8354, 0x50D2, 0x8355, 0x50D3, 0x8356, 0x50D4,\t0x8357, 0x50D5, 0x8358, 0x50D7, 0x8359, 0x50D8, 0x835A, 0x50D9,\r\n\t0x835B, 0x50DB, 0x835C, 0x50DC, 0x835D, 0x50DD, 0x835E, 0x50DE,\t0x835F, 0x50DF, 0x8360, 0x50E0, 0x8361, 0x50E1, 0x8362, 0x50E2,\r\n\t0x8363, 0x50E3, 0x8364, 0x50E4, 0x8365, 0x50E5, 0x8366, 0x50E8,\t0x8367, 0x50E9, 0x8368, 0x50EA, 0x8369, 0x50EB, 0x836A, 0x50EF,\r\n\t0x836B, 0x50F0, 0x836C, 0x50F1, 0x836D, 0x50F2, 0x836E, 0x50F4,\t0x836F, 0x50F6, 0x8370, 0x50F7, 0x8371, 0x50F8, 0x8372, 0x50F9,\r\n\t0x8373, 0x50FA, 0x8374, 0x50FC, 0x8375, 0x50FD, 0x8376, 0x50FE,\t0x8377, 0x50FF, 0x8378, 0x5100, 0x8379, 0x5101, 0x837A, 0x5102,\r\n\t0x837B, 0x5103, 0x837C, 0x5104, 0x837D, 0x5105, 0x837E, 0x5108,\t0x8380, 0x5109, 0x8381, 0x510A, 0x8382, 0x510C, 0x8383, 0x510D,\r\n\t0x8384, 0x510E, 0x8385, 0x510F, 0x8386, 0x5110, 0x8387, 0x5111,\t0x8388, 0x5113, 0x8389, 0x5114, 0x838A, 0x5115, 0x838B, 0x5116,\r\n\t0x838C, 0x5117, 0x838D, 0x5118, 0x838E, 0x5119, 0x838F, 0x511A,\t0x8390, 0x511B, 0x8391, 0x511C, 0x8392, 0x511D, 0x8393, 0x511E,\r\n\t0x8394, 0x511F, 0x8395, 0x5120, 0x8396, 0x5122, 0x8397, 0x5123,\t0x8398, 0x5124, 0x8399, 0x5125, 0x839A, 0x5126, 0x839B, 0x5127,\r\n\t0x839C, 0x5128, 0x839D, 0x5129, 0x839E, 0x512A, 0x839F, 0x512B,\t0x83A0, 0x512C, 0x83A1, 0x512D, 0x83A2, 0x512E, 0x83A3, 0x512F,\r\n\t0x83A4, 0x5130, 0x83A5, 0x5131, 0x83A6, 0x5132, 0x83A7, 0x5133,\t0x83A8, 0x5134, 0x83A9, 0x5135, 0x83AA, 0x5136, 0x83AB, 0x5137,\r\n\t0x83AC, 0x5138, 0x83AD, 0x5139, 0x83AE, 0x513A, 0x83AF, 0x513B,\t0x83B0, 0x513C, 0x83B1, 0x513D, 0x83B2, 0x513E, 0x83B3, 0x5142,\r\n\t0x83B4, 0x5147, 0x83B5, 0x514A, 0x83B6, 0x514C, 0x83B7, 0x514E,\t0x83B8, 0x514F, 0x83B9, 0x5150, 0x83BA, 0x5152, 0x83BB, 0x5153,\r\n\t0x83BC, 0x5157, 0x83BD, 0x5158, 0x83BE, 0x5159, 0x83BF, 0x515B,\t0x83C0, 0x515D, 0x83C1, 0x515E, 0x83C2, 0x515F, 0x83C3, 0x5160,\r\n\t0x83C4, 0x5161, 0x83C5, 0x5163, 0x83C6, 0x5164, 0x83C7, 0x5166,\t0x83C8, 0x5167, 0x83C9, 0x5169, 0x83CA, 0x516A, 0x83CB, 0x516F,\r\n\t0x83CC, 0x5172, 0x83CD, 0x517A, 0x83CE, 0x517E, 0x83CF, 0x517F,\t0x83D0, 0x5183, 0x83D1, 0x5184, 0x83D2, 0x5186, 0x83D3, 0x5187,\r\n\t0x83D4, 0x518A, 0x83D5, 0x518B, 0x83D6, 0x518E, 0x83D7, 0x518F,\t0x83D8, 0x5190, 0x83D9, 0x5191, 0x83DA, 0x5193, 0x83DB, 0x5194,\r\n\t0x83DC, 0x5198, 0x83DD, 0x519A, 0x83DE, 0x519D, 0x83DF, 0x519E,\t0x83E0, 0x519F, 0x83E1, 0x51A1, 0x83E2, 0x51A3, 0x83E3, 0x51A6,\r\n\t0x83E4, 0x51A7, 0x83E5, 0x51A8, 0x83E6, 0x51A9, 0x83E7, 0x51AA,\t0x83E8, 0x51AD, 0x83E9, 0x51AE, 0x83EA, 0x51B4, 0x83EB, 0x51B8,\r\n\t0x83EC, 0x51B9, 0x83ED, 0x51BA, 0x83EE, 0x51BE, 0x83EF, 0x51BF,\t0x83F0, 0x51C1, 0x83F1, 0x51C2, 0x83F2, 0x51C3, 0x83F3, 0x51C5,\r\n\t0x83F4, 0x51C8, 0x83F5, 0x51CA, 0x83F6, 0x51CD, 0x83F7, 0x51CE,\t0x83F8, 0x51D0, 0x83F9, 0x51D2, 0x83FA, 0x51D3, 0x83FB, 0x51D4,\r\n\t0x83FC, 0x51D5, 0x83FD, 0x51D6, 0x83FE, 0x51D7, 0x8440, 0x51D8,\t0x8441, 0x51D9, 0x8442, 0x51DA, 0x8443, 0x51DC, 0x8444, 0x51DE,\r\n\t0x8445, 0x51DF, 0x8446, 0x51E2, 0x8447, 0x51E3, 0x8448, 0x51E5,\t0x8449, 0x51E6, 0x844A, 0x51E7, 0x844B, 0x51E8, 0x844C, 0x51E9,\r\n\t0x844D, 0x51EA, 0x844E, 0x51EC, 0x844F, 0x51EE, 0x8450, 0x51F1,\t0x8451, 0x51F2, 0x8452, 0x51F4, 0x8453, 0x51F7, 0x8454, 0x51FE,\r\n\t0x8455, 0x5204, 0x8456, 0x5205, 0x8457, 0x5209, 0x8458, 0x520B,\t0x8459, 0x520C, 0x845A, 0x520F, 0x845B, 0x5210, 0x845C, 0x5213,\r\n\t0x845D, 0x5214, 0x845E, 0x5215, 0x845F, 0x521C, 0x8460, 0x521E,\t0x8461, 0x521F, 0x8462, 0x5221, 0x8463, 0x5222, 0x8464, 0x5223,\r\n\t0x8465, 0x5225, 0x8466, 0x5226, 0x8467, 0x5227, 0x8468, 0x522A,\t0x8469, 0x522C, 0x846A, 0x522F, 0x846B, 0x5231, 0x846C, 0x5232,\r\n\t0x846D, 0x5234, 0x846E, 0x5235, 0x846F, 0x523C, 0x8470, 0x523E,\t0x8471, 0x5244, 0x8472, 0x5245, 0x8473, 0x5246, 0x8474, 0x5247,\r\n\t0x8475, 0x5248, 0x8476, 0x5249, 0x8477, 0x524B, 0x8478, 0x524E,\t0x8479, 0x524F, 0x847A, 0x5252, 0x847B, 0x5253, 0x847C, 0x5255,\r\n\t0x847D, 0x5257, 0x847E, 0x5258, 0x8480, 0x5259, 0x8481, 0x525A,\t0x8482, 0x525B, 0x8483, 0x525D, 0x8484, 0x525F, 0x8485, 0x5260,\r\n\t0x8486, 0x5262, 0x8487, 0x5263, 0x8488, 0x5264, 0x8489, 0x5266,\t0x848A, 0x5268, 0x848B, 0x526B, 0x848C, 0x526C, 0x848D, 0x526D,\r\n\t0x848E, 0x526E, 0x848F, 0x5270, 0x8490, 0x5271, 0x8491, 0x5273,\t0x8492, 0x5274, 0x8493, 0x5275, 0x8494, 0x5276, 0x8495, 0x5277,\r\n\t0x8496, 0x5278, 0x8497, 0x5279, 0x8498, 0x527A, 0x8499, 0x527B,\t0x849A, 0x527C, 0x849B, 0x527E, 0x849C, 0x5280, 0x849D, 0x5283,\r\n\t0x849E, 0x5284, 0x849F, 0x5285, 0x84A0, 0x5286, 0x84A1, 0x5287,\t0x84A2, 0x5289, 0x84A3, 0x528A, 0x84A4, 0x528B, 0x84A5, 0x528C,\r\n\t0x84A6, 0x528D, 0x84A7, 0x528E, 0x84A8, 0x528F, 0x84A9, 0x5291,\t0x84AA, 0x5292, 0x84AB, 0x5294, 0x84AC, 0x5295, 0x84AD, 0x5296,\r\n\t0x84AE, 0x5297, 0x84AF, 0x5298, 0x84B0, 0x5299, 0x84B1, 0x529A,\t0x84B2, 0x529C, 0x84B3, 0x52A4, 0x84B4, 0x52A5, 0x84B5, 0x52A6,\r\n\t0x84B6, 0x52A7, 0x84B7, 0x52AE, 0x84B8, 0x52AF, 0x84B9, 0x52B0,\t0x84BA, 0x52B4, 0x84BB, 0x52B5, 0x84BC, 0x52B6, 0x84BD, 0x52B7,\r\n\t0x84BE, 0x52B8, 0x84BF, 0x52B9, 0x84C0, 0x52BA, 0x84C1, 0x52BB,\t0x84C2, 0x52BC, 0x84C3, 0x52BD, 0x84C4, 0x52C0, 0x84C5, 0x52C1,\r\n\t0x84C6, 0x52C2, 0x84C7, 0x52C4, 0x84C8, 0x52C5, 0x84C9, 0x52C6,\t0x84CA, 0x52C8, 0x84CB, 0x52CA, 0x84CC, 0x52CC, 0x84CD, 0x52CD,\r\n\t0x84CE, 0x52CE, 0x84CF, 0x52CF, 0x84D0, 0x52D1, 0x84D1, 0x52D3,\t0x84D2, 0x52D4, 0x84D3, 0x52D5, 0x84D4, 0x52D7, 0x84D5, 0x52D9,\r\n\t0x84D6, 0x52DA, 0x84D7, 0x52DB, 0x84D8, 0x52DC, 0x84D9, 0x52DD,\t0x84DA, 0x52DE, 0x84DB, 0x52E0, 0x84DC, 0x52E1, 0x84DD, 0x52E2,\r\n\t0x84DE, 0x52E3, 0x84DF, 0x52E5, 0x84E0, 0x52E6, 0x84E1, 0x52E7,\t0x84E2, 0x52E8, 0x84E3, 0x52E9, 0x84E4, 0x52EA, 0x84E5, 0x52EB,\r\n\t0x84E6, 0x52EC, 0x84E7, 0x52ED, 0x84E8, 0x52EE, 0x84E9, 0x52EF,\t0x84EA, 0x52F1, 0x84EB, 0x52F2, 0x84EC, 0x52F3, 0x84ED, 0x52F4,\r\n\t0x84EE, 0x52F5, 0x84EF, 0x52F6, 0x84F0, 0x52F7, 0x84F1, 0x52F8,\t0x84F2, 0x52FB, 0x84F3, 0x52FC, 0x84F4, 0x52FD, 0x84F5, 0x5301,\r\n\t0x84F6, 0x5302, 0x84F7, 0x5303, 0x84F8, 0x5304, 0x84F9, 0x5307,\t0x84FA, 0x5309, 0x84FB, 0x530A, 0x84FC, 0x530B, 0x84FD, 0x530C,\r\n\t0x84FE, 0x530E, 0x8540, 0x5311, 0x8541, 0x5312, 0x8542, 0x5313,\t0x8543, 0x5314, 0x8544, 0x5318, 0x8545, 0x531B, 0x8546, 0x531C,\r\n\t0x8547, 0x531E, 0x8548, 0x531F, 0x8549, 0x5322, 0x854A, 0x5324,\t0x854B, 0x5325, 0x854C, 0x5327, 0x854D, 0x5328, 0x854E, 0x5329,\r\n\t0x854F, 0x532B, 0x8550, 0x532C, 0x8551, 0x532D, 0x8552, 0x532F,\t0x8553, 0x5330, 0x8554, 0x5331, 0x8555, 0x5332, 0x8556, 0x5333,\r\n\t0x8557, 0x5334, 0x8558, 0x5335, 0x8559, 0x5336, 0x855A, 0x5337,\t0x855B, 0x5338, 0x855C, 0x533C, 0x855D, 0x533D, 0x855E, 0x5340,\r\n\t0x855F, 0x5342, 0x8560, 0x5344, 0x8561, 0x5346, 0x8562, 0x534B,\t0x8563, 0x534C, 0x8564, 0x534D, 0x8565, 0x5350, 0x8566, 0x5354,\r\n\t0x8567, 0x5358, 0x8568, 0x5359, 0x8569, 0x535B, 0x856A, 0x535D,\t0x856B, 0x5365, 0x856C, 0x5368, 0x856D, 0x536A, 0x856E, 0x536C,\r\n\t0x856F, 0x536D, 0x8570, 0x5372, 0x8571, 0x5376, 0x8572, 0x5379,\t0x8573, 0x537B, 0x8574, 0x537C, 0x8575, 0x537D, 0x8576, 0x537E,\r\n\t0x8577, 0x5380, 0x8578, 0x5381, 0x8579, 0x5383, 0x857A, 0x5387,\t0x857B, 0x5388, 0x857C, 0x538A, 0x857D, 0x538E, 0x857E, 0x538F,\r\n\t0x8580, 0x5390, 0x8581, 0x5391, 0x8582, 0x5392, 0x8583, 0x5393,\t0x8584, 0x5394, 0x8585, 0x5396, 0x8586, 0x5397, 0x8587, 0x5399,\r\n\t0x8588, 0x539B, 0x8589, 0x539C, 0x858A, 0x539E, 0x858B, 0x53A0,\t0x858C, 0x53A1, 0x858D, 0x53A4, 0x858E, 0x53A7, 0x858F, 0x53AA,\r\n\t0x8590, 0x53AB, 0x8591, 0x53AC, 0x8592, 0x53AD, 0x8593, 0x53AF,\t0x8594, 0x53B0, 0x8595, 0x53B1, 0x8596, 0x53B2, 0x8597, 0x53B3,\r\n\t0x8598, 0x53B4, 0x8599, 0x53B5, 0x859A, 0x53B7, 0x859B, 0x53B8,\t0x859C, 0x53B9, 0x859D, 0x53BA, 0x859E, 0x53BC, 0x859F, 0x53BD,\r\n\t0x85A0, 0x53BE, 0x85A1, 0x53C0, 0x85A2, 0x53C3, 0x85A3, 0x53C4,\t0x85A4, 0x53C5, 0x85A5, 0x53C6, 0x85A6, 0x53C7, 0x85A7, 0x53CE,\r\n\t0x85A8, 0x53CF, 0x85A9, 0x53D0, 0x85AA, 0x53D2, 0x85AB, 0x53D3,\t0x85AC, 0x53D5, 0x85AD, 0x53DA, 0x85AE, 0x53DC, 0x85AF, 0x53DD,\r\n\t0x85B0, 0x53DE, 0x85B1, 0x53E1, 0x85B2, 0x53E2, 0x85B3, 0x53E7,\t0x85B4, 0x53F4, 0x85B5, 0x53FA, 0x85B6, 0x53FE, 0x85B7, 0x53FF,\r\n\t0x85B8, 0x5400, 0x85B9, 0x5402, 0x85BA, 0x5405, 0x85BB, 0x5407,\t0x85BC, 0x540B, 0x85BD, 0x5414, 0x85BE, 0x5418, 0x85BF, 0x5419,\r\n\t0x85C0, 0x541A, 0x85C1, 0x541C, 0x85C2, 0x5422, 0x85C3, 0x5424,\t0x85C4, 0x5425, 0x85C5, 0x542A, 0x85C6, 0x5430, 0x85C7, 0x5433,\r\n\t0x85C8, 0x5436, 0x85C9, 0x5437, 0x85CA, 0x543A, 0x85CB, 0x543D,\t0x85CC, 0x543F, 0x85CD, 0x5441, 0x85CE, 0x5442, 0x85CF, 0x5444,\r\n\t0x85D0, 0x5445, 0x85D1, 0x5447, 0x85D2, 0x5449, 0x85D3, 0x544C,\t0x85D4, 0x544D, 0x85D5, 0x544E, 0x85D6, 0x544F, 0x85D7, 0x5451,\r\n\t0x85D8, 0x545A, 0x85D9, 0x545D, 0x85DA, 0x545E, 0x85DB, 0x545F,\t0x85DC, 0x5460, 0x85DD, 0x5461, 0x85DE, 0x5463, 0x85DF, 0x5465,\r\n\t0x85E0, 0x5467, 0x85E1, 0x5469, 0x85E2, 0x546A, 0x85E3, 0x546B,\t0x85E4, 0x546C, 0x85E5, 0x546D, 0x85E6, 0x546E, 0x85E7, 0x546F,\r\n\t0x85E8, 0x5470, 0x85E9, 0x5474, 0x85EA, 0x5479, 0x85EB, 0x547A,\t0x85EC, 0x547E, 0x85ED, 0x547F, 0x85EE, 0x5481, 0x85EF, 0x5483,\r\n\t0x85F0, 0x5485, 0x85F1, 0x5487, 0x85F2, 0x5488, 0x85F3, 0x5489,\t0x85F4, 0x548A, 0x85F5, 0x548D, 0x85F6, 0x5491, 0x85F7, 0x5493,\r\n\t0x85F8, 0x5497, 0x85F9, 0x5498, 0x85FA, 0x549C, 0x85FB, 0x549E,\t0x85FC, 0x549F, 0x85FD, 0x54A0, 0x85FE, 0x54A1, 0x8640, 0x54A2,\r\n\t0x8641, 0x54A5, 0x8642, 0x54AE, 0x8643, 0x54B0, 0x8644, 0x54B2,\t0x8645, 0x54B5, 0x8646, 0x54B6, 0x8647, 0x54B7, 0x8648, 0x54B9,\r\n\t0x8649, 0x54BA, 0x864A, 0x54BC, 0x864B, 0x54BE, 0x864C, 0x54C3,\t0x864D, 0x54C5, 0x864E, 0x54CA, 0x864F, 0x54CB, 0x8650, 0x54D6,\r\n\t0x8651, 0x54D8, 0x8652, 0x54DB, 0x8653, 0x54E0, 0x8654, 0x54E1,\t0x8655, 0x54E2, 0x8656, 0x54E3, 0x8657, 0x54E4, 0x8658, 0x54EB,\r\n\t0x8659, 0x54EC, 0x865A, 0x54EF, 0x865B, 0x54F0, 0x865C, 0x54F1,\t0x865D, 0x54F4, 0x865E, 0x54F5, 0x865F, 0x54F6, 0x8660, 0x54F7,\r\n\t0x8661, 0x54F8, 0x8662, 0x54F9, 0x8663, 0x54FB, 0x8664, 0x54FE,\t0x8665, 0x5500, 0x8666, 0x5502, 0x8667, 0x5503, 0x8668, 0x5504,\r\n\t0x8669, 0x5505, 0x866A, 0x5508, 0x866B, 0x550A, 0x866C, 0x550B,\t0x866D, 0x550C, 0x866E, 0x550D, 0x866F, 0x550E, 0x8670, 0x5512,\r\n\t0x8671, 0x5513, 0x8672, 0x5515, 0x8673, 0x5516, 0x8674, 0x5517,\t0x8675, 0x5518, 0x8676, 0x5519, 0x8677, 0x551A, 0x8678, 0x551C,\r\n\t0x8679, 0x551D, 0x867A, 0x551E, 0x867B, 0x551F, 0x867C, 0x5521,\t0x867D, 0x5525, 0x867E, 0x5526, 0x8680, 0x5528, 0x8681, 0x5529,\r\n\t0x8682, 0x552B, 0x8683, 0x552D, 0x8684, 0x5532, 0x8685, 0x5534,\t0x8686, 0x5535, 0x8687, 0x5536, 0x8688, 0x5538, 0x8689, 0x5539,\r\n\t0x868A, 0x553A, 0x868B, 0x553B, 0x868C, 0x553D, 0x868D, 0x5540,\t0x868E, 0x5542, 0x868F, 0x5545, 0x8690, 0x5547, 0x8691, 0x5548,\r\n\t0x8692, 0x554B, 0x8693, 0x554C, 0x8694, 0x554D, 0x8695, 0x554E,\t0x8696, 0x554F, 0x8697, 0x5551, 0x8698, 0x5552, 0x8699, 0x5553,\r\n\t0x869A, 0x5554, 0x869B, 0x5557, 0x869C, 0x5558, 0x869D, 0x5559,\t0x869E, 0x555A, 0x869F, 0x555B, 0x86A0, 0x555D, 0x86A1, 0x555E,\r\n\t0x86A2, 0x555F, 0x86A3, 0x5560, 0x86A4, 0x5562, 0x86A5, 0x5563,\t0x86A6, 0x5568, 0x86A7, 0x5569, 0x86A8, 0x556B, 0x86A9, 0x556F,\r\n\t0x86AA, 0x5570, 0x86AB, 0x5571, 0x86AC, 0x5572, 0x86AD, 0x5573,\t0x86AE, 0x5574, 0x86AF, 0x5579, 0x86B0, 0x557A, 0x86B1, 0x557D,\r\n\t0x86B2, 0x557F, 0x86B3, 0x5585, 0x86B4, 0x5586, 0x86B5, 0x558C,\t0x86B6, 0x558D, 0x86B7, 0x558E, 0x86B8, 0x5590, 0x86B9, 0x5592,\r\n\t0x86BA, 0x5593, 0x86BB, 0x5595, 0x86BC, 0x5596, 0x86BD, 0x5597,\t0x86BE, 0x559A, 0x86BF, 0x559B, 0x86C0, 0x559E, 0x86C1, 0x55A0,\r\n\t0x86C2, 0x55A1, 0x86C3, 0x55A2, 0x86C4, 0x55A3, 0x86C5, 0x55A4,\t0x86C6, 0x55A5, 0x86C7, 0x55A6, 0x86C8, 0x55A8, 0x86C9, 0x55A9,\r\n\t0x86CA, 0x55AA, 0x86CB, 0x55AB, 0x86CC, 0x55AC, 0x86CD, 0x55AD,\t0x86CE, 0x55AE, 0x86CF, 0x55AF, 0x86D0, 0x55B0, 0x86D1, 0x55B2,\r\n\t0x86D2, 0x55B4, 0x86D3, 0x55B6, 0x86D4, 0x55B8, 0x86D5, 0x55BA,\t0x86D6, 0x55BC, 0x86D7, 0x55BF, 0x86D8, 0x55C0, 0x86D9, 0x55C1,\r\n\t0x86DA, 0x55C2, 0x86DB, 0x55C3, 0x86DC, 0x55C6, 0x86DD, 0x55C7,\t0x86DE, 0x55C8, 0x86DF, 0x55CA, 0x86E0, 0x55CB, 0x86E1, 0x55CE,\r\n\t0x86E2, 0x55CF, 0x86E3, 0x55D0, 0x86E4, 0x55D5, 0x86E5, 0x55D7,\t0x86E6, 0x55D8, 0x86E7, 0x55D9, 0x86E8, 0x55DA, 0x86E9, 0x55DB,\r\n\t0x86EA, 0x55DE, 0x86EB, 0x55E0, 0x86EC, 0x55E2, 0x86ED, 0x55E7,\t0x86EE, 0x55E9, 0x86EF, 0x55ED, 0x86F0, 0x55EE, 0x86F1, 0x55F0,\r\n\t0x86F2, 0x55F1, 0x86F3, 0x55F4, 0x86F4, 0x55F6, 0x86F5, 0x55F8,\t0x86F6, 0x55F9, 0x86F7, 0x55FA, 0x86F8, 0x55FB, 0x86F9, 0x55FC,\r\n\t0x86FA, 0x55FF, 0x86FB, 0x5602, 0x86FC, 0x5603, 0x86FD, 0x5604,\t0x86FE, 0x5605, 0x8740, 0x5606, 0x8741, 0x5607, 0x8742, 0x560A,\r\n\t0x8743, 0x560B, 0x8744, 0x560D, 0x8745, 0x5610, 0x8746, 0x5611,\t0x8747, 0x5612, 0x8748, 0x5613, 0x8749, 0x5614, 0x874A, 0x5615,\r\n\t0x874B, 0x5616, 0x874C, 0x5617, 0x874D, 0x5619, 0x874E, 0x561A,\t0x874F, 0x561C, 0x8750, 0x561D, 0x8751, 0x5620, 0x8752, 0x5621,\r\n\t0x8753, 0x5622, 0x8754, 0x5625, 0x8755, 0x5626, 0x8756, 0x5628,\t0x8757, 0x5629, 0x8758, 0x562A, 0x8759, 0x562B, 0x875A, 0x562E,\r\n\t0x875B, 0x562F, 0x875C, 0x5630, 0x875D, 0x5633, 0x875E, 0x5635,\t0x875F, 0x5637, 0x8760, 0x5638, 0x8761, 0x563A, 0x8762, 0x563C,\r\n\t0x8763, 0x563D, 0x8764, 0x563E, 0x8765, 0x5640, 0x8766, 0x5641,\t0x8767, 0x5642, 0x8768, 0x5643, 0x8769, 0x5644, 0x876A, 0x5645,\r\n\t0x876B, 0x5646, 0x876C, 0x5647, 0x876D, 0x5648, 0x876E, 0x5649,\t0x876F, 0x564A, 0x8770, 0x564B, 0x8771, 0x564F, 0x8772, 0x5650,\r\n\t0x8773, 0x5651, 0x8774, 0x5652, 0x8775, 0x5653, 0x8776, 0x5655,\t0x8777, 0x5656, 0x8778, 0x565A, 0x8779, 0x565B, 0x877A, 0x565D,\r\n\t0x877B, 0x565E, 0x877C, 0x565F, 0x877D, 0x5660, 0x877E, 0x5661,\t0x8780, 0x5663, 0x8781, 0x5665, 0x8782, 0x5666, 0x8783, 0x5667,\r\n\t0x8784, 0x566D, 0x8785, 0x566E, 0x8786, 0x566F, 0x8787, 0x5670,\t0x8788, 0x5672, 0x8789, 0x5673, 0x878A, 0x5674, 0x878B, 0x5675,\r\n\t0x878C, 0x5677, 0x878D, 0x5678, 0x878E, 0x5679, 0x878F, 0x567A,\t0x8790, 0x567D, 0x8791, 0x567E, 0x8792, 0x567F, 0x8793, 0x5680,\r\n\t0x8794, 0x5681, 0x8795, 0x5682, 0x8796, 0x5683, 0x8797, 0x5684,\t0x8798, 0x5687, 0x8799, 0x5688, 0x879A, 0x5689, 0x879B, 0x568A,\r\n\t0x879C, 0x568B, 0x879D, 0x568C, 0x879E, 0x568D, 0x879F, 0x5690,\t0x87A0, 0x5691, 0x87A1, 0x5692, 0x87A2, 0x5694, 0x87A3, 0x5695,\r\n\t0x87A4, 0x5696, 0x87A5, 0x5697, 0x87A6, 0x5698, 0x87A7, 0x5699,\t0x87A8, 0x569A, 0x87A9, 0x569B, 0x87AA, 0x569C, 0x87AB, 0x569D,\r\n\t0x87AC, 0x569E, 0x87AD, 0x569F, 0x87AE, 0x56A0, 0x87AF, 0x56A1,\t0x87B0, 0x56A2, 0x87B1, 0x56A4, 0x87B2, 0x56A5, 0x87B3, 0x56A6,\r\n\t0x87B4, 0x56A7, 0x87B5, 0x56A8, 0x87B6, 0x56A9, 0x87B7, 0x56AA,\t0x87B8, 0x56AB, 0x87B9, 0x56AC, 0x87BA, 0x56AD, 0x87BB, 0x56AE,\r\n\t0x87BC, 0x56B0, 0x87BD, 0x56B1, 0x87BE, 0x56B2, 0x87BF, 0x56B3,\t0x87C0, 0x56B4, 0x87C1, 0x56B5, 0x87C2, 0x56B6, 0x87C3, 0x56B8,\r\n\t0x87C4, 0x56B9, 0x87C5, 0x56BA, 0x87C6, 0x56BB, 0x87C7, 0x56BD,\t0x87C8, 0x56BE, 0x87C9, 0x56BF, 0x87CA, 0x56C0, 0x87CB, 0x56C1,\r\n\t0x87CC, 0x56C2, 0x87CD, 0x56C3, 0x87CE, 0x56C4, 0x87CF, 0x56C5,\t0x87D0, 0x56C6, 0x87D1, 0x56C7, 0x87D2, 0x56C8, 0x87D3, 0x56C9,\r\n\t0x87D4, 0x56CB, 0x87D5, 0x56CC, 0x87D6, 0x56CD, 0x87D7, 0x56CE,\t0x87D8, 0x56CF, 0x87D9, 0x56D0, 0x87DA, 0x56D1, 0x87DB, 0x56D2,\r\n\t0x87DC, 0x56D3, 0x87DD, 0x56D5, 0x87DE, 0x56D6, 0x87DF, 0x56D8,\t0x87E0, 0x56D9, 0x87E1, 0x56DC, 0x87E2, 0x56E3, 0x87E3, 0x56E5,\r\n\t0x87E4, 0x56E6, 0x87E5, 0x56E7, 0x87E6, 0x56E8, 0x87E7, 0x56E9,\t0x87E8, 0x56EA, 0x87E9, 0x56EC, 0x87EA, 0x56EE, 0x87EB, 0x56EF,\r\n\t0x87EC, 0x56F2, 0x87ED, 0x56F3, 0x87EE, 0x56F6, 0x87EF, 0x56F7,\t0x87F0, 0x56F8, 0x87F1, 0x56FB, 0x87F2, 0x56FC, 0x87F3, 0x5700,\r\n\t0x87F4, 0x5701, 0x87F5, 0x5702, 0x87F6, 0x5705, 0x87F7, 0x5707,\t0x87F8, 0x570B, 0x87F9, 0x570C, 0x87FA, 0x570D, 0x87FB, 0x570E,\r\n\t0x87FC, 0x570F, 0x87FD, 0x5710, 0x87FE, 0x5711, 0x8840, 0x5712,\t0x8841, 0x5713, 0x8842, 0x5714, 0x8843, 0x5715, 0x8844, 0x5716,\r\n\t0x8845, 0x5717, 0x8846, 0x5718, 0x8847, 0x5719, 0x8848, 0x571A,\t0x8849, 0x571B, 0x884A, 0x571D, 0x884B, 0x571E, 0x884C, 0x5720,\r\n\t0x884D, 0x5721, 0x884E, 0x5722, 0x884F, 0x5724, 0x8850, 0x5725,\t0x8851, 0x5726, 0x8852, 0x5727, 0x8853, 0x572B, 0x8854, 0x5731,\r\n\t0x8855, 0x5732, 0x8856, 0x5734, 0x8857, 0x5735, 0x8858, 0x5736,\t0x8859, 0x5737, 0x885A, 0x5738, 0x885B, 0x573C, 0x885C, 0x573D,\r\n\t0x885D, 0x573F, 0x885E, 0x5741, 0x885F, 0x5743, 0x8860, 0x5744,\t0x8861, 0x5745, 0x8862, 0x5746, 0x8863, 0x5748, 0x8864, 0x5749,\r\n\t0x8865, 0x574B, 0x8866, 0x5752, 0x8867, 0x5753, 0x8868, 0x5754,\t0x8869, 0x5755, 0x886A, 0x5756, 0x886B, 0x5758, 0x886C, 0x5759,\r\n\t0x886D, 0x5762, 0x886E, 0x5763, 0x886F, 0x5765, 0x8870, 0x5767,\t0x8871, 0x576C, 0x8872, 0x576E, 0x8873, 0x5770, 0x8874, 0x5771,\r\n\t0x8875, 0x5772, 0x8876, 0x5774, 0x8877, 0x5775, 0x8878, 0x5778,\t0x8879, 0x5779, 0x887A, 0x577A, 0x887B, 0x577D, 0x887C, 0x577E,\r\n\t0x887D, 0x577F, 0x887E, 0x5780, 0x8880, 0x5781, 0x8881, 0x5787,\t0x8882, 0x5788, 0x8883, 0x5789, 0x8884, 0x578A, 0x8885, 0x578D,\r\n\t0x8886, 0x578E, 0x8887, 0x578F, 0x8888, 0x5790, 0x8889, 0x5791,\t0x888A, 0x5794, 0x888B, 0x5795, 0x888C, 0x5796, 0x888D, 0x5797,\r\n\t0x888E, 0x5798, 0x888F, 0x5799, 0x8890, 0x579A, 0x8891, 0x579C,\t0x8892, 0x579D, 0x8893, 0x579E, 0x8894, 0x579F, 0x8895, 0x57A5,\r\n\t0x8896, 0x57A8, 0x8897, 0x57AA, 0x8898, 0x57AC, 0x8899, 0x57AF,\t0x889A, 0x57B0, 0x889B, 0x57B1, 0x889C, 0x57B3, 0x889D, 0x57B5,\r\n\t0x889E, 0x57B6, 0x889F, 0x57B7, 0x88A0, 0x57B9, 0x88A1, 0x57BA,\t0x88A2, 0x57BB, 0x88A3, 0x57BC, 0x88A4, 0x57BD, 0x88A5, 0x57BE,\r\n\t0x88A6, 0x57BF, 0x88A7, 0x57C0, 0x88A8, 0x57C1, 0x88A9, 0x57C4,\t0x88AA, 0x57C5, 0x88AB, 0x57C6, 0x88AC, 0x57C7, 0x88AD, 0x57C8,\r\n\t0x88AE, 0x57C9, 0x88AF, 0x57CA, 0x88B0, 0x57CC, 0x88B1, 0x57CD,\t0x88B2, 0x57D0, 0x88B3, 0x57D1, 0x88B4, 0x57D3, 0x88B5, 0x57D6,\r\n\t0x88B6, 0x57D7, 0x88B7, 0x57DB, 0x88B8, 0x57DC, 0x88B9, 0x57DE,\t0x88BA, 0x57E1, 0x88BB, 0x57E2, 0x88BC, 0x57E3, 0x88BD, 0x57E5,\r\n\t0x88BE, 0x57E6, 0x88BF, 0x57E7, 0x88C0, 0x57E8, 0x88C1, 0x57E9,\t0x88C2, 0x57EA, 0x88C3, 0x57EB, 0x88C4, 0x57EC, 0x88C5, 0x57EE,\r\n\t0x88C6, 0x57F0, 0x88C7, 0x57F1, 0x88C8, 0x57F2, 0x88C9, 0x57F3,\t0x88CA, 0x57F5, 0x88CB, 0x57F6, 0x88CC, 0x57F7, 0x88CD, 0x57FB,\r\n\t0x88CE, 0x57FC, 0x88CF, 0x57FE, 0x88D0, 0x57FF, 0x88D1, 0x5801,\t0x88D2, 0x5803, 0x88D3, 0x5804, 0x88D4, 0x5805, 0x88D5, 0x5808,\r\n\t0x88D6, 0x5809, 0x88D7, 0x580A, 0x88D8, 0x580C, 0x88D9, 0x580E,\t0x88DA, 0x580F, 0x88DB, 0x5810, 0x88DC, 0x5812, 0x88DD, 0x5813,\r\n\t0x88DE, 0x5814, 0x88DF, 0x5816, 0x88E0, 0x5817, 0x88E1, 0x5818,\t0x88E2, 0x581A, 0x88E3, 0x581B, 0x88E4, 0x581C, 0x88E5, 0x581D,\r\n\t0x88E6, 0x581F, 0x88E7, 0x5822, 0x88E8, 0x5823, 0x88E9, 0x5825,\t0x88EA, 0x5826, 0x88EB, 0x5827, 0x88EC, 0x5828, 0x88ED, 0x5829,\r\n\t0x88EE, 0x582B, 0x88EF, 0x582C, 0x88F0, 0x582D, 0x88F1, 0x582E,\t0x88F2, 0x582F, 0x88F3, 0x5831, 0x88F4, 0x5832, 0x88F5, 0x5833,\r\n\t0x88F6, 0x5834, 0x88F7, 0x5836, 0x88F8, 0x5837, 0x88F9, 0x5838,\t0x88FA, 0x5839, 0x88FB, 0x583A, 0x88FC, 0x583B, 0x88FD, 0x583C,\r\n\t0x88FE, 0x583D, 0x8940, 0x583E, 0x8941, 0x583F, 0x8942, 0x5840,\t0x8943, 0x5841, 0x8944, 0x5842, 0x8945, 0x5843, 0x8946, 0x5845,\r\n\t0x8947, 0x5846, 0x8948, 0x5847, 0x8949, 0x5848, 0x894A, 0x5849,\t0x894B, 0x584A, 0x894C, 0x584B, 0x894D, 0x584E, 0x894E, 0x584F,\r\n\t0x894F, 0x5850, 0x8950, 0x5852, 0x8951, 0x5853, 0x8952, 0x5855,\t0x8953, 0x5856, 0x8954, 0x5857, 0x8955, 0x5859, 0x8956, 0x585A,\r\n\t0x8957, 0x585B, 0x8958, 0x585C, 0x8959, 0x585D, 0x895A, 0x585F,\t0x895B, 0x5860, 0x895C, 0x5861, 0x895D, 0x5862, 0x895E, 0x5863,\r\n\t0x895F, 0x5864, 0x8960, 0x5866, 0x8961, 0x5867, 0x8962, 0x5868,\t0x8963, 0x5869, 0x8964, 0x586A, 0x8965, 0x586D, 0x8966, 0x586E,\r\n\t0x8967, 0x586F, 0x8968, 0x5870, 0x8969, 0x5871, 0x896A, 0x5872,\t0x896B, 0x5873, 0x896C, 0x5874, 0x896D, 0x5875, 0x896E, 0x5876,\r\n\t0x896F, 0x5877, 0x8970, 0x5878, 0x8971, 0x5879, 0x8972, 0x587A,\t0x8973, 0x587B, 0x8974, 0x587C, 0x8975, 0x587D, 0x8976, 0x587F,\r\n\t0x8977, 0x5882, 0x8978, 0x5884, 0x8979, 0x5886, 0x897A, 0x5887,\t0x897B, 0x5888, 0x897C, 0x588A, 0x897D, 0x588B, 0x897E, 0x588C,\r\n\t0x8980, 0x588D, 0x8981, 0x588E, 0x8982, 0x588F, 0x8983, 0x5890,\t0x8984, 0x5891, 0x8985, 0x5894, 0x8986, 0x5895, 0x8987, 0x5896,\r\n\t0x8988, 0x5897, 0x8989, 0x5898, 0x898A, 0x589B, 0x898B, 0x589C,\t0x898C, 0x589D, 0x898D, 0x58A0, 0x898E, 0x58A1, 0x898F, 0x58A2,\r\n\t0x8990, 0x58A3, 0x8991, 0x58A4, 0x8992, 0x58A5, 0x8993, 0x58A6,\t0x8994, 0x58A7, 0x8995, 0x58AA, 0x8996, 0x58AB, 0x8997, 0x58AC,\r\n\t0x8998, 0x58AD, 0x8999, 0x58AE, 0x899A, 0x58AF, 0x899B, 0x58B0,\t0x899C, 0x58B1, 0x899D, 0x58B2, 0x899E, 0x58B3, 0x899F, 0x58B4,\r\n\t0x89A0, 0x58B5, 0x89A1, 0x58B6, 0x89A2, 0x58B7, 0x89A3, 0x58B8,\t0x89A4, 0x58B9, 0x89A5, 0x58BA, 0x89A6, 0x58BB, 0x89A7, 0x58BD,\r\n\t0x89A8, 0x58BE, 0x89A9, 0x58BF, 0x89AA, 0x58C0, 0x89AB, 0x58C2,\t0x89AC, 0x58C3, 0x89AD, 0x58C4, 0x89AE, 0x58C6, 0x89AF, 0x58C7,\r\n\t0x89B0, 0x58C8, 0x89B1, 0x58C9, 0x89B2, 0x58CA, 0x89B3, 0x58CB,\t0x89B4, 0x58CC, 0x89B5, 0x58CD, 0x89B6, 0x58CE, 0x89B7, 0x58CF,\r\n\t0x89B8, 0x58D0, 0x89B9, 0x58D2, 0x89BA, 0x58D3, 0x89BB, 0x58D4,\t0x89BC, 0x58D6, 0x89BD, 0x58D7, 0x89BE, 0x58D8, 0x89BF, 0x58D9,\r\n\t0x89C0, 0x58DA, 0x89C1, 0x58DB, 0x89C2, 0x58DC, 0x89C3, 0x58DD,\t0x89C4, 0x58DE, 0x89C5, 0x58DF, 0x89C6, 0x58E0, 0x89C7, 0x58E1,\r\n\t0x89C8, 0x58E2, 0x89C9, 0x58E3, 0x89CA, 0x58E5, 0x89CB, 0x58E6,\t0x89CC, 0x58E7, 0x89CD, 0x58E8, 0x89CE, 0x58E9, 0x89CF, 0x58EA,\r\n\t0x89D0, 0x58ED, 0x89D1, 0x58EF, 0x89D2, 0x58F1, 0x89D3, 0x58F2,\t0x89D4, 0x58F4, 0x89D5, 0x58F5, 0x89D6, 0x58F7, 0x89D7, 0x58F8,\r\n\t0x89D8, 0x58FA, 0x89D9, 0x58FB, 0x89DA, 0x58FC, 0x89DB, 0x58FD,\t0x89DC, 0x58FE, 0x89DD, 0x58FF, 0x89DE, 0x5900, 0x89DF, 0x5901,\r\n\t0x89E0, 0x5903, 0x89E1, 0x5905, 0x89E2, 0x5906, 0x89E3, 0x5908,\t0x89E4, 0x5909, 0x89E5, 0x590A, 0x89E6, 0x590B, 0x89E7, 0x590C,\r\n\t0x89E8, 0x590E, 0x89E9, 0x5910, 0x89EA, 0x5911, 0x89EB, 0x5912,\t0x89EC, 0x5913, 0x89ED, 0x5917, 0x89EE, 0x5918, 0x89EF, 0x591B,\r\n\t0x89F0, 0x591D, 0x89F1, 0x591E, 0x89F2, 0x5920, 0x89F3, 0x5921,\t0x89F4, 0x5922, 0x89F5, 0x5923, 0x89F6, 0x5926, 0x89F7, 0x5928,\r\n\t0x89F8, 0x592C, 0x89F9, 0x5930, 0x89FA, 0x5932, 0x89FB, 0x5933,\t0x89FC, 0x5935, 0x89FD, 0x5936, 0x89FE, 0x593B, 0x8A40, 0x593D,\r\n\t0x8A41, 0x593E, 0x8A42, 0x593F, 0x8A43, 0x5940, 0x8A44, 0x5943,\t0x8A45, 0x5945, 0x8A46, 0x5946, 0x8A47, 0x594A, 0x8A48, 0x594C,\r\n\t0x8A49, 0x594D, 0x8A4A, 0x5950, 0x8A4B, 0x5952, 0x8A4C, 0x5953,\t0x8A4D, 0x5959, 0x8A4E, 0x595B, 0x8A4F, 0x595C, 0x8A50, 0x595D,\r\n\t0x8A51, 0x595E, 0x8A52, 0x595F, 0x8A53, 0x5961, 0x8A54, 0x5963,\t0x8A55, 0x5964, 0x8A56, 0x5966, 0x8A57, 0x5967, 0x8A58, 0x5968,\r\n\t0x8A59, 0x5969, 0x8A5A, 0x596A, 0x8A5B, 0x596B, 0x8A5C, 0x596C,\t0x8A5D, 0x596D, 0x8A5E, 0x596E, 0x8A5F, 0x596F, 0x8A60, 0x5970,\r\n\t0x8A61, 0x5971, 0x8A62, 0x5972, 0x8A63, 0x5975, 0x8A64, 0x5977,\t0x8A65, 0x597A, 0x8A66, 0x597B, 0x8A67, 0x597C, 0x8A68, 0x597E,\r\n\t0x8A69, 0x597F, 0x8A6A, 0x5980, 0x8A6B, 0x5985, 0x8A6C, 0x5989,\t0x8A6D, 0x598B, 0x8A6E, 0x598C, 0x8A6F, 0x598E, 0x8A70, 0x598F,\r\n\t0x8A71, 0x5990, 0x8A72, 0x5991, 0x8A73, 0x5994, 0x8A74, 0x5995,\t0x8A75, 0x5998, 0x8A76, 0x599A, 0x8A77, 0x599B, 0x8A78, 0x599C,\r\n\t0x8A79, 0x599D, 0x8A7A, 0x599F, 0x8A7B, 0x59A0, 0x8A7C, 0x59A1,\t0x8A7D, 0x59A2, 0x8A7E, 0x59A6, 0x8A80, 0x59A7, 0x8A81, 0x59AC,\r\n\t0x8A82, 0x59AD, 0x8A83, 0x59B0, 0x8A84, 0x59B1, 0x8A85, 0x59B3,\t0x8A86, 0x59B4, 0x8A87, 0x59B5, 0x8A88, 0x59B6, 0x8A89, 0x59B7,\r\n\t0x8A8A, 0x59B8, 0x8A8B, 0x59BA, 0x8A8C, 0x59BC, 0x8A8D, 0x59BD,\t0x8A8E, 0x59BF, 0x8A8F, 0x59C0, 0x8A90, 0x59C1, 0x8A91, 0x59C2,\r\n\t0x8A92, 0x59C3, 0x8A93, 0x59C4, 0x8A94, 0x59C5, 0x8A95, 0x59C7,\t0x8A96, 0x59C8, 0x8A97, 0x59C9, 0x8A98, 0x59CC, 0x8A99, 0x59CD,\r\n\t0x8A9A, 0x59CE, 0x8A9B, 0x59CF, 0x8A9C, 0x59D5, 0x8A9D, 0x59D6,\t0x8A9E, 0x59D9, 0x8A9F, 0x59DB, 0x8AA0, 0x59DE, 0x8AA1, 0x59DF,\r\n\t0x8AA2, 0x59E0, 0x8AA3, 0x59E1, 0x8AA4, 0x59E2, 0x8AA5, 0x59E4,\t0x8AA6, 0x59E6, 0x8AA7, 0x59E7, 0x8AA8, 0x59E9, 0x8AA9, 0x59EA,\r\n\t0x8AAA, 0x59EB, 0x8AAB, 0x59ED, 0x8AAC, 0x59EE, 0x8AAD, 0x59EF,\t0x8AAE, 0x59F0, 0x8AAF, 0x59F1, 0x8AB0, 0x59F2, 0x8AB1, 0x59F3,\r\n\t0x8AB2, 0x59F4, 0x8AB3, 0x59F5, 0x8AB4, 0x59F6, 0x8AB5, 0x59F7,\t0x8AB6, 0x59F8, 0x8AB7, 0x59FA, 0x8AB8, 0x59FC, 0x8AB9, 0x59FD,\r\n\t0x8ABA, 0x59FE, 0x8ABB, 0x5A00, 0x8ABC, 0x5A02, 0x8ABD, 0x5A0A,\t0x8ABE, 0x5A0B, 0x8ABF, 0x5A0D, 0x8AC0, 0x5A0E, 0x8AC1, 0x5A0F,\r\n\t0x8AC2, 0x5A10, 0x8AC3, 0x5A12, 0x8AC4, 0x5A14, 0x8AC5, 0x5A15,\t0x8AC6, 0x5A16, 0x8AC7, 0x5A17, 0x8AC8, 0x5A19, 0x8AC9, 0x5A1A,\r\n\t0x8ACA, 0x5A1B, 0x8ACB, 0x5A1D, 0x8ACC, 0x5A1E, 0x8ACD, 0x5A21,\t0x8ACE, 0x5A22, 0x8ACF, 0x5A24, 0x8AD0, 0x5A26, 0x8AD1, 0x5A27,\r\n\t0x8AD2, 0x5A28, 0x8AD3, 0x5A2A, 0x8AD4, 0x5A2B, 0x8AD5, 0x5A2C,\t0x8AD6, 0x5A2D, 0x8AD7, 0x5A2E, 0x8AD8, 0x5A2F, 0x8AD9, 0x5A30,\r\n\t0x8ADA, 0x5A33, 0x8ADB, 0x5A35, 0x8ADC, 0x5A37, 0x8ADD, 0x5A38,\t0x8ADE, 0x5A39, 0x8ADF, 0x5A3A, 0x8AE0, 0x5A3B, 0x8AE1, 0x5A3D,\r\n\t0x8AE2, 0x5A3E, 0x8AE3, 0x5A3F, 0x8AE4, 0x5A41, 0x8AE5, 0x5A42,\t0x8AE6, 0x5A43, 0x8AE7, 0x5A44, 0x8AE8, 0x5A45, 0x8AE9, 0x5A47,\r\n\t0x8AEA, 0x5A48, 0x8AEB, 0x5A4B, 0x8AEC, 0x5A4C, 0x8AED, 0x5A4D,\t0x8AEE, 0x5A4E, 0x8AEF, 0x5A4F, 0x8AF0, 0x5A50, 0x8AF1, 0x5A51,\r\n\t0x8AF2, 0x5A52, 0x8AF3, 0x5A53, 0x8AF4, 0x5A54, 0x8AF5, 0x5A56,\t0x8AF6, 0x5A57, 0x8AF7, 0x5A58, 0x8AF8, 0x5A59, 0x8AF9, 0x5A5B,\r\n\t0x8AFA, 0x5A5C, 0x8AFB, 0x5A5D, 0x8AFC, 0x5A5E, 0x8AFD, 0x5A5F,\t0x8AFE, 0x5A60, 0x8B40, 0x5A61, 0x8B41, 0x5A63, 0x8B42, 0x5A64,\r\n\t0x8B43, 0x5A65, 0x8B44, 0x5A66, 0x8B45, 0x5A68, 0x8B46, 0x5A69,\t0x8B47, 0x5A6B, 0x8B48, 0x5A6C, 0x8B49, 0x5A6D, 0x8B4A, 0x5A6E,\r\n\t0x8B4B, 0x5A6F, 0x8B4C, 0x5A70, 0x8B4D, 0x5A71, 0x8B4E, 0x5A72,\t0x8B4F, 0x5A73, 0x8B50, 0x5A78, 0x8B51, 0x5A79, 0x8B52, 0x5A7B,\r\n\t0x8B53, 0x5A7C, 0x8B54, 0x5A7D, 0x8B55, 0x5A7E, 0x8B56, 0x5A80,\t0x8B57, 0x5A81, 0x8B58, 0x5A82, 0x8B59, 0x5A83, 0x8B5A, 0x5A84,\r\n\t0x8B5B, 0x5A85, 0x8B5C, 0x5A86, 0x8B5D, 0x5A87, 0x8B5E, 0x5A88,\t0x8B5F, 0x5A89, 0x8B60, 0x5A8A, 0x8B61, 0x5A8B, 0x8B62, 0x5A8C,\r\n\t0x8B63, 0x5A8D, 0x8B64, 0x5A8E, 0x8B65, 0x5A8F, 0x8B66, 0x5A90,\t0x8B67, 0x5A91, 0x8B68, 0x5A93, 0x8B69, 0x5A94, 0x8B6A, 0x5A95,\r\n\t0x8B6B, 0x5A96, 0x8B6C, 0x5A97, 0x8B6D, 0x5A98, 0x8B6E, 0x5A99,\t0x8B6F, 0x5A9C, 0x8B70, 0x5A9D, 0x8B71, 0x5A9E, 0x8B72, 0x5A9F,\r\n\t0x8B73, 0x5AA0, 0x8B74, 0x5AA1, 0x8B75, 0x5AA2, 0x8B76, 0x5AA3,\t0x8B77, 0x5AA4, 0x8B78, 0x5AA5, 0x8B79, 0x5AA6, 0x8B7A, 0x5AA7,\r\n\t0x8B7B, 0x5AA8, 0x8B7C, 0x5AA9, 0x8B7D, 0x5AAB, 0x8B7E, 0x5AAC,\t0x8B80, 0x5AAD, 0x8B81, 0x5AAE, 0x8B82, 0x5AAF, 0x8B83, 0x5AB0,\r\n\t0x8B84, 0x5AB1, 0x8B85, 0x5AB4, 0x8B86, 0x5AB6, 0x8B87, 0x5AB7,\t0x8B88, 0x5AB9, 0x8B89, 0x5ABA, 0x8B8A, 0x5ABB, 0x8B8B, 0x5ABC,\r\n\t0x8B8C, 0x5ABD, 0x8B8D, 0x5ABF, 0x8B8E, 0x5AC0, 0x8B8F, 0x5AC3,\t0x8B90, 0x5AC4, 0x8B91, 0x5AC5, 0x8B92, 0x5AC6, 0x8B93, 0x5AC7,\r\n\t0x8B94, 0x5AC8, 0x8B95, 0x5ACA, 0x8B96, 0x5ACB, 0x8B97, 0x5ACD,\t0x8B98, 0x5ACE, 0x8B99, 0x5ACF, 0x8B9A, 0x5AD0, 0x8B9B, 0x5AD1,\r\n\t0x8B9C, 0x5AD3, 0x8B9D, 0x5AD5, 0x8B9E, 0x5AD7, 0x8B9F, 0x5AD9,\t0x8BA0, 0x5ADA, 0x8BA1, 0x5ADB, 0x8BA2, 0x5ADD, 0x8BA3, 0x5ADE,\r\n\t0x8BA4, 0x5ADF, 0x8BA5, 0x5AE2, 0x8BA6, 0x5AE4, 0x8BA7, 0x5AE5,\t0x8BA8, 0x5AE7, 0x8BA9, 0x5AE8, 0x8BAA, 0x5AEA, 0x8BAB, 0x5AEC,\r\n\t0x8BAC, 0x5AED, 0x8BAD, 0x5AEE, 0x8BAE, 0x5AEF, 0x8BAF, 0x5AF0,\t0x8BB0, 0x5AF2, 0x8BB1, 0x5AF3, 0x8BB2, 0x5AF4, 0x8BB3, 0x5AF5,\r\n\t0x8BB4, 0x5AF6, 0x8BB5, 0x5AF7, 0x8BB6, 0x5AF8, 0x8BB7, 0x5AF9,\t0x8BB8, 0x5AFA, 0x8BB9, 0x5AFB, 0x8BBA, 0x5AFC, 0x8BBB, 0x5AFD,\r\n\t0x8BBC, 0x5AFE, 0x8BBD, 0x5AFF, 0x8BBE, 0x5B00, 0x8BBF, 0x5B01,\t0x8BC0, 0x5B02, 0x8BC1, 0x5B03, 0x8BC2, 0x5B04, 0x8BC3, 0x5B05,\r\n\t0x8BC4, 0x5B06, 0x8BC5, 0x5B07, 0x8BC6, 0x5B08, 0x8BC7, 0x5B0A,\t0x8BC8, 0x5B0B, 0x8BC9, 0x5B0C, 0x8BCA, 0x5B0D, 0x8BCB, 0x5B0E,\r\n\t0x8BCC, 0x5B0F, 0x8BCD, 0x5B10, 0x8BCE, 0x5B11, 0x8BCF, 0x5B12,\t0x8BD0, 0x5B13, 0x8BD1, 0x5B14, 0x8BD2, 0x5B15, 0x8BD3, 0x5B18,\r\n\t0x8BD4, 0x5B19, 0x8BD5, 0x5B1A, 0x8BD6, 0x5B1B, 0x8BD7, 0x5B1C,\t0x8BD8, 0x5B1D, 0x8BD9, 0x5B1E, 0x8BDA, 0x5B1F, 0x8BDB, 0x5B20,\r\n\t0x8BDC, 0x5B21, 0x8BDD, 0x5B22, 0x8BDE, 0x5B23, 0x8BDF, 0x5B24,\t0x8BE0, 0x5B25, 0x8BE1, 0x5B26, 0x8BE2, 0x5B27, 0x8BE3, 0x5B28,\r\n\t0x8BE4, 0x5B29, 0x8BE5, 0x5B2A, 0x8BE6, 0x5B2B, 0x8BE7, 0x5B2C,\t0x8BE8, 0x5B2D, 0x8BE9, 0x5B2E, 0x8BEA, 0x5B2F, 0x8BEB, 0x5B30,\r\n\t0x8BEC, 0x5B31, 0x8BED, 0x5B33, 0x8BEE, 0x5B35, 0x8BEF, 0x5B36,\t0x8BF0, 0x5B38, 0x8BF1, 0x5B39, 0x8BF2, 0x5B3A, 0x8BF3, 0x5B3B,\r\n\t0x8BF4, 0x5B3C, 0x8BF5, 0x5B3D, 0x8BF6, 0x5B3E, 0x8BF7, 0x5B3F,\t0x8BF8, 0x5B41, 0x8BF9, 0x5B42, 0x8BFA, 0x5B43, 0x8BFB, 0x5B44,\r\n\t0x8BFC, 0x5B45, 0x8BFD, 0x5B46, 0x8BFE, 0x5B47, 0x8C40, 0x5B48,\t0x8C41, 0x5B49, 0x8C42, 0x5B4A, 0x8C43, 0x5B4B, 0x8C44, 0x5B4C,\r\n\t0x8C45, 0x5B4D, 0x8C46, 0x5B4E, 0x8C47, 0x5B4F, 0x8C48, 0x5B52,\t0x8C49, 0x5B56, 0x8C4A, 0x5B5E, 0x8C4B, 0x5B60, 0x8C4C, 0x5B61,\r\n\t0x8C4D, 0x5B67, 0x8C4E, 0x5B68, 0x8C4F, 0x5B6B, 0x8C50, 0x5B6D,\t0x8C51, 0x5B6E, 0x8C52, 0x5B6F, 0x8C53, 0x5B72, 0x8C54, 0x5B74,\r\n\t0x8C55, 0x5B76, 0x8C56, 0x5B77, 0x8C57, 0x5B78, 0x8C58, 0x5B79,\t0x8C59, 0x5B7B, 0x8C5A, 0x5B7C, 0x8C5B, 0x5B7E, 0x8C5C, 0x5B7F,\r\n\t0x8C5D, 0x5B82, 0x8C5E, 0x5B86, 0x8C5F, 0x5B8A, 0x8C60, 0x5B8D,\t0x8C61, 0x5B8E, 0x8C62, 0x5B90, 0x8C63, 0x5B91, 0x8C64, 0x5B92,\r\n\t0x8C65, 0x5B94, 0x8C66, 0x5B96, 0x8C67, 0x5B9F, 0x8C68, 0x5BA7,\t0x8C69, 0x5BA8, 0x8C6A, 0x5BA9, 0x8C6B, 0x5BAC, 0x8C6C, 0x5BAD,\r\n\t0x8C6D, 0x5BAE, 0x8C6E, 0x5BAF, 0x8C6F, 0x5BB1, 0x8C70, 0x5BB2,\t0x8C71, 0x5BB7, 0x8C72, 0x5BBA, 0x8C73, 0x5BBB, 0x8C74, 0x5BBC,\r\n\t0x8C75, 0x5BC0, 0x8C76, 0x5BC1, 0x8C77, 0x5BC3, 0x8C78, 0x5BC8,\t0x8C79, 0x5BC9, 0x8C7A, 0x5BCA, 0x8C7B, 0x5BCB, 0x8C7C, 0x5BCD,\r\n\t0x8C7D, 0x5BCE, 0x8C7E, 0x5BCF, 0x8C80, 0x5BD1, 0x8C81, 0x5BD4,\t0x8C82, 0x5BD5, 0x8C83, 0x5BD6, 0x8C84, 0x5BD7, 0x8C85, 0x5BD8,\r\n\t0x8C86, 0x5BD9, 0x8C87, 0x5BDA, 0x8C88, 0x5BDB, 0x8C89, 0x5BDC,\t0x8C8A, 0x5BE0, 0x8C8B, 0x5BE2, 0x8C8C, 0x5BE3, 0x8C8D, 0x5BE6,\r\n\t0x8C8E, 0x5BE7, 0x8C8F, 0x5BE9, 0x8C90, 0x5BEA, 0x8C91, 0x5BEB,\t0x8C92, 0x5BEC, 0x8C93, 0x5BED, 0x8C94, 0x5BEF, 0x8C95, 0x5BF1,\r\n\t0x8C96, 0x5BF2, 0x8C97, 0x5BF3, 0x8C98, 0x5BF4, 0x8C99, 0x5BF5,\t0x8C9A, 0x5BF6, 0x8C9B, 0x5BF7, 0x8C9C, 0x5BFD, 0x8C9D, 0x5BFE,\r\n\t0x8C9E, 0x5C00, 0x8C9F, 0x5C02, 0x8CA0, 0x5C03, 0x8CA1, 0x5C05,\t0x8CA2, 0x5C07, 0x8CA3, 0x5C08, 0x8CA4, 0x5C0B, 0x8CA5, 0x5C0C,\r\n\t0x8CA6, 0x5C0D, 0x8CA7, 0x5C0E, 0x8CA8, 0x5C10, 0x8CA9, 0x5C12,\t0x8CAA, 0x5C13, 0x8CAB, 0x5C17, 0x8CAC, 0x5C19, 0x8CAD, 0x5C1B,\r\n\t0x8CAE, 0x5C1E, 0x8CAF, 0x5C1F, 0x8CB0, 0x5C20, 0x8CB1, 0x5C21,\t0x8CB2, 0x5C23, 0x8CB3, 0x5C26, 0x8CB4, 0x5C28, 0x8CB5, 0x5C29,\r\n\t0x8CB6, 0x5C2A, 0x8CB7, 0x5C2B, 0x8CB8, 0x5C2D, 0x8CB9, 0x5C2E,\t0x8CBA, 0x5C2F, 0x8CBB, 0x5C30, 0x8CBC, 0x5C32, 0x8CBD, 0x5C33,\r\n\t0x8CBE, 0x5C35, 0x8CBF, 0x5C36, 0x8CC0, 0x5C37, 0x8CC1, 0x5C43,\t0x8CC2, 0x5C44, 0x8CC3, 0x5C46, 0x8CC4, 0x5C47, 0x8CC5, 0x5C4C,\r\n\t0x8CC6, 0x5C4D, 0x8CC7, 0x5C52, 0x8CC8, 0x5C53, 0x8CC9, 0x5C54,\t0x8CCA, 0x5C56, 0x8CCB, 0x5C57, 0x8CCC, 0x5C58, 0x8CCD, 0x5C5A,\r\n\t0x8CCE, 0x5C5B, 0x8CCF, 0x5C5C, 0x8CD0, 0x5C5D, 0x8CD1, 0x5C5F,\t0x8CD2, 0x5C62, 0x8CD3, 0x5C64, 0x8CD4, 0x5C67, 0x8CD5, 0x5C68,\r\n\t0x8CD6, 0x5C69, 0x8CD7, 0x5C6A, 0x8CD8, 0x5C6B, 0x8CD9, 0x5C6C,\t0x8CDA, 0x5C6D, 0x8CDB, 0x5C70, 0x8CDC, 0x5C72, 0x8CDD, 0x5C73,\r\n\t0x8CDE, 0x5C74, 0x8CDF, 0x5C75, 0x8CE0, 0x5C76, 0x8CE1, 0x5C77,\t0x8CE2, 0x5C78, 0x8CE3, 0x5C7B, 0x8CE4, 0x5C7C, 0x8CE5, 0x5C7D,\r\n\t0x8CE6, 0x5C7E, 0x8CE7, 0x5C80, 0x8CE8, 0x5C83, 0x8CE9, 0x5C84,\t0x8CEA, 0x5C85, 0x8CEB, 0x5C86, 0x8CEC, 0x5C87, 0x8CED, 0x5C89,\r\n\t0x8CEE, 0x5C8A, 0x8CEF, 0x5C8B, 0x8CF0, 0x5C8E, 0x8CF1, 0x5C8F,\t0x8CF2, 0x5C92, 0x8CF3, 0x5C93, 0x8CF4, 0x5C95, 0x8CF5, 0x5C9D,\r\n\t0x8CF6, 0x5C9E, 0x8CF7, 0x5C9F, 0x8CF8, 0x5CA0, 0x8CF9, 0x5CA1,\t0x8CFA, 0x5CA4, 0x8CFB, 0x5CA5, 0x8CFC, 0x5CA6, 0x8CFD, 0x5CA7,\r\n\t0x8CFE, 0x5CA8, 0x8D40, 0x5CAA, 0x8D41, 0x5CAE, 0x8D42, 0x5CAF,\t0x8D43, 0x5CB0, 0x8D44, 0x5CB2, 0x8D45, 0x5CB4, 0x8D46, 0x5CB6,\r\n\t0x8D47, 0x5CB9, 0x8D48, 0x5CBA, 0x8D49, 0x5CBB, 0x8D4A, 0x5CBC,\t0x8D4B, 0x5CBE, 0x8D4C, 0x5CC0, 0x8D4D, 0x5CC2, 0x8D4E, 0x5CC3,\r\n\t0x8D4F, 0x5CC5, 0x8D50, 0x5CC6, 0x8D51, 0x5CC7, 0x8D52, 0x5CC8,\t0x8D53, 0x5CC9, 0x8D54, 0x5CCA, 0x8D55, 0x5CCC, 0x8D56, 0x5CCD,\r\n\t0x8D57, 0x5CCE, 0x8D58, 0x5CCF, 0x8D59, 0x5CD0, 0x8D5A, 0x5CD1,\t0x8D5B, 0x5CD3, 0x8D5C, 0x5CD4, 0x8D5D, 0x5CD5, 0x8D5E, 0x5CD6,\r\n\t0x8D5F, 0x5CD7, 0x8D60, 0x5CD8, 0x8D61, 0x5CDA, 0x8D62, 0x5CDB,\t0x8D63, 0x5CDC, 0x8D64, 0x5CDD, 0x8D65, 0x5CDE, 0x8D66, 0x5CDF,\r\n\t0x8D67, 0x5CE0, 0x8D68, 0x5CE2, 0x8D69, 0x5CE3, 0x8D6A, 0x5CE7,\t0x8D6B, 0x5CE9, 0x8D6C, 0x5CEB, 0x8D6D, 0x5CEC, 0x8D6E, 0x5CEE,\r\n\t0x8D6F, 0x5CEF, 0x8D70, 0x5CF1, 0x8D71, 0x5CF2, 0x8D72, 0x5CF3,\t0x8D73, 0x5CF4, 0x8D74, 0x5CF5, 0x8D75, 0x5CF6, 0x8D76, 0x5CF7,\r\n\t0x8D77, 0x5CF8, 0x8D78, 0x5CF9, 0x8D79, 0x5CFA, 0x8D7A, 0x5CFC,\t0x8D7B, 0x5CFD, 0x8D7C, 0x5CFE, 0x8D7D, 0x5CFF, 0x8D7E, 0x5D00,\r\n\t0x8D80, 0x5D01, 0x8D81, 0x5D04, 0x8D82, 0x5D05, 0x8D83, 0x5D08,\t0x8D84, 0x5D09, 0x8D85, 0x5D0A, 0x8D86, 0x5D0B, 0x8D87, 0x5D0C,\r\n\t0x8D88, 0x5D0D, 0x8D89, 0x5D0F, 0x8D8A, 0x5D10, 0x8D8B, 0x5D11,\t0x8D8C, 0x5D12, 0x8D8D, 0x5D13, 0x8D8E, 0x5D15, 0x8D8F, 0x5D17,\r\n\t0x8D90, 0x5D18, 0x8D91, 0x5D19, 0x8D92, 0x5D1A, 0x8D93, 0x5D1C,\t0x8D94, 0x5D1D, 0x8D95, 0x5D1F, 0x8D96, 0x5D20, 0x8D97, 0x5D21,\r\n\t0x8D98, 0x5D22, 0x8D99, 0x5D23, 0x8D9A, 0x5D25, 0x8D9B, 0x5D28,\t0x8D9C, 0x5D2A, 0x8D9D, 0x5D2B, 0x8D9E, 0x5D2C, 0x8D9F, 0x5D2F,\r\n\t0x8DA0, 0x5D30, 0x8DA1, 0x5D31, 0x8DA2, 0x5D32, 0x8DA3, 0x5D33,\t0x8DA4, 0x5D35, 0x8DA5, 0x5D36, 0x8DA6, 0x5D37, 0x8DA7, 0x5D38,\r\n\t0x8DA8, 0x5D39, 0x8DA9, 0x5D3A, 0x8DAA, 0x5D3B, 0x8DAB, 0x5D3C,\t0x8DAC, 0x5D3F, 0x8DAD, 0x5D40, 0x8DAE, 0x5D41, 0x8DAF, 0x5D42,\r\n\t0x8DB0, 0x5D43, 0x8DB1, 0x5D44, 0x8DB2, 0x5D45, 0x8DB3, 0x5D46,\t0x8DB4, 0x5D48, 0x8DB5, 0x5D49, 0x8DB6, 0x5D4D, 0x8DB7, 0x5D4E,\r\n\t0x8DB8, 0x5D4F, 0x8DB9, 0x5D50, 0x8DBA, 0x5D51, 0x8DBB, 0x5D52,\t0x8DBC, 0x5D53, 0x8DBD, 0x5D54, 0x8DBE, 0x5D55, 0x8DBF, 0x5D56,\r\n\t0x8DC0, 0x5D57, 0x8DC1, 0x5D59, 0x8DC2, 0x5D5A, 0x8DC3, 0x5D5C,\t0x8DC4, 0x5D5E, 0x8DC5, 0x5D5F, 0x8DC6, 0x5D60, 0x8DC7, 0x5D61,\r\n\t0x8DC8, 0x5D62, 0x8DC9, 0x5D63, 0x8DCA, 0x5D64, 0x8DCB, 0x5D65,\t0x8DCC, 0x5D66, 0x8DCD, 0x5D67, 0x8DCE, 0x5D68, 0x8DCF, 0x5D6A,\r\n\t0x8DD0, 0x5D6D, 0x8DD1, 0x5D6E, 0x8DD2, 0x5D70, 0x8DD3, 0x5D71,\t0x8DD4, 0x5D72, 0x8DD5, 0x5D73, 0x8DD6, 0x5D75, 0x8DD7, 0x5D76,\r\n\t0x8DD8, 0x5D77, 0x8DD9, 0x5D78, 0x8DDA, 0x5D79, 0x8DDB, 0x5D7A,\t0x8DDC, 0x5D7B, 0x8DDD, 0x5D7C, 0x8DDE, 0x5D7D, 0x8DDF, 0x5D7E,\r\n\t0x8DE0, 0x5D7F, 0x8DE1, 0x5D80, 0x8DE2, 0x5D81, 0x8DE3, 0x5D83,\t0x8DE4, 0x5D84, 0x8DE5, 0x5D85, 0x8DE6, 0x5D86, 0x8DE7, 0x5D87,\r\n\t0x8DE8, 0x5D88, 0x8DE9, 0x5D89, 0x8DEA, 0x5D8A, 0x8DEB, 0x5D8B,\t0x8DEC, 0x5D8C, 0x8DED, 0x5D8D, 0x8DEE, 0x5D8E, 0x8DEF, 0x5D8F,\r\n\t0x8DF0, 0x5D90, 0x8DF1, 0x5D91, 0x8DF2, 0x5D92, 0x8DF3, 0x5D93,\t0x8DF4, 0x5D94, 0x8DF5, 0x5D95, 0x8DF6, 0x5D96, 0x8DF7, 0x5D97,\r\n\t0x8DF8, 0x5D98, 0x8DF9, 0x5D9A, 0x8DFA, 0x5D9B, 0x8DFB, 0x5D9C,\t0x8DFC, 0x5D9E, 0x8DFD, 0x5D9F, 0x8DFE, 0x5DA0, 0x8E40, 0x5DA1,\r\n\t0x8E41, 0x5DA2, 0x8E42, 0x5DA3, 0x8E43, 0x5DA4, 0x8E44, 0x5DA5,\t0x8E45, 0x5DA6, 0x8E46, 0x5DA7, 0x8E47, 0x5DA8, 0x8E48, 0x5DA9,\r\n\t0x8E49, 0x5DAA, 0x8E4A, 0x5DAB, 0x8E4B, 0x5DAC, 0x8E4C, 0x5DAD,\t0x8E4D, 0x5DAE, 0x8E4E, 0x5DAF, 0x8E4F, 0x5DB0, 0x8E50, 0x5DB1,\r\n\t0x8E51, 0x5DB2, 0x8E52, 0x5DB3, 0x8E53, 0x5DB4, 0x8E54, 0x5DB5,\t0x8E55, 0x5DB6, 0x8E56, 0x5DB8, 0x8E57, 0x5DB9, 0x8E58, 0x5DBA,\r\n\t0x8E59, 0x5DBB, 0x8E5A, 0x5DBC, 0x8E5B, 0x5DBD, 0x8E5C, 0x5DBE,\t0x8E5D, 0x5DBF, 0x8E5E, 0x5DC0, 0x8E5F, 0x5DC1, 0x8E60, 0x5DC2,\r\n\t0x8E61, 0x5DC3, 0x8E62, 0x5DC4, 0x8E63, 0x5DC6, 0x8E64, 0x5DC7,\t0x8E65, 0x5DC8, 0x8E66, 0x5DC9, 0x8E67, 0x5DCA, 0x8E68, 0x5DCB,\r\n\t0x8E69, 0x5DCC, 0x8E6A, 0x5DCE, 0x8E6B, 0x5DCF, 0x8E6C, 0x5DD0,\t0x8E6D, 0x5DD1, 0x8E6E, 0x5DD2, 0x8E6F, 0x5DD3, 0x8E70, 0x5DD4,\r\n\t0x8E71, 0x5DD5, 0x8E72, 0x5DD6, 0x8E73, 0x5DD7, 0x8E74, 0x5DD8,\t0x8E75, 0x5DD9, 0x8E76, 0x5DDA, 0x8E77, 0x5DDC, 0x8E78, 0x5DDF,\r\n\t0x8E79, 0x5DE0, 0x8E7A, 0x5DE3, 0x8E7B, 0x5DE4, 0x8E7C, 0x5DEA,\t0x8E7D, 0x5DEC, 0x8E7E, 0x5DED, 0x8E80, 0x5DF0, 0x8E81, 0x5DF5,\r\n\t0x8E82, 0x5DF6, 0x8E83, 0x5DF8, 0x8E84, 0x5DF9, 0x8E85, 0x5DFA,\t0x8E86, 0x5DFB, 0x8E87, 0x5DFC, 0x8E88, 0x5DFF, 0x8E89, 0x5E00,\r\n\t0x8E8A, 0x5E04, 0x8E8B, 0x5E07, 0x8E8C, 0x5E09, 0x8E8D, 0x5E0A,\t0x8E8E, 0x5E0B, 0x8E8F, 0x5E0D, 0x8E90, 0x5E0E, 0x8E91, 0x5E12,\r\n\t0x8E92, 0x5E13, 0x8E93, 0x5E17, 0x8E94, 0x5E1E, 0x8E95, 0x5E1F,\t0x8E96, 0x5E20, 0x8E97, 0x5E21, 0x8E98, 0x5E22, 0x8E99, 0x5E23,\r\n\t0x8E9A, 0x5E24, 0x8E9B, 0x5E25, 0x8E9C, 0x5E28, 0x8E9D, 0x5E29,\t0x8E9E, 0x5E2A, 0x8E9F, 0x5E2B, 0x8EA0, 0x5E2C, 0x8EA1, 0x5E2F,\r\n\t0x8EA2, 0x5E30, 0x8EA3, 0x5E32, 0x8EA4, 0x5E33, 0x8EA5, 0x5E34,\t0x8EA6, 0x5E35, 0x8EA7, 0x5E36, 0x8EA8, 0x5E39, 0x8EA9, 0x5E3A,\r\n\t0x8EAA, 0x5E3E, 0x8EAB, 0x5E3F, 0x8EAC, 0x5E40, 0x8EAD, 0x5E41,\t0x8EAE, 0x5E43, 0x8EAF, 0x5E46, 0x8EB0, 0x5E47, 0x8EB1, 0x5E48,\r\n\t0x8EB2, 0x5E49, 0x8EB3, 0x5E4A, 0x8EB4, 0x5E4B, 0x8EB5, 0x5E4D,\t0x8EB6, 0x5E4E, 0x8EB7, 0x5E4F, 0x8EB8, 0x5E50, 0x8EB9, 0x5E51,\r\n\t0x8EBA, 0x5E52, 0x8EBB, 0x5E53, 0x8EBC, 0x5E56, 0x8EBD, 0x5E57,\t0x8EBE, 0x5E58, 0x8EBF, 0x5E59, 0x8EC0, 0x5E5A, 0x8EC1, 0x5E5C,\r\n\t0x8EC2, 0x5E5D, 0x8EC3, 0x5E5F, 0x8EC4, 0x5E60, 0x8EC5, 0x5E63,\t0x8EC6, 0x5E64, 0x8EC7, 0x5E65, 0x8EC8, 0x5E66, 0x8EC9, 0x5E67,\r\n\t0x8ECA, 0x5E68, 0x8ECB, 0x5E69, 0x8ECC, 0x5E6A, 0x8ECD, 0x5E6B,\t0x8ECE, 0x5E6C, 0x8ECF, 0x5E6D, 0x8ED0, 0x5E6E, 0x8ED1, 0x5E6F,\r\n\t0x8ED2, 0x5E70, 0x8ED3, 0x5E71, 0x8ED4, 0x5E75, 0x8ED5, 0x5E77,\t0x8ED6, 0x5E79, 0x8ED7, 0x5E7E, 0x8ED8, 0x5E81, 0x8ED9, 0x5E82,\r\n\t0x8EDA, 0x5E83, 0x8EDB, 0x5E85, 0x8EDC, 0x5E88, 0x8EDD, 0x5E89,\t0x8EDE, 0x5E8C, 0x8EDF, 0x5E8D, 0x8EE0, 0x5E8E, 0x8EE1, 0x5E92,\r\n\t0x8EE2, 0x5E98, 0x8EE3, 0x5E9B, 0x8EE4, 0x5E9D, 0x8EE5, 0x5EA1,\t0x8EE6, 0x5EA2, 0x8EE7, 0x5EA3, 0x8EE8, 0x5EA4, 0x8EE9, 0x5EA8,\r\n\t0x8EEA, 0x5EA9, 0x8EEB, 0x5EAA, 0x8EEC, 0x5EAB, 0x8EED, 0x5EAC,\t0x8EEE, 0x5EAE, 0x8EEF, 0x5EAF, 0x8EF0, 0x5EB0, 0x8EF1, 0x5EB1,\r\n\t0x8EF2, 0x5EB2, 0x8EF3, 0x5EB4, 0x8EF4, 0x5EBA, 0x8EF5, 0x5EBB,\t0x8EF6, 0x5EBC, 0x8EF7, 0x5EBD, 0x8EF8, 0x5EBF, 0x8EF9, 0x5EC0,\r\n\t0x8EFA, 0x5EC1, 0x8EFB, 0x5EC2, 0x8EFC, 0x5EC3, 0x8EFD, 0x5EC4,\t0x8EFE, 0x5EC5, 0x8F40, 0x5EC6, 0x8F41, 0x5EC7, 0x8F42, 0x5EC8,\r\n\t0x8F43, 0x5ECB, 0x8F44, 0x5ECC, 0x8F45, 0x5ECD, 0x8F46, 0x5ECE,\t0x8F47, 0x5ECF, 0x8F48, 0x5ED0, 0x8F49, 0x5ED4, 0x8F4A, 0x5ED5,\r\n\t0x8F4B, 0x5ED7, 0x8F4C, 0x5ED8, 0x8F4D, 0x5ED9, 0x8F4E, 0x5EDA,\t0x8F4F, 0x5EDC, 0x8F50, 0x5EDD, 0x8F51, 0x5EDE, 0x8F52, 0x5EDF,\r\n\t0x8F53, 0x5EE0, 0x8F54, 0x5EE1, 0x8F55, 0x5EE2, 0x8F56, 0x5EE3,\t0x8F57, 0x5EE4, 0x8F58, 0x5EE5, 0x8F59, 0x5EE6, 0x8F5A, 0x5EE7,\r\n\t0x8F5B, 0x5EE9, 0x8F5C, 0x5EEB, 0x8F5D, 0x5EEC, 0x8F5E, 0x5EED,\t0x8F5F, 0x5EEE, 0x8F60, 0x5EEF, 0x8F61, 0x5EF0, 0x8F62, 0x5EF1,\r\n\t0x8F63, 0x5EF2, 0x8F64, 0x5EF3, 0x8F65, 0x5EF5, 0x8F66, 0x5EF8,\t0x8F67, 0x5EF9, 0x8F68, 0x5EFB, 0x8F69, 0x5EFC, 0x8F6A, 0x5EFD,\r\n\t0x8F6B, 0x5F05, 0x8F6C, 0x5F06, 0x8F6D, 0x5F07, 0x8F6E, 0x5F09,\t0x8F6F, 0x5F0C, 0x8F70, 0x5F0D, 0x8F71, 0x5F0E, 0x8F72, 0x5F10,\r\n\t0x8F73, 0x5F12, 0x8F74, 0x5F14, 0x8F75, 0x5F16, 0x8F76, 0x5F19,\t0x8F77, 0x5F1A, 0x8F78, 0x5F1C, 0x8F79, 0x5F1D, 0x8F7A, 0x5F1E,\r\n\t0x8F7B, 0x5F21, 0x8F7C, 0x5F22, 0x8F7D, 0x5F23, 0x8F7E, 0x5F24,\t0x8F80, 0x5F28, 0x8F81, 0x5F2B, 0x8F82, 0x5F2C, 0x8F83, 0x5F2E,\r\n\t0x8F84, 0x5F30, 0x8F85, 0x5F32, 0x8F86, 0x5F33, 0x8F87, 0x5F34,\t0x8F88, 0x5F35, 0x8F89, 0x5F36, 0x8F8A, 0x5F37, 0x8F8B, 0x5F38,\r\n\t0x8F8C, 0x5F3B, 0x8F8D, 0x5F3D, 0x8F8E, 0x5F3E, 0x8F8F, 0x5F3F,\t0x8F90, 0x5F41, 0x8F91, 0x5F42, 0x8F92, 0x5F43, 0x8F93, 0x5F44,\r\n\t0x8F94, 0x5F45, 0x8F95, 0x5F46, 0x8F96, 0x5F47, 0x8F97, 0x5F48,\t0x8F98, 0x5F49, 0x8F99, 0x5F4A, 0x8F9A, 0x5F4B, 0x8F9B, 0x5F4C,\r\n\t0x8F9C, 0x5F4D, 0x8F9D, 0x5F4E, 0x8F9E, 0x5F4F, 0x8F9F, 0x5F51,\t0x8FA0, 0x5F54, 0x8FA1, 0x5F59, 0x8FA2, 0x5F5A, 0x8FA3, 0x5F5B,\r\n\t0x8FA4, 0x5F5C, 0x8FA5, 0x5F5E, 0x8FA6, 0x5F5F, 0x8FA7, 0x5F60,\t0x8FA8, 0x5F63, 0x8FA9, 0x5F65, 0x8FAA, 0x5F67, 0x8FAB, 0x5F68,\r\n\t0x8FAC, 0x5F6B, 0x8FAD, 0x5F6E, 0x8FAE, 0x5F6F, 0x8FAF, 0x5F72,\t0x8FB0, 0x5F74, 0x8FB1, 0x5F75, 0x8FB2, 0x5F76, 0x8FB3, 0x5F78,\r\n\t0x8FB4, 0x5F7A, 0x8FB5, 0x5F7D, 0x8FB6, 0x5F7E, 0x8FB7, 0x5F7F,\t0x8FB8, 0x5F83, 0x8FB9, 0x5F86, 0x8FBA, 0x5F8D, 0x8FBB, 0x5F8E,\r\n\t0x8FBC, 0x5F8F, 0x8FBD, 0x5F91, 0x8FBE, 0x5F93, 0x8FBF, 0x5F94,\t0x8FC0, 0x5F96, 0x8FC1, 0x5F9A, 0x8FC2, 0x5F9B, 0x8FC3, 0x5F9D,\r\n\t0x8FC4, 0x5F9E, 0x8FC5, 0x5F9F, 0x8FC6, 0x5FA0, 0x8FC7, 0x5FA2,\t0x8FC8, 0x5FA3, 0x8FC9, 0x5FA4, 0x8FCA, 0x5FA5, 0x8FCB, 0x5FA6,\r\n\t0x8FCC, 0x5FA7, 0x8FCD, 0x5FA9, 0x8FCE, 0x5FAB, 0x8FCF, 0x5FAC,\t0x8FD0, 0x5FAF, 0x8FD1, 0x5FB0, 0x8FD2, 0x5FB1, 0x8FD3, 0x5FB2,\r\n\t0x8FD4, 0x5FB3, 0x8FD5, 0x5FB4, 0x8FD6, 0x5FB6, 0x8FD7, 0x5FB8,\t0x8FD8, 0x5FB9, 0x8FD9, 0x5FBA, 0x8FDA, 0x5FBB, 0x8FDB, 0x5FBE,\r\n\t0x8FDC, 0x5FBF, 0x8FDD, 0x5FC0, 0x8FDE, 0x5FC1, 0x8FDF, 0x5FC2,\t0x8FE0, 0x5FC7, 0x8FE1, 0x5FC8, 0x8FE2, 0x5FCA, 0x8FE3, 0x5FCB,\r\n\t0x8FE4, 0x5FCE, 0x8FE5, 0x5FD3, 0x8FE6, 0x5FD4, 0x8FE7, 0x5FD5,\t0x8FE8, 0x5FDA, 0x8FE9, 0x5FDB, 0x8FEA, 0x5FDC, 0x8FEB, 0x5FDE,\r\n\t0x8FEC, 0x5FDF, 0x8FED, 0x5FE2, 0x8FEE, 0x5FE3, 0x8FEF, 0x5FE5,\t0x8FF0, 0x5FE6, 0x8FF1, 0x5FE8, 0x8FF2, 0x5FE9, 0x8FF3, 0x5FEC,\r\n\t0x8FF4, 0x5FEF, 0x8FF5, 0x5FF0, 0x8FF6, 0x5FF2, 0x8FF7, 0x5FF3,\t0x8FF8, 0x5FF4, 0x8FF9, 0x5FF6, 0x8FFA, 0x5FF7, 0x8FFB, 0x5FF9,\r\n\t0x8FFC, 0x5FFA, 0x8FFD, 0x5FFC, 0x8FFE, 0x6007, 0x9040, 0x6008,\t0x9041, 0x6009, 0x9042, 0x600B, 0x9043, 0x600C, 0x9044, 0x6010,\r\n\t0x9045, 0x6011, 0x9046, 0x6013, 0x9047, 0x6017, 0x9048, 0x6018,\t0x9049, 0x601A, 0x904A, 0x601E, 0x904B, 0x601F, 0x904C, 0x6022,\r\n\t0x904D, 0x6023, 0x904E, 0x6024, 0x904F, 0x602C, 0x9050, 0x602D,\t0x9051, 0x602E, 0x9052, 0x6030, 0x9053, 0x6031, 0x9054, 0x6032,\r\n\t0x9055, 0x6033, 0x9056, 0x6034, 0x9057, 0x6036, 0x9058, 0x6037,\t0x9059, 0x6038, 0x905A, 0x6039, 0x905B, 0x603A, 0x905C, 0x603D,\r\n\t0x905D, 0x603E, 0x905E, 0x6040, 0x905F, 0x6044, 0x9060, 0x6045,\t0x9061, 0x6046, 0x9062, 0x6047, 0x9063, 0x6048, 0x9064, 0x6049,\r\n\t0x9065, 0x604A, 0x9066, 0x604C, 0x9067, 0x604E, 0x9068, 0x604F,\t0x9069, 0x6051, 0x906A, 0x6053, 0x906B, 0x6054, 0x906C, 0x6056,\r\n\t0x906D, 0x6057, 0x906E, 0x6058, 0x906F, 0x605B, 0x9070, 0x605C,\t0x9071, 0x605E, 0x9072, 0x605F, 0x9073, 0x6060, 0x9074, 0x6061,\r\n\t0x9075, 0x6065, 0x9076, 0x6066, 0x9077, 0x606E, 0x9078, 0x6071,\t0x9079, 0x6072, 0x907A, 0x6074, 0x907B, 0x6075, 0x907C, 0x6077,\r\n\t0x907D, 0x607E, 0x907E, 0x6080, 0x9080, 0x6081, 0x9081, 0x6082,\t0x9082, 0x6085, 0x9083, 0x6086, 0x9084, 0x6087, 0x9085, 0x6088,\r\n\t0x9086, 0x608A, 0x9087, 0x608B, 0x9088, 0x608E, 0x9089, 0x608F,\t0x908A, 0x6090, 0x908B, 0x6091, 0x908C, 0x6093, 0x908D, 0x6095,\r\n\t0x908E, 0x6097, 0x908F, 0x6098, 0x9090, 0x6099, 0x9091, 0x609C,\t0x9092, 0x609E, 0x9093, 0x60A1, 0x9094, 0x60A2, 0x9095, 0x60A4,\r\n\t0x9096, 0x60A5, 0x9097, 0x60A7, 0x9098, 0x60A9, 0x9099, 0x60AA,\t0x909A, 0x60AE, 0x909B, 0x60B0, 0x909C, 0x60B3, 0x909D, 0x60B5,\r\n\t0x909E, 0x60B6, 0x909F, 0x60B7, 0x90A0, 0x60B9, 0x90A1, 0x60BA,\t0x90A2, 0x60BD, 0x90A3, 0x60BE, 0x90A4, 0x60BF, 0x90A5, 0x60C0,\r\n\t0x90A6, 0x60C1, 0x90A7, 0x60C2, 0x90A8, 0x60C3, 0x90A9, 0x60C4,\t0x90AA, 0x60C7, 0x90AB, 0x60C8, 0x90AC, 0x60C9, 0x90AD, 0x60CC,\r\n\t0x90AE, 0x60CD, 0x90AF, 0x60CE, 0x90B0, 0x60CF, 0x90B1, 0x60D0,\t0x90B2, 0x60D2, 0x90B3, 0x60D3, 0x90B4, 0x60D4, 0x90B5, 0x60D6,\r\n\t0x90B6, 0x60D7, 0x90B7, 0x60D9, 0x90B8, 0x60DB, 0x90B9, 0x60DE,\t0x90BA, 0x60E1, 0x90BB, 0x60E2, 0x90BC, 0x60E3, 0x90BD, 0x60E4,\r\n\t0x90BE, 0x60E5, 0x90BF, 0x60EA, 0x90C0, 0x60F1, 0x90C1, 0x60F2,\t0x90C2, 0x60F5, 0x90C3, 0x60F7, 0x90C4, 0x60F8, 0x90C5, 0x60FB,\r\n\t0x90C6, 0x60FC, 0x90C7, 0x60FD, 0x90C8, 0x60FE, 0x90C9, 0x60FF,\t0x90CA, 0x6102, 0x90CB, 0x6103, 0x90CC, 0x6104, 0x90CD, 0x6105,\r\n\t0x90CE, 0x6107, 0x90CF, 0x610A, 0x90D0, 0x610B, 0x90D1, 0x610C,\t0x90D2, 0x6110, 0x90D3, 0x6111, 0x90D4, 0x6112, 0x90D5, 0x6113,\r\n\t0x90D6, 0x6114, 0x90D7, 0x6116, 0x90D8, 0x6117, 0x90D9, 0x6118,\t0x90DA, 0x6119, 0x90DB, 0x611B, 0x90DC, 0x611C, 0x90DD, 0x611D,\r\n\t0x90DE, 0x611E, 0x90DF, 0x6121, 0x90E0, 0x6122, 0x90E1, 0x6125,\t0x90E2, 0x6128, 0x90E3, 0x6129, 0x90E4, 0x612A, 0x90E5, 0x612C,\r\n\t0x90E6, 0x612D, 0x90E7, 0x612E, 0x90E8, 0x612F, 0x90E9, 0x6130,\t0x90EA, 0x6131, 0x90EB, 0x6132, 0x90EC, 0x6133, 0x90ED, 0x6134,\r\n\t0x90EE, 0x6135, 0x90EF, 0x6136, 0x90F0, 0x6137, 0x90F1, 0x6138,\t0x90F2, 0x6139, 0x90F3, 0x613A, 0x90F4, 0x613B, 0x90F5, 0x613C,\r\n\t0x90F6, 0x613D, 0x90F7, 0x613E, 0x90F8, 0x6140, 0x90F9, 0x6141,\t0x90FA, 0x6142, 0x90FB, 0x6143, 0x90FC, 0x6144, 0x90FD, 0x6145,\r\n\t0x90FE, 0x6146, 0x9140, 0x6147, 0x9141, 0x6149, 0x9142, 0x614B,\t0x9143, 0x614D, 0x9144, 0x614F, 0x9145, 0x6150, 0x9146, 0x6152,\r\n\t0x9147, 0x6153, 0x9148, 0x6154, 0x9149, 0x6156, 0x914A, 0x6157,\t0x914B, 0x6158, 0x914C, 0x6159, 0x914D, 0x615A, 0x914E, 0x615B,\r\n\t0x914F, 0x615C, 0x9150, 0x615E, 0x9151, 0x615F, 0x9152, 0x6160,\t0x9153, 0x6161, 0x9154, 0x6163, 0x9155, 0x6164, 0x9156, 0x6165,\r\n\t0x9157, 0x6166, 0x9158, 0x6169, 0x9159, 0x616A, 0x915A, 0x616B,\t0x915B, 0x616C, 0x915C, 0x616D, 0x915D, 0x616E, 0x915E, 0x616F,\r\n\t0x915F, 0x6171, 0x9160, 0x6172, 0x9161, 0x6173, 0x9162, 0x6174,\t0x9163, 0x6176, 0x9164, 0x6178, 0x9165, 0x6179, 0x9166, 0x617A,\r\n\t0x9167, 0x617B, 0x9168, 0x617C, 0x9169, 0x617D, 0x916A, 0x617E,\t0x916B, 0x617F, 0x916C, 0x6180, 0x916D, 0x6181, 0x916E, 0x6182,\r\n\t0x916F, 0x6183, 0x9170, 0x6184, 0x9171, 0x6185, 0x9172, 0x6186,\t0x9173, 0x6187, 0x9174, 0x6188, 0x9175, 0x6189, 0x9176, 0x618A,\r\n\t0x9177, 0x618C, 0x9178, 0x618D, 0x9179, 0x618F, 0x917A, 0x6190,\t0x917B, 0x6191, 0x917C, 0x6192, 0x917D, 0x6193, 0x917E, 0x6195,\r\n\t0x9180, 0x6196, 0x9181, 0x6197, 0x9182, 0x6198, 0x9183, 0x6199,\t0x9184, 0x619A, 0x9185, 0x619B, 0x9186, 0x619C, 0x9187, 0x619E,\r\n\t0x9188, 0x619F, 0x9189, 0x61A0, 0x918A, 0x61A1, 0x918B, 0x61A2,\t0x918C, 0x61A3, 0x918D, 0x61A4, 0x918E, 0x61A5, 0x918F, 0x61A6,\r\n\t0x9190, 0x61AA, 0x9191, 0x61AB, 0x9192, 0x61AD, 0x9193, 0x61AE,\t0x9194, 0x61AF, 0x9195, 0x61B0, 0x9196, 0x61B1, 0x9197, 0x61B2,\r\n\t0x9198, 0x61B3, 0x9199, 0x61B4, 0x919A, 0x61B5, 0x919B, 0x61B6,\t0x919C, 0x61B8, 0x919D, 0x61B9, 0x919E, 0x61BA, 0x919F, 0x61BB,\r\n\t0x91A0, 0x61BC, 0x91A1, 0x61BD, 0x91A2, 0x61BF, 0x91A3, 0x61C0,\t0x91A4, 0x61C1, 0x91A5, 0x61C3, 0x91A6, 0x61C4, 0x91A7, 0x61C5,\r\n\t0x91A8, 0x61C6, 0x91A9, 0x61C7, 0x91AA, 0x61C9, 0x91AB, 0x61CC,\t0x91AC, 0x61CD, 0x91AD, 0x61CE, 0x91AE, 0x61CF, 0x91AF, 0x61D0,\r\n\t0x91B0, 0x61D3, 0x91B1, 0x61D5, 0x91B2, 0x61D6, 0x91B3, 0x61D7,\t0x91B4, 0x61D8, 0x91B5, 0x61D9, 0x91B6, 0x61DA, 0x91B7, 0x61DB,\r\n\t0x91B8, 0x61DC, 0x91B9, 0x61DD, 0x91BA, 0x61DE, 0x91BB, 0x61DF,\t0x91BC, 0x61E0, 0x91BD, 0x61E1, 0x91BE, 0x61E2, 0x91BF, 0x61E3,\r\n\t0x91C0, 0x61E4, 0x91C1, 0x61E5, 0x91C2, 0x61E7, 0x91C3, 0x61E8,\t0x91C4, 0x61E9, 0x91C5, 0x61EA, 0x91C6, 0x61EB, 0x91C7, 0x61EC,\r\n\t0x91C8, 0x61ED, 0x91C9, 0x61EE, 0x91CA, 0x61EF, 0x91CB, 0x61F0,\t0x91CC, 0x61F1, 0x91CD, 0x61F2, 0x91CE, 0x61F3, 0x91CF, 0x61F4,\r\n\t0x91D0, 0x61F6, 0x91D1, 0x61F7, 0x91D2, 0x61F8, 0x91D3, 0x61F9,\t0x91D4, 0x61FA, 0x91D5, 0x61FB, 0x91D6, 0x61FC, 0x91D7, 0x61FD,\r\n\t0x91D8, 0x61FE, 0x91D9, 0x6200, 0x91DA, 0x6201, 0x91DB, 0x6202,\t0x91DC, 0x6203, 0x91DD, 0x6204, 0x91DE, 0x6205, 0x91DF, 0x6207,\r\n\t0x91E0, 0x6209, 0x91E1, 0x6213, 0x91E2, 0x6214, 0x91E3, 0x6219,\t0x91E4, 0x621C, 0x91E5, 0x621D, 0x91E6, 0x621E, 0x91E7, 0x6220,\r\n\t0x91E8, 0x6223, 0x91E9, 0x6226, 0x91EA, 0x6227, 0x91EB, 0x6228,\t0x91EC, 0x6229, 0x91ED, 0x622B, 0x91EE, 0x622D, 0x91EF, 0x622F,\r\n\t0x91F0, 0x6230, 0x91F1, 0x6231, 0x91F2, 0x6232, 0x91F3, 0x6235,\t0x91F4, 0x6236, 0x91F5, 0x6238, 0x91F6, 0x6239, 0x91F7, 0x623A,\r\n\t0x91F8, 0x623B, 0x91F9, 0x623C, 0x91FA, 0x6242, 0x91FB, 0x6244,\t0x91FC, 0x6245, 0x91FD, 0x6246, 0x91FE, 0x624A, 0x9240, 0x624F,\r\n\t0x9241, 0x6250, 0x9242, 0x6255, 0x9243, 0x6256, 0x9244, 0x6257,\t0x9245, 0x6259, 0x9246, 0x625A, 0x9247, 0x625C, 0x9248, 0x625D,\r\n\t0x9249, 0x625E, 0x924A, 0x625F, 0x924B, 0x6260, 0x924C, 0x6261,\t0x924D, 0x6262, 0x924E, 0x6264, 0x924F, 0x6265, 0x9250, 0x6268,\r\n\t0x9251, 0x6271, 0x9252, 0x6272, 0x9253, 0x6274, 0x9254, 0x6275,\t0x9255, 0x6277, 0x9256, 0x6278, 0x9257, 0x627A, 0x9258, 0x627B,\r\n\t0x9259, 0x627D, 0x925A, 0x6281, 0x925B, 0x6282, 0x925C, 0x6283,\t0x925D, 0x6285, 0x925E, 0x6286, 0x925F, 0x6287, 0x9260, 0x6288,\r\n\t0x9261, 0x628B, 0x9262, 0x628C, 0x9263, 0x628D, 0x9264, 0x628E,\t0x9265, 0x628F, 0x9266, 0x6290, 0x9267, 0x6294, 0x9268, 0x6299,\r\n\t0x9269, 0x629C, 0x926A, 0x629D, 0x926B, 0x629E, 0x926C, 0x62A3,\t0x926D, 0x62A6, 0x926E, 0x62A7, 0x926F, 0x62A9, 0x9270, 0x62AA,\r\n\t0x9271, 0x62AD, 0x9272, 0x62AE, 0x9273, 0x62AF, 0x9274, 0x62B0,\t0x9275, 0x62B2, 0x9276, 0x62B3, 0x9277, 0x62B4, 0x9278, 0x62B6,\r\n\t0x9279, 0x62B7, 0x927A, 0x62B8, 0x927B, 0x62BA, 0x927C, 0x62BE,\t0x927D, 0x62C0, 0x927E, 0x62C1, 0x9280, 0x62C3, 0x9281, 0x62CB,\r\n\t0x9282, 0x62CF, 0x9283, 0x62D1, 0x9284, 0x62D5, 0x9285, 0x62DD,\t0x9286, 0x62DE, 0x9287, 0x62E0, 0x9288, 0x62E1, 0x9289, 0x62E4,\r\n\t0x928A, 0x62EA, 0x928B, 0x62EB, 0x928C, 0x62F0, 0x928D, 0x62F2,\t0x928E, 0x62F5, 0x928F, 0x62F8, 0x9290, 0x62F9, 0x9291, 0x62FA,\r\n\t0x9292, 0x62FB, 0x9293, 0x6300, 0x9294, 0x6303, 0x9295, 0x6304,\t0x9296, 0x6305, 0x9297, 0x6306, 0x9298, 0x630A, 0x9299, 0x630B,\r\n\t0x929A, 0x630C, 0x929B, 0x630D, 0x929C, 0x630F, 0x929D, 0x6310,\t0x929E, 0x6312, 0x929F, 0x6313, 0x92A0, 0x6314, 0x92A1, 0x6315,\r\n\t0x92A2, 0x6317, 0x92A3, 0x6318, 0x92A4, 0x6319, 0x92A5, 0x631C,\t0x92A6, 0x6326, 0x92A7, 0x6327, 0x92A8, 0x6329, 0x92A9, 0x632C,\r\n\t0x92AA, 0x632D, 0x92AB, 0x632E, 0x92AC, 0x6330, 0x92AD, 0x6331,\t0x92AE, 0x6333, 0x92AF, 0x6334, 0x92B0, 0x6335, 0x92B1, 0x6336,\r\n\t0x92B2, 0x6337, 0x92B3, 0x6338, 0x92B4, 0x633B, 0x92B5, 0x633C,\t0x92B6, 0x633E, 0x92B7, 0x633F, 0x92B8, 0x6340, 0x92B9, 0x6341,\r\n\t0x92BA, 0x6344, 0x92BB, 0x6347, 0x92BC, 0x6348, 0x92BD, 0x634A,\t0x92BE, 0x6351, 0x92BF, 0x6352, 0x92C0, 0x6353, 0x92C1, 0x6354,\r\n\t0x92C2, 0x6356, 0x92C3, 0x6357, 0x92C4, 0x6358, 0x92C5, 0x6359,\t0x92C6, 0x635A, 0x92C7, 0x635B, 0x92C8, 0x635C, 0x92C9, 0x635D,\r\n\t0x92CA, 0x6360, 0x92CB, 0x6364, 0x92CC, 0x6365, 0x92CD, 0x6366,\t0x92CE, 0x6368, 0x92CF, 0x636A, 0x92D0, 0x636B, 0x92D1, 0x636C,\r\n\t0x92D2, 0x636F, 0x92D3, 0x6370, 0x92D4, 0x6372, 0x92D5, 0x6373,\t0x92D6, 0x6374, 0x92D7, 0x6375, 0x92D8, 0x6378, 0x92D9, 0x6379,\r\n\t0x92DA, 0x637C, 0x92DB, 0x637D, 0x92DC, 0x637E, 0x92DD, 0x637F,\t0x92DE, 0x6381, 0x92DF, 0x6383, 0x92E0, 0x6384, 0x92E1, 0x6385,\r\n\t0x92E2, 0x6386, 0x92E3, 0x638B, 0x92E4, 0x638D, 0x92E5, 0x6391,\t0x92E6, 0x6393, 0x92E7, 0x6394, 0x92E8, 0x6395, 0x92E9, 0x6397,\r\n\t0x92EA, 0x6399, 0x92EB, 0x639A, 0x92EC, 0x639B, 0x92ED, 0x639C,\t0x92EE, 0x639D, 0x92EF, 0x639E, 0x92F0, 0x639F, 0x92F1, 0x63A1,\r\n\t0x92F2, 0x63A4, 0x92F3, 0x63A6, 0x92F4, 0x63AB, 0x92F5, 0x63AF,\t0x92F6, 0x63B1, 0x92F7, 0x63B2, 0x92F8, 0x63B5, 0x92F9, 0x63B6,\r\n\t0x92FA, 0x63B9, 0x92FB, 0x63BB, 0x92FC, 0x63BD, 0x92FD, 0x63BF,\t0x92FE, 0x63C0, 0x9340, 0x63C1, 0x9341, 0x63C2, 0x9342, 0x63C3,\r\n\t0x9343, 0x63C5, 0x9344, 0x63C7, 0x9345, 0x63C8, 0x9346, 0x63CA,\t0x9347, 0x63CB, 0x9348, 0x63CC, 0x9349, 0x63D1, 0x934A, 0x63D3,\r\n\t0x934B, 0x63D4, 0x934C, 0x63D5, 0x934D, 0x63D7, 0x934E, 0x63D8,\t0x934F, 0x63D9, 0x9350, 0x63DA, 0x9351, 0x63DB, 0x9352, 0x63DC,\r\n\t0x9353, 0x63DD, 0x9354, 0x63DF, 0x9355, 0x63E2, 0x9356, 0x63E4,\t0x9357, 0x63E5, 0x9358, 0x63E6, 0x9359, 0x63E7, 0x935A, 0x63E8,\r\n\t0x935B, 0x63EB, 0x935C, 0x63EC, 0x935D, 0x63EE, 0x935E, 0x63EF,\t0x935F, 0x63F0, 0x9360, 0x63F1, 0x9361, 0x63F3, 0x9362, 0x63F5,\r\n\t0x9363, 0x63F7, 0x9364, 0x63F9, 0x9365, 0x63FA, 0x9366, 0x63FB,\t0x9367, 0x63FC, 0x9368, 0x63FE, 0x9369, 0x6403, 0x936A, 0x6404,\r\n\t0x936B, 0x6406, 0x936C, 0x6407, 0x936D, 0x6408, 0x936E, 0x6409,\t0x936F, 0x640A, 0x9370, 0x640D, 0x9371, 0x640E, 0x9372, 0x6411,\r\n\t0x9373, 0x6412, 0x9374, 0x6415, 0x9375, 0x6416, 0x9376, 0x6417,\t0x9377, 0x6418, 0x9378, 0x6419, 0x9379, 0x641A, 0x937A, 0x641D,\r\n\t0x937B, 0x641F, 0x937C, 0x6422, 0x937D, 0x6423, 0x937E, 0x6424,\t0x9380, 0x6425, 0x9381, 0x6427, 0x9382, 0x6428, 0x9383, 0x6429,\r\n\t0x9384, 0x642B, 0x9385, 0x642E, 0x9386, 0x642F, 0x9387, 0x6430,\t0x9388, 0x6431, 0x9389, 0x6432, 0x938A, 0x6433, 0x938B, 0x6435,\r\n\t0x938C, 0x6436, 0x938D, 0x6437, 0x938E, 0x6438, 0x938F, 0x6439,\t0x9390, 0x643B, 0x9391, 0x643C, 0x9392, 0x643E, 0x9393, 0x6440,\r\n\t0x9394, 0x6442, 0x9395, 0x6443, 0x9396, 0x6449, 0x9397, 0x644B,\t0x9398, 0x644C, 0x9399, 0x644D, 0x939A, 0x644E, 0x939B, 0x644F,\r\n\t0x939C, 0x6450, 0x939D, 0x6451, 0x939E, 0x6453, 0x939F, 0x6455,\t0x93A0, 0x6456, 0x93A1, 0x6457, 0x93A2, 0x6459, 0x93A3, 0x645A,\r\n\t0x93A4, 0x645B, 0x93A5, 0x645C, 0x93A6, 0x645D, 0x93A7, 0x645F,\t0x93A8, 0x6460, 0x93A9, 0x6461, 0x93AA, 0x6462, 0x93AB, 0x6463,\r\n\t0x93AC, 0x6464, 0x93AD, 0x6465, 0x93AE, 0x6466, 0x93AF, 0x6468,\t0x93B0, 0x646A, 0x93B1, 0x646B, 0x93B2, 0x646C, 0x93B3, 0x646E,\r\n\t0x93B4, 0x646F, 0x93B5, 0x6470, 0x93B6, 0x6471, 0x93B7, 0x6472,\t0x93B8, 0x6473, 0x93B9, 0x6474, 0x93BA, 0x6475, 0x93BB, 0x6476,\r\n\t0x93BC, 0x6477, 0x93BD, 0x647B, 0x93BE, 0x647C, 0x93BF, 0x647D,\t0x93C0, 0x647E, 0x93C1, 0x647F, 0x93C2, 0x6480, 0x93C3, 0x6481,\r\n\t0x93C4, 0x6483, 0x93C5, 0x6486, 0x93C6, 0x6488, 0x93C7, 0x6489,\t0x93C8, 0x648A, 0x93C9, 0x648B, 0x93CA, 0x648C, 0x93CB, 0x648D,\r\n\t0x93CC, 0x648E, 0x93CD, 0x648F, 0x93CE, 0x6490, 0x93CF, 0x6493,\t0x93D0, 0x6494, 0x93D1, 0x6497, 0x93D2, 0x6498, 0x93D3, 0x649A,\r\n\t0x93D4, 0x649B, 0x93D5, 0x649C, 0x93D6, 0x649D, 0x93D7, 0x649F,\t0x93D8, 0x64A0, 0x93D9, 0x64A1, 0x93DA, 0x64A2, 0x93DB, 0x64A3,\r\n\t0x93DC, 0x64A5, 0x93DD, 0x64A6, 0x93DE, 0x64A7, 0x93DF, 0x64A8,\t0x93E0, 0x64AA, 0x93E1, 0x64AB, 0x93E2, 0x64AF, 0x93E3, 0x64B1,\r\n\t0x93E4, 0x64B2, 0x93E5, 0x64B3, 0x93E6, 0x64B4, 0x93E7, 0x64B6,\t0x93E8, 0x64B9, 0x93E9, 0x64BB, 0x93EA, 0x64BD, 0x93EB, 0x64BE,\r\n\t0x93EC, 0x64BF, 0x93ED, 0x64C1, 0x93EE, 0x64C3, 0x93EF, 0x64C4,\t0x93F0, 0x64C6, 0x93F1, 0x64C7, 0x93F2, 0x64C8, 0x93F3, 0x64C9,\r\n\t0x93F4, 0x64CA, 0x93F5, 0x64CB, 0x93F6, 0x64CC, 0x93F7, 0x64CF,\t0x93F8, 0x64D1, 0x93F9, 0x64D3, 0x93FA, 0x64D4, 0x93FB, 0x64D5,\r\n\t0x93FC, 0x64D6, 0x93FD, 0x64D9, 0x93FE, 0x64DA, 0x9440, 0x64DB,\t0x9441, 0x64DC, 0x9442, 0x64DD, 0x9443, 0x64DF, 0x9444, 0x64E0,\r\n\t0x9445, 0x64E1, 0x9446, 0x64E3, 0x9447, 0x64E5, 0x9448, 0x64E7,\t0x9449, 0x64E8, 0x944A, 0x64E9, 0x944B, 0x64EA, 0x944C, 0x64EB,\r\n\t0x944D, 0x64EC, 0x944E, 0x64ED, 0x944F, 0x64EE, 0x9450, 0x64EF,\t0x9451, 0x64F0, 0x9452, 0x64F1, 0x9453, 0x64F2, 0x9454, 0x64F3,\r\n\t0x9455, 0x64F4, 0x9456, 0x64F5, 0x9457, 0x64F6, 0x9458, 0x64F7,\t0x9459, 0x64F8, 0x945A, 0x64F9, 0x945B, 0x64FA, 0x945C, 0x64FB,\r\n\t0x945D, 0x64FC, 0x945E, 0x64FD, 0x945F, 0x64FE, 0x9460, 0x64FF,\t0x9461, 0x6501, 0x9462, 0x6502, 0x9463, 0x6503, 0x9464, 0x6504,\r\n\t0x9465, 0x6505, 0x9466, 0x6506, 0x9467, 0x6507, 0x9468, 0x6508,\t0x9469, 0x650A, 0x946A, 0x650B, 0x946B, 0x650C, 0x946C, 0x650D,\r\n\t0x946D, 0x650E, 0x946E, 0x650F, 0x946F, 0x6510, 0x9470, 0x6511,\t0x9471, 0x6513, 0x9472, 0x6514, 0x9473, 0x6515, 0x9474, 0x6516,\r\n\t0x9475, 0x6517, 0x9476, 0x6519, 0x9477, 0x651A, 0x9478, 0x651B,\t0x9479, 0x651C, 0x947A, 0x651D, 0x947B, 0x651E, 0x947C, 0x651F,\r\n\t0x947D, 0x6520, 0x947E, 0x6521, 0x9480, 0x6522, 0x9481, 0x6523,\t0x9482, 0x6524, 0x9483, 0x6526, 0x9484, 0x6527, 0x9485, 0x6528,\r\n\t0x9486, 0x6529, 0x9487, 0x652A, 0x9488, 0x652C, 0x9489, 0x652D,\t0x948A, 0x6530, 0x948B, 0x6531, 0x948C, 0x6532, 0x948D, 0x6533,\r\n\t0x948E, 0x6537, 0x948F, 0x653A, 0x9490, 0x653C, 0x9491, 0x653D,\t0x9492, 0x6540, 0x9493, 0x6541, 0x9494, 0x6542, 0x9495, 0x6543,\r\n\t0x9496, 0x6544, 0x9497, 0x6546, 0x9498, 0x6547, 0x9499, 0x654A,\t0x949A, 0x654B, 0x949B, 0x654D, 0x949C, 0x654E, 0x949D, 0x6550,\r\n\t0x949E, 0x6552, 0x949F, 0x6553, 0x94A0, 0x6554, 0x94A1, 0x6557,\t0x94A2, 0x6558, 0x94A3, 0x655A, 0x94A4, 0x655C, 0x94A5, 0x655F,\r\n\t0x94A6, 0x6560, 0x94A7, 0x6561, 0x94A8, 0x6564, 0x94A9, 0x6565,\t0x94AA, 0x6567, 0x94AB, 0x6568, 0x94AC, 0x6569, 0x94AD, 0x656A,\r\n\t0x94AE, 0x656D, 0x94AF, 0x656E, 0x94B0, 0x656F, 0x94B1, 0x6571,\t0x94B2, 0x6573, 0x94B3, 0x6575, 0x94B4, 0x6576, 0x94B5, 0x6578,\r\n\t0x94B6, 0x6579, 0x94B7, 0x657A, 0x94B8, 0x657B, 0x94B9, 0x657C,\t0x94BA, 0x657D, 0x94BB, 0x657E, 0x94BC, 0x657F, 0x94BD, 0x6580,\r\n\t0x94BE, 0x6581, 0x94BF, 0x6582, 0x94C0, 0x6583, 0x94C1, 0x6584,\t0x94C2, 0x6585, 0x94C3, 0x6586, 0x94C4, 0x6588, 0x94C5, 0x6589,\r\n\t0x94C6, 0x658A, 0x94C7, 0x658D, 0x94C8, 0x658E, 0x94C9, 0x658F,\t0x94CA, 0x6592, 0x94CB, 0x6594, 0x94CC, 0x6595, 0x94CD, 0x6596,\r\n\t0x94CE, 0x6598, 0x94CF, 0x659A, 0x94D0, 0x659D, 0x94D1, 0x659E,\t0x94D2, 0x65A0, 0x94D3, 0x65A2, 0x94D4, 0x65A3, 0x94D5, 0x65A6,\r\n\t0x94D6, 0x65A8, 0x94D7, 0x65AA, 0x94D8, 0x65AC, 0x94D9, 0x65AE,\t0x94DA, 0x65B1, 0x94DB, 0x65B2, 0x94DC, 0x65B3, 0x94DD, 0x65B4,\r\n\t0x94DE, 0x65B5, 0x94DF, 0x65B6, 0x94E0, 0x65B7, 0x94E1, 0x65B8,\t0x94E2, 0x65BA, 0x94E3, 0x65BB, 0x94E4, 0x65BE, 0x94E5, 0x65BF,\r\n\t0x94E6, 0x65C0, 0x94E7, 0x65C2, 0x94E8, 0x65C7, 0x94E9, 0x65C8,\t0x94EA, 0x65C9, 0x94EB, 0x65CA, 0x94EC, 0x65CD, 0x94ED, 0x65D0,\r\n\t0x94EE, 0x65D1, 0x94EF, 0x65D3, 0x94F0, 0x65D4, 0x94F1, 0x65D5,\t0x94F2, 0x65D8, 0x94F3, 0x65D9, 0x94F4, 0x65DA, 0x94F5, 0x65DB,\r\n\t0x94F6, 0x65DC, 0x94F7, 0x65DD, 0x94F8, 0x65DE, 0x94F9, 0x65DF,\t0x94FA, 0x65E1, 0x94FB, 0x65E3, 0x94FC, 0x65E4, 0x94FD, 0x65EA,\r\n\t0x94FE, 0x65EB, 0x9540, 0x65F2, 0x9541, 0x65F3, 0x9542, 0x65F4,\t0x9543, 0x65F5, 0x9544, 0x65F8, 0x9545, 0x65F9, 0x9546, 0x65FB,\r\n\t0x9547, 0x65FC, 0x9548, 0x65FD, 0x9549, 0x65FE, 0x954A, 0x65FF,\t0x954B, 0x6601, 0x954C, 0x6604, 0x954D, 0x6605, 0x954E, 0x6607,\r\n\t0x954F, 0x6608, 0x9550, 0x6609, 0x9551, 0x660B, 0x9552, 0x660D,\t0x9553, 0x6610, 0x9554, 0x6611, 0x9555, 0x6612, 0x9556, 0x6616,\r\n\t0x9557, 0x6617, 0x9558, 0x6618, 0x9559, 0x661A, 0x955A, 0x661B,\t0x955B, 0x661C, 0x955C, 0x661E, 0x955D, 0x6621, 0x955E, 0x6622,\r\n\t0x955F, 0x6623, 0x9560, 0x6624, 0x9561, 0x6626, 0x9562, 0x6629,\t0x9563, 0x662A, 0x9564, 0x662B, 0x9565, 0x662C, 0x9566, 0x662E,\r\n\t0x9567, 0x6630, 0x9568, 0x6632, 0x9569, 0x6633, 0x956A, 0x6637,\t0x956B, 0x6638, 0x956C, 0x6639, 0x956D, 0x663A, 0x956E, 0x663B,\r\n\t0x956F, 0x663D, 0x9570, 0x663F, 0x9571, 0x6640, 0x9572, 0x6642,\t0x9573, 0x6644, 0x9574, 0x6645, 0x9575, 0x6646, 0x9576, 0x6647,\r\n\t0x9577, 0x6648, 0x9578, 0x6649, 0x9579, 0x664A, 0x957A, 0x664D,\t0x957B, 0x664E, 0x957C, 0x6650, 0x957D, 0x6651, 0x957E, 0x6658,\r\n\t0x9580, 0x6659, 0x9581, 0x665B, 0x9582, 0x665C, 0x9583, 0x665D,\t0x9584, 0x665E, 0x9585, 0x6660, 0x9586, 0x6662, 0x9587, 0x6663,\r\n\t0x9588, 0x6665, 0x9589, 0x6667, 0x958A, 0x6669, 0x958B, 0x666A,\t0x958C, 0x666B, 0x958D, 0x666C, 0x958E, 0x666D, 0x958F, 0x6671,\r\n\t0x9590, 0x6672, 0x9591, 0x6673, 0x9592, 0x6675, 0x9593, 0x6678,\t0x9594, 0x6679, 0x9595, 0x667B, 0x9596, 0x667C, 0x9597, 0x667D,\r\n\t0x9598, 0x667F, 0x9599, 0x6680, 0x959A, 0x6681, 0x959B, 0x6683,\t0x959C, 0x6685, 0x959D, 0x6686, 0x959E, 0x6688, 0x959F, 0x6689,\r\n\t0x95A0, 0x668A, 0x95A1, 0x668B, 0x95A2, 0x668D, 0x95A3, 0x668E,\t0x95A4, 0x668F, 0x95A5, 0x6690, 0x95A6, 0x6692, 0x95A7, 0x6693,\r\n\t0x95A8, 0x6694, 0x95A9, 0x6695, 0x95AA, 0x6698, 0x95AB, 0x6699,\t0x95AC, 0x669A, 0x95AD, 0x669B, 0x95AE, 0x669C, 0x95AF, 0x669E,\r\n\t0x95B0, 0x669F, 0x95B1, 0x66A0, 0x95B2, 0x66A1, 0x95B3, 0x66A2,\t0x95B4, 0x66A3, 0x95B5, 0x66A4, 0x95B6, 0x66A5, 0x95B7, 0x66A6,\r\n\t0x95B8, 0x66A9, 0x95B9, 0x66AA, 0x95BA, 0x66AB, 0x95BB, 0x66AC,\t0x95BC, 0x66AD, 0x95BD, 0x66AF, 0x95BE, 0x66B0, 0x95BF, 0x66B1,\r\n\t0x95C0, 0x66B2, 0x95C1, 0x66B3, 0x95C2, 0x66B5, 0x95C3, 0x66B6,\t0x95C4, 0x66B7, 0x95C5, 0x66B8, 0x95C6, 0x66BA, 0x95C7, 0x66BB,\r\n\t0x95C8, 0x66BC, 0x95C9, 0x66BD, 0x95CA, 0x66BF, 0x95CB, 0x66C0,\t0x95CC, 0x66C1, 0x95CD, 0x66C2, 0x95CE, 0x66C3, 0x95CF, 0x66C4,\r\n\t0x95D0, 0x66C5, 0x95D1, 0x66C6, 0x95D2, 0x66C7, 0x95D3, 0x66C8,\t0x95D4, 0x66C9, 0x95D5, 0x66CA, 0x95D6, 0x66CB, 0x95D7, 0x66CC,\r\n\t0x95D8, 0x66CD, 0x95D9, 0x66CE, 0x95DA, 0x66CF, 0x95DB, 0x66D0,\t0x95DC, 0x66D1, 0x95DD, 0x66D2, 0x95DE, 0x66D3, 0x95DF, 0x66D4,\r\n\t0x95E0, 0x66D5, 0x95E1, 0x66D6, 0x95E2, 0x66D7, 0x95E3, 0x66D8,\t0x95E4, 0x66DA, 0x95E5, 0x66DE, 0x95E6, 0x66DF, 0x95E7, 0x66E0,\r\n\t0x95E8, 0x66E1, 0x95E9, 0x66E2, 0x95EA, 0x66E3, 0x95EB, 0x66E4,\t0x95EC, 0x66E5, 0x95ED, 0x66E7, 0x95EE, 0x66E8, 0x95EF, 0x66EA,\r\n\t0x95F0, 0x66EB, 0x95F1, 0x66EC, 0x95F2, 0x66ED, 0x95F3, 0x66EE,\t0x95F4, 0x66EF, 0x95F5, 0x66F1, 0x95F6, 0x66F5, 0x95F7, 0x66F6,\r\n\t0x95F8, 0x66F8, 0x95F9, 0x66FA, 0x95FA, 0x66FB, 0x95FB, 0x66FD,\t0x95FC, 0x6701, 0x95FD, 0x6702, 0x95FE, 0x6703, 0x9640, 0x6704,\r\n\t0x9641, 0x6705, 0x9642, 0x6706, 0x9643, 0x6707, 0x9644, 0x670C,\t0x9645, 0x670E, 0x9646, 0x670F, 0x9647, 0x6711, 0x9648, 0x6712,\r\n\t0x9649, 0x6713, 0x964A, 0x6716, 0x964B, 0x6718, 0x964C, 0x6719,\t0x964D, 0x671A, 0x964E, 0x671C, 0x964F, 0x671E, 0x9650, 0x6720,\r\n\t0x9651, 0x6721, 0x9652, 0x6722, 0x9653, 0x6723, 0x9654, 0x6724,\t0x9655, 0x6725, 0x9656, 0x6727, 0x9657, 0x6729, 0x9658, 0x672E,\r\n\t0x9659, 0x6730, 0x965A, 0x6732, 0x965B, 0x6733, 0x965C, 0x6736,\t0x965D, 0x6737, 0x965E, 0x6738, 0x965F, 0x6739, 0x9660, 0x673B,\r\n\t0x9661, 0x673C, 0x9662, 0x673E, 0x9663, 0x673F, 0x9664, 0x6741,\t0x9665, 0x6744, 0x9666, 0x6745, 0x9667, 0x6747, 0x9668, 0x674A,\r\n\t0x9669, 0x674B, 0x966A, 0x674D, 0x966B, 0x6752, 0x966C, 0x6754,\t0x966D, 0x6755, 0x966E, 0x6757, 0x966F, 0x6758, 0x9670, 0x6759,\r\n\t0x9671, 0x675A, 0x9672, 0x675B, 0x9673, 0x675D, 0x9674, 0x6762,\t0x9675, 0x6763, 0x9676, 0x6764, 0x9677, 0x6766, 0x9678, 0x6767,\r\n\t0x9679, 0x676B, 0x967A, 0x676C, 0x967B, 0x676E, 0x967C, 0x6771,\t0x967D, 0x6774, 0x967E, 0x6776, 0x9680, 0x6778, 0x9681, 0x6779,\r\n\t0x9682, 0x677A, 0x9683, 0x677B, 0x9684, 0x677D, 0x9685, 0x6780,\t0x9686, 0x6782, 0x9687, 0x6783, 0x9688, 0x6785, 0x9689, 0x6786,\r\n\t0x968A, 0x6788, 0x968B, 0x678A, 0x968C, 0x678C, 0x968D, 0x678D,\t0x968E, 0x678E, 0x968F, 0x678F, 0x9690, 0x6791, 0x9691, 0x6792,\r\n\t0x9692, 0x6793, 0x9693, 0x6794, 0x9694, 0x6796, 0x9695, 0x6799,\t0x9696, 0x679B, 0x9697, 0x679F, 0x9698, 0x67A0, 0x9699, 0x67A1,\r\n\t0x969A, 0x67A4, 0x969B, 0x67A6, 0x969C, 0x67A9, 0x969D, 0x67AC,\t0x969E, 0x67AE, 0x969F, 0x67B1, 0x96A0, 0x67B2, 0x96A1, 0x67B4,\r\n\t0x96A2, 0x67B9, 0x96A3, 0x67BA, 0x96A4, 0x67BB, 0x96A5, 0x67BC,\t0x96A6, 0x67BD, 0x96A7, 0x67BE, 0x96A8, 0x67BF, 0x96A9, 0x67C0,\r\n\t0x96AA, 0x67C2, 0x96AB, 0x67C5, 0x96AC, 0x67C6, 0x96AD, 0x67C7,\t0x96AE, 0x67C8, 0x96AF, 0x67C9, 0x96B0, 0x67CA, 0x96B1, 0x67CB,\r\n\t0x96B2, 0x67CC, 0x96B3, 0x67CD, 0x96B4, 0x67CE, 0x96B5, 0x67D5,\t0x96B6, 0x67D6, 0x96B7, 0x67D7, 0x96B8, 0x67DB, 0x96B9, 0x67DF,\r\n\t0x96BA, 0x67E1, 0x96BB, 0x67E3, 0x96BC, 0x67E4, 0x96BD, 0x67E6,\t0x96BE, 0x67E7, 0x96BF, 0x67E8, 0x96C0, 0x67EA, 0x96C1, 0x67EB,\r\n\t0x96C2, 0x67ED, 0x96C3, 0x67EE, 0x96C4, 0x67F2, 0x96C5, 0x67F5,\t0x96C6, 0x67F6, 0x96C7, 0x67F7, 0x96C8, 0x67F8, 0x96C9, 0x67F9,\r\n\t0x96CA, 0x67FA, 0x96CB, 0x67FB, 0x96CC, 0x67FC, 0x96CD, 0x67FE,\t0x96CE, 0x6801, 0x96CF, 0x6802, 0x96D0, 0x6803, 0x96D1, 0x6804,\r\n\t0x96D2, 0x6806, 0x96D3, 0x680D, 0x96D4, 0x6810, 0x96D5, 0x6812,\t0x96D6, 0x6814, 0x96D7, 0x6815, 0x96D8, 0x6818, 0x96D9, 0x6819,\r\n\t0x96DA, 0x681A, 0x96DB, 0x681B, 0x96DC, 0x681C, 0x96DD, 0x681E,\t0x96DE, 0x681F, 0x96DF, 0x6820, 0x96E0, 0x6822, 0x96E1, 0x6823,\r\n\t0x96E2, 0x6824, 0x96E3, 0x6825, 0x96E4, 0x6826, 0x96E5, 0x6827,\t0x96E6, 0x6828, 0x96E7, 0x682B, 0x96E8, 0x682C, 0x96E9, 0x682D,\r\n\t0x96EA, 0x682E, 0x96EB, 0x682F, 0x96EC, 0x6830, 0x96ED, 0x6831,\t0x96EE, 0x6834, 0x96EF, 0x6835, 0x96F0, 0x6836, 0x96F1, 0x683A,\r\n\t0x96F2, 0x683B, 0x96F3, 0x683F, 0x96F4, 0x6847, 0x96F5, 0x684B,\t0x96F6, 0x684D, 0x96F7, 0x684F, 0x96F8, 0x6852, 0x96F9, 0x6856,\r\n\t0x96FA, 0x6857, 0x96FB, 0x6858, 0x96FC, 0x6859, 0x96FD, 0x685A,\t0x96FE, 0x685B, 0x9740, 0x685C, 0x9741, 0x685D, 0x9742, 0x685E,\r\n\t0x9743, 0x685F, 0x9744, 0x686A, 0x9745, 0x686C, 0x9746, 0x686D,\t0x9747, 0x686E, 0x9748, 0x686F, 0x9749, 0x6870, 0x974A, 0x6871,\r\n\t0x974B, 0x6872, 0x974C, 0x6873, 0x974D, 0x6875, 0x974E, 0x6878,\t0x974F, 0x6879, 0x9750, 0x687A, 0x9751, 0x687B, 0x9752, 0x687C,\r\n\t0x9753, 0x687D, 0x9754, 0x687E, 0x9755, 0x687F, 0x9756, 0x6880,\t0x9757, 0x6882, 0x9758, 0x6884, 0x9759, 0x6887, 0x975A, 0x6888,\r\n\t0x975B, 0x6889, 0x975C, 0x688A, 0x975D, 0x688B, 0x975E, 0x688C,\t0x975F, 0x688D, 0x9760, 0x688E, 0x9761, 0x6890, 0x9762, 0x6891,\r\n\t0x9763, 0x6892, 0x9764, 0x6894, 0x9765, 0x6895, 0x9766, 0x6896,\t0x9767, 0x6898, 0x9768, 0x6899, 0x9769, 0x689A, 0x976A, 0x689B,\r\n\t0x976B, 0x689C, 0x976C, 0x689D, 0x976D, 0x689E, 0x976E, 0x689F,\t0x976F, 0x68A0, 0x9770, 0x68A1, 0x9771, 0x68A3, 0x9772, 0x68A4,\r\n\t0x9773, 0x68A5, 0x9774, 0x68A9, 0x9775, 0x68AA, 0x9776, 0x68AB,\t0x9777, 0x68AC, 0x9778, 0x68AE, 0x9779, 0x68B1, 0x977A, 0x68B2,\r\n\t0x977B, 0x68B4, 0x977C, 0x68B6, 0x977D, 0x68B7, 0x977E, 0x68B8,\t0x9780, 0x68B9, 0x9781, 0x68BA, 0x9782, 0x68BB, 0x9783, 0x68BC,\r\n\t0x9784, 0x68BD, 0x9785, 0x68BE, 0x9786, 0x68BF, 0x9787, 0x68C1,\t0x9788, 0x68C3, 0x9789, 0x68C4, 0x978A, 0x68C5, 0x978B, 0x68C6,\r\n\t0x978C, 0x68C7, 0x978D, 0x68C8, 0x978E, 0x68CA, 0x978F, 0x68CC,\t0x9790, 0x68CE, 0x9791, 0x68CF, 0x9792, 0x68D0, 0x9793, 0x68D1,\r\n\t0x9794, 0x68D3, 0x9795, 0x68D4, 0x9796, 0x68D6, 0x9797, 0x68D7,\t0x9798, 0x68D9, 0x9799, 0x68DB, 0x979A, 0x68DC, 0x979B, 0x68DD,\r\n\t0x979C, 0x68DE, 0x979D, 0x68DF, 0x979E, 0x68E1, 0x979F, 0x68E2,\t0x97A0, 0x68E4, 0x97A1, 0x68E5, 0x97A2, 0x68E6, 0x97A3, 0x68E7,\r\n\t0x97A4, 0x68E8, 0x97A5, 0x68E9, 0x97A6, 0x68EA, 0x97A7, 0x68EB,\t0x97A8, 0x68EC, 0x97A9, 0x68ED, 0x97AA, 0x68EF, 0x97AB, 0x68F2,\r\n\t0x97AC, 0x68F3, 0x97AD, 0x68F4, 0x97AE, 0x68F6, 0x97AF, 0x68F7,\t0x97B0, 0x68F8, 0x97B1, 0x68FB, 0x97B2, 0x68FD, 0x97B3, 0x68FE,\r\n\t0x97B4, 0x68FF, 0x97B5, 0x6900, 0x97B6, 0x6902, 0x97B7, 0x6903,\t0x97B8, 0x6904, 0x97B9, 0x6906, 0x97BA, 0x6907, 0x97BB, 0x6908,\r\n\t0x97BC, 0x6909, 0x97BD, 0x690A, 0x97BE, 0x690C, 0x97BF, 0x690F,\t0x97C0, 0x6911, 0x97C1, 0x6913, 0x97C2, 0x6914, 0x97C3, 0x6915,\r\n\t0x97C4, 0x6916, 0x97C5, 0x6917, 0x97C6, 0x6918, 0x97C7, 0x6919,\t0x97C8, 0x691A, 0x97C9, 0x691B, 0x97CA, 0x691C, 0x97CB, 0x691D,\r\n\t0x97CC, 0x691E, 0x97CD, 0x6921, 0x97CE, 0x6922, 0x97CF, 0x6923,\t0x97D0, 0x6925, 0x97D1, 0x6926, 0x97D2, 0x6927, 0x97D3, 0x6928,\r\n\t0x97D4, 0x6929, 0x97D5, 0x692A, 0x97D6, 0x692B, 0x97D7, 0x692C,\t0x97D8, 0x692E, 0x97D9, 0x692F, 0x97DA, 0x6931, 0x97DB, 0x6932,\r\n\t0x97DC, 0x6933, 0x97DD, 0x6935, 0x97DE, 0x6936, 0x97DF, 0x6937,\t0x97E0, 0x6938, 0x97E1, 0x693A, 0x97E2, 0x693B, 0x97E3, 0x693C,\r\n\t0x97E4, 0x693E, 0x97E5, 0x6940, 0x97E6, 0x6941, 0x97E7, 0x6943,\t0x97E8, 0x6944, 0x97E9, 0x6945, 0x97EA, 0x6946, 0x97EB, 0x6947,\r\n\t0x97EC, 0x6948, 0x97ED, 0x6949, 0x97EE, 0x694A, 0x97EF, 0x694B,\t0x97F0, 0x694C, 0x97F1, 0x694D, 0x97F2, 0x694E, 0x97F3, 0x694F,\r\n\t0x97F4, 0x6950, 0x97F5, 0x6951, 0x97F6, 0x6952, 0x97F7, 0x6953,\t0x97F8, 0x6955, 0x97F9, 0x6956, 0x97FA, 0x6958, 0x97FB, 0x6959,\r\n\t0x97FC, 0x695B, 0x97FD, 0x695C, 0x97FE, 0x695F, 0x9840, 0x6961,\t0x9841, 0x6962, 0x9842, 0x6964, 0x9843, 0x6965, 0x9844, 0x6967,\r\n\t0x9845, 0x6968, 0x9846, 0x6969, 0x9847, 0x696A, 0x9848, 0x696C,\t0x9849, 0x696D, 0x984A, 0x696F, 0x984B, 0x6970, 0x984C, 0x6972,\r\n\t0x984D, 0x6973, 0x984E, 0x6974, 0x984F, 0x6975, 0x9850, 0x6976,\t0x9851, 0x697A, 0x9852, 0x697B, 0x9853, 0x697D, 0x9854, 0x697E,\r\n\t0x9855, 0x697F, 0x9856, 0x6981, 0x9857, 0x6983, 0x9858, 0x6985,\t0x9859, 0x698A, 0x985A, 0x698B, 0x985B, 0x698C, 0x985C, 0x698E,\r\n\t0x985D, 0x698F, 0x985E, 0x6990, 0x985F, 0x6991, 0x9860, 0x6992,\t0x9861, 0x6993, 0x9862, 0x6996, 0x9863, 0x6997, 0x9864, 0x6999,\r\n\t0x9865, 0x699A, 0x9866, 0x699D, 0x9867, 0x699E, 0x9868, 0x699F,\t0x9869, 0x69A0, 0x986A, 0x69A1, 0x986B, 0x69A2, 0x986C, 0x69A3,\r\n\t0x986D, 0x69A4, 0x986E, 0x69A5, 0x986F, 0x69A6, 0x9870, 0x69A9,\t0x9871, 0x69AA, 0x9872, 0x69AC, 0x9873, 0x69AE, 0x9874, 0x69AF,\r\n\t0x9875, 0x69B0, 0x9876, 0x69B2, 0x9877, 0x69B3, 0x9878, 0x69B5,\t0x9879, 0x69B6, 0x987A, 0x69B8, 0x987B, 0x69B9, 0x987C, 0x69BA,\r\n\t0x987D, 0x69BC, 0x987E, 0x69BD, 0x9880, 0x69BE, 0x9881, 0x69BF,\t0x9882, 0x69C0, 0x9883, 0x69C2, 0x9884, 0x69C3, 0x9885, 0x69C4,\r\n\t0x9886, 0x69C5, 0x9887, 0x69C6, 0x9888, 0x69C7, 0x9889, 0x69C8,\t0x988A, 0x69C9, 0x988B, 0x69CB, 0x988C, 0x69CD, 0x988D, 0x69CF,\r\n\t0x988E, 0x69D1, 0x988F, 0x69D2, 0x9890, 0x69D3, 0x9891, 0x69D5,\t0x9892, 0x69D6, 0x9893, 0x69D7, 0x9894, 0x69D8, 0x9895, 0x69D9,\r\n\t0x9896, 0x69DA, 0x9897, 0x69DC, 0x9898, 0x69DD, 0x9899, 0x69DE,\t0x989A, 0x69E1, 0x989B, 0x69E2, 0x989C, 0x69E3, 0x989D, 0x69E4,\r\n\t0x989E, 0x69E5, 0x989F, 0x69E6, 0x98A0, 0x69E7, 0x98A1, 0x69E8,\t0x98A2, 0x69E9, 0x98A3, 0x69EA, 0x98A4, 0x69EB, 0x98A5, 0x69EC,\r\n\t0x98A6, 0x69EE, 0x98A7, 0x69EF, 0x98A8, 0x69F0, 0x98A9, 0x69F1,\t0x98AA, 0x69F3, 0x98AB, 0x69F4, 0x98AC, 0x69F5, 0x98AD, 0x69F6,\r\n\t0x98AE, 0x69F7, 0x98AF, 0x69F8, 0x98B0, 0x69F9, 0x98B1, 0x69FA,\t0x98B2, 0x69FB, 0x98B3, 0x69FC, 0x98B4, 0x69FE, 0x98B5, 0x6A00,\r\n\t0x98B6, 0x6A01, 0x98B7, 0x6A02, 0x98B8, 0x6A03, 0x98B9, 0x6A04,\t0x98BA, 0x6A05, 0x98BB, 0x6A06, 0x98BC, 0x6A07, 0x98BD, 0x6A08,\r\n\t0x98BE, 0x6A09, 0x98BF, 0x6A0B, 0x98C0, 0x6A0C, 0x98C1, 0x6A0D,\t0x98C2, 0x6A0E, 0x98C3, 0x6A0F, 0x98C4, 0x6A10, 0x98C5, 0x6A11,\r\n\t0x98C6, 0x6A12, 0x98C7, 0x6A13, 0x98C8, 0x6A14, 0x98C9, 0x6A15,\t0x98CA, 0x6A16, 0x98CB, 0x6A19, 0x98CC, 0x6A1A, 0x98CD, 0x6A1B,\r\n\t0x98CE, 0x6A1C, 0x98CF, 0x6A1D, 0x98D0, 0x6A1E, 0x98D1, 0x6A20,\t0x98D2, 0x6A22, 0x98D3, 0x6A23, 0x98D4, 0x6A24, 0x98D5, 0x6A25,\r\n\t0x98D6, 0x6A26, 0x98D7, 0x6A27, 0x98D8, 0x6A29, 0x98D9, 0x6A2B,\t0x98DA, 0x6A2C, 0x98DB, 0x6A2D, 0x98DC, 0x6A2E, 0x98DD, 0x6A30,\r\n\t0x98DE, 0x6A32, 0x98DF, 0x6A33, 0x98E0, 0x6A34, 0x98E1, 0x6A36,\t0x98E2, 0x6A37, 0x98E3, 0x6A38, 0x98E4, 0x6A39, 0x98E5, 0x6A3A,\r\n\t0x98E6, 0x6A3B, 0x98E7, 0x6A3C, 0x98E8, 0x6A3F, 0x98E9, 0x6A40,\t0x98EA, 0x6A41, 0x98EB, 0x6A42, 0x98EC, 0x6A43, 0x98ED, 0x6A45,\r\n\t0x98EE, 0x6A46, 0x98EF, 0x6A48, 0x98F0, 0x6A49, 0x98F1, 0x6A4A,\t0x98F2, 0x6A4B, 0x98F3, 0x6A4C, 0x98F4, 0x6A4D, 0x98F5, 0x6A4E,\r\n\t0x98F6, 0x6A4F, 0x98F7, 0x6A51, 0x98F8, 0x6A52, 0x98F9, 0x6A53,\t0x98FA, 0x6A54, 0x98FB, 0x6A55, 0x98FC, 0x6A56, 0x98FD, 0x6A57,\r\n\t0x98FE, 0x6A5A, 0x9940, 0x6A5C, 0x9941, 0x6A5D, 0x9942, 0x6A5E,\t0x9943, 0x6A5F, 0x9944, 0x6A60, 0x9945, 0x6A62, 0x9946, 0x6A63,\r\n\t0x9947, 0x6A64, 0x9948, 0x6A66, 0x9949, 0x6A67, 0x994A, 0x6A68,\t0x994B, 0x6A69, 0x994C, 0x6A6A, 0x994D, 0x6A6B, 0x994E, 0x6A6C,\r\n\t0x994F, 0x6A6D, 0x9950, 0x6A6E, 0x9951, 0x6A6F, 0x9952, 0x6A70,\t0x9953, 0x6A72, 0x9954, 0x6A73, 0x9955, 0x6A74, 0x9956, 0x6A75,\r\n\t0x9957, 0x6A76, 0x9958, 0x6A77, 0x9959, 0x6A78, 0x995A, 0x6A7A,\t0x995B, 0x6A7B, 0x995C, 0x6A7D, 0x995D, 0x6A7E, 0x995E, 0x6A7F,\r\n\t0x995F, 0x6A81, 0x9960, 0x6A82, 0x9961, 0x6A83, 0x9962, 0x6A85,\t0x9963, 0x6A86, 0x9964, 0x6A87, 0x9965, 0x6A88, 0x9966, 0x6A89,\r\n\t0x9967, 0x6A8A, 0x9968, 0x6A8B, 0x9969, 0x6A8C, 0x996A, 0x6A8D,\t0x996B, 0x6A8F, 0x996C, 0x6A92, 0x996D, 0x6A93, 0x996E, 0x6A94,\r\n\t0x996F, 0x6A95, 0x9970, 0x6A96, 0x9971, 0x6A98, 0x9972, 0x6A99,\t0x9973, 0x6A9A, 0x9974, 0x6A9B, 0x9975, 0x6A9C, 0x9976, 0x6A9D,\r\n\t0x9977, 0x6A9E, 0x9978, 0x6A9F, 0x9979, 0x6AA1, 0x997A, 0x6AA2,\t0x997B, 0x6AA3, 0x997C, 0x6AA4, 0x997D, 0x6AA5, 0x997E, 0x6AA6,\r\n\t0x9980, 0x6AA7, 0x9981, 0x6AA8, 0x9982, 0x6AAA, 0x9983, 0x6AAD,\t0x9984, 0x6AAE, 0x9985, 0x6AAF, 0x9986, 0x6AB0, 0x9987, 0x6AB1,\r\n\t0x9988, 0x6AB2, 0x9989, 0x6AB3, 0x998A, 0x6AB4, 0x998B, 0x6AB5,\t0x998C, 0x6AB6, 0x998D, 0x6AB7, 0x998E, 0x6AB8, 0x998F, 0x6AB9,\r\n\t0x9990, 0x6ABA, 0x9991, 0x6ABB, 0x9992, 0x6ABC, 0x9993, 0x6ABD,\t0x9994, 0x6ABE, 0x9995, 0x6ABF, 0x9996, 0x6AC0, 0x9997, 0x6AC1,\r\n\t0x9998, 0x6AC2, 0x9999, 0x6AC3, 0x999A, 0x6AC4, 0x999B, 0x6AC5,\t0x999C, 0x6AC6, 0x999D, 0x6AC7, 0x999E, 0x6AC8, 0x999F, 0x6AC9,\r\n\t0x99A0, 0x6ACA, 0x99A1, 0x6ACB, 0x99A2, 0x6ACC, 0x99A3, 0x6ACD,\t0x99A4, 0x6ACE, 0x99A5, 0x6ACF, 0x99A6, 0x6AD0, 0x99A7, 0x6AD1,\r\n\t0x99A8, 0x6AD2, 0x99A9, 0x6AD3, 0x99AA, 0x6AD4, 0x99AB, 0x6AD5,\t0x99AC, 0x6AD6, 0x99AD, 0x6AD7, 0x99AE, 0x6AD8, 0x99AF, 0x6AD9,\r\n\t0x99B0, 0x6ADA, 0x99B1, 0x6ADB, 0x99B2, 0x6ADC, 0x99B3, 0x6ADD,\t0x99B4, 0x6ADE, 0x99B5, 0x6ADF, 0x99B6, 0x6AE0, 0x99B7, 0x6AE1,\r\n\t0x99B8, 0x6AE2, 0x99B9, 0x6AE3, 0x99BA, 0x6AE4, 0x99BB, 0x6AE5,\t0x99BC, 0x6AE6, 0x99BD, 0x6AE7, 0x99BE, 0x6AE8, 0x99BF, 0x6AE9,\r\n\t0x99C0, 0x6AEA, 0x99C1, 0x6AEB, 0x99C2, 0x6AEC, 0x99C3, 0x6AED,\t0x99C4, 0x6AEE, 0x99C5, 0x6AEF, 0x99C6, 0x6AF0, 0x99C7, 0x6AF1,\r\n\t0x99C8, 0x6AF2, 0x99C9, 0x6AF3, 0x99CA, 0x6AF4, 0x99CB, 0x6AF5,\t0x99CC, 0x6AF6, 0x99CD, 0x6AF7, 0x99CE, 0x6AF8, 0x99CF, 0x6AF9,\r\n\t0x99D0, 0x6AFA, 0x99D1, 0x6AFB, 0x99D2, 0x6AFC, 0x99D3, 0x6AFD,\t0x99D4, 0x6AFE, 0x99D5, 0x6AFF, 0x99D6, 0x6B00, 0x99D7, 0x6B01,\r\n\t0x99D8, 0x6B02, 0x99D9, 0x6B03, 0x99DA, 0x6B04, 0x99DB, 0x6B05,\t0x99DC, 0x6B06, 0x99DD, 0x6B07, 0x99DE, 0x6B08, 0x99DF, 0x6B09,\r\n\t0x99E0, 0x6B0A, 0x99E1, 0x6B0B, 0x99E2, 0x6B0C, 0x99E3, 0x6B0D,\t0x99E4, 0x6B0E, 0x99E5, 0x6B0F, 0x99E6, 0x6B10, 0x99E7, 0x6B11,\r\n\t0x99E8, 0x6B12, 0x99E9, 0x6B13, 0x99EA, 0x6B14, 0x99EB, 0x6B15,\t0x99EC, 0x6B16, 0x99ED, 0x6B17, 0x99EE, 0x6B18, 0x99EF, 0x6B19,\r\n\t0x99F0, 0x6B1A, 0x99F1, 0x6B1B, 0x99F2, 0x6B1C, 0x99F3, 0x6B1D,\t0x99F4, 0x6B1E, 0x99F5, 0x6B1F, 0x99F6, 0x6B25, 0x99F7, 0x6B26,\r\n\t0x99F8, 0x6B28, 0x99F9, 0x6B29, 0x99FA, 0x6B2A, 0x99FB, 0x6B2B,\t0x99FC, 0x6B2C, 0x99FD, 0x6B2D, 0x99FE, 0x6B2E, 0x9A40, 0x6B2F,\r\n\t0x9A41, 0x6B30, 0x9A42, 0x6B31, 0x9A43, 0x6B33, 0x9A44, 0x6B34,\t0x9A45, 0x6B35, 0x9A46, 0x6B36, 0x9A47, 0x6B38, 0x9A48, 0x6B3B,\r\n\t0x9A49, 0x6B3C, 0x9A4A, 0x6B3D, 0x9A4B, 0x6B3F, 0x9A4C, 0x6B40,\t0x9A4D, 0x6B41, 0x9A4E, 0x6B42, 0x9A4F, 0x6B44, 0x9A50, 0x6B45,\r\n\t0x9A51, 0x6B48, 0x9A52, 0x6B4A, 0x9A53, 0x6B4B, 0x9A54, 0x6B4D,\t0x9A55, 0x6B4E, 0x9A56, 0x6B4F, 0x9A57, 0x6B50, 0x9A58, 0x6B51,\r\n\t0x9A59, 0x6B52, 0x9A5A, 0x6B53, 0x9A5B, 0x6B54, 0x9A5C, 0x6B55,\t0x9A5D, 0x6B56, 0x9A5E, 0x6B57, 0x9A5F, 0x6B58, 0x9A60, 0x6B5A,\r\n\t0x9A61, 0x6B5B, 0x9A62, 0x6B5C, 0x9A63, 0x6B5D, 0x9A64, 0x6B5E,\t0x9A65, 0x6B5F, 0x9A66, 0x6B60, 0x9A67, 0x6B61, 0x9A68, 0x6B68,\r\n\t0x9A69, 0x6B69, 0x9A6A, 0x6B6B, 0x9A6B, 0x6B6C, 0x9A6C, 0x6B6D,\t0x9A6D, 0x6B6E, 0x9A6E, 0x6B6F, 0x9A6F, 0x6B70, 0x9A70, 0x6B71,\r\n\t0x9A71, 0x6B72, 0x9A72, 0x6B73, 0x9A73, 0x6B74, 0x9A74, 0x6B75,\t0x9A75, 0x6B76, 0x9A76, 0x6B77, 0x9A77, 0x6B78, 0x9A78, 0x6B7A,\r\n\t0x9A79, 0x6B7D, 0x9A7A, 0x6B7E, 0x9A7B, 0x6B7F, 0x9A7C, 0x6B80,\t0x9A7D, 0x6B85, 0x9A7E, 0x6B88, 0x9A80, 0x6B8C, 0x9A81, 0x6B8E,\r\n\t0x9A82, 0x6B8F, 0x9A83, 0x6B90, 0x9A84, 0x6B91, 0x9A85, 0x6B94,\t0x9A86, 0x6B95, 0x9A87, 0x6B97, 0x9A88, 0x6B98, 0x9A89, 0x6B99,\r\n\t0x9A8A, 0x6B9C, 0x9A8B, 0x6B9D, 0x9A8C, 0x6B9E, 0x9A8D, 0x6B9F,\t0x9A8E, 0x6BA0, 0x9A8F, 0x6BA2, 0x9A90, 0x6BA3, 0x9A91, 0x6BA4,\r\n\t0x9A92, 0x6BA5, 0x9A93, 0x6BA6, 0x9A94, 0x6BA7, 0x9A95, 0x6BA8,\t0x9A96, 0x6BA9, 0x9A97, 0x6BAB, 0x9A98, 0x6BAC, 0x9A99, 0x6BAD,\r\n\t0x9A9A, 0x6BAE, 0x9A9B, 0x6BAF, 0x9A9C, 0x6BB0, 0x9A9D, 0x6BB1,\t0x9A9E, 0x6BB2, 0x9A9F, 0x6BB6, 0x9AA0, 0x6BB8, 0x9AA1, 0x6BB9,\r\n\t0x9AA2, 0x6BBA, 0x9AA3, 0x6BBB, 0x9AA4, 0x6BBC, 0x9AA5, 0x6BBD,\t0x9AA6, 0x6BBE, 0x9AA7, 0x6BC0, 0x9AA8, 0x6BC3, 0x9AA9, 0x6BC4,\r\n\t0x9AAA, 0x6BC6, 0x9AAB, 0x6BC7, 0x9AAC, 0x6BC8, 0x9AAD, 0x6BC9,\t0x9AAE, 0x6BCA, 0x9AAF, 0x6BCC, 0x9AB0, 0x6BCE, 0x9AB1, 0x6BD0,\r\n\t0x9AB2, 0x6BD1, 0x9AB3, 0x6BD8, 0x9AB4, 0x6BDA, 0x9AB5, 0x6BDC,\t0x9AB6, 0x6BDD, 0x9AB7, 0x6BDE, 0x9AB8, 0x6BDF, 0x9AB9, 0x6BE0,\r\n\t0x9ABA, 0x6BE2, 0x9ABB, 0x6BE3, 0x9ABC, 0x6BE4, 0x9ABD, 0x6BE5,\t0x9ABE, 0x6BE6, 0x9ABF, 0x6BE7, 0x9AC0, 0x6BE8, 0x9AC1, 0x6BE9,\r\n\t0x9AC2, 0x6BEC, 0x9AC3, 0x6BED, 0x9AC4, 0x6BEE, 0x9AC5, 0x6BF0,\t0x9AC6, 0x6BF1, 0x9AC7, 0x6BF2, 0x9AC8, 0x6BF4, 0x9AC9, 0x6BF6,\r\n\t0x9ACA, 0x6BF7, 0x9ACB, 0x6BF8, 0x9ACC, 0x6BFA, 0x9ACD, 0x6BFB,\t0x9ACE, 0x6BFC, 0x9ACF, 0x6BFE, 0x9AD0, 0x6BFF, 0x9AD1, 0x6C00,\r\n\t0x9AD2, 0x6C01, 0x9AD3, 0x6C02, 0x9AD4, 0x6C03, 0x9AD5, 0x6C04,\t0x9AD6, 0x6C08, 0x9AD7, 0x6C09, 0x9AD8, 0x6C0A, 0x9AD9, 0x6C0B,\r\n\t0x9ADA, 0x6C0C, 0x9ADB, 0x6C0E, 0x9ADC, 0x6C12, 0x9ADD, 0x6C17,\t0x9ADE, 0x6C1C, 0x9ADF, 0x6C1D, 0x9AE0, 0x6C1E, 0x9AE1, 0x6C20,\r\n\t0x9AE2, 0x6C23, 0x9AE3, 0x6C25, 0x9AE4, 0x6C2B, 0x9AE5, 0x6C2C,\t0x9AE6, 0x6C2D, 0x9AE7, 0x6C31, 0x9AE8, 0x6C33, 0x9AE9, 0x6C36,\r\n\t0x9AEA, 0x6C37, 0x9AEB, 0x6C39, 0x9AEC, 0x6C3A, 0x9AED, 0x6C3B,\t0x9AEE, 0x6C3C, 0x9AEF, 0x6C3E, 0x9AF0, 0x6C3F, 0x9AF1, 0x6C43,\r\n\t0x9AF2, 0x6C44, 0x9AF3, 0x6C45, 0x9AF4, 0x6C48, 0x9AF5, 0x6C4B,\t0x9AF6, 0x6C4C, 0x9AF7, 0x6C4D, 0x9AF8, 0x6C4E, 0x9AF9, 0x6C4F,\r\n\t0x9AFA, 0x6C51, 0x9AFB, 0x6C52, 0x9AFC, 0x6C53, 0x9AFD, 0x6C56,\t0x9AFE, 0x6C58, 0x9B40, 0x6C59, 0x9B41, 0x6C5A, 0x9B42, 0x6C62,\r\n\t0x9B43, 0x6C63, 0x9B44, 0x6C65, 0x9B45, 0x6C66, 0x9B46, 0x6C67,\t0x9B47, 0x6C6B, 0x9B48, 0x6C6C, 0x9B49, 0x6C6D, 0x9B4A, 0x6C6E,\r\n\t0x9B4B, 0x6C6F, 0x9B4C, 0x6C71, 0x9B4D, 0x6C73, 0x9B4E, 0x6C75,\t0x9B4F, 0x6C77, 0x9B50, 0x6C78, 0x9B51, 0x6C7A, 0x9B52, 0x6C7B,\r\n\t0x9B53, 0x6C7C, 0x9B54, 0x6C7F, 0x9B55, 0x6C80, 0x9B56, 0x6C84,\t0x9B57, 0x6C87, 0x9B58, 0x6C8A, 0x9B59, 0x6C8B, 0x9B5A, 0x6C8D,\r\n\t0x9B5B, 0x6C8E, 0x9B5C, 0x6C91, 0x9B5D, 0x6C92, 0x9B5E, 0x6C95,\t0x9B5F, 0x6C96, 0x9B60, 0x6C97, 0x9B61, 0x6C98, 0x9B62, 0x6C9A,\r\n\t0x9B63, 0x6C9C, 0x9B64, 0x6C9D, 0x9B65, 0x6C9E, 0x9B66, 0x6CA0,\t0x9B67, 0x6CA2, 0x9B68, 0x6CA8, 0x9B69, 0x6CAC, 0x9B6A, 0x6CAF,\r\n\t0x9B6B, 0x6CB0, 0x9B6C, 0x6CB4, 0x9B6D, 0x6CB5, 0x9B6E, 0x6CB6,\t0x9B6F, 0x6CB7, 0x9B70, 0x6CBA, 0x9B71, 0x6CC0, 0x9B72, 0x6CC1,\r\n\t0x9B73, 0x6CC2, 0x9B74, 0x6CC3, 0x9B75, 0x6CC6, 0x9B76, 0x6CC7,\t0x9B77, 0x6CC8, 0x9B78, 0x6CCB, 0x9B79, 0x6CCD, 0x9B7A, 0x6CCE,\r\n\t0x9B7B, 0x6CCF, 0x9B7C, 0x6CD1, 0x9B7D, 0x6CD2, 0x9B7E, 0x6CD8,\t0x9B80, 0x6CD9, 0x9B81, 0x6CDA, 0x9B82, 0x6CDC, 0x9B83, 0x6CDD,\r\n\t0x9B84, 0x6CDF, 0x9B85, 0x6CE4, 0x9B86, 0x6CE6, 0x9B87, 0x6CE7,\t0x9B88, 0x6CE9, 0x9B89, 0x6CEC, 0x9B8A, 0x6CED, 0x9B8B, 0x6CF2,\r\n\t0x9B8C, 0x6CF4, 0x9B8D, 0x6CF9, 0x9B8E, 0x6CFF, 0x9B8F, 0x6D00,\t0x9B90, 0x6D02, 0x9B91, 0x6D03, 0x9B92, 0x6D05, 0x9B93, 0x6D06,\r\n\t0x9B94, 0x6D08, 0x9B95, 0x6D09, 0x9B96, 0x6D0A, 0x9B97, 0x6D0D,\t0x9B98, 0x6D0F, 0x9B99, 0x6D10, 0x9B9A, 0x6D11, 0x9B9B, 0x6D13,\r\n\t0x9B9C, 0x6D14, 0x9B9D, 0x6D15, 0x9B9E, 0x6D16, 0x9B9F, 0x6D18,\t0x9BA0, 0x6D1C, 0x9BA1, 0x6D1D, 0x9BA2, 0x6D1F, 0x9BA3, 0x6D20,\r\n\t0x9BA4, 0x6D21, 0x9BA5, 0x6D22, 0x9BA6, 0x6D23, 0x9BA7, 0x6D24,\t0x9BA8, 0x6D26, 0x9BA9, 0x6D28, 0x9BAA, 0x6D29, 0x9BAB, 0x6D2C,\r\n\t0x9BAC, 0x6D2D, 0x9BAD, 0x6D2F, 0x9BAE, 0x6D30, 0x9BAF, 0x6D34,\t0x9BB0, 0x6D36, 0x9BB1, 0x6D37, 0x9BB2, 0x6D38, 0x9BB3, 0x6D3A,\r\n\t0x9BB4, 0x6D3F, 0x9BB5, 0x6D40, 0x9BB6, 0x6D42, 0x9BB7, 0x6D44,\t0x9BB8, 0x6D49, 0x9BB9, 0x6D4C, 0x9BBA, 0x6D50, 0x9BBB, 0x6D55,\r\n\t0x9BBC, 0x6D56, 0x9BBD, 0x6D57, 0x9BBE, 0x6D58, 0x9BBF, 0x6D5B,\t0x9BC0, 0x6D5D, 0x9BC1, 0x6D5F, 0x9BC2, 0x6D61, 0x9BC3, 0x6D62,\r\n\t0x9BC4, 0x6D64, 0x9BC5, 0x6D65, 0x9BC6, 0x6D67, 0x9BC7, 0x6D68,\t0x9BC8, 0x6D6B, 0x9BC9, 0x6D6C, 0x9BCA, 0x6D6D, 0x9BCB, 0x6D70,\r\n\t0x9BCC, 0x6D71, 0x9BCD, 0x6D72, 0x9BCE, 0x6D73, 0x9BCF, 0x6D75,\t0x9BD0, 0x6D76, 0x9BD1, 0x6D79, 0x9BD2, 0x6D7A, 0x9BD3, 0x6D7B,\r\n\t0x9BD4, 0x6D7D, 0x9BD5, 0x6D7E, 0x9BD6, 0x6D7F, 0x9BD7, 0x6D80,\t0x9BD8, 0x6D81, 0x9BD9, 0x6D83, 0x9BDA, 0x6D84, 0x9BDB, 0x6D86,\r\n\t0x9BDC, 0x6D87, 0x9BDD, 0x6D8A, 0x9BDE, 0x6D8B, 0x9BDF, 0x6D8D,\t0x9BE0, 0x6D8F, 0x9BE1, 0x6D90, 0x9BE2, 0x6D92, 0x9BE3, 0x6D96,\r\n\t0x9BE4, 0x6D97, 0x9BE5, 0x6D98, 0x9BE6, 0x6D99, 0x9BE7, 0x6D9A,\t0x9BE8, 0x6D9C, 0x9BE9, 0x6DA2, 0x9BEA, 0x6DA5, 0x9BEB, 0x6DAC,\r\n\t0x9BEC, 0x6DAD, 0x9BED, 0x6DB0, 0x9BEE, 0x6DB1, 0x9BEF, 0x6DB3,\t0x9BF0, 0x6DB4, 0x9BF1, 0x6DB6, 0x9BF2, 0x6DB7, 0x9BF3, 0x6DB9,\r\n\t0x9BF4, 0x6DBA, 0x9BF5, 0x6DBB, 0x9BF6, 0x6DBC, 0x9BF7, 0x6DBD,\t0x9BF8, 0x6DBE, 0x9BF9, 0x6DC1, 0x9BFA, 0x6DC2, 0x9BFB, 0x6DC3,\r\n\t0x9BFC, 0x6DC8, 0x9BFD, 0x6DC9, 0x9BFE, 0x6DCA, 0x9C40, 0x6DCD,\t0x9C41, 0x6DCE, 0x9C42, 0x6DCF, 0x9C43, 0x6DD0, 0x9C44, 0x6DD2,\r\n\t0x9C45, 0x6DD3, 0x9C46, 0x6DD4, 0x9C47, 0x6DD5, 0x9C48, 0x6DD7,\t0x9C49, 0x6DDA, 0x9C4A, 0x6DDB, 0x9C4B, 0x6DDC, 0x9C4C, 0x6DDF,\r\n\t0x9C4D, 0x6DE2, 0x9C4E, 0x6DE3, 0x9C4F, 0x6DE5, 0x9C50, 0x6DE7,\t0x9C51, 0x6DE8, 0x9C52, 0x6DE9, 0x9C53, 0x6DEA, 0x9C54, 0x6DED,\r\n\t0x9C55, 0x6DEF, 0x9C56, 0x6DF0, 0x9C57, 0x6DF2, 0x9C58, 0x6DF4,\t0x9C59, 0x6DF5, 0x9C5A, 0x6DF6, 0x9C5B, 0x6DF8, 0x9C5C, 0x6DFA,\r\n\t0x9C5D, 0x6DFD, 0x9C5E, 0x6DFE, 0x9C5F, 0x6DFF, 0x9C60, 0x6E00,\t0x9C61, 0x6E01, 0x9C62, 0x6E02, 0x9C63, 0x6E03, 0x9C64, 0x6E04,\r\n\t0x9C65, 0x6E06, 0x9C66, 0x6E07, 0x9C67, 0x6E08, 0x9C68, 0x6E09,\t0x9C69, 0x6E0B, 0x9C6A, 0x6E0F, 0x9C6B, 0x6E12, 0x9C6C, 0x6E13,\r\n\t0x9C6D, 0x6E15, 0x9C6E, 0x6E18, 0x9C6F, 0x6E19, 0x9C70, 0x6E1B,\t0x9C71, 0x6E1C, 0x9C72, 0x6E1E, 0x9C73, 0x6E1F, 0x9C74, 0x6E22,\r\n\t0x9C75, 0x6E26, 0x9C76, 0x6E27, 0x9C77, 0x6E28, 0x9C78, 0x6E2A,\t0x9C79, 0x6E2C, 0x9C7A, 0x6E2E, 0x9C7B, 0x6E30, 0x9C7C, 0x6E31,\r\n\t0x9C7D, 0x6E33, 0x9C7E, 0x6E35, 0x9C80, 0x6E36, 0x9C81, 0x6E37,\t0x9C82, 0x6E39, 0x9C83, 0x6E3B, 0x9C84, 0x6E3C, 0x9C85, 0x6E3D,\r\n\t0x9C86, 0x6E3E, 0x9C87, 0x6E3F, 0x9C88, 0x6E40, 0x9C89, 0x6E41,\t0x9C8A, 0x6E42, 0x9C8B, 0x6E45, 0x9C8C, 0x6E46, 0x9C8D, 0x6E47,\r\n\t0x9C8E, 0x6E48, 0x9C8F, 0x6E49, 0x9C90, 0x6E4A, 0x9C91, 0x6E4B,\t0x9C92, 0x6E4C, 0x9C93, 0x6E4F, 0x9C94, 0x6E50, 0x9C95, 0x6E51,\r\n\t0x9C96, 0x6E52, 0x9C97, 0x6E55, 0x9C98, 0x6E57, 0x9C99, 0x6E59,\t0x9C9A, 0x6E5A, 0x9C9B, 0x6E5C, 0x9C9C, 0x6E5D, 0x9C9D, 0x6E5E,\r\n\t0x9C9E, 0x6E60, 0x9C9F, 0x6E61, 0x9CA0, 0x6E62, 0x9CA1, 0x6E63,\t0x9CA2, 0x6E64, 0x9CA3, 0x6E65, 0x9CA4, 0x6E66, 0x9CA5, 0x6E67,\r\n\t0x9CA6, 0x6E68, 0x9CA7, 0x6E69, 0x9CA8, 0x6E6A, 0x9CA9, 0x6E6C,\t0x9CAA, 0x6E6D, 0x9CAB, 0x6E6F, 0x9CAC, 0x6E70, 0x9CAD, 0x6E71,\r\n\t0x9CAE, 0x6E72, 0x9CAF, 0x6E73, 0x9CB0, 0x6E74, 0x9CB1, 0x6E75,\t0x9CB2, 0x6E76, 0x9CB3, 0x6E77, 0x9CB4, 0x6E78, 0x9CB5, 0x6E79,\r\n\t0x9CB6, 0x6E7A, 0x9CB7, 0x6E7B, 0x9CB8, 0x6E7C, 0x9CB9, 0x6E7D,\t0x9CBA, 0x6E80, 0x9CBB, 0x6E81, 0x9CBC, 0x6E82, 0x9CBD, 0x6E84,\r\n\t0x9CBE, 0x6E87, 0x9CBF, 0x6E88, 0x9CC0, 0x6E8A, 0x9CC1, 0x6E8B,\t0x9CC2, 0x6E8C, 0x9CC3, 0x6E8D, 0x9CC4, 0x6E8E, 0x9CC5, 0x6E91,\r\n\t0x9CC6, 0x6E92, 0x9CC7, 0x6E93, 0x9CC8, 0x6E94, 0x9CC9, 0x6E95,\t0x9CCA, 0x6E96, 0x9CCB, 0x6E97, 0x9CCC, 0x6E99, 0x9CCD, 0x6E9A,\r\n\t0x9CCE, 0x6E9B, 0x9CCF, 0x6E9D, 0x9CD0, 0x6E9E, 0x9CD1, 0x6EA0,\t0x9CD2, 0x6EA1, 0x9CD3, 0x6EA3, 0x9CD4, 0x6EA4, 0x9CD5, 0x6EA6,\r\n\t0x9CD6, 0x6EA8, 0x9CD7, 0x6EA9, 0x9CD8, 0x6EAB, 0x9CD9, 0x6EAC,\t0x9CDA, 0x6EAD, 0x9CDB, 0x6EAE, 0x9CDC, 0x6EB0, 0x9CDD, 0x6EB3,\r\n\t0x9CDE, 0x6EB5, 0x9CDF, 0x6EB8, 0x9CE0, 0x6EB9, 0x9CE1, 0x6EBC,\t0x9CE2, 0x6EBE, 0x9CE3, 0x6EBF, 0x9CE4, 0x6EC0, 0x9CE5, 0x6EC3,\r\n\t0x9CE6, 0x6EC4, 0x9CE7, 0x6EC5, 0x9CE8, 0x6EC6, 0x9CE9, 0x6EC8,\t0x9CEA, 0x6EC9, 0x9CEB, 0x6ECA, 0x9CEC, 0x6ECC, 0x9CED, 0x6ECD,\r\n\t0x9CEE, 0x6ECE, 0x9CEF, 0x6ED0, 0x9CF0, 0x6ED2, 0x9CF1, 0x6ED6,\t0x9CF2, 0x6ED8, 0x9CF3, 0x6ED9, 0x9CF4, 0x6EDB, 0x9CF5, 0x6EDC,\r\n\t0x9CF6, 0x6EDD, 0x9CF7, 0x6EE3, 0x9CF8, 0x6EE7, 0x9CF9, 0x6EEA,\t0x9CFA, 0x6EEB, 0x9CFB, 0x6EEC, 0x9CFC, 0x6EED, 0x9CFD, 0x6EEE,\r\n\t0x9CFE, 0x6EEF, 0x9D40, 0x6EF0, 0x9D41, 0x6EF1, 0x9D42, 0x6EF2,\t0x9D43, 0x6EF3, 0x9D44, 0x6EF5, 0x9D45, 0x6EF6, 0x9D46, 0x6EF7,\r\n\t0x9D47, 0x6EF8, 0x9D48, 0x6EFA, 0x9D49, 0x6EFB, 0x9D4A, 0x6EFC,\t0x9D4B, 0x6EFD, 0x9D4C, 0x6EFE, 0x9D4D, 0x6EFF, 0x9D4E, 0x6F00,\r\n\t0x9D4F, 0x6F01, 0x9D50, 0x6F03, 0x9D51, 0x6F04, 0x9D52, 0x6F05,\t0x9D53, 0x6F07, 0x9D54, 0x6F08, 0x9D55, 0x6F0A, 0x9D56, 0x6F0B,\r\n\t0x9D57, 0x6F0C, 0x9D58, 0x6F0D, 0x9D59, 0x6F0E, 0x9D5A, 0x6F10,\t0x9D5B, 0x6F11, 0x9D5C, 0x6F12, 0x9D5D, 0x6F16, 0x9D5E, 0x6F17,\r\n\t0x9D5F, 0x6F18, 0x9D60, 0x6F19, 0x9D61, 0x6F1A, 0x9D62, 0x6F1B,\t0x9D63, 0x6F1C, 0x9D64, 0x6F1D, 0x9D65, 0x6F1E, 0x9D66, 0x6F1F,\r\n\t0x9D67, 0x6F21, 0x9D68, 0x6F22, 0x9D69, 0x6F23, 0x9D6A, 0x6F25,\t0x9D6B, 0x6F26, 0x9D6C, 0x6F27, 0x9D6D, 0x6F28, 0x9D6E, 0x6F2C,\r\n\t0x9D6F, 0x6F2E, 0x9D70, 0x6F30, 0x9D71, 0x6F32, 0x9D72, 0x6F34,\t0x9D73, 0x6F35, 0x9D74, 0x6F37, 0x9D75, 0x6F38, 0x9D76, 0x6F39,\r\n\t0x9D77, 0x6F3A, 0x9D78, 0x6F3B, 0x9D79, 0x6F3C, 0x9D7A, 0x6F3D,\t0x9D7B, 0x6F3F, 0x9D7C, 0x6F40, 0x9D7D, 0x6F41, 0x9D7E, 0x6F42,\r\n\t0x9D80, 0x6F43, 0x9D81, 0x6F44, 0x9D82, 0x6F45, 0x9D83, 0x6F48,\t0x9D84, 0x6F49, 0x9D85, 0x6F4A, 0x9D86, 0x6F4C, 0x9D87, 0x6F4E,\r\n\t0x9D88, 0x6F4F, 0x9D89, 0x6F50, 0x9D8A, 0x6F51, 0x9D8B, 0x6F52,\t0x9D8C, 0x6F53, 0x9D8D, 0x6F54, 0x9D8E, 0x6F55, 0x9D8F, 0x6F56,\r\n\t0x9D90, 0x6F57, 0x9D91, 0x6F59, 0x9D92, 0x6F5A, 0x9D93, 0x6F5B,\t0x9D94, 0x6F5D, 0x9D95, 0x6F5F, 0x9D96, 0x6F60, 0x9D97, 0x6F61,\r\n\t0x9D98, 0x6F63, 0x9D99, 0x6F64, 0x9D9A, 0x6F65, 0x9D9B, 0x6F67,\t0x9D9C, 0x6F68, 0x9D9D, 0x6F69, 0x9D9E, 0x6F6A, 0x9D9F, 0x6F6B,\r\n\t0x9DA0, 0x6F6C, 0x9DA1, 0x6F6F, 0x9DA2, 0x6F70, 0x9DA3, 0x6F71,\t0x9DA4, 0x6F73, 0x9DA5, 0x6F75, 0x9DA6, 0x6F76, 0x9DA7, 0x6F77,\r\n\t0x9DA8, 0x6F79, 0x9DA9, 0x6F7B, 0x9DAA, 0x6F7D, 0x9DAB, 0x6F7E,\t0x9DAC, 0x6F7F, 0x9DAD, 0x6F80, 0x9DAE, 0x6F81, 0x9DAF, 0x6F82,\r\n\t0x9DB0, 0x6F83, 0x9DB1, 0x6F85, 0x9DB2, 0x6F86, 0x9DB3, 0x6F87,\t0x9DB4, 0x6F8A, 0x9DB5, 0x6F8B, 0x9DB6, 0x6F8F, 0x9DB7, 0x6F90,\r\n\t0x9DB8, 0x6F91, 0x9DB9, 0x6F92, 0x9DBA, 0x6F93, 0x9DBB, 0x6F94,\t0x9DBC, 0x6F95, 0x9DBD, 0x6F96, 0x9DBE, 0x6F97, 0x9DBF, 0x6F98,\r\n\t0x9DC0, 0x6F99, 0x9DC1, 0x6F9A, 0x9DC2, 0x6F9B, 0x9DC3, 0x6F9D,\t0x9DC4, 0x6F9E, 0x9DC5, 0x6F9F, 0x9DC6, 0x6FA0, 0x9DC7, 0x6FA2,\r\n\t0x9DC8, 0x6FA3, 0x9DC9, 0x6FA4, 0x9DCA, 0x6FA5, 0x9DCB, 0x6FA6,\t0x9DCC, 0x6FA8, 0x9DCD, 0x6FA9, 0x9DCE, 0x6FAA, 0x9DCF, 0x6FAB,\r\n\t0x9DD0, 0x6FAC, 0x9DD1, 0x6FAD, 0x9DD2, 0x6FAE, 0x9DD3, 0x6FAF,\t0x9DD4, 0x6FB0, 0x9DD5, 0x6FB1, 0x9DD6, 0x6FB2, 0x9DD7, 0x6FB4,\r\n\t0x9DD8, 0x6FB5, 0x9DD9, 0x6FB7, 0x9DDA, 0x6FB8, 0x9DDB, 0x6FBA,\t0x9DDC, 0x6FBB, 0x9DDD, 0x6FBC, 0x9DDE, 0x6FBD, 0x9DDF, 0x6FBE,\r\n\t0x9DE0, 0x6FBF, 0x9DE1, 0x6FC1, 0x9DE2, 0x6FC3, 0x9DE3, 0x6FC4,\t0x9DE4, 0x6FC5, 0x9DE5, 0x6FC6, 0x9DE6, 0x6FC7, 0x9DE7, 0x6FC8,\r\n\t0x9DE8, 0x6FCA, 0x9DE9, 0x6FCB, 0x9DEA, 0x6FCC, 0x9DEB, 0x6FCD,\t0x9DEC, 0x6FCE, 0x9DED, 0x6FCF, 0x9DEE, 0x6FD0, 0x9DEF, 0x6FD3,\r\n\t0x9DF0, 0x6FD4, 0x9DF1, 0x6FD5, 0x9DF2, 0x6FD6, 0x9DF3, 0x6FD7,\t0x9DF4, 0x6FD8, 0x9DF5, 0x6FD9, 0x9DF6, 0x6FDA, 0x9DF7, 0x6FDB,\r\n\t0x9DF8, 0x6FDC, 0x9DF9, 0x6FDD, 0x9DFA, 0x6FDF, 0x9DFB, 0x6FE2,\t0x9DFC, 0x6FE3, 0x9DFD, 0x6FE4, 0x9DFE, 0x6FE5, 0x9E40, 0x6FE6,\r\n\t0x9E41, 0x6FE7, 0x9E42, 0x6FE8, 0x9E43, 0x6FE9, 0x9E44, 0x6FEA,\t0x9E45, 0x6FEB, 0x9E46, 0x6FEC, 0x9E47, 0x6FED, 0x9E48, 0x6FF0,\r\n\t0x9E49, 0x6FF1, 0x9E4A, 0x6FF2, 0x9E4B, 0x6FF3, 0x9E4C, 0x6FF4,\t0x9E4D, 0x6FF5, 0x9E4E, 0x6FF6, 0x9E4F, 0x6FF7, 0x9E50, 0x6FF8,\r\n\t0x9E51, 0x6FF9, 0x9E52, 0x6FFA, 0x9E53, 0x6FFB, 0x9E54, 0x6FFC,\t0x9E55, 0x6FFD, 0x9E56, 0x6FFE, 0x9E57, 0x6FFF, 0x9E58, 0x7000,\r\n\t0x9E59, 0x7001, 0x9E5A, 0x7002, 0x9E5B, 0x7003, 0x9E5C, 0x7004,\t0x9E5D, 0x7005, 0x9E5E, 0x7006, 0x9E5F, 0x7007, 0x9E60, 0x7008,\r\n\t0x9E61, 0x7009, 0x9E62, 0x700A, 0x9E63, 0x700B, 0x9E64, 0x700C,\t0x9E65, 0x700D, 0x9E66, 0x700E, 0x9E67, 0x700F, 0x9E68, 0x7010,\r\n\t0x9E69, 0x7012, 0x9E6A, 0x7013, 0x9E6B, 0x7014, 0x9E6C, 0x7015,\t0x9E6D, 0x7016, 0x9E6E, 0x7017, 0x9E6F, 0x7018, 0x9E70, 0x7019,\r\n\t0x9E71, 0x701C, 0x9E72, 0x701D, 0x9E73, 0x701E, 0x9E74, 0x701F,\t0x9E75, 0x7020, 0x9E76, 0x7021, 0x9E77, 0x7022, 0x9E78, 0x7024,\r\n\t0x9E79, 0x7025, 0x9E7A, 0x7026, 0x9E7B, 0x7027, 0x9E7C, 0x7028,\t0x9E7D, 0x7029, 0x9E7E, 0x702A, 0x9E80, 0x702B, 0x9E81, 0x702C,\r\n\t0x9E82, 0x702D, 0x9E83, 0x702E, 0x9E84, 0x702F, 0x9E85, 0x7030,\t0x9E86, 0x7031, 0x9E87, 0x7032, 0x9E88, 0x7033, 0x9E89, 0x7034,\r\n\t0x9E8A, 0x7036, 0x9E8B, 0x7037, 0x9E8C, 0x7038, 0x9E8D, 0x703A,\t0x9E8E, 0x703B, 0x9E8F, 0x703C, 0x9E90, 0x703D, 0x9E91, 0x703E,\r\n\t0x9E92, 0x703F, 0x9E93, 0x7040, 0x9E94, 0x7041, 0x9E95, 0x7042,\t0x9E96, 0x7043, 0x9E97, 0x7044, 0x9E98, 0x7045, 0x9E99, 0x7046,\r\n\t0x9E9A, 0x7047, 0x9E9B, 0x7048, 0x9E9C, 0x7049, 0x9E9D, 0x704A,\t0x9E9E, 0x704B, 0x9E9F, 0x704D, 0x9EA0, 0x704E, 0x9EA1, 0x7050,\r\n\t0x9EA2, 0x7051, 0x9EA3, 0x7052, 0x9EA4, 0x7053, 0x9EA5, 0x7054,\t0x9EA6, 0x7055, 0x9EA7, 0x7056, 0x9EA8, 0x7057, 0x9EA9, 0x7058,\r\n\t0x9EAA, 0x7059, 0x9EAB, 0x705A, 0x9EAC, 0x705B, 0x9EAD, 0x705C,\t0x9EAE, 0x705D, 0x9EAF, 0x705F, 0x9EB0, 0x7060, 0x9EB1, 0x7061,\r\n\t0x9EB2, 0x7062, 0x9EB3, 0x7063, 0x9EB4, 0x7064, 0x9EB5, 0x7065,\t0x9EB6, 0x7066, 0x9EB7, 0x7067, 0x9EB8, 0x7068, 0x9EB9, 0x7069,\r\n\t0x9EBA, 0x706A, 0x9EBB, 0x706E, 0x9EBC, 0x7071, 0x9EBD, 0x7072,\t0x9EBE, 0x7073, 0x9EBF, 0x7074, 0x9EC0, 0x7077, 0x9EC1, 0x7079,\r\n\t0x9EC2, 0x707A, 0x9EC3, 0x707B, 0x9EC4, 0x707D, 0x9EC5, 0x7081,\t0x9EC6, 0x7082, 0x9EC7, 0x7083, 0x9EC8, 0x7084, 0x9EC9, 0x7086,\r\n\t0x9ECA, 0x7087, 0x9ECB, 0x7088, 0x9ECC, 0x708B, 0x9ECD, 0x708C,\t0x9ECE, 0x708D, 0x9ECF, 0x708F, 0x9ED0, 0x7090, 0x9ED1, 0x7091,\r\n\t0x9ED2, 0x7093, 0x9ED3, 0x7097, 0x9ED4, 0x7098, 0x9ED5, 0x709A,\t0x9ED6, 0x709B, 0x9ED7, 0x709E, 0x9ED8, 0x709F, 0x9ED9, 0x70A0,\r\n\t0x9EDA, 0x70A1, 0x9EDB, 0x70A2, 0x9EDC, 0x70A3, 0x9EDD, 0x70A4,\t0x9EDE, 0x70A5, 0x9EDF, 0x70A6, 0x9EE0, 0x70A7, 0x9EE1, 0x70A8,\r\n\t0x9EE2, 0x70A9, 0x9EE3, 0x70AA, 0x9EE4, 0x70B0, 0x9EE5, 0x70B2,\t0x9EE6, 0x70B4, 0x9EE7, 0x70B5, 0x9EE8, 0x70B6, 0x9EE9, 0x70BA,\r\n\t0x9EEA, 0x70BE, 0x9EEB, 0x70BF, 0x9EEC, 0x70C4, 0x9EED, 0x70C5,\t0x9EEE, 0x70C6, 0x9EEF, 0x70C7, 0x9EF0, 0x70C9, 0x9EF1, 0x70CB,\r\n\t0x9EF2, 0x70CC, 0x9EF3, 0x70CD, 0x9EF4, 0x70CE, 0x9EF5, 0x70CF,\t0x9EF6, 0x70D0, 0x9EF7, 0x70D1, 0x9EF8, 0x70D2, 0x9EF9, 0x70D3,\r\n\t0x9EFA, 0x70D4, 0x9EFB, 0x70D5, 0x9EFC, 0x70D6, 0x9EFD, 0x70D7,\t0x9EFE, 0x70DA, 0x9F40, 0x70DC, 0x9F41, 0x70DD, 0x9F42, 0x70DE,\r\n\t0x9F43, 0x70E0, 0x9F44, 0x70E1, 0x9F45, 0x70E2, 0x9F46, 0x70E3,\t0x9F47, 0x70E5, 0x9F48, 0x70EA, 0x9F49, 0x70EE, 0x9F4A, 0x70F0,\r\n\t0x9F4B, 0x70F1, 0x9F4C, 0x70F2, 0x9F4D, 0x70F3, 0x9F4E, 0x70F4,\t0x9F4F, 0x70F5, 0x9F50, 0x70F6, 0x9F51, 0x70F8, 0x9F52, 0x70FA,\r\n\t0x9F53, 0x70FB, 0x9F54, 0x70FC, 0x9F55, 0x70FE, 0x9F56, 0x70FF,\t0x9F57, 0x7100, 0x9F58, 0x7101, 0x9F59, 0x7102, 0x9F5A, 0x7103,\r\n\t0x9F5B, 0x7104, 0x9F5C, 0x7105, 0x9F5D, 0x7106, 0x9F5E, 0x7107,\t0x9F5F, 0x7108, 0x9F60, 0x710B, 0x9F61, 0x710C, 0x9F62, 0x710D,\r\n\t0x9F63, 0x710E, 0x9F64, 0x710F, 0x9F65, 0x7111, 0x9F66, 0x7112,\t0x9F67, 0x7114, 0x9F68, 0x7117, 0x9F69, 0x711B, 0x9F6A, 0x711C,\r\n\t0x9F6B, 0x711D, 0x9F6C, 0x711E, 0x9F6D, 0x711F, 0x9F6E, 0x7120,\t0x9F6F, 0x7121, 0x9F70, 0x7122, 0x9F71, 0x7123, 0x9F72, 0x7124,\r\n\t0x9F73, 0x7125, 0x9F74, 0x7127, 0x9F75, 0x7128, 0x9F76, 0x7129,\t0x9F77, 0x712A, 0x9F78, 0x712B, 0x9F79, 0x712C, 0x9F7A, 0x712D,\r\n\t0x9F7B, 0x712E, 0x9F7C, 0x7132, 0x9F7D, 0x7133, 0x9F7E, 0x7134,\t0x9F80, 0x7135, 0x9F81, 0x7137, 0x9F82, 0x7138, 0x9F83, 0x7139,\r\n\t0x9F84, 0x713A, 0x9F85, 0x713B, 0x9F86, 0x713C, 0x9F87, 0x713D,\t0x9F88, 0x713E, 0x9F89, 0x713F, 0x9F8A, 0x7140, 0x9F8B, 0x7141,\r\n\t0x9F8C, 0x7142, 0x9F8D, 0x7143, 0x9F8E, 0x7144, 0x9F8F, 0x7146,\t0x9F90, 0x7147, 0x9F91, 0x7148, 0x9F92, 0x7149, 0x9F93, 0x714B,\r\n\t0x9F94, 0x714D, 0x9F95, 0x714F, 0x9F96, 0x7150, 0x9F97, 0x7151,\t0x9F98, 0x7152, 0x9F99, 0x7153, 0x9F9A, 0x7154, 0x9F9B, 0x7155,\r\n\t0x9F9C, 0x7156, 0x9F9D, 0x7157, 0x9F9E, 0x7158, 0x9F9F, 0x7159,\t0x9FA0, 0x715A, 0x9FA1, 0x715B, 0x9FA2, 0x715D, 0x9FA3, 0x715F,\r\n\t0x9FA4, 0x7160, 0x9FA5, 0x7161, 0x9FA6, 0x7162, 0x9FA7, 0x7163,\t0x9FA8, 0x7165, 0x9FA9, 0x7169, 0x9FAA, 0x716A, 0x9FAB, 0x716B,\r\n\t0x9FAC, 0x716C, 0x9FAD, 0x716D, 0x9FAE, 0x716F, 0x9FAF, 0x7170,\t0x9FB0, 0x7171, 0x9FB1, 0x7174, 0x9FB2, 0x7175, 0x9FB3, 0x7176,\r\n\t0x9FB4, 0x7177, 0x9FB5, 0x7179, 0x9FB6, 0x717B, 0x9FB7, 0x717C,\t0x9FB8, 0x717E, 0x9FB9, 0x717F, 0x9FBA, 0x7180, 0x9FBB, 0x7181,\r\n\t0x9FBC, 0x7182, 0x9FBD, 0x7183, 0x9FBE, 0x7185, 0x9FBF, 0x7186,\t0x9FC0, 0x7187, 0x9FC1, 0x7188, 0x9FC2, 0x7189, 0x9FC3, 0x718B,\r\n\t0x9FC4, 0x718C, 0x9FC5, 0x718D, 0x9FC6, 0x718E, 0x9FC7, 0x7190,\t0x9FC8, 0x7191, 0x9FC9, 0x7192, 0x9FCA, 0x7193, 0x9FCB, 0x7195,\r\n\t0x9FCC, 0x7196, 0x9FCD, 0x7197, 0x9FCE, 0x719A, 0x9FCF, 0x719B,\t0x9FD0, 0x719C, 0x9FD1, 0x719D, 0x9FD2, 0x719E, 0x9FD3, 0x71A1,\r\n\t0x9FD4, 0x71A2, 0x9FD5, 0x71A3, 0x9FD6, 0x71A4, 0x9FD7, 0x71A5,\t0x9FD8, 0x71A6, 0x9FD9, 0x71A7, 0x9FDA, 0x71A9, 0x9FDB, 0x71AA,\r\n\t0x9FDC, 0x71AB, 0x9FDD, 0x71AD, 0x9FDE, 0x71AE, 0x9FDF, 0x71AF,\t0x9FE0, 0x71B0, 0x9FE1, 0x71B1, 0x9FE2, 0x71B2, 0x9FE3, 0x71B4,\r\n\t0x9FE4, 0x71B6, 0x9FE5, 0x71B7, 0x9FE6, 0x71B8, 0x9FE7, 0x71BA,\t0x9FE8, 0x71BB, 0x9FE9, 0x71BC, 0x9FEA, 0x71BD, 0x9FEB, 0x71BE,\r\n\t0x9FEC, 0x71BF, 0x9FED, 0x71C0, 0x9FEE, 0x71C1, 0x9FEF, 0x71C2,\t0x9FF0, 0x71C4, 0x9FF1, 0x71C5, 0x9FF2, 0x71C6, 0x9FF3, 0x71C7,\r\n\t0x9FF4, 0x71C8, 0x9FF5, 0x71C9, 0x9FF6, 0x71CA, 0x9FF7, 0x71CB,\t0x9FF8, 0x71CC, 0x9FF9, 0x71CD, 0x9FFA, 0x71CF, 0x9FFB, 0x71D0,\r\n\t0x9FFC, 0x71D1, 0x9FFD, 0x71D2, 0x9FFE, 0x71D3, 0xA040, 0x71D6,\t0xA041, 0x71D7, 0xA042, 0x71D8, 0xA043, 0x71D9, 0xA044, 0x71DA,\r\n\t0xA045, 0x71DB, 0xA046, 0x71DC, 0xA047, 0x71DD, 0xA048, 0x71DE,\t0xA049, 0x71DF, 0xA04A, 0x71E1, 0xA04B, 0x71E2, 0xA04C, 0x71E3,\r\n\t0xA04D, 0x71E4, 0xA04E, 0x71E6, 0xA04F, 0x71E8, 0xA050, 0x71E9,\t0xA051, 0x71EA, 0xA052, 0x71EB, 0xA053, 0x71EC, 0xA054, 0x71ED,\r\n\t0xA055, 0x71EF, 0xA056, 0x71F0, 0xA057, 0x71F1, 0xA058, 0x71F2,\t0xA059, 0x71F3, 0xA05A, 0x71F4, 0xA05B, 0x71F5, 0xA05C, 0x71F6,\r\n\t0xA05D, 0x71F7, 0xA05E, 0x71F8, 0xA05F, 0x71FA, 0xA060, 0x71FB,\t0xA061, 0x71FC, 0xA062, 0x71FD, 0xA063, 0x71FE, 0xA064, 0x71FF,\r\n\t0xA065, 0x7200, 0xA066, 0x7201, 0xA067, 0x7202, 0xA068, 0x7203,\t0xA069, 0x7204, 0xA06A, 0x7205, 0xA06B, 0x7207, 0xA06C, 0x7208,\r\n\t0xA06D, 0x7209, 0xA06E, 0x720A, 0xA06F, 0x720B, 0xA070, 0x720C,\t0xA071, 0x720D, 0xA072, 0x720E, 0xA073, 0x720F, 0xA074, 0x7210,\r\n\t0xA075, 0x7211, 0xA076, 0x7212, 0xA077, 0x7213, 0xA078, 0x7214,\t0xA079, 0x7215, 0xA07A, 0x7216, 0xA07B, 0x7217, 0xA07C, 0x7218,\r\n\t0xA07D, 0x7219, 0xA07E, 0x721A, 0xA080, 0x721B, 0xA081, 0x721C,\t0xA082, 0x721E, 0xA083, 0x721F, 0xA084, 0x7220, 0xA085, 0x7221,\r\n\t0xA086, 0x7222, 0xA087, 0x7223, 0xA088, 0x7224, 0xA089, 0x7225,\t0xA08A, 0x7226, 0xA08B, 0x7227, 0xA08C, 0x7229, 0xA08D, 0x722B,\r\n\t0xA08E, 0x722D, 0xA08F, 0x722E, 0xA090, 0x722F, 0xA091, 0x7232,\t0xA092, 0x7233, 0xA093, 0x7234, 0xA094, 0x723A, 0xA095, 0x723C,\r\n\t0xA096, 0x723E, 0xA097, 0x7240, 0xA098, 0x7241, 0xA099, 0x7242,\t0xA09A, 0x7243, 0xA09B, 0x7244, 0xA09C, 0x7245, 0xA09D, 0x7246,\r\n\t0xA09E, 0x7249, 0xA09F, 0x724A, 0xA0A0, 0x724B, 0xA0A1, 0x724E,\t0xA0A2, 0x724F, 0xA0A3, 0x7250, 0xA0A4, 0x7251, 0xA0A5, 0x7253,\r\n\t0xA0A6, 0x7254, 0xA0A7, 0x7255, 0xA0A8, 0x7257, 0xA0A9, 0x7258,\t0xA0AA, 0x725A, 0xA0AB, 0x725C, 0xA0AC, 0x725E, 0xA0AD, 0x7260,\r\n\t0xA0AE, 0x7263, 0xA0AF, 0x7264, 0xA0B0, 0x7265, 0xA0B1, 0x7268,\t0xA0B2, 0x726A, 0xA0B3, 0x726B, 0xA0B4, 0x726C, 0xA0B5, 0x726D,\r\n\t0xA0B6, 0x7270, 0xA0B7, 0x7271, 0xA0B8, 0x7273, 0xA0B9, 0x7274,\t0xA0BA, 0x7276, 0xA0BB, 0x7277, 0xA0BC, 0x7278, 0xA0BD, 0x727B,\r\n\t0xA0BE, 0x727C, 0xA0BF, 0x727D, 0xA0C0, 0x7282, 0xA0C1, 0x7283,\t0xA0C2, 0x7285, 0xA0C3, 0x7286, 0xA0C4, 0x7287, 0xA0C5, 0x7288,\r\n\t0xA0C6, 0x7289, 0xA0C7, 0x728C, 0xA0C8, 0x728E, 0xA0C9, 0x7290,\t0xA0CA, 0x7291, 0xA0CB, 0x7293, 0xA0CC, 0x7294, 0xA0CD, 0x7295,\r\n\t0xA0CE, 0x7296, 0xA0CF, 0x7297, 0xA0D0, 0x7298, 0xA0D1, 0x7299,\t0xA0D2, 0x729A, 0xA0D3, 0x729B, 0xA0D4, 0x729C, 0xA0D5, 0x729D,\r\n\t0xA0D6, 0x729E, 0xA0D7, 0x72A0, 0xA0D8, 0x72A1, 0xA0D9, 0x72A2,\t0xA0DA, 0x72A3, 0xA0DB, 0x72A4, 0xA0DC, 0x72A5, 0xA0DD, 0x72A6,\r\n\t0xA0DE, 0x72A7, 0xA0DF, 0x72A8, 0xA0E0, 0x72A9, 0xA0E1, 0x72AA,\t0xA0E2, 0x72AB, 0xA0E3, 0x72AE, 0xA0E4, 0x72B1, 0xA0E5, 0x72B2,\r\n\t0xA0E6, 0x72B3, 0xA0E7, 0x72B5, 0xA0E8, 0x72BA, 0xA0E9, 0x72BB,\t0xA0EA, 0x72BC, 0xA0EB, 0x72BD, 0xA0EC, 0x72BE, 0xA0ED, 0x72BF,\r\n\t0xA0EE, 0x72C0, 0xA0EF, 0x72C5, 0xA0F0, 0x72C6, 0xA0F1, 0x72C7,\t0xA0F2, 0x72C9, 0xA0F3, 0x72CA, 0xA0F4, 0x72CB, 0xA0F5, 0x72CC,\r\n\t0xA0F6, 0x72CF, 0xA0F7, 0x72D1, 0xA0F8, 0x72D3, 0xA0F9, 0x72D4,\t0xA0FA, 0x72D5, 0xA0FB, 0x72D6, 0xA0FC, 0x72D8, 0xA0FD, 0x72DA,\r\n\t0xA0FE, 0x72DB, 0xA1A1, 0x3000, 0xA1A2, 0x3001, 0xA1A3, 0x3002,\t0xA1A4, 0x00B7, 0xA1A5, 0x02C9, 0xA1A6, 0x02C7, 0xA1A7, 0x00A8,\r\n\t0xA1A8, 0x3003, 0xA1A9, 0x3005, 0xA1AA, 0x2014, 0xA1AB, 0xFF5E,\t0xA1AC, 0x2016, 0xA1AD, 0x2026, 0xA1AE, 0x2018, 0xA1AF, 0x2019,\r\n\t0xA1B0, 0x201C, 0xA1B1, 0x201D, 0xA1B2, 0x3014, 0xA1B3, 0x3015,\t0xA1B4, 0x3008, 0xA1B5, 0x3009, 0xA1B6, 0x300A, 0xA1B7, 0x300B,\r\n\t0xA1B8, 0x300C, 0xA1B9, 0x300D, 0xA1BA, 0x300E, 0xA1BB, 0x300F,\t0xA1BC, 0x3016, 0xA1BD, 0x3017, 0xA1BE, 0x3010, 0xA1BF, 0x3011,\r\n\t0xA1C0, 0x00B1, 0xA1C1, 0x00D7, 0xA1C2, 0x00F7, 0xA1C3, 0x2236,\t0xA1C4, 0x2227, 0xA1C5, 0x2228, 0xA1C6, 0x2211, 0xA1C7, 0x220F,\r\n\t0xA1C8, 0x222A, 0xA1C9, 0x2229, 0xA1CA, 0x2208, 0xA1CB, 0x2237,\t0xA1CC, 0x221A, 0xA1CD, 0x22A5, 0xA1CE, 0x2225, 0xA1CF, 0x2220,\r\n\t0xA1D0, 0x2312, 0xA1D1, 0x2299, 0xA1D2, 0x222B, 0xA1D3, 0x222E,\t0xA1D4, 0x2261, 0xA1D5, 0x224C, 0xA1D6, 0x2248, 0xA1D7, 0x223D,\r\n\t0xA1D8, 0x221D, 0xA1D9, 0x2260, 0xA1DA, 0x226E, 0xA1DB, 0x226F,\t0xA1DC, 0x2264, 0xA1DD, 0x2265, 0xA1DE, 0x221E, 0xA1DF, 0x2235,\r\n\t0xA1E0, 0x2234, 0xA1E1, 0x2642, 0xA1E2, 0x2640, 0xA1E3, 0x00B0,\t0xA1E4, 0x2032, 0xA1E5, 0x2033, 0xA1E6, 0x2103, 0xA1E7, 0xFF04,\r\n\t0xA1E8, 0x00A4, 0xA1E9, 0xFFE0, 0xA1EA, 0xFFE1, 0xA1EB, 0x2030,\t0xA1EC, 0x00A7, 0xA1ED, 0x2116, 0xA1EE, 0x2606, 0xA1EF, 0x2605,\r\n\t0xA1F0, 0x25CB, 0xA1F1, 0x25CF, 0xA1F2, 0x25CE, 0xA1F3, 0x25C7,\t0xA1F4, 0x25C6, 0xA1F5, 0x25A1, 0xA1F6, 0x25A0, 0xA1F7, 0x25B3,\r\n\t0xA1F8, 0x25B2, 0xA1F9, 0x203B, 0xA1FA, 0x2192, 0xA1FB, 0x2190,\t0xA1FC, 0x2191, 0xA1FD, 0x2193, 0xA1FE, 0x3013, 0xA2A1, 0x2170,\r\n\t0xA2A2, 0x2171, 0xA2A3, 0x2172, 0xA2A4, 0x2173, 0xA2A5, 0x2174,\t0xA2A6, 0x2175, 0xA2A7, 0x2176, 0xA2A8, 0x2177, 0xA2A9, 0x2178,\r\n\t0xA2AA, 0x2179, 0xA2B1, 0x2488, 0xA2B2, 0x2489, 0xA2B3, 0x248A,\t0xA2B4, 0x248B, 0xA2B5, 0x248C, 0xA2B6, 0x248D, 0xA2B7, 0x248E,\r\n\t0xA2B8, 0x248F, 0xA2B9, 0x2490, 0xA2BA, 0x2491, 0xA2BB, 0x2492,\t0xA2BC, 0x2493, 0xA2BD, 0x2494, 0xA2BE, 0x2495, 0xA2BF, 0x2496,\r\n\t0xA2C0, 0x2497, 0xA2C1, 0x2498, 0xA2C2, 0x2499, 0xA2C3, 0x249A,\t0xA2C4, 0x249B, 0xA2C5, 0x2474, 0xA2C6, 0x2475, 0xA2C7, 0x2476,\r\n\t0xA2C8, 0x2477, 0xA2C9, 0x2478, 0xA2CA, 0x2479, 0xA2CB, 0x247A,\t0xA2CC, 0x247B, 0xA2CD, 0x247C, 0xA2CE, 0x247D, 0xA2CF, 0x247E,\r\n\t0xA2D0, 0x247F, 0xA2D1, 0x2480, 0xA2D2, 0x2481, 0xA2D3, 0x2482,\t0xA2D4, 0x2483, 0xA2D5, 0x2484, 0xA2D6, 0x2485, 0xA2D7, 0x2486,\r\n\t0xA2D8, 0x2487, 0xA2D9, 0x2460, 0xA2DA, 0x2461, 0xA2DB, 0x2462,\t0xA2DC, 0x2463, 0xA2DD, 0x2464, 0xA2DE, 0x2465, 0xA2DF, 0x2466,\r\n\t0xA2E0, 0x2467, 0xA2E1, 0x2468, 0xA2E2, 0x2469, 0xA2E5, 0x3220,\t0xA2E6, 0x3221, 0xA2E7, 0x3222, 0xA2E8, 0x3223, 0xA2E9, 0x3224,\r\n\t0xA2EA, 0x3225, 0xA2EB, 0x3226, 0xA2EC, 0x3227, 0xA2ED, 0x3228,\t0xA2EE, 0x3229, 0xA2F1, 0x2160, 0xA2F2, 0x2161, 0xA2F3, 0x2162,\r\n\t0xA2F4, 0x2163, 0xA2F5, 0x2164, 0xA2F6, 0x2165, 0xA2F7, 0x2166,\t0xA2F8, 0x2167, 0xA2F9, 0x2168, 0xA2FA, 0x2169, 0xA2FB, 0x216A,\r\n\t0xA2FC, 0x216B, 0xA3A1, 0xFF01, 0xA3A2, 0xFF02, 0xA3A3, 0xFF03,\t0xA3A4, 0xFFE5, 0xA3A5, 0xFF05, 0xA3A6, 0xFF06, 0xA3A7, 0xFF07,\r\n\t0xA3A8, 0xFF08, 0xA3A9, 0xFF09, 0xA3AA, 0xFF0A, 0xA3AB, 0xFF0B,\t0xA3AC, 0xFF0C, 0xA3AD, 0xFF0D, 0xA3AE, 0xFF0E, 0xA3AF, 0xFF0F,\r\n\t0xA3B0, 0xFF10, 0xA3B1, 0xFF11, 0xA3B2, 0xFF12, 0xA3B3, 0xFF13,\t0xA3B4, 0xFF14, 0xA3B5, 0xFF15, 0xA3B6, 0xFF16, 0xA3B7, 0xFF17,\r\n\t0xA3B8, 0xFF18, 0xA3B9, 0xFF19, 0xA3BA, 0xFF1A, 0xA3BB, 0xFF1B,\t0xA3BC, 0xFF1C, 0xA3BD, 0xFF1D, 0xA3BE, 0xFF1E, 0xA3BF, 0xFF1F,\r\n\t0xA3C0, 0xFF20, 0xA3C1, 0xFF21, 0xA3C2, 0xFF22, 0xA3C3, 0xFF23,\t0xA3C4, 0xFF24, 0xA3C5, 0xFF25, 0xA3C6, 0xFF26, 0xA3C7, 0xFF27,\r\n\t0xA3C8, 0xFF28, 0xA3C9, 0xFF29, 0xA3CA, 0xFF2A, 0xA3CB, 0xFF2B,\t0xA3CC, 0xFF2C, 0xA3CD, 0xFF2D, 0xA3CE, 0xFF2E, 0xA3CF, 0xFF2F,\r\n\t0xA3D0, 0xFF30, 0xA3D1, 0xFF31, 0xA3D2, 0xFF32, 0xA3D3, 0xFF33,\t0xA3D4, 0xFF34, 0xA3D5, 0xFF35, 0xA3D6, 0xFF36, 0xA3D7, 0xFF37,\r\n\t0xA3D8, 0xFF38, 0xA3D9, 0xFF39, 0xA3DA, 0xFF3A, 0xA3DB, 0xFF3B,\t0xA3DC, 0xFF3C, 0xA3DD, 0xFF3D, 0xA3DE, 0xFF3E, 0xA3DF, 0xFF3F,\r\n\t0xA3E0, 0xFF40, 0xA3E1, 0xFF41, 0xA3E2, 0xFF42, 0xA3E3, 0xFF43,\t0xA3E4, 0xFF44, 0xA3E5, 0xFF45, 0xA3E6, 0xFF46, 0xA3E7, 0xFF47,\r\n\t0xA3E8, 0xFF48, 0xA3E9, 0xFF49, 0xA3EA, 0xFF4A, 0xA3EB, 0xFF4B,\t0xA3EC, 0xFF4C, 0xA3ED, 0xFF4D, 0xA3EE, 0xFF4E, 0xA3EF, 0xFF4F,\r\n\t0xA3F0, 0xFF50, 0xA3F1, 0xFF51, 0xA3F2, 0xFF52, 0xA3F3, 0xFF53,\t0xA3F4, 0xFF54, 0xA3F5, 0xFF55, 0xA3F6, 0xFF56, 0xA3F7, 0xFF57,\r\n\t0xA3F8, 0xFF58, 0xA3F9, 0xFF59, 0xA3FA, 0xFF5A, 0xA3FB, 0xFF5B,\t0xA3FC, 0xFF5C, 0xA3FD, 0xFF5D, 0xA3FE, 0xFFE3, 0xA4A1, 0x3041,\r\n\t0xA4A2, 0x3042, 0xA4A3, 0x3043, 0xA4A4, 0x3044, 0xA4A5, 0x3045,\t0xA4A6, 0x3046, 0xA4A7, 0x3047, 0xA4A8, 0x3048, 0xA4A9, 0x3049,\r\n\t0xA4AA, 0x304A, 0xA4AB, 0x304B, 0xA4AC, 0x304C, 0xA4AD, 0x304D,\t0xA4AE, 0x304E, 0xA4AF, 0x304F, 0xA4B0, 0x3050, 0xA4B1, 0x3051,\r\n\t0xA4B2, 0x3052, 0xA4B3, 0x3053, 0xA4B4, 0x3054, 0xA4B5, 0x3055,\t0xA4B6, 0x3056, 0xA4B7, 0x3057, 0xA4B8, 0x3058, 0xA4B9, 0x3059,\r\n\t0xA4BA, 0x305A, 0xA4BB, 0x305B, 0xA4BC, 0x305C, 0xA4BD, 0x305D,\t0xA4BE, 0x305E, 0xA4BF, 0x305F, 0xA4C0, 0x3060, 0xA4C1, 0x3061,\r\n\t0xA4C2, 0x3062, 0xA4C3, 0x3063, 0xA4C4, 0x3064, 0xA4C5, 0x3065,\t0xA4C6, 0x3066, 0xA4C7, 0x3067, 0xA4C8, 0x3068, 0xA4C9, 0x3069,\r\n\t0xA4CA, 0x306A, 0xA4CB, 0x306B, 0xA4CC, 0x306C, 0xA4CD, 0x306D,\t0xA4CE, 0x306E, 0xA4CF, 0x306F, 0xA4D0, 0x3070, 0xA4D1, 0x3071,\r\n\t0xA4D2, 0x3072, 0xA4D3, 0x3073, 0xA4D4, 0x3074, 0xA4D5, 0x3075,\t0xA4D6, 0x3076, 0xA4D7, 0x3077, 0xA4D8, 0x3078, 0xA4D9, 0x3079,\r\n\t0xA4DA, 0x307A, 0xA4DB, 0x307B, 0xA4DC, 0x307C, 0xA4DD, 0x307D,\t0xA4DE, 0x307E, 0xA4DF, 0x307F, 0xA4E0, 0x3080, 0xA4E1, 0x3081,\r\n\t0xA4E2, 0x3082, 0xA4E3, 0x3083, 0xA4E4, 0x3084, 0xA4E5, 0x3085,\t0xA4E6, 0x3086, 0xA4E7, 0x3087, 0xA4E8, 0x3088, 0xA4E9, 0x3089,\r\n\t0xA4EA, 0x308A, 0xA4EB, 0x308B, 0xA4EC, 0x308C, 0xA4ED, 0x308D,\t0xA4EE, 0x308E, 0xA4EF, 0x308F, 0xA4F0, 0x3090, 0xA4F1, 0x3091,\r\n\t0xA4F2, 0x3092, 0xA4F3, 0x3093, 0xA5A1, 0x30A1, 0xA5A2, 0x30A2,\t0xA5A3, 0x30A3, 0xA5A4, 0x30A4, 0xA5A5, 0x30A5, 0xA5A6, 0x30A6,\r\n\t0xA5A7, 0x30A7, 0xA5A8, 0x30A8, 0xA5A9, 0x30A9, 0xA5AA, 0x30AA,\t0xA5AB, 0x30AB, 0xA5AC, 0x30AC, 0xA5AD, 0x30AD, 0xA5AE, 0x30AE,\r\n\t0xA5AF, 0x30AF, 0xA5B0, 0x30B0, 0xA5B1, 0x30B1, 0xA5B2, 0x30B2,\t0xA5B3, 0x30B3, 0xA5B4, 0x30B4, 0xA5B5, 0x30B5, 0xA5B6, 0x30B6,\r\n\t0xA5B7, 0x30B7, 0xA5B8, 0x30B8, 0xA5B9, 0x30B9, 0xA5BA, 0x30BA,\t0xA5BB, 0x30BB, 0xA5BC, 0x30BC, 0xA5BD, 0x30BD, 0xA5BE, 0x30BE,\r\n\t0xA5BF, 0x30BF, 0xA5C0, 0x30C0, 0xA5C1, 0x30C1, 0xA5C2, 0x30C2,\t0xA5C3, 0x30C3, 0xA5C4, 0x30C4, 0xA5C5, 0x30C5, 0xA5C6, 0x30C6,\r\n\t0xA5C7, 0x30C7, 0xA5C8, 0x30C8, 0xA5C9, 0x30C9, 0xA5CA, 0x30CA,\t0xA5CB, 0x30CB, 0xA5CC, 0x30CC, 0xA5CD, 0x30CD, 0xA5CE, 0x30CE,\r\n\t0xA5CF, 0x30CF, 0xA5D0, 0x30D0, 0xA5D1, 0x30D1, 0xA5D2, 0x30D2,\t0xA5D3, 0x30D3, 0xA5D4, 0x30D4, 0xA5D5, 0x30D5, 0xA5D6, 0x30D6,\r\n\t0xA5D7, 0x30D7, 0xA5D8, 0x30D8, 0xA5D9, 0x30D9, 0xA5DA, 0x30DA,\t0xA5DB, 0x30DB, 0xA5DC, 0x30DC, 0xA5DD, 0x30DD, 0xA5DE, 0x30DE,\r\n\t0xA5DF, 0x30DF, 0xA5E0, 0x30E0, 0xA5E1, 0x30E1, 0xA5E2, 0x30E2,\t0xA5E3, 0x30E3, 0xA5E4, 0x30E4, 0xA5E5, 0x30E5, 0xA5E6, 0x30E6,\r\n\t0xA5E7, 0x30E7, 0xA5E8, 0x30E8, 0xA5E9, 0x30E9, 0xA5EA, 0x30EA,\t0xA5EB, 0x30EB, 0xA5EC, 0x30EC, 0xA5ED, 0x30ED, 0xA5EE, 0x30EE,\r\n\t0xA5EF, 0x30EF, 0xA5F0, 0x30F0, 0xA5F1, 0x30F1, 0xA5F2, 0x30F2,\t0xA5F3, 0x30F3, 0xA5F4, 0x30F4, 0xA5F5, 0x30F5, 0xA5F6, 0x30F6,\r\n\t0xA6A1, 0x0391, 0xA6A2, 0x0392, 0xA6A3, 0x0393, 0xA6A4, 0x0394,\t0xA6A5, 0x0395, 0xA6A6, 0x0396, 0xA6A7, 0x0397, 0xA6A8, 0x0398,\r\n\t0xA6A9, 0x0399, 0xA6AA, 0x039A, 0xA6AB, 0x039B, 0xA6AC, 0x039C,\t0xA6AD, 0x039D, 0xA6AE, 0x039E, 0xA6AF, 0x039F, 0xA6B0, 0x03A0,\r\n\t0xA6B1, 0x03A1, 0xA6B2, 0x03A3, 0xA6B3, 0x03A4, 0xA6B4, 0x03A5,\t0xA6B5, 0x03A6, 0xA6B6, 0x03A7, 0xA6B7, 0x03A8, 0xA6B8, 0x03A9,\r\n\t0xA6C1, 0x03B1, 0xA6C2, 0x03B2, 0xA6C3, 0x03B3, 0xA6C4, 0x03B4,\t0xA6C5, 0x03B5, 0xA6C6, 0x03B6, 0xA6C7, 0x03B7, 0xA6C8, 0x03B8,\r\n\t0xA6C9, 0x03B9, 0xA6CA, 0x03BA, 0xA6CB, 0x03BB, 0xA6CC, 0x03BC,\t0xA6CD, 0x03BD, 0xA6CE, 0x03BE, 0xA6CF, 0x03BF, 0xA6D0, 0x03C0,\r\n\t0xA6D1, 0x03C1, 0xA6D2, 0x03C3, 0xA6D3, 0x03C4, 0xA6D4, 0x03C5,\t0xA6D5, 0x03C6, 0xA6D6, 0x03C7, 0xA6D7, 0x03C8, 0xA6D8, 0x03C9,\r\n\t0xA6E0, 0xFE35, 0xA6E1, 0xFE36, 0xA6E2, 0xFE39, 0xA6E3, 0xFE3A,\t0xA6E4, 0xFE3F, 0xA6E5, 0xFE40, 0xA6E6, 0xFE3D, 0xA6E7, 0xFE3E,\r\n\t0xA6E8, 0xFE41, 0xA6E9, 0xFE42, 0xA6EA, 0xFE43, 0xA6EB, 0xFE44,\t0xA6EE, 0xFE3B, 0xA6EF, 0xFE3C, 0xA6F0, 0xFE37, 0xA6F1, 0xFE38,\r\n\t0xA6F2, 0xFE31, 0xA6F4, 0xFE33, 0xA6F5, 0xFE34, 0xA7A1, 0x0410,\t0xA7A2, 0x0411, 0xA7A3, 0x0412, 0xA7A4, 0x0413, 0xA7A5, 0x0414,\r\n\t0xA7A6, 0x0415, 0xA7A7, 0x0401, 0xA7A8, 0x0416, 0xA7A9, 0x0417,\t0xA7AA, 0x0418, 0xA7AB, 0x0419, 0xA7AC, 0x041A, 0xA7AD, 0x041B,\r\n\t0xA7AE, 0x041C, 0xA7AF, 0x041D, 0xA7B0, 0x041E, 0xA7B1, 0x041F,\t0xA7B2, 0x0420, 0xA7B3, 0x0421, 0xA7B4, 0x0422, 0xA7B5, 0x0423,\r\n\t0xA7B6, 0x0424, 0xA7B7, 0x0425, 0xA7B8, 0x0426, 0xA7B9, 0x0427,\t0xA7BA, 0x0428, 0xA7BB, 0x0429, 0xA7BC, 0x042A, 0xA7BD, 0x042B,\r\n\t0xA7BE, 0x042C, 0xA7BF, 0x042D, 0xA7C0, 0x042E, 0xA7C1, 0x042F,\t0xA7D1, 0x0430, 0xA7D2, 0x0431, 0xA7D3, 0x0432, 0xA7D4, 0x0433,\r\n\t0xA7D5, 0x0434, 0xA7D6, 0x0435, 0xA7D7, 0x0451, 0xA7D8, 0x0436,\t0xA7D9, 0x0437, 0xA7DA, 0x0438, 0xA7DB, 0x0439, 0xA7DC, 0x043A,\r\n\t0xA7DD, 0x043B, 0xA7DE, 0x043C, 0xA7DF, 0x043D, 0xA7E0, 0x043E,\t0xA7E1, 0x043F, 0xA7E2, 0x0440, 0xA7E3, 0x0441, 0xA7E4, 0x0442,\r\n\t0xA7E5, 0x0443, 0xA7E6, 0x0444, 0xA7E7, 0x0445, 0xA7E8, 0x0446,\t0xA7E9, 0x0447, 0xA7EA, 0x0448, 0xA7EB, 0x0449, 0xA7EC, 0x044A,\r\n\t0xA7ED, 0x044B, 0xA7EE, 0x044C, 0xA7EF, 0x044D, 0xA7F0, 0x044E,\t0xA7F1, 0x044F, 0xA840, 0x02CA, 0xA841, 0x02CB, 0xA842, 0x02D9,\r\n\t0xA843, 0x2013, 0xA844, 0x2015, 0xA845, 0x2025, 0xA846, 0x2035,\t0xA847, 0x2105, 0xA848, 0x2109, 0xA849, 0x2196, 0xA84A, 0x2197,\r\n\t0xA84B, 0x2198, 0xA84C, 0x2199, 0xA84D, 0x2215, 0xA84E, 0x221F,\t0xA84F, 0x2223, 0xA850, 0x2252, 0xA851, 0x2266, 0xA852, 0x2267,\r\n\t0xA853, 0x22BF, 0xA854, 0x2550, 0xA855, 0x2551, 0xA856, 0x2552,\t0xA857, 0x2553, 0xA858, 0x2554, 0xA859, 0x2555, 0xA85A, 0x2556,\r\n\t0xA85B, 0x2557, 0xA85C, 0x2558, 0xA85D, 0x2559, 0xA85E, 0x255A,\t0xA85F, 0x255B, 0xA860, 0x255C, 0xA861, 0x255D, 0xA862, 0x255E,\r\n\t0xA863, 0x255F, 0xA864, 0x2560, 0xA865, 0x2561, 0xA866, 0x2562,\t0xA867, 0x2563, 0xA868, 0x2564, 0xA869, 0x2565, 0xA86A, 0x2566,\r\n\t0xA86B, 0x2567, 0xA86C, 0x2568, 0xA86D, 0x2569, 0xA86E, 0x256A,\t0xA86F, 0x256B, 0xA870, 0x256C, 0xA871, 0x256D, 0xA872, 0x256E,\r\n\t0xA873, 0x256F, 0xA874, 0x2570, 0xA875, 0x2571, 0xA876, 0x2572,\t0xA877, 0x2573, 0xA878, 0x2581, 0xA879, 0x2582, 0xA87A, 0x2583,\r\n\t0xA87B, 0x2584, 0xA87C, 0x2585, 0xA87D, 0x2586, 0xA87E, 0x2587,\t0xA880, 0x2588, 0xA881, 0x2589, 0xA882, 0x258A, 0xA883, 0x258B,\r\n\t0xA884, 0x258C, 0xA885, 0x258D, 0xA886, 0x258E, 0xA887, 0x258F,\t0xA888, 0x2593, 0xA889, 0x2594, 0xA88A, 0x2595, 0xA88B, 0x25BC,\r\n\t0xA88C, 0x25BD, 0xA88D, 0x25E2, 0xA88E, 0x25E3, 0xA88F, 0x25E4,\t0xA890, 0x25E5, 0xA891, 0x2609, 0xA892, 0x2295, 0xA893, 0x3012,\r\n\t0xA894, 0x301D, 0xA895, 0x301E, 0xA8A1, 0x0101, 0xA8A2, 0x00E1,\t0xA8A3, 0x01CE, 0xA8A4, 0x00E0, 0xA8A5, 0x0113, 0xA8A6, 0x00E9,\r\n\t0xA8A7, 0x011B, 0xA8A8, 0x00E8, 0xA8A9, 0x012B, 0xA8AA, 0x00ED,\t0xA8AB, 0x01D0, 0xA8AC, 0x00EC, 0xA8AD, 0x014D, 0xA8AE, 0x00F3,\r\n\t0xA8AF, 0x01D2, 0xA8B0, 0x00F2, 0xA8B1, 0x016B, 0xA8B2, 0x00FA,\t0xA8B3, 0x01D4, 0xA8B4, 0x00F9, 0xA8B5, 0x01D6, 0xA8B6, 0x01D8,\r\n\t0xA8B7, 0x01DA, 0xA8B8, 0x01DC, 0xA8B9, 0x00FC, 0xA8BA, 0x00EA,\t0xA8BB, 0x0251, 0xA8BD, 0x0144, 0xA8BE, 0x0148, 0xA8C0, 0x0261,\r\n\t0xA8C5, 0x3105, 0xA8C6, 0x3106, 0xA8C7, 0x3107, 0xA8C8, 0x3108,\t0xA8C9, 0x3109, 0xA8CA, 0x310A, 0xA8CB, 0x310B, 0xA8CC, 0x310C,\r\n\t0xA8CD, 0x310D, 0xA8CE, 0x310E, 0xA8CF, 0x310F, 0xA8D0, 0x3110,\t0xA8D1, 0x3111, 0xA8D2, 0x3112, 0xA8D3, 0x3113, 0xA8D4, 0x3114,\r\n\t0xA8D5, 0x3115, 0xA8D6, 0x3116, 0xA8D7, 0x3117, 0xA8D8, 0x3118,\t0xA8D9, 0x3119, 0xA8DA, 0x311A, 0xA8DB, 0x311B, 0xA8DC, 0x311C,\r\n\t0xA8DD, 0x311D, 0xA8DE, 0x311E, 0xA8DF, 0x311F, 0xA8E0, 0x3120,\t0xA8E1, 0x3121, 0xA8E2, 0x3122, 0xA8E3, 0x3123, 0xA8E4, 0x3124,\r\n\t0xA8E5, 0x3125, 0xA8E6, 0x3126, 0xA8E7, 0x3127, 0xA8E8, 0x3128,\t0xA8E9, 0x3129, 0xA940, 0x3021, 0xA941, 0x3022, 0xA942, 0x3023,\r\n\t0xA943, 0x3024, 0xA944, 0x3025, 0xA945, 0x3026, 0xA946, 0x3027,\t0xA947, 0x3028, 0xA948, 0x3029, 0xA949, 0x32A3, 0xA94A, 0x338E,\r\n\t0xA94B, 0x338F, 0xA94C, 0x339C, 0xA94D, 0x339D, 0xA94E, 0x339E,\t0xA94F, 0x33A1, 0xA950, 0x33C4, 0xA951, 0x33CE, 0xA952, 0x33D1,\r\n\t0xA953, 0x33D2, 0xA954, 0x33D5, 0xA955, 0xFE30, 0xA956, 0xFFE2,\t0xA957, 0xFFE4, 0xA959, 0x2121, 0xA95A, 0x3231, 0xA95C, 0x2010,\r\n\t0xA960, 0x30FC, 0xA961, 0x309B, 0xA962, 0x309C, 0xA963, 0x30FD,\t0xA964, 0x30FE, 0xA965, 0x3006, 0xA966, 0x309D, 0xA967, 0x309E,\r\n\t0xA968, 0xFE49, 0xA969, 0xFE4A, 0xA96A, 0xFE4B, 0xA96B, 0xFE4C,\t0xA96C, 0xFE4D, 0xA96D, 0xFE4E, 0xA96E, 0xFE4F, 0xA96F, 0xFE50,\r\n\t0xA970, 0xFE51, 0xA971, 0xFE52, 0xA972, 0xFE54, 0xA973, 0xFE55,\t0xA974, 0xFE56, 0xA975, 0xFE57, 0xA976, 0xFE59, 0xA977, 0xFE5A,\r\n\t0xA978, 0xFE5B, 0xA979, 0xFE5C, 0xA97A, 0xFE5D, 0xA97B, 0xFE5E,\t0xA97C, 0xFE5F, 0xA97D, 0xFE60, 0xA97E, 0xFE61, 0xA980, 0xFE62,\r\n\t0xA981, 0xFE63, 0xA982, 0xFE64, 0xA983, 0xFE65, 0xA984, 0xFE66,\t0xA985, 0xFE68, 0xA986, 0xFE69, 0xA987, 0xFE6A, 0xA988, 0xFE6B,\r\n\t0xA996, 0x3007, 0xA9A4, 0x2500, 0xA9A5, 0x2501, 0xA9A6, 0x2502,\t0xA9A7, 0x2503, 0xA9A8, 0x2504, 0xA9A9, 0x2505, 0xA9AA, 0x2506,\r\n\t0xA9AB, 0x2507, 0xA9AC, 0x2508, 0xA9AD, 0x2509, 0xA9AE, 0x250A,\t0xA9AF, 0x250B, 0xA9B0, 0x250C, 0xA9B1, 0x250D, 0xA9B2, 0x250E,\r\n\t0xA9B3, 0x250F, 0xA9B4, 0x2510, 0xA9B5, 0x2511, 0xA9B6, 0x2512,\t0xA9B7, 0x2513, 0xA9B8, 0x2514, 0xA9B9, 0x2515, 0xA9BA, 0x2516,\r\n\t0xA9BB, 0x2517, 0xA9BC, 0x2518, 0xA9BD, 0x2519, 0xA9BE, 0x251A,\t0xA9BF, 0x251B, 0xA9C0, 0x251C, 0xA9C1, 0x251D, 0xA9C2, 0x251E,\r\n\t0xA9C3, 0x251F, 0xA9C4, 0x2520, 0xA9C5, 0x2521, 0xA9C6, 0x2522,\t0xA9C7, 0x2523, 0xA9C8, 0x2524, 0xA9C9, 0x2525, 0xA9CA, 0x2526,\r\n\t0xA9CB, 0x2527, 0xA9CC, 0x2528, 0xA9CD, 0x2529, 0xA9CE, 0x252A,\t0xA9CF, 0x252B, 0xA9D0, 0x252C, 0xA9D1, 0x252D, 0xA9D2, 0x252E,\r\n\t0xA9D3, 0x252F, 0xA9D4, 0x2530, 0xA9D5, 0x2531, 0xA9D6, 0x2532,\t0xA9D7, 0x2533, 0xA9D8, 0x2534, 0xA9D9, 0x2535, 0xA9DA, 0x2536,\r\n\t0xA9DB, 0x2537, 0xA9DC, 0x2538, 0xA9DD, 0x2539, 0xA9DE, 0x253A,\t0xA9DF, 0x253B, 0xA9E0, 0x253C, 0xA9E1, 0x253D, 0xA9E2, 0x253E,\r\n\t0xA9E3, 0x253F, 0xA9E4, 0x2540, 0xA9E5, 0x2541, 0xA9E6, 0x2542,\t0xA9E7, 0x2543, 0xA9E8, 0x2544, 0xA9E9, 0x2545, 0xA9EA, 0x2546,\r\n\t0xA9EB, 0x2547, 0xA9EC, 0x2548, 0xA9ED, 0x2549, 0xA9EE, 0x254A,\t0xA9EF, 0x254B, 0xAA40, 0x72DC, 0xAA41, 0x72DD, 0xAA42, 0x72DF,\r\n\t0xAA43, 0x72E2, 0xAA44, 0x72E3, 0xAA45, 0x72E4, 0xAA46, 0x72E5,\t0xAA47, 0x72E6, 0xAA48, 0x72E7, 0xAA49, 0x72EA, 0xAA4A, 0x72EB,\r\n\t0xAA4B, 0x72F5, 0xAA4C, 0x72F6, 0xAA4D, 0x72F9, 0xAA4E, 0x72FD,\t0xAA4F, 0x72FE, 0xAA50, 0x72FF, 0xAA51, 0x7300, 0xAA52, 0x7302,\r\n\t0xAA53, 0x7304, 0xAA54, 0x7305, 0xAA55, 0x7306, 0xAA56, 0x7307,\t0xAA57, 0x7308, 0xAA58, 0x7309, 0xAA59, 0x730B, 0xAA5A, 0x730C,\r\n\t0xAA5B, 0x730D, 0xAA5C, 0x730F, 0xAA5D, 0x7310, 0xAA5E, 0x7311,\t0xAA5F, 0x7312, 0xAA60, 0x7314, 0xAA61, 0x7318, 0xAA62, 0x7319,\r\n\t0xAA63, 0x731A, 0xAA64, 0x731F, 0xAA65, 0x7320, 0xAA66, 0x7323,\t0xAA67, 0x7324, 0xAA68, 0x7326, 0xAA69, 0x7327, 0xAA6A, 0x7328,\r\n\t0xAA6B, 0x732D, 0xAA6C, 0x732F, 0xAA6D, 0x7330, 0xAA6E, 0x7332,\t0xAA6F, 0x7333, 0xAA70, 0x7335, 0xAA71, 0x7336, 0xAA72, 0x733A,\r\n\t0xAA73, 0x733B, 0xAA74, 0x733C, 0xAA75, 0x733D, 0xAA76, 0x7340,\t0xAA77, 0x7341, 0xAA78, 0x7342, 0xAA79, 0x7343, 0xAA7A, 0x7344,\r\n\t0xAA7B, 0x7345, 0xAA7C, 0x7346, 0xAA7D, 0x7347, 0xAA7E, 0x7348,\t0xAA80, 0x7349, 0xAA81, 0x734A, 0xAA82, 0x734B, 0xAA83, 0x734C,\r\n\t0xAA84, 0x734E, 0xAA85, 0x734F, 0xAA86, 0x7351, 0xAA87, 0x7353,\t0xAA88, 0x7354, 0xAA89, 0x7355, 0xAA8A, 0x7356, 0xAA8B, 0x7358,\r\n\t0xAA8C, 0x7359, 0xAA8D, 0x735A, 0xAA8E, 0x735B, 0xAA8F, 0x735C,\t0xAA90, 0x735D, 0xAA91, 0x735E, 0xAA92, 0x735F, 0xAA93, 0x7361,\r\n\t0xAA94, 0x7362, 0xAA95, 0x7363, 0xAA96, 0x7364, 0xAA97, 0x7365,\t0xAA98, 0x7366, 0xAA99, 0x7367, 0xAA9A, 0x7368, 0xAA9B, 0x7369,\r\n\t0xAA9C, 0x736A, 0xAA9D, 0x736B, 0xAA9E, 0x736E, 0xAA9F, 0x7370,\t0xAAA0, 0x7371, 0xAB40, 0x7372, 0xAB41, 0x7373, 0xAB42, 0x7374,\r\n\t0xAB43, 0x7375, 0xAB44, 0x7376, 0xAB45, 0x7377, 0xAB46, 0x7378,\t0xAB47, 0x7379, 0xAB48, 0x737A, 0xAB49, 0x737B, 0xAB4A, 0x737C,\r\n\t0xAB4B, 0x737D, 0xAB4C, 0x737F, 0xAB4D, 0x7380, 0xAB4E, 0x7381,\t0xAB4F, 0x7382, 0xAB50, 0x7383, 0xAB51, 0x7385, 0xAB52, 0x7386,\r\n\t0xAB53, 0x7388, 0xAB54, 0x738A, 0xAB55, 0x738C, 0xAB56, 0x738D,\t0xAB57, 0x738F, 0xAB58, 0x7390, 0xAB59, 0x7392, 0xAB5A, 0x7393,\r\n\t0xAB5B, 0x7394, 0xAB5C, 0x7395, 0xAB5D, 0x7397, 0xAB5E, 0x7398,\t0xAB5F, 0x7399, 0xAB60, 0x739A, 0xAB61, 0x739C, 0xAB62, 0x739D,\r\n\t0xAB63, 0x739E, 0xAB64, 0x73A0, 0xAB65, 0x73A1, 0xAB66, 0x73A3,\t0xAB67, 0x73A4, 0xAB68, 0x73A5, 0xAB69, 0x73A6, 0xAB6A, 0x73A7,\r\n\t0xAB6B, 0x73A8, 0xAB6C, 0x73AA, 0xAB6D, 0x73AC, 0xAB6E, 0x73AD,\t0xAB6F, 0x73B1, 0xAB70, 0x73B4, 0xAB71, 0x73B5, 0xAB72, 0x73B6,\r\n\t0xAB73, 0x73B8, 0xAB74, 0x73B9, 0xAB75, 0x73BC, 0xAB76, 0x73BD,\t0xAB77, 0x73BE, 0xAB78, 0x73BF, 0xAB79, 0x73C1, 0xAB7A, 0x73C3,\r\n\t0xAB7B, 0x73C4, 0xAB7C, 0x73C5, 0xAB7D, 0x73C6, 0xAB7E, 0x73C7,\t0xAB80, 0x73CB, 0xAB81, 0x73CC, 0xAB82, 0x73CE, 0xAB83, 0x73D2,\r\n\t0xAB84, 0x73D3, 0xAB85, 0x73D4, 0xAB86, 0x73D5, 0xAB87, 0x73D6,\t0xAB88, 0x73D7, 0xAB89, 0x73D8, 0xAB8A, 0x73DA, 0xAB8B, 0x73DB,\r\n\t0xAB8C, 0x73DC, 0xAB8D, 0x73DD, 0xAB8E, 0x73DF, 0xAB8F, 0x73E1,\t0xAB90, 0x73E2, 0xAB91, 0x73E3, 0xAB92, 0x73E4, 0xAB93, 0x73E6,\r\n\t0xAB94, 0x73E8, 0xAB95, 0x73EA, 0xAB96, 0x73EB, 0xAB97, 0x73EC,\t0xAB98, 0x73EE, 0xAB99, 0x73EF, 0xAB9A, 0x73F0, 0xAB9B, 0x73F1,\r\n\t0xAB9C, 0x73F3, 0xAB9D, 0x73F4, 0xAB9E, 0x73F5, 0xAB9F, 0x73F6,\t0xABA0, 0x73F7, 0xAC40, 0x73F8, 0xAC41, 0x73F9, 0xAC42, 0x73FA,\r\n\t0xAC43, 0x73FB, 0xAC44, 0x73FC, 0xAC45, 0x73FD, 0xAC46, 0x73FE,\t0xAC47, 0x73FF, 0xAC48, 0x7400, 0xAC49, 0x7401, 0xAC4A, 0x7402,\r\n\t0xAC4B, 0x7404, 0xAC4C, 0x7407, 0xAC4D, 0x7408, 0xAC4E, 0x740B,\t0xAC4F, 0x740C, 0xAC50, 0x740D, 0xAC51, 0x740E, 0xAC52, 0x7411,\r\n\t0xAC53, 0x7412, 0xAC54, 0x7413, 0xAC55, 0x7414, 0xAC56, 0x7415,\t0xAC57, 0x7416, 0xAC58, 0x7417, 0xAC59, 0x7418, 0xAC5A, 0x7419,\r\n\t0xAC5B, 0x741C, 0xAC5C, 0x741D, 0xAC5D, 0x741E, 0xAC5E, 0x741F,\t0xAC5F, 0x7420, 0xAC60, 0x7421, 0xAC61, 0x7423, 0xAC62, 0x7424,\r\n\t0xAC63, 0x7427, 0xAC64, 0x7429, 0xAC65, 0x742B, 0xAC66, 0x742D,\t0xAC67, 0x742F, 0xAC68, 0x7431, 0xAC69, 0x7432, 0xAC6A, 0x7437,\r\n\t0xAC6B, 0x7438, 0xAC6C, 0x7439, 0xAC6D, 0x743A, 0xAC6E, 0x743B,\t0xAC6F, 0x743D, 0xAC70, 0x743E, 0xAC71, 0x743F, 0xAC72, 0x7440,\r\n\t0xAC73, 0x7442, 0xAC74, 0x7443, 0xAC75, 0x7444, 0xAC76, 0x7445,\t0xAC77, 0x7446, 0xAC78, 0x7447, 0xAC79, 0x7448, 0xAC7A, 0x7449,\r\n\t0xAC7B, 0x744A, 0xAC7C, 0x744B, 0xAC7D, 0x744C, 0xAC7E, 0x744D,\t0xAC80, 0x744E, 0xAC81, 0x744F, 0xAC82, 0x7450, 0xAC83, 0x7451,\r\n\t0xAC84, 0x7452, 0xAC85, 0x7453, 0xAC86, 0x7454, 0xAC87, 0x7456,\t0xAC88, 0x7458, 0xAC89, 0x745D, 0xAC8A, 0x7460, 0xAC8B, 0x7461,\r\n\t0xAC8C, 0x7462, 0xAC8D, 0x7463, 0xAC8E, 0x7464, 0xAC8F, 0x7465,\t0xAC90, 0x7466, 0xAC91, 0x7467, 0xAC92, 0x7468, 0xAC93, 0x7469,\r\n\t0xAC94, 0x746A, 0xAC95, 0x746B, 0xAC96, 0x746C, 0xAC97, 0x746E,\t0xAC98, 0x746F, 0xAC99, 0x7471, 0xAC9A, 0x7472, 0xAC9B, 0x7473,\r\n\t0xAC9C, 0x7474, 0xAC9D, 0x7475, 0xAC9E, 0x7478, 0xAC9F, 0x7479,\t0xACA0, 0x747A, 0xAD40, 0x747B, 0xAD41, 0x747C, 0xAD42, 0x747D,\r\n\t0xAD43, 0x747F, 0xAD44, 0x7482, 0xAD45, 0x7484, 0xAD46, 0x7485,\t0xAD47, 0x7486, 0xAD48, 0x7488, 0xAD49, 0x7489, 0xAD4A, 0x748A,\r\n\t0xAD4B, 0x748C, 0xAD4C, 0x748D, 0xAD4D, 0x748F, 0xAD4E, 0x7491,\t0xAD4F, 0x7492, 0xAD50, 0x7493, 0xAD51, 0x7494, 0xAD52, 0x7495,\r\n\t0xAD53, 0x7496, 0xAD54, 0x7497, 0xAD55, 0x7498, 0xAD56, 0x7499,\t0xAD57, 0x749A, 0xAD58, 0x749B, 0xAD59, 0x749D, 0xAD5A, 0x749F,\r\n\t0xAD5B, 0x74A0, 0xAD5C, 0x74A1, 0xAD5D, 0x74A2, 0xAD5E, 0x74A3,\t0xAD5F, 0x74A4, 0xAD60, 0x74A5, 0xAD61, 0x74A6, 0xAD62, 0x74AA,\r\n\t0xAD63, 0x74AB, 0xAD64, 0x74AC, 0xAD65, 0x74AD, 0xAD66, 0x74AE,\t0xAD67, 0x74AF, 0xAD68, 0x74B0, 0xAD69, 0x74B1, 0xAD6A, 0x74B2,\r\n\t0xAD6B, 0x74B3, 0xAD6C, 0x74B4, 0xAD6D, 0x74B5, 0xAD6E, 0x74B6,\t0xAD6F, 0x74B7, 0xAD70, 0x74B8, 0xAD71, 0x74B9, 0xAD72, 0x74BB,\r\n\t0xAD73, 0x74BC, 0xAD74, 0x74BD, 0xAD75, 0x74BE, 0xAD76, 0x74BF,\t0xAD77, 0x74C0, 0xAD78, 0x74C1, 0xAD79, 0x74C2, 0xAD7A, 0x74C3,\r\n\t0xAD7B, 0x74C4, 0xAD7C, 0x74C5, 0xAD7D, 0x74C6, 0xAD7E, 0x74C7,\t0xAD80, 0x74C8, 0xAD81, 0x74C9, 0xAD82, 0x74CA, 0xAD83, 0x74CB,\r\n\t0xAD84, 0x74CC, 0xAD85, 0x74CD, 0xAD86, 0x74CE, 0xAD87, 0x74CF,\t0xAD88, 0x74D0, 0xAD89, 0x74D1, 0xAD8A, 0x74D3, 0xAD8B, 0x74D4,\r\n\t0xAD8C, 0x74D5, 0xAD8D, 0x74D6, 0xAD8E, 0x74D7, 0xAD8F, 0x74D8,\t0xAD90, 0x74D9, 0xAD91, 0x74DA, 0xAD92, 0x74DB, 0xAD93, 0x74DD,\r\n\t0xAD94, 0x74DF, 0xAD95, 0x74E1, 0xAD96, 0x74E5, 0xAD97, 0x74E7,\t0xAD98, 0x74E8, 0xAD99, 0x74E9, 0xAD9A, 0x74EA, 0xAD9B, 0x74EB,\r\n\t0xAD9C, 0x74EC, 0xAD9D, 0x74ED, 0xAD9E, 0x74F0, 0xAD9F, 0x74F1,\t0xADA0, 0x74F2, 0xAE40, 0x74F3, 0xAE41, 0x74F5, 0xAE42, 0x74F8,\r\n\t0xAE43, 0x74F9, 0xAE44, 0x74FA, 0xAE45, 0x74FB, 0xAE46, 0x74FC,\t0xAE47, 0x74FD, 0xAE48, 0x74FE, 0xAE49, 0x7500, 0xAE4A, 0x7501,\r\n\t0xAE4B, 0x7502, 0xAE4C, 0x7503, 0xAE4D, 0x7505, 0xAE4E, 0x7506,\t0xAE4F, 0x7507, 0xAE50, 0x7508, 0xAE51, 0x7509, 0xAE52, 0x750A,\r\n\t0xAE53, 0x750B, 0xAE54, 0x750C, 0xAE55, 0x750E, 0xAE56, 0x7510,\t0xAE57, 0x7512, 0xAE58, 0x7514, 0xAE59, 0x7515, 0xAE5A, 0x7516,\r\n\t0xAE5B, 0x7517, 0xAE5C, 0x751B, 0xAE5D, 0x751D, 0xAE5E, 0x751E,\t0xAE5F, 0x7520, 0xAE60, 0x7521, 0xAE61, 0x7522, 0xAE62, 0x7523,\r\n\t0xAE63, 0x7524, 0xAE64, 0x7526, 0xAE65, 0x7527, 0xAE66, 0x752A,\t0xAE67, 0x752E, 0xAE68, 0x7534, 0xAE69, 0x7536, 0xAE6A, 0x7539,\r\n\t0xAE6B, 0x753C, 0xAE6C, 0x753D, 0xAE6D, 0x753F, 0xAE6E, 0x7541,\t0xAE6F, 0x7542, 0xAE70, 0x7543, 0xAE71, 0x7544, 0xAE72, 0x7546,\r\n\t0xAE73, 0x7547, 0xAE74, 0x7549, 0xAE75, 0x754A, 0xAE76, 0x754D,\t0xAE77, 0x7550, 0xAE78, 0x7551, 0xAE79, 0x7552, 0xAE7A, 0x7553,\r\n\t0xAE7B, 0x7555, 0xAE7C, 0x7556, 0xAE7D, 0x7557, 0xAE7E, 0x7558,\t0xAE80, 0x755D, 0xAE81, 0x755E, 0xAE82, 0x755F, 0xAE83, 0x7560,\r\n\t0xAE84, 0x7561, 0xAE85, 0x7562, 0xAE86, 0x7563, 0xAE87, 0x7564,\t0xAE88, 0x7567, 0xAE89, 0x7568, 0xAE8A, 0x7569, 0xAE8B, 0x756B,\r\n\t0xAE8C, 0x756C, 0xAE8D, 0x756D, 0xAE8E, 0x756E, 0xAE8F, 0x756F,\t0xAE90, 0x7570, 0xAE91, 0x7571, 0xAE92, 0x7573, 0xAE93, 0x7575,\r\n\t0xAE94, 0x7576, 0xAE95, 0x7577, 0xAE96, 0x757A, 0xAE97, 0x757B,\t0xAE98, 0x757C, 0xAE99, 0x757D, 0xAE9A, 0x757E, 0xAE9B, 0x7580,\r\n\t0xAE9C, 0x7581, 0xAE9D, 0x7582, 0xAE9E, 0x7584, 0xAE9F, 0x7585,\t0xAEA0, 0x7587, 0xAF40, 0x7588, 0xAF41, 0x7589, 0xAF42, 0x758A,\r\n\t0xAF43, 0x758C, 0xAF44, 0x758D, 0xAF45, 0x758E, 0xAF46, 0x7590,\t0xAF47, 0x7593, 0xAF48, 0x7595, 0xAF49, 0x7598, 0xAF4A, 0x759B,\r\n\t0xAF4B, 0x759C, 0xAF4C, 0x759E, 0xAF4D, 0x75A2, 0xAF4E, 0x75A6,\t0xAF4F, 0x75A7, 0xAF50, 0x75A8, 0xAF51, 0x75A9, 0xAF52, 0x75AA,\r\n\t0xAF53, 0x75AD, 0xAF54, 0x75B6, 0xAF55, 0x75B7, 0xAF56, 0x75BA,\t0xAF57, 0x75BB, 0xAF58, 0x75BF, 0xAF59, 0x75C0, 0xAF5A, 0x75C1,\r\n\t0xAF5B, 0x75C6, 0xAF5C, 0x75CB, 0xAF5D, 0x75CC, 0xAF5E, 0x75CE,\t0xAF5F, 0x75CF, 0xAF60, 0x75D0, 0xAF61, 0x75D1, 0xAF62, 0x75D3,\r\n\t0xAF63, 0x75D7, 0xAF64, 0x75D9, 0xAF65, 0x75DA, 0xAF66, 0x75DC,\t0xAF67, 0x75DD, 0xAF68, 0x75DF, 0xAF69, 0x75E0, 0xAF6A, 0x75E1,\r\n\t0xAF6B, 0x75E5, 0xAF6C, 0x75E9, 0xAF6D, 0x75EC, 0xAF6E, 0x75ED,\t0xAF6F, 0x75EE, 0xAF70, 0x75EF, 0xAF71, 0x75F2, 0xAF72, 0x75F3,\r\n\t0xAF73, 0x75F5, 0xAF74, 0x75F6, 0xAF75, 0x75F7, 0xAF76, 0x75F8,\t0xAF77, 0x75FA, 0xAF78, 0x75FB, 0xAF79, 0x75FD, 0xAF7A, 0x75FE,\r\n\t0xAF7B, 0x7602, 0xAF7C, 0x7604, 0xAF7D, 0x7606, 0xAF7E, 0x7607,\t0xAF80, 0x7608, 0xAF81, 0x7609, 0xAF82, 0x760B, 0xAF83, 0x760D,\r\n\t0xAF84, 0x760E, 0xAF85, 0x760F, 0xAF86, 0x7611, 0xAF87, 0x7612,\t0xAF88, 0x7613, 0xAF89, 0x7614, 0xAF8A, 0x7616, 0xAF8B, 0x761A,\r\n\t0xAF8C, 0x761C, 0xAF8D, 0x761D, 0xAF8E, 0x761E, 0xAF8F, 0x7621,\t0xAF90, 0x7623, 0xAF91, 0x7627, 0xAF92, 0x7628, 0xAF93, 0x762C,\r\n\t0xAF94, 0x762E, 0xAF95, 0x762F, 0xAF96, 0x7631, 0xAF97, 0x7632,\t0xAF98, 0x7636, 0xAF99, 0x7637, 0xAF9A, 0x7639, 0xAF9B, 0x763A,\r\n\t0xAF9C, 0x763B, 0xAF9D, 0x763D, 0xAF9E, 0x7641, 0xAF9F, 0x7642,\t0xAFA0, 0x7644, 0xB040, 0x7645, 0xB041, 0x7646, 0xB042, 0x7647,\r\n\t0xB043, 0x7648, 0xB044, 0x7649, 0xB045, 0x764A, 0xB046, 0x764B,\t0xB047, 0x764E, 0xB048, 0x764F, 0xB049, 0x7650, 0xB04A, 0x7651,\r\n\t0xB04B, 0x7652, 0xB04C, 0x7653, 0xB04D, 0x7655, 0xB04E, 0x7657,\t0xB04F, 0x7658, 0xB050, 0x7659, 0xB051, 0x765A, 0xB052, 0x765B,\r\n\t0xB053, 0x765D, 0xB054, 0x765F, 0xB055, 0x7660, 0xB056, 0x7661,\t0xB057, 0x7662, 0xB058, 0x7664, 0xB059, 0x7665, 0xB05A, 0x7666,\r\n\t0xB05B, 0x7667, 0xB05C, 0x7668, 0xB05D, 0x7669, 0xB05E, 0x766A,\t0xB05F, 0x766C, 0xB060, 0x766D, 0xB061, 0x766E, 0xB062, 0x7670,\r\n\t0xB063, 0x7671, 0xB064, 0x7672, 0xB065, 0x7673, 0xB066, 0x7674,\t0xB067, 0x7675, 0xB068, 0x7676, 0xB069, 0x7677, 0xB06A, 0x7679,\r\n\t0xB06B, 0x767A, 0xB06C, 0x767C, 0xB06D, 0x767F, 0xB06E, 0x7680,\t0xB06F, 0x7681, 0xB070, 0x7683, 0xB071, 0x7685, 0xB072, 0x7689,\r\n\t0xB073, 0x768A, 0xB074, 0x768C, 0xB075, 0x768D, 0xB076, 0x768F,\t0xB077, 0x7690, 0xB078, 0x7692, 0xB079, 0x7694, 0xB07A, 0x7695,\r\n\t0xB07B, 0x7697, 0xB07C, 0x7698, 0xB07D, 0x769A, 0xB07E, 0x769B,\t0xB080, 0x769C, 0xB081, 0x769D, 0xB082, 0x769E, 0xB083, 0x769F,\r\n\t0xB084, 0x76A0, 0xB085, 0x76A1, 0xB086, 0x76A2, 0xB087, 0x76A3,\t0xB088, 0x76A5, 0xB089, 0x76A6, 0xB08A, 0x76A7, 0xB08B, 0x76A8,\r\n\t0xB08C, 0x76A9, 0xB08D, 0x76AA, 0xB08E, 0x76AB, 0xB08F, 0x76AC,\t0xB090, 0x76AD, 0xB091, 0x76AF, 0xB092, 0x76B0, 0xB093, 0x76B3,\r\n\t0xB094, 0x76B5, 0xB095, 0x76B6, 0xB096, 0x76B7, 0xB097, 0x76B8,\t0xB098, 0x76B9, 0xB099, 0x76BA, 0xB09A, 0x76BB, 0xB09B, 0x76BC,\r\n\t0xB09C, 0x76BD, 0xB09D, 0x76BE, 0xB09E, 0x76C0, 0xB09F, 0x76C1,\t0xB0A0, 0x76C3, 0xB0A1, 0x554A, 0xB0A2, 0x963F, 0xB0A3, 0x57C3,\r\n\t0xB0A4, 0x6328, 0xB0A5, 0x54CE, 0xB0A6, 0x5509, 0xB0A7, 0x54C0,\t0xB0A8, 0x7691, 0xB0A9, 0x764C, 0xB0AA, 0x853C, 0xB0AB, 0x77EE,\r\n\t0xB0AC, 0x827E, 0xB0AD, 0x788D, 0xB0AE, 0x7231, 0xB0AF, 0x9698,\t0xB0B0, 0x978D, 0xB0B1, 0x6C28, 0xB0B2, 0x5B89, 0xB0B3, 0x4FFA,\r\n\t0xB0B4, 0x6309, 0xB0B5, 0x6697, 0xB0B6, 0x5CB8, 0xB0B7, 0x80FA,\t0xB0B8, 0x6848, 0xB0B9, 0x80AE, 0xB0BA, 0x6602, 0xB0BB, 0x76CE,\r\n\t0xB0BC, 0x51F9, 0xB0BD, 0x6556, 0xB0BE, 0x71AC, 0xB0BF, 0x7FF1,\t0xB0C0, 0x8884, 0xB0C1, 0x50B2, 0xB0C2, 0x5965, 0xB0C3, 0x61CA,\r\n\t0xB0C4, 0x6FB3, 0xB0C5, 0x82AD, 0xB0C6, 0x634C, 0xB0C7, 0x6252,\t0xB0C8, 0x53ED, 0xB0C9, 0x5427, 0xB0CA, 0x7B06, 0xB0CB, 0x516B,\r\n\t0xB0CC, 0x75A4, 0xB0CD, 0x5DF4, 0xB0CE, 0x62D4, 0xB0CF, 0x8DCB,\t0xB0D0, 0x9776, 0xB0D1, 0x628A, 0xB0D2, 0x8019, 0xB0D3, 0x575D,\r\n\t0xB0D4, 0x9738, 0xB0D5, 0x7F62, 0xB0D6, 0x7238, 0xB0D7, 0x767D,\t0xB0D8, 0x67CF, 0xB0D9, 0x767E, 0xB0DA, 0x6446, 0xB0DB, 0x4F70,\r\n\t0xB0DC, 0x8D25, 0xB0DD, 0x62DC, 0xB0DE, 0x7A17, 0xB0DF, 0x6591,\t0xB0E0, 0x73ED, 0xB0E1, 0x642C, 0xB0E2, 0x6273, 0xB0E3, 0x822C,\r\n\t0xB0E4, 0x9881, 0xB0E5, 0x677F, 0xB0E6, 0x7248, 0xB0E7, 0x626E,\t0xB0E8, 0x62CC, 0xB0E9, 0x4F34, 0xB0EA, 0x74E3, 0xB0EB, 0x534A,\r\n\t0xB0EC, 0x529E, 0xB0ED, 0x7ECA, 0xB0EE, 0x90A6, 0xB0EF, 0x5E2E,\t0xB0F0, 0x6886, 0xB0F1, 0x699C, 0xB0F2, 0x8180, 0xB0F3, 0x7ED1,\r\n\t0xB0F4, 0x68D2, 0xB0F5, 0x78C5, 0xB0F6, 0x868C, 0xB0F7, 0x9551,\t0xB0F8, 0x508D, 0xB0F9, 0x8C24, 0xB0FA, 0x82DE, 0xB0FB, 0x80DE,\r\n\t0xB0FC, 0x5305, 0xB0FD, 0x8912, 0xB0FE, 0x5265, 0xB140, 0x76C4,\t0xB141, 0x76C7, 0xB142, 0x76C9, 0xB143, 0x76CB, 0xB144, 0x76CC,\r\n\t0xB145, 0x76D3, 0xB146, 0x76D5, 0xB147, 0x76D9, 0xB148, 0x76DA,\t0xB149, 0x76DC, 0xB14A, 0x76DD, 0xB14B, 0x76DE, 0xB14C, 0x76E0,\r\n\t0xB14D, 0x76E1, 0xB14E, 0x76E2, 0xB14F, 0x76E3, 0xB150, 0x76E4,\t0xB151, 0x76E6, 0xB152, 0x76E7, 0xB153, 0x76E8, 0xB154, 0x76E9,\r\n\t0xB155, 0x76EA, 0xB156, 0x76EB, 0xB157, 0x76EC, 0xB158, 0x76ED,\t0xB159, 0x76F0, 0xB15A, 0x76F3, 0xB15B, 0x76F5, 0xB15C, 0x76F6,\r\n\t0xB15D, 0x76F7, 0xB15E, 0x76FA, 0xB15F, 0x76FB, 0xB160, 0x76FD,\t0xB161, 0x76FF, 0xB162, 0x7700, 0xB163, 0x7702, 0xB164, 0x7703,\r\n\t0xB165, 0x7705, 0xB166, 0x7706, 0xB167, 0x770A, 0xB168, 0x770C,\t0xB169, 0x770E, 0xB16A, 0x770F, 0xB16B, 0x7710, 0xB16C, 0x7711,\r\n\t0xB16D, 0x7712, 0xB16E, 0x7713, 0xB16F, 0x7714, 0xB170, 0x7715,\t0xB171, 0x7716, 0xB172, 0x7717, 0xB173, 0x7718, 0xB174, 0x771B,\r\n\t0xB175, 0x771C, 0xB176, 0x771D, 0xB177, 0x771E, 0xB178, 0x7721,\t0xB179, 0x7723, 0xB17A, 0x7724, 0xB17B, 0x7725, 0xB17C, 0x7727,\r\n\t0xB17D, 0x772A, 0xB17E, 0x772B, 0xB180, 0x772C, 0xB181, 0x772E,\t0xB182, 0x7730, 0xB183, 0x7731, 0xB184, 0x7732, 0xB185, 0x7733,\r\n\t0xB186, 0x7734, 0xB187, 0x7739, 0xB188, 0x773B, 0xB189, 0x773D,\t0xB18A, 0x773E, 0xB18B, 0x773F, 0xB18C, 0x7742, 0xB18D, 0x7744,\r\n\t0xB18E, 0x7745, 0xB18F, 0x7746, 0xB190, 0x7748, 0xB191, 0x7749,\t0xB192, 0x774A, 0xB193, 0x774B, 0xB194, 0x774C, 0xB195, 0x774D,\r\n\t0xB196, 0x774E, 0xB197, 0x774F, 0xB198, 0x7752, 0xB199, 0x7753,\t0xB19A, 0x7754, 0xB19B, 0x7755, 0xB19C, 0x7756, 0xB19D, 0x7757,\r\n\t0xB19E, 0x7758, 0xB19F, 0x7759, 0xB1A0, 0x775C, 0xB1A1, 0x8584,\t0xB1A2, 0x96F9, 0xB1A3, 0x4FDD, 0xB1A4, 0x5821, 0xB1A5, 0x9971,\r\n\t0xB1A6, 0x5B9D, 0xB1A7, 0x62B1, 0xB1A8, 0x62A5, 0xB1A9, 0x66B4,\t0xB1AA, 0x8C79, 0xB1AB, 0x9C8D, 0xB1AC, 0x7206, 0xB1AD, 0x676F,\r\n\t0xB1AE, 0x7891, 0xB1AF, 0x60B2, 0xB1B0, 0x5351, 0xB1B1, 0x5317,\t0xB1B2, 0x8F88, 0xB1B3, 0x80CC, 0xB1B4, 0x8D1D, 0xB1B5, 0x94A1,\r\n\t0xB1B6, 0x500D, 0xB1B7, 0x72C8, 0xB1B8, 0x5907, 0xB1B9, 0x60EB,\t0xB1BA, 0x7119, 0xB1BB, 0x88AB, 0xB1BC, 0x5954, 0xB1BD, 0x82EF,\r\n\t0xB1BE, 0x672C, 0xB1BF, 0x7B28, 0xB1C0, 0x5D29, 0xB1C1, 0x7EF7,\t0xB1C2, 0x752D, 0xB1C3, 0x6CF5, 0xB1C4, 0x8E66, 0xB1C5, 0x8FF8,\r\n\t0xB1C6, 0x903C, 0xB1C7, 0x9F3B, 0xB1C8, 0x6BD4, 0xB1C9, 0x9119,\t0xB1CA, 0x7B14, 0xB1CB, 0x5F7C, 0xB1CC, 0x78A7, 0xB1CD, 0x84D6,\r\n\t0xB1CE, 0x853D, 0xB1CF, 0x6BD5, 0xB1D0, 0x6BD9, 0xB1D1, 0x6BD6,\t0xB1D2, 0x5E01, 0xB1D3, 0x5E87, 0xB1D4, 0x75F9, 0xB1D5, 0x95ED,\r\n\t0xB1D6, 0x655D, 0xB1D7, 0x5F0A, 0xB1D8, 0x5FC5, 0xB1D9, 0x8F9F,\t0xB1DA, 0x58C1, 0xB1DB, 0x81C2, 0xB1DC, 0x907F, 0xB1DD, 0x965B,\r\n\t0xB1DE, 0x97AD, 0xB1DF, 0x8FB9, 0xB1E0, 0x7F16, 0xB1E1, 0x8D2C,\t0xB1E2, 0x6241, 0xB1E3, 0x4FBF, 0xB1E4, 0x53D8, 0xB1E5, 0x535E,\r\n\t0xB1E6, 0x8FA8, 0xB1E7, 0x8FA9, 0xB1E8, 0x8FAB, 0xB1E9, 0x904D,\t0xB1EA, 0x6807, 0xB1EB, 0x5F6A, 0xB1EC, 0x8198, 0xB1ED, 0x8868,\r\n\t0xB1EE, 0x9CD6, 0xB1EF, 0x618B, 0xB1F0, 0x522B, 0xB1F1, 0x762A,\t0xB1F2, 0x5F6C, 0xB1F3, 0x658C, 0xB1F4, 0x6FD2, 0xB1F5, 0x6EE8,\r\n\t0xB1F6, 0x5BBE, 0xB1F7, 0x6448, 0xB1F8, 0x5175, 0xB1F9, 0x51B0,\t0xB1FA, 0x67C4, 0xB1FB, 0x4E19, 0xB1FC, 0x79C9, 0xB1FD, 0x997C,\r\n\t0xB1FE, 0x70B3, 0xB240, 0x775D, 0xB241, 0x775E, 0xB242, 0x775F,\t0xB243, 0x7760, 0xB244, 0x7764, 0xB245, 0x7767, 0xB246, 0x7769,\r\n\t0xB247, 0x776A, 0xB248, 0x776D, 0xB249, 0x776E, 0xB24A, 0x776F,\t0xB24B, 0x7770, 0xB24C, 0x7771, 0xB24D, 0x7772, 0xB24E, 0x7773,\r\n\t0xB24F, 0x7774, 0xB250, 0x7775, 0xB251, 0x7776, 0xB252, 0x7777,\t0xB253, 0x7778, 0xB254, 0x777A, 0xB255, 0x777B, 0xB256, 0x777C,\r\n\t0xB257, 0x7781, 0xB258, 0x7782, 0xB259, 0x7783, 0xB25A, 0x7786,\t0xB25B, 0x7787, 0xB25C, 0x7788, 0xB25D, 0x7789, 0xB25E, 0x778A,\r\n\t0xB25F, 0x778B, 0xB260, 0x778F, 0xB261, 0x7790, 0xB262, 0x7793,\t0xB263, 0x7794, 0xB264, 0x7795, 0xB265, 0x7796, 0xB266, 0x7797,\r\n\t0xB267, 0x7798, 0xB268, 0x7799, 0xB269, 0x779A, 0xB26A, 0x779B,\t0xB26B, 0x779C, 0xB26C, 0x779D, 0xB26D, 0x779E, 0xB26E, 0x77A1,\r\n\t0xB26F, 0x77A3, 0xB270, 0x77A4, 0xB271, 0x77A6, 0xB272, 0x77A8,\t0xB273, 0x77AB, 0xB274, 0x77AD, 0xB275, 0x77AE, 0xB276, 0x77AF,\r\n\t0xB277, 0x77B1, 0xB278, 0x77B2, 0xB279, 0x77B4, 0xB27A, 0x77B6,\t0xB27B, 0x77B7, 0xB27C, 0x77B8, 0xB27D, 0x77B9, 0xB27E, 0x77BA,\r\n\t0xB280, 0x77BC, 0xB281, 0x77BE, 0xB282, 0x77C0, 0xB283, 0x77C1,\t0xB284, 0x77C2, 0xB285, 0x77C3, 0xB286, 0x77C4, 0xB287, 0x77C5,\r\n\t0xB288, 0x77C6, 0xB289, 0x77C7, 0xB28A, 0x77C8, 0xB28B, 0x77C9,\t0xB28C, 0x77CA, 0xB28D, 0x77CB, 0xB28E, 0x77CC, 0xB28F, 0x77CE,\r\n\t0xB290, 0x77CF, 0xB291, 0x77D0, 0xB292, 0x77D1, 0xB293, 0x77D2,\t0xB294, 0x77D3, 0xB295, 0x77D4, 0xB296, 0x77D5, 0xB297, 0x77D6,\r\n\t0xB298, 0x77D8, 0xB299, 0x77D9, 0xB29A, 0x77DA, 0xB29B, 0x77DD,\t0xB29C, 0x77DE, 0xB29D, 0x77DF, 0xB29E, 0x77E0, 0xB29F, 0x77E1,\r\n\t0xB2A0, 0x77E4, 0xB2A1, 0x75C5, 0xB2A2, 0x5E76, 0xB2A3, 0x73BB,\t0xB2A4, 0x83E0, 0xB2A5, 0x64AD, 0xB2A6, 0x62E8, 0xB2A7, 0x94B5,\r\n\t0xB2A8, 0x6CE2, 0xB2A9, 0x535A, 0xB2AA, 0x52C3, 0xB2AB, 0x640F,\t0xB2AC, 0x94C2, 0xB2AD, 0x7B94, 0xB2AE, 0x4F2F, 0xB2AF, 0x5E1B,\r\n\t0xB2B0, 0x8236, 0xB2B1, 0x8116, 0xB2B2, 0x818A, 0xB2B3, 0x6E24,\t0xB2B4, 0x6CCA, 0xB2B5, 0x9A73, 0xB2B6, 0x6355, 0xB2B7, 0x535C,\r\n\t0xB2B8, 0x54FA, 0xB2B9, 0x8865, 0xB2BA, 0x57E0, 0xB2BB, 0x4E0D,\t0xB2BC, 0x5E03, 0xB2BD, 0x6B65, 0xB2BE, 0x7C3F, 0xB2BF, 0x90E8,\r\n\t0xB2C0, 0x6016, 0xB2C1, 0x64E6, 0xB2C2, 0x731C, 0xB2C3, 0x88C1,\t0xB2C4, 0x6750, 0xB2C5, 0x624D, 0xB2C6, 0x8D22, 0xB2C7, 0x776C,\r\n\t0xB2C8, 0x8E29, 0xB2C9, 0x91C7, 0xB2CA, 0x5F69, 0xB2CB, 0x83DC,\t0xB2CC, 0x8521, 0xB2CD, 0x9910, 0xB2CE, 0x53C2, 0xB2CF, 0x8695,\r\n\t0xB2D0, 0x6B8B, 0xB2D1, 0x60ED, 0xB2D2, 0x60E8, 0xB2D3, 0x707F,\t0xB2D4, 0x82CD, 0xB2D5, 0x8231, 0xB2D6, 0x4ED3, 0xB2D7, 0x6CA7,\r\n\t0xB2D8, 0x85CF, 0xB2D9, 0x64CD, 0xB2DA, 0x7CD9, 0xB2DB, 0x69FD,\t0xB2DC, 0x66F9, 0xB2DD, 0x8349, 0xB2DE, 0x5395, 0xB2DF, 0x7B56,\r\n\t0xB2E0, 0x4FA7, 0xB2E1, 0x518C, 0xB2E2, 0x6D4B, 0xB2E3, 0x5C42,\t0xB2E4, 0x8E6D, 0xB2E5, 0x63D2, 0xB2E6, 0x53C9, 0xB2E7, 0x832C,\r\n\t0xB2E8, 0x8336, 0xB2E9, 0x67E5, 0xB2EA, 0x78B4, 0xB2EB, 0x643D,\t0xB2EC, 0x5BDF, 0xB2ED, 0x5C94, 0xB2EE, 0x5DEE, 0xB2EF, 0x8BE7,\r\n\t0xB2F0, 0x62C6, 0xB2F1, 0x67F4, 0xB2F2, 0x8C7A, 0xB2F3, 0x6400,\t0xB2F4, 0x63BA, 0xB2F5, 0x8749, 0xB2F6, 0x998B, 0xB2F7, 0x8C17,\r\n\t0xB2F8, 0x7F20, 0xB2F9, 0x94F2, 0xB2FA, 0x4EA7, 0xB2FB, 0x9610,\t0xB2FC, 0x98A4, 0xB2FD, 0x660C, 0xB2FE, 0x7316, 0xB340, 0x77E6,\r\n\t0xB341, 0x77E8, 0xB342, 0x77EA, 0xB343, 0x77EF, 0xB344, 0x77F0,\t0xB345, 0x77F1, 0xB346, 0x77F2, 0xB347, 0x77F4, 0xB348, 0x77F5,\r\n\t0xB349, 0x77F7, 0xB34A, 0x77F9, 0xB34B, 0x77FA, 0xB34C, 0x77FB,\t0xB34D, 0x77FC, 0xB34E, 0x7803, 0xB34F, 0x7804, 0xB350, 0x7805,\r\n\t0xB351, 0x7806, 0xB352, 0x7807, 0xB353, 0x7808, 0xB354, 0x780A,\t0xB355, 0x780B, 0xB356, 0x780E, 0xB357, 0x780F, 0xB358, 0x7810,\r\n\t0xB359, 0x7813, 0xB35A, 0x7815, 0xB35B, 0x7819, 0xB35C, 0x781B,\t0xB35D, 0x781E, 0xB35E, 0x7820, 0xB35F, 0x7821, 0xB360, 0x7822,\r\n\t0xB361, 0x7824, 0xB362, 0x7828, 0xB363, 0x782A, 0xB364, 0x782B,\t0xB365, 0x782E, 0xB366, 0x782F, 0xB367, 0x7831, 0xB368, 0x7832,\r\n\t0xB369, 0x7833, 0xB36A, 0x7835, 0xB36B, 0x7836, 0xB36C, 0x783D,\t0xB36D, 0x783F, 0xB36E, 0x7841, 0xB36F, 0x7842, 0xB370, 0x7843,\r\n\t0xB371, 0x7844, 0xB372, 0x7846, 0xB373, 0x7848, 0xB374, 0x7849,\t0xB375, 0x784A, 0xB376, 0x784B, 0xB377, 0x784D, 0xB378, 0x784F,\r\n\t0xB379, 0x7851, 0xB37A, 0x7853, 0xB37B, 0x7854, 0xB37C, 0x7858,\t0xB37D, 0x7859, 0xB37E, 0x785A, 0xB380, 0x785B, 0xB381, 0x785C,\r\n\t0xB382, 0x785E, 0xB383, 0x785F, 0xB384, 0x7860, 0xB385, 0x7861,\t0xB386, 0x7862, 0xB387, 0x7863, 0xB388, 0x7864, 0xB389, 0x7865,\r\n\t0xB38A, 0x7866, 0xB38B, 0x7867, 0xB38C, 0x7868, 0xB38D, 0x7869,\t0xB38E, 0x786F, 0xB38F, 0x7870, 0xB390, 0x7871, 0xB391, 0x7872,\r\n\t0xB392, 0x7873, 0xB393, 0x7874, 0xB394, 0x7875, 0xB395, 0x7876,\t0xB396, 0x7878, 0xB397, 0x7879, 0xB398, 0x787A, 0xB399, 0x787B,\r\n\t0xB39A, 0x787D, 0xB39B, 0x787E, 0xB39C, 0x787F, 0xB39D, 0x7880,\t0xB39E, 0x7881, 0xB39F, 0x7882, 0xB3A0, 0x7883, 0xB3A1, 0x573A,\r\n\t0xB3A2, 0x5C1D, 0xB3A3, 0x5E38, 0xB3A4, 0x957F, 0xB3A5, 0x507F,\t0xB3A6, 0x80A0, 0xB3A7, 0x5382, 0xB3A8, 0x655E, 0xB3A9, 0x7545,\r\n\t0xB3AA, 0x5531, 0xB3AB, 0x5021, 0xB3AC, 0x8D85, 0xB3AD, 0x6284,\t0xB3AE, 0x949E, 0xB3AF, 0x671D, 0xB3B0, 0x5632, 0xB3B1, 0x6F6E,\r\n\t0xB3B2, 0x5DE2, 0xB3B3, 0x5435, 0xB3B4, 0x7092, 0xB3B5, 0x8F66,\t0xB3B6, 0x626F, 0xB3B7, 0x64A4, 0xB3B8, 0x63A3, 0xB3B9, 0x5F7B,\r\n\t0xB3BA, 0x6F88, 0xB3BB, 0x90F4, 0xB3BC, 0x81E3, 0xB3BD, 0x8FB0,\t0xB3BE, 0x5C18, 0xB3BF, 0x6668, 0xB3C0, 0x5FF1, 0xB3C1, 0x6C89,\r\n\t0xB3C2, 0x9648, 0xB3C3, 0x8D81, 0xB3C4, 0x886C, 0xB3C5, 0x6491,\t0xB3C6, 0x79F0, 0xB3C7, 0x57CE, 0xB3C8, 0x6A59, 0xB3C9, 0x6210,\r\n\t0xB3CA, 0x5448, 0xB3CB, 0x4E58, 0xB3CC, 0x7A0B, 0xB3CD, 0x60E9,\t0xB3CE, 0x6F84, 0xB3CF, 0x8BDA, 0xB3D0, 0x627F, 0xB3D1, 0x901E,\r\n\t0xB3D2, 0x9A8B, 0xB3D3, 0x79E4, 0xB3D4, 0x5403, 0xB3D5, 0x75F4,\t0xB3D6, 0x6301, 0xB3D7, 0x5319, 0xB3D8, 0x6C60, 0xB3D9, 0x8FDF,\r\n\t0xB3DA, 0x5F1B, 0xB3DB, 0x9A70, 0xB3DC, 0x803B, 0xB3DD, 0x9F7F,\t0xB3DE, 0x4F88, 0xB3DF, 0x5C3A, 0xB3E0, 0x8D64, 0xB3E1, 0x7FC5,\r\n\t0xB3E2, 0x65A5, 0xB3E3, 0x70BD, 0xB3E4, 0x5145, 0xB3E5, 0x51B2,\t0xB3E6, 0x866B, 0xB3E7, 0x5D07, 0xB3E8, 0x5BA0, 0xB3E9, 0x62BD,\r\n\t0xB3EA, 0x916C, 0xB3EB, 0x7574, 0xB3EC, 0x8E0C, 0xB3ED, 0x7A20,\t0xB3EE, 0x6101, 0xB3EF, 0x7B79, 0xB3F0, 0x4EC7, 0xB3F1, 0x7EF8,\r\n\t0xB3F2, 0x7785, 0xB3F3, 0x4E11, 0xB3F4, 0x81ED, 0xB3F5, 0x521D,\t0xB3F6, 0x51FA, 0xB3F7, 0x6A71, 0xB3F8, 0x53A8, 0xB3F9, 0x8E87,\r\n\t0xB3FA, 0x9504, 0xB3FB, 0x96CF, 0xB3FC, 0x6EC1, 0xB3FD, 0x9664,\t0xB3FE, 0x695A, 0xB440, 0x7884, 0xB441, 0x7885, 0xB442, 0x7886,\r\n\t0xB443, 0x7888, 0xB444, 0x788A, 0xB445, 0x788B, 0xB446, 0x788F,\t0xB447, 0x7890, 0xB448, 0x7892, 0xB449, 0x7894, 0xB44A, 0x7895,\r\n\t0xB44B, 0x7896, 0xB44C, 0x7899, 0xB44D, 0x789D, 0xB44E, 0x789E,\t0xB44F, 0x78A0, 0xB450, 0x78A2, 0xB451, 0x78A4, 0xB452, 0x78A6,\r\n\t0xB453, 0x78A8, 0xB454, 0x78A9, 0xB455, 0x78AA, 0xB456, 0x78AB,\t0xB457, 0x78AC, 0xB458, 0x78AD, 0xB459, 0x78AE, 0xB45A, 0x78AF,\r\n\t0xB45B, 0x78B5, 0xB45C, 0x78B6, 0xB45D, 0x78B7, 0xB45E, 0x78B8,\t0xB45F, 0x78BA, 0xB460, 0x78BB, 0xB461, 0x78BC, 0xB462, 0x78BD,\r\n\t0xB463, 0x78BF, 0xB464, 0x78C0, 0xB465, 0x78C2, 0xB466, 0x78C3,\t0xB467, 0x78C4, 0xB468, 0x78C6, 0xB469, 0x78C7, 0xB46A, 0x78C8,\r\n\t0xB46B, 0x78CC, 0xB46C, 0x78CD, 0xB46D, 0x78CE, 0xB46E, 0x78CF,\t0xB46F, 0x78D1, 0xB470, 0x78D2, 0xB471, 0x78D3, 0xB472, 0x78D6,\r\n\t0xB473, 0x78D7, 0xB474, 0x78D8, 0xB475, 0x78DA, 0xB476, 0x78DB,\t0xB477, 0x78DC, 0xB478, 0x78DD, 0xB479, 0x78DE, 0xB47A, 0x78DF,\r\n\t0xB47B, 0x78E0, 0xB47C, 0x78E1, 0xB47D, 0x78E2, 0xB47E, 0x78E3,\t0xB480, 0x78E4, 0xB481, 0x78E5, 0xB482, 0x78E6, 0xB483, 0x78E7,\r\n\t0xB484, 0x78E9, 0xB485, 0x78EA, 0xB486, 0x78EB, 0xB487, 0x78ED,\t0xB488, 0x78EE, 0xB489, 0x78EF, 0xB48A, 0x78F0, 0xB48B, 0x78F1,\r\n\t0xB48C, 0x78F3, 0xB48D, 0x78F5, 0xB48E, 0x78F6, 0xB48F, 0x78F8,\t0xB490, 0x78F9, 0xB491, 0x78FB, 0xB492, 0x78FC, 0xB493, 0x78FD,\r\n\t0xB494, 0x78FE, 0xB495, 0x78FF, 0xB496, 0x7900, 0xB497, 0x7902,\t0xB498, 0x7903, 0xB499, 0x7904, 0xB49A, 0x7906, 0xB49B, 0x7907,\r\n\t0xB49C, 0x7908, 0xB49D, 0x7909, 0xB49E, 0x790A, 0xB49F, 0x790B,\t0xB4A0, 0x790C, 0xB4A1, 0x7840, 0xB4A2, 0x50A8, 0xB4A3, 0x77D7,\r\n\t0xB4A4, 0x6410, 0xB4A5, 0x89E6, 0xB4A6, 0x5904, 0xB4A7, 0x63E3,\t0xB4A8, 0x5DDD, 0xB4A9, 0x7A7F, 0xB4AA, 0x693D, 0xB4AB, 0x4F20,\r\n\t0xB4AC, 0x8239, 0xB4AD, 0x5598, 0xB4AE, 0x4E32, 0xB4AF, 0x75AE,\t0xB4B0, 0x7A97, 0xB4B1, 0x5E62, 0xB4B2, 0x5E8A, 0xB4B3, 0x95EF,\r\n\t0xB4B4, 0x521B, 0xB4B5, 0x5439, 0xB4B6, 0x708A, 0xB4B7, 0x6376,\t0xB4B8, 0x9524, 0xB4B9, 0x5782, 0xB4BA, 0x6625, 0xB4BB, 0x693F,\r\n\t0xB4BC, 0x9187, 0xB4BD, 0x5507, 0xB4BE, 0x6DF3, 0xB4BF, 0x7EAF,\t0xB4C0, 0x8822, 0xB4C1, 0x6233, 0xB4C2, 0x7EF0, 0xB4C3, 0x75B5,\r\n\t0xB4C4, 0x8328, 0xB4C5, 0x78C1, 0xB4C6, 0x96CC, 0xB4C7, 0x8F9E,\t0xB4C8, 0x6148, 0xB4C9, 0x74F7, 0xB4CA, 0x8BCD, 0xB4CB, 0x6B64,\r\n\t0xB4CC, 0x523A, 0xB4CD, 0x8D50, 0xB4CE, 0x6B21, 0xB4CF, 0x806A,\t0xB4D0, 0x8471, 0xB4D1, 0x56F1, 0xB4D2, 0x5306, 0xB4D3, 0x4ECE,\r\n\t0xB4D4, 0x4E1B, 0xB4D5, 0x51D1, 0xB4D6, 0x7C97, 0xB4D7, 0x918B,\t0xB4D8, 0x7C07, 0xB4D9, 0x4FC3, 0xB4DA, 0x8E7F, 0xB4DB, 0x7BE1,\r\n\t0xB4DC, 0x7A9C, 0xB4DD, 0x6467, 0xB4DE, 0x5D14, 0xB4DF, 0x50AC,\t0xB4E0, 0x8106, 0xB4E1, 0x7601, 0xB4E2, 0x7CB9, 0xB4E3, 0x6DEC,\r\n\t0xB4E4, 0x7FE0, 0xB4E5, 0x6751, 0xB4E6, 0x5B58, 0xB4E7, 0x5BF8,\t0xB4E8, 0x78CB, 0xB4E9, 0x64AE, 0xB4EA, 0x6413, 0xB4EB, 0x63AA,\r\n\t0xB4EC, 0x632B, 0xB4ED, 0x9519, 0xB4EE, 0x642D, 0xB4EF, 0x8FBE,\t0xB4F0, 0x7B54, 0xB4F1, 0x7629, 0xB4F2, 0x6253, 0xB4F3, 0x5927,\r\n\t0xB4F4, 0x5446, 0xB4F5, 0x6B79, 0xB4F6, 0x50A3, 0xB4F7, 0x6234,\t0xB4F8, 0x5E26, 0xB4F9, 0x6B86, 0xB4FA, 0x4EE3, 0xB4FB, 0x8D37,\r\n\t0xB4FC, 0x888B, 0xB4FD, 0x5F85, 0xB4FE, 0x902E, 0xB540, 0x790D,\t0xB541, 0x790E, 0xB542, 0x790F, 0xB543, 0x7910, 0xB544, 0x7911,\r\n\t0xB545, 0x7912, 0xB546, 0x7914, 0xB547, 0x7915, 0xB548, 0x7916,\t0xB549, 0x7917, 0xB54A, 0x7918, 0xB54B, 0x7919, 0xB54C, 0x791A,\r\n\t0xB54D, 0x791B, 0xB54E, 0x791C, 0xB54F, 0x791D, 0xB550, 0x791F,\t0xB551, 0x7920, 0xB552, 0x7921, 0xB553, 0x7922, 0xB554, 0x7923,\r\n\t0xB555, 0x7925, 0xB556, 0x7926, 0xB557, 0x7927, 0xB558, 0x7928,\t0xB559, 0x7929, 0xB55A, 0x792A, 0xB55B, 0x792B, 0xB55C, 0x792C,\r\n\t0xB55D, 0x792D, 0xB55E, 0x792E, 0xB55F, 0x792F, 0xB560, 0x7930,\t0xB561, 0x7931, 0xB562, 0x7932, 0xB563, 0x7933, 0xB564, 0x7935,\r\n\t0xB565, 0x7936, 0xB566, 0x7937, 0xB567, 0x7938, 0xB568, 0x7939,\t0xB569, 0x793D, 0xB56A, 0x793F, 0xB56B, 0x7942, 0xB56C, 0x7943,\r\n\t0xB56D, 0x7944, 0xB56E, 0x7945, 0xB56F, 0x7947, 0xB570, 0x794A,\t0xB571, 0x794B, 0xB572, 0x794C, 0xB573, 0x794D, 0xB574, 0x794E,\r\n\t0xB575, 0x794F, 0xB576, 0x7950, 0xB577, 0x7951, 0xB578, 0x7952,\t0xB579, 0x7954, 0xB57A, 0x7955, 0xB57B, 0x7958, 0xB57C, 0x7959,\r\n\t0xB57D, 0x7961, 0xB57E, 0x7963, 0xB580, 0x7964, 0xB581, 0x7966,\t0xB582, 0x7969, 0xB583, 0x796A, 0xB584, 0x796B, 0xB585, 0x796C,\r\n\t0xB586, 0x796E, 0xB587, 0x7970, 0xB588, 0x7971, 0xB589, 0x7972,\t0xB58A, 0x7973, 0xB58B, 0x7974, 0xB58C, 0x7975, 0xB58D, 0x7976,\r\n\t0xB58E, 0x7979, 0xB58F, 0x797B, 0xB590, 0x797C, 0xB591, 0x797D,\t0xB592, 0x797E, 0xB593, 0x797F, 0xB594, 0x7982, 0xB595, 0x7983,\r\n\t0xB596, 0x7986, 0xB597, 0x7987, 0xB598, 0x7988, 0xB599, 0x7989,\t0xB59A, 0x798B, 0xB59B, 0x798C, 0xB59C, 0x798D, 0xB59D, 0x798E,\r\n\t0xB59E, 0x7990, 0xB59F, 0x7991, 0xB5A0, 0x7992, 0xB5A1, 0x6020,\t0xB5A2, 0x803D, 0xB5A3, 0x62C5, 0xB5A4, 0x4E39, 0xB5A5, 0x5355,\r\n\t0xB5A6, 0x90F8, 0xB5A7, 0x63B8, 0xB5A8, 0x80C6, 0xB5A9, 0x65E6,\t0xB5AA, 0x6C2E, 0xB5AB, 0x4F46, 0xB5AC, 0x60EE, 0xB5AD, 0x6DE1,\r\n\t0xB5AE, 0x8BDE, 0xB5AF, 0x5F39, 0xB5B0, 0x86CB, 0xB5B1, 0x5F53,\t0xB5B2, 0x6321, 0xB5B3, 0x515A, 0xB5B4, 0x8361, 0xB5B5, 0x6863,\r\n\t0xB5B6, 0x5200, 0xB5B7, 0x6363, 0xB5B8, 0x8E48, 0xB5B9, 0x5012,\t0xB5BA, 0x5C9B, 0xB5BB, 0x7977, 0xB5BC, 0x5BFC, 0xB5BD, 0x5230,\r\n\t0xB5BE, 0x7A3B, 0xB5BF, 0x60BC, 0xB5C0, 0x9053, 0xB5C1, 0x76D7,\t0xB5C2, 0x5FB7, 0xB5C3, 0x5F97, 0xB5C4, 0x7684, 0xB5C5, 0x8E6C,\r\n\t0xB5C6, 0x706F, 0xB5C7, 0x767B, 0xB5C8, 0x7B49, 0xB5C9, 0x77AA,\t0xB5CA, 0x51F3, 0xB5CB, 0x9093, 0xB5CC, 0x5824, 0xB5CD, 0x4F4E,\r\n\t0xB5CE, 0x6EF4, 0xB5CF, 0x8FEA, 0xB5D0, 0x654C, 0xB5D1, 0x7B1B,\t0xB5D2, 0x72C4, 0xB5D3, 0x6DA4, 0xB5D4, 0x7FDF, 0xB5D5, 0x5AE1,\r\n\t0xB5D6, 0x62B5, 0xB5D7, 0x5E95, 0xB5D8, 0x5730, 0xB5D9, 0x8482,\t0xB5DA, 0x7B2C, 0xB5DB, 0x5E1D, 0xB5DC, 0x5F1F, 0xB5DD, 0x9012,\r\n\t0xB5DE, 0x7F14, 0xB5DF, 0x98A0, 0xB5E0, 0x6382, 0xB5E1, 0x6EC7,\t0xB5E2, 0x7898, 0xB5E3, 0x70B9, 0xB5E4, 0x5178, 0xB5E5, 0x975B,\r\n\t0xB5E6, 0x57AB, 0xB5E7, 0x7535, 0xB5E8, 0x4F43, 0xB5E9, 0x7538,\t0xB5EA, 0x5E97, 0xB5EB, 0x60E6, 0xB5EC, 0x5960, 0xB5ED, 0x6DC0,\r\n\t0xB5EE, 0x6BBF, 0xB5EF, 0x7889, 0xB5F0, 0x53FC, 0xB5F1, 0x96D5,\t0xB5F2, 0x51CB, 0xB5F3, 0x5201, 0xB5F4, 0x6389, 0xB5F5, 0x540A,\r\n\t0xB5F6, 0x9493, 0xB5F7, 0x8C03, 0xB5F8, 0x8DCC, 0xB5F9, 0x7239,\t0xB5FA, 0x789F, 0xB5FB, 0x8776, 0xB5FC, 0x8FED, 0xB5FD, 0x8C0D,\r\n\t0xB5FE, 0x53E0, 0xB640, 0x7993, 0xB641, 0x7994, 0xB642, 0x7995,\t0xB643, 0x7996, 0xB644, 0x7997, 0xB645, 0x7998, 0xB646, 0x7999,\r\n\t0xB647, 0x799B, 0xB648, 0x799C, 0xB649, 0x799D, 0xB64A, 0x799E,\t0xB64B, 0x799F, 0xB64C, 0x79A0, 0xB64D, 0x79A1, 0xB64E, 0x79A2,\r\n\t0xB64F, 0x79A3, 0xB650, 0x79A4, 0xB651, 0x79A5, 0xB652, 0x79A6,\t0xB653, 0x79A8, 0xB654, 0x79A9, 0xB655, 0x79AA, 0xB656, 0x79AB,\r\n\t0xB657, 0x79AC, 0xB658, 0x79AD, 0xB659, 0x79AE, 0xB65A, 0x79AF,\t0xB65B, 0x79B0, 0xB65C, 0x79B1, 0xB65D, 0x79B2, 0xB65E, 0x79B4,\r\n\t0xB65F, 0x79B5, 0xB660, 0x79B6, 0xB661, 0x79B7, 0xB662, 0x79B8,\t0xB663, 0x79BC, 0xB664, 0x79BF, 0xB665, 0x79C2, 0xB666, 0x79C4,\r\n\t0xB667, 0x79C5, 0xB668, 0x79C7, 0xB669, 0x79C8, 0xB66A, 0x79CA,\t0xB66B, 0x79CC, 0xB66C, 0x79CE, 0xB66D, 0x79CF, 0xB66E, 0x79D0,\r\n\t0xB66F, 0x79D3, 0xB670, 0x79D4, 0xB671, 0x79D6, 0xB672, 0x79D7,\t0xB673, 0x79D9, 0xB674, 0x79DA, 0xB675, 0x79DB, 0xB676, 0x79DC,\r\n\t0xB677, 0x79DD, 0xB678, 0x79DE, 0xB679, 0x79E0, 0xB67A, 0x79E1,\t0xB67B, 0x79E2, 0xB67C, 0x79E5, 0xB67D, 0x79E8, 0xB67E, 0x79EA,\r\n\t0xB680, 0x79EC, 0xB681, 0x79EE, 0xB682, 0x79F1, 0xB683, 0x79F2,\t0xB684, 0x79F3, 0xB685, 0x79F4, 0xB686, 0x79F5, 0xB687, 0x79F6,\r\n\t0xB688, 0x79F7, 0xB689, 0x79F9, 0xB68A, 0x79FA, 0xB68B, 0x79FC,\t0xB68C, 0x79FE, 0xB68D, 0x79FF, 0xB68E, 0x7A01, 0xB68F, 0x7A04,\r\n\t0xB690, 0x7A05, 0xB691, 0x7A07, 0xB692, 0x7A08, 0xB693, 0x7A09,\t0xB694, 0x7A0A, 0xB695, 0x7A0C, 0xB696, 0x7A0F, 0xB697, 0x7A10,\r\n\t0xB698, 0x7A11, 0xB699, 0x7A12, 0xB69A, 0x7A13, 0xB69B, 0x7A15,\t0xB69C, 0x7A16, 0xB69D, 0x7A18, 0xB69E, 0x7A19, 0xB69F, 0x7A1B,\r\n\t0xB6A0, 0x7A1C, 0xB6A1, 0x4E01, 0xB6A2, 0x76EF, 0xB6A3, 0x53EE,\t0xB6A4, 0x9489, 0xB6A5, 0x9876, 0xB6A6, 0x9F0E, 0xB6A7, 0x952D,\r\n\t0xB6A8, 0x5B9A, 0xB6A9, 0x8BA2, 0xB6AA, 0x4E22, 0xB6AB, 0x4E1C,\t0xB6AC, 0x51AC, 0xB6AD, 0x8463, 0xB6AE, 0x61C2, 0xB6AF, 0x52A8,\r\n\t0xB6B0, 0x680B, 0xB6B1, 0x4F97, 0xB6B2, 0x606B, 0xB6B3, 0x51BB,\t0xB6B4, 0x6D1E, 0xB6B5, 0x515C, 0xB6B6, 0x6296, 0xB6B7, 0x6597,\r\n\t0xB6B8, 0x9661, 0xB6B9, 0x8C46, 0xB6BA, 0x9017, 0xB6BB, 0x75D8,\t0xB6BC, 0x90FD, 0xB6BD, 0x7763, 0xB6BE, 0x6BD2, 0xB6BF, 0x728A,\r\n\t0xB6C0, 0x72EC, 0xB6C1, 0x8BFB, 0xB6C2, 0x5835, 0xB6C3, 0x7779,\t0xB6C4, 0x8D4C, 0xB6C5, 0x675C, 0xB6C6, 0x9540, 0xB6C7, 0x809A,\r\n\t0xB6C8, 0x5EA6, 0xB6C9, 0x6E21, 0xB6CA, 0x5992, 0xB6CB, 0x7AEF,\t0xB6CC, 0x77ED, 0xB6CD, 0x953B, 0xB6CE, 0x6BB5, 0xB6CF, 0x65AD,\r\n\t0xB6D0, 0x7F0E, 0xB6D1, 0x5806, 0xB6D2, 0x5151, 0xB6D3, 0x961F,\t0xB6D4, 0x5BF9, 0xB6D5, 0x58A9, 0xB6D6, 0x5428, 0xB6D7, 0x8E72,\r\n\t0xB6D8, 0x6566, 0xB6D9, 0x987F, 0xB6DA, 0x56E4, 0xB6DB, 0x949D,\t0xB6DC, 0x76FE, 0xB6DD, 0x9041, 0xB6DE, 0x6387, 0xB6DF, 0x54C6,\r\n\t0xB6E0, 0x591A, 0xB6E1, 0x593A, 0xB6E2, 0x579B, 0xB6E3, 0x8EB2,\t0xB6E4, 0x6735, 0xB6E5, 0x8DFA, 0xB6E6, 0x8235, 0xB6E7, 0x5241,\r\n\t0xB6E8, 0x60F0, 0xB6E9, 0x5815, 0xB6EA, 0x86FE, 0xB6EB, 0x5CE8,\t0xB6EC, 0x9E45, 0xB6ED, 0x4FC4, 0xB6EE, 0x989D, 0xB6EF, 0x8BB9,\r\n\t0xB6F0, 0x5A25, 0xB6F1, 0x6076, 0xB6F2, 0x5384, 0xB6F3, 0x627C,\t0xB6F4, 0x904F, 0xB6F5, 0x9102, 0xB6F6, 0x997F, 0xB6F7, 0x6069,\r\n\t0xB6F8, 0x800C, 0xB6F9, 0x513F, 0xB6FA, 0x8033, 0xB6FB, 0x5C14,\t0xB6FC, 0x9975, 0xB6FD, 0x6D31, 0xB6FE, 0x4E8C, 0xB740, 0x7A1D,\r\n\t0xB741, 0x7A1F, 0xB742, 0x7A21, 0xB743, 0x7A22, 0xB744, 0x7A24,\t0xB745, 0x7A25, 0xB746, 0x7A26, 0xB747, 0x7A27, 0xB748, 0x7A28,\r\n\t0xB749, 0x7A29, 0xB74A, 0x7A2A, 0xB74B, 0x7A2B, 0xB74C, 0x7A2C,\t0xB74D, 0x7A2D, 0xB74E, 0x7A2E, 0xB74F, 0x7A2F, 0xB750, 0x7A30,\r\n\t0xB751, 0x7A31, 0xB752, 0x7A32, 0xB753, 0x7A34, 0xB754, 0x7A35,\t0xB755, 0x7A36, 0xB756, 0x7A38, 0xB757, 0x7A3A, 0xB758, 0x7A3E,\r\n\t0xB759, 0x7A40, 0xB75A, 0x7A41, 0xB75B, 0x7A42, 0xB75C, 0x7A43,\t0xB75D, 0x7A44, 0xB75E, 0x7A45, 0xB75F, 0x7A47, 0xB760, 0x7A48,\r\n\t0xB761, 0x7A49, 0xB762, 0x7A4A, 0xB763, 0x7A4B, 0xB764, 0x7A4C,\t0xB765, 0x7A4D, 0xB766, 0x7A4E, 0xB767, 0x7A4F, 0xB768, 0x7A50,\r\n\t0xB769, 0x7A52, 0xB76A, 0x7A53, 0xB76B, 0x7A54, 0xB76C, 0x7A55,\t0xB76D, 0x7A56, 0xB76E, 0x7A58, 0xB76F, 0x7A59, 0xB770, 0x7A5A,\r\n\t0xB771, 0x7A5B, 0xB772, 0x7A5C, 0xB773, 0x7A5D, 0xB774, 0x7A5E,\t0xB775, 0x7A5F, 0xB776, 0x7A60, 0xB777, 0x7A61, 0xB778, 0x7A62,\r\n\t0xB779, 0x7A63, 0xB77A, 0x7A64, 0xB77B, 0x7A65, 0xB77C, 0x7A66,\t0xB77D, 0x7A67, 0xB77E, 0x7A68, 0xB780, 0x7A69, 0xB781, 0x7A6A,\r\n\t0xB782, 0x7A6B, 0xB783, 0x7A6C, 0xB784, 0x7A6D, 0xB785, 0x7A6E,\t0xB786, 0x7A6F, 0xB787, 0x7A71, 0xB788, 0x7A72, 0xB789, 0x7A73,\r\n\t0xB78A, 0x7A75, 0xB78B, 0x7A7B, 0xB78C, 0x7A7C, 0xB78D, 0x7A7D,\t0xB78E, 0x7A7E, 0xB78F, 0x7A82, 0xB790, 0x7A85, 0xB791, 0x7A87,\r\n\t0xB792, 0x7A89, 0xB793, 0x7A8A, 0xB794, 0x7A8B, 0xB795, 0x7A8C,\t0xB796, 0x7A8E, 0xB797, 0x7A8F, 0xB798, 0x7A90, 0xB799, 0x7A93,\r\n\t0xB79A, 0x7A94, 0xB79B, 0x7A99, 0xB79C, 0x7A9A, 0xB79D, 0x7A9B,\t0xB79E, 0x7A9E, 0xB79F, 0x7AA1, 0xB7A0, 0x7AA2, 0xB7A1, 0x8D30,\r\n\t0xB7A2, 0x53D1, 0xB7A3, 0x7F5A, 0xB7A4, 0x7B4F, 0xB7A5, 0x4F10,\t0xB7A6, 0x4E4F, 0xB7A7, 0x9600, 0xB7A8, 0x6CD5, 0xB7A9, 0x73D0,\r\n\t0xB7AA, 0x85E9, 0xB7AB, 0x5E06, 0xB7AC, 0x756A, 0xB7AD, 0x7FFB,\t0xB7AE, 0x6A0A, 0xB7AF, 0x77FE, 0xB7B0, 0x9492, 0xB7B1, 0x7E41,\r\n\t0xB7B2, 0x51E1, 0xB7B3, 0x70E6, 0xB7B4, 0x53CD, 0xB7B5, 0x8FD4,\t0xB7B6, 0x8303, 0xB7B7, 0x8D29, 0xB7B8, 0x72AF, 0xB7B9, 0x996D,\r\n\t0xB7BA, 0x6CDB, 0xB7BB, 0x574A, 0xB7BC, 0x82B3, 0xB7BD, 0x65B9,\t0xB7BE, 0x80AA, 0xB7BF, 0x623F, 0xB7C0, 0x9632, 0xB7C1, 0x59A8,\r\n\t0xB7C2, 0x4EFF, 0xB7C3, 0x8BBF, 0xB7C4, 0x7EBA, 0xB7C5, 0x653E,\t0xB7C6, 0x83F2, 0xB7C7, 0x975E, 0xB7C8, 0x5561, 0xB7C9, 0x98DE,\r\n\t0xB7CA, 0x80A5, 0xB7CB, 0x532A, 0xB7CC, 0x8BFD, 0xB7CD, 0x5420,\t0xB7CE, 0x80BA, 0xB7CF, 0x5E9F, 0xB7D0, 0x6CB8, 0xB7D1, 0x8D39,\r\n\t0xB7D2, 0x82AC, 0xB7D3, 0x915A, 0xB7D4, 0x5429, 0xB7D5, 0x6C1B,\t0xB7D6, 0x5206, 0xB7D7, 0x7EB7, 0xB7D8, 0x575F, 0xB7D9, 0x711A,\r\n\t0xB7DA, 0x6C7E, 0xB7DB, 0x7C89, 0xB7DC, 0x594B, 0xB7DD, 0x4EFD,\t0xB7DE, 0x5FFF, 0xB7DF, 0x6124, 0xB7E0, 0x7CAA, 0xB7E1, 0x4E30,\r\n\t0xB7E2, 0x5C01, 0xB7E3, 0x67AB, 0xB7E4, 0x8702, 0xB7E5, 0x5CF0,\t0xB7E6, 0x950B, 0xB7E7, 0x98CE, 0xB7E8, 0x75AF, 0xB7E9, 0x70FD,\r\n\t0xB7EA, 0x9022, 0xB7EB, 0x51AF, 0xB7EC, 0x7F1D, 0xB7ED, 0x8BBD,\t0xB7EE, 0x5949, 0xB7EF, 0x51E4, 0xB7F0, 0x4F5B, 0xB7F1, 0x5426,\r\n\t0xB7F2, 0x592B, 0xB7F3, 0x6577, 0xB7F4, 0x80A4, 0xB7F5, 0x5B75,\t0xB7F6, 0x6276, 0xB7F7, 0x62C2, 0xB7F8, 0x8F90, 0xB7F9, 0x5E45,\r\n\t0xB7FA, 0x6C1F, 0xB7FB, 0x7B26, 0xB7FC, 0x4F0F, 0xB7FD, 0x4FD8,\t0xB7FE, 0x670D, 0xB840, 0x7AA3, 0xB841, 0x7AA4, 0xB842, 0x7AA7,\r\n\t0xB843, 0x7AA9, 0xB844, 0x7AAA, 0xB845, 0x7AAB, 0xB846, 0x7AAE,\t0xB847, 0x7AAF, 0xB848, 0x7AB0, 0xB849, 0x7AB1, 0xB84A, 0x7AB2,\r\n\t0xB84B, 0x7AB4, 0xB84C, 0x7AB5, 0xB84D, 0x7AB6, 0xB84E, 0x7AB7,\t0xB84F, 0x7AB8, 0xB850, 0x7AB9, 0xB851, 0x7ABA, 0xB852, 0x7ABB,\r\n\t0xB853, 0x7ABC, 0xB854, 0x7ABD, 0xB855, 0x7ABE, 0xB856, 0x7AC0,\t0xB857, 0x7AC1, 0xB858, 0x7AC2, 0xB859, 0x7AC3, 0xB85A, 0x7AC4,\r\n\t0xB85B, 0x7AC5, 0xB85C, 0x7AC6, 0xB85D, 0x7AC7, 0xB85E, 0x7AC8,\t0xB85F, 0x7AC9, 0xB860, 0x7ACA, 0xB861, 0x7ACC, 0xB862, 0x7ACD,\r\n\t0xB863, 0x7ACE, 0xB864, 0x7ACF, 0xB865, 0x7AD0, 0xB866, 0x7AD1,\t0xB867, 0x7AD2, 0xB868, 0x7AD3, 0xB869, 0x7AD4, 0xB86A, 0x7AD5,\r\n\t0xB86B, 0x7AD7, 0xB86C, 0x7AD8, 0xB86D, 0x7ADA, 0xB86E, 0x7ADB,\t0xB86F, 0x7ADC, 0xB870, 0x7ADD, 0xB871, 0x7AE1, 0xB872, 0x7AE2,\r\n\t0xB873, 0x7AE4, 0xB874, 0x7AE7, 0xB875, 0x7AE8, 0xB876, 0x7AE9,\t0xB877, 0x7AEA, 0xB878, 0x7AEB, 0xB879, 0x7AEC, 0xB87A, 0x7AEE,\r\n\t0xB87B, 0x7AF0, 0xB87C, 0x7AF1, 0xB87D, 0x7AF2, 0xB87E, 0x7AF3,\t0xB880, 0x7AF4, 0xB881, 0x7AF5, 0xB882, 0x7AF6, 0xB883, 0x7AF7,\r\n\t0xB884, 0x7AF8, 0xB885, 0x7AFB, 0xB886, 0x7AFC, 0xB887, 0x7AFE,\t0xB888, 0x7B00, 0xB889, 0x7B01, 0xB88A, 0x7B02, 0xB88B, 0x7B05,\r\n\t0xB88C, 0x7B07, 0xB88D, 0x7B09, 0xB88E, 0x7B0C, 0xB88F, 0x7B0D,\t0xB890, 0x7B0E, 0xB891, 0x7B10, 0xB892, 0x7B12, 0xB893, 0x7B13,\r\n\t0xB894, 0x7B16, 0xB895, 0x7B17, 0xB896, 0x7B18, 0xB897, 0x7B1A,\t0xB898, 0x7B1C, 0xB899, 0x7B1D, 0xB89A, 0x7B1F, 0xB89B, 0x7B21,\r\n\t0xB89C, 0x7B22, 0xB89D, 0x7B23, 0xB89E, 0x7B27, 0xB89F, 0x7B29,\t0xB8A0, 0x7B2D, 0xB8A1, 0x6D6E, 0xB8A2, 0x6DAA, 0xB8A3, 0x798F,\r\n\t0xB8A4, 0x88B1, 0xB8A5, 0x5F17, 0xB8A6, 0x752B, 0xB8A7, 0x629A,\t0xB8A8, 0x8F85, 0xB8A9, 0x4FEF, 0xB8AA, 0x91DC, 0xB8AB, 0x65A7,\r\n\t0xB8AC, 0x812F, 0xB8AD, 0x8151, 0xB8AE, 0x5E9C, 0xB8AF, 0x8150,\t0xB8B0, 0x8D74, 0xB8B1, 0x526F, 0xB8B2, 0x8986, 0xB8B3, 0x8D4B,\r\n\t0xB8B4, 0x590D, 0xB8B5, 0x5085, 0xB8B6, 0x4ED8, 0xB8B7, 0x961C,\t0xB8B8, 0x7236, 0xB8B9, 0x8179, 0xB8BA, 0x8D1F, 0xB8BB, 0x5BCC,\r\n\t0xB8BC, 0x8BA3, 0xB8BD, 0x9644, 0xB8BE, 0x5987, 0xB8BF, 0x7F1A,\t0xB8C0, 0x5490, 0xB8C1, 0x5676, 0xB8C2, 0x560E, 0xB8C3, 0x8BE5,\r\n\t0xB8C4, 0x6539, 0xB8C5, 0x6982, 0xB8C6, 0x9499, 0xB8C7, 0x76D6,\t0xB8C8, 0x6E89, 0xB8C9, 0x5E72, 0xB8CA, 0x7518, 0xB8CB, 0x6746,\r\n\t0xB8CC, 0x67D1, 0xB8CD, 0x7AFF, 0xB8CE, 0x809D, 0xB8CF, 0x8D76,\t0xB8D0, 0x611F, 0xB8D1, 0x79C6, 0xB8D2, 0x6562, 0xB8D3, 0x8D63,\r\n\t0xB8D4, 0x5188, 0xB8D5, 0x521A, 0xB8D6, 0x94A2, 0xB8D7, 0x7F38,\t0xB8D8, 0x809B, 0xB8D9, 0x7EB2, 0xB8DA, 0x5C97, 0xB8DB, 0x6E2F,\r\n\t0xB8DC, 0x6760, 0xB8DD, 0x7BD9, 0xB8DE, 0x768B, 0xB8DF, 0x9AD8,\t0xB8E0, 0x818F, 0xB8E1, 0x7F94, 0xB8E2, 0x7CD5, 0xB8E3, 0x641E,\r\n\t0xB8E4, 0x9550, 0xB8E5, 0x7A3F, 0xB8E6, 0x544A, 0xB8E7, 0x54E5,\t0xB8E8, 0x6B4C, 0xB8E9, 0x6401, 0xB8EA, 0x6208, 0xB8EB, 0x9E3D,\r\n\t0xB8EC, 0x80F3, 0xB8ED, 0x7599, 0xB8EE, 0x5272, 0xB8EF, 0x9769,\t0xB8F0, 0x845B, 0xB8F1, 0x683C, 0xB8F2, 0x86E4, 0xB8F3, 0x9601,\r\n\t0xB8F4, 0x9694, 0xB8F5, 0x94EC, 0xB8F6, 0x4E2A, 0xB8F7, 0x5404,\t0xB8F8, 0x7ED9, 0xB8F9, 0x6839, 0xB8FA, 0x8DDF, 0xB8FB, 0x8015,\r\n\t0xB8FC, 0x66F4, 0xB8FD, 0x5E9A, 0xB8FE, 0x7FB9, 0xB940, 0x7B2F,\t0xB941, 0x7B30, 0xB942, 0x7B32, 0xB943, 0x7B34, 0xB944, 0x7B35,\r\n\t0xB945, 0x7B36, 0xB946, 0x7B37, 0xB947, 0x7B39, 0xB948, 0x7B3B,\t0xB949, 0x7B3D, 0xB94A, 0x7B3F, 0xB94B, 0x7B40, 0xB94C, 0x7B41,\r\n\t0xB94D, 0x7B42, 0xB94E, 0x7B43, 0xB94F, 0x7B44, 0xB950, 0x7B46,\t0xB951, 0x7B48, 0xB952, 0x7B4A, 0xB953, 0x7B4D, 0xB954, 0x7B4E,\r\n\t0xB955, 0x7B53, 0xB956, 0x7B55, 0xB957, 0x7B57, 0xB958, 0x7B59,\t0xB959, 0x7B5C, 0xB95A, 0x7B5E, 0xB95B, 0x7B5F, 0xB95C, 0x7B61,\r\n\t0xB95D, 0x7B63, 0xB95E, 0x7B64, 0xB95F, 0x7B65, 0xB960, 0x7B66,\t0xB961, 0x7B67, 0xB962, 0x7B68, 0xB963, 0x7B69, 0xB964, 0x7B6A,\r\n\t0xB965, 0x7B6B, 0xB966, 0x7B6C, 0xB967, 0x7B6D, 0xB968, 0x7B6F,\t0xB969, 0x7B70, 0xB96A, 0x7B73, 0xB96B, 0x7B74, 0xB96C, 0x7B76,\r\n\t0xB96D, 0x7B78, 0xB96E, 0x7B7A, 0xB96F, 0x7B7C, 0xB970, 0x7B7D,\t0xB971, 0x7B7F, 0xB972, 0x7B81, 0xB973, 0x7B82, 0xB974, 0x7B83,\r\n\t0xB975, 0x7B84, 0xB976, 0x7B86, 0xB977, 0x7B87, 0xB978, 0x7B88,\t0xB979, 0x7B89, 0xB97A, 0x7B8A, 0xB97B, 0x7B8B, 0xB97C, 0x7B8C,\r\n\t0xB97D, 0x7B8E, 0xB97E, 0x7B8F, 0xB980, 0x7B91, 0xB981, 0x7B92,\t0xB982, 0x7B93, 0xB983, 0x7B96, 0xB984, 0x7B98, 0xB985, 0x7B99,\r\n\t0xB986, 0x7B9A, 0xB987, 0x7B9B, 0xB988, 0x7B9E, 0xB989, 0x7B9F,\t0xB98A, 0x7BA0, 0xB98B, 0x7BA3, 0xB98C, 0x7BA4, 0xB98D, 0x7BA5,\r\n\t0xB98E, 0x7BAE, 0xB98F, 0x7BAF, 0xB990, 0x7BB0, 0xB991, 0x7BB2,\t0xB992, 0x7BB3, 0xB993, 0x7BB5, 0xB994, 0x7BB6, 0xB995, 0x7BB7,\r\n\t0xB996, 0x7BB9, 0xB997, 0x7BBA, 0xB998, 0x7BBB, 0xB999, 0x7BBC,\t0xB99A, 0x7BBD, 0xB99B, 0x7BBE, 0xB99C, 0x7BBF, 0xB99D, 0x7BC0,\r\n\t0xB99E, 0x7BC2, 0xB99F, 0x7BC3, 0xB9A0, 0x7BC4, 0xB9A1, 0x57C2,\t0xB9A2, 0x803F, 0xB9A3, 0x6897, 0xB9A4, 0x5DE5, 0xB9A5, 0x653B,\r\n\t0xB9A6, 0x529F, 0xB9A7, 0x606D, 0xB9A8, 0x9F9A, 0xB9A9, 0x4F9B,\t0xB9AA, 0x8EAC, 0xB9AB, 0x516C, 0xB9AC, 0x5BAB, 0xB9AD, 0x5F13,\r\n\t0xB9AE, 0x5DE9, 0xB9AF, 0x6C5E, 0xB9B0, 0x62F1, 0xB9B1, 0x8D21,\t0xB9B2, 0x5171, 0xB9B3, 0x94A9, 0xB9B4, 0x52FE, 0xB9B5, 0x6C9F,\r\n\t0xB9B6, 0x82DF, 0xB9B7, 0x72D7, 0xB9B8, 0x57A2, 0xB9B9, 0x6784,\t0xB9BA, 0x8D2D, 0xB9BB, 0x591F, 0xB9BC, 0x8F9C, 0xB9BD, 0x83C7,\r\n\t0xB9BE, 0x5495, 0xB9BF, 0x7B8D, 0xB9C0, 0x4F30, 0xB9C1, 0x6CBD,\t0xB9C2, 0x5B64, 0xB9C3, 0x59D1, 0xB9C4, 0x9F13, 0xB9C5, 0x53E4,\r\n\t0xB9C6, 0x86CA, 0xB9C7, 0x9AA8, 0xB9C8, 0x8C37, 0xB9C9, 0x80A1,\t0xB9CA, 0x6545, 0xB9CB, 0x987E, 0xB9CC, 0x56FA, 0xB9CD, 0x96C7,\r\n\t0xB9CE, 0x522E, 0xB9CF, 0x74DC, 0xB9D0, 0x5250, 0xB9D1, 0x5BE1,\t0xB9D2, 0x6302, 0xB9D3, 0x8902, 0xB9D4, 0x4E56, 0xB9D5, 0x62D0,\r\n\t0xB9D6, 0x602A, 0xB9D7, 0x68FA, 0xB9D8, 0x5173, 0xB9D9, 0x5B98,\t0xB9DA, 0x51A0, 0xB9DB, 0x89C2, 0xB9DC, 0x7BA1, 0xB9DD, 0x9986,\r\n\t0xB9DE, 0x7F50, 0xB9DF, 0x60EF, 0xB9E0, 0x704C, 0xB9E1, 0x8D2F,\t0xB9E2, 0x5149, 0xB9E3, 0x5E7F, 0xB9E4, 0x901B, 0xB9E5, 0x7470,\r\n\t0xB9E6, 0x89C4, 0xB9E7, 0x572D, 0xB9E8, 0x7845, 0xB9E9, 0x5F52,\t0xB9EA, 0x9F9F, 0xB9EB, 0x95FA, 0xB9EC, 0x8F68, 0xB9ED, 0x9B3C,\r\n\t0xB9EE, 0x8BE1, 0xB9EF, 0x7678, 0xB9F0, 0x6842, 0xB9F1, 0x67DC,\t0xB9F2, 0x8DEA, 0xB9F3, 0x8D35, 0xB9F4, 0x523D, 0xB9F5, 0x8F8A,\r\n\t0xB9F6, 0x6EDA, 0xB9F7, 0x68CD, 0xB9F8, 0x9505, 0xB9F9, 0x90ED,\t0xB9FA, 0x56FD, 0xB9FB, 0x679C, 0xB9FC, 0x88F9, 0xB9FD, 0x8FC7,\r\n\t0xB9FE, 0x54C8, 0xBA40, 0x7BC5, 0xBA41, 0x7BC8, 0xBA42, 0x7BC9,\t0xBA43, 0x7BCA, 0xBA44, 0x7BCB, 0xBA45, 0x7BCD, 0xBA46, 0x7BCE,\r\n\t0xBA47, 0x7BCF, 0xBA48, 0x7BD0, 0xBA49, 0x7BD2, 0xBA4A, 0x7BD4,\t0xBA4B, 0x7BD5, 0xBA4C, 0x7BD6, 0xBA4D, 0x7BD7, 0xBA4E, 0x7BD8,\r\n\t0xBA4F, 0x7BDB, 0xBA50, 0x7BDC, 0xBA51, 0x7BDE, 0xBA52, 0x7BDF,\t0xBA53, 0x7BE0, 0xBA54, 0x7BE2, 0xBA55, 0x7BE3, 0xBA56, 0x7BE4,\r\n\t0xBA57, 0x7BE7, 0xBA58, 0x7BE8, 0xBA59, 0x7BE9, 0xBA5A, 0x7BEB,\t0xBA5B, 0x7BEC, 0xBA5C, 0x7BED, 0xBA5D, 0x7BEF, 0xBA5E, 0x7BF0,\r\n\t0xBA5F, 0x7BF2, 0xBA60, 0x7BF3, 0xBA61, 0x7BF4, 0xBA62, 0x7BF5,\t0xBA63, 0x7BF6, 0xBA64, 0x7BF8, 0xBA65, 0x7BF9, 0xBA66, 0x7BFA,\r\n\t0xBA67, 0x7BFB, 0xBA68, 0x7BFD, 0xBA69, 0x7BFF, 0xBA6A, 0x7C00,\t0xBA6B, 0x7C01, 0xBA6C, 0x7C02, 0xBA6D, 0x7C03, 0xBA6E, 0x7C04,\r\n\t0xBA6F, 0x7C05, 0xBA70, 0x7C06, 0xBA71, 0x7C08, 0xBA72, 0x7C09,\t0xBA73, 0x7C0A, 0xBA74, 0x7C0D, 0xBA75, 0x7C0E, 0xBA76, 0x7C10,\r\n\t0xBA77, 0x7C11, 0xBA78, 0x7C12, 0xBA79, 0x7C13, 0xBA7A, 0x7C14,\t0xBA7B, 0x7C15, 0xBA7C, 0x7C17, 0xBA7D, 0x7C18, 0xBA7E, 0x7C19,\r\n\t0xBA80, 0x7C1A, 0xBA81, 0x7C1B, 0xBA82, 0x7C1C, 0xBA83, 0x7C1D,\t0xBA84, 0x7C1E, 0xBA85, 0x7C20, 0xBA86, 0x7C21, 0xBA87, 0x7C22,\r\n\t0xBA88, 0x7C23, 0xBA89, 0x7C24, 0xBA8A, 0x7C25, 0xBA8B, 0x7C28,\t0xBA8C, 0x7C29, 0xBA8D, 0x7C2B, 0xBA8E, 0x7C2C, 0xBA8F, 0x7C2D,\r\n\t0xBA90, 0x7C2E, 0xBA91, 0x7C2F, 0xBA92, 0x7C30, 0xBA93, 0x7C31,\t0xBA94, 0x7C32, 0xBA95, 0x7C33, 0xBA96, 0x7C34, 0xBA97, 0x7C35,\r\n\t0xBA98, 0x7C36, 0xBA99, 0x7C37, 0xBA9A, 0x7C39, 0xBA9B, 0x7C3A,\t0xBA9C, 0x7C3B, 0xBA9D, 0x7C3C, 0xBA9E, 0x7C3D, 0xBA9F, 0x7C3E,\r\n\t0xBAA0, 0x7C42, 0xBAA1, 0x9AB8, 0xBAA2, 0x5B69, 0xBAA3, 0x6D77,\t0xBAA4, 0x6C26, 0xBAA5, 0x4EA5, 0xBAA6, 0x5BB3, 0xBAA7, 0x9A87,\r\n\t0xBAA8, 0x9163, 0xBAA9, 0x61A8, 0xBAAA, 0x90AF, 0xBAAB, 0x97E9,\t0xBAAC, 0x542B, 0xBAAD, 0x6DB5, 0xBAAE, 0x5BD2, 0xBAAF, 0x51FD,\r\n\t0xBAB0, 0x558A, 0xBAB1, 0x7F55, 0xBAB2, 0x7FF0, 0xBAB3, 0x64BC,\t0xBAB4, 0x634D, 0xBAB5, 0x65F1, 0xBAB6, 0x61BE, 0xBAB7, 0x608D,\r\n\t0xBAB8, 0x710A, 0xBAB9, 0x6C57, 0xBABA, 0x6C49, 0xBABB, 0x592F,\t0xBABC, 0x676D, 0xBABD, 0x822A, 0xBABE, 0x58D5, 0xBABF, 0x568E,\r\n\t0xBAC0, 0x8C6A, 0xBAC1, 0x6BEB, 0xBAC2, 0x90DD, 0xBAC3, 0x597D,\t0xBAC4, 0x8017, 0xBAC5, 0x53F7, 0xBAC6, 0x6D69, 0xBAC7, 0x5475,\r\n\t0xBAC8, 0x559D, 0xBAC9, 0x8377, 0xBACA, 0x83CF, 0xBACB, 0x6838,\t0xBACC, 0x79BE, 0xBACD, 0x548C, 0xBACE, 0x4F55, 0xBACF, 0x5408,\r\n\t0xBAD0, 0x76D2, 0xBAD1, 0x8C89, 0xBAD2, 0x9602, 0xBAD3, 0x6CB3,\t0xBAD4, 0x6DB8, 0xBAD5, 0x8D6B, 0xBAD6, 0x8910, 0xBAD7, 0x9E64,\r\n\t0xBAD8, 0x8D3A, 0xBAD9, 0x563F, 0xBADA, 0x9ED1, 0xBADB, 0x75D5,\t0xBADC, 0x5F88, 0xBADD, 0x72E0, 0xBADE, 0x6068, 0xBADF, 0x54FC,\r\n\t0xBAE0, 0x4EA8, 0xBAE1, 0x6A2A, 0xBAE2, 0x8861, 0xBAE3, 0x6052,\t0xBAE4, 0x8F70, 0xBAE5, 0x54C4, 0xBAE6, 0x70D8, 0xBAE7, 0x8679,\r\n\t0xBAE8, 0x9E3F, 0xBAE9, 0x6D2A, 0xBAEA, 0x5B8F, 0xBAEB, 0x5F18,\t0xBAEC, 0x7EA2, 0xBAED, 0x5589, 0xBAEE, 0x4FAF, 0xBAEF, 0x7334,\r\n\t0xBAF0, 0x543C, 0xBAF1, 0x539A, 0xBAF2, 0x5019, 0xBAF3, 0x540E,\t0xBAF4, 0x547C, 0xBAF5, 0x4E4E, 0xBAF6, 0x5FFD, 0xBAF7, 0x745A,\r\n\t0xBAF8, 0x58F6, 0xBAF9, 0x846B, 0xBAFA, 0x80E1, 0xBAFB, 0x8774,\t0xBAFC, 0x72D0, 0xBAFD, 0x7CCA, 0xBAFE, 0x6E56, 0xBB40, 0x7C43,\r\n\t0xBB41, 0x7C44, 0xBB42, 0x7C45, 0xBB43, 0x7C46, 0xBB44, 0x7C47,\t0xBB45, 0x7C48, 0xBB46, 0x7C49, 0xBB47, 0x7C4A, 0xBB48, 0x7C4B,\r\n\t0xBB49, 0x7C4C, 0xBB4A, 0x7C4E, 0xBB4B, 0x7C4F, 0xBB4C, 0x7C50,\t0xBB4D, 0x7C51, 0xBB4E, 0x7C52, 0xBB4F, 0x7C53, 0xBB50, 0x7C54,\r\n\t0xBB51, 0x7C55, 0xBB52, 0x7C56, 0xBB53, 0x7C57, 0xBB54, 0x7C58,\t0xBB55, 0x7C59, 0xBB56, 0x7C5A, 0xBB57, 0x7C5B, 0xBB58, 0x7C5C,\r\n\t0xBB59, 0x7C5D, 0xBB5A, 0x7C5E, 0xBB5B, 0x7C5F, 0xBB5C, 0x7C60,\t0xBB5D, 0x7C61, 0xBB5E, 0x7C62, 0xBB5F, 0x7C63, 0xBB60, 0x7C64,\r\n\t0xBB61, 0x7C65, 0xBB62, 0x7C66, 0xBB63, 0x7C67, 0xBB64, 0x7C68,\t0xBB65, 0x7C69, 0xBB66, 0x7C6A, 0xBB67, 0x7C6B, 0xBB68, 0x7C6C,\r\n\t0xBB69, 0x7C6D, 0xBB6A, 0x7C6E, 0xBB6B, 0x7C6F, 0xBB6C, 0x7C70,\t0xBB6D, 0x7C71, 0xBB6E, 0x7C72, 0xBB6F, 0x7C75, 0xBB70, 0x7C76,\r\n\t0xBB71, 0x7C77, 0xBB72, 0x7C78, 0xBB73, 0x7C79, 0xBB74, 0x7C7A,\t0xBB75, 0x7C7E, 0xBB76, 0x7C7F, 0xBB77, 0x7C80, 0xBB78, 0x7C81,\r\n\t0xBB79, 0x7C82, 0xBB7A, 0x7C83, 0xBB7B, 0x7C84, 0xBB7C, 0x7C85,\t0xBB7D, 0x7C86, 0xBB7E, 0x7C87, 0xBB80, 0x7C88, 0xBB81, 0x7C8A,\r\n\t0xBB82, 0x7C8B, 0xBB83, 0x7C8C, 0xBB84, 0x7C8D, 0xBB85, 0x7C8E,\t0xBB86, 0x7C8F, 0xBB87, 0x7C90, 0xBB88, 0x7C93, 0xBB89, 0x7C94,\r\n\t0xBB8A, 0x7C96, 0xBB8B, 0x7C99, 0xBB8C, 0x7C9A, 0xBB8D, 0x7C9B,\t0xBB8E, 0x7CA0, 0xBB8F, 0x7CA1, 0xBB90, 0x7CA3, 0xBB91, 0x7CA6,\r\n\t0xBB92, 0x7CA7, 0xBB93, 0x7CA8, 0xBB94, 0x7CA9, 0xBB95, 0x7CAB,\t0xBB96, 0x7CAC, 0xBB97, 0x7CAD, 0xBB98, 0x7CAF, 0xBB99, 0x7CB0,\r\n\t0xBB9A, 0x7CB4, 0xBB9B, 0x7CB5, 0xBB9C, 0x7CB6, 0xBB9D, 0x7CB7,\t0xBB9E, 0x7CB8, 0xBB9F, 0x7CBA, 0xBBA0, 0x7CBB, 0xBBA1, 0x5F27,\r\n\t0xBBA2, 0x864E, 0xBBA3, 0x552C, 0xBBA4, 0x62A4, 0xBBA5, 0x4E92,\t0xBBA6, 0x6CAA, 0xBBA7, 0x6237, 0xBBA8, 0x82B1, 0xBBA9, 0x54D7,\r\n\t0xBBAA, 0x534E, 0xBBAB, 0x733E, 0xBBAC, 0x6ED1, 0xBBAD, 0x753B,\t0xBBAE, 0x5212, 0xBBAF, 0x5316, 0xBBB0, 0x8BDD, 0xBBB1, 0x69D0,\r\n\t0xBBB2, 0x5F8A, 0xBBB3, 0x6000, 0xBBB4, 0x6DEE, 0xBBB5, 0x574F,\t0xBBB6, 0x6B22, 0xBBB7, 0x73AF, 0xBBB8, 0x6853, 0xBBB9, 0x8FD8,\r\n\t0xBBBA, 0x7F13, 0xBBBB, 0x6362, 0xBBBC, 0x60A3, 0xBBBD, 0x5524,\t0xBBBE, 0x75EA, 0xBBBF, 0x8C62, 0xBBC0, 0x7115, 0xBBC1, 0x6DA3,\r\n\t0xBBC2, 0x5BA6, 0xBBC3, 0x5E7B, 0xBBC4, 0x8352, 0xBBC5, 0x614C,\t0xBBC6, 0x9EC4, 0xBBC7, 0x78FA, 0xBBC8, 0x8757, 0xBBC9, 0x7C27,\r\n\t0xBBCA, 0x7687, 0xBBCB, 0x51F0, 0xBBCC, 0x60F6, 0xBBCD, 0x714C,\t0xBBCE, 0x6643, 0xBBCF, 0x5E4C, 0xBBD0, 0x604D, 0xBBD1, 0x8C0E,\r\n\t0xBBD2, 0x7070, 0xBBD3, 0x6325, 0xBBD4, 0x8F89, 0xBBD5, 0x5FBD,\t0xBBD6, 0x6062, 0xBBD7, 0x86D4, 0xBBD8, 0x56DE, 0xBBD9, 0x6BC1,\r\n\t0xBBDA, 0x6094, 0xBBDB, 0x6167, 0xBBDC, 0x5349, 0xBBDD, 0x60E0,\t0xBBDE, 0x6666, 0xBBDF, 0x8D3F, 0xBBE0, 0x79FD, 0xBBE1, 0x4F1A,\r\n\t0xBBE2, 0x70E9, 0xBBE3, 0x6C47, 0xBBE4, 0x8BB3, 0xBBE5, 0x8BF2,\t0xBBE6, 0x7ED8, 0xBBE7, 0x8364, 0xBBE8, 0x660F, 0xBBE9, 0x5A5A,\r\n\t0xBBEA, 0x9B42, 0xBBEB, 0x6D51, 0xBBEC, 0x6DF7, 0xBBED, 0x8C41,\t0xBBEE, 0x6D3B, 0xBBEF, 0x4F19, 0xBBF0, 0x706B, 0xBBF1, 0x83B7,\r\n\t0xBBF2, 0x6216, 0xBBF3, 0x60D1, 0xBBF4, 0x970D, 0xBBF5, 0x8D27,\t0xBBF6, 0x7978, 0xBBF7, 0x51FB, 0xBBF8, 0x573E, 0xBBF9, 0x57FA,\r\n\t0xBBFA, 0x673A, 0xBBFB, 0x7578, 0xBBFC, 0x7A3D, 0xBBFD, 0x79EF,\t0xBBFE, 0x7B95, 0xBC40, 0x7CBF, 0xBC41, 0x7CC0, 0xBC42, 0x7CC2,\r\n\t0xBC43, 0x7CC3, 0xBC44, 0x7CC4, 0xBC45, 0x7CC6, 0xBC46, 0x7CC9,\t0xBC47, 0x7CCB, 0xBC48, 0x7CCE, 0xBC49, 0x7CCF, 0xBC4A, 0x7CD0,\r\n\t0xBC4B, 0x7CD1, 0xBC4C, 0x7CD2, 0xBC4D, 0x7CD3, 0xBC4E, 0x7CD4,\t0xBC4F, 0x7CD8, 0xBC50, 0x7CDA, 0xBC51, 0x7CDB, 0xBC52, 0x7CDD,\r\n\t0xBC53, 0x7CDE, 0xBC54, 0x7CE1, 0xBC55, 0x7CE2, 0xBC56, 0x7CE3,\t0xBC57, 0x7CE4, 0xBC58, 0x7CE5, 0xBC59, 0x7CE6, 0xBC5A, 0x7CE7,\r\n\t0xBC5B, 0x7CE9, 0xBC5C, 0x7CEA, 0xBC5D, 0x7CEB, 0xBC5E, 0x7CEC,\t0xBC5F, 0x7CED, 0xBC60, 0x7CEE, 0xBC61, 0x7CF0, 0xBC62, 0x7CF1,\r\n\t0xBC63, 0x7CF2, 0xBC64, 0x7CF3, 0xBC65, 0x7CF4, 0xBC66, 0x7CF5,\t0xBC67, 0x7CF6, 0xBC68, 0x7CF7, 0xBC69, 0x7CF9, 0xBC6A, 0x7CFA,\r\n\t0xBC6B, 0x7CFC, 0xBC6C, 0x7CFD, 0xBC6D, 0x7CFE, 0xBC6E, 0x7CFF,\t0xBC6F, 0x7D00, 0xBC70, 0x7D01, 0xBC71, 0x7D02, 0xBC72, 0x7D03,\r\n\t0xBC73, 0x7D04, 0xBC74, 0x7D05, 0xBC75, 0x7D06, 0xBC76, 0x7D07,\t0xBC77, 0x7D08, 0xBC78, 0x7D09, 0xBC79, 0x7D0B, 0xBC7A, 0x7D0C,\r\n\t0xBC7B, 0x7D0D, 0xBC7C, 0x7D0E, 0xBC7D, 0x7D0F, 0xBC7E, 0x7D10,\t0xBC80, 0x7D11, 0xBC81, 0x7D12, 0xBC82, 0x7D13, 0xBC83, 0x7D14,\r\n\t0xBC84, 0x7D15, 0xBC85, 0x7D16, 0xBC86, 0x7D17, 0xBC87, 0x7D18,\t0xBC88, 0x7D19, 0xBC89, 0x7D1A, 0xBC8A, 0x7D1B, 0xBC8B, 0x7D1C,\r\n\t0xBC8C, 0x7D1D, 0xBC8D, 0x7D1E, 0xBC8E, 0x7D1F, 0xBC8F, 0x7D21,\t0xBC90, 0x7D23, 0xBC91, 0x7D24, 0xBC92, 0x7D25, 0xBC93, 0x7D26,\r\n\t0xBC94, 0x7D28, 0xBC95, 0x7D29, 0xBC96, 0x7D2A, 0xBC97, 0x7D2C,\t0xBC98, 0x7D2D, 0xBC99, 0x7D2E, 0xBC9A, 0x7D30, 0xBC9B, 0x7D31,\r\n\t0xBC9C, 0x7D32, 0xBC9D, 0x7D33, 0xBC9E, 0x7D34, 0xBC9F, 0x7D35,\t0xBCA0, 0x7D36, 0xBCA1, 0x808C, 0xBCA2, 0x9965, 0xBCA3, 0x8FF9,\r\n\t0xBCA4, 0x6FC0, 0xBCA5, 0x8BA5, 0xBCA6, 0x9E21, 0xBCA7, 0x59EC,\t0xBCA8, 0x7EE9, 0xBCA9, 0x7F09, 0xBCAA, 0x5409, 0xBCAB, 0x6781,\r\n\t0xBCAC, 0x68D8, 0xBCAD, 0x8F91, 0xBCAE, 0x7C4D, 0xBCAF, 0x96C6,\t0xBCB0, 0x53CA, 0xBCB1, 0x6025, 0xBCB2, 0x75BE, 0xBCB3, 0x6C72,\r\n\t0xBCB4, 0x5373, 0xBCB5, 0x5AC9, 0xBCB6, 0x7EA7, 0xBCB7, 0x6324,\t0xBCB8, 0x51E0, 0xBCB9, 0x810A, 0xBCBA, 0x5DF1, 0xBCBB, 0x84DF,\r\n\t0xBCBC, 0x6280, 0xBCBD, 0x5180, 0xBCBE, 0x5B63, 0xBCBF, 0x4F0E,\t0xBCC0, 0x796D, 0xBCC1, 0x5242, 0xBCC2, 0x60B8, 0xBCC3, 0x6D4E,\r\n\t0xBCC4, 0x5BC4, 0xBCC5, 0x5BC2, 0xBCC6, 0x8BA1, 0xBCC7, 0x8BB0,\t0xBCC8, 0x65E2, 0xBCC9, 0x5FCC, 0xBCCA, 0x9645, 0xBCCB, 0x5993,\r\n\t0xBCCC, 0x7EE7, 0xBCCD, 0x7EAA, 0xBCCE, 0x5609, 0xBCCF, 0x67B7,\t0xBCD0, 0x5939, 0xBCD1, 0x4F73, 0xBCD2, 0x5BB6, 0xBCD3, 0x52A0,\r\n\t0xBCD4, 0x835A, 0xBCD5, 0x988A, 0xBCD6, 0x8D3E, 0xBCD7, 0x7532,\t0xBCD8, 0x94BE, 0xBCD9, 0x5047, 0xBCDA, 0x7A3C, 0xBCDB, 0x4EF7,\r\n\t0xBCDC, 0x67B6, 0xBCDD, 0x9A7E, 0xBCDE, 0x5AC1, 0xBCDF, 0x6B7C,\t0xBCE0, 0x76D1, 0xBCE1, 0x575A, 0xBCE2, 0x5C16, 0xBCE3, 0x7B3A,\r\n\t0xBCE4, 0x95F4, 0xBCE5, 0x714E, 0xBCE6, 0x517C, 0xBCE7, 0x80A9,\t0xBCE8, 0x8270, 0xBCE9, 0x5978, 0xBCEA, 0x7F04, 0xBCEB, 0x8327,\r\n\t0xBCEC, 0x68C0, 0xBCED, 0x67EC, 0xBCEE, 0x78B1, 0xBCEF, 0x7877,\t0xBCF0, 0x62E3, 0xBCF1, 0x6361, 0xBCF2, 0x7B80, 0xBCF3, 0x4FED,\r\n\t0xBCF4, 0x526A, 0xBCF5, 0x51CF, 0xBCF6, 0x8350, 0xBCF7, 0x69DB,\t0xBCF8, 0x9274, 0xBCF9, 0x8DF5, 0xBCFA, 0x8D31, 0xBCFB, 0x89C1,\r\n\t0xBCFC, 0x952E, 0xBCFD, 0x7BAD, 0xBCFE, 0x4EF6, 0xBD40, 0x7D37,\t0xBD41, 0x7D38, 0xBD42, 0x7D39, 0xBD43, 0x7D3A, 0xBD44, 0x7D3B,\r\n\t0xBD45, 0x7D3C, 0xBD46, 0x7D3D, 0xBD47, 0x7D3E, 0xBD48, 0x7D3F,\t0xBD49, 0x7D40, 0xBD4A, 0x7D41, 0xBD4B, 0x7D42, 0xBD4C, 0x7D43,\r\n\t0xBD4D, 0x7D44, 0xBD4E, 0x7D45, 0xBD4F, 0x7D46, 0xBD50, 0x7D47,\t0xBD51, 0x7D48, 0xBD52, 0x7D49, 0xBD53, 0x7D4A, 0xBD54, 0x7D4B,\r\n\t0xBD55, 0x7D4C, 0xBD56, 0x7D4D, 0xBD57, 0x7D4E, 0xBD58, 0x7D4F,\t0xBD59, 0x7D50, 0xBD5A, 0x7D51, 0xBD5B, 0x7D52, 0xBD5C, 0x7D53,\r\n\t0xBD5D, 0x7D54, 0xBD5E, 0x7D55, 0xBD5F, 0x7D56, 0xBD60, 0x7D57,\t0xBD61, 0x7D58, 0xBD62, 0x7D59, 0xBD63, 0x7D5A, 0xBD64, 0x7D5B,\r\n\t0xBD65, 0x7D5C, 0xBD66, 0x7D5D, 0xBD67, 0x7D5E, 0xBD68, 0x7D5F,\t0xBD69, 0x7D60, 0xBD6A, 0x7D61, 0xBD6B, 0x7D62, 0xBD6C, 0x7D63,\r\n\t0xBD6D, 0x7D64, 0xBD6E, 0x7D65, 0xBD6F, 0x7D66, 0xBD70, 0x7D67,\t0xBD71, 0x7D68, 0xBD72, 0x7D69, 0xBD73, 0x7D6A, 0xBD74, 0x7D6B,\r\n\t0xBD75, 0x7D6C, 0xBD76, 0x7D6D, 0xBD77, 0x7D6F, 0xBD78, 0x7D70,\t0xBD79, 0x7D71, 0xBD7A, 0x7D72, 0xBD7B, 0x7D73, 0xBD7C, 0x7D74,\r\n\t0xBD7D, 0x7D75, 0xBD7E, 0x7D76, 0xBD80, 0x7D78, 0xBD81, 0x7D79,\t0xBD82, 0x7D7A, 0xBD83, 0x7D7B, 0xBD84, 0x7D7C, 0xBD85, 0x7D7D,\r\n\t0xBD86, 0x7D7E, 0xBD87, 0x7D7F, 0xBD88, 0x7D80, 0xBD89, 0x7D81,\t0xBD8A, 0x7D82, 0xBD8B, 0x7D83, 0xBD8C, 0x7D84, 0xBD8D, 0x7D85,\r\n\t0xBD8E, 0x7D86, 0xBD8F, 0x7D87, 0xBD90, 0x7D88, 0xBD91, 0x7D89,\t0xBD92, 0x7D8A, 0xBD93, 0x7D8B, 0xBD94, 0x7D8C, 0xBD95, 0x7D8D,\r\n\t0xBD96, 0x7D8E, 0xBD97, 0x7D8F, 0xBD98, 0x7D90, 0xBD99, 0x7D91,\t0xBD9A, 0x7D92, 0xBD9B, 0x7D93, 0xBD9C, 0x7D94, 0xBD9D, 0x7D95,\r\n\t0xBD9E, 0x7D96, 0xBD9F, 0x7D97, 0xBDA0, 0x7D98, 0xBDA1, 0x5065,\t0xBDA2, 0x8230, 0xBDA3, 0x5251, 0xBDA4, 0x996F, 0xBDA5, 0x6E10,\r\n\t0xBDA6, 0x6E85, 0xBDA7, 0x6DA7, 0xBDA8, 0x5EFA, 0xBDA9, 0x50F5,\t0xBDAA, 0x59DC, 0xBDAB, 0x5C06, 0xBDAC, 0x6D46, 0xBDAD, 0x6C5F,\r\n\t0xBDAE, 0x7586, 0xBDAF, 0x848B, 0xBDB0, 0x6868, 0xBDB1, 0x5956,\t0xBDB2, 0x8BB2, 0xBDB3, 0x5320, 0xBDB4, 0x9171, 0xBDB5, 0x964D,\r\n\t0xBDB6, 0x8549, 0xBDB7, 0x6912, 0xBDB8, 0x7901, 0xBDB9, 0x7126,\t0xBDBA, 0x80F6, 0xBDBB, 0x4EA4, 0xBDBC, 0x90CA, 0xBDBD, 0x6D47,\r\n\t0xBDBE, 0x9A84, 0xBDBF, 0x5A07, 0xBDC0, 0x56BC, 0xBDC1, 0x6405,\t0xBDC2, 0x94F0, 0xBDC3, 0x77EB, 0xBDC4, 0x4FA5, 0xBDC5, 0x811A,\r\n\t0xBDC6, 0x72E1, 0xBDC7, 0x89D2, 0xBDC8, 0x997A, 0xBDC9, 0x7F34,\t0xBDCA, 0x7EDE, 0xBDCB, 0x527F, 0xBDCC, 0x6559, 0xBDCD, 0x9175,\r\n\t0xBDCE, 0x8F7F, 0xBDCF, 0x8F83, 0xBDD0, 0x53EB, 0xBDD1, 0x7A96,\t0xBDD2, 0x63ED, 0xBDD3, 0x63A5, 0xBDD4, 0x7686, 0xBDD5, 0x79F8,\r\n\t0xBDD6, 0x8857, 0xBDD7, 0x9636, 0xBDD8, 0x622A, 0xBDD9, 0x52AB,\t0xBDDA, 0x8282, 0xBDDB, 0x6854, 0xBDDC, 0x6770, 0xBDDD, 0x6377,\r\n\t0xBDDE, 0x776B, 0xBDDF, 0x7AED, 0xBDE0, 0x6D01, 0xBDE1, 0x7ED3,\t0xBDE2, 0x89E3, 0xBDE3, 0x59D0, 0xBDE4, 0x6212, 0xBDE5, 0x85C9,\r\n\t0xBDE6, 0x82A5, 0xBDE7, 0x754C, 0xBDE8, 0x501F, 0xBDE9, 0x4ECB,\t0xBDEA, 0x75A5, 0xBDEB, 0x8BEB, 0xBDEC, 0x5C4A, 0xBDED, 0x5DFE,\r\n\t0xBDEE, 0x7B4B, 0xBDEF, 0x65A4, 0xBDF0, 0x91D1, 0xBDF1, 0x4ECA,\t0xBDF2, 0x6D25, 0xBDF3, 0x895F, 0xBDF4, 0x7D27, 0xBDF5, 0x9526,\r\n\t0xBDF6, 0x4EC5, 0xBDF7, 0x8C28, 0xBDF8, 0x8FDB, 0xBDF9, 0x9773,\t0xBDFA, 0x664B, 0xBDFB, 0x7981, 0xBDFC, 0x8FD1, 0xBDFD, 0x70EC,\r\n\t0xBDFE, 0x6D78, 0xBE40, 0x7D99, 0xBE41, 0x7D9A, 0xBE42, 0x7D9B,\t0xBE43, 0x7D9C, 0xBE44, 0x7D9D, 0xBE45, 0x7D9E, 0xBE46, 0x7D9F,\r\n\t0xBE47, 0x7DA0, 0xBE48, 0x7DA1, 0xBE49, 0x7DA2, 0xBE4A, 0x7DA3,\t0xBE4B, 0x7DA4, 0xBE4C, 0x7DA5, 0xBE4D, 0x7DA7, 0xBE4E, 0x7DA8,\r\n\t0xBE4F, 0x7DA9, 0xBE50, 0x7DAA, 0xBE51, 0x7DAB, 0xBE52, 0x7DAC,\t0xBE53, 0x7DAD, 0xBE54, 0x7DAF, 0xBE55, 0x7DB0, 0xBE56, 0x7DB1,\r\n\t0xBE57, 0x7DB2, 0xBE58, 0x7DB3, 0xBE59, 0x7DB4, 0xBE5A, 0x7DB5,\t0xBE5B, 0x7DB6, 0xBE5C, 0x7DB7, 0xBE5D, 0x7DB8, 0xBE5E, 0x7DB9,\r\n\t0xBE5F, 0x7DBA, 0xBE60, 0x7DBB, 0xBE61, 0x7DBC, 0xBE62, 0x7DBD,\t0xBE63, 0x7DBE, 0xBE64, 0x7DBF, 0xBE65, 0x7DC0, 0xBE66, 0x7DC1,\r\n\t0xBE67, 0x7DC2, 0xBE68, 0x7DC3, 0xBE69, 0x7DC4, 0xBE6A, 0x7DC5,\t0xBE6B, 0x7DC6, 0xBE6C, 0x7DC7, 0xBE6D, 0x7DC8, 0xBE6E, 0x7DC9,\r\n\t0xBE6F, 0x7DCA, 0xBE70, 0x7DCB, 0xBE71, 0x7DCC, 0xBE72, 0x7DCD,\t0xBE73, 0x7DCE, 0xBE74, 0x7DCF, 0xBE75, 0x7DD0, 0xBE76, 0x7DD1,\r\n\t0xBE77, 0x7DD2, 0xBE78, 0x7DD3, 0xBE79, 0x7DD4, 0xBE7A, 0x7DD5,\t0xBE7B, 0x7DD6, 0xBE7C, 0x7DD7, 0xBE7D, 0x7DD8, 0xBE7E, 0x7DD9,\r\n\t0xBE80, 0x7DDA, 0xBE81, 0x7DDB, 0xBE82, 0x7DDC, 0xBE83, 0x7DDD,\t0xBE84, 0x7DDE, 0xBE85, 0x7DDF, 0xBE86, 0x7DE0, 0xBE87, 0x7DE1,\r\n\t0xBE88, 0x7DE2, 0xBE89, 0x7DE3, 0xBE8A, 0x7DE4, 0xBE8B, 0x7DE5,\t0xBE8C, 0x7DE6, 0xBE8D, 0x7DE7, 0xBE8E, 0x7DE8, 0xBE8F, 0x7DE9,\r\n\t0xBE90, 0x7DEA, 0xBE91, 0x7DEB, 0xBE92, 0x7DEC, 0xBE93, 0x7DED,\t0xBE94, 0x7DEE, 0xBE95, 0x7DEF, 0xBE96, 0x7DF0, 0xBE97, 0x7DF1,\r\n\t0xBE98, 0x7DF2, 0xBE99, 0x7DF3, 0xBE9A, 0x7DF4, 0xBE9B, 0x7DF5,\t0xBE9C, 0x7DF6, 0xBE9D, 0x7DF7, 0xBE9E, 0x7DF8, 0xBE9F, 0x7DF9,\r\n\t0xBEA0, 0x7DFA, 0xBEA1, 0x5C3D, 0xBEA2, 0x52B2, 0xBEA3, 0x8346,\t0xBEA4, 0x5162, 0xBEA5, 0x830E, 0xBEA6, 0x775B, 0xBEA7, 0x6676,\r\n\t0xBEA8, 0x9CB8, 0xBEA9, 0x4EAC, 0xBEAA, 0x60CA, 0xBEAB, 0x7CBE,\t0xBEAC, 0x7CB3, 0xBEAD, 0x7ECF, 0xBEAE, 0x4E95, 0xBEAF, 0x8B66,\r\n\t0xBEB0, 0x666F, 0xBEB1, 0x9888, 0xBEB2, 0x9759, 0xBEB3, 0x5883,\t0xBEB4, 0x656C, 0xBEB5, 0x955C, 0xBEB6, 0x5F84, 0xBEB7, 0x75C9,\r\n\t0xBEB8, 0x9756, 0xBEB9, 0x7ADF, 0xBEBA, 0x7ADE, 0xBEBB, 0x51C0,\t0xBEBC, 0x70AF, 0xBEBD, 0x7A98, 0xBEBE, 0x63EA, 0xBEBF, 0x7A76,\r\n\t0xBEC0, 0x7EA0, 0xBEC1, 0x7396, 0xBEC2, 0x97ED, 0xBEC3, 0x4E45,\t0xBEC4, 0x7078, 0xBEC5, 0x4E5D, 0xBEC6, 0x9152, 0xBEC7, 0x53A9,\r\n\t0xBEC8, 0x6551, 0xBEC9, 0x65E7, 0xBECA, 0x81FC, 0xBECB, 0x8205,\t0xBECC, 0x548E, 0xBECD, 0x5C31, 0xBECE, 0x759A, 0xBECF, 0x97A0,\r\n\t0xBED0, 0x62D8, 0xBED1, 0x72D9, 0xBED2, 0x75BD, 0xBED3, 0x5C45,\t0xBED4, 0x9A79, 0xBED5, 0x83CA, 0xBED6, 0x5C40, 0xBED7, 0x5480,\r\n\t0xBED8, 0x77E9, 0xBED9, 0x4E3E, 0xBEDA, 0x6CAE, 0xBEDB, 0x805A,\t0xBEDC, 0x62D2, 0xBEDD, 0x636E, 0xBEDE, 0x5DE8, 0xBEDF, 0x5177,\r\n\t0xBEE0, 0x8DDD, 0xBEE1, 0x8E1E, 0xBEE2, 0x952F, 0xBEE3, 0x4FF1,\t0xBEE4, 0x53E5, 0xBEE5, 0x60E7, 0xBEE6, 0x70AC, 0xBEE7, 0x5267,\r\n\t0xBEE8, 0x6350, 0xBEE9, 0x9E43, 0xBEEA, 0x5A1F, 0xBEEB, 0x5026,\t0xBEEC, 0x7737, 0xBEED, 0x5377, 0xBEEE, 0x7EE2, 0xBEEF, 0x6485,\r\n\t0xBEF0, 0x652B, 0xBEF1, 0x6289, 0xBEF2, 0x6398, 0xBEF3, 0x5014,\t0xBEF4, 0x7235, 0xBEF5, 0x89C9, 0xBEF6, 0x51B3, 0xBEF7, 0x8BC0,\r\n\t0xBEF8, 0x7EDD, 0xBEF9, 0x5747, 0xBEFA, 0x83CC, 0xBEFB, 0x94A7,\t0xBEFC, 0x519B, 0xBEFD, 0x541B, 0xBEFE, 0x5CFB, 0xBF40, 0x7DFB,\r\n\t0xBF41, 0x7DFC, 0xBF42, 0x7DFD, 0xBF43, 0x7DFE, 0xBF44, 0x7DFF,\t0xBF45, 0x7E00, 0xBF46, 0x7E01, 0xBF47, 0x7E02, 0xBF48, 0x7E03,\r\n\t0xBF49, 0x7E04, 0xBF4A, 0x7E05, 0xBF4B, 0x7E06, 0xBF4C, 0x7E07,\t0xBF4D, 0x7E08, 0xBF4E, 0x7E09, 0xBF4F, 0x7E0A, 0xBF50, 0x7E0B,\r\n\t0xBF51, 0x7E0C, 0xBF52, 0x7E0D, 0xBF53, 0x7E0E, 0xBF54, 0x7E0F,\t0xBF55, 0x7E10, 0xBF56, 0x7E11, 0xBF57, 0x7E12, 0xBF58, 0x7E13,\r\n\t0xBF59, 0x7E14, 0xBF5A, 0x7E15, 0xBF5B, 0x7E16, 0xBF5C, 0x7E17,\t0xBF5D, 0x7E18, 0xBF5E, 0x7E19, 0xBF5F, 0x7E1A, 0xBF60, 0x7E1B,\r\n\t0xBF61, 0x7E1C, 0xBF62, 0x7E1D, 0xBF63, 0x7E1E, 0xBF64, 0x7E1F,\t0xBF65, 0x7E20, 0xBF66, 0x7E21, 0xBF67, 0x7E22, 0xBF68, 0x7E23,\r\n\t0xBF69, 0x7E24, 0xBF6A, 0x7E25, 0xBF6B, 0x7E26, 0xBF6C, 0x7E27,\t0xBF6D, 0x7E28, 0xBF6E, 0x7E29, 0xBF6F, 0x7E2A, 0xBF70, 0x7E2B,\r\n\t0xBF71, 0x7E2C, 0xBF72, 0x7E2D, 0xBF73, 0x7E2E, 0xBF74, 0x7E2F,\t0xBF75, 0x7E30, 0xBF76, 0x7E31, 0xBF77, 0x7E32, 0xBF78, 0x7E33,\r\n\t0xBF79, 0x7E34, 0xBF7A, 0x7E35, 0xBF7B, 0x7E36, 0xBF7C, 0x7E37,\t0xBF7D, 0x7E38, 0xBF7E, 0x7E39, 0xBF80, 0x7E3A, 0xBF81, 0x7E3C,\r\n\t0xBF82, 0x7E3D, 0xBF83, 0x7E3E, 0xBF84, 0x7E3F, 0xBF85, 0x7E40,\t0xBF86, 0x7E42, 0xBF87, 0x7E43, 0xBF88, 0x7E44, 0xBF89, 0x7E45,\r\n\t0xBF8A, 0x7E46, 0xBF8B, 0x7E48, 0xBF8C, 0x7E49, 0xBF8D, 0x7E4A,\t0xBF8E, 0x7E4B, 0xBF8F, 0x7E4C, 0xBF90, 0x7E4D, 0xBF91, 0x7E4E,\r\n\t0xBF92, 0x7E4F, 0xBF93, 0x7E50, 0xBF94, 0x7E51, 0xBF95, 0x7E52,\t0xBF96, 0x7E53, 0xBF97, 0x7E54, 0xBF98, 0x7E55, 0xBF99, 0x7E56,\r\n\t0xBF9A, 0x7E57, 0xBF9B, 0x7E58, 0xBF9C, 0x7E59, 0xBF9D, 0x7E5A,\t0xBF9E, 0x7E5B, 0xBF9F, 0x7E5C, 0xBFA0, 0x7E5D, 0xBFA1, 0x4FCA,\r\n\t0xBFA2, 0x7AE3, 0xBFA3, 0x6D5A, 0xBFA4, 0x90E1, 0xBFA5, 0x9A8F,\t0xBFA6, 0x5580, 0xBFA7, 0x5496, 0xBFA8, 0x5361, 0xBFA9, 0x54AF,\r\n\t0xBFAA, 0x5F00, 0xBFAB, 0x63E9, 0xBFAC, 0x6977, 0xBFAD, 0x51EF,\t0xBFAE, 0x6168, 0xBFAF, 0x520A, 0xBFB0, 0x582A, 0xBFB1, 0x52D8,\r\n\t0xBFB2, 0x574E, 0xBFB3, 0x780D, 0xBFB4, 0x770B, 0xBFB5, 0x5EB7,\t0xBFB6, 0x6177, 0xBFB7, 0x7CE0, 0xBFB8, 0x625B, 0xBFB9, 0x6297,\r\n\t0xBFBA, 0x4EA2, 0xBFBB, 0x7095, 0xBFBC, 0x8003, 0xBFBD, 0x62F7,\t0xBFBE, 0x70E4, 0xBFBF, 0x9760, 0xBFC0, 0x5777, 0xBFC1, 0x82DB,\r\n\t0xBFC2, 0x67EF, 0xBFC3, 0x68F5, 0xBFC4, 0x78D5, 0xBFC5, 0x9897,\t0xBFC6, 0x79D1, 0xBFC7, 0x58F3, 0xBFC8, 0x54B3, 0xBFC9, 0x53EF,\r\n\t0xBFCA, 0x6E34, 0xBFCB, 0x514B, 0xBFCC, 0x523B, 0xBFCD, 0x5BA2,\t0xBFCE, 0x8BFE, 0xBFCF, 0x80AF, 0xBFD0, 0x5543, 0xBFD1, 0x57A6,\r\n\t0xBFD2, 0x6073, 0xBFD3, 0x5751, 0xBFD4, 0x542D, 0xBFD5, 0x7A7A,\t0xBFD6, 0x6050, 0xBFD7, 0x5B54, 0xBFD8, 0x63A7, 0xBFD9, 0x62A0,\r\n\t0xBFDA, 0x53E3, 0xBFDB, 0x6263, 0xBFDC, 0x5BC7, 0xBFDD, 0x67AF,\t0xBFDE, 0x54ED, 0xBFDF, 0x7A9F, 0xBFE0, 0x82E6, 0xBFE1, 0x9177,\r\n\t0xBFE2, 0x5E93, 0xBFE3, 0x88E4, 0xBFE4, 0x5938, 0xBFE5, 0x57AE,\t0xBFE6, 0x630E, 0xBFE7, 0x8DE8, 0xBFE8, 0x80EF, 0xBFE9, 0x5757,\r\n\t0xBFEA, 0x7B77, 0xBFEB, 0x4FA9, 0xBFEC, 0x5FEB, 0xBFED, 0x5BBD,\t0xBFEE, 0x6B3E, 0xBFEF, 0x5321, 0xBFF0, 0x7B50, 0xBFF1, 0x72C2,\r\n\t0xBFF2, 0x6846, 0xBFF3, 0x77FF, 0xBFF4, 0x7736, 0xBFF5, 0x65F7,\t0xBFF6, 0x51B5, 0xBFF7, 0x4E8F, 0xBFF8, 0x76D4, 0xBFF9, 0x5CBF,\r\n\t0xBFFA, 0x7AA5, 0xBFFB, 0x8475, 0xBFFC, 0x594E, 0xBFFD, 0x9B41,\t0xBFFE, 0x5080, 0xC040, 0x7E5E, 0xC041, 0x7E5F, 0xC042, 0x7E60,\r\n\t0xC043, 0x7E61, 0xC044, 0x7E62, 0xC045, 0x7E63, 0xC046, 0x7E64,\t0xC047, 0x7E65, 0xC048, 0x7E66, 0xC049, 0x7E67, 0xC04A, 0x7E68,\r\n\t0xC04B, 0x7E69, 0xC04C, 0x7E6A, 0xC04D, 0x7E6B, 0xC04E, 0x7E6C,\t0xC04F, 0x7E6D, 0xC050, 0x7E6E, 0xC051, 0x7E6F, 0xC052, 0x7E70,\r\n\t0xC053, 0x7E71, 0xC054, 0x7E72, 0xC055, 0x7E73, 0xC056, 0x7E74,\t0xC057, 0x7E75, 0xC058, 0x7E76, 0xC059, 0x7E77, 0xC05A, 0x7E78,\r\n\t0xC05B, 0x7E79, 0xC05C, 0x7E7A, 0xC05D, 0x7E7B, 0xC05E, 0x7E7C,\t0xC05F, 0x7E7D, 0xC060, 0x7E7E, 0xC061, 0x7E7F, 0xC062, 0x7E80,\r\n\t0xC063, 0x7E81, 0xC064, 0x7E83, 0xC065, 0x7E84, 0xC066, 0x7E85,\t0xC067, 0x7E86, 0xC068, 0x7E87, 0xC069, 0x7E88, 0xC06A, 0x7E89,\r\n\t0xC06B, 0x7E8A, 0xC06C, 0x7E8B, 0xC06D, 0x7E8C, 0xC06E, 0x7E8D,\t0xC06F, 0x7E8E, 0xC070, 0x7E8F, 0xC071, 0x7E90, 0xC072, 0x7E91,\r\n\t0xC073, 0x7E92, 0xC074, 0x7E93, 0xC075, 0x7E94, 0xC076, 0x7E95,\t0xC077, 0x7E96, 0xC078, 0x7E97, 0xC079, 0x7E98, 0xC07A, 0x7E99,\r\n\t0xC07B, 0x7E9A, 0xC07C, 0x7E9C, 0xC07D, 0x7E9D, 0xC07E, 0x7E9E,\t0xC080, 0x7EAE, 0xC081, 0x7EB4, 0xC082, 0x7EBB, 0xC083, 0x7EBC,\r\n\t0xC084, 0x7ED6, 0xC085, 0x7EE4, 0xC086, 0x7EEC, 0xC087, 0x7EF9,\t0xC088, 0x7F0A, 0xC089, 0x7F10, 0xC08A, 0x7F1E, 0xC08B, 0x7F37,\r\n\t0xC08C, 0x7F39, 0xC08D, 0x7F3B, 0xC08E, 0x7F3C, 0xC08F, 0x7F3D,\t0xC090, 0x7F3E, 0xC091, 0x7F3F, 0xC092, 0x7F40, 0xC093, 0x7F41,\r\n\t0xC094, 0x7F43, 0xC095, 0x7F46, 0xC096, 0x7F47, 0xC097, 0x7F48,\t0xC098, 0x7F49, 0xC099, 0x7F4A, 0xC09A, 0x7F4B, 0xC09B, 0x7F4C,\r\n\t0xC09C, 0x7F4D, 0xC09D, 0x7F4E, 0xC09E, 0x7F4F, 0xC09F, 0x7F52,\t0xC0A0, 0x7F53, 0xC0A1, 0x9988, 0xC0A2, 0x6127, 0xC0A3, 0x6E83,\r\n\t0xC0A4, 0x5764, 0xC0A5, 0x6606, 0xC0A6, 0x6346, 0xC0A7, 0x56F0,\t0xC0A8, 0x62EC, 0xC0A9, 0x6269, 0xC0AA, 0x5ED3, 0xC0AB, 0x9614,\r\n\t0xC0AC, 0x5783, 0xC0AD, 0x62C9, 0xC0AE, 0x5587, 0xC0AF, 0x8721,\t0xC0B0, 0x814A, 0xC0B1, 0x8FA3, 0xC0B2, 0x5566, 0xC0B3, 0x83B1,\r\n\t0xC0B4, 0x6765, 0xC0B5, 0x8D56, 0xC0B6, 0x84DD, 0xC0B7, 0x5A6A,\t0xC0B8, 0x680F, 0xC0B9, 0x62E6, 0xC0BA, 0x7BEE, 0xC0BB, 0x9611,\r\n\t0xC0BC, 0x5170, 0xC0BD, 0x6F9C, 0xC0BE, 0x8C30, 0xC0BF, 0x63FD,\t0xC0C0, 0x89C8, 0xC0C1, 0x61D2, 0xC0C2, 0x7F06, 0xC0C3, 0x70C2,\r\n\t0xC0C4, 0x6EE5, 0xC0C5, 0x7405, 0xC0C6, 0x6994, 0xC0C7, 0x72FC,\t0xC0C8, 0x5ECA, 0xC0C9, 0x90CE, 0xC0CA, 0x6717, 0xC0CB, 0x6D6A,\r\n\t0xC0CC, 0x635E, 0xC0CD, 0x52B3, 0xC0CE, 0x7262, 0xC0CF, 0x8001,\t0xC0D0, 0x4F6C, 0xC0D1, 0x59E5, 0xC0D2, 0x916A, 0xC0D3, 0x70D9,\r\n\t0xC0D4, 0x6D9D, 0xC0D5, 0x52D2, 0xC0D6, 0x4E50, 0xC0D7, 0x96F7,\t0xC0D8, 0x956D, 0xC0D9, 0x857E, 0xC0DA, 0x78CA, 0xC0DB, 0x7D2F,\r\n\t0xC0DC, 0x5121, 0xC0DD, 0x5792, 0xC0DE, 0x64C2, 0xC0DF, 0x808B,\t0xC0E0, 0x7C7B, 0xC0E1, 0x6CEA, 0xC0E2, 0x68F1, 0xC0E3, 0x695E,\r\n\t0xC0E4, 0x51B7, 0xC0E5, 0x5398, 0xC0E6, 0x68A8, 0xC0E7, 0x7281,\t0xC0E8, 0x9ECE, 0xC0E9, 0x7BF1, 0xC0EA, 0x72F8, 0xC0EB, 0x79BB,\r\n\t0xC0EC, 0x6F13, 0xC0ED, 0x7406, 0xC0EE, 0x674E, 0xC0EF, 0x91CC,\t0xC0F0, 0x9CA4, 0xC0F1, 0x793C, 0xC0F2, 0x8389, 0xC0F3, 0x8354,\r\n\t0xC0F4, 0x540F, 0xC0F5, 0x6817, 0xC0F6, 0x4E3D, 0xC0F7, 0x5389,\t0xC0F8, 0x52B1, 0xC0F9, 0x783E, 0xC0FA, 0x5386, 0xC0FB, 0x5229,\r\n\t0xC0FC, 0x5088, 0xC0FD, 0x4F8B, 0xC0FE, 0x4FD0, 0xC140, 0x7F56,\t0xC141, 0x7F59, 0xC142, 0x7F5B, 0xC143, 0x7F5C, 0xC144, 0x7F5D,\r\n\t0xC145, 0x7F5E, 0xC146, 0x7F60, 0xC147, 0x7F63, 0xC148, 0x7F64,\t0xC149, 0x7F65, 0xC14A, 0x7F66, 0xC14B, 0x7F67, 0xC14C, 0x7F6B,\r\n\t0xC14D, 0x7F6C, 0xC14E, 0x7F6D, 0xC14F, 0x7F6F, 0xC150, 0x7F70,\t0xC151, 0x7F73, 0xC152, 0x7F75, 0xC153, 0x7F76, 0xC154, 0x7F77,\r\n\t0xC155, 0x7F78, 0xC156, 0x7F7A, 0xC157, 0x7F7B, 0xC158, 0x7F7C,\t0xC159, 0x7F7D, 0xC15A, 0x7F7F, 0xC15B, 0x7F80, 0xC15C, 0x7F82,\r\n\t0xC15D, 0x7F83, 0xC15E, 0x7F84, 0xC15F, 0x7F85, 0xC160, 0x7F86,\t0xC161, 0x7F87, 0xC162, 0x7F88, 0xC163, 0x7F89, 0xC164, 0x7F8B,\r\n\t0xC165, 0x7F8D, 0xC166, 0x7F8F, 0xC167, 0x7F90, 0xC168, 0x7F91,\t0xC169, 0x7F92, 0xC16A, 0x7F93, 0xC16B, 0x7F95, 0xC16C, 0x7F96,\r\n\t0xC16D, 0x7F97, 0xC16E, 0x7F98, 0xC16F, 0x7F99, 0xC170, 0x7F9B,\t0xC171, 0x7F9C, 0xC172, 0x7FA0, 0xC173, 0x7FA2, 0xC174, 0x7FA3,\r\n\t0xC175, 0x7FA5, 0xC176, 0x7FA6, 0xC177, 0x7FA8, 0xC178, 0x7FA9,\t0xC179, 0x7FAA, 0xC17A, 0x7FAB, 0xC17B, 0x7FAC, 0xC17C, 0x7FAD,\r\n\t0xC17D, 0x7FAE, 0xC17E, 0x7FB1, 0xC180, 0x7FB3, 0xC181, 0x7FB4,\t0xC182, 0x7FB5, 0xC183, 0x7FB6, 0xC184, 0x7FB7, 0xC185, 0x7FBA,\r\n\t0xC186, 0x7FBB, 0xC187, 0x7FBE, 0xC188, 0x7FC0, 0xC189, 0x7FC2,\t0xC18A, 0x7FC3, 0xC18B, 0x7FC4, 0xC18C, 0x7FC6, 0xC18D, 0x7FC7,\r\n\t0xC18E, 0x7FC8, 0xC18F, 0x7FC9, 0xC190, 0x7FCB, 0xC191, 0x7FCD,\t0xC192, 0x7FCF, 0xC193, 0x7FD0, 0xC194, 0x7FD1, 0xC195, 0x7FD2,\r\n\t0xC196, 0x7FD3, 0xC197, 0x7FD6, 0xC198, 0x7FD7, 0xC199, 0x7FD9,\t0xC19A, 0x7FDA, 0xC19B, 0x7FDB, 0xC19C, 0x7FDC, 0xC19D, 0x7FDD,\r\n\t0xC19E, 0x7FDE, 0xC19F, 0x7FE2, 0xC1A0, 0x7FE3, 0xC1A1, 0x75E2,\t0xC1A2, 0x7ACB, 0xC1A3, 0x7C92, 0xC1A4, 0x6CA5, 0xC1A5, 0x96B6,\r\n\t0xC1A6, 0x529B, 0xC1A7, 0x7483, 0xC1A8, 0x54E9, 0xC1A9, 0x4FE9,\t0xC1AA, 0x8054, 0xC1AB, 0x83B2, 0xC1AC, 0x8FDE, 0xC1AD, 0x9570,\r\n\t0xC1AE, 0x5EC9, 0xC1AF, 0x601C, 0xC1B0, 0x6D9F, 0xC1B1, 0x5E18,\t0xC1B2, 0x655B, 0xC1B3, 0x8138, 0xC1B4, 0x94FE, 0xC1B5, 0x604B,\r\n\t0xC1B6, 0x70BC, 0xC1B7, 0x7EC3, 0xC1B8, 0x7CAE, 0xC1B9, 0x51C9,\t0xC1BA, 0x6881, 0xC1BB, 0x7CB1, 0xC1BC, 0x826F, 0xC1BD, 0x4E24,\r\n\t0xC1BE, 0x8F86, 0xC1BF, 0x91CF, 0xC1C0, 0x667E, 0xC1C1, 0x4EAE,\t0xC1C2, 0x8C05, 0xC1C3, 0x64A9, 0xC1C4, 0x804A, 0xC1C5, 0x50DA,\r\n\t0xC1C6, 0x7597, 0xC1C7, 0x71CE, 0xC1C8, 0x5BE5, 0xC1C9, 0x8FBD,\t0xC1CA, 0x6F66, 0xC1CB, 0x4E86, 0xC1CC, 0x6482, 0xC1CD, 0x9563,\r\n\t0xC1CE, 0x5ED6, 0xC1CF, 0x6599, 0xC1D0, 0x5217, 0xC1D1, 0x88C2,\t0xC1D2, 0x70C8, 0xC1D3, 0x52A3, 0xC1D4, 0x730E, 0xC1D5, 0x7433,\r\n\t0xC1D6, 0x6797, 0xC1D7, 0x78F7, 0xC1D8, 0x9716, 0xC1D9, 0x4E34,\t0xC1DA, 0x90BB, 0xC1DB, 0x9CDE, 0xC1DC, 0x6DCB, 0xC1DD, 0x51DB,\r\n\t0xC1DE, 0x8D41, 0xC1DF, 0x541D, 0xC1E0, 0x62CE, 0xC1E1, 0x73B2,\t0xC1E2, 0x83F1, 0xC1E3, 0x96F6, 0xC1E4, 0x9F84, 0xC1E5, 0x94C3,\r\n\t0xC1E6, 0x4F36, 0xC1E7, 0x7F9A, 0xC1E8, 0x51CC, 0xC1E9, 0x7075,\t0xC1EA, 0x9675, 0xC1EB, 0x5CAD, 0xC1EC, 0x9886, 0xC1ED, 0x53E6,\r\n\t0xC1EE, 0x4EE4, 0xC1EF, 0x6E9C, 0xC1F0, 0x7409, 0xC1F1, 0x69B4,\t0xC1F2, 0x786B, 0xC1F3, 0x998F, 0xC1F4, 0x7559, 0xC1F5, 0x5218,\r\n\t0xC1F6, 0x7624, 0xC1F7, 0x6D41, 0xC1F8, 0x67F3, 0xC1F9, 0x516D,\t0xC1FA, 0x9F99, 0xC1FB, 0x804B, 0xC1FC, 0x5499, 0xC1FD, 0x7B3C,\r\n\t0xC1FE, 0x7ABF, 0xC240, 0x7FE4, 0xC241, 0x7FE7, 0xC242, 0x7FE8,\t0xC243, 0x7FEA, 0xC244, 0x7FEB, 0xC245, 0x7FEC, 0xC246, 0x7FED,\r\n\t0xC247, 0x7FEF, 0xC248, 0x7FF2, 0xC249, 0x7FF4, 0xC24A, 0x7FF5,\t0xC24B, 0x7FF6, 0xC24C, 0x7FF7, 0xC24D, 0x7FF8, 0xC24E, 0x7FF9,\r\n\t0xC24F, 0x7FFA, 0xC250, 0x7FFD, 0xC251, 0x7FFE, 0xC252, 0x7FFF,\t0xC253, 0x8002, 0xC254, 0x8007, 0xC255, 0x8008, 0xC256, 0x8009,\r\n\t0xC257, 0x800A, 0xC258, 0x800E, 0xC259, 0x800F, 0xC25A, 0x8011,\t0xC25B, 0x8013, 0xC25C, 0x801A, 0xC25D, 0x801B, 0xC25E, 0x801D,\r\n\t0xC25F, 0x801E, 0xC260, 0x801F, 0xC261, 0x8021, 0xC262, 0x8023,\t0xC263, 0x8024, 0xC264, 0x802B, 0xC265, 0x802C, 0xC266, 0x802D,\r\n\t0xC267, 0x802E, 0xC268, 0x802F, 0xC269, 0x8030, 0xC26A, 0x8032,\t0xC26B, 0x8034, 0xC26C, 0x8039, 0xC26D, 0x803A, 0xC26E, 0x803C,\r\n\t0xC26F, 0x803E, 0xC270, 0x8040, 0xC271, 0x8041, 0xC272, 0x8044,\t0xC273, 0x8045, 0xC274, 0x8047, 0xC275, 0x8048, 0xC276, 0x8049,\r\n\t0xC277, 0x804E, 0xC278, 0x804F, 0xC279, 0x8050, 0xC27A, 0x8051,\t0xC27B, 0x8053, 0xC27C, 0x8055, 0xC27D, 0x8056, 0xC27E, 0x8057,\r\n\t0xC280, 0x8059, 0xC281, 0x805B, 0xC282, 0x805C, 0xC283, 0x805D,\t0xC284, 0x805E, 0xC285, 0x805F, 0xC286, 0x8060, 0xC287, 0x8061,\r\n\t0xC288, 0x8062, 0xC289, 0x8063, 0xC28A, 0x8064, 0xC28B, 0x8065,\t0xC28C, 0x8066, 0xC28D, 0x8067, 0xC28E, 0x8068, 0xC28F, 0x806B,\r\n\t0xC290, 0x806C, 0xC291, 0x806D, 0xC292, 0x806E, 0xC293, 0x806F,\t0xC294, 0x8070, 0xC295, 0x8072, 0xC296, 0x8073, 0xC297, 0x8074,\r\n\t0xC298, 0x8075, 0xC299, 0x8076, 0xC29A, 0x8077, 0xC29B, 0x8078,\t0xC29C, 0x8079, 0xC29D, 0x807A, 0xC29E, 0x807B, 0xC29F, 0x807C,\r\n\t0xC2A0, 0x807D, 0xC2A1, 0x9686, 0xC2A2, 0x5784, 0xC2A3, 0x62E2,\t0xC2A4, 0x9647, 0xC2A5, 0x697C, 0xC2A6, 0x5A04, 0xC2A7, 0x6402,\r\n\t0xC2A8, 0x7BD3, 0xC2A9, 0x6F0F, 0xC2AA, 0x964B, 0xC2AB, 0x82A6,\t0xC2AC, 0x5362, 0xC2AD, 0x9885, 0xC2AE, 0x5E90, 0xC2AF, 0x7089,\r\n\t0xC2B0, 0x63B3, 0xC2B1, 0x5364, 0xC2B2, 0x864F, 0xC2B3, 0x9C81,\t0xC2B4, 0x9E93, 0xC2B5, 0x788C, 0xC2B6, 0x9732, 0xC2B7, 0x8DEF,\r\n\t0xC2B8, 0x8D42, 0xC2B9, 0x9E7F, 0xC2BA, 0x6F5E, 0xC2BB, 0x7984,\t0xC2BC, 0x5F55, 0xC2BD, 0x9646, 0xC2BE, 0x622E, 0xC2BF, 0x9A74,\r\n\t0xC2C0, 0x5415, 0xC2C1, 0x94DD, 0xC2C2, 0x4FA3, 0xC2C3, 0x65C5,\t0xC2C4, 0x5C65, 0xC2C5, 0x5C61, 0xC2C6, 0x7F15, 0xC2C7, 0x8651,\r\n\t0xC2C8, 0x6C2F, 0xC2C9, 0x5F8B, 0xC2CA, 0x7387, 0xC2CB, 0x6EE4,\t0xC2CC, 0x7EFF, 0xC2CD, 0x5CE6, 0xC2CE, 0x631B, 0xC2CF, 0x5B6A,\r\n\t0xC2D0, 0x6EE6, 0xC2D1, 0x5375, 0xC2D2, 0x4E71, 0xC2D3, 0x63A0,\t0xC2D4, 0x7565, 0xC2D5, 0x62A1, 0xC2D6, 0x8F6E, 0xC2D7, 0x4F26,\r\n\t0xC2D8, 0x4ED1, 0xC2D9, 0x6CA6, 0xC2DA, 0x7EB6, 0xC2DB, 0x8BBA,\t0xC2DC, 0x841D, 0xC2DD, 0x87BA, 0xC2DE, 0x7F57, 0xC2DF, 0x903B,\r\n\t0xC2E0, 0x9523, 0xC2E1, 0x7BA9, 0xC2E2, 0x9AA1, 0xC2E3, 0x88F8,\t0xC2E4, 0x843D, 0xC2E5, 0x6D1B, 0xC2E6, 0x9A86, 0xC2E7, 0x7EDC,\r\n\t0xC2E8, 0x5988, 0xC2E9, 0x9EBB, 0xC2EA, 0x739B, 0xC2EB, 0x7801,\t0xC2EC, 0x8682, 0xC2ED, 0x9A6C, 0xC2EE, 0x9A82, 0xC2EF, 0x561B,\r\n\t0xC2F0, 0x5417, 0xC2F1, 0x57CB, 0xC2F2, 0x4E70, 0xC2F3, 0x9EA6,\t0xC2F4, 0x5356, 0xC2F5, 0x8FC8, 0xC2F6, 0x8109, 0xC2F7, 0x7792,\r\n\t0xC2F8, 0x9992, 0xC2F9, 0x86EE, 0xC2FA, 0x6EE1, 0xC2FB, 0x8513,\t0xC2FC, 0x66FC, 0xC2FD, 0x6162, 0xC2FE, 0x6F2B, 0xC340, 0x807E,\r\n\t0xC341, 0x8081, 0xC342, 0x8082, 0xC343, 0x8085, 0xC344, 0x8088,\t0xC345, 0x808A, 0xC346, 0x808D, 0xC347, 0x808E, 0xC348, 0x808F,\r\n\t0xC349, 0x8090, 0xC34A, 0x8091, 0xC34B, 0x8092, 0xC34C, 0x8094,\t0xC34D, 0x8095, 0xC34E, 0x8097, 0xC34F, 0x8099, 0xC350, 0x809E,\r\n\t0xC351, 0x80A3, 0xC352, 0x80A6, 0xC353, 0x80A7, 0xC354, 0x80A8,\t0xC355, 0x80AC, 0xC356, 0x80B0, 0xC357, 0x80B3, 0xC358, 0x80B5,\r\n\t0xC359, 0x80B6, 0xC35A, 0x80B8, 0xC35B, 0x80B9, 0xC35C, 0x80BB,\t0xC35D, 0x80C5, 0xC35E, 0x80C7, 0xC35F, 0x80C8, 0xC360, 0x80C9,\r\n\t0xC361, 0x80CA, 0xC362, 0x80CB, 0xC363, 0x80CF, 0xC364, 0x80D0,\t0xC365, 0x80D1, 0xC366, 0x80D2, 0xC367, 0x80D3, 0xC368, 0x80D4,\r\n\t0xC369, 0x80D5, 0xC36A, 0x80D8, 0xC36B, 0x80DF, 0xC36C, 0x80E0,\t0xC36D, 0x80E2, 0xC36E, 0x80E3, 0xC36F, 0x80E6, 0xC370, 0x80EE,\r\n\t0xC371, 0x80F5, 0xC372, 0x80F7, 0xC373, 0x80F9, 0xC374, 0x80FB,\t0xC375, 0x80FE, 0xC376, 0x80FF, 0xC377, 0x8100, 0xC378, 0x8101,\r\n\t0xC379, 0x8103, 0xC37A, 0x8104, 0xC37B, 0x8105, 0xC37C, 0x8107,\t0xC37D, 0x8108, 0xC37E, 0x810B, 0xC380, 0x810C, 0xC381, 0x8115,\r\n\t0xC382, 0x8117, 0xC383, 0x8119, 0xC384, 0x811B, 0xC385, 0x811C,\t0xC386, 0x811D, 0xC387, 0x811F, 0xC388, 0x8120, 0xC389, 0x8121,\r\n\t0xC38A, 0x8122, 0xC38B, 0x8123, 0xC38C, 0x8124, 0xC38D, 0x8125,\t0xC38E, 0x8126, 0xC38F, 0x8127, 0xC390, 0x8128, 0xC391, 0x8129,\r\n\t0xC392, 0x812A, 0xC393, 0x812B, 0xC394, 0x812D, 0xC395, 0x812E,\t0xC396, 0x8130, 0xC397, 0x8133, 0xC398, 0x8134, 0xC399, 0x8135,\r\n\t0xC39A, 0x8137, 0xC39B, 0x8139, 0xC39C, 0x813A, 0xC39D, 0x813B,\t0xC39E, 0x813C, 0xC39F, 0x813D, 0xC3A0, 0x813F, 0xC3A1, 0x8C29,\r\n\t0xC3A2, 0x8292, 0xC3A3, 0x832B, 0xC3A4, 0x76F2, 0xC3A5, 0x6C13,\t0xC3A6, 0x5FD9, 0xC3A7, 0x83BD, 0xC3A8, 0x732B, 0xC3A9, 0x8305,\r\n\t0xC3AA, 0x951A, 0xC3AB, 0x6BDB, 0xC3AC, 0x77DB, 0xC3AD, 0x94C6,\t0xC3AE, 0x536F, 0xC3AF, 0x8302, 0xC3B0, 0x5192, 0xC3B1, 0x5E3D,\r\n\t0xC3B2, 0x8C8C, 0xC3B3, 0x8D38, 0xC3B4, 0x4E48, 0xC3B5, 0x73AB,\t0xC3B6, 0x679A, 0xC3B7, 0x6885, 0xC3B8, 0x9176, 0xC3B9, 0x9709,\r\n\t0xC3BA, 0x7164, 0xC3BB, 0x6CA1, 0xC3BC, 0x7709, 0xC3BD, 0x5A92,\t0xC3BE, 0x9541, 0xC3BF, 0x6BCF, 0xC3C0, 0x7F8E, 0xC3C1, 0x6627,\r\n\t0xC3C2, 0x5BD0, 0xC3C3, 0x59B9, 0xC3C4, 0x5A9A, 0xC3C5, 0x95E8,\t0xC3C6, 0x95F7, 0xC3C7, 0x4EEC, 0xC3C8, 0x840C, 0xC3C9, 0x8499,\r\n\t0xC3CA, 0x6AAC, 0xC3CB, 0x76DF, 0xC3CC, 0x9530, 0xC3CD, 0x731B,\t0xC3CE, 0x68A6, 0xC3CF, 0x5B5F, 0xC3D0, 0x772F, 0xC3D1, 0x919A,\r\n\t0xC3D2, 0x9761, 0xC3D3, 0x7CDC, 0xC3D4, 0x8FF7, 0xC3D5, 0x8C1C,\t0xC3D6, 0x5F25, 0xC3D7, 0x7C73, 0xC3D8, 0x79D8, 0xC3D9, 0x89C5,\r\n\t0xC3DA, 0x6CCC, 0xC3DB, 0x871C, 0xC3DC, 0x5BC6, 0xC3DD, 0x5E42,\t0xC3DE, 0x68C9, 0xC3DF, 0x7720, 0xC3E0, 0x7EF5, 0xC3E1, 0x5195,\r\n\t0xC3E2, 0x514D, 0xC3E3, 0x52C9, 0xC3E4, 0x5A29, 0xC3E5, 0x7F05,\t0xC3E6, 0x9762, 0xC3E7, 0x82D7, 0xC3E8, 0x63CF, 0xC3E9, 0x7784,\r\n\t0xC3EA, 0x85D0, 0xC3EB, 0x79D2, 0xC3EC, 0x6E3A, 0xC3ED, 0x5E99,\t0xC3EE, 0x5999, 0xC3EF, 0x8511, 0xC3F0, 0x706D, 0xC3F1, 0x6C11,\r\n\t0xC3F2, 0x62BF, 0xC3F3, 0x76BF, 0xC3F4, 0x654F, 0xC3F5, 0x60AF,\t0xC3F6, 0x95FD, 0xC3F7, 0x660E, 0xC3F8, 0x879F, 0xC3F9, 0x9E23,\r\n\t0xC3FA, 0x94ED, 0xC3FB, 0x540D, 0xC3FC, 0x547D, 0xC3FD, 0x8C2C,\t0xC3FE, 0x6478, 0xC440, 0x8140, 0xC441, 0x8141, 0xC442, 0x8142,\r\n\t0xC443, 0x8143, 0xC444, 0x8144, 0xC445, 0x8145, 0xC446, 0x8147,\t0xC447, 0x8149, 0xC448, 0x814D, 0xC449, 0x814E, 0xC44A, 0x814F,\r\n\t0xC44B, 0x8152, 0xC44C, 0x8156, 0xC44D, 0x8157, 0xC44E, 0x8158,\t0xC44F, 0x815B, 0xC450, 0x815C, 0xC451, 0x815D, 0xC452, 0x815E,\r\n\t0xC453, 0x815F, 0xC454, 0x8161, 0xC455, 0x8162, 0xC456, 0x8163,\t0xC457, 0x8164, 0xC458, 0x8166, 0xC459, 0x8168, 0xC45A, 0x816A,\r\n\t0xC45B, 0x816B, 0xC45C, 0x816C, 0xC45D, 0x816F, 0xC45E, 0x8172,\t0xC45F, 0x8173, 0xC460, 0x8175, 0xC461, 0x8176, 0xC462, 0x8177,\r\n\t0xC463, 0x8178, 0xC464, 0x8181, 0xC465, 0x8183, 0xC466, 0x8184,\t0xC467, 0x8185, 0xC468, 0x8186, 0xC469, 0x8187, 0xC46A, 0x8189,\r\n\t0xC46B, 0x818B, 0xC46C, 0x818C, 0xC46D, 0x818D, 0xC46E, 0x818E,\t0xC46F, 0x8190, 0xC470, 0x8192, 0xC471, 0x8193, 0xC472, 0x8194,\r\n\t0xC473, 0x8195, 0xC474, 0x8196, 0xC475, 0x8197, 0xC476, 0x8199,\t0xC477, 0x819A, 0xC478, 0x819E, 0xC479, 0x819F, 0xC47A, 0x81A0,\r\n\t0xC47B, 0x81A1, 0xC47C, 0x81A2, 0xC47D, 0x81A4, 0xC47E, 0x81A5,\t0xC480, 0x81A7, 0xC481, 0x81A9, 0xC482, 0x81AB, 0xC483, 0x81AC,\r\n\t0xC484, 0x81AD, 0xC485, 0x81AE, 0xC486, 0x81AF, 0xC487, 0x81B0,\t0xC488, 0x81B1, 0xC489, 0x81B2, 0xC48A, 0x81B4, 0xC48B, 0x81B5,\r\n\t0xC48C, 0x81B6, 0xC48D, 0x81B7, 0xC48E, 0x81B8, 0xC48F, 0x81B9,\t0xC490, 0x81BC, 0xC491, 0x81BD, 0xC492, 0x81BE, 0xC493, 0x81BF,\r\n\t0xC494, 0x81C4, 0xC495, 0x81C5, 0xC496, 0x81C7, 0xC497, 0x81C8,\t0xC498, 0x81C9, 0xC499, 0x81CB, 0xC49A, 0x81CD, 0xC49B, 0x81CE,\r\n\t0xC49C, 0x81CF, 0xC49D, 0x81D0, 0xC49E, 0x81D1, 0xC49F, 0x81D2,\t0xC4A0, 0x81D3, 0xC4A1, 0x6479, 0xC4A2, 0x8611, 0xC4A3, 0x6A21,\r\n\t0xC4A4, 0x819C, 0xC4A5, 0x78E8, 0xC4A6, 0x6469, 0xC4A7, 0x9B54,\t0xC4A8, 0x62B9, 0xC4A9, 0x672B, 0xC4AA, 0x83AB, 0xC4AB, 0x58A8,\r\n\t0xC4AC, 0x9ED8, 0xC4AD, 0x6CAB, 0xC4AE, 0x6F20, 0xC4AF, 0x5BDE,\t0xC4B0, 0x964C, 0xC4B1, 0x8C0B, 0xC4B2, 0x725F, 0xC4B3, 0x67D0,\r\n\t0xC4B4, 0x62C7, 0xC4B5, 0x7261, 0xC4B6, 0x4EA9, 0xC4B7, 0x59C6,\t0xC4B8, 0x6BCD, 0xC4B9, 0x5893, 0xC4BA, 0x66AE, 0xC4BB, 0x5E55,\r\n\t0xC4BC, 0x52DF, 0xC4BD, 0x6155, 0xC4BE, 0x6728, 0xC4BF, 0x76EE,\t0xC4C0, 0x7766, 0xC4C1, 0x7267, 0xC4C2, 0x7A46, 0xC4C3, 0x62FF,\r\n\t0xC4C4, 0x54EA, 0xC4C5, 0x5450, 0xC4C6, 0x94A0, 0xC4C7, 0x90A3,\t0xC4C8, 0x5A1C, 0xC4C9, 0x7EB3, 0xC4CA, 0x6C16, 0xC4CB, 0x4E43,\r\n\t0xC4CC, 0x5976, 0xC4CD, 0x8010, 0xC4CE, 0x5948, 0xC4CF, 0x5357,\t0xC4D0, 0x7537, 0xC4D1, 0x96BE, 0xC4D2, 0x56CA, 0xC4D3, 0x6320,\r\n\t0xC4D4, 0x8111, 0xC4D5, 0x607C, 0xC4D6, 0x95F9, 0xC4D7, 0x6DD6,\t0xC4D8, 0x5462, 0xC4D9, 0x9981, 0xC4DA, 0x5185, 0xC4DB, 0x5AE9,\r\n\t0xC4DC, 0x80FD, 0xC4DD, 0x59AE, 0xC4DE, 0x9713, 0xC4DF, 0x502A,\t0xC4E0, 0x6CE5, 0xC4E1, 0x5C3C, 0xC4E2, 0x62DF, 0xC4E3, 0x4F60,\r\n\t0xC4E4, 0x533F, 0xC4E5, 0x817B, 0xC4E6, 0x9006, 0xC4E7, 0x6EBA,\t0xC4E8, 0x852B, 0xC4E9, 0x62C8, 0xC4EA, 0x5E74, 0xC4EB, 0x78BE,\r\n\t0xC4EC, 0x64B5, 0xC4ED, 0x637B, 0xC4EE, 0x5FF5, 0xC4EF, 0x5A18,\t0xC4F0, 0x917F, 0xC4F1, 0x9E1F, 0xC4F2, 0x5C3F, 0xC4F3, 0x634F,\r\n\t0xC4F4, 0x8042, 0xC4F5, 0x5B7D, 0xC4F6, 0x556E, 0xC4F7, 0x954A,\t0xC4F8, 0x954D, 0xC4F9, 0x6D85, 0xC4FA, 0x60A8, 0xC4FB, 0x67E0,\r\n\t0xC4FC, 0x72DE, 0xC4FD, 0x51DD, 0xC4FE, 0x5B81, 0xC540, 0x81D4,\t0xC541, 0x81D5, 0xC542, 0x81D6, 0xC543, 0x81D7, 0xC544, 0x81D8,\r\n\t0xC545, 0x81D9, 0xC546, 0x81DA, 0xC547, 0x81DB, 0xC548, 0x81DC,\t0xC549, 0x81DD, 0xC54A, 0x81DE, 0xC54B, 0x81DF, 0xC54C, 0x81E0,\r\n\t0xC54D, 0x81E1, 0xC54E, 0x81E2, 0xC54F, 0x81E4, 0xC550, 0x81E5,\t0xC551, 0x81E6, 0xC552, 0x81E8, 0xC553, 0x81E9, 0xC554, 0x81EB,\r\n\t0xC555, 0x81EE, 0xC556, 0x81EF, 0xC557, 0x81F0, 0xC558, 0x81F1,\t0xC559, 0x81F2, 0xC55A, 0x81F5, 0xC55B, 0x81F6, 0xC55C, 0x81F7,\r\n\t0xC55D, 0x81F8, 0xC55E, 0x81F9, 0xC55F, 0x81FA, 0xC560, 0x81FD,\t0xC561, 0x81FF, 0xC562, 0x8203, 0xC563, 0x8207, 0xC564, 0x8208,\r\n\t0xC565, 0x8209, 0xC566, 0x820A, 0xC567, 0x820B, 0xC568, 0x820E,\t0xC569, 0x820F, 0xC56A, 0x8211, 0xC56B, 0x8213, 0xC56C, 0x8215,\r\n\t0xC56D, 0x8216, 0xC56E, 0x8217, 0xC56F, 0x8218, 0xC570, 0x8219,\t0xC571, 0x821A, 0xC572, 0x821D, 0xC573, 0x8220, 0xC574, 0x8224,\r\n\t0xC575, 0x8225, 0xC576, 0x8226, 0xC577, 0x8227, 0xC578, 0x8229,\t0xC579, 0x822E, 0xC57A, 0x8232, 0xC57B, 0x823A, 0xC57C, 0x823C,\r\n\t0xC57D, 0x823D, 0xC57E, 0x823F, 0xC580, 0x8240, 0xC581, 0x8241,\t0xC582, 0x8242, 0xC583, 0x8243, 0xC584, 0x8245, 0xC585, 0x8246,\r\n\t0xC586, 0x8248, 0xC587, 0x824A, 0xC588, 0x824C, 0xC589, 0x824D,\t0xC58A, 0x824E, 0xC58B, 0x8250, 0xC58C, 0x8251, 0xC58D, 0x8252,\r\n\t0xC58E, 0x8253, 0xC58F, 0x8254, 0xC590, 0x8255, 0xC591, 0x8256,\t0xC592, 0x8257, 0xC593, 0x8259, 0xC594, 0x825B, 0xC595, 0x825C,\r\n\t0xC596, 0x825D, 0xC597, 0x825E, 0xC598, 0x8260, 0xC599, 0x8261,\t0xC59A, 0x8262, 0xC59B, 0x8263, 0xC59C, 0x8264, 0xC59D, 0x8265,\r\n\t0xC59E, 0x8266, 0xC59F, 0x8267, 0xC5A0, 0x8269, 0xC5A1, 0x62E7,\t0xC5A2, 0x6CDE, 0xC5A3, 0x725B, 0xC5A4, 0x626D, 0xC5A5, 0x94AE,\r\n\t0xC5A6, 0x7EBD, 0xC5A7, 0x8113, 0xC5A8, 0x6D53, 0xC5A9, 0x519C,\t0xC5AA, 0x5F04, 0xC5AB, 0x5974, 0xC5AC, 0x52AA, 0xC5AD, 0x6012,\r\n\t0xC5AE, 0x5973, 0xC5AF, 0x6696, 0xC5B0, 0x8650, 0xC5B1, 0x759F,\t0xC5B2, 0x632A, 0xC5B3, 0x61E6, 0xC5B4, 0x7CEF, 0xC5B5, 0x8BFA,\r\n\t0xC5B6, 0x54E6, 0xC5B7, 0x6B27, 0xC5B8, 0x9E25, 0xC5B9, 0x6BB4,\t0xC5BA, 0x85D5, 0xC5BB, 0x5455, 0xC5BC, 0x5076, 0xC5BD, 0x6CA4,\r\n\t0xC5BE, 0x556A, 0xC5BF, 0x8DB4, 0xC5C0, 0x722C, 0xC5C1, 0x5E15,\t0xC5C2, 0x6015, 0xC5C3, 0x7436, 0xC5C4, 0x62CD, 0xC5C5, 0x6392,\r\n\t0xC5C6, 0x724C, 0xC5C7, 0x5F98, 0xC5C8, 0x6E43, 0xC5C9, 0x6D3E,\t0xC5CA, 0x6500, 0xC5CB, 0x6F58, 0xC5CC, 0x76D8, 0xC5CD, 0x78D0,\r\n\t0xC5CE, 0x76FC, 0xC5CF, 0x7554, 0xC5D0, 0x5224, 0xC5D1, 0x53DB,\t0xC5D2, 0x4E53, 0xC5D3, 0x5E9E, 0xC5D4, 0x65C1, 0xC5D5, 0x802A,\r\n\t0xC5D6, 0x80D6, 0xC5D7, 0x629B, 0xC5D8, 0x5486, 0xC5D9, 0x5228,\t0xC5DA, 0x70AE, 0xC5DB, 0x888D, 0xC5DC, 0x8DD1, 0xC5DD, 0x6CE1,\r\n\t0xC5DE, 0x5478, 0xC5DF, 0x80DA, 0xC5E0, 0x57F9, 0xC5E1, 0x88F4,\t0xC5E2, 0x8D54, 0xC5E3, 0x966A, 0xC5E4, 0x914D, 0xC5E5, 0x4F69,\r\n\t0xC5E6, 0x6C9B, 0xC5E7, 0x55B7, 0xC5E8, 0x76C6, 0xC5E9, 0x7830,\t0xC5EA, 0x62A8, 0xC5EB, 0x70F9, 0xC5EC, 0x6F8E, 0xC5ED, 0x5F6D,\r\n\t0xC5EE, 0x84EC, 0xC5EF, 0x68DA, 0xC5F0, 0x787C, 0xC5F1, 0x7BF7,\t0xC5F2, 0x81A8, 0xC5F3, 0x670B, 0xC5F4, 0x9E4F, 0xC5F5, 0x6367,\r\n\t0xC5F6, 0x78B0, 0xC5F7, 0x576F, 0xC5F8, 0x7812, 0xC5F9, 0x9739,\t0xC5FA, 0x6279, 0xC5FB, 0x62AB, 0xC5FC, 0x5288, 0xC5FD, 0x7435,\r\n\t0xC5FE, 0x6BD7, 0xC640, 0x826A, 0xC641, 0x826B, 0xC642, 0x826C,\t0xC643, 0x826D, 0xC644, 0x8271, 0xC645, 0x8275, 0xC646, 0x8276,\r\n\t0xC647, 0x8277, 0xC648, 0x8278, 0xC649, 0x827B, 0xC64A, 0x827C,\t0xC64B, 0x8280, 0xC64C, 0x8281, 0xC64D, 0x8283, 0xC64E, 0x8285,\r\n\t0xC64F, 0x8286, 0xC650, 0x8287, 0xC651, 0x8289, 0xC652, 0x828C,\t0xC653, 0x8290, 0xC654, 0x8293, 0xC655, 0x8294, 0xC656, 0x8295,\r\n\t0xC657, 0x8296, 0xC658, 0x829A, 0xC659, 0x829B, 0xC65A, 0x829E,\t0xC65B, 0x82A0, 0xC65C, 0x82A2, 0xC65D, 0x82A3, 0xC65E, 0x82A7,\r\n\t0xC65F, 0x82B2, 0xC660, 0x82B5, 0xC661, 0x82B6, 0xC662, 0x82BA,\t0xC663, 0x82BB, 0xC664, 0x82BC, 0xC665, 0x82BF, 0xC666, 0x82C0,\r\n\t0xC667, 0x82C2, 0xC668, 0x82C3, 0xC669, 0x82C5, 0xC66A, 0x82C6,\t0xC66B, 0x82C9, 0xC66C, 0x82D0, 0xC66D, 0x82D6, 0xC66E, 0x82D9,\r\n\t0xC66F, 0x82DA, 0xC670, 0x82DD, 0xC671, 0x82E2, 0xC672, 0x82E7,\t0xC673, 0x82E8, 0xC674, 0x82E9, 0xC675, 0x82EA, 0xC676, 0x82EC,\r\n\t0xC677, 0x82ED, 0xC678, 0x82EE, 0xC679, 0x82F0, 0xC67A, 0x82F2,\t0xC67B, 0x82F3, 0xC67C, 0x82F5, 0xC67D, 0x82F6, 0xC67E, 0x82F8,\r\n\t0xC680, 0x82FA, 0xC681, 0x82FC, 0xC682, 0x82FD, 0xC683, 0x82FE,\t0xC684, 0x82FF, 0xC685, 0x8300, 0xC686, 0x830A, 0xC687, 0x830B,\r\n\t0xC688, 0x830D, 0xC689, 0x8310, 0xC68A, 0x8312, 0xC68B, 0x8313,\t0xC68C, 0x8316, 0xC68D, 0x8318, 0xC68E, 0x8319, 0xC68F, 0x831D,\r\n\t0xC690, 0x831E, 0xC691, 0x831F, 0xC692, 0x8320, 0xC693, 0x8321,\t0xC694, 0x8322, 0xC695, 0x8323, 0xC696, 0x8324, 0xC697, 0x8325,\r\n\t0xC698, 0x8326, 0xC699, 0x8329, 0xC69A, 0x832A, 0xC69B, 0x832E,\t0xC69C, 0x8330, 0xC69D, 0x8332, 0xC69E, 0x8337, 0xC69F, 0x833B,\r\n\t0xC6A0, 0x833D, 0xC6A1, 0x5564, 0xC6A2, 0x813E, 0xC6A3, 0x75B2,\t0xC6A4, 0x76AE, 0xC6A5, 0x5339, 0xC6A6, 0x75DE, 0xC6A7, 0x50FB,\r\n\t0xC6A8, 0x5C41, 0xC6A9, 0x8B6C, 0xC6AA, 0x7BC7, 0xC6AB, 0x504F,\t0xC6AC, 0x7247, 0xC6AD, 0x9A97, 0xC6AE, 0x98D8, 0xC6AF, 0x6F02,\r\n\t0xC6B0, 0x74E2, 0xC6B1, 0x7968, 0xC6B2, 0x6487, 0xC6B3, 0x77A5,\t0xC6B4, 0x62FC, 0xC6B5, 0x9891, 0xC6B6, 0x8D2B, 0xC6B7, 0x54C1,\r\n\t0xC6B8, 0x8058, 0xC6B9, 0x4E52, 0xC6BA, 0x576A, 0xC6BB, 0x82F9,\t0xC6BC, 0x840D, 0xC6BD, 0x5E73, 0xC6BE, 0x51ED, 0xC6BF, 0x74F6,\r\n\t0xC6C0, 0x8BC4, 0xC6C1, 0x5C4F, 0xC6C2, 0x5761, 0xC6C3, 0x6CFC,\t0xC6C4, 0x9887, 0xC6C5, 0x5A46, 0xC6C6, 0x7834, 0xC6C7, 0x9B44,\r\n\t0xC6C8, 0x8FEB, 0xC6C9, 0x7C95, 0xC6CA, 0x5256, 0xC6CB, 0x6251,\t0xC6CC, 0x94FA, 0xC6CD, 0x4EC6, 0xC6CE, 0x8386, 0xC6CF, 0x8461,\r\n\t0xC6D0, 0x83E9, 0xC6D1, 0x84B2, 0xC6D2, 0x57D4, 0xC6D3, 0x6734,\t0xC6D4, 0x5703, 0xC6D5, 0x666E, 0xC6D6, 0x6D66, 0xC6D7, 0x8C31,\r\n\t0xC6D8, 0x66DD, 0xC6D9, 0x7011, 0xC6DA, 0x671F, 0xC6DB, 0x6B3A,\t0xC6DC, 0x6816, 0xC6DD, 0x621A, 0xC6DE, 0x59BB, 0xC6DF, 0x4E03,\r\n\t0xC6E0, 0x51C4, 0xC6E1, 0x6F06, 0xC6E2, 0x67D2, 0xC6E3, 0x6C8F,\t0xC6E4, 0x5176, 0xC6E5, 0x68CB, 0xC6E6, 0x5947, 0xC6E7, 0x6B67,\r\n\t0xC6E8, 0x7566, 0xC6E9, 0x5D0E, 0xC6EA, 0x8110, 0xC6EB, 0x9F50,\t0xC6EC, 0x65D7, 0xC6ED, 0x7948, 0xC6EE, 0x7941, 0xC6EF, 0x9A91,\r\n\t0xC6F0, 0x8D77, 0xC6F1, 0x5C82, 0xC6F2, 0x4E5E, 0xC6F3, 0x4F01,\t0xC6F4, 0x542F, 0xC6F5, 0x5951, 0xC6F6, 0x780C, 0xC6F7, 0x5668,\r\n\t0xC6F8, 0x6C14, 0xC6F9, 0x8FC4, 0xC6FA, 0x5F03, 0xC6FB, 0x6C7D,\t0xC6FC, 0x6CE3, 0xC6FD, 0x8BAB, 0xC6FE, 0x6390, 0xC740, 0x833E,\r\n\t0xC741, 0x833F, 0xC742, 0x8341, 0xC743, 0x8342, 0xC744, 0x8344,\t0xC745, 0x8345, 0xC746, 0x8348, 0xC747, 0x834A, 0xC748, 0x834B,\r\n\t0xC749, 0x834C, 0xC74A, 0x834D, 0xC74B, 0x834E, 0xC74C, 0x8353,\t0xC74D, 0x8355, 0xC74E, 0x8356, 0xC74F, 0x8357, 0xC750, 0x8358,\r\n\t0xC751, 0x8359, 0xC752, 0x835D, 0xC753, 0x8362, 0xC754, 0x8370,\t0xC755, 0x8371, 0xC756, 0x8372, 0xC757, 0x8373, 0xC758, 0x8374,\r\n\t0xC759, 0x8375, 0xC75A, 0x8376, 0xC75B, 0x8379, 0xC75C, 0x837A,\t0xC75D, 0x837E, 0xC75E, 0x837F, 0xC75F, 0x8380, 0xC760, 0x8381,\r\n\t0xC761, 0x8382, 0xC762, 0x8383, 0xC763, 0x8384, 0xC764, 0x8387,\t0xC765, 0x8388, 0xC766, 0x838A, 0xC767, 0x838B, 0xC768, 0x838C,\r\n\t0xC769, 0x838D, 0xC76A, 0x838F, 0xC76B, 0x8390, 0xC76C, 0x8391,\t0xC76D, 0x8394, 0xC76E, 0x8395, 0xC76F, 0x8396, 0xC770, 0x8397,\r\n\t0xC771, 0x8399, 0xC772, 0x839A, 0xC773, 0x839D, 0xC774, 0x839F,\t0xC775, 0x83A1, 0xC776, 0x83A2, 0xC777, 0x83A3, 0xC778, 0x83A4,\r\n\t0xC779, 0x83A5, 0xC77A, 0x83A6, 0xC77B, 0x83A7, 0xC77C, 0x83AC,\t0xC77D, 0x83AD, 0xC77E, 0x83AE, 0xC780, 0x83AF, 0xC781, 0x83B5,\r\n\t0xC782, 0x83BB, 0xC783, 0x83BE, 0xC784, 0x83BF, 0xC785, 0x83C2,\t0xC786, 0x83C3, 0xC787, 0x83C4, 0xC788, 0x83C6, 0xC789, 0x83C8,\r\n\t0xC78A, 0x83C9, 0xC78B, 0x83CB, 0xC78C, 0x83CD, 0xC78D, 0x83CE,\t0xC78E, 0x83D0, 0xC78F, 0x83D1, 0xC790, 0x83D2, 0xC791, 0x83D3,\r\n\t0xC792, 0x83D5, 0xC793, 0x83D7, 0xC794, 0x83D9, 0xC795, 0x83DA,\t0xC796, 0x83DB, 0xC797, 0x83DE, 0xC798, 0x83E2, 0xC799, 0x83E3,\r\n\t0xC79A, 0x83E4, 0xC79B, 0x83E6, 0xC79C, 0x83E7, 0xC79D, 0x83E8,\t0xC79E, 0x83EB, 0xC79F, 0x83EC, 0xC7A0, 0x83ED, 0xC7A1, 0x6070,\r\n\t0xC7A2, 0x6D3D, 0xC7A3, 0x7275, 0xC7A4, 0x6266, 0xC7A5, 0x948E,\t0xC7A6, 0x94C5, 0xC7A7, 0x5343, 0xC7A8, 0x8FC1, 0xC7A9, 0x7B7E,\r\n\t0xC7AA, 0x4EDF, 0xC7AB, 0x8C26, 0xC7AC, 0x4E7E, 0xC7AD, 0x9ED4,\t0xC7AE, 0x94B1, 0xC7AF, 0x94B3, 0xC7B0, 0x524D, 0xC7B1, 0x6F5C,\r\n\t0xC7B2, 0x9063, 0xC7B3, 0x6D45, 0xC7B4, 0x8C34, 0xC7B5, 0x5811,\t0xC7B6, 0x5D4C, 0xC7B7, 0x6B20, 0xC7B8, 0x6B49, 0xC7B9, 0x67AA,\r\n\t0xC7BA, 0x545B, 0xC7BB, 0x8154, 0xC7BC, 0x7F8C, 0xC7BD, 0x5899,\t0xC7BE, 0x8537, 0xC7BF, 0x5F3A, 0xC7C0, 0x62A2, 0xC7C1, 0x6A47,\r\n\t0xC7C2, 0x9539, 0xC7C3, 0x6572, 0xC7C4, 0x6084, 0xC7C5, 0x6865,\t0xC7C6, 0x77A7, 0xC7C7, 0x4E54, 0xC7C8, 0x4FA8, 0xC7C9, 0x5DE7,\r\n\t0xC7CA, 0x9798, 0xC7CB, 0x64AC, 0xC7CC, 0x7FD8, 0xC7CD, 0x5CED,\t0xC7CE, 0x4FCF, 0xC7CF, 0x7A8D, 0xC7D0, 0x5207, 0xC7D1, 0x8304,\r\n\t0xC7D2, 0x4E14, 0xC7D3, 0x602F, 0xC7D4, 0x7A83, 0xC7D5, 0x94A6,\t0xC7D6, 0x4FB5, 0xC7D7, 0x4EB2, 0xC7D8, 0x79E6, 0xC7D9, 0x7434,\r\n\t0xC7DA, 0x52E4, 0xC7DB, 0x82B9, 0xC7DC, 0x64D2, 0xC7DD, 0x79BD,\t0xC7DE, 0x5BDD, 0xC7DF, 0x6C81, 0xC7E0, 0x9752, 0xC7E1, 0x8F7B,\r\n\t0xC7E2, 0x6C22, 0xC7E3, 0x503E, 0xC7E4, 0x537F, 0xC7E5, 0x6E05,\t0xC7E6, 0x64CE, 0xC7E7, 0x6674, 0xC7E8, 0x6C30, 0xC7E9, 0x60C5,\r\n\t0xC7EA, 0x9877, 0xC7EB, 0x8BF7, 0xC7EC, 0x5E86, 0xC7ED, 0x743C,\t0xC7EE, 0x7A77, 0xC7EF, 0x79CB, 0xC7F0, 0x4E18, 0xC7F1, 0x90B1,\r\n\t0xC7F2, 0x7403, 0xC7F3, 0x6C42, 0xC7F4, 0x56DA, 0xC7F5, 0x914B,\t0xC7F6, 0x6CC5, 0xC7F7, 0x8D8B, 0xC7F8, 0x533A, 0xC7F9, 0x86C6,\r\n\t0xC7FA, 0x66F2, 0xC7FB, 0x8EAF, 0xC7FC, 0x5C48, 0xC7FD, 0x9A71,\t0xC7FE, 0x6E20, 0xC840, 0x83EE, 0xC841, 0x83EF, 0xC842, 0x83F3,\r\n\t0xC843, 0x83F4, 0xC844, 0x83F5, 0xC845, 0x83F6, 0xC846, 0x83F7,\t0xC847, 0x83FA, 0xC848, 0x83FB, 0xC849, 0x83FC, 0xC84A, 0x83FE,\r\n\t0xC84B, 0x83FF, 0xC84C, 0x8400, 0xC84D, 0x8402, 0xC84E, 0x8405,\t0xC84F, 0x8407, 0xC850, 0x8408, 0xC851, 0x8409, 0xC852, 0x840A,\r\n\t0xC853, 0x8410, 0xC854, 0x8412, 0xC855, 0x8413, 0xC856, 0x8414,\t0xC857, 0x8415, 0xC858, 0x8416, 0xC859, 0x8417, 0xC85A, 0x8419,\r\n\t0xC85B, 0x841A, 0xC85C, 0x841B, 0xC85D, 0x841E, 0xC85E, 0x841F,\t0xC85F, 0x8420, 0xC860, 0x8421, 0xC861, 0x8422, 0xC862, 0x8423,\r\n\t0xC863, 0x8429, 0xC864, 0x842A, 0xC865, 0x842B, 0xC866, 0x842C,\t0xC867, 0x842D, 0xC868, 0x842E, 0xC869, 0x842F, 0xC86A, 0x8430,\r\n\t0xC86B, 0x8432, 0xC86C, 0x8433, 0xC86D, 0x8434, 0xC86E, 0x8435,\t0xC86F, 0x8436, 0xC870, 0x8437, 0xC871, 0x8439, 0xC872, 0x843A,\r\n\t0xC873, 0x843B, 0xC874, 0x843E, 0xC875, 0x843F, 0xC876, 0x8440,\t0xC877, 0x8441, 0xC878, 0x8442, 0xC879, 0x8443, 0xC87A, 0x8444,\r\n\t0xC87B, 0x8445, 0xC87C, 0x8447, 0xC87D, 0x8448, 0xC87E, 0x8449,\t0xC880, 0x844A, 0xC881, 0x844B, 0xC882, 0x844C, 0xC883, 0x844D,\r\n\t0xC884, 0x844E, 0xC885, 0x844F, 0xC886, 0x8450, 0xC887, 0x8452,\t0xC888, 0x8453, 0xC889, 0x8454, 0xC88A, 0x8455, 0xC88B, 0x8456,\r\n\t0xC88C, 0x8458, 0xC88D, 0x845D, 0xC88E, 0x845E, 0xC88F, 0x845F,\t0xC890, 0x8460, 0xC891, 0x8462, 0xC892, 0x8464, 0xC893, 0x8465,\r\n\t0xC894, 0x8466, 0xC895, 0x8467, 0xC896, 0x8468, 0xC897, 0x846A,\t0xC898, 0x846E, 0xC899, 0x846F, 0xC89A, 0x8470, 0xC89B, 0x8472,\r\n\t0xC89C, 0x8474, 0xC89D, 0x8477, 0xC89E, 0x8479, 0xC89F, 0x847B,\t0xC8A0, 0x847C, 0xC8A1, 0x53D6, 0xC8A2, 0x5A36, 0xC8A3, 0x9F8B,\r\n\t0xC8A4, 0x8DA3, 0xC8A5, 0x53BB, 0xC8A6, 0x5708, 0xC8A7, 0x98A7,\t0xC8A8, 0x6743, 0xC8A9, 0x919B, 0xC8AA, 0x6CC9, 0xC8AB, 0x5168,\r\n\t0xC8AC, 0x75CA, 0xC8AD, 0x62F3, 0xC8AE, 0x72AC, 0xC8AF, 0x5238,\t0xC8B0, 0x529D, 0xC8B1, 0x7F3A, 0xC8B2, 0x7094, 0xC8B3, 0x7638,\r\n\t0xC8B4, 0x5374, 0xC8B5, 0x9E4A, 0xC8B6, 0x69B7, 0xC8B7, 0x786E,\t0xC8B8, 0x96C0, 0xC8B9, 0x88D9, 0xC8BA, 0x7FA4, 0xC8BB, 0x7136,\r\n\t0xC8BC, 0x71C3, 0xC8BD, 0x5189, 0xC8BE, 0x67D3, 0xC8BF, 0x74E4,\t0xC8C0, 0x58E4, 0xC8C1, 0x6518, 0xC8C2, 0x56B7, 0xC8C3, 0x8BA9,\r\n\t0xC8C4, 0x9976, 0xC8C5, 0x6270, 0xC8C6, 0x7ED5, 0xC8C7, 0x60F9,\t0xC8C8, 0x70ED, 0xC8C9, 0x58EC, 0xC8CA, 0x4EC1, 0xC8CB, 0x4EBA,\r\n\t0xC8CC, 0x5FCD, 0xC8CD, 0x97E7, 0xC8CE, 0x4EFB, 0xC8CF, 0x8BA4,\t0xC8D0, 0x5203, 0xC8D1, 0x598A, 0xC8D2, 0x7EAB, 0xC8D3, 0x6254,\r\n\t0xC8D4, 0x4ECD, 0xC8D5, 0x65E5, 0xC8D6, 0x620E, 0xC8D7, 0x8338,\t0xC8D8, 0x84C9, 0xC8D9, 0x8363, 0xC8DA, 0x878D, 0xC8DB, 0x7194,\r\n\t0xC8DC, 0x6EB6, 0xC8DD, 0x5BB9, 0xC8DE, 0x7ED2, 0xC8DF, 0x5197,\t0xC8E0, 0x63C9, 0xC8E1, 0x67D4, 0xC8E2, 0x8089, 0xC8E3, 0x8339,\r\n\t0xC8E4, 0x8815, 0xC8E5, 0x5112, 0xC8E6, 0x5B7A, 0xC8E7, 0x5982,\t0xC8E8, 0x8FB1, 0xC8E9, 0x4E73, 0xC8EA, 0x6C5D, 0xC8EB, 0x5165,\r\n\t0xC8EC, 0x8925, 0xC8ED, 0x8F6F, 0xC8EE, 0x962E, 0xC8EF, 0x854A,\t0xC8F0, 0x745E, 0xC8F1, 0x9510, 0xC8F2, 0x95F0, 0xC8F3, 0x6DA6,\r\n\t0xC8F4, 0x82E5, 0xC8F5, 0x5F31, 0xC8F6, 0x6492, 0xC8F7, 0x6D12,\t0xC8F8, 0x8428, 0xC8F9, 0x816E, 0xC8FA, 0x9CC3, 0xC8FB, 0x585E,\r\n\t0xC8FC, 0x8D5B, 0xC8FD, 0x4E09, 0xC8FE, 0x53C1, 0xC940, 0x847D,\t0xC941, 0x847E, 0xC942, 0x847F, 0xC943, 0x8480, 0xC944, 0x8481,\r\n\t0xC945, 0x8483, 0xC946, 0x8484, 0xC947, 0x8485, 0xC948, 0x8486,\t0xC949, 0x848A, 0xC94A, 0x848D, 0xC94B, 0x848F, 0xC94C, 0x8490,\r\n\t0xC94D, 0x8491, 0xC94E, 0x8492, 0xC94F, 0x8493, 0xC950, 0x8494,\t0xC951, 0x8495, 0xC952, 0x8496, 0xC953, 0x8498, 0xC954, 0x849A,\r\n\t0xC955, 0x849B, 0xC956, 0x849D, 0xC957, 0x849E, 0xC958, 0x849F,\t0xC959, 0x84A0, 0xC95A, 0x84A2, 0xC95B, 0x84A3, 0xC95C, 0x84A4,\r\n\t0xC95D, 0x84A5, 0xC95E, 0x84A6, 0xC95F, 0x84A7, 0xC960, 0x84A8,\t0xC961, 0x84A9, 0xC962, 0x84AA, 0xC963, 0x84AB, 0xC964, 0x84AC,\r\n\t0xC965, 0x84AD, 0xC966, 0x84AE, 0xC967, 0x84B0, 0xC968, 0x84B1,\t0xC969, 0x84B3, 0xC96A, 0x84B5, 0xC96B, 0x84B6, 0xC96C, 0x84B7,\r\n\t0xC96D, 0x84BB, 0xC96E, 0x84BC, 0xC96F, 0x84BE, 0xC970, 0x84C0,\t0xC971, 0x84C2, 0xC972, 0x84C3, 0xC973, 0x84C5, 0xC974, 0x84C6,\r\n\t0xC975, 0x84C7, 0xC976, 0x84C8, 0xC977, 0x84CB, 0xC978, 0x84CC,\t0xC979, 0x84CE, 0xC97A, 0x84CF, 0xC97B, 0x84D2, 0xC97C, 0x84D4,\r\n\t0xC97D, 0x84D5, 0xC97E, 0x84D7, 0xC980, 0x84D8, 0xC981, 0x84D9,\t0xC982, 0x84DA, 0xC983, 0x84DB, 0xC984, 0x84DC, 0xC985, 0x84DE,\r\n\t0xC986, 0x84E1, 0xC987, 0x84E2, 0xC988, 0x84E4, 0xC989, 0x84E7,\t0xC98A, 0x84E8, 0xC98B, 0x84E9, 0xC98C, 0x84EA, 0xC98D, 0x84EB,\r\n\t0xC98E, 0x84ED, 0xC98F, 0x84EE, 0xC990, 0x84EF, 0xC991, 0x84F1,\t0xC992, 0x84F2, 0xC993, 0x84F3, 0xC994, 0x84F4, 0xC995, 0x84F5,\r\n\t0xC996, 0x84F6, 0xC997, 0x84F7, 0xC998, 0x84F8, 0xC999, 0x84F9,\t0xC99A, 0x84FA, 0xC99B, 0x84FB, 0xC99C, 0x84FD, 0xC99D, 0x84FE,\r\n\t0xC99E, 0x8500, 0xC99F, 0x8501, 0xC9A0, 0x8502, 0xC9A1, 0x4F1E,\t0xC9A2, 0x6563, 0xC9A3, 0x6851, 0xC9A4, 0x55D3, 0xC9A5, 0x4E27,\r\n\t0xC9A6, 0x6414, 0xC9A7, 0x9A9A, 0xC9A8, 0x626B, 0xC9A9, 0x5AC2,\t0xC9AA, 0x745F, 0xC9AB, 0x8272, 0xC9AC, 0x6DA9, 0xC9AD, 0x68EE,\r\n\t0xC9AE, 0x50E7, 0xC9AF, 0x838E, 0xC9B0, 0x7802, 0xC9B1, 0x6740,\t0xC9B2, 0x5239, 0xC9B3, 0x6C99, 0xC9B4, 0x7EB1, 0xC9B5, 0x50BB,\r\n\t0xC9B6, 0x5565, 0xC9B7, 0x715E, 0xC9B8, 0x7B5B, 0xC9B9, 0x6652,\t0xC9BA, 0x73CA, 0xC9BB, 0x82EB, 0xC9BC, 0x6749, 0xC9BD, 0x5C71,\r\n\t0xC9BE, 0x5220, 0xC9BF, 0x717D, 0xC9C0, 0x886B, 0xC9C1, 0x95EA,\t0xC9C2, 0x9655, 0xC9C3, 0x64C5, 0xC9C4, 0x8D61, 0xC9C5, 0x81B3,\r\n\t0xC9C6, 0x5584, 0xC9C7, 0x6C55, 0xC9C8, 0x6247, 0xC9C9, 0x7F2E,\t0xC9CA, 0x5892, 0xC9CB, 0x4F24, 0xC9CC, 0x5546, 0xC9CD, 0x8D4F,\r\n\t0xC9CE, 0x664C, 0xC9CF, 0x4E0A, 0xC9D0, 0x5C1A, 0xC9D1, 0x88F3,\t0xC9D2, 0x68A2, 0xC9D3, 0x634E, 0xC9D4, 0x7A0D, 0xC9D5, 0x70E7,\r\n\t0xC9D6, 0x828D, 0xC9D7, 0x52FA, 0xC9D8, 0x97F6, 0xC9D9, 0x5C11,\t0xC9DA, 0x54E8, 0xC9DB, 0x90B5, 0xC9DC, 0x7ECD, 0xC9DD, 0x5962,\r\n\t0xC9DE, 0x8D4A, 0xC9DF, 0x86C7, 0xC9E0, 0x820C, 0xC9E1, 0x820D,\t0xC9E2, 0x8D66, 0xC9E3, 0x6444, 0xC9E4, 0x5C04, 0xC9E5, 0x6151,\r\n\t0xC9E6, 0x6D89, 0xC9E7, 0x793E, 0xC9E8, 0x8BBE, 0xC9E9, 0x7837,\t0xC9EA, 0x7533, 0xC9EB, 0x547B, 0xC9EC, 0x4F38, 0xC9ED, 0x8EAB,\r\n\t0xC9EE, 0x6DF1, 0xC9EF, 0x5A20, 0xC9F0, 0x7EC5, 0xC9F1, 0x795E,\t0xC9F2, 0x6C88, 0xC9F3, 0x5BA1, 0xC9F4, 0x5A76, 0xC9F5, 0x751A,\r\n\t0xC9F6, 0x80BE, 0xC9F7, 0x614E, 0xC9F8, 0x6E17, 0xC9F9, 0x58F0,\t0xC9FA, 0x751F, 0xC9FB, 0x7525, 0xC9FC, 0x7272, 0xC9FD, 0x5347,\r\n\t0xC9FE, 0x7EF3, 0xCA40, 0x8503, 0xCA41, 0x8504, 0xCA42, 0x8505,\t0xCA43, 0x8506, 0xCA44, 0x8507, 0xCA45, 0x8508, 0xCA46, 0x8509,\r\n\t0xCA47, 0x850A, 0xCA48, 0x850B, 0xCA49, 0x850D, 0xCA4A, 0x850E,\t0xCA4B, 0x850F, 0xCA4C, 0x8510, 0xCA4D, 0x8512, 0xCA4E, 0x8514,\r\n\t0xCA4F, 0x8515, 0xCA50, 0x8516, 0xCA51, 0x8518, 0xCA52, 0x8519,\t0xCA53, 0x851B, 0xCA54, 0x851C, 0xCA55, 0x851D, 0xCA56, 0x851E,\r\n\t0xCA57, 0x8520, 0xCA58, 0x8522, 0xCA59, 0x8523, 0xCA5A, 0x8524,\t0xCA5B, 0x8525, 0xCA5C, 0x8526, 0xCA5D, 0x8527, 0xCA5E, 0x8528,\r\n\t0xCA5F, 0x8529, 0xCA60, 0x852A, 0xCA61, 0x852D, 0xCA62, 0x852E,\t0xCA63, 0x852F, 0xCA64, 0x8530, 0xCA65, 0x8531, 0xCA66, 0x8532,\r\n\t0xCA67, 0x8533, 0xCA68, 0x8534, 0xCA69, 0x8535, 0xCA6A, 0x8536,\t0xCA6B, 0x853E, 0xCA6C, 0x853F, 0xCA6D, 0x8540, 0xCA6E, 0x8541,\r\n\t0xCA6F, 0x8542, 0xCA70, 0x8544, 0xCA71, 0x8545, 0xCA72, 0x8546,\t0xCA73, 0x8547, 0xCA74, 0x854B, 0xCA75, 0x854C, 0xCA76, 0x854D,\r\n\t0xCA77, 0x854E, 0xCA78, 0x854F, 0xCA79, 0x8550, 0xCA7A, 0x8551,\t0xCA7B, 0x8552, 0xCA7C, 0x8553, 0xCA7D, 0x8554, 0xCA7E, 0x8555,\r\n\t0xCA80, 0x8557, 0xCA81, 0x8558, 0xCA82, 0x855A, 0xCA83, 0x855B,\t0xCA84, 0x855C, 0xCA85, 0x855D, 0xCA86, 0x855F, 0xCA87, 0x8560,\r\n\t0xCA88, 0x8561, 0xCA89, 0x8562, 0xCA8A, 0x8563, 0xCA8B, 0x8565,\t0xCA8C, 0x8566, 0xCA8D, 0x8567, 0xCA8E, 0x8569, 0xCA8F, 0x856A,\r\n\t0xCA90, 0x856B, 0xCA91, 0x856C, 0xCA92, 0x856D, 0xCA93, 0x856E,\t0xCA94, 0x856F, 0xCA95, 0x8570, 0xCA96, 0x8571, 0xCA97, 0x8573,\r\n\t0xCA98, 0x8575, 0xCA99, 0x8576, 0xCA9A, 0x8577, 0xCA9B, 0x8578,\t0xCA9C, 0x857C, 0xCA9D, 0x857D, 0xCA9E, 0x857F, 0xCA9F, 0x8580,\r\n\t0xCAA0, 0x8581, 0xCAA1, 0x7701, 0xCAA2, 0x76DB, 0xCAA3, 0x5269,\t0xCAA4, 0x80DC, 0xCAA5, 0x5723, 0xCAA6, 0x5E08, 0xCAA7, 0x5931,\r\n\t0xCAA8, 0x72EE, 0xCAA9, 0x65BD, 0xCAAA, 0x6E7F, 0xCAAB, 0x8BD7,\t0xCAAC, 0x5C38, 0xCAAD, 0x8671, 0xCAAE, 0x5341, 0xCAAF, 0x77F3,\r\n\t0xCAB0, 0x62FE, 0xCAB1, 0x65F6, 0xCAB2, 0x4EC0, 0xCAB3, 0x98DF,\t0xCAB4, 0x8680, 0xCAB5, 0x5B9E, 0xCAB6, 0x8BC6, 0xCAB7, 0x53F2,\r\n\t0xCAB8, 0x77E2, 0xCAB9, 0x4F7F, 0xCABA, 0x5C4E, 0xCABB, 0x9A76,\t0xCABC, 0x59CB, 0xCABD, 0x5F0F, 0xCABE, 0x793A, 0xCABF, 0x58EB,\r\n\t0xCAC0, 0x4E16, 0xCAC1, 0x67FF, 0xCAC2, 0x4E8B, 0xCAC3, 0x62ED,\t0xCAC4, 0x8A93, 0xCAC5, 0x901D, 0xCAC6, 0x52BF, 0xCAC7, 0x662F,\r\n\t0xCAC8, 0x55DC, 0xCAC9, 0x566C, 0xCACA, 0x9002, 0xCACB, 0x4ED5,\t0xCACC, 0x4F8D, 0xCACD, 0x91CA, 0xCACE, 0x9970, 0xCACF, 0x6C0F,\r\n\t0xCAD0, 0x5E02, 0xCAD1, 0x6043, 0xCAD2, 0x5BA4, 0xCAD3, 0x89C6,\t0xCAD4, 0x8BD5, 0xCAD5, 0x6536, 0xCAD6, 0x624B, 0xCAD7, 0x9996,\r\n\t0xCAD8, 0x5B88, 0xCAD9, 0x5BFF, 0xCADA, 0x6388, 0xCADB, 0x552E,\t0xCADC, 0x53D7, 0xCADD, 0x7626, 0xCADE, 0x517D, 0xCADF, 0x852C,\r\n\t0xCAE0, 0x67A2, 0xCAE1, 0x68B3, 0xCAE2, 0x6B8A, 0xCAE3, 0x6292,\t0xCAE4, 0x8F93, 0xCAE5, 0x53D4, 0xCAE6, 0x8212, 0xCAE7, 0x6DD1,\r\n\t0xCAE8, 0x758F, 0xCAE9, 0x4E66, 0xCAEA, 0x8D4E, 0xCAEB, 0x5B70,\t0xCAEC, 0x719F, 0xCAED, 0x85AF, 0xCAEE, 0x6691, 0xCAEF, 0x66D9,\r\n\t0xCAF0, 0x7F72, 0xCAF1, 0x8700, 0xCAF2, 0x9ECD, 0xCAF3, 0x9F20,\t0xCAF4, 0x5C5E, 0xCAF5, 0x672F, 0xCAF6, 0x8FF0, 0xCAF7, 0x6811,\r\n\t0xCAF8, 0x675F, 0xCAF9, 0x620D, 0xCAFA, 0x7AD6, 0xCAFB, 0x5885,\t0xCAFC, 0x5EB6, 0xCAFD, 0x6570, 0xCAFE, 0x6F31, 0xCB40, 0x8582,\r\n\t0xCB41, 0x8583, 0xCB42, 0x8586, 0xCB43, 0x8588, 0xCB44, 0x8589,\t0xCB45, 0x858A, 0xCB46, 0x858B, 0xCB47, 0x858C, 0xCB48, 0x858D,\r\n\t0xCB49, 0x858E, 0xCB4A, 0x8590, 0xCB4B, 0x8591, 0xCB4C, 0x8592,\t0xCB4D, 0x8593, 0xCB4E, 0x8594, 0xCB4F, 0x8595, 0xCB50, 0x8596,\r\n\t0xCB51, 0x8597, 0xCB52, 0x8598, 0xCB53, 0x8599, 0xCB54, 0x859A,\t0xCB55, 0x859D, 0xCB56, 0x859E, 0xCB57, 0x859F, 0xCB58, 0x85A0,\r\n\t0xCB59, 0x85A1, 0xCB5A, 0x85A2, 0xCB5B, 0x85A3, 0xCB5C, 0x85A5,\t0xCB5D, 0x85A6, 0xCB5E, 0x85A7, 0xCB5F, 0x85A9, 0xCB60, 0x85AB,\r\n\t0xCB61, 0x85AC, 0xCB62, 0x85AD, 0xCB63, 0x85B1, 0xCB64, 0x85B2,\t0xCB65, 0x85B3, 0xCB66, 0x85B4, 0xCB67, 0x85B5, 0xCB68, 0x85B6,\r\n\t0xCB69, 0x85B8, 0xCB6A, 0x85BA, 0xCB6B, 0x85BB, 0xCB6C, 0x85BC,\t0xCB6D, 0x85BD, 0xCB6E, 0x85BE, 0xCB6F, 0x85BF, 0xCB70, 0x85C0,\r\n\t0xCB71, 0x85C2, 0xCB72, 0x85C3, 0xCB73, 0x85C4, 0xCB74, 0x85C5,\t0xCB75, 0x85C6, 0xCB76, 0x85C7, 0xCB77, 0x85C8, 0xCB78, 0x85CA,\r\n\t0xCB79, 0x85CB, 0xCB7A, 0x85CC, 0xCB7B, 0x85CD, 0xCB7C, 0x85CE,\t0xCB7D, 0x85D1, 0xCB7E, 0x85D2, 0xCB80, 0x85D4, 0xCB81, 0x85D6,\r\n\t0xCB82, 0x85D7, 0xCB83, 0x85D8, 0xCB84, 0x85D9, 0xCB85, 0x85DA,\t0xCB86, 0x85DB, 0xCB87, 0x85DD, 0xCB88, 0x85DE, 0xCB89, 0x85DF,\r\n\t0xCB8A, 0x85E0, 0xCB8B, 0x85E1, 0xCB8C, 0x85E2, 0xCB8D, 0x85E3,\t0xCB8E, 0x85E5, 0xCB8F, 0x85E6, 0xCB90, 0x85E7, 0xCB91, 0x85E8,\r\n\t0xCB92, 0x85EA, 0xCB93, 0x85EB, 0xCB94, 0x85EC, 0xCB95, 0x85ED,\t0xCB96, 0x85EE, 0xCB97, 0x85EF, 0xCB98, 0x85F0, 0xCB99, 0x85F1,\r\n\t0xCB9A, 0x85F2, 0xCB9B, 0x85F3, 0xCB9C, 0x85F4, 0xCB9D, 0x85F5,\t0xCB9E, 0x85F6, 0xCB9F, 0x85F7, 0xCBA0, 0x85F8, 0xCBA1, 0x6055,\r\n\t0xCBA2, 0x5237, 0xCBA3, 0x800D, 0xCBA4, 0x6454, 0xCBA5, 0x8870,\t0xCBA6, 0x7529, 0xCBA7, 0x5E05, 0xCBA8, 0x6813, 0xCBA9, 0x62F4,\r\n\t0xCBAA, 0x971C, 0xCBAB, 0x53CC, 0xCBAC, 0x723D, 0xCBAD, 0x8C01,\t0xCBAE, 0x6C34, 0xCBAF, 0x7761, 0xCBB0, 0x7A0E, 0xCBB1, 0x542E,\r\n\t0xCBB2, 0x77AC, 0xCBB3, 0x987A, 0xCBB4, 0x821C, 0xCBB5, 0x8BF4,\t0xCBB6, 0x7855, 0xCBB7, 0x6714, 0xCBB8, 0x70C1, 0xCBB9, 0x65AF,\r\n\t0xCBBA, 0x6495, 0xCBBB, 0x5636, 0xCBBC, 0x601D, 0xCBBD, 0x79C1,\t0xCBBE, 0x53F8, 0xCBBF, 0x4E1D, 0xCBC0, 0x6B7B, 0xCBC1, 0x8086,\r\n\t0xCBC2, 0x5BFA, 0xCBC3, 0x55E3, 0xCBC4, 0x56DB, 0xCBC5, 0x4F3A,\t0xCBC6, 0x4F3C, 0xCBC7, 0x9972, 0xCBC8, 0x5DF3, 0xCBC9, 0x677E,\r\n\t0xCBCA, 0x8038, 0xCBCB, 0x6002, 0xCBCC, 0x9882, 0xCBCD, 0x9001,\t0xCBCE, 0x5B8B, 0xCBCF, 0x8BBC, 0xCBD0, 0x8BF5, 0xCBD1, 0x641C,\r\n\t0xCBD2, 0x8258, 0xCBD3, 0x64DE, 0xCBD4, 0x55FD, 0xCBD5, 0x82CF,\t0xCBD6, 0x9165, 0xCBD7, 0x4FD7, 0xCBD8, 0x7D20, 0xCBD9, 0x901F,\r\n\t0xCBDA, 0x7C9F, 0xCBDB, 0x50F3, 0xCBDC, 0x5851, 0xCBDD, 0x6EAF,\t0xCBDE, 0x5BBF, 0xCBDF, 0x8BC9, 0xCBE0, 0x8083, 0xCBE1, 0x9178,\r\n\t0xCBE2, 0x849C, 0xCBE3, 0x7B97, 0xCBE4, 0x867D, 0xCBE5, 0x968B,\t0xCBE6, 0x968F, 0xCBE7, 0x7EE5, 0xCBE8, 0x9AD3, 0xCBE9, 0x788E,\r\n\t0xCBEA, 0x5C81, 0xCBEB, 0x7A57, 0xCBEC, 0x9042, 0xCBED, 0x96A7,\t0xCBEE, 0x795F, 0xCBEF, 0x5B59, 0xCBF0, 0x635F, 0xCBF1, 0x7B0B,\r\n\t0xCBF2, 0x84D1, 0xCBF3, 0x68AD, 0xCBF4, 0x5506, 0xCBF5, 0x7F29,\t0xCBF6, 0x7410, 0xCBF7, 0x7D22, 0xCBF8, 0x9501, 0xCBF9, 0x6240,\r\n\t0xCBFA, 0x584C, 0xCBFB, 0x4ED6, 0xCBFC, 0x5B83, 0xCBFD, 0x5979,\t0xCBFE, 0x5854, 0xCC40, 0x85F9, 0xCC41, 0x85FA, 0xCC42, 0x85FC,\r\n\t0xCC43, 0x85FD, 0xCC44, 0x85FE, 0xCC45, 0x8600, 0xCC46, 0x8601,\t0xCC47, 0x8602, 0xCC48, 0x8603, 0xCC49, 0x8604, 0xCC4A, 0x8606,\r\n\t0xCC4B, 0x8607, 0xCC4C, 0x8608, 0xCC4D, 0x8609, 0xCC4E, 0x860A,\t0xCC4F, 0x860B, 0xCC50, 0x860C, 0xCC51, 0x860D, 0xCC52, 0x860E,\r\n\t0xCC53, 0x860F, 0xCC54, 0x8610, 0xCC55, 0x8612, 0xCC56, 0x8613,\t0xCC57, 0x8614, 0xCC58, 0x8615, 0xCC59, 0x8617, 0xCC5A, 0x8618,\r\n\t0xCC5B, 0x8619, 0xCC5C, 0x861A, 0xCC5D, 0x861B, 0xCC5E, 0x861C,\t0xCC5F, 0x861D, 0xCC60, 0x861E, 0xCC61, 0x861F, 0xCC62, 0x8620,\r\n\t0xCC63, 0x8621, 0xCC64, 0x8622, 0xCC65, 0x8623, 0xCC66, 0x8624,\t0xCC67, 0x8625, 0xCC68, 0x8626, 0xCC69, 0x8628, 0xCC6A, 0x862A,\r\n\t0xCC6B, 0x862B, 0xCC6C, 0x862C, 0xCC6D, 0x862D, 0xCC6E, 0x862E,\t0xCC6F, 0x862F, 0xCC70, 0x8630, 0xCC71, 0x8631, 0xCC72, 0x8632,\r\n\t0xCC73, 0x8633, 0xCC74, 0x8634, 0xCC75, 0x8635, 0xCC76, 0x8636,\t0xCC77, 0x8637, 0xCC78, 0x8639, 0xCC79, 0x863A, 0xCC7A, 0x863B,\r\n\t0xCC7B, 0x863D, 0xCC7C, 0x863E, 0xCC7D, 0x863F, 0xCC7E, 0x8640,\t0xCC80, 0x8641, 0xCC81, 0x8642, 0xCC82, 0x8643, 0xCC83, 0x8644,\r\n\t0xCC84, 0x8645, 0xCC85, 0x8646, 0xCC86, 0x8647, 0xCC87, 0x8648,\t0xCC88, 0x8649, 0xCC89, 0x864A, 0xCC8A, 0x864B, 0xCC8B, 0x864C,\r\n\t0xCC8C, 0x8652, 0xCC8D, 0x8653, 0xCC8E, 0x8655, 0xCC8F, 0x8656,\t0xCC90, 0x8657, 0xCC91, 0x8658, 0xCC92, 0x8659, 0xCC93, 0x865B,\r\n\t0xCC94, 0x865C, 0xCC95, 0x865D, 0xCC96, 0x865F, 0xCC97, 0x8660,\t0xCC98, 0x8661, 0xCC99, 0x8663, 0xCC9A, 0x8664, 0xCC9B, 0x8665,\r\n\t0xCC9C, 0x8666, 0xCC9D, 0x8667, 0xCC9E, 0x8668, 0xCC9F, 0x8669,\t0xCCA0, 0x866A, 0xCCA1, 0x736D, 0xCCA2, 0x631E, 0xCCA3, 0x8E4B,\r\n\t0xCCA4, 0x8E0F, 0xCCA5, 0x80CE, 0xCCA6, 0x82D4, 0xCCA7, 0x62AC,\t0xCCA8, 0x53F0, 0xCCA9, 0x6CF0, 0xCCAA, 0x915E, 0xCCAB, 0x592A,\r\n\t0xCCAC, 0x6001, 0xCCAD, 0x6C70, 0xCCAE, 0x574D, 0xCCAF, 0x644A,\t0xCCB0, 0x8D2A, 0xCCB1, 0x762B, 0xCCB2, 0x6EE9, 0xCCB3, 0x575B,\r\n\t0xCCB4, 0x6A80, 0xCCB5, 0x75F0, 0xCCB6, 0x6F6D, 0xCCB7, 0x8C2D,\t0xCCB8, 0x8C08, 0xCCB9, 0x5766, 0xCCBA, 0x6BEF, 0xCCBB, 0x8892,\r\n\t0xCCBC, 0x78B3, 0xCCBD, 0x63A2, 0xCCBE, 0x53F9, 0xCCBF, 0x70AD,\t0xCCC0, 0x6C64, 0xCCC1, 0x5858, 0xCCC2, 0x642A, 0xCCC3, 0x5802,\r\n\t0xCCC4, 0x68E0, 0xCCC5, 0x819B, 0xCCC6, 0x5510, 0xCCC7, 0x7CD6,\t0xCCC8, 0x5018, 0xCCC9, 0x8EBA, 0xCCCA, 0x6DCC, 0xCCCB, 0x8D9F,\r\n\t0xCCCC, 0x70EB, 0xCCCD, 0x638F, 0xCCCE, 0x6D9B, 0xCCCF, 0x6ED4,\t0xCCD0, 0x7EE6, 0xCCD1, 0x8404, 0xCCD2, 0x6843, 0xCCD3, 0x9003,\r\n\t0xCCD4, 0x6DD8, 0xCCD5, 0x9676, 0xCCD6, 0x8BA8, 0xCCD7, 0x5957,\t0xCCD8, 0x7279, 0xCCD9, 0x85E4, 0xCCDA, 0x817E, 0xCCDB, 0x75BC,\r\n\t0xCCDC, 0x8A8A, 0xCCDD, 0x68AF, 0xCCDE, 0x5254, 0xCCDF, 0x8E22,\t0xCCE0, 0x9511, 0xCCE1, 0x63D0, 0xCCE2, 0x9898, 0xCCE3, 0x8E44,\r\n\t0xCCE4, 0x557C, 0xCCE5, 0x4F53, 0xCCE6, 0x66FF, 0xCCE7, 0x568F,\t0xCCE8, 0x60D5, 0xCCE9, 0x6D95, 0xCCEA, 0x5243, 0xCCEB, 0x5C49,\r\n\t0xCCEC, 0x5929, 0xCCED, 0x6DFB, 0xCCEE, 0x586B, 0xCCEF, 0x7530,\t0xCCF0, 0x751C, 0xCCF1, 0x606C, 0xCCF2, 0x8214, 0xCCF3, 0x8146,\r\n\t0xCCF4, 0x6311, 0xCCF5, 0x6761, 0xCCF6, 0x8FE2, 0xCCF7, 0x773A,\t0xCCF8, 0x8DF3, 0xCCF9, 0x8D34, 0xCCFA, 0x94C1, 0xCCFB, 0x5E16,\r\n\t0xCCFC, 0x5385, 0xCCFD, 0x542C, 0xCCFE, 0x70C3, 0xCD40, 0x866D,\t0xCD41, 0x866F, 0xCD42, 0x8670, 0xCD43, 0x8672, 0xCD44, 0x8673,\r\n\t0xCD45, 0x8674, 0xCD46, 0x8675, 0xCD47, 0x8676, 0xCD48, 0x8677,\t0xCD49, 0x8678, 0xCD4A, 0x8683, 0xCD4B, 0x8684, 0xCD4C, 0x8685,\r\n\t0xCD4D, 0x8686, 0xCD4E, 0x8687, 0xCD4F, 0x8688, 0xCD50, 0x8689,\t0xCD51, 0x868E, 0xCD52, 0x868F, 0xCD53, 0x8690, 0xCD54, 0x8691,\r\n\t0xCD55, 0x8692, 0xCD56, 0x8694, 0xCD57, 0x8696, 0xCD58, 0x8697,\t0xCD59, 0x8698, 0xCD5A, 0x8699, 0xCD5B, 0x869A, 0xCD5C, 0x869B,\r\n\t0xCD5D, 0x869E, 0xCD5E, 0x869F, 0xCD5F, 0x86A0, 0xCD60, 0x86A1,\t0xCD61, 0x86A2, 0xCD62, 0x86A5, 0xCD63, 0x86A6, 0xCD64, 0x86AB,\r\n\t0xCD65, 0x86AD, 0xCD66, 0x86AE, 0xCD67, 0x86B2, 0xCD68, 0x86B3,\t0xCD69, 0x86B7, 0xCD6A, 0x86B8, 0xCD6B, 0x86B9, 0xCD6C, 0x86BB,\r\n\t0xCD6D, 0x86BC, 0xCD6E, 0x86BD, 0xCD6F, 0x86BE, 0xCD70, 0x86BF,\t0xCD71, 0x86C1, 0xCD72, 0x86C2, 0xCD73, 0x86C3, 0xCD74, 0x86C5,\r\n\t0xCD75, 0x86C8, 0xCD76, 0x86CC, 0xCD77, 0x86CD, 0xCD78, 0x86D2,\t0xCD79, 0x86D3, 0xCD7A, 0x86D5, 0xCD7B, 0x86D6, 0xCD7C, 0x86D7,\r\n\t0xCD7D, 0x86DA, 0xCD7E, 0x86DC, 0xCD80, 0x86DD, 0xCD81, 0x86E0,\t0xCD82, 0x86E1, 0xCD83, 0x86E2, 0xCD84, 0x86E3, 0xCD85, 0x86E5,\r\n\t0xCD86, 0x86E6, 0xCD87, 0x86E7, 0xCD88, 0x86E8, 0xCD89, 0x86EA,\t0xCD8A, 0x86EB, 0xCD8B, 0x86EC, 0xCD8C, 0x86EF, 0xCD8D, 0x86F5,\r\n\t0xCD8E, 0x86F6, 0xCD8F, 0x86F7, 0xCD90, 0x86FA, 0xCD91, 0x86FB,\t0xCD92, 0x86FC, 0xCD93, 0x86FD, 0xCD94, 0x86FF, 0xCD95, 0x8701,\r\n\t0xCD96, 0x8704, 0xCD97, 0x8705, 0xCD98, 0x8706, 0xCD99, 0x870B,\t0xCD9A, 0x870C, 0xCD9B, 0x870E, 0xCD9C, 0x870F, 0xCD9D, 0x8710,\r\n\t0xCD9E, 0x8711, 0xCD9F, 0x8714, 0xCDA0, 0x8716, 0xCDA1, 0x6C40,\t0xCDA2, 0x5EF7, 0xCDA3, 0x505C, 0xCDA4, 0x4EAD, 0xCDA5, 0x5EAD,\r\n\t0xCDA6, 0x633A, 0xCDA7, 0x8247, 0xCDA8, 0x901A, 0xCDA9, 0x6850,\t0xCDAA, 0x916E, 0xCDAB, 0x77B3, 0xCDAC, 0x540C, 0xCDAD, 0x94DC,\r\n\t0xCDAE, 0x5F64, 0xCDAF, 0x7AE5, 0xCDB0, 0x6876, 0xCDB1, 0x6345,\t0xCDB2, 0x7B52, 0xCDB3, 0x7EDF, 0xCDB4, 0x75DB, 0xCDB5, 0x5077,\r\n\t0xCDB6, 0x6295, 0xCDB7, 0x5934, 0xCDB8, 0x900F, 0xCDB9, 0x51F8,\t0xCDBA, 0x79C3, 0xCDBB, 0x7A81, 0xCDBC, 0x56FE, 0xCDBD, 0x5F92,\r\n\t0xCDBE, 0x9014, 0xCDBF, 0x6D82, 0xCDC0, 0x5C60, 0xCDC1, 0x571F,\t0xCDC2, 0x5410, 0xCDC3, 0x5154, 0xCDC4, 0x6E4D, 0xCDC5, 0x56E2,\r\n\t0xCDC6, 0x63A8, 0xCDC7, 0x9893, 0xCDC8, 0x817F, 0xCDC9, 0x8715,\t0xCDCA, 0x892A, 0xCDCB, 0x9000, 0xCDCC, 0x541E, 0xCDCD, 0x5C6F,\r\n\t0xCDCE, 0x81C0, 0xCDCF, 0x62D6, 0xCDD0, 0x6258, 0xCDD1, 0x8131,\t0xCDD2, 0x9E35, 0xCDD3, 0x9640, 0xCDD4, 0x9A6E, 0xCDD5, 0x9A7C,\r\n\t0xCDD6, 0x692D, 0xCDD7, 0x59A5, 0xCDD8, 0x62D3, 0xCDD9, 0x553E,\t0xCDDA, 0x6316, 0xCDDB, 0x54C7, 0xCDDC, 0x86D9, 0xCDDD, 0x6D3C,\r\n\t0xCDDE, 0x5A03, 0xCDDF, 0x74E6, 0xCDE0, 0x889C, 0xCDE1, 0x6B6A,\t0xCDE2, 0x5916, 0xCDE3, 0x8C4C, 0xCDE4, 0x5F2F, 0xCDE5, 0x6E7E,\r\n\t0xCDE6, 0x73A9, 0xCDE7, 0x987D, 0xCDE8, 0x4E38, 0xCDE9, 0x70F7,\t0xCDEA, 0x5B8C, 0xCDEB, 0x7897, 0xCDEC, 0x633D, 0xCDED, 0x665A,\r\n\t0xCDEE, 0x7696, 0xCDEF, 0x60CB, 0xCDF0, 0x5B9B, 0xCDF1, 0x5A49,\t0xCDF2, 0x4E07, 0xCDF3, 0x8155, 0xCDF4, 0x6C6A, 0xCDF5, 0x738B,\r\n\t0xCDF6, 0x4EA1, 0xCDF7, 0x6789, 0xCDF8, 0x7F51, 0xCDF9, 0x5F80,\t0xCDFA, 0x65FA, 0xCDFB, 0x671B, 0xCDFC, 0x5FD8, 0xCDFD, 0x5984,\r\n\t0xCDFE, 0x5A01, 0xCE40, 0x8719, 0xCE41, 0x871B, 0xCE42, 0x871D,\t0xCE43, 0x871F, 0xCE44, 0x8720, 0xCE45, 0x8724, 0xCE46, 0x8726,\r\n\t0xCE47, 0x8727, 0xCE48, 0x8728, 0xCE49, 0x872A, 0xCE4A, 0x872B,\t0xCE4B, 0x872C, 0xCE4C, 0x872D, 0xCE4D, 0x872F, 0xCE4E, 0x8730,\r\n\t0xCE4F, 0x8732, 0xCE50, 0x8733, 0xCE51, 0x8735, 0xCE52, 0x8736,\t0xCE53, 0x8738, 0xCE54, 0x8739, 0xCE55, 0x873A, 0xCE56, 0x873C,\r\n\t0xCE57, 0x873D, 0xCE58, 0x8740, 0xCE59, 0x8741, 0xCE5A, 0x8742,\t0xCE5B, 0x8743, 0xCE5C, 0x8744, 0xCE5D, 0x8745, 0xCE5E, 0x8746,\r\n\t0xCE5F, 0x874A, 0xCE60, 0x874B, 0xCE61, 0x874D, 0xCE62, 0x874F,\t0xCE63, 0x8750, 0xCE64, 0x8751, 0xCE65, 0x8752, 0xCE66, 0x8754,\r\n\t0xCE67, 0x8755, 0xCE68, 0x8756, 0xCE69, 0x8758, 0xCE6A, 0x875A,\t0xCE6B, 0x875B, 0xCE6C, 0x875C, 0xCE6D, 0x875D, 0xCE6E, 0x875E,\r\n\t0xCE6F, 0x875F, 0xCE70, 0x8761, 0xCE71, 0x8762, 0xCE72, 0x8766,\t0xCE73, 0x8767, 0xCE74, 0x8768, 0xCE75, 0x8769, 0xCE76, 0x876A,\r\n\t0xCE77, 0x876B, 0xCE78, 0x876C, 0xCE79, 0x876D, 0xCE7A, 0x876F,\t0xCE7B, 0x8771, 0xCE7C, 0x8772, 0xCE7D, 0x8773, 0xCE7E, 0x8775,\r\n\t0xCE80, 0x8777, 0xCE81, 0x8778, 0xCE82, 0x8779, 0xCE83, 0x877A,\t0xCE84, 0x877F, 0xCE85, 0x8780, 0xCE86, 0x8781, 0xCE87, 0x8784,\r\n\t0xCE88, 0x8786, 0xCE89, 0x8787, 0xCE8A, 0x8789, 0xCE8B, 0x878A,\t0xCE8C, 0x878C, 0xCE8D, 0x878E, 0xCE8E, 0x878F, 0xCE8F, 0x8790,\r\n\t0xCE90, 0x8791, 0xCE91, 0x8792, 0xCE92, 0x8794, 0xCE93, 0x8795,\t0xCE94, 0x8796, 0xCE95, 0x8798, 0xCE96, 0x8799, 0xCE97, 0x879A,\r\n\t0xCE98, 0x879B, 0xCE99, 0x879C, 0xCE9A, 0x879D, 0xCE9B, 0x879E,\t0xCE9C, 0x87A0, 0xCE9D, 0x87A1, 0xCE9E, 0x87A2, 0xCE9F, 0x87A3,\r\n\t0xCEA0, 0x87A4, 0xCEA1, 0x5DCD, 0xCEA2, 0x5FAE, 0xCEA3, 0x5371,\t0xCEA4, 0x97E6, 0xCEA5, 0x8FDD, 0xCEA6, 0x6845, 0xCEA7, 0x56F4,\r\n\t0xCEA8, 0x552F, 0xCEA9, 0x60DF, 0xCEAA, 0x4E3A, 0xCEAB, 0x6F4D,\t0xCEAC, 0x7EF4, 0xCEAD, 0x82C7, 0xCEAE, 0x840E, 0xCEAF, 0x59D4,\r\n\t0xCEB0, 0x4F1F, 0xCEB1, 0x4F2A, 0xCEB2, 0x5C3E, 0xCEB3, 0x7EAC,\t0xCEB4, 0x672A, 0xCEB5, 0x851A, 0xCEB6, 0x5473, 0xCEB7, 0x754F,\r\n\t0xCEB8, 0x80C3, 0xCEB9, 0x5582, 0xCEBA, 0x9B4F, 0xCEBB, 0x4F4D,\t0xCEBC, 0x6E2D, 0xCEBD, 0x8C13, 0xCEBE, 0x5C09, 0xCEBF, 0x6170,\r\n\t0xCEC0, 0x536B, 0xCEC1, 0x761F, 0xCEC2, 0x6E29, 0xCEC3, 0x868A,\t0xCEC4, 0x6587, 0xCEC5, 0x95FB, 0xCEC6, 0x7EB9, 0xCEC7, 0x543B,\r\n\t0xCEC8, 0x7A33, 0xCEC9, 0x7D0A, 0xCECA, 0x95EE, 0xCECB, 0x55E1,\t0xCECC, 0x7FC1, 0xCECD, 0x74EE, 0xCECE, 0x631D, 0xCECF, 0x8717,\r\n\t0xCED0, 0x6DA1, 0xCED1, 0x7A9D, 0xCED2, 0x6211, 0xCED3, 0x65A1,\t0xCED4, 0x5367, 0xCED5, 0x63E1, 0xCED6, 0x6C83, 0xCED7, 0x5DEB,\r\n\t0xCED8, 0x545C, 0xCED9, 0x94A8, 0xCEDA, 0x4E4C, 0xCEDB, 0x6C61,\t0xCEDC, 0x8BEC, 0xCEDD, 0x5C4B, 0xCEDE, 0x65E0, 0xCEDF, 0x829C,\r\n\t0xCEE0, 0x68A7, 0xCEE1, 0x543E, 0xCEE2, 0x5434, 0xCEE3, 0x6BCB,\t0xCEE4, 0x6B66, 0xCEE5, 0x4E94, 0xCEE6, 0x6342, 0xCEE7, 0x5348,\r\n\t0xCEE8, 0x821E, 0xCEE9, 0x4F0D, 0xCEEA, 0x4FAE, 0xCEEB, 0x575E,\t0xCEEC, 0x620A, 0xCEED, 0x96FE, 0xCEEE, 0x6664, 0xCEEF, 0x7269,\r\n\t0xCEF0, 0x52FF, 0xCEF1, 0x52A1, 0xCEF2, 0x609F, 0xCEF3, 0x8BEF,\t0xCEF4, 0x6614, 0xCEF5, 0x7199, 0xCEF6, 0x6790, 0xCEF7, 0x897F,\r\n\t0xCEF8, 0x7852, 0xCEF9, 0x77FD, 0xCEFA, 0x6670, 0xCEFB, 0x563B,\t0xCEFC, 0x5438, 0xCEFD, 0x9521, 0xCEFE, 0x727A, 0xCF40, 0x87A5,\r\n\t0xCF41, 0x87A6, 0xCF42, 0x87A7, 0xCF43, 0x87A9, 0xCF44, 0x87AA,\t0xCF45, 0x87AE, 0xCF46, 0x87B0, 0xCF47, 0x87B1, 0xCF48, 0x87B2,\r\n\t0xCF49, 0x87B4, 0xCF4A, 0x87B6, 0xCF4B, 0x87B7, 0xCF4C, 0x87B8,\t0xCF4D, 0x87B9, 0xCF4E, 0x87BB, 0xCF4F, 0x87BC, 0xCF50, 0x87BE,\r\n\t0xCF51, 0x87BF, 0xCF52, 0x87C1, 0xCF53, 0x87C2, 0xCF54, 0x87C3,\t0xCF55, 0x87C4, 0xCF56, 0x87C5, 0xCF57, 0x87C7, 0xCF58, 0x87C8,\r\n\t0xCF59, 0x87C9, 0xCF5A, 0x87CC, 0xCF5B, 0x87CD, 0xCF5C, 0x87CE,\t0xCF5D, 0x87CF, 0xCF5E, 0x87D0, 0xCF5F, 0x87D4, 0xCF60, 0x87D5,\r\n\t0xCF61, 0x87D6, 0xCF62, 0x87D7, 0xCF63, 0x87D8, 0xCF64, 0x87D9,\t0xCF65, 0x87DA, 0xCF66, 0x87DC, 0xCF67, 0x87DD, 0xCF68, 0x87DE,\r\n\t0xCF69, 0x87DF, 0xCF6A, 0x87E1, 0xCF6B, 0x87E2, 0xCF6C, 0x87E3,\t0xCF6D, 0x87E4, 0xCF6E, 0x87E6, 0xCF6F, 0x87E7, 0xCF70, 0x87E8,\r\n\t0xCF71, 0x87E9, 0xCF72, 0x87EB, 0xCF73, 0x87EC, 0xCF74, 0x87ED,\t0xCF75, 0x87EF, 0xCF76, 0x87F0, 0xCF77, 0x87F1, 0xCF78, 0x87F2,\r\n\t0xCF79, 0x87F3, 0xCF7A, 0x87F4, 0xCF7B, 0x87F5, 0xCF7C, 0x87F6,\t0xCF7D, 0x87F7, 0xCF7E, 0x87F8, 0xCF80, 0x87FA, 0xCF81, 0x87FB,\r\n\t0xCF82, 0x87FC, 0xCF83, 0x87FD, 0xCF84, 0x87FF, 0xCF85, 0x8800,\t0xCF86, 0x8801, 0xCF87, 0x8802, 0xCF88, 0x8804, 0xCF89, 0x8805,\r\n\t0xCF8A, 0x8806, 0xCF8B, 0x8807, 0xCF8C, 0x8808, 0xCF8D, 0x8809,\t0xCF8E, 0x880B, 0xCF8F, 0x880C, 0xCF90, 0x880D, 0xCF91, 0x880E,\r\n\t0xCF92, 0x880F, 0xCF93, 0x8810, 0xCF94, 0x8811, 0xCF95, 0x8812,\t0xCF96, 0x8814, 0xCF97, 0x8817, 0xCF98, 0x8818, 0xCF99, 0x8819,\r\n\t0xCF9A, 0x881A, 0xCF9B, 0x881C, 0xCF9C, 0x881D, 0xCF9D, 0x881E,\t0xCF9E, 0x881F, 0xCF9F, 0x8820, 0xCFA0, 0x8823, 0xCFA1, 0x7A00,\r\n\t0xCFA2, 0x606F, 0xCFA3, 0x5E0C, 0xCFA4, 0x6089, 0xCFA5, 0x819D,\t0xCFA6, 0x5915, 0xCFA7, 0x60DC, 0xCFA8, 0x7184, 0xCFA9, 0x70EF,\r\n\t0xCFAA, 0x6EAA, 0xCFAB, 0x6C50, 0xCFAC, 0x7280, 0xCFAD, 0x6A84,\t0xCFAE, 0x88AD, 0xCFAF, 0x5E2D, 0xCFB0, 0x4E60, 0xCFB1, 0x5AB3,\r\n\t0xCFB2, 0x559C, 0xCFB3, 0x94E3, 0xCFB4, 0x6D17, 0xCFB5, 0x7CFB,\t0xCFB6, 0x9699, 0xCFB7, 0x620F, 0xCFB8, 0x7EC6, 0xCFB9, 0x778E,\r\n\t0xCFBA, 0x867E, 0xCFBB, 0x5323, 0xCFBC, 0x971E, 0xCFBD, 0x8F96,\t0xCFBE, 0x6687, 0xCFBF, 0x5CE1, 0xCFC0, 0x4FA0, 0xCFC1, 0x72ED,\r\n\t0xCFC2, 0x4E0B, 0xCFC3, 0x53A6, 0xCFC4, 0x590F, 0xCFC5, 0x5413,\t0xCFC6, 0x6380, 0xCFC7, 0x9528, 0xCFC8, 0x5148, 0xCFC9, 0x4ED9,\r\n\t0xCFCA, 0x9C9C, 0xCFCB, 0x7EA4, 0xCFCC, 0x54B8, 0xCFCD, 0x8D24,\t0xCFCE, 0x8854, 0xCFCF, 0x8237, 0xCFD0, 0x95F2, 0xCFD1, 0x6D8E,\r\n\t0xCFD2, 0x5F26, 0xCFD3, 0x5ACC, 0xCFD4, 0x663E, 0xCFD5, 0x9669,\t0xCFD6, 0x73B0, 0xCFD7, 0x732E, 0xCFD8, 0x53BF, 0xCFD9, 0x817A,\r\n\t0xCFDA, 0x9985, 0xCFDB, 0x7FA1, 0xCFDC, 0x5BAA, 0xCFDD, 0x9677,\t0xCFDE, 0x9650, 0xCFDF, 0x7EBF, 0xCFE0, 0x76F8, 0xCFE1, 0x53A2,\r\n\t0xCFE2, 0x9576, 0xCFE3, 0x9999, 0xCFE4, 0x7BB1, 0xCFE5, 0x8944,\t0xCFE6, 0x6E58, 0xCFE7, 0x4E61, 0xCFE8, 0x7FD4, 0xCFE9, 0x7965,\r\n\t0xCFEA, 0x8BE6, 0xCFEB, 0x60F3, 0xCFEC, 0x54CD, 0xCFED, 0x4EAB,\t0xCFEE, 0x9879, 0xCFEF, 0x5DF7, 0xCFF0, 0x6A61, 0xCFF1, 0x50CF,\r\n\t0xCFF2, 0x5411, 0xCFF3, 0x8C61, 0xCFF4, 0x8427, 0xCFF5, 0x785D,\t0xCFF6, 0x9704, 0xCFF7, 0x524A, 0xCFF8, 0x54EE, 0xCFF9, 0x56A3,\r\n\t0xCFFA, 0x9500, 0xCFFB, 0x6D88, 0xCFFC, 0x5BB5, 0xCFFD, 0x6DC6,\t0xCFFE, 0x6653, 0xD040, 0x8824, 0xD041, 0x8825, 0xD042, 0x8826,\r\n\t0xD043, 0x8827, 0xD044, 0x8828, 0xD045, 0x8829, 0xD046, 0x882A,\t0xD047, 0x882B, 0xD048, 0x882C, 0xD049, 0x882D, 0xD04A, 0x882E,\r\n\t0xD04B, 0x882F, 0xD04C, 0x8830, 0xD04D, 0x8831, 0xD04E, 0x8833,\t0xD04F, 0x8834, 0xD050, 0x8835, 0xD051, 0x8836, 0xD052, 0x8837,\r\n\t0xD053, 0x8838, 0xD054, 0x883A, 0xD055, 0x883B, 0xD056, 0x883D,\t0xD057, 0x883E, 0xD058, 0x883F, 0xD059, 0x8841, 0xD05A, 0x8842,\r\n\t0xD05B, 0x8843, 0xD05C, 0x8846, 0xD05D, 0x8847, 0xD05E, 0x8848,\t0xD05F, 0x8849, 0xD060, 0x884A, 0xD061, 0x884B, 0xD062, 0x884E,\r\n\t0xD063, 0x884F, 0xD064, 0x8850, 0xD065, 0x8851, 0xD066, 0x8852,\t0xD067, 0x8853, 0xD068, 0x8855, 0xD069, 0x8856, 0xD06A, 0x8858,\r\n\t0xD06B, 0x885A, 0xD06C, 0x885B, 0xD06D, 0x885C, 0xD06E, 0x885D,\t0xD06F, 0x885E, 0xD070, 0x885F, 0xD071, 0x8860, 0xD072, 0x8866,\r\n\t0xD073, 0x8867, 0xD074, 0x886A, 0xD075, 0x886D, 0xD076, 0x886F,\t0xD077, 0x8871, 0xD078, 0x8873, 0xD079, 0x8874, 0xD07A, 0x8875,\r\n\t0xD07B, 0x8876, 0xD07C, 0x8878, 0xD07D, 0x8879, 0xD07E, 0x887A,\t0xD080, 0x887B, 0xD081, 0x887C, 0xD082, 0x8880, 0xD083, 0x8883,\r\n\t0xD084, 0x8886, 0xD085, 0x8887, 0xD086, 0x8889, 0xD087, 0x888A,\t0xD088, 0x888C, 0xD089, 0x888E, 0xD08A, 0x888F, 0xD08B, 0x8890,\r\n\t0xD08C, 0x8891, 0xD08D, 0x8893, 0xD08E, 0x8894, 0xD08F, 0x8895,\t0xD090, 0x8897, 0xD091, 0x8898, 0xD092, 0x8899, 0xD093, 0x889A,\r\n\t0xD094, 0x889B, 0xD095, 0x889D, 0xD096, 0x889E, 0xD097, 0x889F,\t0xD098, 0x88A0, 0xD099, 0x88A1, 0xD09A, 0x88A3, 0xD09B, 0x88A5,\r\n\t0xD09C, 0x88A6, 0xD09D, 0x88A7, 0xD09E, 0x88A8, 0xD09F, 0x88A9,\t0xD0A0, 0x88AA, 0xD0A1, 0x5C0F, 0xD0A2, 0x5B5D, 0xD0A3, 0x6821,\r\n\t0xD0A4, 0x8096, 0xD0A5, 0x5578, 0xD0A6, 0x7B11, 0xD0A7, 0x6548,\t0xD0A8, 0x6954, 0xD0A9, 0x4E9B, 0xD0AA, 0x6B47, 0xD0AB, 0x874E,\r\n\t0xD0AC, 0x978B, 0xD0AD, 0x534F, 0xD0AE, 0x631F, 0xD0AF, 0x643A,\t0xD0B0, 0x90AA, 0xD0B1, 0x659C, 0xD0B2, 0x80C1, 0xD0B3, 0x8C10,\r\n\t0xD0B4, 0x5199, 0xD0B5, 0x68B0, 0xD0B6, 0x5378, 0xD0B7, 0x87F9,\t0xD0B8, 0x61C8, 0xD0B9, 0x6CC4, 0xD0BA, 0x6CFB, 0xD0BB, 0x8C22,\r\n\t0xD0BC, 0x5C51, 0xD0BD, 0x85AA, 0xD0BE, 0x82AF, 0xD0BF, 0x950C,\t0xD0C0, 0x6B23, 0xD0C1, 0x8F9B, 0xD0C2, 0x65B0, 0xD0C3, 0x5FFB,\r\n\t0xD0C4, 0x5FC3, 0xD0C5, 0x4FE1, 0xD0C6, 0x8845, 0xD0C7, 0x661F,\t0xD0C8, 0x8165, 0xD0C9, 0x7329, 0xD0CA, 0x60FA, 0xD0CB, 0x5174,\r\n\t0xD0CC, 0x5211, 0xD0CD, 0x578B, 0xD0CE, 0x5F62, 0xD0CF, 0x90A2,\t0xD0D0, 0x884C, 0xD0D1, 0x9192, 0xD0D2, 0x5E78, 0xD0D3, 0x674F,\r\n\t0xD0D4, 0x6027, 0xD0D5, 0x59D3, 0xD0D6, 0x5144, 0xD0D7, 0x51F6,\t0xD0D8, 0x80F8, 0xD0D9, 0x5308, 0xD0DA, 0x6C79, 0xD0DB, 0x96C4,\r\n\t0xD0DC, 0x718A, 0xD0DD, 0x4F11, 0xD0DE, 0x4FEE, 0xD0DF, 0x7F9E,\t0xD0E0, 0x673D, 0xD0E1, 0x55C5, 0xD0E2, 0x9508, 0xD0E3, 0x79C0,\r\n\t0xD0E4, 0x8896, 0xD0E5, 0x7EE3, 0xD0E6, 0x589F, 0xD0E7, 0x620C,\t0xD0E8, 0x9700, 0xD0E9, 0x865A, 0xD0EA, 0x5618, 0xD0EB, 0x987B,\r\n\t0xD0EC, 0x5F90, 0xD0ED, 0x8BB8, 0xD0EE, 0x84C4, 0xD0EF, 0x9157,\t0xD0F0, 0x53D9, 0xD0F1, 0x65ED, 0xD0F2, 0x5E8F, 0xD0F3, 0x755C,\r\n\t0xD0F4, 0x6064, 0xD0F5, 0x7D6E, 0xD0F6, 0x5A7F, 0xD0F7, 0x7EEA,\t0xD0F8, 0x7EED, 0xD0F9, 0x8F69, 0xD0FA, 0x55A7, 0xD0FB, 0x5BA3,\r\n\t0xD0FC, 0x60AC, 0xD0FD, 0x65CB, 0xD0FE, 0x7384, 0xD140, 0x88AC,\t0xD141, 0x88AE, 0xD142, 0x88AF, 0xD143, 0x88B0, 0xD144, 0x88B2,\r\n\t0xD145, 0x88B3, 0xD146, 0x88B4, 0xD147, 0x88B5, 0xD148, 0x88B6,\t0xD149, 0x88B8, 0xD14A, 0x88B9, 0xD14B, 0x88BA, 0xD14C, 0x88BB,\r\n\t0xD14D, 0x88BD, 0xD14E, 0x88BE, 0xD14F, 0x88BF, 0xD150, 0x88C0,\t0xD151, 0x88C3, 0xD152, 0x88C4, 0xD153, 0x88C7, 0xD154, 0x88C8,\r\n\t0xD155, 0x88CA, 0xD156, 0x88CB, 0xD157, 0x88CC, 0xD158, 0x88CD,\t0xD159, 0x88CF, 0xD15A, 0x88D0, 0xD15B, 0x88D1, 0xD15C, 0x88D3,\r\n\t0xD15D, 0x88D6, 0xD15E, 0x88D7, 0xD15F, 0x88DA, 0xD160, 0x88DB,\t0xD161, 0x88DC, 0xD162, 0x88DD, 0xD163, 0x88DE, 0xD164, 0x88E0,\r\n\t0xD165, 0x88E1, 0xD166, 0x88E6, 0xD167, 0x88E7, 0xD168, 0x88E9,\t0xD169, 0x88EA, 0xD16A, 0x88EB, 0xD16B, 0x88EC, 0xD16C, 0x88ED,\r\n\t0xD16D, 0x88EE, 0xD16E, 0x88EF, 0xD16F, 0x88F2, 0xD170, 0x88F5,\t0xD171, 0x88F6, 0xD172, 0x88F7, 0xD173, 0x88FA, 0xD174, 0x88FB,\r\n\t0xD175, 0x88FD, 0xD176, 0x88FF, 0xD177, 0x8900, 0xD178, 0x8901,\t0xD179, 0x8903, 0xD17A, 0x8904, 0xD17B, 0x8905, 0xD17C, 0x8906,\r\n\t0xD17D, 0x8907, 0xD17E, 0x8908, 0xD180, 0x8909, 0xD181, 0x890B,\t0xD182, 0x890C, 0xD183, 0x890D, 0xD184, 0x890E, 0xD185, 0x890F,\r\n\t0xD186, 0x8911, 0xD187, 0x8914, 0xD188, 0x8915, 0xD189, 0x8916,\t0xD18A, 0x8917, 0xD18B, 0x8918, 0xD18C, 0x891C, 0xD18D, 0x891D,\r\n\t0xD18E, 0x891E, 0xD18F, 0x891F, 0xD190, 0x8920, 0xD191, 0x8922,\t0xD192, 0x8923, 0xD193, 0x8924, 0xD194, 0x8926, 0xD195, 0x8927,\r\n\t0xD196, 0x8928, 0xD197, 0x8929, 0xD198, 0x892C, 0xD199, 0x892D,\t0xD19A, 0x892E, 0xD19B, 0x892F, 0xD19C, 0x8931, 0xD19D, 0x8932,\r\n\t0xD19E, 0x8933, 0xD19F, 0x8935, 0xD1A0, 0x8937, 0xD1A1, 0x9009,\t0xD1A2, 0x7663, 0xD1A3, 0x7729, 0xD1A4, 0x7EDA, 0xD1A5, 0x9774,\r\n\t0xD1A6, 0x859B, 0xD1A7, 0x5B66, 0xD1A8, 0x7A74, 0xD1A9, 0x96EA,\t0xD1AA, 0x8840, 0xD1AB, 0x52CB, 0xD1AC, 0x718F, 0xD1AD, 0x5FAA,\r\n\t0xD1AE, 0x65EC, 0xD1AF, 0x8BE2, 0xD1B0, 0x5BFB, 0xD1B1, 0x9A6F,\t0xD1B2, 0x5DE1, 0xD1B3, 0x6B89, 0xD1B4, 0x6C5B, 0xD1B5, 0x8BAD,\r\n\t0xD1B6, 0x8BAF, 0xD1B7, 0x900A, 0xD1B8, 0x8FC5, 0xD1B9, 0x538B,\t0xD1BA, 0x62BC, 0xD1BB, 0x9E26, 0xD1BC, 0x9E2D, 0xD1BD, 0x5440,\r\n\t0xD1BE, 0x4E2B, 0xD1BF, 0x82BD, 0xD1C0, 0x7259, 0xD1C1, 0x869C,\t0xD1C2, 0x5D16, 0xD1C3, 0x8859, 0xD1C4, 0x6DAF, 0xD1C5, 0x96C5,\r\n\t0xD1C6, 0x54D1, 0xD1C7, 0x4E9A, 0xD1C8, 0x8BB6, 0xD1C9, 0x7109,\t0xD1CA, 0x54BD, 0xD1CB, 0x9609, 0xD1CC, 0x70DF, 0xD1CD, 0x6DF9,\r\n\t0xD1CE, 0x76D0, 0xD1CF, 0x4E25, 0xD1D0, 0x7814, 0xD1D1, 0x8712,\t0xD1D2, 0x5CA9, 0xD1D3, 0x5EF6, 0xD1D4, 0x8A00, 0xD1D5, 0x989C,\r\n\t0xD1D6, 0x960E, 0xD1D7, 0x708E, 0xD1D8, 0x6CBF, 0xD1D9, 0x5944,\t0xD1DA, 0x63A9, 0xD1DB, 0x773C, 0xD1DC, 0x884D, 0xD1DD, 0x6F14,\r\n\t0xD1DE, 0x8273, 0xD1DF, 0x5830, 0xD1E0, 0x71D5, 0xD1E1, 0x538C,\t0xD1E2, 0x781A, 0xD1E3, 0x96C1, 0xD1E4, 0x5501, 0xD1E5, 0x5F66,\r\n\t0xD1E6, 0x7130, 0xD1E7, 0x5BB4, 0xD1E8, 0x8C1A, 0xD1E9, 0x9A8C,\t0xD1EA, 0x6B83, 0xD1EB, 0x592E, 0xD1EC, 0x9E2F, 0xD1ED, 0x79E7,\r\n\t0xD1EE, 0x6768, 0xD1EF, 0x626C, 0xD1F0, 0x4F6F, 0xD1F1, 0x75A1,\t0xD1F2, 0x7F8A, 0xD1F3, 0x6D0B, 0xD1F4, 0x9633, 0xD1F5, 0x6C27,\r\n\t0xD1F6, 0x4EF0, 0xD1F7, 0x75D2, 0xD1F8, 0x517B, 0xD1F9, 0x6837,\t0xD1FA, 0x6F3E, 0xD1FB, 0x9080, 0xD1FC, 0x8170, 0xD1FD, 0x5996,\r\n\t0xD1FE, 0x7476, 0xD240, 0x8938, 0xD241, 0x8939, 0xD242, 0x893A,\t0xD243, 0x893B, 0xD244, 0x893C, 0xD245, 0x893D, 0xD246, 0x893E,\r\n\t0xD247, 0x893F, 0xD248, 0x8940, 0xD249, 0x8942, 0xD24A, 0x8943,\t0xD24B, 0x8945, 0xD24C, 0x8946, 0xD24D, 0x8947, 0xD24E, 0x8948,\r\n\t0xD24F, 0x8949, 0xD250, 0x894A, 0xD251, 0x894B, 0xD252, 0x894C,\t0xD253, 0x894D, 0xD254, 0x894E, 0xD255, 0x894F, 0xD256, 0x8950,\r\n\t0xD257, 0x8951, 0xD258, 0x8952, 0xD259, 0x8953, 0xD25A, 0x8954,\t0xD25B, 0x8955, 0xD25C, 0x8956, 0xD25D, 0x8957, 0xD25E, 0x8958,\r\n\t0xD25F, 0x8959, 0xD260, 0x895A, 0xD261, 0x895B, 0xD262, 0x895C,\t0xD263, 0x895D, 0xD264, 0x8960, 0xD265, 0x8961, 0xD266, 0x8962,\r\n\t0xD267, 0x8963, 0xD268, 0x8964, 0xD269, 0x8965, 0xD26A, 0x8967,\t0xD26B, 0x8968, 0xD26C, 0x8969, 0xD26D, 0x896A, 0xD26E, 0x896B,\r\n\t0xD26F, 0x896C, 0xD270, 0x896D, 0xD271, 0x896E, 0xD272, 0x896F,\t0xD273, 0x8970, 0xD274, 0x8971, 0xD275, 0x8972, 0xD276, 0x8973,\r\n\t0xD277, 0x8974, 0xD278, 0x8975, 0xD279, 0x8976, 0xD27A, 0x8977,\t0xD27B, 0x8978, 0xD27C, 0x8979, 0xD27D, 0x897A, 0xD27E, 0x897C,\r\n\t0xD280, 0x897D, 0xD281, 0x897E, 0xD282, 0x8980, 0xD283, 0x8982,\t0xD284, 0x8984, 0xD285, 0x8985, 0xD286, 0x8987, 0xD287, 0x8988,\r\n\t0xD288, 0x8989, 0xD289, 0x898A, 0xD28A, 0x898B, 0xD28B, 0x898C,\t0xD28C, 0x898D, 0xD28D, 0x898E, 0xD28E, 0x898F, 0xD28F, 0x8990,\r\n\t0xD290, 0x8991, 0xD291, 0x8992, 0xD292, 0x8993, 0xD293, 0x8994,\t0xD294, 0x8995, 0xD295, 0x8996, 0xD296, 0x8997, 0xD297, 0x8998,\r\n\t0xD298, 0x8999, 0xD299, 0x899A, 0xD29A, 0x899B, 0xD29B, 0x899C,\t0xD29C, 0x899D, 0xD29D, 0x899E, 0xD29E, 0x899F, 0xD29F, 0x89A0,\r\n\t0xD2A0, 0x89A1, 0xD2A1, 0x6447, 0xD2A2, 0x5C27, 0xD2A3, 0x9065,\t0xD2A4, 0x7A91, 0xD2A5, 0x8C23, 0xD2A6, 0x59DA, 0xD2A7, 0x54AC,\r\n\t0xD2A8, 0x8200, 0xD2A9, 0x836F, 0xD2AA, 0x8981, 0xD2AB, 0x8000,\t0xD2AC, 0x6930, 0xD2AD, 0x564E, 0xD2AE, 0x8036, 0xD2AF, 0x7237,\r\n\t0xD2B0, 0x91CE, 0xD2B1, 0x51B6, 0xD2B2, 0x4E5F, 0xD2B3, 0x9875,\t0xD2B4, 0x6396, 0xD2B5, 0x4E1A, 0xD2B6, 0x53F6, 0xD2B7, 0x66F3,\r\n\t0xD2B8, 0x814B, 0xD2B9, 0x591C, 0xD2BA, 0x6DB2, 0xD2BB, 0x4E00,\t0xD2BC, 0x58F9, 0xD2BD, 0x533B, 0xD2BE, 0x63D6, 0xD2BF, 0x94F1,\r\n\t0xD2C0, 0x4F9D, 0xD2C1, 0x4F0A, 0xD2C2, 0x8863, 0xD2C3, 0x9890,\t0xD2C4, 0x5937, 0xD2C5, 0x9057, 0xD2C6, 0x79FB, 0xD2C7, 0x4EEA,\r\n\t0xD2C8, 0x80F0, 0xD2C9, 0x7591, 0xD2CA, 0x6C82, 0xD2CB, 0x5B9C,\t0xD2CC, 0x59E8, 0xD2CD, 0x5F5D, 0xD2CE, 0x6905, 0xD2CF, 0x8681,\r\n\t0xD2D0, 0x501A, 0xD2D1, 0x5DF2, 0xD2D2, 0x4E59, 0xD2D3, 0x77E3,\t0xD2D4, 0x4EE5, 0xD2D5, 0x827A, 0xD2D6, 0x6291, 0xD2D7, 0x6613,\r\n\t0xD2D8, 0x9091, 0xD2D9, 0x5C79, 0xD2DA, 0x4EBF, 0xD2DB, 0x5F79,\t0xD2DC, 0x81C6, 0xD2DD, 0x9038, 0xD2DE, 0x8084, 0xD2DF, 0x75AB,\r\n\t0xD2E0, 0x4EA6, 0xD2E1, 0x88D4, 0xD2E2, 0x610F, 0xD2E3, 0x6BC5,\t0xD2E4, 0x5FC6, 0xD2E5, 0x4E49, 0xD2E6, 0x76CA, 0xD2E7, 0x6EA2,\r\n\t0xD2E8, 0x8BE3, 0xD2E9, 0x8BAE, 0xD2EA, 0x8C0A, 0xD2EB, 0x8BD1,\t0xD2EC, 0x5F02, 0xD2ED, 0x7FFC, 0xD2EE, 0x7FCC, 0xD2EF, 0x7ECE,\r\n\t0xD2F0, 0x8335, 0xD2F1, 0x836B, 0xD2F2, 0x56E0, 0xD2F3, 0x6BB7,\t0xD2F4, 0x97F3, 0xD2F5, 0x9634, 0xD2F6, 0x59FB, 0xD2F7, 0x541F,\r\n\t0xD2F8, 0x94F6, 0xD2F9, 0x6DEB, 0xD2FA, 0x5BC5, 0xD2FB, 0x996E,\t0xD2FC, 0x5C39, 0xD2FD, 0x5F15, 0xD2FE, 0x9690, 0xD340, 0x89A2,\r\n\t0xD341, 0x89A3, 0xD342, 0x89A4, 0xD343, 0x89A5, 0xD344, 0x89A6,\t0xD345, 0x89A7, 0xD346, 0x89A8, 0xD347, 0x89A9, 0xD348, 0x89AA,\r\n\t0xD349, 0x89AB, 0xD34A, 0x89AC, 0xD34B, 0x89AD, 0xD34C, 0x89AE,\t0xD34D, 0x89AF, 0xD34E, 0x89B0, 0xD34F, 0x89B1, 0xD350, 0x89B2,\r\n\t0xD351, 0x89B3, 0xD352, 0x89B4, 0xD353, 0x89B5, 0xD354, 0x89B6,\t0xD355, 0x89B7, 0xD356, 0x89B8, 0xD357, 0x89B9, 0xD358, 0x89BA,\r\n\t0xD359, 0x89BB, 0xD35A, 0x89BC, 0xD35B, 0x89BD, 0xD35C, 0x89BE,\t0xD35D, 0x89BF, 0xD35E, 0x89C0, 0xD35F, 0x89C3, 0xD360, 0x89CD,\r\n\t0xD361, 0x89D3, 0xD362, 0x89D4, 0xD363, 0x89D5, 0xD364, 0x89D7,\t0xD365, 0x89D8, 0xD366, 0x89D9, 0xD367, 0x89DB, 0xD368, 0x89DD,\r\n\t0xD369, 0x89DF, 0xD36A, 0x89E0, 0xD36B, 0x89E1, 0xD36C, 0x89E2,\t0xD36D, 0x89E4, 0xD36E, 0x89E7, 0xD36F, 0x89E8, 0xD370, 0x89E9,\r\n\t0xD371, 0x89EA, 0xD372, 0x89EC, 0xD373, 0x89ED, 0xD374, 0x89EE,\t0xD375, 0x89F0, 0xD376, 0x89F1, 0xD377, 0x89F2, 0xD378, 0x89F4,\r\n\t0xD379, 0x89F5, 0xD37A, 0x89F6, 0xD37B, 0x89F7, 0xD37C, 0x89F8,\t0xD37D, 0x89F9, 0xD37E, 0x89FA, 0xD380, 0x89FB, 0xD381, 0x89FC,\r\n\t0xD382, 0x89FD, 0xD383, 0x89FE, 0xD384, 0x89FF, 0xD385, 0x8A01,\t0xD386, 0x8A02, 0xD387, 0x8A03, 0xD388, 0x8A04, 0xD389, 0x8A05,\r\n\t0xD38A, 0x8A06, 0xD38B, 0x8A08, 0xD38C, 0x8A09, 0xD38D, 0x8A0A,\t0xD38E, 0x8A0B, 0xD38F, 0x8A0C, 0xD390, 0x8A0D, 0xD391, 0x8A0E,\r\n\t0xD392, 0x8A0F, 0xD393, 0x8A10, 0xD394, 0x8A11, 0xD395, 0x8A12,\t0xD396, 0x8A13, 0xD397, 0x8A14, 0xD398, 0x8A15, 0xD399, 0x8A16,\r\n\t0xD39A, 0x8A17, 0xD39B, 0x8A18, 0xD39C, 0x8A19, 0xD39D, 0x8A1A,\t0xD39E, 0x8A1B, 0xD39F, 0x8A1C, 0xD3A0, 0x8A1D, 0xD3A1, 0x5370,\r\n\t0xD3A2, 0x82F1, 0xD3A3, 0x6A31, 0xD3A4, 0x5A74, 0xD3A5, 0x9E70,\t0xD3A6, 0x5E94, 0xD3A7, 0x7F28, 0xD3A8, 0x83B9, 0xD3A9, 0x8424,\r\n\t0xD3AA, 0x8425, 0xD3AB, 0x8367, 0xD3AC, 0x8747, 0xD3AD, 0x8FCE,\t0xD3AE, 0x8D62, 0xD3AF, 0x76C8, 0xD3B0, 0x5F71, 0xD3B1, 0x9896,\r\n\t0xD3B2, 0x786C, 0xD3B3, 0x6620, 0xD3B4, 0x54DF, 0xD3B5, 0x62E5,\t0xD3B6, 0x4F63, 0xD3B7, 0x81C3, 0xD3B8, 0x75C8, 0xD3B9, 0x5EB8,\r\n\t0xD3BA, 0x96CD, 0xD3BB, 0x8E0A, 0xD3BC, 0x86F9, 0xD3BD, 0x548F,\t0xD3BE, 0x6CF3, 0xD3BF, 0x6D8C, 0xD3C0, 0x6C38, 0xD3C1, 0x607F,\r\n\t0xD3C2, 0x52C7, 0xD3C3, 0x7528, 0xD3C4, 0x5E7D, 0xD3C5, 0x4F18,\t0xD3C6, 0x60A0, 0xD3C7, 0x5FE7, 0xD3C8, 0x5C24, 0xD3C9, 0x7531,\r\n\t0xD3CA, 0x90AE, 0xD3CB, 0x94C0, 0xD3CC, 0x72B9, 0xD3CD, 0x6CB9,\t0xD3CE, 0x6E38, 0xD3CF, 0x9149, 0xD3D0, 0x6709, 0xD3D1, 0x53CB,\r\n\t0xD3D2, 0x53F3, 0xD3D3, 0x4F51, 0xD3D4, 0x91C9, 0xD3D5, 0x8BF1,\t0xD3D6, 0x53C8, 0xD3D7, 0x5E7C, 0xD3D8, 0x8FC2, 0xD3D9, 0x6DE4,\r\n\t0xD3DA, 0x4E8E, 0xD3DB, 0x76C2, 0xD3DC, 0x6986, 0xD3DD, 0x865E,\t0xD3DE, 0x611A, 0xD3DF, 0x8206, 0xD3E0, 0x4F59, 0xD3E1, 0x4FDE,\r\n\t0xD3E2, 0x903E, 0xD3E3, 0x9C7C, 0xD3E4, 0x6109, 0xD3E5, 0x6E1D,\t0xD3E6, 0x6E14, 0xD3E7, 0x9685, 0xD3E8, 0x4E88, 0xD3E9, 0x5A31,\r\n\t0xD3EA, 0x96E8, 0xD3EB, 0x4E0E, 0xD3EC, 0x5C7F, 0xD3ED, 0x79B9,\t0xD3EE, 0x5B87, 0xD3EF, 0x8BED, 0xD3F0, 0x7FBD, 0xD3F1, 0x7389,\r\n\t0xD3F2, 0x57DF, 0xD3F3, 0x828B, 0xD3F4, 0x90C1, 0xD3F5, 0x5401,\t0xD3F6, 0x9047, 0xD3F7, 0x55BB, 0xD3F8, 0x5CEA, 0xD3F9, 0x5FA1,\r\n\t0xD3FA, 0x6108, 0xD3FB, 0x6B32, 0xD3FC, 0x72F1, 0xD3FD, 0x80B2,\t0xD3FE, 0x8A89, 0xD440, 0x8A1E, 0xD441, 0x8A1F, 0xD442, 0x8A20,\r\n\t0xD443, 0x8A21, 0xD444, 0x8A22, 0xD445, 0x8A23, 0xD446, 0x8A24,\t0xD447, 0x8A25, 0xD448, 0x8A26, 0xD449, 0x8A27, 0xD44A, 0x8A28,\r\n\t0xD44B, 0x8A29, 0xD44C, 0x8A2A, 0xD44D, 0x8A2B, 0xD44E, 0x8A2C,\t0xD44F, 0x8A2D, 0xD450, 0x8A2E, 0xD451, 0x8A2F, 0xD452, 0x8A30,\r\n\t0xD453, 0x8A31, 0xD454, 0x8A32, 0xD455, 0x8A33, 0xD456, 0x8A34,\t0xD457, 0x8A35, 0xD458, 0x8A36, 0xD459, 0x8A37, 0xD45A, 0x8A38,\r\n\t0xD45B, 0x8A39, 0xD45C, 0x8A3A, 0xD45D, 0x8A3B, 0xD45E, 0x8A3C,\t0xD45F, 0x8A3D, 0xD460, 0x8A3F, 0xD461, 0x8A40, 0xD462, 0x8A41,\r\n\t0xD463, 0x8A42, 0xD464, 0x8A43, 0xD465, 0x8A44, 0xD466, 0x8A45,\t0xD467, 0x8A46, 0xD468, 0x8A47, 0xD469, 0x8A49, 0xD46A, 0x8A4A,\r\n\t0xD46B, 0x8A4B, 0xD46C, 0x8A4C, 0xD46D, 0x8A4D, 0xD46E, 0x8A4E,\t0xD46F, 0x8A4F, 0xD470, 0x8A50, 0xD471, 0x8A51, 0xD472, 0x8A52,\r\n\t0xD473, 0x8A53, 0xD474, 0x8A54, 0xD475, 0x8A55, 0xD476, 0x8A56,\t0xD477, 0x8A57, 0xD478, 0x8A58, 0xD479, 0x8A59, 0xD47A, 0x8A5A,\r\n\t0xD47B, 0x8A5B, 0xD47C, 0x8A5C, 0xD47D, 0x8A5D, 0xD47E, 0x8A5E,\t0xD480, 0x8A5F, 0xD481, 0x8A60, 0xD482, 0x8A61, 0xD483, 0x8A62,\r\n\t0xD484, 0x8A63, 0xD485, 0x8A64, 0xD486, 0x8A65, 0xD487, 0x8A66,\t0xD488, 0x8A67, 0xD489, 0x8A68, 0xD48A, 0x8A69, 0xD48B, 0x8A6A,\r\n\t0xD48C, 0x8A6B, 0xD48D, 0x8A6C, 0xD48E, 0x8A6D, 0xD48F, 0x8A6E,\t0xD490, 0x8A6F, 0xD491, 0x8A70, 0xD492, 0x8A71, 0xD493, 0x8A72,\r\n\t0xD494, 0x8A73, 0xD495, 0x8A74, 0xD496, 0x8A75, 0xD497, 0x8A76,\t0xD498, 0x8A77, 0xD499, 0x8A78, 0xD49A, 0x8A7A, 0xD49B, 0x8A7B,\r\n\t0xD49C, 0x8A7C, 0xD49D, 0x8A7D, 0xD49E, 0x8A7E, 0xD49F, 0x8A7F,\t0xD4A0, 0x8A80, 0xD4A1, 0x6D74, 0xD4A2, 0x5BD3, 0xD4A3, 0x88D5,\r\n\t0xD4A4, 0x9884, 0xD4A5, 0x8C6B, 0xD4A6, 0x9A6D, 0xD4A7, 0x9E33,\t0xD4A8, 0x6E0A, 0xD4A9, 0x51A4, 0xD4AA, 0x5143, 0xD4AB, 0x57A3,\r\n\t0xD4AC, 0x8881, 0xD4AD, 0x539F, 0xD4AE, 0x63F4, 0xD4AF, 0x8F95,\t0xD4B0, 0x56ED, 0xD4B1, 0x5458, 0xD4B2, 0x5706, 0xD4B3, 0x733F,\r\n\t0xD4B4, 0x6E90, 0xD4B5, 0x7F18, 0xD4B6, 0x8FDC, 0xD4B7, 0x82D1,\t0xD4B8, 0x613F, 0xD4B9, 0x6028, 0xD4BA, 0x9662, 0xD4BB, 0x66F0,\r\n\t0xD4BC, 0x7EA6, 0xD4BD, 0x8D8A, 0xD4BE, 0x8DC3, 0xD4BF, 0x94A5,\t0xD4C0, 0x5CB3, 0xD4C1, 0x7CA4, 0xD4C2, 0x6708, 0xD4C3, 0x60A6,\r\n\t0xD4C4, 0x9605, 0xD4C5, 0x8018, 0xD4C6, 0x4E91, 0xD4C7, 0x90E7,\t0xD4C8, 0x5300, 0xD4C9, 0x9668, 0xD4CA, 0x5141, 0xD4CB, 0x8FD0,\r\n\t0xD4CC, 0x8574, 0xD4CD, 0x915D, 0xD4CE, 0x6655, 0xD4CF, 0x97F5,\t0xD4D0, 0x5B55, 0xD4D1, 0x531D, 0xD4D2, 0x7838, 0xD4D3, 0x6742,\r\n\t0xD4D4, 0x683D, 0xD4D5, 0x54C9, 0xD4D6, 0x707E, 0xD4D7, 0x5BB0,\t0xD4D8, 0x8F7D, 0xD4D9, 0x518D, 0xD4DA, 0x5728, 0xD4DB, 0x54B1,\r\n\t0xD4DC, 0x6512, 0xD4DD, 0x6682, 0xD4DE, 0x8D5E, 0xD4DF, 0x8D43,\t0xD4E0, 0x810F, 0xD4E1, 0x846C, 0xD4E2, 0x906D, 0xD4E3, 0x7CDF,\r\n\t0xD4E4, 0x51FF, 0xD4E5, 0x85FB, 0xD4E6, 0x67A3, 0xD4E7, 0x65E9,\t0xD4E8, 0x6FA1, 0xD4E9, 0x86A4, 0xD4EA, 0x8E81, 0xD4EB, 0x566A,\r\n\t0xD4EC, 0x9020, 0xD4ED, 0x7682, 0xD4EE, 0x7076, 0xD4EF, 0x71E5,\t0xD4F0, 0x8D23, 0xD4F1, 0x62E9, 0xD4F2, 0x5219, 0xD4F3, 0x6CFD,\r\n\t0xD4F4, 0x8D3C, 0xD4F5, 0x600E, 0xD4F6, 0x589E, 0xD4F7, 0x618E,\t0xD4F8, 0x66FE, 0xD4F9, 0x8D60, 0xD4FA, 0x624E, 0xD4FB, 0x55B3,\r\n\t0xD4FC, 0x6E23, 0xD4FD, 0x672D, 0xD4FE, 0x8F67, 0xD540, 0x8A81,\t0xD541, 0x8A82, 0xD542, 0x8A83, 0xD543, 0x8A84, 0xD544, 0x8A85,\r\n\t0xD545, 0x8A86, 0xD546, 0x8A87, 0xD547, 0x8A88, 0xD548, 0x8A8B,\t0xD549, 0x8A8C, 0xD54A, 0x8A8D, 0xD54B, 0x8A8E, 0xD54C, 0x8A8F,\r\n\t0xD54D, 0x8A90, 0xD54E, 0x8A91, 0xD54F, 0x8A92, 0xD550, 0x8A94,\t0xD551, 0x8A95, 0xD552, 0x8A96, 0xD553, 0x8A97, 0xD554, 0x8A98,\r\n\t0xD555, 0x8A99, 0xD556, 0x8A9A, 0xD557, 0x8A9B, 0xD558, 0x8A9C,\t0xD559, 0x8A9D, 0xD55A, 0x8A9E, 0xD55B, 0x8A9F, 0xD55C, 0x8AA0,\r\n\t0xD55D, 0x8AA1, 0xD55E, 0x8AA2, 0xD55F, 0x8AA3, 0xD560, 0x8AA4,\t0xD561, 0x8AA5, 0xD562, 0x8AA6, 0xD563, 0x8AA7, 0xD564, 0x8AA8,\r\n\t0xD565, 0x8AA9, 0xD566, 0x8AAA, 0xD567, 0x8AAB, 0xD568, 0x8AAC,\t0xD569, 0x8AAD, 0xD56A, 0x8AAE, 0xD56B, 0x8AAF, 0xD56C, 0x8AB0,\r\n\t0xD56D, 0x8AB1, 0xD56E, 0x8AB2, 0xD56F, 0x8AB3, 0xD570, 0x8AB4,\t0xD571, 0x8AB5, 0xD572, 0x8AB6, 0xD573, 0x8AB7, 0xD574, 0x8AB8,\r\n\t0xD575, 0x8AB9, 0xD576, 0x8ABA, 0xD577, 0x8ABB, 0xD578, 0x8ABC,\t0xD579, 0x8ABD, 0xD57A, 0x8ABE, 0xD57B, 0x8ABF, 0xD57C, 0x8AC0,\r\n\t0xD57D, 0x8AC1, 0xD57E, 0x8AC2, 0xD580, 0x8AC3, 0xD581, 0x8AC4,\t0xD582, 0x8AC5, 0xD583, 0x8AC6, 0xD584, 0x8AC7, 0xD585, 0x8AC8,\r\n\t0xD586, 0x8AC9, 0xD587, 0x8ACA, 0xD588, 0x8ACB, 0xD589, 0x8ACC,\t0xD58A, 0x8ACD, 0xD58B, 0x8ACE, 0xD58C, 0x8ACF, 0xD58D, 0x8AD0,\r\n\t0xD58E, 0x8AD1, 0xD58F, 0x8AD2, 0xD590, 0x8AD3, 0xD591, 0x8AD4,\t0xD592, 0x8AD5, 0xD593, 0x8AD6, 0xD594, 0x8AD7, 0xD595, 0x8AD8,\r\n\t0xD596, 0x8AD9, 0xD597, 0x8ADA, 0xD598, 0x8ADB, 0xD599, 0x8ADC,\t0xD59A, 0x8ADD, 0xD59B, 0x8ADE, 0xD59C, 0x8ADF, 0xD59D, 0x8AE0,\r\n\t0xD59E, 0x8AE1, 0xD59F, 0x8AE2, 0xD5A0, 0x8AE3, 0xD5A1, 0x94E1,\t0xD5A2, 0x95F8, 0xD5A3, 0x7728, 0xD5A4, 0x6805, 0xD5A5, 0x69A8,\r\n\t0xD5A6, 0x548B, 0xD5A7, 0x4E4D, 0xD5A8, 0x70B8, 0xD5A9, 0x8BC8,\t0xD5AA, 0x6458, 0xD5AB, 0x658B, 0xD5AC, 0x5B85, 0xD5AD, 0x7A84,\r\n\t0xD5AE, 0x503A, 0xD5AF, 0x5BE8, 0xD5B0, 0x77BB, 0xD5B1, 0x6BE1,\t0xD5B2, 0x8A79, 0xD5B3, 0x7C98, 0xD5B4, 0x6CBE, 0xD5B5, 0x76CF,\r\n\t0xD5B6, 0x65A9, 0xD5B7, 0x8F97, 0xD5B8, 0x5D2D, 0xD5B9, 0x5C55,\t0xD5BA, 0x8638, 0xD5BB, 0x6808, 0xD5BC, 0x5360, 0xD5BD, 0x6218,\r\n\t0xD5BE, 0x7AD9, 0xD5BF, 0x6E5B, 0xD5C0, 0x7EFD, 0xD5C1, 0x6A1F,\t0xD5C2, 0x7AE0, 0xD5C3, 0x5F70, 0xD5C4, 0x6F33, 0xD5C5, 0x5F20,\r\n\t0xD5C6, 0x638C, 0xD5C7, 0x6DA8, 0xD5C8, 0x6756, 0xD5C9, 0x4E08,\t0xD5CA, 0x5E10, 0xD5CB, 0x8D26, 0xD5CC, 0x4ED7, 0xD5CD, 0x80C0,\r\n\t0xD5CE, 0x7634, 0xD5CF, 0x969C, 0xD5D0, 0x62DB, 0xD5D1, 0x662D,\t0xD5D2, 0x627E, 0xD5D3, 0x6CBC, 0xD5D4, 0x8D75, 0xD5D5, 0x7167,\r\n\t0xD5D6, 0x7F69, 0xD5D7, 0x5146, 0xD5D8, 0x8087, 0xD5D9, 0x53EC,\t0xD5DA, 0x906E, 0xD5DB, 0x6298, 0xD5DC, 0x54F2, 0xD5DD, 0x86F0,\r\n\t0xD5DE, 0x8F99, 0xD5DF, 0x8005, 0xD5E0, 0x9517, 0xD5E1, 0x8517,\t0xD5E2, 0x8FD9, 0xD5E3, 0x6D59, 0xD5E4, 0x73CD, 0xD5E5, 0x659F,\r\n\t0xD5E6, 0x771F, 0xD5E7, 0x7504, 0xD5E8, 0x7827, 0xD5E9, 0x81FB,\t0xD5EA, 0x8D1E, 0xD5EB, 0x9488, 0xD5EC, 0x4FA6, 0xD5ED, 0x6795,\r\n\t0xD5EE, 0x75B9, 0xD5EF, 0x8BCA, 0xD5F0, 0x9707, 0xD5F1, 0x632F,\t0xD5F2, 0x9547, 0xD5F3, 0x9635, 0xD5F4, 0x84B8, 0xD5F5, 0x6323,\r\n\t0xD5F6, 0x7741, 0xD5F7, 0x5F81, 0xD5F8, 0x72F0, 0xD5F9, 0x4E89,\t0xD5FA, 0x6014, 0xD5FB, 0x6574, 0xD5FC, 0x62EF, 0xD5FD, 0x6B63,\r\n\t0xD5FE, 0x653F, 0xD640, 0x8AE4, 0xD641, 0x8AE5, 0xD642, 0x8AE6,\t0xD643, 0x8AE7, 0xD644, 0x8AE8, 0xD645, 0x8AE9, 0xD646, 0x8AEA,\r\n\t0xD647, 0x8AEB, 0xD648, 0x8AEC, 0xD649, 0x8AED, 0xD64A, 0x8AEE,\t0xD64B, 0x8AEF, 0xD64C, 0x8AF0, 0xD64D, 0x8AF1, 0xD64E, 0x8AF2,\r\n\t0xD64F, 0x8AF3, 0xD650, 0x8AF4, 0xD651, 0x8AF5, 0xD652, 0x8AF6,\t0xD653, 0x8AF7, 0xD654, 0x8AF8, 0xD655, 0x8AF9, 0xD656, 0x8AFA,\r\n\t0xD657, 0x8AFB, 0xD658, 0x8AFC, 0xD659, 0x8AFD, 0xD65A, 0x8AFE,\t0xD65B, 0x8AFF, 0xD65C, 0x8B00, 0xD65D, 0x8B01, 0xD65E, 0x8B02,\r\n\t0xD65F, 0x8B03, 0xD660, 0x8B04, 0xD661, 0x8B05, 0xD662, 0x8B06,\t0xD663, 0x8B08, 0xD664, 0x8B09, 0xD665, 0x8B0A, 0xD666, 0x8B0B,\r\n\t0xD667, 0x8B0C, 0xD668, 0x8B0D, 0xD669, 0x8B0E, 0xD66A, 0x8B0F,\t0xD66B, 0x8B10, 0xD66C, 0x8B11, 0xD66D, 0x8B12, 0xD66E, 0x8B13,\r\n\t0xD66F, 0x8B14, 0xD670, 0x8B15, 0xD671, 0x8B16, 0xD672, 0x8B17,\t0xD673, 0x8B18, 0xD674, 0x8B19, 0xD675, 0x8B1A, 0xD676, 0x8B1B,\r\n\t0xD677, 0x8B1C, 0xD678, 0x8B1D, 0xD679, 0x8B1E, 0xD67A, 0x8B1F,\t0xD67B, 0x8B20, 0xD67C, 0x8B21, 0xD67D, 0x8B22, 0xD67E, 0x8B23,\r\n\t0xD680, 0x8B24, 0xD681, 0x8B25, 0xD682, 0x8B27, 0xD683, 0x8B28,\t0xD684, 0x8B29, 0xD685, 0x8B2A, 0xD686, 0x8B2B, 0xD687, 0x8B2C,\r\n\t0xD688, 0x8B2D, 0xD689, 0x8B2E, 0xD68A, 0x8B2F, 0xD68B, 0x8B30,\t0xD68C, 0x8B31, 0xD68D, 0x8B32, 0xD68E, 0x8B33, 0xD68F, 0x8B34,\r\n\t0xD690, 0x8B35, 0xD691, 0x8B36, 0xD692, 0x8B37, 0xD693, 0x8B38,\t0xD694, 0x8B39, 0xD695, 0x8B3A, 0xD696, 0x8B3B, 0xD697, 0x8B3C,\r\n\t0xD698, 0x8B3D, 0xD699, 0x8B3E, 0xD69A, 0x8B3F, 0xD69B, 0x8B40,\t0xD69C, 0x8B41, 0xD69D, 0x8B42, 0xD69E, 0x8B43, 0xD69F, 0x8B44,\r\n\t0xD6A0, 0x8B45, 0xD6A1, 0x5E27, 0xD6A2, 0x75C7, 0xD6A3, 0x90D1,\t0xD6A4, 0x8BC1, 0xD6A5, 0x829D, 0xD6A6, 0x679D, 0xD6A7, 0x652F,\r\n\t0xD6A8, 0x5431, 0xD6A9, 0x8718, 0xD6AA, 0x77E5, 0xD6AB, 0x80A2,\t0xD6AC, 0x8102, 0xD6AD, 0x6C41, 0xD6AE, 0x4E4B, 0xD6AF, 0x7EC7,\r\n\t0xD6B0, 0x804C, 0xD6B1, 0x76F4, 0xD6B2, 0x690D, 0xD6B3, 0x6B96,\t0xD6B4, 0x6267, 0xD6B5, 0x503C, 0xD6B6, 0x4F84, 0xD6B7, 0x5740,\r\n\t0xD6B8, 0x6307, 0xD6B9, 0x6B62, 0xD6BA, 0x8DBE, 0xD6BB, 0x53EA,\t0xD6BC, 0x65E8, 0xD6BD, 0x7EB8, 0xD6BE, 0x5FD7, 0xD6BF, 0x631A,\r\n\t0xD6C0, 0x63B7, 0xD6C1, 0x81F3, 0xD6C2, 0x81F4, 0xD6C3, 0x7F6E,\t0xD6C4, 0x5E1C, 0xD6C5, 0x5CD9, 0xD6C6, 0x5236, 0xD6C7, 0x667A,\r\n\t0xD6C8, 0x79E9, 0xD6C9, 0x7A1A, 0xD6CA, 0x8D28, 0xD6CB, 0x7099,\t0xD6CC, 0x75D4, 0xD6CD, 0x6EDE, 0xD6CE, 0x6CBB, 0xD6CF, 0x7A92,\r\n\t0xD6D0, 0x4E2D, 0xD6D1, 0x76C5, 0xD6D2, 0x5FE0, 0xD6D3, 0x949F,\t0xD6D4, 0x8877, 0xD6D5, 0x7EC8, 0xD6D6, 0x79CD, 0xD6D7, 0x80BF,\r\n\t0xD6D8, 0x91CD, 0xD6D9, 0x4EF2, 0xD6DA, 0x4F17, 0xD6DB, 0x821F,\t0xD6DC, 0x5468, 0xD6DD, 0x5DDE, 0xD6DE, 0x6D32, 0xD6DF, 0x8BCC,\r\n\t0xD6E0, 0x7CA5, 0xD6E1, 0x8F74, 0xD6E2, 0x8098, 0xD6E3, 0x5E1A,\t0xD6E4, 0x5492, 0xD6E5, 0x76B1, 0xD6E6, 0x5B99, 0xD6E7, 0x663C,\r\n\t0xD6E8, 0x9AA4, 0xD6E9, 0x73E0, 0xD6EA, 0x682A, 0xD6EB, 0x86DB,\t0xD6EC, 0x6731, 0xD6ED, 0x732A, 0xD6EE, 0x8BF8, 0xD6EF, 0x8BDB,\r\n\t0xD6F0, 0x9010, 0xD6F1, 0x7AF9, 0xD6F2, 0x70DB, 0xD6F3, 0x716E,\t0xD6F4, 0x62C4, 0xD6F5, 0x77A9, 0xD6F6, 0x5631, 0xD6F7, 0x4E3B,\r\n\t0xD6F8, 0x8457, 0xD6F9, 0x67F1, 0xD6FA, 0x52A9, 0xD6FB, 0x86C0,\t0xD6FC, 0x8D2E, 0xD6FD, 0x94F8, 0xD6FE, 0x7B51, 0xD740, 0x8B46,\r\n\t0xD741, 0x8B47, 0xD742, 0x8B48, 0xD743, 0x8B49, 0xD744, 0x8B4A,\t0xD745, 0x8B4B, 0xD746, 0x8B4C, 0xD747, 0x8B4D, 0xD748, 0x8B4E,\r\n\t0xD749, 0x8B4F, 0xD74A, 0x8B50, 0xD74B, 0x8B51, 0xD74C, 0x8B52,\t0xD74D, 0x8B53, 0xD74E, 0x8B54, 0xD74F, 0x8B55, 0xD750, 0x8B56,\r\n\t0xD751, 0x8B57, 0xD752, 0x8B58, 0xD753, 0x8B59, 0xD754, 0x8B5A,\t0xD755, 0x8B5B, 0xD756, 0x8B5C, 0xD757, 0x8B5D, 0xD758, 0x8B5E,\r\n\t0xD759, 0x8B5F, 0xD75A, 0x8B60, 0xD75B, 0x8B61, 0xD75C, 0x8B62,\t0xD75D, 0x8B63, 0xD75E, 0x8B64, 0xD75F, 0x8B65, 0xD760, 0x8B67,\r\n\t0xD761, 0x8B68, 0xD762, 0x8B69, 0xD763, 0x8B6A, 0xD764, 0x8B6B,\t0xD765, 0x8B6D, 0xD766, 0x8B6E, 0xD767, 0x8B6F, 0xD768, 0x8B70,\r\n\t0xD769, 0x8B71, 0xD76A, 0x8B72, 0xD76B, 0x8B73, 0xD76C, 0x8B74,\t0xD76D, 0x8B75, 0xD76E, 0x8B76, 0xD76F, 0x8B77, 0xD770, 0x8B78,\r\n\t0xD771, 0x8B79, 0xD772, 0x8B7A, 0xD773, 0x8B7B, 0xD774, 0x8B7C,\t0xD775, 0x8B7D, 0xD776, 0x8B7E, 0xD777, 0x8B7F, 0xD778, 0x8B80,\r\n\t0xD779, 0x8B81, 0xD77A, 0x8B82, 0xD77B, 0x8B83, 0xD77C, 0x8B84,\t0xD77D, 0x8B85, 0xD77E, 0x8B86, 0xD780, 0x8B87, 0xD781, 0x8B88,\r\n\t0xD782, 0x8B89, 0xD783, 0x8B8A, 0xD784, 0x8B8B, 0xD785, 0x8B8C,\t0xD786, 0x8B8D, 0xD787, 0x8B8E, 0xD788, 0x8B8F, 0xD789, 0x8B90,\r\n\t0xD78A, 0x8B91, 0xD78B, 0x8B92, 0xD78C, 0x8B93, 0xD78D, 0x8B94,\t0xD78E, 0x8B95, 0xD78F, 0x8B96, 0xD790, 0x8B97, 0xD791, 0x8B98,\r\n\t0xD792, 0x8B99, 0xD793, 0x8B9A, 0xD794, 0x8B9B, 0xD795, 0x8B9C,\t0xD796, 0x8B9D, 0xD797, 0x8B9E, 0xD798, 0x8B9F, 0xD799, 0x8BAC,\r\n\t0xD79A, 0x8BB1, 0xD79B, 0x8BBB, 0xD79C, 0x8BC7, 0xD79D, 0x8BD0,\t0xD79E, 0x8BEA, 0xD79F, 0x8C09, 0xD7A0, 0x8C1E, 0xD7A1, 0x4F4F,\r\n\t0xD7A2, 0x6CE8, 0xD7A3, 0x795D, 0xD7A4, 0x9A7B, 0xD7A5, 0x6293,\t0xD7A6, 0x722A, 0xD7A7, 0x62FD, 0xD7A8, 0x4E13, 0xD7A9, 0x7816,\r\n\t0xD7AA, 0x8F6C, 0xD7AB, 0x64B0, 0xD7AC, 0x8D5A, 0xD7AD, 0x7BC6,\t0xD7AE, 0x6869, 0xD7AF, 0x5E84, 0xD7B0, 0x88C5, 0xD7B1, 0x5986,\r\n\t0xD7B2, 0x649E, 0xD7B3, 0x58EE, 0xD7B4, 0x72B6, 0xD7B5, 0x690E,\t0xD7B6, 0x9525, 0xD7B7, 0x8FFD, 0xD7B8, 0x8D58, 0xD7B9, 0x5760,\r\n\t0xD7BA, 0x7F00, 0xD7BB, 0x8C06, 0xD7BC, 0x51C6, 0xD7BD, 0x6349,\t0xD7BE, 0x62D9, 0xD7BF, 0x5353, 0xD7C0, 0x684C, 0xD7C1, 0x7422,\r\n\t0xD7C2, 0x8301, 0xD7C3, 0x914C, 0xD7C4, 0x5544, 0xD7C5, 0x7740,\t0xD7C6, 0x707C, 0xD7C7, 0x6D4A, 0xD7C8, 0x5179, 0xD7C9, 0x54A8,\r\n\t0xD7CA, 0x8D44, 0xD7CB, 0x59FF, 0xD7CC, 0x6ECB, 0xD7CD, 0x6DC4,\t0xD7CE, 0x5B5C, 0xD7CF, 0x7D2B, 0xD7D0, 0x4ED4, 0xD7D1, 0x7C7D,\r\n\t0xD7D2, 0x6ED3, 0xD7D3, 0x5B50, 0xD7D4, 0x81EA, 0xD7D5, 0x6E0D,\t0xD7D6, 0x5B57, 0xD7D7, 0x9B03, 0xD7D8, 0x68D5, 0xD7D9, 0x8E2A,\r\n\t0xD7DA, 0x5B97, 0xD7DB, 0x7EFC, 0xD7DC, 0x603B, 0xD7DD, 0x7EB5,\t0xD7DE, 0x90B9, 0xD7DF, 0x8D70, 0xD7E0, 0x594F, 0xD7E1, 0x63CD,\r\n\t0xD7E2, 0x79DF, 0xD7E3, 0x8DB3, 0xD7E4, 0x5352, 0xD7E5, 0x65CF,\t0xD7E6, 0x7956, 0xD7E7, 0x8BC5, 0xD7E8, 0x963B, 0xD7E9, 0x7EC4,\r\n\t0xD7EA, 0x94BB, 0xD7EB, 0x7E82, 0xD7EC, 0x5634, 0xD7ED, 0x9189,\t0xD7EE, 0x6700, 0xD7EF, 0x7F6A, 0xD7F0, 0x5C0A, 0xD7F1, 0x9075,\r\n\t0xD7F2, 0x6628, 0xD7F3, 0x5DE6, 0xD7F4, 0x4F50, 0xD7F5, 0x67DE,\t0xD7F6, 0x505A, 0xD7F7, 0x4F5C, 0xD7F8, 0x5750, 0xD7F9, 0x5EA7,\r\n\t0xD840, 0x8C38, 0xD841, 0x8C39, 0xD842, 0x8C3A, 0xD843, 0x8C3B,\t0xD844, 0x8C3C, 0xD845, 0x8C3D, 0xD846, 0x8C3E, 0xD847, 0x8C3F,\r\n\t0xD848, 0x8C40, 0xD849, 0x8C42, 0xD84A, 0x8C43, 0xD84B, 0x8C44,\t0xD84C, 0x8C45, 0xD84D, 0x8C48, 0xD84E, 0x8C4A, 0xD84F, 0x8C4B,\r\n\t0xD850, 0x8C4D, 0xD851, 0x8C4E, 0xD852, 0x8C4F, 0xD853, 0x8C50,\t0xD854, 0x8C51, 0xD855, 0x8C52, 0xD856, 0x8C53, 0xD857, 0x8C54,\r\n\t0xD858, 0x8C56, 0xD859, 0x8C57, 0xD85A, 0x8C58, 0xD85B, 0x8C59,\t0xD85C, 0x8C5B, 0xD85D, 0x8C5C, 0xD85E, 0x8C5D, 0xD85F, 0x8C5E,\r\n\t0xD860, 0x8C5F, 0xD861, 0x8C60, 0xD862, 0x8C63, 0xD863, 0x8C64,\t0xD864, 0x8C65, 0xD865, 0x8C66, 0xD866, 0x8C67, 0xD867, 0x8C68,\r\n\t0xD868, 0x8C69, 0xD869, 0x8C6C, 0xD86A, 0x8C6D, 0xD86B, 0x8C6E,\t0xD86C, 0x8C6F, 0xD86D, 0x8C70, 0xD86E, 0x8C71, 0xD86F, 0x8C72,\r\n\t0xD870, 0x8C74, 0xD871, 0x8C75, 0xD872, 0x8C76, 0xD873, 0x8C77,\t0xD874, 0x8C7B, 0xD875, 0x8C7C, 0xD876, 0x8C7D, 0xD877, 0x8C7E,\r\n\t0xD878, 0x8C7F, 0xD879, 0x8C80, 0xD87A, 0x8C81, 0xD87B, 0x8C83,\t0xD87C, 0x8C84, 0xD87D, 0x8C86, 0xD87E, 0x8C87, 0xD880, 0x8C88,\r\n\t0xD881, 0x8C8B, 0xD882, 0x8C8D, 0xD883, 0x8C8E, 0xD884, 0x8C8F,\t0xD885, 0x8C90, 0xD886, 0x8C91, 0xD887, 0x8C92, 0xD888, 0x8C93,\r\n\t0xD889, 0x8C95, 0xD88A, 0x8C96, 0xD88B, 0x8C97, 0xD88C, 0x8C99,\t0xD88D, 0x8C9A, 0xD88E, 0x8C9B, 0xD88F, 0x8C9C, 0xD890, 0x8C9D,\r\n\t0xD891, 0x8C9E, 0xD892, 0x8C9F, 0xD893, 0x8CA0, 0xD894, 0x8CA1,\t0xD895, 0x8CA2, 0xD896, 0x8CA3, 0xD897, 0x8CA4, 0xD898, 0x8CA5,\r\n\t0xD899, 0x8CA6, 0xD89A, 0x8CA7, 0xD89B, 0x8CA8, 0xD89C, 0x8CA9,\t0xD89D, 0x8CAA, 0xD89E, 0x8CAB, 0xD89F, 0x8CAC, 0xD8A0, 0x8CAD,\r\n\t0xD8A1, 0x4E8D, 0xD8A2, 0x4E0C, 0xD8A3, 0x5140, 0xD8A4, 0x4E10,\t0xD8A5, 0x5EFF, 0xD8A6, 0x5345, 0xD8A7, 0x4E15, 0xD8A8, 0x4E98,\r\n\t0xD8A9, 0x4E1E, 0xD8AA, 0x9B32, 0xD8AB, 0x5B6C, 0xD8AC, 0x5669,\t0xD8AD, 0x4E28, 0xD8AE, 0x79BA, 0xD8AF, 0x4E3F, 0xD8B0, 0x5315,\r\n\t0xD8B1, 0x4E47, 0xD8B2, 0x592D, 0xD8B3, 0x723B, 0xD8B4, 0x536E,\t0xD8B5, 0x6C10, 0xD8B6, 0x56DF, 0xD8B7, 0x80E4, 0xD8B8, 0x9997,\r\n\t0xD8B9, 0x6BD3, 0xD8BA, 0x777E, 0xD8BB, 0x9F17, 0xD8BC, 0x4E36,\t0xD8BD, 0x4E9F, 0xD8BE, 0x9F10, 0xD8BF, 0x4E5C, 0xD8C0, 0x4E69,\r\n\t0xD8C1, 0x4E93, 0xD8C2, 0x8288, 0xD8C3, 0x5B5B, 0xD8C4, 0x556C,\t0xD8C5, 0x560F, 0xD8C6, 0x4EC4, 0xD8C7, 0x538D, 0xD8C8, 0x539D,\r\n\t0xD8C9, 0x53A3, 0xD8CA, 0x53A5, 0xD8CB, 0x53AE, 0xD8CC, 0x9765,\t0xD8CD, 0x8D5D, 0xD8CE, 0x531A, 0xD8CF, 0x53F5, 0xD8D0, 0x5326,\r\n\t0xD8D1, 0x532E, 0xD8D2, 0x533E, 0xD8D3, 0x8D5C, 0xD8D4, 0x5366,\t0xD8D5, 0x5363, 0xD8D6, 0x5202, 0xD8D7, 0x5208, 0xD8D8, 0x520E,\r\n\t0xD8D9, 0x522D, 0xD8DA, 0x5233, 0xD8DB, 0x523F, 0xD8DC, 0x5240,\t0xD8DD, 0x524C, 0xD8DE, 0x525E, 0xD8DF, 0x5261, 0xD8E0, 0x525C,\r\n\t0xD8E1, 0x84AF, 0xD8E2, 0x527D, 0xD8E3, 0x5282, 0xD8E4, 0x5281,\t0xD8E5, 0x5290, 0xD8E6, 0x5293, 0xD8E7, 0x5182, 0xD8E8, 0x7F54,\r\n\t0xD8E9, 0x4EBB, 0xD8EA, 0x4EC3, 0xD8EB, 0x4EC9, 0xD8EC, 0x4EC2,\t0xD8ED, 0x4EE8, 0xD8EE, 0x4EE1, 0xD8EF, 0x4EEB, 0xD8F0, 0x4EDE,\r\n\t0xD8F1, 0x4F1B, 0xD8F2, 0x4EF3, 0xD8F3, 0x4F22, 0xD8F4, 0x4F64,\t0xD8F5, 0x4EF5, 0xD8F6, 0x4F25, 0xD8F7, 0x4F27, 0xD8F8, 0x4F09,\r\n\t0xD8F9, 0x4F2B, 0xD8FA, 0x4F5E, 0xD8FB, 0x4F67, 0xD8FC, 0x6538,\t0xD8FD, 0x4F5A, 0xD8FE, 0x4F5D, 0xD940, 0x8CAE, 0xD941, 0x8CAF,\r\n\t0xD942, 0x8CB0, 0xD943, 0x8CB1, 0xD944, 0x8CB2, 0xD945, 0x8CB3,\t0xD946, 0x8CB4, 0xD947, 0x8CB5, 0xD948, 0x8CB6, 0xD949, 0x8CB7,\r\n\t0xD94A, 0x8CB8, 0xD94B, 0x8CB9, 0xD94C, 0x8CBA, 0xD94D, 0x8CBB,\t0xD94E, 0x8CBC, 0xD94F, 0x8CBD, 0xD950, 0x8CBE, 0xD951, 0x8CBF,\r\n\t0xD952, 0x8CC0, 0xD953, 0x8CC1, 0xD954, 0x8CC2, 0xD955, 0x8CC3,\t0xD956, 0x8CC4, 0xD957, 0x8CC5, 0xD958, 0x8CC6, 0xD959, 0x8CC7,\r\n\t0xD95A, 0x8CC8, 0xD95B, 0x8CC9, 0xD95C, 0x8CCA, 0xD95D, 0x8CCB,\t0xD95E, 0x8CCC, 0xD95F, 0x8CCD, 0xD960, 0x8CCE, 0xD961, 0x8CCF,\r\n\t0xD962, 0x8CD0, 0xD963, 0x8CD1, 0xD964, 0x8CD2, 0xD965, 0x8CD3,\t0xD966, 0x8CD4, 0xD967, 0x8CD5, 0xD968, 0x8CD6, 0xD969, 0x8CD7,\r\n\t0xD96A, 0x8CD8, 0xD96B, 0x8CD9, 0xD96C, 0x8CDA, 0xD96D, 0x8CDB,\t0xD96E, 0x8CDC, 0xD96F, 0x8CDD, 0xD970, 0x8CDE, 0xD971, 0x8CDF,\r\n\t0xD972, 0x8CE0, 0xD973, 0x8CE1, 0xD974, 0x8CE2, 0xD975, 0x8CE3,\t0xD976, 0x8CE4, 0xD977, 0x8CE5, 0xD978, 0x8CE6, 0xD979, 0x8CE7,\r\n\t0xD97A, 0x8CE8, 0xD97B, 0x8CE9, 0xD97C, 0x8CEA, 0xD97D, 0x8CEB,\t0xD97E, 0x8CEC, 0xD980, 0x8CED, 0xD981, 0x8CEE, 0xD982, 0x8CEF,\r\n\t0xD983, 0x8CF0, 0xD984, 0x8CF1, 0xD985, 0x8CF2, 0xD986, 0x8CF3,\t0xD987, 0x8CF4, 0xD988, 0x8CF5, 0xD989, 0x8CF6, 0xD98A, 0x8CF7,\r\n\t0xD98B, 0x8CF8, 0xD98C, 0x8CF9, 0xD98D, 0x8CFA, 0xD98E, 0x8CFB,\t0xD98F, 0x8CFC, 0xD990, 0x8CFD, 0xD991, 0x8CFE, 0xD992, 0x8CFF,\r\n\t0xD993, 0x8D00, 0xD994, 0x8D01, 0xD995, 0x8D02, 0xD996, 0x8D03,\t0xD997, 0x8D04, 0xD998, 0x8D05, 0xD999, 0x8D06, 0xD99A, 0x8D07,\r\n\t0xD99B, 0x8D08, 0xD99C, 0x8D09, 0xD99D, 0x8D0A, 0xD99E, 0x8D0B,\t0xD99F, 0x8D0C, 0xD9A0, 0x8D0D, 0xD9A1, 0x4F5F, 0xD9A2, 0x4F57,\r\n\t0xD9A3, 0x4F32, 0xD9A4, 0x4F3D, 0xD9A5, 0x4F76, 0xD9A6, 0x4F74,\t0xD9A7, 0x4F91, 0xD9A8, 0x4F89, 0xD9A9, 0x4F83, 0xD9AA, 0x4F8F,\r\n\t0xD9AB, 0x4F7E, 0xD9AC, 0x4F7B, 0xD9AD, 0x4FAA, 0xD9AE, 0x4F7C,\t0xD9AF, 0x4FAC, 0xD9B0, 0x4F94, 0xD9B1, 0x4FE6, 0xD9B2, 0x4FE8,\r\n\t0xD9B3, 0x4FEA, 0xD9B4, 0x4FC5, 0xD9B5, 0x4FDA, 0xD9B6, 0x4FE3,\t0xD9B7, 0x4FDC, 0xD9B8, 0x4FD1, 0xD9B9, 0x4FDF, 0xD9BA, 0x4FF8,\r\n\t0xD9BB, 0x5029, 0xD9BC, 0x504C, 0xD9BD, 0x4FF3, 0xD9BE, 0x502C,\t0xD9BF, 0x500F, 0xD9C0, 0x502E, 0xD9C1, 0x502D, 0xD9C2, 0x4FFE,\r\n\t0xD9C3, 0x501C, 0xD9C4, 0x500C, 0xD9C5, 0x5025, 0xD9C6, 0x5028,\t0xD9C7, 0x507E, 0xD9C8, 0x5043, 0xD9C9, 0x5055, 0xD9CA, 0x5048,\r\n\t0xD9CB, 0x504E, 0xD9CC, 0x506C, 0xD9CD, 0x507B, 0xD9CE, 0x50A5,\t0xD9CF, 0x50A7, 0xD9D0, 0x50A9, 0xD9D1, 0x50BA, 0xD9D2, 0x50D6,\r\n\t0xD9D3, 0x5106, 0xD9D4, 0x50ED, 0xD9D5, 0x50EC, 0xD9D6, 0x50E6,\t0xD9D7, 0x50EE, 0xD9D8, 0x5107, 0xD9D9, 0x510B, 0xD9DA, 0x4EDD,\r\n\t0xD9DB, 0x6C3D, 0xD9DC, 0x4F58, 0xD9DD, 0x4F65, 0xD9DE, 0x4FCE,\t0xD9DF, 0x9FA0, 0xD9E0, 0x6C46, 0xD9E1, 0x7C74, 0xD9E2, 0x516E,\r\n\t0xD9E3, 0x5DFD, 0xD9E4, 0x9EC9, 0xD9E5, 0x9998, 0xD9E6, 0x5181,\t0xD9E7, 0x5914, 0xD9E8, 0x52F9, 0xD9E9, 0x530D, 0xD9EA, 0x8A07,\r\n\t0xD9EB, 0x5310, 0xD9EC, 0x51EB, 0xD9ED, 0x5919, 0xD9EE, 0x5155,\t0xD9EF, 0x4EA0, 0xD9F0, 0x5156, 0xD9F1, 0x4EB3, 0xD9F2, 0x886E,\r\n\t0xD9F3, 0x88A4, 0xD9F4, 0x4EB5, 0xD9F5, 0x8114, 0xD9F6, 0x88D2,\t0xD9F7, 0x7980, 0xD9F8, 0x5B34, 0xD9F9, 0x8803, 0xD9FA, 0x7FB8,\r\n\t0xD9FB, 0x51AB, 0xD9FC, 0x51B1, 0xD9FD, 0x51BD, 0xD9FE, 0x51BC,\t0xDA40, 0x8D0E, 0xDA41, 0x8D0F, 0xDA42, 0x8D10, 0xDA43, 0x8D11,\r\n\t0xDA44, 0x8D12, 0xDA45, 0x8D13, 0xDA46, 0x8D14, 0xDA47, 0x8D15,\t0xDA48, 0x8D16, 0xDA49, 0x8D17, 0xDA4A, 0x8D18, 0xDA4B, 0x8D19,\r\n\t0xDA4C, 0x8D1A, 0xDA4D, 0x8D1B, 0xDA4E, 0x8D1C, 0xDA4F, 0x8D20,\t0xDA50, 0x8D51, 0xDA51, 0x8D52, 0xDA52, 0x8D57, 0xDA53, 0x8D5F,\r\n\t0xDA54, 0x8D65, 0xDA55, 0x8D68, 0xDA56, 0x8D69, 0xDA57, 0x8D6A,\t0xDA58, 0x8D6C, 0xDA59, 0x8D6E, 0xDA5A, 0x8D6F, 0xDA5B, 0x8D71,\r\n\t0xDA5C, 0x8D72, 0xDA5D, 0x8D78, 0xDA5E, 0x8D79, 0xDA5F, 0x8D7A,\t0xDA60, 0x8D7B, 0xDA61, 0x8D7C, 0xDA62, 0x8D7D, 0xDA63, 0x8D7E,\r\n\t0xDA64, 0x8D7F, 0xDA65, 0x8D80, 0xDA66, 0x8D82, 0xDA67, 0x8D83,\t0xDA68, 0x8D86, 0xDA69, 0x8D87, 0xDA6A, 0x8D88, 0xDA6B, 0x8D89,\r\n\t0xDA6C, 0x8D8C, 0xDA6D, 0x8D8D, 0xDA6E, 0x8D8E, 0xDA6F, 0x8D8F,\t0xDA70, 0x8D90, 0xDA71, 0x8D92, 0xDA72, 0x8D93, 0xDA73, 0x8D95,\r\n\t0xDA74, 0x8D96, 0xDA75, 0x8D97, 0xDA76, 0x8D98, 0xDA77, 0x8D99,\t0xDA78, 0x8D9A, 0xDA79, 0x8D9B, 0xDA7A, 0x8D9C, 0xDA7B, 0x8D9D,\r\n\t0xDA7C, 0x8D9E, 0xDA7D, 0x8DA0, 0xDA7E, 0x8DA1, 0xDA80, 0x8DA2,\t0xDA81, 0x8DA4, 0xDA82, 0x8DA5, 0xDA83, 0x8DA6, 0xDA84, 0x8DA7,\r\n\t0xDA85, 0x8DA8, 0xDA86, 0x8DA9, 0xDA87, 0x8DAA, 0xDA88, 0x8DAB,\t0xDA89, 0x8DAC, 0xDA8A, 0x8DAD, 0xDA8B, 0x8DAE, 0xDA8C, 0x8DAF,\r\n\t0xDA8D, 0x8DB0, 0xDA8E, 0x8DB2, 0xDA8F, 0x8DB6, 0xDA90, 0x8DB7,\t0xDA91, 0x8DB9, 0xDA92, 0x8DBB, 0xDA93, 0x8DBD, 0xDA94, 0x8DC0,\r\n\t0xDA95, 0x8DC1, 0xDA96, 0x8DC2, 0xDA97, 0x8DC5, 0xDA98, 0x8DC7,\t0xDA99, 0x8DC8, 0xDA9A, 0x8DC9, 0xDA9B, 0x8DCA, 0xDA9C, 0x8DCD,\r\n\t0xDA9D, 0x8DD0, 0xDA9E, 0x8DD2, 0xDA9F, 0x8DD3, 0xDAA0, 0x8DD4,\t0xDAA1, 0x51C7, 0xDAA2, 0x5196, 0xDAA3, 0x51A2, 0xDAA4, 0x51A5,\r\n\t0xDAA5, 0x8BA0, 0xDAA6, 0x8BA6, 0xDAA7, 0x8BA7, 0xDAA8, 0x8BAA,\t0xDAA9, 0x8BB4, 0xDAAA, 0x8BB5, 0xDAAB, 0x8BB7, 0xDAAC, 0x8BC2,\r\n\t0xDAAD, 0x8BC3, 0xDAAE, 0x8BCB, 0xDAAF, 0x8BCF, 0xDAB0, 0x8BCE,\t0xDAB1, 0x8BD2, 0xDAB2, 0x8BD3, 0xDAB3, 0x8BD4, 0xDAB4, 0x8BD6,\r\n\t0xDAB5, 0x8BD8, 0xDAB6, 0x8BD9, 0xDAB7, 0x8BDC, 0xDAB8, 0x8BDF,\t0xDAB9, 0x8BE0, 0xDABA, 0x8BE4, 0xDABB, 0x8BE8, 0xDABC, 0x8BE9,\r\n\t0xDABD, 0x8BEE, 0xDABE, 0x8BF0, 0xDABF, 0x8BF3, 0xDAC0, 0x8BF6,\t0xDAC1, 0x8BF9, 0xDAC2, 0x8BFC, 0xDAC3, 0x8BFF, 0xDAC4, 0x8C00,\r\n\t0xDAC5, 0x8C02, 0xDAC6, 0x8C04, 0xDAC7, 0x8C07, 0xDAC8, 0x8C0C,\t0xDAC9, 0x8C0F, 0xDACA, 0x8C11, 0xDACB, 0x8C12, 0xDACC, 0x8C14,\r\n\t0xDACD, 0x8C15, 0xDACE, 0x8C16, 0xDACF, 0x8C19, 0xDAD0, 0x8C1B,\t0xDAD1, 0x8C18, 0xDAD2, 0x8C1D, 0xDAD3, 0x8C1F, 0xDAD4, 0x8C20,\r\n\t0xDAD5, 0x8C21, 0xDAD6, 0x8C25, 0xDAD7, 0x8C27, 0xDAD8, 0x8C2A,\t0xDAD9, 0x8C2B, 0xDADA, 0x8C2E, 0xDADB, 0x8C2F, 0xDADC, 0x8C32,\r\n\t0xDADD, 0x8C33, 0xDADE, 0x8C35, 0xDADF, 0x8C36, 0xDAE0, 0x5369,\t0xDAE1, 0x537A, 0xDAE2, 0x961D, 0xDAE3, 0x9622, 0xDAE4, 0x9621,\r\n\t0xDAE5, 0x9631, 0xDAE6, 0x962A, 0xDAE7, 0x963D, 0xDAE8, 0x963C,\t0xDAE9, 0x9642, 0xDAEA, 0x9649, 0xDAEB, 0x9654, 0xDAEC, 0x965F,\r\n\t0xDAED, 0x9667, 0xDAEE, 0x966C, 0xDAEF, 0x9672, 0xDAF0, 0x9674,\t0xDAF1, 0x9688, 0xDAF2, 0x968D, 0xDAF3, 0x9697, 0xDAF4, 0x96B0,\r\n\t0xDAF5, 0x9097, 0xDAF6, 0x909B, 0xDAF7, 0x909D, 0xDAF8, 0x9099,\t0xDAF9, 0x90AC, 0xDAFA, 0x90A1, 0xDAFB, 0x90B4, 0xDAFC, 0x90B3,\r\n\t0xDAFD, 0x90B6, 0xDAFE, 0x90BA, 0xDB40, 0x8DD5, 0xDB41, 0x8DD8,\t0xDB42, 0x8DD9, 0xDB43, 0x8DDC, 0xDB44, 0x8DE0, 0xDB45, 0x8DE1,\r\n\t0xDB46, 0x8DE2, 0xDB47, 0x8DE5, 0xDB48, 0x8DE6, 0xDB49, 0x8DE7,\t0xDB4A, 0x8DE9, 0xDB4B, 0x8DED, 0xDB4C, 0x8DEE, 0xDB4D, 0x8DF0,\r\n\t0xDB4E, 0x8DF1, 0xDB4F, 0x8DF2, 0xDB50, 0x8DF4, 0xDB51, 0x8DF6,\t0xDB52, 0x8DFC, 0xDB53, 0x8DFE, 0xDB54, 0x8DFF, 0xDB55, 0x8E00,\r\n\t0xDB56, 0x8E01, 0xDB57, 0x8E02, 0xDB58, 0x8E03, 0xDB59, 0x8E04,\t0xDB5A, 0x8E06, 0xDB5B, 0x8E07, 0xDB5C, 0x8E08, 0xDB5D, 0x8E0B,\r\n\t0xDB5E, 0x8E0D, 0xDB5F, 0x8E0E, 0xDB60, 0x8E10, 0xDB61, 0x8E11,\t0xDB62, 0x8E12, 0xDB63, 0x8E13, 0xDB64, 0x8E15, 0xDB65, 0x8E16,\r\n\t0xDB66, 0x8E17, 0xDB67, 0x8E18, 0xDB68, 0x8E19, 0xDB69, 0x8E1A,\t0xDB6A, 0x8E1B, 0xDB6B, 0x8E1C, 0xDB6C, 0x8E20, 0xDB6D, 0x8E21,\r\n\t0xDB6E, 0x8E24, 0xDB6F, 0x8E25, 0xDB70, 0x8E26, 0xDB71, 0x8E27,\t0xDB72, 0x8E28, 0xDB73, 0x8E2B, 0xDB74, 0x8E2D, 0xDB75, 0x8E30,\r\n\t0xDB76, 0x8E32, 0xDB77, 0x8E33, 0xDB78, 0x8E34, 0xDB79, 0x8E36,\t0xDB7A, 0x8E37, 0xDB7B, 0x8E38, 0xDB7C, 0x8E3B, 0xDB7D, 0x8E3C,\r\n\t0xDB7E, 0x8E3E, 0xDB80, 0x8E3F, 0xDB81, 0x8E43, 0xDB82, 0x8E45,\t0xDB83, 0x8E46, 0xDB84, 0x8E4C, 0xDB85, 0x8E4D, 0xDB86, 0x8E4E,\r\n\t0xDB87, 0x8E4F, 0xDB88, 0x8E50, 0xDB89, 0x8E53, 0xDB8A, 0x8E54,\t0xDB8B, 0x8E55, 0xDB8C, 0x8E56, 0xDB8D, 0x8E57, 0xDB8E, 0x8E58,\r\n\t0xDB8F, 0x8E5A, 0xDB90, 0x8E5B, 0xDB91, 0x8E5C, 0xDB92, 0x8E5D,\t0xDB93, 0x8E5E, 0xDB94, 0x8E5F, 0xDB95, 0x8E60, 0xDB96, 0x8E61,\r\n\t0xDB97, 0x8E62, 0xDB98, 0x8E63, 0xDB99, 0x8E64, 0xDB9A, 0x8E65,\t0xDB9B, 0x8E67, 0xDB9C, 0x8E68, 0xDB9D, 0x8E6A, 0xDB9E, 0x8E6B,\r\n\t0xDB9F, 0x8E6E, 0xDBA0, 0x8E71, 0xDBA1, 0x90B8, 0xDBA2, 0x90B0,\t0xDBA3, 0x90CF, 0xDBA4, 0x90C5, 0xDBA5, 0x90BE, 0xDBA6, 0x90D0,\r\n\t0xDBA7, 0x90C4, 0xDBA8, 0x90C7, 0xDBA9, 0x90D3, 0xDBAA, 0x90E6,\t0xDBAB, 0x90E2, 0xDBAC, 0x90DC, 0xDBAD, 0x90D7, 0xDBAE, 0x90DB,\r\n\t0xDBAF, 0x90EB, 0xDBB0, 0x90EF, 0xDBB1, 0x90FE, 0xDBB2, 0x9104,\t0xDBB3, 0x9122, 0xDBB4, 0x911E, 0xDBB5, 0x9123, 0xDBB6, 0x9131,\r\n\t0xDBB7, 0x912F, 0xDBB8, 0x9139, 0xDBB9, 0x9143, 0xDBBA, 0x9146,\t0xDBBB, 0x520D, 0xDBBC, 0x5942, 0xDBBD, 0x52A2, 0xDBBE, 0x52AC,\r\n\t0xDBBF, 0x52AD, 0xDBC0, 0x52BE, 0xDBC1, 0x54FF, 0xDBC2, 0x52D0,\t0xDBC3, 0x52D6, 0xDBC4, 0x52F0, 0xDBC5, 0x53DF, 0xDBC6, 0x71EE,\r\n\t0xDBC7, 0x77CD, 0xDBC8, 0x5EF4, 0xDBC9, 0x51F5, 0xDBCA, 0x51FC,\t0xDBCB, 0x9B2F, 0xDBCC, 0x53B6, 0xDBCD, 0x5F01, 0xDBCE, 0x755A,\r\n\t0xDBCF, 0x5DEF, 0xDBD0, 0x574C, 0xDBD1, 0x57A9, 0xDBD2, 0x57A1,\t0xDBD3, 0x587E, 0xDBD4, 0x58BC, 0xDBD5, 0x58C5, 0xDBD6, 0x58D1,\r\n\t0xDBD7, 0x5729, 0xDBD8, 0x572C, 0xDBD9, 0x572A, 0xDBDA, 0x5733,\t0xDBDB, 0x5739, 0xDBDC, 0x572E, 0xDBDD, 0x572F, 0xDBDE, 0x575C,\r\n\t0xDBDF, 0x573B, 0xDBE0, 0x5742, 0xDBE1, 0x5769, 0xDBE2, 0x5785,\t0xDBE3, 0x576B, 0xDBE4, 0x5786, 0xDBE5, 0x577C, 0xDBE6, 0x577B,\r\n\t0xDBE7, 0x5768, 0xDBE8, 0x576D, 0xDBE9, 0x5776, 0xDBEA, 0x5773,\t0xDBEB, 0x57AD, 0xDBEC, 0x57A4, 0xDBED, 0x578C, 0xDBEE, 0x57B2,\r\n\t0xDBEF, 0x57CF, 0xDBF0, 0x57A7, 0xDBF1, 0x57B4, 0xDBF2, 0x5793,\t0xDBF3, 0x57A0, 0xDBF4, 0x57D5, 0xDBF5, 0x57D8, 0xDBF6, 0x57DA,\r\n\t0xDBF7, 0x57D9, 0xDBF8, 0x57D2, 0xDBF9, 0x57B8, 0xDBFA, 0x57F4,\t0xDBFB, 0x57EF, 0xDBFC, 0x57F8, 0xDBFD, 0x57E4, 0xDBFE, 0x57DD,\r\n\t0xDC40, 0x8E73, 0xDC41, 0x8E75, 0xDC42, 0x8E77, 0xDC43, 0x8E78,\t0xDC44, 0x8E79, 0xDC45, 0x8E7A, 0xDC46, 0x8E7B, 0xDC47, 0x8E7D,\r\n\t0xDC48, 0x8E7E, 0xDC49, 0x8E80, 0xDC4A, 0x8E82, 0xDC4B, 0x8E83,\t0xDC4C, 0x8E84, 0xDC4D, 0x8E86, 0xDC4E, 0x8E88, 0xDC4F, 0x8E89,\r\n\t0xDC50, 0x8E8A, 0xDC51, 0x8E8B, 0xDC52, 0x8E8C, 0xDC53, 0x8E8D,\t0xDC54, 0x8E8E, 0xDC55, 0x8E91, 0xDC56, 0x8E92, 0xDC57, 0x8E93,\r\n\t0xDC58, 0x8E95, 0xDC59, 0x8E96, 0xDC5A, 0x8E97, 0xDC5B, 0x8E98,\t0xDC5C, 0x8E99, 0xDC5D, 0x8E9A, 0xDC5E, 0x8E9B, 0xDC5F, 0x8E9D,\r\n\t0xDC60, 0x8E9F, 0xDC61, 0x8EA0, 0xDC62, 0x8EA1, 0xDC63, 0x8EA2,\t0xDC64, 0x8EA3, 0xDC65, 0x8EA4, 0xDC66, 0x8EA5, 0xDC67, 0x8EA6,\r\n\t0xDC68, 0x8EA7, 0xDC69, 0x8EA8, 0xDC6A, 0x8EA9, 0xDC6B, 0x8EAA,\t0xDC6C, 0x8EAD, 0xDC6D, 0x8EAE, 0xDC6E, 0x8EB0, 0xDC6F, 0x8EB1,\r\n\t0xDC70, 0x8EB3, 0xDC71, 0x8EB4, 0xDC72, 0x8EB5, 0xDC73, 0x8EB6,\t0xDC74, 0x8EB7, 0xDC75, 0x8EB8, 0xDC76, 0x8EB9, 0xDC77, 0x8EBB,\r\n\t0xDC78, 0x8EBC, 0xDC79, 0x8EBD, 0xDC7A, 0x8EBE, 0xDC7B, 0x8EBF,\t0xDC7C, 0x8EC0, 0xDC7D, 0x8EC1, 0xDC7E, 0x8EC2, 0xDC80, 0x8EC3,\r\n\t0xDC81, 0x8EC4, 0xDC82, 0x8EC5, 0xDC83, 0x8EC6, 0xDC84, 0x8EC7,\t0xDC85, 0x8EC8, 0xDC86, 0x8EC9, 0xDC87, 0x8ECA, 0xDC88, 0x8ECB,\r\n\t0xDC89, 0x8ECC, 0xDC8A, 0x8ECD, 0xDC8B, 0x8ECF, 0xDC8C, 0x8ED0,\t0xDC8D, 0x8ED1, 0xDC8E, 0x8ED2, 0xDC8F, 0x8ED3, 0xDC90, 0x8ED4,\r\n\t0xDC91, 0x8ED5, 0xDC92, 0x8ED6, 0xDC93, 0x8ED7, 0xDC94, 0x8ED8,\t0xDC95, 0x8ED9, 0xDC96, 0x8EDA, 0xDC97, 0x8EDB, 0xDC98, 0x8EDC,\r\n\t0xDC99, 0x8EDD, 0xDC9A, 0x8EDE, 0xDC9B, 0x8EDF, 0xDC9C, 0x8EE0,\t0xDC9D, 0x8EE1, 0xDC9E, 0x8EE2, 0xDC9F, 0x8EE3, 0xDCA0, 0x8EE4,\r\n\t0xDCA1, 0x580B, 0xDCA2, 0x580D, 0xDCA3, 0x57FD, 0xDCA4, 0x57ED,\t0xDCA5, 0x5800, 0xDCA6, 0x581E, 0xDCA7, 0x5819, 0xDCA8, 0x5844,\r\n\t0xDCA9, 0x5820, 0xDCAA, 0x5865, 0xDCAB, 0x586C, 0xDCAC, 0x5881,\t0xDCAD, 0x5889, 0xDCAE, 0x589A, 0xDCAF, 0x5880, 0xDCB0, 0x99A8,\r\n\t0xDCB1, 0x9F19, 0xDCB2, 0x61FF, 0xDCB3, 0x8279, 0xDCB4, 0x827D,\t0xDCB5, 0x827F, 0xDCB6, 0x828F, 0xDCB7, 0x828A, 0xDCB8, 0x82A8,\r\n\t0xDCB9, 0x8284, 0xDCBA, 0x828E, 0xDCBB, 0x8291, 0xDCBC, 0x8297,\t0xDCBD, 0x8299, 0xDCBE, 0x82AB, 0xDCBF, 0x82B8, 0xDCC0, 0x82BE,\r\n\t0xDCC1, 0x82B0, 0xDCC2, 0x82C8, 0xDCC3, 0x82CA, 0xDCC4, 0x82E3,\t0xDCC5, 0x8298, 0xDCC6, 0x82B7, 0xDCC7, 0x82AE, 0xDCC8, 0x82CB,\r\n\t0xDCC9, 0x82CC, 0xDCCA, 0x82C1, 0xDCCB, 0x82A9, 0xDCCC, 0x82B4,\t0xDCCD, 0x82A1, 0xDCCE, 0x82AA, 0xDCCF, 0x829F, 0xDCD0, 0x82C4,\r\n\t0xDCD1, 0x82CE, 0xDCD2, 0x82A4, 0xDCD3, 0x82E1, 0xDCD4, 0x8309,\t0xDCD5, 0x82F7, 0xDCD6, 0x82E4, 0xDCD7, 0x830F, 0xDCD8, 0x8307,\r\n\t0xDCD9, 0x82DC, 0xDCDA, 0x82F4, 0xDCDB, 0x82D2, 0xDCDC, 0x82D8,\t0xDCDD, 0x830C, 0xDCDE, 0x82FB, 0xDCDF, 0x82D3, 0xDCE0, 0x8311,\r\n\t0xDCE1, 0x831A, 0xDCE2, 0x8306, 0xDCE3, 0x8314, 0xDCE4, 0x8315,\t0xDCE5, 0x82E0, 0xDCE6, 0x82D5, 0xDCE7, 0x831C, 0xDCE8, 0x8351,\r\n\t0xDCE9, 0x835B, 0xDCEA, 0x835C, 0xDCEB, 0x8308, 0xDCEC, 0x8392,\t0xDCED, 0x833C, 0xDCEE, 0x8334, 0xDCEF, 0x8331, 0xDCF0, 0x839B,\r\n\t0xDCF1, 0x835E, 0xDCF2, 0x832F, 0xDCF3, 0x834F, 0xDCF4, 0x8347,\t0xDCF5, 0x8343, 0xDCF6, 0x835F, 0xDCF7, 0x8340, 0xDCF8, 0x8317,\r\n\t0xDCF9, 0x8360, 0xDCFA, 0x832D, 0xDCFB, 0x833A, 0xDCFC, 0x8333,\t0xDCFD, 0x8366, 0xDCFE, 0x8365, 0xDD40, 0x8EE5, 0xDD41, 0x8EE6,\r\n\t0xDD42, 0x8EE7, 0xDD43, 0x8EE8, 0xDD44, 0x8EE9, 0xDD45, 0x8EEA,\t0xDD46, 0x8EEB, 0xDD47, 0x8EEC, 0xDD48, 0x8EED, 0xDD49, 0x8EEE,\r\n\t0xDD4A, 0x8EEF, 0xDD4B, 0x8EF0, 0xDD4C, 0x8EF1, 0xDD4D, 0x8EF2,\t0xDD4E, 0x8EF3, 0xDD4F, 0x8EF4, 0xDD50, 0x8EF5, 0xDD51, 0x8EF6,\r\n\t0xDD52, 0x8EF7, 0xDD53, 0x8EF8, 0xDD54, 0x8EF9, 0xDD55, 0x8EFA,\t0xDD56, 0x8EFB, 0xDD57, 0x8EFC, 0xDD58, 0x8EFD, 0xDD59, 0x8EFE,\r\n\t0xDD5A, 0x8EFF, 0xDD5B, 0x8F00, 0xDD5C, 0x8F01, 0xDD5D, 0x8F02,\t0xDD5E, 0x8F03, 0xDD5F, 0x8F04, 0xDD60, 0x8F05, 0xDD61, 0x8F06,\r\n\t0xDD62, 0x8F07, 0xDD63, 0x8F08, 0xDD64, 0x8F09, 0xDD65, 0x8F0A,\t0xDD66, 0x8F0B, 0xDD67, 0x8F0C, 0xDD68, 0x8F0D, 0xDD69, 0x8F0E,\r\n\t0xDD6A, 0x8F0F, 0xDD6B, 0x8F10, 0xDD6C, 0x8F11, 0xDD6D, 0x8F12,\t0xDD6E, 0x8F13, 0xDD6F, 0x8F14, 0xDD70, 0x8F15, 0xDD71, 0x8F16,\r\n\t0xDD72, 0x8F17, 0xDD73, 0x8F18, 0xDD74, 0x8F19, 0xDD75, 0x8F1A,\t0xDD76, 0x8F1B, 0xDD77, 0x8F1C, 0xDD78, 0x8F1D, 0xDD79, 0x8F1E,\r\n\t0xDD7A, 0x8F1F, 0xDD7B, 0x8F20, 0xDD7C, 0x8F21, 0xDD7D, 0x8F22,\t0xDD7E, 0x8F23, 0xDD80, 0x8F24, 0xDD81, 0x8F25, 0xDD82, 0x8F26,\r\n\t0xDD83, 0x8F27, 0xDD84, 0x8F28, 0xDD85, 0x8F29, 0xDD86, 0x8F2A,\t0xDD87, 0x8F2B, 0xDD88, 0x8F2C, 0xDD89, 0x8F2D, 0xDD8A, 0x8F2E,\r\n\t0xDD8B, 0x8F2F, 0xDD8C, 0x8F30, 0xDD8D, 0x8F31, 0xDD8E, 0x8F32,\t0xDD8F, 0x8F33, 0xDD90, 0x8F34, 0xDD91, 0x8F35, 0xDD92, 0x8F36,\r\n\t0xDD93, 0x8F37, 0xDD94, 0x8F38, 0xDD95, 0x8F39, 0xDD96, 0x8F3A,\t0xDD97, 0x8F3B, 0xDD98, 0x8F3C, 0xDD99, 0x8F3D, 0xDD9A, 0x8F3E,\r\n\t0xDD9B, 0x8F3F, 0xDD9C, 0x8F40, 0xDD9D, 0x8F41, 0xDD9E, 0x8F42,\t0xDD9F, 0x8F43, 0xDDA0, 0x8F44, 0xDDA1, 0x8368, 0xDDA2, 0x831B,\r\n\t0xDDA3, 0x8369, 0xDDA4, 0x836C, 0xDDA5, 0x836A, 0xDDA6, 0x836D,\t0xDDA7, 0x836E, 0xDDA8, 0x83B0, 0xDDA9, 0x8378, 0xDDAA, 0x83B3,\r\n\t0xDDAB, 0x83B4, 0xDDAC, 0x83A0, 0xDDAD, 0x83AA, 0xDDAE, 0x8393,\t0xDDAF, 0x839C, 0xDDB0, 0x8385, 0xDDB1, 0x837C, 0xDDB2, 0x83B6,\r\n\t0xDDB3, 0x83A9, 0xDDB4, 0x837D, 0xDDB5, 0x83B8, 0xDDB6, 0x837B,\t0xDDB7, 0x8398, 0xDDB8, 0x839E, 0xDDB9, 0x83A8, 0xDDBA, 0x83BA,\r\n\t0xDDBB, 0x83BC, 0xDDBC, 0x83C1, 0xDDBD, 0x8401, 0xDDBE, 0x83E5,\t0xDDBF, 0x83D8, 0xDDC0, 0x5807, 0xDDC1, 0x8418, 0xDDC2, 0x840B,\r\n\t0xDDC3, 0x83DD, 0xDDC4, 0x83FD, 0xDDC5, 0x83D6, 0xDDC6, 0x841C,\t0xDDC7, 0x8438, 0xDDC8, 0x8411, 0xDDC9, 0x8406, 0xDDCA, 0x83D4,\r\n\t0xDDCB, 0x83DF, 0xDDCC, 0x840F, 0xDDCD, 0x8403, 0xDDCE, 0x83F8,\t0xDDCF, 0x83F9, 0xDDD0, 0x83EA, 0xDDD1, 0x83C5, 0xDDD2, 0x83C0,\r\n\t0xDDD3, 0x8426, 0xDDD4, 0x83F0, 0xDDD5, 0x83E1, 0xDDD6, 0x845C,\t0xDDD7, 0x8451, 0xDDD8, 0x845A, 0xDDD9, 0x8459, 0xDDDA, 0x8473,\r\n\t0xDDDB, 0x8487, 0xDDDC, 0x8488, 0xDDDD, 0x847A, 0xDDDE, 0x8489,\t0xDDDF, 0x8478, 0xDDE0, 0x843C, 0xDDE1, 0x8446, 0xDDE2, 0x8469,\r\n\t0xDDE3, 0x8476, 0xDDE4, 0x848C, 0xDDE5, 0x848E, 0xDDE6, 0x8431,\t0xDDE7, 0x846D, 0xDDE8, 0x84C1, 0xDDE9, 0x84CD, 0xDDEA, 0x84D0,\r\n\t0xDDEB, 0x84E6, 0xDDEC, 0x84BD, 0xDDED, 0x84D3, 0xDDEE, 0x84CA,\t0xDDEF, 0x84BF, 0xDDF0, 0x84BA, 0xDDF1, 0x84E0, 0xDDF2, 0x84A1,\r\n\t0xDDF3, 0x84B9, 0xDDF4, 0x84B4, 0xDDF5, 0x8497, 0xDDF6, 0x84E5,\t0xDDF7, 0x84E3, 0xDDF8, 0x850C, 0xDDF9, 0x750D, 0xDDFA, 0x8538,\r\n\t0xDDFB, 0x84F0, 0xDDFC, 0x8539, 0xDDFD, 0x851F, 0xDDFE, 0x853A,\t0xDE40, 0x8F45, 0xDE41, 0x8F46, 0xDE42, 0x8F47, 0xDE43, 0x8F48,\r\n\t0xDE44, 0x8F49, 0xDE45, 0x8F4A, 0xDE46, 0x8F4B, 0xDE47, 0x8F4C,\t0xDE48, 0x8F4D, 0xDE49, 0x8F4E, 0xDE4A, 0x8F4F, 0xDE4B, 0x8F50,\r\n\t0xDE4C, 0x8F51, 0xDE4D, 0x8F52, 0xDE4E, 0x8F53, 0xDE4F, 0x8F54,\t0xDE50, 0x8F55, 0xDE51, 0x8F56, 0xDE52, 0x8F57, 0xDE53, 0x8F58,\r\n\t0xDE54, 0x8F59, 0xDE55, 0x8F5A, 0xDE56, 0x8F5B, 0xDE57, 0x8F5C,\t0xDE58, 0x8F5D, 0xDE59, 0x8F5E, 0xDE5A, 0x8F5F, 0xDE5B, 0x8F60,\r\n\t0xDE5C, 0x8F61, 0xDE5D, 0x8F62, 0xDE5E, 0x8F63, 0xDE5F, 0x8F64,\t0xDE60, 0x8F65, 0xDE61, 0x8F6A, 0xDE62, 0x8F80, 0xDE63, 0x8F8C,\r\n\t0xDE64, 0x8F92, 0xDE65, 0x8F9D, 0xDE66, 0x8FA0, 0xDE67, 0x8FA1,\t0xDE68, 0x8FA2, 0xDE69, 0x8FA4, 0xDE6A, 0x8FA5, 0xDE6B, 0x8FA6,\r\n\t0xDE6C, 0x8FA7, 0xDE6D, 0x8FAA, 0xDE6E, 0x8FAC, 0xDE6F, 0x8FAD,\t0xDE70, 0x8FAE, 0xDE71, 0x8FAF, 0xDE72, 0x8FB2, 0xDE73, 0x8FB3,\r\n\t0xDE74, 0x8FB4, 0xDE75, 0x8FB5, 0xDE76, 0x8FB7, 0xDE77, 0x8FB8,\t0xDE78, 0x8FBA, 0xDE79, 0x8FBB, 0xDE7A, 0x8FBC, 0xDE7B, 0x8FBF,\r\n\t0xDE7C, 0x8FC0, 0xDE7D, 0x8FC3, 0xDE7E, 0x8FC6, 0xDE80, 0x8FC9,\t0xDE81, 0x8FCA, 0xDE82, 0x8FCB, 0xDE83, 0x8FCC, 0xDE84, 0x8FCD,\r\n\t0xDE85, 0x8FCF, 0xDE86, 0x8FD2, 0xDE87, 0x8FD6, 0xDE88, 0x8FD7,\t0xDE89, 0x8FDA, 0xDE8A, 0x8FE0, 0xDE8B, 0x8FE1, 0xDE8C, 0x8FE3,\r\n\t0xDE8D, 0x8FE7, 0xDE8E, 0x8FEC, 0xDE8F, 0x8FEF, 0xDE90, 0x8FF1,\t0xDE91, 0x8FF2, 0xDE92, 0x8FF4, 0xDE93, 0x8FF5, 0xDE94, 0x8FF6,\r\n\t0xDE95, 0x8FFA, 0xDE96, 0x8FFB, 0xDE97, 0x8FFC, 0xDE98, 0x8FFE,\t0xDE99, 0x8FFF, 0xDE9A, 0x9007, 0xDE9B, 0x9008, 0xDE9C, 0x900C,\r\n\t0xDE9D, 0x900E, 0xDE9E, 0x9013, 0xDE9F, 0x9015, 0xDEA0, 0x9018,\t0xDEA1, 0x8556, 0xDEA2, 0x853B, 0xDEA3, 0x84FF, 0xDEA4, 0x84FC,\r\n\t0xDEA5, 0x8559, 0xDEA6, 0x8548, 0xDEA7, 0x8568, 0xDEA8, 0x8564,\t0xDEA9, 0x855E, 0xDEAA, 0x857A, 0xDEAB, 0x77A2, 0xDEAC, 0x8543,\r\n\t0xDEAD, 0x8572, 0xDEAE, 0x857B, 0xDEAF, 0x85A4, 0xDEB0, 0x85A8,\t0xDEB1, 0x8587, 0xDEB2, 0x858F, 0xDEB3, 0x8579, 0xDEB4, 0x85AE,\r\n\t0xDEB5, 0x859C, 0xDEB6, 0x8585, 0xDEB7, 0x85B9, 0xDEB8, 0x85B7,\t0xDEB9, 0x85B0, 0xDEBA, 0x85D3, 0xDEBB, 0x85C1, 0xDEBC, 0x85DC,\r\n\t0xDEBD, 0x85FF, 0xDEBE, 0x8627, 0xDEBF, 0x8605, 0xDEC0, 0x8629,\t0xDEC1, 0x8616, 0xDEC2, 0x863C, 0xDEC3, 0x5EFE, 0xDEC4, 0x5F08,\r\n\t0xDEC5, 0x593C, 0xDEC6, 0x5941, 0xDEC7, 0x8037, 0xDEC8, 0x5955,\t0xDEC9, 0x595A, 0xDECA, 0x5958, 0xDECB, 0x530F, 0xDECC, 0x5C22,\r\n\t0xDECD, 0x5C25, 0xDECE, 0x5C2C, 0xDECF, 0x5C34, 0xDED0, 0x624C,\t0xDED1, 0x626A, 0xDED2, 0x629F, 0xDED3, 0x62BB, 0xDED4, 0x62CA,\r\n\t0xDED5, 0x62DA, 0xDED6, 0x62D7, 0xDED7, 0x62EE, 0xDED8, 0x6322,\t0xDED9, 0x62F6, 0xDEDA, 0x6339, 0xDEDB, 0x634B, 0xDEDC, 0x6343,\r\n\t0xDEDD, 0x63AD, 0xDEDE, 0x63F6, 0xDEDF, 0x6371, 0xDEE0, 0x637A,\t0xDEE1, 0x638E, 0xDEE2, 0x63B4, 0xDEE3, 0x636D, 0xDEE4, 0x63AC,\r\n\t0xDEE5, 0x638A, 0xDEE6, 0x6369, 0xDEE7, 0x63AE, 0xDEE8, 0x63BC,\t0xDEE9, 0x63F2, 0xDEEA, 0x63F8, 0xDEEB, 0x63E0, 0xDEEC, 0x63FF,\r\n\t0xDEED, 0x63C4, 0xDEEE, 0x63DE, 0xDEEF, 0x63CE, 0xDEF0, 0x6452,\t0xDEF1, 0x63C6, 0xDEF2, 0x63BE, 0xDEF3, 0x6445, 0xDEF4, 0x6441,\r\n\t0xDEF5, 0x640B, 0xDEF6, 0x641B, 0xDEF7, 0x6420, 0xDEF8, 0x640C,\t0xDEF9, 0x6426, 0xDEFA, 0x6421, 0xDEFB, 0x645E, 0xDEFC, 0x6484,\r\n\t0xDEFD, 0x646D, 0xDEFE, 0x6496, 0xDF40, 0x9019, 0xDF41, 0x901C,\t0xDF42, 0x9023, 0xDF43, 0x9024, 0xDF44, 0x9025, 0xDF45, 0x9027,\r\n\t0xDF46, 0x9028, 0xDF47, 0x9029, 0xDF48, 0x902A, 0xDF49, 0x902B,\t0xDF4A, 0x902C, 0xDF4B, 0x9030, 0xDF4C, 0x9031, 0xDF4D, 0x9032,\r\n\t0xDF4E, 0x9033, 0xDF4F, 0x9034, 0xDF50, 0x9037, 0xDF51, 0x9039,\t0xDF52, 0x903A, 0xDF53, 0x903D, 0xDF54, 0x903F, 0xDF55, 0x9040,\r\n\t0xDF56, 0x9043, 0xDF57, 0x9045, 0xDF58, 0x9046, 0xDF59, 0x9048,\t0xDF5A, 0x9049, 0xDF5B, 0x904A, 0xDF5C, 0x904B, 0xDF5D, 0x904C,\r\n\t0xDF5E, 0x904E, 0xDF5F, 0x9054, 0xDF60, 0x9055, 0xDF61, 0x9056,\t0xDF62, 0x9059, 0xDF63, 0x905A, 0xDF64, 0x905C, 0xDF65, 0x905D,\r\n\t0xDF66, 0x905E, 0xDF67, 0x905F, 0xDF68, 0x9060, 0xDF69, 0x9061,\t0xDF6A, 0x9064, 0xDF6B, 0x9066, 0xDF6C, 0x9067, 0xDF6D, 0x9069,\r\n\t0xDF6E, 0x906A, 0xDF6F, 0x906B, 0xDF70, 0x906C, 0xDF71, 0x906F,\t0xDF72, 0x9070, 0xDF73, 0x9071, 0xDF74, 0x9072, 0xDF75, 0x9073,\r\n\t0xDF76, 0x9076, 0xDF77, 0x9077, 0xDF78, 0x9078, 0xDF79, 0x9079,\t0xDF7A, 0x907A, 0xDF7B, 0x907B, 0xDF7C, 0x907C, 0xDF7D, 0x907E,\r\n\t0xDF7E, 0x9081, 0xDF80, 0x9084, 0xDF81, 0x9085, 0xDF82, 0x9086,\t0xDF83, 0x9087, 0xDF84, 0x9089, 0xDF85, 0x908A, 0xDF86, 0x908C,\r\n\t0xDF87, 0x908D, 0xDF88, 0x908E, 0xDF89, 0x908F, 0xDF8A, 0x9090,\t0xDF8B, 0x9092, 0xDF8C, 0x9094, 0xDF8D, 0x9096, 0xDF8E, 0x9098,\r\n\t0xDF8F, 0x909A, 0xDF90, 0x909C, 0xDF91, 0x909E, 0xDF92, 0x909F,\t0xDF93, 0x90A0, 0xDF94, 0x90A4, 0xDF95, 0x90A5, 0xDF96, 0x90A7,\r\n\t0xDF97, 0x90A8, 0xDF98, 0x90A9, 0xDF99, 0x90AB, 0xDF9A, 0x90AD,\t0xDF9B, 0x90B2, 0xDF9C, 0x90B7, 0xDF9D, 0x90BC, 0xDF9E, 0x90BD,\r\n\t0xDF9F, 0x90BF, 0xDFA0, 0x90C0, 0xDFA1, 0x647A, 0xDFA2, 0x64B7,\t0xDFA3, 0x64B8, 0xDFA4, 0x6499, 0xDFA5, 0x64BA, 0xDFA6, 0x64C0,\r\n\t0xDFA7, 0x64D0, 0xDFA8, 0x64D7, 0xDFA9, 0x64E4, 0xDFAA, 0x64E2,\t0xDFAB, 0x6509, 0xDFAC, 0x6525, 0xDFAD, 0x652E, 0xDFAE, 0x5F0B,\r\n\t0xDFAF, 0x5FD2, 0xDFB0, 0x7519, 0xDFB1, 0x5F11, 0xDFB2, 0x535F,\t0xDFB3, 0x53F1, 0xDFB4, 0x53FD, 0xDFB5, 0x53E9, 0xDFB6, 0x53E8,\r\n\t0xDFB7, 0x53FB, 0xDFB8, 0x5412, 0xDFB9, 0x5416, 0xDFBA, 0x5406,\t0xDFBB, 0x544B, 0xDFBC, 0x5452, 0xDFBD, 0x5453, 0xDFBE, 0x5454,\r\n\t0xDFBF, 0x5456, 0xDFC0, 0x5443, 0xDFC1, 0x5421, 0xDFC2, 0x5457,\t0xDFC3, 0x5459, 0xDFC4, 0x5423, 0xDFC5, 0x5432, 0xDFC6, 0x5482,\r\n\t0xDFC7, 0x5494, 0xDFC8, 0x5477, 0xDFC9, 0x5471, 0xDFCA, 0x5464,\t0xDFCB, 0x549A, 0xDFCC, 0x549B, 0xDFCD, 0x5484, 0xDFCE, 0x5476,\r\n\t0xDFCF, 0x5466, 0xDFD0, 0x549D, 0xDFD1, 0x54D0, 0xDFD2, 0x54AD,\t0xDFD3, 0x54C2, 0xDFD4, 0x54B4, 0xDFD5, 0x54D2, 0xDFD6, 0x54A7,\r\n\t0xDFD7, 0x54A6, 0xDFD8, 0x54D3, 0xDFD9, 0x54D4, 0xDFDA, 0x5472,\t0xDFDB, 0x54A3, 0xDFDC, 0x54D5, 0xDFDD, 0x54BB, 0xDFDE, 0x54BF,\r\n\t0xDFDF, 0x54CC, 0xDFE0, 0x54D9, 0xDFE1, 0x54DA, 0xDFE2, 0x54DC,\t0xDFE3, 0x54A9, 0xDFE4, 0x54AA, 0xDFE5, 0x54A4, 0xDFE6, 0x54DD,\r\n\t0xDFE7, 0x54CF, 0xDFE8, 0x54DE, 0xDFE9, 0x551B, 0xDFEA, 0x54E7,\t0xDFEB, 0x5520, 0xDFEC, 0x54FD, 0xDFED, 0x5514, 0xDFEE, 0x54F3,\r\n\t0xDFEF, 0x5522, 0xDFF0, 0x5523, 0xDFF1, 0x550F, 0xDFF2, 0x5511,\t0xDFF3, 0x5527, 0xDFF4, 0x552A, 0xDFF5, 0x5567, 0xDFF6, 0x558F,\r\n\t0xDFF7, 0x55B5, 0xDFF8, 0x5549, 0xDFF9, 0x556D, 0xDFFA, 0x5541,\t0xDFFB, 0x5555, 0xDFFC, 0x553F, 0xDFFD, 0x5550, 0xDFFE, 0x553C,\r\n\t0xE040, 0x90C2, 0xE041, 0x90C3, 0xE042, 0x90C6, 0xE043, 0x90C8,\t0xE044, 0x90C9, 0xE045, 0x90CB, 0xE046, 0x90CC, 0xE047, 0x90CD,\r\n\t0xE048, 0x90D2, 0xE049, 0x90D4, 0xE04A, 0x90D5, 0xE04B, 0x90D6,\t0xE04C, 0x90D8, 0xE04D, 0x90D9, 0xE04E, 0x90DA, 0xE04F, 0x90DE,\r\n\t0xE050, 0x90DF, 0xE051, 0x90E0, 0xE052, 0x90E3, 0xE053, 0x90E4,\t0xE054, 0x90E5, 0xE055, 0x90E9, 0xE056, 0x90EA, 0xE057, 0x90EC,\r\n\t0xE058, 0x90EE, 0xE059, 0x90F0, 0xE05A, 0x90F1, 0xE05B, 0x90F2,\t0xE05C, 0x90F3, 0xE05D, 0x90F5, 0xE05E, 0x90F6, 0xE05F, 0x90F7,\r\n\t0xE060, 0x90F9, 0xE061, 0x90FA, 0xE062, 0x90FB, 0xE063, 0x90FC,\t0xE064, 0x90FF, 0xE065, 0x9100, 0xE066, 0x9101, 0xE067, 0x9103,\r\n\t0xE068, 0x9105, 0xE069, 0x9106, 0xE06A, 0x9107, 0xE06B, 0x9108,\t0xE06C, 0x9109, 0xE06D, 0x910A, 0xE06E, 0x910B, 0xE06F, 0x910C,\r\n\t0xE070, 0x910D, 0xE071, 0x910E, 0xE072, 0x910F, 0xE073, 0x9110,\t0xE074, 0x9111, 0xE075, 0x9112, 0xE076, 0x9113, 0xE077, 0x9114,\r\n\t0xE078, 0x9115, 0xE079, 0x9116, 0xE07A, 0x9117, 0xE07B, 0x9118,\t0xE07C, 0x911A, 0xE07D, 0x911B, 0xE07E, 0x911C, 0xE080, 0x911D,\r\n\t0xE081, 0x911F, 0xE082, 0x9120, 0xE083, 0x9121, 0xE084, 0x9124,\t0xE085, 0x9125, 0xE086, 0x9126, 0xE087, 0x9127, 0xE088, 0x9128,\r\n\t0xE089, 0x9129, 0xE08A, 0x912A, 0xE08B, 0x912B, 0xE08C, 0x912C,\t0xE08D, 0x912D, 0xE08E, 0x912E, 0xE08F, 0x9130, 0xE090, 0x9132,\r\n\t0xE091, 0x9133, 0xE092, 0x9134, 0xE093, 0x9135, 0xE094, 0x9136,\t0xE095, 0x9137, 0xE096, 0x9138, 0xE097, 0x913A, 0xE098, 0x913B,\r\n\t0xE099, 0x913C, 0xE09A, 0x913D, 0xE09B, 0x913E, 0xE09C, 0x913F,\t0xE09D, 0x9140, 0xE09E, 0x9141, 0xE09F, 0x9142, 0xE0A0, 0x9144,\r\n\t0xE0A1, 0x5537, 0xE0A2, 0x5556, 0xE0A3, 0x5575, 0xE0A4, 0x5576,\t0xE0A5, 0x5577, 0xE0A6, 0x5533, 0xE0A7, 0x5530, 0xE0A8, 0x555C,\r\n\t0xE0A9, 0x558B, 0xE0AA, 0x55D2, 0xE0AB, 0x5583, 0xE0AC, 0x55B1,\t0xE0AD, 0x55B9, 0xE0AE, 0x5588, 0xE0AF, 0x5581, 0xE0B0, 0x559F,\r\n\t0xE0B1, 0x557E, 0xE0B2, 0x55D6, 0xE0B3, 0x5591, 0xE0B4, 0x557B,\t0xE0B5, 0x55DF, 0xE0B6, 0x55BD, 0xE0B7, 0x55BE, 0xE0B8, 0x5594,\r\n\t0xE0B9, 0x5599, 0xE0BA, 0x55EA, 0xE0BB, 0x55F7, 0xE0BC, 0x55C9,\t0xE0BD, 0x561F, 0xE0BE, 0x55D1, 0xE0BF, 0x55EB, 0xE0C0, 0x55EC,\r\n\t0xE0C1, 0x55D4, 0xE0C2, 0x55E6, 0xE0C3, 0x55DD, 0xE0C4, 0x55C4,\t0xE0C5, 0x55EF, 0xE0C6, 0x55E5, 0xE0C7, 0x55F2, 0xE0C8, 0x55F3,\r\n\t0xE0C9, 0x55CC, 0xE0CA, 0x55CD, 0xE0CB, 0x55E8, 0xE0CC, 0x55F5,\t0xE0CD, 0x55E4, 0xE0CE, 0x8F94, 0xE0CF, 0x561E, 0xE0D0, 0x5608,\r\n\t0xE0D1, 0x560C, 0xE0D2, 0x5601, 0xE0D3, 0x5624, 0xE0D4, 0x5623,\t0xE0D5, 0x55FE, 0xE0D6, 0x5600, 0xE0D7, 0x5627, 0xE0D8, 0x562D,\r\n\t0xE0D9, 0x5658, 0xE0DA, 0x5639, 0xE0DB, 0x5657, 0xE0DC, 0x562C,\t0xE0DD, 0x564D, 0xE0DE, 0x5662, 0xE0DF, 0x5659, 0xE0E0, 0x565C,\r\n\t0xE0E1, 0x564C, 0xE0E2, 0x5654, 0xE0E3, 0x5686, 0xE0E4, 0x5664,\t0xE0E5, 0x5671, 0xE0E6, 0x566B, 0xE0E7, 0x567B, 0xE0E8, 0x567C,\r\n\t0xE0E9, 0x5685, 0xE0EA, 0x5693, 0xE0EB, 0x56AF, 0xE0EC, 0x56D4,\t0xE0ED, 0x56D7, 0xE0EE, 0x56DD, 0xE0EF, 0x56E1, 0xE0F0, 0x56F5,\r\n\t0xE0F1, 0x56EB, 0xE0F2, 0x56F9, 0xE0F3, 0x56FF, 0xE0F4, 0x5704,\t0xE0F5, 0x570A, 0xE0F6, 0x5709, 0xE0F7, 0x571C, 0xE0F8, 0x5E0F,\r\n\t0xE0F9, 0x5E19, 0xE0FA, 0x5E14, 0xE0FB, 0x5E11, 0xE0FC, 0x5E31,\t0xE0FD, 0x5E3B, 0xE0FE, 0x5E3C, 0xE140, 0x9145, 0xE141, 0x9147,\r\n\t0xE142, 0x9148, 0xE143, 0x9151, 0xE144, 0x9153, 0xE145, 0x9154,\t0xE146, 0x9155, 0xE147, 0x9156, 0xE148, 0x9158, 0xE149, 0x9159,\r\n\t0xE14A, 0x915B, 0xE14B, 0x915C, 0xE14C, 0x915F, 0xE14D, 0x9160,\t0xE14E, 0x9166, 0xE14F, 0x9167, 0xE150, 0x9168, 0xE151, 0x916B,\r\n\t0xE152, 0x916D, 0xE153, 0x9173, 0xE154, 0x917A, 0xE155, 0x917B,\t0xE156, 0x917C, 0xE157, 0x9180, 0xE158, 0x9181, 0xE159, 0x9182,\r\n\t0xE15A, 0x9183, 0xE15B, 0x9184, 0xE15C, 0x9186, 0xE15D, 0x9188,\t0xE15E, 0x918A, 0xE15F, 0x918E, 0xE160, 0x918F, 0xE161, 0x9193,\r\n\t0xE162, 0x9194, 0xE163, 0x9195, 0xE164, 0x9196, 0xE165, 0x9197,\t0xE166, 0x9198, 0xE167, 0x9199, 0xE168, 0x919C, 0xE169, 0x919D,\r\n\t0xE16A, 0x919E, 0xE16B, 0x919F, 0xE16C, 0x91A0, 0xE16D, 0x91A1,\t0xE16E, 0x91A4, 0xE16F, 0x91A5, 0xE170, 0x91A6, 0xE171, 0x91A7,\r\n\t0xE172, 0x91A8, 0xE173, 0x91A9, 0xE174, 0x91AB, 0xE175, 0x91AC,\t0xE176, 0x91B0, 0xE177, 0x91B1, 0xE178, 0x91B2, 0xE179, 0x91B3,\r\n\t0xE17A, 0x91B6, 0xE17B, 0x91B7, 0xE17C, 0x91B8, 0xE17D, 0x91B9,\t0xE17E, 0x91BB, 0xE180, 0x91BC, 0xE181, 0x91BD, 0xE182, 0x91BE,\r\n\t0xE183, 0x91BF, 0xE184, 0x91C0, 0xE185, 0x91C1, 0xE186, 0x91C2,\t0xE187, 0x91C3, 0xE188, 0x91C4, 0xE189, 0x91C5, 0xE18A, 0x91C6,\r\n\t0xE18B, 0x91C8, 0xE18C, 0x91CB, 0xE18D, 0x91D0, 0xE18E, 0x91D2,\t0xE18F, 0x91D3, 0xE190, 0x91D4, 0xE191, 0x91D5, 0xE192, 0x91D6,\r\n\t0xE193, 0x91D7, 0xE194, 0x91D8, 0xE195, 0x91D9, 0xE196, 0x91DA,\t0xE197, 0x91DB, 0xE198, 0x91DD, 0xE199, 0x91DE, 0xE19A, 0x91DF,\r\n\t0xE19B, 0x91E0, 0xE19C, 0x91E1, 0xE19D, 0x91E2, 0xE19E, 0x91E3,\t0xE19F, 0x91E4, 0xE1A0, 0x91E5, 0xE1A1, 0x5E37, 0xE1A2, 0x5E44,\r\n\t0xE1A3, 0x5E54, 0xE1A4, 0x5E5B, 0xE1A5, 0x5E5E, 0xE1A6, 0x5E61,\t0xE1A7, 0x5C8C, 0xE1A8, 0x5C7A, 0xE1A9, 0x5C8D, 0xE1AA, 0x5C90,\r\n\t0xE1AB, 0x5C96, 0xE1AC, 0x5C88, 0xE1AD, 0x5C98, 0xE1AE, 0x5C99,\t0xE1AF, 0x5C91, 0xE1B0, 0x5C9A, 0xE1B1, 0x5C9C, 0xE1B2, 0x5CB5,\r\n\t0xE1B3, 0x5CA2, 0xE1B4, 0x5CBD, 0xE1B5, 0x5CAC, 0xE1B6, 0x5CAB,\t0xE1B7, 0x5CB1, 0xE1B8, 0x5CA3, 0xE1B9, 0x5CC1, 0xE1BA, 0x5CB7,\r\n\t0xE1BB, 0x5CC4, 0xE1BC, 0x5CD2, 0xE1BD, 0x5CE4, 0xE1BE, 0x5CCB,\t0xE1BF, 0x5CE5, 0xE1C0, 0x5D02, 0xE1C1, 0x5D03, 0xE1C2, 0x5D27,\r\n\t0xE1C3, 0x5D26, 0xE1C4, 0x5D2E, 0xE1C5, 0x5D24, 0xE1C6, 0x5D1E,\t0xE1C7, 0x5D06, 0xE1C8, 0x5D1B, 0xE1C9, 0x5D58, 0xE1CA, 0x5D3E,\r\n\t0xE1CB, 0x5D34, 0xE1CC, 0x5D3D, 0xE1CD, 0x5D6C, 0xE1CE, 0x5D5B,\t0xE1CF, 0x5D6F, 0xE1D0, 0x5D5D, 0xE1D1, 0x5D6B, 0xE1D2, 0x5D4B,\r\n\t0xE1D3, 0x5D4A, 0xE1D4, 0x5D69, 0xE1D5, 0x5D74, 0xE1D6, 0x5D82,\t0xE1D7, 0x5D99, 0xE1D8, 0x5D9D, 0xE1D9, 0x8C73, 0xE1DA, 0x5DB7,\r\n\t0xE1DB, 0x5DC5, 0xE1DC, 0x5F73, 0xE1DD, 0x5F77, 0xE1DE, 0x5F82,\t0xE1DF, 0x5F87, 0xE1E0, 0x5F89, 0xE1E1, 0x5F8C, 0xE1E2, 0x5F95,\r\n\t0xE1E3, 0x5F99, 0xE1E4, 0x5F9C, 0xE1E5, 0x5FA8, 0xE1E6, 0x5FAD,\t0xE1E7, 0x5FB5, 0xE1E8, 0x5FBC, 0xE1E9, 0x8862, 0xE1EA, 0x5F61,\r\n\t0xE1EB, 0x72AD, 0xE1EC, 0x72B0, 0xE1ED, 0x72B4, 0xE1EE, 0x72B7,\t0xE1EF, 0x72B8, 0xE1F0, 0x72C3, 0xE1F1, 0x72C1, 0xE1F2, 0x72CE,\r\n\t0xE1F3, 0x72CD, 0xE1F4, 0x72D2, 0xE1F5, 0x72E8, 0xE1F6, 0x72EF,\t0xE1F7, 0x72E9, 0xE1F8, 0x72F2, 0xE1F9, 0x72F4, 0xE1FA, 0x72F7,\r\n\t0xE1FB, 0x7301, 0xE1FC, 0x72F3, 0xE1FD, 0x7303, 0xE1FE, 0x72FA,\t0xE240, 0x91E6, 0xE241, 0x91E7, 0xE242, 0x91E8, 0xE243, 0x91E9,\r\n\t0xE244, 0x91EA, 0xE245, 0x91EB, 0xE246, 0x91EC, 0xE247, 0x91ED,\t0xE248, 0x91EE, 0xE249, 0x91EF, 0xE24A, 0x91F0, 0xE24B, 0x91F1,\r\n\t0xE24C, 0x91F2, 0xE24D, 0x91F3, 0xE24E, 0x91F4, 0xE24F, 0x91F5,\t0xE250, 0x91F6, 0xE251, 0x91F7, 0xE252, 0x91F8, 0xE253, 0x91F9,\r\n\t0xE254, 0x91FA, 0xE255, 0x91FB, 0xE256, 0x91FC, 0xE257, 0x91FD,\t0xE258, 0x91FE, 0xE259, 0x91FF, 0xE25A, 0x9200, 0xE25B, 0x9201,\r\n\t0xE25C, 0x9202, 0xE25D, 0x9203, 0xE25E, 0x9204, 0xE25F, 0x9205,\t0xE260, 0x9206, 0xE261, 0x9207, 0xE262, 0x9208, 0xE263, 0x9209,\r\n\t0xE264, 0x920A, 0xE265, 0x920B, 0xE266, 0x920C, 0xE267, 0x920D,\t0xE268, 0x920E, 0xE269, 0x920F, 0xE26A, 0x9210, 0xE26B, 0x9211,\r\n\t0xE26C, 0x9212, 0xE26D, 0x9213, 0xE26E, 0x9214, 0xE26F, 0x9215,\t0xE270, 0x9216, 0xE271, 0x9217, 0xE272, 0x9218, 0xE273, 0x9219,\r\n\t0xE274, 0x921A, 0xE275, 0x921B, 0xE276, 0x921C, 0xE277, 0x921D,\t0xE278, 0x921E, 0xE279, 0x921F, 0xE27A, 0x9220, 0xE27B, 0x9221,\r\n\t0xE27C, 0x9222, 0xE27D, 0x9223, 0xE27E, 0x9224, 0xE280, 0x9225,\t0xE281, 0x9226, 0xE282, 0x9227, 0xE283, 0x9228, 0xE284, 0x9229,\r\n\t0xE285, 0x922A, 0xE286, 0x922B, 0xE287, 0x922C, 0xE288, 0x922D,\t0xE289, 0x922E, 0xE28A, 0x922F, 0xE28B, 0x9230, 0xE28C, 0x9231,\r\n\t0xE28D, 0x9232, 0xE28E, 0x9233, 0xE28F, 0x9234, 0xE290, 0x9235,\t0xE291, 0x9236, 0xE292, 0x9237, 0xE293, 0x9238, 0xE294, 0x9239,\r\n\t0xE295, 0x923A, 0xE296, 0x923B, 0xE297, 0x923C, 0xE298, 0x923D,\t0xE299, 0x923E, 0xE29A, 0x923F, 0xE29B, 0x9240, 0xE29C, 0x9241,\r\n\t0xE29D, 0x9242, 0xE29E, 0x9243, 0xE29F, 0x9244, 0xE2A0, 0x9245,\t0xE2A1, 0x72FB, 0xE2A2, 0x7317, 0xE2A3, 0x7313, 0xE2A4, 0x7321,\r\n\t0xE2A5, 0x730A, 0xE2A6, 0x731E, 0xE2A7, 0x731D, 0xE2A8, 0x7315,\t0xE2A9, 0x7322, 0xE2AA, 0x7339, 0xE2AB, 0x7325, 0xE2AC, 0x732C,\r\n\t0xE2AD, 0x7338, 0xE2AE, 0x7331, 0xE2AF, 0x7350, 0xE2B0, 0x734D,\t0xE2B1, 0x7357, 0xE2B2, 0x7360, 0xE2B3, 0x736C, 0xE2B4, 0x736F,\r\n\t0xE2B5, 0x737E, 0xE2B6, 0x821B, 0xE2B7, 0x5925, 0xE2B8, 0x98E7,\t0xE2B9, 0x5924, 0xE2BA, 0x5902, 0xE2BB, 0x9963, 0xE2BC, 0x9967,\r\n\t0xE2BD, 0x9968, 0xE2BE, 0x9969, 0xE2BF, 0x996A, 0xE2C0, 0x996B,\t0xE2C1, 0x996C, 0xE2C2, 0x9974, 0xE2C3, 0x9977, 0xE2C4, 0x997D,\r\n\t0xE2C5, 0x9980, 0xE2C6, 0x9984, 0xE2C7, 0x9987, 0xE2C8, 0x998A,\t0xE2C9, 0x998D, 0xE2CA, 0x9990, 0xE2CB, 0x9991, 0xE2CC, 0x9993,\r\n\t0xE2CD, 0x9994, 0xE2CE, 0x9995, 0xE2CF, 0x5E80, 0xE2D0, 0x5E91,\t0xE2D1, 0x5E8B, 0xE2D2, 0x5E96, 0xE2D3, 0x5EA5, 0xE2D4, 0x5EA0,\r\n\t0xE2D5, 0x5EB9, 0xE2D6, 0x5EB5, 0xE2D7, 0x5EBE, 0xE2D8, 0x5EB3,\t0xE2D9, 0x8D53, 0xE2DA, 0x5ED2, 0xE2DB, 0x5ED1, 0xE2DC, 0x5EDB,\r\n\t0xE2DD, 0x5EE8, 0xE2DE, 0x5EEA, 0xE2DF, 0x81BA, 0xE2E0, 0x5FC4,\t0xE2E1, 0x5FC9, 0xE2E2, 0x5FD6, 0xE2E3, 0x5FCF, 0xE2E4, 0x6003,\r\n\t0xE2E5, 0x5FEE, 0xE2E6, 0x6004, 0xE2E7, 0x5FE1, 0xE2E8, 0x5FE4,\t0xE2E9, 0x5FFE, 0xE2EA, 0x6005, 0xE2EB, 0x6006, 0xE2EC, 0x5FEA,\r\n\t0xE2ED, 0x5FED, 0xE2EE, 0x5FF8, 0xE2EF, 0x6019, 0xE2F0, 0x6035,\t0xE2F1, 0x6026, 0xE2F2, 0x601B, 0xE2F3, 0x600F, 0xE2F4, 0x600D,\r\n\t0xE2F5, 0x6029, 0xE2F6, 0x602B, 0xE2F7, 0x600A, 0xE2F8, 0x603F,\t0xE2F9, 0x6021, 0xE2FA, 0x6078, 0xE2FB, 0x6079, 0xE2FC, 0x607B,\r\n\t0xE2FD, 0x607A, 0xE2FE, 0x6042, 0xE340, 0x9246, 0xE341, 0x9247,\t0xE342, 0x9248, 0xE343, 0x9249, 0xE344, 0x924A, 0xE345, 0x924B,\r\n\t0xE346, 0x924C, 0xE347, 0x924D, 0xE348, 0x924E, 0xE349, 0x924F,\t0xE34A, 0x9250, 0xE34B, 0x9251, 0xE34C, 0x9252, 0xE34D, 0x9253,\r\n\t0xE34E, 0x9254, 0xE34F, 0x9255, 0xE350, 0x9256, 0xE351, 0x9257,\t0xE352, 0x9258, 0xE353, 0x9259, 0xE354, 0x925A, 0xE355, 0x925B,\r\n\t0xE356, 0x925C, 0xE357, 0x925D, 0xE358, 0x925E, 0xE359, 0x925F,\t0xE35A, 0x9260, 0xE35B, 0x9261, 0xE35C, 0x9262, 0xE35D, 0x9263,\r\n\t0xE35E, 0x9264, 0xE35F, 0x9265, 0xE360, 0x9266, 0xE361, 0x9267,\t0xE362, 0x9268, 0xE363, 0x9269, 0xE364, 0x926A, 0xE365, 0x926B,\r\n\t0xE366, 0x926C, 0xE367, 0x926D, 0xE368, 0x926E, 0xE369, 0x926F,\t0xE36A, 0x9270, 0xE36B, 0x9271, 0xE36C, 0x9272, 0xE36D, 0x9273,\r\n\t0xE36E, 0x9275, 0xE36F, 0x9276, 0xE370, 0x9277, 0xE371, 0x9278,\t0xE372, 0x9279, 0xE373, 0x927A, 0xE374, 0x927B, 0xE375, 0x927C,\r\n\t0xE376, 0x927D, 0xE377, 0x927E, 0xE378, 0x927F, 0xE379, 0x9280,\t0xE37A, 0x9281, 0xE37B, 0x9282, 0xE37C, 0x9283, 0xE37D, 0x9284,\r\n\t0xE37E, 0x9285, 0xE380, 0x9286, 0xE381, 0x9287, 0xE382, 0x9288,\t0xE383, 0x9289, 0xE384, 0x928A, 0xE385, 0x928B, 0xE386, 0x928C,\r\n\t0xE387, 0x928D, 0xE388, 0x928F, 0xE389, 0x9290, 0xE38A, 0x9291,\t0xE38B, 0x9292, 0xE38C, 0x9293, 0xE38D, 0x9294, 0xE38E, 0x9295,\r\n\t0xE38F, 0x9296, 0xE390, 0x9297, 0xE391, 0x9298, 0xE392, 0x9299,\t0xE393, 0x929A, 0xE394, 0x929B, 0xE395, 0x929C, 0xE396, 0x929D,\r\n\t0xE397, 0x929E, 0xE398, 0x929F, 0xE399, 0x92A0, 0xE39A, 0x92A1,\t0xE39B, 0x92A2, 0xE39C, 0x92A3, 0xE39D, 0x92A4, 0xE39E, 0x92A5,\r\n\t0xE39F, 0x92A6, 0xE3A0, 0x92A7, 0xE3A1, 0x606A, 0xE3A2, 0x607D,\t0xE3A3, 0x6096, 0xE3A4, 0x609A, 0xE3A5, 0x60AD, 0xE3A6, 0x609D,\r\n\t0xE3A7, 0x6083, 0xE3A8, 0x6092, 0xE3A9, 0x608C, 0xE3AA, 0x609B,\t0xE3AB, 0x60EC, 0xE3AC, 0x60BB, 0xE3AD, 0x60B1, 0xE3AE, 0x60DD,\r\n\t0xE3AF, 0x60D8, 0xE3B0, 0x60C6, 0xE3B1, 0x60DA, 0xE3B2, 0x60B4,\t0xE3B3, 0x6120, 0xE3B4, 0x6126, 0xE3B5, 0x6115, 0xE3B6, 0x6123,\r\n\t0xE3B7, 0x60F4, 0xE3B8, 0x6100, 0xE3B9, 0x610E, 0xE3BA, 0x612B,\t0xE3BB, 0x614A, 0xE3BC, 0x6175, 0xE3BD, 0x61AC, 0xE3BE, 0x6194,\r\n\t0xE3BF, 0x61A7, 0xE3C0, 0x61B7, 0xE3C1, 0x61D4, 0xE3C2, 0x61F5,\t0xE3C3, 0x5FDD, 0xE3C4, 0x96B3, 0xE3C5, 0x95E9, 0xE3C6, 0x95EB,\r\n\t0xE3C7, 0x95F1, 0xE3C8, 0x95F3, 0xE3C9, 0x95F5, 0xE3CA, 0x95F6,\t0xE3CB, 0x95FC, 0xE3CC, 0x95FE, 0xE3CD, 0x9603, 0xE3CE, 0x9604,\r\n\t0xE3CF, 0x9606, 0xE3D0, 0x9608, 0xE3D1, 0x960A, 0xE3D2, 0x960B,\t0xE3D3, 0x960C, 0xE3D4, 0x960D, 0xE3D5, 0x960F, 0xE3D6, 0x9612,\r\n\t0xE3D7, 0x9615, 0xE3D8, 0x9616, 0xE3D9, 0x9617, 0xE3DA, 0x9619,\t0xE3DB, 0x961A, 0xE3DC, 0x4E2C, 0xE3DD, 0x723F, 0xE3DE, 0x6215,\r\n\t0xE3DF, 0x6C35, 0xE3E0, 0x6C54, 0xE3E1, 0x6C5C, 0xE3E2, 0x6C4A,\t0xE3E3, 0x6CA3, 0xE3E4, 0x6C85, 0xE3E5, 0x6C90, 0xE3E6, 0x6C94,\r\n\t0xE3E7, 0x6C8C, 0xE3E8, 0x6C68, 0xE3E9, 0x6C69, 0xE3EA, 0x6C74,\t0xE3EB, 0x6C76, 0xE3EC, 0x6C86, 0xE3ED, 0x6CA9, 0xE3EE, 0x6CD0,\r\n\t0xE3EF, 0x6CD4, 0xE3F0, 0x6CAD, 0xE3F1, 0x6CF7, 0xE3F2, 0x6CF8,\t0xE3F3, 0x6CF1, 0xE3F4, 0x6CD7, 0xE3F5, 0x6CB2, 0xE3F6, 0x6CE0,\r\n\t0xE3F7, 0x6CD6, 0xE3F8, 0x6CFA, 0xE3F9, 0x6CEB, 0xE3FA, 0x6CEE,\t0xE3FB, 0x6CB1, 0xE3FC, 0x6CD3, 0xE3FD, 0x6CEF, 0xE3FE, 0x6CFE,\r\n\t0xE440, 0x92A8, 0xE441, 0x92A9, 0xE442, 0x92AA, 0xE443, 0x92AB,\t0xE444, 0x92AC, 0xE445, 0x92AD, 0xE446, 0x92AF, 0xE447, 0x92B0,\r\n\t0xE448, 0x92B1, 0xE449, 0x92B2, 0xE44A, 0x92B3, 0xE44B, 0x92B4,\t0xE44C, 0x92B5, 0xE44D, 0x92B6, 0xE44E, 0x92B7, 0xE44F, 0x92B8,\r\n\t0xE450, 0x92B9, 0xE451, 0x92BA, 0xE452, 0x92BB, 0xE453, 0x92BC,\t0xE454, 0x92BD, 0xE455, 0x92BE, 0xE456, 0x92BF, 0xE457, 0x92C0,\r\n\t0xE458, 0x92C1, 0xE459, 0x92C2, 0xE45A, 0x92C3, 0xE45B, 0x92C4,\t0xE45C, 0x92C5, 0xE45D, 0x92C6, 0xE45E, 0x92C7, 0xE45F, 0x92C9,\r\n\t0xE460, 0x92CA, 0xE461, 0x92CB, 0xE462, 0x92CC, 0xE463, 0x92CD,\t0xE464, 0x92CE, 0xE465, 0x92CF, 0xE466, 0x92D0, 0xE467, 0x92D1,\r\n\t0xE468, 0x92D2, 0xE469, 0x92D3, 0xE46A, 0x92D4, 0xE46B, 0x92D5,\t0xE46C, 0x92D6, 0xE46D, 0x92D7, 0xE46E, 0x92D8, 0xE46F, 0x92D9,\r\n\t0xE470, 0x92DA, 0xE471, 0x92DB, 0xE472, 0x92DC, 0xE473, 0x92DD,\t0xE474, 0x92DE, 0xE475, 0x92DF, 0xE476, 0x92E0, 0xE477, 0x92E1,\r\n\t0xE478, 0x92E2, 0xE479, 0x92E3, 0xE47A, 0x92E4, 0xE47B, 0x92E5,\t0xE47C, 0x92E6, 0xE47D, 0x92E7, 0xE47E, 0x92E8, 0xE480, 0x92E9,\r\n\t0xE481, 0x92EA, 0xE482, 0x92EB, 0xE483, 0x92EC, 0xE484, 0x92ED,\t0xE485, 0x92EE, 0xE486, 0x92EF, 0xE487, 0x92F0, 0xE488, 0x92F1,\r\n\t0xE489, 0x92F2, 0xE48A, 0x92F3, 0xE48B, 0x92F4, 0xE48C, 0x92F5,\t0xE48D, 0x92F6, 0xE48E, 0x92F7, 0xE48F, 0x92F8, 0xE490, 0x92F9,\r\n\t0xE491, 0x92FA, 0xE492, 0x92FB, 0xE493, 0x92FC, 0xE494, 0x92FD,\t0xE495, 0x92FE, 0xE496, 0x92FF, 0xE497, 0x9300, 0xE498, 0x9301,\r\n\t0xE499, 0x9302, 0xE49A, 0x9303, 0xE49B, 0x9304, 0xE49C, 0x9305,\t0xE49D, 0x9306, 0xE49E, 0x9307, 0xE49F, 0x9308, 0xE4A0, 0x9309,\r\n\t0xE4A1, 0x6D39, 0xE4A2, 0x6D27, 0xE4A3, 0x6D0C, 0xE4A4, 0x6D43,\t0xE4A5, 0x6D48, 0xE4A6, 0x6D07, 0xE4A7, 0x6D04, 0xE4A8, 0x6D19,\r\n\t0xE4A9, 0x6D0E, 0xE4AA, 0x6D2B, 0xE4AB, 0x6D4D, 0xE4AC, 0x6D2E,\t0xE4AD, 0x6D35, 0xE4AE, 0x6D1A, 0xE4AF, 0x6D4F, 0xE4B0, 0x6D52,\r\n\t0xE4B1, 0x6D54, 0xE4B2, 0x6D33, 0xE4B3, 0x6D91, 0xE4B4, 0x6D6F,\t0xE4B5, 0x6D9E, 0xE4B6, 0x6DA0, 0xE4B7, 0x6D5E, 0xE4B8, 0x6D93,\r\n\t0xE4B9, 0x6D94, 0xE4BA, 0x6D5C, 0xE4BB, 0x6D60, 0xE4BC, 0x6D7C,\t0xE4BD, 0x6D63, 0xE4BE, 0x6E1A, 0xE4BF, 0x6DC7, 0xE4C0, 0x6DC5,\r\n\t0xE4C1, 0x6DDE, 0xE4C2, 0x6E0E, 0xE4C3, 0x6DBF, 0xE4C4, 0x6DE0,\t0xE4C5, 0x6E11, 0xE4C6, 0x6DE6, 0xE4C7, 0x6DDD, 0xE4C8, 0x6DD9,\r\n\t0xE4C9, 0x6E16, 0xE4CA, 0x6DAB, 0xE4CB, 0x6E0C, 0xE4CC, 0x6DAE,\t0xE4CD, 0x6E2B, 0xE4CE, 0x6E6E, 0xE4CF, 0x6E4E, 0xE4D0, 0x6E6B,\r\n\t0xE4D1, 0x6EB2, 0xE4D2, 0x6E5F, 0xE4D3, 0x6E86, 0xE4D4, 0x6E53,\t0xE4D5, 0x6E54, 0xE4D6, 0x6E32, 0xE4D7, 0x6E25, 0xE4D8, 0x6E44,\r\n\t0xE4D9, 0x6EDF, 0xE4DA, 0x6EB1, 0xE4DB, 0x6E98, 0xE4DC, 0x6EE0,\t0xE4DD, 0x6F2D, 0xE4DE, 0x6EE2, 0xE4DF, 0x6EA5, 0xE4E0, 0x6EA7,\r\n\t0xE4E1, 0x6EBD, 0xE4E2, 0x6EBB, 0xE4E3, 0x6EB7, 0xE4E4, 0x6ED7,\t0xE4E5, 0x6EB4, 0xE4E6, 0x6ECF, 0xE4E7, 0x6E8F, 0xE4E8, 0x6EC2,\r\n\t0xE4E9, 0x6E9F, 0xE4EA, 0x6F62, 0xE4EB, 0x6F46, 0xE4EC, 0x6F47,\t0xE4ED, 0x6F24, 0xE4EE, 0x6F15, 0xE4EF, 0x6EF9, 0xE4F0, 0x6F2F,\r\n\t0xE4F1, 0x6F36, 0xE4F2, 0x6F4B, 0xE4F3, 0x6F74, 0xE4F4, 0x6F2A,\t0xE4F5, 0x6F09, 0xE4F6, 0x6F29, 0xE4F7, 0x6F89, 0xE4F8, 0x6F8D,\r\n\t0xE4F9, 0x6F8C, 0xE4FA, 0x6F78, 0xE4FB, 0x6F72, 0xE4FC, 0x6F7C,\t0xE4FD, 0x6F7A, 0xE4FE, 0x6FD1, 0xE540, 0x930A, 0xE541, 0x930B,\r\n\t0xE542, 0x930C, 0xE543, 0x930D, 0xE544, 0x930E, 0xE545, 0x930F,\t0xE546, 0x9310, 0xE547, 0x9311, 0xE548, 0x9312, 0xE549, 0x9313,\r\n\t0xE54A, 0x9314, 0xE54B, 0x9315, 0xE54C, 0x9316, 0xE54D, 0x9317,\t0xE54E, 0x9318, 0xE54F, 0x9319, 0xE550, 0x931A, 0xE551, 0x931B,\r\n\t0xE552, 0x931C, 0xE553, 0x931D, 0xE554, 0x931E, 0xE555, 0x931F,\t0xE556, 0x9320, 0xE557, 0x9321, 0xE558, 0x9322, 0xE559, 0x9323,\r\n\t0xE55A, 0x9324, 0xE55B, 0x9325, 0xE55C, 0x9326, 0xE55D, 0x9327,\t0xE55E, 0x9328, 0xE55F, 0x9329, 0xE560, 0x932A, 0xE561, 0x932B,\r\n\t0xE562, 0x932C, 0xE563, 0x932D, 0xE564, 0x932E, 0xE565, 0x932F,\t0xE566, 0x9330, 0xE567, 0x9331, 0xE568, 0x9332, 0xE569, 0x9333,\r\n\t0xE56A, 0x9334, 0xE56B, 0x9335, 0xE56C, 0x9336, 0xE56D, 0x9337,\t0xE56E, 0x9338, 0xE56F, 0x9339, 0xE570, 0x933A, 0xE571, 0x933B,\r\n\t0xE572, 0x933C, 0xE573, 0x933D, 0xE574, 0x933F, 0xE575, 0x9340,\t0xE576, 0x9341, 0xE577, 0x9342, 0xE578, 0x9343, 0xE579, 0x9344,\r\n\t0xE57A, 0x9345, 0xE57B, 0x9346, 0xE57C, 0x9347, 0xE57D, 0x9348,\t0xE57E, 0x9349, 0xE580, 0x934A, 0xE581, 0x934B, 0xE582, 0x934C,\r\n\t0xE583, 0x934D, 0xE584, 0x934E, 0xE585, 0x934F, 0xE586, 0x9350,\t0xE587, 0x9351, 0xE588, 0x9352, 0xE589, 0x9353, 0xE58A, 0x9354,\r\n\t0xE58B, 0x9355, 0xE58C, 0x9356, 0xE58D, 0x9357, 0xE58E, 0x9358,\t0xE58F, 0x9359, 0xE590, 0x935A, 0xE591, 0x935B, 0xE592, 0x935C,\r\n\t0xE593, 0x935D, 0xE594, 0x935E, 0xE595, 0x935F, 0xE596, 0x9360,\t0xE597, 0x9361, 0xE598, 0x9362, 0xE599, 0x9363, 0xE59A, 0x9364,\r\n\t0xE59B, 0x9365, 0xE59C, 0x9366, 0xE59D, 0x9367, 0xE59E, 0x9368,\t0xE59F, 0x9369, 0xE5A0, 0x936B, 0xE5A1, 0x6FC9, 0xE5A2, 0x6FA7,\r\n\t0xE5A3, 0x6FB9, 0xE5A4, 0x6FB6, 0xE5A5, 0x6FC2, 0xE5A6, 0x6FE1,\t0xE5A7, 0x6FEE, 0xE5A8, 0x6FDE, 0xE5A9, 0x6FE0, 0xE5AA, 0x6FEF,\r\n\t0xE5AB, 0x701A, 0xE5AC, 0x7023, 0xE5AD, 0x701B, 0xE5AE, 0x7039,\t0xE5AF, 0x7035, 0xE5B0, 0x704F, 0xE5B1, 0x705E, 0xE5B2, 0x5B80,\r\n\t0xE5B3, 0x5B84, 0xE5B4, 0x5B95, 0xE5B5, 0x5B93, 0xE5B6, 0x5BA5,\t0xE5B7, 0x5BB8, 0xE5B8, 0x752F, 0xE5B9, 0x9A9E, 0xE5BA, 0x6434,\r\n\t0xE5BB, 0x5BE4, 0xE5BC, 0x5BEE, 0xE5BD, 0x8930, 0xE5BE, 0x5BF0,\t0xE5BF, 0x8E47, 0xE5C0, 0x8B07, 0xE5C1, 0x8FB6, 0xE5C2, 0x8FD3,\r\n\t0xE5C3, 0x8FD5, 0xE5C4, 0x8FE5, 0xE5C5, 0x8FEE, 0xE5C6, 0x8FE4,\t0xE5C7, 0x8FE9, 0xE5C8, 0x8FE6, 0xE5C9, 0x8FF3, 0xE5CA, 0x8FE8,\r\n\t0xE5CB, 0x9005, 0xE5CC, 0x9004, 0xE5CD, 0x900B, 0xE5CE, 0x9026,\t0xE5CF, 0x9011, 0xE5D0, 0x900D, 0xE5D1, 0x9016, 0xE5D2, 0x9021,\r\n\t0xE5D3, 0x9035, 0xE5D4, 0x9036, 0xE5D5, 0x902D, 0xE5D6, 0x902F,\t0xE5D7, 0x9044, 0xE5D8, 0x9051, 0xE5D9, 0x9052, 0xE5DA, 0x9050,\r\n\t0xE5DB, 0x9068, 0xE5DC, 0x9058, 0xE5DD, 0x9062, 0xE5DE, 0x905B,\t0xE5DF, 0x66B9, 0xE5E0, 0x9074, 0xE5E1, 0x907D, 0xE5E2, 0x9082,\r\n\t0xE5E3, 0x9088, 0xE5E4, 0x9083, 0xE5E5, 0x908B, 0xE5E6, 0x5F50,\t0xE5E7, 0x5F57, 0xE5E8, 0x5F56, 0xE5E9, 0x5F58, 0xE5EA, 0x5C3B,\r\n\t0xE5EB, 0x54AB, 0xE5EC, 0x5C50, 0xE5ED, 0x5C59, 0xE5EE, 0x5B71,\t0xE5EF, 0x5C63, 0xE5F0, 0x5C66, 0xE5F1, 0x7FBC, 0xE5F2, 0x5F2A,\r\n\t0xE5F3, 0x5F29, 0xE5F4, 0x5F2D, 0xE5F5, 0x8274, 0xE5F6, 0x5F3C,\t0xE5F7, 0x9B3B, 0xE5F8, 0x5C6E, 0xE5F9, 0x5981, 0xE5FA, 0x5983,\r\n\t0xE5FB, 0x598D, 0xE5FC, 0x59A9, 0xE5FD, 0x59AA, 0xE5FE, 0x59A3,\t0xE640, 0x936C, 0xE641, 0x936D, 0xE642, 0x936E, 0xE643, 0x936F,\r\n\t0xE644, 0x9370, 0xE645, 0x9371, 0xE646, 0x9372, 0xE647, 0x9373,\t0xE648, 0x9374, 0xE649, 0x9375, 0xE64A, 0x9376, 0xE64B, 0x9377,\r\n\t0xE64C, 0x9378, 0xE64D, 0x9379, 0xE64E, 0x937A, 0xE64F, 0x937B,\t0xE650, 0x937C, 0xE651, 0x937D, 0xE652, 0x937E, 0xE653, 0x937F,\r\n\t0xE654, 0x9380, 0xE655, 0x9381, 0xE656, 0x9382, 0xE657, 0x9383,\t0xE658, 0x9384, 0xE659, 0x9385, 0xE65A, 0x9386, 0xE65B, 0x9387,\r\n\t0xE65C, 0x9388, 0xE65D, 0x9389, 0xE65E, 0x938A, 0xE65F, 0x938B,\t0xE660, 0x938C, 0xE661, 0x938D, 0xE662, 0x938E, 0xE663, 0x9390,\r\n\t0xE664, 0x9391, 0xE665, 0x9392, 0xE666, 0x9393, 0xE667, 0x9394,\t0xE668, 0x9395, 0xE669, 0x9396, 0xE66A, 0x9397, 0xE66B, 0x9398,\r\n\t0xE66C, 0x9399, 0xE66D, 0x939A, 0xE66E, 0x939B, 0xE66F, 0x939C,\t0xE670, 0x939D, 0xE671, 0x939E, 0xE672, 0x939F, 0xE673, 0x93A0,\r\n\t0xE674, 0x93A1, 0xE675, 0x93A2, 0xE676, 0x93A3, 0xE677, 0x93A4,\t0xE678, 0x93A5, 0xE679, 0x93A6, 0xE67A, 0x93A7, 0xE67B, 0x93A8,\r\n\t0xE67C, 0x93A9, 0xE67D, 0x93AA, 0xE67E, 0x93AB, 0xE680, 0x93AC,\t0xE681, 0x93AD, 0xE682, 0x93AE, 0xE683, 0x93AF, 0xE684, 0x93B0,\r\n\t0xE685, 0x93B1, 0xE686, 0x93B2, 0xE687, 0x93B3, 0xE688, 0x93B4,\t0xE689, 0x93B5, 0xE68A, 0x93B6, 0xE68B, 0x93B7, 0xE68C, 0x93B8,\r\n\t0xE68D, 0x93B9, 0xE68E, 0x93BA, 0xE68F, 0x93BB, 0xE690, 0x93BC,\t0xE691, 0x93BD, 0xE692, 0x93BE, 0xE693, 0x93BF, 0xE694, 0x93C0,\r\n\t0xE695, 0x93C1, 0xE696, 0x93C2, 0xE697, 0x93C3, 0xE698, 0x93C4,\t0xE699, 0x93C5, 0xE69A, 0x93C6, 0xE69B, 0x93C7, 0xE69C, 0x93C8,\r\n\t0xE69D, 0x93C9, 0xE69E, 0x93CB, 0xE69F, 0x93CC, 0xE6A0, 0x93CD,\t0xE6A1, 0x5997, 0xE6A2, 0x59CA, 0xE6A3, 0x59AB, 0xE6A4, 0x599E,\r\n\t0xE6A5, 0x59A4, 0xE6A6, 0x59D2, 0xE6A7, 0x59B2, 0xE6A8, 0x59AF,\t0xE6A9, 0x59D7, 0xE6AA, 0x59BE, 0xE6AB, 0x5A05, 0xE6AC, 0x5A06,\r\n\t0xE6AD, 0x59DD, 0xE6AE, 0x5A08, 0xE6AF, 0x59E3, 0xE6B0, 0x59D8,\t0xE6B1, 0x59F9, 0xE6B2, 0x5A0C, 0xE6B3, 0x5A09, 0xE6B4, 0x5A32,\r\n\t0xE6B5, 0x5A34, 0xE6B6, 0x5A11, 0xE6B7, 0x5A23, 0xE6B8, 0x5A13,\t0xE6B9, 0x5A40, 0xE6BA, 0x5A67, 0xE6BB, 0x5A4A, 0xE6BC, 0x5A55,\r\n\t0xE6BD, 0x5A3C, 0xE6BE, 0x5A62, 0xE6BF, 0x5A75, 0xE6C0, 0x80EC,\t0xE6C1, 0x5AAA, 0xE6C2, 0x5A9B, 0xE6C3, 0x5A77, 0xE6C4, 0x5A7A,\r\n\t0xE6C5, 0x5ABE, 0xE6C6, 0x5AEB, 0xE6C7, 0x5AB2, 0xE6C8, 0x5AD2,\t0xE6C9, 0x5AD4, 0xE6CA, 0x5AB8, 0xE6CB, 0x5AE0, 0xE6CC, 0x5AE3,\r\n\t0xE6CD, 0x5AF1, 0xE6CE, 0x5AD6, 0xE6CF, 0x5AE6, 0xE6D0, 0x5AD8,\t0xE6D1, 0x5ADC, 0xE6D2, 0x5B09, 0xE6D3, 0x5B17, 0xE6D4, 0x5B16,\r\n\t0xE6D5, 0x5B32, 0xE6D6, 0x5B37, 0xE6D7, 0x5B40, 0xE6D8, 0x5C15,\t0xE6D9, 0x5C1C, 0xE6DA, 0x5B5A, 0xE6DB, 0x5B65, 0xE6DC, 0x5B73,\r\n\t0xE6DD, 0x5B51, 0xE6DE, 0x5B53, 0xE6DF, 0x5B62, 0xE6E0, 0x9A75,\t0xE6E1, 0x9A77, 0xE6E2, 0x9A78, 0xE6E3, 0x9A7A, 0xE6E4, 0x9A7F,\r\n\t0xE6E5, 0x9A7D, 0xE6E6, 0x9A80, 0xE6E7, 0x9A81, 0xE6E8, 0x9A85,\t0xE6E9, 0x9A88, 0xE6EA, 0x9A8A, 0xE6EB, 0x9A90, 0xE6EC, 0x9A92,\r\n\t0xE6ED, 0x9A93, 0xE6EE, 0x9A96, 0xE6EF, 0x9A98, 0xE6F0, 0x9A9B,\t0xE6F1, 0x9A9C, 0xE6F2, 0x9A9D, 0xE6F3, 0x9A9F, 0xE6F4, 0x9AA0,\r\n\t0xE6F5, 0x9AA2, 0xE6F6, 0x9AA3, 0xE6F7, 0x9AA5, 0xE6F8, 0x9AA7,\t0xE6F9, 0x7E9F, 0xE6FA, 0x7EA1, 0xE6FB, 0x7EA3, 0xE6FC, 0x7EA5,\r\n\t0xE6FD, 0x7EA8, 0xE6FE, 0x7EA9, 0xE740, 0x93CE, 0xE741, 0x93CF,\t0xE742, 0x93D0, 0xE743, 0x93D1, 0xE744, 0x93D2, 0xE745, 0x93D3,\r\n\t0xE746, 0x93D4, 0xE747, 0x93D5, 0xE748, 0x93D7, 0xE749, 0x93D8,\t0xE74A, 0x93D9, 0xE74B, 0x93DA, 0xE74C, 0x93DB, 0xE74D, 0x93DC,\r\n\t0xE74E, 0x93DD, 0xE74F, 0x93DE, 0xE750, 0x93DF, 0xE751, 0x93E0,\t0xE752, 0x93E1, 0xE753, 0x93E2, 0xE754, 0x93E3, 0xE755, 0x93E4,\r\n\t0xE756, 0x93E5, 0xE757, 0x93E6, 0xE758, 0x93E7, 0xE759, 0x93E8,\t0xE75A, 0x93E9, 0xE75B, 0x93EA, 0xE75C, 0x93EB, 0xE75D, 0x93EC,\r\n\t0xE75E, 0x93ED, 0xE75F, 0x93EE, 0xE760, 0x93EF, 0xE761, 0x93F0,\t0xE762, 0x93F1, 0xE763, 0x93F2, 0xE764, 0x93F3, 0xE765, 0x93F4,\r\n\t0xE766, 0x93F5, 0xE767, 0x93F6, 0xE768, 0x93F7, 0xE769, 0x93F8,\t0xE76A, 0x93F9, 0xE76B, 0x93FA, 0xE76C, 0x93FB, 0xE76D, 0x93FC,\r\n\t0xE76E, 0x93FD, 0xE76F, 0x93FE, 0xE770, 0x93FF, 0xE771, 0x9400,\t0xE772, 0x9401, 0xE773, 0x9402, 0xE774, 0x9403, 0xE775, 0x9404,\r\n\t0xE776, 0x9405, 0xE777, 0x9406, 0xE778, 0x9407, 0xE779, 0x9408,\t0xE77A, 0x9409, 0xE77B, 0x940A, 0xE77C, 0x940B, 0xE77D, 0x940C,\r\n\t0xE77E, 0x940D, 0xE780, 0x940E, 0xE781, 0x940F, 0xE782, 0x9410,\t0xE783, 0x9411, 0xE784, 0x9412, 0xE785, 0x9413, 0xE786, 0x9414,\r\n\t0xE787, 0x9415, 0xE788, 0x9416, 0xE789, 0x9417, 0xE78A, 0x9418,\t0xE78B, 0x9419, 0xE78C, 0x941A, 0xE78D, 0x941B, 0xE78E, 0x941C,\r\n\t0xE78F, 0x941D, 0xE790, 0x941E, 0xE791, 0x941F, 0xE792, 0x9420,\t0xE793, 0x9421, 0xE794, 0x9422, 0xE795, 0x9423, 0xE796, 0x9424,\r\n\t0xE797, 0x9425, 0xE798, 0x9426, 0xE799, 0x9427, 0xE79A, 0x9428,\t0xE79B, 0x9429, 0xE79C, 0x942A, 0xE79D, 0x942B, 0xE79E, 0x942C,\r\n\t0xE79F, 0x942D, 0xE7A0, 0x942E, 0xE7A1, 0x7EAD, 0xE7A2, 0x7EB0,\t0xE7A3, 0x7EBE, 0xE7A4, 0x7EC0, 0xE7A5, 0x7EC1, 0xE7A6, 0x7EC2,\r\n\t0xE7A7, 0x7EC9, 0xE7A8, 0x7ECB, 0xE7A9, 0x7ECC, 0xE7AA, 0x7ED0,\t0xE7AB, 0x7ED4, 0xE7AC, 0x7ED7, 0xE7AD, 0x7EDB, 0xE7AE, 0x7EE0,\r\n\t0xE7AF, 0x7EE1, 0xE7B0, 0x7EE8, 0xE7B1, 0x7EEB, 0xE7B2, 0x7EEE,\t0xE7B3, 0x7EEF, 0xE7B4, 0x7EF1, 0xE7B5, 0x7EF2, 0xE7B6, 0x7F0D,\r\n\t0xE7B7, 0x7EF6, 0xE7B8, 0x7EFA, 0xE7B9, 0x7EFB, 0xE7BA, 0x7EFE,\t0xE7BB, 0x7F01, 0xE7BC, 0x7F02, 0xE7BD, 0x7F03, 0xE7BE, 0x7F07,\r\n\t0xE7BF, 0x7F08, 0xE7C0, 0x7F0B, 0xE7C1, 0x7F0C, 0xE7C2, 0x7F0F,\t0xE7C3, 0x7F11, 0xE7C4, 0x7F12, 0xE7C5, 0x7F17, 0xE7C6, 0x7F19,\r\n\t0xE7C7, 0x7F1C, 0xE7C8, 0x7F1B, 0xE7C9, 0x7F1F, 0xE7CA, 0x7F21,\t0xE7CB, 0x7F22, 0xE7CC, 0x7F23, 0xE7CD, 0x7F24, 0xE7CE, 0x7F25,\r\n\t0xE7CF, 0x7F26, 0xE7D0, 0x7F27, 0xE7D1, 0x7F2A, 0xE7D2, 0x7F2B,\t0xE7D3, 0x7F2C, 0xE7D4, 0x7F2D, 0xE7D5, 0x7F2F, 0xE7D6, 0x7F30,\r\n\t0xE7D7, 0x7F31, 0xE7D8, 0x7F32, 0xE7D9, 0x7F33, 0xE7DA, 0x7F35,\t0xE7DB, 0x5E7A, 0xE7DC, 0x757F, 0xE7DD, 0x5DDB, 0xE7DE, 0x753E,\r\n\t0xE7DF, 0x9095, 0xE7E0, 0x738E, 0xE7E1, 0x7391, 0xE7E2, 0x73AE,\t0xE7E3, 0x73A2, 0xE7E4, 0x739F, 0xE7E5, 0x73CF, 0xE7E6, 0x73C2,\r\n\t0xE7E7, 0x73D1, 0xE7E8, 0x73B7, 0xE7E9, 0x73B3, 0xE7EA, 0x73C0,\t0xE7EB, 0x73C9, 0xE7EC, 0x73C8, 0xE7ED, 0x73E5, 0xE7EE, 0x73D9,\r\n\t0xE7EF, 0x987C, 0xE7F0, 0x740A, 0xE7F1, 0x73E9, 0xE7F2, 0x73E7,\t0xE7F3, 0x73DE, 0xE7F4, 0x73BA, 0xE7F5, 0x73F2, 0xE7F6, 0x740F,\r\n\t0xE7F7, 0x742A, 0xE7F8, 0x745B, 0xE7F9, 0x7426, 0xE7FA, 0x7425,\t0xE7FB, 0x7428, 0xE7FC, 0x7430, 0xE7FD, 0x742E, 0xE7FE, 0x742C,\r\n\t0xE840, 0x942F, 0xE841, 0x9430, 0xE842, 0x9431, 0xE843, 0x9432,\t0xE844, 0x9433, 0xE845, 0x9434, 0xE846, 0x9435, 0xE847, 0x9436,\r\n\t0xE848, 0x9437, 0xE849, 0x9438, 0xE84A, 0x9439, 0xE84B, 0x943A,\t0xE84C, 0x943B, 0xE84D, 0x943C, 0xE84E, 0x943D, 0xE84F, 0x943F,\r\n\t0xE850, 0x9440, 0xE851, 0x9441, 0xE852, 0x9442, 0xE853, 0x9443,\t0xE854, 0x9444, 0xE855, 0x9445, 0xE856, 0x9446, 0xE857, 0x9447,\r\n\t0xE858, 0x9448, 0xE859, 0x9449, 0xE85A, 0x944A, 0xE85B, 0x944B,\t0xE85C, 0x944C, 0xE85D, 0x944D, 0xE85E, 0x944E, 0xE85F, 0x944F,\r\n\t0xE860, 0x9450, 0xE861, 0x9451, 0xE862, 0x9452, 0xE863, 0x9453,\t0xE864, 0x9454, 0xE865, 0x9455, 0xE866, 0x9456, 0xE867, 0x9457,\r\n\t0xE868, 0x9458, 0xE869, 0x9459, 0xE86A, 0x945A, 0xE86B, 0x945B,\t0xE86C, 0x945C, 0xE86D, 0x945D, 0xE86E, 0x945E, 0xE86F, 0x945F,\r\n\t0xE870, 0x9460, 0xE871, 0x9461, 0xE872, 0x9462, 0xE873, 0x9463,\t0xE874, 0x9464, 0xE875, 0x9465, 0xE876, 0x9466, 0xE877, 0x9467,\r\n\t0xE878, 0x9468, 0xE879, 0x9469, 0xE87A, 0x946A, 0xE87B, 0x946C,\t0xE87C, 0x946D, 0xE87D, 0x946E, 0xE87E, 0x946F, 0xE880, 0x9470,\r\n\t0xE881, 0x9471, 0xE882, 0x9472, 0xE883, 0x9473, 0xE884, 0x9474,\t0xE885, 0x9475, 0xE886, 0x9476, 0xE887, 0x9477, 0xE888, 0x9478,\r\n\t0xE889, 0x9479, 0xE88A, 0x947A, 0xE88B, 0x947B, 0xE88C, 0x947C,\t0xE88D, 0x947D, 0xE88E, 0x947E, 0xE88F, 0x947F, 0xE890, 0x9480,\r\n\t0xE891, 0x9481, 0xE892, 0x9482, 0xE893, 0x9483, 0xE894, 0x9484,\t0xE895, 0x9491, 0xE896, 0x9496, 0xE897, 0x9498, 0xE898, 0x94C7,\r\n\t0xE899, 0x94CF, 0xE89A, 0x94D3, 0xE89B, 0x94D4, 0xE89C, 0x94DA,\t0xE89D, 0x94E6, 0xE89E, 0x94FB, 0xE89F, 0x951C, 0xE8A0, 0x9520,\r\n\t0xE8A1, 0x741B, 0xE8A2, 0x741A, 0xE8A3, 0x7441, 0xE8A4, 0x745C,\t0xE8A5, 0x7457, 0xE8A6, 0x7455, 0xE8A7, 0x7459, 0xE8A8, 0x7477,\r\n\t0xE8A9, 0x746D, 0xE8AA, 0x747E, 0xE8AB, 0x749C, 0xE8AC, 0x748E,\t0xE8AD, 0x7480, 0xE8AE, 0x7481, 0xE8AF, 0x7487, 0xE8B0, 0x748B,\r\n\t0xE8B1, 0x749E, 0xE8B2, 0x74A8, 0xE8B3, 0x74A9, 0xE8B4, 0x7490,\t0xE8B5, 0x74A7, 0xE8B6, 0x74D2, 0xE8B7, 0x74BA, 0xE8B8, 0x97EA,\r\n\t0xE8B9, 0x97EB, 0xE8BA, 0x97EC, 0xE8BB, 0x674C, 0xE8BC, 0x6753,\t0xE8BD, 0x675E, 0xE8BE, 0x6748, 0xE8BF, 0x6769, 0xE8C0, 0x67A5,\r\n\t0xE8C1, 0x6787, 0xE8C2, 0x676A, 0xE8C3, 0x6773, 0xE8C4, 0x6798,\t0xE8C5, 0x67A7, 0xE8C6, 0x6775, 0xE8C7, 0x67A8, 0xE8C8, 0x679E,\r\n\t0xE8C9, 0x67AD, 0xE8CA, 0x678B, 0xE8CB, 0x6777, 0xE8CC, 0x677C,\t0xE8CD, 0x67F0, 0xE8CE, 0x6809, 0xE8CF, 0x67D8, 0xE8D0, 0x680A,\r\n\t0xE8D1, 0x67E9, 0xE8D2, 0x67B0, 0xE8D3, 0x680C, 0xE8D4, 0x67D9,\t0xE8D5, 0x67B5, 0xE8D6, 0x67DA, 0xE8D7, 0x67B3, 0xE8D8, 0x67DD,\r\n\t0xE8D9, 0x6800, 0xE8DA, 0x67C3, 0xE8DB, 0x67B8, 0xE8DC, 0x67E2,\t0xE8DD, 0x680E, 0xE8DE, 0x67C1, 0xE8DF, 0x67FD, 0xE8E0, 0x6832,\r\n\t0xE8E1, 0x6833, 0xE8E2, 0x6860, 0xE8E3, 0x6861, 0xE8E4, 0x684E,\t0xE8E5, 0x6862, 0xE8E6, 0x6844, 0xE8E7, 0x6864, 0xE8E8, 0x6883,\r\n\t0xE8E9, 0x681D, 0xE8EA, 0x6855, 0xE8EB, 0x6866, 0xE8EC, 0x6841,\t0xE8ED, 0x6867, 0xE8EE, 0x6840, 0xE8EF, 0x683E, 0xE8F0, 0x684A,\r\n\t0xE8F1, 0x6849, 0xE8F2, 0x6829, 0xE8F3, 0x68B5, 0xE8F4, 0x688F,\t0xE8F5, 0x6874, 0xE8F6, 0x6877, 0xE8F7, 0x6893, 0xE8F8, 0x686B,\r\n\t0xE8F9, 0x68C2, 0xE8FA, 0x696E, 0xE8FB, 0x68FC, 0xE8FC, 0x691F,\t0xE8FD, 0x6920, 0xE8FE, 0x68F9, 0xE940, 0x9527, 0xE941, 0x9533,\r\n\t0xE942, 0x953D, 0xE943, 0x9543, 0xE944, 0x9548, 0xE945, 0x954B,\t0xE946, 0x9555, 0xE947, 0x955A, 0xE948, 0x9560, 0xE949, 0x956E,\r\n\t0xE94A, 0x9574, 0xE94B, 0x9575, 0xE94C, 0x9577, 0xE94D, 0x9578,\t0xE94E, 0x9579, 0xE94F, 0x957A, 0xE950, 0x957B, 0xE951, 0x957C,\r\n\t0xE952, 0x957D, 0xE953, 0x957E, 0xE954, 0x9580, 0xE955, 0x9581,\t0xE956, 0x9582, 0xE957, 0x9583, 0xE958, 0x9584, 0xE959, 0x9585,\r\n\t0xE95A, 0x9586, 0xE95B, 0x9587, 0xE95C, 0x9588, 0xE95D, 0x9589,\t0xE95E, 0x958A, 0xE95F, 0x958B, 0xE960, 0x958C, 0xE961, 0x958D,\r\n\t0xE962, 0x958E, 0xE963, 0x958F, 0xE964, 0x9590, 0xE965, 0x9591,\t0xE966, 0x9592, 0xE967, 0x9593, 0xE968, 0x9594, 0xE969, 0x9595,\r\n\t0xE96A, 0x9596, 0xE96B, 0x9597, 0xE96C, 0x9598, 0xE96D, 0x9599,\t0xE96E, 0x959A, 0xE96F, 0x959B, 0xE970, 0x959C, 0xE971, 0x959D,\r\n\t0xE972, 0x959E, 0xE973, 0x959F, 0xE974, 0x95A0, 0xE975, 0x95A1,\t0xE976, 0x95A2, 0xE977, 0x95A3, 0xE978, 0x95A4, 0xE979, 0x95A5,\r\n\t0xE97A, 0x95A6, 0xE97B, 0x95A7, 0xE97C, 0x95A8, 0xE97D, 0x95A9,\t0xE97E, 0x95AA, 0xE980, 0x95AB, 0xE981, 0x95AC, 0xE982, 0x95AD,\r\n\t0xE983, 0x95AE, 0xE984, 0x95AF, 0xE985, 0x95B0, 0xE986, 0x95B1,\t0xE987, 0x95B2, 0xE988, 0x95B3, 0xE989, 0x95B4, 0xE98A, 0x95B5,\r\n\t0xE98B, 0x95B6, 0xE98C, 0x95B7, 0xE98D, 0x95B8, 0xE98E, 0x95B9,\t0xE98F, 0x95BA, 0xE990, 0x95BB, 0xE991, 0x95BC, 0xE992, 0x95BD,\r\n\t0xE993, 0x95BE, 0xE994, 0x95BF, 0xE995, 0x95C0, 0xE996, 0x95C1,\t0xE997, 0x95C2, 0xE998, 0x95C3, 0xE999, 0x95C4, 0xE99A, 0x95C5,\r\n\t0xE99B, 0x95C6, 0xE99C, 0x95C7, 0xE99D, 0x95C8, 0xE99E, 0x95C9,\t0xE99F, 0x95CA, 0xE9A0, 0x95CB, 0xE9A1, 0x6924, 0xE9A2, 0x68F0,\r\n\t0xE9A3, 0x690B, 0xE9A4, 0x6901, 0xE9A5, 0x6957, 0xE9A6, 0x68E3,\t0xE9A7, 0x6910, 0xE9A8, 0x6971, 0xE9A9, 0x6939, 0xE9AA, 0x6960,\r\n\t0xE9AB, 0x6942, 0xE9AC, 0x695D, 0xE9AD, 0x6984, 0xE9AE, 0x696B,\t0xE9AF, 0x6980, 0xE9B0, 0x6998, 0xE9B1, 0x6978, 0xE9B2, 0x6934,\r\n\t0xE9B3, 0x69CC, 0xE9B4, 0x6987, 0xE9B5, 0x6988, 0xE9B6, 0x69CE,\t0xE9B7, 0x6989, 0xE9B8, 0x6966, 0xE9B9, 0x6963, 0xE9BA, 0x6979,\r\n\t0xE9BB, 0x699B, 0xE9BC, 0x69A7, 0xE9BD, 0x69BB, 0xE9BE, 0x69AB,\t0xE9BF, 0x69AD, 0xE9C0, 0x69D4, 0xE9C1, 0x69B1, 0xE9C2, 0x69C1,\r\n\t0xE9C3, 0x69CA, 0xE9C4, 0x69DF, 0xE9C5, 0x6995, 0xE9C6, 0x69E0,\t0xE9C7, 0x698D, 0xE9C8, 0x69FF, 0xE9C9, 0x6A2F, 0xE9CA, 0x69ED,\r\n\t0xE9CB, 0x6A17, 0xE9CC, 0x6A18, 0xE9CD, 0x6A65, 0xE9CE, 0x69F2,\t0xE9CF, 0x6A44, 0xE9D0, 0x6A3E, 0xE9D1, 0x6AA0, 0xE9D2, 0x6A50,\r\n\t0xE9D3, 0x6A5B, 0xE9D4, 0x6A35, 0xE9D5, 0x6A8E, 0xE9D6, 0x6A79,\t0xE9D7, 0x6A3D, 0xE9D8, 0x6A28, 0xE9D9, 0x6A58, 0xE9DA, 0x6A7C,\r\n\t0xE9DB, 0x6A91, 0xE9DC, 0x6A90, 0xE9DD, 0x6AA9, 0xE9DE, 0x6A97,\t0xE9DF, 0x6AAB, 0xE9E0, 0x7337, 0xE9E1, 0x7352, 0xE9E2, 0x6B81,\r\n\t0xE9E3, 0x6B82, 0xE9E4, 0x6B87, 0xE9E5, 0x6B84, 0xE9E6, 0x6B92,\t0xE9E7, 0x6B93, 0xE9E8, 0x6B8D, 0xE9E9, 0x6B9A, 0xE9EA, 0x6B9B,\r\n\t0xE9EB, 0x6BA1, 0xE9EC, 0x6BAA, 0xE9ED, 0x8F6B, 0xE9EE, 0x8F6D,\t0xE9EF, 0x8F71, 0xE9F0, 0x8F72, 0xE9F1, 0x8F73, 0xE9F2, 0x8F75,\r\n\t0xE9F3, 0x8F76, 0xE9F4, 0x8F78, 0xE9F5, 0x8F77, 0xE9F6, 0x8F79,\t0xE9F7, 0x8F7A, 0xE9F8, 0x8F7C, 0xE9F9, 0x8F7E, 0xE9FA, 0x8F81,\r\n\t0xE9FB, 0x8F82, 0xE9FC, 0x8F84, 0xE9FD, 0x8F87, 0xE9FE, 0x8F8B,\t0xEA40, 0x95CC, 0xEA41, 0x95CD, 0xEA42, 0x95CE, 0xEA43, 0x95CF,\r\n\t0xEA44, 0x95D0, 0xEA45, 0x95D1, 0xEA46, 0x95D2, 0xEA47, 0x95D3,\t0xEA48, 0x95D4, 0xEA49, 0x95D5, 0xEA4A, 0x95D6, 0xEA4B, 0x95D7,\r\n\t0xEA4C, 0x95D8, 0xEA4D, 0x95D9, 0xEA4E, 0x95DA, 0xEA4F, 0x95DB,\t0xEA50, 0x95DC, 0xEA51, 0x95DD, 0xEA52, 0x95DE, 0xEA53, 0x95DF,\r\n\t0xEA54, 0x95E0, 0xEA55, 0x95E1, 0xEA56, 0x95E2, 0xEA57, 0x95E3,\t0xEA58, 0x95E4, 0xEA59, 0x95E5, 0xEA5A, 0x95E6, 0xEA5B, 0x95E7,\r\n\t0xEA5C, 0x95EC, 0xEA5D, 0x95FF, 0xEA5E, 0x9607, 0xEA5F, 0x9613,\t0xEA60, 0x9618, 0xEA61, 0x961B, 0xEA62, 0x961E, 0xEA63, 0x9620,\r\n\t0xEA64, 0x9623, 0xEA65, 0x9624, 0xEA66, 0x9625, 0xEA67, 0x9626,\t0xEA68, 0x9627, 0xEA69, 0x9628, 0xEA6A, 0x9629, 0xEA6B, 0x962B,\r\n\t0xEA6C, 0x962C, 0xEA6D, 0x962D, 0xEA6E, 0x962F, 0xEA6F, 0x9630,\t0xEA70, 0x9637, 0xEA71, 0x9638, 0xEA72, 0x9639, 0xEA73, 0x963A,\r\n\t0xEA74, 0x963E, 0xEA75, 0x9641, 0xEA76, 0x9643, 0xEA77, 0x964A,\t0xEA78, 0x964E, 0xEA79, 0x964F, 0xEA7A, 0x9651, 0xEA7B, 0x9652,\r\n\t0xEA7C, 0x9653, 0xEA7D, 0x9656, 0xEA7E, 0x9657, 0xEA80, 0x9658,\t0xEA81, 0x9659, 0xEA82, 0x965A, 0xEA83, 0x965C, 0xEA84, 0x965D,\r\n\t0xEA85, 0x965E, 0xEA86, 0x9660, 0xEA87, 0x9663, 0xEA88, 0x9665,\t0xEA89, 0x9666, 0xEA8A, 0x966B, 0xEA8B, 0x966D, 0xEA8C, 0x966E,\r\n\t0xEA8D, 0x966F, 0xEA8E, 0x9670, 0xEA8F, 0x9671, 0xEA90, 0x9673,\t0xEA91, 0x9678, 0xEA92, 0x9679, 0xEA93, 0x967A, 0xEA94, 0x967B,\r\n\t0xEA95, 0x967C, 0xEA96, 0x967D, 0xEA97, 0x967E, 0xEA98, 0x967F,\t0xEA99, 0x9680, 0xEA9A, 0x9681, 0xEA9B, 0x9682, 0xEA9C, 0x9683,\r\n\t0xEA9D, 0x9684, 0xEA9E, 0x9687, 0xEA9F, 0x9689, 0xEAA0, 0x968A,\t0xEAA1, 0x8F8D, 0xEAA2, 0x8F8E, 0xEAA3, 0x8F8F, 0xEAA4, 0x8F98,\r\n\t0xEAA5, 0x8F9A, 0xEAA6, 0x8ECE, 0xEAA7, 0x620B, 0xEAA8, 0x6217,\t0xEAA9, 0x621B, 0xEAAA, 0x621F, 0xEAAB, 0x6222, 0xEAAC, 0x6221,\r\n\t0xEAAD, 0x6225, 0xEAAE, 0x6224, 0xEAAF, 0x622C, 0xEAB0, 0x81E7,\t0xEAB1, 0x74EF, 0xEAB2, 0x74F4, 0xEAB3, 0x74FF, 0xEAB4, 0x750F,\r\n\t0xEAB5, 0x7511, 0xEAB6, 0x7513, 0xEAB7, 0x6534, 0xEAB8, 0x65EE,\t0xEAB9, 0x65EF, 0xEABA, 0x65F0, 0xEABB, 0x660A, 0xEABC, 0x6619,\r\n\t0xEABD, 0x6772, 0xEABE, 0x6603, 0xEABF, 0x6615, 0xEAC0, 0x6600,\t0xEAC1, 0x7085, 0xEAC2, 0x66F7, 0xEAC3, 0x661D, 0xEAC4, 0x6634,\r\n\t0xEAC5, 0x6631, 0xEAC6, 0x6636, 0xEAC7, 0x6635, 0xEAC8, 0x8006,\t0xEAC9, 0x665F, 0xEACA, 0x6654, 0xEACB, 0x6641, 0xEACC, 0x664F,\r\n\t0xEACD, 0x6656, 0xEACE, 0x6661, 0xEACF, 0x6657, 0xEAD0, 0x6677,\t0xEAD1, 0x6684, 0xEAD2, 0x668C, 0xEAD3, 0x66A7, 0xEAD4, 0x669D,\r\n\t0xEAD5, 0x66BE, 0xEAD6, 0x66DB, 0xEAD7, 0x66DC, 0xEAD8, 0x66E6,\t0xEAD9, 0x66E9, 0xEADA, 0x8D32, 0xEADB, 0x8D33, 0xEADC, 0x8D36,\r\n\t0xEADD, 0x8D3B, 0xEADE, 0x8D3D, 0xEADF, 0x8D40, 0xEAE0, 0x8D45,\t0xEAE1, 0x8D46, 0xEAE2, 0x8D48, 0xEAE3, 0x8D49, 0xEAE4, 0x8D47,\r\n\t0xEAE5, 0x8D4D, 0xEAE6, 0x8D55, 0xEAE7, 0x8D59, 0xEAE8, 0x89C7,\t0xEAE9, 0x89CA, 0xEAEA, 0x89CB, 0xEAEB, 0x89CC, 0xEAEC, 0x89CE,\r\n\t0xEAED, 0x89CF, 0xEAEE, 0x89D0, 0xEAEF, 0x89D1, 0xEAF0, 0x726E,\t0xEAF1, 0x729F, 0xEAF2, 0x725D, 0xEAF3, 0x7266, 0xEAF4, 0x726F,\r\n\t0xEAF5, 0x727E, 0xEAF6, 0x727F, 0xEAF7, 0x7284, 0xEAF8, 0x728B,\t0xEAF9, 0x728D, 0xEAFA, 0x728F, 0xEAFB, 0x7292, 0xEAFC, 0x6308,\r\n\t0xEAFD, 0x6332, 0xEAFE, 0x63B0, 0xEB40, 0x968C, 0xEB41, 0x968E,\t0xEB42, 0x9691, 0xEB43, 0x9692, 0xEB44, 0x9693, 0xEB45, 0x9695,\r\n\t0xEB46, 0x9696, 0xEB47, 0x969A, 0xEB48, 0x969B, 0xEB49, 0x969D,\t0xEB4A, 0x969E, 0xEB4B, 0x969F, 0xEB4C, 0x96A0, 0xEB4D, 0x96A1,\r\n\t0xEB4E, 0x96A2, 0xEB4F, 0x96A3, 0xEB50, 0x96A4, 0xEB51, 0x96A5,\t0xEB52, 0x96A6, 0xEB53, 0x96A8, 0xEB54, 0x96A9, 0xEB55, 0x96AA,\r\n\t0xEB56, 0x96AB, 0xEB57, 0x96AC, 0xEB58, 0x96AD, 0xEB59, 0x96AE,\t0xEB5A, 0x96AF, 0xEB5B, 0x96B1, 0xEB5C, 0x96B2, 0xEB5D, 0x96B4,\r\n\t0xEB5E, 0x96B5, 0xEB5F, 0x96B7, 0xEB60, 0x96B8, 0xEB61, 0x96BA,\t0xEB62, 0x96BB, 0xEB63, 0x96BF, 0xEB64, 0x96C2, 0xEB65, 0x96C3,\r\n\t0xEB66, 0x96C8, 0xEB67, 0x96CA, 0xEB68, 0x96CB, 0xEB69, 0x96D0,\t0xEB6A, 0x96D1, 0xEB6B, 0x96D3, 0xEB6C, 0x96D4, 0xEB6D, 0x96D6,\r\n\t0xEB6E, 0x96D7, 0xEB6F, 0x96D8, 0xEB70, 0x96D9, 0xEB71, 0x96DA,\t0xEB72, 0x96DB, 0xEB73, 0x96DC, 0xEB74, 0x96DD, 0xEB75, 0x96DE,\r\n\t0xEB76, 0x96DF, 0xEB77, 0x96E1, 0xEB78, 0x96E2, 0xEB79, 0x96E3,\t0xEB7A, 0x96E4, 0xEB7B, 0x96E5, 0xEB7C, 0x96E6, 0xEB7D, 0x96E7,\r\n\t0xEB7E, 0x96EB, 0xEB80, 0x96EC, 0xEB81, 0x96ED, 0xEB82, 0x96EE,\t0xEB83, 0x96F0, 0xEB84, 0x96F1, 0xEB85, 0x96F2, 0xEB86, 0x96F4,\r\n\t0xEB87, 0x96F5, 0xEB88, 0x96F8, 0xEB89, 0x96FA, 0xEB8A, 0x96FB,\t0xEB8B, 0x96FC, 0xEB8C, 0x96FD, 0xEB8D, 0x96FF, 0xEB8E, 0x9702,\r\n\t0xEB8F, 0x9703, 0xEB90, 0x9705, 0xEB91, 0x970A, 0xEB92, 0x970B,\t0xEB93, 0x970C, 0xEB94, 0x9710, 0xEB95, 0x9711, 0xEB96, 0x9712,\r\n\t0xEB97, 0x9714, 0xEB98, 0x9715, 0xEB99, 0x9717, 0xEB9A, 0x9718,\t0xEB9B, 0x9719, 0xEB9C, 0x971A, 0xEB9D, 0x971B, 0xEB9E, 0x971D,\r\n\t0xEB9F, 0x971F, 0xEBA0, 0x9720, 0xEBA1, 0x643F, 0xEBA2, 0x64D8,\t0xEBA3, 0x8004, 0xEBA4, 0x6BEA, 0xEBA5, 0x6BF3, 0xEBA6, 0x6BFD,\r\n\t0xEBA7, 0x6BF5, 0xEBA8, 0x6BF9, 0xEBA9, 0x6C05, 0xEBAA, 0x6C07,\t0xEBAB, 0x6C06, 0xEBAC, 0x6C0D, 0xEBAD, 0x6C15, 0xEBAE, 0x6C18,\r\n\t0xEBAF, 0x6C19, 0xEBB0, 0x6C1A, 0xEBB1, 0x6C21, 0xEBB2, 0x6C29,\t0xEBB3, 0x6C24, 0xEBB4, 0x6C2A, 0xEBB5, 0x6C32, 0xEBB6, 0x6535,\r\n\t0xEBB7, 0x6555, 0xEBB8, 0x656B, 0xEBB9, 0x724D, 0xEBBA, 0x7252,\t0xEBBB, 0x7256, 0xEBBC, 0x7230, 0xEBBD, 0x8662, 0xEBBE, 0x5216,\r\n\t0xEBBF, 0x809F, 0xEBC0, 0x809C, 0xEBC1, 0x8093, 0xEBC2, 0x80BC,\t0xEBC3, 0x670A, 0xEBC4, 0x80BD, 0xEBC5, 0x80B1, 0xEBC6, 0x80AB,\r\n\t0xEBC7, 0x80AD, 0xEBC8, 0x80B4, 0xEBC9, 0x80B7, 0xEBCA, 0x80E7,\t0xEBCB, 0x80E8, 0xEBCC, 0x80E9, 0xEBCD, 0x80EA, 0xEBCE, 0x80DB,\r\n\t0xEBCF, 0x80C2, 0xEBD0, 0x80C4, 0xEBD1, 0x80D9, 0xEBD2, 0x80CD,\t0xEBD3, 0x80D7, 0xEBD4, 0x6710, 0xEBD5, 0x80DD, 0xEBD6, 0x80EB,\r\n\t0xEBD7, 0x80F1, 0xEBD8, 0x80F4, 0xEBD9, 0x80ED, 0xEBDA, 0x810D,\t0xEBDB, 0x810E, 0xEBDC, 0x80F2, 0xEBDD, 0x80FC, 0xEBDE, 0x6715,\r\n\t0xEBDF, 0x8112, 0xEBE0, 0x8C5A, 0xEBE1, 0x8136, 0xEBE2, 0x811E,\t0xEBE3, 0x812C, 0xEBE4, 0x8118, 0xEBE5, 0x8132, 0xEBE6, 0x8148,\r\n\t0xEBE7, 0x814C, 0xEBE8, 0x8153, 0xEBE9, 0x8174, 0xEBEA, 0x8159,\t0xEBEB, 0x815A, 0xEBEC, 0x8171, 0xEBED, 0x8160, 0xEBEE, 0x8169,\r\n\t0xEBEF, 0x817C, 0xEBF0, 0x817D, 0xEBF1, 0x816D, 0xEBF2, 0x8167,\t0xEBF3, 0x584D, 0xEBF4, 0x5AB5, 0xEBF5, 0x8188, 0xEBF6, 0x8182,\r\n\t0xEBF7, 0x8191, 0xEBF8, 0x6ED5, 0xEBF9, 0x81A3, 0xEBFA, 0x81AA,\t0xEBFB, 0x81CC, 0xEBFC, 0x6726, 0xEBFD, 0x81CA, 0xEBFE, 0x81BB,\r\n\t0xEC40, 0x9721, 0xEC41, 0x9722, 0xEC42, 0x9723, 0xEC43, 0x9724,\t0xEC44, 0x9725, 0xEC45, 0x9726, 0xEC46, 0x9727, 0xEC47, 0x9728,\r\n\t0xEC48, 0x9729, 0xEC49, 0x972B, 0xEC4A, 0x972C, 0xEC4B, 0x972E,\t0xEC4C, 0x972F, 0xEC4D, 0x9731, 0xEC4E, 0x9733, 0xEC4F, 0x9734,\r\n\t0xEC50, 0x9735, 0xEC51, 0x9736, 0xEC52, 0x9737, 0xEC53, 0x973A,\t0xEC54, 0x973B, 0xEC55, 0x973C, 0xEC56, 0x973D, 0xEC57, 0x973F,\r\n\t0xEC58, 0x9740, 0xEC59, 0x9741, 0xEC5A, 0x9742, 0xEC5B, 0x9743,\t0xEC5C, 0x9744, 0xEC5D, 0x9745, 0xEC5E, 0x9746, 0xEC5F, 0x9747,\r\n\t0xEC60, 0x9748, 0xEC61, 0x9749, 0xEC62, 0x974A, 0xEC63, 0x974B,\t0xEC64, 0x974C, 0xEC65, 0x974D, 0xEC66, 0x974E, 0xEC67, 0x974F,\r\n\t0xEC68, 0x9750, 0xEC69, 0x9751, 0xEC6A, 0x9754, 0xEC6B, 0x9755,\t0xEC6C, 0x9757, 0xEC6D, 0x9758, 0xEC6E, 0x975A, 0xEC6F, 0x975C,\r\n\t0xEC70, 0x975D, 0xEC71, 0x975F, 0xEC72, 0x9763, 0xEC73, 0x9764,\t0xEC74, 0x9766, 0xEC75, 0x9767, 0xEC76, 0x9768, 0xEC77, 0x976A,\r\n\t0xEC78, 0x976B, 0xEC79, 0x976C, 0xEC7A, 0x976D, 0xEC7B, 0x976E,\t0xEC7C, 0x976F, 0xEC7D, 0x9770, 0xEC7E, 0x9771, 0xEC80, 0x9772,\r\n\t0xEC81, 0x9775, 0xEC82, 0x9777, 0xEC83, 0x9778, 0xEC84, 0x9779,\t0xEC85, 0x977A, 0xEC86, 0x977B, 0xEC87, 0x977D, 0xEC88, 0x977E,\r\n\t0xEC89, 0x977F, 0xEC8A, 0x9780, 0xEC8B, 0x9781, 0xEC8C, 0x9782,\t0xEC8D, 0x9783, 0xEC8E, 0x9784, 0xEC8F, 0x9786, 0xEC90, 0x9787,\r\n\t0xEC91, 0x9788, 0xEC92, 0x9789, 0xEC93, 0x978A, 0xEC94, 0x978C,\t0xEC95, 0x978E, 0xEC96, 0x978F, 0xEC97, 0x9790, 0xEC98, 0x9793,\r\n\t0xEC99, 0x9795, 0xEC9A, 0x9796, 0xEC9B, 0x9797, 0xEC9C, 0x9799,\t0xEC9D, 0x979A, 0xEC9E, 0x979B, 0xEC9F, 0x979C, 0xECA0, 0x979D,\r\n\t0xECA1, 0x81C1, 0xECA2, 0x81A6, 0xECA3, 0x6B24, 0xECA4, 0x6B37,\t0xECA5, 0x6B39, 0xECA6, 0x6B43, 0xECA7, 0x6B46, 0xECA8, 0x6B59,\r\n\t0xECA9, 0x98D1, 0xECAA, 0x98D2, 0xECAB, 0x98D3, 0xECAC, 0x98D5,\t0xECAD, 0x98D9, 0xECAE, 0x98DA, 0xECAF, 0x6BB3, 0xECB0, 0x5F40,\r\n\t0xECB1, 0x6BC2, 0xECB2, 0x89F3, 0xECB3, 0x6590, 0xECB4, 0x9F51,\t0xECB5, 0x6593, 0xECB6, 0x65BC, 0xECB7, 0x65C6, 0xECB8, 0x65C4,\r\n\t0xECB9, 0x65C3, 0xECBA, 0x65CC, 0xECBB, 0x65CE, 0xECBC, 0x65D2,\t0xECBD, 0x65D6, 0xECBE, 0x7080, 0xECBF, 0x709C, 0xECC0, 0x7096,\r\n\t0xECC1, 0x709D, 0xECC2, 0x70BB, 0xECC3, 0x70C0, 0xECC4, 0x70B7,\t0xECC5, 0x70AB, 0xECC6, 0x70B1, 0xECC7, 0x70E8, 0xECC8, 0x70CA,\r\n\t0xECC9, 0x7110, 0xECCA, 0x7113, 0xECCB, 0x7116, 0xECCC, 0x712F,\t0xECCD, 0x7131, 0xECCE, 0x7173, 0xECCF, 0x715C, 0xECD0, 0x7168,\r\n\t0xECD1, 0x7145, 0xECD2, 0x7172, 0xECD3, 0x714A, 0xECD4, 0x7178,\t0xECD5, 0x717A, 0xECD6, 0x7198, 0xECD7, 0x71B3, 0xECD8, 0x71B5,\r\n\t0xECD9, 0x71A8, 0xECDA, 0x71A0, 0xECDB, 0x71E0, 0xECDC, 0x71D4,\t0xECDD, 0x71E7, 0xECDE, 0x71F9, 0xECDF, 0x721D, 0xECE0, 0x7228,\r\n\t0xECE1, 0x706C, 0xECE2, 0x7118, 0xECE3, 0x7166, 0xECE4, 0x71B9,\t0xECE5, 0x623E, 0xECE6, 0x623D, 0xECE7, 0x6243, 0xECE8, 0x6248,\r\n\t0xECE9, 0x6249, 0xECEA, 0x793B, 0xECEB, 0x7940, 0xECEC, 0x7946,\t0xECED, 0x7949, 0xECEE, 0x795B, 0xECEF, 0x795C, 0xECF0, 0x7953,\r\n\t0xECF1, 0x795A, 0xECF2, 0x7962, 0xECF3, 0x7957, 0xECF4, 0x7960,\t0xECF5, 0x796F, 0xECF6, 0x7967, 0xECF7, 0x797A, 0xECF8, 0x7985,\r\n\t0xECF9, 0x798A, 0xECFA, 0x799A, 0xECFB, 0x79A7, 0xECFC, 0x79B3,\t0xECFD, 0x5FD1, 0xECFE, 0x5FD0, 0xED40, 0x979E, 0xED41, 0x979F,\r\n\t0xED42, 0x97A1, 0xED43, 0x97A2, 0xED44, 0x97A4, 0xED45, 0x97A5,\t0xED46, 0x97A6, 0xED47, 0x97A7, 0xED48, 0x97A8, 0xED49, 0x97A9,\r\n\t0xED4A, 0x97AA, 0xED4B, 0x97AC, 0xED4C, 0x97AE, 0xED4D, 0x97B0,\t0xED4E, 0x97B1, 0xED4F, 0x97B3, 0xED50, 0x97B5, 0xED51, 0x97B6,\r\n\t0xED52, 0x97B7, 0xED53, 0x97B8, 0xED54, 0x97B9, 0xED55, 0x97BA,\t0xED56, 0x97BB, 0xED57, 0x97BC, 0xED58, 0x97BD, 0xED59, 0x97BE,\r\n\t0xED5A, 0x97BF, 0xED5B, 0x97C0, 0xED5C, 0x97C1, 0xED5D, 0x97C2,\t0xED5E, 0x97C3, 0xED5F, 0x97C4, 0xED60, 0x97C5, 0xED61, 0x97C6,\r\n\t0xED62, 0x97C7, 0xED63, 0x97C8, 0xED64, 0x97C9, 0xED65, 0x97CA,\t0xED66, 0x97CB, 0xED67, 0x97CC, 0xED68, 0x97CD, 0xED69, 0x97CE,\r\n\t0xED6A, 0x97CF, 0xED6B, 0x97D0, 0xED6C, 0x97D1, 0xED6D, 0x97D2,\t0xED6E, 0x97D3, 0xED6F, 0x97D4, 0xED70, 0x97D5, 0xED71, 0x97D6,\r\n\t0xED72, 0x97D7, 0xED73, 0x97D8, 0xED74, 0x97D9, 0xED75, 0x97DA,\t0xED76, 0x97DB, 0xED77, 0x97DC, 0xED78, 0x97DD, 0xED79, 0x97DE,\r\n\t0xED7A, 0x97DF, 0xED7B, 0x97E0, 0xED7C, 0x97E1, 0xED7D, 0x97E2,\t0xED7E, 0x97E3, 0xED80, 0x97E4, 0xED81, 0x97E5, 0xED82, 0x97E8,\r\n\t0xED83, 0x97EE, 0xED84, 0x97EF, 0xED85, 0x97F0, 0xED86, 0x97F1,\t0xED87, 0x97F2, 0xED88, 0x97F4, 0xED89, 0x97F7, 0xED8A, 0x97F8,\r\n\t0xED8B, 0x97F9, 0xED8C, 0x97FA, 0xED8D, 0x97FB, 0xED8E, 0x97FC,\t0xED8F, 0x97FD, 0xED90, 0x97FE, 0xED91, 0x97FF, 0xED92, 0x9800,\r\n\t0xED93, 0x9801, 0xED94, 0x9802, 0xED95, 0x9803, 0xED96, 0x9804,\t0xED97, 0x9805, 0xED98, 0x9806, 0xED99, 0x9807, 0xED9A, 0x9808,\r\n\t0xED9B, 0x9809, 0xED9C, 0x980A, 0xED9D, 0x980B, 0xED9E, 0x980C,\t0xED9F, 0x980D, 0xEDA0, 0x980E, 0xEDA1, 0x603C, 0xEDA2, 0x605D,\r\n\t0xEDA3, 0x605A, 0xEDA4, 0x6067, 0xEDA5, 0x6041, 0xEDA6, 0x6059,\t0xEDA7, 0x6063, 0xEDA8, 0x60AB, 0xEDA9, 0x6106, 0xEDAA, 0x610D,\r\n\t0xEDAB, 0x615D, 0xEDAC, 0x61A9, 0xEDAD, 0x619D, 0xEDAE, 0x61CB,\t0xEDAF, 0x61D1, 0xEDB0, 0x6206, 0xEDB1, 0x8080, 0xEDB2, 0x807F,\r\n\t0xEDB3, 0x6C93, 0xEDB4, 0x6CF6, 0xEDB5, 0x6DFC, 0xEDB6, 0x77F6,\t0xEDB7, 0x77F8, 0xEDB8, 0x7800, 0xEDB9, 0x7809, 0xEDBA, 0x7817,\r\n\t0xEDBB, 0x7818, 0xEDBC, 0x7811, 0xEDBD, 0x65AB, 0xEDBE, 0x782D,\t0xEDBF, 0x781C, 0xEDC0, 0x781D, 0xEDC1, 0x7839, 0xEDC2, 0x783A,\r\n\t0xEDC3, 0x783B, 0xEDC4, 0x781F, 0xEDC5, 0x783C, 0xEDC6, 0x7825,\t0xEDC7, 0x782C, 0xEDC8, 0x7823, 0xEDC9, 0x7829, 0xEDCA, 0x784E,\r\n\t0xEDCB, 0x786D, 0xEDCC, 0x7856, 0xEDCD, 0x7857, 0xEDCE, 0x7826,\t0xEDCF, 0x7850, 0xEDD0, 0x7847, 0xEDD1, 0x784C, 0xEDD2, 0x786A,\r\n\t0xEDD3, 0x789B, 0xEDD4, 0x7893, 0xEDD5, 0x789A, 0xEDD6, 0x7887,\t0xEDD7, 0x789C, 0xEDD8, 0x78A1, 0xEDD9, 0x78A3, 0xEDDA, 0x78B2,\r\n\t0xEDDB, 0x78B9, 0xEDDC, 0x78A5, 0xEDDD, 0x78D4, 0xEDDE, 0x78D9,\t0xEDDF, 0x78C9, 0xEDE0, 0x78EC, 0xEDE1, 0x78F2, 0xEDE2, 0x7905,\r\n\t0xEDE3, 0x78F4, 0xEDE4, 0x7913, 0xEDE5, 0x7924, 0xEDE6, 0x791E,\t0xEDE7, 0x7934, 0xEDE8, 0x9F9B, 0xEDE9, 0x9EF9, 0xEDEA, 0x9EFB,\r\n\t0xEDEB, 0x9EFC, 0xEDEC, 0x76F1, 0xEDED, 0x7704, 0xEDEE, 0x770D,\t0xEDEF, 0x76F9, 0xEDF0, 0x7707, 0xEDF1, 0x7708, 0xEDF2, 0x771A,\r\n\t0xEDF3, 0x7722, 0xEDF4, 0x7719, 0xEDF5, 0x772D, 0xEDF6, 0x7726,\t0xEDF7, 0x7735, 0xEDF8, 0x7738, 0xEDF9, 0x7750, 0xEDFA, 0x7751,\r\n\t0xEDFB, 0x7747, 0xEDFC, 0x7743, 0xEDFD, 0x775A, 0xEDFE, 0x7768,\t0xEE40, 0x980F, 0xEE41, 0x9810, 0xEE42, 0x9811, 0xEE43, 0x9812,\r\n\t0xEE44, 0x9813, 0xEE45, 0x9814, 0xEE46, 0x9815, 0xEE47, 0x9816,\t0xEE48, 0x9817, 0xEE49, 0x9818, 0xEE4A, 0x9819, 0xEE4B, 0x981A,\r\n\t0xEE4C, 0x981B, 0xEE4D, 0x981C, 0xEE4E, 0x981D, 0xEE4F, 0x981E,\t0xEE50, 0x981F, 0xEE51, 0x9820, 0xEE52, 0x9821, 0xEE53, 0x9822,\r\n\t0xEE54, 0x9823, 0xEE55, 0x9824, 0xEE56, 0x9825, 0xEE57, 0x9826,\t0xEE58, 0x9827, 0xEE59, 0x9828, 0xEE5A, 0x9829, 0xEE5B, 0x982A,\r\n\t0xEE5C, 0x982B, 0xEE5D, 0x982C, 0xEE5E, 0x982D, 0xEE5F, 0x982E,\t0xEE60, 0x982F, 0xEE61, 0x9830, 0xEE62, 0x9831, 0xEE63, 0x9832,\r\n\t0xEE64, 0x9833, 0xEE65, 0x9834, 0xEE66, 0x9835, 0xEE67, 0x9836,\t0xEE68, 0x9837, 0xEE69, 0x9838, 0xEE6A, 0x9839, 0xEE6B, 0x983A,\r\n\t0xEE6C, 0x983B, 0xEE6D, 0x983C, 0xEE6E, 0x983D, 0xEE6F, 0x983E,\t0xEE70, 0x983F, 0xEE71, 0x9840, 0xEE72, 0x9841, 0xEE73, 0x9842,\r\n\t0xEE74, 0x9843, 0xEE75, 0x9844, 0xEE76, 0x9845, 0xEE77, 0x9846,\t0xEE78, 0x9847, 0xEE79, 0x9848, 0xEE7A, 0x9849, 0xEE7B, 0x984A,\r\n\t0xEE7C, 0x984B, 0xEE7D, 0x984C, 0xEE7E, 0x984D, 0xEE80, 0x984E,\t0xEE81, 0x984F, 0xEE82, 0x9850, 0xEE83, 0x9851, 0xEE84, 0x9852,\r\n\t0xEE85, 0x9853, 0xEE86, 0x9854, 0xEE87, 0x9855, 0xEE88, 0x9856,\t0xEE89, 0x9857, 0xEE8A, 0x9858, 0xEE8B, 0x9859, 0xEE8C, 0x985A,\r\n\t0xEE8D, 0x985B, 0xEE8E, 0x985C, 0xEE8F, 0x985D, 0xEE90, 0x985E,\t0xEE91, 0x985F, 0xEE92, 0x9860, 0xEE93, 0x9861, 0xEE94, 0x9862,\r\n\t0xEE95, 0x9863, 0xEE96, 0x9864, 0xEE97, 0x9865, 0xEE98, 0x9866,\t0xEE99, 0x9867, 0xEE9A, 0x9868, 0xEE9B, 0x9869, 0xEE9C, 0x986A,\r\n\t0xEE9D, 0x986B, 0xEE9E, 0x986C, 0xEE9F, 0x986D, 0xEEA0, 0x986E,\t0xEEA1, 0x7762, 0xEEA2, 0x7765, 0xEEA3, 0x777F, 0xEEA4, 0x778D,\r\n\t0xEEA5, 0x777D, 0xEEA6, 0x7780, 0xEEA7, 0x778C, 0xEEA8, 0x7791,\t0xEEA9, 0x779F, 0xEEAA, 0x77A0, 0xEEAB, 0x77B0, 0xEEAC, 0x77B5,\r\n\t0xEEAD, 0x77BD, 0xEEAE, 0x753A, 0xEEAF, 0x7540, 0xEEB0, 0x754E,\t0xEEB1, 0x754B, 0xEEB2, 0x7548, 0xEEB3, 0x755B, 0xEEB4, 0x7572,\r\n\t0xEEB5, 0x7579, 0xEEB6, 0x7583, 0xEEB7, 0x7F58, 0xEEB8, 0x7F61,\t0xEEB9, 0x7F5F, 0xEEBA, 0x8A48, 0xEEBB, 0x7F68, 0xEEBC, 0x7F74,\r\n\t0xEEBD, 0x7F71, 0xEEBE, 0x7F79, 0xEEBF, 0x7F81, 0xEEC0, 0x7F7E,\t0xEEC1, 0x76CD, 0xEEC2, 0x76E5, 0xEEC3, 0x8832, 0xEEC4, 0x9485,\r\n\t0xEEC5, 0x9486, 0xEEC6, 0x9487, 0xEEC7, 0x948B, 0xEEC8, 0x948A,\t0xEEC9, 0x948C, 0xEECA, 0x948D, 0xEECB, 0x948F, 0xEECC, 0x9490,\r\n\t0xEECD, 0x9494, 0xEECE, 0x9497, 0xEECF, 0x9495, 0xEED0, 0x949A,\t0xEED1, 0x949B, 0xEED2, 0x949C, 0xEED3, 0x94A3, 0xEED4, 0x94A4,\r\n\t0xEED5, 0x94AB, 0xEED6, 0x94AA, 0xEED7, 0x94AD, 0xEED8, 0x94AC,\t0xEED9, 0x94AF, 0xEEDA, 0x94B0, 0xEEDB, 0x94B2, 0xEEDC, 0x94B4,\r\n\t0xEEDD, 0x94B6, 0xEEDE, 0x94B7, 0xEEDF, 0x94B8, 0xEEE0, 0x94B9,\t0xEEE1, 0x94BA, 0xEEE2, 0x94BC, 0xEEE3, 0x94BD, 0xEEE4, 0x94BF,\r\n\t0xEEE5, 0x94C4, 0xEEE6, 0x94C8, 0xEEE7, 0x94C9, 0xEEE8, 0x94CA,\t0xEEE9, 0x94CB, 0xEEEA, 0x94CC, 0xEEEB, 0x94CD, 0xEEEC, 0x94CE,\r\n\t0xEEED, 0x94D0, 0xEEEE, 0x94D1, 0xEEEF, 0x94D2, 0xEEF0, 0x94D5,\t0xEEF1, 0x94D6, 0xEEF2, 0x94D7, 0xEEF3, 0x94D9, 0xEEF4, 0x94D8,\r\n\t0xEEF5, 0x94DB, 0xEEF6, 0x94DE, 0xEEF7, 0x94DF, 0xEEF8, 0x94E0,\t0xEEF9, 0x94E2, 0xEEFA, 0x94E4, 0xEEFB, 0x94E5, 0xEEFC, 0x94E7,\r\n\t0xEEFD, 0x94E8, 0xEEFE, 0x94EA, 0xEF40, 0x986F, 0xEF41, 0x9870,\t0xEF42, 0x9871, 0xEF43, 0x9872, 0xEF44, 0x9873, 0xEF45, 0x9874,\r\n\t0xEF46, 0x988B, 0xEF47, 0x988E, 0xEF48, 0x9892, 0xEF49, 0x9895,\t0xEF4A, 0x9899, 0xEF4B, 0x98A3, 0xEF4C, 0x98A8, 0xEF4D, 0x98A9,\r\n\t0xEF4E, 0x98AA, 0xEF4F, 0x98AB, 0xEF50, 0x98AC, 0xEF51, 0x98AD,\t0xEF52, 0x98AE, 0xEF53, 0x98AF, 0xEF54, 0x98B0, 0xEF55, 0x98B1,\r\n\t0xEF56, 0x98B2, 0xEF57, 0x98B3, 0xEF58, 0x98B4, 0xEF59, 0x98B5,\t0xEF5A, 0x98B6, 0xEF5B, 0x98B7, 0xEF5C, 0x98B8, 0xEF5D, 0x98B9,\r\n\t0xEF5E, 0x98BA, 0xEF5F, 0x98BB, 0xEF60, 0x98BC, 0xEF61, 0x98BD,\t0xEF62, 0x98BE, 0xEF63, 0x98BF, 0xEF64, 0x98C0, 0xEF65, 0x98C1,\r\n\t0xEF66, 0x98C2, 0xEF67, 0x98C3, 0xEF68, 0x98C4, 0xEF69, 0x98C5,\t0xEF6A, 0x98C6, 0xEF6B, 0x98C7, 0xEF6C, 0x98C8, 0xEF6D, 0x98C9,\r\n\t0xEF6E, 0x98CA, 0xEF6F, 0x98CB, 0xEF70, 0x98CC, 0xEF71, 0x98CD,\t0xEF72, 0x98CF, 0xEF73, 0x98D0, 0xEF74, 0x98D4, 0xEF75, 0x98D6,\r\n\t0xEF76, 0x98D7, 0xEF77, 0x98DB, 0xEF78, 0x98DC, 0xEF79, 0x98DD,\t0xEF7A, 0x98E0, 0xEF7B, 0x98E1, 0xEF7C, 0x98E2, 0xEF7D, 0x98E3,\r\n\t0xEF7E, 0x98E4, 0xEF80, 0x98E5, 0xEF81, 0x98E6, 0xEF82, 0x98E9,\t0xEF83, 0x98EA, 0xEF84, 0x98EB, 0xEF85, 0x98EC, 0xEF86, 0x98ED,\r\n\t0xEF87, 0x98EE, 0xEF88, 0x98EF, 0xEF89, 0x98F0, 0xEF8A, 0x98F1,\t0xEF8B, 0x98F2, 0xEF8C, 0x98F3, 0xEF8D, 0x98F4, 0xEF8E, 0x98F5,\r\n\t0xEF8F, 0x98F6, 0xEF90, 0x98F7, 0xEF91, 0x98F8, 0xEF92, 0x98F9,\t0xEF93, 0x98FA, 0xEF94, 0x98FB, 0xEF95, 0x98FC, 0xEF96, 0x98FD,\r\n\t0xEF97, 0x98FE, 0xEF98, 0x98FF, 0xEF99, 0x9900, 0xEF9A, 0x9901,\t0xEF9B, 0x9902, 0xEF9C, 0x9903, 0xEF9D, 0x9904, 0xEF9E, 0x9905,\r\n\t0xEF9F, 0x9906, 0xEFA0, 0x9907, 0xEFA1, 0x94E9, 0xEFA2, 0x94EB,\t0xEFA3, 0x94EE, 0xEFA4, 0x94EF, 0xEFA5, 0x94F3, 0xEFA6, 0x94F4,\r\n\t0xEFA7, 0x94F5, 0xEFA8, 0x94F7, 0xEFA9, 0x94F9, 0xEFAA, 0x94FC,\t0xEFAB, 0x94FD, 0xEFAC, 0x94FF, 0xEFAD, 0x9503, 0xEFAE, 0x9502,\r\n\t0xEFAF, 0x9506, 0xEFB0, 0x9507, 0xEFB1, 0x9509, 0xEFB2, 0x950A,\t0xEFB3, 0x950D, 0xEFB4, 0x950E, 0xEFB5, 0x950F, 0xEFB6, 0x9512,\r\n\t0xEFB7, 0x9513, 0xEFB8, 0x9514, 0xEFB9, 0x9515, 0xEFBA, 0x9516,\t0xEFBB, 0x9518, 0xEFBC, 0x951B, 0xEFBD, 0x951D, 0xEFBE, 0x951E,\r\n\t0xEFBF, 0x951F, 0xEFC0, 0x9522, 0xEFC1, 0x952A, 0xEFC2, 0x952B,\t0xEFC3, 0x9529, 0xEFC4, 0x952C, 0xEFC5, 0x9531, 0xEFC6, 0x9532,\r\n\t0xEFC7, 0x9534, 0xEFC8, 0x9536, 0xEFC9, 0x9537, 0xEFCA, 0x9538,\t0xEFCB, 0x953C, 0xEFCC, 0x953E, 0xEFCD, 0x953F, 0xEFCE, 0x9542,\r\n\t0xEFCF, 0x9535, 0xEFD0, 0x9544, 0xEFD1, 0x9545, 0xEFD2, 0x9546,\t0xEFD3, 0x9549, 0xEFD4, 0x954C, 0xEFD5, 0x954E, 0xEFD6, 0x954F,\r\n\t0xEFD7, 0x9552, 0xEFD8, 0x9553, 0xEFD9, 0x9554, 0xEFDA, 0x9556,\t0xEFDB, 0x9557, 0xEFDC, 0x9558, 0xEFDD, 0x9559, 0xEFDE, 0x955B,\r\n\t0xEFDF, 0x955E, 0xEFE0, 0x955F, 0xEFE1, 0x955D, 0xEFE2, 0x9561,\t0xEFE3, 0x9562, 0xEFE4, 0x9564, 0xEFE5, 0x9565, 0xEFE6, 0x9566,\r\n\t0xEFE7, 0x9567, 0xEFE8, 0x9568, 0xEFE9, 0x9569, 0xEFEA, 0x956A,\t0xEFEB, 0x956B, 0xEFEC, 0x956C, 0xEFED, 0x956F, 0xEFEE, 0x9571,\r\n\t0xEFEF, 0x9572, 0xEFF0, 0x9573, 0xEFF1, 0x953A, 0xEFF2, 0x77E7,\t0xEFF3, 0x77EC, 0xEFF4, 0x96C9, 0xEFF5, 0x79D5, 0xEFF6, 0x79ED,\r\n\t0xEFF7, 0x79E3, 0xEFF8, 0x79EB, 0xEFF9, 0x7A06, 0xEFFA, 0x5D47,\t0xEFFB, 0x7A03, 0xEFFC, 0x7A02, 0xEFFD, 0x7A1E, 0xEFFE, 0x7A14,\r\n\t0xF040, 0x9908, 0xF041, 0x9909, 0xF042, 0x990A, 0xF043, 0x990B,\t0xF044, 0x990C, 0xF045, 0x990E, 0xF046, 0x990F, 0xF047, 0x9911,\r\n\t0xF048, 0x9912, 0xF049, 0x9913, 0xF04A, 0x9914, 0xF04B, 0x9915,\t0xF04C, 0x9916, 0xF04D, 0x9917, 0xF04E, 0x9918, 0xF04F, 0x9919,\r\n\t0xF050, 0x991A, 0xF051, 0x991B, 0xF052, 0x991C, 0xF053, 0x991D,\t0xF054, 0x991E, 0xF055, 0x991F, 0xF056, 0x9920, 0xF057, 0x9921,\r\n\t0xF058, 0x9922, 0xF059, 0x9923, 0xF05A, 0x9924, 0xF05B, 0x9925,\t0xF05C, 0x9926, 0xF05D, 0x9927, 0xF05E, 0x9928, 0xF05F, 0x9929,\r\n\t0xF060, 0x992A, 0xF061, 0x992B, 0xF062, 0x992C, 0xF063, 0x992D,\t0xF064, 0x992F, 0xF065, 0x9930, 0xF066, 0x9931, 0xF067, 0x9932,\r\n\t0xF068, 0x9933, 0xF069, 0x9934, 0xF06A, 0x9935, 0xF06B, 0x9936,\t0xF06C, 0x9937, 0xF06D, 0x9938, 0xF06E, 0x9939, 0xF06F, 0x993A,\r\n\t0xF070, 0x993B, 0xF071, 0x993C, 0xF072, 0x993D, 0xF073, 0x993E,\t0xF074, 0x993F, 0xF075, 0x9940, 0xF076, 0x9941, 0xF077, 0x9942,\r\n\t0xF078, 0x9943, 0xF079, 0x9944, 0xF07A, 0x9945, 0xF07B, 0x9946,\t0xF07C, 0x9947, 0xF07D, 0x9948, 0xF07E, 0x9949, 0xF080, 0x994A,\r\n\t0xF081, 0x994B, 0xF082, 0x994C, 0xF083, 0x994D, 0xF084, 0x994E,\t0xF085, 0x994F, 0xF086, 0x9950, 0xF087, 0x9951, 0xF088, 0x9952,\r\n\t0xF089, 0x9953, 0xF08A, 0x9956, 0xF08B, 0x9957, 0xF08C, 0x9958,\t0xF08D, 0x9959, 0xF08E, 0x995A, 0xF08F, 0x995B, 0xF090, 0x995C,\r\n\t0xF091, 0x995D, 0xF092, 0x995E, 0xF093, 0x995F, 0xF094, 0x9960,\t0xF095, 0x9961, 0xF096, 0x9962, 0xF097, 0x9964, 0xF098, 0x9966,\r\n\t0xF099, 0x9973, 0xF09A, 0x9978, 0xF09B, 0x9979, 0xF09C, 0x997B,\t0xF09D, 0x997E, 0xF09E, 0x9982, 0xF09F, 0x9983, 0xF0A0, 0x9989,\r\n\t0xF0A1, 0x7A39, 0xF0A2, 0x7A37, 0xF0A3, 0x7A51, 0xF0A4, 0x9ECF,\t0xF0A5, 0x99A5, 0xF0A6, 0x7A70, 0xF0A7, 0x7688, 0xF0A8, 0x768E,\r\n\t0xF0A9, 0x7693, 0xF0AA, 0x7699, 0xF0AB, 0x76A4, 0xF0AC, 0x74DE,\t0xF0AD, 0x74E0, 0xF0AE, 0x752C, 0xF0AF, 0x9E20, 0xF0B0, 0x9E22,\r\n\t0xF0B1, 0x9E28, 0xF0B2, 0x9E29, 0xF0B3, 0x9E2A, 0xF0B4, 0x9E2B,\t0xF0B5, 0x9E2C, 0xF0B6, 0x9E32, 0xF0B7, 0x9E31, 0xF0B8, 0x9E36,\r\n\t0xF0B9, 0x9E38, 0xF0BA, 0x9E37, 0xF0BB, 0x9E39, 0xF0BC, 0x9E3A,\t0xF0BD, 0x9E3E, 0xF0BE, 0x9E41, 0xF0BF, 0x9E42, 0xF0C0, 0x9E44,\r\n\t0xF0C1, 0x9E46, 0xF0C2, 0x9E47, 0xF0C3, 0x9E48, 0xF0C4, 0x9E49,\t0xF0C5, 0x9E4B, 0xF0C6, 0x9E4C, 0xF0C7, 0x9E4E, 0xF0C8, 0x9E51,\r\n\t0xF0C9, 0x9E55, 0xF0CA, 0x9E57, 0xF0CB, 0x9E5A, 0xF0CC, 0x9E5B,\t0xF0CD, 0x9E5C, 0xF0CE, 0x9E5E, 0xF0CF, 0x9E63, 0xF0D0, 0x9E66,\r\n\t0xF0D1, 0x9E67, 0xF0D2, 0x9E68, 0xF0D3, 0x9E69, 0xF0D4, 0x9E6A,\t0xF0D5, 0x9E6B, 0xF0D6, 0x9E6C, 0xF0D7, 0x9E71, 0xF0D8, 0x9E6D,\r\n\t0xF0D9, 0x9E73, 0xF0DA, 0x7592, 0xF0DB, 0x7594, 0xF0DC, 0x7596,\t0xF0DD, 0x75A0, 0xF0DE, 0x759D, 0xF0DF, 0x75AC, 0xF0E0, 0x75A3,\r\n\t0xF0E1, 0x75B3, 0xF0E2, 0x75B4, 0xF0E3, 0x75B8, 0xF0E4, 0x75C4,\t0xF0E5, 0x75B1, 0xF0E6, 0x75B0, 0xF0E7, 0x75C3, 0xF0E8, 0x75C2,\r\n\t0xF0E9, 0x75D6, 0xF0EA, 0x75CD, 0xF0EB, 0x75E3, 0xF0EC, 0x75E8,\t0xF0ED, 0x75E6, 0xF0EE, 0x75E4, 0xF0EF, 0x75EB, 0xF0F0, 0x75E7,\r\n\t0xF0F1, 0x7603, 0xF0F2, 0x75F1, 0xF0F3, 0x75FC, 0xF0F4, 0x75FF,\t0xF0F5, 0x7610, 0xF0F6, 0x7600, 0xF0F7, 0x7605, 0xF0F8, 0x760C,\r\n\t0xF0F9, 0x7617, 0xF0FA, 0x760A, 0xF0FB, 0x7625, 0xF0FC, 0x7618,\t0xF0FD, 0x7615, 0xF0FE, 0x7619, 0xF140, 0x998C, 0xF141, 0x998E,\r\n\t0xF142, 0x999A, 0xF143, 0x999B, 0xF144, 0x999C, 0xF145, 0x999D,\t0xF146, 0x999E, 0xF147, 0x999F, 0xF148, 0x99A0, 0xF149, 0x99A1,\r\n\t0xF14A, 0x99A2, 0xF14B, 0x99A3, 0xF14C, 0x99A4, 0xF14D, 0x99A6,\t0xF14E, 0x99A7, 0xF14F, 0x99A9, 0xF150, 0x99AA, 0xF151, 0x99AB,\r\n\t0xF152, 0x99AC, 0xF153, 0x99AD, 0xF154, 0x99AE, 0xF155, 0x99AF,\t0xF156, 0x99B0, 0xF157, 0x99B1, 0xF158, 0x99B2, 0xF159, 0x99B3,\r\n\t0xF15A, 0x99B4, 0xF15B, 0x99B5, 0xF15C, 0x99B6, 0xF15D, 0x99B7,\t0xF15E, 0x99B8, 0xF15F, 0x99B9, 0xF160, 0x99BA, 0xF161, 0x99BB,\r\n\t0xF162, 0x99BC, 0xF163, 0x99BD, 0xF164, 0x99BE, 0xF165, 0x99BF,\t0xF166, 0x99C0, 0xF167, 0x99C1, 0xF168, 0x99C2, 0xF169, 0x99C3,\r\n\t0xF16A, 0x99C4, 0xF16B, 0x99C5, 0xF16C, 0x99C6, 0xF16D, 0x99C7,\t0xF16E, 0x99C8, 0xF16F, 0x99C9, 0xF170, 0x99CA, 0xF171, 0x99CB,\r\n\t0xF172, 0x99CC, 0xF173, 0x99CD, 0xF174, 0x99CE, 0xF175, 0x99CF,\t0xF176, 0x99D0, 0xF177, 0x99D1, 0xF178, 0x99D2, 0xF179, 0x99D3,\r\n\t0xF17A, 0x99D4, 0xF17B, 0x99D5, 0xF17C, 0x99D6, 0xF17D, 0x99D7,\t0xF17E, 0x99D8, 0xF180, 0x99D9, 0xF181, 0x99DA, 0xF182, 0x99DB,\r\n\t0xF183, 0x99DC, 0xF184, 0x99DD, 0xF185, 0x99DE, 0xF186, 0x99DF,\t0xF187, 0x99E0, 0xF188, 0x99E1, 0xF189, 0x99E2, 0xF18A, 0x99E3,\r\n\t0xF18B, 0x99E4, 0xF18C, 0x99E5, 0xF18D, 0x99E6, 0xF18E, 0x99E7,\t0xF18F, 0x99E8, 0xF190, 0x99E9, 0xF191, 0x99EA, 0xF192, 0x99EB,\r\n\t0xF193, 0x99EC, 0xF194, 0x99ED, 0xF195, 0x99EE, 0xF196, 0x99EF,\t0xF197, 0x99F0, 0xF198, 0x99F1, 0xF199, 0x99F2, 0xF19A, 0x99F3,\r\n\t0xF19B, 0x99F4, 0xF19C, 0x99F5, 0xF19D, 0x99F6, 0xF19E, 0x99F7,\t0xF19F, 0x99F8, 0xF1A0, 0x99F9, 0xF1A1, 0x761B, 0xF1A2, 0x763C,\r\n\t0xF1A3, 0x7622, 0xF1A4, 0x7620, 0xF1A5, 0x7640, 0xF1A6, 0x762D,\t0xF1A7, 0x7630, 0xF1A8, 0x763F, 0xF1A9, 0x7635, 0xF1AA, 0x7643,\r\n\t0xF1AB, 0x763E, 0xF1AC, 0x7633, 0xF1AD, 0x764D, 0xF1AE, 0x765E,\t0xF1AF, 0x7654, 0xF1B0, 0x765C, 0xF1B1, 0x7656, 0xF1B2, 0x766B,\r\n\t0xF1B3, 0x766F, 0xF1B4, 0x7FCA, 0xF1B5, 0x7AE6, 0xF1B6, 0x7A78,\t0xF1B7, 0x7A79, 0xF1B8, 0x7A80, 0xF1B9, 0x7A86, 0xF1BA, 0x7A88,\r\n\t0xF1BB, 0x7A95, 0xF1BC, 0x7AA6, 0xF1BD, 0x7AA0, 0xF1BE, 0x7AAC,\t0xF1BF, 0x7AA8, 0xF1C0, 0x7AAD, 0xF1C1, 0x7AB3, 0xF1C2, 0x8864,\r\n\t0xF1C3, 0x8869, 0xF1C4, 0x8872, 0xF1C5, 0x887D, 0xF1C6, 0x887F,\t0xF1C7, 0x8882, 0xF1C8, 0x88A2, 0xF1C9, 0x88C6, 0xF1CA, 0x88B7,\r\n\t0xF1CB, 0x88BC, 0xF1CC, 0x88C9, 0xF1CD, 0x88E2, 0xF1CE, 0x88CE,\t0xF1CF, 0x88E3, 0xF1D0, 0x88E5, 0xF1D1, 0x88F1, 0xF1D2, 0x891A,\r\n\t0xF1D3, 0x88FC, 0xF1D4, 0x88E8, 0xF1D5, 0x88FE, 0xF1D6, 0x88F0,\t0xF1D7, 0x8921, 0xF1D8, 0x8919, 0xF1D9, 0x8913, 0xF1DA, 0x891B,\r\n\t0xF1DB, 0x890A, 0xF1DC, 0x8934, 0xF1DD, 0x892B, 0xF1DE, 0x8936,\t0xF1DF, 0x8941, 0xF1E0, 0x8966, 0xF1E1, 0x897B, 0xF1E2, 0x758B,\r\n\t0xF1E3, 0x80E5, 0xF1E4, 0x76B2, 0xF1E5, 0x76B4, 0xF1E6, 0x77DC,\t0xF1E7, 0x8012, 0xF1E8, 0x8014, 0xF1E9, 0x8016, 0xF1EA, 0x801C,\r\n\t0xF1EB, 0x8020, 0xF1EC, 0x8022, 0xF1ED, 0x8025, 0xF1EE, 0x8026,\t0xF1EF, 0x8027, 0xF1F0, 0x8029, 0xF1F1, 0x8028, 0xF1F2, 0x8031,\r\n\t0xF1F3, 0x800B, 0xF1F4, 0x8035, 0xF1F5, 0x8043, 0xF1F6, 0x8046,\t0xF1F7, 0x804D, 0xF1F8, 0x8052, 0xF1F9, 0x8069, 0xF1FA, 0x8071,\r\n\t0xF1FB, 0x8983, 0xF1FC, 0x9878, 0xF1FD, 0x9880, 0xF1FE, 0x9883,\t0xF240, 0x99FA, 0xF241, 0x99FB, 0xF242, 0x99FC, 0xF243, 0x99FD,\r\n\t0xF244, 0x99FE, 0xF245, 0x99FF, 0xF246, 0x9A00, 0xF247, 0x9A01,\t0xF248, 0x9A02, 0xF249, 0x9A03, 0xF24A, 0x9A04, 0xF24B, 0x9A05,\r\n\t0xF24C, 0x9A06, 0xF24D, 0x9A07, 0xF24E, 0x9A08, 0xF24F, 0x9A09,\t0xF250, 0x9A0A, 0xF251, 0x9A0B, 0xF252, 0x9A0C, 0xF253, 0x9A0D,\r\n\t0xF254, 0x9A0E, 0xF255, 0x9A0F, 0xF256, 0x9A10, 0xF257, 0x9A11,\t0xF258, 0x9A12, 0xF259, 0x9A13, 0xF25A, 0x9A14, 0xF25B, 0x9A15,\r\n\t0xF25C, 0x9A16, 0xF25D, 0x9A17, 0xF25E, 0x9A18, 0xF25F, 0x9A19,\t0xF260, 0x9A1A, 0xF261, 0x9A1B, 0xF262, 0x9A1C, 0xF263, 0x9A1D,\r\n\t0xF264, 0x9A1E, 0xF265, 0x9A1F, 0xF266, 0x9A20, 0xF267, 0x9A21,\t0xF268, 0x9A22, 0xF269, 0x9A23, 0xF26A, 0x9A24, 0xF26B, 0x9A25,\r\n\t0xF26C, 0x9A26, 0xF26D, 0x9A27, 0xF26E, 0x9A28, 0xF26F, 0x9A29,\t0xF270, 0x9A2A, 0xF271, 0x9A2B, 0xF272, 0x9A2C, 0xF273, 0x9A2D,\r\n\t0xF274, 0x9A2E, 0xF275, 0x9A2F, 0xF276, 0x9A30, 0xF277, 0x9A31,\t0xF278, 0x9A32, 0xF279, 0x9A33, 0xF27A, 0x9A34, 0xF27B, 0x9A35,\r\n\t0xF27C, 0x9A36, 0xF27D, 0x9A37, 0xF27E, 0x9A38, 0xF280, 0x9A39,\t0xF281, 0x9A3A, 0xF282, 0x9A3B, 0xF283, 0x9A3C, 0xF284, 0x9A3D,\r\n\t0xF285, 0x9A3E, 0xF286, 0x9A3F, 0xF287, 0x9A40, 0xF288, 0x9A41,\t0xF289, 0x9A42, 0xF28A, 0x9A43, 0xF28B, 0x9A44, 0xF28C, 0x9A45,\r\n\t0xF28D, 0x9A46, 0xF28E, 0x9A47, 0xF28F, 0x9A48, 0xF290, 0x9A49,\t0xF291, 0x9A4A, 0xF292, 0x9A4B, 0xF293, 0x9A4C, 0xF294, 0x9A4D,\r\n\t0xF295, 0x9A4E, 0xF296, 0x9A4F, 0xF297, 0x9A50, 0xF298, 0x9A51,\t0xF299, 0x9A52, 0xF29A, 0x9A53, 0xF29B, 0x9A54, 0xF29C, 0x9A55,\r\n\t0xF29D, 0x9A56, 0xF29E, 0x9A57, 0xF29F, 0x9A58, 0xF2A0, 0x9A59,\t0xF2A1, 0x9889, 0xF2A2, 0x988C, 0xF2A3, 0x988D, 0xF2A4, 0x988F,\r\n\t0xF2A5, 0x9894, 0xF2A6, 0x989A, 0xF2A7, 0x989B, 0xF2A8, 0x989E,\t0xF2A9, 0x989F, 0xF2AA, 0x98A1, 0xF2AB, 0x98A2, 0xF2AC, 0x98A5,\r\n\t0xF2AD, 0x98A6, 0xF2AE, 0x864D, 0xF2AF, 0x8654, 0xF2B0, 0x866C,\t0xF2B1, 0x866E, 0xF2B2, 0x867F, 0xF2B3, 0x867A, 0xF2B4, 0x867C,\r\n\t0xF2B5, 0x867B, 0xF2B6, 0x86A8, 0xF2B7, 0x868D, 0xF2B8, 0x868B,\t0xF2B9, 0x86AC, 0xF2BA, 0x869D, 0xF2BB, 0x86A7, 0xF2BC, 0x86A3,\r\n\t0xF2BD, 0x86AA, 0xF2BE, 0x8693, 0xF2BF, 0x86A9, 0xF2C0, 0x86B6,\t0xF2C1, 0x86C4, 0xF2C2, 0x86B5, 0xF2C3, 0x86CE, 0xF2C4, 0x86B0,\r\n\t0xF2C5, 0x86BA, 0xF2C6, 0x86B1, 0xF2C7, 0x86AF, 0xF2C8, 0x86C9,\t0xF2C9, 0x86CF, 0xF2CA, 0x86B4, 0xF2CB, 0x86E9, 0xF2CC, 0x86F1,\r\n\t0xF2CD, 0x86F2, 0xF2CE, 0x86ED, 0xF2CF, 0x86F3, 0xF2D0, 0x86D0,\t0xF2D1, 0x8713, 0xF2D2, 0x86DE, 0xF2D3, 0x86F4, 0xF2D4, 0x86DF,\r\n\t0xF2D5, 0x86D8, 0xF2D6, 0x86D1, 0xF2D7, 0x8703, 0xF2D8, 0x8707,\t0xF2D9, 0x86F8, 0xF2DA, 0x8708, 0xF2DB, 0x870A, 0xF2DC, 0x870D,\r\n\t0xF2DD, 0x8709, 0xF2DE, 0x8723, 0xF2DF, 0x873B, 0xF2E0, 0x871E,\t0xF2E1, 0x8725, 0xF2E2, 0x872E, 0xF2E3, 0x871A, 0xF2E4, 0x873E,\r\n\t0xF2E5, 0x8748, 0xF2E6, 0x8734, 0xF2E7, 0x8731, 0xF2E8, 0x8729,\t0xF2E9, 0x8737, 0xF2EA, 0x873F, 0xF2EB, 0x8782, 0xF2EC, 0x8722,\r\n\t0xF2ED, 0x877D, 0xF2EE, 0x877E, 0xF2EF, 0x877B, 0xF2F0, 0x8760,\t0xF2F1, 0x8770, 0xF2F2, 0x874C, 0xF2F3, 0x876E, 0xF2F4, 0x878B,\r\n\t0xF2F5, 0x8753, 0xF2F6, 0x8763, 0xF2F7, 0x877C, 0xF2F8, 0x8764,\t0xF2F9, 0x8759, 0xF2FA, 0x8765, 0xF2FB, 0x8793, 0xF2FC, 0x87AF,\r\n\t0xF2FD, 0x87A8, 0xF2FE, 0x87D2, 0xF340, 0x9A5A, 0xF341, 0x9A5B,\t0xF342, 0x9A5C, 0xF343, 0x9A5D, 0xF344, 0x9A5E, 0xF345, 0x9A5F,\r\n\t0xF346, 0x9A60, 0xF347, 0x9A61, 0xF348, 0x9A62, 0xF349, 0x9A63,\t0xF34A, 0x9A64, 0xF34B, 0x9A65, 0xF34C, 0x9A66, 0xF34D, 0x9A67,\r\n\t0xF34E, 0x9A68, 0xF34F, 0x9A69, 0xF350, 0x9A6A, 0xF351, 0x9A6B,\t0xF352, 0x9A72, 0xF353, 0x9A83, 0xF354, 0x9A89, 0xF355, 0x9A8D,\r\n\t0xF356, 0x9A8E, 0xF357, 0x9A94, 0xF358, 0x9A95, 0xF359, 0x9A99,\t0xF35A, 0x9AA6, 0xF35B, 0x9AA9, 0xF35C, 0x9AAA, 0xF35D, 0x9AAB,\r\n\t0xF35E, 0x9AAC, 0xF35F, 0x9AAD, 0xF360, 0x9AAE, 0xF361, 0x9AAF,\t0xF362, 0x9AB2, 0xF363, 0x9AB3, 0xF364, 0x9AB4, 0xF365, 0x9AB5,\r\n\t0xF366, 0x9AB9, 0xF367, 0x9ABB, 0xF368, 0x9ABD, 0xF369, 0x9ABE,\t0xF36A, 0x9ABF, 0xF36B, 0x9AC3, 0xF36C, 0x9AC4, 0xF36D, 0x9AC6,\r\n\t0xF36E, 0x9AC7, 0xF36F, 0x9AC8, 0xF370, 0x9AC9, 0xF371, 0x9ACA,\t0xF372, 0x9ACD, 0xF373, 0x9ACE, 0xF374, 0x9ACF, 0xF375, 0x9AD0,\r\n\t0xF376, 0x9AD2, 0xF377, 0x9AD4, 0xF378, 0x9AD5, 0xF379, 0x9AD6,\t0xF37A, 0x9AD7, 0xF37B, 0x9AD9, 0xF37C, 0x9ADA, 0xF37D, 0x9ADB,\r\n\t0xF37E, 0x9ADC, 0xF380, 0x9ADD, 0xF381, 0x9ADE, 0xF382, 0x9AE0,\t0xF383, 0x9AE2, 0xF384, 0x9AE3, 0xF385, 0x9AE4, 0xF386, 0x9AE5,\r\n\t0xF387, 0x9AE7, 0xF388, 0x9AE8, 0xF389, 0x9AE9, 0xF38A, 0x9AEA,\t0xF38B, 0x9AEC, 0xF38C, 0x9AEE, 0xF38D, 0x9AF0, 0xF38E, 0x9AF1,\r\n\t0xF38F, 0x9AF2, 0xF390, 0x9AF3, 0xF391, 0x9AF4, 0xF392, 0x9AF5,\t0xF393, 0x9AF6, 0xF394, 0x9AF7, 0xF395, 0x9AF8, 0xF396, 0x9AFA,\r\n\t0xF397, 0x9AFC, 0xF398, 0x9AFD, 0xF399, 0x9AFE, 0xF39A, 0x9AFF,\t0xF39B, 0x9B00, 0xF39C, 0x9B01, 0xF39D, 0x9B02, 0xF39E, 0x9B04,\r\n\t0xF39F, 0x9B05, 0xF3A0, 0x9B06, 0xF3A1, 0x87C6, 0xF3A2, 0x8788,\t0xF3A3, 0x8785, 0xF3A4, 0x87AD, 0xF3A5, 0x8797, 0xF3A6, 0x8783,\r\n\t0xF3A7, 0x87AB, 0xF3A8, 0x87E5, 0xF3A9, 0x87AC, 0xF3AA, 0x87B5,\t0xF3AB, 0x87B3, 0xF3AC, 0x87CB, 0xF3AD, 0x87D3, 0xF3AE, 0x87BD,\r\n\t0xF3AF, 0x87D1, 0xF3B0, 0x87C0, 0xF3B1, 0x87CA, 0xF3B2, 0x87DB,\t0xF3B3, 0x87EA, 0xF3B4, 0x87E0, 0xF3B5, 0x87EE, 0xF3B6, 0x8816,\r\n\t0xF3B7, 0x8813, 0xF3B8, 0x87FE, 0xF3B9, 0x880A, 0xF3BA, 0x881B,\t0xF3BB, 0x8821, 0xF3BC, 0x8839, 0xF3BD, 0x883C, 0xF3BE, 0x7F36,\r\n\t0xF3BF, 0x7F42, 0xF3C0, 0x7F44, 0xF3C1, 0x7F45, 0xF3C2, 0x8210,\t0xF3C3, 0x7AFA, 0xF3C4, 0x7AFD, 0xF3C5, 0x7B08, 0xF3C6, 0x7B03,\r\n\t0xF3C7, 0x7B04, 0xF3C8, 0x7B15, 0xF3C9, 0x7B0A, 0xF3CA, 0x7B2B,\t0xF3CB, 0x7B0F, 0xF3CC, 0x7B47, 0xF3CD, 0x7B38, 0xF3CE, 0x7B2A,\r\n\t0xF3CF, 0x7B19, 0xF3D0, 0x7B2E, 0xF3D1, 0x7B31, 0xF3D2, 0x7B20,\t0xF3D3, 0x7B25, 0xF3D4, 0x7B24, 0xF3D5, 0x7B33, 0xF3D6, 0x7B3E,\r\n\t0xF3D7, 0x7B1E, 0xF3D8, 0x7B58, 0xF3D9, 0x7B5A, 0xF3DA, 0x7B45,\t0xF3DB, 0x7B75, 0xF3DC, 0x7B4C, 0xF3DD, 0x7B5D, 0xF3DE, 0x7B60,\r\n\t0xF3DF, 0x7B6E, 0xF3E0, 0x7B7B, 0xF3E1, 0x7B62, 0xF3E2, 0x7B72,\t0xF3E3, 0x7B71, 0xF3E4, 0x7B90, 0xF3E5, 0x7BA6, 0xF3E6, 0x7BA7,\r\n\t0xF3E7, 0x7BB8, 0xF3E8, 0x7BAC, 0xF3E9, 0x7B9D, 0xF3EA, 0x7BA8,\t0xF3EB, 0x7B85, 0xF3EC, 0x7BAA, 0xF3ED, 0x7B9C, 0xF3EE, 0x7BA2,\r\n\t0xF3EF, 0x7BAB, 0xF3F0, 0x7BB4, 0xF3F1, 0x7BD1, 0xF3F2, 0x7BC1,\t0xF3F3, 0x7BCC, 0xF3F4, 0x7BDD, 0xF3F5, 0x7BDA, 0xF3F6, 0x7BE5,\r\n\t0xF3F7, 0x7BE6, 0xF3F8, 0x7BEA, 0xF3F9, 0x7C0C, 0xF3FA, 0x7BFE,\t0xF3FB, 0x7BFC, 0xF3FC, 0x7C0F, 0xF3FD, 0x7C16, 0xF3FE, 0x7C0B,\r\n\t0xF440, 0x9B07, 0xF441, 0x9B09, 0xF442, 0x9B0A, 0xF443, 0x9B0B,\t0xF444, 0x9B0C, 0xF445, 0x9B0D, 0xF446, 0x9B0E, 0xF447, 0x9B10,\r\n\t0xF448, 0x9B11, 0xF449, 0x9B12, 0xF44A, 0x9B14, 0xF44B, 0x9B15,\t0xF44C, 0x9B16, 0xF44D, 0x9B17, 0xF44E, 0x9B18, 0xF44F, 0x9B19,\r\n\t0xF450, 0x9B1A, 0xF451, 0x9B1B, 0xF452, 0x9B1C, 0xF453, 0x9B1D,\t0xF454, 0x9B1E, 0xF455, 0x9B20, 0xF456, 0x9B21, 0xF457, 0x9B22,\r\n\t0xF458, 0x9B24, 0xF459, 0x9B25, 0xF45A, 0x9B26, 0xF45B, 0x9B27,\t0xF45C, 0x9B28, 0xF45D, 0x9B29, 0xF45E, 0x9B2A, 0xF45F, 0x9B2B,\r\n\t0xF460, 0x9B2C, 0xF461, 0x9B2D, 0xF462, 0x9B2E, 0xF463, 0x9B30,\t0xF464, 0x9B31, 0xF465, 0x9B33, 0xF466, 0x9B34, 0xF467, 0x9B35,\r\n\t0xF468, 0x9B36, 0xF469, 0x9B37, 0xF46A, 0x9B38, 0xF46B, 0x9B39,\t0xF46C, 0x9B3A, 0xF46D, 0x9B3D, 0xF46E, 0x9B3E, 0xF46F, 0x9B3F,\r\n\t0xF470, 0x9B40, 0xF471, 0x9B46, 0xF472, 0x9B4A, 0xF473, 0x9B4B,\t0xF474, 0x9B4C, 0xF475, 0x9B4E, 0xF476, 0x9B50, 0xF477, 0x9B52,\r\n\t0xF478, 0x9B53, 0xF479, 0x9B55, 0xF47A, 0x9B56, 0xF47B, 0x9B57,\t0xF47C, 0x9B58, 0xF47D, 0x9B59, 0xF47E, 0x9B5A, 0xF480, 0x9B5B,\r\n\t0xF481, 0x9B5C, 0xF482, 0x9B5D, 0xF483, 0x9B5E, 0xF484, 0x9B5F,\t0xF485, 0x9B60, 0xF486, 0x9B61, 0xF487, 0x9B62, 0xF488, 0x9B63,\r\n\t0xF489, 0x9B64, 0xF48A, 0x9B65, 0xF48B, 0x9B66, 0xF48C, 0x9B67,\t0xF48D, 0x9B68, 0xF48E, 0x9B69, 0xF48F, 0x9B6A, 0xF490, 0x9B6B,\r\n\t0xF491, 0x9B6C, 0xF492, 0x9B6D, 0xF493, 0x9B6E, 0xF494, 0x9B6F,\t0xF495, 0x9B70, 0xF496, 0x9B71, 0xF497, 0x9B72, 0xF498, 0x9B73,\r\n\t0xF499, 0x9B74, 0xF49A, 0x9B75, 0xF49B, 0x9B76, 0xF49C, 0x9B77,\t0xF49D, 0x9B78, 0xF49E, 0x9B79, 0xF49F, 0x9B7A, 0xF4A0, 0x9B7B,\r\n\t0xF4A1, 0x7C1F, 0xF4A2, 0x7C2A, 0xF4A3, 0x7C26, 0xF4A4, 0x7C38,\t0xF4A5, 0x7C41, 0xF4A6, 0x7C40, 0xF4A7, 0x81FE, 0xF4A8, 0x8201,\r\n\t0xF4A9, 0x8202, 0xF4AA, 0x8204, 0xF4AB, 0x81EC, 0xF4AC, 0x8844,\t0xF4AD, 0x8221, 0xF4AE, 0x8222, 0xF4AF, 0x8223, 0xF4B0, 0x822D,\r\n\t0xF4B1, 0x822F, 0xF4B2, 0x8228, 0xF4B3, 0x822B, 0xF4B4, 0x8238,\t0xF4B5, 0x823B, 0xF4B6, 0x8233, 0xF4B7, 0x8234, 0xF4B8, 0x823E,\r\n\t0xF4B9, 0x8244, 0xF4BA, 0x8249, 0xF4BB, 0x824B, 0xF4BC, 0x824F,\t0xF4BD, 0x825A, 0xF4BE, 0x825F, 0xF4BF, 0x8268, 0xF4C0, 0x887E,\r\n\t0xF4C1, 0x8885, 0xF4C2, 0x8888, 0xF4C3, 0x88D8, 0xF4C4, 0x88DF,\t0xF4C5, 0x895E, 0xF4C6, 0x7F9D, 0xF4C7, 0x7F9F, 0xF4C8, 0x7FA7,\r\n\t0xF4C9, 0x7FAF, 0xF4CA, 0x7FB0, 0xF4CB, 0x7FB2, 0xF4CC, 0x7C7C,\t0xF4CD, 0x6549, 0xF4CE, 0x7C91, 0xF4CF, 0x7C9D, 0xF4D0, 0x7C9C,\r\n\t0xF4D1, 0x7C9E, 0xF4D2, 0x7CA2, 0xF4D3, 0x7CB2, 0xF4D4, 0x7CBC,\t0xF4D5, 0x7CBD, 0xF4D6, 0x7CC1, 0xF4D7, 0x7CC7, 0xF4D8, 0x7CCC,\r\n\t0xF4D9, 0x7CCD, 0xF4DA, 0x7CC8, 0xF4DB, 0x7CC5, 0xF4DC, 0x7CD7,\t0xF4DD, 0x7CE8, 0xF4DE, 0x826E, 0xF4DF, 0x66A8, 0xF4E0, 0x7FBF,\r\n\t0xF4E1, 0x7FCE, 0xF4E2, 0x7FD5, 0xF4E3, 0x7FE5, 0xF4E4, 0x7FE1,\t0xF4E5, 0x7FE6, 0xF4E6, 0x7FE9, 0xF4E7, 0x7FEE, 0xF4E8, 0x7FF3,\r\n\t0xF4E9, 0x7CF8, 0xF4EA, 0x7D77, 0xF4EB, 0x7DA6, 0xF4EC, 0x7DAE,\t0xF4ED, 0x7E47, 0xF4EE, 0x7E9B, 0xF4EF, 0x9EB8, 0xF4F0, 0x9EB4,\r\n\t0xF4F1, 0x8D73, 0xF4F2, 0x8D84, 0xF4F3, 0x8D94, 0xF4F4, 0x8D91,\t0xF4F5, 0x8DB1, 0xF4F6, 0x8D67, 0xF4F7, 0x8D6D, 0xF4F8, 0x8C47,\r\n\t0xF4F9, 0x8C49, 0xF4FA, 0x914A, 0xF4FB, 0x9150, 0xF4FC, 0x914E,\t0xF4FD, 0x914F, 0xF4FE, 0x9164, 0xF540, 0x9B7C, 0xF541, 0x9B7D,\r\n\t0xF542, 0x9B7E, 0xF543, 0x9B7F, 0xF544, 0x9B80, 0xF545, 0x9B81,\t0xF546, 0x9B82, 0xF547, 0x9B83, 0xF548, 0x9B84, 0xF549, 0x9B85,\r\n\t0xF54A, 0x9B86, 0xF54B, 0x9B87, 0xF54C, 0x9B88, 0xF54D, 0x9B89,\t0xF54E, 0x9B8A, 0xF54F, 0x9B8B, 0xF550, 0x9B8C, 0xF551, 0x9B8D,\r\n\t0xF552, 0x9B8E, 0xF553, 0x9B8F, 0xF554, 0x9B90, 0xF555, 0x9B91,\t0xF556, 0x9B92, 0xF557, 0x9B93, 0xF558, 0x9B94, 0xF559, 0x9B95,\r\n\t0xF55A, 0x9B96, 0xF55B, 0x9B97, 0xF55C, 0x9B98, 0xF55D, 0x9B99,\t0xF55E, 0x9B9A, 0xF55F, 0x9B9B, 0xF560, 0x9B9C, 0xF561, 0x9B9D,\r\n\t0xF562, 0x9B9E, 0xF563, 0x9B9F, 0xF564, 0x9BA0, 0xF565, 0x9BA1,\t0xF566, 0x9BA2, 0xF567, 0x9BA3, 0xF568, 0x9BA4, 0xF569, 0x9BA5,\r\n\t0xF56A, 0x9BA6, 0xF56B, 0x9BA7, 0xF56C, 0x9BA8, 0xF56D, 0x9BA9,\t0xF56E, 0x9BAA, 0xF56F, 0x9BAB, 0xF570, 0x9BAC, 0xF571, 0x9BAD,\r\n\t0xF572, 0x9BAE, 0xF573, 0x9BAF, 0xF574, 0x9BB0, 0xF575, 0x9BB1,\t0xF576, 0x9BB2, 0xF577, 0x9BB3, 0xF578, 0x9BB4, 0xF579, 0x9BB5,\r\n\t0xF57A, 0x9BB6, 0xF57B, 0x9BB7, 0xF57C, 0x9BB8, 0xF57D, 0x9BB9,\t0xF57E, 0x9BBA, 0xF580, 0x9BBB, 0xF581, 0x9BBC, 0xF582, 0x9BBD,\r\n\t0xF583, 0x9BBE, 0xF584, 0x9BBF, 0xF585, 0x9BC0, 0xF586, 0x9BC1,\t0xF587, 0x9BC2, 0xF588, 0x9BC3, 0xF589, 0x9BC4, 0xF58A, 0x9BC5,\r\n\t0xF58B, 0x9BC6, 0xF58C, 0x9BC7, 0xF58D, 0x9BC8, 0xF58E, 0x9BC9,\t0xF58F, 0x9BCA, 0xF590, 0x9BCB, 0xF591, 0x9BCC, 0xF592, 0x9BCD,\r\n\t0xF593, 0x9BCE, 0xF594, 0x9BCF, 0xF595, 0x9BD0, 0xF596, 0x9BD1,\t0xF597, 0x9BD2, 0xF598, 0x9BD3, 0xF599, 0x9BD4, 0xF59A, 0x9BD5,\r\n\t0xF59B, 0x9BD6, 0xF59C, 0x9BD7, 0xF59D, 0x9BD8, 0xF59E, 0x9BD9,\t0xF59F, 0x9BDA, 0xF5A0, 0x9BDB, 0xF5A1, 0x9162, 0xF5A2, 0x9161,\r\n\t0xF5A3, 0x9170, 0xF5A4, 0x9169, 0xF5A5, 0x916F, 0xF5A6, 0x917D,\t0xF5A7, 0x917E, 0xF5A8, 0x9172, 0xF5A9, 0x9174, 0xF5AA, 0x9179,\r\n\t0xF5AB, 0x918C, 0xF5AC, 0x9185, 0xF5AD, 0x9190, 0xF5AE, 0x918D,\t0xF5AF, 0x9191, 0xF5B0, 0x91A2, 0xF5B1, 0x91A3, 0xF5B2, 0x91AA,\r\n\t0xF5B3, 0x91AD, 0xF5B4, 0x91AE, 0xF5B5, 0x91AF, 0xF5B6, 0x91B5,\t0xF5B7, 0x91B4, 0xF5B8, 0x91BA, 0xF5B9, 0x8C55, 0xF5BA, 0x9E7E,\r\n\t0xF5BB, 0x8DB8, 0xF5BC, 0x8DEB, 0xF5BD, 0x8E05, 0xF5BE, 0x8E59,\t0xF5BF, 0x8E69, 0xF5C0, 0x8DB5, 0xF5C1, 0x8DBF, 0xF5C2, 0x8DBC,\r\n\t0xF5C3, 0x8DBA, 0xF5C4, 0x8DC4, 0xF5C5, 0x8DD6, 0xF5C6, 0x8DD7,\t0xF5C7, 0x8DDA, 0xF5C8, 0x8DDE, 0xF5C9, 0x8DCE, 0xF5CA, 0x8DCF,\r\n\t0xF5CB, 0x8DDB, 0xF5CC, 0x8DC6, 0xF5CD, 0x8DEC, 0xF5CE, 0x8DF7,\t0xF5CF, 0x8DF8, 0xF5D0, 0x8DE3, 0xF5D1, 0x8DF9, 0xF5D2, 0x8DFB,\r\n\t0xF5D3, 0x8DE4, 0xF5D4, 0x8E09, 0xF5D5, 0x8DFD, 0xF5D6, 0x8E14,\t0xF5D7, 0x8E1D, 0xF5D8, 0x8E1F, 0xF5D9, 0x8E2C, 0xF5DA, 0x8E2E,\r\n\t0xF5DB, 0x8E23, 0xF5DC, 0x8E2F, 0xF5DD, 0x8E3A, 0xF5DE, 0x8E40,\t0xF5DF, 0x8E39, 0xF5E0, 0x8E35, 0xF5E1, 0x8E3D, 0xF5E2, 0x8E31,\r\n\t0xF5E3, 0x8E49, 0xF5E4, 0x8E41, 0xF5E5, 0x8E42, 0xF5E6, 0x8E51,\t0xF5E7, 0x8E52, 0xF5E8, 0x8E4A, 0xF5E9, 0x8E70, 0xF5EA, 0x8E76,\r\n\t0xF5EB, 0x8E7C, 0xF5EC, 0x8E6F, 0xF5ED, 0x8E74, 0xF5EE, 0x8E85,\t0xF5EF, 0x8E8F, 0xF5F0, 0x8E94, 0xF5F1, 0x8E90, 0xF5F2, 0x8E9C,\r\n\t0xF5F3, 0x8E9E, 0xF5F4, 0x8C78, 0xF5F5, 0x8C82, 0xF5F6, 0x8C8A,\t0xF5F7, 0x8C85, 0xF5F8, 0x8C98, 0xF5F9, 0x8C94, 0xF5FA, 0x659B,\r\n\t0xF5FB, 0x89D6, 0xF5FC, 0x89DE, 0xF5FD, 0x89DA, 0xF5FE, 0x89DC,\t0xF640, 0x9BDC, 0xF641, 0x9BDD, 0xF642, 0x9BDE, 0xF643, 0x9BDF,\r\n\t0xF644, 0x9BE0, 0xF645, 0x9BE1, 0xF646, 0x9BE2, 0xF647, 0x9BE3,\t0xF648, 0x9BE4, 0xF649, 0x9BE5, 0xF64A, 0x9BE6, 0xF64B, 0x9BE7,\r\n\t0xF64C, 0x9BE8, 0xF64D, 0x9BE9, 0xF64E, 0x9BEA, 0xF64F, 0x9BEB,\t0xF650, 0x9BEC, 0xF651, 0x9BED, 0xF652, 0x9BEE, 0xF653, 0x9BEF,\r\n\t0xF654, 0x9BF0, 0xF655, 0x9BF1, 0xF656, 0x9BF2, 0xF657, 0x9BF3,\t0xF658, 0x9BF4, 0xF659, 0x9BF5, 0xF65A, 0x9BF6, 0xF65B, 0x9BF7,\r\n\t0xF65C, 0x9BF8, 0xF65D, 0x9BF9, 0xF65E, 0x9BFA, 0xF65F, 0x9BFB,\t0xF660, 0x9BFC, 0xF661, 0x9BFD, 0xF662, 0x9BFE, 0xF663, 0x9BFF,\r\n\t0xF664, 0x9C00, 0xF665, 0x9C01, 0xF666, 0x9C02, 0xF667, 0x9C03,\t0xF668, 0x9C04, 0xF669, 0x9C05, 0xF66A, 0x9C06, 0xF66B, 0x9C07,\r\n\t0xF66C, 0x9C08, 0xF66D, 0x9C09, 0xF66E, 0x9C0A, 0xF66F, 0x9C0B,\t0xF670, 0x9C0C, 0xF671, 0x9C0D, 0xF672, 0x9C0E, 0xF673, 0x9C0F,\r\n\t0xF674, 0x9C10, 0xF675, 0x9C11, 0xF676, 0x9C12, 0xF677, 0x9C13,\t0xF678, 0x9C14, 0xF679, 0x9C15, 0xF67A, 0x9C16, 0xF67B, 0x9C17,\r\n\t0xF67C, 0x9C18, 0xF67D, 0x9C19, 0xF67E, 0x9C1A, 0xF680, 0x9C1B,\t0xF681, 0x9C1C, 0xF682, 0x9C1D, 0xF683, 0x9C1E, 0xF684, 0x9C1F,\r\n\t0xF685, 0x9C20, 0xF686, 0x9C21, 0xF687, 0x9C22, 0xF688, 0x9C23,\t0xF689, 0x9C24, 0xF68A, 0x9C25, 0xF68B, 0x9C26, 0xF68C, 0x9C27,\r\n\t0xF68D, 0x9C28, 0xF68E, 0x9C29, 0xF68F, 0x9C2A, 0xF690, 0x9C2B,\t0xF691, 0x9C2C, 0xF692, 0x9C2D, 0xF693, 0x9C2E, 0xF694, 0x9C2F,\r\n\t0xF695, 0x9C30, 0xF696, 0x9C31, 0xF697, 0x9C32, 0xF698, 0x9C33,\t0xF699, 0x9C34, 0xF69A, 0x9C35, 0xF69B, 0x9C36, 0xF69C, 0x9C37,\r\n\t0xF69D, 0x9C38, 0xF69E, 0x9C39, 0xF69F, 0x9C3A, 0xF6A0, 0x9C3B,\t0xF6A1, 0x89E5, 0xF6A2, 0x89EB, 0xF6A3, 0x89EF, 0xF6A4, 0x8A3E,\r\n\t0xF6A5, 0x8B26, 0xF6A6, 0x9753, 0xF6A7, 0x96E9, 0xF6A8, 0x96F3,\t0xF6A9, 0x96EF, 0xF6AA, 0x9706, 0xF6AB, 0x9701, 0xF6AC, 0x9708,\r\n\t0xF6AD, 0x970F, 0xF6AE, 0x970E, 0xF6AF, 0x972A, 0xF6B0, 0x972D,\t0xF6B1, 0x9730, 0xF6B2, 0x973E, 0xF6B3, 0x9F80, 0xF6B4, 0x9F83,\r\n\t0xF6B5, 0x9F85, 0xF6B6, 0x9F86, 0xF6B7, 0x9F87, 0xF6B8, 0x9F88,\t0xF6B9, 0x9F89, 0xF6BA, 0x9F8A, 0xF6BB, 0x9F8C, 0xF6BC, 0x9EFE,\r\n\t0xF6BD, 0x9F0B, 0xF6BE, 0x9F0D, 0xF6BF, 0x96B9, 0xF6C0, 0x96BC,\t0xF6C1, 0x96BD, 0xF6C2, 0x96CE, 0xF6C3, 0x96D2, 0xF6C4, 0x77BF,\r\n\t0xF6C5, 0x96E0, 0xF6C6, 0x928E, 0xF6C7, 0x92AE, 0xF6C8, 0x92C8,\t0xF6C9, 0x933E, 0xF6CA, 0x936A, 0xF6CB, 0x93CA, 0xF6CC, 0x938F,\r\n\t0xF6CD, 0x943E, 0xF6CE, 0x946B, 0xF6CF, 0x9C7F, 0xF6D0, 0x9C82,\t0xF6D1, 0x9C85, 0xF6D2, 0x9C86, 0xF6D3, 0x9C87, 0xF6D4, 0x9C88,\r\n\t0xF6D5, 0x7A23, 0xF6D6, 0x9C8B, 0xF6D7, 0x9C8E, 0xF6D8, 0x9C90,\t0xF6D9, 0x9C91, 0xF6DA, 0x9C92, 0xF6DB, 0x9C94, 0xF6DC, 0x9C95,\r\n\t0xF6DD, 0x9C9A, 0xF6DE, 0x9C9B, 0xF6DF, 0x9C9E, 0xF6E0, 0x9C9F,\t0xF6E1, 0x9CA0, 0xF6E2, 0x9CA1, 0xF6E3, 0x9CA2, 0xF6E4, 0x9CA3,\r\n\t0xF6E5, 0x9CA5, 0xF6E6, 0x9CA6, 0xF6E7, 0x9CA7, 0xF6E8, 0x9CA8,\t0xF6E9, 0x9CA9, 0xF6EA, 0x9CAB, 0xF6EB, 0x9CAD, 0xF6EC, 0x9CAE,\r\n\t0xF6ED, 0x9CB0, 0xF6EE, 0x9CB1, 0xF6EF, 0x9CB2, 0xF6F0, 0x9CB3,\t0xF6F1, 0x9CB4, 0xF6F2, 0x9CB5, 0xF6F3, 0x9CB6, 0xF6F4, 0x9CB7,\r\n\t0xF6F5, 0x9CBA, 0xF6F6, 0x9CBB, 0xF6F7, 0x9CBC, 0xF6F8, 0x9CBD,\t0xF6F9, 0x9CC4, 0xF6FA, 0x9CC5, 0xF6FB, 0x9CC6, 0xF6FC, 0x9CC7,\r\n\t0xF6FD, 0x9CCA, 0xF6FE, 0x9CCB, 0xF740, 0x9C3C, 0xF741, 0x9C3D,\t0xF742, 0x9C3E, 0xF743, 0x9C3F, 0xF744, 0x9C40, 0xF745, 0x9C41,\r\n\t0xF746, 0x9C42, 0xF747, 0x9C43, 0xF748, 0x9C44, 0xF749, 0x9C45,\t0xF74A, 0x9C46, 0xF74B, 0x9C47, 0xF74C, 0x9C48, 0xF74D, 0x9C49,\r\n\t0xF74E, 0x9C4A, 0xF74F, 0x9C4B, 0xF750, 0x9C4C, 0xF751, 0x9C4D,\t0xF752, 0x9C4E, 0xF753, 0x9C4F, 0xF754, 0x9C50, 0xF755, 0x9C51,\r\n\t0xF756, 0x9C52, 0xF757, 0x9C53, 0xF758, 0x9C54, 0xF759, 0x9C55,\t0xF75A, 0x9C56, 0xF75B, 0x9C57, 0xF75C, 0x9C58, 0xF75D, 0x9C59,\r\n\t0xF75E, 0x9C5A, 0xF75F, 0x9C5B, 0xF760, 0x9C5C, 0xF761, 0x9C5D,\t0xF762, 0x9C5E, 0xF763, 0x9C5F, 0xF764, 0x9C60, 0xF765, 0x9C61,\r\n\t0xF766, 0x9C62, 0xF767, 0x9C63, 0xF768, 0x9C64, 0xF769, 0x9C65,\t0xF76A, 0x9C66, 0xF76B, 0x9C67, 0xF76C, 0x9C68, 0xF76D, 0x9C69,\r\n\t0xF76E, 0x9C6A, 0xF76F, 0x9C6B, 0xF770, 0x9C6C, 0xF771, 0x9C6D,\t0xF772, 0x9C6E, 0xF773, 0x9C6F, 0xF774, 0x9C70, 0xF775, 0x9C71,\r\n\t0xF776, 0x9C72, 0xF777, 0x9C73, 0xF778, 0x9C74, 0xF779, 0x9C75,\t0xF77A, 0x9C76, 0xF77B, 0x9C77, 0xF77C, 0x9C78, 0xF77D, 0x9C79,\r\n\t0xF77E, 0x9C7A, 0xF780, 0x9C7B, 0xF781, 0x9C7D, 0xF782, 0x9C7E,\t0xF783, 0x9C80, 0xF784, 0x9C83, 0xF785, 0x9C84, 0xF786, 0x9C89,\r\n\t0xF787, 0x9C8A, 0xF788, 0x9C8C, 0xF789, 0x9C8F, 0xF78A, 0x9C93,\t0xF78B, 0x9C96, 0xF78C, 0x9C97, 0xF78D, 0x9C98, 0xF78E, 0x9C99,\r\n\t0xF78F, 0x9C9D, 0xF790, 0x9CAA, 0xF791, 0x9CAC, 0xF792, 0x9CAF,\t0xF793, 0x9CB9, 0xF794, 0x9CBE, 0xF795, 0x9CBF, 0xF796, 0x9CC0,\r\n\t0xF797, 0x9CC1, 0xF798, 0x9CC2, 0xF799, 0x9CC8, 0xF79A, 0x9CC9,\t0xF79B, 0x9CD1, 0xF79C, 0x9CD2, 0xF79D, 0x9CDA, 0xF79E, 0x9CDB,\r\n\t0xF79F, 0x9CE0, 0xF7A0, 0x9CE1, 0xF7A1, 0x9CCC, 0xF7A2, 0x9CCD,\t0xF7A3, 0x9CCE, 0xF7A4, 0x9CCF, 0xF7A5, 0x9CD0, 0xF7A6, 0x9CD3,\r\n\t0xF7A7, 0x9CD4, 0xF7A8, 0x9CD5, 0xF7A9, 0x9CD7, 0xF7AA, 0x9CD8,\t0xF7AB, 0x9CD9, 0xF7AC, 0x9CDC, 0xF7AD, 0x9CDD, 0xF7AE, 0x9CDF,\r\n\t0xF7AF, 0x9CE2, 0xF7B0, 0x977C, 0xF7B1, 0x9785, 0xF7B2, 0x9791,\t0xF7B3, 0x9792, 0xF7B4, 0x9794, 0xF7B5, 0x97AF, 0xF7B6, 0x97AB,\r\n\t0xF7B7, 0x97A3, 0xF7B8, 0x97B2, 0xF7B9, 0x97B4, 0xF7BA, 0x9AB1,\t0xF7BB, 0x9AB0, 0xF7BC, 0x9AB7, 0xF7BD, 0x9E58, 0xF7BE, 0x9AB6,\r\n\t0xF7BF, 0x9ABA, 0xF7C0, 0x9ABC, 0xF7C1, 0x9AC1, 0xF7C2, 0x9AC0,\t0xF7C3, 0x9AC5, 0xF7C4, 0x9AC2, 0xF7C5, 0x9ACB, 0xF7C6, 0x9ACC,\r\n\t0xF7C7, 0x9AD1, 0xF7C8, 0x9B45, 0xF7C9, 0x9B43, 0xF7CA, 0x9B47,\t0xF7CB, 0x9B49, 0xF7CC, 0x9B48, 0xF7CD, 0x9B4D, 0xF7CE, 0x9B51,\r\n\t0xF7CF, 0x98E8, 0xF7D0, 0x990D, 0xF7D1, 0x992E, 0xF7D2, 0x9955,\t0xF7D3, 0x9954, 0xF7D4, 0x9ADF, 0xF7D5, 0x9AE1, 0xF7D6, 0x9AE6,\r\n\t0xF7D7, 0x9AEF, 0xF7D8, 0x9AEB, 0xF7D9, 0x9AFB, 0xF7DA, 0x9AED,\t0xF7DB, 0x9AF9, 0xF7DC, 0x9B08, 0xF7DD, 0x9B0F, 0xF7DE, 0x9B13,\r\n\t0xF7DF, 0x9B1F, 0xF7E0, 0x9B23, 0xF7E1, 0x9EBD, 0xF7E2, 0x9EBE,\t0xF7E3, 0x7E3B, 0xF7E4, 0x9E82, 0xF7E5, 0x9E87, 0xF7E6, 0x9E88,\r\n\t0xF7E7, 0x9E8B, 0xF7E8, 0x9E92, 0xF7E9, 0x93D6, 0xF7EA, 0x9E9D,\t0xF7EB, 0x9E9F, 0xF7EC, 0x9EDB, 0xF7ED, 0x9EDC, 0xF7EE, 0x9EDD,\r\n\t0xF7EF, 0x9EE0, 0xF7F0, 0x9EDF, 0xF7F1, 0x9EE2, 0xF7F2, 0x9EE9,\t0xF7F3, 0x9EE7, 0xF7F4, 0x9EE5, 0xF7F5, 0x9EEA, 0xF7F6, 0x9EEF,\r\n\t0xF7F7, 0x9F22, 0xF7F8, 0x9F2C, 0xF7F9, 0x9F2F, 0xF7FA, 0x9F39,\t0xF7FB, 0x9F37, 0xF7FC, 0x9F3D, 0xF7FD, 0x9F3E, 0xF7FE, 0x9F44,\r\n\t0xF840, 0x9CE3, 0xF841, 0x9CE4, 0xF842, 0x9CE5, 0xF843, 0x9CE6,\t0xF844, 0x9CE7, 0xF845, 0x9CE8, 0xF846, 0x9CE9, 0xF847, 0x9CEA,\r\n\t0xF848, 0x9CEB, 0xF849, 0x9CEC, 0xF84A, 0x9CED, 0xF84B, 0x9CEE,\t0xF84C, 0x9CEF, 0xF84D, 0x9CF0, 0xF84E, 0x9CF1, 0xF84F, 0x9CF2,\r\n\t0xF850, 0x9CF3, 0xF851, 0x9CF4, 0xF852, 0x9CF5, 0xF853, 0x9CF6,\t0xF854, 0x9CF7, 0xF855, 0x9CF8, 0xF856, 0x9CF9, 0xF857, 0x9CFA,\r\n\t0xF858, 0x9CFB, 0xF859, 0x9CFC, 0xF85A, 0x9CFD, 0xF85B, 0x9CFE,\t0xF85C, 0x9CFF, 0xF85D, 0x9D00, 0xF85E, 0x9D01, 0xF85F, 0x9D02,\r\n\t0xF860, 0x9D03, 0xF861, 0x9D04, 0xF862, 0x9D05, 0xF863, 0x9D06,\t0xF864, 0x9D07, 0xF865, 0x9D08, 0xF866, 0x9D09, 0xF867, 0x9D0A,\r\n\t0xF868, 0x9D0B, 0xF869, 0x9D0C, 0xF86A, 0x9D0D, 0xF86B, 0x9D0E,\t0xF86C, 0x9D0F, 0xF86D, 0x9D10, 0xF86E, 0x9D11, 0xF86F, 0x9D12,\r\n\t0xF870, 0x9D13, 0xF871, 0x9D14, 0xF872, 0x9D15, 0xF873, 0x9D16,\t0xF874, 0x9D17, 0xF875, 0x9D18, 0xF876, 0x9D19, 0xF877, 0x9D1A,\r\n\t0xF878, 0x9D1B, 0xF879, 0x9D1C, 0xF87A, 0x9D1D, 0xF87B, 0x9D1E,\t0xF87C, 0x9D1F, 0xF87D, 0x9D20, 0xF87E, 0x9D21, 0xF880, 0x9D22,\r\n\t0xF881, 0x9D23, 0xF882, 0x9D24, 0xF883, 0x9D25, 0xF884, 0x9D26,\t0xF885, 0x9D27, 0xF886, 0x9D28, 0xF887, 0x9D29, 0xF888, 0x9D2A,\r\n\t0xF889, 0x9D2B, 0xF88A, 0x9D2C, 0xF88B, 0x9D2D, 0xF88C, 0x9D2E,\t0xF88D, 0x9D2F, 0xF88E, 0x9D30, 0xF88F, 0x9D31, 0xF890, 0x9D32,\r\n\t0xF891, 0x9D33, 0xF892, 0x9D34, 0xF893, 0x9D35, 0xF894, 0x9D36,\t0xF895, 0x9D37, 0xF896, 0x9D38, 0xF897, 0x9D39, 0xF898, 0x9D3A,\r\n\t0xF899, 0x9D3B, 0xF89A, 0x9D3C, 0xF89B, 0x9D3D, 0xF89C, 0x9D3E,\t0xF89D, 0x9D3F, 0xF89E, 0x9D40, 0xF89F, 0x9D41, 0xF8A0, 0x9D42,\r\n\t0xF940, 0x9D43, 0xF941, 0x9D44, 0xF942, 0x9D45, 0xF943, 0x9D46,\t0xF944, 0x9D47, 0xF945, 0x9D48, 0xF946, 0x9D49, 0xF947, 0x9D4A,\r\n\t0xF948, 0x9D4B, 0xF949, 0x9D4C, 0xF94A, 0x9D4D, 0xF94B, 0x9D4E,\t0xF94C, 0x9D4F, 0xF94D, 0x9D50, 0xF94E, 0x9D51, 0xF94F, 0x9D52,\r\n\t0xF950, 0x9D53, 0xF951, 0x9D54, 0xF952, 0x9D55, 0xF953, 0x9D56,\t0xF954, 0x9D57, 0xF955, 0x9D58, 0xF956, 0x9D59, 0xF957, 0x9D5A,\r\n\t0xF958, 0x9D5B, 0xF959, 0x9D5C, 0xF95A, 0x9D5D, 0xF95B, 0x9D5E,\t0xF95C, 0x9D5F, 0xF95D, 0x9D60, 0xF95E, 0x9D61, 0xF95F, 0x9D62,\r\n\t0xF960, 0x9D63, 0xF961, 0x9D64, 0xF962, 0x9D65, 0xF963, 0x9D66,\t0xF964, 0x9D67, 0xF965, 0x9D68, 0xF966, 0x9D69, 0xF967, 0x9D6A,\r\n\t0xF968, 0x9D6B, 0xF969, 0x9D6C, 0xF96A, 0x9D6D, 0xF96B, 0x9D6E,\t0xF96C, 0x9D6F, 0xF96D, 0x9D70, 0xF96E, 0x9D71, 0xF96F, 0x9D72,\r\n\t0xF970, 0x9D73, 0xF971, 0x9D74, 0xF972, 0x9D75, 0xF973, 0x9D76,\t0xF974, 0x9D77, 0xF975, 0x9D78, 0xF976, 0x9D79, 0xF977, 0x9D7A,\r\n\t0xF978, 0x9D7B, 0xF979, 0x9D7C, 0xF97A, 0x9D7D, 0xF97B, 0x9D7E,\t0xF97C, 0x9D7F, 0xF97D, 0x9D80, 0xF97E, 0x9D81, 0xF980, 0x9D82,\r\n\t0xF981, 0x9D83, 0xF982, 0x9D84, 0xF983, 0x9D85, 0xF984, 0x9D86,\t0xF985, 0x9D87, 0xF986, 0x9D88, 0xF987, 0x9D89, 0xF988, 0x9D8A,\r\n\t0xF989, 0x9D8B, 0xF98A, 0x9D8C, 0xF98B, 0x9D8D, 0xF98C, 0x9D8E,\t0xF98D, 0x9D8F, 0xF98E, 0x9D90, 0xF98F, 0x9D91, 0xF990, 0x9D92,\r\n\t0xF991, 0x9D93, 0xF992, 0x9D94, 0xF993, 0x9D95, 0xF994, 0x9D96,\t0xF995, 0x9D97, 0xF996, 0x9D98, 0xF997, 0x9D99, 0xF998, 0x9D9A,\r\n\t0xF999, 0x9D9B, 0xF99A, 0x9D9C, 0xF99B, 0x9D9D, 0xF99C, 0x9D9E,\t0xF99D, 0x9D9F, 0xF99E, 0x9DA0, 0xF99F, 0x9DA1, 0xF9A0, 0x9DA2,\r\n\t0xFA40, 0x9DA3, 0xFA41, 0x9DA4, 0xFA42, 0x9DA5, 0xFA43, 0x9DA6,\t0xFA44, 0x9DA7, 0xFA45, 0x9DA8, 0xFA46, 0x9DA9, 0xFA47, 0x9DAA,\r\n\t0xFA48, 0x9DAB, 0xFA49, 0x9DAC, 0xFA4A, 0x9DAD, 0xFA4B, 0x9DAE,\t0xFA4C, 0x9DAF, 0xFA4D, 0x9DB0, 0xFA4E, 0x9DB1, 0xFA4F, 0x9DB2,\r\n\t0xFA50, 0x9DB3, 0xFA51, 0x9DB4, 0xFA52, 0x9DB5, 0xFA53, 0x9DB6,\t0xFA54, 0x9DB7, 0xFA55, 0x9DB8, 0xFA56, 0x9DB9, 0xFA57, 0x9DBA,\r\n\t0xFA58, 0x9DBB, 0xFA59, 0x9DBC, 0xFA5A, 0x9DBD, 0xFA5B, 0x9DBE,\t0xFA5C, 0x9DBF, 0xFA5D, 0x9DC0, 0xFA5E, 0x9DC1, 0xFA5F, 0x9DC2,\r\n\t0xFA60, 0x9DC3, 0xFA61, 0x9DC4, 0xFA62, 0x9DC5, 0xFA63, 0x9DC6,\t0xFA64, 0x9DC7, 0xFA65, 0x9DC8, 0xFA66, 0x9DC9, 0xFA67, 0x9DCA,\r\n\t0xFA68, 0x9DCB, 0xFA69, 0x9DCC, 0xFA6A, 0x9DCD, 0xFA6B, 0x9DCE,\t0xFA6C, 0x9DCF, 0xFA6D, 0x9DD0, 0xFA6E, 0x9DD1, 0xFA6F, 0x9DD2,\r\n\t0xFA70, 0x9DD3, 0xFA71, 0x9DD4, 0xFA72, 0x9DD5, 0xFA73, 0x9DD6,\t0xFA74, 0x9DD7, 0xFA75, 0x9DD8, 0xFA76, 0x9DD9, 0xFA77, 0x9DDA,\r\n\t0xFA78, 0x9DDB, 0xFA79, 0x9DDC, 0xFA7A, 0x9DDD, 0xFA7B, 0x9DDE,\t0xFA7C, 0x9DDF, 0xFA7D, 0x9DE0, 0xFA7E, 0x9DE1, 0xFA80, 0x9DE2,\r\n\t0xFA81, 0x9DE3, 0xFA82, 0x9DE4, 0xFA83, 0x9DE5, 0xFA84, 0x9DE6,\t0xFA85, 0x9DE7, 0xFA86, 0x9DE8, 0xFA87, 0x9DE9, 0xFA88, 0x9DEA,\r\n\t0xFA89, 0x9DEB, 0xFA8A, 0x9DEC, 0xFA8B, 0x9DED, 0xFA8C, 0x9DEE,\t0xFA8D, 0x9DEF, 0xFA8E, 0x9DF0, 0xFA8F, 0x9DF1, 0xFA90, 0x9DF2,\r\n\t0xFA91, 0x9DF3, 0xFA92, 0x9DF4, 0xFA93, 0x9DF5, 0xFA94, 0x9DF6,\t0xFA95, 0x9DF7, 0xFA96, 0x9DF8, 0xFA97, 0x9DF9, 0xFA98, 0x9DFA,\r\n\t0xFA99, 0x9DFB, 0xFA9A, 0x9DFC, 0xFA9B, 0x9DFD, 0xFA9C, 0x9DFE,\t0xFA9D, 0x9DFF, 0xFA9E, 0x9E00, 0xFA9F, 0x9E01, 0xFAA0, 0x9E02,\r\n\t0xFB40, 0x9E03, 0xFB41, 0x9E04, 0xFB42, 0x9E05, 0xFB43, 0x9E06,\t0xFB44, 0x9E07, 0xFB45, 0x9E08, 0xFB46, 0x9E09, 0xFB47, 0x9E0A,\r\n\t0xFB48, 0x9E0B, 0xFB49, 0x9E0C, 0xFB4A, 0x9E0D, 0xFB4B, 0x9E0E,\t0xFB4C, 0x9E0F, 0xFB4D, 0x9E10, 0xFB4E, 0x9E11, 0xFB4F, 0x9E12,\r\n\t0xFB50, 0x9E13, 0xFB51, 0x9E14, 0xFB52, 0x9E15, 0xFB53, 0x9E16,\t0xFB54, 0x9E17, 0xFB55, 0x9E18, 0xFB56, 0x9E19, 0xFB57, 0x9E1A,\r\n\t0xFB58, 0x9E1B, 0xFB59, 0x9E1C, 0xFB5A, 0x9E1D, 0xFB5B, 0x9E1E,\t0xFB5C, 0x9E24, 0xFB5D, 0x9E27, 0xFB5E, 0x9E2E, 0xFB5F, 0x9E30,\r\n\t0xFB60, 0x9E34, 0xFB61, 0x9E3B, 0xFB62, 0x9E3C, 0xFB63, 0x9E40,\t0xFB64, 0x9E4D, 0xFB65, 0x9E50, 0xFB66, 0x9E52, 0xFB67, 0x9E53,\r\n\t0xFB68, 0x9E54, 0xFB69, 0x9E56, 0xFB6A, 0x9E59, 0xFB6B, 0x9E5D,\t0xFB6C, 0x9E5F, 0xFB6D, 0x9E60, 0xFB6E, 0x9E61, 0xFB6F, 0x9E62,\r\n\t0xFB70, 0x9E65, 0xFB71, 0x9E6E, 0xFB72, 0x9E6F, 0xFB73, 0x9E72,\t0xFB74, 0x9E74, 0xFB75, 0x9E75, 0xFB76, 0x9E76, 0xFB77, 0x9E77,\r\n\t0xFB78, 0x9E78, 0xFB79, 0x9E79, 0xFB7A, 0x9E7A, 0xFB7B, 0x9E7B,\t0xFB7C, 0x9E7C, 0xFB7D, 0x9E7D, 0xFB7E, 0x9E80, 0xFB80, 0x9E81,\r\n\t0xFB81, 0x9E83, 0xFB82, 0x9E84, 0xFB83, 0x9E85, 0xFB84, 0x9E86,\t0xFB85, 0x9E89, 0xFB86, 0x9E8A, 0xFB87, 0x9E8C, 0xFB88, 0x9E8D,\r\n\t0xFB89, 0x9E8E, 0xFB8A, 0x9E8F, 0xFB8B, 0x9E90, 0xFB8C, 0x9E91,\t0xFB8D, 0x9E94, 0xFB8E, 0x9E95, 0xFB8F, 0x9E96, 0xFB90, 0x9E97,\r\n\t0xFB91, 0x9E98, 0xFB92, 0x9E99, 0xFB93, 0x9E9A, 0xFB94, 0x9E9B,\t0xFB95, 0x9E9C, 0xFB96, 0x9E9E, 0xFB97, 0x9EA0, 0xFB98, 0x9EA1,\r\n\t0xFB99, 0x9EA2, 0xFB9A, 0x9EA3, 0xFB9B, 0x9EA4, 0xFB9C, 0x9EA5,\t0xFB9D, 0x9EA7, 0xFB9E, 0x9EA8, 0xFB9F, 0x9EA9, 0xFBA0, 0x9EAA,\r\n\t0xFC40, 0x9EAB, 0xFC41, 0x9EAC, 0xFC42, 0x9EAD, 0xFC43, 0x9EAE,\t0xFC44, 0x9EAF, 0xFC45, 0x9EB0, 0xFC46, 0x9EB1, 0xFC47, 0x9EB2,\r\n\t0xFC48, 0x9EB3, 0xFC49, 0x9EB5, 0xFC4A, 0x9EB6, 0xFC4B, 0x9EB7,\t0xFC4C, 0x9EB9, 0xFC4D, 0x9EBA, 0xFC4E, 0x9EBC, 0xFC4F, 0x9EBF,\r\n\t0xFC50, 0x9EC0, 0xFC51, 0x9EC1, 0xFC52, 0x9EC2, 0xFC53, 0x9EC3,\t0xFC54, 0x9EC5, 0xFC55, 0x9EC6, 0xFC56, 0x9EC7, 0xFC57, 0x9EC8,\r\n\t0xFC58, 0x9ECA, 0xFC59, 0x9ECB, 0xFC5A, 0x9ECC, 0xFC5B, 0x9ED0,\t0xFC5C, 0x9ED2, 0xFC5D, 0x9ED3, 0xFC5E, 0x9ED5, 0xFC5F, 0x9ED6,\r\n\t0xFC60, 0x9ED7, 0xFC61, 0x9ED9, 0xFC62, 0x9EDA, 0xFC63, 0x9EDE,\t0xFC64, 0x9EE1, 0xFC65, 0x9EE3, 0xFC66, 0x9EE4, 0xFC67, 0x9EE6,\r\n\t0xFC68, 0x9EE8, 0xFC69, 0x9EEB, 0xFC6A, 0x9EEC, 0xFC6B, 0x9EED,\t0xFC6C, 0x9EEE, 0xFC6D, 0x9EF0, 0xFC6E, 0x9EF1, 0xFC6F, 0x9EF2,\r\n\t0xFC70, 0x9EF3, 0xFC71, 0x9EF4, 0xFC72, 0x9EF5, 0xFC73, 0x9EF6,\t0xFC74, 0x9EF7, 0xFC75, 0x9EF8, 0xFC76, 0x9EFA, 0xFC77, 0x9EFD,\r\n\t0xFC78, 0x9EFF, 0xFC79, 0x9F00, 0xFC7A, 0x9F01, 0xFC7B, 0x9F02,\t0xFC7C, 0x9F03, 0xFC7D, 0x9F04, 0xFC7E, 0x9F05, 0xFC80, 0x9F06,\r\n\t0xFC81, 0x9F07, 0xFC82, 0x9F08, 0xFC83, 0x9F09, 0xFC84, 0x9F0A,\t0xFC85, 0x9F0C, 0xFC86, 0x9F0F, 0xFC87, 0x9F11, 0xFC88, 0x9F12,\r\n\t0xFC89, 0x9F14, 0xFC8A, 0x9F15, 0xFC8B, 0x9F16, 0xFC8C, 0x9F18,\t0xFC8D, 0x9F1A, 0xFC8E, 0x9F1B, 0xFC8F, 0x9F1C, 0xFC90, 0x9F1D,\r\n\t0xFC91, 0x9F1E, 0xFC92, 0x9F1F, 0xFC93, 0x9F21, 0xFC94, 0x9F23,\t0xFC95, 0x9F24, 0xFC96, 0x9F25, 0xFC97, 0x9F26, 0xFC98, 0x9F27,\r\n\t0xFC99, 0x9F28, 0xFC9A, 0x9F29, 0xFC9B, 0x9F2A, 0xFC9C, 0x9F2B,\t0xFC9D, 0x9F2D, 0xFC9E, 0x9F2E, 0xFC9F, 0x9F30, 0xFCA0, 0x9F31,\r\n\t0xFD40, 0x9F32, 0xFD41, 0x9F33, 0xFD42, 0x9F34, 0xFD43, 0x9F35,\t0xFD44, 0x9F36, 0xFD45, 0x9F38, 0xFD46, 0x9F3A, 0xFD47, 0x9F3C,\r\n\t0xFD48, 0x9F3F, 0xFD49, 0x9F40, 0xFD4A, 0x9F41, 0xFD4B, 0x9F42,\t0xFD4C, 0x9F43, 0xFD4D, 0x9F45, 0xFD4E, 0x9F46, 0xFD4F, 0x9F47,\r\n\t0xFD50, 0x9F48, 0xFD51, 0x9F49, 0xFD52, 0x9F4A, 0xFD53, 0x9F4B,\t0xFD54, 0x9F4C, 0xFD55, 0x9F4D, 0xFD56, 0x9F4E, 0xFD57, 0x9F4F,\r\n\t0xFD58, 0x9F52, 0xFD59, 0x9F53, 0xFD5A, 0x9F54, 0xFD5B, 0x9F55,\t0xFD5C, 0x9F56, 0xFD5D, 0x9F57, 0xFD5E, 0x9F58, 0xFD5F, 0x9F59,\r\n\t0xFD60, 0x9F5A, 0xFD61, 0x9F5B, 0xFD62, 0x9F5C, 0xFD63, 0x9F5D,\t0xFD64, 0x9F5E, 0xFD65, 0x9F5F, 0xFD66, 0x9F60, 0xFD67, 0x9F61,\r\n\t0xFD68, 0x9F62, 0xFD69, 0x9F63, 0xFD6A, 0x9F64, 0xFD6B, 0x9F65,\t0xFD6C, 0x9F66, 0xFD6D, 0x9F67, 0xFD6E, 0x9F68, 0xFD6F, 0x9F69,\r\n\t0xFD70, 0x9F6A, 0xFD71, 0x9F6B, 0xFD72, 0x9F6C, 0xFD73, 0x9F6D,\t0xFD74, 0x9F6E, 0xFD75, 0x9F6F, 0xFD76, 0x9F70, 0xFD77, 0x9F71,\r\n\t0xFD78, 0x9F72, 0xFD79, 0x9F73, 0xFD7A, 0x9F74, 0xFD7B, 0x9F75,\t0xFD7C, 0x9F76, 0xFD7D, 0x9F77, 0xFD7E, 0x9F78, 0xFD80, 0x9F79,\r\n\t0xFD81, 0x9F7A, 0xFD82, 0x9F7B, 0xFD83, 0x9F7C, 0xFD84, 0x9F7D,\t0xFD85, 0x9F7E, 0xFD86, 0x9F81, 0xFD87, 0x9F82, 0xFD88, 0x9F8D,\r\n\t0xFD89, 0x9F8E, 0xFD8A, 0x9F8F, 0xFD8B, 0x9F90, 0xFD8C, 0x9F91,\t0xFD8D, 0x9F92, 0xFD8E, 0x9F93, 0xFD8F, 0x9F94, 0xFD90, 0x9F95,\r\n\t0xFD91, 0x9F96, 0xFD92, 0x9F97, 0xFD93, 0x9F98, 0xFD94, 0x9F9C,\t0xFD95, 0x9F9D, 0xFD96, 0x9F9E, 0xFD97, 0x9FA1, 0xFD98, 0x9FA2,\r\n\t0xFD99, 0x9FA3, 0xFD9A, 0x9FA4, 0xFD9B, 0x9FA5, 0xFD9C, 0xF92C,\t0xFD9D, 0xF979, 0xFD9E, 0xF995, 0xFD9F, 0xF9E7, 0xFDA0, 0xF9F1,\r\n\t0xFE40, 0xFA0C, 0xFE41, 0xFA0D, 0xFE42, 0xFA0E, 0xFE43, 0xFA0F,\t0xFE44, 0xFA11, 0xFE45, 0xFA13, 0xFE46, 0xFA14, 0xFE47, 0xFA18,\r\n\t0xFE48, 0xFA1F, 0xFE49, 0xFA20, 0xFE4A, 0xFA21, 0xFE4B, 0xFA23,\t0xFE4C, 0xFA24, 0xFE4D, 0xFA27, 0xFE4E, 0xFA28, 0xFE4F, 0xFA29,\r\n\t0, 0\r\n};\r\n#endif\r\n\r\n#if FF_CODE_PAGE == 949 || FF_CODE_PAGE == 0\t/* Korean */\r\nstatic const WCHAR uni2oem949[] = {\t/* Unicode --> Korean pairs */\r\n\t0x00A1, 0xA2AE, 0x00A4, 0xA2B4, 0x00A7, 0xA1D7, 0x00A8, 0xA1A7,\t0x00AA, 0xA8A3, 0x00AD, 0xA1A9, 0x00AE, 0xA2E7, 0x00B0, 0xA1C6,\r\n\t0x00B1, 0xA1BE, 0x00B2, 0xA9F7, 0x00B3, 0xA9F8, 0x00B4, 0xA2A5,\t0x00B6, 0xA2D2, 0x00B7, 0xA1A4, 0x00B8, 0xA2AC, 0x00B9, 0xA9F6,\r\n\t0x00BA, 0xA8AC, 0x00BC, 0xA8F9, 0x00BD, 0xA8F6, 0x00BE, 0xA8FA,\t0x00BF, 0xA2AF, 0x00C6, 0xA8A1, 0x00D0, 0xA8A2, 0x00D7, 0xA1BF,\r\n\t0x00D8, 0xA8AA, 0x00DE, 0xA8AD, 0x00DF, 0xA9AC, 0x00E6, 0xA9A1,\t0x00F0, 0xA9A3, 0x00F7, 0xA1C0, 0x00F8, 0xA9AA, 0x00FE, 0xA9AD,\r\n\t0x0111, 0xA9A2, 0x0126, 0xA8A4, 0x0127, 0xA9A4, 0x0131, 0xA9A5,\t0x0132, 0xA8A6, 0x0133, 0xA9A6, 0x0138, 0xA9A7, 0x013F, 0xA8A8,\r\n\t0x0140, 0xA9A8, 0x0141, 0xA8A9, 0x0142, 0xA9A9, 0x0149, 0xA9B0,\t0x014A, 0xA8AF, 0x014B, 0xA9AF, 0x0152, 0xA8AB, 0x0153, 0xA9AB,\r\n\t0x0166, 0xA8AE, 0x0167, 0xA9AE, 0x02C7, 0xA2A7, 0x02D0, 0xA2B0,\t0x02D8, 0xA2A8, 0x02D9, 0xA2AB, 0x02DA, 0xA2AA, 0x02DB, 0xA2AD,\r\n\t0x02DD, 0xA2A9, 0x0391, 0xA5C1, 0x0392, 0xA5C2, 0x0393, 0xA5C3,\t0x0394, 0xA5C4, 0x0395, 0xA5C5, 0x0396, 0xA5C6, 0x0397, 0xA5C7,\r\n\t0x0398, 0xA5C8, 0x0399, 0xA5C9, 0x039A, 0xA5CA, 0x039B, 0xA5CB,\t0x039C, 0xA5CC, 0x039D, 0xA5CD, 0x039E, 0xA5CE, 0x039F, 0xA5CF,\r\n\t0x03A0, 0xA5D0, 0x03A1, 0xA5D1, 0x03A3, 0xA5D2, 0x03A4, 0xA5D3,\t0x03A5, 0xA5D4, 0x03A6, 0xA5D5, 0x03A7, 0xA5D6, 0x03A8, 0xA5D7,\r\n\t0x03A9, 0xA5D8, 0x03B1, 0xA5E1, 0x03B2, 0xA5E2, 0x03B3, 0xA5E3,\t0x03B4, 0xA5E4, 0x03B5, 0xA5E5, 0x03B6, 0xA5E6, 0x03B7, 0xA5E7,\r\n\t0x03B8, 0xA5E8, 0x03B9, 0xA5E9, 0x03BA, 0xA5EA, 0x03BB, 0xA5EB,\t0x03BC, 0xA5EC, 0x03BD, 0xA5ED, 0x03BE, 0xA5EE, 0x03BF, 0xA5EF,\r\n\t0x03C0, 0xA5F0, 0x03C1, 0xA5F1, 0x03C3, 0xA5F2, 0x03C4, 0xA5F3,\t0x03C5, 0xA5F4, 0x03C6, 0xA5F5, 0x03C7, 0xA5F6, 0x03C8, 0xA5F7,\r\n\t0x03C9, 0xA5F8, 0x0401, 0xACA7, 0x0410, 0xACA1, 0x0411, 0xACA2,\t0x0412, 0xACA3, 0x0413, 0xACA4, 0x0414, 0xACA5, 0x0415, 0xACA6,\r\n\t0x0416, 0xACA8, 0x0417, 0xACA9, 0x0418, 0xACAA, 0x0419, 0xACAB,\t0x041A, 0xACAC, 0x041B, 0xACAD, 0x041C, 0xACAE, 0x041D, 0xACAF,\r\n\t0x041E, 0xACB0, 0x041F, 0xACB1, 0x0420, 0xACB2, 0x0421, 0xACB3,\t0x0422, 0xACB4, 0x0423, 0xACB5, 0x0424, 0xACB6, 0x0425, 0xACB7,\r\n\t0x0426, 0xACB8, 0x0427, 0xACB9, 0x0428, 0xACBA, 0x0429, 0xACBB,\t0x042A, 0xACBC, 0x042B, 0xACBD, 0x042C, 0xACBE, 0x042D, 0xACBF,\r\n\t0x042E, 0xACC0, 0x042F, 0xACC1, 0x0430, 0xACD1, 0x0431, 0xACD2,\t0x0432, 0xACD3, 0x0433, 0xACD4, 0x0434, 0xACD5, 0x0435, 0xACD6,\r\n\t0x0436, 0xACD8, 0x0437, 0xACD9, 0x0438, 0xACDA, 0x0439, 0xACDB,\t0x043A, 0xACDC, 0x043B, 0xACDD, 0x043C, 0xACDE, 0x043D, 0xACDF,\r\n\t0x043E, 0xACE0, 0x043F, 0xACE1, 0x0440, 0xACE2, 0x0441, 0xACE3,\t0x0442, 0xACE4, 0x0443, 0xACE5, 0x0444, 0xACE6, 0x0445, 0xACE7,\r\n\t0x0446, 0xACE8, 0x0447, 0xACE9, 0x0448, 0xACEA, 0x0449, 0xACEB,\t0x044A, 0xACEC, 0x044B, 0xACED, 0x044C, 0xACEE, 0x044D, 0xACEF,\r\n\t0x044E, 0xACF0, 0x044F, 0xACF1, 0x0451, 0xACD7, 0x2015, 0xA1AA,\t0x2018, 0xA1AE, 0x2019, 0xA1AF, 0x201C, 0xA1B0, 0x201D, 0xA1B1,\r\n\t0x2020, 0xA2D3, 0x2021, 0xA2D4, 0x2025, 0xA1A5, 0x2026, 0xA1A6,\t0x2030, 0xA2B6, 0x2032, 0xA1C7, 0x2033, 0xA1C8, 0x203B, 0xA1D8,\r\n\t0x2074, 0xA9F9, 0x207F, 0xA9FA, 0x2081, 0xA9FB, 0x2082, 0xA9FC,\t0x2083, 0xA9FD, 0x2084, 0xA9FE, 0x20AC, 0xA2E6, 0x2103, 0xA1C9,\r\n\t0x2109, 0xA2B5, 0x2113, 0xA7A4, 0x2116, 0xA2E0, 0x2121, 0xA2E5,\t0x2122, 0xA2E2, 0x2126, 0xA7D9, 0x212B, 0xA1CA, 0x2153, 0xA8F7,\r\n\t0x2154, 0xA8F8, 0x215B, 0xA8FB, 0x215C, 0xA8FC, 0x215D, 0xA8FD,\t0x215E, 0xA8FE, 0x2160, 0xA5B0, 0x2161, 0xA5B1, 0x2162, 0xA5B2,\r\n\t0x2163, 0xA5B3, 0x2164, 0xA5B4, 0x2165, 0xA5B5, 0x2166, 0xA5B6,\t0x2167, 0xA5B7, 0x2168, 0xA5B8, 0x2169, 0xA5B9, 0x2170, 0xA5A1,\r\n\t0x2171, 0xA5A2, 0x2172, 0xA5A3, 0x2173, 0xA5A4, 0x2174, 0xA5A5,\t0x2175, 0xA5A6, 0x2176, 0xA5A7, 0x2177, 0xA5A8, 0x2178, 0xA5A9,\r\n\t0x2179, 0xA5AA, 0x2190, 0xA1E7, 0x2191, 0xA1E8, 0x2192, 0xA1E6,\t0x2193, 0xA1E9, 0x2194, 0xA1EA, 0x2195, 0xA2D5, 0x2196, 0xA2D8,\r\n\t0x2197, 0xA2D6, 0x2198, 0xA2D9, 0x2199, 0xA2D7, 0x21D2, 0xA2A1,\t0x21D4, 0xA2A2, 0x2200, 0xA2A3, 0x2202, 0xA1D3, 0x2203, 0xA2A4,\r\n\t0x2207, 0xA1D4, 0x2208, 0xA1F4, 0x220B, 0xA1F5, 0x220F, 0xA2B3,\t0x2211, 0xA2B2, 0x221A, 0xA1EE, 0x221D, 0xA1F0, 0x221E, 0xA1C4,\r\n\t0x2220, 0xA1D0, 0x2225, 0xA1AB, 0x2227, 0xA1FC, 0x2228, 0xA1FD,\t0x2229, 0xA1FB, 0x222A, 0xA1FA, 0x222B, 0xA1F2, 0x222C, 0xA1F3,\r\n\t0x222E, 0xA2B1, 0x2234, 0xA1C5, 0x2235, 0xA1F1, 0x223C, 0xA1AD,\t0x223D, 0xA1EF, 0x2252, 0xA1D6, 0x2260, 0xA1C1, 0x2261, 0xA1D5,\r\n\t0x2264, 0xA1C2, 0x2265, 0xA1C3, 0x226A, 0xA1EC, 0x226B, 0xA1ED,\t0x2282, 0xA1F8, 0x2283, 0xA1F9, 0x2286, 0xA1F6, 0x2287, 0xA1F7,\r\n\t0x2299, 0xA2C1, 0x22A5, 0xA1D1, 0x2312, 0xA1D2, 0x2460, 0xA8E7,\t0x2461, 0xA8E8, 0x2462, 0xA8E9, 0x2463, 0xA8EA, 0x2464, 0xA8EB,\r\n\t0x2465, 0xA8EC, 0x2466, 0xA8ED, 0x2467, 0xA8EE, 0x2468, 0xA8EF,\t0x2469, 0xA8F0, 0x246A, 0xA8F1, 0x246B, 0xA8F2, 0x246C, 0xA8F3,\r\n\t0x246D, 0xA8F4, 0x246E, 0xA8F5, 0x2474, 0xA9E7, 0x2475, 0xA9E8,\t0x2476, 0xA9E9, 0x2477, 0xA9EA, 0x2478, 0xA9EB, 0x2479, 0xA9EC,\r\n\t0x247A, 0xA9ED, 0x247B, 0xA9EE, 0x247C, 0xA9EF, 0x247D, 0xA9F0,\t0x247E, 0xA9F1, 0x247F, 0xA9F2, 0x2480, 0xA9F3, 0x2481, 0xA9F4,\r\n\t0x2482, 0xA9F5, 0x249C, 0xA9CD, 0x249D, 0xA9CE, 0x249E, 0xA9CF,\t0x249F, 0xA9D0, 0x24A0, 0xA9D1, 0x24A1, 0xA9D2, 0x24A2, 0xA9D3,\r\n\t0x24A3, 0xA9D4, 0x24A4, 0xA9D5, 0x24A5, 0xA9D6, 0x24A6, 0xA9D7,\t0x24A7, 0xA9D8, 0x24A8, 0xA9D9, 0x24A9, 0xA9DA, 0x24AA, 0xA9DB,\r\n\t0x24AB, 0xA9DC, 0x24AC, 0xA9DD, 0x24AD, 0xA9DE, 0x24AE, 0xA9DF,\t0x24AF, 0xA9E0, 0x24B0, 0xA9E1, 0x24B1, 0xA9E2, 0x24B2, 0xA9E3,\r\n\t0x24B3, 0xA9E4, 0x24B4, 0xA9E5, 0x24B5, 0xA9E6, 0x24D0, 0xA8CD,\t0x24D1, 0xA8CE, 0x24D2, 0xA8CF, 0x24D3, 0xA8D0, 0x24D4, 0xA8D1,\r\n\t0x24D5, 0xA8D2, 0x24D6, 0xA8D3, 0x24D7, 0xA8D4, 0x24D8, 0xA8D5,\t0x24D9, 0xA8D6, 0x24DA, 0xA8D7, 0x24DB, 0xA8D8, 0x24DC, 0xA8D9,\r\n\t0x24DD, 0xA8DA, 0x24DE, 0xA8DB, 0x24DF, 0xA8DC, 0x24E0, 0xA8DD,\t0x24E1, 0xA8DE, 0x24E2, 0xA8DF, 0x24E3, 0xA8E0, 0x24E4, 0xA8E1,\r\n\t0x24E5, 0xA8E2, 0x24E6, 0xA8E3, 0x24E7, 0xA8E4, 0x24E8, 0xA8E5,\t0x24E9, 0xA8E6, 0x2500, 0xA6A1, 0x2501, 0xA6AC, 0x2502, 0xA6A2,\r\n\t0x2503, 0xA6AD, 0x250C, 0xA6A3, 0x250D, 0xA6C8, 0x250E, 0xA6C7,\t0x250F, 0xA6AE, 0x2510, 0xA6A4, 0x2511, 0xA6C2, 0x2512, 0xA6C1,\r\n\t0x2513, 0xA6AF, 0x2514, 0xA6A6, 0x2515, 0xA6C6, 0x2516, 0xA6C5,\t0x2517, 0xA6B1, 0x2518, 0xA6A5, 0x2519, 0xA6C4, 0x251A, 0xA6C3,\r\n\t0x251B, 0xA6B0, 0x251C, 0xA6A7, 0x251D, 0xA6BC, 0x251E, 0xA6C9,\t0x251F, 0xA6CA, 0x2520, 0xA6B7, 0x2521, 0xA6CB, 0x2522, 0xA6CC,\r\n\t0x2523, 0xA6B2, 0x2524, 0xA6A9, 0x2525, 0xA6BE, 0x2526, 0xA6CD,\t0x2527, 0xA6CE, 0x2528, 0xA6B9, 0x2529, 0xA6CF, 0x252A, 0xA6D0,\r\n\t0x252B, 0xA6B4, 0x252C, 0xA6A8, 0x252D, 0xA6D1, 0x252E, 0xA6D2,\t0x252F, 0xA6B8, 0x2530, 0xA6BD, 0x2531, 0xA6D3, 0x2532, 0xA6D4,\r\n\t0x2533, 0xA6B3, 0x2534, 0xA6AA, 0x2535, 0xA6D5, 0x2536, 0xA6D6,\t0x2537, 0xA6BA, 0x2538, 0xA6BF, 0x2539, 0xA6D7, 0x253A, 0xA6D8,\r\n\t0x253B, 0xA6B5, 0x253C, 0xA6AB, 0x253D, 0xA6D9, 0x253E, 0xA6DA,\t0x253F, 0xA6BB, 0x2540, 0xA6DB, 0x2541, 0xA6DC, 0x2542, 0xA6C0,\r\n\t0x2543, 0xA6DD, 0x2544, 0xA6DE, 0x2545, 0xA6DF, 0x2546, 0xA6E0,\t0x2547, 0xA6E1, 0x2548, 0xA6E2, 0x2549, 0xA6E3, 0x254A, 0xA6E4,\r\n\t0x254B, 0xA6B6, 0x2592, 0xA2C6, 0x25A0, 0xA1E1, 0x25A1, 0xA1E0,\t0x25A3, 0xA2C3, 0x25A4, 0xA2C7, 0x25A5, 0xA2C8, 0x25A6, 0xA2CB,\r\n\t0x25A7, 0xA2CA, 0x25A8, 0xA2C9, 0x25A9, 0xA2CC, 0x25B2, 0xA1E3,\t0x25B3, 0xA1E2, 0x25B6, 0xA2BA, 0x25B7, 0xA2B9, 0x25BC, 0xA1E5,\r\n\t0x25BD, 0xA1E4, 0x25C0, 0xA2B8, 0x25C1, 0xA2B7, 0x25C6, 0xA1DF,\t0x25C7, 0xA1DE, 0x25C8, 0xA2C2, 0x25CB, 0xA1DB, 0x25CE, 0xA1DD,\r\n\t0x25CF, 0xA1DC, 0x25D0, 0xA2C4, 0x25D1, 0xA2C5, 0x2605, 0xA1DA,\t0x2606, 0xA1D9, 0x260E, 0xA2CF, 0x260F, 0xA2CE, 0x261C, 0xA2D0,\r\n\t0x261E, 0xA2D1, 0x2640, 0xA1CF, 0x2642, 0xA1CE, 0x2660, 0xA2BC,\t0x2661, 0xA2BD, 0x2663, 0xA2C0, 0x2664, 0xA2BB, 0x2665, 0xA2BE,\r\n\t0x2667, 0xA2BF, 0x2668, 0xA2CD, 0x2669, 0xA2DB, 0x266A, 0xA2DC,\t0x266C, 0xA2DD, 0x266D, 0xA2DA, 0x3000, 0xA1A1, 0x3001, 0xA1A2,\r\n\t0x3002, 0xA1A3, 0x3003, 0xA1A8, 0x3008, 0xA1B4, 0x3009, 0xA1B5,\t0x300A, 0xA1B6, 0x300B, 0xA1B7, 0x300C, 0xA1B8, 0x300D, 0xA1B9,\r\n\t0x300E, 0xA1BA, 0x300F, 0xA1BB, 0x3010, 0xA1BC, 0x3011, 0xA1BD,\t0x3013, 0xA1EB, 0x3014, 0xA1B2, 0x3015, 0xA1B3, 0x3041, 0xAAA1,\r\n\t0x3042, 0xAAA2, 0x3043, 0xAAA3, 0x3044, 0xAAA4, 0x3045, 0xAAA5,\t0x3046, 0xAAA6, 0x3047, 0xAAA7, 0x3048, 0xAAA8, 0x3049, 0xAAA9,\r\n\t0x304A, 0xAAAA, 0x304B, 0xAAAB, 0x304C, 0xAAAC, 0x304D, 0xAAAD,\t0x304E, 0xAAAE, 0x304F, 0xAAAF, 0x3050, 0xAAB0, 0x3051, 0xAAB1,\r\n\t0x3052, 0xAAB2, 0x3053, 0xAAB3, 0x3054, 0xAAB4, 0x3055, 0xAAB5,\t0x3056, 0xAAB6, 0x3057, 0xAAB7, 0x3058, 0xAAB8, 0x3059, 0xAAB9,\r\n\t0x305A, 0xAABA, 0x305B, 0xAABB, 0x305C, 0xAABC, 0x305D, 0xAABD,\t0x305E, 0xAABE, 0x305F, 0xAABF, 0x3060, 0xAAC0, 0x3061, 0xAAC1,\r\n\t0x3062, 0xAAC2, 0x3063, 0xAAC3, 0x3064, 0xAAC4, 0x3065, 0xAAC5,\t0x3066, 0xAAC6, 0x3067, 0xAAC7, 0x3068, 0xAAC8, 0x3069, 0xAAC9,\r\n\t0x306A, 0xAACA, 0x306B, 0xAACB, 0x306C, 0xAACC, 0x306D, 0xAACD,\t0x306E, 0xAACE, 0x306F, 0xAACF, 0x3070, 0xAAD0, 0x3071, 0xAAD1,\r\n\t0x3072, 0xAAD2, 0x3073, 0xAAD3, 0x3074, 0xAAD4, 0x3075, 0xAAD5,\t0x3076, 0xAAD6, 0x3077, 0xAAD7, 0x3078, 0xAAD8, 0x3079, 0xAAD9,\r\n\t0x307A, 0xAADA, 0x307B, 0xAADB, 0x307C, 0xAADC, 0x307D, 0xAADD,\t0x307E, 0xAADE, 0x307F, 0xAADF, 0x3080, 0xAAE0, 0x3081, 0xAAE1,\r\n\t0x3082, 0xAAE2, 0x3083, 0xAAE3, 0x3084, 0xAAE4, 0x3085, 0xAAE5,\t0x3086, 0xAAE6, 0x3087, 0xAAE7, 0x3088, 0xAAE8, 0x3089, 0xAAE9,\r\n\t0x308A, 0xAAEA, 0x308B, 0xAAEB, 0x308C, 0xAAEC, 0x308D, 0xAAED,\t0x308E, 0xAAEE, 0x308F, 0xAAEF, 0x3090, 0xAAF0, 0x3091, 0xAAF1,\r\n\t0x3092, 0xAAF2, 0x3093, 0xAAF3, 0x30A1, 0xABA1, 0x30A2, 0xABA2,\t0x30A3, 0xABA3, 0x30A4, 0xABA4, 0x30A5, 0xABA5, 0x30A6, 0xABA6,\r\n\t0x30A7, 0xABA7, 0x30A8, 0xABA8, 0x30A9, 0xABA9, 0x30AA, 0xABAA,\t0x30AB, 0xABAB, 0x30AC, 0xABAC, 0x30AD, 0xABAD, 0x30AE, 0xABAE,\r\n\t0x30AF, 0xABAF, 0x30B0, 0xABB0, 0x30B1, 0xABB1, 0x30B2, 0xABB2,\t0x30B3, 0xABB3, 0x30B4, 0xABB4, 0x30B5, 0xABB5, 0x30B6, 0xABB6,\r\n\t0x30B7, 0xABB7, 0x30B8, 0xABB8, 0x30B9, 0xABB9, 0x30BA, 0xABBA,\t0x30BB, 0xABBB, 0x30BC, 0xABBC, 0x30BD, 0xABBD, 0x30BE, 0xABBE,\r\n\t0x30BF, 0xABBF, 0x30C0, 0xABC0, 0x30C1, 0xABC1, 0x30C2, 0xABC2,\t0x30C3, 0xABC3, 0x30C4, 0xABC4, 0x30C5, 0xABC5, 0x30C6, 0xABC6,\r\n\t0x30C7, 0xABC7, 0x30C8, 0xABC8, 0x30C9, 0xABC9, 0x30CA, 0xABCA,\t0x30CB, 0xABCB, 0x30CC, 0xABCC, 0x30CD, 0xABCD, 0x30CE, 0xABCE,\r\n\t0x30CF, 0xABCF, 0x30D0, 0xABD0, 0x30D1, 0xABD1, 0x30D2, 0xABD2,\t0x30D3, 0xABD3, 0x30D4, 0xABD4, 0x30D5, 0xABD5, 0x30D6, 0xABD6,\r\n\t0x30D7, 0xABD7, 0x30D8, 0xABD8, 0x30D9, 0xABD9, 0x30DA, 0xABDA,\t0x30DB, 0xABDB, 0x30DC, 0xABDC, 0x30DD, 0xABDD, 0x30DE, 0xABDE,\r\n\t0x30DF, 0xABDF, 0x30E0, 0xABE0, 0x30E1, 0xABE1, 0x30E2, 0xABE2,\t0x30E3, 0xABE3, 0x30E4, 0xABE4, 0x30E5, 0xABE5, 0x30E6, 0xABE6,\r\n\t0x30E7, 0xABE7, 0x30E8, 0xABE8, 0x30E9, 0xABE9, 0x30EA, 0xABEA,\t0x30EB, 0xABEB, 0x30EC, 0xABEC, 0x30ED, 0xABED, 0x30EE, 0xABEE,\r\n\t0x30EF, 0xABEF, 0x30F0, 0xABF0, 0x30F1, 0xABF1, 0x30F2, 0xABF2,\t0x30F3, 0xABF3, 0x30F4, 0xABF4, 0x30F5, 0xABF5, 0x30F6, 0xABF6,\r\n\t0x3131, 0xA4A1, 0x3132, 0xA4A2, 0x3133, 0xA4A3, 0x3134, 0xA4A4,\t0x3135, 0xA4A5, 0x3136, 0xA4A6, 0x3137, 0xA4A7, 0x3138, 0xA4A8,\r\n\t0x3139, 0xA4A9, 0x313A, 0xA4AA, 0x313B, 0xA4AB, 0x313C, 0xA4AC,\t0x313D, 0xA4AD, 0x313E, 0xA4AE, 0x313F, 0xA4AF, 0x3140, 0xA4B0,\r\n\t0x3141, 0xA4B1, 0x3142, 0xA4B2, 0x3143, 0xA4B3, 0x3144, 0xA4B4,\t0x3145, 0xA4B5, 0x3146, 0xA4B6, 0x3147, 0xA4B7, 0x3148, 0xA4B8,\r\n\t0x3149, 0xA4B9, 0x314A, 0xA4BA, 0x314B, 0xA4BB, 0x314C, 0xA4BC,\t0x314D, 0xA4BD, 0x314E, 0xA4BE, 0x314F, 0xA4BF, 0x3150, 0xA4C0,\r\n\t0x3151, 0xA4C1, 0x3152, 0xA4C2, 0x3153, 0xA4C3, 0x3154, 0xA4C4,\t0x3155, 0xA4C5, 0x3156, 0xA4C6, 0x3157, 0xA4C7, 0x3158, 0xA4C8,\r\n\t0x3159, 0xA4C9, 0x315A, 0xA4CA, 0x315B, 0xA4CB, 0x315C, 0xA4CC,\t0x315D, 0xA4CD, 0x315E, 0xA4CE, 0x315F, 0xA4CF, 0x3160, 0xA4D0,\r\n\t0x3161, 0xA4D1, 0x3162, 0xA4D2, 0x3163, 0xA4D3, 0x3164, 0xA4D4,\t0x3165, 0xA4D5, 0x3166, 0xA4D6, 0x3167, 0xA4D7, 0x3168, 0xA4D8,\r\n\t0x3169, 0xA4D9, 0x316A, 0xA4DA, 0x316B, 0xA4DB, 0x316C, 0xA4DC,\t0x316D, 0xA4DD, 0x316E, 0xA4DE, 0x316F, 0xA4DF, 0x3170, 0xA4E0,\r\n\t0x3171, 0xA4E1, 0x3172, 0xA4E2, 0x3173, 0xA4E3, 0x3174, 0xA4E4,\t0x3175, 0xA4E5, 0x3176, 0xA4E6, 0x3177, 0xA4E7, 0x3178, 0xA4E8,\r\n\t0x3179, 0xA4E9, 0x317A, 0xA4EA, 0x317B, 0xA4EB, 0x317C, 0xA4EC,\t0x317D, 0xA4ED, 0x317E, 0xA4EE, 0x317F, 0xA4EF, 0x3180, 0xA4F0,\r\n\t0x3181, 0xA4F1, 0x3182, 0xA4F2, 0x3183, 0xA4F3, 0x3184, 0xA4F4,\t0x3185, 0xA4F5, 0x3186, 0xA4F6, 0x3187, 0xA4F7, 0x3188, 0xA4F8,\r\n\t0x3189, 0xA4F9, 0x318A, 0xA4FA, 0x318B, 0xA4FB, 0x318C, 0xA4FC,\t0x318D, 0xA4FD, 0x318E, 0xA4FE, 0x3200, 0xA9B1, 0x3201, 0xA9B2,\r\n\t0x3202, 0xA9B3, 0x3203, 0xA9B4, 0x3204, 0xA9B5, 0x3205, 0xA9B6,\t0x3206, 0xA9B7, 0x3207, 0xA9B8, 0x3208, 0xA9B9, 0x3209, 0xA9BA,\r\n\t0x320A, 0xA9BB, 0x320B, 0xA9BC, 0x320C, 0xA9BD, 0x320D, 0xA9BE,\t0x320E, 0xA9BF, 0x320F, 0xA9C0, 0x3210, 0xA9C1, 0x3211, 0xA9C2,\r\n\t0x3212, 0xA9C3, 0x3213, 0xA9C4, 0x3214, 0xA9C5, 0x3215, 0xA9C6,\t0x3216, 0xA9C7, 0x3217, 0xA9C8, 0x3218, 0xA9C9, 0x3219, 0xA9CA,\r\n\t0x321A, 0xA9CB, 0x321B, 0xA9CC, 0x321C, 0xA2DF, 0x3260, 0xA8B1,\t0x3261, 0xA8B2, 0x3262, 0xA8B3, 0x3263, 0xA8B4, 0x3264, 0xA8B5,\r\n\t0x3265, 0xA8B6, 0x3266, 0xA8B7, 0x3267, 0xA8B8, 0x3268, 0xA8B9,\t0x3269, 0xA8BA, 0x326A, 0xA8BB, 0x326B, 0xA8BC, 0x326C, 0xA8BD,\r\n\t0x326D, 0xA8BE, 0x326E, 0xA8BF, 0x326F, 0xA8C0, 0x3270, 0xA8C1,\t0x3271, 0xA8C2, 0x3272, 0xA8C3, 0x3273, 0xA8C4, 0x3274, 0xA8C5,\r\n\t0x3275, 0xA8C6, 0x3276, 0xA8C7, 0x3277, 0xA8C8, 0x3278, 0xA8C9,\t0x3279, 0xA8CA, 0x327A, 0xA8CB, 0x327B, 0xA8CC, 0x327F, 0xA2DE,\r\n\t0x3380, 0xA7C9, 0x3381, 0xA7CA, 0x3382, 0xA7CB, 0x3383, 0xA7CC,\t0x3384, 0xA7CD, 0x3388, 0xA7BA, 0x3389, 0xA7BB, 0x338A, 0xA7DC,\r\n\t0x338B, 0xA7DD, 0x338C, 0xA7DE, 0x338D, 0xA7B6, 0x338E, 0xA7B7,\t0x338F, 0xA7B8, 0x3390, 0xA7D4, 0x3391, 0xA7D5, 0x3392, 0xA7D6,\r\n\t0x3393, 0xA7D7, 0x3394, 0xA7D8, 0x3395, 0xA7A1, 0x3396, 0xA7A2,\t0x3397, 0xA7A3, 0x3398, 0xA7A5, 0x3399, 0xA7AB, 0x339A, 0xA7AC,\r\n\t0x339B, 0xA7AD, 0x339C, 0xA7AE, 0x339D, 0xA7AF, 0x339E, 0xA7B0,\t0x339F, 0xA7B1, 0x33A0, 0xA7B2, 0x33A1, 0xA7B3, 0x33A2, 0xA7B4,\r\n\t0x33A3, 0xA7A7, 0x33A4, 0xA7A8, 0x33A5, 0xA7A9, 0x33A6, 0xA7AA,\t0x33A7, 0xA7BD, 0x33A8, 0xA7BE, 0x33A9, 0xA7E5, 0x33AA, 0xA7E6,\r\n\t0x33AB, 0xA7E7, 0x33AC, 0xA7E8, 0x33AD, 0xA7E1, 0x33AE, 0xA7E2,\t0x33AF, 0xA7E3, 0x33B0, 0xA7BF, 0x33B1, 0xA7C0, 0x33B2, 0xA7C1,\r\n\t0x33B3, 0xA7C2, 0x33B4, 0xA7C3, 0x33B5, 0xA7C4, 0x33B6, 0xA7C5,\t0x33B7, 0xA7C6, 0x33B8, 0xA7C7, 0x33B9, 0xA7C8, 0x33BA, 0xA7CE,\r\n\t0x33BB, 0xA7CF, 0x33BC, 0xA7D0, 0x33BD, 0xA7D1, 0x33BE, 0xA7D2,\t0x33BF, 0xA7D3, 0x33C0, 0xA7DA, 0x33C1, 0xA7DB, 0x33C2, 0xA2E3,\r\n\t0x33C3, 0xA7EC, 0x33C4, 0xA7A6, 0x33C5, 0xA7E0, 0x33C6, 0xA7EF,\t0x33C7, 0xA2E1, 0x33C8, 0xA7BC, 0x33C9, 0xA7ED, 0x33CA, 0xA7B5,\r\n\t0x33CF, 0xA7B9, 0x33D0, 0xA7EA, 0x33D3, 0xA7EB, 0x33D6, 0xA7DF,\t0x33D8, 0xA2E4, 0x33DB, 0xA7E4, 0x33DC, 0xA7EE, 0x33DD, 0xA7E9,\r\n\t0x4E00, 0xECE9, 0x4E01, 0xEFCB, 0x4E03, 0xF6D2, 0x4E07, 0xD8B2,\t0x4E08, 0xEDDB, 0x4E09, 0xDFB2, 0x4E0A, 0xDFBE, 0x4E0B, 0xF9BB,\r\n\t0x4E0D, 0xDCF4, 0x4E11, 0xF5E4, 0x4E14, 0xF3A6, 0x4E15, 0xDDE0,\t0x4E16, 0xE1A6, 0x4E18, 0xCEF8, 0x4E19, 0xDCB0, 0x4E1E, 0xE3AA,\r\n\t0x4E2D, 0xF1E9, 0x4E32, 0xCDFA, 0x4E38, 0xFCAF, 0x4E39, 0xD3A1,\t0x4E3B, 0xF1AB, 0x4E42, 0xE7D1, 0x4E43, 0xD2AC, 0x4E45, 0xCEF9,\r\n\t0x4E4B, 0xF1FD, 0x4E4D, 0xDEBF, 0x4E4E, 0xFBBA, 0x4E4F, 0xF9B9,\t0x4E56, 0xCED2, 0x4E58, 0xE3AB, 0x4E59, 0xEBE0, 0x4E5D, 0xCEFA,\r\n\t0x4E5E, 0xCBF7, 0x4E5F, 0xE5A5, 0x4E6B, 0xCAE1, 0x4E6D, 0xD4CC,\t0x4E73, 0xEAE1, 0x4E76, 0xDCE3, 0x4E77, 0xDFAD, 0x4E7E, 0xCBEB,\r\n\t0x4E82, 0xD5AF, 0x4E86, 0xD6F5, 0x4E88, 0xE5F8, 0x4E8B, 0xDEC0,\t0x4E8C, 0xECA3, 0x4E8E, 0xE9CD, 0x4E90, 0xEAA7, 0x4E91, 0xE9F6,\r\n\t0x4E92, 0xFBBB, 0x4E94, 0xE7E9, 0x4E95, 0xEFCC, 0x4E98, 0xD0E6,\t0x4E9B, 0xDEC1, 0x4E9E, 0xE4AC, 0x4EA1, 0xD8CC, 0x4EA2, 0xF9F1,\r\n\t0x4EA4, 0xCEDF, 0x4EA5, 0xFAA4, 0x4EA6, 0xE6B2, 0x4EA8, 0xFAFB,\t0x4EAB, 0xFABD, 0x4EAC, 0xCCC8, 0x4EAD, 0xEFCD, 0x4EAE, 0xD5D5,\r\n\t0x4EB6, 0xD3A2, 0x4EBA, 0xECD1, 0x4EC0, 0xE4A7, 0x4EC1, 0xECD2,\t0x4EC4, 0xF6B1, 0x4EC7, 0xCEFB, 0x4ECA, 0xD0D1, 0x4ECB, 0xCBBF,\r\n\t0x4ECD, 0xEDA4, 0x4ED4, 0xEDA8, 0x4ED5, 0xDEC2, 0x4ED6, 0xF6E2,\t0x4ED7, 0xEDDC, 0x4ED8, 0xDCF5, 0x4ED9, 0xE0B9, 0x4EDD, 0xD4CE,\r\n\t0x4EDF, 0xF4B5, 0x4EE3, 0xD3DB, 0x4EE4, 0xD6B5, 0x4EE5, 0xECA4,\t0x4EF0, 0xE4E6, 0x4EF2, 0xF1EA, 0x4EF6, 0xCBEC, 0x4EF7, 0xCBC0,\r\n\t0x4EFB, 0xECF2, 0x4F01, 0xD0EA, 0x4F09, 0xF9F2, 0x4F0A, 0xECA5,\t0x4F0B, 0xD0DF, 0x4F0D, 0xE7EA, 0x4F0E, 0xD0EB, 0x4F0F, 0xDCD1,\r\n\t0x4F10, 0xDBE9, 0x4F11, 0xFDCC, 0x4F2F, 0xDBD7, 0x4F34, 0xDAE1,\t0x4F36, 0xD6B6, 0x4F38, 0xE3DF, 0x4F3A, 0xDEC3, 0x4F3C, 0xDEC4,\r\n\t0x4F3D, 0xCAA1, 0x4F43, 0xEEEC, 0x4F46, 0xD3A3, 0x4F47, 0xEEB7,\t0x4F48, 0xF8CF, 0x4F4D, 0xEAC8, 0x4F4E, 0xEEB8, 0x4F4F, 0xF1AC,\r\n\t0x4F50, 0xF1A5, 0x4F51, 0xE9CE, 0x4F55, 0xF9BC, 0x4F59, 0xE5F9,\t0x4F5A, 0xECEA, 0x4F5B, 0xDDD6, 0x4F5C, 0xEDC2, 0x4F69, 0xF8A5,\r\n\t0x4F6F, 0xE5BA, 0x4F70, 0xDBD8, 0x4F73, 0xCAA2, 0x4F76, 0xD1CD,\t0x4F7A, 0xEEED, 0x4F7E, 0xECEB, 0x4F7F, 0xDEC5, 0x4F81, 0xE3E0,\r\n\t0x4F83, 0xCAC9, 0x4F84, 0xF2E9, 0x4F86, 0xD5CE, 0x4F88, 0xF6B6,\t0x4F8A, 0xCEC2, 0x4F8B, 0xD6C7, 0x4F8D, 0xE3B4, 0x4F8F, 0xF1AD,\r\n\t0x4F91, 0xEAE2, 0x4F96, 0xD7C2, 0x4F98, 0xF3A7, 0x4F9B, 0xCDEA,\t0x4F9D, 0xEBEE, 0x4FAE, 0xD9B2, 0x4FAF, 0xFDA5, 0x4FB5, 0xF6D5,\r\n\t0x4FB6, 0xD5E2, 0x4FBF, 0xF8B5, 0x4FC2, 0xCCF5, 0x4FC3, 0xF5B5,\t0x4FC4, 0xE4AD, 0x4FC9, 0xE7EB, 0x4FCA, 0xF1D5, 0x4FCE, 0xF0BB,\r\n\t0x4FD1, 0xE9B5, 0x4FD3, 0xCCC9, 0x4FD4, 0xFAD5, 0x4FD7, 0xE1D4,\t0x4FDA, 0xD7D6, 0x4FDD, 0xDCC1, 0x4FDF, 0xDEC6, 0x4FE0, 0xFAEF,\r\n\t0x4FE1, 0xE3E1, 0x4FEE, 0xE1F3, 0x4FEF, 0xDCF6, 0x4FF1, 0xCEFC,\t0x4FF3, 0xDBC4, 0x4FF5, 0xF8F1, 0x4FF8, 0xDCE4, 0x4FFA, 0xE5EF,\r\n\t0x5002, 0xDCB1, 0x5006, 0xD5D6, 0x5009, 0xF3DA, 0x500B, 0xCBC1,\t0x500D, 0xDBC3, 0x5011, 0xD9FA, 0x5012, 0xD3EE, 0x5016, 0xFAB8,\r\n\t0x5019, 0xFDA6, 0x501A, 0xEBEF, 0x501C, 0xF4A6, 0x501E, 0xCCCA,\t0x501F, 0xF3A8, 0x5021, 0xF3DB, 0x5023, 0xDBA7, 0x5024, 0xF6B7,\r\n\t0x5026, 0xCFE6, 0x5027, 0xF0F2, 0x5028, 0xCBDA, 0x502A, 0xE7D2,\t0x502B, 0xD7C3, 0x502C, 0xF6F0, 0x502D, 0xE8DE, 0x503B, 0xE5A6,\r\n\t0x5043, 0xE5E7, 0x5047, 0xCAA3, 0x5048, 0xCCA7, 0x5049, 0xEAC9,\t0x504F, 0xF8B6, 0x5055, 0xFAA5, 0x505A, 0xF1AE, 0x505C, 0xEFCE,\r\n\t0x5065, 0xCBED, 0x5074, 0xF6B0, 0x5075, 0xEFCF, 0x5076, 0xE9CF,\t0x5078, 0xF7DE, 0x5080, 0xCED3, 0x5085, 0xDCF7, 0x508D, 0xDBA8,\r\n\t0x5091, 0xCBF8, 0x5098, 0xDFA1, 0x5099, 0xDDE1, 0x50AC, 0xF5CA,\t0x50AD, 0xE9B6, 0x50B2, 0xE7EC, 0x50B3, 0xEEEE, 0x50B5, 0xF3F0,\r\n\t0x50B7, 0xDFBF, 0x50BE, 0xCCCB, 0x50C5, 0xD0C1, 0x50C9, 0xF4D2,\t0x50CA, 0xE0BA, 0x50CF, 0xDFC0, 0x50D1, 0xCEE0, 0x50D5, 0xDCD2,\r\n\t0x50D6, 0xFDEA, 0x50DA, 0xD6F6, 0x50DE, 0xEACA, 0x50E5, 0xE8E9,\t0x50E7, 0xE3AC, 0x50ED, 0xF3D0, 0x50F9, 0xCAA4, 0x50FB, 0xDBF8,\r\n\t0x50FF, 0xDEC7, 0x5100, 0xEBF0, 0x5101, 0xF1D6, 0x5104, 0xE5E2,\t0x5106, 0xCCCC, 0x5109, 0xCBFB, 0x5112, 0xEAE3, 0x511F, 0xDFC1,\r\n\t0x5121, 0xD6ED, 0x512A, 0xE9D0, 0x5132, 0xEEB9, 0x5137, 0xD5E3,\t0x513A, 0xD1D3, 0x513C, 0xE5F0, 0x5140, 0xE8B4, 0x5141, 0xEBC3,\r\n\t0x5143, 0xEAAA, 0x5144, 0xFAFC, 0x5145, 0xF5F6, 0x5146, 0xF0BC,\t0x5147, 0xFDD4, 0x5148, 0xE0BB, 0x5149, 0xCEC3, 0x514B, 0xD0BA,\r\n\t0x514C, 0xF7BA, 0x514D, 0xD8F3, 0x514E, 0xF7CD, 0x5152, 0xE4AE,\t0x515C, 0xD4DF, 0x5162, 0xD0E7, 0x5165, 0xECFD, 0x5167, 0xD2AE,\r\n\t0x5168, 0xEEEF, 0x5169, 0xD5D7, 0x516A, 0xEAE4, 0x516B, 0xF8A2,\t0x516C, 0xCDEB, 0x516D, 0xD7BF, 0x516E, 0xFBB1, 0x5171, 0xCDEC,\r\n\t0x5175, 0xDCB2, 0x5176, 0xD0EC, 0x5177, 0xCEFD, 0x5178, 0xEEF0,\t0x517C, 0xCCC2, 0x5180, 0xD0ED, 0x5186, 0xE5F7, 0x518A, 0xF3FC,\r\n\t0x518D, 0xEEA2, 0x5192, 0xD9B3, 0x5195, 0xD8F4, 0x5197, 0xE9B7,\t0x51A0, 0xCEAE, 0x51A5, 0xD9A2, 0x51AA, 0xD8F1, 0x51AC, 0xD4CF,\r\n\t0x51B6, 0xE5A7, 0x51B7, 0xD5D2, 0x51BD, 0xD6A9, 0x51C4, 0xF4A2,\t0x51C6, 0xF1D7, 0x51C9, 0xD5D8, 0x51CB, 0xF0BD, 0x51CC, 0xD7D0,\r\n\t0x51CD, 0xD4D0, 0x51DC, 0xD7CF, 0x51DD, 0xEBEA, 0x51DE, 0xFDEB,\t0x51E1, 0xDBED, 0x51F0, 0xFCC5, 0x51F1, 0xCBC2, 0x51F6, 0xFDD5,\r\n\t0x51F8, 0xF4C8, 0x51F9, 0xE8EA, 0x51FA, 0xF5F3, 0x51FD, 0xF9DE,\t0x5200, 0xD3EF, 0x5203, 0xECD3, 0x5206, 0xDDC2, 0x5207, 0xEFB7,\r\n\t0x5208, 0xE7D4, 0x520A, 0xCACA, 0x520E, 0xD9FB, 0x5211, 0xFAFD,\t0x5217, 0xD6AA, 0x521D, 0xF4F8, 0x5224, 0xF7F7, 0x5225, 0xDCAC,\r\n\t0x5229, 0xD7D7, 0x522A, 0xDFA2, 0x522E, 0xCEBE, 0x5230, 0xD3F0,\t0x5236, 0xF0A4, 0x5237, 0xE1EC, 0x5238, 0xCFE7, 0x5239, 0xF3CB,\r\n\t0x523A, 0xEDA9, 0x523B, 0xCABE, 0x5243, 0xF4EF, 0x5247, 0xF6CE,\t0x524A, 0xDEFB, 0x524B, 0xD0BB, 0x524C, 0xD5B7, 0x524D, 0xEEF1,\r\n\t0x5254, 0xF4A8, 0x5256, 0xDCF8, 0x525B, 0xCBA7, 0x525D, 0xDACE,\t0x5261, 0xE0E6, 0x5269, 0xEDA5, 0x526A, 0xEEF2, 0x526F, 0xDCF9,\r\n\t0x5272, 0xF9DC, 0x5275, 0xF3DC, 0x527D, 0xF8F2, 0x527F, 0xF4F9,\t0x5283, 0xFCF1, 0x5287, 0xD0BC, 0x5288, 0xDBF9, 0x5289, 0xD7B1,\r\n\t0x528D, 0xCBFC, 0x5291, 0xF0A5, 0x5292, 0xCBFD, 0x529B, 0xD5F4,\t0x529F, 0xCDED, 0x52A0, 0xCAA5, 0x52A3, 0xD6AB, 0x52A4, 0xD0C2,\r\n\t0x52A9, 0xF0BE, 0x52AA, 0xD2BD, 0x52AB, 0xCCA4, 0x52BE, 0xFAB6,\t0x52C1, 0xCCCD, 0x52C3, 0xDAFA, 0x52C5, 0xF6CF, 0x52C7, 0xE9B8,\r\n\t0x52C9, 0xD8F5, 0x52CD, 0xCCCE, 0x52D2, 0xD7CD, 0x52D5, 0xD4D1,\t0x52D6, 0xE9ED, 0x52D8, 0xCAEB, 0x52D9, 0xD9E2, 0x52DB, 0xFDB2,\r\n\t0x52DD, 0xE3AD, 0x52DE, 0xD6CC, 0x52DF, 0xD9B4, 0x52E2, 0xE1A7,\t0x52E3, 0xEED3, 0x52E4, 0xD0C3, 0x52F3, 0xFDB3, 0x52F5, 0xD5E4,\r\n\t0x52F8, 0xCFE8, 0x52FA, 0xEDC3, 0x52FB, 0xD0B2, 0x52FE, 0xCEFE,\t0x52FF, 0xDAA8, 0x5305, 0xF8D0, 0x5308, 0xFDD6, 0x530D, 0xF8D1,\r\n\t0x530F, 0xF8D2, 0x5310, 0xDCD3, 0x5315, 0xDDE2, 0x5316, 0xFBF9,\t0x5317, 0xDDC1, 0x5319, 0xE3B5, 0x5320, 0xEDDD, 0x5321, 0xCEC4,\r\n\t0x5323, 0xCBA1, 0x532A, 0xDDE3, 0x532F, 0xFCDD, 0x5339, 0xF9AF,\t0x533F, 0xD2FB, 0x5340, 0xCFA1, 0x5341, 0xE4A8, 0x5343, 0xF4B6,\r\n\t0x5344, 0xECFE, 0x5347, 0xE3AE, 0x5348, 0xE7ED, 0x5349, 0xFDC1,\t0x534A, 0xDAE2, 0x534D, 0xD8B3, 0x5351, 0xDDE4, 0x5352, 0xF0EF,\r\n\t0x5353, 0xF6F1, 0x5354, 0xFAF0, 0x5357, 0xD1F5, 0x535A, 0xDACF,\t0x535C, 0xDCD4, 0x535E, 0xDCA6, 0x5360, 0xEFBF, 0x5366, 0xCECF,\r\n\t0x5368, 0xE0D9, 0x536F, 0xD9D6, 0x5370, 0xECD4, 0x5371, 0xEACB,\t0x5374, 0xCABF, 0x5375, 0xD5B0, 0x5377, 0xCFE9, 0x537D, 0xF1ED,\r\n\t0x537F, 0xCCCF, 0x5384, 0xE4F8, 0x5393, 0xE4ED, 0x5398, 0xD7D8,\t0x539A, 0xFDA7, 0x539F, 0xEAAB, 0x53A0, 0xF6B2, 0x53A5, 0xCFF0,\r\n\t0x53A6, 0xF9BD, 0x53AD, 0xE6F4, 0x53BB, 0xCBDB, 0x53C3, 0xF3D1,\t0x53C8, 0xE9D1, 0x53C9, 0xF3A9, 0x53CA, 0xD0E0, 0x53CB, 0xE9D2,\r\n\t0x53CD, 0xDAE3, 0x53D4, 0xE2D2, 0x53D6, 0xF6A2, 0x53D7, 0xE1F4,\t0x53DB, 0xDAE4, 0x53E1, 0xE7D5, 0x53E2, 0xF5BF, 0x53E3, 0xCFA2,\r\n\t0x53E4, 0xCDAF, 0x53E5, 0xCFA3, 0x53E9, 0xCDB0, 0x53EA, 0xF1FE,\t0x53EB, 0xD0A3, 0x53EC, 0xE1AF, 0x53ED, 0xF8A3, 0x53EF, 0xCAA6,\r\n\t0x53F0, 0xF7BB, 0x53F1, 0xF2EA, 0x53F2, 0xDEC8, 0x53F3, 0xE9D3,\t0x53F8, 0xDEC9, 0x5403, 0xFDDE, 0x5404, 0xCAC0, 0x5408, 0xF9EA,\r\n\t0x5409, 0xD1CE, 0x540A, 0xEED4, 0x540C, 0xD4D2, 0x540D, 0xD9A3,\t0x540E, 0xFDA8, 0x540F, 0xD7D9, 0x5410, 0xF7CE, 0x5411, 0xFABE,\r\n\t0x541B, 0xCFD6, 0x541D, 0xD7F0, 0x541F, 0xEBE1, 0x5420, 0xF8C5,\t0x5426, 0xDCFA, 0x5429, 0xDDC3, 0x542B, 0xF9DF, 0x5433, 0xE7EF,\r\n\t0x5438, 0xFDE5, 0x5439, 0xF6A3, 0x543B, 0xD9FC, 0x543C, 0xFDA9,\t0x543E, 0xE7EE, 0x5442, 0xD5E5, 0x5448, 0xEFD0, 0x544A, 0xCDB1,\r\n\t0x5451, 0xF7A2, 0x5468, 0xF1B2, 0x546A, 0xF1B1, 0x5471, 0xCDB2,\t0x5473, 0xDAAB, 0x5475, 0xCAA7, 0x547B, 0xE3E2, 0x547C, 0xFBBC,\r\n\t0x547D, 0xD9A4, 0x5480, 0xEEBA, 0x5486, 0xF8D3, 0x548C, 0xFBFA,\t0x548E, 0xCFA4, 0x5490, 0xDCFB, 0x54A4, 0xF6E3, 0x54A8, 0xEDAA,\r\n\t0x54AB, 0xF2A1, 0x54AC, 0xCEE1, 0x54B3, 0xFAA6, 0x54B8, 0xF9E0,\t0x54BD, 0xECD6, 0x54C0, 0xE4EE, 0x54C1, 0xF9A1, 0x54C4, 0xFBEF,\r\n\t0x54C8, 0xF9EB, 0x54C9, 0xEEA3, 0x54E1, 0xEAAC, 0x54E5, 0xCAA8,\t0x54E8, 0xF4FA, 0x54ED, 0xCDD6, 0x54EE, 0xFCF6, 0x54F2, 0xF4C9,\r\n\t0x54FA, 0xF8D4, 0x5504, 0xF8A6, 0x5506, 0xDECA, 0x5507, 0xF2C6,\t0x550E, 0xD7DA, 0x5510, 0xD3D0, 0x551C, 0xD8C5, 0x552F, 0xEAE6,\r\n\t0x5531, 0xF3DD, 0x5535, 0xE4DA, 0x553E, 0xF6E4, 0x5544, 0xF6F2,\t0x5546, 0xDFC2, 0x554F, 0xD9FD, 0x5553, 0xCCF6, 0x5556, 0xD3BA,\r\n\t0x555E, 0xE4AF, 0x5563, 0xF9E1, 0x557C, 0xF0A6, 0x5580, 0xCBD3,\t0x5584, 0xE0BC, 0x5586, 0xF4CA, 0x5587, 0xD4FA, 0x5589, 0xFDAA,\r\n\t0x558A, 0xF9E2, 0x5598, 0xF4B7, 0x5599, 0xFDC2, 0x559A, 0xFCB0,\t0x559C, 0xFDEC, 0x559D, 0xCAE2, 0x55A7, 0xFDBD, 0x55A9, 0xEAE7,\r\n\t0x55AA, 0xDFC3, 0x55AB, 0xD1D2, 0x55AC, 0xCEE2, 0x55AE, 0xD3A4,\t0x55C5, 0xFDAB, 0x55C7, 0xDFE0, 0x55D4, 0xF2C7, 0x55DA, 0xE7F0,\r\n\t0x55DC, 0xD0EE, 0x55DF, 0xF3AA, 0x55E3, 0xDECB, 0x55E4, 0xF6B8,\t0x55FD, 0xE1F5, 0x55FE, 0xF1B3, 0x5606, 0xF7A3, 0x5609, 0xCAA9,\r\n\t0x5614, 0xCFA5, 0x5617, 0xDFC4, 0x562F, 0xE1B0, 0x5632, 0xF0BF,\t0x5634, 0xF6A4, 0x5636, 0xE3B6, 0x5653, 0xFAC6, 0x5668, 0xD0EF,\r\n\t0x566B, 0xFDED, 0x5674, 0xDDC4, 0x5686, 0xFCF7, 0x56A5, 0xE6BF,\t0x56AC, 0xDEAD, 0x56AE, 0xFABF, 0x56B4, 0xE5F1, 0x56BC, 0xEDC4,\r\n\t0x56CA, 0xD2A5, 0x56CD, 0xFDEE, 0x56D1, 0xF5B6, 0x56DA, 0xE1F6,\t0x56DB, 0xDECC, 0x56DE, 0xFCDE, 0x56E0, 0xECD7, 0x56F0, 0xCDDD,\r\n\t0x56F9, 0xD6B7, 0x56FA, 0xCDB3, 0x5703, 0xF8D5, 0x5704, 0xE5D8,\t0x5708, 0xCFEA, 0x570B, 0xCFD0, 0x570D, 0xEACC, 0x5712, 0xEAAE,\r\n\t0x5713, 0xEAAD, 0x5716, 0xD3F1, 0x5718, 0xD3A5, 0x571F, 0xF7CF,\t0x5728, 0xEEA4, 0x572D, 0xD0A4, 0x5730, 0xF2A2, 0x573B, 0xD0F0,\r\n\t0x5740, 0xF2A3, 0x5742, 0xF7F8, 0x5747, 0xD0B3, 0x574A, 0xDBA9,\t0x574D, 0xD3BB, 0x574E, 0xCAEC, 0x5750, 0xF1A6, 0x5751, 0xCBD5,\r\n\t0x5761, 0xF7E7, 0x5764, 0xCDDE, 0x5766, 0xF7A4, 0x576A, 0xF8C0,\t0x576E, 0xD3DD, 0x5770, 0xCCD0, 0x5775, 0xCFA6, 0x577C, 0xF6F3,\r\n\t0x5782, 0xE1F7, 0x5788, 0xD3DC, 0x578B, 0xFAFE, 0x5793, 0xFAA7,\t0x57A0, 0xEBD9, 0x57A2, 0xCFA7, 0x57A3, 0xEAAF, 0x57C3, 0xE4EF,\r\n\t0x57C7, 0xE9B9, 0x57C8, 0xF1D8, 0x57CB, 0xD8D8, 0x57CE, 0xE0F2,\t0x57DF, 0xE6B4, 0x57E0, 0xDCFC, 0x57F0, 0xF3F1, 0x57F4, 0xE3D0,\r\n\t0x57F7, 0xF2FB, 0x57F9, 0xDBC6, 0x57FA, 0xD0F1, 0x57FC, 0xD0F2,\t0x5800, 0xCFDC, 0x5802, 0xD3D1, 0x5805, 0xCCB1, 0x5806, 0xF7D8,\r\n\t0x5808, 0xCBA8, 0x5809, 0xEBBC, 0x580A, 0xE4BE, 0x581E, 0xF4DC,\t0x5821, 0xDCC2, 0x5824, 0xF0A7, 0x5827, 0xE6C0, 0x582A, 0xCAED,\r\n\t0x582F, 0xE8EB, 0x5830, 0xE5E8, 0x5831, 0xDCC3, 0x5834, 0xEDDE,\t0x5835, 0xD3F2, 0x583A, 0xCCF7, 0x584A, 0xCED4, 0x584B, 0xE7AB,\r\n\t0x584F, 0xCBC3, 0x5851, 0xE1B1, 0x5854, 0xF7B2, 0x5857, 0xD3F3,\t0x5858, 0xD3D2, 0x585A, 0xF5C0, 0x585E, 0xDFDD, 0x5861, 0xEEF3,\r\n\t0x5862, 0xE7F1, 0x5864, 0xFDB4, 0x5875, 0xF2C8, 0x5879, 0xF3D2,\t0x587C, 0xEEF4, 0x587E, 0xE2D3, 0x5883, 0xCCD1, 0x5885, 0xDFEA,\r\n\t0x5889, 0xE9BA, 0x5893, 0xD9D7, 0x589C, 0xF5CD, 0x589E, 0xF1F2,\t0x589F, 0xFAC7, 0x58A8, 0xD9F8, 0x58A9, 0xD4C2, 0x58AE, 0xF6E5,\r\n\t0x58B3, 0xDDC5, 0x58BA, 0xE7F2, 0x58BB, 0xEDDF, 0x58BE, 0xCACB,\t0x58C1, 0xDBFA, 0x58C5, 0xE8B5, 0x58C7, 0xD3A6, 0x58CE, 0xFDB5,\r\n\t0x58D1, 0xF9C9, 0x58D3, 0xE4E2, 0x58D5, 0xFBBD, 0x58D8, 0xD7A4,\t0x58D9, 0xCEC5, 0x58DE, 0xCED5, 0x58DF, 0xD6E6, 0x58E4, 0xE5BD,\r\n\t0x58EB, 0xDECD, 0x58EC, 0xECF3, 0x58EF, 0xEDE0, 0x58F9, 0xECEC,\t0x58FA, 0xFBBE, 0x58FB, 0xDFEB, 0x58FD, 0xE1F8, 0x590F, 0xF9BE,\r\n\t0x5914, 0xD0F3, 0x5915, 0xE0AA, 0x5916, 0xE8E2, 0x5919, 0xE2D4,\t0x591A, 0xD2FD, 0x591C, 0xE5A8, 0x5922, 0xD9D3, 0x5927, 0xD3DE,\r\n\t0x5929, 0xF4B8, 0x592A, 0xF7BC, 0x592B, 0xDCFD, 0x592D, 0xE8EC,\t0x592E, 0xE4E7, 0x5931, 0xE3F7, 0x5937, 0xECA8, 0x593E, 0xFAF1,\r\n\t0x5944, 0xE5F2, 0x5947, 0xD0F4, 0x5948, 0xD2AF, 0x5949, 0xDCE5,\t0x594E, 0xD0A5, 0x594F, 0xF1B4, 0x5950, 0xFCB1, 0x5951, 0xCCF8,\r\n\t0x5954, 0xDDC6, 0x5955, 0xFAD1, 0x5957, 0xF7DF, 0x595A, 0xFAA8,\t0x5960, 0xEEF5, 0x5962, 0xDECE, 0x5967, 0xE7F3, 0x596A, 0xF7AC,\r\n\t0x596B, 0xEBC4, 0x596C, 0xEDE1, 0x596D, 0xE0AB, 0x596E, 0xDDC7,\t0x5973, 0xD2B3, 0x5974, 0xD2BF, 0x5978, 0xCACC, 0x597D, 0xFBBF,\r\n\t0x5982, 0xE5FD, 0x5983, 0xDDE5, 0x5984, 0xD8CD, 0x598A, 0xECF4,\t0x5993, 0xD0F5, 0x5996, 0xE8ED, 0x5997, 0xD0D2, 0x5999, 0xD9D8,\r\n\t0x59A5, 0xF6E6, 0x59A8, 0xDBAA, 0x59AC, 0xF7E0, 0x59B9, 0xD8D9,\t0x59BB, 0xF4A3, 0x59BE, 0xF4DD, 0x59C3, 0xEFD1, 0x59C6, 0xD9B5,\r\n\t0x59C9, 0xEDAB, 0x59CB, 0xE3B7, 0x59D0, 0xEEBB, 0x59D1, 0xCDB4,\t0x59D3, 0xE0F3, 0x59D4, 0xEACD, 0x59D9, 0xECF5, 0x59DA, 0xE8EE,\r\n\t0x59DC, 0xCBA9, 0x59DD, 0xF1AF, 0x59E6, 0xCACD, 0x59E8, 0xECA9,\t0x59EA, 0xF2EB, 0x59EC, 0xFDEF, 0x59EE, 0xF9F3, 0x59F8, 0xE6C1,\r\n\t0x59FB, 0xECD8, 0x59FF, 0xEDAC, 0x5A01, 0xEACE, 0x5A03, 0xE8DF,\t0x5A11, 0xDECF, 0x5A18, 0xD2A6, 0x5A1B, 0xE7F4, 0x5A1C, 0xD1D6,\r\n\t0x5A1F, 0xE6C2, 0x5A20, 0xE3E3, 0x5A25, 0xE4B0, 0x5A29, 0xD8B4,\t0x5A36, 0xF6A5, 0x5A3C, 0xF3DE, 0x5A41, 0xD7A5, 0x5A46, 0xF7E8,\r\n\t0x5A49, 0xE8C6, 0x5A5A, 0xFBE6, 0x5A62, 0xDDE6, 0x5A66, 0xDCFE,\t0x5A92, 0xD8DA, 0x5A9A, 0xDAAC, 0x5A9B, 0xEAB0, 0x5AA4, 0xE3B8,\r\n\t0x5AC1, 0xCAAA, 0x5AC2, 0xE1F9, 0x5AC4, 0xEAB1, 0x5AC9, 0xF2EC,\t0x5ACC, 0xFAEE, 0x5AE1, 0xEED5, 0x5AE6, 0xF9F4, 0x5AE9, 0xD2EC,\r\n\t0x5B05, 0xFBFB, 0x5B09, 0xFDF0, 0x5B0B, 0xE0BD, 0x5B0C, 0xCEE3,\t0x5B16, 0xF8C6, 0x5B2A, 0xDEAE, 0x5B40, 0xDFC5, 0x5B43, 0xE5BE,\r\n\t0x5B50, 0xEDAD, 0x5B51, 0xFAEA, 0x5B54, 0xCDEE, 0x5B55, 0xEDA6,\t0x5B57, 0xEDAE, 0x5B58, 0xF0ED, 0x5B5A, 0xDDA1, 0x5B5C, 0xEDAF,\r\n\t0x5B5D, 0xFCF8, 0x5B5F, 0xD8EB, 0x5B63, 0xCCF9, 0x5B64, 0xCDB5,\t0x5B69, 0xFAA9, 0x5B6B, 0xE1DD, 0x5B70, 0xE2D5, 0x5B71, 0xEDCF,\r\n\t0x5B75, 0xDDA2, 0x5B78, 0xF9CA, 0x5B7A, 0xEAE8, 0x5B7C, 0xE5ED,\t0x5B85, 0xD3EB, 0x5B87, 0xE9D4, 0x5B88, 0xE1FA, 0x5B89, 0xE4CC,\r\n\t0x5B8B, 0xE1E4, 0x5B8C, 0xE8C7, 0x5B8F, 0xCEDB, 0x5B93, 0xDCD5,\t0x5B95, 0xF7B5, 0x5B96, 0xFCF3, 0x5B97, 0xF0F3, 0x5B98, 0xCEAF,\r\n\t0x5B99, 0xF1B5, 0x5B9A, 0xEFD2, 0x5B9B, 0xE8C8, 0x5B9C, 0xEBF1,\t0x5BA2, 0xCBD4, 0x5BA3, 0xE0BE, 0x5BA4, 0xE3F8, 0x5BA5, 0xEAE9,\r\n\t0x5BA6, 0xFCB2, 0x5BAC, 0xE0F4, 0x5BAE, 0xCFE0, 0x5BB0, 0xEEA5,\t0x5BB3, 0xFAAA, 0x5BB4, 0xE6C3, 0x5BB5, 0xE1B2, 0x5BB6, 0xCAAB,\r\n\t0x5BB8, 0xE3E4, 0x5BB9, 0xE9BB, 0x5BBF, 0xE2D6, 0x5BC0, 0xF3F2,\t0x5BC2, 0xEED6, 0x5BC3, 0xEAB2, 0x5BC4, 0xD0F6, 0x5BC5, 0xECD9,\r\n\t0x5BC6, 0xDACB, 0x5BC7, 0xCFA8, 0x5BCC, 0xDDA3, 0x5BD0, 0xD8DB,\t0x5BD2, 0xF9CE, 0x5BD3, 0xE9D5, 0x5BD4, 0xE3D1, 0x5BD7, 0xD2BC,\r\n\t0x5BDE, 0xD8AC, 0x5BDF, 0xF3CC, 0x5BE1, 0xCDFB, 0x5BE2, 0xF6D6,\t0x5BE4, 0xE7F5, 0x5BE5, 0xE8EF, 0x5BE6, 0xE3F9, 0x5BE7, 0xD2BB,\r\n\t0x5BE8, 0xF3F3, 0x5BE9, 0xE3FB, 0x5BEB, 0xDED0, 0x5BEC, 0xCEB0,\t0x5BEE, 0xD6F7, 0x5BEF, 0xF1D9, 0x5BF5, 0xF5C1, 0x5BF6, 0xDCC4,\r\n\t0x5BF8, 0xF5BB, 0x5BFA, 0xDED1, 0x5C01, 0xDCE6, 0x5C04, 0xDED2,\t0x5C07, 0xEDE2, 0x5C08, 0xEEF6, 0x5C09, 0xEACF, 0x5C0A, 0xF0EE,\r\n\t0x5C0B, 0xE3FC, 0x5C0D, 0xD3DF, 0x5C0E, 0xD3F4, 0x5C0F, 0xE1B3,\t0x5C11, 0xE1B4, 0x5C16, 0xF4D3, 0x5C19, 0xDFC6, 0x5C24, 0xE9D6,\r\n\t0x5C28, 0xDBAB, 0x5C31, 0xF6A6, 0x5C38, 0xE3B9, 0x5C39, 0xEBC5,\t0x5C3A, 0xF4A9, 0x5C3B, 0xCDB6, 0x5C3C, 0xD2F9, 0x5C3E, 0xDAAD,\r\n\t0x5C3F, 0xD2E3, 0x5C40, 0xCFD1, 0x5C45, 0xCBDC, 0x5C46, 0xCCFA,\t0x5C48, 0xCFDD, 0x5C4B, 0xE8A9, 0x5C4D, 0xE3BB, 0x5C4E, 0xE3BA,\r\n\t0x5C51, 0xE0DA, 0x5C55, 0xEEF7, 0x5C5B, 0xDCB3, 0x5C60, 0xD3F5,\t0x5C62, 0xD7A6, 0x5C64, 0xF6B5, 0x5C65, 0xD7DB, 0x5C6C, 0xE1D5,\r\n\t0x5C6F, 0xD4EA, 0x5C71, 0xDFA3, 0x5C79, 0xFDDF, 0x5C90, 0xD0F7,\t0x5C91, 0xEDD4, 0x5CA1, 0xCBAA, 0x5CA9, 0xE4DB, 0x5CAB, 0xE1FB,\r\n\t0x5CAC, 0xCBA2, 0x5CB1, 0xD3E0, 0x5CB3, 0xE4BF, 0x5CB5, 0xFBC0,\t0x5CB7, 0xDABE, 0x5CB8, 0xE4CD, 0x5CBA, 0xD6B9, 0x5CBE, 0xEFC0,\r\n\t0x5CC0, 0xE1FC, 0x5CD9, 0xF6B9, 0x5CE0, 0xDFC7, 0x5CE8, 0xE4B1,\t0x5CEF, 0xDCE7, 0x5CF0, 0xDCE8, 0x5CF4, 0xFAD6, 0x5CF6, 0xD3F6,\r\n\t0x5CFB, 0xF1DA, 0x5CFD, 0xFAF2, 0x5D07, 0xE2FD, 0x5D0D, 0xD5CF,\t0x5D0E, 0xD0F8, 0x5D11, 0xCDDF, 0x5D14, 0xF5CB, 0x5D16, 0xE4F0,\r\n\t0x5D17, 0xCBAB, 0x5D19, 0xD7C4, 0x5D27, 0xE2FE, 0x5D29, 0xDDDA,\t0x5D4B, 0xDAAE, 0x5D4C, 0xCAEE, 0x5D50, 0xD5B9, 0x5D69, 0xE3A1,\r\n\t0x5D6C, 0xE8E3, 0x5D6F, 0xF3AB, 0x5D87, 0xCFA9, 0x5D8B, 0xD3F7,\t0x5D9D, 0xD4F1, 0x5DA0, 0xCEE4, 0x5DA2, 0xE8F2, 0x5DAA, 0xE5F5,\r\n\t0x5DB8, 0xE7AE, 0x5DBA, 0xD6BA, 0x5DBC, 0xDFEC, 0x5DBD, 0xE4C0,\t0x5DCD, 0xE8E4, 0x5DD2, 0xD8B5, 0x5DD6, 0xE4DC, 0x5DDD, 0xF4B9,\r\n\t0x5DDE, 0xF1B6, 0x5DE1, 0xE2DE, 0x5DE2, 0xE1B5, 0x5DE5, 0xCDEF,\t0x5DE6, 0xF1A7, 0x5DE7, 0xCEE5, 0x5DE8, 0xCBDD, 0x5DEB, 0xD9E3,\r\n\t0x5DEE, 0xF3AC, 0x5DF1, 0xD0F9, 0x5DF2, 0xECAB, 0x5DF3, 0xDED3,\t0x5DF4, 0xF7E9, 0x5DF7, 0xF9F5, 0x5DFD, 0xE1DE, 0x5DFE, 0xCBEE,\r\n\t0x5E02, 0xE3BC, 0x5E03, 0xF8D6, 0x5E06, 0xDBEE, 0x5E0C, 0xFDF1,\t0x5E11, 0xF7B6, 0x5E16, 0xF4DE, 0x5E19, 0xF2ED, 0x5E1B, 0xDBD9,\r\n\t0x5E1D, 0xF0A8, 0x5E25, 0xE1FD, 0x5E2B, 0xDED4, 0x5E2D, 0xE0AC,\t0x5E33, 0xEDE3, 0x5E36, 0xD3E1, 0x5E38, 0xDFC8, 0x5E3D, 0xD9B6,\r\n\t0x5E3F, 0xFDAC, 0x5E40, 0xEFD3, 0x5E44, 0xE4C1, 0x5E45, 0xF8EB,\t0x5E47, 0xDBAC, 0x5E4C, 0xFCC6, 0x5E55, 0xD8AD, 0x5E5F, 0xF6BA,\r\n\t0x5E61, 0xDBDF, 0x5E62, 0xD3D3, 0x5E63, 0xF8C7, 0x5E72, 0xCACE,\t0x5E73, 0xF8C1, 0x5E74, 0xD2B4, 0x5E77, 0xDCB4, 0x5E78, 0xFAB9,\r\n\t0x5E79, 0xCACF, 0x5E7B, 0xFCB3, 0x5E7C, 0xEAEA, 0x5E7D, 0xEAEB,\t0x5E7E, 0xD0FA, 0x5E84, 0xEDE4, 0x5E87, 0xDDE7, 0x5E8A, 0xDFC9,\r\n\t0x5E8F, 0xDFED, 0x5E95, 0xEEBC, 0x5E97, 0xEFC1, 0x5E9A, 0xCCD2,\t0x5E9C, 0xDDA4, 0x5EA0, 0xDFCA, 0x5EA6, 0xD3F8, 0x5EA7, 0xF1A8,\r\n\t0x5EAB, 0xCDB7, 0x5EAD, 0xEFD4, 0x5EB5, 0xE4DD, 0x5EB6, 0xDFEE,\t0x5EB7, 0xCBAC, 0x5EB8, 0xE9BC, 0x5EBE, 0xEAEC, 0x5EC2, 0xDFCB,\r\n\t0x5EC8, 0xF9BF, 0x5EC9, 0xD6AF, 0x5ECA, 0xD5C6, 0x5ED0, 0xCFAA,\t0x5ED3, 0xCEA9, 0x5ED6, 0xD6F8, 0x5EDA, 0xF1B7, 0x5EDB, 0xEEF8,\r\n\t0x5EDF, 0xD9D9, 0x5EE0, 0xF3DF, 0x5EE2, 0xF8C8, 0x5EE3, 0xCEC6,\t0x5EEC, 0xD5E6, 0x5EF3, 0xF4E6, 0x5EF6, 0xE6C5, 0x5EF7, 0xEFD5,\r\n\t0x5EFA, 0xCBEF, 0x5EFB, 0xFCDF, 0x5F01, 0xDCA7, 0x5F04, 0xD6E7,\t0x5F0A, 0xF8C9, 0x5F0F, 0xE3D2, 0x5F11, 0xE3BD, 0x5F13, 0xCFE1,\r\n\t0x5F14, 0xF0C0, 0x5F15, 0xECDA, 0x5F17, 0xDDD7, 0x5F18, 0xFBF0,\t0x5F1B, 0xECAC, 0x5F1F, 0xF0A9, 0x5F26, 0xFAD7, 0x5F27, 0xFBC1,\r\n\t0x5F29, 0xD2C0, 0x5F31, 0xE5B0, 0x5F35, 0xEDE5, 0x5F3A, 0xCBAD,\t0x5F3C, 0xF9B0, 0x5F48, 0xF7A5, 0x5F4A, 0xCBAE, 0x5F4C, 0xDAAF,\r\n\t0x5F4E, 0xD8B6, 0x5F56, 0xD3A7, 0x5F57, 0xFBB2, 0x5F59, 0xFDC4,\t0x5F5B, 0xECAD, 0x5F62, 0xFBA1, 0x5F66, 0xE5E9, 0x5F67, 0xE9EE,\r\n\t0x5F69, 0xF3F4, 0x5F6A, 0xF8F3, 0x5F6B, 0xF0C1, 0x5F6C, 0xDEAF,\t0x5F6D, 0xF8B0, 0x5F70, 0xF3E0, 0x5F71, 0xE7AF, 0x5F77, 0xDBAD,\r\n\t0x5F79, 0xE6B5, 0x5F7C, 0xF9A8, 0x5F7F, 0xDDD8, 0x5F80, 0xE8D9,\t0x5F81, 0xEFD6, 0x5F85, 0xD3E2, 0x5F87, 0xE2DF, 0x5F8A, 0xFCE0,\r\n\t0x5F8B, 0xD7C8, 0x5F8C, 0xFDAD, 0x5F90, 0xDFEF, 0x5F91, 0xCCD3,\t0x5F92, 0xD3F9, 0x5F97, 0xD4F0, 0x5F98, 0xDBC7, 0x5F99, 0xDED5,\r\n\t0x5F9E, 0xF0F4, 0x5FA0, 0xD5D0, 0x5FA1, 0xE5D9, 0x5FA8, 0xFCC7,\t0x5FA9, 0xDCD6, 0x5FAA, 0xE2E0, 0x5FAE, 0xDAB0, 0x5FB5, 0xF3A3,\r\n\t0x5FB7, 0xD3EC, 0x5FB9, 0xF4CB, 0x5FBD, 0xFDC5, 0x5FC3, 0xE3FD,\t0x5FC5, 0xF9B1, 0x5FCC, 0xD0FB, 0x5FCD, 0xECDB, 0x5FD6, 0xF5BC,\r\n\t0x5FD7, 0xF2A4, 0x5FD8, 0xD8CE, 0x5FD9, 0xD8CF, 0x5FE0, 0xF5F7,\t0x5FEB, 0xF6E1, 0x5FF5, 0xD2B7, 0x5FFD, 0xFBEC, 0x5FFF, 0xDDC8,\r\n\t0x600F, 0xE4E8, 0x6012, 0xD2C1, 0x6016, 0xF8D7, 0x601C, 0xD6BB,\t0x601D, 0xDED6, 0x6020, 0xF7BD, 0x6021, 0xECAE, 0x6025, 0xD0E1,\r\n\t0x6027, 0xE0F5, 0x6028, 0xEAB3, 0x602A, 0xCED6, 0x602F, 0xCCA5,\t0x6041, 0xECF6, 0x6042, 0xE2E1, 0x6043, 0xE3BE, 0x604D, 0xFCC8,\r\n\t0x6050, 0xCDF0, 0x6052, 0xF9F6, 0x6055, 0xDFF0, 0x6059, 0xE5BF,\t0x605D, 0xCEBF, 0x6062, 0xFCE1, 0x6063, 0xEDB0, 0x6064, 0xFDD1,\r\n\t0x6065, 0xF6BB, 0x6068, 0xF9CF, 0x6069, 0xEBDA, 0x606A, 0xCAC1,\t0x606C, 0xD2B8, 0x606D, 0xCDF1, 0x606F, 0xE3D3, 0x6070, 0xFDE6,\r\n\t0x6085, 0xE6ED, 0x6089, 0xE3FA, 0x608C, 0xF0AA, 0x608D, 0xF9D0,\t0x6094, 0xFCE2, 0x6096, 0xF8A7, 0x609A, 0xE1E5, 0x609B, 0xEEF9,\r\n\t0x609F, 0xE7F6, 0x60A0, 0xEAED, 0x60A3, 0xFCB4, 0x60A4, 0xF5C2,\t0x60A7, 0xD7DC, 0x60B0, 0xF0F5, 0x60B2, 0xDDE8, 0x60B3, 0xD3ED,\r\n\t0x60B4, 0xF5FC, 0x60B6, 0xDABF, 0x60B8, 0xCCFB, 0x60BC, 0xD3FA,\t0x60BD, 0xF4A4, 0x60C5, 0xEFD7, 0x60C7, 0xD4C3, 0x60D1, 0xFBE3,\r\n\t0x60DA, 0xFBED, 0x60DC, 0xE0AD, 0x60DF, 0xEAEE, 0x60E0, 0xFBB3,\t0x60E1, 0xE4C2, 0x60F0, 0xF6E7, 0x60F1, 0xD2DD, 0x60F3, 0xDFCC,\r\n\t0x60F6, 0xFCC9, 0x60F9, 0xE5A9, 0x60FA, 0xE0F6, 0x60FB, 0xF6B3,\t0x6101, 0xE1FE, 0x6106, 0xCBF0, 0x6108, 0xEAEF, 0x6109, 0xEAF0,\r\n\t0x610D, 0xDAC0, 0x610E, 0xF8B4, 0x610F, 0xEBF2, 0x6115, 0xE4C3,\t0x611A, 0xE9D7, 0x611B, 0xE4F1, 0x611F, 0xCAEF, 0x6127, 0xCED7,\r\n\t0x6130, 0xFCCA, 0x6134, 0xF3E1, 0x6137, 0xCBC4, 0x613C, 0xE3E5,\t0x613E, 0xCBC5, 0x613F, 0xEAB4, 0x6142, 0xE9BD, 0x6144, 0xD7C9,\r\n\t0x6147, 0xEBDB, 0x6148, 0xEDB1, 0x614A, 0xCCC3, 0x614B, 0xF7BE,\t0x614C, 0xFCCB, 0x6153, 0xF8F4, 0x6155, 0xD9B7, 0x6158, 0xF3D3,\r\n\t0x6159, 0xF3D4, 0x615D, 0xF7E4, 0x615F, 0xF7D1, 0x6162, 0xD8B7,\t0x6163, 0xCEB1, 0x6164, 0xCAC2, 0x6167, 0xFBB4, 0x6168, 0xCBC6,\r\n\t0x616B, 0xF0F6, 0x616E, 0xD5E7, 0x6170, 0xEAD0, 0x6176, 0xCCD4,\t0x6177, 0xCBAF, 0x617D, 0xF4AA, 0x617E, 0xE9AF, 0x6181, 0xF5C3,\r\n\t0x6182, 0xE9D8, 0x618A, 0xDDE9, 0x618E, 0xF1F3, 0x6190, 0xD5FB,\t0x6191, 0xDEBB, 0x6194, 0xF4FB, 0x6198, 0xFDF3, 0x6199, 0xFDF2,\r\n\t0x619A, 0xF7A6, 0x61A4, 0xDDC9, 0x61A7, 0xD4D3, 0x61A9, 0xCCA8,\t0x61AB, 0xDAC1, 0x61AC, 0xCCD5, 0x61AE, 0xD9E4, 0x61B2, 0xFACA,\r\n\t0x61B6, 0xE5E3, 0x61BA, 0xD3BC, 0x61BE, 0xCAF0, 0x61C3, 0xD0C4,\t0x61C7, 0xCAD0, 0x61C8, 0xFAAB, 0x61C9, 0xEBEB, 0x61CA, 0xE7F8,\r\n\t0x61CB, 0xD9E5, 0x61E6, 0xD1D7, 0x61F2, 0xF3A4, 0x61F6, 0xD4FB,\t0x61F7, 0xFCE3, 0x61F8, 0xFAD8, 0x61FA, 0xF3D5, 0x61FC, 0xCFAB,\r\n\t0x61FF, 0xEBF3, 0x6200, 0xD5FC, 0x6207, 0xD3D4, 0x6208, 0xCDFC,\t0x620A, 0xD9E6, 0x620C, 0xE2F9, 0x620D, 0xE2A1, 0x620E, 0xEBD4,\r\n\t0x6210, 0xE0F7, 0x6211, 0xE4B2, 0x6212, 0xCCFC, 0x6216, 0xFBE4,\t0x621A, 0xF4AB, 0x621F, 0xD0BD, 0x6221, 0xCAF1, 0x622A, 0xEFB8,\r\n\t0x622E, 0xD7C0, 0x6230, 0xEEFA, 0x6231, 0xFDF4, 0x6234, 0xD3E3,\t0x6236, 0xFBC2, 0x623E, 0xD5E8, 0x623F, 0xDBAE, 0x6240, 0xE1B6,\r\n\t0x6241, 0xF8B7, 0x6247, 0xE0BF, 0x6248, 0xFBC3, 0x6249, 0xDDEA,\t0x624B, 0xE2A2, 0x624D, 0xEEA6, 0x6253, 0xF6E8, 0x6258, 0xF6F5,\r\n\t0x626E, 0xDDCA, 0x6271, 0xD0E2, 0x6276, 0xDDA6, 0x6279, 0xDDEB,\t0x627C, 0xE4F9, 0x627F, 0xE3AF, 0x6280, 0xD0FC, 0x6284, 0xF4FC,\r\n\t0x6289, 0xCCBC, 0x628A, 0xF7EA, 0x6291, 0xE5E4, 0x6292, 0xDFF1,\t0x6295, 0xF7E1, 0x6297, 0xF9F7, 0x6298, 0xEFB9, 0x629B, 0xF8D8,\r\n\t0x62AB, 0xF9A9, 0x62B1, 0xF8D9, 0x62B5, 0xEEBD, 0x62B9, 0xD8C6,\t0x62BC, 0xE4E3, 0x62BD, 0xF5CE, 0x62C2, 0xDDD9, 0x62C7, 0xD9E7,\r\n\t0x62C8, 0xD2B9, 0x62C9, 0xD5C3, 0x62CC, 0xDAE5, 0x62CD, 0xDAD0,\t0x62CF, 0xD1D9, 0x62D0, 0xCED8, 0x62D2, 0xCBDE, 0x62D3, 0xF4AC,\r\n\t0x62D4, 0xDAFB, 0x62D6, 0xF6E9, 0x62D7, 0xE8F3, 0x62D8, 0xCFAC,\t0x62D9, 0xF0F0, 0x62DB, 0xF4FD, 0x62DC, 0xDBC8, 0x62EC, 0xCEC0,\r\n\t0x62ED, 0xE3D4, 0x62EE, 0xD1CF, 0x62EF, 0xF1F5, 0x62F1, 0xCDF2,\t0x62F3, 0xCFEB, 0x62F7, 0xCDB8, 0x62FE, 0xE3A6, 0x62FF, 0xD1DA,\r\n\t0x6301, 0xF2A5, 0x6307, 0xF2A6, 0x6309, 0xE4CE, 0x6311, 0xD3FB,\t0x632B, 0xF1A9, 0x632F, 0xF2C9, 0x633A, 0xEFD8, 0x633B, 0xE6C9,\r\n\t0x633D, 0xD8B8, 0x633E, 0xFAF3, 0x6349, 0xF3B5, 0x634C, 0xF8A4,\t0x634F, 0xD1F3, 0x6350, 0xE6C8, 0x6355, 0xF8DA, 0x6367, 0xDCE9,\r\n\t0x6368, 0xDED7, 0x636E, 0xCBDF, 0x6372, 0xCFEC, 0x6377, 0xF4DF,\t0x637A, 0xD1F4, 0x637B, 0xD2BA, 0x637F, 0xDFF2, 0x6383, 0xE1B7,\r\n\t0x6388, 0xE2A3, 0x6389, 0xD3FC, 0x638C, 0xEDE6, 0x6392, 0xDBC9,\t0x6396, 0xE4FA, 0x6398, 0xCFDE, 0x639B, 0xCED0, 0x63A0, 0xD5D3,\r\n\t0x63A1, 0xF3F5, 0x63A2, 0xF7AE, 0x63A5, 0xEFC8, 0x63A7, 0xCDF3,\t0x63A8, 0xF5CF, 0x63A9, 0xE5F3, 0x63AA, 0xF0C2, 0x63C0, 0xCAD1,\r\n\t0x63C4, 0xEAF1, 0x63C6, 0xD0A6, 0x63CF, 0xD9DA, 0x63D0, 0xF0AB,\t0x63D6, 0xEBE7, 0x63DA, 0xE5C0, 0x63DB, 0xFCB5, 0x63E1, 0xE4C4,\r\n\t0x63ED, 0xCCA9, 0x63EE, 0xFDC6, 0x63F4, 0xEAB5, 0x63F6, 0xE5AA,\t0x63F7, 0xDFBA, 0x640D, 0xE1DF, 0x640F, 0xDAD1, 0x6414, 0xE1B8,\r\n\t0x6416, 0xE8F4, 0x6417, 0xD3FD, 0x641C, 0xE2A4, 0x6422, 0xF2CA,\t0x642C, 0xDAE6, 0x642D, 0xF7B3, 0x643A, 0xFDCD, 0x643E, 0xF3B6,\r\n\t0x6458, 0xEED7, 0x6460, 0xF5C4, 0x6469, 0xD8A4, 0x646F, 0xF2A7,\t0x6478, 0xD9B8, 0x6479, 0xD9B9, 0x647A, 0xEFC9, 0x6488, 0xD6CE,\r\n\t0x6491, 0xF7CB, 0x6492, 0xDFAE, 0x6493, 0xE8F5, 0x649A, 0xD2B5,\t0x649E, 0xD3D5, 0x64A4, 0xF4CC, 0x64A5, 0xDAFC, 0x64AB, 0xD9E8,\r\n\t0x64AD, 0xF7EB, 0x64AE, 0xF5C9, 0x64B0, 0xF3BC, 0x64B2, 0xDAD2,\t0x64BB, 0xD3B5, 0x64C1, 0xE8B6, 0x64C4, 0xD6CF, 0x64C5, 0xF4BA,\r\n\t0x64C7, 0xF7C9, 0x64CA, 0xCCAA, 0x64CD, 0xF0C3, 0x64CE, 0xCCD6,\t0x64D2, 0xD0D3, 0x64D4, 0xD3BD, 0x64D8, 0xDBFB, 0x64DA, 0xCBE0,\r\n\t0x64E1, 0xD3E4, 0x64E2, 0xF6F7, 0x64E5, 0xD5BA, 0x64E6, 0xF3CD,\t0x64E7, 0xCBE1, 0x64EC, 0xEBF4, 0x64F2, 0xF4AD, 0x64F4, 0xFCAA,\r\n\t0x64FA, 0xF7EC, 0x64FE, 0xE8F6, 0x6500, 0xDAE7, 0x6504, 0xF7CC,\t0x6518, 0xE5C1, 0x651D, 0xE0EE, 0x6523, 0xD5FD, 0x652A, 0xCEE6,\r\n\t0x652B, 0xFCAB, 0x652C, 0xD5BB, 0x652F, 0xF2A8, 0x6536, 0xE2A5,\t0x6537, 0xCDB9, 0x6538, 0xEAF2, 0x6539, 0xCBC7, 0x653B, 0xCDF4,\r\n\t0x653E, 0xDBAF, 0x653F, 0xEFD9, 0x6545, 0xCDBA, 0x6548, 0xFCF9,\t0x654D, 0xDFF3, 0x654E, 0xCEE7, 0x654F, 0xDAC2, 0x6551, 0xCFAD,\r\n\t0x6556, 0xE7F9, 0x6557, 0xF8A8, 0x655E, 0xF3E2, 0x6562, 0xCAF2,\t0x6563, 0xDFA4, 0x6566, 0xD4C4, 0x656C, 0xCCD7, 0x656D, 0xE5C2,\r\n\t0x6572, 0xCDBB, 0x6574, 0xEFDA, 0x6575, 0xEED8, 0x6577, 0xDDA7,\t0x6578, 0xE2A6, 0x657E, 0xE0C0, 0x6582, 0xD6B0, 0x6583, 0xF8CA,\r\n\t0x6585, 0xFCFA, 0x6587, 0xD9FE, 0x658C, 0xDEB0, 0x6590, 0xDDEC,\t0x6591, 0xDAE8, 0x6597, 0xD4E0, 0x6599, 0xD6F9, 0x659B, 0xCDD7,\r\n\t0x659C, 0xDED8, 0x659F, 0xF2F8, 0x65A1, 0xE4D6, 0x65A4, 0xD0C5,\t0x65A5, 0xF4AE, 0x65A7, 0xDDA8, 0x65AB, 0xEDC5, 0x65AC, 0xF3D6,\r\n\t0x65AF, 0xDED9, 0x65B0, 0xE3E6, 0x65B7, 0xD3A8, 0x65B9, 0xDBB0,\t0x65BC, 0xE5DA, 0x65BD, 0xE3BF, 0x65C1, 0xDBB1, 0x65C5, 0xD5E9,\r\n\t0x65CB, 0xE0C1, 0x65CC, 0xEFDB, 0x65CF, 0xF0E9, 0x65D2, 0xD7B2,\t0x65D7, 0xD0FD, 0x65E0, 0xD9E9, 0x65E3, 0xD0FE, 0x65E5, 0xECED,\r\n\t0x65E6, 0xD3A9, 0x65E8, 0xF2A9, 0x65E9, 0xF0C4, 0x65EC, 0xE2E2,\t0x65ED, 0xE9EF, 0x65F1, 0xF9D1, 0x65F4, 0xE9D9, 0x65FA, 0xE8DA,\r\n\t0x65FB, 0xDAC3, 0x65FC, 0xDAC4, 0x65FD, 0xD4C5, 0x65FF, 0xE7FA,\t0x6606, 0xCDE0, 0x6607, 0xE3B0, 0x6609, 0xDBB2, 0x660A, 0xFBC4,\r\n\t0x660C, 0xF3E3, 0x660E, 0xD9A5, 0x660F, 0xFBE7, 0x6610, 0xDDCB,\t0x6611, 0xD0D4, 0x6613, 0xE6B6, 0x6614, 0xE0AE, 0x6615, 0xFDDA,\r\n\t0x661E, 0xDCB5, 0x661F, 0xE0F8, 0x6620, 0xE7B1, 0x6625, 0xF5F0,\t0x6627, 0xD8DC, 0x6628, 0xEDC6, 0x662D, 0xE1B9, 0x662F, 0xE3C0,\r\n\t0x6630, 0xF9C0, 0x6631, 0xE9F0, 0x6634, 0xD9DB, 0x6636, 0xF3E4,\t0x663A, 0xDCB6, 0x663B, 0xE4E9, 0x6641, 0xF0C5, 0x6642, 0xE3C1,\r\n\t0x6643, 0xFCCC, 0x6644, 0xFCCD, 0x6649, 0xF2CB, 0x664B, 0xF2CC,\t0x664F, 0xE4CF, 0x6659, 0xF1DB, 0x665B, 0xFAD9, 0x665D, 0xF1B8,\r\n\t0x665E, 0xFDF5, 0x665F, 0xE0F9, 0x6664, 0xE7FB, 0x6665, 0xFCB7,\t0x6666, 0xFCE4, 0x6667, 0xFBC5, 0x6668, 0xE3E7, 0x6669, 0xD8B9,\r\n\t0x666B, 0xF6F8, 0x666E, 0xDCC5, 0x666F, 0xCCD8, 0x6673, 0xE0AF,\t0x6674, 0xF4E7, 0x6676, 0xEFDC, 0x6677, 0xCFFC, 0x6678, 0xEFDD,\r\n\t0x667A, 0xF2AA, 0x6684, 0xFDBE, 0x6687, 0xCAAC, 0x6688, 0xFDBB,\t0x6689, 0xFDC7, 0x668E, 0xE7B2, 0x6690, 0xEAD1, 0x6691, 0xDFF4,\r\n\t0x6696, 0xD1EC, 0x6697, 0xE4DE, 0x6698, 0xE5C3, 0x669D, 0xD9A6,\t0x66A0, 0xCDBC, 0x66A2, 0xF3E5, 0x66AB, 0xEDD5, 0x66AE, 0xD9BA,\r\n\t0x66B2, 0xEDE7, 0x66B3, 0xFBB5, 0x66B4, 0xF8EC, 0x66B9, 0xE0E7,\t0x66BB, 0xCCD9, 0x66BE, 0xD4C6, 0x66C4, 0xE7A5, 0x66C6, 0xD5F5,\r\n\t0x66C7, 0xD3BE, 0x66C9, 0xFCFB, 0x66D6, 0xE4F2, 0x66D9, 0xDFF5,\t0x66DC, 0xE8F8, 0x66DD, 0xF8ED, 0x66E0, 0xCEC7, 0x66E6, 0xFDF6,\r\n\t0x66F0, 0xE8D8, 0x66F2, 0xCDD8, 0x66F3, 0xE7D6, 0x66F4, 0xCCDA,\t0x66F7, 0xCAE3, 0x66F8, 0xDFF6, 0x66F9, 0xF0C7, 0x66FA, 0xF0C6,\r\n\t0x66FC, 0xD8BA, 0x66FE, 0xF1F4, 0x66FF, 0xF4F0, 0x6700, 0xF5CC,\t0x6703, 0xFCE5, 0x6708, 0xEAC5, 0x6709, 0xEAF3, 0x670B, 0xDDDB,\r\n\t0x670D, 0xDCD7, 0x6714, 0xDEFD, 0x6715, 0xF2F9, 0x6717, 0xD5C7,\t0x671B, 0xD8D0, 0x671D, 0xF0C8, 0x671E, 0xD1A1, 0x671F, 0xD1A2,\r\n\t0x6726, 0xD9D4, 0x6727, 0xD6E8, 0x6728, 0xD9CA, 0x672A, 0xDAB1,\t0x672B, 0xD8C7, 0x672C, 0xDCE2, 0x672D, 0xF3CE, 0x672E, 0xF5F4,\r\n\t0x6731, 0xF1B9, 0x6734, 0xDAD3, 0x6736, 0xF6EA, 0x673A, 0xCFF5,\t0x673D, 0xFDAE, 0x6746, 0xCAD2, 0x6749, 0xDFB4, 0x674E, 0xD7DD,\r\n\t0x674F, 0xFABA, 0x6750, 0xEEA7, 0x6751, 0xF5BD, 0x6753, 0xF8F5,\t0x6756, 0xEDE8, 0x675C, 0xD4E1, 0x675E, 0xD1A3, 0x675F, 0xE1D6,\r\n\t0x676D, 0xF9F8, 0x676F, 0xDBCA, 0x6770, 0xCBF9, 0x6771, 0xD4D4,\t0x6773, 0xD9DC, 0x6775, 0xEEBE, 0x6777, 0xF7ED, 0x677B, 0xD2EE,\r\n\t0x677E, 0xE1E6, 0x677F, 0xF7F9, 0x6787, 0xDDED, 0x6789, 0xE8DB,\t0x678B, 0xDBB3, 0x678F, 0xD1F7, 0x6790, 0xE0B0, 0x6793, 0xD4E2,\r\n\t0x6795, 0xF6D7, 0x6797, 0xD7F9, 0x679A, 0xD8DD, 0x679C, 0xCDFD,\t0x679D, 0xF2AB, 0x67AF, 0xCDBD, 0x67B0, 0xF8C2, 0x67B3, 0xF2AC,\r\n\t0x67B6, 0xCAAD, 0x67B7, 0xCAAE, 0x67B8, 0xCFAE, 0x67BE, 0xE3C2,\t0x67C4, 0xDCB7, 0x67CF, 0xDBDA, 0x67D0, 0xD9BB, 0x67D1, 0xCAF3,\r\n\t0x67D2, 0xF6D3, 0x67D3, 0xE6F8, 0x67D4, 0xEAF5, 0x67DA, 0xEAF6,\t0x67DD, 0xF6F9, 0x67E9, 0xCFAF, 0x67EC, 0xCAD3, 0x67EF, 0xCAAF,\r\n\t0x67F0, 0xD2B0, 0x67F1, 0xF1BA, 0x67F3, 0xD7B3, 0x67F4, 0xE3C3,\t0x67F5, 0xF3FD, 0x67F6, 0xDEDA, 0x67FB, 0xDEDB, 0x67FE, 0xEFDE,\r\n\t0x6812, 0xE2E3, 0x6813, 0xEEFB, 0x6816, 0xDFF7, 0x6817, 0xD7CA,\t0x6821, 0xCEE8, 0x6822, 0xDBDB, 0x682A, 0xF1BB, 0x682F, 0xE9F1,\r\n\t0x6838, 0xFAB7, 0x6839, 0xD0C6, 0x683C, 0xCCAB, 0x683D, 0xEEA8,\t0x6840, 0xCBFA, 0x6841, 0xF9F9, 0x6842, 0xCCFD, 0x6843, 0xD3FE,\r\n\t0x6848, 0xE4D0, 0x684E, 0xF2EE, 0x6850, 0xD4D5, 0x6851, 0xDFCD,\t0x6853, 0xFCB8, 0x6854, 0xD1D0, 0x686D, 0xF2CD, 0x6876, 0xF7D2,\r\n\t0x687F, 0xCAD4, 0x6881, 0xD5D9, 0x6885, 0xD8DE, 0x688F, 0xCDD9,\t0x6893, 0xEEA9, 0x6894, 0xF6BC, 0x6897, 0xCCDB, 0x689D, 0xF0C9,\r\n\t0x689F, 0xFCFC, 0x68A1, 0xE8C9, 0x68A2, 0xF4FE, 0x68A7, 0xE7FC,\t0x68A8, 0xD7DE, 0x68AD, 0xDEDC, 0x68AF, 0xF0AC, 0x68B0, 0xCCFE,\r\n\t0x68B1, 0xCDE1, 0x68B3, 0xE1BA, 0x68B5, 0xDBEF, 0x68B6, 0xDAB2,\t0x68C4, 0xD1A5, 0x68C5, 0xDCB8, 0x68C9, 0xD8F6, 0x68CB, 0xD1A4,\r\n\t0x68CD, 0xCDE2, 0x68D2, 0xDCEA, 0x68D5, 0xF0F7, 0x68D7, 0xF0CA,\t0x68D8, 0xD0BE, 0x68DA, 0xDDDC, 0x68DF, 0xD4D6, 0x68E0, 0xD3D6,\r\n\t0x68E7, 0xEDD0, 0x68E8, 0xCDA1, 0x68EE, 0xDFB5, 0x68F2, 0xDFF8,\t0x68F9, 0xD4A1, 0x68FA, 0xCEB2, 0x6900, 0xE8CA, 0x6905, 0xEBF5,\r\n\t0x690D, 0xE3D5, 0x690E, 0xF5D0, 0x6912, 0xF5A1, 0x6927, 0xD9A7,\t0x6930, 0xE5AB, 0x693D, 0xE6CB, 0x693F, 0xF5F1, 0x694A, 0xE5C5,\r\n\t0x6953, 0xF9A3, 0x6954, 0xE0DB, 0x6955, 0xF6EB, 0x6957, 0xCBF1,\t0x6959, 0xD9EA, 0x695A, 0xF5A2, 0x695E, 0xD7D1, 0x6960, 0xD1F8,\r\n\t0x6961, 0xEAF8, 0x6962, 0xEAF9, 0x6963, 0xDAB3, 0x6968, 0xEFDF,\t0x696B, 0xF1EF, 0x696D, 0xE5F6, 0x696E, 0xEEBF, 0x696F, 0xE2E4,\r\n\t0x6975, 0xD0BF, 0x6977, 0xFAAC, 0x6978, 0xF5D1, 0x6979, 0xE7B3,\t0x6995, 0xE9BE, 0x699B, 0xF2CE, 0x699C, 0xDBB4, 0x69A5, 0xFCCE,\r\n\t0x69A7, 0xDDEE, 0x69AE, 0xE7B4, 0x69B4, 0xD7B4, 0x69BB, 0xF7B4,\t0x69C1, 0xCDBE, 0x69C3, 0xDAE9, 0x69CB, 0xCFB0, 0x69CC, 0xF7D9,\r\n\t0x69CD, 0xF3E6, 0x69D0, 0xCED9, 0x69E8, 0xCEAA, 0x69EA, 0xCBC8,\t0x69FB, 0xD0A7, 0x69FD, 0xF0CB, 0x69FF, 0xD0C7, 0x6A02, 0xE4C5,\r\n\t0x6A0A, 0xDBE0, 0x6A11, 0xD5DA, 0x6A13, 0xD7A7, 0x6A17, 0xEEC0,\t0x6A19, 0xF8F6, 0x6A1E, 0xF5D2, 0x6A1F, 0xEDE9, 0x6A21, 0xD9BC,\r\n\t0x6A23, 0xE5C6, 0x6A35, 0xF5A3, 0x6A38, 0xDAD4, 0x6A39, 0xE2A7,\t0x6A3A, 0xFBFC, 0x6A3D, 0xF1DC, 0x6A44, 0xCAF4, 0x6A48, 0xE8FA,\r\n\t0x6A4B, 0xCEE9, 0x6A52, 0xE9F8, 0x6A53, 0xE2E5, 0x6A58, 0xD0B9,\t0x6A59, 0xD4F2, 0x6A5F, 0xD1A6, 0x6A61, 0xDFCE, 0x6A6B, 0xFCF4,\r\n\t0x6A80, 0xD3AA, 0x6A84, 0xCCAC, 0x6A89, 0xEFE0, 0x6A8D, 0xE5E5,\t0x6A8E, 0xD0D5, 0x6A97, 0xDBFC, 0x6A9C, 0xFCE6, 0x6AA2, 0xCBFE,\r\n\t0x6AA3, 0xEDEA, 0x6AB3, 0xDEB1, 0x6ABB, 0xF9E3, 0x6AC2, 0xD4A2,\t0x6AC3, 0xCFF6, 0x6AD3, 0xD6D0, 0x6ADA, 0xD5EA, 0x6ADB, 0xF1EE,\r\n\t0x6AF6, 0xFACB, 0x6AFB, 0xE5A1, 0x6B04, 0xD5B1, 0x6B0A, 0xCFED,\t0x6B0C, 0xEDEB, 0x6B12, 0xD5B2, 0x6B16, 0xD5BC, 0x6B20, 0xFDE2,\r\n\t0x6B21, 0xF3AD, 0x6B23, 0xFDDB, 0x6B32, 0xE9B0, 0x6B3A, 0xD1A7,\t0x6B3D, 0xFDE3, 0x6B3E, 0xCEB3, 0x6B46, 0xFDE4, 0x6B47, 0xFACE,\r\n\t0x6B4C, 0xCAB0, 0x6B4E, 0xF7A7, 0x6B50, 0xCFB1, 0x6B5F, 0xE6A2,\t0x6B61, 0xFCB6, 0x6B62, 0xF2AD, 0x6B63, 0xEFE1, 0x6B64, 0xF3AE,\r\n\t0x6B65, 0xDCC6, 0x6B66, 0xD9EB, 0x6B6A, 0xE8E0, 0x6B72, 0xE1A8,\t0x6B77, 0xD5F6, 0x6B78, 0xCFFD, 0x6B7B, 0xDEDD, 0x6B7F, 0xD9D1,\r\n\t0x6B83, 0xE4EA, 0x6B84, 0xF2CF, 0x6B86, 0xF7BF, 0x6B89, 0xE2E6,\t0x6B8A, 0xE2A8, 0x6B96, 0xE3D6, 0x6B98, 0xEDD1, 0x6B9E, 0xE9F9,\r\n\t0x6BAE, 0xD6B1, 0x6BAF, 0xDEB2, 0x6BB2, 0xE0E8, 0x6BB5, 0xD3AB,\t0x6BB7, 0xEBDC, 0x6BBA, 0xDFAF, 0x6BBC, 0xCAC3, 0x6BBF, 0xEEFC,\r\n\t0x6BC1, 0xFDC3, 0x6BC5, 0xEBF6, 0x6BC6, 0xCFB2, 0x6BCB, 0xD9EC,\t0x6BCD, 0xD9BD, 0x6BCF, 0xD8DF, 0x6BD2, 0xD4B8, 0x6BD3, 0xEBBE,\r\n\t0x6BD4, 0xDDEF, 0x6BD6, 0xDDF0, 0x6BD7, 0xDDF1, 0x6BD8, 0xDDF2,\t0x6BDB, 0xD9BE, 0x6BEB, 0xFBC6, 0x6BEC, 0xCFB3, 0x6C08, 0xEEFD,\r\n\t0x6C0F, 0xE4AB, 0x6C11, 0xDAC5, 0x6C13, 0xD8EC, 0x6C23, 0xD1A8,\t0x6C34, 0xE2A9, 0x6C37, 0xDEBC, 0x6C38, 0xE7B5, 0x6C3E, 0xDBF0,\r\n\t0x6C40, 0xEFE2, 0x6C41, 0xF1F0, 0x6C42, 0xCFB4, 0x6C4E, 0xDBF1,\t0x6C50, 0xE0B1, 0x6C55, 0xDFA5, 0x6C57, 0xF9D2, 0x6C5A, 0xE7FD,\r\n\t0x6C5D, 0xE6A3, 0x6C5E, 0xFBF1, 0x6C5F, 0xCBB0, 0x6C60, 0xF2AE,\t0x6C68, 0xCDE7, 0x6C6A, 0xE8DC, 0x6C6D, 0xE7D7, 0x6C70, 0xF7C0,\r\n\t0x6C72, 0xD0E3, 0x6C76, 0xDAA1, 0x6C7A, 0xCCBD, 0x6C7D, 0xD1A9,\t0x6C7E, 0xDDCC, 0x6C81, 0xE3FE, 0x6C82, 0xD1AA, 0x6C83, 0xE8AA,\r\n\t0x6C85, 0xEAB6, 0x6C86, 0xF9FA, 0x6C87, 0xE6CC, 0x6C88, 0xF6D8,\t0x6C8C, 0xD4C7, 0x6C90, 0xD9CB, 0x6C92, 0xD9D2, 0x6C93, 0xD3CB,\r\n\t0x6C94, 0xD8F7, 0x6C95, 0xDAA9, 0x6C96, 0xF5F8, 0x6C99, 0xDEDE,\t0x6C9A, 0xF2AF, 0x6C9B, 0xF8A9, 0x6CAB, 0xD8C8, 0x6CAE, 0xEEC1,\r\n\t0x6CB3, 0xF9C1, 0x6CB8, 0xDDF3, 0x6CB9, 0xEAFA, 0x6CBB, 0xF6BD,\t0x6CBC, 0xE1BB, 0x6CBD, 0xCDBF, 0x6CBE, 0xF4D4, 0x6CBF, 0xE6CD,\r\n\t0x6CC1, 0xFCCF, 0x6CC2, 0xFBA2, 0x6CC4, 0xE0DC, 0x6CC9, 0xF4BB,\t0x6CCA, 0xDAD5, 0x6CCC, 0xF9B2, 0x6CD3, 0xFBF2, 0x6CD5, 0xDBF6,\r\n\t0x6CD7, 0xDEDF, 0x6CDB, 0xDBF2, 0x6CE1, 0xF8DC, 0x6CE2, 0xF7EE,\t0x6CE3, 0xEBE8, 0x6CE5, 0xD2FA, 0x6CE8, 0xF1BC, 0x6CEB, 0xFADA,\r\n\t0x6CEE, 0xDAEA, 0x6CEF, 0xDAC6, 0x6CF0, 0xF7C1, 0x6CF3, 0xE7B6,\t0x6D0B, 0xE5C7, 0x6D0C, 0xD6AC, 0x6D11, 0xDCC7, 0x6D17, 0xE1A9,\r\n\t0x6D19, 0xE2AA, 0x6D1B, 0xD5A6, 0x6D1E, 0xD4D7, 0x6D25, 0xF2D0,\t0x6D27, 0xEAFB, 0x6D29, 0xE0DD, 0x6D2A, 0xFBF3, 0x6D32, 0xF1BD,\r\n\t0x6D35, 0xE2E7, 0x6D36, 0xFDD7, 0x6D38, 0xCEC8, 0x6D39, 0xEAB7,\t0x6D3B, 0xFCC0, 0x6D3D, 0xFDE7, 0x6D3E, 0xF7EF, 0x6D41, 0xD7B5,\r\n\t0x6D59, 0xEFBA, 0x6D5A, 0xF1DD, 0x6D5C, 0xDEB3, 0x6D63, 0xE8CB,\t0x6D66, 0xF8DD, 0x6D69, 0xFBC7, 0x6D6A, 0xD5C8, 0x6D6C, 0xD7DF,\r\n\t0x6D6E, 0xDDA9, 0x6D74, 0xE9B1, 0x6D77, 0xFAAD, 0x6D78, 0xF6D9,\t0x6D79, 0xFAF4, 0x6D7F, 0xF8AA, 0x6D85, 0xE6EE, 0x6D87, 0xCCDC,\r\n\t0x6D88, 0xE1BC, 0x6D89, 0xE0EF, 0x6D8C, 0xE9BF, 0x6D8D, 0xFCFD,\t0x6D8E, 0xE6CE, 0x6D91, 0xE1D7, 0x6D93, 0xE6CF, 0x6D95, 0xF4F1,\r\n\t0x6DAF, 0xE4F3, 0x6DB2, 0xE4FB, 0x6DB5, 0xF9E4, 0x6DC0, 0xEFE3,\t0x6DC3, 0xCFEE, 0x6DC4, 0xF6BE, 0x6DC5, 0xE0B2, 0x6DC6, 0xFCFE,\r\n\t0x6DC7, 0xD1AB, 0x6DCB, 0xD7FA, 0x6DCF, 0xFBC8, 0x6DD1, 0xE2D7,\t0x6DD8, 0xD4A3, 0x6DD9, 0xF0F8, 0x6DDA, 0xD7A8, 0x6DDE, 0xE1E7,\r\n\t0x6DE1, 0xD3BF, 0x6DE8, 0xEFE4, 0x6DEA, 0xD7C5, 0x6DEB, 0xEBE2,\t0x6DEE, 0xFCE7, 0x6DF1, 0xE4A2, 0x6DF3, 0xE2E8, 0x6DF5, 0xE6D0,\r\n\t0x6DF7, 0xFBE8, 0x6DF8, 0xF4E8, 0x6DF9, 0xE5F4, 0x6DFA, 0xF4BC,\t0x6DFB, 0xF4D5, 0x6E17, 0xDFB6, 0x6E19, 0xFCB9, 0x6E1A, 0xEEC2,\r\n\t0x6E1B, 0xCAF5, 0x6E1F, 0xEFE5, 0x6E20, 0xCBE2, 0x6E21, 0xD4A4,\t0x6E23, 0xDEE0, 0x6E24, 0xDAFD, 0x6E25, 0xE4C6, 0x6E26, 0xE8BE,\r\n\t0x6E2B, 0xE0DE, 0x6E2C, 0xF6B4, 0x6E2D, 0xEAD2, 0x6E2F, 0xF9FB,\t0x6E32, 0xE0C2, 0x6E34, 0xCAE4, 0x6E36, 0xE7B7, 0x6E38, 0xEAFD,\r\n\t0x6E3A, 0xD9DD, 0x6E3C, 0xDAB4, 0x6E3D, 0xEEAA, 0x6E3E, 0xFBE9,\t0x6E43, 0xDBCB, 0x6E44, 0xDAB5, 0x6E4A, 0xF1BE, 0x6E4D, 0xD3AC,\r\n\t0x6E56, 0xFBC9, 0x6E58, 0xDFCF, 0x6E5B, 0xD3C0, 0x6E5C, 0xE3D7,\t0x6E5E, 0xEFE6, 0x6E5F, 0xFCD0, 0x6E67, 0xE9C0, 0x6E6B, 0xF5D3,\r\n\t0x6E6E, 0xECDC, 0x6E6F, 0xF7B7, 0x6E72, 0xEAB8, 0x6E73, 0xD1F9,\t0x6E7A, 0xDCC8, 0x6E90, 0xEAB9, 0x6E96, 0xF1DE, 0x6E9C, 0xD7B6,\r\n\t0x6E9D, 0xCFB5, 0x6E9F, 0xD9A8, 0x6EA2, 0xECEE, 0x6EA5, 0xDDAA,\t0x6EAA, 0xCDA2, 0x6EAB, 0xE8AE, 0x6EAF, 0xE1BD, 0x6EB1, 0xF2D1,\r\n\t0x6EB6, 0xE9C1, 0x6EBA, 0xD2FC, 0x6EC2, 0xDBB5, 0x6EC4, 0xF3E7,\t0x6EC5, 0xD8FE, 0x6EC9, 0xFCD1, 0x6ECB, 0xEDB2, 0x6ECC, 0xF4AF,\r\n\t0x6ECE, 0xFBA3, 0x6ED1, 0xFCC1, 0x6ED3, 0xEEAB, 0x6ED4, 0xD4A5,\t0x6EEF, 0xF4F2, 0x6EF4, 0xEED9, 0x6EF8, 0xFBCA, 0x6EFE, 0xCDE3,\r\n\t0x6EFF, 0xD8BB, 0x6F01, 0xE5DB, 0x6F02, 0xF8F7, 0x6F06, 0xF6D4,\t0x6F0F, 0xD7A9, 0x6F11, 0xCBC9, 0x6F14, 0xE6D1, 0x6F15, 0xF0CC,\r\n\t0x6F20, 0xD8AE, 0x6F22, 0xF9D3, 0x6F23, 0xD5FE, 0x6F2B, 0xD8BC,\t0x6F2C, 0xF2B0, 0x6F31, 0xE2AB, 0x6F32, 0xF3E8, 0x6F38, 0xEFC2,\r\n\t0x6F3F, 0xEDEC, 0x6F41, 0xE7B8, 0x6F51, 0xDAFE, 0x6F54, 0xCCBE,\t0x6F57, 0xF2FC, 0x6F58, 0xDAEB, 0x6F5A, 0xE2D8, 0x6F5B, 0xEDD6,\r\n\t0x6F5E, 0xD6D1, 0x6F5F, 0xE0B3, 0x6F62, 0xFCD2, 0x6F64, 0xEBC8,\t0x6F6D, 0xD3C1, 0x6F6E, 0xF0CD, 0x6F70, 0xCFF7, 0x6F7A, 0xEDD2,\r\n\t0x6F7C, 0xD4D8, 0x6F7D, 0xDCC9, 0x6F7E, 0xD7F1, 0x6F81, 0xDFBB,\t0x6F84, 0xF3A5, 0x6F88, 0xF4CD, 0x6F8D, 0xF1BF, 0x6F8E, 0xF8B1,\r\n\t0x6F90, 0xE9FA, 0x6F94, 0xFBCB, 0x6F97, 0xCAD5, 0x6FA3, 0xF9D4,\t0x6FA4, 0xF7CA, 0x6FA7, 0xD6C8, 0x6FAE, 0xFCE8, 0x6FAF, 0xF3BD,\r\n\t0x6FB1, 0xEEFE, 0x6FB3, 0xE7FE, 0x6FB9, 0xD3C2, 0x6FBE, 0xD3B6,\t0x6FC0, 0xCCAD, 0x6FC1, 0xF6FA, 0x6FC2, 0xD6B2, 0x6FC3, 0xD2D8,\r\n\t0x6FCA, 0xE7D8, 0x6FD5, 0xE3A5, 0x6FDA, 0xE7B9, 0x6FDF, 0xF0AD,\t0x6FE0, 0xFBCC, 0x6FE1, 0xEBA1, 0x6FE4, 0xD4A6, 0x6FE9, 0xFBCD,\r\n\t0x6FEB, 0xD5BD, 0x6FEC, 0xF1DF, 0x6FEF, 0xF6FB, 0x6FF1, 0xDEB4,\t0x6FFE, 0xD5EB, 0x7001, 0xE5C8, 0x7005, 0xFBA4, 0x7006, 0xD4B9,\r\n\t0x7009, 0xDEE1, 0x700B, 0xE4A3, 0x700F, 0xD7B7, 0x7011, 0xF8EE,\t0x7015, 0xDEB5, 0x7018, 0xD6D2, 0x701A, 0xF9D5, 0x701B, 0xE7BA,\r\n\t0x701C, 0xEBD5, 0x701D, 0xD5F7, 0x701E, 0xEFE7, 0x701F, 0xE1BE,\t0x7023, 0xFAAE, 0x7027, 0xD6E9, 0x7028, 0xD6EE, 0x702F, 0xE7BB,\r\n\t0x7037, 0xECCB, 0x703E, 0xD5B3, 0x704C, 0xCEB4, 0x7050, 0xFBA5,\t0x7051, 0xE1EE, 0x7058, 0xF7A8, 0x705D, 0xFBCE, 0x7063, 0xD8BD,\r\n\t0x706B, 0xFBFD, 0x7070, 0xFCE9, 0x7078, 0xCFB6, 0x707C, 0xEDC7,\t0x707D, 0xEEAC, 0x7085, 0xCCDD, 0x708A, 0xF6A7, 0x708E, 0xE6FA,\r\n\t0x7092, 0xF5A4, 0x7098, 0xFDDC, 0x7099, 0xEDB3, 0x709A, 0xCEC9,\t0x70A1, 0xEFE8, 0x70A4, 0xE1BF, 0x70AB, 0xFADB, 0x70AC, 0xCBE3,\r\n\t0x70AD, 0xF7A9, 0x70AF, 0xFBA6, 0x70B3, 0xDCB9, 0x70B7, 0xF1C0,\t0x70B8, 0xEDC8, 0x70B9, 0xEFC3, 0x70C8, 0xD6AD, 0x70CB, 0xFDCE,\r\n\t0x70CF, 0xE8A1, 0x70D8, 0xFBF4, 0x70D9, 0xD5A7, 0x70DD, 0xF1F6,\t0x70DF, 0xE6D3, 0x70F1, 0xCCDE, 0x70F9, 0xF8B2, 0x70FD, 0xDCEB,\r\n\t0x7104, 0xFDB6, 0x7109, 0xE5EA, 0x710C, 0xF1E0, 0x7119, 0xDBCC,\t0x711A, 0xDDCD, 0x711E, 0xD4C8, 0x7121, 0xD9ED, 0x7126, 0xF5A5,\r\n\t0x7130, 0xE6FB, 0x7136, 0xE6D4, 0x7147, 0xFDC8, 0x7149, 0xD6A1,\t0x714A, 0xFDBF, 0x714C, 0xFCD3, 0x714E, 0xEFA1, 0x7150, 0xE7BC,\r\n\t0x7156, 0xD1EE, 0x7159, 0xE6D5, 0x715C, 0xE9F2, 0x715E, 0xDFB0,\t0x7164, 0xD8E0, 0x7165, 0xFCBA, 0x7166, 0xFDAF, 0x7167, 0xF0CE,\r\n\t0x7169, 0xDBE1, 0x716C, 0xE5C9, 0x716E, 0xEDB4, 0x717D, 0xE0C3,\t0x7184, 0xE3D8, 0x7189, 0xE9FB, 0x718A, 0xEAA8, 0x718F, 0xFDB7,\r\n\t0x7192, 0xFBA7, 0x7194, 0xE9C2, 0x7199, 0xFDF7, 0x719F, 0xE2D9,\t0x71A2, 0xDCEC, 0x71AC, 0xE8A2, 0x71B1, 0xE6F0, 0x71B9, 0xFDF8,\r\n\t0x71BA, 0xFDF9, 0x71BE, 0xF6BF, 0x71C1, 0xE7A7, 0x71C3, 0xE6D7,\t0x71C8, 0xD4F3, 0x71C9, 0xD4C9, 0x71CE, 0xD6FA, 0x71D0, 0xD7F2,\r\n\t0x71D2, 0xE1C0, 0x71D4, 0xDBE2, 0x71D5, 0xE6D8, 0x71DF, 0xE7BD,\t0x71E5, 0xF0CF, 0x71E6, 0xF3BE, 0x71E7, 0xE2AC, 0x71ED, 0xF5B7,\r\n\t0x71EE, 0xE0F0, 0x71FB, 0xFDB8, 0x71FC, 0xE3E8, 0x71FE, 0xD4A7,\t0x71FF, 0xE8FC, 0x7200, 0xFAD2, 0x7206, 0xF8EF, 0x7210, 0xD6D3,\r\n\t0x721B, 0xD5B4, 0x722A, 0xF0D0, 0x722C, 0xF7F0, 0x722D, 0xEEB3,\t0x7230, 0xEABA, 0x7232, 0xEAD3, 0x7235, 0xEDC9, 0x7236, 0xDDAB,\r\n\t0x723A, 0xE5AC, 0x723B, 0xFDA1, 0x723D, 0xDFD0, 0x723E, 0xECB3,\t0x7240, 0xDFD1, 0x7246, 0xEDED, 0x7247, 0xF8B8, 0x7248, 0xF7FA,\r\n\t0x724C, 0xF8AB, 0x7252, 0xF4E0, 0x7258, 0xD4BA, 0x7259, 0xE4B3,\t0x725B, 0xE9DA, 0x725D, 0xDEB6, 0x725F, 0xD9BF, 0x7261, 0xD9C0,\r\n\t0x7262, 0xD6EF, 0x7267, 0xD9CC, 0x7269, 0xDAAA, 0x7272, 0xDFE5,\t0x7279, 0xF7E5, 0x727D, 0xCCB2, 0x7280, 0xDFF9, 0x7281, 0xD7E0,\r\n\t0x72A2, 0xD4BB, 0x72A7, 0xFDFA, 0x72AC, 0xCCB3, 0x72AF, 0xDBF3,\t0x72C0, 0xDFD2, 0x72C2, 0xCECA, 0x72C4, 0xEEDA, 0x72CE, 0xE4E4,\r\n\t0x72D0, 0xFBCF, 0x72D7, 0xCFB7, 0x72D9, 0xEEC3, 0x72E1, 0xCEEA,\t0x72E9, 0xE2AD, 0x72F8, 0xD7E1, 0x72F9, 0xFAF5, 0x72FC, 0xD5C9,\r\n\t0x72FD, 0xF8AC, 0x730A, 0xE7D9, 0x7316, 0xF3E9, 0x731B, 0xD8ED,\t0x731C, 0xE3C4, 0x731D, 0xF0F1, 0x7325, 0xE8E5, 0x7329, 0xE0FA,\r\n\t0x732A, 0xEEC4, 0x732B, 0xD9DE, 0x7336, 0xEBA2, 0x7337, 0xEBA3,\t0x733E, 0xFCC2, 0x733F, 0xEABB, 0x7344, 0xE8AB, 0x7345, 0xDEE2,\r\n\t0x7350, 0xEDEF, 0x7352, 0xE8A3, 0x7357, 0xCFF1, 0x7368, 0xD4BC,\t0x736A, 0xFCEA, 0x7370, 0xE7BE, 0x7372, 0xFCF2, 0x7375, 0xD6B4,\r\n\t0x7378, 0xE2AE, 0x737A, 0xD3B7, 0x737B, 0xFACC, 0x7384, 0xFADC,\t0x7386, 0xEDB5, 0x7387, 0xE1E3, 0x7389, 0xE8AC, 0x738B, 0xE8DD,\r\n\t0x738E, 0xEFE9, 0x7394, 0xF4BD, 0x7396, 0xCFB8, 0x7397, 0xE9DB,\t0x7398, 0xD1AC, 0x739F, 0xDAC7, 0x73A7, 0xEBC9, 0x73A9, 0xE8CC,\r\n\t0x73AD, 0xDEB7, 0x73B2, 0xD6BC, 0x73B3, 0xD3E5, 0x73B9, 0xFADD,\t0x73C0, 0xDAD6, 0x73C2, 0xCAB1, 0x73C9, 0xDAC8, 0x73CA, 0xDFA6,\r\n\t0x73CC, 0xF9B3, 0x73CD, 0xF2D2, 0x73CF, 0xCAC4, 0x73D6, 0xCECB,\t0x73D9, 0xCDF5, 0x73DD, 0xFDB0, 0x73DE, 0xD5A8, 0x73E0, 0xF1C1,\r\n\t0x73E3, 0xE2E9, 0x73E4, 0xDCCA, 0x73E5, 0xECB4, 0x73E6, 0xFAC0,\t0x73E9, 0xFBA8, 0x73EA, 0xD0A8, 0x73ED, 0xDAEC, 0x73F7, 0xD9EE,\r\n\t0x73F9, 0xE0FB, 0x73FD, 0xEFEA, 0x73FE, 0xFADE, 0x7401, 0xE0C4,\t0x7403, 0xCFB9, 0x7405, 0xD5CA, 0x7406, 0xD7E2, 0x7407, 0xE2AF,\r\n\t0x7409, 0xD7B8, 0x7413, 0xE8CD, 0x741B, 0xF6DA, 0x7420, 0xEFA2,\t0x7421, 0xE2DA, 0x7422, 0xF6FC, 0x7425, 0xFBD0, 0x7426, 0xD1AD,\r\n\t0x7428, 0xCDE4, 0x742A, 0xD1AE, 0x742B, 0xDCED, 0x742C, 0xE8CE,\t0x742E, 0xF0F9, 0x742F, 0xCEB5, 0x7430, 0xE6FC, 0x7433, 0xD7FB,\r\n\t0x7434, 0xD0D6, 0x7435, 0xDDF5, 0x7436, 0xF7F1, 0x7438, 0xF6FD,\t0x743A, 0xDBF7, 0x743F, 0xFBEA, 0x7440, 0xE9DC, 0x7441, 0xD9C1,\r\n\t0x7443, 0xF5F2, 0x7444, 0xE0C5, 0x744B, 0xEAD4, 0x7455, 0xF9C2,\t0x7457, 0xEABC, 0x7459, 0xD2C5, 0x745A, 0xFBD1, 0x745B, 0xE7C0,\r\n\t0x745C, 0xEBA5, 0x745E, 0xDFFA, 0x745F, 0xE3A2, 0x7460, 0xD7B9,\t0x7462, 0xE9C3, 0x7464, 0xE8FD, 0x7465, 0xE8AF, 0x7468, 0xF2D3,\r\n\t0x7469, 0xFBA9, 0x746A, 0xD8A5, 0x746F, 0xD5CB, 0x747E, 0xD0C8,\t0x7482, 0xD1AF, 0x7483, 0xD7E3, 0x7487, 0xE0C6, 0x7489, 0xD6A2,\r\n\t0x748B, 0xEDF0, 0x7498, 0xD7F3, 0x749C, 0xFCD4, 0x749E, 0xDAD7,\t0x749F, 0xCCDF, 0x74A1, 0xF2D4, 0x74A3, 0xD1B0, 0x74A5, 0xCCE0,\r\n\t0x74A7, 0xDBFD, 0x74A8, 0xF3BF, 0x74AA, 0xF0D1, 0x74B0, 0xFCBB,\t0x74B2, 0xE2B0, 0x74B5, 0xE6A5, 0x74B9, 0xE2DB, 0x74BD, 0xDFDE,\r\n\t0x74BF, 0xE0C7, 0x74C6, 0xF2EF, 0x74CA, 0xCCE1, 0x74CF, 0xD6EA,\t0x74D4, 0xE7C2, 0x74D8, 0xCEB6, 0x74DA, 0xF3C0, 0x74DC, 0xCDFE,\r\n\t0x74E0, 0xFBD2, 0x74E2, 0xF8F8, 0x74E3, 0xF7FB, 0x74E6, 0xE8BF,\t0x74EE, 0xE8B7, 0x74F7, 0xEDB6, 0x7501, 0xDCBA, 0x7504, 0xCCB4,\r\n\t0x7511, 0xF1F7, 0x7515, 0xE8B8, 0x7518, 0xCAF6, 0x751A, 0xE4A4,\t0x751B, 0xF4D6, 0x751F, 0xDFE6, 0x7523, 0xDFA7, 0x7525, 0xDFE7,\r\n\t0x7526, 0xE1C1, 0x7528, 0xE9C4, 0x752B, 0xDCCB, 0x752C, 0xE9C5,\t0x7530, 0xEFA3, 0x7531, 0xEBA6, 0x7532, 0xCBA3, 0x7533, 0xE3E9,\r\n\t0x7537, 0xD1FB, 0x7538, 0xEFA4, 0x753A, 0xEFEB, 0x7547, 0xD0B4,\t0x754C, 0xCDA3, 0x754F, 0xE8E6, 0x7551, 0xEFA5, 0x7553, 0xD3CC,\r\n\t0x7554, 0xDAED, 0x7559, 0xD7BA, 0x755B, 0xF2D5, 0x755C, 0xF5E5,\t0x755D, 0xD9EF, 0x7562, 0xF9B4, 0x7565, 0xD5D4, 0x7566, 0xFDCF,\r\n\t0x756A, 0xDBE3, 0x756F, 0xF1E1, 0x7570, 0xECB6, 0x7575, 0xFBFE,\t0x7576, 0xD3D7, 0x7578, 0xD1B1, 0x757A, 0xCBB1, 0x757F, 0xD1B2,\r\n\t0x7586, 0xCBB2, 0x7587, 0xF1C2, 0x758A, 0xF4E1, 0x758B, 0xF9B5,\t0x758E, 0xE1C3, 0x758F, 0xE1C2, 0x7591, 0xEBF7, 0x759D, 0xDFA8,\r\n\t0x75A5, 0xCBCA, 0x75AB, 0xE6B9, 0x75B1, 0xF8DE, 0x75B2, 0xF9AA,\t0x75B3, 0xCAF7, 0x75B5, 0xEDB7, 0x75B8, 0xD3B8, 0x75B9, 0xF2D6,\r\n\t0x75BC, 0xD4D9, 0x75BD, 0xEEC5, 0x75BE, 0xF2F0, 0x75C2, 0xCAB2,\t0x75C5, 0xDCBB, 0x75C7, 0xF1F8, 0x75CD, 0xECB7, 0x75D2, 0xE5CA,\r\n\t0x75D4, 0xF6C0, 0x75D5, 0xFDDD, 0x75D8, 0xD4E3, 0x75D9, 0xCCE2,\t0x75DB, 0xF7D4, 0x75E2, 0xD7E5, 0x75F0, 0xD3C3, 0x75F2, 0xD8A6,\r\n\t0x75F4, 0xF6C1, 0x75FA, 0xDDF6, 0x75FC, 0xCDC0, 0x7600, 0xE5DC,\t0x760D, 0xE5CB, 0x7619, 0xE1C4, 0x761F, 0xE8B0, 0x7620, 0xF4B0,\r\n\t0x7621, 0xF3EA, 0x7622, 0xDAEE, 0x7624, 0xD7BB, 0x7626, 0xE2B1,\t0x763B, 0xD7AA, 0x7642, 0xD6FB, 0x764C, 0xE4DF, 0x764E, 0xCAD6,\r\n\t0x7652, 0xEBA8, 0x7656, 0xDBFE, 0x7661, 0xF6C2, 0x7664, 0xEFBB,\t0x7669, 0xD4FD, 0x766C, 0xE0C8, 0x7670, 0xE8B9, 0x7672, 0xEFA6,\r\n\t0x7678, 0xCDA4, 0x767B, 0xD4F4, 0x767C, 0xDBA1, 0x767D, 0xDBDC,\t0x767E, 0xDBDD, 0x7684, 0xEEDC, 0x7686, 0xCBCB, 0x7687, 0xFCD5,\r\n\t0x768E, 0xCEEB, 0x7690, 0xCDC1, 0x7693, 0xFBD3, 0x76AE, 0xF9AB,\t0x76BA, 0xF5D4, 0x76BF, 0xD9A9, 0x76C2, 0xE9DD, 0x76C3, 0xDBCD,\r\n\t0x76C6, 0xDDCE, 0x76C8, 0xE7C3, 0x76CA, 0xECCC, 0x76D2, 0xF9EC,\t0x76D6, 0xCBCC, 0x76DB, 0xE0FC, 0x76DC, 0xD4A8, 0x76DE, 0xEDD3,\r\n\t0x76DF, 0xD8EF, 0x76E1, 0xF2D7, 0x76E3, 0xCAF8, 0x76E4, 0xDAEF,\t0x76E7, 0xD6D4, 0x76EE, 0xD9CD, 0x76F2, 0xD8EE, 0x76F4, 0xF2C1,\r\n\t0x76F8, 0xDFD3, 0x76FC, 0xDAF0, 0x76FE, 0xE2EA, 0x7701, 0xE0FD,\t0x7704, 0xD8F8, 0x7708, 0xF7AF, 0x7709, 0xDAB6, 0x770B, 0xCAD7,\r\n\t0x771E, 0xF2D8, 0x7720, 0xD8F9, 0x7729, 0xFADF, 0x7737, 0xCFEF,\t0x7738, 0xD9C2, 0x773A, 0xF0D2, 0x773C, 0xE4D1, 0x7740, 0xF3B7,\r\n\t0x774D, 0xFAE0, 0x775B, 0xEFEC, 0x7761, 0xE2B2, 0x7763, 0xD4BD,\t0x7766, 0xD9CE, 0x776B, 0xF4E2, 0x7779, 0xD4A9, 0x777E, 0xCDC2,\r\n\t0x777F, 0xE7DA, 0x778B, 0xF2D9, 0x7791, 0xD9AA, 0x779E, 0xD8BE,\t0x77A5, 0xDCAD, 0x77AC, 0xE2EB, 0x77AD, 0xD6FC, 0x77B0, 0xCAF9,\r\n\t0x77B3, 0xD4DA, 0x77BB, 0xF4D7, 0x77BC, 0xCCA1, 0x77BF, 0xCFBA,\t0x77D7, 0xF5B8, 0x77DB, 0xD9C3, 0x77DC, 0xD0E8, 0x77E2, 0xE3C5,\r\n\t0x77E3, 0xEBF8, 0x77E5, 0xF2B1, 0x77E9, 0xCFBB, 0x77ED, 0xD3AD,\t0x77EE, 0xE8E1, 0x77EF, 0xCEEC, 0x77F3, 0xE0B4, 0x7802, 0xDEE3,\r\n\t0x7812, 0xDDF7, 0x7825, 0xF2B2, 0x7826, 0xF3F6, 0x7827, 0xF6DB,\t0x782C, 0xD7FE, 0x7832, 0xF8DF, 0x7834, 0xF7F2, 0x7845, 0xD0A9,\r\n\t0x784F, 0xE6DA, 0x785D, 0xF5A6, 0x786B, 0xD7BC, 0x786C, 0xCCE3,\t0x786F, 0xE6DB, 0x787C, 0xDDDD, 0x7881, 0xD1B3, 0x7887, 0xEFED,\r\n\t0x788C, 0xD6DE, 0x788D, 0xE4F4, 0x788E, 0xE1EF, 0x7891, 0xDDF8,\t0x7897, 0xE8CF, 0x78A3, 0xCAE5, 0x78A7, 0xDCA1, 0x78A9, 0xE0B5,\r\n\t0x78BA, 0xFCAC, 0x78BB, 0xFCAD, 0x78BC, 0xD8A7, 0x78C1, 0xEDB8,\t0x78C5, 0xDBB6, 0x78CA, 0xD6F0, 0x78CB, 0xF3AF, 0x78CE, 0xCDA5,\r\n\t0x78D0, 0xDAF1, 0x78E8, 0xD8A8, 0x78EC, 0xCCE4, 0x78EF, 0xD1B4,\t0x78F5, 0xCAD8, 0x78FB, 0xDAF2, 0x7901, 0xF5A7, 0x790E, 0xF5A8,\r\n\t0x7916, 0xE6A6, 0x792A, 0xD5EC, 0x792B, 0xD5F8, 0x792C, 0xDAF3,\t0x793A, 0xE3C6, 0x793E, 0xDEE4, 0x7940, 0xDEE5, 0x7941, 0xD1B5,\r\n\t0x7947, 0xD1B6, 0x7948, 0xD1B7, 0x7949, 0xF2B3, 0x7950, 0xE9DE,\t0x7956, 0xF0D3, 0x7957, 0xF2B4, 0x795A, 0xF0D4, 0x795B, 0xCBE4,\r\n\t0x795C, 0xFBD4, 0x795D, 0xF5E6, 0x795E, 0xE3EA, 0x7960, 0xDEE6,\t0x7965, 0xDFD4, 0x7968, 0xF8F9, 0x796D, 0xF0AE, 0x797A, 0xD1B8,\r\n\t0x797F, 0xD6DF, 0x7981, 0xD0D7, 0x798D, 0xFCA1, 0x798E, 0xEFEE,\t0x798F, 0xDCD8, 0x7991, 0xE9DF, 0x79A6, 0xE5DD, 0x79A7, 0xFDFB,\r\n\t0x79AA, 0xE0C9, 0x79AE, 0xD6C9, 0x79B1, 0xD4AA, 0x79B3, 0xE5CC,\t0x79B9, 0xE9E0, 0x79BD, 0xD0D8, 0x79BE, 0xFCA2, 0x79BF, 0xD4BE,\r\n\t0x79C0, 0xE2B3, 0x79C1, 0xDEE7, 0x79C9, 0xDCBC, 0x79CA, 0xD2B6,\t0x79CB, 0xF5D5, 0x79D1, 0xCEA1, 0x79D2, 0xF5A9, 0x79D5, 0xDDF9,\r\n\t0x79D8, 0xDDFA, 0x79DF, 0xF0D5, 0x79E4, 0xF6DF, 0x79E6, 0xF2DA,\t0x79E7, 0xE4EB, 0x79E9, 0xF2F1, 0x79FB, 0xECB9, 0x7A00, 0xFDFC,\r\n\t0x7A05, 0xE1AA, 0x7A08, 0xCAD9, 0x7A0B, 0xEFEF, 0x7A0D, 0xF5AA,\t0x7A14, 0xECF9, 0x7A17, 0xF8AD, 0x7A19, 0xF2C2, 0x7A1A, 0xF6C3,\r\n\t0x7A1C, 0xD7D2, 0x7A1F, 0xF9A2, 0x7A20, 0xF0D6, 0x7A2E, 0xF0FA,\t0x7A31, 0xF6E0, 0x7A36, 0xE9F3, 0x7A37, 0xF2C3, 0x7A3B, 0xD4AB,\r\n\t0x7A3C, 0xCAB3, 0x7A3D, 0xCDA6, 0x7A3F, 0xCDC3, 0x7A40, 0xCDDA,\t0x7A46, 0xD9CF, 0x7A49, 0xF6C4, 0x7A4D, 0xEEDD, 0x7A4E, 0xE7C4,\r\n\t0x7A57, 0xE2B4, 0x7A61, 0xDFE2, 0x7A62, 0xE7DB, 0x7A69, 0xE8B1,\t0x7A6B, 0xFCAE, 0x7A70, 0xE5CD, 0x7A74, 0xFAEB, 0x7A76, 0xCFBC,\r\n\t0x7A79, 0xCFE2, 0x7A7A, 0xCDF6, 0x7A7D, 0xEFF0, 0x7A7F, 0xF4BE,\t0x7A81, 0xD4CD, 0x7A84, 0xF3B8, 0x7A88, 0xE9A1, 0x7A92, 0xF2F2,\r\n\t0x7A93, 0xF3EB, 0x7A95, 0xF0D7, 0x7A98, 0xCFD7, 0x7A9F, 0xCFDF,\t0x7AA9, 0xE8C0, 0x7AAA, 0xE8C1, 0x7AAE, 0xCFE3, 0x7AAF, 0xE9A2,\r\n\t0x7ABA, 0xD0AA, 0x7AC4, 0xF3C1, 0x7AC5, 0xD0AB, 0x7AC7, 0xD4E4,\t0x7ACA, 0xEFBC, 0x7ACB, 0xD8A1, 0x7AD7, 0xD9DF, 0x7AD9, 0xF3D7,\r\n\t0x7ADD, 0xDCBD, 0x7ADF, 0xCCE5, 0x7AE0, 0xEDF1, 0x7AE3, 0xF1E2,\t0x7AE5, 0xD4DB, 0x7AEA, 0xE2B5, 0x7AED, 0xCAE6, 0x7AEF, 0xD3AE,\r\n\t0x7AF6, 0xCCE6, 0x7AF9, 0xF1D3, 0x7AFA, 0xF5E7, 0x7AFF, 0xCADA,\t0x7B0F, 0xFBEE, 0x7B11, 0xE1C5, 0x7B19, 0xDFE9, 0x7B1B, 0xEEDE,\r\n\t0x7B1E, 0xF7C2, 0x7B20, 0xD8A2, 0x7B26, 0xDDAC, 0x7B2C, 0xF0AF,\t0x7B2D, 0xD6BD, 0x7B39, 0xE1AB, 0x7B46, 0xF9B6, 0x7B49, 0xD4F5,\r\n\t0x7B4B, 0xD0C9, 0x7B4C, 0xEFA7, 0x7B4D, 0xE2EC, 0x7B4F, 0xDBEA,\t0x7B50, 0xCECC, 0x7B51, 0xF5E8, 0x7B52, 0xF7D5, 0x7B54, 0xD3CD,\r\n\t0x7B56, 0xF3FE, 0x7B60, 0xD0B5, 0x7B6C, 0xE0FE, 0x7B6E, 0xDFFB,\t0x7B75, 0xE6DD, 0x7B7D, 0xE8A4, 0x7B87, 0xCBCD, 0x7B8B, 0xEFA8,\r\n\t0x7B8F, 0xEEB4, 0x7B94, 0xDAD8, 0x7B95, 0xD1B9, 0x7B97, 0xDFA9,\t0x7B9A, 0xF3B0, 0x7B9D, 0xCCC4, 0x7BA1, 0xCEB7, 0x7BAD, 0xEFA9,\r\n\t0x7BB1, 0xDFD5, 0x7BB4, 0xEDD7, 0x7BB8, 0xEEC6, 0x7BC0, 0xEFBD,\t0x7BC1, 0xFCD6, 0x7BC4, 0xDBF4, 0x7BC6, 0xEFAA, 0x7BC7, 0xF8B9,\r\n\t0x7BC9, 0xF5E9, 0x7BD2, 0xE3D9, 0x7BE0, 0xE1C6, 0x7BE4, 0xD4BF,\t0x7BE9, 0xDEE8, 0x7C07, 0xF0EA, 0x7C12, 0xF3C2, 0x7C1E, 0xD3AF,\r\n\t0x7C21, 0xCADB, 0x7C27, 0xFCD7, 0x7C2A, 0xEDD8, 0x7C2B, 0xE1C7,\t0x7C3D, 0xF4D8, 0x7C3E, 0xD6B3, 0x7C3F, 0xDDAD, 0x7C43, 0xD5BE,\r\n\t0x7C4C, 0xF1C3, 0x7C4D, 0xEEDF, 0x7C60, 0xD6EB, 0x7C64, 0xF4D9,\t0x7C6C, 0xD7E6, 0x7C73, 0xDAB7, 0x7C83, 0xDDFB, 0x7C89, 0xDDCF,\r\n\t0x7C92, 0xD8A3, 0x7C95, 0xDAD9, 0x7C97, 0xF0D8, 0x7C98, 0xEFC4,\t0x7C9F, 0xE1D8, 0x7CA5, 0xF1D4, 0x7CA7, 0xEDF2, 0x7CAE, 0xD5DB,\r\n\t0x7CB1, 0xD5DC, 0x7CB2, 0xF3C4, 0x7CB3, 0xCBD7, 0x7CB9, 0xE2B6,\t0x7CBE, 0xEFF1, 0x7CCA, 0xFBD5, 0x7CD6, 0xD3D8, 0x7CDE, 0xDDD0,\r\n\t0x7CDF, 0xF0D9, 0x7CE0, 0xCBB3, 0x7CE7, 0xD5DD, 0x7CFB, 0xCDA7,\t0x7CFE, 0xD0AC, 0x7D00, 0xD1BA, 0x7D02, 0xF1C4, 0x7D04, 0xE5B3,\r\n\t0x7D05, 0xFBF5, 0x7D06, 0xE9E1, 0x7D07, 0xFDE0, 0x7D08, 0xFCBC,\t0x7D0A, 0xDAA2, 0x7D0B, 0xDAA3, 0x7D0D, 0xD2A1, 0x7D10, 0xD2EF,\r\n\t0x7D14, 0xE2ED, 0x7D17, 0xDEE9, 0x7D18, 0xCEDC, 0x7D19, 0xF2B5,\t0x7D1A, 0xD0E4, 0x7D1B, 0xDDD1, 0x7D20, 0xE1C8, 0x7D21, 0xDBB7,\r\n\t0x7D22, 0xDFE3, 0x7D2B, 0xEDB9, 0x7D2C, 0xF1C5, 0x7D2E, 0xF3CF,\t0x7D2F, 0xD7AB, 0x7D30, 0xE1AC, 0x7D33, 0xE3EB, 0x7D35, 0xEEC7,\r\n\t0x7D39, 0xE1C9, 0x7D3A, 0xCAFA, 0x7D42, 0xF0FB, 0x7D43, 0xFAE1,\t0x7D44, 0xF0DA, 0x7D45, 0xCCE7, 0x7D46, 0xDAF4, 0x7D50, 0xCCBF,\r\n\t0x7D5E, 0xCEED, 0x7D61, 0xD5A9, 0x7D62, 0xFAE2, 0x7D66, 0xD0E5,\t0x7D68, 0xEBD6, 0x7D6A, 0xECDF, 0x7D6E, 0xDFFC, 0x7D71, 0xF7D6,\r\n\t0x7D72, 0xDEEA, 0x7D73, 0xCBB4, 0x7D76, 0xEFBE, 0x7D79, 0xCCB5,\t0x7D7F, 0xCFBD, 0x7D8E, 0xEFF2, 0x7D8F, 0xE2B7, 0x7D93, 0xCCE8,\r\n\t0x7D9C, 0xF0FC, 0x7DA0, 0xD6E0, 0x7DA2, 0xF1C6, 0x7DAC, 0xE2B8,\t0x7DAD, 0xEBAB, 0x7DB1, 0xCBB5, 0x7DB2, 0xD8D1, 0x7DB4, 0xF4CE,\r\n\t0x7DB5, 0xF3F7, 0x7DB8, 0xD7C6, 0x7DBA, 0xD1BB, 0x7DBB, 0xF7AA,\t0x7DBD, 0xEDCA, 0x7DBE, 0xD7D3, 0x7DBF, 0xD8FA, 0x7DC7, 0xF6C5,\r\n\t0x7DCA, 0xD1CC, 0x7DCB, 0xDDFC, 0x7DD6, 0xDFFD, 0x7DD8, 0xF9E5,\t0x7DDA, 0xE0CA, 0x7DDD, 0xF2FD, 0x7DDE, 0xD3B0, 0x7DE0, 0xF4F3,\r\n\t0x7DE1, 0xDAC9, 0x7DE3, 0xE6DE, 0x7DE8, 0xF8BA, 0x7DE9, 0xE8D0,\t0x7DEC, 0xD8FB, 0x7DEF, 0xEAD5, 0x7DF4, 0xD6A3, 0x7DFB, 0xF6C6,\r\n\t0x7E09, 0xF2DB, 0x7E0A, 0xE4FC, 0x7E15, 0xE8B2, 0x7E1B, 0xDADA,\t0x7E1D, 0xF2DC, 0x7E1E, 0xFBD6, 0x7E1F, 0xE9B2, 0x7E21, 0xEEAD,\r\n\t0x7E23, 0xFAE3, 0x7E2B, 0xDCEE, 0x7E2E, 0xF5EA, 0x7E2F, 0xE6E0,\t0x7E31, 0xF0FD, 0x7E37, 0xD7AC, 0x7E3D, 0xF5C5, 0x7E3E, 0xEEE0,\r\n\t0x7E41, 0xDBE5, 0x7E43, 0xDDDE, 0x7E46, 0xD9F0, 0x7E47, 0xE9A3,\t0x7E52, 0xF1F9, 0x7E54, 0xF2C4, 0x7E55, 0xE0CB, 0x7E5E, 0xE9A4,\r\n\t0x7E61, 0xE2B9, 0x7E69, 0xE3B1, 0x7E6A, 0xFCEB, 0x7E6B, 0xCDA8,\t0x7E6D, 0xCCB6, 0x7E70, 0xF0DB, 0x7E79, 0xE6BA, 0x7E7C, 0xCDA9,\r\n\t0x7E82, 0xF3C3, 0x7E8C, 0xE1D9, 0x7E8F, 0xEFAB, 0x7E93, 0xE7C5,\t0x7E96, 0xE0E9, 0x7E98, 0xF3C5, 0x7E9B, 0xD4C0, 0x7E9C, 0xD5BF,\r\n\t0x7F36, 0xDDAE, 0x7F38, 0xF9FC, 0x7F3A, 0xCCC0, 0x7F4C, 0xE5A2,\t0x7F50, 0xCEB8, 0x7F54, 0xD8D2, 0x7F55, 0xF9D6, 0x7F6A, 0xF1AA,\r\n\t0x7F6B, 0xCED1, 0x7F6E, 0xF6C7, 0x7F70, 0xDBEB, 0x7F72, 0xDFFE,\t0x7F75, 0xD8E1, 0x7F77, 0xF7F3, 0x7F79, 0xD7E7, 0x7F85, 0xD4FE,\r\n\t0x7F88, 0xD1BC, 0x7F8A, 0xE5CF, 0x7F8C, 0xCBB6, 0x7F8E, 0xDAB8,\t0x7F94, 0xCDC4, 0x7F9A, 0xD6BE, 0x7F9E, 0xE2BA, 0x7FA4, 0xCFD8,\r\n\t0x7FA8, 0xE0CC, 0x7FA9, 0xEBF9, 0x7FB2, 0xFDFD, 0x7FB8, 0xD7E8,\t0x7FB9, 0xCBD8, 0x7FBD, 0xE9E2, 0x7FC1, 0xE8BA, 0x7FC5, 0xE3C7,\r\n\t0x7FCA, 0xECCD, 0x7FCC, 0xECCE, 0x7FCE, 0xD6BF, 0x7FD2, 0xE3A7,\t0x7FD4, 0xDFD6, 0x7FD5, 0xFDE8, 0x7FDF, 0xEEE1, 0x7FE0, 0xF6A8,\r\n\t0x7FE1, 0xDDFD, 0x7FE9, 0xF8BB, 0x7FEB, 0xE8D1, 0x7FF0, 0xF9D7,\t0x7FF9, 0xCEEE, 0x7FFC, 0xECCF, 0x8000, 0xE9A5, 0x8001, 0xD6D5,\r\n\t0x8003, 0xCDC5, 0x8005, 0xEDBA, 0x8006, 0xD1BD, 0x8009, 0xCFBE,\t0x800C, 0xECBB, 0x8010, 0xD2B1, 0x8015, 0xCCE9, 0x8017, 0xD9C4,\r\n\t0x8018, 0xE9FC, 0x802D, 0xD1BE, 0x8033, 0xECBC, 0x8036, 0xE5AD,\t0x803D, 0xF7B0, 0x803F, 0xCCEA, 0x8043, 0xD3C4, 0x8046, 0xD6C0,\r\n\t0x804A, 0xD6FD, 0x8056, 0xE1A1, 0x8058, 0xDEBD, 0x805A, 0xF6A9,\t0x805E, 0xDAA4, 0x806F, 0xD6A4, 0x8070, 0xF5C6, 0x8072, 0xE1A2,\r\n\t0x8073, 0xE9C6, 0x8077, 0xF2C5, 0x807D, 0xF4E9, 0x807E, 0xD6EC,\t0x807F, 0xEBD3, 0x8084, 0xECBD, 0x8085, 0xE2DC, 0x8086, 0xDEEB,\r\n\t0x8087, 0xF0DC, 0x8089, 0xEBBF, 0x808B, 0xD7CE, 0x808C, 0xD1BF,\t0x8096, 0xF5AB, 0x809B, 0xF9FD, 0x809D, 0xCADC, 0x80A1, 0xCDC6,\r\n\t0x80A2, 0xF2B6, 0x80A5, 0xDDFE, 0x80A9, 0xCCB7, 0x80AA, 0xDBB8,\t0x80AF, 0xD0E9, 0x80B1, 0xCEDD, 0x80B2, 0xEBC0, 0x80B4, 0xFDA2,\r\n\t0x80BA, 0xF8CB, 0x80C3, 0xEAD6, 0x80C4, 0xF1B0, 0x80CC, 0xDBCE,\t0x80CE, 0xF7C3, 0x80DA, 0xDBCF, 0x80DB, 0xCBA4, 0x80DE, 0xF8E0,\r\n\t0x80E1, 0xFBD7, 0x80E4, 0xEBCA, 0x80E5, 0xE0A1, 0x80F1, 0xCECD,\t0x80F4, 0xD4DC, 0x80F8, 0xFDD8, 0x80FD, 0xD2F6, 0x8102, 0xF2B7,\r\n\t0x8105, 0xFAF6, 0x8106, 0xF6AA, 0x8107, 0xFAF7, 0x8108, 0xD8E6,\t0x810A, 0xF4B1, 0x8118, 0xE8D2, 0x811A, 0xCAC5, 0x811B, 0xCCEB,\r\n\t0x8123, 0xE2EE, 0x8129, 0xE2BB, 0x812B, 0xF7AD, 0x812F, 0xF8E1,\t0x8139, 0xF3EC, 0x813E, 0xDEA1, 0x814B, 0xE4FD, 0x814E, 0xE3EC,\r\n\t0x8150, 0xDDAF, 0x8151, 0xDDB0, 0x8154, 0xCBB7, 0x8155, 0xE8D3,\t0x8165, 0xE1A3, 0x8166, 0xD2E0, 0x816B, 0xF0FE, 0x8170, 0xE9A6,\r\n\t0x8171, 0xCBF2, 0x8178, 0xEDF3, 0x8179, 0xDCD9, 0x817A, 0xE0CD,\t0x817F, 0xF7DA, 0x8180, 0xDBB9, 0x8188, 0xCCAE, 0x818A, 0xDADB,\r\n\t0x818F, 0xCDC7, 0x819A, 0xDDB1, 0x819C, 0xD8AF, 0x819D, 0xE3A3,\t0x81A0, 0xCEEF, 0x81A3, 0xF2F3, 0x81A8, 0xF8B3, 0x81B3, 0xE0CE,\r\n\t0x81B5, 0xF5FD, 0x81BA, 0xEBEC, 0x81BD, 0xD3C5, 0x81BE, 0xFCEC,\t0x81BF, 0xD2DB, 0x81C0, 0xD4EB, 0x81C2, 0xDEA2, 0x81C6, 0xE5E6,\r\n\t0x81CD, 0xF0B0, 0x81D8, 0xD5C4, 0x81DF, 0xEDF4, 0x81E3, 0xE3ED,\t0x81E5, 0xE8C2, 0x81E7, 0xEDF5, 0x81E8, 0xD7FC, 0x81EA, 0xEDBB,\r\n\t0x81ED, 0xF6AB, 0x81F3, 0xF2B8, 0x81F4, 0xF6C8, 0x81FA, 0xD3E6,\t0x81FB, 0xF2DD, 0x81FC, 0xCFBF, 0x81FE, 0xEBAC, 0x8205, 0xCFC0,\r\n\t0x8207, 0xE6A8, 0x8208, 0xFDE9, 0x820A, 0xCFC1, 0x820C, 0xE0DF,\t0x820D, 0xDEEC, 0x8212, 0xE0A2, 0x821B, 0xF4BF, 0x821C, 0xE2EF,\r\n\t0x821E, 0xD9F1, 0x821F, 0xF1C7, 0x8221, 0xCBB8, 0x822A, 0xF9FE,\t0x822B, 0xDBBA, 0x822C, 0xDAF5, 0x8235, 0xF6EC, 0x8236, 0xDADC,\r\n\t0x8237, 0xFAE4, 0x8239, 0xE0CF, 0x8240, 0xDDB2, 0x8245, 0xE6A9,\t0x8247, 0xEFF3, 0x8259, 0xF3ED, 0x8264, 0xEBFA, 0x8266, 0xF9E6,\r\n\t0x826E, 0xCADD, 0x826F, 0xD5DE, 0x8271, 0xCADE, 0x8272, 0xDFE4,\t0x8276, 0xE6FD, 0x8278, 0xF5AC, 0x827E, 0xE4F5, 0x828B, 0xE9E3,\r\n\t0x828D, 0xEDCB, 0x828E, 0xCFE4, 0x8292, 0xD8D3, 0x8299, 0xDDB3,\t0x829A, 0xD4EC, 0x829D, 0xF2B9, 0x829F, 0xDFB7, 0x82A5, 0xCBCE,\r\n\t0x82A6, 0xFBD8, 0x82A9, 0xD0D9, 0x82AC, 0xDDD2, 0x82AD, 0xF7F4,\t0x82AE, 0xE7DC, 0x82AF, 0xE4A5, 0x82B1, 0xFCA3, 0x82B3, 0xDBBB,\r\n\t0x82B7, 0xF2BA, 0x82B8, 0xE9FD, 0x82B9, 0xD0CA, 0x82BB, 0xF5D6,\t0x82BC, 0xD9C5, 0x82BD, 0xE4B4, 0x82BF, 0xEDA7, 0x82D1, 0xEABD,\r\n\t0x82D2, 0xE6FE, 0x82D4, 0xF7C4, 0x82D5, 0xF5AD, 0x82D7, 0xD9E0,\t0x82DB, 0xCAB4, 0x82DE, 0xF8E2, 0x82DF, 0xCFC2, 0x82E1, 0xECBE,\r\n\t0x82E5, 0xE5B4, 0x82E6, 0xCDC8, 0x82E7, 0xEEC8, 0x82F1, 0xE7C8,\t0x82FD, 0xCDC9, 0x82FE, 0xF9B7, 0x8301, 0xF1E8, 0x8302, 0xD9F2,\r\n\t0x8303, 0xDBF5, 0x8304, 0xCAB5, 0x8305, 0xD9C6, 0x8309, 0xD8C9,\t0x8317, 0xD9AB, 0x8328, 0xEDBC, 0x832B, 0xD8D4, 0x832F, 0xDCDA,\r\n\t0x8331, 0xE2BC, 0x8334, 0xFCED, 0x8335, 0xECE0, 0x8336, 0xD2FE,\t0x8338, 0xE9C7, 0x8339, 0xE6AA, 0x8340, 0xE2F0, 0x8347, 0xFABB,\r\n\t0x8349, 0xF5AE, 0x834A, 0xFBAA, 0x834F, 0xECFB, 0x8351, 0xECBF,\t0x8352, 0xFCD8, 0x8373, 0xD4E5, 0x8377, 0xF9C3, 0x837B, 0xEEE2,\r\n\t0x8389, 0xD7E9, 0x838A, 0xEDF6, 0x838E, 0xDEED, 0x8396, 0xCCEC,\t0x8398, 0xE3EE, 0x839E, 0xE8D4, 0x83A2, 0xFAF8, 0x83A9, 0xDDB4,\r\n\t0x83AA, 0xE4B5, 0x83AB, 0xD8B0, 0x83BD, 0xD8D5, 0x83C1, 0xF4EA,\t0x83C5, 0xCEB9, 0x83C9, 0xD6E1, 0x83CA, 0xCFD2, 0x83CC, 0xD0B6,\r\n\t0x83D3, 0xCEA2, 0x83D6, 0xF3EE, 0x83DC, 0xF3F8, 0x83E9, 0xDCCC,\t0x83EB, 0xD0CB, 0x83EF, 0xFCA4, 0x83F0, 0xCDCA, 0x83F1, 0xD7D4,\r\n\t0x83F2, 0xDEA3, 0x83F4, 0xE4E0, 0x83F9, 0xEEC9, 0x83FD, 0xE2DD,\t0x8403, 0xF5FE, 0x8404, 0xD4AC, 0x840A, 0xD5D1, 0x840C, 0xD8F0,\r\n\t0x840D, 0xF8C3, 0x840E, 0xEAD7, 0x8429, 0xF5D7, 0x842C, 0xD8BF,\t0x8431, 0xFDC0, 0x8438, 0xEBAD, 0x843D, 0xD5AA, 0x8449, 0xE7A8,\r\n\t0x8457, 0xEECA, 0x845B, 0xCAE7, 0x8461, 0xF8E3, 0x8463, 0xD4DD,\t0x8466, 0xEAD8, 0x846B, 0xFBD9, 0x846C, 0xEDF7, 0x846F, 0xE5B5,\r\n\t0x8475, 0xD0AD, 0x847A, 0xF1F1, 0x8490, 0xE2BD, 0x8494, 0xE3C8,\t0x8499, 0xD9D5, 0x849C, 0xDFAA, 0x84A1, 0xDBBC, 0x84B2, 0xF8E4,\r\n\t0x84B8, 0xF1FA, 0x84BB, 0xE5B6, 0x84BC, 0xF3EF, 0x84BF, 0xFBDA,\t0x84C0, 0xE1E0, 0x84C2, 0xD9AC, 0x84C4, 0xF5EB, 0x84C6, 0xE0B6,\r\n\t0x84C9, 0xE9C8, 0x84CB, 0xCBCF, 0x84CD, 0xE3C9, 0x84D1, 0xDEEE,\t0x84DA, 0xE2BE, 0x84EC, 0xDCEF, 0x84EE, 0xD6A5, 0x84F4, 0xE2F1,\r\n\t0x84FC, 0xD6FE, 0x8511, 0xD9A1, 0x8513, 0xD8C0, 0x8514, 0xDCDB,\t0x8517, 0xEDBD, 0x8518, 0xDFB8, 0x851A, 0xEAA5, 0x851E, 0xD7AD,\r\n\t0x8521, 0xF3F9, 0x8523, 0xEDF8, 0x8525, 0xF5C7, 0x852C, 0xE1CA,\t0x852D, 0xEBE3, 0x852F, 0xF2DE, 0x853D, 0xF8CC, 0x853F, 0xEAD9,\r\n\t0x8541, 0xD3C6, 0x8543, 0xDBE6, 0x8549, 0xF5AF, 0x854E, 0xCEF0,\t0x8553, 0xE9FE, 0x8559, 0xFBB6, 0x8563, 0xE2F2, 0x8568, 0xCFF2,\r\n\t0x8569, 0xF7B9, 0x856A, 0xD9F3, 0x856D, 0xE1CB, 0x8584, 0xDADD,\t0x8587, 0xDAB9, 0x858F, 0xEBFB, 0x8591, 0xCBB9, 0x8594, 0xEDF9,\r\n\t0x859B, 0xE0E0, 0x85A6, 0xF4C0, 0x85A8, 0xFDBC, 0x85A9, 0xDFB1,\t0x85AA, 0xE3EF, 0x85AF, 0xE0A3, 0x85B0, 0xFDB9, 0x85BA, 0xF0B1,\r\n\t0x85C1, 0xCDCB, 0x85C9, 0xEDBE, 0x85CD, 0xD5C0, 0x85CE, 0xE3F0,\t0x85CF, 0xEDFA, 0x85D5, 0xE9E4, 0x85DC, 0xD5ED, 0x85DD, 0xE7DD,\r\n\t0x85E4, 0xD4F6, 0x85E5, 0xE5B7, 0x85E9, 0xDBE7, 0x85EA, 0xE2BF,\t0x85F7, 0xEECB, 0x85FA, 0xD7F4, 0x85FB, 0xF0DD, 0x85FF, 0xCEAB,\r\n\t0x8602, 0xE7DE, 0x8606, 0xD6D6, 0x8607, 0xE1CC, 0x860A, 0xE8B3,\t0x8616, 0xE5EE, 0x8617, 0xDCA2, 0x861A, 0xE0D0, 0x862D, 0xD5B5,\r\n\t0x863F, 0xD5A1, 0x864E, 0xFBDB, 0x8650, 0xF9CB, 0x8654, 0xCBF3,\t0x8655, 0xF4A5, 0x865B, 0xFAC8, 0x865C, 0xD6D7, 0x865E, 0xE9E5,\r\n\t0x865F, 0xFBDC, 0x8667, 0xFDD0, 0x8679, 0xFBF6, 0x868A, 0xDAA5,\t0x868C, 0xDBBD, 0x8693, 0xECE2, 0x86A3, 0xCDF7, 0x86A4, 0xF0DE,\r\n\t0x86A9, 0xF6C9, 0x86C7, 0xDEEF, 0x86CB, 0xD3B1, 0x86D4, 0xFCEE,\t0x86D9, 0xE8C3, 0x86DB, 0xF1C8, 0x86DF, 0xCEF1, 0x86E4, 0xF9ED,\r\n\t0x86ED, 0xF2F4, 0x86FE, 0xE4B6, 0x8700, 0xF5B9, 0x8702, 0xDCF0,\t0x8703, 0xE3F1, 0x8708, 0xE8A5, 0x8718, 0xF2BB, 0x871A, 0xDEA4,\r\n\t0x871C, 0xDACC, 0x874E, 0xCAE9, 0x8755, 0xE3DA, 0x8757, 0xFCD9,\t0x875F, 0xEADA, 0x8766, 0xF9C4, 0x8768, 0xE3A4, 0x8774, 0xFBDD,\r\n\t0x8776, 0xEFCA, 0x8778, 0xE8C4, 0x8782, 0xD5CC, 0x878D, 0xEBD7,\t0x879F, 0xD9AD, 0x87A2, 0xFBAB, 0x87B3, 0xD3D9, 0x87BA, 0xD5A2,\r\n\t0x87C4, 0xF6DE, 0x87E0, 0xDAF6, 0x87EC, 0xE0D1, 0x87EF, 0xE9A8,\t0x87F2, 0xF5F9, 0x87F9, 0xFAAF, 0x87FB, 0xEBFC, 0x87FE, 0xE0EA,\r\n\t0x8805, 0xE3B2, 0x881F, 0xD5C5, 0x8822, 0xF1E3, 0x8823, 0xD5EE,\t0x8831, 0xCDCC, 0x8836, 0xEDD9, 0x883B, 0xD8C1, 0x8840, 0xFAEC,\r\n\t0x8846, 0xF1EB, 0x884C, 0xFABC, 0x884D, 0xE6E2, 0x8852, 0xFAE5,\t0x8853, 0xE2FA, 0x8857, 0xCAB6, 0x8859, 0xE4B7, 0x885B, 0xEADB,\r\n\t0x885D, 0xF5FA, 0x8861, 0xFBAC, 0x8862, 0xCFC3, 0x8863, 0xEBFD,\t0x8868, 0xF8FA, 0x886B, 0xDFB9, 0x8870, 0xE1F1, 0x8872, 0xD2A4,\r\n\t0x8877, 0xF5FB, 0x887E, 0xD0DA, 0x887F, 0xD0DB, 0x8881, 0xEABE,\t0x8882, 0xD9B1, 0x8888, 0xCAB7, 0x888B, 0xD3E7, 0x888D, 0xF8E5,\r\n\t0x8892, 0xD3B2, 0x8896, 0xE2C0, 0x8897, 0xF2DF, 0x889E, 0xCDE5,\t0x88AB, 0xF9AC, 0x88B4, 0xCDCD, 0x88C1, 0xEEAE, 0x88C2, 0xD6AE,\r\n\t0x88CF, 0xD7EA, 0x88D4, 0xE7E0, 0x88D5, 0xEBAE, 0x88D9, 0xCFD9,\t0x88DC, 0xDCCD, 0x88DD, 0xEDFB, 0x88DF, 0xDEF0, 0x88E1, 0xD7EB,\r\n\t0x88E8, 0xDEA5, 0x88F3, 0xDFD7, 0x88F4, 0xDBD0, 0x88F5, 0xDBD1,\t0x88F8, 0xD5A3, 0x88FD, 0xF0B2, 0x8907, 0xDCDC, 0x8910, 0xCAE8,\r\n\t0x8912, 0xF8E6, 0x8913, 0xDCCE, 0x8918, 0xEADC, 0x8919, 0xDBD2,\t0x8925, 0xE9B3, 0x892A, 0xF7DB, 0x8936, 0xE3A8, 0x8938, 0xD7AE,\r\n\t0x893B, 0xE0E1, 0x8941, 0xCBBA, 0x8944, 0xE5D1, 0x895F, 0xD0DC,\t0x8964, 0xD5C1, 0x896A, 0xD8CA, 0x8972, 0xE3A9, 0x897F, 0xE0A4,\r\n\t0x8981, 0xE9A9, 0x8983, 0xD3C7, 0x8986, 0xDCDD, 0x8987, 0xF8AE,\t0x898B, 0xCCB8, 0x898F, 0xD0AE, 0x8993, 0xD8F2, 0x8996, 0xE3CA,\r\n\t0x89A1, 0xCCAF, 0x89A9, 0xD4AD, 0x89AA, 0xF6D1, 0x89B2, 0xD0CC,\t0x89BA, 0xCAC6, 0x89BD, 0xD5C2, 0x89C0, 0xCEBA, 0x89D2, 0xCAC7,\r\n\t0x89E3, 0xFAB0, 0x89F4, 0xDFD8, 0x89F8, 0xF5BA, 0x8A00, 0xE5EB,\t0x8A02, 0xEFF4, 0x8A03, 0xDDB5, 0x8A08, 0xCDAA, 0x8A0A, 0xE3F2,\r\n\t0x8A0C, 0xFBF7, 0x8A0E, 0xF7D0, 0x8A13, 0xFDBA, 0x8A16, 0xFDE1,\t0x8A17, 0xF6FE, 0x8A18, 0xD1C0, 0x8A1B, 0xE8C5, 0x8A1D, 0xE4B8,\r\n\t0x8A1F, 0xE1E8, 0x8A23, 0xCCC1, 0x8A25, 0xD2ED, 0x8A2A, 0xDBBE,\t0x8A2D, 0xE0E2, 0x8A31, 0xFAC9, 0x8A34, 0xE1CD, 0x8A36, 0xCAB8,\r\n\t0x8A3A, 0xF2E0, 0x8A3B, 0xF1C9, 0x8A50, 0xDEF1, 0x8A54, 0xF0DF,\t0x8A55, 0xF8C4, 0x8A5B, 0xEECC, 0x8A5E, 0xDEF2, 0x8A60, 0xE7C9,\r\n\t0x8A62, 0xE2F3, 0x8A63, 0xE7E1, 0x8A66, 0xE3CB, 0x8A69, 0xE3CC,\t0x8A6D, 0xCFF8, 0x8A6E, 0xEFAC, 0x8A70, 0xFDFE, 0x8A71, 0xFCA5,\r\n\t0x8A72, 0xFAB1, 0x8A73, 0xDFD9, 0x8A75, 0xE0D2, 0x8A79, 0xF4DA,\t0x8A85, 0xF1CA, 0x8A87, 0xCEA3, 0x8A8C, 0xF2BC, 0x8A8D, 0xECE3,\r\n\t0x8A93, 0xE0A5, 0x8A95, 0xF7AB, 0x8A98, 0xEBAF, 0x8A9E, 0xE5DE,\t0x8AA0, 0xE1A4, 0x8AA1, 0xCDAB, 0x8AA3, 0xD9F4, 0x8AA4, 0xE8A6,\r\n\t0x8AA5, 0xCDCE, 0x8AA6, 0xE1E9, 0x8AA8, 0xFCEF, 0x8AAA, 0xE0E3,\t0x8AB0, 0xE2C1, 0x8AB2, 0xCEA4, 0x8AB9, 0xDEA6, 0x8ABC, 0xEBFE,\r\n\t0x8ABE, 0xEBDD, 0x8ABF, 0xF0E0, 0x8AC2, 0xF4DB, 0x8AC4, 0xE2F4,\t0x8AC7, 0xD3C8, 0x8ACB, 0xF4EB, 0x8ACD, 0xEEB5, 0x8ACF, 0xF5D8,\r\n\t0x8AD2, 0xD5DF, 0x8AD6, 0xD6E5, 0x8ADB, 0xEBB0, 0x8ADC, 0xF4E3,\t0x8AE1, 0xE3CD, 0x8AE6, 0xF4F4, 0x8AE7, 0xFAB2, 0x8AEA, 0xEFF5,\r\n\t0x8AEB, 0xCADF, 0x8AED, 0xEBB1, 0x8AEE, 0xEDBF, 0x8AF1, 0xFDC9,\t0x8AF6, 0xE4A6, 0x8AF7, 0xF9A4, 0x8AF8, 0xF0B3, 0x8AFA, 0xE5EC,\r\n\t0x8AFE, 0xD1E7, 0x8B00, 0xD9C7, 0x8B01, 0xE4D7, 0x8B02, 0xEADD,\t0x8B04, 0xD4F7, 0x8B0E, 0xDABA, 0x8B10, 0xDACD, 0x8B14, 0xF9CC,\r\n\t0x8B16, 0xE1DA, 0x8B17, 0xDBBF, 0x8B19, 0xCCC5, 0x8B1A, 0xECD0,\t0x8B1B, 0xCBBB, 0x8B1D, 0xDEF3, 0x8B20, 0xE9AA, 0x8B28, 0xD9C8,\r\n\t0x8B2B, 0xEEE3, 0x8B2C, 0xD7BD, 0x8B33, 0xCFC4, 0x8B39, 0xD0CD,\t0x8B41, 0xFCA6, 0x8B49, 0xF1FB, 0x8B4E, 0xFDD2, 0x8B4F, 0xD1C1,\r\n\t0x8B58, 0xE3DB, 0x8B5A, 0xD3C9, 0x8B5C, 0xDCCF, 0x8B66, 0xCCED,\t0x8B6C, 0xDEA7, 0x8B6F, 0xE6BB, 0x8B70, 0xECA1, 0x8B74, 0xCCB9,\r\n\t0x8B77, 0xFBDE, 0x8B7D, 0xE7E2, 0x8B80, 0xD4C1, 0x8B8A, 0xDCA8,\t0x8B90, 0xE2C2, 0x8B92, 0xF3D8, 0x8B93, 0xE5D3, 0x8B96, 0xF3D9,\r\n\t0x8B9A, 0xF3C6, 0x8C37, 0xCDDB, 0x8C3F, 0xCDAC, 0x8C41, 0xFCC3,\t0x8C46, 0xD4E7, 0x8C48, 0xD1C2, 0x8C4A, 0xF9A5, 0x8C4C, 0xE8D5,\r\n\t0x8C55, 0xE3CE, 0x8C5A, 0xD4CA, 0x8C61, 0xDFDA, 0x8C6A, 0xFBDF,\t0x8C6B, 0xE7E3, 0x8C79, 0xF8FB, 0x8C7A, 0xE3CF, 0x8C82, 0xF5B0,\r\n\t0x8C8A, 0xD8E7, 0x8C8C, 0xD9C9, 0x8C9D, 0xF8AF, 0x8C9E, 0xEFF6,\t0x8CA0, 0xDDB6, 0x8CA1, 0xEEAF, 0x8CA2, 0xCDF8, 0x8CA7, 0xDEB8,\r\n\t0x8CA8, 0xFCA7, 0x8CA9, 0xF7FC, 0x8CAA, 0xF7B1, 0x8CAB, 0xCEBB,\t0x8CAC, 0xF4A1, 0x8CAF, 0xEECD, 0x8CB0, 0xE1AE, 0x8CB3, 0xECC3,\r\n\t0x8CB4, 0xCFFE, 0x8CB6, 0xF8BF, 0x8CB7, 0xD8E2, 0x8CB8, 0xD3E8,\t0x8CBB, 0xDEA8, 0x8CBC, 0xF4E4, 0x8CBD, 0xECC2, 0x8CBF, 0xD9F5,\r\n\t0x8CC0, 0xF9C5, 0x8CC1, 0xDDD3, 0x8CC2, 0xD6F1, 0x8CC3, 0xECFC,\t0x8CC4, 0xFCF0, 0x8CC7, 0xEDC0, 0x8CC8, 0xCAB9, 0x8CCA, 0xEEE4,\r\n\t0x8CD1, 0xF2E1, 0x8CD3, 0xDEB9, 0x8CDA, 0xD6F2, 0x8CDC, 0xDEF4,\t0x8CDE, 0xDFDB, 0x8CE0, 0xDBD3, 0x8CE2, 0xFAE7, 0x8CE3, 0xD8E3,\r\n\t0x8CE4, 0xF4C1, 0x8CE6, 0xDDB7, 0x8CEA, 0xF2F5, 0x8CED, 0xD4AE,\t0x8CF4, 0xD6F3, 0x8CFB, 0xDDB8, 0x8CFC, 0xCFC5, 0x8CFD, 0xDFDF,\r\n\t0x8D04, 0xF2BE, 0x8D05, 0xF6A1, 0x8D07, 0xEBCB, 0x8D08, 0xF1FC,\t0x8D0A, 0xF3C7, 0x8D0D, 0xE0EB, 0x8D13, 0xEDFC, 0x8D16, 0xE1DB,\r\n\t0x8D64, 0xEEE5, 0x8D66, 0xDEF5, 0x8D6B, 0xFAD3, 0x8D70, 0xF1CB,\t0x8D73, 0xD0AF, 0x8D74, 0xDDB9, 0x8D77, 0xD1C3, 0x8D85, 0xF5B1,\r\n\t0x8D8A, 0xEAC6, 0x8D99, 0xF0E1, 0x8DA3, 0xF6AC, 0x8DA8, 0xF5D9,\t0x8DB3, 0xF0EB, 0x8DBA, 0xDDBA, 0x8DBE, 0xF2BF, 0x8DC6, 0xF7C5,\r\n\t0x8DCB, 0xDBA2, 0x8DCC, 0xF2F6, 0x8DCF, 0xCABA, 0x8DDB, 0xF7F5,\t0x8DDD, 0xCBE5, 0x8DE1, 0xEEE6, 0x8DE3, 0xE0D3, 0x8DE8, 0xCEA5,\r\n\t0x8DEF, 0xD6D8, 0x8DF3, 0xD4AF, 0x8E0A, 0xE9C9, 0x8E0F, 0xD3CE,\t0x8E10, 0xF4C2, 0x8E1E, 0xCBE6, 0x8E2A, 0xF1A1, 0x8E30, 0xEBB2,\r\n\t0x8E35, 0xF1A2, 0x8E42, 0xEBB3, 0x8E44, 0xF0B4, 0x8E47, 0xCBF4,\t0x8E48, 0xD4B0, 0x8E49, 0xF3B2, 0x8E4A, 0xFBB7, 0x8E59, 0xF5EC,\r\n\t0x8E5F, 0xEEE7, 0x8E60, 0xF4B2, 0x8E74, 0xF5ED, 0x8E76, 0xCFF3,\t0x8E81, 0xF0E2, 0x8E87, 0xEECE, 0x8E8A, 0xF1CC, 0x8E8D, 0xE5B8,\r\n\t0x8EAA, 0xD7F5, 0x8EAB, 0xE3F3, 0x8EAC, 0xCFE5, 0x8EC0, 0xCFC6,\t0x8ECA, 0xF3B3, 0x8ECB, 0xE4D8, 0x8ECC, 0xCFF9, 0x8ECD, 0xCFDA,\r\n\t0x8ED2, 0xFACD, 0x8EDF, 0xE6E3, 0x8EEB, 0xF2E2, 0x8EF8, 0xF5EE,\t0x8EFB, 0xCABB, 0x8EFE, 0xE3DC, 0x8F03, 0xCEF2, 0x8F05, 0xD6D9,\r\n\t0x8F09, 0xEEB0, 0x8F12, 0xF4E5, 0x8F13, 0xD8C2, 0x8F14, 0xDCD0,\t0x8F15, 0xCCEE, 0x8F1B, 0xD5E0, 0x8F1C, 0xF6CA, 0x8F1D, 0xFDCA,\r\n\t0x8F1E, 0xD8D6, 0x8F1F, 0xF4CF, 0x8F26, 0xD6A6, 0x8F27, 0xDCBE,\t0x8F29, 0xDBD4, 0x8F2A, 0xD7C7, 0x8F2F, 0xF2FE, 0x8F33, 0xF1CD,\r\n\t0x8F38, 0xE2C3, 0x8F39, 0xDCDE, 0x8F3B, 0xDCDF, 0x8F3E, 0xEFAD,\t0x8F3F, 0xE6AB, 0x8F44, 0xF9DD, 0x8F45, 0xEABF, 0x8F49, 0xEFAE,\r\n\t0x8F4D, 0xF4D0, 0x8F4E, 0xCEF3, 0x8F5D, 0xE6AC, 0x8F5F, 0xCEDE,\t0x8F62, 0xD5F9, 0x8F9B, 0xE3F4, 0x8F9C, 0xCDD0, 0x8FA3, 0xD5B8,\r\n\t0x8FA6, 0xF7FD, 0x8FA8, 0xDCA9, 0x8FAD, 0xDEF6, 0x8FAF, 0xDCAA,\t0x8FB0, 0xF2E3, 0x8FB1, 0xE9B4, 0x8FB2, 0xD2DC, 0x8FC2, 0xE9E6,\r\n\t0x8FC5, 0xE3F6, 0x8FCE, 0xE7CA, 0x8FD1, 0xD0CE, 0x8FD4, 0xDAF7,\t0x8FE6, 0xCABC, 0x8FEA, 0xEEE8, 0x8FEB, 0xDADE, 0x8FED, 0xF2F7,\r\n\t0x8FF0, 0xE2FB, 0x8FF2, 0xCCA6, 0x8FF7, 0xDABB, 0x8FF9, 0xEEE9,\t0x8FFD, 0xF5DA, 0x9000, 0xF7DC, 0x9001, 0xE1EA, 0x9002, 0xCEC1,\r\n\t0x9003, 0xD4B1, 0x9005, 0xFDB1, 0x9006, 0xE6BD, 0x9008, 0xFBAD,\t0x900B, 0xF8E7, 0x900D, 0xE1CE, 0x900F, 0xF7E2, 0x9010, 0xF5EF,\r\n\t0x9011, 0xCFC7, 0x9014, 0xD4B2, 0x9015, 0xCCEF, 0x9017, 0xD4E8,\t0x9019, 0xEECF, 0x901A, 0xF7D7, 0x901D, 0xE0A6, 0x901E, 0xD6C1,\r\n\t0x901F, 0xE1DC, 0x9020, 0xF0E3, 0x9021, 0xF1E4, 0x9022, 0xDCF1,\t0x9023, 0xD6A7, 0x902E, 0xF4F5, 0x9031, 0xF1CE, 0x9032, 0xF2E4,\r\n\t0x9035, 0xD0B0, 0x9038, 0xECEF, 0x903C, 0xF9BA, 0x903E, 0xEBB5,\t0x9041, 0xD4ED, 0x9042, 0xE2C4, 0x9047, 0xE9E7, 0x904A, 0xEBB4,\r\n\t0x904B, 0xEAA1, 0x904D, 0xF8BC, 0x904E, 0xCEA6, 0x9050, 0xF9C6,\t0x9051, 0xFCDA, 0x9053, 0xD4B3, 0x9054, 0xD3B9, 0x9055, 0xEADE,\r\n\t0x9059, 0xE9AB, 0x905C, 0xE1E1, 0x905D, 0xD3CF, 0x905E, 0xF4F6,\t0x9060, 0xEAC0, 0x9061, 0xE1CF, 0x9063, 0xCCBA, 0x9069, 0xEEEA,\r\n\t0x906D, 0xF0E4, 0x906E, 0xF3B4, 0x906F, 0xD4EE, 0x9072, 0xF2C0,\t0x9075, 0xF1E5, 0x9077, 0xF4C3, 0x9078, 0xE0D4, 0x907A, 0xEBB6,\r\n\t0x907C, 0xD7A1, 0x907D, 0xCBE8, 0x907F, 0xF9AD, 0x9080, 0xE9AD,\t0x9081, 0xD8E4, 0x9082, 0xFAB3, 0x9083, 0xE2C5, 0x9084, 0xFCBD,\r\n\t0x9087, 0xECC4, 0x9088, 0xD8B1, 0x908A, 0xDCAB, 0x908F, 0xD5A4,\t0x9091, 0xEBE9, 0x9095, 0xE8BB, 0x9099, 0xD8D7, 0x90A2, 0xFBAE,\r\n\t0x90A3, 0xD1E1, 0x90A6, 0xDBC0, 0x90A8, 0xF5BE, 0x90AA, 0xDEF7,\t0x90AF, 0xCAFB, 0x90B0, 0xF7C6, 0x90B1, 0xCFC8, 0x90B5, 0xE1D0,\r\n\t0x90B8, 0xEED0, 0x90C1, 0xE9F4, 0x90CA, 0xCEF4, 0x90DE, 0xD5CD,\t0x90E1, 0xCFDB, 0x90E8, 0xDDBB, 0x90ED, 0xCEAC, 0x90F5, 0xE9E8,\r\n\t0x90FD, 0xD4B4, 0x9102, 0xE4C7, 0x9112, 0xF5DB, 0x9115, 0xFAC1,\t0x9119, 0xDEA9, 0x9127, 0xD4F8, 0x912D, 0xEFF7, 0x9132, 0xD3B3,\r\n\t0x9149, 0xEBB7, 0x914A, 0xEFF8, 0x914B, 0xF5DC, 0x914C, 0xEDCC,\t0x914D, 0xDBD5, 0x914E, 0xF1CF, 0x9152, 0xF1D0, 0x9162, 0xF5B2,\r\n\t0x9169, 0xD9AE, 0x916A, 0xD5AC, 0x916C, 0xE2C6, 0x9175, 0xFDA3,\t0x9177, 0xFBE5, 0x9178, 0xDFAB, 0x9187, 0xE2F5, 0x9189, 0xF6AD,\r\n\t0x918B, 0xF5B3, 0x918D, 0xF0B5, 0x9192, 0xE1A5, 0x919C, 0xF5DD,\t0x91AB, 0xECA2, 0x91AC, 0xEDFD, 0x91AE, 0xF5B4, 0x91AF, 0xFBB8,\r\n\t0x91B1, 0xDBA3, 0x91B4, 0xD6CA, 0x91B5, 0xCBD9, 0x91C0, 0xE5D4,\t0x91C7, 0xF3FA, 0x91C9, 0xEBB8, 0x91CB, 0xE0B7, 0x91CC, 0xD7EC,\r\n\t0x91CD, 0xF1EC, 0x91CE, 0xE5AF, 0x91CF, 0xD5E1, 0x91D0, 0xD7ED,\t0x91D1, 0xD1D1, 0x91D7, 0xE1F2, 0x91D8, 0xEFF9, 0x91DC, 0xDDBC,\r\n\t0x91DD, 0xF6DC, 0x91E3, 0xF0E5, 0x91E7, 0xF4C4, 0x91EA, 0xE9E9,\t0x91F5, 0xF3FB, 0x920D, 0xD4EF, 0x9210, 0xCCA2, 0x9211, 0xF7FE,\r\n\t0x9212, 0xDFBC, 0x9217, 0xEBCD, 0x921E, 0xD0B7, 0x9234, 0xD6C2,\t0x923A, 0xE8AD, 0x923F, 0xEFAF, 0x9240, 0xCBA5, 0x9245, 0xCBE9,\r\n\t0x9249, 0xFAE8, 0x9257, 0xCCC6, 0x925B, 0xE6E7, 0x925E, 0xEAC7,\t0x9262, 0xDBA4, 0x9264, 0xCFC9, 0x9265, 0xE2FC, 0x9266, 0xEFFA,\r\n\t0x9280, 0xEBDE, 0x9283, 0xF5C8, 0x9285, 0xD4DE, 0x9291, 0xE0D5,\t0x9293, 0xEFB0, 0x9296, 0xE2C7, 0x9298, 0xD9AF, 0x929C, 0xF9E7,\r\n\t0x92B3, 0xE7E5, 0x92B6, 0xCFCA, 0x92B7, 0xE1D1, 0x92B9, 0xE2C8,\t0x92CC, 0xEFFB, 0x92CF, 0xFAF9, 0x92D2, 0xDCF2, 0x92E4, 0xE0A7,\r\n\t0x92EA, 0xF8E8, 0x92F8, 0xCBEA, 0x92FC, 0xCBBC, 0x9304, 0xD6E2,\t0x9310, 0xF5DE, 0x9318, 0xF5DF, 0x931A, 0xEEB6, 0x931E, 0xE2F6,\r\n\t0x931F, 0xD3CA, 0x9320, 0xEFFC, 0x9321, 0xD1C4, 0x9322, 0xEFB1,\t0x9324, 0xD1C5, 0x9326, 0xD0DE, 0x9328, 0xD9E1, 0x932B, 0xE0B8,\r\n\t0x932E, 0xCDD1, 0x932F, 0xF3B9, 0x9348, 0xE7CC, 0x934A, 0xD6A8,\t0x934B, 0xCEA7, 0x934D, 0xD4B5, 0x9354, 0xE4C8, 0x935B, 0xD3B4,\r\n\t0x936E, 0xEBB9, 0x9375, 0xCBF5, 0x937C, 0xF6DD, 0x937E, 0xF1A3,\t0x938C, 0xCCC7, 0x9394, 0xE9CA, 0x9396, 0xE1F0, 0x939A, 0xF5E0,\r\n\t0x93A3, 0xFBAF, 0x93A7, 0xCBD1, 0x93AC, 0xFBE0, 0x93AD, 0xF2E5,\t0x93B0, 0xECF0, 0x93C3, 0xF0EC, 0x93D1, 0xEEEB, 0x93DE, 0xE9CB,\r\n\t0x93E1, 0xCCF0, 0x93E4, 0xD7AF, 0x93F6, 0xF3A1, 0x9404, 0xFCF5,\t0x9418, 0xF1A4, 0x9425, 0xE0D6, 0x942B, 0xEFB2, 0x9435, 0xF4D1,\r\n\t0x9438, 0xF7A1, 0x9444, 0xF1D1, 0x9451, 0xCAFC, 0x9452, 0xCAFD,\t0x945B, 0xCECE, 0x947D, 0xF3C8, 0x947F, 0xF3BA, 0x9577, 0xEDFE,\r\n\t0x9580, 0xDAA6, 0x9583, 0xE0EC, 0x9589, 0xF8CD, 0x958B, 0xCBD2,\t0x958F, 0xEBCE, 0x9591, 0xF9D8, 0x9592, 0xF9D9, 0x9593, 0xCAE0,\r\n\t0x9594, 0xDACA, 0x9598, 0xCBA6, 0x95A3, 0xCAC8, 0x95A4, 0xF9EE,\t0x95A5, 0xDBEC, 0x95A8, 0xD0B1, 0x95AD, 0xD5EF, 0x95B1, 0xE6F3,\r\n\t0x95BB, 0xE7A2, 0x95BC, 0xE4D9, 0x95C7, 0xE4E1, 0x95CA, 0xFCC4,\t0x95D4, 0xF9EF, 0x95D5, 0xCFF4, 0x95D6, 0xF7E6, 0x95DC, 0xCEBC,\r\n\t0x95E1, 0xF4C5, 0x95E2, 0xDCA3, 0x961C, 0xDDBD, 0x9621, 0xF4C6,\t0x962A, 0xF8A1, 0x962E, 0xE8D6, 0x9632, 0xDBC1, 0x963B, 0xF0E6,\r\n\t0x963F, 0xE4B9, 0x9640, 0xF6ED, 0x9642, 0xF9AE, 0x9644, 0xDDBE,\t0x964B, 0xD7B0, 0x964C, 0xD8E8, 0x964D, 0xCBBD, 0x9650, 0xF9DA,\r\n\t0x965B, 0xF8CE, 0x965C, 0xF9F0, 0x965D, 0xE0ED, 0x965E, 0xE3B3,\t0x965F, 0xF4B3, 0x9662, 0xEAC2, 0x9663, 0xF2E6, 0x9664, 0xF0B6,\r\n\t0x966A, 0xDBD6, 0x9670, 0xEBE4, 0x9673, 0xF2E7, 0x9675, 0xD7D5,\t0x9676, 0xD4B6, 0x9677, 0xF9E8, 0x9678, 0xD7C1, 0x967D, 0xE5D5,\r\n\t0x9685, 0xE9EA, 0x9686, 0xD7CC, 0x968A, 0xD3E9, 0x968B, 0xE2C9,\t0x968D, 0xFCDB, 0x968E, 0xCDAD, 0x9694, 0xCCB0, 0x9695, 0xEAA2,\r\n\t0x9698, 0xE4F6, 0x9699, 0xD0C0, 0x969B, 0xF0B7, 0x969C, 0xEEA1,\t0x96A3, 0xD7F6, 0x96A7, 0xE2CA, 0x96A8, 0xE2CB, 0x96AA, 0xFACF,\r\n\t0x96B1, 0xEBDF, 0x96B7, 0xD6CB, 0x96BB, 0xF4B4, 0x96C0, 0xEDCD,\t0x96C1, 0xE4D2, 0x96C4, 0xEAA9, 0x96C5, 0xE4BA, 0x96C6, 0xF3A2,\r\n\t0x96C7, 0xCDD2, 0x96C9, 0xF6CB, 0x96CB, 0xF1E6, 0x96CC, 0xEDC1,\t0x96CD, 0xE8BC, 0x96CE, 0xEED1, 0x96D5, 0xF0E7, 0x96D6, 0xE2CC,\r\n\t0x96D9, 0xE4AA, 0x96DB, 0xF5E1, 0x96DC, 0xEDDA, 0x96E2, 0xD7EE,\t0x96E3, 0xD1F1, 0x96E8, 0xE9EB, 0x96E9, 0xE9EC, 0x96EA, 0xE0E4,\r\n\t0x96EF, 0xDAA7, 0x96F0, 0xDDD4, 0x96F2, 0xEAA3, 0x96F6, 0xD6C3,\t0x96F7, 0xD6F4, 0x96F9, 0xDADF, 0x96FB, 0xEFB3, 0x9700, 0xE2CD,\r\n\t0x9706, 0xEFFD, 0x9707, 0xF2E8, 0x9711, 0xEFC5, 0x9713, 0xE7E7,\t0x9716, 0xD7FD, 0x9719, 0xE7CE, 0x971C, 0xDFDC, 0x971E, 0xF9C7,\r\n\t0x9727, 0xD9F6, 0x9730, 0xDFAC, 0x9732, 0xD6DA, 0x9739, 0xDCA4,\t0x973D, 0xF0B8, 0x9742, 0xD5FA, 0x9744, 0xE4F7, 0x9748, 0xD6C4,\r\n\t0x9751, 0xF4EC, 0x9756, 0xEFFE, 0x975C, 0xF0A1, 0x975E, 0xDEAA,\t0x9761, 0xDABC, 0x9762, 0xD8FC, 0x9769, 0xFAD4, 0x976D, 0xECE5,\r\n\t0x9774, 0xFCA8, 0x9777, 0xECE6, 0x977A, 0xD8CB, 0x978B, 0xFBB9,\t0x978D, 0xE4D3, 0x978F, 0xCDF9, 0x97A0, 0xCFD3, 0x97A8, 0xCAEA,\r\n\t0x97AB, 0xCFD4, 0x97AD, 0xF8BD, 0x97C6, 0xF4C7, 0x97CB, 0xEADF,\t0x97D3, 0xF9DB, 0x97DC, 0xD4B7, 0x97F3, 0xEBE5, 0x97F6, 0xE1D2,\r\n\t0x97FB, 0xEAA4, 0x97FF, 0xFAC2, 0x9800, 0xFBE1, 0x9801, 0xFAED,\t0x9802, 0xF0A2, 0x9803, 0xCCF1, 0x9805, 0xFAA3, 0x9806, 0xE2F7,\r\n\t0x9808, 0xE2CE, 0x980A, 0xE9F5, 0x980C, 0xE1EB, 0x9810, 0xE7E8,\t0x9811, 0xE8D7, 0x9812, 0xDAF8, 0x9813, 0xD4CB, 0x9817, 0xF7F6,\r\n\t0x9818, 0xD6C5, 0x982D, 0xD4E9, 0x9830, 0xFAFA, 0x9838, 0xCCF2,\t0x9839, 0xF7DD, 0x983B, 0xDEBA, 0x9846, 0xCEA8, 0x984C, 0xF0B9,\r\n\t0x984D, 0xE4FE, 0x984E, 0xE4C9, 0x9854, 0xE4D4, 0x9858, 0xEAC3,\t0x985A, 0xEFB4, 0x985E, 0xD7BE, 0x9865, 0xFBE2, 0x9867, 0xCDD3,\r\n\t0x986B, 0xEFB5, 0x986F, 0xFAE9, 0x98A8, 0xF9A6, 0x98AF, 0xDFBD,\t0x98B1, 0xF7C7, 0x98C4, 0xF8FD, 0x98C7, 0xF8FC, 0x98DB, 0xDEAB,\r\n\t0x98DC, 0xDBE8, 0x98DF, 0xE3DD, 0x98E1, 0xE1E2, 0x98E2, 0xD1C6,\t0x98ED, 0xF6D0, 0x98EE, 0xEBE6, 0x98EF, 0xDAF9, 0x98F4, 0xECC7,\r\n\t0x98FC, 0xDEF8, 0x98FD, 0xF8E9, 0x98FE, 0xE3DE, 0x9903, 0xCEF5,\t0x9909, 0xFAC3, 0x990A, 0xE5D7, 0x990C, 0xECC8, 0x9910, 0xF3C9,\r\n\t0x9913, 0xE4BB, 0x9918, 0xE6AE, 0x991E, 0xEFB6, 0x9920, 0xDCBF,\t0x9928, 0xCEBD, 0x9945, 0xD8C3, 0x9949, 0xD0CF, 0x994B, 0xCFFA,\r\n\t0x994C, 0xF3CA, 0x994D, 0xE0D7, 0x9951, 0xD1C7, 0x9952, 0xE9AE,\t0x9954, 0xE8BD, 0x9957, 0xFAC4, 0x9996, 0xE2CF, 0x9999, 0xFAC5,\r\n\t0x999D, 0xF9B8, 0x99A5, 0xDCE0, 0x99A8, 0xFBB0, 0x99AC, 0xD8A9,\t0x99AD, 0xE5DF, 0x99AE, 0xF9A7, 0x99B1, 0xF6EE, 0x99B3, 0xF6CC,\r\n\t0x99B4, 0xE2F8, 0x99B9, 0xECF1, 0x99C1, 0xDAE0, 0x99D0, 0xF1D2,\t0x99D1, 0xD2CC, 0x99D2, 0xCFCB, 0x99D5, 0xCABD, 0x99D9, 0xDDBF,\r\n\t0x99DD, 0xF6EF, 0x99DF, 0xDEF9, 0x99ED, 0xFAB4, 0x99F1, 0xD5AD,\t0x99FF, 0xF1E7, 0x9A01, 0xDEBE, 0x9A08, 0xDCC0, 0x9A0E, 0xD1C8,\r\n\t0x9A0F, 0xD1C9, 0x9A19, 0xF8BE, 0x9A2B, 0xCBF6, 0x9A30, 0xD4F9,\t0x9A36, 0xF5E2, 0x9A37, 0xE1D3, 0x9A40, 0xD8E9, 0x9A43, 0xF8FE,\r\n\t0x9A45, 0xCFCC, 0x9A4D, 0xFDA4, 0x9A55, 0xCEF6, 0x9A57, 0xFAD0,\t0x9A5A, 0xCCF3, 0x9A5B, 0xE6BE, 0x9A5F, 0xF6AE, 0x9A62, 0xD5F0,\r\n\t0x9A65, 0xD1CA, 0x9A69, 0xFCBE, 0x9A6A, 0xD5F1, 0x9AA8, 0xCDE9,\t0x9AB8, 0xFAB5, 0x9AD3, 0xE2D0, 0x9AD4, 0xF4F7, 0x9AD8, 0xCDD4,\r\n\t0x9AE5, 0xE7A3, 0x9AEE, 0xDBA5, 0x9B1A, 0xE2D1, 0x9B27, 0xD7A2,\t0x9B2A, 0xF7E3, 0x9B31, 0xEAA6, 0x9B3C, 0xD0A1, 0x9B41, 0xCEDA,\r\n\t0x9B42, 0xFBEB, 0x9B43, 0xDBA6, 0x9B44, 0xDBDE, 0x9B45, 0xD8E5,\t0x9B4F, 0xEAE0, 0x9B54, 0xD8AA, 0x9B5A, 0xE5E0, 0x9B6F, 0xD6DB,\r\n\t0x9B8E, 0xEFC6, 0x9B91, 0xF8EA, 0x9B9F, 0xE4D5, 0x9BAB, 0xCEF7,\t0x9BAE, 0xE0D8, 0x9BC9, 0xD7EF, 0x9BD6, 0xF4ED, 0x9BE4, 0xCDE6,\r\n\t0x9BE8, 0xCCF4, 0x9C0D, 0xF5E3, 0x9C10, 0xE4CA, 0x9C12, 0xDCE1,\t0x9C15, 0xF9C8, 0x9C25, 0xFCBF, 0x9C32, 0xE8A7, 0x9C3B, 0xD8C4,\r\n\t0x9C47, 0xCBBE, 0x9C49, 0xDCAE, 0x9C57, 0xD7F7, 0x9CE5, 0xF0E8,\t0x9CE7, 0xDDC0, 0x9CE9, 0xCFCD, 0x9CF3, 0xDCF3, 0x9CF4, 0xD9B0,\r\n\t0x9CF6, 0xE6E9, 0x9D09, 0xE4BC, 0x9D1B, 0xEAC4, 0x9D26, 0xE4EC,\t0x9D28, 0xE4E5, 0x9D3B, 0xFBF8, 0x9D51, 0xCCBB, 0x9D5D, 0xE4BD,\r\n\t0x9D60, 0xCDDC, 0x9D61, 0xD9F7, 0x9D6C, 0xDDDF, 0x9D72, 0xEDCE,\t0x9DA9, 0xD9D0, 0x9DAF, 0xE5A3, 0x9DB4, 0xF9CD, 0x9DC4, 0xCDAE,\r\n\t0x9DD7, 0xCFCE, 0x9DF2, 0xF6AF, 0x9DF8, 0xFDD3, 0x9DF9, 0xEBED,\t0x9DFA, 0xD6DC, 0x9E1A, 0xE5A4, 0x9E1E, 0xD5B6, 0x9E75, 0xD6DD,\r\n\t0x9E79, 0xF9E9, 0x9E7D, 0xE7A4, 0x9E7F, 0xD6E3, 0x9E92, 0xD1CB,\t0x9E93, 0xD6E4, 0x9E97, 0xD5F2, 0x9E9D, 0xDEFA, 0x9E9F, 0xD7F8,\r\n\t0x9EA5, 0xD8EA, 0x9EB4, 0xCFD5, 0x9EB5, 0xD8FD, 0x9EBB, 0xD8AB,\t0x9EBE, 0xFDCB, 0x9EC3, 0xFCDC, 0x9ECD, 0xE0A8, 0x9ECE, 0xD5F3,\r\n\t0x9ED1, 0xFDD9, 0x9ED4, 0xCCA3, 0x9ED8, 0xD9F9, 0x9EDB, 0xD3EA,\t0x9EDC, 0xF5F5, 0x9EDE, 0xEFC7, 0x9EE8, 0xD3DA, 0x9EF4, 0xDABD,\r\n\t0x9F07, 0xE8A8, 0x9F08, 0xDCAF, 0x9F0E, 0xF0A3, 0x9F13, 0xCDD5,\t0x9F20, 0xE0A9, 0x9F3B, 0xDEAC, 0x9F4A, 0xF0BA, 0x9F4B, 0xEEB1,\r\n\t0x9F4E, 0xEEB2, 0x9F52, 0xF6CD, 0x9F5F, 0xEED2, 0x9F61, 0xD6C6,\t0x9F67, 0xE0E5, 0x9F6A, 0xF3BB, 0x9F6C, 0xE5E1, 0x9F77, 0xE4CB,\r\n\t0x9F8D, 0xD7A3, 0x9F90, 0xDBC2, 0x9F95, 0xCAFE, 0x9F9C, 0xCFCF,\t0xAC00, 0xB0A1, 0xAC01, 0xB0A2, 0xAC02, 0x8141, 0xAC03, 0x8142,\r\n\t0xAC04, 0xB0A3, 0xAC05, 0x8143, 0xAC06, 0x8144, 0xAC07, 0xB0A4,\t0xAC08, 0xB0A5, 0xAC09, 0xB0A6, 0xAC0A, 0xB0A7, 0xAC0B, 0x8145,\r\n\t0xAC0C, 0x8146, 0xAC0D, 0x8147, 0xAC0E, 0x8148, 0xAC0F, 0x8149,\t0xAC10, 0xB0A8, 0xAC11, 0xB0A9, 0xAC12, 0xB0AA, 0xAC13, 0xB0AB,\r\n\t0xAC14, 0xB0AC, 0xAC15, 0xB0AD, 0xAC16, 0xB0AE, 0xAC17, 0xB0AF,\t0xAC18, 0x814A, 0xAC19, 0xB0B0, 0xAC1A, 0xB0B1, 0xAC1B, 0xB0B2,\r\n\t0xAC1C, 0xB0B3, 0xAC1D, 0xB0B4, 0xAC1E, 0x814B, 0xAC1F, 0x814C,\t0xAC20, 0xB0B5, 0xAC21, 0x814D, 0xAC22, 0x814E, 0xAC23, 0x814F,\r\n\t0xAC24, 0xB0B6, 0xAC25, 0x8150, 0xAC26, 0x8151, 0xAC27, 0x8152,\t0xAC28, 0x8153, 0xAC29, 0x8154, 0xAC2A, 0x8155, 0xAC2B, 0x8156,\r\n\t0xAC2C, 0xB0B7, 0xAC2D, 0xB0B8, 0xAC2E, 0x8157, 0xAC2F, 0xB0B9,\t0xAC30, 0xB0BA, 0xAC31, 0xB0BB, 0xAC32, 0x8158, 0xAC33, 0x8159,\r\n\t0xAC34, 0x815A, 0xAC35, 0x8161, 0xAC36, 0x8162, 0xAC37, 0x8163,\t0xAC38, 0xB0BC, 0xAC39, 0xB0BD, 0xAC3A, 0x8164, 0xAC3B, 0x8165,\r\n\t0xAC3C, 0xB0BE, 0xAC3D, 0x8166, 0xAC3E, 0x8167, 0xAC3F, 0x8168,\t0xAC40, 0xB0BF, 0xAC41, 0x8169, 0xAC42, 0x816A, 0xAC43, 0x816B,\r\n\t0xAC44, 0x816C, 0xAC45, 0x816D, 0xAC46, 0x816E, 0xAC47, 0x816F,\t0xAC48, 0x8170, 0xAC49, 0x8171, 0xAC4A, 0x8172, 0xAC4B, 0xB0C0,\r\n\t0xAC4C, 0x8173, 0xAC4D, 0xB0C1, 0xAC4E, 0x8174, 0xAC4F, 0x8175,\t0xAC50, 0x8176, 0xAC51, 0x8177, 0xAC52, 0x8178, 0xAC53, 0x8179,\r\n\t0xAC54, 0xB0C2, 0xAC55, 0x817A, 0xAC56, 0x8181, 0xAC57, 0x8182,\t0xAC58, 0xB0C3, 0xAC59, 0x8183, 0xAC5A, 0x8184, 0xAC5B, 0x8185,\r\n\t0xAC5C, 0xB0C4, 0xAC5D, 0x8186, 0xAC5E, 0x8187, 0xAC5F, 0x8188,\t0xAC60, 0x8189, 0xAC61, 0x818A, 0xAC62, 0x818B, 0xAC63, 0x818C,\r\n\t0xAC64, 0x818D, 0xAC65, 0x818E, 0xAC66, 0x818F, 0xAC67, 0x8190,\t0xAC68, 0x8191, 0xAC69, 0x8192, 0xAC6A, 0x8193, 0xAC6B, 0x8194,\r\n\t0xAC6C, 0x8195, 0xAC6D, 0x8196, 0xAC6E, 0x8197, 0xAC6F, 0x8198,\t0xAC70, 0xB0C5, 0xAC71, 0xB0C6, 0xAC72, 0x8199, 0xAC73, 0x819A,\r\n\t0xAC74, 0xB0C7, 0xAC75, 0x819B, 0xAC76, 0x819C, 0xAC77, 0xB0C8,\t0xAC78, 0xB0C9, 0xAC79, 0x819D, 0xAC7A, 0xB0CA, 0xAC7B, 0x819E,\r\n\t0xAC7C, 0x819F, 0xAC7D, 0x81A0, 0xAC7E, 0x81A1, 0xAC7F, 0x81A2,\t0xAC80, 0xB0CB, 0xAC81, 0xB0CC, 0xAC82, 0x81A3, 0xAC83, 0xB0CD,\r\n\t0xAC84, 0xB0CE, 0xAC85, 0xB0CF, 0xAC86, 0xB0D0, 0xAC87, 0x81A4,\t0xAC88, 0x81A5, 0xAC89, 0xB0D1, 0xAC8A, 0xB0D2, 0xAC8B, 0xB0D3,\r\n\t0xAC8C, 0xB0D4, 0xAC8D, 0x81A6, 0xAC8E, 0x81A7, 0xAC8F, 0x81A8,\t0xAC90, 0xB0D5, 0xAC91, 0x81A9, 0xAC92, 0x81AA, 0xAC93, 0x81AB,\r\n\t0xAC94, 0xB0D6, 0xAC95, 0x81AC, 0xAC96, 0x81AD, 0xAC97, 0x81AE,\t0xAC98, 0x81AF, 0xAC99, 0x81B0, 0xAC9A, 0x81B1, 0xAC9B, 0x81B2,\r\n\t0xAC9C, 0xB0D7, 0xAC9D, 0xB0D8, 0xAC9E, 0x81B3, 0xAC9F, 0xB0D9,\t0xACA0, 0xB0DA, 0xACA1, 0xB0DB, 0xACA2, 0x81B4, 0xACA3, 0x81B5,\r\n\t0xACA4, 0x81B6, 0xACA5, 0x81B7, 0xACA6, 0x81B8, 0xACA7, 0x81B9,\t0xACA8, 0xB0DC, 0xACA9, 0xB0DD, 0xACAA, 0xB0DE, 0xACAB, 0x81BA,\r\n\t0xACAC, 0xB0DF, 0xACAD, 0x81BB, 0xACAE, 0x81BC, 0xACAF, 0xB0E0,\t0xACB0, 0xB0E1, 0xACB1, 0x81BD, 0xACB2, 0x81BE, 0xACB3, 0x81BF,\r\n\t0xACB4, 0x81C0, 0xACB5, 0x81C1, 0xACB6, 0x81C2, 0xACB7, 0x81C3,\t0xACB8, 0xB0E2, 0xACB9, 0xB0E3, 0xACBA, 0x81C4, 0xACBB, 0xB0E4,\r\n\t0xACBC, 0xB0E5, 0xACBD, 0xB0E6, 0xACBE, 0x81C5, 0xACBF, 0x81C6,\t0xACC0, 0x81C7, 0xACC1, 0xB0E7, 0xACC2, 0x81C8, 0xACC3, 0x81C9,\r\n\t0xACC4, 0xB0E8, 0xACC5, 0x81CA, 0xACC6, 0x81CB, 0xACC7, 0x81CC,\t0xACC8, 0xB0E9, 0xACC9, 0x81CD, 0xACCA, 0x81CE, 0xACCB, 0x81CF,\r\n\t0xACCC, 0xB0EA, 0xACCD, 0x81D0, 0xACCE, 0x81D1, 0xACCF, 0x81D2,\t0xACD0, 0x81D3, 0xACD1, 0x81D4, 0xACD2, 0x81D5, 0xACD3, 0x81D6,\r\n\t0xACD4, 0x81D7, 0xACD5, 0xB0EB, 0xACD6, 0x81D8, 0xACD7, 0xB0EC,\t0xACD8, 0x81D9, 0xACD9, 0x81DA, 0xACDA, 0x81DB, 0xACDB, 0x81DC,\r\n\t0xACDC, 0x81DD, 0xACDD, 0x81DE, 0xACDE, 0x81DF, 0xACDF, 0x81E0,\t0xACE0, 0xB0ED, 0xACE1, 0xB0EE, 0xACE2, 0x81E1, 0xACE3, 0x81E2,\r\n\t0xACE4, 0xB0EF, 0xACE5, 0x81E3, 0xACE6, 0x81E4, 0xACE7, 0xB0F0,\t0xACE8, 0xB0F1, 0xACE9, 0x81E5, 0xACEA, 0xB0F2, 0xACEB, 0x81E6,\r\n\t0xACEC, 0xB0F3, 0xACED, 0x81E7, 0xACEE, 0x81E8, 0xACEF, 0xB0F4,\t0xACF0, 0xB0F5, 0xACF1, 0xB0F6, 0xACF2, 0x81E9, 0xACF3, 0xB0F7,\r\n\t0xACF4, 0x81EA, 0xACF5, 0xB0F8, 0xACF6, 0xB0F9, 0xACF7, 0x81EB,\t0xACF8, 0x81EC, 0xACF9, 0x81ED, 0xACFA, 0x81EE, 0xACFB, 0x81EF,\r\n\t0xACFC, 0xB0FA, 0xACFD, 0xB0FB, 0xACFE, 0x81F0, 0xACFF, 0x81F1,\t0xAD00, 0xB0FC, 0xAD01, 0x81F2, 0xAD02, 0x81F3, 0xAD03, 0x81F4,\r\n\t0xAD04, 0xB0FD, 0xAD05, 0x81F5, 0xAD06, 0xB0FE, 0xAD07, 0x81F6,\t0xAD08, 0x81F7, 0xAD09, 0x81F8, 0xAD0A, 0x81F9, 0xAD0B, 0x81FA,\r\n\t0xAD0C, 0xB1A1, 0xAD0D, 0xB1A2, 0xAD0E, 0x81FB, 0xAD0F, 0xB1A3,\t0xAD10, 0x81FC, 0xAD11, 0xB1A4, 0xAD12, 0x81FD, 0xAD13, 0x81FE,\r\n\t0xAD14, 0x8241, 0xAD15, 0x8242, 0xAD16, 0x8243, 0xAD17, 0x8244,\t0xAD18, 0xB1A5, 0xAD19, 0x8245, 0xAD1A, 0x8246, 0xAD1B, 0x8247,\r\n\t0xAD1C, 0xB1A6, 0xAD1D, 0x8248, 0xAD1E, 0x8249, 0xAD1F, 0x824A,\t0xAD20, 0xB1A7, 0xAD21, 0x824B, 0xAD22, 0x824C, 0xAD23, 0x824D,\r\n\t0xAD24, 0x824E, 0xAD25, 0x824F, 0xAD26, 0x8250, 0xAD27, 0x8251,\t0xAD28, 0x8252, 0xAD29, 0xB1A8, 0xAD2A, 0x8253, 0xAD2B, 0x8254,\r\n\t0xAD2C, 0xB1A9, 0xAD2D, 0xB1AA, 0xAD2E, 0x8255, 0xAD2F, 0x8256,\t0xAD30, 0x8257, 0xAD31, 0x8258, 0xAD32, 0x8259, 0xAD33, 0x825A,\r\n\t0xAD34, 0xB1AB, 0xAD35, 0xB1AC, 0xAD36, 0x8261, 0xAD37, 0x8262,\t0xAD38, 0xB1AD, 0xAD39, 0x8263, 0xAD3A, 0x8264, 0xAD3B, 0x8265,\r\n\t0xAD3C, 0xB1AE, 0xAD3D, 0x8266, 0xAD3E, 0x8267, 0xAD3F, 0x8268,\t0xAD40, 0x8269, 0xAD41, 0x826A, 0xAD42, 0x826B, 0xAD43, 0x826C,\r\n\t0xAD44, 0xB1AF, 0xAD45, 0xB1B0, 0xAD46, 0x826D, 0xAD47, 0xB1B1,\t0xAD48, 0x826E, 0xAD49, 0xB1B2, 0xAD4A, 0x826F, 0xAD4B, 0x8270,\r\n\t0xAD4C, 0x8271, 0xAD4D, 0x8272, 0xAD4E, 0x8273, 0xAD4F, 0x8274,\t0xAD50, 0xB1B3, 0xAD51, 0x8275, 0xAD52, 0x8276, 0xAD53, 0x8277,\r\n\t0xAD54, 0xB1B4, 0xAD55, 0x8278, 0xAD56, 0x8279, 0xAD57, 0x827A,\t0xAD58, 0xB1B5, 0xAD59, 0x8281, 0xAD5A, 0x8282, 0xAD5B, 0x8283,\r\n\t0xAD5C, 0x8284, 0xAD5D, 0x8285, 0xAD5E, 0x8286, 0xAD5F, 0x8287,\t0xAD60, 0x8288, 0xAD61, 0xB1B6, 0xAD62, 0x8289, 0xAD63, 0xB1B7,\r\n\t0xAD64, 0x828A, 0xAD65, 0x828B, 0xAD66, 0x828C, 0xAD67, 0x828D,\t0xAD68, 0x828E, 0xAD69, 0x828F, 0xAD6A, 0x8290, 0xAD6B, 0x8291,\r\n\t0xAD6C, 0xB1B8, 0xAD6D, 0xB1B9, 0xAD6E, 0x8292, 0xAD6F, 0x8293,\t0xAD70, 0xB1BA, 0xAD71, 0x8294, 0xAD72, 0x8295, 0xAD73, 0xB1BB,\r\n\t0xAD74, 0xB1BC, 0xAD75, 0xB1BD, 0xAD76, 0xB1BE, 0xAD77, 0x8296,\t0xAD78, 0x8297, 0xAD79, 0x8298, 0xAD7A, 0x8299, 0xAD7B, 0xB1BF,\r\n\t0xAD7C, 0xB1C0, 0xAD7D, 0xB1C1, 0xAD7E, 0x829A, 0xAD7F, 0xB1C2,\t0xAD80, 0x829B, 0xAD81, 0xB1C3, 0xAD82, 0xB1C4, 0xAD83, 0x829C,\r\n\t0xAD84, 0x829D, 0xAD85, 0x829E, 0xAD86, 0x829F, 0xAD87, 0x82A0,\t0xAD88, 0xB1C5, 0xAD89, 0xB1C6, 0xAD8A, 0x82A1, 0xAD8B, 0x82A2,\r\n\t0xAD8C, 0xB1C7, 0xAD8D, 0x82A3, 0xAD8E, 0x82A4, 0xAD8F, 0x82A5,\t0xAD90, 0xB1C8, 0xAD91, 0x82A6, 0xAD92, 0x82A7, 0xAD93, 0x82A8,\r\n\t0xAD94, 0x82A9, 0xAD95, 0x82AA, 0xAD96, 0x82AB, 0xAD97, 0x82AC,\t0xAD98, 0x82AD, 0xAD99, 0x82AE, 0xAD9A, 0x82AF, 0xAD9B, 0x82B0,\r\n\t0xAD9C, 0xB1C9, 0xAD9D, 0xB1CA, 0xAD9E, 0x82B1, 0xAD9F, 0x82B2,\t0xADA0, 0x82B3, 0xADA1, 0x82B4, 0xADA2, 0x82B5, 0xADA3, 0x82B6,\r\n\t0xADA4, 0xB1CB, 0xADA5, 0x82B7, 0xADA6, 0x82B8, 0xADA7, 0x82B9,\t0xADA8, 0x82BA, 0xADA9, 0x82BB, 0xADAA, 0x82BC, 0xADAB, 0x82BD,\r\n\t0xADAC, 0x82BE, 0xADAD, 0x82BF, 0xADAE, 0x82C0, 0xADAF, 0x82C1,\t0xADB0, 0x82C2, 0xADB1, 0x82C3, 0xADB2, 0x82C4, 0xADB3, 0x82C5,\r\n\t0xADB4, 0x82C6, 0xADB5, 0x82C7, 0xADB6, 0x82C8, 0xADB7, 0xB1CC,\t0xADB8, 0x82C9, 0xADB9, 0x82CA, 0xADBA, 0x82CB, 0xADBB, 0x82CC,\r\n\t0xADBC, 0x82CD, 0xADBD, 0x82CE, 0xADBE, 0x82CF, 0xADBF, 0x82D0,\t0xADC0, 0xB1CD, 0xADC1, 0xB1CE, 0xADC2, 0x82D1, 0xADC3, 0x82D2,\r\n\t0xADC4, 0xB1CF, 0xADC5, 0x82D3, 0xADC6, 0x82D4, 0xADC7, 0x82D5,\t0xADC8, 0xB1D0, 0xADC9, 0x82D6, 0xADCA, 0x82D7, 0xADCB, 0x82D8,\r\n\t0xADCC, 0x82D9, 0xADCD, 0x82DA, 0xADCE, 0x82DB, 0xADCF, 0x82DC,\t0xADD0, 0xB1D1, 0xADD1, 0xB1D2, 0xADD2, 0x82DD, 0xADD3, 0xB1D3,\r\n\t0xADD4, 0x82DE, 0xADD5, 0x82DF, 0xADD6, 0x82E0, 0xADD7, 0x82E1,\t0xADD8, 0x82E2, 0xADD9, 0x82E3, 0xADDA, 0x82E4, 0xADDB, 0x82E5,\r\n\t0xADDC, 0xB1D4, 0xADDD, 0x82E6, 0xADDE, 0x82E7, 0xADDF, 0x82E8,\t0xADE0, 0xB1D5, 0xADE1, 0x82E9, 0xADE2, 0x82EA, 0xADE3, 0x82EB,\r\n\t0xADE4, 0xB1D6, 0xADE5, 0x82EC, 0xADE6, 0x82ED, 0xADE7, 0x82EE,\t0xADE8, 0x82EF, 0xADE9, 0x82F0, 0xADEA, 0x82F1, 0xADEB, 0x82F2,\r\n\t0xADEC, 0x82F3, 0xADED, 0x82F4, 0xADEE, 0x82F5, 0xADEF, 0x82F6,\t0xADF0, 0x82F7, 0xADF1, 0x82F8, 0xADF2, 0x82F9, 0xADF3, 0x82FA,\r\n\t0xADF4, 0x82FB, 0xADF5, 0x82FC, 0xADF6, 0x82FD, 0xADF7, 0x82FE,\t0xADF8, 0xB1D7, 0xADF9, 0xB1D8, 0xADFA, 0x8341, 0xADFB, 0x8342,\r\n\t0xADFC, 0xB1D9, 0xADFD, 0x8343, 0xADFE, 0x8344, 0xADFF, 0xB1DA,\t0xAE00, 0xB1DB, 0xAE01, 0xB1DC, 0xAE02, 0x8345, 0xAE03, 0x8346,\r\n\t0xAE04, 0x8347, 0xAE05, 0x8348, 0xAE06, 0x8349, 0xAE07, 0x834A,\t0xAE08, 0xB1DD, 0xAE09, 0xB1DE, 0xAE0A, 0x834B, 0xAE0B, 0xB1DF,\r\n\t0xAE0C, 0x834C, 0xAE0D, 0xB1E0, 0xAE0E, 0x834D, 0xAE0F, 0x834E,\t0xAE10, 0x834F, 0xAE11, 0x8350, 0xAE12, 0x8351, 0xAE13, 0x8352,\r\n\t0xAE14, 0xB1E1, 0xAE15, 0x8353, 0xAE16, 0x8354, 0xAE17, 0x8355,\t0xAE18, 0x8356, 0xAE19, 0x8357, 0xAE1A, 0x8358, 0xAE1B, 0x8359,\r\n\t0xAE1C, 0x835A, 0xAE1D, 0x8361, 0xAE1E, 0x8362, 0xAE1F, 0x8363,\t0xAE20, 0x8364, 0xAE21, 0x8365, 0xAE22, 0x8366, 0xAE23, 0x8367,\r\n\t0xAE24, 0x8368, 0xAE25, 0x8369, 0xAE26, 0x836A, 0xAE27, 0x836B,\t0xAE28, 0x836C, 0xAE29, 0x836D, 0xAE2A, 0x836E, 0xAE2B, 0x836F,\r\n\t0xAE2C, 0x8370, 0xAE2D, 0x8371, 0xAE2E, 0x8372, 0xAE2F, 0x8373,\t0xAE30, 0xB1E2, 0xAE31, 0xB1E3, 0xAE32, 0x8374, 0xAE33, 0x8375,\r\n\t0xAE34, 0xB1E4, 0xAE35, 0x8376, 0xAE36, 0x8377, 0xAE37, 0xB1E5,\t0xAE38, 0xB1E6, 0xAE39, 0x8378, 0xAE3A, 0xB1E7, 0xAE3B, 0x8379,\r\n\t0xAE3C, 0x837A, 0xAE3D, 0x8381, 0xAE3E, 0x8382, 0xAE3F, 0x8383,\t0xAE40, 0xB1E8, 0xAE41, 0xB1E9, 0xAE42, 0x8384, 0xAE43, 0xB1EA,\r\n\t0xAE44, 0x8385, 0xAE45, 0xB1EB, 0xAE46, 0xB1EC, 0xAE47, 0x8386,\t0xAE48, 0x8387, 0xAE49, 0x8388, 0xAE4A, 0xB1ED, 0xAE4B, 0x8389,\r\n\t0xAE4C, 0xB1EE, 0xAE4D, 0xB1EF, 0xAE4E, 0xB1F0, 0xAE4F, 0x838A,\t0xAE50, 0xB1F1, 0xAE51, 0x838B, 0xAE52, 0x838C, 0xAE53, 0x838D,\r\n\t0xAE54, 0xB1F2, 0xAE55, 0x838E, 0xAE56, 0xB1F3, 0xAE57, 0x838F,\t0xAE58, 0x8390, 0xAE59, 0x8391, 0xAE5A, 0x8392, 0xAE5B, 0x8393,\r\n\t0xAE5C, 0xB1F4, 0xAE5D, 0xB1F5, 0xAE5E, 0x8394, 0xAE5F, 0xB1F6,\t0xAE60, 0xB1F7, 0xAE61, 0xB1F8, 0xAE62, 0x8395, 0xAE63, 0x8396,\r\n\t0xAE64, 0x8397, 0xAE65, 0xB1F9, 0xAE66, 0x8398, 0xAE67, 0x8399,\t0xAE68, 0xB1FA, 0xAE69, 0xB1FB, 0xAE6A, 0x839A, 0xAE6B, 0x839B,\r\n\t0xAE6C, 0xB1FC, 0xAE6D, 0x839C, 0xAE6E, 0x839D, 0xAE6F, 0x839E,\t0xAE70, 0xB1FD, 0xAE71, 0x839F, 0xAE72, 0x83A0, 0xAE73, 0x83A1,\r\n\t0xAE74, 0x83A2, 0xAE75, 0x83A3, 0xAE76, 0x83A4, 0xAE77, 0x83A5,\t0xAE78, 0xB1FE, 0xAE79, 0xB2A1, 0xAE7A, 0x83A6, 0xAE7B, 0xB2A2,\r\n\t0xAE7C, 0xB2A3, 0xAE7D, 0xB2A4, 0xAE7E, 0x83A7, 0xAE7F, 0x83A8,\t0xAE80, 0x83A9, 0xAE81, 0x83AA, 0xAE82, 0x83AB, 0xAE83, 0x83AC,\r\n\t0xAE84, 0xB2A5, 0xAE85, 0xB2A6, 0xAE86, 0x83AD, 0xAE87, 0x83AE,\t0xAE88, 0x83AF, 0xAE89, 0x83B0, 0xAE8A, 0x83B1, 0xAE8B, 0x83B2,\r\n\t0xAE8C, 0xB2A7, 0xAE8D, 0x83B3, 0xAE8E, 0x83B4, 0xAE8F, 0x83B5,\t0xAE90, 0x83B6, 0xAE91, 0x83B7, 0xAE92, 0x83B8, 0xAE93, 0x83B9,\r\n\t0xAE94, 0x83BA, 0xAE95, 0x83BB, 0xAE96, 0x83BC, 0xAE97, 0x83BD,\t0xAE98, 0x83BE, 0xAE99, 0x83BF, 0xAE9A, 0x83C0, 0xAE9B, 0x83C1,\r\n\t0xAE9C, 0x83C2, 0xAE9D, 0x83C3, 0xAE9E, 0x83C4, 0xAE9F, 0x83C5,\t0xAEA0, 0x83C6, 0xAEA1, 0x83C7, 0xAEA2, 0x83C8, 0xAEA3, 0x83C9,\r\n\t0xAEA4, 0x83CA, 0xAEA5, 0x83CB, 0xAEA6, 0x83CC, 0xAEA7, 0x83CD,\t0xAEA8, 0x83CE, 0xAEA9, 0x83CF, 0xAEAA, 0x83D0, 0xAEAB, 0x83D1,\r\n\t0xAEAC, 0x83D2, 0xAEAD, 0x83D3, 0xAEAE, 0x83D4, 0xAEAF, 0x83D5,\t0xAEB0, 0x83D6, 0xAEB1, 0x83D7, 0xAEB2, 0x83D8, 0xAEB3, 0x83D9,\r\n\t0xAEB4, 0x83DA, 0xAEB5, 0x83DB, 0xAEB6, 0x83DC, 0xAEB7, 0x83DD,\t0xAEB8, 0x83DE, 0xAEB9, 0x83DF, 0xAEBA, 0x83E0, 0xAEBB, 0x83E1,\r\n\t0xAEBC, 0xB2A8, 0xAEBD, 0xB2A9, 0xAEBE, 0xB2AA, 0xAEBF, 0x83E2,\t0xAEC0, 0xB2AB, 0xAEC1, 0x83E3, 0xAEC2, 0x83E4, 0xAEC3, 0x83E5,\r\n\t0xAEC4, 0xB2AC, 0xAEC5, 0x83E6, 0xAEC6, 0x83E7, 0xAEC7, 0x83E8,\t0xAEC8, 0x83E9, 0xAEC9, 0x83EA, 0xAECA, 0x83EB, 0xAECB, 0x83EC,\r\n\t0xAECC, 0xB2AD, 0xAECD, 0xB2AE, 0xAECE, 0x83ED, 0xAECF, 0xB2AF,\t0xAED0, 0xB2B0, 0xAED1, 0xB2B1, 0xAED2, 0x83EE, 0xAED3, 0x83EF,\r\n\t0xAED4, 0x83F0, 0xAED5, 0x83F1, 0xAED6, 0x83F2, 0xAED7, 0x83F3,\t0xAED8, 0xB2B2, 0xAED9, 0xB2B3, 0xAEDA, 0x83F4, 0xAEDB, 0x83F5,\r\n\t0xAEDC, 0xB2B4, 0xAEDD, 0x83F6, 0xAEDE, 0x83F7, 0xAEDF, 0x83F8,\t0xAEE0, 0x83F9, 0xAEE1, 0x83FA, 0xAEE2, 0x83FB, 0xAEE3, 0x83FC,\r\n\t0xAEE4, 0x83FD, 0xAEE5, 0x83FE, 0xAEE6, 0x8441, 0xAEE7, 0x8442,\t0xAEE8, 0xB2B5, 0xAEE9, 0x8443, 0xAEEA, 0x8444, 0xAEEB, 0xB2B6,\r\n\t0xAEEC, 0x8445, 0xAEED, 0xB2B7, 0xAEEE, 0x8446, 0xAEEF, 0x8447,\t0xAEF0, 0x8448, 0xAEF1, 0x8449, 0xAEF2, 0x844A, 0xAEF3, 0x844B,\r\n\t0xAEF4, 0xB2B8, 0xAEF5, 0x844C, 0xAEF6, 0x844D, 0xAEF7, 0x844E,\t0xAEF8, 0xB2B9, 0xAEF9, 0x844F, 0xAEFA, 0x8450, 0xAEFB, 0x8451,\r\n\t0xAEFC, 0xB2BA, 0xAEFD, 0x8452, 0xAEFE, 0x8453, 0xAEFF, 0x8454,\t0xAF00, 0x8455, 0xAF01, 0x8456, 0xAF02, 0x8457, 0xAF03, 0x8458,\r\n\t0xAF04, 0x8459, 0xAF05, 0x845A, 0xAF06, 0x8461, 0xAF07, 0xB2BB,\t0xAF08, 0xB2BC, 0xAF09, 0x8462, 0xAF0A, 0x8463, 0xAF0B, 0x8464,\r\n\t0xAF0C, 0x8465, 0xAF0D, 0xB2BD, 0xAF0E, 0x8466, 0xAF0F, 0x8467,\t0xAF10, 0xB2BE, 0xAF11, 0x8468, 0xAF12, 0x8469, 0xAF13, 0x846A,\r\n\t0xAF14, 0x846B, 0xAF15, 0x846C, 0xAF16, 0x846D, 0xAF17, 0x846E,\t0xAF18, 0x846F, 0xAF19, 0x8470, 0xAF1A, 0x8471, 0xAF1B, 0x8472,\r\n\t0xAF1C, 0x8473, 0xAF1D, 0x8474, 0xAF1E, 0x8475, 0xAF1F, 0x8476,\t0xAF20, 0x8477, 0xAF21, 0x8478, 0xAF22, 0x8479, 0xAF23, 0x847A,\r\n\t0xAF24, 0x8481, 0xAF25, 0x8482, 0xAF26, 0x8483, 0xAF27, 0x8484,\t0xAF28, 0x8485, 0xAF29, 0x8486, 0xAF2A, 0x8487, 0xAF2B, 0x8488,\r\n\t0xAF2C, 0xB2BF, 0xAF2D, 0xB2C0, 0xAF2E, 0x8489, 0xAF2F, 0x848A,\t0xAF30, 0xB2C1, 0xAF31, 0x848B, 0xAF32, 0xB2C2, 0xAF33, 0x848C,\r\n\t0xAF34, 0xB2C3, 0xAF35, 0x848D, 0xAF36, 0x848E, 0xAF37, 0x848F,\t0xAF38, 0x8490, 0xAF39, 0x8491, 0xAF3A, 0x8492, 0xAF3B, 0x8493,\r\n\t0xAF3C, 0xB2C4, 0xAF3D, 0xB2C5, 0xAF3E, 0x8494, 0xAF3F, 0xB2C6,\t0xAF40, 0x8495, 0xAF41, 0xB2C7, 0xAF42, 0xB2C8, 0xAF43, 0xB2C9,\r\n\t0xAF44, 0x8496, 0xAF45, 0x8497, 0xAF46, 0x8498, 0xAF47, 0x8499,\t0xAF48, 0xB2CA, 0xAF49, 0xB2CB, 0xAF4A, 0x849A, 0xAF4B, 0x849B,\r\n\t0xAF4C, 0x849C, 0xAF4D, 0x849D, 0xAF4E, 0x849E, 0xAF4F, 0x849F,\t0xAF50, 0xB2CC, 0xAF51, 0x84A0, 0xAF52, 0x84A1, 0xAF53, 0x84A2,\r\n\t0xAF54, 0x84A3, 0xAF55, 0x84A4, 0xAF56, 0x84A5, 0xAF57, 0x84A6,\t0xAF58, 0x84A7, 0xAF59, 0x84A8, 0xAF5A, 0x84A9, 0xAF5B, 0x84AA,\r\n\t0xAF5C, 0xB2CD, 0xAF5D, 0xB2CE, 0xAF5E, 0x84AB, 0xAF5F, 0x84AC,\t0xAF60, 0x84AD, 0xAF61, 0x84AE, 0xAF62, 0x84AF, 0xAF63, 0x84B0,\r\n\t0xAF64, 0xB2CF, 0xAF65, 0xB2D0, 0xAF66, 0x84B1, 0xAF67, 0x84B2,\t0xAF68, 0x84B3, 0xAF69, 0x84B4, 0xAF6A, 0x84B5, 0xAF6B, 0x84B6,\r\n\t0xAF6C, 0x84B7, 0xAF6D, 0x84B8, 0xAF6E, 0x84B9, 0xAF6F, 0x84BA,\t0xAF70, 0x84BB, 0xAF71, 0x84BC, 0xAF72, 0x84BD, 0xAF73, 0x84BE,\r\n\t0xAF74, 0x84BF, 0xAF75, 0x84C0, 0xAF76, 0x84C1, 0xAF77, 0x84C2,\t0xAF78, 0x84C3, 0xAF79, 0xB2D1, 0xAF7A, 0x84C4, 0xAF7B, 0x84C5,\r\n\t0xAF7C, 0x84C6, 0xAF7D, 0x84C7, 0xAF7E, 0x84C8, 0xAF7F, 0x84C9,\t0xAF80, 0xB2D2, 0xAF81, 0x84CA, 0xAF82, 0x84CB, 0xAF83, 0x84CC,\r\n\t0xAF84, 0xB2D3, 0xAF85, 0x84CD, 0xAF86, 0x84CE, 0xAF87, 0x84CF,\t0xAF88, 0xB2D4, 0xAF89, 0x84D0, 0xAF8A, 0x84D1, 0xAF8B, 0x84D2,\r\n\t0xAF8C, 0x84D3, 0xAF8D, 0x84D4, 0xAF8E, 0x84D5, 0xAF8F, 0x84D6,\t0xAF90, 0xB2D5, 0xAF91, 0xB2D6, 0xAF92, 0x84D7, 0xAF93, 0x84D8,\r\n\t0xAF94, 0x84D9, 0xAF95, 0xB2D7, 0xAF96, 0x84DA, 0xAF97, 0x84DB,\t0xAF98, 0x84DC, 0xAF99, 0x84DD, 0xAF9A, 0x84DE, 0xAF9B, 0x84DF,\r\n\t0xAF9C, 0xB2D8, 0xAF9D, 0x84E0, 0xAF9E, 0x84E1, 0xAF9F, 0x84E2,\t0xAFA0, 0x84E3, 0xAFA1, 0x84E4, 0xAFA2, 0x84E5, 0xAFA3, 0x84E6,\r\n\t0xAFA4, 0x84E7, 0xAFA5, 0x84E8, 0xAFA6, 0x84E9, 0xAFA7, 0x84EA,\t0xAFA8, 0x84EB, 0xAFA9, 0x84EC, 0xAFAA, 0x84ED, 0xAFAB, 0x84EE,\r\n\t0xAFAC, 0x84EF, 0xAFAD, 0x84F0, 0xAFAE, 0x84F1, 0xAFAF, 0x84F2,\t0xAFB0, 0x84F3, 0xAFB1, 0x84F4, 0xAFB2, 0x84F5, 0xAFB3, 0x84F6,\r\n\t0xAFB4, 0x84F7, 0xAFB5, 0x84F8, 0xAFB6, 0x84F9, 0xAFB7, 0x84FA,\t0xAFB8, 0xB2D9, 0xAFB9, 0xB2DA, 0xAFBA, 0x84FB, 0xAFBB, 0x84FC,\r\n\t0xAFBC, 0xB2DB, 0xAFBD, 0x84FD, 0xAFBE, 0x84FE, 0xAFBF, 0x8541,\t0xAFC0, 0xB2DC, 0xAFC1, 0x8542, 0xAFC2, 0x8543, 0xAFC3, 0x8544,\r\n\t0xAFC4, 0x8545, 0xAFC5, 0x8546, 0xAFC6, 0x8547, 0xAFC7, 0xB2DD,\t0xAFC8, 0xB2DE, 0xAFC9, 0xB2DF, 0xAFCA, 0x8548, 0xAFCB, 0xB2E0,\r\n\t0xAFCC, 0x8549, 0xAFCD, 0xB2E1, 0xAFCE, 0xB2E2, 0xAFCF, 0x854A,\t0xAFD0, 0x854B, 0xAFD1, 0x854C, 0xAFD2, 0x854D, 0xAFD3, 0x854E,\r\n\t0xAFD4, 0xB2E3, 0xAFD5, 0x854F, 0xAFD6, 0x8550, 0xAFD7, 0x8551,\t0xAFD8, 0x8552, 0xAFD9, 0x8553, 0xAFDA, 0x8554, 0xAFDB, 0x8555,\r\n\t0xAFDC, 0xB2E4, 0xAFDD, 0x8556, 0xAFDE, 0x8557, 0xAFDF, 0x8558,\t0xAFE0, 0x8559, 0xAFE1, 0x855A, 0xAFE2, 0x8561, 0xAFE3, 0x8562,\r\n\t0xAFE4, 0x8563, 0xAFE5, 0x8564, 0xAFE6, 0x8565, 0xAFE7, 0x8566,\t0xAFE8, 0xB2E5, 0xAFE9, 0xB2E6, 0xAFEA, 0x8567, 0xAFEB, 0x8568,\r\n\t0xAFEC, 0x8569, 0xAFED, 0x856A, 0xAFEE, 0x856B, 0xAFEF, 0x856C,\t0xAFF0, 0xB2E7, 0xAFF1, 0xB2E8, 0xAFF2, 0x856D, 0xAFF3, 0x856E,\r\n\t0xAFF4, 0xB2E9, 0xAFF5, 0x856F, 0xAFF6, 0x8570, 0xAFF7, 0x8571,\t0xAFF8, 0xB2EA, 0xAFF9, 0x8572, 0xAFFA, 0x8573, 0xAFFB, 0x8574,\r\n\t0xAFFC, 0x8575, 0xAFFD, 0x8576, 0xAFFE, 0x8577, 0xAFFF, 0x8578,\t0xB000, 0xB2EB, 0xB001, 0xB2EC, 0xB002, 0x8579, 0xB003, 0x857A,\r\n\t0xB004, 0xB2ED, 0xB005, 0x8581, 0xB006, 0x8582, 0xB007, 0x8583,\t0xB008, 0x8584, 0xB009, 0x8585, 0xB00A, 0x8586, 0xB00B, 0x8587,\r\n\t0xB00C, 0xB2EE, 0xB00D, 0x8588, 0xB00E, 0x8589, 0xB00F, 0x858A,\t0xB010, 0xB2EF, 0xB011, 0x858B, 0xB012, 0x858C, 0xB013, 0x858D,\r\n\t0xB014, 0xB2F0, 0xB015, 0x858E, 0xB016, 0x858F, 0xB017, 0x8590,\t0xB018, 0x8591, 0xB019, 0x8592, 0xB01A, 0x8593, 0xB01B, 0x8594,\r\n\t0xB01C, 0xB2F1, 0xB01D, 0xB2F2, 0xB01E, 0x8595, 0xB01F, 0x8596,\t0xB020, 0x8597, 0xB021, 0x8598, 0xB022, 0x8599, 0xB023, 0x859A,\r\n\t0xB024, 0x859B, 0xB025, 0x859C, 0xB026, 0x859D, 0xB027, 0x859E,\t0xB028, 0xB2F3, 0xB029, 0x859F, 0xB02A, 0x85A0, 0xB02B, 0x85A1,\r\n\t0xB02C, 0x85A2, 0xB02D, 0x85A3, 0xB02E, 0x85A4, 0xB02F, 0x85A5,\t0xB030, 0x85A6, 0xB031, 0x85A7, 0xB032, 0x85A8, 0xB033, 0x85A9,\r\n\t0xB034, 0x85AA, 0xB035, 0x85AB, 0xB036, 0x85AC, 0xB037, 0x85AD,\t0xB038, 0x85AE, 0xB039, 0x85AF, 0xB03A, 0x85B0, 0xB03B, 0x85B1,\r\n\t0xB03C, 0x85B2, 0xB03D, 0x85B3, 0xB03E, 0x85B4, 0xB03F, 0x85B5,\t0xB040, 0x85B6, 0xB041, 0x85B7, 0xB042, 0x85B8, 0xB043, 0x85B9,\r\n\t0xB044, 0xB2F4, 0xB045, 0xB2F5, 0xB046, 0x85BA, 0xB047, 0x85BB,\t0xB048, 0xB2F6, 0xB049, 0x85BC, 0xB04A, 0xB2F7, 0xB04B, 0x85BD,\r\n\t0xB04C, 0xB2F8, 0xB04D, 0x85BE, 0xB04E, 0xB2F9, 0xB04F, 0x85BF,\t0xB050, 0x85C0, 0xB051, 0x85C1, 0xB052, 0x85C2, 0xB053, 0xB2FA,\r\n\t0xB054, 0xB2FB, 0xB055, 0xB2FC, 0xB056, 0x85C3, 0xB057, 0xB2FD,\t0xB058, 0x85C4, 0xB059, 0xB2FE, 0xB05A, 0x85C5, 0xB05B, 0x85C6,\r\n\t0xB05C, 0x85C7, 0xB05D, 0xB3A1, 0xB05E, 0x85C8, 0xB05F, 0x85C9,\t0xB060, 0x85CA, 0xB061, 0x85CB, 0xB062, 0x85CC, 0xB063, 0x85CD,\r\n\t0xB064, 0x85CE, 0xB065, 0x85CF, 0xB066, 0x85D0, 0xB067, 0x85D1,\t0xB068, 0x85D2, 0xB069, 0x85D3, 0xB06A, 0x85D4, 0xB06B, 0x85D5,\r\n\t0xB06C, 0x85D6, 0xB06D, 0x85D7, 0xB06E, 0x85D8, 0xB06F, 0x85D9,\t0xB070, 0x85DA, 0xB071, 0x85DB, 0xB072, 0x85DC, 0xB073, 0x85DD,\r\n\t0xB074, 0x85DE, 0xB075, 0x85DF, 0xB076, 0x85E0, 0xB077, 0x85E1,\t0xB078, 0x85E2, 0xB079, 0x85E3, 0xB07A, 0x85E4, 0xB07B, 0x85E5,\r\n\t0xB07C, 0xB3A2, 0xB07D, 0xB3A3, 0xB07E, 0x85E6, 0xB07F, 0x85E7,\t0xB080, 0xB3A4, 0xB081, 0x85E8, 0xB082, 0x85E9, 0xB083, 0x85EA,\r\n\t0xB084, 0xB3A5, 0xB085, 0x85EB, 0xB086, 0x85EC, 0xB087, 0x85ED,\t0xB088, 0x85EE, 0xB089, 0x85EF, 0xB08A, 0x85F0, 0xB08B, 0x85F1,\r\n\t0xB08C, 0xB3A6, 0xB08D, 0xB3A7, 0xB08E, 0x85F2, 0xB08F, 0xB3A8,\t0xB090, 0x85F3, 0xB091, 0xB3A9, 0xB092, 0x85F4, 0xB093, 0x85F5,\r\n\t0xB094, 0x85F6, 0xB095, 0x85F7, 0xB096, 0x85F8, 0xB097, 0x85F9,\t0xB098, 0xB3AA, 0xB099, 0xB3AB, 0xB09A, 0xB3AC, 0xB09B, 0x85FA,\r\n\t0xB09C, 0xB3AD, 0xB09D, 0x85FB, 0xB09E, 0x85FC, 0xB09F, 0xB3AE,\t0xB0A0, 0xB3AF, 0xB0A1, 0xB3B0, 0xB0A2, 0xB3B1, 0xB0A3, 0x85FD,\r\n\t0xB0A4, 0x85FE, 0xB0A5, 0x8641, 0xB0A6, 0x8642, 0xB0A7, 0x8643,\t0xB0A8, 0xB3B2, 0xB0A9, 0xB3B3, 0xB0AA, 0x8644, 0xB0AB, 0xB3B4,\r\n\t0xB0AC, 0xB3B5, 0xB0AD, 0xB3B6, 0xB0AE, 0xB3B7, 0xB0AF, 0xB3B8,\t0xB0B0, 0x8645, 0xB0B1, 0xB3B9, 0xB0B2, 0x8646, 0xB0B3, 0xB3BA,\r\n\t0xB0B4, 0xB3BB, 0xB0B5, 0xB3BC, 0xB0B6, 0x8647, 0xB0B7, 0x8648,\t0xB0B8, 0xB3BD, 0xB0B9, 0x8649, 0xB0BA, 0x864A, 0xB0BB, 0x864B,\r\n\t0xB0BC, 0xB3BE, 0xB0BD, 0x864C, 0xB0BE, 0x864D, 0xB0BF, 0x864E,\t0xB0C0, 0x864F, 0xB0C1, 0x8650, 0xB0C2, 0x8651, 0xB0C3, 0x8652,\r\n\t0xB0C4, 0xB3BF, 0xB0C5, 0xB3C0, 0xB0C6, 0x8653, 0xB0C7, 0xB3C1,\t0xB0C8, 0xB3C2, 0xB0C9, 0xB3C3, 0xB0CA, 0x8654, 0xB0CB, 0x8655,\r\n\t0xB0CC, 0x8656, 0xB0CD, 0x8657, 0xB0CE, 0x8658, 0xB0CF, 0x8659,\t0xB0D0, 0xB3C4, 0xB0D1, 0xB3C5, 0xB0D2, 0x865A, 0xB0D3, 0x8661,\r\n\t0xB0D4, 0xB3C6, 0xB0D5, 0x8662, 0xB0D6, 0x8663, 0xB0D7, 0x8664,\t0xB0D8, 0xB3C7, 0xB0D9, 0x8665, 0xB0DA, 0x8666, 0xB0DB, 0x8667,\r\n\t0xB0DC, 0x8668, 0xB0DD, 0x8669, 0xB0DE, 0x866A, 0xB0DF, 0x866B,\t0xB0E0, 0xB3C8, 0xB0E1, 0x866C, 0xB0E2, 0x866D, 0xB0E3, 0x866E,\r\n\t0xB0E4, 0x866F, 0xB0E5, 0xB3C9, 0xB0E6, 0x8670, 0xB0E7, 0x8671,\t0xB0E8, 0x8672, 0xB0E9, 0x8673, 0xB0EA, 0x8674, 0xB0EB, 0x8675,\r\n\t0xB0EC, 0x8676, 0xB0ED, 0x8677, 0xB0EE, 0x8678, 0xB0EF, 0x8679,\t0xB0F0, 0x867A, 0xB0F1, 0x8681, 0xB0F2, 0x8682, 0xB0F3, 0x8683,\r\n\t0xB0F4, 0x8684, 0xB0F5, 0x8685, 0xB0F6, 0x8686, 0xB0F7, 0x8687,\t0xB0F8, 0x8688, 0xB0F9, 0x8689, 0xB0FA, 0x868A, 0xB0FB, 0x868B,\r\n\t0xB0FC, 0x868C, 0xB0FD, 0x868D, 0xB0FE, 0x868E, 0xB0FF, 0x868F,\t0xB100, 0x8690, 0xB101, 0x8691, 0xB102, 0x8692, 0xB103, 0x8693,\r\n\t0xB104, 0x8694, 0xB105, 0x8695, 0xB106, 0x8696, 0xB107, 0x8697,\t0xB108, 0xB3CA, 0xB109, 0xB3CB, 0xB10A, 0x8698, 0xB10B, 0xB3CC,\r\n\t0xB10C, 0xB3CD, 0xB10D, 0x8699, 0xB10E, 0x869A, 0xB10F, 0x869B,\t0xB110, 0xB3CE, 0xB111, 0x869C, 0xB112, 0xB3CF, 0xB113, 0xB3D0,\r\n\t0xB114, 0x869D, 0xB115, 0x869E, 0xB116, 0x869F, 0xB117, 0x86A0,\t0xB118, 0xB3D1, 0xB119, 0xB3D2, 0xB11A, 0x86A1, 0xB11B, 0xB3D3,\r\n\t0xB11C, 0xB3D4, 0xB11D, 0xB3D5, 0xB11E, 0x86A2, 0xB11F, 0x86A3,\t0xB120, 0x86A4, 0xB121, 0x86A5, 0xB122, 0x86A6, 0xB123, 0xB3D6,\r\n\t0xB124, 0xB3D7, 0xB125, 0xB3D8, 0xB126, 0x86A7, 0xB127, 0x86A8,\t0xB128, 0xB3D9, 0xB129, 0x86A9, 0xB12A, 0x86AA, 0xB12B, 0x86AB,\r\n\t0xB12C, 0xB3DA, 0xB12D, 0x86AC, 0xB12E, 0x86AD, 0xB12F, 0x86AE,\t0xB130, 0x86AF, 0xB131, 0x86B0, 0xB132, 0x86B1, 0xB133, 0x86B2,\r\n\t0xB134, 0xB3DB, 0xB135, 0xB3DC, 0xB136, 0x86B3, 0xB137, 0xB3DD,\t0xB138, 0xB3DE, 0xB139, 0xB3DF, 0xB13A, 0x86B4, 0xB13B, 0x86B5,\r\n\t0xB13C, 0x86B6, 0xB13D, 0x86B7, 0xB13E, 0x86B8, 0xB13F, 0x86B9,\t0xB140, 0xB3E0, 0xB141, 0xB3E1, 0xB142, 0x86BA, 0xB143, 0x86BB,\r\n\t0xB144, 0xB3E2, 0xB145, 0x86BC, 0xB146, 0x86BD, 0xB147, 0x86BE,\t0xB148, 0xB3E3, 0xB149, 0x86BF, 0xB14A, 0x86C0, 0xB14B, 0x86C1,\r\n\t0xB14C, 0x86C2, 0xB14D, 0x86C3, 0xB14E, 0x86C4, 0xB14F, 0x86C5,\t0xB150, 0xB3E4, 0xB151, 0xB3E5, 0xB152, 0x86C6, 0xB153, 0x86C7,\r\n\t0xB154, 0xB3E6, 0xB155, 0xB3E7, 0xB156, 0x86C8, 0xB157, 0x86C9,\t0xB158, 0xB3E8, 0xB159, 0x86CA, 0xB15A, 0x86CB, 0xB15B, 0x86CC,\r\n\t0xB15C, 0xB3E9, 0xB15D, 0x86CD, 0xB15E, 0x86CE, 0xB15F, 0x86CF,\t0xB160, 0xB3EA, 0xB161, 0x86D0, 0xB162, 0x86D1, 0xB163, 0x86D2,\r\n\t0xB164, 0x86D3, 0xB165, 0x86D4, 0xB166, 0x86D5, 0xB167, 0x86D6,\t0xB168, 0x86D7, 0xB169, 0x86D8, 0xB16A, 0x86D9, 0xB16B, 0x86DA,\r\n\t0xB16C, 0x86DB, 0xB16D, 0x86DC, 0xB16E, 0x86DD, 0xB16F, 0x86DE,\t0xB170, 0x86DF, 0xB171, 0x86E0, 0xB172, 0x86E1, 0xB173, 0x86E2,\r\n\t0xB174, 0x86E3, 0xB175, 0x86E4, 0xB176, 0x86E5, 0xB177, 0x86E6,\t0xB178, 0xB3EB, 0xB179, 0xB3EC, 0xB17A, 0x86E7, 0xB17B, 0x86E8,\r\n\t0xB17C, 0xB3ED, 0xB17D, 0x86E9, 0xB17E, 0x86EA, 0xB17F, 0x86EB,\t0xB180, 0xB3EE, 0xB181, 0x86EC, 0xB182, 0xB3EF, 0xB183, 0x86ED,\r\n\t0xB184, 0x86EE, 0xB185, 0x86EF, 0xB186, 0x86F0, 0xB187, 0x86F1,\t0xB188, 0xB3F0, 0xB189, 0xB3F1, 0xB18A, 0x86F2, 0xB18B, 0xB3F2,\r\n\t0xB18C, 0x86F3, 0xB18D, 0xB3F3, 0xB18E, 0x86F4, 0xB18F, 0x86F5,\t0xB190, 0x86F6, 0xB191, 0x86F7, 0xB192, 0xB3F4, 0xB193, 0xB3F5,\r\n\t0xB194, 0xB3F6, 0xB195, 0x86F8, 0xB196, 0x86F9, 0xB197, 0x86FA,\t0xB198, 0xB3F7, 0xB199, 0x86FB, 0xB19A, 0x86FC, 0xB19B, 0x86FD,\r\n\t0xB19C, 0xB3F8, 0xB19D, 0x86FE, 0xB19E, 0x8741, 0xB19F, 0x8742,\t0xB1A0, 0x8743, 0xB1A1, 0x8744, 0xB1A2, 0x8745, 0xB1A3, 0x8746,\r\n\t0xB1A4, 0x8747, 0xB1A5, 0x8748, 0xB1A6, 0x8749, 0xB1A7, 0x874A,\t0xB1A8, 0xB3F9, 0xB1A9, 0x874B, 0xB1AA, 0x874C, 0xB1AB, 0x874D,\r\n\t0xB1AC, 0x874E, 0xB1AD, 0x874F, 0xB1AE, 0x8750, 0xB1AF, 0x8751,\t0xB1B0, 0x8752, 0xB1B1, 0x8753, 0xB1B2, 0x8754, 0xB1B3, 0x8755,\r\n\t0xB1B4, 0x8756, 0xB1B5, 0x8757, 0xB1B6, 0x8758, 0xB1B7, 0x8759,\t0xB1B8, 0x875A, 0xB1B9, 0x8761, 0xB1BA, 0x8762, 0xB1BB, 0x8763,\r\n\t0xB1BC, 0x8764, 0xB1BD, 0x8765, 0xB1BE, 0x8766, 0xB1BF, 0x8767,\t0xB1C0, 0x8768, 0xB1C1, 0x8769, 0xB1C2, 0x876A, 0xB1C3, 0x876B,\r\n\t0xB1C4, 0x876C, 0xB1C5, 0x876D, 0xB1C6, 0x876E, 0xB1C7, 0x876F,\t0xB1C8, 0x8770, 0xB1C9, 0x8771, 0xB1CA, 0x8772, 0xB1CB, 0x8773,\r\n\t0xB1CC, 0xB3FA, 0xB1CD, 0x8774, 0xB1CE, 0x8775, 0xB1CF, 0x8776,\t0xB1D0, 0xB3FB, 0xB1D1, 0x8777, 0xB1D2, 0x8778, 0xB1D3, 0x8779,\r\n\t0xB1D4, 0xB3FC, 0xB1D5, 0x877A, 0xB1D6, 0x8781, 0xB1D7, 0x8782,\t0xB1D8, 0x8783, 0xB1D9, 0x8784, 0xB1DA, 0x8785, 0xB1DB, 0x8786,\r\n\t0xB1DC, 0xB3FD, 0xB1DD, 0xB3FE, 0xB1DE, 0x8787, 0xB1DF, 0xB4A1,\t0xB1E0, 0x8788, 0xB1E1, 0x8789, 0xB1E2, 0x878A, 0xB1E3, 0x878B,\r\n\t0xB1E4, 0x878C, 0xB1E5, 0x878D, 0xB1E6, 0x878E, 0xB1E7, 0x878F,\t0xB1E8, 0xB4A2, 0xB1E9, 0xB4A3, 0xB1EA, 0x8790, 0xB1EB, 0x8791,\r\n\t0xB1EC, 0xB4A4, 0xB1ED, 0x8792, 0xB1EE, 0x8793, 0xB1EF, 0x8794,\t0xB1F0, 0xB4A5, 0xB1F1, 0x8795, 0xB1F2, 0x8796, 0xB1F3, 0x8797,\r\n\t0xB1F4, 0x8798, 0xB1F5, 0x8799, 0xB1F6, 0x879A, 0xB1F7, 0x879B,\t0xB1F8, 0x879C, 0xB1F9, 0xB4A6, 0xB1FA, 0x879D, 0xB1FB, 0xB4A7,\r\n\t0xB1FC, 0x879E, 0xB1FD, 0xB4A8, 0xB1FE, 0x879F, 0xB1FF, 0x87A0,\t0xB200, 0x87A1, 0xB201, 0x87A2, 0xB202, 0x87A3, 0xB203, 0x87A4,\r\n\t0xB204, 0xB4A9, 0xB205, 0xB4AA, 0xB206, 0x87A5, 0xB207, 0x87A6,\t0xB208, 0xB4AB, 0xB209, 0x87A7, 0xB20A, 0x87A8, 0xB20B, 0xB4AC,\r\n\t0xB20C, 0xB4AD, 0xB20D, 0x87A9, 0xB20E, 0x87AA, 0xB20F, 0x87AB,\t0xB210, 0x87AC, 0xB211, 0x87AD, 0xB212, 0x87AE, 0xB213, 0x87AF,\r\n\t0xB214, 0xB4AE, 0xB215, 0xB4AF, 0xB216, 0x87B0, 0xB217, 0xB4B0,\t0xB218, 0x87B1, 0xB219, 0xB4B1, 0xB21A, 0x87B2, 0xB21B, 0x87B3,\r\n\t0xB21C, 0x87B4, 0xB21D, 0x87B5, 0xB21E, 0x87B6, 0xB21F, 0x87B7,\t0xB220, 0xB4B2, 0xB221, 0x87B8, 0xB222, 0x87B9, 0xB223, 0x87BA,\r\n\t0xB224, 0x87BB, 0xB225, 0x87BC, 0xB226, 0x87BD, 0xB227, 0x87BE,\t0xB228, 0x87BF, 0xB229, 0x87C0, 0xB22A, 0x87C1, 0xB22B, 0x87C2,\r\n\t0xB22C, 0x87C3, 0xB22D, 0x87C4, 0xB22E, 0x87C5, 0xB22F, 0x87C6,\t0xB230, 0x87C7, 0xB231, 0x87C8, 0xB232, 0x87C9, 0xB233, 0x87CA,\r\n\t0xB234, 0xB4B3, 0xB235, 0x87CB, 0xB236, 0x87CC, 0xB237, 0x87CD,\t0xB238, 0x87CE, 0xB239, 0x87CF, 0xB23A, 0x87D0, 0xB23B, 0x87D1,\r\n\t0xB23C, 0xB4B4, 0xB23D, 0x87D2, 0xB23E, 0x87D3, 0xB23F, 0x87D4,\t0xB240, 0x87D5, 0xB241, 0x87D6, 0xB242, 0x87D7, 0xB243, 0x87D8,\r\n\t0xB244, 0x87D9, 0xB245, 0x87DA, 0xB246, 0x87DB, 0xB247, 0x87DC,\t0xB248, 0x87DD, 0xB249, 0x87DE, 0xB24A, 0x87DF, 0xB24B, 0x87E0,\r\n\t0xB24C, 0x87E1, 0xB24D, 0x87E2, 0xB24E, 0x87E3, 0xB24F, 0x87E4,\t0xB250, 0x87E5, 0xB251, 0x87E6, 0xB252, 0x87E7, 0xB253, 0x87E8,\r\n\t0xB254, 0x87E9, 0xB255, 0x87EA, 0xB256, 0x87EB, 0xB257, 0x87EC,\t0xB258, 0xB4B5, 0xB259, 0x87ED, 0xB25A, 0x87EE, 0xB25B, 0x87EF,\r\n\t0xB25C, 0xB4B6, 0xB25D, 0x87F0, 0xB25E, 0x87F1, 0xB25F, 0x87F2,\t0xB260, 0xB4B7, 0xB261, 0x87F3, 0xB262, 0x87F4, 0xB263, 0x87F5,\r\n\t0xB264, 0x87F6, 0xB265, 0x87F7, 0xB266, 0x87F8, 0xB267, 0x87F9,\t0xB268, 0xB4B8, 0xB269, 0xB4B9, 0xB26A, 0x87FA, 0xB26B, 0x87FB,\r\n\t0xB26C, 0x87FC, 0xB26D, 0x87FD, 0xB26E, 0x87FE, 0xB26F, 0x8841,\t0xB270, 0x8842, 0xB271, 0x8843, 0xB272, 0x8844, 0xB273, 0x8845,\r\n\t0xB274, 0xB4BA, 0xB275, 0xB4BB, 0xB276, 0x8846, 0xB277, 0x8847,\t0xB278, 0x8848, 0xB279, 0x8849, 0xB27A, 0x884A, 0xB27B, 0x884B,\r\n\t0xB27C, 0xB4BC, 0xB27D, 0x884C, 0xB27E, 0x884D, 0xB27F, 0x884E,\t0xB280, 0x884F, 0xB281, 0x8850, 0xB282, 0x8851, 0xB283, 0x8852,\r\n\t0xB284, 0xB4BD, 0xB285, 0xB4BE, 0xB286, 0x8853, 0xB287, 0x8854,\t0xB288, 0x8855, 0xB289, 0xB4BF, 0xB28A, 0x8856, 0xB28B, 0x8857,\r\n\t0xB28C, 0x8858, 0xB28D, 0x8859, 0xB28E, 0x885A, 0xB28F, 0x8861,\t0xB290, 0xB4C0, 0xB291, 0xB4C1, 0xB292, 0x8862, 0xB293, 0x8863,\r\n\t0xB294, 0xB4C2, 0xB295, 0x8864, 0xB296, 0x8865, 0xB297, 0x8866,\t0xB298, 0xB4C3, 0xB299, 0xB4C4, 0xB29A, 0xB4C5, 0xB29B, 0x8867,\r\n\t0xB29C, 0x8868, 0xB29D, 0x8869, 0xB29E, 0x886A, 0xB29F, 0x886B,\t0xB2A0, 0xB4C6, 0xB2A1, 0xB4C7, 0xB2A2, 0x886C, 0xB2A3, 0xB4C8,\r\n\t0xB2A4, 0x886D, 0xB2A5, 0xB4C9, 0xB2A6, 0xB4CA, 0xB2A7, 0x886E,\t0xB2A8, 0x886F, 0xB2A9, 0x8870, 0xB2AA, 0xB4CB, 0xB2AB, 0x8871,\r\n\t0xB2AC, 0xB4CC, 0xB2AD, 0x8872, 0xB2AE, 0x8873, 0xB2AF, 0x8874,\t0xB2B0, 0xB4CD, 0xB2B1, 0x8875, 0xB2B2, 0x8876, 0xB2B3, 0x8877,\r\n\t0xB2B4, 0xB4CE, 0xB2B5, 0x8878, 0xB2B6, 0x8879, 0xB2B7, 0x887A,\t0xB2B8, 0x8881, 0xB2B9, 0x8882, 0xB2BA, 0x8883, 0xB2BB, 0x8884,\r\n\t0xB2BC, 0x8885, 0xB2BD, 0x8886, 0xB2BE, 0x8887, 0xB2BF, 0x8888,\t0xB2C0, 0x8889, 0xB2C1, 0x888A, 0xB2C2, 0x888B, 0xB2C3, 0x888C,\r\n\t0xB2C4, 0x888D, 0xB2C5, 0x888E, 0xB2C6, 0x888F, 0xB2C7, 0x8890,\t0xB2C8, 0xB4CF, 0xB2C9, 0xB4D0, 0xB2CA, 0x8891, 0xB2CB, 0x8892,\r\n\t0xB2CC, 0xB4D1, 0xB2CD, 0x8893, 0xB2CE, 0x8894, 0xB2CF, 0x8895,\t0xB2D0, 0xB4D2, 0xB2D1, 0x8896, 0xB2D2, 0xB4D3, 0xB2D3, 0x8897,\r\n\t0xB2D4, 0x8898, 0xB2D5, 0x8899, 0xB2D6, 0x889A, 0xB2D7, 0x889B,\t0xB2D8, 0xB4D4, 0xB2D9, 0xB4D5, 0xB2DA, 0x889C, 0xB2DB, 0xB4D6,\r\n\t0xB2DC, 0x889D, 0xB2DD, 0xB4D7, 0xB2DE, 0x889E, 0xB2DF, 0x889F,\t0xB2E0, 0x88A0, 0xB2E1, 0x88A1, 0xB2E2, 0xB4D8, 0xB2E3, 0x88A2,\r\n\t0xB2E4, 0xB4D9, 0xB2E5, 0xB4DA, 0xB2E6, 0xB4DB, 0xB2E7, 0x88A3,\t0xB2E8, 0xB4DC, 0xB2E9, 0x88A4, 0xB2EA, 0x88A5, 0xB2EB, 0xB4DD,\r\n\t0xB2EC, 0xB4DE, 0xB2ED, 0xB4DF, 0xB2EE, 0xB4E0, 0xB2EF, 0xB4E1,\t0xB2F0, 0x88A6, 0xB2F1, 0x88A7, 0xB2F2, 0x88A8, 0xB2F3, 0xB4E2,\r\n\t0xB2F4, 0xB4E3, 0xB2F5, 0xB4E4, 0xB2F6, 0x88A9, 0xB2F7, 0xB4E5,\t0xB2F8, 0xB4E6, 0xB2F9, 0xB4E7, 0xB2FA, 0xB4E8, 0xB2FB, 0xB4E9,\r\n\t0xB2FC, 0x88AA, 0xB2FD, 0x88AB, 0xB2FE, 0x88AC, 0xB2FF, 0xB4EA,\t0xB300, 0xB4EB, 0xB301, 0xB4EC, 0xB302, 0x88AD, 0xB303, 0x88AE,\r\n\t0xB304, 0xB4ED, 0xB305, 0x88AF, 0xB306, 0x88B0, 0xB307, 0x88B1,\t0xB308, 0xB4EE, 0xB309, 0x88B2, 0xB30A, 0x88B3, 0xB30B, 0x88B4,\r\n\t0xB30C, 0x88B5, 0xB30D, 0x88B6, 0xB30E, 0x88B7, 0xB30F, 0x88B8,\t0xB310, 0xB4EF, 0xB311, 0xB4F0, 0xB312, 0x88B9, 0xB313, 0xB4F1,\r\n\t0xB314, 0xB4F2, 0xB315, 0xB4F3, 0xB316, 0x88BA, 0xB317, 0x88BB,\t0xB318, 0x88BC, 0xB319, 0x88BD, 0xB31A, 0x88BE, 0xB31B, 0x88BF,\r\n\t0xB31C, 0xB4F4, 0xB31D, 0x88C0, 0xB31E, 0x88C1, 0xB31F, 0x88C2,\t0xB320, 0x88C3, 0xB321, 0x88C4, 0xB322, 0x88C5, 0xB323, 0x88C6,\r\n\t0xB324, 0x88C7, 0xB325, 0x88C8, 0xB326, 0x88C9, 0xB327, 0x88CA,\t0xB328, 0x88CB, 0xB329, 0x88CC, 0xB32A, 0x88CD, 0xB32B, 0x88CE,\r\n\t0xB32C, 0x88CF, 0xB32D, 0x88D0, 0xB32E, 0x88D1, 0xB32F, 0x88D2,\t0xB330, 0x88D3, 0xB331, 0x88D4, 0xB332, 0x88D5, 0xB333, 0x88D6,\r\n\t0xB334, 0x88D7, 0xB335, 0x88D8, 0xB336, 0x88D9, 0xB337, 0x88DA,\t0xB338, 0x88DB, 0xB339, 0x88DC, 0xB33A, 0x88DD, 0xB33B, 0x88DE,\r\n\t0xB33C, 0x88DF, 0xB33D, 0x88E0, 0xB33E, 0x88E1, 0xB33F, 0x88E2,\t0xB340, 0x88E3, 0xB341, 0x88E4, 0xB342, 0x88E5, 0xB343, 0x88E6,\r\n\t0xB344, 0x88E7, 0xB345, 0x88E8, 0xB346, 0x88E9, 0xB347, 0x88EA,\t0xB348, 0x88EB, 0xB349, 0x88EC, 0xB34A, 0x88ED, 0xB34B, 0x88EE,\r\n\t0xB34C, 0x88EF, 0xB34D, 0x88F0, 0xB34E, 0x88F1, 0xB34F, 0x88F2,\t0xB350, 0x88F3, 0xB351, 0x88F4, 0xB352, 0x88F5, 0xB353, 0x88F6,\r\n\t0xB354, 0xB4F5, 0xB355, 0xB4F6, 0xB356, 0xB4F7, 0xB357, 0x88F7,\t0xB358, 0xB4F8, 0xB359, 0x88F8, 0xB35A, 0x88F9, 0xB35B, 0xB4F9,\r\n\t0xB35C, 0xB4FA, 0xB35D, 0x88FA, 0xB35E, 0xB4FB, 0xB35F, 0xB4FC,\t0xB360, 0x88FB, 0xB361, 0x88FC, 0xB362, 0x88FD, 0xB363, 0x88FE,\r\n\t0xB364, 0xB4FD, 0xB365, 0xB4FE, 0xB366, 0x8941, 0xB367, 0xB5A1,\t0xB368, 0x8942, 0xB369, 0xB5A2, 0xB36A, 0x8943, 0xB36B, 0xB5A3,\r\n\t0xB36C, 0x8944, 0xB36D, 0x8945, 0xB36E, 0xB5A4, 0xB36F, 0x8946,\t0xB370, 0xB5A5, 0xB371, 0xB5A6, 0xB372, 0x8947, 0xB373, 0x8948,\r\n\t0xB374, 0xB5A7, 0xB375, 0x8949, 0xB376, 0x894A, 0xB377, 0x894B,\t0xB378, 0xB5A8, 0xB379, 0x894C, 0xB37A, 0x894D, 0xB37B, 0x894E,\r\n\t0xB37C, 0x894F, 0xB37D, 0x8950, 0xB37E, 0x8951, 0xB37F, 0x8952,\t0xB380, 0xB5A9, 0xB381, 0xB5AA, 0xB382, 0x8953, 0xB383, 0xB5AB,\r\n\t0xB384, 0xB5AC, 0xB385, 0xB5AD, 0xB386, 0x8954, 0xB387, 0x8955,\t0xB388, 0x8956, 0xB389, 0x8957, 0xB38A, 0x8958, 0xB38B, 0x8959,\r\n\t0xB38C, 0xB5AE, 0xB38D, 0x895A, 0xB38E, 0x8961, 0xB38F, 0x8962,\t0xB390, 0xB5AF, 0xB391, 0x8963, 0xB392, 0x8964, 0xB393, 0x8965,\r\n\t0xB394, 0xB5B0, 0xB395, 0x8966, 0xB396, 0x8967, 0xB397, 0x8968,\t0xB398, 0x8969, 0xB399, 0x896A, 0xB39A, 0x896B, 0xB39B, 0x896C,\r\n\t0xB39C, 0x896D, 0xB39D, 0x896E, 0xB39E, 0x896F, 0xB39F, 0x8970,\t0xB3A0, 0xB5B1, 0xB3A1, 0xB5B2, 0xB3A2, 0x8971, 0xB3A3, 0x8972,\r\n\t0xB3A4, 0x8973, 0xB3A5, 0x8974, 0xB3A6, 0x8975, 0xB3A7, 0x8976,\t0xB3A8, 0xB5B3, 0xB3A9, 0x8977, 0xB3AA, 0x8978, 0xB3AB, 0x8979,\r\n\t0xB3AC, 0xB5B4, 0xB3AD, 0x897A, 0xB3AE, 0x8981, 0xB3AF, 0x8982,\t0xB3B0, 0x8983, 0xB3B1, 0x8984, 0xB3B2, 0x8985, 0xB3B3, 0x8986,\r\n\t0xB3B4, 0x8987, 0xB3B5, 0x8988, 0xB3B6, 0x8989, 0xB3B7, 0x898A,\t0xB3B8, 0x898B, 0xB3B9, 0x898C, 0xB3BA, 0x898D, 0xB3BB, 0x898E,\r\n\t0xB3BC, 0x898F, 0xB3BD, 0x8990, 0xB3BE, 0x8991, 0xB3BF, 0x8992,\t0xB3C0, 0x8993, 0xB3C1, 0x8994, 0xB3C2, 0x8995, 0xB3C3, 0x8996,\r\n\t0xB3C4, 0xB5B5, 0xB3C5, 0xB5B6, 0xB3C6, 0x8997, 0xB3C7, 0x8998,\t0xB3C8, 0xB5B7, 0xB3C9, 0x8999, 0xB3CA, 0x899A, 0xB3CB, 0xB5B8,\r\n\t0xB3CC, 0xB5B9, 0xB3CD, 0x899B, 0xB3CE, 0xB5BA, 0xB3CF, 0x899C,\t0xB3D0, 0xB5BB, 0xB3D1, 0x899D, 0xB3D2, 0x899E, 0xB3D3, 0x899F,\r\n\t0xB3D4, 0xB5BC, 0xB3D5, 0xB5BD, 0xB3D6, 0x89A0, 0xB3D7, 0xB5BE,\t0xB3D8, 0x89A1, 0xB3D9, 0xB5BF, 0xB3DA, 0x89A2, 0xB3DB, 0xB5C0,\r\n\t0xB3DC, 0x89A3, 0xB3DD, 0xB5C1, 0xB3DE, 0x89A4, 0xB3DF, 0x89A5,\t0xB3E0, 0xB5C2, 0xB3E1, 0x89A6, 0xB3E2, 0x89A7, 0xB3E3, 0x89A8,\r\n\t0xB3E4, 0xB5C3, 0xB3E5, 0x89A9, 0xB3E6, 0x89AA, 0xB3E7, 0x89AB,\t0xB3E8, 0xB5C4, 0xB3E9, 0x89AC, 0xB3EA, 0x89AD, 0xB3EB, 0x89AE,\r\n\t0xB3EC, 0x89AF, 0xB3ED, 0x89B0, 0xB3EE, 0x89B1, 0xB3EF, 0x89B2,\t0xB3F0, 0x89B3, 0xB3F1, 0x89B4, 0xB3F2, 0x89B5, 0xB3F3, 0x89B6,\r\n\t0xB3F4, 0x89B7, 0xB3F5, 0x89B8, 0xB3F6, 0x89B9, 0xB3F7, 0x89BA,\t0xB3F8, 0x89BB, 0xB3F9, 0x89BC, 0xB3FA, 0x89BD, 0xB3FB, 0x89BE,\r\n\t0xB3FC, 0xB5C5, 0xB3FD, 0x89BF, 0xB3FE, 0x89C0, 0xB3FF, 0x89C1,\t0xB400, 0x89C2, 0xB401, 0x89C3, 0xB402, 0x89C4, 0xB403, 0x89C5,\r\n\t0xB404, 0x89C6, 0xB405, 0x89C7, 0xB406, 0x89C8, 0xB407, 0x89C9,\t0xB408, 0x89CA, 0xB409, 0x89CB, 0xB40A, 0x89CC, 0xB40B, 0x89CD,\r\n\t0xB40C, 0x89CE, 0xB40D, 0x89CF, 0xB40E, 0x89D0, 0xB40F, 0x89D1,\t0xB410, 0xB5C6, 0xB411, 0x89D2, 0xB412, 0x89D3, 0xB413, 0x89D4,\r\n\t0xB414, 0x89D5, 0xB415, 0x89D6, 0xB416, 0x89D7, 0xB417, 0x89D8,\t0xB418, 0xB5C7, 0xB419, 0x89D9, 0xB41A, 0x89DA, 0xB41B, 0x89DB,\r\n\t0xB41C, 0xB5C8, 0xB41D, 0x89DC, 0xB41E, 0x89DD, 0xB41F, 0x89DE,\t0xB420, 0xB5C9, 0xB421, 0x89DF, 0xB422, 0x89E0, 0xB423, 0x89E1,\r\n\t0xB424, 0x89E2, 0xB425, 0x89E3, 0xB426, 0x89E4, 0xB427, 0x89E5,\t0xB428, 0xB5CA, 0xB429, 0xB5CB, 0xB42A, 0x89E6, 0xB42B, 0xB5CC,\r\n\t0xB42C, 0x89E7, 0xB42D, 0x89E8, 0xB42E, 0x89E9, 0xB42F, 0x89EA,\t0xB430, 0x89EB, 0xB431, 0x89EC, 0xB432, 0x89ED, 0xB433, 0x89EE,\r\n\t0xB434, 0xB5CD, 0xB435, 0x89EF, 0xB436, 0x89F0, 0xB437, 0x89F1,\t0xB438, 0x89F2, 0xB439, 0x89F3, 0xB43A, 0x89F4, 0xB43B, 0x89F5,\r\n\t0xB43C, 0x89F6, 0xB43D, 0x89F7, 0xB43E, 0x89F8, 0xB43F, 0x89F9,\t0xB440, 0x89FA, 0xB441, 0x89FB, 0xB442, 0x89FC, 0xB443, 0x89FD,\r\n\t0xB444, 0x89FE, 0xB445, 0x8A41, 0xB446, 0x8A42, 0xB447, 0x8A43,\t0xB448, 0x8A44, 0xB449, 0x8A45, 0xB44A, 0x8A46, 0xB44B, 0x8A47,\r\n\t0xB44C, 0x8A48, 0xB44D, 0x8A49, 0xB44E, 0x8A4A, 0xB44F, 0x8A4B,\t0xB450, 0xB5CE, 0xB451, 0xB5CF, 0xB452, 0x8A4C, 0xB453, 0x8A4D,\r\n\t0xB454, 0xB5D0, 0xB455, 0x8A4E, 0xB456, 0x8A4F, 0xB457, 0x8A50,\t0xB458, 0xB5D1, 0xB459, 0x8A51, 0xB45A, 0x8A52, 0xB45B, 0x8A53,\r\n\t0xB45C, 0x8A54, 0xB45D, 0x8A55, 0xB45E, 0x8A56, 0xB45F, 0x8A57,\t0xB460, 0xB5D2, 0xB461, 0xB5D3, 0xB462, 0x8A58, 0xB463, 0xB5D4,\r\n\t0xB464, 0x8A59, 0xB465, 0xB5D5, 0xB466, 0x8A5A, 0xB467, 0x8A61,\t0xB468, 0x8A62, 0xB469, 0x8A63, 0xB46A, 0x8A64, 0xB46B, 0x8A65,\r\n\t0xB46C, 0xB5D6, 0xB46D, 0x8A66, 0xB46E, 0x8A67, 0xB46F, 0x8A68,\t0xB470, 0x8A69, 0xB471, 0x8A6A, 0xB472, 0x8A6B, 0xB473, 0x8A6C,\r\n\t0xB474, 0x8A6D, 0xB475, 0x8A6E, 0xB476, 0x8A6F, 0xB477, 0x8A70,\t0xB478, 0x8A71, 0xB479, 0x8A72, 0xB47A, 0x8A73, 0xB47B, 0x8A74,\r\n\t0xB47C, 0x8A75, 0xB47D, 0x8A76, 0xB47E, 0x8A77, 0xB47F, 0x8A78,\t0xB480, 0xB5D7, 0xB481, 0x8A79, 0xB482, 0x8A7A, 0xB483, 0x8A81,\r\n\t0xB484, 0x8A82, 0xB485, 0x8A83, 0xB486, 0x8A84, 0xB487, 0x8A85,\t0xB488, 0xB5D8, 0xB489, 0x8A86, 0xB48A, 0x8A87, 0xB48B, 0x8A88,\r\n\t0xB48C, 0x8A89, 0xB48D, 0x8A8A, 0xB48E, 0x8A8B, 0xB48F, 0x8A8C,\t0xB490, 0x8A8D, 0xB491, 0x8A8E, 0xB492, 0x8A8F, 0xB493, 0x8A90,\r\n\t0xB494, 0x8A91, 0xB495, 0x8A92, 0xB496, 0x8A93, 0xB497, 0x8A94,\t0xB498, 0x8A95, 0xB499, 0x8A96, 0xB49A, 0x8A97, 0xB49B, 0x8A98,\r\n\t0xB49C, 0x8A99, 0xB49D, 0xB5D9, 0xB49E, 0x8A9A, 0xB49F, 0x8A9B,\t0xB4A0, 0x8A9C, 0xB4A1, 0x8A9D, 0xB4A2, 0x8A9E, 0xB4A3, 0x8A9F,\r\n\t0xB4A4, 0xB5DA, 0xB4A5, 0x8AA0, 0xB4A6, 0x8AA1, 0xB4A7, 0x8AA2,\t0xB4A8, 0xB5DB, 0xB4A9, 0x8AA3, 0xB4AA, 0x8AA4, 0xB4AB, 0x8AA5,\r\n\t0xB4AC, 0xB5DC, 0xB4AD, 0x8AA6, 0xB4AE, 0x8AA7, 0xB4AF, 0x8AA8,\t0xB4B0, 0x8AA9, 0xB4B1, 0x8AAA, 0xB4B2, 0x8AAB, 0xB4B3, 0x8AAC,\r\n\t0xB4B4, 0x8AAD, 0xB4B5, 0xB5DD, 0xB4B6, 0x8AAE, 0xB4B7, 0xB5DE,\t0xB4B8, 0x8AAF, 0xB4B9, 0xB5DF, 0xB4BA, 0x8AB0, 0xB4BB, 0x8AB1,\r\n\t0xB4BC, 0x8AB2, 0xB4BD, 0x8AB3, 0xB4BE, 0x8AB4, 0xB4BF, 0x8AB5,\t0xB4C0, 0xB5E0, 0xB4C1, 0x8AB6, 0xB4C2, 0x8AB7, 0xB4C3, 0x8AB8,\r\n\t0xB4C4, 0xB5E1, 0xB4C5, 0x8AB9, 0xB4C6, 0x8ABA, 0xB4C7, 0x8ABB,\t0xB4C8, 0xB5E2, 0xB4C9, 0x8ABC, 0xB4CA, 0x8ABD, 0xB4CB, 0x8ABE,\r\n\t0xB4CC, 0x8ABF, 0xB4CD, 0x8AC0, 0xB4CE, 0x8AC1, 0xB4CF, 0x8AC2,\t0xB4D0, 0xB5E3, 0xB4D1, 0x8AC3, 0xB4D2, 0x8AC4, 0xB4D3, 0x8AC5,\r\n\t0xB4D4, 0x8AC6, 0xB4D5, 0xB5E4, 0xB4D6, 0x8AC7, 0xB4D7, 0x8AC8,\t0xB4D8, 0x8AC9, 0xB4D9, 0x8ACA, 0xB4DA, 0x8ACB, 0xB4DB, 0x8ACC,\r\n\t0xB4DC, 0xB5E5, 0xB4DD, 0xB5E6, 0xB4DE, 0x8ACD, 0xB4DF, 0x8ACE,\t0xB4E0, 0xB5E7, 0xB4E1, 0x8ACF, 0xB4E2, 0x8AD0, 0xB4E3, 0xB5E8,\r\n\t0xB4E4, 0xB5E9, 0xB4E5, 0x8AD1, 0xB4E6, 0xB5EA, 0xB4E7, 0x8AD2,\t0xB4E8, 0x8AD3, 0xB4E9, 0x8AD4, 0xB4EA, 0x8AD5, 0xB4EB, 0x8AD6,\r\n\t0xB4EC, 0xB5EB, 0xB4ED, 0xB5EC, 0xB4EE, 0x8AD7, 0xB4EF, 0xB5ED,\t0xB4F0, 0x8AD8, 0xB4F1, 0xB5EE, 0xB4F2, 0x8AD9, 0xB4F3, 0x8ADA,\r\n\t0xB4F4, 0x8ADB, 0xB4F5, 0x8ADC, 0xB4F6, 0x8ADD, 0xB4F7, 0x8ADE,\t0xB4F8, 0xB5EF, 0xB4F9, 0x8ADF, 0xB4FA, 0x8AE0, 0xB4FB, 0x8AE1,\r\n\t0xB4FC, 0x8AE2, 0xB4FD, 0x8AE3, 0xB4FE, 0x8AE4, 0xB4FF, 0x8AE5,\t0xB500, 0x8AE6, 0xB501, 0x8AE7, 0xB502, 0x8AE8, 0xB503, 0x8AE9,\r\n\t0xB504, 0x8AEA, 0xB505, 0x8AEB, 0xB506, 0x8AEC, 0xB507, 0x8AED,\t0xB508, 0x8AEE, 0xB509, 0x8AEF, 0xB50A, 0x8AF0, 0xB50B, 0x8AF1,\r\n\t0xB50C, 0x8AF2, 0xB50D, 0x8AF3, 0xB50E, 0x8AF4, 0xB50F, 0x8AF5,\t0xB510, 0x8AF6, 0xB511, 0x8AF7, 0xB512, 0x8AF8, 0xB513, 0x8AF9,\r\n\t0xB514, 0xB5F0, 0xB515, 0xB5F1, 0xB516, 0x8AFA, 0xB517, 0x8AFB,\t0xB518, 0xB5F2, 0xB519, 0x8AFC, 0xB51A, 0x8AFD, 0xB51B, 0xB5F3,\r\n\t0xB51C, 0xB5F4, 0xB51D, 0x8AFE, 0xB51E, 0x8B41, 0xB51F, 0x8B42,\t0xB520, 0x8B43, 0xB521, 0x8B44, 0xB522, 0x8B45, 0xB523, 0x8B46,\r\n\t0xB524, 0xB5F5, 0xB525, 0xB5F6, 0xB526, 0x8B47, 0xB527, 0xB5F7,\t0xB528, 0xB5F8, 0xB529, 0xB5F9, 0xB52A, 0xB5FA, 0xB52B, 0x8B48,\r\n\t0xB52C, 0x8B49, 0xB52D, 0x8B4A, 0xB52E, 0x8B4B, 0xB52F, 0x8B4C,\t0xB530, 0xB5FB, 0xB531, 0xB5FC, 0xB532, 0x8B4D, 0xB533, 0x8B4E,\r\n\t0xB534, 0xB5FD, 0xB535, 0x8B4F, 0xB536, 0x8B50, 0xB537, 0x8B51,\t0xB538, 0xB5FE, 0xB539, 0x8B52, 0xB53A, 0x8B53, 0xB53B, 0x8B54,\r\n\t0xB53C, 0x8B55, 0xB53D, 0x8B56, 0xB53E, 0x8B57, 0xB53F, 0x8B58,\t0xB540, 0xB6A1, 0xB541, 0xB6A2, 0xB542, 0x8B59, 0xB543, 0xB6A3,\r\n\t0xB544, 0xB6A4, 0xB545, 0xB6A5, 0xB546, 0x8B5A, 0xB547, 0x8B61,\t0xB548, 0x8B62, 0xB549, 0x8B63, 0xB54A, 0x8B64, 0xB54B, 0xB6A6,\r\n\t0xB54C, 0xB6A7, 0xB54D, 0xB6A8, 0xB54E, 0x8B65, 0xB54F, 0x8B66,\t0xB550, 0xB6A9, 0xB551, 0x8B67, 0xB552, 0x8B68, 0xB553, 0x8B69,\r\n\t0xB554, 0xB6AA, 0xB555, 0x8B6A, 0xB556, 0x8B6B, 0xB557, 0x8B6C,\t0xB558, 0x8B6D, 0xB559, 0x8B6E, 0xB55A, 0x8B6F, 0xB55B, 0x8B70,\r\n\t0xB55C, 0xB6AB, 0xB55D, 0xB6AC, 0xB55E, 0x8B71, 0xB55F, 0xB6AD,\t0xB560, 0xB6AE, 0xB561, 0xB6AF, 0xB562, 0x8B72, 0xB563, 0x8B73,\r\n\t0xB564, 0x8B74, 0xB565, 0x8B75, 0xB566, 0x8B76, 0xB567, 0x8B77,\t0xB568, 0x8B78, 0xB569, 0x8B79, 0xB56A, 0x8B7A, 0xB56B, 0x8B81,\r\n\t0xB56C, 0x8B82, 0xB56D, 0x8B83, 0xB56E, 0x8B84, 0xB56F, 0x8B85,\t0xB570, 0x8B86, 0xB571, 0x8B87, 0xB572, 0x8B88, 0xB573, 0x8B89,\r\n\t0xB574, 0x8B8A, 0xB575, 0x8B8B, 0xB576, 0x8B8C, 0xB577, 0x8B8D,\t0xB578, 0x8B8E, 0xB579, 0x8B8F, 0xB57A, 0x8B90, 0xB57B, 0x8B91,\r\n\t0xB57C, 0x8B92, 0xB57D, 0x8B93, 0xB57E, 0x8B94, 0xB57F, 0x8B95,\t0xB580, 0x8B96, 0xB581, 0x8B97, 0xB582, 0x8B98, 0xB583, 0x8B99,\r\n\t0xB584, 0x8B9A, 0xB585, 0x8B9B, 0xB586, 0x8B9C, 0xB587, 0x8B9D,\t0xB588, 0x8B9E, 0xB589, 0x8B9F, 0xB58A, 0x8BA0, 0xB58B, 0x8BA1,\r\n\t0xB58C, 0x8BA2, 0xB58D, 0x8BA3, 0xB58E, 0x8BA4, 0xB58F, 0x8BA5,\t0xB590, 0x8BA6, 0xB591, 0x8BA7, 0xB592, 0x8BA8, 0xB593, 0x8BA9,\r\n\t0xB594, 0x8BAA, 0xB595, 0x8BAB, 0xB596, 0x8BAC, 0xB597, 0x8BAD,\t0xB598, 0x8BAE, 0xB599, 0x8BAF, 0xB59A, 0x8BB0, 0xB59B, 0x8BB1,\r\n\t0xB59C, 0x8BB2, 0xB59D, 0x8BB3, 0xB59E, 0x8BB4, 0xB59F, 0x8BB5,\t0xB5A0, 0xB6B0, 0xB5A1, 0xB6B1, 0xB5A2, 0x8BB6, 0xB5A3, 0x8BB7,\r\n\t0xB5A4, 0xB6B2, 0xB5A5, 0x8BB8, 0xB5A6, 0x8BB9, 0xB5A7, 0x8BBA,\t0xB5A8, 0xB6B3, 0xB5A9, 0x8BBB, 0xB5AA, 0xB6B4, 0xB5AB, 0xB6B5,\r\n\t0xB5AC, 0x8BBC, 0xB5AD, 0x8BBD, 0xB5AE, 0x8BBE, 0xB5AF, 0x8BBF,\t0xB5B0, 0xB6B6, 0xB5B1, 0xB6B7, 0xB5B2, 0x8BC0, 0xB5B3, 0xB6B8,\r\n\t0xB5B4, 0xB6B9, 0xB5B5, 0xB6BA, 0xB5B6, 0x8BC1, 0xB5B7, 0x8BC2,\t0xB5B8, 0x8BC3, 0xB5B9, 0x8BC4, 0xB5BA, 0x8BC5, 0xB5BB, 0xB6BB,\r\n\t0xB5BC, 0xB6BC, 0xB5BD, 0xB6BD, 0xB5BE, 0x8BC6, 0xB5BF, 0x8BC7,\t0xB5C0, 0xB6BE, 0xB5C1, 0x8BC8, 0xB5C2, 0x8BC9, 0xB5C3, 0x8BCA,\r\n\t0xB5C4, 0xB6BF, 0xB5C5, 0x8BCB, 0xB5C6, 0x8BCC, 0xB5C7, 0x8BCD,\t0xB5C8, 0x8BCE, 0xB5C9, 0x8BCF, 0xB5CA, 0x8BD0, 0xB5CB, 0x8BD1,\r\n\t0xB5CC, 0xB6C0, 0xB5CD, 0xB6C1, 0xB5CE, 0x8BD2, 0xB5CF, 0xB6C2,\t0xB5D0, 0xB6C3, 0xB5D1, 0xB6C4, 0xB5D2, 0x8BD3, 0xB5D3, 0x8BD4,\r\n\t0xB5D4, 0x8BD5, 0xB5D5, 0x8BD6, 0xB5D6, 0x8BD7, 0xB5D7, 0x8BD8,\t0xB5D8, 0xB6C5, 0xB5D9, 0x8BD9, 0xB5DA, 0x8BDA, 0xB5DB, 0x8BDB,\r\n\t0xB5DC, 0x8BDC, 0xB5DD, 0x8BDD, 0xB5DE, 0x8BDE, 0xB5DF, 0x8BDF,\t0xB5E0, 0x8BE0, 0xB5E1, 0x8BE1, 0xB5E2, 0x8BE2, 0xB5E3, 0x8BE3,\r\n\t0xB5E4, 0x8BE4, 0xB5E5, 0x8BE5, 0xB5E6, 0x8BE6, 0xB5E7, 0x8BE7,\t0xB5E8, 0x8BE8, 0xB5E9, 0x8BE9, 0xB5EA, 0x8BEA, 0xB5EB, 0x8BEB,\r\n\t0xB5EC, 0xB6C6, 0xB5ED, 0x8BEC, 0xB5EE, 0x8BED, 0xB5EF, 0x8BEE,\t0xB5F0, 0x8BEF, 0xB5F1, 0x8BF0, 0xB5F2, 0x8BF1, 0xB5F3, 0x8BF2,\r\n\t0xB5F4, 0x8BF3, 0xB5F5, 0x8BF4, 0xB5F6, 0x8BF5, 0xB5F7, 0x8BF6,\t0xB5F8, 0x8BF7, 0xB5F9, 0x8BF8, 0xB5FA, 0x8BF9, 0xB5FB, 0x8BFA,\r\n\t0xB5FC, 0x8BFB, 0xB5FD, 0x8BFC, 0xB5FE, 0x8BFD, 0xB5FF, 0x8BFE,\t0xB600, 0x8C41, 0xB601, 0x8C42, 0xB602, 0x8C43, 0xB603, 0x8C44,\r\n\t0xB604, 0x8C45, 0xB605, 0x8C46, 0xB606, 0x8C47, 0xB607, 0x8C48,\t0xB608, 0x8C49, 0xB609, 0x8C4A, 0xB60A, 0x8C4B, 0xB60B, 0x8C4C,\r\n\t0xB60C, 0x8C4D, 0xB60D, 0x8C4E, 0xB60E, 0x8C4F, 0xB60F, 0x8C50,\t0xB610, 0xB6C7, 0xB611, 0xB6C8, 0xB612, 0x8C51, 0xB613, 0x8C52,\r\n\t0xB614, 0xB6C9, 0xB615, 0x8C53, 0xB616, 0x8C54, 0xB617, 0x8C55,\t0xB618, 0xB6CA, 0xB619, 0x8C56, 0xB61A, 0x8C57, 0xB61B, 0x8C58,\r\n\t0xB61C, 0x8C59, 0xB61D, 0x8C5A, 0xB61E, 0x8C61, 0xB61F, 0x8C62,\t0xB620, 0x8C63, 0xB621, 0x8C64, 0xB622, 0x8C65, 0xB623, 0x8C66,\r\n\t0xB624, 0x8C67, 0xB625, 0xB6CB, 0xB626, 0x8C68, 0xB627, 0x8C69,\t0xB628, 0x8C6A, 0xB629, 0x8C6B, 0xB62A, 0x8C6C, 0xB62B, 0x8C6D,\r\n\t0xB62C, 0xB6CC, 0xB62D, 0x8C6E, 0xB62E, 0x8C6F, 0xB62F, 0x8C70,\t0xB630, 0x8C71, 0xB631, 0x8C72, 0xB632, 0x8C73, 0xB633, 0x8C74,\r\n\t0xB634, 0xB6CD, 0xB635, 0x8C75, 0xB636, 0x8C76, 0xB637, 0x8C77,\t0xB638, 0x8C78, 0xB639, 0x8C79, 0xB63A, 0x8C7A, 0xB63B, 0x8C81,\r\n\t0xB63C, 0x8C82, 0xB63D, 0x8C83, 0xB63E, 0x8C84, 0xB63F, 0x8C85,\t0xB640, 0x8C86, 0xB641, 0x8C87, 0xB642, 0x8C88, 0xB643, 0x8C89,\r\n\t0xB644, 0x8C8A, 0xB645, 0x8C8B, 0xB646, 0x8C8C, 0xB647, 0x8C8D,\t0xB648, 0xB6CE, 0xB649, 0x8C8E, 0xB64A, 0x8C8F, 0xB64B, 0x8C90,\r\n\t0xB64C, 0x8C91, 0xB64D, 0x8C92, 0xB64E, 0x8C93, 0xB64F, 0x8C94,\t0xB650, 0x8C95, 0xB651, 0x8C96, 0xB652, 0x8C97, 0xB653, 0x8C98,\r\n\t0xB654, 0x8C99, 0xB655, 0x8C9A, 0xB656, 0x8C9B, 0xB657, 0x8C9C,\t0xB658, 0x8C9D, 0xB659, 0x8C9E, 0xB65A, 0x8C9F, 0xB65B, 0x8CA0,\r\n\t0xB65C, 0x8CA1, 0xB65D, 0x8CA2, 0xB65E, 0x8CA3, 0xB65F, 0x8CA4,\t0xB660, 0x8CA5, 0xB661, 0x8CA6, 0xB662, 0x8CA7, 0xB663, 0x8CA8,\r\n\t0xB664, 0xB6CF, 0xB665, 0x8CA9, 0xB666, 0x8CAA, 0xB667, 0x8CAB,\t0xB668, 0xB6D0, 0xB669, 0x8CAC, 0xB66A, 0x8CAD, 0xB66B, 0x8CAE,\r\n\t0xB66C, 0x8CAF, 0xB66D, 0x8CB0, 0xB66E, 0x8CB1, 0xB66F, 0x8CB2,\t0xB670, 0x8CB3, 0xB671, 0x8CB4, 0xB672, 0x8CB5, 0xB673, 0x8CB6,\r\n\t0xB674, 0x8CB7, 0xB675, 0x8CB8, 0xB676, 0x8CB9, 0xB677, 0x8CBA,\t0xB678, 0x8CBB, 0xB679, 0x8CBC, 0xB67A, 0x8CBD, 0xB67B, 0x8CBE,\r\n\t0xB67C, 0x8CBF, 0xB67D, 0x8CC0, 0xB67E, 0x8CC1, 0xB67F, 0x8CC2,\t0xB680, 0x8CC3, 0xB681, 0x8CC4, 0xB682, 0x8CC5, 0xB683, 0x8CC6,\r\n\t0xB684, 0x8CC7, 0xB685, 0x8CC8, 0xB686, 0x8CC9, 0xB687, 0x8CCA,\t0xB688, 0x8CCB, 0xB689, 0x8CCC, 0xB68A, 0x8CCD, 0xB68B, 0x8CCE,\r\n\t0xB68C, 0x8CCF, 0xB68D, 0x8CD0, 0xB68E, 0x8CD1, 0xB68F, 0x8CD2,\t0xB690, 0x8CD3, 0xB691, 0x8CD4, 0xB692, 0x8CD5, 0xB693, 0x8CD6,\r\n\t0xB694, 0x8CD7, 0xB695, 0x8CD8, 0xB696, 0x8CD9, 0xB697, 0x8CDA,\t0xB698, 0x8CDB, 0xB699, 0x8CDC, 0xB69A, 0x8CDD, 0xB69B, 0x8CDE,\r\n\t0xB69C, 0xB6D1, 0xB69D, 0xB6D2, 0xB69E, 0x8CDF, 0xB69F, 0x8CE0,\t0xB6A0, 0xB6D3, 0xB6A1, 0x8CE1, 0xB6A2, 0x8CE2, 0xB6A3, 0x8CE3,\r\n\t0xB6A4, 0xB6D4, 0xB6A5, 0x8CE4, 0xB6A6, 0x8CE5, 0xB6A7, 0x8CE6,\t0xB6A8, 0x8CE7, 0xB6A9, 0x8CE8, 0xB6AA, 0x8CE9, 0xB6AB, 0xB6D5,\r\n\t0xB6AC, 0xB6D6, 0xB6AD, 0x8CEA, 0xB6AE, 0x8CEB, 0xB6AF, 0x8CEC,\t0xB6B0, 0x8CED, 0xB6B1, 0xB6D7, 0xB6B2, 0x8CEE, 0xB6B3, 0x8CEF,\r\n\t0xB6B4, 0x8CF0, 0xB6B5, 0x8CF1, 0xB6B6, 0x8CF2, 0xB6B7, 0x8CF3,\t0xB6B8, 0x8CF4, 0xB6B9, 0x8CF5, 0xB6BA, 0x8CF6, 0xB6BB, 0x8CF7,\r\n\t0xB6BC, 0x8CF8, 0xB6BD, 0x8CF9, 0xB6BE, 0x8CFA, 0xB6BF, 0x8CFB,\t0xB6C0, 0x8CFC, 0xB6C1, 0x8CFD, 0xB6C2, 0x8CFE, 0xB6C3, 0x8D41,\r\n\t0xB6C4, 0x8D42, 0xB6C5, 0x8D43, 0xB6C6, 0x8D44, 0xB6C7, 0x8D45,\t0xB6C8, 0x8D46, 0xB6C9, 0x8D47, 0xB6CA, 0x8D48, 0xB6CB, 0x8D49,\r\n\t0xB6CC, 0x8D4A, 0xB6CD, 0x8D4B, 0xB6CE, 0x8D4C, 0xB6CF, 0x8D4D,\t0xB6D0, 0x8D4E, 0xB6D1, 0x8D4F, 0xB6D2, 0x8D50, 0xB6D3, 0x8D51,\r\n\t0xB6D4, 0xB6D8, 0xB6D5, 0x8D52, 0xB6D6, 0x8D53, 0xB6D7, 0x8D54,\t0xB6D8, 0x8D55, 0xB6D9, 0x8D56, 0xB6DA, 0x8D57, 0xB6DB, 0x8D58,\r\n\t0xB6DC, 0x8D59, 0xB6DD, 0x8D5A, 0xB6DE, 0x8D61, 0xB6DF, 0x8D62,\t0xB6E0, 0x8D63, 0xB6E1, 0x8D64, 0xB6E2, 0x8D65, 0xB6E3, 0x8D66,\r\n\t0xB6E4, 0x8D67, 0xB6E5, 0x8D68, 0xB6E6, 0x8D69, 0xB6E7, 0x8D6A,\t0xB6E8, 0x8D6B, 0xB6E9, 0x8D6C, 0xB6EA, 0x8D6D, 0xB6EB, 0x8D6E,\r\n\t0xB6EC, 0x8D6F, 0xB6ED, 0x8D70, 0xB6EE, 0x8D71, 0xB6EF, 0x8D72,\t0xB6F0, 0xB6D9, 0xB6F1, 0x8D73, 0xB6F2, 0x8D74, 0xB6F3, 0x8D75,\r\n\t0xB6F4, 0xB6DA, 0xB6F5, 0x8D76, 0xB6F6, 0x8D77, 0xB6F7, 0x8D78,\t0xB6F8, 0xB6DB, 0xB6F9, 0x8D79, 0xB6FA, 0x8D7A, 0xB6FB, 0x8D81,\r\n\t0xB6FC, 0x8D82, 0xB6FD, 0x8D83, 0xB6FE, 0x8D84, 0xB6FF, 0x8D85,\t0xB700, 0xB6DC, 0xB701, 0xB6DD, 0xB702, 0x8D86, 0xB703, 0x8D87,\r\n\t0xB704, 0x8D88, 0xB705, 0xB6DE, 0xB706, 0x8D89, 0xB707, 0x8D8A,\t0xB708, 0x8D8B, 0xB709, 0x8D8C, 0xB70A, 0x8D8D, 0xB70B, 0x8D8E,\r\n\t0xB70C, 0x8D8F, 0xB70D, 0x8D90, 0xB70E, 0x8D91, 0xB70F, 0x8D92,\t0xB710, 0x8D93, 0xB711, 0x8D94, 0xB712, 0x8D95, 0xB713, 0x8D96,\r\n\t0xB714, 0x8D97, 0xB715, 0x8D98, 0xB716, 0x8D99, 0xB717, 0x8D9A,\t0xB718, 0x8D9B, 0xB719, 0x8D9C, 0xB71A, 0x8D9D, 0xB71B, 0x8D9E,\r\n\t0xB71C, 0x8D9F, 0xB71D, 0x8DA0, 0xB71E, 0x8DA1, 0xB71F, 0x8DA2,\t0xB720, 0x8DA3, 0xB721, 0x8DA4, 0xB722, 0x8DA5, 0xB723, 0x8DA6,\r\n\t0xB724, 0x8DA7, 0xB725, 0x8DA8, 0xB726, 0x8DA9, 0xB727, 0x8DAA,\t0xB728, 0xB6DF, 0xB729, 0xB6E0, 0xB72A, 0x8DAB, 0xB72B, 0x8DAC,\r\n\t0xB72C, 0xB6E1, 0xB72D, 0x8DAD, 0xB72E, 0x8DAE, 0xB72F, 0xB6E2,\t0xB730, 0xB6E3, 0xB731, 0x8DAF, 0xB732, 0x8DB0, 0xB733, 0x8DB1,\r\n\t0xB734, 0x8DB2, 0xB735, 0x8DB3, 0xB736, 0x8DB4, 0xB737, 0x8DB5,\t0xB738, 0xB6E4, 0xB739, 0xB6E5, 0xB73A, 0x8DB6, 0xB73B, 0xB6E6,\r\n\t0xB73C, 0x8DB7, 0xB73D, 0x8DB8, 0xB73E, 0x8DB9, 0xB73F, 0x8DBA,\t0xB740, 0x8DBB, 0xB741, 0x8DBC, 0xB742, 0x8DBD, 0xB743, 0x8DBE,\r\n\t0xB744, 0xB6E7, 0xB745, 0x8DBF, 0xB746, 0x8DC0, 0xB747, 0x8DC1,\t0xB748, 0xB6E8, 0xB749, 0x8DC2, 0xB74A, 0x8DC3, 0xB74B, 0x8DC4,\r\n\t0xB74C, 0xB6E9, 0xB74D, 0x8DC5, 0xB74E, 0x8DC6, 0xB74F, 0x8DC7,\t0xB750, 0x8DC8, 0xB751, 0x8DC9, 0xB752, 0x8DCA, 0xB753, 0x8DCB,\r\n\t0xB754, 0xB6EA, 0xB755, 0xB6EB, 0xB756, 0x8DCC, 0xB757, 0x8DCD,\t0xB758, 0x8DCE, 0xB759, 0x8DCF, 0xB75A, 0x8DD0, 0xB75B, 0x8DD1,\r\n\t0xB75C, 0x8DD2, 0xB75D, 0x8DD3, 0xB75E, 0x8DD4, 0xB75F, 0x8DD5,\t0xB760, 0xB6EC, 0xB761, 0x8DD6, 0xB762, 0x8DD7, 0xB763, 0x8DD8,\r\n\t0xB764, 0xB6ED, 0xB765, 0x8DD9, 0xB766, 0x8DDA, 0xB767, 0x8DDB,\t0xB768, 0xB6EE, 0xB769, 0x8DDC, 0xB76A, 0x8DDD, 0xB76B, 0x8DDE,\r\n\t0xB76C, 0x8DDF, 0xB76D, 0x8DE0, 0xB76E, 0x8DE1, 0xB76F, 0x8DE2,\t0xB770, 0xB6EF, 0xB771, 0xB6F0, 0xB772, 0x8DE3, 0xB773, 0xB6F1,\r\n\t0xB774, 0x8DE4, 0xB775, 0xB6F2, 0xB776, 0x8DE5, 0xB777, 0x8DE6,\t0xB778, 0x8DE7, 0xB779, 0x8DE8, 0xB77A, 0x8DE9, 0xB77B, 0x8DEA,\r\n\t0xB77C, 0xB6F3, 0xB77D, 0xB6F4, 0xB77E, 0x8DEB, 0xB77F, 0x8DEC,\t0xB780, 0xB6F5, 0xB781, 0x8DED, 0xB782, 0x8DEE, 0xB783, 0x8DEF,\r\n\t0xB784, 0xB6F6, 0xB785, 0x8DF0, 0xB786, 0x8DF1, 0xB787, 0x8DF2,\t0xB788, 0x8DF3, 0xB789, 0x8DF4, 0xB78A, 0x8DF5, 0xB78B, 0x8DF6,\r\n\t0xB78C, 0xB6F7, 0xB78D, 0xB6F8, 0xB78E, 0x8DF7, 0xB78F, 0xB6F9,\t0xB790, 0xB6FA, 0xB791, 0xB6FB, 0xB792, 0xB6FC, 0xB793, 0x8DF8,\r\n\t0xB794, 0x8DF9, 0xB795, 0x8DFA, 0xB796, 0xB6FD, 0xB797, 0xB6FE,\t0xB798, 0xB7A1, 0xB799, 0xB7A2, 0xB79A, 0x8DFB, 0xB79B, 0x8DFC,\r\n\t0xB79C, 0xB7A3, 0xB79D, 0x8DFD, 0xB79E, 0x8DFE, 0xB79F, 0x8E41,\t0xB7A0, 0xB7A4, 0xB7A1, 0x8E42, 0xB7A2, 0x8E43, 0xB7A3, 0x8E44,\r\n\t0xB7A4, 0x8E45, 0xB7A5, 0x8E46, 0xB7A6, 0x8E47, 0xB7A7, 0x8E48,\t0xB7A8, 0xB7A5, 0xB7A9, 0xB7A6, 0xB7AA, 0x8E49, 0xB7AB, 0xB7A7,\r\n\t0xB7AC, 0xB7A8, 0xB7AD, 0xB7A9, 0xB7AE, 0x8E4A, 0xB7AF, 0x8E4B,\t0xB7B0, 0x8E4C, 0xB7B1, 0x8E4D, 0xB7B2, 0x8E4E, 0xB7B3, 0x8E4F,\r\n\t0xB7B4, 0xB7AA, 0xB7B5, 0xB7AB, 0xB7B6, 0x8E50, 0xB7B7, 0x8E51,\t0xB7B8, 0xB7AC, 0xB7B9, 0x8E52, 0xB7BA, 0x8E53, 0xB7BB, 0x8E54,\r\n\t0xB7BC, 0x8E55, 0xB7BD, 0x8E56, 0xB7BE, 0x8E57, 0xB7BF, 0x8E58,\t0xB7C0, 0x8E59, 0xB7C1, 0x8E5A, 0xB7C2, 0x8E61, 0xB7C3, 0x8E62,\r\n\t0xB7C4, 0x8E63, 0xB7C5, 0x8E64, 0xB7C6, 0x8E65, 0xB7C7, 0xB7AD,\t0xB7C8, 0x8E66, 0xB7C9, 0xB7AE, 0xB7CA, 0x8E67, 0xB7CB, 0x8E68,\r\n\t0xB7CC, 0x8E69, 0xB7CD, 0x8E6A, 0xB7CE, 0x8E6B, 0xB7CF, 0x8E6C,\t0xB7D0, 0x8E6D, 0xB7D1, 0x8E6E, 0xB7D2, 0x8E6F, 0xB7D3, 0x8E70,\r\n\t0xB7D4, 0x8E71, 0xB7D5, 0x8E72, 0xB7D6, 0x8E73, 0xB7D7, 0x8E74,\t0xB7D8, 0x8E75, 0xB7D9, 0x8E76, 0xB7DA, 0x8E77, 0xB7DB, 0x8E78,\r\n\t0xB7DC, 0x8E79, 0xB7DD, 0x8E7A, 0xB7DE, 0x8E81, 0xB7DF, 0x8E82,\t0xB7E0, 0x8E83, 0xB7E1, 0x8E84, 0xB7E2, 0x8E85, 0xB7E3, 0x8E86,\r\n\t0xB7E4, 0x8E87, 0xB7E5, 0x8E88, 0xB7E6, 0x8E89, 0xB7E7, 0x8E8A,\t0xB7E8, 0x8E8B, 0xB7E9, 0x8E8C, 0xB7EA, 0x8E8D, 0xB7EB, 0x8E8E,\r\n\t0xB7EC, 0xB7AF, 0xB7ED, 0xB7B0, 0xB7EE, 0x8E8F, 0xB7EF, 0x8E90,\t0xB7F0, 0xB7B1, 0xB7F1, 0x8E91, 0xB7F2, 0x8E92, 0xB7F3, 0x8E93,\r\n\t0xB7F4, 0xB7B2, 0xB7F5, 0x8E94, 0xB7F6, 0x8E95, 0xB7F7, 0x8E96,\t0xB7F8, 0x8E97, 0xB7F9, 0x8E98, 0xB7FA, 0x8E99, 0xB7FB, 0x8E9A,\r\n\t0xB7FC, 0xB7B3, 0xB7FD, 0xB7B4, 0xB7FE, 0x8E9B, 0xB7FF, 0xB7B5,\t0xB800, 0xB7B6, 0xB801, 0xB7B7, 0xB802, 0x8E9C, 0xB803, 0x8E9D,\r\n\t0xB804, 0x8E9E, 0xB805, 0x8E9F, 0xB806, 0x8EA0, 0xB807, 0xB7B8,\t0xB808, 0xB7B9, 0xB809, 0xB7BA, 0xB80A, 0x8EA1, 0xB80B, 0x8EA2,\r\n\t0xB80C, 0xB7BB, 0xB80D, 0x8EA3, 0xB80E, 0x8EA4, 0xB80F, 0x8EA5,\t0xB810, 0xB7BC, 0xB811, 0x8EA6, 0xB812, 0x8EA7, 0xB813, 0x8EA8,\r\n\t0xB814, 0x8EA9, 0xB815, 0x8EAA, 0xB816, 0x8EAB, 0xB817, 0x8EAC,\t0xB818, 0xB7BD, 0xB819, 0xB7BE, 0xB81A, 0x8EAD, 0xB81B, 0xB7BF,\r\n\t0xB81C, 0x8EAE, 0xB81D, 0xB7C0, 0xB81E, 0x8EAF, 0xB81F, 0x8EB0,\t0xB820, 0x8EB1, 0xB821, 0x8EB2, 0xB822, 0x8EB3, 0xB823, 0x8EB4,\r\n\t0xB824, 0xB7C1, 0xB825, 0xB7C2, 0xB826, 0x8EB5, 0xB827, 0x8EB6,\t0xB828, 0xB7C3, 0xB829, 0x8EB7, 0xB82A, 0x8EB8, 0xB82B, 0x8EB9,\r\n\t0xB82C, 0xB7C4, 0xB82D, 0x8EBA, 0xB82E, 0x8EBB, 0xB82F, 0x8EBC,\t0xB830, 0x8EBD, 0xB831, 0x8EBE, 0xB832, 0x8EBF, 0xB833, 0x8EC0,\r\n\t0xB834, 0xB7C5, 0xB835, 0xB7C6, 0xB836, 0x8EC1, 0xB837, 0xB7C7,\t0xB838, 0xB7C8, 0xB839, 0xB7C9, 0xB83A, 0x8EC2, 0xB83B, 0x8EC3,\r\n\t0xB83C, 0x8EC4, 0xB83D, 0x8EC5, 0xB83E, 0x8EC6, 0xB83F, 0x8EC7,\t0xB840, 0xB7CA, 0xB841, 0x8EC8, 0xB842, 0x8EC9, 0xB843, 0x8ECA,\r\n\t0xB844, 0xB7CB, 0xB845, 0x8ECB, 0xB846, 0x8ECC, 0xB847, 0x8ECD,\t0xB848, 0x8ECE, 0xB849, 0x8ECF, 0xB84A, 0x8ED0, 0xB84B, 0x8ED1,\r\n\t0xB84C, 0x8ED2, 0xB84D, 0x8ED3, 0xB84E, 0x8ED4, 0xB84F, 0x8ED5,\t0xB850, 0x8ED6, 0xB851, 0xB7CC, 0xB852, 0x8ED7, 0xB853, 0xB7CD,\r\n\t0xB854, 0x8ED8, 0xB855, 0x8ED9, 0xB856, 0x8EDA, 0xB857, 0x8EDB,\t0xB858, 0x8EDC, 0xB859, 0x8EDD, 0xB85A, 0x8EDE, 0xB85B, 0x8EDF,\r\n\t0xB85C, 0xB7CE, 0xB85D, 0xB7CF, 0xB85E, 0x8EE0, 0xB85F, 0x8EE1,\t0xB860, 0xB7D0, 0xB861, 0x8EE2, 0xB862, 0x8EE3, 0xB863, 0x8EE4,\r\n\t0xB864, 0xB7D1, 0xB865, 0x8EE5, 0xB866, 0x8EE6, 0xB867, 0x8EE7,\t0xB868, 0x8EE8, 0xB869, 0x8EE9, 0xB86A, 0x8EEA, 0xB86B, 0x8EEB,\r\n\t0xB86C, 0xB7D2, 0xB86D, 0xB7D3, 0xB86E, 0x8EEC, 0xB86F, 0xB7D4,\t0xB870, 0x8EED, 0xB871, 0xB7D5, 0xB872, 0x8EEE, 0xB873, 0x8EEF,\r\n\t0xB874, 0x8EF0, 0xB875, 0x8EF1, 0xB876, 0x8EF2, 0xB877, 0x8EF3,\t0xB878, 0xB7D6, 0xB879, 0x8EF4, 0xB87A, 0x8EF5, 0xB87B, 0x8EF6,\r\n\t0xB87C, 0xB7D7, 0xB87D, 0x8EF7, 0xB87E, 0x8EF8, 0xB87F, 0x8EF9,\t0xB880, 0x8EFA, 0xB881, 0x8EFB, 0xB882, 0x8EFC, 0xB883, 0x8EFD,\r\n\t0xB884, 0x8EFE, 0xB885, 0x8F41, 0xB886, 0x8F42, 0xB887, 0x8F43,\t0xB888, 0x8F44, 0xB889, 0x8F45, 0xB88A, 0x8F46, 0xB88B, 0x8F47,\r\n\t0xB88C, 0x8F48, 0xB88D, 0xB7D8, 0xB88E, 0x8F49, 0xB88F, 0x8F4A,\t0xB890, 0x8F4B, 0xB891, 0x8F4C, 0xB892, 0x8F4D, 0xB893, 0x8F4E,\r\n\t0xB894, 0x8F4F, 0xB895, 0x8F50, 0xB896, 0x8F51, 0xB897, 0x8F52,\t0xB898, 0x8F53, 0xB899, 0x8F54, 0xB89A, 0x8F55, 0xB89B, 0x8F56,\r\n\t0xB89C, 0x8F57, 0xB89D, 0x8F58, 0xB89E, 0x8F59, 0xB89F, 0x8F5A,\t0xB8A0, 0x8F61, 0xB8A1, 0x8F62, 0xB8A2, 0x8F63, 0xB8A3, 0x8F64,\r\n\t0xB8A4, 0x8F65, 0xB8A5, 0x8F66, 0xB8A6, 0x8F67, 0xB8A7, 0x8F68,\t0xB8A8, 0xB7D9, 0xB8A9, 0x8F69, 0xB8AA, 0x8F6A, 0xB8AB, 0x8F6B,\r\n\t0xB8AC, 0x8F6C, 0xB8AD, 0x8F6D, 0xB8AE, 0x8F6E, 0xB8AF, 0x8F6F,\t0xB8B0, 0xB7DA, 0xB8B1, 0x8F70, 0xB8B2, 0x8F71, 0xB8B3, 0x8F72,\r\n\t0xB8B4, 0xB7DB, 0xB8B5, 0x8F73, 0xB8B6, 0x8F74, 0xB8B7, 0x8F75,\t0xB8B8, 0xB7DC, 0xB8B9, 0x8F76, 0xB8BA, 0x8F77, 0xB8BB, 0x8F78,\r\n\t0xB8BC, 0x8F79, 0xB8BD, 0x8F7A, 0xB8BE, 0x8F81, 0xB8BF, 0x8F82,\t0xB8C0, 0xB7DD, 0xB8C1, 0xB7DE, 0xB8C2, 0x8F83, 0xB8C3, 0xB7DF,\r\n\t0xB8C4, 0x8F84, 0xB8C5, 0xB7E0, 0xB8C6, 0x8F85, 0xB8C7, 0x8F86,\t0xB8C8, 0x8F87, 0xB8C9, 0x8F88, 0xB8CA, 0x8F89, 0xB8CB, 0x8F8A,\r\n\t0xB8CC, 0xB7E1, 0xB8CD, 0x8F8B, 0xB8CE, 0x8F8C, 0xB8CF, 0x8F8D,\t0xB8D0, 0xB7E2, 0xB8D1, 0x8F8E, 0xB8D2, 0x8F8F, 0xB8D3, 0x8F90,\r\n\t0xB8D4, 0xB7E3, 0xB8D5, 0x8F91, 0xB8D6, 0x8F92, 0xB8D7, 0x8F93,\t0xB8D8, 0x8F94, 0xB8D9, 0x8F95, 0xB8DA, 0x8F96, 0xB8DB, 0x8F97,\r\n\t0xB8DC, 0x8F98, 0xB8DD, 0xB7E4, 0xB8DE, 0x8F99, 0xB8DF, 0xB7E5,\t0xB8E0, 0x8F9A, 0xB8E1, 0xB7E6, 0xB8E2, 0x8F9B, 0xB8E3, 0x8F9C,\r\n\t0xB8E4, 0x8F9D, 0xB8E5, 0x8F9E, 0xB8E6, 0x8F9F, 0xB8E7, 0x8FA0,\t0xB8E8, 0xB7E7, 0xB8E9, 0xB7E8, 0xB8EA, 0x8FA1, 0xB8EB, 0x8FA2,\r\n\t0xB8EC, 0xB7E9, 0xB8ED, 0x8FA3, 0xB8EE, 0x8FA4, 0xB8EF, 0x8FA5,\t0xB8F0, 0xB7EA, 0xB8F1, 0x8FA6, 0xB8F2, 0x8FA7, 0xB8F3, 0x8FA8,\r\n\t0xB8F4, 0x8FA9, 0xB8F5, 0x8FAA, 0xB8F6, 0x8FAB, 0xB8F7, 0x8FAC,\t0xB8F8, 0xB7EB, 0xB8F9, 0xB7EC, 0xB8FA, 0x8FAD, 0xB8FB, 0xB7ED,\r\n\t0xB8FC, 0x8FAE, 0xB8FD, 0xB7EE, 0xB8FE, 0x8FAF, 0xB8FF, 0x8FB0,\t0xB900, 0x8FB1, 0xB901, 0x8FB2, 0xB902, 0x8FB3, 0xB903, 0x8FB4,\r\n\t0xB904, 0xB7EF, 0xB905, 0x8FB5, 0xB906, 0x8FB6, 0xB907, 0x8FB7,\t0xB908, 0x8FB8, 0xB909, 0x8FB9, 0xB90A, 0x8FBA, 0xB90B, 0x8FBB,\r\n\t0xB90C, 0x8FBC, 0xB90D, 0x8FBD, 0xB90E, 0x8FBE, 0xB90F, 0x8FBF,\t0xB910, 0x8FC0, 0xB911, 0x8FC1, 0xB912, 0x8FC2, 0xB913, 0x8FC3,\r\n\t0xB914, 0x8FC4, 0xB915, 0x8FC5, 0xB916, 0x8FC6, 0xB917, 0x8FC7,\t0xB918, 0xB7F0, 0xB919, 0x8FC8, 0xB91A, 0x8FC9, 0xB91B, 0x8FCA,\r\n\t0xB91C, 0x8FCB, 0xB91D, 0x8FCC, 0xB91E, 0x8FCD, 0xB91F, 0x8FCE,\t0xB920, 0xB7F1, 0xB921, 0x8FCF, 0xB922, 0x8FD0, 0xB923, 0x8FD1,\r\n\t0xB924, 0x8FD2, 0xB925, 0x8FD3, 0xB926, 0x8FD4, 0xB927, 0x8FD5,\t0xB928, 0x8FD6, 0xB929, 0x8FD7, 0xB92A, 0x8FD8, 0xB92B, 0x8FD9,\r\n\t0xB92C, 0x8FDA, 0xB92D, 0x8FDB, 0xB92E, 0x8FDC, 0xB92F, 0x8FDD,\t0xB930, 0x8FDE, 0xB931, 0x8FDF, 0xB932, 0x8FE0, 0xB933, 0x8FE1,\r\n\t0xB934, 0x8FE2, 0xB935, 0x8FE3, 0xB936, 0x8FE4, 0xB937, 0x8FE5,\t0xB938, 0x8FE6, 0xB939, 0x8FE7, 0xB93A, 0x8FE8, 0xB93B, 0x8FE9,\r\n\t0xB93C, 0xB7F2, 0xB93D, 0xB7F3, 0xB93E, 0x8FEA, 0xB93F, 0x8FEB,\t0xB940, 0xB7F4, 0xB941, 0x8FEC, 0xB942, 0x8FED, 0xB943, 0x8FEE,\r\n\t0xB944, 0xB7F5, 0xB945, 0x8FEF, 0xB946, 0x8FF0, 0xB947, 0x8FF1,\t0xB948, 0x8FF2, 0xB949, 0x8FF3, 0xB94A, 0x8FF4, 0xB94B, 0x8FF5,\r\n\t0xB94C, 0xB7F6, 0xB94D, 0x8FF6, 0xB94E, 0x8FF7, 0xB94F, 0xB7F7,\t0xB950, 0x8FF8, 0xB951, 0xB7F8, 0xB952, 0x8FF9, 0xB953, 0x8FFA,\r\n\t0xB954, 0x8FFB, 0xB955, 0x8FFC, 0xB956, 0x8FFD, 0xB957, 0x8FFE,\t0xB958, 0xB7F9, 0xB959, 0xB7FA, 0xB95A, 0x9041, 0xB95B, 0x9042,\r\n\t0xB95C, 0xB7FB, 0xB95D, 0x9043, 0xB95E, 0x9044, 0xB95F, 0x9045,\t0xB960, 0xB7FC, 0xB961, 0x9046, 0xB962, 0x9047, 0xB963, 0x9048,\r\n\t0xB964, 0x9049, 0xB965, 0x904A, 0xB966, 0x904B, 0xB967, 0x904C,\t0xB968, 0xB7FD, 0xB969, 0xB7FE, 0xB96A, 0x904D, 0xB96B, 0xB8A1,\r\n\t0xB96C, 0x904E, 0xB96D, 0xB8A2, 0xB96E, 0x904F, 0xB96F, 0x9050,\t0xB970, 0x9051, 0xB971, 0x9052, 0xB972, 0x9053, 0xB973, 0x9054,\r\n\t0xB974, 0xB8A3, 0xB975, 0xB8A4, 0xB976, 0x9055, 0xB977, 0x9056,\t0xB978, 0xB8A5, 0xB979, 0x9057, 0xB97A, 0x9058, 0xB97B, 0x9059,\r\n\t0xB97C, 0xB8A6, 0xB97D, 0x905A, 0xB97E, 0x9061, 0xB97F, 0x9062,\t0xB980, 0x9063, 0xB981, 0x9064, 0xB982, 0x9065, 0xB983, 0x9066,\r\n\t0xB984, 0xB8A7, 0xB985, 0xB8A8, 0xB986, 0x9067, 0xB987, 0xB8A9,\t0xB988, 0x9068, 0xB989, 0xB8AA, 0xB98A, 0xB8AB, 0xB98B, 0x9069,\r\n\t0xB98C, 0x906A, 0xB98D, 0xB8AC, 0xB98E, 0xB8AD, 0xB98F, 0x906B,\t0xB990, 0x906C, 0xB991, 0x906D, 0xB992, 0x906E, 0xB993, 0x906F,\r\n\t0xB994, 0x9070, 0xB995, 0x9071, 0xB996, 0x9072, 0xB997, 0x9073,\t0xB998, 0x9074, 0xB999, 0x9075, 0xB99A, 0x9076, 0xB99B, 0x9077,\r\n\t0xB99C, 0x9078, 0xB99D, 0x9079, 0xB99E, 0x907A, 0xB99F, 0x9081,\t0xB9A0, 0x9082, 0xB9A1, 0x9083, 0xB9A2, 0x9084, 0xB9A3, 0x9085,\r\n\t0xB9A4, 0x9086, 0xB9A5, 0x9087, 0xB9A6, 0x9088, 0xB9A7, 0x9089,\t0xB9A8, 0x908A, 0xB9A9, 0x908B, 0xB9AA, 0x908C, 0xB9AB, 0x908D,\r\n\t0xB9AC, 0xB8AE, 0xB9AD, 0xB8AF, 0xB9AE, 0x908E, 0xB9AF, 0x908F,\t0xB9B0, 0xB8B0, 0xB9B1, 0x9090, 0xB9B2, 0x9091, 0xB9B3, 0x9092,\r\n\t0xB9B4, 0xB8B1, 0xB9B5, 0x9093, 0xB9B6, 0x9094, 0xB9B7, 0x9095,\t0xB9B8, 0x9096, 0xB9B9, 0x9097, 0xB9BA, 0x9098, 0xB9BB, 0x9099,\r\n\t0xB9BC, 0xB8B2, 0xB9BD, 0xB8B3, 0xB9BE, 0x909A, 0xB9BF, 0xB8B4,\t0xB9C0, 0x909B, 0xB9C1, 0xB8B5, 0xB9C2, 0x909C, 0xB9C3, 0x909D,\r\n\t0xB9C4, 0x909E, 0xB9C5, 0x909F, 0xB9C6, 0x90A0, 0xB9C7, 0x90A1,\t0xB9C8, 0xB8B6, 0xB9C9, 0xB8B7, 0xB9CA, 0x90A2, 0xB9CB, 0x90A3,\r\n\t0xB9CC, 0xB8B8, 0xB9CD, 0x90A4, 0xB9CE, 0xB8B9, 0xB9CF, 0xB8BA,\t0xB9D0, 0xB8BB, 0xB9D1, 0xB8BC, 0xB9D2, 0xB8BD, 0xB9D3, 0x90A5,\r\n\t0xB9D4, 0x90A6, 0xB9D5, 0x90A7, 0xB9D6, 0x90A8, 0xB9D7, 0x90A9,\t0xB9D8, 0xB8BE, 0xB9D9, 0xB8BF, 0xB9DA, 0x90AA, 0xB9DB, 0xB8C0,\r\n\t0xB9DC, 0x90AB, 0xB9DD, 0xB8C1, 0xB9DE, 0xB8C2, 0xB9DF, 0x90AC,\t0xB9E0, 0x90AD, 0xB9E1, 0xB8C3, 0xB9E2, 0x90AE, 0xB9E3, 0xB8C4,\r\n\t0xB9E4, 0xB8C5, 0xB9E5, 0xB8C6, 0xB9E6, 0x90AF, 0xB9E7, 0x90B0,\t0xB9E8, 0xB8C7, 0xB9E9, 0x90B1, 0xB9EA, 0x90B2, 0xB9EB, 0x90B3,\r\n\t0xB9EC, 0xB8C8, 0xB9ED, 0x90B4, 0xB9EE, 0x90B5, 0xB9EF, 0x90B6,\t0xB9F0, 0x90B7, 0xB9F1, 0x90B8, 0xB9F2, 0x90B9, 0xB9F3, 0x90BA,\r\n\t0xB9F4, 0xB8C9, 0xB9F5, 0xB8CA, 0xB9F6, 0x90BB, 0xB9F7, 0xB8CB,\t0xB9F8, 0xB8CC, 0xB9F9, 0xB8CD, 0xB9FA, 0xB8CE, 0xB9FB, 0x90BC,\r\n\t0xB9FC, 0x90BD, 0xB9FD, 0x90BE, 0xB9FE, 0x90BF, 0xB9FF, 0x90C0,\t0xBA00, 0xB8CF, 0xBA01, 0xB8D0, 0xBA02, 0x90C1, 0xBA03, 0x90C2,\r\n\t0xBA04, 0x90C3, 0xBA05, 0x90C4, 0xBA06, 0x90C5, 0xBA07, 0x90C6,\t0xBA08, 0xB8D1, 0xBA09, 0x90C7, 0xBA0A, 0x90C8, 0xBA0B, 0x90C9,\r\n\t0xBA0C, 0x90CA, 0xBA0D, 0x90CB, 0xBA0E, 0x90CC, 0xBA0F, 0x90CD,\t0xBA10, 0x90CE, 0xBA11, 0x90CF, 0xBA12, 0x90D0, 0xBA13, 0x90D1,\r\n\t0xBA14, 0x90D2, 0xBA15, 0xB8D2, 0xBA16, 0x90D3, 0xBA17, 0x90D4,\t0xBA18, 0x90D5, 0xBA19, 0x90D6, 0xBA1A, 0x90D7, 0xBA1B, 0x90D8,\r\n\t0xBA1C, 0x90D9, 0xBA1D, 0x90DA, 0xBA1E, 0x90DB, 0xBA1F, 0x90DC,\t0xBA20, 0x90DD, 0xBA21, 0x90DE, 0xBA22, 0x90DF, 0xBA23, 0x90E0,\r\n\t0xBA24, 0x90E1, 0xBA25, 0x90E2, 0xBA26, 0x90E3, 0xBA27, 0x90E4,\t0xBA28, 0x90E5, 0xBA29, 0x90E6, 0xBA2A, 0x90E7, 0xBA2B, 0x90E8,\r\n\t0xBA2C, 0x90E9, 0xBA2D, 0x90EA, 0xBA2E, 0x90EB, 0xBA2F, 0x90EC,\t0xBA30, 0x90ED, 0xBA31, 0x90EE, 0xBA32, 0x90EF, 0xBA33, 0x90F0,\r\n\t0xBA34, 0x90F1, 0xBA35, 0x90F2, 0xBA36, 0x90F3, 0xBA37, 0x90F4,\t0xBA38, 0xB8D3, 0xBA39, 0xB8D4, 0xBA3A, 0x90F5, 0xBA3B, 0x90F6,\r\n\t0xBA3C, 0xB8D5, 0xBA3D, 0x90F7, 0xBA3E, 0x90F8, 0xBA3F, 0x90F9,\t0xBA40, 0xB8D6, 0xBA41, 0x90FA, 0xBA42, 0xB8D7, 0xBA43, 0x90FB,\r\n\t0xBA44, 0x90FC, 0xBA45, 0x90FD, 0xBA46, 0x90FE, 0xBA47, 0x9141,\t0xBA48, 0xB8D8, 0xBA49, 0xB8D9, 0xBA4A, 0x9142, 0xBA4B, 0xB8DA,\r\n\t0xBA4C, 0x9143, 0xBA4D, 0xB8DB, 0xBA4E, 0xB8DC, 0xBA4F, 0x9144,\t0xBA50, 0x9145, 0xBA51, 0x9146, 0xBA52, 0x9147, 0xBA53, 0xB8DD,\r\n\t0xBA54, 0xB8DE, 0xBA55, 0xB8DF, 0xBA56, 0x9148, 0xBA57, 0x9149,\t0xBA58, 0xB8E0, 0xBA59, 0x914A, 0xBA5A, 0x914B, 0xBA5B, 0x914C,\r\n\t0xBA5C, 0xB8E1, 0xBA5D, 0x914D, 0xBA5E, 0x914E, 0xBA5F, 0x914F,\t0xBA60, 0x9150, 0xBA61, 0x9151, 0xBA62, 0x9152, 0xBA63, 0x9153,\r\n\t0xBA64, 0xB8E2, 0xBA65, 0xB8E3, 0xBA66, 0x9154, 0xBA67, 0xB8E4,\t0xBA68, 0xB8E5, 0xBA69, 0xB8E6, 0xBA6A, 0x9155, 0xBA6B, 0x9156,\r\n\t0xBA6C, 0x9157, 0xBA6D, 0x9158, 0xBA6E, 0x9159, 0xBA6F, 0x915A,\t0xBA70, 0xB8E7, 0xBA71, 0xB8E8, 0xBA72, 0x9161, 0xBA73, 0x9162,\r\n\t0xBA74, 0xB8E9, 0xBA75, 0x9163, 0xBA76, 0x9164, 0xBA77, 0x9165,\t0xBA78, 0xB8EA, 0xBA79, 0x9166, 0xBA7A, 0x9167, 0xBA7B, 0x9168,\r\n\t0xBA7C, 0x9169, 0xBA7D, 0x916A, 0xBA7E, 0x916B, 0xBA7F, 0x916C,\t0xBA80, 0x916D, 0xBA81, 0x916E, 0xBA82, 0x916F, 0xBA83, 0xB8EB,\r\n\t0xBA84, 0xB8EC, 0xBA85, 0xB8ED, 0xBA86, 0x9170, 0xBA87, 0xB8EE,\t0xBA88, 0x9171, 0xBA89, 0x9172, 0xBA8A, 0x9173, 0xBA8B, 0x9174,\r\n\t0xBA8C, 0xB8EF, 0xBA8D, 0x9175, 0xBA8E, 0x9176, 0xBA8F, 0x9177,\t0xBA90, 0x9178, 0xBA91, 0x9179, 0xBA92, 0x917A, 0xBA93, 0x9181,\r\n\t0xBA94, 0x9182, 0xBA95, 0x9183, 0xBA96, 0x9184, 0xBA97, 0x9185,\t0xBA98, 0x9186, 0xBA99, 0x9187, 0xBA9A, 0x9188, 0xBA9B, 0x9189,\r\n\t0xBA9C, 0x918A, 0xBA9D, 0x918B, 0xBA9E, 0x918C, 0xBA9F, 0x918D,\t0xBAA0, 0x918E, 0xBAA1, 0x918F, 0xBAA2, 0x9190, 0xBAA3, 0x9191,\r\n\t0xBAA4, 0x9192, 0xBAA5, 0x9193, 0xBAA6, 0x9194, 0xBAA7, 0x9195,\t0xBAA8, 0xB8F0, 0xBAA9, 0xB8F1, 0xBAAA, 0x9196, 0xBAAB, 0xB8F2,\r\n\t0xBAAC, 0xB8F3, 0xBAAD, 0x9197, 0xBAAE, 0x9198, 0xBAAF, 0x9199,\t0xBAB0, 0xB8F4, 0xBAB1, 0x919A, 0xBAB2, 0xB8F5, 0xBAB3, 0x919B,\r\n\t0xBAB4, 0x919C, 0xBAB5, 0x919D, 0xBAB6, 0x919E, 0xBAB7, 0x919F,\t0xBAB8, 0xB8F6, 0xBAB9, 0xB8F7, 0xBABA, 0x91A0, 0xBABB, 0xB8F8,\r\n\t0xBABC, 0x91A1, 0xBABD, 0xB8F9, 0xBABE, 0x91A2, 0xBABF, 0x91A3,\t0xBAC0, 0x91A4, 0xBAC1, 0x91A5, 0xBAC2, 0x91A6, 0xBAC3, 0x91A7,\r\n\t0xBAC4, 0xB8FA, 0xBAC5, 0x91A8, 0xBAC6, 0x91A9, 0xBAC7, 0x91AA,\t0xBAC8, 0xB8FB, 0xBAC9, 0x91AB, 0xBACA, 0x91AC, 0xBACB, 0x91AD,\r\n\t0xBACC, 0x91AE, 0xBACD, 0x91AF, 0xBACE, 0x91B0, 0xBACF, 0x91B1,\t0xBAD0, 0x91B2, 0xBAD1, 0x91B3, 0xBAD2, 0x91B4, 0xBAD3, 0x91B5,\r\n\t0xBAD4, 0x91B6, 0xBAD5, 0x91B7, 0xBAD6, 0x91B8, 0xBAD7, 0x91B9,\t0xBAD8, 0xB8FC, 0xBAD9, 0xB8FD, 0xBADA, 0x91BA, 0xBADB, 0x91BB,\r\n\t0xBADC, 0x91BC, 0xBADD, 0x91BD, 0xBADE, 0x91BE, 0xBADF, 0x91BF,\t0xBAE0, 0x91C0, 0xBAE1, 0x91C1, 0xBAE2, 0x91C2, 0xBAE3, 0x91C3,\r\n\t0xBAE4, 0x91C4, 0xBAE5, 0x91C5, 0xBAE6, 0x91C6, 0xBAE7, 0x91C7,\t0xBAE8, 0x91C8, 0xBAE9, 0x91C9, 0xBAEA, 0x91CA, 0xBAEB, 0x91CB,\r\n\t0xBAEC, 0x91CC, 0xBAED, 0x91CD, 0xBAEE, 0x91CE, 0xBAEF, 0x91CF,\t0xBAF0, 0x91D0, 0xBAF1, 0x91D1, 0xBAF2, 0x91D2, 0xBAF3, 0x91D3,\r\n\t0xBAF4, 0x91D4, 0xBAF5, 0x91D5, 0xBAF6, 0x91D6, 0xBAF7, 0x91D7,\t0xBAF8, 0x91D8, 0xBAF9, 0x91D9, 0xBAFA, 0x91DA, 0xBAFB, 0x91DB,\r\n\t0xBAFC, 0xB8FE, 0xBAFD, 0x91DC, 0xBAFE, 0x91DD, 0xBAFF, 0x91DE,\t0xBB00, 0xB9A1, 0xBB01, 0x91DF, 0xBB02, 0x91E0, 0xBB03, 0x91E1,\r\n\t0xBB04, 0xB9A2, 0xBB05, 0x91E2, 0xBB06, 0x91E3, 0xBB07, 0x91E4,\t0xBB08, 0x91E5, 0xBB09, 0x91E6, 0xBB0A, 0x91E7, 0xBB0B, 0x91E8,\r\n\t0xBB0C, 0x91E9, 0xBB0D, 0xB9A3, 0xBB0E, 0x91EA, 0xBB0F, 0xB9A4,\t0xBB10, 0x91EB, 0xBB11, 0xB9A5, 0xBB12, 0x91EC, 0xBB13, 0x91ED,\r\n\t0xBB14, 0x91EE, 0xBB15, 0x91EF, 0xBB16, 0x91F0, 0xBB17, 0x91F1,\t0xBB18, 0xB9A6, 0xBB19, 0x91F2, 0xBB1A, 0x91F3, 0xBB1B, 0x91F4,\r\n\t0xBB1C, 0xB9A7, 0xBB1D, 0x91F5, 0xBB1E, 0x91F6, 0xBB1F, 0x91F7,\t0xBB20, 0xB9A8, 0xBB21, 0x91F8, 0xBB22, 0x91F9, 0xBB23, 0x91FA,\r\n\t0xBB24, 0x91FB, 0xBB25, 0x91FC, 0xBB26, 0x91FD, 0xBB27, 0x91FE,\t0xBB28, 0x9241, 0xBB29, 0xB9A9, 0xBB2A, 0x9242, 0xBB2B, 0xB9AA,\r\n\t0xBB2C, 0x9243, 0xBB2D, 0x9244, 0xBB2E, 0x9245, 0xBB2F, 0x9246,\t0xBB30, 0x9247, 0xBB31, 0x9248, 0xBB32, 0x9249, 0xBB33, 0x924A,\r\n\t0xBB34, 0xB9AB, 0xBB35, 0xB9AC, 0xBB36, 0xB9AD, 0xBB37, 0x924B,\t0xBB38, 0xB9AE, 0xBB39, 0x924C, 0xBB3A, 0x924D, 0xBB3B, 0xB9AF,\r\n\t0xBB3C, 0xB9B0, 0xBB3D, 0xB9B1, 0xBB3E, 0xB9B2, 0xBB3F, 0x924E,\t0xBB40, 0x924F, 0xBB41, 0x9250, 0xBB42, 0x9251, 0xBB43, 0x9252,\r\n\t0xBB44, 0xB9B3, 0xBB45, 0xB9B4, 0xBB46, 0x9253, 0xBB47, 0xB9B5,\t0xBB48, 0x9254, 0xBB49, 0xB9B6, 0xBB4A, 0x9255, 0xBB4B, 0x9256,\r\n\t0xBB4C, 0x9257, 0xBB4D, 0xB9B7, 0xBB4E, 0x9258, 0xBB4F, 0xB9B8,\t0xBB50, 0xB9B9, 0xBB51, 0x9259, 0xBB52, 0x925A, 0xBB53, 0x9261,\r\n\t0xBB54, 0xB9BA, 0xBB55, 0x9262, 0xBB56, 0x9263, 0xBB57, 0x9264,\t0xBB58, 0xB9BB, 0xBB59, 0x9265, 0xBB5A, 0x9266, 0xBB5B, 0x9267,\r\n\t0xBB5C, 0x9268, 0xBB5D, 0x9269, 0xBB5E, 0x926A, 0xBB5F, 0x926B,\t0xBB60, 0x926C, 0xBB61, 0xB9BC, 0xBB62, 0x926D, 0xBB63, 0xB9BD,\r\n\t0xBB64, 0x926E, 0xBB65, 0x926F, 0xBB66, 0x9270, 0xBB67, 0x9271,\t0xBB68, 0x9272, 0xBB69, 0x9273, 0xBB6A, 0x9274, 0xBB6B, 0x9275,\r\n\t0xBB6C, 0xB9BE, 0xBB6D, 0x9276, 0xBB6E, 0x9277, 0xBB6F, 0x9278,\t0xBB70, 0x9279, 0xBB71, 0x927A, 0xBB72, 0x9281, 0xBB73, 0x9282,\r\n\t0xBB74, 0x9283, 0xBB75, 0x9284, 0xBB76, 0x9285, 0xBB77, 0x9286,\t0xBB78, 0x9287, 0xBB79, 0x9288, 0xBB7A, 0x9289, 0xBB7B, 0x928A,\r\n\t0xBB7C, 0x928B, 0xBB7D, 0x928C, 0xBB7E, 0x928D, 0xBB7F, 0x928E,\t0xBB80, 0x928F, 0xBB81, 0x9290, 0xBB82, 0x9291, 0xBB83, 0x9292,\r\n\t0xBB84, 0x9293, 0xBB85, 0x9294, 0xBB86, 0x9295, 0xBB87, 0x9296,\t0xBB88, 0xB9BF, 0xBB89, 0x9297, 0xBB8A, 0x9298, 0xBB8B, 0x9299,\r\n\t0xBB8C, 0xB9C0, 0xBB8D, 0x929A, 0xBB8E, 0x929B, 0xBB8F, 0x929C,\t0xBB90, 0xB9C1, 0xBB91, 0x929D, 0xBB92, 0x929E, 0xBB93, 0x929F,\r\n\t0xBB94, 0x92A0, 0xBB95, 0x92A1, 0xBB96, 0x92A2, 0xBB97, 0x92A3,\t0xBB98, 0x92A4, 0xBB99, 0x92A5, 0xBB9A, 0x92A6, 0xBB9B, 0x92A7,\r\n\t0xBB9C, 0x92A8, 0xBB9D, 0x92A9, 0xBB9E, 0x92AA, 0xBB9F, 0x92AB,\t0xBBA0, 0x92AC, 0xBBA1, 0x92AD, 0xBBA2, 0x92AE, 0xBBA3, 0x92AF,\r\n\t0xBBA4, 0xB9C2, 0xBBA5, 0x92B0, 0xBBA6, 0x92B1, 0xBBA7, 0x92B2,\t0xBBA8, 0xB9C3, 0xBBA9, 0x92B3, 0xBBAA, 0x92B4, 0xBBAB, 0x92B5,\r\n\t0xBBAC, 0xB9C4, 0xBBAD, 0x92B6, 0xBBAE, 0x92B7, 0xBBAF, 0x92B8,\t0xBBB0, 0x92B9, 0xBBB1, 0x92BA, 0xBBB2, 0x92BB, 0xBBB3, 0x92BC,\r\n\t0xBBB4, 0xB9C5, 0xBBB5, 0x92BD, 0xBBB6, 0x92BE, 0xBBB7, 0xB9C6,\t0xBBB8, 0x92BF, 0xBBB9, 0x92C0, 0xBBBA, 0x92C1, 0xBBBB, 0x92C2,\r\n\t0xBBBC, 0x92C3, 0xBBBD, 0x92C4, 0xBBBE, 0x92C5, 0xBBBF, 0x92C6,\t0xBBC0, 0xB9C7, 0xBBC1, 0x92C7, 0xBBC2, 0x92C8, 0xBBC3, 0x92C9,\r\n\t0xBBC4, 0xB9C8, 0xBBC5, 0x92CA, 0xBBC6, 0x92CB, 0xBBC7, 0x92CC,\t0xBBC8, 0xB9C9, 0xBBC9, 0x92CD, 0xBBCA, 0x92CE, 0xBBCB, 0x92CF,\r\n\t0xBBCC, 0x92D0, 0xBBCD, 0x92D1, 0xBBCE, 0x92D2, 0xBBCF, 0x92D3,\t0xBBD0, 0xB9CA, 0xBBD1, 0x92D4, 0xBBD2, 0x92D5, 0xBBD3, 0xB9CB,\r\n\t0xBBD4, 0x92D6, 0xBBD5, 0x92D7, 0xBBD6, 0x92D8, 0xBBD7, 0x92D9,\t0xBBD8, 0x92DA, 0xBBD9, 0x92DB, 0xBBDA, 0x92DC, 0xBBDB, 0x92DD,\r\n\t0xBBDC, 0x92DE, 0xBBDD, 0x92DF, 0xBBDE, 0x92E0, 0xBBDF, 0x92E1,\t0xBBE0, 0x92E2, 0xBBE1, 0x92E3, 0xBBE2, 0x92E4, 0xBBE3, 0x92E5,\r\n\t0xBBE4, 0x92E6, 0xBBE5, 0x92E7, 0xBBE6, 0x92E8, 0xBBE7, 0x92E9,\t0xBBE8, 0x92EA, 0xBBE9, 0x92EB, 0xBBEA, 0x92EC, 0xBBEB, 0x92ED,\r\n\t0xBBEC, 0x92EE, 0xBBED, 0x92EF, 0xBBEE, 0x92F0, 0xBBEF, 0x92F1,\t0xBBF0, 0x92F2, 0xBBF1, 0x92F3, 0xBBF2, 0x92F4, 0xBBF3, 0x92F5,\r\n\t0xBBF4, 0x92F6, 0xBBF5, 0x92F7, 0xBBF6, 0x92F8, 0xBBF7, 0x92F9,\t0xBBF8, 0xB9CC, 0xBBF9, 0xB9CD, 0xBBFA, 0x92FA, 0xBBFB, 0x92FB,\r\n\t0xBBFC, 0xB9CE, 0xBBFD, 0x92FC, 0xBBFE, 0x92FD, 0xBBFF, 0xB9CF,\t0xBC00, 0xB9D0, 0xBC01, 0x92FE, 0xBC02, 0xB9D1, 0xBC03, 0x9341,\r\n\t0xBC04, 0x9342, 0xBC05, 0x9343, 0xBC06, 0x9344, 0xBC07, 0x9345,\t0xBC08, 0xB9D2, 0xBC09, 0xB9D3, 0xBC0A, 0x9346, 0xBC0B, 0xB9D4,\r\n\t0xBC0C, 0xB9D5, 0xBC0D, 0xB9D6, 0xBC0E, 0x9347, 0xBC0F, 0xB9D7,\t0xBC10, 0x9348, 0xBC11, 0xB9D8, 0xBC12, 0x9349, 0xBC13, 0x934A,\r\n\t0xBC14, 0xB9D9, 0xBC15, 0xB9DA, 0xBC16, 0xB9DB, 0xBC17, 0xB9DC,\t0xBC18, 0xB9DD, 0xBC19, 0x934B, 0xBC1A, 0x934C, 0xBC1B, 0xB9DE,\r\n\t0xBC1C, 0xB9DF, 0xBC1D, 0xB9E0, 0xBC1E, 0xB9E1, 0xBC1F, 0xB9E2,\t0xBC20, 0x934D, 0xBC21, 0x934E, 0xBC22, 0x934F, 0xBC23, 0x9350,\r\n\t0xBC24, 0xB9E3, 0xBC25, 0xB9E4, 0xBC26, 0x9351, 0xBC27, 0xB9E5,\t0xBC28, 0x9352, 0xBC29, 0xB9E6, 0xBC2A, 0x9353, 0xBC2B, 0x9354,\r\n\t0xBC2C, 0x9355, 0xBC2D, 0xB9E7, 0xBC2E, 0x9356, 0xBC2F, 0x9357,\t0xBC30, 0xB9E8, 0xBC31, 0xB9E9, 0xBC32, 0x9358, 0xBC33, 0x9359,\r\n\t0xBC34, 0xB9EA, 0xBC35, 0x935A, 0xBC36, 0x9361, 0xBC37, 0x9362,\t0xBC38, 0xB9EB, 0xBC39, 0x9363, 0xBC3A, 0x9364, 0xBC3B, 0x9365,\r\n\t0xBC3C, 0x9366, 0xBC3D, 0x9367, 0xBC3E, 0x9368, 0xBC3F, 0x9369,\t0xBC40, 0xB9EC, 0xBC41, 0xB9ED, 0xBC42, 0x936A, 0xBC43, 0xB9EE,\r\n\t0xBC44, 0xB9EF, 0xBC45, 0xB9F0, 0xBC46, 0x936B, 0xBC47, 0x936C,\t0xBC48, 0x936D, 0xBC49, 0xB9F1, 0xBC4A, 0x936E, 0xBC4B, 0x936F,\r\n\t0xBC4C, 0xB9F2, 0xBC4D, 0xB9F3, 0xBC4E, 0x9370, 0xBC4F, 0x9371,\t0xBC50, 0xB9F4, 0xBC51, 0x9372, 0xBC52, 0x9373, 0xBC53, 0x9374,\r\n\t0xBC54, 0x9375, 0xBC55, 0x9376, 0xBC56, 0x9377, 0xBC57, 0x9378,\t0xBC58, 0x9379, 0xBC59, 0x937A, 0xBC5A, 0x9381, 0xBC5B, 0x9382,\r\n\t0xBC5C, 0x9383, 0xBC5D, 0xB9F5, 0xBC5E, 0x9384, 0xBC5F, 0x9385,\t0xBC60, 0x9386, 0xBC61, 0x9387, 0xBC62, 0x9388, 0xBC63, 0x9389,\r\n\t0xBC64, 0x938A, 0xBC65, 0x938B, 0xBC66, 0x938C, 0xBC67, 0x938D,\t0xBC68, 0x938E, 0xBC69, 0x938F, 0xBC6A, 0x9390, 0xBC6B, 0x9391,\r\n\t0xBC6C, 0x9392, 0xBC6D, 0x9393, 0xBC6E, 0x9394, 0xBC6F, 0x9395,\t0xBC70, 0x9396, 0xBC71, 0x9397, 0xBC72, 0x9398, 0xBC73, 0x9399,\r\n\t0xBC74, 0x939A, 0xBC75, 0x939B, 0xBC76, 0x939C, 0xBC77, 0x939D,\t0xBC78, 0x939E, 0xBC79, 0x939F, 0xBC7A, 0x93A0, 0xBC7B, 0x93A1,\r\n\t0xBC7C, 0x93A2, 0xBC7D, 0x93A3, 0xBC7E, 0x93A4, 0xBC7F, 0x93A5,\t0xBC80, 0x93A6, 0xBC81, 0x93A7, 0xBC82, 0x93A8, 0xBC83, 0x93A9,\r\n\t0xBC84, 0xB9F6, 0xBC85, 0xB9F7, 0xBC86, 0x93AA, 0xBC87, 0x93AB,\t0xBC88, 0xB9F8, 0xBC89, 0x93AC, 0xBC8A, 0x93AD, 0xBC8B, 0xB9F9,\r\n\t0xBC8C, 0xB9FA, 0xBC8D, 0x93AE, 0xBC8E, 0xB9FB, 0xBC8F, 0x93AF,\t0xBC90, 0x93B0, 0xBC91, 0x93B1, 0xBC92, 0x93B2, 0xBC93, 0x93B3,\r\n\t0xBC94, 0xB9FC, 0xBC95, 0xB9FD, 0xBC96, 0x93B4, 0xBC97, 0xB9FE,\t0xBC98, 0x93B5, 0xBC99, 0xBAA1, 0xBC9A, 0xBAA2, 0xBC9B, 0x93B6,\r\n\t0xBC9C, 0x93B7, 0xBC9D, 0x93B8, 0xBC9E, 0x93B9, 0xBC9F, 0x93BA,\t0xBCA0, 0xBAA3, 0xBCA1, 0xBAA4, 0xBCA2, 0x93BB, 0xBCA3, 0x93BC,\r\n\t0xBCA4, 0xBAA5, 0xBCA5, 0x93BD, 0xBCA6, 0x93BE, 0xBCA7, 0xBAA6,\t0xBCA8, 0xBAA7, 0xBCA9, 0x93BF, 0xBCAA, 0x93C0, 0xBCAB, 0x93C1,\r\n\t0xBCAC, 0x93C2, 0xBCAD, 0x93C3, 0xBCAE, 0x93C4, 0xBCAF, 0x93C5,\t0xBCB0, 0xBAA8, 0xBCB1, 0xBAA9, 0xBCB2, 0x93C6, 0xBCB3, 0xBAAA,\r\n\t0xBCB4, 0xBAAB, 0xBCB5, 0xBAAC, 0xBCB6, 0x93C7, 0xBCB7, 0x93C8,\t0xBCB8, 0x93C9, 0xBCB9, 0x93CA, 0xBCBA, 0x93CB, 0xBCBB, 0x93CC,\r\n\t0xBCBC, 0xBAAD, 0xBCBD, 0xBAAE, 0xBCBE, 0x93CD, 0xBCBF, 0x93CE,\t0xBCC0, 0xBAAF, 0xBCC1, 0x93CF, 0xBCC2, 0x93D0, 0xBCC3, 0x93D1,\r\n\t0xBCC4, 0xBAB0, 0xBCC5, 0x93D2, 0xBCC6, 0x93D3, 0xBCC7, 0x93D4,\t0xBCC8, 0x93D5, 0xBCC9, 0x93D6, 0xBCCA, 0x93D7, 0xBCCB, 0x93D8,\r\n\t0xBCCC, 0x93D9, 0xBCCD, 0xBAB1, 0xBCCE, 0x93DA, 0xBCCF, 0xBAB2,\t0xBCD0, 0xBAB3, 0xBCD1, 0xBAB4, 0xBCD2, 0x93DB, 0xBCD3, 0x93DC,\r\n\t0xBCD4, 0x93DD, 0xBCD5, 0xBAB5, 0xBCD6, 0x93DE, 0xBCD7, 0x93DF,\t0xBCD8, 0xBAB6, 0xBCD9, 0x93E0, 0xBCDA, 0x93E1, 0xBCDB, 0x93E2,\r\n\t0xBCDC, 0xBAB7, 0xBCDD, 0x93E3, 0xBCDE, 0x93E4, 0xBCDF, 0x93E5,\t0xBCE0, 0x93E6, 0xBCE1, 0x93E7, 0xBCE2, 0x93E8, 0xBCE3, 0x93E9,\r\n\t0xBCE4, 0x93EA, 0xBCE5, 0x93EB, 0xBCE6, 0x93EC, 0xBCE7, 0x93ED,\t0xBCE8, 0x93EE, 0xBCE9, 0x93EF, 0xBCEA, 0x93F0, 0xBCEB, 0x93F1,\r\n\t0xBCEC, 0x93F2, 0xBCED, 0x93F3, 0xBCEE, 0x93F4, 0xBCEF, 0x93F5,\t0xBCF0, 0x93F6, 0xBCF1, 0x93F7, 0xBCF2, 0x93F8, 0xBCF3, 0x93F9,\r\n\t0xBCF4, 0xBAB8, 0xBCF5, 0xBAB9, 0xBCF6, 0xBABA, 0xBCF7, 0x93FA,\t0xBCF8, 0xBABB, 0xBCF9, 0x93FB, 0xBCFA, 0x93FC, 0xBCFB, 0x93FD,\r\n\t0xBCFC, 0xBABC, 0xBCFD, 0x93FE, 0xBCFE, 0x9441, 0xBCFF, 0x9442,\t0xBD00, 0x9443, 0xBD01, 0x9444, 0xBD02, 0x9445, 0xBD03, 0x9446,\r\n\t0xBD04, 0xBABD, 0xBD05, 0xBABE, 0xBD06, 0x9447, 0xBD07, 0xBABF,\t0xBD08, 0x9448, 0xBD09, 0xBAC0, 0xBD0A, 0x9449, 0xBD0B, 0x944A,\r\n\t0xBD0C, 0x944B, 0xBD0D, 0x944C, 0xBD0E, 0x944D, 0xBD0F, 0x944E,\t0xBD10, 0xBAC1, 0xBD11, 0x944F, 0xBD12, 0x9450, 0xBD13, 0x9451,\r\n\t0xBD14, 0xBAC2, 0xBD15, 0x9452, 0xBD16, 0x9453, 0xBD17, 0x9454,\t0xBD18, 0x9455, 0xBD19, 0x9456, 0xBD1A, 0x9457, 0xBD1B, 0x9458,\r\n\t0xBD1C, 0x9459, 0xBD1D, 0x945A, 0xBD1E, 0x9461, 0xBD1F, 0x9462,\t0xBD20, 0x9463, 0xBD21, 0x9464, 0xBD22, 0x9465, 0xBD23, 0x9466,\r\n\t0xBD24, 0xBAC3, 0xBD25, 0x9467, 0xBD26, 0x9468, 0xBD27, 0x9469,\t0xBD28, 0x946A, 0xBD29, 0x946B, 0xBD2A, 0x946C, 0xBD2B, 0x946D,\r\n\t0xBD2C, 0xBAC4, 0xBD2D, 0x946E, 0xBD2E, 0x946F, 0xBD2F, 0x9470,\t0xBD30, 0x9471, 0xBD31, 0x9472, 0xBD32, 0x9473, 0xBD33, 0x9474,\r\n\t0xBD34, 0x9475, 0xBD35, 0x9476, 0xBD36, 0x9477, 0xBD37, 0x9478,\t0xBD38, 0x9479, 0xBD39, 0x947A, 0xBD3A, 0x9481, 0xBD3B, 0x9482,\r\n\t0xBD3C, 0x9483, 0xBD3D, 0x9484, 0xBD3E, 0x9485, 0xBD3F, 0x9486,\t0xBD40, 0xBAC5, 0xBD41, 0x9487, 0xBD42, 0x9488, 0xBD43, 0x9489,\r\n\t0xBD44, 0x948A, 0xBD45, 0x948B, 0xBD46, 0x948C, 0xBD47, 0x948D,\t0xBD48, 0xBAC6, 0xBD49, 0xBAC7, 0xBD4A, 0x948E, 0xBD4B, 0x948F,\r\n\t0xBD4C, 0xBAC8, 0xBD4D, 0x9490, 0xBD4E, 0x9491, 0xBD4F, 0x9492,\t0xBD50, 0xBAC9, 0xBD51, 0x9493, 0xBD52, 0x9494, 0xBD53, 0x9495,\r\n\t0xBD54, 0x9496, 0xBD55, 0x9497, 0xBD56, 0x9498, 0xBD57, 0x9499,\t0xBD58, 0xBACA, 0xBD59, 0xBACB, 0xBD5A, 0x949A, 0xBD5B, 0x949B,\r\n\t0xBD5C, 0x949C, 0xBD5D, 0x949D, 0xBD5E, 0x949E, 0xBD5F, 0x949F,\t0xBD60, 0x94A0, 0xBD61, 0x94A1, 0xBD62, 0x94A2, 0xBD63, 0x94A3,\r\n\t0xBD64, 0xBACC, 0xBD65, 0x94A4, 0xBD66, 0x94A5, 0xBD67, 0x94A6,\t0xBD68, 0xBACD, 0xBD69, 0x94A7, 0xBD6A, 0x94A8, 0xBD6B, 0x94A9,\r\n\t0xBD6C, 0x94AA, 0xBD6D, 0x94AB, 0xBD6E, 0x94AC, 0xBD6F, 0x94AD,\t0xBD70, 0x94AE, 0xBD71, 0x94AF, 0xBD72, 0x94B0, 0xBD73, 0x94B1,\r\n\t0xBD74, 0x94B2, 0xBD75, 0x94B3, 0xBD76, 0x94B4, 0xBD77, 0x94B5,\t0xBD78, 0x94B6, 0xBD79, 0x94B7, 0xBD7A, 0x94B8, 0xBD7B, 0x94B9,\r\n\t0xBD7C, 0x94BA, 0xBD7D, 0x94BB, 0xBD7E, 0x94BC, 0xBD7F, 0x94BD,\t0xBD80, 0xBACE, 0xBD81, 0xBACF, 0xBD82, 0x94BE, 0xBD83, 0x94BF,\r\n\t0xBD84, 0xBAD0, 0xBD85, 0x94C0, 0xBD86, 0x94C1, 0xBD87, 0xBAD1,\t0xBD88, 0xBAD2, 0xBD89, 0xBAD3, 0xBD8A, 0xBAD4, 0xBD8B, 0x94C2,\r\n\t0xBD8C, 0x94C3, 0xBD8D, 0x94C4, 0xBD8E, 0x94C5, 0xBD8F, 0x94C6,\t0xBD90, 0xBAD5, 0xBD91, 0xBAD6, 0xBD92, 0x94C7, 0xBD93, 0xBAD7,\r\n\t0xBD94, 0x94C8, 0xBD95, 0xBAD8, 0xBD96, 0x94C9, 0xBD97, 0x94CA,\t0xBD98, 0x94CB, 0xBD99, 0xBAD9, 0xBD9A, 0xBADA, 0xBD9B, 0x94CC,\r\n\t0xBD9C, 0xBADB, 0xBD9D, 0x94CD, 0xBD9E, 0x94CE, 0xBD9F, 0x94CF,\t0xBDA0, 0x94D0, 0xBDA1, 0x94D1, 0xBDA2, 0x94D2, 0xBDA3, 0x94D3,\r\n\t0xBDA4, 0xBADC, 0xBDA5, 0x94D4, 0xBDA6, 0x94D5, 0xBDA7, 0x94D6,\t0xBDA8, 0x94D7, 0xBDA9, 0x94D8, 0xBDAA, 0x94D9, 0xBDAB, 0x94DA,\r\n\t0xBDAC, 0x94DB, 0xBDAD, 0x94DC, 0xBDAE, 0x94DD, 0xBDAF, 0x94DE,\t0xBDB0, 0xBADD, 0xBDB1, 0x94DF, 0xBDB2, 0x94E0, 0xBDB3, 0x94E1,\r\n\t0xBDB4, 0x94E2, 0xBDB5, 0x94E3, 0xBDB6, 0x94E4, 0xBDB7, 0x94E5,\t0xBDB8, 0xBADE, 0xBDB9, 0x94E6, 0xBDBA, 0x94E7, 0xBDBB, 0x94E8,\r\n\t0xBDBC, 0x94E9, 0xBDBD, 0x94EA, 0xBDBE, 0x94EB, 0xBDBF, 0x94EC,\t0xBDC0, 0x94ED, 0xBDC1, 0x94EE, 0xBDC2, 0x94EF, 0xBDC3, 0x94F0,\r\n\t0xBDC4, 0x94F1, 0xBDC5, 0x94F2, 0xBDC6, 0x94F3, 0xBDC7, 0x94F4,\t0xBDC8, 0x94F5, 0xBDC9, 0x94F6, 0xBDCA, 0x94F7, 0xBDCB, 0x94F8,\r\n\t0xBDCC, 0x94F9, 0xBDCD, 0x94FA, 0xBDCE, 0x94FB, 0xBDCF, 0x94FC,\t0xBDD0, 0x94FD, 0xBDD1, 0x94FE, 0xBDD2, 0x9541, 0xBDD3, 0x9542,\r\n\t0xBDD4, 0xBADF, 0xBDD5, 0xBAE0, 0xBDD6, 0x9543, 0xBDD7, 0x9544,\t0xBDD8, 0xBAE1, 0xBDD9, 0x9545, 0xBDDA, 0x9546, 0xBDDB, 0x9547,\r\n\t0xBDDC, 0xBAE2, 0xBDDD, 0x9548, 0xBDDE, 0x9549, 0xBDDF, 0x954A,\t0xBDE0, 0x954B, 0xBDE1, 0x954C, 0xBDE2, 0x954D, 0xBDE3, 0x954E,\r\n\t0xBDE4, 0x954F, 0xBDE5, 0x9550, 0xBDE6, 0x9551, 0xBDE7, 0x9552,\t0xBDE8, 0x9553, 0xBDE9, 0xBAE3, 0xBDEA, 0x9554, 0xBDEB, 0x9555,\r\n\t0xBDEC, 0x9556, 0xBDED, 0x9557, 0xBDEE, 0x9558, 0xBDEF, 0x9559,\t0xBDF0, 0xBAE4, 0xBDF1, 0x955A, 0xBDF2, 0x9561, 0xBDF3, 0x9562,\r\n\t0xBDF4, 0xBAE5, 0xBDF5, 0x9563, 0xBDF6, 0x9564, 0xBDF7, 0x9565,\t0xBDF8, 0xBAE6, 0xBDF9, 0x9566, 0xBDFA, 0x9567, 0xBDFB, 0x9568,\r\n\t0xBDFC, 0x9569, 0xBDFD, 0x956A, 0xBDFE, 0x956B, 0xBDFF, 0x956C,\t0xBE00, 0xBAE7, 0xBE01, 0x956D, 0xBE02, 0x956E, 0xBE03, 0xBAE8,\r\n\t0xBE04, 0x956F, 0xBE05, 0xBAE9, 0xBE06, 0x9570, 0xBE07, 0x9571,\t0xBE08, 0x9572, 0xBE09, 0x9573, 0xBE0A, 0x9574, 0xBE0B, 0x9575,\r\n\t0xBE0C, 0xBAEA, 0xBE0D, 0xBAEB, 0xBE0E, 0x9576, 0xBE0F, 0x9577,\t0xBE10, 0xBAEC, 0xBE11, 0x9578, 0xBE12, 0x9579, 0xBE13, 0x957A,\r\n\t0xBE14, 0xBAED, 0xBE15, 0x9581, 0xBE16, 0x9582, 0xBE17, 0x9583,\t0xBE18, 0x9584, 0xBE19, 0x9585, 0xBE1A, 0x9586, 0xBE1B, 0x9587,\r\n\t0xBE1C, 0xBAEE, 0xBE1D, 0xBAEF, 0xBE1E, 0x9588, 0xBE1F, 0xBAF0,\t0xBE20, 0x9589, 0xBE21, 0x958A, 0xBE22, 0x958B, 0xBE23, 0x958C,\r\n\t0xBE24, 0x958D, 0xBE25, 0x958E, 0xBE26, 0x958F, 0xBE27, 0x9590,\t0xBE28, 0x9591, 0xBE29, 0x9592, 0xBE2A, 0x9593, 0xBE2B, 0x9594,\r\n\t0xBE2C, 0x9595, 0xBE2D, 0x9596, 0xBE2E, 0x9597, 0xBE2F, 0x9598,\t0xBE30, 0x9599, 0xBE31, 0x959A, 0xBE32, 0x959B, 0xBE33, 0x959C,\r\n\t0xBE34, 0x959D, 0xBE35, 0x959E, 0xBE36, 0x959F, 0xBE37, 0x95A0,\t0xBE38, 0x95A1, 0xBE39, 0x95A2, 0xBE3A, 0x95A3, 0xBE3B, 0x95A4,\r\n\t0xBE3C, 0x95A5, 0xBE3D, 0x95A6, 0xBE3E, 0x95A7, 0xBE3F, 0x95A8,\t0xBE40, 0x95A9, 0xBE41, 0x95AA, 0xBE42, 0x95AB, 0xBE43, 0x95AC,\r\n\t0xBE44, 0xBAF1, 0xBE45, 0xBAF2, 0xBE46, 0x95AD, 0xBE47, 0x95AE,\t0xBE48, 0xBAF3, 0xBE49, 0x95AF, 0xBE4A, 0x95B0, 0xBE4B, 0x95B1,\r\n\t0xBE4C, 0xBAF4, 0xBE4D, 0x95B2, 0xBE4E, 0xBAF5, 0xBE4F, 0x95B3,\t0xBE50, 0x95B4, 0xBE51, 0x95B5, 0xBE52, 0x95B6, 0xBE53, 0x95B7,\r\n\t0xBE54, 0xBAF6, 0xBE55, 0xBAF7, 0xBE56, 0x95B8, 0xBE57, 0xBAF8,\t0xBE58, 0x95B9, 0xBE59, 0xBAF9, 0xBE5A, 0xBAFA, 0xBE5B, 0xBAFB,\r\n\t0xBE5C, 0x95BA, 0xBE5D, 0x95BB, 0xBE5E, 0x95BC, 0xBE5F, 0x95BD,\t0xBE60, 0xBAFC, 0xBE61, 0xBAFD, 0xBE62, 0x95BE, 0xBE63, 0x95BF,\r\n\t0xBE64, 0xBAFE, 0xBE65, 0x95C0, 0xBE66, 0x95C1, 0xBE67, 0x95C2,\t0xBE68, 0xBBA1, 0xBE69, 0x95C3, 0xBE6A, 0xBBA2, 0xBE6B, 0x95C4,\r\n\t0xBE6C, 0x95C5, 0xBE6D, 0x95C6, 0xBE6E, 0x95C7, 0xBE6F, 0x95C8,\t0xBE70, 0xBBA3, 0xBE71, 0xBBA4, 0xBE72, 0x95C9, 0xBE73, 0xBBA5,\r\n\t0xBE74, 0xBBA6, 0xBE75, 0xBBA7, 0xBE76, 0x95CA, 0xBE77, 0x95CB,\t0xBE78, 0x95CC, 0xBE79, 0x95CD, 0xBE7A, 0x95CE, 0xBE7B, 0xBBA8,\r\n\t0xBE7C, 0xBBA9, 0xBE7D, 0xBBAA, 0xBE7E, 0x95CF, 0xBE7F, 0x95D0,\t0xBE80, 0xBBAB, 0xBE81, 0x95D1, 0xBE82, 0x95D2, 0xBE83, 0x95D3,\r\n\t0xBE84, 0xBBAC, 0xBE85, 0x95D4, 0xBE86, 0x95D5, 0xBE87, 0x95D6,\t0xBE88, 0x95D7, 0xBE89, 0x95D8, 0xBE8A, 0x95D9, 0xBE8B, 0x95DA,\r\n\t0xBE8C, 0xBBAD, 0xBE8D, 0xBBAE, 0xBE8E, 0x95DB, 0xBE8F, 0xBBAF,\t0xBE90, 0xBBB0, 0xBE91, 0xBBB1, 0xBE92, 0x95DC, 0xBE93, 0x95DD,\r\n\t0xBE94, 0x95DE, 0xBE95, 0x95DF, 0xBE96, 0x95E0, 0xBE97, 0x95E1,\t0xBE98, 0xBBB2, 0xBE99, 0xBBB3, 0xBE9A, 0x95E2, 0xBE9B, 0x95E3,\r\n\t0xBE9C, 0x95E4, 0xBE9D, 0x95E5, 0xBE9E, 0x95E6, 0xBE9F, 0x95E7,\t0xBEA0, 0x95E8, 0xBEA1, 0x95E9, 0xBEA2, 0x95EA, 0xBEA3, 0x95EB,\r\n\t0xBEA4, 0x95EC, 0xBEA5, 0x95ED, 0xBEA6, 0x95EE, 0xBEA7, 0x95EF,\t0xBEA8, 0xBBB4, 0xBEA9, 0x95F0, 0xBEAA, 0x95F1, 0xBEAB, 0x95F2,\r\n\t0xBEAC, 0x95F3, 0xBEAD, 0x95F4, 0xBEAE, 0x95F5, 0xBEAF, 0x95F6,\t0xBEB0, 0x95F7, 0xBEB1, 0x95F8, 0xBEB2, 0x95F9, 0xBEB3, 0x95FA,\r\n\t0xBEB4, 0x95FB, 0xBEB5, 0x95FC, 0xBEB6, 0x95FD, 0xBEB7, 0x95FE,\t0xBEB8, 0x9641, 0xBEB9, 0x9642, 0xBEBA, 0x9643, 0xBEBB, 0x9644,\r\n\t0xBEBC, 0x9645, 0xBEBD, 0x9646, 0xBEBE, 0x9647, 0xBEBF, 0x9648,\t0xBEC0, 0x9649, 0xBEC1, 0x964A, 0xBEC2, 0x964B, 0xBEC3, 0x964C,\r\n\t0xBEC4, 0x964D, 0xBEC5, 0x964E, 0xBEC6, 0x964F, 0xBEC7, 0x9650,\t0xBEC8, 0x9651, 0xBEC9, 0x9652, 0xBECA, 0x9653, 0xBECB, 0x9654,\r\n\t0xBECC, 0x9655, 0xBECD, 0x9656, 0xBECE, 0x9657, 0xBECF, 0x9658,\t0xBED0, 0xBBB5, 0xBED1, 0xBBB6, 0xBED2, 0x9659, 0xBED3, 0x965A,\r\n\t0xBED4, 0xBBB7, 0xBED5, 0x9661, 0xBED6, 0x9662, 0xBED7, 0xBBB8,\t0xBED8, 0xBBB9, 0xBED9, 0x9663, 0xBEDA, 0x9664, 0xBEDB, 0x9665,\r\n\t0xBEDC, 0x9666, 0xBEDD, 0x9667, 0xBEDE, 0x9668, 0xBEDF, 0x9669,\t0xBEE0, 0xBBBA, 0xBEE1, 0x966A, 0xBEE2, 0x966B, 0xBEE3, 0xBBBB,\r\n\t0xBEE4, 0xBBBC, 0xBEE5, 0xBBBD, 0xBEE6, 0x966C, 0xBEE7, 0x966D,\t0xBEE8, 0x966E, 0xBEE9, 0x966F, 0xBEEA, 0x9670, 0xBEEB, 0x9671,\r\n\t0xBEEC, 0xBBBE, 0xBEED, 0x9672, 0xBEEE, 0x9673, 0xBEEF, 0x9674,\t0xBEF0, 0x9675, 0xBEF1, 0x9676, 0xBEF2, 0x9677, 0xBEF3, 0x9678,\r\n\t0xBEF4, 0x9679, 0xBEF5, 0x967A, 0xBEF6, 0x9681, 0xBEF7, 0x9682,\t0xBEF8, 0x9683, 0xBEF9, 0x9684, 0xBEFA, 0x9685, 0xBEFB, 0x9686,\r\n\t0xBEFC, 0x9687, 0xBEFD, 0x9688, 0xBEFE, 0x9689, 0xBEFF, 0x968A,\t0xBF00, 0x968B, 0xBF01, 0xBBBF, 0xBF02, 0x968C, 0xBF03, 0x968D,\r\n\t0xBF04, 0x968E, 0xBF05, 0x968F, 0xBF06, 0x9690, 0xBF07, 0x9691,\t0xBF08, 0xBBC0, 0xBF09, 0xBBC1, 0xBF0A, 0x9692, 0xBF0B, 0x9693,\r\n\t0xBF0C, 0x9694, 0xBF0D, 0x9695, 0xBF0E, 0x9696, 0xBF0F, 0x9697,\t0xBF10, 0x9698, 0xBF11, 0x9699, 0xBF12, 0x969A, 0xBF13, 0x969B,\r\n\t0xBF14, 0x969C, 0xBF15, 0x969D, 0xBF16, 0x969E, 0xBF17, 0x969F,\t0xBF18, 0xBBC2, 0xBF19, 0xBBC3, 0xBF1A, 0x96A0, 0xBF1B, 0xBBC4,\r\n\t0xBF1C, 0xBBC5, 0xBF1D, 0xBBC6, 0xBF1E, 0x96A1, 0xBF1F, 0x96A2,\t0xBF20, 0x96A3, 0xBF21, 0x96A4, 0xBF22, 0x96A5, 0xBF23, 0x96A6,\r\n\t0xBF24, 0x96A7, 0xBF25, 0x96A8, 0xBF26, 0x96A9, 0xBF27, 0x96AA,\t0xBF28, 0x96AB, 0xBF29, 0x96AC, 0xBF2A, 0x96AD, 0xBF2B, 0x96AE,\r\n\t0xBF2C, 0x96AF, 0xBF2D, 0x96B0, 0xBF2E, 0x96B1, 0xBF2F, 0x96B2,\t0xBF30, 0x96B3, 0xBF31, 0x96B4, 0xBF32, 0x96B5, 0xBF33, 0x96B6,\r\n\t0xBF34, 0x96B7, 0xBF35, 0x96B8, 0xBF36, 0x96B9, 0xBF37, 0x96BA,\t0xBF38, 0x96BB, 0xBF39, 0x96BC, 0xBF3A, 0x96BD, 0xBF3B, 0x96BE,\r\n\t0xBF3C, 0x96BF, 0xBF3D, 0x96C0, 0xBF3E, 0x96C1, 0xBF3F, 0x96C2,\t0xBF40, 0xBBC7, 0xBF41, 0xBBC8, 0xBF42, 0x96C3, 0xBF43, 0x96C4,\r\n\t0xBF44, 0xBBC9, 0xBF45, 0x96C5, 0xBF46, 0x96C6, 0xBF47, 0x96C7,\t0xBF48, 0xBBCA, 0xBF49, 0x96C8, 0xBF4A, 0x96C9, 0xBF4B, 0x96CA,\r\n\t0xBF4C, 0x96CB, 0xBF4D, 0x96CC, 0xBF4E, 0x96CD, 0xBF4F, 0x96CE,\t0xBF50, 0xBBCB, 0xBF51, 0xBBCC, 0xBF52, 0x96CF, 0xBF53, 0x96D0,\r\n\t0xBF54, 0x96D1, 0xBF55, 0xBBCD, 0xBF56, 0x96D2, 0xBF57, 0x96D3,\t0xBF58, 0x96D4, 0xBF59, 0x96D5, 0xBF5A, 0x96D6, 0xBF5B, 0x96D7,\r\n\t0xBF5C, 0x96D8, 0xBF5D, 0x96D9, 0xBF5E, 0x96DA, 0xBF5F, 0x96DB,\t0xBF60, 0x96DC, 0xBF61, 0x96DD, 0xBF62, 0x96DE, 0xBF63, 0x96DF,\r\n\t0xBF64, 0x96E0, 0xBF65, 0x96E1, 0xBF66, 0x96E2, 0xBF67, 0x96E3,\t0xBF68, 0x96E4, 0xBF69, 0x96E5, 0xBF6A, 0x96E6, 0xBF6B, 0x96E7,\r\n\t0xBF6C, 0x96E8, 0xBF6D, 0x96E9, 0xBF6E, 0x96EA, 0xBF6F, 0x96EB,\t0xBF70, 0x96EC, 0xBF71, 0x96ED, 0xBF72, 0x96EE, 0xBF73, 0x96EF,\r\n\t0xBF74, 0x96F0, 0xBF75, 0x96F1, 0xBF76, 0x96F2, 0xBF77, 0x96F3,\t0xBF78, 0x96F4, 0xBF79, 0x96F5, 0xBF7A, 0x96F6, 0xBF7B, 0x96F7,\r\n\t0xBF7C, 0x96F8, 0xBF7D, 0x96F9, 0xBF7E, 0x96FA, 0xBF7F, 0x96FB,\t0xBF80, 0x96FC, 0xBF81, 0x96FD, 0xBF82, 0x96FE, 0xBF83, 0x9741,\r\n\t0xBF84, 0x9742, 0xBF85, 0x9743, 0xBF86, 0x9744, 0xBF87, 0x9745,\t0xBF88, 0x9746, 0xBF89, 0x9747, 0xBF8A, 0x9748, 0xBF8B, 0x9749,\r\n\t0xBF8C, 0x974A, 0xBF8D, 0x974B, 0xBF8E, 0x974C, 0xBF8F, 0x974D,\t0xBF90, 0x974E, 0xBF91, 0x974F, 0xBF92, 0x9750, 0xBF93, 0x9751,\r\n\t0xBF94, 0xBBCE, 0xBF95, 0x9752, 0xBF96, 0x9753, 0xBF97, 0x9754,\t0xBF98, 0x9755, 0xBF99, 0x9756, 0xBF9A, 0x9757, 0xBF9B, 0x9758,\r\n\t0xBF9C, 0x9759, 0xBF9D, 0x975A, 0xBF9E, 0x9761, 0xBF9F, 0x9762,\t0xBFA0, 0x9763, 0xBFA1, 0x9764, 0xBFA2, 0x9765, 0xBFA3, 0x9766,\r\n\t0xBFA4, 0x9767, 0xBFA5, 0x9768, 0xBFA6, 0x9769, 0xBFA7, 0x976A,\t0xBFA8, 0x976B, 0xBFA9, 0x976C, 0xBFAA, 0x976D, 0xBFAB, 0x976E,\r\n\t0xBFAC, 0x976F, 0xBFAD, 0x9770, 0xBFAE, 0x9771, 0xBFAF, 0x9772,\t0xBFB0, 0xBBCF, 0xBFB1, 0x9773, 0xBFB2, 0x9774, 0xBFB3, 0x9775,\r\n\t0xBFB4, 0x9776, 0xBFB5, 0x9777, 0xBFB6, 0x9778, 0xBFB7, 0x9779,\t0xBFB8, 0x977A, 0xBFB9, 0x9781, 0xBFBA, 0x9782, 0xBFBB, 0x9783,\r\n\t0xBFBC, 0x9784, 0xBFBD, 0x9785, 0xBFBE, 0x9786, 0xBFBF, 0x9787,\t0xBFC0, 0x9788, 0xBFC1, 0x9789, 0xBFC2, 0x978A, 0xBFC3, 0x978B,\r\n\t0xBFC4, 0x978C, 0xBFC5, 0xBBD0, 0xBFC6, 0x978D, 0xBFC7, 0x978E,\t0xBFC8, 0x978F, 0xBFC9, 0x9790, 0xBFCA, 0x9791, 0xBFCB, 0x9792,\r\n\t0xBFCC, 0xBBD1, 0xBFCD, 0xBBD2, 0xBFCE, 0x9793, 0xBFCF, 0x9794,\t0xBFD0, 0xBBD3, 0xBFD1, 0x9795, 0xBFD2, 0x9796, 0xBFD3, 0x9797,\r\n\t0xBFD4, 0xBBD4, 0xBFD5, 0x9798, 0xBFD6, 0x9799, 0xBFD7, 0x979A,\t0xBFD8, 0x979B, 0xBFD9, 0x979C, 0xBFDA, 0x979D, 0xBFDB, 0x979E,\r\n\t0xBFDC, 0xBBD5, 0xBFDD, 0x979F, 0xBFDE, 0x97A0, 0xBFDF, 0xBBD6,\t0xBFE0, 0x97A1, 0xBFE1, 0xBBD7, 0xBFE2, 0x97A2, 0xBFE3, 0x97A3,\r\n\t0xBFE4, 0x97A4, 0xBFE5, 0x97A5, 0xBFE6, 0x97A6, 0xBFE7, 0x97A7,\t0xBFE8, 0x97A8, 0xBFE9, 0x97A9, 0xBFEA, 0x97AA, 0xBFEB, 0x97AB,\r\n\t0xBFEC, 0x97AC, 0xBFED, 0x97AD, 0xBFEE, 0x97AE, 0xBFEF, 0x97AF,\t0xBFF0, 0x97B0, 0xBFF1, 0x97B1, 0xBFF2, 0x97B2, 0xBFF3, 0x97B3,\r\n\t0xBFF4, 0x97B4, 0xBFF5, 0x97B5, 0xBFF6, 0x97B6, 0xBFF7, 0x97B7,\t0xBFF8, 0x97B8, 0xBFF9, 0x97B9, 0xBFFA, 0x97BA, 0xBFFB, 0x97BB,\r\n\t0xBFFC, 0x97BC, 0xBFFD, 0x97BD, 0xBFFE, 0x97BE, 0xBFFF, 0x97BF,\t0xC000, 0x97C0, 0xC001, 0x97C1, 0xC002, 0x97C2, 0xC003, 0x97C3,\r\n\t0xC004, 0x97C4, 0xC005, 0x97C5, 0xC006, 0x97C6, 0xC007, 0x97C7,\t0xC008, 0x97C8, 0xC009, 0x97C9, 0xC00A, 0x97CA, 0xC00B, 0x97CB,\r\n\t0xC00C, 0x97CC, 0xC00D, 0x97CD, 0xC00E, 0x97CE, 0xC00F, 0x97CF,\t0xC010, 0x97D0, 0xC011, 0x97D1, 0xC012, 0x97D2, 0xC013, 0x97D3,\r\n\t0xC014, 0x97D4, 0xC015, 0x97D5, 0xC016, 0x97D6, 0xC017, 0x97D7,\t0xC018, 0x97D8, 0xC019, 0x97D9, 0xC01A, 0x97DA, 0xC01B, 0x97DB,\r\n\t0xC01C, 0x97DC, 0xC01D, 0x97DD, 0xC01E, 0x97DE, 0xC01F, 0x97DF,\t0xC020, 0x97E0, 0xC021, 0x97E1, 0xC022, 0x97E2, 0xC023, 0x97E3,\r\n\t0xC024, 0x97E4, 0xC025, 0x97E5, 0xC026, 0x97E6, 0xC027, 0x97E7,\t0xC028, 0x97E8, 0xC029, 0x97E9, 0xC02A, 0x97EA, 0xC02B, 0x97EB,\r\n\t0xC02C, 0x97EC, 0xC02D, 0x97ED, 0xC02E, 0x97EE, 0xC02F, 0x97EF,\t0xC030, 0x97F0, 0xC031, 0x97F1, 0xC032, 0x97F2, 0xC033, 0x97F3,\r\n\t0xC034, 0x97F4, 0xC035, 0x97F5, 0xC036, 0x97F6, 0xC037, 0x97F7,\t0xC038, 0x97F8, 0xC039, 0x97F9, 0xC03A, 0x97FA, 0xC03B, 0x97FB,\r\n\t0xC03C, 0xBBD8, 0xC03D, 0x97FC, 0xC03E, 0x97FD, 0xC03F, 0x97FE,\t0xC040, 0x9841, 0xC041, 0x9842, 0xC042, 0x9843, 0xC043, 0x9844,\r\n\t0xC044, 0x9845, 0xC045, 0x9846, 0xC046, 0x9847, 0xC047, 0x9848,\t0xC048, 0x9849, 0xC049, 0x984A, 0xC04A, 0x984B, 0xC04B, 0x984C,\r\n\t0xC04C, 0x984D, 0xC04D, 0x984E, 0xC04E, 0x984F, 0xC04F, 0x9850,\t0xC050, 0x9851, 0xC051, 0xBBD9, 0xC052, 0x9852, 0xC053, 0x9853,\r\n\t0xC054, 0x9854, 0xC055, 0x9855, 0xC056, 0x9856, 0xC057, 0x9857,\t0xC058, 0xBBDA, 0xC059, 0x9858, 0xC05A, 0x9859, 0xC05B, 0x985A,\r\n\t0xC05C, 0xBBDB, 0xC05D, 0x9861, 0xC05E, 0x9862, 0xC05F, 0x9863,\t0xC060, 0xBBDC, 0xC061, 0x9864, 0xC062, 0x9865, 0xC063, 0x9866,\r\n\t0xC064, 0x9867, 0xC065, 0x9868, 0xC066, 0x9869, 0xC067, 0x986A,\t0xC068, 0xBBDD, 0xC069, 0xBBDE, 0xC06A, 0x986B, 0xC06B, 0x986C,\r\n\t0xC06C, 0x986D, 0xC06D, 0x986E, 0xC06E, 0x986F, 0xC06F, 0x9870,\t0xC070, 0x9871, 0xC071, 0x9872, 0xC072, 0x9873, 0xC073, 0x9874,\r\n\t0xC074, 0x9875, 0xC075, 0x9876, 0xC076, 0x9877, 0xC077, 0x9878,\t0xC078, 0x9879, 0xC079, 0x987A, 0xC07A, 0x9881, 0xC07B, 0x9882,\r\n\t0xC07C, 0x9883, 0xC07D, 0x9884, 0xC07E, 0x9885, 0xC07F, 0x9886,\t0xC080, 0x9887, 0xC081, 0x9888, 0xC082, 0x9889, 0xC083, 0x988A,\r\n\t0xC084, 0x988B, 0xC085, 0x988C, 0xC086, 0x988D, 0xC087, 0x988E,\t0xC088, 0x988F, 0xC089, 0x9890, 0xC08A, 0x9891, 0xC08B, 0x9892,\r\n\t0xC08C, 0x9893, 0xC08D, 0x9894, 0xC08E, 0x9895, 0xC08F, 0x9896,\t0xC090, 0xBBDF, 0xC091, 0xBBE0, 0xC092, 0x9897, 0xC093, 0x9898,\r\n\t0xC094, 0xBBE1, 0xC095, 0x9899, 0xC096, 0x989A, 0xC097, 0x989B,\t0xC098, 0xBBE2, 0xC099, 0x989C, 0xC09A, 0x989D, 0xC09B, 0x989E,\r\n\t0xC09C, 0x989F, 0xC09D, 0x98A0, 0xC09E, 0x98A1, 0xC09F, 0x98A2,\t0xC0A0, 0xBBE3, 0xC0A1, 0xBBE4, 0xC0A2, 0x98A3, 0xC0A3, 0xBBE5,\r\n\t0xC0A4, 0x98A4, 0xC0A5, 0xBBE6, 0xC0A6, 0x98A5, 0xC0A7, 0x98A6,\t0xC0A8, 0x98A7, 0xC0A9, 0x98A8, 0xC0AA, 0x98A9, 0xC0AB, 0x98AA,\r\n\t0xC0AC, 0xBBE7, 0xC0AD, 0xBBE8, 0xC0AE, 0x98AB, 0xC0AF, 0xBBE9,\t0xC0B0, 0xBBEA, 0xC0B1, 0x98AC, 0xC0B2, 0x98AD, 0xC0B3, 0xBBEB,\r\n\t0xC0B4, 0xBBEC, 0xC0B5, 0xBBED, 0xC0B6, 0xBBEE, 0xC0B7, 0x98AE,\t0xC0B8, 0x98AF, 0xC0B9, 0x98B0, 0xC0BA, 0x98B1, 0xC0BB, 0x98B2,\r\n\t0xC0BC, 0xBBEF, 0xC0BD, 0xBBF0, 0xC0BE, 0x98B3, 0xC0BF, 0xBBF1,\t0xC0C0, 0xBBF2, 0xC0C1, 0xBBF3, 0xC0C2, 0x98B4, 0xC0C3, 0x98B5,\r\n\t0xC0C4, 0x98B6, 0xC0C5, 0xBBF4, 0xC0C6, 0x98B7, 0xC0C7, 0x98B8,\t0xC0C8, 0xBBF5, 0xC0C9, 0xBBF6, 0xC0CA, 0x98B9, 0xC0CB, 0x98BA,\r\n\t0xC0CC, 0xBBF7, 0xC0CD, 0x98BB, 0xC0CE, 0x98BC, 0xC0CF, 0x98BD,\t0xC0D0, 0xBBF8, 0xC0D1, 0x98BE, 0xC0D2, 0x98BF, 0xC0D3, 0x98C0,\r\n\t0xC0D4, 0x98C1, 0xC0D5, 0x98C2, 0xC0D6, 0x98C3, 0xC0D7, 0x98C4,\t0xC0D8, 0xBBF9, 0xC0D9, 0xBBFA, 0xC0DA, 0x98C5, 0xC0DB, 0xBBFB,\r\n\t0xC0DC, 0xBBFC, 0xC0DD, 0xBBFD, 0xC0DE, 0x98C6, 0xC0DF, 0x98C7,\t0xC0E0, 0x98C8, 0xC0E1, 0x98C9, 0xC0E2, 0x98CA, 0xC0E3, 0x98CB,\r\n\t0xC0E4, 0xBBFE, 0xC0E5, 0xBCA1, 0xC0E6, 0x98CC, 0xC0E7, 0x98CD,\t0xC0E8, 0xBCA2, 0xC0E9, 0x98CE, 0xC0EA, 0x98CF, 0xC0EB, 0x98D0,\r\n\t0xC0EC, 0xBCA3, 0xC0ED, 0x98D1, 0xC0EE, 0x98D2, 0xC0EF, 0x98D3,\t0xC0F0, 0x98D4, 0xC0F1, 0x98D5, 0xC0F2, 0x98D6, 0xC0F3, 0x98D7,\r\n\t0xC0F4, 0xBCA4, 0xC0F5, 0xBCA5, 0xC0F6, 0x98D8, 0xC0F7, 0xBCA6,\t0xC0F8, 0x98D9, 0xC0F9, 0xBCA7, 0xC0FA, 0x98DA, 0xC0FB, 0x98DB,\r\n\t0xC0FC, 0x98DC, 0xC0FD, 0x98DD, 0xC0FE, 0x98DE, 0xC0FF, 0x98DF,\t0xC100, 0xBCA8, 0xC101, 0x98E0, 0xC102, 0x98E1, 0xC103, 0x98E2,\r\n\t0xC104, 0xBCA9, 0xC105, 0x98E3, 0xC106, 0x98E4, 0xC107, 0x98E5,\t0xC108, 0xBCAA, 0xC109, 0x98E6, 0xC10A, 0x98E7, 0xC10B, 0x98E8,\r\n\t0xC10C, 0x98E9, 0xC10D, 0x98EA, 0xC10E, 0x98EB, 0xC10F, 0x98EC,\t0xC110, 0xBCAB, 0xC111, 0x98ED, 0xC112, 0x98EE, 0xC113, 0x98EF,\r\n\t0xC114, 0x98F0, 0xC115, 0xBCAC, 0xC116, 0x98F1, 0xC117, 0x98F2,\t0xC118, 0x98F3, 0xC119, 0x98F4, 0xC11A, 0x98F5, 0xC11B, 0x98F6,\r\n\t0xC11C, 0xBCAD, 0xC11D, 0xBCAE, 0xC11E, 0xBCAF, 0xC11F, 0xBCB0,\t0xC120, 0xBCB1, 0xC121, 0x98F7, 0xC122, 0x98F8, 0xC123, 0xBCB2,\r\n\t0xC124, 0xBCB3, 0xC125, 0x98F9, 0xC126, 0xBCB4, 0xC127, 0xBCB5,\t0xC128, 0x98FA, 0xC129, 0x98FB, 0xC12A, 0x98FC, 0xC12B, 0x98FD,\r\n\t0xC12C, 0xBCB6, 0xC12D, 0xBCB7, 0xC12E, 0x98FE, 0xC12F, 0xBCB8,\t0xC130, 0xBCB9, 0xC131, 0xBCBA, 0xC132, 0x9941, 0xC133, 0x9942,\r\n\t0xC134, 0x9943, 0xC135, 0x9944, 0xC136, 0xBCBB, 0xC137, 0x9945,\t0xC138, 0xBCBC, 0xC139, 0xBCBD, 0xC13A, 0x9946, 0xC13B, 0x9947,\r\n\t0xC13C, 0xBCBE, 0xC13D, 0x9948, 0xC13E, 0x9949, 0xC13F, 0x994A,\t0xC140, 0xBCBF, 0xC141, 0x994B, 0xC142, 0x994C, 0xC143, 0x994D,\r\n\t0xC144, 0x994E, 0xC145, 0x994F, 0xC146, 0x9950, 0xC147, 0x9951,\t0xC148, 0xBCC0, 0xC149, 0xBCC1, 0xC14A, 0x9952, 0xC14B, 0xBCC2,\r\n\t0xC14C, 0xBCC3, 0xC14D, 0xBCC4, 0xC14E, 0x9953, 0xC14F, 0x9954,\t0xC150, 0x9955, 0xC151, 0x9956, 0xC152, 0x9957, 0xC153, 0x9958,\r\n\t0xC154, 0xBCC5, 0xC155, 0xBCC6, 0xC156, 0x9959, 0xC157, 0x995A,\t0xC158, 0xBCC7, 0xC159, 0x9961, 0xC15A, 0x9962, 0xC15B, 0x9963,\r\n\t0xC15C, 0xBCC8, 0xC15D, 0x9964, 0xC15E, 0x9965, 0xC15F, 0x9966,\t0xC160, 0x9967, 0xC161, 0x9968, 0xC162, 0x9969, 0xC163, 0x996A,\r\n\t0xC164, 0xBCC9, 0xC165, 0xBCCA, 0xC166, 0x996B, 0xC167, 0xBCCB,\t0xC168, 0xBCCC, 0xC169, 0xBCCD, 0xC16A, 0x996C, 0xC16B, 0x996D,\r\n\t0xC16C, 0x996E, 0xC16D, 0x996F, 0xC16E, 0x9970, 0xC16F, 0x9971,\t0xC170, 0xBCCE, 0xC171, 0x9972, 0xC172, 0x9973, 0xC173, 0x9974,\r\n\t0xC174, 0xBCCF, 0xC175, 0x9975, 0xC176, 0x9976, 0xC177, 0x9977,\t0xC178, 0xBCD0, 0xC179, 0x9978, 0xC17A, 0x9979, 0xC17B, 0x997A,\r\n\t0xC17C, 0x9981, 0xC17D, 0x9982, 0xC17E, 0x9983, 0xC17F, 0x9984,\t0xC180, 0x9985, 0xC181, 0x9986, 0xC182, 0x9987, 0xC183, 0x9988,\r\n\t0xC184, 0x9989, 0xC185, 0xBCD1, 0xC186, 0x998A, 0xC187, 0x998B,\t0xC188, 0x998C, 0xC189, 0x998D, 0xC18A, 0x998E, 0xC18B, 0x998F,\r\n\t0xC18C, 0xBCD2, 0xC18D, 0xBCD3, 0xC18E, 0xBCD4, 0xC18F, 0x9990,\t0xC190, 0xBCD5, 0xC191, 0x9991, 0xC192, 0x9992, 0xC193, 0x9993,\r\n\t0xC194, 0xBCD6, 0xC195, 0x9994, 0xC196, 0xBCD7, 0xC197, 0x9995,\t0xC198, 0x9996, 0xC199, 0x9997, 0xC19A, 0x9998, 0xC19B, 0x9999,\r\n\t0xC19C, 0xBCD8, 0xC19D, 0xBCD9, 0xC19E, 0x999A, 0xC19F, 0xBCDA,\t0xC1A0, 0x999B, 0xC1A1, 0xBCDB, 0xC1A2, 0x999C, 0xC1A3, 0x999D,\r\n\t0xC1A4, 0x999E, 0xC1A5, 0xBCDC, 0xC1A6, 0x999F, 0xC1A7, 0x99A0,\t0xC1A8, 0xBCDD, 0xC1A9, 0xBCDE, 0xC1AA, 0x99A1, 0xC1AB, 0x99A2,\r\n\t0xC1AC, 0xBCDF, 0xC1AD, 0x99A3, 0xC1AE, 0x99A4, 0xC1AF, 0x99A5,\t0xC1B0, 0xBCE0, 0xC1B1, 0x99A6, 0xC1B2, 0x99A7, 0xC1B3, 0x99A8,\r\n\t0xC1B4, 0x99A9, 0xC1B5, 0x99AA, 0xC1B6, 0x99AB, 0xC1B7, 0x99AC,\t0xC1B8, 0x99AD, 0xC1B9, 0x99AE, 0xC1BA, 0x99AF, 0xC1BB, 0x99B0,\r\n\t0xC1BC, 0x99B1, 0xC1BD, 0xBCE1, 0xC1BE, 0x99B2, 0xC1BF, 0x99B3,\t0xC1C0, 0x99B4, 0xC1C1, 0x99B5, 0xC1C2, 0x99B6, 0xC1C3, 0x99B7,\r\n\t0xC1C4, 0xBCE2, 0xC1C5, 0x99B8, 0xC1C6, 0x99B9, 0xC1C7, 0x99BA,\t0xC1C8, 0xBCE3, 0xC1C9, 0x99BB, 0xC1CA, 0x99BC, 0xC1CB, 0x99BD,\r\n\t0xC1CC, 0xBCE4, 0xC1CD, 0x99BE, 0xC1CE, 0x99BF, 0xC1CF, 0x99C0,\t0xC1D0, 0x99C1, 0xC1D1, 0x99C2, 0xC1D2, 0x99C3, 0xC1D3, 0x99C4,\r\n\t0xC1D4, 0xBCE5, 0xC1D5, 0x99C5, 0xC1D6, 0x99C6, 0xC1D7, 0xBCE6,\t0xC1D8, 0xBCE7, 0xC1D9, 0x99C7, 0xC1DA, 0x99C8, 0xC1DB, 0x99C9,\r\n\t0xC1DC, 0x99CA, 0xC1DD, 0x99CB, 0xC1DE, 0x99CC, 0xC1DF, 0x99CD,\t0xC1E0, 0xBCE8, 0xC1E1, 0x99CE, 0xC1E2, 0x99CF, 0xC1E3, 0x99D0,\r\n\t0xC1E4, 0xBCE9, 0xC1E5, 0x99D1, 0xC1E6, 0x99D2, 0xC1E7, 0x99D3,\t0xC1E8, 0xBCEA, 0xC1E9, 0x99D4, 0xC1EA, 0x99D5, 0xC1EB, 0x99D6,\r\n\t0xC1EC, 0x99D7, 0xC1ED, 0x99D8, 0xC1EE, 0x99D9, 0xC1EF, 0x99DA,\t0xC1F0, 0xBCEB, 0xC1F1, 0xBCEC, 0xC1F2, 0x99DB, 0xC1F3, 0xBCED,\r\n\t0xC1F4, 0x99DC, 0xC1F5, 0x99DD, 0xC1F6, 0x99DE, 0xC1F7, 0x99DF,\t0xC1F8, 0x99E0, 0xC1F9, 0x99E1, 0xC1FA, 0x99E2, 0xC1FB, 0x99E3,\r\n\t0xC1FC, 0xBCEE, 0xC1FD, 0xBCEF, 0xC1FE, 0x99E4, 0xC1FF, 0x99E5,\t0xC200, 0xBCF0, 0xC201, 0x99E6, 0xC202, 0x99E7, 0xC203, 0x99E8,\r\n\t0xC204, 0xBCF1, 0xC205, 0x99E9, 0xC206, 0x99EA, 0xC207, 0x99EB,\t0xC208, 0x99EC, 0xC209, 0x99ED, 0xC20A, 0x99EE, 0xC20B, 0x99EF,\r\n\t0xC20C, 0xBCF2, 0xC20D, 0xBCF3, 0xC20E, 0x99F0, 0xC20F, 0xBCF4,\t0xC210, 0x99F1, 0xC211, 0xBCF5, 0xC212, 0x99F2, 0xC213, 0x99F3,\r\n\t0xC214, 0x99F4, 0xC215, 0x99F5, 0xC216, 0x99F6, 0xC217, 0x99F7,\t0xC218, 0xBCF6, 0xC219, 0xBCF7, 0xC21A, 0x99F8, 0xC21B, 0x99F9,\r\n\t0xC21C, 0xBCF8, 0xC21D, 0x99FA, 0xC21E, 0x99FB, 0xC21F, 0xBCF9,\t0xC220, 0xBCFA, 0xC221, 0x99FC, 0xC222, 0x99FD, 0xC223, 0x99FE,\r\n\t0xC224, 0x9A41, 0xC225, 0x9A42, 0xC226, 0x9A43, 0xC227, 0x9A44,\t0xC228, 0xBCFB, 0xC229, 0xBCFC, 0xC22A, 0x9A45, 0xC22B, 0xBCFD,\r\n\t0xC22C, 0x9A46, 0xC22D, 0xBCFE, 0xC22E, 0x9A47, 0xC22F, 0xBDA1,\t0xC230, 0x9A48, 0xC231, 0xBDA2, 0xC232, 0xBDA3, 0xC233, 0x9A49,\r\n\t0xC234, 0xBDA4, 0xC235, 0x9A4A, 0xC236, 0x9A4B, 0xC237, 0x9A4C,\t0xC238, 0x9A4D, 0xC239, 0x9A4E, 0xC23A, 0x9A4F, 0xC23B, 0x9A50,\r\n\t0xC23C, 0x9A51, 0xC23D, 0x9A52, 0xC23E, 0x9A53, 0xC23F, 0x9A54,\t0xC240, 0x9A55, 0xC241, 0x9A56, 0xC242, 0x9A57, 0xC243, 0x9A58,\r\n\t0xC244, 0x9A59, 0xC245, 0x9A5A, 0xC246, 0x9A61, 0xC247, 0x9A62,\t0xC248, 0xBDA5, 0xC249, 0x9A63, 0xC24A, 0x9A64, 0xC24B, 0x9A65,\r\n\t0xC24C, 0x9A66, 0xC24D, 0x9A67, 0xC24E, 0x9A68, 0xC24F, 0x9A69,\t0xC250, 0xBDA6, 0xC251, 0xBDA7, 0xC252, 0x9A6A, 0xC253, 0x9A6B,\r\n\t0xC254, 0xBDA8, 0xC255, 0x9A6C, 0xC256, 0x9A6D, 0xC257, 0x9A6E,\t0xC258, 0xBDA9, 0xC259, 0x9A6F, 0xC25A, 0x9A70, 0xC25B, 0x9A71,\r\n\t0xC25C, 0x9A72, 0xC25D, 0x9A73, 0xC25E, 0x9A74, 0xC25F, 0x9A75,\t0xC260, 0xBDAA, 0xC261, 0x9A76, 0xC262, 0x9A77, 0xC263, 0x9A78,\r\n\t0xC264, 0x9A79, 0xC265, 0xBDAB, 0xC266, 0x9A7A, 0xC267, 0x9A81,\t0xC268, 0x9A82, 0xC269, 0x9A83, 0xC26A, 0x9A84, 0xC26B, 0x9A85,\r\n\t0xC26C, 0xBDAC, 0xC26D, 0xBDAD, 0xC26E, 0x9A86, 0xC26F, 0x9A87,\t0xC270, 0xBDAE, 0xC271, 0x9A88, 0xC272, 0x9A89, 0xC273, 0x9A8A,\r\n\t0xC274, 0xBDAF, 0xC275, 0x9A8B, 0xC276, 0x9A8C, 0xC277, 0x9A8D,\t0xC278, 0x9A8E, 0xC279, 0x9A8F, 0xC27A, 0x9A90, 0xC27B, 0x9A91,\r\n\t0xC27C, 0xBDB0, 0xC27D, 0xBDB1, 0xC27E, 0x9A92, 0xC27F, 0xBDB2,\t0xC280, 0x9A93, 0xC281, 0xBDB3, 0xC282, 0x9A94, 0xC283, 0x9A95,\r\n\t0xC284, 0x9A96, 0xC285, 0x9A97, 0xC286, 0x9A98, 0xC287, 0x9A99,\t0xC288, 0xBDB4, 0xC289, 0xBDB5, 0xC28A, 0x9A9A, 0xC28B, 0x9A9B,\r\n\t0xC28C, 0x9A9C, 0xC28D, 0x9A9D, 0xC28E, 0x9A9E, 0xC28F, 0x9A9F,\t0xC290, 0xBDB6, 0xC291, 0x9AA0, 0xC292, 0x9AA1, 0xC293, 0x9AA2,\r\n\t0xC294, 0x9AA3, 0xC295, 0x9AA4, 0xC296, 0x9AA5, 0xC297, 0x9AA6,\t0xC298, 0xBDB7, 0xC299, 0x9AA7, 0xC29A, 0x9AA8, 0xC29B, 0xBDB8,\r\n\t0xC29C, 0x9AA9, 0xC29D, 0xBDB9, 0xC29E, 0x9AAA, 0xC29F, 0x9AAB,\t0xC2A0, 0x9AAC, 0xC2A1, 0x9AAD, 0xC2A2, 0x9AAE, 0xC2A3, 0x9AAF,\r\n\t0xC2A4, 0xBDBA, 0xC2A5, 0xBDBB, 0xC2A6, 0x9AB0, 0xC2A7, 0x9AB1,\t0xC2A8, 0xBDBC, 0xC2A9, 0x9AB2, 0xC2AA, 0x9AB3, 0xC2AB, 0x9AB4,\r\n\t0xC2AC, 0xBDBD, 0xC2AD, 0xBDBE, 0xC2AE, 0x9AB5, 0xC2AF, 0x9AB6,\t0xC2B0, 0x9AB7, 0xC2B1, 0x9AB8, 0xC2B2, 0x9AB9, 0xC2B3, 0x9ABA,\r\n\t0xC2B4, 0xBDBF, 0xC2B5, 0xBDC0, 0xC2B6, 0x9ABB, 0xC2B7, 0xBDC1,\t0xC2B8, 0x9ABC, 0xC2B9, 0xBDC2, 0xC2BA, 0x9ABD, 0xC2BB, 0x9ABE,\r\n\t0xC2BC, 0x9ABF, 0xC2BD, 0x9AC0, 0xC2BE, 0x9AC1, 0xC2BF, 0x9AC2,\t0xC2C0, 0x9AC3, 0xC2C1, 0x9AC4, 0xC2C2, 0x9AC5, 0xC2C3, 0x9AC6,\r\n\t0xC2C4, 0x9AC7, 0xC2C5, 0x9AC8, 0xC2C6, 0x9AC9, 0xC2C7, 0x9ACA,\t0xC2C8, 0x9ACB, 0xC2C9, 0x9ACC, 0xC2CA, 0x9ACD, 0xC2CB, 0x9ACE,\r\n\t0xC2CC, 0x9ACF, 0xC2CD, 0x9AD0, 0xC2CE, 0x9AD1, 0xC2CF, 0x9AD2,\t0xC2D0, 0x9AD3, 0xC2D1, 0x9AD4, 0xC2D2, 0x9AD5, 0xC2D3, 0x9AD6,\r\n\t0xC2D4, 0x9AD7, 0xC2D5, 0x9AD8, 0xC2D6, 0x9AD9, 0xC2D7, 0x9ADA,\t0xC2D8, 0x9ADB, 0xC2D9, 0x9ADC, 0xC2DA, 0x9ADD, 0xC2DB, 0x9ADE,\r\n\t0xC2DC, 0xBDC3, 0xC2DD, 0xBDC4, 0xC2DE, 0x9ADF, 0xC2DF, 0x9AE0,\t0xC2E0, 0xBDC5, 0xC2E1, 0x9AE1, 0xC2E2, 0x9AE2, 0xC2E3, 0xBDC6,\r\n\t0xC2E4, 0xBDC7, 0xC2E5, 0x9AE3, 0xC2E6, 0x9AE4, 0xC2E7, 0x9AE5,\t0xC2E8, 0x9AE6, 0xC2E9, 0x9AE7, 0xC2EA, 0x9AE8, 0xC2EB, 0xBDC8,\r\n\t0xC2EC, 0xBDC9, 0xC2ED, 0xBDCA, 0xC2EE, 0x9AE9, 0xC2EF, 0xBDCB,\t0xC2F0, 0x9AEA, 0xC2F1, 0xBDCC, 0xC2F2, 0x9AEB, 0xC2F3, 0x9AEC,\r\n\t0xC2F4, 0x9AED, 0xC2F5, 0x9AEE, 0xC2F6, 0xBDCD, 0xC2F7, 0x9AEF,\t0xC2F8, 0xBDCE, 0xC2F9, 0xBDCF, 0xC2FA, 0x9AF0, 0xC2FB, 0xBDD0,\r\n\t0xC2FC, 0xBDD1, 0xC2FD, 0x9AF1, 0xC2FE, 0x9AF2, 0xC2FF, 0x9AF3,\t0xC300, 0xBDD2, 0xC301, 0x9AF4, 0xC302, 0x9AF5, 0xC303, 0x9AF6,\r\n\t0xC304, 0x9AF7, 0xC305, 0x9AF8, 0xC306, 0x9AF9, 0xC307, 0x9AFA,\t0xC308, 0xBDD3, 0xC309, 0xBDD4, 0xC30A, 0x9AFB, 0xC30B, 0x9AFC,\r\n\t0xC30C, 0xBDD5, 0xC30D, 0xBDD6, 0xC30E, 0x9AFD, 0xC30F, 0x9AFE,\t0xC310, 0x9B41, 0xC311, 0x9B42, 0xC312, 0x9B43, 0xC313, 0xBDD7,\r\n\t0xC314, 0xBDD8, 0xC315, 0xBDD9, 0xC316, 0x9B44, 0xC317, 0x9B45,\t0xC318, 0xBDDA, 0xC319, 0x9B46, 0xC31A, 0x9B47, 0xC31B, 0x9B48,\r\n\t0xC31C, 0xBDDB, 0xC31D, 0x9B49, 0xC31E, 0x9B4A, 0xC31F, 0x9B4B,\t0xC320, 0x9B4C, 0xC321, 0x9B4D, 0xC322, 0x9B4E, 0xC323, 0x9B4F,\r\n\t0xC324, 0xBDDC, 0xC325, 0xBDDD, 0xC326, 0x9B50, 0xC327, 0x9B51,\t0xC328, 0xBDDE, 0xC329, 0xBDDF, 0xC32A, 0x9B52, 0xC32B, 0x9B53,\r\n\t0xC32C, 0x9B54, 0xC32D, 0x9B55, 0xC32E, 0x9B56, 0xC32F, 0x9B57,\t0xC330, 0x9B58, 0xC331, 0x9B59, 0xC332, 0x9B5A, 0xC333, 0x9B61,\r\n\t0xC334, 0x9B62, 0xC335, 0x9B63, 0xC336, 0x9B64, 0xC337, 0x9B65,\t0xC338, 0x9B66, 0xC339, 0x9B67, 0xC33A, 0x9B68, 0xC33B, 0x9B69,\r\n\t0xC33C, 0x9B6A, 0xC33D, 0x9B6B, 0xC33E, 0x9B6C, 0xC33F, 0x9B6D,\t0xC340, 0x9B6E, 0xC341, 0x9B6F, 0xC342, 0x9B70, 0xC343, 0x9B71,\r\n\t0xC344, 0x9B72, 0xC345, 0xBDE0, 0xC346, 0x9B73, 0xC347, 0x9B74,\t0xC348, 0x9B75, 0xC349, 0x9B76, 0xC34A, 0x9B77, 0xC34B, 0x9B78,\r\n\t0xC34C, 0x9B79, 0xC34D, 0x9B7A, 0xC34E, 0x9B81, 0xC34F, 0x9B82,\t0xC350, 0x9B83, 0xC351, 0x9B84, 0xC352, 0x9B85, 0xC353, 0x9B86,\r\n\t0xC354, 0x9B87, 0xC355, 0x9B88, 0xC356, 0x9B89, 0xC357, 0x9B8A,\t0xC358, 0x9B8B, 0xC359, 0x9B8C, 0xC35A, 0x9B8D, 0xC35B, 0x9B8E,\r\n\t0xC35C, 0x9B8F, 0xC35D, 0x9B90, 0xC35E, 0x9B91, 0xC35F, 0x9B92,\t0xC360, 0x9B93, 0xC361, 0x9B94, 0xC362, 0x9B95, 0xC363, 0x9B96,\r\n\t0xC364, 0x9B97, 0xC365, 0x9B98, 0xC366, 0x9B99, 0xC367, 0x9B9A,\t0xC368, 0xBDE1, 0xC369, 0xBDE2, 0xC36A, 0x9B9B, 0xC36B, 0x9B9C,\r\n\t0xC36C, 0xBDE3, 0xC36D, 0x9B9D, 0xC36E, 0x9B9E, 0xC36F, 0x9B9F,\t0xC370, 0xBDE4, 0xC371, 0x9BA0, 0xC372, 0xBDE5, 0xC373, 0x9BA1,\r\n\t0xC374, 0x9BA2, 0xC375, 0x9BA3, 0xC376, 0x9BA4, 0xC377, 0x9BA5,\t0xC378, 0xBDE6, 0xC379, 0xBDE7, 0xC37A, 0x9BA6, 0xC37B, 0x9BA7,\r\n\t0xC37C, 0xBDE8, 0xC37D, 0xBDE9, 0xC37E, 0x9BA8, 0xC37F, 0x9BA9,\t0xC380, 0x9BAA, 0xC381, 0x9BAB, 0xC382, 0x9BAC, 0xC383, 0x9BAD,\r\n\t0xC384, 0xBDEA, 0xC385, 0x9BAE, 0xC386, 0x9BAF, 0xC387, 0x9BB0,\t0xC388, 0xBDEB, 0xC389, 0x9BB1, 0xC38A, 0x9BB2, 0xC38B, 0x9BB3,\r\n\t0xC38C, 0xBDEC, 0xC38D, 0x9BB4, 0xC38E, 0x9BB5, 0xC38F, 0x9BB6,\t0xC390, 0x9BB7, 0xC391, 0x9BB8, 0xC392, 0x9BB9, 0xC393, 0x9BBA,\r\n\t0xC394, 0x9BBB, 0xC395, 0x9BBC, 0xC396, 0x9BBD, 0xC397, 0x9BBE,\t0xC398, 0x9BBF, 0xC399, 0x9BC0, 0xC39A, 0x9BC1, 0xC39B, 0x9BC2,\r\n\t0xC39C, 0x9BC3, 0xC39D, 0x9BC4, 0xC39E, 0x9BC5, 0xC39F, 0x9BC6,\t0xC3A0, 0x9BC7, 0xC3A1, 0x9BC8, 0xC3A2, 0x9BC9, 0xC3A3, 0x9BCA,\r\n\t0xC3A4, 0x9BCB, 0xC3A5, 0x9BCC, 0xC3A6, 0x9BCD, 0xC3A7, 0x9BCE,\t0xC3A8, 0x9BCF, 0xC3A9, 0x9BD0, 0xC3AA, 0x9BD1, 0xC3AB, 0x9BD2,\r\n\t0xC3AC, 0x9BD3, 0xC3AD, 0x9BD4, 0xC3AE, 0x9BD5, 0xC3AF, 0x9BD6,\t0xC3B0, 0x9BD7, 0xC3B1, 0x9BD8, 0xC3B2, 0x9BD9, 0xC3B3, 0x9BDA,\r\n\t0xC3B4, 0x9BDB, 0xC3B5, 0x9BDC, 0xC3B6, 0x9BDD, 0xC3B7, 0x9BDE,\t0xC3B8, 0x9BDF, 0xC3B9, 0x9BE0, 0xC3BA, 0x9BE1, 0xC3BB, 0x9BE2,\r\n\t0xC3BC, 0x9BE3, 0xC3BD, 0x9BE4, 0xC3BE, 0x9BE5, 0xC3BF, 0x9BE6,\t0xC3C0, 0xBDED, 0xC3C1, 0x9BE7, 0xC3C2, 0x9BE8, 0xC3C3, 0x9BE9,\r\n\t0xC3C4, 0x9BEA, 0xC3C5, 0x9BEB, 0xC3C6, 0x9BEC, 0xC3C7, 0x9BED,\t0xC3C8, 0x9BEE, 0xC3C9, 0x9BEF, 0xC3CA, 0x9BF0, 0xC3CB, 0x9BF1,\r\n\t0xC3CC, 0x9BF2, 0xC3CD, 0x9BF3, 0xC3CE, 0x9BF4, 0xC3CF, 0x9BF5,\t0xC3D0, 0x9BF6, 0xC3D1, 0x9BF7, 0xC3D2, 0x9BF8, 0xC3D3, 0x9BF9,\r\n\t0xC3D4, 0x9BFA, 0xC3D5, 0x9BFB, 0xC3D6, 0x9BFC, 0xC3D7, 0x9BFD,\t0xC3D8, 0xBDEE, 0xC3D9, 0xBDEF, 0xC3DA, 0x9BFE, 0xC3DB, 0x9C41,\r\n\t0xC3DC, 0xBDF0, 0xC3DD, 0x9C42, 0xC3DE, 0x9C43, 0xC3DF, 0xBDF1,\t0xC3E0, 0xBDF2, 0xC3E1, 0x9C44, 0xC3E2, 0xBDF3, 0xC3E3, 0x9C45,\r\n\t0xC3E4, 0x9C46, 0xC3E5, 0x9C47, 0xC3E6, 0x9C48, 0xC3E7, 0x9C49,\t0xC3E8, 0xBDF4, 0xC3E9, 0xBDF5, 0xC3EA, 0x9C4A, 0xC3EB, 0x9C4B,\r\n\t0xC3EC, 0x9C4C, 0xC3ED, 0xBDF6, 0xC3EE, 0x9C4D, 0xC3EF, 0x9C4E,\t0xC3F0, 0x9C4F, 0xC3F1, 0x9C50, 0xC3F2, 0x9C51, 0xC3F3, 0x9C52,\r\n\t0xC3F4, 0xBDF7, 0xC3F5, 0xBDF8, 0xC3F6, 0x9C53, 0xC3F7, 0x9C54,\t0xC3F8, 0xBDF9, 0xC3F9, 0x9C55, 0xC3FA, 0x9C56, 0xC3FB, 0x9C57,\r\n\t0xC3FC, 0x9C58, 0xC3FD, 0x9C59, 0xC3FE, 0x9C5A, 0xC3FF, 0x9C61,\t0xC400, 0x9C62, 0xC401, 0x9C63, 0xC402, 0x9C64, 0xC403, 0x9C65,\r\n\t0xC404, 0x9C66, 0xC405, 0x9C67, 0xC406, 0x9C68, 0xC407, 0x9C69,\t0xC408, 0xBDFA, 0xC409, 0x9C6A, 0xC40A, 0x9C6B, 0xC40B, 0x9C6C,\r\n\t0xC40C, 0x9C6D, 0xC40D, 0x9C6E, 0xC40E, 0x9C6F, 0xC40F, 0x9C70,\t0xC410, 0xBDFB, 0xC411, 0x9C71, 0xC412, 0x9C72, 0xC413, 0x9C73,\r\n\t0xC414, 0x9C74, 0xC415, 0x9C75, 0xC416, 0x9C76, 0xC417, 0x9C77,\t0xC418, 0x9C78, 0xC419, 0x9C79, 0xC41A, 0x9C7A, 0xC41B, 0x9C81,\r\n\t0xC41C, 0x9C82, 0xC41D, 0x9C83, 0xC41E, 0x9C84, 0xC41F, 0x9C85,\t0xC420, 0x9C86, 0xC421, 0x9C87, 0xC422, 0x9C88, 0xC423, 0x9C89,\r\n\t0xC424, 0xBDFC, 0xC425, 0x9C8A, 0xC426, 0x9C8B, 0xC427, 0x9C8C,\t0xC428, 0x9C8D, 0xC429, 0x9C8E, 0xC42A, 0x9C8F, 0xC42B, 0x9C90,\r\n\t0xC42C, 0xBDFD, 0xC42D, 0x9C91, 0xC42E, 0x9C92, 0xC42F, 0x9C93,\t0xC430, 0xBDFE, 0xC431, 0x9C94, 0xC432, 0x9C95, 0xC433, 0x9C96,\r\n\t0xC434, 0xBEA1, 0xC435, 0x9C97, 0xC436, 0x9C98, 0xC437, 0x9C99,\t0xC438, 0x9C9A, 0xC439, 0x9C9B, 0xC43A, 0x9C9C, 0xC43B, 0x9C9D,\r\n\t0xC43C, 0xBEA2, 0xC43D, 0xBEA3, 0xC43E, 0x9C9E, 0xC43F, 0x9C9F,\t0xC440, 0x9CA0, 0xC441, 0x9CA1, 0xC442, 0x9CA2, 0xC443, 0x9CA3,\r\n\t0xC444, 0x9CA4, 0xC445, 0x9CA5, 0xC446, 0x9CA6, 0xC447, 0x9CA7,\t0xC448, 0xBEA4, 0xC449, 0x9CA8, 0xC44A, 0x9CA9, 0xC44B, 0x9CAA,\r\n\t0xC44C, 0x9CAB, 0xC44D, 0x9CAC, 0xC44E, 0x9CAD, 0xC44F, 0x9CAE,\t0xC450, 0x9CAF, 0xC451, 0x9CB0, 0xC452, 0x9CB1, 0xC453, 0x9CB2,\r\n\t0xC454, 0x9CB3, 0xC455, 0x9CB4, 0xC456, 0x9CB5, 0xC457, 0x9CB6,\t0xC458, 0x9CB7, 0xC459, 0x9CB8, 0xC45A, 0x9CB9, 0xC45B, 0x9CBA,\r\n\t0xC45C, 0x9CBB, 0xC45D, 0x9CBC, 0xC45E, 0x9CBD, 0xC45F, 0x9CBE,\t0xC460, 0x9CBF, 0xC461, 0x9CC0, 0xC462, 0x9CC1, 0xC463, 0x9CC2,\r\n\t0xC464, 0xBEA5, 0xC465, 0xBEA6, 0xC466, 0x9CC3, 0xC467, 0x9CC4,\t0xC468, 0xBEA7, 0xC469, 0x9CC5, 0xC46A, 0x9CC6, 0xC46B, 0x9CC7,\r\n\t0xC46C, 0xBEA8, 0xC46D, 0x9CC8, 0xC46E, 0x9CC9, 0xC46F, 0x9CCA,\t0xC470, 0x9CCB, 0xC471, 0x9CCC, 0xC472, 0x9CCD, 0xC473, 0x9CCE,\r\n\t0xC474, 0xBEA9, 0xC475, 0xBEAA, 0xC476, 0x9CCF, 0xC477, 0x9CD0,\t0xC478, 0x9CD1, 0xC479, 0xBEAB, 0xC47A, 0x9CD2, 0xC47B, 0x9CD3,\r\n\t0xC47C, 0x9CD4, 0xC47D, 0x9CD5, 0xC47E, 0x9CD6, 0xC47F, 0x9CD7,\t0xC480, 0xBEAC, 0xC481, 0x9CD8, 0xC482, 0x9CD9, 0xC483, 0x9CDA,\r\n\t0xC484, 0x9CDB, 0xC485, 0x9CDC, 0xC486, 0x9CDD, 0xC487, 0x9CDE,\t0xC488, 0x9CDF, 0xC489, 0x9CE0, 0xC48A, 0x9CE1, 0xC48B, 0x9CE2,\r\n\t0xC48C, 0x9CE3, 0xC48D, 0x9CE4, 0xC48E, 0x9CE5, 0xC48F, 0x9CE6,\t0xC490, 0x9CE7, 0xC491, 0x9CE8, 0xC492, 0x9CE9, 0xC493, 0x9CEA,\r\n\t0xC494, 0xBEAD, 0xC495, 0x9CEB, 0xC496, 0x9CEC, 0xC497, 0x9CED,\t0xC498, 0x9CEE, 0xC499, 0x9CEF, 0xC49A, 0x9CF0, 0xC49B, 0x9CF1,\r\n\t0xC49C, 0xBEAE, 0xC49D, 0x9CF2, 0xC49E, 0x9CF3, 0xC49F, 0x9CF4,\t0xC4A0, 0x9CF5, 0xC4A1, 0x9CF6, 0xC4A2, 0x9CF7, 0xC4A3, 0x9CF8,\r\n\t0xC4A4, 0x9CF9, 0xC4A5, 0x9CFA, 0xC4A6, 0x9CFB, 0xC4A7, 0x9CFC,\t0xC4A8, 0x9CFD, 0xC4A9, 0x9CFE, 0xC4AA, 0x9D41, 0xC4AB, 0x9D42,\r\n\t0xC4AC, 0x9D43, 0xC4AD, 0x9D44, 0xC4AE, 0x9D45, 0xC4AF, 0x9D46,\t0xC4B0, 0x9D47, 0xC4B1, 0x9D48, 0xC4B2, 0x9D49, 0xC4B3, 0x9D4A,\r\n\t0xC4B4, 0x9D4B, 0xC4B5, 0x9D4C, 0xC4B6, 0x9D4D, 0xC4B7, 0x9D4E,\t0xC4B8, 0xBEAF, 0xC4B9, 0x9D4F, 0xC4BA, 0x9D50, 0xC4BB, 0x9D51,\r\n\t0xC4BC, 0xBEB0, 0xC4BD, 0x9D52, 0xC4BE, 0x9D53, 0xC4BF, 0x9D54,\t0xC4C0, 0x9D55, 0xC4C1, 0x9D56, 0xC4C2, 0x9D57, 0xC4C3, 0x9D58,\r\n\t0xC4C4, 0x9D59, 0xC4C5, 0x9D5A, 0xC4C6, 0x9D61, 0xC4C7, 0x9D62,\t0xC4C8, 0x9D63, 0xC4C9, 0x9D64, 0xC4CA, 0x9D65, 0xC4CB, 0x9D66,\r\n\t0xC4CC, 0x9D67, 0xC4CD, 0x9D68, 0xC4CE, 0x9D69, 0xC4CF, 0x9D6A,\t0xC4D0, 0x9D6B, 0xC4D1, 0x9D6C, 0xC4D2, 0x9D6D, 0xC4D3, 0x9D6E,\r\n\t0xC4D4, 0x9D6F, 0xC4D5, 0x9D70, 0xC4D6, 0x9D71, 0xC4D7, 0x9D72,\t0xC4D8, 0x9D73, 0xC4D9, 0x9D74, 0xC4DA, 0x9D75, 0xC4DB, 0x9D76,\r\n\t0xC4DC, 0x9D77, 0xC4DD, 0x9D78, 0xC4DE, 0x9D79, 0xC4DF, 0x9D7A,\t0xC4E0, 0x9D81, 0xC4E1, 0x9D82, 0xC4E2, 0x9D83, 0xC4E3, 0x9D84,\r\n\t0xC4E4, 0x9D85, 0xC4E5, 0x9D86, 0xC4E6, 0x9D87, 0xC4E7, 0x9D88,\t0xC4E8, 0x9D89, 0xC4E9, 0xBEB1, 0xC4EA, 0x9D8A, 0xC4EB, 0x9D8B,\r\n\t0xC4EC, 0x9D8C, 0xC4ED, 0x9D8D, 0xC4EE, 0x9D8E, 0xC4EF, 0x9D8F,\t0xC4F0, 0xBEB2, 0xC4F1, 0xBEB3, 0xC4F2, 0x9D90, 0xC4F3, 0x9D91,\r\n\t0xC4F4, 0xBEB4, 0xC4F5, 0x9D92, 0xC4F6, 0x9D93, 0xC4F7, 0x9D94,\t0xC4F8, 0xBEB5, 0xC4F9, 0x9D95, 0xC4FA, 0xBEB6, 0xC4FB, 0x9D96,\r\n\t0xC4FC, 0x9D97, 0xC4FD, 0x9D98, 0xC4FE, 0x9D99, 0xC4FF, 0xBEB7,\t0xC500, 0xBEB8, 0xC501, 0xBEB9, 0xC502, 0x9D9A, 0xC503, 0x9D9B,\r\n\t0xC504, 0x9D9C, 0xC505, 0x9D9D, 0xC506, 0x9D9E, 0xC507, 0x9D9F,\t0xC508, 0x9DA0, 0xC509, 0x9DA1, 0xC50A, 0x9DA2, 0xC50B, 0x9DA3,\r\n\t0xC50C, 0xBEBA, 0xC50D, 0x9DA4, 0xC50E, 0x9DA5, 0xC50F, 0x9DA6,\t0xC510, 0xBEBB, 0xC511, 0x9DA7, 0xC512, 0x9DA8, 0xC513, 0x9DA9,\r\n\t0xC514, 0xBEBC, 0xC515, 0x9DAA, 0xC516, 0x9DAB, 0xC517, 0x9DAC,\t0xC518, 0x9DAD, 0xC519, 0x9DAE, 0xC51A, 0x9DAF, 0xC51B, 0x9DB0,\r\n\t0xC51C, 0xBEBD, 0xC51D, 0x9DB1, 0xC51E, 0x9DB2, 0xC51F, 0x9DB3,\t0xC520, 0x9DB4, 0xC521, 0x9DB5, 0xC522, 0x9DB6, 0xC523, 0x9DB7,\r\n\t0xC524, 0x9DB8, 0xC525, 0x9DB9, 0xC526, 0x9DBA, 0xC527, 0x9DBB,\t0xC528, 0xBEBE, 0xC529, 0xBEBF, 0xC52A, 0x9DBC, 0xC52B, 0x9DBD,\r\n\t0xC52C, 0xBEC0, 0xC52D, 0x9DBE, 0xC52E, 0x9DBF, 0xC52F, 0x9DC0,\t0xC530, 0xBEC1, 0xC531, 0x9DC1, 0xC532, 0x9DC2, 0xC533, 0x9DC3,\r\n\t0xC534, 0x9DC4, 0xC535, 0x9DC5, 0xC536, 0x9DC6, 0xC537, 0x9DC7,\t0xC538, 0xBEC2, 0xC539, 0xBEC3, 0xC53A, 0x9DC8, 0xC53B, 0xBEC4,\r\n\t0xC53C, 0x9DC9, 0xC53D, 0xBEC5, 0xC53E, 0x9DCA, 0xC53F, 0x9DCB,\t0xC540, 0x9DCC, 0xC541, 0x9DCD, 0xC542, 0x9DCE, 0xC543, 0x9DCF,\r\n\t0xC544, 0xBEC6, 0xC545, 0xBEC7, 0xC546, 0x9DD0, 0xC547, 0x9DD1,\t0xC548, 0xBEC8, 0xC549, 0xBEC9, 0xC54A, 0xBECA, 0xC54B, 0x9DD2,\r\n\t0xC54C, 0xBECB, 0xC54D, 0xBECC, 0xC54E, 0xBECD, 0xC54F, 0x9DD3,\t0xC550, 0x9DD4, 0xC551, 0x9DD5, 0xC552, 0x9DD6, 0xC553, 0xBECE,\r\n\t0xC554, 0xBECF, 0xC555, 0xBED0, 0xC556, 0x9DD7, 0xC557, 0xBED1,\t0xC558, 0xBED2, 0xC559, 0xBED3, 0xC55A, 0x9DD8, 0xC55B, 0x9DD9,\r\n\t0xC55C, 0x9DDA, 0xC55D, 0xBED4, 0xC55E, 0xBED5, 0xC55F, 0x9DDB,\t0xC560, 0xBED6, 0xC561, 0xBED7, 0xC562, 0x9DDC, 0xC563, 0x9DDD,\r\n\t0xC564, 0xBED8, 0xC565, 0x9DDE, 0xC566, 0x9DDF, 0xC567, 0x9DE0,\t0xC568, 0xBED9, 0xC569, 0x9DE1, 0xC56A, 0x9DE2, 0xC56B, 0x9DE3,\r\n\t0xC56C, 0x9DE4, 0xC56D, 0x9DE5, 0xC56E, 0x9DE6, 0xC56F, 0x9DE7,\t0xC570, 0xBEDA, 0xC571, 0xBEDB, 0xC572, 0x9DE8, 0xC573, 0xBEDC,\r\n\t0xC574, 0xBEDD, 0xC575, 0xBEDE, 0xC576, 0x9DE9, 0xC577, 0x9DEA,\t0xC578, 0x9DEB, 0xC579, 0x9DEC, 0xC57A, 0x9DED, 0xC57B, 0x9DEE,\r\n\t0xC57C, 0xBEDF, 0xC57D, 0xBEE0, 0xC57E, 0x9DEF, 0xC57F, 0x9DF0,\t0xC580, 0xBEE1, 0xC581, 0x9DF1, 0xC582, 0x9DF2, 0xC583, 0x9DF3,\r\n\t0xC584, 0xBEE2, 0xC585, 0x9DF4, 0xC586, 0x9DF5, 0xC587, 0xBEE3,\t0xC588, 0x9DF6, 0xC589, 0x9DF7, 0xC58A, 0x9DF8, 0xC58B, 0x9DF9,\r\n\t0xC58C, 0xBEE4, 0xC58D, 0xBEE5, 0xC58E, 0x9DFA, 0xC58F, 0xBEE6,\t0xC590, 0x9DFB, 0xC591, 0xBEE7, 0xC592, 0x9DFC, 0xC593, 0x9DFD,\r\n\t0xC594, 0x9DFE, 0xC595, 0xBEE8, 0xC596, 0x9E41, 0xC597, 0xBEE9,\t0xC598, 0xBEEA, 0xC599, 0x9E42, 0xC59A, 0x9E43, 0xC59B, 0x9E44,\r\n\t0xC59C, 0xBEEB, 0xC59D, 0x9E45, 0xC59E, 0x9E46, 0xC59F, 0x9E47,\t0xC5A0, 0xBEEC, 0xC5A1, 0x9E48, 0xC5A2, 0x9E49, 0xC5A3, 0x9E4A,\r\n\t0xC5A4, 0x9E4B, 0xC5A5, 0x9E4C, 0xC5A6, 0x9E4D, 0xC5A7, 0x9E4E,\t0xC5A8, 0x9E4F, 0xC5A9, 0xBEED, 0xC5AA, 0x9E50, 0xC5AB, 0x9E51,\r\n\t0xC5AC, 0x9E52, 0xC5AD, 0x9E53, 0xC5AE, 0x9E54, 0xC5AF, 0x9E55,\t0xC5B0, 0x9E56, 0xC5B1, 0x9E57, 0xC5B2, 0x9E58, 0xC5B3, 0x9E59,\r\n\t0xC5B4, 0xBEEE, 0xC5B5, 0xBEEF, 0xC5B6, 0x9E5A, 0xC5B7, 0x9E61,\t0xC5B8, 0xBEF0, 0xC5B9, 0xBEF1, 0xC5BA, 0x9E62, 0xC5BB, 0xBEF2,\r\n\t0xC5BC, 0xBEF3, 0xC5BD, 0xBEF4, 0xC5BE, 0xBEF5, 0xC5BF, 0x9E63,\t0xC5C0, 0x9E64, 0xC5C1, 0x9E65, 0xC5C2, 0x9E66, 0xC5C3, 0x9E67,\r\n\t0xC5C4, 0xBEF6, 0xC5C5, 0xBEF7, 0xC5C6, 0xBEF8, 0xC5C7, 0xBEF9,\t0xC5C8, 0xBEFA, 0xC5C9, 0xBEFB, 0xC5CA, 0xBEFC, 0xC5CB, 0x9E68,\r\n\t0xC5CC, 0xBEFD, 0xC5CD, 0x9E69, 0xC5CE, 0xBEFE, 0xC5CF, 0x9E6A,\t0xC5D0, 0xBFA1, 0xC5D1, 0xBFA2, 0xC5D2, 0x9E6B, 0xC5D3, 0x9E6C,\r\n\t0xC5D4, 0xBFA3, 0xC5D5, 0x9E6D, 0xC5D6, 0x9E6E, 0xC5D7, 0x9E6F,\t0xC5D8, 0xBFA4, 0xC5D9, 0x9E70, 0xC5DA, 0x9E71, 0xC5DB, 0x9E72,\r\n\t0xC5DC, 0x9E73, 0xC5DD, 0x9E74, 0xC5DE, 0x9E75, 0xC5DF, 0x9E76,\t0xC5E0, 0xBFA5, 0xC5E1, 0xBFA6, 0xC5E2, 0x9E77, 0xC5E3, 0xBFA7,\r\n\t0xC5E4, 0x9E78, 0xC5E5, 0xBFA8, 0xC5E6, 0x9E79, 0xC5E7, 0x9E7A,\t0xC5E8, 0x9E81, 0xC5E9, 0x9E82, 0xC5EA, 0x9E83, 0xC5EB, 0x9E84,\r\n\t0xC5EC, 0xBFA9, 0xC5ED, 0xBFAA, 0xC5EE, 0xBFAB, 0xC5EF, 0x9E85,\t0xC5F0, 0xBFAC, 0xC5F1, 0x9E86, 0xC5F2, 0x9E87, 0xC5F3, 0x9E88,\r\n\t0xC5F4, 0xBFAD, 0xC5F5, 0x9E89, 0xC5F6, 0xBFAE, 0xC5F7, 0xBFAF,\t0xC5F8, 0x9E8A, 0xC5F9, 0x9E8B, 0xC5FA, 0x9E8C, 0xC5FB, 0x9E8D,\r\n\t0xC5FC, 0xBFB0, 0xC5FD, 0xBFB1, 0xC5FE, 0xBFB2, 0xC5FF, 0xBFB3,\t0xC600, 0xBFB4, 0xC601, 0xBFB5, 0xC602, 0x9E8E, 0xC603, 0x9E8F,\r\n\t0xC604, 0x9E90, 0xC605, 0xBFB6, 0xC606, 0xBFB7, 0xC607, 0xBFB8,\t0xC608, 0xBFB9, 0xC609, 0x9E91, 0xC60A, 0x9E92, 0xC60B, 0x9E93,\r\n\t0xC60C, 0xBFBA, 0xC60D, 0x9E94, 0xC60E, 0x9E95, 0xC60F, 0x9E96,\t0xC610, 0xBFBB, 0xC611, 0x9E97, 0xC612, 0x9E98, 0xC613, 0x9E99,\r\n\t0xC614, 0x9E9A, 0xC615, 0x9E9B, 0xC616, 0x9E9C, 0xC617, 0x9E9D,\t0xC618, 0xBFBC, 0xC619, 0xBFBD, 0xC61A, 0x9E9E, 0xC61B, 0xBFBE,\r\n\t0xC61C, 0xBFBF, 0xC61D, 0x9E9F, 0xC61E, 0x9EA0, 0xC61F, 0x9EA1,\t0xC620, 0x9EA2, 0xC621, 0x9EA3, 0xC622, 0x9EA4, 0xC623, 0x9EA5,\r\n\t0xC624, 0xBFC0, 0xC625, 0xBFC1, 0xC626, 0x9EA6, 0xC627, 0x9EA7,\t0xC628, 0xBFC2, 0xC629, 0x9EA8, 0xC62A, 0x9EA9, 0xC62B, 0x9EAA,\r\n\t0xC62C, 0xBFC3, 0xC62D, 0xBFC4, 0xC62E, 0xBFC5, 0xC62F, 0x9EAB,\t0xC630, 0xBFC6, 0xC631, 0x9EAC, 0xC632, 0x9EAD, 0xC633, 0xBFC7,\r\n\t0xC634, 0xBFC8, 0xC635, 0xBFC9, 0xC636, 0x9EAE, 0xC637, 0xBFCA,\t0xC638, 0x9EAF, 0xC639, 0xBFCB, 0xC63A, 0x9EB0, 0xC63B, 0xBFCC,\r\n\t0xC63C, 0x9EB1, 0xC63D, 0x9EB2, 0xC63E, 0x9EB3, 0xC63F, 0x9EB4,\t0xC640, 0xBFCD, 0xC641, 0xBFCE, 0xC642, 0x9EB5, 0xC643, 0x9EB6,\r\n\t0xC644, 0xBFCF, 0xC645, 0x9EB7, 0xC646, 0x9EB8, 0xC647, 0x9EB9,\t0xC648, 0xBFD0, 0xC649, 0x9EBA, 0xC64A, 0x9EBB, 0xC64B, 0x9EBC,\r\n\t0xC64C, 0x9EBD, 0xC64D, 0x9EBE, 0xC64E, 0x9EBF, 0xC64F, 0x9EC0,\t0xC650, 0xBFD1, 0xC651, 0xBFD2, 0xC652, 0x9EC1, 0xC653, 0xBFD3,\r\n\t0xC654, 0xBFD4, 0xC655, 0xBFD5, 0xC656, 0x9EC2, 0xC657, 0x9EC3,\t0xC658, 0x9EC4, 0xC659, 0x9EC5, 0xC65A, 0x9EC6, 0xC65B, 0x9EC7,\r\n\t0xC65C, 0xBFD6, 0xC65D, 0xBFD7, 0xC65E, 0x9EC8, 0xC65F, 0x9EC9,\t0xC660, 0xBFD8, 0xC661, 0x9ECA, 0xC662, 0x9ECB, 0xC663, 0x9ECC,\r\n\t0xC664, 0x9ECD, 0xC665, 0x9ECE, 0xC666, 0x9ECF, 0xC667, 0x9ED0,\t0xC668, 0x9ED1, 0xC669, 0x9ED2, 0xC66A, 0x9ED3, 0xC66B, 0x9ED4,\r\n\t0xC66C, 0xBFD9, 0xC66D, 0x9ED5, 0xC66E, 0x9ED6, 0xC66F, 0xBFDA,\t0xC670, 0x9ED7, 0xC671, 0xBFDB, 0xC672, 0x9ED8, 0xC673, 0x9ED9,\r\n\t0xC674, 0x9EDA, 0xC675, 0x9EDB, 0xC676, 0x9EDC, 0xC677, 0x9EDD,\t0xC678, 0xBFDC, 0xC679, 0xBFDD, 0xC67A, 0x9EDE, 0xC67B, 0x9EDF,\r\n\t0xC67C, 0xBFDE, 0xC67D, 0x9EE0, 0xC67E, 0x9EE1, 0xC67F, 0x9EE2,\t0xC680, 0xBFDF, 0xC681, 0x9EE3, 0xC682, 0x9EE4, 0xC683, 0x9EE5,\r\n\t0xC684, 0x9EE6, 0xC685, 0x9EE7, 0xC686, 0x9EE8, 0xC687, 0x9EE9,\t0xC688, 0xBFE0, 0xC689, 0xBFE1, 0xC68A, 0x9EEA, 0xC68B, 0xBFE2,\r\n\t0xC68C, 0x9EEB, 0xC68D, 0xBFE3, 0xC68E, 0x9EEC, 0xC68F, 0x9EED,\t0xC690, 0x9EEE, 0xC691, 0x9EEF, 0xC692, 0x9EF0, 0xC693, 0x9EF1,\r\n\t0xC694, 0xBFE4, 0xC695, 0xBFE5, 0xC696, 0x9EF2, 0xC697, 0x9EF3,\t0xC698, 0xBFE6, 0xC699, 0x9EF4, 0xC69A, 0x9EF5, 0xC69B, 0x9EF6,\r\n\t0xC69C, 0xBFE7, 0xC69D, 0x9EF7, 0xC69E, 0x9EF8, 0xC69F, 0x9EF9,\t0xC6A0, 0x9EFA, 0xC6A1, 0x9EFB, 0xC6A2, 0x9EFC, 0xC6A3, 0x9EFD,\r\n\t0xC6A4, 0xBFE8, 0xC6A5, 0xBFE9, 0xC6A6, 0x9EFE, 0xC6A7, 0xBFEA,\t0xC6A8, 0x9F41, 0xC6A9, 0xBFEB, 0xC6AA, 0x9F42, 0xC6AB, 0x9F43,\r\n\t0xC6AC, 0x9F44, 0xC6AD, 0x9F45, 0xC6AE, 0x9F46, 0xC6AF, 0x9F47,\t0xC6B0, 0xBFEC, 0xC6B1, 0xBFED, 0xC6B2, 0x9F48, 0xC6B3, 0x9F49,\r\n\t0xC6B4, 0xBFEE, 0xC6B5, 0x9F4A, 0xC6B6, 0x9F4B, 0xC6B7, 0x9F4C,\t0xC6B8, 0xBFEF, 0xC6B9, 0xBFF0, 0xC6BA, 0xBFF1, 0xC6BB, 0x9F4D,\r\n\t0xC6BC, 0x9F4E, 0xC6BD, 0x9F4F, 0xC6BE, 0x9F50, 0xC6BF, 0x9F51,\t0xC6C0, 0xBFF2, 0xC6C1, 0xBFF3, 0xC6C2, 0x9F52, 0xC6C3, 0xBFF4,\r\n\t0xC6C4, 0x9F53, 0xC6C5, 0xBFF5, 0xC6C6, 0x9F54, 0xC6C7, 0x9F55,\t0xC6C8, 0x9F56, 0xC6C9, 0x9F57, 0xC6CA, 0x9F58, 0xC6CB, 0x9F59,\r\n\t0xC6CC, 0xBFF6, 0xC6CD, 0xBFF7, 0xC6CE, 0x9F5A, 0xC6CF, 0x9F61,\t0xC6D0, 0xBFF8, 0xC6D1, 0x9F62, 0xC6D2, 0x9F63, 0xC6D3, 0x9F64,\r\n\t0xC6D4, 0xBFF9, 0xC6D5, 0x9F65, 0xC6D6, 0x9F66, 0xC6D7, 0x9F67,\t0xC6D8, 0x9F68, 0xC6D9, 0x9F69, 0xC6DA, 0x9F6A, 0xC6DB, 0x9F6B,\r\n\t0xC6DC, 0xBFFA, 0xC6DD, 0xBFFB, 0xC6DE, 0x9F6C, 0xC6DF, 0x9F6D,\t0xC6E0, 0xBFFC, 0xC6E1, 0xBFFD, 0xC6E2, 0x9F6E, 0xC6E3, 0x9F6F,\r\n\t0xC6E4, 0x9F70, 0xC6E5, 0x9F71, 0xC6E6, 0x9F72, 0xC6E7, 0x9F73,\t0xC6E8, 0xBFFE, 0xC6E9, 0xC0A1, 0xC6EA, 0x9F74, 0xC6EB, 0x9F75,\r\n\t0xC6EC, 0xC0A2, 0xC6ED, 0x9F76, 0xC6EE, 0x9F77, 0xC6EF, 0x9F78,\t0xC6F0, 0xC0A3, 0xC6F1, 0x9F79, 0xC6F2, 0x9F7A, 0xC6F3, 0x9F81,\r\n\t0xC6F4, 0x9F82, 0xC6F5, 0x9F83, 0xC6F6, 0x9F84, 0xC6F7, 0x9F85,\t0xC6F8, 0xC0A4, 0xC6F9, 0xC0A5, 0xC6FA, 0x9F86, 0xC6FB, 0x9F87,\r\n\t0xC6FC, 0x9F88, 0xC6FD, 0xC0A6, 0xC6FE, 0x9F89, 0xC6FF, 0x9F8A,\t0xC700, 0x9F8B, 0xC701, 0x9F8C, 0xC702, 0x9F8D, 0xC703, 0x9F8E,\r\n\t0xC704, 0xC0A7, 0xC705, 0xC0A8, 0xC706, 0x9F8F, 0xC707, 0x9F90,\t0xC708, 0xC0A9, 0xC709, 0x9F91, 0xC70A, 0x9F92, 0xC70B, 0x9F93,\r\n\t0xC70C, 0xC0AA, 0xC70D, 0x9F94, 0xC70E, 0x9F95, 0xC70F, 0x9F96,\t0xC710, 0x9F97, 0xC711, 0x9F98, 0xC712, 0x9F99, 0xC713, 0x9F9A,\r\n\t0xC714, 0xC0AB, 0xC715, 0xC0AC, 0xC716, 0x9F9B, 0xC717, 0xC0AD,\t0xC718, 0x9F9C, 0xC719, 0xC0AE, 0xC71A, 0x9F9D, 0xC71B, 0x9F9E,\r\n\t0xC71C, 0x9F9F, 0xC71D, 0x9FA0, 0xC71E, 0x9FA1, 0xC71F, 0x9FA2,\t0xC720, 0xC0AF, 0xC721, 0xC0B0, 0xC722, 0x9FA3, 0xC723, 0x9FA4,\r\n\t0xC724, 0xC0B1, 0xC725, 0x9FA5, 0xC726, 0x9FA6, 0xC727, 0x9FA7,\t0xC728, 0xC0B2, 0xC729, 0x9FA8, 0xC72A, 0x9FA9, 0xC72B, 0x9FAA,\r\n\t0xC72C, 0x9FAB, 0xC72D, 0x9FAC, 0xC72E, 0x9FAD, 0xC72F, 0x9FAE,\t0xC730, 0xC0B3, 0xC731, 0xC0B4, 0xC732, 0x9FAF, 0xC733, 0xC0B5,\r\n\t0xC734, 0x9FB0, 0xC735, 0xC0B6, 0xC736, 0x9FB1, 0xC737, 0xC0B7,\t0xC738, 0x9FB2, 0xC739, 0x9FB3, 0xC73A, 0x9FB4, 0xC73B, 0x9FB5,\r\n\t0xC73C, 0xC0B8, 0xC73D, 0xC0B9, 0xC73E, 0x9FB6, 0xC73F, 0x9FB7,\t0xC740, 0xC0BA, 0xC741, 0x9FB8, 0xC742, 0x9FB9, 0xC743, 0x9FBA,\r\n\t0xC744, 0xC0BB, 0xC745, 0x9FBB, 0xC746, 0x9FBC, 0xC747, 0x9FBD,\t0xC748, 0x9FBE, 0xC749, 0x9FBF, 0xC74A, 0xC0BC, 0xC74B, 0x9FC0,\r\n\t0xC74C, 0xC0BD, 0xC74D, 0xC0BE, 0xC74E, 0x9FC1, 0xC74F, 0xC0BF,\t0xC750, 0x9FC2, 0xC751, 0xC0C0, 0xC752, 0xC0C1, 0xC753, 0xC0C2,\r\n\t0xC754, 0xC0C3, 0xC755, 0xC0C4, 0xC756, 0xC0C5, 0xC757, 0xC0C6,\t0xC758, 0xC0C7, 0xC759, 0x9FC3, 0xC75A, 0x9FC4, 0xC75B, 0x9FC5,\r\n\t0xC75C, 0xC0C8, 0xC75D, 0x9FC6, 0xC75E, 0x9FC7, 0xC75F, 0x9FC8,\t0xC760, 0xC0C9, 0xC761, 0x9FC9, 0xC762, 0x9FCA, 0xC763, 0x9FCB,\r\n\t0xC764, 0x9FCC, 0xC765, 0x9FCD, 0xC766, 0x9FCE, 0xC767, 0x9FCF,\t0xC768, 0xC0CA, 0xC769, 0x9FD0, 0xC76A, 0x9FD1, 0xC76B, 0xC0CB,\r\n\t0xC76C, 0x9FD2, 0xC76D, 0x9FD3, 0xC76E, 0x9FD4, 0xC76F, 0x9FD5,\t0xC770, 0x9FD6, 0xC771, 0x9FD7, 0xC772, 0x9FD8, 0xC773, 0x9FD9,\r\n\t0xC774, 0xC0CC, 0xC775, 0xC0CD, 0xC776, 0x9FDA, 0xC777, 0x9FDB,\t0xC778, 0xC0CE, 0xC779, 0x9FDC, 0xC77A, 0x9FDD, 0xC77B, 0x9FDE,\r\n\t0xC77C, 0xC0CF, 0xC77D, 0xC0D0, 0xC77E, 0xC0D1, 0xC77F, 0x9FDF,\t0xC780, 0x9FE0, 0xC781, 0x9FE1, 0xC782, 0x9FE2, 0xC783, 0xC0D2,\r\n\t0xC784, 0xC0D3, 0xC785, 0xC0D4, 0xC786, 0x9FE3, 0xC787, 0xC0D5,\t0xC788, 0xC0D6, 0xC789, 0xC0D7, 0xC78A, 0xC0D8, 0xC78B, 0x9FE4,\r\n\t0xC78C, 0x9FE5, 0xC78D, 0x9FE6, 0xC78E, 0xC0D9, 0xC78F, 0x9FE7,\t0xC790, 0xC0DA, 0xC791, 0xC0DB, 0xC792, 0x9FE8, 0xC793, 0x9FE9,\r\n\t0xC794, 0xC0DC, 0xC795, 0x9FEA, 0xC796, 0xC0DD, 0xC797, 0xC0DE,\t0xC798, 0xC0DF, 0xC799, 0x9FEB, 0xC79A, 0xC0E0, 0xC79B, 0x9FEC,\r\n\t0xC79C, 0x9FED, 0xC79D, 0x9FEE, 0xC79E, 0x9FEF, 0xC79F, 0x9FF0,\t0xC7A0, 0xC0E1, 0xC7A1, 0xC0E2, 0xC7A2, 0x9FF1, 0xC7A3, 0xC0E3,\r\n\t0xC7A4, 0xC0E4, 0xC7A5, 0xC0E5, 0xC7A6, 0xC0E6, 0xC7A7, 0x9FF2,\t0xC7A8, 0x9FF3, 0xC7A9, 0x9FF4, 0xC7AA, 0x9FF5, 0xC7AB, 0x9FF6,\r\n\t0xC7AC, 0xC0E7, 0xC7AD, 0xC0E8, 0xC7AE, 0x9FF7, 0xC7AF, 0x9FF8,\t0xC7B0, 0xC0E9, 0xC7B1, 0x9FF9, 0xC7B2, 0x9FFA, 0xC7B3, 0x9FFB,\r\n\t0xC7B4, 0xC0EA, 0xC7B5, 0x9FFC, 0xC7B6, 0x9FFD, 0xC7B7, 0x9FFE,\t0xC7B8, 0xA041, 0xC7B9, 0xA042, 0xC7BA, 0xA043, 0xC7BB, 0xA044,\r\n\t0xC7BC, 0xC0EB, 0xC7BD, 0xC0EC, 0xC7BE, 0xA045, 0xC7BF, 0xC0ED,\t0xC7C0, 0xC0EE, 0xC7C1, 0xC0EF, 0xC7C2, 0xA046, 0xC7C3, 0xA047,\r\n\t0xC7C4, 0xA048, 0xC7C5, 0xA049, 0xC7C6, 0xA04A, 0xC7C7, 0xA04B,\t0xC7C8, 0xC0F0, 0xC7C9, 0xC0F1, 0xC7CA, 0xA04C, 0xC7CB, 0xA04D,\r\n\t0xC7CC, 0xC0F2, 0xC7CD, 0xA04E, 0xC7CE, 0xC0F3, 0xC7CF, 0xA04F,\t0xC7D0, 0xC0F4, 0xC7D1, 0xA050, 0xC7D2, 0xA051, 0xC7D3, 0xA052,\r\n\t0xC7D4, 0xA053, 0xC7D5, 0xA054, 0xC7D6, 0xA055, 0xC7D7, 0xA056,\t0xC7D8, 0xC0F5, 0xC7D9, 0xA057, 0xC7DA, 0xA058, 0xC7DB, 0xA059,\r\n\t0xC7DC, 0xA05A, 0xC7DD, 0xC0F6, 0xC7DE, 0xA061, 0xC7DF, 0xA062,\t0xC7E0, 0xA063, 0xC7E1, 0xA064, 0xC7E2, 0xA065, 0xC7E3, 0xA066,\r\n\t0xC7E4, 0xC0F7, 0xC7E5, 0xA067, 0xC7E6, 0xA068, 0xC7E7, 0xA069,\t0xC7E8, 0xC0F8, 0xC7E9, 0xA06A, 0xC7EA, 0xA06B, 0xC7EB, 0xA06C,\r\n\t0xC7EC, 0xC0F9, 0xC7ED, 0xA06D, 0xC7EE, 0xA06E, 0xC7EF, 0xA06F,\t0xC7F0, 0xA070, 0xC7F1, 0xA071, 0xC7F2, 0xA072, 0xC7F3, 0xA073,\r\n\t0xC7F4, 0xA074, 0xC7F5, 0xA075, 0xC7F6, 0xA076, 0xC7F7, 0xA077,\t0xC7F8, 0xA078, 0xC7F9, 0xA079, 0xC7FA, 0xA07A, 0xC7FB, 0xA081,\r\n\t0xC7FC, 0xA082, 0xC7FD, 0xA083, 0xC7FE, 0xA084, 0xC7FF, 0xA085,\t0xC800, 0xC0FA, 0xC801, 0xC0FB, 0xC802, 0xA086, 0xC803, 0xA087,\r\n\t0xC804, 0xC0FC, 0xC805, 0xA088, 0xC806, 0xA089, 0xC807, 0xA08A,\t0xC808, 0xC0FD, 0xC809, 0xA08B, 0xC80A, 0xC0FE, 0xC80B, 0xA08C,\r\n\t0xC80C, 0xA08D, 0xC80D, 0xA08E, 0xC80E, 0xA08F, 0xC80F, 0xA090,\t0xC810, 0xC1A1, 0xC811, 0xC1A2, 0xC812, 0xA091, 0xC813, 0xC1A3,\r\n\t0xC814, 0xA092, 0xC815, 0xC1A4, 0xC816, 0xC1A5, 0xC817, 0xA093,\t0xC818, 0xA094, 0xC819, 0xA095, 0xC81A, 0xA096, 0xC81B, 0xA097,\r\n\t0xC81C, 0xC1A6, 0xC81D, 0xC1A7, 0xC81E, 0xA098, 0xC81F, 0xA099,\t0xC820, 0xC1A8, 0xC821, 0xA09A, 0xC822, 0xA09B, 0xC823, 0xA09C,\r\n\t0xC824, 0xC1A9, 0xC825, 0xA09D, 0xC826, 0xA09E, 0xC827, 0xA09F,\t0xC828, 0xA0A0, 0xC829, 0xA0A1, 0xC82A, 0xA0A2, 0xC82B, 0xA0A3,\r\n\t0xC82C, 0xC1AA, 0xC82D, 0xC1AB, 0xC82E, 0xA0A4, 0xC82F, 0xC1AC,\t0xC830, 0xA0A5, 0xC831, 0xC1AD, 0xC832, 0xA0A6, 0xC833, 0xA0A7,\r\n\t0xC834, 0xA0A8, 0xC835, 0xA0A9, 0xC836, 0xA0AA, 0xC837, 0xA0AB,\t0xC838, 0xC1AE, 0xC839, 0xA0AC, 0xC83A, 0xA0AD, 0xC83B, 0xA0AE,\r\n\t0xC83C, 0xC1AF, 0xC83D, 0xA0AF, 0xC83E, 0xA0B0, 0xC83F, 0xA0B1,\t0xC840, 0xC1B0, 0xC841, 0xA0B2, 0xC842, 0xA0B3, 0xC843, 0xA0B4,\r\n\t0xC844, 0xA0B5, 0xC845, 0xA0B6, 0xC846, 0xA0B7, 0xC847, 0xA0B8,\t0xC848, 0xC1B1, 0xC849, 0xC1B2, 0xC84A, 0xA0B9, 0xC84B, 0xA0BA,\r\n\t0xC84C, 0xC1B3, 0xC84D, 0xC1B4, 0xC84E, 0xA0BB, 0xC84F, 0xA0BC,\t0xC850, 0xA0BD, 0xC851, 0xA0BE, 0xC852, 0xA0BF, 0xC853, 0xA0C0,\r\n\t0xC854, 0xC1B5, 0xC855, 0xA0C1, 0xC856, 0xA0C2, 0xC857, 0xA0C3,\t0xC858, 0xA0C4, 0xC859, 0xA0C5, 0xC85A, 0xA0C6, 0xC85B, 0xA0C7,\r\n\t0xC85C, 0xA0C8, 0xC85D, 0xA0C9, 0xC85E, 0xA0CA, 0xC85F, 0xA0CB,\t0xC860, 0xA0CC, 0xC861, 0xA0CD, 0xC862, 0xA0CE, 0xC863, 0xA0CF,\r\n\t0xC864, 0xA0D0, 0xC865, 0xA0D1, 0xC866, 0xA0D2, 0xC867, 0xA0D3,\t0xC868, 0xA0D4, 0xC869, 0xA0D5, 0xC86A, 0xA0D6, 0xC86B, 0xA0D7,\r\n\t0xC86C, 0xA0D8, 0xC86D, 0xA0D9, 0xC86E, 0xA0DA, 0xC86F, 0xA0DB,\t0xC870, 0xC1B6, 0xC871, 0xC1B7, 0xC872, 0xA0DC, 0xC873, 0xA0DD,\r\n\t0xC874, 0xC1B8, 0xC875, 0xA0DE, 0xC876, 0xA0DF, 0xC877, 0xA0E0,\t0xC878, 0xC1B9, 0xC879, 0xA0E1, 0xC87A, 0xC1BA, 0xC87B, 0xA0E2,\r\n\t0xC87C, 0xA0E3, 0xC87D, 0xA0E4, 0xC87E, 0xA0E5, 0xC87F, 0xA0E6,\t0xC880, 0xC1BB, 0xC881, 0xC1BC, 0xC882, 0xA0E7, 0xC883, 0xC1BD,\r\n\t0xC884, 0xA0E8, 0xC885, 0xC1BE, 0xC886, 0xC1BF, 0xC887, 0xC1C0,\t0xC888, 0xA0E9, 0xC889, 0xA0EA, 0xC88A, 0xA0EB, 0xC88B, 0xC1C1,\r\n\t0xC88C, 0xC1C2, 0xC88D, 0xC1C3, 0xC88E, 0xA0EC, 0xC88F, 0xA0ED,\t0xC890, 0xA0EE, 0xC891, 0xA0EF, 0xC892, 0xA0F0, 0xC893, 0xA0F1,\r\n\t0xC894, 0xC1C4, 0xC895, 0xA0F2, 0xC896, 0xA0F3, 0xC897, 0xA0F4,\t0xC898, 0xA0F5, 0xC899, 0xA0F6, 0xC89A, 0xA0F7, 0xC89B, 0xA0F8,\r\n\t0xC89C, 0xA0F9, 0xC89D, 0xC1C5, 0xC89E, 0xA0FA, 0xC89F, 0xC1C6,\t0xC8A0, 0xA0FB, 0xC8A1, 0xC1C7, 0xC8A2, 0xA0FC, 0xC8A3, 0xA0FD,\r\n\t0xC8A4, 0xA0FE, 0xC8A5, 0xA141, 0xC8A6, 0xA142, 0xC8A7, 0xA143,\t0xC8A8, 0xC1C8, 0xC8A9, 0xA144, 0xC8AA, 0xA145, 0xC8AB, 0xA146,\r\n\t0xC8AC, 0xA147, 0xC8AD, 0xA148, 0xC8AE, 0xA149, 0xC8AF, 0xA14A,\t0xC8B0, 0xA14B, 0xC8B1, 0xA14C, 0xC8B2, 0xA14D, 0xC8B3, 0xA14E,\r\n\t0xC8B4, 0xA14F, 0xC8B5, 0xA150, 0xC8B6, 0xA151, 0xC8B7, 0xA152,\t0xC8B8, 0xA153, 0xC8B9, 0xA154, 0xC8BA, 0xA155, 0xC8BB, 0xA156,\r\n\t0xC8BC, 0xC1C9, 0xC8BD, 0xC1CA, 0xC8BE, 0xA157, 0xC8BF, 0xA158,\t0xC8C0, 0xA159, 0xC8C1, 0xA15A, 0xC8C2, 0xA161, 0xC8C3, 0xA162,\r\n\t0xC8C4, 0xC1CB, 0xC8C5, 0xA163, 0xC8C6, 0xA164, 0xC8C7, 0xA165,\t0xC8C8, 0xC1CC, 0xC8C9, 0xA166, 0xC8CA, 0xA167, 0xC8CB, 0xA168,\r\n\t0xC8CC, 0xC1CD, 0xC8CD, 0xA169, 0xC8CE, 0xA16A, 0xC8CF, 0xA16B,\t0xC8D0, 0xA16C, 0xC8D1, 0xA16D, 0xC8D2, 0xA16E, 0xC8D3, 0xA16F,\r\n\t0xC8D4, 0xC1CE, 0xC8D5, 0xC1CF, 0xC8D6, 0xA170, 0xC8D7, 0xC1D0,\t0xC8D8, 0xA171, 0xC8D9, 0xC1D1, 0xC8DA, 0xA172, 0xC8DB, 0xA173,\r\n\t0xC8DC, 0xA174, 0xC8DD, 0xA175, 0xC8DE, 0xA176, 0xC8DF, 0xA177,\t0xC8E0, 0xC1D2, 0xC8E1, 0xC1D3, 0xC8E2, 0xA178, 0xC8E3, 0xA179,\r\n\t0xC8E4, 0xC1D4, 0xC8E5, 0xA17A, 0xC8E6, 0xA181, 0xC8E7, 0xA182,\t0xC8E8, 0xA183, 0xC8E9, 0xA184, 0xC8EA, 0xA185, 0xC8EB, 0xA186,\r\n\t0xC8EC, 0xA187, 0xC8ED, 0xA188, 0xC8EE, 0xA189, 0xC8EF, 0xA18A,\t0xC8F0, 0xA18B, 0xC8F1, 0xA18C, 0xC8F2, 0xA18D, 0xC8F3, 0xA18E,\r\n\t0xC8F4, 0xA18F, 0xC8F5, 0xC1D5, 0xC8F6, 0xA190, 0xC8F7, 0xA191,\t0xC8F8, 0xA192, 0xC8F9, 0xA193, 0xC8FA, 0xA194, 0xC8FB, 0xA195,\r\n\t0xC8FC, 0xC1D6, 0xC8FD, 0xC1D7, 0xC8FE, 0xA196, 0xC8FF, 0xA197,\t0xC900, 0xC1D8, 0xC901, 0xA198, 0xC902, 0xA199, 0xC903, 0xA19A,\r\n\t0xC904, 0xC1D9, 0xC905, 0xC1DA, 0xC906, 0xC1DB, 0xC907, 0xA19B,\t0xC908, 0xA19C, 0xC909, 0xA19D, 0xC90A, 0xA19E, 0xC90B, 0xA19F,\r\n\t0xC90C, 0xC1DC, 0xC90D, 0xC1DD, 0xC90E, 0xA1A0, 0xC90F, 0xC1DE,\t0xC910, 0xA241, 0xC911, 0xC1DF, 0xC912, 0xA242, 0xC913, 0xA243,\r\n\t0xC914, 0xA244, 0xC915, 0xA245, 0xC916, 0xA246, 0xC917, 0xA247,\t0xC918, 0xC1E0, 0xC919, 0xA248, 0xC91A, 0xA249, 0xC91B, 0xA24A,\r\n\t0xC91C, 0xA24B, 0xC91D, 0xA24C, 0xC91E, 0xA24D, 0xC91F, 0xA24E,\t0xC920, 0xA24F, 0xC921, 0xA250, 0xC922, 0xA251, 0xC923, 0xA252,\r\n\t0xC924, 0xA253, 0xC925, 0xA254, 0xC926, 0xA255, 0xC927, 0xA256,\t0xC928, 0xA257, 0xC929, 0xA258, 0xC92A, 0xA259, 0xC92B, 0xA25A,\r\n\t0xC92C, 0xC1E1, 0xC92D, 0xA261, 0xC92E, 0xA262, 0xC92F, 0xA263,\t0xC930, 0xA264, 0xC931, 0xA265, 0xC932, 0xA266, 0xC933, 0xA267,\r\n\t0xC934, 0xC1E2, 0xC935, 0xA268, 0xC936, 0xA269, 0xC937, 0xA26A,\t0xC938, 0xA26B, 0xC939, 0xA26C, 0xC93A, 0xA26D, 0xC93B, 0xA26E,\r\n\t0xC93C, 0xA26F, 0xC93D, 0xA270, 0xC93E, 0xA271, 0xC93F, 0xA272,\t0xC940, 0xA273, 0xC941, 0xA274, 0xC942, 0xA275, 0xC943, 0xA276,\r\n\t0xC944, 0xA277, 0xC945, 0xA278, 0xC946, 0xA279, 0xC947, 0xA27A,\t0xC948, 0xA281, 0xC949, 0xA282, 0xC94A, 0xA283, 0xC94B, 0xA284,\r\n\t0xC94C, 0xA285, 0xC94D, 0xA286, 0xC94E, 0xA287, 0xC94F, 0xA288,\t0xC950, 0xC1E3, 0xC951, 0xC1E4, 0xC952, 0xA289, 0xC953, 0xA28A,\r\n\t0xC954, 0xC1E5, 0xC955, 0xA28B, 0xC956, 0xA28C, 0xC957, 0xA28D,\t0xC958, 0xC1E6, 0xC959, 0xA28E, 0xC95A, 0xA28F, 0xC95B, 0xA290,\r\n\t0xC95C, 0xA291, 0xC95D, 0xA292, 0xC95E, 0xA293, 0xC95F, 0xA294,\t0xC960, 0xC1E7, 0xC961, 0xC1E8, 0xC962, 0xA295, 0xC963, 0xC1E9,\r\n\t0xC964, 0xA296, 0xC965, 0xA297, 0xC966, 0xA298, 0xC967, 0xA299,\t0xC968, 0xA29A, 0xC969, 0xA29B, 0xC96A, 0xA29C, 0xC96B, 0xA29D,\r\n\t0xC96C, 0xC1EA, 0xC96D, 0xA29E, 0xC96E, 0xA29F, 0xC96F, 0xA2A0,\t0xC970, 0xC1EB, 0xC971, 0xA341, 0xC972, 0xA342, 0xC973, 0xA343,\r\n\t0xC974, 0xC1EC, 0xC975, 0xA344, 0xC976, 0xA345, 0xC977, 0xA346,\t0xC978, 0xA347, 0xC979, 0xA348, 0xC97A, 0xA349, 0xC97B, 0xA34A,\r\n\t0xC97C, 0xC1ED, 0xC97D, 0xA34B, 0xC97E, 0xA34C, 0xC97F, 0xA34D,\t0xC980, 0xA34E, 0xC981, 0xA34F, 0xC982, 0xA350, 0xC983, 0xA351,\r\n\t0xC984, 0xA352, 0xC985, 0xA353, 0xC986, 0xA354, 0xC987, 0xA355,\t0xC988, 0xC1EE, 0xC989, 0xC1EF, 0xC98A, 0xA356, 0xC98B, 0xA357,\r\n\t0xC98C, 0xC1F0, 0xC98D, 0xA358, 0xC98E, 0xA359, 0xC98F, 0xA35A,\t0xC990, 0xC1F1, 0xC991, 0xA361, 0xC992, 0xA362, 0xC993, 0xA363,\r\n\t0xC994, 0xA364, 0xC995, 0xA365, 0xC996, 0xA366, 0xC997, 0xA367,\t0xC998, 0xC1F2, 0xC999, 0xC1F3, 0xC99A, 0xA368, 0xC99B, 0xC1F4,\r\n\t0xC99C, 0xA369, 0xC99D, 0xC1F5, 0xC99E, 0xA36A, 0xC99F, 0xA36B,\t0xC9A0, 0xA36C, 0xC9A1, 0xA36D, 0xC9A2, 0xA36E, 0xC9A3, 0xA36F,\r\n\t0xC9A4, 0xA370, 0xC9A5, 0xA371, 0xC9A6, 0xA372, 0xC9A7, 0xA373,\t0xC9A8, 0xA374, 0xC9A9, 0xA375, 0xC9AA, 0xA376, 0xC9AB, 0xA377,\r\n\t0xC9AC, 0xA378, 0xC9AD, 0xA379, 0xC9AE, 0xA37A, 0xC9AF, 0xA381,\t0xC9B0, 0xA382, 0xC9B1, 0xA383, 0xC9B2, 0xA384, 0xC9B3, 0xA385,\r\n\t0xC9B4, 0xA386, 0xC9B5, 0xA387, 0xC9B6, 0xA388, 0xC9B7, 0xA389,\t0xC9B8, 0xA38A, 0xC9B9, 0xA38B, 0xC9BA, 0xA38C, 0xC9BB, 0xA38D,\r\n\t0xC9BC, 0xA38E, 0xC9BD, 0xA38F, 0xC9BE, 0xA390, 0xC9BF, 0xA391,\t0xC9C0, 0xC1F6, 0xC9C1, 0xC1F7, 0xC9C2, 0xA392, 0xC9C3, 0xA393,\r\n\t0xC9C4, 0xC1F8, 0xC9C5, 0xA394, 0xC9C6, 0xA395, 0xC9C7, 0xC1F9,\t0xC9C8, 0xC1FA, 0xC9C9, 0xA396, 0xC9CA, 0xC1FB, 0xC9CB, 0xA397,\r\n\t0xC9CC, 0xA398, 0xC9CD, 0xA399, 0xC9CE, 0xA39A, 0xC9CF, 0xA39B,\t0xC9D0, 0xC1FC, 0xC9D1, 0xC1FD, 0xC9D2, 0xA39C, 0xC9D3, 0xC1FE,\r\n\t0xC9D4, 0xA39D, 0xC9D5, 0xC2A1, 0xC9D6, 0xC2A2, 0xC9D7, 0xA39E,\t0xC9D8, 0xA39F, 0xC9D9, 0xC2A3, 0xC9DA, 0xC2A4, 0xC9DB, 0xA3A0,\r\n\t0xC9DC, 0xC2A5, 0xC9DD, 0xC2A6, 0xC9DE, 0xA441, 0xC9DF, 0xA442,\t0xC9E0, 0xC2A7, 0xC9E1, 0xA443, 0xC9E2, 0xC2A8, 0xC9E3, 0xA444,\r\n\t0xC9E4, 0xC2A9, 0xC9E5, 0xA445, 0xC9E6, 0xA446, 0xC9E7, 0xC2AA,\t0xC9E8, 0xA447, 0xC9E9, 0xA448, 0xC9EA, 0xA449, 0xC9EB, 0xA44A,\r\n\t0xC9EC, 0xC2AB, 0xC9ED, 0xC2AC, 0xC9EE, 0xA44B, 0xC9EF, 0xC2AD,\t0xC9F0, 0xC2AE, 0xC9F1, 0xC2AF, 0xC9F2, 0xA44C, 0xC9F3, 0xA44D,\r\n\t0xC9F4, 0xA44E, 0xC9F5, 0xA44F, 0xC9F6, 0xA450, 0xC9F7, 0xA451,\t0xC9F8, 0xC2B0, 0xC9F9, 0xC2B1, 0xC9FA, 0xA452, 0xC9FB, 0xA453,\r\n\t0xC9FC, 0xC2B2, 0xC9FD, 0xA454, 0xC9FE, 0xA455, 0xC9FF, 0xA456,\t0xCA00, 0xC2B3, 0xCA01, 0xA457, 0xCA02, 0xA458, 0xCA03, 0xA459,\r\n\t0xCA04, 0xA45A, 0xCA05, 0xA461, 0xCA06, 0xA462, 0xCA07, 0xA463,\t0xCA08, 0xC2B4, 0xCA09, 0xC2B5, 0xCA0A, 0xA464, 0xCA0B, 0xC2B6,\r\n\t0xCA0C, 0xC2B7, 0xCA0D, 0xC2B8, 0xCA0E, 0xA465, 0xCA0F, 0xA466,\t0xCA10, 0xA467, 0xCA11, 0xA468, 0xCA12, 0xA469, 0xCA13, 0xA46A,\r\n\t0xCA14, 0xC2B9, 0xCA15, 0xA46B, 0xCA16, 0xA46C, 0xCA17, 0xA46D,\t0xCA18, 0xC2BA, 0xCA19, 0xA46E, 0xCA1A, 0xA46F, 0xCA1B, 0xA470,\r\n\t0xCA1C, 0xA471, 0xCA1D, 0xA472, 0xCA1E, 0xA473, 0xCA1F, 0xA474,\t0xCA20, 0xA475, 0xCA21, 0xA476, 0xCA22, 0xA477, 0xCA23, 0xA478,\r\n\t0xCA24, 0xA479, 0xCA25, 0xA47A, 0xCA26, 0xA481, 0xCA27, 0xA482,\t0xCA28, 0xA483, 0xCA29, 0xC2BB, 0xCA2A, 0xA484, 0xCA2B, 0xA485,\r\n\t0xCA2C, 0xA486, 0xCA2D, 0xA487, 0xCA2E, 0xA488, 0xCA2F, 0xA489,\t0xCA30, 0xA48A, 0xCA31, 0xA48B, 0xCA32, 0xA48C, 0xCA33, 0xA48D,\r\n\t0xCA34, 0xA48E, 0xCA35, 0xA48F, 0xCA36, 0xA490, 0xCA37, 0xA491,\t0xCA38, 0xA492, 0xCA39, 0xA493, 0xCA3A, 0xA494, 0xCA3B, 0xA495,\r\n\t0xCA3C, 0xA496, 0xCA3D, 0xA497, 0xCA3E, 0xA498, 0xCA3F, 0xA499,\t0xCA40, 0xA49A, 0xCA41, 0xA49B, 0xCA42, 0xA49C, 0xCA43, 0xA49D,\r\n\t0xCA44, 0xA49E, 0xCA45, 0xA49F, 0xCA46, 0xA4A0, 0xCA47, 0xA541,\t0xCA48, 0xA542, 0xCA49, 0xA543, 0xCA4A, 0xA544, 0xCA4B, 0xA545,\r\n\t0xCA4C, 0xC2BC, 0xCA4D, 0xC2BD, 0xCA4E, 0xA546, 0xCA4F, 0xA547,\t0xCA50, 0xC2BE, 0xCA51, 0xA548, 0xCA52, 0xA549, 0xCA53, 0xA54A,\r\n\t0xCA54, 0xC2BF, 0xCA55, 0xA54B, 0xCA56, 0xA54C, 0xCA57, 0xA54D,\t0xCA58, 0xA54E, 0xCA59, 0xA54F, 0xCA5A, 0xA550, 0xCA5B, 0xA551,\r\n\t0xCA5C, 0xC2C0, 0xCA5D, 0xC2C1, 0xCA5E, 0xA552, 0xCA5F, 0xC2C2,\t0xCA60, 0xC2C3, 0xCA61, 0xC2C4, 0xCA62, 0xA553, 0xCA63, 0xA554,\r\n\t0xCA64, 0xA555, 0xCA65, 0xA556, 0xCA66, 0xA557, 0xCA67, 0xA558,\t0xCA68, 0xC2C5, 0xCA69, 0xA559, 0xCA6A, 0xA55A, 0xCA6B, 0xA561,\r\n\t0xCA6C, 0xA562, 0xCA6D, 0xA563, 0xCA6E, 0xA564, 0xCA6F, 0xA565,\t0xCA70, 0xA566, 0xCA71, 0xA567, 0xCA72, 0xA568, 0xCA73, 0xA569,\r\n\t0xCA74, 0xA56A, 0xCA75, 0xA56B, 0xCA76, 0xA56C, 0xCA77, 0xA56D,\t0xCA78, 0xA56E, 0xCA79, 0xA56F, 0xCA7A, 0xA570, 0xCA7B, 0xA571,\r\n\t0xCA7C, 0xA572, 0xCA7D, 0xC2C6, 0xCA7E, 0xA573, 0xCA7F, 0xA574,\t0xCA80, 0xA575, 0xCA81, 0xA576, 0xCA82, 0xA577, 0xCA83, 0xA578,\r\n\t0xCA84, 0xC2C7, 0xCA85, 0xA579, 0xCA86, 0xA57A, 0xCA87, 0xA581,\t0xCA88, 0xA582, 0xCA89, 0xA583, 0xCA8A, 0xA584, 0xCA8B, 0xA585,\r\n\t0xCA8C, 0xA586, 0xCA8D, 0xA587, 0xCA8E, 0xA588, 0xCA8F, 0xA589,\t0xCA90, 0xA58A, 0xCA91, 0xA58B, 0xCA92, 0xA58C, 0xCA93, 0xA58D,\r\n\t0xCA94, 0xA58E, 0xCA95, 0xA58F, 0xCA96, 0xA590, 0xCA97, 0xA591,\t0xCA98, 0xC2C8, 0xCA99, 0xA592, 0xCA9A, 0xA593, 0xCA9B, 0xA594,\r\n\t0xCA9C, 0xA595, 0xCA9D, 0xA596, 0xCA9E, 0xA597, 0xCA9F, 0xA598,\t0xCAA0, 0xA599, 0xCAA1, 0xA59A, 0xCAA2, 0xA59B, 0xCAA3, 0xA59C,\r\n\t0xCAA4, 0xA59D, 0xCAA5, 0xA59E, 0xCAA6, 0xA59F, 0xCAA7, 0xA5A0,\t0xCAA8, 0xA641, 0xCAA9, 0xA642, 0xCAAA, 0xA643, 0xCAAB, 0xA644,\r\n\t0xCAAC, 0xA645, 0xCAAD, 0xA646, 0xCAAE, 0xA647, 0xCAAF, 0xA648,\t0xCAB0, 0xA649, 0xCAB1, 0xA64A, 0xCAB2, 0xA64B, 0xCAB3, 0xA64C,\r\n\t0xCAB4, 0xA64D, 0xCAB5, 0xA64E, 0xCAB6, 0xA64F, 0xCAB7, 0xA650,\t0xCAB8, 0xA651, 0xCAB9, 0xA652, 0xCABA, 0xA653, 0xCABB, 0xA654,\r\n\t0xCABC, 0xC2C9, 0xCABD, 0xC2CA, 0xCABE, 0xA655, 0xCABF, 0xA656,\t0xCAC0, 0xC2CB, 0xCAC1, 0xA657, 0xCAC2, 0xA658, 0xCAC3, 0xA659,\r\n\t0xCAC4, 0xC2CC, 0xCAC5, 0xA65A, 0xCAC6, 0xA661, 0xCAC7, 0xA662,\t0xCAC8, 0xA663, 0xCAC9, 0xA664, 0xCACA, 0xA665, 0xCACB, 0xA666,\r\n\t0xCACC, 0xC2CD, 0xCACD, 0xC2CE, 0xCACE, 0xA667, 0xCACF, 0xC2CF,\t0xCAD0, 0xA668, 0xCAD1, 0xC2D0, 0xCAD2, 0xA669, 0xCAD3, 0xC2D1,\r\n\t0xCAD4, 0xA66A, 0xCAD5, 0xA66B, 0xCAD6, 0xA66C, 0xCAD7, 0xA66D,\t0xCAD8, 0xC2D2, 0xCAD9, 0xC2D3, 0xCADA, 0xA66E, 0xCADB, 0xA66F,\r\n\t0xCADC, 0xA670, 0xCADD, 0xA671, 0xCADE, 0xA672, 0xCADF, 0xA673,\t0xCAE0, 0xC2D4, 0xCAE1, 0xA674, 0xCAE2, 0xA675, 0xCAE3, 0xA676,\r\n\t0xCAE4, 0xA677, 0xCAE5, 0xA678, 0xCAE6, 0xA679, 0xCAE7, 0xA67A,\t0xCAE8, 0xA681, 0xCAE9, 0xA682, 0xCAEA, 0xA683, 0xCAEB, 0xA684,\r\n\t0xCAEC, 0xC2D5, 0xCAED, 0xA685, 0xCAEE, 0xA686, 0xCAEF, 0xA687,\t0xCAF0, 0xA688, 0xCAF1, 0xA689, 0xCAF2, 0xA68A, 0xCAF3, 0xA68B,\r\n\t0xCAF4, 0xC2D6, 0xCAF5, 0xA68C, 0xCAF6, 0xA68D, 0xCAF7, 0xA68E,\t0xCAF8, 0xA68F, 0xCAF9, 0xA690, 0xCAFA, 0xA691, 0xCAFB, 0xA692,\r\n\t0xCAFC, 0xA693, 0xCAFD, 0xA694, 0xCAFE, 0xA695, 0xCAFF, 0xA696,\t0xCB00, 0xA697, 0xCB01, 0xA698, 0xCB02, 0xA699, 0xCB03, 0xA69A,\r\n\t0xCB04, 0xA69B, 0xCB05, 0xA69C, 0xCB06, 0xA69D, 0xCB07, 0xA69E,\t0xCB08, 0xC2D7, 0xCB09, 0xA69F, 0xCB0A, 0xA6A0, 0xCB0B, 0xA741,\r\n\t0xCB0C, 0xA742, 0xCB0D, 0xA743, 0xCB0E, 0xA744, 0xCB0F, 0xA745,\t0xCB10, 0xC2D8, 0xCB11, 0xA746, 0xCB12, 0xA747, 0xCB13, 0xA748,\r\n\t0xCB14, 0xC2D9, 0xCB15, 0xA749, 0xCB16, 0xA74A, 0xCB17, 0xA74B,\t0xCB18, 0xC2DA, 0xCB19, 0xA74C, 0xCB1A, 0xA74D, 0xCB1B, 0xA74E,\r\n\t0xCB1C, 0xA74F, 0xCB1D, 0xA750, 0xCB1E, 0xA751, 0xCB1F, 0xA752,\t0xCB20, 0xC2DB, 0xCB21, 0xC2DC, 0xCB22, 0xA753, 0xCB23, 0xA754,\r\n\t0xCB24, 0xA755, 0xCB25, 0xA756, 0xCB26, 0xA757, 0xCB27, 0xA758,\t0xCB28, 0xA759, 0xCB29, 0xA75A, 0xCB2A, 0xA761, 0xCB2B, 0xA762,\r\n\t0xCB2C, 0xA763, 0xCB2D, 0xA764, 0xCB2E, 0xA765, 0xCB2F, 0xA766,\t0xCB30, 0xA767, 0xCB31, 0xA768, 0xCB32, 0xA769, 0xCB33, 0xA76A,\r\n\t0xCB34, 0xA76B, 0xCB35, 0xA76C, 0xCB36, 0xA76D, 0xCB37, 0xA76E,\t0xCB38, 0xA76F, 0xCB39, 0xA770, 0xCB3A, 0xA771, 0xCB3B, 0xA772,\r\n\t0xCB3C, 0xA773, 0xCB3D, 0xA774, 0xCB3E, 0xA775, 0xCB3F, 0xA776,\t0xCB40, 0xA777, 0xCB41, 0xC2DD, 0xCB42, 0xA778, 0xCB43, 0xA779,\r\n\t0xCB44, 0xA77A, 0xCB45, 0xA781, 0xCB46, 0xA782, 0xCB47, 0xA783,\t0xCB48, 0xC2DE, 0xCB49, 0xC2DF, 0xCB4A, 0xA784, 0xCB4B, 0xA785,\r\n\t0xCB4C, 0xC2E0, 0xCB4D, 0xA786, 0xCB4E, 0xA787, 0xCB4F, 0xA788,\t0xCB50, 0xC2E1, 0xCB51, 0xA789, 0xCB52, 0xA78A, 0xCB53, 0xA78B,\r\n\t0xCB54, 0xA78C, 0xCB55, 0xA78D, 0xCB56, 0xA78E, 0xCB57, 0xA78F,\t0xCB58, 0xC2E2, 0xCB59, 0xC2E3, 0xCB5A, 0xA790, 0xCB5B, 0xA791,\r\n\t0xCB5C, 0xA792, 0xCB5D, 0xC2E4, 0xCB5E, 0xA793, 0xCB5F, 0xA794,\t0xCB60, 0xA795, 0xCB61, 0xA796, 0xCB62, 0xA797, 0xCB63, 0xA798,\r\n\t0xCB64, 0xC2E5, 0xCB65, 0xA799, 0xCB66, 0xA79A, 0xCB67, 0xA79B,\t0xCB68, 0xA79C, 0xCB69, 0xA79D, 0xCB6A, 0xA79E, 0xCB6B, 0xA79F,\r\n\t0xCB6C, 0xA7A0, 0xCB6D, 0xA841, 0xCB6E, 0xA842, 0xCB6F, 0xA843,\t0xCB70, 0xA844, 0xCB71, 0xA845, 0xCB72, 0xA846, 0xCB73, 0xA847,\r\n\t0xCB74, 0xA848, 0xCB75, 0xA849, 0xCB76, 0xA84A, 0xCB77, 0xA84B,\t0xCB78, 0xC2E6, 0xCB79, 0xC2E7, 0xCB7A, 0xA84C, 0xCB7B, 0xA84D,\r\n\t0xCB7C, 0xA84E, 0xCB7D, 0xA84F, 0xCB7E, 0xA850, 0xCB7F, 0xA851,\t0xCB80, 0xA852, 0xCB81, 0xA853, 0xCB82, 0xA854, 0xCB83, 0xA855,\r\n\t0xCB84, 0xA856, 0xCB85, 0xA857, 0xCB86, 0xA858, 0xCB87, 0xA859,\t0xCB88, 0xA85A, 0xCB89, 0xA861, 0xCB8A, 0xA862, 0xCB8B, 0xA863,\r\n\t0xCB8C, 0xA864, 0xCB8D, 0xA865, 0xCB8E, 0xA866, 0xCB8F, 0xA867,\t0xCB90, 0xA868, 0xCB91, 0xA869, 0xCB92, 0xA86A, 0xCB93, 0xA86B,\r\n\t0xCB94, 0xA86C, 0xCB95, 0xA86D, 0xCB96, 0xA86E, 0xCB97, 0xA86F,\t0xCB98, 0xA870, 0xCB99, 0xA871, 0xCB9A, 0xA872, 0xCB9B, 0xA873,\r\n\t0xCB9C, 0xC2E8, 0xCB9D, 0xA874, 0xCB9E, 0xA875, 0xCB9F, 0xA876,\t0xCBA0, 0xA877, 0xCBA1, 0xA878, 0xCBA2, 0xA879, 0xCBA3, 0xA87A,\r\n\t0xCBA4, 0xA881, 0xCBA5, 0xA882, 0xCBA6, 0xA883, 0xCBA7, 0xA884,\t0xCBA8, 0xA885, 0xCBA9, 0xA886, 0xCBAA, 0xA887, 0xCBAB, 0xA888,\r\n\t0xCBAC, 0xA889, 0xCBAD, 0xA88A, 0xCBAE, 0xA88B, 0xCBAF, 0xA88C,\t0xCBB0, 0xA88D, 0xCBB1, 0xA88E, 0xCBB2, 0xA88F, 0xCBB3, 0xA890,\r\n\t0xCBB4, 0xA891, 0xCBB5, 0xA892, 0xCBB6, 0xA893, 0xCBB7, 0xA894,\t0xCBB8, 0xC2E9, 0xCBB9, 0xA895, 0xCBBA, 0xA896, 0xCBBB, 0xA897,\r\n\t0xCBBC, 0xA898, 0xCBBD, 0xA899, 0xCBBE, 0xA89A, 0xCBBF, 0xA89B,\t0xCBC0, 0xA89C, 0xCBC1, 0xA89D, 0xCBC2, 0xA89E, 0xCBC3, 0xA89F,\r\n\t0xCBC4, 0xA8A0, 0xCBC5, 0xA941, 0xCBC6, 0xA942, 0xCBC7, 0xA943,\t0xCBC8, 0xA944, 0xCBC9, 0xA945, 0xCBCA, 0xA946, 0xCBCB, 0xA947,\r\n\t0xCBCC, 0xA948, 0xCBCD, 0xA949, 0xCBCE, 0xA94A, 0xCBCF, 0xA94B,\t0xCBD0, 0xA94C, 0xCBD1, 0xA94D, 0xCBD2, 0xA94E, 0xCBD3, 0xA94F,\r\n\t0xCBD4, 0xC2EA, 0xCBD5, 0xA950, 0xCBD6, 0xA951, 0xCBD7, 0xA952,\t0xCBD8, 0xA953, 0xCBD9, 0xA954, 0xCBDA, 0xA955, 0xCBDB, 0xA956,\r\n\t0xCBDC, 0xA957, 0xCBDD, 0xA958, 0xCBDE, 0xA959, 0xCBDF, 0xA95A,\t0xCBE0, 0xA961, 0xCBE1, 0xA962, 0xCBE2, 0xA963, 0xCBE3, 0xA964,\r\n\t0xCBE4, 0xC2EB, 0xCBE5, 0xA965, 0xCBE6, 0xA966, 0xCBE7, 0xC2EC,\t0xCBE8, 0xA967, 0xCBE9, 0xC2ED, 0xCBEA, 0xA968, 0xCBEB, 0xA969,\r\n\t0xCBEC, 0xA96A, 0xCBED, 0xA96B, 0xCBEE, 0xA96C, 0xCBEF, 0xA96D,\t0xCBF0, 0xA96E, 0xCBF1, 0xA96F, 0xCBF2, 0xA970, 0xCBF3, 0xA971,\r\n\t0xCBF4, 0xA972, 0xCBF5, 0xA973, 0xCBF6, 0xA974, 0xCBF7, 0xA975,\t0xCBF8, 0xA976, 0xCBF9, 0xA977, 0xCBFA, 0xA978, 0xCBFB, 0xA979,\r\n\t0xCBFC, 0xA97A, 0xCBFD, 0xA981, 0xCBFE, 0xA982, 0xCBFF, 0xA983,\t0xCC00, 0xA984, 0xCC01, 0xA985, 0xCC02, 0xA986, 0xCC03, 0xA987,\r\n\t0xCC04, 0xA988, 0xCC05, 0xA989, 0xCC06, 0xA98A, 0xCC07, 0xA98B,\t0xCC08, 0xA98C, 0xCC09, 0xA98D, 0xCC0A, 0xA98E, 0xCC0B, 0xA98F,\r\n\t0xCC0C, 0xC2EE, 0xCC0D, 0xC2EF, 0xCC0E, 0xA990, 0xCC0F, 0xA991,\t0xCC10, 0xC2F0, 0xCC11, 0xA992, 0xCC12, 0xA993, 0xCC13, 0xA994,\r\n\t0xCC14, 0xC2F1, 0xCC15, 0xA995, 0xCC16, 0xA996, 0xCC17, 0xA997,\t0xCC18, 0xA998, 0xCC19, 0xA999, 0xCC1A, 0xA99A, 0xCC1B, 0xA99B,\r\n\t0xCC1C, 0xC2F2, 0xCC1D, 0xC2F3, 0xCC1E, 0xA99C, 0xCC1F, 0xA99D,\t0xCC20, 0xA99E, 0xCC21, 0xC2F4, 0xCC22, 0xC2F5, 0xCC23, 0xA99F,\r\n\t0xCC24, 0xA9A0, 0xCC25, 0xAA41, 0xCC26, 0xAA42, 0xCC27, 0xC2F6,\t0xCC28, 0xC2F7, 0xCC29, 0xC2F8, 0xCC2A, 0xAA43, 0xCC2B, 0xAA44,\r\n\t0xCC2C, 0xC2F9, 0xCC2D, 0xAA45, 0xCC2E, 0xC2FA, 0xCC2F, 0xAA46,\t0xCC30, 0xC2FB, 0xCC31, 0xAA47, 0xCC32, 0xAA48, 0xCC33, 0xAA49,\r\n\t0xCC34, 0xAA4A, 0xCC35, 0xAA4B, 0xCC36, 0xAA4C, 0xCC37, 0xAA4D,\t0xCC38, 0xC2FC, 0xCC39, 0xC2FD, 0xCC3A, 0xAA4E, 0xCC3B, 0xC2FE,\r\n\t0xCC3C, 0xC3A1, 0xCC3D, 0xC3A2, 0xCC3E, 0xC3A3, 0xCC3F, 0xAA4F,\t0xCC40, 0xAA50, 0xCC41, 0xAA51, 0xCC42, 0xAA52, 0xCC43, 0xAA53,\r\n\t0xCC44, 0xC3A4, 0xCC45, 0xC3A5, 0xCC46, 0xAA54, 0xCC47, 0xAA55,\t0xCC48, 0xC3A6, 0xCC49, 0xAA56, 0xCC4A, 0xAA57, 0xCC4B, 0xAA58,\r\n\t0xCC4C, 0xC3A7, 0xCC4D, 0xAA59, 0xCC4E, 0xAA5A, 0xCC4F, 0xAA61,\t0xCC50, 0xAA62, 0xCC51, 0xAA63, 0xCC52, 0xAA64, 0xCC53, 0xAA65,\r\n\t0xCC54, 0xC3A8, 0xCC55, 0xC3A9, 0xCC56, 0xAA66, 0xCC57, 0xC3AA,\t0xCC58, 0xC3AB, 0xCC59, 0xC3AC, 0xCC5A, 0xAA67, 0xCC5B, 0xAA68,\r\n\t0xCC5C, 0xAA69, 0xCC5D, 0xAA6A, 0xCC5E, 0xAA6B, 0xCC5F, 0xAA6C,\t0xCC60, 0xC3AD, 0xCC61, 0xAA6D, 0xCC62, 0xAA6E, 0xCC63, 0xAA6F,\r\n\t0xCC64, 0xC3AE, 0xCC65, 0xAA70, 0xCC66, 0xC3AF, 0xCC67, 0xAA71,\t0xCC68, 0xC3B0, 0xCC69, 0xAA72, 0xCC6A, 0xAA73, 0xCC6B, 0xAA74,\r\n\t0xCC6C, 0xAA75, 0xCC6D, 0xAA76, 0xCC6E, 0xAA77, 0xCC6F, 0xAA78,\t0xCC70, 0xC3B1, 0xCC71, 0xAA79, 0xCC72, 0xAA7A, 0xCC73, 0xAA81,\r\n\t0xCC74, 0xAA82, 0xCC75, 0xC3B2, 0xCC76, 0xAA83, 0xCC77, 0xAA84,\t0xCC78, 0xAA85, 0xCC79, 0xAA86, 0xCC7A, 0xAA87, 0xCC7B, 0xAA88,\r\n\t0xCC7C, 0xAA89, 0xCC7D, 0xAA8A, 0xCC7E, 0xAA8B, 0xCC7F, 0xAA8C,\t0xCC80, 0xAA8D, 0xCC81, 0xAA8E, 0xCC82, 0xAA8F, 0xCC83, 0xAA90,\r\n\t0xCC84, 0xAA91, 0xCC85, 0xAA92, 0xCC86, 0xAA93, 0xCC87, 0xAA94,\t0xCC88, 0xAA95, 0xCC89, 0xAA96, 0xCC8A, 0xAA97, 0xCC8B, 0xAA98,\r\n\t0xCC8C, 0xAA99, 0xCC8D, 0xAA9A, 0xCC8E, 0xAA9B, 0xCC8F, 0xAA9C,\t0xCC90, 0xAA9D, 0xCC91, 0xAA9E, 0xCC92, 0xAA9F, 0xCC93, 0xAAA0,\r\n\t0xCC94, 0xAB41, 0xCC95, 0xAB42, 0xCC96, 0xAB43, 0xCC97, 0xAB44,\t0xCC98, 0xC3B3, 0xCC99, 0xC3B4, 0xCC9A, 0xAB45, 0xCC9B, 0xAB46,\r\n\t0xCC9C, 0xC3B5, 0xCC9D, 0xAB47, 0xCC9E, 0xAB48, 0xCC9F, 0xAB49,\t0xCCA0, 0xC3B6, 0xCCA1, 0xAB4A, 0xCCA2, 0xAB4B, 0xCCA3, 0xAB4C,\r\n\t0xCCA4, 0xAB4D, 0xCCA5, 0xAB4E, 0xCCA6, 0xAB4F, 0xCCA7, 0xAB50,\t0xCCA8, 0xC3B7, 0xCCA9, 0xC3B8, 0xCCAA, 0xAB51, 0xCCAB, 0xC3B9,\r\n\t0xCCAC, 0xC3BA, 0xCCAD, 0xC3BB, 0xCCAE, 0xAB52, 0xCCAF, 0xAB53,\t0xCCB0, 0xAB54, 0xCCB1, 0xAB55, 0xCCB2, 0xAB56, 0xCCB3, 0xAB57,\r\n\t0xCCB4, 0xC3BC, 0xCCB5, 0xC3BD, 0xCCB6, 0xAB58, 0xCCB7, 0xAB59,\t0xCCB8, 0xC3BE, 0xCCB9, 0xAB5A, 0xCCBA, 0xAB61, 0xCCBB, 0xAB62,\r\n\t0xCCBC, 0xC3BF, 0xCCBD, 0xAB63, 0xCCBE, 0xAB64, 0xCCBF, 0xAB65,\t0xCCC0, 0xAB66, 0xCCC1, 0xAB67, 0xCCC2, 0xAB68, 0xCCC3, 0xAB69,\r\n\t0xCCC4, 0xC3C0, 0xCCC5, 0xC3C1, 0xCCC6, 0xAB6A, 0xCCC7, 0xC3C2,\t0xCCC8, 0xAB6B, 0xCCC9, 0xC3C3, 0xCCCA, 0xAB6C, 0xCCCB, 0xAB6D,\r\n\t0xCCCC, 0xAB6E, 0xCCCD, 0xAB6F, 0xCCCE, 0xAB70, 0xCCCF, 0xAB71,\t0xCCD0, 0xC3C4, 0xCCD1, 0xAB72, 0xCCD2, 0xAB73, 0xCCD3, 0xAB74,\r\n\t0xCCD4, 0xC3C5, 0xCCD5, 0xAB75, 0xCCD6, 0xAB76, 0xCCD7, 0xAB77,\t0xCCD8, 0xAB78, 0xCCD9, 0xAB79, 0xCCDA, 0xAB7A, 0xCCDB, 0xAB81,\r\n\t0xCCDC, 0xAB82, 0xCCDD, 0xAB83, 0xCCDE, 0xAB84, 0xCCDF, 0xAB85,\t0xCCE0, 0xAB86, 0xCCE1, 0xAB87, 0xCCE2, 0xAB88, 0xCCE3, 0xAB89,\r\n\t0xCCE4, 0xC3C6, 0xCCE5, 0xAB8A, 0xCCE6, 0xAB8B, 0xCCE7, 0xAB8C,\t0xCCE8, 0xAB8D, 0xCCE9, 0xAB8E, 0xCCEA, 0xAB8F, 0xCCEB, 0xAB90,\r\n\t0xCCEC, 0xC3C7, 0xCCED, 0xAB91, 0xCCEE, 0xAB92, 0xCCEF, 0xAB93,\t0xCCF0, 0xC3C8, 0xCCF1, 0xAB94, 0xCCF2, 0xAB95, 0xCCF3, 0xAB96,\r\n\t0xCCF4, 0xAB97, 0xCCF5, 0xAB98, 0xCCF6, 0xAB99, 0xCCF7, 0xAB9A,\t0xCCF8, 0xAB9B, 0xCCF9, 0xAB9C, 0xCCFA, 0xAB9D, 0xCCFB, 0xAB9E,\r\n\t0xCCFC, 0xAB9F, 0xCCFD, 0xABA0, 0xCCFE, 0xAC41, 0xCCFF, 0xAC42,\t0xCD00, 0xAC43, 0xCD01, 0xC3C9, 0xCD02, 0xAC44, 0xCD03, 0xAC45,\r\n\t0xCD04, 0xAC46, 0xCD05, 0xAC47, 0xCD06, 0xAC48, 0xCD07, 0xAC49,\t0xCD08, 0xC3CA, 0xCD09, 0xC3CB, 0xCD0A, 0xAC4A, 0xCD0B, 0xAC4B,\r\n\t0xCD0C, 0xC3CC, 0xCD0D, 0xAC4C, 0xCD0E, 0xAC4D, 0xCD0F, 0xAC4E,\t0xCD10, 0xC3CD, 0xCD11, 0xAC4F, 0xCD12, 0xAC50, 0xCD13, 0xAC51,\r\n\t0xCD14, 0xAC52, 0xCD15, 0xAC53, 0xCD16, 0xAC54, 0xCD17, 0xAC55,\t0xCD18, 0xC3CE, 0xCD19, 0xC3CF, 0xCD1A, 0xAC56, 0xCD1B, 0xC3D0,\r\n\t0xCD1C, 0xAC57, 0xCD1D, 0xC3D1, 0xCD1E, 0xAC58, 0xCD1F, 0xAC59,\t0xCD20, 0xAC5A, 0xCD21, 0xAC61, 0xCD22, 0xAC62, 0xCD23, 0xAC63,\r\n\t0xCD24, 0xC3D2, 0xCD25, 0xAC64, 0xCD26, 0xAC65, 0xCD27, 0xAC66,\t0xCD28, 0xC3D3, 0xCD29, 0xAC67, 0xCD2A, 0xAC68, 0xCD2B, 0xAC69,\r\n\t0xCD2C, 0xC3D4, 0xCD2D, 0xAC6A, 0xCD2E, 0xAC6B, 0xCD2F, 0xAC6C,\t0xCD30, 0xAC6D, 0xCD31, 0xAC6E, 0xCD32, 0xAC6F, 0xCD33, 0xAC70,\r\n\t0xCD34, 0xAC71, 0xCD35, 0xAC72, 0xCD36, 0xAC73, 0xCD37, 0xAC74,\t0xCD38, 0xAC75, 0xCD39, 0xC3D5, 0xCD3A, 0xAC76, 0xCD3B, 0xAC77,\r\n\t0xCD3C, 0xAC78, 0xCD3D, 0xAC79, 0xCD3E, 0xAC7A, 0xCD3F, 0xAC81,\t0xCD40, 0xAC82, 0xCD41, 0xAC83, 0xCD42, 0xAC84, 0xCD43, 0xAC85,\r\n\t0xCD44, 0xAC86, 0xCD45, 0xAC87, 0xCD46, 0xAC88, 0xCD47, 0xAC89,\t0xCD48, 0xAC8A, 0xCD49, 0xAC8B, 0xCD4A, 0xAC8C, 0xCD4B, 0xAC8D,\r\n\t0xCD4C, 0xAC8E, 0xCD4D, 0xAC8F, 0xCD4E, 0xAC90, 0xCD4F, 0xAC91,\t0xCD50, 0xAC92, 0xCD51, 0xAC93, 0xCD52, 0xAC94, 0xCD53, 0xAC95,\r\n\t0xCD54, 0xAC96, 0xCD55, 0xAC97, 0xCD56, 0xAC98, 0xCD57, 0xAC99,\t0xCD58, 0xAC9A, 0xCD59, 0xAC9B, 0xCD5A, 0xAC9C, 0xCD5B, 0xAC9D,\r\n\t0xCD5C, 0xC3D6, 0xCD5D, 0xAC9E, 0xCD5E, 0xAC9F, 0xCD5F, 0xACA0,\t0xCD60, 0xC3D7, 0xCD61, 0xAD41, 0xCD62, 0xAD42, 0xCD63, 0xAD43,\r\n\t0xCD64, 0xC3D8, 0xCD65, 0xAD44, 0xCD66, 0xAD45, 0xCD67, 0xAD46,\t0xCD68, 0xAD47, 0xCD69, 0xAD48, 0xCD6A, 0xAD49, 0xCD6B, 0xAD4A,\r\n\t0xCD6C, 0xC3D9, 0xCD6D, 0xC3DA, 0xCD6E, 0xAD4B, 0xCD6F, 0xC3DB,\t0xCD70, 0xAD4C, 0xCD71, 0xC3DC, 0xCD72, 0xAD4D, 0xCD73, 0xAD4E,\r\n\t0xCD74, 0xAD4F, 0xCD75, 0xAD50, 0xCD76, 0xAD51, 0xCD77, 0xAD52,\t0xCD78, 0xC3DD, 0xCD79, 0xAD53, 0xCD7A, 0xAD54, 0xCD7B, 0xAD55,\r\n\t0xCD7C, 0xAD56, 0xCD7D, 0xAD57, 0xCD7E, 0xAD58, 0xCD7F, 0xAD59,\t0xCD80, 0xAD5A, 0xCD81, 0xAD61, 0xCD82, 0xAD62, 0xCD83, 0xAD63,\r\n\t0xCD84, 0xAD64, 0xCD85, 0xAD65, 0xCD86, 0xAD66, 0xCD87, 0xAD67,\t0xCD88, 0xC3DE, 0xCD89, 0xAD68, 0xCD8A, 0xAD69, 0xCD8B, 0xAD6A,\r\n\t0xCD8C, 0xAD6B, 0xCD8D, 0xAD6C, 0xCD8E, 0xAD6D, 0xCD8F, 0xAD6E,\t0xCD90, 0xAD6F, 0xCD91, 0xAD70, 0xCD92, 0xAD71, 0xCD93, 0xAD72,\r\n\t0xCD94, 0xC3DF, 0xCD95, 0xC3E0, 0xCD96, 0xAD73, 0xCD97, 0xAD74,\t0xCD98, 0xC3E1, 0xCD99, 0xAD75, 0xCD9A, 0xAD76, 0xCD9B, 0xAD77,\r\n\t0xCD9C, 0xC3E2, 0xCD9D, 0xAD78, 0xCD9E, 0xAD79, 0xCD9F, 0xAD7A,\t0xCDA0, 0xAD81, 0xCDA1, 0xAD82, 0xCDA2, 0xAD83, 0xCDA3, 0xAD84,\r\n\t0xCDA4, 0xC3E3, 0xCDA5, 0xC3E4, 0xCDA6, 0xAD85, 0xCDA7, 0xC3E5,\t0xCDA8, 0xAD86, 0xCDA9, 0xC3E6, 0xCDAA, 0xAD87, 0xCDAB, 0xAD88,\r\n\t0xCDAC, 0xAD89, 0xCDAD, 0xAD8A, 0xCDAE, 0xAD8B, 0xCDAF, 0xAD8C,\t0xCDB0, 0xC3E7, 0xCDB1, 0xAD8D, 0xCDB2, 0xAD8E, 0xCDB3, 0xAD8F,\r\n\t0xCDB4, 0xAD90, 0xCDB5, 0xAD91, 0xCDB6, 0xAD92, 0xCDB7, 0xAD93,\t0xCDB8, 0xAD94, 0xCDB9, 0xAD95, 0xCDBA, 0xAD96, 0xCDBB, 0xAD97,\r\n\t0xCDBC, 0xAD98, 0xCDBD, 0xAD99, 0xCDBE, 0xAD9A, 0xCDBF, 0xAD9B,\t0xCDC0, 0xAD9C, 0xCDC1, 0xAD9D, 0xCDC2, 0xAD9E, 0xCDC3, 0xAD9F,\r\n\t0xCDC4, 0xC3E8, 0xCDC5, 0xADA0, 0xCDC6, 0xAE41, 0xCDC7, 0xAE42,\t0xCDC8, 0xAE43, 0xCDC9, 0xAE44, 0xCDCA, 0xAE45, 0xCDCB, 0xAE46,\r\n\t0xCDCC, 0xC3E9, 0xCDCD, 0xAE47, 0xCDCE, 0xAE48, 0xCDCF, 0xAE49,\t0xCDD0, 0xC3EA, 0xCDD1, 0xAE4A, 0xCDD2, 0xAE4B, 0xCDD3, 0xAE4C,\r\n\t0xCDD4, 0xAE4D, 0xCDD5, 0xAE4E, 0xCDD6, 0xAE4F, 0xCDD7, 0xAE50,\t0xCDD8, 0xAE51, 0xCDD9, 0xAE52, 0xCDDA, 0xAE53, 0xCDDB, 0xAE54,\r\n\t0xCDDC, 0xAE55, 0xCDDD, 0xAE56, 0xCDDE, 0xAE57, 0xCDDF, 0xAE58,\t0xCDE0, 0xAE59, 0xCDE1, 0xAE5A, 0xCDE2, 0xAE61, 0xCDE3, 0xAE62,\r\n\t0xCDE4, 0xAE63, 0xCDE5, 0xAE64, 0xCDE6, 0xAE65, 0xCDE7, 0xAE66,\t0xCDE8, 0xC3EB, 0xCDE9, 0xAE67, 0xCDEA, 0xAE68, 0xCDEB, 0xAE69,\r\n\t0xCDEC, 0xC3EC, 0xCDED, 0xAE6A, 0xCDEE, 0xAE6B, 0xCDEF, 0xAE6C,\t0xCDF0, 0xC3ED, 0xCDF1, 0xAE6D, 0xCDF2, 0xAE6E, 0xCDF3, 0xAE6F,\r\n\t0xCDF4, 0xAE70, 0xCDF5, 0xAE71, 0xCDF6, 0xAE72, 0xCDF7, 0xAE73,\t0xCDF8, 0xC3EE, 0xCDF9, 0xC3EF, 0xCDFA, 0xAE74, 0xCDFB, 0xC3F0,\r\n\t0xCDFC, 0xAE75, 0xCDFD, 0xC3F1, 0xCDFE, 0xAE76, 0xCDFF, 0xAE77,\t0xCE00, 0xAE78, 0xCE01, 0xAE79, 0xCE02, 0xAE7A, 0xCE03, 0xAE81,\r\n\t0xCE04, 0xC3F2, 0xCE05, 0xAE82, 0xCE06, 0xAE83, 0xCE07, 0xAE84,\t0xCE08, 0xC3F3, 0xCE09, 0xAE85, 0xCE0A, 0xAE86, 0xCE0B, 0xAE87,\r\n\t0xCE0C, 0xC3F4, 0xCE0D, 0xAE88, 0xCE0E, 0xAE89, 0xCE0F, 0xAE8A,\t0xCE10, 0xAE8B, 0xCE11, 0xAE8C, 0xCE12, 0xAE8D, 0xCE13, 0xAE8E,\r\n\t0xCE14, 0xC3F5, 0xCE15, 0xAE8F, 0xCE16, 0xAE90, 0xCE17, 0xAE91,\t0xCE18, 0xAE92, 0xCE19, 0xC3F6, 0xCE1A, 0xAE93, 0xCE1B, 0xAE94,\r\n\t0xCE1C, 0xAE95, 0xCE1D, 0xAE96, 0xCE1E, 0xAE97, 0xCE1F, 0xAE98,\t0xCE20, 0xC3F7, 0xCE21, 0xC3F8, 0xCE22, 0xAE99, 0xCE23, 0xAE9A,\r\n\t0xCE24, 0xC3F9, 0xCE25, 0xAE9B, 0xCE26, 0xAE9C, 0xCE27, 0xAE9D,\t0xCE28, 0xC3FA, 0xCE29, 0xAE9E, 0xCE2A, 0xAE9F, 0xCE2B, 0xAEA0,\r\n\t0xCE2C, 0xAF41, 0xCE2D, 0xAF42, 0xCE2E, 0xAF43, 0xCE2F, 0xAF44,\t0xCE30, 0xC3FB, 0xCE31, 0xC3FC, 0xCE32, 0xAF45, 0xCE33, 0xC3FD,\r\n\t0xCE34, 0xAF46, 0xCE35, 0xC3FE, 0xCE36, 0xAF47, 0xCE37, 0xAF48,\t0xCE38, 0xAF49, 0xCE39, 0xAF4A, 0xCE3A, 0xAF4B, 0xCE3B, 0xAF4C,\r\n\t0xCE3C, 0xAF4D, 0xCE3D, 0xAF4E, 0xCE3E, 0xAF4F, 0xCE3F, 0xAF50,\t0xCE40, 0xAF51, 0xCE41, 0xAF52, 0xCE42, 0xAF53, 0xCE43, 0xAF54,\r\n\t0xCE44, 0xAF55, 0xCE45, 0xAF56, 0xCE46, 0xAF57, 0xCE47, 0xAF58,\t0xCE48, 0xAF59, 0xCE49, 0xAF5A, 0xCE4A, 0xAF61, 0xCE4B, 0xAF62,\r\n\t0xCE4C, 0xAF63, 0xCE4D, 0xAF64, 0xCE4E, 0xAF65, 0xCE4F, 0xAF66,\t0xCE50, 0xAF67, 0xCE51, 0xAF68, 0xCE52, 0xAF69, 0xCE53, 0xAF6A,\r\n\t0xCE54, 0xAF6B, 0xCE55, 0xAF6C, 0xCE56, 0xAF6D, 0xCE57, 0xAF6E,\t0xCE58, 0xC4A1, 0xCE59, 0xC4A2, 0xCE5A, 0xAF6F, 0xCE5B, 0xAF70,\r\n\t0xCE5C, 0xC4A3, 0xCE5D, 0xAF71, 0xCE5E, 0xAF72, 0xCE5F, 0xC4A4,\t0xCE60, 0xC4A5, 0xCE61, 0xC4A6, 0xCE62, 0xAF73, 0xCE63, 0xAF74,\r\n\t0xCE64, 0xAF75, 0xCE65, 0xAF76, 0xCE66, 0xAF77, 0xCE67, 0xAF78,\t0xCE68, 0xC4A7, 0xCE69, 0xC4A8, 0xCE6A, 0xAF79, 0xCE6B, 0xC4A9,\r\n\t0xCE6C, 0xAF7A, 0xCE6D, 0xC4AA, 0xCE6E, 0xAF81, 0xCE6F, 0xAF82,\t0xCE70, 0xAF83, 0xCE71, 0xAF84, 0xCE72, 0xAF85, 0xCE73, 0xAF86,\r\n\t0xCE74, 0xC4AB, 0xCE75, 0xC4AC, 0xCE76, 0xAF87, 0xCE77, 0xAF88,\t0xCE78, 0xC4AD, 0xCE79, 0xAF89, 0xCE7A, 0xAF8A, 0xCE7B, 0xAF8B,\r\n\t0xCE7C, 0xC4AE, 0xCE7D, 0xAF8C, 0xCE7E, 0xAF8D, 0xCE7F, 0xAF8E,\t0xCE80, 0xAF8F, 0xCE81, 0xAF90, 0xCE82, 0xAF91, 0xCE83, 0xAF92,\r\n\t0xCE84, 0xC4AF, 0xCE85, 0xC4B0, 0xCE86, 0xAF93, 0xCE87, 0xC4B1,\t0xCE88, 0xAF94, 0xCE89, 0xC4B2, 0xCE8A, 0xAF95, 0xCE8B, 0xAF96,\r\n\t0xCE8C, 0xAF97, 0xCE8D, 0xAF98, 0xCE8E, 0xAF99, 0xCE8F, 0xAF9A,\t0xCE90, 0xC4B3, 0xCE91, 0xC4B4, 0xCE92, 0xAF9B, 0xCE93, 0xAF9C,\r\n\t0xCE94, 0xC4B5, 0xCE95, 0xAF9D, 0xCE96, 0xAF9E, 0xCE97, 0xAF9F,\t0xCE98, 0xC4B6, 0xCE99, 0xAFA0, 0xCE9A, 0xB041, 0xCE9B, 0xB042,\r\n\t0xCE9C, 0xB043, 0xCE9D, 0xB044, 0xCE9E, 0xB045, 0xCE9F, 0xB046,\t0xCEA0, 0xC4B7, 0xCEA1, 0xC4B8, 0xCEA2, 0xB047, 0xCEA3, 0xC4B9,\r\n\t0xCEA4, 0xC4BA, 0xCEA5, 0xC4BB, 0xCEA6, 0xB048, 0xCEA7, 0xB049,\t0xCEA8, 0xB04A, 0xCEA9, 0xB04B, 0xCEAA, 0xB04C, 0xCEAB, 0xB04D,\r\n\t0xCEAC, 0xC4BC, 0xCEAD, 0xC4BD, 0xCEAE, 0xB04E, 0xCEAF, 0xB04F,\t0xCEB0, 0xB050, 0xCEB1, 0xB051, 0xCEB2, 0xB052, 0xCEB3, 0xB053,\r\n\t0xCEB4, 0xB054, 0xCEB5, 0xB055, 0xCEB6, 0xB056, 0xCEB7, 0xB057,\t0xCEB8, 0xB058, 0xCEB9, 0xB059, 0xCEBA, 0xB05A, 0xCEBB, 0xB061,\r\n\t0xCEBC, 0xB062, 0xCEBD, 0xB063, 0xCEBE, 0xB064, 0xCEBF, 0xB065,\t0xCEC0, 0xB066, 0xCEC1, 0xC4BE, 0xCEC2, 0xB067, 0xCEC3, 0xB068,\r\n\t0xCEC4, 0xB069, 0xCEC5, 0xB06A, 0xCEC6, 0xB06B, 0xCEC7, 0xB06C,\t0xCEC8, 0xB06D, 0xCEC9, 0xB06E, 0xCECA, 0xB06F, 0xCECB, 0xB070,\r\n\t0xCECC, 0xB071, 0xCECD, 0xB072, 0xCECE, 0xB073, 0xCECF, 0xB074,\t0xCED0, 0xB075, 0xCED1, 0xB076, 0xCED2, 0xB077, 0xCED3, 0xB078,\r\n\t0xCED4, 0xB079, 0xCED5, 0xB07A, 0xCED6, 0xB081, 0xCED7, 0xB082,\t0xCED8, 0xB083, 0xCED9, 0xB084, 0xCEDA, 0xB085, 0xCEDB, 0xB086,\r\n\t0xCEDC, 0xB087, 0xCEDD, 0xB088, 0xCEDE, 0xB089, 0xCEDF, 0xB08A,\t0xCEE0, 0xB08B, 0xCEE1, 0xB08C, 0xCEE2, 0xB08D, 0xCEE3, 0xB08E,\r\n\t0xCEE4, 0xC4BF, 0xCEE5, 0xC4C0, 0xCEE6, 0xB08F, 0xCEE7, 0xB090,\t0xCEE8, 0xC4C1, 0xCEE9, 0xB091, 0xCEEA, 0xB092, 0xCEEB, 0xC4C2,\r\n\t0xCEEC, 0xC4C3, 0xCEED, 0xB093, 0xCEEE, 0xB094, 0xCEEF, 0xB095,\t0xCEF0, 0xB096, 0xCEF1, 0xB097, 0xCEF2, 0xB098, 0xCEF3, 0xB099,\r\n\t0xCEF4, 0xC4C4, 0xCEF5, 0xC4C5, 0xCEF6, 0xB09A, 0xCEF7, 0xC4C6,\t0xCEF8, 0xC4C7, 0xCEF9, 0xC4C8, 0xCEFA, 0xB09B, 0xCEFB, 0xB09C,\r\n\t0xCEFC, 0xB09D, 0xCEFD, 0xB09E, 0xCEFE, 0xB09F, 0xCEFF, 0xB0A0,\t0xCF00, 0xC4C9, 0xCF01, 0xC4CA, 0xCF02, 0xB141, 0xCF03, 0xB142,\r\n\t0xCF04, 0xC4CB, 0xCF05, 0xB143, 0xCF06, 0xB144, 0xCF07, 0xB145,\t0xCF08, 0xC4CC, 0xCF09, 0xB146, 0xCF0A, 0xB147, 0xCF0B, 0xB148,\r\n\t0xCF0C, 0xB149, 0xCF0D, 0xB14A, 0xCF0E, 0xB14B, 0xCF0F, 0xB14C,\t0xCF10, 0xC4CD, 0xCF11, 0xC4CE, 0xCF12, 0xB14D, 0xCF13, 0xC4CF,\r\n\t0xCF14, 0xB14E, 0xCF15, 0xC4D0, 0xCF16, 0xB14F, 0xCF17, 0xB150,\t0xCF18, 0xB151, 0xCF19, 0xB152, 0xCF1A, 0xB153, 0xCF1B, 0xB154,\r\n\t0xCF1C, 0xC4D1, 0xCF1D, 0xB155, 0xCF1E, 0xB156, 0xCF1F, 0xB157,\t0xCF20, 0xC4D2, 0xCF21, 0xB158, 0xCF22, 0xB159, 0xCF23, 0xB15A,\r\n\t0xCF24, 0xC4D3, 0xCF25, 0xB161, 0xCF26, 0xB162, 0xCF27, 0xB163,\t0xCF28, 0xB164, 0xCF29, 0xB165, 0xCF2A, 0xB166, 0xCF2B, 0xB167,\r\n\t0xCF2C, 0xC4D4, 0xCF2D, 0xC4D5, 0xCF2E, 0xB168, 0xCF2F, 0xC4D6,\t0xCF30, 0xC4D7, 0xCF31, 0xC4D8, 0xCF32, 0xB169, 0xCF33, 0xB16A,\r\n\t0xCF34, 0xB16B, 0xCF35, 0xB16C, 0xCF36, 0xB16D, 0xCF37, 0xB16E,\t0xCF38, 0xC4D9, 0xCF39, 0xB16F, 0xCF3A, 0xB170, 0xCF3B, 0xB171,\r\n\t0xCF3C, 0xB172, 0xCF3D, 0xB173, 0xCF3E, 0xB174, 0xCF3F, 0xB175,\t0xCF40, 0xB176, 0xCF41, 0xB177, 0xCF42, 0xB178, 0xCF43, 0xB179,\r\n\t0xCF44, 0xB17A, 0xCF45, 0xB181, 0xCF46, 0xB182, 0xCF47, 0xB183,\t0xCF48, 0xB184, 0xCF49, 0xB185, 0xCF4A, 0xB186, 0xCF4B, 0xB187,\r\n\t0xCF4C, 0xB188, 0xCF4D, 0xB189, 0xCF4E, 0xB18A, 0xCF4F, 0xB18B,\t0xCF50, 0xB18C, 0xCF51, 0xB18D, 0xCF52, 0xB18E, 0xCF53, 0xB18F,\r\n\t0xCF54, 0xC4DA, 0xCF55, 0xC4DB, 0xCF56, 0xB190, 0xCF57, 0xB191,\t0xCF58, 0xC4DC, 0xCF59, 0xB192, 0xCF5A, 0xB193, 0xCF5B, 0xB194,\r\n\t0xCF5C, 0xC4DD, 0xCF5D, 0xB195, 0xCF5E, 0xB196, 0xCF5F, 0xB197,\t0xCF60, 0xB198, 0xCF61, 0xB199, 0xCF62, 0xB19A, 0xCF63, 0xB19B,\r\n\t0xCF64, 0xC4DE, 0xCF65, 0xC4DF, 0xCF66, 0xB19C, 0xCF67, 0xC4E0,\t0xCF68, 0xB19D, 0xCF69, 0xC4E1, 0xCF6A, 0xB19E, 0xCF6B, 0xB19F,\r\n\t0xCF6C, 0xB1A0, 0xCF6D, 0xB241, 0xCF6E, 0xB242, 0xCF6F, 0xB243,\t0xCF70, 0xC4E2, 0xCF71, 0xC4E3, 0xCF72, 0xB244, 0xCF73, 0xB245,\r\n\t0xCF74, 0xC4E4, 0xCF75, 0xB246, 0xCF76, 0xB247, 0xCF77, 0xB248,\t0xCF78, 0xC4E5, 0xCF79, 0xB249, 0xCF7A, 0xB24A, 0xCF7B, 0xB24B,\r\n\t0xCF7C, 0xB24C, 0xCF7D, 0xB24D, 0xCF7E, 0xB24E, 0xCF7F, 0xB24F,\t0xCF80, 0xC4E6, 0xCF81, 0xB250, 0xCF82, 0xB251, 0xCF83, 0xB252,\r\n\t0xCF84, 0xB253, 0xCF85, 0xC4E7, 0xCF86, 0xB254, 0xCF87, 0xB255,\t0xCF88, 0xB256, 0xCF89, 0xB257, 0xCF8A, 0xB258, 0xCF8B, 0xB259,\r\n\t0xCF8C, 0xC4E8, 0xCF8D, 0xB25A, 0xCF8E, 0xB261, 0xCF8F, 0xB262,\t0xCF90, 0xB263, 0xCF91, 0xB264, 0xCF92, 0xB265, 0xCF93, 0xB266,\r\n\t0xCF94, 0xB267, 0xCF95, 0xB268, 0xCF96, 0xB269, 0xCF97, 0xB26A,\t0xCF98, 0xB26B, 0xCF99, 0xB26C, 0xCF9A, 0xB26D, 0xCF9B, 0xB26E,\r\n\t0xCF9C, 0xB26F, 0xCF9D, 0xB270, 0xCF9E, 0xB271, 0xCF9F, 0xB272,\t0xCFA0, 0xB273, 0xCFA1, 0xC4E9, 0xCFA2, 0xB274, 0xCFA3, 0xB275,\r\n\t0xCFA4, 0xB276, 0xCFA5, 0xB277, 0xCFA6, 0xB278, 0xCFA7, 0xB279,\t0xCFA8, 0xC4EA, 0xCFA9, 0xB27A, 0xCFAA, 0xB281, 0xCFAB, 0xB282,\r\n\t0xCFAC, 0xB283, 0xCFAD, 0xB284, 0xCFAE, 0xB285, 0xCFAF, 0xB286,\t0xCFB0, 0xC4EB, 0xCFB1, 0xB287, 0xCFB2, 0xB288, 0xCFB3, 0xB289,\r\n\t0xCFB4, 0xB28A, 0xCFB5, 0xB28B, 0xCFB6, 0xB28C, 0xCFB7, 0xB28D,\t0xCFB8, 0xB28E, 0xCFB9, 0xB28F, 0xCFBA, 0xB290, 0xCFBB, 0xB291,\r\n\t0xCFBC, 0xB292, 0xCFBD, 0xB293, 0xCFBE, 0xB294, 0xCFBF, 0xB295,\t0xCFC0, 0xB296, 0xCFC1, 0xB297, 0xCFC2, 0xB298, 0xCFC3, 0xB299,\r\n\t0xCFC4, 0xC4EC, 0xCFC5, 0xB29A, 0xCFC6, 0xB29B, 0xCFC7, 0xB29C,\t0xCFC8, 0xB29D, 0xCFC9, 0xB29E, 0xCFCA, 0xB29F, 0xCFCB, 0xB2A0,\r\n\t0xCFCC, 0xB341, 0xCFCD, 0xB342, 0xCFCE, 0xB343, 0xCFCF, 0xB344,\t0xCFD0, 0xB345, 0xCFD1, 0xB346, 0xCFD2, 0xB347, 0xCFD3, 0xB348,\r\n\t0xCFD4, 0xB349, 0xCFD5, 0xB34A, 0xCFD6, 0xB34B, 0xCFD7, 0xB34C,\t0xCFD8, 0xB34D, 0xCFD9, 0xB34E, 0xCFDA, 0xB34F, 0xCFDB, 0xB350,\r\n\t0xCFDC, 0xB351, 0xCFDD, 0xB352, 0xCFDE, 0xB353, 0xCFDF, 0xB354,\t0xCFE0, 0xC4ED, 0xCFE1, 0xC4EE, 0xCFE2, 0xB355, 0xCFE3, 0xB356,\r\n\t0xCFE4, 0xC4EF, 0xCFE5, 0xB357, 0xCFE6, 0xB358, 0xCFE7, 0xB359,\t0xCFE8, 0xC4F0, 0xCFE9, 0xB35A, 0xCFEA, 0xB361, 0xCFEB, 0xB362,\r\n\t0xCFEC, 0xB363, 0xCFED, 0xB364, 0xCFEE, 0xB365, 0xCFEF, 0xB366,\t0xCFF0, 0xC4F1, 0xCFF1, 0xC4F2, 0xCFF2, 0xB367, 0xCFF3, 0xC4F3,\r\n\t0xCFF4, 0xB368, 0xCFF5, 0xC4F4, 0xCFF6, 0xB369, 0xCFF7, 0xB36A,\t0xCFF8, 0xB36B, 0xCFF9, 0xB36C, 0xCFFA, 0xB36D, 0xCFFB, 0xB36E,\r\n\t0xCFFC, 0xC4F5, 0xCFFD, 0xB36F, 0xCFFE, 0xB370, 0xCFFF, 0xB371,\t0xD000, 0xC4F6, 0xD001, 0xB372, 0xD002, 0xB373, 0xD003, 0xB374,\r\n\t0xD004, 0xC4F7, 0xD005, 0xB375, 0xD006, 0xB376, 0xD007, 0xB377,\t0xD008, 0xB378, 0xD009, 0xB379, 0xD00A, 0xB37A, 0xD00B, 0xB381,\r\n\t0xD00C, 0xB382, 0xD00D, 0xB383, 0xD00E, 0xB384, 0xD00F, 0xB385,\t0xD010, 0xB386, 0xD011, 0xC4F8, 0xD012, 0xB387, 0xD013, 0xB388,\r\n\t0xD014, 0xB389, 0xD015, 0xB38A, 0xD016, 0xB38B, 0xD017, 0xB38C,\t0xD018, 0xC4F9, 0xD019, 0xB38D, 0xD01A, 0xB38E, 0xD01B, 0xB38F,\r\n\t0xD01C, 0xB390, 0xD01D, 0xB391, 0xD01E, 0xB392, 0xD01F, 0xB393,\t0xD020, 0xB394, 0xD021, 0xB395, 0xD022, 0xB396, 0xD023, 0xB397,\r\n\t0xD024, 0xB398, 0xD025, 0xB399, 0xD026, 0xB39A, 0xD027, 0xB39B,\t0xD028, 0xB39C, 0xD029, 0xB39D, 0xD02A, 0xB39E, 0xD02B, 0xB39F,\r\n\t0xD02C, 0xB3A0, 0xD02D, 0xC4FA, 0xD02E, 0xB441, 0xD02F, 0xB442,\t0xD030, 0xB443, 0xD031, 0xB444, 0xD032, 0xB445, 0xD033, 0xB446,\r\n\t0xD034, 0xC4FB, 0xD035, 0xC4FC, 0xD036, 0xB447, 0xD037, 0xB448,\t0xD038, 0xC4FD, 0xD039, 0xB449, 0xD03A, 0xB44A, 0xD03B, 0xB44B,\r\n\t0xD03C, 0xC4FE, 0xD03D, 0xB44C, 0xD03E, 0xB44D, 0xD03F, 0xB44E,\t0xD040, 0xB44F, 0xD041, 0xB450, 0xD042, 0xB451, 0xD043, 0xB452,\r\n\t0xD044, 0xC5A1, 0xD045, 0xC5A2, 0xD046, 0xB453, 0xD047, 0xC5A3,\t0xD048, 0xB454, 0xD049, 0xC5A4, 0xD04A, 0xB455, 0xD04B, 0xB456,\r\n\t0xD04C, 0xB457, 0xD04D, 0xB458, 0xD04E, 0xB459, 0xD04F, 0xB45A,\t0xD050, 0xC5A5, 0xD051, 0xB461, 0xD052, 0xB462, 0xD053, 0xB463,\r\n\t0xD054, 0xC5A6, 0xD055, 0xB464, 0xD056, 0xB465, 0xD057, 0xB466,\t0xD058, 0xC5A7, 0xD059, 0xB467, 0xD05A, 0xB468, 0xD05B, 0xB469,\r\n\t0xD05C, 0xB46A, 0xD05D, 0xB46B, 0xD05E, 0xB46C, 0xD05F, 0xB46D,\t0xD060, 0xC5A8, 0xD061, 0xB46E, 0xD062, 0xB46F, 0xD063, 0xB470,\r\n\t0xD064, 0xB471, 0xD065, 0xB472, 0xD066, 0xB473, 0xD067, 0xB474,\t0xD068, 0xB475, 0xD069, 0xB476, 0xD06A, 0xB477, 0xD06B, 0xB478,\r\n\t0xD06C, 0xC5A9, 0xD06D, 0xC5AA, 0xD06E, 0xB479, 0xD06F, 0xB47A,\t0xD070, 0xC5AB, 0xD071, 0xB481, 0xD072, 0xB482, 0xD073, 0xB483,\r\n\t0xD074, 0xC5AC, 0xD075, 0xB484, 0xD076, 0xB485, 0xD077, 0xB486,\t0xD078, 0xB487, 0xD079, 0xB488, 0xD07A, 0xB489, 0xD07B, 0xB48A,\r\n\t0xD07C, 0xC5AD, 0xD07D, 0xC5AE, 0xD07E, 0xB48B, 0xD07F, 0xB48C,\t0xD080, 0xB48D, 0xD081, 0xC5AF, 0xD082, 0xB48E, 0xD083, 0xB48F,\r\n\t0xD084, 0xB490, 0xD085, 0xB491, 0xD086, 0xB492, 0xD087, 0xB493,\t0xD088, 0xB494, 0xD089, 0xB495, 0xD08A, 0xB496, 0xD08B, 0xB497,\r\n\t0xD08C, 0xB498, 0xD08D, 0xB499, 0xD08E, 0xB49A, 0xD08F, 0xB49B,\t0xD090, 0xB49C, 0xD091, 0xB49D, 0xD092, 0xB49E, 0xD093, 0xB49F,\r\n\t0xD094, 0xB4A0, 0xD095, 0xB541, 0xD096, 0xB542, 0xD097, 0xB543,\t0xD098, 0xB544, 0xD099, 0xB545, 0xD09A, 0xB546, 0xD09B, 0xB547,\r\n\t0xD09C, 0xB548, 0xD09D, 0xB549, 0xD09E, 0xB54A, 0xD09F, 0xB54B,\t0xD0A0, 0xB54C, 0xD0A1, 0xB54D, 0xD0A2, 0xB54E, 0xD0A3, 0xB54F,\r\n\t0xD0A4, 0xC5B0, 0xD0A5, 0xC5B1, 0xD0A6, 0xB550, 0xD0A7, 0xB551,\t0xD0A8, 0xC5B2, 0xD0A9, 0xB552, 0xD0AA, 0xB553, 0xD0AB, 0xB554,\r\n\t0xD0AC, 0xC5B3, 0xD0AD, 0xB555, 0xD0AE, 0xB556, 0xD0AF, 0xB557,\t0xD0B0, 0xB558, 0xD0B1, 0xB559, 0xD0B2, 0xB55A, 0xD0B3, 0xB561,\r\n\t0xD0B4, 0xC5B4, 0xD0B5, 0xC5B5, 0xD0B6, 0xB562, 0xD0B7, 0xC5B6,\t0xD0B8, 0xB563, 0xD0B9, 0xC5B7, 0xD0BA, 0xB564, 0xD0BB, 0xB565,\r\n\t0xD0BC, 0xB566, 0xD0BD, 0xB567, 0xD0BE, 0xB568, 0xD0BF, 0xB569,\t0xD0C0, 0xC5B8, 0xD0C1, 0xC5B9, 0xD0C2, 0xB56A, 0xD0C3, 0xB56B,\r\n\t0xD0C4, 0xC5BA, 0xD0C5, 0xB56C, 0xD0C6, 0xB56D, 0xD0C7, 0xB56E,\t0xD0C8, 0xC5BB, 0xD0C9, 0xC5BC, 0xD0CA, 0xB56F, 0xD0CB, 0xB570,\r\n\t0xD0CC, 0xB571, 0xD0CD, 0xB572, 0xD0CE, 0xB573, 0xD0CF, 0xB574,\t0xD0D0, 0xC5BD, 0xD0D1, 0xC5BE, 0xD0D2, 0xB575, 0xD0D3, 0xC5BF,\r\n\t0xD0D4, 0xC5C0, 0xD0D5, 0xC5C1, 0xD0D6, 0xB576, 0xD0D7, 0xB577,\t0xD0D8, 0xB578, 0xD0D9, 0xB579, 0xD0DA, 0xB57A, 0xD0DB, 0xB581,\r\n\t0xD0DC, 0xC5C2, 0xD0DD, 0xC5C3, 0xD0DE, 0xB582, 0xD0DF, 0xB583,\t0xD0E0, 0xC5C4, 0xD0E1, 0xB584, 0xD0E2, 0xB585, 0xD0E3, 0xB586,\r\n\t0xD0E4, 0xC5C5, 0xD0E5, 0xB587, 0xD0E6, 0xB588, 0xD0E7, 0xB589,\t0xD0E8, 0xB58A, 0xD0E9, 0xB58B, 0xD0EA, 0xB58C, 0xD0EB, 0xB58D,\r\n\t0xD0EC, 0xC5C6, 0xD0ED, 0xC5C7, 0xD0EE, 0xB58E, 0xD0EF, 0xC5C8,\t0xD0F0, 0xC5C9, 0xD0F1, 0xC5CA, 0xD0F2, 0xB58F, 0xD0F3, 0xB590,\r\n\t0xD0F4, 0xB591, 0xD0F5, 0xB592, 0xD0F6, 0xB593, 0xD0F7, 0xB594,\t0xD0F8, 0xC5CB, 0xD0F9, 0xB595, 0xD0FA, 0xB596, 0xD0FB, 0xB597,\r\n\t0xD0FC, 0xB598, 0xD0FD, 0xB599, 0xD0FE, 0xB59A, 0xD0FF, 0xB59B,\t0xD100, 0xB59C, 0xD101, 0xB59D, 0xD102, 0xB59E, 0xD103, 0xB59F,\r\n\t0xD104, 0xB5A0, 0xD105, 0xB641, 0xD106, 0xB642, 0xD107, 0xB643,\t0xD108, 0xB644, 0xD109, 0xB645, 0xD10A, 0xB646, 0xD10B, 0xB647,\r\n\t0xD10C, 0xB648, 0xD10D, 0xC5CC, 0xD10E, 0xB649, 0xD10F, 0xB64A,\t0xD110, 0xB64B, 0xD111, 0xB64C, 0xD112, 0xB64D, 0xD113, 0xB64E,\r\n\t0xD114, 0xB64F, 0xD115, 0xB650, 0xD116, 0xB651, 0xD117, 0xB652,\t0xD118, 0xB653, 0xD119, 0xB654, 0xD11A, 0xB655, 0xD11B, 0xB656,\r\n\t0xD11C, 0xB657, 0xD11D, 0xB658, 0xD11E, 0xB659, 0xD11F, 0xB65A,\t0xD120, 0xB661, 0xD121, 0xB662, 0xD122, 0xB663, 0xD123, 0xB664,\r\n\t0xD124, 0xB665, 0xD125, 0xB666, 0xD126, 0xB667, 0xD127, 0xB668,\t0xD128, 0xB669, 0xD129, 0xB66A, 0xD12A, 0xB66B, 0xD12B, 0xB66C,\r\n\t0xD12C, 0xB66D, 0xD12D, 0xB66E, 0xD12E, 0xB66F, 0xD12F, 0xB670,\t0xD130, 0xC5CD, 0xD131, 0xC5CE, 0xD132, 0xB671, 0xD133, 0xB672,\r\n\t0xD134, 0xC5CF, 0xD135, 0xB673, 0xD136, 0xB674, 0xD137, 0xB675,\t0xD138, 0xC5D0, 0xD139, 0xB676, 0xD13A, 0xC5D1, 0xD13B, 0xB677,\r\n\t0xD13C, 0xB678, 0xD13D, 0xB679, 0xD13E, 0xB67A, 0xD13F, 0xB681,\t0xD140, 0xC5D2, 0xD141, 0xC5D3, 0xD142, 0xB682, 0xD143, 0xC5D4,\r\n\t0xD144, 0xC5D5, 0xD145, 0xC5D6, 0xD146, 0xB683, 0xD147, 0xB684,\t0xD148, 0xB685, 0xD149, 0xB686, 0xD14A, 0xB687, 0xD14B, 0xB688,\r\n\t0xD14C, 0xC5D7, 0xD14D, 0xC5D8, 0xD14E, 0xB689, 0xD14F, 0xB68A,\t0xD150, 0xC5D9, 0xD151, 0xB68B, 0xD152, 0xB68C, 0xD153, 0xB68D,\r\n\t0xD154, 0xC5DA, 0xD155, 0xB68E, 0xD156, 0xB68F, 0xD157, 0xB690,\t0xD158, 0xB691, 0xD159, 0xB692, 0xD15A, 0xB693, 0xD15B, 0xB694,\r\n\t0xD15C, 0xC5DB, 0xD15D, 0xC5DC, 0xD15E, 0xB695, 0xD15F, 0xC5DD,\t0xD160, 0xB696, 0xD161, 0xC5DE, 0xD162, 0xB697, 0xD163, 0xB698,\r\n\t0xD164, 0xB699, 0xD165, 0xB69A, 0xD166, 0xB69B, 0xD167, 0xB69C,\t0xD168, 0xC5DF, 0xD169, 0xB69D, 0xD16A, 0xB69E, 0xD16B, 0xB69F,\r\n\t0xD16C, 0xC5E0, 0xD16D, 0xB6A0, 0xD16E, 0xB741, 0xD16F, 0xB742,\t0xD170, 0xB743, 0xD171, 0xB744, 0xD172, 0xB745, 0xD173, 0xB746,\r\n\t0xD174, 0xB747, 0xD175, 0xB748, 0xD176, 0xB749, 0xD177, 0xB74A,\t0xD178, 0xB74B, 0xD179, 0xB74C, 0xD17A, 0xB74D, 0xD17B, 0xB74E,\r\n\t0xD17C, 0xC5E1, 0xD17D, 0xB74F, 0xD17E, 0xB750, 0xD17F, 0xB751,\t0xD180, 0xB752, 0xD181, 0xB753, 0xD182, 0xB754, 0xD183, 0xB755,\r\n\t0xD184, 0xC5E2, 0xD185, 0xB756, 0xD186, 0xB757, 0xD187, 0xB758,\t0xD188, 0xC5E3, 0xD189, 0xB759, 0xD18A, 0xB75A, 0xD18B, 0xB761,\r\n\t0xD18C, 0xB762, 0xD18D, 0xB763, 0xD18E, 0xB764, 0xD18F, 0xB765,\t0xD190, 0xB766, 0xD191, 0xB767, 0xD192, 0xB768, 0xD193, 0xB769,\r\n\t0xD194, 0xB76A, 0xD195, 0xB76B, 0xD196, 0xB76C, 0xD197, 0xB76D,\t0xD198, 0xB76E, 0xD199, 0xB76F, 0xD19A, 0xB770, 0xD19B, 0xB771,\r\n\t0xD19C, 0xB772, 0xD19D, 0xB773, 0xD19E, 0xB774, 0xD19F, 0xB775,\t0xD1A0, 0xC5E4, 0xD1A1, 0xC5E5, 0xD1A2, 0xB776, 0xD1A3, 0xB777,\r\n\t0xD1A4, 0xC5E6, 0xD1A5, 0xB778, 0xD1A6, 0xB779, 0xD1A7, 0xB77A,\t0xD1A8, 0xC5E7, 0xD1A9, 0xB781, 0xD1AA, 0xB782, 0xD1AB, 0xB783,\r\n\t0xD1AC, 0xB784, 0xD1AD, 0xB785, 0xD1AE, 0xB786, 0xD1AF, 0xB787,\t0xD1B0, 0xC5E8, 0xD1B1, 0xC5E9, 0xD1B2, 0xB788, 0xD1B3, 0xC5EA,\r\n\t0xD1B4, 0xB789, 0xD1B5, 0xC5EB, 0xD1B6, 0xB78A, 0xD1B7, 0xB78B,\t0xD1B8, 0xB78C, 0xD1B9, 0xB78D, 0xD1BA, 0xC5EC, 0xD1BB, 0xB78E,\r\n\t0xD1BC, 0xC5ED, 0xD1BD, 0xB78F, 0xD1BE, 0xB790, 0xD1BF, 0xB791,\t0xD1C0, 0xC5EE, 0xD1C1, 0xB792, 0xD1C2, 0xB793, 0xD1C3, 0xB794,\r\n\t0xD1C4, 0xB795, 0xD1C5, 0xB796, 0xD1C6, 0xB797, 0xD1C7, 0xB798,\t0xD1C8, 0xB799, 0xD1C9, 0xB79A, 0xD1CA, 0xB79B, 0xD1CB, 0xB79C,\r\n\t0xD1CC, 0xB79D, 0xD1CD, 0xB79E, 0xD1CE, 0xB79F, 0xD1CF, 0xB7A0,\t0xD1D0, 0xB841, 0xD1D1, 0xB842, 0xD1D2, 0xB843, 0xD1D3, 0xB844,\r\n\t0xD1D4, 0xB845, 0xD1D5, 0xB846, 0xD1D6, 0xB847, 0xD1D7, 0xB848,\t0xD1D8, 0xC5EF, 0xD1D9, 0xB849, 0xD1DA, 0xB84A, 0xD1DB, 0xB84B,\r\n\t0xD1DC, 0xB84C, 0xD1DD, 0xB84D, 0xD1DE, 0xB84E, 0xD1DF, 0xB84F,\t0xD1E0, 0xB850, 0xD1E1, 0xB851, 0xD1E2, 0xB852, 0xD1E3, 0xB853,\r\n\t0xD1E4, 0xB854, 0xD1E5, 0xB855, 0xD1E6, 0xB856, 0xD1E7, 0xB857,\t0xD1E8, 0xB858, 0xD1E9, 0xB859, 0xD1EA, 0xB85A, 0xD1EB, 0xB861,\r\n\t0xD1EC, 0xB862, 0xD1ED, 0xB863, 0xD1EE, 0xB864, 0xD1EF, 0xB865,\t0xD1F0, 0xB866, 0xD1F1, 0xB867, 0xD1F2, 0xB868, 0xD1F3, 0xB869,\r\n\t0xD1F4, 0xC5F0, 0xD1F5, 0xB86A, 0xD1F6, 0xB86B, 0xD1F7, 0xB86C,\t0xD1F8, 0xC5F1, 0xD1F9, 0xB86D, 0xD1FA, 0xB86E, 0xD1FB, 0xB86F,\r\n\t0xD1FC, 0xB870, 0xD1FD, 0xB871, 0xD1FE, 0xB872, 0xD1FF, 0xB873,\t0xD200, 0xB874, 0xD201, 0xB875, 0xD202, 0xB876, 0xD203, 0xB877,\r\n\t0xD204, 0xB878, 0xD205, 0xB879, 0xD206, 0xB87A, 0xD207, 0xC5F2,\t0xD208, 0xB881, 0xD209, 0xC5F3, 0xD20A, 0xB882, 0xD20B, 0xB883,\r\n\t0xD20C, 0xB884, 0xD20D, 0xB885, 0xD20E, 0xB886, 0xD20F, 0xB887,\t0xD210, 0xC5F4, 0xD211, 0xB888, 0xD212, 0xB889, 0xD213, 0xB88A,\r\n\t0xD214, 0xB88B, 0xD215, 0xB88C, 0xD216, 0xB88D, 0xD217, 0xB88E,\t0xD218, 0xB88F, 0xD219, 0xB890, 0xD21A, 0xB891, 0xD21B, 0xB892,\r\n\t0xD21C, 0xB893, 0xD21D, 0xB894, 0xD21E, 0xB895, 0xD21F, 0xB896,\t0xD220, 0xB897, 0xD221, 0xB898, 0xD222, 0xB899, 0xD223, 0xB89A,\r\n\t0xD224, 0xB89B, 0xD225, 0xB89C, 0xD226, 0xB89D, 0xD227, 0xB89E,\t0xD228, 0xB89F, 0xD229, 0xB8A0, 0xD22A, 0xB941, 0xD22B, 0xB942,\r\n\t0xD22C, 0xC5F5, 0xD22D, 0xC5F6, 0xD22E, 0xB943, 0xD22F, 0xB944,\t0xD230, 0xC5F7, 0xD231, 0xB945, 0xD232, 0xB946, 0xD233, 0xB947,\r\n\t0xD234, 0xC5F8, 0xD235, 0xB948, 0xD236, 0xB949, 0xD237, 0xB94A,\t0xD238, 0xB94B, 0xD239, 0xB94C, 0xD23A, 0xB94D, 0xD23B, 0xB94E,\r\n\t0xD23C, 0xC5F9, 0xD23D, 0xC5FA, 0xD23E, 0xB94F, 0xD23F, 0xC5FB,\t0xD240, 0xB950, 0xD241, 0xC5FC, 0xD242, 0xB951, 0xD243, 0xB952,\r\n\t0xD244, 0xB953, 0xD245, 0xB954, 0xD246, 0xB955, 0xD247, 0xB956,\t0xD248, 0xC5FD, 0xD249, 0xB957, 0xD24A, 0xB958, 0xD24B, 0xB959,\r\n\t0xD24C, 0xB95A, 0xD24D, 0xB961, 0xD24E, 0xB962, 0xD24F, 0xB963,\t0xD250, 0xB964, 0xD251, 0xB965, 0xD252, 0xB966, 0xD253, 0xB967,\r\n\t0xD254, 0xB968, 0xD255, 0xB969, 0xD256, 0xB96A, 0xD257, 0xB96B,\t0xD258, 0xB96C, 0xD259, 0xB96D, 0xD25A, 0xB96E, 0xD25B, 0xB96F,\r\n\t0xD25C, 0xC5FE, 0xD25D, 0xB970, 0xD25E, 0xB971, 0xD25F, 0xB972,\t0xD260, 0xB973, 0xD261, 0xB974, 0xD262, 0xB975, 0xD263, 0xB976,\r\n\t0xD264, 0xC6A1, 0xD265, 0xB977, 0xD266, 0xB978, 0xD267, 0xB979,\t0xD268, 0xB97A, 0xD269, 0xB981, 0xD26A, 0xB982, 0xD26B, 0xB983,\r\n\t0xD26C, 0xB984, 0xD26D, 0xB985, 0xD26E, 0xB986, 0xD26F, 0xB987,\t0xD270, 0xB988, 0xD271, 0xB989, 0xD272, 0xB98A, 0xD273, 0xB98B,\r\n\t0xD274, 0xB98C, 0xD275, 0xB98D, 0xD276, 0xB98E, 0xD277, 0xB98F,\t0xD278, 0xB990, 0xD279, 0xB991, 0xD27A, 0xB992, 0xD27B, 0xB993,\r\n\t0xD27C, 0xB994, 0xD27D, 0xB995, 0xD27E, 0xB996, 0xD27F, 0xB997,\t0xD280, 0xC6A2, 0xD281, 0xC6A3, 0xD282, 0xB998, 0xD283, 0xB999,\r\n\t0xD284, 0xC6A4, 0xD285, 0xB99A, 0xD286, 0xB99B, 0xD287, 0xB99C,\t0xD288, 0xC6A5, 0xD289, 0xB99D, 0xD28A, 0xB99E, 0xD28B, 0xB99F,\r\n\t0xD28C, 0xB9A0, 0xD28D, 0xBA41, 0xD28E, 0xBA42, 0xD28F, 0xBA43,\t0xD290, 0xC6A6, 0xD291, 0xC6A7, 0xD292, 0xBA44, 0xD293, 0xBA45,\r\n\t0xD294, 0xBA46, 0xD295, 0xC6A8, 0xD296, 0xBA47, 0xD297, 0xBA48,\t0xD298, 0xBA49, 0xD299, 0xBA4A, 0xD29A, 0xBA4B, 0xD29B, 0xBA4C,\r\n\t0xD29C, 0xC6A9, 0xD29D, 0xBA4D, 0xD29E, 0xBA4E, 0xD29F, 0xBA4F,\t0xD2A0, 0xC6AA, 0xD2A1, 0xBA50, 0xD2A2, 0xBA51, 0xD2A3, 0xBA52,\r\n\t0xD2A4, 0xC6AB, 0xD2A5, 0xBA53, 0xD2A6, 0xBA54, 0xD2A7, 0xBA55,\t0xD2A8, 0xBA56, 0xD2A9, 0xBA57, 0xD2AA, 0xBA58, 0xD2AB, 0xBA59,\r\n\t0xD2AC, 0xC6AC, 0xD2AD, 0xBA5A, 0xD2AE, 0xBA61, 0xD2AF, 0xBA62,\t0xD2B0, 0xBA63, 0xD2B1, 0xC6AD, 0xD2B2, 0xBA64, 0xD2B3, 0xBA65,\r\n\t0xD2B4, 0xBA66, 0xD2B5, 0xBA67, 0xD2B6, 0xBA68, 0xD2B7, 0xBA69,\t0xD2B8, 0xC6AE, 0xD2B9, 0xC6AF, 0xD2BA, 0xBA6A, 0xD2BB, 0xBA6B,\r\n\t0xD2BC, 0xC6B0, 0xD2BD, 0xBA6C, 0xD2BE, 0xBA6D, 0xD2BF, 0xC6B1,\t0xD2C0, 0xC6B2, 0xD2C1, 0xBA6E, 0xD2C2, 0xC6B3, 0xD2C3, 0xBA6F,\r\n\t0xD2C4, 0xBA70, 0xD2C5, 0xBA71, 0xD2C6, 0xBA72, 0xD2C7, 0xBA73,\t0xD2C8, 0xC6B4, 0xD2C9, 0xC6B5, 0xD2CA, 0xBA74, 0xD2CB, 0xC6B6,\r\n\t0xD2CC, 0xBA75, 0xD2CD, 0xBA76, 0xD2CE, 0xBA77, 0xD2CF, 0xBA78,\t0xD2D0, 0xBA79, 0xD2D1, 0xBA7A, 0xD2D2, 0xBA81, 0xD2D3, 0xBA82,\r\n\t0xD2D4, 0xC6B7, 0xD2D5, 0xBA83, 0xD2D6, 0xBA84, 0xD2D7, 0xBA85,\t0xD2D8, 0xC6B8, 0xD2D9, 0xBA86, 0xD2DA, 0xBA87, 0xD2DB, 0xBA88,\r\n\t0xD2DC, 0xC6B9, 0xD2DD, 0xBA89, 0xD2DE, 0xBA8A, 0xD2DF, 0xBA8B,\t0xD2E0, 0xBA8C, 0xD2E1, 0xBA8D, 0xD2E2, 0xBA8E, 0xD2E3, 0xBA8F,\r\n\t0xD2E4, 0xC6BA, 0xD2E5, 0xC6BB, 0xD2E6, 0xBA90, 0xD2E7, 0xBA91,\t0xD2E8, 0xBA92, 0xD2E9, 0xBA93, 0xD2EA, 0xBA94, 0xD2EB, 0xBA95,\r\n\t0xD2EC, 0xBA96, 0xD2ED, 0xBA97, 0xD2EE, 0xBA98, 0xD2EF, 0xBA99,\t0xD2F0, 0xC6BC, 0xD2F1, 0xC6BD, 0xD2F2, 0xBA9A, 0xD2F3, 0xBA9B,\r\n\t0xD2F4, 0xC6BE, 0xD2F5, 0xBA9C, 0xD2F6, 0xBA9D, 0xD2F7, 0xBA9E,\t0xD2F8, 0xC6BF, 0xD2F9, 0xBA9F, 0xD2FA, 0xBAA0, 0xD2FB, 0xBB41,\r\n\t0xD2FC, 0xBB42, 0xD2FD, 0xBB43, 0xD2FE, 0xBB44, 0xD2FF, 0xBB45,\t0xD300, 0xC6C0, 0xD301, 0xC6C1, 0xD302, 0xBB46, 0xD303, 0xC6C2,\r\n\t0xD304, 0xBB47, 0xD305, 0xC6C3, 0xD306, 0xBB48, 0xD307, 0xBB49,\t0xD308, 0xBB4A, 0xD309, 0xBB4B, 0xD30A, 0xBB4C, 0xD30B, 0xBB4D,\r\n\t0xD30C, 0xC6C4, 0xD30D, 0xC6C5, 0xD30E, 0xC6C6, 0xD30F, 0xBB4E,\t0xD310, 0xC6C7, 0xD311, 0xBB4F, 0xD312, 0xBB50, 0xD313, 0xBB51,\r\n\t0xD314, 0xC6C8, 0xD315, 0xBB52, 0xD316, 0xC6C9, 0xD317, 0xBB53,\t0xD318, 0xBB54, 0xD319, 0xBB55, 0xD31A, 0xBB56, 0xD31B, 0xBB57,\r\n\t0xD31C, 0xC6CA, 0xD31D, 0xC6CB, 0xD31E, 0xBB58, 0xD31F, 0xC6CC,\t0xD320, 0xC6CD, 0xD321, 0xC6CE, 0xD322, 0xBB59, 0xD323, 0xBB5A,\r\n\t0xD324, 0xBB61, 0xD325, 0xC6CF, 0xD326, 0xBB62, 0xD327, 0xBB63,\t0xD328, 0xC6D0, 0xD329, 0xC6D1, 0xD32A, 0xBB64, 0xD32B, 0xBB65,\r\n\t0xD32C, 0xC6D2, 0xD32D, 0xBB66, 0xD32E, 0xBB67, 0xD32F, 0xBB68,\t0xD330, 0xC6D3, 0xD331, 0xBB69, 0xD332, 0xBB6A, 0xD333, 0xBB6B,\r\n\t0xD334, 0xBB6C, 0xD335, 0xBB6D, 0xD336, 0xBB6E, 0xD337, 0xBB6F,\t0xD338, 0xC6D4, 0xD339, 0xC6D5, 0xD33A, 0xBB70, 0xD33B, 0xC6D6,\r\n\t0xD33C, 0xC6D7, 0xD33D, 0xC6D8, 0xD33E, 0xBB71, 0xD33F, 0xBB72,\t0xD340, 0xBB73, 0xD341, 0xBB74, 0xD342, 0xBB75, 0xD343, 0xBB76,\r\n\t0xD344, 0xC6D9, 0xD345, 0xC6DA, 0xD346, 0xBB77, 0xD347, 0xBB78,\t0xD348, 0xBB79, 0xD349, 0xBB7A, 0xD34A, 0xBB81, 0xD34B, 0xBB82,\r\n\t0xD34C, 0xBB83, 0xD34D, 0xBB84, 0xD34E, 0xBB85, 0xD34F, 0xBB86,\t0xD350, 0xBB87, 0xD351, 0xBB88, 0xD352, 0xBB89, 0xD353, 0xBB8A,\r\n\t0xD354, 0xBB8B, 0xD355, 0xBB8C, 0xD356, 0xBB8D, 0xD357, 0xBB8E,\t0xD358, 0xBB8F, 0xD359, 0xBB90, 0xD35A, 0xBB91, 0xD35B, 0xBB92,\r\n\t0xD35C, 0xBB93, 0xD35D, 0xBB94, 0xD35E, 0xBB95, 0xD35F, 0xBB96,\t0xD360, 0xBB97, 0xD361, 0xBB98, 0xD362, 0xBB99, 0xD363, 0xBB9A,\r\n\t0xD364, 0xBB9B, 0xD365, 0xBB9C, 0xD366, 0xBB9D, 0xD367, 0xBB9E,\t0xD368, 0xBB9F, 0xD369, 0xBBA0, 0xD36A, 0xBC41, 0xD36B, 0xBC42,\r\n\t0xD36C, 0xBC43, 0xD36D, 0xBC44, 0xD36E, 0xBC45, 0xD36F, 0xBC46,\t0xD370, 0xBC47, 0xD371, 0xBC48, 0xD372, 0xBC49, 0xD373, 0xBC4A,\r\n\t0xD374, 0xBC4B, 0xD375, 0xBC4C, 0xD376, 0xBC4D, 0xD377, 0xBC4E,\t0xD378, 0xBC4F, 0xD379, 0xBC50, 0xD37A, 0xBC51, 0xD37B, 0xBC52,\r\n\t0xD37C, 0xC6DB, 0xD37D, 0xC6DC, 0xD37E, 0xBC53, 0xD37F, 0xBC54,\t0xD380, 0xC6DD, 0xD381, 0xBC55, 0xD382, 0xBC56, 0xD383, 0xBC57,\r\n\t0xD384, 0xC6DE, 0xD385, 0xBC58, 0xD386, 0xBC59, 0xD387, 0xBC5A,\t0xD388, 0xBC61, 0xD389, 0xBC62, 0xD38A, 0xBC63, 0xD38B, 0xBC64,\r\n\t0xD38C, 0xC6DF, 0xD38D, 0xC6E0, 0xD38E, 0xBC65, 0xD38F, 0xC6E1,\t0xD390, 0xC6E2, 0xD391, 0xC6E3, 0xD392, 0xBC66, 0xD393, 0xBC67,\r\n\t0xD394, 0xBC68, 0xD395, 0xBC69, 0xD396, 0xBC6A, 0xD397, 0xBC6B,\t0xD398, 0xC6E4, 0xD399, 0xC6E5, 0xD39A, 0xBC6C, 0xD39B, 0xBC6D,\r\n\t0xD39C, 0xC6E6, 0xD39D, 0xBC6E, 0xD39E, 0xBC6F, 0xD39F, 0xBC70,\t0xD3A0, 0xC6E7, 0xD3A1, 0xBC71, 0xD3A2, 0xBC72, 0xD3A3, 0xBC73,\r\n\t0xD3A4, 0xBC74, 0xD3A5, 0xBC75, 0xD3A6, 0xBC76, 0xD3A7, 0xBC77,\t0xD3A8, 0xC6E8, 0xD3A9, 0xC6E9, 0xD3AA, 0xBC78, 0xD3AB, 0xC6EA,\r\n\t0xD3AC, 0xBC79, 0xD3AD, 0xC6EB, 0xD3AE, 0xBC7A, 0xD3AF, 0xBC81,\t0xD3B0, 0xBC82, 0xD3B1, 0xBC83, 0xD3B2, 0xBC84, 0xD3B3, 0xBC85,\r\n\t0xD3B4, 0xC6EC, 0xD3B5, 0xBC86, 0xD3B6, 0xBC87, 0xD3B7, 0xBC88,\t0xD3B8, 0xC6ED, 0xD3B9, 0xBC89, 0xD3BA, 0xBC8A, 0xD3BB, 0xBC8B,\r\n\t0xD3BC, 0xC6EE, 0xD3BD, 0xBC8C, 0xD3BE, 0xBC8D, 0xD3BF, 0xBC8E,\t0xD3C0, 0xBC8F, 0xD3C1, 0xBC90, 0xD3C2, 0xBC91, 0xD3C3, 0xBC92,\r\n\t0xD3C4, 0xC6EF, 0xD3C5, 0xC6F0, 0xD3C6, 0xBC93, 0xD3C7, 0xBC94,\t0xD3C8, 0xC6F1, 0xD3C9, 0xC6F2, 0xD3CA, 0xBC95, 0xD3CB, 0xBC96,\r\n\t0xD3CC, 0xBC97, 0xD3CD, 0xBC98, 0xD3CE, 0xBC99, 0xD3CF, 0xBC9A,\t0xD3D0, 0xC6F3, 0xD3D1, 0xBC9B, 0xD3D2, 0xBC9C, 0xD3D3, 0xBC9D,\r\n\t0xD3D4, 0xBC9E, 0xD3D5, 0xBC9F, 0xD3D6, 0xBCA0, 0xD3D7, 0xBD41,\t0xD3D8, 0xC6F4, 0xD3D9, 0xBD42, 0xD3DA, 0xBD43, 0xD3DB, 0xBD44,\r\n\t0xD3DC, 0xBD45, 0xD3DD, 0xBD46, 0xD3DE, 0xBD47, 0xD3DF, 0xBD48,\t0xD3E0, 0xBD49, 0xD3E1, 0xC6F5, 0xD3E2, 0xBD4A, 0xD3E3, 0xC6F6,\r\n\t0xD3E4, 0xBD4B, 0xD3E5, 0xBD4C, 0xD3E6, 0xBD4D, 0xD3E7, 0xBD4E,\t0xD3E8, 0xBD4F, 0xD3E9, 0xBD50, 0xD3EA, 0xBD51, 0xD3EB, 0xBD52,\r\n\t0xD3EC, 0xC6F7, 0xD3ED, 0xC6F8, 0xD3EE, 0xBD53, 0xD3EF, 0xBD54,\t0xD3F0, 0xC6F9, 0xD3F1, 0xBD55, 0xD3F2, 0xBD56, 0xD3F3, 0xBD57,\r\n\t0xD3F4, 0xC6FA, 0xD3F5, 0xBD58, 0xD3F6, 0xBD59, 0xD3F7, 0xBD5A,\t0xD3F8, 0xBD61, 0xD3F9, 0xBD62, 0xD3FA, 0xBD63, 0xD3FB, 0xBD64,\r\n\t0xD3FC, 0xC6FB, 0xD3FD, 0xC6FC, 0xD3FE, 0xBD65, 0xD3FF, 0xC6FD,\t0xD400, 0xBD66, 0xD401, 0xC6FE, 0xD402, 0xBD67, 0xD403, 0xBD68,\r\n\t0xD404, 0xBD69, 0xD405, 0xBD6A, 0xD406, 0xBD6B, 0xD407, 0xBD6C,\t0xD408, 0xC7A1, 0xD409, 0xBD6D, 0xD40A, 0xBD6E, 0xD40B, 0xBD6F,\r\n\t0xD40C, 0xBD70, 0xD40D, 0xBD71, 0xD40E, 0xBD72, 0xD40F, 0xBD73,\t0xD410, 0xBD74, 0xD411, 0xBD75, 0xD412, 0xBD76, 0xD413, 0xBD77,\r\n\t0xD414, 0xBD78, 0xD415, 0xBD79, 0xD416, 0xBD7A, 0xD417, 0xBD81,\t0xD418, 0xBD82, 0xD419, 0xBD83, 0xD41A, 0xBD84, 0xD41B, 0xBD85,\r\n\t0xD41C, 0xBD86, 0xD41D, 0xC7A2, 0xD41E, 0xBD87, 0xD41F, 0xBD88,\t0xD420, 0xBD89, 0xD421, 0xBD8A, 0xD422, 0xBD8B, 0xD423, 0xBD8C,\r\n\t0xD424, 0xBD8D, 0xD425, 0xBD8E, 0xD426, 0xBD8F, 0xD427, 0xBD90,\t0xD428, 0xBD91, 0xD429, 0xBD92, 0xD42A, 0xBD93, 0xD42B, 0xBD94,\r\n\t0xD42C, 0xBD95, 0xD42D, 0xBD96, 0xD42E, 0xBD97, 0xD42F, 0xBD98,\t0xD430, 0xBD99, 0xD431, 0xBD9A, 0xD432, 0xBD9B, 0xD433, 0xBD9C,\r\n\t0xD434, 0xBD9D, 0xD435, 0xBD9E, 0xD436, 0xBD9F, 0xD437, 0xBDA0,\t0xD438, 0xBE41, 0xD439, 0xBE42, 0xD43A, 0xBE43, 0xD43B, 0xBE44,\r\n\t0xD43C, 0xBE45, 0xD43D, 0xBE46, 0xD43E, 0xBE47, 0xD43F, 0xBE48,\t0xD440, 0xC7A3, 0xD441, 0xBE49, 0xD442, 0xBE4A, 0xD443, 0xBE4B,\r\n\t0xD444, 0xC7A4, 0xD445, 0xBE4C, 0xD446, 0xBE4D, 0xD447, 0xBE4E,\t0xD448, 0xBE4F, 0xD449, 0xBE50, 0xD44A, 0xBE51, 0xD44B, 0xBE52,\r\n\t0xD44C, 0xBE53, 0xD44D, 0xBE54, 0xD44E, 0xBE55, 0xD44F, 0xBE56,\t0xD450, 0xBE57, 0xD451, 0xBE58, 0xD452, 0xBE59, 0xD453, 0xBE5A,\r\n\t0xD454, 0xBE61, 0xD455, 0xBE62, 0xD456, 0xBE63, 0xD457, 0xBE64,\t0xD458, 0xBE65, 0xD459, 0xBE66, 0xD45A, 0xBE67, 0xD45B, 0xBE68,\r\n\t0xD45C, 0xC7A5, 0xD45D, 0xBE69, 0xD45E, 0xBE6A, 0xD45F, 0xBE6B,\t0xD460, 0xC7A6, 0xD461, 0xBE6C, 0xD462, 0xBE6D, 0xD463, 0xBE6E,\r\n\t0xD464, 0xC7A7, 0xD465, 0xBE6F, 0xD466, 0xBE70, 0xD467, 0xBE71,\t0xD468, 0xBE72, 0xD469, 0xBE73, 0xD46A, 0xBE74, 0xD46B, 0xBE75,\r\n\t0xD46C, 0xBE76, 0xD46D, 0xC7A8, 0xD46E, 0xBE77, 0xD46F, 0xC7A9,\t0xD470, 0xBE78, 0xD471, 0xBE79, 0xD472, 0xBE7A, 0xD473, 0xBE81,\r\n\t0xD474, 0xBE82, 0xD475, 0xBE83, 0xD476, 0xBE84, 0xD477, 0xBE85,\t0xD478, 0xC7AA, 0xD479, 0xC7AB, 0xD47A, 0xBE86, 0xD47B, 0xBE87,\r\n\t0xD47C, 0xC7AC, 0xD47D, 0xBE88, 0xD47E, 0xBE89, 0xD47F, 0xC7AD,\t0xD480, 0xC7AE, 0xD481, 0xBE8A, 0xD482, 0xC7AF, 0xD483, 0xBE8B,\r\n\t0xD484, 0xBE8C, 0xD485, 0xBE8D, 0xD486, 0xBE8E, 0xD487, 0xBE8F,\t0xD488, 0xC7B0, 0xD489, 0xC7B1, 0xD48A, 0xBE90, 0xD48B, 0xC7B2,\r\n\t0xD48C, 0xBE91, 0xD48D, 0xC7B3, 0xD48E, 0xBE92, 0xD48F, 0xBE93,\t0xD490, 0xBE94, 0xD491, 0xBE95, 0xD492, 0xBE96, 0xD493, 0xBE97,\r\n\t0xD494, 0xC7B4, 0xD495, 0xBE98, 0xD496, 0xBE99, 0xD497, 0xBE9A,\t0xD498, 0xBE9B, 0xD499, 0xBE9C, 0xD49A, 0xBE9D, 0xD49B, 0xBE9E,\r\n\t0xD49C, 0xBE9F, 0xD49D, 0xBEA0, 0xD49E, 0xBF41, 0xD49F, 0xBF42,\t0xD4A0, 0xBF43, 0xD4A1, 0xBF44, 0xD4A2, 0xBF45, 0xD4A3, 0xBF46,\r\n\t0xD4A4, 0xBF47, 0xD4A5, 0xBF48, 0xD4A6, 0xBF49, 0xD4A7, 0xBF4A,\t0xD4A8, 0xBF4B, 0xD4A9, 0xC7B5, 0xD4AA, 0xBF4C, 0xD4AB, 0xBF4D,\r\n\t0xD4AC, 0xBF4E, 0xD4AD, 0xBF4F, 0xD4AE, 0xBF50, 0xD4AF, 0xBF51,\t0xD4B0, 0xBF52, 0xD4B1, 0xBF53, 0xD4B2, 0xBF54, 0xD4B3, 0xBF55,\r\n\t0xD4B4, 0xBF56, 0xD4B5, 0xBF57, 0xD4B6, 0xBF58, 0xD4B7, 0xBF59,\t0xD4B8, 0xBF5A, 0xD4B9, 0xBF61, 0xD4BA, 0xBF62, 0xD4BB, 0xBF63,\r\n\t0xD4BC, 0xBF64, 0xD4BD, 0xBF65, 0xD4BE, 0xBF66, 0xD4BF, 0xBF67,\t0xD4C0, 0xBF68, 0xD4C1, 0xBF69, 0xD4C2, 0xBF6A, 0xD4C3, 0xBF6B,\r\n\t0xD4C4, 0xBF6C, 0xD4C5, 0xBF6D, 0xD4C6, 0xBF6E, 0xD4C7, 0xBF6F,\t0xD4C8, 0xBF70, 0xD4C9, 0xBF71, 0xD4CA, 0xBF72, 0xD4CB, 0xBF73,\r\n\t0xD4CC, 0xC7B6, 0xD4CD, 0xBF74, 0xD4CE, 0xBF75, 0xD4CF, 0xBF76,\t0xD4D0, 0xC7B7, 0xD4D1, 0xBF77, 0xD4D2, 0xBF78, 0xD4D3, 0xBF79,\r\n\t0xD4D4, 0xC7B8, 0xD4D5, 0xBF7A, 0xD4D6, 0xBF81, 0xD4D7, 0xBF82,\t0xD4D8, 0xBF83, 0xD4D9, 0xBF84, 0xD4DA, 0xBF85, 0xD4DB, 0xBF86,\r\n\t0xD4DC, 0xC7B9, 0xD4DD, 0xBF87, 0xD4DE, 0xBF88, 0xD4DF, 0xC7BA,\t0xD4E0, 0xBF89, 0xD4E1, 0xBF8A, 0xD4E2, 0xBF8B, 0xD4E3, 0xBF8C,\r\n\t0xD4E4, 0xBF8D, 0xD4E5, 0xBF8E, 0xD4E6, 0xBF8F, 0xD4E7, 0xBF90,\t0xD4E8, 0xC7BB, 0xD4E9, 0xBF91, 0xD4EA, 0xBF92, 0xD4EB, 0xBF93,\r\n\t0xD4EC, 0xC7BC, 0xD4ED, 0xBF94, 0xD4EE, 0xBF95, 0xD4EF, 0xBF96,\t0xD4F0, 0xC7BD, 0xD4F1, 0xBF97, 0xD4F2, 0xBF98, 0xD4F3, 0xBF99,\r\n\t0xD4F4, 0xBF9A, 0xD4F5, 0xBF9B, 0xD4F6, 0xBF9C, 0xD4F7, 0xBF9D,\t0xD4F8, 0xC7BE, 0xD4F9, 0xBF9E, 0xD4FA, 0xBF9F, 0xD4FB, 0xC7BF,\r\n\t0xD4FC, 0xBFA0, 0xD4FD, 0xC7C0, 0xD4FE, 0xC041, 0xD4FF, 0xC042,\t0xD500, 0xC043, 0xD501, 0xC044, 0xD502, 0xC045, 0xD503, 0xC046,\r\n\t0xD504, 0xC7C1, 0xD505, 0xC047, 0xD506, 0xC048, 0xD507, 0xC049,\t0xD508, 0xC7C2, 0xD509, 0xC04A, 0xD50A, 0xC04B, 0xD50B, 0xC04C,\r\n\t0xD50C, 0xC7C3, 0xD50D, 0xC04D, 0xD50E, 0xC04E, 0xD50F, 0xC04F,\t0xD510, 0xC050, 0xD511, 0xC051, 0xD512, 0xC052, 0xD513, 0xC053,\r\n\t0xD514, 0xC7C4, 0xD515, 0xC7C5, 0xD516, 0xC054, 0xD517, 0xC7C6,\t0xD518, 0xC055, 0xD519, 0xC056, 0xD51A, 0xC057, 0xD51B, 0xC058,\r\n\t0xD51C, 0xC059, 0xD51D, 0xC05A, 0xD51E, 0xC061, 0xD51F, 0xC062,\t0xD520, 0xC063, 0xD521, 0xC064, 0xD522, 0xC065, 0xD523, 0xC066,\r\n\t0xD524, 0xC067, 0xD525, 0xC068, 0xD526, 0xC069, 0xD527, 0xC06A,\t0xD528, 0xC06B, 0xD529, 0xC06C, 0xD52A, 0xC06D, 0xD52B, 0xC06E,\r\n\t0xD52C, 0xC06F, 0xD52D, 0xC070, 0xD52E, 0xC071, 0xD52F, 0xC072,\t0xD530, 0xC073, 0xD531, 0xC074, 0xD532, 0xC075, 0xD533, 0xC076,\r\n\t0xD534, 0xC077, 0xD535, 0xC078, 0xD536, 0xC079, 0xD537, 0xC07A,\t0xD538, 0xC081, 0xD539, 0xC082, 0xD53A, 0xC083, 0xD53B, 0xC084,\r\n\t0xD53C, 0xC7C7, 0xD53D, 0xC7C8, 0xD53E, 0xC085, 0xD53F, 0xC086,\t0xD540, 0xC7C9, 0xD541, 0xC087, 0xD542, 0xC088, 0xD543, 0xC089,\r\n\t0xD544, 0xC7CA, 0xD545, 0xC08A, 0xD546, 0xC08B, 0xD547, 0xC08C,\t0xD548, 0xC08D, 0xD549, 0xC08E, 0xD54A, 0xC08F, 0xD54B, 0xC090,\r\n\t0xD54C, 0xC7CB, 0xD54D, 0xC7CC, 0xD54E, 0xC091, 0xD54F, 0xC7CD,\t0xD550, 0xC092, 0xD551, 0xC7CE, 0xD552, 0xC093, 0xD553, 0xC094,\r\n\t0xD554, 0xC095, 0xD555, 0xC096, 0xD556, 0xC097, 0xD557, 0xC098,\t0xD558, 0xC7CF, 0xD559, 0xC7D0, 0xD55A, 0xC099, 0xD55B, 0xC09A,\r\n\t0xD55C, 0xC7D1, 0xD55D, 0xC09B, 0xD55E, 0xC09C, 0xD55F, 0xC09D,\t0xD560, 0xC7D2, 0xD561, 0xC09E, 0xD562, 0xC09F, 0xD563, 0xC0A0,\r\n\t0xD564, 0xC141, 0xD565, 0xC7D3, 0xD566, 0xC142, 0xD567, 0xC143,\t0xD568, 0xC7D4, 0xD569, 0xC7D5, 0xD56A, 0xC144, 0xD56B, 0xC7D6,\r\n\t0xD56C, 0xC145, 0xD56D, 0xC7D7, 0xD56E, 0xC146, 0xD56F, 0xC147,\t0xD570, 0xC148, 0xD571, 0xC149, 0xD572, 0xC14A, 0xD573, 0xC14B,\r\n\t0xD574, 0xC7D8, 0xD575, 0xC7D9, 0xD576, 0xC14C, 0xD577, 0xC14D,\t0xD578, 0xC7DA, 0xD579, 0xC14E, 0xD57A, 0xC14F, 0xD57B, 0xC150,\r\n\t0xD57C, 0xC7DB, 0xD57D, 0xC151, 0xD57E, 0xC152, 0xD57F, 0xC153,\t0xD580, 0xC154, 0xD581, 0xC155, 0xD582, 0xC156, 0xD583, 0xC157,\r\n\t0xD584, 0xC7DC, 0xD585, 0xC7DD, 0xD586, 0xC158, 0xD587, 0xC7DE,\t0xD588, 0xC7DF, 0xD589, 0xC7E0, 0xD58A, 0xC159, 0xD58B, 0xC15A,\r\n\t0xD58C, 0xC161, 0xD58D, 0xC162, 0xD58E, 0xC163, 0xD58F, 0xC164,\t0xD590, 0xC7E1, 0xD591, 0xC165, 0xD592, 0xC166, 0xD593, 0xC167,\r\n\t0xD594, 0xC168, 0xD595, 0xC169, 0xD596, 0xC16A, 0xD597, 0xC16B,\t0xD598, 0xC16C, 0xD599, 0xC16D, 0xD59A, 0xC16E, 0xD59B, 0xC16F,\r\n\t0xD59C, 0xC170, 0xD59D, 0xC171, 0xD59E, 0xC172, 0xD59F, 0xC173,\t0xD5A0, 0xC174, 0xD5A1, 0xC175, 0xD5A2, 0xC176, 0xD5A3, 0xC177,\r\n\t0xD5A4, 0xC178, 0xD5A5, 0xC7E2, 0xD5A6, 0xC179, 0xD5A7, 0xC17A,\t0xD5A8, 0xC181, 0xD5A9, 0xC182, 0xD5AA, 0xC183, 0xD5AB, 0xC184,\r\n\t0xD5AC, 0xC185, 0xD5AD, 0xC186, 0xD5AE, 0xC187, 0xD5AF, 0xC188,\t0xD5B0, 0xC189, 0xD5B1, 0xC18A, 0xD5B2, 0xC18B, 0xD5B3, 0xC18C,\r\n\t0xD5B4, 0xC18D, 0xD5B5, 0xC18E, 0xD5B6, 0xC18F, 0xD5B7, 0xC190,\t0xD5B8, 0xC191, 0xD5B9, 0xC192, 0xD5BA, 0xC193, 0xD5BB, 0xC194,\r\n\t0xD5BC, 0xC195, 0xD5BD, 0xC196, 0xD5BE, 0xC197, 0xD5BF, 0xC198,\t0xD5C0, 0xC199, 0xD5C1, 0xC19A, 0xD5C2, 0xC19B, 0xD5C3, 0xC19C,\r\n\t0xD5C4, 0xC19D, 0xD5C5, 0xC19E, 0xD5C6, 0xC19F, 0xD5C7, 0xC1A0,\t0xD5C8, 0xC7E3, 0xD5C9, 0xC7E4, 0xD5CA, 0xC241, 0xD5CB, 0xC242,\r\n\t0xD5CC, 0xC7E5, 0xD5CD, 0xC243, 0xD5CE, 0xC244, 0xD5CF, 0xC245,\t0xD5D0, 0xC7E6, 0xD5D1, 0xC246, 0xD5D2, 0xC7E7, 0xD5D3, 0xC247,\r\n\t0xD5D4, 0xC248, 0xD5D5, 0xC249, 0xD5D6, 0xC24A, 0xD5D7, 0xC24B,\t0xD5D8, 0xC7E8, 0xD5D9, 0xC7E9, 0xD5DA, 0xC24C, 0xD5DB, 0xC7EA,\r\n\t0xD5DC, 0xC24D, 0xD5DD, 0xC7EB, 0xD5DE, 0xC24E, 0xD5DF, 0xC24F,\t0xD5E0, 0xC250, 0xD5E1, 0xC251, 0xD5E2, 0xC252, 0xD5E3, 0xC253,\r\n\t0xD5E4, 0xC7EC, 0xD5E5, 0xC7ED, 0xD5E6, 0xC254, 0xD5E7, 0xC255,\t0xD5E8, 0xC7EE, 0xD5E9, 0xC256, 0xD5EA, 0xC257, 0xD5EB, 0xC258,\r\n\t0xD5EC, 0xC7EF, 0xD5ED, 0xC259, 0xD5EE, 0xC25A, 0xD5EF, 0xC261,\t0xD5F0, 0xC262, 0xD5F1, 0xC263, 0xD5F2, 0xC264, 0xD5F3, 0xC265,\r\n\t0xD5F4, 0xC7F0, 0xD5F5, 0xC7F1, 0xD5F6, 0xC266, 0xD5F7, 0xC7F2,\t0xD5F8, 0xC267, 0xD5F9, 0xC7F3, 0xD5FA, 0xC268, 0xD5FB, 0xC269,\r\n\t0xD5FC, 0xC26A, 0xD5FD, 0xC26B, 0xD5FE, 0xC26C, 0xD5FF, 0xC26D,\t0xD600, 0xC7F4, 0xD601, 0xC7F5, 0xD602, 0xC26E, 0xD603, 0xC26F,\r\n\t0xD604, 0xC7F6, 0xD605, 0xC270, 0xD606, 0xC271, 0xD607, 0xC272,\t0xD608, 0xC7F7, 0xD609, 0xC273, 0xD60A, 0xC274, 0xD60B, 0xC275,\r\n\t0xD60C, 0xC276, 0xD60D, 0xC277, 0xD60E, 0xC278, 0xD60F, 0xC279,\t0xD610, 0xC7F8, 0xD611, 0xC7F9, 0xD612, 0xC27A, 0xD613, 0xC7FA,\r\n\t0xD614, 0xC7FB, 0xD615, 0xC7FC, 0xD616, 0xC281, 0xD617, 0xC282,\t0xD618, 0xC283, 0xD619, 0xC284, 0xD61A, 0xC285, 0xD61B, 0xC286,\r\n\t0xD61C, 0xC7FD, 0xD61D, 0xC287, 0xD61E, 0xC288, 0xD61F, 0xC289,\t0xD620, 0xC7FE, 0xD621, 0xC28A, 0xD622, 0xC28B, 0xD623, 0xC28C,\r\n\t0xD624, 0xC8A1, 0xD625, 0xC28D, 0xD626, 0xC28E, 0xD627, 0xC28F,\t0xD628, 0xC290, 0xD629, 0xC291, 0xD62A, 0xC292, 0xD62B, 0xC293,\r\n\t0xD62C, 0xC294, 0xD62D, 0xC8A2, 0xD62E, 0xC295, 0xD62F, 0xC296,\t0xD630, 0xC297, 0xD631, 0xC298, 0xD632, 0xC299, 0xD633, 0xC29A,\r\n\t0xD634, 0xC29B, 0xD635, 0xC29C, 0xD636, 0xC29D, 0xD637, 0xC29E,\t0xD638, 0xC8A3, 0xD639, 0xC8A4, 0xD63A, 0xC29F, 0xD63B, 0xC2A0,\r\n\t0xD63C, 0xC8A5, 0xD63D, 0xC341, 0xD63E, 0xC342, 0xD63F, 0xC343,\t0xD640, 0xC8A6, 0xD641, 0xC344, 0xD642, 0xC345, 0xD643, 0xC346,\r\n\t0xD644, 0xC347, 0xD645, 0xC8A7, 0xD646, 0xC348, 0xD647, 0xC349,\t0xD648, 0xC8A8, 0xD649, 0xC8A9, 0xD64A, 0xC34A, 0xD64B, 0xC8AA,\r\n\t0xD64C, 0xC34B, 0xD64D, 0xC8AB, 0xD64E, 0xC34C, 0xD64F, 0xC34D,\t0xD650, 0xC34E, 0xD651, 0xC8AC, 0xD652, 0xC34F, 0xD653, 0xC350,\r\n\t0xD654, 0xC8AD, 0xD655, 0xC8AE, 0xD656, 0xC351, 0xD657, 0xC352,\t0xD658, 0xC8AF, 0xD659, 0xC353, 0xD65A, 0xC354, 0xD65B, 0xC355,\r\n\t0xD65C, 0xC8B0, 0xD65D, 0xC356, 0xD65E, 0xC357, 0xD65F, 0xC358,\t0xD660, 0xC359, 0xD661, 0xC35A, 0xD662, 0xC361, 0xD663, 0xC362,\r\n\t0xD664, 0xC363, 0xD665, 0xC364, 0xD666, 0xC365, 0xD667, 0xC8B1,\t0xD668, 0xC366, 0xD669, 0xC8B2, 0xD66A, 0xC367, 0xD66B, 0xC368,\r\n\t0xD66C, 0xC369, 0xD66D, 0xC36A, 0xD66E, 0xC36B, 0xD66F, 0xC36C,\t0xD670, 0xC8B3, 0xD671, 0xC8B4, 0xD672, 0xC36D, 0xD673, 0xC36E,\r\n\t0xD674, 0xC8B5, 0xD675, 0xC36F, 0xD676, 0xC370, 0xD677, 0xC371,\t0xD678, 0xC372, 0xD679, 0xC373, 0xD67A, 0xC374, 0xD67B, 0xC375,\r\n\t0xD67C, 0xC376, 0xD67D, 0xC377, 0xD67E, 0xC378, 0xD67F, 0xC379,\t0xD680, 0xC37A, 0xD681, 0xC381, 0xD682, 0xC382, 0xD683, 0xC8B6,\r\n\t0xD684, 0xC383, 0xD685, 0xC8B7, 0xD686, 0xC384, 0xD687, 0xC385,\t0xD688, 0xC386, 0xD689, 0xC387, 0xD68A, 0xC388, 0xD68B, 0xC389,\r\n\t0xD68C, 0xC8B8, 0xD68D, 0xC8B9, 0xD68E, 0xC38A, 0xD68F, 0xC38B,\t0xD690, 0xC8BA, 0xD691, 0xC38C, 0xD692, 0xC38D, 0xD693, 0xC38E,\r\n\t0xD694, 0xC8BB, 0xD695, 0xC38F, 0xD696, 0xC390, 0xD697, 0xC391,\t0xD698, 0xC392, 0xD699, 0xC393, 0xD69A, 0xC394, 0xD69B, 0xC395,\r\n\t0xD69C, 0xC396, 0xD69D, 0xC8BC, 0xD69E, 0xC397, 0xD69F, 0xC8BD,\t0xD6A0, 0xC398, 0xD6A1, 0xC8BE, 0xD6A2, 0xC399, 0xD6A3, 0xC39A,\r\n\t0xD6A4, 0xC39B, 0xD6A5, 0xC39C, 0xD6A6, 0xC39D, 0xD6A7, 0xC39E,\t0xD6A8, 0xC8BF, 0xD6A9, 0xC39F, 0xD6AA, 0xC3A0, 0xD6AB, 0xC441,\r\n\t0xD6AC, 0xC8C0, 0xD6AD, 0xC442, 0xD6AE, 0xC443, 0xD6AF, 0xC444,\t0xD6B0, 0xC8C1, 0xD6B1, 0xC445, 0xD6B2, 0xC446, 0xD6B3, 0xC447,\r\n\t0xD6B4, 0xC448, 0xD6B5, 0xC449, 0xD6B6, 0xC44A, 0xD6B7, 0xC44B,\t0xD6B8, 0xC44C, 0xD6B9, 0xC8C2, 0xD6BA, 0xC44D, 0xD6BB, 0xC8C3,\r\n\t0xD6BC, 0xC44E, 0xD6BD, 0xC44F, 0xD6BE, 0xC450, 0xD6BF, 0xC451,\t0xD6C0, 0xC452, 0xD6C1, 0xC453, 0xD6C2, 0xC454, 0xD6C3, 0xC455,\r\n\t0xD6C4, 0xC8C4, 0xD6C5, 0xC8C5, 0xD6C6, 0xC456, 0xD6C7, 0xC457,\t0xD6C8, 0xC8C6, 0xD6C9, 0xC458, 0xD6CA, 0xC459, 0xD6CB, 0xC45A,\r\n\t0xD6CC, 0xC8C7, 0xD6CD, 0xC461, 0xD6CE, 0xC462, 0xD6CF, 0xC463,\t0xD6D0, 0xC464, 0xD6D1, 0xC8C8, 0xD6D2, 0xC465, 0xD6D3, 0xC466,\r\n\t0xD6D4, 0xC8C9, 0xD6D5, 0xC467, 0xD6D6, 0xC468, 0xD6D7, 0xC8CA,\t0xD6D8, 0xC469, 0xD6D9, 0xC8CB, 0xD6DA, 0xC46A, 0xD6DB, 0xC46B,\r\n\t0xD6DC, 0xC46C, 0xD6DD, 0xC46D, 0xD6DE, 0xC46E, 0xD6DF, 0xC46F,\t0xD6E0, 0xC8CC, 0xD6E1, 0xC470, 0xD6E2, 0xC471, 0xD6E3, 0xC472,\r\n\t0xD6E4, 0xC8CD, 0xD6E5, 0xC473, 0xD6E6, 0xC474, 0xD6E7, 0xC475,\t0xD6E8, 0xC8CE, 0xD6E9, 0xC476, 0xD6EA, 0xC477, 0xD6EB, 0xC478,\r\n\t0xD6EC, 0xC479, 0xD6ED, 0xC47A, 0xD6EE, 0xC481, 0xD6EF, 0xC482,\t0xD6F0, 0xC8CF, 0xD6F1, 0xC483, 0xD6F2, 0xC484, 0xD6F3, 0xC485,\r\n\t0xD6F4, 0xC486, 0xD6F5, 0xC8D0, 0xD6F6, 0xC487, 0xD6F7, 0xC488,\t0xD6F8, 0xC489, 0xD6F9, 0xC48A, 0xD6FA, 0xC48B, 0xD6FB, 0xC48C,\r\n\t0xD6FC, 0xC8D1, 0xD6FD, 0xC8D2, 0xD6FE, 0xC48D, 0xD6FF, 0xC48E,\t0xD700, 0xC8D3, 0xD701, 0xC48F, 0xD702, 0xC490, 0xD703, 0xC491,\r\n\t0xD704, 0xC8D4, 0xD705, 0xC492, 0xD706, 0xC493, 0xD707, 0xC494,\t0xD708, 0xC495, 0xD709, 0xC496, 0xD70A, 0xC497, 0xD70B, 0xC498,\r\n\t0xD70C, 0xC499, 0xD70D, 0xC49A, 0xD70E, 0xC49B, 0xD70F, 0xC49C,\t0xD710, 0xC49D, 0xD711, 0xC8D5, 0xD712, 0xC49E, 0xD713, 0xC49F,\r\n\t0xD714, 0xC4A0, 0xD715, 0xC541, 0xD716, 0xC542, 0xD717, 0xC543,\t0xD718, 0xC8D6, 0xD719, 0xC8D7, 0xD71A, 0xC544, 0xD71B, 0xC545,\r\n\t0xD71C, 0xC8D8, 0xD71D, 0xC546, 0xD71E, 0xC547, 0xD71F, 0xC548,\t0xD720, 0xC8D9, 0xD721, 0xC549, 0xD722, 0xC54A, 0xD723, 0xC54B,\r\n\t0xD724, 0xC54C, 0xD725, 0xC54D, 0xD726, 0xC54E, 0xD727, 0xC54F,\t0xD728, 0xC8DA, 0xD729, 0xC8DB, 0xD72A, 0xC550, 0xD72B, 0xC8DC,\r\n\t0xD72C, 0xC551, 0xD72D, 0xC8DD, 0xD72E, 0xC552, 0xD72F, 0xC553,\t0xD730, 0xC554, 0xD731, 0xC555, 0xD732, 0xC556, 0xD733, 0xC557,\r\n\t0xD734, 0xC8DE, 0xD735, 0xC8DF, 0xD736, 0xC558, 0xD737, 0xC559,\t0xD738, 0xC8E0, 0xD739, 0xC55A, 0xD73A, 0xC561, 0xD73B, 0xC562,\r\n\t0xD73C, 0xC8E1, 0xD73D, 0xC563, 0xD73E, 0xC564, 0xD73F, 0xC565,\t0xD740, 0xC566, 0xD741, 0xC567, 0xD742, 0xC568, 0xD743, 0xC569,\r\n\t0xD744, 0xC8E2, 0xD745, 0xC56A, 0xD746, 0xC56B, 0xD747, 0xC8E3,\t0xD748, 0xC56C, 0xD749, 0xC8E4, 0xD74A, 0xC56D, 0xD74B, 0xC56E,\r\n\t0xD74C, 0xC56F, 0xD74D, 0xC570, 0xD74E, 0xC571, 0xD74F, 0xC572,\t0xD750, 0xC8E5, 0xD751, 0xC8E6, 0xD752, 0xC573, 0xD753, 0xC574,\r\n\t0xD754, 0xC8E7, 0xD755, 0xC575, 0xD756, 0xC8E8, 0xD757, 0xC8E9,\t0xD758, 0xC8EA, 0xD759, 0xC8EB, 0xD75A, 0xC576, 0xD75B, 0xC577,\r\n\t0xD75C, 0xC578, 0xD75D, 0xC579, 0xD75E, 0xC57A, 0xD75F, 0xC581,\t0xD760, 0xC8EC, 0xD761, 0xC8ED, 0xD762, 0xC582, 0xD763, 0xC8EE,\r\n\t0xD764, 0xC583, 0xD765, 0xC8EF, 0xD766, 0xC584, 0xD767, 0xC585,\t0xD768, 0xC586, 0xD769, 0xC8F0, 0xD76A, 0xC587, 0xD76B, 0xC588,\r\n\t0xD76C, 0xC8F1, 0xD76D, 0xC589, 0xD76E, 0xC58A, 0xD76F, 0xC58B,\t0xD770, 0xC8F2, 0xD771, 0xC58C, 0xD772, 0xC58D, 0xD773, 0xC58E,\r\n\t0xD774, 0xC8F3, 0xD775, 0xC58F, 0xD776, 0xC590, 0xD777, 0xC591,\t0xD778, 0xC592, 0xD779, 0xC593, 0xD77A, 0xC594, 0xD77B, 0xC595,\r\n\t0xD77C, 0xC8F4, 0xD77D, 0xC8F5, 0xD77E, 0xC596, 0xD77F, 0xC597,\t0xD780, 0xC598, 0xD781, 0xC8F6, 0xD782, 0xC599, 0xD783, 0xC59A,\r\n\t0xD784, 0xC59B, 0xD785, 0xC59C, 0xD786, 0xC59D, 0xD787, 0xC59E,\t0xD788, 0xC8F7, 0xD789, 0xC8F8, 0xD78A, 0xC59F, 0xD78B, 0xC5A0,\r\n\t0xD78C, 0xC8F9, 0xD78D, 0xC641, 0xD78E, 0xC642, 0xD78F, 0xC643,\t0xD790, 0xC8FA, 0xD791, 0xC644, 0xD792, 0xC645, 0xD793, 0xC646,\r\n\t0xD794, 0xC647, 0xD795, 0xC648, 0xD796, 0xC649, 0xD797, 0xC64A,\t0xD798, 0xC8FB, 0xD799, 0xC8FC, 0xD79A, 0xC64B, 0xD79B, 0xC8FD,\r\n\t0xD79C, 0xC64C, 0xD79D, 0xC8FE, 0xD79E, 0xC64D, 0xD79F, 0xC64E,\t0xD7A0, 0xC64F, 0xD7A1, 0xC650, 0xD7A2, 0xC651, 0xD7A3, 0xC652,\r\n\t0xF900, 0xCBD0, 0xF901, 0xCBD6, 0xF902, 0xCBE7, 0xF903, 0xCDCF,\t0xF904, 0xCDE8, 0xF905, 0xCEAD, 0xF906, 0xCFFB, 0xF907, 0xD0A2,\r\n\t0xF908, 0xD0B8, 0xF909, 0xD0D0, 0xF90A, 0xD0DD, 0xF90B, 0xD1D4,\t0xF90C, 0xD1D5, 0xF90D, 0xD1D8, 0xF90E, 0xD1DB, 0xF90F, 0xD1DC,\r\n\t0xF910, 0xD1DD, 0xF911, 0xD1DE, 0xF912, 0xD1DF, 0xF913, 0xD1E0,\t0xF914, 0xD1E2, 0xF915, 0xD1E3, 0xF916, 0xD1E4, 0xF917, 0xD1E5,\r\n\t0xF918, 0xD1E6, 0xF919, 0xD1E8, 0xF91A, 0xD1E9, 0xF91B, 0xD1EA,\t0xF91C, 0xD1EB, 0xF91D, 0xD1ED, 0xF91E, 0xD1EF, 0xF91F, 0xD1F0,\r\n\t0xF920, 0xD1F2, 0xF921, 0xD1F6, 0xF922, 0xD1FA, 0xF923, 0xD1FC,\t0xF924, 0xD1FD, 0xF925, 0xD1FE, 0xF926, 0xD2A2, 0xF927, 0xD2A3,\r\n\t0xF928, 0xD2A7, 0xF929, 0xD2A8, 0xF92A, 0xD2A9, 0xF92B, 0xD2AA,\t0xF92C, 0xD2AB, 0xF92D, 0xD2AD, 0xF92E, 0xD2B2, 0xF92F, 0xD2BE,\r\n\t0xF930, 0xD2C2, 0xF931, 0xD2C3, 0xF932, 0xD2C4, 0xF933, 0xD2C6,\t0xF934, 0xD2C7, 0xF935, 0xD2C8, 0xF936, 0xD2C9, 0xF937, 0xD2CA,\r\n\t0xF938, 0xD2CB, 0xF939, 0xD2CD, 0xF93A, 0xD2CE, 0xF93B, 0xD2CF,\t0xF93C, 0xD2D0, 0xF93D, 0xD2D1, 0xF93E, 0xD2D2, 0xF93F, 0xD2D3,\r\n\t0xF940, 0xD2D4, 0xF941, 0xD2D5, 0xF942, 0xD2D6, 0xF943, 0xD2D7,\t0xF944, 0xD2D9, 0xF945, 0xD2DA, 0xF946, 0xD2DE, 0xF947, 0xD2DF,\r\n\t0xF948, 0xD2E1, 0xF949, 0xD2E2, 0xF94A, 0xD2E4, 0xF94B, 0xD2E5,\t0xF94C, 0xD2E6, 0xF94D, 0xD2E7, 0xF94E, 0xD2E8, 0xF94F, 0xD2E9,\r\n\t0xF950, 0xD2EA, 0xF951, 0xD2EB, 0xF952, 0xD2F0, 0xF953, 0xD2F1,\t0xF954, 0xD2F2, 0xF955, 0xD2F3, 0xF956, 0xD2F4, 0xF957, 0xD2F5,\r\n\t0xF958, 0xD2F7, 0xF959, 0xD2F8, 0xF95A, 0xD4E6, 0xF95B, 0xD4FC,\t0xF95C, 0xD5A5, 0xF95D, 0xD5AB, 0xF95E, 0xD5AE, 0xF95F, 0xD6B8,\r\n\t0xF960, 0xD6CD, 0xF961, 0xD7CB, 0xF962, 0xD7E4, 0xF963, 0xDBC5,\t0xF964, 0xDBE4, 0xF965, 0xDCA5, 0xF966, 0xDDA5, 0xF967, 0xDDD5,\r\n\t0xF968, 0xDDF4, 0xF969, 0xDEFC, 0xF96A, 0xDEFE, 0xF96B, 0xDFB3,\t0xF96C, 0xDFE1, 0xF96D, 0xDFE8, 0xF96E, 0xE0F1, 0xF96F, 0xE1AD,\r\n\t0xF970, 0xE1ED, 0xF971, 0xE3F5, 0xF972, 0xE4A1, 0xF973, 0xE4A9,\t0xF974, 0xE5AE, 0xF975, 0xE5B1, 0xF976, 0xE5B2, 0xF977, 0xE5B9,\r\n\t0xF978, 0xE5BB, 0xF979, 0xE5BC, 0xF97A, 0xE5C4, 0xF97B, 0xE5CE,\t0xF97C, 0xE5D0, 0xF97D, 0xE5D2, 0xF97E, 0xE5D6, 0xF97F, 0xE5FA,\r\n\t0xF980, 0xE5FB, 0xF981, 0xE5FC, 0xF982, 0xE5FE, 0xF983, 0xE6A1,\t0xF984, 0xE6A4, 0xF985, 0xE6A7, 0xF986, 0xE6AD, 0xF987, 0xE6AF,\r\n\t0xF988, 0xE6B0, 0xF989, 0xE6B1, 0xF98A, 0xE6B3, 0xF98B, 0xE6B7,\t0xF98C, 0xE6B8, 0xF98D, 0xE6BC, 0xF98E, 0xE6C4, 0xF98F, 0xE6C6,\r\n\t0xF990, 0xE6C7, 0xF991, 0xE6CA, 0xF992, 0xE6D2, 0xF993, 0xE6D6,\t0xF994, 0xE6D9, 0xF995, 0xE6DC, 0xF996, 0xE6DF, 0xF997, 0xE6E1,\r\n\t0xF998, 0xE6E4, 0xF999, 0xE6E5, 0xF99A, 0xE6E6, 0xF99B, 0xE6E8,\t0xF99C, 0xE6EA, 0xF99D, 0xE6EB, 0xF99E, 0xE6EC, 0xF99F, 0xE6EF,\r\n\t0xF9A0, 0xE6F1, 0xF9A1, 0xE6F2, 0xF9A2, 0xE6F5, 0xF9A3, 0xE6F6,\t0xF9A4, 0xE6F7, 0xF9A5, 0xE6F9, 0xF9A6, 0xE7A1, 0xF9A7, 0xE7A6,\r\n\t0xF9A8, 0xE7A9, 0xF9A9, 0xE7AA, 0xF9AA, 0xE7AC, 0xF9AB, 0xE7AD,\t0xF9AC, 0xE7B0, 0xF9AD, 0xE7BF, 0xF9AE, 0xE7C1, 0xF9AF, 0xE7C6,\r\n\t0xF9B0, 0xE7C7, 0xF9B1, 0xE7CB, 0xF9B2, 0xE7CD, 0xF9B3, 0xE7CF,\t0xF9B4, 0xE7D0, 0xF9B5, 0xE7D3, 0xF9B6, 0xE7DF, 0xF9B7, 0xE7E4,\r\n\t0xF9B8, 0xE7E6, 0xF9B9, 0xE7F7, 0xF9BA, 0xE8E7, 0xF9BB, 0xE8E8,\t0xF9BC, 0xE8F0, 0xF9BD, 0xE8F1, 0xF9BE, 0xE8F7, 0xF9BF, 0xE8F9,\r\n\t0xF9C0, 0xE8FB, 0xF9C1, 0xE8FE, 0xF9C2, 0xE9A7, 0xF9C3, 0xE9AC,\t0xF9C4, 0xE9CC, 0xF9C5, 0xE9F7, 0xF9C6, 0xEAC1, 0xF9C7, 0xEAE5,\r\n\t0xF9C8, 0xEAF4, 0xF9C9, 0xEAF7, 0xF9CA, 0xEAFC, 0xF9CB, 0xEAFE,\t0xF9CC, 0xEBA4, 0xF9CD, 0xEBA7, 0xF9CE, 0xEBA9, 0xF9CF, 0xEBAA,\r\n\t0xF9D0, 0xEBBA, 0xF9D1, 0xEBBB, 0xF9D2, 0xEBBD, 0xF9D3, 0xEBC1,\t0xF9D4, 0xEBC2, 0xF9D5, 0xEBC6, 0xF9D6, 0xEBC7, 0xF9D7, 0xEBCC,\r\n\t0xF9D8, 0xEBCF, 0xF9D9, 0xEBD0, 0xF9DA, 0xEBD1, 0xF9DB, 0xEBD2,\t0xF9DC, 0xEBD8, 0xF9DD, 0xECA6, 0xF9DE, 0xECA7, 0xF9DF, 0xECAA,\r\n\t0xF9E0, 0xECAF, 0xF9E1, 0xECB0, 0xF9E2, 0xECB1, 0xF9E3, 0xECB2,\t0xF9E4, 0xECB5, 0xF9E5, 0xECB8, 0xF9E6, 0xECBA, 0xF9E7, 0xECC0,\r\n\t0xF9E8, 0xECC1, 0xF9E9, 0xECC5, 0xF9EA, 0xECC6, 0xF9EB, 0xECC9,\t0xF9EC, 0xECCA, 0xF9ED, 0xECD5, 0xF9EE, 0xECDD, 0xF9EF, 0xECDE,\r\n\t0xF9F0, 0xECE1, 0xF9F1, 0xECE4, 0xF9F2, 0xECE7, 0xF9F3, 0xECE8,\t0xF9F4, 0xECF7, 0xF9F5, 0xECF8, 0xF9F6, 0xECFA, 0xF9F7, 0xEDA1,\r\n\t0xF9F8, 0xEDA2, 0xF9F9, 0xEDA3, 0xF9FA, 0xEDEE, 0xF9FB, 0xEEDB,\t0xF9FC, 0xF2BD, 0xF9FD, 0xF2FA, 0xF9FE, 0xF3B1, 0xF9FF, 0xF4A7,\r\n\t0xFA00, 0xF4EE, 0xFA01, 0xF6F4, 0xFA02, 0xF6F6, 0xFA03, 0xF7B8,\t0xFA04, 0xF7C8, 0xFA05, 0xF7D3, 0xFA06, 0xF8DB, 0xFA07, 0xF8F0,\r\n\t0xFA08, 0xFAA1, 0xFA09, 0xFAA2, 0xFA0A, 0xFAE6, 0xFA0B, 0xFCA9,\t0xFF01, 0xA3A1, 0xFF02, 0xA3A2, 0xFF03, 0xA3A3, 0xFF04, 0xA3A4,\r\n\t0xFF05, 0xA3A5, 0xFF06, 0xA3A6, 0xFF07, 0xA3A7, 0xFF08, 0xA3A8,\t0xFF09, 0xA3A9, 0xFF0A, 0xA3AA, 0xFF0B, 0xA3AB, 0xFF0C, 0xA3AC,\r\n\t0xFF0D, 0xA3AD, 0xFF0E, 0xA3AE, 0xFF0F, 0xA3AF, 0xFF10, 0xA3B0,\t0xFF11, 0xA3B1, 0xFF12, 0xA3B2, 0xFF13, 0xA3B3, 0xFF14, 0xA3B4,\r\n\t0xFF15, 0xA3B5, 0xFF16, 0xA3B6, 0xFF17, 0xA3B7, 0xFF18, 0xA3B8,\t0xFF19, 0xA3B9, 0xFF1A, 0xA3BA, 0xFF1B, 0xA3BB, 0xFF1C, 0xA3BC,\r\n\t0xFF1D, 0xA3BD, 0xFF1E, 0xA3BE, 0xFF1F, 0xA3BF, 0xFF20, 0xA3C0,\t0xFF21, 0xA3C1, 0xFF22, 0xA3C2, 0xFF23, 0xA3C3, 0xFF24, 0xA3C4,\r\n\t0xFF25, 0xA3C5, 0xFF26, 0xA3C6, 0xFF27, 0xA3C7, 0xFF28, 0xA3C8,\t0xFF29, 0xA3C9, 0xFF2A, 0xA3CA, 0xFF2B, 0xA3CB, 0xFF2C, 0xA3CC,\r\n\t0xFF2D, 0xA3CD, 0xFF2E, 0xA3CE, 0xFF2F, 0xA3CF, 0xFF30, 0xA3D0,\t0xFF31, 0xA3D1, 0xFF32, 0xA3D2, 0xFF33, 0xA3D3, 0xFF34, 0xA3D4,\r\n\t0xFF35, 0xA3D5, 0xFF36, 0xA3D6, 0xFF37, 0xA3D7, 0xFF38, 0xA3D8,\t0xFF39, 0xA3D9, 0xFF3A, 0xA3DA, 0xFF3B, 0xA3DB, 0xFF3C, 0xA1AC,\r\n\t0xFF3D, 0xA3DD, 0xFF3E, 0xA3DE, 0xFF3F, 0xA3DF, 0xFF40, 0xA3E0,\t0xFF41, 0xA3E1, 0xFF42, 0xA3E2, 0xFF43, 0xA3E3, 0xFF44, 0xA3E4,\r\n\t0xFF45, 0xA3E5, 0xFF46, 0xA3E6, 0xFF47, 0xA3E7, 0xFF48, 0xA3E8,\t0xFF49, 0xA3E9, 0xFF4A, 0xA3EA, 0xFF4B, 0xA3EB, 0xFF4C, 0xA3EC,\r\n\t0xFF4D, 0xA3ED, 0xFF4E, 0xA3EE, 0xFF4F, 0xA3EF, 0xFF50, 0xA3F0,\t0xFF51, 0xA3F1, 0xFF52, 0xA3F2, 0xFF53, 0xA3F3, 0xFF54, 0xA3F4,\r\n\t0xFF55, 0xA3F5, 0xFF56, 0xA3F6, 0xFF57, 0xA3F7, 0xFF58, 0xA3F8,\t0xFF59, 0xA3F9, 0xFF5A, 0xA3FA, 0xFF5B, 0xA3FB, 0xFF5C, 0xA3FC,\r\n\t0xFF5D, 0xA3FD, 0xFF5E, 0xA2A6, 0xFFE0, 0xA1CB, 0xFFE1, 0xA1CC,\t0xFFE2, 0xA1FE, 0xFFE3, 0xA3FE, 0xFFE5, 0xA1CD, 0xFFE6, 0xA3DC,\r\n\t0, 0\r\n};\r\n\r\nstatic const WCHAR oem2uni949[] = {\t/* Korean --> Unicode pairs */\r\n\t0x8141, 0xAC02, 0x8142, 0xAC03, 0x8143, 0xAC05, 0x8144, 0xAC06,\t0x8145, 0xAC0B, 0x8146, 0xAC0C, 0x8147, 0xAC0D, 0x8148, 0xAC0E,\r\n\t0x8149, 0xAC0F, 0x814A, 0xAC18, 0x814B, 0xAC1E, 0x814C, 0xAC1F,\t0x814D, 0xAC21, 0x814E, 0xAC22, 0x814F, 0xAC23, 0x8150, 0xAC25,\r\n\t0x8151, 0xAC26, 0x8152, 0xAC27, 0x8153, 0xAC28, 0x8154, 0xAC29,\t0x8155, 0xAC2A, 0x8156, 0xAC2B, 0x8157, 0xAC2E, 0x8158, 0xAC32,\r\n\t0x8159, 0xAC33, 0x815A, 0xAC34, 0x8161, 0xAC35, 0x8162, 0xAC36,\t0x8163, 0xAC37, 0x8164, 0xAC3A, 0x8165, 0xAC3B, 0x8166, 0xAC3D,\r\n\t0x8167, 0xAC3E, 0x8168, 0xAC3F, 0x8169, 0xAC41, 0x816A, 0xAC42,\t0x816B, 0xAC43, 0x816C, 0xAC44, 0x816D, 0xAC45, 0x816E, 0xAC46,\r\n\t0x816F, 0xAC47, 0x8170, 0xAC48, 0x8171, 0xAC49, 0x8172, 0xAC4A,\t0x8173, 0xAC4C, 0x8174, 0xAC4E, 0x8175, 0xAC4F, 0x8176, 0xAC50,\r\n\t0x8177, 0xAC51, 0x8178, 0xAC52, 0x8179, 0xAC53, 0x817A, 0xAC55,\t0x8181, 0xAC56, 0x8182, 0xAC57, 0x8183, 0xAC59, 0x8184, 0xAC5A,\r\n\t0x8185, 0xAC5B, 0x8186, 0xAC5D, 0x8187, 0xAC5E, 0x8188, 0xAC5F,\t0x8189, 0xAC60, 0x818A, 0xAC61, 0x818B, 0xAC62, 0x818C, 0xAC63,\r\n\t0x818D, 0xAC64, 0x818E, 0xAC65, 0x818F, 0xAC66, 0x8190, 0xAC67,\t0x8191, 0xAC68, 0x8192, 0xAC69, 0x8193, 0xAC6A, 0x8194, 0xAC6B,\r\n\t0x8195, 0xAC6C, 0x8196, 0xAC6D, 0x8197, 0xAC6E, 0x8198, 0xAC6F,\t0x8199, 0xAC72, 0x819A, 0xAC73, 0x819B, 0xAC75, 0x819C, 0xAC76,\r\n\t0x819D, 0xAC79, 0x819E, 0xAC7B, 0x819F, 0xAC7C, 0x81A0, 0xAC7D,\t0x81A1, 0xAC7E, 0x81A2, 0xAC7F, 0x81A3, 0xAC82, 0x81A4, 0xAC87,\r\n\t0x81A5, 0xAC88, 0x81A6, 0xAC8D, 0x81A7, 0xAC8E, 0x81A8, 0xAC8F,\t0x81A9, 0xAC91, 0x81AA, 0xAC92, 0x81AB, 0xAC93, 0x81AC, 0xAC95,\r\n\t0x81AD, 0xAC96, 0x81AE, 0xAC97, 0x81AF, 0xAC98, 0x81B0, 0xAC99,\t0x81B1, 0xAC9A, 0x81B2, 0xAC9B, 0x81B3, 0xAC9E, 0x81B4, 0xACA2,\r\n\t0x81B5, 0xACA3, 0x81B6, 0xACA4, 0x81B7, 0xACA5, 0x81B8, 0xACA6,\t0x81B9, 0xACA7, 0x81BA, 0xACAB, 0x81BB, 0xACAD, 0x81BC, 0xACAE,\r\n\t0x81BD, 0xACB1, 0x81BE, 0xACB2, 0x81BF, 0xACB3, 0x81C0, 0xACB4,\t0x81C1, 0xACB5, 0x81C2, 0xACB6, 0x81C3, 0xACB7, 0x81C4, 0xACBA,\r\n\t0x81C5, 0xACBE, 0x81C6, 0xACBF, 0x81C7, 0xACC0, 0x81C8, 0xACC2,\t0x81C9, 0xACC3, 0x81CA, 0xACC5, 0x81CB, 0xACC6, 0x81CC, 0xACC7,\r\n\t0x81CD, 0xACC9, 0x81CE, 0xACCA, 0x81CF, 0xACCB, 0x81D0, 0xACCD,\t0x81D1, 0xACCE, 0x81D2, 0xACCF, 0x81D3, 0xACD0, 0x81D4, 0xACD1,\r\n\t0x81D5, 0xACD2, 0x81D6, 0xACD3, 0x81D7, 0xACD4, 0x81D8, 0xACD6,\t0x81D9, 0xACD8, 0x81DA, 0xACD9, 0x81DB, 0xACDA, 0x81DC, 0xACDB,\r\n\t0x81DD, 0xACDC, 0x81DE, 0xACDD, 0x81DF, 0xACDE, 0x81E0, 0xACDF,\t0x81E1, 0xACE2, 0x81E2, 0xACE3, 0x81E3, 0xACE5, 0x81E4, 0xACE6,\r\n\t0x81E5, 0xACE9, 0x81E6, 0xACEB, 0x81E7, 0xACED, 0x81E8, 0xACEE,\t0x81E9, 0xACF2, 0x81EA, 0xACF4, 0x81EB, 0xACF7, 0x81EC, 0xACF8,\r\n\t0x81ED, 0xACF9, 0x81EE, 0xACFA, 0x81EF, 0xACFB, 0x81F0, 0xACFE,\t0x81F1, 0xACFF, 0x81F2, 0xAD01, 0x81F3, 0xAD02, 0x81F4, 0xAD03,\r\n\t0x81F5, 0xAD05, 0x81F6, 0xAD07, 0x81F7, 0xAD08, 0x81F8, 0xAD09,\t0x81F9, 0xAD0A, 0x81FA, 0xAD0B, 0x81FB, 0xAD0E, 0x81FC, 0xAD10,\r\n\t0x81FD, 0xAD12, 0x81FE, 0xAD13, 0x8241, 0xAD14, 0x8242, 0xAD15,\t0x8243, 0xAD16, 0x8244, 0xAD17, 0x8245, 0xAD19, 0x8246, 0xAD1A,\r\n\t0x8247, 0xAD1B, 0x8248, 0xAD1D, 0x8249, 0xAD1E, 0x824A, 0xAD1F,\t0x824B, 0xAD21, 0x824C, 0xAD22, 0x824D, 0xAD23, 0x824E, 0xAD24,\r\n\t0x824F, 0xAD25, 0x8250, 0xAD26, 0x8251, 0xAD27, 0x8252, 0xAD28,\t0x8253, 0xAD2A, 0x8254, 0xAD2B, 0x8255, 0xAD2E, 0x8256, 0xAD2F,\r\n\t0x8257, 0xAD30, 0x8258, 0xAD31, 0x8259, 0xAD32, 0x825A, 0xAD33,\t0x8261, 0xAD36, 0x8262, 0xAD37, 0x8263, 0xAD39, 0x8264, 0xAD3A,\r\n\t0x8265, 0xAD3B, 0x8266, 0xAD3D, 0x8267, 0xAD3E, 0x8268, 0xAD3F,\t0x8269, 0xAD40, 0x826A, 0xAD41, 0x826B, 0xAD42, 0x826C, 0xAD43,\r\n\t0x826D, 0xAD46, 0x826E, 0xAD48, 0x826F, 0xAD4A, 0x8270, 0xAD4B,\t0x8271, 0xAD4C, 0x8272, 0xAD4D, 0x8273, 0xAD4E, 0x8274, 0xAD4F,\r\n\t0x8275, 0xAD51, 0x8276, 0xAD52, 0x8277, 0xAD53, 0x8278, 0xAD55,\t0x8279, 0xAD56, 0x827A, 0xAD57, 0x8281, 0xAD59, 0x8282, 0xAD5A,\r\n\t0x8283, 0xAD5B, 0x8284, 0xAD5C, 0x8285, 0xAD5D, 0x8286, 0xAD5E,\t0x8287, 0xAD5F, 0x8288, 0xAD60, 0x8289, 0xAD62, 0x828A, 0xAD64,\r\n\t0x828B, 0xAD65, 0x828C, 0xAD66, 0x828D, 0xAD67, 0x828E, 0xAD68,\t0x828F, 0xAD69, 0x8290, 0xAD6A, 0x8291, 0xAD6B, 0x8292, 0xAD6E,\r\n\t0x8293, 0xAD6F, 0x8294, 0xAD71, 0x8295, 0xAD72, 0x8296, 0xAD77,\t0x8297, 0xAD78, 0x8298, 0xAD79, 0x8299, 0xAD7A, 0x829A, 0xAD7E,\r\n\t0x829B, 0xAD80, 0x829C, 0xAD83, 0x829D, 0xAD84, 0x829E, 0xAD85,\t0x829F, 0xAD86, 0x82A0, 0xAD87, 0x82A1, 0xAD8A, 0x82A2, 0xAD8B,\r\n\t0x82A3, 0xAD8D, 0x82A4, 0xAD8E, 0x82A5, 0xAD8F, 0x82A6, 0xAD91,\t0x82A7, 0xAD92, 0x82A8, 0xAD93, 0x82A9, 0xAD94, 0x82AA, 0xAD95,\r\n\t0x82AB, 0xAD96, 0x82AC, 0xAD97, 0x82AD, 0xAD98, 0x82AE, 0xAD99,\t0x82AF, 0xAD9A, 0x82B0, 0xAD9B, 0x82B1, 0xAD9E, 0x82B2, 0xAD9F,\r\n\t0x82B3, 0xADA0, 0x82B4, 0xADA1, 0x82B5, 0xADA2, 0x82B6, 0xADA3,\t0x82B7, 0xADA5, 0x82B8, 0xADA6, 0x82B9, 0xADA7, 0x82BA, 0xADA8,\r\n\t0x82BB, 0xADA9, 0x82BC, 0xADAA, 0x82BD, 0xADAB, 0x82BE, 0xADAC,\t0x82BF, 0xADAD, 0x82C0, 0xADAE, 0x82C1, 0xADAF, 0x82C2, 0xADB0,\r\n\t0x82C3, 0xADB1, 0x82C4, 0xADB2, 0x82C5, 0xADB3, 0x82C6, 0xADB4,\t0x82C7, 0xADB5, 0x82C8, 0xADB6, 0x82C9, 0xADB8, 0x82CA, 0xADB9,\r\n\t0x82CB, 0xADBA, 0x82CC, 0xADBB, 0x82CD, 0xADBC, 0x82CE, 0xADBD,\t0x82CF, 0xADBE, 0x82D0, 0xADBF, 0x82D1, 0xADC2, 0x82D2, 0xADC3,\r\n\t0x82D3, 0xADC5, 0x82D4, 0xADC6, 0x82D5, 0xADC7, 0x82D6, 0xADC9,\t0x82D7, 0xADCA, 0x82D8, 0xADCB, 0x82D9, 0xADCC, 0x82DA, 0xADCD,\r\n\t0x82DB, 0xADCE, 0x82DC, 0xADCF, 0x82DD, 0xADD2, 0x82DE, 0xADD4,\t0x82DF, 0xADD5, 0x82E0, 0xADD6, 0x82E1, 0xADD7, 0x82E2, 0xADD8,\r\n\t0x82E3, 0xADD9, 0x82E4, 0xADDA, 0x82E5, 0xADDB, 0x82E6, 0xADDD,\t0x82E7, 0xADDE, 0x82E8, 0xADDF, 0x82E9, 0xADE1, 0x82EA, 0xADE2,\r\n\t0x82EB, 0xADE3, 0x82EC, 0xADE5, 0x82ED, 0xADE6, 0x82EE, 0xADE7,\t0x82EF, 0xADE8, 0x82F0, 0xADE9, 0x82F1, 0xADEA, 0x82F2, 0xADEB,\r\n\t0x82F3, 0xADEC, 0x82F4, 0xADED, 0x82F5, 0xADEE, 0x82F6, 0xADEF,\t0x82F7, 0xADF0, 0x82F8, 0xADF1, 0x82F9, 0xADF2, 0x82FA, 0xADF3,\r\n\t0x82FB, 0xADF4, 0x82FC, 0xADF5, 0x82FD, 0xADF6, 0x82FE, 0xADF7,\t0x8341, 0xADFA, 0x8342, 0xADFB, 0x8343, 0xADFD, 0x8344, 0xADFE,\r\n\t0x8345, 0xAE02, 0x8346, 0xAE03, 0x8347, 0xAE04, 0x8348, 0xAE05,\t0x8349, 0xAE06, 0x834A, 0xAE07, 0x834B, 0xAE0A, 0x834C, 0xAE0C,\r\n\t0x834D, 0xAE0E, 0x834E, 0xAE0F, 0x834F, 0xAE10, 0x8350, 0xAE11,\t0x8351, 0xAE12, 0x8352, 0xAE13, 0x8353, 0xAE15, 0x8354, 0xAE16,\r\n\t0x8355, 0xAE17, 0x8356, 0xAE18, 0x8357, 0xAE19, 0x8358, 0xAE1A,\t0x8359, 0xAE1B, 0x835A, 0xAE1C, 0x8361, 0xAE1D, 0x8362, 0xAE1E,\r\n\t0x8363, 0xAE1F, 0x8364, 0xAE20, 0x8365, 0xAE21, 0x8366, 0xAE22,\t0x8367, 0xAE23, 0x8368, 0xAE24, 0x8369, 0xAE25, 0x836A, 0xAE26,\r\n\t0x836B, 0xAE27, 0x836C, 0xAE28, 0x836D, 0xAE29, 0x836E, 0xAE2A,\t0x836F, 0xAE2B, 0x8370, 0xAE2C, 0x8371, 0xAE2D, 0x8372, 0xAE2E,\r\n\t0x8373, 0xAE2F, 0x8374, 0xAE32, 0x8375, 0xAE33, 0x8376, 0xAE35,\t0x8377, 0xAE36, 0x8378, 0xAE39, 0x8379, 0xAE3B, 0x837A, 0xAE3C,\r\n\t0x8381, 0xAE3D, 0x8382, 0xAE3E, 0x8383, 0xAE3F, 0x8384, 0xAE42,\t0x8385, 0xAE44, 0x8386, 0xAE47, 0x8387, 0xAE48, 0x8388, 0xAE49,\r\n\t0x8389, 0xAE4B, 0x838A, 0xAE4F, 0x838B, 0xAE51, 0x838C, 0xAE52,\t0x838D, 0xAE53, 0x838E, 0xAE55, 0x838F, 0xAE57, 0x8390, 0xAE58,\r\n\t0x8391, 0xAE59, 0x8392, 0xAE5A, 0x8393, 0xAE5B, 0x8394, 0xAE5E,\t0x8395, 0xAE62, 0x8396, 0xAE63, 0x8397, 0xAE64, 0x8398, 0xAE66,\r\n\t0x8399, 0xAE67, 0x839A, 0xAE6A, 0x839B, 0xAE6B, 0x839C, 0xAE6D,\t0x839D, 0xAE6E, 0x839E, 0xAE6F, 0x839F, 0xAE71, 0x83A0, 0xAE72,\r\n\t0x83A1, 0xAE73, 0x83A2, 0xAE74, 0x83A3, 0xAE75, 0x83A4, 0xAE76,\t0x83A5, 0xAE77, 0x83A6, 0xAE7A, 0x83A7, 0xAE7E, 0x83A8, 0xAE7F,\r\n\t0x83A9, 0xAE80, 0x83AA, 0xAE81, 0x83AB, 0xAE82, 0x83AC, 0xAE83,\t0x83AD, 0xAE86, 0x83AE, 0xAE87, 0x83AF, 0xAE88, 0x83B0, 0xAE89,\r\n\t0x83B1, 0xAE8A, 0x83B2, 0xAE8B, 0x83B3, 0xAE8D, 0x83B4, 0xAE8E,\t0x83B5, 0xAE8F, 0x83B6, 0xAE90, 0x83B7, 0xAE91, 0x83B8, 0xAE92,\r\n\t0x83B9, 0xAE93, 0x83BA, 0xAE94, 0x83BB, 0xAE95, 0x83BC, 0xAE96,\t0x83BD, 0xAE97, 0x83BE, 0xAE98, 0x83BF, 0xAE99, 0x83C0, 0xAE9A,\r\n\t0x83C1, 0xAE9B, 0x83C2, 0xAE9C, 0x83C3, 0xAE9D, 0x83C4, 0xAE9E,\t0x83C5, 0xAE9F, 0x83C6, 0xAEA0, 0x83C7, 0xAEA1, 0x83C8, 0xAEA2,\r\n\t0x83C9, 0xAEA3, 0x83CA, 0xAEA4, 0x83CB, 0xAEA5, 0x83CC, 0xAEA6,\t0x83CD, 0xAEA7, 0x83CE, 0xAEA8, 0x83CF, 0xAEA9, 0x83D0, 0xAEAA,\r\n\t0x83D1, 0xAEAB, 0x83D2, 0xAEAC, 0x83D3, 0xAEAD, 0x83D4, 0xAEAE,\t0x83D5, 0xAEAF, 0x83D6, 0xAEB0, 0x83D7, 0xAEB1, 0x83D8, 0xAEB2,\r\n\t0x83D9, 0xAEB3, 0x83DA, 0xAEB4, 0x83DB, 0xAEB5, 0x83DC, 0xAEB6,\t0x83DD, 0xAEB7, 0x83DE, 0xAEB8, 0x83DF, 0xAEB9, 0x83E0, 0xAEBA,\r\n\t0x83E1, 0xAEBB, 0x83E2, 0xAEBF, 0x83E3, 0xAEC1, 0x83E4, 0xAEC2,\t0x83E5, 0xAEC3, 0x83E6, 0xAEC5, 0x83E7, 0xAEC6, 0x83E8, 0xAEC7,\r\n\t0x83E9, 0xAEC8, 0x83EA, 0xAEC9, 0x83EB, 0xAECA, 0x83EC, 0xAECB,\t0x83ED, 0xAECE, 0x83EE, 0xAED2, 0x83EF, 0xAED3, 0x83F0, 0xAED4,\r\n\t0x83F1, 0xAED5, 0x83F2, 0xAED6, 0x83F3, 0xAED7, 0x83F4, 0xAEDA,\t0x83F5, 0xAEDB, 0x83F6, 0xAEDD, 0x83F7, 0xAEDE, 0x83F8, 0xAEDF,\r\n\t0x83F9, 0xAEE0, 0x83FA, 0xAEE1, 0x83FB, 0xAEE2, 0x83FC, 0xAEE3,\t0x83FD, 0xAEE4, 0x83FE, 0xAEE5, 0x8441, 0xAEE6, 0x8442, 0xAEE7,\r\n\t0x8443, 0xAEE9, 0x8444, 0xAEEA, 0x8445, 0xAEEC, 0x8446, 0xAEEE,\t0x8447, 0xAEEF, 0x8448, 0xAEF0, 0x8449, 0xAEF1, 0x844A, 0xAEF2,\r\n\t0x844B, 0xAEF3, 0x844C, 0xAEF5, 0x844D, 0xAEF6, 0x844E, 0xAEF7,\t0x844F, 0xAEF9, 0x8450, 0xAEFA, 0x8451, 0xAEFB, 0x8452, 0xAEFD,\r\n\t0x8453, 0xAEFE, 0x8454, 0xAEFF, 0x8455, 0xAF00, 0x8456, 0xAF01,\t0x8457, 0xAF02, 0x8458, 0xAF03, 0x8459, 0xAF04, 0x845A, 0xAF05,\r\n\t0x8461, 0xAF06, 0x8462, 0xAF09, 0x8463, 0xAF0A, 0x8464, 0xAF0B,\t0x8465, 0xAF0C, 0x8466, 0xAF0E, 0x8467, 0xAF0F, 0x8468, 0xAF11,\r\n\t0x8469, 0xAF12, 0x846A, 0xAF13, 0x846B, 0xAF14, 0x846C, 0xAF15,\t0x846D, 0xAF16, 0x846E, 0xAF17, 0x846F, 0xAF18, 0x8470, 0xAF19,\r\n\t0x8471, 0xAF1A, 0x8472, 0xAF1B, 0x8473, 0xAF1C, 0x8474, 0xAF1D,\t0x8475, 0xAF1E, 0x8476, 0xAF1F, 0x8477, 0xAF20, 0x8478, 0xAF21,\r\n\t0x8479, 0xAF22, 0x847A, 0xAF23, 0x8481, 0xAF24, 0x8482, 0xAF25,\t0x8483, 0xAF26, 0x8484, 0xAF27, 0x8485, 0xAF28, 0x8486, 0xAF29,\r\n\t0x8487, 0xAF2A, 0x8488, 0xAF2B, 0x8489, 0xAF2E, 0x848A, 0xAF2F,\t0x848B, 0xAF31, 0x848C, 0xAF33, 0x848D, 0xAF35, 0x848E, 0xAF36,\r\n\t0x848F, 0xAF37, 0x8490, 0xAF38, 0x8491, 0xAF39, 0x8492, 0xAF3A,\t0x8493, 0xAF3B, 0x8494, 0xAF3E, 0x8495, 0xAF40, 0x8496, 0xAF44,\r\n\t0x8497, 0xAF45, 0x8498, 0xAF46, 0x8499, 0xAF47, 0x849A, 0xAF4A,\t0x849B, 0xAF4B, 0x849C, 0xAF4C, 0x849D, 0xAF4D, 0x849E, 0xAF4E,\r\n\t0x849F, 0xAF4F, 0x84A0, 0xAF51, 0x84A1, 0xAF52, 0x84A2, 0xAF53,\t0x84A3, 0xAF54, 0x84A4, 0xAF55, 0x84A5, 0xAF56, 0x84A6, 0xAF57,\r\n\t0x84A7, 0xAF58, 0x84A8, 0xAF59, 0x84A9, 0xAF5A, 0x84AA, 0xAF5B,\t0x84AB, 0xAF5E, 0x84AC, 0xAF5F, 0x84AD, 0xAF60, 0x84AE, 0xAF61,\r\n\t0x84AF, 0xAF62, 0x84B0, 0xAF63, 0x84B1, 0xAF66, 0x84B2, 0xAF67,\t0x84B3, 0xAF68, 0x84B4, 0xAF69, 0x84B5, 0xAF6A, 0x84B6, 0xAF6B,\r\n\t0x84B7, 0xAF6C, 0x84B8, 0xAF6D, 0x84B9, 0xAF6E, 0x84BA, 0xAF6F,\t0x84BB, 0xAF70, 0x84BC, 0xAF71, 0x84BD, 0xAF72, 0x84BE, 0xAF73,\r\n\t0x84BF, 0xAF74, 0x84C0, 0xAF75, 0x84C1, 0xAF76, 0x84C2, 0xAF77,\t0x84C3, 0xAF78, 0x84C4, 0xAF7A, 0x84C5, 0xAF7B, 0x84C6, 0xAF7C,\r\n\t0x84C7, 0xAF7D, 0x84C8, 0xAF7E, 0x84C9, 0xAF7F, 0x84CA, 0xAF81,\t0x84CB, 0xAF82, 0x84CC, 0xAF83, 0x84CD, 0xAF85, 0x84CE, 0xAF86,\r\n\t0x84CF, 0xAF87, 0x84D0, 0xAF89, 0x84D1, 0xAF8A, 0x84D2, 0xAF8B,\t0x84D3, 0xAF8C, 0x84D4, 0xAF8D, 0x84D5, 0xAF8E, 0x84D6, 0xAF8F,\r\n\t0x84D7, 0xAF92, 0x84D8, 0xAF93, 0x84D9, 0xAF94, 0x84DA, 0xAF96,\t0x84DB, 0xAF97, 0x84DC, 0xAF98, 0x84DD, 0xAF99, 0x84DE, 0xAF9A,\r\n\t0x84DF, 0xAF9B, 0x84E0, 0xAF9D, 0x84E1, 0xAF9E, 0x84E2, 0xAF9F,\t0x84E3, 0xAFA0, 0x84E4, 0xAFA1, 0x84E5, 0xAFA2, 0x84E6, 0xAFA3,\r\n\t0x84E7, 0xAFA4, 0x84E8, 0xAFA5, 0x84E9, 0xAFA6, 0x84EA, 0xAFA7,\t0x84EB, 0xAFA8, 0x84EC, 0xAFA9, 0x84ED, 0xAFAA, 0x84EE, 0xAFAB,\r\n\t0x84EF, 0xAFAC, 0x84F0, 0xAFAD, 0x84F1, 0xAFAE, 0x84F2, 0xAFAF,\t0x84F3, 0xAFB0, 0x84F4, 0xAFB1, 0x84F5, 0xAFB2, 0x84F6, 0xAFB3,\r\n\t0x84F7, 0xAFB4, 0x84F8, 0xAFB5, 0x84F9, 0xAFB6, 0x84FA, 0xAFB7,\t0x84FB, 0xAFBA, 0x84FC, 0xAFBB, 0x84FD, 0xAFBD, 0x84FE, 0xAFBE,\r\n\t0x8541, 0xAFBF, 0x8542, 0xAFC1, 0x8543, 0xAFC2, 0x8544, 0xAFC3,\t0x8545, 0xAFC4, 0x8546, 0xAFC5, 0x8547, 0xAFC6, 0x8548, 0xAFCA,\r\n\t0x8549, 0xAFCC, 0x854A, 0xAFCF, 0x854B, 0xAFD0, 0x854C, 0xAFD1,\t0x854D, 0xAFD2, 0x854E, 0xAFD3, 0x854F, 0xAFD5, 0x8550, 0xAFD6,\r\n\t0x8551, 0xAFD7, 0x8552, 0xAFD8, 0x8553, 0xAFD9, 0x8554, 0xAFDA,\t0x8555, 0xAFDB, 0x8556, 0xAFDD, 0x8557, 0xAFDE, 0x8558, 0xAFDF,\r\n\t0x8559, 0xAFE0, 0x855A, 0xAFE1, 0x8561, 0xAFE2, 0x8562, 0xAFE3,\t0x8563, 0xAFE4, 0x8564, 0xAFE5, 0x8565, 0xAFE6, 0x8566, 0xAFE7,\r\n\t0x8567, 0xAFEA, 0x8568, 0xAFEB, 0x8569, 0xAFEC, 0x856A, 0xAFED,\t0x856B, 0xAFEE, 0x856C, 0xAFEF, 0x856D, 0xAFF2, 0x856E, 0xAFF3,\r\n\t0x856F, 0xAFF5, 0x8570, 0xAFF6, 0x8571, 0xAFF7, 0x8572, 0xAFF9,\t0x8573, 0xAFFA, 0x8574, 0xAFFB, 0x8575, 0xAFFC, 0x8576, 0xAFFD,\r\n\t0x8577, 0xAFFE, 0x8578, 0xAFFF, 0x8579, 0xB002, 0x857A, 0xB003,\t0x8581, 0xB005, 0x8582, 0xB006, 0x8583, 0xB007, 0x8584, 0xB008,\r\n\t0x8585, 0xB009, 0x8586, 0xB00A, 0x8587, 0xB00B, 0x8588, 0xB00D,\t0x8589, 0xB00E, 0x858A, 0xB00F, 0x858B, 0xB011, 0x858C, 0xB012,\r\n\t0x858D, 0xB013, 0x858E, 0xB015, 0x858F, 0xB016, 0x8590, 0xB017,\t0x8591, 0xB018, 0x8592, 0xB019, 0x8593, 0xB01A, 0x8594, 0xB01B,\r\n\t0x8595, 0xB01E, 0x8596, 0xB01F, 0x8597, 0xB020, 0x8598, 0xB021,\t0x8599, 0xB022, 0x859A, 0xB023, 0x859B, 0xB024, 0x859C, 0xB025,\r\n\t0x859D, 0xB026, 0x859E, 0xB027, 0x859F, 0xB029, 0x85A0, 0xB02A,\t0x85A1, 0xB02B, 0x85A2, 0xB02C, 0x85A3, 0xB02D, 0x85A4, 0xB02E,\r\n\t0x85A5, 0xB02F, 0x85A6, 0xB030, 0x85A7, 0xB031, 0x85A8, 0xB032,\t0x85A9, 0xB033, 0x85AA, 0xB034, 0x85AB, 0xB035, 0x85AC, 0xB036,\r\n\t0x85AD, 0xB037, 0x85AE, 0xB038, 0x85AF, 0xB039, 0x85B0, 0xB03A,\t0x85B1, 0xB03B, 0x85B2, 0xB03C, 0x85B3, 0xB03D, 0x85B4, 0xB03E,\r\n\t0x85B5, 0xB03F, 0x85B6, 0xB040, 0x85B7, 0xB041, 0x85B8, 0xB042,\t0x85B9, 0xB043, 0x85BA, 0xB046, 0x85BB, 0xB047, 0x85BC, 0xB049,\r\n\t0x85BD, 0xB04B, 0x85BE, 0xB04D, 0x85BF, 0xB04F, 0x85C0, 0xB050,\t0x85C1, 0xB051, 0x85C2, 0xB052, 0x85C3, 0xB056, 0x85C4, 0xB058,\r\n\t0x85C5, 0xB05A, 0x85C6, 0xB05B, 0x85C7, 0xB05C, 0x85C8, 0xB05E,\t0x85C9, 0xB05F, 0x85CA, 0xB060, 0x85CB, 0xB061, 0x85CC, 0xB062,\r\n\t0x85CD, 0xB063, 0x85CE, 0xB064, 0x85CF, 0xB065, 0x85D0, 0xB066,\t0x85D1, 0xB067, 0x85D2, 0xB068, 0x85D3, 0xB069, 0x85D4, 0xB06A,\r\n\t0x85D5, 0xB06B, 0x85D6, 0xB06C, 0x85D7, 0xB06D, 0x85D8, 0xB06E,\t0x85D9, 0xB06F, 0x85DA, 0xB070, 0x85DB, 0xB071, 0x85DC, 0xB072,\r\n\t0x85DD, 0xB073, 0x85DE, 0xB074, 0x85DF, 0xB075, 0x85E0, 0xB076,\t0x85E1, 0xB077, 0x85E2, 0xB078, 0x85E3, 0xB079, 0x85E4, 0xB07A,\r\n\t0x85E5, 0xB07B, 0x85E6, 0xB07E, 0x85E7, 0xB07F, 0x85E8, 0xB081,\t0x85E9, 0xB082, 0x85EA, 0xB083, 0x85EB, 0xB085, 0x85EC, 0xB086,\r\n\t0x85ED, 0xB087, 0x85EE, 0xB088, 0x85EF, 0xB089, 0x85F0, 0xB08A,\t0x85F1, 0xB08B, 0x85F2, 0xB08E, 0x85F3, 0xB090, 0x85F4, 0xB092,\r\n\t0x85F5, 0xB093, 0x85F6, 0xB094, 0x85F7, 0xB095, 0x85F8, 0xB096,\t0x85F9, 0xB097, 0x85FA, 0xB09B, 0x85FB, 0xB09D, 0x85FC, 0xB09E,\r\n\t0x85FD, 0xB0A3, 0x85FE, 0xB0A4, 0x8641, 0xB0A5, 0x8642, 0xB0A6,\t0x8643, 0xB0A7, 0x8644, 0xB0AA, 0x8645, 0xB0B0, 0x8646, 0xB0B2,\r\n\t0x8647, 0xB0B6, 0x8648, 0xB0B7, 0x8649, 0xB0B9, 0x864A, 0xB0BA,\t0x864B, 0xB0BB, 0x864C, 0xB0BD, 0x864D, 0xB0BE, 0x864E, 0xB0BF,\r\n\t0x864F, 0xB0C0, 0x8650, 0xB0C1, 0x8651, 0xB0C2, 0x8652, 0xB0C3,\t0x8653, 0xB0C6, 0x8654, 0xB0CA, 0x8655, 0xB0CB, 0x8656, 0xB0CC,\r\n\t0x8657, 0xB0CD, 0x8658, 0xB0CE, 0x8659, 0xB0CF, 0x865A, 0xB0D2,\t0x8661, 0xB0D3, 0x8662, 0xB0D5, 0x8663, 0xB0D6, 0x8664, 0xB0D7,\r\n\t0x8665, 0xB0D9, 0x8666, 0xB0DA, 0x8667, 0xB0DB, 0x8668, 0xB0DC,\t0x8669, 0xB0DD, 0x866A, 0xB0DE, 0x866B, 0xB0DF, 0x866C, 0xB0E1,\r\n\t0x866D, 0xB0E2, 0x866E, 0xB0E3, 0x866F, 0xB0E4, 0x8670, 0xB0E6,\t0x8671, 0xB0E7, 0x8672, 0xB0E8, 0x8673, 0xB0E9, 0x8674, 0xB0EA,\r\n\t0x8675, 0xB0EB, 0x8676, 0xB0EC, 0x8677, 0xB0ED, 0x8678, 0xB0EE,\t0x8679, 0xB0EF, 0x867A, 0xB0F0, 0x8681, 0xB0F1, 0x8682, 0xB0F2,\r\n\t0x8683, 0xB0F3, 0x8684, 0xB0F4, 0x8685, 0xB0F5, 0x8686, 0xB0F6,\t0x8687, 0xB0F7, 0x8688, 0xB0F8, 0x8689, 0xB0F9, 0x868A, 0xB0FA,\r\n\t0x868B, 0xB0FB, 0x868C, 0xB0FC, 0x868D, 0xB0FD, 0x868E, 0xB0FE,\t0x868F, 0xB0FF, 0x8690, 0xB100, 0x8691, 0xB101, 0x8692, 0xB102,\r\n\t0x8693, 0xB103, 0x8694, 0xB104, 0x8695, 0xB105, 0x8696, 0xB106,\t0x8697, 0xB107, 0x8698, 0xB10A, 0x8699, 0xB10D, 0x869A, 0xB10E,\r\n\t0x869B, 0xB10F, 0x869C, 0xB111, 0x869D, 0xB114, 0x869E, 0xB115,\t0x869F, 0xB116, 0x86A0, 0xB117, 0x86A1, 0xB11A, 0x86A2, 0xB11E,\r\n\t0x86A3, 0xB11F, 0x86A4, 0xB120, 0x86A5, 0xB121, 0x86A6, 0xB122,\t0x86A7, 0xB126, 0x86A8, 0xB127, 0x86A9, 0xB129, 0x86AA, 0xB12A,\r\n\t0x86AB, 0xB12B, 0x86AC, 0xB12D, 0x86AD, 0xB12E, 0x86AE, 0xB12F,\t0x86AF, 0xB130, 0x86B0, 0xB131, 0x86B1, 0xB132, 0x86B2, 0xB133,\r\n\t0x86B3, 0xB136, 0x86B4, 0xB13A, 0x86B5, 0xB13B, 0x86B6, 0xB13C,\t0x86B7, 0xB13D, 0x86B8, 0xB13E, 0x86B9, 0xB13F, 0x86BA, 0xB142,\r\n\t0x86BB, 0xB143, 0x86BC, 0xB145, 0x86BD, 0xB146, 0x86BE, 0xB147,\t0x86BF, 0xB149, 0x86C0, 0xB14A, 0x86C1, 0xB14B, 0x86C2, 0xB14C,\r\n\t0x86C3, 0xB14D, 0x86C4, 0xB14E, 0x86C5, 0xB14F, 0x86C6, 0xB152,\t0x86C7, 0xB153, 0x86C8, 0xB156, 0x86C9, 0xB157, 0x86CA, 0xB159,\r\n\t0x86CB, 0xB15A, 0x86CC, 0xB15B, 0x86CD, 0xB15D, 0x86CE, 0xB15E,\t0x86CF, 0xB15F, 0x86D0, 0xB161, 0x86D1, 0xB162, 0x86D2, 0xB163,\r\n\t0x86D3, 0xB164, 0x86D4, 0xB165, 0x86D5, 0xB166, 0x86D6, 0xB167,\t0x86D7, 0xB168, 0x86D8, 0xB169, 0x86D9, 0xB16A, 0x86DA, 0xB16B,\r\n\t0x86DB, 0xB16C, 0x86DC, 0xB16D, 0x86DD, 0xB16E, 0x86DE, 0xB16F,\t0x86DF, 0xB170, 0x86E0, 0xB171, 0x86E1, 0xB172, 0x86E2, 0xB173,\r\n\t0x86E3, 0xB174, 0x86E4, 0xB175, 0x86E5, 0xB176, 0x86E6, 0xB177,\t0x86E7, 0xB17A, 0x86E8, 0xB17B, 0x86E9, 0xB17D, 0x86EA, 0xB17E,\r\n\t0x86EB, 0xB17F, 0x86EC, 0xB181, 0x86ED, 0xB183, 0x86EE, 0xB184,\t0x86EF, 0xB185, 0x86F0, 0xB186, 0x86F1, 0xB187, 0x86F2, 0xB18A,\r\n\t0x86F3, 0xB18C, 0x86F4, 0xB18E, 0x86F5, 0xB18F, 0x86F6, 0xB190,\t0x86F7, 0xB191, 0x86F8, 0xB195, 0x86F9, 0xB196, 0x86FA, 0xB197,\r\n\t0x86FB, 0xB199, 0x86FC, 0xB19A, 0x86FD, 0xB19B, 0x86FE, 0xB19D,\t0x8741, 0xB19E, 0x8742, 0xB19F, 0x8743, 0xB1A0, 0x8744, 0xB1A1,\r\n\t0x8745, 0xB1A2, 0x8746, 0xB1A3, 0x8747, 0xB1A4, 0x8748, 0xB1A5,\t0x8749, 0xB1A6, 0x874A, 0xB1A7, 0x874B, 0xB1A9, 0x874C, 0xB1AA,\r\n\t0x874D, 0xB1AB, 0x874E, 0xB1AC, 0x874F, 0xB1AD, 0x8750, 0xB1AE,\t0x8751, 0xB1AF, 0x8752, 0xB1B0, 0x8753, 0xB1B1, 0x8754, 0xB1B2,\r\n\t0x8755, 0xB1B3, 0x8756, 0xB1B4, 0x8757, 0xB1B5, 0x8758, 0xB1B6,\t0x8759, 0xB1B7, 0x875A, 0xB1B8, 0x8761, 0xB1B9, 0x8762, 0xB1BA,\r\n\t0x8763, 0xB1BB, 0x8764, 0xB1BC, 0x8765, 0xB1BD, 0x8766, 0xB1BE,\t0x8767, 0xB1BF, 0x8768, 0xB1C0, 0x8769, 0xB1C1, 0x876A, 0xB1C2,\r\n\t0x876B, 0xB1C3, 0x876C, 0xB1C4, 0x876D, 0xB1C5, 0x876E, 0xB1C6,\t0x876F, 0xB1C7, 0x8770, 0xB1C8, 0x8771, 0xB1C9, 0x8772, 0xB1CA,\r\n\t0x8773, 0xB1CB, 0x8774, 0xB1CD, 0x8775, 0xB1CE, 0x8776, 0xB1CF,\t0x8777, 0xB1D1, 0x8778, 0xB1D2, 0x8779, 0xB1D3, 0x877A, 0xB1D5,\r\n\t0x8781, 0xB1D6, 0x8782, 0xB1D7, 0x8783, 0xB1D8, 0x8784, 0xB1D9,\t0x8785, 0xB1DA, 0x8786, 0xB1DB, 0x8787, 0xB1DE, 0x8788, 0xB1E0,\r\n\t0x8789, 0xB1E1, 0x878A, 0xB1E2, 0x878B, 0xB1E3, 0x878C, 0xB1E4,\t0x878D, 0xB1E5, 0x878E, 0xB1E6, 0x878F, 0xB1E7, 0x8790, 0xB1EA,\r\n\t0x8791, 0xB1EB, 0x8792, 0xB1ED, 0x8793, 0xB1EE, 0x8794, 0xB1EF,\t0x8795, 0xB1F1, 0x8796, 0xB1F2, 0x8797, 0xB1F3, 0x8798, 0xB1F4,\r\n\t0x8799, 0xB1F5, 0x879A, 0xB1F6, 0x879B, 0xB1F7, 0x879C, 0xB1F8,\t0x879D, 0xB1FA, 0x879E, 0xB1FC, 0x879F, 0xB1FE, 0x87A0, 0xB1FF,\r\n\t0x87A1, 0xB200, 0x87A2, 0xB201, 0x87A3, 0xB202, 0x87A4, 0xB203,\t0x87A5, 0xB206, 0x87A6, 0xB207, 0x87A7, 0xB209, 0x87A8, 0xB20A,\r\n\t0x87A9, 0xB20D, 0x87AA, 0xB20E, 0x87AB, 0xB20F, 0x87AC, 0xB210,\t0x87AD, 0xB211, 0x87AE, 0xB212, 0x87AF, 0xB213, 0x87B0, 0xB216,\r\n\t0x87B1, 0xB218, 0x87B2, 0xB21A, 0x87B3, 0xB21B, 0x87B4, 0xB21C,\t0x87B5, 0xB21D, 0x87B6, 0xB21E, 0x87B7, 0xB21F, 0x87B8, 0xB221,\r\n\t0x87B9, 0xB222, 0x87BA, 0xB223, 0x87BB, 0xB224, 0x87BC, 0xB225,\t0x87BD, 0xB226, 0x87BE, 0xB227, 0x87BF, 0xB228, 0x87C0, 0xB229,\r\n\t0x87C1, 0xB22A, 0x87C2, 0xB22B, 0x87C3, 0xB22C, 0x87C4, 0xB22D,\t0x87C5, 0xB22E, 0x87C6, 0xB22F, 0x87C7, 0xB230, 0x87C8, 0xB231,\r\n\t0x87C9, 0xB232, 0x87CA, 0xB233, 0x87CB, 0xB235, 0x87CC, 0xB236,\t0x87CD, 0xB237, 0x87CE, 0xB238, 0x87CF, 0xB239, 0x87D0, 0xB23A,\r\n\t0x87D1, 0xB23B, 0x87D2, 0xB23D, 0x87D3, 0xB23E, 0x87D4, 0xB23F,\t0x87D5, 0xB240, 0x87D6, 0xB241, 0x87D7, 0xB242, 0x87D8, 0xB243,\r\n\t0x87D9, 0xB244, 0x87DA, 0xB245, 0x87DB, 0xB246, 0x87DC, 0xB247,\t0x87DD, 0xB248, 0x87DE, 0xB249, 0x87DF, 0xB24A, 0x87E0, 0xB24B,\r\n\t0x87E1, 0xB24C, 0x87E2, 0xB24D, 0x87E3, 0xB24E, 0x87E4, 0xB24F,\t0x87E5, 0xB250, 0x87E6, 0xB251, 0x87E7, 0xB252, 0x87E8, 0xB253,\r\n\t0x87E9, 0xB254, 0x87EA, 0xB255, 0x87EB, 0xB256, 0x87EC, 0xB257,\t0x87ED, 0xB259, 0x87EE, 0xB25A, 0x87EF, 0xB25B, 0x87F0, 0xB25D,\r\n\t0x87F1, 0xB25E, 0x87F2, 0xB25F, 0x87F3, 0xB261, 0x87F4, 0xB262,\t0x87F5, 0xB263, 0x87F6, 0xB264, 0x87F7, 0xB265, 0x87F8, 0xB266,\r\n\t0x87F9, 0xB267, 0x87FA, 0xB26A, 0x87FB, 0xB26B, 0x87FC, 0xB26C,\t0x87FD, 0xB26D, 0x87FE, 0xB26E, 0x8841, 0xB26F, 0x8842, 0xB270,\r\n\t0x8843, 0xB271, 0x8844, 0xB272, 0x8845, 0xB273, 0x8846, 0xB276,\t0x8847, 0xB277, 0x8848, 0xB278, 0x8849, 0xB279, 0x884A, 0xB27A,\r\n\t0x884B, 0xB27B, 0x884C, 0xB27D, 0x884D, 0xB27E, 0x884E, 0xB27F,\t0x884F, 0xB280, 0x8850, 0xB281, 0x8851, 0xB282, 0x8852, 0xB283,\r\n\t0x8853, 0xB286, 0x8854, 0xB287, 0x8855, 0xB288, 0x8856, 0xB28A,\t0x8857, 0xB28B, 0x8858, 0xB28C, 0x8859, 0xB28D, 0x885A, 0xB28E,\r\n\t0x8861, 0xB28F, 0x8862, 0xB292, 0x8863, 0xB293, 0x8864, 0xB295,\t0x8865, 0xB296, 0x8866, 0xB297, 0x8867, 0xB29B, 0x8868, 0xB29C,\r\n\t0x8869, 0xB29D, 0x886A, 0xB29E, 0x886B, 0xB29F, 0x886C, 0xB2A2,\t0x886D, 0xB2A4, 0x886E, 0xB2A7, 0x886F, 0xB2A8, 0x8870, 0xB2A9,\r\n\t0x8871, 0xB2AB, 0x8872, 0xB2AD, 0x8873, 0xB2AE, 0x8874, 0xB2AF,\t0x8875, 0xB2B1, 0x8876, 0xB2B2, 0x8877, 0xB2B3, 0x8878, 0xB2B5,\r\n\t0x8879, 0xB2B6, 0x887A, 0xB2B7, 0x8881, 0xB2B8, 0x8882, 0xB2B9,\t0x8883, 0xB2BA, 0x8884, 0xB2BB, 0x8885, 0xB2BC, 0x8886, 0xB2BD,\r\n\t0x8887, 0xB2BE, 0x8888, 0xB2BF, 0x8889, 0xB2C0, 0x888A, 0xB2C1,\t0x888B, 0xB2C2, 0x888C, 0xB2C3, 0x888D, 0xB2C4, 0x888E, 0xB2C5,\r\n\t0x888F, 0xB2C6, 0x8890, 0xB2C7, 0x8891, 0xB2CA, 0x8892, 0xB2CB,\t0x8893, 0xB2CD, 0x8894, 0xB2CE, 0x8895, 0xB2CF, 0x8896, 0xB2D1,\r\n\t0x8897, 0xB2D3, 0x8898, 0xB2D4, 0x8899, 0xB2D5, 0x889A, 0xB2D6,\t0x889B, 0xB2D7, 0x889C, 0xB2DA, 0x889D, 0xB2DC, 0x889E, 0xB2DE,\r\n\t0x889F, 0xB2DF, 0x88A0, 0xB2E0, 0x88A1, 0xB2E1, 0x88A2, 0xB2E3,\t0x88A3, 0xB2E7, 0x88A4, 0xB2E9, 0x88A5, 0xB2EA, 0x88A6, 0xB2F0,\r\n\t0x88A7, 0xB2F1, 0x88A8, 0xB2F2, 0x88A9, 0xB2F6, 0x88AA, 0xB2FC,\t0x88AB, 0xB2FD, 0x88AC, 0xB2FE, 0x88AD, 0xB302, 0x88AE, 0xB303,\r\n\t0x88AF, 0xB305, 0x88B0, 0xB306, 0x88B1, 0xB307, 0x88B2, 0xB309,\t0x88B3, 0xB30A, 0x88B4, 0xB30B, 0x88B5, 0xB30C, 0x88B6, 0xB30D,\r\n\t0x88B7, 0xB30E, 0x88B8, 0xB30F, 0x88B9, 0xB312, 0x88BA, 0xB316,\t0x88BB, 0xB317, 0x88BC, 0xB318, 0x88BD, 0xB319, 0x88BE, 0xB31A,\r\n\t0x88BF, 0xB31B, 0x88C0, 0xB31D, 0x88C1, 0xB31E, 0x88C2, 0xB31F,\t0x88C3, 0xB320, 0x88C4, 0xB321, 0x88C5, 0xB322, 0x88C6, 0xB323,\r\n\t0x88C7, 0xB324, 0x88C8, 0xB325, 0x88C9, 0xB326, 0x88CA, 0xB327,\t0x88CB, 0xB328, 0x88CC, 0xB329, 0x88CD, 0xB32A, 0x88CE, 0xB32B,\r\n\t0x88CF, 0xB32C, 0x88D0, 0xB32D, 0x88D1, 0xB32E, 0x88D2, 0xB32F,\t0x88D3, 0xB330, 0x88D4, 0xB331, 0x88D5, 0xB332, 0x88D6, 0xB333,\r\n\t0x88D7, 0xB334, 0x88D8, 0xB335, 0x88D9, 0xB336, 0x88DA, 0xB337,\t0x88DB, 0xB338, 0x88DC, 0xB339, 0x88DD, 0xB33A, 0x88DE, 0xB33B,\r\n\t0x88DF, 0xB33C, 0x88E0, 0xB33D, 0x88E1, 0xB33E, 0x88E2, 0xB33F,\t0x88E3, 0xB340, 0x88E4, 0xB341, 0x88E5, 0xB342, 0x88E6, 0xB343,\r\n\t0x88E7, 0xB344, 0x88E8, 0xB345, 0x88E9, 0xB346, 0x88EA, 0xB347,\t0x88EB, 0xB348, 0x88EC, 0xB349, 0x88ED, 0xB34A, 0x88EE, 0xB34B,\r\n\t0x88EF, 0xB34C, 0x88F0, 0xB34D, 0x88F1, 0xB34E, 0x88F2, 0xB34F,\t0x88F3, 0xB350, 0x88F4, 0xB351, 0x88F5, 0xB352, 0x88F6, 0xB353,\r\n\t0x88F7, 0xB357, 0x88F8, 0xB359, 0x88F9, 0xB35A, 0x88FA, 0xB35D,\t0x88FB, 0xB360, 0x88FC, 0xB361, 0x88FD, 0xB362, 0x88FE, 0xB363,\r\n\t0x8941, 0xB366, 0x8942, 0xB368, 0x8943, 0xB36A, 0x8944, 0xB36C,\t0x8945, 0xB36D, 0x8946, 0xB36F, 0x8947, 0xB372, 0x8948, 0xB373,\r\n\t0x8949, 0xB375, 0x894A, 0xB376, 0x894B, 0xB377, 0x894C, 0xB379,\t0x894D, 0xB37A, 0x894E, 0xB37B, 0x894F, 0xB37C, 0x8950, 0xB37D,\r\n\t0x8951, 0xB37E, 0x8952, 0xB37F, 0x8953, 0xB382, 0x8954, 0xB386,\t0x8955, 0xB387, 0x8956, 0xB388, 0x8957, 0xB389, 0x8958, 0xB38A,\r\n\t0x8959, 0xB38B, 0x895A, 0xB38D, 0x8961, 0xB38E, 0x8962, 0xB38F,\t0x8963, 0xB391, 0x8964, 0xB392, 0x8965, 0xB393, 0x8966, 0xB395,\r\n\t0x8967, 0xB396, 0x8968, 0xB397, 0x8969, 0xB398, 0x896A, 0xB399,\t0x896B, 0xB39A, 0x896C, 0xB39B, 0x896D, 0xB39C, 0x896E, 0xB39D,\r\n\t0x896F, 0xB39E, 0x8970, 0xB39F, 0x8971, 0xB3A2, 0x8972, 0xB3A3,\t0x8973, 0xB3A4, 0x8974, 0xB3A5, 0x8975, 0xB3A6, 0x8976, 0xB3A7,\r\n\t0x8977, 0xB3A9, 0x8978, 0xB3AA, 0x8979, 0xB3AB, 0x897A, 0xB3AD,\t0x8981, 0xB3AE, 0x8982, 0xB3AF, 0x8983, 0xB3B0, 0x8984, 0xB3B1,\r\n\t0x8985, 0xB3B2, 0x8986, 0xB3B3, 0x8987, 0xB3B4, 0x8988, 0xB3B5,\t0x8989, 0xB3B6, 0x898A, 0xB3B7, 0x898B, 0xB3B8, 0x898C, 0xB3B9,\r\n\t0x898D, 0xB3BA, 0x898E, 0xB3BB, 0x898F, 0xB3BC, 0x8990, 0xB3BD,\t0x8991, 0xB3BE, 0x8992, 0xB3BF, 0x8993, 0xB3C0, 0x8994, 0xB3C1,\r\n\t0x8995, 0xB3C2, 0x8996, 0xB3C3, 0x8997, 0xB3C6, 0x8998, 0xB3C7,\t0x8999, 0xB3C9, 0x899A, 0xB3CA, 0x899B, 0xB3CD, 0x899C, 0xB3CF,\r\n\t0x899D, 0xB3D1, 0x899E, 0xB3D2, 0x899F, 0xB3D3, 0x89A0, 0xB3D6,\t0x89A1, 0xB3D8, 0x89A2, 0xB3DA, 0x89A3, 0xB3DC, 0x89A4, 0xB3DE,\r\n\t0x89A5, 0xB3DF, 0x89A6, 0xB3E1, 0x89A7, 0xB3E2, 0x89A8, 0xB3E3,\t0x89A9, 0xB3E5, 0x89AA, 0xB3E6, 0x89AB, 0xB3E7, 0x89AC, 0xB3E9,\r\n\t0x89AD, 0xB3EA, 0x89AE, 0xB3EB, 0x89AF, 0xB3EC, 0x89B0, 0xB3ED,\t0x89B1, 0xB3EE, 0x89B2, 0xB3EF, 0x89B3, 0xB3F0, 0x89B4, 0xB3F1,\r\n\t0x89B5, 0xB3F2, 0x89B6, 0xB3F3, 0x89B7, 0xB3F4, 0x89B8, 0xB3F5,\t0x89B9, 0xB3F6, 0x89BA, 0xB3F7, 0x89BB, 0xB3F8, 0x89BC, 0xB3F9,\r\n\t0x89BD, 0xB3FA, 0x89BE, 0xB3FB, 0x89BF, 0xB3FD, 0x89C0, 0xB3FE,\t0x89C1, 0xB3FF, 0x89C2, 0xB400, 0x89C3, 0xB401, 0x89C4, 0xB402,\r\n\t0x89C5, 0xB403, 0x89C6, 0xB404, 0x89C7, 0xB405, 0x89C8, 0xB406,\t0x89C9, 0xB407, 0x89CA, 0xB408, 0x89CB, 0xB409, 0x89CC, 0xB40A,\r\n\t0x89CD, 0xB40B, 0x89CE, 0xB40C, 0x89CF, 0xB40D, 0x89D0, 0xB40E,\t0x89D1, 0xB40F, 0x89D2, 0xB411, 0x89D3, 0xB412, 0x89D4, 0xB413,\r\n\t0x89D5, 0xB414, 0x89D6, 0xB415, 0x89D7, 0xB416, 0x89D8, 0xB417,\t0x89D9, 0xB419, 0x89DA, 0xB41A, 0x89DB, 0xB41B, 0x89DC, 0xB41D,\r\n\t0x89DD, 0xB41E, 0x89DE, 0xB41F, 0x89DF, 0xB421, 0x89E0, 0xB422,\t0x89E1, 0xB423, 0x89E2, 0xB424, 0x89E3, 0xB425, 0x89E4, 0xB426,\r\n\t0x89E5, 0xB427, 0x89E6, 0xB42A, 0x89E7, 0xB42C, 0x89E8, 0xB42D,\t0x89E9, 0xB42E, 0x89EA, 0xB42F, 0x89EB, 0xB430, 0x89EC, 0xB431,\r\n\t0x89ED, 0xB432, 0x89EE, 0xB433, 0x89EF, 0xB435, 0x89F0, 0xB436,\t0x89F1, 0xB437, 0x89F2, 0xB438, 0x89F3, 0xB439, 0x89F4, 0xB43A,\r\n\t0x89F5, 0xB43B, 0x89F6, 0xB43C, 0x89F7, 0xB43D, 0x89F8, 0xB43E,\t0x89F9, 0xB43F, 0x89FA, 0xB440, 0x89FB, 0xB441, 0x89FC, 0xB442,\r\n\t0x89FD, 0xB443, 0x89FE, 0xB444, 0x8A41, 0xB445, 0x8A42, 0xB446,\t0x8A43, 0xB447, 0x8A44, 0xB448, 0x8A45, 0xB449, 0x8A46, 0xB44A,\r\n\t0x8A47, 0xB44B, 0x8A48, 0xB44C, 0x8A49, 0xB44D, 0x8A4A, 0xB44E,\t0x8A4B, 0xB44F, 0x8A4C, 0xB452, 0x8A4D, 0xB453, 0x8A4E, 0xB455,\r\n\t0x8A4F, 0xB456, 0x8A50, 0xB457, 0x8A51, 0xB459, 0x8A52, 0xB45A,\t0x8A53, 0xB45B, 0x8A54, 0xB45C, 0x8A55, 0xB45D, 0x8A56, 0xB45E,\r\n\t0x8A57, 0xB45F, 0x8A58, 0xB462, 0x8A59, 0xB464, 0x8A5A, 0xB466,\t0x8A61, 0xB467, 0x8A62, 0xB468, 0x8A63, 0xB469, 0x8A64, 0xB46A,\r\n\t0x8A65, 0xB46B, 0x8A66, 0xB46D, 0x8A67, 0xB46E, 0x8A68, 0xB46F,\t0x8A69, 0xB470, 0x8A6A, 0xB471, 0x8A6B, 0xB472, 0x8A6C, 0xB473,\r\n\t0x8A6D, 0xB474, 0x8A6E, 0xB475, 0x8A6F, 0xB476, 0x8A70, 0xB477,\t0x8A71, 0xB478, 0x8A72, 0xB479, 0x8A73, 0xB47A, 0x8A74, 0xB47B,\r\n\t0x8A75, 0xB47C, 0x8A76, 0xB47D, 0x8A77, 0xB47E, 0x8A78, 0xB47F,\t0x8A79, 0xB481, 0x8A7A, 0xB482, 0x8A81, 0xB483, 0x8A82, 0xB484,\r\n\t0x8A83, 0xB485, 0x8A84, 0xB486, 0x8A85, 0xB487, 0x8A86, 0xB489,\t0x8A87, 0xB48A, 0x8A88, 0xB48B, 0x8A89, 0xB48C, 0x8A8A, 0xB48D,\r\n\t0x8A8B, 0xB48E, 0x8A8C, 0xB48F, 0x8A8D, 0xB490, 0x8A8E, 0xB491,\t0x8A8F, 0xB492, 0x8A90, 0xB493, 0x8A91, 0xB494, 0x8A92, 0xB495,\r\n\t0x8A93, 0xB496, 0x8A94, 0xB497, 0x8A95, 0xB498, 0x8A96, 0xB499,\t0x8A97, 0xB49A, 0x8A98, 0xB49B, 0x8A99, 0xB49C, 0x8A9A, 0xB49E,\r\n\t0x8A9B, 0xB49F, 0x8A9C, 0xB4A0, 0x8A9D, 0xB4A1, 0x8A9E, 0xB4A2,\t0x8A9F, 0xB4A3, 0x8AA0, 0xB4A5, 0x8AA1, 0xB4A6, 0x8AA2, 0xB4A7,\r\n\t0x8AA3, 0xB4A9, 0x8AA4, 0xB4AA, 0x8AA5, 0xB4AB, 0x8AA6, 0xB4AD,\t0x8AA7, 0xB4AE, 0x8AA8, 0xB4AF, 0x8AA9, 0xB4B0, 0x8AAA, 0xB4B1,\r\n\t0x8AAB, 0xB4B2, 0x8AAC, 0xB4B3, 0x8AAD, 0xB4B4, 0x8AAE, 0xB4B6,\t0x8AAF, 0xB4B8, 0x8AB0, 0xB4BA, 0x8AB1, 0xB4BB, 0x8AB2, 0xB4BC,\r\n\t0x8AB3, 0xB4BD, 0x8AB4, 0xB4BE, 0x8AB5, 0xB4BF, 0x8AB6, 0xB4C1,\t0x8AB7, 0xB4C2, 0x8AB8, 0xB4C3, 0x8AB9, 0xB4C5, 0x8ABA, 0xB4C6,\r\n\t0x8ABB, 0xB4C7, 0x8ABC, 0xB4C9, 0x8ABD, 0xB4CA, 0x8ABE, 0xB4CB,\t0x8ABF, 0xB4CC, 0x8AC0, 0xB4CD, 0x8AC1, 0xB4CE, 0x8AC2, 0xB4CF,\r\n\t0x8AC3, 0xB4D1, 0x8AC4, 0xB4D2, 0x8AC5, 0xB4D3, 0x8AC6, 0xB4D4,\t0x8AC7, 0xB4D6, 0x8AC8, 0xB4D7, 0x8AC9, 0xB4D8, 0x8ACA, 0xB4D9,\r\n\t0x8ACB, 0xB4DA, 0x8ACC, 0xB4DB, 0x8ACD, 0xB4DE, 0x8ACE, 0xB4DF,\t0x8ACF, 0xB4E1, 0x8AD0, 0xB4E2, 0x8AD1, 0xB4E5, 0x8AD2, 0xB4E7,\r\n\t0x8AD3, 0xB4E8, 0x8AD4, 0xB4E9, 0x8AD5, 0xB4EA, 0x8AD6, 0xB4EB,\t0x8AD7, 0xB4EE, 0x8AD8, 0xB4F0, 0x8AD9, 0xB4F2, 0x8ADA, 0xB4F3,\r\n\t0x8ADB, 0xB4F4, 0x8ADC, 0xB4F5, 0x8ADD, 0xB4F6, 0x8ADE, 0xB4F7,\t0x8ADF, 0xB4F9, 0x8AE0, 0xB4FA, 0x8AE1, 0xB4FB, 0x8AE2, 0xB4FC,\r\n\t0x8AE3, 0xB4FD, 0x8AE4, 0xB4FE, 0x8AE5, 0xB4FF, 0x8AE6, 0xB500,\t0x8AE7, 0xB501, 0x8AE8, 0xB502, 0x8AE9, 0xB503, 0x8AEA, 0xB504,\r\n\t0x8AEB, 0xB505, 0x8AEC, 0xB506, 0x8AED, 0xB507, 0x8AEE, 0xB508,\t0x8AEF, 0xB509, 0x8AF0, 0xB50A, 0x8AF1, 0xB50B, 0x8AF2, 0xB50C,\r\n\t0x8AF3, 0xB50D, 0x8AF4, 0xB50E, 0x8AF5, 0xB50F, 0x8AF6, 0xB510,\t0x8AF7, 0xB511, 0x8AF8, 0xB512, 0x8AF9, 0xB513, 0x8AFA, 0xB516,\r\n\t0x8AFB, 0xB517, 0x8AFC, 0xB519, 0x8AFD, 0xB51A, 0x8AFE, 0xB51D,\t0x8B41, 0xB51E, 0x8B42, 0xB51F, 0x8B43, 0xB520, 0x8B44, 0xB521,\r\n\t0x8B45, 0xB522, 0x8B46, 0xB523, 0x8B47, 0xB526, 0x8B48, 0xB52B,\t0x8B49, 0xB52C, 0x8B4A, 0xB52D, 0x8B4B, 0xB52E, 0x8B4C, 0xB52F,\r\n\t0x8B4D, 0xB532, 0x8B4E, 0xB533, 0x8B4F, 0xB535, 0x8B50, 0xB536,\t0x8B51, 0xB537, 0x8B52, 0xB539, 0x8B53, 0xB53A, 0x8B54, 0xB53B,\r\n\t0x8B55, 0xB53C, 0x8B56, 0xB53D, 0x8B57, 0xB53E, 0x8B58, 0xB53F,\t0x8B59, 0xB542, 0x8B5A, 0xB546, 0x8B61, 0xB547, 0x8B62, 0xB548,\r\n\t0x8B63, 0xB549, 0x8B64, 0xB54A, 0x8B65, 0xB54E, 0x8B66, 0xB54F,\t0x8B67, 0xB551, 0x8B68, 0xB552, 0x8B69, 0xB553, 0x8B6A, 0xB555,\r\n\t0x8B6B, 0xB556, 0x8B6C, 0xB557, 0x8B6D, 0xB558, 0x8B6E, 0xB559,\t0x8B6F, 0xB55A, 0x8B70, 0xB55B, 0x8B71, 0xB55E, 0x8B72, 0xB562,\r\n\t0x8B73, 0xB563, 0x8B74, 0xB564, 0x8B75, 0xB565, 0x8B76, 0xB566,\t0x8B77, 0xB567, 0x8B78, 0xB568, 0x8B79, 0xB569, 0x8B7A, 0xB56A,\r\n\t0x8B81, 0xB56B, 0x8B82, 0xB56C, 0x8B83, 0xB56D, 0x8B84, 0xB56E,\t0x8B85, 0xB56F, 0x8B86, 0xB570, 0x8B87, 0xB571, 0x8B88, 0xB572,\r\n\t0x8B89, 0xB573, 0x8B8A, 0xB574, 0x8B8B, 0xB575, 0x8B8C, 0xB576,\t0x8B8D, 0xB577, 0x8B8E, 0xB578, 0x8B8F, 0xB579, 0x8B90, 0xB57A,\r\n\t0x8B91, 0xB57B, 0x8B92, 0xB57C, 0x8B93, 0xB57D, 0x8B94, 0xB57E,\t0x8B95, 0xB57F, 0x8B96, 0xB580, 0x8B97, 0xB581, 0x8B98, 0xB582,\r\n\t0x8B99, 0xB583, 0x8B9A, 0xB584, 0x8B9B, 0xB585, 0x8B9C, 0xB586,\t0x8B9D, 0xB587, 0x8B9E, 0xB588, 0x8B9F, 0xB589, 0x8BA0, 0xB58A,\r\n\t0x8BA1, 0xB58B, 0x8BA2, 0xB58C, 0x8BA3, 0xB58D, 0x8BA4, 0xB58E,\t0x8BA5, 0xB58F, 0x8BA6, 0xB590, 0x8BA7, 0xB591, 0x8BA8, 0xB592,\r\n\t0x8BA9, 0xB593, 0x8BAA, 0xB594, 0x8BAB, 0xB595, 0x8BAC, 0xB596,\t0x8BAD, 0xB597, 0x8BAE, 0xB598, 0x8BAF, 0xB599, 0x8BB0, 0xB59A,\r\n\t0x8BB1, 0xB59B, 0x8BB2, 0xB59C, 0x8BB3, 0xB59D, 0x8BB4, 0xB59E,\t0x8BB5, 0xB59F, 0x8BB6, 0xB5A2, 0x8BB7, 0xB5A3, 0x8BB8, 0xB5A5,\r\n\t0x8BB9, 0xB5A6, 0x8BBA, 0xB5A7, 0x8BBB, 0xB5A9, 0x8BBC, 0xB5AC,\t0x8BBD, 0xB5AD, 0x8BBE, 0xB5AE, 0x8BBF, 0xB5AF, 0x8BC0, 0xB5B2,\r\n\t0x8BC1, 0xB5B6, 0x8BC2, 0xB5B7, 0x8BC3, 0xB5B8, 0x8BC4, 0xB5B9,\t0x8BC5, 0xB5BA, 0x8BC6, 0xB5BE, 0x8BC7, 0xB5BF, 0x8BC8, 0xB5C1,\r\n\t0x8BC9, 0xB5C2, 0x8BCA, 0xB5C3, 0x8BCB, 0xB5C5, 0x8BCC, 0xB5C6,\t0x8BCD, 0xB5C7, 0x8BCE, 0xB5C8, 0x8BCF, 0xB5C9, 0x8BD0, 0xB5CA,\r\n\t0x8BD1, 0xB5CB, 0x8BD2, 0xB5CE, 0x8BD3, 0xB5D2, 0x8BD4, 0xB5D3,\t0x8BD5, 0xB5D4, 0x8BD6, 0xB5D5, 0x8BD7, 0xB5D6, 0x8BD8, 0xB5D7,\r\n\t0x8BD9, 0xB5D9, 0x8BDA, 0xB5DA, 0x8BDB, 0xB5DB, 0x8BDC, 0xB5DC,\t0x8BDD, 0xB5DD, 0x8BDE, 0xB5DE, 0x8BDF, 0xB5DF, 0x8BE0, 0xB5E0,\r\n\t0x8BE1, 0xB5E1, 0x8BE2, 0xB5E2, 0x8BE3, 0xB5E3, 0x8BE4, 0xB5E4,\t0x8BE5, 0xB5E5, 0x8BE6, 0xB5E6, 0x8BE7, 0xB5E7, 0x8BE8, 0xB5E8,\r\n\t0x8BE9, 0xB5E9, 0x8BEA, 0xB5EA, 0x8BEB, 0xB5EB, 0x8BEC, 0xB5ED,\t0x8BED, 0xB5EE, 0x8BEE, 0xB5EF, 0x8BEF, 0xB5F0, 0x8BF0, 0xB5F1,\r\n\t0x8BF1, 0xB5F2, 0x8BF2, 0xB5F3, 0x8BF3, 0xB5F4, 0x8BF4, 0xB5F5,\t0x8BF5, 0xB5F6, 0x8BF6, 0xB5F7, 0x8BF7, 0xB5F8, 0x8BF8, 0xB5F9,\r\n\t0x8BF9, 0xB5FA, 0x8BFA, 0xB5FB, 0x8BFB, 0xB5FC, 0x8BFC, 0xB5FD,\t0x8BFD, 0xB5FE, 0x8BFE, 0xB5FF, 0x8C41, 0xB600, 0x8C42, 0xB601,\r\n\t0x8C43, 0xB602, 0x8C44, 0xB603, 0x8C45, 0xB604, 0x8C46, 0xB605,\t0x8C47, 0xB606, 0x8C48, 0xB607, 0x8C49, 0xB608, 0x8C4A, 0xB609,\r\n\t0x8C4B, 0xB60A, 0x8C4C, 0xB60B, 0x8C4D, 0xB60C, 0x8C4E, 0xB60D,\t0x8C4F, 0xB60E, 0x8C50, 0xB60F, 0x8C51, 0xB612, 0x8C52, 0xB613,\r\n\t0x8C53, 0xB615, 0x8C54, 0xB616, 0x8C55, 0xB617, 0x8C56, 0xB619,\t0x8C57, 0xB61A, 0x8C58, 0xB61B, 0x8C59, 0xB61C, 0x8C5A, 0xB61D,\r\n\t0x8C61, 0xB61E, 0x8C62, 0xB61F, 0x8C63, 0xB620, 0x8C64, 0xB621,\t0x8C65, 0xB622, 0x8C66, 0xB623, 0x8C67, 0xB624, 0x8C68, 0xB626,\r\n\t0x8C69, 0xB627, 0x8C6A, 0xB628, 0x8C6B, 0xB629, 0x8C6C, 0xB62A,\t0x8C6D, 0xB62B, 0x8C6E, 0xB62D, 0x8C6F, 0xB62E, 0x8C70, 0xB62F,\r\n\t0x8C71, 0xB630, 0x8C72, 0xB631, 0x8C73, 0xB632, 0x8C74, 0xB633,\t0x8C75, 0xB635, 0x8C76, 0xB636, 0x8C77, 0xB637, 0x8C78, 0xB638,\r\n\t0x8C79, 0xB639, 0x8C7A, 0xB63A, 0x8C81, 0xB63B, 0x8C82, 0xB63C,\t0x8C83, 0xB63D, 0x8C84, 0xB63E, 0x8C85, 0xB63F, 0x8C86, 0xB640,\r\n\t0x8C87, 0xB641, 0x8C88, 0xB642, 0x8C89, 0xB643, 0x8C8A, 0xB644,\t0x8C8B, 0xB645, 0x8C8C, 0xB646, 0x8C8D, 0xB647, 0x8C8E, 0xB649,\r\n\t0x8C8F, 0xB64A, 0x8C90, 0xB64B, 0x8C91, 0xB64C, 0x8C92, 0xB64D,\t0x8C93, 0xB64E, 0x8C94, 0xB64F, 0x8C95, 0xB650, 0x8C96, 0xB651,\r\n\t0x8C97, 0xB652, 0x8C98, 0xB653, 0x8C99, 0xB654, 0x8C9A, 0xB655,\t0x8C9B, 0xB656, 0x8C9C, 0xB657, 0x8C9D, 0xB658, 0x8C9E, 0xB659,\r\n\t0x8C9F, 0xB65A, 0x8CA0, 0xB65B, 0x8CA1, 0xB65C, 0x8CA2, 0xB65D,\t0x8CA3, 0xB65E, 0x8CA4, 0xB65F, 0x8CA5, 0xB660, 0x8CA6, 0xB661,\r\n\t0x8CA7, 0xB662, 0x8CA8, 0xB663, 0x8CA9, 0xB665, 0x8CAA, 0xB666,\t0x8CAB, 0xB667, 0x8CAC, 0xB669, 0x8CAD, 0xB66A, 0x8CAE, 0xB66B,\r\n\t0x8CAF, 0xB66C, 0x8CB0, 0xB66D, 0x8CB1, 0xB66E, 0x8CB2, 0xB66F,\t0x8CB3, 0xB670, 0x8CB4, 0xB671, 0x8CB5, 0xB672, 0x8CB6, 0xB673,\r\n\t0x8CB7, 0xB674, 0x8CB8, 0xB675, 0x8CB9, 0xB676, 0x8CBA, 0xB677,\t0x8CBB, 0xB678, 0x8CBC, 0xB679, 0x8CBD, 0xB67A, 0x8CBE, 0xB67B,\r\n\t0x8CBF, 0xB67C, 0x8CC0, 0xB67D, 0x8CC1, 0xB67E, 0x8CC2, 0xB67F,\t0x8CC3, 0xB680, 0x8CC4, 0xB681, 0x8CC5, 0xB682, 0x8CC6, 0xB683,\r\n\t0x8CC7, 0xB684, 0x8CC8, 0xB685, 0x8CC9, 0xB686, 0x8CCA, 0xB687,\t0x8CCB, 0xB688, 0x8CCC, 0xB689, 0x8CCD, 0xB68A, 0x8CCE, 0xB68B,\r\n\t0x8CCF, 0xB68C, 0x8CD0, 0xB68D, 0x8CD1, 0xB68E, 0x8CD2, 0xB68F,\t0x8CD3, 0xB690, 0x8CD4, 0xB691, 0x8CD5, 0xB692, 0x8CD6, 0xB693,\r\n\t0x8CD7, 0xB694, 0x8CD8, 0xB695, 0x8CD9, 0xB696, 0x8CDA, 0xB697,\t0x8CDB, 0xB698, 0x8CDC, 0xB699, 0x8CDD, 0xB69A, 0x8CDE, 0xB69B,\r\n\t0x8CDF, 0xB69E, 0x8CE0, 0xB69F, 0x8CE1, 0xB6A1, 0x8CE2, 0xB6A2,\t0x8CE3, 0xB6A3, 0x8CE4, 0xB6A5, 0x8CE5, 0xB6A6, 0x8CE6, 0xB6A7,\r\n\t0x8CE7, 0xB6A8, 0x8CE8, 0xB6A9, 0x8CE9, 0xB6AA, 0x8CEA, 0xB6AD,\t0x8CEB, 0xB6AE, 0x8CEC, 0xB6AF, 0x8CED, 0xB6B0, 0x8CEE, 0xB6B2,\r\n\t0x8CEF, 0xB6B3, 0x8CF0, 0xB6B4, 0x8CF1, 0xB6B5, 0x8CF2, 0xB6B6,\t0x8CF3, 0xB6B7, 0x8CF4, 0xB6B8, 0x8CF5, 0xB6B9, 0x8CF6, 0xB6BA,\r\n\t0x8CF7, 0xB6BB, 0x8CF8, 0xB6BC, 0x8CF9, 0xB6BD, 0x8CFA, 0xB6BE,\t0x8CFB, 0xB6BF, 0x8CFC, 0xB6C0, 0x8CFD, 0xB6C1, 0x8CFE, 0xB6C2,\r\n\t0x8D41, 0xB6C3, 0x8D42, 0xB6C4, 0x8D43, 0xB6C5, 0x8D44, 0xB6C6,\t0x8D45, 0xB6C7, 0x8D46, 0xB6C8, 0x8D47, 0xB6C9, 0x8D48, 0xB6CA,\r\n\t0x8D49, 0xB6CB, 0x8D4A, 0xB6CC, 0x8D4B, 0xB6CD, 0x8D4C, 0xB6CE,\t0x8D4D, 0xB6CF, 0x8D4E, 0xB6D0, 0x8D4F, 0xB6D1, 0x8D50, 0xB6D2,\r\n\t0x8D51, 0xB6D3, 0x8D52, 0xB6D5, 0x8D53, 0xB6D6, 0x8D54, 0xB6D7,\t0x8D55, 0xB6D8, 0x8D56, 0xB6D9, 0x8D57, 0xB6DA, 0x8D58, 0xB6DB,\r\n\t0x8D59, 0xB6DC, 0x8D5A, 0xB6DD, 0x8D61, 0xB6DE, 0x8D62, 0xB6DF,\t0x8D63, 0xB6E0, 0x8D64, 0xB6E1, 0x8D65, 0xB6E2, 0x8D66, 0xB6E3,\r\n\t0x8D67, 0xB6E4, 0x8D68, 0xB6E5, 0x8D69, 0xB6E6, 0x8D6A, 0xB6E7,\t0x8D6B, 0xB6E8, 0x8D6C, 0xB6E9, 0x8D6D, 0xB6EA, 0x8D6E, 0xB6EB,\r\n\t0x8D6F, 0xB6EC, 0x8D70, 0xB6ED, 0x8D71, 0xB6EE, 0x8D72, 0xB6EF,\t0x8D73, 0xB6F1, 0x8D74, 0xB6F2, 0x8D75, 0xB6F3, 0x8D76, 0xB6F5,\r\n\t0x8D77, 0xB6F6, 0x8D78, 0xB6F7, 0x8D79, 0xB6F9, 0x8D7A, 0xB6FA,\t0x8D81, 0xB6FB, 0x8D82, 0xB6FC, 0x8D83, 0xB6FD, 0x8D84, 0xB6FE,\r\n\t0x8D85, 0xB6FF, 0x8D86, 0xB702, 0x8D87, 0xB703, 0x8D88, 0xB704,\t0x8D89, 0xB706, 0x8D8A, 0xB707, 0x8D8B, 0xB708, 0x8D8C, 0xB709,\r\n\t0x8D8D, 0xB70A, 0x8D8E, 0xB70B, 0x8D8F, 0xB70C, 0x8D90, 0xB70D,\t0x8D91, 0xB70E, 0x8D92, 0xB70F, 0x8D93, 0xB710, 0x8D94, 0xB711,\r\n\t0x8D95, 0xB712, 0x8D96, 0xB713, 0x8D97, 0xB714, 0x8D98, 0xB715,\t0x8D99, 0xB716, 0x8D9A, 0xB717, 0x8D9B, 0xB718, 0x8D9C, 0xB719,\r\n\t0x8D9D, 0xB71A, 0x8D9E, 0xB71B, 0x8D9F, 0xB71C, 0x8DA0, 0xB71D,\t0x8DA1, 0xB71E, 0x8DA2, 0xB71F, 0x8DA3, 0xB720, 0x8DA4, 0xB721,\r\n\t0x8DA5, 0xB722, 0x8DA6, 0xB723, 0x8DA7, 0xB724, 0x8DA8, 0xB725,\t0x8DA9, 0xB726, 0x8DAA, 0xB727, 0x8DAB, 0xB72A, 0x8DAC, 0xB72B,\r\n\t0x8DAD, 0xB72D, 0x8DAE, 0xB72E, 0x8DAF, 0xB731, 0x8DB0, 0xB732,\t0x8DB1, 0xB733, 0x8DB2, 0xB734, 0x8DB3, 0xB735, 0x8DB4, 0xB736,\r\n\t0x8DB5, 0xB737, 0x8DB6, 0xB73A, 0x8DB7, 0xB73C, 0x8DB8, 0xB73D,\t0x8DB9, 0xB73E, 0x8DBA, 0xB73F, 0x8DBB, 0xB740, 0x8DBC, 0xB741,\r\n\t0x8DBD, 0xB742, 0x8DBE, 0xB743, 0x8DBF, 0xB745, 0x8DC0, 0xB746,\t0x8DC1, 0xB747, 0x8DC2, 0xB749, 0x8DC3, 0xB74A, 0x8DC4, 0xB74B,\r\n\t0x8DC5, 0xB74D, 0x8DC6, 0xB74E, 0x8DC7, 0xB74F, 0x8DC8, 0xB750,\t0x8DC9, 0xB751, 0x8DCA, 0xB752, 0x8DCB, 0xB753, 0x8DCC, 0xB756,\r\n\t0x8DCD, 0xB757, 0x8DCE, 0xB758, 0x8DCF, 0xB759, 0x8DD0, 0xB75A,\t0x8DD1, 0xB75B, 0x8DD2, 0xB75C, 0x8DD3, 0xB75D, 0x8DD4, 0xB75E,\r\n\t0x8DD5, 0xB75F, 0x8DD6, 0xB761, 0x8DD7, 0xB762, 0x8DD8, 0xB763,\t0x8DD9, 0xB765, 0x8DDA, 0xB766, 0x8DDB, 0xB767, 0x8DDC, 0xB769,\r\n\t0x8DDD, 0xB76A, 0x8DDE, 0xB76B, 0x8DDF, 0xB76C, 0x8DE0, 0xB76D,\t0x8DE1, 0xB76E, 0x8DE2, 0xB76F, 0x8DE3, 0xB772, 0x8DE4, 0xB774,\r\n\t0x8DE5, 0xB776, 0x8DE6, 0xB777, 0x8DE7, 0xB778, 0x8DE8, 0xB779,\t0x8DE9, 0xB77A, 0x8DEA, 0xB77B, 0x8DEB, 0xB77E, 0x8DEC, 0xB77F,\r\n\t0x8DED, 0xB781, 0x8DEE, 0xB782, 0x8DEF, 0xB783, 0x8DF0, 0xB785,\t0x8DF1, 0xB786, 0x8DF2, 0xB787, 0x8DF3, 0xB788, 0x8DF4, 0xB789,\r\n\t0x8DF5, 0xB78A, 0x8DF6, 0xB78B, 0x8DF7, 0xB78E, 0x8DF8, 0xB793,\t0x8DF9, 0xB794, 0x8DFA, 0xB795, 0x8DFB, 0xB79A, 0x8DFC, 0xB79B,\r\n\t0x8DFD, 0xB79D, 0x8DFE, 0xB79E, 0x8E41, 0xB79F, 0x8E42, 0xB7A1,\t0x8E43, 0xB7A2, 0x8E44, 0xB7A3, 0x8E45, 0xB7A4, 0x8E46, 0xB7A5,\r\n\t0x8E47, 0xB7A6, 0x8E48, 0xB7A7, 0x8E49, 0xB7AA, 0x8E4A, 0xB7AE,\t0x8E4B, 0xB7AF, 0x8E4C, 0xB7B0, 0x8E4D, 0xB7B1, 0x8E4E, 0xB7B2,\r\n\t0x8E4F, 0xB7B3, 0x8E50, 0xB7B6, 0x8E51, 0xB7B7, 0x8E52, 0xB7B9,\t0x8E53, 0xB7BA, 0x8E54, 0xB7BB, 0x8E55, 0xB7BC, 0x8E56, 0xB7BD,\r\n\t0x8E57, 0xB7BE, 0x8E58, 0xB7BF, 0x8E59, 0xB7C0, 0x8E5A, 0xB7C1,\t0x8E61, 0xB7C2, 0x8E62, 0xB7C3, 0x8E63, 0xB7C4, 0x8E64, 0xB7C5,\r\n\t0x8E65, 0xB7C6, 0x8E66, 0xB7C8, 0x8E67, 0xB7CA, 0x8E68, 0xB7CB,\t0x8E69, 0xB7CC, 0x8E6A, 0xB7CD, 0x8E6B, 0xB7CE, 0x8E6C, 0xB7CF,\r\n\t0x8E6D, 0xB7D0, 0x8E6E, 0xB7D1, 0x8E6F, 0xB7D2, 0x8E70, 0xB7D3,\t0x8E71, 0xB7D4, 0x8E72, 0xB7D5, 0x8E73, 0xB7D6, 0x8E74, 0xB7D7,\r\n\t0x8E75, 0xB7D8, 0x8E76, 0xB7D9, 0x8E77, 0xB7DA, 0x8E78, 0xB7DB,\t0x8E79, 0xB7DC, 0x8E7A, 0xB7DD, 0x8E81, 0xB7DE, 0x8E82, 0xB7DF,\r\n\t0x8E83, 0xB7E0, 0x8E84, 0xB7E1, 0x8E85, 0xB7E2, 0x8E86, 0xB7E3,\t0x8E87, 0xB7E4, 0x8E88, 0xB7E5, 0x8E89, 0xB7E6, 0x8E8A, 0xB7E7,\r\n\t0x8E8B, 0xB7E8, 0x8E8C, 0xB7E9, 0x8E8D, 0xB7EA, 0x8E8E, 0xB7EB,\t0x8E8F, 0xB7EE, 0x8E90, 0xB7EF, 0x8E91, 0xB7F1, 0x8E92, 0xB7F2,\r\n\t0x8E93, 0xB7F3, 0x8E94, 0xB7F5, 0x8E95, 0xB7F6, 0x8E96, 0xB7F7,\t0x8E97, 0xB7F8, 0x8E98, 0xB7F9, 0x8E99, 0xB7FA, 0x8E9A, 0xB7FB,\r\n\t0x8E9B, 0xB7FE, 0x8E9C, 0xB802, 0x8E9D, 0xB803, 0x8E9E, 0xB804,\t0x8E9F, 0xB805, 0x8EA0, 0xB806, 0x8EA1, 0xB80A, 0x8EA2, 0xB80B,\r\n\t0x8EA3, 0xB80D, 0x8EA4, 0xB80E, 0x8EA5, 0xB80F, 0x8EA6, 0xB811,\t0x8EA7, 0xB812, 0x8EA8, 0xB813, 0x8EA9, 0xB814, 0x8EAA, 0xB815,\r\n\t0x8EAB, 0xB816, 0x8EAC, 0xB817, 0x8EAD, 0xB81A, 0x8EAE, 0xB81C,\t0x8EAF, 0xB81E, 0x8EB0, 0xB81F, 0x8EB1, 0xB820, 0x8EB2, 0xB821,\r\n\t0x8EB3, 0xB822, 0x8EB4, 0xB823, 0x8EB5, 0xB826, 0x8EB6, 0xB827,\t0x8EB7, 0xB829, 0x8EB8, 0xB82A, 0x8EB9, 0xB82B, 0x8EBA, 0xB82D,\r\n\t0x8EBB, 0xB82E, 0x8EBC, 0xB82F, 0x8EBD, 0xB830, 0x8EBE, 0xB831,\t0x8EBF, 0xB832, 0x8EC0, 0xB833, 0x8EC1, 0xB836, 0x8EC2, 0xB83A,\r\n\t0x8EC3, 0xB83B, 0x8EC4, 0xB83C, 0x8EC5, 0xB83D, 0x8EC6, 0xB83E,\t0x8EC7, 0xB83F, 0x8EC8, 0xB841, 0x8EC9, 0xB842, 0x8ECA, 0xB843,\r\n\t0x8ECB, 0xB845, 0x8ECC, 0xB846, 0x8ECD, 0xB847, 0x8ECE, 0xB848,\t0x8ECF, 0xB849, 0x8ED0, 0xB84A, 0x8ED1, 0xB84B, 0x8ED2, 0xB84C,\r\n\t0x8ED3, 0xB84D, 0x8ED4, 0xB84E, 0x8ED5, 0xB84F, 0x8ED6, 0xB850,\t0x8ED7, 0xB852, 0x8ED8, 0xB854, 0x8ED9, 0xB855, 0x8EDA, 0xB856,\r\n\t0x8EDB, 0xB857, 0x8EDC, 0xB858, 0x8EDD, 0xB859, 0x8EDE, 0xB85A,\t0x8EDF, 0xB85B, 0x8EE0, 0xB85E, 0x8EE1, 0xB85F, 0x8EE2, 0xB861,\r\n\t0x8EE3, 0xB862, 0x8EE4, 0xB863, 0x8EE5, 0xB865, 0x8EE6, 0xB866,\t0x8EE7, 0xB867, 0x8EE8, 0xB868, 0x8EE9, 0xB869, 0x8EEA, 0xB86A,\r\n\t0x8EEB, 0xB86B, 0x8EEC, 0xB86E, 0x8EED, 0xB870, 0x8EEE, 0xB872,\t0x8EEF, 0xB873, 0x8EF0, 0xB874, 0x8EF1, 0xB875, 0x8EF2, 0xB876,\r\n\t0x8EF3, 0xB877, 0x8EF4, 0xB879, 0x8EF5, 0xB87A, 0x8EF6, 0xB87B,\t0x8EF7, 0xB87D, 0x8EF8, 0xB87E, 0x8EF9, 0xB87F, 0x8EFA, 0xB880,\r\n\t0x8EFB, 0xB881, 0x8EFC, 0xB882, 0x8EFD, 0xB883, 0x8EFE, 0xB884,\t0x8F41, 0xB885, 0x8F42, 0xB886, 0x8F43, 0xB887, 0x8F44, 0xB888,\r\n\t0x8F45, 0xB889, 0x8F46, 0xB88A, 0x8F47, 0xB88B, 0x8F48, 0xB88C,\t0x8F49, 0xB88E, 0x8F4A, 0xB88F, 0x8F4B, 0xB890, 0x8F4C, 0xB891,\r\n\t0x8F4D, 0xB892, 0x8F4E, 0xB893, 0x8F4F, 0xB894, 0x8F50, 0xB895,\t0x8F51, 0xB896, 0x8F52, 0xB897, 0x8F53, 0xB898, 0x8F54, 0xB899,\r\n\t0x8F55, 0xB89A, 0x8F56, 0xB89B, 0x8F57, 0xB89C, 0x8F58, 0xB89D,\t0x8F59, 0xB89E, 0x8F5A, 0xB89F, 0x8F61, 0xB8A0, 0x8F62, 0xB8A1,\r\n\t0x8F63, 0xB8A2, 0x8F64, 0xB8A3, 0x8F65, 0xB8A4, 0x8F66, 0xB8A5,\t0x8F67, 0xB8A6, 0x8F68, 0xB8A7, 0x8F69, 0xB8A9, 0x8F6A, 0xB8AA,\r\n\t0x8F6B, 0xB8AB, 0x8F6C, 0xB8AC, 0x8F6D, 0xB8AD, 0x8F6E, 0xB8AE,\t0x8F6F, 0xB8AF, 0x8F70, 0xB8B1, 0x8F71, 0xB8B2, 0x8F72, 0xB8B3,\r\n\t0x8F73, 0xB8B5, 0x8F74, 0xB8B6, 0x8F75, 0xB8B7, 0x8F76, 0xB8B9,\t0x8F77, 0xB8BA, 0x8F78, 0xB8BB, 0x8F79, 0xB8BC, 0x8F7A, 0xB8BD,\r\n\t0x8F81, 0xB8BE, 0x8F82, 0xB8BF, 0x8F83, 0xB8C2, 0x8F84, 0xB8C4,\t0x8F85, 0xB8C6, 0x8F86, 0xB8C7, 0x8F87, 0xB8C8, 0x8F88, 0xB8C9,\r\n\t0x8F89, 0xB8CA, 0x8F8A, 0xB8CB, 0x8F8B, 0xB8CD, 0x8F8C, 0xB8CE,\t0x8F8D, 0xB8CF, 0x8F8E, 0xB8D1, 0x8F8F, 0xB8D2, 0x8F90, 0xB8D3,\r\n\t0x8F91, 0xB8D5, 0x8F92, 0xB8D6, 0x8F93, 0xB8D7, 0x8F94, 0xB8D8,\t0x8F95, 0xB8D9, 0x8F96, 0xB8DA, 0x8F97, 0xB8DB, 0x8F98, 0xB8DC,\r\n\t0x8F99, 0xB8DE, 0x8F9A, 0xB8E0, 0x8F9B, 0xB8E2, 0x8F9C, 0xB8E3,\t0x8F9D, 0xB8E4, 0x8F9E, 0xB8E5, 0x8F9F, 0xB8E6, 0x8FA0, 0xB8E7,\r\n\t0x8FA1, 0xB8EA, 0x8FA2, 0xB8EB, 0x8FA3, 0xB8ED, 0x8FA4, 0xB8EE,\t0x8FA5, 0xB8EF, 0x8FA6, 0xB8F1, 0x8FA7, 0xB8F2, 0x8FA8, 0xB8F3,\r\n\t0x8FA9, 0xB8F4, 0x8FAA, 0xB8F5, 0x8FAB, 0xB8F6, 0x8FAC, 0xB8F7,\t0x8FAD, 0xB8FA, 0x8FAE, 0xB8FC, 0x8FAF, 0xB8FE, 0x8FB0, 0xB8FF,\r\n\t0x8FB1, 0xB900, 0x8FB2, 0xB901, 0x8FB3, 0xB902, 0x8FB4, 0xB903,\t0x8FB5, 0xB905, 0x8FB6, 0xB906, 0x8FB7, 0xB907, 0x8FB8, 0xB908,\r\n\t0x8FB9, 0xB909, 0x8FBA, 0xB90A, 0x8FBB, 0xB90B, 0x8FBC, 0xB90C,\t0x8FBD, 0xB90D, 0x8FBE, 0xB90E, 0x8FBF, 0xB90F, 0x8FC0, 0xB910,\r\n\t0x8FC1, 0xB911, 0x8FC2, 0xB912, 0x8FC3, 0xB913, 0x8FC4, 0xB914,\t0x8FC5, 0xB915, 0x8FC6, 0xB916, 0x8FC7, 0xB917, 0x8FC8, 0xB919,\r\n\t0x8FC9, 0xB91A, 0x8FCA, 0xB91B, 0x8FCB, 0xB91C, 0x8FCC, 0xB91D,\t0x8FCD, 0xB91E, 0x8FCE, 0xB91F, 0x8FCF, 0xB921, 0x8FD0, 0xB922,\r\n\t0x8FD1, 0xB923, 0x8FD2, 0xB924, 0x8FD3, 0xB925, 0x8FD4, 0xB926,\t0x8FD5, 0xB927, 0x8FD6, 0xB928, 0x8FD7, 0xB929, 0x8FD8, 0xB92A,\r\n\t0x8FD9, 0xB92B, 0x8FDA, 0xB92C, 0x8FDB, 0xB92D, 0x8FDC, 0xB92E,\t0x8FDD, 0xB92F, 0x8FDE, 0xB930, 0x8FDF, 0xB931, 0x8FE0, 0xB932,\r\n\t0x8FE1, 0xB933, 0x8FE2, 0xB934, 0x8FE3, 0xB935, 0x8FE4, 0xB936,\t0x8FE5, 0xB937, 0x8FE6, 0xB938, 0x8FE7, 0xB939, 0x8FE8, 0xB93A,\r\n\t0x8FE9, 0xB93B, 0x8FEA, 0xB93E, 0x8FEB, 0xB93F, 0x8FEC, 0xB941,\t0x8FED, 0xB942, 0x8FEE, 0xB943, 0x8FEF, 0xB945, 0x8FF0, 0xB946,\r\n\t0x8FF1, 0xB947, 0x8FF2, 0xB948, 0x8FF3, 0xB949, 0x8FF4, 0xB94A,\t0x8FF5, 0xB94B, 0x8FF6, 0xB94D, 0x8FF7, 0xB94E, 0x8FF8, 0xB950,\r\n\t0x8FF9, 0xB952, 0x8FFA, 0xB953, 0x8FFB, 0xB954, 0x8FFC, 0xB955,\t0x8FFD, 0xB956, 0x8FFE, 0xB957, 0x9041, 0xB95A, 0x9042, 0xB95B,\r\n\t0x9043, 0xB95D, 0x9044, 0xB95E, 0x9045, 0xB95F, 0x9046, 0xB961,\t0x9047, 0xB962, 0x9048, 0xB963, 0x9049, 0xB964, 0x904A, 0xB965,\r\n\t0x904B, 0xB966, 0x904C, 0xB967, 0x904D, 0xB96A, 0x904E, 0xB96C,\t0x904F, 0xB96E, 0x9050, 0xB96F, 0x9051, 0xB970, 0x9052, 0xB971,\r\n\t0x9053, 0xB972, 0x9054, 0xB973, 0x9055, 0xB976, 0x9056, 0xB977,\t0x9057, 0xB979, 0x9058, 0xB97A, 0x9059, 0xB97B, 0x905A, 0xB97D,\r\n\t0x9061, 0xB97E, 0x9062, 0xB97F, 0x9063, 0xB980, 0x9064, 0xB981,\t0x9065, 0xB982, 0x9066, 0xB983, 0x9067, 0xB986, 0x9068, 0xB988,\r\n\t0x9069, 0xB98B, 0x906A, 0xB98C, 0x906B, 0xB98F, 0x906C, 0xB990,\t0x906D, 0xB991, 0x906E, 0xB992, 0x906F, 0xB993, 0x9070, 0xB994,\r\n\t0x9071, 0xB995, 0x9072, 0xB996, 0x9073, 0xB997, 0x9074, 0xB998,\t0x9075, 0xB999, 0x9076, 0xB99A, 0x9077, 0xB99B, 0x9078, 0xB99C,\r\n\t0x9079, 0xB99D, 0x907A, 0xB99E, 0x9081, 0xB99F, 0x9082, 0xB9A0,\t0x9083, 0xB9A1, 0x9084, 0xB9A2, 0x9085, 0xB9A3, 0x9086, 0xB9A4,\r\n\t0x9087, 0xB9A5, 0x9088, 0xB9A6, 0x9089, 0xB9A7, 0x908A, 0xB9A8,\t0x908B, 0xB9A9, 0x908C, 0xB9AA, 0x908D, 0xB9AB, 0x908E, 0xB9AE,\r\n\t0x908F, 0xB9AF, 0x9090, 0xB9B1, 0x9091, 0xB9B2, 0x9092, 0xB9B3,\t0x9093, 0xB9B5, 0x9094, 0xB9B6, 0x9095, 0xB9B7, 0x9096, 0xB9B8,\r\n\t0x9097, 0xB9B9, 0x9098, 0xB9BA, 0x9099, 0xB9BB, 0x909A, 0xB9BE,\t0x909B, 0xB9C0, 0x909C, 0xB9C2, 0x909D, 0xB9C3, 0x909E, 0xB9C4,\r\n\t0x909F, 0xB9C5, 0x90A0, 0xB9C6, 0x90A1, 0xB9C7, 0x90A2, 0xB9CA,\t0x90A3, 0xB9CB, 0x90A4, 0xB9CD, 0x90A5, 0xB9D3, 0x90A6, 0xB9D4,\r\n\t0x90A7, 0xB9D5, 0x90A8, 0xB9D6, 0x90A9, 0xB9D7, 0x90AA, 0xB9DA,\t0x90AB, 0xB9DC, 0x90AC, 0xB9DF, 0x90AD, 0xB9E0, 0x90AE, 0xB9E2,\r\n\t0x90AF, 0xB9E6, 0x90B0, 0xB9E7, 0x90B1, 0xB9E9, 0x90B2, 0xB9EA,\t0x90B3, 0xB9EB, 0x90B4, 0xB9ED, 0x90B5, 0xB9EE, 0x90B6, 0xB9EF,\r\n\t0x90B7, 0xB9F0, 0x90B8, 0xB9F1, 0x90B9, 0xB9F2, 0x90BA, 0xB9F3,\t0x90BB, 0xB9F6, 0x90BC, 0xB9FB, 0x90BD, 0xB9FC, 0x90BE, 0xB9FD,\r\n\t0x90BF, 0xB9FE, 0x90C0, 0xB9FF, 0x90C1, 0xBA02, 0x90C2, 0xBA03,\t0x90C3, 0xBA04, 0x90C4, 0xBA05, 0x90C5, 0xBA06, 0x90C6, 0xBA07,\r\n\t0x90C7, 0xBA09, 0x90C8, 0xBA0A, 0x90C9, 0xBA0B, 0x90CA, 0xBA0C,\t0x90CB, 0xBA0D, 0x90CC, 0xBA0E, 0x90CD, 0xBA0F, 0x90CE, 0xBA10,\r\n\t0x90CF, 0xBA11, 0x90D0, 0xBA12, 0x90D1, 0xBA13, 0x90D2, 0xBA14,\t0x90D3, 0xBA16, 0x90D4, 0xBA17, 0x90D5, 0xBA18, 0x90D6, 0xBA19,\r\n\t0x90D7, 0xBA1A, 0x90D8, 0xBA1B, 0x90D9, 0xBA1C, 0x90DA, 0xBA1D,\t0x90DB, 0xBA1E, 0x90DC, 0xBA1F, 0x90DD, 0xBA20, 0x90DE, 0xBA21,\r\n\t0x90DF, 0xBA22, 0x90E0, 0xBA23, 0x90E1, 0xBA24, 0x90E2, 0xBA25,\t0x90E3, 0xBA26, 0x90E4, 0xBA27, 0x90E5, 0xBA28, 0x90E6, 0xBA29,\r\n\t0x90E7, 0xBA2A, 0x90E8, 0xBA2B, 0x90E9, 0xBA2C, 0x90EA, 0xBA2D,\t0x90EB, 0xBA2E, 0x90EC, 0xBA2F, 0x90ED, 0xBA30, 0x90EE, 0xBA31,\r\n\t0x90EF, 0xBA32, 0x90F0, 0xBA33, 0x90F1, 0xBA34, 0x90F2, 0xBA35,\t0x90F3, 0xBA36, 0x90F4, 0xBA37, 0x90F5, 0xBA3A, 0x90F6, 0xBA3B,\r\n\t0x90F7, 0xBA3D, 0x90F8, 0xBA3E, 0x90F9, 0xBA3F, 0x90FA, 0xBA41,\t0x90FB, 0xBA43, 0x90FC, 0xBA44, 0x90FD, 0xBA45, 0x90FE, 0xBA46,\r\n\t0x9141, 0xBA47, 0x9142, 0xBA4A, 0x9143, 0xBA4C, 0x9144, 0xBA4F,\t0x9145, 0xBA50, 0x9146, 0xBA51, 0x9147, 0xBA52, 0x9148, 0xBA56,\r\n\t0x9149, 0xBA57, 0x914A, 0xBA59, 0x914B, 0xBA5A, 0x914C, 0xBA5B,\t0x914D, 0xBA5D, 0x914E, 0xBA5E, 0x914F, 0xBA5F, 0x9150, 0xBA60,\r\n\t0x9151, 0xBA61, 0x9152, 0xBA62, 0x9153, 0xBA63, 0x9154, 0xBA66,\t0x9155, 0xBA6A, 0x9156, 0xBA6B, 0x9157, 0xBA6C, 0x9158, 0xBA6D,\r\n\t0x9159, 0xBA6E, 0x915A, 0xBA6F, 0x9161, 0xBA72, 0x9162, 0xBA73,\t0x9163, 0xBA75, 0x9164, 0xBA76, 0x9165, 0xBA77, 0x9166, 0xBA79,\r\n\t0x9167, 0xBA7A, 0x9168, 0xBA7B, 0x9169, 0xBA7C, 0x916A, 0xBA7D,\t0x916B, 0xBA7E, 0x916C, 0xBA7F, 0x916D, 0xBA80, 0x916E, 0xBA81,\r\n\t0x916F, 0xBA82, 0x9170, 0xBA86, 0x9171, 0xBA88, 0x9172, 0xBA89,\t0x9173, 0xBA8A, 0x9174, 0xBA8B, 0x9175, 0xBA8D, 0x9176, 0xBA8E,\r\n\t0x9177, 0xBA8F, 0x9178, 0xBA90, 0x9179, 0xBA91, 0x917A, 0xBA92,\t0x9181, 0xBA93, 0x9182, 0xBA94, 0x9183, 0xBA95, 0x9184, 0xBA96,\r\n\t0x9185, 0xBA97, 0x9186, 0xBA98, 0x9187, 0xBA99, 0x9188, 0xBA9A,\t0x9189, 0xBA9B, 0x918A, 0xBA9C, 0x918B, 0xBA9D, 0x918C, 0xBA9E,\r\n\t0x918D, 0xBA9F, 0x918E, 0xBAA0, 0x918F, 0xBAA1, 0x9190, 0xBAA2,\t0x9191, 0xBAA3, 0x9192, 0xBAA4, 0x9193, 0xBAA5, 0x9194, 0xBAA6,\r\n\t0x9195, 0xBAA7, 0x9196, 0xBAAA, 0x9197, 0xBAAD, 0x9198, 0xBAAE,\t0x9199, 0xBAAF, 0x919A, 0xBAB1, 0x919B, 0xBAB3, 0x919C, 0xBAB4,\r\n\t0x919D, 0xBAB5, 0x919E, 0xBAB6, 0x919F, 0xBAB7, 0x91A0, 0xBABA,\t0x91A1, 0xBABC, 0x91A2, 0xBABE, 0x91A3, 0xBABF, 0x91A4, 0xBAC0,\r\n\t0x91A5, 0xBAC1, 0x91A6, 0xBAC2, 0x91A7, 0xBAC3, 0x91A8, 0xBAC5,\t0x91A9, 0xBAC6, 0x91AA, 0xBAC7, 0x91AB, 0xBAC9, 0x91AC, 0xBACA,\r\n\t0x91AD, 0xBACB, 0x91AE, 0xBACC, 0x91AF, 0xBACD, 0x91B0, 0xBACE,\t0x91B1, 0xBACF, 0x91B2, 0xBAD0, 0x91B3, 0xBAD1, 0x91B4, 0xBAD2,\r\n\t0x91B5, 0xBAD3, 0x91B6, 0xBAD4, 0x91B7, 0xBAD5, 0x91B8, 0xBAD6,\t0x91B9, 0xBAD7, 0x91BA, 0xBADA, 0x91BB, 0xBADB, 0x91BC, 0xBADC,\r\n\t0x91BD, 0xBADD, 0x91BE, 0xBADE, 0x91BF, 0xBADF, 0x91C0, 0xBAE0,\t0x91C1, 0xBAE1, 0x91C2, 0xBAE2, 0x91C3, 0xBAE3, 0x91C4, 0xBAE4,\r\n\t0x91C5, 0xBAE5, 0x91C6, 0xBAE6, 0x91C7, 0xBAE7, 0x91C8, 0xBAE8,\t0x91C9, 0xBAE9, 0x91CA, 0xBAEA, 0x91CB, 0xBAEB, 0x91CC, 0xBAEC,\r\n\t0x91CD, 0xBAED, 0x91CE, 0xBAEE, 0x91CF, 0xBAEF, 0x91D0, 0xBAF0,\t0x91D1, 0xBAF1, 0x91D2, 0xBAF2, 0x91D3, 0xBAF3, 0x91D4, 0xBAF4,\r\n\t0x91D5, 0xBAF5, 0x91D6, 0xBAF6, 0x91D7, 0xBAF7, 0x91D8, 0xBAF8,\t0x91D9, 0xBAF9, 0x91DA, 0xBAFA, 0x91DB, 0xBAFB, 0x91DC, 0xBAFD,\r\n\t0x91DD, 0xBAFE, 0x91DE, 0xBAFF, 0x91DF, 0xBB01, 0x91E0, 0xBB02,\t0x91E1, 0xBB03, 0x91E2, 0xBB05, 0x91E3, 0xBB06, 0x91E4, 0xBB07,\r\n\t0x91E5, 0xBB08, 0x91E6, 0xBB09, 0x91E7, 0xBB0A, 0x91E8, 0xBB0B,\t0x91E9, 0xBB0C, 0x91EA, 0xBB0E, 0x91EB, 0xBB10, 0x91EC, 0xBB12,\r\n\t0x91ED, 0xBB13, 0x91EE, 0xBB14, 0x91EF, 0xBB15, 0x91F0, 0xBB16,\t0x91F1, 0xBB17, 0x91F2, 0xBB19, 0x91F3, 0xBB1A, 0x91F4, 0xBB1B,\r\n\t0x91F5, 0xBB1D, 0x91F6, 0xBB1E, 0x91F7, 0xBB1F, 0x91F8, 0xBB21,\t0x91F9, 0xBB22, 0x91FA, 0xBB23, 0x91FB, 0xBB24, 0x91FC, 0xBB25,\r\n\t0x91FD, 0xBB26, 0x91FE, 0xBB27, 0x9241, 0xBB28, 0x9242, 0xBB2A,\t0x9243, 0xBB2C, 0x9244, 0xBB2D, 0x9245, 0xBB2E, 0x9246, 0xBB2F,\r\n\t0x9247, 0xBB30, 0x9248, 0xBB31, 0x9249, 0xBB32, 0x924A, 0xBB33,\t0x924B, 0xBB37, 0x924C, 0xBB39, 0x924D, 0xBB3A, 0x924E, 0xBB3F,\r\n\t0x924F, 0xBB40, 0x9250, 0xBB41, 0x9251, 0xBB42, 0x9252, 0xBB43,\t0x9253, 0xBB46, 0x9254, 0xBB48, 0x9255, 0xBB4A, 0x9256, 0xBB4B,\r\n\t0x9257, 0xBB4C, 0x9258, 0xBB4E, 0x9259, 0xBB51, 0x925A, 0xBB52,\t0x9261, 0xBB53, 0x9262, 0xBB55, 0x9263, 0xBB56, 0x9264, 0xBB57,\r\n\t0x9265, 0xBB59, 0x9266, 0xBB5A, 0x9267, 0xBB5B, 0x9268, 0xBB5C,\t0x9269, 0xBB5D, 0x926A, 0xBB5E, 0x926B, 0xBB5F, 0x926C, 0xBB60,\r\n\t0x926D, 0xBB62, 0x926E, 0xBB64, 0x926F, 0xBB65, 0x9270, 0xBB66,\t0x9271, 0xBB67, 0x9272, 0xBB68, 0x9273, 0xBB69, 0x9274, 0xBB6A,\r\n\t0x9275, 0xBB6B, 0x9276, 0xBB6D, 0x9277, 0xBB6E, 0x9278, 0xBB6F,\t0x9279, 0xBB70, 0x927A, 0xBB71, 0x9281, 0xBB72, 0x9282, 0xBB73,\r\n\t0x9283, 0xBB74, 0x9284, 0xBB75, 0x9285, 0xBB76, 0x9286, 0xBB77,\t0x9287, 0xBB78, 0x9288, 0xBB79, 0x9289, 0xBB7A, 0x928A, 0xBB7B,\r\n\t0x928B, 0xBB7C, 0x928C, 0xBB7D, 0x928D, 0xBB7E, 0x928E, 0xBB7F,\t0x928F, 0xBB80, 0x9290, 0xBB81, 0x9291, 0xBB82, 0x9292, 0xBB83,\r\n\t0x9293, 0xBB84, 0x9294, 0xBB85, 0x9295, 0xBB86, 0x9296, 0xBB87,\t0x9297, 0xBB89, 0x9298, 0xBB8A, 0x9299, 0xBB8B, 0x929A, 0xBB8D,\r\n\t0x929B, 0xBB8E, 0x929C, 0xBB8F, 0x929D, 0xBB91, 0x929E, 0xBB92,\t0x929F, 0xBB93, 0x92A0, 0xBB94, 0x92A1, 0xBB95, 0x92A2, 0xBB96,\r\n\t0x92A3, 0xBB97, 0x92A4, 0xBB98, 0x92A5, 0xBB99, 0x92A6, 0xBB9A,\t0x92A7, 0xBB9B, 0x92A8, 0xBB9C, 0x92A9, 0xBB9D, 0x92AA, 0xBB9E,\r\n\t0x92AB, 0xBB9F, 0x92AC, 0xBBA0, 0x92AD, 0xBBA1, 0x92AE, 0xBBA2,\t0x92AF, 0xBBA3, 0x92B0, 0xBBA5, 0x92B1, 0xBBA6, 0x92B2, 0xBBA7,\r\n\t0x92B3, 0xBBA9, 0x92B4, 0xBBAA, 0x92B5, 0xBBAB, 0x92B6, 0xBBAD,\t0x92B7, 0xBBAE, 0x92B8, 0xBBAF, 0x92B9, 0xBBB0, 0x92BA, 0xBBB1,\r\n\t0x92BB, 0xBBB2, 0x92BC, 0xBBB3, 0x92BD, 0xBBB5, 0x92BE, 0xBBB6,\t0x92BF, 0xBBB8, 0x92C0, 0xBBB9, 0x92C1, 0xBBBA, 0x92C2, 0xBBBB,\r\n\t0x92C3, 0xBBBC, 0x92C4, 0xBBBD, 0x92C5, 0xBBBE, 0x92C6, 0xBBBF,\t0x92C7, 0xBBC1, 0x92C8, 0xBBC2, 0x92C9, 0xBBC3, 0x92CA, 0xBBC5,\r\n\t0x92CB, 0xBBC6, 0x92CC, 0xBBC7, 0x92CD, 0xBBC9, 0x92CE, 0xBBCA,\t0x92CF, 0xBBCB, 0x92D0, 0xBBCC, 0x92D1, 0xBBCD, 0x92D2, 0xBBCE,\r\n\t0x92D3, 0xBBCF, 0x92D4, 0xBBD1, 0x92D5, 0xBBD2, 0x92D6, 0xBBD4,\t0x92D7, 0xBBD5, 0x92D8, 0xBBD6, 0x92D9, 0xBBD7, 0x92DA, 0xBBD8,\r\n\t0x92DB, 0xBBD9, 0x92DC, 0xBBDA, 0x92DD, 0xBBDB, 0x92DE, 0xBBDC,\t0x92DF, 0xBBDD, 0x92E0, 0xBBDE, 0x92E1, 0xBBDF, 0x92E2, 0xBBE0,\r\n\t0x92E3, 0xBBE1, 0x92E4, 0xBBE2, 0x92E5, 0xBBE3, 0x92E6, 0xBBE4,\t0x92E7, 0xBBE5, 0x92E8, 0xBBE6, 0x92E9, 0xBBE7, 0x92EA, 0xBBE8,\r\n\t0x92EB, 0xBBE9, 0x92EC, 0xBBEA, 0x92ED, 0xBBEB, 0x92EE, 0xBBEC,\t0x92EF, 0xBBED, 0x92F0, 0xBBEE, 0x92F1, 0xBBEF, 0x92F2, 0xBBF0,\r\n\t0x92F3, 0xBBF1, 0x92F4, 0xBBF2, 0x92F5, 0xBBF3, 0x92F6, 0xBBF4,\t0x92F7, 0xBBF5, 0x92F8, 0xBBF6, 0x92F9, 0xBBF7, 0x92FA, 0xBBFA,\r\n\t0x92FB, 0xBBFB, 0x92FC, 0xBBFD, 0x92FD, 0xBBFE, 0x92FE, 0xBC01,\t0x9341, 0xBC03, 0x9342, 0xBC04, 0x9343, 0xBC05, 0x9344, 0xBC06,\r\n\t0x9345, 0xBC07, 0x9346, 0xBC0A, 0x9347, 0xBC0E, 0x9348, 0xBC10,\t0x9349, 0xBC12, 0x934A, 0xBC13, 0x934B, 0xBC19, 0x934C, 0xBC1A,\r\n\t0x934D, 0xBC20, 0x934E, 0xBC21, 0x934F, 0xBC22, 0x9350, 0xBC23,\t0x9351, 0xBC26, 0x9352, 0xBC28, 0x9353, 0xBC2A, 0x9354, 0xBC2B,\r\n\t0x9355, 0xBC2C, 0x9356, 0xBC2E, 0x9357, 0xBC2F, 0x9358, 0xBC32,\t0x9359, 0xBC33, 0x935A, 0xBC35, 0x9361, 0xBC36, 0x9362, 0xBC37,\r\n\t0x9363, 0xBC39, 0x9364, 0xBC3A, 0x9365, 0xBC3B, 0x9366, 0xBC3C,\t0x9367, 0xBC3D, 0x9368, 0xBC3E, 0x9369, 0xBC3F, 0x936A, 0xBC42,\r\n\t0x936B, 0xBC46, 0x936C, 0xBC47, 0x936D, 0xBC48, 0x936E, 0xBC4A,\t0x936F, 0xBC4B, 0x9370, 0xBC4E, 0x9371, 0xBC4F, 0x9372, 0xBC51,\r\n\t0x9373, 0xBC52, 0x9374, 0xBC53, 0x9375, 0xBC54, 0x9376, 0xBC55,\t0x9377, 0xBC56, 0x9378, 0xBC57, 0x9379, 0xBC58, 0x937A, 0xBC59,\r\n\t0x9381, 0xBC5A, 0x9382, 0xBC5B, 0x9383, 0xBC5C, 0x9384, 0xBC5E,\t0x9385, 0xBC5F, 0x9386, 0xBC60, 0x9387, 0xBC61, 0x9388, 0xBC62,\r\n\t0x9389, 0xBC63, 0x938A, 0xBC64, 0x938B, 0xBC65, 0x938C, 0xBC66,\t0x938D, 0xBC67, 0x938E, 0xBC68, 0x938F, 0xBC69, 0x9390, 0xBC6A,\r\n\t0x9391, 0xBC6B, 0x9392, 0xBC6C, 0x9393, 0xBC6D, 0x9394, 0xBC6E,\t0x9395, 0xBC6F, 0x9396, 0xBC70, 0x9397, 0xBC71, 0x9398, 0xBC72,\r\n\t0x9399, 0xBC73, 0x939A, 0xBC74, 0x939B, 0xBC75, 0x939C, 0xBC76,\t0x939D, 0xBC77, 0x939E, 0xBC78, 0x939F, 0xBC79, 0x93A0, 0xBC7A,\r\n\t0x93A1, 0xBC7B, 0x93A2, 0xBC7C, 0x93A3, 0xBC7D, 0x93A4, 0xBC7E,\t0x93A5, 0xBC7F, 0x93A6, 0xBC80, 0x93A7, 0xBC81, 0x93A8, 0xBC82,\r\n\t0x93A9, 0xBC83, 0x93AA, 0xBC86, 0x93AB, 0xBC87, 0x93AC, 0xBC89,\t0x93AD, 0xBC8A, 0x93AE, 0xBC8D, 0x93AF, 0xBC8F, 0x93B0, 0xBC90,\r\n\t0x93B1, 0xBC91, 0x93B2, 0xBC92, 0x93B3, 0xBC93, 0x93B4, 0xBC96,\t0x93B5, 0xBC98, 0x93B6, 0xBC9B, 0x93B7, 0xBC9C, 0x93B8, 0xBC9D,\r\n\t0x93B9, 0xBC9E, 0x93BA, 0xBC9F, 0x93BB, 0xBCA2, 0x93BC, 0xBCA3,\t0x93BD, 0xBCA5, 0x93BE, 0xBCA6, 0x93BF, 0xBCA9, 0x93C0, 0xBCAA,\r\n\t0x93C1, 0xBCAB, 0x93C2, 0xBCAC, 0x93C3, 0xBCAD, 0x93C4, 0xBCAE,\t0x93C5, 0xBCAF, 0x93C6, 0xBCB2, 0x93C7, 0xBCB6, 0x93C8, 0xBCB7,\r\n\t0x93C9, 0xBCB8, 0x93CA, 0xBCB9, 0x93CB, 0xBCBA, 0x93CC, 0xBCBB,\t0x93CD, 0xBCBE, 0x93CE, 0xBCBF, 0x93CF, 0xBCC1, 0x93D0, 0xBCC2,\r\n\t0x93D1, 0xBCC3, 0x93D2, 0xBCC5, 0x93D3, 0xBCC6, 0x93D4, 0xBCC7,\t0x93D5, 0xBCC8, 0x93D6, 0xBCC9, 0x93D7, 0xBCCA, 0x93D8, 0xBCCB,\r\n\t0x93D9, 0xBCCC, 0x93DA, 0xBCCE, 0x93DB, 0xBCD2, 0x93DC, 0xBCD3,\t0x93DD, 0xBCD4, 0x93DE, 0xBCD6, 0x93DF, 0xBCD7, 0x93E0, 0xBCD9,\r\n\t0x93E1, 0xBCDA, 0x93E2, 0xBCDB, 0x93E3, 0xBCDD, 0x93E4, 0xBCDE,\t0x93E5, 0xBCDF, 0x93E6, 0xBCE0, 0x93E7, 0xBCE1, 0x93E8, 0xBCE2,\r\n\t0x93E9, 0xBCE3, 0x93EA, 0xBCE4, 0x93EB, 0xBCE5, 0x93EC, 0xBCE6,\t0x93ED, 0xBCE7, 0x93EE, 0xBCE8, 0x93EF, 0xBCE9, 0x93F0, 0xBCEA,\r\n\t0x93F1, 0xBCEB, 0x93F2, 0xBCEC, 0x93F3, 0xBCED, 0x93F4, 0xBCEE,\t0x93F5, 0xBCEF, 0x93F6, 0xBCF0, 0x93F7, 0xBCF1, 0x93F8, 0xBCF2,\r\n\t0x93F9, 0xBCF3, 0x93FA, 0xBCF7, 0x93FB, 0xBCF9, 0x93FC, 0xBCFA,\t0x93FD, 0xBCFB, 0x93FE, 0xBCFD, 0x9441, 0xBCFE, 0x9442, 0xBCFF,\r\n\t0x9443, 0xBD00, 0x9444, 0xBD01, 0x9445, 0xBD02, 0x9446, 0xBD03,\t0x9447, 0xBD06, 0x9448, 0xBD08, 0x9449, 0xBD0A, 0x944A, 0xBD0B,\r\n\t0x944B, 0xBD0C, 0x944C, 0xBD0D, 0x944D, 0xBD0E, 0x944E, 0xBD0F,\t0x944F, 0xBD11, 0x9450, 0xBD12, 0x9451, 0xBD13, 0x9452, 0xBD15,\r\n\t0x9453, 0xBD16, 0x9454, 0xBD17, 0x9455, 0xBD18, 0x9456, 0xBD19,\t0x9457, 0xBD1A, 0x9458, 0xBD1B, 0x9459, 0xBD1C, 0x945A, 0xBD1D,\r\n\t0x9461, 0xBD1E, 0x9462, 0xBD1F, 0x9463, 0xBD20, 0x9464, 0xBD21,\t0x9465, 0xBD22, 0x9466, 0xBD23, 0x9467, 0xBD25, 0x9468, 0xBD26,\r\n\t0x9469, 0xBD27, 0x946A, 0xBD28, 0x946B, 0xBD29, 0x946C, 0xBD2A,\t0x946D, 0xBD2B, 0x946E, 0xBD2D, 0x946F, 0xBD2E, 0x9470, 0xBD2F,\r\n\t0x9471, 0xBD30, 0x9472, 0xBD31, 0x9473, 0xBD32, 0x9474, 0xBD33,\t0x9475, 0xBD34, 0x9476, 0xBD35, 0x9477, 0xBD36, 0x9478, 0xBD37,\r\n\t0x9479, 0xBD38, 0x947A, 0xBD39, 0x9481, 0xBD3A, 0x9482, 0xBD3B,\t0x9483, 0xBD3C, 0x9484, 0xBD3D, 0x9485, 0xBD3E, 0x9486, 0xBD3F,\r\n\t0x9487, 0xBD41, 0x9488, 0xBD42, 0x9489, 0xBD43, 0x948A, 0xBD44,\t0x948B, 0xBD45, 0x948C, 0xBD46, 0x948D, 0xBD47, 0x948E, 0xBD4A,\r\n\t0x948F, 0xBD4B, 0x9490, 0xBD4D, 0x9491, 0xBD4E, 0x9492, 0xBD4F,\t0x9493, 0xBD51, 0x9494, 0xBD52, 0x9495, 0xBD53, 0x9496, 0xBD54,\r\n\t0x9497, 0xBD55, 0x9498, 0xBD56, 0x9499, 0xBD57, 0x949A, 0xBD5A,\t0x949B, 0xBD5B, 0x949C, 0xBD5C, 0x949D, 0xBD5D, 0x949E, 0xBD5E,\r\n\t0x949F, 0xBD5F, 0x94A0, 0xBD60, 0x94A1, 0xBD61, 0x94A2, 0xBD62,\t0x94A3, 0xBD63, 0x94A4, 0xBD65, 0x94A5, 0xBD66, 0x94A6, 0xBD67,\r\n\t0x94A7, 0xBD69, 0x94A8, 0xBD6A, 0x94A9, 0xBD6B, 0x94AA, 0xBD6C,\t0x94AB, 0xBD6D, 0x94AC, 0xBD6E, 0x94AD, 0xBD6F, 0x94AE, 0xBD70,\r\n\t0x94AF, 0xBD71, 0x94B0, 0xBD72, 0x94B1, 0xBD73, 0x94B2, 0xBD74,\t0x94B3, 0xBD75, 0x94B4, 0xBD76, 0x94B5, 0xBD77, 0x94B6, 0xBD78,\r\n\t0x94B7, 0xBD79, 0x94B8, 0xBD7A, 0x94B9, 0xBD7B, 0x94BA, 0xBD7C,\t0x94BB, 0xBD7D, 0x94BC, 0xBD7E, 0x94BD, 0xBD7F, 0x94BE, 0xBD82,\r\n\t0x94BF, 0xBD83, 0x94C0, 0xBD85, 0x94C1, 0xBD86, 0x94C2, 0xBD8B,\t0x94C3, 0xBD8C, 0x94C4, 0xBD8D, 0x94C5, 0xBD8E, 0x94C6, 0xBD8F,\r\n\t0x94C7, 0xBD92, 0x94C8, 0xBD94, 0x94C9, 0xBD96, 0x94CA, 0xBD97,\t0x94CB, 0xBD98, 0x94CC, 0xBD9B, 0x94CD, 0xBD9D, 0x94CE, 0xBD9E,\r\n\t0x94CF, 0xBD9F, 0x94D0, 0xBDA0, 0x94D1, 0xBDA1, 0x94D2, 0xBDA2,\t0x94D3, 0xBDA3, 0x94D4, 0xBDA5, 0x94D5, 0xBDA6, 0x94D6, 0xBDA7,\r\n\t0x94D7, 0xBDA8, 0x94D8, 0xBDA9, 0x94D9, 0xBDAA, 0x94DA, 0xBDAB,\t0x94DB, 0xBDAC, 0x94DC, 0xBDAD, 0x94DD, 0xBDAE, 0x94DE, 0xBDAF,\r\n\t0x94DF, 0xBDB1, 0x94E0, 0xBDB2, 0x94E1, 0xBDB3, 0x94E2, 0xBDB4,\t0x94E3, 0xBDB5, 0x94E4, 0xBDB6, 0x94E5, 0xBDB7, 0x94E6, 0xBDB9,\r\n\t0x94E7, 0xBDBA, 0x94E8, 0xBDBB, 0x94E9, 0xBDBC, 0x94EA, 0xBDBD,\t0x94EB, 0xBDBE, 0x94EC, 0xBDBF, 0x94ED, 0xBDC0, 0x94EE, 0xBDC1,\r\n\t0x94EF, 0xBDC2, 0x94F0, 0xBDC3, 0x94F1, 0xBDC4, 0x94F2, 0xBDC5,\t0x94F3, 0xBDC6, 0x94F4, 0xBDC7, 0x94F5, 0xBDC8, 0x94F6, 0xBDC9,\r\n\t0x94F7, 0xBDCA, 0x94F8, 0xBDCB, 0x94F9, 0xBDCC, 0x94FA, 0xBDCD,\t0x94FB, 0xBDCE, 0x94FC, 0xBDCF, 0x94FD, 0xBDD0, 0x94FE, 0xBDD1,\r\n\t0x9541, 0xBDD2, 0x9542, 0xBDD3, 0x9543, 0xBDD6, 0x9544, 0xBDD7,\t0x9545, 0xBDD9, 0x9546, 0xBDDA, 0x9547, 0xBDDB, 0x9548, 0xBDDD,\r\n\t0x9549, 0xBDDE, 0x954A, 0xBDDF, 0x954B, 0xBDE0, 0x954C, 0xBDE1,\t0x954D, 0xBDE2, 0x954E, 0xBDE3, 0x954F, 0xBDE4, 0x9550, 0xBDE5,\r\n\t0x9551, 0xBDE6, 0x9552, 0xBDE7, 0x9553, 0xBDE8, 0x9554, 0xBDEA,\t0x9555, 0xBDEB, 0x9556, 0xBDEC, 0x9557, 0xBDED, 0x9558, 0xBDEE,\r\n\t0x9559, 0xBDEF, 0x955A, 0xBDF1, 0x9561, 0xBDF2, 0x9562, 0xBDF3,\t0x9563, 0xBDF5, 0x9564, 0xBDF6, 0x9565, 0xBDF7, 0x9566, 0xBDF9,\r\n\t0x9567, 0xBDFA, 0x9568, 0xBDFB, 0x9569, 0xBDFC, 0x956A, 0xBDFD,\t0x956B, 0xBDFE, 0x956C, 0xBDFF, 0x956D, 0xBE01, 0x956E, 0xBE02,\r\n\t0x956F, 0xBE04, 0x9570, 0xBE06, 0x9571, 0xBE07, 0x9572, 0xBE08,\t0x9573, 0xBE09, 0x9574, 0xBE0A, 0x9575, 0xBE0B, 0x9576, 0xBE0E,\r\n\t0x9577, 0xBE0F, 0x9578, 0xBE11, 0x9579, 0xBE12, 0x957A, 0xBE13,\t0x9581, 0xBE15, 0x9582, 0xBE16, 0x9583, 0xBE17, 0x9584, 0xBE18,\r\n\t0x9585, 0xBE19, 0x9586, 0xBE1A, 0x9587, 0xBE1B, 0x9588, 0xBE1E,\t0x9589, 0xBE20, 0x958A, 0xBE21, 0x958B, 0xBE22, 0x958C, 0xBE23,\r\n\t0x958D, 0xBE24, 0x958E, 0xBE25, 0x958F, 0xBE26, 0x9590, 0xBE27,\t0x9591, 0xBE28, 0x9592, 0xBE29, 0x9593, 0xBE2A, 0x9594, 0xBE2B,\r\n\t0x9595, 0xBE2C, 0x9596, 0xBE2D, 0x9597, 0xBE2E, 0x9598, 0xBE2F,\t0x9599, 0xBE30, 0x959A, 0xBE31, 0x959B, 0xBE32, 0x959C, 0xBE33,\r\n\t0x959D, 0xBE34, 0x959E, 0xBE35, 0x959F, 0xBE36, 0x95A0, 0xBE37,\t0x95A1, 0xBE38, 0x95A2, 0xBE39, 0x95A3, 0xBE3A, 0x95A4, 0xBE3B,\r\n\t0x95A5, 0xBE3C, 0x95A6, 0xBE3D, 0x95A7, 0xBE3E, 0x95A8, 0xBE3F,\t0x95A9, 0xBE40, 0x95AA, 0xBE41, 0x95AB, 0xBE42, 0x95AC, 0xBE43,\r\n\t0x95AD, 0xBE46, 0x95AE, 0xBE47, 0x95AF, 0xBE49, 0x95B0, 0xBE4A,\t0x95B1, 0xBE4B, 0x95B2, 0xBE4D, 0x95B3, 0xBE4F, 0x95B4, 0xBE50,\r\n\t0x95B5, 0xBE51, 0x95B6, 0xBE52, 0x95B7, 0xBE53, 0x95B8, 0xBE56,\t0x95B9, 0xBE58, 0x95BA, 0xBE5C, 0x95BB, 0xBE5D, 0x95BC, 0xBE5E,\r\n\t0x95BD, 0xBE5F, 0x95BE, 0xBE62, 0x95BF, 0xBE63, 0x95C0, 0xBE65,\t0x95C1, 0xBE66, 0x95C2, 0xBE67, 0x95C3, 0xBE69, 0x95C4, 0xBE6B,\r\n\t0x95C5, 0xBE6C, 0x95C6, 0xBE6D, 0x95C7, 0xBE6E, 0x95C8, 0xBE6F,\t0x95C9, 0xBE72, 0x95CA, 0xBE76, 0x95CB, 0xBE77, 0x95CC, 0xBE78,\r\n\t0x95CD, 0xBE79, 0x95CE, 0xBE7A, 0x95CF, 0xBE7E, 0x95D0, 0xBE7F,\t0x95D1, 0xBE81, 0x95D2, 0xBE82, 0x95D3, 0xBE83, 0x95D4, 0xBE85,\r\n\t0x95D5, 0xBE86, 0x95D6, 0xBE87, 0x95D7, 0xBE88, 0x95D8, 0xBE89,\t0x95D9, 0xBE8A, 0x95DA, 0xBE8B, 0x95DB, 0xBE8E, 0x95DC, 0xBE92,\r\n\t0x95DD, 0xBE93, 0x95DE, 0xBE94, 0x95DF, 0xBE95, 0x95E0, 0xBE96,\t0x95E1, 0xBE97, 0x95E2, 0xBE9A, 0x95E3, 0xBE9B, 0x95E4, 0xBE9C,\r\n\t0x95E5, 0xBE9D, 0x95E6, 0xBE9E, 0x95E7, 0xBE9F, 0x95E8, 0xBEA0,\t0x95E9, 0xBEA1, 0x95EA, 0xBEA2, 0x95EB, 0xBEA3, 0x95EC, 0xBEA4,\r\n\t0x95ED, 0xBEA5, 0x95EE, 0xBEA6, 0x95EF, 0xBEA7, 0x95F0, 0xBEA9,\t0x95F1, 0xBEAA, 0x95F2, 0xBEAB, 0x95F3, 0xBEAC, 0x95F4, 0xBEAD,\r\n\t0x95F5, 0xBEAE, 0x95F6, 0xBEAF, 0x95F7, 0xBEB0, 0x95F8, 0xBEB1,\t0x95F9, 0xBEB2, 0x95FA, 0xBEB3, 0x95FB, 0xBEB4, 0x95FC, 0xBEB5,\r\n\t0x95FD, 0xBEB6, 0x95FE, 0xBEB7, 0x9641, 0xBEB8, 0x9642, 0xBEB9,\t0x9643, 0xBEBA, 0x9644, 0xBEBB, 0x9645, 0xBEBC, 0x9646, 0xBEBD,\r\n\t0x9647, 0xBEBE, 0x9648, 0xBEBF, 0x9649, 0xBEC0, 0x964A, 0xBEC1,\t0x964B, 0xBEC2, 0x964C, 0xBEC3, 0x964D, 0xBEC4, 0x964E, 0xBEC5,\r\n\t0x964F, 0xBEC6, 0x9650, 0xBEC7, 0x9651, 0xBEC8, 0x9652, 0xBEC9,\t0x9653, 0xBECA, 0x9654, 0xBECB, 0x9655, 0xBECC, 0x9656, 0xBECD,\r\n\t0x9657, 0xBECE, 0x9658, 0xBECF, 0x9659, 0xBED2, 0x965A, 0xBED3,\t0x9661, 0xBED5, 0x9662, 0xBED6, 0x9663, 0xBED9, 0x9664, 0xBEDA,\r\n\t0x9665, 0xBEDB, 0x9666, 0xBEDC, 0x9667, 0xBEDD, 0x9668, 0xBEDE,\t0x9669, 0xBEDF, 0x966A, 0xBEE1, 0x966B, 0xBEE2, 0x966C, 0xBEE6,\r\n\t0x966D, 0xBEE7, 0x966E, 0xBEE8, 0x966F, 0xBEE9, 0x9670, 0xBEEA,\t0x9671, 0xBEEB, 0x9672, 0xBEED, 0x9673, 0xBEEE, 0x9674, 0xBEEF,\r\n\t0x9675, 0xBEF0, 0x9676, 0xBEF1, 0x9677, 0xBEF2, 0x9678, 0xBEF3,\t0x9679, 0xBEF4, 0x967A, 0xBEF5, 0x9681, 0xBEF6, 0x9682, 0xBEF7,\r\n\t0x9683, 0xBEF8, 0x9684, 0xBEF9, 0x9685, 0xBEFA, 0x9686, 0xBEFB,\t0x9687, 0xBEFC, 0x9688, 0xBEFD, 0x9689, 0xBEFE, 0x968A, 0xBEFF,\r\n\t0x968B, 0xBF00, 0x968C, 0xBF02, 0x968D, 0xBF03, 0x968E, 0xBF04,\t0x968F, 0xBF05, 0x9690, 0xBF06, 0x9691, 0xBF07, 0x9692, 0xBF0A,\r\n\t0x9693, 0xBF0B, 0x9694, 0xBF0C, 0x9695, 0xBF0D, 0x9696, 0xBF0E,\t0x9697, 0xBF0F, 0x9698, 0xBF10, 0x9699, 0xBF11, 0x969A, 0xBF12,\r\n\t0x969B, 0xBF13, 0x969C, 0xBF14, 0x969D, 0xBF15, 0x969E, 0xBF16,\t0x969F, 0xBF17, 0x96A0, 0xBF1A, 0x96A1, 0xBF1E, 0x96A2, 0xBF1F,\r\n\t0x96A3, 0xBF20, 0x96A4, 0xBF21, 0x96A5, 0xBF22, 0x96A6, 0xBF23,\t0x96A7, 0xBF24, 0x96A8, 0xBF25, 0x96A9, 0xBF26, 0x96AA, 0xBF27,\r\n\t0x96AB, 0xBF28, 0x96AC, 0xBF29, 0x96AD, 0xBF2A, 0x96AE, 0xBF2B,\t0x96AF, 0xBF2C, 0x96B0, 0xBF2D, 0x96B1, 0xBF2E, 0x96B2, 0xBF2F,\r\n\t0x96B3, 0xBF30, 0x96B4, 0xBF31, 0x96B5, 0xBF32, 0x96B6, 0xBF33,\t0x96B7, 0xBF34, 0x96B8, 0xBF35, 0x96B9, 0xBF36, 0x96BA, 0xBF37,\r\n\t0x96BB, 0xBF38, 0x96BC, 0xBF39, 0x96BD, 0xBF3A, 0x96BE, 0xBF3B,\t0x96BF, 0xBF3C, 0x96C0, 0xBF3D, 0x96C1, 0xBF3E, 0x96C2, 0xBF3F,\r\n\t0x96C3, 0xBF42, 0x96C4, 0xBF43, 0x96C5, 0xBF45, 0x96C6, 0xBF46,\t0x96C7, 0xBF47, 0x96C8, 0xBF49, 0x96C9, 0xBF4A, 0x96CA, 0xBF4B,\r\n\t0x96CB, 0xBF4C, 0x96CC, 0xBF4D, 0x96CD, 0xBF4E, 0x96CE, 0xBF4F,\t0x96CF, 0xBF52, 0x96D0, 0xBF53, 0x96D1, 0xBF54, 0x96D2, 0xBF56,\r\n\t0x96D3, 0xBF57, 0x96D4, 0xBF58, 0x96D5, 0xBF59, 0x96D6, 0xBF5A,\t0x96D7, 0xBF5B, 0x96D8, 0xBF5C, 0x96D9, 0xBF5D, 0x96DA, 0xBF5E,\r\n\t0x96DB, 0xBF5F, 0x96DC, 0xBF60, 0x96DD, 0xBF61, 0x96DE, 0xBF62,\t0x96DF, 0xBF63, 0x96E0, 0xBF64, 0x96E1, 0xBF65, 0x96E2, 0xBF66,\r\n\t0x96E3, 0xBF67, 0x96E4, 0xBF68, 0x96E5, 0xBF69, 0x96E6, 0xBF6A,\t0x96E7, 0xBF6B, 0x96E8, 0xBF6C, 0x96E9, 0xBF6D, 0x96EA, 0xBF6E,\r\n\t0x96EB, 0xBF6F, 0x96EC, 0xBF70, 0x96ED, 0xBF71, 0x96EE, 0xBF72,\t0x96EF, 0xBF73, 0x96F0, 0xBF74, 0x96F1, 0xBF75, 0x96F2, 0xBF76,\r\n\t0x96F3, 0xBF77, 0x96F4, 0xBF78, 0x96F5, 0xBF79, 0x96F6, 0xBF7A,\t0x96F7, 0xBF7B, 0x96F8, 0xBF7C, 0x96F9, 0xBF7D, 0x96FA, 0xBF7E,\r\n\t0x96FB, 0xBF7F, 0x96FC, 0xBF80, 0x96FD, 0xBF81, 0x96FE, 0xBF82,\t0x9741, 0xBF83, 0x9742, 0xBF84, 0x9743, 0xBF85, 0x9744, 0xBF86,\r\n\t0x9745, 0xBF87, 0x9746, 0xBF88, 0x9747, 0xBF89, 0x9748, 0xBF8A,\t0x9749, 0xBF8B, 0x974A, 0xBF8C, 0x974B, 0xBF8D, 0x974C, 0xBF8E,\r\n\t0x974D, 0xBF8F, 0x974E, 0xBF90, 0x974F, 0xBF91, 0x9750, 0xBF92,\t0x9751, 0xBF93, 0x9752, 0xBF95, 0x9753, 0xBF96, 0x9754, 0xBF97,\r\n\t0x9755, 0xBF98, 0x9756, 0xBF99, 0x9757, 0xBF9A, 0x9758, 0xBF9B,\t0x9759, 0xBF9C, 0x975A, 0xBF9D, 0x9761, 0xBF9E, 0x9762, 0xBF9F,\r\n\t0x9763, 0xBFA0, 0x9764, 0xBFA1, 0x9765, 0xBFA2, 0x9766, 0xBFA3,\t0x9767, 0xBFA4, 0x9768, 0xBFA5, 0x9769, 0xBFA6, 0x976A, 0xBFA7,\r\n\t0x976B, 0xBFA8, 0x976C, 0xBFA9, 0x976D, 0xBFAA, 0x976E, 0xBFAB,\t0x976F, 0xBFAC, 0x9770, 0xBFAD, 0x9771, 0xBFAE, 0x9772, 0xBFAF,\r\n\t0x9773, 0xBFB1, 0x9774, 0xBFB2, 0x9775, 0xBFB3, 0x9776, 0xBFB4,\t0x9777, 0xBFB5, 0x9778, 0xBFB6, 0x9779, 0xBFB7, 0x977A, 0xBFB8,\r\n\t0x9781, 0xBFB9, 0x9782, 0xBFBA, 0x9783, 0xBFBB, 0x9784, 0xBFBC,\t0x9785, 0xBFBD, 0x9786, 0xBFBE, 0x9787, 0xBFBF, 0x9788, 0xBFC0,\r\n\t0x9789, 0xBFC1, 0x978A, 0xBFC2, 0x978B, 0xBFC3, 0x978C, 0xBFC4,\t0x978D, 0xBFC6, 0x978E, 0xBFC7, 0x978F, 0xBFC8, 0x9790, 0xBFC9,\r\n\t0x9791, 0xBFCA, 0x9792, 0xBFCB, 0x9793, 0xBFCE, 0x9794, 0xBFCF,\t0x9795, 0xBFD1, 0x9796, 0xBFD2, 0x9797, 0xBFD3, 0x9798, 0xBFD5,\r\n\t0x9799, 0xBFD6, 0x979A, 0xBFD7, 0x979B, 0xBFD8, 0x979C, 0xBFD9,\t0x979D, 0xBFDA, 0x979E, 0xBFDB, 0x979F, 0xBFDD, 0x97A0, 0xBFDE,\r\n\t0x97A1, 0xBFE0, 0x97A2, 0xBFE2, 0x97A3, 0xBFE3, 0x97A4, 0xBFE4,\t0x97A5, 0xBFE5, 0x97A6, 0xBFE6, 0x97A7, 0xBFE7, 0x97A8, 0xBFE8,\r\n\t0x97A9, 0xBFE9, 0x97AA, 0xBFEA, 0x97AB, 0xBFEB, 0x97AC, 0xBFEC,\t0x97AD, 0xBFED, 0x97AE, 0xBFEE, 0x97AF, 0xBFEF, 0x97B0, 0xBFF0,\r\n\t0x97B1, 0xBFF1, 0x97B2, 0xBFF2, 0x97B3, 0xBFF3, 0x97B4, 0xBFF4,\t0x97B5, 0xBFF5, 0x97B6, 0xBFF6, 0x97B7, 0xBFF7, 0x97B8, 0xBFF8,\r\n\t0x97B9, 0xBFF9, 0x97BA, 0xBFFA, 0x97BB, 0xBFFB, 0x97BC, 0xBFFC,\t0x97BD, 0xBFFD, 0x97BE, 0xBFFE, 0x97BF, 0xBFFF, 0x97C0, 0xC000,\r\n\t0x97C1, 0xC001, 0x97C2, 0xC002, 0x97C3, 0xC003, 0x97C4, 0xC004,\t0x97C5, 0xC005, 0x97C6, 0xC006, 0x97C7, 0xC007, 0x97C8, 0xC008,\r\n\t0x97C9, 0xC009, 0x97CA, 0xC00A, 0x97CB, 0xC00B, 0x97CC, 0xC00C,\t0x97CD, 0xC00D, 0x97CE, 0xC00E, 0x97CF, 0xC00F, 0x97D0, 0xC010,\r\n\t0x97D1, 0xC011, 0x97D2, 0xC012, 0x97D3, 0xC013, 0x97D4, 0xC014,\t0x97D5, 0xC015, 0x97D6, 0xC016, 0x97D7, 0xC017, 0x97D8, 0xC018,\r\n\t0x97D9, 0xC019, 0x97DA, 0xC01A, 0x97DB, 0xC01B, 0x97DC, 0xC01C,\t0x97DD, 0xC01D, 0x97DE, 0xC01E, 0x97DF, 0xC01F, 0x97E0, 0xC020,\r\n\t0x97E1, 0xC021, 0x97E2, 0xC022, 0x97E3, 0xC023, 0x97E4, 0xC024,\t0x97E5, 0xC025, 0x97E6, 0xC026, 0x97E7, 0xC027, 0x97E8, 0xC028,\r\n\t0x97E9, 0xC029, 0x97EA, 0xC02A, 0x97EB, 0xC02B, 0x97EC, 0xC02C,\t0x97ED, 0xC02D, 0x97EE, 0xC02E, 0x97EF, 0xC02F, 0x97F0, 0xC030,\r\n\t0x97F1, 0xC031, 0x97F2, 0xC032, 0x97F3, 0xC033, 0x97F4, 0xC034,\t0x97F5, 0xC035, 0x97F6, 0xC036, 0x97F7, 0xC037, 0x97F8, 0xC038,\r\n\t0x97F9, 0xC039, 0x97FA, 0xC03A, 0x97FB, 0xC03B, 0x97FC, 0xC03D,\t0x97FD, 0xC03E, 0x97FE, 0xC03F, 0x9841, 0xC040, 0x9842, 0xC041,\r\n\t0x9843, 0xC042, 0x9844, 0xC043, 0x9845, 0xC044, 0x9846, 0xC045,\t0x9847, 0xC046, 0x9848, 0xC047, 0x9849, 0xC048, 0x984A, 0xC049,\r\n\t0x984B, 0xC04A, 0x984C, 0xC04B, 0x984D, 0xC04C, 0x984E, 0xC04D,\t0x984F, 0xC04E, 0x9850, 0xC04F, 0x9851, 0xC050, 0x9852, 0xC052,\r\n\t0x9853, 0xC053, 0x9854, 0xC054, 0x9855, 0xC055, 0x9856, 0xC056,\t0x9857, 0xC057, 0x9858, 0xC059, 0x9859, 0xC05A, 0x985A, 0xC05B,\r\n\t0x9861, 0xC05D, 0x9862, 0xC05E, 0x9863, 0xC05F, 0x9864, 0xC061,\t0x9865, 0xC062, 0x9866, 0xC063, 0x9867, 0xC064, 0x9868, 0xC065,\r\n\t0x9869, 0xC066, 0x986A, 0xC067, 0x986B, 0xC06A, 0x986C, 0xC06B,\t0x986D, 0xC06C, 0x986E, 0xC06D, 0x986F, 0xC06E, 0x9870, 0xC06F,\r\n\t0x9871, 0xC070, 0x9872, 0xC071, 0x9873, 0xC072, 0x9874, 0xC073,\t0x9875, 0xC074, 0x9876, 0xC075, 0x9877, 0xC076, 0x9878, 0xC077,\r\n\t0x9879, 0xC078, 0x987A, 0xC079, 0x9881, 0xC07A, 0x9882, 0xC07B,\t0x9883, 0xC07C, 0x9884, 0xC07D, 0x9885, 0xC07E, 0x9886, 0xC07F,\r\n\t0x9887, 0xC080, 0x9888, 0xC081, 0x9889, 0xC082, 0x988A, 0xC083,\t0x988B, 0xC084, 0x988C, 0xC085, 0x988D, 0xC086, 0x988E, 0xC087,\r\n\t0x988F, 0xC088, 0x9890, 0xC089, 0x9891, 0xC08A, 0x9892, 0xC08B,\t0x9893, 0xC08C, 0x9894, 0xC08D, 0x9895, 0xC08E, 0x9896, 0xC08F,\r\n\t0x9897, 0xC092, 0x9898, 0xC093, 0x9899, 0xC095, 0x989A, 0xC096,\t0x989B, 0xC097, 0x989C, 0xC099, 0x989D, 0xC09A, 0x989E, 0xC09B,\r\n\t0x989F, 0xC09C, 0x98A0, 0xC09D, 0x98A1, 0xC09E, 0x98A2, 0xC09F,\t0x98A3, 0xC0A2, 0x98A4, 0xC0A4, 0x98A5, 0xC0A6, 0x98A6, 0xC0A7,\r\n\t0x98A7, 0xC0A8, 0x98A8, 0xC0A9, 0x98A9, 0xC0AA, 0x98AA, 0xC0AB,\t0x98AB, 0xC0AE, 0x98AC, 0xC0B1, 0x98AD, 0xC0B2, 0x98AE, 0xC0B7,\r\n\t0x98AF, 0xC0B8, 0x98B0, 0xC0B9, 0x98B1, 0xC0BA, 0x98B2, 0xC0BB,\t0x98B3, 0xC0BE, 0x98B4, 0xC0C2, 0x98B5, 0xC0C3, 0x98B6, 0xC0C4,\r\n\t0x98B7, 0xC0C6, 0x98B8, 0xC0C7, 0x98B9, 0xC0CA, 0x98BA, 0xC0CB,\t0x98BB, 0xC0CD, 0x98BC, 0xC0CE, 0x98BD, 0xC0CF, 0x98BE, 0xC0D1,\r\n\t0x98BF, 0xC0D2, 0x98C0, 0xC0D3, 0x98C1, 0xC0D4, 0x98C2, 0xC0D5,\t0x98C3, 0xC0D6, 0x98C4, 0xC0D7, 0x98C5, 0xC0DA, 0x98C6, 0xC0DE,\r\n\t0x98C7, 0xC0DF, 0x98C8, 0xC0E0, 0x98C9, 0xC0E1, 0x98CA, 0xC0E2,\t0x98CB, 0xC0E3, 0x98CC, 0xC0E6, 0x98CD, 0xC0E7, 0x98CE, 0xC0E9,\r\n\t0x98CF, 0xC0EA, 0x98D0, 0xC0EB, 0x98D1, 0xC0ED, 0x98D2, 0xC0EE,\t0x98D3, 0xC0EF, 0x98D4, 0xC0F0, 0x98D5, 0xC0F1, 0x98D6, 0xC0F2,\r\n\t0x98D7, 0xC0F3, 0x98D8, 0xC0F6, 0x98D9, 0xC0F8, 0x98DA, 0xC0FA,\t0x98DB, 0xC0FB, 0x98DC, 0xC0FC, 0x98DD, 0xC0FD, 0x98DE, 0xC0FE,\r\n\t0x98DF, 0xC0FF, 0x98E0, 0xC101, 0x98E1, 0xC102, 0x98E2, 0xC103,\t0x98E3, 0xC105, 0x98E4, 0xC106, 0x98E5, 0xC107, 0x98E6, 0xC109,\r\n\t0x98E7, 0xC10A, 0x98E8, 0xC10B, 0x98E9, 0xC10C, 0x98EA, 0xC10D,\t0x98EB, 0xC10E, 0x98EC, 0xC10F, 0x98ED, 0xC111, 0x98EE, 0xC112,\r\n\t0x98EF, 0xC113, 0x98F0, 0xC114, 0x98F1, 0xC116, 0x98F2, 0xC117,\t0x98F3, 0xC118, 0x98F4, 0xC119, 0x98F5, 0xC11A, 0x98F6, 0xC11B,\r\n\t0x98F7, 0xC121, 0x98F8, 0xC122, 0x98F9, 0xC125, 0x98FA, 0xC128,\t0x98FB, 0xC129, 0x98FC, 0xC12A, 0x98FD, 0xC12B, 0x98FE, 0xC12E,\r\n\t0x9941, 0xC132, 0x9942, 0xC133, 0x9943, 0xC134, 0x9944, 0xC135,\t0x9945, 0xC137, 0x9946, 0xC13A, 0x9947, 0xC13B, 0x9948, 0xC13D,\r\n\t0x9949, 0xC13E, 0x994A, 0xC13F, 0x994B, 0xC141, 0x994C, 0xC142,\t0x994D, 0xC143, 0x994E, 0xC144, 0x994F, 0xC145, 0x9950, 0xC146,\r\n\t0x9951, 0xC147, 0x9952, 0xC14A, 0x9953, 0xC14E, 0x9954, 0xC14F,\t0x9955, 0xC150, 0x9956, 0xC151, 0x9957, 0xC152, 0x9958, 0xC153,\r\n\t0x9959, 0xC156, 0x995A, 0xC157, 0x9961, 0xC159, 0x9962, 0xC15A,\t0x9963, 0xC15B, 0x9964, 0xC15D, 0x9965, 0xC15E, 0x9966, 0xC15F,\r\n\t0x9967, 0xC160, 0x9968, 0xC161, 0x9969, 0xC162, 0x996A, 0xC163,\t0x996B, 0xC166, 0x996C, 0xC16A, 0x996D, 0xC16B, 0x996E, 0xC16C,\r\n\t0x996F, 0xC16D, 0x9970, 0xC16E, 0x9971, 0xC16F, 0x9972, 0xC171,\t0x9973, 0xC172, 0x9974, 0xC173, 0x9975, 0xC175, 0x9976, 0xC176,\r\n\t0x9977, 0xC177, 0x9978, 0xC179, 0x9979, 0xC17A, 0x997A, 0xC17B,\t0x9981, 0xC17C, 0x9982, 0xC17D, 0x9983, 0xC17E, 0x9984, 0xC17F,\r\n\t0x9985, 0xC180, 0x9986, 0xC181, 0x9987, 0xC182, 0x9988, 0xC183,\t0x9989, 0xC184, 0x998A, 0xC186, 0x998B, 0xC187, 0x998C, 0xC188,\r\n\t0x998D, 0xC189, 0x998E, 0xC18A, 0x998F, 0xC18B, 0x9990, 0xC18F,\t0x9991, 0xC191, 0x9992, 0xC192, 0x9993, 0xC193, 0x9994, 0xC195,\r\n\t0x9995, 0xC197, 0x9996, 0xC198, 0x9997, 0xC199, 0x9998, 0xC19A,\t0x9999, 0xC19B, 0x999A, 0xC19E, 0x999B, 0xC1A0, 0x999C, 0xC1A2,\r\n\t0x999D, 0xC1A3, 0x999E, 0xC1A4, 0x999F, 0xC1A6, 0x99A0, 0xC1A7,\t0x99A1, 0xC1AA, 0x99A2, 0xC1AB, 0x99A3, 0xC1AD, 0x99A4, 0xC1AE,\r\n\t0x99A5, 0xC1AF, 0x99A6, 0xC1B1, 0x99A7, 0xC1B2, 0x99A8, 0xC1B3,\t0x99A9, 0xC1B4, 0x99AA, 0xC1B5, 0x99AB, 0xC1B6, 0x99AC, 0xC1B7,\r\n\t0x99AD, 0xC1B8, 0x99AE, 0xC1B9, 0x99AF, 0xC1BA, 0x99B0, 0xC1BB,\t0x99B1, 0xC1BC, 0x99B2, 0xC1BE, 0x99B3, 0xC1BF, 0x99B4, 0xC1C0,\r\n\t0x99B5, 0xC1C1, 0x99B6, 0xC1C2, 0x99B7, 0xC1C3, 0x99B8, 0xC1C5,\t0x99B9, 0xC1C6, 0x99BA, 0xC1C7, 0x99BB, 0xC1C9, 0x99BC, 0xC1CA,\r\n\t0x99BD, 0xC1CB, 0x99BE, 0xC1CD, 0x99BF, 0xC1CE, 0x99C0, 0xC1CF,\t0x99C1, 0xC1D0, 0x99C2, 0xC1D1, 0x99C3, 0xC1D2, 0x99C4, 0xC1D3,\r\n\t0x99C5, 0xC1D5, 0x99C6, 0xC1D6, 0x99C7, 0xC1D9, 0x99C8, 0xC1DA,\t0x99C9, 0xC1DB, 0x99CA, 0xC1DC, 0x99CB, 0xC1DD, 0x99CC, 0xC1DE,\r\n\t0x99CD, 0xC1DF, 0x99CE, 0xC1E1, 0x99CF, 0xC1E2, 0x99D0, 0xC1E3,\t0x99D1, 0xC1E5, 0x99D2, 0xC1E6, 0x99D3, 0xC1E7, 0x99D4, 0xC1E9,\r\n\t0x99D5, 0xC1EA, 0x99D6, 0xC1EB, 0x99D7, 0xC1EC, 0x99D8, 0xC1ED,\t0x99D9, 0xC1EE, 0x99DA, 0xC1EF, 0x99DB, 0xC1F2, 0x99DC, 0xC1F4,\r\n\t0x99DD, 0xC1F5, 0x99DE, 0xC1F6, 0x99DF, 0xC1F7, 0x99E0, 0xC1F8,\t0x99E1, 0xC1F9, 0x99E2, 0xC1FA, 0x99E3, 0xC1FB, 0x99E4, 0xC1FE,\r\n\t0x99E5, 0xC1FF, 0x99E6, 0xC201, 0x99E7, 0xC202, 0x99E8, 0xC203,\t0x99E9, 0xC205, 0x99EA, 0xC206, 0x99EB, 0xC207, 0x99EC, 0xC208,\r\n\t0x99ED, 0xC209, 0x99EE, 0xC20A, 0x99EF, 0xC20B, 0x99F0, 0xC20E,\t0x99F1, 0xC210, 0x99F2, 0xC212, 0x99F3, 0xC213, 0x99F4, 0xC214,\r\n\t0x99F5, 0xC215, 0x99F6, 0xC216, 0x99F7, 0xC217, 0x99F8, 0xC21A,\t0x99F9, 0xC21B, 0x99FA, 0xC21D, 0x99FB, 0xC21E, 0x99FC, 0xC221,\r\n\t0x99FD, 0xC222, 0x99FE, 0xC223, 0x9A41, 0xC224, 0x9A42, 0xC225,\t0x9A43, 0xC226, 0x9A44, 0xC227, 0x9A45, 0xC22A, 0x9A46, 0xC22C,\r\n\t0x9A47, 0xC22E, 0x9A48, 0xC230, 0x9A49, 0xC233, 0x9A4A, 0xC235,\t0x9A4B, 0xC236, 0x9A4C, 0xC237, 0x9A4D, 0xC238, 0x9A4E, 0xC239,\r\n\t0x9A4F, 0xC23A, 0x9A50, 0xC23B, 0x9A51, 0xC23C, 0x9A52, 0xC23D,\t0x9A53, 0xC23E, 0x9A54, 0xC23F, 0x9A55, 0xC240, 0x9A56, 0xC241,\r\n\t0x9A57, 0xC242, 0x9A58, 0xC243, 0x9A59, 0xC244, 0x9A5A, 0xC245,\t0x9A61, 0xC246, 0x9A62, 0xC247, 0x9A63, 0xC249, 0x9A64, 0xC24A,\r\n\t0x9A65, 0xC24B, 0x9A66, 0xC24C, 0x9A67, 0xC24D, 0x9A68, 0xC24E,\t0x9A69, 0xC24F, 0x9A6A, 0xC252, 0x9A6B, 0xC253, 0x9A6C, 0xC255,\r\n\t0x9A6D, 0xC256, 0x9A6E, 0xC257, 0x9A6F, 0xC259, 0x9A70, 0xC25A,\t0x9A71, 0xC25B, 0x9A72, 0xC25C, 0x9A73, 0xC25D, 0x9A74, 0xC25E,\r\n\t0x9A75, 0xC25F, 0x9A76, 0xC261, 0x9A77, 0xC262, 0x9A78, 0xC263,\t0x9A79, 0xC264, 0x9A7A, 0xC266, 0x9A81, 0xC267, 0x9A82, 0xC268,\r\n\t0x9A83, 0xC269, 0x9A84, 0xC26A, 0x9A85, 0xC26B, 0x9A86, 0xC26E,\t0x9A87, 0xC26F, 0x9A88, 0xC271, 0x9A89, 0xC272, 0x9A8A, 0xC273,\r\n\t0x9A8B, 0xC275, 0x9A8C, 0xC276, 0x9A8D, 0xC277, 0x9A8E, 0xC278,\t0x9A8F, 0xC279, 0x9A90, 0xC27A, 0x9A91, 0xC27B, 0x9A92, 0xC27E,\r\n\t0x9A93, 0xC280, 0x9A94, 0xC282, 0x9A95, 0xC283, 0x9A96, 0xC284,\t0x9A97, 0xC285, 0x9A98, 0xC286, 0x9A99, 0xC287, 0x9A9A, 0xC28A,\r\n\t0x9A9B, 0xC28B, 0x9A9C, 0xC28C, 0x9A9D, 0xC28D, 0x9A9E, 0xC28E,\t0x9A9F, 0xC28F, 0x9AA0, 0xC291, 0x9AA1, 0xC292, 0x9AA2, 0xC293,\r\n\t0x9AA3, 0xC294, 0x9AA4, 0xC295, 0x9AA5, 0xC296, 0x9AA6, 0xC297,\t0x9AA7, 0xC299, 0x9AA8, 0xC29A, 0x9AA9, 0xC29C, 0x9AAA, 0xC29E,\r\n\t0x9AAB, 0xC29F, 0x9AAC, 0xC2A0, 0x9AAD, 0xC2A1, 0x9AAE, 0xC2A2,\t0x9AAF, 0xC2A3, 0x9AB0, 0xC2A6, 0x9AB1, 0xC2A7, 0x9AB2, 0xC2A9,\r\n\t0x9AB3, 0xC2AA, 0x9AB4, 0xC2AB, 0x9AB5, 0xC2AE, 0x9AB6, 0xC2AF,\t0x9AB7, 0xC2B0, 0x9AB8, 0xC2B1, 0x9AB9, 0xC2B2, 0x9ABA, 0xC2B3,\r\n\t0x9ABB, 0xC2B6, 0x9ABC, 0xC2B8, 0x9ABD, 0xC2BA, 0x9ABE, 0xC2BB,\t0x9ABF, 0xC2BC, 0x9AC0, 0xC2BD, 0x9AC1, 0xC2BE, 0x9AC2, 0xC2BF,\r\n\t0x9AC3, 0xC2C0, 0x9AC4, 0xC2C1, 0x9AC5, 0xC2C2, 0x9AC6, 0xC2C3,\t0x9AC7, 0xC2C4, 0x9AC8, 0xC2C5, 0x9AC9, 0xC2C6, 0x9ACA, 0xC2C7,\r\n\t0x9ACB, 0xC2C8, 0x9ACC, 0xC2C9, 0x9ACD, 0xC2CA, 0x9ACE, 0xC2CB,\t0x9ACF, 0xC2CC, 0x9AD0, 0xC2CD, 0x9AD1, 0xC2CE, 0x9AD2, 0xC2CF,\r\n\t0x9AD3, 0xC2D0, 0x9AD4, 0xC2D1, 0x9AD5, 0xC2D2, 0x9AD6, 0xC2D3,\t0x9AD7, 0xC2D4, 0x9AD8, 0xC2D5, 0x9AD9, 0xC2D6, 0x9ADA, 0xC2D7,\r\n\t0x9ADB, 0xC2D8, 0x9ADC, 0xC2D9, 0x9ADD, 0xC2DA, 0x9ADE, 0xC2DB,\t0x9ADF, 0xC2DE, 0x9AE0, 0xC2DF, 0x9AE1, 0xC2E1, 0x9AE2, 0xC2E2,\r\n\t0x9AE3, 0xC2E5, 0x9AE4, 0xC2E6, 0x9AE5, 0xC2E7, 0x9AE6, 0xC2E8,\t0x9AE7, 0xC2E9, 0x9AE8, 0xC2EA, 0x9AE9, 0xC2EE, 0x9AEA, 0xC2F0,\r\n\t0x9AEB, 0xC2F2, 0x9AEC, 0xC2F3, 0x9AED, 0xC2F4, 0x9AEE, 0xC2F5,\t0x9AEF, 0xC2F7, 0x9AF0, 0xC2FA, 0x9AF1, 0xC2FD, 0x9AF2, 0xC2FE,\r\n\t0x9AF3, 0xC2FF, 0x9AF4, 0xC301, 0x9AF5, 0xC302, 0x9AF6, 0xC303,\t0x9AF7, 0xC304, 0x9AF8, 0xC305, 0x9AF9, 0xC306, 0x9AFA, 0xC307,\r\n\t0x9AFB, 0xC30A, 0x9AFC, 0xC30B, 0x9AFD, 0xC30E, 0x9AFE, 0xC30F,\t0x9B41, 0xC310, 0x9B42, 0xC311, 0x9B43, 0xC312, 0x9B44, 0xC316,\r\n\t0x9B45, 0xC317, 0x9B46, 0xC319, 0x9B47, 0xC31A, 0x9B48, 0xC31B,\t0x9B49, 0xC31D, 0x9B4A, 0xC31E, 0x9B4B, 0xC31F, 0x9B4C, 0xC320,\r\n\t0x9B4D, 0xC321, 0x9B4E, 0xC322, 0x9B4F, 0xC323, 0x9B50, 0xC326,\t0x9B51, 0xC327, 0x9B52, 0xC32A, 0x9B53, 0xC32B, 0x9B54, 0xC32C,\r\n\t0x9B55, 0xC32D, 0x9B56, 0xC32E, 0x9B57, 0xC32F, 0x9B58, 0xC330,\t0x9B59, 0xC331, 0x9B5A, 0xC332, 0x9B61, 0xC333, 0x9B62, 0xC334,\r\n\t0x9B63, 0xC335, 0x9B64, 0xC336, 0x9B65, 0xC337, 0x9B66, 0xC338,\t0x9B67, 0xC339, 0x9B68, 0xC33A, 0x9B69, 0xC33B, 0x9B6A, 0xC33C,\r\n\t0x9B6B, 0xC33D, 0x9B6C, 0xC33E, 0x9B6D, 0xC33F, 0x9B6E, 0xC340,\t0x9B6F, 0xC341, 0x9B70, 0xC342, 0x9B71, 0xC343, 0x9B72, 0xC344,\r\n\t0x9B73, 0xC346, 0x9B74, 0xC347, 0x9B75, 0xC348, 0x9B76, 0xC349,\t0x9B77, 0xC34A, 0x9B78, 0xC34B, 0x9B79, 0xC34C, 0x9B7A, 0xC34D,\r\n\t0x9B81, 0xC34E, 0x9B82, 0xC34F, 0x9B83, 0xC350, 0x9B84, 0xC351,\t0x9B85, 0xC352, 0x9B86, 0xC353, 0x9B87, 0xC354, 0x9B88, 0xC355,\r\n\t0x9B89, 0xC356, 0x9B8A, 0xC357, 0x9B8B, 0xC358, 0x9B8C, 0xC359,\t0x9B8D, 0xC35A, 0x9B8E, 0xC35B, 0x9B8F, 0xC35C, 0x9B90, 0xC35D,\r\n\t0x9B91, 0xC35E, 0x9B92, 0xC35F, 0x9B93, 0xC360, 0x9B94, 0xC361,\t0x9B95, 0xC362, 0x9B96, 0xC363, 0x9B97, 0xC364, 0x9B98, 0xC365,\r\n\t0x9B99, 0xC366, 0x9B9A, 0xC367, 0x9B9B, 0xC36A, 0x9B9C, 0xC36B,\t0x9B9D, 0xC36D, 0x9B9E, 0xC36E, 0x9B9F, 0xC36F, 0x9BA0, 0xC371,\r\n\t0x9BA1, 0xC373, 0x9BA2, 0xC374, 0x9BA3, 0xC375, 0x9BA4, 0xC376,\t0x9BA5, 0xC377, 0x9BA6, 0xC37A, 0x9BA7, 0xC37B, 0x9BA8, 0xC37E,\r\n\t0x9BA9, 0xC37F, 0x9BAA, 0xC380, 0x9BAB, 0xC381, 0x9BAC, 0xC382,\t0x9BAD, 0xC383, 0x9BAE, 0xC385, 0x9BAF, 0xC386, 0x9BB0, 0xC387,\r\n\t0x9BB1, 0xC389, 0x9BB2, 0xC38A, 0x9BB3, 0xC38B, 0x9BB4, 0xC38D,\t0x9BB5, 0xC38E, 0x9BB6, 0xC38F, 0x9BB7, 0xC390, 0x9BB8, 0xC391,\r\n\t0x9BB9, 0xC392, 0x9BBA, 0xC393, 0x9BBB, 0xC394, 0x9BBC, 0xC395,\t0x9BBD, 0xC396, 0x9BBE, 0xC397, 0x9BBF, 0xC398, 0x9BC0, 0xC399,\r\n\t0x9BC1, 0xC39A, 0x9BC2, 0xC39B, 0x9BC3, 0xC39C, 0x9BC4, 0xC39D,\t0x9BC5, 0xC39E, 0x9BC6, 0xC39F, 0x9BC7, 0xC3A0, 0x9BC8, 0xC3A1,\r\n\t0x9BC9, 0xC3A2, 0x9BCA, 0xC3A3, 0x9BCB, 0xC3A4, 0x9BCC, 0xC3A5,\t0x9BCD, 0xC3A6, 0x9BCE, 0xC3A7, 0x9BCF, 0xC3A8, 0x9BD0, 0xC3A9,\r\n\t0x9BD1, 0xC3AA, 0x9BD2, 0xC3AB, 0x9BD3, 0xC3AC, 0x9BD4, 0xC3AD,\t0x9BD5, 0xC3AE, 0x9BD6, 0xC3AF, 0x9BD7, 0xC3B0, 0x9BD8, 0xC3B1,\r\n\t0x9BD9, 0xC3B2, 0x9BDA, 0xC3B3, 0x9BDB, 0xC3B4, 0x9BDC, 0xC3B5,\t0x9BDD, 0xC3B6, 0x9BDE, 0xC3B7, 0x9BDF, 0xC3B8, 0x9BE0, 0xC3B9,\r\n\t0x9BE1, 0xC3BA, 0x9BE2, 0xC3BB, 0x9BE3, 0xC3BC, 0x9BE4, 0xC3BD,\t0x9BE5, 0xC3BE, 0x9BE6, 0xC3BF, 0x9BE7, 0xC3C1, 0x9BE8, 0xC3C2,\r\n\t0x9BE9, 0xC3C3, 0x9BEA, 0xC3C4, 0x9BEB, 0xC3C5, 0x9BEC, 0xC3C6,\t0x9BED, 0xC3C7, 0x9BEE, 0xC3C8, 0x9BEF, 0xC3C9, 0x9BF0, 0xC3CA,\r\n\t0x9BF1, 0xC3CB, 0x9BF2, 0xC3CC, 0x9BF3, 0xC3CD, 0x9BF4, 0xC3CE,\t0x9BF5, 0xC3CF, 0x9BF6, 0xC3D0, 0x9BF7, 0xC3D1, 0x9BF8, 0xC3D2,\r\n\t0x9BF9, 0xC3D3, 0x9BFA, 0xC3D4, 0x9BFB, 0xC3D5, 0x9BFC, 0xC3D6,\t0x9BFD, 0xC3D7, 0x9BFE, 0xC3DA, 0x9C41, 0xC3DB, 0x9C42, 0xC3DD,\r\n\t0x9C43, 0xC3DE, 0x9C44, 0xC3E1, 0x9C45, 0xC3E3, 0x9C46, 0xC3E4,\t0x9C47, 0xC3E5, 0x9C48, 0xC3E6, 0x9C49, 0xC3E7, 0x9C4A, 0xC3EA,\r\n\t0x9C4B, 0xC3EB, 0x9C4C, 0xC3EC, 0x9C4D, 0xC3EE, 0x9C4E, 0xC3EF,\t0x9C4F, 0xC3F0, 0x9C50, 0xC3F1, 0x9C51, 0xC3F2, 0x9C52, 0xC3F3,\r\n\t0x9C53, 0xC3F6, 0x9C54, 0xC3F7, 0x9C55, 0xC3F9, 0x9C56, 0xC3FA,\t0x9C57, 0xC3FB, 0x9C58, 0xC3FC, 0x9C59, 0xC3FD, 0x9C5A, 0xC3FE,\r\n\t0x9C61, 0xC3FF, 0x9C62, 0xC400, 0x9C63, 0xC401, 0x9C64, 0xC402,\t0x9C65, 0xC403, 0x9C66, 0xC404, 0x9C67, 0xC405, 0x9C68, 0xC406,\r\n\t0x9C69, 0xC407, 0x9C6A, 0xC409, 0x9C6B, 0xC40A, 0x9C6C, 0xC40B,\t0x9C6D, 0xC40C, 0x9C6E, 0xC40D, 0x9C6F, 0xC40E, 0x9C70, 0xC40F,\r\n\t0x9C71, 0xC411, 0x9C72, 0xC412, 0x9C73, 0xC413, 0x9C74, 0xC414,\t0x9C75, 0xC415, 0x9C76, 0xC416, 0x9C77, 0xC417, 0x9C78, 0xC418,\r\n\t0x9C79, 0xC419, 0x9C7A, 0xC41A, 0x9C81, 0xC41B, 0x9C82, 0xC41C,\t0x9C83, 0xC41D, 0x9C84, 0xC41E, 0x9C85, 0xC41F, 0x9C86, 0xC420,\r\n\t0x9C87, 0xC421, 0x9C88, 0xC422, 0x9C89, 0xC423, 0x9C8A, 0xC425,\t0x9C8B, 0xC426, 0x9C8C, 0xC427, 0x9C8D, 0xC428, 0x9C8E, 0xC429,\r\n\t0x9C8F, 0xC42A, 0x9C90, 0xC42B, 0x9C91, 0xC42D, 0x9C92, 0xC42E,\t0x9C93, 0xC42F, 0x9C94, 0xC431, 0x9C95, 0xC432, 0x9C96, 0xC433,\r\n\t0x9C97, 0xC435, 0x9C98, 0xC436, 0x9C99, 0xC437, 0x9C9A, 0xC438,\t0x9C9B, 0xC439, 0x9C9C, 0xC43A, 0x9C9D, 0xC43B, 0x9C9E, 0xC43E,\r\n\t0x9C9F, 0xC43F, 0x9CA0, 0xC440, 0x9CA1, 0xC441, 0x9CA2, 0xC442,\t0x9CA3, 0xC443, 0x9CA4, 0xC444, 0x9CA5, 0xC445, 0x9CA6, 0xC446,\r\n\t0x9CA7, 0xC447, 0x9CA8, 0xC449, 0x9CA9, 0xC44A, 0x9CAA, 0xC44B,\t0x9CAB, 0xC44C, 0x9CAC, 0xC44D, 0x9CAD, 0xC44E, 0x9CAE, 0xC44F,\r\n\t0x9CAF, 0xC450, 0x9CB0, 0xC451, 0x9CB1, 0xC452, 0x9CB2, 0xC453,\t0x9CB3, 0xC454, 0x9CB4, 0xC455, 0x9CB5, 0xC456, 0x9CB6, 0xC457,\r\n\t0x9CB7, 0xC458, 0x9CB8, 0xC459, 0x9CB9, 0xC45A, 0x9CBA, 0xC45B,\t0x9CBB, 0xC45C, 0x9CBC, 0xC45D, 0x9CBD, 0xC45E, 0x9CBE, 0xC45F,\r\n\t0x9CBF, 0xC460, 0x9CC0, 0xC461, 0x9CC1, 0xC462, 0x9CC2, 0xC463,\t0x9CC3, 0xC466, 0x9CC4, 0xC467, 0x9CC5, 0xC469, 0x9CC6, 0xC46A,\r\n\t0x9CC7, 0xC46B, 0x9CC8, 0xC46D, 0x9CC9, 0xC46E, 0x9CCA, 0xC46F,\t0x9CCB, 0xC470, 0x9CCC, 0xC471, 0x9CCD, 0xC472, 0x9CCE, 0xC473,\r\n\t0x9CCF, 0xC476, 0x9CD0, 0xC477, 0x9CD1, 0xC478, 0x9CD2, 0xC47A,\t0x9CD3, 0xC47B, 0x9CD4, 0xC47C, 0x9CD5, 0xC47D, 0x9CD6, 0xC47E,\r\n\t0x9CD7, 0xC47F, 0x9CD8, 0xC481, 0x9CD9, 0xC482, 0x9CDA, 0xC483,\t0x9CDB, 0xC484, 0x9CDC, 0xC485, 0x9CDD, 0xC486, 0x9CDE, 0xC487,\r\n\t0x9CDF, 0xC488, 0x9CE0, 0xC489, 0x9CE1, 0xC48A, 0x9CE2, 0xC48B,\t0x9CE3, 0xC48C, 0x9CE4, 0xC48D, 0x9CE5, 0xC48E, 0x9CE6, 0xC48F,\r\n\t0x9CE7, 0xC490, 0x9CE8, 0xC491, 0x9CE9, 0xC492, 0x9CEA, 0xC493,\t0x9CEB, 0xC495, 0x9CEC, 0xC496, 0x9CED, 0xC497, 0x9CEE, 0xC498,\r\n\t0x9CEF, 0xC499, 0x9CF0, 0xC49A, 0x9CF1, 0xC49B, 0x9CF2, 0xC49D,\t0x9CF3, 0xC49E, 0x9CF4, 0xC49F, 0x9CF5, 0xC4A0, 0x9CF6, 0xC4A1,\r\n\t0x9CF7, 0xC4A2, 0x9CF8, 0xC4A3, 0x9CF9, 0xC4A4, 0x9CFA, 0xC4A5,\t0x9CFB, 0xC4A6, 0x9CFC, 0xC4A7, 0x9CFD, 0xC4A8, 0x9CFE, 0xC4A9,\r\n\t0x9D41, 0xC4AA, 0x9D42, 0xC4AB, 0x9D43, 0xC4AC, 0x9D44, 0xC4AD,\t0x9D45, 0xC4AE, 0x9D46, 0xC4AF, 0x9D47, 0xC4B0, 0x9D48, 0xC4B1,\r\n\t0x9D49, 0xC4B2, 0x9D4A, 0xC4B3, 0x9D4B, 0xC4B4, 0x9D4C, 0xC4B5,\t0x9D4D, 0xC4B6, 0x9D4E, 0xC4B7, 0x9D4F, 0xC4B9, 0x9D50, 0xC4BA,\r\n\t0x9D51, 0xC4BB, 0x9D52, 0xC4BD, 0x9D53, 0xC4BE, 0x9D54, 0xC4BF,\t0x9D55, 0xC4C0, 0x9D56, 0xC4C1, 0x9D57, 0xC4C2, 0x9D58, 0xC4C3,\r\n\t0x9D59, 0xC4C4, 0x9D5A, 0xC4C5, 0x9D61, 0xC4C6, 0x9D62, 0xC4C7,\t0x9D63, 0xC4C8, 0x9D64, 0xC4C9, 0x9D65, 0xC4CA, 0x9D66, 0xC4CB,\r\n\t0x9D67, 0xC4CC, 0x9D68, 0xC4CD, 0x9D69, 0xC4CE, 0x9D6A, 0xC4CF,\t0x9D6B, 0xC4D0, 0x9D6C, 0xC4D1, 0x9D6D, 0xC4D2, 0x9D6E, 0xC4D3,\r\n\t0x9D6F, 0xC4D4, 0x9D70, 0xC4D5, 0x9D71, 0xC4D6, 0x9D72, 0xC4D7,\t0x9D73, 0xC4D8, 0x9D74, 0xC4D9, 0x9D75, 0xC4DA, 0x9D76, 0xC4DB,\r\n\t0x9D77, 0xC4DC, 0x9D78, 0xC4DD, 0x9D79, 0xC4DE, 0x9D7A, 0xC4DF,\t0x9D81, 0xC4E0, 0x9D82, 0xC4E1, 0x9D83, 0xC4E2, 0x9D84, 0xC4E3,\r\n\t0x9D85, 0xC4E4, 0x9D86, 0xC4E5, 0x9D87, 0xC4E6, 0x9D88, 0xC4E7,\t0x9D89, 0xC4E8, 0x9D8A, 0xC4EA, 0x9D8B, 0xC4EB, 0x9D8C, 0xC4EC,\r\n\t0x9D8D, 0xC4ED, 0x9D8E, 0xC4EE, 0x9D8F, 0xC4EF, 0x9D90, 0xC4F2,\t0x9D91, 0xC4F3, 0x9D92, 0xC4F5, 0x9D93, 0xC4F6, 0x9D94, 0xC4F7,\r\n\t0x9D95, 0xC4F9, 0x9D96, 0xC4FB, 0x9D97, 0xC4FC, 0x9D98, 0xC4FD,\t0x9D99, 0xC4FE, 0x9D9A, 0xC502, 0x9D9B, 0xC503, 0x9D9C, 0xC504,\r\n\t0x9D9D, 0xC505, 0x9D9E, 0xC506, 0x9D9F, 0xC507, 0x9DA0, 0xC508,\t0x9DA1, 0xC509, 0x9DA2, 0xC50A, 0x9DA3, 0xC50B, 0x9DA4, 0xC50D,\r\n\t0x9DA5, 0xC50E, 0x9DA6, 0xC50F, 0x9DA7, 0xC511, 0x9DA8, 0xC512,\t0x9DA9, 0xC513, 0x9DAA, 0xC515, 0x9DAB, 0xC516, 0x9DAC, 0xC517,\r\n\t0x9DAD, 0xC518, 0x9DAE, 0xC519, 0x9DAF, 0xC51A, 0x9DB0, 0xC51B,\t0x9DB1, 0xC51D, 0x9DB2, 0xC51E, 0x9DB3, 0xC51F, 0x9DB4, 0xC520,\r\n\t0x9DB5, 0xC521, 0x9DB6, 0xC522, 0x9DB7, 0xC523, 0x9DB8, 0xC524,\t0x9DB9, 0xC525, 0x9DBA, 0xC526, 0x9DBB, 0xC527, 0x9DBC, 0xC52A,\r\n\t0x9DBD, 0xC52B, 0x9DBE, 0xC52D, 0x9DBF, 0xC52E, 0x9DC0, 0xC52F,\t0x9DC1, 0xC531, 0x9DC2, 0xC532, 0x9DC3, 0xC533, 0x9DC4, 0xC534,\r\n\t0x9DC5, 0xC535, 0x9DC6, 0xC536, 0x9DC7, 0xC537, 0x9DC8, 0xC53A,\t0x9DC9, 0xC53C, 0x9DCA, 0xC53E, 0x9DCB, 0xC53F, 0x9DCC, 0xC540,\r\n\t0x9DCD, 0xC541, 0x9DCE, 0xC542, 0x9DCF, 0xC543, 0x9DD0, 0xC546,\t0x9DD1, 0xC547, 0x9DD2, 0xC54B, 0x9DD3, 0xC54F, 0x9DD4, 0xC550,\r\n\t0x9DD5, 0xC551, 0x9DD6, 0xC552, 0x9DD7, 0xC556, 0x9DD8, 0xC55A,\t0x9DD9, 0xC55B, 0x9DDA, 0xC55C, 0x9DDB, 0xC55F, 0x9DDC, 0xC562,\r\n\t0x9DDD, 0xC563, 0x9DDE, 0xC565, 0x9DDF, 0xC566, 0x9DE0, 0xC567,\t0x9DE1, 0xC569, 0x9DE2, 0xC56A, 0x9DE3, 0xC56B, 0x9DE4, 0xC56C,\r\n\t0x9DE5, 0xC56D, 0x9DE6, 0xC56E, 0x9DE7, 0xC56F, 0x9DE8, 0xC572,\t0x9DE9, 0xC576, 0x9DEA, 0xC577, 0x9DEB, 0xC578, 0x9DEC, 0xC579,\r\n\t0x9DED, 0xC57A, 0x9DEE, 0xC57B, 0x9DEF, 0xC57E, 0x9DF0, 0xC57F,\t0x9DF1, 0xC581, 0x9DF2, 0xC582, 0x9DF3, 0xC583, 0x9DF4, 0xC585,\r\n\t0x9DF5, 0xC586, 0x9DF6, 0xC588, 0x9DF7, 0xC589, 0x9DF8, 0xC58A,\t0x9DF9, 0xC58B, 0x9DFA, 0xC58E, 0x9DFB, 0xC590, 0x9DFC, 0xC592,\r\n\t0x9DFD, 0xC593, 0x9DFE, 0xC594, 0x9E41, 0xC596, 0x9E42, 0xC599,\t0x9E43, 0xC59A, 0x9E44, 0xC59B, 0x9E45, 0xC59D, 0x9E46, 0xC59E,\r\n\t0x9E47, 0xC59F, 0x9E48, 0xC5A1, 0x9E49, 0xC5A2, 0x9E4A, 0xC5A3,\t0x9E4B, 0xC5A4, 0x9E4C, 0xC5A5, 0x9E4D, 0xC5A6, 0x9E4E, 0xC5A7,\r\n\t0x9E4F, 0xC5A8, 0x9E50, 0xC5AA, 0x9E51, 0xC5AB, 0x9E52, 0xC5AC,\t0x9E53, 0xC5AD, 0x9E54, 0xC5AE, 0x9E55, 0xC5AF, 0x9E56, 0xC5B0,\r\n\t0x9E57, 0xC5B1, 0x9E58, 0xC5B2, 0x9E59, 0xC5B3, 0x9E5A, 0xC5B6,\t0x9E61, 0xC5B7, 0x9E62, 0xC5BA, 0x9E63, 0xC5BF, 0x9E64, 0xC5C0,\r\n\t0x9E65, 0xC5C1, 0x9E66, 0xC5C2, 0x9E67, 0xC5C3, 0x9E68, 0xC5CB,\t0x9E69, 0xC5CD, 0x9E6A, 0xC5CF, 0x9E6B, 0xC5D2, 0x9E6C, 0xC5D3,\r\n\t0x9E6D, 0xC5D5, 0x9E6E, 0xC5D6, 0x9E6F, 0xC5D7, 0x9E70, 0xC5D9,\t0x9E71, 0xC5DA, 0x9E72, 0xC5DB, 0x9E73, 0xC5DC, 0x9E74, 0xC5DD,\r\n\t0x9E75, 0xC5DE, 0x9E76, 0xC5DF, 0x9E77, 0xC5E2, 0x9E78, 0xC5E4,\t0x9E79, 0xC5E6, 0x9E7A, 0xC5E7, 0x9E81, 0xC5E8, 0x9E82, 0xC5E9,\r\n\t0x9E83, 0xC5EA, 0x9E84, 0xC5EB, 0x9E85, 0xC5EF, 0x9E86, 0xC5F1,\t0x9E87, 0xC5F2, 0x9E88, 0xC5F3, 0x9E89, 0xC5F5, 0x9E8A, 0xC5F8,\r\n\t0x9E8B, 0xC5F9, 0x9E8C, 0xC5FA, 0x9E8D, 0xC5FB, 0x9E8E, 0xC602,\t0x9E8F, 0xC603, 0x9E90, 0xC604, 0x9E91, 0xC609, 0x9E92, 0xC60A,\r\n\t0x9E93, 0xC60B, 0x9E94, 0xC60D, 0x9E95, 0xC60E, 0x9E96, 0xC60F,\t0x9E97, 0xC611, 0x9E98, 0xC612, 0x9E99, 0xC613, 0x9E9A, 0xC614,\r\n\t0x9E9B, 0xC615, 0x9E9C, 0xC616, 0x9E9D, 0xC617, 0x9E9E, 0xC61A,\t0x9E9F, 0xC61D, 0x9EA0, 0xC61E, 0x9EA1, 0xC61F, 0x9EA2, 0xC620,\r\n\t0x9EA3, 0xC621, 0x9EA4, 0xC622, 0x9EA5, 0xC623, 0x9EA6, 0xC626,\t0x9EA7, 0xC627, 0x9EA8, 0xC629, 0x9EA9, 0xC62A, 0x9EAA, 0xC62B,\r\n\t0x9EAB, 0xC62F, 0x9EAC, 0xC631, 0x9EAD, 0xC632, 0x9EAE, 0xC636,\t0x9EAF, 0xC638, 0x9EB0, 0xC63A, 0x9EB1, 0xC63C, 0x9EB2, 0xC63D,\r\n\t0x9EB3, 0xC63E, 0x9EB4, 0xC63F, 0x9EB5, 0xC642, 0x9EB6, 0xC643,\t0x9EB7, 0xC645, 0x9EB8, 0xC646, 0x9EB9, 0xC647, 0x9EBA, 0xC649,\r\n\t0x9EBB, 0xC64A, 0x9EBC, 0xC64B, 0x9EBD, 0xC64C, 0x9EBE, 0xC64D,\t0x9EBF, 0xC64E, 0x9EC0, 0xC64F, 0x9EC1, 0xC652, 0x9EC2, 0xC656,\r\n\t0x9EC3, 0xC657, 0x9EC4, 0xC658, 0x9EC5, 0xC659, 0x9EC6, 0xC65A,\t0x9EC7, 0xC65B, 0x9EC8, 0xC65E, 0x9EC9, 0xC65F, 0x9ECA, 0xC661,\r\n\t0x9ECB, 0xC662, 0x9ECC, 0xC663, 0x9ECD, 0xC664, 0x9ECE, 0xC665,\t0x9ECF, 0xC666, 0x9ED0, 0xC667, 0x9ED1, 0xC668, 0x9ED2, 0xC669,\r\n\t0x9ED3, 0xC66A, 0x9ED4, 0xC66B, 0x9ED5, 0xC66D, 0x9ED6, 0xC66E,\t0x9ED7, 0xC670, 0x9ED8, 0xC672, 0x9ED9, 0xC673, 0x9EDA, 0xC674,\r\n\t0x9EDB, 0xC675, 0x9EDC, 0xC676, 0x9EDD, 0xC677, 0x9EDE, 0xC67A,\t0x9EDF, 0xC67B, 0x9EE0, 0xC67D, 0x9EE1, 0xC67E, 0x9EE2, 0xC67F,\r\n\t0x9EE3, 0xC681, 0x9EE4, 0xC682, 0x9EE5, 0xC683, 0x9EE6, 0xC684,\t0x9EE7, 0xC685, 0x9EE8, 0xC686, 0x9EE9, 0xC687, 0x9EEA, 0xC68A,\r\n\t0x9EEB, 0xC68C, 0x9EEC, 0xC68E, 0x9EED, 0xC68F, 0x9EEE, 0xC690,\t0x9EEF, 0xC691, 0x9EF0, 0xC692, 0x9EF1, 0xC693, 0x9EF2, 0xC696,\r\n\t0x9EF3, 0xC697, 0x9EF4, 0xC699, 0x9EF5, 0xC69A, 0x9EF6, 0xC69B,\t0x9EF7, 0xC69D, 0x9EF8, 0xC69E, 0x9EF9, 0xC69F, 0x9EFA, 0xC6A0,\r\n\t0x9EFB, 0xC6A1, 0x9EFC, 0xC6A2, 0x9EFD, 0xC6A3, 0x9EFE, 0xC6A6,\t0x9F41, 0xC6A8, 0x9F42, 0xC6AA, 0x9F43, 0xC6AB, 0x9F44, 0xC6AC,\r\n\t0x9F45, 0xC6AD, 0x9F46, 0xC6AE, 0x9F47, 0xC6AF, 0x9F48, 0xC6B2,\t0x9F49, 0xC6B3, 0x9F4A, 0xC6B5, 0x9F4B, 0xC6B6, 0x9F4C, 0xC6B7,\r\n\t0x9F4D, 0xC6BB, 0x9F4E, 0xC6BC, 0x9F4F, 0xC6BD, 0x9F50, 0xC6BE,\t0x9F51, 0xC6BF, 0x9F52, 0xC6C2, 0x9F53, 0xC6C4, 0x9F54, 0xC6C6,\r\n\t0x9F55, 0xC6C7, 0x9F56, 0xC6C8, 0x9F57, 0xC6C9, 0x9F58, 0xC6CA,\t0x9F59, 0xC6CB, 0x9F5A, 0xC6CE, 0x9F61, 0xC6CF, 0x9F62, 0xC6D1,\r\n\t0x9F63, 0xC6D2, 0x9F64, 0xC6D3, 0x9F65, 0xC6D5, 0x9F66, 0xC6D6,\t0x9F67, 0xC6D7, 0x9F68, 0xC6D8, 0x9F69, 0xC6D9, 0x9F6A, 0xC6DA,\r\n\t0x9F6B, 0xC6DB, 0x9F6C, 0xC6DE, 0x9F6D, 0xC6DF, 0x9F6E, 0xC6E2,\t0x9F6F, 0xC6E3, 0x9F70, 0xC6E4, 0x9F71, 0xC6E5, 0x9F72, 0xC6E6,\r\n\t0x9F73, 0xC6E7, 0x9F74, 0xC6EA, 0x9F75, 0xC6EB, 0x9F76, 0xC6ED,\t0x9F77, 0xC6EE, 0x9F78, 0xC6EF, 0x9F79, 0xC6F1, 0x9F7A, 0xC6F2,\r\n\t0x9F81, 0xC6F3, 0x9F82, 0xC6F4, 0x9F83, 0xC6F5, 0x9F84, 0xC6F6,\t0x9F85, 0xC6F7, 0x9F86, 0xC6FA, 0x9F87, 0xC6FB, 0x9F88, 0xC6FC,\r\n\t0x9F89, 0xC6FE, 0x9F8A, 0xC6FF, 0x9F8B, 0xC700, 0x9F8C, 0xC701,\t0x9F8D, 0xC702, 0x9F8E, 0xC703, 0x9F8F, 0xC706, 0x9F90, 0xC707,\r\n\t0x9F91, 0xC709, 0x9F92, 0xC70A, 0x9F93, 0xC70B, 0x9F94, 0xC70D,\t0x9F95, 0xC70E, 0x9F96, 0xC70F, 0x9F97, 0xC710, 0x9F98, 0xC711,\r\n\t0x9F99, 0xC712, 0x9F9A, 0xC713, 0x9F9B, 0xC716, 0x9F9C, 0xC718,\t0x9F9D, 0xC71A, 0x9F9E, 0xC71B, 0x9F9F, 0xC71C, 0x9FA0, 0xC71D,\r\n\t0x9FA1, 0xC71E, 0x9FA2, 0xC71F, 0x9FA3, 0xC722, 0x9FA4, 0xC723,\t0x9FA5, 0xC725, 0x9FA6, 0xC726, 0x9FA7, 0xC727, 0x9FA8, 0xC729,\r\n\t0x9FA9, 0xC72A, 0x9FAA, 0xC72B, 0x9FAB, 0xC72C, 0x9FAC, 0xC72D,\t0x9FAD, 0xC72E, 0x9FAE, 0xC72F, 0x9FAF, 0xC732, 0x9FB0, 0xC734,\r\n\t0x9FB1, 0xC736, 0x9FB2, 0xC738, 0x9FB3, 0xC739, 0x9FB4, 0xC73A,\t0x9FB5, 0xC73B, 0x9FB6, 0xC73E, 0x9FB7, 0xC73F, 0x9FB8, 0xC741,\r\n\t0x9FB9, 0xC742, 0x9FBA, 0xC743, 0x9FBB, 0xC745, 0x9FBC, 0xC746,\t0x9FBD, 0xC747, 0x9FBE, 0xC748, 0x9FBF, 0xC749, 0x9FC0, 0xC74B,\r\n\t0x9FC1, 0xC74E, 0x9FC2, 0xC750, 0x9FC3, 0xC759, 0x9FC4, 0xC75A,\t0x9FC5, 0xC75B, 0x9FC6, 0xC75D, 0x9FC7, 0xC75E, 0x9FC8, 0xC75F,\r\n\t0x9FC9, 0xC761, 0x9FCA, 0xC762, 0x9FCB, 0xC763, 0x9FCC, 0xC764,\t0x9FCD, 0xC765, 0x9FCE, 0xC766, 0x9FCF, 0xC767, 0x9FD0, 0xC769,\r\n\t0x9FD1, 0xC76A, 0x9FD2, 0xC76C, 0x9FD3, 0xC76D, 0x9FD4, 0xC76E,\t0x9FD5, 0xC76F, 0x9FD6, 0xC770, 0x9FD7, 0xC771, 0x9FD8, 0xC772,\r\n\t0x9FD9, 0xC773, 0x9FDA, 0xC776, 0x9FDB, 0xC777, 0x9FDC, 0xC779,\t0x9FDD, 0xC77A, 0x9FDE, 0xC77B, 0x9FDF, 0xC77F, 0x9FE0, 0xC780,\r\n\t0x9FE1, 0xC781, 0x9FE2, 0xC782, 0x9FE3, 0xC786, 0x9FE4, 0xC78B,\t0x9FE5, 0xC78C, 0x9FE6, 0xC78D, 0x9FE7, 0xC78F, 0x9FE8, 0xC792,\r\n\t0x9FE9, 0xC793, 0x9FEA, 0xC795, 0x9FEB, 0xC799, 0x9FEC, 0xC79B,\t0x9FED, 0xC79C, 0x9FEE, 0xC79D, 0x9FEF, 0xC79E, 0x9FF0, 0xC79F,\r\n\t0x9FF1, 0xC7A2, 0x9FF2, 0xC7A7, 0x9FF3, 0xC7A8, 0x9FF4, 0xC7A9,\t0x9FF5, 0xC7AA, 0x9FF6, 0xC7AB, 0x9FF7, 0xC7AE, 0x9FF8, 0xC7AF,\r\n\t0x9FF9, 0xC7B1, 0x9FFA, 0xC7B2, 0x9FFB, 0xC7B3, 0x9FFC, 0xC7B5,\t0x9FFD, 0xC7B6, 0x9FFE, 0xC7B7, 0xA041, 0xC7B8, 0xA042, 0xC7B9,\r\n\t0xA043, 0xC7BA, 0xA044, 0xC7BB, 0xA045, 0xC7BE, 0xA046, 0xC7C2,\t0xA047, 0xC7C3, 0xA048, 0xC7C4, 0xA049, 0xC7C5, 0xA04A, 0xC7C6,\r\n\t0xA04B, 0xC7C7, 0xA04C, 0xC7CA, 0xA04D, 0xC7CB, 0xA04E, 0xC7CD,\t0xA04F, 0xC7CF, 0xA050, 0xC7D1, 0xA051, 0xC7D2, 0xA052, 0xC7D3,\r\n\t0xA053, 0xC7D4, 0xA054, 0xC7D5, 0xA055, 0xC7D6, 0xA056, 0xC7D7,\t0xA057, 0xC7D9, 0xA058, 0xC7DA, 0xA059, 0xC7DB, 0xA05A, 0xC7DC,\r\n\t0xA061, 0xC7DE, 0xA062, 0xC7DF, 0xA063, 0xC7E0, 0xA064, 0xC7E1,\t0xA065, 0xC7E2, 0xA066, 0xC7E3, 0xA067, 0xC7E5, 0xA068, 0xC7E6,\r\n\t0xA069, 0xC7E7, 0xA06A, 0xC7E9, 0xA06B, 0xC7EA, 0xA06C, 0xC7EB,\t0xA06D, 0xC7ED, 0xA06E, 0xC7EE, 0xA06F, 0xC7EF, 0xA070, 0xC7F0,\r\n\t0xA071, 0xC7F1, 0xA072, 0xC7F2, 0xA073, 0xC7F3, 0xA074, 0xC7F4,\t0xA075, 0xC7F5, 0xA076, 0xC7F6, 0xA077, 0xC7F7, 0xA078, 0xC7F8,\r\n\t0xA079, 0xC7F9, 0xA07A, 0xC7FA, 0xA081, 0xC7FB, 0xA082, 0xC7FC,\t0xA083, 0xC7FD, 0xA084, 0xC7FE, 0xA085, 0xC7FF, 0xA086, 0xC802,\r\n\t0xA087, 0xC803, 0xA088, 0xC805, 0xA089, 0xC806, 0xA08A, 0xC807,\t0xA08B, 0xC809, 0xA08C, 0xC80B, 0xA08D, 0xC80C, 0xA08E, 0xC80D,\r\n\t0xA08F, 0xC80E, 0xA090, 0xC80F, 0xA091, 0xC812, 0xA092, 0xC814,\t0xA093, 0xC817, 0xA094, 0xC818, 0xA095, 0xC819, 0xA096, 0xC81A,\r\n\t0xA097, 0xC81B, 0xA098, 0xC81E, 0xA099, 0xC81F, 0xA09A, 0xC821,\t0xA09B, 0xC822, 0xA09C, 0xC823, 0xA09D, 0xC825, 0xA09E, 0xC826,\r\n\t0xA09F, 0xC827, 0xA0A0, 0xC828, 0xA0A1, 0xC829, 0xA0A2, 0xC82A,\t0xA0A3, 0xC82B, 0xA0A4, 0xC82E, 0xA0A5, 0xC830, 0xA0A6, 0xC832,\r\n\t0xA0A7, 0xC833, 0xA0A8, 0xC834, 0xA0A9, 0xC835, 0xA0AA, 0xC836,\t0xA0AB, 0xC837, 0xA0AC, 0xC839, 0xA0AD, 0xC83A, 0xA0AE, 0xC83B,\r\n\t0xA0AF, 0xC83D, 0xA0B0, 0xC83E, 0xA0B1, 0xC83F, 0xA0B2, 0xC841,\t0xA0B3, 0xC842, 0xA0B4, 0xC843, 0xA0B5, 0xC844, 0xA0B6, 0xC845,\r\n\t0xA0B7, 0xC846, 0xA0B8, 0xC847, 0xA0B9, 0xC84A, 0xA0BA, 0xC84B,\t0xA0BB, 0xC84E, 0xA0BC, 0xC84F, 0xA0BD, 0xC850, 0xA0BE, 0xC851,\r\n\t0xA0BF, 0xC852, 0xA0C0, 0xC853, 0xA0C1, 0xC855, 0xA0C2, 0xC856,\t0xA0C3, 0xC857, 0xA0C4, 0xC858, 0xA0C5, 0xC859, 0xA0C6, 0xC85A,\r\n\t0xA0C7, 0xC85B, 0xA0C8, 0xC85C, 0xA0C9, 0xC85D, 0xA0CA, 0xC85E,\t0xA0CB, 0xC85F, 0xA0CC, 0xC860, 0xA0CD, 0xC861, 0xA0CE, 0xC862,\r\n\t0xA0CF, 0xC863, 0xA0D0, 0xC864, 0xA0D1, 0xC865, 0xA0D2, 0xC866,\t0xA0D3, 0xC867, 0xA0D4, 0xC868, 0xA0D5, 0xC869, 0xA0D6, 0xC86A,\r\n\t0xA0D7, 0xC86B, 0xA0D8, 0xC86C, 0xA0D9, 0xC86D, 0xA0DA, 0xC86E,\t0xA0DB, 0xC86F, 0xA0DC, 0xC872, 0xA0DD, 0xC873, 0xA0DE, 0xC875,\r\n\t0xA0DF, 0xC876, 0xA0E0, 0xC877, 0xA0E1, 0xC879, 0xA0E2, 0xC87B,\t0xA0E3, 0xC87C, 0xA0E4, 0xC87D, 0xA0E5, 0xC87E, 0xA0E6, 0xC87F,\r\n\t0xA0E7, 0xC882, 0xA0E8, 0xC884, 0xA0E9, 0xC888, 0xA0EA, 0xC889,\t0xA0EB, 0xC88A, 0xA0EC, 0xC88E, 0xA0ED, 0xC88F, 0xA0EE, 0xC890,\r\n\t0xA0EF, 0xC891, 0xA0F0, 0xC892, 0xA0F1, 0xC893, 0xA0F2, 0xC895,\t0xA0F3, 0xC896, 0xA0F4, 0xC897, 0xA0F5, 0xC898, 0xA0F6, 0xC899,\r\n\t0xA0F7, 0xC89A, 0xA0F8, 0xC89B, 0xA0F9, 0xC89C, 0xA0FA, 0xC89E,\t0xA0FB, 0xC8A0, 0xA0FC, 0xC8A2, 0xA0FD, 0xC8A3, 0xA0FE, 0xC8A4,\r\n\t0xA141, 0xC8A5, 0xA142, 0xC8A6, 0xA143, 0xC8A7, 0xA144, 0xC8A9,\t0xA145, 0xC8AA, 0xA146, 0xC8AB, 0xA147, 0xC8AC, 0xA148, 0xC8AD,\r\n\t0xA149, 0xC8AE, 0xA14A, 0xC8AF, 0xA14B, 0xC8B0, 0xA14C, 0xC8B1,\t0xA14D, 0xC8B2, 0xA14E, 0xC8B3, 0xA14F, 0xC8B4, 0xA150, 0xC8B5,\r\n\t0xA151, 0xC8B6, 0xA152, 0xC8B7, 0xA153, 0xC8B8, 0xA154, 0xC8B9,\t0xA155, 0xC8BA, 0xA156, 0xC8BB, 0xA157, 0xC8BE, 0xA158, 0xC8BF,\r\n\t0xA159, 0xC8C0, 0xA15A, 0xC8C1, 0xA161, 0xC8C2, 0xA162, 0xC8C3,\t0xA163, 0xC8C5, 0xA164, 0xC8C6, 0xA165, 0xC8C7, 0xA166, 0xC8C9,\r\n\t0xA167, 0xC8CA, 0xA168, 0xC8CB, 0xA169, 0xC8CD, 0xA16A, 0xC8CE,\t0xA16B, 0xC8CF, 0xA16C, 0xC8D0, 0xA16D, 0xC8D1, 0xA16E, 0xC8D2,\r\n\t0xA16F, 0xC8D3, 0xA170, 0xC8D6, 0xA171, 0xC8D8, 0xA172, 0xC8DA,\t0xA173, 0xC8DB, 0xA174, 0xC8DC, 0xA175, 0xC8DD, 0xA176, 0xC8DE,\r\n\t0xA177, 0xC8DF, 0xA178, 0xC8E2, 0xA179, 0xC8E3, 0xA17A, 0xC8E5,\t0xA181, 0xC8E6, 0xA182, 0xC8E7, 0xA183, 0xC8E8, 0xA184, 0xC8E9,\r\n\t0xA185, 0xC8EA, 0xA186, 0xC8EB, 0xA187, 0xC8EC, 0xA188, 0xC8ED,\t0xA189, 0xC8EE, 0xA18A, 0xC8EF, 0xA18B, 0xC8F0, 0xA18C, 0xC8F1,\r\n\t0xA18D, 0xC8F2, 0xA18E, 0xC8F3, 0xA18F, 0xC8F4, 0xA190, 0xC8F6,\t0xA191, 0xC8F7, 0xA192, 0xC8F8, 0xA193, 0xC8F9, 0xA194, 0xC8FA,\r\n\t0xA195, 0xC8FB, 0xA196, 0xC8FE, 0xA197, 0xC8FF, 0xA198, 0xC901,\t0xA199, 0xC902, 0xA19A, 0xC903, 0xA19B, 0xC907, 0xA19C, 0xC908,\r\n\t0xA19D, 0xC909, 0xA19E, 0xC90A, 0xA19F, 0xC90B, 0xA1A0, 0xC90E,\t0xA1A1, 0x3000, 0xA1A2, 0x3001, 0xA1A3, 0x3002, 0xA1A4, 0x00B7,\r\n\t0xA1A5, 0x2025, 0xA1A6, 0x2026, 0xA1A7, 0x00A8, 0xA1A8, 0x3003,\t0xA1A9, 0x00AD, 0xA1AA, 0x2015, 0xA1AB, 0x2225, 0xA1AC, 0xFF3C,\r\n\t0xA1AD, 0x223C, 0xA1AE, 0x2018, 0xA1AF, 0x2019, 0xA1B0, 0x201C,\t0xA1B1, 0x201D, 0xA1B2, 0x3014, 0xA1B3, 0x3015, 0xA1B4, 0x3008,\r\n\t0xA1B5, 0x3009, 0xA1B6, 0x300A, 0xA1B7, 0x300B, 0xA1B8, 0x300C,\t0xA1B9, 0x300D, 0xA1BA, 0x300E, 0xA1BB, 0x300F, 0xA1BC, 0x3010,\r\n\t0xA1BD, 0x3011, 0xA1BE, 0x00B1, 0xA1BF, 0x00D7, 0xA1C0, 0x00F7,\t0xA1C1, 0x2260, 0xA1C2, 0x2264, 0xA1C3, 0x2265, 0xA1C4, 0x221E,\r\n\t0xA1C5, 0x2234, 0xA1C6, 0x00B0, 0xA1C7, 0x2032, 0xA1C8, 0x2033,\t0xA1C9, 0x2103, 0xA1CA, 0x212B, 0xA1CB, 0xFFE0, 0xA1CC, 0xFFE1,\r\n\t0xA1CD, 0xFFE5, 0xA1CE, 0x2642, 0xA1CF, 0x2640, 0xA1D0, 0x2220,\t0xA1D1, 0x22A5, 0xA1D2, 0x2312, 0xA1D3, 0x2202, 0xA1D4, 0x2207,\r\n\t0xA1D5, 0x2261, 0xA1D6, 0x2252, 0xA1D7, 0x00A7, 0xA1D8, 0x203B,\t0xA1D9, 0x2606, 0xA1DA, 0x2605, 0xA1DB, 0x25CB, 0xA1DC, 0x25CF,\r\n\t0xA1DD, 0x25CE, 0xA1DE, 0x25C7, 0xA1DF, 0x25C6, 0xA1E0, 0x25A1,\t0xA1E1, 0x25A0, 0xA1E2, 0x25B3, 0xA1E3, 0x25B2, 0xA1E4, 0x25BD,\r\n\t0xA1E5, 0x25BC, 0xA1E6, 0x2192, 0xA1E7, 0x2190, 0xA1E8, 0x2191,\t0xA1E9, 0x2193, 0xA1EA, 0x2194, 0xA1EB, 0x3013, 0xA1EC, 0x226A,\r\n\t0xA1ED, 0x226B, 0xA1EE, 0x221A, 0xA1EF, 0x223D, 0xA1F0, 0x221D,\t0xA1F1, 0x2235, 0xA1F2, 0x222B, 0xA1F3, 0x222C, 0xA1F4, 0x2208,\r\n\t0xA1F5, 0x220B, 0xA1F6, 0x2286, 0xA1F7, 0x2287, 0xA1F8, 0x2282,\t0xA1F9, 0x2283, 0xA1FA, 0x222A, 0xA1FB, 0x2229, 0xA1FC, 0x2227,\r\n\t0xA1FD, 0x2228, 0xA1FE, 0xFFE2, 0xA241, 0xC910, 0xA242, 0xC912,\t0xA243, 0xC913, 0xA244, 0xC914, 0xA245, 0xC915, 0xA246, 0xC916,\r\n\t0xA247, 0xC917, 0xA248, 0xC919, 0xA249, 0xC91A, 0xA24A, 0xC91B,\t0xA24B, 0xC91C, 0xA24C, 0xC91D, 0xA24D, 0xC91E, 0xA24E, 0xC91F,\r\n\t0xA24F, 0xC920, 0xA250, 0xC921, 0xA251, 0xC922, 0xA252, 0xC923,\t0xA253, 0xC924, 0xA254, 0xC925, 0xA255, 0xC926, 0xA256, 0xC927,\r\n\t0xA257, 0xC928, 0xA258, 0xC929, 0xA259, 0xC92A, 0xA25A, 0xC92B,\t0xA261, 0xC92D, 0xA262, 0xC92E, 0xA263, 0xC92F, 0xA264, 0xC930,\r\n\t0xA265, 0xC931, 0xA266, 0xC932, 0xA267, 0xC933, 0xA268, 0xC935,\t0xA269, 0xC936, 0xA26A, 0xC937, 0xA26B, 0xC938, 0xA26C, 0xC939,\r\n\t0xA26D, 0xC93A, 0xA26E, 0xC93B, 0xA26F, 0xC93C, 0xA270, 0xC93D,\t0xA271, 0xC93E, 0xA272, 0xC93F, 0xA273, 0xC940, 0xA274, 0xC941,\r\n\t0xA275, 0xC942, 0xA276, 0xC943, 0xA277, 0xC944, 0xA278, 0xC945,\t0xA279, 0xC946, 0xA27A, 0xC947, 0xA281, 0xC948, 0xA282, 0xC949,\r\n\t0xA283, 0xC94A, 0xA284, 0xC94B, 0xA285, 0xC94C, 0xA286, 0xC94D,\t0xA287, 0xC94E, 0xA288, 0xC94F, 0xA289, 0xC952, 0xA28A, 0xC953,\r\n\t0xA28B, 0xC955, 0xA28C, 0xC956, 0xA28D, 0xC957, 0xA28E, 0xC959,\t0xA28F, 0xC95A, 0xA290, 0xC95B, 0xA291, 0xC95C, 0xA292, 0xC95D,\r\n\t0xA293, 0xC95E, 0xA294, 0xC95F, 0xA295, 0xC962, 0xA296, 0xC964,\t0xA297, 0xC965, 0xA298, 0xC966, 0xA299, 0xC967, 0xA29A, 0xC968,\r\n\t0xA29B, 0xC969, 0xA29C, 0xC96A, 0xA29D, 0xC96B, 0xA29E, 0xC96D,\t0xA29F, 0xC96E, 0xA2A0, 0xC96F, 0xA2A1, 0x21D2, 0xA2A2, 0x21D4,\r\n\t0xA2A3, 0x2200, 0xA2A4, 0x2203, 0xA2A5, 0x00B4, 0xA2A6, 0xFF5E,\t0xA2A7, 0x02C7, 0xA2A8, 0x02D8, 0xA2A9, 0x02DD, 0xA2AA, 0x02DA,\r\n\t0xA2AB, 0x02D9, 0xA2AC, 0x00B8, 0xA2AD, 0x02DB, 0xA2AE, 0x00A1,\t0xA2AF, 0x00BF, 0xA2B0, 0x02D0, 0xA2B1, 0x222E, 0xA2B2, 0x2211,\r\n\t0xA2B3, 0x220F, 0xA2B4, 0x00A4, 0xA2B5, 0x2109, 0xA2B6, 0x2030,\t0xA2B7, 0x25C1, 0xA2B8, 0x25C0, 0xA2B9, 0x25B7, 0xA2BA, 0x25B6,\r\n\t0xA2BB, 0x2664, 0xA2BC, 0x2660, 0xA2BD, 0x2661, 0xA2BE, 0x2665,\t0xA2BF, 0x2667, 0xA2C0, 0x2663, 0xA2C1, 0x2299, 0xA2C2, 0x25C8,\r\n\t0xA2C3, 0x25A3, 0xA2C4, 0x25D0, 0xA2C5, 0x25D1, 0xA2C6, 0x2592,\t0xA2C7, 0x25A4, 0xA2C8, 0x25A5, 0xA2C9, 0x25A8, 0xA2CA, 0x25A7,\r\n\t0xA2CB, 0x25A6, 0xA2CC, 0x25A9, 0xA2CD, 0x2668, 0xA2CE, 0x260F,\t0xA2CF, 0x260E, 0xA2D0, 0x261C, 0xA2D1, 0x261E, 0xA2D2, 0x00B6,\r\n\t0xA2D3, 0x2020, 0xA2D4, 0x2021, 0xA2D5, 0x2195, 0xA2D6, 0x2197,\t0xA2D7, 0x2199, 0xA2D8, 0x2196, 0xA2D9, 0x2198, 0xA2DA, 0x266D,\r\n\t0xA2DB, 0x2669, 0xA2DC, 0x266A, 0xA2DD, 0x266C, 0xA2DE, 0x327F,\t0xA2DF, 0x321C, 0xA2E0, 0x2116, 0xA2E1, 0x33C7, 0xA2E2, 0x2122,\r\n\t0xA2E3, 0x33C2, 0xA2E4, 0x33D8, 0xA2E5, 0x2121, 0xA2E6, 0x20AC,\t0xA2E7, 0x00AE, 0xA341, 0xC971, 0xA342, 0xC972, 0xA343, 0xC973,\r\n\t0xA344, 0xC975, 0xA345, 0xC976, 0xA346, 0xC977, 0xA347, 0xC978,\t0xA348, 0xC979, 0xA349, 0xC97A, 0xA34A, 0xC97B, 0xA34B, 0xC97D,\r\n\t0xA34C, 0xC97E, 0xA34D, 0xC97F, 0xA34E, 0xC980, 0xA34F, 0xC981,\t0xA350, 0xC982, 0xA351, 0xC983, 0xA352, 0xC984, 0xA353, 0xC985,\r\n\t0xA354, 0xC986, 0xA355, 0xC987, 0xA356, 0xC98A, 0xA357, 0xC98B,\t0xA358, 0xC98D, 0xA359, 0xC98E, 0xA35A, 0xC98F, 0xA361, 0xC991,\r\n\t0xA362, 0xC992, 0xA363, 0xC993, 0xA364, 0xC994, 0xA365, 0xC995,\t0xA366, 0xC996, 0xA367, 0xC997, 0xA368, 0xC99A, 0xA369, 0xC99C,\r\n\t0xA36A, 0xC99E, 0xA36B, 0xC99F, 0xA36C, 0xC9A0, 0xA36D, 0xC9A1,\t0xA36E, 0xC9A2, 0xA36F, 0xC9A3, 0xA370, 0xC9A4, 0xA371, 0xC9A5,\r\n\t0xA372, 0xC9A6, 0xA373, 0xC9A7, 0xA374, 0xC9A8, 0xA375, 0xC9A9,\t0xA376, 0xC9AA, 0xA377, 0xC9AB, 0xA378, 0xC9AC, 0xA379, 0xC9AD,\r\n\t0xA37A, 0xC9AE, 0xA381, 0xC9AF, 0xA382, 0xC9B0, 0xA383, 0xC9B1,\t0xA384, 0xC9B2, 0xA385, 0xC9B3, 0xA386, 0xC9B4, 0xA387, 0xC9B5,\r\n\t0xA388, 0xC9B6, 0xA389, 0xC9B7, 0xA38A, 0xC9B8, 0xA38B, 0xC9B9,\t0xA38C, 0xC9BA, 0xA38D, 0xC9BB, 0xA38E, 0xC9BC, 0xA38F, 0xC9BD,\r\n\t0xA390, 0xC9BE, 0xA391, 0xC9BF, 0xA392, 0xC9C2, 0xA393, 0xC9C3,\t0xA394, 0xC9C5, 0xA395, 0xC9C6, 0xA396, 0xC9C9, 0xA397, 0xC9CB,\r\n\t0xA398, 0xC9CC, 0xA399, 0xC9CD, 0xA39A, 0xC9CE, 0xA39B, 0xC9CF,\t0xA39C, 0xC9D2, 0xA39D, 0xC9D4, 0xA39E, 0xC9D7, 0xA39F, 0xC9D8,\r\n\t0xA3A0, 0xC9DB, 0xA3A1, 0xFF01, 0xA3A2, 0xFF02, 0xA3A3, 0xFF03,\t0xA3A4, 0xFF04, 0xA3A5, 0xFF05, 0xA3A6, 0xFF06, 0xA3A7, 0xFF07,\r\n\t0xA3A8, 0xFF08, 0xA3A9, 0xFF09, 0xA3AA, 0xFF0A, 0xA3AB, 0xFF0B,\t0xA3AC, 0xFF0C, 0xA3AD, 0xFF0D, 0xA3AE, 0xFF0E, 0xA3AF, 0xFF0F,\r\n\t0xA3B0, 0xFF10, 0xA3B1, 0xFF11, 0xA3B2, 0xFF12, 0xA3B3, 0xFF13,\t0xA3B4, 0xFF14, 0xA3B5, 0xFF15, 0xA3B6, 0xFF16, 0xA3B7, 0xFF17,\r\n\t0xA3B8, 0xFF18, 0xA3B9, 0xFF19, 0xA3BA, 0xFF1A, 0xA3BB, 0xFF1B,\t0xA3BC, 0xFF1C, 0xA3BD, 0xFF1D, 0xA3BE, 0xFF1E, 0xA3BF, 0xFF1F,\r\n\t0xA3C0, 0xFF20, 0xA3C1, 0xFF21, 0xA3C2, 0xFF22, 0xA3C3, 0xFF23,\t0xA3C4, 0xFF24, 0xA3C5, 0xFF25, 0xA3C6, 0xFF26, 0xA3C7, 0xFF27,\r\n\t0xA3C8, 0xFF28, 0xA3C9, 0xFF29, 0xA3CA, 0xFF2A, 0xA3CB, 0xFF2B,\t0xA3CC, 0xFF2C, 0xA3CD, 0xFF2D, 0xA3CE, 0xFF2E, 0xA3CF, 0xFF2F,\r\n\t0xA3D0, 0xFF30, 0xA3D1, 0xFF31, 0xA3D2, 0xFF32, 0xA3D3, 0xFF33,\t0xA3D4, 0xFF34, 0xA3D5, 0xFF35, 0xA3D6, 0xFF36, 0xA3D7, 0xFF37,\r\n\t0xA3D8, 0xFF38, 0xA3D9, 0xFF39, 0xA3DA, 0xFF3A, 0xA3DB, 0xFF3B,\t0xA3DC, 0xFFE6, 0xA3DD, 0xFF3D, 0xA3DE, 0xFF3E, 0xA3DF, 0xFF3F,\r\n\t0xA3E0, 0xFF40, 0xA3E1, 0xFF41, 0xA3E2, 0xFF42, 0xA3E3, 0xFF43,\t0xA3E4, 0xFF44, 0xA3E5, 0xFF45, 0xA3E6, 0xFF46, 0xA3E7, 0xFF47,\r\n\t0xA3E8, 0xFF48, 0xA3E9, 0xFF49, 0xA3EA, 0xFF4A, 0xA3EB, 0xFF4B,\t0xA3EC, 0xFF4C, 0xA3ED, 0xFF4D, 0xA3EE, 0xFF4E, 0xA3EF, 0xFF4F,\r\n\t0xA3F0, 0xFF50, 0xA3F1, 0xFF51, 0xA3F2, 0xFF52, 0xA3F3, 0xFF53,\t0xA3F4, 0xFF54, 0xA3F5, 0xFF55, 0xA3F6, 0xFF56, 0xA3F7, 0xFF57,\r\n\t0xA3F8, 0xFF58, 0xA3F9, 0xFF59, 0xA3FA, 0xFF5A, 0xA3FB, 0xFF5B,\t0xA3FC, 0xFF5C, 0xA3FD, 0xFF5D, 0xA3FE, 0xFFE3, 0xA441, 0xC9DE,\r\n\t0xA442, 0xC9DF, 0xA443, 0xC9E1, 0xA444, 0xC9E3, 0xA445, 0xC9E5,\t0xA446, 0xC9E6, 0xA447, 0xC9E8, 0xA448, 0xC9E9, 0xA449, 0xC9EA,\r\n\t0xA44A, 0xC9EB, 0xA44B, 0xC9EE, 0xA44C, 0xC9F2, 0xA44D, 0xC9F3,\t0xA44E, 0xC9F4, 0xA44F, 0xC9F5, 0xA450, 0xC9F6, 0xA451, 0xC9F7,\r\n\t0xA452, 0xC9FA, 0xA453, 0xC9FB, 0xA454, 0xC9FD, 0xA455, 0xC9FE,\t0xA456, 0xC9FF, 0xA457, 0xCA01, 0xA458, 0xCA02, 0xA459, 0xCA03,\r\n\t0xA45A, 0xCA04, 0xA461, 0xCA05, 0xA462, 0xCA06, 0xA463, 0xCA07,\t0xA464, 0xCA0A, 0xA465, 0xCA0E, 0xA466, 0xCA0F, 0xA467, 0xCA10,\r\n\t0xA468, 0xCA11, 0xA469, 0xCA12, 0xA46A, 0xCA13, 0xA46B, 0xCA15,\t0xA46C, 0xCA16, 0xA46D, 0xCA17, 0xA46E, 0xCA19, 0xA46F, 0xCA1A,\r\n\t0xA470, 0xCA1B, 0xA471, 0xCA1C, 0xA472, 0xCA1D, 0xA473, 0xCA1E,\t0xA474, 0xCA1F, 0xA475, 0xCA20, 0xA476, 0xCA21, 0xA477, 0xCA22,\r\n\t0xA478, 0xCA23, 0xA479, 0xCA24, 0xA47A, 0xCA25, 0xA481, 0xCA26,\t0xA482, 0xCA27, 0xA483, 0xCA28, 0xA484, 0xCA2A, 0xA485, 0xCA2B,\r\n\t0xA486, 0xCA2C, 0xA487, 0xCA2D, 0xA488, 0xCA2E, 0xA489, 0xCA2F,\t0xA48A, 0xCA30, 0xA48B, 0xCA31, 0xA48C, 0xCA32, 0xA48D, 0xCA33,\r\n\t0xA48E, 0xCA34, 0xA48F, 0xCA35, 0xA490, 0xCA36, 0xA491, 0xCA37,\t0xA492, 0xCA38, 0xA493, 0xCA39, 0xA494, 0xCA3A, 0xA495, 0xCA3B,\r\n\t0xA496, 0xCA3C, 0xA497, 0xCA3D, 0xA498, 0xCA3E, 0xA499, 0xCA3F,\t0xA49A, 0xCA40, 0xA49B, 0xCA41, 0xA49C, 0xCA42, 0xA49D, 0xCA43,\r\n\t0xA49E, 0xCA44, 0xA49F, 0xCA45, 0xA4A0, 0xCA46, 0xA4A1, 0x3131,\t0xA4A2, 0x3132, 0xA4A3, 0x3133, 0xA4A4, 0x3134, 0xA4A5, 0x3135,\r\n\t0xA4A6, 0x3136, 0xA4A7, 0x3137, 0xA4A8, 0x3138, 0xA4A9, 0x3139,\t0xA4AA, 0x313A, 0xA4AB, 0x313B, 0xA4AC, 0x313C, 0xA4AD, 0x313D,\r\n\t0xA4AE, 0x313E, 0xA4AF, 0x313F, 0xA4B0, 0x3140, 0xA4B1, 0x3141,\t0xA4B2, 0x3142, 0xA4B3, 0x3143, 0xA4B4, 0x3144, 0xA4B5, 0x3145,\r\n\t0xA4B6, 0x3146, 0xA4B7, 0x3147, 0xA4B8, 0x3148, 0xA4B9, 0x3149,\t0xA4BA, 0x314A, 0xA4BB, 0x314B, 0xA4BC, 0x314C, 0xA4BD, 0x314D,\r\n\t0xA4BE, 0x314E, 0xA4BF, 0x314F, 0xA4C0, 0x3150, 0xA4C1, 0x3151,\t0xA4C2, 0x3152, 0xA4C3, 0x3153, 0xA4C4, 0x3154, 0xA4C5, 0x3155,\r\n\t0xA4C6, 0x3156, 0xA4C7, 0x3157, 0xA4C8, 0x3158, 0xA4C9, 0x3159,\t0xA4CA, 0x315A, 0xA4CB, 0x315B, 0xA4CC, 0x315C, 0xA4CD, 0x315D,\r\n\t0xA4CE, 0x315E, 0xA4CF, 0x315F, 0xA4D0, 0x3160, 0xA4D1, 0x3161,\t0xA4D2, 0x3162, 0xA4D3, 0x3163, 0xA4D4, 0x3164, 0xA4D5, 0x3165,\r\n\t0xA4D6, 0x3166, 0xA4D7, 0x3167, 0xA4D8, 0x3168, 0xA4D9, 0x3169,\t0xA4DA, 0x316A, 0xA4DB, 0x316B, 0xA4DC, 0x316C, 0xA4DD, 0x316D,\r\n\t0xA4DE, 0x316E, 0xA4DF, 0x316F, 0xA4E0, 0x3170, 0xA4E1, 0x3171,\t0xA4E2, 0x3172, 0xA4E3, 0x3173, 0xA4E4, 0x3174, 0xA4E5, 0x3175,\r\n\t0xA4E6, 0x3176, 0xA4E7, 0x3177, 0xA4E8, 0x3178, 0xA4E9, 0x3179,\t0xA4EA, 0x317A, 0xA4EB, 0x317B, 0xA4EC, 0x317C, 0xA4ED, 0x317D,\r\n\t0xA4EE, 0x317E, 0xA4EF, 0x317F, 0xA4F0, 0x3180, 0xA4F1, 0x3181,\t0xA4F2, 0x3182, 0xA4F3, 0x3183, 0xA4F4, 0x3184, 0xA4F5, 0x3185,\r\n\t0xA4F6, 0x3186, 0xA4F7, 0x3187, 0xA4F8, 0x3188, 0xA4F9, 0x3189,\t0xA4FA, 0x318A, 0xA4FB, 0x318B, 0xA4FC, 0x318C, 0xA4FD, 0x318D,\r\n\t0xA4FE, 0x318E, 0xA541, 0xCA47, 0xA542, 0xCA48, 0xA543, 0xCA49,\t0xA544, 0xCA4A, 0xA545, 0xCA4B, 0xA546, 0xCA4E, 0xA547, 0xCA4F,\r\n\t0xA548, 0xCA51, 0xA549, 0xCA52, 0xA54A, 0xCA53, 0xA54B, 0xCA55,\t0xA54C, 0xCA56, 0xA54D, 0xCA57, 0xA54E, 0xCA58, 0xA54F, 0xCA59,\r\n\t0xA550, 0xCA5A, 0xA551, 0xCA5B, 0xA552, 0xCA5E, 0xA553, 0xCA62,\t0xA554, 0xCA63, 0xA555, 0xCA64, 0xA556, 0xCA65, 0xA557, 0xCA66,\r\n\t0xA558, 0xCA67, 0xA559, 0xCA69, 0xA55A, 0xCA6A, 0xA561, 0xCA6B,\t0xA562, 0xCA6C, 0xA563, 0xCA6D, 0xA564, 0xCA6E, 0xA565, 0xCA6F,\r\n\t0xA566, 0xCA70, 0xA567, 0xCA71, 0xA568, 0xCA72, 0xA569, 0xCA73,\t0xA56A, 0xCA74, 0xA56B, 0xCA75, 0xA56C, 0xCA76, 0xA56D, 0xCA77,\r\n\t0xA56E, 0xCA78, 0xA56F, 0xCA79, 0xA570, 0xCA7A, 0xA571, 0xCA7B,\t0xA572, 0xCA7C, 0xA573, 0xCA7E, 0xA574, 0xCA7F, 0xA575, 0xCA80,\r\n\t0xA576, 0xCA81, 0xA577, 0xCA82, 0xA578, 0xCA83, 0xA579, 0xCA85,\t0xA57A, 0xCA86, 0xA581, 0xCA87, 0xA582, 0xCA88, 0xA583, 0xCA89,\r\n\t0xA584, 0xCA8A, 0xA585, 0xCA8B, 0xA586, 0xCA8C, 0xA587, 0xCA8D,\t0xA588, 0xCA8E, 0xA589, 0xCA8F, 0xA58A, 0xCA90, 0xA58B, 0xCA91,\r\n\t0xA58C, 0xCA92, 0xA58D, 0xCA93, 0xA58E, 0xCA94, 0xA58F, 0xCA95,\t0xA590, 0xCA96, 0xA591, 0xCA97, 0xA592, 0xCA99, 0xA593, 0xCA9A,\r\n\t0xA594, 0xCA9B, 0xA595, 0xCA9C, 0xA596, 0xCA9D, 0xA597, 0xCA9E,\t0xA598, 0xCA9F, 0xA599, 0xCAA0, 0xA59A, 0xCAA1, 0xA59B, 0xCAA2,\r\n\t0xA59C, 0xCAA3, 0xA59D, 0xCAA4, 0xA59E, 0xCAA5, 0xA59F, 0xCAA6,\t0xA5A0, 0xCAA7, 0xA5A1, 0x2170, 0xA5A2, 0x2171, 0xA5A3, 0x2172,\r\n\t0xA5A4, 0x2173, 0xA5A5, 0x2174, 0xA5A6, 0x2175, 0xA5A7, 0x2176,\t0xA5A8, 0x2177, 0xA5A9, 0x2178, 0xA5AA, 0x2179, 0xA5B0, 0x2160,\r\n\t0xA5B1, 0x2161, 0xA5B2, 0x2162, 0xA5B3, 0x2163, 0xA5B4, 0x2164,\t0xA5B5, 0x2165, 0xA5B6, 0x2166, 0xA5B7, 0x2167, 0xA5B8, 0x2168,\r\n\t0xA5B9, 0x2169, 0xA5C1, 0x0391, 0xA5C2, 0x0392, 0xA5C3, 0x0393,\t0xA5C4, 0x0394, 0xA5C5, 0x0395, 0xA5C6, 0x0396, 0xA5C7, 0x0397,\r\n\t0xA5C8, 0x0398, 0xA5C9, 0x0399, 0xA5CA, 0x039A, 0xA5CB, 0x039B,\t0xA5CC, 0x039C, 0xA5CD, 0x039D, 0xA5CE, 0x039E, 0xA5CF, 0x039F,\r\n\t0xA5D0, 0x03A0, 0xA5D1, 0x03A1, 0xA5D2, 0x03A3, 0xA5D3, 0x03A4,\t0xA5D4, 0x03A5, 0xA5D5, 0x03A6, 0xA5D6, 0x03A7, 0xA5D7, 0x03A8,\r\n\t0xA5D8, 0x03A9, 0xA5E1, 0x03B1, 0xA5E2, 0x03B2, 0xA5E3, 0x03B3,\t0xA5E4, 0x03B4, 0xA5E5, 0x03B5, 0xA5E6, 0x03B6, 0xA5E7, 0x03B7,\r\n\t0xA5E8, 0x03B8, 0xA5E9, 0x03B9, 0xA5EA, 0x03BA, 0xA5EB, 0x03BB,\t0xA5EC, 0x03BC, 0xA5ED, 0x03BD, 0xA5EE, 0x03BE, 0xA5EF, 0x03BF,\r\n\t0xA5F0, 0x03C0, 0xA5F1, 0x03C1, 0xA5F2, 0x03C3, 0xA5F3, 0x03C4,\t0xA5F4, 0x03C5, 0xA5F5, 0x03C6, 0xA5F6, 0x03C7, 0xA5F7, 0x03C8,\r\n\t0xA5F8, 0x03C9, 0xA641, 0xCAA8, 0xA642, 0xCAA9, 0xA643, 0xCAAA,\t0xA644, 0xCAAB, 0xA645, 0xCAAC, 0xA646, 0xCAAD, 0xA647, 0xCAAE,\r\n\t0xA648, 0xCAAF, 0xA649, 0xCAB0, 0xA64A, 0xCAB1, 0xA64B, 0xCAB2,\t0xA64C, 0xCAB3, 0xA64D, 0xCAB4, 0xA64E, 0xCAB5, 0xA64F, 0xCAB6,\r\n\t0xA650, 0xCAB7, 0xA651, 0xCAB8, 0xA652, 0xCAB9, 0xA653, 0xCABA,\t0xA654, 0xCABB, 0xA655, 0xCABE, 0xA656, 0xCABF, 0xA657, 0xCAC1,\r\n\t0xA658, 0xCAC2, 0xA659, 0xCAC3, 0xA65A, 0xCAC5, 0xA661, 0xCAC6,\t0xA662, 0xCAC7, 0xA663, 0xCAC8, 0xA664, 0xCAC9, 0xA665, 0xCACA,\r\n\t0xA666, 0xCACB, 0xA667, 0xCACE, 0xA668, 0xCAD0, 0xA669, 0xCAD2,\t0xA66A, 0xCAD4, 0xA66B, 0xCAD5, 0xA66C, 0xCAD6, 0xA66D, 0xCAD7,\r\n\t0xA66E, 0xCADA, 0xA66F, 0xCADB, 0xA670, 0xCADC, 0xA671, 0xCADD,\t0xA672, 0xCADE, 0xA673, 0xCADF, 0xA674, 0xCAE1, 0xA675, 0xCAE2,\r\n\t0xA676, 0xCAE3, 0xA677, 0xCAE4, 0xA678, 0xCAE5, 0xA679, 0xCAE6,\t0xA67A, 0xCAE7, 0xA681, 0xCAE8, 0xA682, 0xCAE9, 0xA683, 0xCAEA,\r\n\t0xA684, 0xCAEB, 0xA685, 0xCAED, 0xA686, 0xCAEE, 0xA687, 0xCAEF,\t0xA688, 0xCAF0, 0xA689, 0xCAF1, 0xA68A, 0xCAF2, 0xA68B, 0xCAF3,\r\n\t0xA68C, 0xCAF5, 0xA68D, 0xCAF6, 0xA68E, 0xCAF7, 0xA68F, 0xCAF8,\t0xA690, 0xCAF9, 0xA691, 0xCAFA, 0xA692, 0xCAFB, 0xA693, 0xCAFC,\r\n\t0xA694, 0xCAFD, 0xA695, 0xCAFE, 0xA696, 0xCAFF, 0xA697, 0xCB00,\t0xA698, 0xCB01, 0xA699, 0xCB02, 0xA69A, 0xCB03, 0xA69B, 0xCB04,\r\n\t0xA69C, 0xCB05, 0xA69D, 0xCB06, 0xA69E, 0xCB07, 0xA69F, 0xCB09,\t0xA6A0, 0xCB0A, 0xA6A1, 0x2500, 0xA6A2, 0x2502, 0xA6A3, 0x250C,\r\n\t0xA6A4, 0x2510, 0xA6A5, 0x2518, 0xA6A6, 0x2514, 0xA6A7, 0x251C,\t0xA6A8, 0x252C, 0xA6A9, 0x2524, 0xA6AA, 0x2534, 0xA6AB, 0x253C,\r\n\t0xA6AC, 0x2501, 0xA6AD, 0x2503, 0xA6AE, 0x250F, 0xA6AF, 0x2513,\t0xA6B0, 0x251B, 0xA6B1, 0x2517, 0xA6B2, 0x2523, 0xA6B3, 0x2533,\r\n\t0xA6B4, 0x252B, 0xA6B5, 0x253B, 0xA6B6, 0x254B, 0xA6B7, 0x2520,\t0xA6B8, 0x252F, 0xA6B9, 0x2528, 0xA6BA, 0x2537, 0xA6BB, 0x253F,\r\n\t0xA6BC, 0x251D, 0xA6BD, 0x2530, 0xA6BE, 0x2525, 0xA6BF, 0x2538,\t0xA6C0, 0x2542, 0xA6C1, 0x2512, 0xA6C2, 0x2511, 0xA6C3, 0x251A,\r\n\t0xA6C4, 0x2519, 0xA6C5, 0x2516, 0xA6C6, 0x2515, 0xA6C7, 0x250E,\t0xA6C8, 0x250D, 0xA6C9, 0x251E, 0xA6CA, 0x251F, 0xA6CB, 0x2521,\r\n\t0xA6CC, 0x2522, 0xA6CD, 0x2526, 0xA6CE, 0x2527, 0xA6CF, 0x2529,\t0xA6D0, 0x252A, 0xA6D1, 0x252D, 0xA6D2, 0x252E, 0xA6D3, 0x2531,\r\n\t0xA6D4, 0x2532, 0xA6D5, 0x2535, 0xA6D6, 0x2536, 0xA6D7, 0x2539,\t0xA6D8, 0x253A, 0xA6D9, 0x253D, 0xA6DA, 0x253E, 0xA6DB, 0x2540,\r\n\t0xA6DC, 0x2541, 0xA6DD, 0x2543, 0xA6DE, 0x2544, 0xA6DF, 0x2545,\t0xA6E0, 0x2546, 0xA6E1, 0x2547, 0xA6E2, 0x2548, 0xA6E3, 0x2549,\r\n\t0xA6E4, 0x254A, 0xA741, 0xCB0B, 0xA742, 0xCB0C, 0xA743, 0xCB0D,\t0xA744, 0xCB0E, 0xA745, 0xCB0F, 0xA746, 0xCB11, 0xA747, 0xCB12,\r\n\t0xA748, 0xCB13, 0xA749, 0xCB15, 0xA74A, 0xCB16, 0xA74B, 0xCB17,\t0xA74C, 0xCB19, 0xA74D, 0xCB1A, 0xA74E, 0xCB1B, 0xA74F, 0xCB1C,\r\n\t0xA750, 0xCB1D, 0xA751, 0xCB1E, 0xA752, 0xCB1F, 0xA753, 0xCB22,\t0xA754, 0xCB23, 0xA755, 0xCB24, 0xA756, 0xCB25, 0xA757, 0xCB26,\r\n\t0xA758, 0xCB27, 0xA759, 0xCB28, 0xA75A, 0xCB29, 0xA761, 0xCB2A,\t0xA762, 0xCB2B, 0xA763, 0xCB2C, 0xA764, 0xCB2D, 0xA765, 0xCB2E,\r\n\t0xA766, 0xCB2F, 0xA767, 0xCB30, 0xA768, 0xCB31, 0xA769, 0xCB32,\t0xA76A, 0xCB33, 0xA76B, 0xCB34, 0xA76C, 0xCB35, 0xA76D, 0xCB36,\r\n\t0xA76E, 0xCB37, 0xA76F, 0xCB38, 0xA770, 0xCB39, 0xA771, 0xCB3A,\t0xA772, 0xCB3B, 0xA773, 0xCB3C, 0xA774, 0xCB3D, 0xA775, 0xCB3E,\r\n\t0xA776, 0xCB3F, 0xA777, 0xCB40, 0xA778, 0xCB42, 0xA779, 0xCB43,\t0xA77A, 0xCB44, 0xA781, 0xCB45, 0xA782, 0xCB46, 0xA783, 0xCB47,\r\n\t0xA784, 0xCB4A, 0xA785, 0xCB4B, 0xA786, 0xCB4D, 0xA787, 0xCB4E,\t0xA788, 0xCB4F, 0xA789, 0xCB51, 0xA78A, 0xCB52, 0xA78B, 0xCB53,\r\n\t0xA78C, 0xCB54, 0xA78D, 0xCB55, 0xA78E, 0xCB56, 0xA78F, 0xCB57,\t0xA790, 0xCB5A, 0xA791, 0xCB5B, 0xA792, 0xCB5C, 0xA793, 0xCB5E,\r\n\t0xA794, 0xCB5F, 0xA795, 0xCB60, 0xA796, 0xCB61, 0xA797, 0xCB62,\t0xA798, 0xCB63, 0xA799, 0xCB65, 0xA79A, 0xCB66, 0xA79B, 0xCB67,\r\n\t0xA79C, 0xCB68, 0xA79D, 0xCB69, 0xA79E, 0xCB6A, 0xA79F, 0xCB6B,\t0xA7A0, 0xCB6C, 0xA7A1, 0x3395, 0xA7A2, 0x3396, 0xA7A3, 0x3397,\r\n\t0xA7A4, 0x2113, 0xA7A5, 0x3398, 0xA7A6, 0x33C4, 0xA7A7, 0x33A3,\t0xA7A8, 0x33A4, 0xA7A9, 0x33A5, 0xA7AA, 0x33A6, 0xA7AB, 0x3399,\r\n\t0xA7AC, 0x339A, 0xA7AD, 0x339B, 0xA7AE, 0x339C, 0xA7AF, 0x339D,\t0xA7B0, 0x339E, 0xA7B1, 0x339F, 0xA7B2, 0x33A0, 0xA7B3, 0x33A1,\r\n\t0xA7B4, 0x33A2, 0xA7B5, 0x33CA, 0xA7B6, 0x338D, 0xA7B7, 0x338E,\t0xA7B8, 0x338F, 0xA7B9, 0x33CF, 0xA7BA, 0x3388, 0xA7BB, 0x3389,\r\n\t0xA7BC, 0x33C8, 0xA7BD, 0x33A7, 0xA7BE, 0x33A8, 0xA7BF, 0x33B0,\t0xA7C0, 0x33B1, 0xA7C1, 0x33B2, 0xA7C2, 0x33B3, 0xA7C3, 0x33B4,\r\n\t0xA7C4, 0x33B5, 0xA7C5, 0x33B6, 0xA7C6, 0x33B7, 0xA7C7, 0x33B8,\t0xA7C8, 0x33B9, 0xA7C9, 0x3380, 0xA7CA, 0x3381, 0xA7CB, 0x3382,\r\n\t0xA7CC, 0x3383, 0xA7CD, 0x3384, 0xA7CE, 0x33BA, 0xA7CF, 0x33BB,\t0xA7D0, 0x33BC, 0xA7D1, 0x33BD, 0xA7D2, 0x33BE, 0xA7D3, 0x33BF,\r\n\t0xA7D4, 0x3390, 0xA7D5, 0x3391, 0xA7D6, 0x3392, 0xA7D7, 0x3393,\t0xA7D8, 0x3394, 0xA7D9, 0x2126, 0xA7DA, 0x33C0, 0xA7DB, 0x33C1,\r\n\t0xA7DC, 0x338A, 0xA7DD, 0x338B, 0xA7DE, 0x338C, 0xA7DF, 0x33D6,\t0xA7E0, 0x33C5, 0xA7E1, 0x33AD, 0xA7E2, 0x33AE, 0xA7E3, 0x33AF,\r\n\t0xA7E4, 0x33DB, 0xA7E5, 0x33A9, 0xA7E6, 0x33AA, 0xA7E7, 0x33AB,\t0xA7E8, 0x33AC, 0xA7E9, 0x33DD, 0xA7EA, 0x33D0, 0xA7EB, 0x33D3,\r\n\t0xA7EC, 0x33C3, 0xA7ED, 0x33C9, 0xA7EE, 0x33DC, 0xA7EF, 0x33C6,\t0xA841, 0xCB6D, 0xA842, 0xCB6E, 0xA843, 0xCB6F, 0xA844, 0xCB70,\r\n\t0xA845, 0xCB71, 0xA846, 0xCB72, 0xA847, 0xCB73, 0xA848, 0xCB74,\t0xA849, 0xCB75, 0xA84A, 0xCB76, 0xA84B, 0xCB77, 0xA84C, 0xCB7A,\r\n\t0xA84D, 0xCB7B, 0xA84E, 0xCB7C, 0xA84F, 0xCB7D, 0xA850, 0xCB7E,\t0xA851, 0xCB7F, 0xA852, 0xCB80, 0xA853, 0xCB81, 0xA854, 0xCB82,\r\n\t0xA855, 0xCB83, 0xA856, 0xCB84, 0xA857, 0xCB85, 0xA858, 0xCB86,\t0xA859, 0xCB87, 0xA85A, 0xCB88, 0xA861, 0xCB89, 0xA862, 0xCB8A,\r\n\t0xA863, 0xCB8B, 0xA864, 0xCB8C, 0xA865, 0xCB8D, 0xA866, 0xCB8E,\t0xA867, 0xCB8F, 0xA868, 0xCB90, 0xA869, 0xCB91, 0xA86A, 0xCB92,\r\n\t0xA86B, 0xCB93, 0xA86C, 0xCB94, 0xA86D, 0xCB95, 0xA86E, 0xCB96,\t0xA86F, 0xCB97, 0xA870, 0xCB98, 0xA871, 0xCB99, 0xA872, 0xCB9A,\r\n\t0xA873, 0xCB9B, 0xA874, 0xCB9D, 0xA875, 0xCB9E, 0xA876, 0xCB9F,\t0xA877, 0xCBA0, 0xA878, 0xCBA1, 0xA879, 0xCBA2, 0xA87A, 0xCBA3,\r\n\t0xA881, 0xCBA4, 0xA882, 0xCBA5, 0xA883, 0xCBA6, 0xA884, 0xCBA7,\t0xA885, 0xCBA8, 0xA886, 0xCBA9, 0xA887, 0xCBAA, 0xA888, 0xCBAB,\r\n\t0xA889, 0xCBAC, 0xA88A, 0xCBAD, 0xA88B, 0xCBAE, 0xA88C, 0xCBAF,\t0xA88D, 0xCBB0, 0xA88E, 0xCBB1, 0xA88F, 0xCBB2, 0xA890, 0xCBB3,\r\n\t0xA891, 0xCBB4, 0xA892, 0xCBB5, 0xA893, 0xCBB6, 0xA894, 0xCBB7,\t0xA895, 0xCBB9, 0xA896, 0xCBBA, 0xA897, 0xCBBB, 0xA898, 0xCBBC,\r\n\t0xA899, 0xCBBD, 0xA89A, 0xCBBE, 0xA89B, 0xCBBF, 0xA89C, 0xCBC0,\t0xA89D, 0xCBC1, 0xA89E, 0xCBC2, 0xA89F, 0xCBC3, 0xA8A0, 0xCBC4,\r\n\t0xA8A1, 0x00C6, 0xA8A2, 0x00D0, 0xA8A3, 0x00AA, 0xA8A4, 0x0126,\t0xA8A6, 0x0132, 0xA8A8, 0x013F, 0xA8A9, 0x0141, 0xA8AA, 0x00D8,\r\n\t0xA8AB, 0x0152, 0xA8AC, 0x00BA, 0xA8AD, 0x00DE, 0xA8AE, 0x0166,\t0xA8AF, 0x014A, 0xA8B1, 0x3260, 0xA8B2, 0x3261, 0xA8B3, 0x3262,\r\n\t0xA8B4, 0x3263, 0xA8B5, 0x3264, 0xA8B6, 0x3265, 0xA8B7, 0x3266,\t0xA8B8, 0x3267, 0xA8B9, 0x3268, 0xA8BA, 0x3269, 0xA8BB, 0x326A,\r\n\t0xA8BC, 0x326B, 0xA8BD, 0x326C, 0xA8BE, 0x326D, 0xA8BF, 0x326E,\t0xA8C0, 0x326F, 0xA8C1, 0x3270, 0xA8C2, 0x3271, 0xA8C3, 0x3272,\r\n\t0xA8C4, 0x3273, 0xA8C5, 0x3274, 0xA8C6, 0x3275, 0xA8C7, 0x3276,\t0xA8C8, 0x3277, 0xA8C9, 0x3278, 0xA8CA, 0x3279, 0xA8CB, 0x327A,\r\n\t0xA8CC, 0x327B, 0xA8CD, 0x24D0, 0xA8CE, 0x24D1, 0xA8CF, 0x24D2,\t0xA8D0, 0x24D3, 0xA8D1, 0x24D4, 0xA8D2, 0x24D5, 0xA8D3, 0x24D6,\r\n\t0xA8D4, 0x24D7, 0xA8D5, 0x24D8, 0xA8D6, 0x24D9, 0xA8D7, 0x24DA,\t0xA8D8, 0x24DB, 0xA8D9, 0x24DC, 0xA8DA, 0x24DD, 0xA8DB, 0x24DE,\r\n\t0xA8DC, 0x24DF, 0xA8DD, 0x24E0, 0xA8DE, 0x24E1, 0xA8DF, 0x24E2,\t0xA8E0, 0x24E3, 0xA8E1, 0x24E4, 0xA8E2, 0x24E5, 0xA8E3, 0x24E6,\r\n\t0xA8E4, 0x24E7, 0xA8E5, 0x24E8, 0xA8E6, 0x24E9, 0xA8E7, 0x2460,\t0xA8E8, 0x2461, 0xA8E9, 0x2462, 0xA8EA, 0x2463, 0xA8EB, 0x2464,\r\n\t0xA8EC, 0x2465, 0xA8ED, 0x2466, 0xA8EE, 0x2467, 0xA8EF, 0x2468,\t0xA8F0, 0x2469, 0xA8F1, 0x246A, 0xA8F2, 0x246B, 0xA8F3, 0x246C,\r\n\t0xA8F4, 0x246D, 0xA8F5, 0x246E, 0xA8F6, 0x00BD, 0xA8F7, 0x2153,\t0xA8F8, 0x2154, 0xA8F9, 0x00BC, 0xA8FA, 0x00BE, 0xA8FB, 0x215B,\r\n\t0xA8FC, 0x215C, 0xA8FD, 0x215D, 0xA8FE, 0x215E, 0xA941, 0xCBC5,\t0xA942, 0xCBC6, 0xA943, 0xCBC7, 0xA944, 0xCBC8, 0xA945, 0xCBC9,\r\n\t0xA946, 0xCBCA, 0xA947, 0xCBCB, 0xA948, 0xCBCC, 0xA949, 0xCBCD,\t0xA94A, 0xCBCE, 0xA94B, 0xCBCF, 0xA94C, 0xCBD0, 0xA94D, 0xCBD1,\r\n\t0xA94E, 0xCBD2, 0xA94F, 0xCBD3, 0xA950, 0xCBD5, 0xA951, 0xCBD6,\t0xA952, 0xCBD7, 0xA953, 0xCBD8, 0xA954, 0xCBD9, 0xA955, 0xCBDA,\r\n\t0xA956, 0xCBDB, 0xA957, 0xCBDC, 0xA958, 0xCBDD, 0xA959, 0xCBDE,\t0xA95A, 0xCBDF, 0xA961, 0xCBE0, 0xA962, 0xCBE1, 0xA963, 0xCBE2,\r\n\t0xA964, 0xCBE3, 0xA965, 0xCBE5, 0xA966, 0xCBE6, 0xA967, 0xCBE8,\t0xA968, 0xCBEA, 0xA969, 0xCBEB, 0xA96A, 0xCBEC, 0xA96B, 0xCBED,\r\n\t0xA96C, 0xCBEE, 0xA96D, 0xCBEF, 0xA96E, 0xCBF0, 0xA96F, 0xCBF1,\t0xA970, 0xCBF2, 0xA971, 0xCBF3, 0xA972, 0xCBF4, 0xA973, 0xCBF5,\r\n\t0xA974, 0xCBF6, 0xA975, 0xCBF7, 0xA976, 0xCBF8, 0xA977, 0xCBF9,\t0xA978, 0xCBFA, 0xA979, 0xCBFB, 0xA97A, 0xCBFC, 0xA981, 0xCBFD,\r\n\t0xA982, 0xCBFE, 0xA983, 0xCBFF, 0xA984, 0xCC00, 0xA985, 0xCC01,\t0xA986, 0xCC02, 0xA987, 0xCC03, 0xA988, 0xCC04, 0xA989, 0xCC05,\r\n\t0xA98A, 0xCC06, 0xA98B, 0xCC07, 0xA98C, 0xCC08, 0xA98D, 0xCC09,\t0xA98E, 0xCC0A, 0xA98F, 0xCC0B, 0xA990, 0xCC0E, 0xA991, 0xCC0F,\r\n\t0xA992, 0xCC11, 0xA993, 0xCC12, 0xA994, 0xCC13, 0xA995, 0xCC15,\t0xA996, 0xCC16, 0xA997, 0xCC17, 0xA998, 0xCC18, 0xA999, 0xCC19,\r\n\t0xA99A, 0xCC1A, 0xA99B, 0xCC1B, 0xA99C, 0xCC1E, 0xA99D, 0xCC1F,\t0xA99E, 0xCC20, 0xA99F, 0xCC23, 0xA9A0, 0xCC24, 0xA9A1, 0x00E6,\r\n\t0xA9A2, 0x0111, 0xA9A3, 0x00F0, 0xA9A4, 0x0127, 0xA9A5, 0x0131,\t0xA9A6, 0x0133, 0xA9A7, 0x0138, 0xA9A8, 0x0140, 0xA9A9, 0x0142,\r\n\t0xA9AA, 0x00F8, 0xA9AB, 0x0153, 0xA9AC, 0x00DF, 0xA9AD, 0x00FE,\t0xA9AE, 0x0167, 0xA9AF, 0x014B, 0xA9B0, 0x0149, 0xA9B1, 0x3200,\r\n\t0xA9B2, 0x3201, 0xA9B3, 0x3202, 0xA9B4, 0x3203, 0xA9B5, 0x3204,\t0xA9B6, 0x3205, 0xA9B7, 0x3206, 0xA9B8, 0x3207, 0xA9B9, 0x3208,\r\n\t0xA9BA, 0x3209, 0xA9BB, 0x320A, 0xA9BC, 0x320B, 0xA9BD, 0x320C,\t0xA9BE, 0x320D, 0xA9BF, 0x320E, 0xA9C0, 0x320F, 0xA9C1, 0x3210,\r\n\t0xA9C2, 0x3211, 0xA9C3, 0x3212, 0xA9C4, 0x3213, 0xA9C5, 0x3214,\t0xA9C6, 0x3215, 0xA9C7, 0x3216, 0xA9C8, 0x3217, 0xA9C9, 0x3218,\r\n\t0xA9CA, 0x3219, 0xA9CB, 0x321A, 0xA9CC, 0x321B, 0xA9CD, 0x249C,\t0xA9CE, 0x249D, 0xA9CF, 0x249E, 0xA9D0, 0x249F, 0xA9D1, 0x24A0,\r\n\t0xA9D2, 0x24A1, 0xA9D3, 0x24A2, 0xA9D4, 0x24A3, 0xA9D5, 0x24A4,\t0xA9D6, 0x24A5, 0xA9D7, 0x24A6, 0xA9D8, 0x24A7, 0xA9D9, 0x24A8,\r\n\t0xA9DA, 0x24A9, 0xA9DB, 0x24AA, 0xA9DC, 0x24AB, 0xA9DD, 0x24AC,\t0xA9DE, 0x24AD, 0xA9DF, 0x24AE, 0xA9E0, 0x24AF, 0xA9E1, 0x24B0,\r\n\t0xA9E2, 0x24B1, 0xA9E3, 0x24B2, 0xA9E4, 0x24B3, 0xA9E5, 0x24B4,\t0xA9E6, 0x24B5, 0xA9E7, 0x2474, 0xA9E8, 0x2475, 0xA9E9, 0x2476,\r\n\t0xA9EA, 0x2477, 0xA9EB, 0x2478, 0xA9EC, 0x2479, 0xA9ED, 0x247A,\t0xA9EE, 0x247B, 0xA9EF, 0x247C, 0xA9F0, 0x247D, 0xA9F1, 0x247E,\r\n\t0xA9F2, 0x247F, 0xA9F3, 0x2480, 0xA9F4, 0x2481, 0xA9F5, 0x2482,\t0xA9F6, 0x00B9, 0xA9F7, 0x00B2, 0xA9F8, 0x00B3, 0xA9F9, 0x2074,\r\n\t0xA9FA, 0x207F, 0xA9FB, 0x2081, 0xA9FC, 0x2082, 0xA9FD, 0x2083,\t0xA9FE, 0x2084, 0xAA41, 0xCC25, 0xAA42, 0xCC26, 0xAA43, 0xCC2A,\r\n\t0xAA44, 0xCC2B, 0xAA45, 0xCC2D, 0xAA46, 0xCC2F, 0xAA47, 0xCC31,\t0xAA48, 0xCC32, 0xAA49, 0xCC33, 0xAA4A, 0xCC34, 0xAA4B, 0xCC35,\r\n\t0xAA4C, 0xCC36, 0xAA4D, 0xCC37, 0xAA4E, 0xCC3A, 0xAA4F, 0xCC3F,\t0xAA50, 0xCC40, 0xAA51, 0xCC41, 0xAA52, 0xCC42, 0xAA53, 0xCC43,\r\n\t0xAA54, 0xCC46, 0xAA55, 0xCC47, 0xAA56, 0xCC49, 0xAA57, 0xCC4A,\t0xAA58, 0xCC4B, 0xAA59, 0xCC4D, 0xAA5A, 0xCC4E, 0xAA61, 0xCC4F,\r\n\t0xAA62, 0xCC50, 0xAA63, 0xCC51, 0xAA64, 0xCC52, 0xAA65, 0xCC53,\t0xAA66, 0xCC56, 0xAA67, 0xCC5A, 0xAA68, 0xCC5B, 0xAA69, 0xCC5C,\r\n\t0xAA6A, 0xCC5D, 0xAA6B, 0xCC5E, 0xAA6C, 0xCC5F, 0xAA6D, 0xCC61,\t0xAA6E, 0xCC62, 0xAA6F, 0xCC63, 0xAA70, 0xCC65, 0xAA71, 0xCC67,\r\n\t0xAA72, 0xCC69, 0xAA73, 0xCC6A, 0xAA74, 0xCC6B, 0xAA75, 0xCC6C,\t0xAA76, 0xCC6D, 0xAA77, 0xCC6E, 0xAA78, 0xCC6F, 0xAA79, 0xCC71,\r\n\t0xAA7A, 0xCC72, 0xAA81, 0xCC73, 0xAA82, 0xCC74, 0xAA83, 0xCC76,\t0xAA84, 0xCC77, 0xAA85, 0xCC78, 0xAA86, 0xCC79, 0xAA87, 0xCC7A,\r\n\t0xAA88, 0xCC7B, 0xAA89, 0xCC7C, 0xAA8A, 0xCC7D, 0xAA8B, 0xCC7E,\t0xAA8C, 0xCC7F, 0xAA8D, 0xCC80, 0xAA8E, 0xCC81, 0xAA8F, 0xCC82,\r\n\t0xAA90, 0xCC83, 0xAA91, 0xCC84, 0xAA92, 0xCC85, 0xAA93, 0xCC86,\t0xAA94, 0xCC87, 0xAA95, 0xCC88, 0xAA96, 0xCC89, 0xAA97, 0xCC8A,\r\n\t0xAA98, 0xCC8B, 0xAA99, 0xCC8C, 0xAA9A, 0xCC8D, 0xAA9B, 0xCC8E,\t0xAA9C, 0xCC8F, 0xAA9D, 0xCC90, 0xAA9E, 0xCC91, 0xAA9F, 0xCC92,\r\n\t0xAAA0, 0xCC93, 0xAAA1, 0x3041, 0xAAA2, 0x3042, 0xAAA3, 0x3043,\t0xAAA4, 0x3044, 0xAAA5, 0x3045, 0xAAA6, 0x3046, 0xAAA7, 0x3047,\r\n\t0xAAA8, 0x3048, 0xAAA9, 0x3049, 0xAAAA, 0x304A, 0xAAAB, 0x304B,\t0xAAAC, 0x304C, 0xAAAD, 0x304D, 0xAAAE, 0x304E, 0xAAAF, 0x304F,\r\n\t0xAAB0, 0x3050, 0xAAB1, 0x3051, 0xAAB2, 0x3052, 0xAAB3, 0x3053,\t0xAAB4, 0x3054, 0xAAB5, 0x3055, 0xAAB6, 0x3056, 0xAAB7, 0x3057,\r\n\t0xAAB8, 0x3058, 0xAAB9, 0x3059, 0xAABA, 0x305A, 0xAABB, 0x305B,\t0xAABC, 0x305C, 0xAABD, 0x305D, 0xAABE, 0x305E, 0xAABF, 0x305F,\r\n\t0xAAC0, 0x3060, 0xAAC1, 0x3061, 0xAAC2, 0x3062, 0xAAC3, 0x3063,\t0xAAC4, 0x3064, 0xAAC5, 0x3065, 0xAAC6, 0x3066, 0xAAC7, 0x3067,\r\n\t0xAAC8, 0x3068, 0xAAC9, 0x3069, 0xAACA, 0x306A, 0xAACB, 0x306B,\t0xAACC, 0x306C, 0xAACD, 0x306D, 0xAACE, 0x306E, 0xAACF, 0x306F,\r\n\t0xAAD0, 0x3070, 0xAAD1, 0x3071, 0xAAD2, 0x3072, 0xAAD3, 0x3073,\t0xAAD4, 0x3074, 0xAAD5, 0x3075, 0xAAD6, 0x3076, 0xAAD7, 0x3077,\r\n\t0xAAD8, 0x3078, 0xAAD9, 0x3079, 0xAADA, 0x307A, 0xAADB, 0x307B,\t0xAADC, 0x307C, 0xAADD, 0x307D, 0xAADE, 0x307E, 0xAADF, 0x307F,\r\n\t0xAAE0, 0x3080, 0xAAE1, 0x3081, 0xAAE2, 0x3082, 0xAAE3, 0x3083,\t0xAAE4, 0x3084, 0xAAE5, 0x3085, 0xAAE6, 0x3086, 0xAAE7, 0x3087,\r\n\t0xAAE8, 0x3088, 0xAAE9, 0x3089, 0xAAEA, 0x308A, 0xAAEB, 0x308B,\t0xAAEC, 0x308C, 0xAAED, 0x308D, 0xAAEE, 0x308E, 0xAAEF, 0x308F,\r\n\t0xAAF0, 0x3090, 0xAAF1, 0x3091, 0xAAF2, 0x3092, 0xAAF3, 0x3093,\t0xAB41, 0xCC94, 0xAB42, 0xCC95, 0xAB43, 0xCC96, 0xAB44, 0xCC97,\r\n\t0xAB45, 0xCC9A, 0xAB46, 0xCC9B, 0xAB47, 0xCC9D, 0xAB48, 0xCC9E,\t0xAB49, 0xCC9F, 0xAB4A, 0xCCA1, 0xAB4B, 0xCCA2, 0xAB4C, 0xCCA3,\r\n\t0xAB4D, 0xCCA4, 0xAB4E, 0xCCA5, 0xAB4F, 0xCCA6, 0xAB50, 0xCCA7,\t0xAB51, 0xCCAA, 0xAB52, 0xCCAE, 0xAB53, 0xCCAF, 0xAB54, 0xCCB0,\r\n\t0xAB55, 0xCCB1, 0xAB56, 0xCCB2, 0xAB57, 0xCCB3, 0xAB58, 0xCCB6,\t0xAB59, 0xCCB7, 0xAB5A, 0xCCB9, 0xAB61, 0xCCBA, 0xAB62, 0xCCBB,\r\n\t0xAB63, 0xCCBD, 0xAB64, 0xCCBE, 0xAB65, 0xCCBF, 0xAB66, 0xCCC0,\t0xAB67, 0xCCC1, 0xAB68, 0xCCC2, 0xAB69, 0xCCC3, 0xAB6A, 0xCCC6,\r\n\t0xAB6B, 0xCCC8, 0xAB6C, 0xCCCA, 0xAB6D, 0xCCCB, 0xAB6E, 0xCCCC,\t0xAB6F, 0xCCCD, 0xAB70, 0xCCCE, 0xAB71, 0xCCCF, 0xAB72, 0xCCD1,\r\n\t0xAB73, 0xCCD2, 0xAB74, 0xCCD3, 0xAB75, 0xCCD5, 0xAB76, 0xCCD6,\t0xAB77, 0xCCD7, 0xAB78, 0xCCD8, 0xAB79, 0xCCD9, 0xAB7A, 0xCCDA,\r\n\t0xAB81, 0xCCDB, 0xAB82, 0xCCDC, 0xAB83, 0xCCDD, 0xAB84, 0xCCDE,\t0xAB85, 0xCCDF, 0xAB86, 0xCCE0, 0xAB87, 0xCCE1, 0xAB88, 0xCCE2,\r\n\t0xAB89, 0xCCE3, 0xAB8A, 0xCCE5, 0xAB8B, 0xCCE6, 0xAB8C, 0xCCE7,\t0xAB8D, 0xCCE8, 0xAB8E, 0xCCE9, 0xAB8F, 0xCCEA, 0xAB90, 0xCCEB,\r\n\t0xAB91, 0xCCED, 0xAB92, 0xCCEE, 0xAB93, 0xCCEF, 0xAB94, 0xCCF1,\t0xAB95, 0xCCF2, 0xAB96, 0xCCF3, 0xAB97, 0xCCF4, 0xAB98, 0xCCF5,\r\n\t0xAB99, 0xCCF6, 0xAB9A, 0xCCF7, 0xAB9B, 0xCCF8, 0xAB9C, 0xCCF9,\t0xAB9D, 0xCCFA, 0xAB9E, 0xCCFB, 0xAB9F, 0xCCFC, 0xABA0, 0xCCFD,\r\n\t0xABA1, 0x30A1, 0xABA2, 0x30A2, 0xABA3, 0x30A3, 0xABA4, 0x30A4,\t0xABA5, 0x30A5, 0xABA6, 0x30A6, 0xABA7, 0x30A7, 0xABA8, 0x30A8,\r\n\t0xABA9, 0x30A9, 0xABAA, 0x30AA, 0xABAB, 0x30AB, 0xABAC, 0x30AC,\t0xABAD, 0x30AD, 0xABAE, 0x30AE, 0xABAF, 0x30AF, 0xABB0, 0x30B0,\r\n\t0xABB1, 0x30B1, 0xABB2, 0x30B2, 0xABB3, 0x30B3, 0xABB4, 0x30B4,\t0xABB5, 0x30B5, 0xABB6, 0x30B6, 0xABB7, 0x30B7, 0xABB8, 0x30B8,\r\n\t0xABB9, 0x30B9, 0xABBA, 0x30BA, 0xABBB, 0x30BB, 0xABBC, 0x30BC,\t0xABBD, 0x30BD, 0xABBE, 0x30BE, 0xABBF, 0x30BF, 0xABC0, 0x30C0,\r\n\t0xABC1, 0x30C1, 0xABC2, 0x30C2, 0xABC3, 0x30C3, 0xABC4, 0x30C4,\t0xABC5, 0x30C5, 0xABC6, 0x30C6, 0xABC7, 0x30C7, 0xABC8, 0x30C8,\r\n\t0xABC9, 0x30C9, 0xABCA, 0x30CA, 0xABCB, 0x30CB, 0xABCC, 0x30CC,\t0xABCD, 0x30CD, 0xABCE, 0x30CE, 0xABCF, 0x30CF, 0xABD0, 0x30D0,\r\n\t0xABD1, 0x30D1, 0xABD2, 0x30D2, 0xABD3, 0x30D3, 0xABD4, 0x30D4,\t0xABD5, 0x30D5, 0xABD6, 0x30D6, 0xABD7, 0x30D7, 0xABD8, 0x30D8,\r\n\t0xABD9, 0x30D9, 0xABDA, 0x30DA, 0xABDB, 0x30DB, 0xABDC, 0x30DC,\t0xABDD, 0x30DD, 0xABDE, 0x30DE, 0xABDF, 0x30DF, 0xABE0, 0x30E0,\r\n\t0xABE1, 0x30E1, 0xABE2, 0x30E2, 0xABE3, 0x30E3, 0xABE4, 0x30E4,\t0xABE5, 0x30E5, 0xABE6, 0x30E6, 0xABE7, 0x30E7, 0xABE8, 0x30E8,\r\n\t0xABE9, 0x30E9, 0xABEA, 0x30EA, 0xABEB, 0x30EB, 0xABEC, 0x30EC,\t0xABED, 0x30ED, 0xABEE, 0x30EE, 0xABEF, 0x30EF, 0xABF0, 0x30F0,\r\n\t0xABF1, 0x30F1, 0xABF2, 0x30F2, 0xABF3, 0x30F3, 0xABF4, 0x30F4,\t0xABF5, 0x30F5, 0xABF6, 0x30F6, 0xAC41, 0xCCFE, 0xAC42, 0xCCFF,\r\n\t0xAC43, 0xCD00, 0xAC44, 0xCD02, 0xAC45, 0xCD03, 0xAC46, 0xCD04,\t0xAC47, 0xCD05, 0xAC48, 0xCD06, 0xAC49, 0xCD07, 0xAC4A, 0xCD0A,\r\n\t0xAC4B, 0xCD0B, 0xAC4C, 0xCD0D, 0xAC4D, 0xCD0E, 0xAC4E, 0xCD0F,\t0xAC4F, 0xCD11, 0xAC50, 0xCD12, 0xAC51, 0xCD13, 0xAC52, 0xCD14,\r\n\t0xAC53, 0xCD15, 0xAC54, 0xCD16, 0xAC55, 0xCD17, 0xAC56, 0xCD1A,\t0xAC57, 0xCD1C, 0xAC58, 0xCD1E, 0xAC59, 0xCD1F, 0xAC5A, 0xCD20,\r\n\t0xAC61, 0xCD21, 0xAC62, 0xCD22, 0xAC63, 0xCD23, 0xAC64, 0xCD25,\t0xAC65, 0xCD26, 0xAC66, 0xCD27, 0xAC67, 0xCD29, 0xAC68, 0xCD2A,\r\n\t0xAC69, 0xCD2B, 0xAC6A, 0xCD2D, 0xAC6B, 0xCD2E, 0xAC6C, 0xCD2F,\t0xAC6D, 0xCD30, 0xAC6E, 0xCD31, 0xAC6F, 0xCD32, 0xAC70, 0xCD33,\r\n\t0xAC71, 0xCD34, 0xAC72, 0xCD35, 0xAC73, 0xCD36, 0xAC74, 0xCD37,\t0xAC75, 0xCD38, 0xAC76, 0xCD3A, 0xAC77, 0xCD3B, 0xAC78, 0xCD3C,\r\n\t0xAC79, 0xCD3D, 0xAC7A, 0xCD3E, 0xAC81, 0xCD3F, 0xAC82, 0xCD40,\t0xAC83, 0xCD41, 0xAC84, 0xCD42, 0xAC85, 0xCD43, 0xAC86, 0xCD44,\r\n\t0xAC87, 0xCD45, 0xAC88, 0xCD46, 0xAC89, 0xCD47, 0xAC8A, 0xCD48,\t0xAC8B, 0xCD49, 0xAC8C, 0xCD4A, 0xAC8D, 0xCD4B, 0xAC8E, 0xCD4C,\r\n\t0xAC8F, 0xCD4D, 0xAC90, 0xCD4E, 0xAC91, 0xCD4F, 0xAC92, 0xCD50,\t0xAC93, 0xCD51, 0xAC94, 0xCD52, 0xAC95, 0xCD53, 0xAC96, 0xCD54,\r\n\t0xAC97, 0xCD55, 0xAC98, 0xCD56, 0xAC99, 0xCD57, 0xAC9A, 0xCD58,\t0xAC9B, 0xCD59, 0xAC9C, 0xCD5A, 0xAC9D, 0xCD5B, 0xAC9E, 0xCD5D,\r\n\t0xAC9F, 0xCD5E, 0xACA0, 0xCD5F, 0xACA1, 0x0410, 0xACA2, 0x0411,\t0xACA3, 0x0412, 0xACA4, 0x0413, 0xACA5, 0x0414, 0xACA6, 0x0415,\r\n\t0xACA7, 0x0401, 0xACA8, 0x0416, 0xACA9, 0x0417, 0xACAA, 0x0418,\t0xACAB, 0x0419, 0xACAC, 0x041A, 0xACAD, 0x041B, 0xACAE, 0x041C,\r\n\t0xACAF, 0x041D, 0xACB0, 0x041E, 0xACB1, 0x041F, 0xACB2, 0x0420,\t0xACB3, 0x0421, 0xACB4, 0x0422, 0xACB5, 0x0423, 0xACB6, 0x0424,\r\n\t0xACB7, 0x0425, 0xACB8, 0x0426, 0xACB9, 0x0427, 0xACBA, 0x0428,\t0xACBB, 0x0429, 0xACBC, 0x042A, 0xACBD, 0x042B, 0xACBE, 0x042C,\r\n\t0xACBF, 0x042D, 0xACC0, 0x042E, 0xACC1, 0x042F, 0xACD1, 0x0430,\t0xACD2, 0x0431, 0xACD3, 0x0432, 0xACD4, 0x0433, 0xACD5, 0x0434,\r\n\t0xACD6, 0x0435, 0xACD7, 0x0451, 0xACD8, 0x0436, 0xACD9, 0x0437,\t0xACDA, 0x0438, 0xACDB, 0x0439, 0xACDC, 0x043A, 0xACDD, 0x043B,\r\n\t0xACDE, 0x043C, 0xACDF, 0x043D, 0xACE0, 0x043E, 0xACE1, 0x043F,\t0xACE2, 0x0440, 0xACE3, 0x0441, 0xACE4, 0x0442, 0xACE5, 0x0443,\r\n\t0xACE6, 0x0444, 0xACE7, 0x0445, 0xACE8, 0x0446, 0xACE9, 0x0447,\t0xACEA, 0x0448, 0xACEB, 0x0449, 0xACEC, 0x044A, 0xACED, 0x044B,\r\n\t0xACEE, 0x044C, 0xACEF, 0x044D, 0xACF0, 0x044E, 0xACF1, 0x044F,\t0xAD41, 0xCD61, 0xAD42, 0xCD62, 0xAD43, 0xCD63, 0xAD44, 0xCD65,\r\n\t0xAD45, 0xCD66, 0xAD46, 0xCD67, 0xAD47, 0xCD68, 0xAD48, 0xCD69,\t0xAD49, 0xCD6A, 0xAD4A, 0xCD6B, 0xAD4B, 0xCD6E, 0xAD4C, 0xCD70,\r\n\t0xAD4D, 0xCD72, 0xAD4E, 0xCD73, 0xAD4F, 0xCD74, 0xAD50, 0xCD75,\t0xAD51, 0xCD76, 0xAD52, 0xCD77, 0xAD53, 0xCD79, 0xAD54, 0xCD7A,\r\n\t0xAD55, 0xCD7B, 0xAD56, 0xCD7C, 0xAD57, 0xCD7D, 0xAD58, 0xCD7E,\t0xAD59, 0xCD7F, 0xAD5A, 0xCD80, 0xAD61, 0xCD81, 0xAD62, 0xCD82,\r\n\t0xAD63, 0xCD83, 0xAD64, 0xCD84, 0xAD65, 0xCD85, 0xAD66, 0xCD86,\t0xAD67, 0xCD87, 0xAD68, 0xCD89, 0xAD69, 0xCD8A, 0xAD6A, 0xCD8B,\r\n\t0xAD6B, 0xCD8C, 0xAD6C, 0xCD8D, 0xAD6D, 0xCD8E, 0xAD6E, 0xCD8F,\t0xAD6F, 0xCD90, 0xAD70, 0xCD91, 0xAD71, 0xCD92, 0xAD72, 0xCD93,\r\n\t0xAD73, 0xCD96, 0xAD74, 0xCD97, 0xAD75, 0xCD99, 0xAD76, 0xCD9A,\t0xAD77, 0xCD9B, 0xAD78, 0xCD9D, 0xAD79, 0xCD9E, 0xAD7A, 0xCD9F,\r\n\t0xAD81, 0xCDA0, 0xAD82, 0xCDA1, 0xAD83, 0xCDA2, 0xAD84, 0xCDA3,\t0xAD85, 0xCDA6, 0xAD86, 0xCDA8, 0xAD87, 0xCDAA, 0xAD88, 0xCDAB,\r\n\t0xAD89, 0xCDAC, 0xAD8A, 0xCDAD, 0xAD8B, 0xCDAE, 0xAD8C, 0xCDAF,\t0xAD8D, 0xCDB1, 0xAD8E, 0xCDB2, 0xAD8F, 0xCDB3, 0xAD90, 0xCDB4,\r\n\t0xAD91, 0xCDB5, 0xAD92, 0xCDB6, 0xAD93, 0xCDB7, 0xAD94, 0xCDB8,\t0xAD95, 0xCDB9, 0xAD96, 0xCDBA, 0xAD97, 0xCDBB, 0xAD98, 0xCDBC,\r\n\t0xAD99, 0xCDBD, 0xAD9A, 0xCDBE, 0xAD9B, 0xCDBF, 0xAD9C, 0xCDC0,\t0xAD9D, 0xCDC1, 0xAD9E, 0xCDC2, 0xAD9F, 0xCDC3, 0xADA0, 0xCDC5,\r\n\t0xAE41, 0xCDC6, 0xAE42, 0xCDC7, 0xAE43, 0xCDC8, 0xAE44, 0xCDC9,\t0xAE45, 0xCDCA, 0xAE46, 0xCDCB, 0xAE47, 0xCDCD, 0xAE48, 0xCDCE,\r\n\t0xAE49, 0xCDCF, 0xAE4A, 0xCDD1, 0xAE4B, 0xCDD2, 0xAE4C, 0xCDD3,\t0xAE4D, 0xCDD4, 0xAE4E, 0xCDD5, 0xAE4F, 0xCDD6, 0xAE50, 0xCDD7,\r\n\t0xAE51, 0xCDD8, 0xAE52, 0xCDD9, 0xAE53, 0xCDDA, 0xAE54, 0xCDDB,\t0xAE55, 0xCDDC, 0xAE56, 0xCDDD, 0xAE57, 0xCDDE, 0xAE58, 0xCDDF,\r\n\t0xAE59, 0xCDE0, 0xAE5A, 0xCDE1, 0xAE61, 0xCDE2, 0xAE62, 0xCDE3,\t0xAE63, 0xCDE4, 0xAE64, 0xCDE5, 0xAE65, 0xCDE6, 0xAE66, 0xCDE7,\r\n\t0xAE67, 0xCDE9, 0xAE68, 0xCDEA, 0xAE69, 0xCDEB, 0xAE6A, 0xCDED,\t0xAE6B, 0xCDEE, 0xAE6C, 0xCDEF, 0xAE6D, 0xCDF1, 0xAE6E, 0xCDF2,\r\n\t0xAE6F, 0xCDF3, 0xAE70, 0xCDF4, 0xAE71, 0xCDF5, 0xAE72, 0xCDF6,\t0xAE73, 0xCDF7, 0xAE74, 0xCDFA, 0xAE75, 0xCDFC, 0xAE76, 0xCDFE,\r\n\t0xAE77, 0xCDFF, 0xAE78, 0xCE00, 0xAE79, 0xCE01, 0xAE7A, 0xCE02,\t0xAE81, 0xCE03, 0xAE82, 0xCE05, 0xAE83, 0xCE06, 0xAE84, 0xCE07,\r\n\t0xAE85, 0xCE09, 0xAE86, 0xCE0A, 0xAE87, 0xCE0B, 0xAE88, 0xCE0D,\t0xAE89, 0xCE0E, 0xAE8A, 0xCE0F, 0xAE8B, 0xCE10, 0xAE8C, 0xCE11,\r\n\t0xAE8D, 0xCE12, 0xAE8E, 0xCE13, 0xAE8F, 0xCE15, 0xAE90, 0xCE16,\t0xAE91, 0xCE17, 0xAE92, 0xCE18, 0xAE93, 0xCE1A, 0xAE94, 0xCE1B,\r\n\t0xAE95, 0xCE1C, 0xAE96, 0xCE1D, 0xAE97, 0xCE1E, 0xAE98, 0xCE1F,\t0xAE99, 0xCE22, 0xAE9A, 0xCE23, 0xAE9B, 0xCE25, 0xAE9C, 0xCE26,\r\n\t0xAE9D, 0xCE27, 0xAE9E, 0xCE29, 0xAE9F, 0xCE2A, 0xAEA0, 0xCE2B,\t0xAF41, 0xCE2C, 0xAF42, 0xCE2D, 0xAF43, 0xCE2E, 0xAF44, 0xCE2F,\r\n\t0xAF45, 0xCE32, 0xAF46, 0xCE34, 0xAF47, 0xCE36, 0xAF48, 0xCE37,\t0xAF49, 0xCE38, 0xAF4A, 0xCE39, 0xAF4B, 0xCE3A, 0xAF4C, 0xCE3B,\r\n\t0xAF4D, 0xCE3C, 0xAF4E, 0xCE3D, 0xAF4F, 0xCE3E, 0xAF50, 0xCE3F,\t0xAF51, 0xCE40, 0xAF52, 0xCE41, 0xAF53, 0xCE42, 0xAF54, 0xCE43,\r\n\t0xAF55, 0xCE44, 0xAF56, 0xCE45, 0xAF57, 0xCE46, 0xAF58, 0xCE47,\t0xAF59, 0xCE48, 0xAF5A, 0xCE49, 0xAF61, 0xCE4A, 0xAF62, 0xCE4B,\r\n\t0xAF63, 0xCE4C, 0xAF64, 0xCE4D, 0xAF65, 0xCE4E, 0xAF66, 0xCE4F,\t0xAF67, 0xCE50, 0xAF68, 0xCE51, 0xAF69, 0xCE52, 0xAF6A, 0xCE53,\r\n\t0xAF6B, 0xCE54, 0xAF6C, 0xCE55, 0xAF6D, 0xCE56, 0xAF6E, 0xCE57,\t0xAF6F, 0xCE5A, 0xAF70, 0xCE5B, 0xAF71, 0xCE5D, 0xAF72, 0xCE5E,\r\n\t0xAF73, 0xCE62, 0xAF74, 0xCE63, 0xAF75, 0xCE64, 0xAF76, 0xCE65,\t0xAF77, 0xCE66, 0xAF78, 0xCE67, 0xAF79, 0xCE6A, 0xAF7A, 0xCE6C,\r\n\t0xAF81, 0xCE6E, 0xAF82, 0xCE6F, 0xAF83, 0xCE70, 0xAF84, 0xCE71,\t0xAF85, 0xCE72, 0xAF86, 0xCE73, 0xAF87, 0xCE76, 0xAF88, 0xCE77,\r\n\t0xAF89, 0xCE79, 0xAF8A, 0xCE7A, 0xAF8B, 0xCE7B, 0xAF8C, 0xCE7D,\t0xAF8D, 0xCE7E, 0xAF8E, 0xCE7F, 0xAF8F, 0xCE80, 0xAF90, 0xCE81,\r\n\t0xAF91, 0xCE82, 0xAF92, 0xCE83, 0xAF93, 0xCE86, 0xAF94, 0xCE88,\t0xAF95, 0xCE8A, 0xAF96, 0xCE8B, 0xAF97, 0xCE8C, 0xAF98, 0xCE8D,\r\n\t0xAF99, 0xCE8E, 0xAF9A, 0xCE8F, 0xAF9B, 0xCE92, 0xAF9C, 0xCE93,\t0xAF9D, 0xCE95, 0xAF9E, 0xCE96, 0xAF9F, 0xCE97, 0xAFA0, 0xCE99,\r\n\t0xB041, 0xCE9A, 0xB042, 0xCE9B, 0xB043, 0xCE9C, 0xB044, 0xCE9D,\t0xB045, 0xCE9E, 0xB046, 0xCE9F, 0xB047, 0xCEA2, 0xB048, 0xCEA6,\r\n\t0xB049, 0xCEA7, 0xB04A, 0xCEA8, 0xB04B, 0xCEA9, 0xB04C, 0xCEAA,\t0xB04D, 0xCEAB, 0xB04E, 0xCEAE, 0xB04F, 0xCEAF, 0xB050, 0xCEB0,\r\n\t0xB051, 0xCEB1, 0xB052, 0xCEB2, 0xB053, 0xCEB3, 0xB054, 0xCEB4,\t0xB055, 0xCEB5, 0xB056, 0xCEB6, 0xB057, 0xCEB7, 0xB058, 0xCEB8,\r\n\t0xB059, 0xCEB9, 0xB05A, 0xCEBA, 0xB061, 0xCEBB, 0xB062, 0xCEBC,\t0xB063, 0xCEBD, 0xB064, 0xCEBE, 0xB065, 0xCEBF, 0xB066, 0xCEC0,\r\n\t0xB067, 0xCEC2, 0xB068, 0xCEC3, 0xB069, 0xCEC4, 0xB06A, 0xCEC5,\t0xB06B, 0xCEC6, 0xB06C, 0xCEC7, 0xB06D, 0xCEC8, 0xB06E, 0xCEC9,\r\n\t0xB06F, 0xCECA, 0xB070, 0xCECB, 0xB071, 0xCECC, 0xB072, 0xCECD,\t0xB073, 0xCECE, 0xB074, 0xCECF, 0xB075, 0xCED0, 0xB076, 0xCED1,\r\n\t0xB077, 0xCED2, 0xB078, 0xCED3, 0xB079, 0xCED4, 0xB07A, 0xCED5,\t0xB081, 0xCED6, 0xB082, 0xCED7, 0xB083, 0xCED8, 0xB084, 0xCED9,\r\n\t0xB085, 0xCEDA, 0xB086, 0xCEDB, 0xB087, 0xCEDC, 0xB088, 0xCEDD,\t0xB089, 0xCEDE, 0xB08A, 0xCEDF, 0xB08B, 0xCEE0, 0xB08C, 0xCEE1,\r\n\t0xB08D, 0xCEE2, 0xB08E, 0xCEE3, 0xB08F, 0xCEE6, 0xB090, 0xCEE7,\t0xB091, 0xCEE9, 0xB092, 0xCEEA, 0xB093, 0xCEED, 0xB094, 0xCEEE,\r\n\t0xB095, 0xCEEF, 0xB096, 0xCEF0, 0xB097, 0xCEF1, 0xB098, 0xCEF2,\t0xB099, 0xCEF3, 0xB09A, 0xCEF6, 0xB09B, 0xCEFA, 0xB09C, 0xCEFB,\r\n\t0xB09D, 0xCEFC, 0xB09E, 0xCEFD, 0xB09F, 0xCEFE, 0xB0A0, 0xCEFF,\t0xB0A1, 0xAC00, 0xB0A2, 0xAC01, 0xB0A3, 0xAC04, 0xB0A4, 0xAC07,\r\n\t0xB0A5, 0xAC08, 0xB0A6, 0xAC09, 0xB0A7, 0xAC0A, 0xB0A8, 0xAC10,\t0xB0A9, 0xAC11, 0xB0AA, 0xAC12, 0xB0AB, 0xAC13, 0xB0AC, 0xAC14,\r\n\t0xB0AD, 0xAC15, 0xB0AE, 0xAC16, 0xB0AF, 0xAC17, 0xB0B0, 0xAC19,\t0xB0B1, 0xAC1A, 0xB0B2, 0xAC1B, 0xB0B3, 0xAC1C, 0xB0B4, 0xAC1D,\r\n\t0xB0B5, 0xAC20, 0xB0B6, 0xAC24, 0xB0B7, 0xAC2C, 0xB0B8, 0xAC2D,\t0xB0B9, 0xAC2F, 0xB0BA, 0xAC30, 0xB0BB, 0xAC31, 0xB0BC, 0xAC38,\r\n\t0xB0BD, 0xAC39, 0xB0BE, 0xAC3C, 0xB0BF, 0xAC40, 0xB0C0, 0xAC4B,\t0xB0C1, 0xAC4D, 0xB0C2, 0xAC54, 0xB0C3, 0xAC58, 0xB0C4, 0xAC5C,\r\n\t0xB0C5, 0xAC70, 0xB0C6, 0xAC71, 0xB0C7, 0xAC74, 0xB0C8, 0xAC77,\t0xB0C9, 0xAC78, 0xB0CA, 0xAC7A, 0xB0CB, 0xAC80, 0xB0CC, 0xAC81,\r\n\t0xB0CD, 0xAC83, 0xB0CE, 0xAC84, 0xB0CF, 0xAC85, 0xB0D0, 0xAC86,\t0xB0D1, 0xAC89, 0xB0D2, 0xAC8A, 0xB0D3, 0xAC8B, 0xB0D4, 0xAC8C,\r\n\t0xB0D5, 0xAC90, 0xB0D6, 0xAC94, 0xB0D7, 0xAC9C, 0xB0D8, 0xAC9D,\t0xB0D9, 0xAC9F, 0xB0DA, 0xACA0, 0xB0DB, 0xACA1, 0xB0DC, 0xACA8,\r\n\t0xB0DD, 0xACA9, 0xB0DE, 0xACAA, 0xB0DF, 0xACAC, 0xB0E0, 0xACAF,\t0xB0E1, 0xACB0, 0xB0E2, 0xACB8, 0xB0E3, 0xACB9, 0xB0E4, 0xACBB,\r\n\t0xB0E5, 0xACBC, 0xB0E6, 0xACBD, 0xB0E7, 0xACC1, 0xB0E8, 0xACC4,\t0xB0E9, 0xACC8, 0xB0EA, 0xACCC, 0xB0EB, 0xACD5, 0xB0EC, 0xACD7,\r\n\t0xB0ED, 0xACE0, 0xB0EE, 0xACE1, 0xB0EF, 0xACE4, 0xB0F0, 0xACE7,\t0xB0F1, 0xACE8, 0xB0F2, 0xACEA, 0xB0F3, 0xACEC, 0xB0F4, 0xACEF,\r\n\t0xB0F5, 0xACF0, 0xB0F6, 0xACF1, 0xB0F7, 0xACF3, 0xB0F8, 0xACF5,\t0xB0F9, 0xACF6, 0xB0FA, 0xACFC, 0xB0FB, 0xACFD, 0xB0FC, 0xAD00,\r\n\t0xB0FD, 0xAD04, 0xB0FE, 0xAD06, 0xB141, 0xCF02, 0xB142, 0xCF03,\t0xB143, 0xCF05, 0xB144, 0xCF06, 0xB145, 0xCF07, 0xB146, 0xCF09,\r\n\t0xB147, 0xCF0A, 0xB148, 0xCF0B, 0xB149, 0xCF0C, 0xB14A, 0xCF0D,\t0xB14B, 0xCF0E, 0xB14C, 0xCF0F, 0xB14D, 0xCF12, 0xB14E, 0xCF14,\r\n\t0xB14F, 0xCF16, 0xB150, 0xCF17, 0xB151, 0xCF18, 0xB152, 0xCF19,\t0xB153, 0xCF1A, 0xB154, 0xCF1B, 0xB155, 0xCF1D, 0xB156, 0xCF1E,\r\n\t0xB157, 0xCF1F, 0xB158, 0xCF21, 0xB159, 0xCF22, 0xB15A, 0xCF23,\t0xB161, 0xCF25, 0xB162, 0xCF26, 0xB163, 0xCF27, 0xB164, 0xCF28,\r\n\t0xB165, 0xCF29, 0xB166, 0xCF2A, 0xB167, 0xCF2B, 0xB168, 0xCF2E,\t0xB169, 0xCF32, 0xB16A, 0xCF33, 0xB16B, 0xCF34, 0xB16C, 0xCF35,\r\n\t0xB16D, 0xCF36, 0xB16E, 0xCF37, 0xB16F, 0xCF39, 0xB170, 0xCF3A,\t0xB171, 0xCF3B, 0xB172, 0xCF3C, 0xB173, 0xCF3D, 0xB174, 0xCF3E,\r\n\t0xB175, 0xCF3F, 0xB176, 0xCF40, 0xB177, 0xCF41, 0xB178, 0xCF42,\t0xB179, 0xCF43, 0xB17A, 0xCF44, 0xB181, 0xCF45, 0xB182, 0xCF46,\r\n\t0xB183, 0xCF47, 0xB184, 0xCF48, 0xB185, 0xCF49, 0xB186, 0xCF4A,\t0xB187, 0xCF4B, 0xB188, 0xCF4C, 0xB189, 0xCF4D, 0xB18A, 0xCF4E,\r\n\t0xB18B, 0xCF4F, 0xB18C, 0xCF50, 0xB18D, 0xCF51, 0xB18E, 0xCF52,\t0xB18F, 0xCF53, 0xB190, 0xCF56, 0xB191, 0xCF57, 0xB192, 0xCF59,\r\n\t0xB193, 0xCF5A, 0xB194, 0xCF5B, 0xB195, 0xCF5D, 0xB196, 0xCF5E,\t0xB197, 0xCF5F, 0xB198, 0xCF60, 0xB199, 0xCF61, 0xB19A, 0xCF62,\r\n\t0xB19B, 0xCF63, 0xB19C, 0xCF66, 0xB19D, 0xCF68, 0xB19E, 0xCF6A,\t0xB19F, 0xCF6B, 0xB1A0, 0xCF6C, 0xB1A1, 0xAD0C, 0xB1A2, 0xAD0D,\r\n\t0xB1A3, 0xAD0F, 0xB1A4, 0xAD11, 0xB1A5, 0xAD18, 0xB1A6, 0xAD1C,\t0xB1A7, 0xAD20, 0xB1A8, 0xAD29, 0xB1A9, 0xAD2C, 0xB1AA, 0xAD2D,\r\n\t0xB1AB, 0xAD34, 0xB1AC, 0xAD35, 0xB1AD, 0xAD38, 0xB1AE, 0xAD3C,\t0xB1AF, 0xAD44, 0xB1B0, 0xAD45, 0xB1B1, 0xAD47, 0xB1B2, 0xAD49,\r\n\t0xB1B3, 0xAD50, 0xB1B4, 0xAD54, 0xB1B5, 0xAD58, 0xB1B6, 0xAD61,\t0xB1B7, 0xAD63, 0xB1B8, 0xAD6C, 0xB1B9, 0xAD6D, 0xB1BA, 0xAD70,\r\n\t0xB1BB, 0xAD73, 0xB1BC, 0xAD74, 0xB1BD, 0xAD75, 0xB1BE, 0xAD76,\t0xB1BF, 0xAD7B, 0xB1C0, 0xAD7C, 0xB1C1, 0xAD7D, 0xB1C2, 0xAD7F,\r\n\t0xB1C3, 0xAD81, 0xB1C4, 0xAD82, 0xB1C5, 0xAD88, 0xB1C6, 0xAD89,\t0xB1C7, 0xAD8C, 0xB1C8, 0xAD90, 0xB1C9, 0xAD9C, 0xB1CA, 0xAD9D,\r\n\t0xB1CB, 0xADA4, 0xB1CC, 0xADB7, 0xB1CD, 0xADC0, 0xB1CE, 0xADC1,\t0xB1CF, 0xADC4, 0xB1D0, 0xADC8, 0xB1D1, 0xADD0, 0xB1D2, 0xADD1,\r\n\t0xB1D3, 0xADD3, 0xB1D4, 0xADDC, 0xB1D5, 0xADE0, 0xB1D6, 0xADE4,\t0xB1D7, 0xADF8, 0xB1D8, 0xADF9, 0xB1D9, 0xADFC, 0xB1DA, 0xADFF,\r\n\t0xB1DB, 0xAE00, 0xB1DC, 0xAE01, 0xB1DD, 0xAE08, 0xB1DE, 0xAE09,\t0xB1DF, 0xAE0B, 0xB1E0, 0xAE0D, 0xB1E1, 0xAE14, 0xB1E2, 0xAE30,\r\n\t0xB1E3, 0xAE31, 0xB1E4, 0xAE34, 0xB1E5, 0xAE37, 0xB1E6, 0xAE38,\t0xB1E7, 0xAE3A, 0xB1E8, 0xAE40, 0xB1E9, 0xAE41, 0xB1EA, 0xAE43,\r\n\t0xB1EB, 0xAE45, 0xB1EC, 0xAE46, 0xB1ED, 0xAE4A, 0xB1EE, 0xAE4C,\t0xB1EF, 0xAE4D, 0xB1F0, 0xAE4E, 0xB1F1, 0xAE50, 0xB1F2, 0xAE54,\r\n\t0xB1F3, 0xAE56, 0xB1F4, 0xAE5C, 0xB1F5, 0xAE5D, 0xB1F6, 0xAE5F,\t0xB1F7, 0xAE60, 0xB1F8, 0xAE61, 0xB1F9, 0xAE65, 0xB1FA, 0xAE68,\r\n\t0xB1FB, 0xAE69, 0xB1FC, 0xAE6C, 0xB1FD, 0xAE70, 0xB1FE, 0xAE78,\t0xB241, 0xCF6D, 0xB242, 0xCF6E, 0xB243, 0xCF6F, 0xB244, 0xCF72,\r\n\t0xB245, 0xCF73, 0xB246, 0xCF75, 0xB247, 0xCF76, 0xB248, 0xCF77,\t0xB249, 0xCF79, 0xB24A, 0xCF7A, 0xB24B, 0xCF7B, 0xB24C, 0xCF7C,\r\n\t0xB24D, 0xCF7D, 0xB24E, 0xCF7E, 0xB24F, 0xCF7F, 0xB250, 0xCF81,\t0xB251, 0xCF82, 0xB252, 0xCF83, 0xB253, 0xCF84, 0xB254, 0xCF86,\r\n\t0xB255, 0xCF87, 0xB256, 0xCF88, 0xB257, 0xCF89, 0xB258, 0xCF8A,\t0xB259, 0xCF8B, 0xB25A, 0xCF8D, 0xB261, 0xCF8E, 0xB262, 0xCF8F,\r\n\t0xB263, 0xCF90, 0xB264, 0xCF91, 0xB265, 0xCF92, 0xB266, 0xCF93,\t0xB267, 0xCF94, 0xB268, 0xCF95, 0xB269, 0xCF96, 0xB26A, 0xCF97,\r\n\t0xB26B, 0xCF98, 0xB26C, 0xCF99, 0xB26D, 0xCF9A, 0xB26E, 0xCF9B,\t0xB26F, 0xCF9C, 0xB270, 0xCF9D, 0xB271, 0xCF9E, 0xB272, 0xCF9F,\r\n\t0xB273, 0xCFA0, 0xB274, 0xCFA2, 0xB275, 0xCFA3, 0xB276, 0xCFA4,\t0xB277, 0xCFA5, 0xB278, 0xCFA6, 0xB279, 0xCFA7, 0xB27A, 0xCFA9,\r\n\t0xB281, 0xCFAA, 0xB282, 0xCFAB, 0xB283, 0xCFAC, 0xB284, 0xCFAD,\t0xB285, 0xCFAE, 0xB286, 0xCFAF, 0xB287, 0xCFB1, 0xB288, 0xCFB2,\r\n\t0xB289, 0xCFB3, 0xB28A, 0xCFB4, 0xB28B, 0xCFB5, 0xB28C, 0xCFB6,\t0xB28D, 0xCFB7, 0xB28E, 0xCFB8, 0xB28F, 0xCFB9, 0xB290, 0xCFBA,\r\n\t0xB291, 0xCFBB, 0xB292, 0xCFBC, 0xB293, 0xCFBD, 0xB294, 0xCFBE,\t0xB295, 0xCFBF, 0xB296, 0xCFC0, 0xB297, 0xCFC1, 0xB298, 0xCFC2,\r\n\t0xB299, 0xCFC3, 0xB29A, 0xCFC5, 0xB29B, 0xCFC6, 0xB29C, 0xCFC7,\t0xB29D, 0xCFC8, 0xB29E, 0xCFC9, 0xB29F, 0xCFCA, 0xB2A0, 0xCFCB,\r\n\t0xB2A1, 0xAE79, 0xB2A2, 0xAE7B, 0xB2A3, 0xAE7C, 0xB2A4, 0xAE7D,\t0xB2A5, 0xAE84, 0xB2A6, 0xAE85, 0xB2A7, 0xAE8C, 0xB2A8, 0xAEBC,\r\n\t0xB2A9, 0xAEBD, 0xB2AA, 0xAEBE, 0xB2AB, 0xAEC0, 0xB2AC, 0xAEC4,\t0xB2AD, 0xAECC, 0xB2AE, 0xAECD, 0xB2AF, 0xAECF, 0xB2B0, 0xAED0,\r\n\t0xB2B1, 0xAED1, 0xB2B2, 0xAED8, 0xB2B3, 0xAED9, 0xB2B4, 0xAEDC,\t0xB2B5, 0xAEE8, 0xB2B6, 0xAEEB, 0xB2B7, 0xAEED, 0xB2B8, 0xAEF4,\r\n\t0xB2B9, 0xAEF8, 0xB2BA, 0xAEFC, 0xB2BB, 0xAF07, 0xB2BC, 0xAF08,\t0xB2BD, 0xAF0D, 0xB2BE, 0xAF10, 0xB2BF, 0xAF2C, 0xB2C0, 0xAF2D,\r\n\t0xB2C1, 0xAF30, 0xB2C2, 0xAF32, 0xB2C3, 0xAF34, 0xB2C4, 0xAF3C,\t0xB2C5, 0xAF3D, 0xB2C6, 0xAF3F, 0xB2C7, 0xAF41, 0xB2C8, 0xAF42,\r\n\t0xB2C9, 0xAF43, 0xB2CA, 0xAF48, 0xB2CB, 0xAF49, 0xB2CC, 0xAF50,\t0xB2CD, 0xAF5C, 0xB2CE, 0xAF5D, 0xB2CF, 0xAF64, 0xB2D0, 0xAF65,\r\n\t0xB2D1, 0xAF79, 0xB2D2, 0xAF80, 0xB2D3, 0xAF84, 0xB2D4, 0xAF88,\t0xB2D5, 0xAF90, 0xB2D6, 0xAF91, 0xB2D7, 0xAF95, 0xB2D8, 0xAF9C,\r\n\t0xB2D9, 0xAFB8, 0xB2DA, 0xAFB9, 0xB2DB, 0xAFBC, 0xB2DC, 0xAFC0,\t0xB2DD, 0xAFC7, 0xB2DE, 0xAFC8, 0xB2DF, 0xAFC9, 0xB2E0, 0xAFCB,\r\n\t0xB2E1, 0xAFCD, 0xB2E2, 0xAFCE, 0xB2E3, 0xAFD4, 0xB2E4, 0xAFDC,\t0xB2E5, 0xAFE8, 0xB2E6, 0xAFE9, 0xB2E7, 0xAFF0, 0xB2E8, 0xAFF1,\r\n\t0xB2E9, 0xAFF4, 0xB2EA, 0xAFF8, 0xB2EB, 0xB000, 0xB2EC, 0xB001,\t0xB2ED, 0xB004, 0xB2EE, 0xB00C, 0xB2EF, 0xB010, 0xB2F0, 0xB014,\r\n\t0xB2F1, 0xB01C, 0xB2F2, 0xB01D, 0xB2F3, 0xB028, 0xB2F4, 0xB044,\t0xB2F5, 0xB045, 0xB2F6, 0xB048, 0xB2F7, 0xB04A, 0xB2F8, 0xB04C,\r\n\t0xB2F9, 0xB04E, 0xB2FA, 0xB053, 0xB2FB, 0xB054, 0xB2FC, 0xB055,\t0xB2FD, 0xB057, 0xB2FE, 0xB059, 0xB341, 0xCFCC, 0xB342, 0xCFCD,\r\n\t0xB343, 0xCFCE, 0xB344, 0xCFCF, 0xB345, 0xCFD0, 0xB346, 0xCFD1,\t0xB347, 0xCFD2, 0xB348, 0xCFD3, 0xB349, 0xCFD4, 0xB34A, 0xCFD5,\r\n\t0xB34B, 0xCFD6, 0xB34C, 0xCFD7, 0xB34D, 0xCFD8, 0xB34E, 0xCFD9,\t0xB34F, 0xCFDA, 0xB350, 0xCFDB, 0xB351, 0xCFDC, 0xB352, 0xCFDD,\r\n\t0xB353, 0xCFDE, 0xB354, 0xCFDF, 0xB355, 0xCFE2, 0xB356, 0xCFE3,\t0xB357, 0xCFE5, 0xB358, 0xCFE6, 0xB359, 0xCFE7, 0xB35A, 0xCFE9,\r\n\t0xB361, 0xCFEA, 0xB362, 0xCFEB, 0xB363, 0xCFEC, 0xB364, 0xCFED,\t0xB365, 0xCFEE, 0xB366, 0xCFEF, 0xB367, 0xCFF2, 0xB368, 0xCFF4,\r\n\t0xB369, 0xCFF6, 0xB36A, 0xCFF7, 0xB36B, 0xCFF8, 0xB36C, 0xCFF9,\t0xB36D, 0xCFFA, 0xB36E, 0xCFFB, 0xB36F, 0xCFFD, 0xB370, 0xCFFE,\r\n\t0xB371, 0xCFFF, 0xB372, 0xD001, 0xB373, 0xD002, 0xB374, 0xD003,\t0xB375, 0xD005, 0xB376, 0xD006, 0xB377, 0xD007, 0xB378, 0xD008,\r\n\t0xB379, 0xD009, 0xB37A, 0xD00A, 0xB381, 0xD00B, 0xB382, 0xD00C,\t0xB383, 0xD00D, 0xB384, 0xD00E, 0xB385, 0xD00F, 0xB386, 0xD010,\r\n\t0xB387, 0xD012, 0xB388, 0xD013, 0xB389, 0xD014, 0xB38A, 0xD015,\t0xB38B, 0xD016, 0xB38C, 0xD017, 0xB38D, 0xD019, 0xB38E, 0xD01A,\r\n\t0xB38F, 0xD01B, 0xB390, 0xD01C, 0xB391, 0xD01D, 0xB392, 0xD01E,\t0xB393, 0xD01F, 0xB394, 0xD020, 0xB395, 0xD021, 0xB396, 0xD022,\r\n\t0xB397, 0xD023, 0xB398, 0xD024, 0xB399, 0xD025, 0xB39A, 0xD026,\t0xB39B, 0xD027, 0xB39C, 0xD028, 0xB39D, 0xD029, 0xB39E, 0xD02A,\r\n\t0xB39F, 0xD02B, 0xB3A0, 0xD02C, 0xB3A1, 0xB05D, 0xB3A2, 0xB07C,\t0xB3A3, 0xB07D, 0xB3A4, 0xB080, 0xB3A5, 0xB084, 0xB3A6, 0xB08C,\r\n\t0xB3A7, 0xB08D, 0xB3A8, 0xB08F, 0xB3A9, 0xB091, 0xB3AA, 0xB098,\t0xB3AB, 0xB099, 0xB3AC, 0xB09A, 0xB3AD, 0xB09C, 0xB3AE, 0xB09F,\r\n\t0xB3AF, 0xB0A0, 0xB3B0, 0xB0A1, 0xB3B1, 0xB0A2, 0xB3B2, 0xB0A8,\t0xB3B3, 0xB0A9, 0xB3B4, 0xB0AB, 0xB3B5, 0xB0AC, 0xB3B6, 0xB0AD,\r\n\t0xB3B7, 0xB0AE, 0xB3B8, 0xB0AF, 0xB3B9, 0xB0B1, 0xB3BA, 0xB0B3,\t0xB3BB, 0xB0B4, 0xB3BC, 0xB0B5, 0xB3BD, 0xB0B8, 0xB3BE, 0xB0BC,\r\n\t0xB3BF, 0xB0C4, 0xB3C0, 0xB0C5, 0xB3C1, 0xB0C7, 0xB3C2, 0xB0C8,\t0xB3C3, 0xB0C9, 0xB3C4, 0xB0D0, 0xB3C5, 0xB0D1, 0xB3C6, 0xB0D4,\r\n\t0xB3C7, 0xB0D8, 0xB3C8, 0xB0E0, 0xB3C9, 0xB0E5, 0xB3CA, 0xB108,\t0xB3CB, 0xB109, 0xB3CC, 0xB10B, 0xB3CD, 0xB10C, 0xB3CE, 0xB110,\r\n\t0xB3CF, 0xB112, 0xB3D0, 0xB113, 0xB3D1, 0xB118, 0xB3D2, 0xB119,\t0xB3D3, 0xB11B, 0xB3D4, 0xB11C, 0xB3D5, 0xB11D, 0xB3D6, 0xB123,\r\n\t0xB3D7, 0xB124, 0xB3D8, 0xB125, 0xB3D9, 0xB128, 0xB3DA, 0xB12C,\t0xB3DB, 0xB134, 0xB3DC, 0xB135, 0xB3DD, 0xB137, 0xB3DE, 0xB138,\r\n\t0xB3DF, 0xB139, 0xB3E0, 0xB140, 0xB3E1, 0xB141, 0xB3E2, 0xB144,\t0xB3E3, 0xB148, 0xB3E4, 0xB150, 0xB3E5, 0xB151, 0xB3E6, 0xB154,\r\n\t0xB3E7, 0xB155, 0xB3E8, 0xB158, 0xB3E9, 0xB15C, 0xB3EA, 0xB160,\t0xB3EB, 0xB178, 0xB3EC, 0xB179, 0xB3ED, 0xB17C, 0xB3EE, 0xB180,\r\n\t0xB3EF, 0xB182, 0xB3F0, 0xB188, 0xB3F1, 0xB189, 0xB3F2, 0xB18B,\t0xB3F3, 0xB18D, 0xB3F4, 0xB192, 0xB3F5, 0xB193, 0xB3F6, 0xB194,\r\n\t0xB3F7, 0xB198, 0xB3F8, 0xB19C, 0xB3F9, 0xB1A8, 0xB3FA, 0xB1CC,\t0xB3FB, 0xB1D0, 0xB3FC, 0xB1D4, 0xB3FD, 0xB1DC, 0xB3FE, 0xB1DD,\r\n\t0xB441, 0xD02E, 0xB442, 0xD02F, 0xB443, 0xD030, 0xB444, 0xD031,\t0xB445, 0xD032, 0xB446, 0xD033, 0xB447, 0xD036, 0xB448, 0xD037,\r\n\t0xB449, 0xD039, 0xB44A, 0xD03A, 0xB44B, 0xD03B, 0xB44C, 0xD03D,\t0xB44D, 0xD03E, 0xB44E, 0xD03F, 0xB44F, 0xD040, 0xB450, 0xD041,\r\n\t0xB451, 0xD042, 0xB452, 0xD043, 0xB453, 0xD046, 0xB454, 0xD048,\t0xB455, 0xD04A, 0xB456, 0xD04B, 0xB457, 0xD04C, 0xB458, 0xD04D,\r\n\t0xB459, 0xD04E, 0xB45A, 0xD04F, 0xB461, 0xD051, 0xB462, 0xD052,\t0xB463, 0xD053, 0xB464, 0xD055, 0xB465, 0xD056, 0xB466, 0xD057,\r\n\t0xB467, 0xD059, 0xB468, 0xD05A, 0xB469, 0xD05B, 0xB46A, 0xD05C,\t0xB46B, 0xD05D, 0xB46C, 0xD05E, 0xB46D, 0xD05F, 0xB46E, 0xD061,\r\n\t0xB46F, 0xD062, 0xB470, 0xD063, 0xB471, 0xD064, 0xB472, 0xD065,\t0xB473, 0xD066, 0xB474, 0xD067, 0xB475, 0xD068, 0xB476, 0xD069,\r\n\t0xB477, 0xD06A, 0xB478, 0xD06B, 0xB479, 0xD06E, 0xB47A, 0xD06F,\t0xB481, 0xD071, 0xB482, 0xD072, 0xB483, 0xD073, 0xB484, 0xD075,\r\n\t0xB485, 0xD076, 0xB486, 0xD077, 0xB487, 0xD078, 0xB488, 0xD079,\t0xB489, 0xD07A, 0xB48A, 0xD07B, 0xB48B, 0xD07E, 0xB48C, 0xD07F,\r\n\t0xB48D, 0xD080, 0xB48E, 0xD082, 0xB48F, 0xD083, 0xB490, 0xD084,\t0xB491, 0xD085, 0xB492, 0xD086, 0xB493, 0xD087, 0xB494, 0xD088,\r\n\t0xB495, 0xD089, 0xB496, 0xD08A, 0xB497, 0xD08B, 0xB498, 0xD08C,\t0xB499, 0xD08D, 0xB49A, 0xD08E, 0xB49B, 0xD08F, 0xB49C, 0xD090,\r\n\t0xB49D, 0xD091, 0xB49E, 0xD092, 0xB49F, 0xD093, 0xB4A0, 0xD094,\t0xB4A1, 0xB1DF, 0xB4A2, 0xB1E8, 0xB4A3, 0xB1E9, 0xB4A4, 0xB1EC,\r\n\t0xB4A5, 0xB1F0, 0xB4A6, 0xB1F9, 0xB4A7, 0xB1FB, 0xB4A8, 0xB1FD,\t0xB4A9, 0xB204, 0xB4AA, 0xB205, 0xB4AB, 0xB208, 0xB4AC, 0xB20B,\r\n\t0xB4AD, 0xB20C, 0xB4AE, 0xB214, 0xB4AF, 0xB215, 0xB4B0, 0xB217,\t0xB4B1, 0xB219, 0xB4B2, 0xB220, 0xB4B3, 0xB234, 0xB4B4, 0xB23C,\r\n\t0xB4B5, 0xB258, 0xB4B6, 0xB25C, 0xB4B7, 0xB260, 0xB4B8, 0xB268,\t0xB4B9, 0xB269, 0xB4BA, 0xB274, 0xB4BB, 0xB275, 0xB4BC, 0xB27C,\r\n\t0xB4BD, 0xB284, 0xB4BE, 0xB285, 0xB4BF, 0xB289, 0xB4C0, 0xB290,\t0xB4C1, 0xB291, 0xB4C2, 0xB294, 0xB4C3, 0xB298, 0xB4C4, 0xB299,\r\n\t0xB4C5, 0xB29A, 0xB4C6, 0xB2A0, 0xB4C7, 0xB2A1, 0xB4C8, 0xB2A3,\t0xB4C9, 0xB2A5, 0xB4CA, 0xB2A6, 0xB4CB, 0xB2AA, 0xB4CC, 0xB2AC,\r\n\t0xB4CD, 0xB2B0, 0xB4CE, 0xB2B4, 0xB4CF, 0xB2C8, 0xB4D0, 0xB2C9,\t0xB4D1, 0xB2CC, 0xB4D2, 0xB2D0, 0xB4D3, 0xB2D2, 0xB4D4, 0xB2D8,\r\n\t0xB4D5, 0xB2D9, 0xB4D6, 0xB2DB, 0xB4D7, 0xB2DD, 0xB4D8, 0xB2E2,\t0xB4D9, 0xB2E4, 0xB4DA, 0xB2E5, 0xB4DB, 0xB2E6, 0xB4DC, 0xB2E8,\r\n\t0xB4DD, 0xB2EB, 0xB4DE, 0xB2EC, 0xB4DF, 0xB2ED, 0xB4E0, 0xB2EE,\t0xB4E1, 0xB2EF, 0xB4E2, 0xB2F3, 0xB4E3, 0xB2F4, 0xB4E4, 0xB2F5,\r\n\t0xB4E5, 0xB2F7, 0xB4E6, 0xB2F8, 0xB4E7, 0xB2F9, 0xB4E8, 0xB2FA,\t0xB4E9, 0xB2FB, 0xB4EA, 0xB2FF, 0xB4EB, 0xB300, 0xB4EC, 0xB301,\r\n\t0xB4ED, 0xB304, 0xB4EE, 0xB308, 0xB4EF, 0xB310, 0xB4F0, 0xB311,\t0xB4F1, 0xB313, 0xB4F2, 0xB314, 0xB4F3, 0xB315, 0xB4F4, 0xB31C,\r\n\t0xB4F5, 0xB354, 0xB4F6, 0xB355, 0xB4F7, 0xB356, 0xB4F8, 0xB358,\t0xB4F9, 0xB35B, 0xB4FA, 0xB35C, 0xB4FB, 0xB35E, 0xB4FC, 0xB35F,\r\n\t0xB4FD, 0xB364, 0xB4FE, 0xB365, 0xB541, 0xD095, 0xB542, 0xD096,\t0xB543, 0xD097, 0xB544, 0xD098, 0xB545, 0xD099, 0xB546, 0xD09A,\r\n\t0xB547, 0xD09B, 0xB548, 0xD09C, 0xB549, 0xD09D, 0xB54A, 0xD09E,\t0xB54B, 0xD09F, 0xB54C, 0xD0A0, 0xB54D, 0xD0A1, 0xB54E, 0xD0A2,\r\n\t0xB54F, 0xD0A3, 0xB550, 0xD0A6, 0xB551, 0xD0A7, 0xB552, 0xD0A9,\t0xB553, 0xD0AA, 0xB554, 0xD0AB, 0xB555, 0xD0AD, 0xB556, 0xD0AE,\r\n\t0xB557, 0xD0AF, 0xB558, 0xD0B0, 0xB559, 0xD0B1, 0xB55A, 0xD0B2,\t0xB561, 0xD0B3, 0xB562, 0xD0B6, 0xB563, 0xD0B8, 0xB564, 0xD0BA,\r\n\t0xB565, 0xD0BB, 0xB566, 0xD0BC, 0xB567, 0xD0BD, 0xB568, 0xD0BE,\t0xB569, 0xD0BF, 0xB56A, 0xD0C2, 0xB56B, 0xD0C3, 0xB56C, 0xD0C5,\r\n\t0xB56D, 0xD0C6, 0xB56E, 0xD0C7, 0xB56F, 0xD0CA, 0xB570, 0xD0CB,\t0xB571, 0xD0CC, 0xB572, 0xD0CD, 0xB573, 0xD0CE, 0xB574, 0xD0CF,\r\n\t0xB575, 0xD0D2, 0xB576, 0xD0D6, 0xB577, 0xD0D7, 0xB578, 0xD0D8,\t0xB579, 0xD0D9, 0xB57A, 0xD0DA, 0xB581, 0xD0DB, 0xB582, 0xD0DE,\r\n\t0xB583, 0xD0DF, 0xB584, 0xD0E1, 0xB585, 0xD0E2, 0xB586, 0xD0E3,\t0xB587, 0xD0E5, 0xB588, 0xD0E6, 0xB589, 0xD0E7, 0xB58A, 0xD0E8,\r\n\t0xB58B, 0xD0E9, 0xB58C, 0xD0EA, 0xB58D, 0xD0EB, 0xB58E, 0xD0EE,\t0xB58F, 0xD0F2, 0xB590, 0xD0F3, 0xB591, 0xD0F4, 0xB592, 0xD0F5,\r\n\t0xB593, 0xD0F6, 0xB594, 0xD0F7, 0xB595, 0xD0F9, 0xB596, 0xD0FA,\t0xB597, 0xD0FB, 0xB598, 0xD0FC, 0xB599, 0xD0FD, 0xB59A, 0xD0FE,\r\n\t0xB59B, 0xD0FF, 0xB59C, 0xD100, 0xB59D, 0xD101, 0xB59E, 0xD102,\t0xB59F, 0xD103, 0xB5A0, 0xD104, 0xB5A1, 0xB367, 0xB5A2, 0xB369,\r\n\t0xB5A3, 0xB36B, 0xB5A4, 0xB36E, 0xB5A5, 0xB370, 0xB5A6, 0xB371,\t0xB5A7, 0xB374, 0xB5A8, 0xB378, 0xB5A9, 0xB380, 0xB5AA, 0xB381,\r\n\t0xB5AB, 0xB383, 0xB5AC, 0xB384, 0xB5AD, 0xB385, 0xB5AE, 0xB38C,\t0xB5AF, 0xB390, 0xB5B0, 0xB394, 0xB5B1, 0xB3A0, 0xB5B2, 0xB3A1,\r\n\t0xB5B3, 0xB3A8, 0xB5B4, 0xB3AC, 0xB5B5, 0xB3C4, 0xB5B6, 0xB3C5,\t0xB5B7, 0xB3C8, 0xB5B8, 0xB3CB, 0xB5B9, 0xB3CC, 0xB5BA, 0xB3CE,\r\n\t0xB5BB, 0xB3D0, 0xB5BC, 0xB3D4, 0xB5BD, 0xB3D5, 0xB5BE, 0xB3D7,\t0xB5BF, 0xB3D9, 0xB5C0, 0xB3DB, 0xB5C1, 0xB3DD, 0xB5C2, 0xB3E0,\r\n\t0xB5C3, 0xB3E4, 0xB5C4, 0xB3E8, 0xB5C5, 0xB3FC, 0xB5C6, 0xB410,\t0xB5C7, 0xB418, 0xB5C8, 0xB41C, 0xB5C9, 0xB420, 0xB5CA, 0xB428,\r\n\t0xB5CB, 0xB429, 0xB5CC, 0xB42B, 0xB5CD, 0xB434, 0xB5CE, 0xB450,\t0xB5CF, 0xB451, 0xB5D0, 0xB454, 0xB5D1, 0xB458, 0xB5D2, 0xB460,\r\n\t0xB5D3, 0xB461, 0xB5D4, 0xB463, 0xB5D5, 0xB465, 0xB5D6, 0xB46C,\t0xB5D7, 0xB480, 0xB5D8, 0xB488, 0xB5D9, 0xB49D, 0xB5DA, 0xB4A4,\r\n\t0xB5DB, 0xB4A8, 0xB5DC, 0xB4AC, 0xB5DD, 0xB4B5, 0xB5DE, 0xB4B7,\t0xB5DF, 0xB4B9, 0xB5E0, 0xB4C0, 0xB5E1, 0xB4C4, 0xB5E2, 0xB4C8,\r\n\t0xB5E3, 0xB4D0, 0xB5E4, 0xB4D5, 0xB5E5, 0xB4DC, 0xB5E6, 0xB4DD,\t0xB5E7, 0xB4E0, 0xB5E8, 0xB4E3, 0xB5E9, 0xB4E4, 0xB5EA, 0xB4E6,\r\n\t0xB5EB, 0xB4EC, 0xB5EC, 0xB4ED, 0xB5ED, 0xB4EF, 0xB5EE, 0xB4F1,\t0xB5EF, 0xB4F8, 0xB5F0, 0xB514, 0xB5F1, 0xB515, 0xB5F2, 0xB518,\r\n\t0xB5F3, 0xB51B, 0xB5F4, 0xB51C, 0xB5F5, 0xB524, 0xB5F6, 0xB525,\t0xB5F7, 0xB527, 0xB5F8, 0xB528, 0xB5F9, 0xB529, 0xB5FA, 0xB52A,\r\n\t0xB5FB, 0xB530, 0xB5FC, 0xB531, 0xB5FD, 0xB534, 0xB5FE, 0xB538,\t0xB641, 0xD105, 0xB642, 0xD106, 0xB643, 0xD107, 0xB644, 0xD108,\r\n\t0xB645, 0xD109, 0xB646, 0xD10A, 0xB647, 0xD10B, 0xB648, 0xD10C,\t0xB649, 0xD10E, 0xB64A, 0xD10F, 0xB64B, 0xD110, 0xB64C, 0xD111,\r\n\t0xB64D, 0xD112, 0xB64E, 0xD113, 0xB64F, 0xD114, 0xB650, 0xD115,\t0xB651, 0xD116, 0xB652, 0xD117, 0xB653, 0xD118, 0xB654, 0xD119,\r\n\t0xB655, 0xD11A, 0xB656, 0xD11B, 0xB657, 0xD11C, 0xB658, 0xD11D,\t0xB659, 0xD11E, 0xB65A, 0xD11F, 0xB661, 0xD120, 0xB662, 0xD121,\r\n\t0xB663, 0xD122, 0xB664, 0xD123, 0xB665, 0xD124, 0xB666, 0xD125,\t0xB667, 0xD126, 0xB668, 0xD127, 0xB669, 0xD128, 0xB66A, 0xD129,\r\n\t0xB66B, 0xD12A, 0xB66C, 0xD12B, 0xB66D, 0xD12C, 0xB66E, 0xD12D,\t0xB66F, 0xD12E, 0xB670, 0xD12F, 0xB671, 0xD132, 0xB672, 0xD133,\r\n\t0xB673, 0xD135, 0xB674, 0xD136, 0xB675, 0xD137, 0xB676, 0xD139,\t0xB677, 0xD13B, 0xB678, 0xD13C, 0xB679, 0xD13D, 0xB67A, 0xD13E,\r\n\t0xB681, 0xD13F, 0xB682, 0xD142, 0xB683, 0xD146, 0xB684, 0xD147,\t0xB685, 0xD148, 0xB686, 0xD149, 0xB687, 0xD14A, 0xB688, 0xD14B,\r\n\t0xB689, 0xD14E, 0xB68A, 0xD14F, 0xB68B, 0xD151, 0xB68C, 0xD152,\t0xB68D, 0xD153, 0xB68E, 0xD155, 0xB68F, 0xD156, 0xB690, 0xD157,\r\n\t0xB691, 0xD158, 0xB692, 0xD159, 0xB693, 0xD15A, 0xB694, 0xD15B,\t0xB695, 0xD15E, 0xB696, 0xD160, 0xB697, 0xD162, 0xB698, 0xD163,\r\n\t0xB699, 0xD164, 0xB69A, 0xD165, 0xB69B, 0xD166, 0xB69C, 0xD167,\t0xB69D, 0xD169, 0xB69E, 0xD16A, 0xB69F, 0xD16B, 0xB6A0, 0xD16D,\r\n\t0xB6A1, 0xB540, 0xB6A2, 0xB541, 0xB6A3, 0xB543, 0xB6A4, 0xB544,\t0xB6A5, 0xB545, 0xB6A6, 0xB54B, 0xB6A7, 0xB54C, 0xB6A8, 0xB54D,\r\n\t0xB6A9, 0xB550, 0xB6AA, 0xB554, 0xB6AB, 0xB55C, 0xB6AC, 0xB55D,\t0xB6AD, 0xB55F, 0xB6AE, 0xB560, 0xB6AF, 0xB561, 0xB6B0, 0xB5A0,\r\n\t0xB6B1, 0xB5A1, 0xB6B2, 0xB5A4, 0xB6B3, 0xB5A8, 0xB6B4, 0xB5AA,\t0xB6B5, 0xB5AB, 0xB6B6, 0xB5B0, 0xB6B7, 0xB5B1, 0xB6B8, 0xB5B3,\r\n\t0xB6B9, 0xB5B4, 0xB6BA, 0xB5B5, 0xB6BB, 0xB5BB, 0xB6BC, 0xB5BC,\t0xB6BD, 0xB5BD, 0xB6BE, 0xB5C0, 0xB6BF, 0xB5C4, 0xB6C0, 0xB5CC,\r\n\t0xB6C1, 0xB5CD, 0xB6C2, 0xB5CF, 0xB6C3, 0xB5D0, 0xB6C4, 0xB5D1,\t0xB6C5, 0xB5D8, 0xB6C6, 0xB5EC, 0xB6C7, 0xB610, 0xB6C8, 0xB611,\r\n\t0xB6C9, 0xB614, 0xB6CA, 0xB618, 0xB6CB, 0xB625, 0xB6CC, 0xB62C,\t0xB6CD, 0xB634, 0xB6CE, 0xB648, 0xB6CF, 0xB664, 0xB6D0, 0xB668,\r\n\t0xB6D1, 0xB69C, 0xB6D2, 0xB69D, 0xB6D3, 0xB6A0, 0xB6D4, 0xB6A4,\t0xB6D5, 0xB6AB, 0xB6D6, 0xB6AC, 0xB6D7, 0xB6B1, 0xB6D8, 0xB6D4,\r\n\t0xB6D9, 0xB6F0, 0xB6DA, 0xB6F4, 0xB6DB, 0xB6F8, 0xB6DC, 0xB700,\t0xB6DD, 0xB701, 0xB6DE, 0xB705, 0xB6DF, 0xB728, 0xB6E0, 0xB729,\r\n\t0xB6E1, 0xB72C, 0xB6E2, 0xB72F, 0xB6E3, 0xB730, 0xB6E4, 0xB738,\t0xB6E5, 0xB739, 0xB6E6, 0xB73B, 0xB6E7, 0xB744, 0xB6E8, 0xB748,\r\n\t0xB6E9, 0xB74C, 0xB6EA, 0xB754, 0xB6EB, 0xB755, 0xB6EC, 0xB760,\t0xB6ED, 0xB764, 0xB6EE, 0xB768, 0xB6EF, 0xB770, 0xB6F0, 0xB771,\r\n\t0xB6F1, 0xB773, 0xB6F2, 0xB775, 0xB6F3, 0xB77C, 0xB6F4, 0xB77D,\t0xB6F5, 0xB780, 0xB6F6, 0xB784, 0xB6F7, 0xB78C, 0xB6F8, 0xB78D,\r\n\t0xB6F9, 0xB78F, 0xB6FA, 0xB790, 0xB6FB, 0xB791, 0xB6FC, 0xB792,\t0xB6FD, 0xB796, 0xB6FE, 0xB797, 0xB741, 0xD16E, 0xB742, 0xD16F,\r\n\t0xB743, 0xD170, 0xB744, 0xD171, 0xB745, 0xD172, 0xB746, 0xD173,\t0xB747, 0xD174, 0xB748, 0xD175, 0xB749, 0xD176, 0xB74A, 0xD177,\r\n\t0xB74B, 0xD178, 0xB74C, 0xD179, 0xB74D, 0xD17A, 0xB74E, 0xD17B,\t0xB74F, 0xD17D, 0xB750, 0xD17E, 0xB751, 0xD17F, 0xB752, 0xD180,\r\n\t0xB753, 0xD181, 0xB754, 0xD182, 0xB755, 0xD183, 0xB756, 0xD185,\t0xB757, 0xD186, 0xB758, 0xD187, 0xB759, 0xD189, 0xB75A, 0xD18A,\r\n\t0xB761, 0xD18B, 0xB762, 0xD18C, 0xB763, 0xD18D, 0xB764, 0xD18E,\t0xB765, 0xD18F, 0xB766, 0xD190, 0xB767, 0xD191, 0xB768, 0xD192,\r\n\t0xB769, 0xD193, 0xB76A, 0xD194, 0xB76B, 0xD195, 0xB76C, 0xD196,\t0xB76D, 0xD197, 0xB76E, 0xD198, 0xB76F, 0xD199, 0xB770, 0xD19A,\r\n\t0xB771, 0xD19B, 0xB772, 0xD19C, 0xB773, 0xD19D, 0xB774, 0xD19E,\t0xB775, 0xD19F, 0xB776, 0xD1A2, 0xB777, 0xD1A3, 0xB778, 0xD1A5,\r\n\t0xB779, 0xD1A6, 0xB77A, 0xD1A7, 0xB781, 0xD1A9, 0xB782, 0xD1AA,\t0xB783, 0xD1AB, 0xB784, 0xD1AC, 0xB785, 0xD1AD, 0xB786, 0xD1AE,\r\n\t0xB787, 0xD1AF, 0xB788, 0xD1B2, 0xB789, 0xD1B4, 0xB78A, 0xD1B6,\t0xB78B, 0xD1B7, 0xB78C, 0xD1B8, 0xB78D, 0xD1B9, 0xB78E, 0xD1BB,\r\n\t0xB78F, 0xD1BD, 0xB790, 0xD1BE, 0xB791, 0xD1BF, 0xB792, 0xD1C1,\t0xB793, 0xD1C2, 0xB794, 0xD1C3, 0xB795, 0xD1C4, 0xB796, 0xD1C5,\r\n\t0xB797, 0xD1C6, 0xB798, 0xD1C7, 0xB799, 0xD1C8, 0xB79A, 0xD1C9,\t0xB79B, 0xD1CA, 0xB79C, 0xD1CB, 0xB79D, 0xD1CC, 0xB79E, 0xD1CD,\r\n\t0xB79F, 0xD1CE, 0xB7A0, 0xD1CF, 0xB7A1, 0xB798, 0xB7A2, 0xB799,\t0xB7A3, 0xB79C, 0xB7A4, 0xB7A0, 0xB7A5, 0xB7A8, 0xB7A6, 0xB7A9,\r\n\t0xB7A7, 0xB7AB, 0xB7A8, 0xB7AC, 0xB7A9, 0xB7AD, 0xB7AA, 0xB7B4,\t0xB7AB, 0xB7B5, 0xB7AC, 0xB7B8, 0xB7AD, 0xB7C7, 0xB7AE, 0xB7C9,\r\n\t0xB7AF, 0xB7EC, 0xB7B0, 0xB7ED, 0xB7B1, 0xB7F0, 0xB7B2, 0xB7F4,\t0xB7B3, 0xB7FC, 0xB7B4, 0xB7FD, 0xB7B5, 0xB7FF, 0xB7B6, 0xB800,\r\n\t0xB7B7, 0xB801, 0xB7B8, 0xB807, 0xB7B9, 0xB808, 0xB7BA, 0xB809,\t0xB7BB, 0xB80C, 0xB7BC, 0xB810, 0xB7BD, 0xB818, 0xB7BE, 0xB819,\r\n\t0xB7BF, 0xB81B, 0xB7C0, 0xB81D, 0xB7C1, 0xB824, 0xB7C2, 0xB825,\t0xB7C3, 0xB828, 0xB7C4, 0xB82C, 0xB7C5, 0xB834, 0xB7C6, 0xB835,\r\n\t0xB7C7, 0xB837, 0xB7C8, 0xB838, 0xB7C9, 0xB839, 0xB7CA, 0xB840,\t0xB7CB, 0xB844, 0xB7CC, 0xB851, 0xB7CD, 0xB853, 0xB7CE, 0xB85C,\r\n\t0xB7CF, 0xB85D, 0xB7D0, 0xB860, 0xB7D1, 0xB864, 0xB7D2, 0xB86C,\t0xB7D3, 0xB86D, 0xB7D4, 0xB86F, 0xB7D5, 0xB871, 0xB7D6, 0xB878,\r\n\t0xB7D7, 0xB87C, 0xB7D8, 0xB88D, 0xB7D9, 0xB8A8, 0xB7DA, 0xB8B0,\t0xB7DB, 0xB8B4, 0xB7DC, 0xB8B8, 0xB7DD, 0xB8C0, 0xB7DE, 0xB8C1,\r\n\t0xB7DF, 0xB8C3, 0xB7E0, 0xB8C5, 0xB7E1, 0xB8CC, 0xB7E2, 0xB8D0,\t0xB7E3, 0xB8D4, 0xB7E4, 0xB8DD, 0xB7E5, 0xB8DF, 0xB7E6, 0xB8E1,\r\n\t0xB7E7, 0xB8E8, 0xB7E8, 0xB8E9, 0xB7E9, 0xB8EC, 0xB7EA, 0xB8F0,\t0xB7EB, 0xB8F8, 0xB7EC, 0xB8F9, 0xB7ED, 0xB8FB, 0xB7EE, 0xB8FD,\r\n\t0xB7EF, 0xB904, 0xB7F0, 0xB918, 0xB7F1, 0xB920, 0xB7F2, 0xB93C,\t0xB7F3, 0xB93D, 0xB7F4, 0xB940, 0xB7F5, 0xB944, 0xB7F6, 0xB94C,\r\n\t0xB7F7, 0xB94F, 0xB7F8, 0xB951, 0xB7F9, 0xB958, 0xB7FA, 0xB959,\t0xB7FB, 0xB95C, 0xB7FC, 0xB960, 0xB7FD, 0xB968, 0xB7FE, 0xB969,\r\n\t0xB841, 0xD1D0, 0xB842, 0xD1D1, 0xB843, 0xD1D2, 0xB844, 0xD1D3,\t0xB845, 0xD1D4, 0xB846, 0xD1D5, 0xB847, 0xD1D6, 0xB848, 0xD1D7,\r\n\t0xB849, 0xD1D9, 0xB84A, 0xD1DA, 0xB84B, 0xD1DB, 0xB84C, 0xD1DC,\t0xB84D, 0xD1DD, 0xB84E, 0xD1DE, 0xB84F, 0xD1DF, 0xB850, 0xD1E0,\r\n\t0xB851, 0xD1E1, 0xB852, 0xD1E2, 0xB853, 0xD1E3, 0xB854, 0xD1E4,\t0xB855, 0xD1E5, 0xB856, 0xD1E6, 0xB857, 0xD1E7, 0xB858, 0xD1E8,\r\n\t0xB859, 0xD1E9, 0xB85A, 0xD1EA, 0xB861, 0xD1EB, 0xB862, 0xD1EC,\t0xB863, 0xD1ED, 0xB864, 0xD1EE, 0xB865, 0xD1EF, 0xB866, 0xD1F0,\r\n\t0xB867, 0xD1F1, 0xB868, 0xD1F2, 0xB869, 0xD1F3, 0xB86A, 0xD1F5,\t0xB86B, 0xD1F6, 0xB86C, 0xD1F7, 0xB86D, 0xD1F9, 0xB86E, 0xD1FA,\r\n\t0xB86F, 0xD1FB, 0xB870, 0xD1FC, 0xB871, 0xD1FD, 0xB872, 0xD1FE,\t0xB873, 0xD1FF, 0xB874, 0xD200, 0xB875, 0xD201, 0xB876, 0xD202,\r\n\t0xB877, 0xD203, 0xB878, 0xD204, 0xB879, 0xD205, 0xB87A, 0xD206,\t0xB881, 0xD208, 0xB882, 0xD20A, 0xB883, 0xD20B, 0xB884, 0xD20C,\r\n\t0xB885, 0xD20D, 0xB886, 0xD20E, 0xB887, 0xD20F, 0xB888, 0xD211,\t0xB889, 0xD212, 0xB88A, 0xD213, 0xB88B, 0xD214, 0xB88C, 0xD215,\r\n\t0xB88D, 0xD216, 0xB88E, 0xD217, 0xB88F, 0xD218, 0xB890, 0xD219,\t0xB891, 0xD21A, 0xB892, 0xD21B, 0xB893, 0xD21C, 0xB894, 0xD21D,\r\n\t0xB895, 0xD21E, 0xB896, 0xD21F, 0xB897, 0xD220, 0xB898, 0xD221,\t0xB899, 0xD222, 0xB89A, 0xD223, 0xB89B, 0xD224, 0xB89C, 0xD225,\r\n\t0xB89D, 0xD226, 0xB89E, 0xD227, 0xB89F, 0xD228, 0xB8A0, 0xD229,\t0xB8A1, 0xB96B, 0xB8A2, 0xB96D, 0xB8A3, 0xB974, 0xB8A4, 0xB975,\r\n\t0xB8A5, 0xB978, 0xB8A6, 0xB97C, 0xB8A7, 0xB984, 0xB8A8, 0xB985,\t0xB8A9, 0xB987, 0xB8AA, 0xB989, 0xB8AB, 0xB98A, 0xB8AC, 0xB98D,\r\n\t0xB8AD, 0xB98E, 0xB8AE, 0xB9AC, 0xB8AF, 0xB9AD, 0xB8B0, 0xB9B0,\t0xB8B1, 0xB9B4, 0xB8B2, 0xB9BC, 0xB8B3, 0xB9BD, 0xB8B4, 0xB9BF,\r\n\t0xB8B5, 0xB9C1, 0xB8B6, 0xB9C8, 0xB8B7, 0xB9C9, 0xB8B8, 0xB9CC,\t0xB8B9, 0xB9CE, 0xB8BA, 0xB9CF, 0xB8BB, 0xB9D0, 0xB8BC, 0xB9D1,\r\n\t0xB8BD, 0xB9D2, 0xB8BE, 0xB9D8, 0xB8BF, 0xB9D9, 0xB8C0, 0xB9DB,\t0xB8C1, 0xB9DD, 0xB8C2, 0xB9DE, 0xB8C3, 0xB9E1, 0xB8C4, 0xB9E3,\r\n\t0xB8C5, 0xB9E4, 0xB8C6, 0xB9E5, 0xB8C7, 0xB9E8, 0xB8C8, 0xB9EC,\t0xB8C9, 0xB9F4, 0xB8CA, 0xB9F5, 0xB8CB, 0xB9F7, 0xB8CC, 0xB9F8,\r\n\t0xB8CD, 0xB9F9, 0xB8CE, 0xB9FA, 0xB8CF, 0xBA00, 0xB8D0, 0xBA01,\t0xB8D1, 0xBA08, 0xB8D2, 0xBA15, 0xB8D3, 0xBA38, 0xB8D4, 0xBA39,\r\n\t0xB8D5, 0xBA3C, 0xB8D6, 0xBA40, 0xB8D7, 0xBA42, 0xB8D8, 0xBA48,\t0xB8D9, 0xBA49, 0xB8DA, 0xBA4B, 0xB8DB, 0xBA4D, 0xB8DC, 0xBA4E,\r\n\t0xB8DD, 0xBA53, 0xB8DE, 0xBA54, 0xB8DF, 0xBA55, 0xB8E0, 0xBA58,\t0xB8E1, 0xBA5C, 0xB8E2, 0xBA64, 0xB8E3, 0xBA65, 0xB8E4, 0xBA67,\r\n\t0xB8E5, 0xBA68, 0xB8E6, 0xBA69, 0xB8E7, 0xBA70, 0xB8E8, 0xBA71,\t0xB8E9, 0xBA74, 0xB8EA, 0xBA78, 0xB8EB, 0xBA83, 0xB8EC, 0xBA84,\r\n\t0xB8ED, 0xBA85, 0xB8EE, 0xBA87, 0xB8EF, 0xBA8C, 0xB8F0, 0xBAA8,\t0xB8F1, 0xBAA9, 0xB8F2, 0xBAAB, 0xB8F3, 0xBAAC, 0xB8F4, 0xBAB0,\r\n\t0xB8F5, 0xBAB2, 0xB8F6, 0xBAB8, 0xB8F7, 0xBAB9, 0xB8F8, 0xBABB,\t0xB8F9, 0xBABD, 0xB8FA, 0xBAC4, 0xB8FB, 0xBAC8, 0xB8FC, 0xBAD8,\r\n\t0xB8FD, 0xBAD9, 0xB8FE, 0xBAFC, 0xB941, 0xD22A, 0xB942, 0xD22B,\t0xB943, 0xD22E, 0xB944, 0xD22F, 0xB945, 0xD231, 0xB946, 0xD232,\r\n\t0xB947, 0xD233, 0xB948, 0xD235, 0xB949, 0xD236, 0xB94A, 0xD237,\t0xB94B, 0xD238, 0xB94C, 0xD239, 0xB94D, 0xD23A, 0xB94E, 0xD23B,\r\n\t0xB94F, 0xD23E, 0xB950, 0xD240, 0xB951, 0xD242, 0xB952, 0xD243,\t0xB953, 0xD244, 0xB954, 0xD245, 0xB955, 0xD246, 0xB956, 0xD247,\r\n\t0xB957, 0xD249, 0xB958, 0xD24A, 0xB959, 0xD24B, 0xB95A, 0xD24C,\t0xB961, 0xD24D, 0xB962, 0xD24E, 0xB963, 0xD24F, 0xB964, 0xD250,\r\n\t0xB965, 0xD251, 0xB966, 0xD252, 0xB967, 0xD253, 0xB968, 0xD254,\t0xB969, 0xD255, 0xB96A, 0xD256, 0xB96B, 0xD257, 0xB96C, 0xD258,\r\n\t0xB96D, 0xD259, 0xB96E, 0xD25A, 0xB96F, 0xD25B, 0xB970, 0xD25D,\t0xB971, 0xD25E, 0xB972, 0xD25F, 0xB973, 0xD260, 0xB974, 0xD261,\r\n\t0xB975, 0xD262, 0xB976, 0xD263, 0xB977, 0xD265, 0xB978, 0xD266,\t0xB979, 0xD267, 0xB97A, 0xD268, 0xB981, 0xD269, 0xB982, 0xD26A,\r\n\t0xB983, 0xD26B, 0xB984, 0xD26C, 0xB985, 0xD26D, 0xB986, 0xD26E,\t0xB987, 0xD26F, 0xB988, 0xD270, 0xB989, 0xD271, 0xB98A, 0xD272,\r\n\t0xB98B, 0xD273, 0xB98C, 0xD274, 0xB98D, 0xD275, 0xB98E, 0xD276,\t0xB98F, 0xD277, 0xB990, 0xD278, 0xB991, 0xD279, 0xB992, 0xD27A,\r\n\t0xB993, 0xD27B, 0xB994, 0xD27C, 0xB995, 0xD27D, 0xB996, 0xD27E,\t0xB997, 0xD27F, 0xB998, 0xD282, 0xB999, 0xD283, 0xB99A, 0xD285,\r\n\t0xB99B, 0xD286, 0xB99C, 0xD287, 0xB99D, 0xD289, 0xB99E, 0xD28A,\t0xB99F, 0xD28B, 0xB9A0, 0xD28C, 0xB9A1, 0xBB00, 0xB9A2, 0xBB04,\r\n\t0xB9A3, 0xBB0D, 0xB9A4, 0xBB0F, 0xB9A5, 0xBB11, 0xB9A6, 0xBB18,\t0xB9A7, 0xBB1C, 0xB9A8, 0xBB20, 0xB9A9, 0xBB29, 0xB9AA, 0xBB2B,\r\n\t0xB9AB, 0xBB34, 0xB9AC, 0xBB35, 0xB9AD, 0xBB36, 0xB9AE, 0xBB38,\t0xB9AF, 0xBB3B, 0xB9B0, 0xBB3C, 0xB9B1, 0xBB3D, 0xB9B2, 0xBB3E,\r\n\t0xB9B3, 0xBB44, 0xB9B4, 0xBB45, 0xB9B5, 0xBB47, 0xB9B6, 0xBB49,\t0xB9B7, 0xBB4D, 0xB9B8, 0xBB4F, 0xB9B9, 0xBB50, 0xB9BA, 0xBB54,\r\n\t0xB9BB, 0xBB58, 0xB9BC, 0xBB61, 0xB9BD, 0xBB63, 0xB9BE, 0xBB6C,\t0xB9BF, 0xBB88, 0xB9C0, 0xBB8C, 0xB9C1, 0xBB90, 0xB9C2, 0xBBA4,\r\n\t0xB9C3, 0xBBA8, 0xB9C4, 0xBBAC, 0xB9C5, 0xBBB4, 0xB9C6, 0xBBB7,\t0xB9C7, 0xBBC0, 0xB9C8, 0xBBC4, 0xB9C9, 0xBBC8, 0xB9CA, 0xBBD0,\r\n\t0xB9CB, 0xBBD3, 0xB9CC, 0xBBF8, 0xB9CD, 0xBBF9, 0xB9CE, 0xBBFC,\t0xB9CF, 0xBBFF, 0xB9D0, 0xBC00, 0xB9D1, 0xBC02, 0xB9D2, 0xBC08,\r\n\t0xB9D3, 0xBC09, 0xB9D4, 0xBC0B, 0xB9D5, 0xBC0C, 0xB9D6, 0xBC0D,\t0xB9D7, 0xBC0F, 0xB9D8, 0xBC11, 0xB9D9, 0xBC14, 0xB9DA, 0xBC15,\r\n\t0xB9DB, 0xBC16, 0xB9DC, 0xBC17, 0xB9DD, 0xBC18, 0xB9DE, 0xBC1B,\t0xB9DF, 0xBC1C, 0xB9E0, 0xBC1D, 0xB9E1, 0xBC1E, 0xB9E2, 0xBC1F,\r\n\t0xB9E3, 0xBC24, 0xB9E4, 0xBC25, 0xB9E5, 0xBC27, 0xB9E6, 0xBC29,\t0xB9E7, 0xBC2D, 0xB9E8, 0xBC30, 0xB9E9, 0xBC31, 0xB9EA, 0xBC34,\r\n\t0xB9EB, 0xBC38, 0xB9EC, 0xBC40, 0xB9ED, 0xBC41, 0xB9EE, 0xBC43,\t0xB9EF, 0xBC44, 0xB9F0, 0xBC45, 0xB9F1, 0xBC49, 0xB9F2, 0xBC4C,\r\n\t0xB9F3, 0xBC4D, 0xB9F4, 0xBC50, 0xB9F5, 0xBC5D, 0xB9F6, 0xBC84,\t0xB9F7, 0xBC85, 0xB9F8, 0xBC88, 0xB9F9, 0xBC8B, 0xB9FA, 0xBC8C,\r\n\t0xB9FB, 0xBC8E, 0xB9FC, 0xBC94, 0xB9FD, 0xBC95, 0xB9FE, 0xBC97,\t0xBA41, 0xD28D, 0xBA42, 0xD28E, 0xBA43, 0xD28F, 0xBA44, 0xD292,\r\n\t0xBA45, 0xD293, 0xBA46, 0xD294, 0xBA47, 0xD296, 0xBA48, 0xD297,\t0xBA49, 0xD298, 0xBA4A, 0xD299, 0xBA4B, 0xD29A, 0xBA4C, 0xD29B,\r\n\t0xBA4D, 0xD29D, 0xBA4E, 0xD29E, 0xBA4F, 0xD29F, 0xBA50, 0xD2A1,\t0xBA51, 0xD2A2, 0xBA52, 0xD2A3, 0xBA53, 0xD2A5, 0xBA54, 0xD2A6,\r\n\t0xBA55, 0xD2A7, 0xBA56, 0xD2A8, 0xBA57, 0xD2A9, 0xBA58, 0xD2AA,\t0xBA59, 0xD2AB, 0xBA5A, 0xD2AD, 0xBA61, 0xD2AE, 0xBA62, 0xD2AF,\r\n\t0xBA63, 0xD2B0, 0xBA64, 0xD2B2, 0xBA65, 0xD2B3, 0xBA66, 0xD2B4,\t0xBA67, 0xD2B5, 0xBA68, 0xD2B6, 0xBA69, 0xD2B7, 0xBA6A, 0xD2BA,\r\n\t0xBA6B, 0xD2BB, 0xBA6C, 0xD2BD, 0xBA6D, 0xD2BE, 0xBA6E, 0xD2C1,\t0xBA6F, 0xD2C3, 0xBA70, 0xD2C4, 0xBA71, 0xD2C5, 0xBA72, 0xD2C6,\r\n\t0xBA73, 0xD2C7, 0xBA74, 0xD2CA, 0xBA75, 0xD2CC, 0xBA76, 0xD2CD,\t0xBA77, 0xD2CE, 0xBA78, 0xD2CF, 0xBA79, 0xD2D0, 0xBA7A, 0xD2D1,\r\n\t0xBA81, 0xD2D2, 0xBA82, 0xD2D3, 0xBA83, 0xD2D5, 0xBA84, 0xD2D6,\t0xBA85, 0xD2D7, 0xBA86, 0xD2D9, 0xBA87, 0xD2DA, 0xBA88, 0xD2DB,\r\n\t0xBA89, 0xD2DD, 0xBA8A, 0xD2DE, 0xBA8B, 0xD2DF, 0xBA8C, 0xD2E0,\t0xBA8D, 0xD2E1, 0xBA8E, 0xD2E2, 0xBA8F, 0xD2E3, 0xBA90, 0xD2E6,\r\n\t0xBA91, 0xD2E7, 0xBA92, 0xD2E8, 0xBA93, 0xD2E9, 0xBA94, 0xD2EA,\t0xBA95, 0xD2EB, 0xBA96, 0xD2EC, 0xBA97, 0xD2ED, 0xBA98, 0xD2EE,\r\n\t0xBA99, 0xD2EF, 0xBA9A, 0xD2F2, 0xBA9B, 0xD2F3, 0xBA9C, 0xD2F5,\t0xBA9D, 0xD2F6, 0xBA9E, 0xD2F7, 0xBA9F, 0xD2F9, 0xBAA0, 0xD2FA,\r\n\t0xBAA1, 0xBC99, 0xBAA2, 0xBC9A, 0xBAA3, 0xBCA0, 0xBAA4, 0xBCA1,\t0xBAA5, 0xBCA4, 0xBAA6, 0xBCA7, 0xBAA7, 0xBCA8, 0xBAA8, 0xBCB0,\r\n\t0xBAA9, 0xBCB1, 0xBAAA, 0xBCB3, 0xBAAB, 0xBCB4, 0xBAAC, 0xBCB5,\t0xBAAD, 0xBCBC, 0xBAAE, 0xBCBD, 0xBAAF, 0xBCC0, 0xBAB0, 0xBCC4,\r\n\t0xBAB1, 0xBCCD, 0xBAB2, 0xBCCF, 0xBAB3, 0xBCD0, 0xBAB4, 0xBCD1,\t0xBAB5, 0xBCD5, 0xBAB6, 0xBCD8, 0xBAB7, 0xBCDC, 0xBAB8, 0xBCF4,\r\n\t0xBAB9, 0xBCF5, 0xBABA, 0xBCF6, 0xBABB, 0xBCF8, 0xBABC, 0xBCFC,\t0xBABD, 0xBD04, 0xBABE, 0xBD05, 0xBABF, 0xBD07, 0xBAC0, 0xBD09,\r\n\t0xBAC1, 0xBD10, 0xBAC2, 0xBD14, 0xBAC3, 0xBD24, 0xBAC4, 0xBD2C,\t0xBAC5, 0xBD40, 0xBAC6, 0xBD48, 0xBAC7, 0xBD49, 0xBAC8, 0xBD4C,\r\n\t0xBAC9, 0xBD50, 0xBACA, 0xBD58, 0xBACB, 0xBD59, 0xBACC, 0xBD64,\t0xBACD, 0xBD68, 0xBACE, 0xBD80, 0xBACF, 0xBD81, 0xBAD0, 0xBD84,\r\n\t0xBAD1, 0xBD87, 0xBAD2, 0xBD88, 0xBAD3, 0xBD89, 0xBAD4, 0xBD8A,\t0xBAD5, 0xBD90, 0xBAD6, 0xBD91, 0xBAD7, 0xBD93, 0xBAD8, 0xBD95,\r\n\t0xBAD9, 0xBD99, 0xBADA, 0xBD9A, 0xBADB, 0xBD9C, 0xBADC, 0xBDA4,\t0xBADD, 0xBDB0, 0xBADE, 0xBDB8, 0xBADF, 0xBDD4, 0xBAE0, 0xBDD5,\r\n\t0xBAE1, 0xBDD8, 0xBAE2, 0xBDDC, 0xBAE3, 0xBDE9, 0xBAE4, 0xBDF0,\t0xBAE5, 0xBDF4, 0xBAE6, 0xBDF8, 0xBAE7, 0xBE00, 0xBAE8, 0xBE03,\r\n\t0xBAE9, 0xBE05, 0xBAEA, 0xBE0C, 0xBAEB, 0xBE0D, 0xBAEC, 0xBE10,\t0xBAED, 0xBE14, 0xBAEE, 0xBE1C, 0xBAEF, 0xBE1D, 0xBAF0, 0xBE1F,\r\n\t0xBAF1, 0xBE44, 0xBAF2, 0xBE45, 0xBAF3, 0xBE48, 0xBAF4, 0xBE4C,\t0xBAF5, 0xBE4E, 0xBAF6, 0xBE54, 0xBAF7, 0xBE55, 0xBAF8, 0xBE57,\r\n\t0xBAF9, 0xBE59, 0xBAFA, 0xBE5A, 0xBAFB, 0xBE5B, 0xBAFC, 0xBE60,\t0xBAFD, 0xBE61, 0xBAFE, 0xBE64, 0xBB41, 0xD2FB, 0xBB42, 0xD2FC,\r\n\t0xBB43, 0xD2FD, 0xBB44, 0xD2FE, 0xBB45, 0xD2FF, 0xBB46, 0xD302,\t0xBB47, 0xD304, 0xBB48, 0xD306, 0xBB49, 0xD307, 0xBB4A, 0xD308,\r\n\t0xBB4B, 0xD309, 0xBB4C, 0xD30A, 0xBB4D, 0xD30B, 0xBB4E, 0xD30F,\t0xBB4F, 0xD311, 0xBB50, 0xD312, 0xBB51, 0xD313, 0xBB52, 0xD315,\r\n\t0xBB53, 0xD317, 0xBB54, 0xD318, 0xBB55, 0xD319, 0xBB56, 0xD31A,\t0xBB57, 0xD31B, 0xBB58, 0xD31E, 0xBB59, 0xD322, 0xBB5A, 0xD323,\r\n\t0xBB61, 0xD324, 0xBB62, 0xD326, 0xBB63, 0xD327, 0xBB64, 0xD32A,\t0xBB65, 0xD32B, 0xBB66, 0xD32D, 0xBB67, 0xD32E, 0xBB68, 0xD32F,\r\n\t0xBB69, 0xD331, 0xBB6A, 0xD332, 0xBB6B, 0xD333, 0xBB6C, 0xD334,\t0xBB6D, 0xD335, 0xBB6E, 0xD336, 0xBB6F, 0xD337, 0xBB70, 0xD33A,\r\n\t0xBB71, 0xD33E, 0xBB72, 0xD33F, 0xBB73, 0xD340, 0xBB74, 0xD341,\t0xBB75, 0xD342, 0xBB76, 0xD343, 0xBB77, 0xD346, 0xBB78, 0xD347,\r\n\t0xBB79, 0xD348, 0xBB7A, 0xD349, 0xBB81, 0xD34A, 0xBB82, 0xD34B,\t0xBB83, 0xD34C, 0xBB84, 0xD34D, 0xBB85, 0xD34E, 0xBB86, 0xD34F,\r\n\t0xBB87, 0xD350, 0xBB88, 0xD351, 0xBB89, 0xD352, 0xBB8A, 0xD353,\t0xBB8B, 0xD354, 0xBB8C, 0xD355, 0xBB8D, 0xD356, 0xBB8E, 0xD357,\r\n\t0xBB8F, 0xD358, 0xBB90, 0xD359, 0xBB91, 0xD35A, 0xBB92, 0xD35B,\t0xBB93, 0xD35C, 0xBB94, 0xD35D, 0xBB95, 0xD35E, 0xBB96, 0xD35F,\r\n\t0xBB97, 0xD360, 0xBB98, 0xD361, 0xBB99, 0xD362, 0xBB9A, 0xD363,\t0xBB9B, 0xD364, 0xBB9C, 0xD365, 0xBB9D, 0xD366, 0xBB9E, 0xD367,\r\n\t0xBB9F, 0xD368, 0xBBA0, 0xD369, 0xBBA1, 0xBE68, 0xBBA2, 0xBE6A,\t0xBBA3, 0xBE70, 0xBBA4, 0xBE71, 0xBBA5, 0xBE73, 0xBBA6, 0xBE74,\r\n\t0xBBA7, 0xBE75, 0xBBA8, 0xBE7B, 0xBBA9, 0xBE7C, 0xBBAA, 0xBE7D,\t0xBBAB, 0xBE80, 0xBBAC, 0xBE84, 0xBBAD, 0xBE8C, 0xBBAE, 0xBE8D,\r\n\t0xBBAF, 0xBE8F, 0xBBB0, 0xBE90, 0xBBB1, 0xBE91, 0xBBB2, 0xBE98,\t0xBBB3, 0xBE99, 0xBBB4, 0xBEA8, 0xBBB5, 0xBED0, 0xBBB6, 0xBED1,\r\n\t0xBBB7, 0xBED4, 0xBBB8, 0xBED7, 0xBBB9, 0xBED8, 0xBBBA, 0xBEE0,\t0xBBBB, 0xBEE3, 0xBBBC, 0xBEE4, 0xBBBD, 0xBEE5, 0xBBBE, 0xBEEC,\r\n\t0xBBBF, 0xBF01, 0xBBC0, 0xBF08, 0xBBC1, 0xBF09, 0xBBC2, 0xBF18,\t0xBBC3, 0xBF19, 0xBBC4, 0xBF1B, 0xBBC5, 0xBF1C, 0xBBC6, 0xBF1D,\r\n\t0xBBC7, 0xBF40, 0xBBC8, 0xBF41, 0xBBC9, 0xBF44, 0xBBCA, 0xBF48,\t0xBBCB, 0xBF50, 0xBBCC, 0xBF51, 0xBBCD, 0xBF55, 0xBBCE, 0xBF94,\r\n\t0xBBCF, 0xBFB0, 0xBBD0, 0xBFC5, 0xBBD1, 0xBFCC, 0xBBD2, 0xBFCD,\t0xBBD3, 0xBFD0, 0xBBD4, 0xBFD4, 0xBBD5, 0xBFDC, 0xBBD6, 0xBFDF,\r\n\t0xBBD7, 0xBFE1, 0xBBD8, 0xC03C, 0xBBD9, 0xC051, 0xBBDA, 0xC058,\t0xBBDB, 0xC05C, 0xBBDC, 0xC060, 0xBBDD, 0xC068, 0xBBDE, 0xC069,\r\n\t0xBBDF, 0xC090, 0xBBE0, 0xC091, 0xBBE1, 0xC094, 0xBBE2, 0xC098,\t0xBBE3, 0xC0A0, 0xBBE4, 0xC0A1, 0xBBE5, 0xC0A3, 0xBBE6, 0xC0A5,\r\n\t0xBBE7, 0xC0AC, 0xBBE8, 0xC0AD, 0xBBE9, 0xC0AF, 0xBBEA, 0xC0B0,\t0xBBEB, 0xC0B3, 0xBBEC, 0xC0B4, 0xBBED, 0xC0B5, 0xBBEE, 0xC0B6,\r\n\t0xBBEF, 0xC0BC, 0xBBF0, 0xC0BD, 0xBBF1, 0xC0BF, 0xBBF2, 0xC0C0,\t0xBBF3, 0xC0C1, 0xBBF4, 0xC0C5, 0xBBF5, 0xC0C8, 0xBBF6, 0xC0C9,\r\n\t0xBBF7, 0xC0CC, 0xBBF8, 0xC0D0, 0xBBF9, 0xC0D8, 0xBBFA, 0xC0D9,\t0xBBFB, 0xC0DB, 0xBBFC, 0xC0DC, 0xBBFD, 0xC0DD, 0xBBFE, 0xC0E4,\r\n\t0xBC41, 0xD36A, 0xBC42, 0xD36B, 0xBC43, 0xD36C, 0xBC44, 0xD36D,\t0xBC45, 0xD36E, 0xBC46, 0xD36F, 0xBC47, 0xD370, 0xBC48, 0xD371,\r\n\t0xBC49, 0xD372, 0xBC4A, 0xD373, 0xBC4B, 0xD374, 0xBC4C, 0xD375,\t0xBC4D, 0xD376, 0xBC4E, 0xD377, 0xBC4F, 0xD378, 0xBC50, 0xD379,\r\n\t0xBC51, 0xD37A, 0xBC52, 0xD37B, 0xBC53, 0xD37E, 0xBC54, 0xD37F,\t0xBC55, 0xD381, 0xBC56, 0xD382, 0xBC57, 0xD383, 0xBC58, 0xD385,\r\n\t0xBC59, 0xD386, 0xBC5A, 0xD387, 0xBC61, 0xD388, 0xBC62, 0xD389,\t0xBC63, 0xD38A, 0xBC64, 0xD38B, 0xBC65, 0xD38E, 0xBC66, 0xD392,\r\n\t0xBC67, 0xD393, 0xBC68, 0xD394, 0xBC69, 0xD395, 0xBC6A, 0xD396,\t0xBC6B, 0xD397, 0xBC6C, 0xD39A, 0xBC6D, 0xD39B, 0xBC6E, 0xD39D,\r\n\t0xBC6F, 0xD39E, 0xBC70, 0xD39F, 0xBC71, 0xD3A1, 0xBC72, 0xD3A2,\t0xBC73, 0xD3A3, 0xBC74, 0xD3A4, 0xBC75, 0xD3A5, 0xBC76, 0xD3A6,\r\n\t0xBC77, 0xD3A7, 0xBC78, 0xD3AA, 0xBC79, 0xD3AC, 0xBC7A, 0xD3AE,\t0xBC81, 0xD3AF, 0xBC82, 0xD3B0, 0xBC83, 0xD3B1, 0xBC84, 0xD3B2,\r\n\t0xBC85, 0xD3B3, 0xBC86, 0xD3B5, 0xBC87, 0xD3B6, 0xBC88, 0xD3B7,\t0xBC89, 0xD3B9, 0xBC8A, 0xD3BA, 0xBC8B, 0xD3BB, 0xBC8C, 0xD3BD,\r\n\t0xBC8D, 0xD3BE, 0xBC8E, 0xD3BF, 0xBC8F, 0xD3C0, 0xBC90, 0xD3C1,\t0xBC91, 0xD3C2, 0xBC92, 0xD3C3, 0xBC93, 0xD3C6, 0xBC94, 0xD3C7,\r\n\t0xBC95, 0xD3CA, 0xBC96, 0xD3CB, 0xBC97, 0xD3CC, 0xBC98, 0xD3CD,\t0xBC99, 0xD3CE, 0xBC9A, 0xD3CF, 0xBC9B, 0xD3D1, 0xBC9C, 0xD3D2,\r\n\t0xBC9D, 0xD3D3, 0xBC9E, 0xD3D4, 0xBC9F, 0xD3D5, 0xBCA0, 0xD3D6,\t0xBCA1, 0xC0E5, 0xBCA2, 0xC0E8, 0xBCA3, 0xC0EC, 0xBCA4, 0xC0F4,\r\n\t0xBCA5, 0xC0F5, 0xBCA6, 0xC0F7, 0xBCA7, 0xC0F9, 0xBCA8, 0xC100,\t0xBCA9, 0xC104, 0xBCAA, 0xC108, 0xBCAB, 0xC110, 0xBCAC, 0xC115,\r\n\t0xBCAD, 0xC11C, 0xBCAE, 0xC11D, 0xBCAF, 0xC11E, 0xBCB0, 0xC11F,\t0xBCB1, 0xC120, 0xBCB2, 0xC123, 0xBCB3, 0xC124, 0xBCB4, 0xC126,\r\n\t0xBCB5, 0xC127, 0xBCB6, 0xC12C, 0xBCB7, 0xC12D, 0xBCB8, 0xC12F,\t0xBCB9, 0xC130, 0xBCBA, 0xC131, 0xBCBB, 0xC136, 0xBCBC, 0xC138,\r\n\t0xBCBD, 0xC139, 0xBCBE, 0xC13C, 0xBCBF, 0xC140, 0xBCC0, 0xC148,\t0xBCC1, 0xC149, 0xBCC2, 0xC14B, 0xBCC3, 0xC14C, 0xBCC4, 0xC14D,\r\n\t0xBCC5, 0xC154, 0xBCC6, 0xC155, 0xBCC7, 0xC158, 0xBCC8, 0xC15C,\t0xBCC9, 0xC164, 0xBCCA, 0xC165, 0xBCCB, 0xC167, 0xBCCC, 0xC168,\r\n\t0xBCCD, 0xC169, 0xBCCE, 0xC170, 0xBCCF, 0xC174, 0xBCD0, 0xC178,\t0xBCD1, 0xC185, 0xBCD2, 0xC18C, 0xBCD3, 0xC18D, 0xBCD4, 0xC18E,\r\n\t0xBCD5, 0xC190, 0xBCD6, 0xC194, 0xBCD7, 0xC196, 0xBCD8, 0xC19C,\t0xBCD9, 0xC19D, 0xBCDA, 0xC19F, 0xBCDB, 0xC1A1, 0xBCDC, 0xC1A5,\r\n\t0xBCDD, 0xC1A8, 0xBCDE, 0xC1A9, 0xBCDF, 0xC1AC, 0xBCE0, 0xC1B0,\t0xBCE1, 0xC1BD, 0xBCE2, 0xC1C4, 0xBCE3, 0xC1C8, 0xBCE4, 0xC1CC,\r\n\t0xBCE5, 0xC1D4, 0xBCE6, 0xC1D7, 0xBCE7, 0xC1D8, 0xBCE8, 0xC1E0,\t0xBCE9, 0xC1E4, 0xBCEA, 0xC1E8, 0xBCEB, 0xC1F0, 0xBCEC, 0xC1F1,\r\n\t0xBCED, 0xC1F3, 0xBCEE, 0xC1FC, 0xBCEF, 0xC1FD, 0xBCF0, 0xC200,\t0xBCF1, 0xC204, 0xBCF2, 0xC20C, 0xBCF3, 0xC20D, 0xBCF4, 0xC20F,\r\n\t0xBCF5, 0xC211, 0xBCF6, 0xC218, 0xBCF7, 0xC219, 0xBCF8, 0xC21C,\t0xBCF9, 0xC21F, 0xBCFA, 0xC220, 0xBCFB, 0xC228, 0xBCFC, 0xC229,\r\n\t0xBCFD, 0xC22B, 0xBCFE, 0xC22D, 0xBD41, 0xD3D7, 0xBD42, 0xD3D9,\t0xBD43, 0xD3DA, 0xBD44, 0xD3DB, 0xBD45, 0xD3DC, 0xBD46, 0xD3DD,\r\n\t0xBD47, 0xD3DE, 0xBD48, 0xD3DF, 0xBD49, 0xD3E0, 0xBD4A, 0xD3E2,\t0xBD4B, 0xD3E4, 0xBD4C, 0xD3E5, 0xBD4D, 0xD3E6, 0xBD4E, 0xD3E7,\r\n\t0xBD4F, 0xD3E8, 0xBD50, 0xD3E9, 0xBD51, 0xD3EA, 0xBD52, 0xD3EB,\t0xBD53, 0xD3EE, 0xBD54, 0xD3EF, 0xBD55, 0xD3F1, 0xBD56, 0xD3F2,\r\n\t0xBD57, 0xD3F3, 0xBD58, 0xD3F5, 0xBD59, 0xD3F6, 0xBD5A, 0xD3F7,\t0xBD61, 0xD3F8, 0xBD62, 0xD3F9, 0xBD63, 0xD3FA, 0xBD64, 0xD3FB,\r\n\t0xBD65, 0xD3FE, 0xBD66, 0xD400, 0xBD67, 0xD402, 0xBD68, 0xD403,\t0xBD69, 0xD404, 0xBD6A, 0xD405, 0xBD6B, 0xD406, 0xBD6C, 0xD407,\r\n\t0xBD6D, 0xD409, 0xBD6E, 0xD40A, 0xBD6F, 0xD40B, 0xBD70, 0xD40C,\t0xBD71, 0xD40D, 0xBD72, 0xD40E, 0xBD73, 0xD40F, 0xBD74, 0xD410,\r\n\t0xBD75, 0xD411, 0xBD76, 0xD412, 0xBD77, 0xD413, 0xBD78, 0xD414,\t0xBD79, 0xD415, 0xBD7A, 0xD416, 0xBD81, 0xD417, 0xBD82, 0xD418,\r\n\t0xBD83, 0xD419, 0xBD84, 0xD41A, 0xBD85, 0xD41B, 0xBD86, 0xD41C,\t0xBD87, 0xD41E, 0xBD88, 0xD41F, 0xBD89, 0xD420, 0xBD8A, 0xD421,\r\n\t0xBD8B, 0xD422, 0xBD8C, 0xD423, 0xBD8D, 0xD424, 0xBD8E, 0xD425,\t0xBD8F, 0xD426, 0xBD90, 0xD427, 0xBD91, 0xD428, 0xBD92, 0xD429,\r\n\t0xBD93, 0xD42A, 0xBD94, 0xD42B, 0xBD95, 0xD42C, 0xBD96, 0xD42D,\t0xBD97, 0xD42E, 0xBD98, 0xD42F, 0xBD99, 0xD430, 0xBD9A, 0xD431,\r\n\t0xBD9B, 0xD432, 0xBD9C, 0xD433, 0xBD9D, 0xD434, 0xBD9E, 0xD435,\t0xBD9F, 0xD436, 0xBDA0, 0xD437, 0xBDA1, 0xC22F, 0xBDA2, 0xC231,\r\n\t0xBDA3, 0xC232, 0xBDA4, 0xC234, 0xBDA5, 0xC248, 0xBDA6, 0xC250,\t0xBDA7, 0xC251, 0xBDA8, 0xC254, 0xBDA9, 0xC258, 0xBDAA, 0xC260,\r\n\t0xBDAB, 0xC265, 0xBDAC, 0xC26C, 0xBDAD, 0xC26D, 0xBDAE, 0xC270,\t0xBDAF, 0xC274, 0xBDB0, 0xC27C, 0xBDB1, 0xC27D, 0xBDB2, 0xC27F,\r\n\t0xBDB3, 0xC281, 0xBDB4, 0xC288, 0xBDB5, 0xC289, 0xBDB6, 0xC290,\t0xBDB7, 0xC298, 0xBDB8, 0xC29B, 0xBDB9, 0xC29D, 0xBDBA, 0xC2A4,\r\n\t0xBDBB, 0xC2A5, 0xBDBC, 0xC2A8, 0xBDBD, 0xC2AC, 0xBDBE, 0xC2AD,\t0xBDBF, 0xC2B4, 0xBDC0, 0xC2B5, 0xBDC1, 0xC2B7, 0xBDC2, 0xC2B9,\r\n\t0xBDC3, 0xC2DC, 0xBDC4, 0xC2DD, 0xBDC5, 0xC2E0, 0xBDC6, 0xC2E3,\t0xBDC7, 0xC2E4, 0xBDC8, 0xC2EB, 0xBDC9, 0xC2EC, 0xBDCA, 0xC2ED,\r\n\t0xBDCB, 0xC2EF, 0xBDCC, 0xC2F1, 0xBDCD, 0xC2F6, 0xBDCE, 0xC2F8,\t0xBDCF, 0xC2F9, 0xBDD0, 0xC2FB, 0xBDD1, 0xC2FC, 0xBDD2, 0xC300,\r\n\t0xBDD3, 0xC308, 0xBDD4, 0xC309, 0xBDD5, 0xC30C, 0xBDD6, 0xC30D,\t0xBDD7, 0xC313, 0xBDD8, 0xC314, 0xBDD9, 0xC315, 0xBDDA, 0xC318,\r\n\t0xBDDB, 0xC31C, 0xBDDC, 0xC324, 0xBDDD, 0xC325, 0xBDDE, 0xC328,\t0xBDDF, 0xC329, 0xBDE0, 0xC345, 0xBDE1, 0xC368, 0xBDE2, 0xC369,\r\n\t0xBDE3, 0xC36C, 0xBDE4, 0xC370, 0xBDE5, 0xC372, 0xBDE6, 0xC378,\t0xBDE7, 0xC379, 0xBDE8, 0xC37C, 0xBDE9, 0xC37D, 0xBDEA, 0xC384,\r\n\t0xBDEB, 0xC388, 0xBDEC, 0xC38C, 0xBDED, 0xC3C0, 0xBDEE, 0xC3D8,\t0xBDEF, 0xC3D9, 0xBDF0, 0xC3DC, 0xBDF1, 0xC3DF, 0xBDF2, 0xC3E0,\r\n\t0xBDF3, 0xC3E2, 0xBDF4, 0xC3E8, 0xBDF5, 0xC3E9, 0xBDF6, 0xC3ED,\t0xBDF7, 0xC3F4, 0xBDF8, 0xC3F5, 0xBDF9, 0xC3F8, 0xBDFA, 0xC408,\r\n\t0xBDFB, 0xC410, 0xBDFC, 0xC424, 0xBDFD, 0xC42C, 0xBDFE, 0xC430,\t0xBE41, 0xD438, 0xBE42, 0xD439, 0xBE43, 0xD43A, 0xBE44, 0xD43B,\r\n\t0xBE45, 0xD43C, 0xBE46, 0xD43D, 0xBE47, 0xD43E, 0xBE48, 0xD43F,\t0xBE49, 0xD441, 0xBE4A, 0xD442, 0xBE4B, 0xD443, 0xBE4C, 0xD445,\r\n\t0xBE4D, 0xD446, 0xBE4E, 0xD447, 0xBE4F, 0xD448, 0xBE50, 0xD449,\t0xBE51, 0xD44A, 0xBE52, 0xD44B, 0xBE53, 0xD44C, 0xBE54, 0xD44D,\r\n\t0xBE55, 0xD44E, 0xBE56, 0xD44F, 0xBE57, 0xD450, 0xBE58, 0xD451,\t0xBE59, 0xD452, 0xBE5A, 0xD453, 0xBE61, 0xD454, 0xBE62, 0xD455,\r\n\t0xBE63, 0xD456, 0xBE64, 0xD457, 0xBE65, 0xD458, 0xBE66, 0xD459,\t0xBE67, 0xD45A, 0xBE68, 0xD45B, 0xBE69, 0xD45D, 0xBE6A, 0xD45E,\r\n\t0xBE6B, 0xD45F, 0xBE6C, 0xD461, 0xBE6D, 0xD462, 0xBE6E, 0xD463,\t0xBE6F, 0xD465, 0xBE70, 0xD466, 0xBE71, 0xD467, 0xBE72, 0xD468,\r\n\t0xBE73, 0xD469, 0xBE74, 0xD46A, 0xBE75, 0xD46B, 0xBE76, 0xD46C,\t0xBE77, 0xD46E, 0xBE78, 0xD470, 0xBE79, 0xD471, 0xBE7A, 0xD472,\r\n\t0xBE81, 0xD473, 0xBE82, 0xD474, 0xBE83, 0xD475, 0xBE84, 0xD476,\t0xBE85, 0xD477, 0xBE86, 0xD47A, 0xBE87, 0xD47B, 0xBE88, 0xD47D,\r\n\t0xBE89, 0xD47E, 0xBE8A, 0xD481, 0xBE8B, 0xD483, 0xBE8C, 0xD484,\t0xBE8D, 0xD485, 0xBE8E, 0xD486, 0xBE8F, 0xD487, 0xBE90, 0xD48A,\r\n\t0xBE91, 0xD48C, 0xBE92, 0xD48E, 0xBE93, 0xD48F, 0xBE94, 0xD490,\t0xBE95, 0xD491, 0xBE96, 0xD492, 0xBE97, 0xD493, 0xBE98, 0xD495,\r\n\t0xBE99, 0xD496, 0xBE9A, 0xD497, 0xBE9B, 0xD498, 0xBE9C, 0xD499,\t0xBE9D, 0xD49A, 0xBE9E, 0xD49B, 0xBE9F, 0xD49C, 0xBEA0, 0xD49D,\r\n\t0xBEA1, 0xC434, 0xBEA2, 0xC43C, 0xBEA3, 0xC43D, 0xBEA4, 0xC448,\t0xBEA5, 0xC464, 0xBEA6, 0xC465, 0xBEA7, 0xC468, 0xBEA8, 0xC46C,\r\n\t0xBEA9, 0xC474, 0xBEAA, 0xC475, 0xBEAB, 0xC479, 0xBEAC, 0xC480,\t0xBEAD, 0xC494, 0xBEAE, 0xC49C, 0xBEAF, 0xC4B8, 0xBEB0, 0xC4BC,\r\n\t0xBEB1, 0xC4E9, 0xBEB2, 0xC4F0, 0xBEB3, 0xC4F1, 0xBEB4, 0xC4F4,\t0xBEB5, 0xC4F8, 0xBEB6, 0xC4FA, 0xBEB7, 0xC4FF, 0xBEB8, 0xC500,\r\n\t0xBEB9, 0xC501, 0xBEBA, 0xC50C, 0xBEBB, 0xC510, 0xBEBC, 0xC514,\t0xBEBD, 0xC51C, 0xBEBE, 0xC528, 0xBEBF, 0xC529, 0xBEC0, 0xC52C,\r\n\t0xBEC1, 0xC530, 0xBEC2, 0xC538, 0xBEC3, 0xC539, 0xBEC4, 0xC53B,\t0xBEC5, 0xC53D, 0xBEC6, 0xC544, 0xBEC7, 0xC545, 0xBEC8, 0xC548,\r\n\t0xBEC9, 0xC549, 0xBECA, 0xC54A, 0xBECB, 0xC54C, 0xBECC, 0xC54D,\t0xBECD, 0xC54E, 0xBECE, 0xC553, 0xBECF, 0xC554, 0xBED0, 0xC555,\r\n\t0xBED1, 0xC557, 0xBED2, 0xC558, 0xBED3, 0xC559, 0xBED4, 0xC55D,\t0xBED5, 0xC55E, 0xBED6, 0xC560, 0xBED7, 0xC561, 0xBED8, 0xC564,\r\n\t0xBED9, 0xC568, 0xBEDA, 0xC570, 0xBEDB, 0xC571, 0xBEDC, 0xC573,\t0xBEDD, 0xC574, 0xBEDE, 0xC575, 0xBEDF, 0xC57C, 0xBEE0, 0xC57D,\r\n\t0xBEE1, 0xC580, 0xBEE2, 0xC584, 0xBEE3, 0xC587, 0xBEE4, 0xC58C,\t0xBEE5, 0xC58D, 0xBEE6, 0xC58F, 0xBEE7, 0xC591, 0xBEE8, 0xC595,\r\n\t0xBEE9, 0xC597, 0xBEEA, 0xC598, 0xBEEB, 0xC59C, 0xBEEC, 0xC5A0,\t0xBEED, 0xC5A9, 0xBEEE, 0xC5B4, 0xBEEF, 0xC5B5, 0xBEF0, 0xC5B8,\r\n\t0xBEF1, 0xC5B9, 0xBEF2, 0xC5BB, 0xBEF3, 0xC5BC, 0xBEF4, 0xC5BD,\t0xBEF5, 0xC5BE, 0xBEF6, 0xC5C4, 0xBEF7, 0xC5C5, 0xBEF8, 0xC5C6,\r\n\t0xBEF9, 0xC5C7, 0xBEFA, 0xC5C8, 0xBEFB, 0xC5C9, 0xBEFC, 0xC5CA,\t0xBEFD, 0xC5CC, 0xBEFE, 0xC5CE, 0xBF41, 0xD49E, 0xBF42, 0xD49F,\r\n\t0xBF43, 0xD4A0, 0xBF44, 0xD4A1, 0xBF45, 0xD4A2, 0xBF46, 0xD4A3,\t0xBF47, 0xD4A4, 0xBF48, 0xD4A5, 0xBF49, 0xD4A6, 0xBF4A, 0xD4A7,\r\n\t0xBF4B, 0xD4A8, 0xBF4C, 0xD4AA, 0xBF4D, 0xD4AB, 0xBF4E, 0xD4AC,\t0xBF4F, 0xD4AD, 0xBF50, 0xD4AE, 0xBF51, 0xD4AF, 0xBF52, 0xD4B0,\r\n\t0xBF53, 0xD4B1, 0xBF54, 0xD4B2, 0xBF55, 0xD4B3, 0xBF56, 0xD4B4,\t0xBF57, 0xD4B5, 0xBF58, 0xD4B6, 0xBF59, 0xD4B7, 0xBF5A, 0xD4B8,\r\n\t0xBF61, 0xD4B9, 0xBF62, 0xD4BA, 0xBF63, 0xD4BB, 0xBF64, 0xD4BC,\t0xBF65, 0xD4BD, 0xBF66, 0xD4BE, 0xBF67, 0xD4BF, 0xBF68, 0xD4C0,\r\n\t0xBF69, 0xD4C1, 0xBF6A, 0xD4C2, 0xBF6B, 0xD4C3, 0xBF6C, 0xD4C4,\t0xBF6D, 0xD4C5, 0xBF6E, 0xD4C6, 0xBF6F, 0xD4C7, 0xBF70, 0xD4C8,\r\n\t0xBF71, 0xD4C9, 0xBF72, 0xD4CA, 0xBF73, 0xD4CB, 0xBF74, 0xD4CD,\t0xBF75, 0xD4CE, 0xBF76, 0xD4CF, 0xBF77, 0xD4D1, 0xBF78, 0xD4D2,\r\n\t0xBF79, 0xD4D3, 0xBF7A, 0xD4D5, 0xBF81, 0xD4D6, 0xBF82, 0xD4D7,\t0xBF83, 0xD4D8, 0xBF84, 0xD4D9, 0xBF85, 0xD4DA, 0xBF86, 0xD4DB,\r\n\t0xBF87, 0xD4DD, 0xBF88, 0xD4DE, 0xBF89, 0xD4E0, 0xBF8A, 0xD4E1,\t0xBF8B, 0xD4E2, 0xBF8C, 0xD4E3, 0xBF8D, 0xD4E4, 0xBF8E, 0xD4E5,\r\n\t0xBF8F, 0xD4E6, 0xBF90, 0xD4E7, 0xBF91, 0xD4E9, 0xBF92, 0xD4EA,\t0xBF93, 0xD4EB, 0xBF94, 0xD4ED, 0xBF95, 0xD4EE, 0xBF96, 0xD4EF,\r\n\t0xBF97, 0xD4F1, 0xBF98, 0xD4F2, 0xBF99, 0xD4F3, 0xBF9A, 0xD4F4,\t0xBF9B, 0xD4F5, 0xBF9C, 0xD4F6, 0xBF9D, 0xD4F7, 0xBF9E, 0xD4F9,\r\n\t0xBF9F, 0xD4FA, 0xBFA0, 0xD4FC, 0xBFA1, 0xC5D0, 0xBFA2, 0xC5D1,\t0xBFA3, 0xC5D4, 0xBFA4, 0xC5D8, 0xBFA5, 0xC5E0, 0xBFA6, 0xC5E1,\r\n\t0xBFA7, 0xC5E3, 0xBFA8, 0xC5E5, 0xBFA9, 0xC5EC, 0xBFAA, 0xC5ED,\t0xBFAB, 0xC5EE, 0xBFAC, 0xC5F0, 0xBFAD, 0xC5F4, 0xBFAE, 0xC5F6,\r\n\t0xBFAF, 0xC5F7, 0xBFB0, 0xC5FC, 0xBFB1, 0xC5FD, 0xBFB2, 0xC5FE,\t0xBFB3, 0xC5FF, 0xBFB4, 0xC600, 0xBFB5, 0xC601, 0xBFB6, 0xC605,\r\n\t0xBFB7, 0xC606, 0xBFB8, 0xC607, 0xBFB9, 0xC608, 0xBFBA, 0xC60C,\t0xBFBB, 0xC610, 0xBFBC, 0xC618, 0xBFBD, 0xC619, 0xBFBE, 0xC61B,\r\n\t0xBFBF, 0xC61C, 0xBFC0, 0xC624, 0xBFC1, 0xC625, 0xBFC2, 0xC628,\t0xBFC3, 0xC62C, 0xBFC4, 0xC62D, 0xBFC5, 0xC62E, 0xBFC6, 0xC630,\r\n\t0xBFC7, 0xC633, 0xBFC8, 0xC634, 0xBFC9, 0xC635, 0xBFCA, 0xC637,\t0xBFCB, 0xC639, 0xBFCC, 0xC63B, 0xBFCD, 0xC640, 0xBFCE, 0xC641,\r\n\t0xBFCF, 0xC644, 0xBFD0, 0xC648, 0xBFD1, 0xC650, 0xBFD2, 0xC651,\t0xBFD3, 0xC653, 0xBFD4, 0xC654, 0xBFD5, 0xC655, 0xBFD6, 0xC65C,\r\n\t0xBFD7, 0xC65D, 0xBFD8, 0xC660, 0xBFD9, 0xC66C, 0xBFDA, 0xC66F,\t0xBFDB, 0xC671, 0xBFDC, 0xC678, 0xBFDD, 0xC679, 0xBFDE, 0xC67C,\r\n\t0xBFDF, 0xC680, 0xBFE0, 0xC688, 0xBFE1, 0xC689, 0xBFE2, 0xC68B,\t0xBFE3, 0xC68D, 0xBFE4, 0xC694, 0xBFE5, 0xC695, 0xBFE6, 0xC698,\r\n\t0xBFE7, 0xC69C, 0xBFE8, 0xC6A4, 0xBFE9, 0xC6A5, 0xBFEA, 0xC6A7,\t0xBFEB, 0xC6A9, 0xBFEC, 0xC6B0, 0xBFED, 0xC6B1, 0xBFEE, 0xC6B4,\r\n\t0xBFEF, 0xC6B8, 0xBFF0, 0xC6B9, 0xBFF1, 0xC6BA, 0xBFF2, 0xC6C0,\t0xBFF3, 0xC6C1, 0xBFF4, 0xC6C3, 0xBFF5, 0xC6C5, 0xBFF6, 0xC6CC,\r\n\t0xBFF7, 0xC6CD, 0xBFF8, 0xC6D0, 0xBFF9, 0xC6D4, 0xBFFA, 0xC6DC,\t0xBFFB, 0xC6DD, 0xBFFC, 0xC6E0, 0xBFFD, 0xC6E1, 0xBFFE, 0xC6E8,\r\n\t0xC041, 0xD4FE, 0xC042, 0xD4FF, 0xC043, 0xD500, 0xC044, 0xD501,\t0xC045, 0xD502, 0xC046, 0xD503, 0xC047, 0xD505, 0xC048, 0xD506,\r\n\t0xC049, 0xD507, 0xC04A, 0xD509, 0xC04B, 0xD50A, 0xC04C, 0xD50B,\t0xC04D, 0xD50D, 0xC04E, 0xD50E, 0xC04F, 0xD50F, 0xC050, 0xD510,\r\n\t0xC051, 0xD511, 0xC052, 0xD512, 0xC053, 0xD513, 0xC054, 0xD516,\t0xC055, 0xD518, 0xC056, 0xD519, 0xC057, 0xD51A, 0xC058, 0xD51B,\r\n\t0xC059, 0xD51C, 0xC05A, 0xD51D, 0xC061, 0xD51E, 0xC062, 0xD51F,\t0xC063, 0xD520, 0xC064, 0xD521, 0xC065, 0xD522, 0xC066, 0xD523,\r\n\t0xC067, 0xD524, 0xC068, 0xD525, 0xC069, 0xD526, 0xC06A, 0xD527,\t0xC06B, 0xD528, 0xC06C, 0xD529, 0xC06D, 0xD52A, 0xC06E, 0xD52B,\r\n\t0xC06F, 0xD52C, 0xC070, 0xD52D, 0xC071, 0xD52E, 0xC072, 0xD52F,\t0xC073, 0xD530, 0xC074, 0xD531, 0xC075, 0xD532, 0xC076, 0xD533,\r\n\t0xC077, 0xD534, 0xC078, 0xD535, 0xC079, 0xD536, 0xC07A, 0xD537,\t0xC081, 0xD538, 0xC082, 0xD539, 0xC083, 0xD53A, 0xC084, 0xD53B,\r\n\t0xC085, 0xD53E, 0xC086, 0xD53F, 0xC087, 0xD541, 0xC088, 0xD542,\t0xC089, 0xD543, 0xC08A, 0xD545, 0xC08B, 0xD546, 0xC08C, 0xD547,\r\n\t0xC08D, 0xD548, 0xC08E, 0xD549, 0xC08F, 0xD54A, 0xC090, 0xD54B,\t0xC091, 0xD54E, 0xC092, 0xD550, 0xC093, 0xD552, 0xC094, 0xD553,\r\n\t0xC095, 0xD554, 0xC096, 0xD555, 0xC097, 0xD556, 0xC098, 0xD557,\t0xC099, 0xD55A, 0xC09A, 0xD55B, 0xC09B, 0xD55D, 0xC09C, 0xD55E,\r\n\t0xC09D, 0xD55F, 0xC09E, 0xD561, 0xC09F, 0xD562, 0xC0A0, 0xD563,\t0xC0A1, 0xC6E9, 0xC0A2, 0xC6EC, 0xC0A3, 0xC6F0, 0xC0A4, 0xC6F8,\r\n\t0xC0A5, 0xC6F9, 0xC0A6, 0xC6FD, 0xC0A7, 0xC704, 0xC0A8, 0xC705,\t0xC0A9, 0xC708, 0xC0AA, 0xC70C, 0xC0AB, 0xC714, 0xC0AC, 0xC715,\r\n\t0xC0AD, 0xC717, 0xC0AE, 0xC719, 0xC0AF, 0xC720, 0xC0B0, 0xC721,\t0xC0B1, 0xC724, 0xC0B2, 0xC728, 0xC0B3, 0xC730, 0xC0B4, 0xC731,\r\n\t0xC0B5, 0xC733, 0xC0B6, 0xC735, 0xC0B7, 0xC737, 0xC0B8, 0xC73C,\t0xC0B9, 0xC73D, 0xC0BA, 0xC740, 0xC0BB, 0xC744, 0xC0BC, 0xC74A,\r\n\t0xC0BD, 0xC74C, 0xC0BE, 0xC74D, 0xC0BF, 0xC74F, 0xC0C0, 0xC751,\t0xC0C1, 0xC752, 0xC0C2, 0xC753, 0xC0C3, 0xC754, 0xC0C4, 0xC755,\r\n\t0xC0C5, 0xC756, 0xC0C6, 0xC757, 0xC0C7, 0xC758, 0xC0C8, 0xC75C,\t0xC0C9, 0xC760, 0xC0CA, 0xC768, 0xC0CB, 0xC76B, 0xC0CC, 0xC774,\r\n\t0xC0CD, 0xC775, 0xC0CE, 0xC778, 0xC0CF, 0xC77C, 0xC0D0, 0xC77D,\t0xC0D1, 0xC77E, 0xC0D2, 0xC783, 0xC0D3, 0xC784, 0xC0D4, 0xC785,\r\n\t0xC0D5, 0xC787, 0xC0D6, 0xC788, 0xC0D7, 0xC789, 0xC0D8, 0xC78A,\t0xC0D9, 0xC78E, 0xC0DA, 0xC790, 0xC0DB, 0xC791, 0xC0DC, 0xC794,\r\n\t0xC0DD, 0xC796, 0xC0DE, 0xC797, 0xC0DF, 0xC798, 0xC0E0, 0xC79A,\t0xC0E1, 0xC7A0, 0xC0E2, 0xC7A1, 0xC0E3, 0xC7A3, 0xC0E4, 0xC7A4,\r\n\t0xC0E5, 0xC7A5, 0xC0E6, 0xC7A6, 0xC0E7, 0xC7AC, 0xC0E8, 0xC7AD,\t0xC0E9, 0xC7B0, 0xC0EA, 0xC7B4, 0xC0EB, 0xC7BC, 0xC0EC, 0xC7BD,\r\n\t0xC0ED, 0xC7BF, 0xC0EE, 0xC7C0, 0xC0EF, 0xC7C1, 0xC0F0, 0xC7C8,\t0xC0F1, 0xC7C9, 0xC0F2, 0xC7CC, 0xC0F3, 0xC7CE, 0xC0F4, 0xC7D0,\r\n\t0xC0F5, 0xC7D8, 0xC0F6, 0xC7DD, 0xC0F7, 0xC7E4, 0xC0F8, 0xC7E8,\t0xC0F9, 0xC7EC, 0xC0FA, 0xC800, 0xC0FB, 0xC801, 0xC0FC, 0xC804,\r\n\t0xC0FD, 0xC808, 0xC0FE, 0xC80A, 0xC141, 0xD564, 0xC142, 0xD566,\t0xC143, 0xD567, 0xC144, 0xD56A, 0xC145, 0xD56C, 0xC146, 0xD56E,\r\n\t0xC147, 0xD56F, 0xC148, 0xD570, 0xC149, 0xD571, 0xC14A, 0xD572,\t0xC14B, 0xD573, 0xC14C, 0xD576, 0xC14D, 0xD577, 0xC14E, 0xD579,\r\n\t0xC14F, 0xD57A, 0xC150, 0xD57B, 0xC151, 0xD57D, 0xC152, 0xD57E,\t0xC153, 0xD57F, 0xC154, 0xD580, 0xC155, 0xD581, 0xC156, 0xD582,\r\n\t0xC157, 0xD583, 0xC158, 0xD586, 0xC159, 0xD58A, 0xC15A, 0xD58B,\t0xC161, 0xD58C, 0xC162, 0xD58D, 0xC163, 0xD58E, 0xC164, 0xD58F,\r\n\t0xC165, 0xD591, 0xC166, 0xD592, 0xC167, 0xD593, 0xC168, 0xD594,\t0xC169, 0xD595, 0xC16A, 0xD596, 0xC16B, 0xD597, 0xC16C, 0xD598,\r\n\t0xC16D, 0xD599, 0xC16E, 0xD59A, 0xC16F, 0xD59B, 0xC170, 0xD59C,\t0xC171, 0xD59D, 0xC172, 0xD59E, 0xC173, 0xD59F, 0xC174, 0xD5A0,\r\n\t0xC175, 0xD5A1, 0xC176, 0xD5A2, 0xC177, 0xD5A3, 0xC178, 0xD5A4,\t0xC179, 0xD5A6, 0xC17A, 0xD5A7, 0xC181, 0xD5A8, 0xC182, 0xD5A9,\r\n\t0xC183, 0xD5AA, 0xC184, 0xD5AB, 0xC185, 0xD5AC, 0xC186, 0xD5AD,\t0xC187, 0xD5AE, 0xC188, 0xD5AF, 0xC189, 0xD5B0, 0xC18A, 0xD5B1,\r\n\t0xC18B, 0xD5B2, 0xC18C, 0xD5B3, 0xC18D, 0xD5B4, 0xC18E, 0xD5B5,\t0xC18F, 0xD5B6, 0xC190, 0xD5B7, 0xC191, 0xD5B8, 0xC192, 0xD5B9,\r\n\t0xC193, 0xD5BA, 0xC194, 0xD5BB, 0xC195, 0xD5BC, 0xC196, 0xD5BD,\t0xC197, 0xD5BE, 0xC198, 0xD5BF, 0xC199, 0xD5C0, 0xC19A, 0xD5C1,\r\n\t0xC19B, 0xD5C2, 0xC19C, 0xD5C3, 0xC19D, 0xD5C4, 0xC19E, 0xD5C5,\t0xC19F, 0xD5C6, 0xC1A0, 0xD5C7, 0xC1A1, 0xC810, 0xC1A2, 0xC811,\r\n\t0xC1A3, 0xC813, 0xC1A4, 0xC815, 0xC1A5, 0xC816, 0xC1A6, 0xC81C,\t0xC1A7, 0xC81D, 0xC1A8, 0xC820, 0xC1A9, 0xC824, 0xC1AA, 0xC82C,\r\n\t0xC1AB, 0xC82D, 0xC1AC, 0xC82F, 0xC1AD, 0xC831, 0xC1AE, 0xC838,\t0xC1AF, 0xC83C, 0xC1B0, 0xC840, 0xC1B1, 0xC848, 0xC1B2, 0xC849,\r\n\t0xC1B3, 0xC84C, 0xC1B4, 0xC84D, 0xC1B5, 0xC854, 0xC1B6, 0xC870,\t0xC1B7, 0xC871, 0xC1B8, 0xC874, 0xC1B9, 0xC878, 0xC1BA, 0xC87A,\r\n\t0xC1BB, 0xC880, 0xC1BC, 0xC881, 0xC1BD, 0xC883, 0xC1BE, 0xC885,\t0xC1BF, 0xC886, 0xC1C0, 0xC887, 0xC1C1, 0xC88B, 0xC1C2, 0xC88C,\r\n\t0xC1C3, 0xC88D, 0xC1C4, 0xC894, 0xC1C5, 0xC89D, 0xC1C6, 0xC89F,\t0xC1C7, 0xC8A1, 0xC1C8, 0xC8A8, 0xC1C9, 0xC8BC, 0xC1CA, 0xC8BD,\r\n\t0xC1CB, 0xC8C4, 0xC1CC, 0xC8C8, 0xC1CD, 0xC8CC, 0xC1CE, 0xC8D4,\t0xC1CF, 0xC8D5, 0xC1D0, 0xC8D7, 0xC1D1, 0xC8D9, 0xC1D2, 0xC8E0,\r\n\t0xC1D3, 0xC8E1, 0xC1D4, 0xC8E4, 0xC1D5, 0xC8F5, 0xC1D6, 0xC8FC,\t0xC1D7, 0xC8FD, 0xC1D8, 0xC900, 0xC1D9, 0xC904, 0xC1DA, 0xC905,\r\n\t0xC1DB, 0xC906, 0xC1DC, 0xC90C, 0xC1DD, 0xC90D, 0xC1DE, 0xC90F,\t0xC1DF, 0xC911, 0xC1E0, 0xC918, 0xC1E1, 0xC92C, 0xC1E2, 0xC934,\r\n\t0xC1E3, 0xC950, 0xC1E4, 0xC951, 0xC1E5, 0xC954, 0xC1E6, 0xC958,\t0xC1E7, 0xC960, 0xC1E8, 0xC961, 0xC1E9, 0xC963, 0xC1EA, 0xC96C,\r\n\t0xC1EB, 0xC970, 0xC1EC, 0xC974, 0xC1ED, 0xC97C, 0xC1EE, 0xC988,\t0xC1EF, 0xC989, 0xC1F0, 0xC98C, 0xC1F1, 0xC990, 0xC1F2, 0xC998,\r\n\t0xC1F3, 0xC999, 0xC1F4, 0xC99B, 0xC1F5, 0xC99D, 0xC1F6, 0xC9C0,\t0xC1F7, 0xC9C1, 0xC1F8, 0xC9C4, 0xC1F9, 0xC9C7, 0xC1FA, 0xC9C8,\r\n\t0xC1FB, 0xC9CA, 0xC1FC, 0xC9D0, 0xC1FD, 0xC9D1, 0xC1FE, 0xC9D3,\t0xC241, 0xD5CA, 0xC242, 0xD5CB, 0xC243, 0xD5CD, 0xC244, 0xD5CE,\r\n\t0xC245, 0xD5CF, 0xC246, 0xD5D1, 0xC247, 0xD5D3, 0xC248, 0xD5D4,\t0xC249, 0xD5D5, 0xC24A, 0xD5D6, 0xC24B, 0xD5D7, 0xC24C, 0xD5DA,\r\n\t0xC24D, 0xD5DC, 0xC24E, 0xD5DE, 0xC24F, 0xD5DF, 0xC250, 0xD5E0,\t0xC251, 0xD5E1, 0xC252, 0xD5E2, 0xC253, 0xD5E3, 0xC254, 0xD5E6,\r\n\t0xC255, 0xD5E7, 0xC256, 0xD5E9, 0xC257, 0xD5EA, 0xC258, 0xD5EB,\t0xC259, 0xD5ED, 0xC25A, 0xD5EE, 0xC261, 0xD5EF, 0xC262, 0xD5F0,\r\n\t0xC263, 0xD5F1, 0xC264, 0xD5F2, 0xC265, 0xD5F3, 0xC266, 0xD5F6,\t0xC267, 0xD5F8, 0xC268, 0xD5FA, 0xC269, 0xD5FB, 0xC26A, 0xD5FC,\r\n\t0xC26B, 0xD5FD, 0xC26C, 0xD5FE, 0xC26D, 0xD5FF, 0xC26E, 0xD602,\t0xC26F, 0xD603, 0xC270, 0xD605, 0xC271, 0xD606, 0xC272, 0xD607,\r\n\t0xC273, 0xD609, 0xC274, 0xD60A, 0xC275, 0xD60B, 0xC276, 0xD60C,\t0xC277, 0xD60D, 0xC278, 0xD60E, 0xC279, 0xD60F, 0xC27A, 0xD612,\r\n\t0xC281, 0xD616, 0xC282, 0xD617, 0xC283, 0xD618, 0xC284, 0xD619,\t0xC285, 0xD61A, 0xC286, 0xD61B, 0xC287, 0xD61D, 0xC288, 0xD61E,\r\n\t0xC289, 0xD61F, 0xC28A, 0xD621, 0xC28B, 0xD622, 0xC28C, 0xD623,\t0xC28D, 0xD625, 0xC28E, 0xD626, 0xC28F, 0xD627, 0xC290, 0xD628,\r\n\t0xC291, 0xD629, 0xC292, 0xD62A, 0xC293, 0xD62B, 0xC294, 0xD62C,\t0xC295, 0xD62E, 0xC296, 0xD62F, 0xC297, 0xD630, 0xC298, 0xD631,\r\n\t0xC299, 0xD632, 0xC29A, 0xD633, 0xC29B, 0xD634, 0xC29C, 0xD635,\t0xC29D, 0xD636, 0xC29E, 0xD637, 0xC29F, 0xD63A, 0xC2A0, 0xD63B,\r\n\t0xC2A1, 0xC9D5, 0xC2A2, 0xC9D6, 0xC2A3, 0xC9D9, 0xC2A4, 0xC9DA,\t0xC2A5, 0xC9DC, 0xC2A6, 0xC9DD, 0xC2A7, 0xC9E0, 0xC2A8, 0xC9E2,\r\n\t0xC2A9, 0xC9E4, 0xC2AA, 0xC9E7, 0xC2AB, 0xC9EC, 0xC2AC, 0xC9ED,\t0xC2AD, 0xC9EF, 0xC2AE, 0xC9F0, 0xC2AF, 0xC9F1, 0xC2B0, 0xC9F8,\r\n\t0xC2B1, 0xC9F9, 0xC2B2, 0xC9FC, 0xC2B3, 0xCA00, 0xC2B4, 0xCA08,\t0xC2B5, 0xCA09, 0xC2B6, 0xCA0B, 0xC2B7, 0xCA0C, 0xC2B8, 0xCA0D,\r\n\t0xC2B9, 0xCA14, 0xC2BA, 0xCA18, 0xC2BB, 0xCA29, 0xC2BC, 0xCA4C,\t0xC2BD, 0xCA4D, 0xC2BE, 0xCA50, 0xC2BF, 0xCA54, 0xC2C0, 0xCA5C,\r\n\t0xC2C1, 0xCA5D, 0xC2C2, 0xCA5F, 0xC2C3, 0xCA60, 0xC2C4, 0xCA61,\t0xC2C5, 0xCA68, 0xC2C6, 0xCA7D, 0xC2C7, 0xCA84, 0xC2C8, 0xCA98,\r\n\t0xC2C9, 0xCABC, 0xC2CA, 0xCABD, 0xC2CB, 0xCAC0, 0xC2CC, 0xCAC4,\t0xC2CD, 0xCACC, 0xC2CE, 0xCACD, 0xC2CF, 0xCACF, 0xC2D0, 0xCAD1,\r\n\t0xC2D1, 0xCAD3, 0xC2D2, 0xCAD8, 0xC2D3, 0xCAD9, 0xC2D4, 0xCAE0,\t0xC2D5, 0xCAEC, 0xC2D6, 0xCAF4, 0xC2D7, 0xCB08, 0xC2D8, 0xCB10,\r\n\t0xC2D9, 0xCB14, 0xC2DA, 0xCB18, 0xC2DB, 0xCB20, 0xC2DC, 0xCB21,\t0xC2DD, 0xCB41, 0xC2DE, 0xCB48, 0xC2DF, 0xCB49, 0xC2E0, 0xCB4C,\r\n\t0xC2E1, 0xCB50, 0xC2E2, 0xCB58, 0xC2E3, 0xCB59, 0xC2E4, 0xCB5D,\t0xC2E5, 0xCB64, 0xC2E6, 0xCB78, 0xC2E7, 0xCB79, 0xC2E8, 0xCB9C,\r\n\t0xC2E9, 0xCBB8, 0xC2EA, 0xCBD4, 0xC2EB, 0xCBE4, 0xC2EC, 0xCBE7,\t0xC2ED, 0xCBE9, 0xC2EE, 0xCC0C, 0xC2EF, 0xCC0D, 0xC2F0, 0xCC10,\r\n\t0xC2F1, 0xCC14, 0xC2F2, 0xCC1C, 0xC2F3, 0xCC1D, 0xC2F4, 0xCC21,\t0xC2F5, 0xCC22, 0xC2F6, 0xCC27, 0xC2F7, 0xCC28, 0xC2F8, 0xCC29,\r\n\t0xC2F9, 0xCC2C, 0xC2FA, 0xCC2E, 0xC2FB, 0xCC30, 0xC2FC, 0xCC38,\t0xC2FD, 0xCC39, 0xC2FE, 0xCC3B, 0xC341, 0xD63D, 0xC342, 0xD63E,\r\n\t0xC343, 0xD63F, 0xC344, 0xD641, 0xC345, 0xD642, 0xC346, 0xD643,\t0xC347, 0xD644, 0xC348, 0xD646, 0xC349, 0xD647, 0xC34A, 0xD64A,\r\n\t0xC34B, 0xD64C, 0xC34C, 0xD64E, 0xC34D, 0xD64F, 0xC34E, 0xD650,\t0xC34F, 0xD652, 0xC350, 0xD653, 0xC351, 0xD656, 0xC352, 0xD657,\r\n\t0xC353, 0xD659, 0xC354, 0xD65A, 0xC355, 0xD65B, 0xC356, 0xD65D,\t0xC357, 0xD65E, 0xC358, 0xD65F, 0xC359, 0xD660, 0xC35A, 0xD661,\r\n\t0xC361, 0xD662, 0xC362, 0xD663, 0xC363, 0xD664, 0xC364, 0xD665,\t0xC365, 0xD666, 0xC366, 0xD668, 0xC367, 0xD66A, 0xC368, 0xD66B,\r\n\t0xC369, 0xD66C, 0xC36A, 0xD66D, 0xC36B, 0xD66E, 0xC36C, 0xD66F,\t0xC36D, 0xD672, 0xC36E, 0xD673, 0xC36F, 0xD675, 0xC370, 0xD676,\r\n\t0xC371, 0xD677, 0xC372, 0xD678, 0xC373, 0xD679, 0xC374, 0xD67A,\t0xC375, 0xD67B, 0xC376, 0xD67C, 0xC377, 0xD67D, 0xC378, 0xD67E,\r\n\t0xC379, 0xD67F, 0xC37A, 0xD680, 0xC381, 0xD681, 0xC382, 0xD682,\t0xC383, 0xD684, 0xC384, 0xD686, 0xC385, 0xD687, 0xC386, 0xD688,\r\n\t0xC387, 0xD689, 0xC388, 0xD68A, 0xC389, 0xD68B, 0xC38A, 0xD68E,\t0xC38B, 0xD68F, 0xC38C, 0xD691, 0xC38D, 0xD692, 0xC38E, 0xD693,\r\n\t0xC38F, 0xD695, 0xC390, 0xD696, 0xC391, 0xD697, 0xC392, 0xD698,\t0xC393, 0xD699, 0xC394, 0xD69A, 0xC395, 0xD69B, 0xC396, 0xD69C,\r\n\t0xC397, 0xD69E, 0xC398, 0xD6A0, 0xC399, 0xD6A2, 0xC39A, 0xD6A3,\t0xC39B, 0xD6A4, 0xC39C, 0xD6A5, 0xC39D, 0xD6A6, 0xC39E, 0xD6A7,\r\n\t0xC39F, 0xD6A9, 0xC3A0, 0xD6AA, 0xC3A1, 0xCC3C, 0xC3A2, 0xCC3D,\t0xC3A3, 0xCC3E, 0xC3A4, 0xCC44, 0xC3A5, 0xCC45, 0xC3A6, 0xCC48,\r\n\t0xC3A7, 0xCC4C, 0xC3A8, 0xCC54, 0xC3A9, 0xCC55, 0xC3AA, 0xCC57,\t0xC3AB, 0xCC58, 0xC3AC, 0xCC59, 0xC3AD, 0xCC60, 0xC3AE, 0xCC64,\r\n\t0xC3AF, 0xCC66, 0xC3B0, 0xCC68, 0xC3B1, 0xCC70, 0xC3B2, 0xCC75,\t0xC3B3, 0xCC98, 0xC3B4, 0xCC99, 0xC3B5, 0xCC9C, 0xC3B6, 0xCCA0,\r\n\t0xC3B7, 0xCCA8, 0xC3B8, 0xCCA9, 0xC3B9, 0xCCAB, 0xC3BA, 0xCCAC,\t0xC3BB, 0xCCAD, 0xC3BC, 0xCCB4, 0xC3BD, 0xCCB5, 0xC3BE, 0xCCB8,\r\n\t0xC3BF, 0xCCBC, 0xC3C0, 0xCCC4, 0xC3C1, 0xCCC5, 0xC3C2, 0xCCC7,\t0xC3C3, 0xCCC9, 0xC3C4, 0xCCD0, 0xC3C5, 0xCCD4, 0xC3C6, 0xCCE4,\r\n\t0xC3C7, 0xCCEC, 0xC3C8, 0xCCF0, 0xC3C9, 0xCD01, 0xC3CA, 0xCD08,\t0xC3CB, 0xCD09, 0xC3CC, 0xCD0C, 0xC3CD, 0xCD10, 0xC3CE, 0xCD18,\r\n\t0xC3CF, 0xCD19, 0xC3D0, 0xCD1B, 0xC3D1, 0xCD1D, 0xC3D2, 0xCD24,\t0xC3D3, 0xCD28, 0xC3D4, 0xCD2C, 0xC3D5, 0xCD39, 0xC3D6, 0xCD5C,\r\n\t0xC3D7, 0xCD60, 0xC3D8, 0xCD64, 0xC3D9, 0xCD6C, 0xC3DA, 0xCD6D,\t0xC3DB, 0xCD6F, 0xC3DC, 0xCD71, 0xC3DD, 0xCD78, 0xC3DE, 0xCD88,\r\n\t0xC3DF, 0xCD94, 0xC3E0, 0xCD95, 0xC3E1, 0xCD98, 0xC3E2, 0xCD9C,\t0xC3E3, 0xCDA4, 0xC3E4, 0xCDA5, 0xC3E5, 0xCDA7, 0xC3E6, 0xCDA9,\r\n\t0xC3E7, 0xCDB0, 0xC3E8, 0xCDC4, 0xC3E9, 0xCDCC, 0xC3EA, 0xCDD0,\t0xC3EB, 0xCDE8, 0xC3EC, 0xCDEC, 0xC3ED, 0xCDF0, 0xC3EE, 0xCDF8,\r\n\t0xC3EF, 0xCDF9, 0xC3F0, 0xCDFB, 0xC3F1, 0xCDFD, 0xC3F2, 0xCE04,\t0xC3F3, 0xCE08, 0xC3F4, 0xCE0C, 0xC3F5, 0xCE14, 0xC3F6, 0xCE19,\r\n\t0xC3F7, 0xCE20, 0xC3F8, 0xCE21, 0xC3F9, 0xCE24, 0xC3FA, 0xCE28,\t0xC3FB, 0xCE30, 0xC3FC, 0xCE31, 0xC3FD, 0xCE33, 0xC3FE, 0xCE35,\r\n\t0xC441, 0xD6AB, 0xC442, 0xD6AD, 0xC443, 0xD6AE, 0xC444, 0xD6AF,\t0xC445, 0xD6B1, 0xC446, 0xD6B2, 0xC447, 0xD6B3, 0xC448, 0xD6B4,\r\n\t0xC449, 0xD6B5, 0xC44A, 0xD6B6, 0xC44B, 0xD6B7, 0xC44C, 0xD6B8,\t0xC44D, 0xD6BA, 0xC44E, 0xD6BC, 0xC44F, 0xD6BD, 0xC450, 0xD6BE,\r\n\t0xC451, 0xD6BF, 0xC452, 0xD6C0, 0xC453, 0xD6C1, 0xC454, 0xD6C2,\t0xC455, 0xD6C3, 0xC456, 0xD6C6, 0xC457, 0xD6C7, 0xC458, 0xD6C9,\r\n\t0xC459, 0xD6CA, 0xC45A, 0xD6CB, 0xC461, 0xD6CD, 0xC462, 0xD6CE,\t0xC463, 0xD6CF, 0xC464, 0xD6D0, 0xC465, 0xD6D2, 0xC466, 0xD6D3,\r\n\t0xC467, 0xD6D5, 0xC468, 0xD6D6, 0xC469, 0xD6D8, 0xC46A, 0xD6DA,\t0xC46B, 0xD6DB, 0xC46C, 0xD6DC, 0xC46D, 0xD6DD, 0xC46E, 0xD6DE,\r\n\t0xC46F, 0xD6DF, 0xC470, 0xD6E1, 0xC471, 0xD6E2, 0xC472, 0xD6E3,\t0xC473, 0xD6E5, 0xC474, 0xD6E6, 0xC475, 0xD6E7, 0xC476, 0xD6E9,\r\n\t0xC477, 0xD6EA, 0xC478, 0xD6EB, 0xC479, 0xD6EC, 0xC47A, 0xD6ED,\t0xC481, 0xD6EE, 0xC482, 0xD6EF, 0xC483, 0xD6F1, 0xC484, 0xD6F2,\r\n\t0xC485, 0xD6F3, 0xC486, 0xD6F4, 0xC487, 0xD6F6, 0xC488, 0xD6F7,\t0xC489, 0xD6F8, 0xC48A, 0xD6F9, 0xC48B, 0xD6FA, 0xC48C, 0xD6FB,\r\n\t0xC48D, 0xD6FE, 0xC48E, 0xD6FF, 0xC48F, 0xD701, 0xC490, 0xD702,\t0xC491, 0xD703, 0xC492, 0xD705, 0xC493, 0xD706, 0xC494, 0xD707,\r\n\t0xC495, 0xD708, 0xC496, 0xD709, 0xC497, 0xD70A, 0xC498, 0xD70B,\t0xC499, 0xD70C, 0xC49A, 0xD70D, 0xC49B, 0xD70E, 0xC49C, 0xD70F,\r\n\t0xC49D, 0xD710, 0xC49E, 0xD712, 0xC49F, 0xD713, 0xC4A0, 0xD714,\t0xC4A1, 0xCE58, 0xC4A2, 0xCE59, 0xC4A3, 0xCE5C, 0xC4A4, 0xCE5F,\r\n\t0xC4A5, 0xCE60, 0xC4A6, 0xCE61, 0xC4A7, 0xCE68, 0xC4A8, 0xCE69,\t0xC4A9, 0xCE6B, 0xC4AA, 0xCE6D, 0xC4AB, 0xCE74, 0xC4AC, 0xCE75,\r\n\t0xC4AD, 0xCE78, 0xC4AE, 0xCE7C, 0xC4AF, 0xCE84, 0xC4B0, 0xCE85,\t0xC4B1, 0xCE87, 0xC4B2, 0xCE89, 0xC4B3, 0xCE90, 0xC4B4, 0xCE91,\r\n\t0xC4B5, 0xCE94, 0xC4B6, 0xCE98, 0xC4B7, 0xCEA0, 0xC4B8, 0xCEA1,\t0xC4B9, 0xCEA3, 0xC4BA, 0xCEA4, 0xC4BB, 0xCEA5, 0xC4BC, 0xCEAC,\r\n\t0xC4BD, 0xCEAD, 0xC4BE, 0xCEC1, 0xC4BF, 0xCEE4, 0xC4C0, 0xCEE5,\t0xC4C1, 0xCEE8, 0xC4C2, 0xCEEB, 0xC4C3, 0xCEEC, 0xC4C4, 0xCEF4,\r\n\t0xC4C5, 0xCEF5, 0xC4C6, 0xCEF7, 0xC4C7, 0xCEF8, 0xC4C8, 0xCEF9,\t0xC4C9, 0xCF00, 0xC4CA, 0xCF01, 0xC4CB, 0xCF04, 0xC4CC, 0xCF08,\r\n\t0xC4CD, 0xCF10, 0xC4CE, 0xCF11, 0xC4CF, 0xCF13, 0xC4D0, 0xCF15,\t0xC4D1, 0xCF1C, 0xC4D2, 0xCF20, 0xC4D3, 0xCF24, 0xC4D4, 0xCF2C,\r\n\t0xC4D5, 0xCF2D, 0xC4D6, 0xCF2F, 0xC4D7, 0xCF30, 0xC4D8, 0xCF31,\t0xC4D9, 0xCF38, 0xC4DA, 0xCF54, 0xC4DB, 0xCF55, 0xC4DC, 0xCF58,\r\n\t0xC4DD, 0xCF5C, 0xC4DE, 0xCF64, 0xC4DF, 0xCF65, 0xC4E0, 0xCF67,\t0xC4E1, 0xCF69, 0xC4E2, 0xCF70, 0xC4E3, 0xCF71, 0xC4E4, 0xCF74,\r\n\t0xC4E5, 0xCF78, 0xC4E6, 0xCF80, 0xC4E7, 0xCF85, 0xC4E8, 0xCF8C,\t0xC4E9, 0xCFA1, 0xC4EA, 0xCFA8, 0xC4EB, 0xCFB0, 0xC4EC, 0xCFC4,\r\n\t0xC4ED, 0xCFE0, 0xC4EE, 0xCFE1, 0xC4EF, 0xCFE4, 0xC4F0, 0xCFE8,\t0xC4F1, 0xCFF0, 0xC4F2, 0xCFF1, 0xC4F3, 0xCFF3, 0xC4F4, 0xCFF5,\r\n\t0xC4F5, 0xCFFC, 0xC4F6, 0xD000, 0xC4F7, 0xD004, 0xC4F8, 0xD011,\t0xC4F9, 0xD018, 0xC4FA, 0xD02D, 0xC4FB, 0xD034, 0xC4FC, 0xD035,\r\n\t0xC4FD, 0xD038, 0xC4FE, 0xD03C, 0xC541, 0xD715, 0xC542, 0xD716,\t0xC543, 0xD717, 0xC544, 0xD71A, 0xC545, 0xD71B, 0xC546, 0xD71D,\r\n\t0xC547, 0xD71E, 0xC548, 0xD71F, 0xC549, 0xD721, 0xC54A, 0xD722,\t0xC54B, 0xD723, 0xC54C, 0xD724, 0xC54D, 0xD725, 0xC54E, 0xD726,\r\n\t0xC54F, 0xD727, 0xC550, 0xD72A, 0xC551, 0xD72C, 0xC552, 0xD72E,\t0xC553, 0xD72F, 0xC554, 0xD730, 0xC555, 0xD731, 0xC556, 0xD732,\r\n\t0xC557, 0xD733, 0xC558, 0xD736, 0xC559, 0xD737, 0xC55A, 0xD739,\t0xC561, 0xD73A, 0xC562, 0xD73B, 0xC563, 0xD73D, 0xC564, 0xD73E,\r\n\t0xC565, 0xD73F, 0xC566, 0xD740, 0xC567, 0xD741, 0xC568, 0xD742,\t0xC569, 0xD743, 0xC56A, 0xD745, 0xC56B, 0xD746, 0xC56C, 0xD748,\r\n\t0xC56D, 0xD74A, 0xC56E, 0xD74B, 0xC56F, 0xD74C, 0xC570, 0xD74D,\t0xC571, 0xD74E, 0xC572, 0xD74F, 0xC573, 0xD752, 0xC574, 0xD753,\r\n\t0xC575, 0xD755, 0xC576, 0xD75A, 0xC577, 0xD75B, 0xC578, 0xD75C,\t0xC579, 0xD75D, 0xC57A, 0xD75E, 0xC581, 0xD75F, 0xC582, 0xD762,\r\n\t0xC583, 0xD764, 0xC584, 0xD766, 0xC585, 0xD767, 0xC586, 0xD768,\t0xC587, 0xD76A, 0xC588, 0xD76B, 0xC589, 0xD76D, 0xC58A, 0xD76E,\r\n\t0xC58B, 0xD76F, 0xC58C, 0xD771, 0xC58D, 0xD772, 0xC58E, 0xD773,\t0xC58F, 0xD775, 0xC590, 0xD776, 0xC591, 0xD777, 0xC592, 0xD778,\r\n\t0xC593, 0xD779, 0xC594, 0xD77A, 0xC595, 0xD77B, 0xC596, 0xD77E,\t0xC597, 0xD77F, 0xC598, 0xD780, 0xC599, 0xD782, 0xC59A, 0xD783,\r\n\t0xC59B, 0xD784, 0xC59C, 0xD785, 0xC59D, 0xD786, 0xC59E, 0xD787,\t0xC59F, 0xD78A, 0xC5A0, 0xD78B, 0xC5A1, 0xD044, 0xC5A2, 0xD045,\r\n\t0xC5A3, 0xD047, 0xC5A4, 0xD049, 0xC5A5, 0xD050, 0xC5A6, 0xD054,\t0xC5A7, 0xD058, 0xC5A8, 0xD060, 0xC5A9, 0xD06C, 0xC5AA, 0xD06D,\r\n\t0xC5AB, 0xD070, 0xC5AC, 0xD074, 0xC5AD, 0xD07C, 0xC5AE, 0xD07D,\t0xC5AF, 0xD081, 0xC5B0, 0xD0A4, 0xC5B1, 0xD0A5, 0xC5B2, 0xD0A8,\r\n\t0xC5B3, 0xD0AC, 0xC5B4, 0xD0B4, 0xC5B5, 0xD0B5, 0xC5B6, 0xD0B7,\t0xC5B7, 0xD0B9, 0xC5B8, 0xD0C0, 0xC5B9, 0xD0C1, 0xC5BA, 0xD0C4,\r\n\t0xC5BB, 0xD0C8, 0xC5BC, 0xD0C9, 0xC5BD, 0xD0D0, 0xC5BE, 0xD0D1,\t0xC5BF, 0xD0D3, 0xC5C0, 0xD0D4, 0xC5C1, 0xD0D5, 0xC5C2, 0xD0DC,\r\n\t0xC5C3, 0xD0DD, 0xC5C4, 0xD0E0, 0xC5C5, 0xD0E4, 0xC5C6, 0xD0EC,\t0xC5C7, 0xD0ED, 0xC5C8, 0xD0EF, 0xC5C9, 0xD0F0, 0xC5CA, 0xD0F1,\r\n\t0xC5CB, 0xD0F8, 0xC5CC, 0xD10D, 0xC5CD, 0xD130, 0xC5CE, 0xD131,\t0xC5CF, 0xD134, 0xC5D0, 0xD138, 0xC5D1, 0xD13A, 0xC5D2, 0xD140,\r\n\t0xC5D3, 0xD141, 0xC5D4, 0xD143, 0xC5D5, 0xD144, 0xC5D6, 0xD145,\t0xC5D7, 0xD14C, 0xC5D8, 0xD14D, 0xC5D9, 0xD150, 0xC5DA, 0xD154,\r\n\t0xC5DB, 0xD15C, 0xC5DC, 0xD15D, 0xC5DD, 0xD15F, 0xC5DE, 0xD161,\t0xC5DF, 0xD168, 0xC5E0, 0xD16C, 0xC5E1, 0xD17C, 0xC5E2, 0xD184,\r\n\t0xC5E3, 0xD188, 0xC5E4, 0xD1A0, 0xC5E5, 0xD1A1, 0xC5E6, 0xD1A4,\t0xC5E7, 0xD1A8, 0xC5E8, 0xD1B0, 0xC5E9, 0xD1B1, 0xC5EA, 0xD1B3,\r\n\t0xC5EB, 0xD1B5, 0xC5EC, 0xD1BA, 0xC5ED, 0xD1BC, 0xC5EE, 0xD1C0,\t0xC5EF, 0xD1D8, 0xC5F0, 0xD1F4, 0xC5F1, 0xD1F8, 0xC5F2, 0xD207,\r\n\t0xC5F3, 0xD209, 0xC5F4, 0xD210, 0xC5F5, 0xD22C, 0xC5F6, 0xD22D,\t0xC5F7, 0xD230, 0xC5F8, 0xD234, 0xC5F9, 0xD23C, 0xC5FA, 0xD23D,\r\n\t0xC5FB, 0xD23F, 0xC5FC, 0xD241, 0xC5FD, 0xD248, 0xC5FE, 0xD25C,\t0xC641, 0xD78D, 0xC642, 0xD78E, 0xC643, 0xD78F, 0xC644, 0xD791,\r\n\t0xC645, 0xD792, 0xC646, 0xD793, 0xC647, 0xD794, 0xC648, 0xD795,\t0xC649, 0xD796, 0xC64A, 0xD797, 0xC64B, 0xD79A, 0xC64C, 0xD79C,\r\n\t0xC64D, 0xD79E, 0xC64E, 0xD79F, 0xC64F, 0xD7A0, 0xC650, 0xD7A1,\t0xC651, 0xD7A2, 0xC652, 0xD7A3, 0xC6A1, 0xD264, 0xC6A2, 0xD280,\r\n\t0xC6A3, 0xD281, 0xC6A4, 0xD284, 0xC6A5, 0xD288, 0xC6A6, 0xD290,\t0xC6A7, 0xD291, 0xC6A8, 0xD295, 0xC6A9, 0xD29C, 0xC6AA, 0xD2A0,\r\n\t0xC6AB, 0xD2A4, 0xC6AC, 0xD2AC, 0xC6AD, 0xD2B1, 0xC6AE, 0xD2B8,\t0xC6AF, 0xD2B9, 0xC6B0, 0xD2BC, 0xC6B1, 0xD2BF, 0xC6B2, 0xD2C0,\r\n\t0xC6B3, 0xD2C2, 0xC6B4, 0xD2C8, 0xC6B5, 0xD2C9, 0xC6B6, 0xD2CB,\t0xC6B7, 0xD2D4, 0xC6B8, 0xD2D8, 0xC6B9, 0xD2DC, 0xC6BA, 0xD2E4,\r\n\t0xC6BB, 0xD2E5, 0xC6BC, 0xD2F0, 0xC6BD, 0xD2F1, 0xC6BE, 0xD2F4,\t0xC6BF, 0xD2F8, 0xC6C0, 0xD300, 0xC6C1, 0xD301, 0xC6C2, 0xD303,\r\n\t0xC6C3, 0xD305, 0xC6C4, 0xD30C, 0xC6C5, 0xD30D, 0xC6C6, 0xD30E,\t0xC6C7, 0xD310, 0xC6C8, 0xD314, 0xC6C9, 0xD316, 0xC6CA, 0xD31C,\r\n\t0xC6CB, 0xD31D, 0xC6CC, 0xD31F, 0xC6CD, 0xD320, 0xC6CE, 0xD321,\t0xC6CF, 0xD325, 0xC6D0, 0xD328, 0xC6D1, 0xD329, 0xC6D2, 0xD32C,\r\n\t0xC6D3, 0xD330, 0xC6D4, 0xD338, 0xC6D5, 0xD339, 0xC6D6, 0xD33B,\t0xC6D7, 0xD33C, 0xC6D8, 0xD33D, 0xC6D9, 0xD344, 0xC6DA, 0xD345,\r\n\t0xC6DB, 0xD37C, 0xC6DC, 0xD37D, 0xC6DD, 0xD380, 0xC6DE, 0xD384,\t0xC6DF, 0xD38C, 0xC6E0, 0xD38D, 0xC6E1, 0xD38F, 0xC6E2, 0xD390,\r\n\t0xC6E3, 0xD391, 0xC6E4, 0xD398, 0xC6E5, 0xD399, 0xC6E6, 0xD39C,\t0xC6E7, 0xD3A0, 0xC6E8, 0xD3A8, 0xC6E9, 0xD3A9, 0xC6EA, 0xD3AB,\r\n\t0xC6EB, 0xD3AD, 0xC6EC, 0xD3B4, 0xC6ED, 0xD3B8, 0xC6EE, 0xD3BC,\t0xC6EF, 0xD3C4, 0xC6F0, 0xD3C5, 0xC6F1, 0xD3C8, 0xC6F2, 0xD3C9,\r\n\t0xC6F3, 0xD3D0, 0xC6F4, 0xD3D8, 0xC6F5, 0xD3E1, 0xC6F6, 0xD3E3,\t0xC6F7, 0xD3EC, 0xC6F8, 0xD3ED, 0xC6F9, 0xD3F0, 0xC6FA, 0xD3F4,\r\n\t0xC6FB, 0xD3FC, 0xC6FC, 0xD3FD, 0xC6FD, 0xD3FF, 0xC6FE, 0xD401,\t0xC7A1, 0xD408, 0xC7A2, 0xD41D, 0xC7A3, 0xD440, 0xC7A4, 0xD444,\r\n\t0xC7A5, 0xD45C, 0xC7A6, 0xD460, 0xC7A7, 0xD464, 0xC7A8, 0xD46D,\t0xC7A9, 0xD46F, 0xC7AA, 0xD478, 0xC7AB, 0xD479, 0xC7AC, 0xD47C,\r\n\t0xC7AD, 0xD47F, 0xC7AE, 0xD480, 0xC7AF, 0xD482, 0xC7B0, 0xD488,\t0xC7B1, 0xD489, 0xC7B2, 0xD48B, 0xC7B3, 0xD48D, 0xC7B4, 0xD494,\r\n\t0xC7B5, 0xD4A9, 0xC7B6, 0xD4CC, 0xC7B7, 0xD4D0, 0xC7B8, 0xD4D4,\t0xC7B9, 0xD4DC, 0xC7BA, 0xD4DF, 0xC7BB, 0xD4E8, 0xC7BC, 0xD4EC,\r\n\t0xC7BD, 0xD4F0, 0xC7BE, 0xD4F8, 0xC7BF, 0xD4FB, 0xC7C0, 0xD4FD,\t0xC7C1, 0xD504, 0xC7C2, 0xD508, 0xC7C3, 0xD50C, 0xC7C4, 0xD514,\r\n\t0xC7C5, 0xD515, 0xC7C6, 0xD517, 0xC7C7, 0xD53C, 0xC7C8, 0xD53D,\t0xC7C9, 0xD540, 0xC7CA, 0xD544, 0xC7CB, 0xD54C, 0xC7CC, 0xD54D,\r\n\t0xC7CD, 0xD54F, 0xC7CE, 0xD551, 0xC7CF, 0xD558, 0xC7D0, 0xD559,\t0xC7D1, 0xD55C, 0xC7D2, 0xD560, 0xC7D3, 0xD565, 0xC7D4, 0xD568,\r\n\t0xC7D5, 0xD569, 0xC7D6, 0xD56B, 0xC7D7, 0xD56D, 0xC7D8, 0xD574,\t0xC7D9, 0xD575, 0xC7DA, 0xD578, 0xC7DB, 0xD57C, 0xC7DC, 0xD584,\r\n\t0xC7DD, 0xD585, 0xC7DE, 0xD587, 0xC7DF, 0xD588, 0xC7E0, 0xD589,\t0xC7E1, 0xD590, 0xC7E2, 0xD5A5, 0xC7E3, 0xD5C8, 0xC7E4, 0xD5C9,\r\n\t0xC7E5, 0xD5CC, 0xC7E6, 0xD5D0, 0xC7E7, 0xD5D2, 0xC7E8, 0xD5D8,\t0xC7E9, 0xD5D9, 0xC7EA, 0xD5DB, 0xC7EB, 0xD5DD, 0xC7EC, 0xD5E4,\r\n\t0xC7ED, 0xD5E5, 0xC7EE, 0xD5E8, 0xC7EF, 0xD5EC, 0xC7F0, 0xD5F4,\t0xC7F1, 0xD5F5, 0xC7F2, 0xD5F7, 0xC7F3, 0xD5F9, 0xC7F4, 0xD600,\r\n\t0xC7F5, 0xD601, 0xC7F6, 0xD604, 0xC7F7, 0xD608, 0xC7F8, 0xD610,\t0xC7F9, 0xD611, 0xC7FA, 0xD613, 0xC7FB, 0xD614, 0xC7FC, 0xD615,\r\n\t0xC7FD, 0xD61C, 0xC7FE, 0xD620, 0xC8A1, 0xD624, 0xC8A2, 0xD62D,\t0xC8A3, 0xD638, 0xC8A4, 0xD639, 0xC8A5, 0xD63C, 0xC8A6, 0xD640,\r\n\t0xC8A7, 0xD645, 0xC8A8, 0xD648, 0xC8A9, 0xD649, 0xC8AA, 0xD64B,\t0xC8AB, 0xD64D, 0xC8AC, 0xD651, 0xC8AD, 0xD654, 0xC8AE, 0xD655,\r\n\t0xC8AF, 0xD658, 0xC8B0, 0xD65C, 0xC8B1, 0xD667, 0xC8B2, 0xD669,\t0xC8B3, 0xD670, 0xC8B4, 0xD671, 0xC8B5, 0xD674, 0xC8B6, 0xD683,\r\n\t0xC8B7, 0xD685, 0xC8B8, 0xD68C, 0xC8B9, 0xD68D, 0xC8BA, 0xD690,\t0xC8BB, 0xD694, 0xC8BC, 0xD69D, 0xC8BD, 0xD69F, 0xC8BE, 0xD6A1,\r\n\t0xC8BF, 0xD6A8, 0xC8C0, 0xD6AC, 0xC8C1, 0xD6B0, 0xC8C2, 0xD6B9,\t0xC8C3, 0xD6BB, 0xC8C4, 0xD6C4, 0xC8C5, 0xD6C5, 0xC8C6, 0xD6C8,\r\n\t0xC8C7, 0xD6CC, 0xC8C8, 0xD6D1, 0xC8C9, 0xD6D4, 0xC8CA, 0xD6D7,\t0xC8CB, 0xD6D9, 0xC8CC, 0xD6E0, 0xC8CD, 0xD6E4, 0xC8CE, 0xD6E8,\r\n\t0xC8CF, 0xD6F0, 0xC8D0, 0xD6F5, 0xC8D1, 0xD6FC, 0xC8D2, 0xD6FD,\t0xC8D3, 0xD700, 0xC8D4, 0xD704, 0xC8D5, 0xD711, 0xC8D6, 0xD718,\r\n\t0xC8D7, 0xD719, 0xC8D8, 0xD71C, 0xC8D9, 0xD720, 0xC8DA, 0xD728,\t0xC8DB, 0xD729, 0xC8DC, 0xD72B, 0xC8DD, 0xD72D, 0xC8DE, 0xD734,\r\n\t0xC8DF, 0xD735, 0xC8E0, 0xD738, 0xC8E1, 0xD73C, 0xC8E2, 0xD744,\t0xC8E3, 0xD747, 0xC8E4, 0xD749, 0xC8E5, 0xD750, 0xC8E6, 0xD751,\r\n\t0xC8E7, 0xD754, 0xC8E8, 0xD756, 0xC8E9, 0xD757, 0xC8EA, 0xD758,\t0xC8EB, 0xD759, 0xC8EC, 0xD760, 0xC8ED, 0xD761, 0xC8EE, 0xD763,\r\n\t0xC8EF, 0xD765, 0xC8F0, 0xD769, 0xC8F1, 0xD76C, 0xC8F2, 0xD770,\t0xC8F3, 0xD774, 0xC8F4, 0xD77C, 0xC8F5, 0xD77D, 0xC8F6, 0xD781,\r\n\t0xC8F7, 0xD788, 0xC8F8, 0xD789, 0xC8F9, 0xD78C, 0xC8FA, 0xD790,\t0xC8FB, 0xD798, 0xC8FC, 0xD799, 0xC8FD, 0xD79B, 0xC8FE, 0xD79D,\r\n\t0xCAA1, 0x4F3D, 0xCAA2, 0x4F73, 0xCAA3, 0x5047, 0xCAA4, 0x50F9,\t0xCAA5, 0x52A0, 0xCAA6, 0x53EF, 0xCAA7, 0x5475, 0xCAA8, 0x54E5,\r\n\t0xCAA9, 0x5609, 0xCAAA, 0x5AC1, 0xCAAB, 0x5BB6, 0xCAAC, 0x6687,\t0xCAAD, 0x67B6, 0xCAAE, 0x67B7, 0xCAAF, 0x67EF, 0xCAB0, 0x6B4C,\r\n\t0xCAB1, 0x73C2, 0xCAB2, 0x75C2, 0xCAB3, 0x7A3C, 0xCAB4, 0x82DB,\t0xCAB5, 0x8304, 0xCAB6, 0x8857, 0xCAB7, 0x8888, 0xCAB8, 0x8A36,\r\n\t0xCAB9, 0x8CC8, 0xCABA, 0x8DCF, 0xCABB, 0x8EFB, 0xCABC, 0x8FE6,\t0xCABD, 0x99D5, 0xCABE, 0x523B, 0xCABF, 0x5374, 0xCAC0, 0x5404,\r\n\t0xCAC1, 0x606A, 0xCAC2, 0x6164, 0xCAC3, 0x6BBC, 0xCAC4, 0x73CF,\t0xCAC5, 0x811A, 0xCAC6, 0x89BA, 0xCAC7, 0x89D2, 0xCAC8, 0x95A3,\r\n\t0xCAC9, 0x4F83, 0xCACA, 0x520A, 0xCACB, 0x58BE, 0xCACC, 0x5978,\t0xCACD, 0x59E6, 0xCACE, 0x5E72, 0xCACF, 0x5E79, 0xCAD0, 0x61C7,\r\n\t0xCAD1, 0x63C0, 0xCAD2, 0x6746, 0xCAD3, 0x67EC, 0xCAD4, 0x687F,\t0xCAD5, 0x6F97, 0xCAD6, 0x764E, 0xCAD7, 0x770B, 0xCAD8, 0x78F5,\r\n\t0xCAD9, 0x7A08, 0xCADA, 0x7AFF, 0xCADB, 0x7C21, 0xCADC, 0x809D,\t0xCADD, 0x826E, 0xCADE, 0x8271, 0xCADF, 0x8AEB, 0xCAE0, 0x9593,\r\n\t0xCAE1, 0x4E6B, 0xCAE2, 0x559D, 0xCAE3, 0x66F7, 0xCAE4, 0x6E34,\t0xCAE5, 0x78A3, 0xCAE6, 0x7AED, 0xCAE7, 0x845B, 0xCAE8, 0x8910,\r\n\t0xCAE9, 0x874E, 0xCAEA, 0x97A8, 0xCAEB, 0x52D8, 0xCAEC, 0x574E,\t0xCAED, 0x582A, 0xCAEE, 0x5D4C, 0xCAEF, 0x611F, 0xCAF0, 0x61BE,\r\n\t0xCAF1, 0x6221, 0xCAF2, 0x6562, 0xCAF3, 0x67D1, 0xCAF4, 0x6A44,\t0xCAF5, 0x6E1B, 0xCAF6, 0x7518, 0xCAF7, 0x75B3, 0xCAF8, 0x76E3,\r\n\t0xCAF9, 0x77B0, 0xCAFA, 0x7D3A, 0xCAFB, 0x90AF, 0xCAFC, 0x9451,\t0xCAFD, 0x9452, 0xCAFE, 0x9F95, 0xCBA1, 0x5323, 0xCBA2, 0x5CAC,\r\n\t0xCBA3, 0x7532, 0xCBA4, 0x80DB, 0xCBA5, 0x9240, 0xCBA6, 0x9598,\t0xCBA7, 0x525B, 0xCBA8, 0x5808, 0xCBA9, 0x59DC, 0xCBAA, 0x5CA1,\r\n\t0xCBAB, 0x5D17, 0xCBAC, 0x5EB7, 0xCBAD, 0x5F3A, 0xCBAE, 0x5F4A,\t0xCBAF, 0x6177, 0xCBB0, 0x6C5F, 0xCBB1, 0x757A, 0xCBB2, 0x7586,\r\n\t0xCBB3, 0x7CE0, 0xCBB4, 0x7D73, 0xCBB5, 0x7DB1, 0xCBB6, 0x7F8C,\t0xCBB7, 0x8154, 0xCBB8, 0x8221, 0xCBB9, 0x8591, 0xCBBA, 0x8941,\r\n\t0xCBBB, 0x8B1B, 0xCBBC, 0x92FC, 0xCBBD, 0x964D, 0xCBBE, 0x9C47,\t0xCBBF, 0x4ECB, 0xCBC0, 0x4EF7, 0xCBC1, 0x500B, 0xCBC2, 0x51F1,\r\n\t0xCBC3, 0x584F, 0xCBC4, 0x6137, 0xCBC5, 0x613E, 0xCBC6, 0x6168,\t0xCBC7, 0x6539, 0xCBC8, 0x69EA, 0xCBC9, 0x6F11, 0xCBCA, 0x75A5,\r\n\t0xCBCB, 0x7686, 0xCBCC, 0x76D6, 0xCBCD, 0x7B87, 0xCBCE, 0x82A5,\t0xCBCF, 0x84CB, 0xCBD0, 0xF900, 0xCBD1, 0x93A7, 0xCBD2, 0x958B,\r\n\t0xCBD3, 0x5580, 0xCBD4, 0x5BA2, 0xCBD5, 0x5751, 0xCBD6, 0xF901,\t0xCBD7, 0x7CB3, 0xCBD8, 0x7FB9, 0xCBD9, 0x91B5, 0xCBDA, 0x5028,\r\n\t0xCBDB, 0x53BB, 0xCBDC, 0x5C45, 0xCBDD, 0x5DE8, 0xCBDE, 0x62D2,\t0xCBDF, 0x636E, 0xCBE0, 0x64DA, 0xCBE1, 0x64E7, 0xCBE2, 0x6E20,\r\n\t0xCBE3, 0x70AC, 0xCBE4, 0x795B, 0xCBE5, 0x8DDD, 0xCBE6, 0x8E1E,\t0xCBE7, 0xF902, 0xCBE8, 0x907D, 0xCBE9, 0x9245, 0xCBEA, 0x92F8,\r\n\t0xCBEB, 0x4E7E, 0xCBEC, 0x4EF6, 0xCBED, 0x5065, 0xCBEE, 0x5DFE,\t0xCBEF, 0x5EFA, 0xCBF0, 0x6106, 0xCBF1, 0x6957, 0xCBF2, 0x8171,\r\n\t0xCBF3, 0x8654, 0xCBF4, 0x8E47, 0xCBF5, 0x9375, 0xCBF6, 0x9A2B,\t0xCBF7, 0x4E5E, 0xCBF8, 0x5091, 0xCBF9, 0x6770, 0xCBFA, 0x6840,\r\n\t0xCBFB, 0x5109, 0xCBFC, 0x528D, 0xCBFD, 0x5292, 0xCBFE, 0x6AA2,\t0xCCA1, 0x77BC, 0xCCA2, 0x9210, 0xCCA3, 0x9ED4, 0xCCA4, 0x52AB,\r\n\t0xCCA5, 0x602F, 0xCCA6, 0x8FF2, 0xCCA7, 0x5048, 0xCCA8, 0x61A9,\t0xCCA9, 0x63ED, 0xCCAA, 0x64CA, 0xCCAB, 0x683C, 0xCCAC, 0x6A84,\r\n\t0xCCAD, 0x6FC0, 0xCCAE, 0x8188, 0xCCAF, 0x89A1, 0xCCB0, 0x9694,\t0xCCB1, 0x5805, 0xCCB2, 0x727D, 0xCCB3, 0x72AC, 0xCCB4, 0x7504,\r\n\t0xCCB5, 0x7D79, 0xCCB6, 0x7E6D, 0xCCB7, 0x80A9, 0xCCB8, 0x898B,\t0xCCB9, 0x8B74, 0xCCBA, 0x9063, 0xCCBB, 0x9D51, 0xCCBC, 0x6289,\r\n\t0xCCBD, 0x6C7A, 0xCCBE, 0x6F54, 0xCCBF, 0x7D50, 0xCCC0, 0x7F3A,\t0xCCC1, 0x8A23, 0xCCC2, 0x517C, 0xCCC3, 0x614A, 0xCCC4, 0x7B9D,\r\n\t0xCCC5, 0x8B19, 0xCCC6, 0x9257, 0xCCC7, 0x938C, 0xCCC8, 0x4EAC,\t0xCCC9, 0x4FD3, 0xCCCA, 0x501E, 0xCCCB, 0x50BE, 0xCCCC, 0x5106,\r\n\t0xCCCD, 0x52C1, 0xCCCE, 0x52CD, 0xCCCF, 0x537F, 0xCCD0, 0x5770,\t0xCCD1, 0x5883, 0xCCD2, 0x5E9A, 0xCCD3, 0x5F91, 0xCCD4, 0x6176,\r\n\t0xCCD5, 0x61AC, 0xCCD6, 0x64CE, 0xCCD7, 0x656C, 0xCCD8, 0x666F,\t0xCCD9, 0x66BB, 0xCCDA, 0x66F4, 0xCCDB, 0x6897, 0xCCDC, 0x6D87,\r\n\t0xCCDD, 0x7085, 0xCCDE, 0x70F1, 0xCCDF, 0x749F, 0xCCE0, 0x74A5,\t0xCCE1, 0x74CA, 0xCCE2, 0x75D9, 0xCCE3, 0x786C, 0xCCE4, 0x78EC,\r\n\t0xCCE5, 0x7ADF, 0xCCE6, 0x7AF6, 0xCCE7, 0x7D45, 0xCCE8, 0x7D93,\t0xCCE9, 0x8015, 0xCCEA, 0x803F, 0xCCEB, 0x811B, 0xCCEC, 0x8396,\r\n\t0xCCED, 0x8B66, 0xCCEE, 0x8F15, 0xCCEF, 0x9015, 0xCCF0, 0x93E1,\t0xCCF1, 0x9803, 0xCCF2, 0x9838, 0xCCF3, 0x9A5A, 0xCCF4, 0x9BE8,\r\n\t0xCCF5, 0x4FC2, 0xCCF6, 0x5553, 0xCCF7, 0x583A, 0xCCF8, 0x5951,\t0xCCF9, 0x5B63, 0xCCFA, 0x5C46, 0xCCFB, 0x60B8, 0xCCFC, 0x6212,\r\n\t0xCCFD, 0x6842, 0xCCFE, 0x68B0, 0xCDA1, 0x68E8, 0xCDA2, 0x6EAA,\t0xCDA3, 0x754C, 0xCDA4, 0x7678, 0xCDA5, 0x78CE, 0xCDA6, 0x7A3D,\r\n\t0xCDA7, 0x7CFB, 0xCDA8, 0x7E6B, 0xCDA9, 0x7E7C, 0xCDAA, 0x8A08,\t0xCDAB, 0x8AA1, 0xCDAC, 0x8C3F, 0xCDAD, 0x968E, 0xCDAE, 0x9DC4,\r\n\t0xCDAF, 0x53E4, 0xCDB0, 0x53E9, 0xCDB1, 0x544A, 0xCDB2, 0x5471,\t0xCDB3, 0x56FA, 0xCDB4, 0x59D1, 0xCDB5, 0x5B64, 0xCDB6, 0x5C3B,\r\n\t0xCDB7, 0x5EAB, 0xCDB8, 0x62F7, 0xCDB9, 0x6537, 0xCDBA, 0x6545,\t0xCDBB, 0x6572, 0xCDBC, 0x66A0, 0xCDBD, 0x67AF, 0xCDBE, 0x69C1,\r\n\t0xCDBF, 0x6CBD, 0xCDC0, 0x75FC, 0xCDC1, 0x7690, 0xCDC2, 0x777E,\t0xCDC3, 0x7A3F, 0xCDC4, 0x7F94, 0xCDC5, 0x8003, 0xCDC6, 0x80A1,\r\n\t0xCDC7, 0x818F, 0xCDC8, 0x82E6, 0xCDC9, 0x82FD, 0xCDCA, 0x83F0,\t0xCDCB, 0x85C1, 0xCDCC, 0x8831, 0xCDCD, 0x88B4, 0xCDCE, 0x8AA5,\r\n\t0xCDCF, 0xF903, 0xCDD0, 0x8F9C, 0xCDD1, 0x932E, 0xCDD2, 0x96C7,\t0xCDD3, 0x9867, 0xCDD4, 0x9AD8, 0xCDD5, 0x9F13, 0xCDD6, 0x54ED,\r\n\t0xCDD7, 0x659B, 0xCDD8, 0x66F2, 0xCDD9, 0x688F, 0xCDDA, 0x7A40,\t0xCDDB, 0x8C37, 0xCDDC, 0x9D60, 0xCDDD, 0x56F0, 0xCDDE, 0x5764,\r\n\t0xCDDF, 0x5D11, 0xCDE0, 0x6606, 0xCDE1, 0x68B1, 0xCDE2, 0x68CD,\t0xCDE3, 0x6EFE, 0xCDE4, 0x7428, 0xCDE5, 0x889E, 0xCDE6, 0x9BE4,\r\n\t0xCDE7, 0x6C68, 0xCDE8, 0xF904, 0xCDE9, 0x9AA8, 0xCDEA, 0x4F9B,\t0xCDEB, 0x516C, 0xCDEC, 0x5171, 0xCDED, 0x529F, 0xCDEE, 0x5B54,\r\n\t0xCDEF, 0x5DE5, 0xCDF0, 0x6050, 0xCDF1, 0x606D, 0xCDF2, 0x62F1,\t0xCDF3, 0x63A7, 0xCDF4, 0x653B, 0xCDF5, 0x73D9, 0xCDF6, 0x7A7A,\r\n\t0xCDF7, 0x86A3, 0xCDF8, 0x8CA2, 0xCDF9, 0x978F, 0xCDFA, 0x4E32,\t0xCDFB, 0x5BE1, 0xCDFC, 0x6208, 0xCDFD, 0x679C, 0xCDFE, 0x74DC,\r\n\t0xCEA1, 0x79D1, 0xCEA2, 0x83D3, 0xCEA3, 0x8A87, 0xCEA4, 0x8AB2,\t0xCEA5, 0x8DE8, 0xCEA6, 0x904E, 0xCEA7, 0x934B, 0xCEA8, 0x9846,\r\n\t0xCEA9, 0x5ED3, 0xCEAA, 0x69E8, 0xCEAB, 0x85FF, 0xCEAC, 0x90ED,\t0xCEAD, 0xF905, 0xCEAE, 0x51A0, 0xCEAF, 0x5B98, 0xCEB0, 0x5BEC,\r\n\t0xCEB1, 0x6163, 0xCEB2, 0x68FA, 0xCEB3, 0x6B3E, 0xCEB4, 0x704C,\t0xCEB5, 0x742F, 0xCEB6, 0x74D8, 0xCEB7, 0x7BA1, 0xCEB8, 0x7F50,\r\n\t0xCEB9, 0x83C5, 0xCEBA, 0x89C0, 0xCEBB, 0x8CAB, 0xCEBC, 0x95DC,\t0xCEBD, 0x9928, 0xCEBE, 0x522E, 0xCEBF, 0x605D, 0xCEC0, 0x62EC,\r\n\t0xCEC1, 0x9002, 0xCEC2, 0x4F8A, 0xCEC3, 0x5149, 0xCEC4, 0x5321,\t0xCEC5, 0x58D9, 0xCEC6, 0x5EE3, 0xCEC7, 0x66E0, 0xCEC8, 0x6D38,\r\n\t0xCEC9, 0x709A, 0xCECA, 0x72C2, 0xCECB, 0x73D6, 0xCECC, 0x7B50,\t0xCECD, 0x80F1, 0xCECE, 0x945B, 0xCECF, 0x5366, 0xCED0, 0x639B,\r\n\t0xCED1, 0x7F6B, 0xCED2, 0x4E56, 0xCED3, 0x5080, 0xCED4, 0x584A,\t0xCED5, 0x58DE, 0xCED6, 0x602A, 0xCED7, 0x6127, 0xCED8, 0x62D0,\r\n\t0xCED9, 0x69D0, 0xCEDA, 0x9B41, 0xCEDB, 0x5B8F, 0xCEDC, 0x7D18,\t0xCEDD, 0x80B1, 0xCEDE, 0x8F5F, 0xCEDF, 0x4EA4, 0xCEE0, 0x50D1,\r\n\t0xCEE1, 0x54AC, 0xCEE2, 0x55AC, 0xCEE3, 0x5B0C, 0xCEE4, 0x5DA0,\t0xCEE5, 0x5DE7, 0xCEE6, 0x652A, 0xCEE7, 0x654E, 0xCEE8, 0x6821,\r\n\t0xCEE9, 0x6A4B, 0xCEEA, 0x72E1, 0xCEEB, 0x768E, 0xCEEC, 0x77EF,\t0xCEED, 0x7D5E, 0xCEEE, 0x7FF9, 0xCEEF, 0x81A0, 0xCEF0, 0x854E,\r\n\t0xCEF1, 0x86DF, 0xCEF2, 0x8F03, 0xCEF3, 0x8F4E, 0xCEF4, 0x90CA,\t0xCEF5, 0x9903, 0xCEF6, 0x9A55, 0xCEF7, 0x9BAB, 0xCEF8, 0x4E18,\r\n\t0xCEF9, 0x4E45, 0xCEFA, 0x4E5D, 0xCEFB, 0x4EC7, 0xCEFC, 0x4FF1,\t0xCEFD, 0x5177, 0xCEFE, 0x52FE, 0xCFA1, 0x5340, 0xCFA2, 0x53E3,\r\n\t0xCFA3, 0x53E5, 0xCFA4, 0x548E, 0xCFA5, 0x5614, 0xCFA6, 0x5775,\t0xCFA7, 0x57A2, 0xCFA8, 0x5BC7, 0xCFA9, 0x5D87, 0xCFAA, 0x5ED0,\r\n\t0xCFAB, 0x61FC, 0xCFAC, 0x62D8, 0xCFAD, 0x6551, 0xCFAE, 0x67B8,\t0xCFAF, 0x67E9, 0xCFB0, 0x69CB, 0xCFB1, 0x6B50, 0xCFB2, 0x6BC6,\r\n\t0xCFB3, 0x6BEC, 0xCFB4, 0x6C42, 0xCFB5, 0x6E9D, 0xCFB6, 0x7078,\t0xCFB7, 0x72D7, 0xCFB8, 0x7396, 0xCFB9, 0x7403, 0xCFBA, 0x77BF,\r\n\t0xCFBB, 0x77E9, 0xCFBC, 0x7A76, 0xCFBD, 0x7D7F, 0xCFBE, 0x8009,\t0xCFBF, 0x81FC, 0xCFC0, 0x8205, 0xCFC1, 0x820A, 0xCFC2, 0x82DF,\r\n\t0xCFC3, 0x8862, 0xCFC4, 0x8B33, 0xCFC5, 0x8CFC, 0xCFC6, 0x8EC0,\t0xCFC7, 0x9011, 0xCFC8, 0x90B1, 0xCFC9, 0x9264, 0xCFCA, 0x92B6,\r\n\t0xCFCB, 0x99D2, 0xCFCC, 0x9A45, 0xCFCD, 0x9CE9, 0xCFCE, 0x9DD7,\t0xCFCF, 0x9F9C, 0xCFD0, 0x570B, 0xCFD1, 0x5C40, 0xCFD2, 0x83CA,\r\n\t0xCFD3, 0x97A0, 0xCFD4, 0x97AB, 0xCFD5, 0x9EB4, 0xCFD6, 0x541B,\t0xCFD7, 0x7A98, 0xCFD8, 0x7FA4, 0xCFD9, 0x88D9, 0xCFDA, 0x8ECD,\r\n\t0xCFDB, 0x90E1, 0xCFDC, 0x5800, 0xCFDD, 0x5C48, 0xCFDE, 0x6398,\t0xCFDF, 0x7A9F, 0xCFE0, 0x5BAE, 0xCFE1, 0x5F13, 0xCFE2, 0x7A79,\r\n\t0xCFE3, 0x7AAE, 0xCFE4, 0x828E, 0xCFE5, 0x8EAC, 0xCFE6, 0x5026,\t0xCFE7, 0x5238, 0xCFE8, 0x52F8, 0xCFE9, 0x5377, 0xCFEA, 0x5708,\r\n\t0xCFEB, 0x62F3, 0xCFEC, 0x6372, 0xCFED, 0x6B0A, 0xCFEE, 0x6DC3,\t0xCFEF, 0x7737, 0xCFF0, 0x53A5, 0xCFF1, 0x7357, 0xCFF2, 0x8568,\r\n\t0xCFF3, 0x8E76, 0xCFF4, 0x95D5, 0xCFF5, 0x673A, 0xCFF6, 0x6AC3,\t0xCFF7, 0x6F70, 0xCFF8, 0x8A6D, 0xCFF9, 0x8ECC, 0xCFFA, 0x994B,\r\n\t0xCFFB, 0xF906, 0xCFFC, 0x6677, 0xCFFD, 0x6B78, 0xCFFE, 0x8CB4,\t0xD0A1, 0x9B3C, 0xD0A2, 0xF907, 0xD0A3, 0x53EB, 0xD0A4, 0x572D,\r\n\t0xD0A5, 0x594E, 0xD0A6, 0x63C6, 0xD0A7, 0x69FB, 0xD0A8, 0x73EA,\t0xD0A9, 0x7845, 0xD0AA, 0x7ABA, 0xD0AB, 0x7AC5, 0xD0AC, 0x7CFE,\r\n\t0xD0AD, 0x8475, 0xD0AE, 0x898F, 0xD0AF, 0x8D73, 0xD0B0, 0x9035,\t0xD0B1, 0x95A8, 0xD0B2, 0x52FB, 0xD0B3, 0x5747, 0xD0B4, 0x7547,\r\n\t0xD0B5, 0x7B60, 0xD0B6, 0x83CC, 0xD0B7, 0x921E, 0xD0B8, 0xF908,\t0xD0B9, 0x6A58, 0xD0BA, 0x514B, 0xD0BB, 0x524B, 0xD0BC, 0x5287,\r\n\t0xD0BD, 0x621F, 0xD0BE, 0x68D8, 0xD0BF, 0x6975, 0xD0C0, 0x9699,\t0xD0C1, 0x50C5, 0xD0C2, 0x52A4, 0xD0C3, 0x52E4, 0xD0C4, 0x61C3,\r\n\t0xD0C5, 0x65A4, 0xD0C6, 0x6839, 0xD0C7, 0x69FF, 0xD0C8, 0x747E,\t0xD0C9, 0x7B4B, 0xD0CA, 0x82B9, 0xD0CB, 0x83EB, 0xD0CC, 0x89B2,\r\n\t0xD0CD, 0x8B39, 0xD0CE, 0x8FD1, 0xD0CF, 0x9949, 0xD0D0, 0xF909,\t0xD0D1, 0x4ECA, 0xD0D2, 0x5997, 0xD0D3, 0x64D2, 0xD0D4, 0x6611,\r\n\t0xD0D5, 0x6A8E, 0xD0D6, 0x7434, 0xD0D7, 0x7981, 0xD0D8, 0x79BD,\t0xD0D9, 0x82A9, 0xD0DA, 0x887E, 0xD0DB, 0x887F, 0xD0DC, 0x895F,\r\n\t0xD0DD, 0xF90A, 0xD0DE, 0x9326, 0xD0DF, 0x4F0B, 0xD0E0, 0x53CA,\t0xD0E1, 0x6025, 0xD0E2, 0x6271, 0xD0E3, 0x6C72, 0xD0E4, 0x7D1A,\r\n\t0xD0E5, 0x7D66, 0xD0E6, 0x4E98, 0xD0E7, 0x5162, 0xD0E8, 0x77DC,\t0xD0E9, 0x80AF, 0xD0EA, 0x4F01, 0xD0EB, 0x4F0E, 0xD0EC, 0x5176,\r\n\t0xD0ED, 0x5180, 0xD0EE, 0x55DC, 0xD0EF, 0x5668, 0xD0F0, 0x573B,\t0xD0F1, 0x57FA, 0xD0F2, 0x57FC, 0xD0F3, 0x5914, 0xD0F4, 0x5947,\r\n\t0xD0F5, 0x5993, 0xD0F6, 0x5BC4, 0xD0F7, 0x5C90, 0xD0F8, 0x5D0E,\t0xD0F9, 0x5DF1, 0xD0FA, 0x5E7E, 0xD0FB, 0x5FCC, 0xD0FC, 0x6280,\r\n\t0xD0FD, 0x65D7, 0xD0FE, 0x65E3, 0xD1A1, 0x671E, 0xD1A2, 0x671F,\t0xD1A3, 0x675E, 0xD1A4, 0x68CB, 0xD1A5, 0x68C4, 0xD1A6, 0x6A5F,\r\n\t0xD1A7, 0x6B3A, 0xD1A8, 0x6C23, 0xD1A9, 0x6C7D, 0xD1AA, 0x6C82,\t0xD1AB, 0x6DC7, 0xD1AC, 0x7398, 0xD1AD, 0x7426, 0xD1AE, 0x742A,\r\n\t0xD1AF, 0x7482, 0xD1B0, 0x74A3, 0xD1B1, 0x7578, 0xD1B2, 0x757F,\t0xD1B3, 0x7881, 0xD1B4, 0x78EF, 0xD1B5, 0x7941, 0xD1B6, 0x7947,\r\n\t0xD1B7, 0x7948, 0xD1B8, 0x797A, 0xD1B9, 0x7B95, 0xD1BA, 0x7D00,\t0xD1BB, 0x7DBA, 0xD1BC, 0x7F88, 0xD1BD, 0x8006, 0xD1BE, 0x802D,\r\n\t0xD1BF, 0x808C, 0xD1C0, 0x8A18, 0xD1C1, 0x8B4F, 0xD1C2, 0x8C48,\t0xD1C3, 0x8D77, 0xD1C4, 0x9321, 0xD1C5, 0x9324, 0xD1C6, 0x98E2,\r\n\t0xD1C7, 0x9951, 0xD1C8, 0x9A0E, 0xD1C9, 0x9A0F, 0xD1CA, 0x9A65,\t0xD1CB, 0x9E92, 0xD1CC, 0x7DCA, 0xD1CD, 0x4F76, 0xD1CE, 0x5409,\r\n\t0xD1CF, 0x62EE, 0xD1D0, 0x6854, 0xD1D1, 0x91D1, 0xD1D2, 0x55AB,\t0xD1D3, 0x513A, 0xD1D4, 0xF90B, 0xD1D5, 0xF90C, 0xD1D6, 0x5A1C,\r\n\t0xD1D7, 0x61E6, 0xD1D8, 0xF90D, 0xD1D9, 0x62CF, 0xD1DA, 0x62FF,\t0xD1DB, 0xF90E, 0xD1DC, 0xF90F, 0xD1DD, 0xF910, 0xD1DE, 0xF911,\r\n\t0xD1DF, 0xF912, 0xD1E0, 0xF913, 0xD1E1, 0x90A3, 0xD1E2, 0xF914,\t0xD1E3, 0xF915, 0xD1E4, 0xF916, 0xD1E5, 0xF917, 0xD1E6, 0xF918,\r\n\t0xD1E7, 0x8AFE, 0xD1E8, 0xF919, 0xD1E9, 0xF91A, 0xD1EA, 0xF91B,\t0xD1EB, 0xF91C, 0xD1EC, 0x6696, 0xD1ED, 0xF91D, 0xD1EE, 0x7156,\r\n\t0xD1EF, 0xF91E, 0xD1F0, 0xF91F, 0xD1F1, 0x96E3, 0xD1F2, 0xF920,\t0xD1F3, 0x634F, 0xD1F4, 0x637A, 0xD1F5, 0x5357, 0xD1F6, 0xF921,\r\n\t0xD1F7, 0x678F, 0xD1F8, 0x6960, 0xD1F9, 0x6E73, 0xD1FA, 0xF922,\t0xD1FB, 0x7537, 0xD1FC, 0xF923, 0xD1FD, 0xF924, 0xD1FE, 0xF925,\r\n\t0xD2A1, 0x7D0D, 0xD2A2, 0xF926, 0xD2A3, 0xF927, 0xD2A4, 0x8872,\t0xD2A5, 0x56CA, 0xD2A6, 0x5A18, 0xD2A7, 0xF928, 0xD2A8, 0xF929,\r\n\t0xD2A9, 0xF92A, 0xD2AA, 0xF92B, 0xD2AB, 0xF92C, 0xD2AC, 0x4E43,\t0xD2AD, 0xF92D, 0xD2AE, 0x5167, 0xD2AF, 0x5948, 0xD2B0, 0x67F0,\r\n\t0xD2B1, 0x8010, 0xD2B2, 0xF92E, 0xD2B3, 0x5973, 0xD2B4, 0x5E74,\t0xD2B5, 0x649A, 0xD2B6, 0x79CA, 0xD2B7, 0x5FF5, 0xD2B8, 0x606C,\r\n\t0xD2B9, 0x62C8, 0xD2BA, 0x637B, 0xD2BB, 0x5BE7, 0xD2BC, 0x5BD7,\t0xD2BD, 0x52AA, 0xD2BE, 0xF92F, 0xD2BF, 0x5974, 0xD2C0, 0x5F29,\r\n\t0xD2C1, 0x6012, 0xD2C2, 0xF930, 0xD2C3, 0xF931, 0xD2C4, 0xF932,\t0xD2C5, 0x7459, 0xD2C6, 0xF933, 0xD2C7, 0xF934, 0xD2C8, 0xF935,\r\n\t0xD2C9, 0xF936, 0xD2CA, 0xF937, 0xD2CB, 0xF938, 0xD2CC, 0x99D1,\t0xD2CD, 0xF939, 0xD2CE, 0xF93A, 0xD2CF, 0xF93B, 0xD2D0, 0xF93C,\r\n\t0xD2D1, 0xF93D, 0xD2D2, 0xF93E, 0xD2D3, 0xF93F, 0xD2D4, 0xF940,\t0xD2D5, 0xF941, 0xD2D6, 0xF942, 0xD2D7, 0xF943, 0xD2D8, 0x6FC3,\r\n\t0xD2D9, 0xF944, 0xD2DA, 0xF945, 0xD2DB, 0x81BF, 0xD2DC, 0x8FB2,\t0xD2DD, 0x60F1, 0xD2DE, 0xF946, 0xD2DF, 0xF947, 0xD2E0, 0x8166,\r\n\t0xD2E1, 0xF948, 0xD2E2, 0xF949, 0xD2E3, 0x5C3F, 0xD2E4, 0xF94A,\t0xD2E5, 0xF94B, 0xD2E6, 0xF94C, 0xD2E7, 0xF94D, 0xD2E8, 0xF94E,\r\n\t0xD2E9, 0xF94F, 0xD2EA, 0xF950, 0xD2EB, 0xF951, 0xD2EC, 0x5AE9,\t0xD2ED, 0x8A25, 0xD2EE, 0x677B, 0xD2EF, 0x7D10, 0xD2F0, 0xF952,\r\n\t0xD2F1, 0xF953, 0xD2F2, 0xF954, 0xD2F3, 0xF955, 0xD2F4, 0xF956,\t0xD2F5, 0xF957, 0xD2F6, 0x80FD, 0xD2F7, 0xF958, 0xD2F8, 0xF959,\r\n\t0xD2F9, 0x5C3C, 0xD2FA, 0x6CE5, 0xD2FB, 0x533F, 0xD2FC, 0x6EBA,\t0xD2FD, 0x591A, 0xD2FE, 0x8336, 0xD3A1, 0x4E39, 0xD3A2, 0x4EB6,\r\n\t0xD3A3, 0x4F46, 0xD3A4, 0x55AE, 0xD3A5, 0x5718, 0xD3A6, 0x58C7,\t0xD3A7, 0x5F56, 0xD3A8, 0x65B7, 0xD3A9, 0x65E6, 0xD3AA, 0x6A80,\r\n\t0xD3AB, 0x6BB5, 0xD3AC, 0x6E4D, 0xD3AD, 0x77ED, 0xD3AE, 0x7AEF,\t0xD3AF, 0x7C1E, 0xD3B0, 0x7DDE, 0xD3B1, 0x86CB, 0xD3B2, 0x8892,\r\n\t0xD3B3, 0x9132, 0xD3B4, 0x935B, 0xD3B5, 0x64BB, 0xD3B6, 0x6FBE,\t0xD3B7, 0x737A, 0xD3B8, 0x75B8, 0xD3B9, 0x9054, 0xD3BA, 0x5556,\r\n\t0xD3BB, 0x574D, 0xD3BC, 0x61BA, 0xD3BD, 0x64D4, 0xD3BE, 0x66C7,\t0xD3BF, 0x6DE1, 0xD3C0, 0x6E5B, 0xD3C1, 0x6F6D, 0xD3C2, 0x6FB9,\r\n\t0xD3C3, 0x75F0, 0xD3C4, 0x8043, 0xD3C5, 0x81BD, 0xD3C6, 0x8541,\t0xD3C7, 0x8983, 0xD3C8, 0x8AC7, 0xD3C9, 0x8B5A, 0xD3CA, 0x931F,\r\n\t0xD3CB, 0x6C93, 0xD3CC, 0x7553, 0xD3CD, 0x7B54, 0xD3CE, 0x8E0F,\t0xD3CF, 0x905D, 0xD3D0, 0x5510, 0xD3D1, 0x5802, 0xD3D2, 0x5858,\r\n\t0xD3D3, 0x5E62, 0xD3D4, 0x6207, 0xD3D5, 0x649E, 0xD3D6, 0x68E0,\t0xD3D7, 0x7576, 0xD3D8, 0x7CD6, 0xD3D9, 0x87B3, 0xD3DA, 0x9EE8,\r\n\t0xD3DB, 0x4EE3, 0xD3DC, 0x5788, 0xD3DD, 0x576E, 0xD3DE, 0x5927,\t0xD3DF, 0x5C0D, 0xD3E0, 0x5CB1, 0xD3E1, 0x5E36, 0xD3E2, 0x5F85,\r\n\t0xD3E3, 0x6234, 0xD3E4, 0x64E1, 0xD3E5, 0x73B3, 0xD3E6, 0x81FA,\t0xD3E7, 0x888B, 0xD3E8, 0x8CB8, 0xD3E9, 0x968A, 0xD3EA, 0x9EDB,\r\n\t0xD3EB, 0x5B85, 0xD3EC, 0x5FB7, 0xD3ED, 0x60B3, 0xD3EE, 0x5012,\t0xD3EF, 0x5200, 0xD3F0, 0x5230, 0xD3F1, 0x5716, 0xD3F2, 0x5835,\r\n\t0xD3F3, 0x5857, 0xD3F4, 0x5C0E, 0xD3F5, 0x5C60, 0xD3F6, 0x5CF6,\t0xD3F7, 0x5D8B, 0xD3F8, 0x5EA6, 0xD3F9, 0x5F92, 0xD3FA, 0x60BC,\r\n\t0xD3FB, 0x6311, 0xD3FC, 0x6389, 0xD3FD, 0x6417, 0xD3FE, 0x6843,\t0xD4A1, 0x68F9, 0xD4A2, 0x6AC2, 0xD4A3, 0x6DD8, 0xD4A4, 0x6E21,\r\n\t0xD4A5, 0x6ED4, 0xD4A6, 0x6FE4, 0xD4A7, 0x71FE, 0xD4A8, 0x76DC,\t0xD4A9, 0x7779, 0xD4AA, 0x79B1, 0xD4AB, 0x7A3B, 0xD4AC, 0x8404,\r\n\t0xD4AD, 0x89A9, 0xD4AE, 0x8CED, 0xD4AF, 0x8DF3, 0xD4B0, 0x8E48,\t0xD4B1, 0x9003, 0xD4B2, 0x9014, 0xD4B3, 0x9053, 0xD4B4, 0x90FD,\r\n\t0xD4B5, 0x934D, 0xD4B6, 0x9676, 0xD4B7, 0x97DC, 0xD4B8, 0x6BD2,\t0xD4B9, 0x7006, 0xD4BA, 0x7258, 0xD4BB, 0x72A2, 0xD4BC, 0x7368,\r\n\t0xD4BD, 0x7763, 0xD4BE, 0x79BF, 0xD4BF, 0x7BE4, 0xD4C0, 0x7E9B,\t0xD4C1, 0x8B80, 0xD4C2, 0x58A9, 0xD4C3, 0x60C7, 0xD4C4, 0x6566,\r\n\t0xD4C5, 0x65FD, 0xD4C6, 0x66BE, 0xD4C7, 0x6C8C, 0xD4C8, 0x711E,\t0xD4C9, 0x71C9, 0xD4CA, 0x8C5A, 0xD4CB, 0x9813, 0xD4CC, 0x4E6D,\r\n\t0xD4CD, 0x7A81, 0xD4CE, 0x4EDD, 0xD4CF, 0x51AC, 0xD4D0, 0x51CD,\t0xD4D1, 0x52D5, 0xD4D2, 0x540C, 0xD4D3, 0x61A7, 0xD4D4, 0x6771,\r\n\t0xD4D5, 0x6850, 0xD4D6, 0x68DF, 0xD4D7, 0x6D1E, 0xD4D8, 0x6F7C,\t0xD4D9, 0x75BC, 0xD4DA, 0x77B3, 0xD4DB, 0x7AE5, 0xD4DC, 0x80F4,\r\n\t0xD4DD, 0x8463, 0xD4DE, 0x9285, 0xD4DF, 0x515C, 0xD4E0, 0x6597,\t0xD4E1, 0x675C, 0xD4E2, 0x6793, 0xD4E3, 0x75D8, 0xD4E4, 0x7AC7,\r\n\t0xD4E5, 0x8373, 0xD4E6, 0xF95A, 0xD4E7, 0x8C46, 0xD4E8, 0x9017,\t0xD4E9, 0x982D, 0xD4EA, 0x5C6F, 0xD4EB, 0x81C0, 0xD4EC, 0x829A,\r\n\t0xD4ED, 0x9041, 0xD4EE, 0x906F, 0xD4EF, 0x920D, 0xD4F0, 0x5F97,\t0xD4F1, 0x5D9D, 0xD4F2, 0x6A59, 0xD4F3, 0x71C8, 0xD4F4, 0x767B,\r\n\t0xD4F5, 0x7B49, 0xD4F6, 0x85E4, 0xD4F7, 0x8B04, 0xD4F8, 0x9127,\t0xD4F9, 0x9A30, 0xD4FA, 0x5587, 0xD4FB, 0x61F6, 0xD4FC, 0xF95B,\r\n\t0xD4FD, 0x7669, 0xD4FE, 0x7F85, 0xD5A1, 0x863F, 0xD5A2, 0x87BA,\t0xD5A3, 0x88F8, 0xD5A4, 0x908F, 0xD5A5, 0xF95C, 0xD5A6, 0x6D1B,\r\n\t0xD5A7, 0x70D9, 0xD5A8, 0x73DE, 0xD5A9, 0x7D61, 0xD5AA, 0x843D,\t0xD5AB, 0xF95D, 0xD5AC, 0x916A, 0xD5AD, 0x99F1, 0xD5AE, 0xF95E,\r\n\t0xD5AF, 0x4E82, 0xD5B0, 0x5375, 0xD5B1, 0x6B04, 0xD5B2, 0x6B12,\t0xD5B3, 0x703E, 0xD5B4, 0x721B, 0xD5B5, 0x862D, 0xD5B6, 0x9E1E,\r\n\t0xD5B7, 0x524C, 0xD5B8, 0x8FA3, 0xD5B9, 0x5D50, 0xD5BA, 0x64E5,\t0xD5BB, 0x652C, 0xD5BC, 0x6B16, 0xD5BD, 0x6FEB, 0xD5BE, 0x7C43,\r\n\t0xD5BF, 0x7E9C, 0xD5C0, 0x85CD, 0xD5C1, 0x8964, 0xD5C2, 0x89BD,\t0xD5C3, 0x62C9, 0xD5C4, 0x81D8, 0xD5C5, 0x881F, 0xD5C6, 0x5ECA,\r\n\t0xD5C7, 0x6717, 0xD5C8, 0x6D6A, 0xD5C9, 0x72FC, 0xD5CA, 0x7405,\t0xD5CB, 0x746F, 0xD5CC, 0x8782, 0xD5CD, 0x90DE, 0xD5CE, 0x4F86,\r\n\t0xD5CF, 0x5D0D, 0xD5D0, 0x5FA0, 0xD5D1, 0x840A, 0xD5D2, 0x51B7,\t0xD5D3, 0x63A0, 0xD5D4, 0x7565, 0xD5D5, 0x4EAE, 0xD5D6, 0x5006,\r\n\t0xD5D7, 0x5169, 0xD5D8, 0x51C9, 0xD5D9, 0x6881, 0xD5DA, 0x6A11,\t0xD5DB, 0x7CAE, 0xD5DC, 0x7CB1, 0xD5DD, 0x7CE7, 0xD5DE, 0x826F,\r\n\t0xD5DF, 0x8AD2, 0xD5E0, 0x8F1B, 0xD5E1, 0x91CF, 0xD5E2, 0x4FB6,\t0xD5E3, 0x5137, 0xD5E4, 0x52F5, 0xD5E5, 0x5442, 0xD5E6, 0x5EEC,\r\n\t0xD5E7, 0x616E, 0xD5E8, 0x623E, 0xD5E9, 0x65C5, 0xD5EA, 0x6ADA,\t0xD5EB, 0x6FFE, 0xD5EC, 0x792A, 0xD5ED, 0x85DC, 0xD5EE, 0x8823,\r\n\t0xD5EF, 0x95AD, 0xD5F0, 0x9A62, 0xD5F1, 0x9A6A, 0xD5F2, 0x9E97,\t0xD5F3, 0x9ECE, 0xD5F4, 0x529B, 0xD5F5, 0x66C6, 0xD5F6, 0x6B77,\r\n\t0xD5F7, 0x701D, 0xD5F8, 0x792B, 0xD5F9, 0x8F62, 0xD5FA, 0x9742,\t0xD5FB, 0x6190, 0xD5FC, 0x6200, 0xD5FD, 0x6523, 0xD5FE, 0x6F23,\r\n\t0xD6A1, 0x7149, 0xD6A2, 0x7489, 0xD6A3, 0x7DF4, 0xD6A4, 0x806F,\t0xD6A5, 0x84EE, 0xD6A6, 0x8F26, 0xD6A7, 0x9023, 0xD6A8, 0x934A,\r\n\t0xD6A9, 0x51BD, 0xD6AA, 0x5217, 0xD6AB, 0x52A3, 0xD6AC, 0x6D0C,\t0xD6AD, 0x70C8, 0xD6AE, 0x88C2, 0xD6AF, 0x5EC9, 0xD6B0, 0x6582,\r\n\t0xD6B1, 0x6BAE, 0xD6B2, 0x6FC2, 0xD6B3, 0x7C3E, 0xD6B4, 0x7375,\t0xD6B5, 0x4EE4, 0xD6B6, 0x4F36, 0xD6B7, 0x56F9, 0xD6B8, 0xF95F,\r\n\t0xD6B9, 0x5CBA, 0xD6BA, 0x5DBA, 0xD6BB, 0x601C, 0xD6BC, 0x73B2,\t0xD6BD, 0x7B2D, 0xD6BE, 0x7F9A, 0xD6BF, 0x7FCE, 0xD6C0, 0x8046,\r\n\t0xD6C1, 0x901E, 0xD6C2, 0x9234, 0xD6C3, 0x96F6, 0xD6C4, 0x9748,\t0xD6C5, 0x9818, 0xD6C6, 0x9F61, 0xD6C7, 0x4F8B, 0xD6C8, 0x6FA7,\r\n\t0xD6C9, 0x79AE, 0xD6CA, 0x91B4, 0xD6CB, 0x96B7, 0xD6CC, 0x52DE,\t0xD6CD, 0xF960, 0xD6CE, 0x6488, 0xD6CF, 0x64C4, 0xD6D0, 0x6AD3,\r\n\t0xD6D1, 0x6F5E, 0xD6D2, 0x7018, 0xD6D3, 0x7210, 0xD6D4, 0x76E7,\t0xD6D5, 0x8001, 0xD6D6, 0x8606, 0xD6D7, 0x865C, 0xD6D8, 0x8DEF,\r\n\t0xD6D9, 0x8F05, 0xD6DA, 0x9732, 0xD6DB, 0x9B6F, 0xD6DC, 0x9DFA,\t0xD6DD, 0x9E75, 0xD6DE, 0x788C, 0xD6DF, 0x797F, 0xD6E0, 0x7DA0,\r\n\t0xD6E1, 0x83C9, 0xD6E2, 0x9304, 0xD6E3, 0x9E7F, 0xD6E4, 0x9E93,\t0xD6E5, 0x8AD6, 0xD6E6, 0x58DF, 0xD6E7, 0x5F04, 0xD6E8, 0x6727,\r\n\t0xD6E9, 0x7027, 0xD6EA, 0x74CF, 0xD6EB, 0x7C60, 0xD6EC, 0x807E,\t0xD6ED, 0x5121, 0xD6EE, 0x7028, 0xD6EF, 0x7262, 0xD6F0, 0x78CA,\r\n\t0xD6F1, 0x8CC2, 0xD6F2, 0x8CDA, 0xD6F3, 0x8CF4, 0xD6F4, 0x96F7,\t0xD6F5, 0x4E86, 0xD6F6, 0x50DA, 0xD6F7, 0x5BEE, 0xD6F8, 0x5ED6,\r\n\t0xD6F9, 0x6599, 0xD6FA, 0x71CE, 0xD6FB, 0x7642, 0xD6FC, 0x77AD,\t0xD6FD, 0x804A, 0xD6FE, 0x84FC, 0xD7A1, 0x907C, 0xD7A2, 0x9B27,\r\n\t0xD7A3, 0x9F8D, 0xD7A4, 0x58D8, 0xD7A5, 0x5A41, 0xD7A6, 0x5C62,\t0xD7A7, 0x6A13, 0xD7A8, 0x6DDA, 0xD7A9, 0x6F0F, 0xD7AA, 0x763B,\r\n\t0xD7AB, 0x7D2F, 0xD7AC, 0x7E37, 0xD7AD, 0x851E, 0xD7AE, 0x8938,\t0xD7AF, 0x93E4, 0xD7B0, 0x964B, 0xD7B1, 0x5289, 0xD7B2, 0x65D2,\r\n\t0xD7B3, 0x67F3, 0xD7B4, 0x69B4, 0xD7B5, 0x6D41, 0xD7B6, 0x6E9C,\t0xD7B7, 0x700F, 0xD7B8, 0x7409, 0xD7B9, 0x7460, 0xD7BA, 0x7559,\r\n\t0xD7BB, 0x7624, 0xD7BC, 0x786B, 0xD7BD, 0x8B2C, 0xD7BE, 0x985E,\t0xD7BF, 0x516D, 0xD7C0, 0x622E, 0xD7C1, 0x9678, 0xD7C2, 0x4F96,\r\n\t0xD7C3, 0x502B, 0xD7C4, 0x5D19, 0xD7C5, 0x6DEA, 0xD7C6, 0x7DB8,\t0xD7C7, 0x8F2A, 0xD7C8, 0x5F8B, 0xD7C9, 0x6144, 0xD7CA, 0x6817,\r\n\t0xD7CB, 0xF961, 0xD7CC, 0x9686, 0xD7CD, 0x52D2, 0xD7CE, 0x808B,\t0xD7CF, 0x51DC, 0xD7D0, 0x51CC, 0xD7D1, 0x695E, 0xD7D2, 0x7A1C,\r\n\t0xD7D3, 0x7DBE, 0xD7D4, 0x83F1, 0xD7D5, 0x9675, 0xD7D6, 0x4FDA,\t0xD7D7, 0x5229, 0xD7D8, 0x5398, 0xD7D9, 0x540F, 0xD7DA, 0x550E,\r\n\t0xD7DB, 0x5C65, 0xD7DC, 0x60A7, 0xD7DD, 0x674E, 0xD7DE, 0x68A8,\t0xD7DF, 0x6D6C, 0xD7E0, 0x7281, 0xD7E1, 0x72F8, 0xD7E2, 0x7406,\r\n\t0xD7E3, 0x7483, 0xD7E4, 0xF962, 0xD7E5, 0x75E2, 0xD7E6, 0x7C6C,\t0xD7E7, 0x7F79, 0xD7E8, 0x7FB8, 0xD7E9, 0x8389, 0xD7EA, 0x88CF,\r\n\t0xD7EB, 0x88E1, 0xD7EC, 0x91CC, 0xD7ED, 0x91D0, 0xD7EE, 0x96E2,\t0xD7EF, 0x9BC9, 0xD7F0, 0x541D, 0xD7F1, 0x6F7E, 0xD7F2, 0x71D0,\r\n\t0xD7F3, 0x7498, 0xD7F4, 0x85FA, 0xD7F5, 0x8EAA, 0xD7F6, 0x96A3,\t0xD7F7, 0x9C57, 0xD7F8, 0x9E9F, 0xD7F9, 0x6797, 0xD7FA, 0x6DCB,\r\n\t0xD7FB, 0x7433, 0xD7FC, 0x81E8, 0xD7FD, 0x9716, 0xD7FE, 0x782C,\t0xD8A1, 0x7ACB, 0xD8A2, 0x7B20, 0xD8A3, 0x7C92, 0xD8A4, 0x6469,\r\n\t0xD8A5, 0x746A, 0xD8A6, 0x75F2, 0xD8A7, 0x78BC, 0xD8A8, 0x78E8,\t0xD8A9, 0x99AC, 0xD8AA, 0x9B54, 0xD8AB, 0x9EBB, 0xD8AC, 0x5BDE,\r\n\t0xD8AD, 0x5E55, 0xD8AE, 0x6F20, 0xD8AF, 0x819C, 0xD8B0, 0x83AB,\t0xD8B1, 0x9088, 0xD8B2, 0x4E07, 0xD8B3, 0x534D, 0xD8B4, 0x5A29,\r\n\t0xD8B5, 0x5DD2, 0xD8B6, 0x5F4E, 0xD8B7, 0x6162, 0xD8B8, 0x633D,\t0xD8B9, 0x6669, 0xD8BA, 0x66FC, 0xD8BB, 0x6EFF, 0xD8BC, 0x6F2B,\r\n\t0xD8BD, 0x7063, 0xD8BE, 0x779E, 0xD8BF, 0x842C, 0xD8C0, 0x8513,\t0xD8C1, 0x883B, 0xD8C2, 0x8F13, 0xD8C3, 0x9945, 0xD8C4, 0x9C3B,\r\n\t0xD8C5, 0x551C, 0xD8C6, 0x62B9, 0xD8C7, 0x672B, 0xD8C8, 0x6CAB,\t0xD8C9, 0x8309, 0xD8CA, 0x896A, 0xD8CB, 0x977A, 0xD8CC, 0x4EA1,\r\n\t0xD8CD, 0x5984, 0xD8CE, 0x5FD8, 0xD8CF, 0x5FD9, 0xD8D0, 0x671B,\t0xD8D1, 0x7DB2, 0xD8D2, 0x7F54, 0xD8D3, 0x8292, 0xD8D4, 0x832B,\r\n\t0xD8D5, 0x83BD, 0xD8D6, 0x8F1E, 0xD8D7, 0x9099, 0xD8D8, 0x57CB,\t0xD8D9, 0x59B9, 0xD8DA, 0x5A92, 0xD8DB, 0x5BD0, 0xD8DC, 0x6627,\r\n\t0xD8DD, 0x679A, 0xD8DE, 0x6885, 0xD8DF, 0x6BCF, 0xD8E0, 0x7164,\t0xD8E1, 0x7F75, 0xD8E2, 0x8CB7, 0xD8E3, 0x8CE3, 0xD8E4, 0x9081,\r\n\t0xD8E5, 0x9B45, 0xD8E6, 0x8108, 0xD8E7, 0x8C8A, 0xD8E8, 0x964C,\t0xD8E9, 0x9A40, 0xD8EA, 0x9EA5, 0xD8EB, 0x5B5F, 0xD8EC, 0x6C13,\r\n\t0xD8ED, 0x731B, 0xD8EE, 0x76F2, 0xD8EF, 0x76DF, 0xD8F0, 0x840C,\t0xD8F1, 0x51AA, 0xD8F2, 0x8993, 0xD8F3, 0x514D, 0xD8F4, 0x5195,\r\n\t0xD8F5, 0x52C9, 0xD8F6, 0x68C9, 0xD8F7, 0x6C94, 0xD8F8, 0x7704,\t0xD8F9, 0x7720, 0xD8FA, 0x7DBF, 0xD8FB, 0x7DEC, 0xD8FC, 0x9762,\r\n\t0xD8FD, 0x9EB5, 0xD8FE, 0x6EC5, 0xD9A1, 0x8511, 0xD9A2, 0x51A5,\t0xD9A3, 0x540D, 0xD9A4, 0x547D, 0xD9A5, 0x660E, 0xD9A6, 0x669D,\r\n\t0xD9A7, 0x6927, 0xD9A8, 0x6E9F, 0xD9A9, 0x76BF, 0xD9AA, 0x7791,\t0xD9AB, 0x8317, 0xD9AC, 0x84C2, 0xD9AD, 0x879F, 0xD9AE, 0x9169,\r\n\t0xD9AF, 0x9298, 0xD9B0, 0x9CF4, 0xD9B1, 0x8882, 0xD9B2, 0x4FAE,\t0xD9B3, 0x5192, 0xD9B4, 0x52DF, 0xD9B5, 0x59C6, 0xD9B6, 0x5E3D,\r\n\t0xD9B7, 0x6155, 0xD9B8, 0x6478, 0xD9B9, 0x6479, 0xD9BA, 0x66AE,\t0xD9BB, 0x67D0, 0xD9BC, 0x6A21, 0xD9BD, 0x6BCD, 0xD9BE, 0x6BDB,\r\n\t0xD9BF, 0x725F, 0xD9C0, 0x7261, 0xD9C1, 0x7441, 0xD9C2, 0x7738,\t0xD9C3, 0x77DB, 0xD9C4, 0x8017, 0xD9C5, 0x82BC, 0xD9C6, 0x8305,\r\n\t0xD9C7, 0x8B00, 0xD9C8, 0x8B28, 0xD9C9, 0x8C8C, 0xD9CA, 0x6728,\t0xD9CB, 0x6C90, 0xD9CC, 0x7267, 0xD9CD, 0x76EE, 0xD9CE, 0x7766,\r\n\t0xD9CF, 0x7A46, 0xD9D0, 0x9DA9, 0xD9D1, 0x6B7F, 0xD9D2, 0x6C92,\t0xD9D3, 0x5922, 0xD9D4, 0x6726, 0xD9D5, 0x8499, 0xD9D6, 0x536F,\r\n\t0xD9D7, 0x5893, 0xD9D8, 0x5999, 0xD9D9, 0x5EDF, 0xD9DA, 0x63CF,\t0xD9DB, 0x6634, 0xD9DC, 0x6773, 0xD9DD, 0x6E3A, 0xD9DE, 0x732B,\r\n\t0xD9DF, 0x7AD7, 0xD9E0, 0x82D7, 0xD9E1, 0x9328, 0xD9E2, 0x52D9,\t0xD9E3, 0x5DEB, 0xD9E4, 0x61AE, 0xD9E5, 0x61CB, 0xD9E6, 0x620A,\r\n\t0xD9E7, 0x62C7, 0xD9E8, 0x64AB, 0xD9E9, 0x65E0, 0xD9EA, 0x6959,\t0xD9EB, 0x6B66, 0xD9EC, 0x6BCB, 0xD9ED, 0x7121, 0xD9EE, 0x73F7,\r\n\t0xD9EF, 0x755D, 0xD9F0, 0x7E46, 0xD9F1, 0x821E, 0xD9F2, 0x8302,\t0xD9F3, 0x856A, 0xD9F4, 0x8AA3, 0xD9F5, 0x8CBF, 0xD9F6, 0x9727,\r\n\t0xD9F7, 0x9D61, 0xD9F8, 0x58A8, 0xD9F9, 0x9ED8, 0xD9FA, 0x5011,\t0xD9FB, 0x520E, 0xD9FC, 0x543B, 0xD9FD, 0x554F, 0xD9FE, 0x6587,\r\n\t0xDAA1, 0x6C76, 0xDAA2, 0x7D0A, 0xDAA3, 0x7D0B, 0xDAA4, 0x805E,\t0xDAA5, 0x868A, 0xDAA6, 0x9580, 0xDAA7, 0x96EF, 0xDAA8, 0x52FF,\r\n\t0xDAA9, 0x6C95, 0xDAAA, 0x7269, 0xDAAB, 0x5473, 0xDAAC, 0x5A9A,\t0xDAAD, 0x5C3E, 0xDAAE, 0x5D4B, 0xDAAF, 0x5F4C, 0xDAB0, 0x5FAE,\r\n\t0xDAB1, 0x672A, 0xDAB2, 0x68B6, 0xDAB3, 0x6963, 0xDAB4, 0x6E3C,\t0xDAB5, 0x6E44, 0xDAB6, 0x7709, 0xDAB7, 0x7C73, 0xDAB8, 0x7F8E,\r\n\t0xDAB9, 0x8587, 0xDABA, 0x8B0E, 0xDABB, 0x8FF7, 0xDABC, 0x9761,\t0xDABD, 0x9EF4, 0xDABE, 0x5CB7, 0xDABF, 0x60B6, 0xDAC0, 0x610D,\r\n\t0xDAC1, 0x61AB, 0xDAC2, 0x654F, 0xDAC3, 0x65FB, 0xDAC4, 0x65FC,\t0xDAC5, 0x6C11, 0xDAC6, 0x6CEF, 0xDAC7, 0x739F, 0xDAC8, 0x73C9,\r\n\t0xDAC9, 0x7DE1, 0xDACA, 0x9594, 0xDACB, 0x5BC6, 0xDACC, 0x871C,\t0xDACD, 0x8B10, 0xDACE, 0x525D, 0xDACF, 0x535A, 0xDAD0, 0x62CD,\r\n\t0xDAD1, 0x640F, 0xDAD2, 0x64B2, 0xDAD3, 0x6734, 0xDAD4, 0x6A38,\t0xDAD5, 0x6CCA, 0xDAD6, 0x73C0, 0xDAD7, 0x749E, 0xDAD8, 0x7B94,\r\n\t0xDAD9, 0x7C95, 0xDADA, 0x7E1B, 0xDADB, 0x818A, 0xDADC, 0x8236,\t0xDADD, 0x8584, 0xDADE, 0x8FEB, 0xDADF, 0x96F9, 0xDAE0, 0x99C1,\r\n\t0xDAE1, 0x4F34, 0xDAE2, 0x534A, 0xDAE3, 0x53CD, 0xDAE4, 0x53DB,\t0xDAE5, 0x62CC, 0xDAE6, 0x642C, 0xDAE7, 0x6500, 0xDAE8, 0x6591,\r\n\t0xDAE9, 0x69C3, 0xDAEA, 0x6CEE, 0xDAEB, 0x6F58, 0xDAEC, 0x73ED,\t0xDAED, 0x7554, 0xDAEE, 0x7622, 0xDAEF, 0x76E4, 0xDAF0, 0x76FC,\r\n\t0xDAF1, 0x78D0, 0xDAF2, 0x78FB, 0xDAF3, 0x792C, 0xDAF4, 0x7D46,\t0xDAF5, 0x822C, 0xDAF6, 0x87E0, 0xDAF7, 0x8FD4, 0xDAF8, 0x9812,\r\n\t0xDAF9, 0x98EF, 0xDAFA, 0x52C3, 0xDAFB, 0x62D4, 0xDAFC, 0x64A5,\t0xDAFD, 0x6E24, 0xDAFE, 0x6F51, 0xDBA1, 0x767C, 0xDBA2, 0x8DCB,\r\n\t0xDBA3, 0x91B1, 0xDBA4, 0x9262, 0xDBA5, 0x9AEE, 0xDBA6, 0x9B43,\t0xDBA7, 0x5023, 0xDBA8, 0x508D, 0xDBA9, 0x574A, 0xDBAA, 0x59A8,\r\n\t0xDBAB, 0x5C28, 0xDBAC, 0x5E47, 0xDBAD, 0x5F77, 0xDBAE, 0x623F,\t0xDBAF, 0x653E, 0xDBB0, 0x65B9, 0xDBB1, 0x65C1, 0xDBB2, 0x6609,\r\n\t0xDBB3, 0x678B, 0xDBB4, 0x699C, 0xDBB5, 0x6EC2, 0xDBB6, 0x78C5,\t0xDBB7, 0x7D21, 0xDBB8, 0x80AA, 0xDBB9, 0x8180, 0xDBBA, 0x822B,\r\n\t0xDBBB, 0x82B3, 0xDBBC, 0x84A1, 0xDBBD, 0x868C, 0xDBBE, 0x8A2A,\t0xDBBF, 0x8B17, 0xDBC0, 0x90A6, 0xDBC1, 0x9632, 0xDBC2, 0x9F90,\r\n\t0xDBC3, 0x500D, 0xDBC4, 0x4FF3, 0xDBC5, 0xF963, 0xDBC6, 0x57F9,\t0xDBC7, 0x5F98, 0xDBC8, 0x62DC, 0xDBC9, 0x6392, 0xDBCA, 0x676F,\r\n\t0xDBCB, 0x6E43, 0xDBCC, 0x7119, 0xDBCD, 0x76C3, 0xDBCE, 0x80CC,\t0xDBCF, 0x80DA, 0xDBD0, 0x88F4, 0xDBD1, 0x88F5, 0xDBD2, 0x8919,\r\n\t0xDBD3, 0x8CE0, 0xDBD4, 0x8F29, 0xDBD5, 0x914D, 0xDBD6, 0x966A,\t0xDBD7, 0x4F2F, 0xDBD8, 0x4F70, 0xDBD9, 0x5E1B, 0xDBDA, 0x67CF,\r\n\t0xDBDB, 0x6822, 0xDBDC, 0x767D, 0xDBDD, 0x767E, 0xDBDE, 0x9B44,\t0xDBDF, 0x5E61, 0xDBE0, 0x6A0A, 0xDBE1, 0x7169, 0xDBE2, 0x71D4,\r\n\t0xDBE3, 0x756A, 0xDBE4, 0xF964, 0xDBE5, 0x7E41, 0xDBE6, 0x8543,\t0xDBE7, 0x85E9, 0xDBE8, 0x98DC, 0xDBE9, 0x4F10, 0xDBEA, 0x7B4F,\r\n\t0xDBEB, 0x7F70, 0xDBEC, 0x95A5, 0xDBED, 0x51E1, 0xDBEE, 0x5E06,\t0xDBEF, 0x68B5, 0xDBF0, 0x6C3E, 0xDBF1, 0x6C4E, 0xDBF2, 0x6CDB,\r\n\t0xDBF3, 0x72AF, 0xDBF4, 0x7BC4, 0xDBF5, 0x8303, 0xDBF6, 0x6CD5,\t0xDBF7, 0x743A, 0xDBF8, 0x50FB, 0xDBF9, 0x5288, 0xDBFA, 0x58C1,\r\n\t0xDBFB, 0x64D8, 0xDBFC, 0x6A97, 0xDBFD, 0x74A7, 0xDBFE, 0x7656,\t0xDCA1, 0x78A7, 0xDCA2, 0x8617, 0xDCA3, 0x95E2, 0xDCA4, 0x9739,\r\n\t0xDCA5, 0xF965, 0xDCA6, 0x535E, 0xDCA7, 0x5F01, 0xDCA8, 0x8B8A,\t0xDCA9, 0x8FA8, 0xDCAA, 0x8FAF, 0xDCAB, 0x908A, 0xDCAC, 0x5225,\r\n\t0xDCAD, 0x77A5, 0xDCAE, 0x9C49, 0xDCAF, 0x9F08, 0xDCB0, 0x4E19,\t0xDCB1, 0x5002, 0xDCB2, 0x5175, 0xDCB3, 0x5C5B, 0xDCB4, 0x5E77,\r\n\t0xDCB5, 0x661E, 0xDCB6, 0x663A, 0xDCB7, 0x67C4, 0xDCB8, 0x68C5,\t0xDCB9, 0x70B3, 0xDCBA, 0x7501, 0xDCBB, 0x75C5, 0xDCBC, 0x79C9,\r\n\t0xDCBD, 0x7ADD, 0xDCBE, 0x8F27, 0xDCBF, 0x9920, 0xDCC0, 0x9A08,\t0xDCC1, 0x4FDD, 0xDCC2, 0x5821, 0xDCC3, 0x5831, 0xDCC4, 0x5BF6,\r\n\t0xDCC5, 0x666E, 0xDCC6, 0x6B65, 0xDCC7, 0x6D11, 0xDCC8, 0x6E7A,\t0xDCC9, 0x6F7D, 0xDCCA, 0x73E4, 0xDCCB, 0x752B, 0xDCCC, 0x83E9,\r\n\t0xDCCD, 0x88DC, 0xDCCE, 0x8913, 0xDCCF, 0x8B5C, 0xDCD0, 0x8F14,\t0xDCD1, 0x4F0F, 0xDCD2, 0x50D5, 0xDCD3, 0x5310, 0xDCD4, 0x535C,\r\n\t0xDCD5, 0x5B93, 0xDCD6, 0x5FA9, 0xDCD7, 0x670D, 0xDCD8, 0x798F,\t0xDCD9, 0x8179, 0xDCDA, 0x832F, 0xDCDB, 0x8514, 0xDCDC, 0x8907,\r\n\t0xDCDD, 0x8986, 0xDCDE, 0x8F39, 0xDCDF, 0x8F3B, 0xDCE0, 0x99A5,\t0xDCE1, 0x9C12, 0xDCE2, 0x672C, 0xDCE3, 0x4E76, 0xDCE4, 0x4FF8,\r\n\t0xDCE5, 0x5949, 0xDCE6, 0x5C01, 0xDCE7, 0x5CEF, 0xDCE8, 0x5CF0,\t0xDCE9, 0x6367, 0xDCEA, 0x68D2, 0xDCEB, 0x70FD, 0xDCEC, 0x71A2,\r\n\t0xDCED, 0x742B, 0xDCEE, 0x7E2B, 0xDCEF, 0x84EC, 0xDCF0, 0x8702,\t0xDCF1, 0x9022, 0xDCF2, 0x92D2, 0xDCF3, 0x9CF3, 0xDCF4, 0x4E0D,\r\n\t0xDCF5, 0x4ED8, 0xDCF6, 0x4FEF, 0xDCF7, 0x5085, 0xDCF8, 0x5256,\t0xDCF9, 0x526F, 0xDCFA, 0x5426, 0xDCFB, 0x5490, 0xDCFC, 0x57E0,\r\n\t0xDCFD, 0x592B, 0xDCFE, 0x5A66, 0xDDA1, 0x5B5A, 0xDDA2, 0x5B75,\t0xDDA3, 0x5BCC, 0xDDA4, 0x5E9C, 0xDDA5, 0xF966, 0xDDA6, 0x6276,\r\n\t0xDDA7, 0x6577, 0xDDA8, 0x65A7, 0xDDA9, 0x6D6E, 0xDDAA, 0x6EA5,\t0xDDAB, 0x7236, 0xDDAC, 0x7B26, 0xDDAD, 0x7C3F, 0xDDAE, 0x7F36,\r\n\t0xDDAF, 0x8150, 0xDDB0, 0x8151, 0xDDB1, 0x819A, 0xDDB2, 0x8240,\t0xDDB3, 0x8299, 0xDDB4, 0x83A9, 0xDDB5, 0x8A03, 0xDDB6, 0x8CA0,\r\n\t0xDDB7, 0x8CE6, 0xDDB8, 0x8CFB, 0xDDB9, 0x8D74, 0xDDBA, 0x8DBA,\t0xDDBB, 0x90E8, 0xDDBC, 0x91DC, 0xDDBD, 0x961C, 0xDDBE, 0x9644,\r\n\t0xDDBF, 0x99D9, 0xDDC0, 0x9CE7, 0xDDC1, 0x5317, 0xDDC2, 0x5206,\t0xDDC3, 0x5429, 0xDDC4, 0x5674, 0xDDC5, 0x58B3, 0xDDC6, 0x5954,\r\n\t0xDDC7, 0x596E, 0xDDC8, 0x5FFF, 0xDDC9, 0x61A4, 0xDDCA, 0x626E,\t0xDDCB, 0x6610, 0xDDCC, 0x6C7E, 0xDDCD, 0x711A, 0xDDCE, 0x76C6,\r\n\t0xDDCF, 0x7C89, 0xDDD0, 0x7CDE, 0xDDD1, 0x7D1B, 0xDDD2, 0x82AC,\t0xDDD3, 0x8CC1, 0xDDD4, 0x96F0, 0xDDD5, 0xF967, 0xDDD6, 0x4F5B,\r\n\t0xDDD7, 0x5F17, 0xDDD8, 0x5F7F, 0xDDD9, 0x62C2, 0xDDDA, 0x5D29,\t0xDDDB, 0x670B, 0xDDDC, 0x68DA, 0xDDDD, 0x787C, 0xDDDE, 0x7E43,\r\n\t0xDDDF, 0x9D6C, 0xDDE0, 0x4E15, 0xDDE1, 0x5099, 0xDDE2, 0x5315,\t0xDDE3, 0x532A, 0xDDE4, 0x5351, 0xDDE5, 0x5983, 0xDDE6, 0x5A62,\r\n\t0xDDE7, 0x5E87, 0xDDE8, 0x60B2, 0xDDE9, 0x618A, 0xDDEA, 0x6249,\t0xDDEB, 0x6279, 0xDDEC, 0x6590, 0xDDED, 0x6787, 0xDDEE, 0x69A7,\r\n\t0xDDEF, 0x6BD4, 0xDDF0, 0x6BD6, 0xDDF1, 0x6BD7, 0xDDF2, 0x6BD8,\t0xDDF3, 0x6CB8, 0xDDF4, 0xF968, 0xDDF5, 0x7435, 0xDDF6, 0x75FA,\r\n\t0xDDF7, 0x7812, 0xDDF8, 0x7891, 0xDDF9, 0x79D5, 0xDDFA, 0x79D8,\t0xDDFB, 0x7C83, 0xDDFC, 0x7DCB, 0xDDFD, 0x7FE1, 0xDDFE, 0x80A5,\r\n\t0xDEA1, 0x813E, 0xDEA2, 0x81C2, 0xDEA3, 0x83F2, 0xDEA4, 0x871A,\t0xDEA5, 0x88E8, 0xDEA6, 0x8AB9, 0xDEA7, 0x8B6C, 0xDEA8, 0x8CBB,\r\n\t0xDEA9, 0x9119, 0xDEAA, 0x975E, 0xDEAB, 0x98DB, 0xDEAC, 0x9F3B,\t0xDEAD, 0x56AC, 0xDEAE, 0x5B2A, 0xDEAF, 0x5F6C, 0xDEB0, 0x658C,\r\n\t0xDEB1, 0x6AB3, 0xDEB2, 0x6BAF, 0xDEB3, 0x6D5C, 0xDEB4, 0x6FF1,\t0xDEB5, 0x7015, 0xDEB6, 0x725D, 0xDEB7, 0x73AD, 0xDEB8, 0x8CA7,\r\n\t0xDEB9, 0x8CD3, 0xDEBA, 0x983B, 0xDEBB, 0x6191, 0xDEBC, 0x6C37,\t0xDEBD, 0x8058, 0xDEBE, 0x9A01, 0xDEBF, 0x4E4D, 0xDEC0, 0x4E8B,\r\n\t0xDEC1, 0x4E9B, 0xDEC2, 0x4ED5, 0xDEC3, 0x4F3A, 0xDEC4, 0x4F3C,\t0xDEC5, 0x4F7F, 0xDEC6, 0x4FDF, 0xDEC7, 0x50FF, 0xDEC8, 0x53F2,\r\n\t0xDEC9, 0x53F8, 0xDECA, 0x5506, 0xDECB, 0x55E3, 0xDECC, 0x56DB,\t0xDECD, 0x58EB, 0xDECE, 0x5962, 0xDECF, 0x5A11, 0xDED0, 0x5BEB,\r\n\t0xDED1, 0x5BFA, 0xDED2, 0x5C04, 0xDED3, 0x5DF3, 0xDED4, 0x5E2B,\t0xDED5, 0x5F99, 0xDED6, 0x601D, 0xDED7, 0x6368, 0xDED8, 0x659C,\r\n\t0xDED9, 0x65AF, 0xDEDA, 0x67F6, 0xDEDB, 0x67FB, 0xDEDC, 0x68AD,\t0xDEDD, 0x6B7B, 0xDEDE, 0x6C99, 0xDEDF, 0x6CD7, 0xDEE0, 0x6E23,\r\n\t0xDEE1, 0x7009, 0xDEE2, 0x7345, 0xDEE3, 0x7802, 0xDEE4, 0x793E,\t0xDEE5, 0x7940, 0xDEE6, 0x7960, 0xDEE7, 0x79C1, 0xDEE8, 0x7BE9,\r\n\t0xDEE9, 0x7D17, 0xDEEA, 0x7D72, 0xDEEB, 0x8086, 0xDEEC, 0x820D,\t0xDEED, 0x838E, 0xDEEE, 0x84D1, 0xDEEF, 0x86C7, 0xDEF0, 0x88DF,\r\n\t0xDEF1, 0x8A50, 0xDEF2, 0x8A5E, 0xDEF3, 0x8B1D, 0xDEF4, 0x8CDC,\t0xDEF5, 0x8D66, 0xDEF6, 0x8FAD, 0xDEF7, 0x90AA, 0xDEF8, 0x98FC,\r\n\t0xDEF9, 0x99DF, 0xDEFA, 0x9E9D, 0xDEFB, 0x524A, 0xDEFC, 0xF969,\t0xDEFD, 0x6714, 0xDEFE, 0xF96A, 0xDFA1, 0x5098, 0xDFA2, 0x522A,\r\n\t0xDFA3, 0x5C71, 0xDFA4, 0x6563, 0xDFA5, 0x6C55, 0xDFA6, 0x73CA,\t0xDFA7, 0x7523, 0xDFA8, 0x759D, 0xDFA9, 0x7B97, 0xDFAA, 0x849C,\r\n\t0xDFAB, 0x9178, 0xDFAC, 0x9730, 0xDFAD, 0x4E77, 0xDFAE, 0x6492,\t0xDFAF, 0x6BBA, 0xDFB0, 0x715E, 0xDFB1, 0x85A9, 0xDFB2, 0x4E09,\r\n\t0xDFB3, 0xF96B, 0xDFB4, 0x6749, 0xDFB5, 0x68EE, 0xDFB6, 0x6E17,\t0xDFB7, 0x829F, 0xDFB8, 0x8518, 0xDFB9, 0x886B, 0xDFBA, 0x63F7,\r\n\t0xDFBB, 0x6F81, 0xDFBC, 0x9212, 0xDFBD, 0x98AF, 0xDFBE, 0x4E0A,\t0xDFBF, 0x50B7, 0xDFC0, 0x50CF, 0xDFC1, 0x511F, 0xDFC2, 0x5546,\r\n\t0xDFC3, 0x55AA, 0xDFC4, 0x5617, 0xDFC5, 0x5B40, 0xDFC6, 0x5C19,\t0xDFC7, 0x5CE0, 0xDFC8, 0x5E38, 0xDFC9, 0x5E8A, 0xDFCA, 0x5EA0,\r\n\t0xDFCB, 0x5EC2, 0xDFCC, 0x60F3, 0xDFCD, 0x6851, 0xDFCE, 0x6A61,\t0xDFCF, 0x6E58, 0xDFD0, 0x723D, 0xDFD1, 0x7240, 0xDFD2, 0x72C0,\r\n\t0xDFD3, 0x76F8, 0xDFD4, 0x7965, 0xDFD5, 0x7BB1, 0xDFD6, 0x7FD4,\t0xDFD7, 0x88F3, 0xDFD8, 0x89F4, 0xDFD9, 0x8A73, 0xDFDA, 0x8C61,\r\n\t0xDFDB, 0x8CDE, 0xDFDC, 0x971C, 0xDFDD, 0x585E, 0xDFDE, 0x74BD,\t0xDFDF, 0x8CFD, 0xDFE0, 0x55C7, 0xDFE1, 0xF96C, 0xDFE2, 0x7A61,\r\n\t0xDFE3, 0x7D22, 0xDFE4, 0x8272, 0xDFE5, 0x7272, 0xDFE6, 0x751F,\t0xDFE7, 0x7525, 0xDFE8, 0xF96D, 0xDFE9, 0x7B19, 0xDFEA, 0x5885,\r\n\t0xDFEB, 0x58FB, 0xDFEC, 0x5DBC, 0xDFED, 0x5E8F, 0xDFEE, 0x5EB6,\t0xDFEF, 0x5F90, 0xDFF0, 0x6055, 0xDFF1, 0x6292, 0xDFF2, 0x637F,\r\n\t0xDFF3, 0x654D, 0xDFF4, 0x6691, 0xDFF5, 0x66D9, 0xDFF6, 0x66F8,\t0xDFF7, 0x6816, 0xDFF8, 0x68F2, 0xDFF9, 0x7280, 0xDFFA, 0x745E,\r\n\t0xDFFB, 0x7B6E, 0xDFFC, 0x7D6E, 0xDFFD, 0x7DD6, 0xDFFE, 0x7F72,\t0xE0A1, 0x80E5, 0xE0A2, 0x8212, 0xE0A3, 0x85AF, 0xE0A4, 0x897F,\r\n\t0xE0A5, 0x8A93, 0xE0A6, 0x901D, 0xE0A7, 0x92E4, 0xE0A8, 0x9ECD,\t0xE0A9, 0x9F20, 0xE0AA, 0x5915, 0xE0AB, 0x596D, 0xE0AC, 0x5E2D,\r\n\t0xE0AD, 0x60DC, 0xE0AE, 0x6614, 0xE0AF, 0x6673, 0xE0B0, 0x6790,\t0xE0B1, 0x6C50, 0xE0B2, 0x6DC5, 0xE0B3, 0x6F5F, 0xE0B4, 0x77F3,\r\n\t0xE0B5, 0x78A9, 0xE0B6, 0x84C6, 0xE0B7, 0x91CB, 0xE0B8, 0x932B,\t0xE0B9, 0x4ED9, 0xE0BA, 0x50CA, 0xE0BB, 0x5148, 0xE0BC, 0x5584,\r\n\t0xE0BD, 0x5B0B, 0xE0BE, 0x5BA3, 0xE0BF, 0x6247, 0xE0C0, 0x657E,\t0xE0C1, 0x65CB, 0xE0C2, 0x6E32, 0xE0C3, 0x717D, 0xE0C4, 0x7401,\r\n\t0xE0C5, 0x7444, 0xE0C6, 0x7487, 0xE0C7, 0x74BF, 0xE0C8, 0x766C,\t0xE0C9, 0x79AA, 0xE0CA, 0x7DDA, 0xE0CB, 0x7E55, 0xE0CC, 0x7FA8,\r\n\t0xE0CD, 0x817A, 0xE0CE, 0x81B3, 0xE0CF, 0x8239, 0xE0D0, 0x861A,\t0xE0D1, 0x87EC, 0xE0D2, 0x8A75, 0xE0D3, 0x8DE3, 0xE0D4, 0x9078,\r\n\t0xE0D5, 0x9291, 0xE0D6, 0x9425, 0xE0D7, 0x994D, 0xE0D8, 0x9BAE,\t0xE0D9, 0x5368, 0xE0DA, 0x5C51, 0xE0DB, 0x6954, 0xE0DC, 0x6CC4,\r\n\t0xE0DD, 0x6D29, 0xE0DE, 0x6E2B, 0xE0DF, 0x820C, 0xE0E0, 0x859B,\t0xE0E1, 0x893B, 0xE0E2, 0x8A2D, 0xE0E3, 0x8AAA, 0xE0E4, 0x96EA,\r\n\t0xE0E5, 0x9F67, 0xE0E6, 0x5261, 0xE0E7, 0x66B9, 0xE0E8, 0x6BB2,\t0xE0E9, 0x7E96, 0xE0EA, 0x87FE, 0xE0EB, 0x8D0D, 0xE0EC, 0x9583,\r\n\t0xE0ED, 0x965D, 0xE0EE, 0x651D, 0xE0EF, 0x6D89, 0xE0F0, 0x71EE,\t0xE0F1, 0xF96E, 0xE0F2, 0x57CE, 0xE0F3, 0x59D3, 0xE0F4, 0x5BAC,\r\n\t0xE0F5, 0x6027, 0xE0F6, 0x60FA, 0xE0F7, 0x6210, 0xE0F8, 0x661F,\t0xE0F9, 0x665F, 0xE0FA, 0x7329, 0xE0FB, 0x73F9, 0xE0FC, 0x76DB,\r\n\t0xE0FD, 0x7701, 0xE0FE, 0x7B6C, 0xE1A1, 0x8056, 0xE1A2, 0x8072,\t0xE1A3, 0x8165, 0xE1A4, 0x8AA0, 0xE1A5, 0x9192, 0xE1A6, 0x4E16,\r\n\t0xE1A7, 0x52E2, 0xE1A8, 0x6B72, 0xE1A9, 0x6D17, 0xE1AA, 0x7A05,\t0xE1AB, 0x7B39, 0xE1AC, 0x7D30, 0xE1AD, 0xF96F, 0xE1AE, 0x8CB0,\r\n\t0xE1AF, 0x53EC, 0xE1B0, 0x562F, 0xE1B1, 0x5851, 0xE1B2, 0x5BB5,\t0xE1B3, 0x5C0F, 0xE1B4, 0x5C11, 0xE1B5, 0x5DE2, 0xE1B6, 0x6240,\r\n\t0xE1B7, 0x6383, 0xE1B8, 0x6414, 0xE1B9, 0x662D, 0xE1BA, 0x68B3,\t0xE1BB, 0x6CBC, 0xE1BC, 0x6D88, 0xE1BD, 0x6EAF, 0xE1BE, 0x701F,\r\n\t0xE1BF, 0x70A4, 0xE1C0, 0x71D2, 0xE1C1, 0x7526, 0xE1C2, 0x758F,\t0xE1C3, 0x758E, 0xE1C4, 0x7619, 0xE1C5, 0x7B11, 0xE1C6, 0x7BE0,\r\n\t0xE1C7, 0x7C2B, 0xE1C8, 0x7D20, 0xE1C9, 0x7D39, 0xE1CA, 0x852C,\t0xE1CB, 0x856D, 0xE1CC, 0x8607, 0xE1CD, 0x8A34, 0xE1CE, 0x900D,\r\n\t0xE1CF, 0x9061, 0xE1D0, 0x90B5, 0xE1D1, 0x92B7, 0xE1D2, 0x97F6,\t0xE1D3, 0x9A37, 0xE1D4, 0x4FD7, 0xE1D5, 0x5C6C, 0xE1D6, 0x675F,\r\n\t0xE1D7, 0x6D91, 0xE1D8, 0x7C9F, 0xE1D9, 0x7E8C, 0xE1DA, 0x8B16,\t0xE1DB, 0x8D16, 0xE1DC, 0x901F, 0xE1DD, 0x5B6B, 0xE1DE, 0x5DFD,\r\n\t0xE1DF, 0x640D, 0xE1E0, 0x84C0, 0xE1E1, 0x905C, 0xE1E2, 0x98E1,\t0xE1E3, 0x7387, 0xE1E4, 0x5B8B, 0xE1E5, 0x609A, 0xE1E6, 0x677E,\r\n\t0xE1E7, 0x6DDE, 0xE1E8, 0x8A1F, 0xE1E9, 0x8AA6, 0xE1EA, 0x9001,\t0xE1EB, 0x980C, 0xE1EC, 0x5237, 0xE1ED, 0xF970, 0xE1EE, 0x7051,\r\n\t0xE1EF, 0x788E, 0xE1F0, 0x9396, 0xE1F1, 0x8870, 0xE1F2, 0x91D7,\t0xE1F3, 0x4FEE, 0xE1F4, 0x53D7, 0xE1F5, 0x55FD, 0xE1F6, 0x56DA,\r\n\t0xE1F7, 0x5782, 0xE1F8, 0x58FD, 0xE1F9, 0x5AC2, 0xE1FA, 0x5B88,\t0xE1FB, 0x5CAB, 0xE1FC, 0x5CC0, 0xE1FD, 0x5E25, 0xE1FE, 0x6101,\r\n\t0xE2A1, 0x620D, 0xE2A2, 0x624B, 0xE2A3, 0x6388, 0xE2A4, 0x641C,\t0xE2A5, 0x6536, 0xE2A6, 0x6578, 0xE2A7, 0x6A39, 0xE2A8, 0x6B8A,\r\n\t0xE2A9, 0x6C34, 0xE2AA, 0x6D19, 0xE2AB, 0x6F31, 0xE2AC, 0x71E7,\t0xE2AD, 0x72E9, 0xE2AE, 0x7378, 0xE2AF, 0x7407, 0xE2B0, 0x74B2,\r\n\t0xE2B1, 0x7626, 0xE2B2, 0x7761, 0xE2B3, 0x79C0, 0xE2B4, 0x7A57,\t0xE2B5, 0x7AEA, 0xE2B6, 0x7CB9, 0xE2B7, 0x7D8F, 0xE2B8, 0x7DAC,\r\n\t0xE2B9, 0x7E61, 0xE2BA, 0x7F9E, 0xE2BB, 0x8129, 0xE2BC, 0x8331,\t0xE2BD, 0x8490, 0xE2BE, 0x84DA, 0xE2BF, 0x85EA, 0xE2C0, 0x8896,\r\n\t0xE2C1, 0x8AB0, 0xE2C2, 0x8B90, 0xE2C3, 0x8F38, 0xE2C4, 0x9042,\t0xE2C5, 0x9083, 0xE2C6, 0x916C, 0xE2C7, 0x9296, 0xE2C8, 0x92B9,\r\n\t0xE2C9, 0x968B, 0xE2CA, 0x96A7, 0xE2CB, 0x96A8, 0xE2CC, 0x96D6,\t0xE2CD, 0x9700, 0xE2CE, 0x9808, 0xE2CF, 0x9996, 0xE2D0, 0x9AD3,\r\n\t0xE2D1, 0x9B1A, 0xE2D2, 0x53D4, 0xE2D3, 0x587E, 0xE2D4, 0x5919,\t0xE2D5, 0x5B70, 0xE2D6, 0x5BBF, 0xE2D7, 0x6DD1, 0xE2D8, 0x6F5A,\r\n\t0xE2D9, 0x719F, 0xE2DA, 0x7421, 0xE2DB, 0x74B9, 0xE2DC, 0x8085,\t0xE2DD, 0x83FD, 0xE2DE, 0x5DE1, 0xE2DF, 0x5F87, 0xE2E0, 0x5FAA,\r\n\t0xE2E1, 0x6042, 0xE2E2, 0x65EC, 0xE2E3, 0x6812, 0xE2E4, 0x696F,\t0xE2E5, 0x6A53, 0xE2E6, 0x6B89, 0xE2E7, 0x6D35, 0xE2E8, 0x6DF3,\r\n\t0xE2E9, 0x73E3, 0xE2EA, 0x76FE, 0xE2EB, 0x77AC, 0xE2EC, 0x7B4D,\t0xE2ED, 0x7D14, 0xE2EE, 0x8123, 0xE2EF, 0x821C, 0xE2F0, 0x8340,\r\n\t0xE2F1, 0x84F4, 0xE2F2, 0x8563, 0xE2F3, 0x8A62, 0xE2F4, 0x8AC4,\t0xE2F5, 0x9187, 0xE2F6, 0x931E, 0xE2F7, 0x9806, 0xE2F8, 0x99B4,\r\n\t0xE2F9, 0x620C, 0xE2FA, 0x8853, 0xE2FB, 0x8FF0, 0xE2FC, 0x9265,\t0xE2FD, 0x5D07, 0xE2FE, 0x5D27, 0xE3A1, 0x5D69, 0xE3A2, 0x745F,\r\n\t0xE3A3, 0x819D, 0xE3A4, 0x8768, 0xE3A5, 0x6FD5, 0xE3A6, 0x62FE,\t0xE3A7, 0x7FD2, 0xE3A8, 0x8936, 0xE3A9, 0x8972, 0xE3AA, 0x4E1E,\r\n\t0xE3AB, 0x4E58, 0xE3AC, 0x50E7, 0xE3AD, 0x52DD, 0xE3AE, 0x5347,\t0xE3AF, 0x627F, 0xE3B0, 0x6607, 0xE3B1, 0x7E69, 0xE3B2, 0x8805,\r\n\t0xE3B3, 0x965E, 0xE3B4, 0x4F8D, 0xE3B5, 0x5319, 0xE3B6, 0x5636,\t0xE3B7, 0x59CB, 0xE3B8, 0x5AA4, 0xE3B9, 0x5C38, 0xE3BA, 0x5C4E,\r\n\t0xE3BB, 0x5C4D, 0xE3BC, 0x5E02, 0xE3BD, 0x5F11, 0xE3BE, 0x6043,\t0xE3BF, 0x65BD, 0xE3C0, 0x662F, 0xE3C1, 0x6642, 0xE3C2, 0x67BE,\r\n\t0xE3C3, 0x67F4, 0xE3C4, 0x731C, 0xE3C5, 0x77E2, 0xE3C6, 0x793A,\t0xE3C7, 0x7FC5, 0xE3C8, 0x8494, 0xE3C9, 0x84CD, 0xE3CA, 0x8996,\r\n\t0xE3CB, 0x8A66, 0xE3CC, 0x8A69, 0xE3CD, 0x8AE1, 0xE3CE, 0x8C55,\t0xE3CF, 0x8C7A, 0xE3D0, 0x57F4, 0xE3D1, 0x5BD4, 0xE3D2, 0x5F0F,\r\n\t0xE3D3, 0x606F, 0xE3D4, 0x62ED, 0xE3D5, 0x690D, 0xE3D6, 0x6B96,\t0xE3D7, 0x6E5C, 0xE3D8, 0x7184, 0xE3D9, 0x7BD2, 0xE3DA, 0x8755,\r\n\t0xE3DB, 0x8B58, 0xE3DC, 0x8EFE, 0xE3DD, 0x98DF, 0xE3DE, 0x98FE,\t0xE3DF, 0x4F38, 0xE3E0, 0x4F81, 0xE3E1, 0x4FE1, 0xE3E2, 0x547B,\r\n\t0xE3E3, 0x5A20, 0xE3E4, 0x5BB8, 0xE3E5, 0x613C, 0xE3E6, 0x65B0,\t0xE3E7, 0x6668, 0xE3E8, 0x71FC, 0xE3E9, 0x7533, 0xE3EA, 0x795E,\r\n\t0xE3EB, 0x7D33, 0xE3EC, 0x814E, 0xE3ED, 0x81E3, 0xE3EE, 0x8398,\t0xE3EF, 0x85AA, 0xE3F0, 0x85CE, 0xE3F1, 0x8703, 0xE3F2, 0x8A0A,\r\n\t0xE3F3, 0x8EAB, 0xE3F4, 0x8F9B, 0xE3F5, 0xF971, 0xE3F6, 0x8FC5,\t0xE3F7, 0x5931, 0xE3F8, 0x5BA4, 0xE3F9, 0x5BE6, 0xE3FA, 0x6089,\r\n\t0xE3FB, 0x5BE9, 0xE3FC, 0x5C0B, 0xE3FD, 0x5FC3, 0xE3FE, 0x6C81,\t0xE4A1, 0xF972, 0xE4A2, 0x6DF1, 0xE4A3, 0x700B, 0xE4A4, 0x751A,\r\n\t0xE4A5, 0x82AF, 0xE4A6, 0x8AF6, 0xE4A7, 0x4EC0, 0xE4A8, 0x5341,\t0xE4A9, 0xF973, 0xE4AA, 0x96D9, 0xE4AB, 0x6C0F, 0xE4AC, 0x4E9E,\r\n\t0xE4AD, 0x4FC4, 0xE4AE, 0x5152, 0xE4AF, 0x555E, 0xE4B0, 0x5A25,\t0xE4B1, 0x5CE8, 0xE4B2, 0x6211, 0xE4B3, 0x7259, 0xE4B4, 0x82BD,\r\n\t0xE4B5, 0x83AA, 0xE4B6, 0x86FE, 0xE4B7, 0x8859, 0xE4B8, 0x8A1D,\t0xE4B9, 0x963F, 0xE4BA, 0x96C5, 0xE4BB, 0x9913, 0xE4BC, 0x9D09,\r\n\t0xE4BD, 0x9D5D, 0xE4BE, 0x580A, 0xE4BF, 0x5CB3, 0xE4C0, 0x5DBD,\t0xE4C1, 0x5E44, 0xE4C2, 0x60E1, 0xE4C3, 0x6115, 0xE4C4, 0x63E1,\r\n\t0xE4C5, 0x6A02, 0xE4C6, 0x6E25, 0xE4C7, 0x9102, 0xE4C8, 0x9354,\t0xE4C9, 0x984E, 0xE4CA, 0x9C10, 0xE4CB, 0x9F77, 0xE4CC, 0x5B89,\r\n\t0xE4CD, 0x5CB8, 0xE4CE, 0x6309, 0xE4CF, 0x664F, 0xE4D0, 0x6848,\t0xE4D1, 0x773C, 0xE4D2, 0x96C1, 0xE4D3, 0x978D, 0xE4D4, 0x9854,\r\n\t0xE4D5, 0x9B9F, 0xE4D6, 0x65A1, 0xE4D7, 0x8B01, 0xE4D8, 0x8ECB,\t0xE4D9, 0x95BC, 0xE4DA, 0x5535, 0xE4DB, 0x5CA9, 0xE4DC, 0x5DD6,\r\n\t0xE4DD, 0x5EB5, 0xE4DE, 0x6697, 0xE4DF, 0x764C, 0xE4E0, 0x83F4,\t0xE4E1, 0x95C7, 0xE4E2, 0x58D3, 0xE4E3, 0x62BC, 0xE4E4, 0x72CE,\r\n\t0xE4E5, 0x9D28, 0xE4E6, 0x4EF0, 0xE4E7, 0x592E, 0xE4E8, 0x600F,\t0xE4E9, 0x663B, 0xE4EA, 0x6B83, 0xE4EB, 0x79E7, 0xE4EC, 0x9D26,\r\n\t0xE4ED, 0x5393, 0xE4EE, 0x54C0, 0xE4EF, 0x57C3, 0xE4F0, 0x5D16,\t0xE4F1, 0x611B, 0xE4F2, 0x66D6, 0xE4F3, 0x6DAF, 0xE4F4, 0x788D,\r\n\t0xE4F5, 0x827E, 0xE4F6, 0x9698, 0xE4F7, 0x9744, 0xE4F8, 0x5384,\t0xE4F9, 0x627C, 0xE4FA, 0x6396, 0xE4FB, 0x6DB2, 0xE4FC, 0x7E0A,\r\n\t0xE4FD, 0x814B, 0xE4FE, 0x984D, 0xE5A1, 0x6AFB, 0xE5A2, 0x7F4C,\t0xE5A3, 0x9DAF, 0xE5A4, 0x9E1A, 0xE5A5, 0x4E5F, 0xE5A6, 0x503B,\r\n\t0xE5A7, 0x51B6, 0xE5A8, 0x591C, 0xE5A9, 0x60F9, 0xE5AA, 0x63F6,\t0xE5AB, 0x6930, 0xE5AC, 0x723A, 0xE5AD, 0x8036, 0xE5AE, 0xF974,\r\n\t0xE5AF, 0x91CE, 0xE5B0, 0x5F31, 0xE5B1, 0xF975, 0xE5B2, 0xF976,\t0xE5B3, 0x7D04, 0xE5B4, 0x82E5, 0xE5B5, 0x846F, 0xE5B6, 0x84BB,\r\n\t0xE5B7, 0x85E5, 0xE5B8, 0x8E8D, 0xE5B9, 0xF977, 0xE5BA, 0x4F6F,\t0xE5BB, 0xF978, 0xE5BC, 0xF979, 0xE5BD, 0x58E4, 0xE5BE, 0x5B43,\r\n\t0xE5BF, 0x6059, 0xE5C0, 0x63DA, 0xE5C1, 0x6518, 0xE5C2, 0x656D,\t0xE5C3, 0x6698, 0xE5C4, 0xF97A, 0xE5C5, 0x694A, 0xE5C6, 0x6A23,\r\n\t0xE5C7, 0x6D0B, 0xE5C8, 0x7001, 0xE5C9, 0x716C, 0xE5CA, 0x75D2,\t0xE5CB, 0x760D, 0xE5CC, 0x79B3, 0xE5CD, 0x7A70, 0xE5CE, 0xF97B,\r\n\t0xE5CF, 0x7F8A, 0xE5D0, 0xF97C, 0xE5D1, 0x8944, 0xE5D2, 0xF97D,\t0xE5D3, 0x8B93, 0xE5D4, 0x91C0, 0xE5D5, 0x967D, 0xE5D6, 0xF97E,\r\n\t0xE5D7, 0x990A, 0xE5D8, 0x5704, 0xE5D9, 0x5FA1, 0xE5DA, 0x65BC,\t0xE5DB, 0x6F01, 0xE5DC, 0x7600, 0xE5DD, 0x79A6, 0xE5DE, 0x8A9E,\r\n\t0xE5DF, 0x99AD, 0xE5E0, 0x9B5A, 0xE5E1, 0x9F6C, 0xE5E2, 0x5104,\t0xE5E3, 0x61B6, 0xE5E4, 0x6291, 0xE5E5, 0x6A8D, 0xE5E6, 0x81C6,\r\n\t0xE5E7, 0x5043, 0xE5E8, 0x5830, 0xE5E9, 0x5F66, 0xE5EA, 0x7109,\t0xE5EB, 0x8A00, 0xE5EC, 0x8AFA, 0xE5ED, 0x5B7C, 0xE5EE, 0x8616,\r\n\t0xE5EF, 0x4FFA, 0xE5F0, 0x513C, 0xE5F1, 0x56B4, 0xE5F2, 0x5944,\t0xE5F3, 0x63A9, 0xE5F4, 0x6DF9, 0xE5F5, 0x5DAA, 0xE5F6, 0x696D,\r\n\t0xE5F7, 0x5186, 0xE5F8, 0x4E88, 0xE5F9, 0x4F59, 0xE5FA, 0xF97F,\t0xE5FB, 0xF980, 0xE5FC, 0xF981, 0xE5FD, 0x5982, 0xE5FE, 0xF982,\r\n\t0xE6A1, 0xF983, 0xE6A2, 0x6B5F, 0xE6A3, 0x6C5D, 0xE6A4, 0xF984,\t0xE6A5, 0x74B5, 0xE6A6, 0x7916, 0xE6A7, 0xF985, 0xE6A8, 0x8207,\r\n\t0xE6A9, 0x8245, 0xE6AA, 0x8339, 0xE6AB, 0x8F3F, 0xE6AC, 0x8F5D,\t0xE6AD, 0xF986, 0xE6AE, 0x9918, 0xE6AF, 0xF987, 0xE6B0, 0xF988,\r\n\t0xE6B1, 0xF989, 0xE6B2, 0x4EA6, 0xE6B3, 0xF98A, 0xE6B4, 0x57DF,\t0xE6B5, 0x5F79, 0xE6B6, 0x6613, 0xE6B7, 0xF98B, 0xE6B8, 0xF98C,\r\n\t0xE6B9, 0x75AB, 0xE6BA, 0x7E79, 0xE6BB, 0x8B6F, 0xE6BC, 0xF98D,\t0xE6BD, 0x9006, 0xE6BE, 0x9A5B, 0xE6BF, 0x56A5, 0xE6C0, 0x5827,\r\n\t0xE6C1, 0x59F8, 0xE6C2, 0x5A1F, 0xE6C3, 0x5BB4, 0xE6C4, 0xF98E,\t0xE6C5, 0x5EF6, 0xE6C6, 0xF98F, 0xE6C7, 0xF990, 0xE6C8, 0x6350,\r\n\t0xE6C9, 0x633B, 0xE6CA, 0xF991, 0xE6CB, 0x693D, 0xE6CC, 0x6C87,\t0xE6CD, 0x6CBF, 0xE6CE, 0x6D8E, 0xE6CF, 0x6D93, 0xE6D0, 0x6DF5,\r\n\t0xE6D1, 0x6F14, 0xE6D2, 0xF992, 0xE6D3, 0x70DF, 0xE6D4, 0x7136,\t0xE6D5, 0x7159, 0xE6D6, 0xF993, 0xE6D7, 0x71C3, 0xE6D8, 0x71D5,\r\n\t0xE6D9, 0xF994, 0xE6DA, 0x784F, 0xE6DB, 0x786F, 0xE6DC, 0xF995,\t0xE6DD, 0x7B75, 0xE6DE, 0x7DE3, 0xE6DF, 0xF996, 0xE6E0, 0x7E2F,\r\n\t0xE6E1, 0xF997, 0xE6E2, 0x884D, 0xE6E3, 0x8EDF, 0xE6E4, 0xF998,\t0xE6E5, 0xF999, 0xE6E6, 0xF99A, 0xE6E7, 0x925B, 0xE6E8, 0xF99B,\r\n\t0xE6E9, 0x9CF6, 0xE6EA, 0xF99C, 0xE6EB, 0xF99D, 0xE6EC, 0xF99E,\t0xE6ED, 0x6085, 0xE6EE, 0x6D85, 0xE6EF, 0xF99F, 0xE6F0, 0x71B1,\r\n\t0xE6F1, 0xF9A0, 0xE6F2, 0xF9A1, 0xE6F3, 0x95B1, 0xE6F4, 0x53AD,\t0xE6F5, 0xF9A2, 0xE6F6, 0xF9A3, 0xE6F7, 0xF9A4, 0xE6F8, 0x67D3,\r\n\t0xE6F9, 0xF9A5, 0xE6FA, 0x708E, 0xE6FB, 0x7130, 0xE6FC, 0x7430,\t0xE6FD, 0x8276, 0xE6FE, 0x82D2, 0xE7A1, 0xF9A6, 0xE7A2, 0x95BB,\r\n\t0xE7A3, 0x9AE5, 0xE7A4, 0x9E7D, 0xE7A5, 0x66C4, 0xE7A6, 0xF9A7,\t0xE7A7, 0x71C1, 0xE7A8, 0x8449, 0xE7A9, 0xF9A8, 0xE7AA, 0xF9A9,\r\n\t0xE7AB, 0x584B, 0xE7AC, 0xF9AA, 0xE7AD, 0xF9AB, 0xE7AE, 0x5DB8,\t0xE7AF, 0x5F71, 0xE7B0, 0xF9AC, 0xE7B1, 0x6620, 0xE7B2, 0x668E,\r\n\t0xE7B3, 0x6979, 0xE7B4, 0x69AE, 0xE7B5, 0x6C38, 0xE7B6, 0x6CF3,\t0xE7B7, 0x6E36, 0xE7B8, 0x6F41, 0xE7B9, 0x6FDA, 0xE7BA, 0x701B,\r\n\t0xE7BB, 0x702F, 0xE7BC, 0x7150, 0xE7BD, 0x71DF, 0xE7BE, 0x7370,\t0xE7BF, 0xF9AD, 0xE7C0, 0x745B, 0xE7C1, 0xF9AE, 0xE7C2, 0x74D4,\r\n\t0xE7C3, 0x76C8, 0xE7C4, 0x7A4E, 0xE7C5, 0x7E93, 0xE7C6, 0xF9AF,\t0xE7C7, 0xF9B0, 0xE7C8, 0x82F1, 0xE7C9, 0x8A60, 0xE7CA, 0x8FCE,\r\n\t0xE7CB, 0xF9B1, 0xE7CC, 0x9348, 0xE7CD, 0xF9B2, 0xE7CE, 0x9719,\t0xE7CF, 0xF9B3, 0xE7D0, 0xF9B4, 0xE7D1, 0x4E42, 0xE7D2, 0x502A,\r\n\t0xE7D3, 0xF9B5, 0xE7D4, 0x5208, 0xE7D5, 0x53E1, 0xE7D6, 0x66F3,\t0xE7D7, 0x6C6D, 0xE7D8, 0x6FCA, 0xE7D9, 0x730A, 0xE7DA, 0x777F,\r\n\t0xE7DB, 0x7A62, 0xE7DC, 0x82AE, 0xE7DD, 0x85DD, 0xE7DE, 0x8602,\t0xE7DF, 0xF9B6, 0xE7E0, 0x88D4, 0xE7E1, 0x8A63, 0xE7E2, 0x8B7D,\r\n\t0xE7E3, 0x8C6B, 0xE7E4, 0xF9B7, 0xE7E5, 0x92B3, 0xE7E6, 0xF9B8,\t0xE7E7, 0x9713, 0xE7E8, 0x9810, 0xE7E9, 0x4E94, 0xE7EA, 0x4F0D,\r\n\t0xE7EB, 0x4FC9, 0xE7EC, 0x50B2, 0xE7ED, 0x5348, 0xE7EE, 0x543E,\t0xE7EF, 0x5433, 0xE7F0, 0x55DA, 0xE7F1, 0x5862, 0xE7F2, 0x58BA,\r\n\t0xE7F3, 0x5967, 0xE7F4, 0x5A1B, 0xE7F5, 0x5BE4, 0xE7F6, 0x609F,\t0xE7F7, 0xF9B9, 0xE7F8, 0x61CA, 0xE7F9, 0x6556, 0xE7FA, 0x65FF,\r\n\t0xE7FB, 0x6664, 0xE7FC, 0x68A7, 0xE7FD, 0x6C5A, 0xE7FE, 0x6FB3,\t0xE8A1, 0x70CF, 0xE8A2, 0x71AC, 0xE8A3, 0x7352, 0xE8A4, 0x7B7D,\r\n\t0xE8A5, 0x8708, 0xE8A6, 0x8AA4, 0xE8A7, 0x9C32, 0xE8A8, 0x9F07,\t0xE8A9, 0x5C4B, 0xE8AA, 0x6C83, 0xE8AB, 0x7344, 0xE8AC, 0x7389,\r\n\t0xE8AD, 0x923A, 0xE8AE, 0x6EAB, 0xE8AF, 0x7465, 0xE8B0, 0x761F,\t0xE8B1, 0x7A69, 0xE8B2, 0x7E15, 0xE8B3, 0x860A, 0xE8B4, 0x5140,\r\n\t0xE8B5, 0x58C5, 0xE8B6, 0x64C1, 0xE8B7, 0x74EE, 0xE8B8, 0x7515,\t0xE8B9, 0x7670, 0xE8BA, 0x7FC1, 0xE8BB, 0x9095, 0xE8BC, 0x96CD,\r\n\t0xE8BD, 0x9954, 0xE8BE, 0x6E26, 0xE8BF, 0x74E6, 0xE8C0, 0x7AA9,\t0xE8C1, 0x7AAA, 0xE8C2, 0x81E5, 0xE8C3, 0x86D9, 0xE8C4, 0x8778,\r\n\t0xE8C5, 0x8A1B, 0xE8C6, 0x5A49, 0xE8C7, 0x5B8C, 0xE8C8, 0x5B9B,\t0xE8C9, 0x68A1, 0xE8CA, 0x6900, 0xE8CB, 0x6D63, 0xE8CC, 0x73A9,\r\n\t0xE8CD, 0x7413, 0xE8CE, 0x742C, 0xE8CF, 0x7897, 0xE8D0, 0x7DE9,\t0xE8D1, 0x7FEB, 0xE8D2, 0x8118, 0xE8D3, 0x8155, 0xE8D4, 0x839E,\r\n\t0xE8D5, 0x8C4C, 0xE8D6, 0x962E, 0xE8D7, 0x9811, 0xE8D8, 0x66F0,\t0xE8D9, 0x5F80, 0xE8DA, 0x65FA, 0xE8DB, 0x6789, 0xE8DC, 0x6C6A,\r\n\t0xE8DD, 0x738B, 0xE8DE, 0x502D, 0xE8DF, 0x5A03, 0xE8E0, 0x6B6A,\t0xE8E1, 0x77EE, 0xE8E2, 0x5916, 0xE8E3, 0x5D6C, 0xE8E4, 0x5DCD,\r\n\t0xE8E5, 0x7325, 0xE8E6, 0x754F, 0xE8E7, 0xF9BA, 0xE8E8, 0xF9BB,\t0xE8E9, 0x50E5, 0xE8EA, 0x51F9, 0xE8EB, 0x582F, 0xE8EC, 0x592D,\r\n\t0xE8ED, 0x5996, 0xE8EE, 0x59DA, 0xE8EF, 0x5BE5, 0xE8F0, 0xF9BC,\t0xE8F1, 0xF9BD, 0xE8F2, 0x5DA2, 0xE8F3, 0x62D7, 0xE8F4, 0x6416,\r\n\t0xE8F5, 0x6493, 0xE8F6, 0x64FE, 0xE8F7, 0xF9BE, 0xE8F8, 0x66DC,\t0xE8F9, 0xF9BF, 0xE8FA, 0x6A48, 0xE8FB, 0xF9C0, 0xE8FC, 0x71FF,\r\n\t0xE8FD, 0x7464, 0xE8FE, 0xF9C1, 0xE9A1, 0x7A88, 0xE9A2, 0x7AAF,\t0xE9A3, 0x7E47, 0xE9A4, 0x7E5E, 0xE9A5, 0x8000, 0xE9A6, 0x8170,\r\n\t0xE9A7, 0xF9C2, 0xE9A8, 0x87EF, 0xE9A9, 0x8981, 0xE9AA, 0x8B20,\t0xE9AB, 0x9059, 0xE9AC, 0xF9C3, 0xE9AD, 0x9080, 0xE9AE, 0x9952,\r\n\t0xE9AF, 0x617E, 0xE9B0, 0x6B32, 0xE9B1, 0x6D74, 0xE9B2, 0x7E1F,\t0xE9B3, 0x8925, 0xE9B4, 0x8FB1, 0xE9B5, 0x4FD1, 0xE9B6, 0x50AD,\r\n\t0xE9B7, 0x5197, 0xE9B8, 0x52C7, 0xE9B9, 0x57C7, 0xE9BA, 0x5889,\t0xE9BB, 0x5BB9, 0xE9BC, 0x5EB8, 0xE9BD, 0x6142, 0xE9BE, 0x6995,\r\n\t0xE9BF, 0x6D8C, 0xE9C0, 0x6E67, 0xE9C1, 0x6EB6, 0xE9C2, 0x7194,\t0xE9C3, 0x7462, 0xE9C4, 0x7528, 0xE9C5, 0x752C, 0xE9C6, 0x8073,\r\n\t0xE9C7, 0x8338, 0xE9C8, 0x84C9, 0xE9C9, 0x8E0A, 0xE9CA, 0x9394,\t0xE9CB, 0x93DE, 0xE9CC, 0xF9C4, 0xE9CD, 0x4E8E, 0xE9CE, 0x4F51,\r\n\t0xE9CF, 0x5076, 0xE9D0, 0x512A, 0xE9D1, 0x53C8, 0xE9D2, 0x53CB,\t0xE9D3, 0x53F3, 0xE9D4, 0x5B87, 0xE9D5, 0x5BD3, 0xE9D6, 0x5C24,\r\n\t0xE9D7, 0x611A, 0xE9D8, 0x6182, 0xE9D9, 0x65F4, 0xE9DA, 0x725B,\t0xE9DB, 0x7397, 0xE9DC, 0x7440, 0xE9DD, 0x76C2, 0xE9DE, 0x7950,\r\n\t0xE9DF, 0x7991, 0xE9E0, 0x79B9, 0xE9E1, 0x7D06, 0xE9E2, 0x7FBD,\t0xE9E3, 0x828B, 0xE9E4, 0x85D5, 0xE9E5, 0x865E, 0xE9E6, 0x8FC2,\r\n\t0xE9E7, 0x9047, 0xE9E8, 0x90F5, 0xE9E9, 0x91EA, 0xE9EA, 0x9685,\t0xE9EB, 0x96E8, 0xE9EC, 0x96E9, 0xE9ED, 0x52D6, 0xE9EE, 0x5F67,\r\n\t0xE9EF, 0x65ED, 0xE9F0, 0x6631, 0xE9F1, 0x682F, 0xE9F2, 0x715C,\t0xE9F3, 0x7A36, 0xE9F4, 0x90C1, 0xE9F5, 0x980A, 0xE9F6, 0x4E91,\r\n\t0xE9F7, 0xF9C5, 0xE9F8, 0x6A52, 0xE9F9, 0x6B9E, 0xE9FA, 0x6F90,\t0xE9FB, 0x7189, 0xE9FC, 0x8018, 0xE9FD, 0x82B8, 0xE9FE, 0x8553,\r\n\t0xEAA1, 0x904B, 0xEAA2, 0x9695, 0xEAA3, 0x96F2, 0xEAA4, 0x97FB,\t0xEAA5, 0x851A, 0xEAA6, 0x9B31, 0xEAA7, 0x4E90, 0xEAA8, 0x718A,\r\n\t0xEAA9, 0x96C4, 0xEAAA, 0x5143, 0xEAAB, 0x539F, 0xEAAC, 0x54E1,\t0xEAAD, 0x5713, 0xEAAE, 0x5712, 0xEAAF, 0x57A3, 0xEAB0, 0x5A9B,\r\n\t0xEAB1, 0x5AC4, 0xEAB2, 0x5BC3, 0xEAB3, 0x6028, 0xEAB4, 0x613F,\t0xEAB5, 0x63F4, 0xEAB6, 0x6C85, 0xEAB7, 0x6D39, 0xEAB8, 0x6E72,\r\n\t0xEAB9, 0x6E90, 0xEABA, 0x7230, 0xEABB, 0x733F, 0xEABC, 0x7457,\t0xEABD, 0x82D1, 0xEABE, 0x8881, 0xEABF, 0x8F45, 0xEAC0, 0x9060,\r\n\t0xEAC1, 0xF9C6, 0xEAC2, 0x9662, 0xEAC3, 0x9858, 0xEAC4, 0x9D1B,\t0xEAC5, 0x6708, 0xEAC6, 0x8D8A, 0xEAC7, 0x925E, 0xEAC8, 0x4F4D,\r\n\t0xEAC9, 0x5049, 0xEACA, 0x50DE, 0xEACB, 0x5371, 0xEACC, 0x570D,\t0xEACD, 0x59D4, 0xEACE, 0x5A01, 0xEACF, 0x5C09, 0xEAD0, 0x6170,\r\n\t0xEAD1, 0x6690, 0xEAD2, 0x6E2D, 0xEAD3, 0x7232, 0xEAD4, 0x744B,\t0xEAD5, 0x7DEF, 0xEAD6, 0x80C3, 0xEAD7, 0x840E, 0xEAD8, 0x8466,\r\n\t0xEAD9, 0x853F, 0xEADA, 0x875F, 0xEADB, 0x885B, 0xEADC, 0x8918,\t0xEADD, 0x8B02, 0xEADE, 0x9055, 0xEADF, 0x97CB, 0xEAE0, 0x9B4F,\r\n\t0xEAE1, 0x4E73, 0xEAE2, 0x4F91, 0xEAE3, 0x5112, 0xEAE4, 0x516A,\t0xEAE5, 0xF9C7, 0xEAE6, 0x552F, 0xEAE7, 0x55A9, 0xEAE8, 0x5B7A,\r\n\t0xEAE9, 0x5BA5, 0xEAEA, 0x5E7C, 0xEAEB, 0x5E7D, 0xEAEC, 0x5EBE,\t0xEAED, 0x60A0, 0xEAEE, 0x60DF, 0xEAEF, 0x6108, 0xEAF0, 0x6109,\r\n\t0xEAF1, 0x63C4, 0xEAF2, 0x6538, 0xEAF3, 0x6709, 0xEAF4, 0xF9C8,\t0xEAF5, 0x67D4, 0xEAF6, 0x67DA, 0xEAF7, 0xF9C9, 0xEAF8, 0x6961,\r\n\t0xEAF9, 0x6962, 0xEAFA, 0x6CB9, 0xEAFB, 0x6D27, 0xEAFC, 0xF9CA,\t0xEAFD, 0x6E38, 0xEAFE, 0xF9CB, 0xEBA1, 0x6FE1, 0xEBA2, 0x7336,\r\n\t0xEBA3, 0x7337, 0xEBA4, 0xF9CC, 0xEBA5, 0x745C, 0xEBA6, 0x7531,\t0xEBA7, 0xF9CD, 0xEBA8, 0x7652, 0xEBA9, 0xF9CE, 0xEBAA, 0xF9CF,\r\n\t0xEBAB, 0x7DAD, 0xEBAC, 0x81FE, 0xEBAD, 0x8438, 0xEBAE, 0x88D5,\t0xEBAF, 0x8A98, 0xEBB0, 0x8ADB, 0xEBB1, 0x8AED, 0xEBB2, 0x8E30,\r\n\t0xEBB3, 0x8E42, 0xEBB4, 0x904A, 0xEBB5, 0x903E, 0xEBB6, 0x907A,\t0xEBB7, 0x9149, 0xEBB8, 0x91C9, 0xEBB9, 0x936E, 0xEBBA, 0xF9D0,\r\n\t0xEBBB, 0xF9D1, 0xEBBC, 0x5809, 0xEBBD, 0xF9D2, 0xEBBE, 0x6BD3,\t0xEBBF, 0x8089, 0xEBC0, 0x80B2, 0xEBC1, 0xF9D3, 0xEBC2, 0xF9D4,\r\n\t0xEBC3, 0x5141, 0xEBC4, 0x596B, 0xEBC5, 0x5C39, 0xEBC6, 0xF9D5,\t0xEBC7, 0xF9D6, 0xEBC8, 0x6F64, 0xEBC9, 0x73A7, 0xEBCA, 0x80E4,\r\n\t0xEBCB, 0x8D07, 0xEBCC, 0xF9D7, 0xEBCD, 0x9217, 0xEBCE, 0x958F,\t0xEBCF, 0xF9D8, 0xEBD0, 0xF9D9, 0xEBD1, 0xF9DA, 0xEBD2, 0xF9DB,\r\n\t0xEBD3, 0x807F, 0xEBD4, 0x620E, 0xEBD5, 0x701C, 0xEBD6, 0x7D68,\t0xEBD7, 0x878D, 0xEBD8, 0xF9DC, 0xEBD9, 0x57A0, 0xEBDA, 0x6069,\r\n\t0xEBDB, 0x6147, 0xEBDC, 0x6BB7, 0xEBDD, 0x8ABE, 0xEBDE, 0x9280,\t0xEBDF, 0x96B1, 0xEBE0, 0x4E59, 0xEBE1, 0x541F, 0xEBE2, 0x6DEB,\r\n\t0xEBE3, 0x852D, 0xEBE4, 0x9670, 0xEBE5, 0x97F3, 0xEBE6, 0x98EE,\t0xEBE7, 0x63D6, 0xEBE8, 0x6CE3, 0xEBE9, 0x9091, 0xEBEA, 0x51DD,\r\n\t0xEBEB, 0x61C9, 0xEBEC, 0x81BA, 0xEBED, 0x9DF9, 0xEBEE, 0x4F9D,\t0xEBEF, 0x501A, 0xEBF0, 0x5100, 0xEBF1, 0x5B9C, 0xEBF2, 0x610F,\r\n\t0xEBF3, 0x61FF, 0xEBF4, 0x64EC, 0xEBF5, 0x6905, 0xEBF6, 0x6BC5,\t0xEBF7, 0x7591, 0xEBF8, 0x77E3, 0xEBF9, 0x7FA9, 0xEBFA, 0x8264,\r\n\t0xEBFB, 0x858F, 0xEBFC, 0x87FB, 0xEBFD, 0x8863, 0xEBFE, 0x8ABC,\t0xECA1, 0x8B70, 0xECA2, 0x91AB, 0xECA3, 0x4E8C, 0xECA4, 0x4EE5,\r\n\t0xECA5, 0x4F0A, 0xECA6, 0xF9DD, 0xECA7, 0xF9DE, 0xECA8, 0x5937,\t0xECA9, 0x59E8, 0xECAA, 0xF9DF, 0xECAB, 0x5DF2, 0xECAC, 0x5F1B,\r\n\t0xECAD, 0x5F5B, 0xECAE, 0x6021, 0xECAF, 0xF9E0, 0xECB0, 0xF9E1,\t0xECB1, 0xF9E2, 0xECB2, 0xF9E3, 0xECB3, 0x723E, 0xECB4, 0x73E5,\r\n\t0xECB5, 0xF9E4, 0xECB6, 0x7570, 0xECB7, 0x75CD, 0xECB8, 0xF9E5,\t0xECB9, 0x79FB, 0xECBA, 0xF9E6, 0xECBB, 0x800C, 0xECBC, 0x8033,\r\n\t0xECBD, 0x8084, 0xECBE, 0x82E1, 0xECBF, 0x8351, 0xECC0, 0xF9E7,\t0xECC1, 0xF9E8, 0xECC2, 0x8CBD, 0xECC3, 0x8CB3, 0xECC4, 0x9087,\r\n\t0xECC5, 0xF9E9, 0xECC6, 0xF9EA, 0xECC7, 0x98F4, 0xECC8, 0x990C,\t0xECC9, 0xF9EB, 0xECCA, 0xF9EC, 0xECCB, 0x7037, 0xECCC, 0x76CA,\r\n\t0xECCD, 0x7FCA, 0xECCE, 0x7FCC, 0xECCF, 0x7FFC, 0xECD0, 0x8B1A,\t0xECD1, 0x4EBA, 0xECD2, 0x4EC1, 0xECD3, 0x5203, 0xECD4, 0x5370,\r\n\t0xECD5, 0xF9ED, 0xECD6, 0x54BD, 0xECD7, 0x56E0, 0xECD8, 0x59FB,\t0xECD9, 0x5BC5, 0xECDA, 0x5F15, 0xECDB, 0x5FCD, 0xECDC, 0x6E6E,\r\n\t0xECDD, 0xF9EE, 0xECDE, 0xF9EF, 0xECDF, 0x7D6A, 0xECE0, 0x8335,\t0xECE1, 0xF9F0, 0xECE2, 0x8693, 0xECE3, 0x8A8D, 0xECE4, 0xF9F1,\r\n\t0xECE5, 0x976D, 0xECE6, 0x9777, 0xECE7, 0xF9F2, 0xECE8, 0xF9F3,\t0xECE9, 0x4E00, 0xECEA, 0x4F5A, 0xECEB, 0x4F7E, 0xECEC, 0x58F9,\r\n\t0xECED, 0x65E5, 0xECEE, 0x6EA2, 0xECEF, 0x9038, 0xECF0, 0x93B0,\t0xECF1, 0x99B9, 0xECF2, 0x4EFB, 0xECF3, 0x58EC, 0xECF4, 0x598A,\r\n\t0xECF5, 0x59D9, 0xECF6, 0x6041, 0xECF7, 0xF9F4, 0xECF8, 0xF9F5,\t0xECF9, 0x7A14, 0xECFA, 0xF9F6, 0xECFB, 0x834F, 0xECFC, 0x8CC3,\r\n\t0xECFD, 0x5165, 0xECFE, 0x5344, 0xEDA1, 0xF9F7, 0xEDA2, 0xF9F8,\t0xEDA3, 0xF9F9, 0xEDA4, 0x4ECD, 0xEDA5, 0x5269, 0xEDA6, 0x5B55,\r\n\t0xEDA7, 0x82BF, 0xEDA8, 0x4ED4, 0xEDA9, 0x523A, 0xEDAA, 0x54A8,\t0xEDAB, 0x59C9, 0xEDAC, 0x59FF, 0xEDAD, 0x5B50, 0xEDAE, 0x5B57,\r\n\t0xEDAF, 0x5B5C, 0xEDB0, 0x6063, 0xEDB1, 0x6148, 0xEDB2, 0x6ECB,\t0xEDB3, 0x7099, 0xEDB4, 0x716E, 0xEDB5, 0x7386, 0xEDB6, 0x74F7,\r\n\t0xEDB7, 0x75B5, 0xEDB8, 0x78C1, 0xEDB9, 0x7D2B, 0xEDBA, 0x8005,\t0xEDBB, 0x81EA, 0xEDBC, 0x8328, 0xEDBD, 0x8517, 0xEDBE, 0x85C9,\r\n\t0xEDBF, 0x8AEE, 0xEDC0, 0x8CC7, 0xEDC1, 0x96CC, 0xEDC2, 0x4F5C,\t0xEDC3, 0x52FA, 0xEDC4, 0x56BC, 0xEDC5, 0x65AB, 0xEDC6, 0x6628,\r\n\t0xEDC7, 0x707C, 0xEDC8, 0x70B8, 0xEDC9, 0x7235, 0xEDCA, 0x7DBD,\t0xEDCB, 0x828D, 0xEDCC, 0x914C, 0xEDCD, 0x96C0, 0xEDCE, 0x9D72,\r\n\t0xEDCF, 0x5B71, 0xEDD0, 0x68E7, 0xEDD1, 0x6B98, 0xEDD2, 0x6F7A,\t0xEDD3, 0x76DE, 0xEDD4, 0x5C91, 0xEDD5, 0x66AB, 0xEDD6, 0x6F5B,\r\n\t0xEDD7, 0x7BB4, 0xEDD8, 0x7C2A, 0xEDD9, 0x8836, 0xEDDA, 0x96DC,\t0xEDDB, 0x4E08, 0xEDDC, 0x4ED7, 0xEDDD, 0x5320, 0xEDDE, 0x5834,\r\n\t0xEDDF, 0x58BB, 0xEDE0, 0x58EF, 0xEDE1, 0x596C, 0xEDE2, 0x5C07,\t0xEDE3, 0x5E33, 0xEDE4, 0x5E84, 0xEDE5, 0x5F35, 0xEDE6, 0x638C,\r\n\t0xEDE7, 0x66B2, 0xEDE8, 0x6756, 0xEDE9, 0x6A1F, 0xEDEA, 0x6AA3,\t0xEDEB, 0x6B0C, 0xEDEC, 0x6F3F, 0xEDED, 0x7246, 0xEDEE, 0xF9FA,\r\n\t0xEDEF, 0x7350, 0xEDF0, 0x748B, 0xEDF1, 0x7AE0, 0xEDF2, 0x7CA7,\t0xEDF3, 0x8178, 0xEDF4, 0x81DF, 0xEDF5, 0x81E7, 0xEDF6, 0x838A,\r\n\t0xEDF7, 0x846C, 0xEDF8, 0x8523, 0xEDF9, 0x8594, 0xEDFA, 0x85CF,\t0xEDFB, 0x88DD, 0xEDFC, 0x8D13, 0xEDFD, 0x91AC, 0xEDFE, 0x9577,\r\n\t0xEEA1, 0x969C, 0xEEA2, 0x518D, 0xEEA3, 0x54C9, 0xEEA4, 0x5728,\t0xEEA5, 0x5BB0, 0xEEA6, 0x624D, 0xEEA7, 0x6750, 0xEEA8, 0x683D,\r\n\t0xEEA9, 0x6893, 0xEEAA, 0x6E3D, 0xEEAB, 0x6ED3, 0xEEAC, 0x707D,\t0xEEAD, 0x7E21, 0xEEAE, 0x88C1, 0xEEAF, 0x8CA1, 0xEEB0, 0x8F09,\r\n\t0xEEB1, 0x9F4B, 0xEEB2, 0x9F4E, 0xEEB3, 0x722D, 0xEEB4, 0x7B8F,\t0xEEB5, 0x8ACD, 0xEEB6, 0x931A, 0xEEB7, 0x4F47, 0xEEB8, 0x4F4E,\r\n\t0xEEB9, 0x5132, 0xEEBA, 0x5480, 0xEEBB, 0x59D0, 0xEEBC, 0x5E95,\t0xEEBD, 0x62B5, 0xEEBE, 0x6775, 0xEEBF, 0x696E, 0xEEC0, 0x6A17,\r\n\t0xEEC1, 0x6CAE, 0xEEC2, 0x6E1A, 0xEEC3, 0x72D9, 0xEEC4, 0x732A,\t0xEEC5, 0x75BD, 0xEEC6, 0x7BB8, 0xEEC7, 0x7D35, 0xEEC8, 0x82E7,\r\n\t0xEEC9, 0x83F9, 0xEECA, 0x8457, 0xEECB, 0x85F7, 0xEECC, 0x8A5B,\t0xEECD, 0x8CAF, 0xEECE, 0x8E87, 0xEECF, 0x9019, 0xEED0, 0x90B8,\r\n\t0xEED1, 0x96CE, 0xEED2, 0x9F5F, 0xEED3, 0x52E3, 0xEED4, 0x540A,\t0xEED5, 0x5AE1, 0xEED6, 0x5BC2, 0xEED7, 0x6458, 0xEED8, 0x6575,\r\n\t0xEED9, 0x6EF4, 0xEEDA, 0x72C4, 0xEEDB, 0xF9FB, 0xEEDC, 0x7684,\t0xEEDD, 0x7A4D, 0xEEDE, 0x7B1B, 0xEEDF, 0x7C4D, 0xEEE0, 0x7E3E,\r\n\t0xEEE1, 0x7FDF, 0xEEE2, 0x837B, 0xEEE3, 0x8B2B, 0xEEE4, 0x8CCA,\t0xEEE5, 0x8D64, 0xEEE6, 0x8DE1, 0xEEE7, 0x8E5F, 0xEEE8, 0x8FEA,\r\n\t0xEEE9, 0x8FF9, 0xEEEA, 0x9069, 0xEEEB, 0x93D1, 0xEEEC, 0x4F43,\t0xEEED, 0x4F7A, 0xEEEE, 0x50B3, 0xEEEF, 0x5168, 0xEEF0, 0x5178,\r\n\t0xEEF1, 0x524D, 0xEEF2, 0x526A, 0xEEF3, 0x5861, 0xEEF4, 0x587C,\t0xEEF5, 0x5960, 0xEEF6, 0x5C08, 0xEEF7, 0x5C55, 0xEEF8, 0x5EDB,\r\n\t0xEEF9, 0x609B, 0xEEFA, 0x6230, 0xEEFB, 0x6813, 0xEEFC, 0x6BBF,\t0xEEFD, 0x6C08, 0xEEFE, 0x6FB1, 0xEFA1, 0x714E, 0xEFA2, 0x7420,\r\n\t0xEFA3, 0x7530, 0xEFA4, 0x7538, 0xEFA5, 0x7551, 0xEFA6, 0x7672,\t0xEFA7, 0x7B4C, 0xEFA8, 0x7B8B, 0xEFA9, 0x7BAD, 0xEFAA, 0x7BC6,\r\n\t0xEFAB, 0x7E8F, 0xEFAC, 0x8A6E, 0xEFAD, 0x8F3E, 0xEFAE, 0x8F49,\t0xEFAF, 0x923F, 0xEFB0, 0x9293, 0xEFB1, 0x9322, 0xEFB2, 0x942B,\r\n\t0xEFB3, 0x96FB, 0xEFB4, 0x985A, 0xEFB5, 0x986B, 0xEFB6, 0x991E,\t0xEFB7, 0x5207, 0xEFB8, 0x622A, 0xEFB9, 0x6298, 0xEFBA, 0x6D59,\r\n\t0xEFBB, 0x7664, 0xEFBC, 0x7ACA, 0xEFBD, 0x7BC0, 0xEFBE, 0x7D76,\t0xEFBF, 0x5360, 0xEFC0, 0x5CBE, 0xEFC1, 0x5E97, 0xEFC2, 0x6F38,\r\n\t0xEFC3, 0x70B9, 0xEFC4, 0x7C98, 0xEFC5, 0x9711, 0xEFC6, 0x9B8E,\t0xEFC7, 0x9EDE, 0xEFC8, 0x63A5, 0xEFC9, 0x647A, 0xEFCA, 0x8776,\r\n\t0xEFCB, 0x4E01, 0xEFCC, 0x4E95, 0xEFCD, 0x4EAD, 0xEFCE, 0x505C,\t0xEFCF, 0x5075, 0xEFD0, 0x5448, 0xEFD1, 0x59C3, 0xEFD2, 0x5B9A,\r\n\t0xEFD3, 0x5E40, 0xEFD4, 0x5EAD, 0xEFD5, 0x5EF7, 0xEFD6, 0x5F81,\t0xEFD7, 0x60C5, 0xEFD8, 0x633A, 0xEFD9, 0x653F, 0xEFDA, 0x6574,\r\n\t0xEFDB, 0x65CC, 0xEFDC, 0x6676, 0xEFDD, 0x6678, 0xEFDE, 0x67FE,\t0xEFDF, 0x6968, 0xEFE0, 0x6A89, 0xEFE1, 0x6B63, 0xEFE2, 0x6C40,\r\n\t0xEFE3, 0x6DC0, 0xEFE4, 0x6DE8, 0xEFE5, 0x6E1F, 0xEFE6, 0x6E5E,\t0xEFE7, 0x701E, 0xEFE8, 0x70A1, 0xEFE9, 0x738E, 0xEFEA, 0x73FD,\r\n\t0xEFEB, 0x753A, 0xEFEC, 0x775B, 0xEFED, 0x7887, 0xEFEE, 0x798E,\t0xEFEF, 0x7A0B, 0xEFF0, 0x7A7D, 0xEFF1, 0x7CBE, 0xEFF2, 0x7D8E,\r\n\t0xEFF3, 0x8247, 0xEFF4, 0x8A02, 0xEFF5, 0x8AEA, 0xEFF6, 0x8C9E,\t0xEFF7, 0x912D, 0xEFF8, 0x914A, 0xEFF9, 0x91D8, 0xEFFA, 0x9266,\r\n\t0xEFFB, 0x92CC, 0xEFFC, 0x9320, 0xEFFD, 0x9706, 0xEFFE, 0x9756,\t0xF0A1, 0x975C, 0xF0A2, 0x9802, 0xF0A3, 0x9F0E, 0xF0A4, 0x5236,\r\n\t0xF0A5, 0x5291, 0xF0A6, 0x557C, 0xF0A7, 0x5824, 0xF0A8, 0x5E1D,\t0xF0A9, 0x5F1F, 0xF0AA, 0x608C, 0xF0AB, 0x63D0, 0xF0AC, 0x68AF,\r\n\t0xF0AD, 0x6FDF, 0xF0AE, 0x796D, 0xF0AF, 0x7B2C, 0xF0B0, 0x81CD,\t0xF0B1, 0x85BA, 0xF0B2, 0x88FD, 0xF0B3, 0x8AF8, 0xF0B4, 0x8E44,\r\n\t0xF0B5, 0x918D, 0xF0B6, 0x9664, 0xF0B7, 0x969B, 0xF0B8, 0x973D,\t0xF0B9, 0x984C, 0xF0BA, 0x9F4A, 0xF0BB, 0x4FCE, 0xF0BC, 0x5146,\r\n\t0xF0BD, 0x51CB, 0xF0BE, 0x52A9, 0xF0BF, 0x5632, 0xF0C0, 0x5F14,\t0xF0C1, 0x5F6B, 0xF0C2, 0x63AA, 0xF0C3, 0x64CD, 0xF0C4, 0x65E9,\r\n\t0xF0C5, 0x6641, 0xF0C6, 0x66FA, 0xF0C7, 0x66F9, 0xF0C8, 0x671D,\t0xF0C9, 0x689D, 0xF0CA, 0x68D7, 0xF0CB, 0x69FD, 0xF0CC, 0x6F15,\r\n\t0xF0CD, 0x6F6E, 0xF0CE, 0x7167, 0xF0CF, 0x71E5, 0xF0D0, 0x722A,\t0xF0D1, 0x74AA, 0xF0D2, 0x773A, 0xF0D3, 0x7956, 0xF0D4, 0x795A,\r\n\t0xF0D5, 0x79DF, 0xF0D6, 0x7A20, 0xF0D7, 0x7A95, 0xF0D8, 0x7C97,\t0xF0D9, 0x7CDF, 0xF0DA, 0x7D44, 0xF0DB, 0x7E70, 0xF0DC, 0x8087,\r\n\t0xF0DD, 0x85FB, 0xF0DE, 0x86A4, 0xF0DF, 0x8A54, 0xF0E0, 0x8ABF,\t0xF0E1, 0x8D99, 0xF0E2, 0x8E81, 0xF0E3, 0x9020, 0xF0E4, 0x906D,\r\n\t0xF0E5, 0x91E3, 0xF0E6, 0x963B, 0xF0E7, 0x96D5, 0xF0E8, 0x9CE5,\t0xF0E9, 0x65CF, 0xF0EA, 0x7C07, 0xF0EB, 0x8DB3, 0xF0EC, 0x93C3,\r\n\t0xF0ED, 0x5B58, 0xF0EE, 0x5C0A, 0xF0EF, 0x5352, 0xF0F0, 0x62D9,\t0xF0F1, 0x731D, 0xF0F2, 0x5027, 0xF0F3, 0x5B97, 0xF0F4, 0x5F9E,\r\n\t0xF0F5, 0x60B0, 0xF0F6, 0x616B, 0xF0F7, 0x68D5, 0xF0F8, 0x6DD9,\t0xF0F9, 0x742E, 0xF0FA, 0x7A2E, 0xF0FB, 0x7D42, 0xF0FC, 0x7D9C,\r\n\t0xF0FD, 0x7E31, 0xF0FE, 0x816B, 0xF1A1, 0x8E2A, 0xF1A2, 0x8E35,\t0xF1A3, 0x937E, 0xF1A4, 0x9418, 0xF1A5, 0x4F50, 0xF1A6, 0x5750,\r\n\t0xF1A7, 0x5DE6, 0xF1A8, 0x5EA7, 0xF1A9, 0x632B, 0xF1AA, 0x7F6A,\t0xF1AB, 0x4E3B, 0xF1AC, 0x4F4F, 0xF1AD, 0x4F8F, 0xF1AE, 0x505A,\r\n\t0xF1AF, 0x59DD, 0xF1B0, 0x80C4, 0xF1B1, 0x546A, 0xF1B2, 0x5468,\t0xF1B3, 0x55FE, 0xF1B4, 0x594F, 0xF1B5, 0x5B99, 0xF1B6, 0x5DDE,\r\n\t0xF1B7, 0x5EDA, 0xF1B8, 0x665D, 0xF1B9, 0x6731, 0xF1BA, 0x67F1,\t0xF1BB, 0x682A, 0xF1BC, 0x6CE8, 0xF1BD, 0x6D32, 0xF1BE, 0x6E4A,\r\n\t0xF1BF, 0x6F8D, 0xF1C0, 0x70B7, 0xF1C1, 0x73E0, 0xF1C2, 0x7587,\t0xF1C3, 0x7C4C, 0xF1C4, 0x7D02, 0xF1C5, 0x7D2C, 0xF1C6, 0x7DA2,\r\n\t0xF1C7, 0x821F, 0xF1C8, 0x86DB, 0xF1C9, 0x8A3B, 0xF1CA, 0x8A85,\t0xF1CB, 0x8D70, 0xF1CC, 0x8E8A, 0xF1CD, 0x8F33, 0xF1CE, 0x9031,\r\n\t0xF1CF, 0x914E, 0xF1D0, 0x9152, 0xF1D1, 0x9444, 0xF1D2, 0x99D0,\t0xF1D3, 0x7AF9, 0xF1D4, 0x7CA5, 0xF1D5, 0x4FCA, 0xF1D6, 0x5101,\r\n\t0xF1D7, 0x51C6, 0xF1D8, 0x57C8, 0xF1D9, 0x5BEF, 0xF1DA, 0x5CFB,\t0xF1DB, 0x6659, 0xF1DC, 0x6A3D, 0xF1DD, 0x6D5A, 0xF1DE, 0x6E96,\r\n\t0xF1DF, 0x6FEC, 0xF1E0, 0x710C, 0xF1E1, 0x756F, 0xF1E2, 0x7AE3,\t0xF1E3, 0x8822, 0xF1E4, 0x9021, 0xF1E5, 0x9075, 0xF1E6, 0x96CB,\r\n\t0xF1E7, 0x99FF, 0xF1E8, 0x8301, 0xF1E9, 0x4E2D, 0xF1EA, 0x4EF2,\t0xF1EB, 0x8846, 0xF1EC, 0x91CD, 0xF1ED, 0x537D, 0xF1EE, 0x6ADB,\r\n\t0xF1EF, 0x696B, 0xF1F0, 0x6C41, 0xF1F1, 0x847A, 0xF1F2, 0x589E,\t0xF1F3, 0x618E, 0xF1F4, 0x66FE, 0xF1F5, 0x62EF, 0xF1F6, 0x70DD,\r\n\t0xF1F7, 0x7511, 0xF1F8, 0x75C7, 0xF1F9, 0x7E52, 0xF1FA, 0x84B8,\t0xF1FB, 0x8B49, 0xF1FC, 0x8D08, 0xF1FD, 0x4E4B, 0xF1FE, 0x53EA,\r\n\t0xF2A1, 0x54AB, 0xF2A2, 0x5730, 0xF2A3, 0x5740, 0xF2A4, 0x5FD7,\t0xF2A5, 0x6301, 0xF2A6, 0x6307, 0xF2A7, 0x646F, 0xF2A8, 0x652F,\r\n\t0xF2A9, 0x65E8, 0xF2AA, 0x667A, 0xF2AB, 0x679D, 0xF2AC, 0x67B3,\t0xF2AD, 0x6B62, 0xF2AE, 0x6C60, 0xF2AF, 0x6C9A, 0xF2B0, 0x6F2C,\r\n\t0xF2B1, 0x77E5, 0xF2B2, 0x7825, 0xF2B3, 0x7949, 0xF2B4, 0x7957,\t0xF2B5, 0x7D19, 0xF2B6, 0x80A2, 0xF2B7, 0x8102, 0xF2B8, 0x81F3,\r\n\t0xF2B9, 0x829D, 0xF2BA, 0x82B7, 0xF2BB, 0x8718, 0xF2BC, 0x8A8C,\t0xF2BD, 0xF9FC, 0xF2BE, 0x8D04, 0xF2BF, 0x8DBE, 0xF2C0, 0x9072,\r\n\t0xF2C1, 0x76F4, 0xF2C2, 0x7A19, 0xF2C3, 0x7A37, 0xF2C4, 0x7E54,\t0xF2C5, 0x8077, 0xF2C6, 0x5507, 0xF2C7, 0x55D4, 0xF2C8, 0x5875,\r\n\t0xF2C9, 0x632F, 0xF2CA, 0x6422, 0xF2CB, 0x6649, 0xF2CC, 0x664B,\t0xF2CD, 0x686D, 0xF2CE, 0x699B, 0xF2CF, 0x6B84, 0xF2D0, 0x6D25,\r\n\t0xF2D1, 0x6EB1, 0xF2D2, 0x73CD, 0xF2D3, 0x7468, 0xF2D4, 0x74A1,\t0xF2D5, 0x755B, 0xF2D6, 0x75B9, 0xF2D7, 0x76E1, 0xF2D8, 0x771E,\r\n\t0xF2D9, 0x778B, 0xF2DA, 0x79E6, 0xF2DB, 0x7E09, 0xF2DC, 0x7E1D,\t0xF2DD, 0x81FB, 0xF2DE, 0x852F, 0xF2DF, 0x8897, 0xF2E0, 0x8A3A,\r\n\t0xF2E1, 0x8CD1, 0xF2E2, 0x8EEB, 0xF2E3, 0x8FB0, 0xF2E4, 0x9032,\t0xF2E5, 0x93AD, 0xF2E6, 0x9663, 0xF2E7, 0x9673, 0xF2E8, 0x9707,\r\n\t0xF2E9, 0x4F84, 0xF2EA, 0x53F1, 0xF2EB, 0x59EA, 0xF2EC, 0x5AC9,\t0xF2ED, 0x5E19, 0xF2EE, 0x684E, 0xF2EF, 0x74C6, 0xF2F0, 0x75BE,\r\n\t0xF2F1, 0x79E9, 0xF2F2, 0x7A92, 0xF2F3, 0x81A3, 0xF2F4, 0x86ED,\t0xF2F5, 0x8CEA, 0xF2F6, 0x8DCC, 0xF2F7, 0x8FED, 0xF2F8, 0x659F,\r\n\t0xF2F9, 0x6715, 0xF2FA, 0xF9FD, 0xF2FB, 0x57F7, 0xF2FC, 0x6F57,\t0xF2FD, 0x7DDD, 0xF2FE, 0x8F2F, 0xF3A1, 0x93F6, 0xF3A2, 0x96C6,\r\n\t0xF3A3, 0x5FB5, 0xF3A4, 0x61F2, 0xF3A5, 0x6F84, 0xF3A6, 0x4E14,\t0xF3A7, 0x4F98, 0xF3A8, 0x501F, 0xF3A9, 0x53C9, 0xF3AA, 0x55DF,\r\n\t0xF3AB, 0x5D6F, 0xF3AC, 0x5DEE, 0xF3AD, 0x6B21, 0xF3AE, 0x6B64,\t0xF3AF, 0x78CB, 0xF3B0, 0x7B9A, 0xF3B1, 0xF9FE, 0xF3B2, 0x8E49,\r\n\t0xF3B3, 0x8ECA, 0xF3B4, 0x906E, 0xF3B5, 0x6349, 0xF3B6, 0x643E,\t0xF3B7, 0x7740, 0xF3B8, 0x7A84, 0xF3B9, 0x932F, 0xF3BA, 0x947F,\r\n\t0xF3BB, 0x9F6A, 0xF3BC, 0x64B0, 0xF3BD, 0x6FAF, 0xF3BE, 0x71E6,\t0xF3BF, 0x74A8, 0xF3C0, 0x74DA, 0xF3C1, 0x7AC4, 0xF3C2, 0x7C12,\r\n\t0xF3C3, 0x7E82, 0xF3C4, 0x7CB2, 0xF3C5, 0x7E98, 0xF3C6, 0x8B9A,\t0xF3C7, 0x8D0A, 0xF3C8, 0x947D, 0xF3C9, 0x9910, 0xF3CA, 0x994C,\r\n\t0xF3CB, 0x5239, 0xF3CC, 0x5BDF, 0xF3CD, 0x64E6, 0xF3CE, 0x672D,\t0xF3CF, 0x7D2E, 0xF3D0, 0x50ED, 0xF3D1, 0x53C3, 0xF3D2, 0x5879,\r\n\t0xF3D3, 0x6158, 0xF3D4, 0x6159, 0xF3D5, 0x61FA, 0xF3D6, 0x65AC,\t0xF3D7, 0x7AD9, 0xF3D8, 0x8B92, 0xF3D9, 0x8B96, 0xF3DA, 0x5009,\r\n\t0xF3DB, 0x5021, 0xF3DC, 0x5275, 0xF3DD, 0x5531, 0xF3DE, 0x5A3C,\t0xF3DF, 0x5EE0, 0xF3E0, 0x5F70, 0xF3E1, 0x6134, 0xF3E2, 0x655E,\r\n\t0xF3E3, 0x660C, 0xF3E4, 0x6636, 0xF3E5, 0x66A2, 0xF3E6, 0x69CD,\t0xF3E7, 0x6EC4, 0xF3E8, 0x6F32, 0xF3E9, 0x7316, 0xF3EA, 0x7621,\r\n\t0xF3EB, 0x7A93, 0xF3EC, 0x8139, 0xF3ED, 0x8259, 0xF3EE, 0x83D6,\t0xF3EF, 0x84BC, 0xF3F0, 0x50B5, 0xF3F1, 0x57F0, 0xF3F2, 0x5BC0,\r\n\t0xF3F3, 0x5BE8, 0xF3F4, 0x5F69, 0xF3F5, 0x63A1, 0xF3F6, 0x7826,\t0xF3F7, 0x7DB5, 0xF3F8, 0x83DC, 0xF3F9, 0x8521, 0xF3FA, 0x91C7,\r\n\t0xF3FB, 0x91F5, 0xF3FC, 0x518A, 0xF3FD, 0x67F5, 0xF3FE, 0x7B56,\t0xF4A1, 0x8CAC, 0xF4A2, 0x51C4, 0xF4A3, 0x59BB, 0xF4A4, 0x60BD,\r\n\t0xF4A5, 0x8655, 0xF4A6, 0x501C, 0xF4A7, 0xF9FF, 0xF4A8, 0x5254,\t0xF4A9, 0x5C3A, 0xF4AA, 0x617D, 0xF4AB, 0x621A, 0xF4AC, 0x62D3,\r\n\t0xF4AD, 0x64F2, 0xF4AE, 0x65A5, 0xF4AF, 0x6ECC, 0xF4B0, 0x7620,\t0xF4B1, 0x810A, 0xF4B2, 0x8E60, 0xF4B3, 0x965F, 0xF4B4, 0x96BB,\r\n\t0xF4B5, 0x4EDF, 0xF4B6, 0x5343, 0xF4B7, 0x5598, 0xF4B8, 0x5929,\t0xF4B9, 0x5DDD, 0xF4BA, 0x64C5, 0xF4BB, 0x6CC9, 0xF4BC, 0x6DFA,\r\n\t0xF4BD, 0x7394, 0xF4BE, 0x7A7F, 0xF4BF, 0x821B, 0xF4C0, 0x85A6,\t0xF4C1, 0x8CE4, 0xF4C2, 0x8E10, 0xF4C3, 0x9077, 0xF4C4, 0x91E7,\r\n\t0xF4C5, 0x95E1, 0xF4C6, 0x9621, 0xF4C7, 0x97C6, 0xF4C8, 0x51F8,\t0xF4C9, 0x54F2, 0xF4CA, 0x5586, 0xF4CB, 0x5FB9, 0xF4CC, 0x64A4,\r\n\t0xF4CD, 0x6F88, 0xF4CE, 0x7DB4, 0xF4CF, 0x8F1F, 0xF4D0, 0x8F4D,\t0xF4D1, 0x9435, 0xF4D2, 0x50C9, 0xF4D3, 0x5C16, 0xF4D4, 0x6CBE,\r\n\t0xF4D5, 0x6DFB, 0xF4D6, 0x751B, 0xF4D7, 0x77BB, 0xF4D8, 0x7C3D,\t0xF4D9, 0x7C64, 0xF4DA, 0x8A79, 0xF4DB, 0x8AC2, 0xF4DC, 0x581E,\r\n\t0xF4DD, 0x59BE, 0xF4DE, 0x5E16, 0xF4DF, 0x6377, 0xF4E0, 0x7252,\t0xF4E1, 0x758A, 0xF4E2, 0x776B, 0xF4E3, 0x8ADC, 0xF4E4, 0x8CBC,\r\n\t0xF4E5, 0x8F12, 0xF4E6, 0x5EF3, 0xF4E7, 0x6674, 0xF4E8, 0x6DF8,\t0xF4E9, 0x807D, 0xF4EA, 0x83C1, 0xF4EB, 0x8ACB, 0xF4EC, 0x9751,\r\n\t0xF4ED, 0x9BD6, 0xF4EE, 0xFA00, 0xF4EF, 0x5243, 0xF4F0, 0x66FF,\t0xF4F1, 0x6D95, 0xF4F2, 0x6EEF, 0xF4F3, 0x7DE0, 0xF4F4, 0x8AE6,\r\n\t0xF4F5, 0x902E, 0xF4F6, 0x905E, 0xF4F7, 0x9AD4, 0xF4F8, 0x521D,\t0xF4F9, 0x527F, 0xF4FA, 0x54E8, 0xF4FB, 0x6194, 0xF4FC, 0x6284,\r\n\t0xF4FD, 0x62DB, 0xF4FE, 0x68A2, 0xF5A1, 0x6912, 0xF5A2, 0x695A,\t0xF5A3, 0x6A35, 0xF5A4, 0x7092, 0xF5A5, 0x7126, 0xF5A6, 0x785D,\r\n\t0xF5A7, 0x7901, 0xF5A8, 0x790E, 0xF5A9, 0x79D2, 0xF5AA, 0x7A0D,\t0xF5AB, 0x8096, 0xF5AC, 0x8278, 0xF5AD, 0x82D5, 0xF5AE, 0x8349,\r\n\t0xF5AF, 0x8549, 0xF5B0, 0x8C82, 0xF5B1, 0x8D85, 0xF5B2, 0x9162,\t0xF5B3, 0x918B, 0xF5B4, 0x91AE, 0xF5B5, 0x4FC3, 0xF5B6, 0x56D1,\r\n\t0xF5B7, 0x71ED, 0xF5B8, 0x77D7, 0xF5B9, 0x8700, 0xF5BA, 0x89F8,\t0xF5BB, 0x5BF8, 0xF5BC, 0x5FD6, 0xF5BD, 0x6751, 0xF5BE, 0x90A8,\r\n\t0xF5BF, 0x53E2, 0xF5C0, 0x585A, 0xF5C1, 0x5BF5, 0xF5C2, 0x60A4,\t0xF5C3, 0x6181, 0xF5C4, 0x6460, 0xF5C5, 0x7E3D, 0xF5C6, 0x8070,\r\n\t0xF5C7, 0x8525, 0xF5C8, 0x9283, 0xF5C9, 0x64AE, 0xF5CA, 0x50AC,\t0xF5CB, 0x5D14, 0xF5CC, 0x6700, 0xF5CD, 0x589C, 0xF5CE, 0x62BD,\r\n\t0xF5CF, 0x63A8, 0xF5D0, 0x690E, 0xF5D1, 0x6978, 0xF5D2, 0x6A1E,\t0xF5D3, 0x6E6B, 0xF5D4, 0x76BA, 0xF5D5, 0x79CB, 0xF5D6, 0x82BB,\r\n\t0xF5D7, 0x8429, 0xF5D8, 0x8ACF, 0xF5D9, 0x8DA8, 0xF5DA, 0x8FFD,\t0xF5DB, 0x9112, 0xF5DC, 0x914B, 0xF5DD, 0x919C, 0xF5DE, 0x9310,\r\n\t0xF5DF, 0x9318, 0xF5E0, 0x939A, 0xF5E1, 0x96DB, 0xF5E2, 0x9A36,\t0xF5E3, 0x9C0D, 0xF5E4, 0x4E11, 0xF5E5, 0x755C, 0xF5E6, 0x795D,\r\n\t0xF5E7, 0x7AFA, 0xF5E8, 0x7B51, 0xF5E9, 0x7BC9, 0xF5EA, 0x7E2E,\t0xF5EB, 0x84C4, 0xF5EC, 0x8E59, 0xF5ED, 0x8E74, 0xF5EE, 0x8EF8,\r\n\t0xF5EF, 0x9010, 0xF5F0, 0x6625, 0xF5F1, 0x693F, 0xF5F2, 0x7443,\t0xF5F3, 0x51FA, 0xF5F4, 0x672E, 0xF5F5, 0x9EDC, 0xF5F6, 0x5145,\r\n\t0xF5F7, 0x5FE0, 0xF5F8, 0x6C96, 0xF5F9, 0x87F2, 0xF5FA, 0x885D,\t0xF5FB, 0x8877, 0xF5FC, 0x60B4, 0xF5FD, 0x81B5, 0xF5FE, 0x8403,\r\n\t0xF6A1, 0x8D05, 0xF6A2, 0x53D6, 0xF6A3, 0x5439, 0xF6A4, 0x5634,\t0xF6A5, 0x5A36, 0xF6A6, 0x5C31, 0xF6A7, 0x708A, 0xF6A8, 0x7FE0,\r\n\t0xF6A9, 0x805A, 0xF6AA, 0x8106, 0xF6AB, 0x81ED, 0xF6AC, 0x8DA3,\t0xF6AD, 0x9189, 0xF6AE, 0x9A5F, 0xF6AF, 0x9DF2, 0xF6B0, 0x5074,\r\n\t0xF6B1, 0x4EC4, 0xF6B2, 0x53A0, 0xF6B3, 0x60FB, 0xF6B4, 0x6E2C,\t0xF6B5, 0x5C64, 0xF6B6, 0x4F88, 0xF6B7, 0x5024, 0xF6B8, 0x55E4,\r\n\t0xF6B9, 0x5CD9, 0xF6BA, 0x5E5F, 0xF6BB, 0x6065, 0xF6BC, 0x6894,\t0xF6BD, 0x6CBB, 0xF6BE, 0x6DC4, 0xF6BF, 0x71BE, 0xF6C0, 0x75D4,\r\n\t0xF6C1, 0x75F4, 0xF6C2, 0x7661, 0xF6C3, 0x7A1A, 0xF6C4, 0x7A49,\t0xF6C5, 0x7DC7, 0xF6C6, 0x7DFB, 0xF6C7, 0x7F6E, 0xF6C8, 0x81F4,\r\n\t0xF6C9, 0x86A9, 0xF6CA, 0x8F1C, 0xF6CB, 0x96C9, 0xF6CC, 0x99B3,\t0xF6CD, 0x9F52, 0xF6CE, 0x5247, 0xF6CF, 0x52C5, 0xF6D0, 0x98ED,\r\n\t0xF6D1, 0x89AA, 0xF6D2, 0x4E03, 0xF6D3, 0x67D2, 0xF6D4, 0x6F06,\t0xF6D5, 0x4FB5, 0xF6D6, 0x5BE2, 0xF6D7, 0x6795, 0xF6D8, 0x6C88,\r\n\t0xF6D9, 0x6D78, 0xF6DA, 0x741B, 0xF6DB, 0x7827, 0xF6DC, 0x91DD,\t0xF6DD, 0x937C, 0xF6DE, 0x87C4, 0xF6DF, 0x79E4, 0xF6E0, 0x7A31,\r\n\t0xF6E1, 0x5FEB, 0xF6E2, 0x4ED6, 0xF6E3, 0x54A4, 0xF6E4, 0x553E,\t0xF6E5, 0x58AE, 0xF6E6, 0x59A5, 0xF6E7, 0x60F0, 0xF6E8, 0x6253,\r\n\t0xF6E9, 0x62D6, 0xF6EA, 0x6736, 0xF6EB, 0x6955, 0xF6EC, 0x8235,\t0xF6ED, 0x9640, 0xF6EE, 0x99B1, 0xF6EF, 0x99DD, 0xF6F0, 0x502C,\r\n\t0xF6F1, 0x5353, 0xF6F2, 0x5544, 0xF6F3, 0x577C, 0xF6F4, 0xFA01,\t0xF6F5, 0x6258, 0xF6F6, 0xFA02, 0xF6F7, 0x64E2, 0xF6F8, 0x666B,\r\n\t0xF6F9, 0x67DD, 0xF6FA, 0x6FC1, 0xF6FB, 0x6FEF, 0xF6FC, 0x7422,\t0xF6FD, 0x7438, 0xF6FE, 0x8A17, 0xF7A1, 0x9438, 0xF7A2, 0x5451,\r\n\t0xF7A3, 0x5606, 0xF7A4, 0x5766, 0xF7A5, 0x5F48, 0xF7A6, 0x619A,\t0xF7A7, 0x6B4E, 0xF7A8, 0x7058, 0xF7A9, 0x70AD, 0xF7AA, 0x7DBB,\r\n\t0xF7AB, 0x8A95, 0xF7AC, 0x596A, 0xF7AD, 0x812B, 0xF7AE, 0x63A2,\t0xF7AF, 0x7708, 0xF7B0, 0x803D, 0xF7B1, 0x8CAA, 0xF7B2, 0x5854,\r\n\t0xF7B3, 0x642D, 0xF7B4, 0x69BB, 0xF7B5, 0x5B95, 0xF7B6, 0x5E11,\t0xF7B7, 0x6E6F, 0xF7B8, 0xFA03, 0xF7B9, 0x8569, 0xF7BA, 0x514C,\r\n\t0xF7BB, 0x53F0, 0xF7BC, 0x592A, 0xF7BD, 0x6020, 0xF7BE, 0x614B,\t0xF7BF, 0x6B86, 0xF7C0, 0x6C70, 0xF7C1, 0x6CF0, 0xF7C2, 0x7B1E,\r\n\t0xF7C3, 0x80CE, 0xF7C4, 0x82D4, 0xF7C5, 0x8DC6, 0xF7C6, 0x90B0,\t0xF7C7, 0x98B1, 0xF7C8, 0xFA04, 0xF7C9, 0x64C7, 0xF7CA, 0x6FA4,\r\n\t0xF7CB, 0x6491, 0xF7CC, 0x6504, 0xF7CD, 0x514E, 0xF7CE, 0x5410,\t0xF7CF, 0x571F, 0xF7D0, 0x8A0E, 0xF7D1, 0x615F, 0xF7D2, 0x6876,\r\n\t0xF7D3, 0xFA05, 0xF7D4, 0x75DB, 0xF7D5, 0x7B52, 0xF7D6, 0x7D71,\t0xF7D7, 0x901A, 0xF7D8, 0x5806, 0xF7D9, 0x69CC, 0xF7DA, 0x817F,\r\n\t0xF7DB, 0x892A, 0xF7DC, 0x9000, 0xF7DD, 0x9839, 0xF7DE, 0x5078,\t0xF7DF, 0x5957, 0xF7E0, 0x59AC, 0xF7E1, 0x6295, 0xF7E2, 0x900F,\r\n\t0xF7E3, 0x9B2A, 0xF7E4, 0x615D, 0xF7E5, 0x7279, 0xF7E6, 0x95D6,\t0xF7E7, 0x5761, 0xF7E8, 0x5A46, 0xF7E9, 0x5DF4, 0xF7EA, 0x628A,\r\n\t0xF7EB, 0x64AD, 0xF7EC, 0x64FA, 0xF7ED, 0x6777, 0xF7EE, 0x6CE2,\t0xF7EF, 0x6D3E, 0xF7F0, 0x722C, 0xF7F1, 0x7436, 0xF7F2, 0x7834,\r\n\t0xF7F3, 0x7F77, 0xF7F4, 0x82AD, 0xF7F5, 0x8DDB, 0xF7F6, 0x9817,\t0xF7F7, 0x5224, 0xF7F8, 0x5742, 0xF7F9, 0x677F, 0xF7FA, 0x7248,\r\n\t0xF7FB, 0x74E3, 0xF7FC, 0x8CA9, 0xF7FD, 0x8FA6, 0xF7FE, 0x9211,\t0xF8A1, 0x962A, 0xF8A2, 0x516B, 0xF8A3, 0x53ED, 0xF8A4, 0x634C,\r\n\t0xF8A5, 0x4F69, 0xF8A6, 0x5504, 0xF8A7, 0x6096, 0xF8A8, 0x6557,\t0xF8A9, 0x6C9B, 0xF8AA, 0x6D7F, 0xF8AB, 0x724C, 0xF8AC, 0x72FD,\r\n\t0xF8AD, 0x7A17, 0xF8AE, 0x8987, 0xF8AF, 0x8C9D, 0xF8B0, 0x5F6D,\t0xF8B1, 0x6F8E, 0xF8B2, 0x70F9, 0xF8B3, 0x81A8, 0xF8B4, 0x610E,\r\n\t0xF8B5, 0x4FBF, 0xF8B6, 0x504F, 0xF8B7, 0x6241, 0xF8B8, 0x7247,\t0xF8B9, 0x7BC7, 0xF8BA, 0x7DE8, 0xF8BB, 0x7FE9, 0xF8BC, 0x904D,\r\n\t0xF8BD, 0x97AD, 0xF8BE, 0x9A19, 0xF8BF, 0x8CB6, 0xF8C0, 0x576A,\t0xF8C1, 0x5E73, 0xF8C2, 0x67B0, 0xF8C3, 0x840D, 0xF8C4, 0x8A55,\r\n\t0xF8C5, 0x5420, 0xF8C6, 0x5B16, 0xF8C7, 0x5E63, 0xF8C8, 0x5EE2,\t0xF8C9, 0x5F0A, 0xF8CA, 0x6583, 0xF8CB, 0x80BA, 0xF8CC, 0x853D,\r\n\t0xF8CD, 0x9589, 0xF8CE, 0x965B, 0xF8CF, 0x4F48, 0xF8D0, 0x5305,\t0xF8D1, 0x530D, 0xF8D2, 0x530F, 0xF8D3, 0x5486, 0xF8D4, 0x54FA,\r\n\t0xF8D5, 0x5703, 0xF8D6, 0x5E03, 0xF8D7, 0x6016, 0xF8D8, 0x629B,\t0xF8D9, 0x62B1, 0xF8DA, 0x6355, 0xF8DB, 0xFA06, 0xF8DC, 0x6CE1,\r\n\t0xF8DD, 0x6D66, 0xF8DE, 0x75B1, 0xF8DF, 0x7832, 0xF8E0, 0x80DE,\t0xF8E1, 0x812F, 0xF8E2, 0x82DE, 0xF8E3, 0x8461, 0xF8E4, 0x84B2,\r\n\t0xF8E5, 0x888D, 0xF8E6, 0x8912, 0xF8E7, 0x900B, 0xF8E8, 0x92EA,\t0xF8E9, 0x98FD, 0xF8EA, 0x9B91, 0xF8EB, 0x5E45, 0xF8EC, 0x66B4,\r\n\t0xF8ED, 0x66DD, 0xF8EE, 0x7011, 0xF8EF, 0x7206, 0xF8F0, 0xFA07,\t0xF8F1, 0x4FF5, 0xF8F2, 0x527D, 0xF8F3, 0x5F6A, 0xF8F4, 0x6153,\r\n\t0xF8F5, 0x6753, 0xF8F6, 0x6A19, 0xF8F7, 0x6F02, 0xF8F8, 0x74E2,\t0xF8F9, 0x7968, 0xF8FA, 0x8868, 0xF8FB, 0x8C79, 0xF8FC, 0x98C7,\r\n\t0xF8FD, 0x98C4, 0xF8FE, 0x9A43, 0xF9A1, 0x54C1, 0xF9A2, 0x7A1F,\t0xF9A3, 0x6953, 0xF9A4, 0x8AF7, 0xF9A5, 0x8C4A, 0xF9A6, 0x98A8,\r\n\t0xF9A7, 0x99AE, 0xF9A8, 0x5F7C, 0xF9A9, 0x62AB, 0xF9AA, 0x75B2,\t0xF9AB, 0x76AE, 0xF9AC, 0x88AB, 0xF9AD, 0x907F, 0xF9AE, 0x9642,\r\n\t0xF9AF, 0x5339, 0xF9B0, 0x5F3C, 0xF9B1, 0x5FC5, 0xF9B2, 0x6CCC,\t0xF9B3, 0x73CC, 0xF9B4, 0x7562, 0xF9B5, 0x758B, 0xF9B6, 0x7B46,\r\n\t0xF9B7, 0x82FE, 0xF9B8, 0x999D, 0xF9B9, 0x4E4F, 0xF9BA, 0x903C,\t0xF9BB, 0x4E0B, 0xF9BC, 0x4F55, 0xF9BD, 0x53A6, 0xF9BE, 0x590F,\r\n\t0xF9BF, 0x5EC8, 0xF9C0, 0x6630, 0xF9C1, 0x6CB3, 0xF9C2, 0x7455,\t0xF9C3, 0x8377, 0xF9C4, 0x8766, 0xF9C5, 0x8CC0, 0xF9C6, 0x9050,\r\n\t0xF9C7, 0x971E, 0xF9C8, 0x9C15, 0xF9C9, 0x58D1, 0xF9CA, 0x5B78,\t0xF9CB, 0x8650, 0xF9CC, 0x8B14, 0xF9CD, 0x9DB4, 0xF9CE, 0x5BD2,\r\n\t0xF9CF, 0x6068, 0xF9D0, 0x608D, 0xF9D1, 0x65F1, 0xF9D2, 0x6C57,\t0xF9D3, 0x6F22, 0xF9D4, 0x6FA3, 0xF9D5, 0x701A, 0xF9D6, 0x7F55,\r\n\t0xF9D7, 0x7FF0, 0xF9D8, 0x9591, 0xF9D9, 0x9592, 0xF9DA, 0x9650,\t0xF9DB, 0x97D3, 0xF9DC, 0x5272, 0xF9DD, 0x8F44, 0xF9DE, 0x51FD,\r\n\t0xF9DF, 0x542B, 0xF9E0, 0x54B8, 0xF9E1, 0x5563, 0xF9E2, 0x558A,\t0xF9E3, 0x6ABB, 0xF9E4, 0x6DB5, 0xF9E5, 0x7DD8, 0xF9E6, 0x8266,\r\n\t0xF9E7, 0x929C, 0xF9E8, 0x9677, 0xF9E9, 0x9E79, 0xF9EA, 0x5408,\t0xF9EB, 0x54C8, 0xF9EC, 0x76D2, 0xF9ED, 0x86E4, 0xF9EE, 0x95A4,\r\n\t0xF9EF, 0x95D4, 0xF9F0, 0x965C, 0xF9F1, 0x4EA2, 0xF9F2, 0x4F09,\t0xF9F3, 0x59EE, 0xF9F4, 0x5AE6, 0xF9F5, 0x5DF7, 0xF9F6, 0x6052,\r\n\t0xF9F7, 0x6297, 0xF9F8, 0x676D, 0xF9F9, 0x6841, 0xF9FA, 0x6C86,\t0xF9FB, 0x6E2F, 0xF9FC, 0x7F38, 0xF9FD, 0x809B, 0xF9FE, 0x822A,\r\n\t0xFAA1, 0xFA08, 0xFAA2, 0xFA09, 0xFAA3, 0x9805, 0xFAA4, 0x4EA5,\t0xFAA5, 0x5055, 0xFAA6, 0x54B3, 0xFAA7, 0x5793, 0xFAA8, 0x595A,\r\n\t0xFAA9, 0x5B69, 0xFAAA, 0x5BB3, 0xFAAB, 0x61C8, 0xFAAC, 0x6977,\t0xFAAD, 0x6D77, 0xFAAE, 0x7023, 0xFAAF, 0x87F9, 0xFAB0, 0x89E3,\r\n\t0xFAB1, 0x8A72, 0xFAB2, 0x8AE7, 0xFAB3, 0x9082, 0xFAB4, 0x99ED,\t0xFAB5, 0x9AB8, 0xFAB6, 0x52BE, 0xFAB7, 0x6838, 0xFAB8, 0x5016,\r\n\t0xFAB9, 0x5E78, 0xFABA, 0x674F, 0xFABB, 0x8347, 0xFABC, 0x884C,\t0xFABD, 0x4EAB, 0xFABE, 0x5411, 0xFABF, 0x56AE, 0xFAC0, 0x73E6,\r\n\t0xFAC1, 0x9115, 0xFAC2, 0x97FF, 0xFAC3, 0x9909, 0xFAC4, 0x9957,\t0xFAC5, 0x9999, 0xFAC6, 0x5653, 0xFAC7, 0x589F, 0xFAC8, 0x865B,\r\n\t0xFAC9, 0x8A31, 0xFACA, 0x61B2, 0xFACB, 0x6AF6, 0xFACC, 0x737B,\t0xFACD, 0x8ED2, 0xFACE, 0x6B47, 0xFACF, 0x96AA, 0xFAD0, 0x9A57,\r\n\t0xFAD1, 0x5955, 0xFAD2, 0x7200, 0xFAD3, 0x8D6B, 0xFAD4, 0x9769,\t0xFAD5, 0x4FD4, 0xFAD6, 0x5CF4, 0xFAD7, 0x5F26, 0xFAD8, 0x61F8,\r\n\t0xFAD9, 0x665B, 0xFADA, 0x6CEB, 0xFADB, 0x70AB, 0xFADC, 0x7384,\t0xFADD, 0x73B9, 0xFADE, 0x73FE, 0xFADF, 0x7729, 0xFAE0, 0x774D,\r\n\t0xFAE1, 0x7D43, 0xFAE2, 0x7D62, 0xFAE3, 0x7E23, 0xFAE4, 0x8237,\t0xFAE5, 0x8852, 0xFAE6, 0xFA0A, 0xFAE7, 0x8CE2, 0xFAE8, 0x9249,\r\n\t0xFAE9, 0x986F, 0xFAEA, 0x5B51, 0xFAEB, 0x7A74, 0xFAEC, 0x8840,\t0xFAED, 0x9801, 0xFAEE, 0x5ACC, 0xFAEF, 0x4FE0, 0xFAF0, 0x5354,\r\n\t0xFAF1, 0x593E, 0xFAF2, 0x5CFD, 0xFAF3, 0x633E, 0xFAF4, 0x6D79,\t0xFAF5, 0x72F9, 0xFAF6, 0x8105, 0xFAF7, 0x8107, 0xFAF8, 0x83A2,\r\n\t0xFAF9, 0x92CF, 0xFAFA, 0x9830, 0xFAFB, 0x4EA8, 0xFAFC, 0x5144,\t0xFAFD, 0x5211, 0xFAFE, 0x578B, 0xFBA1, 0x5F62, 0xFBA2, 0x6CC2,\r\n\t0xFBA3, 0x6ECE, 0xFBA4, 0x7005, 0xFBA5, 0x7050, 0xFBA6, 0x70AF,\t0xFBA7, 0x7192, 0xFBA8, 0x73E9, 0xFBA9, 0x7469, 0xFBAA, 0x834A,\r\n\t0xFBAB, 0x87A2, 0xFBAC, 0x8861, 0xFBAD, 0x9008, 0xFBAE, 0x90A2,\t0xFBAF, 0x93A3, 0xFBB0, 0x99A8, 0xFBB1, 0x516E, 0xFBB2, 0x5F57,\r\n\t0xFBB3, 0x60E0, 0xFBB4, 0x6167, 0xFBB5, 0x66B3, 0xFBB6, 0x8559,\t0xFBB7, 0x8E4A, 0xFBB8, 0x91AF, 0xFBB9, 0x978B, 0xFBBA, 0x4E4E,\r\n\t0xFBBB, 0x4E92, 0xFBBC, 0x547C, 0xFBBD, 0x58D5, 0xFBBE, 0x58FA,\t0xFBBF, 0x597D, 0xFBC0, 0x5CB5, 0xFBC1, 0x5F27, 0xFBC2, 0x6236,\r\n\t0xFBC3, 0x6248, 0xFBC4, 0x660A, 0xFBC5, 0x6667, 0xFBC6, 0x6BEB,\t0xFBC7, 0x6D69, 0xFBC8, 0x6DCF, 0xFBC9, 0x6E56, 0xFBCA, 0x6EF8,\r\n\t0xFBCB, 0x6F94, 0xFBCC, 0x6FE0, 0xFBCD, 0x6FE9, 0xFBCE, 0x705D,\t0xFBCF, 0x72D0, 0xFBD0, 0x7425, 0xFBD1, 0x745A, 0xFBD2, 0x74E0,\r\n\t0xFBD3, 0x7693, 0xFBD4, 0x795C, 0xFBD5, 0x7CCA, 0xFBD6, 0x7E1E,\t0xFBD7, 0x80E1, 0xFBD8, 0x82A6, 0xFBD9, 0x846B, 0xFBDA, 0x84BF,\r\n\t0xFBDB, 0x864E, 0xFBDC, 0x865F, 0xFBDD, 0x8774, 0xFBDE, 0x8B77,\t0xFBDF, 0x8C6A, 0xFBE0, 0x93AC, 0xFBE1, 0x9800, 0xFBE2, 0x9865,\r\n\t0xFBE3, 0x60D1, 0xFBE4, 0x6216, 0xFBE5, 0x9177, 0xFBE6, 0x5A5A,\t0xFBE7, 0x660F, 0xFBE8, 0x6DF7, 0xFBE9, 0x6E3E, 0xFBEA, 0x743F,\r\n\t0xFBEB, 0x9B42, 0xFBEC, 0x5FFD, 0xFBED, 0x60DA, 0xFBEE, 0x7B0F,\t0xFBEF, 0x54C4, 0xFBF0, 0x5F18, 0xFBF1, 0x6C5E, 0xFBF2, 0x6CD3,\r\n\t0xFBF3, 0x6D2A, 0xFBF4, 0x70D8, 0xFBF5, 0x7D05, 0xFBF6, 0x8679,\t0xFBF7, 0x8A0C, 0xFBF8, 0x9D3B, 0xFBF9, 0x5316, 0xFBFA, 0x548C,\r\n\t0xFBFB, 0x5B05, 0xFBFC, 0x6A3A, 0xFBFD, 0x706B, 0xFBFE, 0x7575,\t0xFCA1, 0x798D, 0xFCA2, 0x79BE, 0xFCA3, 0x82B1, 0xFCA4, 0x83EF,\r\n\t0xFCA5, 0x8A71, 0xFCA6, 0x8B41, 0xFCA7, 0x8CA8, 0xFCA8, 0x9774,\t0xFCA9, 0xFA0B, 0xFCAA, 0x64F4, 0xFCAB, 0x652B, 0xFCAC, 0x78BA,\r\n\t0xFCAD, 0x78BB, 0xFCAE, 0x7A6B, 0xFCAF, 0x4E38, 0xFCB0, 0x559A,\t0xFCB1, 0x5950, 0xFCB2, 0x5BA6, 0xFCB3, 0x5E7B, 0xFCB4, 0x60A3,\r\n\t0xFCB5, 0x63DB, 0xFCB6, 0x6B61, 0xFCB7, 0x6665, 0xFCB8, 0x6853,\t0xFCB9, 0x6E19, 0xFCBA, 0x7165, 0xFCBB, 0x74B0, 0xFCBC, 0x7D08,\r\n\t0xFCBD, 0x9084, 0xFCBE, 0x9A69, 0xFCBF, 0x9C25, 0xFCC0, 0x6D3B,\t0xFCC1, 0x6ED1, 0xFCC2, 0x733E, 0xFCC3, 0x8C41, 0xFCC4, 0x95CA,\r\n\t0xFCC5, 0x51F0, 0xFCC6, 0x5E4C, 0xFCC7, 0x5FA8, 0xFCC8, 0x604D,\t0xFCC9, 0x60F6, 0xFCCA, 0x6130, 0xFCCB, 0x614C, 0xFCCC, 0x6643,\r\n\t0xFCCD, 0x6644, 0xFCCE, 0x69A5, 0xFCCF, 0x6CC1, 0xFCD0, 0x6E5F,\t0xFCD1, 0x6EC9, 0xFCD2, 0x6F62, 0xFCD3, 0x714C, 0xFCD4, 0x749C,\r\n\t0xFCD5, 0x7687, 0xFCD6, 0x7BC1, 0xFCD7, 0x7C27, 0xFCD8, 0x8352,\t0xFCD9, 0x8757, 0xFCDA, 0x9051, 0xFCDB, 0x968D, 0xFCDC, 0x9EC3,\r\n\t0xFCDD, 0x532F, 0xFCDE, 0x56DE, 0xFCDF, 0x5EFB, 0xFCE0, 0x5F8A,\t0xFCE1, 0x6062, 0xFCE2, 0x6094, 0xFCE3, 0x61F7, 0xFCE4, 0x6666,\r\n\t0xFCE5, 0x6703, 0xFCE6, 0x6A9C, 0xFCE7, 0x6DEE, 0xFCE8, 0x6FAE,\t0xFCE9, 0x7070, 0xFCEA, 0x736A, 0xFCEB, 0x7E6A, 0xFCEC, 0x81BE,\r\n\t0xFCED, 0x8334, 0xFCEE, 0x86D4, 0xFCEF, 0x8AA8, 0xFCF0, 0x8CC4,\t0xFCF1, 0x5283, 0xFCF2, 0x7372, 0xFCF3, 0x5B96, 0xFCF4, 0x6A6B,\r\n\t0xFCF5, 0x9404, 0xFCF6, 0x54EE, 0xFCF7, 0x5686, 0xFCF8, 0x5B5D,\t0xFCF9, 0x6548, 0xFCFA, 0x6585, 0xFCFB, 0x66C9, 0xFCFC, 0x689F,\r\n\t0xFCFD, 0x6D8D, 0xFCFE, 0x6DC6, 0xFDA1, 0x723B, 0xFDA2, 0x80B4,\t0xFDA3, 0x9175, 0xFDA4, 0x9A4D, 0xFDA5, 0x4FAF, 0xFDA6, 0x5019,\r\n\t0xFDA7, 0x539A, 0xFDA8, 0x540E, 0xFDA9, 0x543C, 0xFDAA, 0x5589,\t0xFDAB, 0x55C5, 0xFDAC, 0x5E3F, 0xFDAD, 0x5F8C, 0xFDAE, 0x673D,\r\n\t0xFDAF, 0x7166, 0xFDB0, 0x73DD, 0xFDB1, 0x9005, 0xFDB2, 0x52DB,\t0xFDB3, 0x52F3, 0xFDB4, 0x5864, 0xFDB5, 0x58CE, 0xFDB6, 0x7104,\r\n\t0xFDB7, 0x718F, 0xFDB8, 0x71FB, 0xFDB9, 0x85B0, 0xFDBA, 0x8A13,\t0xFDBB, 0x6688, 0xFDBC, 0x85A8, 0xFDBD, 0x55A7, 0xFDBE, 0x6684,\r\n\t0xFDBF, 0x714A, 0xFDC0, 0x8431, 0xFDC1, 0x5349, 0xFDC2, 0x5599,\t0xFDC3, 0x6BC1, 0xFDC4, 0x5F59, 0xFDC5, 0x5FBD, 0xFDC6, 0x63EE,\r\n\t0xFDC7, 0x6689, 0xFDC8, 0x7147, 0xFDC9, 0x8AF1, 0xFDCA, 0x8F1D,\t0xFDCB, 0x9EBE, 0xFDCC, 0x4F11, 0xFDCD, 0x643A, 0xFDCE, 0x70CB,\r\n\t0xFDCF, 0x7566, 0xFDD0, 0x8667, 0xFDD1, 0x6064, 0xFDD2, 0x8B4E,\t0xFDD3, 0x9DF8, 0xFDD4, 0x5147, 0xFDD5, 0x51F6, 0xFDD6, 0x5308,\r\n\t0xFDD7, 0x6D36, 0xFDD8, 0x80F8, 0xFDD9, 0x9ED1, 0xFDDA, 0x6615,\t0xFDDB, 0x6B23, 0xFDDC, 0x7098, 0xFDDD, 0x75D5, 0xFDDE, 0x5403,\r\n\t0xFDDF, 0x5C79, 0xFDE0, 0x7D07, 0xFDE1, 0x8A16, 0xFDE2, 0x6B20,\t0xFDE3, 0x6B3D, 0xFDE4, 0x6B46, 0xFDE5, 0x5438, 0xFDE6, 0x6070,\r\n\t0xFDE7, 0x6D3D, 0xFDE8, 0x7FD5, 0xFDE9, 0x8208, 0xFDEA, 0x50D6,\t0xFDEB, 0x51DE, 0xFDEC, 0x559C, 0xFDED, 0x566B, 0xFDEE, 0x56CD,\r\n\t0xFDEF, 0x59EC, 0xFDF0, 0x5B09, 0xFDF1, 0x5E0C, 0xFDF2, 0x6199,\t0xFDF3, 0x6198, 0xFDF4, 0x6231, 0xFDF5, 0x665E, 0xFDF6, 0x66E6,\r\n\t0xFDF7, 0x7199, 0xFDF8, 0x71B9, 0xFDF9, 0x71BA, 0xFDFA, 0x72A7,\t0xFDFB, 0x79A7, 0xFDFC, 0x7A00, 0xFDFD, 0x7FB2, 0xFDFE, 0x8A70,\r\n\t0, 0\r\n};\r\n#endif\r\n\r\n#if FF_CODE_PAGE == 950 || FF_CODE_PAGE == 0\t/* Traditional Chinese */\r\nstatic const WCHAR uni2oem950[] = {\t/* Unicode --> Big5 pairs */\r\n\t0x00A7, 0xA1B1, 0x00AF, 0xA1C2, 0x00B0, 0xA258, 0x00B1, 0xA1D3,\t0x00B7, 0xA150, 0x00D7, 0xA1D1, 0x00F7, 0xA1D2, 0x02C7, 0xA3BE,\r\n\t0x02C9, 0xA3BC, 0x02CA, 0xA3BD, 0x02CB, 0xA3BF, 0x02CD, 0xA1C5,\t0x02D9, 0xA3BB, 0x0391, 0xA344, 0x0392, 0xA345, 0x0393, 0xA346,\r\n\t0x0394, 0xA347, 0x0395, 0xA348, 0x0396, 0xA349, 0x0397, 0xA34A,\t0x0398, 0xA34B, 0x0399, 0xA34C, 0x039A, 0xA34D, 0x039B, 0xA34E,\r\n\t0x039C, 0xA34F, 0x039D, 0xA350, 0x039E, 0xA351, 0x039F, 0xA352,\t0x03A0, 0xA353, 0x03A1, 0xA354, 0x03A3, 0xA355, 0x03A4, 0xA356,\r\n\t0x03A5, 0xA357, 0x03A6, 0xA358, 0x03A7, 0xA359, 0x03A8, 0xA35A,\t0x03A9, 0xA35B, 0x03B1, 0xA35C, 0x03B2, 0xA35D, 0x03B3, 0xA35E,\r\n\t0x03B4, 0xA35F, 0x03B5, 0xA360, 0x03B6, 0xA361, 0x03B7, 0xA362,\t0x03B8, 0xA363, 0x03B9, 0xA364, 0x03BA, 0xA365, 0x03BB, 0xA366,\r\n\t0x03BC, 0xA367, 0x03BD, 0xA368, 0x03BE, 0xA369, 0x03BF, 0xA36A,\t0x03C0, 0xA36B, 0x03C1, 0xA36C, 0x03C3, 0xA36D, 0x03C4, 0xA36E,\r\n\t0x03C5, 0xA36F, 0x03C6, 0xA370, 0x03C7, 0xA371, 0x03C8, 0xA372,\t0x03C9, 0xA373, 0x2013, 0xA156, 0x2014, 0xA158, 0x2018, 0xA1A5,\r\n\t0x2019, 0xA1A6, 0x201C, 0xA1A7, 0x201D, 0xA1A8, 0x2025, 0xA14C,\t0x2026, 0xA14B, 0x2027, 0xA145, 0x2032, 0xA1AC, 0x2035, 0xA1AB,\r\n\t0x203B, 0xA1B0, 0x20AC, 0xA3E1, 0x2103, 0xA24A, 0x2105, 0xA1C1,\t0x2109, 0xA24B, 0x2160, 0xA2B9, 0x2161, 0xA2BA, 0x2162, 0xA2BB,\r\n\t0x2163, 0xA2BC, 0x2164, 0xA2BD, 0x2165, 0xA2BE, 0x2166, 0xA2BF,\t0x2167, 0xA2C0, 0x2168, 0xA2C1, 0x2169, 0xA2C2, 0x2190, 0xA1F6,\r\n\t0x2191, 0xA1F4, 0x2192, 0xA1F7, 0x2193, 0xA1F5, 0x2196, 0xA1F8,\t0x2197, 0xA1F9, 0x2198, 0xA1FB, 0x2199, 0xA1FA, 0x2215, 0xA241,\r\n\t0x221A, 0xA1D4, 0x221E, 0xA1DB, 0x221F, 0xA1E8, 0x2220, 0xA1E7,\t0x2223, 0xA1FD, 0x2225, 0xA1FC, 0x2229, 0xA1E4, 0x222A, 0xA1E5,\r\n\t0x222B, 0xA1EC, 0x222E, 0xA1ED, 0x2234, 0xA1EF, 0x2235, 0xA1EE,\t0x2252, 0xA1DC, 0x2260, 0xA1DA, 0x2261, 0xA1DD, 0x2266, 0xA1D8,\r\n\t0x2267, 0xA1D9, 0x2295, 0xA1F2, 0x2299, 0xA1F3, 0x22A5, 0xA1E6,\t0x22BF, 0xA1E9, 0x2500, 0xA277, 0x2502, 0xA278, 0x250C, 0xA27A,\r\n\t0x2510, 0xA27B, 0x2514, 0xA27C, 0x2518, 0xA27D, 0x251C, 0xA275,\t0x2524, 0xA274, 0x252C, 0xA273, 0x2534, 0xA272, 0x253C, 0xA271,\r\n\t0x2550, 0xA2A4, 0x2550, 0xF9F9, 0x2551, 0xF9F8, 0x2552, 0xF9E6,\t0x2553, 0xF9EF, 0x2554, 0xF9DD, 0x2555, 0xF9E8, 0x2556, 0xF9F1,\r\n\t0x2557, 0xF9DF, 0x2558, 0xF9EC, 0x2559, 0xF9F5, 0x255A, 0xF9E3,\t0x255B, 0xF9EE, 0x255C, 0xF9F7, 0x255D, 0xF9E5, 0x255E, 0xA2A5,\r\n\t0x255E, 0xF9E9, 0x255F, 0xF9F2, 0x2560, 0xF9E0, 0x2561, 0xA2A7,\t0x2561, 0xF9EB, 0x2562, 0xF9F4, 0x2563, 0xF9E2, 0x2564, 0xF9E7,\r\n\t0x2565, 0xF9F0, 0x2566, 0xF9DE, 0x2567, 0xF9ED, 0x2568, 0xF9F6,\t0x2569, 0xF9E4, 0x256A, 0xA2A6, 0x256A, 0xF9EA, 0x256B, 0xF9F3,\r\n\t0x256C, 0xF9E1, 0x256D, 0xA27E, 0x256D, 0xF9FA, 0x256E, 0xA2A1,\t0x256E, 0xF9FB, 0x256F, 0xA2A3, 0x256F, 0xF9FD, 0x2570, 0xA2A2,\r\n\t0x2570, 0xF9FC, 0x2571, 0xA2AC, 0x2572, 0xA2AD, 0x2573, 0xA2AE,\t0x2574, 0xA15A, 0x2581, 0xA262, 0x2582, 0xA263, 0x2583, 0xA264,\r\n\t0x2584, 0xA265, 0x2585, 0xA266, 0x2586, 0xA267, 0x2587, 0xA268,\t0x2588, 0xA269, 0x2589, 0xA270, 0x258A, 0xA26F, 0x258B, 0xA26E,\r\n\t0x258C, 0xA26D, 0x258D, 0xA26C, 0x258E, 0xA26B, 0x258F, 0xA26A,\t0x2593, 0xF9FE, 0x2594, 0xA276, 0x2595, 0xA279, 0x25A0, 0xA1BD,\r\n\t0x25A1, 0xA1BC, 0x25B2, 0xA1B6, 0x25B3, 0xA1B5, 0x25BC, 0xA1BF,\t0x25BD, 0xA1BE, 0x25C6, 0xA1BB, 0x25C7, 0xA1BA, 0x25CB, 0xA1B3,\r\n\t0x25CE, 0xA1B7, 0x25CF, 0xA1B4, 0x25E2, 0xA2A8, 0x25E3, 0xA2A9,\t0x25E4, 0xA2AB, 0x25E5, 0xA2AA, 0x2605, 0xA1B9, 0x2606, 0xA1B8,\r\n\t0x2640, 0xA1F0, 0x2642, 0xA1F1, 0x3000, 0xA140, 0x3001, 0xA142,\t0x3002, 0xA143, 0x3003, 0xA1B2, 0x3008, 0xA171, 0x3009, 0xA172,\r\n\t0x300A, 0xA16D, 0x300B, 0xA16E, 0x300C, 0xA175, 0x300D, 0xA176,\t0x300E, 0xA179, 0x300F, 0xA17A, 0x3010, 0xA169, 0x3011, 0xA16A,\r\n\t0x3012, 0xA245, 0x3014, 0xA165, 0x3015, 0xA166, 0x301D, 0xA1A9,\t0x301E, 0xA1AA, 0x3021, 0xA2C3, 0x3022, 0xA2C4, 0x3023, 0xA2C5,\r\n\t0x3024, 0xA2C6, 0x3025, 0xA2C7, 0x3026, 0xA2C8, 0x3027, 0xA2C9,\t0x3028, 0xA2CA, 0x3029, 0xA2CB, 0x3105, 0xA374, 0x3106, 0xA375,\r\n\t0x3107, 0xA376, 0x3108, 0xA377, 0x3109, 0xA378, 0x310A, 0xA379,\t0x310B, 0xA37A, 0x310C, 0xA37B, 0x310D, 0xA37C, 0x310E, 0xA37D,\r\n\t0x310F, 0xA37E, 0x3110, 0xA3A1, 0x3111, 0xA3A2, 0x3112, 0xA3A3,\t0x3113, 0xA3A4, 0x3114, 0xA3A5, 0x3115, 0xA3A6, 0x3116, 0xA3A7,\r\n\t0x3117, 0xA3A8, 0x3118, 0xA3A9, 0x3119, 0xA3AA, 0x311A, 0xA3AB,\t0x311B, 0xA3AC, 0x311C, 0xA3AD, 0x311D, 0xA3AE, 0x311E, 0xA3AF,\r\n\t0x311F, 0xA3B0, 0x3120, 0xA3B1, 0x3121, 0xA3B2, 0x3122, 0xA3B3,\t0x3123, 0xA3B4, 0x3124, 0xA3B5, 0x3125, 0xA3B6, 0x3126, 0xA3B7,\r\n\t0x3127, 0xA3B8, 0x3128, 0xA3B9, 0x3129, 0xA3BA, 0x32A3, 0xA1C0,\t0x338E, 0xA255, 0x338F, 0xA256, 0x339C, 0xA250, 0x339D, 0xA251,\r\n\t0x339E, 0xA252, 0x33A1, 0xA254, 0x33C4, 0xA257, 0x33CE, 0xA253,\t0x33D1, 0xA1EB, 0x33D2, 0xA1EA, 0x33D5, 0xA24F, 0x4E00, 0xA440,\r\n\t0x4E01, 0xA442, 0x4E03, 0xA443, 0x4E07, 0xC945, 0x4E08, 0xA456,\t0x4E09, 0xA454, 0x4E0A, 0xA457, 0x4E0B, 0xA455, 0x4E0C, 0xC946,\r\n\t0x4E0D, 0xA4A3, 0x4E0E, 0xC94F, 0x4E0F, 0xC94D, 0x4E10, 0xA4A2,\t0x4E11, 0xA4A1, 0x4E14, 0xA542, 0x4E15, 0xA541, 0x4E16, 0xA540,\r\n\t0x4E18, 0xA543, 0x4E19, 0xA4FE, 0x4E1E, 0xA5E0, 0x4E1F, 0xA5E1,\t0x4E26, 0xA8C3, 0x4E2B, 0xA458, 0x4E2D, 0xA4A4, 0x4E2E, 0xC950,\r\n\t0x4E30, 0xA4A5, 0x4E31, 0xC963, 0x4E32, 0xA6EA, 0x4E33, 0xCBB1,\t0x4E38, 0xA459, 0x4E39, 0xA4A6, 0x4E3B, 0xA544, 0x4E3C, 0xC964,\r\n\t0x4E42, 0xC940, 0x4E43, 0xA444, 0x4E45, 0xA45B, 0x4E47, 0xC947,\t0x4E48, 0xA45C, 0x4E4B, 0xA4A7, 0x4E4D, 0xA545, 0x4E4E, 0xA547,\r\n\t0x4E4F, 0xA546, 0x4E52, 0xA5E2, 0x4E53, 0xA5E3, 0x4E56, 0xA8C4,\t0x4E58, 0xADBC, 0x4E59, 0xA441, 0x4E5C, 0xC941, 0x4E5D, 0xA445,\r\n\t0x4E5E, 0xA45E, 0x4E5F, 0xA45D, 0x4E69, 0xA5E4, 0x4E73, 0xA8C5,\t0x4E7E, 0xB0AE, 0x4E7F, 0xD44B, 0x4E82, 0xB6C3, 0x4E83, 0xDCB1,\r\n\t0x4E84, 0xDCB2, 0x4E86, 0xA446, 0x4E88, 0xA4A9, 0x4E8B, 0xA8C6,\t0x4E8C, 0xA447, 0x4E8D, 0xC948, 0x4E8E, 0xA45F, 0x4E91, 0xA4AA,\r\n\t0x4E92, 0xA4AC, 0x4E93, 0xC951, 0x4E94, 0xA4AD, 0x4E95, 0xA4AB,\t0x4E99, 0xA5E5, 0x4E9B, 0xA8C7, 0x4E9E, 0xA8C8, 0x4E9F, 0xAB45,\r\n\t0x4EA1, 0xA460, 0x4EA2, 0xA4AE, 0x4EA4, 0xA5E6, 0x4EA5, 0xA5E8,\t0x4EA6, 0xA5E7, 0x4EA8, 0xA6EB, 0x4EAB, 0xA8C9, 0x4EAC, 0xA8CA,\r\n\t0x4EAD, 0xAB46, 0x4EAE, 0xAB47, 0x4EB3, 0xADBD, 0x4EB6, 0xDCB3,\t0x4EB9, 0xF6D6, 0x4EBA, 0xA448, 0x4EC0, 0xA4B0, 0x4EC1, 0xA4AF,\r\n\t0x4EC2, 0xC952, 0x4EC3, 0xA4B1, 0x4EC4, 0xA4B7, 0x4EC6, 0xA4B2,\t0x4EC7, 0xA4B3, 0x4EC8, 0xC954, 0x4EC9, 0xC953, 0x4ECA, 0xA4B5,\r\n\t0x4ECB, 0xA4B6, 0x4ECD, 0xA4B4, 0x4ED4, 0xA54A, 0x4ED5, 0xA54B,\t0x4ED6, 0xA54C, 0x4ED7, 0xA54D, 0x4ED8, 0xA549, 0x4ED9, 0xA550,\r\n\t0x4EDA, 0xC96A, 0x4EDC, 0xC966, 0x4EDD, 0xC969, 0x4EDE, 0xA551,\t0x4EDF, 0xA561, 0x4EE1, 0xC968, 0x4EE3, 0xA54E, 0x4EE4, 0xA54F,\r\n\t0x4EE5, 0xA548, 0x4EE8, 0xC965, 0x4EE9, 0xC967, 0x4EF0, 0xA5F5,\t0x4EF1, 0xC9B0, 0x4EF2, 0xA5F2, 0x4EF3, 0xA5F6, 0x4EF4, 0xC9BA,\r\n\t0x4EF5, 0xC9AE, 0x4EF6, 0xA5F3, 0x4EF7, 0xC9B2, 0x4EFB, 0xA5F4,\t0x4EFD, 0xA5F7, 0x4EFF, 0xA5E9, 0x4F00, 0xC9B1, 0x4F01, 0xA5F8,\r\n\t0x4F02, 0xC9B5, 0x4F04, 0xC9B9, 0x4F05, 0xC9B6, 0x4F08, 0xC9B3,\t0x4F09, 0xA5EA, 0x4F0A, 0xA5EC, 0x4F0B, 0xA5F9, 0x4F0D, 0xA5EE,\r\n\t0x4F0E, 0xC9AB, 0x4F0F, 0xA5F1, 0x4F10, 0xA5EF, 0x4F11, 0xA5F0,\t0x4F12, 0xC9BB, 0x4F13, 0xC9B8, 0x4F14, 0xC9AF, 0x4F15, 0xA5ED,\r\n\t0x4F18, 0xC9AC, 0x4F19, 0xA5EB, 0x4F1D, 0xC9B4, 0x4F22, 0xC9B7,\t0x4F2C, 0xC9AD, 0x4F2D, 0xCA66, 0x4F2F, 0xA742, 0x4F30, 0xA6F4,\r\n\t0x4F33, 0xCA67, 0x4F34, 0xA6F1, 0x4F36, 0xA744, 0x4F38, 0xA6F9,\t0x4F3A, 0xA6F8, 0x4F3B, 0xCA5B, 0x4F3C, 0xA6FC, 0x4F3D, 0xA6F7,\r\n\t0x4F3E, 0xCA60, 0x4F3F, 0xCA68, 0x4F41, 0xCA64, 0x4F43, 0xA6FA,\t0x4F46, 0xA6FD, 0x4F47, 0xA6EE, 0x4F48, 0xA747, 0x4F49, 0xCA5D,\r\n\t0x4F4C, 0xCBBD, 0x4F4D, 0xA6EC, 0x4F4E, 0xA743, 0x4F4F, 0xA6ED,\t0x4F50, 0xA6F5, 0x4F51, 0xA6F6, 0x4F52, 0xCA62, 0x4F53, 0xCA5E,\r\n\t0x4F54, 0xA6FB, 0x4F55, 0xA6F3, 0x4F56, 0xCA5A, 0x4F57, 0xA6EF,\t0x4F58, 0xCA65, 0x4F59, 0xA745, 0x4F5A, 0xA748, 0x4F5B, 0xA6F2,\r\n\t0x4F5C, 0xA740, 0x4F5D, 0xA746, 0x4F5E, 0xA6F0, 0x4F5F, 0xCA63,\t0x4F60, 0xA741, 0x4F61, 0xCA69, 0x4F62, 0xCA5C, 0x4F63, 0xA6FE,\r\n\t0x4F64, 0xCA5F, 0x4F67, 0xCA61, 0x4F69, 0xA8D8, 0x4F6A, 0xCBBF,\t0x4F6B, 0xCBCB, 0x4F6C, 0xA8D0, 0x4F6E, 0xCBCC, 0x4F6F, 0xA8CB,\r\n\t0x4F70, 0xA8D5, 0x4F73, 0xA8CE, 0x4F74, 0xCBB9, 0x4F75, 0xA8D6,\t0x4F76, 0xCBB8, 0x4F77, 0xCBBC, 0x4F78, 0xCBC3, 0x4F79, 0xCBC1,\r\n\t0x4F7A, 0xA8DE, 0x4F7B, 0xA8D9, 0x4F7C, 0xCBB3, 0x4F7D, 0xCBB5,\t0x4F7E, 0xA8DB, 0x4F7F, 0xA8CF, 0x4F80, 0xCBB6, 0x4F81, 0xCBC2,\r\n\t0x4F82, 0xCBC9, 0x4F83, 0xA8D4, 0x4F84, 0xCBBB, 0x4F85, 0xCBB4,\t0x4F86, 0xA8D3, 0x4F87, 0xCBB7, 0x4F88, 0xA8D7, 0x4F89, 0xCBBA,\r\n\t0x4F8B, 0xA8D2, 0x4F8D, 0xA8CD, 0x4F8F, 0xA8DC, 0x4F90, 0xCBC4,\t0x4F91, 0xA8DD, 0x4F92, 0xCBC8, 0x4F94, 0xCBC6, 0x4F95, 0xCBCA,\r\n\t0x4F96, 0xA8DA, 0x4F97, 0xCBBE, 0x4F98, 0xCBB2, 0x4F9A, 0xCBC0,\t0x4F9B, 0xA8D1, 0x4F9C, 0xCBC5, 0x4F9D, 0xA8CC, 0x4F9E, 0xCBC7,\r\n\t0x4FAE, 0xAB56, 0x4FAF, 0xAB4A, 0x4FB2, 0xCDE0, 0x4FB3, 0xCDE8,\t0x4FB5, 0xAB49, 0x4FB6, 0xAB51, 0x4FB7, 0xAB5D, 0x4FB9, 0xCDEE,\r\n\t0x4FBA, 0xCDEC, 0x4FBB, 0xCDE7, 0x4FBF, 0xAB4B, 0x4FC0, 0xCDED,\t0x4FC1, 0xCDE3, 0x4FC2, 0xAB59, 0x4FC3, 0xAB50, 0x4FC4, 0xAB58,\r\n\t0x4FC5, 0xCDDE, 0x4FC7, 0xCDEA, 0x4FC9, 0xCDE1, 0x4FCA, 0xAB54,\t0x4FCB, 0xCDE2, 0x4FCD, 0xCDDD, 0x4FCE, 0xAB5B, 0x4FCF, 0xAB4E,\r\n\t0x4FD0, 0xAB57, 0x4FD1, 0xAB4D, 0x4FD3, 0xCDDF, 0x4FD4, 0xCDE4,\t0x4FD6, 0xCDEB, 0x4FD7, 0xAB55, 0x4FD8, 0xAB52, 0x4FD9, 0xCDE6,\r\n\t0x4FDA, 0xAB5A, 0x4FDB, 0xCDE9, 0x4FDC, 0xCDE5, 0x4FDD, 0xAB4F,\t0x4FDE, 0xAB5C, 0x4FDF, 0xAB53, 0x4FE0, 0xAB4C, 0x4FE1, 0xAB48,\r\n\t0x4FEC, 0xCDEF, 0x4FEE, 0xADD7, 0x4FEF, 0xADC1, 0x4FF1, 0xADD1,\t0x4FF3, 0xADD6, 0x4FF4, 0xD0D0, 0x4FF5, 0xD0CF, 0x4FF6, 0xD0D4,\r\n\t0x4FF7, 0xD0D5, 0x4FF8, 0xADC4, 0x4FFA, 0xADCD, 0x4FFE, 0xADDA,\t0x5000, 0xADCE, 0x5005, 0xD0C9, 0x5006, 0xADC7, 0x5007, 0xD0CA,\r\n\t0x5009, 0xADDC, 0x500B, 0xADD3, 0x500C, 0xADBE, 0x500D, 0xADBF,\t0x500E, 0xD0DD, 0x500F, 0xB0BF, 0x5011, 0xADCC, 0x5012, 0xADCB,\r\n\t0x5013, 0xD0CB, 0x5014, 0xADCF, 0x5015, 0xD45B, 0x5016, 0xADC6,\t0x5017, 0xD0D6, 0x5018, 0xADD5, 0x5019, 0xADD4, 0x501A, 0xADCA,\r\n\t0x501B, 0xD0CE, 0x501C, 0xD0D7, 0x501E, 0xD0C8, 0x501F, 0xADC9,\t0x5020, 0xD0D8, 0x5021, 0xADD2, 0x5022, 0xD0CC, 0x5023, 0xADC0,\r\n\t0x5025, 0xADC3, 0x5026, 0xADC2, 0x5027, 0xD0D9, 0x5028, 0xADD0,\t0x5029, 0xADC5, 0x502A, 0xADD9, 0x502B, 0xADDB, 0x502C, 0xD0D3,\r\n\t0x502D, 0xADD8, 0x502F, 0xD0DB, 0x5030, 0xD0CD, 0x5031, 0xD0DC,\t0x5033, 0xD0D1, 0x5035, 0xD0DA, 0x5037, 0xD0D2, 0x503C, 0xADC8,\r\n\t0x5040, 0xD463, 0x5041, 0xD457, 0x5043, 0xB0B3, 0x5045, 0xD45C,\t0x5046, 0xD462, 0x5047, 0xB0B2, 0x5048, 0xD455, 0x5049, 0xB0B6,\r\n\t0x504A, 0xD459, 0x504B, 0xD452, 0x504C, 0xB0B4, 0x504D, 0xD456,\t0x504E, 0xB0B9, 0x504F, 0xB0BE, 0x5051, 0xD467, 0x5053, 0xD451,\r\n\t0x5055, 0xB0BA, 0x5057, 0xD466, 0x505A, 0xB0B5, 0x505B, 0xD458,\t0x505C, 0xB0B1, 0x505D, 0xD453, 0x505E, 0xD44F, 0x505F, 0xD45D,\r\n\t0x5060, 0xD450, 0x5061, 0xD44E, 0x5062, 0xD45A, 0x5063, 0xD460,\t0x5064, 0xD461, 0x5065, 0xB0B7, 0x5068, 0xD85B, 0x5069, 0xD45E,\r\n\t0x506A, 0xD44D, 0x506B, 0xD45F, 0x506D, 0xB0C1, 0x506E, 0xD464,\t0x506F, 0xB0C0, 0x5070, 0xD44C, 0x5072, 0xD454, 0x5073, 0xD465,\r\n\t0x5074, 0xB0BC, 0x5075, 0xB0BB, 0x5076, 0xB0B8, 0x5077, 0xB0BD,\t0x507A, 0xB0AF, 0x507D, 0xB0B0, 0x5080, 0xB3C8, 0x5082, 0xD85E,\r\n\t0x5083, 0xD857, 0x5085, 0xB3C5, 0x5087, 0xD85F, 0x508B, 0xD855,\t0x508C, 0xD858, 0x508D, 0xB3C4, 0x508E, 0xD859, 0x5091, 0xB3C7,\r\n\t0x5092, 0xD85D, 0x5094, 0xD853, 0x5095, 0xD852, 0x5096, 0xB3C9,\t0x5098, 0xB3CA, 0x5099, 0xB3C6, 0x509A, 0xB3CB, 0x509B, 0xD851,\r\n\t0x509C, 0xD85C, 0x509D, 0xD85A, 0x509E, 0xD854, 0x50A2, 0xB3C3,\t0x50A3, 0xD856, 0x50AC, 0xB6CA, 0x50AD, 0xB6C4, 0x50AE, 0xDCB7,\r\n\t0x50AF, 0xB6CD, 0x50B0, 0xDCBD, 0x50B1, 0xDCC0, 0x50B2, 0xB6C6,\t0x50B3, 0xB6C7, 0x50B4, 0xDCBA, 0x50B5, 0xB6C5, 0x50B6, 0xDCC3,\r\n\t0x50B7, 0xB6CB, 0x50B8, 0xDCC4, 0x50BA, 0xDCBF, 0x50BB, 0xB6CC,\t0x50BD, 0xDCB4, 0x50BE, 0xB6C9, 0x50BF, 0xDCB5, 0x50C1, 0xDCBE,\r\n\t0x50C2, 0xDCBC, 0x50C4, 0xDCB8, 0x50C5, 0xB6C8, 0x50C6, 0xDCB6,\t0x50C7, 0xB6CE, 0x50C8, 0xDCBB, 0x50C9, 0xDCC2, 0x50CA, 0xDCB9,\r\n\t0x50CB, 0xDCC1, 0x50CE, 0xB9B6, 0x50CF, 0xB9B3, 0x50D1, 0xB9B4,\t0x50D3, 0xE0F9, 0x50D4, 0xE0F1, 0x50D5, 0xB9B2, 0x50D6, 0xB9AF,\r\n\t0x50D7, 0xE0F2, 0x50DA, 0xB9B1, 0x50DB, 0xE0F5, 0x50DD, 0xE0F7,\t0x50E0, 0xE0FE, 0x50E3, 0xE0FD, 0x50E4, 0xE0F8, 0x50E5, 0xB9AE,\r\n\t0x50E6, 0xE0F0, 0x50E7, 0xB9AC, 0x50E8, 0xE0F3, 0x50E9, 0xB9B7,\t0x50EA, 0xE0F6, 0x50EC, 0xE0FA, 0x50ED, 0xB9B0, 0x50EE, 0xB9AD,\r\n\t0x50EF, 0xE0FC, 0x50F0, 0xE0FB, 0x50F1, 0xB9B5, 0x50F3, 0xE0F4,\t0x50F5, 0xBBF8, 0x50F6, 0xE4EC, 0x50F8, 0xE4E9, 0x50F9, 0xBBF9,\r\n\t0x50FB, 0xBBF7, 0x50FD, 0xE4F0, 0x50FE, 0xE4ED, 0x50FF, 0xE4E6,\t0x5100, 0xBBF6, 0x5102, 0xBBFA, 0x5103, 0xE4E7, 0x5104, 0xBBF5,\r\n\t0x5105, 0xBBFD, 0x5106, 0xE4EA, 0x5107, 0xE4EB, 0x5108, 0xBBFB,\t0x5109, 0xBBFC, 0x510A, 0xE4F1, 0x510B, 0xE4EE, 0x510C, 0xE4EF,\r\n\t0x5110, 0xBEAA, 0x5111, 0xE8F8, 0x5112, 0xBEA7, 0x5113, 0xE8F5,\t0x5114, 0xBEA9, 0x5115, 0xBEAB, 0x5117, 0xE8F6, 0x5118, 0xBEA8,\r\n\t0x511A, 0xE8F7, 0x511C, 0xE8F4, 0x511F, 0xC076, 0x5120, 0xECBD,\t0x5121, 0xC077, 0x5122, 0xECBB, 0x5124, 0xECBC, 0x5125, 0xECBA,\r\n\t0x5126, 0xECB9, 0x5129, 0xECBE, 0x512A, 0xC075, 0x512D, 0xEFB8,\t0x512E, 0xEFB9, 0x5130, 0xE4E8, 0x5131, 0xEFB7, 0x5132, 0xC078,\r\n\t0x5133, 0xC35F, 0x5134, 0xF1EB, 0x5135, 0xF1EC, 0x5137, 0xC4D7,\t0x5138, 0xC4D8, 0x5139, 0xF5C1, 0x513A, 0xF5C0, 0x513B, 0xC56C,\r\n\t0x513C, 0xC56B, 0x513D, 0xF7D0, 0x513F, 0xA449, 0x5140, 0xA461,\t0x5141, 0xA4B9, 0x5143, 0xA4B8, 0x5144, 0xA553, 0x5145, 0xA552,\r\n\t0x5146, 0xA5FC, 0x5147, 0xA5FB, 0x5148, 0xA5FD, 0x5149, 0xA5FA,\t0x514B, 0xA74A, 0x514C, 0xA749, 0x514D, 0xA74B, 0x5152, 0xA8E0,\r\n\t0x5154, 0xA8DF, 0x5155, 0xA8E1, 0x5157, 0xAB5E, 0x5159, 0xA259,\t0x515A, 0xD0DE, 0x515B, 0xA25A, 0x515C, 0xB0C2, 0x515D, 0xA25C,\r\n\t0x515E, 0xA25B, 0x515F, 0xD860, 0x5161, 0xA25D, 0x5162, 0xB9B8,\t0x5163, 0xA25E, 0x5165, 0xA44A, 0x5167, 0xA4BA, 0x5168, 0xA5FE,\r\n\t0x5169, 0xA8E2, 0x516B, 0xA44B, 0x516C, 0xA4BD, 0x516D, 0xA4BB,\t0x516E, 0xA4BC, 0x5171, 0xA640, 0x5175, 0xA74C, 0x5176, 0xA8E4,\r\n\t0x5177, 0xA8E3, 0x5178, 0xA8E5, 0x517C, 0xADDD, 0x5180, 0xBEAC,\t0x5187, 0xC94E, 0x5189, 0xA554, 0x518A, 0xA555, 0x518D, 0xA641,\r\n\t0x518F, 0xCA6A, 0x5191, 0xAB60, 0x5192, 0xAB5F, 0x5193, 0xD0E0,\t0x5194, 0xD0DF, 0x5195, 0xB0C3, 0x5197, 0xA4BE, 0x5198, 0xC955,\r\n\t0x519E, 0xCBCD, 0x51A0, 0xAB61, 0x51A2, 0xADE0, 0x51A4, 0xADDE,\t0x51A5, 0xADDF, 0x51AA, 0xBEAD, 0x51AC, 0xA556, 0x51B0, 0xA642,\r\n\t0x51B1, 0xC9BC, 0x51B6, 0xA74D, 0x51B7, 0xA74E, 0x51B9, 0xCA6B,\t0x51BC, 0xCBCE, 0x51BD, 0xA8E6, 0x51BE, 0xCBCF, 0x51C4, 0xD0E2,\r\n\t0x51C5, 0xD0E3, 0x51C6, 0xADE3, 0x51C8, 0xD0E4, 0x51CA, 0xD0E1,\t0x51CB, 0xADE4, 0x51CC, 0xADE2, 0x51CD, 0xADE1, 0x51CE, 0xD0E5,\r\n\t0x51D0, 0xD468, 0x51D4, 0xD861, 0x51D7, 0xDCC5, 0x51D8, 0xE140,\t0x51DC, 0xBBFE, 0x51DD, 0xBEAE, 0x51DE, 0xE8F9, 0x51E0, 0xA44C,\r\n\t0x51E1, 0xA45A, 0x51F0, 0xB0C4, 0x51F1, 0xB3CD, 0x51F3, 0xB9B9,\t0x51F5, 0xC942, 0x51F6, 0xA4BF, 0x51F8, 0xA559, 0x51F9, 0xA557,\r\n\t0x51FA, 0xA558, 0x51FD, 0xA8E7, 0x5200, 0xA44D, 0x5201, 0xA44E,\t0x5203, 0xA462, 0x5206, 0xA4C0, 0x5207, 0xA4C1, 0x5208, 0xA4C2,\r\n\t0x5209, 0xC9BE, 0x520A, 0xA55A, 0x520C, 0xC96B, 0x520E, 0xA646,\t0x5210, 0xC9BF, 0x5211, 0xA644, 0x5212, 0xA645, 0x5213, 0xC9BD,\r\n\t0x5216, 0xA647, 0x5217, 0xA643, 0x521C, 0xCA6C, 0x521D, 0xAAEC,\t0x521E, 0xCA6D, 0x5221, 0xCA6E, 0x5224, 0xA750, 0x5225, 0xA74F,\r\n\t0x5228, 0xA753, 0x5229, 0xA751, 0x522A, 0xA752, 0x522E, 0xA8ED,\t0x5230, 0xA8EC, 0x5231, 0xCBD4, 0x5232, 0xCBD1, 0x5233, 0xCBD2,\r\n\t0x5235, 0xCBD0, 0x5236, 0xA8EE, 0x5237, 0xA8EA, 0x5238, 0xA8E9,\t0x523A, 0xA8EB, 0x523B, 0xA8E8, 0x5241, 0xA8EF, 0x5243, 0xAB63,\r\n\t0x5244, 0xCDF0, 0x5246, 0xCBD3, 0x5247, 0xAB68, 0x5249, 0xCDF1,\t0x524A, 0xAB64, 0x524B, 0xAB67, 0x524C, 0xAB66, 0x524D, 0xAB65,\r\n\t0x524E, 0xAB62, 0x5252, 0xD0E8, 0x5254, 0xADE7, 0x5255, 0xD0EB,\t0x5256, 0xADE5, 0x525A, 0xD0E7, 0x525B, 0xADE8, 0x525C, 0xADE6,\r\n\t0x525D, 0xADE9, 0x525E, 0xD0E9, 0x525F, 0xD0EA, 0x5261, 0xD0E6,\t0x5262, 0xD0EC, 0x5269, 0xB3D1, 0x526A, 0xB0C5, 0x526B, 0xD469,\r\n\t0x526C, 0xD46B, 0x526D, 0xD46A, 0x526E, 0xD46C, 0x526F, 0xB0C6,\t0x5272, 0xB3CE, 0x5274, 0xB3CF, 0x5275, 0xB3D0, 0x5277, 0xB6D0,\r\n\t0x5278, 0xDCC7, 0x527A, 0xDCC6, 0x527B, 0xDCC8, 0x527C, 0xDCC9,\t0x527D, 0xB6D1, 0x527F, 0xB6CF, 0x5280, 0xE141, 0x5281, 0xE142,\r\n\t0x5282, 0xB9BB, 0x5283, 0xB9BA, 0x5284, 0xE35A, 0x5287, 0xBC40,\t0x5288, 0xBC41, 0x5289, 0xBC42, 0x528A, 0xBC44, 0x528B, 0xE4F2,\r\n\t0x528C, 0xE4F3, 0x528D, 0xBC43, 0x5291, 0xBEAF, 0x5293, 0xBEB0,\t0x5296, 0xF1ED, 0x5297, 0xF5C3, 0x5298, 0xF5C2, 0x5299, 0xF7D1,\r\n\t0x529B, 0xA44F, 0x529F, 0xA55C, 0x52A0, 0xA55B, 0x52A3, 0xA648,\t0x52A6, 0xC9C0, 0x52A9, 0xA755, 0x52AA, 0xA756, 0x52AB, 0xA754,\r\n\t0x52AC, 0xA757, 0x52AD, 0xCA6F, 0x52AE, 0xCA70, 0x52BB, 0xA8F1,\t0x52BC, 0xCBD5, 0x52BE, 0xA8F0, 0x52C0, 0xCDF2, 0x52C1, 0xAB6C,\r\n\t0x52C2, 0xCDF3, 0x52C3, 0xAB6B, 0x52C7, 0xAB69, 0x52C9, 0xAB6A,\t0x52CD, 0xD0ED, 0x52D2, 0xB0C7, 0x52D3, 0xD46E, 0x52D5, 0xB0CA,\r\n\t0x52D6, 0xD46D, 0x52D7, 0xB1E5, 0x52D8, 0xB0C9, 0x52D9, 0xB0C8,\t0x52DB, 0xB3D4, 0x52DD, 0xB3D3, 0x52DE, 0xB3D2, 0x52DF, 0xB6D2,\r\n\t0x52E2, 0xB6D5, 0x52E3, 0xB6D6, 0x52E4, 0xB6D4, 0x52E6, 0xB6D3,\t0x52E9, 0xE143, 0x52EB, 0xE144, 0x52EF, 0xE4F5, 0x52F0, 0xBC45,\r\n\t0x52F1, 0xE4F4, 0x52F3, 0xBEB1, 0x52F4, 0xECBF, 0x52F5, 0xC079,\t0x52F7, 0xF1EE, 0x52F8, 0xC455, 0x52FA, 0xA463, 0x52FB, 0xA4C3,\r\n\t0x52FC, 0xC956, 0x52FE, 0xA4C4, 0x52FF, 0xA4C5, 0x5305, 0xA55D,\t0x5306, 0xA55E, 0x5308, 0xA649, 0x5309, 0xCA71, 0x530A, 0xCBD6,\r\n\t0x530B, 0xCBD7, 0x530D, 0xAB6D, 0x530E, 0xD0EE, 0x530F, 0xB0CC,\t0x5310, 0xB0CB, 0x5311, 0xD863, 0x5312, 0xD862, 0x5315, 0xA450,\r\n\t0x5316, 0xA4C6, 0x5317, 0xA55F, 0x5319, 0xB0CD, 0x531A, 0xC943,\t0x531C, 0xC96C, 0x531D, 0xA560, 0x531F, 0xC9C2, 0x5320, 0xA64B,\r\n\t0x5321, 0xA64A, 0x5322, 0xC9C1, 0x5323, 0xA758, 0x532A, 0xADEA,\t0x532D, 0xD46F, 0x532F, 0xB6D7, 0x5330, 0xE145, 0x5331, 0xB9BC,\r\n\t0x5334, 0xE8FA, 0x5337, 0xF3FD, 0x5339, 0xA4C7, 0x533C, 0xCBD8,\t0x533D, 0xCDF4, 0x533E, 0xB0D0, 0x533F, 0xB0CE, 0x5340, 0xB0CF,\r\n\t0x5341, 0xA2CC, 0x5341, 0xA451, 0x5343, 0xA464, 0x5344, 0xA2CD,\t0x5345, 0xA2CE, 0x5345, 0xA4CA, 0x5347, 0xA4C9, 0x5348, 0xA4C8,\r\n\t0x5349, 0xA563, 0x534A, 0xA562, 0x534C, 0xC96D, 0x534D, 0xC9C3,\t0x5351, 0xA8F5, 0x5352, 0xA8F2, 0x5353, 0xA8F4, 0x5354, 0xA8F3,\r\n\t0x5357, 0xAB6E, 0x535A, 0xB3D5, 0x535C, 0xA452, 0x535E, 0xA4CB,\t0x5360, 0xA565, 0x5361, 0xA564, 0x5363, 0xCA72, 0x5366, 0xA8F6,\r\n\t0x536C, 0xC957, 0x536E, 0xA567, 0x536F, 0xA566, 0x5370, 0xA64C,\t0x5371, 0xA64D, 0x5372, 0xCA73, 0x5373, 0xA759, 0x5375, 0xA75A,\r\n\t0x5377, 0xA8F7, 0x5378, 0xA8F8, 0x5379, 0xA8F9, 0x537B, 0xAB6F,\t0x537C, 0xCDF5, 0x537F, 0xADEB, 0x5382, 0xC944, 0x5384, 0xA4CC,\r\n\t0x538A, 0xC9C4, 0x538E, 0xCA74, 0x538F, 0xCA75, 0x5392, 0xCBD9,\t0x5394, 0xCBDA, 0x5396, 0xCDF7, 0x5397, 0xCDF6, 0x5398, 0xCDF9,\r\n\t0x5399, 0xCDF8, 0x539A, 0xAB70, 0x539C, 0xD470, 0x539D, 0xADED,\t0x539E, 0xD0EF, 0x539F, 0xADEC, 0x53A4, 0xD864, 0x53A5, 0xB3D6,\r\n\t0x53A7, 0xD865, 0x53AC, 0xE146, 0x53AD, 0xB9BD, 0x53B2, 0xBC46,\t0x53B4, 0xF1EF, 0x53B9, 0xC958, 0x53BB, 0xA568, 0x53C3, 0xB0D1,\r\n\t0x53C8, 0xA453, 0x53C9, 0xA465, 0x53CA, 0xA4CE, 0x53CB, 0xA4CD,\t0x53CD, 0xA4CF, 0x53D4, 0xA8FB, 0x53D6, 0xA8FA, 0x53D7, 0xA8FC,\r\n\t0x53DB, 0xAB71, 0x53DF, 0xADEE, 0x53E1, 0xE8FB, 0x53E2, 0xC24F,\t0x53E3, 0xA466, 0x53E4, 0xA56A, 0x53E5, 0xA579, 0x53E6, 0xA574,\r\n\t0x53E8, 0xA56F, 0x53E9, 0xA56E, 0x53EA, 0xA575, 0x53EB, 0xA573,\t0x53EC, 0xA56C, 0x53ED, 0xA57A, 0x53EE, 0xA56D, 0x53EF, 0xA569,\r\n\t0x53F0, 0xA578, 0x53F1, 0xA577, 0x53F2, 0xA576, 0x53F3, 0xA56B,\t0x53F5, 0xA572, 0x53F8, 0xA571, 0x53FB, 0xA57B, 0x53FC, 0xA570,\r\n\t0x5401, 0xA653, 0x5403, 0xA659, 0x5404, 0xA655, 0x5406, 0xA65B,\t0x5407, 0xC9C5, 0x5408, 0xA658, 0x5409, 0xA64E, 0x540A, 0xA651,\r\n\t0x540B, 0xA654, 0x540C, 0xA650, 0x540D, 0xA657, 0x540E, 0xA65A,\t0x540F, 0xA64F, 0x5410, 0xA652, 0x5411, 0xA656, 0x5412, 0xA65C,\r\n\t0x5418, 0xCA7E, 0x5419, 0xCA7B, 0x541B, 0xA767, 0x541C, 0xCA7C,\t0x541D, 0xA75B, 0x541E, 0xA75D, 0x541F, 0xA775, 0x5420, 0xA770,\r\n\t0x5424, 0xCAA5, 0x5425, 0xCA7D, 0x5426, 0xA75F, 0x5427, 0xA761,\t0x5428, 0xCAA4, 0x5429, 0xA768, 0x542A, 0xCA78, 0x542B, 0xA774,\r\n\t0x542C, 0xA776, 0x542D, 0xA75C, 0x542E, 0xA76D, 0x5430, 0xCA76,\t0x5431, 0xA773, 0x5433, 0xA764, 0x5435, 0xA76E, 0x5436, 0xA76F,\r\n\t0x5437, 0xCA77, 0x5438, 0xA76C, 0x5439, 0xA76A, 0x543B, 0xA76B,\t0x543C, 0xA771, 0x543D, 0xCAA1, 0x543E, 0xA75E, 0x5440, 0xA772,\r\n\t0x5441, 0xCAA3, 0x5442, 0xA766, 0x5443, 0xA763, 0x5445, 0xCA7A,\t0x5446, 0xA762, 0x5447, 0xCAA6, 0x5448, 0xA765, 0x544A, 0xA769,\r\n\t0x544E, 0xA760, 0x544F, 0xCAA2, 0x5454, 0xCA79, 0x5460, 0xCBEB,\t0x5461, 0xCBEA, 0x5462, 0xA94F, 0x5463, 0xCBED, 0x5464, 0xCBEF,\r\n\t0x5465, 0xCBE4, 0x5466, 0xCBE7, 0x5467, 0xCBEE, 0x5468, 0xA950,\t0x546B, 0xCBE1, 0x546C, 0xCBE5, 0x546F, 0xCBE9, 0x5470, 0xCE49,\r\n\t0x5471, 0xA94B, 0x5472, 0xCE4D, 0x5473, 0xA8FD, 0x5474, 0xCBE6,\t0x5475, 0xA8FE, 0x5476, 0xA94C, 0x5477, 0xA945, 0x5478, 0xA941,\r\n\t0x547A, 0xCBE2, 0x547B, 0xA944, 0x547C, 0xA949, 0x547D, 0xA952,\t0x547E, 0xCBE3, 0x547F, 0xCBDC, 0x5480, 0xA943, 0x5481, 0xCBDD,\r\n\t0x5482, 0xCBDF, 0x5484, 0xA946, 0x5486, 0xA948, 0x5487, 0xCBDB,\t0x5488, 0xCBE0, 0x548B, 0xA951, 0x548C, 0xA94D, 0x548D, 0xCBE8,\r\n\t0x548E, 0xA953, 0x5490, 0xA94A, 0x5491, 0xCBDE, 0x5492, 0xA947,\t0x5495, 0xA942, 0x5496, 0xA940, 0x5498, 0xCBEC, 0x549A, 0xA94E,\r\n\t0x54A0, 0xCE48, 0x54A1, 0xCDFB, 0x54A2, 0xCE4B, 0x54A5, 0xCDFD,\t0x54A6, 0xAB78, 0x54A7, 0xABA8, 0x54A8, 0xAB74, 0x54A9, 0xABA7,\r\n\t0x54AA, 0xAB7D, 0x54AB, 0xABA4, 0x54AC, 0xAB72, 0x54AD, 0xCDFC,\t0x54AE, 0xCE43, 0x54AF, 0xABA3, 0x54B0, 0xCE4F, 0x54B1, 0xABA5,\r\n\t0x54B3, 0xAB79, 0x54B6, 0xCE45, 0x54B7, 0xCE42, 0x54B8, 0xAB77,\t0x54BA, 0xCDFA, 0x54BB, 0xABA6, 0x54BC, 0xCE4A, 0x54BD, 0xAB7C,\r\n\t0x54BE, 0xCE4C, 0x54BF, 0xABA9, 0x54C0, 0xAB73, 0x54C1, 0xAB7E,\t0x54C2, 0xAB7B, 0x54C3, 0xCE40, 0x54C4, 0xABA1, 0x54C5, 0xCE46,\r\n\t0x54C6, 0xCE47, 0x54C7, 0xAB7A, 0x54C8, 0xABA2, 0x54C9, 0xAB76,\t0x54CE, 0xAB75, 0x54CF, 0xCDFE, 0x54D6, 0xCE44, 0x54DE, 0xCE4E,\r\n\t0x54E0, 0xD144, 0x54E1, 0xADFB, 0x54E2, 0xD0F1, 0x54E4, 0xD0F6,\t0x54E5, 0xADF4, 0x54E6, 0xAE40, 0x54E7, 0xD0F4, 0x54E8, 0xADEF,\r\n\t0x54E9, 0xADF9, 0x54EA, 0xADFE, 0x54EB, 0xD0FB, 0x54ED, 0xADFA,\t0x54EE, 0xADFD, 0x54F1, 0xD0FE, 0x54F2, 0xADF5, 0x54F3, 0xD0F5,\r\n\t0x54F7, 0xD142, 0x54F8, 0xD143, 0x54FA, 0xADF7, 0x54FB, 0xD141,\t0x54FC, 0xADF3, 0x54FD, 0xAE43, 0x54FF, 0xD0F8, 0x5501, 0xADF1,\r\n\t0x5503, 0xD146, 0x5504, 0xD0F9, 0x5505, 0xD0FD, 0x5506, 0xADF6,\t0x5507, 0xAE42, 0x5508, 0xD0FA, 0x5509, 0xADFC, 0x550A, 0xD140,\r\n\t0x550B, 0xD147, 0x550C, 0xD4A1, 0x550E, 0xD145, 0x550F, 0xAE44,\t0x5510, 0xADF0, 0x5511, 0xD0FC, 0x5512, 0xD0F3, 0x5514, 0xADF8,\r\n\t0x5517, 0xD0F2, 0x551A, 0xD0F7, 0x5526, 0xD0F0, 0x5527, 0xAE41,\t0x552A, 0xD477, 0x552C, 0xB0E4, 0x552D, 0xD4A7, 0x552E, 0xB0E2,\r\n\t0x552F, 0xB0DF, 0x5530, 0xD47C, 0x5531, 0xB0DB, 0x5532, 0xD4A2,\t0x5533, 0xB0E6, 0x5534, 0xD476, 0x5535, 0xD47B, 0x5536, 0xD47A,\r\n\t0x5537, 0xADF2, 0x5538, 0xB0E1, 0x5539, 0xD4A5, 0x553B, 0xD4A8,\t0x553C, 0xD473, 0x553E, 0xB3E8, 0x5540, 0xD4A9, 0x5541, 0xB0E7,\r\n\t0x5543, 0xB0D9, 0x5544, 0xB0D6, 0x5545, 0xD47E, 0x5546, 0xB0D3,\t0x5548, 0xD4A6, 0x554A, 0xB0DA, 0x554B, 0xD4AA, 0x554D, 0xD474,\r\n\t0x554E, 0xD4A4, 0x554F, 0xB0DD, 0x5550, 0xD475, 0x5551, 0xD478,\t0x5552, 0xD47D, 0x5555, 0xB0DE, 0x5556, 0xB0DC, 0x5557, 0xB0E8,\r\n\t0x555C, 0xB0E3, 0x555E, 0xB0D7, 0x555F, 0xB1D2, 0x5561, 0xB0D8,\t0x5562, 0xD479, 0x5563, 0xB0E5, 0x5564, 0xB0E0, 0x5565, 0xD4A3,\r\n\t0x5566, 0xB0D5, 0x556A, 0xB0D4, 0x5575, 0xD471, 0x5576, 0xD472,\t0x5577, 0xD86A, 0x557B, 0xB3D7, 0x557C, 0xB3DA, 0x557D, 0xD875,\r\n\t0x557E, 0xB3EE, 0x557F, 0xD878, 0x5580, 0xB3D8, 0x5581, 0xD871,\t0x5582, 0xB3DE, 0x5583, 0xB3E4, 0x5584, 0xB5BD, 0x5587, 0xB3E2,\r\n\t0x5588, 0xD86E, 0x5589, 0xB3EF, 0x558A, 0xB3DB, 0x558B, 0xB3E3,\t0x558C, 0xD876, 0x558D, 0xDCD7, 0x558E, 0xD87B, 0x558F, 0xD86F,\r\n\t0x5591, 0xD866, 0x5592, 0xD873, 0x5593, 0xD86D, 0x5594, 0xB3E1,\t0x5595, 0xD879, 0x5598, 0xB3DD, 0x5599, 0xB3F1, 0x559A, 0xB3EA,\r\n\t0x559C, 0xB3DF, 0x559D, 0xB3DC, 0x559F, 0xB3E7, 0x55A1, 0xD87A,\t0x55A2, 0xD86C, 0x55A3, 0xD872, 0x55A4, 0xD874, 0x55A5, 0xD868,\r\n\t0x55A6, 0xD877, 0x55A7, 0xB3D9, 0x55A8, 0xD867, 0x55AA, 0xB3E0,\t0x55AB, 0xB3F0, 0x55AC, 0xB3EC, 0x55AD, 0xD869, 0x55AE, 0xB3E6,\r\n\t0x55B1, 0xB3ED, 0x55B2, 0xB3E9, 0x55B3, 0xB3E5, 0x55B5, 0xD870,\t0x55BB, 0xB3EB, 0x55BF, 0xDCD5, 0x55C0, 0xDCD1, 0x55C2, 0xDCE0,\r\n\t0x55C3, 0xDCCA, 0x55C4, 0xDCD3, 0x55C5, 0xB6E5, 0x55C6, 0xB6E6,\t0x55C7, 0xB6DE, 0x55C8, 0xDCDC, 0x55C9, 0xB6E8, 0x55CA, 0xDCCF,\r\n\t0x55CB, 0xDCCE, 0x55CC, 0xDCCC, 0x55CD, 0xDCDE, 0x55CE, 0xB6DC,\t0x55CF, 0xDCD8, 0x55D0, 0xDCCD, 0x55D1, 0xB6DF, 0x55D2, 0xDCD6,\r\n\t0x55D3, 0xB6DA, 0x55D4, 0xDCD2, 0x55D5, 0xDCD9, 0x55D6, 0xDCDB,\t0x55D9, 0xDCDF, 0x55DA, 0xB6E3, 0x55DB, 0xDCCB, 0x55DC, 0xB6DD,\r\n\t0x55DD, 0xDCD0, 0x55DF, 0xB6D8, 0x55E1, 0xB6E4, 0x55E2, 0xDCDA,\t0x55E3, 0xB6E0, 0x55E4, 0xB6E1, 0x55E5, 0xB6E7, 0x55E6, 0xB6DB,\r\n\t0x55E7, 0xA25F, 0x55E8, 0xB6D9, 0x55E9, 0xDCD4, 0x55EF, 0xB6E2,\t0x55F2, 0xDCDD, 0x55F6, 0xB9CD, 0x55F7, 0xB9C8, 0x55F9, 0xE155,\r\n\t0x55FA, 0xE151, 0x55FC, 0xE14B, 0x55FD, 0xB9C2, 0x55FE, 0xB9BE,\t0x55FF, 0xE154, 0x5600, 0xB9BF, 0x5601, 0xE14E, 0x5602, 0xE150,\r\n\t0x5604, 0xE153, 0x5606, 0xB9C4, 0x5608, 0xB9CB, 0x5609, 0xB9C5,\t0x560C, 0xE149, 0x560D, 0xB9C6, 0x560E, 0xB9C7, 0x560F, 0xE14C,\r\n\t0x5610, 0xB9CC, 0x5612, 0xE14A, 0x5613, 0xE14F, 0x5614, 0xB9C3,\t0x5615, 0xE148, 0x5616, 0xB9C9, 0x5617, 0xB9C1, 0x561B, 0xB9C0,\r\n\t0x561C, 0xE14D, 0x561D, 0xE152, 0x561F, 0xB9CA, 0x5627, 0xE147,\t0x5629, 0xBC4D, 0x562A, 0xE547, 0x562C, 0xE544, 0x562E, 0xBC47,\r\n\t0x562F, 0xBC53, 0x5630, 0xBC54, 0x5632, 0xBC4A, 0x5633, 0xE542,\t0x5634, 0xBC4C, 0x5635, 0xE4F9, 0x5636, 0xBC52, 0x5638, 0xE546,\r\n\t0x5639, 0xBC49, 0x563A, 0xE548, 0x563B, 0xBC48, 0x563D, 0xE543,\t0x563E, 0xE545, 0x563F, 0xBC4B, 0x5640, 0xE541, 0x5641, 0xE4FA,\r\n\t0x5642, 0xE4F7, 0x5645, 0xD86B, 0x5646, 0xE4FD, 0x5648, 0xE4F6,\t0x5649, 0xE4FC, 0x564A, 0xE4FB, 0x564C, 0xE4F8, 0x564E, 0xBC4F,\r\n\t0x5653, 0xBC4E, 0x5657, 0xBC50, 0x5658, 0xE4FE, 0x5659, 0xBEB2,\t0x565A, 0xE540, 0x565E, 0xE945, 0x5660, 0xE8FD, 0x5662, 0xBEBE,\r\n\t0x5663, 0xE942, 0x5664, 0xBEB6, 0x5665, 0xBEBA, 0x5666, 0xE941,\t0x5668, 0xBEB9, 0x5669, 0xBEB5, 0x566A, 0xBEB8, 0x566B, 0xBEB3,\r\n\t0x566C, 0xBEBD, 0x566D, 0xE943, 0x566E, 0xE8FE, 0x566F, 0xBEBC,\t0x5670, 0xE8FC, 0x5671, 0xBEBB, 0x5672, 0xE944, 0x5673, 0xE940,\r\n\t0x5674, 0xBC51, 0x5676, 0xBEBF, 0x5677, 0xE946, 0x5678, 0xBEB7,\t0x5679, 0xBEB4, 0x567E, 0xECC6, 0x567F, 0xECC8, 0x5680, 0xC07B,\r\n\t0x5681, 0xECC9, 0x5682, 0xECC7, 0x5683, 0xECC5, 0x5684, 0xECC4,\t0x5685, 0xC07D, 0x5686, 0xECC3, 0x5687, 0xC07E, 0x568C, 0xECC1,\r\n\t0x568D, 0xECC2, 0x568E, 0xC07A, 0x568F, 0xC0A1, 0x5690, 0xC07C,\t0x5693, 0xECC0, 0x5695, 0xC250, 0x5697, 0xEFBC, 0x5698, 0xEFBA,\r\n\t0x5699, 0xEFBF, 0x569A, 0xEFBD, 0x569C, 0xEFBB, 0x569D, 0xEFBE,\t0x56A5, 0xC360, 0x56A6, 0xF1F2, 0x56A7, 0xF1F3, 0x56A8, 0xC456,\r\n\t0x56AA, 0xF1F4, 0x56AB, 0xF1F0, 0x56AC, 0xF1F5, 0x56AD, 0xF1F1,\t0x56AE, 0xC251, 0x56B2, 0xF3FE, 0x56B3, 0xF441, 0x56B4, 0xC459,\r\n\t0x56B5, 0xF440, 0x56B6, 0xC458, 0x56B7, 0xC457, 0x56BC, 0xC45A,\t0x56BD, 0xF5C5, 0x56BE, 0xF5C6, 0x56C0, 0xC4DA, 0x56C1, 0xC4D9,\r\n\t0x56C2, 0xC4DB, 0x56C3, 0xF5C4, 0x56C5, 0xF6D8, 0x56C6, 0xF6D7,\t0x56C8, 0xC56D, 0x56C9, 0xC56F, 0x56CA, 0xC56E, 0x56CB, 0xF6D9,\r\n\t0x56CC, 0xC5C8, 0x56CD, 0xF8A6, 0x56D1, 0xC5F1, 0x56D3, 0xF8A5,\t0x56D4, 0xF8EE, 0x56D7, 0xC949, 0x56DA, 0xA57D, 0x56DB, 0xA57C,\r\n\t0x56DD, 0xA65F, 0x56DE, 0xA65E, 0x56DF, 0xC9C7, 0x56E0, 0xA65D,\t0x56E1, 0xC9C6, 0x56E4, 0xA779, 0x56E5, 0xCAA9, 0x56E7, 0xCAA8,\r\n\t0x56EA, 0xA777, 0x56EB, 0xA77A, 0x56EE, 0xCAA7, 0x56F0, 0xA778,\t0x56F7, 0xCBF0, 0x56F9, 0xCBF1, 0x56FA, 0xA954, 0x56FF, 0xABAA,\r\n\t0x5701, 0xD148, 0x5702, 0xD149, 0x5703, 0xAE45, 0x5704, 0xAE46,\t0x5707, 0xD4AC, 0x5708, 0xB0E9, 0x5709, 0xB0EB, 0x570A, 0xD4AB,\r\n\t0x570B, 0xB0EA, 0x570C, 0xD87C, 0x570D, 0xB3F2, 0x5712, 0xB6E9,\t0x5713, 0xB6EA, 0x5714, 0xDCE1, 0x5716, 0xB9CF, 0x5718, 0xB9CE,\r\n\t0x571A, 0xE549, 0x571B, 0xE948, 0x571C, 0xE947, 0x571E, 0xF96B,\t0x571F, 0xA467, 0x5720, 0xC959, 0x5722, 0xC96E, 0x5723, 0xC96F,\r\n\t0x5728, 0xA662, 0x5729, 0xA666, 0x572A, 0xC9C9, 0x572C, 0xA664,\t0x572D, 0xA663, 0x572E, 0xC9C8, 0x572F, 0xA665, 0x5730, 0xA661,\r\n\t0x5733, 0xA660, 0x5734, 0xC9CA, 0x573B, 0xA7A6, 0x573E, 0xA7A3,\t0x5740, 0xA77D, 0x5741, 0xCAAA, 0x5745, 0xCAAB, 0x5747, 0xA7A1,\r\n\t0x5749, 0xCAAD, 0x574A, 0xA77B, 0x574B, 0xCAAE, 0x574C, 0xCAAC,\t0x574D, 0xA77E, 0x574E, 0xA7A2, 0x574F, 0xA7A5, 0x5750, 0xA7A4,\r\n\t0x5751, 0xA77C, 0x5752, 0xCAAF, 0x5761, 0xA959, 0x5762, 0xCBFE,\t0x5764, 0xA95B, 0x5766, 0xA95A, 0x5768, 0xCC40, 0x5769, 0xA958,\r\n\t0x576A, 0xA957, 0x576B, 0xCBF5, 0x576D, 0xCBF4, 0x576F, 0xCBF2,\t0x5770, 0xCBF7, 0x5771, 0xCBF6, 0x5772, 0xCBF3, 0x5773, 0xCBFC,\r\n\t0x5774, 0xCBFD, 0x5775, 0xCBFA, 0x5776, 0xCBF8, 0x5777, 0xA956,\t0x577B, 0xCBFB, 0x577C, 0xA95C, 0x577D, 0xCC41, 0x5780, 0xCBF9,\r\n\t0x5782, 0xABAB, 0x5783, 0xA955, 0x578B, 0xABAC, 0x578C, 0xCE54,\t0x578F, 0xCE5A, 0x5793, 0xABB2, 0x5794, 0xCE58, 0x5795, 0xCE5E,\r\n\t0x5797, 0xCE55, 0x5798, 0xCE59, 0x5799, 0xCE5B, 0x579A, 0xCE5D,\t0x579B, 0xCE57, 0x579D, 0xCE56, 0x579E, 0xCE51, 0x579F, 0xCE52,\r\n\t0x57A0, 0xABAD, 0x57A2, 0xABAF, 0x57A3, 0xABAE, 0x57A4, 0xCE53,\t0x57A5, 0xCE5C, 0x57AE, 0xABB1, 0x57B5, 0xCE50, 0x57B6, 0xD153,\r\n\t0x57B8, 0xD152, 0x57B9, 0xD157, 0x57BA, 0xD14E, 0x57BC, 0xD151,\t0x57BD, 0xD150, 0x57BF, 0xD154, 0x57C1, 0xD158, 0x57C2, 0xAE47,\r\n\t0x57C3, 0xAE4A, 0x57C6, 0xD14F, 0x57C7, 0xD155, 0x57CB, 0xAE49,\t0x57CC, 0xD14A, 0x57CE, 0xABB0, 0x57CF, 0xD4BA, 0x57D0, 0xD156,\r\n\t0x57D2, 0xD14D, 0x57D4, 0xAE48, 0x57D5, 0xD14C, 0x57DC, 0xD4B1,\t0x57DF, 0xB0EC, 0x57E0, 0xB0F0, 0x57E1, 0xD4C1, 0x57E2, 0xD4AF,\r\n\t0x57E3, 0xD4BD, 0x57E4, 0xB0F1, 0x57E5, 0xD4BF, 0x57E7, 0xD4C5,\t0x57E9, 0xD4C9, 0x57EC, 0xD4C0, 0x57ED, 0xD4B4, 0x57EE, 0xD4BC,\r\n\t0x57F0, 0xD4CA, 0x57F1, 0xD4C8, 0x57F2, 0xD4BE, 0x57F3, 0xD4B9,\t0x57F4, 0xD4B2, 0x57F5, 0xD8A6, 0x57F6, 0xD4B0, 0x57F7, 0xB0F5,\r\n\t0x57F8, 0xD4B7, 0x57F9, 0xB0F6, 0x57FA, 0xB0F2, 0x57FB, 0xD4AD,\t0x57FC, 0xD4C3, 0x57FD, 0xD4B5, 0x5800, 0xD4B3, 0x5801, 0xD4C6,\r\n\t0x5802, 0xB0F3, 0x5804, 0xD4CC, 0x5805, 0xB0ED, 0x5806, 0xB0EF,\t0x5807, 0xD4BB, 0x5808, 0xD4B6, 0x5809, 0xAE4B, 0x580A, 0xB0EE,\r\n\t0x580B, 0xD4B8, 0x580C, 0xD4C7, 0x580D, 0xD4CB, 0x580E, 0xD4C2,\t0x5810, 0xD4C4, 0x5814, 0xD4AE, 0x5819, 0xD8A1, 0x581B, 0xD8AA,\r\n\t0x581C, 0xD8A9, 0x581D, 0xB3FA, 0x581E, 0xD8A2, 0x5820, 0xB3FB,\t0x5821, 0xB3F9, 0x5823, 0xD8A4, 0x5824, 0xB3F6, 0x5825, 0xD8A8,\r\n\t0x5827, 0xD8A3, 0x5828, 0xD8A5, 0x5829, 0xD87D, 0x582A, 0xB3F4,\t0x582C, 0xD8B2, 0x582D, 0xD8B1, 0x582E, 0xD8AE, 0x582F, 0xB3F3,\r\n\t0x5830, 0xB3F7, 0x5831, 0xB3F8, 0x5832, 0xD14B, 0x5833, 0xD8AB,\t0x5834, 0xB3F5, 0x5835, 0xB0F4, 0x5836, 0xD8AD, 0x5837, 0xD87E,\r\n\t0x5838, 0xD8B0, 0x5839, 0xD8AF, 0x583B, 0xD8B3, 0x583D, 0xDCEF,\t0x583F, 0xD8AC, 0x5848, 0xD8A7, 0x5849, 0xDCE7, 0x584A, 0xB6F4,\r\n\t0x584B, 0xB6F7, 0x584C, 0xB6F2, 0x584D, 0xDCE6, 0x584E, 0xDCEA,\t0x584F, 0xDCE5, 0x5851, 0xB6EC, 0x5852, 0xB6F6, 0x5853, 0xDCE2,\r\n\t0x5854, 0xB6F0, 0x5855, 0xDCE9, 0x5857, 0xB6EE, 0x5858, 0xB6ED,\t0x5859, 0xDCEC, 0x585A, 0xB6EF, 0x585B, 0xDCEE, 0x585D, 0xDCEB,\r\n\t0x585E, 0xB6EB, 0x5862, 0xB6F5, 0x5863, 0xDCF0, 0x5864, 0xDCE4,\t0x5865, 0xDCED, 0x5868, 0xDCE3, 0x586B, 0xB6F1, 0x586D, 0xB6F3,\r\n\t0x586F, 0xDCE8, 0x5871, 0xDCF1, 0x5874, 0xE15D, 0x5875, 0xB9D0,\t0x5876, 0xE163, 0x5879, 0xB9D5, 0x587A, 0xE15F, 0x587B, 0xE166,\r\n\t0x587C, 0xE157, 0x587D, 0xB9D7, 0x587E, 0xB9D1, 0x587F, 0xE15C,\t0x5880, 0xBC55, 0x5881, 0xE15B, 0x5882, 0xE164, 0x5883, 0xB9D2,\r\n\t0x5885, 0xB9D6, 0x5886, 0xE15A, 0x5887, 0xE160, 0x5888, 0xE165,\t0x5889, 0xE156, 0x588A, 0xB9D4, 0x588B, 0xE15E, 0x588E, 0xE162,\r\n\t0x588F, 0xE168, 0x5890, 0xE158, 0x5891, 0xE161, 0x5893, 0xB9D3,\t0x5894, 0xE167, 0x5898, 0xE159, 0x589C, 0xBC59, 0x589D, 0xE54B,\r\n\t0x589E, 0xBC57, 0x589F, 0xBC56, 0x58A0, 0xE54D, 0x58A1, 0xE552,\t0x58A3, 0xE54E, 0x58A5, 0xE551, 0x58A6, 0xBC5C, 0x58A8, 0xBEA5,\r\n\t0x58A9, 0xBC5B, 0x58AB, 0xE54A, 0x58AC, 0xE550, 0x58AE, 0xBC5A,\t0x58AF, 0xE54F, 0x58B1, 0xE54C, 0x58B3, 0xBC58, 0x58BA, 0xE94D,\r\n\t0x58BB, 0xF9D9, 0x58BC, 0xE94F, 0x58BD, 0xE94A, 0x58BE, 0xBEC1,\t0x58BF, 0xE94C, 0x58C1, 0xBEC0, 0x58C2, 0xE94E, 0x58C5, 0xBEC3,\r\n\t0x58C6, 0xE950, 0x58C7, 0xBEC2, 0x58C8, 0xE949, 0x58C9, 0xE94B,\t0x58CE, 0xC0A5, 0x58CF, 0xECCC, 0x58D1, 0xC0A4, 0x58D2, 0xECCD,\r\n\t0x58D3, 0xC0A3, 0x58D4, 0xECCB, 0x58D5, 0xC0A2, 0x58D6, 0xECCA,\t0x58D8, 0xC253, 0x58D9, 0xC252, 0x58DA, 0xF1F6, 0x58DB, 0xF1F8,\r\n\t0x58DD, 0xF1F7, 0x58DE, 0xC361, 0x58DF, 0xC362, 0x58E2, 0xC363,\t0x58E3, 0xF442, 0x58E4, 0xC45B, 0x58E7, 0xF7D3, 0x58E8, 0xF7D2,\r\n\t0x58E9, 0xC5F2, 0x58EB, 0xA468, 0x58EC, 0xA4D0, 0x58EF, 0xA7A7,\t0x58F4, 0xCE5F, 0x58F9, 0xB3FC, 0x58FA, 0xB3FD, 0x58FC, 0xDCF2,\r\n\t0x58FD, 0xB9D8, 0x58FE, 0xE169, 0x58FF, 0xE553, 0x5903, 0xC95A,\t0x5906, 0xCAB0, 0x590C, 0xCC42, 0x590D, 0xCE60, 0x590E, 0xD159,\r\n\t0x590F, 0xAE4C, 0x5912, 0xF1F9, 0x5914, 0xC4DC, 0x5915, 0xA469,\t0x5916, 0xA57E, 0x5917, 0xC970, 0x5919, 0xA667, 0x591A, 0xA668,\r\n\t0x591C, 0xA95D, 0x5920, 0xB0F7, 0x5922, 0xB9DA, 0x5924, 0xB9DB,\t0x5925, 0xB9D9, 0x5927, 0xA46A, 0x5929, 0xA4D1, 0x592A, 0xA4D3,\r\n\t0x592B, 0xA4D2, 0x592C, 0xC95B, 0x592D, 0xA4D4, 0x592E, 0xA5A1,\t0x592F, 0xC971, 0x5931, 0xA5A2, 0x5937, 0xA669, 0x5938, 0xA66A,\r\n\t0x593C, 0xC9CB, 0x593E, 0xA7A8, 0x5940, 0xCAB1, 0x5944, 0xA961,\t0x5945, 0xCC43, 0x5947, 0xA95F, 0x5948, 0xA960, 0x5949, 0xA95E,\r\n\t0x594A, 0xD15A, 0x594E, 0xABB6, 0x594F, 0xABB5, 0x5950, 0xABB7,\t0x5951, 0xABB4, 0x5953, 0xCE61, 0x5954, 0xA962, 0x5955, 0xABB3,\r\n\t0x5957, 0xAE4D, 0x5958, 0xAE4E, 0x595A, 0xAE4F, 0x595C, 0xD4CD,\t0x5960, 0xB3FE, 0x5961, 0xD8B4, 0x5962, 0xB0F8, 0x5967, 0xB6F8,\r\n\t0x5969, 0xB9DD, 0x596A, 0xB9DC, 0x596B, 0xE16A, 0x596D, 0xBC5D,\t0x596E, 0xBEC4, 0x5970, 0xEFC0, 0x5971, 0xF6DA, 0x5972, 0xF7D4,\r\n\t0x5973, 0xA46B, 0x5974, 0xA5A3, 0x5976, 0xA5A4, 0x5977, 0xC9D1,\t0x5978, 0xA66C, 0x5979, 0xA66F, 0x597B, 0xC9CF, 0x597C, 0xC9CD,\r\n\t0x597D, 0xA66E, 0x597E, 0xC9D0, 0x597F, 0xC9D2, 0x5980, 0xC9CC,\t0x5981, 0xA671, 0x5982, 0xA670, 0x5983, 0xA66D, 0x5984, 0xA66B,\r\n\t0x5985, 0xC9CE, 0x598A, 0xA7B3, 0x598D, 0xA7B0, 0x598E, 0xCAB6,\t0x598F, 0xCAB9, 0x5990, 0xCAB8, 0x5992, 0xA7AA, 0x5993, 0xA7B2,\r\n\t0x5996, 0xA7AF, 0x5997, 0xCAB5, 0x5998, 0xCAB3, 0x5999, 0xA7AE,\t0x599D, 0xA7A9, 0x599E, 0xA7AC, 0x59A0, 0xCAB4, 0x59A1, 0xCABB,\r\n\t0x59A2, 0xCAB7, 0x59A3, 0xA7AD, 0x59A4, 0xA7B1, 0x59A5, 0xA7B4,\t0x59A6, 0xCAB2, 0x59A7, 0xCABA, 0x59A8, 0xA7AB, 0x59AE, 0xA967,\r\n\t0x59AF, 0xA96F, 0x59B1, 0xCC4F, 0x59B2, 0xCC48, 0x59B3, 0xA970,\t0x59B4, 0xCC53, 0x59B5, 0xCC44, 0x59B6, 0xCC4B, 0x59B9, 0xA966,\r\n\t0x59BA, 0xCC45, 0x59BB, 0xA964, 0x59BC, 0xCC4C, 0x59BD, 0xCC50,\t0x59BE, 0xA963, 0x59C0, 0xCC51, 0x59C1, 0xCC4A, 0x59C3, 0xCC4D,\r\n\t0x59C5, 0xA972, 0x59C6, 0xA969, 0x59C7, 0xCC54, 0x59C8, 0xCC52,\t0x59CA, 0xA96E, 0x59CB, 0xA96C, 0x59CC, 0xCC49, 0x59CD, 0xA96B,\r\n\t0x59CE, 0xCC47, 0x59CF, 0xCC46, 0x59D0, 0xA96A, 0x59D1, 0xA968,\t0x59D2, 0xA971, 0x59D3, 0xA96D, 0x59D4, 0xA965, 0x59D6, 0xCC4E,\r\n\t0x59D8, 0xABB9, 0x59DA, 0xABC0, 0x59DB, 0xCE6F, 0x59DC, 0xABB8,\t0x59DD, 0xCE67, 0x59DE, 0xCE63, 0x59E0, 0xCE73, 0x59E1, 0xCE62,\r\n\t0x59E3, 0xABBB, 0x59E4, 0xCE6C, 0x59E5, 0xABBE, 0x59E6, 0xABC1,\t0x59E8, 0xABBC, 0x59E9, 0xCE70, 0x59EA, 0xABBF, 0x59EC, 0xAE56,\r\n\t0x59ED, 0xCE76, 0x59EE, 0xCE64, 0x59F1, 0xCE66, 0x59F2, 0xCE6D,\t0x59F3, 0xCE71, 0x59F4, 0xCE75, 0x59F5, 0xCE72, 0x59F6, 0xCE6B,\r\n\t0x59F7, 0xCE6E, 0x59FA, 0xCE68, 0x59FB, 0xABC3, 0x59FC, 0xCE6A,\t0x59FD, 0xCE69, 0x59FE, 0xCE74, 0x59FF, 0xABBA, 0x5A00, 0xCE65,\r\n\t0x5A01, 0xABC2, 0x5A03, 0xABBD, 0x5A09, 0xAE5C, 0x5A0A, 0xD162,\t0x5A0C, 0xAE5B, 0x5A0F, 0xD160, 0x5A11, 0xAE50, 0x5A13, 0xAE55,\r\n\t0x5A15, 0xD15F, 0x5A16, 0xD15C, 0x5A17, 0xD161, 0x5A18, 0xAE51,\t0x5A19, 0xD15B, 0x5A1B, 0xAE54, 0x5A1C, 0xAE52, 0x5A1E, 0xD163,\r\n\t0x5A1F, 0xAE53, 0x5A20, 0xAE57, 0x5A23, 0xAE58, 0x5A25, 0xAE5A,\t0x5A29, 0xAE59, 0x5A2D, 0xD15D, 0x5A2E, 0xD15E, 0x5A33, 0xD164,\r\n\t0x5A35, 0xD4D4, 0x5A36, 0xB0F9, 0x5A37, 0xD8C2, 0x5A38, 0xD4D3,\t0x5A39, 0xD4E6, 0x5A3C, 0xB140, 0x5A3E, 0xD4E4, 0x5A40, 0xB0FE,\r\n\t0x5A41, 0xB0FA, 0x5A42, 0xD4ED, 0x5A43, 0xD4DD, 0x5A44, 0xD4E0,\t0x5A46, 0xB143, 0x5A47, 0xD4EA, 0x5A48, 0xD4E2, 0x5A49, 0xB0FB,\r\n\t0x5A4A, 0xB144, 0x5A4C, 0xD4E7, 0x5A4D, 0xD4E5, 0x5A50, 0xD4D6,\t0x5A51, 0xD4EB, 0x5A52, 0xD4DF, 0x5A53, 0xD4DA, 0x5A55, 0xD4D0,\r\n\t0x5A56, 0xD4EC, 0x5A57, 0xD4DC, 0x5A58, 0xD4CF, 0x5A5A, 0xB142,\t0x5A5B, 0xD4E1, 0x5A5C, 0xD4EE, 0x5A5D, 0xD4DE, 0x5A5E, 0xD4D2,\r\n\t0x5A5F, 0xD4D7, 0x5A60, 0xD4CE, 0x5A62, 0xB141, 0x5A64, 0xD4DB,\t0x5A65, 0xD4D8, 0x5A66, 0xB0FC, 0x5A67, 0xD4D1, 0x5A69, 0xD4E9,\r\n\t0x5A6A, 0xB0FD, 0x5A6C, 0xD4D9, 0x5A6D, 0xD4D5, 0x5A70, 0xD4E8,\t0x5A77, 0xB440, 0x5A78, 0xD8BB, 0x5A7A, 0xD8B8, 0x5A7B, 0xD8C9,\r\n\t0x5A7C, 0xD8BD, 0x5A7D, 0xD8CA, 0x5A7F, 0xB442, 0x5A83, 0xD8C6,\t0x5A84, 0xD8C3, 0x5A8A, 0xD8C4, 0x5A8B, 0xD8C7, 0x5A8C, 0xD8CB,\r\n\t0x5A8E, 0xD4E3, 0x5A8F, 0xD8CD, 0x5A90, 0xDD47, 0x5A92, 0xB443,\t0x5A93, 0xD8CE, 0x5A94, 0xD8B6, 0x5A95, 0xD8C0, 0x5A97, 0xD8C5,\r\n\t0x5A9A, 0xB441, 0x5A9B, 0xB444, 0x5A9C, 0xD8CC, 0x5A9D, 0xD8CF,\t0x5A9E, 0xD8BA, 0x5A9F, 0xD8B7, 0x5AA2, 0xD8B9, 0x5AA5, 0xD8BE,\r\n\t0x5AA6, 0xD8BC, 0x5AA7, 0xB445, 0x5AA9, 0xD8C8, 0x5AAC, 0xD8BF,\t0x5AAE, 0xD8C1, 0x5AAF, 0xD8B5, 0x5AB0, 0xDCFA, 0x5AB1, 0xDCF8,\r\n\t0x5AB2, 0xB742, 0x5AB3, 0xB740, 0x5AB4, 0xDD43, 0x5AB5, 0xDCF9,\t0x5AB6, 0xDD44, 0x5AB7, 0xDD40, 0x5AB8, 0xDCF7, 0x5AB9, 0xDD46,\r\n\t0x5ABA, 0xDCF6, 0x5ABB, 0xDCFD, 0x5ABC, 0xB6FE, 0x5ABD, 0xB6FD,\t0x5ABE, 0xB6FC, 0x5ABF, 0xDCFB, 0x5AC0, 0xDD41, 0x5AC1, 0xB6F9,\r\n\t0x5AC2, 0xB741, 0x5AC4, 0xDCF4, 0x5AC6, 0xDCFE, 0x5AC7, 0xDCF3,\t0x5AC8, 0xDCFC, 0x5AC9, 0xB6FA, 0x5ACA, 0xDD42, 0x5ACB, 0xDCF5,\r\n\t0x5ACC, 0xB6FB, 0x5ACD, 0xDD45, 0x5AD5, 0xE16E, 0x5AD6, 0xB9E2,\t0x5AD7, 0xB9E1, 0x5AD8, 0xB9E3, 0x5AD9, 0xE17A, 0x5ADA, 0xE170,\r\n\t0x5ADB, 0xE176, 0x5ADC, 0xE16B, 0x5ADD, 0xE179, 0x5ADE, 0xE178,\t0x5ADF, 0xE17C, 0x5AE0, 0xE175, 0x5AE1, 0xB9DE, 0x5AE2, 0xE174,\r\n\t0x5AE3, 0xB9E4, 0x5AE5, 0xE16D, 0x5AE6, 0xB9DF, 0x5AE8, 0xE17B,\t0x5AE9, 0xB9E0, 0x5AEA, 0xE16F, 0x5AEB, 0xE172, 0x5AEC, 0xE177,\r\n\t0x5AED, 0xE171, 0x5AEE, 0xE16C, 0x5AF3, 0xE173, 0x5AF4, 0xE555,\t0x5AF5, 0xBC61, 0x5AF6, 0xE558, 0x5AF7, 0xE557, 0x5AF8, 0xE55A,\r\n\t0x5AF9, 0xE55C, 0x5AFA, 0xF9DC, 0x5AFB, 0xBC5F, 0x5AFD, 0xE556,\t0x5AFF, 0xE554, 0x5B01, 0xE55D, 0x5B02, 0xE55B, 0x5B03, 0xE559,\r\n\t0x5B05, 0xE55F, 0x5B07, 0xE55E, 0x5B08, 0xBC63, 0x5B09, 0xBC5E,\t0x5B0B, 0xBC60, 0x5B0C, 0xBC62, 0x5B0F, 0xE560, 0x5B10, 0xE957,\r\n\t0x5B13, 0xE956, 0x5B14, 0xE955, 0x5B16, 0xE958, 0x5B17, 0xE951,\t0x5B19, 0xE952, 0x5B1A, 0xE95A, 0x5B1B, 0xE953, 0x5B1D, 0xBEC5,\r\n\t0x5B1E, 0xE95C, 0x5B20, 0xE95B, 0x5B21, 0xE954, 0x5B23, 0xECD1,\t0x5B24, 0xC0A8, 0x5B25, 0xECCF, 0x5B26, 0xECD4, 0x5B27, 0xECD3,\r\n\t0x5B28, 0xE959, 0x5B2A, 0xC0A7, 0x5B2C, 0xECD2, 0x5B2D, 0xECCE,\t0x5B2E, 0xECD6, 0x5B2F, 0xECD5, 0x5B30, 0xC0A6, 0x5B32, 0xECD0,\r\n\t0x5B34, 0xBEC6, 0x5B38, 0xC254, 0x5B3C, 0xEFC1, 0x5B3D, 0xF1FA,\t0x5B3E, 0xF1FB, 0x5B3F, 0xF1FC, 0x5B40, 0xC45C, 0x5B43, 0xC45D,\r\n\t0x5B45, 0xF443, 0x5B47, 0xF5C8, 0x5B48, 0xF5C7, 0x5B4B, 0xF6DB,\t0x5B4C, 0xF6DC, 0x5B4D, 0xF7D5, 0x5B4E, 0xF8A7, 0x5B50, 0xA46C,\r\n\t0x5B51, 0xA46D, 0x5B53, 0xA46E, 0x5B54, 0xA4D5, 0x5B55, 0xA5A5,\t0x5B56, 0xC9D3, 0x5B57, 0xA672, 0x5B58, 0xA673, 0x5B5A, 0xA7B7,\r\n\t0x5B5B, 0xA7B8, 0x5B5C, 0xA7B6, 0x5B5D, 0xA7B5, 0x5B5F, 0xA973,\t0x5B62, 0xCC55, 0x5B63, 0xA975, 0x5B64, 0xA974, 0x5B65, 0xCC56,\r\n\t0x5B69, 0xABC4, 0x5B6B, 0xAE5D, 0x5B6C, 0xD165, 0x5B6E, 0xD4F0,\t0x5B70, 0xB145, 0x5B71, 0xB447, 0x5B72, 0xD4EF, 0x5B73, 0xB446,\r\n\t0x5B75, 0xB9E5, 0x5B77, 0xE17D, 0x5B78, 0xBEC7, 0x5B7A, 0xC0A9,\t0x5B7B, 0xECD7, 0x5B7D, 0xC45E, 0x5B7F, 0xC570, 0x5B81, 0xC972,\r\n\t0x5B83, 0xA5A6, 0x5B84, 0xC973, 0x5B85, 0xA676, 0x5B87, 0xA674,\t0x5B88, 0xA675, 0x5B89, 0xA677, 0x5B8B, 0xA7BA, 0x5B8C, 0xA7B9,\r\n\t0x5B8E, 0xCABC, 0x5B8F, 0xA7BB, 0x5B92, 0xCABD, 0x5B93, 0xCC57,\t0x5B95, 0xCC58, 0x5B97, 0xA976, 0x5B98, 0xA978, 0x5B99, 0xA97A,\r\n\t0x5B9A, 0xA977, 0x5B9B, 0xA97B, 0x5B9C, 0xA979, 0x5BA2, 0xABC8,\t0x5BA3, 0xABC5, 0x5BA4, 0xABC7, 0x5BA5, 0xABC9, 0x5BA6, 0xABC6,\r\n\t0x5BA7, 0xD166, 0x5BA8, 0xCE77, 0x5BAC, 0xD168, 0x5BAD, 0xD167,\t0x5BAE, 0xAE63, 0x5BB0, 0xAE5F, 0x5BB3, 0xAE60, 0x5BB4, 0xAE62,\r\n\t0x5BB5, 0xAE64, 0x5BB6, 0xAE61, 0x5BB8, 0xAE66, 0x5BB9, 0xAE65,\t0x5BBF, 0xB14A, 0x5BC0, 0xD4F2, 0x5BC1, 0xD4F1, 0x5BC2, 0xB149,\r\n\t0x5BC4, 0xB148, 0x5BC5, 0xB147, 0x5BC6, 0xB14B, 0x5BC7, 0xB146,\t0x5BCA, 0xD8D5, 0x5BCB, 0xD8D2, 0x5BCC, 0xB449, 0x5BCD, 0xD8D1,\r\n\t0x5BCE, 0xD8D6, 0x5BD0, 0xB44B, 0x5BD1, 0xD8D4, 0x5BD2, 0xB448,\t0x5BD3, 0xB44A, 0x5BD4, 0xD8D3, 0x5BD6, 0xDD48, 0x5BD8, 0xDD49,\r\n\t0x5BD9, 0xDD4A, 0x5BDE, 0xB9E6, 0x5BDF, 0xB9EE, 0x5BE0, 0xE17E,\t0x5BE1, 0xB9E8, 0x5BE2, 0xB9EC, 0x5BE3, 0xE1A1, 0x5BE4, 0xB9ED,\r\n\t0x5BE5, 0xB9E9, 0x5BE6, 0xB9EA, 0x5BE7, 0xB9E7, 0x5BE8, 0xB9EB,\t0x5BE9, 0xBC66, 0x5BEA, 0xD8D0, 0x5BEB, 0xBC67, 0x5BEC, 0xBC65,\r\n\t0x5BEE, 0xBC64, 0x5BEF, 0xE95D, 0x5BF0, 0xBEC8, 0x5BF1, 0xECD8,\t0x5BF2, 0xECD9, 0x5BF5, 0xC364, 0x5BF6, 0xC45F, 0x5BF8, 0xA46F,\r\n\t0x5BFA, 0xA678, 0x5C01, 0xABCA, 0x5C03, 0xD169, 0x5C04, 0xAE67,\t0x5C07, 0xB14E, 0x5C08, 0xB14D, 0x5C09, 0xB14C, 0x5C0A, 0xB44C,\r\n\t0x5C0B, 0xB44D, 0x5C0C, 0xD8D7, 0x5C0D, 0xB9EF, 0x5C0E, 0xBEC9,\t0x5C0F, 0xA470, 0x5C10, 0xC95C, 0x5C11, 0xA4D6, 0x5C12, 0xC974,\r\n\t0x5C15, 0xC9D4, 0x5C16, 0xA679, 0x5C1A, 0xA97C, 0x5C1F, 0xDD4B,\t0x5C22, 0xA471, 0x5C24, 0xA4D7, 0x5C25, 0xC9D5, 0x5C28, 0xCABE,\r\n\t0x5C2A, 0xCABF, 0x5C2C, 0xA7BC, 0x5C30, 0xD8D8, 0x5C31, 0xB44E,\t0x5C33, 0xDD4C, 0x5C37, 0xC0AA, 0x5C38, 0xA472, 0x5C39, 0xA4A8,\r\n\t0x5C3A, 0xA4D8, 0x5C3B, 0xC975, 0x5C3C, 0xA5A7, 0x5C3E, 0xA7C0,\t0x5C3F, 0xA7BF, 0x5C40, 0xA7BD, 0x5C41, 0xA7BE, 0x5C44, 0xCC59,\r\n\t0x5C45, 0xA97E, 0x5C46, 0xA9A1, 0x5C47, 0xCC5A, 0x5C48, 0xA97D,\t0x5C4B, 0xABCE, 0x5C4C, 0xCE78, 0x5C4D, 0xABCD, 0x5C4E, 0xABCB,\r\n\t0x5C4F, 0xABCC, 0x5C50, 0xAE6A, 0x5C51, 0xAE68, 0x5C54, 0xD16B,\t0x5C55, 0xAE69, 0x5C56, 0xD16A, 0x5C58, 0xAE5E, 0x5C59, 0xD4F3,\r\n\t0x5C5C, 0xB150, 0x5C5D, 0xB151, 0x5C60, 0xB14F, 0x5C62, 0xB9F0,\t0x5C63, 0xE1A2, 0x5C64, 0xBC68, 0x5C65, 0xBC69, 0x5C67, 0xE561,\r\n\t0x5C68, 0xC0AB, 0x5C69, 0xEFC2, 0x5C6A, 0xEFC3, 0x5C6C, 0xC4DD,\t0x5C6D, 0xF8A8, 0x5C6E, 0xC94B, 0x5C6F, 0xA4D9, 0x5C71, 0xA473,\r\n\t0x5C73, 0xC977, 0x5C74, 0xC976, 0x5C79, 0xA67A, 0x5C7A, 0xC9D7,\t0x5C7B, 0xC9D8, 0x5C7C, 0xC9D6, 0x5C7E, 0xC9D9, 0x5C86, 0xCAC7,\r\n\t0x5C88, 0xCAC2, 0x5C89, 0xCAC4, 0x5C8A, 0xCAC6, 0x5C8B, 0xCAC3,\t0x5C8C, 0xA7C4, 0x5C8D, 0xCAC0, 0x5C8F, 0xCAC1, 0x5C90, 0xA7C1,\r\n\t0x5C91, 0xA7C2, 0x5C92, 0xCAC5, 0x5C93, 0xCAC8, 0x5C94, 0xA7C3,\t0x5C95, 0xCAC9, 0x5C9D, 0xCC68, 0x5C9F, 0xCC62, 0x5CA0, 0xCC5D,\r\n\t0x5CA1, 0xA9A3, 0x5CA2, 0xCC65, 0x5CA3, 0xCC63, 0x5CA4, 0xCC5C,\t0x5CA5, 0xCC69, 0x5CA6, 0xCC6C, 0x5CA7, 0xCC67, 0x5CA8, 0xCC60,\r\n\t0x5CA9, 0xA9A5, 0x5CAA, 0xCC66, 0x5CAB, 0xA9A6, 0x5CAC, 0xCC61,\t0x5CAD, 0xCC64, 0x5CAE, 0xCC5B, 0x5CAF, 0xCC5F, 0x5CB0, 0xCC6B,\r\n\t0x5CB1, 0xA9A7, 0x5CB3, 0xA9A8, 0x5CB5, 0xCC5E, 0x5CB6, 0xCC6A,\t0x5CB7, 0xA9A2, 0x5CB8, 0xA9A4, 0x5CC6, 0xCEAB, 0x5CC7, 0xCEA4,\r\n\t0x5CC8, 0xCEAA, 0x5CC9, 0xCEA3, 0x5CCA, 0xCEA5, 0x5CCB, 0xCE7D,\t0x5CCC, 0xCE7B, 0x5CCE, 0xCEAC, 0x5CCF, 0xCEA9, 0x5CD0, 0xCE79,\r\n\t0x5CD2, 0xABD0, 0x5CD3, 0xCEA7, 0x5CD4, 0xCEA8, 0x5CD6, 0xCEA6,\t0x5CD7, 0xCE7C, 0x5CD8, 0xCE7A, 0x5CD9, 0xABCF, 0x5CDA, 0xCEA2,\r\n\t0x5CDB, 0xCE7E, 0x5CDE, 0xCEA1, 0x5CDF, 0xCEAD, 0x5CE8, 0xAE6F,\t0x5CEA, 0xAE6E, 0x5CEC, 0xD16C, 0x5CED, 0xAE6B, 0x5CEE, 0xD16E,\r\n\t0x5CF0, 0xAE70, 0x5CF1, 0xD16F, 0x5CF4, 0xAE73, 0x5CF6, 0xAE71,\t0x5CF7, 0xD170, 0x5CF8, 0xCEAE, 0x5CF9, 0xD172, 0x5CFB, 0xAE6D,\r\n\t0x5CFD, 0xAE6C, 0x5CFF, 0xD16D, 0x5D00, 0xD171, 0x5D01, 0xAE72,\t0x5D06, 0xB153, 0x5D07, 0xB152, 0x5D0B, 0xD4F5, 0x5D0C, 0xD4F9,\r\n\t0x5D0D, 0xD4FB, 0x5D0E, 0xB154, 0x5D0F, 0xD4FE, 0x5D11, 0xB158,\t0x5D12, 0xD541, 0x5D14, 0xB15A, 0x5D16, 0xB156, 0x5D17, 0xB15E,\r\n\t0x5D19, 0xB15B, 0x5D1A, 0xD4F7, 0x5D1B, 0xB155, 0x5D1D, 0xD4F6,\t0x5D1E, 0xD4F4, 0x5D1F, 0xD543, 0x5D20, 0xD4F8, 0x5D22, 0xB157,\r\n\t0x5D23, 0xD542, 0x5D24, 0xB15C, 0x5D25, 0xD4FD, 0x5D26, 0xD4FC,\t0x5D27, 0xB15D, 0x5D28, 0xD4FA, 0x5D29, 0xB159, 0x5D2E, 0xD544,\r\n\t0x5D30, 0xD540, 0x5D31, 0xD8E7, 0x5D32, 0xD8EE, 0x5D33, 0xD8E3,\t0x5D34, 0xB451, 0x5D35, 0xD8DF, 0x5D36, 0xD8EF, 0x5D37, 0xD8D9,\r\n\t0x5D38, 0xD8EC, 0x5D39, 0xD8EA, 0x5D3A, 0xD8E4, 0x5D3C, 0xD8ED,\t0x5D3D, 0xD8E6, 0x5D3F, 0xD8DE, 0x5D40, 0xD8F0, 0x5D41, 0xD8DC,\r\n\t0x5D42, 0xD8E9, 0x5D43, 0xD8DA, 0x5D45, 0xD8F1, 0x5D47, 0xB452,\t0x5D49, 0xD8EB, 0x5D4A, 0xDD4F, 0x5D4B, 0xD8DD, 0x5D4C, 0xB44F,\r\n\t0x5D4E, 0xD8E1, 0x5D50, 0xB450, 0x5D51, 0xD8E0, 0x5D52, 0xD8E5,\t0x5D55, 0xD8E2, 0x5D59, 0xD8E8, 0x5D5E, 0xDD53, 0x5D62, 0xDD56,\r\n\t0x5D63, 0xDD4E, 0x5D65, 0xDD50, 0x5D67, 0xDD55, 0x5D68, 0xDD54,\t0x5D69, 0xB743, 0x5D6B, 0xD8DB, 0x5D6C, 0xDD52, 0x5D6F, 0xB744,\r\n\t0x5D71, 0xDD4D, 0x5D72, 0xDD51, 0x5D77, 0xE1A9, 0x5D79, 0xE1B0,\t0x5D7A, 0xE1A7, 0x5D7C, 0xE1AE, 0x5D7D, 0xE1A5, 0x5D7E, 0xE1AD,\r\n\t0x5D7F, 0xE1B1, 0x5D80, 0xE1A4, 0x5D81, 0xE1A8, 0x5D82, 0xE1A3,\t0x5D84, 0xB9F1, 0x5D86, 0xE1A6, 0x5D87, 0xB9F2, 0x5D88, 0xE1AC,\r\n\t0x5D89, 0xE1AB, 0x5D8A, 0xE1AA, 0x5D8D, 0xE1AF, 0x5D92, 0xE565,\t0x5D93, 0xE567, 0x5D94, 0xBC6B, 0x5D95, 0xE568, 0x5D97, 0xE563,\r\n\t0x5D99, 0xE562, 0x5D9A, 0xE56C, 0x5D9C, 0xE56A, 0x5D9D, 0xBC6A,\t0x5D9E, 0xE56D, 0x5D9F, 0xE564, 0x5DA0, 0xE569, 0x5DA1, 0xE56B,\r\n\t0x5DA2, 0xE566, 0x5DA7, 0xE961, 0x5DA8, 0xE966, 0x5DA9, 0xE960,\t0x5DAA, 0xE965, 0x5DAC, 0xE95E, 0x5DAD, 0xE968, 0x5DAE, 0xE964,\r\n\t0x5DAF, 0xE969, 0x5DB0, 0xE963, 0x5DB1, 0xE95F, 0x5DB2, 0xE967,\t0x5DB4, 0xE96A, 0x5DB5, 0xE962, 0x5DB7, 0xECDA, 0x5DB8, 0xC0AF,\r\n\t0x5DBA, 0xC0AD, 0x5DBC, 0xC0AC, 0x5DBD, 0xC0AE, 0x5DC0, 0xEFC4,\t0x5DC2, 0xF172, 0x5DC3, 0xF1FD, 0x5DC6, 0xF444, 0x5DC7, 0xF445,\r\n\t0x5DC9, 0xC460, 0x5DCB, 0xF5C9, 0x5DCD, 0xC4DE, 0x5DCF, 0xF5CA,\t0x5DD1, 0xF6DE, 0x5DD2, 0xC572, 0x5DD4, 0xC571, 0x5DD5, 0xF6DD,\r\n\t0x5DD6, 0xC5C9, 0x5DD8, 0xF7D6, 0x5DDD, 0xA474, 0x5DDE, 0xA67B,\t0x5DDF, 0xC9DA, 0x5DE0, 0xCACA, 0x5DE1, 0xA8B5, 0x5DE2, 0xB15F,\r\n\t0x5DE5, 0xA475, 0x5DE6, 0xA5AA, 0x5DE7, 0xA5A9, 0x5DE8, 0xA5A8,\t0x5DEB, 0xA7C5, 0x5DEE, 0xAE74, 0x5DF0, 0xDD57, 0x5DF1, 0xA476,\r\n\t0x5DF2, 0xA477, 0x5DF3, 0xA478, 0x5DF4, 0xA4DA, 0x5DF7, 0xABD1,\t0x5DF9, 0xCEAF, 0x5DFD, 0xB453, 0x5DFE, 0xA479, 0x5DFF, 0xC95D,\r\n\t0x5E02, 0xA5AB, 0x5E03, 0xA5AC, 0x5E04, 0xC978, 0x5E06, 0xA67C,\t0x5E0A, 0xCACB, 0x5E0C, 0xA7C6, 0x5E0E, 0xCACC, 0x5E11, 0xA9AE,\r\n\t0x5E14, 0xCC6E, 0x5E15, 0xA9AC, 0x5E16, 0xA9AB, 0x5E17, 0xCC6D,\t0x5E18, 0xA9A9, 0x5E19, 0xCC6F, 0x5E1A, 0xA9AA, 0x5E1B, 0xA9AD,\r\n\t0x5E1D, 0xABD2, 0x5E1F, 0xABD4, 0x5E20, 0xCEB3, 0x5E21, 0xCEB0,\t0x5E22, 0xCEB1, 0x5E23, 0xCEB2, 0x5E24, 0xCEB4, 0x5E25, 0xABD3,\r\n\t0x5E28, 0xD174, 0x5E29, 0xD173, 0x5E2B, 0xAE76, 0x5E2D, 0xAE75,\t0x5E33, 0xB162, 0x5E34, 0xD546, 0x5E36, 0xB161, 0x5E37, 0xB163,\r\n\t0x5E38, 0xB160, 0x5E3D, 0xB455, 0x5E3E, 0xD545, 0x5E40, 0xB456,\t0x5E41, 0xD8F3, 0x5E43, 0xB457, 0x5E44, 0xD8F2, 0x5E45, 0xB454,\r\n\t0x5E4A, 0xDD5A, 0x5E4B, 0xDD5C, 0x5E4C, 0xB745, 0x5E4D, 0xDD5B,\t0x5E4E, 0xDD59, 0x5E4F, 0xDD58, 0x5E53, 0xE1B4, 0x5E54, 0xB9F7,\r\n\t0x5E55, 0xB9F5, 0x5E57, 0xB9F6, 0x5E58, 0xE1B2, 0x5E59, 0xE1B3,\t0x5E5B, 0xB9F3, 0x5E5C, 0xE571, 0x5E5D, 0xE56F, 0x5E5F, 0xBC6D,\r\n\t0x5E60, 0xE570, 0x5E61, 0xBC6E, 0x5E62, 0xBC6C, 0x5E63, 0xB9F4,\t0x5E66, 0xE96D, 0x5E67, 0xE96B, 0x5E68, 0xE96C, 0x5E69, 0xE56E,\r\n\t0x5E6A, 0xECDC, 0x5E6B, 0xC0B0, 0x5E6C, 0xECDB, 0x5E6D, 0xEFC5,\t0x5E6E, 0xEFC6, 0x5E6F, 0xE96E, 0x5E70, 0xF1FE, 0x5E72, 0xA47A,\r\n\t0x5E73, 0xA5AD, 0x5E74, 0xA67E, 0x5E75, 0xC9DB, 0x5E76, 0xA67D,\t0x5E78, 0xA9AF, 0x5E79, 0xB746, 0x5E7B, 0xA4DB, 0x5E7C, 0xA5AE,\r\n\t0x5E7D, 0xABD5, 0x5E7E, 0xB458, 0x5E80, 0xC979, 0x5E82, 0xC97A,\t0x5E84, 0xC9DC, 0x5E87, 0xA7C8, 0x5E88, 0xCAD0, 0x5E89, 0xCACE,\r\n\t0x5E8A, 0xA7C9, 0x5E8B, 0xCACD, 0x5E8C, 0xCACF, 0x5E8D, 0xCAD1,\t0x5E8F, 0xA7C7, 0x5E95, 0xA9B3, 0x5E96, 0xA9B4, 0x5E97, 0xA9B1,\r\n\t0x5E9A, 0xA9B0, 0x5E9B, 0xCEB8, 0x5E9C, 0xA9B2, 0x5EA0, 0xABD6,\t0x5EA2, 0xCEB7, 0x5EA3, 0xCEB9, 0x5EA4, 0xCEB6, 0x5EA5, 0xCEBA,\r\n\t0x5EA6, 0xABD7, 0x5EA7, 0xAE79, 0x5EA8, 0xD175, 0x5EAA, 0xD177,\t0x5EAB, 0xAE77, 0x5EAC, 0xD178, 0x5EAD, 0xAE78, 0x5EAE, 0xD176,\r\n\t0x5EB0, 0xCEB5, 0x5EB1, 0xD547, 0x5EB2, 0xD54A, 0x5EB3, 0xD54B,\t0x5EB4, 0xD548, 0x5EB5, 0xB167, 0x5EB6, 0xB166, 0x5EB7, 0xB164,\r\n\t0x5EB8, 0xB165, 0x5EB9, 0xD549, 0x5EBE, 0xB168, 0x5EC1, 0xB45A,\t0x5EC2, 0xB45B, 0x5EC4, 0xB45C, 0x5EC5, 0xDD5D, 0x5EC6, 0xDD5F,\r\n\t0x5EC7, 0xDD61, 0x5EC8, 0xB748, 0x5EC9, 0xB747, 0x5ECA, 0xB459,\t0x5ECB, 0xDD60, 0x5ECC, 0xDD5E, 0x5ECE, 0xE1B8, 0x5ED1, 0xE1B6,\r\n\t0x5ED2, 0xE1BC, 0x5ED3, 0xB9F8, 0x5ED4, 0xE1BD, 0x5ED5, 0xE1BA,\t0x5ED6, 0xB9F9, 0x5ED7, 0xE1B7, 0x5ED8, 0xE1B5, 0x5ED9, 0xE1BB,\r\n\t0x5EDA, 0xBC70, 0x5EDB, 0xE573, 0x5EDC, 0xE1B9, 0x5EDD, 0xBC72,\t0x5EDE, 0xE574, 0x5EDF, 0xBC71, 0x5EE0, 0xBC74, 0x5EE1, 0xE575,\r\n\t0x5EE2, 0xBC6F, 0x5EE3, 0xBC73, 0x5EE5, 0xE973, 0x5EE6, 0xE971,\t0x5EE7, 0xE970, 0x5EE8, 0xE972, 0x5EE9, 0xE96F, 0x5EEC, 0xC366,\r\n\t0x5EEE, 0xF446, 0x5EEF, 0xF447, 0x5EF1, 0xF5CB, 0x5EF2, 0xF6DF,\t0x5EF3, 0xC655, 0x5EF6, 0xA9B5, 0x5EF7, 0xA7CA, 0x5EFA, 0xABD8,\r\n\t0x5EFE, 0xA47B, 0x5EFF, 0xA4DC, 0x5F01, 0xA5AF, 0x5F02, 0xC9DD,\t0x5F04, 0xA7CB, 0x5F05, 0xCAD2, 0x5F07, 0xCEBB, 0x5F08, 0xABD9,\r\n\t0x5F0A, 0xB9FA, 0x5F0B, 0xA47C, 0x5F0F, 0xA6A1, 0x5F12, 0xB749,\t0x5F13, 0xA47D, 0x5F14, 0xA4DD, 0x5F15, 0xA4DE, 0x5F17, 0xA5B1,\r\n\t0x5F18, 0xA5B0, 0x5F1A, 0xC9DE, 0x5F1B, 0xA6A2, 0x5F1D, 0xCAD3,\t0x5F1F, 0xA7CC, 0x5F22, 0xCC71, 0x5F23, 0xCC72, 0x5F24, 0xCC73,\r\n\t0x5F26, 0xA9B6, 0x5F27, 0xA9B7, 0x5F28, 0xCC70, 0x5F29, 0xA9B8,\t0x5F2D, 0xABDA, 0x5F2E, 0xCEBC, 0x5F30, 0xD17A, 0x5F31, 0xAE7A,\r\n\t0x5F33, 0xD179, 0x5F35, 0xB169, 0x5F36, 0xD54C, 0x5F37, 0xB16A,\t0x5F38, 0xD54D, 0x5F3C, 0xB45D, 0x5F40, 0xDD62, 0x5F43, 0xE1BF,\r\n\t0x5F44, 0xE1BE, 0x5F46, 0xB9FB, 0x5F48, 0xBC75, 0x5F49, 0xE576,\t0x5F4A, 0xBECA, 0x5F4B, 0xE974, 0x5F4C, 0xC0B1, 0x5F4E, 0xC573,\r\n\t0x5F4F, 0xF7D8, 0x5F54, 0xCC74, 0x5F56, 0xCEBD, 0x5F57, 0xB16B,\t0x5F58, 0xD8F4, 0x5F59, 0xB74A, 0x5F5D, 0xC255, 0x5F62, 0xA7CE,\r\n\t0x5F64, 0xA7CD, 0x5F65, 0xABDB, 0x5F67, 0xD17B, 0x5F69, 0xB16D,\t0x5F6A, 0xB343, 0x5F6B, 0xB16E, 0x5F6C, 0xB16C, 0x5F6D, 0xB45E,\r\n\t0x5F6F, 0xE1C0, 0x5F70, 0xB9FC, 0x5F71, 0xBC76, 0x5F73, 0xC94C,\t0x5F74, 0xC9DF, 0x5F76, 0xCAD5, 0x5F77, 0xA7CF, 0x5F78, 0xCAD4,\r\n\t0x5F79, 0xA7D0, 0x5F7C, 0xA9BC, 0x5F7D, 0xCC77, 0x5F7E, 0xCC76,\t0x5F7F, 0xA9BB, 0x5F80, 0xA9B9, 0x5F81, 0xA9BA, 0x5F82, 0xCC75,\r\n\t0x5F85, 0xABDD, 0x5F86, 0xCEBE, 0x5F87, 0xABE0, 0x5F88, 0xABDC,\t0x5F89, 0xABE2, 0x5F8A, 0xABDE, 0x5F8B, 0xABDF, 0x5F8C, 0xABE1,\r\n\t0x5F90, 0xAE7D, 0x5F91, 0xAE7C, 0x5F92, 0xAE7B, 0x5F96, 0xD54F,\t0x5F97, 0xB16F, 0x5F98, 0xB172, 0x5F99, 0xB170, 0x5F9B, 0xD54E,\r\n\t0x5F9C, 0xB175, 0x5F9E, 0xB171, 0x5F9F, 0xD550, 0x5FA0, 0xB174,\t0x5FA1, 0xB173, 0x5FA5, 0xD8F6, 0x5FA6, 0xD8F5, 0x5FA8, 0xB461,\r\n\t0x5FA9, 0xB45F, 0x5FAA, 0xB460, 0x5FAB, 0xD8F7, 0x5FAC, 0xB74B,\t0x5FAD, 0xDD64, 0x5FAE, 0xB74C, 0x5FAF, 0xDD63, 0x5FB2, 0xE577,\r\n\t0x5FB5, 0xBC78, 0x5FB6, 0xE1C1, 0x5FB7, 0xBC77, 0x5FB9, 0xB9FD,\t0x5FBB, 0xECDE, 0x5FBC, 0xE975, 0x5FBD, 0xC0B2, 0x5FBE, 0xECDD,\r\n\t0x5FBF, 0xF240, 0x5FC0, 0xF448, 0x5FC1, 0xF449, 0x5FC3, 0xA4DF,\t0x5FC5, 0xA5B2, 0x5FC9, 0xC97B, 0x5FCC, 0xA7D2, 0x5FCD, 0xA7D4,\r\n\t0x5FCF, 0xC9E2, 0x5FD0, 0xCAD8, 0x5FD1, 0xCAD7, 0x5FD2, 0xCAD6,\t0x5FD4, 0xC9E1, 0x5FD5, 0xC9E0, 0x5FD6, 0xA6A4, 0x5FD7, 0xA7D3,\r\n\t0x5FD8, 0xA7D1, 0x5FD9, 0xA6A3, 0x5FDD, 0xA9BD, 0x5FDE, 0xCC78,\t0x5FE0, 0xA9BE, 0x5FE1, 0xCADD, 0x5FE3, 0xCADF, 0x5FE4, 0xCADE,\r\n\t0x5FE5, 0xCC79, 0x5FE8, 0xCADA, 0x5FEA, 0xA7D8, 0x5FEB, 0xA7D6,\t0x5FED, 0xCAD9, 0x5FEE, 0xCADB, 0x5FEF, 0xCAE1, 0x5FF1, 0xA7D5,\r\n\t0x5FF3, 0xCADC, 0x5FF4, 0xCAE5, 0x5FF5, 0xA9C0, 0x5FF7, 0xCAE2,\t0x5FF8, 0xA7D7, 0x5FFA, 0xCAE0, 0x5FFB, 0xCAE3, 0x5FFD, 0xA9BF,\r\n\t0x5FFF, 0xA9C1, 0x6000, 0xCAE4, 0x6009, 0xCCAF, 0x600A, 0xCCA2,\t0x600B, 0xCC7E, 0x600C, 0xCCAE, 0x600D, 0xCCA9, 0x600E, 0xABE7,\r\n\t0x600F, 0xA9C2, 0x6010, 0xCCAA, 0x6011, 0xCCAD, 0x6012, 0xABE3,\t0x6013, 0xCCAC, 0x6014, 0xA9C3, 0x6015, 0xA9C8, 0x6016, 0xA9C6,\r\n\t0x6017, 0xCCA3, 0x6019, 0xCC7C, 0x601A, 0xCCA5, 0x601B, 0xA9CD,\t0x601C, 0xCCB0, 0x601D, 0xABE4, 0x601E, 0xCCA6, 0x6020, 0xABE5,\r\n\t0x6021, 0xA9C9, 0x6022, 0xCCA8, 0x6024, 0xCECD, 0x6025, 0xABE6,\t0x6026, 0xCC7B, 0x6027, 0xA9CA, 0x6028, 0xABE8, 0x6029, 0xA9CB,\r\n\t0x602A, 0xA9C7, 0x602B, 0xA9CC, 0x602C, 0xCCA7, 0x602D, 0xCC7A,\t0x602E, 0xCCAB, 0x602F, 0xA9C4, 0x6032, 0xCC7D, 0x6033, 0xCCA4,\r\n\t0x6034, 0xCCA1, 0x6035, 0xA9C5, 0x6037, 0xCEBF, 0x6039, 0xCEC0,\t0x6040, 0xCECA, 0x6041, 0xD1A1, 0x6042, 0xCECB, 0x6043, 0xABEE,\r\n\t0x6044, 0xCECE, 0x6045, 0xCEC4, 0x6046, 0xABED, 0x6047, 0xCEC6,\t0x6049, 0xCEC7, 0x604C, 0xCEC9, 0x604D, 0xABE9, 0x6050, 0xAEA3,\r\n\t0x6052, 0xF9DA, 0x6053, 0xCEC5, 0x6054, 0xCEC1, 0x6055, 0xAEA4,\t0x6058, 0xCECF, 0x6059, 0xAE7E, 0x605A, 0xD17D, 0x605B, 0xCEC8,\r\n\t0x605D, 0xD17C, 0x605E, 0xCEC3, 0x605F, 0xCECC, 0x6062, 0xABEC,\t0x6063, 0xAEA1, 0x6064, 0xABF2, 0x6065, 0xAEA2, 0x6066, 0xCED0,\r\n\t0x6067, 0xD17E, 0x6068, 0xABEB, 0x6069, 0xAEA6, 0x606A, 0xABF1,\t0x606B, 0xABF0, 0x606C, 0xABEF, 0x606D, 0xAEA5, 0x606E, 0xCED1,\r\n\t0x606F, 0xAEA7, 0x6070, 0xABEA, 0x6072, 0xCEC2, 0x607F, 0xB176,\t0x6080, 0xD1A4, 0x6081, 0xD1A6, 0x6083, 0xD1A8, 0x6084, 0xAEA8,\r\n\t0x6085, 0xAEAE, 0x6086, 0xD553, 0x6087, 0xD1AC, 0x6088, 0xD1A3,\t0x6089, 0xB178, 0x608A, 0xD551, 0x608C, 0xAEAD, 0x608D, 0xAEAB,\r\n\t0x608E, 0xD1AE, 0x6090, 0xD552, 0x6092, 0xD1A5, 0x6094, 0xAEAC,\t0x6095, 0xD1A9, 0x6096, 0xAEAF, 0x6097, 0xD1AB, 0x609A, 0xAEAA,\r\n\t0x609B, 0xD1AA, 0x609C, 0xD1AD, 0x609D, 0xD1A7, 0x609F, 0xAEA9,\t0x60A0, 0xB179, 0x60A2, 0xD1A2, 0x60A3, 0xB177, 0x60A8, 0xB17A,\r\n\t0x60B0, 0xD555, 0x60B1, 0xD55E, 0x60B2, 0xB464, 0x60B4, 0xB17C,\t0x60B5, 0xB1A3, 0x60B6, 0xB465, 0x60B7, 0xD560, 0x60B8, 0xB1AA,\r\n\t0x60B9, 0xD8F9, 0x60BA, 0xD556, 0x60BB, 0xB1A2, 0x60BC, 0xB1A5,\t0x60BD, 0xB17E, 0x60BE, 0xD554, 0x60BF, 0xD562, 0x60C0, 0xD565,\r\n\t0x60C1, 0xD949, 0x60C3, 0xD563, 0x60C4, 0xD8FD, 0x60C5, 0xB1A1,\t0x60C6, 0xB1A8, 0x60C7, 0xB1AC, 0x60C8, 0xD55D, 0x60C9, 0xD8F8,\r\n\t0x60CA, 0xD561, 0x60CB, 0xB17B, 0x60CC, 0xD8FA, 0x60CD, 0xD564,\t0x60CE, 0xD8FC, 0x60CF, 0xD559, 0x60D1, 0xB462, 0x60D3, 0xD557,\r\n\t0x60D4, 0xD558, 0x60D5, 0xB1A7, 0x60D8, 0xB1A6, 0x60D9, 0xD55B,\t0x60DA, 0xB1AB, 0x60DB, 0xD55F, 0x60DC, 0xB1A4, 0x60DD, 0xD55C,\r\n\t0x60DF, 0xB1A9, 0x60E0, 0xB466, 0x60E1, 0xB463, 0x60E2, 0xD8FB,\t0x60E4, 0xD55A, 0x60E6, 0xB17D, 0x60F0, 0xB46B, 0x60F1, 0xB46F,\r\n\t0x60F2, 0xD940, 0x60F3, 0xB751, 0x60F4, 0xB46D, 0x60F5, 0xD944,\t0x60F6, 0xB471, 0x60F7, 0xDD65, 0x60F8, 0xD946, 0x60F9, 0xB753,\r\n\t0x60FA, 0xB469, 0x60FB, 0xB46C, 0x60FC, 0xD947, 0x60FE, 0xD948,\t0x60FF, 0xD94E, 0x6100, 0xB473, 0x6101, 0xB754, 0x6103, 0xD94A,\r\n\t0x6104, 0xD94F, 0x6105, 0xD943, 0x6106, 0xB75E, 0x6108, 0xB755,\t0x6109, 0xB472, 0x610A, 0xD941, 0x610B, 0xD950, 0x610D, 0xB75D,\r\n\t0x610E, 0xB470, 0x610F, 0xB74E, 0x6110, 0xD94D, 0x6112, 0xB474,\t0x6113, 0xD945, 0x6114, 0xD8FE, 0x6115, 0xB46A, 0x6116, 0xD942,\r\n\t0x6118, 0xD94B, 0x611A, 0xB74D, 0x611B, 0xB752, 0x611C, 0xB467,\t0x611D, 0xD94C, 0x611F, 0xB750, 0x6123, 0xB468, 0x6127, 0xB75C,\r\n\t0x6128, 0xE1C3, 0x6129, 0xDD70, 0x612B, 0xDD68, 0x612C, 0xE1C2,\t0x612E, 0xDD6C, 0x612F, 0xDD6E, 0x6132, 0xDD6B, 0x6134, 0xB75B,\r\n\t0x6136, 0xDD6A, 0x6137, 0xB75F, 0x613B, 0xE1D2, 0x613E, 0xB75A,\t0x613F, 0xBA40, 0x6140, 0xDD71, 0x6141, 0xE1C4, 0x6144, 0xB758,\r\n\t0x6145, 0xDD69, 0x6146, 0xDD6D, 0x6147, 0xB9FE, 0x6148, 0xB74F,\t0x6149, 0xDD66, 0x614A, 0xDD67, 0x614B, 0xBA41, 0x614C, 0xB757,\r\n\t0x614D, 0xB759, 0x614E, 0xB756, 0x614F, 0xDD6F, 0x6152, 0xE1C8,\t0x6153, 0xE1C9, 0x6154, 0xE1CE, 0x6155, 0xBC7D, 0x6156, 0xE1D5,\r\n\t0x6158, 0xBA47, 0x615A, 0xBA46, 0x615B, 0xE1D0, 0x615D, 0xBC7C,\t0x615E, 0xE1C5, 0x615F, 0xBA45, 0x6161, 0xE1D4, 0x6162, 0xBA43,\r\n\t0x6163, 0xBA44, 0x6165, 0xE1D1, 0x6166, 0xE5AA, 0x6167, 0xBC7A,\t0x6168, 0xB46E, 0x616A, 0xE1D3, 0x616B, 0xBCA3, 0x616C, 0xE1CB,\r\n\t0x616E, 0xBC7B, 0x6170, 0xBCA2, 0x6171, 0xE1C6, 0x6172, 0xE1CA,\t0x6173, 0xE1C7, 0x6174, 0xE1CD, 0x6175, 0xBA48, 0x6176, 0xBC79,\r\n\t0x6177, 0xBA42, 0x6179, 0xE57A, 0x617A, 0xE1CF, 0x617C, 0xBCA1,\t0x617E, 0xBCA4, 0x6180, 0xE1CC, 0x6182, 0xBC7E, 0x6183, 0xE579,\r\n\t0x6189, 0xE57E, 0x618A, 0xBECE, 0x618B, 0xE578, 0x618C, 0xE9A3,\t0x618D, 0xE5A9, 0x618E, 0xBCA8, 0x6190, 0xBCA6, 0x6191, 0xBECC,\r\n\t0x6192, 0xE5A6, 0x6193, 0xE5A2, 0x6194, 0xBCAC, 0x6196, 0xE978,\t0x619A, 0xBCAA, 0x619B, 0xE5A1, 0x619D, 0xE976, 0x619F, 0xE5A5,\r\n\t0x61A1, 0xE5A8, 0x61A2, 0xE57D, 0x61A4, 0xBCAB, 0x61A7, 0xBCA5,\t0x61A8, 0xE977, 0x61A9, 0xBECD, 0x61AA, 0xE5A7, 0x61AB, 0xBCA7,\r\n\t0x61AC, 0xBCA9, 0x61AD, 0xE5A4, 0x61AE, 0xBCAD, 0x61AF, 0xE5A3,\t0x61B0, 0xE57C, 0x61B1, 0xE57B, 0x61B2, 0xBECB, 0x61B3, 0xE5AB,\r\n\t0x61B4, 0xE97A, 0x61B5, 0xECE0, 0x61B6, 0xBED0, 0x61B8, 0xE9A2,\t0x61BA, 0xE97E, 0x61BC, 0xECE1, 0x61BE, 0xBED1, 0x61BF, 0xE9A1,\r\n\t0x61C1, 0xE97C, 0x61C2, 0xC0B4, 0x61C3, 0xECDF, 0x61C5, 0xE979,\t0x61C6, 0xE97B, 0x61C7, 0xC0B5, 0x61C8, 0xBED3, 0x61C9, 0xC0B3,\r\n\t0x61CA, 0xBED2, 0x61CB, 0xC0B7, 0x61CC, 0xE97D, 0x61CD, 0xBECF,\t0x61D6, 0xEFCF, 0x61D8, 0xEFC7, 0x61DE, 0xECE7, 0x61DF, 0xEFC8,\r\n\t0x61E0, 0xECE3, 0x61E3, 0xC256, 0x61E4, 0xECE5, 0x61E5, 0xECE4,\t0x61E6, 0xC0B6, 0x61E7, 0xECE2, 0x61E8, 0xECE6, 0x61E9, 0xEFD0,\r\n\t0x61EA, 0xEFCC, 0x61EB, 0xEFCE, 0x61ED, 0xEFC9, 0x61EE, 0xEFCA,\t0x61F0, 0xEFCD, 0x61F1, 0xEFCB, 0x61F2, 0xC367, 0x61F5, 0xC36A,\r\n\t0x61F6, 0xC369, 0x61F7, 0xC368, 0x61F8, 0xC461, 0x61F9, 0xF44A,\t0x61FA, 0xC462, 0x61FB, 0xF241, 0x61FC, 0xC4DF, 0x61FD, 0xF5CC,\r\n\t0x61FE, 0xC4E0, 0x61FF, 0xC574, 0x6200, 0xC5CA, 0x6201, 0xF7D9,\t0x6203, 0xF7DA, 0x6204, 0xF7DB, 0x6207, 0xF9BA, 0x6208, 0xA4E0,\r\n\t0x6209, 0xC97C, 0x620A, 0xA5B3, 0x620C, 0xA6A6, 0x620D, 0xA6A7,\t0x620E, 0xA6A5, 0x6210, 0xA6A8, 0x6211, 0xA7DA, 0x6212, 0xA7D9,\r\n\t0x6214, 0xCCB1, 0x6215, 0xA9CF, 0x6216, 0xA9CE, 0x6219, 0xD1AF,\t0x621A, 0xB1AD, 0x621B, 0xB1AE, 0x621F, 0xB475, 0x6220, 0xDD72,\r\n\t0x6221, 0xB760, 0x6222, 0xB761, 0x6223, 0xDD74, 0x6224, 0xDD76,\t0x6225, 0xDD75, 0x6227, 0xE1D7, 0x6229, 0xE1D6, 0x622A, 0xBA49,\r\n\t0x622B, 0xE1D8, 0x622D, 0xE5AC, 0x622E, 0xBCAE, 0x6230, 0xBED4,\t0x6232, 0xC0B8, 0x6233, 0xC257, 0x6234, 0xC0B9, 0x6236, 0xA4E1,\r\n\t0x623A, 0xCAE6, 0x623D, 0xCCB2, 0x623E, 0xA9D1, 0x623F, 0xA9D0,\t0x6240, 0xA9D2, 0x6241, 0xABF3, 0x6242, 0xCED2, 0x6243, 0xCED3,\r\n\t0x6246, 0xD1B0, 0x6247, 0xAEB0, 0x6248, 0xB1AF, 0x6249, 0xB476,\t0x624A, 0xD951, 0x624B, 0xA4E2, 0x624D, 0xA47E, 0x624E, 0xA4E3,\r\n\t0x6250, 0xC97D, 0x6251, 0xA5B7, 0x6252, 0xA5B6, 0x6253, 0xA5B4,\t0x6254, 0xA5B5, 0x6258, 0xA6AB, 0x6259, 0xC9E9, 0x625A, 0xC9EB,\r\n\t0x625B, 0xA6AA, 0x625C, 0xC9E3, 0x625E, 0xC9E4, 0x6260, 0xC9EA,\t0x6261, 0xC9E6, 0x6262, 0xC9E8, 0x6263, 0xA6A9, 0x6264, 0xC9E5,\r\n\t0x6265, 0xC9EC, 0x6266, 0xC9E7, 0x626D, 0xA7E1, 0x626E, 0xA7EA,\t0x626F, 0xA7E8, 0x6270, 0xCAF0, 0x6271, 0xCAED, 0x6272, 0xCAF5,\r\n\t0x6273, 0xA7E6, 0x6274, 0xCAF6, 0x6276, 0xA7DF, 0x6277, 0xCAF3,\t0x6279, 0xA7E5, 0x627A, 0xCAEF, 0x627B, 0xCAEE, 0x627C, 0xA7E3,\r\n\t0x627D, 0xCAF4, 0x627E, 0xA7E4, 0x627F, 0xA9D3, 0x6280, 0xA7DE,\t0x6281, 0xCAF1, 0x6283, 0xCAE7, 0x6284, 0xA7DB, 0x6286, 0xA7EE,\r\n\t0x6287, 0xCAEC, 0x6288, 0xCAF2, 0x6289, 0xA7E0, 0x628A, 0xA7E2,\t0x628C, 0xCAE8, 0x628E, 0xCAE9, 0x628F, 0xCAEA, 0x6291, 0xA7ED,\r\n\t0x6292, 0xA7E7, 0x6293, 0xA7EC, 0x6294, 0xCAEB, 0x6295, 0xA7EB,\t0x6296, 0xA7DD, 0x6297, 0xA7DC, 0x6298, 0xA7E9, 0x62A8, 0xA9E1,\r\n\t0x62A9, 0xCCBE, 0x62AA, 0xCCB7, 0x62AB, 0xA9DC, 0x62AC, 0xA9EF,\t0x62AD, 0xCCB3, 0x62AE, 0xCCBA, 0x62AF, 0xCCBC, 0x62B0, 0xCCBF,\r\n\t0x62B1, 0xA9EA, 0x62B3, 0xCCBB, 0x62B4, 0xCCB4, 0x62B5, 0xA9E8,\t0x62B6, 0xCCB8, 0x62B8, 0xCCC0, 0x62B9, 0xA9D9, 0x62BB, 0xCCBD,\r\n\t0x62BC, 0xA9E3, 0x62BD, 0xA9E2, 0x62BE, 0xCCB6, 0x62BF, 0xA9D7,\t0x62C2, 0xA9D8, 0x62C4, 0xA9D6, 0x62C6, 0xA9EE, 0x62C7, 0xA9E6,\r\n\t0x62C8, 0xA9E0, 0x62C9, 0xA9D4, 0x62CA, 0xCCB9, 0x62CB, 0xA9DF,\t0x62CC, 0xA9D5, 0x62CD, 0xA9E7, 0x62CE, 0xA9F0, 0x62CF, 0xCED4,\r\n\t0x62D0, 0xA9E4, 0x62D1, 0xCCB5, 0x62D2, 0xA9DA, 0x62D3, 0xA9DD,\t0x62D4, 0xA9DE, 0x62D6, 0xA9EC, 0x62D7, 0xA9ED, 0x62D8, 0xA9EB,\r\n\t0x62D9, 0xA9E5, 0x62DA, 0xA9E9, 0x62DB, 0xA9DB, 0x62DC, 0xABF4,\t0x62EB, 0xCEDA, 0x62EC, 0xAC41, 0x62ED, 0xABF8, 0x62EE, 0xABFA,\r\n\t0x62EF, 0xAC40, 0x62F0, 0xCEE6, 0x62F1, 0xABFD, 0x62F2, 0xD1B1,\t0x62F3, 0xAEB1, 0x62F4, 0xAC43, 0x62F5, 0xCED7, 0x62F6, 0xCEDF,\r\n\t0x62F7, 0xABFE, 0x62F8, 0xCEDE, 0x62F9, 0xCEDB, 0x62FA, 0xCEE3,\t0x62FB, 0xCEE5, 0x62FC, 0xABF7, 0x62FD, 0xABFB, 0x62FE, 0xAC42,\r\n\t0x62FF, 0xAEB3, 0x6300, 0xCEE0, 0x6301, 0xABF9, 0x6302, 0xAC45,\t0x6303, 0xCED9, 0x6307, 0xABFC, 0x6308, 0xAEB2, 0x6309, 0xABF6,\r\n\t0x630B, 0xCED6, 0x630C, 0xCEDD, 0x630D, 0xCED5, 0x630E, 0xCED8,\t0x630F, 0xCEDC, 0x6310, 0xD1B2, 0x6311, 0xAC44, 0x6313, 0xCEE1,\r\n\t0x6314, 0xCEE2, 0x6315, 0xCEE4, 0x6316, 0xABF5, 0x6328, 0xAEC1,\t0x6329, 0xD1BE, 0x632A, 0xAEBF, 0x632B, 0xAEC0, 0x632C, 0xD1B4,\r\n\t0x632D, 0xD1C4, 0x632F, 0xAEB6, 0x6332, 0xD566, 0x6333, 0xD1C6,\t0x6334, 0xD1C0, 0x6336, 0xD1B7, 0x6338, 0xD1C9, 0x6339, 0xD1BA,\r\n\t0x633A, 0xAEBC, 0x633B, 0xD57D, 0x633C, 0xD1BD, 0x633D, 0xAEBE,\t0x633E, 0xAEB5, 0x6340, 0xD1CB, 0x6341, 0xD1BF, 0x6342, 0xAEB8,\r\n\t0x6343, 0xD1B8, 0x6344, 0xD1B5, 0x6345, 0xD1B6, 0x6346, 0xAEB9,\t0x6347, 0xD1C5, 0x6348, 0xD1CC, 0x6349, 0xAEBB, 0x634A, 0xD1BC,\r\n\t0x634B, 0xD1BB, 0x634C, 0xAEC3, 0x634D, 0xAEC2, 0x634E, 0xAEB4,\t0x634F, 0xAEBA, 0x6350, 0xAEBD, 0x6351, 0xD1C8, 0x6354, 0xD1C2,\r\n\t0x6355, 0xAEB7, 0x6356, 0xD1B3, 0x6357, 0xD1CA, 0x6358, 0xD1C1,\t0x6359, 0xD1C3, 0x635A, 0xD1C7, 0x6365, 0xD567, 0x6367, 0xB1B7,\r\n\t0x6368, 0xB1CB, 0x6369, 0xB1CA, 0x636B, 0xB1BF, 0x636D, 0xD579,\t0x636E, 0xD575, 0x636F, 0xD572, 0x6370, 0xD5A6, 0x6371, 0xB1BA,\r\n\t0x6372, 0xB1B2, 0x6375, 0xD577, 0x6376, 0xB4A8, 0x6377, 0xB1B6,\t0x6378, 0xD5A1, 0x637A, 0xB1CC, 0x637B, 0xB1C9, 0x637C, 0xD57B,\r\n\t0x637D, 0xD56A, 0x6380, 0xB1C8, 0x6381, 0xD5A3, 0x6382, 0xD569,\t0x6383, 0xB1BD, 0x6384, 0xB1C1, 0x6385, 0xD5A2, 0x6387, 0xD573,\r\n\t0x6388, 0xB1C2, 0x6389, 0xB1BC, 0x638A, 0xD568, 0x638C, 0xB478,\t0x638D, 0xD5A5, 0x638E, 0xD571, 0x638F, 0xB1C7, 0x6390, 0xD574,\r\n\t0x6391, 0xD5A4, 0x6392, 0xB1C6, 0x6394, 0xD952, 0x6396, 0xB1B3,\t0x6397, 0xD56F, 0x6398, 0xB1B8, 0x6399, 0xB1C3, 0x639B, 0xB1BE,\r\n\t0x639C, 0xD578, 0x639D, 0xD56E, 0x639E, 0xD56C, 0x639F, 0xD57E,\t0x63A0, 0xB1B0, 0x63A1, 0xB1C4, 0x63A2, 0xB1B4, 0x63A3, 0xB477,\r\n\t0x63A4, 0xD57C, 0x63A5, 0xB1B5, 0x63A7, 0xB1B1, 0x63A8, 0xB1C0,\t0x63A9, 0xB1BB, 0x63AA, 0xB1B9, 0x63AB, 0xD570, 0x63AC, 0xB1C5,\r\n\t0x63AD, 0xD56D, 0x63AE, 0xD57A, 0x63AF, 0xD576, 0x63B0, 0xD954,\t0x63B1, 0xD953, 0x63BD, 0xD56B, 0x63BE, 0xD964, 0x63C0, 0xB47A,\r\n\t0x63C2, 0xD96A, 0x63C3, 0xD959, 0x63C4, 0xD967, 0x63C5, 0xDD77,\t0x63C6, 0xB47D, 0x63C7, 0xD96B, 0x63C8, 0xD96E, 0x63C9, 0xB47C,\r\n\t0x63CA, 0xD95C, 0x63CB, 0xD96D, 0x63CC, 0xD96C, 0x63CD, 0xB47E,\t0x63CE, 0xD955, 0x63CF, 0xB479, 0x63D0, 0xB4A3, 0x63D2, 0xB4A1,\r\n\t0x63D3, 0xD969, 0x63D5, 0xD95F, 0x63D6, 0xB4A5, 0x63D7, 0xD970,\t0x63D8, 0xD968, 0x63D9, 0xD971, 0x63DA, 0xB4AD, 0x63DB, 0xB4AB,\r\n\t0x63DC, 0xD966, 0x63DD, 0xD965, 0x63DF, 0xD963, 0x63E0, 0xD95D,\t0x63E1, 0xB4A4, 0x63E3, 0xB4A2, 0x63E4, 0xD1B9, 0x63E5, 0xD956,\r\n\t0x63E7, 0xDDB7, 0x63E8, 0xD957, 0x63E9, 0xB47B, 0x63EA, 0xB4AA,\t0x63EB, 0xDD79, 0x63ED, 0xB4A6, 0x63EE, 0xB4A7, 0x63EF, 0xD958,\r\n\t0x63F0, 0xD96F, 0x63F1, 0xDD78, 0x63F2, 0xD960, 0x63F3, 0xD95B,\t0x63F4, 0xB4A9, 0x63F5, 0xD961, 0x63F6, 0xD95E, 0x63F9, 0xB4AE,\r\n\t0x6406, 0xB770, 0x6409, 0xDD7C, 0x640A, 0xDDB1, 0x640B, 0xDDB6,\t0x640C, 0xDDAA, 0x640D, 0xB76C, 0x640E, 0xDDBB, 0x640F, 0xB769,\r\n\t0x6410, 0xDD7A, 0x6412, 0xDD7B, 0x6413, 0xB762, 0x6414, 0xB76B,\t0x6415, 0xDDA4, 0x6416, 0xB76E, 0x6417, 0xB76F, 0x6418, 0xDDA5,\r\n\t0x641A, 0xDDB2, 0x641B, 0xDDB8, 0x641C, 0xB76A, 0x641E, 0xB764,\t0x641F, 0xDDA3, 0x6420, 0xDD7D, 0x6421, 0xDDBA, 0x6422, 0xDDA8,\r\n\t0x6423, 0xDDA9, 0x6424, 0xDD7E, 0x6425, 0xDDB4, 0x6426, 0xDDAB,\t0x6427, 0xDDB5, 0x6428, 0xDDAD, 0x642A, 0xB765, 0x642B, 0xE1D9,\r\n\t0x642C, 0xB768, 0x642D, 0xB766, 0x642E, 0xDDB9, 0x642F, 0xDDB0,\t0x6430, 0xDDAC, 0x6433, 0xDDA1, 0x6434, 0xBA53, 0x6435, 0xDDAF,\r\n\t0x6436, 0xB76D, 0x6437, 0xDDA7, 0x6439, 0xDDA6, 0x643D, 0xB767,\t0x643E, 0xB763, 0x643F, 0xE1EE, 0x6440, 0xDDB3, 0x6441, 0xDDAE,\r\n\t0x6443, 0xDDA2, 0x644B, 0xE1E9, 0x644D, 0xE1DA, 0x644E, 0xE1E5,\t0x6450, 0xE1EC, 0x6451, 0xBA51, 0x6452, 0xB4AC, 0x6453, 0xE1EA,\r\n\t0x6454, 0xBA4C, 0x6458, 0xBA4B, 0x6459, 0xE1F1, 0x645B, 0xE1DB,\t0x645C, 0xE1E8, 0x645D, 0xE1DC, 0x645E, 0xE1E7, 0x645F, 0xBA4F,\r\n\t0x6460, 0xE1EB, 0x6461, 0xD962, 0x6465, 0xE1F2, 0x6466, 0xE1E3,\t0x6467, 0xBA52, 0x6468, 0xE5BA, 0x6469, 0xBCAF, 0x646B, 0xE1F0,\r\n\t0x646C, 0xE1EF, 0x646D, 0xBA54, 0x646E, 0xE5AD, 0x646F, 0xBCB0,\t0x6470, 0xE5AE, 0x6472, 0xE1DF, 0x6473, 0xE1E0, 0x6474, 0xE1DD,\r\n\t0x6475, 0xE1E2, 0x6476, 0xE1DE, 0x6477, 0xE1F3, 0x6478, 0xBA4E,\t0x6479, 0xBCB1, 0x647A, 0xBA50, 0x647B, 0xBA55, 0x647D, 0xE1E1,\r\n\t0x647F, 0xE1ED, 0x6482, 0xE1E6, 0x6485, 0xE5B1, 0x6487, 0xBA4A,\t0x6488, 0xBCB4, 0x6489, 0xE9AA, 0x648A, 0xE5B6, 0x648B, 0xE5B5,\r\n\t0x648C, 0xE5B7, 0x648F, 0xE5B4, 0x6490, 0xBCB5, 0x6492, 0xBCBB,\t0x6493, 0xBCB8, 0x6495, 0xBCB9, 0x6496, 0xE5AF, 0x6497, 0xE5B2,\r\n\t0x6498, 0xE5BC, 0x6499, 0xBCC1, 0x649A, 0xBCBF, 0x649C, 0xE5B3,\t0x649D, 0xD95A, 0x649E, 0xBCB2, 0x649F, 0xE5B9, 0x64A0, 0xE5B0,\r\n\t0x64A2, 0xBCC2, 0x64A3, 0xE5B8, 0x64A4, 0xBA4D, 0x64A5, 0xBCB7,\t0x64A6, 0xE1E4, 0x64A9, 0xBCBA, 0x64AB, 0xBCBE, 0x64AC, 0xBCC0,\r\n\t0x64AD, 0xBCBD, 0x64AE, 0xBCBC, 0x64B0, 0xBCB6, 0x64B1, 0xE5BB,\t0x64B2, 0xBCB3, 0x64B3, 0xBCC3, 0x64BB, 0xBED8, 0x64BC, 0xBED9,\r\n\t0x64BD, 0xE9A9, 0x64BE, 0xBEE2, 0x64BF, 0xBEDF, 0x64C1, 0xBED6,\t0x64C2, 0xBEDD, 0x64C3, 0xE9AB, 0x64C4, 0xBEDB, 0x64C5, 0xBED5,\r\n\t0x64C7, 0xBEDC, 0x64C9, 0xE9A8, 0x64CA, 0xC0BB, 0x64CB, 0xBED7,\t0x64CD, 0xBEDE, 0x64CE, 0xC0BA, 0x64CF, 0xE9A7, 0x64D0, 0xE9A6,\r\n\t0x64D2, 0xBEE0, 0x64D4, 0xBEE1, 0x64D6, 0xE9A5, 0x64D7, 0xE9A4,\t0x64D8, 0xC0BC, 0x64D9, 0xE9AE, 0x64DA, 0xBEDA, 0x64DB, 0xE9AC,\r\n\t0x64E0, 0xC0BD, 0x64E2, 0xC0C2, 0x64E3, 0xECEA, 0x64E4, 0xECEC,\t0x64E6, 0xC0BF, 0x64E8, 0xECED, 0x64E9, 0xECE9, 0x64EB, 0xECEB,\r\n\t0x64EC, 0xC0C0, 0x64ED, 0xC0C3, 0x64EF, 0xECE8, 0x64F0, 0xC0BE,\t0x64F1, 0xC0C1, 0x64F2, 0xC259, 0x64F3, 0xE9AD, 0x64F4, 0xC258,\r\n\t0x64F7, 0xC25E, 0x64F8, 0xEFD4, 0x64FA, 0xC25C, 0x64FB, 0xC25D,\t0x64FC, 0xEFD7, 0x64FD, 0xEFD3, 0x64FE, 0xC25A, 0x64FF, 0xEFD1,\r\n\t0x6500, 0xC36B, 0x6501, 0xEFD5, 0x6503, 0xEFD6, 0x6504, 0xEFD2,\t0x6506, 0xC25B, 0x6507, 0xF242, 0x6509, 0xF245, 0x650C, 0xF246,\r\n\t0x650D, 0xF244, 0x650E, 0xF247, 0x650F, 0xC36C, 0x6510, 0xF243,\t0x6513, 0xF44E, 0x6514, 0xC464, 0x6515, 0xF44D, 0x6516, 0xF44C,\r\n\t0x6517, 0xF44B, 0x6518, 0xC463, 0x6519, 0xC465, 0x651B, 0xF5CD,\t0x651C, 0xC4E2, 0x651D, 0xC4E1, 0x6520, 0xF6E1, 0x6521, 0xF6E0,\r\n\t0x6522, 0xF6E3, 0x6523, 0xC5CB, 0x6524, 0xC575, 0x6525, 0xF7DD,\t0x6526, 0xF6E2, 0x6529, 0xF7DC, 0x652A, 0xC5CD, 0x652B, 0xC5CC,\r\n\t0x652C, 0xC5F3, 0x652D, 0xF8A9, 0x652E, 0xF8EF, 0x652F, 0xA4E4,\t0x6532, 0xD972, 0x6533, 0xE9AF, 0x6536, 0xA6AC, 0x6537, 0xCAF7,\r\n\t0x6538, 0xA7F1, 0x6539, 0xA7EF, 0x653B, 0xA7F0, 0x653D, 0xCCC1,\t0x653E, 0xA9F1, 0x653F, 0xAC46, 0x6541, 0xCEE7, 0x6543, 0xCEE8,\r\n\t0x6545, 0xAC47, 0x6546, 0xD1CE, 0x6548, 0xAEC4, 0x6549, 0xAEC5,\t0x654A, 0xD1CD, 0x654F, 0xB1D3, 0x6551, 0xB1CF, 0x6553, 0xD5A7,\r\n\t0x6554, 0xB1D6, 0x6555, 0xB1D5, 0x6556, 0xB1CE, 0x6557, 0xB1D1,\t0x6558, 0xB1D4, 0x6559, 0xB1D0, 0x655C, 0xD976, 0x655D, 0xB1CD,\r\n\t0x655E, 0xB4AF, 0x6562, 0xB4B1, 0x6563, 0xB4B2, 0x6564, 0xD975,\t0x6565, 0xD978, 0x6566, 0xB4B0, 0x6567, 0xD973, 0x6568, 0xD977,\r\n\t0x656A, 0xD974, 0x656C, 0xB771, 0x656F, 0xDDBC, 0x6572, 0xBA56,\t0x6573, 0xE1F4, 0x6574, 0xBEE3, 0x6575, 0xBCC4, 0x6576, 0xE5BD,\r\n\t0x6577, 0xBCC5, 0x6578, 0xBCC6, 0x6579, 0xE5BF, 0x657A, 0xE5BE,\t0x657B, 0xE5C0, 0x657C, 0xE9B1, 0x657F, 0xE9B0, 0x6580, 0xECEF,\r\n\t0x6581, 0xECEE, 0x6582, 0xC0C4, 0x6583, 0xC0C5, 0x6584, 0xF248,\t0x6587, 0xA4E5, 0x658C, 0xD979, 0x6590, 0xB4B4, 0x6591, 0xB4B3,\r\n\t0x6592, 0xDDBD, 0x6594, 0xEFD8, 0x6595, 0xC4E3, 0x6596, 0xF7DE,\t0x6597, 0xA4E6, 0x6599, 0xAEC6, 0x659B, 0xB1D8, 0x659C, 0xB1D7,\r\n\t0x659D, 0xD97A, 0x659E, 0xD97B, 0x659F, 0xB772, 0x65A0, 0xE1F5,\t0x65A1, 0xBA57, 0x65A2, 0xE9B2, 0x65A4, 0xA4E7, 0x65A5, 0xA5B8,\r\n\t0x65A7, 0xA9F2, 0x65A8, 0xCCC2, 0x65AA, 0xCEE9, 0x65AB, 0xAC48,\t0x65AC, 0xB1D9, 0x65AE, 0xD97C, 0x65AF, 0xB4B5, 0x65B0, 0xB773,\r\n\t0x65B2, 0xE5C1, 0x65B3, 0xE5C2, 0x65B6, 0xECF0, 0x65B7, 0xC25F,\t0x65B8, 0xF8F0, 0x65B9, 0xA4E8, 0x65BB, 0xCCC3, 0x65BC, 0xA9F3,\r\n\t0x65BD, 0xAC49, 0x65BF, 0xCEEA, 0x65C1, 0xAEC7, 0x65C2, 0xD1D2,\t0x65C3, 0xD1D0, 0x65C4, 0xD1D1, 0x65C5, 0xAEC8, 0x65C6, 0xD1CF,\r\n\t0x65CB, 0xB1DB, 0x65CC, 0xB1DC, 0x65CD, 0xD5A8, 0x65CE, 0xB1DD,\t0x65CF, 0xB1DA, 0x65D0, 0xD97D, 0x65D2, 0xD97E, 0x65D3, 0xDDBE,\r\n\t0x65D6, 0xBA59, 0x65D7, 0xBA58, 0x65DA, 0xECF1, 0x65DB, 0xEFD9,\t0x65DD, 0xF24A, 0x65DE, 0xF249, 0x65DF, 0xF44F, 0x65E1, 0xC95E,\r\n\t0x65E2, 0xAC4A, 0x65E5, 0xA4E9, 0x65E6, 0xA5B9, 0x65E8, 0xA6AE,\t0x65E9, 0xA6AD, 0x65EC, 0xA6AF, 0x65ED, 0xA6B0, 0x65EE, 0xC9EE,\r\n\t0x65EF, 0xC9ED, 0x65F0, 0xCAF8, 0x65F1, 0xA7F2, 0x65F2, 0xCAFB,\t0x65F3, 0xCAFA, 0x65F4, 0xCAF9, 0x65F5, 0xCAFC, 0x65FA, 0xA9F4,\r\n\t0x65FB, 0xCCC9, 0x65FC, 0xCCC5, 0x65FD, 0xCCCE, 0x6600, 0xA9FB,\t0x6602, 0xA9F9, 0x6603, 0xCCCA, 0x6604, 0xCCC6, 0x6605, 0xCCCD,\r\n\t0x6606, 0xA9F8, 0x6607, 0xAA40, 0x6608, 0xCCC8, 0x6609, 0xCCC4,\t0x660A, 0xA9FE, 0x660B, 0xCCCB, 0x660C, 0xA9F7, 0x660D, 0xCCCC,\r\n\t0x660E, 0xA9FA, 0x660F, 0xA9FC, 0x6610, 0xCCD0, 0x6611, 0xCCCF,\t0x6612, 0xCCC7, 0x6613, 0xA9F6, 0x6614, 0xA9F5, 0x6615, 0xA9FD,\r\n\t0x661C, 0xCEEF, 0x661D, 0xCEF5, 0x661F, 0xAC50, 0x6620, 0xAC4D,\t0x6621, 0xCEEC, 0x6622, 0xCEF1, 0x6624, 0xAC53, 0x6625, 0xAC4B,\r\n\t0x6626, 0xCEF0, 0x6627, 0xAC4E, 0x6628, 0xAC51, 0x662B, 0xCEF3,\t0x662D, 0xAC4C, 0x662E, 0xCEF8, 0x662F, 0xAC4F, 0x6631, 0xAC52,\r\n\t0x6632, 0xCEED, 0x6633, 0xCEF2, 0x6634, 0xCEF6, 0x6635, 0xCEEE,\t0x6636, 0xCEEB, 0x6639, 0xCEF7, 0x663A, 0xCEF4, 0x6641, 0xAED0,\r\n\t0x6642, 0xAEC9, 0x6643, 0xAECC, 0x6645, 0xAECF, 0x6647, 0xD1D5,\t0x6649, 0xAECA, 0x664A, 0xD1D3, 0x664C, 0xAECE, 0x664F, 0xAECB,\r\n\t0x6651, 0xD1D6, 0x6652, 0xAECD, 0x6659, 0xD5AC, 0x665A, 0xB1DF,\t0x665B, 0xD5AB, 0x665C, 0xD5AD, 0x665D, 0xB1DE, 0x665E, 0xB1E3,\r\n\t0x665F, 0xD1D4, 0x6661, 0xD5AA, 0x6662, 0xD5AE, 0x6664, 0xB1E0,\t0x6665, 0xD5A9, 0x6666, 0xB1E2, 0x6668, 0xB1E1, 0x666A, 0xD9A7,\r\n\t0x666C, 0xD9A2, 0x666E, 0xB4B6, 0x666F, 0xB4BA, 0x6670, 0xB4B7,\t0x6671, 0xD9A5, 0x6672, 0xD9A8, 0x6674, 0xB4B8, 0x6676, 0xB4B9,\r\n\t0x6677, 0xB4BE, 0x6678, 0xDDC7, 0x6679, 0xD9A6, 0x667A, 0xB4BC,\t0x667B, 0xD9A3, 0x667C, 0xD9A1, 0x667E, 0xB4BD, 0x6680, 0xD9A4,\r\n\t0x6684, 0xB779, 0x6686, 0xDDBF, 0x6687, 0xB776, 0x6688, 0xB777,\t0x6689, 0xB775, 0x668A, 0xDDC4, 0x668B, 0xDDC3, 0x668C, 0xDDC0,\r\n\t0x668D, 0xB77B, 0x6690, 0xDDC2, 0x6691, 0xB4BB, 0x6694, 0xDDC6,\t0x6695, 0xDDC1, 0x6696, 0xB778, 0x6697, 0xB774, 0x6698, 0xB77A,\r\n\t0x6699, 0xDDC5, 0x669D, 0xBA5C, 0x669F, 0xE1F8, 0x66A0, 0xE1F7,\t0x66A1, 0xE1F6, 0x66A2, 0xBA5A, 0x66A8, 0xBA5B, 0x66A9, 0xE5C5,\r\n\t0x66AA, 0xE5C8, 0x66AB, 0xBCC8, 0x66AE, 0xBCC7, 0x66AF, 0xE5C9,\t0x66B0, 0xE5C4, 0x66B1, 0xBCCA, 0x66B2, 0xE5C6, 0x66B4, 0xBCC9,\r\n\t0x66B5, 0xE5C3, 0x66B7, 0xE5C7, 0x66B8, 0xBEE9, 0x66B9, 0xBEE6,\t0x66BA, 0xE9BB, 0x66BB, 0xE9BA, 0x66BD, 0xE9B9, 0x66BE, 0xE9B4,\r\n\t0x66C0, 0xE9B5, 0x66C4, 0xBEE7, 0x66C6, 0xBEE4, 0x66C7, 0xBEE8,\t0x66C8, 0xE9B3, 0x66C9, 0xBEE5, 0x66CA, 0xE9B6, 0x66CB, 0xE9B7,\r\n\t0x66CC, 0xE9BC, 0x66CF, 0xE9B8, 0x66D2, 0xECF2, 0x66D6, 0xC0C7,\t0x66D8, 0xEFDC, 0x66D9, 0xC0C6, 0x66DA, 0xEFDA, 0x66DB, 0xEFDB,\r\n\t0x66DC, 0xC260, 0x66DD, 0xC36E, 0x66DE, 0xF24B, 0x66E0, 0xC36D,\t0x66E3, 0xF451, 0x66E4, 0xF452, 0x66E6, 0xC466, 0x66E8, 0xF450,\r\n\t0x66E9, 0xC4E4, 0x66EB, 0xF7DF, 0x66EC, 0xC5CE, 0x66ED, 0xF8AA,\t0x66EE, 0xF8AB, 0x66F0, 0xA4EA, 0x66F2, 0xA6B1, 0x66F3, 0xA6B2,\r\n\t0x66F4, 0xA7F3, 0x66F6, 0xCCD1, 0x66F7, 0xAC54, 0x66F8, 0xAED1,\t0x66F9, 0xB1E4, 0x66FC, 0xB0D2, 0x66FE, 0xB4BF, 0x66FF, 0xB4C0,\r\n\t0x6700, 0xB3CC, 0x6701, 0xD9A9, 0x6703, 0xB77C, 0x6704, 0xE1FA,\t0x6705, 0xE1F9, 0x6708, 0xA4EB, 0x6709, 0xA6B3, 0x670A, 0xCCD2,\r\n\t0x670B, 0xAA42, 0x670D, 0xAA41, 0x670F, 0xCEF9, 0x6710, 0xCEFA,\t0x6712, 0xD1D7, 0x6713, 0xD1D8, 0x6714, 0xAED2, 0x6715, 0xAED3,\r\n\t0x6717, 0xAED4, 0x6718, 0xD5AF, 0x671B, 0xB1E6, 0x671D, 0xB4C2,\t0x671F, 0xB4C1, 0x6720, 0xDDC8, 0x6721, 0xDF7A, 0x6722, 0xE1FB,\r\n\t0x6723, 0xE9BD, 0x6726, 0xC261, 0x6727, 0xC467, 0x6728, 0xA4EC,\t0x672A, 0xA5BC, 0x672B, 0xA5BD, 0x672C, 0xA5BB, 0x672D, 0xA5BE,\r\n\t0x672E, 0xA5BA, 0x6731, 0xA6B6, 0x6733, 0xC9F6, 0x6734, 0xA6B5,\t0x6735, 0xA6B7, 0x6738, 0xC9F1, 0x6739, 0xC9F0, 0x673A, 0xC9F3,\r\n\t0x673B, 0xC9F2, 0x673C, 0xC9F5, 0x673D, 0xA6B4, 0x673E, 0xC9EF,\t0x673F, 0xC9F4, 0x6745, 0xCAFD, 0x6746, 0xA7FD, 0x6747, 0xCAFE,\r\n\t0x6748, 0xCB43, 0x6749, 0xA7FC, 0x674B, 0xCB47, 0x674C, 0xCB42,\t0x674D, 0xCB45, 0x674E, 0xA7F5, 0x674F, 0xA7F6, 0x6750, 0xA7F7,\r\n\t0x6751, 0xA7F8, 0x6753, 0xA840, 0x6755, 0xCB41, 0x6756, 0xA7FA,\t0x6757, 0xA841, 0x6759, 0xCB40, 0x675A, 0xCB46, 0x675C, 0xA7F9,\r\n\t0x675D, 0xCB44, 0x675E, 0xA7FB, 0x675F, 0xA7F4, 0x6760, 0xA7FE,\t0x676A, 0xAA57, 0x676C, 0xCCD4, 0x676D, 0xAA43, 0x676F, 0xAA4D,\r\n\t0x6770, 0xAA4E, 0x6771, 0xAA46, 0x6772, 0xAA58, 0x6773, 0xAA48,\t0x6774, 0xCCDC, 0x6775, 0xAA53, 0x6776, 0xCCD7, 0x6777, 0xAA49,\r\n\t0x6778, 0xCCE6, 0x6779, 0xCCE7, 0x677A, 0xCCDF, 0x677B, 0xCCD8,\t0x677C, 0xAA56, 0x677D, 0xCCE4, 0x677E, 0xAA51, 0x677F, 0xAA4F,\r\n\t0x6781, 0xCCE5, 0x6783, 0xCCE3, 0x6784, 0xCCDB, 0x6785, 0xCCD3,\t0x6786, 0xCCDA, 0x6787, 0xAA4A, 0x6789, 0xAA50, 0x678B, 0xAA44,\r\n\t0x678C, 0xCCDE, 0x678D, 0xCCDD, 0x678E, 0xCCD5, 0x6790, 0xAA52,\t0x6791, 0xCCE1, 0x6792, 0xCCD6, 0x6793, 0xAA55, 0x6794, 0xCCE8,\r\n\t0x6795, 0xAA45, 0x6797, 0xAA4C, 0x6798, 0xCCD9, 0x6799, 0xCCE2,\t0x679A, 0xAA54, 0x679C, 0xAA47, 0x679D, 0xAA4B, 0x679F, 0xCCE0,\r\n\t0x67AE, 0xCF5B, 0x67AF, 0xAC5C, 0x67B0, 0xAC69, 0x67B2, 0xCF56,\t0x67B3, 0xCF4C, 0x67B4, 0xAC62, 0x67B5, 0xCF4A, 0x67B6, 0xAC5B,\r\n\t0x67B7, 0xCF45, 0x67B8, 0xAC65, 0x67B9, 0xCF52, 0x67BA, 0xCEFE,\t0x67BB, 0xCF41, 0x67C0, 0xCF44, 0x67C1, 0xCEFB, 0x67C2, 0xCF51,\r\n\t0x67C3, 0xCF61, 0x67C4, 0xAC60, 0x67C5, 0xCF46, 0x67C6, 0xCF58,\t0x67C8, 0xCEFD, 0x67C9, 0xCF5F, 0x67CA, 0xCF60, 0x67CB, 0xCF63,\r\n\t0x67CC, 0xCF5A, 0x67CD, 0xCF4B, 0x67CE, 0xCF53, 0x67CF, 0xAC66,\t0x67D0, 0xAC59, 0x67D1, 0xAC61, 0x67D2, 0xAC6D, 0x67D3, 0xAC56,\r\n\t0x67D4, 0xAC58, 0x67D8, 0xCF43, 0x67D9, 0xAC6A, 0x67DA, 0xAC63,\t0x67DB, 0xCF5D, 0x67DC, 0xCF40, 0x67DD, 0xAC6C, 0x67DE, 0xAC67,\r\n\t0x67DF, 0xCF49, 0x67E2, 0xAC6B, 0x67E3, 0xCF50, 0x67E4, 0xCF48,\t0x67E5, 0xAC64, 0x67E6, 0xCF5C, 0x67E7, 0xCF54, 0x67E9, 0xAC5E,\r\n\t0x67EA, 0xCF62, 0x67EB, 0xCF47, 0x67EC, 0xAC5A, 0x67ED, 0xCF59,\t0x67EE, 0xCF4F, 0x67EF, 0xAC5F, 0x67F0, 0xCF55, 0x67F1, 0xAC57,\r\n\t0x67F2, 0xCEFC, 0x67F3, 0xAC68, 0x67F4, 0xAEE3, 0x67F5, 0xAC5D,\t0x67F6, 0xCF4E, 0x67F7, 0xCF4D, 0x67F8, 0xCF42, 0x67FA, 0xCF5E,\r\n\t0x67FC, 0xCF57, 0x67FF, 0xAC55, 0x6812, 0xD1EC, 0x6813, 0xAEEA,\t0x6814, 0xD1ED, 0x6816, 0xD1E1, 0x6817, 0xAEDF, 0x6818, 0xAEEB,\r\n\t0x681A, 0xD1DA, 0x681C, 0xD1E3, 0x681D, 0xD1EB, 0x681F, 0xD1D9,\t0x6820, 0xD1F4, 0x6821, 0xAED5, 0x6825, 0xD1F3, 0x6826, 0xD1EE,\r\n\t0x6828, 0xD1EF, 0x6829, 0xAEDD, 0x682A, 0xAEE8, 0x682B, 0xD1E5,\t0x682D, 0xD1E6, 0x682E, 0xD1F0, 0x682F, 0xD1E7, 0x6831, 0xD1E2,\r\n\t0x6832, 0xD1DC, 0x6833, 0xD1DD, 0x6834, 0xD1EA, 0x6835, 0xD1E4,\t0x6838, 0xAED6, 0x6839, 0xAEDA, 0x683A, 0xD1F2, 0x683B, 0xD1DE,\r\n\t0x683C, 0xAEE6, 0x683D, 0xAEE2, 0x6840, 0xAEE5, 0x6841, 0xAEEC,\t0x6842, 0xAEDB, 0x6843, 0xAEE7, 0x6844, 0xD1E9, 0x6845, 0xAEE9,\r\n\t0x6846, 0xAED8, 0x6848, 0xAED7, 0x6849, 0xD1DB, 0x684B, 0xD1DF,\t0x684C, 0xAEE0, 0x684D, 0xD1F1, 0x684E, 0xD1E8, 0x684F, 0xD1E0,\r\n\t0x6850, 0xAEE4, 0x6851, 0xAEE1, 0x6853, 0xAED9, 0x6854, 0xAEDC,\t0x686B, 0xD5C4, 0x686D, 0xD5B4, 0x686E, 0xD5B5, 0x686F, 0xD5B9,\r\n\t0x6871, 0xD5C8, 0x6872, 0xD5C5, 0x6874, 0xD5BE, 0x6875, 0xD5BD,\t0x6876, 0xB1ED, 0x6877, 0xD5C1, 0x6878, 0xD5D0, 0x6879, 0xD5B0,\r\n\t0x687B, 0xD5D1, 0x687C, 0xD5C3, 0x687D, 0xD5D5, 0x687E, 0xD5C9,\t0x687F, 0xB1EC, 0x6880, 0xD5C7, 0x6881, 0xB1E7, 0x6882, 0xB1FC,\r\n\t0x6883, 0xB1F2, 0x6885, 0xB1F6, 0x6886, 0xB1F5, 0x6887, 0xD5B1,\t0x6889, 0xD5CE, 0x688A, 0xD5D4, 0x688B, 0xD5CC, 0x688C, 0xD5D3,\r\n\t0x688F, 0xD5C0, 0x6890, 0xD5B2, 0x6891, 0xD5D2, 0x6892, 0xD5C2,\t0x6893, 0xB1EA, 0x6894, 0xB1F7, 0x6896, 0xD5CB, 0x6897, 0xB1F0,\r\n\t0x689B, 0xD5CA, 0x689C, 0xD5B3, 0x689D, 0xB1F8, 0x689F, 0xB1FA,\t0x68A0, 0xD5CD, 0x68A1, 0xB1FB, 0x68A2, 0xB1E9, 0x68A3, 0xD5BA,\r\n\t0x68A4, 0xD5CF, 0x68A7, 0xB1EF, 0x68A8, 0xB1F9, 0x68A9, 0xD5BC,\t0x68AA, 0xD5C6, 0x68AB, 0xD5B7, 0x68AC, 0xD5BB, 0x68AD, 0xB1F4,\r\n\t0x68AE, 0xD5B6, 0x68AF, 0xB1E8, 0x68B0, 0xB1F1, 0x68B1, 0xB1EE,\t0x68B2, 0xD5BF, 0x68B3, 0xAEDE, 0x68B4, 0xD9C0, 0x68B5, 0xB1EB,\r\n\t0x68C4, 0xB1F3, 0x68C6, 0xD9C3, 0x68C7, 0xD9D9, 0x68C8, 0xD9CE,\t0x68C9, 0xB4D6, 0x68CB, 0xB4D1, 0x68CC, 0xD9BD, 0x68CD, 0xB4D2,\r\n\t0x68CE, 0xD9CD, 0x68D0, 0xD9C6, 0x68D1, 0xD9D3, 0x68D2, 0xB4CE,\t0x68D3, 0xD9AB, 0x68D4, 0xD9D5, 0x68D5, 0xB4C4, 0x68D6, 0xD9B3,\r\n\t0x68D7, 0xB4C7, 0x68D8, 0xB4C6, 0x68DA, 0xB4D7, 0x68DC, 0xD9AD,\t0x68DD, 0xD9CF, 0x68DE, 0xD9D0, 0x68DF, 0xB4C9, 0x68E0, 0xB4C5,\r\n\t0x68E1, 0xD9BB, 0x68E3, 0xB4D0, 0x68E4, 0xD9B6, 0x68E6, 0xD9D1,\t0x68E7, 0xB4CC, 0x68E8, 0xD9C9, 0x68E9, 0xD9D6, 0x68EA, 0xD9B0,\r\n\t0x68EB, 0xD9B5, 0x68EC, 0xD9AF, 0x68EE, 0xB4CB, 0x68EF, 0xD9C2,\t0x68F0, 0xDDDE, 0x68F1, 0xD9B1, 0x68F2, 0xB4CF, 0x68F3, 0xD9BA,\r\n\t0x68F4, 0xD9D2, 0x68F5, 0xB4CA, 0x68F6, 0xD9B7, 0x68F7, 0xD9B4,\t0x68F8, 0xD9C5, 0x68F9, 0xB4CD, 0x68FA, 0xB4C3, 0x68FB, 0xB4D9,\r\n\t0x68FC, 0xD9C8, 0x68FD, 0xD9C7, 0x6904, 0xD9AC, 0x6905, 0xB4C8,\t0x6906, 0xD9D4, 0x6907, 0xD9BC, 0x6908, 0xD9BE, 0x690A, 0xD9CB,\r\n\t0x690B, 0xD9CA, 0x690C, 0xD9AA, 0x690D, 0xB4D3, 0x690E, 0xB4D5,\t0x690F, 0xD9B2, 0x6910, 0xD9B9, 0x6911, 0xD9C1, 0x6912, 0xB4D4,\r\n\t0x6913, 0xD9B8, 0x6914, 0xD9C4, 0x6915, 0xD9D7, 0x6917, 0xD9CC,\t0x6925, 0xD9D8, 0x692A, 0xD9AE, 0x692F, 0xDDF2, 0x6930, 0xB7A6,\r\n\t0x6932, 0xDDF0, 0x6933, 0xDDDB, 0x6934, 0xDDE0, 0x6935, 0xDDD9,\t0x6937, 0xDDEC, 0x6938, 0xDDCB, 0x6939, 0xDDD2, 0x693B, 0xDDEA,\r\n\t0x693C, 0xDDF4, 0x693D, 0xDDDC, 0x693F, 0xDDCF, 0x6940, 0xDDE2,\t0x6941, 0xDDE7, 0x6942, 0xDDD3, 0x6944, 0xDDE4, 0x6945, 0xDDD0,\r\n\t0x6948, 0xDDD7, 0x6949, 0xDDD8, 0x694A, 0xB7A8, 0x694B, 0xDDEB,\t0x694C, 0xDDE9, 0x694E, 0xDDCC, 0x694F, 0xDDEE, 0x6951, 0xDDEF,\r\n\t0x6952, 0xDDF1, 0x6953, 0xB7AC, 0x6954, 0xB7A4, 0x6956, 0xD5B8,\t0x6957, 0xDDD4, 0x6958, 0xDDE6, 0x6959, 0xDDD5, 0x695A, 0xB7A1,\r\n\t0x695B, 0xB7B1, 0x695C, 0xDDED, 0x695D, 0xB7AF, 0x695E, 0xB7AB,\t0x695F, 0xDDCA, 0x6960, 0xB7A3, 0x6962, 0xDDCD, 0x6963, 0xB7B0,\r\n\t0x6965, 0xDDDD, 0x6966, 0xDDC9, 0x6968, 0xB7A9, 0x6969, 0xDDE1,\t0x696A, 0xDDD1, 0x696B, 0xB7AA, 0x696C, 0xDDDA, 0x696D, 0xB77E,\r\n\t0x696E, 0xB4D8, 0x696F, 0xDDE3, 0x6970, 0xD9BF, 0x6971, 0xDDCE,\t0x6974, 0xDDE8, 0x6975, 0xB7A5, 0x6976, 0xDDE5, 0x6977, 0xB7A2,\r\n\t0x6978, 0xDDDF, 0x6979, 0xB7AD, 0x697A, 0xDDD6, 0x697B, 0xDDF3,\t0x6982, 0xB7A7, 0x6983, 0xDEC6, 0x6986, 0xB7AE, 0x698D, 0xE24A,\r\n\t0x698E, 0xE248, 0x6990, 0xE25E, 0x6991, 0xE246, 0x6993, 0xE258,\t0x6994, 0xB77D, 0x6995, 0xBA5F, 0x6996, 0xE242, 0x6997, 0xE25D,\r\n\t0x6999, 0xE247, 0x699A, 0xE255, 0x699B, 0xBA64, 0x699C, 0xBA5D,\t0x699E, 0xE25B, 0x69A0, 0xE240, 0x69A1, 0xE25A, 0x69A3, 0xBA6F,\r\n\t0x69A4, 0xE251, 0x69A5, 0xE261, 0x69A6, 0xBA6D, 0x69A7, 0xE249,\t0x69A8, 0xBA5E, 0x69A9, 0xE24B, 0x69AA, 0xE259, 0x69AB, 0xBA67,\r\n\t0x69AC, 0xE244, 0x69AD, 0xBA6B, 0x69AE, 0xBA61, 0x69AF, 0xE24D,\t0x69B0, 0xE243, 0x69B1, 0xE1FC, 0x69B3, 0xE257, 0x69B4, 0xBA68,\r\n\t0x69B5, 0xE260, 0x69B6, 0xE1FD, 0x69B7, 0xBA65, 0x69B9, 0xE253,\t0x69BB, 0xBA66, 0x69BC, 0xE245, 0x69BD, 0xE250, 0x69BE, 0xE24C,\r\n\t0x69BF, 0xE24E, 0x69C1, 0xBA60, 0x69C2, 0xE25F, 0x69C3, 0xBA6E,\t0x69C4, 0xE24F, 0x69C6, 0xE262, 0x69C9, 0xE1FE, 0x69CA, 0xE254,\r\n\t0x69CB, 0xBA63, 0x69CC, 0xBA6C, 0x69CD, 0xBA6A, 0x69CE, 0xE241,\t0x69CF, 0xE256, 0x69D0, 0xBA69, 0x69D3, 0xBA62, 0x69D4, 0xE252,\r\n\t0x69D9, 0xE25C, 0x69E2, 0xE5D5, 0x69E4, 0xE5D1, 0x69E5, 0xE5CD,\t0x69E6, 0xE5E1, 0x69E7, 0xE5DE, 0x69E8, 0xBCCD, 0x69EB, 0xE5E5,\r\n\t0x69EC, 0xE5D4, 0x69ED, 0xBCD8, 0x69EE, 0xE5DB, 0x69F1, 0xE5D0,\t0x69F2, 0xE5DA, 0x69F3, 0xBCD5, 0x69F4, 0xE5EE, 0x69F6, 0xE5EB,\r\n\t0x69F7, 0xE5DD, 0x69F8, 0xE5CE, 0x69FB, 0xE5E2, 0x69FC, 0xE5E4,\t0x69FD, 0xBCD1, 0x69FE, 0xE5D8, 0x69FF, 0xE5D3, 0x6A00, 0xE5CA,\r\n\t0x6A01, 0xBCCE, 0x6A02, 0xBCD6, 0x6A04, 0xE5E7, 0x6A05, 0xBCD7,\t0x6A06, 0xE5CB, 0x6A07, 0xE5ED, 0x6A08, 0xE5E0, 0x6A09, 0xE5E6,\r\n\t0x6A0A, 0xBCD4, 0x6A0D, 0xE5E3, 0x6A0F, 0xE5EA, 0x6A11, 0xBCD9,\t0x6A13, 0xBCD3, 0x6A14, 0xE5DC, 0x6A15, 0xE5CF, 0x6A16, 0xE5EF,\r\n\t0x6A17, 0xE5CC, 0x6A18, 0xE5E8, 0x6A19, 0xBCD0, 0x6A1B, 0xE5D6,\t0x6A1D, 0xE5D7, 0x6A1E, 0xBCCF, 0x6A1F, 0xBCCC, 0x6A20, 0xE5D2,\r\n\t0x6A21, 0xBCD2, 0x6A23, 0xBCCB, 0x6A25, 0xE5E9, 0x6A26, 0xE5EC,\t0x6A27, 0xE5D9, 0x6A28, 0xE9CA, 0x6A32, 0xE9C2, 0x6A34, 0xE9BE,\r\n\t0x6A35, 0xBEF6, 0x6A38, 0xBEEB, 0x6A39, 0xBEF0, 0x6A3A, 0xBEEC,\t0x6A3B, 0xE9CC, 0x6A3C, 0xE9D7, 0x6A3D, 0xBEEA, 0x6A3E, 0xE9C4,\r\n\t0x6A3F, 0xE9CD, 0x6A40, 0xE5DF, 0x6A41, 0xE9CE, 0x6A44, 0xBEF1,\t0x6A46, 0xE9DD, 0x6A47, 0xBEF5, 0x6A48, 0xBEF8, 0x6A49, 0xE9C0,\r\n\t0x6A4B, 0xBEF4, 0x6A4D, 0xE9DB, 0x6A4E, 0xE9DC, 0x6A4F, 0xE9D2,\t0x6A50, 0xE9D1, 0x6A51, 0xE9C9, 0x6A54, 0xE9D3, 0x6A55, 0xE9DA,\r\n\t0x6A56, 0xE9D9, 0x6A58, 0xBEEF, 0x6A59, 0xBEED, 0x6A5A, 0xE9CB,\t0x6A5B, 0xE9C8, 0x6A5D, 0xE9C5, 0x6A5E, 0xE9D8, 0x6A5F, 0xBEF7,\r\n\t0x6A60, 0xE9D6, 0x6A61, 0xBEF3, 0x6A62, 0xBEF2, 0x6A64, 0xE9D0,\t0x6A66, 0xE9BF, 0x6A67, 0xE9C1, 0x6A68, 0xE9C3, 0x6A69, 0xE9D5,\r\n\t0x6A6A, 0xE9CF, 0x6A6B, 0xBEEE, 0x6A6D, 0xE9C6, 0x6A6F, 0xE9D4,\t0x6A76, 0xE9C7, 0x6A7E, 0xC0CF, 0x6A7F, 0xED45, 0x6A80, 0xC0C8,\r\n\t0x6A81, 0xECF5, 0x6A83, 0xED41, 0x6A84, 0xC0CA, 0x6A85, 0xED48,\t0x6A87, 0xECFC, 0x6A89, 0xECF7, 0x6A8C, 0xED49, 0x6A8D, 0xECF3,\r\n\t0x6A8E, 0xECFE, 0x6A90, 0xC0D1, 0x6A91, 0xED44, 0x6A92, 0xED4A,\t0x6A93, 0xECFD, 0x6A94, 0xC0C9, 0x6A95, 0xED40, 0x6A96, 0xECF4,\r\n\t0x6A97, 0xC0D0, 0x6A9A, 0xED47, 0x6A9B, 0xECF9, 0x6A9C, 0xC0CC,\t0x6A9E, 0xECFB, 0x6A9F, 0xECF8, 0x6AA0, 0xC0D2, 0x6AA1, 0xECFA,\r\n\t0x6AA2, 0xC0CB, 0x6AA3, 0xC0CE, 0x6AA4, 0xED43, 0x6AA5, 0xECF6,\t0x6AA6, 0xED46, 0x6AA8, 0xED42, 0x6AAC, 0xC263, 0x6AAD, 0xEFE7,\r\n\t0x6AAE, 0xC268, 0x6AAF, 0xC269, 0x6AB3, 0xC262, 0x6AB4, 0xEFE6,\t0x6AB6, 0xEFE3, 0x6AB7, 0xEFE4, 0x6AB8, 0xC266, 0x6AB9, 0xEFDE,\r\n\t0x6ABA, 0xEFE2, 0x6ABB, 0xC265, 0x6ABD, 0xEFDF, 0x6AC2, 0xC267,\t0x6AC3, 0xC264, 0x6AC5, 0xEFDD, 0x6AC6, 0xEFE1, 0x6AC7, 0xEFE5,\r\n\t0x6ACB, 0xF251, 0x6ACC, 0xF24E, 0x6ACD, 0xF257, 0x6ACF, 0xF256,\t0x6AD0, 0xF254, 0x6AD1, 0xF24F, 0x6AD3, 0xC372, 0x6AD9, 0xF250,\r\n\t0x6ADA, 0xC371, 0x6ADB, 0xC0CD, 0x6ADC, 0xF253, 0x6ADD, 0xC370,\t0x6ADE, 0xF258, 0x6ADF, 0xF252, 0x6AE0, 0xF24D, 0x6AE1, 0xEFE0,\r\n\t0x6AE5, 0xC36F, 0x6AE7, 0xF24C, 0x6AE8, 0xF456, 0x6AEA, 0xF455,\t0x6AEB, 0xF255, 0x6AEC, 0xC468, 0x6AEE, 0xF459, 0x6AEF, 0xF45A,\r\n\t0x6AF0, 0xF454, 0x6AF1, 0xF458, 0x6AF3, 0xF453, 0x6AF8, 0xF5D1,\t0x6AF9, 0xF457, 0x6AFA, 0xC4E7, 0x6AFB, 0xC4E5, 0x6AFC, 0xF5CF,\r\n\t0x6B00, 0xF5D2, 0x6B02, 0xF5CE, 0x6B03, 0xF5D0, 0x6B04, 0xC4E6,\t0x6B08, 0xF6E5, 0x6B09, 0xF6E6, 0x6B0A, 0xC576, 0x6B0B, 0xF6E4,\r\n\t0x6B0F, 0xF7E2, 0x6B10, 0xC5CF, 0x6B11, 0xF7E0, 0x6B12, 0xF7E1,\t0x6B13, 0xF8AC, 0x6B16, 0xC656, 0x6B17, 0xF8F3, 0x6B18, 0xF8F1,\r\n\t0x6B19, 0xF8F2, 0x6B1A, 0xF8F4, 0x6B1E, 0xF9BB, 0x6B20, 0xA4ED,\t0x6B21, 0xA6B8, 0x6B23, 0xAA59, 0x6B25, 0xCCE9, 0x6B28, 0xCF64,\r\n\t0x6B2C, 0xD1F5, 0x6B2D, 0xD1F7, 0x6B2F, 0xD1F6, 0x6B31, 0xD1F8,\t0x6B32, 0xB1FD, 0x6B33, 0xD5D7, 0x6B34, 0xD1F9, 0x6B36, 0xD5D6,\r\n\t0x6B37, 0xD5D8, 0x6B38, 0xD5D9, 0x6B39, 0xD9DA, 0x6B3A, 0xB4DB,\t0x6B3B, 0xD9DB, 0x6B3C, 0xD9DD, 0x6B3D, 0xB4DC, 0x6B3E, 0xB4DA,\r\n\t0x6B3F, 0xD9DC, 0x6B41, 0xDDFA, 0x6B42, 0xDDF8, 0x6B43, 0xDDF7,\t0x6B45, 0xDDF6, 0x6B46, 0xDDF5, 0x6B47, 0xB7B2, 0x6B48, 0xDDF9,\r\n\t0x6B49, 0xBA70, 0x6B4A, 0xE263, 0x6B4B, 0xE265, 0x6B4C, 0xBA71,\t0x6B4D, 0xE264, 0x6B4E, 0xBCDB, 0x6B50, 0xBCDA, 0x6B51, 0xE5F0,\r\n\t0x6B54, 0xE9DF, 0x6B55, 0xE9DE, 0x6B56, 0xE9E0, 0x6B59, 0xBEF9,\t0x6B5B, 0xED4B, 0x6B5C, 0xC0D3, 0x6B5E, 0xEFE8, 0x6B5F, 0xC26A,\r\n\t0x6B60, 0xF259, 0x6B61, 0xC577, 0x6B62, 0xA4EE, 0x6B63, 0xA5BF,\t0x6B64, 0xA6B9, 0x6B65, 0xA842, 0x6B66, 0xAA5A, 0x6B67, 0xAA5B,\r\n\t0x6B6A, 0xAC6E, 0x6B6D, 0xD1FA, 0x6B72, 0xB7B3, 0x6B76, 0xE6D1,\t0x6B77, 0xBEFA, 0x6B78, 0xC26B, 0x6B79, 0xA4EF, 0x6B7B, 0xA6BA,\r\n\t0x6B7E, 0xCCEB, 0x6B7F, 0xAA5C, 0x6B80, 0xCCEA, 0x6B82, 0xCF65,\t0x6B83, 0xAC6F, 0x6B84, 0xCF66, 0x6B86, 0xAC70, 0x6B88, 0xD1FC,\r\n\t0x6B89, 0xAEEE, 0x6B8A, 0xAEED, 0x6B8C, 0xD5DE, 0x6B8D, 0xD5DC,\t0x6B8E, 0xD5DD, 0x6B8F, 0xD5DB, 0x6B91, 0xD5DA, 0x6B94, 0xD9DE,\r\n\t0x6B95, 0xD9E1, 0x6B96, 0xB4DE, 0x6B97, 0xD9DF, 0x6B98, 0xB4DD,\t0x6B99, 0xD9E0, 0x6B9B, 0xDDFB, 0x6B9E, 0xE266, 0x6B9F, 0xE267,\r\n\t0x6BA0, 0xE268, 0x6BA2, 0xE5F3, 0x6BA3, 0xE5F2, 0x6BA4, 0xBCDC,\t0x6BA5, 0xE5F1, 0x6BA6, 0xE5F4, 0x6BA7, 0xE9E1, 0x6BAA, 0xE9E2,\r\n\t0x6BAB, 0xE9E3, 0x6BAD, 0xED4C, 0x6BAE, 0xC0D4, 0x6BAF, 0xC26C,\t0x6BB0, 0xF25A, 0x6BB2, 0xC4E8, 0x6BB3, 0xC95F, 0x6BB5, 0xAC71,\r\n\t0x6BB6, 0xCF67, 0x6BB7, 0xAEEF, 0x6BBA, 0xB1FE, 0x6BBC, 0xB4DF,\t0x6BBD, 0xD9E2, 0x6BBF, 0xB7B5, 0x6BC0, 0xB7B4, 0x6BC3, 0xE269,\r\n\t0x6BC4, 0xE26A, 0x6BC5, 0xBCDD, 0x6BC6, 0xBCDE, 0x6BC7, 0xE9E5,\t0x6BC8, 0xE9E4, 0x6BC9, 0xEFE9, 0x6BCA, 0xF7E3, 0x6BCB, 0xA4F0,\r\n\t0x6BCC, 0xC960, 0x6BCD, 0xA5C0, 0x6BCF, 0xA843, 0x6BD0, 0xCB48,\t0x6BD2, 0xAC72, 0x6BD3, 0xB7B6, 0x6BD4, 0xA4F1, 0x6BD6, 0xCF68,\r\n\t0x6BD7, 0xAC73, 0x6BD8, 0xCF69, 0x6BDA, 0xC0D5, 0x6BDB, 0xA4F2,\t0x6BDE, 0xCCEC, 0x6BE0, 0xCF6A, 0x6BE2, 0xD242, 0x6BE3, 0xD241,\r\n\t0x6BE4, 0xD1FE, 0x6BE6, 0xD1FD, 0x6BE7, 0xD243, 0x6BE8, 0xD240,\t0x6BEB, 0xB240, 0x6BEC, 0xB241, 0x6BEF, 0xB4E0, 0x6BF0, 0xD9E3,\r\n\t0x6BF2, 0xD9E4, 0x6BF3, 0xD9E5, 0x6BF7, 0xDE41, 0x6BF8, 0xDE42,\t0x6BF9, 0xDE40, 0x6BFB, 0xDDFD, 0x6BFC, 0xDDFE, 0x6BFD, 0xB7B7,\r\n\t0x6BFE, 0xE26B, 0x6BFF, 0xE5F7, 0x6C00, 0xE5F6, 0x6C01, 0xE5F5,\t0x6C02, 0xE5F8, 0x6C03, 0xE9E7, 0x6C04, 0xE9E6, 0x6C05, 0xBEFB,\r\n\t0x6C06, 0xE9E8, 0x6C08, 0xC0D6, 0x6C09, 0xED4D, 0x6C0B, 0xEFEA,\t0x6C0C, 0xF25B, 0x6C0D, 0xF6E7, 0x6C0F, 0xA4F3, 0x6C10, 0xA5C2,\r\n\t0x6C11, 0xA5C1, 0x6C13, 0xAA5D, 0x6C14, 0xC961, 0x6C15, 0xC97E,\t0x6C16, 0xA6BB, 0x6C18, 0xC9F7, 0x6C19, 0xCB49, 0x6C1A, 0xCB4A,\r\n\t0x6C1B, 0xAA5E, 0x6C1D, 0xCCED, 0x6C1F, 0xAC74, 0x6C20, 0xCF6B,\t0x6C21, 0xCF6C, 0x6C23, 0xAEF0, 0x6C24, 0xAEF4, 0x6C25, 0xD244,\r\n\t0x6C26, 0xAEF3, 0x6C27, 0xAEF1, 0x6C28, 0xAEF2, 0x6C2A, 0xD5DF,\t0x6C2B, 0xB242, 0x6C2C, 0xB4E3, 0x6C2E, 0xB4E1, 0x6C2F, 0xB4E2,\r\n\t0x6C30, 0xD9E6, 0x6C33, 0xBA72, 0x6C34, 0xA4F4, 0x6C36, 0xC9A1,\t0x6C38, 0xA5C3, 0x6C3B, 0xC9A4, 0x6C3E, 0xA5C6, 0x6C3F, 0xC9A3,\r\n\t0x6C40, 0xA5C5, 0x6C41, 0xA5C4, 0x6C42, 0xA844, 0x6C43, 0xC9A2,\t0x6C46, 0xC9F8, 0x6C4A, 0xC9FC, 0x6C4B, 0xC9FE, 0x6C4C, 0xCA40,\r\n\t0x6C4D, 0xA6C5, 0x6C4E, 0xA6C6, 0x6C4F, 0xC9FB, 0x6C50, 0xA6C1,\t0x6C52, 0xC9F9, 0x6C54, 0xC9FD, 0x6C55, 0xA6C2, 0x6C57, 0xA6BD,\r\n\t0x6C59, 0xA6BE, 0x6C5B, 0xA6C4, 0x6C5C, 0xC9FA, 0x6C5D, 0xA6BC,\t0x6C5E, 0xA845, 0x6C5F, 0xA6BF, 0x6C60, 0xA6C0, 0x6C61, 0xA6C3,\r\n\t0x6C65, 0xCB5B, 0x6C66, 0xCB59, 0x6C67, 0xCB4C, 0x6C68, 0xA851,\t0x6C69, 0xCB53, 0x6C6A, 0xA84C, 0x6C6B, 0xCB4D, 0x6C6D, 0xCB55,\r\n\t0x6C6F, 0xCB52, 0x6C70, 0xA84F, 0x6C71, 0xCB51, 0x6C72, 0xA856,\t0x6C73, 0xCB5A, 0x6C74, 0xA858, 0x6C76, 0xA85A, 0x6C78, 0xCB4B,\r\n\t0x6C7A, 0xA84D, 0x6C7B, 0xCB5C, 0x6C7D, 0xA854, 0x6C7E, 0xA857,\t0x6C80, 0xCD45, 0x6C81, 0xA847, 0x6C82, 0xA85E, 0x6C83, 0xA855,\r\n\t0x6C84, 0xCB4E, 0x6C85, 0xA84A, 0x6C86, 0xA859, 0x6C87, 0xCB56,\t0x6C88, 0xA848, 0x6C89, 0xA849, 0x6C8A, 0xCD43, 0x6C8B, 0xCB4F,\r\n\t0x6C8C, 0xA850, 0x6C8D, 0xA85B, 0x6C8E, 0xCB5D, 0x6C8F, 0xCB50,\t0x6C90, 0xA84E, 0x6C92, 0xA853, 0x6C93, 0xCCEE, 0x6C94, 0xA85C,\r\n\t0x6C95, 0xCB57, 0x6C96, 0xA852, 0x6C98, 0xA85D, 0x6C99, 0xA846,\t0x6C9A, 0xCB54, 0x6C9B, 0xA84B, 0x6C9C, 0xCB58, 0x6C9D, 0xCD44,\r\n\t0x6CAB, 0xAA6A, 0x6CAC, 0xAA7A, 0x6CAD, 0xCCF5, 0x6CAE, 0xAA71,\t0x6CB0, 0xCD4B, 0x6CB1, 0xAA62, 0x6CB3, 0xAA65, 0x6CB4, 0xCD42,\r\n\t0x6CB6, 0xCCF3, 0x6CB7, 0xCCF7, 0x6CB8, 0xAA6D, 0x6CB9, 0xAA6F,\t0x6CBA, 0xCCFA, 0x6CBB, 0xAA76, 0x6CBC, 0xAA68, 0x6CBD, 0xAA66,\r\n\t0x6CBE, 0xAA67, 0x6CBF, 0xAA75, 0x6CC0, 0xCD47, 0x6CC1, 0xAA70,\t0x6CC2, 0xCCF9, 0x6CC3, 0xCCFB, 0x6CC4, 0xAA6E, 0x6CC5, 0xAA73,\r\n\t0x6CC6, 0xCCFC, 0x6CC7, 0xCD4A, 0x6CC9, 0xAC75, 0x6CCA, 0xAA79,\t0x6CCC, 0xAA63, 0x6CCD, 0xCD49, 0x6CCF, 0xCD4D, 0x6CD0, 0xCCF8,\r\n\t0x6CD1, 0xCD4F, 0x6CD2, 0xCD40, 0x6CD3, 0xAA6C, 0x6CD4, 0xCCF4,\t0x6CD5, 0xAA6B, 0x6CD6, 0xAA7D, 0x6CD7, 0xAA72, 0x6CD9, 0xCCF2,\r\n\t0x6CDA, 0xCF75, 0x6CDB, 0xAA78, 0x6CDC, 0xAA7C, 0x6CDD, 0xCD41,\t0x6CDE, 0xCD46, 0x6CE0, 0xAA7E, 0x6CE1, 0xAA77, 0x6CE2, 0xAA69,\r\n\t0x6CE3, 0xAA5F, 0x6CE5, 0xAA64, 0x6CE7, 0xCCF6, 0x6CE8, 0xAA60,\t0x6CE9, 0xCD4E, 0x6CEB, 0xCCF0, 0x6CEC, 0xCCEF, 0x6CED, 0xCCFD,\r\n\t0x6CEE, 0xCCF1, 0x6CEF, 0xAA7B, 0x6CF0, 0xAEF5, 0x6CF1, 0xAA74,\t0x6CF2, 0xCCFE, 0x6CF3, 0xAA61, 0x6CF5, 0xACA6, 0x6CF9, 0xCD4C,\r\n\t0x6D00, 0xCF7C, 0x6D01, 0xCFA1, 0x6D03, 0xCFA4, 0x6D04, 0xCF77,\t0x6D07, 0xCFA7, 0x6D08, 0xCFAA, 0x6D09, 0xCFAC, 0x6D0A, 0xCF74,\r\n\t0x6D0B, 0xAC76, 0x6D0C, 0xAC7B, 0x6D0D, 0xD249, 0x6D0E, 0xACAD,\t0x6D0F, 0xCFA5, 0x6D10, 0xCFAD, 0x6D11, 0xCF7B, 0x6D12, 0xCF73,\r\n\t0x6D16, 0xD264, 0x6D17, 0xAC7E, 0x6D18, 0xCFA2, 0x6D19, 0xCF78,\t0x6D1A, 0xCF7A, 0x6D1B, 0xACA5, 0x6D1D, 0xCF7D, 0x6D1E, 0xAC7D,\r\n\t0x6D1F, 0xCF70, 0x6D20, 0xCFA8, 0x6D22, 0xCFAB, 0x6D25, 0xAC7A,\t0x6D27, 0xACA8, 0x6D28, 0xCF6D, 0x6D29, 0xACAA, 0x6D2A, 0xAC78,\r\n\t0x6D2B, 0xACAE, 0x6D2C, 0xCFA9, 0x6D2D, 0xCF6F, 0x6D2E, 0xACAB,\t0x6D2F, 0xD25E, 0x6D30, 0xCD48, 0x6D31, 0xAC7C, 0x6D32, 0xAC77,\r\n\t0x6D33, 0xCF76, 0x6D34, 0xCF6E, 0x6D35, 0xACAC, 0x6D36, 0xACA4,\t0x6D37, 0xCFA3, 0x6D38, 0xACA9, 0x6D39, 0xACA7, 0x6D3A, 0xCF79,\r\n\t0x6D3B, 0xACA1, 0x6D3C, 0xCF71, 0x6D3D, 0xACA2, 0x6D3E, 0xACA3,\t0x6D3F, 0xCF72, 0x6D40, 0xCFA6, 0x6D41, 0xAC79, 0x6D42, 0xCF7E,\r\n\t0x6D58, 0xD24C, 0x6D59, 0xAEFD, 0x6D5A, 0xAF43, 0x6D5E, 0xD255,\t0x6D5F, 0xD25B, 0x6D60, 0xD257, 0x6D61, 0xD24A, 0x6D62, 0xD24D,\r\n\t0x6D63, 0xD246, 0x6D64, 0xD247, 0x6D65, 0xAF4A, 0x6D66, 0xAEFA,\t0x6D67, 0xD256, 0x6D68, 0xD25F, 0x6D69, 0xAF45, 0x6D6A, 0xAEF6,\r\n\t0x6D6C, 0xAF40, 0x6D6D, 0xD24E, 0x6D6E, 0xAF42, 0x6D6F, 0xD24F,\t0x6D70, 0xD259, 0x6D74, 0xAF44, 0x6D75, 0xD268, 0x6D76, 0xD248,\r\n\t0x6D77, 0xAEFC, 0x6D78, 0xAEFB, 0x6D79, 0xAF48, 0x6D7A, 0xD245,\t0x6D7B, 0xD266, 0x6D7C, 0xD25A, 0x6D7D, 0xD267, 0x6D7E, 0xD261,\r\n\t0x6D7F, 0xD253, 0x6D80, 0xD262, 0x6D82, 0xD25C, 0x6D83, 0xD265,\t0x6D84, 0xD263, 0x6D85, 0xAF49, 0x6D86, 0xD254, 0x6D87, 0xAEF9,\r\n\t0x6D88, 0xAEF8, 0x6D89, 0xAF41, 0x6D8A, 0xAF47, 0x6D8B, 0xD260,\t0x6D8C, 0xAF46, 0x6D8D, 0xD251, 0x6D8E, 0xB243, 0x6D90, 0xD269,\r\n\t0x6D91, 0xD250, 0x6D92, 0xD24B, 0x6D93, 0xAEFE, 0x6D94, 0xAF4B,\t0x6D95, 0xAEF7, 0x6D97, 0xD258, 0x6D98, 0xD25D, 0x6DAA, 0xB265,\r\n\t0x6DAB, 0xD5E1, 0x6DAC, 0xD5E5, 0x6DAE, 0xB252, 0x6DAF, 0xB250,\t0x6DB2, 0xB247, 0x6DB3, 0xD5E3, 0x6DB4, 0xD5E2, 0x6DB5, 0xB25B,\r\n\t0x6DB7, 0xD5E8, 0x6DB8, 0xB255, 0x6DBA, 0xD5FA, 0x6DBB, 0xD647,\t0x6DBC, 0xB244, 0x6DBD, 0xD5F7, 0x6DBE, 0xD5F0, 0x6DBF, 0xB267,\r\n\t0x6DC0, 0xD5E0, 0x6DC2, 0xD5FC, 0x6DC4, 0xB264, 0x6DC5, 0xB258,\t0x6DC6, 0xB263, 0x6DC7, 0xB24E, 0x6DC8, 0xD5EC, 0x6DC9, 0xD5FE,\r\n\t0x6DCA, 0xD5F6, 0x6DCB, 0xB24F, 0x6DCC, 0xB249, 0x6DCD, 0xD645,\t0x6DCF, 0xD5FD, 0x6DD0, 0xD640, 0x6DD1, 0xB251, 0x6DD2, 0xB259,\r\n\t0x6DD3, 0xD642, 0x6DD4, 0xD5EA, 0x6DD5, 0xD5FB, 0x6DD6, 0xD5EF,\t0x6DD7, 0xD644, 0x6DD8, 0xB25E, 0x6DD9, 0xB246, 0x6DDA, 0xB25C,\r\n\t0x6DDB, 0xD5F4, 0x6DDC, 0xD5F2, 0x6DDD, 0xD5F3, 0x6DDE, 0xB253,\t0x6DDF, 0xD5EE, 0x6DE0, 0xD5ED, 0x6DE1, 0xB248, 0x6DE2, 0xD5E7,\r\n\t0x6DE3, 0xD646, 0x6DE4, 0xB24A, 0x6DE5, 0xD5F1, 0x6DE6, 0xB268,\t0x6DE8, 0xB262, 0x6DE9, 0xD5E6, 0x6DEA, 0xB25F, 0x6DEB, 0xB25D,\r\n\t0x6DEC, 0xB266, 0x6DED, 0xD5F8, 0x6DEE, 0xB261, 0x6DEF, 0xD252,\t0x6DF0, 0xD5F9, 0x6DF1, 0xB260, 0x6DF2, 0xD641, 0x6DF3, 0xB245,\r\n\t0x6DF4, 0xD5F5, 0x6DF5, 0xB257, 0x6DF6, 0xD5E9, 0x6DF7, 0xB256,\t0x6DF9, 0xB254, 0x6DFA, 0xB24C, 0x6DFB, 0xB24B, 0x6DFC, 0xD9E7,\r\n\t0x6DFD, 0xD643, 0x6E00, 0xD5EB, 0x6E03, 0xD9FC, 0x6E05, 0xB24D,\t0x6E19, 0xB541, 0x6E1A, 0xB25A, 0x6E1B, 0xB4EE, 0x6E1C, 0xD9F6,\r\n\t0x6E1D, 0xB4FC, 0x6E1F, 0xD9EA, 0x6E20, 0xB4EB, 0x6E21, 0xB4E7,\t0x6E22, 0xDA49, 0x6E23, 0xB4ED, 0x6E24, 0xB4F1, 0x6E25, 0xB4EC,\r\n\t0x6E26, 0xB4F5, 0x6E27, 0xDA4D, 0x6E28, 0xDA44, 0x6E2B, 0xD9F1,\t0x6E2C, 0xB4FA, 0x6E2D, 0xB4F4, 0x6E2E, 0xD9FD, 0x6E2F, 0xB4E4,\r\n\t0x6E30, 0xDA4A, 0x6E31, 0xDA43, 0x6E32, 0xB4E8, 0x6E33, 0xD9F7,\t0x6E34, 0xB4F7, 0x6E35, 0xDA55, 0x6E36, 0xDA56, 0x6E38, 0xB4E5,\r\n\t0x6E39, 0xDA48, 0x6E3A, 0xB4F9, 0x6E3B, 0xD9FB, 0x6E3C, 0xD9ED,\t0x6E3D, 0xD9EE, 0x6E3E, 0xB4FD, 0x6E3F, 0xD9F2, 0x6E40, 0xD9F9,\r\n\t0x6E41, 0xD9F3, 0x6E43, 0xB4FB, 0x6E44, 0xB544, 0x6E45, 0xD9EF,\t0x6E46, 0xD9E8, 0x6E47, 0xD9E9, 0x6E49, 0xD9EB, 0x6E4A, 0xB4EA,\r\n\t0x6E4B, 0xD9F8, 0x6E4D, 0xB4F8, 0x6E4E, 0xB542, 0x6E51, 0xD9FA,\t0x6E52, 0xDA53, 0x6E53, 0xDA4B, 0x6E54, 0xB4E6, 0x6E55, 0xDA51,\r\n\t0x6E56, 0xB4F2, 0x6E58, 0xB4F0, 0x6E5A, 0xDA57, 0x6E5B, 0xB4EF,\t0x6E5C, 0xDA41, 0x6E5D, 0xD9F4, 0x6E5E, 0xD9FE, 0x6E5F, 0xB547,\r\n\t0x6E60, 0xDA45, 0x6E61, 0xDA42, 0x6E62, 0xD9F0, 0x6E63, 0xB543,\t0x6E64, 0xDA4F, 0x6E65, 0xDA4C, 0x6E66, 0xDA54, 0x6E67, 0xB4E9,\r\n\t0x6E68, 0xDA40, 0x6E69, 0xB546, 0x6E6B, 0xDA47, 0x6E6E, 0xB4F3,\t0x6E6F, 0xB4F6, 0x6E71, 0xDA46, 0x6E72, 0xB545, 0x6E73, 0xD9F5,\r\n\t0x6E74, 0xD5E4, 0x6E77, 0xDA50, 0x6E78, 0xDA4E, 0x6E79, 0xDA52,\t0x6E88, 0xD9EC, 0x6E89, 0xB540, 0x6E8D, 0xDE61, 0x6E8E, 0xDE60,\r\n\t0x6E8F, 0xDE46, 0x6E90, 0xB7BD, 0x6E92, 0xDE5F, 0x6E93, 0xDE49,\t0x6E94, 0xDE4A, 0x6E96, 0xB7C7, 0x6E97, 0xDE68, 0x6E98, 0xB7C2,\r\n\t0x6E99, 0xDE5E, 0x6E9B, 0xDE43, 0x6E9C, 0xB7C8, 0x6E9D, 0xB7BE,\t0x6E9E, 0xDE52, 0x6E9F, 0xDE48, 0x6EA0, 0xDE4B, 0x6EA1, 0xDE63,\r\n\t0x6EA2, 0xB7B8, 0x6EA3, 0xDE6A, 0x6EA4, 0xDE62, 0x6EA5, 0xB7C1,\t0x6EA6, 0xDE57, 0x6EA7, 0xB7CC, 0x6EAA, 0xB7CB, 0x6EAB, 0xB7C5,\r\n\t0x6EAE, 0xDE69, 0x6EAF, 0xB7B9, 0x6EB0, 0xDE55, 0x6EB1, 0xDE4C,\t0x6EB2, 0xDE59, 0x6EB3, 0xDE65, 0x6EB4, 0xB7CD, 0x6EB6, 0xB7BB,\r\n\t0x6EB7, 0xDE54, 0x6EB9, 0xDE4D, 0x6EBA, 0xB7C4, 0x6EBC, 0xB7C3,\t0x6EBD, 0xDE50, 0x6EBE, 0xDE5A, 0x6EBF, 0xDE64, 0x6EC0, 0xDE47,\r\n\t0x6EC1, 0xDE51, 0x6EC2, 0xB7BC, 0x6EC3, 0xDE5B, 0x6EC4, 0xB7C9,\t0x6EC5, 0xB7C0, 0x6EC6, 0xDE4E, 0x6EC7, 0xB7BF, 0x6EC8, 0xDE45,\r\n\t0x6EC9, 0xDE53, 0x6ECA, 0xDE67, 0x6ECB, 0xB4FE, 0x6ECC, 0xBAB0,\t0x6ECD, 0xDE56, 0x6ECE, 0xE26C, 0x6ECF, 0xDE58, 0x6ED0, 0xDE66,\r\n\t0x6ED1, 0xB7C6, 0x6ED2, 0xDE4F, 0x6ED3, 0xB7BA, 0x6ED4, 0xB7CA,\t0x6ED5, 0xBCF0, 0x6ED6, 0xDE44, 0x6ED8, 0xDE5D, 0x6EDC, 0xDE5C,\r\n\t0x6EEB, 0xE2AA, 0x6EEC, 0xBAAD, 0x6EED, 0xE27D, 0x6EEE, 0xE2A4,\t0x6EEF, 0xBAA2, 0x6EF1, 0xE26E, 0x6EF2, 0xBAAF, 0x6EF4, 0xBA77,\r\n\t0x6EF5, 0xE26D, 0x6EF6, 0xE2B0, 0x6EF7, 0xBAB1, 0x6EF8, 0xE271,\t0x6EF9, 0xE2A3, 0x6EFB, 0xE273, 0x6EFC, 0xE2B3, 0x6EFD, 0xE2AF,\r\n\t0x6EFE, 0xBA75, 0x6EFF, 0xBAA1, 0x6F00, 0xE653, 0x6F01, 0xBAAE,\t0x6F02, 0xBA7D, 0x6F03, 0xE26F, 0x6F05, 0xE2AE, 0x6F06, 0xBAA3,\r\n\t0x6F07, 0xE2AB, 0x6F08, 0xE2B8, 0x6F09, 0xE275, 0x6F0A, 0xE27E,\t0x6F0D, 0xE2B6, 0x6F0E, 0xE2AC, 0x6F0F, 0xBA7C, 0x6F12, 0xE27C,\r\n\t0x6F13, 0xBA76, 0x6F14, 0xBA74, 0x6F15, 0xBAA8, 0x6F18, 0xE27A,\t0x6F19, 0xE277, 0x6F1A, 0xE278, 0x6F1C, 0xE2B2, 0x6F1E, 0xE2B7,\r\n\t0x6F1F, 0xE2B5, 0x6F20, 0xBA7A, 0x6F21, 0xE2B9, 0x6F22, 0xBA7E,\t0x6F23, 0xBAA7, 0x6F25, 0xE270, 0x6F26, 0xE5FA, 0x6F27, 0xE279,\r\n\t0x6F29, 0xBA78, 0x6F2A, 0xBAAC, 0x6F2B, 0xBAA9, 0x6F2C, 0xBA7B,\t0x6F2D, 0xE2A5, 0x6F2E, 0xE274, 0x6F2F, 0xBAAA, 0x6F30, 0xE2A7,\r\n\t0x6F31, 0xBAA4, 0x6F32, 0xBAA6, 0x6F33, 0xBA73, 0x6F35, 0xE2A9,\t0x6F36, 0xE2A1, 0x6F37, 0xE272, 0x6F38, 0xBAA5, 0x6F39, 0xE2B1,\r\n\t0x6F3A, 0xE2B4, 0x6F3B, 0xE27B, 0x6F3C, 0xE2A8, 0x6F3E, 0xBA79,\t0x6F3F, 0xBCDF, 0x6F40, 0xE2A6, 0x6F41, 0xE5F9, 0x6F43, 0xE2AD,\r\n\t0x6F4E, 0xE276, 0x6F4F, 0xE644, 0x6F50, 0xE64E, 0x6F51, 0xBCE2,\t0x6F52, 0xE64D, 0x6F53, 0xE659, 0x6F54, 0xBCE4, 0x6F55, 0xE64B,\r\n\t0x6F57, 0xE64F, 0x6F58, 0xBCEF, 0x6F5A, 0xE646, 0x6F5B, 0xBCE7,\t0x6F5D, 0xE652, 0x6F5E, 0xE9F0, 0x6F5F, 0xBCF3, 0x6F60, 0xBCF2,\r\n\t0x6F61, 0xE654, 0x6F62, 0xE643, 0x6F63, 0xE65E, 0x6F64, 0xBCED,\t0x6F66, 0xBCE3, 0x6F67, 0xE657, 0x6F69, 0xE65B, 0x6F6A, 0xE660,\r\n\t0x6F6B, 0xE655, 0x6F6C, 0xE649, 0x6F6D, 0xBCE6, 0x6F6E, 0xBCE9,\t0x6F6F, 0xBCF1, 0x6F70, 0xBCEC, 0x6F72, 0xE64C, 0x6F73, 0xE2A2,\r\n\t0x6F76, 0xE648, 0x6F77, 0xE65F, 0x6F78, 0xBCE8, 0x6F7A, 0xBCEB,\t0x6F7B, 0xE661, 0x6F7C, 0xBCE0, 0x6F7D, 0xE656, 0x6F7E, 0xE5FB,\r\n\t0x6F7F, 0xE65C, 0x6F80, 0xC0DF, 0x6F82, 0xE64A, 0x6F84, 0xBCE1,\t0x6F85, 0xE645, 0x6F86, 0xBCE5, 0x6F87, 0xE5FC, 0x6F88, 0xBAAB,\r\n\t0x6F89, 0xE641, 0x6F8B, 0xE65A, 0x6F8C, 0xE642, 0x6F8D, 0xE640,\t0x6F8E, 0xBCEA, 0x6F90, 0xE658, 0x6F92, 0xE5FE, 0x6F93, 0xE651,\r\n\t0x6F94, 0xE650, 0x6F95, 0xE65D, 0x6F96, 0xE647, 0x6F97, 0xBCEE,\t0x6F9E, 0xE9F3, 0x6FA0, 0xBF49, 0x6FA1, 0xBEFE, 0x6FA2, 0xEA40,\r\n\t0x6FA3, 0xE9EB, 0x6FA4, 0xBF41, 0x6FA5, 0xE9F7, 0x6FA6, 0xBF48,\t0x6FA7, 0xBF43, 0x6FA8, 0xE9F5, 0x6FA9, 0xED4F, 0x6FAA, 0xE9FB,\r\n\t0x6FAB, 0xEA42, 0x6FAC, 0xE9FA, 0x6FAD, 0xE9E9, 0x6FAE, 0xE9F8,\t0x6FAF, 0xEA44, 0x6FB0, 0xEA46, 0x6FB1, 0xBEFD, 0x6FB2, 0xEA45,\r\n\t0x6FB3, 0xBF44, 0x6FB4, 0xBF4A, 0x6FB6, 0xBF47, 0x6FB8, 0xE9FE,\t0x6FB9, 0xBF46, 0x6FBA, 0xE9F9, 0x6FBC, 0xE9ED, 0x6FBD, 0xE9F2,\r\n\t0x6FBF, 0xE9FD, 0x6FC0, 0xBF45, 0x6FC1, 0xBF42, 0x6FC2, 0xBEFC,\t0x6FC3, 0xBF40, 0x6FC4, 0xE9F1, 0x6FC6, 0xE5FD, 0x6FC7, 0xE9EC,\r\n\t0x6FC8, 0xE9EF, 0x6FC9, 0xEA41, 0x6FCA, 0xE9F4, 0x6FCB, 0xE9EA,\t0x6FCC, 0xED4E, 0x6FCD, 0xEA43, 0x6FCE, 0xE9EE, 0x6FCF, 0xE9FC,\r\n\t0x6FD4, 0xED51, 0x6FD5, 0xC0E3, 0x6FD8, 0xC0D7, 0x6FDB, 0xC0DB,\t0x6FDC, 0xED53, 0x6FDD, 0xED59, 0x6FDE, 0xED57, 0x6FDF, 0xC0D9,\r\n\t0x6FE0, 0xC0DA, 0x6FE1, 0xC0E1, 0x6FE2, 0xED5A, 0x6FE3, 0xED52,\t0x6FE4, 0xC0DC, 0x6FE6, 0xED56, 0x6FE7, 0xED55, 0x6FE8, 0xED5B,\r\n\t0x6FE9, 0xC0E2, 0x6FEB, 0xC0DD, 0x6FEC, 0xC0E0, 0x6FED, 0xED54,\t0x6FEE, 0xC0E4, 0x6FEF, 0xC0DE, 0x6FF0, 0xC0E5, 0x6FF1, 0xC0D8,\r\n\t0x6FF2, 0xED58, 0x6FF4, 0xED50, 0x6FF7, 0xEFF7, 0x6FFA, 0xC271,\t0x6FFB, 0xEFF4, 0x6FFC, 0xEFF6, 0x6FFE, 0xC26F, 0x6FFF, 0xEFF2,\r\n\t0x7000, 0xEFF3, 0x7001, 0xEFEE, 0x7004, 0xE9F6, 0x7005, 0xEFEF,\t0x7006, 0xC270, 0x7007, 0xEFEB, 0x7009, 0xC26D, 0x700A, 0xEFF8,\r\n\t0x700B, 0xC26E, 0x700C, 0xEFEC, 0x700D, 0xEFED, 0x700E, 0xEFF1,\t0x700F, 0xC273, 0x7011, 0xC272, 0x7014, 0xEFF0, 0x7015, 0xC378,\r\n\t0x7016, 0xF25F, 0x7017, 0xF265, 0x7018, 0xC379, 0x7019, 0xF25C,\t0x701A, 0xC376, 0x701B, 0xC373, 0x701C, 0xF267, 0x701D, 0xC377,\r\n\t0x701F, 0xC374, 0x7020, 0xF25E, 0x7021, 0xF261, 0x7022, 0xF262,\t0x7023, 0xF263, 0x7024, 0xF266, 0x7026, 0xEFF5, 0x7027, 0xF25D,\r\n\t0x7028, 0xC375, 0x7029, 0xF264, 0x702A, 0xF268, 0x702B, 0xF260,\t0x702F, 0xF45D, 0x7030, 0xC46A, 0x7031, 0xF460, 0x7032, 0xC46B,\r\n\t0x7033, 0xF468, 0x7034, 0xF45F, 0x7035, 0xF45C, 0x7037, 0xF45E,\t0x7038, 0xF462, 0x7039, 0xF465, 0x703A, 0xF464, 0x703B, 0xF467,\r\n\t0x703C, 0xF45B, 0x703E, 0xC469, 0x703F, 0xF463, 0x7040, 0xF466,\t0x7041, 0xF469, 0x7042, 0xF461, 0x7043, 0xF5D3, 0x7044, 0xF5D4,\r\n\t0x7045, 0xF5D8, 0x7046, 0xF5D9, 0x7048, 0xF5D6, 0x7049, 0xF5D7,\t0x704A, 0xF5D5, 0x704C, 0xC4E9, 0x7051, 0xC578, 0x7052, 0xF6EB,\r\n\t0x7055, 0xF6E8, 0x7056, 0xF6E9, 0x7057, 0xF6EA, 0x7058, 0xC579,\t0x705A, 0xF7E5, 0x705B, 0xF7E4, 0x705D, 0xF8AF, 0x705E, 0xC5F4,\r\n\t0x705F, 0xF8AD, 0x7060, 0xF8B0, 0x7061, 0xF8AE, 0x7062, 0xF8F5,\t0x7063, 0xC657, 0x7064, 0xC665, 0x7065, 0xF9A3, 0x7066, 0xF96C,\r\n\t0x7068, 0xF9A2, 0x7069, 0xF9D0, 0x706A, 0xF9D1, 0x706B, 0xA4F5,\t0x7070, 0xA6C7, 0x7071, 0xCA41, 0x7074, 0xCB5E, 0x7076, 0xA85F,\r\n\t0x7078, 0xA862, 0x707A, 0xCB5F, 0x707C, 0xA860, 0x707D, 0xA861,\t0x7082, 0xCD58, 0x7083, 0xCD5A, 0x7084, 0xCD55, 0x7085, 0xCD52,\r\n\t0x7086, 0xCD54, 0x708A, 0xAAA4, 0x708E, 0xAAA2, 0x7091, 0xCD56,\t0x7092, 0xAAA3, 0x7093, 0xCD53, 0x7094, 0xCD50, 0x7095, 0xAAA1,\r\n\t0x7096, 0xCD57, 0x7098, 0xCD51, 0x7099, 0xAAA5, 0x709A, 0xCD59,\t0x709F, 0xCFAF, 0x70A1, 0xCFB3, 0x70A4, 0xACB7, 0x70A9, 0xCFB6,\r\n\t0x70AB, 0xACAF, 0x70AC, 0xACB2, 0x70AD, 0xACB4, 0x70AE, 0xACB6,\t0x70AF, 0xACB3, 0x70B0, 0xCFB2, 0x70B1, 0xCFB1, 0x70B3, 0xACB1,\r\n\t0x70B4, 0xCFB4, 0x70B5, 0xCFB5, 0x70B7, 0xCFAE, 0x70B8, 0xACB5,\t0x70BA, 0xACB0, 0x70BE, 0xCFB0, 0x70C5, 0xD277, 0x70C6, 0xD278,\r\n\t0x70C7, 0xD279, 0x70C8, 0xAF50, 0x70CA, 0xAF4C, 0x70CB, 0xD26E,\t0x70CD, 0xD276, 0x70CE, 0xD27B, 0x70CF, 0xAF51, 0x70D1, 0xD26C,\r\n\t0x70D2, 0xD272, 0x70D3, 0xD26B, 0x70D4, 0xD275, 0x70D7, 0xD271,\t0x70D8, 0xAF4D, 0x70D9, 0xAF4F, 0x70DA, 0xD27A, 0x70DC, 0xD26A,\r\n\t0x70DD, 0xD26D, 0x70DE, 0xD273, 0x70E0, 0xD274, 0x70E1, 0xD27C,\t0x70E2, 0xD270, 0x70E4, 0xAF4E, 0x70EF, 0xB26D, 0x70F0, 0xD64E,\r\n\t0x70F3, 0xD650, 0x70F4, 0xD64C, 0x70F6, 0xD658, 0x70F7, 0xD64A,\t0x70F8, 0xD657, 0x70F9, 0xB269, 0x70FA, 0xD648, 0x70FB, 0xDA5B,\r\n\t0x70FC, 0xD652, 0x70FD, 0xB26C, 0x70FF, 0xD653, 0x7100, 0xD656,\t0x7102, 0xD65A, 0x7104, 0xD64F, 0x7106, 0xD654, 0x7109, 0xB26A,\r\n\t0x710A, 0xB26B, 0x710B, 0xD659, 0x710C, 0xD64D, 0x710D, 0xD649,\t0x710E, 0xD65B, 0x7110, 0xD651, 0x7113, 0xD655, 0x7117, 0xD64B,\r\n\t0x7119, 0xB548, 0x711A, 0xB549, 0x711B, 0xDA65, 0x711C, 0xB54F,\t0x711E, 0xDA59, 0x711F, 0xDA62, 0x7120, 0xDA58, 0x7121, 0xB54C,\r\n\t0x7122, 0xDA60, 0x7123, 0xDA5E, 0x7125, 0xDA5F, 0x7126, 0xB54A,\t0x7128, 0xDA63, 0x712E, 0xDA5C, 0x712F, 0xDA5A, 0x7130, 0xB54B,\r\n\t0x7131, 0xDA5D, 0x7132, 0xDA61, 0x7136, 0xB54D, 0x713A, 0xDA64,\t0x7141, 0xDE70, 0x7142, 0xDE77, 0x7143, 0xDE79, 0x7144, 0xDEA1,\r\n\t0x7146, 0xB7DA, 0x7147, 0xDE6B, 0x7149, 0xB7D2, 0x714B, 0xDE7A,\t0x714C, 0xB7D7, 0x714D, 0xDEA2, 0x714E, 0xB7CE, 0x7150, 0xDE7D,\r\n\t0x7152, 0xDE6D, 0x7153, 0xDE7E, 0x7154, 0xDE6C, 0x7156, 0xB7DC,\t0x7158, 0xDE78, 0x7159, 0xB7CF, 0x715A, 0xDEA3, 0x715C, 0xB7D4,\r\n\t0x715D, 0xDE71, 0x715E, 0xB7D9, 0x715F, 0xDE7C, 0x7160, 0xDE6F,\t0x7161, 0xDE76, 0x7162, 0xDE72, 0x7163, 0xDE6E, 0x7164, 0xB7D1,\r\n\t0x7165, 0xB7D8, 0x7166, 0xB7D6, 0x7167, 0xB7D3, 0x7168, 0xB7DB,\t0x7169, 0xB7D0, 0x716A, 0xDE75, 0x716C, 0xB7D5, 0x716E, 0xB54E,\r\n\t0x7170, 0xDE7B, 0x7172, 0xDE73, 0x7178, 0xDE74, 0x717B, 0xE2C1,\t0x717D, 0xBAB4, 0x7180, 0xE2BD, 0x7181, 0xE2C3, 0x7182, 0xE2BF,\r\n\t0x7184, 0xBAB6, 0x7185, 0xE2BE, 0x7186, 0xE2C2, 0x7187, 0xE2BA,\t0x7189, 0xE2BC, 0x718A, 0xBAB5, 0x718F, 0xE2C0, 0x7190, 0xE2BB,\r\n\t0x7192, 0xBAB7, 0x7194, 0xBAB2, 0x7197, 0xE2C4, 0x7199, 0xBAB3,\t0x719A, 0xE667, 0x719B, 0xE664, 0x719C, 0xE670, 0x719D, 0xE66A,\r\n\t0x719E, 0xE66C, 0x719F, 0xBCF4, 0x71A0, 0xE666, 0x71A1, 0xE66E,\t0x71A4, 0xE66D, 0x71A5, 0xE66B, 0x71A7, 0xE671, 0x71A8, 0xBCF7,\r\n\t0x71A9, 0xE668, 0x71AA, 0xE66F, 0x71AC, 0xBCF5, 0x71AF, 0xE663,\t0x71B0, 0xE665, 0x71B1, 0xBCF6, 0x71B2, 0xE662, 0x71B3, 0xE672,\r\n\t0x71B5, 0xE669, 0x71B8, 0xEA4A, 0x71B9, 0xBF51, 0x71BC, 0xEA55,\t0x71BD, 0xEA53, 0x71BE, 0xBF4B, 0x71BF, 0xEA49, 0x71C0, 0xEA4C,\r\n\t0x71C1, 0xEA4D, 0x71C2, 0xEA48, 0x71C3, 0xBF55, 0x71C4, 0xBF56,\t0x71C5, 0xEA47, 0x71C6, 0xEA56, 0x71C7, 0xEA51, 0x71C8, 0xBF4F,\r\n\t0x71C9, 0xBF4C, 0x71CA, 0xEA50, 0x71CB, 0xEA4E, 0x71CE, 0xBF52,\t0x71CF, 0xEA52, 0x71D0, 0xBF4D, 0x71D2, 0xBF4E, 0x71D4, 0xEA4F,\r\n\t0x71D5, 0xBF50, 0x71D6, 0xEA4B, 0x71D8, 0xEA54, 0x71D9, 0xBF53,\t0x71DA, 0xEA57, 0x71DB, 0xEA58, 0x71DC, 0xBF54, 0x71DF, 0xC0E7,\r\n\t0x71E0, 0xC0EE, 0x71E1, 0xED5C, 0x71E2, 0xED62, 0x71E4, 0xED60,\t0x71E5, 0xC0EA, 0x71E6, 0xC0E9, 0x71E7, 0xC0E6, 0x71E8, 0xED5E,\r\n\t0x71EC, 0xC0EC, 0x71ED, 0xC0EB, 0x71EE, 0xC0E8, 0x71F0, 0xED61,\t0x71F1, 0xED5D, 0x71F2, 0xED5F, 0x71F4, 0xC0ED, 0x71F8, 0xC277,\r\n\t0x71F9, 0xEFFB, 0x71FB, 0xC274, 0x71FC, 0xC275, 0x71FD, 0xEFFD,\t0x71FE, 0xC276, 0x71FF, 0xEFFA, 0x7201, 0xEFF9, 0x7202, 0xF26C,\r\n\t0x7203, 0xEFFC, 0x7205, 0xF26D, 0x7206, 0xC37A, 0x7207, 0xF26B,\t0x720A, 0xF26A, 0x720C, 0xF269, 0x720D, 0xC37B, 0x7210, 0xC46C,\r\n\t0x7213, 0xF46A, 0x7214, 0xF46B, 0x7219, 0xF5DC, 0x721A, 0xF5DB,\t0x721B, 0xC4EA, 0x721D, 0xF5DA, 0x721E, 0xF6EC, 0x721F, 0xF6ED,\r\n\t0x7222, 0xF7E6, 0x7223, 0xF8B1, 0x7226, 0xF8F6, 0x7227, 0xF9BC,\t0x7228, 0xC679, 0x7229, 0xF9C6, 0x722A, 0xA4F6, 0x722C, 0xAAA6,\r\n\t0x722D, 0xAAA7, 0x7230, 0xACB8, 0x7235, 0xC0EF, 0x7236, 0xA4F7,\t0x7238, 0xAAA8, 0x7239, 0xAF52, 0x723A, 0xB7DD, 0x723B, 0xA4F8,\r\n\t0x723D, 0xB26E, 0x723E, 0xBAB8, 0x723F, 0xC962, 0x7241, 0xCFB7,\t0x7242, 0xD27D, 0x7244, 0xE2C5, 0x7246, 0xC0F0, 0x7247, 0xA4F9,\r\n\t0x7248, 0xAAA9, 0x7249, 0xCFB8, 0x724A, 0xCFB9, 0x724B, 0xDA66,\t0x724C, 0xB550, 0x724F, 0xDEA4, 0x7252, 0xB7DE, 0x7253, 0xE2C6,\r\n\t0x7256, 0xBCF8, 0x7258, 0xC37C, 0x7259, 0xA4FA, 0x725A, 0xDA67,\t0x725B, 0xA4FB, 0x725D, 0xA6C9, 0x725E, 0xCA42, 0x725F, 0xA6C8,\r\n\t0x7260, 0xA865, 0x7261, 0xA864, 0x7262, 0xA863, 0x7263, 0xCB60,\t0x7267, 0xAAAA, 0x7269, 0xAAAB, 0x726A, 0xCD5B, 0x726C, 0xCFBA,\r\n\t0x726E, 0xCFBD, 0x726F, 0xACBA, 0x7270, 0xCFBB, 0x7272, 0xACB9,\t0x7273, 0xCFBC, 0x7274, 0xACBB, 0x7276, 0xD2A2, 0x7277, 0xD2A1,\r\n\t0x7278, 0xD27E, 0x7279, 0xAF53, 0x727B, 0xD65D, 0x727C, 0xD65E,\t0x727D, 0xB26F, 0x727E, 0xD65C, 0x727F, 0xD65F, 0x7280, 0xB552,\r\n\t0x7281, 0xB270, 0x7284, 0xB551, 0x7285, 0xDA6B, 0x7286, 0xDA6A,\t0x7288, 0xDA68, 0x7289, 0xDA69, 0x728B, 0xDA6C, 0x728C, 0xDEA6,\r\n\t0x728D, 0xDEA5, 0x728E, 0xDEA9, 0x7290, 0xDEA8, 0x7291, 0xDEA7,\t0x7292, 0xBAB9, 0x7293, 0xE2C9, 0x7295, 0xE2C8, 0x7296, 0xBABA,\r\n\t0x7297, 0xE2C7, 0x7298, 0xE673, 0x729A, 0xE674, 0x729B, 0xBCF9,\t0x729D, 0xEA59, 0x729E, 0xEA5A, 0x72A1, 0xF272, 0x72A2, 0xC37D,\r\n\t0x72A3, 0xF271, 0x72A4, 0xF270, 0x72A5, 0xF26E, 0x72A6, 0xF26F,\t0x72A7, 0xC4EB, 0x72A8, 0xF46C, 0x72A9, 0xF6EE, 0x72AA, 0xF8F7,\r\n\t0x72AC, 0xA4FC, 0x72AE, 0xC9A5, 0x72AF, 0xA5C7, 0x72B0, 0xC9A6,\t0x72B4, 0xCA43, 0x72B5, 0xCA44, 0x72BA, 0xCB66, 0x72BD, 0xCB62,\r\n\t0x72BF, 0xCB61, 0x72C0, 0xAAAC, 0x72C1, 0xCB65, 0x72C2, 0xA867,\t0x72C3, 0xCB63, 0x72C4, 0xA866, 0x72C5, 0xCB67, 0x72C6, 0xCB64,\r\n\t0x72C9, 0xCD5F, 0x72CA, 0xCFBE, 0x72CB, 0xCD5D, 0x72CC, 0xCD64,\t0x72CE, 0xAAAD, 0x72D0, 0xAAB0, 0x72D1, 0xCD65, 0x72D2, 0xCD61,\r\n\t0x72D4, 0xCD62, 0x72D6, 0xCD5C, 0x72D7, 0xAAAF, 0x72D8, 0xCD5E,\t0x72D9, 0xAAAE, 0x72DA, 0xCD63, 0x72DC, 0xCD60, 0x72DF, 0xCFC2,\r\n\t0x72E0, 0xACBD, 0x72E1, 0xACBE, 0x72E3, 0xCFC5, 0x72E4, 0xCFBF,\t0x72E6, 0xCFC4, 0x72E8, 0xCFC0, 0x72E9, 0xACBC, 0x72EA, 0xCFC3,\r\n\t0x72EB, 0xCFC1, 0x72F3, 0xD2A8, 0x72F4, 0xD2A5, 0x72F6, 0xD2A7,\t0x72F7, 0xAF58, 0x72F8, 0xAF57, 0x72F9, 0xAF55, 0x72FA, 0xD2A4,\r\n\t0x72FB, 0xD2A9, 0x72FC, 0xAF54, 0x72FD, 0xAF56, 0x72FE, 0xD2A6,\t0x72FF, 0xD667, 0x7300, 0xD2A3, 0x7301, 0xD2AA, 0x7307, 0xD662,\r\n\t0x7308, 0xD666, 0x730A, 0xD665, 0x730B, 0xDA6E, 0x730C, 0xDA79,\t0x730F, 0xD668, 0x7311, 0xD663, 0x7312, 0xDA6D, 0x7313, 0xB274,\r\n\t0x7316, 0xB273, 0x7317, 0xD661, 0x7318, 0xD664, 0x7319, 0xB275,\t0x731B, 0xB272, 0x731C, 0xB271, 0x731D, 0xD660, 0x731E, 0xD669,\r\n\t0x7322, 0xDA70, 0x7323, 0xDA77, 0x7325, 0xB554, 0x7326, 0xDA76,\t0x7327, 0xDA73, 0x7329, 0xB556, 0x732D, 0xDA75, 0x7330, 0xDA6F,\r\n\t0x7331, 0xDA71, 0x7332, 0xDA74, 0x7333, 0xDA72, 0x7334, 0xB555,\t0x7335, 0xDA78, 0x7336, 0xB553, 0x7337, 0xB7DF, 0x733A, 0xDEAD,\r\n\t0x733B, 0xDEAC, 0x733C, 0xDEAA, 0x733E, 0xB7E2, 0x733F, 0xB7E1,\t0x7340, 0xDEAE, 0x7342, 0xDEAB, 0x7343, 0xE2CA, 0x7344, 0xBABB,\r\n\t0x7345, 0xB7E0, 0x7349, 0xDEB0, 0x734A, 0xDEAF, 0x734C, 0xE2CD,\t0x734D, 0xE2CB, 0x734E, 0xBCFA, 0x7350, 0xBABC, 0x7351, 0xE2CC,\r\n\t0x7352, 0xE676, 0x7357, 0xBCFB, 0x7358, 0xE675, 0x7359, 0xE67E,\t0x735A, 0xE67D, 0x735B, 0xE67B, 0x735D, 0xE67A, 0x735E, 0xE677,\r\n\t0x735F, 0xE678, 0x7360, 0xE679, 0x7361, 0xE67C, 0x7362, 0xE6A1,\t0x7365, 0xEA5F, 0x7366, 0xEA5C, 0x7367, 0xEA5D, 0x7368, 0xBF57,\r\n\t0x7369, 0xEA5B, 0x736A, 0xEA61, 0x736B, 0xEA60, 0x736C, 0xEA5E,\t0x736E, 0xED64, 0x736F, 0xED65, 0x7370, 0xC0F1, 0x7372, 0xC0F2,\r\n\t0x7373, 0xED63, 0x7375, 0xC279, 0x7376, 0xEFFE, 0x7377, 0xC278,\t0x7378, 0xC37E, 0x737A, 0xC3A1, 0x737B, 0xC46D, 0x737C, 0xF46E,\r\n\t0x737D, 0xF46D, 0x737E, 0xF5DD, 0x737F, 0xF6EF, 0x7380, 0xC57A,\t0x7381, 0xF7E8, 0x7382, 0xF7E7, 0x7383, 0xF7E9, 0x7384, 0xA5C8,\r\n\t0x7385, 0xCFC6, 0x7386, 0xAF59, 0x7387, 0xB276, 0x7388, 0xD66A,\t0x7389, 0xA5C9, 0x738A, 0xC9A7, 0x738B, 0xA4FD, 0x738E, 0xCA45,\r\n\t0x7392, 0xCB6C, 0x7393, 0xCB6A, 0x7394, 0xCB6B, 0x7395, 0xCB68,\t0x7396, 0xA868, 0x7397, 0xCB69, 0x739D, 0xCD6D, 0x739F, 0xAAB3,\r\n\t0x73A0, 0xCD6B, 0x73A1, 0xCD67, 0x73A2, 0xCD6A, 0x73A4, 0xCD66,\t0x73A5, 0xAAB5, 0x73A6, 0xCD69, 0x73A8, 0xAAB2, 0x73A9, 0xAAB1,\r\n\t0x73AB, 0xAAB4, 0x73AC, 0xCD6C, 0x73AD, 0xCD68, 0x73B2, 0xACC2,\t0x73B3, 0xACC5, 0x73B4, 0xCFCE, 0x73B5, 0xCFCD, 0x73B6, 0xCFCC,\r\n\t0x73B7, 0xACBF, 0x73B8, 0xCFD5, 0x73B9, 0xCFCB, 0x73BB, 0xACC1,\t0x73BC, 0xD2AF, 0x73BE, 0xCFD2, 0x73BF, 0xCFD0, 0x73C0, 0xACC4,\r\n\t0x73C2, 0xCFC8, 0x73C3, 0xCFD3, 0x73C5, 0xCFCA, 0x73C6, 0xCFD4,\t0x73C7, 0xCFD1, 0x73C8, 0xCFC9, 0x73CA, 0xACC0, 0x73CB, 0xCFD6,\r\n\t0x73CC, 0xCFC7, 0x73CD, 0xACC3, 0x73D2, 0xD2B4, 0x73D3, 0xD2AB,\t0x73D4, 0xD2B6, 0x73D6, 0xD2AE, 0x73D7, 0xD2B9, 0x73D8, 0xD2BA,\r\n\t0x73D9, 0xD2AC, 0x73DA, 0xD2B8, 0x73DB, 0xD2B5, 0x73DC, 0xD2B3,\t0x73DD, 0xD2B7, 0x73DE, 0xAF5F, 0x73E0, 0xAF5D, 0x73E3, 0xD2B1,\r\n\t0x73E5, 0xD2AD, 0x73E7, 0xD2B0, 0x73E8, 0xD2BB, 0x73E9, 0xD2B2,\t0x73EA, 0xAF5E, 0x73EB, 0xCFCF, 0x73ED, 0xAF5A, 0x73EE, 0xAF5C,\r\n\t0x73F4, 0xD678, 0x73F5, 0xD66D, 0x73F6, 0xD66B, 0x73F8, 0xD66C,\t0x73FA, 0xD673, 0x73FC, 0xD674, 0x73FD, 0xD670, 0x73FE, 0xB27B,\r\n\t0x73FF, 0xD675, 0x7400, 0xD672, 0x7401, 0xD66F, 0x7403, 0xB279,\t0x7404, 0xD66E, 0x7405, 0xB277, 0x7406, 0xB27A, 0x7407, 0xD671,\r\n\t0x7408, 0xD679, 0x7409, 0xAF5B, 0x740A, 0xB278, 0x740B, 0xD677,\t0x740C, 0xD676, 0x740D, 0xB27C, 0x7416, 0xDA7E, 0x741A, 0xDAA1,\r\n\t0x741B, 0xB560, 0x741D, 0xDAA7, 0x7420, 0xDAA9, 0x7421, 0xDAA2,\t0x7422, 0xB55A, 0x7423, 0xDAA6, 0x7424, 0xDAA5, 0x7425, 0xB55B,\r\n\t0x7426, 0xB561, 0x7428, 0xB562, 0x7429, 0xDAA8, 0x742A, 0xB558,\t0x742B, 0xDA7D, 0x742C, 0xDA7B, 0x742D, 0xDAA3, 0x742E, 0xDA7A,\r\n\t0x742F, 0xB55F, 0x7430, 0xDA7C, 0x7431, 0xDAA4, 0x7432, 0xDAAA,\t0x7433, 0xB559, 0x7434, 0xB55E, 0x7435, 0xB55C, 0x7436, 0xB55D,\r\n\t0x743A, 0xB557, 0x743F, 0xB7E9, 0x7440, 0xDEB7, 0x7441, 0xB7E8,\t0x7442, 0xDEBB, 0x7444, 0xDEB1, 0x7446, 0xDEBC, 0x744A, 0xDEB2,\r\n\t0x744B, 0xDEB3, 0x744D, 0xDEBD, 0x744E, 0xDEBA, 0x744F, 0xDEB8,\t0x7450, 0xDEB9, 0x7451, 0xDEB5, 0x7452, 0xDEB4, 0x7454, 0xDEBE,\r\n\t0x7455, 0xB7E5, 0x7457, 0xDEB6, 0x7459, 0xB7EA, 0x745A, 0xB7E4,\t0x745B, 0xB7EB, 0x745C, 0xB7EC, 0x745E, 0xB7E7, 0x745F, 0xB7E6,\r\n\t0x7462, 0xE2CE, 0x7463, 0xBABE, 0x7464, 0xBABD, 0x7467, 0xE2D3,\t0x7469, 0xBCFC, 0x746A, 0xBABF, 0x746D, 0xBAC1, 0x746E, 0xE2D4,\r\n\t0x746F, 0xB7E3, 0x7470, 0xBAC0, 0x7471, 0xE2D0, 0x7472, 0xE2D2,\t0x7473, 0xE2CF, 0x7475, 0xE2D1, 0x7479, 0xE6AB, 0x747C, 0xE6AA,\r\n\t0x747D, 0xE6A7, 0x747E, 0xBD40, 0x747F, 0xEA62, 0x7480, 0xBD41,\t0x7481, 0xE6A6, 0x7483, 0xBCFE, 0x7485, 0xE6A8, 0x7486, 0xE6A5,\r\n\t0x7487, 0xE6A2, 0x7488, 0xE6A9, 0x7489, 0xE6A3, 0x748A, 0xE6A4,\t0x748B, 0xBCFD, 0x7490, 0xED69, 0x7492, 0xEA66, 0x7494, 0xEA65,\r\n\t0x7495, 0xEA67, 0x7497, 0xED66, 0x7498, 0xBF5A, 0x749A, 0xEA63,\t0x749C, 0xBF58, 0x749E, 0xBF5C, 0x749F, 0xBF5B, 0x74A0, 0xEA64,\r\n\t0x74A1, 0xEA68, 0x74A3, 0xBF59, 0x74A5, 0xED6D, 0x74A6, 0xC0F5,\t0x74A7, 0xC27A, 0x74A8, 0xC0F6, 0x74A9, 0xC0F3, 0x74AA, 0xED6A,\r\n\t0x74AB, 0xED68, 0x74AD, 0xED6B, 0x74AF, 0xED6E, 0x74B0, 0xC0F4,\t0x74B1, 0xED6C, 0x74B2, 0xED67, 0x74B5, 0xF042, 0x74B6, 0xF045,\r\n\t0x74B7, 0xF275, 0x74B8, 0xF040, 0x74BA, 0xF46F, 0x74BB, 0xF046,\t0x74BD, 0xC3A2, 0x74BE, 0xF044, 0x74BF, 0xC27B, 0x74C0, 0xF041,\r\n\t0x74C1, 0xF043, 0x74C2, 0xF047, 0x74C3, 0xF276, 0x74C5, 0xF274,\t0x74CA, 0xC3A3, 0x74CB, 0xF273, 0x74CF, 0xC46E, 0x74D4, 0xC4ED,\r\n\t0x74D5, 0xF6F1, 0x74D6, 0xC4EC, 0x74D7, 0xF6F3, 0x74D8, 0xF6F0,\t0x74D9, 0xF6F2, 0x74DA, 0xC5D0, 0x74DB, 0xF8B2, 0x74DC, 0xA5CA,\r\n\t0x74DD, 0xCD6E, 0x74DE, 0xD2BC, 0x74DF, 0xD2BD, 0x74E0, 0xB27D,\t0x74E1, 0xDEBF, 0x74E2, 0xBF5D, 0x74E3, 0xC3A4, 0x74E4, 0xC57B,\r\n\t0x74E5, 0xF8B3, 0x74E6, 0xA5CB, 0x74E8, 0xCD6F, 0x74E9, 0xA260,\t0x74EC, 0xCFD7, 0x74EE, 0xCFD8, 0x74F4, 0xD2BE, 0x74F5, 0xD2BF,\r\n\t0x74F6, 0xB27E, 0x74F7, 0xB2A1, 0x74FB, 0xDAAB, 0x74FD, 0xDEC2,\t0x74FE, 0xDEC1, 0x74FF, 0xDEC0, 0x7500, 0xE2D5, 0x7502, 0xE2D6,\r\n\t0x7503, 0xE2D7, 0x7504, 0xBAC2, 0x7507, 0xE6AD, 0x7508, 0xE6AC,\t0x750B, 0xEA69, 0x750C, 0xBF5E, 0x750D, 0xBF5F, 0x750F, 0xED72,\r\n\t0x7510, 0xED6F, 0x7511, 0xED70, 0x7512, 0xED71, 0x7513, 0xF049,\t0x7514, 0xF048, 0x7515, 0xC27C, 0x7516, 0xF277, 0x7517, 0xF5DE,\r\n\t0x7518, 0xA5CC, 0x751A, 0xACC6, 0x751C, 0xB2A2, 0x751D, 0xDEC3,\t0x751F, 0xA5CD, 0x7521, 0xD2C0, 0x7522, 0xB2A3, 0x7525, 0xB563,\r\n\t0x7526, 0xB564, 0x7528, 0xA5CE, 0x7529, 0xA5CF, 0x752A, 0xCA46,\t0x752B, 0xA86A, 0x752C, 0xA869, 0x752D, 0xACC7, 0x752E, 0xCFD9,\r\n\t0x752F, 0xDAAC, 0x7530, 0xA5D0, 0x7531, 0xA5D1, 0x7532, 0xA5D2,\t0x7533, 0xA5D3, 0x7537, 0xA86B, 0x7538, 0xA86C, 0x7539, 0xCB6E,\r\n\t0x753A, 0xCB6D, 0x753D, 0xAAB6, 0x753E, 0xCD72, 0x753F, 0xCD70,\t0x7540, 0xCD71, 0x7547, 0xCFDA, 0x7548, 0xCFDB, 0x754B, 0xACCB,\r\n\t0x754C, 0xACC9, 0x754E, 0xACCA, 0x754F, 0xACC8, 0x7554, 0xAF60,\t0x7559, 0xAF64, 0x755A, 0xAF63, 0x755B, 0xD2C1, 0x755C, 0xAF62,\r\n\t0x755D, 0xAF61, 0x755F, 0xD2C2, 0x7562, 0xB2A6, 0x7563, 0xD67B,\t0x7564, 0xD67A, 0x7565, 0xB2A4, 0x7566, 0xB2A5, 0x756A, 0xB566,\r\n\t0x756B, 0xB565, 0x756C, 0xDAAE, 0x756F, 0xDAAD, 0x7570, 0xB2A7,\t0x7576, 0xB7ED, 0x7577, 0xDEC5, 0x7578, 0xB7EE, 0x7579, 0xDEC4,\r\n\t0x757D, 0xE2D8, 0x757E, 0xE6AE, 0x757F, 0xBD42, 0x7580, 0xEA6A,\t0x7584, 0xED73, 0x7586, 0xC3A6, 0x7587, 0xC3A5, 0x758A, 0xC57C,\r\n\t0x758B, 0xA5D4, 0x758C, 0xCD73, 0x758F, 0xB2A8, 0x7590, 0xE2D9,\t0x7591, 0xBAC3, 0x7594, 0xCB6F, 0x7595, 0xCB70, 0x7598, 0xCD74,\r\n\t0x7599, 0xAAB8, 0x759A, 0xAAB9, 0x759D, 0xAAB7, 0x75A2, 0xACCF,\t0x75A3, 0xACD0, 0x75A4, 0xACCD, 0x75A5, 0xACCE, 0x75A7, 0xCFDC,\r\n\t0x75AA, 0xCFDD, 0x75AB, 0xACCC, 0x75B0, 0xD2C3, 0x75B2, 0xAF68,\t0x75B3, 0xAF69, 0x75B5, 0xB2AB, 0x75B6, 0xD2C9, 0x75B8, 0xAF6E,\r\n\t0x75B9, 0xAF6C, 0x75BA, 0xD2CA, 0x75BB, 0xD2C5, 0x75BC, 0xAF6B,\t0x75BD, 0xAF6A, 0x75BE, 0xAF65, 0x75BF, 0xD2C8, 0x75C0, 0xD2C7,\r\n\t0x75C1, 0xD2C4, 0x75C2, 0xAF6D, 0x75C4, 0xD2C6, 0x75C5, 0xAF66,\t0x75C7, 0xAF67, 0x75CA, 0xB2AC, 0x75CB, 0xD6A1, 0x75CC, 0xD6A2,\r\n\t0x75CD, 0xB2AD, 0x75CE, 0xD67C, 0x75CF, 0xD67E, 0x75D0, 0xD6A4,\t0x75D1, 0xD6A3, 0x75D2, 0xD67D, 0x75D4, 0xB2A9, 0x75D5, 0xB2AA,\r\n\t0x75D7, 0xDAB6, 0x75D8, 0xB56B, 0x75D9, 0xB56A, 0x75DA, 0xDAB0,\t0x75DB, 0xB568, 0x75DD, 0xDAB3, 0x75DE, 0xB56C, 0x75DF, 0xDAB4,\r\n\t0x75E0, 0xB56D, 0x75E1, 0xDAB1, 0x75E2, 0xB567, 0x75E3, 0xB569,\t0x75E4, 0xDAB5, 0x75E6, 0xDAB2, 0x75E7, 0xDAAF, 0x75ED, 0xDED2,\r\n\t0x75EF, 0xDEC7, 0x75F0, 0xB7F0, 0x75F1, 0xB7F3, 0x75F2, 0xB7F2,\t0x75F3, 0xB7F7, 0x75F4, 0xB7F6, 0x75F5, 0xDED3, 0x75F6, 0xDED1,\r\n\t0x75F7, 0xDECA, 0x75F8, 0xDECE, 0x75F9, 0xDECD, 0x75FA, 0xB7F4,\t0x75FB, 0xDED0, 0x75FC, 0xDECC, 0x75FD, 0xDED4, 0x75FE, 0xDECB,\r\n\t0x75FF, 0xB7F5, 0x7600, 0xB7EF, 0x7601, 0xB7F1, 0x7603, 0xDEC9,\t0x7608, 0xE2DB, 0x7609, 0xBAC7, 0x760A, 0xE2DF, 0x760B, 0xBAC6,\r\n\t0x760C, 0xE2DC, 0x760D, 0xBAC5, 0x760F, 0xDEC8, 0x7610, 0xDECF,\t0x7611, 0xE2DE, 0x7613, 0xBAC8, 0x7614, 0xE2E0, 0x7615, 0xE2DD,\r\n\t0x7616, 0xE2DA, 0x7619, 0xE6B1, 0x761A, 0xE6B5, 0x761B, 0xE6B7,\t0x761C, 0xE6B3, 0x761D, 0xE6B2, 0x761E, 0xE6B0, 0x761F, 0xBD45,\r\n\t0x7620, 0xBD43, 0x7621, 0xBD48, 0x7622, 0xBD49, 0x7623, 0xE6B4,\t0x7624, 0xBD46, 0x7625, 0xE6AF, 0x7626, 0xBD47, 0x7627, 0xBAC4,\r\n\t0x7628, 0xE6B6, 0x7629, 0xBD44, 0x762D, 0xEA6C, 0x762F, 0xEA6B,\t0x7630, 0xEA73, 0x7631, 0xEA6D, 0x7632, 0xEA72, 0x7633, 0xEA6F,\r\n\t0x7634, 0xBF60, 0x7635, 0xEA71, 0x7638, 0xBF61, 0x763A, 0xBF62,\t0x763C, 0xEA70, 0x763D, 0xEA6E, 0x7642, 0xC0F8, 0x7643, 0xED74,\r\n\t0x7646, 0xC0F7, 0x7647, 0xED77, 0x7648, 0xED75, 0x7649, 0xED76,\t0x764C, 0xC0F9, 0x7650, 0xF04D, 0x7652, 0xC2A1, 0x7653, 0xF04E,\r\n\t0x7656, 0xC27D, 0x7657, 0xF04F, 0x7658, 0xC27E, 0x7659, 0xF04C,\t0x765A, 0xF050, 0x765C, 0xF04A, 0x765F, 0xC3A7, 0x7660, 0xF278,\r\n\t0x7661, 0xC3A8, 0x7662, 0xC46F, 0x7664, 0xF04B, 0x7665, 0xC470,\t0x7669, 0xC4EE, 0x766A, 0xF5DF, 0x766C, 0xC57E, 0x766D, 0xF6F4,\r\n\t0x766E, 0xC57D, 0x7670, 0xF7EA, 0x7671, 0xC5F5, 0x7672, 0xC5F6,\t0x7675, 0xF9CC, 0x7678, 0xACD1, 0x7679, 0xCFDE, 0x767B, 0xB56E,\r\n\t0x767C, 0xB56F, 0x767D, 0xA5D5, 0x767E, 0xA6CA, 0x767F, 0xCA47,\t0x7681, 0xCB71, 0x7682, 0xA86D, 0x7684, 0xAABA, 0x7686, 0xACD2,\r\n\t0x7687, 0xACD3, 0x7688, 0xACD4, 0x7689, 0xD6A6, 0x768A, 0xD2CB,\t0x768B, 0xAF6F, 0x768E, 0xB2AE, 0x768F, 0xD6A5, 0x7692, 0xDAB8,\r\n\t0x7693, 0xB571, 0x7695, 0xDAB7, 0x7696, 0xB570, 0x7699, 0xDED5,\t0x769A, 0xBD4A, 0x769B, 0xE6BB, 0x769C, 0xE6B8, 0x769D, 0xE6B9,\r\n\t0x769E, 0xE6BA, 0x76A4, 0xED78, 0x76A6, 0xF051, 0x76AA, 0xF471,\t0x76AB, 0xF470, 0x76AD, 0xF6F5, 0x76AE, 0xA5D6, 0x76AF, 0xCD75,\r\n\t0x76B0, 0xAF70, 0x76B4, 0xB572, 0x76B5, 0xDED6, 0x76B8, 0xE2E1,\t0x76BA, 0xBD4B, 0x76BB, 0xEA74, 0x76BD, 0xF052, 0x76BE, 0xF472,\r\n\t0x76BF, 0xA5D7, 0x76C2, 0xAABB, 0x76C3, 0xACD7, 0x76C4, 0xCFDF,\t0x76C5, 0xACD8, 0x76C6, 0xACD6, 0x76C8, 0xACD5, 0x76C9, 0xD2CC,\r\n\t0x76CA, 0xAF71, 0x76CD, 0xAF72, 0x76CE, 0xAF73, 0x76D2, 0xB2B0,\t0x76D3, 0xD6A7, 0x76D4, 0xB2AF, 0x76DA, 0xDAB9, 0x76DB, 0xB2B1,\r\n\t0x76DC, 0xB573, 0x76DD, 0xDED7, 0x76DE, 0xB7F8, 0x76DF, 0xB7F9,\t0x76E1, 0xBAC9, 0x76E3, 0xBACA, 0x76E4, 0xBD4C, 0x76E5, 0xBF64,\r\n\t0x76E6, 0xEA75, 0x76E7, 0xBF63, 0x76E9, 0xED79, 0x76EA, 0xC0FA,\t0x76EC, 0xF053, 0x76ED, 0xF473, 0x76EE, 0xA5D8, 0x76EF, 0xA86E,\r\n\t0x76F0, 0xCD78, 0x76F1, 0xCD77, 0x76F2, 0xAABC, 0x76F3, 0xCD76,\t0x76F4, 0xAABD, 0x76F5, 0xCD79, 0x76F7, 0xCFE5, 0x76F8, 0xACDB,\r\n\t0x76F9, 0xACDA, 0x76FA, 0xCFE7, 0x76FB, 0xCFE6, 0x76FC, 0xACDF,\t0x76FE, 0xACDE, 0x7701, 0xACD9, 0x7703, 0xCFE1, 0x7704, 0xCFE2,\r\n\t0x7705, 0xCFE3, 0x7707, 0xACE0, 0x7708, 0xCFE0, 0x7709, 0xACDC,\t0x770A, 0xCFE4, 0x770B, 0xACDD, 0x7710, 0xD2CF, 0x7711, 0xD2D3,\r\n\t0x7712, 0xD2D1, 0x7713, 0xD2D0, 0x7715, 0xD2D4, 0x7719, 0xD2D5,\t0x771A, 0xD2D6, 0x771B, 0xD2CE, 0x771D, 0xD2CD, 0x771F, 0xAF75,\r\n\t0x7720, 0xAF76, 0x7722, 0xD2D7, 0x7723, 0xD2D2, 0x7725, 0xD6B0,\t0x7727, 0xD2D8, 0x7728, 0xAF77, 0x7729, 0xAF74, 0x772D, 0xD6AA,\r\n\t0x772F, 0xD6A9, 0x7731, 0xD6AB, 0x7732, 0xD6AC, 0x7733, 0xD6AE,\t0x7734, 0xD6AD, 0x7735, 0xD6B2, 0x7736, 0xB2B5, 0x7737, 0xB2B2,\r\n\t0x7738, 0xB2B6, 0x7739, 0xD6A8, 0x773A, 0xB2B7, 0x773B, 0xD6B1,\t0x773C, 0xB2B4, 0x773D, 0xD6AF, 0x773E, 0xB2B3, 0x7744, 0xDABC,\r\n\t0x7745, 0xDABE, 0x7746, 0xDABA, 0x7747, 0xDABB, 0x774A, 0xDABF,\t0x774B, 0xDAC1, 0x774C, 0xDAC2, 0x774D, 0xDABD, 0x774E, 0xDAC0,\r\n\t0x774F, 0xB574, 0x7752, 0xDEDB, 0x7754, 0xDEE0, 0x7755, 0xDED8,\t0x7756, 0xDEDC, 0x7759, 0xDEE1, 0x775A, 0xDEDD, 0x775B, 0xB7FA,\r\n\t0x775C, 0xB843, 0x775E, 0xB7FD, 0x775F, 0xDED9, 0x7760, 0xDEDA,\t0x7761, 0xBACE, 0x7762, 0xB846, 0x7763, 0xB7FE, 0x7765, 0xB844,\r\n\t0x7766, 0xB7FC, 0x7767, 0xDEDF, 0x7768, 0xB845, 0x7769, 0xDEDE,\t0x776A, 0xB841, 0x776B, 0xB7FB, 0x776C, 0xB842, 0x776D, 0xDEE2,\r\n\t0x776E, 0xE2E6, 0x776F, 0xE2E8, 0x7779, 0xB840, 0x777C, 0xE2E3,\t0x777D, 0xBACC, 0x777E, 0xE2E9, 0x777F, 0xBACD, 0x7780, 0xE2E7,\r\n\t0x7781, 0xE2E2, 0x7782, 0xE2E5, 0x7783, 0xE2EA, 0x7784, 0xBACB,\t0x7785, 0xE2E4, 0x7787, 0xBD4E, 0x7788, 0xE6BF, 0x7789, 0xE6BE,\r\n\t0x778B, 0xBD51, 0x778C, 0xBD4F, 0x778D, 0xE6BC, 0x778E, 0xBD4D,\t0x778F, 0xE6BD, 0x7791, 0xBD50, 0x7795, 0xEA7D, 0x7797, 0xEAA1,\r\n\t0x7799, 0xEA7E, 0x779A, 0xEA76, 0x779B, 0xEA7A, 0x779C, 0xEA79,\t0x779D, 0xEA77, 0x779E, 0xBF66, 0x779F, 0xBF67, 0x77A0, 0xBF65,\r\n\t0x77A1, 0xEA78, 0x77A2, 0xEA7B, 0x77A3, 0xEA7C, 0x77A5, 0xBF68,\t0x77A7, 0xC140, 0x77A8, 0xEDA3, 0x77AA, 0xC0FC, 0x77AB, 0xED7B,\r\n\t0x77AC, 0xC0FE, 0x77AD, 0xC141, 0x77B0, 0xC0FD, 0x77B1, 0xEDA2,\t0x77B2, 0xED7C, 0x77B3, 0xC0FB, 0x77B4, 0xEDA1, 0x77B5, 0xED7A,\r\n\t0x77B6, 0xED7E, 0x77B7, 0xED7D, 0x77BA, 0xF055, 0x77BB, 0xC2A4,\t0x77BC, 0xC2A5, 0x77BD, 0xC2A2, 0x77BF, 0xC2A3, 0x77C2, 0xF054,\r\n\t0x77C4, 0xF27B, 0x77C7, 0xC3A9, 0x77C9, 0xF279, 0x77CA, 0xF27A,\t0x77CC, 0xF474, 0x77CD, 0xF477, 0x77CE, 0xF475, 0x77CF, 0xF476,\r\n\t0x77D0, 0xF5E0, 0x77D3, 0xC4EF, 0x77D4, 0xF7EB, 0x77D5, 0xF8B4,\t0x77D7, 0xC5F7, 0x77D8, 0xF8F8, 0x77D9, 0xF8F9, 0x77DA, 0xC666,\r\n\t0x77DB, 0xA5D9, 0x77DC, 0xACE1, 0x77DE, 0xDAC3, 0x77E0, 0xDEE3,\t0x77E2, 0xA5DA, 0x77E3, 0xA86F, 0x77E5, 0xAABE, 0x77E7, 0xCFE8,\r\n\t0x77E8, 0xCFE9, 0x77E9, 0xAF78, 0x77EC, 0xDAC4, 0x77ED, 0xB575,\t0x77EE, 0xB847, 0x77EF, 0xC142, 0x77F0, 0xEDA4, 0x77F1, 0xF27C,\r\n\t0x77F2, 0xF478, 0x77F3, 0xA5DB, 0x77F7, 0xCDA1, 0x77F8, 0xCD7A,\t0x77F9, 0xCD7C, 0x77FA, 0xCD7E, 0x77FB, 0xCD7D, 0x77FC, 0xCD7B,\r\n\t0x77FD, 0xAABF, 0x7802, 0xACE2, 0x7803, 0xCFF2, 0x7805, 0xCFED,\t0x7806, 0xCFEA, 0x7809, 0xCFF1, 0x780C, 0xACE4, 0x780D, 0xACE5,\r\n\t0x780E, 0xCFF0, 0x780F, 0xCFEF, 0x7810, 0xCFEE, 0x7811, 0xCFEB,\t0x7812, 0xCFEC, 0x7813, 0xCFF3, 0x7814, 0xACE3, 0x781D, 0xAF7C,\r\n\t0x781F, 0xAFA4, 0x7820, 0xAFA3, 0x7821, 0xD2E1, 0x7822, 0xD2DB,\t0x7823, 0xD2D9, 0x7825, 0xAFA1, 0x7826, 0xD6B9, 0x7827, 0xAF7A,\r\n\t0x7828, 0xD2DE, 0x7829, 0xD2E2, 0x782A, 0xD2E4, 0x782B, 0xD2E0,\t0x782C, 0xD2DA, 0x782D, 0xAFA2, 0x782E, 0xD2DF, 0x782F, 0xD2DD,\r\n\t0x7830, 0xAF79, 0x7831, 0xD2E5, 0x7832, 0xAFA5, 0x7833, 0xD2E3,\t0x7834, 0xAF7D, 0x7835, 0xD2DC, 0x7837, 0xAF7E, 0x7838, 0xAF7B,\r\n\t0x7843, 0xB2B9, 0x7845, 0xD6BA, 0x7848, 0xD6B3, 0x7849, 0xD6B5,\t0x784A, 0xD6B7, 0x784C, 0xD6B8, 0x784D, 0xD6B6, 0x784E, 0xB2BA,\r\n\t0x7850, 0xD6BB, 0x7852, 0xD6B4, 0x785C, 0xDAC8, 0x785D, 0xB576,\t0x785E, 0xDAD0, 0x7860, 0xDAC5, 0x7862, 0xDAD1, 0x7864, 0xDAC6,\r\n\t0x7865, 0xDAC7, 0x7868, 0xDACF, 0x7869, 0xDACE, 0x786A, 0xDACB,\t0x786B, 0xB2B8, 0x786C, 0xB577, 0x786D, 0xDAC9, 0x786E, 0xDACC,\r\n\t0x786F, 0xB578, 0x7870, 0xDACD, 0x7871, 0xDACA, 0x7879, 0xDEEE,\t0x787B, 0xDEF2, 0x787C, 0xB84E, 0x787E, 0xE2F0, 0x787F, 0xB851,\r\n\t0x7880, 0xDEF0, 0x7881, 0xF9D6, 0x7883, 0xDEED, 0x7884, 0xDEE8,\t0x7885, 0xDEEA, 0x7886, 0xDEEB, 0x7887, 0xDEE4, 0x7889, 0xB84D,\r\n\t0x788C, 0xB84C, 0x788E, 0xB848, 0x788F, 0xDEE7, 0x7891, 0xB84F,\t0x7893, 0xB850, 0x7894, 0xDEE6, 0x7895, 0xDEE9, 0x7896, 0xDEF1,\r\n\t0x7897, 0xB84A, 0x7898, 0xB84B, 0x7899, 0xDEEF, 0x789A, 0xDEE5,\t0x789E, 0xE2F2, 0x789F, 0xBAD0, 0x78A0, 0xE2F4, 0x78A1, 0xDEEC,\r\n\t0x78A2, 0xE2F6, 0x78A3, 0xBAD4, 0x78A4, 0xE2F7, 0x78A5, 0xE2F3,\t0x78A7, 0xBAD1, 0x78A8, 0xE2EF, 0x78A9, 0xBAD3, 0x78AA, 0xE2EC,\r\n\t0x78AB, 0xE2F1, 0x78AC, 0xE2F5, 0x78AD, 0xE2EE, 0x78B0, 0xB849,\t0x78B2, 0xE2EB, 0x78B3, 0xBAD2, 0x78B4, 0xE2ED, 0x78BA, 0xBD54,\r\n\t0x78BB, 0xE6C1, 0x78BC, 0xBD58, 0x78BE, 0xBD56, 0x78C1, 0xBACF,\t0x78C3, 0xE6C8, 0x78C4, 0xE6C9, 0x78C5, 0xBD53, 0x78C8, 0xE6C7,\r\n\t0x78C9, 0xE6CA, 0x78CA, 0xBD55, 0x78CB, 0xBD52, 0x78CC, 0xE6C3,\t0x78CD, 0xE6C0, 0x78CE, 0xE6C5, 0x78CF, 0xE6C2, 0x78D0, 0xBD59,\r\n\t0x78D1, 0xE6C4, 0x78D4, 0xE6C6, 0x78D5, 0xBD57, 0x78DA, 0xBF6A,\t0x78DB, 0xEAA8, 0x78DD, 0xEAA2, 0x78DE, 0xEAA6, 0x78DF, 0xEAAC,\r\n\t0x78E0, 0xEAAD, 0x78E1, 0xEAA9, 0x78E2, 0xEAAA, 0x78E3, 0xEAA7,\t0x78E5, 0xEAA4, 0x78E7, 0xBF6C, 0x78E8, 0xBF69, 0x78E9, 0xEAA3,\r\n\t0x78EA, 0xEAA5, 0x78EC, 0xBF6B, 0x78ED, 0xEAAB, 0x78EF, 0xC146,\t0x78F2, 0xEDAA, 0x78F3, 0xEDA5, 0x78F4, 0xC145, 0x78F7, 0xC143,\r\n\t0x78F9, 0xEDAC, 0x78FA, 0xC144, 0x78FB, 0xEDA8, 0x78FC, 0xEDA9,\t0x78FD, 0xEDA6, 0x78FE, 0xEDAD, 0x78FF, 0xF056, 0x7901, 0xC147,\r\n\t0x7902, 0xEDA7, 0x7904, 0xEDAE, 0x7905, 0xEDAB, 0x7909, 0xF05A,\t0x790C, 0xF057, 0x790E, 0xC2A6, 0x7910, 0xF05B, 0x7911, 0xF05D,\r\n\t0x7912, 0xF05C, 0x7913, 0xF058, 0x7914, 0xF059, 0x7917, 0xF2A3,\t0x7919, 0xC3AA, 0x791B, 0xF27E, 0x791C, 0xF2A2, 0x791D, 0xF27D,\r\n\t0x791E, 0xF2A4, 0x7921, 0xF2A1, 0x7923, 0xF47A, 0x7924, 0xF47D,\t0x7925, 0xF479, 0x7926, 0xC471, 0x7927, 0xF47B, 0x7928, 0xF47C,\r\n\t0x7929, 0xF47E, 0x792A, 0xC472, 0x792B, 0xC474, 0x792C, 0xC473,\t0x792D, 0xF5E1, 0x792F, 0xF5E3, 0x7931, 0xF5E2, 0x7935, 0xF6F6,\r\n\t0x7938, 0xF8B5, 0x7939, 0xF8FA, 0x793A, 0xA5DC, 0x793D, 0xCB72,\t0x793E, 0xAAC0, 0x793F, 0xCDA3, 0x7940, 0xAAC1, 0x7941, 0xAAC2,\r\n\t0x7942, 0xCDA2, 0x7944, 0xCFF8, 0x7945, 0xCFF7, 0x7946, 0xACE6,\t0x7947, 0xACE9, 0x7948, 0xACE8, 0x7949, 0xACE7, 0x794A, 0xCFF4,\r\n\t0x794B, 0xCFF6, 0x794C, 0xCFF5, 0x794F, 0xD2E8, 0x7950, 0xAFA7,\t0x7951, 0xD2EC, 0x7952, 0xD2EB, 0x7953, 0xD2EA, 0x7954, 0xD2E6,\r\n\t0x7955, 0xAFA6, 0x7956, 0xAFAA, 0x7957, 0xAFAD, 0x795A, 0xAFAE,\t0x795B, 0xD2E7, 0x795C, 0xD2E9, 0x795D, 0xAFAC, 0x795E, 0xAFAB,\r\n\t0x795F, 0xAFA9, 0x7960, 0xAFA8, 0x7961, 0xD6C2, 0x7963, 0xD6C0,\t0x7964, 0xD6BC, 0x7965, 0xB2BB, 0x7967, 0xD6BD, 0x7968, 0xB2BC,\r\n\t0x7969, 0xD6BE, 0x796A, 0xD6BF, 0x796B, 0xD6C1, 0x796D, 0xB2BD,\t0x7970, 0xDAD5, 0x7972, 0xDAD4, 0x7973, 0xDAD3, 0x7974, 0xDAD2,\r\n\t0x7979, 0xDEF6, 0x797A, 0xB852, 0x797C, 0xDEF3, 0x797D, 0xDEF5,\t0x797F, 0xB853, 0x7981, 0xB854, 0x7982, 0xDEF4, 0x7988, 0xE341,\r\n\t0x798A, 0xE2F9, 0x798B, 0xE2FA, 0x798D, 0xBAD7, 0x798E, 0xBAD5,\t0x798F, 0xBAD6, 0x7990, 0xE343, 0x7992, 0xE342, 0x7993, 0xE2FE,\r\n\t0x7994, 0xE2FD, 0x7995, 0xE2FC, 0x7996, 0xE2FB, 0x7997, 0xE340,\t0x7998, 0xE2F8, 0x799A, 0xE6CB, 0x799B, 0xE6D0, 0x799C, 0xE6CE,\r\n\t0x79A0, 0xE6CD, 0x79A1, 0xE6CC, 0x79A2, 0xE6CF, 0x79A4, 0xEAAE,\t0x79A6, 0xBF6D, 0x79A7, 0xC148, 0x79A8, 0xEDB0, 0x79AA, 0xC149,\r\n\t0x79AB, 0xEDAF, 0x79AC, 0xF05F, 0x79AD, 0xF05E, 0x79AE, 0xC2A7,\t0x79B0, 0xF2A5, 0x79B1, 0xC3AB, 0x79B2, 0xF4A1, 0x79B3, 0xC5A1,\r\n\t0x79B4, 0xF6F7, 0x79B6, 0xF8B7, 0x79B7, 0xF8B6, 0x79B8, 0xC9A8,\t0x79B9, 0xACEA, 0x79BA, 0xACEB, 0x79BB, 0xD6C3, 0x79BD, 0xB856,\r\n\t0x79BE, 0xA5DD, 0x79BF, 0xA872, 0x79C0, 0xA871, 0x79C1, 0xA870,\t0x79C5, 0xCDA4, 0x79C8, 0xAAC4, 0x79C9, 0xAAC3, 0x79CB, 0xACEE,\r\n\t0x79CD, 0xCFFA, 0x79CE, 0xCFFD, 0x79CF, 0xCFFB, 0x79D1, 0xACEC,\t0x79D2, 0xACED, 0x79D5, 0xCFF9, 0x79D6, 0xCFFC, 0x79D8, 0xAFB5,\r\n\t0x79DC, 0xD2F3, 0x79DD, 0xD2F5, 0x79DE, 0xD2F4, 0x79DF, 0xAFB2,\t0x79E0, 0xD2EF, 0x79E3, 0xAFB0, 0x79E4, 0xAFAF, 0x79E6, 0xAFB3,\r\n\t0x79E7, 0xAFB1, 0x79E9, 0xAFB4, 0x79EA, 0xD2F2, 0x79EB, 0xD2ED,\t0x79EC, 0xD2EE, 0x79ED, 0xD2F1, 0x79EE, 0xD2F0, 0x79F6, 0xD6C6,\r\n\t0x79F7, 0xD6C7, 0x79F8, 0xD6C5, 0x79FA, 0xD6C4, 0x79FB, 0xB2BE,\t0x7A00, 0xB57D, 0x7A02, 0xDAD6, 0x7A03, 0xDAD8, 0x7A04, 0xDADA,\r\n\t0x7A05, 0xB57C, 0x7A08, 0xB57A, 0x7A0A, 0xDAD7, 0x7A0B, 0xB57B,\t0x7A0C, 0xDAD9, 0x7A0D, 0xB579, 0x7A10, 0xDF41, 0x7A11, 0xDEF7,\r\n\t0x7A12, 0xDEFA, 0x7A13, 0xDEFE, 0x7A14, 0xB85A, 0x7A15, 0xDEFC,\t0x7A17, 0xDEFB, 0x7A18, 0xDEF8, 0x7A19, 0xDEF9, 0x7A1A, 0xB858,\r\n\t0x7A1B, 0xDF40, 0x7A1C, 0xB857, 0x7A1E, 0xB85C, 0x7A1F, 0xB85B,\t0x7A20, 0xB859, 0x7A22, 0xDEFD, 0x7A26, 0xE349, 0x7A28, 0xE348,\r\n\t0x7A2B, 0xE344, 0x7A2E, 0xBAD8, 0x7A2F, 0xE347, 0x7A30, 0xE346,\t0x7A31, 0xBAD9, 0x7A37, 0xBD5E, 0x7A39, 0xE6D2, 0x7A3B, 0xBD5F,\r\n\t0x7A3C, 0xBD5B, 0x7A3D, 0xBD5D, 0x7A3F, 0xBD5A, 0x7A40, 0xBD5C,\t0x7A44, 0xEAAF, 0x7A46, 0xBF70, 0x7A47, 0xEAB1, 0x7A48, 0xEAB0,\r\n\t0x7A4A, 0xE345, 0x7A4B, 0xBF72, 0x7A4C, 0xBF71, 0x7A4D, 0xBF6E,\t0x7A4E, 0xBF6F, 0x7A54, 0xEDB5, 0x7A56, 0xEDB3, 0x7A57, 0xC14A,\r\n\t0x7A58, 0xEDB4, 0x7A5A, 0xEDB6, 0x7A5B, 0xEDB2, 0x7A5C, 0xEDB1,\t0x7A5F, 0xF060, 0x7A60, 0xC2AA, 0x7A61, 0xC2A8, 0x7A62, 0xC2A9,\r\n\t0x7A67, 0xF2A6, 0x7A68, 0xF2A7, 0x7A69, 0xC3AD, 0x7A6B, 0xC3AC,\t0x7A6C, 0xF4A3, 0x7A6D, 0xF4A4, 0x7A6E, 0xF4A2, 0x7A70, 0xF6F8,\r\n\t0x7A71, 0xF6F9, 0x7A74, 0xA5DE, 0x7A75, 0xCA48, 0x7A76, 0xA873,\t0x7A78, 0xCDA5, 0x7A79, 0xAAC6, 0x7A7A, 0xAAC5, 0x7A7B, 0xCDA6,\r\n\t0x7A7E, 0xD040, 0x7A7F, 0xACEF, 0x7A80, 0xCFFE, 0x7A81, 0xACF0,\t0x7A84, 0xAFB6, 0x7A85, 0xD2F8, 0x7A86, 0xD2F6, 0x7A87, 0xD2FC,\r\n\t0x7A88, 0xAFB7, 0x7A89, 0xD2F7, 0x7A8A, 0xD2FB, 0x7A8B, 0xD2F9,\t0x7A8C, 0xD2FA, 0x7A8F, 0xD6C8, 0x7A90, 0xD6CA, 0x7A92, 0xB2BF,\r\n\t0x7A94, 0xD6C9, 0x7A95, 0xB2C0, 0x7A96, 0xB5A2, 0x7A97, 0xB5A1,\t0x7A98, 0xB57E, 0x7A99, 0xDADB, 0x7A9E, 0xDF44, 0x7A9F, 0xB85D,\r\n\t0x7AA0, 0xB85E, 0x7AA2, 0xDF43, 0x7AA3, 0xDF42, 0x7AA8, 0xE34A,\t0x7AA9, 0xBADB, 0x7AAA, 0xBADA, 0x7AAB, 0xE34B, 0x7AAC, 0xE34C,\r\n\t0x7AAE, 0xBD61, 0x7AAF, 0xBD60, 0x7AB1, 0xEAB5, 0x7AB2, 0xE6D3,\t0x7AB3, 0xE6D5, 0x7AB4, 0xE6D4, 0x7AB5, 0xEAB4, 0x7AB6, 0xEAB2,\r\n\t0x7AB7, 0xEAB6, 0x7AB8, 0xEAB3, 0x7ABA, 0xBF73, 0x7ABE, 0xEDB7,\t0x7ABF, 0xC14B, 0x7AC0, 0xEDB8, 0x7AC1, 0xEDB9, 0x7AC4, 0xC2AB,\r\n\t0x7AC5, 0xC2AC, 0x7AC7, 0xC475, 0x7ACA, 0xC5D1, 0x7ACB, 0xA5DF,\t0x7AD1, 0xD041, 0x7AD8, 0xD2FD, 0x7AD9, 0xAFB8, 0x7ADF, 0xB3BA,\r\n\t0x7AE0, 0xB3B9, 0x7AE3, 0xB5A4, 0x7AE4, 0xDADD, 0x7AE5, 0xB5A3,\t0x7AE6, 0xDADC, 0x7AEB, 0xDF45, 0x7AED, 0xBADC, 0x7AEE, 0xE34D,\r\n\t0x7AEF, 0xBADD, 0x7AF6, 0xC476, 0x7AF7, 0xF4A5, 0x7AF9, 0xA6CB,\t0x7AFA, 0xAAC7, 0x7AFB, 0xCDA7, 0x7AFD, 0xACF2, 0x7AFF, 0xACF1,\r\n\t0x7B00, 0xD042, 0x7B01, 0xD043, 0x7B04, 0xD340, 0x7B05, 0xD342,\t0x7B06, 0xAFB9, 0x7B08, 0xD344, 0x7B09, 0xD347, 0x7B0A, 0xD345,\r\n\t0x7B0E, 0xD346, 0x7B0F, 0xD343, 0x7B10, 0xD2FE, 0x7B11, 0xAFBA,\t0x7B12, 0xD348, 0x7B13, 0xD341, 0x7B18, 0xD6D3, 0x7B19, 0xB2C6,\r\n\t0x7B1A, 0xD6DC, 0x7B1B, 0xB2C3, 0x7B1D, 0xD6D5, 0x7B1E, 0xB2C7,\t0x7B20, 0xB2C1, 0x7B22, 0xD6D0, 0x7B23, 0xD6DD, 0x7B24, 0xD6D1,\r\n\t0x7B25, 0xD6CE, 0x7B26, 0xB2C5, 0x7B28, 0xB2C2, 0x7B2A, 0xD6D4,\t0x7B2B, 0xD6D7, 0x7B2C, 0xB2C4, 0x7B2D, 0xD6D8, 0x7B2E, 0xB2C8,\r\n\t0x7B2F, 0xD6D9, 0x7B30, 0xD6CF, 0x7B31, 0xD6D6, 0x7B32, 0xD6DA,\t0x7B33, 0xD6D2, 0x7B34, 0xD6CD, 0x7B35, 0xD6CB, 0x7B38, 0xD6DB,\r\n\t0x7B3B, 0xDADF, 0x7B40, 0xDAE4, 0x7B44, 0xDAE0, 0x7B45, 0xDAE6,\t0x7B46, 0xB5A7, 0x7B47, 0xD6CC, 0x7B48, 0xDAE1, 0x7B49, 0xB5A5,\r\n\t0x7B4A, 0xDADE, 0x7B4B, 0xB5AC, 0x7B4C, 0xDAE2, 0x7B4D, 0xB5AB,\t0x7B4E, 0xDAE3, 0x7B4F, 0xB5AD, 0x7B50, 0xB5A8, 0x7B51, 0xB5AE,\r\n\t0x7B52, 0xB5A9, 0x7B54, 0xB5AA, 0x7B56, 0xB5A6, 0x7B58, 0xDAE5,\t0x7B60, 0xB861, 0x7B61, 0xDF50, 0x7B63, 0xDF53, 0x7B64, 0xDF47,\r\n\t0x7B65, 0xDF4C, 0x7B66, 0xDF46, 0x7B67, 0xB863, 0x7B69, 0xDF4A,\t0x7B6D, 0xDF48, 0x7B6E, 0xB862, 0x7B70, 0xDF4F, 0x7B71, 0xDF4E,\r\n\t0x7B72, 0xDF4B, 0x7B73, 0xDF4D, 0x7B74, 0xDF49, 0x7B75, 0xBAE1,\t0x7B76, 0xDF52, 0x7B77, 0xB85F, 0x7B78, 0xDF51, 0x7B82, 0xE35D,\r\n\t0x7B84, 0xBAE8, 0x7B85, 0xE358, 0x7B87, 0xBAE7, 0x7B88, 0xE34E,\t0x7B8A, 0xE350, 0x7B8B, 0xBAE0, 0x7B8C, 0xE355, 0x7B8D, 0xE354,\r\n\t0x7B8E, 0xE357, 0x7B8F, 0xBAE5, 0x7B90, 0xE352, 0x7B91, 0xE351,\t0x7B94, 0xBAE4, 0x7B95, 0xBADF, 0x7B96, 0xE353, 0x7B97, 0xBAE2,\r\n\t0x7B98, 0xE359, 0x7B99, 0xE35B, 0x7B9B, 0xE356, 0x7B9C, 0xE34F,\t0x7B9D, 0xBAE3, 0x7BA0, 0xBD69, 0x7BA1, 0xBADE, 0x7BA4, 0xE35C,\r\n\t0x7BAC, 0xE6D9, 0x7BAD, 0xBD62, 0x7BAF, 0xE6DB, 0x7BB1, 0xBD63,\t0x7BB4, 0xBD65, 0x7BB5, 0xE6DE, 0x7BB7, 0xE6D6, 0x7BB8, 0xBAE6,\r\n\t0x7BB9, 0xE6DC, 0x7BBE, 0xE6D8, 0x7BC0, 0xB860, 0x7BC1, 0xBD68,\t0x7BC4, 0xBD64, 0x7BC6, 0xBD66, 0x7BC7, 0xBD67, 0x7BC9, 0xBF76,\r\n\t0x7BCA, 0xE6DD, 0x7BCB, 0xE6D7, 0x7BCC, 0xBD6A, 0x7BCE, 0xE6DA,\t0x7BD4, 0xEAC0, 0x7BD5, 0xEABB, 0x7BD8, 0xEAC5, 0x7BD9, 0xBF74,\r\n\t0x7BDA, 0xEABD, 0x7BDB, 0xBF78, 0x7BDC, 0xEAC3, 0x7BDD, 0xEABA,\t0x7BDE, 0xEAB7, 0x7BDF, 0xEAC6, 0x7BE0, 0xC151, 0x7BE1, 0xBF79,\r\n\t0x7BE2, 0xEAC2, 0x7BE3, 0xEAB8, 0x7BE4, 0xBF77, 0x7BE5, 0xEABC,\t0x7BE6, 0xBF7B, 0x7BE7, 0xEAB9, 0x7BE8, 0xEABE, 0x7BE9, 0xBF7A,\r\n\t0x7BEA, 0xEAC1, 0x7BEB, 0xEAC4, 0x7BF0, 0xEDCB, 0x7BF1, 0xEDCC,\t0x7BF2, 0xEDBC, 0x7BF3, 0xEDC3, 0x7BF4, 0xEDC1, 0x7BF7, 0xC14F,\r\n\t0x7BF8, 0xEDC8, 0x7BF9, 0xEABF, 0x7BFB, 0xEDBF, 0x7BFD, 0xEDC9,\t0x7BFE, 0xC14E, 0x7BFF, 0xEDBE, 0x7C00, 0xEDBD, 0x7C01, 0xEDC7,\r\n\t0x7C02, 0xEDC4, 0x7C03, 0xEDC6, 0x7C05, 0xEDBA, 0x7C06, 0xEDCA,\t0x7C07, 0xC14C, 0x7C09, 0xEDC5, 0x7C0A, 0xEDCE, 0x7C0B, 0xEDC2,\r\n\t0x7C0C, 0xC150, 0x7C0D, 0xC14D, 0x7C0E, 0xEDC0, 0x7C0F, 0xEDBB,\t0x7C10, 0xEDCD, 0x7C11, 0xBF75, 0x7C19, 0xF063, 0x7C1C, 0xF061,\r\n\t0x7C1D, 0xF067, 0x7C1E, 0xC2B0, 0x7C1F, 0xF065, 0x7C20, 0xF064,\t0x7C21, 0xC2B2, 0x7C22, 0xF06A, 0x7C23, 0xC2B1, 0x7C25, 0xF06B,\r\n\t0x7C26, 0xF068, 0x7C27, 0xC2AE, 0x7C28, 0xF069, 0x7C29, 0xF062,\t0x7C2A, 0xC2AF, 0x7C2B, 0xC2AD, 0x7C2C, 0xF2AB, 0x7C2D, 0xF066,\r\n\t0x7C30, 0xF06C, 0x7C33, 0xF2A8, 0x7C37, 0xC3B2, 0x7C38, 0xC3B0,\t0x7C39, 0xF2AA, 0x7C3B, 0xF2AC, 0x7C3C, 0xF2A9, 0x7C3D, 0xC3B1,\r\n\t0x7C3E, 0xC3AE, 0x7C3F, 0xC3AF, 0x7C40, 0xC3B3, 0x7C43, 0xC478,\t0x7C45, 0xF4AA, 0x7C47, 0xF4A9, 0x7C48, 0xF4A7, 0x7C49, 0xF4A6,\r\n\t0x7C4A, 0xF4A8, 0x7C4C, 0xC477, 0x7C4D, 0xC479, 0x7C50, 0xC4F0,\t0x7C53, 0xF5E5, 0x7C54, 0xF5E4, 0x7C57, 0xF6FA, 0x7C59, 0xF6FC,\r\n\t0x7C5A, 0xF6FE, 0x7C5B, 0xF6FD, 0x7C5C, 0xF6FB, 0x7C5F, 0xC5A3,\t0x7C60, 0xC5A2, 0x7C63, 0xC5D3, 0x7C64, 0xC5D2, 0x7C65, 0xC5D4,\r\n\t0x7C66, 0xF7ED, 0x7C67, 0xF7EC, 0x7C69, 0xF8FB, 0x7C6A, 0xF8B8,\t0x7C6B, 0xF8FC, 0x7C6C, 0xC658, 0x7C6E, 0xC659, 0x7C6F, 0xF96D,\r\n\t0x7C72, 0xC67E, 0x7C73, 0xA6CC, 0x7C75, 0xCDA8, 0x7C78, 0xD045,\t0x7C79, 0xD046, 0x7C7A, 0xD044, 0x7C7D, 0xACF3, 0x7C7F, 0xD047,\r\n\t0x7C80, 0xD048, 0x7C81, 0xD049, 0x7C84, 0xD349, 0x7C85, 0xD34F,\t0x7C88, 0xD34D, 0x7C89, 0xAFBB, 0x7C8A, 0xD34B, 0x7C8C, 0xD34C,\r\n\t0x7C8D, 0xD34E, 0x7C91, 0xD34A, 0x7C92, 0xB2C9, 0x7C94, 0xD6DE,\t0x7C95, 0xB2CB, 0x7C96, 0xD6E0, 0x7C97, 0xB2CA, 0x7C98, 0xD6DF,\r\n\t0x7C9E, 0xDAE8, 0x7C9F, 0xB5AF, 0x7CA1, 0xDAEA, 0x7CA2, 0xDAE7,\t0x7CA3, 0xD6E1, 0x7CA5, 0xB5B0, 0x7CA7, 0xF9DB, 0x7CA8, 0xDAE9,\r\n\t0x7CAF, 0xDF56, 0x7CB1, 0xB864, 0x7CB2, 0xDF54, 0x7CB3, 0xB865,\t0x7CB4, 0xDF55, 0x7CB5, 0xB866, 0x7CB9, 0xBAE9, 0x7CBA, 0xE361,\r\n\t0x7CBB, 0xE35E, 0x7CBC, 0xE360, 0x7CBD, 0xBAEA, 0x7CBE, 0xBAEB,\t0x7CBF, 0xE35F, 0x7CC5, 0xE6DF, 0x7CC8, 0xE6E0, 0x7CCA, 0xBD6B,\r\n\t0x7CCB, 0xE6E2, 0x7CCC, 0xE6E1, 0x7CCE, 0xA261, 0x7CD0, 0xEACA,\t0x7CD1, 0xEACB, 0x7CD2, 0xEAC7, 0x7CD4, 0xEAC8, 0x7CD5, 0xBF7C,\r\n\t0x7CD6, 0xBF7D, 0x7CD7, 0xEAC9, 0x7CD9, 0xC157, 0x7CDC, 0xC153,\t0x7CDD, 0xC158, 0x7CDE, 0xC154, 0x7CDF, 0xC156, 0x7CE0, 0xC152,\r\n\t0x7CE2, 0xC155, 0x7CE7, 0xC2B3, 0x7CE8, 0xEDCF, 0x7CEA, 0xF2AE,\t0x7CEC, 0xF2AD, 0x7CEE, 0xF4AB, 0x7CEF, 0xC47A, 0x7CF0, 0xC47B,\r\n\t0x7CF1, 0xF741, 0x7CF2, 0xF5E6, 0x7CF4, 0xF740, 0x7CF6, 0xF8FD,\t0x7CF7, 0xF9A4, 0x7CF8, 0xA6CD, 0x7CFB, 0xA874, 0x7CFD, 0xCDA9,\r\n\t0x7CFE, 0xAAC8, 0x7D00, 0xACF6, 0x7D01, 0xD04C, 0x7D02, 0xACF4,\t0x7D03, 0xD04A, 0x7D04, 0xACF9, 0x7D05, 0xACF5, 0x7D06, 0xACFA,\r\n\t0x7D07, 0xACF8, 0x7D08, 0xD04B, 0x7D09, 0xACF7, 0x7D0A, 0xAFBF,\t0x7D0B, 0xAFBE, 0x7D0C, 0xD35A, 0x7D0D, 0xAFC7, 0x7D0E, 0xD353,\r\n\t0x7D0F, 0xD359, 0x7D10, 0xAFC3, 0x7D11, 0xD352, 0x7D12, 0xD358,\t0x7D13, 0xD356, 0x7D14, 0xAFC2, 0x7D15, 0xAFC4, 0x7D16, 0xD355,\r\n\t0x7D17, 0xAFBD, 0x7D18, 0xD354, 0x7D19, 0xAFC8, 0x7D1A, 0xAFC5,\t0x7D1B, 0xAFC9, 0x7D1C, 0xAFC6, 0x7D1D, 0xD351, 0x7D1E, 0xD350,\r\n\t0x7D1F, 0xD357, 0x7D20, 0xAFC0, 0x7D21, 0xAFBC, 0x7D22, 0xAFC1,\t0x7D28, 0xD6F0, 0x7D29, 0xD6E9, 0x7D2B, 0xB5B5, 0x7D2C, 0xD6E8,\r\n\t0x7D2E, 0xB2CF, 0x7D2F, 0xB2D6, 0x7D30, 0xB2D3, 0x7D31, 0xB2D9,\t0x7D32, 0xB2D8, 0x7D33, 0xB2D4, 0x7D35, 0xD6E2, 0x7D36, 0xD6E5,\r\n\t0x7D38, 0xD6E4, 0x7D39, 0xB2D0, 0x7D3A, 0xD6E6, 0x7D3B, 0xD6EF,\t0x7D3C, 0xB2D1, 0x7D3D, 0xD6E3, 0x7D3E, 0xD6EC, 0x7D3F, 0xD6ED,\r\n\t0x7D40, 0xB2D2, 0x7D41, 0xD6EA, 0x7D42, 0xB2D7, 0x7D43, 0xB2CD,\t0x7D44, 0xB2D5, 0x7D45, 0xD6E7, 0x7D46, 0xB2CC, 0x7D47, 0xD6EB,\r\n\t0x7D4A, 0xD6EE, 0x7D4E, 0xDAFB, 0x7D4F, 0xDAF2, 0x7D50, 0xB5B2,\t0x7D51, 0xDAF9, 0x7D52, 0xDAF6, 0x7D53, 0xDAEE, 0x7D54, 0xDAF7,\r\n\t0x7D55, 0xB5B4, 0x7D56, 0xDAEF, 0x7D58, 0xDAEB, 0x7D5B, 0xB86C,\t0x7D5C, 0xDAF4, 0x7D5E, 0xB5B1, 0x7D5F, 0xDAFA, 0x7D61, 0xB5B8,\r\n\t0x7D62, 0xB5BA, 0x7D63, 0xDAED, 0x7D66, 0xB5B9, 0x7D67, 0xDAF0,\t0x7D68, 0xB5B3, 0x7D69, 0xDAF8, 0x7D6A, 0xDAF1, 0x7D6B, 0xDAF5,\r\n\t0x7D6D, 0xDAF3, 0x7D6E, 0xB5B6, 0x7D6F, 0xDAEC, 0x7D70, 0xB5BB,\t0x7D71, 0xB2CE, 0x7D72, 0xB5B7, 0x7D73, 0xB5BC, 0x7D79, 0xB868,\r\n\t0x7D7A, 0xDF5D, 0x7D7B, 0xDF5F, 0x7D7C, 0xDF61, 0x7D7D, 0xDF65,\t0x7D7F, 0xDF5B, 0x7D80, 0xDF59, 0x7D81, 0xB86A, 0x7D83, 0xDF60,\r\n\t0x7D84, 0xDF64, 0x7D85, 0xDF5C, 0x7D86, 0xDF58, 0x7D88, 0xDF57,\t0x7D8C, 0xDF62, 0x7D8D, 0xDF5A, 0x7D8E, 0xDF5E, 0x7D8F, 0xB86B,\r\n\t0x7D91, 0xB869, 0x7D92, 0xDF66, 0x7D93, 0xB867, 0x7D94, 0xDF63,\t0x7D96, 0xE372, 0x7D9C, 0xBAEE, 0x7D9D, 0xE36A, 0x7D9E, 0xBD78,\r\n\t0x7D9F, 0xE374, 0x7DA0, 0xBAF1, 0x7DA1, 0xE378, 0x7DA2, 0xBAF7,\t0x7DA3, 0xE365, 0x7DA6, 0xE375, 0x7DA7, 0xE362, 0x7DA9, 0xE377,\r\n\t0x7DAA, 0xE366, 0x7DAC, 0xBAFE, 0x7DAD, 0xBAFB, 0x7DAE, 0xE376,\t0x7DAF, 0xE370, 0x7DB0, 0xBAED, 0x7DB1, 0xBAF5, 0x7DB2, 0xBAF4,\r\n\t0x7DB4, 0xBAF3, 0x7DB5, 0xBAF9, 0x7DB7, 0xE363, 0x7DB8, 0xBAFA,\t0x7DB9, 0xE371, 0x7DBA, 0xBAF6, 0x7DBB, 0xBAEC, 0x7DBC, 0xE373,\r\n\t0x7DBD, 0xBAEF, 0x7DBE, 0xBAF0, 0x7DBF, 0xBAF8, 0x7DC0, 0xE368,\t0x7DC1, 0xE367, 0x7DC2, 0xE364, 0x7DC4, 0xE36C, 0x7DC5, 0xE369,\r\n\t0x7DC6, 0xE36D, 0x7DC7, 0xBAFD, 0x7DC9, 0xE379, 0x7DCA, 0xBAF2,\t0x7DCB, 0xE36E, 0x7DCC, 0xE36F, 0x7DCE, 0xE36B, 0x7DD2, 0xBAFC,\r\n\t0x7DD7, 0xE6E7, 0x7DD8, 0xBD70, 0x7DD9, 0xBD79, 0x7DDA, 0xBD75,\t0x7DDB, 0xE6E4, 0x7DDD, 0xBD72, 0x7DDE, 0xBD76, 0x7DDF, 0xE6F0,\r\n\t0x7DE0, 0xBD6C, 0x7DE1, 0xE6E8, 0x7DE3, 0xBD74, 0x7DE6, 0xE6EB,\t0x7DE7, 0xE6E6, 0x7DE8, 0xBD73, 0x7DE9, 0xBD77, 0x7DEA, 0xE6E5,\r\n\t0x7DEC, 0xBD71, 0x7DEE, 0xE6EF, 0x7DEF, 0xBD6E, 0x7DF0, 0xE6EE,\t0x7DF1, 0xE6ED, 0x7DF2, 0xBD7A, 0x7DF3, 0xE572, 0x7DF4, 0xBD6D,\r\n\t0x7DF6, 0xE6EC, 0x7DF7, 0xE6E3, 0x7DF9, 0xBD7B, 0x7DFA, 0xE6EA,\t0x7DFB, 0xBD6F, 0x7E03, 0xE6E9, 0x7E08, 0xBFA2, 0x7E09, 0xBFA7,\r\n\t0x7E0A, 0xBF7E, 0x7E0B, 0xEAD8, 0x7E0C, 0xEACF, 0x7E0D, 0xEADB,\t0x7E0E, 0xEAD3, 0x7E0F, 0xEAD9, 0x7E10, 0xBFA8, 0x7E11, 0xBFA1,\r\n\t0x7E12, 0xEACC, 0x7E13, 0xEAD2, 0x7E14, 0xEADC, 0x7E15, 0xEAD5,\t0x7E16, 0xEADA, 0x7E17, 0xEACE, 0x7E1A, 0xEAD6, 0x7E1B, 0xBFA3,\r\n\t0x7E1C, 0xEAD4, 0x7E1D, 0xBFA6, 0x7E1E, 0xBFA5, 0x7E1F, 0xEAD0,\t0x7E20, 0xEAD1, 0x7E21, 0xEACD, 0x7E22, 0xEAD7, 0x7E23, 0xBFA4,\r\n\t0x7E24, 0xEADE, 0x7E25, 0xEADD, 0x7E29, 0xEDDA, 0x7E2A, 0xEDD6,\t0x7E2B, 0xC15F, 0x7E2D, 0xEDD0, 0x7E2E, 0xC159, 0x7E2F, 0xC169,\r\n\t0x7E30, 0xEDDC, 0x7E31, 0xC161, 0x7E32, 0xC15D, 0x7E33, 0xEDD3,\t0x7E34, 0xC164, 0x7E35, 0xC167, 0x7E36, 0xEDDE, 0x7E37, 0xC15C,\r\n\t0x7E38, 0xEDD5, 0x7E39, 0xC165, 0x7E3A, 0xEDE0, 0x7E3B, 0xEDDD,\t0x7E3C, 0xEDD1, 0x7E3D, 0xC160, 0x7E3E, 0xC15A, 0x7E3F, 0xC168,\r\n\t0x7E40, 0xEDD8, 0x7E41, 0xC163, 0x7E42, 0xEDD2, 0x7E43, 0xC15E,\t0x7E44, 0xEDDF, 0x7E45, 0xC162, 0x7E46, 0xC15B, 0x7E47, 0xEDD9,\r\n\t0x7E48, 0xC166, 0x7E49, 0xEDD7, 0x7E4C, 0xEDDB, 0x7E50, 0xF06E,\t0x7E51, 0xF074, 0x7E52, 0xC2B9, 0x7E53, 0xF077, 0x7E54, 0xC2B4,\r\n\t0x7E55, 0xC2B5, 0x7E56, 0xF06F, 0x7E57, 0xF076, 0x7E58, 0xF071,\t0x7E59, 0xC2BA, 0x7E5A, 0xC2B7, 0x7E5C, 0xF06D, 0x7E5E, 0xC2B6,\r\n\t0x7E5F, 0xF073, 0x7E60, 0xF075, 0x7E61, 0xC2B8, 0x7E62, 0xF072,\t0x7E63, 0xF070, 0x7E68, 0xF2B8, 0x7E69, 0xC3B7, 0x7E6A, 0xC3B8,\r\n\t0x7E6B, 0xC3B4, 0x7E6D, 0xC3B5, 0x7E6F, 0xF2B4, 0x7E70, 0xF2B2,\t0x7E72, 0xF2B6, 0x7E73, 0xC3BA, 0x7E74, 0xF2B7, 0x7E75, 0xF2B0,\r\n\t0x7E76, 0xF2AF, 0x7E77, 0xF2B3, 0x7E78, 0xF2B1, 0x7E79, 0xC3B6,\t0x7E7A, 0xF2B5, 0x7E7B, 0xF4AC, 0x7E7C, 0xC47E, 0x7E7D, 0xC47D,\r\n\t0x7E7E, 0xF4AD, 0x7E80, 0xF4AF, 0x7E81, 0xF4AE, 0x7E82, 0xC4A1,\t0x7E86, 0xF5EB, 0x7E87, 0xF5E8, 0x7E88, 0xF5E9, 0x7E8A, 0xF5E7,\r\n\t0x7E8B, 0xF5EA, 0x7E8C, 0xC4F2, 0x7E8D, 0xF5EC, 0x7E8F, 0xC4F1,\t0x7E91, 0xF742, 0x7E93, 0xC5D5, 0x7E94, 0xC5D7, 0x7E95, 0xF7EE,\r\n\t0x7E96, 0xC5D6, 0x7E97, 0xF8B9, 0x7E98, 0xF940, 0x7E99, 0xF942,\t0x7E9A, 0xF8FE, 0x7E9B, 0xF941, 0x7E9C, 0xC66C, 0x7F36, 0xA6CE,\r\n\t0x7F38, 0xACFB, 0x7F39, 0xD26F, 0x7F3A, 0xAFCA, 0x7F3D, 0xB2DA,\t0x7F3E, 0xDAFC, 0x7F3F, 0xDAFD, 0x7F43, 0xEADF, 0x7F44, 0xC16A,\r\n\t0x7F45, 0xEDE1, 0x7F48, 0xC2BB, 0x7F4A, 0xF2BA, 0x7F4B, 0xF2B9,\t0x7F4C, 0xC4A2, 0x7F4D, 0xF5ED, 0x7F4F, 0xF743, 0x7F50, 0xC5F8,\r\n\t0x7F51, 0xCA49, 0x7F54, 0xAAC9, 0x7F55, 0xA875, 0x7F58, 0xD04D,\t0x7F5B, 0xD360, 0x7F5C, 0xD35B, 0x7F5D, 0xD35F, 0x7F5E, 0xD35D,\r\n\t0x7F5F, 0xAFCB, 0x7F60, 0xD35E, 0x7F61, 0xD35C, 0x7F63, 0xD6F1,\t0x7F65, 0xDAFE, 0x7F66, 0xDB40, 0x7F67, 0xDF69, 0x7F68, 0xDF6A,\r\n\t0x7F69, 0xB86E, 0x7F6A, 0xB86F, 0x7F6B, 0xDF68, 0x7F6C, 0xDF6B,\t0x7F6D, 0xDF67, 0x7F6E, 0xB86D, 0x7F70, 0xBB40, 0x7F72, 0xB870,\r\n\t0x7F73, 0xE37A, 0x7F75, 0xBD7C, 0x7F76, 0xE6F1, 0x7F77, 0xBD7D,\t0x7F79, 0xBFA9, 0x7F7A, 0xEAE2, 0x7F7B, 0xEAE0, 0x7F7C, 0xEAE1,\r\n\t0x7F7D, 0xEDE4, 0x7F7E, 0xEDE3, 0x7F7F, 0xEDE2, 0x7F83, 0xF2BB,\t0x7F85, 0xC3B9, 0x7F86, 0xF2BC, 0x7F87, 0xF744, 0x7F88, 0xC5F9,\r\n\t0x7F89, 0xF8BA, 0x7F8A, 0xA6CF, 0x7F8B, 0xAACB, 0x7F8C, 0xAACA,\t0x7F8D, 0xD04F, 0x7F8E, 0xACFC, 0x7F91, 0xD04E, 0x7F92, 0xD362,\r\n\t0x7F94, 0xAFCC, 0x7F95, 0xD6F2, 0x7F96, 0xD361, 0x7F9A, 0xB2DC,\t0x7F9B, 0xD6F5, 0x7F9C, 0xD6F3, 0x7F9D, 0xD6F4, 0x7F9E, 0xB2DB,\r\n\t0x7FA0, 0xDB42, 0x7FA1, 0xDB43, 0x7FA2, 0xDB41, 0x7FA4, 0xB873,\t0x7FA5, 0xDF6D, 0x7FA6, 0xDF6C, 0x7FA7, 0xDF6E, 0x7FA8, 0xB872,\r\n\t0x7FA9, 0xB871, 0x7FAC, 0xE6F2, 0x7FAD, 0xE6F4, 0x7FAF, 0xBD7E,\t0x7FB0, 0xE6F3, 0x7FB1, 0xEAE3, 0x7FB2, 0xBFAA, 0x7FB3, 0xF079,\r\n\t0x7FB5, 0xF078, 0x7FB6, 0xC3BB, 0x7FB7, 0xF2BD, 0x7FB8, 0xC3BD,\t0x7FB9, 0xC3BC, 0x7FBA, 0xF4B0, 0x7FBB, 0xF5EE, 0x7FBC, 0xC4F3,\r\n\t0x7FBD, 0xA6D0, 0x7FBE, 0xD050, 0x7FBF, 0xACFD, 0x7FC0, 0xD365,\t0x7FC1, 0xAFCE, 0x7FC2, 0xD364, 0x7FC3, 0xD363, 0x7FC5, 0xAFCD,\r\n\t0x7FC7, 0xD6FB, 0x7FC9, 0xD6FD, 0x7FCA, 0xD6F6, 0x7FCB, 0xD6F7,\t0x7FCC, 0xB2DD, 0x7FCD, 0xD6F8, 0x7FCE, 0xB2DE, 0x7FCF, 0xD6FC,\r\n\t0x7FD0, 0xD6F9, 0x7FD1, 0xD6FA, 0x7FD2, 0xB2DF, 0x7FD4, 0xB5BE,\t0x7FD5, 0xB5BF, 0x7FD7, 0xDB44, 0x7FDB, 0xDF6F, 0x7FDC, 0xDF70,\r\n\t0x7FDE, 0xE37E, 0x7FDF, 0xBB43, 0x7FE0, 0xBB41, 0x7FE1, 0xBB42,\t0x7FE2, 0xE37B, 0x7FE3, 0xE37C, 0x7FE5, 0xE37D, 0x7FE6, 0xE6F9,\r\n\t0x7FE8, 0xE6FA, 0x7FE9, 0xBDA1, 0x7FEA, 0xE6F7, 0x7FEB, 0xE6F6,\t0x7FEC, 0xE6F8, 0x7FED, 0xE6F5, 0x7FEE, 0xBFAD, 0x7FEF, 0xEAE4,\r\n\t0x7FF0, 0xBFAB, 0x7FF1, 0xBFAC, 0x7FF2, 0xEDE6, 0x7FF3, 0xC16B,\t0x7FF4, 0xEDE5, 0x7FF5, 0xEFA8, 0x7FF7, 0xF07A, 0x7FF8, 0xF07B,\r\n\t0x7FF9, 0xC2BC, 0x7FFB, 0xC2BD, 0x7FFC, 0xC16C, 0x7FFD, 0xF2BE,\t0x7FFE, 0xF2BF, 0x7FFF, 0xF4B1, 0x8000, 0xC4A3, 0x8001, 0xA6D1,\r\n\t0x8003, 0xA6D2, 0x8004, 0xACFE, 0x8005, 0xAACC, 0x8006, 0xAFCF,\t0x8007, 0xD051, 0x800B, 0xB5C0, 0x800C, 0xA6D3, 0x800D, 0xAD41,\r\n\t0x800E, 0xD052, 0x800F, 0xD053, 0x8010, 0xAD40, 0x8011, 0xAD42,\t0x8012, 0xA6D4, 0x8014, 0xD054, 0x8015, 0xAFD1, 0x8016, 0xD366,\r\n\t0x8017, 0xAFD3, 0x8018, 0xAFD0, 0x8019, 0xAFD2, 0x801B, 0xD741,\t0x801C, 0xB2E0, 0x801E, 0xD740, 0x801F, 0xD6FE, 0x8021, 0xDF71,\r\n\t0x8024, 0xE3A1, 0x8026, 0xBDA2, 0x8028, 0xBFAE, 0x8029, 0xEAE6,\t0x802A, 0xEAE5, 0x802C, 0xEDE7, 0x8030, 0xF5EF, 0x8033, 0xA6D5,\r\n\t0x8034, 0xCB73, 0x8035, 0xCDAA, 0x8036, 0xAD43, 0x8037, 0xD055,\t0x8039, 0xD368, 0x803D, 0xAFD4, 0x803E, 0xD367, 0x803F, 0xAFD5,\r\n\t0x8043, 0xD743, 0x8046, 0xB2E2, 0x8047, 0xD742, 0x8048, 0xD744,\t0x804A, 0xB2E1, 0x804F, 0xDB46, 0x8050, 0xDB47, 0x8051, 0xDB45,\r\n\t0x8052, 0xB5C1, 0x8056, 0xB874, 0x8058, 0xB875, 0x805A, 0xBB45,\t0x805C, 0xE3A3, 0x805D, 0xE3A2, 0x805E, 0xBB44, 0x8064, 0xE6FB,\r\n\t0x8067, 0xE6FC, 0x806C, 0xEAE7, 0x806F, 0xC170, 0x8070, 0xC16F,\t0x8071, 0xC16D, 0x8072, 0xC16E, 0x8073, 0xC171, 0x8075, 0xF07C,\r\n\t0x8076, 0xC2BF, 0x8077, 0xC2BE, 0x8078, 0xF2C0, 0x8079, 0xF4B2,\t0x807D, 0xC5A5, 0x807E, 0xC5A4, 0x807F, 0xA6D6, 0x8082, 0xD1FB,\r\n\t0x8084, 0xB877, 0x8085, 0xB5C2, 0x8086, 0xB876, 0x8087, 0xBB46,\t0x8089, 0xA6D7, 0x808A, 0xC9A9, 0x808B, 0xA6D8, 0x808C, 0xA6D9,\r\n\t0x808F, 0xCDAB, 0x8090, 0xCB76, 0x8092, 0xCB77, 0x8093, 0xA877,\t0x8095, 0xCB74, 0x8096, 0xA876, 0x8098, 0xA879, 0x8099, 0xCB75,\r\n\t0x809A, 0xA87B, 0x809B, 0xA87A, 0x809C, 0xCB78, 0x809D, 0xA878,\t0x80A1, 0xAAD1, 0x80A2, 0xAACF, 0x80A3, 0xCDAD, 0x80A5, 0xAACE,\r\n\t0x80A9, 0xAAD3, 0x80AA, 0xAAD5, 0x80AB, 0xAAD2, 0x80AD, 0xCDB0,\t0x80AE, 0xCDAC, 0x80AF, 0xAAD6, 0x80B1, 0xAAD0, 0x80B2, 0xA87C,\r\n\t0x80B4, 0xAAD4, 0x80B5, 0xCDAF, 0x80B8, 0xCDAE, 0x80BA, 0xAACD,\t0x80C2, 0xD05B, 0x80C3, 0xAD47, 0x80C4, 0xAD48, 0x80C5, 0xD05D,\r\n\t0x80C7, 0xD057, 0x80C8, 0xD05A, 0x80C9, 0xD063, 0x80CA, 0xD061,\t0x80CC, 0xAD49, 0x80CD, 0xD067, 0x80CE, 0xAD4C, 0x80CF, 0xD064,\r\n\t0x80D0, 0xD05C, 0x80D1, 0xD059, 0x80D4, 0xDB49, 0x80D5, 0xD062,\t0x80D6, 0xAD44, 0x80D7, 0xD065, 0x80D8, 0xD056, 0x80D9, 0xD05F,\r\n\t0x80DA, 0xAD46, 0x80DB, 0xAD4B, 0x80DC, 0xD060, 0x80DD, 0xAD4F,\t0x80DE, 0xAD4D, 0x80E0, 0xD058, 0x80E1, 0xAD4A, 0x80E3, 0xD05E,\r\n\t0x80E4, 0xAD4E, 0x80E5, 0xAD45, 0x80E6, 0xD066, 0x80ED, 0xAFDA,\t0x80EF, 0xAFE3, 0x80F0, 0xAFD8, 0x80F1, 0xAFD6, 0x80F2, 0xD36A,\r\n\t0x80F3, 0xAFDE, 0x80F4, 0xAFDB, 0x80F5, 0xD36C, 0x80F8, 0xAFDD,\t0x80F9, 0xD36B, 0x80FA, 0xD369, 0x80FB, 0xD36E, 0x80FC, 0xAFE2,\r\n\t0x80FD, 0xAFE0, 0x80FE, 0xDB48, 0x8100, 0xD36F, 0x8101, 0xD36D,\t0x8102, 0xAFD7, 0x8105, 0xAFD9, 0x8106, 0xAFDC, 0x8108, 0xAFDF,\r\n\t0x810A, 0xAFE1, 0x8115, 0xD74E, 0x8116, 0xB2E4, 0x8118, 0xD745,\t0x8119, 0xD747, 0x811B, 0xD748, 0x811D, 0xD750, 0x811E, 0xD74C,\r\n\t0x811F, 0xD74A, 0x8121, 0xD74D, 0x8122, 0xD751, 0x8123, 0xB2E5,\t0x8124, 0xB2E9, 0x8125, 0xD746, 0x8127, 0xD74F, 0x8129, 0xB2E7,\r\n\t0x812B, 0xB2E6, 0x812C, 0xD74B, 0x812D, 0xD749, 0x812F, 0xB2E3,\t0x8130, 0xB2E8, 0x8139, 0xB5C8, 0x813A, 0xDB51, 0x813D, 0xDB4F,\r\n\t0x813E, 0xB5CA, 0x8143, 0xDB4A, 0x8144, 0xDFA1, 0x8146, 0xB5C9,\t0x8147, 0xDB4E, 0x814A, 0xDB4B, 0x814B, 0xB5C5, 0x814C, 0xB5CB,\r\n\t0x814D, 0xDB50, 0x814E, 0xB5C7, 0x814F, 0xDB4D, 0x8150, 0xBB47,\t0x8151, 0xB5C6, 0x8152, 0xDB4C, 0x8153, 0xB5CC, 0x8154, 0xB5C4,\r\n\t0x8155, 0xB5C3, 0x815B, 0xDF77, 0x815C, 0xDF75, 0x815E, 0xDF7B,\t0x8160, 0xDF73, 0x8161, 0xDFA2, 0x8162, 0xDF78, 0x8164, 0xDF72,\r\n\t0x8165, 0xB87B, 0x8166, 0xB8A3, 0x8167, 0xDF7D, 0x8169, 0xDF76,\t0x816B, 0xB87E, 0x816E, 0xB87C, 0x816F, 0xDF7E, 0x8170, 0xB879,\r\n\t0x8171, 0xB878, 0x8172, 0xDF79, 0x8173, 0xB87D, 0x8174, 0xB5CD,\t0x8176, 0xDF7C, 0x8177, 0xDF74, 0x8178, 0xB87A, 0x8179, 0xB8A1,\r\n\t0x817A, 0xB8A2, 0x817F, 0xBB4C, 0x8180, 0xBB48, 0x8182, 0xBB4D,\t0x8183, 0xE3A6, 0x8186, 0xE3A5, 0x8187, 0xE3A7, 0x8188, 0xBB4A,\r\n\t0x8189, 0xE3A4, 0x818A, 0xBB4B, 0x818B, 0xE3AA, 0x818C, 0xE3A9,\t0x818D, 0xE3A8, 0x818F, 0xBB49, 0x8195, 0xE741, 0x8197, 0xE744,\r\n\t0x8198, 0xBDA8, 0x8199, 0xE743, 0x819A, 0xBDA7, 0x819B, 0xBDA3,\t0x819C, 0xBDA4, 0x819D, 0xBDA5, 0x819E, 0xE740, 0x819F, 0xE6FE,\r\n\t0x81A0, 0xBDA6, 0x81A2, 0xE742, 0x81A3, 0xE6FD, 0x81A6, 0xEAE9,\t0x81A7, 0xEAF3, 0x81A8, 0xBFB1, 0x81A9, 0xBFB0, 0x81AB, 0xEAED,\r\n\t0x81AC, 0xEAEF, 0x81AE, 0xEAEA, 0x81B0, 0xEAEE, 0x81B1, 0xEAE8,\t0x81B2, 0xEAF1, 0x81B3, 0xBFAF, 0x81B4, 0xEAF0, 0x81B5, 0xEAEC,\r\n\t0x81B7, 0xEAF2, 0x81B9, 0xEAEB, 0x81BA, 0xC174, 0x81BB, 0xEDE8,\t0x81BC, 0xEDEE, 0x81BD, 0xC178, 0x81BE, 0xC17A, 0x81BF, 0xC177,\r\n\t0x81C0, 0xC176, 0x81C2, 0xC175, 0x81C3, 0xC173, 0x81C4, 0xEDE9,\t0x81C5, 0xEDEC, 0x81C6, 0xC172, 0x81C7, 0xEDED, 0x81C9, 0xC179,\r\n\t0x81CA, 0xEDEB, 0x81CC, 0xEDEA, 0x81CD, 0xC2C0, 0x81CF, 0xC2C1,\t0x81D0, 0xF0A1, 0x81D1, 0xF07D, 0x81D2, 0xF07E, 0x81D5, 0xF2C2,\r\n\t0x81D7, 0xF2C1, 0x81D8, 0xC3BE, 0x81D9, 0xF4B4, 0x81DA, 0xC4A4,\t0x81DB, 0xF4B3, 0x81DD, 0xF5F0, 0x81DE, 0xF745, 0x81DF, 0xC5A6,\r\n\t0x81E0, 0xF943, 0x81E1, 0xF944, 0x81E2, 0xC5D8, 0x81E3, 0xA6DA,\t0x81E5, 0xAAD7, 0x81E6, 0xDB52, 0x81E7, 0xBB4E, 0x81E8, 0xC17B,\r\n\t0x81E9, 0xEDEF, 0x81EA, 0xA6DB, 0x81EC, 0xAFE5, 0x81ED, 0xAFE4,\t0x81EE, 0xDB53, 0x81F2, 0xEAF4, 0x81F3, 0xA6DC, 0x81F4, 0xAD50,\r\n\t0x81F7, 0xDB54, 0x81F8, 0xDB55, 0x81F9, 0xDB56, 0x81FA, 0xBB4F,\t0x81FB, 0xBFB2, 0x81FC, 0xA6DD, 0x81FE, 0xAAD8, 0x81FF, 0xD068,\r\n\t0x8200, 0xAFE6, 0x8201, 0xD370, 0x8202, 0xB2EA, 0x8204, 0xDB57,\t0x8205, 0xB8A4, 0x8207, 0xBB50, 0x8208, 0xBFB3, 0x8209, 0xC17C,\r\n\t0x820A, 0xC2C2, 0x820B, 0xF4B5, 0x820C, 0xA6DE, 0x820D, 0xAAD9,\t0x8210, 0xAFE7, 0x8211, 0xD752, 0x8212, 0xB5CE, 0x8214, 0xBB51,\r\n\t0x8215, 0xE3AB, 0x8216, 0xE745, 0x821B, 0xA6DF, 0x821C, 0xB5CF,\t0x821D, 0xDFA3, 0x821E, 0xBB52, 0x821F, 0xA6E0, 0x8220, 0xCDB1,\r\n\t0x8221, 0xD069, 0x8222, 0xAD51, 0x8225, 0xD372, 0x8228, 0xAFEA,\t0x822A, 0xAFE8, 0x822B, 0xAFE9, 0x822C, 0xAFEB, 0x822F, 0xD371,\r\n\t0x8232, 0xD757, 0x8233, 0xD754, 0x8234, 0xD756, 0x8235, 0xB2EB,\t0x8236, 0xB2ED, 0x8237, 0xB2EC, 0x8238, 0xD753, 0x8239, 0xB2EE,\r\n\t0x823A, 0xD755, 0x823C, 0xDB58, 0x823D, 0xDB59, 0x823F, 0xDB5A,\t0x8240, 0xDFA6, 0x8242, 0xDFA7, 0x8244, 0xDFA5, 0x8245, 0xDFA8,\r\n\t0x8247, 0xB8A5, 0x8249, 0xDFA4, 0x824B, 0xBB53, 0x824E, 0xE74A,\t0x824F, 0xE746, 0x8250, 0xE749, 0x8251, 0xE74B, 0x8252, 0xE748,\r\n\t0x8253, 0xE747, 0x8255, 0xEAF5, 0x8256, 0xEAF6, 0x8257, 0xEAF7,\t0x8258, 0xBFB4, 0x8259, 0xBFB5, 0x825A, 0xEDF1, 0x825B, 0xEDF0,\r\n\t0x825C, 0xEDF2, 0x825E, 0xF0A3, 0x825F, 0xF0A2, 0x8261, 0xF2C4,\t0x8263, 0xF2C5, 0x8264, 0xF2C3, 0x8266, 0xC4A5, 0x8268, 0xF4B6,\r\n\t0x8269, 0xF4B7, 0x826B, 0xF746, 0x826C, 0xF7EF, 0x826D, 0xF8BB,\t0x826E, 0xA6E1, 0x826F, 0xA87D, 0x8271, 0xC17D, 0x8272, 0xA6E2,\r\n\t0x8274, 0xD758, 0x8275, 0xDB5B, 0x8277, 0xC641, 0x8278, 0xCA4A,\t0x827C, 0xCA4B, 0x827D, 0xCA4D, 0x827E, 0xA6E3, 0x827F, 0xCA4E,\r\n\t0x8280, 0xCA4C, 0x8283, 0xCBA2, 0x8284, 0xCBA3, 0x8285, 0xCB7B,\t0x828A, 0xCBA1, 0x828B, 0xA8A1, 0x828D, 0xA8A2, 0x828E, 0xCB7C,\r\n\t0x828F, 0xCB7A, 0x8290, 0xCB79, 0x8291, 0xCB7D, 0x8292, 0xA87E,\t0x8293, 0xCB7E, 0x8294, 0xD06A, 0x8298, 0xCDB6, 0x8299, 0xAADC,\r\n\t0x829A, 0xCDB5, 0x829B, 0xCDB7, 0x829D, 0xAADB, 0x829E, 0xCDBC,\t0x829F, 0xAADF, 0x82A0, 0xCDB2, 0x82A1, 0xCDC0, 0x82A2, 0xCDC6,\r\n\t0x82A3, 0xAAE6, 0x82A4, 0xCDC3, 0x82A5, 0xAAE3, 0x82A7, 0xCDB9,\t0x82A8, 0xCDBF, 0x82A9, 0xCDC1, 0x82AB, 0xCDB4, 0x82AC, 0xAAE2,\r\n\t0x82AD, 0xAADD, 0x82AE, 0xCDBA, 0x82AF, 0xAAE4, 0x82B0, 0xAAE7,\t0x82B1, 0xAAE1, 0x82B3, 0xAADA, 0x82B4, 0xCDBE, 0x82B5, 0xCDB8,\r\n\t0x82B6, 0xCDC5, 0x82B7, 0xAAE9, 0x82B8, 0xAAE5, 0x82B9, 0xAAE0,\t0x82BA, 0xCDBD, 0x82BB, 0xAFEC, 0x82BC, 0xCDBB, 0x82BD, 0xAADE,\r\n\t0x82BE, 0xAAE8, 0x82C0, 0xCDB3, 0x82C2, 0xCDC2, 0x82C3, 0xCDC4,\t0x82D1, 0xAD62, 0x82D2, 0xAD5C, 0x82D3, 0xAD64, 0x82D4, 0xAD61,\r\n\t0x82D5, 0xD071, 0x82D6, 0xD074, 0x82D7, 0xAD5D, 0x82D9, 0xD06B,\t0x82DB, 0xAD56, 0x82DC, 0xAD60, 0x82DE, 0xAD63, 0x82DF, 0xAD65,\r\n\t0x82E0, 0xD0A2, 0x82E1, 0xD077, 0x82E3, 0xAD55, 0x82E4, 0xD0A1,\t0x82E5, 0xAD59, 0x82E6, 0xAD57, 0x82E7, 0xAD52, 0x82E8, 0xD06F,\r\n\t0x82EA, 0xD07E, 0x82EB, 0xD073, 0x82EC, 0xD076, 0x82ED, 0xD0A5,\t0x82EF, 0xAD66, 0x82F0, 0xD07D, 0x82F1, 0xAD5E, 0x82F2, 0xD078,\r\n\t0x82F3, 0xD0A4, 0x82F4, 0xD075, 0x82F5, 0xD079, 0x82F6, 0xD07C,\t0x82F9, 0xD06D, 0x82FA, 0xD0A3, 0x82FB, 0xD07B, 0x82FE, 0xD06C,\r\n\t0x8300, 0xD070, 0x8301, 0xAD5F, 0x8302, 0xAD5A, 0x8303, 0xAD53,\t0x8304, 0xAD58, 0x8305, 0xAD54, 0x8306, 0xAD67, 0x8307, 0xD06E,\r\n\t0x8308, 0xD3A5, 0x8309, 0xAD5B, 0x830C, 0xD07A, 0x830D, 0xCE41,\t0x8316, 0xD3A8, 0x8317, 0xAFFA, 0x8319, 0xD376, 0x831B, 0xD3A3,\r\n\t0x831C, 0xD37D, 0x831E, 0xD3B2, 0x8320, 0xD3AA, 0x8322, 0xD37E,\t0x8324, 0xD3A9, 0x8325, 0xD378, 0x8326, 0xD37C, 0x8327, 0xD3B5,\r\n\t0x8328, 0xAFFD, 0x8329, 0xD3AD, 0x832A, 0xD3A4, 0x832B, 0xAFED,\t0x832C, 0xD3B3, 0x832D, 0xD374, 0x832F, 0xD3AC, 0x8331, 0xAFFC,\r\n\t0x8332, 0xAFF7, 0x8333, 0xD373, 0x8334, 0xAFF5, 0x8335, 0xAFF4,\t0x8336, 0xAFF9, 0x8337, 0xD3AB, 0x8338, 0xAFF1, 0x8339, 0xAFF8,\r\n\t0x833A, 0xD072, 0x833B, 0xDB5C, 0x833C, 0xD3A6, 0x833F, 0xD37A,\t0x8340, 0xAFFB, 0x8341, 0xD37B, 0x8342, 0xD3A1, 0x8343, 0xAFFE,\r\n\t0x8344, 0xD375, 0x8345, 0xD3AF, 0x8347, 0xD3AE, 0x8348, 0xD3B6,\t0x8349, 0xAFF3, 0x834A, 0xAFF0, 0x834B, 0xD3B4, 0x834C, 0xD3B0,\r\n\t0x834D, 0xD3A7, 0x834E, 0xD3A2, 0x834F, 0xAFF6, 0x8350, 0xAFF2,\t0x8351, 0xD377, 0x8352, 0xAFEE, 0x8353, 0xD3B1, 0x8354, 0xAFEF,\r\n\t0x8356, 0xD379, 0x8373, 0xD75E, 0x8374, 0xD760, 0x8375, 0xD765,\t0x8376, 0xD779, 0x8377, 0xB2FC, 0x8378, 0xB2F2, 0x837A, 0xD75D,\r\n\t0x837B, 0xB2FD, 0x837C, 0xB2FE, 0x837D, 0xD768, 0x837E, 0xD76F,\t0x837F, 0xD775, 0x8381, 0xD762, 0x8383, 0xD769, 0x8386, 0xB340,\r\n\t0x8387, 0xD777, 0x8388, 0xD772, 0x8389, 0xB2FA, 0x838A, 0xB2F8,\t0x838B, 0xD76E, 0x838C, 0xD76A, 0x838D, 0xD75C, 0x838E, 0xB2EF,\r\n\t0x838F, 0xD761, 0x8390, 0xD759, 0x8392, 0xB2F7, 0x8393, 0xB2F9,\t0x8394, 0xD766, 0x8395, 0xD763, 0x8396, 0xB2F4, 0x8397, 0xD773,\r\n\t0x8398, 0xB2F1, 0x8399, 0xD764, 0x839A, 0xD77A, 0x839B, 0xD76C,\t0x839D, 0xD76B, 0x839E, 0xB2F0, 0x83A0, 0xB2FB, 0x83A2, 0xB2F3,\r\n\t0x83A3, 0xD75A, 0x83A4, 0xD75F, 0x83A5, 0xD770, 0x83A6, 0xD776,\t0x83A7, 0xB341, 0x83A8, 0xD75B, 0x83A9, 0xD767, 0x83AA, 0xD76D,\r\n\t0x83AB, 0xB2F6, 0x83AE, 0xD778, 0x83AF, 0xD771, 0x83B0, 0xD774,\t0x83BD, 0xB2F5, 0x83BF, 0xDB6C, 0x83C0, 0xDB60, 0x83C1, 0xB5D7,\r\n\t0x83C2, 0xDB7D, 0x83C3, 0xDBA7, 0x83C4, 0xDBAA, 0x83C5, 0xB5D5,\t0x83C6, 0xDB68, 0x83C7, 0xDBA3, 0x83C8, 0xDB69, 0x83C9, 0xDB77,\r\n\t0x83CA, 0xB5E2, 0x83CB, 0xDB73, 0x83CC, 0xB5DF, 0x83CE, 0xDB74,\t0x83CF, 0xDB5D, 0x83D1, 0xDBA4, 0x83D4, 0xB5E8, 0x83D5, 0xDBA1,\r\n\t0x83D6, 0xDB75, 0x83D7, 0xDBAC, 0x83D8, 0xDB70, 0x83D9, 0xDFC8,\t0x83DB, 0xDBAF, 0x83DC, 0xB5E6, 0x83DD, 0xDB6E, 0x83DE, 0xDB7A,\r\n\t0x83DF, 0xB5E9, 0x83E0, 0xB5D4, 0x83E1, 0xDB72, 0x83E2, 0xDBAD,\t0x83E3, 0xDB6B, 0x83E4, 0xDB64, 0x83E5, 0xDB6F, 0x83E7, 0xDB63,\r\n\t0x83E8, 0xDB61, 0x83E9, 0xB5D0, 0x83EA, 0xDBA5, 0x83EB, 0xDB6A,\t0x83EC, 0xDBA8, 0x83EE, 0xDBA9, 0x83EF, 0xB5D8, 0x83F0, 0xB5DD,\r\n\t0x83F1, 0xB5D9, 0x83F2, 0xB5E1, 0x83F3, 0xDB7E, 0x83F4, 0xB5DA,\t0x83F5, 0xDB76, 0x83F6, 0xDB66, 0x83F8, 0xB5D2, 0x83F9, 0xDB5E,\r\n\t0x83FA, 0xDBA2, 0x83FB, 0xDBAB, 0x83FC, 0xDB65, 0x83FD, 0xB5E0,\t0x83FE, 0xDBB0, 0x83FF, 0xDB71, 0x8401, 0xDB6D, 0x8403, 0xB5D1,\r\n\t0x8404, 0xB5E5, 0x8406, 0xDB7C, 0x8407, 0xB5E7, 0x8409, 0xDB78,\t0x840A, 0xB5DC, 0x840B, 0xB5D6, 0x840C, 0xB5DE, 0x840D, 0xB5D3,\r\n\t0x840E, 0xB5E4, 0x840F, 0xDB79, 0x8410, 0xDB67, 0x8411, 0xDB7B,\t0x8412, 0xDB62, 0x8413, 0xDBA6, 0x841B, 0xDBAE, 0x8423, 0xDB5F,\r\n\t0x8429, 0xDFC7, 0x842B, 0xDFDD, 0x842C, 0xB855, 0x842D, 0xDFCC,\t0x842F, 0xDFCA, 0x8430, 0xDFB5, 0x8431, 0xB8A9, 0x8432, 0xDFC5,\r\n\t0x8433, 0xDFD9, 0x8434, 0xDFC1, 0x8435, 0xB8B1, 0x8436, 0xDFD8,\t0x8437, 0xDFBF, 0x8438, 0xB5E3, 0x8439, 0xDFCF, 0x843A, 0xDFC0,\r\n\t0x843B, 0xDFD6, 0x843C, 0xB8B0, 0x843D, 0xB8A8, 0x843F, 0xDFAA,\t0x8440, 0xDFB2, 0x8442, 0xDFCB, 0x8443, 0xDFC3, 0x8444, 0xDFDC,\r\n\t0x8445, 0xDFC6, 0x8446, 0xB8B6, 0x8447, 0xDFD7, 0x8449, 0xB8AD,\t0x844B, 0xDFC9, 0x844C, 0xDFD1, 0x844D, 0xDFB6, 0x844E, 0xDFD0,\r\n\t0x8450, 0xDFE1, 0x8451, 0xDFB1, 0x8452, 0xDFD2, 0x8454, 0xDFDF,\t0x8456, 0xDFAB, 0x8457, 0xB5DB, 0x8459, 0xDFB9, 0x845A, 0xDFB8,\r\n\t0x845B, 0xB8AF, 0x845D, 0xDFBC, 0x845E, 0xDFBE, 0x845F, 0xDFCD,\t0x8460, 0xDFDE, 0x8461, 0xB8B2, 0x8463, 0xB8B3, 0x8465, 0xDFB0,\r\n\t0x8466, 0xB8AB, 0x8467, 0xDFB4, 0x8468, 0xDFDA, 0x8469, 0xB8B4,\t0x846B, 0xB8AC, 0x846C, 0xB8AE, 0x846D, 0xB8B5, 0x846E, 0xDFE0,\r\n\t0x846F, 0xDFD3, 0x8470, 0xDFCE, 0x8473, 0xDFBB, 0x8474, 0xDFBA,\t0x8475, 0xB8AA, 0x8476, 0xDFAC, 0x8477, 0xB8A7, 0x8478, 0xDFC4,\r\n\t0x8479, 0xDFAD, 0x847A, 0xDFC2, 0x847D, 0xDFB7, 0x847E, 0xDFDB,\t0x8482, 0xB8A6, 0x8486, 0xDFB3, 0x848D, 0xDFAF, 0x848E, 0xDFD5,\r\n\t0x848F, 0xDFAE, 0x8490, 0xBB60, 0x8491, 0xE3D3, 0x8494, 0xE3C2,\t0x8497, 0xE3AC, 0x8498, 0xE3CA, 0x8499, 0xBB58, 0x849A, 0xE3BB,\r\n\t0x849B, 0xE3C5, 0x849C, 0xBB5B, 0x849D, 0xE3BE, 0x849E, 0xBB59,\t0x849F, 0xE3AF, 0x84A0, 0xE3CD, 0x84A1, 0xE3AE, 0x84A2, 0xE3C1,\r\n\t0x84A4, 0xE3AD, 0x84A7, 0xE3BF, 0x84A8, 0xE3C8, 0x84A9, 0xE3C6,\t0x84AA, 0xE3BA, 0x84AB, 0xE3B5, 0x84AC, 0xE3B3, 0x84AE, 0xE3B4,\r\n\t0x84AF, 0xE3C7, 0x84B0, 0xE3D2, 0x84B1, 0xE3BC, 0x84B2, 0xBB5A,\t0x84B4, 0xE3B7, 0x84B6, 0xE3CB, 0x84B8, 0xBB5D, 0x84B9, 0xE3B6,\r\n\t0x84BA, 0xE3B0, 0x84BB, 0xE3C0, 0x84BC, 0xBB61, 0x84BF, 0xBB55,\t0x84C0, 0xBB5E, 0x84C1, 0xE3B8, 0x84C2, 0xE3B2, 0x84C4, 0xBB57,\r\n\t0x84C5, 0xDFD4, 0x84C6, 0xBB56, 0x84C7, 0xE3C3, 0x84C9, 0xBB54,\t0x84CA, 0xBB63, 0x84CB, 0xBB5C, 0x84CC, 0xE3C4, 0x84CD, 0xE3B9,\r\n\t0x84CE, 0xE3B1, 0x84CF, 0xE3CC, 0x84D0, 0xE3BD, 0x84D1, 0xBB62,\t0x84D2, 0xE3D0, 0x84D3, 0xBB5F, 0x84D4, 0xE3CF, 0x84D6, 0xE3C9,\r\n\t0x84D7, 0xE3CE, 0x84DB, 0xE3D1, 0x84E7, 0xE773, 0x84E8, 0xE774,\t0x84E9, 0xE767, 0x84EA, 0xE766, 0x84EB, 0xE762, 0x84EC, 0xBDB4,\r\n\t0x84EE, 0xBDAC, 0x84EF, 0xE776, 0x84F0, 0xE775, 0x84F1, 0xDFA9,\t0x84F2, 0xE75F, 0x84F3, 0xE763, 0x84F4, 0xE75D, 0x84F6, 0xE770,\r\n\t0x84F7, 0xE761, 0x84F9, 0xE777, 0x84FA, 0xE75A, 0x84FB, 0xE758,\t0x84FC, 0xE764, 0x84FD, 0xE76E, 0x84FE, 0xE769, 0x84FF, 0xBDB6,\r\n\t0x8500, 0xE74F, 0x8502, 0xE76D, 0x8506, 0xBDB7, 0x8507, 0xDFBD,\t0x8508, 0xE75B, 0x8509, 0xE752, 0x850A, 0xE755, 0x850B, 0xE77B,\r\n\t0x850C, 0xE75C, 0x850D, 0xE753, 0x850E, 0xE751, 0x850F, 0xE74E,\t0x8511, 0xBDB0, 0x8512, 0xE765, 0x8513, 0xBDAF, 0x8514, 0xBDB3,\r\n\t0x8515, 0xE760, 0x8516, 0xE768, 0x8517, 0xBDA9, 0x8518, 0xE778,\t0x8519, 0xE77C, 0x851A, 0xBDAB, 0x851C, 0xE757, 0x851D, 0xE76B,\r\n\t0x851E, 0xE76F, 0x851F, 0xE754, 0x8520, 0xE779, 0x8521, 0xBDB2,\t0x8523, 0xBDB1, 0x8524, 0xE74C, 0x8525, 0xBDB5, 0x8526, 0xE772,\r\n\t0x8527, 0xE756, 0x8528, 0xE76A, 0x8529, 0xE750, 0x852A, 0xE75E,\t0x852B, 0xE759, 0x852C, 0xBDAD, 0x852D, 0xBDAE, 0x852E, 0xE76C,\r\n\t0x852F, 0xE77D, 0x8530, 0xE77A, 0x8531, 0xE771, 0x853B, 0xE74D,\t0x853D, 0xBDAA, 0x853E, 0xEB49, 0x8540, 0xEB40, 0x8541, 0xEB43,\r\n\t0x8543, 0xBFBB, 0x8544, 0xEB45, 0x8545, 0xEAF9, 0x8546, 0xEB41,\t0x8547, 0xEB47, 0x8548, 0xBFB8, 0x8549, 0xBFBC, 0x854A, 0xBFB6,\r\n\t0x854D, 0xEAFB, 0x854E, 0xEB4C, 0x8551, 0xEB46, 0x8553, 0xEAFC,\t0x8554, 0xEB55, 0x8555, 0xEB4F, 0x8556, 0xEAF8, 0x8557, 0xEE46,\r\n\t0x8558, 0xEAFE, 0x8559, 0xBFB7, 0x855B, 0xEB4A, 0x855D, 0xEB54,\t0x855E, 0xBFBF, 0x8560, 0xEB51, 0x8561, 0xEAFD, 0x8562, 0xEB44,\r\n\t0x8563, 0xEB48, 0x8564, 0xEB42, 0x8565, 0xEB56, 0x8566, 0xEB53,\t0x8567, 0xEB50, 0x8568, 0xBFB9, 0x8569, 0xBFBA, 0x856A, 0xBFBE,\r\n\t0x856B, 0xEAFA, 0x856C, 0xEB57, 0x856D, 0xBFBD, 0x856E, 0xEB4D,\t0x8571, 0xEB4B, 0x8575, 0xEB4E, 0x8576, 0xEE53, 0x8577, 0xEE40,\r\n\t0x8578, 0xEE45, 0x8579, 0xEE52, 0x857A, 0xEE44, 0x857B, 0xEDFB,\t0x857C, 0xEE41, 0x857E, 0xC1A2, 0x8580, 0xEDF4, 0x8581, 0xEE4D,\r\n\t0x8582, 0xEE4F, 0x8583, 0xEDF3, 0x8584, 0xC1A1, 0x8585, 0xEE51,\t0x8586, 0xEE49, 0x8587, 0xC1A8, 0x8588, 0xEE50, 0x8589, 0xEE42,\r\n\t0x858A, 0xC1AA, 0x858B, 0xEDF9, 0x858C, 0xEB52, 0x858D, 0xEE4A,\t0x858E, 0xEE47, 0x858F, 0xEDF5, 0x8590, 0xEE55, 0x8591, 0xC1A4,\r\n\t0x8594, 0xC1A5, 0x8595, 0xEDF7, 0x8596, 0xEE48, 0x8598, 0xEE54,\t0x8599, 0xEE4B, 0x859A, 0xEDFD, 0x859B, 0xC1A7, 0x859C, 0xC1A3,\r\n\t0x859D, 0xEE4C, 0x859E, 0xEDFE, 0x859F, 0xEE56, 0x85A0, 0xEDF8,\t0x85A1, 0xEE43, 0x85A2, 0xEE4E, 0x85A3, 0xEDFA, 0x85A4, 0xEDFC,\r\n\t0x85A6, 0xC2CB, 0x85A7, 0xEDF6, 0x85A8, 0xC1A9, 0x85A9, 0xC2C4,\t0x85AA, 0xC17E, 0x85AF, 0xC1A6, 0x85B0, 0xC2C8, 0x85B1, 0xF0B3,\r\n\t0x85B3, 0xF0A9, 0x85B4, 0xF0A4, 0x85B5, 0xF0AA, 0x85B6, 0xF0B4,\t0x85B7, 0xF0B8, 0x85B8, 0xF0B7, 0x85B9, 0xC2CA, 0x85BA, 0xC2C9,\r\n\t0x85BD, 0xF0AB, 0x85BE, 0xF0B9, 0x85BF, 0xF0AE, 0x85C0, 0xF0A6,\t0x85C2, 0xF0A8, 0x85C3, 0xF0A7, 0x85C4, 0xF0AD, 0x85C5, 0xF0B2,\r\n\t0x85C6, 0xF0A5, 0x85C7, 0xF0AC, 0x85C8, 0xF0B1, 0x85C9, 0xC2C7,\t0x85CB, 0xF0AF, 0x85CD, 0xC2C5, 0x85CE, 0xF0B0, 0x85CF, 0xC2C3,\r\n\t0x85D0, 0xC2C6, 0x85D1, 0xF2D5, 0x85D2, 0xF0B5, 0x85D5, 0xC3C2,\t0x85D7, 0xF2CD, 0x85D8, 0xF2D1, 0x85D9, 0xF2C9, 0x85DA, 0xF2CC,\r\n\t0x85DC, 0xF2D4, 0x85DD, 0xC3C0, 0x85DE, 0xF2D9, 0x85DF, 0xF2D2,\t0x85E1, 0xF2CA, 0x85E2, 0xF2DA, 0x85E3, 0xF2D3, 0x85E4, 0xC3C3,\r\n\t0x85E5, 0xC3C4, 0x85E6, 0xF2D7, 0x85E8, 0xF2CB, 0x85E9, 0xC3BF,\t0x85EA, 0xC3C1, 0x85EB, 0xF2C6, 0x85EC, 0xF2CE, 0x85ED, 0xF2C8,\r\n\t0x85EF, 0xF2D8, 0x85F0, 0xF2D6, 0x85F1, 0xF2C7, 0x85F2, 0xF2CF,\t0x85F6, 0xF4BE, 0x85F7, 0xC3C5, 0x85F8, 0xF2D0, 0x85F9, 0xC4A7,\r\n\t0x85FA, 0xC4A9, 0x85FB, 0xC4A6, 0x85FD, 0xF4C3, 0x85FE, 0xF4BB,\t0x85FF, 0xF4B9, 0x8600, 0xF4BD, 0x8601, 0xF4BA, 0x8604, 0xF4BF,\r\n\t0x8605, 0xF4C1, 0x8606, 0xC4AA, 0x8607, 0xC4AC, 0x8609, 0xF4C0,\t0x860A, 0xC4AD, 0x860B, 0xC4AB, 0x860C, 0xF4C2, 0x8611, 0xC4A8,\r\n\t0x8617, 0xC4F4, 0x8618, 0xF5F1, 0x8619, 0xF5F7, 0x861A, 0xC4F6,\t0x861B, 0xF4BC, 0x861C, 0xF5F6, 0x861E, 0xF5FD, 0x861F, 0xF5F4,\r\n\t0x8620, 0xF5FB, 0x8621, 0xF5FA, 0x8622, 0xF4B8, 0x8623, 0xF5F5,\t0x8624, 0xF0B6, 0x8625, 0xF5FE, 0x8626, 0xF5F3, 0x8627, 0xF5F8,\r\n\t0x8629, 0xF5FC, 0x862A, 0xF5F2, 0x862C, 0xF74A, 0x862D, 0xC4F5,\t0x862E, 0xF5F9, 0x8631, 0xF7F4, 0x8632, 0xF74B, 0x8633, 0xF749,\r\n\t0x8634, 0xF747, 0x8635, 0xF748, 0x8636, 0xF74C, 0x8638, 0xC5D9,\t0x8639, 0xF7F2, 0x863A, 0xF7F0, 0x863B, 0xF7F5, 0x863C, 0xF7F3,\r\n\t0x863E, 0xF7F6, 0x863F, 0xC5DA, 0x8640, 0xF7F1, 0x8643, 0xF8BC,\t0x8646, 0xF945, 0x8647, 0xF946, 0x8648, 0xF947, 0x864B, 0xF9C7,\r\n\t0x864C, 0xF9BD, 0x864D, 0xCA4F, 0x864E, 0xAAEA, 0x8650, 0xAD68,\t0x8652, 0xD3B8, 0x8653, 0xD3B7, 0x8654, 0xB040, 0x8655, 0xB342,\r\n\t0x8656, 0xD77C, 0x8659, 0xD77B, 0x865B, 0xB5EA, 0x865C, 0xB8B8,\t0x865E, 0xB8B7, 0x865F, 0xB8B9, 0x8661, 0xE3D4, 0x8662, 0xE77E,\r\n\t0x8663, 0xEB58, 0x8664, 0xEB5A, 0x8665, 0xEB59, 0x8667, 0xC1AB,\t0x8668, 0xEE57, 0x8669, 0xF0BA, 0x866A, 0xF9A5, 0x866B, 0xA6E4,\r\n\t0x866D, 0xCDC9, 0x866E, 0xCDCA, 0x866F, 0xCDC8, 0x8670, 0xCDC7,\t0x8671, 0xAAEB, 0x8673, 0xD0A9, 0x8674, 0xD0A7, 0x8677, 0xD0A6,\r\n\t0x8679, 0xAD69, 0x867A, 0xAD6B, 0x867B, 0xAD6A, 0x867C, 0xD0A8,\t0x8685, 0xD3C4, 0x8686, 0xD3C1, 0x8687, 0xD3BF, 0x868A, 0xB041,\r\n\t0x868B, 0xD3C2, 0x868C, 0xB046, 0x868D, 0xD3BC, 0x868E, 0xD3CB,\t0x8690, 0xD3CD, 0x8691, 0xD3BD, 0x8693, 0xB043, 0x8694, 0xD3CE,\r\n\t0x8695, 0xD3C9, 0x8696, 0xD3BB, 0x8697, 0xD3C0, 0x8698, 0xD3CA,\t0x8699, 0xD3C6, 0x869A, 0xD3C3, 0x869C, 0xB048, 0x869D, 0xD3CC,\r\n\t0x869E, 0xD3BE, 0x86A1, 0xD3C7, 0x86A2, 0xD3B9, 0x86A3, 0xB047,\t0x86A4, 0xB044, 0x86A5, 0xD3C5, 0x86A7, 0xD3C8, 0x86A8, 0xD3BA,\r\n\t0x86A9, 0xB045, 0x86AA, 0xB042, 0x86AF, 0xB34C, 0x86B0, 0xD7A5,\t0x86B1, 0xB34B, 0x86B3, 0xD7A8, 0x86B4, 0xD7AB, 0x86B5, 0xB348,\r\n\t0x86B6, 0xB346, 0x86B7, 0xD77E, 0x86B8, 0xD7A9, 0x86B9, 0xD7A7,\t0x86BA, 0xD7A4, 0x86BB, 0xD7AC, 0x86BC, 0xD7AD, 0x86BD, 0xD7AF,\r\n\t0x86BE, 0xD7B0, 0x86BF, 0xD77D, 0x86C0, 0xB345, 0x86C1, 0xD7A2,\t0x86C2, 0xD7A1, 0x86C3, 0xD7AE, 0x86C4, 0xB347, 0x86C5, 0xD7A3,\r\n\t0x86C6, 0xB349, 0x86C7, 0xB344, 0x86C8, 0xD7A6, 0x86C9, 0xB34D,\t0x86CB, 0xB34A, 0x86CC, 0xD7AA, 0x86D0, 0xB5F1, 0x86D1, 0xDBBF,\r\n\t0x86D3, 0xDBB4, 0x86D4, 0xB5EE, 0x86D6, 0xDFE7, 0x86D7, 0xDBBD,\t0x86D8, 0xDBB1, 0x86D9, 0xB5EC, 0x86DA, 0xDBB6, 0x86DB, 0xB5EF,\r\n\t0x86DC, 0xDBBA, 0x86DD, 0xDBB8, 0x86DE, 0xB5F2, 0x86DF, 0xB5EB,\t0x86E2, 0xDBB2, 0x86E3, 0xDBB5, 0x86E4, 0xB5F0, 0x86E6, 0xDBB3,\r\n\t0x86E8, 0xDBBE, 0x86E9, 0xDBBC, 0x86EA, 0xDBB7, 0x86EB, 0xDBB9,\t0x86EC, 0xDBBB, 0x86ED, 0xB5ED, 0x86F5, 0xDFE8, 0x86F6, 0xDFEE,\r\n\t0x86F7, 0xDFE4, 0x86F8, 0xDFEA, 0x86F9, 0xB8BA, 0x86FA, 0xDFE6,\t0x86FB, 0xB8C0, 0x86FE, 0xB8BF, 0x8700, 0xB8BE, 0x8701, 0xDFED,\r\n\t0x8702, 0xB8C1, 0x8703, 0xB8C2, 0x8704, 0xDFE3, 0x8705, 0xDFF0,\t0x8706, 0xB8C3, 0x8707, 0xB8BD, 0x8708, 0xB8BC, 0x8709, 0xDFEC,\r\n\t0x870A, 0xB8C4, 0x870B, 0xDFE2, 0x870C, 0xDFE5, 0x870D, 0xDFEF,\t0x870E, 0xDFEB, 0x8711, 0xE3F4, 0x8712, 0xE3E9, 0x8713, 0xB8BB,\r\n\t0x8718, 0xBB6A, 0x8719, 0xE3DD, 0x871A, 0xE3F2, 0x871B, 0xE3DE,\t0x871C, 0xBB65, 0x871E, 0xE3DB, 0x8720, 0xE3E4, 0x8721, 0xE3DC,\r\n\t0x8722, 0xBB67, 0x8723, 0xE3D6, 0x8724, 0xE3F1, 0x8725, 0xBB68,\t0x8726, 0xE3EE, 0x8727, 0xE3EF, 0x8728, 0xE3D7, 0x8729, 0xBB6D,\r\n\t0x872A, 0xE3E6, 0x872C, 0xE3E0, 0x872D, 0xE3E7, 0x872E, 0xE3DA,\t0x8730, 0xE3F3, 0x8731, 0xE3EB, 0x8732, 0xE3E5, 0x8733, 0xE3D5,\r\n\t0x8734, 0xBB69, 0x8735, 0xE3EC, 0x8737, 0xBB6C, 0x8738, 0xE3F0,\t0x873A, 0xE3EA, 0x873B, 0xBB66, 0x873C, 0xE3E8, 0x873E, 0xE3E2,\r\n\t0x873F, 0xBB64, 0x8740, 0xE3D9, 0x8741, 0xE3E1, 0x8742, 0xE3ED,\t0x8743, 0xE3DF, 0x8746, 0xE3E3, 0x874C, 0xBDC1, 0x874D, 0xDFE9,\r\n\t0x874E, 0xE7B2, 0x874F, 0xE7BB, 0x8750, 0xE7B1, 0x8751, 0xE7AD,\t0x8752, 0xE7AA, 0x8753, 0xBDC2, 0x8754, 0xE7A8, 0x8755, 0xBB6B,\r\n\t0x8756, 0xE7A1, 0x8757, 0xBDC0, 0x8758, 0xE7A7, 0x8759, 0xBDBF,\t0x875A, 0xE7AC, 0x875B, 0xE7A9, 0x875C, 0xE7B9, 0x875D, 0xE7B4,\r\n\t0x875E, 0xE7AE, 0x875F, 0xE7B3, 0x8760, 0xBDBB, 0x8761, 0xE7AB,\t0x8762, 0xE7BE, 0x8763, 0xE7A2, 0x8764, 0xE7A3, 0x8765, 0xE7BA,\r\n\t0x8766, 0xBDBC, 0x8767, 0xE7BF, 0x8768, 0xBDBE, 0x8769, 0xE7C0,\t0x876A, 0xE7B0, 0x876B, 0xE3D8, 0x876C, 0xE7B6, 0x876D, 0xE7AF,\r\n\t0x876E, 0xE7B8, 0x876F, 0xE7B5, 0x8773, 0xE7A6, 0x8774, 0xBDB9,\t0x8775, 0xE7BD, 0x8776, 0xBDBA, 0x8777, 0xE7A4, 0x8778, 0xBDBD,\r\n\t0x8779, 0xEB64, 0x877A, 0xE7B7, 0x877B, 0xE7BC, 0x8781, 0xEB61,\t0x8782, 0xBDB8, 0x8783, 0xBFC0, 0x8784, 0xEB6B, 0x8785, 0xEB67,\r\n\t0x8787, 0xEB65, 0x8788, 0xEB60, 0x8789, 0xEB6F, 0x878D, 0xBFC4,\t0x878F, 0xEB5C, 0x8790, 0xEB68, 0x8791, 0xEB69, 0x8792, 0xEB5F,\r\n\t0x8793, 0xEB5E, 0x8794, 0xEB6C, 0x8796, 0xEB62, 0x8797, 0xEB5D,\t0x8798, 0xEB63, 0x879A, 0xEB6E, 0x879B, 0xEB5B, 0x879C, 0xEB6D,\r\n\t0x879D, 0xEB6A, 0x879E, 0xBFC2, 0x879F, 0xBFC1, 0x87A2, 0xBFC3,\t0x87A3, 0xEB66, 0x87A4, 0xF0CB, 0x87AA, 0xEE59, 0x87AB, 0xC1B1,\r\n\t0x87AC, 0xEE5D, 0x87AD, 0xEE5A, 0x87AE, 0xEE61, 0x87AF, 0xEE67,\t0x87B0, 0xEE5C, 0x87B2, 0xEE70, 0x87B3, 0xC1AE, 0x87B4, 0xEE6A,\r\n\t0x87B5, 0xEE5F, 0x87B6, 0xEE6B, 0x87B7, 0xEE66, 0x87B8, 0xEE6D,\t0x87B9, 0xEE5E, 0x87BA, 0xC1B3, 0x87BB, 0xC1B2, 0x87BC, 0xEE60,\r\n\t0x87BD, 0xEE6E, 0x87BE, 0xEE58, 0x87BF, 0xEE6C, 0x87C0, 0xC1AC,\t0x87C2, 0xEE64, 0x87C3, 0xEE63, 0x87C4, 0xEE68, 0x87C5, 0xEE5B,\r\n\t0x87C6, 0xC1B0, 0x87C8, 0xC1B4, 0x87C9, 0xEE62, 0x87CA, 0xEE69,\t0x87CB, 0xC1B5, 0x87CC, 0xEE65, 0x87D1, 0xC1AD, 0x87D2, 0xC1AF,\r\n\t0x87D3, 0xF0C7, 0x87D4, 0xF0C5, 0x87D7, 0xF0CC, 0x87D8, 0xF0C9,\t0x87D9, 0xF0CD, 0x87DB, 0xF0BE, 0x87DC, 0xF0C6, 0x87DD, 0xF0D1,\r\n\t0x87DE, 0xEE6F, 0x87DF, 0xF0C2, 0x87E0, 0xC2CF, 0x87E1, 0xE7A5,\t0x87E2, 0xF0BD, 0x87E3, 0xF0CA, 0x87E4, 0xF0C4, 0x87E5, 0xF0C1,\r\n\t0x87E6, 0xF0BC, 0x87E7, 0xF0BB, 0x87E8, 0xF0D0, 0x87EA, 0xF0C0,\t0x87EB, 0xF0BF, 0x87EC, 0xC2CD, 0x87ED, 0xF0C8, 0x87EF, 0xC2CC,\r\n\t0x87F2, 0xC2CE, 0x87F3, 0xF0C3, 0x87F4, 0xF0CF, 0x87F6, 0xF2DE,\t0x87F7, 0xF2DF, 0x87F9, 0xC3C9, 0x87FA, 0xF2DC, 0x87FB, 0xC3C6,\r\n\t0x87FC, 0xF2E4, 0x87FE, 0xC3CA, 0x87FF, 0xF2E6, 0x8800, 0xF2DB,\t0x8801, 0xF0CE, 0x8802, 0xF2E8, 0x8803, 0xF2DD, 0x8805, 0xC3C7,\r\n\t0x8806, 0xF2E3, 0x8808, 0xF2E5, 0x8809, 0xF2E0, 0x880A, 0xF2E7,\t0x880B, 0xF2E2, 0x880C, 0xF2E1, 0x880D, 0xC3C8, 0x8810, 0xF4C5,\r\n\t0x8811, 0xF4C6, 0x8813, 0xF4C8, 0x8814, 0xC4AE, 0x8815, 0xC4AF,\t0x8816, 0xF4C9, 0x8817, 0xF4C7, 0x8819, 0xF4C4, 0x881B, 0xF642,\r\n\t0x881C, 0xF645, 0x881D, 0xF641, 0x881F, 0xC4FA, 0x8820, 0xF643,\t0x8821, 0xC4F9, 0x8822, 0xC4F8, 0x8823, 0xC4F7, 0x8824, 0xF644,\r\n\t0x8825, 0xF751, 0x8826, 0xF74F, 0x8828, 0xF74E, 0x8829, 0xF640,\t0x882A, 0xF750, 0x882B, 0xF646, 0x882C, 0xF74D, 0x882E, 0xF7F9,\r\n\t0x882F, 0xF7D7, 0x8830, 0xF7F7, 0x8831, 0xC5DB, 0x8832, 0xF7F8,\t0x8833, 0xF7FA, 0x8835, 0xF8BF, 0x8836, 0xC5FA, 0x8837, 0xF8BE,\r\n\t0x8838, 0xF8BD, 0x8839, 0xC5FB, 0x883B, 0xC65A, 0x883C, 0xF96E,\t0x883D, 0xF9A7, 0x883E, 0xF9A6, 0x883F, 0xF9A8, 0x8840, 0xA6E5,\r\n\t0x8841, 0xD0AA, 0x8843, 0xD3CF, 0x8844, 0xD3D0, 0x8848, 0xDBC0,\t0x884A, 0xF647, 0x884B, 0xF8C0, 0x884C, 0xA6E6, 0x884D, 0xAD6C,\r\n\t0x884E, 0xD0AB, 0x8852, 0xD7B1, 0x8853, 0xB34E, 0x8855, 0xDBC2,\t0x8856, 0xDBC1, 0x8857, 0xB5F3, 0x8859, 0xB8C5, 0x885A, 0xE7C1,\r\n\t0x885B, 0xBDC3, 0x885D, 0xBDC4, 0x8861, 0xBFC5, 0x8862, 0xC5FC,\t0x8863, 0xA6E7, 0x8867, 0xD0AC, 0x8868, 0xAAED, 0x8869, 0xD0AE,\r\n\t0x886A, 0xD0AD, 0x886B, 0xAD6D, 0x886D, 0xD3D1, 0x886F, 0xD3D8,\t0x8870, 0xB049, 0x8871, 0xD3D6, 0x8872, 0xD3D4, 0x8874, 0xD3DB,\r\n\t0x8875, 0xD3D2, 0x8876, 0xD3D3, 0x8877, 0xB04A, 0x8879, 0xB04E,\t0x887C, 0xD3DC, 0x887D, 0xB04D, 0x887E, 0xD3DA, 0x887F, 0xD3D7,\r\n\t0x8880, 0xD3D5, 0x8881, 0xB04B, 0x8882, 0xB04C, 0x8883, 0xD3D9,\t0x8888, 0xB350, 0x8889, 0xD7B2, 0x888B, 0xB355, 0x888C, 0xD7C2,\r\n\t0x888D, 0xB354, 0x888E, 0xD7C4, 0x8891, 0xD7B8, 0x8892, 0xB352,\t0x8893, 0xD7C3, 0x8895, 0xD7B3, 0x8896, 0xB353, 0x8897, 0xD7BF,\r\n\t0x8898, 0xD7BB, 0x8899, 0xD7BD, 0x889A, 0xD7B7, 0x889B, 0xD7BE,\t0x889E, 0xB34F, 0x889F, 0xD7BA, 0x88A1, 0xD7B9, 0x88A2, 0xD7B5,\r\n\t0x88A4, 0xD7C0, 0x88A7, 0xD7BC, 0x88A8, 0xD7B4, 0x88AA, 0xD7B6,\t0x88AB, 0xB351, 0x88AC, 0xD7C1, 0x88B1, 0xB5F6, 0x88B2, 0xDBCD,\r\n\t0x88B6, 0xDBC9, 0x88B7, 0xDBCB, 0x88B8, 0xDBC6, 0x88B9, 0xDBC5,\t0x88BA, 0xDBC3, 0x88BC, 0xDBCA, 0x88BD, 0xDBCC, 0x88BE, 0xDBC8,\r\n\t0x88C0, 0xDBC7, 0x88C1, 0xB5F4, 0x88C2, 0xB5F5, 0x88C9, 0xDBCF,\t0x88CA, 0xB8CD, 0x88CB, 0xDFF2, 0x88CC, 0xDFF8, 0x88CD, 0xDFF3,\r\n\t0x88CE, 0xDFF4, 0x88CF, 0xF9D8, 0x88D0, 0xDFF9, 0x88D2, 0xB8CF,\t0x88D4, 0xB8C7, 0x88D5, 0xB8CE, 0x88D6, 0xDFF1, 0x88D7, 0xDBC4,\r\n\t0x88D8, 0xB8CA, 0x88D9, 0xB8C8, 0x88DA, 0xDFF7, 0x88DB, 0xDFF6,\t0x88DC, 0xB8C9, 0x88DD, 0xB8CB, 0x88DE, 0xDFF5, 0x88DF, 0xB8C6,\r\n\t0x88E1, 0xB8CC, 0x88E7, 0xE3F6, 0x88E8, 0xBB74, 0x88EB, 0xE442,\t0x88EC, 0xE441, 0x88EE, 0xE3FB, 0x88EF, 0xBB76, 0x88F0, 0xE440,\r\n\t0x88F1, 0xE3F7, 0x88F2, 0xE3F8, 0x88F3, 0xBB6E, 0x88F4, 0xBB70,\t0x88F6, 0xE3FD, 0x88F7, 0xE3F5, 0x88F8, 0xBB72, 0x88F9, 0xBB71,\r\n\t0x88FA, 0xE3F9, 0x88FB, 0xE3FE, 0x88FC, 0xE3FC, 0x88FD, 0xBB73,\t0x88FE, 0xE3FA, 0x8901, 0xDBCE, 0x8902, 0xBB6F, 0x8905, 0xE7C2,\r\n\t0x8906, 0xE7C9, 0x8907, 0xBDC6, 0x8909, 0xE7CD, 0x890A, 0xBDCA,\t0x890B, 0xE7C5, 0x890C, 0xE7C3, 0x890E, 0xE7CC, 0x8910, 0xBDC5,\r\n\t0x8911, 0xE7CB, 0x8912, 0xBDC7, 0x8913, 0xBDC8, 0x8914, 0xE7C4,\t0x8915, 0xBDC9, 0x8916, 0xE7CA, 0x8917, 0xE7C6, 0x8918, 0xE7C7,\r\n\t0x8919, 0xE7C8, 0x891A, 0xBB75, 0x891E, 0xEB70, 0x891F, 0xEB7C,\t0x8921, 0xBFCA, 0x8922, 0xEB77, 0x8923, 0xEB79, 0x8925, 0xBFC8,\r\n\t0x8926, 0xEB71, 0x8927, 0xEB75, 0x8929, 0xEB78, 0x892A, 0xBFC6,\t0x892B, 0xBFC9, 0x892C, 0xEB7B, 0x892D, 0xEB73, 0x892E, 0xEB74,\r\n\t0x892F, 0xEB7A, 0x8930, 0xEB72, 0x8931, 0xEB76, 0x8932, 0xBFC7,\t0x8933, 0xEE72, 0x8935, 0xEE71, 0x8936, 0xC1B7, 0x8937, 0xEE77,\r\n\t0x8938, 0xC1B9, 0x893B, 0xC1B6, 0x893C, 0xEE73, 0x893D, 0xC1BA,\t0x893E, 0xEE74, 0x8941, 0xEE75, 0x8942, 0xEE78, 0x8944, 0xC1B8,\r\n\t0x8946, 0xF0D6, 0x8949, 0xF0D9, 0x894B, 0xF0D3, 0x894C, 0xF0D5,\t0x894F, 0xF0D4, 0x8950, 0xF0D7, 0x8951, 0xF0D8, 0x8952, 0xEE76,\r\n\t0x8953, 0xF0D2, 0x8956, 0xC3CD, 0x8957, 0xF2EC, 0x8958, 0xF2EF,\t0x8959, 0xF2F1, 0x895A, 0xF2EA, 0x895B, 0xF2EB, 0x895C, 0xF2EE,\r\n\t0x895D, 0xF2F0, 0x895E, 0xC3CE, 0x895F, 0xC3CC, 0x8960, 0xC3CB,\t0x8961, 0xF2ED, 0x8962, 0xF2E9, 0x8963, 0xF4CA, 0x8964, 0xC4B0,\r\n\t0x8966, 0xF4CB, 0x8969, 0xF649, 0x896A, 0xC4FB, 0x896B, 0xF64B,\t0x896C, 0xC4FC, 0x896D, 0xF648, 0x896E, 0xF64A, 0x896F, 0xC5A8,\r\n\t0x8971, 0xF752, 0x8972, 0xC5A7, 0x8973, 0xF7FD, 0x8974, 0xF7FC,\t0x8976, 0xF7FB, 0x8979, 0xF948, 0x897A, 0xF949, 0x897B, 0xF94B,\r\n\t0x897C, 0xF94A, 0x897E, 0xCA50, 0x897F, 0xA6E8, 0x8981, 0xAD6E,\t0x8982, 0xD7C5, 0x8983, 0xB5F7, 0x8985, 0xDFFA, 0x8986, 0xC2D0,\r\n\t0x8988, 0xF2F2, 0x898B, 0xA8A3, 0x898F, 0xB357, 0x8993, 0xB356,\t0x8995, 0xDBD0, 0x8996, 0xB5F8, 0x8997, 0xDBD2, 0x8998, 0xDBD1,\r\n\t0x899B, 0xDFFB, 0x899C, 0xB8D0, 0x899D, 0xE443, 0x899E, 0xE446,\t0x899F, 0xE445, 0x89A1, 0xE444, 0x89A2, 0xE7CE, 0x89A3, 0xE7D0,\r\n\t0x89A4, 0xE7CF, 0x89A6, 0xBFCC, 0x89AA, 0xBFCB, 0x89AC, 0xC1BB,\t0x89AD, 0xEE79, 0x89AE, 0xEE7B, 0x89AF, 0xEE7A, 0x89B2, 0xC2D1,\r\n\t0x89B6, 0xF2F4, 0x89B7, 0xF2F3, 0x89B9, 0xF4CC, 0x89BA, 0xC4B1,\t0x89BD, 0xC4FD, 0x89BE, 0xF754, 0x89BF, 0xF753, 0x89C0, 0xC65B,\r\n\t0x89D2, 0xA8A4, 0x89D3, 0xD0AF, 0x89D4, 0xAD6F, 0x89D5, 0xD7C8,\t0x89D6, 0xD7C6, 0x89D9, 0xD7C7, 0x89DA, 0xDBD4, 0x89DB, 0xDBD5,\r\n\t0x89DC, 0xE043, 0x89DD, 0xDBD3, 0x89DF, 0xDFFC, 0x89E0, 0xE041,\t0x89E1, 0xE040, 0x89E2, 0xE042, 0x89E3, 0xB8D1, 0x89E4, 0xDFFE,\r\n\t0x89E5, 0xDFFD, 0x89E6, 0xE044, 0x89E8, 0xE449, 0x89E9, 0xE447,\t0x89EB, 0xE448, 0x89EC, 0xE7D3, 0x89ED, 0xE7D1, 0x89F0, 0xE7D2,\r\n\t0x89F1, 0xEB7D, 0x89F2, 0xEE7C, 0x89F3, 0xEE7D, 0x89F4, 0xC2D2,\t0x89F6, 0xF2F5, 0x89F7, 0xF4CD, 0x89F8, 0xC4B2, 0x89FA, 0xF64C,\r\n\t0x89FB, 0xF755, 0x89FC, 0xC5A9, 0x89FE, 0xF7FE, 0x89FF, 0xF94C,\t0x8A00, 0xA8A5, 0x8A02, 0xAD71, 0x8A03, 0xAD72, 0x8A04, 0xD0B0,\r\n\t0x8A07, 0xD0B1, 0x8A08, 0xAD70, 0x8A0A, 0xB054, 0x8A0C, 0xB052,\t0x8A0E, 0xB051, 0x8A0F, 0xB058, 0x8A10, 0xB050, 0x8A11, 0xB059,\r\n\t0x8A12, 0xD3DD, 0x8A13, 0xB056, 0x8A15, 0xB053, 0x8A16, 0xB057,\t0x8A17, 0xB055, 0x8A18, 0xB04F, 0x8A1B, 0xB35F, 0x8A1D, 0xB359,\r\n\t0x8A1E, 0xD7CC, 0x8A1F, 0xB35E, 0x8A22, 0xB360, 0x8A23, 0xB35A,\t0x8A25, 0xB35B, 0x8A27, 0xD7CA, 0x8A2A, 0xB358, 0x8A2C, 0xD7CB,\r\n\t0x8A2D, 0xB35D, 0x8A30, 0xD7C9, 0x8A31, 0xB35C, 0x8A34, 0xB644,\t0x8A36, 0xB646, 0x8A39, 0xDBD8, 0x8A3A, 0xB645, 0x8A3B, 0xB5F9,\r\n\t0x8A3C, 0xB5FD, 0x8A3E, 0xB8E4, 0x8A3F, 0xE049, 0x8A40, 0xDBDA,\t0x8A41, 0xB5FE, 0x8A44, 0xDBDD, 0x8A45, 0xDBDE, 0x8A46, 0xB643,\r\n\t0x8A48, 0xDBE0, 0x8A4A, 0xDBE2, 0x8A4C, 0xDBE3, 0x8A4D, 0xDBD7,\t0x8A4E, 0xDBD6, 0x8A4F, 0xDBE4, 0x8A50, 0xB642, 0x8A51, 0xDBE1,\r\n\t0x8A52, 0xDBDF, 0x8A54, 0xB640, 0x8A55, 0xB5FB, 0x8A56, 0xB647,\t0x8A57, 0xDBDB, 0x8A58, 0xDBDC, 0x8A59, 0xDBD9, 0x8A5B, 0xB641,\r\n\t0x8A5E, 0xB5FC, 0x8A60, 0xB5FA, 0x8A61, 0xE048, 0x8A62, 0xB8DF,\t0x8A63, 0xB8DA, 0x8A66, 0xB8D5, 0x8A68, 0xB8E5, 0x8A69, 0xB8D6,\r\n\t0x8A6B, 0xB8D2, 0x8A6C, 0xB8E1, 0x8A6D, 0xB8DE, 0x8A6E, 0xB8E0,\t0x8A70, 0xB8D7, 0x8A71, 0xB8DC, 0x8A72, 0xB8D3, 0x8A73, 0xB8D4,\r\n\t0x8A74, 0xE050, 0x8A75, 0xE04D, 0x8A76, 0xE045, 0x8A77, 0xE04A,\t0x8A79, 0xB8E2, 0x8A7A, 0xE051, 0x8A7B, 0xB8E3, 0x8A7C, 0xB8D9,\r\n\t0x8A7F, 0xE047, 0x8A81, 0xE04F, 0x8A82, 0xE04B, 0x8A83, 0xE04E,\t0x8A84, 0xE04C, 0x8A85, 0xB8DD, 0x8A86, 0xE046, 0x8A87, 0xB8D8,\r\n\t0x8A8B, 0xE44C, 0x8A8C, 0xBB78, 0x8A8D, 0xBB7B, 0x8A8F, 0xE44E,\t0x8A91, 0xBBA5, 0x8A92, 0xE44D, 0x8A93, 0xBB7D, 0x8A95, 0xBDCF,\r\n\t0x8A96, 0xE44F, 0x8A98, 0xBBA4, 0x8A99, 0xE44B, 0x8A9A, 0xBBA6,\t0x8A9E, 0xBB79, 0x8AA0, 0xB8DB, 0x8AA1, 0xBB7C, 0x8AA3, 0xBB7A,\r\n\t0x8AA4, 0xBB7E, 0x8AA5, 0xBBA2, 0x8AA6, 0xBB77, 0x8AA7, 0xBBA7,\t0x8AA8, 0xBBA3, 0x8AAA, 0xBBA1, 0x8AAB, 0xE44A, 0x8AB0, 0xBDD6,\r\n\t0x8AB2, 0xBDD2, 0x8AB6, 0xBDD9, 0x8AB8, 0xE7D6, 0x8AB9, 0xBDDA,\t0x8ABA, 0xE7E2, 0x8ABB, 0xE7DB, 0x8ABC, 0xBDCB, 0x8ABD, 0xE7E3,\r\n\t0x8ABE, 0xE7DD, 0x8ABF, 0xBDD5, 0x8AC0, 0xE7DE, 0x8AC2, 0xBDD4,\t0x8AC3, 0xE7E1, 0x8AC4, 0xBDCE, 0x8AC5, 0xE7DF, 0x8AC6, 0xE7D5,\r\n\t0x8AC7, 0xBDCD, 0x8AC8, 0xEBAA, 0x8AC9, 0xBDD3, 0x8ACB, 0xBDD0,\t0x8ACD, 0xBDD8, 0x8ACF, 0xE7D4, 0x8AD1, 0xE7D8, 0x8AD2, 0xBDCC,\r\n\t0x8AD3, 0xE7D7, 0x8AD4, 0xE7D9, 0x8AD5, 0xE7DA, 0x8AD6, 0xBDD7,\t0x8AD7, 0xE7DC, 0x8AD8, 0xE7E0, 0x8AD9, 0xE7E4, 0x8ADB, 0xBDDB,\r\n\t0x8ADC, 0xBFD2, 0x8ADD, 0xEBA5, 0x8ADE, 0xEBAB, 0x8ADF, 0xEBA8,\t0x8AE0, 0xEB7E, 0x8AE1, 0xEBAC, 0x8AE2, 0xEBA1, 0x8AE4, 0xEBA7,\r\n\t0x8AE6, 0xBFCD, 0x8AE7, 0xBFD3, 0x8AE8, 0xEBAD, 0x8AEB, 0xBFCF,\t0x8AED, 0xBFD9, 0x8AEE, 0xBFD4, 0x8AEF, 0xEBAF, 0x8AF0, 0xEBA9,\r\n\t0x8AF1, 0xBFD0, 0x8AF2, 0xEBA2, 0x8AF3, 0xBFDA, 0x8AF4, 0xEBA3,\t0x8AF5, 0xEBA4, 0x8AF6, 0xBFDB, 0x8AF7, 0xBFD8, 0x8AF8, 0xBDD1,\r\n\t0x8AFA, 0xBFCE, 0x8AFB, 0xEBB0, 0x8AFC, 0xBFDC, 0x8AFE, 0xBFD5,\t0x8AFF, 0xEBAE, 0x8B00, 0xBFD1, 0x8B01, 0xBFD6, 0x8B02, 0xBFD7,\r\n\t0x8B04, 0xC1C3, 0x8B05, 0xEEA4, 0x8B06, 0xEEAD, 0x8B07, 0xEEAA,\t0x8B08, 0xEEAC, 0x8B0A, 0xC1C0, 0x8B0B, 0xEEA5, 0x8B0D, 0xEEAB,\r\n\t0x8B0E, 0xC1BC, 0x8B0F, 0xEEA7, 0x8B10, 0xC1C4, 0x8B11, 0xEEA3,\t0x8B12, 0xEEA8, 0x8B13, 0xEEAF, 0x8B14, 0xEBA6, 0x8B15, 0xEEA9,\r\n\t0x8B16, 0xEEA2, 0x8B17, 0xC1BD, 0x8B18, 0xEEA1, 0x8B19, 0xC1BE,\t0x8B1A, 0xEEB0, 0x8B1B, 0xC1BF, 0x8B1C, 0xEEAE, 0x8B1D, 0xC1C2,\r\n\t0x8B1E, 0xEE7E, 0x8B20, 0xC1C1, 0x8B22, 0xEEA6, 0x8B23, 0xF0DC,\t0x8B24, 0xF0EA, 0x8B25, 0xF0E5, 0x8B26, 0xF0E7, 0x8B27, 0xF0DB,\r\n\t0x8B28, 0xC2D3, 0x8B2A, 0xF0DA, 0x8B2B, 0xC2D6, 0x8B2C, 0xC2D5,\t0x8B2E, 0xF0E9, 0x8B2F, 0xF0E1, 0x8B30, 0xF0DE, 0x8B31, 0xF0E4,\r\n\t0x8B33, 0xF0DD, 0x8B35, 0xF0DF, 0x8B36, 0xF0E8, 0x8B37, 0xF0E6,\t0x8B39, 0xC2D4, 0x8B3A, 0xF0ED, 0x8B3B, 0xF0EB, 0x8B3C, 0xF0E2,\r\n\t0x8B3D, 0xF0EC, 0x8B3E, 0xF0E3, 0x8B40, 0xF2F9, 0x8B41, 0xC3CF,\t0x8B42, 0xF341, 0x8B45, 0xF64F, 0x8B46, 0xC3D6, 0x8B47, 0xF0E0,\r\n\t0x8B48, 0xF2F7, 0x8B49, 0xC3D2, 0x8B4A, 0xF2F8, 0x8B4B, 0xF2FD,\t0x8B4E, 0xC3D4, 0x8B4F, 0xC3D5, 0x8B50, 0xF2F6, 0x8B51, 0xF340,\r\n\t0x8B52, 0xF342, 0x8B53, 0xF2FA, 0x8B54, 0xF2FC, 0x8B55, 0xF2FE,\t0x8B56, 0xF2FB, 0x8B57, 0xF343, 0x8B58, 0xC3D1, 0x8B59, 0xC3D7,\r\n\t0x8B5A, 0xC3D3, 0x8B5C, 0xC3D0, 0x8B5D, 0xF4D0, 0x8B5F, 0xC4B7,\t0x8B60, 0xF4CE, 0x8B63, 0xF4D2, 0x8B65, 0xF4D3, 0x8B66, 0xC4B5,\r\n\t0x8B67, 0xF4D4, 0x8B68, 0xF4D1, 0x8B6A, 0xF4CF, 0x8B6B, 0xC4B8,\t0x8B6C, 0xC4B4, 0x8B6D, 0xF4D5, 0x8B6F, 0xC4B6, 0x8B70, 0xC4B3,\r\n\t0x8B74, 0xC4FE, 0x8B77, 0xC540, 0x8B78, 0xF64E, 0x8B79, 0xF64D,\t0x8B7A, 0xF650, 0x8B7B, 0xF651, 0x8B7D, 0xC541, 0x8B7E, 0xF756,\r\n\t0x8B7F, 0xF75B, 0x8B80, 0xC5AA, 0x8B82, 0xF758, 0x8B84, 0xF757,\t0x8B85, 0xF75A, 0x8B86, 0xF759, 0x8B88, 0xF843, 0x8B8A, 0xC5DC,\r\n\t0x8B8B, 0xF842, 0x8B8C, 0xF840, 0x8B8E, 0xF841, 0x8B92, 0xC5FE,\t0x8B93, 0xC5FD, 0x8B94, 0xF8C1, 0x8B95, 0xF8C2, 0x8B96, 0xC640,\r\n\t0x8B98, 0xF94D, 0x8B99, 0xF94E, 0x8B9A, 0xC667, 0x8B9C, 0xC66D,\t0x8B9E, 0xF9A9, 0x8B9F, 0xF9C8, 0x8C37, 0xA8A6, 0x8C39, 0xD7CD,\r\n\t0x8C3B, 0xD7CE, 0x8C3C, 0xE052, 0x8C3D, 0xE450, 0x8C3E, 0xE7E5,\t0x8C3F, 0xC1C6, 0x8C41, 0xC1C5, 0x8C42, 0xF0EE, 0x8C43, 0xF344,\r\n\t0x8C45, 0xF844, 0x8C46, 0xA8A7, 0x8C47, 0xD3DE, 0x8C48, 0xB05A,\t0x8C49, 0xB361, 0x8C4A, 0xE054, 0x8C4B, 0xE053, 0x8C4C, 0xBDDC,\r\n\t0x8C4D, 0xE7E6, 0x8C4E, 0xBDDD, 0x8C4F, 0xEEB1, 0x8C50, 0xC2D7,\t0x8C54, 0xC676, 0x8C55, 0xA8A8, 0x8C56, 0xCDCB, 0x8C57, 0xD3DF,\r\n\t0x8C5A, 0xB362, 0x8C5C, 0xD7CF, 0x8C5D, 0xD7D0, 0x8C5F, 0xDBE5,\t0x8C61, 0xB648, 0x8C62, 0xB8E6, 0x8C64, 0xE056, 0x8C65, 0xE055,\r\n\t0x8C66, 0xE057, 0x8C68, 0xE451, 0x8C69, 0xE452, 0x8C6A, 0xBBA8,\t0x8C6B, 0xBFDD, 0x8C6C, 0xBDDE, 0x8C6D, 0xBFDE, 0x8C6F, 0xEEB5,\r\n\t0x8C70, 0xEEB2, 0x8C71, 0xEEB4, 0x8C72, 0xEEB3, 0x8C73, 0xC1C7,\t0x8C75, 0xF0EF, 0x8C76, 0xF346, 0x8C77, 0xF345, 0x8C78, 0xCBA4,\r\n\t0x8C79, 0xB05C, 0x8C7A, 0xB05B, 0x8C7B, 0xD3E0, 0x8C7D, 0xD7D1,\t0x8C80, 0xDBE7, 0x8C81, 0xDBE6, 0x8C82, 0xB649, 0x8C84, 0xE059,\r\n\t0x8C85, 0xE05A, 0x8C86, 0xE058, 0x8C89, 0xB8E8, 0x8C8A, 0xB8E7,\t0x8C8C, 0xBBAA, 0x8C8D, 0xBBA9, 0x8C8F, 0xE7E7, 0x8C90, 0xEBB3,\r\n\t0x8C91, 0xEBB1, 0x8C92, 0xEBB2, 0x8C93, 0xBFDF, 0x8C94, 0xEEB7,\t0x8C95, 0xEEB6, 0x8C97, 0xF0F2, 0x8C98, 0xF0F1, 0x8C99, 0xF0F0,\r\n\t0x8C9A, 0xF347, 0x8C9C, 0xF9AA, 0x8C9D, 0xA8A9, 0x8C9E, 0xAD73,\t0x8CA0, 0xAD74, 0x8CA1, 0xB05D, 0x8CA2, 0xB05E, 0x8CA3, 0xD3E2,\r\n\t0x8CA4, 0xD3E1, 0x8CA5, 0xD7D2, 0x8CA7, 0xB368, 0x8CA8, 0xB366,\t0x8CA9, 0xB363, 0x8CAA, 0xB367, 0x8CAB, 0xB365, 0x8CAC, 0xB364,\r\n\t0x8CAF, 0xB64A, 0x8CB0, 0xDBEA, 0x8CB2, 0xB8ED, 0x8CB3, 0xB64C,\t0x8CB4, 0xB651, 0x8CB5, 0xDBEC, 0x8CB6, 0xB653, 0x8CB7, 0xB652,\r\n\t0x8CB8, 0xB655, 0x8CB9, 0xDBEB, 0x8CBA, 0xDBE8, 0x8CBB, 0xB64F,\t0x8CBC, 0xB64B, 0x8CBD, 0xB64D, 0x8CBE, 0xDBE9, 0x8CBF, 0xB654,\r\n\t0x8CC0, 0xB650, 0x8CC1, 0xB64E, 0x8CC2, 0xB8EF, 0x8CC3, 0xB8EE,\t0x8CC4, 0xB8EC, 0x8CC5, 0xB8F0, 0x8CC7, 0xB8EA, 0x8CC8, 0xB8EB,\r\n\t0x8CCA, 0xB8E9, 0x8CCC, 0xE05B, 0x8CCF, 0xE454, 0x8CD1, 0xBBAC,\t0x8CD2, 0xBBAD, 0x8CD3, 0xBBAB, 0x8CD5, 0xE453, 0x8CD7, 0xE455,\r\n\t0x8CD9, 0xE7EA, 0x8CDA, 0xE7EC, 0x8CDC, 0xBDE7, 0x8CDD, 0xE7ED,\t0x8CDE, 0xBDE0, 0x8CDF, 0xE7E9, 0x8CE0, 0xBDDF, 0x8CE1, 0xBDE9,\r\n\t0x8CE2, 0xBDE5, 0x8CE3, 0xBDE6, 0x8CE4, 0xBDE2, 0x8CE5, 0xE7E8,\t0x8CE6, 0xBDE1, 0x8CE7, 0xE7EE, 0x8CE8, 0xE7EB, 0x8CEA, 0xBDE8,\r\n\t0x8CEC, 0xBDE3, 0x8CED, 0xBDE4, 0x8CEE, 0xEBB5, 0x8CF0, 0xEBB7,\t0x8CF1, 0xEBB6, 0x8CF3, 0xEBB8, 0x8CF4, 0xBFE0, 0x8CF5, 0xEBB4,\r\n\t0x8CF8, 0xC1CB, 0x8CF9, 0xEEB8, 0x8CFA, 0xC1C8, 0x8CFB, 0xC1CC,\t0x8CFC, 0xC1CA, 0x8CFD, 0xC1C9, 0x8CFE, 0xF0F3, 0x8D00, 0xF0F6,\r\n\t0x8D02, 0xF0F5, 0x8D04, 0xF0F4, 0x8D05, 0xC2D8, 0x8D06, 0xF348,\t0x8D07, 0xF349, 0x8D08, 0xC3D8, 0x8D09, 0xF34A, 0x8D0A, 0xC3D9,\r\n\t0x8D0D, 0xC4BA, 0x8D0F, 0xC4B9, 0x8D10, 0xF652, 0x8D13, 0xC542,\t0x8D14, 0xF653, 0x8D15, 0xF75C, 0x8D16, 0xC5AB, 0x8D17, 0xC5AC,\r\n\t0x8D19, 0xF845, 0x8D1B, 0xC642, 0x8D64, 0xA8AA, 0x8D66, 0xB36A,\t0x8D67, 0xB369, 0x8D68, 0xE05C, 0x8D69, 0xE05D, 0x8D6B, 0xBBAE,\r\n\t0x8D6C, 0xEBB9, 0x8D6D, 0xBDEA, 0x8D6E, 0xEBBA, 0x8D6F, 0xEEB9,\t0x8D70, 0xA8AB, 0x8D72, 0xD0B2, 0x8D73, 0xAD76, 0x8D74, 0xAD75,\r\n\t0x8D76, 0xD3E3, 0x8D77, 0xB05F, 0x8D78, 0xD3E4, 0x8D79, 0xD7D5,\t0x8D7B, 0xD7D4, 0x8D7D, 0xD7D3, 0x8D80, 0xDBEE, 0x8D81, 0xB658,\r\n\t0x8D84, 0xDBED, 0x8D85, 0xB657, 0x8D89, 0xDBEF, 0x8D8A, 0xB656,\t0x8D8C, 0xE05F, 0x8D8D, 0xE062, 0x8D8E, 0xE060, 0x8D8F, 0xE061,\r\n\t0x8D90, 0xE065, 0x8D91, 0xE05E, 0x8D92, 0xE066, 0x8D93, 0xE063,\t0x8D94, 0xE064, 0x8D95, 0xBBB0, 0x8D96, 0xE456, 0x8D99, 0xBBAF,\r\n\t0x8D9B, 0xE7F2, 0x8D9C, 0xE7F0, 0x8D9F, 0xBDEB, 0x8DA0, 0xE7EF,\t0x8DA1, 0xE7F1, 0x8DA3, 0xBDEC, 0x8DA5, 0xEBBB, 0x8DA7, 0xEBBC,\r\n\t0x8DA8, 0xC1CD, 0x8DAA, 0xF34C, 0x8DAB, 0xF34E, 0x8DAC, 0xF34B,\t0x8DAD, 0xF34D, 0x8DAE, 0xF4D6, 0x8DAF, 0xF654, 0x8DB2, 0xF96F,\r\n\t0x8DB3, 0xA8AC, 0x8DB4, 0xAD77, 0x8DB5, 0xD3E5, 0x8DB6, 0xD3E7,\t0x8DB7, 0xD3E6, 0x8DB9, 0xD7D8, 0x8DBA, 0xB36C, 0x8DBC, 0xD7D6,\r\n\t0x8DBE, 0xB36B, 0x8DBF, 0xD7D9, 0x8DC1, 0xD7DA, 0x8DC2, 0xD7D7,\t0x8DC5, 0xDBFB, 0x8DC6, 0xB660, 0x8DC7, 0xDBF3, 0x8DC8, 0xDBF9,\r\n\t0x8DCB, 0xB65B, 0x8DCC, 0xB65E, 0x8DCD, 0xDBF2, 0x8DCE, 0xB659,\t0x8DCF, 0xDBF6, 0x8DD0, 0xE06C, 0x8DD1, 0xB65D, 0x8DD3, 0xDBF1,\r\n\t0x8DD5, 0xDBF7, 0x8DD6, 0xDBF4, 0x8DD7, 0xDBFA, 0x8DD8, 0xDBF0,\t0x8DD9, 0xDBF8, 0x8DDA, 0xB65C, 0x8DDB, 0xB65F, 0x8DDC, 0xDBF5,\r\n\t0x8DDD, 0xB65A, 0x8DDF, 0xB8F2, 0x8DE0, 0xE068, 0x8DE1, 0xB8F1,\t0x8DE2, 0xE06F, 0x8DE3, 0xE06E, 0x8DE4, 0xB8F8, 0x8DE6, 0xB8F9,\r\n\t0x8DE7, 0xE070, 0x8DE8, 0xB8F3, 0x8DE9, 0xE06D, 0x8DEA, 0xB8F7,\t0x8DEB, 0xE072, 0x8DEC, 0xE069, 0x8DEE, 0xE06B, 0x8DEF, 0xB8F4,\r\n\t0x8DF0, 0xE067, 0x8DF1, 0xE06A, 0x8DF2, 0xE071, 0x8DF3, 0xB8F5,\t0x8DF4, 0xE073, 0x8DFA, 0xB8F6, 0x8DFC, 0xBBB1, 0x8DFD, 0xE45B,\r\n\t0x8DFE, 0xE461, 0x8DFF, 0xE459, 0x8E00, 0xE462, 0x8E02, 0xE458,\t0x8E03, 0xE45D, 0x8E04, 0xE463, 0x8E05, 0xE460, 0x8E06, 0xE45F,\r\n\t0x8E07, 0xE45E, 0x8E09, 0xE457, 0x8E0A, 0xE45C, 0x8E0D, 0xE45A,\t0x8E0F, 0xBDF1, 0x8E10, 0xBDEE, 0x8E11, 0xE7FB, 0x8E12, 0xE841,\r\n\t0x8E13, 0xE843, 0x8E14, 0xE840, 0x8E15, 0xE7F8, 0x8E16, 0xE7FA,\t0x8E17, 0xE845, 0x8E18, 0xE842, 0x8E19, 0xE7FC, 0x8E1A, 0xE846,\r\n\t0x8E1B, 0xE7F9, 0x8E1C, 0xE844, 0x8E1D, 0xBDEF, 0x8E1E, 0xBDF5,\t0x8E1F, 0xBDF3, 0x8E20, 0xE7F3, 0x8E21, 0xBDF4, 0x8E22, 0xBDF0,\r\n\t0x8E23, 0xE7F4, 0x8E24, 0xE7F6, 0x8E25, 0xE7F5, 0x8E26, 0xE7FD,\t0x8E27, 0xE7FE, 0x8E29, 0xBDF2, 0x8E2B, 0xBDED, 0x8E2E, 0xE7F7,\r\n\t0x8E30, 0xEBC6, 0x8E31, 0xBFE2, 0x8E33, 0xEBBD, 0x8E34, 0xBFE3,\t0x8E35, 0xBFE6, 0x8E36, 0xEBC2, 0x8E38, 0xEBBF, 0x8E39, 0xBFE5,\r\n\t0x8E3C, 0xEBC3, 0x8E3D, 0xEBC4, 0x8E3E, 0xEBBE, 0x8E3F, 0xEBC7,\t0x8E40, 0xEBC0, 0x8E41, 0xEBC5, 0x8E42, 0xBFE4, 0x8E44, 0xBFE1,\r\n\t0x8E45, 0xEBC1, 0x8E47, 0xEEBF, 0x8E48, 0xC1D0, 0x8E49, 0xC1CE,\t0x8E4A, 0xC1D1, 0x8E4B, 0xC1CF, 0x8E4C, 0xEEBE, 0x8E4D, 0xEEBB,\r\n\t0x8E4E, 0xEEBA, 0x8E50, 0xEEBD, 0x8E53, 0xEEBC, 0x8E54, 0xF145,\t0x8E55, 0xC2DE, 0x8E56, 0xF0FB, 0x8E57, 0xF0FA, 0x8E59, 0xC2D9,\r\n\t0x8E5A, 0xF141, 0x8E5B, 0xF140, 0x8E5C, 0xF0F7, 0x8E5D, 0xF143,\t0x8E5E, 0xF0FC, 0x8E5F, 0xC2DD, 0x8E60, 0xF0F9, 0x8E61, 0xF142,\r\n\t0x8E62, 0xF0F8, 0x8E63, 0xC2DA, 0x8E64, 0xC2DC, 0x8E65, 0xF0FD,\t0x8E66, 0xC2DB, 0x8E67, 0xF0FE, 0x8E69, 0xF144, 0x8E6A, 0xF352,\r\n\t0x8E6C, 0xC3DE, 0x8E6D, 0xF34F, 0x8E6F, 0xF353, 0x8E72, 0xC3DB,\t0x8E73, 0xF351, 0x8E74, 0xC3E0, 0x8E76, 0xC3DD, 0x8E78, 0xF350,\r\n\t0x8E7A, 0xC3DF, 0x8E7B, 0xF354, 0x8E7C, 0xC3DA, 0x8E81, 0xC4BC,\t0x8E82, 0xC4BE, 0x8E84, 0xF4D9, 0x8E85, 0xC4BD, 0x8E86, 0xF4D7,\r\n\t0x8E87, 0xC3DC, 0x8E88, 0xF4D8, 0x8E89, 0xC4BB, 0x8E8A, 0xC543,\t0x8E8B, 0xC545, 0x8E8C, 0xF656, 0x8E8D, 0xC544, 0x8E8E, 0xF655,\r\n\t0x8E90, 0xF761, 0x8E91, 0xC5AD, 0x8E92, 0xF760, 0x8E93, 0xC5AE,\t0x8E94, 0xF75E, 0x8E95, 0xF75D, 0x8E96, 0xF762, 0x8E97, 0xF763,\r\n\t0x8E98, 0xF846, 0x8E9A, 0xF75F, 0x8E9D, 0xF8C6, 0x8E9E, 0xF8C3,\t0x8E9F, 0xF8C4, 0x8EA0, 0xF8C5, 0x8EA1, 0xC65C, 0x8EA3, 0xF951,\r\n\t0x8EA4, 0xF950, 0x8EA5, 0xF94F, 0x8EA6, 0xF970, 0x8EA8, 0xF9BE,\t0x8EA9, 0xF9AB, 0x8EAA, 0xC66E, 0x8EAB, 0xA8AD, 0x8EAC, 0xB060,\r\n\t0x8EB2, 0xB8FA, 0x8EBA, 0xBDF6, 0x8EBD, 0xEBC8, 0x8EC0, 0xC2DF,\t0x8EC2, 0xF355, 0x8EC9, 0xF9AC, 0x8ECA, 0xA8AE, 0x8ECB, 0xAAEE,\r\n\t0x8ECC, 0xAD79, 0x8ECD, 0xAD78, 0x8ECF, 0xB063, 0x8ED1, 0xD3E8,\t0x8ED2, 0xB061, 0x8ED3, 0xD3E9, 0x8ED4, 0xB062, 0x8ED7, 0xD7DF,\r\n\t0x8ED8, 0xD7DB, 0x8EDB, 0xB36D, 0x8EDC, 0xD7DE, 0x8EDD, 0xD7DD,\t0x8EDE, 0xD7DC, 0x8EDF, 0xB36E, 0x8EE0, 0xD7E0, 0x8EE1, 0xD7E1,\r\n\t0x8EE5, 0xDC43, 0x8EE6, 0xDC41, 0x8EE7, 0xDC45, 0x8EE8, 0xDC46,\t0x8EE9, 0xDC4C, 0x8EEB, 0xDC48, 0x8EEC, 0xDC4A, 0x8EEE, 0xDC42,\r\n\t0x8EEF, 0xDBFC, 0x8EF1, 0xDC49, 0x8EF4, 0xDC4B, 0x8EF5, 0xDC44,\t0x8EF6, 0xDC47, 0x8EF7, 0xDBFD, 0x8EF8, 0xB662, 0x8EF9, 0xDC40,\r\n\t0x8EFA, 0xDBFE, 0x8EFB, 0xB661, 0x8EFC, 0xB663, 0x8EFE, 0xB8FD,\t0x8EFF, 0xE075, 0x8F00, 0xE077, 0x8F01, 0xE076, 0x8F02, 0xE07B,\r\n\t0x8F03, 0xB8FB, 0x8F05, 0xE078, 0x8F06, 0xE074, 0x8F07, 0xE079,\t0x8F08, 0xE07A, 0x8F09, 0xB8FC, 0x8F0A, 0xB8FE, 0x8F0B, 0xE07C,\r\n\t0x8F0D, 0xE467, 0x8F0E, 0xE466, 0x8F10, 0xE464, 0x8F11, 0xE465,\t0x8F12, 0xBBB3, 0x8F13, 0xBBB5, 0x8F14, 0xBBB2, 0x8F15, 0xBBB4,\r\n\t0x8F16, 0xE84D, 0x8F17, 0xE84E, 0x8F18, 0xE849, 0x8F1A, 0xE84A,\t0x8F1B, 0xBDF8, 0x8F1C, 0xBDFD, 0x8F1D, 0xBDF7, 0x8F1E, 0xBDFE,\r\n\t0x8F1F, 0xBDF9, 0x8F20, 0xE84B, 0x8F23, 0xE84C, 0x8F24, 0xE848,\t0x8F25, 0xBE40, 0x8F26, 0xBDFB, 0x8F29, 0xBDFA, 0x8F2A, 0xBDFC,\r\n\t0x8F2C, 0xE847, 0x8F2E, 0xEBCA, 0x8F2F, 0xBFE8, 0x8F32, 0xEBCC,\t0x8F33, 0xBFEA, 0x8F34, 0xEBCF, 0x8F35, 0xEBCB, 0x8F36, 0xEBC9,\r\n\t0x8F37, 0xEBCE, 0x8F38, 0xBFE9, 0x8F39, 0xEBCD, 0x8F3B, 0xBFE7,\t0x8F3E, 0xC1D3, 0x8F3F, 0xC1D6, 0x8F40, 0xEEC1, 0x8F42, 0xC1D4,\r\n\t0x8F43, 0xEEC0, 0x8F44, 0xC1D2, 0x8F45, 0xC1D5, 0x8F46, 0xF146,\t0x8F47, 0xF147, 0x8F48, 0xF148, 0x8F49, 0xC2E0, 0x8F4B, 0xF149,\r\n\t0x8F4D, 0xC2E1, 0x8F4E, 0xC3E2, 0x8F4F, 0xF358, 0x8F50, 0xF359,\t0x8F51, 0xF357, 0x8F52, 0xF356, 0x8F53, 0xF35A, 0x8F54, 0xC3E1,\r\n\t0x8F55, 0xF4DD, 0x8F56, 0xF4DB, 0x8F57, 0xF4DC, 0x8F58, 0xF4DE,\t0x8F59, 0xF4DA, 0x8F5A, 0xF4DF, 0x8F5B, 0xF658, 0x8F5D, 0xF659,\r\n\t0x8F5E, 0xF657, 0x8F5F, 0xC546, 0x8F60, 0xF764, 0x8F61, 0xC5AF,\t0x8F62, 0xF765, 0x8F63, 0xF848, 0x8F64, 0xF847, 0x8F9B, 0xA8AF,\r\n\t0x8F9C, 0xB664, 0x8F9F, 0xB940, 0x8FA3, 0xBBB6, 0x8FA6, 0xBFEC,\t0x8FA8, 0xBFEB, 0x8FAD, 0xC3E3, 0x8FAE, 0xC47C, 0x8FAF, 0xC547,\r\n\t0x8FB0, 0xA8B0, 0x8FB1, 0xB064, 0x8FB2, 0xB941, 0x8FB4, 0xF35B,\t0x8FBF, 0xCBA6, 0x8FC2, 0xA8B1, 0x8FC4, 0xA8B4, 0x8FC5, 0xA8B3,\r\n\t0x8FC6, 0xA8B2, 0x8FC9, 0xCBA5, 0x8FCB, 0xCDCD, 0x8FCD, 0xCDCF,\t0x8FCE, 0xAAEF, 0x8FD1, 0xAAF1, 0x8FD2, 0xCDCC, 0x8FD3, 0xCDCE,\r\n\t0x8FD4, 0xAAF0, 0x8FD5, 0xCDD1, 0x8FD6, 0xCDD0, 0x8FD7, 0xCDD2,\t0x8FE0, 0xD0B6, 0x8FE1, 0xD0B4, 0x8FE2, 0xAD7C, 0x8FE3, 0xD0B3,\r\n\t0x8FE4, 0xADA3, 0x8FE5, 0xAD7E, 0x8FE6, 0xAD7B, 0x8FE8, 0xADA4,\t0x8FEA, 0xAD7D, 0x8FEB, 0xADA2, 0x8FED, 0xADA1, 0x8FEE, 0xD0B5,\r\n\t0x8FF0, 0xAD7A, 0x8FF4, 0xB06A, 0x8FF5, 0xD3EB, 0x8FF6, 0xD3F1,\t0x8FF7, 0xB067, 0x8FF8, 0xB06E, 0x8FFA, 0xB069, 0x8FFB, 0xD3EE,\r\n\t0x8FFC, 0xD3F0, 0x8FFD, 0xB06C, 0x8FFE, 0xD3EA, 0x8FFF, 0xD3ED,\t0x9000, 0xB068, 0x9001, 0xB065, 0x9002, 0xD3EC, 0x9003, 0xB06B,\r\n\t0x9004, 0xD3EF, 0x9005, 0xB06D, 0x9006, 0xB066, 0x900B, 0xD7E3,\t0x900C, 0xD7E6, 0x900D, 0xB370, 0x900F, 0xB37A, 0x9010, 0xB376,\r\n\t0x9011, 0xD7E4, 0x9014, 0xB37E, 0x9015, 0xB377, 0x9016, 0xB37C,\t0x9017, 0xB372, 0x9019, 0xB36F, 0x901A, 0xB371, 0x901B, 0xB37D,\r\n\t0x901C, 0xD7E5, 0x901D, 0xB375, 0x901E, 0xB378, 0x901F, 0xB374,\t0x9020, 0xB379, 0x9021, 0xD7E7, 0x9022, 0xB37B, 0x9023, 0xB373,\r\n\t0x9024, 0xD7E2, 0x902D, 0xDC4D, 0x902E, 0xB665, 0x902F, 0xDC4F,\t0x9031, 0xB667, 0x9032, 0xB669, 0x9034, 0xDC4E, 0x9035, 0xB666,\r\n\t0x9036, 0xB66A, 0x9038, 0xB668, 0x903C, 0xB947, 0x903D, 0xE0A3,\t0x903E, 0xB94F, 0x903F, 0xE07E, 0x9041, 0xB950, 0x9042, 0xB945,\r\n\t0x9044, 0xE0A1, 0x9047, 0xB94A, 0x9049, 0xE0A2, 0x904A, 0xB943,\t0x904B, 0xB942, 0x904D, 0xB94D, 0x904E, 0xB94C, 0x904F, 0xB94B,\r\n\t0x9050, 0xB949, 0x9051, 0xB94E, 0x9052, 0xE07D, 0x9053, 0xB944,\t0x9054, 0xB946, 0x9055, 0xB948, 0x9058, 0xBBB8, 0x9059, 0xBBBB,\r\n\t0x905B, 0xBBBF, 0x905C, 0xBBB9, 0x905D, 0xBBBE, 0x905E, 0xBBBC,\t0x9060, 0xBBB7, 0x9062, 0xBBBD, 0x9063, 0xBBBA, 0x9067, 0xE852,\r\n\t0x9068, 0xBE43, 0x9069, 0xBE41, 0x906B, 0xE853, 0x906D, 0xBE44,\t0x906E, 0xBE42, 0x906F, 0xE851, 0x9070, 0xE850, 0x9072, 0xBFF0,\r\n\t0x9073, 0xE84F, 0x9074, 0xBFEE, 0x9075, 0xBFED, 0x9076, 0xEBD0,\t0x9077, 0xBE45, 0x9078, 0xBFEF, 0x9079, 0xEBD1, 0x907A, 0xBFF2,\r\n\t0x907B, 0xEBD2, 0x907C, 0xBFF1, 0x907D, 0xC1D8, 0x907E, 0xEEC3,\t0x907F, 0xC1D7, 0x9080, 0xC1DC, 0x9081, 0xC1DA, 0x9082, 0xC1DB,\r\n\t0x9083, 0xC2E3, 0x9084, 0xC1D9, 0x9085, 0xEEC2, 0x9086, 0xEBD3,\t0x9087, 0xC2E2, 0x9088, 0xC2E4, 0x908A, 0xC3E4, 0x908B, 0xC3E5,\r\n\t0x908D, 0xF4E0, 0x908F, 0xC5DE, 0x9090, 0xC5DD, 0x9091, 0xA8B6,\t0x9094, 0xCA55, 0x9095, 0xB06F, 0x9097, 0xCA52, 0x9098, 0xCA53,\r\n\t0x9099, 0xCA51, 0x909B, 0xCA54, 0x909E, 0xCBAA, 0x909F, 0xCBA7,\t0x90A0, 0xCBAC, 0x90A1, 0xCBA8, 0x90A2, 0xA8B7, 0x90A3, 0xA8BA,\r\n\t0x90A5, 0xCBA9, 0x90A6, 0xA8B9, 0x90A7, 0xCBAB, 0x90AA, 0xA8B8,\t0x90AF, 0xCDD5, 0x90B0, 0xCDD7, 0x90B1, 0xAAF4, 0x90B2, 0xCDD3,\r\n\t0x90B3, 0xCDD6, 0x90B4, 0xCDD4, 0x90B5, 0xAAF2, 0x90B6, 0xAAF5,\t0x90B8, 0xAAF3, 0x90BD, 0xD0B8, 0x90BE, 0xD0BC, 0x90BF, 0xD0B9,\r\n\t0x90C1, 0xADA7, 0x90C3, 0xADA8, 0x90C5, 0xD0BB, 0x90C7, 0xD0BD,\t0x90C8, 0xD0BF, 0x90CA, 0xADA5, 0x90CB, 0xD0BE, 0x90CE, 0xADA6,\r\n\t0x90D4, 0xD7EE, 0x90D5, 0xD0BA, 0x90D6, 0xD3F2, 0x90D7, 0xD3FB,\t0x90D8, 0xD3F9, 0x90D9, 0xD3F4, 0x90DA, 0xD3F5, 0x90DB, 0xD3FA,\r\n\t0x90DC, 0xD3FC, 0x90DD, 0xB071, 0x90DF, 0xD3F7, 0x90E0, 0xD3F3,\t0x90E1, 0xB070, 0x90E2, 0xB072, 0x90E3, 0xD3F6, 0x90E4, 0xD3FD,\r\n\t0x90E5, 0xD3F8, 0x90E8, 0xB3A1, 0x90E9, 0xD7F1, 0x90EA, 0xD7E9,\t0x90EB, 0xD7EF, 0x90EC, 0xD7F0, 0x90ED, 0xB3A2, 0x90EF, 0xD7E8,\r\n\t0x90F0, 0xD7EA, 0x90F1, 0xD0B7, 0x90F2, 0xD7EC, 0x90F3, 0xD7ED,\t0x90F4, 0xD7EB, 0x90F5, 0xB66C, 0x90F9, 0xDC56, 0x90FA, 0xEBD4,\r\n\t0x90FB, 0xDC57, 0x90FC, 0xDC54, 0x90FD, 0xB3A3, 0x90FE, 0xB66E,\t0x90FF, 0xDC53, 0x9100, 0xDC59, 0x9101, 0xDC58, 0x9102, 0xB66B,\r\n\t0x9103, 0xDC5C, 0x9104, 0xDC52, 0x9105, 0xDC5B, 0x9106, 0xDC50,\t0x9107, 0xDC5A, 0x9108, 0xDC55, 0x9109, 0xB66D, 0x910B, 0xE0AA,\r\n\t0x910D, 0xE0A5, 0x910E, 0xE0AB, 0x910F, 0xE0A6, 0x9110, 0xE0A4,\t0x9111, 0xE0A7, 0x9112, 0xB951, 0x9114, 0xE0A9, 0x9116, 0xE0A8,\r\n\t0x9117, 0xB952, 0x9118, 0xBBC1, 0x9119, 0xBBC0, 0x911A, 0xE46E,\t0x911B, 0xE471, 0x911C, 0xE469, 0x911D, 0xE46D, 0x911E, 0xBBC2,\r\n\t0x911F, 0xE46C, 0x9120, 0xE46A, 0x9121, 0xE470, 0x9122, 0xE46B,\t0x9123, 0xE468, 0x9124, 0xE46F, 0x9126, 0xE859, 0x9127, 0xBE48,\r\n\t0x9128, 0xF14A, 0x9129, 0xE856, 0x912A, 0xE857, 0x912B, 0xE855,\t0x912C, 0xDC51, 0x912D, 0xBE47, 0x912E, 0xE85A, 0x912F, 0xE854,\r\n\t0x9130, 0xBE46, 0x9131, 0xBE49, 0x9132, 0xE858, 0x9133, 0xEBD5,\t0x9134, 0xBFF3, 0x9135, 0xEBD6, 0x9136, 0xEBD7, 0x9138, 0xEEC4,\r\n\t0x9139, 0xC1DD, 0x913A, 0xF14B, 0x913B, 0xF14C, 0x913E, 0xF14D,\t0x913F, 0xF35D, 0x9140, 0xF35C, 0x9141, 0xF4E2, 0x9143, 0xF4E1,\r\n\t0x9144, 0xF65B, 0x9145, 0xF65C, 0x9146, 0xF65A, 0x9147, 0xF766,\t0x9148, 0xC5B0, 0x9149, 0xA8BB, 0x914A, 0xADAA, 0x914B, 0xADA9,\r\n\t0x914C, 0xB075, 0x914D, 0xB074, 0x914E, 0xD440, 0x914F, 0xD441,\t0x9150, 0xD3FE, 0x9152, 0xB073, 0x9153, 0xD7F5, 0x9155, 0xD7F6,\r\n\t0x9156, 0xD7F2, 0x9157, 0xB3A4, 0x9158, 0xD7F3, 0x915A, 0xD7F4,\t0x915F, 0xDC5F, 0x9160, 0xDC61, 0x9161, 0xDC5D, 0x9162, 0xDC60,\r\n\t0x9163, 0xB66F, 0x9164, 0xDC5E, 0x9165, 0xB670, 0x9168, 0xDD73,\t0x9169, 0xB955, 0x916A, 0xB954, 0x916C, 0xB953, 0x916E, 0xE0AC,\r\n\t0x916F, 0xE0AD, 0x9172, 0xE473, 0x9173, 0xE475, 0x9174, 0xBBC6,\t0x9175, 0xBBC3, 0x9177, 0xBBC5, 0x9178, 0xBBC4, 0x9179, 0xE474,\r\n\t0x917A, 0xE472, 0x9180, 0xE861, 0x9181, 0xE85E, 0x9182, 0xE85F,\t0x9183, 0xBE4D, 0x9184, 0xE860, 0x9185, 0xE85B, 0x9186, 0xE85C,\r\n\t0x9187, 0xBE4A, 0x9189, 0xBE4B, 0x918A, 0xE85D, 0x918B, 0xBE4C,\t0x918D, 0xEBDB, 0x918F, 0xEBDC, 0x9190, 0xEBD9, 0x9191, 0xEBDA,\r\n\t0x9192, 0xBFF4, 0x9193, 0xEBD8, 0x9199, 0xEEC8, 0x919A, 0xEEC5,\t0x919B, 0xEEC7, 0x919C, 0xC1E0, 0x919D, 0xEECB, 0x919E, 0xC1DF,\r\n\t0x919F, 0xEEC9, 0x91A0, 0xEECC, 0x91A1, 0xEECA, 0x91A2, 0xEEC6,\t0x91A3, 0xC1DE, 0x91A5, 0xF14F, 0x91A7, 0xF150, 0x91A8, 0xF14E,\r\n\t0x91AA, 0xF152, 0x91AB, 0xC2E5, 0x91AC, 0xC2E6, 0x91AD, 0xF35F,\t0x91AE, 0xC3E7, 0x91AF, 0xF151, 0x91B0, 0xF35E, 0x91B1, 0xC3E6,\r\n\t0x91B2, 0xF4E5, 0x91B3, 0xF4E6, 0x91B4, 0xC4BF, 0x91B5, 0xF4E4,\t0x91B7, 0xF4E3, 0x91B9, 0xF65D, 0x91BA, 0xC548, 0x91BC, 0xF849,\r\n\t0x91BD, 0xF8C8, 0x91BE, 0xF8C7, 0x91C0, 0xC643, 0x91C1, 0xC65D,\t0x91C2, 0xF8C9, 0x91C3, 0xF971, 0x91C5, 0xC66F, 0x91C6, 0xA8BC,\r\n\t0x91C7, 0xAAF6, 0x91C9, 0xB956, 0x91CB, 0xC4C0, 0x91CC, 0xA8BD,\t0x91CD, 0xADAB, 0x91CE, 0xB3A5, 0x91CF, 0xB671, 0x91D0, 0xC2E7,\r\n\t0x91D1, 0xAAF7, 0x91D3, 0xD0C1, 0x91D4, 0xD0C0, 0x91D5, 0xD442,\t0x91D7, 0xB078, 0x91D8, 0xB076, 0x91D9, 0xB07A, 0x91DA, 0xD444,\r\n\t0x91DC, 0xB079, 0x91DD, 0xB077, 0x91E2, 0xD443, 0x91E3, 0xB3A8,\t0x91E4, 0xD7FC, 0x91E6, 0xB3A7, 0x91E7, 0xB3A9, 0x91E8, 0xD842,\r\n\t0x91E9, 0xB3AB, 0x91EA, 0xD7FE, 0x91EB, 0xD840, 0x91EC, 0xD7F7,\t0x91ED, 0xB3AA, 0x91EE, 0xD843, 0x91F1, 0xD7F9, 0x91F3, 0xD7FA,\r\n\t0x91F4, 0xD7F8, 0x91F5, 0xB3A6, 0x91F7, 0xD841, 0x91F8, 0xD7FB,\t0x91F9, 0xD7FD, 0x91FD, 0xDC6D, 0x91FF, 0xDC6C, 0x9200, 0xDC6A,\r\n\t0x9201, 0xDC62, 0x9202, 0xDC71, 0x9203, 0xDC65, 0x9204, 0xDC6F,\t0x9205, 0xDC76, 0x9206, 0xDC6E, 0x9207, 0xB679, 0x9209, 0xB675,\r\n\t0x920A, 0xDC63, 0x920C, 0xDC69, 0x920D, 0xB677, 0x920F, 0xDC68,\t0x9210, 0xB678, 0x9211, 0xB67A, 0x9212, 0xDC6B, 0x9214, 0xB672,\r\n\t0x9215, 0xB673, 0x9216, 0xDC77, 0x9217, 0xDC75, 0x9219, 0xDC74,\t0x921A, 0xDC66, 0x921C, 0xDC72, 0x921E, 0xB676, 0x9223, 0xB674,\r\n\t0x9224, 0xDC73, 0x9225, 0xDC64, 0x9226, 0xDC67, 0x9227, 0xDC70,\t0x922D, 0xE4BA, 0x922E, 0xE0B7, 0x9230, 0xE0B0, 0x9231, 0xE0C3,\r\n\t0x9232, 0xE0CC, 0x9233, 0xE0B3, 0x9234, 0xB961, 0x9236, 0xE0C0,\t0x9237, 0xB957, 0x9238, 0xB959, 0x9239, 0xB965, 0x923A, 0xE0B1,\r\n\t0x923D, 0xB95A, 0x923E, 0xB95C, 0x923F, 0xB966, 0x9240, 0xB95B,\t0x9245, 0xB964, 0x9246, 0xE0B9, 0x9248, 0xE0AE, 0x9249, 0xB962,\r\n\t0x924A, 0xE0B8, 0x924B, 0xB95E, 0x924C, 0xE0CA, 0x924D, 0xB963,\t0x924E, 0xE0C8, 0x924F, 0xE0BC, 0x9250, 0xE0C6, 0x9251, 0xB960,\r\n\t0x9252, 0xE0AF, 0x9253, 0xE0C9, 0x9254, 0xE0C4, 0x9256, 0xE0CB,\t0x9257, 0xB958, 0x925A, 0xB967, 0x925B, 0xB95D, 0x925E, 0xE0B5,\r\n\t0x9260, 0xE0BD, 0x9261, 0xE0C1, 0x9263, 0xE0C5, 0x9264, 0xB95F,\t0x9265, 0xE0B4, 0x9266, 0xE0B2, 0x9267, 0xE0BE, 0x926C, 0xE0BB,\r\n\t0x926D, 0xE0BA, 0x926F, 0xE0BF, 0x9270, 0xE0C2, 0x9272, 0xE0C7,\t0x9276, 0xE478, 0x9278, 0xBBC7, 0x9279, 0xE4A4, 0x927A, 0xE47A,\r\n\t0x927B, 0xBBCC, 0x927C, 0xBBD0, 0x927D, 0xE4AD, 0x927E, 0xE4B5,\t0x927F, 0xE4A6, 0x9280, 0xBBC8, 0x9282, 0xE4AA, 0x9283, 0xE0B6,\r\n\t0x9285, 0xBBC9, 0x9286, 0xE4B1, 0x9287, 0xE4B6, 0x9288, 0xE4AE,\t0x928A, 0xE4B0, 0x928B, 0xE4B9, 0x928C, 0xE4B2, 0x928D, 0xE47E,\r\n\t0x928E, 0xE4A9, 0x9291, 0xBBD1, 0x9293, 0xBBCD, 0x9294, 0xE47C,\t0x9295, 0xE4AB, 0x9296, 0xBBCB, 0x9297, 0xE4A5, 0x9298, 0xBBCA,\r\n\t0x9299, 0xE4B3, 0x929A, 0xE4A2, 0x929B, 0xE479, 0x929C, 0xBBCE,\t0x929D, 0xE4B8, 0x92A0, 0xE47B, 0x92A1, 0xE4AF, 0x92A2, 0xE4AC,\r\n\t0x92A3, 0xE4A7, 0x92A4, 0xE477, 0x92A5, 0xE476, 0x92A6, 0xE4A1,\t0x92A7, 0xE4B4, 0x92A8, 0xBBCF, 0x92A9, 0xE4B7, 0x92AA, 0xE47D,\r\n\t0x92AB, 0xE4A3, 0x92AC, 0xBE52, 0x92B2, 0xBE5A, 0x92B3, 0xBE55,\t0x92B4, 0xE8A4, 0x92B5, 0xE8A1, 0x92B6, 0xE867, 0x92B7, 0xBE50,\r\n\t0x92B9, 0xF9D7, 0x92BB, 0xBE4F, 0x92BC, 0xBE56, 0x92C0, 0xE865,\t0x92C1, 0xBE54, 0x92C2, 0xE871, 0x92C3, 0xE863, 0x92C4, 0xE864,\r\n\t0x92C5, 0xBE4E, 0x92C6, 0xE8A3, 0x92C7, 0xBE58, 0x92C8, 0xE874,\t0x92C9, 0xE879, 0x92CA, 0xE873, 0x92CB, 0xEBEE, 0x92CC, 0xE86F,\r\n\t0x92CD, 0xE877, 0x92CE, 0xE875, 0x92CF, 0xE868, 0x92D0, 0xE862,\t0x92D1, 0xE87D, 0x92D2, 0xBE57, 0x92D3, 0xE87E, 0x92D5, 0xE878,\r\n\t0x92D7, 0xE86D, 0x92D8, 0xE86B, 0x92D9, 0xE866, 0x92DD, 0xE86E,\t0x92DE, 0xE87B, 0x92DF, 0xE86A, 0x92E0, 0xE87A, 0x92E1, 0xE8A2,\r\n\t0x92E4, 0xBE53, 0x92E6, 0xE876, 0x92E7, 0xE87C, 0x92E8, 0xE872,\t0x92E9, 0xE86C, 0x92EA, 0xBE51, 0x92EE, 0xE4A8, 0x92EF, 0xE870,\r\n\t0x92F0, 0xBE59, 0x92F1, 0xE869, 0x92F7, 0xEBF4, 0x92F8, 0xBFF7,\t0x92F9, 0xEBF3, 0x92FA, 0xEBF0, 0x92FB, 0xEC44, 0x92FC, 0xBFFB,\r\n\t0x92FE, 0xEC41, 0x92FF, 0xEBF8, 0x9300, 0xEC43, 0x9301, 0xEBE9,\t0x9302, 0xEBF6, 0x9304, 0xBFFD, 0x9306, 0xEBE1, 0x9308, 0xEBDF,\r\n\t0x9309, 0xEC42, 0x930B, 0xEC40, 0x930C, 0xEBFE, 0x930D, 0xEBED,\t0x930E, 0xEBEC, 0x930F, 0xEBE2, 0x9310, 0xC040, 0x9312, 0xEBE8,\r\n\t0x9313, 0xEBF2, 0x9314, 0xEBFD, 0x9315, 0xC043, 0x9316, 0xEC45,\t0x9318, 0xC1E8, 0x9319, 0xC045, 0x931A, 0xBFFE, 0x931B, 0xEBE6,\r\n\t0x931D, 0xEBEF, 0x931E, 0xEBDE, 0x931F, 0xEBE0, 0x9320, 0xBFF5,\t0x9321, 0xC042, 0x9322, 0xBFFA, 0x9323, 0xEBE7, 0x9324, 0xEBF7,\r\n\t0x9325, 0xEBF1, 0x9326, 0xC041, 0x9327, 0xEBDD, 0x9328, 0xC1E3,\t0x9329, 0xEBF9, 0x932A, 0xEBFC, 0x932B, 0xBFFC, 0x932D, 0xEBEB,\r\n\t0x932E, 0xC044, 0x932F, 0xBFF9, 0x9333, 0xBFF8, 0x9334, 0xEBF5,\t0x9335, 0xEBFB, 0x9336, 0xBFF6, 0x9338, 0xEBE4, 0x9339, 0xEBFA,\r\n\t0x933C, 0xEBE5, 0x9346, 0xEBEA, 0x9347, 0xEED2, 0x9349, 0xEED7,\t0x934A, 0xC1E5, 0x934B, 0xC1E7, 0x934C, 0xEEDD, 0x934D, 0xC1E1,\r\n\t0x934E, 0xEEEC, 0x934F, 0xEEE3, 0x9350, 0xEED8, 0x9351, 0xEED9,\t0x9352, 0xEEE2, 0x9354, 0xC1EE, 0x9355, 0xEEE1, 0x9356, 0xEED1,\r\n\t0x9357, 0xEEE0, 0x9358, 0xEED4, 0x9359, 0xEEED, 0x935A, 0xC1ED,\t0x935B, 0xC1EB, 0x935C, 0xEED5, 0x935E, 0xEEE8, 0x9360, 0xEEDA,\r\n\t0x9361, 0xEEE7, 0x9363, 0xEEE9, 0x9364, 0xEED0, 0x9365, 0xC1E6,\t0x9367, 0xEEEA, 0x936A, 0xEEDE, 0x936C, 0xC1EA, 0x936D, 0xEEDB,\r\n\t0x9370, 0xC1EC, 0x9371, 0xEEE4, 0x9375, 0xC1E4, 0x9376, 0xEED6,\t0x9377, 0xEEE5, 0x9379, 0xEEDF, 0x937A, 0xEBE3, 0x937B, 0xEEE6,\r\n\t0x937C, 0xEED3, 0x937E, 0xC1E9, 0x9380, 0xEEEB, 0x9382, 0xC1E2,\t0x9383, 0xEECE, 0x9388, 0xF160, 0x9389, 0xF159, 0x938A, 0xC2E9,\r\n\t0x938C, 0xF154, 0x938D, 0xF163, 0x938E, 0xF15B, 0x938F, 0xEEDC,\t0x9391, 0xF165, 0x9392, 0xF155, 0x9394, 0xC2E8, 0x9395, 0xF15F,\r\n\t0x9396, 0xC2EA, 0x9397, 0xC2F2, 0x9398, 0xC2F0, 0x9399, 0xF161,\t0x939A, 0xC2F1, 0x939B, 0xF157, 0x939D, 0xF158, 0x939E, 0xF15D,\r\n\t0x939F, 0xF162, 0x93A1, 0xEECD, 0x93A2, 0xC2EB, 0x93A3, 0xF16A,\t0x93A4, 0xF167, 0x93A5, 0xF16B, 0x93A6, 0xF15E, 0x93A7, 0xF15A,\r\n\t0x93A8, 0xF168, 0x93A9, 0xF36A, 0x93AA, 0xF15C, 0x93AC, 0xC2EE,\t0x93AE, 0xC2ED, 0x93AF, 0xEECF, 0x93B0, 0xC2EF, 0x93B1, 0xF164,\r\n\t0x93B2, 0xF166, 0x93B3, 0xC2EC, 0x93B4, 0xF169, 0x93B5, 0xF153,\t0x93B7, 0xF156, 0x93C0, 0xF373, 0x93C2, 0xF363, 0x93C3, 0xC3EB,\r\n\t0x93C4, 0xF371, 0x93C7, 0xF361, 0x93C8, 0xC3EC, 0x93CA, 0xF36C,\t0x93CC, 0xF368, 0x93CD, 0xC3F1, 0x93CE, 0xF372, 0x93CF, 0xF362,\r\n\t0x93D0, 0xF365, 0x93D1, 0xC3E9, 0x93D2, 0xF374, 0x93D4, 0xF36D,\t0x93D5, 0xF370, 0x93D6, 0xC3EF, 0x93D7, 0xC3F4, 0x93D8, 0xC3F2,\r\n\t0x93D9, 0xF369, 0x93DA, 0xF364, 0x93DC, 0xC3ED, 0x93DD, 0xC3EE,\t0x93DE, 0xF360, 0x93DF, 0xC3EA, 0x93E1, 0xC3E8, 0x93E2, 0xC3F0,\r\n\t0x93E3, 0xF36F, 0x93E4, 0xC3F3, 0x93E6, 0xF36B, 0x93E7, 0xF375,\t0x93E8, 0xC3F5, 0x93EC, 0xF367, 0x93EE, 0xF36E, 0x93F5, 0xF4F3,\r\n\t0x93F6, 0xF542, 0x93F7, 0xF4F5, 0x93F8, 0xF4FC, 0x93F9, 0xF366,\t0x93FA, 0xF4FA, 0x93FB, 0xF4E9, 0x93FC, 0xF540, 0x93FD, 0xC4C3,\r\n\t0x93FE, 0xF4ED, 0x93FF, 0xF4FE, 0x9400, 0xF4F4, 0x9403, 0xC4C2,\t0x9406, 0xF544, 0x9407, 0xF4F6, 0x9409, 0xF4FB, 0x940A, 0xF4FD,\r\n\t0x940B, 0xF4E7, 0x940C, 0xF541, 0x940D, 0xF4F2, 0x940E, 0xF4F7,\t0x940F, 0xF4EB, 0x9410, 0xF4EF, 0x9411, 0xF543, 0x9412, 0xF4F9,\r\n\t0x9413, 0xF4E8, 0x9414, 0xF4EC, 0x9415, 0xF4EE, 0x9416, 0xF4F8,\t0x9418, 0xC4C1, 0x9419, 0xF4F1, 0x9420, 0xF4EA, 0x9428, 0xF4F0,\r\n\t0x9429, 0xF661, 0x942A, 0xF666, 0x942B, 0xC54F, 0x942C, 0xF668,\t0x942E, 0xC549, 0x9430, 0xF664, 0x9431, 0xF66A, 0x9432, 0xC54E,\r\n\t0x9433, 0xC54A, 0x9435, 0xC54B, 0x9436, 0xF660, 0x9437, 0xF667,\t0x9438, 0xC54D, 0x9439, 0xF665, 0x943A, 0xC54C, 0x943B, 0xF65F,\r\n\t0x943C, 0xF663, 0x943D, 0xF662, 0x943F, 0xF65E, 0x9440, 0xF669,\t0x9444, 0xC5B1, 0x9445, 0xF76D, 0x9446, 0xF770, 0x9447, 0xF76C,\r\n\t0x9448, 0xF76E, 0x9449, 0xF76F, 0x944A, 0xF769, 0x944B, 0xF76A,\t0x944C, 0xF767, 0x944F, 0xF76B, 0x9450, 0xF768, 0x9451, 0xC5B2,\r\n\t0x9452, 0xC5B3, 0x9455, 0xF84B, 0x9457, 0xF84D, 0x945D, 0xF84C,\t0x945E, 0xF84E, 0x9460, 0xC5E0, 0x9462, 0xF84A, 0x9463, 0xC5DF,\r\n\t0x9464, 0xC5E1, 0x9468, 0xF8CB, 0x9469, 0xF8CC, 0x946A, 0xC644,\t0x946B, 0xF8CA, 0x946D, 0xF953, 0x946E, 0xF952, 0x946F, 0xF954,\r\n\t0x9470, 0xC65F, 0x9471, 0xF955, 0x9472, 0xC65E, 0x9473, 0xF956,\t0x9474, 0xF972, 0x9475, 0xF975, 0x9476, 0xF974, 0x9477, 0xC668,\r\n\t0x9478, 0xF973, 0x947C, 0xC672, 0x947D, 0xC670, 0x947E, 0xC671,\t0x947F, 0xC677, 0x9480, 0xF9C0, 0x9481, 0xF9C1, 0x9482, 0xF9BF,\r\n\t0x9483, 0xF9C9, 0x9577, 0xAAF8, 0x957A, 0xD844, 0x957B, 0xDC78,\t0x957C, 0xE8A5, 0x957D, 0xF376, 0x9580, 0xAAF9, 0x9582, 0xADAC,\r\n\t0x9583, 0xB07B, 0x9586, 0xD845, 0x9588, 0xD846, 0x9589, 0xB3AC,\t0x958B, 0xB67D, 0x958C, 0xDC7A, 0x958D, 0xDC79, 0x958E, 0xB6A3,\r\n\t0x958F, 0xB67C, 0x9590, 0xDC7B, 0x9591, 0xB67E, 0x9592, 0xB6A2,\t0x9593, 0xB6A1, 0x9594, 0xB67B, 0x9598, 0xB968, 0x959B, 0xE0D0,\r\n\t0x959C, 0xE0CE, 0x959E, 0xE0CF, 0x959F, 0xE0CD, 0x95A1, 0xBBD2,\t0x95A3, 0xBBD5, 0x95A4, 0xBBD7, 0x95A5, 0xBBD6, 0x95A8, 0xBBD3,\r\n\t0x95A9, 0xBBD4, 0x95AB, 0xE8A7, 0x95AC, 0xE8A6, 0x95AD, 0xBE5B,\t0x95AE, 0xE8A8, 0x95B0, 0xE8A9, 0x95B1, 0xBE5C, 0x95B5, 0xEC4D,\r\n\t0x95B6, 0xEC4B, 0x95B7, 0xEEF3, 0x95B9, 0xEC49, 0x95BA, 0xEC4A,\t0x95BB, 0xC046, 0x95BC, 0xEC46, 0x95BD, 0xEC4E, 0x95BE, 0xEC48,\r\n\t0x95BF, 0xEC4C, 0x95C0, 0xEEEF, 0x95C3, 0xEEF1, 0x95C5, 0xEEF2,\t0x95C6, 0xC1F3, 0x95C7, 0xEEEE, 0x95C8, 0xC1F2, 0x95C9, 0xEEF0,\r\n\t0x95CA, 0xC1EF, 0x95CB, 0xC1F0, 0x95CC, 0xC1F1, 0x95CD, 0xEC47,\t0x95D0, 0xC2F5, 0x95D1, 0xF16E, 0x95D2, 0xF16C, 0x95D3, 0xF16D,\r\n\t0x95D4, 0xC2F3, 0x95D5, 0xC2F6, 0x95D6, 0xC2F4, 0x95DA, 0xF377,\t0x95DB, 0xF378, 0x95DC, 0xC3F6, 0x95DE, 0xF545, 0x95DF, 0xF547,\r\n\t0x95E0, 0xF546, 0x95E1, 0xC4C4, 0x95E2, 0xC550, 0x95E3, 0xF66D,\t0x95E4, 0xF66C, 0x95E5, 0xF66B, 0x961C, 0xAAFA, 0x961E, 0xC9AA,\r\n\t0x9620, 0xCA58, 0x9621, 0xA6E9, 0x9622, 0xCA56, 0x9623, 0xCA59,\t0x9624, 0xCA57, 0x9628, 0xCBAE, 0x962A, 0xA8C1, 0x962C, 0xA8C2,\r\n\t0x962D, 0xCBB0, 0x962E, 0xA8BF, 0x962F, 0xCBAF, 0x9630, 0xCBAD,\t0x9631, 0xA8C0, 0x9632, 0xA8BE, 0x9639, 0xCDD8, 0x963A, 0xCDDB,\r\n\t0x963B, 0xAAFD, 0x963C, 0xCDDA, 0x963D, 0xCDD9, 0x963F, 0xAAFC,\t0x9640, 0xAAFB, 0x9642, 0xAB40, 0x9643, 0xCDDC, 0x9644, 0xAAFE,\r\n\t0x964A, 0xD0C6, 0x964B, 0xADAE, 0x964C, 0xADAF, 0x964D, 0xADB0,\t0x964E, 0xD0C7, 0x964F, 0xD0C3, 0x9650, 0xADAD, 0x9651, 0xD0C4,\r\n\t0x9653, 0xD0C5, 0x9654, 0xD0C2, 0x9658, 0xB0A4, 0x965B, 0xB0A1,\t0x965C, 0xD445, 0x965D, 0xB0A2, 0x965E, 0xB0A5, 0x965F, 0xD446,\r\n\t0x9661, 0xB07E, 0x9662, 0xB07C, 0x9663, 0xB07D, 0x9664, 0xB0A3,\t0x966A, 0xB3AD, 0x966B, 0xD849, 0x966C, 0xB3B5, 0x966D, 0xD848,\r\n\t0x966F, 0xD84B, 0x9670, 0xB3B1, 0x9671, 0xD84A, 0x9672, 0xB6AB,\t0x9673, 0xB3AF, 0x9674, 0xB3B2, 0x9675, 0xB3AE, 0x9676, 0xB3B3,\r\n\t0x9677, 0xB3B4, 0x9678, 0xB3B0, 0x967C, 0xD847, 0x967D, 0xB6A7,\t0x967E, 0xDC7D, 0x9680, 0xDCA3, 0x9683, 0xDCA2, 0x9684, 0xB6AC,\r\n\t0x9685, 0xB6A8, 0x9686, 0xB6A9, 0x9687, 0xDC7C, 0x9688, 0xDC7E,\t0x9689, 0xDCA1, 0x968A, 0xB6A4, 0x968B, 0xB6A6, 0x968D, 0xB6AA,\r\n\t0x968E, 0xB6A5, 0x9691, 0xE0D3, 0x9692, 0xE0D1, 0x9693, 0xE0D2,\t0x9694, 0xB96A, 0x9695, 0xB96B, 0x9697, 0xE0D4, 0x9698, 0xB969,\r\n\t0x9699, 0xBBD8, 0x969B, 0xBBDA, 0x969C, 0xBBD9, 0x969E, 0xE4BB,\t0x96A1, 0xE4BC, 0x96A2, 0xE8AB, 0x96A4, 0xE8AA, 0x96A7, 0xC047,\r\n\t0x96A8, 0xC048, 0x96A9, 0xEC4F, 0x96AA, 0xC049, 0x96AC, 0xEEF6,\t0x96AE, 0xEEF4, 0x96B0, 0xEEF5, 0x96B1, 0xC1F4, 0x96B3, 0xF16F,\r\n\t0x96B4, 0xC3F7, 0x96B8, 0xC1F5, 0x96B9, 0xAB41, 0x96BB, 0xB0A6,\t0x96BC, 0xD447, 0x96BF, 0xD84C, 0x96C0, 0xB3B6, 0x96C1, 0xB6AD,\r\n\t0x96C2, 0xDCA4, 0x96C3, 0xDCA6, 0x96C4, 0xB6AF, 0x96C5, 0xB6AE,\t0x96C6, 0xB6B0, 0x96C7, 0xB6B1, 0x96C8, 0xDCA5, 0x96C9, 0xB96E,\r\n\t0x96CA, 0xB96F, 0x96CB, 0xB96D, 0x96CC, 0xBBDB, 0x96CD, 0xB96C,\t0x96CE, 0xE0D5, 0x96D2, 0xBBDC, 0x96D3, 0xE8AC, 0x96D4, 0xEC50,\r\n\t0x96D5, 0xC04A, 0x96D6, 0xC1F6, 0x96D7, 0xF170, 0x96D8, 0xF174,\t0x96D9, 0xC2F9, 0x96DA, 0xF171, 0x96DB, 0xC2FA, 0x96DC, 0xC2F8,\r\n\t0x96DD, 0xF175, 0x96DE, 0xC2FB, 0x96DF, 0xF173, 0x96E1, 0xF379,\t0x96E2, 0xC2F7, 0x96E3, 0xC3F8, 0x96E5, 0xF8CD, 0x96E8, 0xAB42,\r\n\t0x96E9, 0xB3B8, 0x96EA, 0xB3B7, 0x96EF, 0xB6B2, 0x96F0, 0xDCA8,\t0x96F1, 0xDCA7, 0x96F2, 0xB6B3, 0x96F5, 0xE0D9, 0x96F6, 0xB973,\r\n\t0x96F7, 0xB970, 0x96F8, 0xE0D8, 0x96F9, 0xB972, 0x96FA, 0xE0D6,\t0x96FB, 0xB971, 0x96FD, 0xE0D7, 0x96FF, 0xE4BD, 0x9700, 0xBBDD,\r\n\t0x9702, 0xE8AF, 0x9704, 0xBE5D, 0x9705, 0xE8AD, 0x9706, 0xBE5E,\t0x9707, 0xBE5F, 0x9708, 0xE8AE, 0x9709, 0xBE60, 0x970B, 0xEC51,\r\n\t0x970D, 0xC04E, 0x970E, 0xC04B, 0x970F, 0xC050, 0x9710, 0xEC53,\t0x9711, 0xC04C, 0x9712, 0xEC52, 0x9713, 0xC04F, 0x9716, 0xC04D,\r\n\t0x9718, 0xEEF9, 0x9719, 0xEEFB, 0x971C, 0xC1F7, 0x971D, 0xEEFA,\t0x971E, 0xC1F8, 0x971F, 0xEEF8, 0x9720, 0xEEF7, 0x9722, 0xF177,\r\n\t0x9723, 0xF176, 0x9724, 0xC2FC, 0x9725, 0xF178, 0x9726, 0xF37E,\t0x9727, 0xC3FA, 0x9728, 0xF37D, 0x9729, 0xF37A, 0x972A, 0xC3F9,\r\n\t0x972B, 0xF37B, 0x972C, 0xF37C, 0x972E, 0xF548, 0x972F, 0xF549,\t0x9730, 0xC4C5, 0x9732, 0xC553, 0x9735, 0xF66E, 0x9738, 0xC551,\r\n\t0x9739, 0xC552, 0x973A, 0xF66F, 0x973D, 0xC5B4, 0x973E, 0xC5B5,\t0x973F, 0xF771, 0x9742, 0xC645, 0x9743, 0xF8CF, 0x9744, 0xC647,\r\n\t0x9746, 0xF8CE, 0x9747, 0xF8D0, 0x9748, 0xC646, 0x9749, 0xF957,\t0x974B, 0xF9AD, 0x9752, 0xAB43, 0x9756, 0xB974, 0x9758, 0xE4BE,\r\n\t0x975A, 0xE8B0, 0x975B, 0xC051, 0x975C, 0xC052, 0x975E, 0xAB44,\t0x9760, 0xBE61, 0x9761, 0xC3FB, 0x9762, 0xADB1, 0x9766, 0xC053,\r\n\t0x9768, 0xC5E2, 0x9769, 0xADB2, 0x976A, 0xD84D, 0x976C, 0xDCA9,\t0x976E, 0xDCAB, 0x9770, 0xDCAA, 0x9772, 0xE0DD, 0x9773, 0xE0DA,\r\n\t0x9774, 0xB975, 0x9776, 0xB976, 0x9777, 0xE0DB, 0x9778, 0xE0DC,\t0x977A, 0xE4C0, 0x977B, 0xE4C5, 0x977C, 0xBBDE, 0x977D, 0xE4BF,\r\n\t0x977E, 0xE4C1, 0x977F, 0xE4C8, 0x9780, 0xE4C3, 0x9781, 0xE4C7,\t0x9782, 0xE4C4, 0x9783, 0xE4C2, 0x9784, 0xE4C6, 0x9785, 0xBBDF,\r\n\t0x9788, 0xE8B3, 0x978A, 0xE8B1, 0x978B, 0xBE63, 0x978D, 0xBE62,\t0x978E, 0xE8B2, 0x978F, 0xBE64, 0x9794, 0xEC56, 0x9797, 0xEC55,\r\n\t0x9798, 0xC054, 0x9799, 0xEC54, 0x979A, 0xEEFC, 0x979C, 0xEEFE,\t0x979D, 0xEF41, 0x979E, 0xEF40, 0x97A0, 0xC1F9, 0x97A1, 0xEEFD,\r\n\t0x97A2, 0xF1A1, 0x97A3, 0xC2FD, 0x97A4, 0xF17D, 0x97A5, 0xF1A2,\t0x97A6, 0xC2FE, 0x97A8, 0xF17B, 0x97AA, 0xF17E, 0x97AB, 0xF17C,\r\n\t0x97AC, 0xF179, 0x97AD, 0xC340, 0x97AE, 0xF17A, 0x97B3, 0xF3A1,\t0x97B6, 0xF3A3, 0x97B7, 0xF3A2, 0x97B9, 0xF54A, 0x97BB, 0xF54B,\r\n\t0x97BF, 0xF670, 0x97C1, 0xC5B7, 0x97C3, 0xC5B6, 0x97C4, 0xF84F,\t0x97C5, 0xF850, 0x97C6, 0xC648, 0x97C7, 0xF8D1, 0x97C9, 0xC669,\r\n\t0x97CB, 0xADB3, 0x97CC, 0xB6B4, 0x97CD, 0xE4CA, 0x97CE, 0xE4C9,\t0x97CF, 0xE8B5, 0x97D0, 0xE8B4, 0x97D3, 0xC1FA, 0x97D4, 0xEF43,\r\n\t0x97D5, 0xEF42, 0x97D6, 0xF1A5, 0x97D7, 0xF1A3, 0x97D8, 0xF1A6,\t0x97D9, 0xF1A4, 0x97DC, 0xC3FC, 0x97DD, 0xF3A4, 0x97DE, 0xF3A5,\r\n\t0x97DF, 0xF3A6, 0x97E1, 0xF671, 0x97E3, 0xF772, 0x97E5, 0xF8D2,\t0x97ED, 0xADB4, 0x97F0, 0xEC57, 0x97F1, 0xEF44, 0x97F3, 0xADB5,\r\n\t0x97F6, 0xBBE0, 0x97F8, 0xEC58, 0x97F9, 0xC341, 0x97FA, 0xF1A7,\t0x97FB, 0xC3FD, 0x97FD, 0xF54C, 0x97FE, 0xF54D, 0x97FF, 0xC554,\r\n\t0x9800, 0xF851, 0x9801, 0xADB6, 0x9802, 0xB3BB, 0x9803, 0xB3BC,\t0x9804, 0xD84E, 0x9805, 0xB6B5, 0x9806, 0xB6B6, 0x9807, 0xDCAC,\r\n\t0x9808, 0xB6B7, 0x980A, 0xB97A, 0x980C, 0xB97C, 0x980D, 0xE0DF,\t0x980E, 0xE0E0, 0x980F, 0xE0DE, 0x9810, 0xB977, 0x9811, 0xB978,\r\n\t0x9812, 0xB97B, 0x9813, 0xB979, 0x9816, 0xE4CB, 0x9817, 0xBBE1,\t0x9818, 0xBBE2, 0x981B, 0xE8BC, 0x981C, 0xBE67, 0x981D, 0xE8B7,\r\n\t0x981E, 0xE8B6, 0x9820, 0xE8BB, 0x9821, 0xBE65, 0x9824, 0xC05B,\t0x9826, 0xE8B8, 0x9827, 0xE8BD, 0x9828, 0xE8BA, 0x9829, 0xE8B9,\r\n\t0x982B, 0xBE66, 0x982D, 0xC059, 0x982F, 0xEC5A, 0x9830, 0xC055,\t0x9832, 0xEC5B, 0x9835, 0xEC59, 0x9837, 0xC058, 0x9838, 0xC056,\r\n\t0x9839, 0xC05A, 0x983B, 0xC057, 0x9841, 0xEF45, 0x9843, 0xEF4A,\t0x9844, 0xEF46, 0x9845, 0xEF49, 0x9846, 0xC1FB, 0x9848, 0xEDD4,\r\n\t0x9849, 0xEF48, 0x984A, 0xEF47, 0x984C, 0xC344, 0x984D, 0xC342,\t0x984E, 0xC345, 0x984F, 0xC343, 0x9850, 0xF1A8, 0x9851, 0xF1A9,\r\n\t0x9852, 0xF1AA, 0x9853, 0xC346, 0x9857, 0xF3AA, 0x9858, 0xC440,\t0x9859, 0xF3A8, 0x985B, 0xC441, 0x985C, 0xF3A7, 0x985D, 0xF3A9,\r\n\t0x985E, 0xC3FE, 0x985F, 0xF551, 0x9860, 0xF54E, 0x9862, 0xF54F,\t0x9863, 0xF550, 0x9864, 0xF672, 0x9865, 0xC556, 0x9867, 0xC555,\r\n\t0x9869, 0xF774, 0x986A, 0xF773, 0x986B, 0xC5B8, 0x986F, 0xC5E3,\t0x9870, 0xC649, 0x9871, 0xC660, 0x9872, 0xF958, 0x9873, 0xF9AE,\r\n\t0x9874, 0xF9AF, 0x98A8, 0xADB7, 0x98A9, 0xDCAD, 0x98AC, 0xE0E1,\t0x98AD, 0xE4CC, 0x98AE, 0xE4CD, 0x98AF, 0xBBE3, 0x98B1, 0xBBE4,\r\n\t0x98B2, 0xE8BE, 0x98B3, 0xBE68, 0x98B6, 0xC1FC, 0x98B8, 0xF1AB,\t0x98BA, 0xC347, 0x98BB, 0xF3AD, 0x98BC, 0xC442, 0x98BD, 0xF3AC,\r\n\t0x98BE, 0xF3AE, 0x98BF, 0xF3AB, 0x98C0, 0xF675, 0x98C1, 0xF552,\t0x98C2, 0xF553, 0x98C4, 0xC4C6, 0x98C6, 0xF674, 0x98C9, 0xF673,\r\n\t0x98CB, 0xF775, 0x98CC, 0xF9B0, 0x98DB, 0xADB8, 0x98DF, 0xADB9,\t0x98E2, 0xB0A7, 0x98E3, 0xD448, 0x98E5, 0xD84F, 0x98E7, 0xB6B8,\r\n\t0x98E9, 0xB6BB, 0x98EA, 0xB6B9, 0x98EB, 0xDCAE, 0x98ED, 0xB6BD,\t0x98EF, 0xB6BA, 0x98F2, 0xB6BC, 0x98F4, 0xB97E, 0x98F6, 0xE0E2,\r\n\t0x98F9, 0xE0E3, 0x98FA, 0xE8C0, 0x98FC, 0xB97D, 0x98FD, 0xB9A1,\t0x98FE, 0xB9A2, 0x9900, 0xE4CF, 0x9902, 0xE4CE, 0x9903, 0xBBE5,\r\n\t0x9905, 0xBBE6, 0x9907, 0xE4D0, 0x9908, 0xE8BF, 0x9909, 0xBBE8,\t0x990A, 0xBE69, 0x990C, 0xBBE7, 0x9910, 0xC05C, 0x9911, 0xE8C1,\r\n\t0x9912, 0xBE6B, 0x9913, 0xBE6A, 0x9914, 0xE8C2, 0x9915, 0xE8C5,\t0x9916, 0xE8C3, 0x9917, 0xE8C4, 0x9918, 0xBE6C, 0x991A, 0xC061,\r\n\t0x991B, 0xC05F, 0x991E, 0xC05E, 0x991F, 0xEC5D, 0x9921, 0xC060,\t0x9924, 0xEC5C, 0x9925, 0xEF4B, 0x9927, 0xEC5E, 0x9928, 0xC05D,\r\n\t0x9929, 0xEC5F, 0x992A, 0xEF4E, 0x992B, 0xEF4C, 0x992C, 0xEF4D,\t0x992D, 0xEF52, 0x992E, 0xC34B, 0x992F, 0xEF51, 0x9930, 0xEF54,\r\n\t0x9931, 0xEF53, 0x9932, 0xEF50, 0x9933, 0xEF4F, 0x9935, 0xC1FD,\t0x993A, 0xF1AE, 0x993C, 0xF1AD, 0x993D, 0xC34A, 0x993E, 0xC348,\r\n\t0x993F, 0xC349, 0x9941, 0xF1AC, 0x9943, 0xF3B1, 0x9945, 0xC443,\t0x9947, 0xF3B0, 0x9948, 0xF3AF, 0x9949, 0xC444, 0x994B, 0xF558,\r\n\t0x994C, 0xF557, 0x994E, 0xF555, 0x9950, 0xF554, 0x9951, 0xC4C8,\t0x9952, 0xC4C7, 0x9953, 0xF559, 0x9954, 0xF776, 0x9955, 0xC5B9,\r\n\t0x9956, 0xF677, 0x9957, 0xC557, 0x9958, 0xF676, 0x9959, 0xF556,\t0x995B, 0xF777, 0x995C, 0xC5E4, 0x995E, 0xC661, 0x995F, 0xF959,\r\n\t0x9961, 0xF9B1, 0x9996, 0xADBA, 0x9997, 0xD850, 0x9998, 0xEF55,\t0x9999, 0xADBB, 0x999C, 0xE4D2, 0x999D, 0xE4D1, 0x999E, 0xEC60,\r\n\t0x99A1, 0xEF57, 0x99A3, 0xEF56, 0x99A5, 0xC34C, 0x99A6, 0xF3B2,\t0x99A7, 0xF3B3, 0x99A8, 0xC4C9, 0x99AB, 0xF9B2, 0x99AC, 0xB0A8,\r\n\t0x99AD, 0xB6BF, 0x99AE, 0xB6BE, 0x99AF, 0xE0E4, 0x99B0, 0xE0E6,\t0x99B1, 0xB9A4, 0x99B2, 0xE0E5, 0x99B3, 0xB9A3, 0x99B4, 0xB9A5,\r\n\t0x99B5, 0xE0E7, 0x99B9, 0xE4D4, 0x99BA, 0xE4D6, 0x99BB, 0xE4D5,\t0x99BD, 0xE4D8, 0x99C1, 0xBBE9, 0x99C2, 0xE4D7, 0x99C3, 0xE4D3,\r\n\t0x99C7, 0xE4D9, 0x99C9, 0xE8CC, 0x99CB, 0xE8CF, 0x99CC, 0xE8D1,\t0x99CD, 0xE8C7, 0x99CE, 0xE8CB, 0x99CF, 0xE8C8, 0x99D0, 0xBE6E,\r\n\t0x99D1, 0xBE71, 0x99D2, 0xBE73, 0x99D3, 0xE8C9, 0x99D4, 0xE8CA,\t0x99D5, 0xBE72, 0x99D6, 0xE8CD, 0x99D7, 0xE8D0, 0x99D8, 0xE8CE,\r\n\t0x99D9, 0xBE74, 0x99DB, 0xBE70, 0x99DC, 0xE8C6, 0x99DD, 0xBE6D,\t0x99DF, 0xBE6F, 0x99E2, 0xC063, 0x99E3, 0xEC66, 0x99E4, 0xEC64,\r\n\t0x99E5, 0xEC63, 0x99E7, 0xEC69, 0x99E9, 0xEC68, 0x99EA, 0xEC67,\t0x99EC, 0xEC62, 0x99ED, 0xC062, 0x99EE, 0xEC61, 0x99F0, 0xEC65,\r\n\t0x99F1, 0xC064, 0x99F4, 0xEF5A, 0x99F6, 0xEF5E, 0x99F7, 0xEF5B,\t0x99F8, 0xEF5D, 0x99F9, 0xEF5C, 0x99FA, 0xEF59, 0x99FB, 0xEF5F,\r\n\t0x99FC, 0xEF62, 0x99FD, 0xEF60, 0x99FE, 0xEF61, 0x99FF, 0xC240,\t0x9A01, 0xC1FE, 0x9A02, 0xEF58, 0x9A03, 0xEF63, 0x9A04, 0xF1B3,\r\n\t0x9A05, 0xF1B6, 0x9A06, 0xF1B8, 0x9A07, 0xF1B7, 0x9A09, 0xF1B1,\t0x9A0A, 0xF1B5, 0x9A0B, 0xF1B0, 0x9A0D, 0xF1B2, 0x9A0E, 0xC34D,\r\n\t0x9A0F, 0xF1AF, 0x9A11, 0xF1B4, 0x9A14, 0xF3C0, 0x9A15, 0xF3B5,\t0x9A16, 0xC445, 0x9A19, 0xC446, 0x9A1A, 0xF3B4, 0x9A1B, 0xF3B9,\r\n\t0x9A1C, 0xF3BF, 0x9A1D, 0xF3B7, 0x9A1E, 0xF3BE, 0x9A20, 0xF3BB,\t0x9A22, 0xF3BA, 0x9A23, 0xF3BD, 0x9A24, 0xF3B8, 0x9A25, 0xF3B6,\r\n\t0x9A27, 0xF3BC, 0x9A29, 0xF560, 0x9A2A, 0xF55E, 0x9A2B, 0xC4CA,\t0x9A2C, 0xF55D, 0x9A2D, 0xF563, 0x9A2E, 0xF561, 0x9A30, 0xC4CB,\r\n\t0x9A31, 0xF55C, 0x9A32, 0xF55A, 0x9A34, 0xF55B, 0x9A35, 0xC4CD,\t0x9A36, 0xF55F, 0x9A37, 0xC4CC, 0x9A38, 0xF562, 0x9A39, 0xF678,\r\n\t0x9A3A, 0xF67E, 0x9A3D, 0xF679, 0x9A3E, 0xC55B, 0x9A3F, 0xF6A1,\t0x9A40, 0xC55A, 0x9A41, 0xF67D, 0x9A42, 0xF67C, 0x9A43, 0xC559,\r\n\t0x9A44, 0xF67B, 0x9A45, 0xC558, 0x9A46, 0xF67A, 0x9A48, 0xF77D,\t0x9A49, 0xF7A1, 0x9A4A, 0xF77E, 0x9A4C, 0xF77B, 0x9A4D, 0xC5BB,\r\n\t0x9A4E, 0xF778, 0x9A4F, 0xF77C, 0x9A50, 0xF7A3, 0x9A52, 0xF7A2,\t0x9A53, 0xF779, 0x9A54, 0xF77A, 0x9A55, 0xC5BA, 0x9A56, 0xF852,\r\n\t0x9A57, 0xC5E7, 0x9A59, 0xF853, 0x9A5A, 0xC5E5, 0x9A5B, 0xC5E6,\t0x9A5E, 0xF8D3, 0x9A5F, 0xC64A, 0x9A60, 0xF976, 0x9A62, 0xC66A,\r\n\t0x9A64, 0xF9B3, 0x9A65, 0xC66B, 0x9A66, 0xF9B4, 0x9A67, 0xF9B5,\t0x9A68, 0xF9C3, 0x9A69, 0xF9C2, 0x9A6A, 0xC67A, 0x9A6B, 0xF9CD,\r\n\t0x9AA8, 0xB0A9, 0x9AAB, 0xE0E9, 0x9AAD, 0xE0E8, 0x9AAF, 0xBBEA,\t0x9AB0, 0xBBEB, 0x9AB1, 0xE4DA, 0x9AB3, 0xE8D2, 0x9AB4, 0xEC6C,\r\n\t0x9AB7, 0xBE75, 0x9AB8, 0xC065, 0x9AB9, 0xEC6A, 0x9ABB, 0xEC6D,\t0x9ABC, 0xC066, 0x9ABE, 0xEF64, 0x9ABF, 0xEC6B, 0x9AC0, 0xF1B9,\r\n\t0x9AC1, 0xC34E, 0x9AC2, 0xF3C1, 0x9AC6, 0xF566, 0x9AC7, 0xF564,\t0x9ACA, 0xF565, 0x9ACD, 0xF6A2, 0x9ACF, 0xC55C, 0x9AD0, 0xF7A4,\r\n\t0x9AD1, 0xC5EA, 0x9AD2, 0xC5BC, 0x9AD3, 0xC5E8, 0x9AD4, 0xC5E9,\t0x9AD5, 0xF8D4, 0x9AD6, 0xC662, 0x9AD8, 0xB0AA, 0x9ADC, 0xF1BA,\r\n\t0x9ADF, 0xD449, 0x9AE1, 0xB9A6, 0x9AE3, 0xE4DB, 0x9AE6, 0xBBEC,\t0x9AE7, 0xE4DC, 0x9AEB, 0xE8D4, 0x9AEC, 0xE8D3, 0x9AED, 0xC068,\r\n\t0x9AEE, 0xBE76, 0x9AEF, 0xBE77, 0x9AF1, 0xE8D7, 0x9AF2, 0xE8D6,\t0x9AF3, 0xE8D5, 0x9AF6, 0xEC6E, 0x9AF7, 0xEC71, 0x9AF9, 0xEC70,\r\n\t0x9AFA, 0xEC6F, 0x9AFB, 0xC067, 0x9AFC, 0xEF68, 0x9AFD, 0xEF66,\t0x9AFE, 0xEF65, 0x9B01, 0xEF67, 0x9B03, 0xC34F, 0x9B04, 0xF1BC,\r\n\t0x9B05, 0xF1BD, 0x9B06, 0xC350, 0x9B08, 0xF1BB, 0x9B0A, 0xF3C3,\t0x9B0B, 0xF3C2, 0x9B0C, 0xF3C5, 0x9B0D, 0xC447, 0x9B0E, 0xF3C4,\r\n\t0x9B10, 0xF567, 0x9B11, 0xF569, 0x9B12, 0xF568, 0x9B15, 0xF6A3,\t0x9B16, 0xF6A6, 0x9B17, 0xF6A4, 0x9B18, 0xF6A5, 0x9B19, 0xF7A5,\r\n\t0x9B1A, 0xC5BD, 0x9B1E, 0xF854, 0x9B1F, 0xF855, 0x9B20, 0xF856,\t0x9B22, 0xC64B, 0x9B23, 0xC663, 0x9B24, 0xF9B6, 0x9B25, 0xB0AB,\r\n\t0x9B27, 0xBE78, 0x9B28, 0xC069, 0x9B29, 0xF1BE, 0x9B2B, 0xF7A6,\t0x9B2E, 0xF9C4, 0x9B2F, 0xD44A, 0x9B31, 0xC67B, 0x9B32, 0xB0AC,\r\n\t0x9B33, 0xEC72, 0x9B35, 0xF1BF, 0x9B37, 0xF3C6, 0x9B3A, 0xF6A7,\t0x9B3B, 0xF7A7, 0x9B3C, 0xB0AD, 0x9B3E, 0xE4DD, 0x9B3F, 0xE4DE,\r\n\t0x9B41, 0xBBED, 0x9B42, 0xBBEE, 0x9B43, 0xE8D9, 0x9B44, 0xBE7A,\t0x9B45, 0xBE79, 0x9B46, 0xE8D8, 0x9B48, 0xEF69, 0x9B4A, 0xF1C0,\r\n\t0x9B4B, 0xF1C2, 0x9B4C, 0xF1C1, 0x9B4D, 0xC353, 0x9B4E, 0xC352,\t0x9B4F, 0xC351, 0x9B51, 0xC55E, 0x9B52, 0xF6A8, 0x9B54, 0xC55D,\r\n\t0x9B55, 0xF7A9, 0x9B56, 0xF7A8, 0x9B58, 0xC64C, 0x9B59, 0xF8D5,\t0x9B5A, 0xB3BD, 0x9B5B, 0xE0EA, 0x9B5F, 0xE4E1, 0x9B60, 0xE4DF,\r\n\t0x9B61, 0xE4E0, 0x9B64, 0xE8E2, 0x9B66, 0xE8DD, 0x9B67, 0xE8DA,\t0x9B68, 0xE8E1, 0x9B6C, 0xE8E3, 0x9B6F, 0xBE7C, 0x9B70, 0xE8E0,\r\n\t0x9B71, 0xE8DC, 0x9B74, 0xE8DB, 0x9B75, 0xE8DF, 0x9B76, 0xE8DE,\t0x9B77, 0xBE7B, 0x9B7A, 0xEC7D, 0x9B7B, 0xEC78, 0x9B7C, 0xEC76,\r\n\t0x9B7D, 0xECA1, 0x9B7E, 0xEC77, 0x9B80, 0xEC73, 0x9B82, 0xEC79,\t0x9B85, 0xEC74, 0x9B86, 0xEF72, 0x9B87, 0xEC75, 0x9B88, 0xECA2,\r\n\t0x9B90, 0xEC7C, 0x9B91, 0xC06A, 0x9B92, 0xEC7B, 0x9B93, 0xEC7A,\t0x9B95, 0xEC7E, 0x9B9A, 0xEF6A, 0x9B9B, 0xEF6D, 0x9B9E, 0xEF6C,\r\n\t0x9BA0, 0xEF74, 0x9BA1, 0xEF6F, 0x9BA2, 0xEF73, 0x9BA4, 0xEF71,\t0x9BA5, 0xEF70, 0x9BA6, 0xEF6E, 0x9BA8, 0xEF6B, 0x9BAA, 0xC243,\r\n\t0x9BAB, 0xC242, 0x9BAD, 0xC244, 0x9BAE, 0xC241, 0x9BAF, 0xEF75,\t0x9BB5, 0xF1C8, 0x9BB6, 0xF1CB, 0x9BB8, 0xF1C9, 0x9BB9, 0xF1CD,\r\n\t0x9BBD, 0xF1CE, 0x9BBF, 0xF1C6, 0x9BC0, 0xC358, 0x9BC1, 0xF1C7,\t0x9BC3, 0xF1C5, 0x9BC4, 0xF1CC, 0x9BC6, 0xF1C4, 0x9BC7, 0xF1C3,\r\n\t0x9BC8, 0xC357, 0x9BC9, 0xC355, 0x9BCA, 0xC354, 0x9BD3, 0xF1CA,\t0x9BD4, 0xF3CF, 0x9BD5, 0xF3D5, 0x9BD6, 0xC44A, 0x9BD7, 0xF3D0,\r\n\t0x9BD9, 0xF3D3, 0x9BDA, 0xF3D7, 0x9BDB, 0xC44B, 0x9BDC, 0xF3D2,\t0x9BDE, 0xF3CA, 0x9BE0, 0xF3C9, 0x9BE1, 0xF3D6, 0x9BE2, 0xF3CD,\r\n\t0x9BE4, 0xF3CB, 0x9BE5, 0xF3D4, 0x9BE6, 0xF3CC, 0x9BE7, 0xC449,\t0x9BE8, 0xC448, 0x9BEA, 0xF3C7, 0x9BEB, 0xF3C8, 0x9BEC, 0xF3D1,\r\n\t0x9BF0, 0xF3CE, 0x9BF7, 0xF56C, 0x9BF8, 0xF56F, 0x9BFD, 0xC356,\t0x9C05, 0xF56D, 0x9C06, 0xF573, 0x9C07, 0xF571, 0x9C08, 0xF56B,\r\n\t0x9C09, 0xF576, 0x9C0B, 0xF56A, 0x9C0D, 0xC4CF, 0x9C0E, 0xF572,\t0x9C12, 0xF56E, 0x9C13, 0xC4CE, 0x9C14, 0xF575, 0x9C17, 0xF574,\r\n\t0x9C1C, 0xF6AB, 0x9C1D, 0xF6AA, 0x9C21, 0xF6B1, 0x9C23, 0xF6AD,\t0x9C24, 0xF6B0, 0x9C25, 0xC560, 0x9C28, 0xF6AE, 0x9C29, 0xF6AF,\r\n\t0x9C2B, 0xF6A9, 0x9C2C, 0xF6AC, 0x9C2D, 0xC55F, 0x9C31, 0xC5BF,\t0x9C32, 0xF7B4, 0x9C33, 0xF7AF, 0x9C34, 0xF7B3, 0x9C36, 0xF7B6,\r\n\t0x9C37, 0xF7B2, 0x9C39, 0xF7AE, 0x9C3B, 0xC5C1, 0x9C3C, 0xF7B1,\t0x9C3D, 0xF7B5, 0x9C3E, 0xC5C0, 0x9C3F, 0xF7AC, 0x9C40, 0xF570,\r\n\t0x9C41, 0xF7B0, 0x9C44, 0xF7AD, 0x9C46, 0xF7AA, 0x9C48, 0xF7AB,\t0x9C49, 0xC5BE, 0x9C4A, 0xF85A, 0x9C4B, 0xF85C, 0x9C4C, 0xF85F,\r\n\t0x9C4D, 0xF85B, 0x9C4E, 0xF860, 0x9C50, 0xF859, 0x9C52, 0xF857,\t0x9C54, 0xC5EB, 0x9C55, 0xF85D, 0x9C56, 0xC5ED, 0x9C57, 0xC5EC,\r\n\t0x9C58, 0xF858, 0x9C59, 0xF85E, 0x9C5E, 0xF8DA, 0x9C5F, 0xC64D,\t0x9C60, 0xF8DB, 0x9C62, 0xF8D9, 0x9C63, 0xF8D6, 0x9C66, 0xF8D8,\r\n\t0x9C67, 0xF8D7, 0x9C68, 0xF95A, 0x9C6D, 0xF95C, 0x9C6E, 0xF95B,\t0x9C71, 0xF979, 0x9C73, 0xF978, 0x9C74, 0xF977, 0x9C75, 0xF97A,\r\n\t0x9C77, 0xC673, 0x9C78, 0xC674, 0x9C79, 0xF9CA, 0x9C7A, 0xF9CE,\t0x9CE5, 0xB3BE, 0x9CE6, 0xDCAF, 0x9CE7, 0xE0ED, 0x9CE9, 0xB9A7,\r\n\t0x9CEA, 0xE0EB, 0x9CED, 0xE0EC, 0x9CF1, 0xE4E2, 0x9CF2, 0xE4E3,\t0x9CF3, 0xBBF1, 0x9CF4, 0xBBEF, 0x9CF5, 0xE4E4, 0x9CF6, 0xBBF0,\r\n\t0x9CF7, 0xE8E8, 0x9CF9, 0xE8EB, 0x9CFA, 0xE8E5, 0x9CFB, 0xE8EC,\t0x9CFC, 0xE8E4, 0x9CFD, 0xE8E6, 0x9CFF, 0xE8E7, 0x9D00, 0xE8EA,\r\n\t0x9D03, 0xBEA1, 0x9D04, 0xE8EF, 0x9D05, 0xE8EE, 0x9D06, 0xBE7D,\t0x9D07, 0xE8E9, 0x9D08, 0xE8ED, 0x9D09, 0xBE7E, 0x9D10, 0xECAC,\r\n\t0x9D12, 0xC06F, 0x9D14, 0xECA7, 0x9D15, 0xC06B, 0x9D17, 0xECA4,\t0x9D18, 0xECAA, 0x9D19, 0xECAD, 0x9D1B, 0xC070, 0x9D1D, 0xECA9,\r\n\t0x9D1E, 0xECA6, 0x9D1F, 0xECAE, 0x9D20, 0xECA5, 0x9D22, 0xECAB,\t0x9D23, 0xC06C, 0x9D25, 0xECA3, 0x9D26, 0xC06D, 0x9D28, 0xC06E,\r\n\t0x9D29, 0xECA8, 0x9D2D, 0xEFA9, 0x9D2E, 0xEF7A, 0x9D2F, 0xEF7B,\t0x9D30, 0xEF7E, 0x9D31, 0xEF7C, 0x9D33, 0xEF76, 0x9D36, 0xEF79,\r\n\t0x9D37, 0xEFA5, 0x9D38, 0xEF7D, 0x9D3B, 0xC245, 0x9D3D, 0xEFA7,\t0x9D3E, 0xEFA4, 0x9D3F, 0xC246, 0x9D40, 0xEFA6, 0x9D41, 0xEF77,\r\n\t0x9D42, 0xEFA2, 0x9D43, 0xEFA3, 0x9D45, 0xEFA1, 0x9D4A, 0xF1D2,\t0x9D4B, 0xF1D4, 0x9D4C, 0xF1D7, 0x9D4F, 0xF1D1, 0x9D51, 0xC359,\r\n\t0x9D52, 0xF1D9, 0x9D53, 0xF1D0, 0x9D54, 0xF1DA, 0x9D56, 0xF1D6,\t0x9D57, 0xF1D8, 0x9D58, 0xF1DC, 0x9D59, 0xF1D5, 0x9D5A, 0xF1DD,\r\n\t0x9D5B, 0xF1D3, 0x9D5C, 0xF1CF, 0x9D5D, 0xC35A, 0x9D5F, 0xF1DB,\t0x9D60, 0xC35B, 0x9D61, 0xC44D, 0x9D67, 0xEF78, 0x9D68, 0xF3F1,\r\n\t0x9D69, 0xF3E8, 0x9D6A, 0xC44F, 0x9D6B, 0xF3E4, 0x9D6C, 0xC450,\t0x9D6F, 0xF3ED, 0x9D70, 0xF3E7, 0x9D71, 0xF3DD, 0x9D72, 0xC44E,\r\n\t0x9D73, 0xF3EA, 0x9D74, 0xF3E5, 0x9D75, 0xF3E6, 0x9D77, 0xF3D8,\t0x9D78, 0xF3DF, 0x9D79, 0xF3EE, 0x9D7B, 0xF3EB, 0x9D7D, 0xF3E3,\r\n\t0x9D7F, 0xF3EF, 0x9D80, 0xF3DE, 0x9D81, 0xF3D9, 0x9D82, 0xF3EC,\t0x9D84, 0xF3DB, 0x9D85, 0xF3E9, 0x9D86, 0xF3E0, 0x9D87, 0xF3F0,\r\n\t0x9D88, 0xF3DC, 0x9D89, 0xC44C, 0x9D8A, 0xF3DA, 0x9D8B, 0xF3E1,\t0x9D8C, 0xF3E2, 0x9D90, 0xF57D, 0x9D92, 0xF57B, 0x9D94, 0xF5A2,\r\n\t0x9D96, 0xF5AE, 0x9D97, 0xF5A5, 0x9D98, 0xF57C, 0x9D99, 0xF578,\t0x9D9A, 0xF5A7, 0x9D9B, 0xF57E, 0x9D9C, 0xF5A3, 0x9D9D, 0xF57A,\r\n\t0x9D9E, 0xF5AA, 0x9D9F, 0xF577, 0x9DA0, 0xF5A1, 0x9DA1, 0xF5A6,\t0x9DA2, 0xF5A8, 0x9DA3, 0xF5AB, 0x9DA4, 0xF579, 0x9DA6, 0xF5AF,\r\n\t0x9DA7, 0xF5B0, 0x9DA8, 0xF5A9, 0x9DA9, 0xF5AD, 0x9DAA, 0xF5A4,\t0x9DAC, 0xF6C1, 0x9DAD, 0xF6C4, 0x9DAF, 0xC561, 0x9DB1, 0xF6C3,\r\n\t0x9DB2, 0xF6C8, 0x9DB3, 0xF6C6, 0x9DB4, 0xC562, 0x9DB5, 0xF6BD,\t0x9DB6, 0xF6B3, 0x9DB7, 0xF6B2, 0x9DB8, 0xC564, 0x9DB9, 0xF6BF,\r\n\t0x9DBA, 0xF6C0, 0x9DBB, 0xF6BC, 0x9DBC, 0xF6B4, 0x9DBE, 0xF6B9,\t0x9DBF, 0xF5AC, 0x9DC1, 0xF6B5, 0x9DC2, 0xC563, 0x9DC3, 0xF6BB,\r\n\t0x9DC5, 0xF6BA, 0x9DC7, 0xF6B6, 0x9DC8, 0xF6C2, 0x9DCA, 0xF6B7,\t0x9DCB, 0xF7BB, 0x9DCC, 0xF6C5, 0x9DCD, 0xF6C7, 0x9DCE, 0xF6BE,\r\n\t0x9DCF, 0xF6B8, 0x9DD0, 0xF7BC, 0x9DD1, 0xF7BE, 0x9DD2, 0xF7B8,\t0x9DD3, 0xC5C2, 0x9DD5, 0xF7C5, 0x9DD6, 0xF7C3, 0x9DD7, 0xC5C3,\r\n\t0x9DD8, 0xF7C2, 0x9DD9, 0xF7C1, 0x9DDA, 0xF7BA, 0x9DDB, 0xF7B7,\t0x9DDC, 0xF7BD, 0x9DDD, 0xF7C6, 0x9DDE, 0xF7B9, 0x9DDF, 0xF7BF,\r\n\t0x9DE1, 0xF869, 0x9DE2, 0xF86E, 0x9DE3, 0xF864, 0x9DE4, 0xF867,\t0x9DE5, 0xC5EE, 0x9DE6, 0xF86B, 0x9DE8, 0xF872, 0x9DE9, 0xF7C0,\r\n\t0x9DEB, 0xF865, 0x9DEC, 0xF86F, 0x9DED, 0xF873, 0x9DEE, 0xF86A,\t0x9DEF, 0xF863, 0x9DF0, 0xF86D, 0x9DF2, 0xF86C, 0x9DF3, 0xF871,\r\n\t0x9DF4, 0xF870, 0x9DF5, 0xF7C4, 0x9DF6, 0xF868, 0x9DF7, 0xF862,\t0x9DF8, 0xF866, 0x9DF9, 0xC64E, 0x9DFA, 0xC64F, 0x9DFB, 0xF861,\r\n\t0x9DFD, 0xF8E6, 0x9DFE, 0xF8DD, 0x9DFF, 0xF8E5, 0x9E00, 0xF8E2,\t0x9E01, 0xF8E3, 0x9E02, 0xF8DC, 0x9E03, 0xF8DF, 0x9E04, 0xF8E7,\r\n\t0x9E05, 0xF8E1, 0x9E06, 0xF8E0, 0x9E07, 0xF8DE, 0x9E09, 0xF8E4,\t0x9E0B, 0xF95D, 0x9E0D, 0xF95E, 0x9E0F, 0xF960, 0x9E10, 0xF95F,\r\n\t0x9E11, 0xF962, 0x9E12, 0xF961, 0x9E13, 0xF97C, 0x9E14, 0xF97B,\t0x9E15, 0xF9B7, 0x9E17, 0xF9B8, 0x9E19, 0xF9C5, 0x9E1A, 0xC678,\r\n\t0x9E1B, 0xC67C, 0x9E1D, 0xF9CF, 0x9E1E, 0xC67D, 0x9E75, 0xB3BF,\t0x9E79, 0xC4D0, 0x9E7A, 0xF6C9, 0x9E7C, 0xC650, 0x9E7D, 0xC651,\r\n\t0x9E7F, 0xB3C0, 0x9E80, 0xE0EE, 0x9E82, 0xB9A8, 0x9E83, 0xE8F0,\t0x9E86, 0xECB0, 0x9E87, 0xECB1, 0x9E88, 0xECAF, 0x9E89, 0xEFAB,\r\n\t0x9E8A, 0xEFAA, 0x9E8B, 0xC247, 0x9E8C, 0xF1DF, 0x9E8D, 0xEFAC,\t0x9E8E, 0xF1DE, 0x9E91, 0xF3F3, 0x9E92, 0xC451, 0x9E93, 0xC453,\r\n\t0x9E94, 0xF3F2, 0x9E97, 0xC452, 0x9E99, 0xF5B1, 0x9E9A, 0xF5B3,\t0x9E9B, 0xF5B2, 0x9E9C, 0xF6CA, 0x9E9D, 0xC565, 0x9E9F, 0xC5EF,\r\n\t0x9EA0, 0xF8E8, 0x9EA1, 0xF963, 0x9EA4, 0xF9D2, 0x9EA5, 0xB3C1,\t0x9EA7, 0xE4E5, 0x9EA9, 0xBEA2, 0x9EAD, 0xECB3, 0x9EAE, 0xECB2,\r\n\t0x9EB0, 0xEFAD, 0x9EB4, 0xC454, 0x9EB5, 0xC4D1, 0x9EB6, 0xF7C7,\t0x9EB7, 0xF9CB, 0x9EBB, 0xB3C2, 0x9EBC, 0xBBF2, 0x9EBE, 0xBEA3,\r\n\t0x9EC0, 0xF3F4, 0x9EC2, 0xF874, 0x9EC3, 0xB6C0, 0x9EC8, 0xEFAE,\t0x9ECC, 0xC664, 0x9ECD, 0xB6C1, 0x9ECE, 0xBEA4, 0x9ECF, 0xC248,\r\n\t0x9ED0, 0xF875, 0x9ED1, 0xB6C2, 0x9ED3, 0xE8F1, 0x9ED4, 0xC072,\t0x9ED5, 0xECB4, 0x9ED6, 0xECB5, 0x9ED8, 0xC071, 0x9EDA, 0xEFAF,\r\n\t0x9EDB, 0xC24C, 0x9EDC, 0xC24A, 0x9EDD, 0xC24B, 0x9EDE, 0xC249,\t0x9EDF, 0xF1E0, 0x9EE0, 0xC35C, 0x9EE4, 0xF5B5, 0x9EE5, 0xF5B4,\r\n\t0x9EE6, 0xF5B7, 0x9EE7, 0xF5B6, 0x9EE8, 0xC4D2, 0x9EEB, 0xF6CB,\t0x9EED, 0xF6CD, 0x9EEE, 0xF6CC, 0x9EEF, 0xC566, 0x9EF0, 0xF7C8,\r\n\t0x9EF2, 0xF876, 0x9EF3, 0xF877, 0x9EF4, 0xC5F0, 0x9EF5, 0xF964,\t0x9EF6, 0xF97D, 0x9EF7, 0xC675, 0x9EF9, 0xDCB0, 0x9EFA, 0xECB6,\r\n\t0x9EFB, 0xEFB0, 0x9EFC, 0xF3F5, 0x9EFD, 0xE0EF, 0x9EFF, 0xEFB1,\t0x9F00, 0xF1E2, 0x9F01, 0xF1E1, 0x9F06, 0xF878, 0x9F07, 0xC652,\r\n\t0x9F09, 0xF965, 0x9F0A, 0xF97E, 0x9F0E, 0xB9A9, 0x9F0F, 0xE8F2,\t0x9F10, 0xE8F3, 0x9F12, 0xECB7, 0x9F13, 0xB9AA, 0x9F15, 0xC35D,\r\n\t0x9F16, 0xF1E3, 0x9F18, 0xF6CF, 0x9F19, 0xC567, 0x9F1A, 0xF6D0,\t0x9F1B, 0xF6CE, 0x9F1C, 0xF879, 0x9F1E, 0xF8E9, 0x9F20, 0xB9AB,\r\n\t0x9F22, 0xEFB4, 0x9F23, 0xEFB3, 0x9F24, 0xEFB2, 0x9F25, 0xF1E4,\t0x9F28, 0xF1E8, 0x9F29, 0xF1E7, 0x9F2A, 0xF1E6, 0x9F2B, 0xF1E5,\r\n\t0x9F2C, 0xC35E, 0x9F2D, 0xF3F6, 0x9F2E, 0xF5B9, 0x9F2F, 0xC4D3,\t0x9F30, 0xF5B8, 0x9F31, 0xF6D1, 0x9F32, 0xF7CB, 0x9F33, 0xF7CA,\r\n\t0x9F34, 0xC5C4, 0x9F35, 0xF7C9, 0x9F36, 0xF87C, 0x9F37, 0xF87B,\t0x9F38, 0xF87A, 0x9F3B, 0xBBF3, 0x9F3D, 0xECB8, 0x9F3E, 0xC24D,\r\n\t0x9F40, 0xF3F7, 0x9F41, 0xF3F8, 0x9F42, 0xF7CC, 0x9F43, 0xF87D,\t0x9F46, 0xF8EA, 0x9F47, 0xF966, 0x9F48, 0xF9B9, 0x9F49, 0xF9D4,\r\n\t0x9F4A, 0xBBF4, 0x9F4B, 0xC24E, 0x9F4C, 0xF1E9, 0x9F4D, 0xF3F9,\t0x9F4E, 0xF6D2, 0x9F4F, 0xF87E, 0x9F52, 0xBEA6, 0x9F54, 0xEFB5,\r\n\t0x9F55, 0xF1EA, 0x9F56, 0xF3FA, 0x9F57, 0xF3FB, 0x9F58, 0xF3FC,\t0x9F59, 0xF5BE, 0x9F5B, 0xF5BA, 0x9F5C, 0xC568, 0x9F5D, 0xF5BD,\r\n\t0x9F5E, 0xF5BC, 0x9F5F, 0xC4D4, 0x9F60, 0xF5BB, 0x9F61, 0xC4D6,\t0x9F63, 0xC4D5, 0x9F64, 0xF6D4, 0x9F65, 0xF6D3, 0x9F66, 0xC569,\r\n\t0x9F67, 0xC56A, 0x9F6A, 0xC5C6, 0x9F6B, 0xF7CD, 0x9F6C, 0xC5C5,\t0x9F6E, 0xF8A3, 0x9F6F, 0xF8A4, 0x9F70, 0xF8A2, 0x9F71, 0xF8A1,\r\n\t0x9F72, 0xC654, 0x9F74, 0xF8EB, 0x9F75, 0xF8EC, 0x9F76, 0xF8ED,\t0x9F77, 0xC653, 0x9F78, 0xF967, 0x9F79, 0xF96A, 0x9F7A, 0xF969,\r\n\t0x9F7B, 0xF968, 0x9F7E, 0xF9D3, 0x9F8D, 0xC073, 0x9F90, 0xC365,\t0x9F91, 0xF5BF, 0x9F92, 0xF6D5, 0x9F94, 0xC5C7, 0x9F95, 0xF7CE,\r\n\t0x9F98, 0xF9D5, 0x9F9C, 0xC074, 0x9FA0, 0xEFB6, 0x9FA2, 0xF7CF,\t0x9FA4, 0xF9A1, 0xFA0C, 0xC94A, 0xFA0D, 0xDDFC, 0xFE30, 0xA14A,\r\n\t0xFE31, 0xA157, 0xFE33, 0xA159, 0xFE34, 0xA15B, 0xFE35, 0xA15F,\t0xFE36, 0xA160, 0xFE37, 0xA163, 0xFE38, 0xA164, 0xFE39, 0xA167,\r\n\t0xFE3A, 0xA168, 0xFE3B, 0xA16B, 0xFE3C, 0xA16C, 0xFE3D, 0xA16F,\t0xFE3E, 0xA170, 0xFE3F, 0xA173, 0xFE40, 0xA174, 0xFE41, 0xA177,\r\n\t0xFE42, 0xA178, 0xFE43, 0xA17B, 0xFE44, 0xA17C, 0xFE49, 0xA1C6,\t0xFE4A, 0xA1C7, 0xFE4B, 0xA1CA, 0xFE4C, 0xA1CB, 0xFE4D, 0xA1C8,\r\n\t0xFE4E, 0xA1C9, 0xFE4F, 0xA15C, 0xFE50, 0xA14D, 0xFE51, 0xA14E,\t0xFE52, 0xA14F, 0xFE54, 0xA151, 0xFE55, 0xA152, 0xFE56, 0xA153,\r\n\t0xFE57, 0xA154, 0xFE59, 0xA17D, 0xFE5A, 0xA17E, 0xFE5B, 0xA1A1,\t0xFE5C, 0xA1A2, 0xFE5D, 0xA1A3, 0xFE5E, 0xA1A4, 0xFE5F, 0xA1CC,\r\n\t0xFE60, 0xA1CD, 0xFE61, 0xA1CE, 0xFE62, 0xA1DE, 0xFE63, 0xA1DF,\t0xFE64, 0xA1E0, 0xFE65, 0xA1E1, 0xFE66, 0xA1E2, 0xFE68, 0xA242,\r\n\t0xFE69, 0xA24C, 0xFE6A, 0xA24D, 0xFE6B, 0xA24E, 0xFF01, 0xA149,\t0xFF03, 0xA1AD, 0xFF04, 0xA243, 0xFF05, 0xA248, 0xFF06, 0xA1AE,\r\n\t0xFF08, 0xA15D, 0xFF09, 0xA15E, 0xFF0A, 0xA1AF, 0xFF0B, 0xA1CF,\t0xFF0C, 0xA141, 0xFF0D, 0xA1D0, 0xFF0E, 0xA144, 0xFF0F, 0xA1FE,\r\n\t0xFF10, 0xA2AF, 0xFF11, 0xA2B0, 0xFF12, 0xA2B1, 0xFF13, 0xA2B2,\t0xFF14, 0xA2B3, 0xFF15, 0xA2B4, 0xFF16, 0xA2B5, 0xFF17, 0xA2B6,\r\n\t0xFF18, 0xA2B7, 0xFF19, 0xA2B8, 0xFF1A, 0xA147, 0xFF1B, 0xA146,\t0xFF1C, 0xA1D5, 0xFF1D, 0xA1D7, 0xFF1E, 0xA1D6, 0xFF1F, 0xA148,\r\n\t0xFF20, 0xA249, 0xFF21, 0xA2CF, 0xFF22, 0xA2D0, 0xFF23, 0xA2D1,\t0xFF24, 0xA2D2, 0xFF25, 0xA2D3, 0xFF26, 0xA2D4, 0xFF27, 0xA2D5,\r\n\t0xFF28, 0xA2D6, 0xFF29, 0xA2D7, 0xFF2A, 0xA2D8, 0xFF2B, 0xA2D9,\t0xFF2C, 0xA2DA, 0xFF2D, 0xA2DB, 0xFF2E, 0xA2DC, 0xFF2F, 0xA2DD,\r\n\t0xFF30, 0xA2DE, 0xFF31, 0xA2DF, 0xFF32, 0xA2E0, 0xFF33, 0xA2E1,\t0xFF34, 0xA2E2, 0xFF35, 0xA2E3, 0xFF36, 0xA2E4, 0xFF37, 0xA2E5,\r\n\t0xFF38, 0xA2E6, 0xFF39, 0xA2E7, 0xFF3A, 0xA2E8, 0xFF3C, 0xA240,\t0xFF3F, 0xA1C4, 0xFF41, 0xA2E9, 0xFF42, 0xA2EA, 0xFF43, 0xA2EB,\r\n\t0xFF44, 0xA2EC, 0xFF45, 0xA2ED, 0xFF46, 0xA2EE, 0xFF47, 0xA2EF,\t0xFF48, 0xA2F0, 0xFF49, 0xA2F1, 0xFF4A, 0xA2F2, 0xFF4B, 0xA2F3,\r\n\t0xFF4C, 0xA2F4, 0xFF4D, 0xA2F5, 0xFF4E, 0xA2F6, 0xFF4F, 0xA2F7,\t0xFF50, 0xA2F8, 0xFF51, 0xA2F9, 0xFF52, 0xA2FA, 0xFF53, 0xA2FB,\r\n\t0xFF54, 0xA2FC, 0xFF55, 0xA2FD, 0xFF56, 0xA2FE, 0xFF57, 0xA340,\t0xFF58, 0xA341, 0xFF59, 0xA342, 0xFF5A, 0xA343, 0xFF5B, 0xA161,\r\n\t0xFF5C, 0xA155, 0xFF5D, 0xA162, 0xFF5E, 0xA1E3, 0xFFE0, 0xA246,\t0xFFE1, 0xA247, 0xFFE3, 0xA1C3, 0xFFE5, 0xA244, 0, 0\r\n};\r\n\r\nstatic const WCHAR oem2uni950[] = {\t/* Big5 --> Unicode pairs */\r\n\t0xA140, 0x3000, 0xA141, 0xFF0C, 0xA142, 0x3001, 0xA143, 0x3002,\t0xA144, 0xFF0E, 0xA145, 0x2027, 0xA146, 0xFF1B, 0xA147, 0xFF1A,\r\n\t0xA148, 0xFF1F, 0xA149, 0xFF01, 0xA14A, 0xFE30, 0xA14B, 0x2026,\t0xA14C, 0x2025, 0xA14D, 0xFE50, 0xA14E, 0xFE51, 0xA14F, 0xFE52,\r\n\t0xA150, 0x00B7, 0xA151, 0xFE54, 0xA152, 0xFE55, 0xA153, 0xFE56,\t0xA154, 0xFE57, 0xA155, 0xFF5C, 0xA156, 0x2013, 0xA157, 0xFE31,\r\n\t0xA158, 0x2014, 0xA159, 0xFE33, 0xA15A, 0x2574, 0xA15B, 0xFE34,\t0xA15C, 0xFE4F, 0xA15D, 0xFF08, 0xA15E, 0xFF09, 0xA15F, 0xFE35,\r\n\t0xA160, 0xFE36, 0xA161, 0xFF5B, 0xA162, 0xFF5D, 0xA163, 0xFE37,\t0xA164, 0xFE38, 0xA165, 0x3014, 0xA166, 0x3015, 0xA167, 0xFE39,\r\n\t0xA168, 0xFE3A, 0xA169, 0x3010, 0xA16A, 0x3011, 0xA16B, 0xFE3B,\t0xA16C, 0xFE3C, 0xA16D, 0x300A, 0xA16E, 0x300B, 0xA16F, 0xFE3D,\r\n\t0xA170, 0xFE3E, 0xA171, 0x3008, 0xA172, 0x3009, 0xA173, 0xFE3F,\t0xA174, 0xFE40, 0xA175, 0x300C, 0xA176, 0x300D, 0xA177, 0xFE41,\r\n\t0xA178, 0xFE42, 0xA179, 0x300E, 0xA17A, 0x300F, 0xA17B, 0xFE43,\t0xA17C, 0xFE44, 0xA17D, 0xFE59, 0xA17E, 0xFE5A, 0xA1A1, 0xFE5B,\r\n\t0xA1A2, 0xFE5C, 0xA1A3, 0xFE5D, 0xA1A4, 0xFE5E, 0xA1A5, 0x2018,\t0xA1A6, 0x2019, 0xA1A7, 0x201C, 0xA1A8, 0x201D, 0xA1A9, 0x301D,\r\n\t0xA1AA, 0x301E, 0xA1AB, 0x2035, 0xA1AC, 0x2032, 0xA1AD, 0xFF03,\t0xA1AE, 0xFF06, 0xA1AF, 0xFF0A, 0xA1B0, 0x203B, 0xA1B1, 0x00A7,\r\n\t0xA1B2, 0x3003, 0xA1B3, 0x25CB, 0xA1B4, 0x25CF, 0xA1B5, 0x25B3,\t0xA1B6, 0x25B2, 0xA1B7, 0x25CE, 0xA1B8, 0x2606, 0xA1B9, 0x2605,\r\n\t0xA1BA, 0x25C7, 0xA1BB, 0x25C6, 0xA1BC, 0x25A1, 0xA1BD, 0x25A0,\t0xA1BE, 0x25BD, 0xA1BF, 0x25BC, 0xA1C0, 0x32A3, 0xA1C1, 0x2105,\r\n\t0xA1C2, 0x00AF, 0xA1C3, 0xFFE3, 0xA1C4, 0xFF3F, 0xA1C5, 0x02CD,\t0xA1C6, 0xFE49, 0xA1C7, 0xFE4A, 0xA1C8, 0xFE4D, 0xA1C9, 0xFE4E,\r\n\t0xA1CA, 0xFE4B, 0xA1CB, 0xFE4C, 0xA1CC, 0xFE5F, 0xA1CD, 0xFE60,\t0xA1CE, 0xFE61, 0xA1CF, 0xFF0B, 0xA1D0, 0xFF0D, 0xA1D1, 0x00D7,\r\n\t0xA1D2, 0x00F7, 0xA1D3, 0x00B1, 0xA1D4, 0x221A, 0xA1D5, 0xFF1C,\t0xA1D6, 0xFF1E, 0xA1D7, 0xFF1D, 0xA1D8, 0x2266, 0xA1D9, 0x2267,\r\n\t0xA1DA, 0x2260, 0xA1DB, 0x221E, 0xA1DC, 0x2252, 0xA1DD, 0x2261,\t0xA1DE, 0xFE62, 0xA1DF, 0xFE63, 0xA1E0, 0xFE64, 0xA1E1, 0xFE65,\r\n\t0xA1E2, 0xFE66, 0xA1E3, 0xFF5E, 0xA1E4, 0x2229, 0xA1E5, 0x222A,\t0xA1E6, 0x22A5, 0xA1E7, 0x2220, 0xA1E8, 0x221F, 0xA1E9, 0x22BF,\r\n\t0xA1EA, 0x33D2, 0xA1EB, 0x33D1, 0xA1EC, 0x222B, 0xA1ED, 0x222E,\t0xA1EE, 0x2235, 0xA1EF, 0x2234, 0xA1F0, 0x2640, 0xA1F1, 0x2642,\r\n\t0xA1F2, 0x2295, 0xA1F3, 0x2299, 0xA1F4, 0x2191, 0xA1F5, 0x2193,\t0xA1F6, 0x2190, 0xA1F7, 0x2192, 0xA1F8, 0x2196, 0xA1F9, 0x2197,\r\n\t0xA1FA, 0x2199, 0xA1FB, 0x2198, 0xA1FC, 0x2225, 0xA1FD, 0x2223,\t0xA1FE, 0xFF0F, 0xA240, 0xFF3C, 0xA241, 0x2215, 0xA242, 0xFE68,\r\n\t0xA243, 0xFF04, 0xA244, 0xFFE5, 0xA245, 0x3012, 0xA246, 0xFFE0,\t0xA247, 0xFFE1, 0xA248, 0xFF05, 0xA249, 0xFF20, 0xA24A, 0x2103,\r\n\t0xA24B, 0x2109, 0xA24C, 0xFE69, 0xA24D, 0xFE6A, 0xA24E, 0xFE6B,\t0xA24F, 0x33D5, 0xA250, 0x339C, 0xA251, 0x339D, 0xA252, 0x339E,\r\n\t0xA253, 0x33CE, 0xA254, 0x33A1, 0xA255, 0x338E, 0xA256, 0x338F,\t0xA257, 0x33C4, 0xA258, 0x00B0, 0xA259, 0x5159, 0xA25A, 0x515B,\r\n\t0xA25B, 0x515E, 0xA25C, 0x515D, 0xA25D, 0x5161, 0xA25E, 0x5163,\t0xA25F, 0x55E7, 0xA260, 0x74E9, 0xA261, 0x7CCE, 0xA262, 0x2581,\r\n\t0xA263, 0x2582, 0xA264, 0x2583, 0xA265, 0x2584, 0xA266, 0x2585,\t0xA267, 0x2586, 0xA268, 0x2587, 0xA269, 0x2588, 0xA26A, 0x258F,\r\n\t0xA26B, 0x258E, 0xA26C, 0x258D, 0xA26D, 0x258C, 0xA26E, 0x258B,\t0xA26F, 0x258A, 0xA270, 0x2589, 0xA271, 0x253C, 0xA272, 0x2534,\r\n\t0xA273, 0x252C, 0xA274, 0x2524, 0xA275, 0x251C, 0xA276, 0x2594,\t0xA277, 0x2500, 0xA278, 0x2502, 0xA279, 0x2595, 0xA27A, 0x250C,\r\n\t0xA27B, 0x2510, 0xA27C, 0x2514, 0xA27D, 0x2518, 0xA27E, 0x256D,\t0xA2A1, 0x256E, 0xA2A2, 0x2570, 0xA2A3, 0x256F, 0xA2A4, 0x2550,\r\n\t0xA2A5, 0x255E, 0xA2A6, 0x256A, 0xA2A7, 0x2561, 0xA2A8, 0x25E2,\t0xA2A9, 0x25E3, 0xA2AA, 0x25E5, 0xA2AB, 0x25E4, 0xA2AC, 0x2571,\r\n\t0xA2AD, 0x2572, 0xA2AE, 0x2573, 0xA2AF, 0xFF10, 0xA2B0, 0xFF11,\t0xA2B1, 0xFF12, 0xA2B2, 0xFF13, 0xA2B3, 0xFF14, 0xA2B4, 0xFF15,\r\n\t0xA2B5, 0xFF16, 0xA2B6, 0xFF17, 0xA2B7, 0xFF18, 0xA2B8, 0xFF19,\t0xA2B9, 0x2160, 0xA2BA, 0x2161, 0xA2BB, 0x2162, 0xA2BC, 0x2163,\r\n\t0xA2BD, 0x2164, 0xA2BE, 0x2165, 0xA2BF, 0x2166, 0xA2C0, 0x2167,\t0xA2C1, 0x2168, 0xA2C2, 0x2169, 0xA2C3, 0x3021, 0xA2C4, 0x3022,\r\n\t0xA2C5, 0x3023, 0xA2C6, 0x3024, 0xA2C7, 0x3025, 0xA2C8, 0x3026,\t0xA2C9, 0x3027, 0xA2CA, 0x3028, 0xA2CB, 0x3029, 0xA2CC, 0x5341,\r\n\t0xA2CD, 0x5344, 0xA2CE, 0x5345, 0xA2CF, 0xFF21, 0xA2D0, 0xFF22,\t0xA2D1, 0xFF23, 0xA2D2, 0xFF24, 0xA2D3, 0xFF25, 0xA2D4, 0xFF26,\r\n\t0xA2D5, 0xFF27, 0xA2D6, 0xFF28, 0xA2D7, 0xFF29, 0xA2D8, 0xFF2A,\t0xA2D9, 0xFF2B, 0xA2DA, 0xFF2C, 0xA2DB, 0xFF2D, 0xA2DC, 0xFF2E,\r\n\t0xA2DD, 0xFF2F, 0xA2DE, 0xFF30, 0xA2DF, 0xFF31, 0xA2E0, 0xFF32,\t0xA2E1, 0xFF33, 0xA2E2, 0xFF34, 0xA2E3, 0xFF35, 0xA2E4, 0xFF36,\r\n\t0xA2E5, 0xFF37, 0xA2E6, 0xFF38, 0xA2E7, 0xFF39, 0xA2E8, 0xFF3A,\t0xA2E9, 0xFF41, 0xA2EA, 0xFF42, 0xA2EB, 0xFF43, 0xA2EC, 0xFF44,\r\n\t0xA2ED, 0xFF45, 0xA2EE, 0xFF46, 0xA2EF, 0xFF47, 0xA2F0, 0xFF48,\t0xA2F1, 0xFF49, 0xA2F2, 0xFF4A, 0xA2F3, 0xFF4B, 0xA2F4, 0xFF4C,\r\n\t0xA2F5, 0xFF4D, 0xA2F6, 0xFF4E, 0xA2F7, 0xFF4F, 0xA2F8, 0xFF50,\t0xA2F9, 0xFF51, 0xA2FA, 0xFF52, 0xA2FB, 0xFF53, 0xA2FC, 0xFF54,\r\n\t0xA2FD, 0xFF55, 0xA2FE, 0xFF56, 0xA340, 0xFF57, 0xA341, 0xFF58,\t0xA342, 0xFF59, 0xA343, 0xFF5A, 0xA344, 0x0391, 0xA345, 0x0392,\r\n\t0xA346, 0x0393, 0xA347, 0x0394, 0xA348, 0x0395, 0xA349, 0x0396,\t0xA34A, 0x0397, 0xA34B, 0x0398, 0xA34C, 0x0399, 0xA34D, 0x039A,\r\n\t0xA34E, 0x039B, 0xA34F, 0x039C, 0xA350, 0x039D, 0xA351, 0x039E,\t0xA352, 0x039F, 0xA353, 0x03A0, 0xA354, 0x03A1, 0xA355, 0x03A3,\r\n\t0xA356, 0x03A4, 0xA357, 0x03A5, 0xA358, 0x03A6, 0xA359, 0x03A7,\t0xA35A, 0x03A8, 0xA35B, 0x03A9, 0xA35C, 0x03B1, 0xA35D, 0x03B2,\r\n\t0xA35E, 0x03B3, 0xA35F, 0x03B4, 0xA360, 0x03B5, 0xA361, 0x03B6,\t0xA362, 0x03B7, 0xA363, 0x03B8, 0xA364, 0x03B9, 0xA365, 0x03BA,\r\n\t0xA366, 0x03BB, 0xA367, 0x03BC, 0xA368, 0x03BD, 0xA369, 0x03BE,\t0xA36A, 0x03BF, 0xA36B, 0x03C0, 0xA36C, 0x03C1, 0xA36D, 0x03C3,\r\n\t0xA36E, 0x03C4, 0xA36F, 0x03C5, 0xA370, 0x03C6, 0xA371, 0x03C7,\t0xA372, 0x03C8, 0xA373, 0x03C9, 0xA374, 0x3105, 0xA375, 0x3106,\r\n\t0xA376, 0x3107, 0xA377, 0x3108, 0xA378, 0x3109, 0xA379, 0x310A,\t0xA37A, 0x310B, 0xA37B, 0x310C, 0xA37C, 0x310D, 0xA37D, 0x310E,\r\n\t0xA37E, 0x310F, 0xA3A1, 0x3110, 0xA3A2, 0x3111, 0xA3A3, 0x3112,\t0xA3A4, 0x3113, 0xA3A5, 0x3114, 0xA3A6, 0x3115, 0xA3A7, 0x3116,\r\n\t0xA3A8, 0x3117, 0xA3A9, 0x3118, 0xA3AA, 0x3119, 0xA3AB, 0x311A,\t0xA3AC, 0x311B, 0xA3AD, 0x311C, 0xA3AE, 0x311D, 0xA3AF, 0x311E,\r\n\t0xA3B0, 0x311F, 0xA3B1, 0x3120, 0xA3B2, 0x3121, 0xA3B3, 0x3122,\t0xA3B4, 0x3123, 0xA3B5, 0x3124, 0xA3B6, 0x3125, 0xA3B7, 0x3126,\r\n\t0xA3B8, 0x3127, 0xA3B9, 0x3128, 0xA3BA, 0x3129, 0xA3BB, 0x02D9,\t0xA3BC, 0x02C9, 0xA3BD, 0x02CA, 0xA3BE, 0x02C7, 0xA3BF, 0x02CB,\r\n\t0xA3E1, 0x20AC, 0xA440, 0x4E00, 0xA441, 0x4E59, 0xA442, 0x4E01,\t0xA443, 0x4E03, 0xA444, 0x4E43, 0xA445, 0x4E5D, 0xA446, 0x4E86,\r\n\t0xA447, 0x4E8C, 0xA448, 0x4EBA, 0xA449, 0x513F, 0xA44A, 0x5165,\t0xA44B, 0x516B, 0xA44C, 0x51E0, 0xA44D, 0x5200, 0xA44E, 0x5201,\r\n\t0xA44F, 0x529B, 0xA450, 0x5315, 0xA451, 0x5341, 0xA452, 0x535C,\t0xA453, 0x53C8, 0xA454, 0x4E09, 0xA455, 0x4E0B, 0xA456, 0x4E08,\r\n\t0xA457, 0x4E0A, 0xA458, 0x4E2B, 0xA459, 0x4E38, 0xA45A, 0x51E1,\t0xA45B, 0x4E45, 0xA45C, 0x4E48, 0xA45D, 0x4E5F, 0xA45E, 0x4E5E,\r\n\t0xA45F, 0x4E8E, 0xA460, 0x4EA1, 0xA461, 0x5140, 0xA462, 0x5203,\t0xA463, 0x52FA, 0xA464, 0x5343, 0xA465, 0x53C9, 0xA466, 0x53E3,\r\n\t0xA467, 0x571F, 0xA468, 0x58EB, 0xA469, 0x5915, 0xA46A, 0x5927,\t0xA46B, 0x5973, 0xA46C, 0x5B50, 0xA46D, 0x5B51, 0xA46E, 0x5B53,\r\n\t0xA46F, 0x5BF8, 0xA470, 0x5C0F, 0xA471, 0x5C22, 0xA472, 0x5C38,\t0xA473, 0x5C71, 0xA474, 0x5DDD, 0xA475, 0x5DE5, 0xA476, 0x5DF1,\r\n\t0xA477, 0x5DF2, 0xA478, 0x5DF3, 0xA479, 0x5DFE, 0xA47A, 0x5E72,\t0xA47B, 0x5EFE, 0xA47C, 0x5F0B, 0xA47D, 0x5F13, 0xA47E, 0x624D,\r\n\t0xA4A1, 0x4E11, 0xA4A2, 0x4E10, 0xA4A3, 0x4E0D, 0xA4A4, 0x4E2D,\t0xA4A5, 0x4E30, 0xA4A6, 0x4E39, 0xA4A7, 0x4E4B, 0xA4A8, 0x5C39,\r\n\t0xA4A9, 0x4E88, 0xA4AA, 0x4E91, 0xA4AB, 0x4E95, 0xA4AC, 0x4E92,\t0xA4AD, 0x4E94, 0xA4AE, 0x4EA2, 0xA4AF, 0x4EC1, 0xA4B0, 0x4EC0,\r\n\t0xA4B1, 0x4EC3, 0xA4B2, 0x4EC6, 0xA4B3, 0x4EC7, 0xA4B4, 0x4ECD,\t0xA4B5, 0x4ECA, 0xA4B6, 0x4ECB, 0xA4B7, 0x4EC4, 0xA4B8, 0x5143,\r\n\t0xA4B9, 0x5141, 0xA4BA, 0x5167, 0xA4BB, 0x516D, 0xA4BC, 0x516E,\t0xA4BD, 0x516C, 0xA4BE, 0x5197, 0xA4BF, 0x51F6, 0xA4C0, 0x5206,\r\n\t0xA4C1, 0x5207, 0xA4C2, 0x5208, 0xA4C3, 0x52FB, 0xA4C4, 0x52FE,\t0xA4C5, 0x52FF, 0xA4C6, 0x5316, 0xA4C7, 0x5339, 0xA4C8, 0x5348,\r\n\t0xA4C9, 0x5347, 0xA4CA, 0x5345, 0xA4CB, 0x535E, 0xA4CC, 0x5384,\t0xA4CD, 0x53CB, 0xA4CE, 0x53CA, 0xA4CF, 0x53CD, 0xA4D0, 0x58EC,\r\n\t0xA4D1, 0x5929, 0xA4D2, 0x592B, 0xA4D3, 0x592A, 0xA4D4, 0x592D,\t0xA4D5, 0x5B54, 0xA4D6, 0x5C11, 0xA4D7, 0x5C24, 0xA4D8, 0x5C3A,\r\n\t0xA4D9, 0x5C6F, 0xA4DA, 0x5DF4, 0xA4DB, 0x5E7B, 0xA4DC, 0x5EFF,\t0xA4DD, 0x5F14, 0xA4DE, 0x5F15, 0xA4DF, 0x5FC3, 0xA4E0, 0x6208,\r\n\t0xA4E1, 0x6236, 0xA4E2, 0x624B, 0xA4E3, 0x624E, 0xA4E4, 0x652F,\t0xA4E5, 0x6587, 0xA4E6, 0x6597, 0xA4E7, 0x65A4, 0xA4E8, 0x65B9,\r\n\t0xA4E9, 0x65E5, 0xA4EA, 0x66F0, 0xA4EB, 0x6708, 0xA4EC, 0x6728,\t0xA4ED, 0x6B20, 0xA4EE, 0x6B62, 0xA4EF, 0x6B79, 0xA4F0, 0x6BCB,\r\n\t0xA4F1, 0x6BD4, 0xA4F2, 0x6BDB, 0xA4F3, 0x6C0F, 0xA4F4, 0x6C34,\t0xA4F5, 0x706B, 0xA4F6, 0x722A, 0xA4F7, 0x7236, 0xA4F8, 0x723B,\r\n\t0xA4F9, 0x7247, 0xA4FA, 0x7259, 0xA4FB, 0x725B, 0xA4FC, 0x72AC,\t0xA4FD, 0x738B, 0xA4FE, 0x4E19, 0xA540, 0x4E16, 0xA541, 0x4E15,\r\n\t0xA542, 0x4E14, 0xA543, 0x4E18, 0xA544, 0x4E3B, 0xA545, 0x4E4D,\t0xA546, 0x4E4F, 0xA547, 0x4E4E, 0xA548, 0x4EE5, 0xA549, 0x4ED8,\r\n\t0xA54A, 0x4ED4, 0xA54B, 0x4ED5, 0xA54C, 0x4ED6, 0xA54D, 0x4ED7,\t0xA54E, 0x4EE3, 0xA54F, 0x4EE4, 0xA550, 0x4ED9, 0xA551, 0x4EDE,\r\n\t0xA552, 0x5145, 0xA553, 0x5144, 0xA554, 0x5189, 0xA555, 0x518A,\t0xA556, 0x51AC, 0xA557, 0x51F9, 0xA558, 0x51FA, 0xA559, 0x51F8,\r\n\t0xA55A, 0x520A, 0xA55B, 0x52A0, 0xA55C, 0x529F, 0xA55D, 0x5305,\t0xA55E, 0x5306, 0xA55F, 0x5317, 0xA560, 0x531D, 0xA561, 0x4EDF,\r\n\t0xA562, 0x534A, 0xA563, 0x5349, 0xA564, 0x5361, 0xA565, 0x5360,\t0xA566, 0x536F, 0xA567, 0x536E, 0xA568, 0x53BB, 0xA569, 0x53EF,\r\n\t0xA56A, 0x53E4, 0xA56B, 0x53F3, 0xA56C, 0x53EC, 0xA56D, 0x53EE,\t0xA56E, 0x53E9, 0xA56F, 0x53E8, 0xA570, 0x53FC, 0xA571, 0x53F8,\r\n\t0xA572, 0x53F5, 0xA573, 0x53EB, 0xA574, 0x53E6, 0xA575, 0x53EA,\t0xA576, 0x53F2, 0xA577, 0x53F1, 0xA578, 0x53F0, 0xA579, 0x53E5,\r\n\t0xA57A, 0x53ED, 0xA57B, 0x53FB, 0xA57C, 0x56DB, 0xA57D, 0x56DA,\t0xA57E, 0x5916, 0xA5A1, 0x592E, 0xA5A2, 0x5931, 0xA5A3, 0x5974,\r\n\t0xA5A4, 0x5976, 0xA5A5, 0x5B55, 0xA5A6, 0x5B83, 0xA5A7, 0x5C3C,\t0xA5A8, 0x5DE8, 0xA5A9, 0x5DE7, 0xA5AA, 0x5DE6, 0xA5AB, 0x5E02,\r\n\t0xA5AC, 0x5E03, 0xA5AD, 0x5E73, 0xA5AE, 0x5E7C, 0xA5AF, 0x5F01,\t0xA5B0, 0x5F18, 0xA5B1, 0x5F17, 0xA5B2, 0x5FC5, 0xA5B3, 0x620A,\r\n\t0xA5B4, 0x6253, 0xA5B5, 0x6254, 0xA5B6, 0x6252, 0xA5B7, 0x6251,\t0xA5B8, 0x65A5, 0xA5B9, 0x65E6, 0xA5BA, 0x672E, 0xA5BB, 0x672C,\r\n\t0xA5BC, 0x672A, 0xA5BD, 0x672B, 0xA5BE, 0x672D, 0xA5BF, 0x6B63,\t0xA5C0, 0x6BCD, 0xA5C1, 0x6C11, 0xA5C2, 0x6C10, 0xA5C3, 0x6C38,\r\n\t0xA5C4, 0x6C41, 0xA5C5, 0x6C40, 0xA5C6, 0x6C3E, 0xA5C7, 0x72AF,\t0xA5C8, 0x7384, 0xA5C9, 0x7389, 0xA5CA, 0x74DC, 0xA5CB, 0x74E6,\r\n\t0xA5CC, 0x7518, 0xA5CD, 0x751F, 0xA5CE, 0x7528, 0xA5CF, 0x7529,\t0xA5D0, 0x7530, 0xA5D1, 0x7531, 0xA5D2, 0x7532, 0xA5D3, 0x7533,\r\n\t0xA5D4, 0x758B, 0xA5D5, 0x767D, 0xA5D6, 0x76AE, 0xA5D7, 0x76BF,\t0xA5D8, 0x76EE, 0xA5D9, 0x77DB, 0xA5DA, 0x77E2, 0xA5DB, 0x77F3,\r\n\t0xA5DC, 0x793A, 0xA5DD, 0x79BE, 0xA5DE, 0x7A74, 0xA5DF, 0x7ACB,\t0xA5E0, 0x4E1E, 0xA5E1, 0x4E1F, 0xA5E2, 0x4E52, 0xA5E3, 0x4E53,\r\n\t0xA5E4, 0x4E69, 0xA5E5, 0x4E99, 0xA5E6, 0x4EA4, 0xA5E7, 0x4EA6,\t0xA5E8, 0x4EA5, 0xA5E9, 0x4EFF, 0xA5EA, 0x4F09, 0xA5EB, 0x4F19,\r\n\t0xA5EC, 0x4F0A, 0xA5ED, 0x4F15, 0xA5EE, 0x4F0D, 0xA5EF, 0x4F10,\t0xA5F0, 0x4F11, 0xA5F1, 0x4F0F, 0xA5F2, 0x4EF2, 0xA5F3, 0x4EF6,\r\n\t0xA5F4, 0x4EFB, 0xA5F5, 0x4EF0, 0xA5F6, 0x4EF3, 0xA5F7, 0x4EFD,\t0xA5F8, 0x4F01, 0xA5F9, 0x4F0B, 0xA5FA, 0x5149, 0xA5FB, 0x5147,\r\n\t0xA5FC, 0x5146, 0xA5FD, 0x5148, 0xA5FE, 0x5168, 0xA640, 0x5171,\t0xA641, 0x518D, 0xA642, 0x51B0, 0xA643, 0x5217, 0xA644, 0x5211,\r\n\t0xA645, 0x5212, 0xA646, 0x520E, 0xA647, 0x5216, 0xA648, 0x52A3,\t0xA649, 0x5308, 0xA64A, 0x5321, 0xA64B, 0x5320, 0xA64C, 0x5370,\r\n\t0xA64D, 0x5371, 0xA64E, 0x5409, 0xA64F, 0x540F, 0xA650, 0x540C,\t0xA651, 0x540A, 0xA652, 0x5410, 0xA653, 0x5401, 0xA654, 0x540B,\r\n\t0xA655, 0x5404, 0xA656, 0x5411, 0xA657, 0x540D, 0xA658, 0x5408,\t0xA659, 0x5403, 0xA65A, 0x540E, 0xA65B, 0x5406, 0xA65C, 0x5412,\r\n\t0xA65D, 0x56E0, 0xA65E, 0x56DE, 0xA65F, 0x56DD, 0xA660, 0x5733,\t0xA661, 0x5730, 0xA662, 0x5728, 0xA663, 0x572D, 0xA664, 0x572C,\r\n\t0xA665, 0x572F, 0xA666, 0x5729, 0xA667, 0x5919, 0xA668, 0x591A,\t0xA669, 0x5937, 0xA66A, 0x5938, 0xA66B, 0x5984, 0xA66C, 0x5978,\r\n\t0xA66D, 0x5983, 0xA66E, 0x597D, 0xA66F, 0x5979, 0xA670, 0x5982,\t0xA671, 0x5981, 0xA672, 0x5B57, 0xA673, 0x5B58, 0xA674, 0x5B87,\r\n\t0xA675, 0x5B88, 0xA676, 0x5B85, 0xA677, 0x5B89, 0xA678, 0x5BFA,\t0xA679, 0x5C16, 0xA67A, 0x5C79, 0xA67B, 0x5DDE, 0xA67C, 0x5E06,\r\n\t0xA67D, 0x5E76, 0xA67E, 0x5E74, 0xA6A1, 0x5F0F, 0xA6A2, 0x5F1B,\t0xA6A3, 0x5FD9, 0xA6A4, 0x5FD6, 0xA6A5, 0x620E, 0xA6A6, 0x620C,\r\n\t0xA6A7, 0x620D, 0xA6A8, 0x6210, 0xA6A9, 0x6263, 0xA6AA, 0x625B,\t0xA6AB, 0x6258, 0xA6AC, 0x6536, 0xA6AD, 0x65E9, 0xA6AE, 0x65E8,\r\n\t0xA6AF, 0x65EC, 0xA6B0, 0x65ED, 0xA6B1, 0x66F2, 0xA6B2, 0x66F3,\t0xA6B3, 0x6709, 0xA6B4, 0x673D, 0xA6B5, 0x6734, 0xA6B6, 0x6731,\r\n\t0xA6B7, 0x6735, 0xA6B8, 0x6B21, 0xA6B9, 0x6B64, 0xA6BA, 0x6B7B,\t0xA6BB, 0x6C16, 0xA6BC, 0x6C5D, 0xA6BD, 0x6C57, 0xA6BE, 0x6C59,\r\n\t0xA6BF, 0x6C5F, 0xA6C0, 0x6C60, 0xA6C1, 0x6C50, 0xA6C2, 0x6C55,\t0xA6C3, 0x6C61, 0xA6C4, 0x6C5B, 0xA6C5, 0x6C4D, 0xA6C6, 0x6C4E,\r\n\t0xA6C7, 0x7070, 0xA6C8, 0x725F, 0xA6C9, 0x725D, 0xA6CA, 0x767E,\t0xA6CB, 0x7AF9, 0xA6CC, 0x7C73, 0xA6CD, 0x7CF8, 0xA6CE, 0x7F36,\r\n\t0xA6CF, 0x7F8A, 0xA6D0, 0x7FBD, 0xA6D1, 0x8001, 0xA6D2, 0x8003,\t0xA6D3, 0x800C, 0xA6D4, 0x8012, 0xA6D5, 0x8033, 0xA6D6, 0x807F,\r\n\t0xA6D7, 0x8089, 0xA6D8, 0x808B, 0xA6D9, 0x808C, 0xA6DA, 0x81E3,\t0xA6DB, 0x81EA, 0xA6DC, 0x81F3, 0xA6DD, 0x81FC, 0xA6DE, 0x820C,\r\n\t0xA6DF, 0x821B, 0xA6E0, 0x821F, 0xA6E1, 0x826E, 0xA6E2, 0x8272,\t0xA6E3, 0x827E, 0xA6E4, 0x866B, 0xA6E5, 0x8840, 0xA6E6, 0x884C,\r\n\t0xA6E7, 0x8863, 0xA6E8, 0x897F, 0xA6E9, 0x9621, 0xA6EA, 0x4E32,\t0xA6EB, 0x4EA8, 0xA6EC, 0x4F4D, 0xA6ED, 0x4F4F, 0xA6EE, 0x4F47,\r\n\t0xA6EF, 0x4F57, 0xA6F0, 0x4F5E, 0xA6F1, 0x4F34, 0xA6F2, 0x4F5B,\t0xA6F3, 0x4F55, 0xA6F4, 0x4F30, 0xA6F5, 0x4F50, 0xA6F6, 0x4F51,\r\n\t0xA6F7, 0x4F3D, 0xA6F8, 0x4F3A, 0xA6F9, 0x4F38, 0xA6FA, 0x4F43,\t0xA6FB, 0x4F54, 0xA6FC, 0x4F3C, 0xA6FD, 0x4F46, 0xA6FE, 0x4F63,\r\n\t0xA740, 0x4F5C, 0xA741, 0x4F60, 0xA742, 0x4F2F, 0xA743, 0x4F4E,\t0xA744, 0x4F36, 0xA745, 0x4F59, 0xA746, 0x4F5D, 0xA747, 0x4F48,\r\n\t0xA748, 0x4F5A, 0xA749, 0x514C, 0xA74A, 0x514B, 0xA74B, 0x514D,\t0xA74C, 0x5175, 0xA74D, 0x51B6, 0xA74E, 0x51B7, 0xA74F, 0x5225,\r\n\t0xA750, 0x5224, 0xA751, 0x5229, 0xA752, 0x522A, 0xA753, 0x5228,\t0xA754, 0x52AB, 0xA755, 0x52A9, 0xA756, 0x52AA, 0xA757, 0x52AC,\r\n\t0xA758, 0x5323, 0xA759, 0x5373, 0xA75A, 0x5375, 0xA75B, 0x541D,\t0xA75C, 0x542D, 0xA75D, 0x541E, 0xA75E, 0x543E, 0xA75F, 0x5426,\r\n\t0xA760, 0x544E, 0xA761, 0x5427, 0xA762, 0x5446, 0xA763, 0x5443,\t0xA764, 0x5433, 0xA765, 0x5448, 0xA766, 0x5442, 0xA767, 0x541B,\r\n\t0xA768, 0x5429, 0xA769, 0x544A, 0xA76A, 0x5439, 0xA76B, 0x543B,\t0xA76C, 0x5438, 0xA76D, 0x542E, 0xA76E, 0x5435, 0xA76F, 0x5436,\r\n\t0xA770, 0x5420, 0xA771, 0x543C, 0xA772, 0x5440, 0xA773, 0x5431,\t0xA774, 0x542B, 0xA775, 0x541F, 0xA776, 0x542C, 0xA777, 0x56EA,\r\n\t0xA778, 0x56F0, 0xA779, 0x56E4, 0xA77A, 0x56EB, 0xA77B, 0x574A,\t0xA77C, 0x5751, 0xA77D, 0x5740, 0xA77E, 0x574D, 0xA7A1, 0x5747,\r\n\t0xA7A2, 0x574E, 0xA7A3, 0x573E, 0xA7A4, 0x5750, 0xA7A5, 0x574F,\t0xA7A6, 0x573B, 0xA7A7, 0x58EF, 0xA7A8, 0x593E, 0xA7A9, 0x599D,\r\n\t0xA7AA, 0x5992, 0xA7AB, 0x59A8, 0xA7AC, 0x599E, 0xA7AD, 0x59A3,\t0xA7AE, 0x5999, 0xA7AF, 0x5996, 0xA7B0, 0x598D, 0xA7B1, 0x59A4,\r\n\t0xA7B2, 0x5993, 0xA7B3, 0x598A, 0xA7B4, 0x59A5, 0xA7B5, 0x5B5D,\t0xA7B6, 0x5B5C, 0xA7B7, 0x5B5A, 0xA7B8, 0x5B5B, 0xA7B9, 0x5B8C,\r\n\t0xA7BA, 0x5B8B, 0xA7BB, 0x5B8F, 0xA7BC, 0x5C2C, 0xA7BD, 0x5C40,\t0xA7BE, 0x5C41, 0xA7BF, 0x5C3F, 0xA7C0, 0x5C3E, 0xA7C1, 0x5C90,\r\n\t0xA7C2, 0x5C91, 0xA7C3, 0x5C94, 0xA7C4, 0x5C8C, 0xA7C5, 0x5DEB,\t0xA7C6, 0x5E0C, 0xA7C7, 0x5E8F, 0xA7C8, 0x5E87, 0xA7C9, 0x5E8A,\r\n\t0xA7CA, 0x5EF7, 0xA7CB, 0x5F04, 0xA7CC, 0x5F1F, 0xA7CD, 0x5F64,\t0xA7CE, 0x5F62, 0xA7CF, 0x5F77, 0xA7D0, 0x5F79, 0xA7D1, 0x5FD8,\r\n\t0xA7D2, 0x5FCC, 0xA7D3, 0x5FD7, 0xA7D4, 0x5FCD, 0xA7D5, 0x5FF1,\t0xA7D6, 0x5FEB, 0xA7D7, 0x5FF8, 0xA7D8, 0x5FEA, 0xA7D9, 0x6212,\r\n\t0xA7DA, 0x6211, 0xA7DB, 0x6284, 0xA7DC, 0x6297, 0xA7DD, 0x6296,\t0xA7DE, 0x6280, 0xA7DF, 0x6276, 0xA7E0, 0x6289, 0xA7E1, 0x626D,\r\n\t0xA7E2, 0x628A, 0xA7E3, 0x627C, 0xA7E4, 0x627E, 0xA7E5, 0x6279,\t0xA7E6, 0x6273, 0xA7E7, 0x6292, 0xA7E8, 0x626F, 0xA7E9, 0x6298,\r\n\t0xA7EA, 0x626E, 0xA7EB, 0x6295, 0xA7EC, 0x6293, 0xA7ED, 0x6291,\t0xA7EE, 0x6286, 0xA7EF, 0x6539, 0xA7F0, 0x653B, 0xA7F1, 0x6538,\r\n\t0xA7F2, 0x65F1, 0xA7F3, 0x66F4, 0xA7F4, 0x675F, 0xA7F5, 0x674E,\t0xA7F6, 0x674F, 0xA7F7, 0x6750, 0xA7F8, 0x6751, 0xA7F9, 0x675C,\r\n\t0xA7FA, 0x6756, 0xA7FB, 0x675E, 0xA7FC, 0x6749, 0xA7FD, 0x6746,\t0xA7FE, 0x6760, 0xA840, 0x6753, 0xA841, 0x6757, 0xA842, 0x6B65,\r\n\t0xA843, 0x6BCF, 0xA844, 0x6C42, 0xA845, 0x6C5E, 0xA846, 0x6C99,\t0xA847, 0x6C81, 0xA848, 0x6C88, 0xA849, 0x6C89, 0xA84A, 0x6C85,\r\n\t0xA84B, 0x6C9B, 0xA84C, 0x6C6A, 0xA84D, 0x6C7A, 0xA84E, 0x6C90,\t0xA84F, 0x6C70, 0xA850, 0x6C8C, 0xA851, 0x6C68, 0xA852, 0x6C96,\r\n\t0xA853, 0x6C92, 0xA854, 0x6C7D, 0xA855, 0x6C83, 0xA856, 0x6C72,\t0xA857, 0x6C7E, 0xA858, 0x6C74, 0xA859, 0x6C86, 0xA85A, 0x6C76,\r\n\t0xA85B, 0x6C8D, 0xA85C, 0x6C94, 0xA85D, 0x6C98, 0xA85E, 0x6C82,\t0xA85F, 0x7076, 0xA860, 0x707C, 0xA861, 0x707D, 0xA862, 0x7078,\r\n\t0xA863, 0x7262, 0xA864, 0x7261, 0xA865, 0x7260, 0xA866, 0x72C4,\t0xA867, 0x72C2, 0xA868, 0x7396, 0xA869, 0x752C, 0xA86A, 0x752B,\r\n\t0xA86B, 0x7537, 0xA86C, 0x7538, 0xA86D, 0x7682, 0xA86E, 0x76EF,\t0xA86F, 0x77E3, 0xA870, 0x79C1, 0xA871, 0x79C0, 0xA872, 0x79BF,\r\n\t0xA873, 0x7A76, 0xA874, 0x7CFB, 0xA875, 0x7F55, 0xA876, 0x8096,\t0xA877, 0x8093, 0xA878, 0x809D, 0xA879, 0x8098, 0xA87A, 0x809B,\r\n\t0xA87B, 0x809A, 0xA87C, 0x80B2, 0xA87D, 0x826F, 0xA87E, 0x8292,\t0xA8A1, 0x828B, 0xA8A2, 0x828D, 0xA8A3, 0x898B, 0xA8A4, 0x89D2,\r\n\t0xA8A5, 0x8A00, 0xA8A6, 0x8C37, 0xA8A7, 0x8C46, 0xA8A8, 0x8C55,\t0xA8A9, 0x8C9D, 0xA8AA, 0x8D64, 0xA8AB, 0x8D70, 0xA8AC, 0x8DB3,\r\n\t0xA8AD, 0x8EAB, 0xA8AE, 0x8ECA, 0xA8AF, 0x8F9B, 0xA8B0, 0x8FB0,\t0xA8B1, 0x8FC2, 0xA8B2, 0x8FC6, 0xA8B3, 0x8FC5, 0xA8B4, 0x8FC4,\r\n\t0xA8B5, 0x5DE1, 0xA8B6, 0x9091, 0xA8B7, 0x90A2, 0xA8B8, 0x90AA,\t0xA8B9, 0x90A6, 0xA8BA, 0x90A3, 0xA8BB, 0x9149, 0xA8BC, 0x91C6,\r\n\t0xA8BD, 0x91CC, 0xA8BE, 0x9632, 0xA8BF, 0x962E, 0xA8C0, 0x9631,\t0xA8C1, 0x962A, 0xA8C2, 0x962C, 0xA8C3, 0x4E26, 0xA8C4, 0x4E56,\r\n\t0xA8C5, 0x4E73, 0xA8C6, 0x4E8B, 0xA8C7, 0x4E9B, 0xA8C8, 0x4E9E,\t0xA8C9, 0x4EAB, 0xA8CA, 0x4EAC, 0xA8CB, 0x4F6F, 0xA8CC, 0x4F9D,\r\n\t0xA8CD, 0x4F8D, 0xA8CE, 0x4F73, 0xA8CF, 0x4F7F, 0xA8D0, 0x4F6C,\t0xA8D1, 0x4F9B, 0xA8D2, 0x4F8B, 0xA8D3, 0x4F86, 0xA8D4, 0x4F83,\r\n\t0xA8D5, 0x4F70, 0xA8D6, 0x4F75, 0xA8D7, 0x4F88, 0xA8D8, 0x4F69,\t0xA8D9, 0x4F7B, 0xA8DA, 0x4F96, 0xA8DB, 0x4F7E, 0xA8DC, 0x4F8F,\r\n\t0xA8DD, 0x4F91, 0xA8DE, 0x4F7A, 0xA8DF, 0x5154, 0xA8E0, 0x5152,\t0xA8E1, 0x5155, 0xA8E2, 0x5169, 0xA8E3, 0x5177, 0xA8E4, 0x5176,\r\n\t0xA8E5, 0x5178, 0xA8E6, 0x51BD, 0xA8E7, 0x51FD, 0xA8E8, 0x523B,\t0xA8E9, 0x5238, 0xA8EA, 0x5237, 0xA8EB, 0x523A, 0xA8EC, 0x5230,\r\n\t0xA8ED, 0x522E, 0xA8EE, 0x5236, 0xA8EF, 0x5241, 0xA8F0, 0x52BE,\t0xA8F1, 0x52BB, 0xA8F2, 0x5352, 0xA8F3, 0x5354, 0xA8F4, 0x5353,\r\n\t0xA8F5, 0x5351, 0xA8F6, 0x5366, 0xA8F7, 0x5377, 0xA8F8, 0x5378,\t0xA8F9, 0x5379, 0xA8FA, 0x53D6, 0xA8FB, 0x53D4, 0xA8FC, 0x53D7,\r\n\t0xA8FD, 0x5473, 0xA8FE, 0x5475, 0xA940, 0x5496, 0xA941, 0x5478,\t0xA942, 0x5495, 0xA943, 0x5480, 0xA944, 0x547B, 0xA945, 0x5477,\r\n\t0xA946, 0x5484, 0xA947, 0x5492, 0xA948, 0x5486, 0xA949, 0x547C,\t0xA94A, 0x5490, 0xA94B, 0x5471, 0xA94C, 0x5476, 0xA94D, 0x548C,\r\n\t0xA94E, 0x549A, 0xA94F, 0x5462, 0xA950, 0x5468, 0xA951, 0x548B,\t0xA952, 0x547D, 0xA953, 0x548E, 0xA954, 0x56FA, 0xA955, 0x5783,\r\n\t0xA956, 0x5777, 0xA957, 0x576A, 0xA958, 0x5769, 0xA959, 0x5761,\t0xA95A, 0x5766, 0xA95B, 0x5764, 0xA95C, 0x577C, 0xA95D, 0x591C,\r\n\t0xA95E, 0x5949, 0xA95F, 0x5947, 0xA960, 0x5948, 0xA961, 0x5944,\t0xA962, 0x5954, 0xA963, 0x59BE, 0xA964, 0x59BB, 0xA965, 0x59D4,\r\n\t0xA966, 0x59B9, 0xA967, 0x59AE, 0xA968, 0x59D1, 0xA969, 0x59C6,\t0xA96A, 0x59D0, 0xA96B, 0x59CD, 0xA96C, 0x59CB, 0xA96D, 0x59D3,\r\n\t0xA96E, 0x59CA, 0xA96F, 0x59AF, 0xA970, 0x59B3, 0xA971, 0x59D2,\t0xA972, 0x59C5, 0xA973, 0x5B5F, 0xA974, 0x5B64, 0xA975, 0x5B63,\r\n\t0xA976, 0x5B97, 0xA977, 0x5B9A, 0xA978, 0x5B98, 0xA979, 0x5B9C,\t0xA97A, 0x5B99, 0xA97B, 0x5B9B, 0xA97C, 0x5C1A, 0xA97D, 0x5C48,\r\n\t0xA97E, 0x5C45, 0xA9A1, 0x5C46, 0xA9A2, 0x5CB7, 0xA9A3, 0x5CA1,\t0xA9A4, 0x5CB8, 0xA9A5, 0x5CA9, 0xA9A6, 0x5CAB, 0xA9A7, 0x5CB1,\r\n\t0xA9A8, 0x5CB3, 0xA9A9, 0x5E18, 0xA9AA, 0x5E1A, 0xA9AB, 0x5E16,\t0xA9AC, 0x5E15, 0xA9AD, 0x5E1B, 0xA9AE, 0x5E11, 0xA9AF, 0x5E78,\r\n\t0xA9B0, 0x5E9A, 0xA9B1, 0x5E97, 0xA9B2, 0x5E9C, 0xA9B3, 0x5E95,\t0xA9B4, 0x5E96, 0xA9B5, 0x5EF6, 0xA9B6, 0x5F26, 0xA9B7, 0x5F27,\r\n\t0xA9B8, 0x5F29, 0xA9B9, 0x5F80, 0xA9BA, 0x5F81, 0xA9BB, 0x5F7F,\t0xA9BC, 0x5F7C, 0xA9BD, 0x5FDD, 0xA9BE, 0x5FE0, 0xA9BF, 0x5FFD,\r\n\t0xA9C0, 0x5FF5, 0xA9C1, 0x5FFF, 0xA9C2, 0x600F, 0xA9C3, 0x6014,\t0xA9C4, 0x602F, 0xA9C5, 0x6035, 0xA9C6, 0x6016, 0xA9C7, 0x602A,\r\n\t0xA9C8, 0x6015, 0xA9C9, 0x6021, 0xA9CA, 0x6027, 0xA9CB, 0x6029,\t0xA9CC, 0x602B, 0xA9CD, 0x601B, 0xA9CE, 0x6216, 0xA9CF, 0x6215,\r\n\t0xA9D0, 0x623F, 0xA9D1, 0x623E, 0xA9D2, 0x6240, 0xA9D3, 0x627F,\t0xA9D4, 0x62C9, 0xA9D5, 0x62CC, 0xA9D6, 0x62C4, 0xA9D7, 0x62BF,\r\n\t0xA9D8, 0x62C2, 0xA9D9, 0x62B9, 0xA9DA, 0x62D2, 0xA9DB, 0x62DB,\t0xA9DC, 0x62AB, 0xA9DD, 0x62D3, 0xA9DE, 0x62D4, 0xA9DF, 0x62CB,\r\n\t0xA9E0, 0x62C8, 0xA9E1, 0x62A8, 0xA9E2, 0x62BD, 0xA9E3, 0x62BC,\t0xA9E4, 0x62D0, 0xA9E5, 0x62D9, 0xA9E6, 0x62C7, 0xA9E7, 0x62CD,\r\n\t0xA9E8, 0x62B5, 0xA9E9, 0x62DA, 0xA9EA, 0x62B1, 0xA9EB, 0x62D8,\t0xA9EC, 0x62D6, 0xA9ED, 0x62D7, 0xA9EE, 0x62C6, 0xA9EF, 0x62AC,\r\n\t0xA9F0, 0x62CE, 0xA9F1, 0x653E, 0xA9F2, 0x65A7, 0xA9F3, 0x65BC,\t0xA9F4, 0x65FA, 0xA9F5, 0x6614, 0xA9F6, 0x6613, 0xA9F7, 0x660C,\r\n\t0xA9F8, 0x6606, 0xA9F9, 0x6602, 0xA9FA, 0x660E, 0xA9FB, 0x6600,\t0xA9FC, 0x660F, 0xA9FD, 0x6615, 0xA9FE, 0x660A, 0xAA40, 0x6607,\r\n\t0xAA41, 0x670D, 0xAA42, 0x670B, 0xAA43, 0x676D, 0xAA44, 0x678B,\t0xAA45, 0x6795, 0xAA46, 0x6771, 0xAA47, 0x679C, 0xAA48, 0x6773,\r\n\t0xAA49, 0x6777, 0xAA4A, 0x6787, 0xAA4B, 0x679D, 0xAA4C, 0x6797,\t0xAA4D, 0x676F, 0xAA4E, 0x6770, 0xAA4F, 0x677F, 0xAA50, 0x6789,\r\n\t0xAA51, 0x677E, 0xAA52, 0x6790, 0xAA53, 0x6775, 0xAA54, 0x679A,\t0xAA55, 0x6793, 0xAA56, 0x677C, 0xAA57, 0x676A, 0xAA58, 0x6772,\r\n\t0xAA59, 0x6B23, 0xAA5A, 0x6B66, 0xAA5B, 0x6B67, 0xAA5C, 0x6B7F,\t0xAA5D, 0x6C13, 0xAA5E, 0x6C1B, 0xAA5F, 0x6CE3, 0xAA60, 0x6CE8,\r\n\t0xAA61, 0x6CF3, 0xAA62, 0x6CB1, 0xAA63, 0x6CCC, 0xAA64, 0x6CE5,\t0xAA65, 0x6CB3, 0xAA66, 0x6CBD, 0xAA67, 0x6CBE, 0xAA68, 0x6CBC,\r\n\t0xAA69, 0x6CE2, 0xAA6A, 0x6CAB, 0xAA6B, 0x6CD5, 0xAA6C, 0x6CD3,\t0xAA6D, 0x6CB8, 0xAA6E, 0x6CC4, 0xAA6F, 0x6CB9, 0xAA70, 0x6CC1,\r\n\t0xAA71, 0x6CAE, 0xAA72, 0x6CD7, 0xAA73, 0x6CC5, 0xAA74, 0x6CF1,\t0xAA75, 0x6CBF, 0xAA76, 0x6CBB, 0xAA77, 0x6CE1, 0xAA78, 0x6CDB,\r\n\t0xAA79, 0x6CCA, 0xAA7A, 0x6CAC, 0xAA7B, 0x6CEF, 0xAA7C, 0x6CDC,\t0xAA7D, 0x6CD6, 0xAA7E, 0x6CE0, 0xAAA1, 0x7095, 0xAAA2, 0x708E,\r\n\t0xAAA3, 0x7092, 0xAAA4, 0x708A, 0xAAA5, 0x7099, 0xAAA6, 0x722C,\t0xAAA7, 0x722D, 0xAAA8, 0x7238, 0xAAA9, 0x7248, 0xAAAA, 0x7267,\r\n\t0xAAAB, 0x7269, 0xAAAC, 0x72C0, 0xAAAD, 0x72CE, 0xAAAE, 0x72D9,\t0xAAAF, 0x72D7, 0xAAB0, 0x72D0, 0xAAB1, 0x73A9, 0xAAB2, 0x73A8,\r\n\t0xAAB3, 0x739F, 0xAAB4, 0x73AB, 0xAAB5, 0x73A5, 0xAAB6, 0x753D,\t0xAAB7, 0x759D, 0xAAB8, 0x7599, 0xAAB9, 0x759A, 0xAABA, 0x7684,\r\n\t0xAABB, 0x76C2, 0xAABC, 0x76F2, 0xAABD, 0x76F4, 0xAABE, 0x77E5,\t0xAABF, 0x77FD, 0xAAC0, 0x793E, 0xAAC1, 0x7940, 0xAAC2, 0x7941,\r\n\t0xAAC3, 0x79C9, 0xAAC4, 0x79C8, 0xAAC5, 0x7A7A, 0xAAC6, 0x7A79,\t0xAAC7, 0x7AFA, 0xAAC8, 0x7CFE, 0xAAC9, 0x7F54, 0xAACA, 0x7F8C,\r\n\t0xAACB, 0x7F8B, 0xAACC, 0x8005, 0xAACD, 0x80BA, 0xAACE, 0x80A5,\t0xAACF, 0x80A2, 0xAAD0, 0x80B1, 0xAAD1, 0x80A1, 0xAAD2, 0x80AB,\r\n\t0xAAD3, 0x80A9, 0xAAD4, 0x80B4, 0xAAD5, 0x80AA, 0xAAD6, 0x80AF,\t0xAAD7, 0x81E5, 0xAAD8, 0x81FE, 0xAAD9, 0x820D, 0xAADA, 0x82B3,\r\n\t0xAADB, 0x829D, 0xAADC, 0x8299, 0xAADD, 0x82AD, 0xAADE, 0x82BD,\t0xAADF, 0x829F, 0xAAE0, 0x82B9, 0xAAE1, 0x82B1, 0xAAE2, 0x82AC,\r\n\t0xAAE3, 0x82A5, 0xAAE4, 0x82AF, 0xAAE5, 0x82B8, 0xAAE6, 0x82A3,\t0xAAE7, 0x82B0, 0xAAE8, 0x82BE, 0xAAE9, 0x82B7, 0xAAEA, 0x864E,\r\n\t0xAAEB, 0x8671, 0xAAEC, 0x521D, 0xAAED, 0x8868, 0xAAEE, 0x8ECB,\t0xAAEF, 0x8FCE, 0xAAF0, 0x8FD4, 0xAAF1, 0x8FD1, 0xAAF2, 0x90B5,\r\n\t0xAAF3, 0x90B8, 0xAAF4, 0x90B1, 0xAAF5, 0x90B6, 0xAAF6, 0x91C7,\t0xAAF7, 0x91D1, 0xAAF8, 0x9577, 0xAAF9, 0x9580, 0xAAFA, 0x961C,\r\n\t0xAAFB, 0x9640, 0xAAFC, 0x963F, 0xAAFD, 0x963B, 0xAAFE, 0x9644,\t0xAB40, 0x9642, 0xAB41, 0x96B9, 0xAB42, 0x96E8, 0xAB43, 0x9752,\r\n\t0xAB44, 0x975E, 0xAB45, 0x4E9F, 0xAB46, 0x4EAD, 0xAB47, 0x4EAE,\t0xAB48, 0x4FE1, 0xAB49, 0x4FB5, 0xAB4A, 0x4FAF, 0xAB4B, 0x4FBF,\r\n\t0xAB4C, 0x4FE0, 0xAB4D, 0x4FD1, 0xAB4E, 0x4FCF, 0xAB4F, 0x4FDD,\t0xAB50, 0x4FC3, 0xAB51, 0x4FB6, 0xAB52, 0x4FD8, 0xAB53, 0x4FDF,\r\n\t0xAB54, 0x4FCA, 0xAB55, 0x4FD7, 0xAB56, 0x4FAE, 0xAB57, 0x4FD0,\t0xAB58, 0x4FC4, 0xAB59, 0x4FC2, 0xAB5A, 0x4FDA, 0xAB5B, 0x4FCE,\r\n\t0xAB5C, 0x4FDE, 0xAB5D, 0x4FB7, 0xAB5E, 0x5157, 0xAB5F, 0x5192,\t0xAB60, 0x5191, 0xAB61, 0x51A0, 0xAB62, 0x524E, 0xAB63, 0x5243,\r\n\t0xAB64, 0x524A, 0xAB65, 0x524D, 0xAB66, 0x524C, 0xAB67, 0x524B,\t0xAB68, 0x5247, 0xAB69, 0x52C7, 0xAB6A, 0x52C9, 0xAB6B, 0x52C3,\r\n\t0xAB6C, 0x52C1, 0xAB6D, 0x530D, 0xAB6E, 0x5357, 0xAB6F, 0x537B,\t0xAB70, 0x539A, 0xAB71, 0x53DB, 0xAB72, 0x54AC, 0xAB73, 0x54C0,\r\n\t0xAB74, 0x54A8, 0xAB75, 0x54CE, 0xAB76, 0x54C9, 0xAB77, 0x54B8,\t0xAB78, 0x54A6, 0xAB79, 0x54B3, 0xAB7A, 0x54C7, 0xAB7B, 0x54C2,\r\n\t0xAB7C, 0x54BD, 0xAB7D, 0x54AA, 0xAB7E, 0x54C1, 0xABA1, 0x54C4,\t0xABA2, 0x54C8, 0xABA3, 0x54AF, 0xABA4, 0x54AB, 0xABA5, 0x54B1,\r\n\t0xABA6, 0x54BB, 0xABA7, 0x54A9, 0xABA8, 0x54A7, 0xABA9, 0x54BF,\t0xABAA, 0x56FF, 0xABAB, 0x5782, 0xABAC, 0x578B, 0xABAD, 0x57A0,\r\n\t0xABAE, 0x57A3, 0xABAF, 0x57A2, 0xABB0, 0x57CE, 0xABB1, 0x57AE,\t0xABB2, 0x5793, 0xABB3, 0x5955, 0xABB4, 0x5951, 0xABB5, 0x594F,\r\n\t0xABB6, 0x594E, 0xABB7, 0x5950, 0xABB8, 0x59DC, 0xABB9, 0x59D8,\t0xABBA, 0x59FF, 0xABBB, 0x59E3, 0xABBC, 0x59E8, 0xABBD, 0x5A03,\r\n\t0xABBE, 0x59E5, 0xABBF, 0x59EA, 0xABC0, 0x59DA, 0xABC1, 0x59E6,\t0xABC2, 0x5A01, 0xABC3, 0x59FB, 0xABC4, 0x5B69, 0xABC5, 0x5BA3,\r\n\t0xABC6, 0x5BA6, 0xABC7, 0x5BA4, 0xABC8, 0x5BA2, 0xABC9, 0x5BA5,\t0xABCA, 0x5C01, 0xABCB, 0x5C4E, 0xABCC, 0x5C4F, 0xABCD, 0x5C4D,\r\n\t0xABCE, 0x5C4B, 0xABCF, 0x5CD9, 0xABD0, 0x5CD2, 0xABD1, 0x5DF7,\t0xABD2, 0x5E1D, 0xABD3, 0x5E25, 0xABD4, 0x5E1F, 0xABD5, 0x5E7D,\r\n\t0xABD6, 0x5EA0, 0xABD7, 0x5EA6, 0xABD8, 0x5EFA, 0xABD9, 0x5F08,\t0xABDA, 0x5F2D, 0xABDB, 0x5F65, 0xABDC, 0x5F88, 0xABDD, 0x5F85,\r\n\t0xABDE, 0x5F8A, 0xABDF, 0x5F8B, 0xABE0, 0x5F87, 0xABE1, 0x5F8C,\t0xABE2, 0x5F89, 0xABE3, 0x6012, 0xABE4, 0x601D, 0xABE5, 0x6020,\r\n\t0xABE6, 0x6025, 0xABE7, 0x600E, 0xABE8, 0x6028, 0xABE9, 0x604D,\t0xABEA, 0x6070, 0xABEB, 0x6068, 0xABEC, 0x6062, 0xABED, 0x6046,\r\n\t0xABEE, 0x6043, 0xABEF, 0x606C, 0xABF0, 0x606B, 0xABF1, 0x606A,\t0xABF2, 0x6064, 0xABF3, 0x6241, 0xABF4, 0x62DC, 0xABF5, 0x6316,\r\n\t0xABF6, 0x6309, 0xABF7, 0x62FC, 0xABF8, 0x62ED, 0xABF9, 0x6301,\t0xABFA, 0x62EE, 0xABFB, 0x62FD, 0xABFC, 0x6307, 0xABFD, 0x62F1,\r\n\t0xABFE, 0x62F7, 0xAC40, 0x62EF, 0xAC41, 0x62EC, 0xAC42, 0x62FE,\t0xAC43, 0x62F4, 0xAC44, 0x6311, 0xAC45, 0x6302, 0xAC46, 0x653F,\r\n\t0xAC47, 0x6545, 0xAC48, 0x65AB, 0xAC49, 0x65BD, 0xAC4A, 0x65E2,\t0xAC4B, 0x6625, 0xAC4C, 0x662D, 0xAC4D, 0x6620, 0xAC4E, 0x6627,\r\n\t0xAC4F, 0x662F, 0xAC50, 0x661F, 0xAC51, 0x6628, 0xAC52, 0x6631,\t0xAC53, 0x6624, 0xAC54, 0x66F7, 0xAC55, 0x67FF, 0xAC56, 0x67D3,\r\n\t0xAC57, 0x67F1, 0xAC58, 0x67D4, 0xAC59, 0x67D0, 0xAC5A, 0x67EC,\t0xAC5B, 0x67B6, 0xAC5C, 0x67AF, 0xAC5D, 0x67F5, 0xAC5E, 0x67E9,\r\n\t0xAC5F, 0x67EF, 0xAC60, 0x67C4, 0xAC61, 0x67D1, 0xAC62, 0x67B4,\t0xAC63, 0x67DA, 0xAC64, 0x67E5, 0xAC65, 0x67B8, 0xAC66, 0x67CF,\r\n\t0xAC67, 0x67DE, 0xAC68, 0x67F3, 0xAC69, 0x67B0, 0xAC6A, 0x67D9,\t0xAC6B, 0x67E2, 0xAC6C, 0x67DD, 0xAC6D, 0x67D2, 0xAC6E, 0x6B6A,\r\n\t0xAC6F, 0x6B83, 0xAC70, 0x6B86, 0xAC71, 0x6BB5, 0xAC72, 0x6BD2,\t0xAC73, 0x6BD7, 0xAC74, 0x6C1F, 0xAC75, 0x6CC9, 0xAC76, 0x6D0B,\r\n\t0xAC77, 0x6D32, 0xAC78, 0x6D2A, 0xAC79, 0x6D41, 0xAC7A, 0x6D25,\t0xAC7B, 0x6D0C, 0xAC7C, 0x6D31, 0xAC7D, 0x6D1E, 0xAC7E, 0x6D17,\r\n\t0xACA1, 0x6D3B, 0xACA2, 0x6D3D, 0xACA3, 0x6D3E, 0xACA4, 0x6D36,\t0xACA5, 0x6D1B, 0xACA6, 0x6CF5, 0xACA7, 0x6D39, 0xACA8, 0x6D27,\r\n\t0xACA9, 0x6D38, 0xACAA, 0x6D29, 0xACAB, 0x6D2E, 0xACAC, 0x6D35,\t0xACAD, 0x6D0E, 0xACAE, 0x6D2B, 0xACAF, 0x70AB, 0xACB0, 0x70BA,\r\n\t0xACB1, 0x70B3, 0xACB2, 0x70AC, 0xACB3, 0x70AF, 0xACB4, 0x70AD,\t0xACB5, 0x70B8, 0xACB6, 0x70AE, 0xACB7, 0x70A4, 0xACB8, 0x7230,\r\n\t0xACB9, 0x7272, 0xACBA, 0x726F, 0xACBB, 0x7274, 0xACBC, 0x72E9,\t0xACBD, 0x72E0, 0xACBE, 0x72E1, 0xACBF, 0x73B7, 0xACC0, 0x73CA,\r\n\t0xACC1, 0x73BB, 0xACC2, 0x73B2, 0xACC3, 0x73CD, 0xACC4, 0x73C0,\t0xACC5, 0x73B3, 0xACC6, 0x751A, 0xACC7, 0x752D, 0xACC8, 0x754F,\r\n\t0xACC9, 0x754C, 0xACCA, 0x754E, 0xACCB, 0x754B, 0xACCC, 0x75AB,\t0xACCD, 0x75A4, 0xACCE, 0x75A5, 0xACCF, 0x75A2, 0xACD0, 0x75A3,\r\n\t0xACD1, 0x7678, 0xACD2, 0x7686, 0xACD3, 0x7687, 0xACD4, 0x7688,\t0xACD5, 0x76C8, 0xACD6, 0x76C6, 0xACD7, 0x76C3, 0xACD8, 0x76C5,\r\n\t0xACD9, 0x7701, 0xACDA, 0x76F9, 0xACDB, 0x76F8, 0xACDC, 0x7709,\t0xACDD, 0x770B, 0xACDE, 0x76FE, 0xACDF, 0x76FC, 0xACE0, 0x7707,\r\n\t0xACE1, 0x77DC, 0xACE2, 0x7802, 0xACE3, 0x7814, 0xACE4, 0x780C,\t0xACE5, 0x780D, 0xACE6, 0x7946, 0xACE7, 0x7949, 0xACE8, 0x7948,\r\n\t0xACE9, 0x7947, 0xACEA, 0x79B9, 0xACEB, 0x79BA, 0xACEC, 0x79D1,\t0xACED, 0x79D2, 0xACEE, 0x79CB, 0xACEF, 0x7A7F, 0xACF0, 0x7A81,\r\n\t0xACF1, 0x7AFF, 0xACF2, 0x7AFD, 0xACF3, 0x7C7D, 0xACF4, 0x7D02,\t0xACF5, 0x7D05, 0xACF6, 0x7D00, 0xACF7, 0x7D09, 0xACF8, 0x7D07,\r\n\t0xACF9, 0x7D04, 0xACFA, 0x7D06, 0xACFB, 0x7F38, 0xACFC, 0x7F8E,\t0xACFD, 0x7FBF, 0xACFE, 0x8004, 0xAD40, 0x8010, 0xAD41, 0x800D,\r\n\t0xAD42, 0x8011, 0xAD43, 0x8036, 0xAD44, 0x80D6, 0xAD45, 0x80E5,\t0xAD46, 0x80DA, 0xAD47, 0x80C3, 0xAD48, 0x80C4, 0xAD49, 0x80CC,\r\n\t0xAD4A, 0x80E1, 0xAD4B, 0x80DB, 0xAD4C, 0x80CE, 0xAD4D, 0x80DE,\t0xAD4E, 0x80E4, 0xAD4F, 0x80DD, 0xAD50, 0x81F4, 0xAD51, 0x8222,\r\n\t0xAD52, 0x82E7, 0xAD53, 0x8303, 0xAD54, 0x8305, 0xAD55, 0x82E3,\t0xAD56, 0x82DB, 0xAD57, 0x82E6, 0xAD58, 0x8304, 0xAD59, 0x82E5,\r\n\t0xAD5A, 0x8302, 0xAD5B, 0x8309, 0xAD5C, 0x82D2, 0xAD5D, 0x82D7,\t0xAD5E, 0x82F1, 0xAD5F, 0x8301, 0xAD60, 0x82DC, 0xAD61, 0x82D4,\r\n\t0xAD62, 0x82D1, 0xAD63, 0x82DE, 0xAD64, 0x82D3, 0xAD65, 0x82DF,\t0xAD66, 0x82EF, 0xAD67, 0x8306, 0xAD68, 0x8650, 0xAD69, 0x8679,\r\n\t0xAD6A, 0x867B, 0xAD6B, 0x867A, 0xAD6C, 0x884D, 0xAD6D, 0x886B,\t0xAD6E, 0x8981, 0xAD6F, 0x89D4, 0xAD70, 0x8A08, 0xAD71, 0x8A02,\r\n\t0xAD72, 0x8A03, 0xAD73, 0x8C9E, 0xAD74, 0x8CA0, 0xAD75, 0x8D74,\t0xAD76, 0x8D73, 0xAD77, 0x8DB4, 0xAD78, 0x8ECD, 0xAD79, 0x8ECC,\r\n\t0xAD7A, 0x8FF0, 0xAD7B, 0x8FE6, 0xAD7C, 0x8FE2, 0xAD7D, 0x8FEA,\t0xAD7E, 0x8FE5, 0xADA1, 0x8FED, 0xADA2, 0x8FEB, 0xADA3, 0x8FE4,\r\n\t0xADA4, 0x8FE8, 0xADA5, 0x90CA, 0xADA6, 0x90CE, 0xADA7, 0x90C1,\t0xADA8, 0x90C3, 0xADA9, 0x914B, 0xADAA, 0x914A, 0xADAB, 0x91CD,\r\n\t0xADAC, 0x9582, 0xADAD, 0x9650, 0xADAE, 0x964B, 0xADAF, 0x964C,\t0xADB0, 0x964D, 0xADB1, 0x9762, 0xADB2, 0x9769, 0xADB3, 0x97CB,\r\n\t0xADB4, 0x97ED, 0xADB5, 0x97F3, 0xADB6, 0x9801, 0xADB7, 0x98A8,\t0xADB8, 0x98DB, 0xADB9, 0x98DF, 0xADBA, 0x9996, 0xADBB, 0x9999,\r\n\t0xADBC, 0x4E58, 0xADBD, 0x4EB3, 0xADBE, 0x500C, 0xADBF, 0x500D,\t0xADC0, 0x5023, 0xADC1, 0x4FEF, 0xADC2, 0x5026, 0xADC3, 0x5025,\r\n\t0xADC4, 0x4FF8, 0xADC5, 0x5029, 0xADC6, 0x5016, 0xADC7, 0x5006,\t0xADC8, 0x503C, 0xADC9, 0x501F, 0xADCA, 0x501A, 0xADCB, 0x5012,\r\n\t0xADCC, 0x5011, 0xADCD, 0x4FFA, 0xADCE, 0x5000, 0xADCF, 0x5014,\t0xADD0, 0x5028, 0xADD1, 0x4FF1, 0xADD2, 0x5021, 0xADD3, 0x500B,\r\n\t0xADD4, 0x5019, 0xADD5, 0x5018, 0xADD6, 0x4FF3, 0xADD7, 0x4FEE,\t0xADD8, 0x502D, 0xADD9, 0x502A, 0xADDA, 0x4FFE, 0xADDB, 0x502B,\r\n\t0xADDC, 0x5009, 0xADDD, 0x517C, 0xADDE, 0x51A4, 0xADDF, 0x51A5,\t0xADE0, 0x51A2, 0xADE1, 0x51CD, 0xADE2, 0x51CC, 0xADE3, 0x51C6,\r\n\t0xADE4, 0x51CB, 0xADE5, 0x5256, 0xADE6, 0x525C, 0xADE7, 0x5254,\t0xADE8, 0x525B, 0xADE9, 0x525D, 0xADEA, 0x532A, 0xADEB, 0x537F,\r\n\t0xADEC, 0x539F, 0xADED, 0x539D, 0xADEE, 0x53DF, 0xADEF, 0x54E8,\t0xADF0, 0x5510, 0xADF1, 0x5501, 0xADF2, 0x5537, 0xADF3, 0x54FC,\r\n\t0xADF4, 0x54E5, 0xADF5, 0x54F2, 0xADF6, 0x5506, 0xADF7, 0x54FA,\t0xADF8, 0x5514, 0xADF9, 0x54E9, 0xADFA, 0x54ED, 0xADFB, 0x54E1,\r\n\t0xADFC, 0x5509, 0xADFD, 0x54EE, 0xADFE, 0x54EA, 0xAE40, 0x54E6,\t0xAE41, 0x5527, 0xAE42, 0x5507, 0xAE43, 0x54FD, 0xAE44, 0x550F,\r\n\t0xAE45, 0x5703, 0xAE46, 0x5704, 0xAE47, 0x57C2, 0xAE48, 0x57D4,\t0xAE49, 0x57CB, 0xAE4A, 0x57C3, 0xAE4B, 0x5809, 0xAE4C, 0x590F,\r\n\t0xAE4D, 0x5957, 0xAE4E, 0x5958, 0xAE4F, 0x595A, 0xAE50, 0x5A11,\t0xAE51, 0x5A18, 0xAE52, 0x5A1C, 0xAE53, 0x5A1F, 0xAE54, 0x5A1B,\r\n\t0xAE55, 0x5A13, 0xAE56, 0x59EC, 0xAE57, 0x5A20, 0xAE58, 0x5A23,\t0xAE59, 0x5A29, 0xAE5A, 0x5A25, 0xAE5B, 0x5A0C, 0xAE5C, 0x5A09,\r\n\t0xAE5D, 0x5B6B, 0xAE5E, 0x5C58, 0xAE5F, 0x5BB0, 0xAE60, 0x5BB3,\t0xAE61, 0x5BB6, 0xAE62, 0x5BB4, 0xAE63, 0x5BAE, 0xAE64, 0x5BB5,\r\n\t0xAE65, 0x5BB9, 0xAE66, 0x5BB8, 0xAE67, 0x5C04, 0xAE68, 0x5C51,\t0xAE69, 0x5C55, 0xAE6A, 0x5C50, 0xAE6B, 0x5CED, 0xAE6C, 0x5CFD,\r\n\t0xAE6D, 0x5CFB, 0xAE6E, 0x5CEA, 0xAE6F, 0x5CE8, 0xAE70, 0x5CF0,\t0xAE71, 0x5CF6, 0xAE72, 0x5D01, 0xAE73, 0x5CF4, 0xAE74, 0x5DEE,\r\n\t0xAE75, 0x5E2D, 0xAE76, 0x5E2B, 0xAE77, 0x5EAB, 0xAE78, 0x5EAD,\t0xAE79, 0x5EA7, 0xAE7A, 0x5F31, 0xAE7B, 0x5F92, 0xAE7C, 0x5F91,\r\n\t0xAE7D, 0x5F90, 0xAE7E, 0x6059, 0xAEA1, 0x6063, 0xAEA2, 0x6065,\t0xAEA3, 0x6050, 0xAEA4, 0x6055, 0xAEA5, 0x606D, 0xAEA6, 0x6069,\r\n\t0xAEA7, 0x606F, 0xAEA8, 0x6084, 0xAEA9, 0x609F, 0xAEAA, 0x609A,\t0xAEAB, 0x608D, 0xAEAC, 0x6094, 0xAEAD, 0x608C, 0xAEAE, 0x6085,\r\n\t0xAEAF, 0x6096, 0xAEB0, 0x6247, 0xAEB1, 0x62F3, 0xAEB2, 0x6308,\t0xAEB3, 0x62FF, 0xAEB4, 0x634E, 0xAEB5, 0x633E, 0xAEB6, 0x632F,\r\n\t0xAEB7, 0x6355, 0xAEB8, 0x6342, 0xAEB9, 0x6346, 0xAEBA, 0x634F,\t0xAEBB, 0x6349, 0xAEBC, 0x633A, 0xAEBD, 0x6350, 0xAEBE, 0x633D,\r\n\t0xAEBF, 0x632A, 0xAEC0, 0x632B, 0xAEC1, 0x6328, 0xAEC2, 0x634D,\t0xAEC3, 0x634C, 0xAEC4, 0x6548, 0xAEC5, 0x6549, 0xAEC6, 0x6599,\r\n\t0xAEC7, 0x65C1, 0xAEC8, 0x65C5, 0xAEC9, 0x6642, 0xAECA, 0x6649,\t0xAECB, 0x664F, 0xAECC, 0x6643, 0xAECD, 0x6652, 0xAECE, 0x664C,\r\n\t0xAECF, 0x6645, 0xAED0, 0x6641, 0xAED1, 0x66F8, 0xAED2, 0x6714,\t0xAED3, 0x6715, 0xAED4, 0x6717, 0xAED5, 0x6821, 0xAED6, 0x6838,\r\n\t0xAED7, 0x6848, 0xAED8, 0x6846, 0xAED9, 0x6853, 0xAEDA, 0x6839,\t0xAEDB, 0x6842, 0xAEDC, 0x6854, 0xAEDD, 0x6829, 0xAEDE, 0x68B3,\r\n\t0xAEDF, 0x6817, 0xAEE0, 0x684C, 0xAEE1, 0x6851, 0xAEE2, 0x683D,\t0xAEE3, 0x67F4, 0xAEE4, 0x6850, 0xAEE5, 0x6840, 0xAEE6, 0x683C,\r\n\t0xAEE7, 0x6843, 0xAEE8, 0x682A, 0xAEE9, 0x6845, 0xAEEA, 0x6813,\t0xAEEB, 0x6818, 0xAEEC, 0x6841, 0xAEED, 0x6B8A, 0xAEEE, 0x6B89,\r\n\t0xAEEF, 0x6BB7, 0xAEF0, 0x6C23, 0xAEF1, 0x6C27, 0xAEF2, 0x6C28,\t0xAEF3, 0x6C26, 0xAEF4, 0x6C24, 0xAEF5, 0x6CF0, 0xAEF6, 0x6D6A,\r\n\t0xAEF7, 0x6D95, 0xAEF8, 0x6D88, 0xAEF9, 0x6D87, 0xAEFA, 0x6D66,\t0xAEFB, 0x6D78, 0xAEFC, 0x6D77, 0xAEFD, 0x6D59, 0xAEFE, 0x6D93,\r\n\t0xAF40, 0x6D6C, 0xAF41, 0x6D89, 0xAF42, 0x6D6E, 0xAF43, 0x6D5A,\t0xAF44, 0x6D74, 0xAF45, 0x6D69, 0xAF46, 0x6D8C, 0xAF47, 0x6D8A,\r\n\t0xAF48, 0x6D79, 0xAF49, 0x6D85, 0xAF4A, 0x6D65, 0xAF4B, 0x6D94,\t0xAF4C, 0x70CA, 0xAF4D, 0x70D8, 0xAF4E, 0x70E4, 0xAF4F, 0x70D9,\r\n\t0xAF50, 0x70C8, 0xAF51, 0x70CF, 0xAF52, 0x7239, 0xAF53, 0x7279,\t0xAF54, 0x72FC, 0xAF55, 0x72F9, 0xAF56, 0x72FD, 0xAF57, 0x72F8,\r\n\t0xAF58, 0x72F7, 0xAF59, 0x7386, 0xAF5A, 0x73ED, 0xAF5B, 0x7409,\t0xAF5C, 0x73EE, 0xAF5D, 0x73E0, 0xAF5E, 0x73EA, 0xAF5F, 0x73DE,\r\n\t0xAF60, 0x7554, 0xAF61, 0x755D, 0xAF62, 0x755C, 0xAF63, 0x755A,\t0xAF64, 0x7559, 0xAF65, 0x75BE, 0xAF66, 0x75C5, 0xAF67, 0x75C7,\r\n\t0xAF68, 0x75B2, 0xAF69, 0x75B3, 0xAF6A, 0x75BD, 0xAF6B, 0x75BC,\t0xAF6C, 0x75B9, 0xAF6D, 0x75C2, 0xAF6E, 0x75B8, 0xAF6F, 0x768B,\r\n\t0xAF70, 0x76B0, 0xAF71, 0x76CA, 0xAF72, 0x76CD, 0xAF73, 0x76CE,\t0xAF74, 0x7729, 0xAF75, 0x771F, 0xAF76, 0x7720, 0xAF77, 0x7728,\r\n\t0xAF78, 0x77E9, 0xAF79, 0x7830, 0xAF7A, 0x7827, 0xAF7B, 0x7838,\t0xAF7C, 0x781D, 0xAF7D, 0x7834, 0xAF7E, 0x7837, 0xAFA1, 0x7825,\r\n\t0xAFA2, 0x782D, 0xAFA3, 0x7820, 0xAFA4, 0x781F, 0xAFA5, 0x7832,\t0xAFA6, 0x7955, 0xAFA7, 0x7950, 0xAFA8, 0x7960, 0xAFA9, 0x795F,\r\n\t0xAFAA, 0x7956, 0xAFAB, 0x795E, 0xAFAC, 0x795D, 0xAFAD, 0x7957,\t0xAFAE, 0x795A, 0xAFAF, 0x79E4, 0xAFB0, 0x79E3, 0xAFB1, 0x79E7,\r\n\t0xAFB2, 0x79DF, 0xAFB3, 0x79E6, 0xAFB4, 0x79E9, 0xAFB5, 0x79D8,\t0xAFB6, 0x7A84, 0xAFB7, 0x7A88, 0xAFB8, 0x7AD9, 0xAFB9, 0x7B06,\r\n\t0xAFBA, 0x7B11, 0xAFBB, 0x7C89, 0xAFBC, 0x7D21, 0xAFBD, 0x7D17,\t0xAFBE, 0x7D0B, 0xAFBF, 0x7D0A, 0xAFC0, 0x7D20, 0xAFC1, 0x7D22,\r\n\t0xAFC2, 0x7D14, 0xAFC3, 0x7D10, 0xAFC4, 0x7D15, 0xAFC5, 0x7D1A,\t0xAFC6, 0x7D1C, 0xAFC7, 0x7D0D, 0xAFC8, 0x7D19, 0xAFC9, 0x7D1B,\r\n\t0xAFCA, 0x7F3A, 0xAFCB, 0x7F5F, 0xAFCC, 0x7F94, 0xAFCD, 0x7FC5,\t0xAFCE, 0x7FC1, 0xAFCF, 0x8006, 0xAFD0, 0x8018, 0xAFD1, 0x8015,\r\n\t0xAFD2, 0x8019, 0xAFD3, 0x8017, 0xAFD4, 0x803D, 0xAFD5, 0x803F,\t0xAFD6, 0x80F1, 0xAFD7, 0x8102, 0xAFD8, 0x80F0, 0xAFD9, 0x8105,\r\n\t0xAFDA, 0x80ED, 0xAFDB, 0x80F4, 0xAFDC, 0x8106, 0xAFDD, 0x80F8,\t0xAFDE, 0x80F3, 0xAFDF, 0x8108, 0xAFE0, 0x80FD, 0xAFE1, 0x810A,\r\n\t0xAFE2, 0x80FC, 0xAFE3, 0x80EF, 0xAFE4, 0x81ED, 0xAFE5, 0x81EC,\t0xAFE6, 0x8200, 0xAFE7, 0x8210, 0xAFE8, 0x822A, 0xAFE9, 0x822B,\r\n\t0xAFEA, 0x8228, 0xAFEB, 0x822C, 0xAFEC, 0x82BB, 0xAFED, 0x832B,\t0xAFEE, 0x8352, 0xAFEF, 0x8354, 0xAFF0, 0x834A, 0xAFF1, 0x8338,\r\n\t0xAFF2, 0x8350, 0xAFF3, 0x8349, 0xAFF4, 0x8335, 0xAFF5, 0x8334,\t0xAFF6, 0x834F, 0xAFF7, 0x8332, 0xAFF8, 0x8339, 0xAFF9, 0x8336,\r\n\t0xAFFA, 0x8317, 0xAFFB, 0x8340, 0xAFFC, 0x8331, 0xAFFD, 0x8328,\t0xAFFE, 0x8343, 0xB040, 0x8654, 0xB041, 0x868A, 0xB042, 0x86AA,\r\n\t0xB043, 0x8693, 0xB044, 0x86A4, 0xB045, 0x86A9, 0xB046, 0x868C,\t0xB047, 0x86A3, 0xB048, 0x869C, 0xB049, 0x8870, 0xB04A, 0x8877,\r\n\t0xB04B, 0x8881, 0xB04C, 0x8882, 0xB04D, 0x887D, 0xB04E, 0x8879,\t0xB04F, 0x8A18, 0xB050, 0x8A10, 0xB051, 0x8A0E, 0xB052, 0x8A0C,\r\n\t0xB053, 0x8A15, 0xB054, 0x8A0A, 0xB055, 0x8A17, 0xB056, 0x8A13,\t0xB057, 0x8A16, 0xB058, 0x8A0F, 0xB059, 0x8A11, 0xB05A, 0x8C48,\r\n\t0xB05B, 0x8C7A, 0xB05C, 0x8C79, 0xB05D, 0x8CA1, 0xB05E, 0x8CA2,\t0xB05F, 0x8D77, 0xB060, 0x8EAC, 0xB061, 0x8ED2, 0xB062, 0x8ED4,\r\n\t0xB063, 0x8ECF, 0xB064, 0x8FB1, 0xB065, 0x9001, 0xB066, 0x9006,\t0xB067, 0x8FF7, 0xB068, 0x9000, 0xB069, 0x8FFA, 0xB06A, 0x8FF4,\r\n\t0xB06B, 0x9003, 0xB06C, 0x8FFD, 0xB06D, 0x9005, 0xB06E, 0x8FF8,\t0xB06F, 0x9095, 0xB070, 0x90E1, 0xB071, 0x90DD, 0xB072, 0x90E2,\r\n\t0xB073, 0x9152, 0xB074, 0x914D, 0xB075, 0x914C, 0xB076, 0x91D8,\t0xB077, 0x91DD, 0xB078, 0x91D7, 0xB079, 0x91DC, 0xB07A, 0x91D9,\r\n\t0xB07B, 0x9583, 0xB07C, 0x9662, 0xB07D, 0x9663, 0xB07E, 0x9661,\t0xB0A1, 0x965B, 0xB0A2, 0x965D, 0xB0A3, 0x9664, 0xB0A4, 0x9658,\r\n\t0xB0A5, 0x965E, 0xB0A6, 0x96BB, 0xB0A7, 0x98E2, 0xB0A8, 0x99AC,\t0xB0A9, 0x9AA8, 0xB0AA, 0x9AD8, 0xB0AB, 0x9B25, 0xB0AC, 0x9B32,\r\n\t0xB0AD, 0x9B3C, 0xB0AE, 0x4E7E, 0xB0AF, 0x507A, 0xB0B0, 0x507D,\t0xB0B1, 0x505C, 0xB0B2, 0x5047, 0xB0B3, 0x5043, 0xB0B4, 0x504C,\r\n\t0xB0B5, 0x505A, 0xB0B6, 0x5049, 0xB0B7, 0x5065, 0xB0B8, 0x5076,\t0xB0B9, 0x504E, 0xB0BA, 0x5055, 0xB0BB, 0x5075, 0xB0BC, 0x5074,\r\n\t0xB0BD, 0x5077, 0xB0BE, 0x504F, 0xB0BF, 0x500F, 0xB0C0, 0x506F,\t0xB0C1, 0x506D, 0xB0C2, 0x515C, 0xB0C3, 0x5195, 0xB0C4, 0x51F0,\r\n\t0xB0C5, 0x526A, 0xB0C6, 0x526F, 0xB0C7, 0x52D2, 0xB0C8, 0x52D9,\t0xB0C9, 0x52D8, 0xB0CA, 0x52D5, 0xB0CB, 0x5310, 0xB0CC, 0x530F,\r\n\t0xB0CD, 0x5319, 0xB0CE, 0x533F, 0xB0CF, 0x5340, 0xB0D0, 0x533E,\t0xB0D1, 0x53C3, 0xB0D2, 0x66FC, 0xB0D3, 0x5546, 0xB0D4, 0x556A,\r\n\t0xB0D5, 0x5566, 0xB0D6, 0x5544, 0xB0D7, 0x555E, 0xB0D8, 0x5561,\t0xB0D9, 0x5543, 0xB0DA, 0x554A, 0xB0DB, 0x5531, 0xB0DC, 0x5556,\r\n\t0xB0DD, 0x554F, 0xB0DE, 0x5555, 0xB0DF, 0x552F, 0xB0E0, 0x5564,\t0xB0E1, 0x5538, 0xB0E2, 0x552E, 0xB0E3, 0x555C, 0xB0E4, 0x552C,\r\n\t0xB0E5, 0x5563, 0xB0E6, 0x5533, 0xB0E7, 0x5541, 0xB0E8, 0x5557,\t0xB0E9, 0x5708, 0xB0EA, 0x570B, 0xB0EB, 0x5709, 0xB0EC, 0x57DF,\r\n\t0xB0ED, 0x5805, 0xB0EE, 0x580A, 0xB0EF, 0x5806, 0xB0F0, 0x57E0,\t0xB0F1, 0x57E4, 0xB0F2, 0x57FA, 0xB0F3, 0x5802, 0xB0F4, 0x5835,\r\n\t0xB0F5, 0x57F7, 0xB0F6, 0x57F9, 0xB0F7, 0x5920, 0xB0F8, 0x5962,\t0xB0F9, 0x5A36, 0xB0FA, 0x5A41, 0xB0FB, 0x5A49, 0xB0FC, 0x5A66,\r\n\t0xB0FD, 0x5A6A, 0xB0FE, 0x5A40, 0xB140, 0x5A3C, 0xB141, 0x5A62,\t0xB142, 0x5A5A, 0xB143, 0x5A46, 0xB144, 0x5A4A, 0xB145, 0x5B70,\r\n\t0xB146, 0x5BC7, 0xB147, 0x5BC5, 0xB148, 0x5BC4, 0xB149, 0x5BC2,\t0xB14A, 0x5BBF, 0xB14B, 0x5BC6, 0xB14C, 0x5C09, 0xB14D, 0x5C08,\r\n\t0xB14E, 0x5C07, 0xB14F, 0x5C60, 0xB150, 0x5C5C, 0xB151, 0x5C5D,\t0xB152, 0x5D07, 0xB153, 0x5D06, 0xB154, 0x5D0E, 0xB155, 0x5D1B,\r\n\t0xB156, 0x5D16, 0xB157, 0x5D22, 0xB158, 0x5D11, 0xB159, 0x5D29,\t0xB15A, 0x5D14, 0xB15B, 0x5D19, 0xB15C, 0x5D24, 0xB15D, 0x5D27,\r\n\t0xB15E, 0x5D17, 0xB15F, 0x5DE2, 0xB160, 0x5E38, 0xB161, 0x5E36,\t0xB162, 0x5E33, 0xB163, 0x5E37, 0xB164, 0x5EB7, 0xB165, 0x5EB8,\r\n\t0xB166, 0x5EB6, 0xB167, 0x5EB5, 0xB168, 0x5EBE, 0xB169, 0x5F35,\t0xB16A, 0x5F37, 0xB16B, 0x5F57, 0xB16C, 0x5F6C, 0xB16D, 0x5F69,\r\n\t0xB16E, 0x5F6B, 0xB16F, 0x5F97, 0xB170, 0x5F99, 0xB171, 0x5F9E,\t0xB172, 0x5F98, 0xB173, 0x5FA1, 0xB174, 0x5FA0, 0xB175, 0x5F9C,\r\n\t0xB176, 0x607F, 0xB177, 0x60A3, 0xB178, 0x6089, 0xB179, 0x60A0,\t0xB17A, 0x60A8, 0xB17B, 0x60CB, 0xB17C, 0x60B4, 0xB17D, 0x60E6,\r\n\t0xB17E, 0x60BD, 0xB1A1, 0x60C5, 0xB1A2, 0x60BB, 0xB1A3, 0x60B5,\t0xB1A4, 0x60DC, 0xB1A5, 0x60BC, 0xB1A6, 0x60D8, 0xB1A7, 0x60D5,\r\n\t0xB1A8, 0x60C6, 0xB1A9, 0x60DF, 0xB1AA, 0x60B8, 0xB1AB, 0x60DA,\t0xB1AC, 0x60C7, 0xB1AD, 0x621A, 0xB1AE, 0x621B, 0xB1AF, 0x6248,\r\n\t0xB1B0, 0x63A0, 0xB1B1, 0x63A7, 0xB1B2, 0x6372, 0xB1B3, 0x6396,\t0xB1B4, 0x63A2, 0xB1B5, 0x63A5, 0xB1B6, 0x6377, 0xB1B7, 0x6367,\r\n\t0xB1B8, 0x6398, 0xB1B9, 0x63AA, 0xB1BA, 0x6371, 0xB1BB, 0x63A9,\t0xB1BC, 0x6389, 0xB1BD, 0x6383, 0xB1BE, 0x639B, 0xB1BF, 0x636B,\r\n\t0xB1C0, 0x63A8, 0xB1C1, 0x6384, 0xB1C2, 0x6388, 0xB1C3, 0x6399,\t0xB1C4, 0x63A1, 0xB1C5, 0x63AC, 0xB1C6, 0x6392, 0xB1C7, 0x638F,\r\n\t0xB1C8, 0x6380, 0xB1C9, 0x637B, 0xB1CA, 0x6369, 0xB1CB, 0x6368,\t0xB1CC, 0x637A, 0xB1CD, 0x655D, 0xB1CE, 0x6556, 0xB1CF, 0x6551,\r\n\t0xB1D0, 0x6559, 0xB1D1, 0x6557, 0xB1D2, 0x555F, 0xB1D3, 0x654F,\t0xB1D4, 0x6558, 0xB1D5, 0x6555, 0xB1D6, 0x6554, 0xB1D7, 0x659C,\r\n\t0xB1D8, 0x659B, 0xB1D9, 0x65AC, 0xB1DA, 0x65CF, 0xB1DB, 0x65CB,\t0xB1DC, 0x65CC, 0xB1DD, 0x65CE, 0xB1DE, 0x665D, 0xB1DF, 0x665A,\r\n\t0xB1E0, 0x6664, 0xB1E1, 0x6668, 0xB1E2, 0x6666, 0xB1E3, 0x665E,\t0xB1E4, 0x66F9, 0xB1E5, 0x52D7, 0xB1E6, 0x671B, 0xB1E7, 0x6881,\r\n\t0xB1E8, 0x68AF, 0xB1E9, 0x68A2, 0xB1EA, 0x6893, 0xB1EB, 0x68B5,\t0xB1EC, 0x687F, 0xB1ED, 0x6876, 0xB1EE, 0x68B1, 0xB1EF, 0x68A7,\r\n\t0xB1F0, 0x6897, 0xB1F1, 0x68B0, 0xB1F2, 0x6883, 0xB1F3, 0x68C4,\t0xB1F4, 0x68AD, 0xB1F5, 0x6886, 0xB1F6, 0x6885, 0xB1F7, 0x6894,\r\n\t0xB1F8, 0x689D, 0xB1F9, 0x68A8, 0xB1FA, 0x689F, 0xB1FB, 0x68A1,\t0xB1FC, 0x6882, 0xB1FD, 0x6B32, 0xB1FE, 0x6BBA, 0xB240, 0x6BEB,\r\n\t0xB241, 0x6BEC, 0xB242, 0x6C2B, 0xB243, 0x6D8E, 0xB244, 0x6DBC,\t0xB245, 0x6DF3, 0xB246, 0x6DD9, 0xB247, 0x6DB2, 0xB248, 0x6DE1,\r\n\t0xB249, 0x6DCC, 0xB24A, 0x6DE4, 0xB24B, 0x6DFB, 0xB24C, 0x6DFA,\t0xB24D, 0x6E05, 0xB24E, 0x6DC7, 0xB24F, 0x6DCB, 0xB250, 0x6DAF,\r\n\t0xB251, 0x6DD1, 0xB252, 0x6DAE, 0xB253, 0x6DDE, 0xB254, 0x6DF9,\t0xB255, 0x6DB8, 0xB256, 0x6DF7, 0xB257, 0x6DF5, 0xB258, 0x6DC5,\r\n\t0xB259, 0x6DD2, 0xB25A, 0x6E1A, 0xB25B, 0x6DB5, 0xB25C, 0x6DDA,\t0xB25D, 0x6DEB, 0xB25E, 0x6DD8, 0xB25F, 0x6DEA, 0xB260, 0x6DF1,\r\n\t0xB261, 0x6DEE, 0xB262, 0x6DE8, 0xB263, 0x6DC6, 0xB264, 0x6DC4,\t0xB265, 0x6DAA, 0xB266, 0x6DEC, 0xB267, 0x6DBF, 0xB268, 0x6DE6,\r\n\t0xB269, 0x70F9, 0xB26A, 0x7109, 0xB26B, 0x710A, 0xB26C, 0x70FD,\t0xB26D, 0x70EF, 0xB26E, 0x723D, 0xB26F, 0x727D, 0xB270, 0x7281,\r\n\t0xB271, 0x731C, 0xB272, 0x731B, 0xB273, 0x7316, 0xB274, 0x7313,\t0xB275, 0x7319, 0xB276, 0x7387, 0xB277, 0x7405, 0xB278, 0x740A,\r\n\t0xB279, 0x7403, 0xB27A, 0x7406, 0xB27B, 0x73FE, 0xB27C, 0x740D,\t0xB27D, 0x74E0, 0xB27E, 0x74F6, 0xB2A1, 0x74F7, 0xB2A2, 0x751C,\r\n\t0xB2A3, 0x7522, 0xB2A4, 0x7565, 0xB2A5, 0x7566, 0xB2A6, 0x7562,\t0xB2A7, 0x7570, 0xB2A8, 0x758F, 0xB2A9, 0x75D4, 0xB2AA, 0x75D5,\r\n\t0xB2AB, 0x75B5, 0xB2AC, 0x75CA, 0xB2AD, 0x75CD, 0xB2AE, 0x768E,\t0xB2AF, 0x76D4, 0xB2B0, 0x76D2, 0xB2B1, 0x76DB, 0xB2B2, 0x7737,\r\n\t0xB2B3, 0x773E, 0xB2B4, 0x773C, 0xB2B5, 0x7736, 0xB2B6, 0x7738,\t0xB2B7, 0x773A, 0xB2B8, 0x786B, 0xB2B9, 0x7843, 0xB2BA, 0x784E,\r\n\t0xB2BB, 0x7965, 0xB2BC, 0x7968, 0xB2BD, 0x796D, 0xB2BE, 0x79FB,\t0xB2BF, 0x7A92, 0xB2C0, 0x7A95, 0xB2C1, 0x7B20, 0xB2C2, 0x7B28,\r\n\t0xB2C3, 0x7B1B, 0xB2C4, 0x7B2C, 0xB2C5, 0x7B26, 0xB2C6, 0x7B19,\t0xB2C7, 0x7B1E, 0xB2C8, 0x7B2E, 0xB2C9, 0x7C92, 0xB2CA, 0x7C97,\r\n\t0xB2CB, 0x7C95, 0xB2CC, 0x7D46, 0xB2CD, 0x7D43, 0xB2CE, 0x7D71,\t0xB2CF, 0x7D2E, 0xB2D0, 0x7D39, 0xB2D1, 0x7D3C, 0xB2D2, 0x7D40,\r\n\t0xB2D3, 0x7D30, 0xB2D4, 0x7D33, 0xB2D5, 0x7D44, 0xB2D6, 0x7D2F,\t0xB2D7, 0x7D42, 0xB2D8, 0x7D32, 0xB2D9, 0x7D31, 0xB2DA, 0x7F3D,\r\n\t0xB2DB, 0x7F9E, 0xB2DC, 0x7F9A, 0xB2DD, 0x7FCC, 0xB2DE, 0x7FCE,\t0xB2DF, 0x7FD2, 0xB2E0, 0x801C, 0xB2E1, 0x804A, 0xB2E2, 0x8046,\r\n\t0xB2E3, 0x812F, 0xB2E4, 0x8116, 0xB2E5, 0x8123, 0xB2E6, 0x812B,\t0xB2E7, 0x8129, 0xB2E8, 0x8130, 0xB2E9, 0x8124, 0xB2EA, 0x8202,\r\n\t0xB2EB, 0x8235, 0xB2EC, 0x8237, 0xB2ED, 0x8236, 0xB2EE, 0x8239,\t0xB2EF, 0x838E, 0xB2F0, 0x839E, 0xB2F1, 0x8398, 0xB2F2, 0x8378,\r\n\t0xB2F3, 0x83A2, 0xB2F4, 0x8396, 0xB2F5, 0x83BD, 0xB2F6, 0x83AB,\t0xB2F7, 0x8392, 0xB2F8, 0x838A, 0xB2F9, 0x8393, 0xB2FA, 0x8389,\r\n\t0xB2FB, 0x83A0, 0xB2FC, 0x8377, 0xB2FD, 0x837B, 0xB2FE, 0x837C,\t0xB340, 0x8386, 0xB341, 0x83A7, 0xB342, 0x8655, 0xB343, 0x5F6A,\r\n\t0xB344, 0x86C7, 0xB345, 0x86C0, 0xB346, 0x86B6, 0xB347, 0x86C4,\t0xB348, 0x86B5, 0xB349, 0x86C6, 0xB34A, 0x86CB, 0xB34B, 0x86B1,\r\n\t0xB34C, 0x86AF, 0xB34D, 0x86C9, 0xB34E, 0x8853, 0xB34F, 0x889E,\t0xB350, 0x8888, 0xB351, 0x88AB, 0xB352, 0x8892, 0xB353, 0x8896,\r\n\t0xB354, 0x888D, 0xB355, 0x888B, 0xB356, 0x8993, 0xB357, 0x898F,\t0xB358, 0x8A2A, 0xB359, 0x8A1D, 0xB35A, 0x8A23, 0xB35B, 0x8A25,\r\n\t0xB35C, 0x8A31, 0xB35D, 0x8A2D, 0xB35E, 0x8A1F, 0xB35F, 0x8A1B,\t0xB360, 0x8A22, 0xB361, 0x8C49, 0xB362, 0x8C5A, 0xB363, 0x8CA9,\r\n\t0xB364, 0x8CAC, 0xB365, 0x8CAB, 0xB366, 0x8CA8, 0xB367, 0x8CAA,\t0xB368, 0x8CA7, 0xB369, 0x8D67, 0xB36A, 0x8D66, 0xB36B, 0x8DBE,\r\n\t0xB36C, 0x8DBA, 0xB36D, 0x8EDB, 0xB36E, 0x8EDF, 0xB36F, 0x9019,\t0xB370, 0x900D, 0xB371, 0x901A, 0xB372, 0x9017, 0xB373, 0x9023,\r\n\t0xB374, 0x901F, 0xB375, 0x901D, 0xB376, 0x9010, 0xB377, 0x9015,\t0xB378, 0x901E, 0xB379, 0x9020, 0xB37A, 0x900F, 0xB37B, 0x9022,\r\n\t0xB37C, 0x9016, 0xB37D, 0x901B, 0xB37E, 0x9014, 0xB3A1, 0x90E8,\t0xB3A2, 0x90ED, 0xB3A3, 0x90FD, 0xB3A4, 0x9157, 0xB3A5, 0x91CE,\r\n\t0xB3A6, 0x91F5, 0xB3A7, 0x91E6, 0xB3A8, 0x91E3, 0xB3A9, 0x91E7,\t0xB3AA, 0x91ED, 0xB3AB, 0x91E9, 0xB3AC, 0x9589, 0xB3AD, 0x966A,\r\n\t0xB3AE, 0x9675, 0xB3AF, 0x9673, 0xB3B0, 0x9678, 0xB3B1, 0x9670,\t0xB3B2, 0x9674, 0xB3B3, 0x9676, 0xB3B4, 0x9677, 0xB3B5, 0x966C,\r\n\t0xB3B6, 0x96C0, 0xB3B7, 0x96EA, 0xB3B8, 0x96E9, 0xB3B9, 0x7AE0,\t0xB3BA, 0x7ADF, 0xB3BB, 0x9802, 0xB3BC, 0x9803, 0xB3BD, 0x9B5A,\r\n\t0xB3BE, 0x9CE5, 0xB3BF, 0x9E75, 0xB3C0, 0x9E7F, 0xB3C1, 0x9EA5,\t0xB3C2, 0x9EBB, 0xB3C3, 0x50A2, 0xB3C4, 0x508D, 0xB3C5, 0x5085,\r\n\t0xB3C6, 0x5099, 0xB3C7, 0x5091, 0xB3C8, 0x5080, 0xB3C9, 0x5096,\t0xB3CA, 0x5098, 0xB3CB, 0x509A, 0xB3CC, 0x6700, 0xB3CD, 0x51F1,\r\n\t0xB3CE, 0x5272, 0xB3CF, 0x5274, 0xB3D0, 0x5275, 0xB3D1, 0x5269,\t0xB3D2, 0x52DE, 0xB3D3, 0x52DD, 0xB3D4, 0x52DB, 0xB3D5, 0x535A,\r\n\t0xB3D6, 0x53A5, 0xB3D7, 0x557B, 0xB3D8, 0x5580, 0xB3D9, 0x55A7,\t0xB3DA, 0x557C, 0xB3DB, 0x558A, 0xB3DC, 0x559D, 0xB3DD, 0x5598,\r\n\t0xB3DE, 0x5582, 0xB3DF, 0x559C, 0xB3E0, 0x55AA, 0xB3E1, 0x5594,\t0xB3E2, 0x5587, 0xB3E3, 0x558B, 0xB3E4, 0x5583, 0xB3E5, 0x55B3,\r\n\t0xB3E6, 0x55AE, 0xB3E7, 0x559F, 0xB3E8, 0x553E, 0xB3E9, 0x55B2,\t0xB3EA, 0x559A, 0xB3EB, 0x55BB, 0xB3EC, 0x55AC, 0xB3ED, 0x55B1,\r\n\t0xB3EE, 0x557E, 0xB3EF, 0x5589, 0xB3F0, 0x55AB, 0xB3F1, 0x5599,\t0xB3F2, 0x570D, 0xB3F3, 0x582F, 0xB3F4, 0x582A, 0xB3F5, 0x5834,\r\n\t0xB3F6, 0x5824, 0xB3F7, 0x5830, 0xB3F8, 0x5831, 0xB3F9, 0x5821,\t0xB3FA, 0x581D, 0xB3FB, 0x5820, 0xB3FC, 0x58F9, 0xB3FD, 0x58FA,\r\n\t0xB3FE, 0x5960, 0xB440, 0x5A77, 0xB441, 0x5A9A, 0xB442, 0x5A7F,\t0xB443, 0x5A92, 0xB444, 0x5A9B, 0xB445, 0x5AA7, 0xB446, 0x5B73,\r\n\t0xB447, 0x5B71, 0xB448, 0x5BD2, 0xB449, 0x5BCC, 0xB44A, 0x5BD3,\t0xB44B, 0x5BD0, 0xB44C, 0x5C0A, 0xB44D, 0x5C0B, 0xB44E, 0x5C31,\r\n\t0xB44F, 0x5D4C, 0xB450, 0x5D50, 0xB451, 0x5D34, 0xB452, 0x5D47,\t0xB453, 0x5DFD, 0xB454, 0x5E45, 0xB455, 0x5E3D, 0xB456, 0x5E40,\r\n\t0xB457, 0x5E43, 0xB458, 0x5E7E, 0xB459, 0x5ECA, 0xB45A, 0x5EC1,\t0xB45B, 0x5EC2, 0xB45C, 0x5EC4, 0xB45D, 0x5F3C, 0xB45E, 0x5F6D,\r\n\t0xB45F, 0x5FA9, 0xB460, 0x5FAA, 0xB461, 0x5FA8, 0xB462, 0x60D1,\t0xB463, 0x60E1, 0xB464, 0x60B2, 0xB465, 0x60B6, 0xB466, 0x60E0,\r\n\t0xB467, 0x611C, 0xB468, 0x6123, 0xB469, 0x60FA, 0xB46A, 0x6115,\t0xB46B, 0x60F0, 0xB46C, 0x60FB, 0xB46D, 0x60F4, 0xB46E, 0x6168,\r\n\t0xB46F, 0x60F1, 0xB470, 0x610E, 0xB471, 0x60F6, 0xB472, 0x6109,\t0xB473, 0x6100, 0xB474, 0x6112, 0xB475, 0x621F, 0xB476, 0x6249,\r\n\t0xB477, 0x63A3, 0xB478, 0x638C, 0xB479, 0x63CF, 0xB47A, 0x63C0,\t0xB47B, 0x63E9, 0xB47C, 0x63C9, 0xB47D, 0x63C6, 0xB47E, 0x63CD,\r\n\t0xB4A1, 0x63D2, 0xB4A2, 0x63E3, 0xB4A3, 0x63D0, 0xB4A4, 0x63E1,\t0xB4A5, 0x63D6, 0xB4A6, 0x63ED, 0xB4A7, 0x63EE, 0xB4A8, 0x6376,\r\n\t0xB4A9, 0x63F4, 0xB4AA, 0x63EA, 0xB4AB, 0x63DB, 0xB4AC, 0x6452,\t0xB4AD, 0x63DA, 0xB4AE, 0x63F9, 0xB4AF, 0x655E, 0xB4B0, 0x6566,\r\n\t0xB4B1, 0x6562, 0xB4B2, 0x6563, 0xB4B3, 0x6591, 0xB4B4, 0x6590,\t0xB4B5, 0x65AF, 0xB4B6, 0x666E, 0xB4B7, 0x6670, 0xB4B8, 0x6674,\r\n\t0xB4B9, 0x6676, 0xB4BA, 0x666F, 0xB4BB, 0x6691, 0xB4BC, 0x667A,\t0xB4BD, 0x667E, 0xB4BE, 0x6677, 0xB4BF, 0x66FE, 0xB4C0, 0x66FF,\r\n\t0xB4C1, 0x671F, 0xB4C2, 0x671D, 0xB4C3, 0x68FA, 0xB4C4, 0x68D5,\t0xB4C5, 0x68E0, 0xB4C6, 0x68D8, 0xB4C7, 0x68D7, 0xB4C8, 0x6905,\r\n\t0xB4C9, 0x68DF, 0xB4CA, 0x68F5, 0xB4CB, 0x68EE, 0xB4CC, 0x68E7,\t0xB4CD, 0x68F9, 0xB4CE, 0x68D2, 0xB4CF, 0x68F2, 0xB4D0, 0x68E3,\r\n\t0xB4D1, 0x68CB, 0xB4D2, 0x68CD, 0xB4D3, 0x690D, 0xB4D4, 0x6912,\t0xB4D5, 0x690E, 0xB4D6, 0x68C9, 0xB4D7, 0x68DA, 0xB4D8, 0x696E,\r\n\t0xB4D9, 0x68FB, 0xB4DA, 0x6B3E, 0xB4DB, 0x6B3A, 0xB4DC, 0x6B3D,\t0xB4DD, 0x6B98, 0xB4DE, 0x6B96, 0xB4DF, 0x6BBC, 0xB4E0, 0x6BEF,\r\n\t0xB4E1, 0x6C2E, 0xB4E2, 0x6C2F, 0xB4E3, 0x6C2C, 0xB4E4, 0x6E2F,\t0xB4E5, 0x6E38, 0xB4E6, 0x6E54, 0xB4E7, 0x6E21, 0xB4E8, 0x6E32,\r\n\t0xB4E9, 0x6E67, 0xB4EA, 0x6E4A, 0xB4EB, 0x6E20, 0xB4EC, 0x6E25,\t0xB4ED, 0x6E23, 0xB4EE, 0x6E1B, 0xB4EF, 0x6E5B, 0xB4F0, 0x6E58,\r\n\t0xB4F1, 0x6E24, 0xB4F2, 0x6E56, 0xB4F3, 0x6E6E, 0xB4F4, 0x6E2D,\t0xB4F5, 0x6E26, 0xB4F6, 0x6E6F, 0xB4F7, 0x6E34, 0xB4F8, 0x6E4D,\r\n\t0xB4F9, 0x6E3A, 0xB4FA, 0x6E2C, 0xB4FB, 0x6E43, 0xB4FC, 0x6E1D,\t0xB4FD, 0x6E3E, 0xB4FE, 0x6ECB, 0xB540, 0x6E89, 0xB541, 0x6E19,\r\n\t0xB542, 0x6E4E, 0xB543, 0x6E63, 0xB544, 0x6E44, 0xB545, 0x6E72,\t0xB546, 0x6E69, 0xB547, 0x6E5F, 0xB548, 0x7119, 0xB549, 0x711A,\r\n\t0xB54A, 0x7126, 0xB54B, 0x7130, 0xB54C, 0x7121, 0xB54D, 0x7136,\t0xB54E, 0x716E, 0xB54F, 0x711C, 0xB550, 0x724C, 0xB551, 0x7284,\r\n\t0xB552, 0x7280, 0xB553, 0x7336, 0xB554, 0x7325, 0xB555, 0x7334,\t0xB556, 0x7329, 0xB557, 0x743A, 0xB558, 0x742A, 0xB559, 0x7433,\r\n\t0xB55A, 0x7422, 0xB55B, 0x7425, 0xB55C, 0x7435, 0xB55D, 0x7436,\t0xB55E, 0x7434, 0xB55F, 0x742F, 0xB560, 0x741B, 0xB561, 0x7426,\r\n\t0xB562, 0x7428, 0xB563, 0x7525, 0xB564, 0x7526, 0xB565, 0x756B,\t0xB566, 0x756A, 0xB567, 0x75E2, 0xB568, 0x75DB, 0xB569, 0x75E3,\r\n\t0xB56A, 0x75D9, 0xB56B, 0x75D8, 0xB56C, 0x75DE, 0xB56D, 0x75E0,\t0xB56E, 0x767B, 0xB56F, 0x767C, 0xB570, 0x7696, 0xB571, 0x7693,\r\n\t0xB572, 0x76B4, 0xB573, 0x76DC, 0xB574, 0x774F, 0xB575, 0x77ED,\t0xB576, 0x785D, 0xB577, 0x786C, 0xB578, 0x786F, 0xB579, 0x7A0D,\r\n\t0xB57A, 0x7A08, 0xB57B, 0x7A0B, 0xB57C, 0x7A05, 0xB57D, 0x7A00,\t0xB57E, 0x7A98, 0xB5A1, 0x7A97, 0xB5A2, 0x7A96, 0xB5A3, 0x7AE5,\r\n\t0xB5A4, 0x7AE3, 0xB5A5, 0x7B49, 0xB5A6, 0x7B56, 0xB5A7, 0x7B46,\t0xB5A8, 0x7B50, 0xB5A9, 0x7B52, 0xB5AA, 0x7B54, 0xB5AB, 0x7B4D,\r\n\t0xB5AC, 0x7B4B, 0xB5AD, 0x7B4F, 0xB5AE, 0x7B51, 0xB5AF, 0x7C9F,\t0xB5B0, 0x7CA5, 0xB5B1, 0x7D5E, 0xB5B2, 0x7D50, 0xB5B3, 0x7D68,\r\n\t0xB5B4, 0x7D55, 0xB5B5, 0x7D2B, 0xB5B6, 0x7D6E, 0xB5B7, 0x7D72,\t0xB5B8, 0x7D61, 0xB5B9, 0x7D66, 0xB5BA, 0x7D62, 0xB5BB, 0x7D70,\r\n\t0xB5BC, 0x7D73, 0xB5BD, 0x5584, 0xB5BE, 0x7FD4, 0xB5BF, 0x7FD5,\t0xB5C0, 0x800B, 0xB5C1, 0x8052, 0xB5C2, 0x8085, 0xB5C3, 0x8155,\r\n\t0xB5C4, 0x8154, 0xB5C5, 0x814B, 0xB5C6, 0x8151, 0xB5C7, 0x814E,\t0xB5C8, 0x8139, 0xB5C9, 0x8146, 0xB5CA, 0x813E, 0xB5CB, 0x814C,\r\n\t0xB5CC, 0x8153, 0xB5CD, 0x8174, 0xB5CE, 0x8212, 0xB5CF, 0x821C,\t0xB5D0, 0x83E9, 0xB5D1, 0x8403, 0xB5D2, 0x83F8, 0xB5D3, 0x840D,\r\n\t0xB5D4, 0x83E0, 0xB5D5, 0x83C5, 0xB5D6, 0x840B, 0xB5D7, 0x83C1,\t0xB5D8, 0x83EF, 0xB5D9, 0x83F1, 0xB5DA, 0x83F4, 0xB5DB, 0x8457,\r\n\t0xB5DC, 0x840A, 0xB5DD, 0x83F0, 0xB5DE, 0x840C, 0xB5DF, 0x83CC,\t0xB5E0, 0x83FD, 0xB5E1, 0x83F2, 0xB5E2, 0x83CA, 0xB5E3, 0x8438,\r\n\t0xB5E4, 0x840E, 0xB5E5, 0x8404, 0xB5E6, 0x83DC, 0xB5E7, 0x8407,\t0xB5E8, 0x83D4, 0xB5E9, 0x83DF, 0xB5EA, 0x865B, 0xB5EB, 0x86DF,\r\n\t0xB5EC, 0x86D9, 0xB5ED, 0x86ED, 0xB5EE, 0x86D4, 0xB5EF, 0x86DB,\t0xB5F0, 0x86E4, 0xB5F1, 0x86D0, 0xB5F2, 0x86DE, 0xB5F3, 0x8857,\r\n\t0xB5F4, 0x88C1, 0xB5F5, 0x88C2, 0xB5F6, 0x88B1, 0xB5F7, 0x8983,\t0xB5F8, 0x8996, 0xB5F9, 0x8A3B, 0xB5FA, 0x8A60, 0xB5FB, 0x8A55,\r\n\t0xB5FC, 0x8A5E, 0xB5FD, 0x8A3C, 0xB5FE, 0x8A41, 0xB640, 0x8A54,\t0xB641, 0x8A5B, 0xB642, 0x8A50, 0xB643, 0x8A46, 0xB644, 0x8A34,\r\n\t0xB645, 0x8A3A, 0xB646, 0x8A36, 0xB647, 0x8A56, 0xB648, 0x8C61,\t0xB649, 0x8C82, 0xB64A, 0x8CAF, 0xB64B, 0x8CBC, 0xB64C, 0x8CB3,\r\n\t0xB64D, 0x8CBD, 0xB64E, 0x8CC1, 0xB64F, 0x8CBB, 0xB650, 0x8CC0,\t0xB651, 0x8CB4, 0xB652, 0x8CB7, 0xB653, 0x8CB6, 0xB654, 0x8CBF,\r\n\t0xB655, 0x8CB8, 0xB656, 0x8D8A, 0xB657, 0x8D85, 0xB658, 0x8D81,\t0xB659, 0x8DCE, 0xB65A, 0x8DDD, 0xB65B, 0x8DCB, 0xB65C, 0x8DDA,\r\n\t0xB65D, 0x8DD1, 0xB65E, 0x8DCC, 0xB65F, 0x8DDB, 0xB660, 0x8DC6,\t0xB661, 0x8EFB, 0xB662, 0x8EF8, 0xB663, 0x8EFC, 0xB664, 0x8F9C,\r\n\t0xB665, 0x902E, 0xB666, 0x9035, 0xB667, 0x9031, 0xB668, 0x9038,\t0xB669, 0x9032, 0xB66A, 0x9036, 0xB66B, 0x9102, 0xB66C, 0x90F5,\r\n\t0xB66D, 0x9109, 0xB66E, 0x90FE, 0xB66F, 0x9163, 0xB670, 0x9165,\t0xB671, 0x91CF, 0xB672, 0x9214, 0xB673, 0x9215, 0xB674, 0x9223,\r\n\t0xB675, 0x9209, 0xB676, 0x921E, 0xB677, 0x920D, 0xB678, 0x9210,\t0xB679, 0x9207, 0xB67A, 0x9211, 0xB67B, 0x9594, 0xB67C, 0x958F,\r\n\t0xB67D, 0x958B, 0xB67E, 0x9591, 0xB6A1, 0x9593, 0xB6A2, 0x9592,\t0xB6A3, 0x958E, 0xB6A4, 0x968A, 0xB6A5, 0x968E, 0xB6A6, 0x968B,\r\n\t0xB6A7, 0x967D, 0xB6A8, 0x9685, 0xB6A9, 0x9686, 0xB6AA, 0x968D,\t0xB6AB, 0x9672, 0xB6AC, 0x9684, 0xB6AD, 0x96C1, 0xB6AE, 0x96C5,\r\n\t0xB6AF, 0x96C4, 0xB6B0, 0x96C6, 0xB6B1, 0x96C7, 0xB6B2, 0x96EF,\t0xB6B3, 0x96F2, 0xB6B4, 0x97CC, 0xB6B5, 0x9805, 0xB6B6, 0x9806,\r\n\t0xB6B7, 0x9808, 0xB6B8, 0x98E7, 0xB6B9, 0x98EA, 0xB6BA, 0x98EF,\t0xB6BB, 0x98E9, 0xB6BC, 0x98F2, 0xB6BD, 0x98ED, 0xB6BE, 0x99AE,\r\n\t0xB6BF, 0x99AD, 0xB6C0, 0x9EC3, 0xB6C1, 0x9ECD, 0xB6C2, 0x9ED1,\t0xB6C3, 0x4E82, 0xB6C4, 0x50AD, 0xB6C5, 0x50B5, 0xB6C6, 0x50B2,\r\n\t0xB6C7, 0x50B3, 0xB6C8, 0x50C5, 0xB6C9, 0x50BE, 0xB6CA, 0x50AC,\t0xB6CB, 0x50B7, 0xB6CC, 0x50BB, 0xB6CD, 0x50AF, 0xB6CE, 0x50C7,\r\n\t0xB6CF, 0x527F, 0xB6D0, 0x5277, 0xB6D1, 0x527D, 0xB6D2, 0x52DF,\t0xB6D3, 0x52E6, 0xB6D4, 0x52E4, 0xB6D5, 0x52E2, 0xB6D6, 0x52E3,\r\n\t0xB6D7, 0x532F, 0xB6D8, 0x55DF, 0xB6D9, 0x55E8, 0xB6DA, 0x55D3,\t0xB6DB, 0x55E6, 0xB6DC, 0x55CE, 0xB6DD, 0x55DC, 0xB6DE, 0x55C7,\r\n\t0xB6DF, 0x55D1, 0xB6E0, 0x55E3, 0xB6E1, 0x55E4, 0xB6E2, 0x55EF,\t0xB6E3, 0x55DA, 0xB6E4, 0x55E1, 0xB6E5, 0x55C5, 0xB6E6, 0x55C6,\r\n\t0xB6E7, 0x55E5, 0xB6E8, 0x55C9, 0xB6E9, 0x5712, 0xB6EA, 0x5713,\t0xB6EB, 0x585E, 0xB6EC, 0x5851, 0xB6ED, 0x5858, 0xB6EE, 0x5857,\r\n\t0xB6EF, 0x585A, 0xB6F0, 0x5854, 0xB6F1, 0x586B, 0xB6F2, 0x584C,\t0xB6F3, 0x586D, 0xB6F4, 0x584A, 0xB6F5, 0x5862, 0xB6F6, 0x5852,\r\n\t0xB6F7, 0x584B, 0xB6F8, 0x5967, 0xB6F9, 0x5AC1, 0xB6FA, 0x5AC9,\t0xB6FB, 0x5ACC, 0xB6FC, 0x5ABE, 0xB6FD, 0x5ABD, 0xB6FE, 0x5ABC,\r\n\t0xB740, 0x5AB3, 0xB741, 0x5AC2, 0xB742, 0x5AB2, 0xB743, 0x5D69,\t0xB744, 0x5D6F, 0xB745, 0x5E4C, 0xB746, 0x5E79, 0xB747, 0x5EC9,\r\n\t0xB748, 0x5EC8, 0xB749, 0x5F12, 0xB74A, 0x5F59, 0xB74B, 0x5FAC,\t0xB74C, 0x5FAE, 0xB74D, 0x611A, 0xB74E, 0x610F, 0xB74F, 0x6148,\r\n\t0xB750, 0x611F, 0xB751, 0x60F3, 0xB752, 0x611B, 0xB753, 0x60F9,\t0xB754, 0x6101, 0xB755, 0x6108, 0xB756, 0x614E, 0xB757, 0x614C,\r\n\t0xB758, 0x6144, 0xB759, 0x614D, 0xB75A, 0x613E, 0xB75B, 0x6134,\t0xB75C, 0x6127, 0xB75D, 0x610D, 0xB75E, 0x6106, 0xB75F, 0x6137,\r\n\t0xB760, 0x6221, 0xB761, 0x6222, 0xB762, 0x6413, 0xB763, 0x643E,\t0xB764, 0x641E, 0xB765, 0x642A, 0xB766, 0x642D, 0xB767, 0x643D,\r\n\t0xB768, 0x642C, 0xB769, 0x640F, 0xB76A, 0x641C, 0xB76B, 0x6414,\t0xB76C, 0x640D, 0xB76D, 0x6436, 0xB76E, 0x6416, 0xB76F, 0x6417,\r\n\t0xB770, 0x6406, 0xB771, 0x656C, 0xB772, 0x659F, 0xB773, 0x65B0,\t0xB774, 0x6697, 0xB775, 0x6689, 0xB776, 0x6687, 0xB777, 0x6688,\r\n\t0xB778, 0x6696, 0xB779, 0x6684, 0xB77A, 0x6698, 0xB77B, 0x668D,\t0xB77C, 0x6703, 0xB77D, 0x6994, 0xB77E, 0x696D, 0xB7A1, 0x695A,\r\n\t0xB7A2, 0x6977, 0xB7A3, 0x6960, 0xB7A4, 0x6954, 0xB7A5, 0x6975,\t0xB7A6, 0x6930, 0xB7A7, 0x6982, 0xB7A8, 0x694A, 0xB7A9, 0x6968,\r\n\t0xB7AA, 0x696B, 0xB7AB, 0x695E, 0xB7AC, 0x6953, 0xB7AD, 0x6979,\t0xB7AE, 0x6986, 0xB7AF, 0x695D, 0xB7B0, 0x6963, 0xB7B1, 0x695B,\r\n\t0xB7B2, 0x6B47, 0xB7B3, 0x6B72, 0xB7B4, 0x6BC0, 0xB7B5, 0x6BBF,\t0xB7B6, 0x6BD3, 0xB7B7, 0x6BFD, 0xB7B8, 0x6EA2, 0xB7B9, 0x6EAF,\r\n\t0xB7BA, 0x6ED3, 0xB7BB, 0x6EB6, 0xB7BC, 0x6EC2, 0xB7BD, 0x6E90,\t0xB7BE, 0x6E9D, 0xB7BF, 0x6EC7, 0xB7C0, 0x6EC5, 0xB7C1, 0x6EA5,\r\n\t0xB7C2, 0x6E98, 0xB7C3, 0x6EBC, 0xB7C4, 0x6EBA, 0xB7C5, 0x6EAB,\t0xB7C6, 0x6ED1, 0xB7C7, 0x6E96, 0xB7C8, 0x6E9C, 0xB7C9, 0x6EC4,\r\n\t0xB7CA, 0x6ED4, 0xB7CB, 0x6EAA, 0xB7CC, 0x6EA7, 0xB7CD, 0x6EB4,\t0xB7CE, 0x714E, 0xB7CF, 0x7159, 0xB7D0, 0x7169, 0xB7D1, 0x7164,\r\n\t0xB7D2, 0x7149, 0xB7D3, 0x7167, 0xB7D4, 0x715C, 0xB7D5, 0x716C,\t0xB7D6, 0x7166, 0xB7D7, 0x714C, 0xB7D8, 0x7165, 0xB7D9, 0x715E,\r\n\t0xB7DA, 0x7146, 0xB7DB, 0x7168, 0xB7DC, 0x7156, 0xB7DD, 0x723A,\t0xB7DE, 0x7252, 0xB7DF, 0x7337, 0xB7E0, 0x7345, 0xB7E1, 0x733F,\r\n\t0xB7E2, 0x733E, 0xB7E3, 0x746F, 0xB7E4, 0x745A, 0xB7E5, 0x7455,\t0xB7E6, 0x745F, 0xB7E7, 0x745E, 0xB7E8, 0x7441, 0xB7E9, 0x743F,\r\n\t0xB7EA, 0x7459, 0xB7EB, 0x745B, 0xB7EC, 0x745C, 0xB7ED, 0x7576,\t0xB7EE, 0x7578, 0xB7EF, 0x7600, 0xB7F0, 0x75F0, 0xB7F1, 0x7601,\r\n\t0xB7F2, 0x75F2, 0xB7F3, 0x75F1, 0xB7F4, 0x75FA, 0xB7F5, 0x75FF,\t0xB7F6, 0x75F4, 0xB7F7, 0x75F3, 0xB7F8, 0x76DE, 0xB7F9, 0x76DF,\r\n\t0xB7FA, 0x775B, 0xB7FB, 0x776B, 0xB7FC, 0x7766, 0xB7FD, 0x775E,\t0xB7FE, 0x7763, 0xB840, 0x7779, 0xB841, 0x776A, 0xB842, 0x776C,\r\n\t0xB843, 0x775C, 0xB844, 0x7765, 0xB845, 0x7768, 0xB846, 0x7762,\t0xB847, 0x77EE, 0xB848, 0x788E, 0xB849, 0x78B0, 0xB84A, 0x7897,\r\n\t0xB84B, 0x7898, 0xB84C, 0x788C, 0xB84D, 0x7889, 0xB84E, 0x787C,\t0xB84F, 0x7891, 0xB850, 0x7893, 0xB851, 0x787F, 0xB852, 0x797A,\r\n\t0xB853, 0x797F, 0xB854, 0x7981, 0xB855, 0x842C, 0xB856, 0x79BD,\t0xB857, 0x7A1C, 0xB858, 0x7A1A, 0xB859, 0x7A20, 0xB85A, 0x7A14,\r\n\t0xB85B, 0x7A1F, 0xB85C, 0x7A1E, 0xB85D, 0x7A9F, 0xB85E, 0x7AA0,\t0xB85F, 0x7B77, 0xB860, 0x7BC0, 0xB861, 0x7B60, 0xB862, 0x7B6E,\r\n\t0xB863, 0x7B67, 0xB864, 0x7CB1, 0xB865, 0x7CB3, 0xB866, 0x7CB5,\t0xB867, 0x7D93, 0xB868, 0x7D79, 0xB869, 0x7D91, 0xB86A, 0x7D81,\r\n\t0xB86B, 0x7D8F, 0xB86C, 0x7D5B, 0xB86D, 0x7F6E, 0xB86E, 0x7F69,\t0xB86F, 0x7F6A, 0xB870, 0x7F72, 0xB871, 0x7FA9, 0xB872, 0x7FA8,\r\n\t0xB873, 0x7FA4, 0xB874, 0x8056, 0xB875, 0x8058, 0xB876, 0x8086,\t0xB877, 0x8084, 0xB878, 0x8171, 0xB879, 0x8170, 0xB87A, 0x8178,\r\n\t0xB87B, 0x8165, 0xB87C, 0x816E, 0xB87D, 0x8173, 0xB87E, 0x816B,\t0xB8A1, 0x8179, 0xB8A2, 0x817A, 0xB8A3, 0x8166, 0xB8A4, 0x8205,\r\n\t0xB8A5, 0x8247, 0xB8A6, 0x8482, 0xB8A7, 0x8477, 0xB8A8, 0x843D,\t0xB8A9, 0x8431, 0xB8AA, 0x8475, 0xB8AB, 0x8466, 0xB8AC, 0x846B,\r\n\t0xB8AD, 0x8449, 0xB8AE, 0x846C, 0xB8AF, 0x845B, 0xB8B0, 0x843C,\t0xB8B1, 0x8435, 0xB8B2, 0x8461, 0xB8B3, 0x8463, 0xB8B4, 0x8469,\r\n\t0xB8B5, 0x846D, 0xB8B6, 0x8446, 0xB8B7, 0x865E, 0xB8B8, 0x865C,\t0xB8B9, 0x865F, 0xB8BA, 0x86F9, 0xB8BB, 0x8713, 0xB8BC, 0x8708,\r\n\t0xB8BD, 0x8707, 0xB8BE, 0x8700, 0xB8BF, 0x86FE, 0xB8C0, 0x86FB,\t0xB8C1, 0x8702, 0xB8C2, 0x8703, 0xB8C3, 0x8706, 0xB8C4, 0x870A,\r\n\t0xB8C5, 0x8859, 0xB8C6, 0x88DF, 0xB8C7, 0x88D4, 0xB8C8, 0x88D9,\t0xB8C9, 0x88DC, 0xB8CA, 0x88D8, 0xB8CB, 0x88DD, 0xB8CC, 0x88E1,\r\n\t0xB8CD, 0x88CA, 0xB8CE, 0x88D5, 0xB8CF, 0x88D2, 0xB8D0, 0x899C,\t0xB8D1, 0x89E3, 0xB8D2, 0x8A6B, 0xB8D3, 0x8A72, 0xB8D4, 0x8A73,\r\n\t0xB8D5, 0x8A66, 0xB8D6, 0x8A69, 0xB8D7, 0x8A70, 0xB8D8, 0x8A87,\t0xB8D9, 0x8A7C, 0xB8DA, 0x8A63, 0xB8DB, 0x8AA0, 0xB8DC, 0x8A71,\r\n\t0xB8DD, 0x8A85, 0xB8DE, 0x8A6D, 0xB8DF, 0x8A62, 0xB8E0, 0x8A6E,\t0xB8E1, 0x8A6C, 0xB8E2, 0x8A79, 0xB8E3, 0x8A7B, 0xB8E4, 0x8A3E,\r\n\t0xB8E5, 0x8A68, 0xB8E6, 0x8C62, 0xB8E7, 0x8C8A, 0xB8E8, 0x8C89,\t0xB8E9, 0x8CCA, 0xB8EA, 0x8CC7, 0xB8EB, 0x8CC8, 0xB8EC, 0x8CC4,\r\n\t0xB8ED, 0x8CB2, 0xB8EE, 0x8CC3, 0xB8EF, 0x8CC2, 0xB8F0, 0x8CC5,\t0xB8F1, 0x8DE1, 0xB8F2, 0x8DDF, 0xB8F3, 0x8DE8, 0xB8F4, 0x8DEF,\r\n\t0xB8F5, 0x8DF3, 0xB8F6, 0x8DFA, 0xB8F7, 0x8DEA, 0xB8F8, 0x8DE4,\t0xB8F9, 0x8DE6, 0xB8FA, 0x8EB2, 0xB8FB, 0x8F03, 0xB8FC, 0x8F09,\r\n\t0xB8FD, 0x8EFE, 0xB8FE, 0x8F0A, 0xB940, 0x8F9F, 0xB941, 0x8FB2,\t0xB942, 0x904B, 0xB943, 0x904A, 0xB944, 0x9053, 0xB945, 0x9042,\r\n\t0xB946, 0x9054, 0xB947, 0x903C, 0xB948, 0x9055, 0xB949, 0x9050,\t0xB94A, 0x9047, 0xB94B, 0x904F, 0xB94C, 0x904E, 0xB94D, 0x904D,\r\n\t0xB94E, 0x9051, 0xB94F, 0x903E, 0xB950, 0x9041, 0xB951, 0x9112,\t0xB952, 0x9117, 0xB953, 0x916C, 0xB954, 0x916A, 0xB955, 0x9169,\r\n\t0xB956, 0x91C9, 0xB957, 0x9237, 0xB958, 0x9257, 0xB959, 0x9238,\t0xB95A, 0x923D, 0xB95B, 0x9240, 0xB95C, 0x923E, 0xB95D, 0x925B,\r\n\t0xB95E, 0x924B, 0xB95F, 0x9264, 0xB960, 0x9251, 0xB961, 0x9234,\t0xB962, 0x9249, 0xB963, 0x924D, 0xB964, 0x9245, 0xB965, 0x9239,\r\n\t0xB966, 0x923F, 0xB967, 0x925A, 0xB968, 0x9598, 0xB969, 0x9698,\t0xB96A, 0x9694, 0xB96B, 0x9695, 0xB96C, 0x96CD, 0xB96D, 0x96CB,\r\n\t0xB96E, 0x96C9, 0xB96F, 0x96CA, 0xB970, 0x96F7, 0xB971, 0x96FB,\t0xB972, 0x96F9, 0xB973, 0x96F6, 0xB974, 0x9756, 0xB975, 0x9774,\r\n\t0xB976, 0x9776, 0xB977, 0x9810, 0xB978, 0x9811, 0xB979, 0x9813,\t0xB97A, 0x980A, 0xB97B, 0x9812, 0xB97C, 0x980C, 0xB97D, 0x98FC,\r\n\t0xB97E, 0x98F4, 0xB9A1, 0x98FD, 0xB9A2, 0x98FE, 0xB9A3, 0x99B3,\t0xB9A4, 0x99B1, 0xB9A5, 0x99B4, 0xB9A6, 0x9AE1, 0xB9A7, 0x9CE9,\r\n\t0xB9A8, 0x9E82, 0xB9A9, 0x9F0E, 0xB9AA, 0x9F13, 0xB9AB, 0x9F20,\t0xB9AC, 0x50E7, 0xB9AD, 0x50EE, 0xB9AE, 0x50E5, 0xB9AF, 0x50D6,\r\n\t0xB9B0, 0x50ED, 0xB9B1, 0x50DA, 0xB9B2, 0x50D5, 0xB9B3, 0x50CF,\t0xB9B4, 0x50D1, 0xB9B5, 0x50F1, 0xB9B6, 0x50CE, 0xB9B7, 0x50E9,\r\n\t0xB9B8, 0x5162, 0xB9B9, 0x51F3, 0xB9BA, 0x5283, 0xB9BB, 0x5282,\t0xB9BC, 0x5331, 0xB9BD, 0x53AD, 0xB9BE, 0x55FE, 0xB9BF, 0x5600,\r\n\t0xB9C0, 0x561B, 0xB9C1, 0x5617, 0xB9C2, 0x55FD, 0xB9C3, 0x5614,\t0xB9C4, 0x5606, 0xB9C5, 0x5609, 0xB9C6, 0x560D, 0xB9C7, 0x560E,\r\n\t0xB9C8, 0x55F7, 0xB9C9, 0x5616, 0xB9CA, 0x561F, 0xB9CB, 0x5608,\t0xB9CC, 0x5610, 0xB9CD, 0x55F6, 0xB9CE, 0x5718, 0xB9CF, 0x5716,\r\n\t0xB9D0, 0x5875, 0xB9D1, 0x587E, 0xB9D2, 0x5883, 0xB9D3, 0x5893,\t0xB9D4, 0x588A, 0xB9D5, 0x5879, 0xB9D6, 0x5885, 0xB9D7, 0x587D,\r\n\t0xB9D8, 0x58FD, 0xB9D9, 0x5925, 0xB9DA, 0x5922, 0xB9DB, 0x5924,\t0xB9DC, 0x596A, 0xB9DD, 0x5969, 0xB9DE, 0x5AE1, 0xB9DF, 0x5AE6,\r\n\t0xB9E0, 0x5AE9, 0xB9E1, 0x5AD7, 0xB9E2, 0x5AD6, 0xB9E3, 0x5AD8,\t0xB9E4, 0x5AE3, 0xB9E5, 0x5B75, 0xB9E6, 0x5BDE, 0xB9E7, 0x5BE7,\r\n\t0xB9E8, 0x5BE1, 0xB9E9, 0x5BE5, 0xB9EA, 0x5BE6, 0xB9EB, 0x5BE8,\t0xB9EC, 0x5BE2, 0xB9ED, 0x5BE4, 0xB9EE, 0x5BDF, 0xB9EF, 0x5C0D,\r\n\t0xB9F0, 0x5C62, 0xB9F1, 0x5D84, 0xB9F2, 0x5D87, 0xB9F3, 0x5E5B,\t0xB9F4, 0x5E63, 0xB9F5, 0x5E55, 0xB9F6, 0x5E57, 0xB9F7, 0x5E54,\r\n\t0xB9F8, 0x5ED3, 0xB9F9, 0x5ED6, 0xB9FA, 0x5F0A, 0xB9FB, 0x5F46,\t0xB9FC, 0x5F70, 0xB9FD, 0x5FB9, 0xB9FE, 0x6147, 0xBA40, 0x613F,\r\n\t0xBA41, 0x614B, 0xBA42, 0x6177, 0xBA43, 0x6162, 0xBA44, 0x6163,\t0xBA45, 0x615F, 0xBA46, 0x615A, 0xBA47, 0x6158, 0xBA48, 0x6175,\r\n\t0xBA49, 0x622A, 0xBA4A, 0x6487, 0xBA4B, 0x6458, 0xBA4C, 0x6454,\t0xBA4D, 0x64A4, 0xBA4E, 0x6478, 0xBA4F, 0x645F, 0xBA50, 0x647A,\r\n\t0xBA51, 0x6451, 0xBA52, 0x6467, 0xBA53, 0x6434, 0xBA54, 0x646D,\t0xBA55, 0x647B, 0xBA56, 0x6572, 0xBA57, 0x65A1, 0xBA58, 0x65D7,\r\n\t0xBA59, 0x65D6, 0xBA5A, 0x66A2, 0xBA5B, 0x66A8, 0xBA5C, 0x669D,\t0xBA5D, 0x699C, 0xBA5E, 0x69A8, 0xBA5F, 0x6995, 0xBA60, 0x69C1,\r\n\t0xBA61, 0x69AE, 0xBA62, 0x69D3, 0xBA63, 0x69CB, 0xBA64, 0x699B,\t0xBA65, 0x69B7, 0xBA66, 0x69BB, 0xBA67, 0x69AB, 0xBA68, 0x69B4,\r\n\t0xBA69, 0x69D0, 0xBA6A, 0x69CD, 0xBA6B, 0x69AD, 0xBA6C, 0x69CC,\t0xBA6D, 0x69A6, 0xBA6E, 0x69C3, 0xBA6F, 0x69A3, 0xBA70, 0x6B49,\r\n\t0xBA71, 0x6B4C, 0xBA72, 0x6C33, 0xBA73, 0x6F33, 0xBA74, 0x6F14,\t0xBA75, 0x6EFE, 0xBA76, 0x6F13, 0xBA77, 0x6EF4, 0xBA78, 0x6F29,\r\n\t0xBA79, 0x6F3E, 0xBA7A, 0x6F20, 0xBA7B, 0x6F2C, 0xBA7C, 0x6F0F,\t0xBA7D, 0x6F02, 0xBA7E, 0x6F22, 0xBAA1, 0x6EFF, 0xBAA2, 0x6EEF,\r\n\t0xBAA3, 0x6F06, 0xBAA4, 0x6F31, 0xBAA5, 0x6F38, 0xBAA6, 0x6F32,\t0xBAA7, 0x6F23, 0xBAA8, 0x6F15, 0xBAA9, 0x6F2B, 0xBAAA, 0x6F2F,\r\n\t0xBAAB, 0x6F88, 0xBAAC, 0x6F2A, 0xBAAD, 0x6EEC, 0xBAAE, 0x6F01,\t0xBAAF, 0x6EF2, 0xBAB0, 0x6ECC, 0xBAB1, 0x6EF7, 0xBAB2, 0x7194,\r\n\t0xBAB3, 0x7199, 0xBAB4, 0x717D, 0xBAB5, 0x718A, 0xBAB6, 0x7184,\t0xBAB7, 0x7192, 0xBAB8, 0x723E, 0xBAB9, 0x7292, 0xBABA, 0x7296,\r\n\t0xBABB, 0x7344, 0xBABC, 0x7350, 0xBABD, 0x7464, 0xBABE, 0x7463,\t0xBABF, 0x746A, 0xBAC0, 0x7470, 0xBAC1, 0x746D, 0xBAC2, 0x7504,\r\n\t0xBAC3, 0x7591, 0xBAC4, 0x7627, 0xBAC5, 0x760D, 0xBAC6, 0x760B,\t0xBAC7, 0x7609, 0xBAC8, 0x7613, 0xBAC9, 0x76E1, 0xBACA, 0x76E3,\r\n\t0xBACB, 0x7784, 0xBACC, 0x777D, 0xBACD, 0x777F, 0xBACE, 0x7761,\t0xBACF, 0x78C1, 0xBAD0, 0x789F, 0xBAD1, 0x78A7, 0xBAD2, 0x78B3,\r\n\t0xBAD3, 0x78A9, 0xBAD4, 0x78A3, 0xBAD5, 0x798E, 0xBAD6, 0x798F,\t0xBAD7, 0x798D, 0xBAD8, 0x7A2E, 0xBAD9, 0x7A31, 0xBADA, 0x7AAA,\r\n\t0xBADB, 0x7AA9, 0xBADC, 0x7AED, 0xBADD, 0x7AEF, 0xBADE, 0x7BA1,\t0xBADF, 0x7B95, 0xBAE0, 0x7B8B, 0xBAE1, 0x7B75, 0xBAE2, 0x7B97,\r\n\t0xBAE3, 0x7B9D, 0xBAE4, 0x7B94, 0xBAE5, 0x7B8F, 0xBAE6, 0x7BB8,\t0xBAE7, 0x7B87, 0xBAE8, 0x7B84, 0xBAE9, 0x7CB9, 0xBAEA, 0x7CBD,\r\n\t0xBAEB, 0x7CBE, 0xBAEC, 0x7DBB, 0xBAED, 0x7DB0, 0xBAEE, 0x7D9C,\t0xBAEF, 0x7DBD, 0xBAF0, 0x7DBE, 0xBAF1, 0x7DA0, 0xBAF2, 0x7DCA,\r\n\t0xBAF3, 0x7DB4, 0xBAF4, 0x7DB2, 0xBAF5, 0x7DB1, 0xBAF6, 0x7DBA,\t0xBAF7, 0x7DA2, 0xBAF8, 0x7DBF, 0xBAF9, 0x7DB5, 0xBAFA, 0x7DB8,\r\n\t0xBAFB, 0x7DAD, 0xBAFC, 0x7DD2, 0xBAFD, 0x7DC7, 0xBAFE, 0x7DAC,\t0xBB40, 0x7F70, 0xBB41, 0x7FE0, 0xBB42, 0x7FE1, 0xBB43, 0x7FDF,\r\n\t0xBB44, 0x805E, 0xBB45, 0x805A, 0xBB46, 0x8087, 0xBB47, 0x8150,\t0xBB48, 0x8180, 0xBB49, 0x818F, 0xBB4A, 0x8188, 0xBB4B, 0x818A,\r\n\t0xBB4C, 0x817F, 0xBB4D, 0x8182, 0xBB4E, 0x81E7, 0xBB4F, 0x81FA,\t0xBB50, 0x8207, 0xBB51, 0x8214, 0xBB52, 0x821E, 0xBB53, 0x824B,\r\n\t0xBB54, 0x84C9, 0xBB55, 0x84BF, 0xBB56, 0x84C6, 0xBB57, 0x84C4,\t0xBB58, 0x8499, 0xBB59, 0x849E, 0xBB5A, 0x84B2, 0xBB5B, 0x849C,\r\n\t0xBB5C, 0x84CB, 0xBB5D, 0x84B8, 0xBB5E, 0x84C0, 0xBB5F, 0x84D3,\t0xBB60, 0x8490, 0xBB61, 0x84BC, 0xBB62, 0x84D1, 0xBB63, 0x84CA,\r\n\t0xBB64, 0x873F, 0xBB65, 0x871C, 0xBB66, 0x873B, 0xBB67, 0x8722,\t0xBB68, 0x8725, 0xBB69, 0x8734, 0xBB6A, 0x8718, 0xBB6B, 0x8755,\r\n\t0xBB6C, 0x8737, 0xBB6D, 0x8729, 0xBB6E, 0x88F3, 0xBB6F, 0x8902,\t0xBB70, 0x88F4, 0xBB71, 0x88F9, 0xBB72, 0x88F8, 0xBB73, 0x88FD,\r\n\t0xBB74, 0x88E8, 0xBB75, 0x891A, 0xBB76, 0x88EF, 0xBB77, 0x8AA6,\t0xBB78, 0x8A8C, 0xBB79, 0x8A9E, 0xBB7A, 0x8AA3, 0xBB7B, 0x8A8D,\r\n\t0xBB7C, 0x8AA1, 0xBB7D, 0x8A93, 0xBB7E, 0x8AA4, 0xBBA1, 0x8AAA,\t0xBBA2, 0x8AA5, 0xBBA3, 0x8AA8, 0xBBA4, 0x8A98, 0xBBA5, 0x8A91,\r\n\t0xBBA6, 0x8A9A, 0xBBA7, 0x8AA7, 0xBBA8, 0x8C6A, 0xBBA9, 0x8C8D,\t0xBBAA, 0x8C8C, 0xBBAB, 0x8CD3, 0xBBAC, 0x8CD1, 0xBBAD, 0x8CD2,\r\n\t0xBBAE, 0x8D6B, 0xBBAF, 0x8D99, 0xBBB0, 0x8D95, 0xBBB1, 0x8DFC,\t0xBBB2, 0x8F14, 0xBBB3, 0x8F12, 0xBBB4, 0x8F15, 0xBBB5, 0x8F13,\r\n\t0xBBB6, 0x8FA3, 0xBBB7, 0x9060, 0xBBB8, 0x9058, 0xBBB9, 0x905C,\t0xBBBA, 0x9063, 0xBBBB, 0x9059, 0xBBBC, 0x905E, 0xBBBD, 0x9062,\r\n\t0xBBBE, 0x905D, 0xBBBF, 0x905B, 0xBBC0, 0x9119, 0xBBC1, 0x9118,\t0xBBC2, 0x911E, 0xBBC3, 0x9175, 0xBBC4, 0x9178, 0xBBC5, 0x9177,\r\n\t0xBBC6, 0x9174, 0xBBC7, 0x9278, 0xBBC8, 0x9280, 0xBBC9, 0x9285,\t0xBBCA, 0x9298, 0xBBCB, 0x9296, 0xBBCC, 0x927B, 0xBBCD, 0x9293,\r\n\t0xBBCE, 0x929C, 0xBBCF, 0x92A8, 0xBBD0, 0x927C, 0xBBD1, 0x9291,\t0xBBD2, 0x95A1, 0xBBD3, 0x95A8, 0xBBD4, 0x95A9, 0xBBD5, 0x95A3,\r\n\t0xBBD6, 0x95A5, 0xBBD7, 0x95A4, 0xBBD8, 0x9699, 0xBBD9, 0x969C,\t0xBBDA, 0x969B, 0xBBDB, 0x96CC, 0xBBDC, 0x96D2, 0xBBDD, 0x9700,\r\n\t0xBBDE, 0x977C, 0xBBDF, 0x9785, 0xBBE0, 0x97F6, 0xBBE1, 0x9817,\t0xBBE2, 0x9818, 0xBBE3, 0x98AF, 0xBBE4, 0x98B1, 0xBBE5, 0x9903,\r\n\t0xBBE6, 0x9905, 0xBBE7, 0x990C, 0xBBE8, 0x9909, 0xBBE9, 0x99C1,\t0xBBEA, 0x9AAF, 0xBBEB, 0x9AB0, 0xBBEC, 0x9AE6, 0xBBED, 0x9B41,\r\n\t0xBBEE, 0x9B42, 0xBBEF, 0x9CF4, 0xBBF0, 0x9CF6, 0xBBF1, 0x9CF3,\t0xBBF2, 0x9EBC, 0xBBF3, 0x9F3B, 0xBBF4, 0x9F4A, 0xBBF5, 0x5104,\r\n\t0xBBF6, 0x5100, 0xBBF7, 0x50FB, 0xBBF8, 0x50F5, 0xBBF9, 0x50F9,\t0xBBFA, 0x5102, 0xBBFB, 0x5108, 0xBBFC, 0x5109, 0xBBFD, 0x5105,\r\n\t0xBBFE, 0x51DC, 0xBC40, 0x5287, 0xBC41, 0x5288, 0xBC42, 0x5289,\t0xBC43, 0x528D, 0xBC44, 0x528A, 0xBC45, 0x52F0, 0xBC46, 0x53B2,\r\n\t0xBC47, 0x562E, 0xBC48, 0x563B, 0xBC49, 0x5639, 0xBC4A, 0x5632,\t0xBC4B, 0x563F, 0xBC4C, 0x5634, 0xBC4D, 0x5629, 0xBC4E, 0x5653,\r\n\t0xBC4F, 0x564E, 0xBC50, 0x5657, 0xBC51, 0x5674, 0xBC52, 0x5636,\t0xBC53, 0x562F, 0xBC54, 0x5630, 0xBC55, 0x5880, 0xBC56, 0x589F,\r\n\t0xBC57, 0x589E, 0xBC58, 0x58B3, 0xBC59, 0x589C, 0xBC5A, 0x58AE,\t0xBC5B, 0x58A9, 0xBC5C, 0x58A6, 0xBC5D, 0x596D, 0xBC5E, 0x5B09,\r\n\t0xBC5F, 0x5AFB, 0xBC60, 0x5B0B, 0xBC61, 0x5AF5, 0xBC62, 0x5B0C,\t0xBC63, 0x5B08, 0xBC64, 0x5BEE, 0xBC65, 0x5BEC, 0xBC66, 0x5BE9,\r\n\t0xBC67, 0x5BEB, 0xBC68, 0x5C64, 0xBC69, 0x5C65, 0xBC6A, 0x5D9D,\t0xBC6B, 0x5D94, 0xBC6C, 0x5E62, 0xBC6D, 0x5E5F, 0xBC6E, 0x5E61,\r\n\t0xBC6F, 0x5EE2, 0xBC70, 0x5EDA, 0xBC71, 0x5EDF, 0xBC72, 0x5EDD,\t0xBC73, 0x5EE3, 0xBC74, 0x5EE0, 0xBC75, 0x5F48, 0xBC76, 0x5F71,\r\n\t0xBC77, 0x5FB7, 0xBC78, 0x5FB5, 0xBC79, 0x6176, 0xBC7A, 0x6167,\t0xBC7B, 0x616E, 0xBC7C, 0x615D, 0xBC7D, 0x6155, 0xBC7E, 0x6182,\r\n\t0xBCA1, 0x617C, 0xBCA2, 0x6170, 0xBCA3, 0x616B, 0xBCA4, 0x617E,\t0xBCA5, 0x61A7, 0xBCA6, 0x6190, 0xBCA7, 0x61AB, 0xBCA8, 0x618E,\r\n\t0xBCA9, 0x61AC, 0xBCAA, 0x619A, 0xBCAB, 0x61A4, 0xBCAC, 0x6194,\t0xBCAD, 0x61AE, 0xBCAE, 0x622E, 0xBCAF, 0x6469, 0xBCB0, 0x646F,\r\n\t0xBCB1, 0x6479, 0xBCB2, 0x649E, 0xBCB3, 0x64B2, 0xBCB4, 0x6488,\t0xBCB5, 0x6490, 0xBCB6, 0x64B0, 0xBCB7, 0x64A5, 0xBCB8, 0x6493,\r\n\t0xBCB9, 0x6495, 0xBCBA, 0x64A9, 0xBCBB, 0x6492, 0xBCBC, 0x64AE,\t0xBCBD, 0x64AD, 0xBCBE, 0x64AB, 0xBCBF, 0x649A, 0xBCC0, 0x64AC,\r\n\t0xBCC1, 0x6499, 0xBCC2, 0x64A2, 0xBCC3, 0x64B3, 0xBCC4, 0x6575,\t0xBCC5, 0x6577, 0xBCC6, 0x6578, 0xBCC7, 0x66AE, 0xBCC8, 0x66AB,\r\n\t0xBCC9, 0x66B4, 0xBCCA, 0x66B1, 0xBCCB, 0x6A23, 0xBCCC, 0x6A1F,\t0xBCCD, 0x69E8, 0xBCCE, 0x6A01, 0xBCCF, 0x6A1E, 0xBCD0, 0x6A19,\r\n\t0xBCD1, 0x69FD, 0xBCD2, 0x6A21, 0xBCD3, 0x6A13, 0xBCD4, 0x6A0A,\t0xBCD5, 0x69F3, 0xBCD6, 0x6A02, 0xBCD7, 0x6A05, 0xBCD8, 0x69ED,\r\n\t0xBCD9, 0x6A11, 0xBCDA, 0x6B50, 0xBCDB, 0x6B4E, 0xBCDC, 0x6BA4,\t0xBCDD, 0x6BC5, 0xBCDE, 0x6BC6, 0xBCDF, 0x6F3F, 0xBCE0, 0x6F7C,\r\n\t0xBCE1, 0x6F84, 0xBCE2, 0x6F51, 0xBCE3, 0x6F66, 0xBCE4, 0x6F54,\t0xBCE5, 0x6F86, 0xBCE6, 0x6F6D, 0xBCE7, 0x6F5B, 0xBCE8, 0x6F78,\r\n\t0xBCE9, 0x6F6E, 0xBCEA, 0x6F8E, 0xBCEB, 0x6F7A, 0xBCEC, 0x6F70,\t0xBCED, 0x6F64, 0xBCEE, 0x6F97, 0xBCEF, 0x6F58, 0xBCF0, 0x6ED5,\r\n\t0xBCF1, 0x6F6F, 0xBCF2, 0x6F60, 0xBCF3, 0x6F5F, 0xBCF4, 0x719F,\t0xBCF5, 0x71AC, 0xBCF6, 0x71B1, 0xBCF7, 0x71A8, 0xBCF8, 0x7256,\r\n\t0xBCF9, 0x729B, 0xBCFA, 0x734E, 0xBCFB, 0x7357, 0xBCFC, 0x7469,\t0xBCFD, 0x748B, 0xBCFE, 0x7483, 0xBD40, 0x747E, 0xBD41, 0x7480,\r\n\t0xBD42, 0x757F, 0xBD43, 0x7620, 0xBD44, 0x7629, 0xBD45, 0x761F,\t0xBD46, 0x7624, 0xBD47, 0x7626, 0xBD48, 0x7621, 0xBD49, 0x7622,\r\n\t0xBD4A, 0x769A, 0xBD4B, 0x76BA, 0xBD4C, 0x76E4, 0xBD4D, 0x778E,\t0xBD4E, 0x7787, 0xBD4F, 0x778C, 0xBD50, 0x7791, 0xBD51, 0x778B,\r\n\t0xBD52, 0x78CB, 0xBD53, 0x78C5, 0xBD54, 0x78BA, 0xBD55, 0x78CA,\t0xBD56, 0x78BE, 0xBD57, 0x78D5, 0xBD58, 0x78BC, 0xBD59, 0x78D0,\r\n\t0xBD5A, 0x7A3F, 0xBD5B, 0x7A3C, 0xBD5C, 0x7A40, 0xBD5D, 0x7A3D,\t0xBD5E, 0x7A37, 0xBD5F, 0x7A3B, 0xBD60, 0x7AAF, 0xBD61, 0x7AAE,\r\n\t0xBD62, 0x7BAD, 0xBD63, 0x7BB1, 0xBD64, 0x7BC4, 0xBD65, 0x7BB4,\t0xBD66, 0x7BC6, 0xBD67, 0x7BC7, 0xBD68, 0x7BC1, 0xBD69, 0x7BA0,\r\n\t0xBD6A, 0x7BCC, 0xBD6B, 0x7CCA, 0xBD6C, 0x7DE0, 0xBD6D, 0x7DF4,\t0xBD6E, 0x7DEF, 0xBD6F, 0x7DFB, 0xBD70, 0x7DD8, 0xBD71, 0x7DEC,\r\n\t0xBD72, 0x7DDD, 0xBD73, 0x7DE8, 0xBD74, 0x7DE3, 0xBD75, 0x7DDA,\t0xBD76, 0x7DDE, 0xBD77, 0x7DE9, 0xBD78, 0x7D9E, 0xBD79, 0x7DD9,\r\n\t0xBD7A, 0x7DF2, 0xBD7B, 0x7DF9, 0xBD7C, 0x7F75, 0xBD7D, 0x7F77,\t0xBD7E, 0x7FAF, 0xBDA1, 0x7FE9, 0xBDA2, 0x8026, 0xBDA3, 0x819B,\r\n\t0xBDA4, 0x819C, 0xBDA5, 0x819D, 0xBDA6, 0x81A0, 0xBDA7, 0x819A,\t0xBDA8, 0x8198, 0xBDA9, 0x8517, 0xBDAA, 0x853D, 0xBDAB, 0x851A,\r\n\t0xBDAC, 0x84EE, 0xBDAD, 0x852C, 0xBDAE, 0x852D, 0xBDAF, 0x8513,\t0xBDB0, 0x8511, 0xBDB1, 0x8523, 0xBDB2, 0x8521, 0xBDB3, 0x8514,\r\n\t0xBDB4, 0x84EC, 0xBDB5, 0x8525, 0xBDB6, 0x84FF, 0xBDB7, 0x8506,\t0xBDB8, 0x8782, 0xBDB9, 0x8774, 0xBDBA, 0x8776, 0xBDBB, 0x8760,\r\n\t0xBDBC, 0x8766, 0xBDBD, 0x8778, 0xBDBE, 0x8768, 0xBDBF, 0x8759,\t0xBDC0, 0x8757, 0xBDC1, 0x874C, 0xBDC2, 0x8753, 0xBDC3, 0x885B,\r\n\t0xBDC4, 0x885D, 0xBDC5, 0x8910, 0xBDC6, 0x8907, 0xBDC7, 0x8912,\t0xBDC8, 0x8913, 0xBDC9, 0x8915, 0xBDCA, 0x890A, 0xBDCB, 0x8ABC,\r\n\t0xBDCC, 0x8AD2, 0xBDCD, 0x8AC7, 0xBDCE, 0x8AC4, 0xBDCF, 0x8A95,\t0xBDD0, 0x8ACB, 0xBDD1, 0x8AF8, 0xBDD2, 0x8AB2, 0xBDD3, 0x8AC9,\r\n\t0xBDD4, 0x8AC2, 0xBDD5, 0x8ABF, 0xBDD6, 0x8AB0, 0xBDD7, 0x8AD6,\t0xBDD8, 0x8ACD, 0xBDD9, 0x8AB6, 0xBDDA, 0x8AB9, 0xBDDB, 0x8ADB,\r\n\t0xBDDC, 0x8C4C, 0xBDDD, 0x8C4E, 0xBDDE, 0x8C6C, 0xBDDF, 0x8CE0,\t0xBDE0, 0x8CDE, 0xBDE1, 0x8CE6, 0xBDE2, 0x8CE4, 0xBDE3, 0x8CEC,\r\n\t0xBDE4, 0x8CED, 0xBDE5, 0x8CE2, 0xBDE6, 0x8CE3, 0xBDE7, 0x8CDC,\t0xBDE8, 0x8CEA, 0xBDE9, 0x8CE1, 0xBDEA, 0x8D6D, 0xBDEB, 0x8D9F,\r\n\t0xBDEC, 0x8DA3, 0xBDED, 0x8E2B, 0xBDEE, 0x8E10, 0xBDEF, 0x8E1D,\t0xBDF0, 0x8E22, 0xBDF1, 0x8E0F, 0xBDF2, 0x8E29, 0xBDF3, 0x8E1F,\r\n\t0xBDF4, 0x8E21, 0xBDF5, 0x8E1E, 0xBDF6, 0x8EBA, 0xBDF7, 0x8F1D,\t0xBDF8, 0x8F1B, 0xBDF9, 0x8F1F, 0xBDFA, 0x8F29, 0xBDFB, 0x8F26,\r\n\t0xBDFC, 0x8F2A, 0xBDFD, 0x8F1C, 0xBDFE, 0x8F1E, 0xBE40, 0x8F25,\t0xBE41, 0x9069, 0xBE42, 0x906E, 0xBE43, 0x9068, 0xBE44, 0x906D,\r\n\t0xBE45, 0x9077, 0xBE46, 0x9130, 0xBE47, 0x912D, 0xBE48, 0x9127,\t0xBE49, 0x9131, 0xBE4A, 0x9187, 0xBE4B, 0x9189, 0xBE4C, 0x918B,\r\n\t0xBE4D, 0x9183, 0xBE4E, 0x92C5, 0xBE4F, 0x92BB, 0xBE50, 0x92B7,\t0xBE51, 0x92EA, 0xBE52, 0x92AC, 0xBE53, 0x92E4, 0xBE54, 0x92C1,\r\n\t0xBE55, 0x92B3, 0xBE56, 0x92BC, 0xBE57, 0x92D2, 0xBE58, 0x92C7,\t0xBE59, 0x92F0, 0xBE5A, 0x92B2, 0xBE5B, 0x95AD, 0xBE5C, 0x95B1,\r\n\t0xBE5D, 0x9704, 0xBE5E, 0x9706, 0xBE5F, 0x9707, 0xBE60, 0x9709,\t0xBE61, 0x9760, 0xBE62, 0x978D, 0xBE63, 0x978B, 0xBE64, 0x978F,\r\n\t0xBE65, 0x9821, 0xBE66, 0x982B, 0xBE67, 0x981C, 0xBE68, 0x98B3,\t0xBE69, 0x990A, 0xBE6A, 0x9913, 0xBE6B, 0x9912, 0xBE6C, 0x9918,\r\n\t0xBE6D, 0x99DD, 0xBE6E, 0x99D0, 0xBE6F, 0x99DF, 0xBE70, 0x99DB,\t0xBE71, 0x99D1, 0xBE72, 0x99D5, 0xBE73, 0x99D2, 0xBE74, 0x99D9,\r\n\t0xBE75, 0x9AB7, 0xBE76, 0x9AEE, 0xBE77, 0x9AEF, 0xBE78, 0x9B27,\t0xBE79, 0x9B45, 0xBE7A, 0x9B44, 0xBE7B, 0x9B77, 0xBE7C, 0x9B6F,\r\n\t0xBE7D, 0x9D06, 0xBE7E, 0x9D09, 0xBEA1, 0x9D03, 0xBEA2, 0x9EA9,\t0xBEA3, 0x9EBE, 0xBEA4, 0x9ECE, 0xBEA5, 0x58A8, 0xBEA6, 0x9F52,\r\n\t0xBEA7, 0x5112, 0xBEA8, 0x5118, 0xBEA9, 0x5114, 0xBEAA, 0x5110,\t0xBEAB, 0x5115, 0xBEAC, 0x5180, 0xBEAD, 0x51AA, 0xBEAE, 0x51DD,\r\n\t0xBEAF, 0x5291, 0xBEB0, 0x5293, 0xBEB1, 0x52F3, 0xBEB2, 0x5659,\t0xBEB3, 0x566B, 0xBEB4, 0x5679, 0xBEB5, 0x5669, 0xBEB6, 0x5664,\r\n\t0xBEB7, 0x5678, 0xBEB8, 0x566A, 0xBEB9, 0x5668, 0xBEBA, 0x5665,\t0xBEBB, 0x5671, 0xBEBC, 0x566F, 0xBEBD, 0x566C, 0xBEBE, 0x5662,\r\n\t0xBEBF, 0x5676, 0xBEC0, 0x58C1, 0xBEC1, 0x58BE, 0xBEC2, 0x58C7,\t0xBEC3, 0x58C5, 0xBEC4, 0x596E, 0xBEC5, 0x5B1D, 0xBEC6, 0x5B34,\r\n\t0xBEC7, 0x5B78, 0xBEC8, 0x5BF0, 0xBEC9, 0x5C0E, 0xBECA, 0x5F4A,\t0xBECB, 0x61B2, 0xBECC, 0x6191, 0xBECD, 0x61A9, 0xBECE, 0x618A,\r\n\t0xBECF, 0x61CD, 0xBED0, 0x61B6, 0xBED1, 0x61BE, 0xBED2, 0x61CA,\t0xBED3, 0x61C8, 0xBED4, 0x6230, 0xBED5, 0x64C5, 0xBED6, 0x64C1,\r\n\t0xBED7, 0x64CB, 0xBED8, 0x64BB, 0xBED9, 0x64BC, 0xBEDA, 0x64DA,\t0xBEDB, 0x64C4, 0xBEDC, 0x64C7, 0xBEDD, 0x64C2, 0xBEDE, 0x64CD,\r\n\t0xBEDF, 0x64BF, 0xBEE0, 0x64D2, 0xBEE1, 0x64D4, 0xBEE2, 0x64BE,\t0xBEE3, 0x6574, 0xBEE4, 0x66C6, 0xBEE5, 0x66C9, 0xBEE6, 0x66B9,\r\n\t0xBEE7, 0x66C4, 0xBEE8, 0x66C7, 0xBEE9, 0x66B8, 0xBEEA, 0x6A3D,\t0xBEEB, 0x6A38, 0xBEEC, 0x6A3A, 0xBEED, 0x6A59, 0xBEEE, 0x6A6B,\r\n\t0xBEEF, 0x6A58, 0xBEF0, 0x6A39, 0xBEF1, 0x6A44, 0xBEF2, 0x6A62,\t0xBEF3, 0x6A61, 0xBEF4, 0x6A4B, 0xBEF5, 0x6A47, 0xBEF6, 0x6A35,\r\n\t0xBEF7, 0x6A5F, 0xBEF8, 0x6A48, 0xBEF9, 0x6B59, 0xBEFA, 0x6B77,\t0xBEFB, 0x6C05, 0xBEFC, 0x6FC2, 0xBEFD, 0x6FB1, 0xBEFE, 0x6FA1,\r\n\t0xBF40, 0x6FC3, 0xBF41, 0x6FA4, 0xBF42, 0x6FC1, 0xBF43, 0x6FA7,\t0xBF44, 0x6FB3, 0xBF45, 0x6FC0, 0xBF46, 0x6FB9, 0xBF47, 0x6FB6,\r\n\t0xBF48, 0x6FA6, 0xBF49, 0x6FA0, 0xBF4A, 0x6FB4, 0xBF4B, 0x71BE,\t0xBF4C, 0x71C9, 0xBF4D, 0x71D0, 0xBF4E, 0x71D2, 0xBF4F, 0x71C8,\r\n\t0xBF50, 0x71D5, 0xBF51, 0x71B9, 0xBF52, 0x71CE, 0xBF53, 0x71D9,\t0xBF54, 0x71DC, 0xBF55, 0x71C3, 0xBF56, 0x71C4, 0xBF57, 0x7368,\r\n\t0xBF58, 0x749C, 0xBF59, 0x74A3, 0xBF5A, 0x7498, 0xBF5B, 0x749F,\t0xBF5C, 0x749E, 0xBF5D, 0x74E2, 0xBF5E, 0x750C, 0xBF5F, 0x750D,\r\n\t0xBF60, 0x7634, 0xBF61, 0x7638, 0xBF62, 0x763A, 0xBF63, 0x76E7,\t0xBF64, 0x76E5, 0xBF65, 0x77A0, 0xBF66, 0x779E, 0xBF67, 0x779F,\r\n\t0xBF68, 0x77A5, 0xBF69, 0x78E8, 0xBF6A, 0x78DA, 0xBF6B, 0x78EC,\t0xBF6C, 0x78E7, 0xBF6D, 0x79A6, 0xBF6E, 0x7A4D, 0xBF6F, 0x7A4E,\r\n\t0xBF70, 0x7A46, 0xBF71, 0x7A4C, 0xBF72, 0x7A4B, 0xBF73, 0x7ABA,\t0xBF74, 0x7BD9, 0xBF75, 0x7C11, 0xBF76, 0x7BC9, 0xBF77, 0x7BE4,\r\n\t0xBF78, 0x7BDB, 0xBF79, 0x7BE1, 0xBF7A, 0x7BE9, 0xBF7B, 0x7BE6,\t0xBF7C, 0x7CD5, 0xBF7D, 0x7CD6, 0xBF7E, 0x7E0A, 0xBFA1, 0x7E11,\r\n\t0xBFA2, 0x7E08, 0xBFA3, 0x7E1B, 0xBFA4, 0x7E23, 0xBFA5, 0x7E1E,\t0xBFA6, 0x7E1D, 0xBFA7, 0x7E09, 0xBFA8, 0x7E10, 0xBFA9, 0x7F79,\r\n\t0xBFAA, 0x7FB2, 0xBFAB, 0x7FF0, 0xBFAC, 0x7FF1, 0xBFAD, 0x7FEE,\t0xBFAE, 0x8028, 0xBFAF, 0x81B3, 0xBFB0, 0x81A9, 0xBFB1, 0x81A8,\r\n\t0xBFB2, 0x81FB, 0xBFB3, 0x8208, 0xBFB4, 0x8258, 0xBFB5, 0x8259,\t0xBFB6, 0x854A, 0xBFB7, 0x8559, 0xBFB8, 0x8548, 0xBFB9, 0x8568,\r\n\t0xBFBA, 0x8569, 0xBFBB, 0x8543, 0xBFBC, 0x8549, 0xBFBD, 0x856D,\t0xBFBE, 0x856A, 0xBFBF, 0x855E, 0xBFC0, 0x8783, 0xBFC1, 0x879F,\r\n\t0xBFC2, 0x879E, 0xBFC3, 0x87A2, 0xBFC4, 0x878D, 0xBFC5, 0x8861,\t0xBFC6, 0x892A, 0xBFC7, 0x8932, 0xBFC8, 0x8925, 0xBFC9, 0x892B,\r\n\t0xBFCA, 0x8921, 0xBFCB, 0x89AA, 0xBFCC, 0x89A6, 0xBFCD, 0x8AE6,\t0xBFCE, 0x8AFA, 0xBFCF, 0x8AEB, 0xBFD0, 0x8AF1, 0xBFD1, 0x8B00,\r\n\t0xBFD2, 0x8ADC, 0xBFD3, 0x8AE7, 0xBFD4, 0x8AEE, 0xBFD5, 0x8AFE,\t0xBFD6, 0x8B01, 0xBFD7, 0x8B02, 0xBFD8, 0x8AF7, 0xBFD9, 0x8AED,\r\n\t0xBFDA, 0x8AF3, 0xBFDB, 0x8AF6, 0xBFDC, 0x8AFC, 0xBFDD, 0x8C6B,\t0xBFDE, 0x8C6D, 0xBFDF, 0x8C93, 0xBFE0, 0x8CF4, 0xBFE1, 0x8E44,\r\n\t0xBFE2, 0x8E31, 0xBFE3, 0x8E34, 0xBFE4, 0x8E42, 0xBFE5, 0x8E39,\t0xBFE6, 0x8E35, 0xBFE7, 0x8F3B, 0xBFE8, 0x8F2F, 0xBFE9, 0x8F38,\r\n\t0xBFEA, 0x8F33, 0xBFEB, 0x8FA8, 0xBFEC, 0x8FA6, 0xBFED, 0x9075,\t0xBFEE, 0x9074, 0xBFEF, 0x9078, 0xBFF0, 0x9072, 0xBFF1, 0x907C,\r\n\t0xBFF2, 0x907A, 0xBFF3, 0x9134, 0xBFF4, 0x9192, 0xBFF5, 0x9320,\t0xBFF6, 0x9336, 0xBFF7, 0x92F8, 0xBFF8, 0x9333, 0xBFF9, 0x932F,\r\n\t0xBFFA, 0x9322, 0xBFFB, 0x92FC, 0xBFFC, 0x932B, 0xBFFD, 0x9304,\t0xBFFE, 0x931A, 0xC040, 0x9310, 0xC041, 0x9326, 0xC042, 0x9321,\r\n\t0xC043, 0x9315, 0xC044, 0x932E, 0xC045, 0x9319, 0xC046, 0x95BB,\t0xC047, 0x96A7, 0xC048, 0x96A8, 0xC049, 0x96AA, 0xC04A, 0x96D5,\r\n\t0xC04B, 0x970E, 0xC04C, 0x9711, 0xC04D, 0x9716, 0xC04E, 0x970D,\t0xC04F, 0x9713, 0xC050, 0x970F, 0xC051, 0x975B, 0xC052, 0x975C,\r\n\t0xC053, 0x9766, 0xC054, 0x9798, 0xC055, 0x9830, 0xC056, 0x9838,\t0xC057, 0x983B, 0xC058, 0x9837, 0xC059, 0x982D, 0xC05A, 0x9839,\r\n\t0xC05B, 0x9824, 0xC05C, 0x9910, 0xC05D, 0x9928, 0xC05E, 0x991E,\t0xC05F, 0x991B, 0xC060, 0x9921, 0xC061, 0x991A, 0xC062, 0x99ED,\r\n\t0xC063, 0x99E2, 0xC064, 0x99F1, 0xC065, 0x9AB8, 0xC066, 0x9ABC,\t0xC067, 0x9AFB, 0xC068, 0x9AED, 0xC069, 0x9B28, 0xC06A, 0x9B91,\r\n\t0xC06B, 0x9D15, 0xC06C, 0x9D23, 0xC06D, 0x9D26, 0xC06E, 0x9D28,\t0xC06F, 0x9D12, 0xC070, 0x9D1B, 0xC071, 0x9ED8, 0xC072, 0x9ED4,\r\n\t0xC073, 0x9F8D, 0xC074, 0x9F9C, 0xC075, 0x512A, 0xC076, 0x511F,\t0xC077, 0x5121, 0xC078, 0x5132, 0xC079, 0x52F5, 0xC07A, 0x568E,\r\n\t0xC07B, 0x5680, 0xC07C, 0x5690, 0xC07D, 0x5685, 0xC07E, 0x5687,\t0xC0A1, 0x568F, 0xC0A2, 0x58D5, 0xC0A3, 0x58D3, 0xC0A4, 0x58D1,\r\n\t0xC0A5, 0x58CE, 0xC0A6, 0x5B30, 0xC0A7, 0x5B2A, 0xC0A8, 0x5B24,\t0xC0A9, 0x5B7A, 0xC0AA, 0x5C37, 0xC0AB, 0x5C68, 0xC0AC, 0x5DBC,\r\n\t0xC0AD, 0x5DBA, 0xC0AE, 0x5DBD, 0xC0AF, 0x5DB8, 0xC0B0, 0x5E6B,\t0xC0B1, 0x5F4C, 0xC0B2, 0x5FBD, 0xC0B3, 0x61C9, 0xC0B4, 0x61C2,\r\n\t0xC0B5, 0x61C7, 0xC0B6, 0x61E6, 0xC0B7, 0x61CB, 0xC0B8, 0x6232,\t0xC0B9, 0x6234, 0xC0BA, 0x64CE, 0xC0BB, 0x64CA, 0xC0BC, 0x64D8,\r\n\t0xC0BD, 0x64E0, 0xC0BE, 0x64F0, 0xC0BF, 0x64E6, 0xC0C0, 0x64EC,\t0xC0C1, 0x64F1, 0xC0C2, 0x64E2, 0xC0C3, 0x64ED, 0xC0C4, 0x6582,\r\n\t0xC0C5, 0x6583, 0xC0C6, 0x66D9, 0xC0C7, 0x66D6, 0xC0C8, 0x6A80,\t0xC0C9, 0x6A94, 0xC0CA, 0x6A84, 0xC0CB, 0x6AA2, 0xC0CC, 0x6A9C,\r\n\t0xC0CD, 0x6ADB, 0xC0CE, 0x6AA3, 0xC0CF, 0x6A7E, 0xC0D0, 0x6A97,\t0xC0D1, 0x6A90, 0xC0D2, 0x6AA0, 0xC0D3, 0x6B5C, 0xC0D4, 0x6BAE,\r\n\t0xC0D5, 0x6BDA, 0xC0D6, 0x6C08, 0xC0D7, 0x6FD8, 0xC0D8, 0x6FF1,\t0xC0D9, 0x6FDF, 0xC0DA, 0x6FE0, 0xC0DB, 0x6FDB, 0xC0DC, 0x6FE4,\r\n\t0xC0DD, 0x6FEB, 0xC0DE, 0x6FEF, 0xC0DF, 0x6F80, 0xC0E0, 0x6FEC,\t0xC0E1, 0x6FE1, 0xC0E2, 0x6FE9, 0xC0E3, 0x6FD5, 0xC0E4, 0x6FEE,\r\n\t0xC0E5, 0x6FF0, 0xC0E6, 0x71E7, 0xC0E7, 0x71DF, 0xC0E8, 0x71EE,\t0xC0E9, 0x71E6, 0xC0EA, 0x71E5, 0xC0EB, 0x71ED, 0xC0EC, 0x71EC,\r\n\t0xC0ED, 0x71F4, 0xC0EE, 0x71E0, 0xC0EF, 0x7235, 0xC0F0, 0x7246,\t0xC0F1, 0x7370, 0xC0F2, 0x7372, 0xC0F3, 0x74A9, 0xC0F4, 0x74B0,\r\n\t0xC0F5, 0x74A6, 0xC0F6, 0x74A8, 0xC0F7, 0x7646, 0xC0F8, 0x7642,\t0xC0F9, 0x764C, 0xC0FA, 0x76EA, 0xC0FB, 0x77B3, 0xC0FC, 0x77AA,\r\n\t0xC0FD, 0x77B0, 0xC0FE, 0x77AC, 0xC140, 0x77A7, 0xC141, 0x77AD,\t0xC142, 0x77EF, 0xC143, 0x78F7, 0xC144, 0x78FA, 0xC145, 0x78F4,\r\n\t0xC146, 0x78EF, 0xC147, 0x7901, 0xC148, 0x79A7, 0xC149, 0x79AA,\t0xC14A, 0x7A57, 0xC14B, 0x7ABF, 0xC14C, 0x7C07, 0xC14D, 0x7C0D,\r\n\t0xC14E, 0x7BFE, 0xC14F, 0x7BF7, 0xC150, 0x7C0C, 0xC151, 0x7BE0,\t0xC152, 0x7CE0, 0xC153, 0x7CDC, 0xC154, 0x7CDE, 0xC155, 0x7CE2,\r\n\t0xC156, 0x7CDF, 0xC157, 0x7CD9, 0xC158, 0x7CDD, 0xC159, 0x7E2E,\t0xC15A, 0x7E3E, 0xC15B, 0x7E46, 0xC15C, 0x7E37, 0xC15D, 0x7E32,\r\n\t0xC15E, 0x7E43, 0xC15F, 0x7E2B, 0xC160, 0x7E3D, 0xC161, 0x7E31,\t0xC162, 0x7E45, 0xC163, 0x7E41, 0xC164, 0x7E34, 0xC165, 0x7E39,\r\n\t0xC166, 0x7E48, 0xC167, 0x7E35, 0xC168, 0x7E3F, 0xC169, 0x7E2F,\t0xC16A, 0x7F44, 0xC16B, 0x7FF3, 0xC16C, 0x7FFC, 0xC16D, 0x8071,\r\n\t0xC16E, 0x8072, 0xC16F, 0x8070, 0xC170, 0x806F, 0xC171, 0x8073,\t0xC172, 0x81C6, 0xC173, 0x81C3, 0xC174, 0x81BA, 0xC175, 0x81C2,\r\n\t0xC176, 0x81C0, 0xC177, 0x81BF, 0xC178, 0x81BD, 0xC179, 0x81C9,\t0xC17A, 0x81BE, 0xC17B, 0x81E8, 0xC17C, 0x8209, 0xC17D, 0x8271,\r\n\t0xC17E, 0x85AA, 0xC1A1, 0x8584, 0xC1A2, 0x857E, 0xC1A3, 0x859C,\t0xC1A4, 0x8591, 0xC1A5, 0x8594, 0xC1A6, 0x85AF, 0xC1A7, 0x859B,\r\n\t0xC1A8, 0x8587, 0xC1A9, 0x85A8, 0xC1AA, 0x858A, 0xC1AB, 0x8667,\t0xC1AC, 0x87C0, 0xC1AD, 0x87D1, 0xC1AE, 0x87B3, 0xC1AF, 0x87D2,\r\n\t0xC1B0, 0x87C6, 0xC1B1, 0x87AB, 0xC1B2, 0x87BB, 0xC1B3, 0x87BA,\t0xC1B4, 0x87C8, 0xC1B5, 0x87CB, 0xC1B6, 0x893B, 0xC1B7, 0x8936,\r\n\t0xC1B8, 0x8944, 0xC1B9, 0x8938, 0xC1BA, 0x893D, 0xC1BB, 0x89AC,\t0xC1BC, 0x8B0E, 0xC1BD, 0x8B17, 0xC1BE, 0x8B19, 0xC1BF, 0x8B1B,\r\n\t0xC1C0, 0x8B0A, 0xC1C1, 0x8B20, 0xC1C2, 0x8B1D, 0xC1C3, 0x8B04,\t0xC1C4, 0x8B10, 0xC1C5, 0x8C41, 0xC1C6, 0x8C3F, 0xC1C7, 0x8C73,\r\n\t0xC1C8, 0x8CFA, 0xC1C9, 0x8CFD, 0xC1CA, 0x8CFC, 0xC1CB, 0x8CF8,\t0xC1CC, 0x8CFB, 0xC1CD, 0x8DA8, 0xC1CE, 0x8E49, 0xC1CF, 0x8E4B,\r\n\t0xC1D0, 0x8E48, 0xC1D1, 0x8E4A, 0xC1D2, 0x8F44, 0xC1D3, 0x8F3E,\t0xC1D4, 0x8F42, 0xC1D5, 0x8F45, 0xC1D6, 0x8F3F, 0xC1D7, 0x907F,\r\n\t0xC1D8, 0x907D, 0xC1D9, 0x9084, 0xC1DA, 0x9081, 0xC1DB, 0x9082,\t0xC1DC, 0x9080, 0xC1DD, 0x9139, 0xC1DE, 0x91A3, 0xC1DF, 0x919E,\r\n\t0xC1E0, 0x919C, 0xC1E1, 0x934D, 0xC1E2, 0x9382, 0xC1E3, 0x9328,\t0xC1E4, 0x9375, 0xC1E5, 0x934A, 0xC1E6, 0x9365, 0xC1E7, 0x934B,\r\n\t0xC1E8, 0x9318, 0xC1E9, 0x937E, 0xC1EA, 0x936C, 0xC1EB, 0x935B,\t0xC1EC, 0x9370, 0xC1ED, 0x935A, 0xC1EE, 0x9354, 0xC1EF, 0x95CA,\r\n\t0xC1F0, 0x95CB, 0xC1F1, 0x95CC, 0xC1F2, 0x95C8, 0xC1F3, 0x95C6,\t0xC1F4, 0x96B1, 0xC1F5, 0x96B8, 0xC1F6, 0x96D6, 0xC1F7, 0x971C,\r\n\t0xC1F8, 0x971E, 0xC1F9, 0x97A0, 0xC1FA, 0x97D3, 0xC1FB, 0x9846,\t0xC1FC, 0x98B6, 0xC1FD, 0x9935, 0xC1FE, 0x9A01, 0xC240, 0x99FF,\r\n\t0xC241, 0x9BAE, 0xC242, 0x9BAB, 0xC243, 0x9BAA, 0xC244, 0x9BAD,\t0xC245, 0x9D3B, 0xC246, 0x9D3F, 0xC247, 0x9E8B, 0xC248, 0x9ECF,\r\n\t0xC249, 0x9EDE, 0xC24A, 0x9EDC, 0xC24B, 0x9EDD, 0xC24C, 0x9EDB,\t0xC24D, 0x9F3E, 0xC24E, 0x9F4B, 0xC24F, 0x53E2, 0xC250, 0x5695,\r\n\t0xC251, 0x56AE, 0xC252, 0x58D9, 0xC253, 0x58D8, 0xC254, 0x5B38,\t0xC255, 0x5F5D, 0xC256, 0x61E3, 0xC257, 0x6233, 0xC258, 0x64F4,\r\n\t0xC259, 0x64F2, 0xC25A, 0x64FE, 0xC25B, 0x6506, 0xC25C, 0x64FA,\t0xC25D, 0x64FB, 0xC25E, 0x64F7, 0xC25F, 0x65B7, 0xC260, 0x66DC,\r\n\t0xC261, 0x6726, 0xC262, 0x6AB3, 0xC263, 0x6AAC, 0xC264, 0x6AC3,\t0xC265, 0x6ABB, 0xC266, 0x6AB8, 0xC267, 0x6AC2, 0xC268, 0x6AAE,\r\n\t0xC269, 0x6AAF, 0xC26A, 0x6B5F, 0xC26B, 0x6B78, 0xC26C, 0x6BAF,\t0xC26D, 0x7009, 0xC26E, 0x700B, 0xC26F, 0x6FFE, 0xC270, 0x7006,\r\n\t0xC271, 0x6FFA, 0xC272, 0x7011, 0xC273, 0x700F, 0xC274, 0x71FB,\t0xC275, 0x71FC, 0xC276, 0x71FE, 0xC277, 0x71F8, 0xC278, 0x7377,\r\n\t0xC279, 0x7375, 0xC27A, 0x74A7, 0xC27B, 0x74BF, 0xC27C, 0x7515,\t0xC27D, 0x7656, 0xC27E, 0x7658, 0xC2A1, 0x7652, 0xC2A2, 0x77BD,\r\n\t0xC2A3, 0x77BF, 0xC2A4, 0x77BB, 0xC2A5, 0x77BC, 0xC2A6, 0x790E,\t0xC2A7, 0x79AE, 0xC2A8, 0x7A61, 0xC2A9, 0x7A62, 0xC2AA, 0x7A60,\r\n\t0xC2AB, 0x7AC4, 0xC2AC, 0x7AC5, 0xC2AD, 0x7C2B, 0xC2AE, 0x7C27,\t0xC2AF, 0x7C2A, 0xC2B0, 0x7C1E, 0xC2B1, 0x7C23, 0xC2B2, 0x7C21,\r\n\t0xC2B3, 0x7CE7, 0xC2B4, 0x7E54, 0xC2B5, 0x7E55, 0xC2B6, 0x7E5E,\t0xC2B7, 0x7E5A, 0xC2B8, 0x7E61, 0xC2B9, 0x7E52, 0xC2BA, 0x7E59,\r\n\t0xC2BB, 0x7F48, 0xC2BC, 0x7FF9, 0xC2BD, 0x7FFB, 0xC2BE, 0x8077,\t0xC2BF, 0x8076, 0xC2C0, 0x81CD, 0xC2C1, 0x81CF, 0xC2C2, 0x820A,\r\n\t0xC2C3, 0x85CF, 0xC2C4, 0x85A9, 0xC2C5, 0x85CD, 0xC2C6, 0x85D0,\t0xC2C7, 0x85C9, 0xC2C8, 0x85B0, 0xC2C9, 0x85BA, 0xC2CA, 0x85B9,\r\n\t0xC2CB, 0x85A6, 0xC2CC, 0x87EF, 0xC2CD, 0x87EC, 0xC2CE, 0x87F2,\t0xC2CF, 0x87E0, 0xC2D0, 0x8986, 0xC2D1, 0x89B2, 0xC2D2, 0x89F4,\r\n\t0xC2D3, 0x8B28, 0xC2D4, 0x8B39, 0xC2D5, 0x8B2C, 0xC2D6, 0x8B2B,\t0xC2D7, 0x8C50, 0xC2D8, 0x8D05, 0xC2D9, 0x8E59, 0xC2DA, 0x8E63,\r\n\t0xC2DB, 0x8E66, 0xC2DC, 0x8E64, 0xC2DD, 0x8E5F, 0xC2DE, 0x8E55,\t0xC2DF, 0x8EC0, 0xC2E0, 0x8F49, 0xC2E1, 0x8F4D, 0xC2E2, 0x9087,\r\n\t0xC2E3, 0x9083, 0xC2E4, 0x9088, 0xC2E5, 0x91AB, 0xC2E6, 0x91AC,\t0xC2E7, 0x91D0, 0xC2E8, 0x9394, 0xC2E9, 0x938A, 0xC2EA, 0x9396,\r\n\t0xC2EB, 0x93A2, 0xC2EC, 0x93B3, 0xC2ED, 0x93AE, 0xC2EE, 0x93AC,\t0xC2EF, 0x93B0, 0xC2F0, 0x9398, 0xC2F1, 0x939A, 0xC2F2, 0x9397,\r\n\t0xC2F3, 0x95D4, 0xC2F4, 0x95D6, 0xC2F5, 0x95D0, 0xC2F6, 0x95D5,\t0xC2F7, 0x96E2, 0xC2F8, 0x96DC, 0xC2F9, 0x96D9, 0xC2FA, 0x96DB,\r\n\t0xC2FB, 0x96DE, 0xC2FC, 0x9724, 0xC2FD, 0x97A3, 0xC2FE, 0x97A6,\t0xC340, 0x97AD, 0xC341, 0x97F9, 0xC342, 0x984D, 0xC343, 0x984F,\r\n\t0xC344, 0x984C, 0xC345, 0x984E, 0xC346, 0x9853, 0xC347, 0x98BA,\t0xC348, 0x993E, 0xC349, 0x993F, 0xC34A, 0x993D, 0xC34B, 0x992E,\r\n\t0xC34C, 0x99A5, 0xC34D, 0x9A0E, 0xC34E, 0x9AC1, 0xC34F, 0x9B03,\t0xC350, 0x9B06, 0xC351, 0x9B4F, 0xC352, 0x9B4E, 0xC353, 0x9B4D,\r\n\t0xC354, 0x9BCA, 0xC355, 0x9BC9, 0xC356, 0x9BFD, 0xC357, 0x9BC8,\t0xC358, 0x9BC0, 0xC359, 0x9D51, 0xC35A, 0x9D5D, 0xC35B, 0x9D60,\r\n\t0xC35C, 0x9EE0, 0xC35D, 0x9F15, 0xC35E, 0x9F2C, 0xC35F, 0x5133,\t0xC360, 0x56A5, 0xC361, 0x58DE, 0xC362, 0x58DF, 0xC363, 0x58E2,\r\n\t0xC364, 0x5BF5, 0xC365, 0x9F90, 0xC366, 0x5EEC, 0xC367, 0x61F2,\t0xC368, 0x61F7, 0xC369, 0x61F6, 0xC36A, 0x61F5, 0xC36B, 0x6500,\r\n\t0xC36C, 0x650F, 0xC36D, 0x66E0, 0xC36E, 0x66DD, 0xC36F, 0x6AE5,\t0xC370, 0x6ADD, 0xC371, 0x6ADA, 0xC372, 0x6AD3, 0xC373, 0x701B,\r\n\t0xC374, 0x701F, 0xC375, 0x7028, 0xC376, 0x701A, 0xC377, 0x701D,\t0xC378, 0x7015, 0xC379, 0x7018, 0xC37A, 0x7206, 0xC37B, 0x720D,\r\n\t0xC37C, 0x7258, 0xC37D, 0x72A2, 0xC37E, 0x7378, 0xC3A1, 0x737A,\t0xC3A2, 0x74BD, 0xC3A3, 0x74CA, 0xC3A4, 0x74E3, 0xC3A5, 0x7587,\r\n\t0xC3A6, 0x7586, 0xC3A7, 0x765F, 0xC3A8, 0x7661, 0xC3A9, 0x77C7,\t0xC3AA, 0x7919, 0xC3AB, 0x79B1, 0xC3AC, 0x7A6B, 0xC3AD, 0x7A69,\r\n\t0xC3AE, 0x7C3E, 0xC3AF, 0x7C3F, 0xC3B0, 0x7C38, 0xC3B1, 0x7C3D,\t0xC3B2, 0x7C37, 0xC3B3, 0x7C40, 0xC3B4, 0x7E6B, 0xC3B5, 0x7E6D,\r\n\t0xC3B6, 0x7E79, 0xC3B7, 0x7E69, 0xC3B8, 0x7E6A, 0xC3B9, 0x7F85,\t0xC3BA, 0x7E73, 0xC3BB, 0x7FB6, 0xC3BC, 0x7FB9, 0xC3BD, 0x7FB8,\r\n\t0xC3BE, 0x81D8, 0xC3BF, 0x85E9, 0xC3C0, 0x85DD, 0xC3C1, 0x85EA,\t0xC3C2, 0x85D5, 0xC3C3, 0x85E4, 0xC3C4, 0x85E5, 0xC3C5, 0x85F7,\r\n\t0xC3C6, 0x87FB, 0xC3C7, 0x8805, 0xC3C8, 0x880D, 0xC3C9, 0x87F9,\t0xC3CA, 0x87FE, 0xC3CB, 0x8960, 0xC3CC, 0x895F, 0xC3CD, 0x8956,\r\n\t0xC3CE, 0x895E, 0xC3CF, 0x8B41, 0xC3D0, 0x8B5C, 0xC3D1, 0x8B58,\t0xC3D2, 0x8B49, 0xC3D3, 0x8B5A, 0xC3D4, 0x8B4E, 0xC3D5, 0x8B4F,\r\n\t0xC3D6, 0x8B46, 0xC3D7, 0x8B59, 0xC3D8, 0x8D08, 0xC3D9, 0x8D0A,\t0xC3DA, 0x8E7C, 0xC3DB, 0x8E72, 0xC3DC, 0x8E87, 0xC3DD, 0x8E76,\r\n\t0xC3DE, 0x8E6C, 0xC3DF, 0x8E7A, 0xC3E0, 0x8E74, 0xC3E1, 0x8F54,\t0xC3E2, 0x8F4E, 0xC3E3, 0x8FAD, 0xC3E4, 0x908A, 0xC3E5, 0x908B,\r\n\t0xC3E6, 0x91B1, 0xC3E7, 0x91AE, 0xC3E8, 0x93E1, 0xC3E9, 0x93D1,\t0xC3EA, 0x93DF, 0xC3EB, 0x93C3, 0xC3EC, 0x93C8, 0xC3ED, 0x93DC,\r\n\t0xC3EE, 0x93DD, 0xC3EF, 0x93D6, 0xC3F0, 0x93E2, 0xC3F1, 0x93CD,\t0xC3F2, 0x93D8, 0xC3F3, 0x93E4, 0xC3F4, 0x93D7, 0xC3F5, 0x93E8,\r\n\t0xC3F6, 0x95DC, 0xC3F7, 0x96B4, 0xC3F8, 0x96E3, 0xC3F9, 0x972A,\t0xC3FA, 0x9727, 0xC3FB, 0x9761, 0xC3FC, 0x97DC, 0xC3FD, 0x97FB,\r\n\t0xC3FE, 0x985E, 0xC440, 0x9858, 0xC441, 0x985B, 0xC442, 0x98BC,\t0xC443, 0x9945, 0xC444, 0x9949, 0xC445, 0x9A16, 0xC446, 0x9A19,\r\n\t0xC447, 0x9B0D, 0xC448, 0x9BE8, 0xC449, 0x9BE7, 0xC44A, 0x9BD6,\t0xC44B, 0x9BDB, 0xC44C, 0x9D89, 0xC44D, 0x9D61, 0xC44E, 0x9D72,\r\n\t0xC44F, 0x9D6A, 0xC450, 0x9D6C, 0xC451, 0x9E92, 0xC452, 0x9E97,\t0xC453, 0x9E93, 0xC454, 0x9EB4, 0xC455, 0x52F8, 0xC456, 0x56A8,\r\n\t0xC457, 0x56B7, 0xC458, 0x56B6, 0xC459, 0x56B4, 0xC45A, 0x56BC,\t0xC45B, 0x58E4, 0xC45C, 0x5B40, 0xC45D, 0x5B43, 0xC45E, 0x5B7D,\r\n\t0xC45F, 0x5BF6, 0xC460, 0x5DC9, 0xC461, 0x61F8, 0xC462, 0x61FA,\t0xC463, 0x6518, 0xC464, 0x6514, 0xC465, 0x6519, 0xC466, 0x66E6,\r\n\t0xC467, 0x6727, 0xC468, 0x6AEC, 0xC469, 0x703E, 0xC46A, 0x7030,\t0xC46B, 0x7032, 0xC46C, 0x7210, 0xC46D, 0x737B, 0xC46E, 0x74CF,\r\n\t0xC46F, 0x7662, 0xC470, 0x7665, 0xC471, 0x7926, 0xC472, 0x792A,\t0xC473, 0x792C, 0xC474, 0x792B, 0xC475, 0x7AC7, 0xC476, 0x7AF6,\r\n\t0xC477, 0x7C4C, 0xC478, 0x7C43, 0xC479, 0x7C4D, 0xC47A, 0x7CEF,\t0xC47B, 0x7CF0, 0xC47C, 0x8FAE, 0xC47D, 0x7E7D, 0xC47E, 0x7E7C,\r\n\t0xC4A1, 0x7E82, 0xC4A2, 0x7F4C, 0xC4A3, 0x8000, 0xC4A4, 0x81DA,\t0xC4A5, 0x8266, 0xC4A6, 0x85FB, 0xC4A7, 0x85F9, 0xC4A8, 0x8611,\r\n\t0xC4A9, 0x85FA, 0xC4AA, 0x8606, 0xC4AB, 0x860B, 0xC4AC, 0x8607,\t0xC4AD, 0x860A, 0xC4AE, 0x8814, 0xC4AF, 0x8815, 0xC4B0, 0x8964,\r\n\t0xC4B1, 0x89BA, 0xC4B2, 0x89F8, 0xC4B3, 0x8B70, 0xC4B4, 0x8B6C,\t0xC4B5, 0x8B66, 0xC4B6, 0x8B6F, 0xC4B7, 0x8B5F, 0xC4B8, 0x8B6B,\r\n\t0xC4B9, 0x8D0F, 0xC4BA, 0x8D0D, 0xC4BB, 0x8E89, 0xC4BC, 0x8E81,\t0xC4BD, 0x8E85, 0xC4BE, 0x8E82, 0xC4BF, 0x91B4, 0xC4C0, 0x91CB,\r\n\t0xC4C1, 0x9418, 0xC4C2, 0x9403, 0xC4C3, 0x93FD, 0xC4C4, 0x95E1,\t0xC4C5, 0x9730, 0xC4C6, 0x98C4, 0xC4C7, 0x9952, 0xC4C8, 0x9951,\r\n\t0xC4C9, 0x99A8, 0xC4CA, 0x9A2B, 0xC4CB, 0x9A30, 0xC4CC, 0x9A37,\t0xC4CD, 0x9A35, 0xC4CE, 0x9C13, 0xC4CF, 0x9C0D, 0xC4D0, 0x9E79,\r\n\t0xC4D1, 0x9EB5, 0xC4D2, 0x9EE8, 0xC4D3, 0x9F2F, 0xC4D4, 0x9F5F,\t0xC4D5, 0x9F63, 0xC4D6, 0x9F61, 0xC4D7, 0x5137, 0xC4D8, 0x5138,\r\n\t0xC4D9, 0x56C1, 0xC4DA, 0x56C0, 0xC4DB, 0x56C2, 0xC4DC, 0x5914,\t0xC4DD, 0x5C6C, 0xC4DE, 0x5DCD, 0xC4DF, 0x61FC, 0xC4E0, 0x61FE,\r\n\t0xC4E1, 0x651D, 0xC4E2, 0x651C, 0xC4E3, 0x6595, 0xC4E4, 0x66E9,\t0xC4E5, 0x6AFB, 0xC4E6, 0x6B04, 0xC4E7, 0x6AFA, 0xC4E8, 0x6BB2,\r\n\t0xC4E9, 0x704C, 0xC4EA, 0x721B, 0xC4EB, 0x72A7, 0xC4EC, 0x74D6,\t0xC4ED, 0x74D4, 0xC4EE, 0x7669, 0xC4EF, 0x77D3, 0xC4F0, 0x7C50,\r\n\t0xC4F1, 0x7E8F, 0xC4F2, 0x7E8C, 0xC4F3, 0x7FBC, 0xC4F4, 0x8617,\t0xC4F5, 0x862D, 0xC4F6, 0x861A, 0xC4F7, 0x8823, 0xC4F8, 0x8822,\r\n\t0xC4F9, 0x8821, 0xC4FA, 0x881F, 0xC4FB, 0x896A, 0xC4FC, 0x896C,\t0xC4FD, 0x89BD, 0xC4FE, 0x8B74, 0xC540, 0x8B77, 0xC541, 0x8B7D,\r\n\t0xC542, 0x8D13, 0xC543, 0x8E8A, 0xC544, 0x8E8D, 0xC545, 0x8E8B,\t0xC546, 0x8F5F, 0xC547, 0x8FAF, 0xC548, 0x91BA, 0xC549, 0x942E,\r\n\t0xC54A, 0x9433, 0xC54B, 0x9435, 0xC54C, 0x943A, 0xC54D, 0x9438,\t0xC54E, 0x9432, 0xC54F, 0x942B, 0xC550, 0x95E2, 0xC551, 0x9738,\r\n\t0xC552, 0x9739, 0xC553, 0x9732, 0xC554, 0x97FF, 0xC555, 0x9867,\t0xC556, 0x9865, 0xC557, 0x9957, 0xC558, 0x9A45, 0xC559, 0x9A43,\r\n\t0xC55A, 0x9A40, 0xC55B, 0x9A3E, 0xC55C, 0x9ACF, 0xC55D, 0x9B54,\t0xC55E, 0x9B51, 0xC55F, 0x9C2D, 0xC560, 0x9C25, 0xC561, 0x9DAF,\r\n\t0xC562, 0x9DB4, 0xC563, 0x9DC2, 0xC564, 0x9DB8, 0xC565, 0x9E9D,\t0xC566, 0x9EEF, 0xC567, 0x9F19, 0xC568, 0x9F5C, 0xC569, 0x9F66,\r\n\t0xC56A, 0x9F67, 0xC56B, 0x513C, 0xC56C, 0x513B, 0xC56D, 0x56C8,\t0xC56E, 0x56CA, 0xC56F, 0x56C9, 0xC570, 0x5B7F, 0xC571, 0x5DD4,\r\n\t0xC572, 0x5DD2, 0xC573, 0x5F4E, 0xC574, 0x61FF, 0xC575, 0x6524,\t0xC576, 0x6B0A, 0xC577, 0x6B61, 0xC578, 0x7051, 0xC579, 0x7058,\r\n\t0xC57A, 0x7380, 0xC57B, 0x74E4, 0xC57C, 0x758A, 0xC57D, 0x766E,\t0xC57E, 0x766C, 0xC5A1, 0x79B3, 0xC5A2, 0x7C60, 0xC5A3, 0x7C5F,\r\n\t0xC5A4, 0x807E, 0xC5A5, 0x807D, 0xC5A6, 0x81DF, 0xC5A7, 0x8972,\t0xC5A8, 0x896F, 0xC5A9, 0x89FC, 0xC5AA, 0x8B80, 0xC5AB, 0x8D16,\r\n\t0xC5AC, 0x8D17, 0xC5AD, 0x8E91, 0xC5AE, 0x8E93, 0xC5AF, 0x8F61,\t0xC5B0, 0x9148, 0xC5B1, 0x9444, 0xC5B2, 0x9451, 0xC5B3, 0x9452,\r\n\t0xC5B4, 0x973D, 0xC5B5, 0x973E, 0xC5B6, 0x97C3, 0xC5B7, 0x97C1,\t0xC5B8, 0x986B, 0xC5B9, 0x9955, 0xC5BA, 0x9A55, 0xC5BB, 0x9A4D,\r\n\t0xC5BC, 0x9AD2, 0xC5BD, 0x9B1A, 0xC5BE, 0x9C49, 0xC5BF, 0x9C31,\t0xC5C0, 0x9C3E, 0xC5C1, 0x9C3B, 0xC5C2, 0x9DD3, 0xC5C3, 0x9DD7,\r\n\t0xC5C4, 0x9F34, 0xC5C5, 0x9F6C, 0xC5C6, 0x9F6A, 0xC5C7, 0x9F94,\t0xC5C8, 0x56CC, 0xC5C9, 0x5DD6, 0xC5CA, 0x6200, 0xC5CB, 0x6523,\r\n\t0xC5CC, 0x652B, 0xC5CD, 0x652A, 0xC5CE, 0x66EC, 0xC5CF, 0x6B10,\t0xC5D0, 0x74DA, 0xC5D1, 0x7ACA, 0xC5D2, 0x7C64, 0xC5D3, 0x7C63,\r\n\t0xC5D4, 0x7C65, 0xC5D5, 0x7E93, 0xC5D6, 0x7E96, 0xC5D7, 0x7E94,\t0xC5D8, 0x81E2, 0xC5D9, 0x8638, 0xC5DA, 0x863F, 0xC5DB, 0x8831,\r\n\t0xC5DC, 0x8B8A, 0xC5DD, 0x9090, 0xC5DE, 0x908F, 0xC5DF, 0x9463,\t0xC5E0, 0x9460, 0xC5E1, 0x9464, 0xC5E2, 0x9768, 0xC5E3, 0x986F,\r\n\t0xC5E4, 0x995C, 0xC5E5, 0x9A5A, 0xC5E6, 0x9A5B, 0xC5E7, 0x9A57,\t0xC5E8, 0x9AD3, 0xC5E9, 0x9AD4, 0xC5EA, 0x9AD1, 0xC5EB, 0x9C54,\r\n\t0xC5EC, 0x9C57, 0xC5ED, 0x9C56, 0xC5EE, 0x9DE5, 0xC5EF, 0x9E9F,\t0xC5F0, 0x9EF4, 0xC5F1, 0x56D1, 0xC5F2, 0x58E9, 0xC5F3, 0x652C,\r\n\t0xC5F4, 0x705E, 0xC5F5, 0x7671, 0xC5F6, 0x7672, 0xC5F7, 0x77D7,\t0xC5F8, 0x7F50, 0xC5F9, 0x7F88, 0xC5FA, 0x8836, 0xC5FB, 0x8839,\r\n\t0xC5FC, 0x8862, 0xC5FD, 0x8B93, 0xC5FE, 0x8B92, 0xC640, 0x8B96,\t0xC641, 0x8277, 0xC642, 0x8D1B, 0xC643, 0x91C0, 0xC644, 0x946A,\r\n\t0xC645, 0x9742, 0xC646, 0x9748, 0xC647, 0x9744, 0xC648, 0x97C6,\t0xC649, 0x9870, 0xC64A, 0x9A5F, 0xC64B, 0x9B22, 0xC64C, 0x9B58,\r\n\t0xC64D, 0x9C5F, 0xC64E, 0x9DF9, 0xC64F, 0x9DFA, 0xC650, 0x9E7C,\t0xC651, 0x9E7D, 0xC652, 0x9F07, 0xC653, 0x9F77, 0xC654, 0x9F72,\r\n\t0xC655, 0x5EF3, 0xC656, 0x6B16, 0xC657, 0x7063, 0xC658, 0x7C6C,\t0xC659, 0x7C6E, 0xC65A, 0x883B, 0xC65B, 0x89C0, 0xC65C, 0x8EA1,\r\n\t0xC65D, 0x91C1, 0xC65E, 0x9472, 0xC65F, 0x9470, 0xC660, 0x9871,\t0xC661, 0x995E, 0xC662, 0x9AD6, 0xC663, 0x9B23, 0xC664, 0x9ECC,\r\n\t0xC665, 0x7064, 0xC666, 0x77DA, 0xC667, 0x8B9A, 0xC668, 0x9477,\t0xC669, 0x97C9, 0xC66A, 0x9A62, 0xC66B, 0x9A65, 0xC66C, 0x7E9C,\r\n\t0xC66D, 0x8B9C, 0xC66E, 0x8EAA, 0xC66F, 0x91C5, 0xC670, 0x947D,\t0xC671, 0x947E, 0xC672, 0x947C, 0xC673, 0x9C77, 0xC674, 0x9C78,\r\n\t0xC675, 0x9EF7, 0xC676, 0x8C54, 0xC677, 0x947F, 0xC678, 0x9E1A,\t0xC679, 0x7228, 0xC67A, 0x9A6A, 0xC67B, 0x9B31, 0xC67C, 0x9E1B,\r\n\t0xC67D, 0x9E1E, 0xC67E, 0x7C72, 0xC940, 0x4E42, 0xC941, 0x4E5C,\t0xC942, 0x51F5, 0xC943, 0x531A, 0xC944, 0x5382, 0xC945, 0x4E07,\r\n\t0xC946, 0x4E0C, 0xC947, 0x4E47, 0xC948, 0x4E8D, 0xC949, 0x56D7,\t0xC94A, 0xFA0C, 0xC94B, 0x5C6E, 0xC94C, 0x5F73, 0xC94D, 0x4E0F,\r\n\t0xC94E, 0x5187, 0xC94F, 0x4E0E, 0xC950, 0x4E2E, 0xC951, 0x4E93,\t0xC952, 0x4EC2, 0xC953, 0x4EC9, 0xC954, 0x4EC8, 0xC955, 0x5198,\r\n\t0xC956, 0x52FC, 0xC957, 0x536C, 0xC958, 0x53B9, 0xC959, 0x5720,\t0xC95A, 0x5903, 0xC95B, 0x592C, 0xC95C, 0x5C10, 0xC95D, 0x5DFF,\r\n\t0xC95E, 0x65E1, 0xC95F, 0x6BB3, 0xC960, 0x6BCC, 0xC961, 0x6C14,\t0xC962, 0x723F, 0xC963, 0x4E31, 0xC964, 0x4E3C, 0xC965, 0x4EE8,\r\n\t0xC966, 0x4EDC, 0xC967, 0x4EE9, 0xC968, 0x4EE1, 0xC969, 0x4EDD,\t0xC96A, 0x4EDA, 0xC96B, 0x520C, 0xC96C, 0x531C, 0xC96D, 0x534C,\r\n\t0xC96E, 0x5722, 0xC96F, 0x5723, 0xC970, 0x5917, 0xC971, 0x592F,\t0xC972, 0x5B81, 0xC973, 0x5B84, 0xC974, 0x5C12, 0xC975, 0x5C3B,\r\n\t0xC976, 0x5C74, 0xC977, 0x5C73, 0xC978, 0x5E04, 0xC979, 0x5E80,\t0xC97A, 0x5E82, 0xC97B, 0x5FC9, 0xC97C, 0x6209, 0xC97D, 0x6250,\r\n\t0xC97E, 0x6C15, 0xC9A1, 0x6C36, 0xC9A2, 0x6C43, 0xC9A3, 0x6C3F,\t0xC9A4, 0x6C3B, 0xC9A5, 0x72AE, 0xC9A6, 0x72B0, 0xC9A7, 0x738A,\r\n\t0xC9A8, 0x79B8, 0xC9A9, 0x808A, 0xC9AA, 0x961E, 0xC9AB, 0x4F0E,\t0xC9AC, 0x4F18, 0xC9AD, 0x4F2C, 0xC9AE, 0x4EF5, 0xC9AF, 0x4F14,\r\n\t0xC9B0, 0x4EF1, 0xC9B1, 0x4F00, 0xC9B2, 0x4EF7, 0xC9B3, 0x4F08,\t0xC9B4, 0x4F1D, 0xC9B5, 0x4F02, 0xC9B6, 0x4F05, 0xC9B7, 0x4F22,\r\n\t0xC9B8, 0x4F13, 0xC9B9, 0x4F04, 0xC9BA, 0x4EF4, 0xC9BB, 0x4F12,\t0xC9BC, 0x51B1, 0xC9BD, 0x5213, 0xC9BE, 0x5209, 0xC9BF, 0x5210,\r\n\t0xC9C0, 0x52A6, 0xC9C1, 0x5322, 0xC9C2, 0x531F, 0xC9C3, 0x534D,\t0xC9C4, 0x538A, 0xC9C5, 0x5407, 0xC9C6, 0x56E1, 0xC9C7, 0x56DF,\r\n\t0xC9C8, 0x572E, 0xC9C9, 0x572A, 0xC9CA, 0x5734, 0xC9CB, 0x593C,\t0xC9CC, 0x5980, 0xC9CD, 0x597C, 0xC9CE, 0x5985, 0xC9CF, 0x597B,\r\n\t0xC9D0, 0x597E, 0xC9D1, 0x5977, 0xC9D2, 0x597F, 0xC9D3, 0x5B56,\t0xC9D4, 0x5C15, 0xC9D5, 0x5C25, 0xC9D6, 0x5C7C, 0xC9D7, 0x5C7A,\r\n\t0xC9D8, 0x5C7B, 0xC9D9, 0x5C7E, 0xC9DA, 0x5DDF, 0xC9DB, 0x5E75,\t0xC9DC, 0x5E84, 0xC9DD, 0x5F02, 0xC9DE, 0x5F1A, 0xC9DF, 0x5F74,\r\n\t0xC9E0, 0x5FD5, 0xC9E1, 0x5FD4, 0xC9E2, 0x5FCF, 0xC9E3, 0x625C,\t0xC9E4, 0x625E, 0xC9E5, 0x6264, 0xC9E6, 0x6261, 0xC9E7, 0x6266,\r\n\t0xC9E8, 0x6262, 0xC9E9, 0x6259, 0xC9EA, 0x6260, 0xC9EB, 0x625A,\t0xC9EC, 0x6265, 0xC9ED, 0x65EF, 0xC9EE, 0x65EE, 0xC9EF, 0x673E,\r\n\t0xC9F0, 0x6739, 0xC9F1, 0x6738, 0xC9F2, 0x673B, 0xC9F3, 0x673A,\t0xC9F4, 0x673F, 0xC9F5, 0x673C, 0xC9F6, 0x6733, 0xC9F7, 0x6C18,\r\n\t0xC9F8, 0x6C46, 0xC9F9, 0x6C52, 0xC9FA, 0x6C5C, 0xC9FB, 0x6C4F,\t0xC9FC, 0x6C4A, 0xC9FD, 0x6C54, 0xC9FE, 0x6C4B, 0xCA40, 0x6C4C,\r\n\t0xCA41, 0x7071, 0xCA42, 0x725E, 0xCA43, 0x72B4, 0xCA44, 0x72B5,\t0xCA45, 0x738E, 0xCA46, 0x752A, 0xCA47, 0x767F, 0xCA48, 0x7A75,\r\n\t0xCA49, 0x7F51, 0xCA4A, 0x8278, 0xCA4B, 0x827C, 0xCA4C, 0x8280,\t0xCA4D, 0x827D, 0xCA4E, 0x827F, 0xCA4F, 0x864D, 0xCA50, 0x897E,\r\n\t0xCA51, 0x9099, 0xCA52, 0x9097, 0xCA53, 0x9098, 0xCA54, 0x909B,\t0xCA55, 0x9094, 0xCA56, 0x9622, 0xCA57, 0x9624, 0xCA58, 0x9620,\r\n\t0xCA59, 0x9623, 0xCA5A, 0x4F56, 0xCA5B, 0x4F3B, 0xCA5C, 0x4F62,\t0xCA5D, 0x4F49, 0xCA5E, 0x4F53, 0xCA5F, 0x4F64, 0xCA60, 0x4F3E,\r\n\t0xCA61, 0x4F67, 0xCA62, 0x4F52, 0xCA63, 0x4F5F, 0xCA64, 0x4F41,\t0xCA65, 0x4F58, 0xCA66, 0x4F2D, 0xCA67, 0x4F33, 0xCA68, 0x4F3F,\r\n\t0xCA69, 0x4F61, 0xCA6A, 0x518F, 0xCA6B, 0x51B9, 0xCA6C, 0x521C,\t0xCA6D, 0x521E, 0xCA6E, 0x5221, 0xCA6F, 0x52AD, 0xCA70, 0x52AE,\r\n\t0xCA71, 0x5309, 0xCA72, 0x5363, 0xCA73, 0x5372, 0xCA74, 0x538E,\t0xCA75, 0x538F, 0xCA76, 0x5430, 0xCA77, 0x5437, 0xCA78, 0x542A,\r\n\t0xCA79, 0x5454, 0xCA7A, 0x5445, 0xCA7B, 0x5419, 0xCA7C, 0x541C,\t0xCA7D, 0x5425, 0xCA7E, 0x5418, 0xCAA1, 0x543D, 0xCAA2, 0x544F,\r\n\t0xCAA3, 0x5441, 0xCAA4, 0x5428, 0xCAA5, 0x5424, 0xCAA6, 0x5447,\t0xCAA7, 0x56EE, 0xCAA8, 0x56E7, 0xCAA9, 0x56E5, 0xCAAA, 0x5741,\r\n\t0xCAAB, 0x5745, 0xCAAC, 0x574C, 0xCAAD, 0x5749, 0xCAAE, 0x574B,\t0xCAAF, 0x5752, 0xCAB0, 0x5906, 0xCAB1, 0x5940, 0xCAB2, 0x59A6,\r\n\t0xCAB3, 0x5998, 0xCAB4, 0x59A0, 0xCAB5, 0x5997, 0xCAB6, 0x598E,\t0xCAB7, 0x59A2, 0xCAB8, 0x5990, 0xCAB9, 0x598F, 0xCABA, 0x59A7,\r\n\t0xCABB, 0x59A1, 0xCABC, 0x5B8E, 0xCABD, 0x5B92, 0xCABE, 0x5C28,\t0xCABF, 0x5C2A, 0xCAC0, 0x5C8D, 0xCAC1, 0x5C8F, 0xCAC2, 0x5C88,\r\n\t0xCAC3, 0x5C8B, 0xCAC4, 0x5C89, 0xCAC5, 0x5C92, 0xCAC6, 0x5C8A,\t0xCAC7, 0x5C86, 0xCAC8, 0x5C93, 0xCAC9, 0x5C95, 0xCACA, 0x5DE0,\r\n\t0xCACB, 0x5E0A, 0xCACC, 0x5E0E, 0xCACD, 0x5E8B, 0xCACE, 0x5E89,\t0xCACF, 0x5E8C, 0xCAD0, 0x5E88, 0xCAD1, 0x5E8D, 0xCAD2, 0x5F05,\r\n\t0xCAD3, 0x5F1D, 0xCAD4, 0x5F78, 0xCAD5, 0x5F76, 0xCAD6, 0x5FD2,\t0xCAD7, 0x5FD1, 0xCAD8, 0x5FD0, 0xCAD9, 0x5FED, 0xCADA, 0x5FE8,\r\n\t0xCADB, 0x5FEE, 0xCADC, 0x5FF3, 0xCADD, 0x5FE1, 0xCADE, 0x5FE4,\t0xCADF, 0x5FE3, 0xCAE0, 0x5FFA, 0xCAE1, 0x5FEF, 0xCAE2, 0x5FF7,\r\n\t0xCAE3, 0x5FFB, 0xCAE4, 0x6000, 0xCAE5, 0x5FF4, 0xCAE6, 0x623A,\t0xCAE7, 0x6283, 0xCAE8, 0x628C, 0xCAE9, 0x628E, 0xCAEA, 0x628F,\r\n\t0xCAEB, 0x6294, 0xCAEC, 0x6287, 0xCAED, 0x6271, 0xCAEE, 0x627B,\t0xCAEF, 0x627A, 0xCAF0, 0x6270, 0xCAF1, 0x6281, 0xCAF2, 0x6288,\r\n\t0xCAF3, 0x6277, 0xCAF4, 0x627D, 0xCAF5, 0x6272, 0xCAF6, 0x6274,\t0xCAF7, 0x6537, 0xCAF8, 0x65F0, 0xCAF9, 0x65F4, 0xCAFA, 0x65F3,\r\n\t0xCAFB, 0x65F2, 0xCAFC, 0x65F5, 0xCAFD, 0x6745, 0xCAFE, 0x6747,\t0xCB40, 0x6759, 0xCB41, 0x6755, 0xCB42, 0x674C, 0xCB43, 0x6748,\r\n\t0xCB44, 0x675D, 0xCB45, 0x674D, 0xCB46, 0x675A, 0xCB47, 0x674B,\t0xCB48, 0x6BD0, 0xCB49, 0x6C19, 0xCB4A, 0x6C1A, 0xCB4B, 0x6C78,\r\n\t0xCB4C, 0x6C67, 0xCB4D, 0x6C6B, 0xCB4E, 0x6C84, 0xCB4F, 0x6C8B,\t0xCB50, 0x6C8F, 0xCB51, 0x6C71, 0xCB52, 0x6C6F, 0xCB53, 0x6C69,\r\n\t0xCB54, 0x6C9A, 0xCB55, 0x6C6D, 0xCB56, 0x6C87, 0xCB57, 0x6C95,\t0xCB58, 0x6C9C, 0xCB59, 0x6C66, 0xCB5A, 0x6C73, 0xCB5B, 0x6C65,\r\n\t0xCB5C, 0x6C7B, 0xCB5D, 0x6C8E, 0xCB5E, 0x7074, 0xCB5F, 0x707A,\t0xCB60, 0x7263, 0xCB61, 0x72BF, 0xCB62, 0x72BD, 0xCB63, 0x72C3,\r\n\t0xCB64, 0x72C6, 0xCB65, 0x72C1, 0xCB66, 0x72BA, 0xCB67, 0x72C5,\t0xCB68, 0x7395, 0xCB69, 0x7397, 0xCB6A, 0x7393, 0xCB6B, 0x7394,\r\n\t0xCB6C, 0x7392, 0xCB6D, 0x753A, 0xCB6E, 0x7539, 0xCB6F, 0x7594,\t0xCB70, 0x7595, 0xCB71, 0x7681, 0xCB72, 0x793D, 0xCB73, 0x8034,\r\n\t0xCB74, 0x8095, 0xCB75, 0x8099, 0xCB76, 0x8090, 0xCB77, 0x8092,\t0xCB78, 0x809C, 0xCB79, 0x8290, 0xCB7A, 0x828F, 0xCB7B, 0x8285,\r\n\t0xCB7C, 0x828E, 0xCB7D, 0x8291, 0xCB7E, 0x8293, 0xCBA1, 0x828A,\t0xCBA2, 0x8283, 0xCBA3, 0x8284, 0xCBA4, 0x8C78, 0xCBA5, 0x8FC9,\r\n\t0xCBA6, 0x8FBF, 0xCBA7, 0x909F, 0xCBA8, 0x90A1, 0xCBA9, 0x90A5,\t0xCBAA, 0x909E, 0xCBAB, 0x90A7, 0xCBAC, 0x90A0, 0xCBAD, 0x9630,\r\n\t0xCBAE, 0x9628, 0xCBAF, 0x962F, 0xCBB0, 0x962D, 0xCBB1, 0x4E33,\t0xCBB2, 0x4F98, 0xCBB3, 0x4F7C, 0xCBB4, 0x4F85, 0xCBB5, 0x4F7D,\r\n\t0xCBB6, 0x4F80, 0xCBB7, 0x4F87, 0xCBB8, 0x4F76, 0xCBB9, 0x4F74,\t0xCBBA, 0x4F89, 0xCBBB, 0x4F84, 0xCBBC, 0x4F77, 0xCBBD, 0x4F4C,\r\n\t0xCBBE, 0x4F97, 0xCBBF, 0x4F6A, 0xCBC0, 0x4F9A, 0xCBC1, 0x4F79,\t0xCBC2, 0x4F81, 0xCBC3, 0x4F78, 0xCBC4, 0x4F90, 0xCBC5, 0x4F9C,\r\n\t0xCBC6, 0x4F94, 0xCBC7, 0x4F9E, 0xCBC8, 0x4F92, 0xCBC9, 0x4F82,\t0xCBCA, 0x4F95, 0xCBCB, 0x4F6B, 0xCBCC, 0x4F6E, 0xCBCD, 0x519E,\r\n\t0xCBCE, 0x51BC, 0xCBCF, 0x51BE, 0xCBD0, 0x5235, 0xCBD1, 0x5232,\t0xCBD2, 0x5233, 0xCBD3, 0x5246, 0xCBD4, 0x5231, 0xCBD5, 0x52BC,\r\n\t0xCBD6, 0x530A, 0xCBD7, 0x530B, 0xCBD8, 0x533C, 0xCBD9, 0x5392,\t0xCBDA, 0x5394, 0xCBDB, 0x5487, 0xCBDC, 0x547F, 0xCBDD, 0x5481,\r\n\t0xCBDE, 0x5491, 0xCBDF, 0x5482, 0xCBE0, 0x5488, 0xCBE1, 0x546B,\t0xCBE2, 0x547A, 0xCBE3, 0x547E, 0xCBE4, 0x5465, 0xCBE5, 0x546C,\r\n\t0xCBE6, 0x5474, 0xCBE7, 0x5466, 0xCBE8, 0x548D, 0xCBE9, 0x546F,\t0xCBEA, 0x5461, 0xCBEB, 0x5460, 0xCBEC, 0x5498, 0xCBED, 0x5463,\r\n\t0xCBEE, 0x5467, 0xCBEF, 0x5464, 0xCBF0, 0x56F7, 0xCBF1, 0x56F9,\t0xCBF2, 0x576F, 0xCBF3, 0x5772, 0xCBF4, 0x576D, 0xCBF5, 0x576B,\r\n\t0xCBF6, 0x5771, 0xCBF7, 0x5770, 0xCBF8, 0x5776, 0xCBF9, 0x5780,\t0xCBFA, 0x5775, 0xCBFB, 0x577B, 0xCBFC, 0x5773, 0xCBFD, 0x5774,\r\n\t0xCBFE, 0x5762, 0xCC40, 0x5768, 0xCC41, 0x577D, 0xCC42, 0x590C,\t0xCC43, 0x5945, 0xCC44, 0x59B5, 0xCC45, 0x59BA, 0xCC46, 0x59CF,\r\n\t0xCC47, 0x59CE, 0xCC48, 0x59B2, 0xCC49, 0x59CC, 0xCC4A, 0x59C1,\t0xCC4B, 0x59B6, 0xCC4C, 0x59BC, 0xCC4D, 0x59C3, 0xCC4E, 0x59D6,\r\n\t0xCC4F, 0x59B1, 0xCC50, 0x59BD, 0xCC51, 0x59C0, 0xCC52, 0x59C8,\t0xCC53, 0x59B4, 0xCC54, 0x59C7, 0xCC55, 0x5B62, 0xCC56, 0x5B65,\r\n\t0xCC57, 0x5B93, 0xCC58, 0x5B95, 0xCC59, 0x5C44, 0xCC5A, 0x5C47,\t0xCC5B, 0x5CAE, 0xCC5C, 0x5CA4, 0xCC5D, 0x5CA0, 0xCC5E, 0x5CB5,\r\n\t0xCC5F, 0x5CAF, 0xCC60, 0x5CA8, 0xCC61, 0x5CAC, 0xCC62, 0x5C9F,\t0xCC63, 0x5CA3, 0xCC64, 0x5CAD, 0xCC65, 0x5CA2, 0xCC66, 0x5CAA,\r\n\t0xCC67, 0x5CA7, 0xCC68, 0x5C9D, 0xCC69, 0x5CA5, 0xCC6A, 0x5CB6,\t0xCC6B, 0x5CB0, 0xCC6C, 0x5CA6, 0xCC6D, 0x5E17, 0xCC6E, 0x5E14,\r\n\t0xCC6F, 0x5E19, 0xCC70, 0x5F28, 0xCC71, 0x5F22, 0xCC72, 0x5F23,\t0xCC73, 0x5F24, 0xCC74, 0x5F54, 0xCC75, 0x5F82, 0xCC76, 0x5F7E,\r\n\t0xCC77, 0x5F7D, 0xCC78, 0x5FDE, 0xCC79, 0x5FE5, 0xCC7A, 0x602D,\t0xCC7B, 0x6026, 0xCC7C, 0x6019, 0xCC7D, 0x6032, 0xCC7E, 0x600B,\r\n\t0xCCA1, 0x6034, 0xCCA2, 0x600A, 0xCCA3, 0x6017, 0xCCA4, 0x6033,\t0xCCA5, 0x601A, 0xCCA6, 0x601E, 0xCCA7, 0x602C, 0xCCA8, 0x6022,\r\n\t0xCCA9, 0x600D, 0xCCAA, 0x6010, 0xCCAB, 0x602E, 0xCCAC, 0x6013,\t0xCCAD, 0x6011, 0xCCAE, 0x600C, 0xCCAF, 0x6009, 0xCCB0, 0x601C,\r\n\t0xCCB1, 0x6214, 0xCCB2, 0x623D, 0xCCB3, 0x62AD, 0xCCB4, 0x62B4,\t0xCCB5, 0x62D1, 0xCCB6, 0x62BE, 0xCCB7, 0x62AA, 0xCCB8, 0x62B6,\r\n\t0xCCB9, 0x62CA, 0xCCBA, 0x62AE, 0xCCBB, 0x62B3, 0xCCBC, 0x62AF,\t0xCCBD, 0x62BB, 0xCCBE, 0x62A9, 0xCCBF, 0x62B0, 0xCCC0, 0x62B8,\r\n\t0xCCC1, 0x653D, 0xCCC2, 0x65A8, 0xCCC3, 0x65BB, 0xCCC4, 0x6609,\t0xCCC5, 0x65FC, 0xCCC6, 0x6604, 0xCCC7, 0x6612, 0xCCC8, 0x6608,\r\n\t0xCCC9, 0x65FB, 0xCCCA, 0x6603, 0xCCCB, 0x660B, 0xCCCC, 0x660D,\t0xCCCD, 0x6605, 0xCCCE, 0x65FD, 0xCCCF, 0x6611, 0xCCD0, 0x6610,\r\n\t0xCCD1, 0x66F6, 0xCCD2, 0x670A, 0xCCD3, 0x6785, 0xCCD4, 0x676C,\t0xCCD5, 0x678E, 0xCCD6, 0x6792, 0xCCD7, 0x6776, 0xCCD8, 0x677B,\r\n\t0xCCD9, 0x6798, 0xCCDA, 0x6786, 0xCCDB, 0x6784, 0xCCDC, 0x6774,\t0xCCDD, 0x678D, 0xCCDE, 0x678C, 0xCCDF, 0x677A, 0xCCE0, 0x679F,\r\n\t0xCCE1, 0x6791, 0xCCE2, 0x6799, 0xCCE3, 0x6783, 0xCCE4, 0x677D,\t0xCCE5, 0x6781, 0xCCE6, 0x6778, 0xCCE7, 0x6779, 0xCCE8, 0x6794,\r\n\t0xCCE9, 0x6B25, 0xCCEA, 0x6B80, 0xCCEB, 0x6B7E, 0xCCEC, 0x6BDE,\t0xCCED, 0x6C1D, 0xCCEE, 0x6C93, 0xCCEF, 0x6CEC, 0xCCF0, 0x6CEB,\r\n\t0xCCF1, 0x6CEE, 0xCCF2, 0x6CD9, 0xCCF3, 0x6CB6, 0xCCF4, 0x6CD4,\t0xCCF5, 0x6CAD, 0xCCF6, 0x6CE7, 0xCCF7, 0x6CB7, 0xCCF8, 0x6CD0,\r\n\t0xCCF9, 0x6CC2, 0xCCFA, 0x6CBA, 0xCCFB, 0x6CC3, 0xCCFC, 0x6CC6,\t0xCCFD, 0x6CED, 0xCCFE, 0x6CF2, 0xCD40, 0x6CD2, 0xCD41, 0x6CDD,\r\n\t0xCD42, 0x6CB4, 0xCD43, 0x6C8A, 0xCD44, 0x6C9D, 0xCD45, 0x6C80,\t0xCD46, 0x6CDE, 0xCD47, 0x6CC0, 0xCD48, 0x6D30, 0xCD49, 0x6CCD,\r\n\t0xCD4A, 0x6CC7, 0xCD4B, 0x6CB0, 0xCD4C, 0x6CF9, 0xCD4D, 0x6CCF,\t0xCD4E, 0x6CE9, 0xCD4F, 0x6CD1, 0xCD50, 0x7094, 0xCD51, 0x7098,\r\n\t0xCD52, 0x7085, 0xCD53, 0x7093, 0xCD54, 0x7086, 0xCD55, 0x7084,\t0xCD56, 0x7091, 0xCD57, 0x7096, 0xCD58, 0x7082, 0xCD59, 0x709A,\r\n\t0xCD5A, 0x7083, 0xCD5B, 0x726A, 0xCD5C, 0x72D6, 0xCD5D, 0x72CB,\t0xCD5E, 0x72D8, 0xCD5F, 0x72C9, 0xCD60, 0x72DC, 0xCD61, 0x72D2,\r\n\t0xCD62, 0x72D4, 0xCD63, 0x72DA, 0xCD64, 0x72CC, 0xCD65, 0x72D1,\t0xCD66, 0x73A4, 0xCD67, 0x73A1, 0xCD68, 0x73AD, 0xCD69, 0x73A6,\r\n\t0xCD6A, 0x73A2, 0xCD6B, 0x73A0, 0xCD6C, 0x73AC, 0xCD6D, 0x739D,\t0xCD6E, 0x74DD, 0xCD6F, 0x74E8, 0xCD70, 0x753F, 0xCD71, 0x7540,\r\n\t0xCD72, 0x753E, 0xCD73, 0x758C, 0xCD74, 0x7598, 0xCD75, 0x76AF,\t0xCD76, 0x76F3, 0xCD77, 0x76F1, 0xCD78, 0x76F0, 0xCD79, 0x76F5,\r\n\t0xCD7A, 0x77F8, 0xCD7B, 0x77FC, 0xCD7C, 0x77F9, 0xCD7D, 0x77FB,\t0xCD7E, 0x77FA, 0xCDA1, 0x77F7, 0xCDA2, 0x7942, 0xCDA3, 0x793F,\r\n\t0xCDA4, 0x79C5, 0xCDA5, 0x7A78, 0xCDA6, 0x7A7B, 0xCDA7, 0x7AFB,\t0xCDA8, 0x7C75, 0xCDA9, 0x7CFD, 0xCDAA, 0x8035, 0xCDAB, 0x808F,\r\n\t0xCDAC, 0x80AE, 0xCDAD, 0x80A3, 0xCDAE, 0x80B8, 0xCDAF, 0x80B5,\t0xCDB0, 0x80AD, 0xCDB1, 0x8220, 0xCDB2, 0x82A0, 0xCDB3, 0x82C0,\r\n\t0xCDB4, 0x82AB, 0xCDB5, 0x829A, 0xCDB6, 0x8298, 0xCDB7, 0x829B,\t0xCDB8, 0x82B5, 0xCDB9, 0x82A7, 0xCDBA, 0x82AE, 0xCDBB, 0x82BC,\r\n\t0xCDBC, 0x829E, 0xCDBD, 0x82BA, 0xCDBE, 0x82B4, 0xCDBF, 0x82A8,\t0xCDC0, 0x82A1, 0xCDC1, 0x82A9, 0xCDC2, 0x82C2, 0xCDC3, 0x82A4,\r\n\t0xCDC4, 0x82C3, 0xCDC5, 0x82B6, 0xCDC6, 0x82A2, 0xCDC7, 0x8670,\t0xCDC8, 0x866F, 0xCDC9, 0x866D, 0xCDCA, 0x866E, 0xCDCB, 0x8C56,\r\n\t0xCDCC, 0x8FD2, 0xCDCD, 0x8FCB, 0xCDCE, 0x8FD3, 0xCDCF, 0x8FCD,\t0xCDD0, 0x8FD6, 0xCDD1, 0x8FD5, 0xCDD2, 0x8FD7, 0xCDD3, 0x90B2,\r\n\t0xCDD4, 0x90B4, 0xCDD5, 0x90AF, 0xCDD6, 0x90B3, 0xCDD7, 0x90B0,\t0xCDD8, 0x9639, 0xCDD9, 0x963D, 0xCDDA, 0x963C, 0xCDDB, 0x963A,\r\n\t0xCDDC, 0x9643, 0xCDDD, 0x4FCD, 0xCDDE, 0x4FC5, 0xCDDF, 0x4FD3,\t0xCDE0, 0x4FB2, 0xCDE1, 0x4FC9, 0xCDE2, 0x4FCB, 0xCDE3, 0x4FC1,\r\n\t0xCDE4, 0x4FD4, 0xCDE5, 0x4FDC, 0xCDE6, 0x4FD9, 0xCDE7, 0x4FBB,\t0xCDE8, 0x4FB3, 0xCDE9, 0x4FDB, 0xCDEA, 0x4FC7, 0xCDEB, 0x4FD6,\r\n\t0xCDEC, 0x4FBA, 0xCDED, 0x4FC0, 0xCDEE, 0x4FB9, 0xCDEF, 0x4FEC,\t0xCDF0, 0x5244, 0xCDF1, 0x5249, 0xCDF2, 0x52C0, 0xCDF3, 0x52C2,\r\n\t0xCDF4, 0x533D, 0xCDF5, 0x537C, 0xCDF6, 0x5397, 0xCDF7, 0x5396,\t0xCDF8, 0x5399, 0xCDF9, 0x5398, 0xCDFA, 0x54BA, 0xCDFB, 0x54A1,\r\n\t0xCDFC, 0x54AD, 0xCDFD, 0x54A5, 0xCDFE, 0x54CF, 0xCE40, 0x54C3,\t0xCE41, 0x830D, 0xCE42, 0x54B7, 0xCE43, 0x54AE, 0xCE44, 0x54D6,\r\n\t0xCE45, 0x54B6, 0xCE46, 0x54C5, 0xCE47, 0x54C6, 0xCE48, 0x54A0,\t0xCE49, 0x5470, 0xCE4A, 0x54BC, 0xCE4B, 0x54A2, 0xCE4C, 0x54BE,\r\n\t0xCE4D, 0x5472, 0xCE4E, 0x54DE, 0xCE4F, 0x54B0, 0xCE50, 0x57B5,\t0xCE51, 0x579E, 0xCE52, 0x579F, 0xCE53, 0x57A4, 0xCE54, 0x578C,\r\n\t0xCE55, 0x5797, 0xCE56, 0x579D, 0xCE57, 0x579B, 0xCE58, 0x5794,\t0xCE59, 0x5798, 0xCE5A, 0x578F, 0xCE5B, 0x5799, 0xCE5C, 0x57A5,\r\n\t0xCE5D, 0x579A, 0xCE5E, 0x5795, 0xCE5F, 0x58F4, 0xCE60, 0x590D,\t0xCE61, 0x5953, 0xCE62, 0x59E1, 0xCE63, 0x59DE, 0xCE64, 0x59EE,\r\n\t0xCE65, 0x5A00, 0xCE66, 0x59F1, 0xCE67, 0x59DD, 0xCE68, 0x59FA,\t0xCE69, 0x59FD, 0xCE6A, 0x59FC, 0xCE6B, 0x59F6, 0xCE6C, 0x59E4,\r\n\t0xCE6D, 0x59F2, 0xCE6E, 0x59F7, 0xCE6F, 0x59DB, 0xCE70, 0x59E9,\t0xCE71, 0x59F3, 0xCE72, 0x59F5, 0xCE73, 0x59E0, 0xCE74, 0x59FE,\r\n\t0xCE75, 0x59F4, 0xCE76, 0x59ED, 0xCE77, 0x5BA8, 0xCE78, 0x5C4C,\t0xCE79, 0x5CD0, 0xCE7A, 0x5CD8, 0xCE7B, 0x5CCC, 0xCE7C, 0x5CD7,\r\n\t0xCE7D, 0x5CCB, 0xCE7E, 0x5CDB, 0xCEA1, 0x5CDE, 0xCEA2, 0x5CDA,\t0xCEA3, 0x5CC9, 0xCEA4, 0x5CC7, 0xCEA5, 0x5CCA, 0xCEA6, 0x5CD6,\r\n\t0xCEA7, 0x5CD3, 0xCEA8, 0x5CD4, 0xCEA9, 0x5CCF, 0xCEAA, 0x5CC8,\t0xCEAB, 0x5CC6, 0xCEAC, 0x5CCE, 0xCEAD, 0x5CDF, 0xCEAE, 0x5CF8,\r\n\t0xCEAF, 0x5DF9, 0xCEB0, 0x5E21, 0xCEB1, 0x5E22, 0xCEB2, 0x5E23,\t0xCEB3, 0x5E20, 0xCEB4, 0x5E24, 0xCEB5, 0x5EB0, 0xCEB6, 0x5EA4,\r\n\t0xCEB7, 0x5EA2, 0xCEB8, 0x5E9B, 0xCEB9, 0x5EA3, 0xCEBA, 0x5EA5,\t0xCEBB, 0x5F07, 0xCEBC, 0x5F2E, 0xCEBD, 0x5F56, 0xCEBE, 0x5F86,\r\n\t0xCEBF, 0x6037, 0xCEC0, 0x6039, 0xCEC1, 0x6054, 0xCEC2, 0x6072,\t0xCEC3, 0x605E, 0xCEC4, 0x6045, 0xCEC5, 0x6053, 0xCEC6, 0x6047,\r\n\t0xCEC7, 0x6049, 0xCEC8, 0x605B, 0xCEC9, 0x604C, 0xCECA, 0x6040,\t0xCECB, 0x6042, 0xCECC, 0x605F, 0xCECD, 0x6024, 0xCECE, 0x6044,\r\n\t0xCECF, 0x6058, 0xCED0, 0x6066, 0xCED1, 0x606E, 0xCED2, 0x6242,\t0xCED3, 0x6243, 0xCED4, 0x62CF, 0xCED5, 0x630D, 0xCED6, 0x630B,\r\n\t0xCED7, 0x62F5, 0xCED8, 0x630E, 0xCED9, 0x6303, 0xCEDA, 0x62EB,\t0xCEDB, 0x62F9, 0xCEDC, 0x630F, 0xCEDD, 0x630C, 0xCEDE, 0x62F8,\r\n\t0xCEDF, 0x62F6, 0xCEE0, 0x6300, 0xCEE1, 0x6313, 0xCEE2, 0x6314,\t0xCEE3, 0x62FA, 0xCEE4, 0x6315, 0xCEE5, 0x62FB, 0xCEE6, 0x62F0,\r\n\t0xCEE7, 0x6541, 0xCEE8, 0x6543, 0xCEE9, 0x65AA, 0xCEEA, 0x65BF,\t0xCEEB, 0x6636, 0xCEEC, 0x6621, 0xCEED, 0x6632, 0xCEEE, 0x6635,\r\n\t0xCEEF, 0x661C, 0xCEF0, 0x6626, 0xCEF1, 0x6622, 0xCEF2, 0x6633,\t0xCEF3, 0x662B, 0xCEF4, 0x663A, 0xCEF5, 0x661D, 0xCEF6, 0x6634,\r\n\t0xCEF7, 0x6639, 0xCEF8, 0x662E, 0xCEF9, 0x670F, 0xCEFA, 0x6710,\t0xCEFB, 0x67C1, 0xCEFC, 0x67F2, 0xCEFD, 0x67C8, 0xCEFE, 0x67BA,\r\n\t0xCF40, 0x67DC, 0xCF41, 0x67BB, 0xCF42, 0x67F8, 0xCF43, 0x67D8,\t0xCF44, 0x67C0, 0xCF45, 0x67B7, 0xCF46, 0x67C5, 0xCF47, 0x67EB,\r\n\t0xCF48, 0x67E4, 0xCF49, 0x67DF, 0xCF4A, 0x67B5, 0xCF4B, 0x67CD,\t0xCF4C, 0x67B3, 0xCF4D, 0x67F7, 0xCF4E, 0x67F6, 0xCF4F, 0x67EE,\r\n\t0xCF50, 0x67E3, 0xCF51, 0x67C2, 0xCF52, 0x67B9, 0xCF53, 0x67CE,\t0xCF54, 0x67E7, 0xCF55, 0x67F0, 0xCF56, 0x67B2, 0xCF57, 0x67FC,\r\n\t0xCF58, 0x67C6, 0xCF59, 0x67ED, 0xCF5A, 0x67CC, 0xCF5B, 0x67AE,\t0xCF5C, 0x67E6, 0xCF5D, 0x67DB, 0xCF5E, 0x67FA, 0xCF5F, 0x67C9,\r\n\t0xCF60, 0x67CA, 0xCF61, 0x67C3, 0xCF62, 0x67EA, 0xCF63, 0x67CB,\t0xCF64, 0x6B28, 0xCF65, 0x6B82, 0xCF66, 0x6B84, 0xCF67, 0x6BB6,\r\n\t0xCF68, 0x6BD6, 0xCF69, 0x6BD8, 0xCF6A, 0x6BE0, 0xCF6B, 0x6C20,\t0xCF6C, 0x6C21, 0xCF6D, 0x6D28, 0xCF6E, 0x6D34, 0xCF6F, 0x6D2D,\r\n\t0xCF70, 0x6D1F, 0xCF71, 0x6D3C, 0xCF72, 0x6D3F, 0xCF73, 0x6D12,\t0xCF74, 0x6D0A, 0xCF75, 0x6CDA, 0xCF76, 0x6D33, 0xCF77, 0x6D04,\r\n\t0xCF78, 0x6D19, 0xCF79, 0x6D3A, 0xCF7A, 0x6D1A, 0xCF7B, 0x6D11,\t0xCF7C, 0x6D00, 0xCF7D, 0x6D1D, 0xCF7E, 0x6D42, 0xCFA1, 0x6D01,\r\n\t0xCFA2, 0x6D18, 0xCFA3, 0x6D37, 0xCFA4, 0x6D03, 0xCFA5, 0x6D0F,\t0xCFA6, 0x6D40, 0xCFA7, 0x6D07, 0xCFA8, 0x6D20, 0xCFA9, 0x6D2C,\r\n\t0xCFAA, 0x6D08, 0xCFAB, 0x6D22, 0xCFAC, 0x6D09, 0xCFAD, 0x6D10,\t0xCFAE, 0x70B7, 0xCFAF, 0x709F, 0xCFB0, 0x70BE, 0xCFB1, 0x70B1,\r\n\t0xCFB2, 0x70B0, 0xCFB3, 0x70A1, 0xCFB4, 0x70B4, 0xCFB5, 0x70B5,\t0xCFB6, 0x70A9, 0xCFB7, 0x7241, 0xCFB8, 0x7249, 0xCFB9, 0x724A,\r\n\t0xCFBA, 0x726C, 0xCFBB, 0x7270, 0xCFBC, 0x7273, 0xCFBD, 0x726E,\t0xCFBE, 0x72CA, 0xCFBF, 0x72E4, 0xCFC0, 0x72E8, 0xCFC1, 0x72EB,\r\n\t0xCFC2, 0x72DF, 0xCFC3, 0x72EA, 0xCFC4, 0x72E6, 0xCFC5, 0x72E3,\t0xCFC6, 0x7385, 0xCFC7, 0x73CC, 0xCFC8, 0x73C2, 0xCFC9, 0x73C8,\r\n\t0xCFCA, 0x73C5, 0xCFCB, 0x73B9, 0xCFCC, 0x73B6, 0xCFCD, 0x73B5,\t0xCFCE, 0x73B4, 0xCFCF, 0x73EB, 0xCFD0, 0x73BF, 0xCFD1, 0x73C7,\r\n\t0xCFD2, 0x73BE, 0xCFD3, 0x73C3, 0xCFD4, 0x73C6, 0xCFD5, 0x73B8,\t0xCFD6, 0x73CB, 0xCFD7, 0x74EC, 0xCFD8, 0x74EE, 0xCFD9, 0x752E,\r\n\t0xCFDA, 0x7547, 0xCFDB, 0x7548, 0xCFDC, 0x75A7, 0xCFDD, 0x75AA,\t0xCFDE, 0x7679, 0xCFDF, 0x76C4, 0xCFE0, 0x7708, 0xCFE1, 0x7703,\r\n\t0xCFE2, 0x7704, 0xCFE3, 0x7705, 0xCFE4, 0x770A, 0xCFE5, 0x76F7,\t0xCFE6, 0x76FB, 0xCFE7, 0x76FA, 0xCFE8, 0x77E7, 0xCFE9, 0x77E8,\r\n\t0xCFEA, 0x7806, 0xCFEB, 0x7811, 0xCFEC, 0x7812, 0xCFED, 0x7805,\t0xCFEE, 0x7810, 0xCFEF, 0x780F, 0xCFF0, 0x780E, 0xCFF1, 0x7809,\r\n\t0xCFF2, 0x7803, 0xCFF3, 0x7813, 0xCFF4, 0x794A, 0xCFF5, 0x794C,\t0xCFF6, 0x794B, 0xCFF7, 0x7945, 0xCFF8, 0x7944, 0xCFF9, 0x79D5,\r\n\t0xCFFA, 0x79CD, 0xCFFB, 0x79CF, 0xCFFC, 0x79D6, 0xCFFD, 0x79CE,\t0xCFFE, 0x7A80, 0xD040, 0x7A7E, 0xD041, 0x7AD1, 0xD042, 0x7B00,\r\n\t0xD043, 0x7B01, 0xD044, 0x7C7A, 0xD045, 0x7C78, 0xD046, 0x7C79,\t0xD047, 0x7C7F, 0xD048, 0x7C80, 0xD049, 0x7C81, 0xD04A, 0x7D03,\r\n\t0xD04B, 0x7D08, 0xD04C, 0x7D01, 0xD04D, 0x7F58, 0xD04E, 0x7F91,\t0xD04F, 0x7F8D, 0xD050, 0x7FBE, 0xD051, 0x8007, 0xD052, 0x800E,\r\n\t0xD053, 0x800F, 0xD054, 0x8014, 0xD055, 0x8037, 0xD056, 0x80D8,\t0xD057, 0x80C7, 0xD058, 0x80E0, 0xD059, 0x80D1, 0xD05A, 0x80C8,\r\n\t0xD05B, 0x80C2, 0xD05C, 0x80D0, 0xD05D, 0x80C5, 0xD05E, 0x80E3,\t0xD05F, 0x80D9, 0xD060, 0x80DC, 0xD061, 0x80CA, 0xD062, 0x80D5,\r\n\t0xD063, 0x80C9, 0xD064, 0x80CF, 0xD065, 0x80D7, 0xD066, 0x80E6,\t0xD067, 0x80CD, 0xD068, 0x81FF, 0xD069, 0x8221, 0xD06A, 0x8294,\r\n\t0xD06B, 0x82D9, 0xD06C, 0x82FE, 0xD06D, 0x82F9, 0xD06E, 0x8307,\t0xD06F, 0x82E8, 0xD070, 0x8300, 0xD071, 0x82D5, 0xD072, 0x833A,\r\n\t0xD073, 0x82EB, 0xD074, 0x82D6, 0xD075, 0x82F4, 0xD076, 0x82EC,\t0xD077, 0x82E1, 0xD078, 0x82F2, 0xD079, 0x82F5, 0xD07A, 0x830C,\r\n\t0xD07B, 0x82FB, 0xD07C, 0x82F6, 0xD07D, 0x82F0, 0xD07E, 0x82EA,\t0xD0A1, 0x82E4, 0xD0A2, 0x82E0, 0xD0A3, 0x82FA, 0xD0A4, 0x82F3,\r\n\t0xD0A5, 0x82ED, 0xD0A6, 0x8677, 0xD0A7, 0x8674, 0xD0A8, 0x867C,\t0xD0A9, 0x8673, 0xD0AA, 0x8841, 0xD0AB, 0x884E, 0xD0AC, 0x8867,\r\n\t0xD0AD, 0x886A, 0xD0AE, 0x8869, 0xD0AF, 0x89D3, 0xD0B0, 0x8A04,\t0xD0B1, 0x8A07, 0xD0B2, 0x8D72, 0xD0B3, 0x8FE3, 0xD0B4, 0x8FE1,\r\n\t0xD0B5, 0x8FEE, 0xD0B6, 0x8FE0, 0xD0B7, 0x90F1, 0xD0B8, 0x90BD,\t0xD0B9, 0x90BF, 0xD0BA, 0x90D5, 0xD0BB, 0x90C5, 0xD0BC, 0x90BE,\r\n\t0xD0BD, 0x90C7, 0xD0BE, 0x90CB, 0xD0BF, 0x90C8, 0xD0C0, 0x91D4,\t0xD0C1, 0x91D3, 0xD0C2, 0x9654, 0xD0C3, 0x964F, 0xD0C4, 0x9651,\r\n\t0xD0C5, 0x9653, 0xD0C6, 0x964A, 0xD0C7, 0x964E, 0xD0C8, 0x501E,\t0xD0C9, 0x5005, 0xD0CA, 0x5007, 0xD0CB, 0x5013, 0xD0CC, 0x5022,\r\n\t0xD0CD, 0x5030, 0xD0CE, 0x501B, 0xD0CF, 0x4FF5, 0xD0D0, 0x4FF4,\t0xD0D1, 0x5033, 0xD0D2, 0x5037, 0xD0D3, 0x502C, 0xD0D4, 0x4FF6,\r\n\t0xD0D5, 0x4FF7, 0xD0D6, 0x5017, 0xD0D7, 0x501C, 0xD0D8, 0x5020,\t0xD0D9, 0x5027, 0xD0DA, 0x5035, 0xD0DB, 0x502F, 0xD0DC, 0x5031,\r\n\t0xD0DD, 0x500E, 0xD0DE, 0x515A, 0xD0DF, 0x5194, 0xD0E0, 0x5193,\t0xD0E1, 0x51CA, 0xD0E2, 0x51C4, 0xD0E3, 0x51C5, 0xD0E4, 0x51C8,\r\n\t0xD0E5, 0x51CE, 0xD0E6, 0x5261, 0xD0E7, 0x525A, 0xD0E8, 0x5252,\t0xD0E9, 0x525E, 0xD0EA, 0x525F, 0xD0EB, 0x5255, 0xD0EC, 0x5262,\r\n\t0xD0ED, 0x52CD, 0xD0EE, 0x530E, 0xD0EF, 0x539E, 0xD0F0, 0x5526,\t0xD0F1, 0x54E2, 0xD0F2, 0x5517, 0xD0F3, 0x5512, 0xD0F4, 0x54E7,\r\n\t0xD0F5, 0x54F3, 0xD0F6, 0x54E4, 0xD0F7, 0x551A, 0xD0F8, 0x54FF,\t0xD0F9, 0x5504, 0xD0FA, 0x5508, 0xD0FB, 0x54EB, 0xD0FC, 0x5511,\r\n\t0xD0FD, 0x5505, 0xD0FE, 0x54F1, 0xD140, 0x550A, 0xD141, 0x54FB,\t0xD142, 0x54F7, 0xD143, 0x54F8, 0xD144, 0x54E0, 0xD145, 0x550E,\r\n\t0xD146, 0x5503, 0xD147, 0x550B, 0xD148, 0x5701, 0xD149, 0x5702,\t0xD14A, 0x57CC, 0xD14B, 0x5832, 0xD14C, 0x57D5, 0xD14D, 0x57D2,\r\n\t0xD14E, 0x57BA, 0xD14F, 0x57C6, 0xD150, 0x57BD, 0xD151, 0x57BC,\t0xD152, 0x57B8, 0xD153, 0x57B6, 0xD154, 0x57BF, 0xD155, 0x57C7,\r\n\t0xD156, 0x57D0, 0xD157, 0x57B9, 0xD158, 0x57C1, 0xD159, 0x590E,\t0xD15A, 0x594A, 0xD15B, 0x5A19, 0xD15C, 0x5A16, 0xD15D, 0x5A2D,\r\n\t0xD15E, 0x5A2E, 0xD15F, 0x5A15, 0xD160, 0x5A0F, 0xD161, 0x5A17,\t0xD162, 0x5A0A, 0xD163, 0x5A1E, 0xD164, 0x5A33, 0xD165, 0x5B6C,\r\n\t0xD166, 0x5BA7, 0xD167, 0x5BAD, 0xD168, 0x5BAC, 0xD169, 0x5C03,\t0xD16A, 0x5C56, 0xD16B, 0x5C54, 0xD16C, 0x5CEC, 0xD16D, 0x5CFF,\r\n\t0xD16E, 0x5CEE, 0xD16F, 0x5CF1, 0xD170, 0x5CF7, 0xD171, 0x5D00,\t0xD172, 0x5CF9, 0xD173, 0x5E29, 0xD174, 0x5E28, 0xD175, 0x5EA8,\r\n\t0xD176, 0x5EAE, 0xD177, 0x5EAA, 0xD178, 0x5EAC, 0xD179, 0x5F33,\t0xD17A, 0x5F30, 0xD17B, 0x5F67, 0xD17C, 0x605D, 0xD17D, 0x605A,\r\n\t0xD17E, 0x6067, 0xD1A1, 0x6041, 0xD1A2, 0x60A2, 0xD1A3, 0x6088,\t0xD1A4, 0x6080, 0xD1A5, 0x6092, 0xD1A6, 0x6081, 0xD1A7, 0x609D,\r\n\t0xD1A8, 0x6083, 0xD1A9, 0x6095, 0xD1AA, 0x609B, 0xD1AB, 0x6097,\t0xD1AC, 0x6087, 0xD1AD, 0x609C, 0xD1AE, 0x608E, 0xD1AF, 0x6219,\r\n\t0xD1B0, 0x6246, 0xD1B1, 0x62F2, 0xD1B2, 0x6310, 0xD1B3, 0x6356,\t0xD1B4, 0x632C, 0xD1B5, 0x6344, 0xD1B6, 0x6345, 0xD1B7, 0x6336,\r\n\t0xD1B8, 0x6343, 0xD1B9, 0x63E4, 0xD1BA, 0x6339, 0xD1BB, 0x634B,\t0xD1BC, 0x634A, 0xD1BD, 0x633C, 0xD1BE, 0x6329, 0xD1BF, 0x6341,\r\n\t0xD1C0, 0x6334, 0xD1C1, 0x6358, 0xD1C2, 0x6354, 0xD1C3, 0x6359,\t0xD1C4, 0x632D, 0xD1C5, 0x6347, 0xD1C6, 0x6333, 0xD1C7, 0x635A,\r\n\t0xD1C8, 0x6351, 0xD1C9, 0x6338, 0xD1CA, 0x6357, 0xD1CB, 0x6340,\t0xD1CC, 0x6348, 0xD1CD, 0x654A, 0xD1CE, 0x6546, 0xD1CF, 0x65C6,\r\n\t0xD1D0, 0x65C3, 0xD1D1, 0x65C4, 0xD1D2, 0x65C2, 0xD1D3, 0x664A,\t0xD1D4, 0x665F, 0xD1D5, 0x6647, 0xD1D6, 0x6651, 0xD1D7, 0x6712,\r\n\t0xD1D8, 0x6713, 0xD1D9, 0x681F, 0xD1DA, 0x681A, 0xD1DB, 0x6849,\t0xD1DC, 0x6832, 0xD1DD, 0x6833, 0xD1DE, 0x683B, 0xD1DF, 0x684B,\r\n\t0xD1E0, 0x684F, 0xD1E1, 0x6816, 0xD1E2, 0x6831, 0xD1E3, 0x681C,\t0xD1E4, 0x6835, 0xD1E5, 0x682B, 0xD1E6, 0x682D, 0xD1E7, 0x682F,\r\n\t0xD1E8, 0x684E, 0xD1E9, 0x6844, 0xD1EA, 0x6834, 0xD1EB, 0x681D,\t0xD1EC, 0x6812, 0xD1ED, 0x6814, 0xD1EE, 0x6826, 0xD1EF, 0x6828,\r\n\t0xD1F0, 0x682E, 0xD1F1, 0x684D, 0xD1F2, 0x683A, 0xD1F3, 0x6825,\t0xD1F4, 0x6820, 0xD1F5, 0x6B2C, 0xD1F6, 0x6B2F, 0xD1F7, 0x6B2D,\r\n\t0xD1F8, 0x6B31, 0xD1F9, 0x6B34, 0xD1FA, 0x6B6D, 0xD1FB, 0x8082,\t0xD1FC, 0x6B88, 0xD1FD, 0x6BE6, 0xD1FE, 0x6BE4, 0xD240, 0x6BE8,\r\n\t0xD241, 0x6BE3, 0xD242, 0x6BE2, 0xD243, 0x6BE7, 0xD244, 0x6C25,\t0xD245, 0x6D7A, 0xD246, 0x6D63, 0xD247, 0x6D64, 0xD248, 0x6D76,\r\n\t0xD249, 0x6D0D, 0xD24A, 0x6D61, 0xD24B, 0x6D92, 0xD24C, 0x6D58,\t0xD24D, 0x6D62, 0xD24E, 0x6D6D, 0xD24F, 0x6D6F, 0xD250, 0x6D91,\r\n\t0xD251, 0x6D8D, 0xD252, 0x6DEF, 0xD253, 0x6D7F, 0xD254, 0x6D86,\t0xD255, 0x6D5E, 0xD256, 0x6D67, 0xD257, 0x6D60, 0xD258, 0x6D97,\r\n\t0xD259, 0x6D70, 0xD25A, 0x6D7C, 0xD25B, 0x6D5F, 0xD25C, 0x6D82,\t0xD25D, 0x6D98, 0xD25E, 0x6D2F, 0xD25F, 0x6D68, 0xD260, 0x6D8B,\r\n\t0xD261, 0x6D7E, 0xD262, 0x6D80, 0xD263, 0x6D84, 0xD264, 0x6D16,\t0xD265, 0x6D83, 0xD266, 0x6D7B, 0xD267, 0x6D7D, 0xD268, 0x6D75,\r\n\t0xD269, 0x6D90, 0xD26A, 0x70DC, 0xD26B, 0x70D3, 0xD26C, 0x70D1,\t0xD26D, 0x70DD, 0xD26E, 0x70CB, 0xD26F, 0x7F39, 0xD270, 0x70E2,\r\n\t0xD271, 0x70D7, 0xD272, 0x70D2, 0xD273, 0x70DE, 0xD274, 0x70E0,\t0xD275, 0x70D4, 0xD276, 0x70CD, 0xD277, 0x70C5, 0xD278, 0x70C6,\r\n\t0xD279, 0x70C7, 0xD27A, 0x70DA, 0xD27B, 0x70CE, 0xD27C, 0x70E1,\t0xD27D, 0x7242, 0xD27E, 0x7278, 0xD2A1, 0x7277, 0xD2A2, 0x7276,\r\n\t0xD2A3, 0x7300, 0xD2A4, 0x72FA, 0xD2A5, 0x72F4, 0xD2A6, 0x72FE,\t0xD2A7, 0x72F6, 0xD2A8, 0x72F3, 0xD2A9, 0x72FB, 0xD2AA, 0x7301,\r\n\t0xD2AB, 0x73D3, 0xD2AC, 0x73D9, 0xD2AD, 0x73E5, 0xD2AE, 0x73D6,\t0xD2AF, 0x73BC, 0xD2B0, 0x73E7, 0xD2B1, 0x73E3, 0xD2B2, 0x73E9,\r\n\t0xD2B3, 0x73DC, 0xD2B4, 0x73D2, 0xD2B5, 0x73DB, 0xD2B6, 0x73D4,\t0xD2B7, 0x73DD, 0xD2B8, 0x73DA, 0xD2B9, 0x73D7, 0xD2BA, 0x73D8,\r\n\t0xD2BB, 0x73E8, 0xD2BC, 0x74DE, 0xD2BD, 0x74DF, 0xD2BE, 0x74F4,\t0xD2BF, 0x74F5, 0xD2C0, 0x7521, 0xD2C1, 0x755B, 0xD2C2, 0x755F,\r\n\t0xD2C3, 0x75B0, 0xD2C4, 0x75C1, 0xD2C5, 0x75BB, 0xD2C6, 0x75C4,\t0xD2C7, 0x75C0, 0xD2C8, 0x75BF, 0xD2C9, 0x75B6, 0xD2CA, 0x75BA,\r\n\t0xD2CB, 0x768A, 0xD2CC, 0x76C9, 0xD2CD, 0x771D, 0xD2CE, 0x771B,\t0xD2CF, 0x7710, 0xD2D0, 0x7713, 0xD2D1, 0x7712, 0xD2D2, 0x7723,\r\n\t0xD2D3, 0x7711, 0xD2D4, 0x7715, 0xD2D5, 0x7719, 0xD2D6, 0x771A,\t0xD2D7, 0x7722, 0xD2D8, 0x7727, 0xD2D9, 0x7823, 0xD2DA, 0x782C,\r\n\t0xD2DB, 0x7822, 0xD2DC, 0x7835, 0xD2DD, 0x782F, 0xD2DE, 0x7828,\t0xD2DF, 0x782E, 0xD2E0, 0x782B, 0xD2E1, 0x7821, 0xD2E2, 0x7829,\r\n\t0xD2E3, 0x7833, 0xD2E4, 0x782A, 0xD2E5, 0x7831, 0xD2E6, 0x7954,\t0xD2E7, 0x795B, 0xD2E8, 0x794F, 0xD2E9, 0x795C, 0xD2EA, 0x7953,\r\n\t0xD2EB, 0x7952, 0xD2EC, 0x7951, 0xD2ED, 0x79EB, 0xD2EE, 0x79EC,\t0xD2EF, 0x79E0, 0xD2F0, 0x79EE, 0xD2F1, 0x79ED, 0xD2F2, 0x79EA,\r\n\t0xD2F3, 0x79DC, 0xD2F4, 0x79DE, 0xD2F5, 0x79DD, 0xD2F6, 0x7A86,\t0xD2F7, 0x7A89, 0xD2F8, 0x7A85, 0xD2F9, 0x7A8B, 0xD2FA, 0x7A8C,\r\n\t0xD2FB, 0x7A8A, 0xD2FC, 0x7A87, 0xD2FD, 0x7AD8, 0xD2FE, 0x7B10,\t0xD340, 0x7B04, 0xD341, 0x7B13, 0xD342, 0x7B05, 0xD343, 0x7B0F,\r\n\t0xD344, 0x7B08, 0xD345, 0x7B0A, 0xD346, 0x7B0E, 0xD347, 0x7B09,\t0xD348, 0x7B12, 0xD349, 0x7C84, 0xD34A, 0x7C91, 0xD34B, 0x7C8A,\r\n\t0xD34C, 0x7C8C, 0xD34D, 0x7C88, 0xD34E, 0x7C8D, 0xD34F, 0x7C85,\t0xD350, 0x7D1E, 0xD351, 0x7D1D, 0xD352, 0x7D11, 0xD353, 0x7D0E,\r\n\t0xD354, 0x7D18, 0xD355, 0x7D16, 0xD356, 0x7D13, 0xD357, 0x7D1F,\t0xD358, 0x7D12, 0xD359, 0x7D0F, 0xD35A, 0x7D0C, 0xD35B, 0x7F5C,\r\n\t0xD35C, 0x7F61, 0xD35D, 0x7F5E, 0xD35E, 0x7F60, 0xD35F, 0x7F5D,\t0xD360, 0x7F5B, 0xD361, 0x7F96, 0xD362, 0x7F92, 0xD363, 0x7FC3,\r\n\t0xD364, 0x7FC2, 0xD365, 0x7FC0, 0xD366, 0x8016, 0xD367, 0x803E,\t0xD368, 0x8039, 0xD369, 0x80FA, 0xD36A, 0x80F2, 0xD36B, 0x80F9,\r\n\t0xD36C, 0x80F5, 0xD36D, 0x8101, 0xD36E, 0x80FB, 0xD36F, 0x8100,\t0xD370, 0x8201, 0xD371, 0x822F, 0xD372, 0x8225, 0xD373, 0x8333,\r\n\t0xD374, 0x832D, 0xD375, 0x8344, 0xD376, 0x8319, 0xD377, 0x8351,\t0xD378, 0x8325, 0xD379, 0x8356, 0xD37A, 0x833F, 0xD37B, 0x8341,\r\n\t0xD37C, 0x8326, 0xD37D, 0x831C, 0xD37E, 0x8322, 0xD3A1, 0x8342,\t0xD3A2, 0x834E, 0xD3A3, 0x831B, 0xD3A4, 0x832A, 0xD3A5, 0x8308,\r\n\t0xD3A6, 0x833C, 0xD3A7, 0x834D, 0xD3A8, 0x8316, 0xD3A9, 0x8324,\t0xD3AA, 0x8320, 0xD3AB, 0x8337, 0xD3AC, 0x832F, 0xD3AD, 0x8329,\r\n\t0xD3AE, 0x8347, 0xD3AF, 0x8345, 0xD3B0, 0x834C, 0xD3B1, 0x8353,\t0xD3B2, 0x831E, 0xD3B3, 0x832C, 0xD3B4, 0x834B, 0xD3B5, 0x8327,\r\n\t0xD3B6, 0x8348, 0xD3B7, 0x8653, 0xD3B8, 0x8652, 0xD3B9, 0x86A2,\t0xD3BA, 0x86A8, 0xD3BB, 0x8696, 0xD3BC, 0x868D, 0xD3BD, 0x8691,\r\n\t0xD3BE, 0x869E, 0xD3BF, 0x8687, 0xD3C0, 0x8697, 0xD3C1, 0x8686,\t0xD3C2, 0x868B, 0xD3C3, 0x869A, 0xD3C4, 0x8685, 0xD3C5, 0x86A5,\r\n\t0xD3C6, 0x8699, 0xD3C7, 0x86A1, 0xD3C8, 0x86A7, 0xD3C9, 0x8695,\t0xD3CA, 0x8698, 0xD3CB, 0x868E, 0xD3CC, 0x869D, 0xD3CD, 0x8690,\r\n\t0xD3CE, 0x8694, 0xD3CF, 0x8843, 0xD3D0, 0x8844, 0xD3D1, 0x886D,\t0xD3D2, 0x8875, 0xD3D3, 0x8876, 0xD3D4, 0x8872, 0xD3D5, 0x8880,\r\n\t0xD3D6, 0x8871, 0xD3D7, 0x887F, 0xD3D8, 0x886F, 0xD3D9, 0x8883,\t0xD3DA, 0x887E, 0xD3DB, 0x8874, 0xD3DC, 0x887C, 0xD3DD, 0x8A12,\r\n\t0xD3DE, 0x8C47, 0xD3DF, 0x8C57, 0xD3E0, 0x8C7B, 0xD3E1, 0x8CA4,\t0xD3E2, 0x8CA3, 0xD3E3, 0x8D76, 0xD3E4, 0x8D78, 0xD3E5, 0x8DB5,\r\n\t0xD3E6, 0x8DB7, 0xD3E7, 0x8DB6, 0xD3E8, 0x8ED1, 0xD3E9, 0x8ED3,\t0xD3EA, 0x8FFE, 0xD3EB, 0x8FF5, 0xD3EC, 0x9002, 0xD3ED, 0x8FFF,\r\n\t0xD3EE, 0x8FFB, 0xD3EF, 0x9004, 0xD3F0, 0x8FFC, 0xD3F1, 0x8FF6,\t0xD3F2, 0x90D6, 0xD3F3, 0x90E0, 0xD3F4, 0x90D9, 0xD3F5, 0x90DA,\r\n\t0xD3F6, 0x90E3, 0xD3F7, 0x90DF, 0xD3F8, 0x90E5, 0xD3F9, 0x90D8,\t0xD3FA, 0x90DB, 0xD3FB, 0x90D7, 0xD3FC, 0x90DC, 0xD3FD, 0x90E4,\r\n\t0xD3FE, 0x9150, 0xD440, 0x914E, 0xD441, 0x914F, 0xD442, 0x91D5,\t0xD443, 0x91E2, 0xD444, 0x91DA, 0xD445, 0x965C, 0xD446, 0x965F,\r\n\t0xD447, 0x96BC, 0xD448, 0x98E3, 0xD449, 0x9ADF, 0xD44A, 0x9B2F,\t0xD44B, 0x4E7F, 0xD44C, 0x5070, 0xD44D, 0x506A, 0xD44E, 0x5061,\r\n\t0xD44F, 0x505E, 0xD450, 0x5060, 0xD451, 0x5053, 0xD452, 0x504B,\t0xD453, 0x505D, 0xD454, 0x5072, 0xD455, 0x5048, 0xD456, 0x504D,\r\n\t0xD457, 0x5041, 0xD458, 0x505B, 0xD459, 0x504A, 0xD45A, 0x5062,\t0xD45B, 0x5015, 0xD45C, 0x5045, 0xD45D, 0x505F, 0xD45E, 0x5069,\r\n\t0xD45F, 0x506B, 0xD460, 0x5063, 0xD461, 0x5064, 0xD462, 0x5046,\t0xD463, 0x5040, 0xD464, 0x506E, 0xD465, 0x5073, 0xD466, 0x5057,\r\n\t0xD467, 0x5051, 0xD468, 0x51D0, 0xD469, 0x526B, 0xD46A, 0x526D,\t0xD46B, 0x526C, 0xD46C, 0x526E, 0xD46D, 0x52D6, 0xD46E, 0x52D3,\r\n\t0xD46F, 0x532D, 0xD470, 0x539C, 0xD471, 0x5575, 0xD472, 0x5576,\t0xD473, 0x553C, 0xD474, 0x554D, 0xD475, 0x5550, 0xD476, 0x5534,\r\n\t0xD477, 0x552A, 0xD478, 0x5551, 0xD479, 0x5562, 0xD47A, 0x5536,\t0xD47B, 0x5535, 0xD47C, 0x5530, 0xD47D, 0x5552, 0xD47E, 0x5545,\r\n\t0xD4A1, 0x550C, 0xD4A2, 0x5532, 0xD4A3, 0x5565, 0xD4A4, 0x554E,\t0xD4A5, 0x5539, 0xD4A6, 0x5548, 0xD4A7, 0x552D, 0xD4A8, 0x553B,\r\n\t0xD4A9, 0x5540, 0xD4AA, 0x554B, 0xD4AB, 0x570A, 0xD4AC, 0x5707,\t0xD4AD, 0x57FB, 0xD4AE, 0x5814, 0xD4AF, 0x57E2, 0xD4B0, 0x57F6,\r\n\t0xD4B1, 0x57DC, 0xD4B2, 0x57F4, 0xD4B3, 0x5800, 0xD4B4, 0x57ED,\t0xD4B5, 0x57FD, 0xD4B6, 0x5808, 0xD4B7, 0x57F8, 0xD4B8, 0x580B,\r\n\t0xD4B9, 0x57F3, 0xD4BA, 0x57CF, 0xD4BB, 0x5807, 0xD4BC, 0x57EE,\t0xD4BD, 0x57E3, 0xD4BE, 0x57F2, 0xD4BF, 0x57E5, 0xD4C0, 0x57EC,\r\n\t0xD4C1, 0x57E1, 0xD4C2, 0x580E, 0xD4C3, 0x57FC, 0xD4C4, 0x5810,\t0xD4C5, 0x57E7, 0xD4C6, 0x5801, 0xD4C7, 0x580C, 0xD4C8, 0x57F1,\r\n\t0xD4C9, 0x57E9, 0xD4CA, 0x57F0, 0xD4CB, 0x580D, 0xD4CC, 0x5804,\t0xD4CD, 0x595C, 0xD4CE, 0x5A60, 0xD4CF, 0x5A58, 0xD4D0, 0x5A55,\r\n\t0xD4D1, 0x5A67, 0xD4D2, 0x5A5E, 0xD4D3, 0x5A38, 0xD4D4, 0x5A35,\t0xD4D5, 0x5A6D, 0xD4D6, 0x5A50, 0xD4D7, 0x5A5F, 0xD4D8, 0x5A65,\r\n\t0xD4D9, 0x5A6C, 0xD4DA, 0x5A53, 0xD4DB, 0x5A64, 0xD4DC, 0x5A57,\t0xD4DD, 0x5A43, 0xD4DE, 0x5A5D, 0xD4DF, 0x5A52, 0xD4E0, 0x5A44,\r\n\t0xD4E1, 0x5A5B, 0xD4E2, 0x5A48, 0xD4E3, 0x5A8E, 0xD4E4, 0x5A3E,\t0xD4E5, 0x5A4D, 0xD4E6, 0x5A39, 0xD4E7, 0x5A4C, 0xD4E8, 0x5A70,\r\n\t0xD4E9, 0x5A69, 0xD4EA, 0x5A47, 0xD4EB, 0x5A51, 0xD4EC, 0x5A56,\t0xD4ED, 0x5A42, 0xD4EE, 0x5A5C, 0xD4EF, 0x5B72, 0xD4F0, 0x5B6E,\r\n\t0xD4F1, 0x5BC1, 0xD4F2, 0x5BC0, 0xD4F3, 0x5C59, 0xD4F4, 0x5D1E,\t0xD4F5, 0x5D0B, 0xD4F6, 0x5D1D, 0xD4F7, 0x5D1A, 0xD4F8, 0x5D20,\r\n\t0xD4F9, 0x5D0C, 0xD4FA, 0x5D28, 0xD4FB, 0x5D0D, 0xD4FC, 0x5D26,\t0xD4FD, 0x5D25, 0xD4FE, 0x5D0F, 0xD540, 0x5D30, 0xD541, 0x5D12,\r\n\t0xD542, 0x5D23, 0xD543, 0x5D1F, 0xD544, 0x5D2E, 0xD545, 0x5E3E,\t0xD546, 0x5E34, 0xD547, 0x5EB1, 0xD548, 0x5EB4, 0xD549, 0x5EB9,\r\n\t0xD54A, 0x5EB2, 0xD54B, 0x5EB3, 0xD54C, 0x5F36, 0xD54D, 0x5F38,\t0xD54E, 0x5F9B, 0xD54F, 0x5F96, 0xD550, 0x5F9F, 0xD551, 0x608A,\r\n\t0xD552, 0x6090, 0xD553, 0x6086, 0xD554, 0x60BE, 0xD555, 0x60B0,\t0xD556, 0x60BA, 0xD557, 0x60D3, 0xD558, 0x60D4, 0xD559, 0x60CF,\r\n\t0xD55A, 0x60E4, 0xD55B, 0x60D9, 0xD55C, 0x60DD, 0xD55D, 0x60C8,\t0xD55E, 0x60B1, 0xD55F, 0x60DB, 0xD560, 0x60B7, 0xD561, 0x60CA,\r\n\t0xD562, 0x60BF, 0xD563, 0x60C3, 0xD564, 0x60CD, 0xD565, 0x60C0,\t0xD566, 0x6332, 0xD567, 0x6365, 0xD568, 0x638A, 0xD569, 0x6382,\r\n\t0xD56A, 0x637D, 0xD56B, 0x63BD, 0xD56C, 0x639E, 0xD56D, 0x63AD,\t0xD56E, 0x639D, 0xD56F, 0x6397, 0xD570, 0x63AB, 0xD571, 0x638E,\r\n\t0xD572, 0x636F, 0xD573, 0x6387, 0xD574, 0x6390, 0xD575, 0x636E,\t0xD576, 0x63AF, 0xD577, 0x6375, 0xD578, 0x639C, 0xD579, 0x636D,\r\n\t0xD57A, 0x63AE, 0xD57B, 0x637C, 0xD57C, 0x63A4, 0xD57D, 0x633B,\t0xD57E, 0x639F, 0xD5A1, 0x6378, 0xD5A2, 0x6385, 0xD5A3, 0x6381,\r\n\t0xD5A4, 0x6391, 0xD5A5, 0x638D, 0xD5A6, 0x6370, 0xD5A7, 0x6553,\t0xD5A8, 0x65CD, 0xD5A9, 0x6665, 0xD5AA, 0x6661, 0xD5AB, 0x665B,\r\n\t0xD5AC, 0x6659, 0xD5AD, 0x665C, 0xD5AE, 0x6662, 0xD5AF, 0x6718,\t0xD5B0, 0x6879, 0xD5B1, 0x6887, 0xD5B2, 0x6890, 0xD5B3, 0x689C,\r\n\t0xD5B4, 0x686D, 0xD5B5, 0x686E, 0xD5B6, 0x68AE, 0xD5B7, 0x68AB,\t0xD5B8, 0x6956, 0xD5B9, 0x686F, 0xD5BA, 0x68A3, 0xD5BB, 0x68AC,\r\n\t0xD5BC, 0x68A9, 0xD5BD, 0x6875, 0xD5BE, 0x6874, 0xD5BF, 0x68B2,\t0xD5C0, 0x688F, 0xD5C1, 0x6877, 0xD5C2, 0x6892, 0xD5C3, 0x687C,\r\n\t0xD5C4, 0x686B, 0xD5C5, 0x6872, 0xD5C6, 0x68AA, 0xD5C7, 0x6880,\t0xD5C8, 0x6871, 0xD5C9, 0x687E, 0xD5CA, 0x689B, 0xD5CB, 0x6896,\r\n\t0xD5CC, 0x688B, 0xD5CD, 0x68A0, 0xD5CE, 0x6889, 0xD5CF, 0x68A4,\t0xD5D0, 0x6878, 0xD5D1, 0x687B, 0xD5D2, 0x6891, 0xD5D3, 0x688C,\r\n\t0xD5D4, 0x688A, 0xD5D5, 0x687D, 0xD5D6, 0x6B36, 0xD5D7, 0x6B33,\t0xD5D8, 0x6B37, 0xD5D9, 0x6B38, 0xD5DA, 0x6B91, 0xD5DB, 0x6B8F,\r\n\t0xD5DC, 0x6B8D, 0xD5DD, 0x6B8E, 0xD5DE, 0x6B8C, 0xD5DF, 0x6C2A,\t0xD5E0, 0x6DC0, 0xD5E1, 0x6DAB, 0xD5E2, 0x6DB4, 0xD5E3, 0x6DB3,\r\n\t0xD5E4, 0x6E74, 0xD5E5, 0x6DAC, 0xD5E6, 0x6DE9, 0xD5E7, 0x6DE2,\t0xD5E8, 0x6DB7, 0xD5E9, 0x6DF6, 0xD5EA, 0x6DD4, 0xD5EB, 0x6E00,\r\n\t0xD5EC, 0x6DC8, 0xD5ED, 0x6DE0, 0xD5EE, 0x6DDF, 0xD5EF, 0x6DD6,\t0xD5F0, 0x6DBE, 0xD5F1, 0x6DE5, 0xD5F2, 0x6DDC, 0xD5F3, 0x6DDD,\r\n\t0xD5F4, 0x6DDB, 0xD5F5, 0x6DF4, 0xD5F6, 0x6DCA, 0xD5F7, 0x6DBD,\t0xD5F8, 0x6DED, 0xD5F9, 0x6DF0, 0xD5FA, 0x6DBA, 0xD5FB, 0x6DD5,\r\n\t0xD5FC, 0x6DC2, 0xD5FD, 0x6DCF, 0xD5FE, 0x6DC9, 0xD640, 0x6DD0,\t0xD641, 0x6DF2, 0xD642, 0x6DD3, 0xD643, 0x6DFD, 0xD644, 0x6DD7,\r\n\t0xD645, 0x6DCD, 0xD646, 0x6DE3, 0xD647, 0x6DBB, 0xD648, 0x70FA,\t0xD649, 0x710D, 0xD64A, 0x70F7, 0xD64B, 0x7117, 0xD64C, 0x70F4,\r\n\t0xD64D, 0x710C, 0xD64E, 0x70F0, 0xD64F, 0x7104, 0xD650, 0x70F3,\t0xD651, 0x7110, 0xD652, 0x70FC, 0xD653, 0x70FF, 0xD654, 0x7106,\r\n\t0xD655, 0x7113, 0xD656, 0x7100, 0xD657, 0x70F8, 0xD658, 0x70F6,\t0xD659, 0x710B, 0xD65A, 0x7102, 0xD65B, 0x710E, 0xD65C, 0x727E,\r\n\t0xD65D, 0x727B, 0xD65E, 0x727C, 0xD65F, 0x727F, 0xD660, 0x731D,\t0xD661, 0x7317, 0xD662, 0x7307, 0xD663, 0x7311, 0xD664, 0x7318,\r\n\t0xD665, 0x730A, 0xD666, 0x7308, 0xD667, 0x72FF, 0xD668, 0x730F,\t0xD669, 0x731E, 0xD66A, 0x7388, 0xD66B, 0x73F6, 0xD66C, 0x73F8,\r\n\t0xD66D, 0x73F5, 0xD66E, 0x7404, 0xD66F, 0x7401, 0xD670, 0x73FD,\t0xD671, 0x7407, 0xD672, 0x7400, 0xD673, 0x73FA, 0xD674, 0x73FC,\r\n\t0xD675, 0x73FF, 0xD676, 0x740C, 0xD677, 0x740B, 0xD678, 0x73F4,\t0xD679, 0x7408, 0xD67A, 0x7564, 0xD67B, 0x7563, 0xD67C, 0x75CE,\r\n\t0xD67D, 0x75D2, 0xD67E, 0x75CF, 0xD6A1, 0x75CB, 0xD6A2, 0x75CC,\t0xD6A3, 0x75D1, 0xD6A4, 0x75D0, 0xD6A5, 0x768F, 0xD6A6, 0x7689,\r\n\t0xD6A7, 0x76D3, 0xD6A8, 0x7739, 0xD6A9, 0x772F, 0xD6AA, 0x772D,\t0xD6AB, 0x7731, 0xD6AC, 0x7732, 0xD6AD, 0x7734, 0xD6AE, 0x7733,\r\n\t0xD6AF, 0x773D, 0xD6B0, 0x7725, 0xD6B1, 0x773B, 0xD6B2, 0x7735,\t0xD6B3, 0x7848, 0xD6B4, 0x7852, 0xD6B5, 0x7849, 0xD6B6, 0x784D,\r\n\t0xD6B7, 0x784A, 0xD6B8, 0x784C, 0xD6B9, 0x7826, 0xD6BA, 0x7845,\t0xD6BB, 0x7850, 0xD6BC, 0x7964, 0xD6BD, 0x7967, 0xD6BE, 0x7969,\r\n\t0xD6BF, 0x796A, 0xD6C0, 0x7963, 0xD6C1, 0x796B, 0xD6C2, 0x7961,\t0xD6C3, 0x79BB, 0xD6C4, 0x79FA, 0xD6C5, 0x79F8, 0xD6C6, 0x79F6,\r\n\t0xD6C7, 0x79F7, 0xD6C8, 0x7A8F, 0xD6C9, 0x7A94, 0xD6CA, 0x7A90,\t0xD6CB, 0x7B35, 0xD6CC, 0x7B47, 0xD6CD, 0x7B34, 0xD6CE, 0x7B25,\r\n\t0xD6CF, 0x7B30, 0xD6D0, 0x7B22, 0xD6D1, 0x7B24, 0xD6D2, 0x7B33,\t0xD6D3, 0x7B18, 0xD6D4, 0x7B2A, 0xD6D5, 0x7B1D, 0xD6D6, 0x7B31,\r\n\t0xD6D7, 0x7B2B, 0xD6D8, 0x7B2D, 0xD6D9, 0x7B2F, 0xD6DA, 0x7B32,\t0xD6DB, 0x7B38, 0xD6DC, 0x7B1A, 0xD6DD, 0x7B23, 0xD6DE, 0x7C94,\r\n\t0xD6DF, 0x7C98, 0xD6E0, 0x7C96, 0xD6E1, 0x7CA3, 0xD6E2, 0x7D35,\t0xD6E3, 0x7D3D, 0xD6E4, 0x7D38, 0xD6E5, 0x7D36, 0xD6E6, 0x7D3A,\r\n\t0xD6E7, 0x7D45, 0xD6E8, 0x7D2C, 0xD6E9, 0x7D29, 0xD6EA, 0x7D41,\t0xD6EB, 0x7D47, 0xD6EC, 0x7D3E, 0xD6ED, 0x7D3F, 0xD6EE, 0x7D4A,\r\n\t0xD6EF, 0x7D3B, 0xD6F0, 0x7D28, 0xD6F1, 0x7F63, 0xD6F2, 0x7F95,\t0xD6F3, 0x7F9C, 0xD6F4, 0x7F9D, 0xD6F5, 0x7F9B, 0xD6F6, 0x7FCA,\r\n\t0xD6F7, 0x7FCB, 0xD6F8, 0x7FCD, 0xD6F9, 0x7FD0, 0xD6FA, 0x7FD1,\t0xD6FB, 0x7FC7, 0xD6FC, 0x7FCF, 0xD6FD, 0x7FC9, 0xD6FE, 0x801F,\r\n\t0xD740, 0x801E, 0xD741, 0x801B, 0xD742, 0x8047, 0xD743, 0x8043,\t0xD744, 0x8048, 0xD745, 0x8118, 0xD746, 0x8125, 0xD747, 0x8119,\r\n\t0xD748, 0x811B, 0xD749, 0x812D, 0xD74A, 0x811F, 0xD74B, 0x812C,\t0xD74C, 0x811E, 0xD74D, 0x8121, 0xD74E, 0x8115, 0xD74F, 0x8127,\r\n\t0xD750, 0x811D, 0xD751, 0x8122, 0xD752, 0x8211, 0xD753, 0x8238,\t0xD754, 0x8233, 0xD755, 0x823A, 0xD756, 0x8234, 0xD757, 0x8232,\r\n\t0xD758, 0x8274, 0xD759, 0x8390, 0xD75A, 0x83A3, 0xD75B, 0x83A8,\t0xD75C, 0x838D, 0xD75D, 0x837A, 0xD75E, 0x8373, 0xD75F, 0x83A4,\r\n\t0xD760, 0x8374, 0xD761, 0x838F, 0xD762, 0x8381, 0xD763, 0x8395,\t0xD764, 0x8399, 0xD765, 0x8375, 0xD766, 0x8394, 0xD767, 0x83A9,\r\n\t0xD768, 0x837D, 0xD769, 0x8383, 0xD76A, 0x838C, 0xD76B, 0x839D,\t0xD76C, 0x839B, 0xD76D, 0x83AA, 0xD76E, 0x838B, 0xD76F, 0x837E,\r\n\t0xD770, 0x83A5, 0xD771, 0x83AF, 0xD772, 0x8388, 0xD773, 0x8397,\t0xD774, 0x83B0, 0xD775, 0x837F, 0xD776, 0x83A6, 0xD777, 0x8387,\r\n\t0xD778, 0x83AE, 0xD779, 0x8376, 0xD77A, 0x839A, 0xD77B, 0x8659,\t0xD77C, 0x8656, 0xD77D, 0x86BF, 0xD77E, 0x86B7, 0xD7A1, 0x86C2,\r\n\t0xD7A2, 0x86C1, 0xD7A3, 0x86C5, 0xD7A4, 0x86BA, 0xD7A5, 0x86B0,\t0xD7A6, 0x86C8, 0xD7A7, 0x86B9, 0xD7A8, 0x86B3, 0xD7A9, 0x86B8,\r\n\t0xD7AA, 0x86CC, 0xD7AB, 0x86B4, 0xD7AC, 0x86BB, 0xD7AD, 0x86BC,\t0xD7AE, 0x86C3, 0xD7AF, 0x86BD, 0xD7B0, 0x86BE, 0xD7B1, 0x8852,\r\n\t0xD7B2, 0x8889, 0xD7B3, 0x8895, 0xD7B4, 0x88A8, 0xD7B5, 0x88A2,\t0xD7B6, 0x88AA, 0xD7B7, 0x889A, 0xD7B8, 0x8891, 0xD7B9, 0x88A1,\r\n\t0xD7BA, 0x889F, 0xD7BB, 0x8898, 0xD7BC, 0x88A7, 0xD7BD, 0x8899,\t0xD7BE, 0x889B, 0xD7BF, 0x8897, 0xD7C0, 0x88A4, 0xD7C1, 0x88AC,\r\n\t0xD7C2, 0x888C, 0xD7C3, 0x8893, 0xD7C4, 0x888E, 0xD7C5, 0x8982,\t0xD7C6, 0x89D6, 0xD7C7, 0x89D9, 0xD7C8, 0x89D5, 0xD7C9, 0x8A30,\r\n\t0xD7CA, 0x8A27, 0xD7CB, 0x8A2C, 0xD7CC, 0x8A1E, 0xD7CD, 0x8C39,\t0xD7CE, 0x8C3B, 0xD7CF, 0x8C5C, 0xD7D0, 0x8C5D, 0xD7D1, 0x8C7D,\r\n\t0xD7D2, 0x8CA5, 0xD7D3, 0x8D7D, 0xD7D4, 0x8D7B, 0xD7D5, 0x8D79,\t0xD7D6, 0x8DBC, 0xD7D7, 0x8DC2, 0xD7D8, 0x8DB9, 0xD7D9, 0x8DBF,\r\n\t0xD7DA, 0x8DC1, 0xD7DB, 0x8ED8, 0xD7DC, 0x8EDE, 0xD7DD, 0x8EDD,\t0xD7DE, 0x8EDC, 0xD7DF, 0x8ED7, 0xD7E0, 0x8EE0, 0xD7E1, 0x8EE1,\r\n\t0xD7E2, 0x9024, 0xD7E3, 0x900B, 0xD7E4, 0x9011, 0xD7E5, 0x901C,\t0xD7E6, 0x900C, 0xD7E7, 0x9021, 0xD7E8, 0x90EF, 0xD7E9, 0x90EA,\r\n\t0xD7EA, 0x90F0, 0xD7EB, 0x90F4, 0xD7EC, 0x90F2, 0xD7ED, 0x90F3,\t0xD7EE, 0x90D4, 0xD7EF, 0x90EB, 0xD7F0, 0x90EC, 0xD7F1, 0x90E9,\r\n\t0xD7F2, 0x9156, 0xD7F3, 0x9158, 0xD7F4, 0x915A, 0xD7F5, 0x9153,\t0xD7F6, 0x9155, 0xD7F7, 0x91EC, 0xD7F8, 0x91F4, 0xD7F9, 0x91F1,\r\n\t0xD7FA, 0x91F3, 0xD7FB, 0x91F8, 0xD7FC, 0x91E4, 0xD7FD, 0x91F9,\t0xD7FE, 0x91EA, 0xD840, 0x91EB, 0xD841, 0x91F7, 0xD842, 0x91E8,\r\n\t0xD843, 0x91EE, 0xD844, 0x957A, 0xD845, 0x9586, 0xD846, 0x9588,\t0xD847, 0x967C, 0xD848, 0x966D, 0xD849, 0x966B, 0xD84A, 0x9671,\r\n\t0xD84B, 0x966F, 0xD84C, 0x96BF, 0xD84D, 0x976A, 0xD84E, 0x9804,\t0xD84F, 0x98E5, 0xD850, 0x9997, 0xD851, 0x509B, 0xD852, 0x5095,\r\n\t0xD853, 0x5094, 0xD854, 0x509E, 0xD855, 0x508B, 0xD856, 0x50A3,\t0xD857, 0x5083, 0xD858, 0x508C, 0xD859, 0x508E, 0xD85A, 0x509D,\r\n\t0xD85B, 0x5068, 0xD85C, 0x509C, 0xD85D, 0x5092, 0xD85E, 0x5082,\t0xD85F, 0x5087, 0xD860, 0x515F, 0xD861, 0x51D4, 0xD862, 0x5312,\r\n\t0xD863, 0x5311, 0xD864, 0x53A4, 0xD865, 0x53A7, 0xD866, 0x5591,\t0xD867, 0x55A8, 0xD868, 0x55A5, 0xD869, 0x55AD, 0xD86A, 0x5577,\r\n\t0xD86B, 0x5645, 0xD86C, 0x55A2, 0xD86D, 0x5593, 0xD86E, 0x5588,\t0xD86F, 0x558F, 0xD870, 0x55B5, 0xD871, 0x5581, 0xD872, 0x55A3,\r\n\t0xD873, 0x5592, 0xD874, 0x55A4, 0xD875, 0x557D, 0xD876, 0x558C,\t0xD877, 0x55A6, 0xD878, 0x557F, 0xD879, 0x5595, 0xD87A, 0x55A1,\r\n\t0xD87B, 0x558E, 0xD87C, 0x570C, 0xD87D, 0x5829, 0xD87E, 0x5837,\t0xD8A1, 0x5819, 0xD8A2, 0x581E, 0xD8A3, 0x5827, 0xD8A4, 0x5823,\r\n\t0xD8A5, 0x5828, 0xD8A6, 0x57F5, 0xD8A7, 0x5848, 0xD8A8, 0x5825,\t0xD8A9, 0x581C, 0xD8AA, 0x581B, 0xD8AB, 0x5833, 0xD8AC, 0x583F,\r\n\t0xD8AD, 0x5836, 0xD8AE, 0x582E, 0xD8AF, 0x5839, 0xD8B0, 0x5838,\t0xD8B1, 0x582D, 0xD8B2, 0x582C, 0xD8B3, 0x583B, 0xD8B4, 0x5961,\r\n\t0xD8B5, 0x5AAF, 0xD8B6, 0x5A94, 0xD8B7, 0x5A9F, 0xD8B8, 0x5A7A,\t0xD8B9, 0x5AA2, 0xD8BA, 0x5A9E, 0xD8BB, 0x5A78, 0xD8BC, 0x5AA6,\r\n\t0xD8BD, 0x5A7C, 0xD8BE, 0x5AA5, 0xD8BF, 0x5AAC, 0xD8C0, 0x5A95,\t0xD8C1, 0x5AAE, 0xD8C2, 0x5A37, 0xD8C3, 0x5A84, 0xD8C4, 0x5A8A,\r\n\t0xD8C5, 0x5A97, 0xD8C6, 0x5A83, 0xD8C7, 0x5A8B, 0xD8C8, 0x5AA9,\t0xD8C9, 0x5A7B, 0xD8CA, 0x5A7D, 0xD8CB, 0x5A8C, 0xD8CC, 0x5A9C,\r\n\t0xD8CD, 0x5A8F, 0xD8CE, 0x5A93, 0xD8CF, 0x5A9D, 0xD8D0, 0x5BEA,\t0xD8D1, 0x5BCD, 0xD8D2, 0x5BCB, 0xD8D3, 0x5BD4, 0xD8D4, 0x5BD1,\r\n\t0xD8D5, 0x5BCA, 0xD8D6, 0x5BCE, 0xD8D7, 0x5C0C, 0xD8D8, 0x5C30,\t0xD8D9, 0x5D37, 0xD8DA, 0x5D43, 0xD8DB, 0x5D6B, 0xD8DC, 0x5D41,\r\n\t0xD8DD, 0x5D4B, 0xD8DE, 0x5D3F, 0xD8DF, 0x5D35, 0xD8E0, 0x5D51,\t0xD8E1, 0x5D4E, 0xD8E2, 0x5D55, 0xD8E3, 0x5D33, 0xD8E4, 0x5D3A,\r\n\t0xD8E5, 0x5D52, 0xD8E6, 0x5D3D, 0xD8E7, 0x5D31, 0xD8E8, 0x5D59,\t0xD8E9, 0x5D42, 0xD8EA, 0x5D39, 0xD8EB, 0x5D49, 0xD8EC, 0x5D38,\r\n\t0xD8ED, 0x5D3C, 0xD8EE, 0x5D32, 0xD8EF, 0x5D36, 0xD8F0, 0x5D40,\t0xD8F1, 0x5D45, 0xD8F2, 0x5E44, 0xD8F3, 0x5E41, 0xD8F4, 0x5F58,\r\n\t0xD8F5, 0x5FA6, 0xD8F6, 0x5FA5, 0xD8F7, 0x5FAB, 0xD8F8, 0x60C9,\t0xD8F9, 0x60B9, 0xD8FA, 0x60CC, 0xD8FB, 0x60E2, 0xD8FC, 0x60CE,\r\n\t0xD8FD, 0x60C4, 0xD8FE, 0x6114, 0xD940, 0x60F2, 0xD941, 0x610A,\t0xD942, 0x6116, 0xD943, 0x6105, 0xD944, 0x60F5, 0xD945, 0x6113,\r\n\t0xD946, 0x60F8, 0xD947, 0x60FC, 0xD948, 0x60FE, 0xD949, 0x60C1,\t0xD94A, 0x6103, 0xD94B, 0x6118, 0xD94C, 0x611D, 0xD94D, 0x6110,\r\n\t0xD94E, 0x60FF, 0xD94F, 0x6104, 0xD950, 0x610B, 0xD951, 0x624A,\t0xD952, 0x6394, 0xD953, 0x63B1, 0xD954, 0x63B0, 0xD955, 0x63CE,\r\n\t0xD956, 0x63E5, 0xD957, 0x63E8, 0xD958, 0x63EF, 0xD959, 0x63C3,\t0xD95A, 0x649D, 0xD95B, 0x63F3, 0xD95C, 0x63CA, 0xD95D, 0x63E0,\r\n\t0xD95E, 0x63F6, 0xD95F, 0x63D5, 0xD960, 0x63F2, 0xD961, 0x63F5,\t0xD962, 0x6461, 0xD963, 0x63DF, 0xD964, 0x63BE, 0xD965, 0x63DD,\r\n\t0xD966, 0x63DC, 0xD967, 0x63C4, 0xD968, 0x63D8, 0xD969, 0x63D3,\t0xD96A, 0x63C2, 0xD96B, 0x63C7, 0xD96C, 0x63CC, 0xD96D, 0x63CB,\r\n\t0xD96E, 0x63C8, 0xD96F, 0x63F0, 0xD970, 0x63D7, 0xD971, 0x63D9,\t0xD972, 0x6532, 0xD973, 0x6567, 0xD974, 0x656A, 0xD975, 0x6564,\r\n\t0xD976, 0x655C, 0xD977, 0x6568, 0xD978, 0x6565, 0xD979, 0x658C,\t0xD97A, 0x659D, 0xD97B, 0x659E, 0xD97C, 0x65AE, 0xD97D, 0x65D0,\r\n\t0xD97E, 0x65D2, 0xD9A1, 0x667C, 0xD9A2, 0x666C, 0xD9A3, 0x667B,\t0xD9A4, 0x6680, 0xD9A5, 0x6671, 0xD9A6, 0x6679, 0xD9A7, 0x666A,\r\n\t0xD9A8, 0x6672, 0xD9A9, 0x6701, 0xD9AA, 0x690C, 0xD9AB, 0x68D3,\t0xD9AC, 0x6904, 0xD9AD, 0x68DC, 0xD9AE, 0x692A, 0xD9AF, 0x68EC,\r\n\t0xD9B0, 0x68EA, 0xD9B1, 0x68F1, 0xD9B2, 0x690F, 0xD9B3, 0x68D6,\t0xD9B4, 0x68F7, 0xD9B5, 0x68EB, 0xD9B6, 0x68E4, 0xD9B7, 0x68F6,\r\n\t0xD9B8, 0x6913, 0xD9B9, 0x6910, 0xD9BA, 0x68F3, 0xD9BB, 0x68E1,\t0xD9BC, 0x6907, 0xD9BD, 0x68CC, 0xD9BE, 0x6908, 0xD9BF, 0x6970,\r\n\t0xD9C0, 0x68B4, 0xD9C1, 0x6911, 0xD9C2, 0x68EF, 0xD9C3, 0x68C6,\t0xD9C4, 0x6914, 0xD9C5, 0x68F8, 0xD9C6, 0x68D0, 0xD9C7, 0x68FD,\r\n\t0xD9C8, 0x68FC, 0xD9C9, 0x68E8, 0xD9CA, 0x690B, 0xD9CB, 0x690A,\t0xD9CC, 0x6917, 0xD9CD, 0x68CE, 0xD9CE, 0x68C8, 0xD9CF, 0x68DD,\r\n\t0xD9D0, 0x68DE, 0xD9D1, 0x68E6, 0xD9D2, 0x68F4, 0xD9D3, 0x68D1,\t0xD9D4, 0x6906, 0xD9D5, 0x68D4, 0xD9D6, 0x68E9, 0xD9D7, 0x6915,\r\n\t0xD9D8, 0x6925, 0xD9D9, 0x68C7, 0xD9DA, 0x6B39, 0xD9DB, 0x6B3B,\t0xD9DC, 0x6B3F, 0xD9DD, 0x6B3C, 0xD9DE, 0x6B94, 0xD9DF, 0x6B97,\r\n\t0xD9E0, 0x6B99, 0xD9E1, 0x6B95, 0xD9E2, 0x6BBD, 0xD9E3, 0x6BF0,\t0xD9E4, 0x6BF2, 0xD9E5, 0x6BF3, 0xD9E6, 0x6C30, 0xD9E7, 0x6DFC,\r\n\t0xD9E8, 0x6E46, 0xD9E9, 0x6E47, 0xD9EA, 0x6E1F, 0xD9EB, 0x6E49,\t0xD9EC, 0x6E88, 0xD9ED, 0x6E3C, 0xD9EE, 0x6E3D, 0xD9EF, 0x6E45,\r\n\t0xD9F0, 0x6E62, 0xD9F1, 0x6E2B, 0xD9F2, 0x6E3F, 0xD9F3, 0x6E41,\t0xD9F4, 0x6E5D, 0xD9F5, 0x6E73, 0xD9F6, 0x6E1C, 0xD9F7, 0x6E33,\r\n\t0xD9F8, 0x6E4B, 0xD9F9, 0x6E40, 0xD9FA, 0x6E51, 0xD9FB, 0x6E3B,\t0xD9FC, 0x6E03, 0xD9FD, 0x6E2E, 0xD9FE, 0x6E5E, 0xDA40, 0x6E68,\r\n\t0xDA41, 0x6E5C, 0xDA42, 0x6E61, 0xDA43, 0x6E31, 0xDA44, 0x6E28,\t0xDA45, 0x6E60, 0xDA46, 0x6E71, 0xDA47, 0x6E6B, 0xDA48, 0x6E39,\r\n\t0xDA49, 0x6E22, 0xDA4A, 0x6E30, 0xDA4B, 0x6E53, 0xDA4C, 0x6E65,\t0xDA4D, 0x6E27, 0xDA4E, 0x6E78, 0xDA4F, 0x6E64, 0xDA50, 0x6E77,\r\n\t0xDA51, 0x6E55, 0xDA52, 0x6E79, 0xDA53, 0x6E52, 0xDA54, 0x6E66,\t0xDA55, 0x6E35, 0xDA56, 0x6E36, 0xDA57, 0x6E5A, 0xDA58, 0x7120,\r\n\t0xDA59, 0x711E, 0xDA5A, 0x712F, 0xDA5B, 0x70FB, 0xDA5C, 0x712E,\t0xDA5D, 0x7131, 0xDA5E, 0x7123, 0xDA5F, 0x7125, 0xDA60, 0x7122,\r\n\t0xDA61, 0x7132, 0xDA62, 0x711F, 0xDA63, 0x7128, 0xDA64, 0x713A,\t0xDA65, 0x711B, 0xDA66, 0x724B, 0xDA67, 0x725A, 0xDA68, 0x7288,\r\n\t0xDA69, 0x7289, 0xDA6A, 0x7286, 0xDA6B, 0x7285, 0xDA6C, 0x728B,\t0xDA6D, 0x7312, 0xDA6E, 0x730B, 0xDA6F, 0x7330, 0xDA70, 0x7322,\r\n\t0xDA71, 0x7331, 0xDA72, 0x7333, 0xDA73, 0x7327, 0xDA74, 0x7332,\t0xDA75, 0x732D, 0xDA76, 0x7326, 0xDA77, 0x7323, 0xDA78, 0x7335,\r\n\t0xDA79, 0x730C, 0xDA7A, 0x742E, 0xDA7B, 0x742C, 0xDA7C, 0x7430,\t0xDA7D, 0x742B, 0xDA7E, 0x7416, 0xDAA1, 0x741A, 0xDAA2, 0x7421,\r\n\t0xDAA3, 0x742D, 0xDAA4, 0x7431, 0xDAA5, 0x7424, 0xDAA6, 0x7423,\t0xDAA7, 0x741D, 0xDAA8, 0x7429, 0xDAA9, 0x7420, 0xDAAA, 0x7432,\r\n\t0xDAAB, 0x74FB, 0xDAAC, 0x752F, 0xDAAD, 0x756F, 0xDAAE, 0x756C,\t0xDAAF, 0x75E7, 0xDAB0, 0x75DA, 0xDAB1, 0x75E1, 0xDAB2, 0x75E6,\r\n\t0xDAB3, 0x75DD, 0xDAB4, 0x75DF, 0xDAB5, 0x75E4, 0xDAB6, 0x75D7,\t0xDAB7, 0x7695, 0xDAB8, 0x7692, 0xDAB9, 0x76DA, 0xDABA, 0x7746,\r\n\t0xDABB, 0x7747, 0xDABC, 0x7744, 0xDABD, 0x774D, 0xDABE, 0x7745,\t0xDABF, 0x774A, 0xDAC0, 0x774E, 0xDAC1, 0x774B, 0xDAC2, 0x774C,\r\n\t0xDAC3, 0x77DE, 0xDAC4, 0x77EC, 0xDAC5, 0x7860, 0xDAC6, 0x7864,\t0xDAC7, 0x7865, 0xDAC8, 0x785C, 0xDAC9, 0x786D, 0xDACA, 0x7871,\r\n\t0xDACB, 0x786A, 0xDACC, 0x786E, 0xDACD, 0x7870, 0xDACE, 0x7869,\t0xDACF, 0x7868, 0xDAD0, 0x785E, 0xDAD1, 0x7862, 0xDAD2, 0x7974,\r\n\t0xDAD3, 0x7973, 0xDAD4, 0x7972, 0xDAD5, 0x7970, 0xDAD6, 0x7A02,\t0xDAD7, 0x7A0A, 0xDAD8, 0x7A03, 0xDAD9, 0x7A0C, 0xDADA, 0x7A04,\r\n\t0xDADB, 0x7A99, 0xDADC, 0x7AE6, 0xDADD, 0x7AE4, 0xDADE, 0x7B4A,\t0xDADF, 0x7B3B, 0xDAE0, 0x7B44, 0xDAE1, 0x7B48, 0xDAE2, 0x7B4C,\r\n\t0xDAE3, 0x7B4E, 0xDAE4, 0x7B40, 0xDAE5, 0x7B58, 0xDAE6, 0x7B45,\t0xDAE7, 0x7CA2, 0xDAE8, 0x7C9E, 0xDAE9, 0x7CA8, 0xDAEA, 0x7CA1,\r\n\t0xDAEB, 0x7D58, 0xDAEC, 0x7D6F, 0xDAED, 0x7D63, 0xDAEE, 0x7D53,\t0xDAEF, 0x7D56, 0xDAF0, 0x7D67, 0xDAF1, 0x7D6A, 0xDAF2, 0x7D4F,\r\n\t0xDAF3, 0x7D6D, 0xDAF4, 0x7D5C, 0xDAF5, 0x7D6B, 0xDAF6, 0x7D52,\t0xDAF7, 0x7D54, 0xDAF8, 0x7D69, 0xDAF9, 0x7D51, 0xDAFA, 0x7D5F,\r\n\t0xDAFB, 0x7D4E, 0xDAFC, 0x7F3E, 0xDAFD, 0x7F3F, 0xDAFE, 0x7F65,\t0xDB40, 0x7F66, 0xDB41, 0x7FA2, 0xDB42, 0x7FA0, 0xDB43, 0x7FA1,\r\n\t0xDB44, 0x7FD7, 0xDB45, 0x8051, 0xDB46, 0x804F, 0xDB47, 0x8050,\t0xDB48, 0x80FE, 0xDB49, 0x80D4, 0xDB4A, 0x8143, 0xDB4B, 0x814A,\r\n\t0xDB4C, 0x8152, 0xDB4D, 0x814F, 0xDB4E, 0x8147, 0xDB4F, 0x813D,\t0xDB50, 0x814D, 0xDB51, 0x813A, 0xDB52, 0x81E6, 0xDB53, 0x81EE,\r\n\t0xDB54, 0x81F7, 0xDB55, 0x81F8, 0xDB56, 0x81F9, 0xDB57, 0x8204,\t0xDB58, 0x823C, 0xDB59, 0x823D, 0xDB5A, 0x823F, 0xDB5B, 0x8275,\r\n\t0xDB5C, 0x833B, 0xDB5D, 0x83CF, 0xDB5E, 0x83F9, 0xDB5F, 0x8423,\t0xDB60, 0x83C0, 0xDB61, 0x83E8, 0xDB62, 0x8412, 0xDB63, 0x83E7,\r\n\t0xDB64, 0x83E4, 0xDB65, 0x83FC, 0xDB66, 0x83F6, 0xDB67, 0x8410,\t0xDB68, 0x83C6, 0xDB69, 0x83C8, 0xDB6A, 0x83EB, 0xDB6B, 0x83E3,\r\n\t0xDB6C, 0x83BF, 0xDB6D, 0x8401, 0xDB6E, 0x83DD, 0xDB6F, 0x83E5,\t0xDB70, 0x83D8, 0xDB71, 0x83FF, 0xDB72, 0x83E1, 0xDB73, 0x83CB,\r\n\t0xDB74, 0x83CE, 0xDB75, 0x83D6, 0xDB76, 0x83F5, 0xDB77, 0x83C9,\t0xDB78, 0x8409, 0xDB79, 0x840F, 0xDB7A, 0x83DE, 0xDB7B, 0x8411,\r\n\t0xDB7C, 0x8406, 0xDB7D, 0x83C2, 0xDB7E, 0x83F3, 0xDBA1, 0x83D5,\t0xDBA2, 0x83FA, 0xDBA3, 0x83C7, 0xDBA4, 0x83D1, 0xDBA5, 0x83EA,\r\n\t0xDBA6, 0x8413, 0xDBA7, 0x83C3, 0xDBA8, 0x83EC, 0xDBA9, 0x83EE,\t0xDBAA, 0x83C4, 0xDBAB, 0x83FB, 0xDBAC, 0x83D7, 0xDBAD, 0x83E2,\r\n\t0xDBAE, 0x841B, 0xDBAF, 0x83DB, 0xDBB0, 0x83FE, 0xDBB1, 0x86D8,\t0xDBB2, 0x86E2, 0xDBB3, 0x86E6, 0xDBB4, 0x86D3, 0xDBB5, 0x86E3,\r\n\t0xDBB6, 0x86DA, 0xDBB7, 0x86EA, 0xDBB8, 0x86DD, 0xDBB9, 0x86EB,\t0xDBBA, 0x86DC, 0xDBBB, 0x86EC, 0xDBBC, 0x86E9, 0xDBBD, 0x86D7,\r\n\t0xDBBE, 0x86E8, 0xDBBF, 0x86D1, 0xDBC0, 0x8848, 0xDBC1, 0x8856,\t0xDBC2, 0x8855, 0xDBC3, 0x88BA, 0xDBC4, 0x88D7, 0xDBC5, 0x88B9,\r\n\t0xDBC6, 0x88B8, 0xDBC7, 0x88C0, 0xDBC8, 0x88BE, 0xDBC9, 0x88B6,\t0xDBCA, 0x88BC, 0xDBCB, 0x88B7, 0xDBCC, 0x88BD, 0xDBCD, 0x88B2,\r\n\t0xDBCE, 0x8901, 0xDBCF, 0x88C9, 0xDBD0, 0x8995, 0xDBD1, 0x8998,\t0xDBD2, 0x8997, 0xDBD3, 0x89DD, 0xDBD4, 0x89DA, 0xDBD5, 0x89DB,\r\n\t0xDBD6, 0x8A4E, 0xDBD7, 0x8A4D, 0xDBD8, 0x8A39, 0xDBD9, 0x8A59,\t0xDBDA, 0x8A40, 0xDBDB, 0x8A57, 0xDBDC, 0x8A58, 0xDBDD, 0x8A44,\r\n\t0xDBDE, 0x8A45, 0xDBDF, 0x8A52, 0xDBE0, 0x8A48, 0xDBE1, 0x8A51,\t0xDBE2, 0x8A4A, 0xDBE3, 0x8A4C, 0xDBE4, 0x8A4F, 0xDBE5, 0x8C5F,\r\n\t0xDBE6, 0x8C81, 0xDBE7, 0x8C80, 0xDBE8, 0x8CBA, 0xDBE9, 0x8CBE,\t0xDBEA, 0x8CB0, 0xDBEB, 0x8CB9, 0xDBEC, 0x8CB5, 0xDBED, 0x8D84,\r\n\t0xDBEE, 0x8D80, 0xDBEF, 0x8D89, 0xDBF0, 0x8DD8, 0xDBF1, 0x8DD3,\t0xDBF2, 0x8DCD, 0xDBF3, 0x8DC7, 0xDBF4, 0x8DD6, 0xDBF5, 0x8DDC,\r\n\t0xDBF6, 0x8DCF, 0xDBF7, 0x8DD5, 0xDBF8, 0x8DD9, 0xDBF9, 0x8DC8,\t0xDBFA, 0x8DD7, 0xDBFB, 0x8DC5, 0xDBFC, 0x8EEF, 0xDBFD, 0x8EF7,\r\n\t0xDBFE, 0x8EFA, 0xDC40, 0x8EF9, 0xDC41, 0x8EE6, 0xDC42, 0x8EEE,\t0xDC43, 0x8EE5, 0xDC44, 0x8EF5, 0xDC45, 0x8EE7, 0xDC46, 0x8EE8,\r\n\t0xDC47, 0x8EF6, 0xDC48, 0x8EEB, 0xDC49, 0x8EF1, 0xDC4A, 0x8EEC,\t0xDC4B, 0x8EF4, 0xDC4C, 0x8EE9, 0xDC4D, 0x902D, 0xDC4E, 0x9034,\r\n\t0xDC4F, 0x902F, 0xDC50, 0x9106, 0xDC51, 0x912C, 0xDC52, 0x9104,\t0xDC53, 0x90FF, 0xDC54, 0x90FC, 0xDC55, 0x9108, 0xDC56, 0x90F9,\r\n\t0xDC57, 0x90FB, 0xDC58, 0x9101, 0xDC59, 0x9100, 0xDC5A, 0x9107,\t0xDC5B, 0x9105, 0xDC5C, 0x9103, 0xDC5D, 0x9161, 0xDC5E, 0x9164,\r\n\t0xDC5F, 0x915F, 0xDC60, 0x9162, 0xDC61, 0x9160, 0xDC62, 0x9201,\t0xDC63, 0x920A, 0xDC64, 0x9225, 0xDC65, 0x9203, 0xDC66, 0x921A,\r\n\t0xDC67, 0x9226, 0xDC68, 0x920F, 0xDC69, 0x920C, 0xDC6A, 0x9200,\t0xDC6B, 0x9212, 0xDC6C, 0x91FF, 0xDC6D, 0x91FD, 0xDC6E, 0x9206,\r\n\t0xDC6F, 0x9204, 0xDC70, 0x9227, 0xDC71, 0x9202, 0xDC72, 0x921C,\t0xDC73, 0x9224, 0xDC74, 0x9219, 0xDC75, 0x9217, 0xDC76, 0x9205,\r\n\t0xDC77, 0x9216, 0xDC78, 0x957B, 0xDC79, 0x958D, 0xDC7A, 0x958C,\t0xDC7B, 0x9590, 0xDC7C, 0x9687, 0xDC7D, 0x967E, 0xDC7E, 0x9688,\r\n\t0xDCA1, 0x9689, 0xDCA2, 0x9683, 0xDCA3, 0x9680, 0xDCA4, 0x96C2,\t0xDCA5, 0x96C8, 0xDCA6, 0x96C3, 0xDCA7, 0x96F1, 0xDCA8, 0x96F0,\r\n\t0xDCA9, 0x976C, 0xDCAA, 0x9770, 0xDCAB, 0x976E, 0xDCAC, 0x9807,\t0xDCAD, 0x98A9, 0xDCAE, 0x98EB, 0xDCAF, 0x9CE6, 0xDCB0, 0x9EF9,\r\n\t0xDCB1, 0x4E83, 0xDCB2, 0x4E84, 0xDCB3, 0x4EB6, 0xDCB4, 0x50BD,\t0xDCB5, 0x50BF, 0xDCB6, 0x50C6, 0xDCB7, 0x50AE, 0xDCB8, 0x50C4,\r\n\t0xDCB9, 0x50CA, 0xDCBA, 0x50B4, 0xDCBB, 0x50C8, 0xDCBC, 0x50C2,\t0xDCBD, 0x50B0, 0xDCBE, 0x50C1, 0xDCBF, 0x50BA, 0xDCC0, 0x50B1,\r\n\t0xDCC1, 0x50CB, 0xDCC2, 0x50C9, 0xDCC3, 0x50B6, 0xDCC4, 0x50B8,\t0xDCC5, 0x51D7, 0xDCC6, 0x527A, 0xDCC7, 0x5278, 0xDCC8, 0x527B,\r\n\t0xDCC9, 0x527C, 0xDCCA, 0x55C3, 0xDCCB, 0x55DB, 0xDCCC, 0x55CC,\t0xDCCD, 0x55D0, 0xDCCE, 0x55CB, 0xDCCF, 0x55CA, 0xDCD0, 0x55DD,\r\n\t0xDCD1, 0x55C0, 0xDCD2, 0x55D4, 0xDCD3, 0x55C4, 0xDCD4, 0x55E9,\t0xDCD5, 0x55BF, 0xDCD6, 0x55D2, 0xDCD7, 0x558D, 0xDCD8, 0x55CF,\r\n\t0xDCD9, 0x55D5, 0xDCDA, 0x55E2, 0xDCDB, 0x55D6, 0xDCDC, 0x55C8,\t0xDCDD, 0x55F2, 0xDCDE, 0x55CD, 0xDCDF, 0x55D9, 0xDCE0, 0x55C2,\r\n\t0xDCE1, 0x5714, 0xDCE2, 0x5853, 0xDCE3, 0x5868, 0xDCE4, 0x5864,\t0xDCE5, 0x584F, 0xDCE6, 0x584D, 0xDCE7, 0x5849, 0xDCE8, 0x586F,\r\n\t0xDCE9, 0x5855, 0xDCEA, 0x584E, 0xDCEB, 0x585D, 0xDCEC, 0x5859,\t0xDCED, 0x5865, 0xDCEE, 0x585B, 0xDCEF, 0x583D, 0xDCF0, 0x5863,\r\n\t0xDCF1, 0x5871, 0xDCF2, 0x58FC, 0xDCF3, 0x5AC7, 0xDCF4, 0x5AC4,\t0xDCF5, 0x5ACB, 0xDCF6, 0x5ABA, 0xDCF7, 0x5AB8, 0xDCF8, 0x5AB1,\r\n\t0xDCF9, 0x5AB5, 0xDCFA, 0x5AB0, 0xDCFB, 0x5ABF, 0xDCFC, 0x5AC8,\t0xDCFD, 0x5ABB, 0xDCFE, 0x5AC6, 0xDD40, 0x5AB7, 0xDD41, 0x5AC0,\r\n\t0xDD42, 0x5ACA, 0xDD43, 0x5AB4, 0xDD44, 0x5AB6, 0xDD45, 0x5ACD,\t0xDD46, 0x5AB9, 0xDD47, 0x5A90, 0xDD48, 0x5BD6, 0xDD49, 0x5BD8,\r\n\t0xDD4A, 0x5BD9, 0xDD4B, 0x5C1F, 0xDD4C, 0x5C33, 0xDD4D, 0x5D71,\t0xDD4E, 0x5D63, 0xDD4F, 0x5D4A, 0xDD50, 0x5D65, 0xDD51, 0x5D72,\r\n\t0xDD52, 0x5D6C, 0xDD53, 0x5D5E, 0xDD54, 0x5D68, 0xDD55, 0x5D67,\t0xDD56, 0x5D62, 0xDD57, 0x5DF0, 0xDD58, 0x5E4F, 0xDD59, 0x5E4E,\r\n\t0xDD5A, 0x5E4A, 0xDD5B, 0x5E4D, 0xDD5C, 0x5E4B, 0xDD5D, 0x5EC5,\t0xDD5E, 0x5ECC, 0xDD5F, 0x5EC6, 0xDD60, 0x5ECB, 0xDD61, 0x5EC7,\r\n\t0xDD62, 0x5F40, 0xDD63, 0x5FAF, 0xDD64, 0x5FAD, 0xDD65, 0x60F7,\t0xDD66, 0x6149, 0xDD67, 0x614A, 0xDD68, 0x612B, 0xDD69, 0x6145,\r\n\t0xDD6A, 0x6136, 0xDD6B, 0x6132, 0xDD6C, 0x612E, 0xDD6D, 0x6146,\t0xDD6E, 0x612F, 0xDD6F, 0x614F, 0xDD70, 0x6129, 0xDD71, 0x6140,\r\n\t0xDD72, 0x6220, 0xDD73, 0x9168, 0xDD74, 0x6223, 0xDD75, 0x6225,\t0xDD76, 0x6224, 0xDD77, 0x63C5, 0xDD78, 0x63F1, 0xDD79, 0x63EB,\r\n\t0xDD7A, 0x6410, 0xDD7B, 0x6412, 0xDD7C, 0x6409, 0xDD7D, 0x6420,\t0xDD7E, 0x6424, 0xDDA1, 0x6433, 0xDDA2, 0x6443, 0xDDA3, 0x641F,\r\n\t0xDDA4, 0x6415, 0xDDA5, 0x6418, 0xDDA6, 0x6439, 0xDDA7, 0x6437,\t0xDDA8, 0x6422, 0xDDA9, 0x6423, 0xDDAA, 0x640C, 0xDDAB, 0x6426,\r\n\t0xDDAC, 0x6430, 0xDDAD, 0x6428, 0xDDAE, 0x6441, 0xDDAF, 0x6435,\t0xDDB0, 0x642F, 0xDDB1, 0x640A, 0xDDB2, 0x641A, 0xDDB3, 0x6440,\r\n\t0xDDB4, 0x6425, 0xDDB5, 0x6427, 0xDDB6, 0x640B, 0xDDB7, 0x63E7,\t0xDDB8, 0x641B, 0xDDB9, 0x642E, 0xDDBA, 0x6421, 0xDDBB, 0x640E,\r\n\t0xDDBC, 0x656F, 0xDDBD, 0x6592, 0xDDBE, 0x65D3, 0xDDBF, 0x6686,\t0xDDC0, 0x668C, 0xDDC1, 0x6695, 0xDDC2, 0x6690, 0xDDC3, 0x668B,\r\n\t0xDDC4, 0x668A, 0xDDC5, 0x6699, 0xDDC6, 0x6694, 0xDDC7, 0x6678,\t0xDDC8, 0x6720, 0xDDC9, 0x6966, 0xDDCA, 0x695F, 0xDDCB, 0x6938,\r\n\t0xDDCC, 0x694E, 0xDDCD, 0x6962, 0xDDCE, 0x6971, 0xDDCF, 0x693F,\t0xDDD0, 0x6945, 0xDDD1, 0x696A, 0xDDD2, 0x6939, 0xDDD3, 0x6942,\r\n\t0xDDD4, 0x6957, 0xDDD5, 0x6959, 0xDDD6, 0x697A, 0xDDD7, 0x6948,\t0xDDD8, 0x6949, 0xDDD9, 0x6935, 0xDDDA, 0x696C, 0xDDDB, 0x6933,\r\n\t0xDDDC, 0x693D, 0xDDDD, 0x6965, 0xDDDE, 0x68F0, 0xDDDF, 0x6978,\t0xDDE0, 0x6934, 0xDDE1, 0x6969, 0xDDE2, 0x6940, 0xDDE3, 0x696F,\r\n\t0xDDE4, 0x6944, 0xDDE5, 0x6976, 0xDDE6, 0x6958, 0xDDE7, 0x6941,\t0xDDE8, 0x6974, 0xDDE9, 0x694C, 0xDDEA, 0x693B, 0xDDEB, 0x694B,\r\n\t0xDDEC, 0x6937, 0xDDED, 0x695C, 0xDDEE, 0x694F, 0xDDEF, 0x6951,\t0xDDF0, 0x6932, 0xDDF1, 0x6952, 0xDDF2, 0x692F, 0xDDF3, 0x697B,\r\n\t0xDDF4, 0x693C, 0xDDF5, 0x6B46, 0xDDF6, 0x6B45, 0xDDF7, 0x6B43,\t0xDDF8, 0x6B42, 0xDDF9, 0x6B48, 0xDDFA, 0x6B41, 0xDDFB, 0x6B9B,\r\n\t0xDDFC, 0xFA0D, 0xDDFD, 0x6BFB, 0xDDFE, 0x6BFC, 0xDE40, 0x6BF9,\t0xDE41, 0x6BF7, 0xDE42, 0x6BF8, 0xDE43, 0x6E9B, 0xDE44, 0x6ED6,\r\n\t0xDE45, 0x6EC8, 0xDE46, 0x6E8F, 0xDE47, 0x6EC0, 0xDE48, 0x6E9F,\t0xDE49, 0x6E93, 0xDE4A, 0x6E94, 0xDE4B, 0x6EA0, 0xDE4C, 0x6EB1,\r\n\t0xDE4D, 0x6EB9, 0xDE4E, 0x6EC6, 0xDE4F, 0x6ED2, 0xDE50, 0x6EBD,\t0xDE51, 0x6EC1, 0xDE52, 0x6E9E, 0xDE53, 0x6EC9, 0xDE54, 0x6EB7,\r\n\t0xDE55, 0x6EB0, 0xDE56, 0x6ECD, 0xDE57, 0x6EA6, 0xDE58, 0x6ECF,\t0xDE59, 0x6EB2, 0xDE5A, 0x6EBE, 0xDE5B, 0x6EC3, 0xDE5C, 0x6EDC,\r\n\t0xDE5D, 0x6ED8, 0xDE5E, 0x6E99, 0xDE5F, 0x6E92, 0xDE60, 0x6E8E,\t0xDE61, 0x6E8D, 0xDE62, 0x6EA4, 0xDE63, 0x6EA1, 0xDE64, 0x6EBF,\r\n\t0xDE65, 0x6EB3, 0xDE66, 0x6ED0, 0xDE67, 0x6ECA, 0xDE68, 0x6E97,\t0xDE69, 0x6EAE, 0xDE6A, 0x6EA3, 0xDE6B, 0x7147, 0xDE6C, 0x7154,\r\n\t0xDE6D, 0x7152, 0xDE6E, 0x7163, 0xDE6F, 0x7160, 0xDE70, 0x7141,\t0xDE71, 0x715D, 0xDE72, 0x7162, 0xDE73, 0x7172, 0xDE74, 0x7178,\r\n\t0xDE75, 0x716A, 0xDE76, 0x7161, 0xDE77, 0x7142, 0xDE78, 0x7158,\t0xDE79, 0x7143, 0xDE7A, 0x714B, 0xDE7B, 0x7170, 0xDE7C, 0x715F,\r\n\t0xDE7D, 0x7150, 0xDE7E, 0x7153, 0xDEA1, 0x7144, 0xDEA2, 0x714D,\t0xDEA3, 0x715A, 0xDEA4, 0x724F, 0xDEA5, 0x728D, 0xDEA6, 0x728C,\r\n\t0xDEA7, 0x7291, 0xDEA8, 0x7290, 0xDEA9, 0x728E, 0xDEAA, 0x733C,\t0xDEAB, 0x7342, 0xDEAC, 0x733B, 0xDEAD, 0x733A, 0xDEAE, 0x7340,\r\n\t0xDEAF, 0x734A, 0xDEB0, 0x7349, 0xDEB1, 0x7444, 0xDEB2, 0x744A,\t0xDEB3, 0x744B, 0xDEB4, 0x7452, 0xDEB5, 0x7451, 0xDEB6, 0x7457,\r\n\t0xDEB7, 0x7440, 0xDEB8, 0x744F, 0xDEB9, 0x7450, 0xDEBA, 0x744E,\t0xDEBB, 0x7442, 0xDEBC, 0x7446, 0xDEBD, 0x744D, 0xDEBE, 0x7454,\r\n\t0xDEBF, 0x74E1, 0xDEC0, 0x74FF, 0xDEC1, 0x74FE, 0xDEC2, 0x74FD,\t0xDEC3, 0x751D, 0xDEC4, 0x7579, 0xDEC5, 0x7577, 0xDEC6, 0x6983,\r\n\t0xDEC7, 0x75EF, 0xDEC8, 0x760F, 0xDEC9, 0x7603, 0xDECA, 0x75F7,\t0xDECB, 0x75FE, 0xDECC, 0x75FC, 0xDECD, 0x75F9, 0xDECE, 0x75F8,\r\n\t0xDECF, 0x7610, 0xDED0, 0x75FB, 0xDED1, 0x75F6, 0xDED2, 0x75ED,\t0xDED3, 0x75F5, 0xDED4, 0x75FD, 0xDED5, 0x7699, 0xDED6, 0x76B5,\r\n\t0xDED7, 0x76DD, 0xDED8, 0x7755, 0xDED9, 0x775F, 0xDEDA, 0x7760,\t0xDEDB, 0x7752, 0xDEDC, 0x7756, 0xDEDD, 0x775A, 0xDEDE, 0x7769,\r\n\t0xDEDF, 0x7767, 0xDEE0, 0x7754, 0xDEE1, 0x7759, 0xDEE2, 0x776D,\t0xDEE3, 0x77E0, 0xDEE4, 0x7887, 0xDEE5, 0x789A, 0xDEE6, 0x7894,\r\n\t0xDEE7, 0x788F, 0xDEE8, 0x7884, 0xDEE9, 0x7895, 0xDEEA, 0x7885,\t0xDEEB, 0x7886, 0xDEEC, 0x78A1, 0xDEED, 0x7883, 0xDEEE, 0x7879,\r\n\t0xDEEF, 0x7899, 0xDEF0, 0x7880, 0xDEF1, 0x7896, 0xDEF2, 0x787B,\t0xDEF3, 0x797C, 0xDEF4, 0x7982, 0xDEF5, 0x797D, 0xDEF6, 0x7979,\r\n\t0xDEF7, 0x7A11, 0xDEF8, 0x7A18, 0xDEF9, 0x7A19, 0xDEFA, 0x7A12,\t0xDEFB, 0x7A17, 0xDEFC, 0x7A15, 0xDEFD, 0x7A22, 0xDEFE, 0x7A13,\r\n\t0xDF40, 0x7A1B, 0xDF41, 0x7A10, 0xDF42, 0x7AA3, 0xDF43, 0x7AA2,\t0xDF44, 0x7A9E, 0xDF45, 0x7AEB, 0xDF46, 0x7B66, 0xDF47, 0x7B64,\r\n\t0xDF48, 0x7B6D, 0xDF49, 0x7B74, 0xDF4A, 0x7B69, 0xDF4B, 0x7B72,\t0xDF4C, 0x7B65, 0xDF4D, 0x7B73, 0xDF4E, 0x7B71, 0xDF4F, 0x7B70,\r\n\t0xDF50, 0x7B61, 0xDF51, 0x7B78, 0xDF52, 0x7B76, 0xDF53, 0x7B63,\t0xDF54, 0x7CB2, 0xDF55, 0x7CB4, 0xDF56, 0x7CAF, 0xDF57, 0x7D88,\r\n\t0xDF58, 0x7D86, 0xDF59, 0x7D80, 0xDF5A, 0x7D8D, 0xDF5B, 0x7D7F,\t0xDF5C, 0x7D85, 0xDF5D, 0x7D7A, 0xDF5E, 0x7D8E, 0xDF5F, 0x7D7B,\r\n\t0xDF60, 0x7D83, 0xDF61, 0x7D7C, 0xDF62, 0x7D8C, 0xDF63, 0x7D94,\t0xDF64, 0x7D84, 0xDF65, 0x7D7D, 0xDF66, 0x7D92, 0xDF67, 0x7F6D,\r\n\t0xDF68, 0x7F6B, 0xDF69, 0x7F67, 0xDF6A, 0x7F68, 0xDF6B, 0x7F6C,\t0xDF6C, 0x7FA6, 0xDF6D, 0x7FA5, 0xDF6E, 0x7FA7, 0xDF6F, 0x7FDB,\r\n\t0xDF70, 0x7FDC, 0xDF71, 0x8021, 0xDF72, 0x8164, 0xDF73, 0x8160,\t0xDF74, 0x8177, 0xDF75, 0x815C, 0xDF76, 0x8169, 0xDF77, 0x815B,\r\n\t0xDF78, 0x8162, 0xDF79, 0x8172, 0xDF7A, 0x6721, 0xDF7B, 0x815E,\t0xDF7C, 0x8176, 0xDF7D, 0x8167, 0xDF7E, 0x816F, 0xDFA1, 0x8144,\r\n\t0xDFA2, 0x8161, 0xDFA3, 0x821D, 0xDFA4, 0x8249, 0xDFA5, 0x8244,\t0xDFA6, 0x8240, 0xDFA7, 0x8242, 0xDFA8, 0x8245, 0xDFA9, 0x84F1,\r\n\t0xDFAA, 0x843F, 0xDFAB, 0x8456, 0xDFAC, 0x8476, 0xDFAD, 0x8479,\t0xDFAE, 0x848F, 0xDFAF, 0x848D, 0xDFB0, 0x8465, 0xDFB1, 0x8451,\r\n\t0xDFB2, 0x8440, 0xDFB3, 0x8486, 0xDFB4, 0x8467, 0xDFB5, 0x8430,\t0xDFB6, 0x844D, 0xDFB7, 0x847D, 0xDFB8, 0x845A, 0xDFB9, 0x8459,\r\n\t0xDFBA, 0x8474, 0xDFBB, 0x8473, 0xDFBC, 0x845D, 0xDFBD, 0x8507,\t0xDFBE, 0x845E, 0xDFBF, 0x8437, 0xDFC0, 0x843A, 0xDFC1, 0x8434,\r\n\t0xDFC2, 0x847A, 0xDFC3, 0x8443, 0xDFC4, 0x8478, 0xDFC5, 0x8432,\t0xDFC6, 0x8445, 0xDFC7, 0x8429, 0xDFC8, 0x83D9, 0xDFC9, 0x844B,\r\n\t0xDFCA, 0x842F, 0xDFCB, 0x8442, 0xDFCC, 0x842D, 0xDFCD, 0x845F,\t0xDFCE, 0x8470, 0xDFCF, 0x8439, 0xDFD0, 0x844E, 0xDFD1, 0x844C,\r\n\t0xDFD2, 0x8452, 0xDFD3, 0x846F, 0xDFD4, 0x84C5, 0xDFD5, 0x848E,\t0xDFD6, 0x843B, 0xDFD7, 0x8447, 0xDFD8, 0x8436, 0xDFD9, 0x8433,\r\n\t0xDFDA, 0x8468, 0xDFDB, 0x847E, 0xDFDC, 0x8444, 0xDFDD, 0x842B,\t0xDFDE, 0x8460, 0xDFDF, 0x8454, 0xDFE0, 0x846E, 0xDFE1, 0x8450,\r\n\t0xDFE2, 0x870B, 0xDFE3, 0x8704, 0xDFE4, 0x86F7, 0xDFE5, 0x870C,\t0xDFE6, 0x86FA, 0xDFE7, 0x86D6, 0xDFE8, 0x86F5, 0xDFE9, 0x874D,\r\n\t0xDFEA, 0x86F8, 0xDFEB, 0x870E, 0xDFEC, 0x8709, 0xDFED, 0x8701,\t0xDFEE, 0x86F6, 0xDFEF, 0x870D, 0xDFF0, 0x8705, 0xDFF1, 0x88D6,\r\n\t0xDFF2, 0x88CB, 0xDFF3, 0x88CD, 0xDFF4, 0x88CE, 0xDFF5, 0x88DE,\t0xDFF6, 0x88DB, 0xDFF7, 0x88DA, 0xDFF8, 0x88CC, 0xDFF9, 0x88D0,\r\n\t0xDFFA, 0x8985, 0xDFFB, 0x899B, 0xDFFC, 0x89DF, 0xDFFD, 0x89E5,\t0xDFFE, 0x89E4, 0xE040, 0x89E1, 0xE041, 0x89E0, 0xE042, 0x89E2,\r\n\t0xE043, 0x89DC, 0xE044, 0x89E6, 0xE045, 0x8A76, 0xE046, 0x8A86,\t0xE047, 0x8A7F, 0xE048, 0x8A61, 0xE049, 0x8A3F, 0xE04A, 0x8A77,\r\n\t0xE04B, 0x8A82, 0xE04C, 0x8A84, 0xE04D, 0x8A75, 0xE04E, 0x8A83,\t0xE04F, 0x8A81, 0xE050, 0x8A74, 0xE051, 0x8A7A, 0xE052, 0x8C3C,\r\n\t0xE053, 0x8C4B, 0xE054, 0x8C4A, 0xE055, 0x8C65, 0xE056, 0x8C64,\t0xE057, 0x8C66, 0xE058, 0x8C86, 0xE059, 0x8C84, 0xE05A, 0x8C85,\r\n\t0xE05B, 0x8CCC, 0xE05C, 0x8D68, 0xE05D, 0x8D69, 0xE05E, 0x8D91,\t0xE05F, 0x8D8C, 0xE060, 0x8D8E, 0xE061, 0x8D8F, 0xE062, 0x8D8D,\r\n\t0xE063, 0x8D93, 0xE064, 0x8D94, 0xE065, 0x8D90, 0xE066, 0x8D92,\t0xE067, 0x8DF0, 0xE068, 0x8DE0, 0xE069, 0x8DEC, 0xE06A, 0x8DF1,\r\n\t0xE06B, 0x8DEE, 0xE06C, 0x8DD0, 0xE06D, 0x8DE9, 0xE06E, 0x8DE3,\t0xE06F, 0x8DE2, 0xE070, 0x8DE7, 0xE071, 0x8DF2, 0xE072, 0x8DEB,\r\n\t0xE073, 0x8DF4, 0xE074, 0x8F06, 0xE075, 0x8EFF, 0xE076, 0x8F01,\t0xE077, 0x8F00, 0xE078, 0x8F05, 0xE079, 0x8F07, 0xE07A, 0x8F08,\r\n\t0xE07B, 0x8F02, 0xE07C, 0x8F0B, 0xE07D, 0x9052, 0xE07E, 0x903F,\t0xE0A1, 0x9044, 0xE0A2, 0x9049, 0xE0A3, 0x903D, 0xE0A4, 0x9110,\r\n\t0xE0A5, 0x910D, 0xE0A6, 0x910F, 0xE0A7, 0x9111, 0xE0A8, 0x9116,\t0xE0A9, 0x9114, 0xE0AA, 0x910B, 0xE0AB, 0x910E, 0xE0AC, 0x916E,\r\n\t0xE0AD, 0x916F, 0xE0AE, 0x9248, 0xE0AF, 0x9252, 0xE0B0, 0x9230,\t0xE0B1, 0x923A, 0xE0B2, 0x9266, 0xE0B3, 0x9233, 0xE0B4, 0x9265,\r\n\t0xE0B5, 0x925E, 0xE0B6, 0x9283, 0xE0B7, 0x922E, 0xE0B8, 0x924A,\t0xE0B9, 0x9246, 0xE0BA, 0x926D, 0xE0BB, 0x926C, 0xE0BC, 0x924F,\r\n\t0xE0BD, 0x9260, 0xE0BE, 0x9267, 0xE0BF, 0x926F, 0xE0C0, 0x9236,\t0xE0C1, 0x9261, 0xE0C2, 0x9270, 0xE0C3, 0x9231, 0xE0C4, 0x9254,\r\n\t0xE0C5, 0x9263, 0xE0C6, 0x9250, 0xE0C7, 0x9272, 0xE0C8, 0x924E,\t0xE0C9, 0x9253, 0xE0CA, 0x924C, 0xE0CB, 0x9256, 0xE0CC, 0x9232,\r\n\t0xE0CD, 0x959F, 0xE0CE, 0x959C, 0xE0CF, 0x959E, 0xE0D0, 0x959B,\t0xE0D1, 0x9692, 0xE0D2, 0x9693, 0xE0D3, 0x9691, 0xE0D4, 0x9697,\r\n\t0xE0D5, 0x96CE, 0xE0D6, 0x96FA, 0xE0D7, 0x96FD, 0xE0D8, 0x96F8,\t0xE0D9, 0x96F5, 0xE0DA, 0x9773, 0xE0DB, 0x9777, 0xE0DC, 0x9778,\r\n\t0xE0DD, 0x9772, 0xE0DE, 0x980F, 0xE0DF, 0x980D, 0xE0E0, 0x980E,\t0xE0E1, 0x98AC, 0xE0E2, 0x98F6, 0xE0E3, 0x98F9, 0xE0E4, 0x99AF,\r\n\t0xE0E5, 0x99B2, 0xE0E6, 0x99B0, 0xE0E7, 0x99B5, 0xE0E8, 0x9AAD,\t0xE0E9, 0x9AAB, 0xE0EA, 0x9B5B, 0xE0EB, 0x9CEA, 0xE0EC, 0x9CED,\r\n\t0xE0ED, 0x9CE7, 0xE0EE, 0x9E80, 0xE0EF, 0x9EFD, 0xE0F0, 0x50E6,\t0xE0F1, 0x50D4, 0xE0F2, 0x50D7, 0xE0F3, 0x50E8, 0xE0F4, 0x50F3,\r\n\t0xE0F5, 0x50DB, 0xE0F6, 0x50EA, 0xE0F7, 0x50DD, 0xE0F8, 0x50E4,\t0xE0F9, 0x50D3, 0xE0FA, 0x50EC, 0xE0FB, 0x50F0, 0xE0FC, 0x50EF,\r\n\t0xE0FD, 0x50E3, 0xE0FE, 0x50E0, 0xE140, 0x51D8, 0xE141, 0x5280,\t0xE142, 0x5281, 0xE143, 0x52E9, 0xE144, 0x52EB, 0xE145, 0x5330,\r\n\t0xE146, 0x53AC, 0xE147, 0x5627, 0xE148, 0x5615, 0xE149, 0x560C,\t0xE14A, 0x5612, 0xE14B, 0x55FC, 0xE14C, 0x560F, 0xE14D, 0x561C,\r\n\t0xE14E, 0x5601, 0xE14F, 0x5613, 0xE150, 0x5602, 0xE151, 0x55FA,\t0xE152, 0x561D, 0xE153, 0x5604, 0xE154, 0x55FF, 0xE155, 0x55F9,\r\n\t0xE156, 0x5889, 0xE157, 0x587C, 0xE158, 0x5890, 0xE159, 0x5898,\t0xE15A, 0x5886, 0xE15B, 0x5881, 0xE15C, 0x587F, 0xE15D, 0x5874,\r\n\t0xE15E, 0x588B, 0xE15F, 0x587A, 0xE160, 0x5887, 0xE161, 0x5891,\t0xE162, 0x588E, 0xE163, 0x5876, 0xE164, 0x5882, 0xE165, 0x5888,\r\n\t0xE166, 0x587B, 0xE167, 0x5894, 0xE168, 0x588F, 0xE169, 0x58FE,\t0xE16A, 0x596B, 0xE16B, 0x5ADC, 0xE16C, 0x5AEE, 0xE16D, 0x5AE5,\r\n\t0xE16E, 0x5AD5, 0xE16F, 0x5AEA, 0xE170, 0x5ADA, 0xE171, 0x5AED,\t0xE172, 0x5AEB, 0xE173, 0x5AF3, 0xE174, 0x5AE2, 0xE175, 0x5AE0,\r\n\t0xE176, 0x5ADB, 0xE177, 0x5AEC, 0xE178, 0x5ADE, 0xE179, 0x5ADD,\t0xE17A, 0x5AD9, 0xE17B, 0x5AE8, 0xE17C, 0x5ADF, 0xE17D, 0x5B77,\r\n\t0xE17E, 0x5BE0, 0xE1A1, 0x5BE3, 0xE1A2, 0x5C63, 0xE1A3, 0x5D82,\t0xE1A4, 0x5D80, 0xE1A5, 0x5D7D, 0xE1A6, 0x5D86, 0xE1A7, 0x5D7A,\r\n\t0xE1A8, 0x5D81, 0xE1A9, 0x5D77, 0xE1AA, 0x5D8A, 0xE1AB, 0x5D89,\t0xE1AC, 0x5D88, 0xE1AD, 0x5D7E, 0xE1AE, 0x5D7C, 0xE1AF, 0x5D8D,\r\n\t0xE1B0, 0x5D79, 0xE1B1, 0x5D7F, 0xE1B2, 0x5E58, 0xE1B3, 0x5E59,\t0xE1B4, 0x5E53, 0xE1B5, 0x5ED8, 0xE1B6, 0x5ED1, 0xE1B7, 0x5ED7,\r\n\t0xE1B8, 0x5ECE, 0xE1B9, 0x5EDC, 0xE1BA, 0x5ED5, 0xE1BB, 0x5ED9,\t0xE1BC, 0x5ED2, 0xE1BD, 0x5ED4, 0xE1BE, 0x5F44, 0xE1BF, 0x5F43,\r\n\t0xE1C0, 0x5F6F, 0xE1C1, 0x5FB6, 0xE1C2, 0x612C, 0xE1C3, 0x6128,\t0xE1C4, 0x6141, 0xE1C5, 0x615E, 0xE1C6, 0x6171, 0xE1C7, 0x6173,\r\n\t0xE1C8, 0x6152, 0xE1C9, 0x6153, 0xE1CA, 0x6172, 0xE1CB, 0x616C,\t0xE1CC, 0x6180, 0xE1CD, 0x6174, 0xE1CE, 0x6154, 0xE1CF, 0x617A,\r\n\t0xE1D0, 0x615B, 0xE1D1, 0x6165, 0xE1D2, 0x613B, 0xE1D3, 0x616A,\t0xE1D4, 0x6161, 0xE1D5, 0x6156, 0xE1D6, 0x6229, 0xE1D7, 0x6227,\r\n\t0xE1D8, 0x622B, 0xE1D9, 0x642B, 0xE1DA, 0x644D, 0xE1DB, 0x645B,\t0xE1DC, 0x645D, 0xE1DD, 0x6474, 0xE1DE, 0x6476, 0xE1DF, 0x6472,\r\n\t0xE1E0, 0x6473, 0xE1E1, 0x647D, 0xE1E2, 0x6475, 0xE1E3, 0x6466,\t0xE1E4, 0x64A6, 0xE1E5, 0x644E, 0xE1E6, 0x6482, 0xE1E7, 0x645E,\r\n\t0xE1E8, 0x645C, 0xE1E9, 0x644B, 0xE1EA, 0x6453, 0xE1EB, 0x6460,\t0xE1EC, 0x6450, 0xE1ED, 0x647F, 0xE1EE, 0x643F, 0xE1EF, 0x646C,\r\n\t0xE1F0, 0x646B, 0xE1F1, 0x6459, 0xE1F2, 0x6465, 0xE1F3, 0x6477,\t0xE1F4, 0x6573, 0xE1F5, 0x65A0, 0xE1F6, 0x66A1, 0xE1F7, 0x66A0,\r\n\t0xE1F8, 0x669F, 0xE1F9, 0x6705, 0xE1FA, 0x6704, 0xE1FB, 0x6722,\t0xE1FC, 0x69B1, 0xE1FD, 0x69B6, 0xE1FE, 0x69C9, 0xE240, 0x69A0,\r\n\t0xE241, 0x69CE, 0xE242, 0x6996, 0xE243, 0x69B0, 0xE244, 0x69AC,\t0xE245, 0x69BC, 0xE246, 0x6991, 0xE247, 0x6999, 0xE248, 0x698E,\r\n\t0xE249, 0x69A7, 0xE24A, 0x698D, 0xE24B, 0x69A9, 0xE24C, 0x69BE,\t0xE24D, 0x69AF, 0xE24E, 0x69BF, 0xE24F, 0x69C4, 0xE250, 0x69BD,\r\n\t0xE251, 0x69A4, 0xE252, 0x69D4, 0xE253, 0x69B9, 0xE254, 0x69CA,\t0xE255, 0x699A, 0xE256, 0x69CF, 0xE257, 0x69B3, 0xE258, 0x6993,\r\n\t0xE259, 0x69AA, 0xE25A, 0x69A1, 0xE25B, 0x699E, 0xE25C, 0x69D9,\t0xE25D, 0x6997, 0xE25E, 0x6990, 0xE25F, 0x69C2, 0xE260, 0x69B5,\r\n\t0xE261, 0x69A5, 0xE262, 0x69C6, 0xE263, 0x6B4A, 0xE264, 0x6B4D,\t0xE265, 0x6B4B, 0xE266, 0x6B9E, 0xE267, 0x6B9F, 0xE268, 0x6BA0,\r\n\t0xE269, 0x6BC3, 0xE26A, 0x6BC4, 0xE26B, 0x6BFE, 0xE26C, 0x6ECE,\t0xE26D, 0x6EF5, 0xE26E, 0x6EF1, 0xE26F, 0x6F03, 0xE270, 0x6F25,\r\n\t0xE271, 0x6EF8, 0xE272, 0x6F37, 0xE273, 0x6EFB, 0xE274, 0x6F2E,\t0xE275, 0x6F09, 0xE276, 0x6F4E, 0xE277, 0x6F19, 0xE278, 0x6F1A,\r\n\t0xE279, 0x6F27, 0xE27A, 0x6F18, 0xE27B, 0x6F3B, 0xE27C, 0x6F12,\t0xE27D, 0x6EED, 0xE27E, 0x6F0A, 0xE2A1, 0x6F36, 0xE2A2, 0x6F73,\r\n\t0xE2A3, 0x6EF9, 0xE2A4, 0x6EEE, 0xE2A5, 0x6F2D, 0xE2A6, 0x6F40,\t0xE2A7, 0x6F30, 0xE2A8, 0x6F3C, 0xE2A9, 0x6F35, 0xE2AA, 0x6EEB,\r\n\t0xE2AB, 0x6F07, 0xE2AC, 0x6F0E, 0xE2AD, 0x6F43, 0xE2AE, 0x6F05,\t0xE2AF, 0x6EFD, 0xE2B0, 0x6EF6, 0xE2B1, 0x6F39, 0xE2B2, 0x6F1C,\r\n\t0xE2B3, 0x6EFC, 0xE2B4, 0x6F3A, 0xE2B5, 0x6F1F, 0xE2B6, 0x6F0D,\t0xE2B7, 0x6F1E, 0xE2B8, 0x6F08, 0xE2B9, 0x6F21, 0xE2BA, 0x7187,\r\n\t0xE2BB, 0x7190, 0xE2BC, 0x7189, 0xE2BD, 0x7180, 0xE2BE, 0x7185,\t0xE2BF, 0x7182, 0xE2C0, 0x718F, 0xE2C1, 0x717B, 0xE2C2, 0x7186,\r\n\t0xE2C3, 0x7181, 0xE2C4, 0x7197, 0xE2C5, 0x7244, 0xE2C6, 0x7253,\t0xE2C7, 0x7297, 0xE2C8, 0x7295, 0xE2C9, 0x7293, 0xE2CA, 0x7343,\r\n\t0xE2CB, 0x734D, 0xE2CC, 0x7351, 0xE2CD, 0x734C, 0xE2CE, 0x7462,\t0xE2CF, 0x7473, 0xE2D0, 0x7471, 0xE2D1, 0x7475, 0xE2D2, 0x7472,\r\n\t0xE2D3, 0x7467, 0xE2D4, 0x746E, 0xE2D5, 0x7500, 0xE2D6, 0x7502,\t0xE2D7, 0x7503, 0xE2D8, 0x757D, 0xE2D9, 0x7590, 0xE2DA, 0x7616,\r\n\t0xE2DB, 0x7608, 0xE2DC, 0x760C, 0xE2DD, 0x7615, 0xE2DE, 0x7611,\t0xE2DF, 0x760A, 0xE2E0, 0x7614, 0xE2E1, 0x76B8, 0xE2E2, 0x7781,\r\n\t0xE2E3, 0x777C, 0xE2E4, 0x7785, 0xE2E5, 0x7782, 0xE2E6, 0x776E,\t0xE2E7, 0x7780, 0xE2E8, 0x776F, 0xE2E9, 0x777E, 0xE2EA, 0x7783,\r\n\t0xE2EB, 0x78B2, 0xE2EC, 0x78AA, 0xE2ED, 0x78B4, 0xE2EE, 0x78AD,\t0xE2EF, 0x78A8, 0xE2F0, 0x787E, 0xE2F1, 0x78AB, 0xE2F2, 0x789E,\r\n\t0xE2F3, 0x78A5, 0xE2F4, 0x78A0, 0xE2F5, 0x78AC, 0xE2F6, 0x78A2,\t0xE2F7, 0x78A4, 0xE2F8, 0x7998, 0xE2F9, 0x798A, 0xE2FA, 0x798B,\r\n\t0xE2FB, 0x7996, 0xE2FC, 0x7995, 0xE2FD, 0x7994, 0xE2FE, 0x7993,\t0xE340, 0x7997, 0xE341, 0x7988, 0xE342, 0x7992, 0xE343, 0x7990,\r\n\t0xE344, 0x7A2B, 0xE345, 0x7A4A, 0xE346, 0x7A30, 0xE347, 0x7A2F,\t0xE348, 0x7A28, 0xE349, 0x7A26, 0xE34A, 0x7AA8, 0xE34B, 0x7AAB,\r\n\t0xE34C, 0x7AAC, 0xE34D, 0x7AEE, 0xE34E, 0x7B88, 0xE34F, 0x7B9C,\t0xE350, 0x7B8A, 0xE351, 0x7B91, 0xE352, 0x7B90, 0xE353, 0x7B96,\r\n\t0xE354, 0x7B8D, 0xE355, 0x7B8C, 0xE356, 0x7B9B, 0xE357, 0x7B8E,\t0xE358, 0x7B85, 0xE359, 0x7B98, 0xE35A, 0x5284, 0xE35B, 0x7B99,\r\n\t0xE35C, 0x7BA4, 0xE35D, 0x7B82, 0xE35E, 0x7CBB, 0xE35F, 0x7CBF,\t0xE360, 0x7CBC, 0xE361, 0x7CBA, 0xE362, 0x7DA7, 0xE363, 0x7DB7,\r\n\t0xE364, 0x7DC2, 0xE365, 0x7DA3, 0xE366, 0x7DAA, 0xE367, 0x7DC1,\t0xE368, 0x7DC0, 0xE369, 0x7DC5, 0xE36A, 0x7D9D, 0xE36B, 0x7DCE,\r\n\t0xE36C, 0x7DC4, 0xE36D, 0x7DC6, 0xE36E, 0x7DCB, 0xE36F, 0x7DCC,\t0xE370, 0x7DAF, 0xE371, 0x7DB9, 0xE372, 0x7D96, 0xE373, 0x7DBC,\r\n\t0xE374, 0x7D9F, 0xE375, 0x7DA6, 0xE376, 0x7DAE, 0xE377, 0x7DA9,\t0xE378, 0x7DA1, 0xE379, 0x7DC9, 0xE37A, 0x7F73, 0xE37B, 0x7FE2,\r\n\t0xE37C, 0x7FE3, 0xE37D, 0x7FE5, 0xE37E, 0x7FDE, 0xE3A1, 0x8024,\t0xE3A2, 0x805D, 0xE3A3, 0x805C, 0xE3A4, 0x8189, 0xE3A5, 0x8186,\r\n\t0xE3A6, 0x8183, 0xE3A7, 0x8187, 0xE3A8, 0x818D, 0xE3A9, 0x818C,\t0xE3AA, 0x818B, 0xE3AB, 0x8215, 0xE3AC, 0x8497, 0xE3AD, 0x84A4,\r\n\t0xE3AE, 0x84A1, 0xE3AF, 0x849F, 0xE3B0, 0x84BA, 0xE3B1, 0x84CE,\t0xE3B2, 0x84C2, 0xE3B3, 0x84AC, 0xE3B4, 0x84AE, 0xE3B5, 0x84AB,\r\n\t0xE3B6, 0x84B9, 0xE3B7, 0x84B4, 0xE3B8, 0x84C1, 0xE3B9, 0x84CD,\t0xE3BA, 0x84AA, 0xE3BB, 0x849A, 0xE3BC, 0x84B1, 0xE3BD, 0x84D0,\r\n\t0xE3BE, 0x849D, 0xE3BF, 0x84A7, 0xE3C0, 0x84BB, 0xE3C1, 0x84A2,\t0xE3C2, 0x8494, 0xE3C3, 0x84C7, 0xE3C4, 0x84CC, 0xE3C5, 0x849B,\r\n\t0xE3C6, 0x84A9, 0xE3C7, 0x84AF, 0xE3C8, 0x84A8, 0xE3C9, 0x84D6,\t0xE3CA, 0x8498, 0xE3CB, 0x84B6, 0xE3CC, 0x84CF, 0xE3CD, 0x84A0,\r\n\t0xE3CE, 0x84D7, 0xE3CF, 0x84D4, 0xE3D0, 0x84D2, 0xE3D1, 0x84DB,\t0xE3D2, 0x84B0, 0xE3D3, 0x8491, 0xE3D4, 0x8661, 0xE3D5, 0x8733,\r\n\t0xE3D6, 0x8723, 0xE3D7, 0x8728, 0xE3D8, 0x876B, 0xE3D9, 0x8740,\t0xE3DA, 0x872E, 0xE3DB, 0x871E, 0xE3DC, 0x8721, 0xE3DD, 0x8719,\r\n\t0xE3DE, 0x871B, 0xE3DF, 0x8743, 0xE3E0, 0x872C, 0xE3E1, 0x8741,\t0xE3E2, 0x873E, 0xE3E3, 0x8746, 0xE3E4, 0x8720, 0xE3E5, 0x8732,\r\n\t0xE3E6, 0x872A, 0xE3E7, 0x872D, 0xE3E8, 0x873C, 0xE3E9, 0x8712,\t0xE3EA, 0x873A, 0xE3EB, 0x8731, 0xE3EC, 0x8735, 0xE3ED, 0x8742,\r\n\t0xE3EE, 0x8726, 0xE3EF, 0x8727, 0xE3F0, 0x8738, 0xE3F1, 0x8724,\t0xE3F2, 0x871A, 0xE3F3, 0x8730, 0xE3F4, 0x8711, 0xE3F5, 0x88F7,\r\n\t0xE3F6, 0x88E7, 0xE3F7, 0x88F1, 0xE3F8, 0x88F2, 0xE3F9, 0x88FA,\t0xE3FA, 0x88FE, 0xE3FB, 0x88EE, 0xE3FC, 0x88FC, 0xE3FD, 0x88F6,\r\n\t0xE3FE, 0x88FB, 0xE440, 0x88F0, 0xE441, 0x88EC, 0xE442, 0x88EB,\t0xE443, 0x899D, 0xE444, 0x89A1, 0xE445, 0x899F, 0xE446, 0x899E,\r\n\t0xE447, 0x89E9, 0xE448, 0x89EB, 0xE449, 0x89E8, 0xE44A, 0x8AAB,\t0xE44B, 0x8A99, 0xE44C, 0x8A8B, 0xE44D, 0x8A92, 0xE44E, 0x8A8F,\r\n\t0xE44F, 0x8A96, 0xE450, 0x8C3D, 0xE451, 0x8C68, 0xE452, 0x8C69,\t0xE453, 0x8CD5, 0xE454, 0x8CCF, 0xE455, 0x8CD7, 0xE456, 0x8D96,\r\n\t0xE457, 0x8E09, 0xE458, 0x8E02, 0xE459, 0x8DFF, 0xE45A, 0x8E0D,\t0xE45B, 0x8DFD, 0xE45C, 0x8E0A, 0xE45D, 0x8E03, 0xE45E, 0x8E07,\r\n\t0xE45F, 0x8E06, 0xE460, 0x8E05, 0xE461, 0x8DFE, 0xE462, 0x8E00,\t0xE463, 0x8E04, 0xE464, 0x8F10, 0xE465, 0x8F11, 0xE466, 0x8F0E,\r\n\t0xE467, 0x8F0D, 0xE468, 0x9123, 0xE469, 0x911C, 0xE46A, 0x9120,\t0xE46B, 0x9122, 0xE46C, 0x911F, 0xE46D, 0x911D, 0xE46E, 0x911A,\r\n\t0xE46F, 0x9124, 0xE470, 0x9121, 0xE471, 0x911B, 0xE472, 0x917A,\t0xE473, 0x9172, 0xE474, 0x9179, 0xE475, 0x9173, 0xE476, 0x92A5,\r\n\t0xE477, 0x92A4, 0xE478, 0x9276, 0xE479, 0x929B, 0xE47A, 0x927A,\t0xE47B, 0x92A0, 0xE47C, 0x9294, 0xE47D, 0x92AA, 0xE47E, 0x928D,\r\n\t0xE4A1, 0x92A6, 0xE4A2, 0x929A, 0xE4A3, 0x92AB, 0xE4A4, 0x9279,\t0xE4A5, 0x9297, 0xE4A6, 0x927F, 0xE4A7, 0x92A3, 0xE4A8, 0x92EE,\r\n\t0xE4A9, 0x928E, 0xE4AA, 0x9282, 0xE4AB, 0x9295, 0xE4AC, 0x92A2,\t0xE4AD, 0x927D, 0xE4AE, 0x9288, 0xE4AF, 0x92A1, 0xE4B0, 0x928A,\r\n\t0xE4B1, 0x9286, 0xE4B2, 0x928C, 0xE4B3, 0x9299, 0xE4B4, 0x92A7,\t0xE4B5, 0x927E, 0xE4B6, 0x9287, 0xE4B7, 0x92A9, 0xE4B8, 0x929D,\r\n\t0xE4B9, 0x928B, 0xE4BA, 0x922D, 0xE4BB, 0x969E, 0xE4BC, 0x96A1,\t0xE4BD, 0x96FF, 0xE4BE, 0x9758, 0xE4BF, 0x977D, 0xE4C0, 0x977A,\r\n\t0xE4C1, 0x977E, 0xE4C2, 0x9783, 0xE4C3, 0x9780, 0xE4C4, 0x9782,\t0xE4C5, 0x977B, 0xE4C6, 0x9784, 0xE4C7, 0x9781, 0xE4C8, 0x977F,\r\n\t0xE4C9, 0x97CE, 0xE4CA, 0x97CD, 0xE4CB, 0x9816, 0xE4CC, 0x98AD,\t0xE4CD, 0x98AE, 0xE4CE, 0x9902, 0xE4CF, 0x9900, 0xE4D0, 0x9907,\r\n\t0xE4D1, 0x999D, 0xE4D2, 0x999C, 0xE4D3, 0x99C3, 0xE4D4, 0x99B9,\t0xE4D5, 0x99BB, 0xE4D6, 0x99BA, 0xE4D7, 0x99C2, 0xE4D8, 0x99BD,\r\n\t0xE4D9, 0x99C7, 0xE4DA, 0x9AB1, 0xE4DB, 0x9AE3, 0xE4DC, 0x9AE7,\t0xE4DD, 0x9B3E, 0xE4DE, 0x9B3F, 0xE4DF, 0x9B60, 0xE4E0, 0x9B61,\r\n\t0xE4E1, 0x9B5F, 0xE4E2, 0x9CF1, 0xE4E3, 0x9CF2, 0xE4E4, 0x9CF5,\t0xE4E5, 0x9EA7, 0xE4E6, 0x50FF, 0xE4E7, 0x5103, 0xE4E8, 0x5130,\r\n\t0xE4E9, 0x50F8, 0xE4EA, 0x5106, 0xE4EB, 0x5107, 0xE4EC, 0x50F6,\t0xE4ED, 0x50FE, 0xE4EE, 0x510B, 0xE4EF, 0x510C, 0xE4F0, 0x50FD,\r\n\t0xE4F1, 0x510A, 0xE4F2, 0x528B, 0xE4F3, 0x528C, 0xE4F4, 0x52F1,\t0xE4F5, 0x52EF, 0xE4F6, 0x5648, 0xE4F7, 0x5642, 0xE4F8, 0x564C,\r\n\t0xE4F9, 0x5635, 0xE4FA, 0x5641, 0xE4FB, 0x564A, 0xE4FC, 0x5649,\t0xE4FD, 0x5646, 0xE4FE, 0x5658, 0xE540, 0x565A, 0xE541, 0x5640,\r\n\t0xE542, 0x5633, 0xE543, 0x563D, 0xE544, 0x562C, 0xE545, 0x563E,\t0xE546, 0x5638, 0xE547, 0x562A, 0xE548, 0x563A, 0xE549, 0x571A,\r\n\t0xE54A, 0x58AB, 0xE54B, 0x589D, 0xE54C, 0x58B1, 0xE54D, 0x58A0,\t0xE54E, 0x58A3, 0xE54F, 0x58AF, 0xE550, 0x58AC, 0xE551, 0x58A5,\r\n\t0xE552, 0x58A1, 0xE553, 0x58FF, 0xE554, 0x5AFF, 0xE555, 0x5AF4,\t0xE556, 0x5AFD, 0xE557, 0x5AF7, 0xE558, 0x5AF6, 0xE559, 0x5B03,\r\n\t0xE55A, 0x5AF8, 0xE55B, 0x5B02, 0xE55C, 0x5AF9, 0xE55D, 0x5B01,\t0xE55E, 0x5B07, 0xE55F, 0x5B05, 0xE560, 0x5B0F, 0xE561, 0x5C67,\r\n\t0xE562, 0x5D99, 0xE563, 0x5D97, 0xE564, 0x5D9F, 0xE565, 0x5D92,\t0xE566, 0x5DA2, 0xE567, 0x5D93, 0xE568, 0x5D95, 0xE569, 0x5DA0,\r\n\t0xE56A, 0x5D9C, 0xE56B, 0x5DA1, 0xE56C, 0x5D9A, 0xE56D, 0x5D9E,\t0xE56E, 0x5E69, 0xE56F, 0x5E5D, 0xE570, 0x5E60, 0xE571, 0x5E5C,\r\n\t0xE572, 0x7DF3, 0xE573, 0x5EDB, 0xE574, 0x5EDE, 0xE575, 0x5EE1,\t0xE576, 0x5F49, 0xE577, 0x5FB2, 0xE578, 0x618B, 0xE579, 0x6183,\r\n\t0xE57A, 0x6179, 0xE57B, 0x61B1, 0xE57C, 0x61B0, 0xE57D, 0x61A2,\t0xE57E, 0x6189, 0xE5A1, 0x619B, 0xE5A2, 0x6193, 0xE5A3, 0x61AF,\r\n\t0xE5A4, 0x61AD, 0xE5A5, 0x619F, 0xE5A6, 0x6192, 0xE5A7, 0x61AA,\t0xE5A8, 0x61A1, 0xE5A9, 0x618D, 0xE5AA, 0x6166, 0xE5AB, 0x61B3,\r\n\t0xE5AC, 0x622D, 0xE5AD, 0x646E, 0xE5AE, 0x6470, 0xE5AF, 0x6496,\t0xE5B0, 0x64A0, 0xE5B1, 0x6485, 0xE5B2, 0x6497, 0xE5B3, 0x649C,\r\n\t0xE5B4, 0x648F, 0xE5B5, 0x648B, 0xE5B6, 0x648A, 0xE5B7, 0x648C,\t0xE5B8, 0x64A3, 0xE5B9, 0x649F, 0xE5BA, 0x6468, 0xE5BB, 0x64B1,\r\n\t0xE5BC, 0x6498, 0xE5BD, 0x6576, 0xE5BE, 0x657A, 0xE5BF, 0x6579,\t0xE5C0, 0x657B, 0xE5C1, 0x65B2, 0xE5C2, 0x65B3, 0xE5C3, 0x66B5,\r\n\t0xE5C4, 0x66B0, 0xE5C5, 0x66A9, 0xE5C6, 0x66B2, 0xE5C7, 0x66B7,\t0xE5C8, 0x66AA, 0xE5C9, 0x66AF, 0xE5CA, 0x6A00, 0xE5CB, 0x6A06,\r\n\t0xE5CC, 0x6A17, 0xE5CD, 0x69E5, 0xE5CE, 0x69F8, 0xE5CF, 0x6A15,\t0xE5D0, 0x69F1, 0xE5D1, 0x69E4, 0xE5D2, 0x6A20, 0xE5D3, 0x69FF,\r\n\t0xE5D4, 0x69EC, 0xE5D5, 0x69E2, 0xE5D6, 0x6A1B, 0xE5D7, 0x6A1D,\t0xE5D8, 0x69FE, 0xE5D9, 0x6A27, 0xE5DA, 0x69F2, 0xE5DB, 0x69EE,\r\n\t0xE5DC, 0x6A14, 0xE5DD, 0x69F7, 0xE5DE, 0x69E7, 0xE5DF, 0x6A40,\t0xE5E0, 0x6A08, 0xE5E1, 0x69E6, 0xE5E2, 0x69FB, 0xE5E3, 0x6A0D,\r\n\t0xE5E4, 0x69FC, 0xE5E5, 0x69EB, 0xE5E6, 0x6A09, 0xE5E7, 0x6A04,\t0xE5E8, 0x6A18, 0xE5E9, 0x6A25, 0xE5EA, 0x6A0F, 0xE5EB, 0x69F6,\r\n\t0xE5EC, 0x6A26, 0xE5ED, 0x6A07, 0xE5EE, 0x69F4, 0xE5EF, 0x6A16,\t0xE5F0, 0x6B51, 0xE5F1, 0x6BA5, 0xE5F2, 0x6BA3, 0xE5F3, 0x6BA2,\r\n\t0xE5F4, 0x6BA6, 0xE5F5, 0x6C01, 0xE5F6, 0x6C00, 0xE5F7, 0x6BFF,\t0xE5F8, 0x6C02, 0xE5F9, 0x6F41, 0xE5FA, 0x6F26, 0xE5FB, 0x6F7E,\r\n\t0xE5FC, 0x6F87, 0xE5FD, 0x6FC6, 0xE5FE, 0x6F92, 0xE640, 0x6F8D,\t0xE641, 0x6F89, 0xE642, 0x6F8C, 0xE643, 0x6F62, 0xE644, 0x6F4F,\r\n\t0xE645, 0x6F85, 0xE646, 0x6F5A, 0xE647, 0x6F96, 0xE648, 0x6F76,\t0xE649, 0x6F6C, 0xE64A, 0x6F82, 0xE64B, 0x6F55, 0xE64C, 0x6F72,\r\n\t0xE64D, 0x6F52, 0xE64E, 0x6F50, 0xE64F, 0x6F57, 0xE650, 0x6F94,\t0xE651, 0x6F93, 0xE652, 0x6F5D, 0xE653, 0x6F00, 0xE654, 0x6F61,\r\n\t0xE655, 0x6F6B, 0xE656, 0x6F7D, 0xE657, 0x6F67, 0xE658, 0x6F90,\t0xE659, 0x6F53, 0xE65A, 0x6F8B, 0xE65B, 0x6F69, 0xE65C, 0x6F7F,\r\n\t0xE65D, 0x6F95, 0xE65E, 0x6F63, 0xE65F, 0x6F77, 0xE660, 0x6F6A,\t0xE661, 0x6F7B, 0xE662, 0x71B2, 0xE663, 0x71AF, 0xE664, 0x719B,\r\n\t0xE665, 0x71B0, 0xE666, 0x71A0, 0xE667, 0x719A, 0xE668, 0x71A9,\t0xE669, 0x71B5, 0xE66A, 0x719D, 0xE66B, 0x71A5, 0xE66C, 0x719E,\r\n\t0xE66D, 0x71A4, 0xE66E, 0x71A1, 0xE66F, 0x71AA, 0xE670, 0x719C,\t0xE671, 0x71A7, 0xE672, 0x71B3, 0xE673, 0x7298, 0xE674, 0x729A,\r\n\t0xE675, 0x7358, 0xE676, 0x7352, 0xE677, 0x735E, 0xE678, 0x735F,\t0xE679, 0x7360, 0xE67A, 0x735D, 0xE67B, 0x735B, 0xE67C, 0x7361,\r\n\t0xE67D, 0x735A, 0xE67E, 0x7359, 0xE6A1, 0x7362, 0xE6A2, 0x7487,\t0xE6A3, 0x7489, 0xE6A4, 0x748A, 0xE6A5, 0x7486, 0xE6A6, 0x7481,\r\n\t0xE6A7, 0x747D, 0xE6A8, 0x7485, 0xE6A9, 0x7488, 0xE6AA, 0x747C,\t0xE6AB, 0x7479, 0xE6AC, 0x7508, 0xE6AD, 0x7507, 0xE6AE, 0x757E,\r\n\t0xE6AF, 0x7625, 0xE6B0, 0x761E, 0xE6B1, 0x7619, 0xE6B2, 0x761D,\t0xE6B3, 0x761C, 0xE6B4, 0x7623, 0xE6B5, 0x761A, 0xE6B6, 0x7628,\r\n\t0xE6B7, 0x761B, 0xE6B8, 0x769C, 0xE6B9, 0x769D, 0xE6BA, 0x769E,\t0xE6BB, 0x769B, 0xE6BC, 0x778D, 0xE6BD, 0x778F, 0xE6BE, 0x7789,\r\n\t0xE6BF, 0x7788, 0xE6C0, 0x78CD, 0xE6C1, 0x78BB, 0xE6C2, 0x78CF,\t0xE6C3, 0x78CC, 0xE6C4, 0x78D1, 0xE6C5, 0x78CE, 0xE6C6, 0x78D4,\r\n\t0xE6C7, 0x78C8, 0xE6C8, 0x78C3, 0xE6C9, 0x78C4, 0xE6CA, 0x78C9,\t0xE6CB, 0x799A, 0xE6CC, 0x79A1, 0xE6CD, 0x79A0, 0xE6CE, 0x799C,\r\n\t0xE6CF, 0x79A2, 0xE6D0, 0x799B, 0xE6D1, 0x6B76, 0xE6D2, 0x7A39,\t0xE6D3, 0x7AB2, 0xE6D4, 0x7AB4, 0xE6D5, 0x7AB3, 0xE6D6, 0x7BB7,\r\n\t0xE6D7, 0x7BCB, 0xE6D8, 0x7BBE, 0xE6D9, 0x7BAC, 0xE6DA, 0x7BCE,\t0xE6DB, 0x7BAF, 0xE6DC, 0x7BB9, 0xE6DD, 0x7BCA, 0xE6DE, 0x7BB5,\r\n\t0xE6DF, 0x7CC5, 0xE6E0, 0x7CC8, 0xE6E1, 0x7CCC, 0xE6E2, 0x7CCB,\t0xE6E3, 0x7DF7, 0xE6E4, 0x7DDB, 0xE6E5, 0x7DEA, 0xE6E6, 0x7DE7,\r\n\t0xE6E7, 0x7DD7, 0xE6E8, 0x7DE1, 0xE6E9, 0x7E03, 0xE6EA, 0x7DFA,\t0xE6EB, 0x7DE6, 0xE6EC, 0x7DF6, 0xE6ED, 0x7DF1, 0xE6EE, 0x7DF0,\r\n\t0xE6EF, 0x7DEE, 0xE6F0, 0x7DDF, 0xE6F1, 0x7F76, 0xE6F2, 0x7FAC,\t0xE6F3, 0x7FB0, 0xE6F4, 0x7FAD, 0xE6F5, 0x7FED, 0xE6F6, 0x7FEB,\r\n\t0xE6F7, 0x7FEA, 0xE6F8, 0x7FEC, 0xE6F9, 0x7FE6, 0xE6FA, 0x7FE8,\t0xE6FB, 0x8064, 0xE6FC, 0x8067, 0xE6FD, 0x81A3, 0xE6FE, 0x819F,\r\n\t0xE740, 0x819E, 0xE741, 0x8195, 0xE742, 0x81A2, 0xE743, 0x8199,\t0xE744, 0x8197, 0xE745, 0x8216, 0xE746, 0x824F, 0xE747, 0x8253,\r\n\t0xE748, 0x8252, 0xE749, 0x8250, 0xE74A, 0x824E, 0xE74B, 0x8251,\t0xE74C, 0x8524, 0xE74D, 0x853B, 0xE74E, 0x850F, 0xE74F, 0x8500,\r\n\t0xE750, 0x8529, 0xE751, 0x850E, 0xE752, 0x8509, 0xE753, 0x850D,\t0xE754, 0x851F, 0xE755, 0x850A, 0xE756, 0x8527, 0xE757, 0x851C,\r\n\t0xE758, 0x84FB, 0xE759, 0x852B, 0xE75A, 0x84FA, 0xE75B, 0x8508,\t0xE75C, 0x850C, 0xE75D, 0x84F4, 0xE75E, 0x852A, 0xE75F, 0x84F2,\r\n\t0xE760, 0x8515, 0xE761, 0x84F7, 0xE762, 0x84EB, 0xE763, 0x84F3,\t0xE764, 0x84FC, 0xE765, 0x8512, 0xE766, 0x84EA, 0xE767, 0x84E9,\r\n\t0xE768, 0x8516, 0xE769, 0x84FE, 0xE76A, 0x8528, 0xE76B, 0x851D,\t0xE76C, 0x852E, 0xE76D, 0x8502, 0xE76E, 0x84FD, 0xE76F, 0x851E,\r\n\t0xE770, 0x84F6, 0xE771, 0x8531, 0xE772, 0x8526, 0xE773, 0x84E7,\t0xE774, 0x84E8, 0xE775, 0x84F0, 0xE776, 0x84EF, 0xE777, 0x84F9,\r\n\t0xE778, 0x8518, 0xE779, 0x8520, 0xE77A, 0x8530, 0xE77B, 0x850B,\t0xE77C, 0x8519, 0xE77D, 0x852F, 0xE77E, 0x8662, 0xE7A1, 0x8756,\r\n\t0xE7A2, 0x8763, 0xE7A3, 0x8764, 0xE7A4, 0x8777, 0xE7A5, 0x87E1,\t0xE7A6, 0x8773, 0xE7A7, 0x8758, 0xE7A8, 0x8754, 0xE7A9, 0x875B,\r\n\t0xE7AA, 0x8752, 0xE7AB, 0x8761, 0xE7AC, 0x875A, 0xE7AD, 0x8751,\t0xE7AE, 0x875E, 0xE7AF, 0x876D, 0xE7B0, 0x876A, 0xE7B1, 0x8750,\r\n\t0xE7B2, 0x874E, 0xE7B3, 0x875F, 0xE7B4, 0x875D, 0xE7B5, 0x876F,\t0xE7B6, 0x876C, 0xE7B7, 0x877A, 0xE7B8, 0x876E, 0xE7B9, 0x875C,\r\n\t0xE7BA, 0x8765, 0xE7BB, 0x874F, 0xE7BC, 0x877B, 0xE7BD, 0x8775,\t0xE7BE, 0x8762, 0xE7BF, 0x8767, 0xE7C0, 0x8769, 0xE7C1, 0x885A,\r\n\t0xE7C2, 0x8905, 0xE7C3, 0x890C, 0xE7C4, 0x8914, 0xE7C5, 0x890B,\t0xE7C6, 0x8917, 0xE7C7, 0x8918, 0xE7C8, 0x8919, 0xE7C9, 0x8906,\r\n\t0xE7CA, 0x8916, 0xE7CB, 0x8911, 0xE7CC, 0x890E, 0xE7CD, 0x8909,\t0xE7CE, 0x89A2, 0xE7CF, 0x89A4, 0xE7D0, 0x89A3, 0xE7D1, 0x89ED,\r\n\t0xE7D2, 0x89F0, 0xE7D3, 0x89EC, 0xE7D4, 0x8ACF, 0xE7D5, 0x8AC6,\t0xE7D6, 0x8AB8, 0xE7D7, 0x8AD3, 0xE7D8, 0x8AD1, 0xE7D9, 0x8AD4,\r\n\t0xE7DA, 0x8AD5, 0xE7DB, 0x8ABB, 0xE7DC, 0x8AD7, 0xE7DD, 0x8ABE,\t0xE7DE, 0x8AC0, 0xE7DF, 0x8AC5, 0xE7E0, 0x8AD8, 0xE7E1, 0x8AC3,\r\n\t0xE7E2, 0x8ABA, 0xE7E3, 0x8ABD, 0xE7E4, 0x8AD9, 0xE7E5, 0x8C3E,\t0xE7E6, 0x8C4D, 0xE7E7, 0x8C8F, 0xE7E8, 0x8CE5, 0xE7E9, 0x8CDF,\r\n\t0xE7EA, 0x8CD9, 0xE7EB, 0x8CE8, 0xE7EC, 0x8CDA, 0xE7ED, 0x8CDD,\t0xE7EE, 0x8CE7, 0xE7EF, 0x8DA0, 0xE7F0, 0x8D9C, 0xE7F1, 0x8DA1,\r\n\t0xE7F2, 0x8D9B, 0xE7F3, 0x8E20, 0xE7F4, 0x8E23, 0xE7F5, 0x8E25,\t0xE7F6, 0x8E24, 0xE7F7, 0x8E2E, 0xE7F8, 0x8E15, 0xE7F9, 0x8E1B,\r\n\t0xE7FA, 0x8E16, 0xE7FB, 0x8E11, 0xE7FC, 0x8E19, 0xE7FD, 0x8E26,\t0xE7FE, 0x8E27, 0xE840, 0x8E14, 0xE841, 0x8E12, 0xE842, 0x8E18,\r\n\t0xE843, 0x8E13, 0xE844, 0x8E1C, 0xE845, 0x8E17, 0xE846, 0x8E1A,\t0xE847, 0x8F2C, 0xE848, 0x8F24, 0xE849, 0x8F18, 0xE84A, 0x8F1A,\r\n\t0xE84B, 0x8F20, 0xE84C, 0x8F23, 0xE84D, 0x8F16, 0xE84E, 0x8F17,\t0xE84F, 0x9073, 0xE850, 0x9070, 0xE851, 0x906F, 0xE852, 0x9067,\r\n\t0xE853, 0x906B, 0xE854, 0x912F, 0xE855, 0x912B, 0xE856, 0x9129,\t0xE857, 0x912A, 0xE858, 0x9132, 0xE859, 0x9126, 0xE85A, 0x912E,\r\n\t0xE85B, 0x9185, 0xE85C, 0x9186, 0xE85D, 0x918A, 0xE85E, 0x9181,\t0xE85F, 0x9182, 0xE860, 0x9184, 0xE861, 0x9180, 0xE862, 0x92D0,\r\n\t0xE863, 0x92C3, 0xE864, 0x92C4, 0xE865, 0x92C0, 0xE866, 0x92D9,\t0xE867, 0x92B6, 0xE868, 0x92CF, 0xE869, 0x92F1, 0xE86A, 0x92DF,\r\n\t0xE86B, 0x92D8, 0xE86C, 0x92E9, 0xE86D, 0x92D7, 0xE86E, 0x92DD,\t0xE86F, 0x92CC, 0xE870, 0x92EF, 0xE871, 0x92C2, 0xE872, 0x92E8,\r\n\t0xE873, 0x92CA, 0xE874, 0x92C8, 0xE875, 0x92CE, 0xE876, 0x92E6,\t0xE877, 0x92CD, 0xE878, 0x92D5, 0xE879, 0x92C9, 0xE87A, 0x92E0,\r\n\t0xE87B, 0x92DE, 0xE87C, 0x92E7, 0xE87D, 0x92D1, 0xE87E, 0x92D3,\t0xE8A1, 0x92B5, 0xE8A2, 0x92E1, 0xE8A3, 0x92C6, 0xE8A4, 0x92B4,\r\n\t0xE8A5, 0x957C, 0xE8A6, 0x95AC, 0xE8A7, 0x95AB, 0xE8A8, 0x95AE,\t0xE8A9, 0x95B0, 0xE8AA, 0x96A4, 0xE8AB, 0x96A2, 0xE8AC, 0x96D3,\r\n\t0xE8AD, 0x9705, 0xE8AE, 0x9708, 0xE8AF, 0x9702, 0xE8B0, 0x975A,\t0xE8B1, 0x978A, 0xE8B2, 0x978E, 0xE8B3, 0x9788, 0xE8B4, 0x97D0,\r\n\t0xE8B5, 0x97CF, 0xE8B6, 0x981E, 0xE8B7, 0x981D, 0xE8B8, 0x9826,\t0xE8B9, 0x9829, 0xE8BA, 0x9828, 0xE8BB, 0x9820, 0xE8BC, 0x981B,\r\n\t0xE8BD, 0x9827, 0xE8BE, 0x98B2, 0xE8BF, 0x9908, 0xE8C0, 0x98FA,\t0xE8C1, 0x9911, 0xE8C2, 0x9914, 0xE8C3, 0x9916, 0xE8C4, 0x9917,\r\n\t0xE8C5, 0x9915, 0xE8C6, 0x99DC, 0xE8C7, 0x99CD, 0xE8C8, 0x99CF,\t0xE8C9, 0x99D3, 0xE8CA, 0x99D4, 0xE8CB, 0x99CE, 0xE8CC, 0x99C9,\r\n\t0xE8CD, 0x99D6, 0xE8CE, 0x99D8, 0xE8CF, 0x99CB, 0xE8D0, 0x99D7,\t0xE8D1, 0x99CC, 0xE8D2, 0x9AB3, 0xE8D3, 0x9AEC, 0xE8D4, 0x9AEB,\r\n\t0xE8D5, 0x9AF3, 0xE8D6, 0x9AF2, 0xE8D7, 0x9AF1, 0xE8D8, 0x9B46,\t0xE8D9, 0x9B43, 0xE8DA, 0x9B67, 0xE8DB, 0x9B74, 0xE8DC, 0x9B71,\r\n\t0xE8DD, 0x9B66, 0xE8DE, 0x9B76, 0xE8DF, 0x9B75, 0xE8E0, 0x9B70,\t0xE8E1, 0x9B68, 0xE8E2, 0x9B64, 0xE8E3, 0x9B6C, 0xE8E4, 0x9CFC,\r\n\t0xE8E5, 0x9CFA, 0xE8E6, 0x9CFD, 0xE8E7, 0x9CFF, 0xE8E8, 0x9CF7,\t0xE8E9, 0x9D07, 0xE8EA, 0x9D00, 0xE8EB, 0x9CF9, 0xE8EC, 0x9CFB,\r\n\t0xE8ED, 0x9D08, 0xE8EE, 0x9D05, 0xE8EF, 0x9D04, 0xE8F0, 0x9E83,\t0xE8F1, 0x9ED3, 0xE8F2, 0x9F0F, 0xE8F3, 0x9F10, 0xE8F4, 0x511C,\r\n\t0xE8F5, 0x5113, 0xE8F6, 0x5117, 0xE8F7, 0x511A, 0xE8F8, 0x5111,\t0xE8F9, 0x51DE, 0xE8FA, 0x5334, 0xE8FB, 0x53E1, 0xE8FC, 0x5670,\r\n\t0xE8FD, 0x5660, 0xE8FE, 0x566E, 0xE940, 0x5673, 0xE941, 0x5666,\t0xE942, 0x5663, 0xE943, 0x566D, 0xE944, 0x5672, 0xE945, 0x565E,\r\n\t0xE946, 0x5677, 0xE947, 0x571C, 0xE948, 0x571B, 0xE949, 0x58C8,\t0xE94A, 0x58BD, 0xE94B, 0x58C9, 0xE94C, 0x58BF, 0xE94D, 0x58BA,\r\n\t0xE94E, 0x58C2, 0xE94F, 0x58BC, 0xE950, 0x58C6, 0xE951, 0x5B17,\t0xE952, 0x5B19, 0xE953, 0x5B1B, 0xE954, 0x5B21, 0xE955, 0x5B14,\r\n\t0xE956, 0x5B13, 0xE957, 0x5B10, 0xE958, 0x5B16, 0xE959, 0x5B28,\t0xE95A, 0x5B1A, 0xE95B, 0x5B20, 0xE95C, 0x5B1E, 0xE95D, 0x5BEF,\r\n\t0xE95E, 0x5DAC, 0xE95F, 0x5DB1, 0xE960, 0x5DA9, 0xE961, 0x5DA7,\t0xE962, 0x5DB5, 0xE963, 0x5DB0, 0xE964, 0x5DAE, 0xE965, 0x5DAA,\r\n\t0xE966, 0x5DA8, 0xE967, 0x5DB2, 0xE968, 0x5DAD, 0xE969, 0x5DAF,\t0xE96A, 0x5DB4, 0xE96B, 0x5E67, 0xE96C, 0x5E68, 0xE96D, 0x5E66,\r\n\t0xE96E, 0x5E6F, 0xE96F, 0x5EE9, 0xE970, 0x5EE7, 0xE971, 0x5EE6,\t0xE972, 0x5EE8, 0xE973, 0x5EE5, 0xE974, 0x5F4B, 0xE975, 0x5FBC,\r\n\t0xE976, 0x619D, 0xE977, 0x61A8, 0xE978, 0x6196, 0xE979, 0x61C5,\t0xE97A, 0x61B4, 0xE97B, 0x61C6, 0xE97C, 0x61C1, 0xE97D, 0x61CC,\r\n\t0xE97E, 0x61BA, 0xE9A1, 0x61BF, 0xE9A2, 0x61B8, 0xE9A3, 0x618C,\t0xE9A4, 0x64D7, 0xE9A5, 0x64D6, 0xE9A6, 0x64D0, 0xE9A7, 0x64CF,\r\n\t0xE9A8, 0x64C9, 0xE9A9, 0x64BD, 0xE9AA, 0x6489, 0xE9AB, 0x64C3,\t0xE9AC, 0x64DB, 0xE9AD, 0x64F3, 0xE9AE, 0x64D9, 0xE9AF, 0x6533,\r\n\t0xE9B0, 0x657F, 0xE9B1, 0x657C, 0xE9B2, 0x65A2, 0xE9B3, 0x66C8,\t0xE9B4, 0x66BE, 0xE9B5, 0x66C0, 0xE9B6, 0x66CA, 0xE9B7, 0x66CB,\r\n\t0xE9B8, 0x66CF, 0xE9B9, 0x66BD, 0xE9BA, 0x66BB, 0xE9BB, 0x66BA,\t0xE9BC, 0x66CC, 0xE9BD, 0x6723, 0xE9BE, 0x6A34, 0xE9BF, 0x6A66,\r\n\t0xE9C0, 0x6A49, 0xE9C1, 0x6A67, 0xE9C2, 0x6A32, 0xE9C3, 0x6A68,\t0xE9C4, 0x6A3E, 0xE9C5, 0x6A5D, 0xE9C6, 0x6A6D, 0xE9C7, 0x6A76,\r\n\t0xE9C8, 0x6A5B, 0xE9C9, 0x6A51, 0xE9CA, 0x6A28, 0xE9CB, 0x6A5A,\t0xE9CC, 0x6A3B, 0xE9CD, 0x6A3F, 0xE9CE, 0x6A41, 0xE9CF, 0x6A6A,\r\n\t0xE9D0, 0x6A64, 0xE9D1, 0x6A50, 0xE9D2, 0x6A4F, 0xE9D3, 0x6A54,\t0xE9D4, 0x6A6F, 0xE9D5, 0x6A69, 0xE9D6, 0x6A60, 0xE9D7, 0x6A3C,\r\n\t0xE9D8, 0x6A5E, 0xE9D9, 0x6A56, 0xE9DA, 0x6A55, 0xE9DB, 0x6A4D,\t0xE9DC, 0x6A4E, 0xE9DD, 0x6A46, 0xE9DE, 0x6B55, 0xE9DF, 0x6B54,\r\n\t0xE9E0, 0x6B56, 0xE9E1, 0x6BA7, 0xE9E2, 0x6BAA, 0xE9E3, 0x6BAB,\t0xE9E4, 0x6BC8, 0xE9E5, 0x6BC7, 0xE9E6, 0x6C04, 0xE9E7, 0x6C03,\r\n\t0xE9E8, 0x6C06, 0xE9E9, 0x6FAD, 0xE9EA, 0x6FCB, 0xE9EB, 0x6FA3,\t0xE9EC, 0x6FC7, 0xE9ED, 0x6FBC, 0xE9EE, 0x6FCE, 0xE9EF, 0x6FC8,\r\n\t0xE9F0, 0x6F5E, 0xE9F1, 0x6FC4, 0xE9F2, 0x6FBD, 0xE9F3, 0x6F9E,\t0xE9F4, 0x6FCA, 0xE9F5, 0x6FA8, 0xE9F6, 0x7004, 0xE9F7, 0x6FA5,\r\n\t0xE9F8, 0x6FAE, 0xE9F9, 0x6FBA, 0xE9FA, 0x6FAC, 0xE9FB, 0x6FAA,\t0xE9FC, 0x6FCF, 0xE9FD, 0x6FBF, 0xE9FE, 0x6FB8, 0xEA40, 0x6FA2,\r\n\t0xEA41, 0x6FC9, 0xEA42, 0x6FAB, 0xEA43, 0x6FCD, 0xEA44, 0x6FAF,\t0xEA45, 0x6FB2, 0xEA46, 0x6FB0, 0xEA47, 0x71C5, 0xEA48, 0x71C2,\r\n\t0xEA49, 0x71BF, 0xEA4A, 0x71B8, 0xEA4B, 0x71D6, 0xEA4C, 0x71C0,\t0xEA4D, 0x71C1, 0xEA4E, 0x71CB, 0xEA4F, 0x71D4, 0xEA50, 0x71CA,\r\n\t0xEA51, 0x71C7, 0xEA52, 0x71CF, 0xEA53, 0x71BD, 0xEA54, 0x71D8,\t0xEA55, 0x71BC, 0xEA56, 0x71C6, 0xEA57, 0x71DA, 0xEA58, 0x71DB,\r\n\t0xEA59, 0x729D, 0xEA5A, 0x729E, 0xEA5B, 0x7369, 0xEA5C, 0x7366,\t0xEA5D, 0x7367, 0xEA5E, 0x736C, 0xEA5F, 0x7365, 0xEA60, 0x736B,\r\n\t0xEA61, 0x736A, 0xEA62, 0x747F, 0xEA63, 0x749A, 0xEA64, 0x74A0,\t0xEA65, 0x7494, 0xEA66, 0x7492, 0xEA67, 0x7495, 0xEA68, 0x74A1,\r\n\t0xEA69, 0x750B, 0xEA6A, 0x7580, 0xEA6B, 0x762F, 0xEA6C, 0x762D,\t0xEA6D, 0x7631, 0xEA6E, 0x763D, 0xEA6F, 0x7633, 0xEA70, 0x763C,\r\n\t0xEA71, 0x7635, 0xEA72, 0x7632, 0xEA73, 0x7630, 0xEA74, 0x76BB,\t0xEA75, 0x76E6, 0xEA76, 0x779A, 0xEA77, 0x779D, 0xEA78, 0x77A1,\r\n\t0xEA79, 0x779C, 0xEA7A, 0x779B, 0xEA7B, 0x77A2, 0xEA7C, 0x77A3,\t0xEA7D, 0x7795, 0xEA7E, 0x7799, 0xEAA1, 0x7797, 0xEAA2, 0x78DD,\r\n\t0xEAA3, 0x78E9, 0xEAA4, 0x78E5, 0xEAA5, 0x78EA, 0xEAA6, 0x78DE,\t0xEAA7, 0x78E3, 0xEAA8, 0x78DB, 0xEAA9, 0x78E1, 0xEAAA, 0x78E2,\r\n\t0xEAAB, 0x78ED, 0xEAAC, 0x78DF, 0xEAAD, 0x78E0, 0xEAAE, 0x79A4,\t0xEAAF, 0x7A44, 0xEAB0, 0x7A48, 0xEAB1, 0x7A47, 0xEAB2, 0x7AB6,\r\n\t0xEAB3, 0x7AB8, 0xEAB4, 0x7AB5, 0xEAB5, 0x7AB1, 0xEAB6, 0x7AB7,\t0xEAB7, 0x7BDE, 0xEAB8, 0x7BE3, 0xEAB9, 0x7BE7, 0xEABA, 0x7BDD,\r\n\t0xEABB, 0x7BD5, 0xEABC, 0x7BE5, 0xEABD, 0x7BDA, 0xEABE, 0x7BE8,\t0xEABF, 0x7BF9, 0xEAC0, 0x7BD4, 0xEAC1, 0x7BEA, 0xEAC2, 0x7BE2,\r\n\t0xEAC3, 0x7BDC, 0xEAC4, 0x7BEB, 0xEAC5, 0x7BD8, 0xEAC6, 0x7BDF,\t0xEAC7, 0x7CD2, 0xEAC8, 0x7CD4, 0xEAC9, 0x7CD7, 0xEACA, 0x7CD0,\r\n\t0xEACB, 0x7CD1, 0xEACC, 0x7E12, 0xEACD, 0x7E21, 0xEACE, 0x7E17,\t0xEACF, 0x7E0C, 0xEAD0, 0x7E1F, 0xEAD1, 0x7E20, 0xEAD2, 0x7E13,\r\n\t0xEAD3, 0x7E0E, 0xEAD4, 0x7E1C, 0xEAD5, 0x7E15, 0xEAD6, 0x7E1A,\t0xEAD7, 0x7E22, 0xEAD8, 0x7E0B, 0xEAD9, 0x7E0F, 0xEADA, 0x7E16,\r\n\t0xEADB, 0x7E0D, 0xEADC, 0x7E14, 0xEADD, 0x7E25, 0xEADE, 0x7E24,\t0xEADF, 0x7F43, 0xEAE0, 0x7F7B, 0xEAE1, 0x7F7C, 0xEAE2, 0x7F7A,\r\n\t0xEAE3, 0x7FB1, 0xEAE4, 0x7FEF, 0xEAE5, 0x802A, 0xEAE6, 0x8029,\t0xEAE7, 0x806C, 0xEAE8, 0x81B1, 0xEAE9, 0x81A6, 0xEAEA, 0x81AE,\r\n\t0xEAEB, 0x81B9, 0xEAEC, 0x81B5, 0xEAED, 0x81AB, 0xEAEE, 0x81B0,\t0xEAEF, 0x81AC, 0xEAF0, 0x81B4, 0xEAF1, 0x81B2, 0xEAF2, 0x81B7,\r\n\t0xEAF3, 0x81A7, 0xEAF4, 0x81F2, 0xEAF5, 0x8255, 0xEAF6, 0x8256,\t0xEAF7, 0x8257, 0xEAF8, 0x8556, 0xEAF9, 0x8545, 0xEAFA, 0x856B,\r\n\t0xEAFB, 0x854D, 0xEAFC, 0x8553, 0xEAFD, 0x8561, 0xEAFE, 0x8558,\t0xEB40, 0x8540, 0xEB41, 0x8546, 0xEB42, 0x8564, 0xEB43, 0x8541,\r\n\t0xEB44, 0x8562, 0xEB45, 0x8544, 0xEB46, 0x8551, 0xEB47, 0x8547,\t0xEB48, 0x8563, 0xEB49, 0x853E, 0xEB4A, 0x855B, 0xEB4B, 0x8571,\r\n\t0xEB4C, 0x854E, 0xEB4D, 0x856E, 0xEB4E, 0x8575, 0xEB4F, 0x8555,\t0xEB50, 0x8567, 0xEB51, 0x8560, 0xEB52, 0x858C, 0xEB53, 0x8566,\r\n\t0xEB54, 0x855D, 0xEB55, 0x8554, 0xEB56, 0x8565, 0xEB57, 0x856C,\t0xEB58, 0x8663, 0xEB59, 0x8665, 0xEB5A, 0x8664, 0xEB5B, 0x879B,\r\n\t0xEB5C, 0x878F, 0xEB5D, 0x8797, 0xEB5E, 0x8793, 0xEB5F, 0x8792,\t0xEB60, 0x8788, 0xEB61, 0x8781, 0xEB62, 0x8796, 0xEB63, 0x8798,\r\n\t0xEB64, 0x8779, 0xEB65, 0x8787, 0xEB66, 0x87A3, 0xEB67, 0x8785,\t0xEB68, 0x8790, 0xEB69, 0x8791, 0xEB6A, 0x879D, 0xEB6B, 0x8784,\r\n\t0xEB6C, 0x8794, 0xEB6D, 0x879C, 0xEB6E, 0x879A, 0xEB6F, 0x8789,\t0xEB70, 0x891E, 0xEB71, 0x8926, 0xEB72, 0x8930, 0xEB73, 0x892D,\r\n\t0xEB74, 0x892E, 0xEB75, 0x8927, 0xEB76, 0x8931, 0xEB77, 0x8922,\t0xEB78, 0x8929, 0xEB79, 0x8923, 0xEB7A, 0x892F, 0xEB7B, 0x892C,\r\n\t0xEB7C, 0x891F, 0xEB7D, 0x89F1, 0xEB7E, 0x8AE0, 0xEBA1, 0x8AE2,\t0xEBA2, 0x8AF2, 0xEBA3, 0x8AF4, 0xEBA4, 0x8AF5, 0xEBA5, 0x8ADD,\r\n\t0xEBA6, 0x8B14, 0xEBA7, 0x8AE4, 0xEBA8, 0x8ADF, 0xEBA9, 0x8AF0,\t0xEBAA, 0x8AC8, 0xEBAB, 0x8ADE, 0xEBAC, 0x8AE1, 0xEBAD, 0x8AE8,\r\n\t0xEBAE, 0x8AFF, 0xEBAF, 0x8AEF, 0xEBB0, 0x8AFB, 0xEBB1, 0x8C91,\t0xEBB2, 0x8C92, 0xEBB3, 0x8C90, 0xEBB4, 0x8CF5, 0xEBB5, 0x8CEE,\r\n\t0xEBB6, 0x8CF1, 0xEBB7, 0x8CF0, 0xEBB8, 0x8CF3, 0xEBB9, 0x8D6C,\t0xEBBA, 0x8D6E, 0xEBBB, 0x8DA5, 0xEBBC, 0x8DA7, 0xEBBD, 0x8E33,\r\n\t0xEBBE, 0x8E3E, 0xEBBF, 0x8E38, 0xEBC0, 0x8E40, 0xEBC1, 0x8E45,\t0xEBC2, 0x8E36, 0xEBC3, 0x8E3C, 0xEBC4, 0x8E3D, 0xEBC5, 0x8E41,\r\n\t0xEBC6, 0x8E30, 0xEBC7, 0x8E3F, 0xEBC8, 0x8EBD, 0xEBC9, 0x8F36,\t0xEBCA, 0x8F2E, 0xEBCB, 0x8F35, 0xEBCC, 0x8F32, 0xEBCD, 0x8F39,\r\n\t0xEBCE, 0x8F37, 0xEBCF, 0x8F34, 0xEBD0, 0x9076, 0xEBD1, 0x9079,\t0xEBD2, 0x907B, 0xEBD3, 0x9086, 0xEBD4, 0x90FA, 0xEBD5, 0x9133,\r\n\t0xEBD6, 0x9135, 0xEBD7, 0x9136, 0xEBD8, 0x9193, 0xEBD9, 0x9190,\t0xEBDA, 0x9191, 0xEBDB, 0x918D, 0xEBDC, 0x918F, 0xEBDD, 0x9327,\r\n\t0xEBDE, 0x931E, 0xEBDF, 0x9308, 0xEBE0, 0x931F, 0xEBE1, 0x9306,\t0xEBE2, 0x930F, 0xEBE3, 0x937A, 0xEBE4, 0x9338, 0xEBE5, 0x933C,\r\n\t0xEBE6, 0x931B, 0xEBE7, 0x9323, 0xEBE8, 0x9312, 0xEBE9, 0x9301,\t0xEBEA, 0x9346, 0xEBEB, 0x932D, 0xEBEC, 0x930E, 0xEBED, 0x930D,\r\n\t0xEBEE, 0x92CB, 0xEBEF, 0x931D, 0xEBF0, 0x92FA, 0xEBF1, 0x9325,\t0xEBF2, 0x9313, 0xEBF3, 0x92F9, 0xEBF4, 0x92F7, 0xEBF5, 0x9334,\r\n\t0xEBF6, 0x9302, 0xEBF7, 0x9324, 0xEBF8, 0x92FF, 0xEBF9, 0x9329,\t0xEBFA, 0x9339, 0xEBFB, 0x9335, 0xEBFC, 0x932A, 0xEBFD, 0x9314,\r\n\t0xEBFE, 0x930C, 0xEC40, 0x930B, 0xEC41, 0x92FE, 0xEC42, 0x9309,\t0xEC43, 0x9300, 0xEC44, 0x92FB, 0xEC45, 0x9316, 0xEC46, 0x95BC,\r\n\t0xEC47, 0x95CD, 0xEC48, 0x95BE, 0xEC49, 0x95B9, 0xEC4A, 0x95BA,\t0xEC4B, 0x95B6, 0xEC4C, 0x95BF, 0xEC4D, 0x95B5, 0xEC4E, 0x95BD,\r\n\t0xEC4F, 0x96A9, 0xEC50, 0x96D4, 0xEC51, 0x970B, 0xEC52, 0x9712,\t0xEC53, 0x9710, 0xEC54, 0x9799, 0xEC55, 0x9797, 0xEC56, 0x9794,\r\n\t0xEC57, 0x97F0, 0xEC58, 0x97F8, 0xEC59, 0x9835, 0xEC5A, 0x982F,\t0xEC5B, 0x9832, 0xEC5C, 0x9924, 0xEC5D, 0x991F, 0xEC5E, 0x9927,\r\n\t0xEC5F, 0x9929, 0xEC60, 0x999E, 0xEC61, 0x99EE, 0xEC62, 0x99EC,\t0xEC63, 0x99E5, 0xEC64, 0x99E4, 0xEC65, 0x99F0, 0xEC66, 0x99E3,\r\n\t0xEC67, 0x99EA, 0xEC68, 0x99E9, 0xEC69, 0x99E7, 0xEC6A, 0x9AB9,\t0xEC6B, 0x9ABF, 0xEC6C, 0x9AB4, 0xEC6D, 0x9ABB, 0xEC6E, 0x9AF6,\r\n\t0xEC6F, 0x9AFA, 0xEC70, 0x9AF9, 0xEC71, 0x9AF7, 0xEC72, 0x9B33,\t0xEC73, 0x9B80, 0xEC74, 0x9B85, 0xEC75, 0x9B87, 0xEC76, 0x9B7C,\r\n\t0xEC77, 0x9B7E, 0xEC78, 0x9B7B, 0xEC79, 0x9B82, 0xEC7A, 0x9B93,\t0xEC7B, 0x9B92, 0xEC7C, 0x9B90, 0xEC7D, 0x9B7A, 0xEC7E, 0x9B95,\r\n\t0xECA1, 0x9B7D, 0xECA2, 0x9B88, 0xECA3, 0x9D25, 0xECA4, 0x9D17,\t0xECA5, 0x9D20, 0xECA6, 0x9D1E, 0xECA7, 0x9D14, 0xECA8, 0x9D29,\r\n\t0xECA9, 0x9D1D, 0xECAA, 0x9D18, 0xECAB, 0x9D22, 0xECAC, 0x9D10,\t0xECAD, 0x9D19, 0xECAE, 0x9D1F, 0xECAF, 0x9E88, 0xECB0, 0x9E86,\r\n\t0xECB1, 0x9E87, 0xECB2, 0x9EAE, 0xECB3, 0x9EAD, 0xECB4, 0x9ED5,\t0xECB5, 0x9ED6, 0xECB6, 0x9EFA, 0xECB7, 0x9F12, 0xECB8, 0x9F3D,\r\n\t0xECB9, 0x5126, 0xECBA, 0x5125, 0xECBB, 0x5122, 0xECBC, 0x5124,\t0xECBD, 0x5120, 0xECBE, 0x5129, 0xECBF, 0x52F4, 0xECC0, 0x5693,\r\n\t0xECC1, 0x568C, 0xECC2, 0x568D, 0xECC3, 0x5686, 0xECC4, 0x5684,\t0xECC5, 0x5683, 0xECC6, 0x567E, 0xECC7, 0x5682, 0xECC8, 0x567F,\r\n\t0xECC9, 0x5681, 0xECCA, 0x58D6, 0xECCB, 0x58D4, 0xECCC, 0x58CF,\t0xECCD, 0x58D2, 0xECCE, 0x5B2D, 0xECCF, 0x5B25, 0xECD0, 0x5B32,\r\n\t0xECD1, 0x5B23, 0xECD2, 0x5B2C, 0xECD3, 0x5B27, 0xECD4, 0x5B26,\t0xECD5, 0x5B2F, 0xECD6, 0x5B2E, 0xECD7, 0x5B7B, 0xECD8, 0x5BF1,\r\n\t0xECD9, 0x5BF2, 0xECDA, 0x5DB7, 0xECDB, 0x5E6C, 0xECDC, 0x5E6A,\t0xECDD, 0x5FBE, 0xECDE, 0x5FBB, 0xECDF, 0x61C3, 0xECE0, 0x61B5,\r\n\t0xECE1, 0x61BC, 0xECE2, 0x61E7, 0xECE3, 0x61E0, 0xECE4, 0x61E5,\t0xECE5, 0x61E4, 0xECE6, 0x61E8, 0xECE7, 0x61DE, 0xECE8, 0x64EF,\r\n\t0xECE9, 0x64E9, 0xECEA, 0x64E3, 0xECEB, 0x64EB, 0xECEC, 0x64E4,\t0xECED, 0x64E8, 0xECEE, 0x6581, 0xECEF, 0x6580, 0xECF0, 0x65B6,\r\n\t0xECF1, 0x65DA, 0xECF2, 0x66D2, 0xECF3, 0x6A8D, 0xECF4, 0x6A96,\t0xECF5, 0x6A81, 0xECF6, 0x6AA5, 0xECF7, 0x6A89, 0xECF8, 0x6A9F,\r\n\t0xECF9, 0x6A9B, 0xECFA, 0x6AA1, 0xECFB, 0x6A9E, 0xECFC, 0x6A87,\t0xECFD, 0x6A93, 0xECFE, 0x6A8E, 0xED40, 0x6A95, 0xED41, 0x6A83,\r\n\t0xED42, 0x6AA8, 0xED43, 0x6AA4, 0xED44, 0x6A91, 0xED45, 0x6A7F,\t0xED46, 0x6AA6, 0xED47, 0x6A9A, 0xED48, 0x6A85, 0xED49, 0x6A8C,\r\n\t0xED4A, 0x6A92, 0xED4B, 0x6B5B, 0xED4C, 0x6BAD, 0xED4D, 0x6C09,\t0xED4E, 0x6FCC, 0xED4F, 0x6FA9, 0xED50, 0x6FF4, 0xED51, 0x6FD4,\r\n\t0xED52, 0x6FE3, 0xED53, 0x6FDC, 0xED54, 0x6FED, 0xED55, 0x6FE7,\t0xED56, 0x6FE6, 0xED57, 0x6FDE, 0xED58, 0x6FF2, 0xED59, 0x6FDD,\r\n\t0xED5A, 0x6FE2, 0xED5B, 0x6FE8, 0xED5C, 0x71E1, 0xED5D, 0x71F1,\t0xED5E, 0x71E8, 0xED5F, 0x71F2, 0xED60, 0x71E4, 0xED61, 0x71F0,\r\n\t0xED62, 0x71E2, 0xED63, 0x7373, 0xED64, 0x736E, 0xED65, 0x736F,\t0xED66, 0x7497, 0xED67, 0x74B2, 0xED68, 0x74AB, 0xED69, 0x7490,\r\n\t0xED6A, 0x74AA, 0xED6B, 0x74AD, 0xED6C, 0x74B1, 0xED6D, 0x74A5,\t0xED6E, 0x74AF, 0xED6F, 0x7510, 0xED70, 0x7511, 0xED71, 0x7512,\r\n\t0xED72, 0x750F, 0xED73, 0x7584, 0xED74, 0x7643, 0xED75, 0x7648,\t0xED76, 0x7649, 0xED77, 0x7647, 0xED78, 0x76A4, 0xED79, 0x76E9,\r\n\t0xED7A, 0x77B5, 0xED7B, 0x77AB, 0xED7C, 0x77B2, 0xED7D, 0x77B7,\t0xED7E, 0x77B6, 0xEDA1, 0x77B4, 0xEDA2, 0x77B1, 0xEDA3, 0x77A8,\r\n\t0xEDA4, 0x77F0, 0xEDA5, 0x78F3, 0xEDA6, 0x78FD, 0xEDA7, 0x7902,\t0xEDA8, 0x78FB, 0xEDA9, 0x78FC, 0xEDAA, 0x78F2, 0xEDAB, 0x7905,\r\n\t0xEDAC, 0x78F9, 0xEDAD, 0x78FE, 0xEDAE, 0x7904, 0xEDAF, 0x79AB,\t0xEDB0, 0x79A8, 0xEDB1, 0x7A5C, 0xEDB2, 0x7A5B, 0xEDB3, 0x7A56,\r\n\t0xEDB4, 0x7A58, 0xEDB5, 0x7A54, 0xEDB6, 0x7A5A, 0xEDB7, 0x7ABE,\t0xEDB8, 0x7AC0, 0xEDB9, 0x7AC1, 0xEDBA, 0x7C05, 0xEDBB, 0x7C0F,\r\n\t0xEDBC, 0x7BF2, 0xEDBD, 0x7C00, 0xEDBE, 0x7BFF, 0xEDBF, 0x7BFB,\t0xEDC0, 0x7C0E, 0xEDC1, 0x7BF4, 0xEDC2, 0x7C0B, 0xEDC3, 0x7BF3,\r\n\t0xEDC4, 0x7C02, 0xEDC5, 0x7C09, 0xEDC6, 0x7C03, 0xEDC7, 0x7C01,\t0xEDC8, 0x7BF8, 0xEDC9, 0x7BFD, 0xEDCA, 0x7C06, 0xEDCB, 0x7BF0,\r\n\t0xEDCC, 0x7BF1, 0xEDCD, 0x7C10, 0xEDCE, 0x7C0A, 0xEDCF, 0x7CE8,\t0xEDD0, 0x7E2D, 0xEDD1, 0x7E3C, 0xEDD2, 0x7E42, 0xEDD3, 0x7E33,\r\n\t0xEDD4, 0x9848, 0xEDD5, 0x7E38, 0xEDD6, 0x7E2A, 0xEDD7, 0x7E49,\t0xEDD8, 0x7E40, 0xEDD9, 0x7E47, 0xEDDA, 0x7E29, 0xEDDB, 0x7E4C,\r\n\t0xEDDC, 0x7E30, 0xEDDD, 0x7E3B, 0xEDDE, 0x7E36, 0xEDDF, 0x7E44,\t0xEDE0, 0x7E3A, 0xEDE1, 0x7F45, 0xEDE2, 0x7F7F, 0xEDE3, 0x7F7E,\r\n\t0xEDE4, 0x7F7D, 0xEDE5, 0x7FF4, 0xEDE6, 0x7FF2, 0xEDE7, 0x802C,\t0xEDE8, 0x81BB, 0xEDE9, 0x81C4, 0xEDEA, 0x81CC, 0xEDEB, 0x81CA,\r\n\t0xEDEC, 0x81C5, 0xEDED, 0x81C7, 0xEDEE, 0x81BC, 0xEDEF, 0x81E9,\t0xEDF0, 0x825B, 0xEDF1, 0x825A, 0xEDF2, 0x825C, 0xEDF3, 0x8583,\r\n\t0xEDF4, 0x8580, 0xEDF5, 0x858F, 0xEDF6, 0x85A7, 0xEDF7, 0x8595,\t0xEDF8, 0x85A0, 0xEDF9, 0x858B, 0xEDFA, 0x85A3, 0xEDFB, 0x857B,\r\n\t0xEDFC, 0x85A4, 0xEDFD, 0x859A, 0xEDFE, 0x859E, 0xEE40, 0x8577,\t0xEE41, 0x857C, 0xEE42, 0x8589, 0xEE43, 0x85A1, 0xEE44, 0x857A,\r\n\t0xEE45, 0x8578, 0xEE46, 0x8557, 0xEE47, 0x858E, 0xEE48, 0x8596,\t0xEE49, 0x8586, 0xEE4A, 0x858D, 0xEE4B, 0x8599, 0xEE4C, 0x859D,\r\n\t0xEE4D, 0x8581, 0xEE4E, 0x85A2, 0xEE4F, 0x8582, 0xEE50, 0x8588,\t0xEE51, 0x8585, 0xEE52, 0x8579, 0xEE53, 0x8576, 0xEE54, 0x8598,\r\n\t0xEE55, 0x8590, 0xEE56, 0x859F, 0xEE57, 0x8668, 0xEE58, 0x87BE,\t0xEE59, 0x87AA, 0xEE5A, 0x87AD, 0xEE5B, 0x87C5, 0xEE5C, 0x87B0,\r\n\t0xEE5D, 0x87AC, 0xEE5E, 0x87B9, 0xEE5F, 0x87B5, 0xEE60, 0x87BC,\t0xEE61, 0x87AE, 0xEE62, 0x87C9, 0xEE63, 0x87C3, 0xEE64, 0x87C2,\r\n\t0xEE65, 0x87CC, 0xEE66, 0x87B7, 0xEE67, 0x87AF, 0xEE68, 0x87C4,\t0xEE69, 0x87CA, 0xEE6A, 0x87B4, 0xEE6B, 0x87B6, 0xEE6C, 0x87BF,\r\n\t0xEE6D, 0x87B8, 0xEE6E, 0x87BD, 0xEE6F, 0x87DE, 0xEE70, 0x87B2,\t0xEE71, 0x8935, 0xEE72, 0x8933, 0xEE73, 0x893C, 0xEE74, 0x893E,\r\n\t0xEE75, 0x8941, 0xEE76, 0x8952, 0xEE77, 0x8937, 0xEE78, 0x8942,\t0xEE79, 0x89AD, 0xEE7A, 0x89AF, 0xEE7B, 0x89AE, 0xEE7C, 0x89F2,\r\n\t0xEE7D, 0x89F3, 0xEE7E, 0x8B1E, 0xEEA1, 0x8B18, 0xEEA2, 0x8B16,\t0xEEA3, 0x8B11, 0xEEA4, 0x8B05, 0xEEA5, 0x8B0B, 0xEEA6, 0x8B22,\r\n\t0xEEA7, 0x8B0F, 0xEEA8, 0x8B12, 0xEEA9, 0x8B15, 0xEEAA, 0x8B07,\t0xEEAB, 0x8B0D, 0xEEAC, 0x8B08, 0xEEAD, 0x8B06, 0xEEAE, 0x8B1C,\r\n\t0xEEAF, 0x8B13, 0xEEB0, 0x8B1A, 0xEEB1, 0x8C4F, 0xEEB2, 0x8C70,\t0xEEB3, 0x8C72, 0xEEB4, 0x8C71, 0xEEB5, 0x8C6F, 0xEEB6, 0x8C95,\r\n\t0xEEB7, 0x8C94, 0xEEB8, 0x8CF9, 0xEEB9, 0x8D6F, 0xEEBA, 0x8E4E,\t0xEEBB, 0x8E4D, 0xEEBC, 0x8E53, 0xEEBD, 0x8E50, 0xEEBE, 0x8E4C,\r\n\t0xEEBF, 0x8E47, 0xEEC0, 0x8F43, 0xEEC1, 0x8F40, 0xEEC2, 0x9085,\t0xEEC3, 0x907E, 0xEEC4, 0x9138, 0xEEC5, 0x919A, 0xEEC6, 0x91A2,\r\n\t0xEEC7, 0x919B, 0xEEC8, 0x9199, 0xEEC9, 0x919F, 0xEECA, 0x91A1,\t0xEECB, 0x919D, 0xEECC, 0x91A0, 0xEECD, 0x93A1, 0xEECE, 0x9383,\r\n\t0xEECF, 0x93AF, 0xEED0, 0x9364, 0xEED1, 0x9356, 0xEED2, 0x9347,\t0xEED3, 0x937C, 0xEED4, 0x9358, 0xEED5, 0x935C, 0xEED6, 0x9376,\r\n\t0xEED7, 0x9349, 0xEED8, 0x9350, 0xEED9, 0x9351, 0xEEDA, 0x9360,\t0xEEDB, 0x936D, 0xEEDC, 0x938F, 0xEEDD, 0x934C, 0xEEDE, 0x936A,\r\n\t0xEEDF, 0x9379, 0xEEE0, 0x9357, 0xEEE1, 0x9355, 0xEEE2, 0x9352,\t0xEEE3, 0x934F, 0xEEE4, 0x9371, 0xEEE5, 0x9377, 0xEEE6, 0x937B,\r\n\t0xEEE7, 0x9361, 0xEEE8, 0x935E, 0xEEE9, 0x9363, 0xEEEA, 0x9367,\t0xEEEB, 0x9380, 0xEEEC, 0x934E, 0xEEED, 0x9359, 0xEEEE, 0x95C7,\r\n\t0xEEEF, 0x95C0, 0xEEF0, 0x95C9, 0xEEF1, 0x95C3, 0xEEF2, 0x95C5,\t0xEEF3, 0x95B7, 0xEEF4, 0x96AE, 0xEEF5, 0x96B0, 0xEEF6, 0x96AC,\r\n\t0xEEF7, 0x9720, 0xEEF8, 0x971F, 0xEEF9, 0x9718, 0xEEFA, 0x971D,\t0xEEFB, 0x9719, 0xEEFC, 0x979A, 0xEEFD, 0x97A1, 0xEEFE, 0x979C,\r\n\t0xEF40, 0x979E, 0xEF41, 0x979D, 0xEF42, 0x97D5, 0xEF43, 0x97D4,\t0xEF44, 0x97F1, 0xEF45, 0x9841, 0xEF46, 0x9844, 0xEF47, 0x984A,\r\n\t0xEF48, 0x9849, 0xEF49, 0x9845, 0xEF4A, 0x9843, 0xEF4B, 0x9925,\t0xEF4C, 0x992B, 0xEF4D, 0x992C, 0xEF4E, 0x992A, 0xEF4F, 0x9933,\r\n\t0xEF50, 0x9932, 0xEF51, 0x992F, 0xEF52, 0x992D, 0xEF53, 0x9931,\t0xEF54, 0x9930, 0xEF55, 0x9998, 0xEF56, 0x99A3, 0xEF57, 0x99A1,\r\n\t0xEF58, 0x9A02, 0xEF59, 0x99FA, 0xEF5A, 0x99F4, 0xEF5B, 0x99F7,\t0xEF5C, 0x99F9, 0xEF5D, 0x99F8, 0xEF5E, 0x99F6, 0xEF5F, 0x99FB,\r\n\t0xEF60, 0x99FD, 0xEF61, 0x99FE, 0xEF62, 0x99FC, 0xEF63, 0x9A03,\t0xEF64, 0x9ABE, 0xEF65, 0x9AFE, 0xEF66, 0x9AFD, 0xEF67, 0x9B01,\r\n\t0xEF68, 0x9AFC, 0xEF69, 0x9B48, 0xEF6A, 0x9B9A, 0xEF6B, 0x9BA8,\t0xEF6C, 0x9B9E, 0xEF6D, 0x9B9B, 0xEF6E, 0x9BA6, 0xEF6F, 0x9BA1,\r\n\t0xEF70, 0x9BA5, 0xEF71, 0x9BA4, 0xEF72, 0x9B86, 0xEF73, 0x9BA2,\t0xEF74, 0x9BA0, 0xEF75, 0x9BAF, 0xEF76, 0x9D33, 0xEF77, 0x9D41,\r\n\t0xEF78, 0x9D67, 0xEF79, 0x9D36, 0xEF7A, 0x9D2E, 0xEF7B, 0x9D2F,\t0xEF7C, 0x9D31, 0xEF7D, 0x9D38, 0xEF7E, 0x9D30, 0xEFA1, 0x9D45,\r\n\t0xEFA2, 0x9D42, 0xEFA3, 0x9D43, 0xEFA4, 0x9D3E, 0xEFA5, 0x9D37,\t0xEFA6, 0x9D40, 0xEFA7, 0x9D3D, 0xEFA8, 0x7FF5, 0xEFA9, 0x9D2D,\r\n\t0xEFAA, 0x9E8A, 0xEFAB, 0x9E89, 0xEFAC, 0x9E8D, 0xEFAD, 0x9EB0,\t0xEFAE, 0x9EC8, 0xEFAF, 0x9EDA, 0xEFB0, 0x9EFB, 0xEFB1, 0x9EFF,\r\n\t0xEFB2, 0x9F24, 0xEFB3, 0x9F23, 0xEFB4, 0x9F22, 0xEFB5, 0x9F54,\t0xEFB6, 0x9FA0, 0xEFB7, 0x5131, 0xEFB8, 0x512D, 0xEFB9, 0x512E,\r\n\t0xEFBA, 0x5698, 0xEFBB, 0x569C, 0xEFBC, 0x5697, 0xEFBD, 0x569A,\t0xEFBE, 0x569D, 0xEFBF, 0x5699, 0xEFC0, 0x5970, 0xEFC1, 0x5B3C,\r\n\t0xEFC2, 0x5C69, 0xEFC3, 0x5C6A, 0xEFC4, 0x5DC0, 0xEFC5, 0x5E6D,\t0xEFC6, 0x5E6E, 0xEFC7, 0x61D8, 0xEFC8, 0x61DF, 0xEFC9, 0x61ED,\r\n\t0xEFCA, 0x61EE, 0xEFCB, 0x61F1, 0xEFCC, 0x61EA, 0xEFCD, 0x61F0,\t0xEFCE, 0x61EB, 0xEFCF, 0x61D6, 0xEFD0, 0x61E9, 0xEFD1, 0x64FF,\r\n\t0xEFD2, 0x6504, 0xEFD3, 0x64FD, 0xEFD4, 0x64F8, 0xEFD5, 0x6501,\t0xEFD6, 0x6503, 0xEFD7, 0x64FC, 0xEFD8, 0x6594, 0xEFD9, 0x65DB,\r\n\t0xEFDA, 0x66DA, 0xEFDB, 0x66DB, 0xEFDC, 0x66D8, 0xEFDD, 0x6AC5,\t0xEFDE, 0x6AB9, 0xEFDF, 0x6ABD, 0xEFE0, 0x6AE1, 0xEFE1, 0x6AC6,\r\n\t0xEFE2, 0x6ABA, 0xEFE3, 0x6AB6, 0xEFE4, 0x6AB7, 0xEFE5, 0x6AC7,\t0xEFE6, 0x6AB4, 0xEFE7, 0x6AAD, 0xEFE8, 0x6B5E, 0xEFE9, 0x6BC9,\r\n\t0xEFEA, 0x6C0B, 0xEFEB, 0x7007, 0xEFEC, 0x700C, 0xEFED, 0x700D,\t0xEFEE, 0x7001, 0xEFEF, 0x7005, 0xEFF0, 0x7014, 0xEFF1, 0x700E,\r\n\t0xEFF2, 0x6FFF, 0xEFF3, 0x7000, 0xEFF4, 0x6FFB, 0xEFF5, 0x7026,\t0xEFF6, 0x6FFC, 0xEFF7, 0x6FF7, 0xEFF8, 0x700A, 0xEFF9, 0x7201,\r\n\t0xEFFA, 0x71FF, 0xEFFB, 0x71F9, 0xEFFC, 0x7203, 0xEFFD, 0x71FD,\t0xEFFE, 0x7376, 0xF040, 0x74B8, 0xF041, 0x74C0, 0xF042, 0x74B5,\r\n\t0xF043, 0x74C1, 0xF044, 0x74BE, 0xF045, 0x74B6, 0xF046, 0x74BB,\t0xF047, 0x74C2, 0xF048, 0x7514, 0xF049, 0x7513, 0xF04A, 0x765C,\r\n\t0xF04B, 0x7664, 0xF04C, 0x7659, 0xF04D, 0x7650, 0xF04E, 0x7653,\t0xF04F, 0x7657, 0xF050, 0x765A, 0xF051, 0x76A6, 0xF052, 0x76BD,\r\n\t0xF053, 0x76EC, 0xF054, 0x77C2, 0xF055, 0x77BA, 0xF056, 0x78FF,\t0xF057, 0x790C, 0xF058, 0x7913, 0xF059, 0x7914, 0xF05A, 0x7909,\r\n\t0xF05B, 0x7910, 0xF05C, 0x7912, 0xF05D, 0x7911, 0xF05E, 0x79AD,\t0xF05F, 0x79AC, 0xF060, 0x7A5F, 0xF061, 0x7C1C, 0xF062, 0x7C29,\r\n\t0xF063, 0x7C19, 0xF064, 0x7C20, 0xF065, 0x7C1F, 0xF066, 0x7C2D,\t0xF067, 0x7C1D, 0xF068, 0x7C26, 0xF069, 0x7C28, 0xF06A, 0x7C22,\r\n\t0xF06B, 0x7C25, 0xF06C, 0x7C30, 0xF06D, 0x7E5C, 0xF06E, 0x7E50,\t0xF06F, 0x7E56, 0xF070, 0x7E63, 0xF071, 0x7E58, 0xF072, 0x7E62,\r\n\t0xF073, 0x7E5F, 0xF074, 0x7E51, 0xF075, 0x7E60, 0xF076, 0x7E57,\t0xF077, 0x7E53, 0xF078, 0x7FB5, 0xF079, 0x7FB3, 0xF07A, 0x7FF7,\r\n\t0xF07B, 0x7FF8, 0xF07C, 0x8075, 0xF07D, 0x81D1, 0xF07E, 0x81D2,\t0xF0A1, 0x81D0, 0xF0A2, 0x825F, 0xF0A3, 0x825E, 0xF0A4, 0x85B4,\r\n\t0xF0A5, 0x85C6, 0xF0A6, 0x85C0, 0xF0A7, 0x85C3, 0xF0A8, 0x85C2,\t0xF0A9, 0x85B3, 0xF0AA, 0x85B5, 0xF0AB, 0x85BD, 0xF0AC, 0x85C7,\r\n\t0xF0AD, 0x85C4, 0xF0AE, 0x85BF, 0xF0AF, 0x85CB, 0xF0B0, 0x85CE,\t0xF0B1, 0x85C8, 0xF0B2, 0x85C5, 0xF0B3, 0x85B1, 0xF0B4, 0x85B6,\r\n\t0xF0B5, 0x85D2, 0xF0B6, 0x8624, 0xF0B7, 0x85B8, 0xF0B8, 0x85B7,\t0xF0B9, 0x85BE, 0xF0BA, 0x8669, 0xF0BB, 0x87E7, 0xF0BC, 0x87E6,\r\n\t0xF0BD, 0x87E2, 0xF0BE, 0x87DB, 0xF0BF, 0x87EB, 0xF0C0, 0x87EA,\t0xF0C1, 0x87E5, 0xF0C2, 0x87DF, 0xF0C3, 0x87F3, 0xF0C4, 0x87E4,\r\n\t0xF0C5, 0x87D4, 0xF0C6, 0x87DC, 0xF0C7, 0x87D3, 0xF0C8, 0x87ED,\t0xF0C9, 0x87D8, 0xF0CA, 0x87E3, 0xF0CB, 0x87A4, 0xF0CC, 0x87D7,\r\n\t0xF0CD, 0x87D9, 0xF0CE, 0x8801, 0xF0CF, 0x87F4, 0xF0D0, 0x87E8,\t0xF0D1, 0x87DD, 0xF0D2, 0x8953, 0xF0D3, 0x894B, 0xF0D4, 0x894F,\r\n\t0xF0D5, 0x894C, 0xF0D6, 0x8946, 0xF0D7, 0x8950, 0xF0D8, 0x8951,\t0xF0D9, 0x8949, 0xF0DA, 0x8B2A, 0xF0DB, 0x8B27, 0xF0DC, 0x8B23,\r\n\t0xF0DD, 0x8B33, 0xF0DE, 0x8B30, 0xF0DF, 0x8B35, 0xF0E0, 0x8B47,\t0xF0E1, 0x8B2F, 0xF0E2, 0x8B3C, 0xF0E3, 0x8B3E, 0xF0E4, 0x8B31,\r\n\t0xF0E5, 0x8B25, 0xF0E6, 0x8B37, 0xF0E7, 0x8B26, 0xF0E8, 0x8B36,\t0xF0E9, 0x8B2E, 0xF0EA, 0x8B24, 0xF0EB, 0x8B3B, 0xF0EC, 0x8B3D,\r\n\t0xF0ED, 0x8B3A, 0xF0EE, 0x8C42, 0xF0EF, 0x8C75, 0xF0F0, 0x8C99,\t0xF0F1, 0x8C98, 0xF0F2, 0x8C97, 0xF0F3, 0x8CFE, 0xF0F4, 0x8D04,\r\n\t0xF0F5, 0x8D02, 0xF0F6, 0x8D00, 0xF0F7, 0x8E5C, 0xF0F8, 0x8E62,\t0xF0F9, 0x8E60, 0xF0FA, 0x8E57, 0xF0FB, 0x8E56, 0xF0FC, 0x8E5E,\r\n\t0xF0FD, 0x8E65, 0xF0FE, 0x8E67, 0xF140, 0x8E5B, 0xF141, 0x8E5A,\t0xF142, 0x8E61, 0xF143, 0x8E5D, 0xF144, 0x8E69, 0xF145, 0x8E54,\r\n\t0xF146, 0x8F46, 0xF147, 0x8F47, 0xF148, 0x8F48, 0xF149, 0x8F4B,\t0xF14A, 0x9128, 0xF14B, 0x913A, 0xF14C, 0x913B, 0xF14D, 0x913E,\r\n\t0xF14E, 0x91A8, 0xF14F, 0x91A5, 0xF150, 0x91A7, 0xF151, 0x91AF,\t0xF152, 0x91AA, 0xF153, 0x93B5, 0xF154, 0x938C, 0xF155, 0x9392,\r\n\t0xF156, 0x93B7, 0xF157, 0x939B, 0xF158, 0x939D, 0xF159, 0x9389,\t0xF15A, 0x93A7, 0xF15B, 0x938E, 0xF15C, 0x93AA, 0xF15D, 0x939E,\r\n\t0xF15E, 0x93A6, 0xF15F, 0x9395, 0xF160, 0x9388, 0xF161, 0x9399,\t0xF162, 0x939F, 0xF163, 0x938D, 0xF164, 0x93B1, 0xF165, 0x9391,\r\n\t0xF166, 0x93B2, 0xF167, 0x93A4, 0xF168, 0x93A8, 0xF169, 0x93B4,\t0xF16A, 0x93A3, 0xF16B, 0x93A5, 0xF16C, 0x95D2, 0xF16D, 0x95D3,\r\n\t0xF16E, 0x95D1, 0xF16F, 0x96B3, 0xF170, 0x96D7, 0xF171, 0x96DA,\t0xF172, 0x5DC2, 0xF173, 0x96DF, 0xF174, 0x96D8, 0xF175, 0x96DD,\r\n\t0xF176, 0x9723, 0xF177, 0x9722, 0xF178, 0x9725, 0xF179, 0x97AC,\t0xF17A, 0x97AE, 0xF17B, 0x97A8, 0xF17C, 0x97AB, 0xF17D, 0x97A4,\r\n\t0xF17E, 0x97AA, 0xF1A1, 0x97A2, 0xF1A2, 0x97A5, 0xF1A3, 0x97D7,\t0xF1A4, 0x97D9, 0xF1A5, 0x97D6, 0xF1A6, 0x97D8, 0xF1A7, 0x97FA,\r\n\t0xF1A8, 0x9850, 0xF1A9, 0x9851, 0xF1AA, 0x9852, 0xF1AB, 0x98B8,\t0xF1AC, 0x9941, 0xF1AD, 0x993C, 0xF1AE, 0x993A, 0xF1AF, 0x9A0F,\r\n\t0xF1B0, 0x9A0B, 0xF1B1, 0x9A09, 0xF1B2, 0x9A0D, 0xF1B3, 0x9A04,\t0xF1B4, 0x9A11, 0xF1B5, 0x9A0A, 0xF1B6, 0x9A05, 0xF1B7, 0x9A07,\r\n\t0xF1B8, 0x9A06, 0xF1B9, 0x9AC0, 0xF1BA, 0x9ADC, 0xF1BB, 0x9B08,\t0xF1BC, 0x9B04, 0xF1BD, 0x9B05, 0xF1BE, 0x9B29, 0xF1BF, 0x9B35,\r\n\t0xF1C0, 0x9B4A, 0xF1C1, 0x9B4C, 0xF1C2, 0x9B4B, 0xF1C3, 0x9BC7,\t0xF1C4, 0x9BC6, 0xF1C5, 0x9BC3, 0xF1C6, 0x9BBF, 0xF1C7, 0x9BC1,\r\n\t0xF1C8, 0x9BB5, 0xF1C9, 0x9BB8, 0xF1CA, 0x9BD3, 0xF1CB, 0x9BB6,\t0xF1CC, 0x9BC4, 0xF1CD, 0x9BB9, 0xF1CE, 0x9BBD, 0xF1CF, 0x9D5C,\r\n\t0xF1D0, 0x9D53, 0xF1D1, 0x9D4F, 0xF1D2, 0x9D4A, 0xF1D3, 0x9D5B,\t0xF1D4, 0x9D4B, 0xF1D5, 0x9D59, 0xF1D6, 0x9D56, 0xF1D7, 0x9D4C,\r\n\t0xF1D8, 0x9D57, 0xF1D9, 0x9D52, 0xF1DA, 0x9D54, 0xF1DB, 0x9D5F,\t0xF1DC, 0x9D58, 0xF1DD, 0x9D5A, 0xF1DE, 0x9E8E, 0xF1DF, 0x9E8C,\r\n\t0xF1E0, 0x9EDF, 0xF1E1, 0x9F01, 0xF1E2, 0x9F00, 0xF1E3, 0x9F16,\t0xF1E4, 0x9F25, 0xF1E5, 0x9F2B, 0xF1E6, 0x9F2A, 0xF1E7, 0x9F29,\r\n\t0xF1E8, 0x9F28, 0xF1E9, 0x9F4C, 0xF1EA, 0x9F55, 0xF1EB, 0x5134,\t0xF1EC, 0x5135, 0xF1ED, 0x5296, 0xF1EE, 0x52F7, 0xF1EF, 0x53B4,\r\n\t0xF1F0, 0x56AB, 0xF1F1, 0x56AD, 0xF1F2, 0x56A6, 0xF1F3, 0x56A7,\t0xF1F4, 0x56AA, 0xF1F5, 0x56AC, 0xF1F6, 0x58DA, 0xF1F7, 0x58DD,\r\n\t0xF1F8, 0x58DB, 0xF1F9, 0x5912, 0xF1FA, 0x5B3D, 0xF1FB, 0x5B3E,\t0xF1FC, 0x5B3F, 0xF1FD, 0x5DC3, 0xF1FE, 0x5E70, 0xF240, 0x5FBF,\r\n\t0xF241, 0x61FB, 0xF242, 0x6507, 0xF243, 0x6510, 0xF244, 0x650D,\t0xF245, 0x6509, 0xF246, 0x650C, 0xF247, 0x650E, 0xF248, 0x6584,\r\n\t0xF249, 0x65DE, 0xF24A, 0x65DD, 0xF24B, 0x66DE, 0xF24C, 0x6AE7,\t0xF24D, 0x6AE0, 0xF24E, 0x6ACC, 0xF24F, 0x6AD1, 0xF250, 0x6AD9,\r\n\t0xF251, 0x6ACB, 0xF252, 0x6ADF, 0xF253, 0x6ADC, 0xF254, 0x6AD0,\t0xF255, 0x6AEB, 0xF256, 0x6ACF, 0xF257, 0x6ACD, 0xF258, 0x6ADE,\r\n\t0xF259, 0x6B60, 0xF25A, 0x6BB0, 0xF25B, 0x6C0C, 0xF25C, 0x7019,\t0xF25D, 0x7027, 0xF25E, 0x7020, 0xF25F, 0x7016, 0xF260, 0x702B,\r\n\t0xF261, 0x7021, 0xF262, 0x7022, 0xF263, 0x7023, 0xF264, 0x7029,\t0xF265, 0x7017, 0xF266, 0x7024, 0xF267, 0x701C, 0xF268, 0x702A,\r\n\t0xF269, 0x720C, 0xF26A, 0x720A, 0xF26B, 0x7207, 0xF26C, 0x7202,\t0xF26D, 0x7205, 0xF26E, 0x72A5, 0xF26F, 0x72A6, 0xF270, 0x72A4,\r\n\t0xF271, 0x72A3, 0xF272, 0x72A1, 0xF273, 0x74CB, 0xF274, 0x74C5,\t0xF275, 0x74B7, 0xF276, 0x74C3, 0xF277, 0x7516, 0xF278, 0x7660,\r\n\t0xF279, 0x77C9, 0xF27A, 0x77CA, 0xF27B, 0x77C4, 0xF27C, 0x77F1,\t0xF27D, 0x791D, 0xF27E, 0x791B, 0xF2A1, 0x7921, 0xF2A2, 0x791C,\r\n\t0xF2A3, 0x7917, 0xF2A4, 0x791E, 0xF2A5, 0x79B0, 0xF2A6, 0x7A67,\t0xF2A7, 0x7A68, 0xF2A8, 0x7C33, 0xF2A9, 0x7C3C, 0xF2AA, 0x7C39,\r\n\t0xF2AB, 0x7C2C, 0xF2AC, 0x7C3B, 0xF2AD, 0x7CEC, 0xF2AE, 0x7CEA,\t0xF2AF, 0x7E76, 0xF2B0, 0x7E75, 0xF2B1, 0x7E78, 0xF2B2, 0x7E70,\r\n\t0xF2B3, 0x7E77, 0xF2B4, 0x7E6F, 0xF2B5, 0x7E7A, 0xF2B6, 0x7E72,\t0xF2B7, 0x7E74, 0xF2B8, 0x7E68, 0xF2B9, 0x7F4B, 0xF2BA, 0x7F4A,\r\n\t0xF2BB, 0x7F83, 0xF2BC, 0x7F86, 0xF2BD, 0x7FB7, 0xF2BE, 0x7FFD,\t0xF2BF, 0x7FFE, 0xF2C0, 0x8078, 0xF2C1, 0x81D7, 0xF2C2, 0x81D5,\r\n\t0xF2C3, 0x8264, 0xF2C4, 0x8261, 0xF2C5, 0x8263, 0xF2C6, 0x85EB,\t0xF2C7, 0x85F1, 0xF2C8, 0x85ED, 0xF2C9, 0x85D9, 0xF2CA, 0x85E1,\r\n\t0xF2CB, 0x85E8, 0xF2CC, 0x85DA, 0xF2CD, 0x85D7, 0xF2CE, 0x85EC,\t0xF2CF, 0x85F2, 0xF2D0, 0x85F8, 0xF2D1, 0x85D8, 0xF2D2, 0x85DF,\r\n\t0xF2D3, 0x85E3, 0xF2D4, 0x85DC, 0xF2D5, 0x85D1, 0xF2D6, 0x85F0,\t0xF2D7, 0x85E6, 0xF2D8, 0x85EF, 0xF2D9, 0x85DE, 0xF2DA, 0x85E2,\r\n\t0xF2DB, 0x8800, 0xF2DC, 0x87FA, 0xF2DD, 0x8803, 0xF2DE, 0x87F6,\t0xF2DF, 0x87F7, 0xF2E0, 0x8809, 0xF2E1, 0x880C, 0xF2E2, 0x880B,\r\n\t0xF2E3, 0x8806, 0xF2E4, 0x87FC, 0xF2E5, 0x8808, 0xF2E6, 0x87FF,\t0xF2E7, 0x880A, 0xF2E8, 0x8802, 0xF2E9, 0x8962, 0xF2EA, 0x895A,\r\n\t0xF2EB, 0x895B, 0xF2EC, 0x8957, 0xF2ED, 0x8961, 0xF2EE, 0x895C,\t0xF2EF, 0x8958, 0xF2F0, 0x895D, 0xF2F1, 0x8959, 0xF2F2, 0x8988,\r\n\t0xF2F3, 0x89B7, 0xF2F4, 0x89B6, 0xF2F5, 0x89F6, 0xF2F6, 0x8B50,\t0xF2F7, 0x8B48, 0xF2F8, 0x8B4A, 0xF2F9, 0x8B40, 0xF2FA, 0x8B53,\r\n\t0xF2FB, 0x8B56, 0xF2FC, 0x8B54, 0xF2FD, 0x8B4B, 0xF2FE, 0x8B55,\t0xF340, 0x8B51, 0xF341, 0x8B42, 0xF342, 0x8B52, 0xF343, 0x8B57,\r\n\t0xF344, 0x8C43, 0xF345, 0x8C77, 0xF346, 0x8C76, 0xF347, 0x8C9A,\t0xF348, 0x8D06, 0xF349, 0x8D07, 0xF34A, 0x8D09, 0xF34B, 0x8DAC,\r\n\t0xF34C, 0x8DAA, 0xF34D, 0x8DAD, 0xF34E, 0x8DAB, 0xF34F, 0x8E6D,\t0xF350, 0x8E78, 0xF351, 0x8E73, 0xF352, 0x8E6A, 0xF353, 0x8E6F,\r\n\t0xF354, 0x8E7B, 0xF355, 0x8EC2, 0xF356, 0x8F52, 0xF357, 0x8F51,\t0xF358, 0x8F4F, 0xF359, 0x8F50, 0xF35A, 0x8F53, 0xF35B, 0x8FB4,\r\n\t0xF35C, 0x9140, 0xF35D, 0x913F, 0xF35E, 0x91B0, 0xF35F, 0x91AD,\t0xF360, 0x93DE, 0xF361, 0x93C7, 0xF362, 0x93CF, 0xF363, 0x93C2,\r\n\t0xF364, 0x93DA, 0xF365, 0x93D0, 0xF366, 0x93F9, 0xF367, 0x93EC,\t0xF368, 0x93CC, 0xF369, 0x93D9, 0xF36A, 0x93A9, 0xF36B, 0x93E6,\r\n\t0xF36C, 0x93CA, 0xF36D, 0x93D4, 0xF36E, 0x93EE, 0xF36F, 0x93E3,\t0xF370, 0x93D5, 0xF371, 0x93C4, 0xF372, 0x93CE, 0xF373, 0x93C0,\r\n\t0xF374, 0x93D2, 0xF375, 0x93E7, 0xF376, 0x957D, 0xF377, 0x95DA,\t0xF378, 0x95DB, 0xF379, 0x96E1, 0xF37A, 0x9729, 0xF37B, 0x972B,\r\n\t0xF37C, 0x972C, 0xF37D, 0x9728, 0xF37E, 0x9726, 0xF3A1, 0x97B3,\t0xF3A2, 0x97B7, 0xF3A3, 0x97B6, 0xF3A4, 0x97DD, 0xF3A5, 0x97DE,\r\n\t0xF3A6, 0x97DF, 0xF3A7, 0x985C, 0xF3A8, 0x9859, 0xF3A9, 0x985D,\t0xF3AA, 0x9857, 0xF3AB, 0x98BF, 0xF3AC, 0x98BD, 0xF3AD, 0x98BB,\r\n\t0xF3AE, 0x98BE, 0xF3AF, 0x9948, 0xF3B0, 0x9947, 0xF3B1, 0x9943,\t0xF3B2, 0x99A6, 0xF3B3, 0x99A7, 0xF3B4, 0x9A1A, 0xF3B5, 0x9A15,\r\n\t0xF3B6, 0x9A25, 0xF3B7, 0x9A1D, 0xF3B8, 0x9A24, 0xF3B9, 0x9A1B,\t0xF3BA, 0x9A22, 0xF3BB, 0x9A20, 0xF3BC, 0x9A27, 0xF3BD, 0x9A23,\r\n\t0xF3BE, 0x9A1E, 0xF3BF, 0x9A1C, 0xF3C0, 0x9A14, 0xF3C1, 0x9AC2,\t0xF3C2, 0x9B0B, 0xF3C3, 0x9B0A, 0xF3C4, 0x9B0E, 0xF3C5, 0x9B0C,\r\n\t0xF3C6, 0x9B37, 0xF3C7, 0x9BEA, 0xF3C8, 0x9BEB, 0xF3C9, 0x9BE0,\t0xF3CA, 0x9BDE, 0xF3CB, 0x9BE4, 0xF3CC, 0x9BE6, 0xF3CD, 0x9BE2,\r\n\t0xF3CE, 0x9BF0, 0xF3CF, 0x9BD4, 0xF3D0, 0x9BD7, 0xF3D1, 0x9BEC,\t0xF3D2, 0x9BDC, 0xF3D3, 0x9BD9, 0xF3D4, 0x9BE5, 0xF3D5, 0x9BD5,\r\n\t0xF3D6, 0x9BE1, 0xF3D7, 0x9BDA, 0xF3D8, 0x9D77, 0xF3D9, 0x9D81,\t0xF3DA, 0x9D8A, 0xF3DB, 0x9D84, 0xF3DC, 0x9D88, 0xF3DD, 0x9D71,\r\n\t0xF3DE, 0x9D80, 0xF3DF, 0x9D78, 0xF3E0, 0x9D86, 0xF3E1, 0x9D8B,\t0xF3E2, 0x9D8C, 0xF3E3, 0x9D7D, 0xF3E4, 0x9D6B, 0xF3E5, 0x9D74,\r\n\t0xF3E6, 0x9D75, 0xF3E7, 0x9D70, 0xF3E8, 0x9D69, 0xF3E9, 0x9D85,\t0xF3EA, 0x9D73, 0xF3EB, 0x9D7B, 0xF3EC, 0x9D82, 0xF3ED, 0x9D6F,\r\n\t0xF3EE, 0x9D79, 0xF3EF, 0x9D7F, 0xF3F0, 0x9D87, 0xF3F1, 0x9D68,\t0xF3F2, 0x9E94, 0xF3F3, 0x9E91, 0xF3F4, 0x9EC0, 0xF3F5, 0x9EFC,\r\n\t0xF3F6, 0x9F2D, 0xF3F7, 0x9F40, 0xF3F8, 0x9F41, 0xF3F9, 0x9F4D,\t0xF3FA, 0x9F56, 0xF3FB, 0x9F57, 0xF3FC, 0x9F58, 0xF3FD, 0x5337,\r\n\t0xF3FE, 0x56B2, 0xF440, 0x56B5, 0xF441, 0x56B3, 0xF442, 0x58E3,\t0xF443, 0x5B45, 0xF444, 0x5DC6, 0xF445, 0x5DC7, 0xF446, 0x5EEE,\r\n\t0xF447, 0x5EEF, 0xF448, 0x5FC0, 0xF449, 0x5FC1, 0xF44A, 0x61F9,\t0xF44B, 0x6517, 0xF44C, 0x6516, 0xF44D, 0x6515, 0xF44E, 0x6513,\r\n\t0xF44F, 0x65DF, 0xF450, 0x66E8, 0xF451, 0x66E3, 0xF452, 0x66E4,\t0xF453, 0x6AF3, 0xF454, 0x6AF0, 0xF455, 0x6AEA, 0xF456, 0x6AE8,\r\n\t0xF457, 0x6AF9, 0xF458, 0x6AF1, 0xF459, 0x6AEE, 0xF45A, 0x6AEF,\t0xF45B, 0x703C, 0xF45C, 0x7035, 0xF45D, 0x702F, 0xF45E, 0x7037,\r\n\t0xF45F, 0x7034, 0xF460, 0x7031, 0xF461, 0x7042, 0xF462, 0x7038,\t0xF463, 0x703F, 0xF464, 0x703A, 0xF465, 0x7039, 0xF466, 0x7040,\r\n\t0xF467, 0x703B, 0xF468, 0x7033, 0xF469, 0x7041, 0xF46A, 0x7213,\t0xF46B, 0x7214, 0xF46C, 0x72A8, 0xF46D, 0x737D, 0xF46E, 0x737C,\r\n\t0xF46F, 0x74BA, 0xF470, 0x76AB, 0xF471, 0x76AA, 0xF472, 0x76BE,\t0xF473, 0x76ED, 0xF474, 0x77CC, 0xF475, 0x77CE, 0xF476, 0x77CF,\r\n\t0xF477, 0x77CD, 0xF478, 0x77F2, 0xF479, 0x7925, 0xF47A, 0x7923,\t0xF47B, 0x7927, 0xF47C, 0x7928, 0xF47D, 0x7924, 0xF47E, 0x7929,\r\n\t0xF4A1, 0x79B2, 0xF4A2, 0x7A6E, 0xF4A3, 0x7A6C, 0xF4A4, 0x7A6D,\t0xF4A5, 0x7AF7, 0xF4A6, 0x7C49, 0xF4A7, 0x7C48, 0xF4A8, 0x7C4A,\r\n\t0xF4A9, 0x7C47, 0xF4AA, 0x7C45, 0xF4AB, 0x7CEE, 0xF4AC, 0x7E7B,\t0xF4AD, 0x7E7E, 0xF4AE, 0x7E81, 0xF4AF, 0x7E80, 0xF4B0, 0x7FBA,\r\n\t0xF4B1, 0x7FFF, 0xF4B2, 0x8079, 0xF4B3, 0x81DB, 0xF4B4, 0x81D9,\t0xF4B5, 0x820B, 0xF4B6, 0x8268, 0xF4B7, 0x8269, 0xF4B8, 0x8622,\r\n\t0xF4B9, 0x85FF, 0xF4BA, 0x8601, 0xF4BB, 0x85FE, 0xF4BC, 0x861B,\t0xF4BD, 0x8600, 0xF4BE, 0x85F6, 0xF4BF, 0x8604, 0xF4C0, 0x8609,\r\n\t0xF4C1, 0x8605, 0xF4C2, 0x860C, 0xF4C3, 0x85FD, 0xF4C4, 0x8819,\t0xF4C5, 0x8810, 0xF4C6, 0x8811, 0xF4C7, 0x8817, 0xF4C8, 0x8813,\r\n\t0xF4C9, 0x8816, 0xF4CA, 0x8963, 0xF4CB, 0x8966, 0xF4CC, 0x89B9,\t0xF4CD, 0x89F7, 0xF4CE, 0x8B60, 0xF4CF, 0x8B6A, 0xF4D0, 0x8B5D,\r\n\t0xF4D1, 0x8B68, 0xF4D2, 0x8B63, 0xF4D3, 0x8B65, 0xF4D4, 0x8B67,\t0xF4D5, 0x8B6D, 0xF4D6, 0x8DAE, 0xF4D7, 0x8E86, 0xF4D8, 0x8E88,\r\n\t0xF4D9, 0x8E84, 0xF4DA, 0x8F59, 0xF4DB, 0x8F56, 0xF4DC, 0x8F57,\t0xF4DD, 0x8F55, 0xF4DE, 0x8F58, 0xF4DF, 0x8F5A, 0xF4E0, 0x908D,\r\n\t0xF4E1, 0x9143, 0xF4E2, 0x9141, 0xF4E3, 0x91B7, 0xF4E4, 0x91B5,\t0xF4E5, 0x91B2, 0xF4E6, 0x91B3, 0xF4E7, 0x940B, 0xF4E8, 0x9413,\r\n\t0xF4E9, 0x93FB, 0xF4EA, 0x9420, 0xF4EB, 0x940F, 0xF4EC, 0x9414,\t0xF4ED, 0x93FE, 0xF4EE, 0x9415, 0xF4EF, 0x9410, 0xF4F0, 0x9428,\r\n\t0xF4F1, 0x9419, 0xF4F2, 0x940D, 0xF4F3, 0x93F5, 0xF4F4, 0x9400,\t0xF4F5, 0x93F7, 0xF4F6, 0x9407, 0xF4F7, 0x940E, 0xF4F8, 0x9416,\r\n\t0xF4F9, 0x9412, 0xF4FA, 0x93FA, 0xF4FB, 0x9409, 0xF4FC, 0x93F8,\t0xF4FD, 0x940A, 0xF4FE, 0x93FF, 0xF540, 0x93FC, 0xF541, 0x940C,\r\n\t0xF542, 0x93F6, 0xF543, 0x9411, 0xF544, 0x9406, 0xF545, 0x95DE,\t0xF546, 0x95E0, 0xF547, 0x95DF, 0xF548, 0x972E, 0xF549, 0x972F,\r\n\t0xF54A, 0x97B9, 0xF54B, 0x97BB, 0xF54C, 0x97FD, 0xF54D, 0x97FE,\t0xF54E, 0x9860, 0xF54F, 0x9862, 0xF550, 0x9863, 0xF551, 0x985F,\r\n\t0xF552, 0x98C1, 0xF553, 0x98C2, 0xF554, 0x9950, 0xF555, 0x994E,\t0xF556, 0x9959, 0xF557, 0x994C, 0xF558, 0x994B, 0xF559, 0x9953,\r\n\t0xF55A, 0x9A32, 0xF55B, 0x9A34, 0xF55C, 0x9A31, 0xF55D, 0x9A2C,\t0xF55E, 0x9A2A, 0xF55F, 0x9A36, 0xF560, 0x9A29, 0xF561, 0x9A2E,\r\n\t0xF562, 0x9A38, 0xF563, 0x9A2D, 0xF564, 0x9AC7, 0xF565, 0x9ACA,\t0xF566, 0x9AC6, 0xF567, 0x9B10, 0xF568, 0x9B12, 0xF569, 0x9B11,\r\n\t0xF56A, 0x9C0B, 0xF56B, 0x9C08, 0xF56C, 0x9BF7, 0xF56D, 0x9C05,\t0xF56E, 0x9C12, 0xF56F, 0x9BF8, 0xF570, 0x9C40, 0xF571, 0x9C07,\r\n\t0xF572, 0x9C0E, 0xF573, 0x9C06, 0xF574, 0x9C17, 0xF575, 0x9C14,\t0xF576, 0x9C09, 0xF577, 0x9D9F, 0xF578, 0x9D99, 0xF579, 0x9DA4,\r\n\t0xF57A, 0x9D9D, 0xF57B, 0x9D92, 0xF57C, 0x9D98, 0xF57D, 0x9D90,\t0xF57E, 0x9D9B, 0xF5A1, 0x9DA0, 0xF5A2, 0x9D94, 0xF5A3, 0x9D9C,\r\n\t0xF5A4, 0x9DAA, 0xF5A5, 0x9D97, 0xF5A6, 0x9DA1, 0xF5A7, 0x9D9A,\t0xF5A8, 0x9DA2, 0xF5A9, 0x9DA8, 0xF5AA, 0x9D9E, 0xF5AB, 0x9DA3,\r\n\t0xF5AC, 0x9DBF, 0xF5AD, 0x9DA9, 0xF5AE, 0x9D96, 0xF5AF, 0x9DA6,\t0xF5B0, 0x9DA7, 0xF5B1, 0x9E99, 0xF5B2, 0x9E9B, 0xF5B3, 0x9E9A,\r\n\t0xF5B4, 0x9EE5, 0xF5B5, 0x9EE4, 0xF5B6, 0x9EE7, 0xF5B7, 0x9EE6,\t0xF5B8, 0x9F30, 0xF5B9, 0x9F2E, 0xF5BA, 0x9F5B, 0xF5BB, 0x9F60,\r\n\t0xF5BC, 0x9F5E, 0xF5BD, 0x9F5D, 0xF5BE, 0x9F59, 0xF5BF, 0x9F91,\t0xF5C0, 0x513A, 0xF5C1, 0x5139, 0xF5C2, 0x5298, 0xF5C3, 0x5297,\r\n\t0xF5C4, 0x56C3, 0xF5C5, 0x56BD, 0xF5C6, 0x56BE, 0xF5C7, 0x5B48,\t0xF5C8, 0x5B47, 0xF5C9, 0x5DCB, 0xF5CA, 0x5DCF, 0xF5CB, 0x5EF1,\r\n\t0xF5CC, 0x61FD, 0xF5CD, 0x651B, 0xF5CE, 0x6B02, 0xF5CF, 0x6AFC,\t0xF5D0, 0x6B03, 0xF5D1, 0x6AF8, 0xF5D2, 0x6B00, 0xF5D3, 0x7043,\r\n\t0xF5D4, 0x7044, 0xF5D5, 0x704A, 0xF5D6, 0x7048, 0xF5D7, 0x7049,\t0xF5D8, 0x7045, 0xF5D9, 0x7046, 0xF5DA, 0x721D, 0xF5DB, 0x721A,\r\n\t0xF5DC, 0x7219, 0xF5DD, 0x737E, 0xF5DE, 0x7517, 0xF5DF, 0x766A,\t0xF5E0, 0x77D0, 0xF5E1, 0x792D, 0xF5E2, 0x7931, 0xF5E3, 0x792F,\r\n\t0xF5E4, 0x7C54, 0xF5E5, 0x7C53, 0xF5E6, 0x7CF2, 0xF5E7, 0x7E8A,\t0xF5E8, 0x7E87, 0xF5E9, 0x7E88, 0xF5EA, 0x7E8B, 0xF5EB, 0x7E86,\r\n\t0xF5EC, 0x7E8D, 0xF5ED, 0x7F4D, 0xF5EE, 0x7FBB, 0xF5EF, 0x8030,\t0xF5F0, 0x81DD, 0xF5F1, 0x8618, 0xF5F2, 0x862A, 0xF5F3, 0x8626,\r\n\t0xF5F4, 0x861F, 0xF5F5, 0x8623, 0xF5F6, 0x861C, 0xF5F7, 0x8619,\t0xF5F8, 0x8627, 0xF5F9, 0x862E, 0xF5FA, 0x8621, 0xF5FB, 0x8620,\r\n\t0xF5FC, 0x8629, 0xF5FD, 0x861E, 0xF5FE, 0x8625, 0xF640, 0x8829,\t0xF641, 0x881D, 0xF642, 0x881B, 0xF643, 0x8820, 0xF644, 0x8824,\r\n\t0xF645, 0x881C, 0xF646, 0x882B, 0xF647, 0x884A, 0xF648, 0x896D,\t0xF649, 0x8969, 0xF64A, 0x896E, 0xF64B, 0x896B, 0xF64C, 0x89FA,\r\n\t0xF64D, 0x8B79, 0xF64E, 0x8B78, 0xF64F, 0x8B45, 0xF650, 0x8B7A,\t0xF651, 0x8B7B, 0xF652, 0x8D10, 0xF653, 0x8D14, 0xF654, 0x8DAF,\r\n\t0xF655, 0x8E8E, 0xF656, 0x8E8C, 0xF657, 0x8F5E, 0xF658, 0x8F5B,\t0xF659, 0x8F5D, 0xF65A, 0x9146, 0xF65B, 0x9144, 0xF65C, 0x9145,\r\n\t0xF65D, 0x91B9, 0xF65E, 0x943F, 0xF65F, 0x943B, 0xF660, 0x9436,\t0xF661, 0x9429, 0xF662, 0x943D, 0xF663, 0x943C, 0xF664, 0x9430,\r\n\t0xF665, 0x9439, 0xF666, 0x942A, 0xF667, 0x9437, 0xF668, 0x942C,\t0xF669, 0x9440, 0xF66A, 0x9431, 0xF66B, 0x95E5, 0xF66C, 0x95E4,\r\n\t0xF66D, 0x95E3, 0xF66E, 0x9735, 0xF66F, 0x973A, 0xF670, 0x97BF,\t0xF671, 0x97E1, 0xF672, 0x9864, 0xF673, 0x98C9, 0xF674, 0x98C6,\r\n\t0xF675, 0x98C0, 0xF676, 0x9958, 0xF677, 0x9956, 0xF678, 0x9A39,\t0xF679, 0x9A3D, 0xF67A, 0x9A46, 0xF67B, 0x9A44, 0xF67C, 0x9A42,\r\n\t0xF67D, 0x9A41, 0xF67E, 0x9A3A, 0xF6A1, 0x9A3F, 0xF6A2, 0x9ACD,\t0xF6A3, 0x9B15, 0xF6A4, 0x9B17, 0xF6A5, 0x9B18, 0xF6A6, 0x9B16,\r\n\t0xF6A7, 0x9B3A, 0xF6A8, 0x9B52, 0xF6A9, 0x9C2B, 0xF6AA, 0x9C1D,\t0xF6AB, 0x9C1C, 0xF6AC, 0x9C2C, 0xF6AD, 0x9C23, 0xF6AE, 0x9C28,\r\n\t0xF6AF, 0x9C29, 0xF6B0, 0x9C24, 0xF6B1, 0x9C21, 0xF6B2, 0x9DB7,\t0xF6B3, 0x9DB6, 0xF6B4, 0x9DBC, 0xF6B5, 0x9DC1, 0xF6B6, 0x9DC7,\r\n\t0xF6B7, 0x9DCA, 0xF6B8, 0x9DCF, 0xF6B9, 0x9DBE, 0xF6BA, 0x9DC5,\t0xF6BB, 0x9DC3, 0xF6BC, 0x9DBB, 0xF6BD, 0x9DB5, 0xF6BE, 0x9DCE,\r\n\t0xF6BF, 0x9DB9, 0xF6C0, 0x9DBA, 0xF6C1, 0x9DAC, 0xF6C2, 0x9DC8,\t0xF6C3, 0x9DB1, 0xF6C4, 0x9DAD, 0xF6C5, 0x9DCC, 0xF6C6, 0x9DB3,\r\n\t0xF6C7, 0x9DCD, 0xF6C8, 0x9DB2, 0xF6C9, 0x9E7A, 0xF6CA, 0x9E9C,\t0xF6CB, 0x9EEB, 0xF6CC, 0x9EEE, 0xF6CD, 0x9EED, 0xF6CE, 0x9F1B,\r\n\t0xF6CF, 0x9F18, 0xF6D0, 0x9F1A, 0xF6D1, 0x9F31, 0xF6D2, 0x9F4E,\t0xF6D3, 0x9F65, 0xF6D4, 0x9F64, 0xF6D5, 0x9F92, 0xF6D6, 0x4EB9,\r\n\t0xF6D7, 0x56C6, 0xF6D8, 0x56C5, 0xF6D9, 0x56CB, 0xF6DA, 0x5971,\t0xF6DB, 0x5B4B, 0xF6DC, 0x5B4C, 0xF6DD, 0x5DD5, 0xF6DE, 0x5DD1,\r\n\t0xF6DF, 0x5EF2, 0xF6E0, 0x6521, 0xF6E1, 0x6520, 0xF6E2, 0x6526,\t0xF6E3, 0x6522, 0xF6E4, 0x6B0B, 0xF6E5, 0x6B08, 0xF6E6, 0x6B09,\r\n\t0xF6E7, 0x6C0D, 0xF6E8, 0x7055, 0xF6E9, 0x7056, 0xF6EA, 0x7057,\t0xF6EB, 0x7052, 0xF6EC, 0x721E, 0xF6ED, 0x721F, 0xF6EE, 0x72A9,\r\n\t0xF6EF, 0x737F, 0xF6F0, 0x74D8, 0xF6F1, 0x74D5, 0xF6F2, 0x74D9,\t0xF6F3, 0x74D7, 0xF6F4, 0x766D, 0xF6F5, 0x76AD, 0xF6F6, 0x7935,\r\n\t0xF6F7, 0x79B4, 0xF6F8, 0x7A70, 0xF6F9, 0x7A71, 0xF6FA, 0x7C57,\t0xF6FB, 0x7C5C, 0xF6FC, 0x7C59, 0xF6FD, 0x7C5B, 0xF6FE, 0x7C5A,\r\n\t0xF740, 0x7CF4, 0xF741, 0x7CF1, 0xF742, 0x7E91, 0xF743, 0x7F4F,\t0xF744, 0x7F87, 0xF745, 0x81DE, 0xF746, 0x826B, 0xF747, 0x8634,\r\n\t0xF748, 0x8635, 0xF749, 0x8633, 0xF74A, 0x862C, 0xF74B, 0x8632,\t0xF74C, 0x8636, 0xF74D, 0x882C, 0xF74E, 0x8828, 0xF74F, 0x8826,\r\n\t0xF750, 0x882A, 0xF751, 0x8825, 0xF752, 0x8971, 0xF753, 0x89BF,\t0xF754, 0x89BE, 0xF755, 0x89FB, 0xF756, 0x8B7E, 0xF757, 0x8B84,\r\n\t0xF758, 0x8B82, 0xF759, 0x8B86, 0xF75A, 0x8B85, 0xF75B, 0x8B7F,\t0xF75C, 0x8D15, 0xF75D, 0x8E95, 0xF75E, 0x8E94, 0xF75F, 0x8E9A,\r\n\t0xF760, 0x8E92, 0xF761, 0x8E90, 0xF762, 0x8E96, 0xF763, 0x8E97,\t0xF764, 0x8F60, 0xF765, 0x8F62, 0xF766, 0x9147, 0xF767, 0x944C,\r\n\t0xF768, 0x9450, 0xF769, 0x944A, 0xF76A, 0x944B, 0xF76B, 0x944F,\t0xF76C, 0x9447, 0xF76D, 0x9445, 0xF76E, 0x9448, 0xF76F, 0x9449,\r\n\t0xF770, 0x9446, 0xF771, 0x973F, 0xF772, 0x97E3, 0xF773, 0x986A,\t0xF774, 0x9869, 0xF775, 0x98CB, 0xF776, 0x9954, 0xF777, 0x995B,\r\n\t0xF778, 0x9A4E, 0xF779, 0x9A53, 0xF77A, 0x9A54, 0xF77B, 0x9A4C,\t0xF77C, 0x9A4F, 0xF77D, 0x9A48, 0xF77E, 0x9A4A, 0xF7A1, 0x9A49,\r\n\t0xF7A2, 0x9A52, 0xF7A3, 0x9A50, 0xF7A4, 0x9AD0, 0xF7A5, 0x9B19,\t0xF7A6, 0x9B2B, 0xF7A7, 0x9B3B, 0xF7A8, 0x9B56, 0xF7A9, 0x9B55,\r\n\t0xF7AA, 0x9C46, 0xF7AB, 0x9C48, 0xF7AC, 0x9C3F, 0xF7AD, 0x9C44,\t0xF7AE, 0x9C39, 0xF7AF, 0x9C33, 0xF7B0, 0x9C41, 0xF7B1, 0x9C3C,\r\n\t0xF7B2, 0x9C37, 0xF7B3, 0x9C34, 0xF7B4, 0x9C32, 0xF7B5, 0x9C3D,\t0xF7B6, 0x9C36, 0xF7B7, 0x9DDB, 0xF7B8, 0x9DD2, 0xF7B9, 0x9DDE,\r\n\t0xF7BA, 0x9DDA, 0xF7BB, 0x9DCB, 0xF7BC, 0x9DD0, 0xF7BD, 0x9DDC,\t0xF7BE, 0x9DD1, 0xF7BF, 0x9DDF, 0xF7C0, 0x9DE9, 0xF7C1, 0x9DD9,\r\n\t0xF7C2, 0x9DD8, 0xF7C3, 0x9DD6, 0xF7C4, 0x9DF5, 0xF7C5, 0x9DD5,\t0xF7C6, 0x9DDD, 0xF7C7, 0x9EB6, 0xF7C8, 0x9EF0, 0xF7C9, 0x9F35,\r\n\t0xF7CA, 0x9F33, 0xF7CB, 0x9F32, 0xF7CC, 0x9F42, 0xF7CD, 0x9F6B,\t0xF7CE, 0x9F95, 0xF7CF, 0x9FA2, 0xF7D0, 0x513D, 0xF7D1, 0x5299,\r\n\t0xF7D2, 0x58E8, 0xF7D3, 0x58E7, 0xF7D4, 0x5972, 0xF7D5, 0x5B4D,\t0xF7D6, 0x5DD8, 0xF7D7, 0x882F, 0xF7D8, 0x5F4F, 0xF7D9, 0x6201,\r\n\t0xF7DA, 0x6203, 0xF7DB, 0x6204, 0xF7DC, 0x6529, 0xF7DD, 0x6525,\t0xF7DE, 0x6596, 0xF7DF, 0x66EB, 0xF7E0, 0x6B11, 0xF7E1, 0x6B12,\r\n\t0xF7E2, 0x6B0F, 0xF7E3, 0x6BCA, 0xF7E4, 0x705B, 0xF7E5, 0x705A,\t0xF7E6, 0x7222, 0xF7E7, 0x7382, 0xF7E8, 0x7381, 0xF7E9, 0x7383,\r\n\t0xF7EA, 0x7670, 0xF7EB, 0x77D4, 0xF7EC, 0x7C67, 0xF7ED, 0x7C66,\t0xF7EE, 0x7E95, 0xF7EF, 0x826C, 0xF7F0, 0x863A, 0xF7F1, 0x8640,\r\n\t0xF7F2, 0x8639, 0xF7F3, 0x863C, 0xF7F4, 0x8631, 0xF7F5, 0x863B,\t0xF7F6, 0x863E, 0xF7F7, 0x8830, 0xF7F8, 0x8832, 0xF7F9, 0x882E,\r\n\t0xF7FA, 0x8833, 0xF7FB, 0x8976, 0xF7FC, 0x8974, 0xF7FD, 0x8973,\t0xF7FE, 0x89FE, 0xF840, 0x8B8C, 0xF841, 0x8B8E, 0xF842, 0x8B8B,\r\n\t0xF843, 0x8B88, 0xF844, 0x8C45, 0xF845, 0x8D19, 0xF846, 0x8E98,\t0xF847, 0x8F64, 0xF848, 0x8F63, 0xF849, 0x91BC, 0xF84A, 0x9462,\r\n\t0xF84B, 0x9455, 0xF84C, 0x945D, 0xF84D, 0x9457, 0xF84E, 0x945E,\t0xF84F, 0x97C4, 0xF850, 0x97C5, 0xF851, 0x9800, 0xF852, 0x9A56,\r\n\t0xF853, 0x9A59, 0xF854, 0x9B1E, 0xF855, 0x9B1F, 0xF856, 0x9B20,\t0xF857, 0x9C52, 0xF858, 0x9C58, 0xF859, 0x9C50, 0xF85A, 0x9C4A,\r\n\t0xF85B, 0x9C4D, 0xF85C, 0x9C4B, 0xF85D, 0x9C55, 0xF85E, 0x9C59,\t0xF85F, 0x9C4C, 0xF860, 0x9C4E, 0xF861, 0x9DFB, 0xF862, 0x9DF7,\r\n\t0xF863, 0x9DEF, 0xF864, 0x9DE3, 0xF865, 0x9DEB, 0xF866, 0x9DF8,\t0xF867, 0x9DE4, 0xF868, 0x9DF6, 0xF869, 0x9DE1, 0xF86A, 0x9DEE,\r\n\t0xF86B, 0x9DE6, 0xF86C, 0x9DF2, 0xF86D, 0x9DF0, 0xF86E, 0x9DE2,\t0xF86F, 0x9DEC, 0xF870, 0x9DF4, 0xF871, 0x9DF3, 0xF872, 0x9DE8,\r\n\t0xF873, 0x9DED, 0xF874, 0x9EC2, 0xF875, 0x9ED0, 0xF876, 0x9EF2,\t0xF877, 0x9EF3, 0xF878, 0x9F06, 0xF879, 0x9F1C, 0xF87A, 0x9F38,\r\n\t0xF87B, 0x9F37, 0xF87C, 0x9F36, 0xF87D, 0x9F43, 0xF87E, 0x9F4F,\t0xF8A1, 0x9F71, 0xF8A2, 0x9F70, 0xF8A3, 0x9F6E, 0xF8A4, 0x9F6F,\r\n\t0xF8A5, 0x56D3, 0xF8A6, 0x56CD, 0xF8A7, 0x5B4E, 0xF8A8, 0x5C6D,\t0xF8A9, 0x652D, 0xF8AA, 0x66ED, 0xF8AB, 0x66EE, 0xF8AC, 0x6B13,\r\n\t0xF8AD, 0x705F, 0xF8AE, 0x7061, 0xF8AF, 0x705D, 0xF8B0, 0x7060,\t0xF8B1, 0x7223, 0xF8B2, 0x74DB, 0xF8B3, 0x74E5, 0xF8B4, 0x77D5,\r\n\t0xF8B5, 0x7938, 0xF8B6, 0x79B7, 0xF8B7, 0x79B6, 0xF8B8, 0x7C6A,\t0xF8B9, 0x7E97, 0xF8BA, 0x7F89, 0xF8BB, 0x826D, 0xF8BC, 0x8643,\r\n\t0xF8BD, 0x8838, 0xF8BE, 0x8837, 0xF8BF, 0x8835, 0xF8C0, 0x884B,\t0xF8C1, 0x8B94, 0xF8C2, 0x8B95, 0xF8C3, 0x8E9E, 0xF8C4, 0x8E9F,\r\n\t0xF8C5, 0x8EA0, 0xF8C6, 0x8E9D, 0xF8C7, 0x91BE, 0xF8C8, 0x91BD,\t0xF8C9, 0x91C2, 0xF8CA, 0x946B, 0xF8CB, 0x9468, 0xF8CC, 0x9469,\r\n\t0xF8CD, 0x96E5, 0xF8CE, 0x9746, 0xF8CF, 0x9743, 0xF8D0, 0x9747,\t0xF8D1, 0x97C7, 0xF8D2, 0x97E5, 0xF8D3, 0x9A5E, 0xF8D4, 0x9AD5,\r\n\t0xF8D5, 0x9B59, 0xF8D6, 0x9C63, 0xF8D7, 0x9C67, 0xF8D8, 0x9C66,\t0xF8D9, 0x9C62, 0xF8DA, 0x9C5E, 0xF8DB, 0x9C60, 0xF8DC, 0x9E02,\r\n\t0xF8DD, 0x9DFE, 0xF8DE, 0x9E07, 0xF8DF, 0x9E03, 0xF8E0, 0x9E06,\t0xF8E1, 0x9E05, 0xF8E2, 0x9E00, 0xF8E3, 0x9E01, 0xF8E4, 0x9E09,\r\n\t0xF8E5, 0x9DFF, 0xF8E6, 0x9DFD, 0xF8E7, 0x9E04, 0xF8E8, 0x9EA0,\t0xF8E9, 0x9F1E, 0xF8EA, 0x9F46, 0xF8EB, 0x9F74, 0xF8EC, 0x9F75,\r\n\t0xF8ED, 0x9F76, 0xF8EE, 0x56D4, 0xF8EF, 0x652E, 0xF8F0, 0x65B8,\t0xF8F1, 0x6B18, 0xF8F2, 0x6B19, 0xF8F3, 0x6B17, 0xF8F4, 0x6B1A,\r\n\t0xF8F5, 0x7062, 0xF8F6, 0x7226, 0xF8F7, 0x72AA, 0xF8F8, 0x77D8,\t0xF8F9, 0x77D9, 0xF8FA, 0x7939, 0xF8FB, 0x7C69, 0xF8FC, 0x7C6B,\r\n\t0xF8FD, 0x7CF6, 0xF8FE, 0x7E9A, 0xF940, 0x7E98, 0xF941, 0x7E9B,\t0xF942, 0x7E99, 0xF943, 0x81E0, 0xF944, 0x81E1, 0xF945, 0x8646,\r\n\t0xF946, 0x8647, 0xF947, 0x8648, 0xF948, 0x8979, 0xF949, 0x897A,\t0xF94A, 0x897C, 0xF94B, 0x897B, 0xF94C, 0x89FF, 0xF94D, 0x8B98,\r\n\t0xF94E, 0x8B99, 0xF94F, 0x8EA5, 0xF950, 0x8EA4, 0xF951, 0x8EA3,\t0xF952, 0x946E, 0xF953, 0x946D, 0xF954, 0x946F, 0xF955, 0x9471,\r\n\t0xF956, 0x9473, 0xF957, 0x9749, 0xF958, 0x9872, 0xF959, 0x995F,\t0xF95A, 0x9C68, 0xF95B, 0x9C6E, 0xF95C, 0x9C6D, 0xF95D, 0x9E0B,\r\n\t0xF95E, 0x9E0D, 0xF95F, 0x9E10, 0xF960, 0x9E0F, 0xF961, 0x9E12,\t0xF962, 0x9E11, 0xF963, 0x9EA1, 0xF964, 0x9EF5, 0xF965, 0x9F09,\r\n\t0xF966, 0x9F47, 0xF967, 0x9F78, 0xF968, 0x9F7B, 0xF969, 0x9F7A,\t0xF96A, 0x9F79, 0xF96B, 0x571E, 0xF96C, 0x7066, 0xF96D, 0x7C6F,\r\n\t0xF96E, 0x883C, 0xF96F, 0x8DB2, 0xF970, 0x8EA6, 0xF971, 0x91C3,\t0xF972, 0x9474, 0xF973, 0x9478, 0xF974, 0x9476, 0xF975, 0x9475,\r\n\t0xF976, 0x9A60, 0xF977, 0x9C74, 0xF978, 0x9C73, 0xF979, 0x9C71,\t0xF97A, 0x9C75, 0xF97B, 0x9E14, 0xF97C, 0x9E13, 0xF97D, 0x9EF6,\r\n\t0xF97E, 0x9F0A, 0xF9A1, 0x9FA4, 0xF9A2, 0x7068, 0xF9A3, 0x7065,\t0xF9A4, 0x7CF7, 0xF9A5, 0x866A, 0xF9A6, 0x883E, 0xF9A7, 0x883D,\r\n\t0xF9A8, 0x883F, 0xF9A9, 0x8B9E, 0xF9AA, 0x8C9C, 0xF9AB, 0x8EA9,\t0xF9AC, 0x8EC9, 0xF9AD, 0x974B, 0xF9AE, 0x9873, 0xF9AF, 0x9874,\r\n\t0xF9B0, 0x98CC, 0xF9B1, 0x9961, 0xF9B2, 0x99AB, 0xF9B3, 0x9A64,\t0xF9B4, 0x9A66, 0xF9B5, 0x9A67, 0xF9B6, 0x9B24, 0xF9B7, 0x9E15,\r\n\t0xF9B8, 0x9E17, 0xF9B9, 0x9F48, 0xF9BA, 0x6207, 0xF9BB, 0x6B1E,\t0xF9BC, 0x7227, 0xF9BD, 0x864C, 0xF9BE, 0x8EA8, 0xF9BF, 0x9482,\r\n\t0xF9C0, 0x9480, 0xF9C1, 0x9481, 0xF9C2, 0x9A69, 0xF9C3, 0x9A68,\t0xF9C4, 0x9B2E, 0xF9C5, 0x9E19, 0xF9C6, 0x7229, 0xF9C7, 0x864B,\r\n\t0xF9C8, 0x8B9F, 0xF9C9, 0x9483, 0xF9CA, 0x9C79, 0xF9CB, 0x9EB7,\t0xF9CC, 0x7675, 0xF9CD, 0x9A6B, 0xF9CE, 0x9C7A, 0xF9CF, 0x9E1D,\r\n\t0xF9D0, 0x7069, 0xF9D1, 0x706A, 0xF9D2, 0x9EA4, 0xF9D3, 0x9F7E,\t0xF9D4, 0x9F49, 0xF9D5, 0x9F98, 0xF9D6, 0x7881, 0xF9D7, 0x92B9,\r\n\t0xF9D8, 0x88CF, 0xF9D9, 0x58BB, 0xF9DA, 0x6052, 0xF9DB, 0x7CA7,\t0xF9DC, 0x5AFA, 0xF9DD, 0x2554, 0xF9DE, 0x2566, 0xF9DF, 0x2557,\r\n\t0xF9E0, 0x2560, 0xF9E1, 0x256C, 0xF9E2, 0x2563, 0xF9E3, 0x255A,\t0xF9E4, 0x2569, 0xF9E5, 0x255D, 0xF9E6, 0x2552, 0xF9E7, 0x2564,\r\n\t0xF9E8, 0x2555, 0xF9E9, 0x255E, 0xF9EA, 0x256A, 0xF9EB, 0x2561,\t0xF9EC, 0x2558, 0xF9ED, 0x2567, 0xF9EE, 0x255B, 0xF9EF, 0x2553,\r\n\t0xF9F0, 0x2565, 0xF9F1, 0x2556, 0xF9F2, 0x255F, 0xF9F3, 0x256B,\t0xF9F4, 0x2562, 0xF9F5, 0x2559, 0xF9F6, 0x2568, 0xF9F7, 0x255C,\r\n\t0xF9F8, 0x2551, 0xF9F9, 0x2550, 0xF9FA, 0x256D, 0xF9FB, 0x256E,\t0xF9FC, 0x2570, 0xF9FD, 0x256F, 0xF9FE, 0x2593, 0, 0\r\n};\r\n#endif\r\n\r\n#if FF_CODE_PAGE == 437 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc437[] = {\t/*  CP437(U.S.) to Unicode conversion table */\r\n\t0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,\r\n\t0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,\r\n\t0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,\r\n\t0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 720 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc720[] = {\t/*  CP720(Arabic) to Unicode conversion table */\r\n\t0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000,\r\n\t0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627,\r\n\t0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A,\r\n\t0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 737 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc737[] = {\t/*  CP737(Greek) to Unicode conversion table */\r\n\t0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,\r\n\t0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8,\r\n\t0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E,\r\n\t0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 771 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc771[] = {\t/*  CP771(KBL) to Unicode conversion table */\r\n\t0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,\r\n\t0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,\r\n\t0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D,\r\n\t0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,\r\n\t0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 775 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc775[] = {\t/*  CP775(Baltic) to Unicode conversion table */\r\n\t0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5,\r\n\t0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4,\r\n\t0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D,\r\n\t0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019,\r\n\t0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 850 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc850[] = {\t/*  CP850(Latin 1) to Unicode conversion table */\r\n\t0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,\r\n\t0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,\r\n\t0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,\r\n\t0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,\r\n\t0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,\r\n\t0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 852 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc852[] = {\t/*  CP852(Latin 2) to Unicode conversion table */\r\n\t0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106,\r\n\t0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D,\r\n\t0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,\r\n\t0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580,\r\n\t0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4,\r\n\t0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 855 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc855[] = {\t/*  CP855(Cyrillic) to Unicode conversion table */\r\n\t0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,\r\n\t0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A,\r\n\t0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,\r\n\t0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580,\r\n\t0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116,\r\n\t0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 857 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc857[] = {\t/*  CP857(Turkish) to Unicode conversion table */\r\n\t0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5,\r\n\t0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F,\r\n\t0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,\r\n\t0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,\r\n\t0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4,\r\n\t0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 860 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc860[] = {\t/*  CP860(Portuguese) to Unicode conversion table */\r\n\t0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2,\r\n\t0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3,\r\n\t0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,\r\n\t0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 861 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc861[] = {\t/*  CP861(Icelandic) to Unicode conversion table */\r\n\t0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5,\r\n\t0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192,\r\n\t0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,\r\n\t0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 862 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc862[] = {\t/*  CP862(Hebrew) to Unicode conversion table */\r\n\t0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,\r\n\t0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,\r\n\t0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,\r\n\t0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 863 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc863[] = {\t/*  CP863(Canadian French) to Unicode conversion table */\r\n\t0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0,\r\n\t0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192,\r\n\t0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219,\r\n\t0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 864 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc864[] = {\t/*  CP864(Arabic) to Unicode conversion table */\r\n\t0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518,\r\n\t0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000,\r\n\t0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5,\r\n\t0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F,\r\n\t0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9,\r\n\t0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9,\r\n\t0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1,\r\n\t0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 865 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc865[] = {\t/*  CP865(Nordic) to Unicode conversion table */\r\n\t0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,\r\n\t0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192,\r\n\t0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,\r\n\t0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 866 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc866[] = {\t/*  CP866(Russian) to Unicode conversion table */\r\n\t0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,\r\n\t0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,\r\n\t0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,\r\n\t0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,\r\n\t0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,\r\n\t0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n#if FF_CODE_PAGE == 869 || FF_CODE_PAGE == 0\r\nstatic const WCHAR uc869[] = {\t/*  CP869(Greek 2) to Unicode conversion table */\r\n\t0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389,\r\n\t0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF,\r\n\t0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB,\r\n\t0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510,\r\n\t0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3,\r\n\t0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580,\r\n\t0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384,\r\n\t0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0\r\n};\r\n#endif\r\n\r\n\r\n\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* OEM <==> Unicode Conversions for Static Code Page Configuration with   */\r\n/* SBCS Fixed Code Page                                                   */\r\n/*------------------------------------------------------------------------*/\r\n\r\n#if FF_CODE_PAGE != 0 && FF_CODE_PAGE < 900\r\nWCHAR ff_uni2oem (\t/* Returns OEM code character, zero on error */\r\n\tDWORD\tuni,\t/* UTF-16 encoded character to be converted */\r\n\tWORD\tcp\t\t/* Code page for the conversion */\r\n)\r\n{\r\n\tWCHAR c = 0;\r\n\tconst WCHAR* p = CVTBL(uc, FF_CODE_PAGE);\r\n\r\n\r\n\tif (uni < 0x80) {\t/* ASCII? */\r\n\t\tc = (WCHAR)uni;\r\n\r\n\t} else {\t\t\t/* Non-ASCII */\r\n\t\tif (uni < 0x10000 && cp == FF_CODE_PAGE) {\t/* Is it in BMP and valid code page? */\r\n\t\t\tfor (c = 0; c < 0x80 && uni != p[c]; c++) ;\r\n\t\t\tc = (c + 0x80) & 0xFF;\r\n\t\t}\r\n\t}\r\n\r\n\treturn c;\r\n}\r\n\r\nWCHAR ff_oem2uni (\t/* Returns Unicode character in UTF-16, zero on error */\r\n\tWCHAR\toem,\t/* OEM code to be converted */\r\n\tWORD\tcp\t\t/* Code page for the conversion */\r\n)\r\n{\r\n\tWCHAR c = 0;\r\n\tconst WCHAR* p = CVTBL(uc, FF_CODE_PAGE);\r\n\r\n\r\n\tif (oem < 0x80) {\t/* ASCII? */\r\n\t\tc = oem;\r\n\r\n\t} else {\t\t\t/* Extended char */\r\n\t\tif (cp == FF_CODE_PAGE) {\t/* Is it a valid code page? */\r\n\t\t\tif (oem < 0x100) c = p[oem - 0x80];\r\n\t\t}\r\n\t}\r\n\r\n\treturn c;\r\n}\r\n\r\n#endif\r\n\r\n\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* OEM <==> Unicode Conversions for Static Code Page Configuration with   */\r\n/* DBCS Fixed Code Page                                                   */\r\n/*------------------------------------------------------------------------*/\r\n\r\n#if FF_CODE_PAGE >= 900\r\nWCHAR ff_uni2oem (\t/* Returns OEM code character, zero on error */\r\n\tDWORD\tuni,\t/* UTF-16 encoded character to be converted */\r\n\tWORD\tcp\t\t/* Code page for the conversion */\r\n)\r\n{\r\n\tconst WCHAR* p;\r\n\tWCHAR c = 0, uc;\r\n\tUINT i = 0, n, li, hi;\r\n\r\n\r\n\tif (uni < 0x80) {\t/* ASCII? */\r\n\t\tc = (WCHAR)uni;\r\n\r\n\t} else {\t\t\t/* Non-ASCII */\r\n\t\tif (uni < 0x10000 && cp == FF_CODE_PAGE) {\t/* Is it in BMP and valid code page? */\r\n\t\t\tuc = (WCHAR)uni;\r\n\t\t\tp = CVTBL(uni2oem, FF_CODE_PAGE);\r\n\t\t\thi = sizeof CVTBL(uni2oem, FF_CODE_PAGE) / 4 - 1;\r\n\t\t\tli = 0;\r\n\t\t\tfor (n = 16; n; n--) {\r\n\t\t\t\ti = li + (hi - li) / 2;\r\n\t\t\t\tif (uc == p[i * 2]) break;\r\n\t\t\t\tif (uc > p[i * 2]) {\r\n\t\t\t\t\tli = i;\r\n\t\t\t\t} else {\r\n\t\t\t\t\thi = i;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (n != 0) c = p[i * 2 + 1];\r\n\t\t}\r\n\t}\r\n\r\n\treturn c;\r\n}\r\n\r\n\r\nWCHAR ff_oem2uni (\t/* Returns Unicode character in UTF-16, zero on error */\r\n\tWCHAR\toem,\t/* OEM code to be converted */\r\n\tWORD\tcp\t\t/* Code page for the conversion */\r\n)\r\n{\r\n\tconst WCHAR* p;\r\n\tWCHAR c = 0;\r\n\tUINT i = 0, n, li, hi;\r\n\r\n\r\n\tif (oem < 0x80) {\t/* ASCII? */\r\n\t\tc = oem;\r\n\r\n\t} else {\t\t\t/* Extended char */\r\n\t\tif (cp == FF_CODE_PAGE) {\t/* Is it valid code page? */\r\n\t\t\tp = CVTBL(oem2uni, FF_CODE_PAGE);\r\n\t\t\thi = sizeof CVTBL(oem2uni, FF_CODE_PAGE) / 4 - 1;\r\n\t\t\tli = 0;\r\n\t\t\tfor (n = 16; n; n--) {\r\n\t\t\t\ti = li + (hi - li) / 2;\r\n\t\t\t\tif (oem == p[i * 2]) break;\r\n\t\t\t\tif (oem > p[i * 2]) {\r\n\t\t\t\t\tli = i;\r\n\t\t\t\t} else {\r\n\t\t\t\t\thi = i;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (n != 0) c = p[i * 2 + 1];\r\n\t\t}\r\n\t}\r\n\r\n\treturn c;\r\n}\r\n#endif\r\n\r\n\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* OEM <==> Unicode Conversions for Dynamic Code Page Configuration       */\r\n/*------------------------------------------------------------------------*/\r\n\r\n#if FF_CODE_PAGE == 0\r\n\r\nstatic const WORD cp_code[]          = {  437,   720,   737,   771,   775,   850,   852,   855,   857,   860,   861,   862,   863,   864,   865,   866,   869, 0};\r\nstatic const WCHAR* const cp_table[] = {uc437, uc720, uc737, uc771, uc775, uc850, uc852, uc855, uc857, uc860, uc861, uc862, uc863, uc864, uc865, uc866, uc869, 0};\r\n\r\n\r\nWCHAR ff_uni2oem (\t/* Returns OEM code character, zero on error */\r\n\tDWORD\tuni,\t/* UTF-16 encoded character to be converted */\r\n\tWORD\tcp\t\t/* Code page for the conversion */\r\n)\r\n{\r\n\tconst WCHAR* p;\r\n\tWCHAR c = 0, uc;\r\n\tUINT i, n, li, hi;\r\n\r\n\r\n\tif (uni < 0x80) {\t/* ASCII? */\r\n\t\tc = (WCHAR)uni;\r\n\r\n\t} else {\t\t\t/* Non-ASCII */\r\n\t\tif (uni < 0x10000) { /* Is it in BMP? */\r\n\t\t\tuc = (WCHAR)uni;\r\n\t\t\tp = 0;\r\n\t\t\tif (cp < 900) {\t/* SBCS */\r\n\t\t\t\tfor (i = 0; cp_code[i] != 0 && cp_code[i] != cp; i++) ;\t\t/* Get conversion table */\r\n\t\t\t\tp = cp_table[i];\r\n\t\t\t\tif (p) {\t/* Is it valid code page ? */\r\n\t\t\t\t\tfor (c = 0; c < 0x80 && uc != p[c]; c++) ;\t/* Find OEM code in the table */\r\n\t\t\t\t\tc = (c + 0x80) & 0xFF;\r\n\t\t\t\t}\r\n\t\t\t} else {\t/* DBCS */\r\n\t\t\t\tswitch (cp) {\t/* Get conversion table */\r\n\t\t\t\tcase 932 : p = uni2oem932; hi = sizeof uni2oem932 / 4 - 1; break;\r\n\t\t\t\tcase 936 : p = uni2oem936; hi = sizeof uni2oem936 / 4 - 1; break;\r\n\t\t\t\tcase 949 : p = uni2oem949; hi = sizeof uni2oem949 / 4 - 1; break;\r\n\t\t\t\tcase 950 : p = uni2oem950; hi = sizeof uni2oem950 / 4 - 1; break;\r\n\t\t\t\t}\r\n\t\t\t\tif (p) {\t/* Is it valid code page? */\r\n\t\t\t\t\tli = 0;\r\n\t\t\t\t\tfor (n = 16; n; n--) {\t/* Find OEM code */\r\n\t\t\t\t\t\ti = li + (hi - li) / 2;\r\n\t\t\t\t\t\tif (uc == p[i * 2]) break;\r\n\t\t\t\t\t\tif (uc > p[i * 2]) {\r\n\t\t\t\t\t\t\tli = i;\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\thi = i;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (n != 0) c = p[i * 2 + 1];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn c;\r\n}\r\n\r\n\r\nWCHAR ff_oem2uni (\t/* Returns Unicode character in UTF-16, zero on error */\r\n\tWCHAR\toem,\t/* OEM code to be converted (DBC if >=0x100) */\r\n\tWORD\tcp\t\t/* Code page for the conversion */\r\n)\r\n{\r\n\tconst WCHAR* p;\r\n\tWCHAR c = 0;\r\n\tUINT i, n, li, hi;\r\n\r\n\r\n\tif (oem < 0x80) {\t/* ASCII? */\r\n\t\tc = oem;\r\n\r\n\t} else {\t\t\t/* Extended char */\r\n\t\tp = 0;\r\n\t\tif (cp < 900) {\t/* SBCS */\r\n\t\t\tfor (i = 0; cp_code[i] != 0 && cp_code[i] != cp; i++) ;\t\t/* Get table */\r\n\t\t\tp = cp_table[i];\r\n\t\t\tif (p) {\t/* Is it a valid CP ? */\r\n\t\t\t\tif (oem < 0x100) c = p[oem - 0x80];\r\n\t\t\t}\r\n\t\t} else {\t/* DBCS */\r\n\t\t\tswitch (cp) {\r\n\t\t\tcase 932 : p = oem2uni932; hi = sizeof oem2uni932 / 4 - 1; break;\r\n\t\t\tcase 936 : p = oem2uni936; hi = sizeof oem2uni936 / 4 - 1; break;\r\n\t\t\tcase 949 : p = oem2uni949; hi = sizeof oem2uni949 / 4 - 1; break;\r\n\t\t\tcase 950 : p = oem2uni950; hi = sizeof oem2uni950 / 4 - 1; break;\r\n\t\t\t}\r\n\t\t\tif (p) {\r\n\t\t\t\tli = 0;\r\n\t\t\t\tfor (n = 16; n; n--) {\r\n\t\t\t\t\ti = li + (hi - li) / 2;\r\n\t\t\t\t\tif (oem == p[i * 2]) break;\r\n\t\t\t\t\tif (oem > p[i * 2]) {\r\n\t\t\t\t\t\tli = i;\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\thi = i;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif (n != 0) c = p[i * 2 + 1];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn c;\r\n}\r\n#endif\r\n\r\n\r\n\r\n/*------------------------------------------------------------------------*/\r\n/* Unicode Up-case Conversion                                             */\r\n/*------------------------------------------------------------------------*/\r\n\r\nDWORD ff_wtoupper (\t/* Returns up-converted code point */\r\n\tDWORD uni\t\t/* Unicode code point to be up-converted */\r\n)\r\n{\r\n\tconst WORD* p;\r\n\tWORD uc, bc, nc, cmd;\r\n\tstatic const WORD cvt1[] = {\t/* Compressed up conversion table for U+0000 - U+0FFF */\r\n\t\t/* Basic Latin */\r\n\t\t0x0061,0x031A,\r\n\t\t/* Latin-1 Supplement */\r\n\t\t0x00E0,0x0317,\r\n\t\t0x00F8,0x0307,\r\n\t\t0x00FF,0x0001,0x0178,\r\n\t\t/* Latin Extended-A */\r\n\t\t0x0100,0x0130,\r\n\t\t0x0132,0x0106,\r\n\t\t0x0139,0x0110,\r\n\t\t0x014A,0x012E,\r\n\t\t0x0179,0x0106,\r\n\t\t/* Latin Extended-B */\r\n\t\t0x0180,0x004D,0x0243,0x0181,0x0182,0x0182,0x0184,0x0184,0x0186,0x0187,0x0187,0x0189,0x018A,0x018B,0x018B,0x018D,0x018E,0x018F,0x0190,0x0191,0x0191,0x0193,0x0194,0x01F6,0x0196,0x0197,0x0198,0x0198,0x023D,0x019B,0x019C,0x019D,0x0220,0x019F,0x01A0,0x01A0,0x01A2,0x01A2,0x01A4,0x01A4,0x01A6,0x01A7,0x01A7,0x01A9,0x01AA,0x01AB,0x01AC,0x01AC,0x01AE,0x01AF,0x01AF,0x01B1,0x01B2,0x01B3,0x01B3,0x01B5,0x01B5,0x01B7,0x01B8,0x01B8,0x01BA,0x01BB,0x01BC,0x01BC,0x01BE,0x01F7,0x01C0,0x01C1,0x01C2,0x01C3,0x01C4,0x01C5,0x01C4,0x01C7,0x01C8,0x01C7,0x01CA,0x01CB,0x01CA,\r\n\t\t0x01CD,0x0110,\r\n\t\t0x01DD,0x0001,0x018E,\r\n\t\t0x01DE,0x0112,\r\n\t\t0x01F3,0x0003,0x01F1,0x01F4,0x01F4,\r\n\t\t0x01F8,0x0128,\r\n\t\t0x0222,0x0112,\r\n\t\t0x023A,0x0009,0x2C65,0x023B,0x023B,0x023D,0x2C66,0x023F,0x0240,0x0241,0x0241,\r\n\t\t0x0246,0x010A,\r\n\t\t/* IPA Extensions */\r\n\t\t0x0253,0x0040,0x0181,0x0186,0x0255,0x0189,0x018A,0x0258,0x018F,0x025A,0x0190,0x025C,0x025D,0x025E,0x025F,0x0193,0x0261,0x0262,0x0194,0x0264,0x0265,0x0266,0x0267,0x0197,0x0196,0x026A,0x2C62,0x026C,0x026D,0x026E,0x019C,0x0270,0x0271,0x019D,0x0273,0x0274,0x019F,0x0276,0x0277,0x0278,0x0279,0x027A,0x027B,0x027C,0x2C64,0x027E,0x027F,0x01A6,0x0281,0x0282,0x01A9,0x0284,0x0285,0x0286,0x0287,0x01AE,0x0244,0x01B1,0x01B2,0x0245,0x028D,0x028E,0x028F,0x0290,0x0291,0x01B7,\r\n\t\t/* Greek, Coptic */\r\n\t\t0x037B,0x0003,0x03FD,0x03FE,0x03FF,\r\n\t\t0x03AC,0x0004,0x0386,0x0388,0x0389,0x038A,\r\n\t\t0x03B1,0x0311,\r\n\t\t0x03C2,0x0002,0x03A3,0x03A3,\r\n\t\t0x03C4,0x0308,\r\n\t\t0x03CC,0x0003,0x038C,0x038E,0x038F,\r\n\t\t0x03D8,0x0118,\r\n\t\t0x03F2,0x000A,0x03F9,0x03F3,0x03F4,0x03F5,0x03F6,0x03F7,0x03F7,0x03F9,0x03FA,0x03FA,\r\n\t\t/* Cyrillic */\r\n\t\t0x0430,0x0320,\r\n\t\t0x0450,0x0710,\r\n\t\t0x0460,0x0122,\r\n\t\t0x048A,0x0136,\r\n\t\t0x04C1,0x010E,\r\n\t\t0x04CF,0x0001,0x04C0,\r\n\t\t0x04D0,0x0144,\r\n\t\t/* Armenian */\r\n\t\t0x0561,0x0426,\r\n\r\n\t\t0x0000\t/* EOT */\r\n\t};\r\n\tstatic const WORD cvt2[] = {\t/* Compressed up conversion table for U+1000 - U+FFFF */\r\n\t\t/* Phonetic Extensions */\r\n\t\t0x1D7D,0x0001,0x2C63,\r\n\t\t/* Latin Extended Additional */\r\n\t\t0x1E00,0x0196,\r\n\t\t0x1EA0,0x015A,\r\n\t\t/* Greek Extended */\r\n\t\t0x1F00,0x0608,\r\n\t\t0x1F10,0x0606,\r\n\t\t0x1F20,0x0608,\r\n\t\t0x1F30,0x0608,\r\n\t\t0x1F40,0x0606,\r\n\t\t0x1F51,0x0007,0x1F59,0x1F52,0x1F5B,0x1F54,0x1F5D,0x1F56,0x1F5F,\r\n\t\t0x1F60,0x0608,\r\n\t\t0x1F70,0x000E,0x1FBA,0x1FBB,0x1FC8,0x1FC9,0x1FCA,0x1FCB,0x1FDA,0x1FDB,0x1FF8,0x1FF9,0x1FEA,0x1FEB,0x1FFA,0x1FFB,\r\n\t\t0x1F80,0x0608,\r\n\t\t0x1F90,0x0608,\r\n\t\t0x1FA0,0x0608,\r\n\t\t0x1FB0,0x0004,0x1FB8,0x1FB9,0x1FB2,0x1FBC,\r\n\t\t0x1FCC,0x0001,0x1FC3,\r\n\t\t0x1FD0,0x0602,\r\n\t\t0x1FE0,0x0602,\r\n\t\t0x1FE5,0x0001,0x1FEC,\r\n\t\t0x1FF3,0x0001,0x1FFC,\r\n\t\t/* Letterlike Symbols */\r\n\t\t0x214E,0x0001,0x2132,\r\n\t\t/* Number forms */\r\n\t\t0x2170,0x0210,\r\n\t\t0x2184,0x0001,0x2183,\r\n\t\t/* Enclosed Alphanumerics */\r\n\t\t0x24D0,0x051A,\r\n\t\t0x2C30,0x042F,\r\n\t\t/* Latin Extended-C */\r\n\t\t0x2C60,0x0102,\r\n\t\t0x2C67,0x0106, 0x2C75,0x0102,\r\n\t\t/* Coptic */\r\n\t\t0x2C80,0x0164,\r\n\t\t/* Georgian Supplement */\r\n\t\t0x2D00,0x0826,\r\n\t\t/* Full-width */\r\n\t\t0xFF41,0x031A,\r\n\r\n\t\t0x0000\t/* EOT */\r\n\t};\r\n\r\n\r\n\tif (uni < 0x10000) {\t/* Is it in BMP? */\r\n\t\tuc = (WORD)uni;\r\n\t\tp = uc < 0x1000 ? cvt1 : cvt2;\r\n\t\tfor (;;) {\r\n\t\t\tbc = *p++;\t\t\t\t\t\t\t\t/* Get the block base */\r\n\t\t\tif (bc == 0 || uc < bc) break;\t\t\t/* Not matched? */\r\n\t\t\tnc = *p++; cmd = nc >> 8; nc &= 0xFF;\t/* Get processing command and block size */\r\n\t\t\tif (uc < bc + nc) {\t/* In the block? */\r\n\t\t\t\tswitch (cmd) {\r\n\t\t\t\tcase 0:\tuc = p[uc - bc]; break;\t\t/* Table conversion */\r\n\t\t\t\tcase 1:\tuc -= (uc - bc) & 1; break;\t/* Case pairs */\r\n\t\t\t\tcase 2: uc -= 16; break;\t\t\t/* Shift -16 */\r\n\t\t\t\tcase 3:\tuc -= 32; break;\t\t\t/* Shift -32 */\r\n\t\t\t\tcase 4:\tuc -= 48; break;\t\t\t/* Shift -48 */\r\n\t\t\t\tcase 5:\tuc -= 26; break;\t\t\t/* Shift -26 */\r\n\t\t\t\tcase 6:\tuc += 8; break;\t\t\t\t/* Shift +8 */\r\n\t\t\t\tcase 7: uc -= 80; break;\t\t\t/* Shift -80 */\r\n\t\t\t\tcase 8:\tuc -= 0x1C60; break;\t\t/* Shift -0x1C60 */\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tif (cmd == 0) p += nc;\t/* Skip table if needed */\r\n\t\t}\r\n\t\tuni = uc;\r\n\t}\r\n\r\n\treturn uni;\r\n}\r\n\r\n\r\n#endif /* #if FF_USE_LFN != 0 */\r\n"
  },
  {
    "path": "ftpm-opensbi/platform/vivado-risc-v/objects.mk",
    "content": "#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n\nPLATFORM_RISCV_XLEN = 64\n\nFW_TEXT_START=0x80000000\nFW_DYNAMIC=n\nFW_JUMP=n\n\n# Firmware with payload configuration.\nFW_PAYLOAD=y\n\nifeq ($(PLATFORM_RISCV_XLEN), 32)\n  # This needs to be 4MB aligned for 32-bit support\n  FW_PAYLOAD_OFFSET=0x400000\nelse\n  # This needs to be 2MB aligned for 64-bit support\n  FW_PAYLOAD_OFFSET=0x200000\nendif\n#FW_PAYLOAD_FDT_ADDR=0x82200000\nFW_PAYLOAD_ALIGN=0x1000\n\nplatform-objs-y += platform.o\n\n\n##################################   FTPM   ###############################\n\nCRYPTO_MINI = /workspace/rfTPM/cryptomini\n\nFTPM_OBJS = \\\n\t../../src/ACT_spt.o\t\t\t\\\n\t../../src/ACTCommands.o\t\t\t\\\n\t../../src/AlgorithmCap.o\t\t\t\\\n\t../../src/AlgorithmTests.o\t\t\\\n\t../../src/AsymmetricCommands.o\t\t\\\n\t../../src/Attest_spt.o\t\t\t\\\n\t../../src/AttestationCommands.o\t\t\\\n\t../../src/AuditCommands.o\t\t\t\\\n\t../../src/Bits.o\t\t\t\t\\\n\t../../src/BnConvert.o\t\t\t\\\n    ../../src/BnEccConstants.o  \\\n\t../../src/BnMath.o\t\t\t\\\n    ../../src/BnMemory.o\t\t\t\\\n    ../../src/BnToOsslMath.o\t\t\t\\\n\t../../src/BnUtil.o\t\t\t\\\n\t../../src/Cancel.o\t\t\t\\\n\t../../src/CapabilityCommands.o\t\t\\\n\t../../src/Clock.o\t\t\t\t\\\n\t../../src/ClockCommands.o\t\t\t\\\n\t../../src/CommandAudit.o\t\t\t\\\n\t../../src/CommandCodeAttributes.o\t\t\\\n\t../../src/CommandDispatcher.o\t\t\\\n\t../../src/Context_spt.o\t\t\t\\\n\t../../src/ContextCommands.o\t\t\\\n\t../../src/CryptCmac.o\t\t\t\\\n\t../../src/CryptDes.o\t\t\t\\\n\t../../src/CryptEccCrypt.o\t\t\t\\\n\t../../src/CryptEccData.o\t\t\t\\\n\t../../src/CryptEccKeyExchange.o\t\t\\\n\t../../src/CryptEccMain.o\t\t\t\\\n\t../../src/CryptEccSignature.o\t\t\\\n\t../../src/CryptHash.o\t\t\t\\\n\t../../src/CryptPrime.o\t\t\t\\\n\t../../src/CryptPrimeSieve.o\t\t\\\n\t../../src/CryptRand.o\t\t\t\\\n\t../../src/CryptRsa.o\t\t\t\\\n\t../../src/CryptSelfTest.o\t\t\t\\\n\t../../src/CryptSmac.o\t\t\t\\\n\t../../src/CryptSym.o\t\t\t\\\n\t../../src/CryptUtil.o\t\t\t\\\n\t../../src/DA.o\t\t\t\t\\\n\t../../src/DebugHelpers.o\t\t\t\\\n\t../../src/DictionaryCommands.o\t\t\\\n\t../../src/DuplicationCommands.o\t\t\\\n\t../../src/EACommands.o\t\t\t\\\n\t../../src/EncryptDecrypt_spt.o\t\t\\\n\t../../src/Entity.o\t\t\t\\\n\t../../src/Entropy.o\t\t\t\\\n\t../../src/EphemeralCommands.o\t\t\\\n\t../../src/ExecCommand.o\t\t\t\\\n\t../../src/ExtraData.o\t\t\t\\\n\t../../src/Global.o\t\t\t\\\n\t../../src/Handle.o\t\t\t\\\n\t../../src/HashCommands.o\t\t\t\\\n\t../../src/Hierarchy.o\t\t\t\\\n\t../../src/HierarchyCommands.o\t\t\\\n\t../../src/IoBuffers.o\t\t\t\\\n\t../../src/IntegrityCommands.o\t\t\\\n\t../../src/Locality.o\t\t\t\\\n\t../../src/LocalityPlat.o\t\t\t\\\n\t../../src/ManagementCommands.o\t\t\\\n\t../../src/Manufacture.o\t\t\t\\\n\t../../src/Marshal.o\t\t\t\\\n\t../../src/MathOnByteBuffers.o\t\t\\\n\t../../src/Memory.o\t\t\t\\\n\t../../src/NV_spt.o\t\t\t\\\n\t../../src/NVCommands.o\t\t\t\\\n\t../../src/NVDynamic.o\t\t\t\\\n\t../../src/NVMem.o\t\t\t\t\\\n\t../../src/NVReserved.o\t\t\t\\\n\t../../src/Object_spt.o\t\t\t\\\n\t../../src/Object.o\t\t\t\\\n\t../../src/ObjectCommands.o\t\t\\\n\t../../src/PCR.o\t\t\t\t\\\n\t../../src/PP.o\t\t\t\t\\\n\t../../src/PPPlat.o\t\t\t\\\n\t../../src/PlatformACT.o\t\t\t\\\n\t../../src/PlatformData.o\t\t\t\\\n\t../../src/PlatformPCR.o\t\t\t\\\n\t../../src/Policy_spt.o\t\t\t\\\n\t../../src/Power.o\t\t\t\t\\\n\t../../src/PowerPlat.o\t\t\t\\\n\t../../src/PrimeData.o\t\t\t\\\n\t../../src/PropertyCap.o\t\t\t\\\n\t../../src/RandomCommands.o\t\t\\\n\t../../src/Response.o\t\t\t\\\n\t../../src/ResponseCodeProcessing.o\t\\\n\t../../src/RsaKeyCache.o\t\t\t\\\n\t../../src/RunCommand.o\t\t\t\\\n\t../../src/Session.o\t\t\t\\\n\t../../src/SessionCommands.o\t\t\\\n\t../../src/SessionProcess.o\t\t\\\n\t../../src/SigningCommands.o\t\t\\\n\t../../src/StartupCommands.o\t\t\\\n\t../../src/SymmetricCommands.o\t\t\\\n\t../../src/TestingCommands.o\t\t\\\n\t../../src/Ticket.o\t\t\t\\\n\t../../src/Time.o\t\t\t\t\\\n\t../../src/TpmAsn1.o\t\t\t\\\n\t../../src/TpmBigNumThunks.o\t\t\t\\\n\t../../src/TpmEcc_Signature_ECDAA.o\t\t\t\\\n\t../../src/TpmEcc_Signature_ECDSA.o\t\t\t\\\n    ../../src/TpmEcc_Signature_Schnorr.o\t\t\t\\\n    ../../src/TpmEcc_Signature_SM2.o\t\t\t\\\n    ../../src/TpmEcc_Signature_Util.o\t\t\t\\\n    ../../src/TpmEcc_Util.o\t\t\t\\\n\t../../src/TpmFail.o\t\t\t\\\n\t../../src/TpmMath_Debug.o\t\t\t\\\n    ../../src/TpmMath_Util.o\t\t\t\\\n\t../../src/TpmSizeChecks.o\t\t\t\\\n\t../../src/TpmToOsslSupport.o\t\t\\\n\t../../src/Unique.o\t\t\t\\\n\t../../src/Unmarshal.o\t\t\t\\\n\t../../src/Vendor_TCG_Test.o\t\t\\\n    ../../src/VendorInfo.o\t\t\\\n\t../../src/X509_ECC.o\t\t\t\\\n\t../../src/X509_RSA.o\t\t\t\\\n\t../../src/X509_spt.o\t\t\t\\\n\t../../src/ntc2lib.o\t\t\t\\\n\t../../src/ntc2.o\t\t\t\\\n\t../../src/TPMCmdp.o\t\t\t\\\n\t../../src/mprv.o\t\t\t\\\n\t../../src/intercept.o\t\t\\\n\t../../src/ftpm-sbi-opensbi.o   \t\\\n\t../../src/ftpm.o      \\\n\t./fatfs/diskio.o\t\\\n\t./fatfs/ff.o  \t\t\\\n\t./fatfs/ffsystem.o \t\\\n\t./fatfs/ffunicode.o\n\n\n#   ./ff/ff.o           \n#   ./ff/bootrom.o      \n#   ./ff/ffunicode.o\n\n#../../src/ftpm-sbi-opensbi.o\t\n\n\n\n#!!!v1.4 开gc-section无输出\n\n# 支持硬件双浮点数\nPLATFORM_RISCV_ABI = lp64d\n\n# FTPM_CFLAGS =  -ffunction-sections -fdata-sections\t\\\n#   \t-Wall  \t\t\t\\\n# \t-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \\\n# \t-Wno-deprecated-declarations\t\\\n# \t-Wno-unused-function\t-Wno-unused-variable\t\\\n# \t-Wno-error=missing-prototypes\t-Wno-error=maybe-uninitialized \\\n# \t-Wno-error=switch-unreachable\t-Wno-error=stringop-overflow= \\\n# \t-ggdb -O0 \t\t\t\\\n# \t-DTPM_POSIX\t\t\t\\\n# \t-D_POSIX_\t\t\t\\\n# \t-DTPM_NUVOTON\t\n\nFTPM_CFLAGS = \t\\\n  \t-Wall  \t\t\t\\\n\t-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \\\n\t-Wno-deprecated-declarations\t\\\n\t-Wno-unused-function\t-Wno-unused-variable\t\\\n\t-Wno-error=missing-prototypes\t-Wno-error=maybe-uninitialized \\\n\t-Wno-error=switch-unreachable\t-Wno-error=stringop-overflow= \\\n\t-Os -g0\t\t\t\\\n\t-DTPM_POSIX\t\t\t\\\n\t-D_POSIX_\t\t\t\\\n\t-DTPM_NUVOTON\t\t\\\n\t-DPLATFORM_TYPE=2\n\nFTPM_CFLAGS += -DUSE_BIT_FIELD_STRUCTURES=NO -DSYM_LIB=Ossl -DHASH_LIB=Ossl -DMATH_LIB=TpmBigNum -DBN_MATH_LIB=Ossl\n\n\nplatform-cflags-y += $(FTPM_CFLAGS) -I$(CURDIR)/include/ftpm/ -I$(CRYPTO_MINI)/include\n# platform-ldflags-y = -lcryptomini -L${CRYPTO_MINI} \n\n# -lc -lgcc需要重复，保证cryptomini中的memset等函数能链接到libc\n# platform-ldflags-y = -lcryptomini -lc -lgcc -Wl,--start-group -lc -lgcc -Wl,--end-group -L${CRYPTO_MINI}\n\n\n\n# platform-ldflags-y = -Wl,-Map=output.map -Wl,-gc-sections -lcryptomini -lc -lgloss -lgcc\t-Wl,--start-group -lc -lgloss -Wl,--end-group -lgcc -L${CRYPTO_MINI}\nplatform-ldflags-y =  -lcryptomini -lc -lgloss -lgcc\t-Wl,--start-group -lc -lgloss -Wl,--end-group -lgcc -L${CRYPTO_MINI}\n# platform-ldflags-y = -Wl,-gc-sections -lcryptomini\t-Wl,--start-group -lc -lgcc -Wl,--end-group -L${CRYPTO_MINI}\n\n# platform-ldflags-y = -Wl,-gc-sections\t-lcryptomini\t\t\t\n# \t-lc -lgcc -Wl,--start-group -lc -Wl,--end-group -lgcc\t\n# \t-L${CRYPTO_MINI}\t\n\nplatform-objs-y += $(FTPM_OBJS)\n"
  },
  {
    "path": "ftpm-opensbi/platform/vivado-risc-v/platform.c",
    "content": "/* SPDX-License-Identifier: BSD-2-Clause */\n/* Copyright (C) 2021 Eugene Tarassov */\n\n#include <libfdt.h>\n#include <sbi/riscv_asm.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/riscv_io.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_const.h>\n#include <sbi/sbi_hart.h>\n#include <sbi/sbi_platform.h>\n#include <sbi_utils/fdt/fdt_domain.h>\n#include <sbi_utils/fdt/fdt_fixup.h>\n#include <sbi_utils/fdt/fdt_helper.h>\n#include <sbi_utils/irqchip/fdt_irqchip.h>\n#include <sbi_utils/serial/fdt_serial.h>\n#include <sbi_utils/timer/fdt_timer.h>\n#include <sbi_utils/ipi/fdt_ipi.h>\n\n#include \"ftpm.h\"\n\n/* Linux kernel can support up to 32 HARTs */\n#define MAX_HART_CNT 32\n\n#define SR_RX_FIFO_VALID_DATA   (1 << 0) /* data in receive FIFO */\n#define SR_RX_FIFO_FULL         (1 << 1) /* receive FIFO full    */\n#define SR_TX_FIFO_EMPTY        (1 << 2) /* transmit FIFO empty  */\n#define SR_TX_FIFO_FULL         (1 << 3) /* transmit FIFO full   */\n\nstruct axi_uart_regs {\n    volatile uint32_t rx_fifo;\n    volatile uint32_t tx_fifo;\n    volatile uint32_t status;\n    volatile uint32_t control;\n};\n\nstatic struct axi_uart_regs * regs = NULL;\n\nvoid uart_putc(char ch) {\n    if (regs == NULL) return;\n    while (regs->status & SR_TX_FIFO_FULL) {}\n    regs->tx_fifo = ch & 0xff;\n}\n\nint uart_getc(void) {\n    if (regs == NULL) return -1;\n    if (regs->status & SR_RX_FIFO_VALID_DATA) return regs->rx_fifo;\n    return -1;\n}\n\n/* ---- Console ---- */\n\nstatic struct sbi_console_device console_ops = {\n    .name = \"axi-uart\",\n    .console_putc = uart_putc,\n    .console_getc = uart_getc\n};\n\nstatic const struct fdt_match console_match[] = {\n    { .compatible = \"xlnx,xps-uartlite-1.00.a\" },\n    { .compatible = \"xlnx,opb-uartlite-1.00.b\" },\n    { .compatible = \"riscv,axi-uart-1.0\" },\n    {},\n};\n\nstatic int console_init(void) {\n    void * fdt = sbi_scratch_thishart_arg1_ptr();\n    int coff = fdt_path_offset(fdt, \"/chosen\");\n    if (coff >= 0) {\n        int len = 0;\n        const void * prop = fdt_getprop(fdt, coff, \"stdout-path\", &len);\n        if (prop != NULL && len > 0) {\n            int noff = fdt_path_offset(fdt, prop);\n            if (noff >= 0 && fdt_match_node(fdt, noff, console_match) != NULL) {\n                unsigned long reg_addr = 0, reg_size = 0;\n                if (fdt_get_node_addr_size(fdt, noff, 0, &reg_addr, &reg_size) >= 0 && reg_addr != 0) {\n                    regs = (struct axi_uart_regs *)reg_addr;\n                    sbi_console_set_device(&console_ops);\n                    return 0;\n                }\n            }\n        }\n    }\n\n    return fdt_serial_init();\n}\n\nstatic int vivado_early_init(bool cold_boot)\n{\n\treturn 0;\n}\n\nstatic int vivado_final_init(bool cold_boot)\n{\n\n    ftpm_init();\n\n\treturn 0;\n}\n\n/* ---- Platform ---- */\n\nconst struct sbi_platform_operations platform_ops = {\n    .early_init = vivado_early_init,\n    .final_init = vivado_final_init,\n    .console_init = console_init,\n    .irqchip_init = fdt_irqchip_init,\n    .irqchip_exit = fdt_irqchip_exit,\n    .ipi_init = fdt_ipi_init,\n    .ipi_exit = fdt_ipi_exit,\n    .timer_init = fdt_timer_init,\n    .timer_exit = fdt_timer_exit,\n};\n\n// const struct sbi_platform platform = {\n//     .opensbi_version = OPENSBI_VERSION,\n//     .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),\n//     .name = \"Vivado RISC-V\",\n//     .features = SBI_PLATFORM_DEFAULT_FEATURES,\n//     .hart_count = MAX_HART_CNT,\n//     .hart_stack_size = SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,\n//     .platform_ops_addr = (unsigned long)&platform_ops\n// };\n\nconst struct sbi_platform platform = {\n    .opensbi_version = OPENSBI_VERSION,\n    .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),\n    .name = \"Vivado RISC-V\",\n    .features = SBI_PLATFORM_DEFAULT_FEATURES,\n    .hart_count = 1,\n    .hart_stack_size = 32768,\n    .platform_ops_addr = (unsigned long)&platform_ops\n};"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/LICENSE.txt",
    "content": "Copyright (c) 2011-2019, Ulf Magnusson <ulfalizer@gmail.com>\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/allnoconfig.py",
    "content": "#!/usr/bin/env python3\n\n# Copyright (c) 2018-2019, Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nWrites a configuration file where as many symbols as possible are set to 'n'.\n\nThe default output filename is '.config'. A different filename can be passed\nin the KCONFIG_CONFIG environment variable.\n\nUsage for the Linux kernel:\n\n  $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/allnoconfig.py\n\"\"\"\n\n# See examples/allnoconfig_walk.py for another way to implement this script\n\nimport kconfiglib\n\n\ndef main():\n    kconf = kconfiglib.standard_kconfig(__doc__)\n\n    # Avoid warnings that would otherwise get printed by Kconfiglib for the\n    # following:\n    #\n    # 1. Assigning a value to a symbol without a prompt, which never has any\n    #    effect\n    #\n    # 2. Assigning values invalid for the type (only bool/tristate symbols\n    #    accept 0/1/2, for n/m/y). The assignments will be ignored for other\n    #    symbol types, which is what we want.\n    kconf.warn = False\n    for sym in kconf.unique_defined_syms:\n        sym.set_value(2 if sym.is_allnoconfig_y else 0)\n    kconf.warn = True\n\n    kconf.load_allconfig(\"allno.config\")\n\n    print(kconf.write_config())\n\n\nif __name__ == \"__main__\":\n    main()\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/allyesconfig.py",
    "content": "#!/usr/bin/env python3\n\n# Copyright (c) 2018-2019, Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nWrites a configuration file where as many symbols as possible are set to 'y'.\n\nThe default output filename is '.config'. A different filename can be passed\nin the KCONFIG_CONFIG environment variable.\n\nUsage for the Linux kernel:\n\n  $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/allyesconfig.py\n\"\"\"\nimport kconfiglib\n\n\ndef main():\n    kconf = kconfiglib.standard_kconfig(__doc__)\n\n    # See allnoconfig.py\n    kconf.warn = False\n\n    # Try to set all symbols to 'y'. Dependencies might truncate the value down\n    # later, but this will at least give the highest possible value.\n    #\n    # Assigning 0/1/2 to non-bool/tristate symbols has no effect (int/hex\n    # symbols still take a string, because they preserve formatting).\n    for sym in kconf.unique_defined_syms:\n        # Set choice symbols to 'm'. This value will be ignored for choices in\n        # 'y' mode (the \"normal\" mode), which will instead just get their\n        # default selection, but will set all symbols in m-mode choices to 'm',\n        # which is as high as they can go.\n        #\n        # Here's a convoluted example of how you might get an m-mode choice\n        # even during allyesconfig:\n        #\n        #   choice\n        #           tristate \"weird choice\"\n        #           depends on m\n        sym.set_value(1 if sym.choice else 2)\n\n    # Set all choices to the highest possible mode\n    for choice in kconf.unique_choices:\n        choice.set_value(2)\n\n    kconf.warn = True\n\n    kconf.load_allconfig(\"allyes.config\")\n\n    print(kconf.write_config())\n\n\nif __name__ == \"__main__\":\n    main()\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/defconfig.py",
    "content": "#!/usr/bin/env python3\n\n# Copyright (c) 2019, Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nReads a specified configuration file, then writes a new configuration file.\nThis can be used to initialize the configuration from e.g. an arch-specific\nconfiguration file. This input configuration file would usually be a minimal\nconfiguration file, as generated by e.g. savedefconfig.\n\nThe default output filename is '.config'. A different filename can be passed in\nthe KCONFIG_CONFIG environment variable.\n\"\"\"\nimport argparse\n\nimport kconfiglib\n\n\ndef main():\n    parser = argparse.ArgumentParser(\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n        description=__doc__)\n\n    parser.add_argument(\n        \"--kconfig\",\n        default=\"Kconfig\",\n        help=\"Top-level Kconfig file (default: Kconfig)\")\n\n    parser.add_argument(\n        \"config\",\n        metavar=\"CONFIGURATION\",\n        help=\"Input configuration file\")\n\n    args = parser.parse_args()\n\n    kconf = kconfiglib.Kconfig(args.kconfig, suppress_traceback=True)\n    print(kconf.load_config(args.config))\n    print(kconf.write_config())\n\n\nif __name__ == \"__main__\":\n    main()\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/genconfig.py",
    "content": "#!/usr/bin/env python3\n\n# Copyright (c) 2018-2019, Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nGenerates a header file with #defines from the configuration, matching the\nformat of include/generated/autoconf.h in the Linux kernel.\n\nOptionally, also writes the configuration output as a .config file. See\n--config-out.\n\nThe --sync-deps, --file-list, and --env-list options generate information that\ncan be used to avoid needless rebuilds/reconfigurations.\n\nBefore writing a header or configuration file, Kconfiglib compares the old\ncontents of the file against the new contents. If there's no change, the write\nis skipped. This avoids updating file metadata like the modification time, and\nmight save work depending on your build setup.\n\nBy default, the configuration is generated from '.config'. A different\nconfiguration file can be passed in the KCONFIG_CONFIG environment variable.\n\nA custom header string can be inserted at the beginning of generated\nconfiguration and header files by setting the KCONFIG_CONFIG_HEADER and\nKCONFIG_AUTOHEADER_HEADER environment variables, respectively (this also works\nfor other scripts). The string is not automatically made a comment (this is by\ndesign, to allow anything to be added), and no trailing newline is added, so\nadd '/* */', '#', and newlines as appropriate.\n\nSee https://www.gnu.org/software/make/manual/make.html#Multi_002dLine for a\nhandy way to define multi-line variables in makefiles, for use with custom\nheaders. Remember to export the variable to the environment.\n\"\"\"\nimport argparse\nimport os\nimport sys\n\nimport kconfiglib\n\n\nDEFAULT_SYNC_DEPS_PATH = \"deps/\"\n\n\ndef main():\n    parser = argparse.ArgumentParser(\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n        description=__doc__)\n\n    parser.add_argument(\n        \"--header-path\",\n        metavar=\"HEADER_FILE\",\n        help=\"\"\"\nPath to write the generated header file to. If not specified, the path in the\nenvironment variable KCONFIG_AUTOHEADER is used if it is set, and 'config.h'\notherwise.\n\"\"\")\n\n    parser.add_argument(\n        \"--config-out\",\n        metavar=\"CONFIG_FILE\",\n        help=\"\"\"\nWrite the configuration to CONFIG_FILE. This is useful if you include .config\nfiles in Makefiles, as the generated configuration file will be a full .config\nfile even if .config is outdated. The generated configuration matches what\nolddefconfig would produce. If you use sync-deps, you can include\ndeps/auto.conf instead. --config-out is meant for cases where incremental build\ninformation isn't needed.\n\"\"\")\n\n    parser.add_argument(\n        \"--sync-deps\",\n        metavar=\"OUTPUT_DIR\",\n        nargs=\"?\",\n        const=DEFAULT_SYNC_DEPS_PATH,\n        help=\"\"\"\nEnable generation of symbol dependency information for incremental builds,\noptionally specifying the output directory (default: {}). See the docstring of\nKconfig.sync_deps() in Kconfiglib for more information.\n\"\"\".format(DEFAULT_SYNC_DEPS_PATH))\n\n    parser.add_argument(\n        \"--file-list\",\n        metavar=\"OUTPUT_FILE\",\n        help=\"\"\"\nWrite a list of all Kconfig files to OUTPUT_FILE, with one file per line. The\npaths are relative to $srctree (or to the current directory if $srctree is\nunset). Files appear in the order they're 'source'd.\n\"\"\")\n\n    parser.add_argument(\n        \"--env-list\",\n        metavar=\"OUTPUT_FILE\",\n        help=\"\"\"\nWrite a list of all environment variables referenced in Kconfig files to\nOUTPUT_FILE, with one variable per line. Each line has the format NAME=VALUE.\nOnly environment variables referenced with the preprocessor $(VAR) syntax are\nincluded, and not variables referenced with the older $VAR syntax (which is\nonly supported for backwards compatibility).\n\"\"\")\n\n    parser.add_argument(\n        \"kconfig\",\n        metavar=\"KCONFIG\",\n        nargs=\"?\",\n        default=\"Kconfig\",\n        help=\"Top-level Kconfig file (default: Kconfig)\")\n\n    args = parser.parse_args()\n\n\n    kconf = kconfiglib.Kconfig(args.kconfig, suppress_traceback=True)\n    kconf.load_config()\n\n    if args.header_path is None:\n        if \"KCONFIG_AUTOHEADER\" in os.environ:\n            kconf.write_autoconf()\n        else:\n            # Kconfiglib defaults to include/generated/autoconf.h to be\n            # compatible with the C tools. 'config.h' is used here instead for\n            # backwards compatibility. It's probably a saner default for tools\n            # as well.\n            kconf.write_autoconf(\"config.h\")\n    else:\n        kconf.write_autoconf(args.header_path)\n\n    if args.config_out is not None:\n        kconf.write_config(args.config_out, save_old=False)\n\n    if args.sync_deps is not None:\n        kconf.sync_deps(args.sync_deps)\n\n    if args.file_list is not None:\n        with _open_write(args.file_list) as f:\n            for path in kconf.kconfig_filenames:\n                f.write(path + \"\\n\")\n\n    if args.env_list is not None:\n        with _open_write(args.env_list) as f:\n            for env_var in kconf.env_vars:\n                f.write(\"{}={}\\n\".format(env_var, os.environ[env_var]))\n\n\ndef _open_write(path):\n    # Python 2/3 compatibility. io.open() is available on both, but makes\n    # write() expect 'unicode' strings on Python 2.\n\n    if sys.version_info[0] < 3:\n        return open(path, \"w\")\n    return open(path, \"w\", encoding=\"utf-8\")\n\n\nif __name__ == \"__main__\":\n    main()\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/kconfiglib.py",
    "content": "# Copyright (c) 2011-2019, Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nOverview\n========\n\nKconfiglib is a Python 2/3 library for scripting and extracting information\nfrom Kconfig (https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt)\nconfiguration systems.\n\nSee the homepage at https://github.com/ulfalizer/Kconfiglib for a longer\noverview.\n\nSince Kconfiglib 12.0.0, the library version is available in\nkconfiglib.VERSION, which is a (<major>, <minor>, <patch>) tuple, e.g.\n(12, 0, 0).\n\n\nUsing Kconfiglib on the Linux kernel with the Makefile targets\n==============================================================\n\nFor the Linux kernel, a handy interface is provided by the\nscripts/kconfig/Makefile patch, which can be applied with either 'git am' or\nthe 'patch' utility:\n\n  $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | git am\n  $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | patch -p1\n\nWarning: Not passing -p1 to patch will cause the wrong file to be patched.\n\nPlease tell me if the patch does not apply. It should be trivial to apply\nmanually, as it's just a block of text that needs to be inserted near the other\n*conf: targets in scripts/kconfig/Makefile.\n\nLook further down for a motivation for the Makefile patch and for instructions\non how you can use Kconfiglib without it.\n\nIf you do not wish to install Kconfiglib via pip, the Makefile patch is set up\nso that you can also just clone Kconfiglib into the kernel root:\n\n  $ git clone git://github.com/ulfalizer/Kconfiglib.git\n  $ git am Kconfiglib/makefile.patch  (or 'patch -p1 < Kconfiglib/makefile.patch')\n\nWarning: The directory name Kconfiglib/ is significant in this case, because\nit's added to PYTHONPATH by the new targets in makefile.patch.\n\nThe targets added by the Makefile patch are described in the following\nsections.\n\n\nmake kmenuconfig\n----------------\n\nThis target runs the curses menuconfig interface with Python 3. As of\nKconfiglib 12.2.0, both Python 2 and Python 3 are supported (previously, only\nPython 3 was supported, so this was a backport).\n\n\nmake guiconfig\n--------------\n\nThis target runs the Tkinter menuconfig interface. Both Python 2 and Python 3\nare supported. To change the Python interpreter used, pass\nPYTHONCMD=<executable> to 'make'. The default is 'python'.\n\n\nmake [ARCH=<arch>] iscriptconfig\n--------------------------------\n\nThis target gives an interactive Python prompt where a Kconfig instance has\nbeen preloaded and is available in 'kconf'. To change the Python interpreter\nused, pass PYTHONCMD=<executable> to 'make'. The default is 'python'.\n\nTo get a feel for the API, try evaluating and printing the symbols in\nkconf.defined_syms, and explore the MenuNode menu tree starting at\nkconf.top_node by following 'next' and 'list' pointers.\n\nThe item contained in a menu node is found in MenuNode.item (note that this can\nbe one of the constants kconfiglib.MENU and kconfiglib.COMMENT), and all\nsymbols and choices have a 'nodes' attribute containing their menu nodes\n(usually only one). Printing a menu node will print its item, in Kconfig\nformat.\n\nIf you want to look up a symbol by name, use the kconf.syms dictionary.\n\n\nmake scriptconfig SCRIPT=<script> [SCRIPT_ARG=<arg>]\n----------------------------------------------------\n\nThis target runs the Python script given by the SCRIPT parameter on the\nconfiguration. sys.argv[1] holds the name of the top-level Kconfig file\n(currently always \"Kconfig\" in practice), and sys.argv[2] holds the SCRIPT_ARG\nargument, if given.\n\nSee the examples/ subdirectory for example scripts.\n\n\nmake dumpvarsconfig\n-------------------\n\nThis target prints a list of all environment variables referenced from the\nKconfig files, together with their values. See the\nKconfiglib/examples/dumpvars.py script.\n\nOnly environment variables that are referenced via the Kconfig preprocessor\n$(FOO) syntax are included. The preprocessor was added in Linux 4.18.\n\n\nUsing Kconfiglib without the Makefile targets\n=============================================\n\nThe make targets are only needed to pick up environment variables exported from\nthe Kbuild makefiles and referenced inside Kconfig files, via e.g.\n'source \"arch/$(SRCARCH)/Kconfig\" and commands run via '$(shell,...)'.\n\nThese variables are referenced as of writing (Linux 4.18), together with sample\nvalues:\n\n  srctree          (.)\n  ARCH             (x86)\n  SRCARCH          (x86)\n  KERNELVERSION    (4.18.0)\n  CC               (gcc)\n  HOSTCC           (gcc)\n  HOSTCXX          (g++)\n  CC_VERSION_TEXT  (gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0)\n\nOlder kernels only reference ARCH, SRCARCH, and KERNELVERSION.\n\nIf your kernel is recent enough (4.18+), you can get a list of referenced\nenvironment variables via 'make dumpvarsconfig' (see above). Note that this\ncommand is added by the Makefile patch.\n\nTo run Kconfiglib without the Makefile patch, set the environment variables\nmanually:\n\n  $ srctree=. ARCH=x86 SRCARCH=x86 KERNELVERSION=`make kernelversion` ... python(3)\n  >>> import kconfiglib\n  >>> kconf = kconfiglib.Kconfig()  # filename defaults to \"Kconfig\"\n\nSearch the top-level Makefile for \"Additional ARCH settings\" to see other\npossibilities for ARCH and SRCARCH.\n\n\nIntro to symbol values\n======================\n\nKconfiglib has the same assignment semantics as the C implementation.\n\nAny symbol can be assigned a value by the user (via Kconfig.load_config() or\nSymbol.set_value()), but this user value is only respected if the symbol is\nvisible, which corresponds to it (currently) being visible in the menuconfig\ninterface.\n\nFor symbols with prompts, the visibility of the symbol is determined by the\ncondition on the prompt. Symbols without prompts are never visible, so setting\na user value on them is pointless. A warning will be printed by default if\nSymbol.set_value() is called on a promptless symbol. Assignments to promptless\nsymbols are normal within a .config file, so no similar warning will be printed\nby load_config().\n\nDependencies from parents and 'if'/'depends on' are propagated to properties,\nincluding prompts, so these two configurations are logically equivalent:\n\n(1)\n\n  menu \"menu\"\n      depends on A\n\n  if B\n\n  config FOO\n      tristate \"foo\" if D\n      default y\n      depends on C\n\n  endif\n\n  endmenu\n\n(2)\n\n  menu \"menu\"\n      depends on A\n\n  config FOO\n      tristate \"foo\" if A && B && C && D\n      default y if A && B && C\n\n  endmenu\n\nIn this example, A && B && C && D (the prompt condition) needs to be non-n for\nFOO to be visible (assignable). If its value is m, the symbol can only be\nassigned the value m: The visibility sets an upper bound on the value that can\nbe assigned by the user, and any higher user value will be truncated down.\n\n'default' properties are independent of the visibility, though a 'default' will\noften get the same condition as the prompt due to dependency propagation.\n'default' properties are used if the symbol is not visible or has no user\nvalue.\n\nSymbols with no user value (or that have a user value but are not visible) and\nno (active) 'default' default to n for bool/tristate symbols, and to the empty\nstring for other symbol types.\n\n'select' works similarly to symbol visibility, but sets a lower bound on the\nvalue of the symbol. The lower bound is determined by the value of the\nselect*ing* symbol. 'select' does not respect visibility, so non-visible\nsymbols can be forced to a particular (minimum) value by a select as well.\n\nFor non-bool/tristate symbols, it only matters whether the visibility is n or\nnon-n: m visibility acts the same as y visibility.\n\nConditions on 'default' and 'select' work in mostly intuitive ways. If the\ncondition is n, the 'default' or 'select' is disabled. If it is m, the\n'default' or 'select' value (the value of the selecting symbol) is truncated\ndown to m.\n\nWhen writing a configuration with Kconfig.write_config(), only symbols that are\nvisible, have an (active) default, or are selected will get written out (note\nthat this includes all symbols that would accept user values). Kconfiglib\nmatches the .config format produced by the C implementations down to the\ncharacter. This eases testing.\n\nFor a visible bool/tristate symbol FOO with value n, this line is written to\n.config:\n\n    # CONFIG_FOO is not set\n\nThe point is to remember the user n selection (which might differ from the\ndefault value the symbol would get), while at the same sticking to the rule\nthat undefined corresponds to n (.config uses Makefile format, making the line\nabove a comment). When the .config file is read back in, this line will be\ntreated the same as the following assignment:\n\n    CONFIG_FOO=n\n\nIn Kconfiglib, the set of (currently) assignable values for a bool/tristate\nsymbol appear in Symbol.assignable. For other symbol types, just check if\nsym.visibility is non-0 (non-n) to see whether the user value will have an\neffect.\n\n\nIntro to the menu tree\n======================\n\nThe menu structure, as seen in e.g. menuconfig, is represented by a tree of\nMenuNode objects. The top node of the configuration corresponds to an implicit\ntop-level menu, the title of which is shown at the top in the standard\nmenuconfig interface. (The title is also available in Kconfig.mainmenu_text in\nKconfiglib.)\n\nThe top node is found in Kconfig.top_node. From there, you can visit child menu\nnodes by following the 'list' pointer, and any following menu nodes by\nfollowing the 'next' pointer. Usually, a non-None 'list' pointer indicates a\nmenu or Choice, but menu nodes for symbols can sometimes have a non-None 'list'\npointer too due to submenus created implicitly from dependencies.\n\nMenuNode.item is either a Symbol or a Choice object, or one of the constants\nMENU and COMMENT. The prompt of the menu node can be found in MenuNode.prompt,\nwhich also holds the title for menus and comments. For Symbol and Choice,\nMenuNode.help holds the help text (if any, otherwise None).\n\nMost symbols will only have a single menu node. A symbol defined in multiple\nlocations will have one menu node for each location. The list of menu nodes for\na Symbol or Choice can be found in the Symbol/Choice.nodes attribute.\n\nNote that prompts and help texts for symbols and choices are stored in their\nmenu node(s) rather than in the Symbol or Choice objects themselves. This makes\nit possible to define a symbol in multiple locations with a different prompt or\nhelp text in each location. To get the help text or prompt for a symbol with a\nsingle menu node, do sym.nodes[0].help and sym.nodes[0].prompt, respectively.\nThe prompt is a (text, condition) tuple, where condition determines the\nvisibility (see 'Intro to expressions' below).\n\nThis organization mirrors the C implementation. MenuNode is called\n'struct menu' there, but I thought \"menu\" was a confusing name.\n\nIt is possible to give a Choice a name and define it in multiple locations,\nhence why Choice.nodes is also a list.\n\nAs a convenience, the properties added at a particular definition location are\navailable on the MenuNode itself, in e.g. MenuNode.defaults. This is helpful\nwhen generating documentation, so that symbols/choices defined in multiple\nlocations can be shown with the correct properties at each location.\n\n\nIntro to expressions\n====================\n\nExpressions can be evaluated with the expr_value() function and printed with\nthe expr_str() function (these are used internally as well). Evaluating an\nexpression always yields a tristate value, where n, m, and y are represented as\n0, 1, and 2, respectively.\n\nThe following table should help you figure out how expressions are represented.\nA, B, C, ... are symbols (Symbol instances), NOT is the kconfiglib.NOT\nconstant, etc.\n\nExpression            Representation\n----------            --------------\nA                     A\n\"A\"                   A (constant symbol)\n!A                    (NOT, A)\nA && B                (AND, A, B)\nA && B && C           (AND, A, (AND, B, C))\nA || B                (OR, A, B)\nA || (B && C && D)    (OR, A, (AND, B, (AND, C, D)))\nA = B                 (EQUAL, A, B)\nA != \"foo\"            (UNEQUAL, A, foo (constant symbol))\nA && B = C && D       (AND, A, (AND, (EQUAL, B, C), D))\nn                     Kconfig.n (constant symbol)\nm                     Kconfig.m (constant symbol)\ny                     Kconfig.y (constant symbol)\n\"y\"                   Kconfig.y (constant symbol)\n\nStrings like \"foo\" in 'default \"foo\"' or 'depends on SYM = \"foo\"' are\nrepresented as constant symbols, so the only values that appear in expressions\nare symbols***. This mirrors the C implementation.\n\n***For choice symbols, the parent Choice will appear in expressions as well,\nbut it's usually invisible as the value interfaces of Symbol and Choice are\nidentical. This mirrors the C implementation and makes different choice modes\n\"just work\".\n\nManual evaluation examples:\n\n  - The value of A && B is min(A.tri_value, B.tri_value)\n\n  - The value of A || B is max(A.tri_value, B.tri_value)\n\n  - The value of !A is 2 - A.tri_value\n\n  - The value of A = B is 2 (y) if A.str_value == B.str_value, and 0 (n)\n    otherwise. Note that str_value is used here instead of tri_value.\n\n    For constant (as well as undefined) symbols, str_value matches the name of\n    the symbol. This mirrors the C implementation and explains why\n    'depends on SYM = \"foo\"' above works as expected.\n\nn/m/y are automatically converted to the corresponding constant symbols\n\"n\"/\"m\"/\"y\" (Kconfig.n/m/y) during parsing.\n\nKconfig.const_syms is a dictionary like Kconfig.syms but for constant symbols.\n\nIf a condition is missing (e.g., <cond> when the 'if <cond>' is removed from\n'default A if <cond>'), it is actually Kconfig.y. The standard __str__()\nfunctions just avoid printing 'if y' conditions to give cleaner output.\n\n\nKconfig extensions\n==================\n\nKconfiglib includes a couple of Kconfig extensions:\n\n'source' with relative path\n---------------------------\n\nThe 'rsource' statement sources Kconfig files with a path relative to directory\nof the Kconfig file containing the 'rsource' statement, instead of relative to\nthe project root.\n\nConsider following directory tree:\n\n  Project\n  +--Kconfig\n  |\n  +--src\n     +--Kconfig\n     |\n     +--SubSystem1\n        +--Kconfig\n        |\n        +--ModuleA\n           +--Kconfig\n\nIn this example, assume that src/SubSystem1/Kconfig wants to source\nsrc/SubSystem1/ModuleA/Kconfig.\n\nWith 'source', this statement would be used:\n\n  source \"src/SubSystem1/ModuleA/Kconfig\"\n\nWith 'rsource', this turns into\n\n  rsource \"ModuleA/Kconfig\"\n\nIf an absolute path is given to 'rsource', it acts the same as 'source'.\n\n'rsource' can be used to create \"position-independent\" Kconfig trees that can\nbe moved around freely.\n\n\nGlobbing 'source'\n-----------------\n\n'source' and 'rsource' accept glob patterns, sourcing all matching Kconfig\nfiles. They require at least one matching file, raising a KconfigError\notherwise.\n\nFor example, the following statement might source sub1/foofoofoo and\nsub2/foobarfoo:\n\n  source \"sub[12]/foo*foo\"\n\nThe glob patterns accepted are the same as for the standard glob.glob()\nfunction.\n\nTwo additional statements are provided for cases where it's acceptable for a\npattern to match no files: 'osource' and 'orsource' (the o is for \"optional\").\n\nFor example, the following statements will be no-ops if neither \"foo\" nor any\nfiles matching \"bar*\" exist:\n\n  osource \"foo\"\n  osource \"bar*\"\n\n'orsource' does a relative optional source.\n\n'source' and 'osource' are analogous to 'include' and '-include' in Make.\n\n\nGeneralized def_* keywords\n--------------------------\n\ndef_int, def_hex, and def_string are available in addition to def_bool and\ndef_tristate, allowing int, hex, and string symbols to be given a type and a\ndefault at the same time.\n\n\nExtra optional warnings\n-----------------------\n\nSome optional warnings can be controlled via environment variables:\n\n  - KCONFIG_WARN_UNDEF: If set to 'y', warnings will be generated for all\n    references to undefined symbols within Kconfig files. The only gotcha is\n    that all hex literals must be prefixed with \"0x\" or \"0X\", to make it\n    possible to distinguish them from symbol references.\n\n    Some projects (e.g. the Linux kernel) use multiple Kconfig trees with many\n    shared Kconfig files, leading to some safe undefined symbol references.\n    KCONFIG_WARN_UNDEF is useful in projects that only have a single Kconfig\n    tree though.\n\n    KCONFIG_STRICT is an older alias for this environment variable, supported\n    for backwards compatibility.\n\n  - KCONFIG_WARN_UNDEF_ASSIGN: If set to 'y', warnings will be generated for\n    all assignments to undefined symbols within .config files. By default, no\n    such warnings are generated.\n\n    This warning can also be enabled/disabled via the Kconfig.warn_assign_undef\n    variable.\n\n\nPreprocessor user functions defined in Python\n---------------------------------------------\n\nPreprocessor functions can be defined in Python, which makes it simple to\nintegrate information from existing Python tools into Kconfig (e.g. to have\nKconfig symbols depend on hardware information stored in some other format).\n\nPutting a Python module named kconfigfunctions(.py) anywhere in sys.path will\ncause it to be imported by Kconfiglib (in Kconfig.__init__()). Note that\nsys.path can be customized via PYTHONPATH, and includes the directory of the\nmodule being run by default, as well as installation directories.\n\nIf the KCONFIG_FUNCTIONS environment variable is set, it gives a different\nmodule name to use instead of 'kconfigfunctions'.\n\nThe imported module is expected to define a global dictionary named 'functions'\nthat maps function names to Python functions, as follows:\n\n  def my_fn(kconf, name, arg_1, arg_2, ...):\n      # kconf:\n      #   Kconfig instance\n      #\n      # name:\n      #   Name of the user-defined function (\"my-fn\"). Think argv[0].\n      #\n      # arg_1, arg_2, ...:\n      #   Arguments passed to the function from Kconfig (strings)\n      #\n      # Returns a string to be substituted as the result of calling the\n      # function\n      ...\n\n  def my_other_fn(kconf, name, arg_1, arg_2, ...):\n      ...\n\n  functions = {\n      \"my-fn\":       (my_fn,       <min.args>, <max.args>/None),\n      \"my-other-fn\": (my_other_fn, <min.args>, <max.args>/None),\n      ...\n  }\n\n  ...\n\n<min.args> and <max.args> are the minimum and maximum number of arguments\nexpected by the function (excluding the implicit 'name' argument). If\n<max.args> is None, there is no upper limit to the number of arguments. Passing\nan invalid number of arguments will generate a KconfigError exception.\n\nFunctions can access the current parsing location as kconf.filename/linenr.\nAccessing other fields of the Kconfig object is not safe. See the warning\nbelow.\n\nKeep in mind that for a variable defined like 'foo = $(fn)', 'fn' will be\ncalled only when 'foo' is expanded. If 'fn' uses the parsing location and the\nintent is to use the location of the assignment, you want 'foo := $(fn)'\ninstead, which calls the function immediately.\n\nOnce defined, user functions can be called from Kconfig in the same way as\nother preprocessor functions:\n\n    config FOO\n        ...\n        depends on $(my-fn,arg1,arg2)\n\nIf my_fn() returns \"n\", this will result in\n\n    config FOO\n        ...\n        depends on n\n\nWarning\n*******\n\nUser-defined preprocessor functions are called as they're encountered at parse\ntime, before all Kconfig files have been processed, and before the menu tree\nhas been finalized. There are no guarantees that accessing Kconfig symbols or\nthe menu tree via the 'kconf' parameter will work, and it could potentially\nlead to a crash.\n\nPreferably, user-defined functions should be stateless.\n\n\nFeedback\n========\n\nSend bug reports, suggestions, and questions to ulfalizer a.t Google's email\nservice, or open a ticket on the GitHub page.\n\"\"\"\nimport errno\nimport importlib\nimport os\nimport re\nimport sys\n\n# Get rid of some attribute lookups. These are obvious in context.\nfrom glob import iglob\nfrom os.path import dirname, exists, expandvars, islink, join, realpath\n\n\nVERSION = (14, 1, 0)\n\n\n# File layout:\n#\n# Public classes\n# Public functions\n# Internal functions\n# Global constants\n\n# Line length: 79 columns\n\n\n#\n# Public classes\n#\n\n\nclass Kconfig(object):\n    \"\"\"\n    Represents a Kconfig configuration, e.g. for x86 or ARM. This is the set of\n    symbols, choices, and menu nodes appearing in the configuration. Creating\n    any number of Kconfig objects (including for different architectures) is\n    safe. Kconfiglib doesn't keep any global state.\n\n    The following attributes are available. They should be treated as\n    read-only, and some are implemented through @property magic.\n\n    syms:\n      A dictionary with all symbols in the configuration, indexed by name. Also\n      includes all symbols that are referenced in expressions but never\n      defined, except for constant (quoted) symbols.\n\n      Undefined symbols can be recognized by Symbol.nodes being empty -- see\n      the 'Intro to the menu tree' section in the module docstring.\n\n    const_syms:\n      A dictionary like 'syms' for constant (quoted) symbols\n\n    named_choices:\n      A dictionary like 'syms' for named choices (choice FOO)\n\n    defined_syms:\n      A list with all defined symbols, in the same order as they appear in the\n      Kconfig files. Symbols defined in multiple locations appear multiple\n      times.\n\n      Note: You probably want to use 'unique_defined_syms' instead. This\n      attribute is mostly maintained for backwards compatibility.\n\n    unique_defined_syms:\n      A list like 'defined_syms', but with duplicates removed. Just the first\n      instance is kept for symbols defined in multiple locations. Kconfig order\n      is preserved otherwise.\n\n      Using this attribute instead of 'defined_syms' can save work, and\n      automatically gives reasonable behavior when writing configuration output\n      (symbols defined in multiple locations only generate output once, while\n      still preserving Kconfig order for readability).\n\n    choices:\n      A list with all choices, in the same order as they appear in the Kconfig\n      files.\n\n      Note: You probably want to use 'unique_choices' instead. This attribute\n      is mostly maintained for backwards compatibility.\n\n    unique_choices:\n      Analogous to 'unique_defined_syms', for choices. Named choices can have\n      multiple definition locations.\n\n    menus:\n      A list with all menus, in the same order as they appear in the Kconfig\n      files\n\n    comments:\n      A list with all comments, in the same order as they appear in the Kconfig\n      files\n\n    kconfig_filenames:\n      A list with the filenames of all Kconfig files included in the\n      configuration, relative to $srctree (or relative to the current directory\n      if $srctree isn't set), except absolute paths (e.g.\n      'source \"/foo/Kconfig\"') are kept as-is.\n\n      The files are listed in the order they are source'd, starting with the\n      top-level Kconfig file. If a file is source'd multiple times, it will\n      appear multiple times. Use set() to get unique filenames.\n\n      Note that Kconfig.sync_deps() already indirectly catches any file\n      modifications that change configuration output.\n\n    env_vars:\n      A set() with the names of all environment variables referenced in the\n      Kconfig files.\n\n      Only environment variables referenced with the preprocessor $(FOO) syntax\n      will be registered. The older $FOO syntax is only supported for backwards\n      compatibility.\n\n      Also note that $(FOO) won't be registered unless the environment variable\n      $FOO is actually set. If it isn't, $(FOO) is an expansion of an unset\n      preprocessor variable (which gives the empty string).\n\n      Another gotcha is that environment variables referenced in the values of\n      recursively expanded preprocessor variables (those defined with =) will\n      only be registered if the variable is actually used (expanded) somewhere.\n\n      The note from the 'kconfig_filenames' documentation applies here too.\n\n    n/m/y:\n      The predefined constant symbols n/m/y. Also available in const_syms.\n\n    modules:\n      The Symbol instance for the modules symbol. Currently hardcoded to\n      MODULES, which is backwards compatible. Kconfiglib will warn if\n      'option modules' is set on some other symbol. Tell me if you need proper\n      'option modules' support.\n\n      'modules' is never None. If the MODULES symbol is not explicitly defined,\n      its tri_value will be 0 (n), as expected.\n\n      A simple way to enable modules is to do 'kconf.modules.set_value(2)'\n      (provided the MODULES symbol is defined and visible). Modules are\n      disabled by default in the kernel Kconfig files as of writing, though\n      nearly all defconfig files enable them (with 'CONFIG_MODULES=y').\n\n    defconfig_list:\n      The Symbol instance for the 'option defconfig_list' symbol, or None if no\n      defconfig_list symbol exists. The defconfig filename derived from this\n      symbol can be found in Kconfig.defconfig_filename.\n\n    defconfig_filename:\n      The filename given by the defconfig_list symbol. This is taken from the\n      first 'default' with a satisfied condition where the specified file\n      exists (can be opened for reading). If a defconfig file foo/defconfig is\n      not found and $srctree was set when the Kconfig was created,\n      $srctree/foo/defconfig is looked up as well.\n\n      'defconfig_filename' is None if either no defconfig_list symbol exists,\n      or if the defconfig_list symbol has no 'default' with a satisfied\n      condition that specifies a file that exists.\n\n      Gotcha: scripts/kconfig/Makefile might pass --defconfig=<defconfig> to\n      scripts/kconfig/conf when running e.g. 'make defconfig'. This option\n      overrides the defconfig_list symbol, meaning defconfig_filename might not\n      always match what 'make defconfig' would use.\n\n    top_node:\n      The menu node (see the MenuNode class) of the implicit top-level menu.\n      Acts as the root of the menu tree.\n\n    mainmenu_text:\n      The prompt (title) of the top menu (top_node). Defaults to \"Main menu\".\n      Can be changed with the 'mainmenu' statement (see kconfig-language.txt).\n\n    variables:\n      A dictionary with all preprocessor variables, indexed by name. See the\n      Variable class.\n\n    warn:\n      Set this variable to True/False to enable/disable warnings. See\n      Kconfig.__init__().\n\n      When 'warn' is False, the values of the other warning-related variables\n      are ignored.\n\n      This variable as well as the other warn* variables can be read to check\n      the current warning settings.\n\n    warn_to_stderr:\n      Set this variable to True/False to enable/disable warnings on stderr. See\n      Kconfig.__init__().\n\n    warn_assign_undef:\n      Set this variable to True to generate warnings for assignments to\n      undefined symbols in configuration files.\n\n      This variable is False by default unless the KCONFIG_WARN_UNDEF_ASSIGN\n      environment variable was set to 'y' when the Kconfig instance was\n      created.\n\n    warn_assign_override:\n      Set this variable to True to generate warnings for multiple assignments\n      to the same symbol in configuration files, where the assignments set\n      different values (e.g. CONFIG_FOO=m followed by CONFIG_FOO=y, where the\n      last value would get used).\n\n      This variable is True by default. Disabling it might be useful when\n      merging configurations.\n\n    warn_assign_redun:\n      Like warn_assign_override, but for multiple assignments setting a symbol\n      to the same value.\n\n      This variable is True by default. Disabling it might be useful when\n      merging configurations.\n\n    warnings:\n      A list of strings containing all warnings that have been generated, for\n      cases where more flexibility is needed.\n\n      See the 'warn_to_stderr' parameter to Kconfig.__init__() and the\n      Kconfig.warn_to_stderr variable as well. Note that warnings still get\n      added to Kconfig.warnings when 'warn_to_stderr' is True.\n\n      Just as for warnings printed to stderr, only warnings that are enabled\n      will get added to Kconfig.warnings. See the various Kconfig.warn*\n      variables.\n\n    missing_syms:\n      A list with (name, value) tuples for all assignments to undefined symbols\n      within the most recently loaded .config file(s). 'name' is the symbol\n      name without the 'CONFIG_' prefix. 'value' is a string that gives the\n      right-hand side of the assignment verbatim.\n\n      See Kconfig.load_config() as well.\n\n    srctree:\n      The value the $srctree environment variable had when the Kconfig instance\n      was created, or the empty string if $srctree wasn't set. This gives nice\n      behavior with os.path.join(), which treats \"\" as the current directory,\n      without adding \"./\".\n\n      Kconfig files are looked up relative to $srctree (unless absolute paths\n      are used), and .config files are looked up relative to $srctree if they\n      are not found in the current directory. This is used to support\n      out-of-tree builds. The C tools use this environment variable in the same\n      way.\n\n      Changing $srctree after creating the Kconfig instance has no effect. Only\n      the value when the configuration is loaded matters. This avoids surprises\n      if multiple configurations are loaded with different values for $srctree.\n\n    config_prefix:\n      The value the CONFIG_ environment variable had when the Kconfig instance\n      was created, or \"CONFIG_\" if CONFIG_ wasn't set. This is the prefix used\n      (and expected) on symbol names in .config files and C headers. Used in\n      the same way in the C tools.\n\n    config_header:\n      The value the KCONFIG_CONFIG_HEADER environment variable had when the\n      Kconfig instance was created, or the empty string if\n      KCONFIG_CONFIG_HEADER wasn't set. This string is inserted verbatim at the\n      beginning of configuration files. See write_config().\n\n    header_header:\n      The value the KCONFIG_AUTOHEADER_HEADER environment variable had when the\n      Kconfig instance was created, or the empty string if\n      KCONFIG_AUTOHEADER_HEADER wasn't set. This string is inserted verbatim at\n      the beginning of header files. See write_autoconf().\n\n    filename/linenr:\n      The current parsing location, for use in Python preprocessor functions.\n      See the module docstring.\n    \"\"\"\n    __slots__ = (\n        \"_encoding\",\n        \"_functions\",\n        \"_set_match\",\n        \"_srctree_prefix\",\n        \"_unset_match\",\n        \"_warn_assign_no_prompt\",\n        \"choices\",\n        \"comments\",\n        \"config_header\",\n        \"config_prefix\",\n        \"const_syms\",\n        \"defconfig_list\",\n        \"defined_syms\",\n        \"env_vars\",\n        \"header_header\",\n        \"kconfig_filenames\",\n        \"m\",\n        \"menus\",\n        \"missing_syms\",\n        \"modules\",\n        \"n\",\n        \"named_choices\",\n        \"srctree\",\n        \"syms\",\n        \"top_node\",\n        \"unique_choices\",\n        \"unique_defined_syms\",\n        \"variables\",\n        \"warn\",\n        \"warn_assign_override\",\n        \"warn_assign_redun\",\n        \"warn_assign_undef\",\n        \"warn_to_stderr\",\n        \"warnings\",\n        \"y\",\n\n        # Parsing-related\n        \"_parsing_kconfigs\",\n        \"_readline\",\n        \"filename\",\n        \"linenr\",\n        \"_include_path\",\n        \"_filestack\",\n        \"_line\",\n        \"_tokens\",\n        \"_tokens_i\",\n        \"_reuse_tokens\",\n    )\n\n    #\n    # Public interface\n    #\n\n    def __init__(self, filename=\"Kconfig\", warn=True, warn_to_stderr=True,\n                 encoding=\"utf-8\", suppress_traceback=False):\n        \"\"\"\n        Creates a new Kconfig object by parsing Kconfig files.\n        Note that Kconfig files are not the same as .config files (which store\n        configuration symbol values).\n\n        See the module docstring for some environment variables that influence\n        default warning settings (KCONFIG_WARN_UNDEF and\n        KCONFIG_WARN_UNDEF_ASSIGN).\n\n        Raises KconfigError on syntax/semantic errors, and OSError or (possibly\n        a subclass of) IOError on IO errors ('errno', 'strerror', and\n        'filename' are available). Note that IOError is an alias for OSError on\n        Python 3, so it's enough to catch OSError there. If you need Python 2/3\n        compatibility, it's easiest to catch EnvironmentError, which is a\n        common base class of OSError/IOError on Python 2 and an alias for\n        OSError on Python 3.\n\n        filename (default: \"Kconfig\"):\n          The Kconfig file to load. For the Linux kernel, you'll want \"Kconfig\"\n          from the top-level directory, as environment variables will make sure\n          the right Kconfig is included from there (arch/$SRCARCH/Kconfig as of\n          writing).\n\n          If $srctree is set, 'filename' will be looked up relative to it.\n          $srctree is also used to look up source'd files within Kconfig files.\n          See the class documentation.\n\n          If you are using Kconfiglib via 'make scriptconfig', the filename of\n          the base base Kconfig file will be in sys.argv[1]. It's currently\n          always \"Kconfig\" in practice.\n\n        warn (default: True):\n          True if warnings related to this configuration should be generated.\n          This can be changed later by setting Kconfig.warn to True/False. It\n          is provided as a constructor argument since warnings might be\n          generated during parsing.\n\n          See the other Kconfig.warn_* variables as well, which enable or\n          suppress certain warnings when warnings are enabled.\n\n          All generated warnings are added to the Kconfig.warnings list. See\n          the class documentation.\n\n        warn_to_stderr (default: True):\n          True if warnings should be printed to stderr in addition to being\n          added to Kconfig.warnings.\n\n          This can be changed later by setting Kconfig.warn_to_stderr to\n          True/False.\n\n        encoding (default: \"utf-8\"):\n          The encoding to use when reading and writing files, and when decoding\n          output from commands run via $(shell). If None, the encoding\n          specified in the current locale will be used.\n\n          The \"utf-8\" default avoids exceptions on systems that are configured\n          to use the C locale, which implies an ASCII encoding.\n\n          This parameter has no effect on Python 2, due to implementation\n          issues (regular strings turning into Unicode strings, which are\n          distinct in Python 2). Python 2 doesn't decode regular strings\n          anyway.\n\n          Related PEP: https://www.python.org/dev/peps/pep-0538/\n\n        suppress_traceback (default: False):\n          Helper for tools. When True, any EnvironmentError or KconfigError\n          generated during parsing is caught, the exception message is printed\n          to stderr together with the command name, and sys.exit(1) is called\n          (which generates SystemExit).\n\n          This hides the Python traceback for \"expected\" errors like syntax\n          errors in Kconfig files.\n\n          Other exceptions besides EnvironmentError and KconfigError are still\n          propagated when suppress_traceback is True.\n        \"\"\"\n        try:\n            self._init(filename, warn, warn_to_stderr, encoding)\n        except (EnvironmentError, KconfigError) as e:\n            if suppress_traceback:\n                cmd = sys.argv[0]  # Empty string if missing\n                if cmd:\n                    cmd += \": \"\n                # Some long exception messages have extra newlines for better\n                # formatting when reported as an unhandled exception. Strip\n                # them here.\n                sys.exit(cmd + str(e).strip())\n            raise\n\n    def _init(self, filename, warn, warn_to_stderr, encoding):\n        # See __init__()\n\n        self._encoding = encoding\n\n        self.srctree = os.getenv(\"srctree\", \"\")\n        # A prefix we can reliably strip from glob() results to get a filename\n        # relative to $srctree. relpath() can cause issues for symlinks,\n        # because it assumes symlink/../foo is the same as foo/.\n        self._srctree_prefix = realpath(self.srctree) + os.sep\n\n        self.warn = warn\n        self.warn_to_stderr = warn_to_stderr\n        self.warn_assign_undef = os.getenv(\"KCONFIG_WARN_UNDEF_ASSIGN\") == \"y\"\n        self.warn_assign_override = True\n        self.warn_assign_redun = True\n        self._warn_assign_no_prompt = True\n\n        self.warnings = []\n\n        self.config_prefix = os.getenv(\"CONFIG_\", \"CONFIG_\")\n        # Regular expressions for parsing .config files\n        self._set_match = _re_match(self.config_prefix + r\"([^=]+)=(.*)\")\n        self._unset_match = _re_match(r\"# {}([^ ]+) is not set\".format(\n            self.config_prefix))\n\n        self.config_header = os.getenv(\"KCONFIG_CONFIG_HEADER\", \"\")\n        self.header_header = os.getenv(\"KCONFIG_AUTOHEADER_HEADER\", \"\")\n\n        self.syms = {}\n        self.const_syms = {}\n        self.defined_syms = []\n        self.missing_syms = []\n        self.named_choices = {}\n        self.choices = []\n        self.menus = []\n        self.comments = []\n\n        for nmy in \"n\", \"m\", \"y\":\n            sym = Symbol()\n            sym.kconfig = self\n            sym.name = nmy\n            sym.is_constant = True\n            sym.orig_type = TRISTATE\n            sym._cached_tri_val = STR_TO_TRI[nmy]\n\n            self.const_syms[nmy] = sym\n\n        self.n = self.const_syms[\"n\"]\n        self.m = self.const_syms[\"m\"]\n        self.y = self.const_syms[\"y\"]\n\n        # Make n/m/y well-formed symbols\n        for nmy in \"n\", \"m\", \"y\":\n            sym = self.const_syms[nmy]\n            sym.rev_dep = sym.weak_rev_dep = sym.direct_dep = self.n\n\n        # Maps preprocessor variables names to Variable instances\n        self.variables = {}\n\n        # Predefined preprocessor functions, with min/max number of arguments\n        self._functions = {\n            \"info\":       (_info_fn,       1, 1),\n            \"error-if\":   (_error_if_fn,   2, 2),\n            \"filename\":   (_filename_fn,   0, 0),\n            \"lineno\":     (_lineno_fn,     0, 0),\n            \"shell\":      (_shell_fn,      1, 1),\n            \"warning-if\": (_warning_if_fn, 2, 2),\n        }\n\n        # Add any user-defined preprocessor functions\n        try:\n            self._functions.update(\n                importlib.import_module(\n                    os.getenv(\"KCONFIG_FUNCTIONS\", \"kconfigfunctions\")\n                ).functions)\n        except ImportError:\n            pass\n\n        # This determines whether previously unseen symbols are registered.\n        # They shouldn't be if we parse expressions after parsing, as part of\n        # Kconfig.eval_string().\n        self._parsing_kconfigs = True\n\n        self.modules = self._lookup_sym(\"MODULES\")\n        self.defconfig_list = None\n\n        self.top_node = MenuNode()\n        self.top_node.kconfig = self\n        self.top_node.item = MENU\n        self.top_node.is_menuconfig = True\n        self.top_node.visibility = self.y\n        self.top_node.prompt = (\"Main menu\", self.y)\n        self.top_node.parent = None\n        self.top_node.dep = self.y\n        self.top_node.filename = filename\n        self.top_node.linenr = 1\n        self.top_node.include_path = ()\n\n        # Parse the Kconfig files\n\n        # Not used internally. Provided as a convenience.\n        self.kconfig_filenames = [filename]\n        self.env_vars = set()\n\n        # Keeps track of the location in the parent Kconfig files. Kconfig\n        # files usually source other Kconfig files. See _enter_file().\n        self._filestack = []\n        self._include_path = ()\n\n        # The current parsing location\n        self.filename = filename\n        self.linenr = 0\n\n        # Used to avoid retokenizing lines when we discover that they're not\n        # part of the construct currently being parsed. This is kinda like an\n        # unget operation.\n        self._reuse_tokens = False\n\n        # Open the top-level Kconfig file. Store the readline() method directly\n        # as a small optimization.\n        self._readline = self._open(join(self.srctree, filename), \"r\").readline\n\n        try:\n            # Parse the Kconfig files. Returns the last node, which we\n            # terminate with '.next = None'.\n            self._parse_block(None, self.top_node, self.top_node).next = None\n            self.top_node.list = self.top_node.next\n            self.top_node.next = None\n        except UnicodeDecodeError as e:\n            _decoding_error(e, self.filename)\n\n        # Close the top-level Kconfig file. __self__ fetches the 'file' object\n        # for the method.\n        self._readline.__self__.close()\n\n        self._parsing_kconfigs = False\n\n        # Do various menu tree post-processing\n        self._finalize_node(self.top_node, self.y)\n\n        self.unique_defined_syms = _ordered_unique(self.defined_syms)\n        self.unique_choices = _ordered_unique(self.choices)\n\n        # Do sanity checks. Some of these depend on everything being finalized.\n        self._check_sym_sanity()\n        self._check_choice_sanity()\n\n        # KCONFIG_STRICT is an older alias for KCONFIG_WARN_UNDEF, supported\n        # for backwards compatibility\n        if os.getenv(\"KCONFIG_WARN_UNDEF\") == \"y\" or \\\n           os.getenv(\"KCONFIG_STRICT\") == \"y\":\n\n            self._check_undef_syms()\n\n        # Build Symbol._dependents for all symbols and choices\n        self._build_dep()\n\n        # Check for dependency loops\n        check_dep_loop_sym = _check_dep_loop_sym  # Micro-optimization\n        for sym in self.unique_defined_syms:\n            check_dep_loop_sym(sym, False)\n\n        # Add extra dependencies from choices to choice symbols that get\n        # awkward during dependency loop detection\n        self._add_choice_deps()\n\n    @property\n    def mainmenu_text(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return self.top_node.prompt[0]\n\n    @property\n    def defconfig_filename(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if self.defconfig_list:\n            for filename, cond in self.defconfig_list.defaults:\n                if expr_value(cond):\n                    try:\n                        with self._open_config(filename.str_value) as f:\n                            return f.name\n                    except EnvironmentError:\n                        continue\n\n        return None\n\n    def load_config(self, filename=None, replace=True, verbose=None):\n        \"\"\"\n        Loads symbol values from a file in the .config format. Equivalent to\n        calling Symbol.set_value() to set each of the values.\n\n        \"# CONFIG_FOO is not set\" within a .config file sets the user value of\n        FOO to n. The C tools work the same way.\n\n        For each symbol, the Symbol.user_value attribute holds the value the\n        symbol was assigned in the .config file (if any). The user value might\n        differ from Symbol.str/tri_value if there are unsatisfied dependencies.\n\n        Calling this function also updates the Kconfig.missing_syms attribute\n        with a list of all assignments to undefined symbols within the\n        configuration file. Kconfig.missing_syms is cleared if 'replace' is\n        True, and appended to otherwise. See the documentation for\n        Kconfig.missing_syms as well.\n\n        See the Kconfig.__init__() docstring for raised exceptions\n        (OSError/IOError). KconfigError is never raised here.\n\n        filename (default: None):\n          Path to load configuration from (a string). Respects $srctree if set\n          (see the class documentation).\n\n          If 'filename' is None (the default), the configuration file to load\n          (if any) is calculated automatically, giving the behavior you'd\n          usually want:\n\n            1. If the KCONFIG_CONFIG environment variable is set, it gives the\n               path to the configuration file to load. Otherwise, \".config\" is\n               used. See standard_config_filename().\n\n            2. If the path from (1.) doesn't exist, the configuration file\n               given by kconf.defconfig_filename is loaded instead, which is\n               derived from the 'option defconfig_list' symbol.\n\n            3. If (1.) and (2.) fail to find a configuration file to load, no\n               configuration file is loaded, and symbols retain their current\n               values (e.g., their default values). This is not an error.\n\n           See the return value as well.\n\n        replace (default: True):\n          If True, all existing user values will be cleared before loading the\n          .config. Pass False to merge configurations.\n\n        verbose (default: None):\n          Limited backwards compatibility to prevent crashes. A warning is\n          printed if anything but None is passed.\n\n          Prior to Kconfiglib 12.0.0, this option enabled printing of messages\n          to stdout when 'filename' was None. A message is (always) returned\n          now instead, which is more flexible.\n\n          Will probably be removed in some future version.\n\n        Returns a string with a message saying which file got loaded (or\n        possibly that no file got loaded, when 'filename' is None). This is\n        meant to reduce boilerplate in tools, which can do e.g.\n        print(kconf.load_config()). The returned message distinguishes between\n        loading (replace == True) and merging (replace == False).\n        \"\"\"\n        if verbose is not None:\n            _warn_verbose_deprecated(\"load_config\")\n\n        msg = None\n        if filename is None:\n            filename = standard_config_filename()\n            if not exists(filename) and \\\n               not exists(join(self.srctree, filename)):\n                defconfig = self.defconfig_filename\n                if defconfig is None:\n                    return \"Using default symbol values (no '{}')\" \\\n                           .format(filename)\n\n                msg = \" default configuration '{}' (no '{}')\" \\\n                      .format(defconfig, filename)\n                filename = defconfig\n\n        if not msg:\n            msg = \" configuration '{}'\".format(filename)\n\n        # Disable the warning about assigning to symbols without prompts. This\n        # is normal and expected within a .config file.\n        self._warn_assign_no_prompt = False\n\n        # This stub only exists to make sure _warn_assign_no_prompt gets\n        # reenabled\n        try:\n            self._load_config(filename, replace)\n        except UnicodeDecodeError as e:\n            _decoding_error(e, filename)\n        finally:\n            self._warn_assign_no_prompt = True\n\n        return (\"Loaded\" if replace else \"Merged\") + msg\n\n    def _load_config(self, filename, replace):\n        with self._open_config(filename) as f:\n            if replace:\n                self.missing_syms = []\n\n                # If we're replacing the configuration, keep track of which\n                # symbols and choices got set so that we can unset the rest\n                # later. This avoids invalidating everything and is faster.\n                # Another benefit is that invalidation must be rock solid for\n                # it to work, making it a good test.\n\n                for sym in self.unique_defined_syms:\n                    sym._was_set = False\n\n                for choice in self.unique_choices:\n                    choice._was_set = False\n\n            # Small optimizations\n            set_match = self._set_match\n            unset_match = self._unset_match\n            get_sym = self.syms.get\n\n            for linenr, line in enumerate(f, 1):\n                # The C tools ignore trailing whitespace\n                line = line.rstrip()\n\n                match = set_match(line)\n                if match:\n                    name, val = match.groups()\n                    sym = get_sym(name)\n                    if not sym or not sym.nodes:\n                        self._undef_assign(name, val, filename, linenr)\n                        continue\n\n                    if sym.orig_type in _BOOL_TRISTATE:\n                        # The C implementation only checks the first character\n                        # to the right of '=', for whatever reason\n                        if not (sym.orig_type is BOOL\n                                and val.startswith((\"y\", \"n\")) or\n                                sym.orig_type is TRISTATE\n                                and val.startswith((\"y\", \"m\", \"n\"))):\n                            self._warn(\"'{}' is not a valid value for the {} \"\n                                       \"symbol {}. Assignment ignored.\"\n                                       .format(val, TYPE_TO_STR[sym.orig_type],\n                                               sym.name_and_loc),\n                                       filename, linenr)\n                            continue\n\n                        val = val[0]\n\n                        if sym.choice and val != \"n\":\n                            # During .config loading, we infer the mode of the\n                            # choice from the kind of values that are assigned\n                            # to the choice symbols\n\n                            prev_mode = sym.choice.user_value\n                            if prev_mode is not None and \\\n                               TRI_TO_STR[prev_mode] != val:\n\n                                self._warn(\"both m and y assigned to symbols \"\n                                           \"within the same choice\",\n                                           filename, linenr)\n\n                            # Set the choice's mode\n                            sym.choice.set_value(val)\n\n                    elif sym.orig_type is STRING:\n                        match = _conf_string_match(val)\n                        if not match:\n                            self._warn(\"malformed string literal in \"\n                                       \"assignment to {}. Assignment ignored.\"\n                                       .format(sym.name_and_loc),\n                                       filename, linenr)\n                            continue\n\n                        val = unescape(match.group(1))\n\n                else:\n                    match = unset_match(line)\n                    if not match:\n                        # Print a warning for lines that match neither\n                        # set_match() nor unset_match() and that are not blank\n                        # lines or comments. 'line' has already been\n                        # rstrip()'d, so blank lines show up as \"\" here.\n                        if line and not line.lstrip().startswith(\"#\"):\n                            self._warn(\"ignoring malformed line '{}'\"\n                                       .format(line),\n                                       filename, linenr)\n\n                        continue\n\n                    name = match.group(1)\n                    sym = get_sym(name)\n                    if not sym or not sym.nodes:\n                        self._undef_assign(name, \"n\", filename, linenr)\n                        continue\n\n                    if sym.orig_type not in _BOOL_TRISTATE:\n                        continue\n\n                    val = \"n\"\n\n                # Done parsing the assignment. Set the value.\n\n                if sym._was_set:\n                    self._assigned_twice(sym, val, filename, linenr)\n\n                sym.set_value(val)\n\n        if replace:\n            # If we're replacing the configuration, unset the symbols that\n            # didn't get set\n\n            for sym in self.unique_defined_syms:\n                if not sym._was_set:\n                    sym.unset_value()\n\n            for choice in self.unique_choices:\n                if not choice._was_set:\n                    choice.unset_value()\n\n    def _undef_assign(self, name, val, filename, linenr):\n        # Called for assignments to undefined symbols during .config loading\n\n        self.missing_syms.append((name, val))\n        if self.warn_assign_undef:\n            self._warn(\n                \"attempt to assign the value '{}' to the undefined symbol {}\"\n                .format(val, name), filename, linenr)\n\n    def _assigned_twice(self, sym, new_val, filename, linenr):\n        # Called when a symbol is assigned more than once in a .config file\n\n        # Use strings for bool/tristate user values in the warning\n        if sym.orig_type in _BOOL_TRISTATE:\n            user_val = TRI_TO_STR[sym.user_value]\n        else:\n            user_val = sym.user_value\n\n        msg = '{} set more than once. Old value \"{}\", new value \"{}\".'.format(\n            sym.name_and_loc, user_val, new_val)\n\n        if user_val == new_val:\n            if self.warn_assign_redun:\n                self._warn(msg, filename, linenr)\n        elif self.warn_assign_override:\n            self._warn(msg, filename, linenr)\n\n    def load_allconfig(self, filename):\n        \"\"\"\n        Helper for all*config. Loads (merges) the configuration file specified\n        by KCONFIG_ALLCONFIG, if any. See Documentation/kbuild/kconfig.txt in\n        the Linux kernel.\n\n        Disables warnings for duplicated assignments within configuration files\n        for the duration of the call\n        (kconf.warn_assign_override/warn_assign_redun = False), and restores\n        the previous warning settings at the end. The KCONFIG_ALLCONFIG\n        configuration file is expected to override symbols.\n\n        Exits with sys.exit() (which raises a SystemExit exception) and prints\n        an error to stderr if KCONFIG_ALLCONFIG is set but the configuration\n        file can't be opened.\n\n        filename:\n          Command-specific configuration filename - \"allyes.config\",\n          \"allno.config\", etc.\n        \"\"\"\n        load_allconfig(self, filename)\n\n    def write_autoconf(self, filename=None, header=None):\n        r\"\"\"\n        Writes out symbol values as a C header file, matching the format used\n        by include/generated/autoconf.h in the kernel.\n\n        The ordering of the #defines matches the one generated by\n        write_config(). The order in the C implementation depends on the hash\n        table implementation as of writing, and so won't match.\n\n        If 'filename' exists and its contents is identical to what would get\n        written out, it is left untouched. This avoids updating file metadata\n        like the modification time and possibly triggering redundant work in\n        build tools.\n\n        filename (default: None):\n          Path to write header to.\n\n          If None (the default), the path in the environment variable\n          KCONFIG_AUTOHEADER is used if set, and \"include/generated/autoconf.h\"\n          otherwise. This is compatible with the C tools.\n\n        header (default: None):\n          Text inserted verbatim at the beginning of the file. You would\n          usually want it enclosed in '/* */' to make it a C comment, and\n          include a trailing newline.\n\n          If None (the default), the value of the environment variable\n          KCONFIG_AUTOHEADER_HEADER had when the Kconfig instance was created\n          will be used if it was set, and no header otherwise. See the\n          Kconfig.header_header attribute.\n\n        Returns a string with a message saying that the header got saved, or\n        that there were no changes to it. This is meant to reduce boilerplate\n        in tools, which can do e.g. print(kconf.write_autoconf()).\n        \"\"\"\n        if filename is None:\n            filename = os.getenv(\"KCONFIG_AUTOHEADER\",\n                                 \"include/generated/autoconf.h\")\n\n        if self._write_if_changed(filename, self._autoconf_contents(header)):\n            return \"Kconfig header saved to '{}'\".format(filename)\n        return \"No change to Kconfig header in '{}'\".format(filename)\n\n    def _autoconf_contents(self, header):\n        # write_autoconf() helper. Returns the contents to write as a string,\n        # with 'header' or KCONFIG_AUTOHEADER_HEADER at the beginning.\n\n        if header is None:\n            header = self.header_header\n\n        chunks = [header]  # \"\".join()ed later\n        add = chunks.append\n\n        for sym in self.unique_defined_syms:\n            # _write_to_conf is determined when the value is calculated. This\n            # is a hidden function call due to property magic.\n            #\n            # Note: In client code, you can check if sym.config_string is empty\n            # instead, to avoid accessing the internal _write_to_conf variable\n            # (though it's likely to keep working).\n            val = sym.str_value\n            if not sym._write_to_conf:\n                continue\n\n            if sym.orig_type in _BOOL_TRISTATE:\n                if val == \"y\":\n                    add(\"#define {}{} 1\\n\"\n                        .format(self.config_prefix, sym.name))\n                elif val == \"m\":\n                    add(\"#define {}{}_MODULE 1\\n\"\n                        .format(self.config_prefix, sym.name))\n\n            elif sym.orig_type is STRING:\n                add('#define {}{} \"{}\"\\n'\n                    .format(self.config_prefix, sym.name, escape(val)))\n\n            else:  # sym.orig_type in _INT_HEX:\n                if sym.orig_type is HEX and \\\n                   not val.startswith((\"0x\", \"0X\")):\n                    val = \"0x\" + val\n\n                add(\"#define {}{} {}\\n\"\n                    .format(self.config_prefix, sym.name, val))\n\n        return \"\".join(chunks)\n\n    def write_config(self, filename=None, header=None, save_old=True,\n                     verbose=None):\n        r\"\"\"\n        Writes out symbol values in the .config format. The format matches the\n        C implementation, including ordering.\n\n        Symbols appear in the same order in generated .config files as they do\n        in the Kconfig files. For symbols defined in multiple locations, a\n        single assignment is written out corresponding to the first location\n        where the symbol is defined.\n\n        See the 'Intro to symbol values' section in the module docstring to\n        understand which symbols get written out.\n\n        If 'filename' exists and its contents is identical to what would get\n        written out, it is left untouched. This avoids updating file metadata\n        like the modification time and possibly triggering redundant work in\n        build tools.\n\n        See the Kconfig.__init__() docstring for raised exceptions\n        (OSError/IOError). KconfigError is never raised here.\n\n        filename (default: None):\n          Path to write configuration to (a string).\n\n          If None (the default), the path in the environment variable\n          KCONFIG_CONFIG is used if set, and \".config\" otherwise. See\n          standard_config_filename().\n\n        header (default: None):\n          Text inserted verbatim at the beginning of the file. You would\n          usually want each line to start with '#' to make it a comment, and\n          include a trailing newline.\n\n          if None (the default), the value of the environment variable\n          KCONFIG_CONFIG_HEADER had when the Kconfig instance was created will\n          be used if it was set, and no header otherwise. See the\n          Kconfig.config_header attribute.\n\n        save_old (default: True):\n          If True and <filename> already exists, a copy of it will be saved to\n          <filename>.old in the same directory before the new configuration is\n          written.\n\n          Errors are silently ignored if <filename>.old cannot be written (e.g.\n          due to being a directory, or <filename> being something like\n          /dev/null).\n\n        verbose (default: None):\n          Limited backwards compatibility to prevent crashes. A warning is\n          printed if anything but None is passed.\n\n          Prior to Kconfiglib 12.0.0, this option enabled printing of messages\n          to stdout when 'filename' was None. A message is (always) returned\n          now instead, which is more flexible.\n\n          Will probably be removed in some future version.\n\n        Returns a string with a message saying which file got saved. This is\n        meant to reduce boilerplate in tools, which can do e.g.\n        print(kconf.write_config()).\n        \"\"\"\n        if verbose is not None:\n            _warn_verbose_deprecated(\"write_config\")\n\n        if filename is None:\n            filename = standard_config_filename()\n\n        contents = self._config_contents(header)\n        if self._contents_eq(filename, contents):\n            return \"No change to configuration in '{}'\".format(filename)\n\n        if save_old:\n            _save_old(filename)\n\n        with self._open(filename, \"w\") as f:\n            f.write(contents)\n\n        return \"Configuration saved to '{}'\".format(filename)\n\n    def _config_contents(self, header):\n        # write_config() helper. Returns the contents to write as a string,\n        # with 'header' or KCONFIG_CONFIG_HEADER at the beginning.\n        #\n        # More memory friendly would be to 'yield' the strings and\n        # \"\".join(_config_contents()), but it was a bit slower on my system.\n\n        # node_iter() was used here before commit 3aea9f7 (\"Add '# end of\n        # <menu>' after menus in .config\"). Those comments get tricky to\n        # implement with it.\n\n        for sym in self.unique_defined_syms:\n            sym._visited = False\n\n        if header is None:\n            header = self.config_header\n\n        chunks = [header]  # \"\".join()ed later\n        add = chunks.append\n\n        # Did we just print an '# end of ...' comment?\n        after_end_comment = False\n\n        node = self.top_node\n        while 1:\n            # Jump to the next node with an iterative tree walk\n            if node.list:\n                node = node.list\n            elif node.next:\n                node = node.next\n            else:\n                while node.parent:\n                    node = node.parent\n\n                    # Add a comment when leaving visible menus\n                    if node.item is MENU and expr_value(node.dep) and \\\n                       expr_value(node.visibility) and \\\n                       node is not self.top_node:\n                        add(\"# end of {}\\n\".format(node.prompt[0]))\n                        after_end_comment = True\n\n                    if node.next:\n                        node = node.next\n                        break\n                else:\n                    # No more nodes\n                    return \"\".join(chunks)\n\n            # Generate configuration output for the node\n\n            item = node.item\n\n            if item.__class__ is Symbol:\n                if item._visited:\n                    continue\n                item._visited = True\n\n                conf_string = item.config_string\n                if not conf_string:\n                    continue\n\n                if after_end_comment:\n                    # Add a blank line before the first symbol printed after an\n                    # '# end of ...' comment\n                    after_end_comment = False\n                    add(\"\\n\")\n                add(conf_string)\n\n            elif expr_value(node.dep) and \\\n                 ((item is MENU and expr_value(node.visibility)) or\n                  item is COMMENT):\n\n                add(\"\\n#\\n# {}\\n#\\n\".format(node.prompt[0]))\n                after_end_comment = False\n\n    def write_min_config(self, filename, header=None):\n        \"\"\"\n        Writes out a \"minimal\" configuration file, omitting symbols whose value\n        matches their default value. The format matches the one produced by\n        'make savedefconfig'.\n\n        The resulting configuration file is incomplete, but a complete\n        configuration can be derived from it by loading it. Minimal\n        configuration files can serve as a more manageable configuration format\n        compared to a \"full\" .config file, especially when configurations files\n        are merged or edited by hand.\n\n        See the Kconfig.__init__() docstring for raised exceptions\n        (OSError/IOError). KconfigError is never raised here.\n\n        filename:\n          Path to write minimal configuration to.\n\n        header (default: None):\n          Text inserted verbatim at the beginning of the file. You would\n          usually want each line to start with '#' to make it a comment, and\n          include a final terminating newline.\n\n          if None (the default), the value of the environment variable\n          KCONFIG_CONFIG_HEADER had when the Kconfig instance was created will\n          be used if it was set, and no header otherwise. See the\n          Kconfig.config_header attribute.\n\n        Returns a string with a message saying the minimal configuration got\n        saved, or that there were no changes to it. This is meant to reduce\n        boilerplate in tools, which can do e.g.\n        print(kconf.write_min_config()).\n        \"\"\"\n        if self._write_if_changed(filename, self._min_config_contents(header)):\n            return \"Minimal configuration saved to '{}'\".format(filename)\n        return \"No change to minimal configuration in '{}'\".format(filename)\n\n    def _min_config_contents(self, header):\n        # write_min_config() helper. Returns the contents to write as a string,\n        # with 'header' or KCONFIG_CONFIG_HEADER at the beginning.\n\n        if header is None:\n            header = self.config_header\n\n        chunks = [header]  # \"\".join()ed later\n        add = chunks.append\n\n        for sym in self.unique_defined_syms:\n            # Skip symbols that cannot be changed. Only check\n            # non-choice symbols, as selects don't affect choice\n            # symbols.\n            if not sym.choice and \\\n               sym.visibility <= expr_value(sym.rev_dep):\n                continue\n\n            # Skip symbols whose value matches their default\n            if sym.str_value == sym._str_default():\n                continue\n\n            # Skip symbols that would be selected by default in a\n            # choice, unless the choice is optional or the symbol type\n            # isn't bool (it might be possible to set the choice mode\n            # to n or the symbol to m in those cases).\n            if sym.choice and \\\n               not sym.choice.is_optional and \\\n               sym.choice._selection_from_defaults() is sym and \\\n               sym.orig_type is BOOL and \\\n               sym.tri_value == 2:\n                continue\n\n            add(sym.config_string)\n\n        return \"\".join(chunks)\n\n    def sync_deps(self, path):\n        \"\"\"\n        Creates or updates a directory structure that can be used to avoid\n        doing a full rebuild whenever the configuration is changed, mirroring\n        include/config/ in the kernel.\n\n        This function is intended to be called during each build, before\n        compiling source files that depend on configuration symbols.\n\n        See the Kconfig.__init__() docstring for raised exceptions\n        (OSError/IOError). KconfigError is never raised here.\n\n        path:\n          Path to directory\n\n        sync_deps(path) does the following:\n\n          1. If the directory <path> does not exist, it is created.\n\n          2. If <path>/auto.conf exists, old symbol values are loaded from it,\n             which are then compared against the current symbol values. If a\n             symbol has changed value (would generate different output in\n             autoconf.h compared to before), the change is signaled by\n             touch'ing a file corresponding to the symbol.\n\n             The first time sync_deps() is run on a directory, <path>/auto.conf\n             won't exist, and no old symbol values will be available. This\n             logically has the same effect as updating the entire\n             configuration.\n\n             The path to a symbol's file is calculated from the symbol's name\n             by replacing all '_' with '/' and appending '.h'. For example, the\n             symbol FOO_BAR_BAZ gets the file <path>/foo/bar/baz.h, and FOO\n             gets the file <path>/foo.h.\n\n             This scheme matches the C tools. The point is to avoid having a\n             single directory with a huge number of files, which the underlying\n             filesystem might not handle well.\n\n          3. A new auto.conf with the current symbol values is written, to keep\n             track of them for the next build.\n\n             If auto.conf exists and its contents is identical to what would\n             get written out, it is left untouched. This avoids updating file\n             metadata like the modification time and possibly triggering\n             redundant work in build tools.\n\n\n        The last piece of the puzzle is knowing what symbols each source file\n        depends on. Knowing that, dependencies can be added from source files\n        to the files corresponding to the symbols they depends on. The source\n        file will then get recompiled (only) when the symbol value changes\n        (provided sync_deps() is run first during each build).\n\n        The tool in the kernel that extracts symbol dependencies from source\n        files is scripts/basic/fixdep.c. Missing symbol files also correspond\n        to \"not changed\", which fixdep deals with by using the $(wildcard) Make\n        function when adding symbol prerequisites to source files.\n\n        In case you need a different scheme for your project, the sync_deps()\n        implementation can be used as a template.\n        \"\"\"\n        if not exists(path):\n            os.mkdir(path, 0o755)\n\n        # Load old values from auto.conf, if any\n        self._load_old_vals(path)\n\n        for sym in self.unique_defined_syms:\n            # _write_to_conf is determined when the value is calculated. This\n            # is a hidden function call due to property magic.\n            #\n            # Note: In client code, you can check if sym.config_string is empty\n            # instead, to avoid accessing the internal _write_to_conf variable\n            # (though it's likely to keep working).\n            val = sym.str_value\n\n            # n tristate values do not get written to auto.conf and autoconf.h,\n            # making a missing symbol logically equivalent to n\n\n            if sym._write_to_conf:\n                if sym._old_val is None and \\\n                   sym.orig_type in _BOOL_TRISTATE and \\\n                   val == \"n\":\n                    # No old value (the symbol was missing or n), new value n.\n                    # No change.\n                    continue\n\n                if val == sym._old_val:\n                    # New value matches old. No change.\n                    continue\n\n            elif sym._old_val is None:\n                # The symbol wouldn't appear in autoconf.h (because\n                # _write_to_conf is false), and it wouldn't have appeared in\n                # autoconf.h previously either (because it didn't appear in\n                # auto.conf). No change.\n                continue\n\n            # 'sym' has a new value. Flag it.\n            _touch_dep_file(path, sym.name)\n\n        # Remember the current values as the \"new old\" values.\n        #\n        # This call could go anywhere after the call to _load_old_vals(), but\n        # putting it last means _sync_deps() can be safely rerun if it fails\n        # before this point.\n        self._write_old_vals(path)\n\n    def _load_old_vals(self, path):\n        # Loads old symbol values from auto.conf into a dedicated\n        # Symbol._old_val field. Mirrors load_config().\n        #\n        # The extra field could be avoided with some trickery involving dumping\n        # symbol values and restoring them later, but this is simpler and\n        # faster. The C tools also use a dedicated field for this purpose.\n\n        for sym in self.unique_defined_syms:\n            sym._old_val = None\n\n        try:\n            auto_conf = self._open(join(path, \"auto.conf\"), \"r\")\n        except EnvironmentError as e:\n            if e.errno == errno.ENOENT:\n                # No old values\n                return\n            raise\n\n        with auto_conf as f:\n            for line in f:\n                match = self._set_match(line)\n                if not match:\n                    # We only expect CONFIG_FOO=... (and possibly a header\n                    # comment) in auto.conf\n                    continue\n\n                name, val = match.groups()\n                if name in self.syms:\n                    sym = self.syms[name]\n\n                    if sym.orig_type is STRING:\n                        match = _conf_string_match(val)\n                        if not match:\n                            continue\n                        val = unescape(match.group(1))\n\n                    self.syms[name]._old_val = val\n                else:\n                    # Flag that the symbol no longer exists, in\n                    # case something still depends on it\n                    _touch_dep_file(path, name)\n\n    def _write_old_vals(self, path):\n        # Helper for writing auto.conf. Basically just a simplified\n        # write_config() that doesn't write any comments (including\n        # '# CONFIG_FOO is not set' comments). The format matches the C\n        # implementation, though the ordering is arbitrary there (depends on\n        # the hash table implementation).\n        #\n        # A separate helper function is neater than complicating write_config()\n        # by passing a flag to it, plus we only need to look at symbols here.\n\n        self._write_if_changed(\n            os.path.join(path, \"auto.conf\"),\n            self._old_vals_contents())\n\n    def _old_vals_contents(self):\n        # _write_old_vals() helper. Returns the contents to write as a string.\n\n        # Temporary list instead of generator makes this a bit faster\n        return \"\".join([\n            sym.config_string for sym in self.unique_defined_syms\n                if not (sym.orig_type in _BOOL_TRISTATE and not sym.tri_value)\n        ])\n\n    def node_iter(self, unique_syms=False):\n        \"\"\"\n        Returns a generator for iterating through all MenuNode's in the Kconfig\n        tree. The iteration is done in Kconfig definition order (each node is\n        visited before its children, and the children of a node are visited\n        before the next node).\n\n        The Kconfig.top_node menu node is skipped. It contains an implicit menu\n        that holds the top-level items.\n\n        As an example, the following code will produce a list equal to\n        Kconfig.defined_syms:\n\n          defined_syms = [node.item for node in kconf.node_iter()\n                          if isinstance(node.item, Symbol)]\n\n        unique_syms (default: False):\n          If True, only the first MenuNode will be included for symbols defined\n          in multiple locations.\n\n          Using kconf.node_iter(True) in the example above would give a list\n          equal to unique_defined_syms.\n        \"\"\"\n        if unique_syms:\n            for sym in self.unique_defined_syms:\n                sym._visited = False\n\n        node = self.top_node\n        while 1:\n            # Jump to the next node with an iterative tree walk\n            if node.list:\n                node = node.list\n            elif node.next:\n                node = node.next\n            else:\n                while node.parent:\n                    node = node.parent\n                    if node.next:\n                        node = node.next\n                        break\n                else:\n                    # No more nodes\n                    return\n\n            if unique_syms and node.item.__class__ is Symbol:\n                if node.item._visited:\n                    continue\n                node.item._visited = True\n\n            yield node\n\n    def eval_string(self, s):\n        \"\"\"\n        Returns the tristate value of the expression 's', represented as 0, 1,\n        and 2 for n, m, and y, respectively. Raises KconfigError on syntax\n        errors. Warns if undefined symbols are referenced.\n\n        As an example, if FOO and BAR are tristate symbols at least one of\n        which has the value y, then eval_string(\"y && (FOO || BAR)\") returns\n        2 (y).\n\n        To get the string value of non-bool/tristate symbols, use\n        Symbol.str_value. eval_string() always returns a tristate value, and\n        all non-bool/tristate symbols have the tristate value 0 (n).\n\n        The expression parsing is consistent with how parsing works for\n        conditional ('if ...') expressions in the configuration, and matches\n        the C implementation. m is rewritten to 'm && MODULES', so\n        eval_string(\"m\") will return 0 (n) unless modules are enabled.\n        \"\"\"\n        # The parser is optimized to be fast when parsing Kconfig files (where\n        # an expression can never appear at the beginning of a line). We have\n        # to monkey-patch things a bit here to reuse it.\n\n        self.filename = None\n\n        self._tokens = self._tokenize(\"if \" + s)\n        # Strip \"if \" to avoid giving confusing error messages\n        self._line = s\n        self._tokens_i = 1  # Skip the 'if' token\n\n        return expr_value(self._expect_expr_and_eol())\n\n    def unset_values(self):\n        \"\"\"\n        Removes any user values from all symbols, as if Kconfig.load_config()\n        or Symbol.set_value() had never been called.\n        \"\"\"\n        self._warn_assign_no_prompt = False\n        try:\n            # set_value() already rejects undefined symbols, and they don't\n            # need to be invalidated (because their value never changes), so we\n            # can just iterate over defined symbols\n            for sym in self.unique_defined_syms:\n                sym.unset_value()\n\n            for choice in self.unique_choices:\n                choice.unset_value()\n        finally:\n            self._warn_assign_no_prompt = True\n\n    def enable_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn = True' instead. Maintained for backwards\n        compatibility.\n        \"\"\"\n        self.warn = True\n\n    def disable_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn = False' instead. Maintained for backwards\n        compatibility.\n        \"\"\"\n        self.warn = False\n\n    def enable_stderr_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn_to_stderr = True' instead. Maintained for backwards\n        compatibility.\n        \"\"\"\n        self.warn_to_stderr = True\n\n    def disable_stderr_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn_to_stderr = False' instead. Maintained for backwards\n        compatibility.\n        \"\"\"\n        self.warn_to_stderr = False\n\n    def enable_undef_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn_assign_undef = True' instead. Maintained for backwards\n        compatibility.\n        \"\"\"\n        self.warn_assign_undef = True\n\n    def disable_undef_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn_assign_undef = False' instead. Maintained for\n        backwards compatibility.\n        \"\"\"\n        self.warn_assign_undef = False\n\n    def enable_override_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn_assign_override = True' instead. Maintained for\n        backwards compatibility.\n        \"\"\"\n        self.warn_assign_override = True\n\n    def disable_override_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn_assign_override = False' instead. Maintained for\n        backwards compatibility.\n        \"\"\"\n        self.warn_assign_override = False\n\n    def enable_redun_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn_assign_redun = True' instead. Maintained for backwards\n        compatibility.\n        \"\"\"\n        self.warn_assign_redun = True\n\n    def disable_redun_warnings(self):\n        \"\"\"\n        Do 'Kconfig.warn_assign_redun = False' instead. Maintained for\n        backwards compatibility.\n        \"\"\"\n        self.warn_assign_redun = False\n\n    def __repr__(self):\n        \"\"\"\n        Returns a string with information about the Kconfig object when it is\n        evaluated on e.g. the interactive Python prompt.\n        \"\"\"\n        def status(flag):\n            return \"enabled\" if flag else \"disabled\"\n\n        return \"<{}>\".format(\", \".join((\n            \"configuration with {} symbols\".format(len(self.syms)),\n            'main menu prompt \"{}\"'.format(self.mainmenu_text),\n            \"srctree is current directory\" if not self.srctree else\n                'srctree \"{}\"'.format(self.srctree),\n            'config symbol prefix \"{}\"'.format(self.config_prefix),\n            \"warnings \" + status(self.warn),\n            \"printing of warnings to stderr \" + status(self.warn_to_stderr),\n            \"undef. symbol assignment warnings \" +\n                status(self.warn_assign_undef),\n            \"overriding symbol assignment warnings \" +\n                status(self.warn_assign_override),\n            \"redundant symbol assignment warnings \" +\n                status(self.warn_assign_redun)\n        )))\n\n    #\n    # Private methods\n    #\n\n\n    #\n    # File reading\n    #\n\n    def _open_config(self, filename):\n        # Opens a .config file. First tries to open 'filename', then\n        # '$srctree/filename' if $srctree was set when the configuration was\n        # loaded.\n\n        try:\n            return self._open(filename, \"r\")\n        except EnvironmentError as e:\n            # This will try opening the same file twice if $srctree is unset,\n            # but it's not a big deal\n            try:\n                return self._open(join(self.srctree, filename), \"r\")\n            except EnvironmentError as e2:\n                # This is needed for Python 3, because e2 is deleted after\n                # the try block:\n                #\n                # https://docs.python.org/3/reference/compound_stmts.html#the-try-statement\n                e = e2\n\n            raise _KconfigIOError(\n                e, \"Could not open '{}' ({}: {}). Check that the $srctree \"\n                   \"environment variable ({}) is set correctly.\"\n                   .format(filename, errno.errorcode[e.errno], e.strerror,\n                           \"set to '{}'\".format(self.srctree) if self.srctree\n                               else \"unset or blank\"))\n\n    def _enter_file(self, filename):\n        # Jumps to the beginning of a sourced Kconfig file, saving the previous\n        # position and file object.\n        #\n        # filename:\n        #   Absolute path to file\n\n        # Path relative to $srctree, stored in e.g. self.filename (which makes\n        # it indirectly show up in MenuNode.filename). Equals 'filename' for\n        # absolute paths passed to 'source'.\n        if filename.startswith(self._srctree_prefix):\n            # Relative path (or a redundant absolute path to within $srctree,\n            # but it's probably fine to reduce those too)\n            rel_filename = filename[len(self._srctree_prefix):]\n        else:\n            # Absolute path\n            rel_filename = filename\n\n        self.kconfig_filenames.append(rel_filename)\n\n        # The parent Kconfig files are represented as a list of\n        # (<include path>, <Python 'file' object for Kconfig file>) tuples.\n        #\n        # <include path> is immutable and holds a *tuple* of\n        # (<filename>, <linenr>) tuples, giving the locations of the 'source'\n        # statements in the parent Kconfig files. The current include path is\n        # also available in Kconfig._include_path.\n        #\n        # The point of this redundant setup is to allow Kconfig._include_path\n        # to be assigned directly to MenuNode.include_path without having to\n        # copy it, sharing it wherever possible.\n\n        # Save include path and 'file' object (via its 'readline' function)\n        # before entering the file\n        self._filestack.append((self._include_path, self._readline))\n\n        # _include_path is a tuple, so this rebinds the variable instead of\n        # doing in-place modification\n        self._include_path += ((self.filename, self.linenr),)\n\n        # Check for recursive 'source'\n        for name, _ in self._include_path:\n            if name == rel_filename:\n                raise KconfigError(\n                    \"\\n{}:{}: recursive 'source' of '{}' detected. Check that \"\n                    \"environment variables are set correctly.\\n\"\n                    \"Include path:\\n{}\"\n                    .format(self.filename, self.linenr, rel_filename,\n                            \"\\n\".join(\"{}:{}\".format(name, linenr)\n                                      for name, linenr in self._include_path)))\n\n        try:\n            self._readline = self._open(filename, \"r\").readline\n        except EnvironmentError as e:\n            # We already know that the file exists\n            raise _KconfigIOError(\n                e, \"{}:{}: Could not open '{}' (in '{}') ({}: {})\"\n                   .format(self.filename, self.linenr, filename,\n                           self._line.strip(),\n                           errno.errorcode[e.errno], e.strerror))\n\n        self.filename = rel_filename\n        self.linenr = 0\n\n    def _leave_file(self):\n        # Returns from a Kconfig file to the file that sourced it. See\n        # _enter_file().\n\n        # Restore location from parent Kconfig file\n        self.filename, self.linenr = self._include_path[-1]\n        # Restore include path and 'file' object\n        self._readline.__self__.close()  # __self__ fetches the 'file' object\n        self._include_path, self._readline = self._filestack.pop()\n\n    def _next_line(self):\n        # Fetches and tokenizes the next line from the current Kconfig file.\n        # Returns False at EOF and True otherwise.\n\n        # We might already have tokens from parsing a line and discovering that\n        # it's part of a different construct\n        if self._reuse_tokens:\n            self._reuse_tokens = False\n            # self._tokens_i is known to be 1 here, because _parse_props()\n            # leaves it like that when it can't recognize a line (or parses a\n            # help text)\n            return True\n\n        # readline() returns '' over and over at EOF, which we rely on for help\n        # texts at the end of files (see _line_after_help())\n        line = self._readline()\n        if not line:\n            return False\n        self.linenr += 1\n\n        # Handle line joining\n        while line.endswith(\"\\\\\\n\"):\n            line = line[:-2] + self._readline()\n            self.linenr += 1\n\n        self._tokens = self._tokenize(line)\n        # Initialize to 1 instead of 0 to factor out code from _parse_block()\n        # and _parse_props(). They immediately fetch self._tokens[0].\n        self._tokens_i = 1\n\n        return True\n\n    def _line_after_help(self, line):\n        # Tokenizes a line after a help text. This case is special in that the\n        # line has already been fetched (to discover that it isn't part of the\n        # help text).\n        #\n        # An earlier version used a _saved_line variable instead that was\n        # checked in _next_line(). This special-casing gets rid of it and makes\n        # _reuse_tokens alone sufficient to handle unget.\n\n        # Handle line joining\n        while line.endswith(\"\\\\\\n\"):\n            line = line[:-2] + self._readline()\n            self.linenr += 1\n\n        self._tokens = self._tokenize(line)\n        self._reuse_tokens = True\n\n    def _write_if_changed(self, filename, contents):\n        # Writes 'contents' into 'filename', but only if it differs from the\n        # current contents of the file.\n        #\n        # Another variant would be write a temporary file on the same\n        # filesystem, compare the files, and rename() the temporary file if it\n        # differs, but it breaks stuff like write_config(\"/dev/null\"), which is\n        # used out there to force evaluation-related warnings to be generated.\n        # This simple version is pretty failsafe and portable.\n        #\n        # Returns True if the file has changed and is updated, and False\n        # otherwise.\n\n        if self._contents_eq(filename, contents):\n            return False\n        with self._open(filename, \"w\") as f:\n            f.write(contents)\n        return True\n\n    def _contents_eq(self, filename, contents):\n        # Returns True if the contents of 'filename' is 'contents' (a string),\n        # and False otherwise (including if 'filename' can't be opened/read)\n\n        try:\n            with self._open(filename, \"r\") as f:\n                # Robust re. things like encoding and line endings (mmap()\n                # trickery isn't)\n                return f.read(len(contents) + 1) == contents\n        except EnvironmentError:\n            # If the error here would prevent writing the file as well, we'll\n            # notice it later\n            return False\n\n    #\n    # Tokenization\n    #\n\n    def _lookup_sym(self, name):\n        # Fetches the symbol 'name' from the symbol table, creating and\n        # registering it if it does not exist. If '_parsing_kconfigs' is False,\n        # it means we're in eval_string(), and new symbols won't be registered.\n\n        if name in self.syms:\n            return self.syms[name]\n\n        sym = Symbol()\n        sym.kconfig = self\n        sym.name = name\n        sym.is_constant = False\n        sym.rev_dep = sym.weak_rev_dep = sym.direct_dep = self.n\n\n        if self._parsing_kconfigs:\n            self.syms[name] = sym\n        else:\n            self._warn(\"no symbol {} in configuration\".format(name))\n\n        return sym\n\n    def _lookup_const_sym(self, name):\n        # Like _lookup_sym(), for constant (quoted) symbols\n\n        if name in self.const_syms:\n            return self.const_syms[name]\n\n        sym = Symbol()\n        sym.kconfig = self\n        sym.name = name\n        sym.is_constant = True\n        sym.rev_dep = sym.weak_rev_dep = sym.direct_dep = self.n\n\n        if self._parsing_kconfigs:\n            self.const_syms[name] = sym\n\n        return sym\n\n    def _tokenize(self, s):\n        # Parses 's', returning a None-terminated list of tokens. Registers any\n        # new symbols encountered with _lookup(_const)_sym().\n        #\n        # Tries to be reasonably speedy by processing chunks of text via\n        # regexes and string operations where possible. This is the biggest\n        # hotspot during parsing.\n        #\n        # It might be possible to rewrite this to 'yield' tokens instead,\n        # working across multiple lines. Lookback and compatibility with old\n        # janky versions of the C tools complicate things though.\n\n        self._line = s  # Used for error reporting\n\n        # Initial token on the line\n        match = _command_match(s)\n        if not match:\n            if s.isspace() or s.lstrip().startswith(\"#\"):\n                return (None,)\n            self._parse_error(\"unknown token at start of line\")\n\n        # Tricky implementation detail: While parsing a token, 'token' refers\n        # to the previous token. See _STRING_LEX for why this is needed.\n        token = _get_keyword(match.group(1))\n        if not token:\n            # Backwards compatibility with old versions of the C tools, which\n            # (accidentally) accepted stuff like \"--help--\" and \"-help---\".\n            # This was fixed in the C tools by commit c2264564 (\"kconfig: warn\n            # of unhandled characters in Kconfig commands\"), committed in July\n            # 2015, but it seems people still run Kconfiglib on older kernels.\n            if s.strip(\" \\t\\n-\") == \"help\":\n                return (_T_HELP, None)\n\n            # If the first token is not a keyword (and not a weird help token),\n            # we have a preprocessor variable assignment (or a bare macro on a\n            # line)\n            self._parse_assignment(s)\n            return (None,)\n\n        tokens = [token]\n        # The current index in the string being tokenized\n        i = match.end()\n\n        # Main tokenization loop (for tokens past the first one)\n        while i < len(s):\n            # Test for an identifier/keyword first. This is the most common\n            # case.\n            match = _id_keyword_match(s, i)\n            if match:\n                # We have an identifier or keyword\n\n                # Check what it is. lookup_sym() will take care of allocating\n                # new symbols for us the first time we see them. Note that\n                # 'token' still refers to the previous token.\n\n                name = match.group(1)\n                keyword = _get_keyword(name)\n                if keyword:\n                    # It's a keyword\n                    token = keyword\n                    # Jump past it\n                    i = match.end()\n\n                elif token not in _STRING_LEX:\n                    # It's a non-const symbol, except we translate n, m, and y\n                    # into the corresponding constant symbols, like the C\n                    # implementation\n\n                    if \"$\" in name:\n                        # Macro expansion within symbol name\n                        name, s, i = self._expand_name(s, i)\n                    else:\n                        i = match.end()\n\n                    token = self.const_syms[name] if name in STR_TO_TRI else \\\n                        self._lookup_sym(name)\n\n                else:\n                    # It's a case of missing quotes. For example, the\n                    # following is accepted:\n                    #\n                    #   menu unquoted_title\n                    #\n                    #   config A\n                    #       tristate unquoted_prompt\n                    #\n                    #   endmenu\n                    #\n                    # Named choices ('choice FOO') also end up here.\n\n                    if token is not _T_CHOICE:\n                        self._warn(\"style: quotes recommended around '{}' in '{}'\"\n                                   .format(name, self._line.strip()),\n                                   self.filename, self.linenr)\n\n                    token = name\n                    i = match.end()\n\n            else:\n                # Neither a keyword nor a non-const symbol\n\n                # We always strip whitespace after tokens, so it is safe to\n                # assume that s[i] is the start of a token here.\n                c = s[i]\n\n                if c in \"\\\"'\":\n                    if \"$\" not in s and \"\\\\\" not in s:\n                        # Fast path for lines without $ and \\. Find the\n                        # matching quote.\n                        end_i = s.find(c, i + 1) + 1\n                        if not end_i:\n                            self._parse_error(\"unterminated string\")\n                        val = s[i + 1:end_i - 1]\n                        i = end_i\n                    else:\n                        # Slow path\n                        s, end_i = self._expand_str(s, i)\n\n                        # os.path.expandvars() and the $UNAME_RELEASE replace()\n                        # is a backwards compatibility hack, which should be\n                        # reasonably safe as expandvars() leaves references to\n                        # undefined env. vars. as is.\n                        #\n                        # The preprocessor functionality changed how\n                        # environment variables are referenced, to $(FOO).\n                        val = expandvars(s[i + 1:end_i - 1]\n                                         .replace(\"$UNAME_RELEASE\",\n                                                  _UNAME_RELEASE))\n\n                        i = end_i\n\n                    # This is the only place where we don't survive with a\n                    # single token of lookback: 'option env=\"FOO\"' does not\n                    # refer to a constant symbol named \"FOO\".\n                    token = \\\n                        val if token in _STRING_LEX or tokens[0] is _T_OPTION \\\n                        else self._lookup_const_sym(val)\n\n                elif s.startswith(\"&&\", i):\n                    token = _T_AND\n                    i += 2\n\n                elif s.startswith(\"||\", i):\n                    token = _T_OR\n                    i += 2\n\n                elif c == \"=\":\n                    token = _T_EQUAL\n                    i += 1\n\n                elif s.startswith(\"!=\", i):\n                    token = _T_UNEQUAL\n                    i += 2\n\n                elif c == \"!\":\n                    token = _T_NOT\n                    i += 1\n\n                elif c == \"(\":\n                    token = _T_OPEN_PAREN\n                    i += 1\n\n                elif c == \")\":\n                    token = _T_CLOSE_PAREN\n                    i += 1\n\n                elif c == \"#\":\n                    break\n\n\n                # Very rare\n\n                elif s.startswith(\"<=\", i):\n                    token = _T_LESS_EQUAL\n                    i += 2\n\n                elif c == \"<\":\n                    token = _T_LESS\n                    i += 1\n\n                elif s.startswith(\">=\", i):\n                    token = _T_GREATER_EQUAL\n                    i += 2\n\n                elif c == \">\":\n                    token = _T_GREATER\n                    i += 1\n\n\n                else:\n                    self._parse_error(\"unknown tokens in line\")\n\n\n                # Skip trailing whitespace\n                while i < len(s) and s[i].isspace():\n                    i += 1\n\n\n            # Add the token\n            tokens.append(token)\n\n        # None-terminating the token list makes token fetching simpler/faster\n        tokens.append(None)\n\n        return tokens\n\n    # Helpers for syntax checking and token fetching. See the\n    # 'Intro to expressions' section for what a constant symbol is.\n    #\n    # More of these could be added, but the single-use cases are inlined as an\n    # optimization.\n\n    def _expect_sym(self):\n        token = self._tokens[self._tokens_i]\n        self._tokens_i += 1\n\n        if token.__class__ is not Symbol:\n            self._parse_error(\"expected symbol\")\n\n        return token\n\n    def _expect_nonconst_sym(self):\n        # Used for 'select' and 'imply' only. We know the token indices.\n\n        token = self._tokens[1]\n        self._tokens_i = 2\n\n        if token.__class__ is not Symbol or token.is_constant:\n            self._parse_error(\"expected nonconstant symbol\")\n\n        return token\n\n    def _expect_str_and_eol(self):\n        token = self._tokens[self._tokens_i]\n        self._tokens_i += 1\n\n        if token.__class__ is not str:\n            self._parse_error(\"expected string\")\n\n        if self._tokens[self._tokens_i] is not None:\n            self._trailing_tokens_error()\n\n        return token\n\n    def _expect_expr_and_eol(self):\n        expr = self._parse_expr(True)\n\n        if self._tokens[self._tokens_i] is not None:\n            self._trailing_tokens_error()\n\n        return expr\n\n    def _check_token(self, token):\n        # If the next token is 'token', removes it and returns True\n\n        if self._tokens[self._tokens_i] is token:\n            self._tokens_i += 1\n            return True\n        return False\n\n    #\n    # Preprocessor logic\n    #\n\n    def _parse_assignment(self, s):\n        # Parses a preprocessor variable assignment, registering the variable\n        # if it doesn't already exist. Also takes care of bare macros on lines\n        # (which are allowed, and can be useful for their side effects).\n\n        # Expand any macros in the left-hand side of the assignment (the\n        # variable name)\n        s = s.lstrip()\n        i = 0\n        while 1:\n            i = _assignment_lhs_fragment_match(s, i).end()\n            if s.startswith(\"$(\", i):\n                s, i = self._expand_macro(s, i, ())\n            else:\n                break\n\n        if s.isspace():\n            # We also accept a bare macro on a line (e.g.\n            # $(warning-if,$(foo),ops)), provided it expands to a blank string\n            return\n\n        # Assigned variable\n        name = s[:i]\n\n\n        # Extract assignment operator (=, :=, or +=) and value\n        rhs_match = _assignment_rhs_match(s, i)\n        if not rhs_match:\n            self._parse_error(\"syntax error\")\n\n        op, val = rhs_match.groups()\n\n\n        if name in self.variables:\n            # Already seen variable\n            var = self.variables[name]\n        else:\n            # New variable\n            var = Variable()\n            var.kconfig = self\n            var.name = name\n            var._n_expansions = 0\n            self.variables[name] = var\n\n            # += acts like = on undefined variables (defines a recursive\n            # variable)\n            if op == \"+=\":\n                op = \"=\"\n\n        if op == \"=\":\n            var.is_recursive = True\n            var.value = val\n        elif op == \":=\":\n            var.is_recursive = False\n            var.value = self._expand_whole(val, ())\n        else:  # op == \"+=\"\n            # += does immediate expansion if the variable was last set\n            # with :=\n            var.value += \" \" + (val if var.is_recursive else\n                                self._expand_whole(val, ()))\n\n    def _expand_whole(self, s, args):\n        # Expands preprocessor macros in all of 's'. Used whenever we don't\n        # have to worry about delimiters. See _expand_macro() re. the 'args'\n        # parameter.\n        #\n        # Returns the expanded string.\n\n        i = 0\n        while 1:\n            i = s.find(\"$(\", i)\n            if i == -1:\n                break\n            s, i = self._expand_macro(s, i, args)\n        return s\n\n    def _expand_name(self, s, i):\n        # Expands a symbol name starting at index 'i' in 's'.\n        #\n        # Returns the expanded name, the expanded 's' (including the part\n        # before the name), and the index of the first character in the next\n        # token after the name.\n\n        s, end_i = self._expand_name_iter(s, i)\n        name = s[i:end_i]\n        # isspace() is False for empty strings\n        if not name.strip():\n            # Avoid creating a Kconfig symbol with a blank name. It's almost\n            # guaranteed to be an error.\n            self._parse_error(\"macro expanded to blank string\")\n\n        # Skip trailing whitespace\n        while end_i < len(s) and s[end_i].isspace():\n            end_i += 1\n\n        return name, s, end_i\n\n    def _expand_name_iter(self, s, i):\n        # Expands a symbol name starting at index 'i' in 's'.\n        #\n        # Returns the expanded 's' (including the part before the name) and the\n        # index of the first character after the expanded name in 's'.\n\n        while 1:\n            match = _name_special_search(s, i)\n\n            if match.group() != \"$(\":\n                return (s, match.start())\n            s, i = self._expand_macro(s, match.start(), ())\n\n    def _expand_str(self, s, i):\n        # Expands a quoted string starting at index 'i' in 's'. Handles both\n        # backslash escapes and macro expansion.\n        #\n        # Returns the expanded 's' (including the part before the string) and\n        # the index of the first character after the expanded string in 's'.\n\n        quote = s[i]\n        i += 1  # Skip over initial \"/'\n        while 1:\n            match = _string_special_search(s, i)\n            if not match:\n                self._parse_error(\"unterminated string\")\n\n\n            if match.group() == quote:\n                # Found the end of the string\n                return (s, match.end())\n\n            elif match.group() == \"\\\\\":\n                # Replace '\\x' with 'x'. 'i' ends up pointing to the character\n                # after 'x', which allows macros to be canceled with '\\$(foo)'.\n                i = match.end()\n                s = s[:match.start()] + s[i:]\n\n            elif match.group() == \"$(\":\n                # A macro call within the string\n                s, i = self._expand_macro(s, match.start(), ())\n\n            else:\n                # A ' quote within \" quotes or vice versa\n                i += 1\n\n    def _expand_macro(self, s, i, args):\n        # Expands a macro starting at index 'i' in 's'. If this macro resulted\n        # from the expansion of another macro, 'args' holds the arguments\n        # passed to that macro.\n        #\n        # Returns the expanded 's' (including the part before the macro) and\n        # the index of the first character after the expanded macro in 's'.\n\n        res = s[:i]\n        i += 2  # Skip over \"$(\"\n\n        arg_start = i  # Start of current macro argument\n        new_args = []  # Arguments of this macro call\n        nesting = 0  # Current parentheses nesting level\n\n        while 1:\n            match = _macro_special_search(s, i)\n            if not match:\n                self._parse_error(\"missing end parenthesis in macro expansion\")\n\n\n            if match.group() == \"(\":\n                nesting += 1\n                i = match.end()\n\n            elif match.group() == \")\":\n                if nesting:\n                    nesting -= 1\n                    i = match.end()\n                    continue\n\n                # Found the end of the macro\n\n                new_args.append(s[arg_start:match.start()])\n\n                # $(1) is replaced by the first argument to the function, etc.,\n                # provided at least that many arguments were passed\n\n                try:\n                    # Does the macro look like an integer, with a corresponding\n                    # argument? If so, expand it to the value of the argument.\n                    res += args[int(new_args[0])]\n                except (ValueError, IndexError):\n                    # Regular variables are just functions without arguments,\n                    # and also go through the function value path\n                    res += self._fn_val(new_args)\n\n                return (res + s[match.end():], len(res))\n\n            elif match.group() == \",\":\n                i = match.end()\n                if nesting:\n                    continue\n\n                # Found the end of a macro argument\n                new_args.append(s[arg_start:match.start()])\n                arg_start = i\n\n            else:  # match.group() == \"$(\"\n                # A nested macro call within the macro\n                s, i = self._expand_macro(s, match.start(), args)\n\n    def _fn_val(self, args):\n        # Returns the result of calling the function args[0] with the arguments\n        # args[1..len(args)-1]. Plain variables are treated as functions\n        # without arguments.\n\n        fn = args[0]\n\n        if fn in self.variables:\n            var = self.variables[fn]\n\n            if len(args) == 1:\n                # Plain variable\n                if var._n_expansions:\n                    self._parse_error(\"Preprocessor variable {} recursively \"\n                                      \"references itself\".format(var.name))\n            elif var._n_expansions > 100:\n                # Allow functions to call themselves, but guess that functions\n                # that are overly recursive are stuck\n                self._parse_error(\"Preprocessor function {} seems stuck \"\n                                  \"in infinite recursion\".format(var.name))\n\n            var._n_expansions += 1\n            res = self._expand_whole(self.variables[fn].value, args)\n            var._n_expansions -= 1\n            return res\n\n        if fn in self._functions:\n            # Built-in or user-defined function\n\n            py_fn, min_arg, max_arg = self._functions[fn]\n\n            if len(args) - 1 < min_arg or \\\n               (max_arg is not None and len(args) - 1 > max_arg):\n\n                if min_arg == max_arg:\n                    expected_args = min_arg\n                elif max_arg is None:\n                    expected_args = \"{} or more\".format(min_arg)\n                else:\n                    expected_args = \"{}-{}\".format(min_arg, max_arg)\n\n                raise KconfigError(\"{}:{}: bad number of arguments in call \"\n                                   \"to {}, expected {}, got {}\"\n                                   .format(self.filename, self.linenr, fn,\n                                           expected_args, len(args) - 1))\n\n            return py_fn(self, *args)\n\n        # Environment variables are tried last\n        if fn in os.environ:\n            self.env_vars.add(fn)\n            return os.environ[fn]\n\n        return \"\"\n\n    #\n    # Parsing\n    #\n\n    def _make_and(self, e1, e2):\n        # Constructs an AND (&&) expression. Performs trivial simplification.\n\n        if e1 is self.y:\n            return e2\n\n        if e2 is self.y:\n            return e1\n\n        if e1 is self.n or e2 is self.n:\n            return self.n\n\n        return (AND, e1, e2)\n\n    def _make_or(self, e1, e2):\n        # Constructs an OR (||) expression. Performs trivial simplification.\n\n        if e1 is self.n:\n            return e2\n\n        if e2 is self.n:\n            return e1\n\n        if e1 is self.y or e2 is self.y:\n            return self.y\n\n        return (OR, e1, e2)\n\n    def _parse_block(self, end_token, parent, prev):\n        # Parses a block, which is the contents of either a file or an if,\n        # menu, or choice statement.\n        #\n        # end_token:\n        #   The token that ends the block, e.g. _T_ENDIF (\"endif\") for ifs.\n        #   None for files.\n        #\n        # parent:\n        #   The parent menu node, corresponding to a menu, Choice, or 'if'.\n        #   'if's are flattened after parsing.\n        #\n        # prev:\n        #   The previous menu node. New nodes will be added after this one (by\n        #   modifying 'next' pointers).\n        #\n        #   'prev' is reused to parse a list of child menu nodes (for a menu or\n        #   Choice): After parsing the children, the 'next' pointer is assigned\n        #   to the 'list' pointer to \"tilt up\" the children above the node.\n        #\n        # Returns the final menu node in the block (or 'prev' if the block is\n        # empty). This allows chaining.\n\n        while self._next_line():\n            t0 = self._tokens[0]\n\n            if t0 is _T_CONFIG or t0 is _T_MENUCONFIG:\n                # The tokenizer allocates Symbol objects for us\n                sym = self._tokens[1]\n\n                if sym.__class__ is not Symbol or sym.is_constant:\n                    self._parse_error(\"missing or bad symbol name\")\n\n                if self._tokens[2] is not None:\n                    self._trailing_tokens_error()\n\n                self.defined_syms.append(sym)\n\n                node = MenuNode()\n                node.kconfig = self\n                node.item = sym\n                node.is_menuconfig = (t0 is _T_MENUCONFIG)\n                node.prompt = node.help = node.list = None\n                node.parent = parent\n                node.filename = self.filename\n                node.linenr = self.linenr\n                node.include_path = self._include_path\n\n                sym.nodes.append(node)\n\n                self._parse_props(node)\n\n                if node.is_menuconfig and not node.prompt:\n                    self._warn(\"the menuconfig symbol {} has no prompt\"\n                               .format(sym.name_and_loc))\n\n                # Equivalent to\n                #\n                #   prev.next = node\n                #   prev = node\n                #\n                # due to tricky Python semantics. The order matters.\n                prev.next = prev = node\n\n            elif t0 is None:\n                # Blank line\n                continue\n\n            elif t0 in _SOURCE_TOKENS:\n                pattern = self._expect_str_and_eol()\n\n                if t0 in _REL_SOURCE_TOKENS:\n                    # Relative source\n                    pattern = join(dirname(self.filename), pattern)\n\n                # - glob() doesn't support globbing relative to a directory, so\n                #   we need to prepend $srctree to 'pattern'. Use join()\n                #   instead of '+' so that an absolute path in 'pattern' is\n                #   preserved.\n                #\n                # - Sort the glob results to ensure a consistent ordering of\n                #   Kconfig symbols, which indirectly ensures a consistent\n                #   ordering in e.g. .config files\n                filenames = sorted(iglob(join(self._srctree_prefix, pattern)))\n\n                if not filenames and t0 in _OBL_SOURCE_TOKENS:\n                    raise KconfigError(\n                        \"{}:{}: '{}' not found (in '{}'). Check that \"\n                        \"environment variables are set correctly (e.g. \"\n                        \"$srctree, which is {}). Also note that unset \"\n                        \"environment variables expand to the empty string.\"\n                        .format(self.filename, self.linenr, pattern,\n                                self._line.strip(),\n                                \"set to '{}'\".format(self.srctree)\n                                    if self.srctree else \"unset or blank\"))\n\n                for filename in filenames:\n                    self._enter_file(filename)\n                    prev = self._parse_block(None, parent, prev)\n                    self._leave_file()\n\n            elif t0 is end_token:\n                # Reached the end of the block. Terminate the final node and\n                # return it.\n\n                if self._tokens[1] is not None:\n                    self._trailing_tokens_error()\n\n                prev.next = None\n                return prev\n\n            elif t0 is _T_IF:\n                node = MenuNode()\n                node.item = node.prompt = None\n                node.parent = parent\n                node.dep = self._expect_expr_and_eol()\n\n                self._parse_block(_T_ENDIF, node, node)\n                node.list = node.next\n\n                prev.next = prev = node\n\n            elif t0 is _T_MENU:\n                node = MenuNode()\n                node.kconfig = self\n                node.item = t0  # _T_MENU == MENU\n                node.is_menuconfig = True\n                node.prompt = (self._expect_str_and_eol(), self.y)\n                node.visibility = self.y\n                node.parent = parent\n                node.filename = self.filename\n                node.linenr = self.linenr\n                node.include_path = self._include_path\n\n                self.menus.append(node)\n\n                self._parse_props(node)\n                self._parse_block(_T_ENDMENU, node, node)\n                node.list = node.next\n\n                prev.next = prev = node\n\n            elif t0 is _T_COMMENT:\n                node = MenuNode()\n                node.kconfig = self\n                node.item = t0  # _T_COMMENT == COMMENT\n                node.is_menuconfig = False\n                node.prompt = (self._expect_str_and_eol(), self.y)\n                node.list = None\n                node.parent = parent\n                node.filename = self.filename\n                node.linenr = self.linenr\n                node.include_path = self._include_path\n\n                self.comments.append(node)\n\n                self._parse_props(node)\n\n                prev.next = prev = node\n\n            elif t0 is _T_CHOICE:\n                if self._tokens[1] is None:\n                    choice = Choice()\n                    choice.direct_dep = self.n\n                else:\n                    # Named choice\n                    name = self._expect_str_and_eol()\n                    choice = self.named_choices.get(name)\n                    if not choice:\n                        choice = Choice()\n                        choice.name = name\n                        choice.direct_dep = self.n\n                        self.named_choices[name] = choice\n\n                self.choices.append(choice)\n\n                node = MenuNode()\n                node.kconfig = choice.kconfig = self\n                node.item = choice\n                node.is_menuconfig = True\n                node.prompt = node.help = None\n                node.parent = parent\n                node.filename = self.filename\n                node.linenr = self.linenr\n                node.include_path = self._include_path\n\n                choice.nodes.append(node)\n\n                self._parse_props(node)\n                self._parse_block(_T_ENDCHOICE, node, node)\n                node.list = node.next\n\n                prev.next = prev = node\n\n            elif t0 is _T_MAINMENU:\n                self.top_node.prompt = (self._expect_str_and_eol(), self.y)\n\n            else:\n                # A valid endchoice/endif/endmenu is caught by the 'end_token'\n                # check above\n                self._parse_error(\n                    \"no corresponding 'choice'\" if t0 is _T_ENDCHOICE else\n                    \"no corresponding 'if'\"     if t0 is _T_ENDIF else\n                    \"no corresponding 'menu'\"   if t0 is _T_ENDMENU else\n                    \"unrecognized construct\")\n\n        # End of file reached. Return the last node.\n\n        if end_token:\n            raise KconfigError(\n                \"error: expected '{}' at end of '{}'\"\n                .format(\"endchoice\" if end_token is _T_ENDCHOICE else\n                        \"endif\"     if end_token is _T_ENDIF else\n                        \"endmenu\",\n                        self.filename))\n\n        return prev\n\n    def _parse_cond(self):\n        # Parses an optional 'if <expr>' construct and returns the parsed\n        # <expr>, or self.y if the next token is not _T_IF\n\n        expr = self._parse_expr(True) if self._check_token(_T_IF) else self.y\n\n        if self._tokens[self._tokens_i] is not None:\n            self._trailing_tokens_error()\n\n        return expr\n\n    def _parse_props(self, node):\n        # Parses and adds properties to the MenuNode 'node' (type, 'prompt',\n        # 'default's, etc.) Properties are later copied up to symbols and\n        # choices in a separate pass after parsing, in e.g.\n        # _add_props_to_sym().\n        #\n        # An older version of this code added properties directly to symbols\n        # and choices instead of to their menu nodes (and handled dependency\n        # propagation simultaneously), but that loses information on where a\n        # property is added when a symbol or choice is defined in multiple\n        # locations. Some Kconfig configuration systems rely heavily on such\n        # symbols, and better docs can be generated by keeping track of where\n        # properties are added.\n        #\n        # node:\n        #   The menu node we're parsing properties on\n\n        # Dependencies from 'depends on'. Will get propagated to the properties\n        # below.\n        node.dep = self.y\n\n        while self._next_line():\n            t0 = self._tokens[0]\n\n            if t0 in _TYPE_TOKENS:\n                # Relies on '_T_BOOL is BOOL', etc., to save a conversion\n                self._set_type(node.item, t0)\n                if self._tokens[1] is not None:\n                    self._parse_prompt(node)\n\n            elif t0 is _T_DEPENDS:\n                if not self._check_token(_T_ON):\n                    self._parse_error(\"expected 'on' after 'depends'\")\n\n                node.dep = self._make_and(node.dep,\n                                          self._expect_expr_and_eol())\n\n            elif t0 is _T_HELP:\n                self._parse_help(node)\n\n            elif t0 is _T_SELECT:\n                if node.item.__class__ is not Symbol:\n                    self._parse_error(\"only symbols can select\")\n\n                node.selects.append((self._expect_nonconst_sym(),\n                                     self._parse_cond()))\n\n            elif t0 is None:\n                # Blank line\n                continue\n\n            elif t0 is _T_DEFAULT:\n                node.defaults.append((self._parse_expr(False),\n                                      self._parse_cond()))\n\n            elif t0 in _DEF_TOKEN_TO_TYPE:\n                self._set_type(node.item, _DEF_TOKEN_TO_TYPE[t0])\n                node.defaults.append((self._parse_expr(False),\n                                      self._parse_cond()))\n\n            elif t0 is _T_PROMPT:\n                self._parse_prompt(node)\n\n            elif t0 is _T_RANGE:\n                node.ranges.append((self._expect_sym(), self._expect_sym(),\n                                    self._parse_cond()))\n\n            elif t0 is _T_IMPLY:\n                if node.item.__class__ is not Symbol:\n                    self._parse_error(\"only symbols can imply\")\n\n                node.implies.append((self._expect_nonconst_sym(),\n                                     self._parse_cond()))\n\n            elif t0 is _T_VISIBLE:\n                if not self._check_token(_T_IF):\n                    self._parse_error(\"expected 'if' after 'visible'\")\n\n                node.visibility = self._make_and(node.visibility,\n                                                 self._expect_expr_and_eol())\n\n            elif t0 is _T_OPTION:\n                if self._check_token(_T_ENV):\n                    if not self._check_token(_T_EQUAL):\n                        self._parse_error(\"expected '=' after 'env'\")\n\n                    env_var = self._expect_str_and_eol()\n                    node.item.env_var = env_var\n\n                    if env_var in os.environ:\n                        node.defaults.append(\n                            (self._lookup_const_sym(os.environ[env_var]),\n                             self.y))\n                    else:\n                        self._warn(\"{1} has 'option env=\\\"{0}\\\"', \"\n                                   \"but the environment variable {0} is not \"\n                                   \"set\".format(node.item.name, env_var),\n                                   self.filename, self.linenr)\n\n                    if env_var != node.item.name:\n                        self._warn(\"Kconfiglib expands environment variables \"\n                                   \"in strings directly, meaning you do not \"\n                                   \"need 'option env=...' \\\"bounce\\\" symbols. \"\n                                   \"For compatibility with the C tools, \"\n                                   \"rename {} to {} (so that the symbol name \"\n                                   \"matches the environment variable name).\"\n                                   .format(node.item.name, env_var),\n                                   self.filename, self.linenr)\n\n                elif self._check_token(_T_DEFCONFIG_LIST):\n                    if not self.defconfig_list:\n                        self.defconfig_list = node.item\n                    else:\n                        self._warn(\"'option defconfig_list' set on multiple \"\n                                   \"symbols ({0} and {1}). Only {0} will be \"\n                                   \"used.\".format(self.defconfig_list.name,\n                                                  node.item.name),\n                                   self.filename, self.linenr)\n\n                elif self._check_token(_T_MODULES):\n                    # To reduce warning spam, only warn if 'option modules' is\n                    # set on some symbol that isn't MODULES, which should be\n                    # safe. I haven't run into any projects that make use\n                    # modules besides the kernel yet, and there it's likely to\n                    # keep being called \"MODULES\".\n                    if node.item is not self.modules:\n                        self._warn(\"the 'modules' option is not supported. \"\n                                   \"Let me know if this is a problem for you, \"\n                                   \"as it wouldn't be that hard to implement. \"\n                                   \"Note that modules are supported -- \"\n                                   \"Kconfiglib just assumes the symbol name \"\n                                   \"MODULES, like older versions of the C \"\n                                   \"implementation did when 'option modules' \"\n                                   \"wasn't used.\",\n                                   self.filename, self.linenr)\n\n                elif self._check_token(_T_ALLNOCONFIG_Y):\n                    if node.item.__class__ is not Symbol:\n                        self._parse_error(\"the 'allnoconfig_y' option is only \"\n                                          \"valid for symbols\")\n\n                    node.item.is_allnoconfig_y = True\n\n                else:\n                    self._parse_error(\"unrecognized option\")\n\n            elif t0 is _T_OPTIONAL:\n                if node.item.__class__ is not Choice:\n                    self._parse_error('\"optional\" is only valid for choices')\n\n                node.item.is_optional = True\n\n            else:\n                # Reuse the tokens for the non-property line later\n                self._reuse_tokens = True\n                return\n\n    def _set_type(self, sc, new_type):\n        # Sets the type of 'sc' (symbol or choice) to 'new_type'\n\n        # UNKNOWN is falsy\n        if sc.orig_type and sc.orig_type is not new_type:\n            self._warn(\"{} defined with multiple types, {} will be used\"\n                       .format(sc.name_and_loc, TYPE_TO_STR[new_type]))\n\n        sc.orig_type = new_type\n\n    def _parse_prompt(self, node):\n        # 'prompt' properties override each other within a single definition of\n        # a symbol, but additional prompts can be added by defining the symbol\n        # multiple times\n\n        if node.prompt:\n            self._warn(node.item.name_and_loc +\n                       \" defined with multiple prompts in single location\")\n\n        prompt = self._tokens[1]\n        self._tokens_i = 2\n\n        if prompt.__class__ is not str:\n            self._parse_error(\"expected prompt string\")\n\n        if prompt != prompt.strip():\n            self._warn(node.item.name_and_loc +\n                       \" has leading or trailing whitespace in its prompt\")\n\n            # This avoid issues for e.g. reStructuredText documentation, where\n            # '*prompt *' is invalid\n            prompt = prompt.strip()\n\n        node.prompt = (prompt, self._parse_cond())\n\n    def _parse_help(self, node):\n        if node.help is not None:\n            self._warn(node.item.name_and_loc + \" defined with more than \"\n                       \"one help text -- only the last one will be used\")\n\n        # Micro-optimization. This code is pretty hot.\n        readline = self._readline\n\n        # Find first non-blank (not all-space) line and get its\n        # indentation\n\n        while 1:\n            line = readline()\n            self.linenr += 1\n            if not line:\n                self._empty_help(node, line)\n                return\n            if not line.isspace():\n                break\n\n        len_ = len  # Micro-optimization\n\n        # Use a separate 'expline' variable here and below to avoid stomping on\n        # any tabs people might've put deliberately into the first line after\n        # the help text\n        expline = line.expandtabs()\n        indent = len_(expline) - len_(expline.lstrip())\n        if not indent:\n            self._empty_help(node, line)\n            return\n\n        # The help text goes on till the first non-blank line with less indent\n        # than the first line\n\n        # Add the first line\n        lines = [expline[indent:]]\n        add_line = lines.append  # Micro-optimization\n\n        while 1:\n            line = readline()\n            if line.isspace():\n                # No need to preserve the exact whitespace in these\n                add_line(\"\\n\")\n            elif not line:\n                # End of file\n                break\n            else:\n                expline = line.expandtabs()\n                if len_(expline) - len_(expline.lstrip()) < indent:\n                    break\n                add_line(expline[indent:])\n\n        self.linenr += len_(lines)\n        node.help = \"\".join(lines).rstrip()\n        if line:\n            self._line_after_help(line)\n\n    def _empty_help(self, node, line):\n        self._warn(node.item.name_and_loc +\n                   \" has 'help' but empty help text\")\n        node.help = \"\"\n        if line:\n            self._line_after_help(line)\n\n    def _parse_expr(self, transform_m):\n        # Parses an expression from the tokens in Kconfig._tokens using a\n        # simple top-down approach. See the module docstring for the expression\n        # format.\n        #\n        # transform_m:\n        #   True if m should be rewritten to m && MODULES. See the\n        #   Kconfig.eval_string() documentation.\n\n        # Grammar:\n        #\n        #   expr:     and_expr ['||' expr]\n        #   and_expr: factor ['&&' and_expr]\n        #   factor:   <symbol> ['='/'!='/'<'/... <symbol>]\n        #             '!' factor\n        #             '(' expr ')'\n        #\n        # It helps to think of the 'expr: and_expr' case as a single-operand OR\n        # (no ||), and of the 'and_expr: factor' case as a single-operand AND\n        # (no &&). Parsing code is always a bit tricky.\n\n        # Mind dump: parse_factor() and two nested loops for OR and AND would\n        # work as well. The straightforward implementation there gives a\n        # (op, (op, (op, A, B), C), D) parse for A op B op C op D. Representing\n        # expressions as (op, [list of operands]) instead goes nicely with that\n        # version, but is wasteful for short expressions and complicates\n        # expression evaluation and other code that works on expressions (more\n        # complicated code likely offsets any performance gain from less\n        # recursion too). If we also try to optimize the list representation by\n        # merging lists when possible (e.g. when ANDing two AND expressions),\n        # we end up allocating a ton of lists instead of reusing expressions,\n        # which is bad.\n\n        and_expr = self._parse_and_expr(transform_m)\n\n        # Return 'and_expr' directly if we have a \"single-operand\" OR.\n        # Otherwise, parse the expression on the right and make an OR node.\n        # This turns A || B || C || D into (OR, A, (OR, B, (OR, C, D))).\n        return and_expr if not self._check_token(_T_OR) else \\\n            (OR, and_expr, self._parse_expr(transform_m))\n\n    def _parse_and_expr(self, transform_m):\n        factor = self._parse_factor(transform_m)\n\n        # Return 'factor' directly if we have a \"single-operand\" AND.\n        # Otherwise, parse the right operand and make an AND node. This turns\n        # A && B && C && D into (AND, A, (AND, B, (AND, C, D))).\n        return factor if not self._check_token(_T_AND) else \\\n            (AND, factor, self._parse_and_expr(transform_m))\n\n    def _parse_factor(self, transform_m):\n        token = self._tokens[self._tokens_i]\n        self._tokens_i += 1\n\n        if token.__class__ is Symbol:\n            # Plain symbol or relation\n\n            if self._tokens[self._tokens_i] not in _RELATIONS:\n                # Plain symbol\n\n                # For conditional expressions ('depends on <expr>',\n                # '... if <expr>', etc.), m is rewritten to m && MODULES.\n                if transform_m and token is self.m:\n                    return (AND, self.m, self.modules)\n\n                return token\n\n            # Relation\n            #\n            # _T_EQUAL, _T_UNEQUAL, etc., deliberately have the same values as\n            # EQUAL, UNEQUAL, etc., so we can just use the token directly\n            self._tokens_i += 1\n            return (self._tokens[self._tokens_i - 1], token,\n                    self._expect_sym())\n\n        if token is _T_NOT:\n            # token == _T_NOT == NOT\n            return (token, self._parse_factor(transform_m))\n\n        if token is _T_OPEN_PAREN:\n            expr_parse = self._parse_expr(transform_m)\n            if self._check_token(_T_CLOSE_PAREN):\n                return expr_parse\n\n        self._parse_error(\"malformed expression\")\n\n    #\n    # Caching and invalidation\n    #\n\n    def _build_dep(self):\n        # Populates the Symbol/Choice._dependents sets, which contain all other\n        # items (symbols and choices) that immediately depend on the item in\n        # the sense that changing the value of the item might affect the value\n        # of the dependent items. This is used for caching/invalidation.\n        #\n        # The calculated sets might be larger than necessary as we don't do any\n        # complex analysis of the expressions.\n\n        depend_on = _depend_on  # Micro-optimization\n\n        # Only calculate _dependents for defined symbols. Constant and\n        # undefined symbols could theoretically be selected/implied, but it\n        # wouldn't change their value, so it's not a true dependency.\n        for sym in self.unique_defined_syms:\n            # Symbols depend on the following:\n\n            # The prompt conditions\n            for node in sym.nodes:\n                if node.prompt:\n                    depend_on(sym, node.prompt[1])\n\n            # The default values and their conditions\n            for value, cond in sym.defaults:\n                depend_on(sym, value)\n                depend_on(sym, cond)\n\n            # The reverse and weak reverse dependencies\n            depend_on(sym, sym.rev_dep)\n            depend_on(sym, sym.weak_rev_dep)\n\n            # The ranges along with their conditions\n            for low, high, cond in sym.ranges:\n                depend_on(sym, low)\n                depend_on(sym, high)\n                depend_on(sym, cond)\n\n            # The direct dependencies. This is usually redundant, as the direct\n            # dependencies get propagated to properties, but it's needed to get\n            # invalidation solid for 'imply', which only checks the direct\n            # dependencies (even if there are no properties to propagate it\n            # to).\n            depend_on(sym, sym.direct_dep)\n\n            # In addition to the above, choice symbols depend on the choice\n            # they're in, but that's handled automatically since the Choice is\n            # propagated to the conditions of the properties before\n            # _build_dep() runs.\n\n        for choice in self.unique_choices:\n            # Choices depend on the following:\n\n            # The prompt conditions\n            for node in choice.nodes:\n                if node.prompt:\n                    depend_on(choice, node.prompt[1])\n\n            # The default symbol conditions\n            for _, cond in choice.defaults:\n                depend_on(choice, cond)\n\n    def _add_choice_deps(self):\n        # Choices also depend on the choice symbols themselves, because the\n        # y-mode selection of the choice might change if a choice symbol's\n        # visibility changes.\n        #\n        # We add these dependencies separately after dependency loop detection.\n        # The invalidation algorithm can handle the resulting\n        # <choice symbol> <-> <choice> dependency loops, but they make loop\n        # detection awkward.\n\n        for choice in self.unique_choices:\n            for sym in choice.syms:\n                sym._dependents.add(choice)\n\n    def _invalidate_all(self):\n        # Undefined symbols never change value and don't need to be\n        # invalidated, so we can just iterate over defined symbols.\n        # Invalidating constant symbols would break things horribly.\n        for sym in self.unique_defined_syms:\n            sym._invalidate()\n\n        for choice in self.unique_choices:\n            choice._invalidate()\n\n    #\n    # Post-parsing menu tree processing, including dependency propagation and\n    # implicit submenu creation\n    #\n\n    def _finalize_node(self, node, visible_if):\n        # Finalizes a menu node and its children:\n        #\n        #  - Copies properties from menu nodes up to their contained\n        #    symbols/choices\n        #\n        #  - Propagates dependencies from parent to child nodes\n        #\n        #  - Creates implicit menus (see kconfig-language.txt)\n        #\n        #  - Removes 'if' nodes\n        #\n        #  - Sets 'choice' types and registers choice symbols\n        #\n        # menu_finalize() in the C implementation is similar.\n        #\n        # node:\n        #   The menu node to finalize. This node and its children will have\n        #   been finalized when the function returns, and any implicit menus\n        #   will have been created.\n        #\n        # visible_if:\n        #   Dependencies from 'visible if' on parent menus. These are added to\n        #   the prompts of symbols and choices.\n\n        if node.item.__class__ is Symbol:\n            # Copy defaults, ranges, selects, and implies to the Symbol\n            self._add_props_to_sym(node)\n\n            # Find any items that should go in an implicit menu rooted at the\n            # symbol\n            cur = node\n            while cur.next and _auto_menu_dep(node, cur.next):\n                # This makes implicit submenu creation work recursively, with\n                # implicit menus inside implicit menus\n                self._finalize_node(cur.next, visible_if)\n                cur = cur.next\n                cur.parent = node\n\n            if cur is not node:\n                # Found symbols that should go in an implicit submenu. Tilt\n                # them up above us.\n                node.list = node.next\n                node.next = cur.next\n                cur.next = None\n\n        elif node.list:\n            # The menu node is a choice, menu, or if. Finalize each child node.\n\n            if node.item is MENU:\n                visible_if = self._make_and(visible_if, node.visibility)\n\n            # Propagate the menu node's dependencies to each child menu node.\n            #\n            # This needs to go before the recursive _finalize_node() call so\n            # that implicit submenu creation can look ahead at dependencies.\n            self._propagate_deps(node, visible_if)\n\n            # Finalize the children\n            cur = node.list\n            while cur:\n                self._finalize_node(cur, visible_if)\n                cur = cur.next\n\n        if node.list:\n            # node's children have been individually finalized. Do final steps\n            # to finalize this \"level\" in the menu tree.\n            _flatten(node.list)\n            _remove_ifs(node)\n\n        # Empty choices (node.list None) are possible, so this needs to go\n        # outside\n        if node.item.__class__ is Choice:\n            # Add the node's non-node-specific properties to the choice, like\n            # _add_props_to_sym() does\n            choice = node.item\n            choice.direct_dep = self._make_or(choice.direct_dep, node.dep)\n            choice.defaults += node.defaults\n\n            _finalize_choice(node)\n\n    def _propagate_deps(self, node, visible_if):\n        # Propagates 'node's dependencies to its child menu nodes\n\n        # If the parent node holds a Choice, we use the Choice itself as the\n        # parent dependency. This makes sense as the value (mode) of the choice\n        # limits the visibility of the contained choice symbols. The C\n        # implementation works the same way.\n        #\n        # Due to the similar interface, Choice works as a drop-in replacement\n        # for Symbol here.\n        basedep = node.item if node.item.__class__ is Choice else node.dep\n\n        cur = node.list\n        while cur:\n            dep = cur.dep = self._make_and(cur.dep, basedep)\n\n            if cur.item.__class__ in _SYMBOL_CHOICE:\n                # Propagate 'visible if' and dependencies to the prompt\n                if cur.prompt:\n                    cur.prompt = (cur.prompt[0],\n                                  self._make_and(\n                                      cur.prompt[1],\n                                      self._make_and(visible_if, dep)))\n\n                # Propagate dependencies to defaults\n                if cur.defaults:\n                    cur.defaults = [(default, self._make_and(cond, dep))\n                                    for default, cond in cur.defaults]\n\n                # Propagate dependencies to ranges\n                if cur.ranges:\n                    cur.ranges = [(low, high, self._make_and(cond, dep))\n                                  for low, high, cond in cur.ranges]\n\n                # Propagate dependencies to selects\n                if cur.selects:\n                    cur.selects = [(target, self._make_and(cond, dep))\n                                   for target, cond in cur.selects]\n\n                # Propagate dependencies to implies\n                if cur.implies:\n                    cur.implies = [(target, self._make_and(cond, dep))\n                                   for target, cond in cur.implies]\n\n            elif cur.prompt:  # Not a symbol/choice\n                # Propagate dependencies to the prompt. 'visible if' is only\n                # propagated to symbols/choices.\n                cur.prompt = (cur.prompt[0],\n                              self._make_and(cur.prompt[1], dep))\n\n            cur = cur.next\n\n    def _add_props_to_sym(self, node):\n        # Copies properties from the menu node 'node' up to its contained\n        # symbol, and adds (weak) reverse dependencies to selected/implied\n        # symbols.\n        #\n        # This can't be rolled into _propagate_deps(), because that function\n        # traverses the menu tree roughly breadth-first, meaning properties on\n        # symbols defined in multiple locations could end up in the wrong\n        # order.\n\n        sym = node.item\n\n        # See the Symbol class docstring\n        sym.direct_dep = self._make_or(sym.direct_dep, node.dep)\n\n        sym.defaults += node.defaults\n        sym.ranges += node.ranges\n        sym.selects += node.selects\n        sym.implies += node.implies\n\n        # Modify the reverse dependencies of the selected symbol\n        for target, cond in node.selects:\n            target.rev_dep = self._make_or(\n                target.rev_dep,\n                self._make_and(sym, cond))\n\n        # Modify the weak reverse dependencies of the implied\n        # symbol\n        for target, cond in node.implies:\n            target.weak_rev_dep = self._make_or(\n                target.weak_rev_dep,\n                self._make_and(sym, cond))\n\n    #\n    # Misc.\n    #\n\n    def _check_sym_sanity(self):\n        # Checks various symbol properties that are handiest to check after\n        # parsing. Only generates errors and warnings.\n\n        def num_ok(sym, type_):\n            # Returns True if the (possibly constant) symbol 'sym' is valid as a value\n            # for a symbol of type type_ (INT or HEX)\n\n            # 'not sym.nodes' implies a constant or undefined symbol, e.g. a plain\n            # \"123\"\n            if not sym.nodes:\n                return _is_base_n(sym.name, _TYPE_TO_BASE[type_])\n\n            return sym.orig_type is type_\n\n        for sym in self.unique_defined_syms:\n            if sym.orig_type in _BOOL_TRISTATE:\n                # A helper function could be factored out here, but keep it\n                # speedy/straightforward\n\n                for target_sym, _ in sym.selects:\n                    if target_sym.orig_type not in _BOOL_TRISTATE_UNKNOWN:\n                        self._warn(\"{} selects the {} symbol {}, which is not \"\n                                   \"bool or tristate\"\n                                   .format(sym.name_and_loc,\n                                           TYPE_TO_STR[target_sym.orig_type],\n                                           target_sym.name_and_loc))\n\n                for target_sym, _ in sym.implies:\n                    if target_sym.orig_type not in _BOOL_TRISTATE_UNKNOWN:\n                        self._warn(\"{} implies the {} symbol {}, which is not \"\n                                   \"bool or tristate\"\n                                   .format(sym.name_and_loc,\n                                           TYPE_TO_STR[target_sym.orig_type],\n                                           target_sym.name_and_loc))\n\n            elif sym.orig_type:  # STRING/INT/HEX\n                for default, _ in sym.defaults:\n                    if default.__class__ is not Symbol:\n                        raise KconfigError(\n                            \"the {} symbol {} has a malformed default {} -- \"\n                            \"expected a single symbol\"\n                            .format(TYPE_TO_STR[sym.orig_type],\n                                    sym.name_and_loc, expr_str(default)))\n\n                    if sym.orig_type is STRING:\n                        if not default.is_constant and not default.nodes and \\\n                           not default.name.isupper():\n                            # 'default foo' on a string symbol could be either a symbol\n                            # reference or someone leaving out the quotes. Guess that\n                            # the quotes were left out if 'foo' isn't all-uppercase\n                            # (and no symbol named 'foo' exists).\n                            self._warn(\"style: quotes recommended around \"\n                                       \"default value for string symbol \"\n                                       + sym.name_and_loc)\n\n                    elif not num_ok(default, sym.orig_type):  # INT/HEX\n                        self._warn(\"the {0} symbol {1} has a non-{0} default {2}\"\n                                   .format(TYPE_TO_STR[sym.orig_type],\n                                           sym.name_and_loc,\n                                           default.name_and_loc))\n\n                if sym.selects or sym.implies:\n                    self._warn(\"the {} symbol {} has selects or implies\"\n                               .format(TYPE_TO_STR[sym.orig_type],\n                                       sym.name_and_loc))\n\n            else:  # UNKNOWN\n                self._warn(\"{} defined without a type\"\n                           .format(sym.name_and_loc))\n\n\n            if sym.ranges:\n                if sym.orig_type not in _INT_HEX:\n                    self._warn(\n                        \"the {} symbol {} has ranges, but is not int or hex\"\n                        .format(TYPE_TO_STR[sym.orig_type],\n                                sym.name_and_loc))\n                else:\n                    for low, high, _ in sym.ranges:\n                        if not num_ok(low, sym.orig_type) or \\\n                           not num_ok(high, sym.orig_type):\n\n                            self._warn(\"the {0} symbol {1} has a non-{0} \"\n                                       \"range [{2}, {3}]\"\n                                       .format(TYPE_TO_STR[sym.orig_type],\n                                               sym.name_and_loc,\n                                               low.name_and_loc,\n                                               high.name_and_loc))\n\n    def _check_choice_sanity(self):\n        # Checks various choice properties that are handiest to check after\n        # parsing. Only generates errors and warnings.\n\n        def warn_select_imply(sym, expr, expr_type):\n            msg = \"the choice symbol {} is {} by the following symbols, but \" \\\n                  \"select/imply has no effect on choice symbols\" \\\n                  .format(sym.name_and_loc, expr_type)\n\n            # si = select/imply\n            for si in split_expr(expr, OR):\n                msg += \"\\n - \" + split_expr(si, AND)[0].name_and_loc\n\n            self._warn(msg)\n\n        for choice in self.unique_choices:\n            if choice.orig_type not in _BOOL_TRISTATE:\n                self._warn(\"{} defined with type {}\"\n                           .format(choice.name_and_loc,\n                                   TYPE_TO_STR[choice.orig_type]))\n\n            for node in choice.nodes:\n                if node.prompt:\n                    break\n            else:\n                self._warn(choice.name_and_loc + \" defined without a prompt\")\n\n            for default, _ in choice.defaults:\n                if default.__class__ is not Symbol:\n                    raise KconfigError(\n                        \"{} has a malformed default {}\"\n                        .format(choice.name_and_loc, expr_str(default)))\n\n                if default.choice is not choice:\n                    self._warn(\"the default selection {} of {} is not \"\n                               \"contained in the choice\"\n                               .format(default.name_and_loc,\n                                       choice.name_and_loc))\n\n            for sym in choice.syms:\n                if sym.defaults:\n                    self._warn(\"default on the choice symbol {} will have \"\n                               \"no effect, as defaults do not affect choice \"\n                               \"symbols\".format(sym.name_and_loc))\n\n                if sym.rev_dep is not sym.kconfig.n:\n                    warn_select_imply(sym, sym.rev_dep, \"selected\")\n\n                if sym.weak_rev_dep is not sym.kconfig.n:\n                    warn_select_imply(sym, sym.weak_rev_dep, \"implied\")\n\n                for node in sym.nodes:\n                    if node.parent.item is choice:\n                        if not node.prompt:\n                            self._warn(\"the choice symbol {} has no prompt\"\n                                       .format(sym.name_and_loc))\n\n                    elif node.prompt:\n                        self._warn(\"the choice symbol {} is defined with a \"\n                                   \"prompt outside the choice\"\n                                   .format(sym.name_and_loc))\n\n    def _parse_error(self, msg):\n        raise KconfigError(\"{}error: couldn't parse '{}': {}\".format(\n            \"\" if self.filename is None else\n                \"{}:{}: \".format(self.filename, self.linenr),\n            self._line.strip(), msg))\n\n    def _trailing_tokens_error(self):\n        self._parse_error(\"extra tokens at end of line\")\n\n    def _open(self, filename, mode):\n        # open() wrapper:\n        #\n        # - Enable universal newlines mode on Python 2 to ease\n        #   interoperability between Linux and Windows. It's already the\n        #   default on Python 3.\n        #\n        #   The \"U\" flag would currently work for both Python 2 and 3, but it's\n        #   deprecated on Python 3, so play it future-safe.\n        #\n        #   io.open() defaults to universal newlines on Python 2 (and is an\n        #   alias for open() on Python 3), but it returns 'unicode' strings and\n        #   slows things down:\n        #\n        #     Parsing x86 Kconfigs on Python 2\n        #\n        #     with open(..., \"rU\"):\n        #\n        #       real  0m0.930s\n        #       user  0m0.905s\n        #       sys   0m0.025s\n        #\n        #     with io.open():\n        #\n        #       real  0m1.069s\n        #       user  0m1.040s\n        #       sys   0m0.029s\n        #\n        #   There's no appreciable performance difference between \"r\" and\n        #   \"rU\" for parsing performance on Python 2.\n        #\n        # - For Python 3, force the encoding. Forcing the encoding on Python 2\n        #   turns strings into Unicode strings, which gets messy. Python 2\n        #   doesn't decode regular strings anyway.\n        return open(filename, \"rU\" if mode == \"r\" else mode) if _IS_PY2 else \\\n               open(filename, mode, encoding=self._encoding)\n\n    def _check_undef_syms(self):\n        # Prints warnings for all references to undefined symbols within the\n        # Kconfig files\n\n        def is_num(s):\n            # Returns True if the string 's' looks like a number.\n            #\n            # Internally, all operands in Kconfig are symbols, only undefined symbols\n            # (which numbers usually are) get their name as their value.\n            #\n            # Only hex numbers that start with 0x/0X are classified as numbers.\n            # Otherwise, symbols whose names happen to contain only the letters A-F\n            # would trigger false positives.\n\n            try:\n                int(s)\n            except ValueError:\n                if not s.startswith((\"0x\", \"0X\")):\n                    return False\n\n                try:\n                    int(s, 16)\n                except ValueError:\n                    return False\n\n            return True\n\n        for sym in (self.syms.viewvalues if _IS_PY2 else self.syms.values)():\n            # - sym.nodes empty means the symbol is undefined (has no\n            #   definition locations)\n            #\n            # - Due to Kconfig internals, numbers show up as undefined Kconfig\n            #   symbols, but shouldn't be flagged\n            #\n            # - The MODULES symbol always exists\n            if not sym.nodes and not is_num(sym.name) and \\\n               sym.name != \"MODULES\":\n\n                msg = \"undefined symbol {}:\".format(sym.name)\n                for node in self.node_iter():\n                    if sym in node.referenced:\n                        msg += \"\\n\\n- Referenced at {}:{}:\\n\\n{}\" \\\n                               .format(node.filename, node.linenr, node)\n                self._warn(msg)\n\n    def _warn(self, msg, filename=None, linenr=None):\n        # For printing general warnings\n\n        if not self.warn:\n            return\n\n        msg = \"warning: \" + msg\n        if filename is not None:\n            msg = \"{}:{}: {}\".format(filename, linenr, msg)\n\n        self.warnings.append(msg)\n        if self.warn_to_stderr:\n            sys.stderr.write(msg + \"\\n\")\n\n\nclass Symbol(object):\n    \"\"\"\n    Represents a configuration symbol:\n\n      (menu)config FOO\n          ...\n\n    The following attributes are available. They should be viewed as read-only,\n    and some are implemented through @property magic (but are still efficient\n    to access due to internal caching).\n\n    Note: Prompts, help texts, and locations are stored in the Symbol's\n    MenuNode(s) rather than in the Symbol itself. Check the MenuNode class and\n    the Symbol.nodes attribute. This organization matches the C tools.\n\n    name:\n      The name of the symbol, e.g. \"FOO\" for 'config FOO'.\n\n    type:\n      The type of the symbol. One of BOOL, TRISTATE, STRING, INT, HEX, UNKNOWN.\n      UNKNOWN is for undefined symbols, (non-special) constant symbols, and\n      symbols defined without a type.\n\n      When running without modules (MODULES having the value n), TRISTATE\n      symbols magically change type to BOOL. This also happens for symbols\n      within choices in \"y\" mode. This matches the C tools, and makes sense for\n      menuconfig-like functionality.\n\n    orig_type:\n      The type as given in the Kconfig file, without any magic applied. Used\n      when printing the symbol.\n\n    tri_value:\n      The tristate value of the symbol as an integer. One of 0, 1, 2,\n      representing n, m, y. Always 0 (n) for non-bool/tristate symbols.\n\n      This is the symbol value that's used outside of relation expressions\n      (A, !A, A && B, A || B).\n\n    str_value:\n      The value of the symbol as a string. Gives the value for string/int/hex\n      symbols. For bool/tristate symbols, gives \"n\", \"m\", or \"y\".\n\n      This is the symbol value that's used in relational expressions\n      (A = B, A != B, etc.)\n\n      Gotcha: For int/hex symbols, the exact format of the value is often\n      preserved (e.g. when writing a .config file), hence why you can't get it\n      directly as an int. Do int(int_sym.str_value) or\n      int(hex_sym.str_value, 16) to get the integer value.\n\n    user_value:\n      The user value of the symbol. None if no user value has been assigned\n      (via Kconfig.load_config() or Symbol.set_value()).\n\n      Holds 0, 1, or 2 for bool/tristate symbols, and a string for the other\n      symbol types.\n\n      WARNING: Do not assign directly to this. It will break things. Use\n      Symbol.set_value().\n\n    assignable:\n      A tuple containing the tristate user values that can currently be\n      assigned to the symbol (that would be respected), ordered from lowest (0,\n      representing n) to highest (2, representing y). This corresponds to the\n      selections available in the menuconfig interface. The set of assignable\n      values is calculated from the symbol's visibility and selects/implies.\n\n      Returns the empty set for non-bool/tristate symbols and for symbols with\n      visibility n. The other possible values are (0, 2), (0, 1, 2), (1, 2),\n      (1,), and (2,). A (1,) or (2,) result means the symbol is visible but\n      \"locked\" to m or y through a select, perhaps in combination with the\n      visibility. menuconfig represents this as -M- and -*-, respectively.\n\n      For string/hex/int symbols, check if Symbol.visibility is non-0 (non-n)\n      instead to determine if the value can be changed.\n\n      Some handy 'assignable' idioms:\n\n        # Is 'sym' an assignable (visible) bool/tristate symbol?\n        if sym.assignable:\n            # What's the highest value it can be assigned? [-1] in Python\n            # gives the last element.\n            sym_high = sym.assignable[-1]\n\n            # The lowest?\n            sym_low = sym.assignable[0]\n\n            # Can the symbol be set to at least m?\n            if sym.assignable[-1] >= 1:\n                ...\n\n        # Can the symbol be set to m?\n        if 1 in sym.assignable:\n            ...\n\n    visibility:\n      The visibility of the symbol. One of 0, 1, 2, representing n, m, y. See\n      the module documentation for an overview of symbol values and visibility.\n\n    config_string:\n      The .config assignment string that would get written out for the symbol\n      by Kconfig.write_config(). Returns the empty string if no .config\n      assignment would get written out.\n\n      In general, visible symbols, symbols with (active) defaults, and selected\n      symbols get written out. This includes all non-n-valued bool/tristate\n      symbols, and all visible string/int/hex symbols.\n\n      Symbols with the (no longer needed) 'option env=...' option generate no\n      configuration output, and neither does the special\n      'option defconfig_list' symbol.\n\n      Tip: This field is useful when generating custom configuration output,\n      even for non-.config-like formats. To write just the symbols that would\n      get written out to .config files, do this:\n\n        if sym.config_string:\n            *Write symbol, e.g. by looking sym.str_value*\n\n      This is a superset of the symbols written out by write_autoconf().\n      That function skips all n-valued symbols.\n\n      There usually won't be any great harm in just writing all symbols either,\n      though you might get some special symbols and possibly some \"redundant\"\n      n-valued symbol entries in there.\n\n    name_and_loc:\n      Holds a string like\n\n        \"MY_SYMBOL (defined at foo/Kconfig:12, bar/Kconfig:14)\"\n\n      , giving the name of the symbol and its definition location(s).\n\n      If the symbol is undefined, the location is given as \"(undefined)\".\n\n    nodes:\n      A list of MenuNodes for this symbol. Will contain a single MenuNode for\n      most symbols. Undefined and constant symbols have an empty nodes list.\n      Symbols defined in multiple locations get one node for each location.\n\n    choice:\n      Holds the parent Choice for choice symbols, and None for non-choice\n      symbols. Doubles as a flag for whether a symbol is a choice symbol.\n\n    defaults:\n      List of (default, cond) tuples for the symbol's 'default' properties. For\n      example, 'default A && B if C || D' is represented as\n      ((AND, A, B), (OR, C, D)). If no condition was given, 'cond' is\n      self.kconfig.y.\n\n      Note that 'depends on' and parent dependencies are propagated to\n      'default' conditions.\n\n    selects:\n      List of (symbol, cond) tuples for the symbol's 'select' properties. For\n      example, 'select A if B && C' is represented as (A, (AND, B, C)). If no\n      condition was given, 'cond' is self.kconfig.y.\n\n      Note that 'depends on' and parent dependencies are propagated to 'select'\n      conditions.\n\n    implies:\n      Like 'selects', for imply.\n\n    ranges:\n      List of (low, high, cond) tuples for the symbol's 'range' properties. For\n      example, 'range 1 2 if A' is represented as (1, 2, A). If there is no\n      condition, 'cond' is self.kconfig.y.\n\n      Note that 'depends on' and parent dependencies are propagated to 'range'\n      conditions.\n\n      Gotcha: 1 and 2 above will be represented as (undefined) Symbols rather\n      than plain integers. Undefined symbols get their name as their string\n      value, so this works out. The C tools work the same way.\n\n    orig_defaults:\n    orig_selects:\n    orig_implies:\n    orig_ranges:\n      See the corresponding attributes on the MenuNode class.\n\n    rev_dep:\n      Reverse dependency expression from other symbols selecting this symbol.\n      Multiple selections get ORed together. A condition on a select is ANDed\n      with the selecting symbol.\n\n      For example, if A has 'select FOO' and B has 'select FOO if C', then\n      FOO's rev_dep will be (OR, A, (AND, B, C)).\n\n    weak_rev_dep:\n      Like rev_dep, for imply.\n\n    direct_dep:\n      The direct ('depends on') dependencies for the symbol, or self.kconfig.y\n      if there are no direct dependencies.\n\n      This attribute includes any dependencies from surrounding menus and ifs.\n      Those get propagated to the direct dependencies, and the resulting direct\n      dependencies in turn get propagated to the conditions of all properties.\n\n      If the symbol is defined in multiple locations, the dependencies from the\n      different locations get ORed together.\n\n    referenced:\n      A set() with all symbols and choices referenced in the properties and\n      property conditions of the symbol.\n\n      Also includes dependencies from surrounding menus and ifs, because those\n      get propagated to the symbol (see the 'Intro to symbol values' section in\n      the module docstring).\n\n      Choices appear in the dependencies of choice symbols.\n\n      For the following definitions, only B and not C appears in A's\n      'referenced'. To get transitive references, you'll have to recursively\n      expand 'references' until no new items appear.\n\n        config A\n                bool\n                depends on B\n\n        config B\n                bool\n                depends on C\n\n        config C\n                bool\n\n      See the Symbol.direct_dep attribute if you're only interested in the\n      direct dependencies of the symbol (its 'depends on'). You can extract the\n      symbols in it with the global expr_items() function.\n\n    env_var:\n      If the Symbol has an 'option env=\"FOO\"' option, this contains the name\n      (\"FOO\") of the environment variable. None for symbols without no\n      'option env'.\n\n      'option env=\"FOO\"' acts like a 'default' property whose value is the\n      value of $FOO.\n\n      Symbols with 'option env' are never written out to .config files, even if\n      they are visible. env_var corresponds to a flag called SYMBOL_AUTO in the\n      C implementation.\n\n    is_allnoconfig_y:\n      True if the symbol has 'option allnoconfig_y' set on it. This has no\n      effect internally (except when printing symbols), but can be checked by\n      scripts.\n\n    is_constant:\n      True if the symbol is a constant (quoted) symbol.\n\n    kconfig:\n      The Kconfig instance this symbol is from.\n    \"\"\"\n    __slots__ = (\n        \"_cached_assignable\",\n        \"_cached_str_val\",\n        \"_cached_tri_val\",\n        \"_cached_vis\",\n        \"_dependents\",\n        \"_old_val\",\n        \"_visited\",\n        \"_was_set\",\n        \"_write_to_conf\",\n        \"choice\",\n        \"defaults\",\n        \"direct_dep\",\n        \"env_var\",\n        \"implies\",\n        \"is_allnoconfig_y\",\n        \"is_constant\",\n        \"kconfig\",\n        \"name\",\n        \"nodes\",\n        \"orig_type\",\n        \"ranges\",\n        \"rev_dep\",\n        \"selects\",\n        \"user_value\",\n        \"weak_rev_dep\",\n    )\n\n    #\n    # Public interface\n    #\n\n    @property\n    def type(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if self.orig_type is TRISTATE and \\\n           (self.choice and self.choice.tri_value == 2 or\n            not self.kconfig.modules.tri_value):\n\n            return BOOL\n\n        return self.orig_type\n\n    @property\n    def str_value(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if self._cached_str_val is not None:\n            return self._cached_str_val\n\n        if self.orig_type in _BOOL_TRISTATE:\n            # Also calculates the visibility, so invalidation safe\n            self._cached_str_val = TRI_TO_STR[self.tri_value]\n            return self._cached_str_val\n\n        # As a quirk of Kconfig, undefined symbols get their name as their\n        # string value. This is why things like \"FOO = bar\" work for seeing if\n        # FOO has the value \"bar\".\n        if not self.orig_type:  # UNKNOWN\n            self._cached_str_val = self.name\n            return self.name\n\n        val = \"\"\n        # Warning: See Symbol._rec_invalidate(), and note that this is a hidden\n        # function call (property magic)\n        vis = self.visibility\n\n        self._write_to_conf = (vis != 0)\n\n        if self.orig_type in _INT_HEX:\n            # The C implementation checks the user value against the range in a\n            # separate code path (post-processing after loading a .config).\n            # Checking all values here instead makes more sense for us. It\n            # requires that we check for a range first.\n\n            base = _TYPE_TO_BASE[self.orig_type]\n\n            # Check if a range is in effect\n            for low_expr, high_expr, cond in self.ranges:\n                if expr_value(cond):\n                    has_active_range = True\n\n                    # The zeros are from the C implementation running strtoll()\n                    # on empty strings\n                    low = int(low_expr.str_value, base) if \\\n                      _is_base_n(low_expr.str_value, base) else 0\n                    high = int(high_expr.str_value, base) if \\\n                      _is_base_n(high_expr.str_value, base) else 0\n\n                    break\n            else:\n                has_active_range = False\n\n            # Defaults are used if the symbol is invisible, lacks a user value,\n            # or has an out-of-range user value\n            use_defaults = True\n\n            if vis and self.user_value:\n                user_val = int(self.user_value, base)\n                if has_active_range and not low <= user_val <= high:\n                    num2str = str if base == 10 else hex\n                    self.kconfig._warn(\n                        \"user value {} on the {} symbol {} ignored due to \"\n                        \"being outside the active range ([{}, {}]) -- falling \"\n                        \"back on defaults\"\n                        .format(num2str(user_val), TYPE_TO_STR[self.orig_type],\n                                self.name_and_loc,\n                                num2str(low), num2str(high)))\n                else:\n                    # If the user value is well-formed and satisfies range\n                    # contraints, it is stored in exactly the same form as\n                    # specified in the assignment (with or without \"0x\", etc.)\n                    val = self.user_value\n                    use_defaults = False\n\n            if use_defaults:\n                # No user value or invalid user value. Look at defaults.\n\n                # Used to implement the warning below\n                has_default = False\n\n                for sym, cond in self.defaults:\n                    if expr_value(cond):\n                        has_default = self._write_to_conf = True\n\n                        val = sym.str_value\n\n                        if _is_base_n(val, base):\n                            val_num = int(val, base)\n                        else:\n                            val_num = 0  # strtoll() on empty string\n\n                        break\n                else:\n                    val_num = 0  # strtoll() on empty string\n\n                # This clamping procedure runs even if there's no default\n                if has_active_range:\n                    clamp = None\n                    if val_num < low:\n                        clamp = low\n                    elif val_num > high:\n                        clamp = high\n\n                    if clamp is not None:\n                        # The value is rewritten to a standard form if it is\n                        # clamped\n                        val = str(clamp) \\\n                              if self.orig_type is INT else \\\n                              hex(clamp)\n\n                        if has_default:\n                            num2str = str if base == 10 else hex\n                            self.kconfig._warn(\n                                \"default value {} on {} clamped to {} due to \"\n                                \"being outside the active range ([{}, {}])\"\n                                .format(val_num, self.name_and_loc,\n                                        num2str(clamp), num2str(low),\n                                        num2str(high)))\n\n        elif self.orig_type is STRING:\n            if vis and self.user_value is not None:\n                # If the symbol is visible and has a user value, use that\n                val = self.user_value\n            else:\n                # Otherwise, look at defaults\n                for sym, cond in self.defaults:\n                    if expr_value(cond):\n                        val = sym.str_value\n                        self._write_to_conf = True\n                        break\n\n        # env_var corresponds to SYMBOL_AUTO in the C implementation, and is\n        # also set on the defconfig_list symbol there. Test for the\n        # defconfig_list symbol explicitly instead here, to avoid a nonsensical\n        # env_var setting and the defconfig_list symbol being printed\n        # incorrectly. This code is pretty cold anyway.\n        if self.env_var is not None or self is self.kconfig.defconfig_list:\n            self._write_to_conf = False\n\n        self._cached_str_val = val\n        return val\n\n    @property\n    def tri_value(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if self._cached_tri_val is not None:\n            return self._cached_tri_val\n\n        if self.orig_type not in _BOOL_TRISTATE:\n            if self.orig_type:  # != UNKNOWN\n                # Would take some work to give the location here\n                self.kconfig._warn(\n                    \"The {} symbol {} is being evaluated in a logical context \"\n                    \"somewhere. It will always evaluate to n.\"\n                    .format(TYPE_TO_STR[self.orig_type], self.name_and_loc))\n\n            self._cached_tri_val = 0\n            return 0\n\n        # Warning: See Symbol._rec_invalidate(), and note that this is a hidden\n        # function call (property magic)\n        vis = self.visibility\n        self._write_to_conf = (vis != 0)\n\n        val = 0\n\n        if not self.choice:\n            # Non-choice symbol\n\n            if vis and self.user_value is not None:\n                # If the symbol is visible and has a user value, use that\n                val = min(self.user_value, vis)\n\n            else:\n                # Otherwise, look at defaults and weak reverse dependencies\n                # (implies)\n\n                for default, cond in self.defaults:\n                    dep_val = expr_value(cond)\n                    if dep_val:\n                        val = min(expr_value(default), dep_val)\n                        if val:\n                            self._write_to_conf = True\n                        break\n\n                # Weak reverse dependencies are only considered if our\n                # direct dependencies are met\n                dep_val = expr_value(self.weak_rev_dep)\n                if dep_val and expr_value(self.direct_dep):\n                    val = max(dep_val, val)\n                    self._write_to_conf = True\n\n            # Reverse (select-related) dependencies take precedence\n            dep_val = expr_value(self.rev_dep)\n            if dep_val:\n                if expr_value(self.direct_dep) < dep_val:\n                    self._warn_select_unsatisfied_deps()\n\n                val = max(dep_val, val)\n                self._write_to_conf = True\n\n            # m is promoted to y for (1) bool symbols and (2) symbols with a\n            # weak_rev_dep (from imply) of y\n            if val == 1 and \\\n               (self.type is BOOL or expr_value(self.weak_rev_dep) == 2):\n                val = 2\n\n        elif vis == 2:\n            # Visible choice symbol in y-mode choice. The choice mode limits\n            # the visibility of choice symbols, so it's sufficient to just\n            # check the visibility of the choice symbols themselves.\n            val = 2 if self.choice.selection is self else 0\n\n        elif vis and self.user_value:\n            # Visible choice symbol in m-mode choice, with set non-0 user value\n            val = 1\n\n        self._cached_tri_val = val\n        return val\n\n    @property\n    def assignable(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if self._cached_assignable is None:\n            self._cached_assignable = self._assignable()\n        return self._cached_assignable\n\n    @property\n    def visibility(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if self._cached_vis is None:\n            self._cached_vis = _visibility(self)\n        return self._cached_vis\n\n    @property\n    def config_string(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        # _write_to_conf is determined when the value is calculated. This is a\n        # hidden function call due to property magic.\n        val = self.str_value\n        if not self._write_to_conf:\n            return \"\"\n\n        if self.orig_type in _BOOL_TRISTATE:\n            return \"{}{}={}\\n\" \\\n                   .format(self.kconfig.config_prefix, self.name, val) \\\n                   if val != \"n\" else \\\n                   \"# {}{} is not set\\n\" \\\n                   .format(self.kconfig.config_prefix, self.name)\n\n        if self.orig_type in _INT_HEX:\n            return \"{}{}={}\\n\" \\\n                   .format(self.kconfig.config_prefix, self.name, val)\n\n        # sym.orig_type is STRING\n        return '{}{}=\"{}\"\\n' \\\n               .format(self.kconfig.config_prefix, self.name, escape(val))\n\n    @property\n    def name_and_loc(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return self.name + \" \" + _locs(self)\n\n    def set_value(self, value):\n        \"\"\"\n        Sets the user value of the symbol.\n\n        Equal in effect to assigning the value to the symbol within a .config\n        file. For bool and tristate symbols, use the 'assignable' attribute to\n        check which values can currently be assigned. Setting values outside\n        'assignable' will cause Symbol.user_value to differ from\n        Symbol.str/tri_value (be truncated down or up).\n\n        Setting a choice symbol to 2 (y) sets Choice.user_selection to the\n        choice symbol in addition to setting Symbol.user_value.\n        Choice.user_selection is considered when the choice is in y mode (the\n        \"normal\" mode).\n\n        Other symbols that depend (possibly indirectly) on this symbol are\n        automatically recalculated to reflect the assigned value.\n\n        value:\n          The user value to give to the symbol. For bool and tristate symbols,\n          n/m/y can be specified either as 0/1/2 (the usual format for tristate\n          values in Kconfiglib) or as one of the strings \"n\", \"m\", or \"y\". For\n          other symbol types, pass a string.\n\n          Note that the value for an int/hex symbol is passed as a string, e.g.\n          \"123\" or \"0x0123\". The format of this string is preserved in the\n          output.\n\n          Values that are invalid for the type (such as \"foo\" or 1 (m) for a\n          BOOL or \"0x123\" for an INT) are ignored and won't be stored in\n          Symbol.user_value. Kconfiglib will print a warning by default for\n          invalid assignments, and set_value() will return False.\n\n        Returns True if the value is valid for the type of the symbol, and\n        False otherwise. This only looks at the form of the value. For BOOL and\n        TRISTATE symbols, check the Symbol.assignable attribute to see what\n        values are currently in range and would actually be reflected in the\n        value of the symbol. For other symbol types, check whether the\n        visibility is non-n.\n        \"\"\"\n        if self.orig_type in _BOOL_TRISTATE and value in STR_TO_TRI:\n            value = STR_TO_TRI[value]\n\n        # If the new user value matches the old, nothing changes, and we can\n        # avoid invalidating cached values.\n        #\n        # This optimization is skipped for choice symbols: Setting a choice\n        # symbol's user value to y might change the state of the choice, so it\n        # wouldn't be safe (symbol user values always match the values set in a\n        # .config file or via set_value(), and are never implicitly updated).\n        if value == self.user_value and not self.choice:\n            self._was_set = True\n            return True\n\n        # Check if the value is valid for our type\n        if not (self.orig_type is BOOL     and value in (2, 0)     or\n                self.orig_type is TRISTATE and value in TRI_TO_STR or\n                value.__class__ is str and\n                (self.orig_type is STRING                        or\n                 self.orig_type is INT and _is_base_n(value, 10) or\n                 self.orig_type is HEX and _is_base_n(value, 16)\n                                       and int(value, 16) >= 0)):\n\n            # Display tristate values as n, m, y in the warning\n            self.kconfig._warn(\n                \"the value {} is invalid for {}, which has type {} -- \"\n                \"assignment ignored\"\n                .format(TRI_TO_STR[value] if value in TRI_TO_STR else\n                            \"'{}'\".format(value),\n                        self.name_and_loc, TYPE_TO_STR[self.orig_type]))\n\n            return False\n\n        self.user_value = value\n        self._was_set = True\n\n        if self.choice and value == 2:\n            # Setting a choice symbol to y makes it the user selection of the\n            # choice. Like for symbol user values, the user selection is not\n            # guaranteed to match the actual selection of the choice, as\n            # dependencies come into play.\n            self.choice.user_selection = self\n            self.choice._was_set = True\n            self.choice._rec_invalidate()\n        else:\n            self._rec_invalidate_if_has_prompt()\n\n        return True\n\n    def unset_value(self):\n        \"\"\"\n        Removes any user value from the symbol, as if the symbol had never\n        gotten a user value via Kconfig.load_config() or Symbol.set_value().\n        \"\"\"\n        if self.user_value is not None:\n            self.user_value = None\n            self._rec_invalidate_if_has_prompt()\n\n    @property\n    def referenced(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return {item for node in self.nodes for item in node.referenced}\n\n    @property\n    def orig_defaults(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return [d for node in self.nodes for d in node.orig_defaults]\n\n    @property\n    def orig_selects(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return [s for node in self.nodes for s in node.orig_selects]\n\n    @property\n    def orig_implies(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return [i for node in self.nodes for i in node.orig_implies]\n\n    @property\n    def orig_ranges(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return [r for node in self.nodes for r in node.orig_ranges]\n\n    def __repr__(self):\n        \"\"\"\n        Returns a string with information about the symbol (including its name,\n        value, visibility, and location(s)) when it is evaluated on e.g. the\n        interactive Python prompt.\n        \"\"\"\n        fields = [\"symbol \" + self.name, TYPE_TO_STR[self.type]]\n        add = fields.append\n\n        for node in self.nodes:\n            if node.prompt:\n                add('\"{}\"'.format(node.prompt[0]))\n\n        # Only add quotes for non-bool/tristate symbols\n        add(\"value \" + (self.str_value if self.orig_type in _BOOL_TRISTATE\n                        else '\"{}\"'.format(self.str_value)))\n\n        if not self.is_constant:\n            # These aren't helpful to show for constant symbols\n\n            if self.user_value is not None:\n                # Only add quotes for non-bool/tristate symbols\n                add(\"user value \" + (TRI_TO_STR[self.user_value]\n                                     if self.orig_type in _BOOL_TRISTATE\n                                     else '\"{}\"'.format(self.user_value)))\n\n            add(\"visibility \" + TRI_TO_STR[self.visibility])\n\n            if self.choice:\n                add(\"choice symbol\")\n\n            if self.is_allnoconfig_y:\n                add(\"allnoconfig_y\")\n\n            if self is self.kconfig.defconfig_list:\n                add(\"is the defconfig_list symbol\")\n\n            if self.env_var is not None:\n                add(\"from environment variable \" + self.env_var)\n\n            if self is self.kconfig.modules:\n                add(\"is the modules symbol\")\n\n            add(\"direct deps \" + TRI_TO_STR[expr_value(self.direct_dep)])\n\n        if self.nodes:\n            for node in self.nodes:\n                add(\"{}:{}\".format(node.filename, node.linenr))\n        else:\n            add(\"constant\" if self.is_constant else \"undefined\")\n\n        return \"<{}>\".format(\", \".join(fields))\n\n    def __str__(self):\n        \"\"\"\n        Returns a string representation of the symbol when it is printed.\n        Matches the Kconfig format, with any parent dependencies propagated to\n        the 'depends on' condition.\n\n        The string is constructed by joining the strings returned by\n        MenuNode.__str__() for each of the symbol's menu nodes, so symbols\n        defined in multiple locations will return a string with all\n        definitions.\n\n        The returned string does not end in a newline. An empty string is\n        returned for undefined and constant symbols.\n        \"\"\"\n        return self.custom_str(standard_sc_expr_str)\n\n    def custom_str(self, sc_expr_str_fn):\n        \"\"\"\n        Works like Symbol.__str__(), but allows a custom format to be used for\n        all symbol/choice references. See expr_str().\n        \"\"\"\n        return \"\\n\\n\".join(node.custom_str(sc_expr_str_fn)\n                           for node in self.nodes)\n\n    #\n    # Private methods\n    #\n\n    def __init__(self):\n        \"\"\"\n        Symbol constructor -- not intended to be called directly by Kconfiglib\n        clients.\n        \"\"\"\n        # These attributes are always set on the instance from outside and\n        # don't need defaults:\n        #   kconfig\n        #   direct_dep\n        #   is_constant\n        #   name\n        #   rev_dep\n        #   weak_rev_dep\n\n        # - UNKNOWN == 0\n        # - _visited is used during tree iteration and dep. loop detection\n        self.orig_type = self._visited = 0\n\n        self.nodes = []\n\n        self.defaults = []\n        self.selects = []\n        self.implies = []\n        self.ranges = []\n\n        self.user_value = \\\n        self.choice = \\\n        self.env_var = \\\n        self._cached_str_val = self._cached_tri_val = self._cached_vis = \\\n        self._cached_assignable = None\n\n        # _write_to_conf is calculated along with the value. If True, the\n        # Symbol gets a .config entry.\n\n        self.is_allnoconfig_y = \\\n        self._was_set = \\\n        self._write_to_conf = False\n\n        # See Kconfig._build_dep()\n        self._dependents = set()\n\n    def _assignable(self):\n        # Worker function for the 'assignable' attribute\n\n        if self.orig_type not in _BOOL_TRISTATE:\n            return ()\n\n        # Warning: See Symbol._rec_invalidate(), and note that this is a hidden\n        # function call (property magic)\n        vis = self.visibility\n        if not vis:\n            return ()\n\n        rev_dep_val = expr_value(self.rev_dep)\n\n        if vis == 2:\n            if self.choice:\n                return (2,)\n\n            if not rev_dep_val:\n                if self.type is BOOL or expr_value(self.weak_rev_dep) == 2:\n                    return (0, 2)\n                return (0, 1, 2)\n\n            if rev_dep_val == 2:\n                return (2,)\n\n            # rev_dep_val == 1\n\n            if self.type is BOOL or expr_value(self.weak_rev_dep) == 2:\n                return (2,)\n            return (1, 2)\n\n        # vis == 1\n\n        # Must be a tristate here, because bool m visibility gets promoted to y\n\n        if not rev_dep_val:\n            return (0, 1) if expr_value(self.weak_rev_dep) != 2 else (0, 2)\n\n        if rev_dep_val == 2:\n            return (2,)\n\n        # vis == rev_dep_val == 1\n\n        return (1,)\n\n    def _invalidate(self):\n        # Marks the symbol as needing to be recalculated\n\n        self._cached_str_val = self._cached_tri_val = self._cached_vis = \\\n        self._cached_assignable = None\n\n    def _rec_invalidate(self):\n        # Invalidates the symbol and all items that (possibly) depend on it\n\n        if self is self.kconfig.modules:\n            # Invalidating MODULES has wide-ranging effects\n            self.kconfig._invalidate_all()\n        else:\n            self._invalidate()\n\n            for item in self._dependents:\n                # _cached_vis doubles as a flag that tells us whether 'item'\n                # has cached values, because it's calculated as a side effect\n                # of calculating all other (non-constant) cached values.\n                #\n                # If item._cached_vis is None, it means there can't be cached\n                # values on other items that depend on 'item', because if there\n                # were, some value on 'item' would have been calculated and\n                # item._cached_vis set as a side effect. It's therefore safe to\n                # stop the invalidation at symbols with _cached_vis None.\n                #\n                # This approach massively speeds up scripts that set a lot of\n                # values, vs simply invalidating all possibly dependent symbols\n                # (even when you already have a list of all the dependent\n                # symbols, because some symbols get huge dependency trees).\n                #\n                # This gracefully handles dependency loops too, which is nice\n                # for choices, where the choice depends on the choice symbols\n                # and vice versa.\n                if item._cached_vis is not None:\n                    item._rec_invalidate()\n\n    def _rec_invalidate_if_has_prompt(self):\n        # Invalidates the symbol and its dependent symbols, but only if the\n        # symbol has a prompt. User values never have an effect on promptless\n        # symbols, so we skip invalidation for them as an optimization.\n        #\n        # This also prevents constant (quoted) symbols from being invalidated\n        # if set_value() is called on them, which would make them lose their\n        # value and break things.\n        #\n        # Prints a warning if the symbol has no prompt. In some contexts (e.g.\n        # when loading a .config files) assignments to promptless symbols are\n        # normal and expected, so the warning can be disabled.\n\n        for node in self.nodes:\n            if node.prompt:\n                self._rec_invalidate()\n                return\n\n        if self.kconfig._warn_assign_no_prompt:\n            self.kconfig._warn(self.name_and_loc + \" has no prompt, meaning \"\n                               \"user values have no effect on it\")\n\n    def _str_default(self):\n        # write_min_config() helper function. Returns the value the symbol\n        # would get from defaults if it didn't have a user value. Uses exactly\n        # the same algorithm as the C implementation (though a bit cleaned up),\n        # for compatibility.\n\n        if self.orig_type in _BOOL_TRISTATE:\n            val = 0\n\n            # Defaults, selects, and implies do not affect choice symbols\n            if not self.choice:\n                for default, cond in self.defaults:\n                    cond_val = expr_value(cond)\n                    if cond_val:\n                        val = min(expr_value(default), cond_val)\n                        break\n\n                val = max(expr_value(self.rev_dep),\n                          expr_value(self.weak_rev_dep),\n                          val)\n\n                # Transpose mod to yes if type is bool (possibly due to modules\n                # being disabled)\n                if val == 1 and self.type is BOOL:\n                    val = 2\n\n            return TRI_TO_STR[val]\n\n        if self.orig_type:  # STRING/INT/HEX\n            for default, cond in self.defaults:\n                if expr_value(cond):\n                    return default.str_value\n\n        return \"\"\n\n    def _warn_select_unsatisfied_deps(self):\n        # Helper for printing an informative warning when a symbol with\n        # unsatisfied direct dependencies (dependencies from 'depends on', ifs,\n        # and menus) is selected by some other symbol. Also warn if a symbol\n        # whose direct dependencies evaluate to m is selected to y.\n\n        msg = \"{} has direct dependencies {} with value {}, but is \" \\\n              \"currently being {}-selected by the following symbols:\" \\\n              .format(self.name_and_loc, expr_str(self.direct_dep),\n                      TRI_TO_STR[expr_value(self.direct_dep)],\n                      TRI_TO_STR[expr_value(self.rev_dep)])\n\n        # The reverse dependencies from each select are ORed together\n        for select in split_expr(self.rev_dep, OR):\n            if expr_value(select) <= expr_value(self.direct_dep):\n                # Only include selects that exceed the direct dependencies\n                continue\n\n            # - 'select A if B' turns into A && B\n            # - 'select A' just turns into A\n            #\n            # In both cases, we can split on AND and pick the first operand\n            selecting_sym = split_expr(select, AND)[0]\n\n            msg += \"\\n - {}, with value {}, direct dependencies {} \" \\\n                   \"(value: {})\" \\\n                   .format(selecting_sym.name_and_loc,\n                           selecting_sym.str_value,\n                           expr_str(selecting_sym.direct_dep),\n                           TRI_TO_STR[expr_value(selecting_sym.direct_dep)])\n\n            if select.__class__ is tuple:\n                msg += \", and select condition {} (value: {})\" \\\n                       .format(expr_str(select[2]),\n                               TRI_TO_STR[expr_value(select[2])])\n\n        self.kconfig._warn(msg)\n\n\nclass Choice(object):\n    \"\"\"\n    Represents a choice statement:\n\n      choice\n          ...\n      endchoice\n\n    The following attributes are available on Choice instances. They should be\n    treated as read-only, and some are implemented through @property magic (but\n    are still efficient to access due to internal caching).\n\n    Note: Prompts, help texts, and locations are stored in the Choice's\n    MenuNode(s) rather than in the Choice itself. Check the MenuNode class and\n    the Choice.nodes attribute. This organization matches the C tools.\n\n    name:\n      The name of the choice, e.g. \"FOO\" for 'choice FOO', or None if the\n      Choice has no name.\n\n    type:\n      The type of the choice. One of BOOL, TRISTATE, UNKNOWN. UNKNOWN is for\n      choices defined without a type where none of the contained symbols have a\n      type either (otherwise the choice inherits the type of the first symbol\n      defined with a type).\n\n      When running without modules (CONFIG_MODULES=n), TRISTATE choices\n      magically change type to BOOL. This matches the C tools, and makes sense\n      for menuconfig-like functionality.\n\n    orig_type:\n      The type as given in the Kconfig file, without any magic applied. Used\n      when printing the choice.\n\n    tri_value:\n      The tristate value (mode) of the choice. A choice can be in one of three\n      modes:\n\n        0 (n) - The choice is disabled and no symbols can be selected. For\n                visible choices, this mode is only possible for choices with\n                the 'optional' flag set (see kconfig-language.txt).\n\n        1 (m) - Any number of choice symbols can be set to m, the rest will\n                be n.\n\n        2 (y) - One symbol will be y, the rest n.\n\n      Only tristate choices can be in m mode. The visibility of the choice is\n      an upper bound on the mode, and the mode in turn is an upper bound on the\n      visibility of the choice symbols.\n\n      To change the mode, use Choice.set_value().\n\n      Implementation note:\n        The C tools internally represent choices as a type of symbol, with\n        special-casing in many code paths. This is why there is a lot of\n        similarity to Symbol. The value (mode) of a choice is really just a\n        normal symbol value, and an implicit reverse dependency forces its\n        lower bound to m for visible non-optional choices (the reverse\n        dependency is 'm && <visibility>').\n\n        Symbols within choices get the choice propagated as a dependency to\n        their properties. This turns the mode of the choice into an upper bound\n        on e.g. the visibility of choice symbols, and explains the gotcha\n        related to printing choice symbols mentioned in the module docstring.\n\n        Kconfiglib uses a separate Choice class only because it makes the code\n        and interface less confusing (especially in a user-facing interface).\n        Corresponding attributes have the same name in the Symbol and Choice\n        classes, for consistency and compatibility.\n\n    str_value:\n      Like choice.tri_value, but gives the value as one of the strings\n      \"n\", \"m\", or \"y\"\n\n    user_value:\n      The value (mode) selected by the user through Choice.set_value(). Either\n      0, 1, or 2, or None if the user hasn't selected a mode. See\n      Symbol.user_value.\n\n      WARNING: Do not assign directly to this. It will break things. Use\n      Choice.set_value() instead.\n\n    assignable:\n      See the symbol class documentation. Gives the assignable values (modes).\n\n    selection:\n      The Symbol instance of the currently selected symbol. None if the Choice\n      is not in y mode or has no selected symbol (due to unsatisfied\n      dependencies on choice symbols).\n\n      WARNING: Do not assign directly to this. It will break things. Call\n      sym.set_value(2) on the choice symbol you want to select instead.\n\n    user_selection:\n      The symbol selected by the user (by setting it to y). Ignored if the\n      choice is not in y mode, but still remembered so that the choice \"snaps\n      back\" to the user selection if the mode is changed back to y. This might\n      differ from 'selection' due to unsatisfied dependencies.\n\n      WARNING: Do not assign directly to this. It will break things. Call\n      sym.set_value(2) on the choice symbol to be selected instead.\n\n    visibility:\n      See the Symbol class documentation. Acts on the value (mode).\n\n    name_and_loc:\n      Holds a string like\n\n        \"<choice MY_CHOICE> (defined at foo/Kconfig:12)\"\n\n      , giving the name of the choice and its definition location(s). If the\n      choice has no name (isn't defined with 'choice MY_CHOICE'), then it will\n      be shown as \"<choice>\" before the list of locations (always a single one\n      in that case).\n\n    syms:\n      List of symbols contained in the choice.\n\n      Obscure gotcha: If a symbol depends on the previous symbol within a\n      choice so that an implicit menu is created, it won't be a choice symbol,\n      and won't be included in 'syms'.\n\n    nodes:\n      A list of MenuNodes for this choice. In practice, the list will probably\n      always contain a single MenuNode, but it is possible to give a choice a\n      name and define it in multiple locations.\n\n    defaults:\n      List of (symbol, cond) tuples for the choice's 'defaults' properties. For\n      example, 'default A if B && C' is represented as (A, (AND, B, C)). If\n      there is no condition, 'cond' is self.kconfig.y.\n\n      Note that 'depends on' and parent dependencies are propagated to\n      'default' conditions.\n\n    orig_defaults:\n      See the corresponding attribute on the MenuNode class.\n\n    direct_dep:\n      See Symbol.direct_dep.\n\n    referenced:\n      A set() with all symbols referenced in the properties and property\n      conditions of the choice.\n\n      Also includes dependencies from surrounding menus and ifs, because those\n      get propagated to the choice (see the 'Intro to symbol values' section in\n      the module docstring).\n\n    is_optional:\n      True if the choice has the 'optional' flag set on it and can be in\n      n mode.\n\n    kconfig:\n      The Kconfig instance this choice is from.\n    \"\"\"\n    __slots__ = (\n        \"_cached_assignable\",\n        \"_cached_selection\",\n        \"_cached_vis\",\n        \"_dependents\",\n        \"_visited\",\n        \"_was_set\",\n        \"defaults\",\n        \"direct_dep\",\n        \"is_constant\",\n        \"is_optional\",\n        \"kconfig\",\n        \"name\",\n        \"nodes\",\n        \"orig_type\",\n        \"syms\",\n        \"user_selection\",\n        \"user_value\",\n    )\n\n    #\n    # Public interface\n    #\n\n    @property\n    def type(self):\n        \"\"\"\n        Returns the type of the choice. See Symbol.type.\n        \"\"\"\n        if self.orig_type is TRISTATE and not self.kconfig.modules.tri_value:\n            return BOOL\n        return self.orig_type\n\n    @property\n    def str_value(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return TRI_TO_STR[self.tri_value]\n\n    @property\n    def tri_value(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        # This emulates a reverse dependency of 'm && visibility' for\n        # non-optional choices, which is how the C implementation does it\n\n        val = 0 if self.is_optional else 1\n\n        if self.user_value is not None:\n            val = max(val, self.user_value)\n\n        # Warning: See Symbol._rec_invalidate(), and note that this is a hidden\n        # function call (property magic)\n        val = min(val, self.visibility)\n\n        # Promote m to y for boolean choices\n        return 2 if val == 1 and self.type is BOOL else val\n\n    @property\n    def assignable(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if self._cached_assignable is None:\n            self._cached_assignable = self._assignable()\n        return self._cached_assignable\n\n    @property\n    def visibility(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if self._cached_vis is None:\n            self._cached_vis = _visibility(self)\n        return self._cached_vis\n\n    @property\n    def name_and_loc(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        # Reuse the expression format, which is '<choice (name, if any)>'.\n        return standard_sc_expr_str(self) + \" \" + _locs(self)\n\n    @property\n    def selection(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if self._cached_selection is _NO_CACHED_SELECTION:\n            self._cached_selection = self._selection()\n        return self._cached_selection\n\n    def set_value(self, value):\n        \"\"\"\n        Sets the user value (mode) of the choice. Like for Symbol.set_value(),\n        the visibility might truncate the value. Choices without the 'optional'\n        attribute (is_optional) can never be in n mode, but 0/\"n\" is still\n        accepted since it's not a malformed value (though it will have no\n        effect).\n\n        Returns True if the value is valid for the type of the choice, and\n        False otherwise. This only looks at the form of the value. Check the\n        Choice.assignable attribute to see what values are currently in range\n        and would actually be reflected in the mode of the choice.\n        \"\"\"\n        if value in STR_TO_TRI:\n            value = STR_TO_TRI[value]\n\n        if value == self.user_value:\n            # We know the value must be valid if it was successfully set\n            # previously\n            self._was_set = True\n            return True\n\n        if not (self.orig_type is BOOL     and value in (2, 0) or\n                self.orig_type is TRISTATE and value in TRI_TO_STR):\n\n            # Display tristate values as n, m, y in the warning\n            self.kconfig._warn(\n                \"the value {} is invalid for {}, which has type {} -- \"\n                \"assignment ignored\"\n                .format(TRI_TO_STR[value] if value in TRI_TO_STR else\n                            \"'{}'\".format(value),\n                        self.name_and_loc, TYPE_TO_STR[self.orig_type]))\n\n            return False\n\n        self.user_value = value\n        self._was_set = True\n        self._rec_invalidate()\n\n        return True\n\n    def unset_value(self):\n        \"\"\"\n        Resets the user value (mode) and user selection of the Choice, as if\n        the user had never touched the mode or any of the choice symbols.\n        \"\"\"\n        if self.user_value is not None or self.user_selection:\n            self.user_value = self.user_selection = None\n            self._rec_invalidate()\n\n    @property\n    def referenced(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return {item for node in self.nodes for item in node.referenced}\n\n    @property\n    def orig_defaults(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return [d for node in self.nodes for d in node.orig_defaults]\n\n    def __repr__(self):\n        \"\"\"\n        Returns a string with information about the choice when it is evaluated\n        on e.g. the interactive Python prompt.\n        \"\"\"\n        fields = [\"choice \" + self.name if self.name else \"choice\",\n                  TYPE_TO_STR[self.type]]\n        add = fields.append\n\n        for node in self.nodes:\n            if node.prompt:\n                add('\"{}\"'.format(node.prompt[0]))\n\n        add(\"mode \" + self.str_value)\n\n        if self.user_value is not None:\n            add('user mode {}'.format(TRI_TO_STR[self.user_value]))\n\n        if self.selection:\n            add(\"{} selected\".format(self.selection.name))\n\n        if self.user_selection:\n            user_sel_str = \"{} selected by user\" \\\n                           .format(self.user_selection.name)\n\n            if self.selection is not self.user_selection:\n                user_sel_str += \" (overridden)\"\n\n            add(user_sel_str)\n\n        add(\"visibility \" + TRI_TO_STR[self.visibility])\n\n        if self.is_optional:\n            add(\"optional\")\n\n        for node in self.nodes:\n            add(\"{}:{}\".format(node.filename, node.linenr))\n\n        return \"<{}>\".format(\", \".join(fields))\n\n    def __str__(self):\n        \"\"\"\n        Returns a string representation of the choice when it is printed.\n        Matches the Kconfig format (though without the contained choice\n        symbols), with any parent dependencies propagated to the 'depends on'\n        condition.\n\n        The returned string does not end in a newline.\n\n        See Symbol.__str__() as well.\n        \"\"\"\n        return self.custom_str(standard_sc_expr_str)\n\n    def custom_str(self, sc_expr_str_fn):\n        \"\"\"\n        Works like Choice.__str__(), but allows a custom format to be used for\n        all symbol/choice references. See expr_str().\n        \"\"\"\n        return \"\\n\\n\".join(node.custom_str(sc_expr_str_fn)\n                           for node in self.nodes)\n\n    #\n    # Private methods\n    #\n\n    def __init__(self):\n        \"\"\"\n        Choice constructor -- not intended to be called directly by Kconfiglib\n        clients.\n        \"\"\"\n        # These attributes are always set on the instance from outside and\n        # don't need defaults:\n        #   direct_dep\n        #   kconfig\n\n        # - UNKNOWN == 0\n        # - _visited is used during dep. loop detection\n        self.orig_type = self._visited = 0\n\n        self.nodes = []\n\n        self.syms = []\n        self.defaults = []\n\n        self.name = \\\n        self.user_value = self.user_selection = \\\n        self._cached_vis = self._cached_assignable = None\n\n        self._cached_selection = _NO_CACHED_SELECTION\n\n        # is_constant is checked by _depend_on(). Just set it to avoid having\n        # to special-case choices.\n        self.is_constant = self.is_optional = False\n\n        # See Kconfig._build_dep()\n        self._dependents = set()\n\n    def _assignable(self):\n        # Worker function for the 'assignable' attribute\n\n        # Warning: See Symbol._rec_invalidate(), and note that this is a hidden\n        # function call (property magic)\n        vis = self.visibility\n\n        if not vis:\n            return ()\n\n        if vis == 2:\n            if not self.is_optional:\n                return (2,) if self.type is BOOL else (1, 2)\n            return (0, 2) if self.type is BOOL else (0, 1, 2)\n\n        # vis == 1\n\n        return (0, 1) if self.is_optional else (1,)\n\n    def _selection(self):\n        # Worker function for the 'selection' attribute\n\n        # Warning: See Symbol._rec_invalidate(), and note that this is a hidden\n        # function call (property magic)\n        if self.tri_value != 2:\n            # Not in y mode, so no selection\n            return None\n\n        # Use the user selection if it's visible\n        if self.user_selection and self.user_selection.visibility:\n            return self.user_selection\n\n        # Otherwise, check if we have a default\n        return self._selection_from_defaults()\n\n    def _selection_from_defaults(self):\n        # Check if we have a default\n        for sym, cond in self.defaults:\n            # The default symbol must be visible too\n            if expr_value(cond) and sym.visibility:\n                return sym\n\n        # Otherwise, pick the first visible symbol, if any\n        for sym in self.syms:\n            if sym.visibility:\n                return sym\n\n        # Couldn't find a selection\n        return None\n\n    def _invalidate(self):\n        self._cached_vis = self._cached_assignable = None\n        self._cached_selection = _NO_CACHED_SELECTION\n\n    def _rec_invalidate(self):\n        # See Symbol._rec_invalidate()\n\n        self._invalidate()\n\n        for item in self._dependents:\n            if item._cached_vis is not None:\n                item._rec_invalidate()\n\n\nclass MenuNode(object):\n    \"\"\"\n    Represents a menu node in the configuration. This corresponds to an entry\n    in e.g. the 'make menuconfig' interface, though non-visible choices, menus,\n    and comments also get menu nodes. If a symbol or choice is defined in\n    multiple locations, it gets one menu node for each location.\n\n    The top-level menu node, corresponding to the implicit top-level menu, is\n    available in Kconfig.top_node.\n\n    The menu nodes for a Symbol or Choice can be found in the\n    Symbol/Choice.nodes attribute. Menus and comments are represented as plain\n    menu nodes, with their text stored in the prompt attribute (prompt[0]).\n    This mirrors the C implementation.\n\n    The following attributes are available on MenuNode instances. They should\n    be viewed as read-only.\n\n    item:\n      Either a Symbol, a Choice, or one of the constants MENU and COMMENT.\n      Menus and comments are represented as plain menu nodes. Ifs are collapsed\n      (matching the C implementation) and do not appear in the final menu tree.\n\n    next:\n      The following menu node. None if there is no following node.\n\n    list:\n      The first child menu node. None if there are no children.\n\n      Choices and menus naturally have children, but Symbols can also have\n      children because of menus created automatically from dependencies (see\n      kconfig-language.txt).\n\n    parent:\n      The parent menu node. None if there is no parent.\n\n    prompt:\n      A (string, cond) tuple with the prompt for the menu node and its\n      conditional expression (which is self.kconfig.y if there is no\n      condition). None if there is no prompt.\n\n      For symbols and choices, the prompt is stored in the MenuNode rather than\n      the Symbol or Choice instance. For menus and comments, the prompt holds\n      the text.\n\n    defaults:\n      The 'default' properties for this particular menu node. See\n      symbol.defaults.\n\n      When evaluating defaults, you should use Symbol/Choice.defaults instead,\n      as it include properties from all menu nodes (a symbol/choice can have\n      multiple definition locations/menu nodes). MenuNode.defaults is meant for\n      documentation generation.\n\n    selects:\n      Like MenuNode.defaults, for selects.\n\n    implies:\n      Like MenuNode.defaults, for implies.\n\n    ranges:\n      Like MenuNode.defaults, for ranges.\n\n    orig_prompt:\n    orig_defaults:\n    orig_selects:\n    orig_implies:\n    orig_ranges:\n      These work the like the corresponding attributes without orig_*, but omit\n      any dependencies propagated from 'depends on' and surrounding 'if's (the\n      direct dependencies, stored in MenuNode.dep).\n\n      One use for this is generating less cluttered documentation, by only\n      showing the direct dependencies in one place.\n\n    help:\n      The help text for the menu node for Symbols and Choices. None if there is\n      no help text. Always stored in the node rather than the Symbol or Choice.\n      It is possible to have a separate help text at each location if a symbol\n      is defined in multiple locations.\n\n      Trailing whitespace (including a final newline) is stripped from the help\n      text. This was not the case before Kconfiglib 10.21.0, where the format\n      was undocumented.\n\n    dep:\n      The direct ('depends on') dependencies for the menu node, or\n      self.kconfig.y if there are no direct dependencies.\n\n      This attribute includes any dependencies from surrounding menus and ifs.\n      Those get propagated to the direct dependencies, and the resulting direct\n      dependencies in turn get propagated to the conditions of all properties.\n\n      If a symbol or choice is defined in multiple locations, only the\n      properties defined at a particular location get the corresponding\n      MenuNode.dep dependencies propagated to them.\n\n    visibility:\n      The 'visible if' dependencies for the menu node (which must represent a\n      menu), or self.kconfig.y if there are no 'visible if' dependencies.\n      'visible if' dependencies are recursively propagated to the prompts of\n      symbols and choices within the menu.\n\n    referenced:\n      A set() with all symbols and choices referenced in the properties and\n      property conditions of the menu node.\n\n      Also includes dependencies inherited from surrounding menus and ifs.\n      Choices appear in the dependencies of choice symbols.\n\n    is_menuconfig:\n      Set to True if the children of the menu node should be displayed in a\n      separate menu. This is the case for the following items:\n\n        - Menus (node.item == MENU)\n\n        - Choices\n\n        - Symbols defined with the 'menuconfig' keyword. The children come from\n          implicitly created submenus, and should be displayed in a separate\n          menu rather than being indented.\n\n      'is_menuconfig' is just a hint on how to display the menu node. It's\n      ignored internally by Kconfiglib, except when printing symbols.\n\n    filename/linenr:\n      The location where the menu node appears. The filename is relative to\n      $srctree (or to the current directory if $srctree isn't set), except\n      absolute paths are used for paths outside $srctree.\n\n    include_path:\n      A tuple of (filename, linenr) tuples, giving the locations of the\n      'source' statements via which the Kconfig file containing this menu node\n      was included. The first element is the location of the 'source' statement\n      in the top-level Kconfig file passed to Kconfig.__init__(), etc.\n\n      Note that the Kconfig file of the menu node itself isn't included. Check\n      'filename' and 'linenr' for that.\n\n    kconfig:\n      The Kconfig instance the menu node is from.\n    \"\"\"\n    __slots__ = (\n        \"dep\",\n        \"filename\",\n        \"help\",\n        \"include_path\",\n        \"is_menuconfig\",\n        \"item\",\n        \"kconfig\",\n        \"linenr\",\n        \"list\",\n        \"next\",\n        \"parent\",\n        \"prompt\",\n        \"visibility\",\n\n        # Properties\n        \"defaults\",\n        \"selects\",\n        \"implies\",\n        \"ranges\",\n    )\n\n    def __init__(self):\n        # Properties defined on this particular menu node. A local 'depends on'\n        # only applies to these, in case a symbol is defined in multiple\n        # locations.\n        self.defaults = []\n        self.selects = []\n        self.implies = []\n        self.ranges = []\n\n    @property\n    def orig_prompt(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        if not self.prompt:\n            return None\n        return (self.prompt[0], self._strip_dep(self.prompt[1]))\n\n    @property\n    def orig_defaults(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return [(default, self._strip_dep(cond))\n                for default, cond in self.defaults]\n\n    @property\n    def orig_selects(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return [(select, self._strip_dep(cond))\n                for select, cond in self.selects]\n\n    @property\n    def orig_implies(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return [(imply, self._strip_dep(cond))\n                for imply, cond in self.implies]\n\n    @property\n    def orig_ranges(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return [(low, high, self._strip_dep(cond))\n                for low, high, cond in self.ranges]\n\n    @property\n    def referenced(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        # self.dep is included to catch dependencies from a lone 'depends on'\n        # when there are no properties to propagate it to\n        res = expr_items(self.dep)\n\n        if self.prompt:\n            res |= expr_items(self.prompt[1])\n\n        if self.item is MENU:\n            res |= expr_items(self.visibility)\n\n        for value, cond in self.defaults:\n            res |= expr_items(value)\n            res |= expr_items(cond)\n\n        for value, cond in self.selects:\n            res.add(value)\n            res |= expr_items(cond)\n\n        for value, cond in self.implies:\n            res.add(value)\n            res |= expr_items(cond)\n\n        for low, high, cond in self.ranges:\n            res.add(low)\n            res.add(high)\n            res |= expr_items(cond)\n\n        return res\n\n    def __repr__(self):\n        \"\"\"\n        Returns a string with information about the menu node when it is\n        evaluated on e.g. the interactive Python prompt.\n        \"\"\"\n        fields = []\n        add = fields.append\n\n        if self.item.__class__ is Symbol:\n            add(\"menu node for symbol \" + self.item.name)\n\n        elif self.item.__class__ is Choice:\n            s = \"menu node for choice\"\n            if self.item.name is not None:\n                s += \" \" + self.item.name\n            add(s)\n\n        elif self.item is MENU:\n            add(\"menu node for menu\")\n\n        else:  # self.item is COMMENT\n            add(\"menu node for comment\")\n\n        if self.prompt:\n            add('prompt \"{}\" (visibility {})'.format(\n                self.prompt[0], TRI_TO_STR[expr_value(self.prompt[1])]))\n\n        if self.item.__class__ is Symbol and self.is_menuconfig:\n            add(\"is menuconfig\")\n\n        add(\"deps \" + TRI_TO_STR[expr_value(self.dep)])\n\n        if self.item is MENU:\n            add(\"'visible if' deps \" + TRI_TO_STR[expr_value(self.visibility)])\n\n        if self.item.__class__ in _SYMBOL_CHOICE and self.help is not None:\n            add(\"has help\")\n\n        if self.list:\n            add(\"has child\")\n\n        if self.next:\n            add(\"has next\")\n\n        add(\"{}:{}\".format(self.filename, self.linenr))\n\n        return \"<{}>\".format(\", \".join(fields))\n\n    def __str__(self):\n        \"\"\"\n        Returns a string representation of the menu node. Matches the Kconfig\n        format, with any parent dependencies propagated to the 'depends on'\n        condition.\n\n        The output could (almost) be fed back into a Kconfig parser to redefine\n        the object associated with the menu node. See the module documentation\n        for a gotcha related to choice symbols.\n\n        For symbols and choices with multiple menu nodes (multiple definition\n        locations), properties that aren't associated with a particular menu\n        node are shown on all menu nodes ('option env=...', 'optional' for\n        choices, etc.).\n\n        The returned string does not end in a newline.\n        \"\"\"\n        return self.custom_str(standard_sc_expr_str)\n\n    def custom_str(self, sc_expr_str_fn):\n        \"\"\"\n        Works like MenuNode.__str__(), but allows a custom format to be used\n        for all symbol/choice references. See expr_str().\n        \"\"\"\n        return self._menu_comment_node_str(sc_expr_str_fn) \\\n               if self.item in _MENU_COMMENT else \\\n               self._sym_choice_node_str(sc_expr_str_fn)\n\n    def _menu_comment_node_str(self, sc_expr_str_fn):\n        s = '{} \"{}\"'.format(\"menu\" if self.item is MENU else \"comment\",\n                             self.prompt[0])\n\n        if self.dep is not self.kconfig.y:\n            s += \"\\n\\tdepends on {}\".format(expr_str(self.dep, sc_expr_str_fn))\n\n        if self.item is MENU and self.visibility is not self.kconfig.y:\n            s += \"\\n\\tvisible if {}\".format(expr_str(self.visibility,\n                                                     sc_expr_str_fn))\n\n        return s\n\n    def _sym_choice_node_str(self, sc_expr_str_fn):\n        def indent_add(s):\n            lines.append(\"\\t\" + s)\n\n        def indent_add_cond(s, cond):\n            if cond is not self.kconfig.y:\n                s += \" if \" + expr_str(cond, sc_expr_str_fn)\n            indent_add(s)\n\n        sc = self.item\n\n        if sc.__class__ is Symbol:\n            lines = [(\"menuconfig \" if self.is_menuconfig else \"config \")\n                     + sc.name]\n        else:\n            lines = [\"choice \" + sc.name if sc.name else \"choice\"]\n\n        if sc.orig_type and not self.prompt:  # sc.orig_type != UNKNOWN\n            # If there's a prompt, we'll use the '<type> \"prompt\"' shorthand\n            # instead\n            indent_add(TYPE_TO_STR[sc.orig_type])\n\n        if self.prompt:\n            if sc.orig_type:\n                prefix = TYPE_TO_STR[sc.orig_type]\n            else:\n                # Symbol defined without a type (which generates a warning)\n                prefix = \"prompt\"\n\n            indent_add_cond(prefix + ' \"{}\"'.format(escape(self.prompt[0])),\n                            self.orig_prompt[1])\n\n        if sc.__class__ is Symbol:\n            if sc.is_allnoconfig_y:\n                indent_add(\"option allnoconfig_y\")\n\n            if sc is sc.kconfig.defconfig_list:\n                indent_add(\"option defconfig_list\")\n\n            if sc.env_var is not None:\n                indent_add('option env=\"{}\"'.format(sc.env_var))\n\n            if sc is sc.kconfig.modules:\n                indent_add(\"option modules\")\n\n            for low, high, cond in self.orig_ranges:\n                indent_add_cond(\n                    \"range {} {}\".format(sc_expr_str_fn(low),\n                                         sc_expr_str_fn(high)),\n                    cond)\n\n        for default, cond in self.orig_defaults:\n            indent_add_cond(\"default \" + expr_str(default, sc_expr_str_fn),\n                            cond)\n\n        if sc.__class__ is Choice and sc.is_optional:\n            indent_add(\"optional\")\n\n        if sc.__class__ is Symbol:\n            for select, cond in self.orig_selects:\n                indent_add_cond(\"select \" + sc_expr_str_fn(select), cond)\n\n            for imply, cond in self.orig_implies:\n                indent_add_cond(\"imply \" + sc_expr_str_fn(imply), cond)\n\n        if self.dep is not sc.kconfig.y:\n            indent_add(\"depends on \" + expr_str(self.dep, sc_expr_str_fn))\n\n        if self.help is not None:\n            indent_add(\"help\")\n            for line in self.help.splitlines():\n                indent_add(\"  \" + line)\n\n        return \"\\n\".join(lines)\n\n    def _strip_dep(self, expr):\n        # Helper function for removing MenuNode.dep from 'expr'. Uses two\n        # pieces of internal knowledge: (1) Expressions are reused rather than\n        # copied, and (2) the direct dependencies always appear at the end.\n\n        # ... if dep -> ... if y\n        if self.dep is expr:\n            return self.kconfig.y\n\n        # (AND, X, dep) -> X\n        if expr.__class__ is tuple and expr[0] is AND and expr[2] is self.dep:\n            return expr[1]\n\n        return expr\n\n\nclass Variable(object):\n    \"\"\"\n    Represents a preprocessor variable/function.\n\n    The following attributes are available:\n\n    name:\n      The name of the variable.\n\n    value:\n      The unexpanded value of the variable.\n\n    expanded_value:\n      The expanded value of the variable. For simple variables (those defined\n      with :=), this will equal 'value'. Accessing this property will raise a\n      KconfigError if the expansion seems to be stuck in a loop.\n\n      Accessing this field is the same as calling expanded_value_w_args() with\n      no arguments. I hadn't considered function arguments when adding it. It\n      is retained for backwards compatibility though.\n\n    is_recursive:\n      True if the variable is recursive (defined with =).\n    \"\"\"\n    __slots__ = (\n        \"_n_expansions\",\n        \"is_recursive\",\n        \"kconfig\",\n        \"name\",\n        \"value\",\n    )\n\n    @property\n    def expanded_value(self):\n        \"\"\"\n        See the class documentation.\n        \"\"\"\n        return self.expanded_value_w_args()\n\n    def expanded_value_w_args(self, *args):\n        \"\"\"\n        Returns the expanded value of the variable/function. Any arguments\n        passed will be substituted for $(1), $(2), etc.\n\n        Raises a KconfigError if the expansion seems to be stuck in a loop.\n        \"\"\"\n        return self.kconfig._fn_val((self.name,) + args)\n\n    def __repr__(self):\n        return \"<variable {}, {}, value '{}'>\" \\\n               .format(self.name,\n                       \"recursive\" if self.is_recursive else \"immediate\",\n                       self.value)\n\n\nclass KconfigError(Exception):\n    \"\"\"\n    Exception raised for Kconfig-related errors.\n\n    KconfigError and KconfigSyntaxError are the same class. The\n    KconfigSyntaxError alias is only maintained for backwards compatibility.\n    \"\"\"\n\nKconfigSyntaxError = KconfigError  # Backwards compatibility\n\n\nclass InternalError(Exception):\n    \"Never raised. Kept around for backwards compatibility.\"\n\n\n# Workaround:\n#\n# If 'errno' and 'strerror' are set on IOError, then __str__() always returns\n# \"[Errno <errno>] <strerror>\", ignoring any custom message passed to the\n# constructor. By defining our own subclass, we can use a custom message while\n# also providing 'errno', 'strerror', and 'filename' to scripts.\nclass _KconfigIOError(IOError):\n    def __init__(self, ioerror, msg):\n        self.msg = msg\n        super(_KconfigIOError, self).__init__(\n            ioerror.errno, ioerror.strerror, ioerror.filename)\n\n    def __str__(self):\n        return self.msg\n\n\n#\n# Public functions\n#\n\n\ndef expr_value(expr):\n    \"\"\"\n    Evaluates the expression 'expr' to a tristate value. Returns 0 (n), 1 (m),\n    or 2 (y).\n\n    'expr' must be an already-parsed expression from a Symbol, Choice, or\n    MenuNode property. To evaluate an expression represented as a string, use\n    Kconfig.eval_string().\n\n    Passing subexpressions of expressions to this function works as expected.\n    \"\"\"\n    if expr.__class__ is not tuple:\n        return expr.tri_value\n\n    if expr[0] is AND:\n        v1 = expr_value(expr[1])\n        # Short-circuit the n case as an optimization (~5% faster\n        # allnoconfig.py and allyesconfig.py, as of writing)\n        return 0 if not v1 else min(v1, expr_value(expr[2]))\n\n    if expr[0] is OR:\n        v1 = expr_value(expr[1])\n        # Short-circuit the y case as an optimization\n        return 2 if v1 == 2 else max(v1, expr_value(expr[2]))\n\n    if expr[0] is NOT:\n        return 2 - expr_value(expr[1])\n\n    # Relation\n    #\n    # Implements <, <=, >, >= comparisons as well. These were added to\n    # kconfig in 31847b67 (kconfig: allow use of relations other than\n    # (in)equality).\n\n    rel, v1, v2 = expr\n\n    # If both operands are strings...\n    if v1.orig_type is STRING and v2.orig_type is STRING:\n        # ...then compare them lexicographically\n        comp = _strcmp(v1.str_value, v2.str_value)\n    else:\n        # Otherwise, try to compare them as numbers\n        try:\n            comp = _sym_to_num(v1) - _sym_to_num(v2)\n        except ValueError:\n            # Fall back on a lexicographic comparison if the operands don't\n            # parse as numbers\n            comp = _strcmp(v1.str_value, v2.str_value)\n\n    return 2*(comp == 0 if rel is EQUAL else\n              comp != 0 if rel is UNEQUAL else\n              comp <  0 if rel is LESS else\n              comp <= 0 if rel is LESS_EQUAL else\n              comp >  0 if rel is GREATER else\n              comp >= 0)\n\n\ndef standard_sc_expr_str(sc):\n    \"\"\"\n    Standard symbol/choice printing function. Uses plain Kconfig syntax, and\n    displays choices as <choice> (or <choice NAME>, for named choices).\n\n    See expr_str().\n    \"\"\"\n    if sc.__class__ is Symbol:\n        if sc.is_constant and sc.name not in STR_TO_TRI:\n            return '\"{}\"'.format(escape(sc.name))\n        return sc.name\n\n    return \"<choice {}>\".format(sc.name) if sc.name else \"<choice>\"\n\n\ndef expr_str(expr, sc_expr_str_fn=standard_sc_expr_str):\n    \"\"\"\n    Returns the string representation of the expression 'expr', as in a Kconfig\n    file.\n\n    Passing subexpressions of expressions to this function works as expected.\n\n    sc_expr_str_fn (default: standard_sc_expr_str):\n      This function is called for every symbol/choice (hence \"sc\") appearing in\n      the expression, with the symbol/choice as the argument. It is expected to\n      return a string to be used for the symbol/choice.\n\n      This can be used e.g. to turn symbols/choices into links when generating\n      documentation, or for printing the value of each symbol/choice after it.\n\n      Note that quoted values are represented as constants symbols\n      (Symbol.is_constant == True).\n    \"\"\"\n    if expr.__class__ is not tuple:\n        return sc_expr_str_fn(expr)\n\n    if expr[0] is AND:\n        return \"{} && {}\".format(_parenthesize(expr[1], OR, sc_expr_str_fn),\n                                 _parenthesize(expr[2], OR, sc_expr_str_fn))\n\n    if expr[0] is OR:\n        # This turns A && B || C && D into \"(A && B) || (C && D)\", which is\n        # redundant, but more readable\n        return \"{} || {}\".format(_parenthesize(expr[1], AND, sc_expr_str_fn),\n                                 _parenthesize(expr[2], AND, sc_expr_str_fn))\n\n    if expr[0] is NOT:\n        if expr[1].__class__ is tuple:\n            return \"!({})\".format(expr_str(expr[1], sc_expr_str_fn))\n        return \"!\" + sc_expr_str_fn(expr[1])  # Symbol\n\n    # Relation\n    #\n    # Relation operands are always symbols (quoted strings are constant\n    # symbols)\n    return \"{} {} {}\".format(sc_expr_str_fn(expr[1]), REL_TO_STR[expr[0]],\n                             sc_expr_str_fn(expr[2]))\n\n\ndef expr_items(expr):\n    \"\"\"\n    Returns a set() of all items (symbols and choices) that appear in the\n    expression 'expr'.\n\n    Passing subexpressions of expressions to this function works as expected.\n    \"\"\"\n    res = set()\n\n    def rec(subexpr):\n        if subexpr.__class__ is tuple:\n            # AND, OR, NOT, or relation\n\n            rec(subexpr[1])\n\n            # NOTs only have a single operand\n            if subexpr[0] is not NOT:\n                rec(subexpr[2])\n\n        else:\n            # Symbol or choice\n            res.add(subexpr)\n\n    rec(expr)\n    return res\n\n\ndef split_expr(expr, op):\n    \"\"\"\n    Returns a list containing the top-level AND or OR operands in the\n    expression 'expr', in the same (left-to-right) order as they appear in\n    the expression.\n\n    This can be handy e.g. for splitting (weak) reverse dependencies\n    from 'select' and 'imply' into individual selects/implies.\n\n    op:\n      Either AND to get AND operands, or OR to get OR operands.\n\n      (Having this as an operand might be more future-safe than having two\n      hardcoded functions.)\n\n\n    Pseudo-code examples:\n\n      split_expr( A                    , OR  )  ->  [A]\n      split_expr( A && B               , OR  )  ->  [A && B]\n      split_expr( A || B               , OR  )  ->  [A, B]\n      split_expr( A || B               , AND )  ->  [A || B]\n      split_expr( A || B || (C && D)   , OR  )  ->  [A, B, C && D]\n\n      # Second || is not at the top level\n      split_expr( A || (B && (C || D)) , OR )  ->  [A, B && (C || D)]\n\n      # Parentheses don't matter as long as we stay at the top level (don't\n      # encounter any non-'op' nodes)\n      split_expr( (A || B) || C        , OR )  ->  [A, B, C]\n      split_expr( A || (B || C)        , OR )  ->  [A, B, C]\n    \"\"\"\n    res = []\n\n    def rec(subexpr):\n        if subexpr.__class__ is tuple and subexpr[0] is op:\n            rec(subexpr[1])\n            rec(subexpr[2])\n        else:\n            res.append(subexpr)\n\n    rec(expr)\n    return res\n\n\ndef escape(s):\n    r\"\"\"\n    Escapes the string 's' in the same fashion as is done for display in\n    Kconfig format and when writing strings to a .config file. \" and \\ are\n    replaced by \\\" and \\\\, respectively.\n    \"\"\"\n    # \\ must be escaped before \" to avoid double escaping\n    return s.replace(\"\\\\\", r\"\\\\\").replace('\"', r'\\\"')\n\n\ndef unescape(s):\n    r\"\"\"\n    Unescapes the string 's'. \\ followed by any character is replaced with just\n    that character. Used internally when reading .config files.\n    \"\"\"\n    return _unescape_sub(r\"\\1\", s)\n\n# unescape() helper\n_unescape_sub = re.compile(r\"\\\\(.)\").sub\n\n\ndef standard_kconfig(description=None):\n    \"\"\"\n    Argument parsing helper for tools that take a single optional Kconfig file\n    argument (default: Kconfig). Returns the Kconfig instance for the parsed\n    configuration. Uses argparse internally.\n\n    Exits with sys.exit() (which raises SystemExit) on errors.\n\n    description (default: None):\n      The 'description' passed to argparse.ArgumentParser().\n      argparse.RawDescriptionHelpFormatter is used, so formatting is preserved.\n    \"\"\"\n    import argparse\n\n    parser = argparse.ArgumentParser(\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n        description=description)\n\n    parser.add_argument(\n        \"kconfig\",\n        metavar=\"KCONFIG\",\n        default=\"Kconfig\",\n        nargs=\"?\",\n        help=\"Top-level Kconfig file (default: Kconfig)\")\n\n    return Kconfig(parser.parse_args().kconfig, suppress_traceback=True)\n\n\ndef standard_config_filename():\n    \"\"\"\n    Helper for tools. Returns the value of KCONFIG_CONFIG (which specifies the\n    .config file to load/save) if it is set, and \".config\" otherwise.\n\n    Calling load_config() with filename=None might give the behavior you want,\n    without having to use this function.\n    \"\"\"\n    return os.getenv(\"KCONFIG_CONFIG\", \".config\")\n\n\ndef load_allconfig(kconf, filename):\n    \"\"\"\n    Use Kconfig.load_allconfig() instead, which was added in Kconfiglib 13.4.0.\n    Supported for backwards compatibility. Might be removed at some point after\n    a long period of deprecation warnings.\n    \"\"\"\n    allconfig = os.getenv(\"KCONFIG_ALLCONFIG\")\n    if allconfig is None:\n        return\n\n    def std_msg(e):\n        # \"Upcasts\" a _KconfigIOError to an IOError, removing the custom\n        # __str__() message. The standard message is better here.\n        #\n        # This might also convert an OSError to an IOError in obscure cases,\n        # but it's probably not a big deal. The distinction is shaky (see\n        # PEP-3151).\n        return IOError(e.errno, e.strerror, e.filename)\n\n    old_warn_assign_override = kconf.warn_assign_override\n    old_warn_assign_redun = kconf.warn_assign_redun\n    kconf.warn_assign_override = kconf.warn_assign_redun = False\n\n    if allconfig in (\"\", \"1\"):\n        try:\n            print(kconf.load_config(filename, False))\n        except EnvironmentError as e1:\n            try:\n                print(kconf.load_config(\"all.config\", False))\n            except EnvironmentError as e2:\n                sys.exit(\"error: KCONFIG_ALLCONFIG is set, but neither {} \"\n                         \"nor all.config could be opened: {}, {}\"\n                         .format(filename, std_msg(e1), std_msg(e2)))\n    else:\n        try:\n            print(kconf.load_config(allconfig, False))\n        except EnvironmentError as e:\n            sys.exit(\"error: KCONFIG_ALLCONFIG is set to '{}', which \"\n                     \"could not be opened: {}\"\n                     .format(allconfig, std_msg(e)))\n\n    kconf.warn_assign_override = old_warn_assign_override\n    kconf.warn_assign_redun = old_warn_assign_redun\n\n\n#\n# Internal functions\n#\n\n\ndef _visibility(sc):\n    # Symbols and Choices have a \"visibility\" that acts as an upper bound on\n    # the values a user can set for them, corresponding to the visibility in\n    # e.g. 'make menuconfig'. This function calculates the visibility for the\n    # Symbol or Choice 'sc' -- the logic is nearly identical.\n\n    vis = 0\n\n    for node in sc.nodes:\n        if node.prompt:\n            vis = max(vis, expr_value(node.prompt[1]))\n\n    if sc.__class__ is Symbol and sc.choice:\n        if sc.choice.orig_type is TRISTATE and \\\n           sc.orig_type is not TRISTATE and sc.choice.tri_value != 2:\n            # Non-tristate choice symbols are only visible in y mode\n            return 0\n\n        if sc.orig_type is TRISTATE and vis == 1 and sc.choice.tri_value == 2:\n            # Choice symbols with m visibility are not visible in y mode\n            return 0\n\n    # Promote m to y if we're dealing with a non-tristate (possibly due to\n    # modules being disabled)\n    if vis == 1 and sc.type is not TRISTATE:\n        return 2\n\n    return vis\n\n\ndef _depend_on(sc, expr):\n    # Adds 'sc' (symbol or choice) as a \"dependee\" to all symbols in 'expr'.\n    # Constant symbols in 'expr' are skipped as they can never change value\n    # anyway.\n\n    if expr.__class__ is tuple:\n        # AND, OR, NOT, or relation\n\n        _depend_on(sc, expr[1])\n\n        # NOTs only have a single operand\n        if expr[0] is not NOT:\n            _depend_on(sc, expr[2])\n\n    elif not expr.is_constant:\n        # Non-constant symbol, or choice\n        expr._dependents.add(sc)\n\n\ndef _parenthesize(expr, type_, sc_expr_str_fn):\n    # expr_str() helper. Adds parentheses around expressions of type 'type_'.\n\n    if expr.__class__ is tuple and expr[0] is type_:\n        return \"({})\".format(expr_str(expr, sc_expr_str_fn))\n    return expr_str(expr, sc_expr_str_fn)\n\n\ndef _ordered_unique(lst):\n    # Returns 'lst' with any duplicates removed, preserving order. This hacky\n    # version seems to be a common idiom. It relies on short-circuit evaluation\n    # and set.add() returning None, which is falsy.\n\n    seen = set()\n    seen_add = seen.add\n    return [x for x in lst if x not in seen and not seen_add(x)]\n\n\ndef _is_base_n(s, n):\n    try:\n        int(s, n)\n        return True\n    except ValueError:\n        return False\n\n\ndef _strcmp(s1, s2):\n    # strcmp()-alike that returns -1, 0, or 1\n\n    return (s1 > s2) - (s1 < s2)\n\n\ndef _sym_to_num(sym):\n    # expr_value() helper for converting a symbol to a number. Raises\n    # ValueError for symbols that can't be converted.\n\n    # For BOOL and TRISTATE, n/m/y count as 0/1/2. This mirrors 9059a3493ef\n    # (\"kconfig: fix relational operators for bool and tristate symbols\") in\n    # the C implementation.\n    return sym.tri_value if sym.orig_type in _BOOL_TRISTATE else \\\n           int(sym.str_value, _TYPE_TO_BASE[sym.orig_type])\n\n\ndef _touch_dep_file(path, sym_name):\n    # If sym_name is MY_SYM_NAME, touches my/sym/name.h. See the sync_deps()\n    # docstring.\n\n    sym_path = path + os.sep + sym_name.lower().replace(\"_\", os.sep) + \".h\"\n    sym_path_dir = dirname(sym_path)\n    if not exists(sym_path_dir):\n        os.makedirs(sym_path_dir, 0o755)\n\n    # A kind of truncating touch, mirroring the C tools\n    os.close(os.open(\n        sym_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o644))\n\n\ndef _save_old(path):\n    # See write_config()\n\n    def copy(src, dst):\n        # Import as needed, to save some startup time\n        import shutil\n        shutil.copyfile(src, dst)\n\n    if islink(path):\n        # Preserve symlinks\n        copy_fn = copy\n    elif hasattr(os, \"replace\"):\n        # Python 3 (3.3+) only. Best choice when available, because it\n        # removes <filename>.old on both *nix and Windows.\n        copy_fn = os.replace\n    elif os.name == \"posix\":\n        # Removes <filename>.old on POSIX systems\n        copy_fn = os.rename\n    else:\n        # Fall back on copying\n        copy_fn = copy\n\n    try:\n        copy_fn(path, path + \".old\")\n    except Exception:\n        # Ignore errors from 'path' missing as well as other errors.\n        # <filename>.old file is usually more of a nice-to-have, and not worth\n        # erroring out over e.g. if <filename>.old happens to be a directory or\n        # <filename> is something like /dev/null.\n        pass\n\n\ndef _locs(sc):\n    # Symbol/Choice.name_and_loc helper. Returns the \"(defined at ...)\" part of\n    # the string. 'sc' is a Symbol or Choice.\n\n    if sc.nodes:\n        return \"(defined at {})\".format(\n            \", \".join(\"{0.filename}:{0.linenr}\".format(node)\n                      for node in sc.nodes))\n\n    return \"(undefined)\"\n\n\n# Menu manipulation\n\n\ndef _expr_depends_on(expr, sym):\n    # Reimplementation of expr_depends_symbol() from mconf.c. Used to determine\n    # if a submenu should be implicitly created. This also influences which\n    # items inside choice statements are considered choice items.\n\n    if expr.__class__ is not tuple:\n        return expr is sym\n\n    if expr[0] in _EQUAL_UNEQUAL:\n        # Check for one of the following:\n        # sym = m/y, m/y = sym, sym != n, n != sym\n\n        left, right = expr[1:]\n\n        if right is sym:\n            left, right = right, left\n        elif left is not sym:\n            return False\n\n        return (expr[0] is EQUAL and right is sym.kconfig.m or\n                                     right is sym.kconfig.y) or \\\n               (expr[0] is UNEQUAL and right is sym.kconfig.n)\n\n    return expr[0] is AND and \\\n           (_expr_depends_on(expr[1], sym) or\n            _expr_depends_on(expr[2], sym))\n\n\ndef _auto_menu_dep(node1, node2):\n    # Returns True if node2 has an \"automatic menu dependency\" on node1. If\n    # node2 has a prompt, we check its condition. Otherwise, we look directly\n    # at node2.dep.\n\n    return _expr_depends_on(node2.prompt[1] if node2.prompt else node2.dep,\n                            node1.item)\n\n\ndef _flatten(node):\n    # \"Flattens\" menu nodes without prompts (e.g. 'if' nodes and non-visible\n    # symbols with children from automatic menu creation) so that their\n    # children appear after them instead. This gives a clean menu structure\n    # with no unexpected \"jumps\" in the indentation.\n    #\n    # Do not flatten promptless choices (which can appear \"legitimately\" if a\n    # named choice is defined in multiple locations to add on symbols). It\n    # looks confusing, and the menuconfig already shows all choice symbols if\n    # you enter the choice at some location with a prompt.\n\n    while node:\n        if node.list and not node.prompt and \\\n           node.item.__class__ is not Choice:\n\n            last_node = node.list\n            while 1:\n                last_node.parent = node.parent\n                if not last_node.next:\n                    break\n                last_node = last_node.next\n\n            last_node.next = node.next\n            node.next = node.list\n            node.list = None\n\n        node = node.next\n\n\ndef _remove_ifs(node):\n    # Removes 'if' nodes (which can be recognized by MenuNode.item being None),\n    # which are assumed to already have been flattened. The C implementation\n    # doesn't bother to do this, but we expose the menu tree directly, and it\n    # makes it nicer to work with.\n\n    cur = node.list\n    while cur and not cur.item:\n        cur = cur.next\n\n    node.list = cur\n\n    while cur:\n        next = cur.next\n        while next and not next.item:\n            next = next.next\n\n        # Equivalent to\n        #\n        #   cur.next = next\n        #   cur = next\n        #\n        # due to tricky Python semantics. The order matters.\n        cur.next = cur = next\n\n\ndef _finalize_choice(node):\n    # Finalizes a choice, marking each symbol whose menu node has the choice as\n    # the parent as a choice symbol, and automatically determining types if not\n    # specified.\n\n    choice = node.item\n\n    cur = node.list\n    while cur:\n        if cur.item.__class__ is Symbol:\n            cur.item.choice = choice\n            choice.syms.append(cur.item)\n        cur = cur.next\n\n    # If no type is specified for the choice, its type is that of\n    # the first choice item with a specified type\n    if not choice.orig_type:\n        for item in choice.syms:\n            if item.orig_type:\n                choice.orig_type = item.orig_type\n                break\n\n    # Each choice item of UNKNOWN type gets the type of the choice\n    for sym in choice.syms:\n        if not sym.orig_type:\n            sym.orig_type = choice.orig_type\n\n\ndef _check_dep_loop_sym(sym, ignore_choice):\n    # Detects dependency loops using depth-first search on the dependency graph\n    # (which is calculated earlier in Kconfig._build_dep()).\n    #\n    # Algorithm:\n    #\n    #  1. Symbols/choices start out with _visited = 0, meaning unvisited.\n    #\n    #  2. When a symbol/choice is first visited, _visited is set to 1, meaning\n    #     \"visited, potentially part of a dependency loop\". The recursive\n    #     search then continues from the symbol/choice.\n    #\n    #  3. If we run into a symbol/choice X with _visited already set to 1,\n    #     there's a dependency loop. The loop is found on the call stack by\n    #     recording symbols while returning (\"on the way back\") until X is seen\n    #     again.\n    #\n    #  4. Once a symbol/choice and all its dependencies (or dependents in this\n    #     case) have been checked recursively without detecting any loops, its\n    #     _visited is set to 2, meaning \"visited, not part of a dependency\n    #     loop\".\n    #\n    #     This saves work if we run into the symbol/choice again in later calls\n    #     to _check_dep_loop_sym(). We just return immediately.\n    #\n    # Choices complicate things, as every choice symbol depends on every other\n    # choice symbol in a sense. When a choice is \"entered\" via a choice symbol\n    # X, we visit all choice symbols from the choice except X, and prevent\n    # immediately revisiting the choice with a flag (ignore_choice).\n    #\n    # Maybe there's a better way to handle this (different flags or the\n    # like...)\n\n    if not sym._visited:\n        # sym._visited == 0, unvisited\n\n        sym._visited = 1\n\n        for dep in sym._dependents:\n            # Choices show up in Symbol._dependents when the choice has the\n            # symbol in a 'prompt' or 'default' condition (e.g.\n            # 'default ... if SYM').\n            #\n            # Since we aren't entering the choice via a choice symbol, all\n            # choice symbols need to be checked, hence the None.\n            loop = _check_dep_loop_choice(dep, None) \\\n                   if dep.__class__ is Choice \\\n                   else _check_dep_loop_sym(dep, False)\n\n            if loop:\n                # Dependency loop found\n                return _found_dep_loop(loop, sym)\n\n        if sym.choice and not ignore_choice:\n            loop = _check_dep_loop_choice(sym.choice, sym)\n            if loop:\n                # Dependency loop found\n                return _found_dep_loop(loop, sym)\n\n        # The symbol is not part of a dependency loop\n        sym._visited = 2\n\n        # No dependency loop found\n        return None\n\n    if sym._visited == 2:\n        # The symbol was checked earlier and is already known to not be part of\n        # a dependency loop\n        return None\n\n    # sym._visited == 1, found a dependency loop. Return the symbol as the\n    # first element in it.\n    return (sym,)\n\n\ndef _check_dep_loop_choice(choice, skip):\n    if not choice._visited:\n        # choice._visited == 0, unvisited\n\n        choice._visited = 1\n\n        # Check for loops involving choice symbols. If we came here via a\n        # choice symbol, skip that one, as we'd get a false positive\n        # '<sym FOO> -> <choice> -> <sym FOO>' loop otherwise.\n        for sym in choice.syms:\n            if sym is not skip:\n                # Prevent the choice from being immediately re-entered via the\n                # \"is a choice symbol\" path by passing True\n                loop = _check_dep_loop_sym(sym, True)\n                if loop:\n                    # Dependency loop found\n                    return _found_dep_loop(loop, choice)\n\n        # The choice is not part of a dependency loop\n        choice._visited = 2\n\n        # No dependency loop found\n        return None\n\n    if choice._visited == 2:\n        # The choice was checked earlier and is already known to not be part of\n        # a dependency loop\n        return None\n\n    # choice._visited == 1, found a dependency loop. Return the choice as the\n    # first element in it.\n    return (choice,)\n\n\ndef _found_dep_loop(loop, cur):\n    # Called \"on the way back\" when we know we have a loop\n\n    # Is the symbol/choice 'cur' where the loop started?\n    if cur is not loop[0]:\n        # Nope, it's just a part of the loop\n        return loop + (cur,)\n\n    # Yep, we have the entire loop. Throw an exception that shows it.\n\n    msg = \"\\nDependency loop\\n\" \\\n            \"===============\\n\\n\"\n\n    for item in loop:\n        if item is not loop[0]:\n            msg += \"...depends on \"\n            if item.__class__ is Symbol and item.choice:\n                msg += \"the choice symbol \"\n\n        msg += \"{}, with definition...\\n\\n{}\\n\\n\" \\\n               .format(item.name_and_loc, item)\n\n        # Small wart: Since we reuse the already calculated\n        # Symbol/Choice._dependents sets for recursive dependency detection, we\n        # lose information on whether a dependency came from a 'select'/'imply'\n        # condition or e.g. a 'depends on'.\n        #\n        # This might cause selecting symbols to \"disappear\". For example,\n        # a symbol B having 'select A if C' gives a direct dependency from A to\n        # C, since it corresponds to a reverse dependency of B && C.\n        #\n        # Always print reverse dependencies for symbols that have them to make\n        # sure information isn't lost. I wonder if there's some neat way to\n        # improve this.\n\n        if item.__class__ is Symbol:\n            if item.rev_dep is not item.kconfig.n:\n                msg += \"(select-related dependencies: {})\\n\\n\" \\\n                       .format(expr_str(item.rev_dep))\n\n            if item.weak_rev_dep is not item.kconfig.n:\n                msg += \"(imply-related dependencies: {})\\n\\n\" \\\n                       .format(expr_str(item.rev_dep))\n\n    msg += \"...depends again on \" + loop[0].name_and_loc\n\n    raise KconfigError(msg)\n\n\ndef _decoding_error(e, filename, macro_linenr=None):\n    # Gives the filename and context for UnicodeDecodeError's, which are a pain\n    # to debug otherwise. 'e' is the UnicodeDecodeError object.\n    #\n    # If the decoding error is for the output of a $(shell,...) command,\n    # macro_linenr holds the line number where it was run (the exact line\n    # number isn't available for decoding errors in files).\n\n    raise KconfigError(\n        \"\\n\"\n        \"Malformed {} in {}\\n\"\n        \"Context: {}\\n\"\n        \"Problematic data: {}\\n\"\n        \"Reason: {}\".format(\n            e.encoding,\n            \"'{}'\".format(filename) if macro_linenr is None else\n                \"output from macro at {}:{}\".format(filename, macro_linenr),\n            e.object[max(e.start - 40, 0):e.end + 40],\n            e.object[e.start:e.end],\n            e.reason))\n\n\ndef _warn_verbose_deprecated(fn_name):\n    sys.stderr.write(\n        \"Deprecation warning: {0}()'s 'verbose' argument has no effect. Since \"\n        \"Kconfiglib 12.0.0, the message is returned from {0}() instead, \"\n        \"and is always generated. Do e.g. print(kconf.{0}()) if you want to \"\n        \"want to show a message like \\\"Loaded configuration '.config'\\\" on \"\n        \"stdout. The old API required ugly hacks to reuse messages in \"\n        \"configuration interfaces.\\n\".format(fn_name))\n\n\n# Predefined preprocessor functions\n\n\ndef _filename_fn(kconf, _):\n    return kconf.filename\n\n\ndef _lineno_fn(kconf, _):\n    return str(kconf.linenr)\n\n\ndef _info_fn(kconf, _, msg):\n    print(\"{}:{}: {}\".format(kconf.filename, kconf.linenr, msg))\n\n    return \"\"\n\n\ndef _warning_if_fn(kconf, _, cond, msg):\n    if cond == \"y\":\n        kconf._warn(msg, kconf.filename, kconf.linenr)\n\n    return \"\"\n\n\ndef _error_if_fn(kconf, _, cond, msg):\n    if cond == \"y\":\n        raise KconfigError(\"{}:{}: {}\".format(\n            kconf.filename, kconf.linenr, msg))\n\n    return \"\"\n\n\ndef _shell_fn(kconf, _, command):\n    import subprocess  # Only import as needed, to save some startup time\n\n    stdout, stderr = subprocess.Popen(\n        command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE\n    ).communicate()\n\n    if not _IS_PY2:\n        try:\n            stdout = stdout.decode(kconf._encoding)\n            stderr = stderr.decode(kconf._encoding)\n        except UnicodeDecodeError as e:\n            _decoding_error(e, kconf.filename, kconf.linenr)\n\n    if stderr:\n        kconf._warn(\"'{}' wrote to stderr: {}\".format(\n                        command, \"\\n\".join(stderr.splitlines())),\n                    kconf.filename, kconf.linenr)\n\n    # Universal newlines with splitlines() (to prevent e.g. stray \\r's in\n    # command output on Windows), trailing newline removal, and\n    # newline-to-space conversion.\n    #\n    # On Python 3 versions before 3.6, it's not possible to specify the\n    # encoding when passing universal_newlines=True to Popen() (the 'encoding'\n    # parameter was added in 3.6), so we do this manual version instead.\n    return \"\\n\".join(stdout.splitlines()).rstrip(\"\\n\").replace(\"\\n\", \" \")\n\n#\n# Global constants\n#\n\nTRI_TO_STR = {\n    0: \"n\",\n    1: \"m\",\n    2: \"y\",\n}\n\nSTR_TO_TRI = {\n    \"n\": 0,\n    \"m\": 1,\n    \"y\": 2,\n}\n\n# Constant representing that there's no cached choice selection. This is\n# distinct from a cached None (no selection). Any object that's not None or a\n# Symbol will do. We test this with 'is'.\n_NO_CACHED_SELECTION = 0\n\n# Are we running on Python 2?\n_IS_PY2 = sys.version_info[0] < 3\n\ntry:\n    _UNAME_RELEASE = os.uname()[2]\nexcept AttributeError:\n    # Only import as needed, to save some startup time\n    import platform\n    _UNAME_RELEASE = platform.uname()[2]\n\n# The token and type constants below are safe to test with 'is', which is a bit\n# faster (~30% faster on my machine, and a few % faster for total parsing\n# time), even without assuming Python's small integer optimization (which\n# caches small integer objects). The constants end up pointing to unique\n# integer objects, and since we consistently refer to them via the names below,\n# we always get the same object.\n#\n# Client code should use == though.\n\n# Tokens, with values 1, 2, ... . Avoiding 0 simplifies some checks by making\n# all tokens except empty strings truthy.\n(\n    _T_ALLNOCONFIG_Y,\n    _T_AND,\n    _T_BOOL,\n    _T_CHOICE,\n    _T_CLOSE_PAREN,\n    _T_COMMENT,\n    _T_CONFIG,\n    _T_DEFAULT,\n    _T_DEFCONFIG_LIST,\n    _T_DEF_BOOL,\n    _T_DEF_HEX,\n    _T_DEF_INT,\n    _T_DEF_STRING,\n    _T_DEF_TRISTATE,\n    _T_DEPENDS,\n    _T_ENDCHOICE,\n    _T_ENDIF,\n    _T_ENDMENU,\n    _T_ENV,\n    _T_EQUAL,\n    _T_GREATER,\n    _T_GREATER_EQUAL,\n    _T_HELP,\n    _T_HEX,\n    _T_IF,\n    _T_IMPLY,\n    _T_INT,\n    _T_LESS,\n    _T_LESS_EQUAL,\n    _T_MAINMENU,\n    _T_MENU,\n    _T_MENUCONFIG,\n    _T_MODULES,\n    _T_NOT,\n    _T_ON,\n    _T_OPEN_PAREN,\n    _T_OPTION,\n    _T_OPTIONAL,\n    _T_OR,\n    _T_ORSOURCE,\n    _T_OSOURCE,\n    _T_PROMPT,\n    _T_RANGE,\n    _T_RSOURCE,\n    _T_SELECT,\n    _T_SOURCE,\n    _T_STRING,\n    _T_TRISTATE,\n    _T_UNEQUAL,\n    _T_VISIBLE,\n) = range(1, 51)\n\n# Keyword to token map, with the get() method assigned directly as a small\n# optimization\n_get_keyword = {\n    \"---help---\":     _T_HELP,\n    \"allnoconfig_y\":  _T_ALLNOCONFIG_Y,\n    \"bool\":           _T_BOOL,\n    \"boolean\":        _T_BOOL,\n    \"choice\":         _T_CHOICE,\n    \"comment\":        _T_COMMENT,\n    \"config\":         _T_CONFIG,\n    \"def_bool\":       _T_DEF_BOOL,\n    \"def_hex\":        _T_DEF_HEX,\n    \"def_int\":        _T_DEF_INT,\n    \"def_string\":     _T_DEF_STRING,\n    \"def_tristate\":   _T_DEF_TRISTATE,\n    \"default\":        _T_DEFAULT,\n    \"defconfig_list\": _T_DEFCONFIG_LIST,\n    \"depends\":        _T_DEPENDS,\n    \"endchoice\":      _T_ENDCHOICE,\n    \"endif\":          _T_ENDIF,\n    \"endmenu\":        _T_ENDMENU,\n    \"env\":            _T_ENV,\n    \"grsource\":       _T_ORSOURCE,  # Backwards compatibility\n    \"gsource\":        _T_OSOURCE,   # Backwards compatibility\n    \"help\":           _T_HELP,\n    \"hex\":            _T_HEX,\n    \"if\":             _T_IF,\n    \"imply\":          _T_IMPLY,\n    \"int\":            _T_INT,\n    \"mainmenu\":       _T_MAINMENU,\n    \"menu\":           _T_MENU,\n    \"menuconfig\":     _T_MENUCONFIG,\n    \"modules\":        _T_MODULES,\n    \"on\":             _T_ON,\n    \"option\":         _T_OPTION,\n    \"optional\":       _T_OPTIONAL,\n    \"orsource\":       _T_ORSOURCE,\n    \"osource\":        _T_OSOURCE,\n    \"prompt\":         _T_PROMPT,\n    \"range\":          _T_RANGE,\n    \"rsource\":        _T_RSOURCE,\n    \"select\":         _T_SELECT,\n    \"source\":         _T_SOURCE,\n    \"string\":         _T_STRING,\n    \"tristate\":       _T_TRISTATE,\n    \"visible\":        _T_VISIBLE,\n}.get\n\n# The constants below match the value of the corresponding tokens to remove the\n# need for conversion\n\n# Node types\nMENU    = _T_MENU\nCOMMENT = _T_COMMENT\n\n# Expression types\nAND           = _T_AND\nOR            = _T_OR\nNOT           = _T_NOT\nEQUAL         = _T_EQUAL\nUNEQUAL       = _T_UNEQUAL\nLESS          = _T_LESS\nLESS_EQUAL    = _T_LESS_EQUAL\nGREATER       = _T_GREATER\nGREATER_EQUAL = _T_GREATER_EQUAL\n\nREL_TO_STR = {\n    EQUAL:         \"=\",\n    UNEQUAL:       \"!=\",\n    LESS:          \"<\",\n    LESS_EQUAL:    \"<=\",\n    GREATER:       \">\",\n    GREATER_EQUAL: \">=\",\n}\n\n# Symbol/choice types. UNKNOWN is 0 (falsy) to simplify some checks.\n# Client code shouldn't rely on it though, as it was non-zero in\n# older versions.\nUNKNOWN  = 0\nBOOL     = _T_BOOL\nTRISTATE = _T_TRISTATE\nSTRING   = _T_STRING\nINT      = _T_INT\nHEX      = _T_HEX\n\nTYPE_TO_STR = {\n    UNKNOWN:  \"unknown\",\n    BOOL:     \"bool\",\n    TRISTATE: \"tristate\",\n    STRING:   \"string\",\n    INT:      \"int\",\n    HEX:      \"hex\",\n}\n\n# Used in comparisons. 0 means the base is inferred from the format of the\n# string.\n_TYPE_TO_BASE = {\n    HEX:      16,\n    INT:      10,\n    STRING:   0,\n    UNKNOWN:  0,\n}\n\n# def_bool -> BOOL, etc.\n_DEF_TOKEN_TO_TYPE = {\n    _T_DEF_BOOL:     BOOL,\n    _T_DEF_HEX:      HEX,\n    _T_DEF_INT:      INT,\n    _T_DEF_STRING:   STRING,\n    _T_DEF_TRISTATE: TRISTATE,\n}\n\n# Tokens after which strings are expected. This is used to tell strings from\n# constant symbol references during tokenization, both of which are enclosed in\n# quotes.\n#\n# Identifier-like lexemes (\"missing quotes\") are also treated as strings after\n# these tokens. _T_CHOICE is included to avoid symbols being registered for\n# named choices.\n_STRING_LEX = frozenset({\n    _T_BOOL,\n    _T_CHOICE,\n    _T_COMMENT,\n    _T_HEX,\n    _T_INT,\n    _T_MAINMENU,\n    _T_MENU,\n    _T_ORSOURCE,\n    _T_OSOURCE,\n    _T_PROMPT,\n    _T_RSOURCE,\n    _T_SOURCE,\n    _T_STRING,\n    _T_TRISTATE,\n})\n\n# Various sets for quick membership tests. Gives a single global lookup and\n# avoids creating temporary dicts/tuples.\n\n_TYPE_TOKENS = frozenset({\n    _T_BOOL,\n    _T_TRISTATE,\n    _T_INT,\n    _T_HEX,\n    _T_STRING,\n})\n\n_SOURCE_TOKENS = frozenset({\n    _T_SOURCE,\n    _T_RSOURCE,\n    _T_OSOURCE,\n    _T_ORSOURCE,\n})\n\n_REL_SOURCE_TOKENS = frozenset({\n    _T_RSOURCE,\n    _T_ORSOURCE,\n})\n\n# Obligatory (non-optional) sources\n_OBL_SOURCE_TOKENS = frozenset({\n    _T_SOURCE,\n    _T_RSOURCE,\n})\n\n_BOOL_TRISTATE = frozenset({\n    BOOL,\n    TRISTATE,\n})\n\n_BOOL_TRISTATE_UNKNOWN = frozenset({\n    BOOL,\n    TRISTATE,\n    UNKNOWN,\n})\n\n_INT_HEX = frozenset({\n    INT,\n    HEX,\n})\n\n_SYMBOL_CHOICE = frozenset({\n    Symbol,\n    Choice,\n})\n\n_MENU_COMMENT = frozenset({\n    MENU,\n    COMMENT,\n})\n\n_EQUAL_UNEQUAL = frozenset({\n    EQUAL,\n    UNEQUAL,\n})\n\n_RELATIONS = frozenset({\n    EQUAL,\n    UNEQUAL,\n    LESS,\n    LESS_EQUAL,\n    GREATER,\n    GREATER_EQUAL,\n})\n\n# Helper functions for getting compiled regular expressions, with the needed\n# matching function returned directly as a small optimization.\n#\n# Use ASCII regex matching on Python 3. It's already the default on Python 2.\n\n\ndef _re_match(regex):\n    return re.compile(regex, 0 if _IS_PY2 else re.ASCII).match\n\n\ndef _re_search(regex):\n    return re.compile(regex, 0 if _IS_PY2 else re.ASCII).search\n\n\n# Various regular expressions used during parsing\n\n# The initial token on a line. Also eats leading and trailing whitespace, so\n# that we can jump straight to the next token (or to the end of the line if\n# there is only one token).\n#\n# This regex will also fail to match for empty lines and comment lines.\n#\n# '$' is included to detect preprocessor variable assignments with macro\n# expansions in the left-hand side.\n_command_match = _re_match(r\"\\s*([A-Za-z0-9_$-]+)\\s*\")\n\n# An identifier/keyword after the first token. Also eats trailing whitespace.\n# '$' is included to detect identifiers containing macro expansions.\n_id_keyword_match = _re_match(r\"([A-Za-z0-9_$/.-]+)\\s*\")\n\n# A fragment in the left-hand side of a preprocessor variable assignment. These\n# are the portions between macro expansions ($(foo)). Macros are supported in\n# the LHS (variable name).\n_assignment_lhs_fragment_match = _re_match(\"[A-Za-z0-9_-]*\")\n\n# The assignment operator and value (right-hand side) in a preprocessor\n# variable assignment\n_assignment_rhs_match = _re_match(r\"\\s*(=|:=|\\+=)\\s*(.*)\")\n\n# Special characters/strings while expanding a macro ('(', ')', ',', and '$(')\n_macro_special_search = _re_search(r\"\\(|\\)|,|\\$\\(\")\n\n# Special characters/strings while expanding a string (quotes, '\\', and '$(')\n_string_special_search = _re_search(r'\"|\\'|\\\\|\\$\\(')\n\n# Special characters/strings while expanding a symbol name. Also includes\n# end-of-line, in case the macro is the last thing on the line.\n_name_special_search = _re_search(r'[^A-Za-z0-9_$/.-]|\\$\\(|$')\n\n# A valid right-hand side for an assignment to a string symbol in a .config\n# file, including escaped characters. Extracts the contents.\n_conf_string_match = _re_match(r'\"((?:[^\\\\\"]|\\\\.)*)\"')\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/menuconfig.py",
    "content": "#!/usr/bin/env python3\n\n# Copyright (c) 2018-2019, Nordic Semiconductor ASA and Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nOverview\n========\n\nA curses-based Python 2/3 menuconfig implementation. The interface should feel\nfamiliar to people used to mconf ('make menuconfig').\n\nSupports the same keys as mconf, and also supports a set of keybindings\ninspired by Vi:\n\n  J/K     : Down/Up\n  L       : Enter menu/Toggle item\n  H       : Leave menu\n  Ctrl-D/U: Page Down/Page Up\n  G/End   : Jump to end of list\n  g/Home  : Jump to beginning of list\n\n[Space] toggles values if possible, and enters menus otherwise. [Enter] works\nthe other way around.\n\nThe mconf feature where pressing a key jumps to a menu entry with that\ncharacter in it in the current menu isn't supported. A jump-to feature for\njumping directly to any symbol (including invisible symbols), choice, menu or\ncomment (as in a Kconfig 'comment \"Foo\"') is available instead.\n\nA few different modes are available:\n\n  F: Toggle show-help mode, which shows the help text of the currently selected\n  item in the window at the bottom of the menu display. This is handy when\n  browsing through options.\n\n  C: Toggle show-name mode, which shows the symbol name before each symbol menu\n  entry\n\n  A: Toggle show-all mode, which shows all items, including currently invisible\n  items and items that lack a prompt. Invisible items are drawn in a different\n  style to make them stand out.\n\n\nRunning\n=======\n\nmenuconfig.py can be run either as a standalone executable or by calling the\nmenuconfig() function with an existing Kconfig instance. The second option is a\nbit inflexible in that it will still load and save .config, etc.\n\nWhen run in standalone mode, the top-level Kconfig file to load can be passed\nas a command-line argument. With no argument, it defaults to \"Kconfig\".\n\nThe KCONFIG_CONFIG environment variable specifies the .config file to load (if\nit exists) and save. If KCONFIG_CONFIG is unset, \".config\" is used.\n\nWhen overwriting a configuration file, the old version is saved to\n<filename>.old (e.g. .config.old).\n\n$srctree is supported through Kconfiglib.\n\n\nColor schemes\n=============\n\nIt is possible to customize the color scheme by setting the MENUCONFIG_STYLE\nenvironment variable. For example, setting it to 'aquatic' will enable an\nalternative, less yellow, more 'make menuconfig'-like color scheme, contributed\nby Mitja Horvat (pinkfluid).\n\nThis is the current list of built-in styles:\n    - default       classic Kconfiglib theme with a yellow accent\n    - monochrome    colorless theme (uses only bold and standout) attributes,\n                    this style is used if the terminal doesn't support colors\n    - aquatic       blue-tinted style loosely resembling the lxdialog theme\n\nIt is possible to customize the current style by changing colors of UI\nelements on the screen. This is the list of elements that can be stylized:\n\n    - path          Top row in the main display, with the menu path\n    - separator     Separator lines between windows. Also used for the top line\n                    in the symbol information display.\n    - list          List of items, e.g. the main display\n    - selection     Style for the selected item\n    - inv-list      Like list, but for invisible items. Used in show-all mode.\n    - inv-selection Like selection, but for invisible items. Used in show-all\n                    mode.\n    - help          Help text windows at the bottom of various fullscreen\n                    dialogs\n    - show-help     Window showing the help text in show-help mode\n    - frame         Frame around dialog boxes\n    - body          Body of dialog boxes\n    - edit          Edit box in pop-up dialogs\n    - jump-edit     Edit box in jump-to dialog\n    - text          Symbol information text\n\nThe color definition is a comma separated list of attributes:\n\n    - fg:COLOR      Set the foreground/background colors. COLOR can be one of\n      * or *        the basic 16 colors (black, red, green, yellow, blue,\n    - bg:COLOR      magenta, cyan, white and brighter versions, for example,\n                    brightred). On terminals that support more than 8 colors,\n                    you can also directly put in a color number, e.g. fg:123\n                    (hexadecimal and octal constants are accepted as well).\n                    Colors outside the range -1..curses.COLORS-1 (which is\n                    terminal-dependent) are ignored (with a warning). The COLOR\n                    can be also specified using a RGB value in the HTML\n                    notation, for example #RRGGBB. If the terminal supports\n                    color changing, the color is rendered accurately.\n                    Otherwise, the visually nearest color is used.\n\n                    If the background or foreground color of an element is not\n                    specified, it defaults to -1, representing the default\n                    terminal foreground or background color.\n\n                    Note: On some terminals a bright version of the color\n                    implies bold.\n    - bold          Use bold text\n    - underline     Use underline text\n    - standout      Standout text attribute (reverse color)\n\nMore often than not, some UI elements share the same color definition. In such\ncases the right value may specify an UI element from which the color definition\nwill be copied. For example, \"separator=help\" will apply the current color\ndefinition for \"help\" to \"separator\".\n\nA keyword without the '=' is assumed to be a style template. The template name\nis looked up in the built-in styles list and the style definition is expanded\nin-place. With this, built-in styles can be used as basis for new styles.\n\nFor example, take the aquatic theme and give it a red selection bar:\n\nMENUCONFIG_STYLE=\"aquatic selection=fg:white,bg:red\"\n\nIf there's an error in the style definition or if a missing style is assigned\nto, the assignment will be ignored, along with a warning being printed on\nstderr.\n\nThe 'default' theme is always implicitly parsed first, so the following two\nsettings have the same effect:\n\n    MENUCONFIG_STYLE=\"selection=fg:white,bg:red\"\n    MENUCONFIG_STYLE=\"default selection=fg:white,bg:red\"\n\nIf the terminal doesn't support colors, the 'monochrome' theme is used, and\nMENUCONFIG_STYLE is ignored. The assumption is that the environment is broken\nsomehow, and that the important thing is to get something usable.\n\n\nOther features\n==============\n\n  - Seamless terminal resizing\n\n  - No dependencies on *nix, as the 'curses' module is in the Python standard\n    library\n\n  - Unicode text entry\n\n  - Improved information screen compared to mconf:\n\n      * Expressions are split up by their top-level &&/|| operands to improve\n        readability\n\n      * Undefined symbols in expressions are pointed out\n\n      * Menus and comments have information displays\n\n      * Kconfig definitions are printed\n\n      * The include path is shown, listing the locations of the 'source'\n        statements that included the Kconfig file of the symbol (or other\n        item)\n\n\nLimitations\n===========\n\nDoesn't work out of the box on Windows, but can be made to work with\n\n    pip install windows-curses\n\nSee the https://github.com/zephyrproject-rtos/windows-curses repository.\n\"\"\"\nfrom __future__ import print_function\n\nimport os\nimport sys\n\n_IS_WINDOWS = os.name == \"nt\"  # Are we running on Windows?\n\ntry:\n    import curses\nexcept ImportError as e:\n    if not _IS_WINDOWS:\n        raise\n    sys.exit(\"\"\"\\\nmenuconfig failed to import the standard Python 'curses' library. Try\ninstalling a package like windows-curses\n(https://github.com/zephyrproject-rtos/windows-curses) by running this command\nin cmd.exe:\n\n    pip install windows-curses\n\nStarting with Kconfiglib 13.0.0, windows-curses is no longer automatically\ninstalled when installing Kconfiglib via pip on Windows (because it breaks\ninstallation on MSYS2).\n\nException:\n{}: {}\"\"\".format(type(e).__name__, e))\n\nimport errno\nimport locale\nimport re\nimport textwrap\n\nfrom kconfiglib import Symbol, Choice, MENU, COMMENT, MenuNode, \\\n                       BOOL, TRISTATE, STRING, INT, HEX, \\\n                       AND, OR, \\\n                       expr_str, expr_value, split_expr, \\\n                       standard_sc_expr_str, \\\n                       TRI_TO_STR, TYPE_TO_STR, \\\n                       standard_kconfig, standard_config_filename\n\n\n#\n# Configuration variables\n#\n\n# If True, try to change LC_CTYPE to a UTF-8 locale if it is set to the C\n# locale (which implies ASCII). This fixes curses Unicode I/O issues on systems\n# with bad defaults. ncurses configures itself from the locale settings.\n#\n# Related PEP: https://www.python.org/dev/peps/pep-0538/\n_CHANGE_C_LC_CTYPE_TO_UTF8 = True\n\n# How many steps an implicit submenu will be indented. Implicit submenus are\n# created when an item depends on the symbol before it. Note that symbols\n# defined with 'menuconfig' create a separate menu instead of indenting.\n_SUBMENU_INDENT = 4\n\n# Number of steps for Page Up/Down to jump\n_PG_JUMP = 6\n\n# Height of the help window in show-help mode\n_SHOW_HELP_HEIGHT = 8\n\n# How far the cursor needs to be from the edge of the window before it starts\n# to scroll. Used for the main menu display, the information display, the\n# search display, and for text boxes.\n_SCROLL_OFFSET = 5\n\n# Minimum width of dialogs that ask for text input\n_INPUT_DIALOG_MIN_WIDTH = 30\n\n# Number of arrows pointing up/down to draw when a window is scrolled\n_N_SCROLL_ARROWS = 14\n\n# Lines of help text shown at the bottom of the \"main\" display\n_MAIN_HELP_LINES = \"\"\"\n[Space/Enter] Toggle/enter  [ESC] Leave menu           [S] Save\n[O] Load                    [?] Symbol info            [/] Jump to symbol\n[F] Toggle show-help mode   [C] Toggle show-name mode  [A] Toggle show-all mode\n[Q] Quit (prompts for save) [D] Save minimal config (advanced)\n\"\"\"[1:-1].split(\"\\n\")\n\n# Lines of help text shown at the bottom of the information dialog\n_INFO_HELP_LINES = \"\"\"\n[ESC/q] Return to menu      [/] Jump to symbol\n\"\"\"[1:-1].split(\"\\n\")\n\n# Lines of help text shown at the bottom of the search dialog\n_JUMP_TO_HELP_LINES = \"\"\"\nType text to narrow the search. Regexes are supported (via Python's 're'\nmodule). The up/down cursor keys step in the list. [Enter] jumps to the\nselected symbol. [ESC] aborts the search. Type multiple space-separated\nstrings/regexes to find entries that match all of them. Type Ctrl-F to\nview the help of the selected item without leaving the dialog.\n\"\"\"[1:-1].split(\"\\n\")\n\n#\n# Styling\n#\n\n_STYLES = {\n    \"default\": \"\"\"\n    path=fg:black,bg:white,bold\n    separator=fg:black,bg:yellow,bold\n    list=fg:black,bg:white\n    selection=fg:white,bg:blue,bold\n    inv-list=fg:red,bg:white\n    inv-selection=fg:red,bg:blue\n    help=path\n    show-help=list\n    frame=fg:black,bg:yellow,bold\n    body=fg:white,bg:black\n    edit=fg:white,bg:blue\n    jump-edit=edit\n    text=list\n    \"\"\",\n\n    # This style is forced on terminals that do no support colors\n    \"monochrome\": \"\"\"\n    path=bold\n    separator=bold,standout\n    list=\n    selection=bold,standout\n    inv-list=bold\n    inv-selection=bold,standout\n    help=bold\n    show-help=\n    frame=bold,standout\n    body=\n    edit=standout\n    jump-edit=\n    text=\n    \"\"\",\n\n    # Blue-tinted style loosely resembling lxdialog\n    \"aquatic\": \"\"\"\n    path=fg:white,bg:blue\n    separator=fg:white,bg:cyan\n    help=path\n    frame=fg:white,bg:cyan\n    body=fg:white,bg:blue\n    edit=fg:black,bg:white\n    \"\"\"\n}\n\n_NAMED_COLORS = {\n    # Basic colors\n    \"black\":         curses.COLOR_BLACK,\n    \"red\":           curses.COLOR_RED,\n    \"green\":         curses.COLOR_GREEN,\n    \"yellow\":        curses.COLOR_YELLOW,\n    \"blue\":          curses.COLOR_BLUE,\n    \"magenta\":       curses.COLOR_MAGENTA,\n    \"cyan\":          curses.COLOR_CYAN,\n    \"white\":         curses.COLOR_WHITE,\n\n    # Bright versions\n    \"brightblack\":   curses.COLOR_BLACK + 8,\n    \"brightred\":     curses.COLOR_RED + 8,\n    \"brightgreen\":   curses.COLOR_GREEN + 8,\n    \"brightyellow\":  curses.COLOR_YELLOW + 8,\n    \"brightblue\":    curses.COLOR_BLUE + 8,\n    \"brightmagenta\": curses.COLOR_MAGENTA + 8,\n    \"brightcyan\":    curses.COLOR_CYAN + 8,\n    \"brightwhite\":   curses.COLOR_WHITE + 8,\n\n    # Aliases\n    \"purple\":        curses.COLOR_MAGENTA,\n    \"brightpurple\":  curses.COLOR_MAGENTA + 8,\n}\n\n\ndef _rgb_to_6cube(rgb):\n    # Converts an 888 RGB color to a 3-tuple (nice in that it's hashable)\n    # representing the closest xterm 256-color 6x6x6 color cube color.\n    #\n    # The xterm 256-color extension uses a RGB color palette with components in\n    # the range 0-5 (a 6x6x6 cube). The catch is that the mapping is nonlinear.\n    # Index 0 in the 6x6x6 cube is mapped to 0, index 1 to 95, then 135, 175,\n    # etc., in increments of 40. See the links below:\n    #\n    #   https://commons.wikimedia.org/wiki/File:Xterm_256color_chart.svg\n    #   https://github.com/tmux/tmux/blob/master/colour.c\n\n    # 48 is the middle ground between 0 and 95.\n    return tuple(0 if x < 48 else int(round(max(1, (x - 55)/40))) for x in rgb)\n\n\ndef _6cube_to_rgb(r6g6b6):\n    # Returns the 888 RGB color for a 666 xterm color cube index\n\n    return tuple(0 if x == 0 else 40*x + 55 for x in r6g6b6)\n\n\ndef _rgb_to_gray(rgb):\n    # Converts an 888 RGB color to the index of an xterm 256-color grayscale\n    # color with approx. the same perceived brightness\n\n    # Calculate the luminance (gray intensity) of the color. See\n    #   https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color\n    # and\n    #   https://www.w3.org/TR/AERT/#color-contrast\n    luma = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]\n\n    # Closest index in the grayscale palette, which starts at RGB 0x080808,\n    # with stepping 0x0A0A0A\n    index = int(round((luma - 8)/10))\n\n    # Clamp the index to 0-23, corresponding to 232-255\n    return max(0, min(index, 23))\n\n\ndef _gray_to_rgb(index):\n    # Convert a grayscale index to its closet single RGB component\n\n    return 3*(10*index + 8,)  # Returns a 3-tuple\n\n\n# Obscure Python: We never pass a value for rgb2index, and it keeps pointing to\n# the same dict. This avoids a global.\ndef _alloc_rgb(rgb, rgb2index={}):\n    # Initialize a new entry in the xterm palette to the given RGB color,\n    # returning its index. If the color has already been initialized, the index\n    # of the existing entry is returned.\n    #\n    # ncurses is palette-based, so we need to overwrite palette entries to make\n    # new colors.\n    #\n    # The colors from 0 to 15 are user-defined, and there's no way to query\n    # their RGB values, so we better leave them untouched. Also leave any\n    # hypothetical colors above 255 untouched (though we're unlikely to\n    # allocate that many colors anyway).\n\n    if rgb in rgb2index:\n        return rgb2index[rgb]\n\n    # Many terminals allow the user to customize the first 16 colors. Avoid\n    # changing their values.\n    color_index = 16 + len(rgb2index)\n    if color_index >= 256:\n        _warn(\"Unable to allocate new RGB color \", rgb, \". Too many colors \"\n              \"allocated.\")\n        return 0\n\n    # Map each RGB component from the range 0-255 to the range 0-1000, which is\n    # what curses uses\n    curses.init_color(color_index, *(int(round(1000*x/255)) for x in rgb))\n    rgb2index[rgb] = color_index\n\n    return color_index\n\n\ndef _color_from_num(num):\n    # Returns the index of a color that looks like color 'num' in the xterm\n    # 256-color palette (but that might not be 'num', if we're redefining\n    # colors)\n\n    # - _alloc_rgb() won't touch the first 16 colors or any (hypothetical)\n    #   colors above 255, so we can always return them as-is\n    #\n    # - If the terminal doesn't support changing color definitions, or if\n    #   curses.COLORS < 256, _alloc_rgb() won't touch any color, and all colors\n    #   can be returned as-is\n    if num < 16 or num > 255 or not curses.can_change_color() or \\\n       curses.COLORS < 256:\n        return num\n\n    # _alloc_rgb() might redefine colors, so emulate the xterm 256-color\n    # palette by allocating new colors instead of returning color numbers\n    # directly\n\n    if num < 232:\n        num -= 16\n        return _alloc_rgb(_6cube_to_rgb(((num//36)%6, (num//6)%6, num%6)))\n\n    return _alloc_rgb(_gray_to_rgb(num - 232))\n\n\ndef _color_from_rgb(rgb):\n    # Returns the index of a color matching the 888 RGB color 'rgb'. The\n    # returned color might be an ~exact match or an approximation, depending on\n    # terminal capabilities.\n\n    # Calculates the Euclidean distance between two RGB colors\n    def dist(r1, r2): return sum((x - y)**2 for x, y in zip(r1, r2))\n\n    if curses.COLORS >= 256:\n        # Assume we're dealing with xterm's 256-color extension\n\n        if curses.can_change_color():\n            # Best case -- the terminal supports changing palette entries via\n            # curses.init_color(). Initialize an unused palette entry and\n            # return it.\n            return _alloc_rgb(rgb)\n\n        # Second best case -- pick between the xterm 256-color extension colors\n\n        # Closest 6-cube \"color\" color\n        c6 = _rgb_to_6cube(rgb)\n        # Closest gray color\n        gray = _rgb_to_gray(rgb)\n\n        if dist(rgb, _6cube_to_rgb(c6)) < dist(rgb, _gray_to_rgb(gray)):\n            # Use the \"color\" color from the 6x6x6 color palette. Calculate the\n            # color number from the 6-cube index triplet.\n            return 16 + 36*c6[0] + 6*c6[1] + c6[2]\n\n        # Use the color from the gray palette\n        return 232 + gray\n\n    # Terminal not in xterm 256-color mode. This is probably the best we can\n    # do, or is it? Submit patches. :)\n    min_dist = float('inf')\n    best = -1\n    for color in range(curses.COLORS):\n        # ncurses uses the range 0..1000. Scale that down to 0..255.\n        d = dist(rgb, tuple(int(round(255*c/1000))\n                            for c in curses.color_content(color)))\n        if d < min_dist:\n            min_dist = d\n            best = color\n\n    return best\n\n\ndef _parse_style(style_str, parsing_default):\n    # Parses a string with '<element>=<style>' assignments. Anything not\n    # containing '=' is assumed to be a reference to a built-in style, which is\n    # treated as if all the assignments from the style were inserted at that\n    # point in the string.\n    #\n    # The parsing_default flag is set to True when we're implicitly parsing the\n    # 'default'/'monochrome' style, to prevent warnings.\n\n    for sline in style_str.split():\n        # Words without a \"=\" character represents a style template\n        if \"=\" in sline:\n            key, data = sline.split(\"=\", 1)\n\n            # The 'default' style template is assumed to define all keys. We\n            # run _style_to_curses() for non-existing keys as well, so that we\n            # print warnings for errors to the right of '=' for those too.\n            if key not in _style and not parsing_default:\n                _warn(\"Ignoring non-existent style\", key)\n\n            # If data is a reference to another key, copy its style\n            if data in _style:\n                _style[key] = _style[data]\n            else:\n                _style[key] = _style_to_curses(data)\n\n        elif sline in _STYLES:\n            # Recursively parse style template. Ignore styles that don't exist,\n            # for backwards/forwards compatibility.\n            _parse_style(_STYLES[sline], parsing_default)\n\n        else:\n            _warn(\"Ignoring non-existent style template\", sline)\n\n# Dictionary mapping element types to the curses attributes used to display\n# them\n_style = {}\n\n\ndef _style_to_curses(style_def):\n    # Parses a style definition string (<element>=<style>), returning\n    # a (fg_color, bg_color, attributes) tuple.\n\n    def parse_color(color_def):\n        color_def = color_def.split(\":\", 1)[1]\n\n        # HTML format, #RRGGBB\n        if re.match(\"#[A-Fa-f0-9]{6}\", color_def):\n            return _color_from_rgb((\n                int(color_def[1:3], 16),\n                int(color_def[3:5], 16),\n                int(color_def[5:7], 16)))\n\n        if color_def in _NAMED_COLORS:\n            color_num = _color_from_num(_NAMED_COLORS[color_def])\n        else:\n            try:\n                color_num = _color_from_num(int(color_def, 0))\n            except ValueError:\n                _warn(\"Ignoring color\", color_def, \"that's neither \"\n                      \"predefined nor a number\")\n                return -1\n\n        if not -1 <= color_num < curses.COLORS:\n            _warn(\"Ignoring color {}, which is outside the range \"\n                  \"-1..curses.COLORS-1 (-1..{})\"\n                  .format(color_def, curses.COLORS - 1))\n            return -1\n\n        return color_num\n\n    fg_color = -1\n    bg_color = -1\n    attrs = 0\n\n    if style_def:\n        for field in style_def.split(\",\"):\n            if field.startswith(\"fg:\"):\n                fg_color = parse_color(field)\n            elif field.startswith(\"bg:\"):\n                bg_color = parse_color(field)\n            elif field == \"bold\":\n                # A_BOLD tends to produce faint and hard-to-read text on the\n                # Windows console, especially with the old color scheme, before\n                # the introduction of\n                # https://blogs.msdn.microsoft.com/commandline/2017/08/02/updating-the-windows-console-colors/\n                attrs |= curses.A_NORMAL if _IS_WINDOWS else curses.A_BOLD\n            elif field == \"standout\":\n                attrs |= curses.A_STANDOUT\n            elif field == \"underline\":\n                attrs |= curses.A_UNDERLINE\n            else:\n                _warn(\"Ignoring unknown style attribute\", field)\n\n    return _style_attr(fg_color, bg_color, attrs)\n\n\ndef _init_styles():\n    if curses.has_colors():\n        try:\n            curses.use_default_colors()\n        except curses.error:\n            # Ignore errors on funky terminals that support colors but not\n            # using default colors. Worst it can do is break transparency and\n            # the like. Ran across this with the MSYS2/winpty setup in\n            # https://github.com/msys2/MINGW-packages/issues/5823, though there\n            # seems to be a lot of general brokenness there.\n            pass\n\n        # Use the 'default' theme as the base, and add any user-defined style\n        # settings from the environment\n        _parse_style(\"default\", True)\n        if \"MENUCONFIG_STYLE\" in os.environ:\n            _parse_style(os.environ[\"MENUCONFIG_STYLE\"], False)\n    else:\n        # Force the 'monochrome' theme if the terminal doesn't support colors.\n        # MENUCONFIG_STYLE is likely to mess things up here (though any colors\n        # would be ignored), so ignore it.\n        _parse_style(\"monochrome\", True)\n\n\n# color_attribs holds the color pairs we've already created, indexed by a\n# (<foreground color>, <background color>) tuple.\n#\n# Obscure Python: We never pass a value for color_attribs, and it keeps\n# pointing to the same dict. This avoids a global.\ndef _style_attr(fg_color, bg_color, attribs, color_attribs={}):\n    # Returns an attribute with the specified foreground and background color\n    # and the attributes in 'attribs'. Reuses color pairs already created if\n    # possible, and creates a new color pair otherwise.\n    #\n    # Returns 'attribs' if colors aren't supported.\n\n    if not curses.has_colors():\n        return attribs\n\n    if (fg_color, bg_color) not in color_attribs:\n        # Create new color pair. Color pair number 0 is hardcoded and cannot be\n        # changed, hence the +1s.\n        curses.init_pair(len(color_attribs) + 1, fg_color, bg_color)\n        color_attribs[(fg_color, bg_color)] = \\\n            curses.color_pair(len(color_attribs) + 1)\n\n    return color_attribs[(fg_color, bg_color)] | attribs\n\n\n#\n# Main application\n#\n\n\ndef _main():\n    menuconfig(standard_kconfig(__doc__))\n\n\ndef menuconfig(kconf):\n    \"\"\"\n    Launches the configuration interface, returning after the user exits.\n\n    kconf:\n      Kconfig instance to be configured\n    \"\"\"\n    global _kconf\n    global _conf_filename\n    global _conf_changed\n    global _minconf_filename\n    global _show_all\n\n    _kconf = kconf\n\n    # Filename to save configuration to\n    _conf_filename = standard_config_filename()\n\n    # Load existing configuration and set _conf_changed True if it is outdated\n    _conf_changed = _load_config()\n\n    # Filename to save minimal configuration to\n    _minconf_filename = \"defconfig\"\n\n    # Any visible items in the top menu?\n    _show_all = False\n    if not _shown_nodes(kconf.top_node):\n        # Nothing visible. Start in show-all mode and try again.\n        _show_all = True\n        if not _shown_nodes(kconf.top_node):\n            # Give up. The implementation relies on always having a selected\n            # node.\n            print(\"Empty configuration -- nothing to configure.\\n\"\n                  \"Check that environment variables are set properly.\")\n            return\n\n    # Disable warnings. They get mangled in curses mode, and we deal with\n    # errors ourselves.\n    kconf.warn = False\n\n    # Make curses use the locale settings specified in the environment\n    locale.setlocale(locale.LC_ALL, \"\")\n\n    # Try to fix Unicode issues on systems with bad defaults\n    if _CHANGE_C_LC_CTYPE_TO_UTF8:\n        _change_c_lc_ctype_to_utf8()\n\n    # Get rid of the delay between pressing ESC and jumping to the parent menu,\n    # unless the user has set ESCDELAY (see ncurses(3)). This makes the UI much\n    # smoother to work with.\n    #\n    # Note: This is strictly pretty iffy, since escape codes for e.g. cursor\n    # keys start with ESC, but I've never seen it cause problems in practice\n    # (probably because it's unlikely that the escape code for a key would get\n    # split up across read()s, at least with a terminal emulator). Please\n    # report if you run into issues. Some suitable small default value could be\n    # used here instead in that case. Maybe it's silly to not put in the\n    # smallest imperceptible delay here already, though I don't like guessing.\n    #\n    # (From a quick glance at the ncurses source code, ESCDELAY might only be\n    # relevant for mouse events there, so maybe escapes are assumed to arrive\n    # in one piece already...)\n    os.environ.setdefault(\"ESCDELAY\", \"0\")\n\n    # Enter curses mode. _menuconfig() returns a string to print on exit, after\n    # curses has been de-initialized.\n    print(curses.wrapper(_menuconfig))\n\n\ndef _load_config():\n    # Loads any existing .config file. See the Kconfig.load_config() docstring.\n    #\n    # Returns True if .config is missing or outdated. We always prompt for\n    # saving the configuration in that case.\n\n    print(_kconf.load_config())\n    if not os.path.exists(_conf_filename):\n        # No .config\n        return True\n\n    return _needs_save()\n\n\ndef _needs_save():\n    # Returns True if a just-loaded .config file is outdated (would get\n    # modified when saving)\n\n    if _kconf.missing_syms:\n        # Assignments to undefined symbols in the .config\n        return True\n\n    for sym in _kconf.unique_defined_syms:\n        if sym.user_value is None:\n            if sym.config_string:\n                # Unwritten symbol\n                return True\n        elif sym.orig_type in (BOOL, TRISTATE):\n            if sym.tri_value != sym.user_value:\n                # Written bool/tristate symbol, new value\n                return True\n        elif sym.str_value != sym.user_value:\n            # Written string/int/hex symbol, new value\n            return True\n\n    # No need to prompt for save\n    return False\n\n\n# Global variables used below:\n#\n#   _stdscr:\n#     stdscr from curses\n#\n#   _cur_menu:\n#     Menu node of the menu (or menuconfig symbol, or choice) currently being\n#     shown\n#\n#   _shown:\n#     List of items in _cur_menu that are shown (ignoring scrolling). In\n#     show-all mode, this list contains all items in _cur_menu. Otherwise, it\n#     contains just the visible items.\n#\n#   _sel_node_i:\n#     Index in _shown of the currently selected node\n#\n#   _menu_scroll:\n#     Index in _shown of the top row of the main display\n#\n#   _parent_screen_rows:\n#     List/stack of the row numbers that the selections in the parent menus\n#     appeared on. This is used to prevent the scrolling from jumping around\n#     when going in and out of menus.\n#\n#   _show_help/_show_name/_show_all:\n#     If True, the corresponding mode is on. See the module docstring.\n#\n#   _conf_filename:\n#     File to save the configuration to\n#\n#   _minconf_filename:\n#     File to save minimal configurations to\n#\n#   _conf_changed:\n#     True if the configuration has been changed. If False, we don't bother\n#     showing the save-and-quit dialog.\n#\n#     We reset this to False whenever the configuration is saved explicitly\n#     from the save dialog.\n\n\ndef _menuconfig(stdscr):\n    # Logic for the main display, with the list of symbols, etc.\n\n    global _stdscr\n    global _conf_filename\n    global _conf_changed\n    global _minconf_filename\n    global _show_help\n    global _show_name\n\n    _stdscr = stdscr\n\n    _init()\n\n    while True:\n        _draw_main()\n        curses.doupdate()\n\n\n        c = _getch_compat(_menu_win)\n\n        if c == curses.KEY_RESIZE:\n            _resize_main()\n\n        elif c in (curses.KEY_DOWN, \"j\", \"J\"):\n            _select_next_menu_entry()\n\n        elif c in (curses.KEY_UP, \"k\", \"K\"):\n            _select_prev_menu_entry()\n\n        elif c in (curses.KEY_NPAGE, \"\\x04\"):  # Page Down/Ctrl-D\n            # Keep it simple. This way we get sane behavior for small windows,\n            # etc., for free.\n            for _ in range(_PG_JUMP):\n                _select_next_menu_entry()\n\n        elif c in (curses.KEY_PPAGE, \"\\x15\"):  # Page Up/Ctrl-U\n            for _ in range(_PG_JUMP):\n                _select_prev_menu_entry()\n\n        elif c in (curses.KEY_END, \"G\"):\n            _select_last_menu_entry()\n\n        elif c in (curses.KEY_HOME, \"g\"):\n            _select_first_menu_entry()\n\n        elif c == \" \":\n            # Toggle the node if possible\n            sel_node = _shown[_sel_node_i]\n            if not _change_node(sel_node):\n                _enter_menu(sel_node)\n\n        elif c in (curses.KEY_RIGHT, \"\\n\", \"l\", \"L\"):\n            # Enter the node if possible\n            sel_node = _shown[_sel_node_i]\n            if not _enter_menu(sel_node):\n                _change_node(sel_node)\n\n        elif c in (\"n\", \"N\"):\n            _set_sel_node_tri_val(0)\n\n        elif c in (\"m\", \"M\"):\n            _set_sel_node_tri_val(1)\n\n        elif c in (\"y\", \"Y\"):\n            _set_sel_node_tri_val(2)\n\n        elif c in (curses.KEY_LEFT, curses.KEY_BACKSPACE, _ERASE_CHAR,\n                   \"\\x1B\", \"h\", \"H\"):  # \\x1B = ESC\n\n            if c == \"\\x1B\" and _cur_menu is _kconf.top_node:\n                res = _quit_dialog()\n                if res:\n                    return res\n            else:\n                _leave_menu()\n\n        elif c in (\"o\", \"O\"):\n            _load_dialog()\n\n        elif c in (\"s\", \"S\"):\n            filename = _save_dialog(_kconf.write_config, _conf_filename,\n                                    \"configuration\")\n            if filename:\n                _conf_filename = filename\n                _conf_changed = False\n\n        elif c in (\"d\", \"D\"):\n            filename = _save_dialog(_kconf.write_min_config, _minconf_filename,\n                                    \"minimal configuration\")\n            if filename:\n                _minconf_filename = filename\n\n        elif c == \"/\":\n            _jump_to_dialog()\n            # The terminal might have been resized while the fullscreen jump-to\n            # dialog was open\n            _resize_main()\n\n        elif c == \"?\":\n            _info_dialog(_shown[_sel_node_i], False)\n            # The terminal might have been resized while the fullscreen info\n            # dialog was open\n            _resize_main()\n\n        elif c in (\"f\", \"F\"):\n            _show_help = not _show_help\n            _set_style(_help_win, \"show-help\" if _show_help else \"help\")\n            _resize_main()\n\n        elif c in (\"c\", \"C\"):\n            _show_name = not _show_name\n\n        elif c in (\"a\", \"A\"):\n            _toggle_show_all()\n\n        elif c in (\"q\", \"Q\"):\n            res = _quit_dialog()\n            if res:\n                return res\n\n\ndef _quit_dialog():\n    if not _conf_changed:\n        return \"No changes to save (for '{}')\".format(_conf_filename)\n\n    while True:\n        c = _key_dialog(\n            \"Quit\",\n            \" Save configuration?\\n\"\n            \"\\n\"\n            \"(Y)es  (N)o  (C)ancel\",\n            \"ync\")\n\n        if c is None or c == \"c\":\n            return None\n\n        if c == \"y\":\n            # Returns a message to print\n            msg = _try_save(_kconf.write_config, _conf_filename, \"configuration\")\n            if msg:\n                return msg\n\n        elif c == \"n\":\n            return \"Configuration ({}) was not saved\".format(_conf_filename)\n\n\ndef _init():\n    # Initializes the main display with the list of symbols, etc. Also does\n    # misc. global initialization that needs to happen after initializing\n    # curses.\n\n    global _ERASE_CHAR\n\n    global _path_win\n    global _top_sep_win\n    global _menu_win\n    global _bot_sep_win\n    global _help_win\n\n    global _parent_screen_rows\n    global _cur_menu\n    global _shown\n    global _sel_node_i\n    global _menu_scroll\n\n    global _show_help\n    global _show_name\n\n    # Looking for this in addition to KEY_BACKSPACE (which is unreliable) makes\n    # backspace work with TERM=vt100. That makes it likely to work in sane\n    # environments.\n    _ERASE_CHAR = curses.erasechar()\n    if sys.version_info[0] >= 3:\n        # erasechar() returns a one-byte bytes object on Python 3. This sets\n        # _ERASE_CHAR to a blank string if it can't be decoded, which should be\n        # harmless.\n        _ERASE_CHAR = _ERASE_CHAR.decode(\"utf-8\", \"ignore\")\n\n    _init_styles()\n\n    # Hide the cursor\n    _safe_curs_set(0)\n\n    # Initialize windows\n\n    # Top row, with menu path\n    _path_win = _styled_win(\"path\")\n\n    # Separator below menu path, with title and arrows pointing up\n    _top_sep_win = _styled_win(\"separator\")\n\n    # List of menu entries with symbols, etc.\n    _menu_win = _styled_win(\"list\")\n    _menu_win.keypad(True)\n\n    # Row below menu list, with arrows pointing down\n    _bot_sep_win = _styled_win(\"separator\")\n\n    # Help window with keys at the bottom. Shows help texts in show-help mode.\n    _help_win = _styled_win(\"help\")\n\n    # The rows we'd like the nodes in the parent menus to appear on. This\n    # prevents the scroll from jumping around when going in and out of menus.\n    _parent_screen_rows = []\n\n    # Initial state\n\n    _cur_menu = _kconf.top_node\n    _shown = _shown_nodes(_cur_menu)\n    _sel_node_i = _menu_scroll = 0\n\n    _show_help = _show_name = False\n\n    # Give windows their initial size\n    _resize_main()\n\n\ndef _resize_main():\n    # Resizes the main display, with the list of symbols, etc., to fill the\n    # terminal\n\n    global _menu_scroll\n\n    screen_height, screen_width = _stdscr.getmaxyx()\n\n    _path_win.resize(1, screen_width)\n    _top_sep_win.resize(1, screen_width)\n    _bot_sep_win.resize(1, screen_width)\n\n    help_win_height = _SHOW_HELP_HEIGHT if _show_help else \\\n        len(_MAIN_HELP_LINES)\n\n    menu_win_height = screen_height - help_win_height - 3\n\n    if menu_win_height >= 1:\n        _menu_win.resize(menu_win_height, screen_width)\n        _help_win.resize(help_win_height, screen_width)\n\n        _top_sep_win.mvwin(1, 0)\n        _menu_win.mvwin(2, 0)\n        _bot_sep_win.mvwin(2 + menu_win_height, 0)\n        _help_win.mvwin(2 + menu_win_height + 1, 0)\n    else:\n        # Degenerate case. Give up on nice rendering and just prevent errors.\n\n        menu_win_height = 1\n\n        _menu_win.resize(1, screen_width)\n        _help_win.resize(1, screen_width)\n\n        for win in _top_sep_win, _menu_win, _bot_sep_win, _help_win:\n            win.mvwin(0, 0)\n\n    # Adjust the scroll so that the selected node is still within the window,\n    # if needed\n    if _sel_node_i - _menu_scroll >= menu_win_height:\n        _menu_scroll = _sel_node_i - menu_win_height + 1\n\n\ndef _height(win):\n    # Returns the height of 'win'\n\n    return win.getmaxyx()[0]\n\n\ndef _width(win):\n    # Returns the width of 'win'\n\n    return win.getmaxyx()[1]\n\n\ndef _enter_menu(menu):\n    # Makes 'menu' the currently displayed menu. In addition to actual 'menu's,\n    # \"menu\" here includes choices and symbols defined with the 'menuconfig'\n    # keyword.\n    #\n    # Returns False if 'menu' can't be entered.\n\n    global _cur_menu\n    global _shown\n    global _sel_node_i\n    global _menu_scroll\n\n    if not menu.is_menuconfig:\n        return False  # Not a menu\n\n    shown_sub = _shown_nodes(menu)\n    # Never enter empty menus. We depend on having a current node.\n    if not shown_sub:\n        return False\n\n    # Remember where the current node appears on the screen, so we can try\n    # to get it to appear in the same place when we leave the menu\n    _parent_screen_rows.append(_sel_node_i - _menu_scroll)\n\n    # Jump into menu\n    _cur_menu = menu\n    _shown = shown_sub\n    _sel_node_i = _menu_scroll = 0\n\n    if isinstance(menu.item, Choice):\n        _select_selected_choice_sym()\n\n    return True\n\n\ndef _select_selected_choice_sym():\n    # Puts the cursor on the currently selected (y-valued) choice symbol, if\n    # any. Does nothing if if the choice has no selection (is not visible/in y\n    # mode).\n\n    global _sel_node_i\n\n    choice = _cur_menu.item\n    if choice.selection:\n        # Search through all menu nodes to handle choice symbols being defined\n        # in multiple locations\n        for node in choice.selection.nodes:\n            if node in _shown:\n                _sel_node_i = _shown.index(node)\n                _center_vertically()\n                return\n\n\ndef _jump_to(node):\n    # Jumps directly to the menu node 'node'\n\n    global _cur_menu\n    global _shown\n    global _sel_node_i\n    global _menu_scroll\n    global _show_all\n    global _parent_screen_rows\n\n    # Clear remembered menu locations. We might not even have been in the\n    # parent menus before.\n    _parent_screen_rows = []\n\n    old_show_all = _show_all\n    jump_into = (isinstance(node.item, Choice) or node.item == MENU) and \\\n                node.list\n\n    # If we're jumping to a non-empty choice or menu, jump to the first entry\n    # in it instead of jumping to its menu node\n    if jump_into:\n        _cur_menu = node\n        node = node.list\n    else:\n        _cur_menu = _parent_menu(node)\n\n    _shown = _shown_nodes(_cur_menu)\n    if node not in _shown:\n        # The node wouldn't be shown. Turn on show-all to show it.\n        _show_all = True\n        _shown = _shown_nodes(_cur_menu)\n\n    _sel_node_i = _shown.index(node)\n\n    if jump_into and not old_show_all and _show_all:\n        # If we're jumping into a choice or menu and were forced to turn on\n        # show-all because the first entry wasn't visible, try turning it off.\n        # That will land us at the first visible node if there are visible\n        # nodes, and is a no-op otherwise.\n        _toggle_show_all()\n\n    _center_vertically()\n\n    # If we're jumping to a non-empty choice, jump to the selected symbol, if\n    # any\n    if jump_into and isinstance(_cur_menu.item, Choice):\n        _select_selected_choice_sym()\n\n\ndef _leave_menu():\n    # Jumps to the parent menu of the current menu. Does nothing if we're in\n    # the top menu.\n\n    global _cur_menu\n    global _shown\n    global _sel_node_i\n    global _menu_scroll\n\n    if _cur_menu is _kconf.top_node:\n        return\n\n    # Jump to parent menu\n    parent = _parent_menu(_cur_menu)\n    _shown = _shown_nodes(parent)\n    _sel_node_i = _shown.index(_cur_menu)\n    _cur_menu = parent\n\n    # Try to make the menu entry appear on the same row on the screen as it did\n    # before we entered the menu.\n\n    if _parent_screen_rows:\n        # The terminal might have shrunk since we were last in the parent menu\n        screen_row = min(_parent_screen_rows.pop(), _height(_menu_win) - 1)\n        _menu_scroll = max(_sel_node_i - screen_row, 0)\n    else:\n        # No saved parent menu locations, meaning we jumped directly to some\n        # node earlier\n        _center_vertically()\n\n\ndef _select_next_menu_entry():\n    # Selects the menu entry after the current one, adjusting the scroll if\n    # necessary. Does nothing if we're already at the last menu entry.\n\n    global _sel_node_i\n    global _menu_scroll\n\n    if _sel_node_i < len(_shown) - 1:\n        # Jump to the next node\n        _sel_node_i += 1\n\n        # If the new node is sufficiently close to the edge of the menu window\n        # (as determined by _SCROLL_OFFSET), increase the scroll by one. This\n        # gives nice and non-jumpy behavior even when\n        # _SCROLL_OFFSET >= _height(_menu_win).\n        if _sel_node_i >= _menu_scroll + _height(_menu_win) - _SCROLL_OFFSET \\\n           and _menu_scroll < _max_scroll(_shown, _menu_win):\n\n            _menu_scroll += 1\n\n\ndef _select_prev_menu_entry():\n    # Selects the menu entry before the current one, adjusting the scroll if\n    # necessary. Does nothing if we're already at the first menu entry.\n\n    global _sel_node_i\n    global _menu_scroll\n\n    if _sel_node_i > 0:\n        # Jump to the previous node\n        _sel_node_i -= 1\n\n        # See _select_next_menu_entry()\n        if _sel_node_i < _menu_scroll + _SCROLL_OFFSET:\n            _menu_scroll = max(_menu_scroll - 1, 0)\n\n\ndef _select_last_menu_entry():\n    # Selects the last menu entry in the current menu\n\n    global _sel_node_i\n    global _menu_scroll\n\n    _sel_node_i = len(_shown) - 1\n    _menu_scroll = _max_scroll(_shown, _menu_win)\n\n\ndef _select_first_menu_entry():\n    # Selects the first menu entry in the current menu\n\n    global _sel_node_i\n    global _menu_scroll\n\n    _sel_node_i = _menu_scroll = 0\n\n\ndef _toggle_show_all():\n    # Toggles show-all mode on/off. If turning it off would give no visible\n    # items in the current menu, it is left on.\n\n    global _show_all\n    global _shown\n    global _sel_node_i\n    global _menu_scroll\n\n    # Row on the screen the cursor is on. Preferably we want the same row to\n    # stay highlighted.\n    old_row = _sel_node_i - _menu_scroll\n\n    _show_all = not _show_all\n    # List of new nodes to be shown after toggling _show_all\n    new_shown = _shown_nodes(_cur_menu)\n\n    # Find a good node to select. The selected node might disappear if show-all\n    # mode is turned off.\n\n    # Select the previously selected node itself if it is still visible. If\n    # there are visible nodes before it, select the closest one.\n    for node in _shown[_sel_node_i::-1]:\n        if node in new_shown:\n            _sel_node_i = new_shown.index(node)\n            break\n    else:\n        # No visible nodes before the previously selected node. Select the\n        # closest visible node after it instead.\n        for node in _shown[_sel_node_i + 1:]:\n            if node in new_shown:\n                _sel_node_i = new_shown.index(node)\n                break\n        else:\n            # No visible nodes at all, meaning show-all was turned off inside\n            # an invisible menu. Don't allow that, as the implementation relies\n            # on always having a selected node.\n            _show_all = True\n            return\n\n    _shown = new_shown\n\n    # Try to make the cursor stay on the same row in the menu window. This\n    # might be impossible if too many nodes have disappeared above the node.\n    _menu_scroll = max(_sel_node_i - old_row, 0)\n\n\ndef _center_vertically():\n    # Centers the selected node vertically, if possible\n\n    global _menu_scroll\n\n    _menu_scroll = min(max(_sel_node_i - _height(_menu_win)//2, 0),\n                       _max_scroll(_shown, _menu_win))\n\n\ndef _draw_main():\n    # Draws the \"main\" display, with the list of symbols, the header, and the\n    # footer.\n    #\n    # This could be optimized to only update the windows that have actually\n    # changed, but keep it simple for now and let curses sort it out.\n\n    term_width = _width(_stdscr)\n\n    #\n    # Update the separator row below the menu path\n    #\n\n    _top_sep_win.erase()\n\n    # Draw arrows pointing up if the symbol window is scrolled down. Draw them\n    # before drawing the title, so the title ends up on top for small windows.\n    if _menu_scroll > 0:\n        _safe_hline(_top_sep_win, 0, 4, curses.ACS_UARROW, _N_SCROLL_ARROWS)\n\n    # Add the 'mainmenu' text as the title, centered at the top\n    _safe_addstr(_top_sep_win,\n                 0, max((term_width - len(_kconf.mainmenu_text))//2, 0),\n                 _kconf.mainmenu_text)\n\n    _top_sep_win.noutrefresh()\n\n    # Note: The menu path at the top is deliberately updated last. See below.\n\n    #\n    # Update the symbol window\n    #\n\n    _menu_win.erase()\n\n    # Draw the _shown nodes starting from index _menu_scroll up to either as\n    # many as fit in the window, or to the end of _shown\n    for i in range(_menu_scroll,\n                   min(_menu_scroll + _height(_menu_win), len(_shown))):\n\n        node = _shown[i]\n\n        # The 'not _show_all' test avoids showing invisible items in red\n        # outside show-all mode, which could look confusing/broken. Invisible\n        # symbols show up outside show-all mode if an invisible symbol has\n        # visible children in an implicit (indented) menu.\n        if _visible(node) or not _show_all:\n            style = _style[\"selection\" if i == _sel_node_i else \"list\"]\n        else:\n            style = _style[\"inv-selection\" if i == _sel_node_i else \"inv-list\"]\n\n        _safe_addstr(_menu_win, i - _menu_scroll, 0, _node_str(node), style)\n\n    _menu_win.noutrefresh()\n\n    #\n    # Update the bottom separator window\n    #\n\n    _bot_sep_win.erase()\n\n    # Draw arrows pointing down if the symbol window is scrolled up\n    if _menu_scroll < _max_scroll(_shown, _menu_win):\n        _safe_hline(_bot_sep_win, 0, 4, curses.ACS_DARROW, _N_SCROLL_ARROWS)\n\n    # Indicate when show-name/show-help/show-all mode is enabled\n    enabled_modes = []\n    if _show_help:\n        enabled_modes.append(\"show-help (toggle with [F])\")\n    if _show_name:\n        enabled_modes.append(\"show-name\")\n    if _show_all:\n        enabled_modes.append(\"show-all\")\n    if enabled_modes:\n        s = \" and \".join(enabled_modes) + \" mode enabled\"\n        _safe_addstr(_bot_sep_win, 0, max(term_width - len(s) - 2, 0), s)\n\n    _bot_sep_win.noutrefresh()\n\n    #\n    # Update the help window, which shows either key bindings or help texts\n    #\n\n    _help_win.erase()\n\n    if _show_help:\n        node = _shown[_sel_node_i]\n        if isinstance(node.item, (Symbol, Choice)) and node.help:\n            help_lines = textwrap.wrap(node.help, _width(_help_win))\n            for i in range(min(_height(_help_win), len(help_lines))):\n                _safe_addstr(_help_win, i, 0, help_lines[i])\n        else:\n            _safe_addstr(_help_win, 0, 0, \"(no help)\")\n    else:\n        for i, line in enumerate(_MAIN_HELP_LINES):\n            _safe_addstr(_help_win, i, 0, line)\n\n    _help_win.noutrefresh()\n\n    #\n    # Update the top row with the menu path.\n    #\n    # Doing this last leaves the cursor on the top row, which avoids some minor\n    # annoying jumpiness in gnome-terminal when reducing the height of the\n    # terminal. It seems to happen whenever the row with the cursor on it\n    # disappears.\n    #\n\n    _path_win.erase()\n\n    # Draw the menu path (\"(Top) -> Menu -> Submenu -> ...\")\n\n    menu_prompts = []\n\n    menu = _cur_menu\n    while menu is not _kconf.top_node:\n        # Promptless choices can be entered in show-all mode. Use\n        # standard_sc_expr_str() for them, so they show up as\n        # '<choice (name if any)>'.\n        menu_prompts.append(menu.prompt[0] if menu.prompt else\n                            standard_sc_expr_str(menu.item))\n        menu = menu.parent\n    menu_prompts.append(\"(Top)\")\n    menu_prompts.reverse()\n\n    # Hack: We can't put ACS_RARROW directly in the string. Temporarily\n    # represent it with NULL.\n    menu_path_str = \" \\0 \".join(menu_prompts)\n\n    # Scroll the menu path to the right if needed to make the current menu's\n    # title visible\n    if len(menu_path_str) > term_width:\n        menu_path_str = menu_path_str[len(menu_path_str) - term_width:]\n\n    # Print the path with the arrows reinserted\n    split_path = menu_path_str.split(\"\\0\")\n    _safe_addstr(_path_win, split_path[0])\n    for s in split_path[1:]:\n        _safe_addch(_path_win, curses.ACS_RARROW)\n        _safe_addstr(_path_win, s)\n\n    _path_win.noutrefresh()\n\n\ndef _parent_menu(node):\n    # Returns the menu node of the menu that contains 'node'. In addition to\n    # proper 'menu's, this might also be a 'menuconfig' symbol or a 'choice'.\n    # \"Menu\" here means a menu in the interface.\n\n    menu = node.parent\n    while not menu.is_menuconfig:\n        menu = menu.parent\n    return menu\n\n\ndef _shown_nodes(menu):\n    # Returns the list of menu nodes from 'menu' (see _parent_menu()) that\n    # would be shown when entering it\n\n    def rec(node):\n        res = []\n\n        while node:\n            if _visible(node) or _show_all:\n                res.append(node)\n                if node.list and not node.is_menuconfig:\n                    # Nodes from implicit menu created from dependencies. Will\n                    # be shown indented. Note that is_menuconfig is True for\n                    # menus and choices as well as 'menuconfig' symbols.\n                    res += rec(node.list)\n\n            elif node.list and isinstance(node.item, Symbol):\n                # Show invisible symbols if they have visible children. This\n                # can happen for an m/y-valued symbol with an optional prompt\n                # ('prompt \"foo\" is COND') that is currently disabled. Note\n                # that it applies to both 'config' and 'menuconfig' symbols.\n                shown_children = rec(node.list)\n                if shown_children:\n                    res.append(node)\n                    if not node.is_menuconfig:\n                        res += shown_children\n\n            node = node.next\n\n        return res\n\n    if isinstance(menu.item, Choice):\n        # For named choices defined in multiple locations, entering the choice\n        # at a particular menu node would normally only show the choice symbols\n        # defined there (because that's what the MenuNode tree looks like).\n        #\n        # That might look confusing, and makes extending choices by defining\n        # them in multiple locations less useful. Instead, gather all the child\n        # menu nodes for all the choices whenever a choice is entered. That\n        # makes all choice symbols visible at all locations.\n        #\n        # Choices can contain non-symbol items (people do all sorts of weird\n        # stuff with them), hence the generality here. We really need to\n        # preserve the menu tree at each choice location.\n        #\n        # Note: Named choices are pretty broken in the C tools, and this is\n        # super obscure, so you probably won't find much that relies on this.\n        # This whole 'if' could be deleted if you don't care about defining\n        # choices in multiple locations to add symbols (which will still work,\n        # just with things being displayed in a way that might be unexpected).\n\n        # Do some additional work to avoid listing choice symbols twice if all\n        # or part of the choice is copied in multiple locations (e.g. by\n        # including some Kconfig file multiple times). We give the prompts at\n        # the current location precedence.\n        seen_syms = {node.item for node in rec(menu.list)\n                     if isinstance(node.item, Symbol)}\n        res = []\n        for choice_node in menu.item.nodes:\n            for node in rec(choice_node.list):\n                # 'choice_node is menu' checks if we're dealing with the\n                # current location\n                if node.item not in seen_syms or choice_node is menu:\n                    res.append(node)\n                    if isinstance(node.item, Symbol):\n                        seen_syms.add(node.item)\n        return res\n\n    return rec(menu.list)\n\n\ndef _visible(node):\n    # Returns True if the node should appear in the menu (outside show-all\n    # mode)\n\n    return node.prompt and expr_value(node.prompt[1]) and not \\\n        (node.item == MENU and not expr_value(node.visibility))\n\n\ndef _change_node(node):\n    # Changes the value of the menu node 'node' if it is a symbol. Bools and\n    # tristates are toggled, while other symbol types pop up a text entry\n    # dialog.\n    #\n    # Returns False if the value of 'node' can't be changed.\n\n    if not _changeable(node):\n        return False\n\n    # sc = symbol/choice\n    sc = node.item\n\n    if sc.orig_type in (INT, HEX, STRING):\n        s = sc.str_value\n\n        while True:\n            s = _input_dialog(\n                \"{} ({})\".format(node.prompt[0], TYPE_TO_STR[sc.orig_type]),\n                s, _range_info(sc))\n\n            if s is None:\n                break\n\n            if sc.orig_type in (INT, HEX):\n                s = s.strip()\n\n                # 'make menuconfig' does this too. Hex values not starting with\n                # '0x' are accepted when loading .config files though.\n                if sc.orig_type == HEX and not s.startswith((\"0x\", \"0X\")):\n                    s = \"0x\" + s\n\n            if _check_valid(sc, s):\n                _set_val(sc, s)\n                break\n\n    elif len(sc.assignable) == 1:\n        # Handles choice symbols for choices in y mode, which are a special\n        # case: .assignable can be (2,) while .tri_value is 0.\n        _set_val(sc, sc.assignable[0])\n\n    else:\n        # Set the symbol to the value after the current value in\n        # sc.assignable, with wrapping\n        val_index = sc.assignable.index(sc.tri_value)\n        _set_val(sc, sc.assignable[(val_index + 1) % len(sc.assignable)])\n\n\n    if _is_y_mode_choice_sym(sc) and not node.list:\n        # Immediately jump to the parent menu after making a choice selection,\n        # like 'make menuconfig' does, except if the menu node has children\n        # (which can happen if a symbol 'depends on' a choice symbol that\n        # immediately precedes it).\n        _leave_menu()\n\n\n    return True\n\n\ndef _changeable(node):\n    # Returns True if the value if 'node' can be changed\n\n    sc = node.item\n\n    if not isinstance(sc, (Symbol, Choice)):\n        return False\n\n    # This will hit for invisible symbols, which appear in show-all mode and\n    # when an invisible symbol has visible children (which can happen e.g. for\n    # symbols with optional prompts)\n    if not (node.prompt and expr_value(node.prompt[1])):\n        return False\n\n    return sc.orig_type in (STRING, INT, HEX) or len(sc.assignable) > 1 \\\n        or _is_y_mode_choice_sym(sc)\n\n\ndef _set_sel_node_tri_val(tri_val):\n    # Sets the value of the currently selected menu entry to 'tri_val', if that\n    # value can be assigned\n\n    sc = _shown[_sel_node_i].item\n    if isinstance(sc, (Symbol, Choice)) and tri_val in sc.assignable:\n        _set_val(sc, tri_val)\n\n\ndef _set_val(sc, val):\n    # Wrapper around Symbol/Choice.set_value() for updating the menu state and\n    # _conf_changed\n\n    global _conf_changed\n\n    # Use the string representation of tristate values. This makes the format\n    # consistent for all symbol types.\n    if val in TRI_TO_STR:\n        val = TRI_TO_STR[val]\n\n    if val != sc.str_value:\n        sc.set_value(val)\n        _conf_changed = True\n\n        # Changing the value of the symbol might have changed what items in the\n        # current menu are visible. Recalculate the state.\n        _update_menu()\n\n\ndef _update_menu():\n    # Updates the current menu after the value of a symbol or choice has been\n    # changed. Changing a value might change which items in the menu are\n    # visible.\n    #\n    # If possible, preserves the location of the cursor on the screen when\n    # items are added/removed above the selected item.\n\n    global _shown\n    global _sel_node_i\n    global _menu_scroll\n\n    # Row on the screen the cursor was on\n    old_row = _sel_node_i - _menu_scroll\n\n    sel_node = _shown[_sel_node_i]\n\n    # New visible nodes\n    _shown = _shown_nodes(_cur_menu)\n\n    # New index of selected node\n    _sel_node_i = _shown.index(sel_node)\n\n    # Try to make the cursor stay on the same row in the menu window. This\n    # might be impossible if too many nodes have disappeared above the node.\n    _menu_scroll = max(_sel_node_i - old_row, 0)\n\n\ndef _input_dialog(title, initial_text, info_text=None):\n    # Pops up a dialog that prompts the user for a string\n    #\n    # title:\n    #   Title to display at the top of the dialog window's border\n    #\n    # initial_text:\n    #   Initial text to prefill the input field with\n    #\n    # info_text:\n    #   String to show next to the input field. If None, just the input field\n    #   is shown.\n\n    win = _styled_win(\"body\")\n    win.keypad(True)\n\n    info_lines = info_text.split(\"\\n\") if info_text else []\n\n    # Give the input dialog its initial size\n    _resize_input_dialog(win, title, info_lines)\n\n    _safe_curs_set(2)\n\n    # Input field text\n    s = initial_text\n\n    # Cursor position\n    i = len(initial_text)\n\n    def edit_width():\n        return _width(win) - 4\n\n    # Horizontal scroll offset\n    hscroll = max(i - edit_width() + 1, 0)\n\n    while True:\n        # Draw the \"main\" display with the menu, etc., so that resizing still\n        # works properly. This is like a stack of windows, only hardcoded for\n        # now.\n        _draw_main()\n        _draw_input_dialog(win, title, info_lines, s, i, hscroll)\n        curses.doupdate()\n\n\n        c = _getch_compat(win)\n\n        if c == curses.KEY_RESIZE:\n            # Resize the main display too. The dialog floats above it.\n            _resize_main()\n            _resize_input_dialog(win, title, info_lines)\n\n        elif c == \"\\n\":\n            _safe_curs_set(0)\n            return s\n\n        elif c == \"\\x1B\":  # \\x1B = ESC\n            _safe_curs_set(0)\n            return None\n\n        else:\n            s, i, hscroll = _edit_text(c, s, i, hscroll, edit_width())\n\n\ndef _resize_input_dialog(win, title, info_lines):\n    # Resizes the input dialog to a size appropriate for the terminal size\n\n    screen_height, screen_width = _stdscr.getmaxyx()\n\n    win_height = 5\n    if info_lines:\n        win_height += len(info_lines) + 1\n    win_height = min(win_height, screen_height)\n\n    win_width = max(_INPUT_DIALOG_MIN_WIDTH,\n                    len(title) + 4,\n                    *(len(line) + 4 for line in info_lines))\n    win_width = min(win_width, screen_width)\n\n    win.resize(win_height, win_width)\n    win.mvwin((screen_height - win_height)//2,\n              (screen_width - win_width)//2)\n\n\ndef _draw_input_dialog(win, title, info_lines, s, i, hscroll):\n    edit_width = _width(win) - 4\n\n    win.erase()\n\n    # Note: Perhaps having a separate window for the input field would be nicer\n    visible_s = s[hscroll:hscroll + edit_width]\n    _safe_addstr(win, 2, 2, visible_s + \" \"*(edit_width - len(visible_s)),\n                 _style[\"edit\"])\n\n    for linenr, line in enumerate(info_lines):\n        _safe_addstr(win, 4 + linenr, 2, line)\n\n    # Draw the frame last so that it overwrites the body text for small windows\n    _draw_frame(win, title)\n\n    _safe_move(win, 2, 2 + i - hscroll)\n\n    win.noutrefresh()\n\n\ndef _load_dialog():\n    # Dialog for loading a new configuration\n\n    global _conf_changed\n    global _conf_filename\n    global _show_all\n\n    if _conf_changed:\n        c = _key_dialog(\n            \"Load\",\n            \"You have unsaved changes. Load new\\n\"\n            \"configuration anyway?\\n\"\n            \"\\n\"\n            \"         (O)K  (C)ancel\",\n            \"oc\")\n\n        if c is None or c == \"c\":\n            return\n\n    filename = _conf_filename\n    while True:\n        filename = _input_dialog(\"File to load\", filename, _load_save_info())\n        if filename is None:\n            return\n\n        filename = os.path.expanduser(filename)\n\n        if _try_load(filename):\n            _conf_filename = filename\n            _conf_changed = _needs_save()\n\n            # Turn on show-all mode if the selected node is not visible after\n            # loading the new configuration. _shown still holds the old state.\n            if _shown[_sel_node_i] not in _shown_nodes(_cur_menu):\n                _show_all = True\n\n            _update_menu()\n\n            # The message dialog indirectly updates the menu display, so _msg()\n            # must be called after the new state has been initialized\n            _msg(\"Success\", \"Loaded \" + filename)\n            return\n\n\ndef _try_load(filename):\n    # Tries to load a configuration file. Pops up an error and returns False on\n    # failure.\n    #\n    # filename:\n    #   Configuration file to load\n\n    try:\n        _kconf.load_config(filename)\n        return True\n    except EnvironmentError as e:\n        _error(\"Error loading '{}'\\n\\n{} (errno: {})\"\n               .format(filename, e.strerror, errno.errorcode[e.errno]))\n        return False\n\n\ndef _save_dialog(save_fn, default_filename, description):\n    # Dialog for saving the current configuration\n    #\n    # save_fn:\n    #   Function to call with 'filename' to save the file\n    #\n    # default_filename:\n    #   Prefilled filename in the input field\n    #\n    # description:\n    #   String describing the thing being saved\n    #\n    # Return value:\n    #   The path to the saved file, or None if no file was saved\n\n    filename = default_filename\n    while True:\n        filename = _input_dialog(\"Filename to save {} to\".format(description),\n                                 filename, _load_save_info())\n        if filename is None:\n            return None\n\n        filename = os.path.expanduser(filename)\n\n        msg = _try_save(save_fn, filename, description)\n        if msg:\n            _msg(\"Success\", msg)\n            return filename\n\n\ndef _try_save(save_fn, filename, description):\n    # Tries to save a configuration file. Returns a message to print on\n    # success.\n    #\n    # save_fn:\n    #   Function to call with 'filename' to save the file\n    #\n    # description:\n    #   String describing the thing being saved\n    #\n    # Return value:\n    #   A message to print on success, and None on failure\n\n    try:\n        # save_fn() returns a message to print\n        return save_fn(filename)\n    except EnvironmentError as e:\n        _error(\"Error saving {} to '{}'\\n\\n{} (errno: {})\"\n               .format(description, e.filename, e.strerror,\n                       errno.errorcode[e.errno]))\n        return None\n\n\ndef _key_dialog(title, text, keys):\n    # Pops up a dialog that can be closed by pressing a key\n    #\n    # title:\n    #   Title to display at the top of the dialog window's border\n    #\n    # text:\n    #   Text to show in the dialog\n    #\n    # keys:\n    #   List of keys that will close the dialog. Other keys (besides ESC) are\n    #   ignored. The caller is responsible for providing a hint about which\n    #   keys can be pressed in 'text'.\n    #\n    # Return value:\n    #   The key that was pressed to close the dialog. Uppercase characters are\n    #   converted to lowercase. ESC will always close the dialog, and returns\n    #   None.\n\n    win = _styled_win(\"body\")\n    win.keypad(True)\n\n    _resize_key_dialog(win, text)\n\n    while True:\n        # See _input_dialog()\n        _draw_main()\n        _draw_key_dialog(win, title, text)\n        curses.doupdate()\n\n\n        c = _getch_compat(win)\n\n        if c == curses.KEY_RESIZE:\n            # Resize the main display too. The dialog floats above it.\n            _resize_main()\n            _resize_key_dialog(win, text)\n\n        elif c == \"\\x1B\":  # \\x1B = ESC\n            return None\n\n        elif isinstance(c, str):\n            c = c.lower()\n            if c in keys:\n                return c\n\n\ndef _resize_key_dialog(win, text):\n    # Resizes the key dialog to a size appropriate for the terminal size\n\n    screen_height, screen_width = _stdscr.getmaxyx()\n\n    lines = text.split(\"\\n\")\n\n    win_height = min(len(lines) + 4, screen_height)\n    win_width = min(max(len(line) for line in lines) + 4, screen_width)\n\n    win.resize(win_height, win_width)\n    win.mvwin((screen_height - win_height)//2,\n              (screen_width - win_width)//2)\n\n\ndef _draw_key_dialog(win, title, text):\n    win.erase()\n\n    for i, line in enumerate(text.split(\"\\n\")):\n        _safe_addstr(win, 2 + i, 2, line)\n\n    # Draw the frame last so that it overwrites the body text for small windows\n    _draw_frame(win, title)\n\n    win.noutrefresh()\n\n\ndef _draw_frame(win, title):\n    # Draw a frame around the inner edges of 'win', with 'title' at the top\n\n    win_height, win_width = win.getmaxyx()\n\n    win.attron(_style[\"frame\"])\n\n    # Draw top/bottom edge\n    _safe_hline(win,              0, 0, \" \", win_width)\n    _safe_hline(win, win_height - 1, 0, \" \", win_width)\n\n    # Draw left/right edge\n    _safe_vline(win, 0,             0, \" \", win_height)\n    _safe_vline(win, 0, win_width - 1, \" \", win_height)\n\n    # Draw title\n    _safe_addstr(win, 0, max((win_width - len(title))//2, 0), title)\n\n    win.attroff(_style[\"frame\"])\n\n\ndef _jump_to_dialog():\n    # Implements the jump-to dialog, where symbols can be looked up via\n    # incremental search and jumped to.\n    #\n    # Returns True if the user jumped to a symbol, and False if the dialog was\n    # canceled.\n\n    s = \"\"  # Search text\n    prev_s = None  # Previous search text\n    s_i = 0  # Search text cursor position\n    hscroll = 0  # Horizontal scroll offset\n\n    sel_node_i = 0  # Index of selected row\n    scroll = 0  # Index in 'matches' of the top row of the list\n\n    # Edit box at the top\n    edit_box = _styled_win(\"jump-edit\")\n    edit_box.keypad(True)\n\n    # List of matches\n    matches_win = _styled_win(\"list\")\n\n    # Bottom separator, with arrows pointing down\n    bot_sep_win = _styled_win(\"separator\")\n\n    # Help window with instructions at the bottom\n    help_win = _styled_win(\"help\")\n\n    # Give windows their initial size\n    _resize_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win,\n                           sel_node_i, scroll)\n\n    _safe_curs_set(2)\n\n    # Logic duplication with _select_{next,prev}_menu_entry(), except we do a\n    # functional variant that returns the new (sel_node_i, scroll) values to\n    # avoid 'nonlocal'. TODO: Can this be factored out in some nice way?\n\n    def select_next_match():\n        if sel_node_i == len(matches) - 1:\n            return sel_node_i, scroll\n\n        if sel_node_i + 1 >= scroll + _height(matches_win) - _SCROLL_OFFSET \\\n           and scroll < _max_scroll(matches, matches_win):\n\n            return sel_node_i + 1, scroll + 1\n\n        return sel_node_i + 1, scroll\n\n    def select_prev_match():\n        if sel_node_i == 0:\n            return sel_node_i, scroll\n\n        if sel_node_i - 1 < scroll + _SCROLL_OFFSET:\n            return sel_node_i - 1, max(scroll - 1, 0)\n\n        return sel_node_i - 1, scroll\n\n    while True:\n        if s != prev_s:\n            # The search text changed. Find new matching nodes.\n\n            prev_s = s\n\n            try:\n                # We could use re.IGNORECASE here instead of lower(), but this\n                # is noticeably less jerky while inputting regexes like\n                # '.*debug$' (though the '.*' is redundant there). Those\n                # probably have bad interactions with re.search(), which\n                # matches anywhere in the string.\n                #\n                # It's not horrible either way. Just a bit smoother.\n                regex_searches = [re.compile(regex).search\n                                  for regex in s.lower().split()]\n\n                # No exception thrown, so the regexes are okay\n                bad_re = None\n\n                # List of matching nodes\n                matches = []\n                add_match = matches.append\n\n                # Search symbols and choices\n\n                for node in _sorted_sc_nodes():\n                    # Symbol/choice\n                    sc = node.item\n\n                    for search in regex_searches:\n                        # Both the name and the prompt might be missing, since\n                        # we're searching both symbols and choices\n\n                        # Does the regex match either the symbol name or the\n                        # prompt (if any)?\n                        if not (sc.name and search(sc.name.lower()) or\n                                node.prompt and search(node.prompt[0].lower())):\n\n                            # Give up on the first regex that doesn't match, to\n                            # speed things up a bit when multiple regexes are\n                            # entered\n                            break\n\n                    else:\n                        add_match(node)\n\n                # Search menus and comments\n\n                for node in _sorted_menu_comment_nodes():\n                    for search in regex_searches:\n                        if not search(node.prompt[0].lower()):\n                            break\n                    else:\n                        add_match(node)\n\n            except re.error as e:\n                # Bad regex. Remember the error message so we can show it.\n                bad_re = \"Bad regular expression\"\n                # re.error.msg was added in Python 3.5\n                if hasattr(e, \"msg\"):\n                    bad_re += \": \" + e.msg\n\n                matches = []\n\n            # Reset scroll and jump to the top of the list of matches\n            sel_node_i = scroll = 0\n\n        _draw_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win,\n                             s, s_i, hscroll,\n                             bad_re, matches, sel_node_i, scroll)\n        curses.doupdate()\n\n\n        c = _getch_compat(edit_box)\n\n        if c == \"\\n\":\n            if matches:\n                _jump_to(matches[sel_node_i])\n                _safe_curs_set(0)\n                return True\n\n        elif c == \"\\x1B\":  # \\x1B = ESC\n            _safe_curs_set(0)\n            return False\n\n        elif c == curses.KEY_RESIZE:\n            # We adjust the scroll so that the selected node stays visible in\n            # the list when the terminal is resized, hence the 'scroll'\n            # assignment\n            scroll = _resize_jump_to_dialog(\n                edit_box, matches_win, bot_sep_win, help_win,\n                sel_node_i, scroll)\n\n        elif c == \"\\x06\":  # \\x06 = Ctrl-F\n            if matches:\n                _safe_curs_set(0)\n                _info_dialog(matches[sel_node_i], True)\n                _safe_curs_set(2)\n\n                scroll = _resize_jump_to_dialog(\n                    edit_box, matches_win, bot_sep_win, help_win,\n                    sel_node_i, scroll)\n\n        elif c == curses.KEY_DOWN:\n            sel_node_i, scroll = select_next_match()\n\n        elif c == curses.KEY_UP:\n            sel_node_i, scroll = select_prev_match()\n\n        elif c in (curses.KEY_NPAGE, \"\\x04\"):  # Page Down/Ctrl-D\n            # Keep it simple. This way we get sane behavior for small windows,\n            # etc., for free.\n            for _ in range(_PG_JUMP):\n                sel_node_i, scroll = select_next_match()\n\n        # Page Up (no Ctrl-U, as it's already used by the edit box)\n        elif c == curses.KEY_PPAGE:\n            for _ in range(_PG_JUMP):\n                sel_node_i, scroll = select_prev_match()\n\n        elif c == curses.KEY_END:\n            sel_node_i = len(matches) - 1\n            scroll = _max_scroll(matches, matches_win)\n\n        elif c == curses.KEY_HOME:\n            sel_node_i = scroll = 0\n\n        else:\n            s, s_i, hscroll = _edit_text(c, s, s_i, hscroll,\n                                         _width(edit_box) - 2)\n\n\n# Obscure Python: We never pass a value for cached_nodes, and it keeps pointing\n# to the same list. This avoids a global.\ndef _sorted_sc_nodes(cached_nodes=[]):\n    # Returns a sorted list of symbol and choice nodes to search. The symbol\n    # nodes appear first, sorted by name, and then the choice nodes, sorted by\n    # prompt and (secondarily) name.\n\n    if not cached_nodes:\n        # Add symbol nodes\n        for sym in sorted(_kconf.unique_defined_syms,\n                          key=lambda sym: sym.name):\n            # += is in-place for lists\n            cached_nodes += sym.nodes\n\n        # Add choice nodes\n\n        choices = sorted(_kconf.unique_choices,\n                         key=lambda choice: choice.name or \"\")\n\n        cached_nodes += sorted(\n            [node for choice in choices for node in choice.nodes],\n            key=lambda node: node.prompt[0] if node.prompt else \"\")\n\n    return cached_nodes\n\n\ndef _sorted_menu_comment_nodes(cached_nodes=[]):\n    # Returns a list of menu and comment nodes to search, sorted by prompt,\n    # with the menus first\n\n    if not cached_nodes:\n        def prompt_text(mc):\n            return mc.prompt[0]\n\n        cached_nodes += sorted(_kconf.menus, key=prompt_text)\n        cached_nodes += sorted(_kconf.comments, key=prompt_text)\n\n    return cached_nodes\n\n\ndef _resize_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win,\n                           sel_node_i, scroll):\n    # Resizes the jump-to dialog to fill the terminal.\n    #\n    # Returns the new scroll index. We adjust the scroll if needed so that the\n    # selected node stays visible.\n\n    screen_height, screen_width = _stdscr.getmaxyx()\n\n    bot_sep_win.resize(1, screen_width)\n\n    help_win_height = len(_JUMP_TO_HELP_LINES)\n    matches_win_height = screen_height - help_win_height - 4\n\n    if matches_win_height >= 1:\n        edit_box.resize(3, screen_width)\n        matches_win.resize(matches_win_height, screen_width)\n        help_win.resize(help_win_height, screen_width)\n\n        matches_win.mvwin(3, 0)\n        bot_sep_win.mvwin(3 + matches_win_height, 0)\n        help_win.mvwin(3 + matches_win_height + 1, 0)\n    else:\n        # Degenerate case. Give up on nice rendering and just prevent errors.\n\n        matches_win_height = 1\n\n        edit_box.resize(screen_height, screen_width)\n        matches_win.resize(1, screen_width)\n        help_win.resize(1, screen_width)\n\n        for win in matches_win, bot_sep_win, help_win:\n            win.mvwin(0, 0)\n\n    # Adjust the scroll so that the selected row is still within the window, if\n    # needed\n    if sel_node_i - scroll >= matches_win_height:\n        return sel_node_i - matches_win_height + 1\n    return scroll\n\n\ndef _draw_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win,\n                         s, s_i, hscroll,\n                         bad_re, matches, sel_node_i, scroll):\n\n    edit_width = _width(edit_box) - 2\n\n    #\n    # Update list of matches\n    #\n\n    matches_win.erase()\n\n    if matches:\n        for i in range(scroll,\n                       min(scroll + _height(matches_win), len(matches))):\n\n            node = matches[i]\n\n            if isinstance(node.item, (Symbol, Choice)):\n                node_str = _name_and_val_str(node.item)\n                if node.prompt:\n                    node_str += ' \"{}\"'.format(node.prompt[0])\n            elif node.item == MENU:\n                node_str = 'menu \"{}\"'.format(node.prompt[0])\n            else:  # node.item == COMMENT\n                node_str = 'comment \"{}\"'.format(node.prompt[0])\n\n            _safe_addstr(matches_win, i - scroll, 0, node_str,\n                         _style[\"selection\" if i == sel_node_i else \"list\"])\n\n    else:\n        # bad_re holds the error message from the re.error exception on errors\n        _safe_addstr(matches_win, 0, 0, bad_re or \"No matches\")\n\n    matches_win.noutrefresh()\n\n    #\n    # Update bottom separator line\n    #\n\n    bot_sep_win.erase()\n\n    # Draw arrows pointing down if the symbol list is scrolled up\n    if scroll < _max_scroll(matches, matches_win):\n        _safe_hline(bot_sep_win, 0, 4, curses.ACS_DARROW, _N_SCROLL_ARROWS)\n\n    bot_sep_win.noutrefresh()\n\n    #\n    # Update help window at bottom\n    #\n\n    help_win.erase()\n\n    for i, line in enumerate(_JUMP_TO_HELP_LINES):\n        _safe_addstr(help_win, i, 0, line)\n\n    help_win.noutrefresh()\n\n    #\n    # Update edit box. We do this last since it makes it handy to position the\n    # cursor.\n    #\n\n    edit_box.erase()\n\n    _draw_frame(edit_box, \"Jump to symbol/choice/menu/comment\")\n\n    # Draw arrows pointing up if the symbol list is scrolled down\n    if scroll > 0:\n        # TODO: Bit ugly that _style[\"frame\"] is repeated here\n        _safe_hline(edit_box, 2, 4, curses.ACS_UARROW, _N_SCROLL_ARROWS,\n                    _style[\"frame\"])\n\n    visible_s = s[hscroll:hscroll + edit_width]\n    _safe_addstr(edit_box, 1, 1, visible_s)\n\n    _safe_move(edit_box, 1, 1 + s_i - hscroll)\n\n    edit_box.noutrefresh()\n\n\ndef _info_dialog(node, from_jump_to_dialog):\n    # Shows a fullscreen window with information about 'node'.\n    #\n    # If 'from_jump_to_dialog' is True, the information dialog was opened from\n    # within the jump-to-dialog. In this case, we make '/' from within the\n    # information dialog just return, to avoid a confusing recursive invocation\n    # of the jump-to-dialog.\n\n    # Top row, with title and arrows point up\n    top_line_win = _styled_win(\"separator\")\n\n    # Text display\n    text_win = _styled_win(\"text\")\n    text_win.keypad(True)\n\n    # Bottom separator, with arrows pointing down\n    bot_sep_win = _styled_win(\"separator\")\n\n    # Help window with keys at the bottom\n    help_win = _styled_win(\"help\")\n\n    # Give windows their initial size\n    _resize_info_dialog(top_line_win, text_win, bot_sep_win, help_win)\n\n\n    # Get lines of help text\n    lines = _info_str(node).split(\"\\n\")\n\n    # Index of first row in 'lines' to show\n    scroll = 0\n\n    while True:\n        _draw_info_dialog(node, lines, scroll, top_line_win, text_win,\n                          bot_sep_win, help_win)\n        curses.doupdate()\n\n\n        c = _getch_compat(text_win)\n\n        if c == curses.KEY_RESIZE:\n            _resize_info_dialog(top_line_win, text_win, bot_sep_win, help_win)\n\n        elif c in (curses.KEY_DOWN, \"j\", \"J\"):\n            if scroll < _max_scroll(lines, text_win):\n                scroll += 1\n\n        elif c in (curses.KEY_NPAGE, \"\\x04\"):  # Page Down/Ctrl-D\n            scroll = min(scroll + _PG_JUMP, _max_scroll(lines, text_win))\n\n        elif c in (curses.KEY_PPAGE, \"\\x15\"):  # Page Up/Ctrl-U\n            scroll = max(scroll - _PG_JUMP, 0)\n\n        elif c in (curses.KEY_END, \"G\"):\n            scroll = _max_scroll(lines, text_win)\n\n        elif c in (curses.KEY_HOME, \"g\"):\n            scroll = 0\n\n        elif c in (curses.KEY_UP, \"k\", \"K\"):\n            if scroll > 0:\n                scroll -= 1\n\n        elif c == \"/\":\n            # Support starting a search from within the information dialog\n\n            if from_jump_to_dialog:\n                return  # Avoid recursion\n\n            if _jump_to_dialog():\n                return  # Jumped to a symbol. Cancel the information dialog.\n\n            # Stay in the information dialog if the jump-to dialog was\n            # canceled. Resize it in case the terminal was resized while the\n            # fullscreen jump-to dialog was open.\n            _resize_info_dialog(top_line_win, text_win, bot_sep_win, help_win)\n\n        elif c in (curses.KEY_LEFT, curses.KEY_BACKSPACE, _ERASE_CHAR,\n                   \"\\x1B\",  # \\x1B = ESC\n                   \"q\", \"Q\", \"h\", \"H\"):\n\n            return\n\n\ndef _resize_info_dialog(top_line_win, text_win, bot_sep_win, help_win):\n    # Resizes the info dialog to fill the terminal\n\n    screen_height, screen_width = _stdscr.getmaxyx()\n\n    top_line_win.resize(1, screen_width)\n    bot_sep_win.resize(1, screen_width)\n\n    help_win_height = len(_INFO_HELP_LINES)\n    text_win_height = screen_height - help_win_height - 2\n\n    if text_win_height >= 1:\n        text_win.resize(text_win_height, screen_width)\n        help_win.resize(help_win_height, screen_width)\n\n        text_win.mvwin(1, 0)\n        bot_sep_win.mvwin(1 + text_win_height, 0)\n        help_win.mvwin(1 + text_win_height + 1, 0)\n    else:\n        # Degenerate case. Give up on nice rendering and just prevent errors.\n\n        text_win.resize(1, screen_width)\n        help_win.resize(1, screen_width)\n\n        for win in text_win, bot_sep_win, help_win:\n            win.mvwin(0, 0)\n\n\ndef _draw_info_dialog(node, lines, scroll, top_line_win, text_win,\n                      bot_sep_win, help_win):\n\n    text_win_height, text_win_width = text_win.getmaxyx()\n\n    # Note: The top row is deliberately updated last. See _draw_main().\n\n    #\n    # Update text display\n    #\n\n    text_win.erase()\n\n    for i, line in enumerate(lines[scroll:scroll + text_win_height]):\n        _safe_addstr(text_win, i, 0, line)\n\n    text_win.noutrefresh()\n\n    #\n    # Update bottom separator line\n    #\n\n    bot_sep_win.erase()\n\n    # Draw arrows pointing down if the symbol window is scrolled up\n    if scroll < _max_scroll(lines, text_win):\n        _safe_hline(bot_sep_win, 0, 4, curses.ACS_DARROW, _N_SCROLL_ARROWS)\n\n    bot_sep_win.noutrefresh()\n\n    #\n    # Update help window at bottom\n    #\n\n    help_win.erase()\n\n    for i, line in enumerate(_INFO_HELP_LINES):\n        _safe_addstr(help_win, i, 0, line)\n\n    help_win.noutrefresh()\n\n    #\n    # Update top row\n    #\n\n    top_line_win.erase()\n\n    # Draw arrows pointing up if the information window is scrolled down. Draw\n    # them before drawing the title, so the title ends up on top for small\n    # windows.\n    if scroll > 0:\n        _safe_hline(top_line_win, 0, 4, curses.ACS_UARROW, _N_SCROLL_ARROWS)\n\n    title = (\"Symbol\" if isinstance(node.item, Symbol) else\n             \"Choice\" if isinstance(node.item, Choice) else\n             \"Menu\"   if node.item == MENU else\n             \"Comment\") + \" information\"\n    _safe_addstr(top_line_win, 0, max((text_win_width - len(title))//2, 0),\n                 title)\n\n    top_line_win.noutrefresh()\n\n\ndef _info_str(node):\n    # Returns information about the menu node 'node' as a string.\n    #\n    # The helper functions are responsible for adding newlines. This allows\n    # them to return \"\" if they don't want to add any output.\n\n    if isinstance(node.item, Symbol):\n        sym = node.item\n\n        return (\n            _name_info(sym) +\n            _prompt_info(sym) +\n            \"Type: {}\\n\".format(TYPE_TO_STR[sym.type]) +\n            _value_info(sym) +\n            _help_info(sym) +\n            _direct_dep_info(sym) +\n            _defaults_info(sym) +\n            _select_imply_info(sym) +\n            _kconfig_def_info(sym)\n        )\n\n    if isinstance(node.item, Choice):\n        choice = node.item\n\n        return (\n            _name_info(choice) +\n            _prompt_info(choice) +\n            \"Type: {}\\n\".format(TYPE_TO_STR[choice.type]) +\n            'Mode: {}\\n'.format(choice.str_value) +\n            _help_info(choice) +\n            _choice_syms_info(choice) +\n            _direct_dep_info(choice) +\n            _defaults_info(choice) +\n            _kconfig_def_info(choice)\n        )\n\n    return _kconfig_def_info(node)  # node.item in (MENU, COMMENT)\n\n\ndef _name_info(sc):\n    # Returns a string with the name of the symbol/choice. Names are optional\n    # for choices.\n\n    return \"Name: {}\\n\".format(sc.name) if sc.name else \"\"\n\n\ndef _prompt_info(sc):\n    # Returns a string listing the prompts of 'sc' (Symbol or Choice)\n\n    s = \"\"\n\n    for node in sc.nodes:\n        if node.prompt:\n            s += \"Prompt: {}\\n\".format(node.prompt[0])\n\n    return s\n\n\ndef _value_info(sym):\n    # Returns a string showing 'sym's value\n\n    # Only put quotes around the value for string symbols\n    return \"Value: {}\\n\".format(\n        '\"{}\"'.format(sym.str_value)\n        if sym.orig_type == STRING\n        else sym.str_value)\n\n\ndef _choice_syms_info(choice):\n    # Returns a string listing the choice symbols in 'choice'. Adds\n    # \"(selected)\" next to the selected one.\n\n    s = \"Choice symbols:\\n\"\n\n    for sym in choice.syms:\n        s += \"  - \" + sym.name\n        if sym is choice.selection:\n            s += \" (selected)\"\n        s += \"\\n\"\n\n    return s + \"\\n\"\n\n\ndef _help_info(sc):\n    # Returns a string with the help text(s) of 'sc' (Symbol or Choice).\n    # Symbols and choices defined in multiple locations can have multiple help\n    # texts.\n\n    s = \"\\n\"\n\n    for node in sc.nodes:\n        if node.help is not None:\n            s += \"Help:\\n\\n{}\\n\\n\".format(_indent(node.help, 2))\n\n    return s\n\n\ndef _direct_dep_info(sc):\n    # Returns a string describing the direct dependencies of 'sc' (Symbol or\n    # Choice). The direct dependencies are the OR of the dependencies from each\n    # definition location. The dependencies at each definition location come\n    # from 'depends on' and dependencies inherited from parent items.\n\n    return \"\" if sc.direct_dep is _kconf.y else \\\n        'Direct dependencies (={}):\\n{}\\n' \\\n        .format(TRI_TO_STR[expr_value(sc.direct_dep)],\n                _split_expr_info(sc.direct_dep, 2))\n\n\ndef _defaults_info(sc):\n    # Returns a string describing the defaults of 'sc' (Symbol or Choice)\n\n    if not sc.defaults:\n        return \"\"\n\n    s = \"Default\"\n    if len(sc.defaults) > 1:\n        s += \"s\"\n    s += \":\\n\"\n\n    for val, cond in sc.orig_defaults:\n        s += \"  - \"\n        if isinstance(sc, Symbol):\n            s += _expr_str(val)\n\n            # Skip the tristate value hint if the expression is just a single\n            # symbol. _expr_str() already shows its value as a string.\n            #\n            # This also avoids showing the tristate value for string/int/hex\n            # defaults, which wouldn't make any sense.\n            if isinstance(val, tuple):\n                s += '  (={})'.format(TRI_TO_STR[expr_value(val)])\n        else:\n            # Don't print the value next to the symbol name for choice\n            # defaults, as it looks a bit confusing\n            s += val.name\n        s += \"\\n\"\n\n        if cond is not _kconf.y:\n            s += \"    Condition (={}):\\n{}\" \\\n                 .format(TRI_TO_STR[expr_value(cond)],\n                         _split_expr_info(cond, 4))\n\n    return s + \"\\n\"\n\n\ndef _split_expr_info(expr, indent):\n    # Returns a string with 'expr' split into its top-level && or || operands,\n    # with one operand per line, together with the operand's value. This is\n    # usually enough to get something readable for long expressions. A fancier\n    # recursive thingy would be possible too.\n    #\n    # indent:\n    #   Number of leading spaces to add before the split expression.\n\n    if len(split_expr(expr, AND)) > 1:\n        split_op = AND\n        op_str = \"&&\"\n    else:\n        split_op = OR\n        op_str = \"||\"\n\n    s = \"\"\n    for i, term in enumerate(split_expr(expr, split_op)):\n        s += \"{}{} {}\".format(indent*\" \",\n                              \"  \" if i == 0 else op_str,\n                              _expr_str(term))\n\n        # Don't bother showing the value hint if the expression is just a\n        # single symbol. _expr_str() already shows its value.\n        if isinstance(term, tuple):\n            s += \"  (={})\".format(TRI_TO_STR[expr_value(term)])\n\n        s += \"\\n\"\n\n    return s\n\n\ndef _select_imply_info(sym):\n    # Returns a string with information about which symbols 'select' or 'imply'\n    # 'sym'. The selecting/implying symbols are grouped according to which\n    # value they select/imply 'sym' to (n/m/y).\n\n    def sis(expr, val, title):\n        # sis = selects/implies\n        sis = [si for si in split_expr(expr, OR) if expr_value(si) == val]\n        if not sis:\n            return \"\"\n\n        res = title\n        for si in sis:\n            res += \"  - {}\\n\".format(split_expr(si, AND)[0].name)\n        return res + \"\\n\"\n\n    s = \"\"\n\n    if sym.rev_dep is not _kconf.n:\n        s += sis(sym.rev_dep, 2,\n                 \"Symbols currently y-selecting this symbol:\\n\")\n        s += sis(sym.rev_dep, 1,\n                 \"Symbols currently m-selecting this symbol:\\n\")\n        s += sis(sym.rev_dep, 0,\n                 \"Symbols currently n-selecting this symbol (no effect):\\n\")\n\n    if sym.weak_rev_dep is not _kconf.n:\n        s += sis(sym.weak_rev_dep, 2,\n                 \"Symbols currently y-implying this symbol:\\n\")\n        s += sis(sym.weak_rev_dep, 1,\n                 \"Symbols currently m-implying this symbol:\\n\")\n        s += sis(sym.weak_rev_dep, 0,\n                 \"Symbols currently n-implying this symbol (no effect):\\n\")\n\n    return s\n\n\ndef _kconfig_def_info(item):\n    # Returns a string with the definition of 'item' in Kconfig syntax,\n    # together with the definition location(s) and their include and menu paths\n\n    nodes = [item] if isinstance(item, MenuNode) else item.nodes\n\n    s = \"Kconfig definition{}, with parent deps. propagated to 'depends on'\\n\" \\\n        .format(\"s\" if len(nodes) > 1 else \"\")\n    s += (len(s) - 1)*\"=\"\n\n    for node in nodes:\n        s += \"\\n\\n\" \\\n             \"At {}:{}\\n\" \\\n             \"{}\" \\\n             \"Menu path: {}\\n\\n\" \\\n             \"{}\" \\\n             .format(node.filename, node.linenr,\n                     _include_path_info(node),\n                     _menu_path_info(node),\n                     _indent(node.custom_str(_name_and_val_str), 2))\n\n    return s\n\n\ndef _include_path_info(node):\n    if not node.include_path:\n        # In the top-level Kconfig file\n        return \"\"\n\n    return \"Included via {}\\n\".format(\n        \" -> \".join(\"{}:{}\".format(filename, linenr)\n                    for filename, linenr in node.include_path))\n\n\ndef _menu_path_info(node):\n    # Returns a string describing the menu path leading up to 'node'\n\n    path = \"\"\n\n    while node.parent is not _kconf.top_node:\n        node = node.parent\n\n        # Promptless choices might appear among the parents. Use\n        # standard_sc_expr_str() for them, so that they show up as\n        # '<choice (name if any)>'.\n        path = \" -> \" + (node.prompt[0] if node.prompt else\n                         standard_sc_expr_str(node.item)) + path\n\n    return \"(Top)\" + path\n\n\ndef _indent(s, n):\n    # Returns 's' with each line indented 'n' spaces. textwrap.indent() is not\n    # available in Python 2 (it's 3.3+).\n\n    return \"\\n\".join(n*\" \" + line for line in s.split(\"\\n\"))\n\n\ndef _name_and_val_str(sc):\n    # Custom symbol/choice printer that shows symbol values after symbols\n\n    # Show the values of non-constant (non-quoted) symbols that don't look like\n    # numbers. Things like 123 are actually symbol references, and only work as\n    # expected due to undefined symbols getting their name as their value.\n    # Showing the symbol value for those isn't helpful though.\n    if isinstance(sc, Symbol) and not sc.is_constant and not _is_num(sc.name):\n        if not sc.nodes:\n            # Undefined symbol reference\n            return \"{}(undefined/n)\".format(sc.name)\n\n        return '{}(={})'.format(sc.name, sc.str_value)\n\n    # For other items, use the standard format\n    return standard_sc_expr_str(sc)\n\n\ndef _expr_str(expr):\n    # Custom expression printer that shows symbol values\n    return expr_str(expr, _name_and_val_str)\n\n\ndef _styled_win(style):\n    # Returns a new curses window with style 'style' and space as the fill\n    # character. The initial dimensions are (1, 1), so the window needs to be\n    # sized and positioned separately.\n\n    win = curses.newwin(1, 1)\n    _set_style(win, style)\n    return win\n\n\ndef _set_style(win, style):\n    # Changes the style of an existing window\n\n    win.bkgdset(\" \", _style[style])\n\n\ndef _max_scroll(lst, win):\n    # Assuming 'lst' is a list of items to be displayed in 'win',\n    # returns the maximum number of steps 'win' can be scrolled down.\n    # We stop scrolling when the bottom item is visible.\n\n    return max(0, len(lst) - _height(win))\n\n\ndef _edit_text(c, s, i, hscroll, width):\n    # Implements text editing commands for edit boxes. Takes a character (which\n    # could also be e.g. curses.KEY_LEFT) and the edit box state, and returns\n    # the new state after the character has been processed.\n    #\n    # c:\n    #   Character from user\n    #\n    # s:\n    #   Current contents of string\n    #\n    # i:\n    #   Current cursor index in string\n    #\n    # hscroll:\n    #   Index in s of the leftmost character in the edit box, for horizontal\n    #   scrolling\n    #\n    # width:\n    #   Width in characters of the edit box\n    #\n    # Return value:\n    #   An (s, i, hscroll) tuple for the new state\n\n    if c == curses.KEY_LEFT:\n        if i > 0:\n            i -= 1\n\n    elif c == curses.KEY_RIGHT:\n        if i < len(s):\n            i += 1\n\n    elif c in (curses.KEY_HOME, \"\\x01\"):  # \\x01 = CTRL-A\n        i = 0\n\n    elif c in (curses.KEY_END, \"\\x05\"):  # \\x05 = CTRL-E\n        i = len(s)\n\n    elif c in (curses.KEY_BACKSPACE, _ERASE_CHAR):\n        if i > 0:\n            s = s[:i-1] + s[i:]\n            i -= 1\n\n    elif c == curses.KEY_DC:\n        s = s[:i] + s[i+1:]\n\n    elif c == \"\\x17\":  # \\x17 = CTRL-W\n        # The \\W removes characters like ',' one at a time\n        new_i = re.search(r\"(?:\\w*|\\W)\\s*$\", s[:i]).start()\n        s = s[:new_i] + s[i:]\n        i = new_i\n\n    elif c == \"\\x0B\":  # \\x0B = CTRL-K\n        s = s[:i]\n\n    elif c == \"\\x15\":  # \\x15 = CTRL-U\n        s = s[i:]\n        i = 0\n\n    elif isinstance(c, str):\n        # Insert character\n        s = s[:i] + c + s[i:]\n        i += 1\n\n    # Adjust the horizontal scroll so that the cursor never touches the left or\n    # right edges of the edit box, except when it's at the beginning or the end\n    # of the string\n    if i < hscroll + _SCROLL_OFFSET:\n        hscroll = max(i - _SCROLL_OFFSET, 0)\n    elif i >= hscroll + width - _SCROLL_OFFSET:\n        max_scroll = max(len(s) - width + 1, 0)\n        hscroll = min(i - width + _SCROLL_OFFSET + 1, max_scroll)\n\n    return s, i, hscroll\n\n\ndef _load_save_info():\n    # Returns an information string for load/save dialog boxes\n\n    return \"(Relative to {})\\n\\nRefer to your home directory with ~\" \\\n           .format(os.path.join(os.getcwd(), \"\"))\n\n\ndef _msg(title, text):\n    # Pops up a message dialog that can be dismissed with Space/Enter/ESC\n\n    _key_dialog(title, text, \" \\n\")\n\n\ndef _error(text):\n    # Pops up an error dialog that can be dismissed with Space/Enter/ESC\n\n    _msg(\"Error\", text)\n\n\ndef _node_str(node):\n    # Returns the complete menu entry text for a menu node.\n    #\n    # Example return value: \"[*] Support for X\"\n\n    # Calculate the indent to print the item with by checking how many levels\n    # above it the closest 'menuconfig' item is (this includes menus and\n    # choices as well as menuconfig symbols)\n    indent = 0\n    parent = node.parent\n    while not parent.is_menuconfig:\n        indent += _SUBMENU_INDENT\n        parent = parent.parent\n\n    # This approach gives nice alignment for empty string symbols (\"()  Foo\")\n    s = \"{:{}}\".format(_value_str(node), 3 + indent)\n\n    if _should_show_name(node):\n        if isinstance(node.item, Symbol):\n            s += \" <{}>\".format(node.item.name)\n        else:\n            # For choices, use standard_sc_expr_str(). That way they show up as\n            # '<choice (name if any)>'.\n            s += \" \" + standard_sc_expr_str(node.item)\n\n    if node.prompt:\n        if node.item == COMMENT:\n            s += \" *** {} ***\".format(node.prompt[0])\n        else:\n            s += \" \" + node.prompt[0]\n\n        if isinstance(node.item, Symbol):\n            sym = node.item\n\n            # Print \"(NEW)\" next to symbols without a user value (from e.g. a\n            # .config), but skip it for choice symbols in choices in y mode,\n            # and for symbols of UNKNOWN type (which generate a warning though)\n            if sym.user_value is None and sym.orig_type and \\\n               not (sym.choice and sym.choice.tri_value == 2):\n\n                s += \" (NEW)\"\n\n    if isinstance(node.item, Choice) and node.item.tri_value == 2:\n        # Print the prompt of the selected symbol after the choice for\n        # choices in y mode\n        sym = node.item.selection\n        if sym:\n            for sym_node in sym.nodes:\n                # Use the prompt used at this choice location, in case the\n                # choice symbol is defined in multiple locations\n                if sym_node.parent is node and sym_node.prompt:\n                    s += \" ({})\".format(sym_node.prompt[0])\n                    break\n            else:\n                # If the symbol isn't defined at this choice location, then\n                # just use whatever prompt we can find for it\n                for sym_node in sym.nodes:\n                    if sym_node.prompt:\n                        s += \" ({})\".format(sym_node.prompt[0])\n                        break\n\n    # Print \"--->\" next to nodes that have menus that can potentially be\n    # entered. Print \"----\" if the menu is empty. We don't allow those to be\n    # entered.\n    if node.is_menuconfig:\n        s += \"  --->\" if _shown_nodes(node) else \"  ----\"\n\n    return s\n\n\ndef _should_show_name(node):\n    # Returns True if 'node' is a symbol or choice whose name should shown (if\n    # any, as names are optional for choices)\n\n    # The 'not node.prompt' case only hits in show-all mode, for promptless\n    # symbols and choices\n    return not node.prompt or \\\n           (_show_name and isinstance(node.item, (Symbol, Choice)))\n\n\ndef _value_str(node):\n    # Returns the value part (\"[*]\", \"<M>\", \"(foo)\" etc.) of a menu node\n\n    item = node.item\n\n    if item in (MENU, COMMENT):\n        return \"\"\n\n    # Wouldn't normally happen, and generates a warning\n    if not item.orig_type:\n        return \"\"\n\n    if item.orig_type in (STRING, INT, HEX):\n        return \"({})\".format(item.str_value)\n\n    # BOOL or TRISTATE\n\n    if _is_y_mode_choice_sym(item):\n        return \"(X)\" if item.choice.selection is item else \"( )\"\n\n    tri_val_str = (\" \", \"M\", \"*\")[item.tri_value]\n\n    if len(item.assignable) <= 1:\n        # Pinned to a single value\n        return \"\" if isinstance(item, Choice) else \"-{}-\".format(tri_val_str)\n\n    if item.type == BOOL:\n        return \"[{}]\".format(tri_val_str)\n\n    # item.type == TRISTATE\n    if item.assignable == (1, 2):\n        return \"{{{}}}\".format(tri_val_str)  # {M}/{*}\n    return \"<{}>\".format(tri_val_str)\n\n\ndef _is_y_mode_choice_sym(item):\n    # The choice mode is an upper bound on the visibility of choice symbols, so\n    # we can check the choice symbols' own visibility to see if the choice is\n    # in y mode\n    return isinstance(item, Symbol) and item.choice and item.visibility == 2\n\n\ndef _check_valid(sym, s):\n    # Returns True if the string 's' is a well-formed value for 'sym'.\n    # Otherwise, displays an error and returns False.\n\n    if sym.orig_type not in (INT, HEX):\n        return True  # Anything goes for non-int/hex symbols\n\n    base = 10 if sym.orig_type == INT else 16\n    try:\n        int(s, base)\n    except ValueError:\n        _error(\"'{}' is a malformed {} value\"\n               .format(s, TYPE_TO_STR[sym.orig_type]))\n        return False\n\n    for low_sym, high_sym, cond in sym.ranges:\n        if expr_value(cond):\n            low_s = low_sym.str_value\n            high_s = high_sym.str_value\n\n            if not int(low_s, base) <= int(s, base) <= int(high_s, base):\n                _error(\"{} is outside the range {}-{}\"\n                       .format(s, low_s, high_s))\n                return False\n\n            break\n\n    return True\n\n\ndef _range_info(sym):\n    # Returns a string with information about the valid range for the symbol\n    # 'sym', or None if 'sym' doesn't have a range\n\n    if sym.orig_type in (INT, HEX):\n        for low, high, cond in sym.ranges:\n            if expr_value(cond):\n                return \"Range: {}-{}\".format(low.str_value, high.str_value)\n\n    return None\n\n\ndef _is_num(name):\n    # Heuristic to see if a symbol name looks like a number, for nicer output\n    # when printing expressions. Things like 16 are actually symbol names, only\n    # they get their name as their value when the symbol is undefined.\n\n    try:\n        int(name)\n    except ValueError:\n        if not name.startswith((\"0x\", \"0X\")):\n            return False\n\n        try:\n            int(name, 16)\n        except ValueError:\n            return False\n\n    return True\n\n\ndef _getch_compat(win):\n    # Uses get_wch() if available (Python 3.3+) and getch() otherwise.\n    #\n    # Also falls back on getch() if get_wch() raises curses.error, to work\n    # around an issue when resizing the terminal on at least macOS Catalina.\n    # See https://github.com/ulfalizer/Kconfiglib/issues/84.\n    #\n    # Also handles a PDCurses resizing quirk.\n\n    try:\n        c = win.get_wch()\n    except (AttributeError, curses.error):\n        c = win.getch()\n        if 0 <= c <= 255:\n            c = chr(c)\n\n    # Decent resizing behavior on PDCurses requires calling resize_term(0, 0)\n    # after receiving KEY_RESIZE, while ncurses (usually) handles terminal\n    # resizing automatically in get(_w)ch() (see the end of the\n    # resizeterm(3NCURSES) man page).\n    #\n    # resize_term(0, 0) reliably fails and does nothing on ncurses, so this\n    # hack gives ncurses/PDCurses compatibility for resizing. I don't know\n    # whether it would cause trouble for other implementations.\n    if c == curses.KEY_RESIZE:\n        try:\n            curses.resize_term(0, 0)\n        except curses.error:\n            pass\n\n    return c\n\n\ndef _warn(*args):\n    # Temporarily returns from curses to shell mode and prints a warning to\n    # stderr. The warning would get lost in curses mode.\n    curses.endwin()\n    print(\"menuconfig warning: \", end=\"\", file=sys.stderr)\n    print(*args, file=sys.stderr)\n    curses.doupdate()\n\n\n# Ignore exceptions from some functions that might fail, e.g. for small\n# windows. They usually do reasonable things anyway.\n\n\ndef _safe_curs_set(visibility):\n    try:\n        curses.curs_set(visibility)\n    except curses.error:\n        pass\n\n\ndef _safe_addstr(win, *args):\n    # Clip the line to avoid wrapping to the next line, which looks glitchy.\n    # addchstr() would do it for us, but it's not available in the 'curses'\n    # module.\n\n    attr = None\n    if isinstance(args[0], str):\n        y, x = win.getyx()\n        s = args[0]\n        if len(args) == 2:\n            attr = args[1]\n    else:\n        y, x, s = args[:3]\n        if len(args) == 4:\n            attr = args[3]\n\n    maxlen = _width(win) - x\n    s = s.expandtabs()\n\n    try:\n        # The 'curses' module uses wattr_set() internally if you pass 'attr',\n        # overwriting the background style, so setting 'attr' to 0 in the first\n        # case won't do the right thing\n        if attr is None:\n            win.addnstr(y, x, s, maxlen)\n        else:\n            win.addnstr(y, x, s, maxlen, attr)\n    except curses.error:\n        pass\n\n\ndef _safe_addch(win, *args):\n    try:\n        win.addch(*args)\n    except curses.error:\n        pass\n\n\ndef _safe_hline(win, *args):\n    try:\n        win.hline(*args)\n    except curses.error:\n        pass\n\n\ndef _safe_vline(win, *args):\n    try:\n        win.vline(*args)\n    except curses.error:\n        pass\n\n\ndef _safe_move(win, *args):\n    try:\n        win.move(*args)\n    except curses.error:\n        pass\n\n\ndef _change_c_lc_ctype_to_utf8():\n    # See _CHANGE_C_LC_CTYPE_TO_UTF8\n\n    if _IS_WINDOWS:\n        # Windows rarely has issues here, and the PEP 538 implementation avoids\n        # changing the locale on it. None of the UTF-8 locales below were\n        # supported from some quick testing either. Play it safe.\n        return\n\n    def try_set_locale(loc):\n        try:\n            locale.setlocale(locale.LC_CTYPE, loc)\n            return True\n        except locale.Error:\n            return False\n\n    # Is LC_CTYPE set to the C locale?\n    if locale.setlocale(locale.LC_CTYPE) == \"C\":\n        # This list was taken from the PEP 538 implementation in the CPython\n        # code, in Python/pylifecycle.c\n        for loc in \"C.UTF-8\", \"C.utf8\", \"UTF-8\":\n            if try_set_locale(loc):\n                # LC_CTYPE successfully changed\n                return\n\n\nif __name__ == \"__main__\":\n    _main()\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/oldconfig.py",
    "content": "#!/usr/bin/env python3\n\n# Copyright (c) 2018-2019, Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nImplements oldconfig functionality.\n\n  1. Loads existing .config\n  2. Prompts for the value of all modifiable symbols/choices that\n     aren't already set in the .config\n  3. Writes an updated .config\n\nThe default input/output filename is '.config'. A different filename can be\npassed in the KCONFIG_CONFIG environment variable.\n\nWhen overwriting a configuration file, the old version is saved to\n<filename>.old (e.g. .config.old).\n\nEntering '?' displays the help text of the symbol/choice, if any.\n\nUnlike 'make oldconfig', this script doesn't print menu titles and comments,\nbut gives Kconfig definition locations. Printing menus and comments would be\npretty easy to add: Look at the parents of each item, and print all menu\nprompts and comments unless they have already been printed (assuming you want\nto skip \"irrelevant\" menus).\n\"\"\"\nfrom __future__ import print_function\n\nimport sys\n\nfrom kconfiglib import Symbol, Choice, BOOL, TRISTATE, HEX, standard_kconfig\n\n\n# Python 2/3 compatibility hack\nif sys.version_info[0] < 3:\n    input = raw_input\n\n\ndef _main():\n    # Earlier symbols in Kconfig files might depend on later symbols and become\n    # visible if their values change. This flag is set to True if the value of\n    # any symbol changes, in which case we rerun the oldconfig to check for new\n    # visible symbols.\n    global conf_changed\n\n    kconf = standard_kconfig(__doc__)\n    print(kconf.load_config())\n\n    while True:\n        conf_changed = False\n\n        for node in kconf.node_iter():\n            oldconfig(node)\n\n        if not conf_changed:\n            break\n\n    print(kconf.write_config())\n\n\ndef oldconfig(node):\n    \"\"\"\n    Prompts the user for a value if node.item is a visible symbol/choice with\n    no user value.\n    \"\"\"\n    # See main()\n    global conf_changed\n\n    # Only symbols and choices can be configured\n    if not isinstance(node.item, (Symbol, Choice)):\n        return\n\n    # Skip symbols and choices that aren't visible\n    if not node.item.visibility:\n        return\n\n    # Skip symbols and choices that don't have a prompt (at this location)\n    if not node.prompt:\n        return\n\n    if isinstance(node.item, Symbol):\n        sym = node.item\n\n        # Skip symbols that already have a user value\n        if sym.user_value is not None:\n            return\n\n        # Skip symbols that can only have a single value, due to selects\n        if len(sym.assignable) == 1:\n            return\n\n        # Skip symbols in choices in y mode. We ask once for the entire choice\n        # instead.\n        if sym.choice and sym.choice.tri_value == 2:\n            return\n\n        # Loop until the user enters a valid value or enters a blank string\n        # (for the default value)\n        while True:\n            val = input(\"{} ({}) [{}] \".format(\n                node.prompt[0], _name_and_loc_str(sym),\n                _default_value_str(sym)))\n\n            if val == \"?\":\n                _print_help(node)\n                continue\n\n            # Substitute a blank string with the default value the symbol\n            # would get\n            if not val:\n                val = sym.str_value\n\n            # Automatically add a \"0x\" prefix for hex symbols, like the\n            # menuconfig interface does. This isn't done when loading .config\n            # files, hence why set_value() doesn't do it automatically.\n            if sym.type == HEX and not val.startswith((\"0x\", \"0X\")):\n                val = \"0x\" + val\n\n            old_str_val = sym.str_value\n\n            # Kconfiglib itself will print a warning here if the value\n            # is invalid, so we don't need to bother\n            if sym.set_value(val):\n                # Valid value input. We're done with this node.\n\n                if sym.str_value != old_str_val:\n                    conf_changed = True\n\n                return\n\n    else:\n        choice = node.item\n\n        # Skip choices that already have a visible user selection...\n        if choice.user_selection and choice.user_selection.visibility == 2:\n            # ...unless there are new visible symbols in the choice. (We know\n            # they have y (2) visibility in that case, because m-visible\n            # symbols get demoted to n-visibility in y-mode choices, and the\n            # user-selected symbol had visibility y.)\n            for sym in choice.syms:\n                if sym is not choice.user_selection and sym.visibility and \\\n                   sym.user_value is None:\n                    # New visible symbols in the choice\n                    break\n            else:\n                # No new visible symbols in the choice\n                return\n\n        # Get a list of available selections. The mode of the choice limits\n        # the visibility of the choice value symbols, so this will indirectly\n        # skip choices in n and m mode.\n        options = [sym for sym in choice.syms if sym.visibility == 2]\n\n        if not options:\n            # No y-visible choice value symbols\n            return\n\n        # Loop until the user enters a valid selection or a blank string (for\n        # the default selection)\n        while True:\n            print(\"{} ({})\".format(node.prompt[0], _name_and_loc_str(choice)))\n\n            for i, sym in enumerate(options, 1):\n                print(\"{} {}. {} ({})\".format(\n                    \">\" if sym is choice.selection else \" \",\n                    i,\n                    # Assume people don't define choice symbols with multiple\n                    # prompts. That generates a warning anyway.\n                    sym.nodes[0].prompt[0],\n                    sym.name))\n\n            sel_index = input(\"choice[1-{}]: \".format(len(options)))\n\n            if sel_index == \"?\":\n                _print_help(node)\n                continue\n\n            # Pick the default selection if the string is blank\n            if not sel_index:\n                choice.selection.set_value(2)\n                break\n\n            try:\n                sel_index = int(sel_index)\n            except ValueError:\n                print(\"Bad index\", file=sys.stderr)\n                continue\n\n            if not 1 <= sel_index <= len(options):\n                print(\"Bad index\", file=sys.stderr)\n                continue\n\n            # Valid selection\n\n            if options[sel_index - 1].tri_value != 2:\n                conf_changed = True\n\n            options[sel_index - 1].set_value(2)\n            break\n\n        # Give all of the non-selected visible choice symbols the user value n.\n        # This makes it so that the choice is no longer considered new once we\n        # do additional passes, if the reason that it was considered new was\n        # that it had new visible choice symbols.\n        #\n        # Only giving visible choice symbols the user value n means we will\n        # prompt for the choice again if later user selections make more new\n        # choice symbols visible, which is correct.\n        for sym in choice.syms:\n            if sym is not choice.user_selection and sym.visibility:\n                sym.set_value(0)\n\n\ndef _name_and_loc_str(sc):\n    # Helper for printing the name of the symbol/choice 'sc' along with the\n    # location(s) in the Kconfig files where it is defined. Unnamed choices\n    # return \"choice\" instead of the name.\n\n    return \"{}, defined at {}\".format(\n        sc.name or \"choice\",\n        \", \".join(\"{}:{}\".format(node.filename, node.linenr)\n                  for node in sc.nodes))\n\n\ndef _print_help(node):\n    print(\"\\n\" + (node.help or \"No help text\\n\"))\n\n\ndef _default_value_str(sym):\n    # Returns the \"m/M/y\" string in e.g.\n    #\n    #   TRISTATE_SYM prompt (TRISTATE_SYM, defined at Kconfig:9) [n/M/y]:\n    #\n    # For string/int/hex, returns the default value as-is.\n\n    if sym.type in (BOOL, TRISTATE):\n        return \"/\".join((\"NMY\" if sym.tri_value == tri else \"nmy\")[tri]\n                        for tri in sym.assignable)\n\n    # string/int/hex\n    return sym.str_value\n\n\nif __name__ == \"__main__\":\n    _main()\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/olddefconfig.py",
    "content": "#!/usr/bin/env python3\n\n# Copyright (c) 2018-2019, Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nUpdates an old .config file or creates a new one, by filling in default values\nfor all new symbols. This is the same as picking the default selection for all\nsymbols in oldconfig, or entering the menuconfig interface and immediately\nsaving.\n\nThe default input/output filename is '.config'. A different filename can be\npassed in the KCONFIG_CONFIG environment variable.\n\nWhen overwriting a configuration file, the old version is saved to\n<filename>.old (e.g. .config.old).\n\"\"\"\nimport kconfiglib\n\n\ndef main():\n    kconf = kconfiglib.standard_kconfig(__doc__)\n    print(kconf.load_config())\n    print(kconf.write_config())\n\n\nif __name__ == \"__main__\":\n    main()\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/savedefconfig.py",
    "content": "#!/usr/bin/env python3\n\n# Copyright (c) 2019, Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nSaves a minimal configuration file that only lists symbols that differ in value\nfrom their defaults. Loading such a configuration file is equivalent to loading\nthe \"full\" configuration file.\n\nMinimal configuration files are handy to start from when editing configuration\nfiles by hand.\n\nThe default input configuration file is '.config'. A different input filename\ncan be passed in the KCONFIG_CONFIG environment variable.\n\nNote: Minimal configurations can also be generated from within the menuconfig\ninterface.\n\"\"\"\nimport argparse\n\nimport kconfiglib\n\n\ndef main():\n    parser = argparse.ArgumentParser(\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n        description=__doc__)\n\n    parser.add_argument(\n        \"--kconfig\",\n        default=\"Kconfig\",\n        help=\"Top-level Kconfig file (default: Kconfig)\")\n\n    parser.add_argument(\n        \"--out\",\n        metavar=\"MINIMAL_CONFIGURATION\",\n        default=\"defconfig\",\n        help=\"Output filename for minimal configuration (default: defconfig)\")\n\n    args = parser.parse_args()\n\n    kconf = kconfiglib.Kconfig(args.kconfig, suppress_traceback=True)\n    print(kconf.load_config())\n    print(kconf.write_min_config(args.out))\n\n\nif __name__ == \"__main__\":\n    main()\n"
  },
  {
    "path": "ftpm-opensbi/scripts/Kconfiglib/setconfig.py",
    "content": "#!/usr/bin/env python3\n\n# Copyright (c) 2019, Ulf Magnusson\n# SPDX-License-Identifier: ISC\n\n\"\"\"\nSimple utility for setting configuration values from the command line.\n\nSample usage:\n\n  $ setconfig FOO_SUPPORT=y BAR_BITS=8\n\nNote: Symbol names should not be prefixed with 'CONFIG_'.\n\nThe exit status on errors is 1.\n\nThe default input/output configuration file is '.config'. A different filename\ncan be passed in the KCONFIG_CONFIG environment variable.\n\nWhen overwriting a configuration file, the old version is saved to\n<filename>.old (e.g. .config.old).\n\"\"\"\nimport argparse\nimport sys\n\nimport kconfiglib\n\n\ndef main():\n    parser = argparse.ArgumentParser(\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n        description=__doc__)\n\n    parser.add_argument(\n        \"--kconfig\",\n        default=\"Kconfig\",\n        help=\"Top-level Kconfig file (default: Kconfig)\")\n\n    parser.add_argument(\n        \"--no-check-exists\",\n        dest=\"check_exists\",\n        action=\"store_false\",\n        help=\"Ignore assignments to non-existent symbols instead of erroring \"\n             \"out\")\n\n    parser.add_argument(\n        \"--no-check-value\",\n        dest=\"check_value\",\n        action=\"store_false\",\n        help=\"Ignore assignments that didn't \\\"take\\\" (where the symbol got a \"\n             \"different value, e.g. due to unsatisfied dependencies) instead \"\n             \"of erroring out\")\n\n    parser.add_argument(\n        \"assignments\",\n        metavar=\"ASSIGNMENT\",\n        nargs=\"*\",\n        help=\"A 'NAME=value' assignment\")\n\n    args = parser.parse_args()\n\n    kconf = kconfiglib.Kconfig(args.kconfig, suppress_traceback=True)\n    print(kconf.load_config())\n\n    for arg in args.assignments:\n        if \"=\" not in arg:\n            sys.exit(\"error: no '=' in assignment: '{}'\".format(arg))\n        name, value = arg.split(\"=\", 1)\n\n        if name not in kconf.syms:\n            if not args.check_exists:\n                continue\n            sys.exit(\"error: no symbol '{}' in configuration\".format(name))\n\n        sym = kconf.syms[name]\n\n        if not sym.set_value(value):\n            sys.exit(\"error: '{}' is an invalid value for the {} symbol {}\"\n                     .format(value, kconfiglib.TYPE_TO_STR[sym.orig_type],\n                             name))\n\n        if args.check_value and sym.str_value != value:\n            sys.exit(\"error: {} was assigned the value '{}', but got the \"\n                     \"value '{}'. Check the symbol's dependencies, and make \"\n                     \"sure that it has a prompt.\"\n                     .format(name, value, sym.str_value))\n\n    print(kconf.write_config())\n\n\nif __name__ == \"__main__\":\n    main()\n"
  },
  {
    "path": "ftpm-opensbi/scripts/carray.sh",
    "content": "#!/usr/bin/env bash\n\nfunction usage()\n{\n\techo \"Usage:\"\n\techo \" $0 [options]\"\n\techo \"Options:\"\n\techo \"     -h                   Display help or usage\"\n\techo \"     -i <input_config>    Input config file\"\n\techo \"     -l <variable_list>   List of variables in the array (Optional)\"\n\texit 1;\n}\n\n# Command line options\nCONFIG_FILE=\"\"\nVAR_LIST=\"\"\n\nwhile getopts \"hi:l:\" o; do\n\tcase \"${o}\" in\n\th)\n\t\tusage\n\t\t;;\n\ti)\n\t\tCONFIG_FILE=${OPTARG}\n\t\t;;\n\tl)\n\t\tVAR_LIST=${OPTARG}\n\t\t;;\n\t*)\n\t\tusage\n\t\t;;\n\tesac\ndone\nshift $((OPTIND-1))\n\nif [ -z \"${CONFIG_FILE}\" ]; then\n\techo \"Must specify input config file\"\n\tusage\nfi\n\nif [ ! -f \"${CONFIG_FILE}\" ]; then\n\techo \"The input config file should be a present\"\n\tusage\nfi\n\nTYPE_HEADER=`cat ${CONFIG_FILE} | awk '{ if ($1 == \"HEADER:\") { printf $2; exit 0; } }'`\nif [ -z \"${TYPE_HEADER}\" ]; then\n\techo \"Must specify HEADER: in input config file\"\n\tusage\nfi\n\nTYPE_NAME=`cat ${CONFIG_FILE} | awk '{ if ($1 == \"TYPE:\") { printf $2; for (i=3; i<=NF; i++) printf \" %s\", $i; exit 0; } }'`\nif [ -z \"${TYPE_NAME}\" ]; then\n\techo \"Must specify TYPE: in input config file\"\n\tusage\nfi\n\nARRAY_NAME=`cat ${CONFIG_FILE} | awk '{ if ($1 == \"NAME:\") { printf $2; exit 0; } }'`\nif [ -z \"${ARRAY_NAME}\" ]; then\n\techo \"Must specify NAME: in input config file\"\n\tusage\nfi\n\nprintf \"#include <%s>\\n\\n\" \"${TYPE_HEADER}\"\n\nfor VAR in ${VAR_LIST}; do\n\tprintf \"extern %s %s;\\n\" \"${TYPE_NAME}\" \"${VAR}\"\ndone\nprintf \"\\n\"\n\nprintf \"%s *%s[] = {\\n\" \"${TYPE_NAME}\" \"${ARRAY_NAME}\"\nfor VAR in ${VAR_LIST}; do\n\tprintf \"\\t&%s,\\n\" \"${VAR}\"\ndone\nprintf \"};\\n\\n\"\n\nprintf \"unsigned long %s_size = sizeof(%s) / sizeof(%s *);\\n\" \"${ARRAY_NAME}\" \"${ARRAY_NAME}\" \"${TYPE_NAME}\"\n"
  },
  {
    "path": "ftpm-opensbi/scripts/create-binary-archive.sh",
    "content": "#!/usr/bin/env bash\n\nfunction usage()\n{\n\techo \"Usage:\"\n\techo \" $0 [options]\"\n\techo \"Options:\"\n\techo \"     -h                       Display help or usage\"\n\techo \"     -p <opensbi_source_path> OpenSBI source path\"\n\techo \"     -o <output_path>         Build output path\"\n\techo \"     -d                       Build and install documentation\"\n\techo \"     -t                       Build only with no archive created\"\n\techo \"     -j <num_threads>         Number of threads for Make (Default: 1)\"\n\techo \"     -s <archive_suffix>      Archive name suffix (Default: unknown)\"\n\techo \"     -x <riscv_xlen>          RISC-V XLENs for Build (Default: 0)\"\n\techo \"                                 0: RV32 and RV64\"\n\techo \"                                32: RV32 only\"\n\techo \"                                64: RV64 only\"\n\texit 1;\n}\n\n# Command line options\nNUM_THREADS=1\nOUTPUT_PATH=\"$(pwd)/build\"\nOPENSBI_SOURCE_PATH=\"$(pwd)\"\nNEED_DOCS=\"no\"\nCOMPILE_ONLY=\"no\"\nARCHIVE_SUFFIX=\"unknown\"\nRISCV_XLEN=0\n\nwhile getopts \"hdtj:o:p:s:x:\" o; do\n\tcase \"${o}\" in\n\th)\n\t\tusage\n\t\t;;\n\td)\n\t\tNEED_DOCS=\"yes\"\n\t\t;;\n\tt)\n\t\tCOMPILE_ONLY=\"yes\"\n\t\t;;\n\tj)\n\t\tNUM_THREADS=${OPTARG}\n\t\t;;\n\to)\n\t\tOUTPUT_PATH=${OPTARG}\n\t\t;;\n\tp)\n\t\tOPENSBI_SOURCE_PATH=${OPTARG}\n\t\t;;\n\ts)\n\t\tARCHIVE_SUFFIX=${OPTARG}\n\t\t;;\n\tx)\n\t\tRISCV_XLEN=${OPTARG}\n\t\t;;\n\t*)\n\t\tusage\n\t\t;;\n\tesac\ndone\nshift $((OPTIND-1))\n\nif [ -z \"${OPENSBI_SOURCE_PATH}\" ]; then\n\techo \"Must specify OpenSBI source path\"\n\tusage\nfi\n\nif [ ! -d \"${OPENSBI_SOURCE_PATH}\" ]; then\n\techo \"OpenSBI source path does not exist\"\n\tusage\nfi\n\nif [ -z \"${ARCHIVE_SUFFIX}\" ]; then\n\techo \"Archive suffice cannot be empty\"\n\tusage\nfi\n\nbuild_opensbi() {\n\t# Setup parameters\n\tBUILD_NUM_THREADS=$1\n\tBUILD_OUTPUT_PATH=$2\n\tBUILD_OPENSBI_SOURCE_PATH=$3\n\tBUILD_DOCS=$4\n\tBUILD_ONLY=$5\n\tBUILD_RISCV_XLEN=$6\n\tBUILD_ARCHIVE_RISCV_XLEN=$7\n\tBUILD_ARCHIVE_SUFFIX=$8\n\n\t# Setup derived parameters\n\tBUILD_VERSION_MAJOR=$(grep \"define OPENSBI_VERSION_MAJOR\" \"${BUILD_OPENSBI_SOURCE_PATH}/include/sbi/sbi_version.h\" | sed 's/.*MAJOR.*\\([0-9][0-9]*\\)/\\1/')\n\tBUILD_VERSION_MINOR=$(grep \"define OPENSBI_VERSION_MINOR\" \"${BUILD_OPENSBI_SOURCE_PATH}/include/sbi/sbi_version.h\" | sed 's/.*MINOR.*\\([0-9][0-9]*\\)/\\1/')\n\tBUILD_NAME=\"opensbi-${BUILD_VERSION_MAJOR}.${BUILD_VERSION_MINOR}-rv${BUILD_RISCV_XLEN}\"\n\tBUILD_ARCHIVE_NAME=\"opensbi-${BUILD_VERSION_MAJOR}.${BUILD_VERSION_MINOR}-rv${BUILD_ARCHIVE_RISCV_XLEN}-${BUILD_ARCHIVE_SUFFIX}\"\n\tcase \"${BUILD_RISCV_XLEN}\" in\n\t32)\n\t\t# Setup 32-bit platform list\n\t\tBUILD_PLATFORM_SUBDIR+=(\"generic\")\n\t\t;;\n\t64)\n\t\t# Setup 64-bit platform list\n\t\tBUILD_PLATFORM_SUBDIR+=(\"nuclei/ux600\")\n\t\tBUILD_PLATFORM_SUBDIR+=(\"kendryte/k210\")\n\t\tBUILD_PLATFORM_SUBDIR+=(\"fpga/ariane\")\n\t\tBUILD_PLATFORM_SUBDIR+=(\"fpga/openpiton\")\n\t\tBUILD_PLATFORM_SUBDIR+=(\"generic\")\n\t\t;;\n\t*)\n\t\techo \"Invalid Build RISC-V XLEN\"\n\t\tusage\n\t\t;;\n\tesac\n\n\t# Ensure output directory is present\n\tmkdir -p \"${BUILD_OUTPUT_PATH}/${BUILD_NAME}\"\n\n\t# Build and install generic library\n\techo \"Build and install generic library XLEN=${BUILD_RISCV_XLEN}\"\n\techo \"\"\n\tmake -C \"${BUILD_OPENSBI_SOURCE_PATH}\" O=\"${BUILD_OUTPUT_PATH}/${BUILD_NAME}\" I=\"${BUILD_OUTPUT_PATH}/${BUILD_ARCHIVE_NAME}\" PLATFORM_RISCV_XLEN=\"${BUILD_RISCV_XLEN}\" install_libsbi -j \"${BUILD_NUM_THREADS}\"\n\techo \"\"\n\n\t# Build and install relevant platforms\n\tfor INDEX in $(seq 0 1 \"$(expr ${#BUILD_PLATFORM_SUBDIR[*]} - 1)\")\n\tdo\n\t\techo \"Build and install PLATFORM=${BUILD_PLATFORM_SUBDIR[${INDEX}]} XLEN=${BUILD_RISCV_XLEN}\"\n\t\techo \"\"\n\t\tmake -C \"${BUILD_OPENSBI_SOURCE_PATH}\" O=\"${BUILD_OUTPUT_PATH}/${BUILD_NAME}\" I=\"${BUILD_OUTPUT_PATH}/${BUILD_ARCHIVE_NAME}\" PLATFORM=\"${BUILD_PLATFORM_SUBDIR[${INDEX}]}\" PLATFORM_RISCV_XLEN=\"${BUILD_RISCV_XLEN}\" install_libplatsbi install_firmwares -j \"${BUILD_NUM_THREADS}\"\n\t\techo \"\"\n\tdone\n\n\t# Build and install docs\n\tif [ \"${BUILD_DOCS}\" == \"yes\" ]; then\n\t\techo \"Build and install docs\"\n\t\techo \"\"\n\t\tmake -C \"${BUILD_OPENSBI_SOURCE_PATH}\" O=\"${BUILD_OUTPUT_PATH}/${BUILD_NAME}\" I=\"${BUILD_OUTPUT_PATH}/${BUILD_ARCHIVE_NAME}\" install_docs\n\t\techo \"\"\n\tfi\n\n\t# Create archive file\n\tif [ \"${BUILD_ONLY}\" == \"no\" ]; then\n\t\techo \"Create archive ${BUILD_ARCHIVE_NAME}.tar.xz\"\n\t\techo \"\"\n\t\ttar  -C \"${BUILD_OUTPUT_PATH}\" -cJvf \"${BUILD_OUTPUT_PATH}/${BUILD_ARCHIVE_NAME}.tar.xz\" \"${BUILD_ARCHIVE_NAME}\"\n\t\techo \"\"\n\tfi\n}\n\ncase \"${RISCV_XLEN}\" in\n0)\n\tbuild_opensbi ${NUM_THREADS} ${OUTPUT_PATH} ${OPENSBI_SOURCE_PATH} \"no\" \"yes\" \"32\" \"\" ${ARCHIVE_SUFFIX}\n\tbuild_opensbi ${NUM_THREADS} ${OUTPUT_PATH} ${OPENSBI_SOURCE_PATH} ${NEED_DOCS} ${COMPILE_ONLY} \"64\" \"\" ${ARCHIVE_SUFFIX}\n\t;;\n32)\n\tbuild_opensbi ${NUM_THREADS} ${OUTPUT_PATH} ${OPENSBI_SOURCE_PATH} ${NEED_DOCS} ${COMPILE_ONLY} \"32\" \"32\" ${ARCHIVE_SUFFIX}\n\t;;\n64)\n\tbuild_opensbi ${NUM_THREADS} ${OUTPUT_PATH} ${OPENSBI_SOURCE_PATH} ${NEED_DOCS} ${COMPILE_ONLY} \"64\" \"64\" ${ARCHIVE_SUFFIX}\n\t;;\n*)\n\techo \"Invalid RISC-V XLEN\"\n\tusage\n\t;;\nesac\n"
  },
  {
    "path": "ftpm-opensbi/scripts/d2c.sh",
    "content": "#!/usr/bin/env bash\n\nfunction usage()\n{\n\techo \"Usage:\"\n\techo \" $0 [options]\"\n\techo \"Options:\"\n\techo \"     -h                   Display help or usage\"\n\techo \"     -i <input_file_path> Input binary file path\"\n\techo \"     -a <c_align>         Output C array alignment\"\n\techo \"     -p <c_prefix>        Output C array name prefix\"\n\techo \"     -t <num_zero_bytes>  Output padding zero bytes\"\n\texit 1;\n}\n\n# Command line options\nINPUT_PATH=\"\"\nOUTPUT_C_ALIGN=\"\"\nOUTPUT_C_PREFIX=\"\"\nNUM_ZERO_BYTES=0\n\nwhile getopts \"hi:a:p:t:\" o; do\n\tcase \"${o}\" in\n\th)\n\t\tusage\n\t\t;;\n\ti)\n\t\tINPUT_PATH=${OPTARG}\n\t\t;;\n\ta)\n\t\tOUTPUT_C_ALIGN=${OPTARG}\n\t\t;;\n\tp)\n\t\tOUTPUT_C_PREFIX=${OPTARG}\n\t\t;;\n\tt)\n\t\tNUM_ZERO_BYTES=${OPTARG}\n\t\t;;\n\t*)\n\t\tusage\n\t\t;;\n\tesac\ndone\nshift $((OPTIND-1))\n\nif [ -z \"${INPUT_PATH}\" ]; then\n\techo \"Must specify input file path\"\n\tusage\nfi\n\nif [ ! -f \"${INPUT_PATH}\" ]; then\n\techo \"The input path should be a file\"\n\tusage\nfi\n\nif [ -z \"${OUTPUT_C_ALIGN}\" ]; then\n\techo \"Must provide output C array alignment\"\n\tusage\nfi\n\nif [ -z \"${OUTPUT_C_PREFIX}\" ]; then\n\techo \"Must provide output C array name prefix\"\n\tusage\nfi\n\nprintf \"const char __attribute__((aligned(%s))) %s_start[] = {\\n\" \"${OUTPUT_C_ALIGN}\" \"${OUTPUT_C_PREFIX}\"\n\nod -v -t x1 -An ${INPUT_PATH} | awk '{for (i=1; i<=NF; i++) printf \" 0x%s,\", $i; printf \"\\n\"; }'\n\necho __dummy__ | awk \"{for (i=1; i<=${NUM_ZERO_BYTES}; i++) { printf \\\" 0x00,\\\"; if (i % 16 == 0) printf \\\"\\n\\\"; } }\"\n\nprintf \"};\\n\"\n\nprintf \"const unsigned long %s_size = sizeof(%s_start);\\n\" \"${OUTPUT_C_PREFIX}\" \"${OUTPUT_C_PREFIX}\"\n"
  },
  {
    "path": "ftpm-opensbi/src/ACTCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tAuthenticated COuntdown Timer Commands\t \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id$\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"ACT_SetTimeout_fp.h\"\n\nextern int verbose;\n\n#if CC_ACT_SetTimeout  // Conditional expansion of this file\n\n/* Error Returns\tMeaning */\n/* TPM_RC_RETRY\treturned when an update for the selected ACT is already pending */\n/* TPM_RC_VALUE\tattempt to disable signaling from an ACT that has not expired */\nTPM_RC\nTPM2_ACT_SetTimeout(\n\t\t    ACT_SetTimeout_In      *in             // IN: input parameter list\n\t\t    )\n{\n    // If 'startTimeout' is UINT32_MAX, then this is an attempt to disable the ACT\n    // and turn off the signaling for the ACT. This is only valid if the ACT\n    // is signaling.\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ACT_SetTimeout: actHandle %08x\\n\", in->actHandle);\n\t// fclose(f);\n  //   }\n    if((in->startTimeout == UINT32_MAX) && !ActGetSignaled(in->actHandle))\n\treturn TPM_RC_VALUE + RC_ACT_SetTimeout_startTimeout;\n    return ActCounterUpdate(in->actHandle, in->startTimeout);\n}\n#endif // CC_ACT_SetTimeout\n"
  },
  {
    "path": "ftpm-opensbi/src/ACT_spt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    ACT Command Support \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This code implements the ACT update code. It does not use a mutex. This code uses\n// a platform service (_plat__ACT_UpdateCounter()) that returns 'false' if the update\n// is not accepted. If this occurs, then TPM_RC_RETRY should be sent to the caller so\n// that they can retry the operation later. The implementation of this is platform\n// dependent but the reference uses a simple flag to indicate that an update is\n// pending and the only process that can clear that flag is the process that does the\n// actual update.\n\n//** Includes\n#include \"Tpm.h\"\n#include \"ACT_spt_fp.h\"\n// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface\n#include \"tpm_to_platform_interface.h\"\n\n//** Functions\n\n#if ACT_SUPPORT\n\n//*** _ActResume()\n// This function does the resume processing for an ACT. It updates the saved count\n// and turns signaling back on if necessary.\nstatic void _ActResume(UINT32     act,     //IN: the act number\n\t\t       ACT_STATE* actData  //IN: pointer to the saved ACT data\n\t\t       )\n{\n    // If the act was non-zero, then restore the counter value.\n    if(actData->remaining > 0)\n\t_plat__ACT_UpdateCounter(act, actData->remaining);\n    // if the counter was zero and the ACT signaling, enable the signaling.\n    else if(go.signaledACT & (1 << act))\n\t_plat__ACT_SetSignaled(act, TRUE);\n}\n\n//*** ActStartup()\n// This function is called by TPM2_Startup() to initialize the ACT counter values.\nBOOL ActStartup(STARTUP_TYPE type)\n{\n    // Reset all the ACT hardware\n    _plat__ACT_Initialize();\n    \n    // If this not a cold start, copy all the current 'signaled' settings to\n    // 'preservedSignaled'.\n    if(g_powerWasLost)\n\tgo.preservedSignaled = 0;\n    else\n\tgo.preservedSignaled |= go.signaledACT;\n    \n    // For TPM_RESET or TPM_RESTART, the ACTs will all be disabled and the output\n    // de-asserted.\n    if(type != SU_RESUME)\n\t{\n\t    go.signaledACT = 0;\n#  define CLEAR_ACT_POLICY(N)\t\t\t\t\t      \\\n\t    go.ACT_##N.hashAlg           = TPM_ALG_NULL;\t      \\\n\t    go.ACT_##N.authPolicy.b.size = 0;\n\t    FOR_EACH_ACT(CLEAR_ACT_POLICY)\n\t\t}\n    else\n\t{\n\t    // Resume each of the implemented ACT\n#  define RESUME_ACT(N) _ActResume(0x##N, &go.ACT_##N);\n\t    \n\t    FOR_EACH_ACT(RESUME_ACT)\n\t\t}\n    // set no ACT updated since last startup. This is to enable the halving of the\n    // timeout value\n    s_ActUpdated = 0;\n    _plat__ACT_EnableTicks(TRUE);\n    return TRUE;\n}\n\n//*** _ActSaveState()\n// Get the counter state and the signaled state for an ACT. If the ACT has not been\n// updated since the last time it was saved, then divide the count by 2.\nstatic void _ActSaveState(UINT32 act, P_ACT_STATE actData)\n{\n    actData->remaining = _plat__ACT_GetRemaining(act);\n    // If the ACT hasn't been updated since the last startup, then it should be\n    // be halved.\n    if((s_ActUpdated & (1 << act)) == 0)\n\t{\n\t    // Don't halve if the count is set to max or if halving would make it zero\n\t    if((actData->remaining != UINT32_MAX) && (actData->remaining > 1))\n\t\tactData->remaining /= 2;\n\t}\n    if(_plat__ACT_GetSignaled(act))\n\tgo.signaledACT |= (1 << act);\n}\n\n//*** ActGetSignaled()\n// This function returns the state of the signaled flag associated with an ACT.\nBOOL ActGetSignaled(TPM_RH actHandle)\n{\n    UINT32 act = actHandle - TPM_RH_ACT_0;\n    //\n    return _plat__ACT_GetSignaled(act);\n}\n\n//***ActShutdown()\n// This function saves the current state of the counters\nBOOL ActShutdown(TPM_SU state  //IN: the type of the shutdown.\n\t\t )\n{\n    // if this is not shutdown state, then the only type of startup is TPM_RESTART\n    // so the timer values will be cleared. If this is shutdown state, get the current\n    // countdown and signaled values. Plus, if the counter has not been updated\n    // since the last restart, divide the time by 2 so that there is no attack on the\n    // countdown by saving the countdown state early and then not using the TPM.\n    if(state == TPM_SU_STATE)\n\t{\n\t    // This will be populated as each of the ACT is queried\n\t    go.signaledACT = 0;\n\t    // Get the current count and the signaled state\n#  define SAVE_ACT_STATE(N) _ActSaveState(0x##N, &go.ACT_##N);\n\t    \n\t    FOR_EACH_ACT(SAVE_ACT_STATE);\n\t}\n    return TRUE;\n}\n\n//*** ActIsImplemented()\n// This function determines if an ACT is implemented in both the TPM and the platform\n// code.\nBOOL ActIsImplemented(UINT32 act)\n{\n    // This switch accounts for the TPM implemented values.\n    switch(act)\n\t{\n\t    FOR_EACH_ACT(CASE_ACT_NUMBER)\n\t\t// This ensures that the platform implements the values implemented by\n\t\t// the TPM\n\t\treturn _plat__ACT_GetImplemented(act);\n\t  default:\n\t    break;\n\t}\n    return FALSE;\n}\n\n//***ActCounterUpdate()\n// This function updates the ACT counter. If the counter already has a pending update,\n// it returns TPM_RC_RETRY so that the update can be tried again later.\nTPM_RC\nActCounterUpdate(TPM_RH handle,   //IN: the handle of the act\n\t\t UINT32 newValue  //IN: the value to set in the ACT\n\t\t )\n{\n    UINT32 act;\n    TPM_RC result;\n    //\n    act = handle - TPM_RH_ACT_0;\n    // This should never fail, but...\n    if(!_plat__ACT_GetImplemented(act))\n\tresult = TPM_RC_VALUE;\n    else\n\t{\n\t    // Will need to clear orderly so fail if we are orderly and NV is\n\t    // not available\n\t    if(NV_IS_ORDERLY)\n\t\tRETURN_IF_NV_IS_NOT_AVAILABLE;\n\t    // if the attempt to update the counter fails, it means that there is an\n\t    // update pending so wait until it has occurred and then do an update.\n\t    if(!_plat__ACT_UpdateCounter(act, newValue))\n\t\tresult = TPM_RC_RETRY;\n\t    else\n\t\t{\n\t\t    // Indicate that the ACT has been updated since last TPM2_Startup().\n\t\t    s_ActUpdated |= (UINT16)(1 << act);\n\t\t    \n\t\t    // Clear the preservedSignaled attribute.\n\t\t    go.preservedSignaled &= ~((UINT16)(1 << act));\n\t\t    \n\t\t    // Need to clear the orderly flag\n\t\t    g_clearOrderly = TRUE;\n\t\t    \n\t\t    result         = TPM_RC_SUCCESS;\n\t\t}\n\t}\n    return result;\n}\n\n//*** ActGetCapabilityData()\n// This function returns the list of ACT data\n//  Return Type: TPMI_YES_NO\n//      YES             if more ACT data is available\n//      NO              if no more ACT data to\nTPMI_YES_NO\nActGetCapabilityData(TPM_HANDLE     actHandle,  // IN: the handle for the starting ACT\n\t\t     UINT32         maxCount,   // IN: maximum allowed return values\n\t\t     TPML_ACT_DATA* actList     // OUT: ACT data list\n\t\t     )\n{\n    // Initialize output property list\n    actList->count = 0;\n    \n    // Make sure that the starting handle value is in range (again)\n    if((actHandle < TPM_RH_ACT_0) || (actHandle > TPM_RH_ACT_F))\n\treturn FALSE;\n    // The maximum count of curves we may return is MAX_ECC_CURVES\n    if(maxCount > MAX_ACT_DATA)\n\tmaxCount = MAX_ACT_DATA;\n    // Scan the ACT data from the starting ACT\n    for(; actHandle <= TPM_RH_ACT_F; actHandle++)\n\t{\n\t    UINT32 act = actHandle - TPM_RH_ACT_0;\n\t    if(actList->count < maxCount)\n\t\t{\n\t\t    if(ActIsImplemented(act))\n\t\t\t{\n\t\t\t    TPMS_ACT_DATA* actData = &actList->actData[actList->count];\n\t\t\t    //\n\t\t\t    memset(&actData->attributes, 0, sizeof(actData->attributes));\n\t\t\t    actData->handle  = actHandle;\n\t\t\t    actData->timeout = _plat__ACT_GetRemaining(act);\n\t\t\t    if(_plat__ACT_GetSignaled(act))\n\t\t\t\tSET_ATTRIBUTE(actData->attributes, TPMA_ACT, signaled);\n\t\t\t    else\n\t\t\t\tCLEAR_ATTRIBUTE(actData->attributes, TPMA_ACT, signaled);\n\t\t\t    if(go.preservedSignaled & (1 << act))\n\t\t\t\tSET_ATTRIBUTE(actData->attributes, TPMA_ACT, preserveSignaled);\n\t\t\t    actList->count++;\n\t\t\t}\n\t\t}\n\t    else\n\t\t{\n\t\t    if(_plat__ACT_GetImplemented(act))\n\t\t\treturn YES;\n\t\t}\n\t}\n    // If we get here, either all of the ACT values were put in the list, or the list\n    // was filled and there are no more ACT values to return\n    return NO;\n}\n\n//*** ActGetOneCapability()\n// This function returns an ACT's capability, if present.\nBOOL ActGetOneCapability(TPM_HANDLE     actHandle,  // IN: the handle for the ACT\n\t\t\t TPMS_ACT_DATA* actData     // OUT: ACT data\n\t\t\t )\n{\n    UINT32 act = actHandle - TPM_RH_ACT_0;\n    \n    if(ActIsImplemented(actHandle - TPM_RH_ACT_0))\n\t{\n\t    memset(&actData->attributes, 0, sizeof(actData->attributes));\n\t    actData->handle  = actHandle;\n\t    actData->timeout = _plat__ACT_GetRemaining(act);\n\t    if(_plat__ACT_GetSignaled(act))\n\t\tSET_ATTRIBUTE(actData->attributes, TPMA_ACT, signaled);\n\t    else\n\t\tCLEAR_ATTRIBUTE(actData->attributes, TPMA_ACT, signaled);\n\t    if(go.preservedSignaled & (1 << act))\n\t\tSET_ATTRIBUTE(actData->attributes, TPMA_ACT, preserveSignaled);\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n#endif  // ACT_SUPPORT\n"
  },
  {
    "path": "ftpm-opensbi/src/AlgorithmCap.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t Algorithm Property Definitions \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.1 AlgorithmCap.c */\n/* 9.1.1 Description */\n/* This file contains the algorithm property definitions for the algorithms and the code for the\n   TPM2_GetCapability() to return the algorithm properties. */\n/* 9.1.2 Includes and Defines */\n#include \"Tpm.h\"\ntypedef struct\n{\n    TPM_ALG_ID          algID;\n    TPMA_ALGORITHM      attributes;\n} ALGORITHM;\nstatic const ALGORITHM    s_algorithms[] =\n    {\n\t// The entries in this table need to be in ascending order but the table doesn't\n\t// need to be full (gaps are allowed). One day, a tool might exist to fill in the\n\t// table from the TPM_ALG description\n#if ALG_RSA\n\t{TPM_ALG_RSA,           TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 1, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_TDES\n\t{TPM_ALG_TDES,          TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_SHA1\n\t{TPM_ALG_SHA1,          TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 0, 0, 0, 0)},\n#endif\n\t{TPM_ALG_HMAC,          TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 1, 0, 0, 0)},\n#if ALG_AES\n\t{TPM_ALG_AES,           TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_MGF1\n\t{TPM_ALG_MGF1,          TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 0, 0, 1, 0)},\n#endif\n\t{TPM_ALG_KEYEDHASH,     TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 1, 0, 1, 1, 0, 0)},\n#if ALG_XOR\n\t{TPM_ALG_XOR,           TPMA_ALGORITHM_INITIALIZER(0, 1, 1, 0, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_SHA256\n\t{TPM_ALG_SHA256,        TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_SHA384\n\t{TPM_ALG_SHA384,        TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_SHA512\n\t{TPM_ALG_SHA512,        TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_SM3_256\n\t{TPM_ALG_SM3_256,       TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_SM4\n\t{TPM_ALG_SM4,           TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_RSASSA\n\t{TPM_ALG_RSASSA,        TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 1, 0, 0, 0)},\n#endif\n#if ALG_RSAES\n\t{TPM_ALG_RSAES,         TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 0, 1, 0, 0)},\n#endif\n#if ALG_RSAPSS\n\t{TPM_ALG_RSAPSS,        TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 1, 0, 0, 0)},\n#endif\n#if ALG_OAEP\n\t{TPM_ALG_OAEP,          TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 0, 1, 0, 0)},\n#endif\n#if ALG_ECDSA\n\t{TPM_ALG_ECDSA,         TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 1, 0, 0, 0)},\n#endif\n#if ALG_ECDH\n\t{TPM_ALG_ECDH,          TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 0, 0, 1, 0)},\n#endif\n#if ALG_ECDAA\n\t{TPM_ALG_ECDAA,         TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 1, 0, 0, 0)},\n#endif\n#if ALG_SM2\n\t{TPM_ALG_SM2,           TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 1, 0, 1, 0)},\n#endif\n#if ALG_ECSCHNORR\n\t{TPM_ALG_ECSCHNORR,      TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 1, 0, 0, 0)},\n#endif\n#if ALG_ECMQV\n\t{TPM_ALG_ECMQV,          TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 0, 0, 0, 0, 1, 0)},\n#endif\n#if ALG_KDF1_SP800_56A\n\t{TPM_ALG_KDF1_SP800_56A, TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 0, 0, 1, 0)},\n#endif\n#if ALG_KDF2\n\t{TPM_ALG_KDF2,           TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 0, 0, 1, 0)},\n#endif\n#if ALG_KDF1_SP800_108\n\t{TPM_ALG_KDF1_SP800_108, TPMA_ALGORITHM_INITIALIZER(0, 0, 1, 0, 0, 0, 0, 1, 0)},\n#endif\n#if ALG_ECC\n\t{TPM_ALG_ECC,            TPMA_ALGORITHM_INITIALIZER(1, 0, 0, 1, 0, 0, 0, 0, 0)},\n#endif\n\t{TPM_ALG_SYMCIPHER,      TPMA_ALGORITHM_INITIALIZER(0, 0, 0, 1, 0, 0, 0, 0, 0)},\n#if ALG_CAMELLIA\n\t{TPM_ALG_CAMELLIA,       TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 0, 0, 0, 0)},\n#endif\n#if ALG_CMAC\n\t{TPM_ALG_CMAC,           TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 1, 0, 0, 0)},\n#endif\n#if ALG_CTR\n\t{TPM_ALG_CTR,            TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 0, 1, 0, 0)},\n#endif\n#if ALG_OFB\n\t{TPM_ALG_OFB,            TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 0, 1, 0, 0)},\n#endif\n#if ALG_CBC\n\t{TPM_ALG_CBC,            TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 0, 1, 0, 0)},\n#endif\n#if ALG_CFB\n\t{TPM_ALG_CFB,            TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 0, 1, 0, 0)},\n#endif\n#if ALG_ECB\n\t{TPM_ALG_ECB,            TPMA_ALGORITHM_INITIALIZER(0, 1, 0, 0, 0, 0, 1, 0, 0)},\n#endif\n    };\n/* 9.1.3 AlgorithmCapGetImplemented() */\n/* This function is used by TPM2_GetCapability() to return a list of the implemented algorithms. */\n/* Return Values Meaning */\n/* YES more algorithms to report */\n/* NO no more algorithms to report */\nTPMI_YES_NO\nAlgorithmCapGetImplemented(\n\t\t\t   TPM_ALG_ID                   algID,     // IN: the starting algorithm ID\n\t\t\t   UINT32                       count,     // IN: count of returned algorithms\n\t\t\t   TPML_ALG_PROPERTY           *algList    // OUT: algorithm list\n\t\t\t   )\n{\n    TPMI_YES_NO     more = NO;\n    UINT32          i;\n    UINT32          algNum;\n    // initialize output algorithm list\n    algList->count = 0;\n    // The maximum count of algorithms we may return is MAX_CAP_ALGS.\n    if(count > MAX_CAP_ALGS)\n\tcount = MAX_CAP_ALGS;\n    // Compute how many algorithms are defined in s_algorithms array.\n    algNum = sizeof(s_algorithms) / sizeof(s_algorithms[0]);\n    // Scan the implemented algorithm list to see if there is a match to 'algID'.\n    for(i = 0; i < algNum; i++)\n\t{\n\t    // If algID is less than the starting algorithm ID, skip it\n\t    if(s_algorithms[i].algID < algID)\n\t\tcontinue;\n\t    if(algList->count < count)\n\t\t{\n\t\t    // If we have not filled up the return list, add more algorithms\n\t\t    // to it\n\t\t    algList->algProperties[algList->count].alg = s_algorithms[i].algID;\n\t\t    algList->algProperties[algList->count].algProperties =\n\t\t\ts_algorithms[i].attributes;\n\t\t    algList->count++;\n\t\t}\n\t    else\n\t\t{\n\t\t    // If the return list is full but we still have algorithms\n\t\t    // available, report this and stop scanning.\n\t\t    more = YES;\n\t\t    break;\n\t\t}\n\t}\n    return more;\n}\n\n//** AlgorithmCapGetOneImplemented()\n// This function returns whether a single algorithm was implemented, along\n// with its properties (if implemented).\nBOOL AlgorithmCapGetOneImplemented(\n\t\t\t\t   TPM_ALG_ID         algID,       // IN: the algorithm ID\n\t\t\t\t   TPMS_ALG_PROPERTY* algProperty  // OUT: algorithm properties\n\t\t\t\t   )\n{\n    UINT32 i;\n    UINT32 algNum;\n\n    // Compute how many algorithms are defined in s_algorithms array.\n    algNum = sizeof(s_algorithms) / sizeof(s_algorithms[0]);\n\n    // Scan the implemented algorithm list to see if there is a match to 'algID'.\n    for(i = 0; i < algNum; i++)\n\t{\n\t    // If algID is less than the starting algorithm ID, skip it\n\t    if(s_algorithms[i].algID == algID)\n\t\t{\n\t\t    algProperty->alg           = algID;\n\t\t    algProperty->algProperties = s_algorithms[i].attributes;\n\t\t    return TRUE;\n\t\t}\n\t}\n    return FALSE;\n}\n\n\n/* 9.1.4 AlgorithmGetImplementedVector()\n\n   This function returns the bit vector of the implemented algorithms.\n*/\nLIB_EXPORT\nvoid\nAlgorithmGetImplementedVector(\n\t\t\t      ALGORITHM_VECTOR    *implemented    // OUT: the implemented bits are SET\n\t\t\t      )\n{\n    int                      index;\n    // Nothing implemented until we say it is\n    MemorySet(implemented, 0, sizeof(ALGORITHM_VECTOR));\n    // Go through the list of implemented algorithms and SET the corresponding bit in\n    // in the implemented vector\n    for(index = (sizeof(s_algorithms) / sizeof(s_algorithms[0])) - 1;\n\tindex >= 0; index--)\n\tSET_BIT(s_algorithms[index].algID, *implemented);\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/AlgorithmTests.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Code to perform the various self-test functions.\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the code to perform the various self-test functions.\n//\n// NOTE: In this implementation, large local variables are made static to minimize\n// stack usage, which is critical for stack-constrained platforms.\n\n//** Includes and Defines\n#include \"Tpm.h\"\n\n#define SELF_TEST_DATA\n\n#if ENABLE_SELF_TESTS\n\n// These includes pull in the data structures. They contain data definitions for the\n// various tests.\n#  include \"SelfTest.h\"\n#  include \"SymmetricTest.h\"\n#  include \"RsaTestData.h\"\n#  include \"EccTestData.h\"\n#  include \"HashTestData.h\"\n#  include \"KdfTestData.h\"\n\n#  define TEST_DEFAULT_TEST_HASH(vector)\t      \\\n    if(TEST_BIT(DEFAULT_TEST_HASH, g_toTest))\t      \\\n\tTestHash(DEFAULT_TEST_HASH, vector);\n\n// Make sure that the algorithm has been tested\n#  define CLEAR_BOTH(alg)\t\t  \\\n    {\t\t\t\t\t  \\\n\tCLEAR_BIT(alg, *toTest);\t  \\\n\tif(toTest != &g_toTest)\t\t\t  \\\n\t    CLEAR_BIT(alg, g_toTest);\t\t  \\\n    }\n\n#  define SET_BOTH(alg)\t\t\t\\\n    {\t\t\t\t\t\\\n\tSET_BIT(alg, *toTest);\t\t\\\n\tif(toTest != &g_toTest)\t\t\t\\\n\t    SET_BIT(alg, g_toTest);\t\t\\\n    }\n\n#  define TEST_BOTH(alg)\t\t\t\t\t\t\\\n    ((toTest != &g_toTest) ? TEST_BIT(alg, *toTest) || TEST_BIT(alg, g_toTest) \\\n     : TEST_BIT(alg, *toTest))\n\n// Can only cancel if doing a list.\n#  define CHECK_CANCELED\t\t\t\t   \\\n    if(_plat__IsCanceled() && toTest != &g_toTest)\t   \\\n\treturn TPM_RC_CANCELED;\n\n//** Hash Tests\n\n//*** Description\n// The hash test does a known-value HMAC using the specified hash algorithm.\n\n//*** TestHash()\n// The hash test function.\nstatic TPM_RC TestHash(TPM_ALG_ID hashAlg, ALGORITHM_VECTOR* toTest)\n{\n    static TPM2B_DIGEST computed;  // value computed\n    static HMAC_STATE   state;\n    UINT16              digestSize;\n    const TPM2B*        testDigest = NULL;\n    //    TPM2B_TYPE(HMAC_BLOCK, DEFAULT_TEST_HASH_BLOCK_SIZE);\n\n    pAssert(hashAlg != TPM_ALG_NULL);\n#  define HASH_CASE_FOR_TEST(HASH, hash)\t\t \\\n    case ALG_##HASH##_VALUE:\t\t\t\t \\\n      testDigest = &c_##HASH##_digest.b;\t\t \\\n      break;\n    switch(hashAlg)\n\t{\n\t    FOR_EACH_HASH(HASH_CASE_FOR_TEST)\n\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t}\n    // Clear the to-test bits\n    CLEAR_BOTH(hashAlg);\n\n    // If there is an algorithm without test vectors, then assume that things are OK.\n    if(testDigest == NULL || testDigest->size == 0)\n\treturn TPM_RC_SUCCESS;\n\n    // Set the HMAC key to twice the digest size\n    digestSize = CryptHashGetDigestSize(hashAlg);\n    CryptHmacStart(&state, hashAlg, digestSize * 2, (BYTE*)c_hashTestKey.t.buffer);\n    CryptDigestUpdate(&state.hashState,\n\t\t      2 * CryptHashGetBlockSize(hashAlg),\n\t\t      (BYTE*)c_hashTestData.t.buffer);\n    computed.t.size = digestSize;\n    CryptHmacEnd(&state, digestSize, computed.t.buffer);\n    if((testDigest->size != computed.t.size)\n       || (memcmp(testDigest->buffer, computed.t.buffer, computed.b.size) != 0))\n\tSELF_TEST_FAILURE;\n    return TPM_RC_SUCCESS;\n}\n\n//** Symmetric Test Functions\n\n//*** MakeIv()\n// Internal function to make the appropriate IV depending on the mode.\nstatic UINT32 MakeIv(TPM_ALG_ID mode,  // IN: symmetric mode\n\t\t     UINT32     size,  // IN: block size of the algorithm\n\t\t     BYTE*      iv     // OUT: IV to fill in\n\t\t     )\n{\n    BYTE i;\n\n    if(mode == TPM_ALG_ECB)\n\treturn 0;\n    if(mode == TPM_ALG_CTR)\n\t{\n\t    // The test uses an IV that has 0xff in the last byte\n\t    for(i = 1; i <= size; i++)\n\t\t*iv++ = 0xff - (BYTE)(size - i);\n\t}\n    else\n\t{\n\t    for(i = 0; i < size; i++)\n\t\t*iv++ = i;\n\t}\n    return size;\n}\n\n//*** TestSymmetricAlgorithm()\n// Function to test a specific algorithm, key size, and mode.\nstatic void TestSymmetricAlgorithm(const SYMMETRIC_TEST_VECTOR* test,  //\n\t\t\t\t   TPM_ALG_ID                   mode   //\n\t\t\t\t   )\n{\n    static BYTE     encrypted[MAX_SYM_BLOCK_SIZE * 2];\n    static BYTE     decrypted[MAX_SYM_BLOCK_SIZE * 2];\n    static TPM2B_IV iv;\n    //\n    // Get the appropriate IV\n    iv.t.size = (UINT16)MakeIv(mode, test->ivSize, iv.t.buffer);\n\n    // Encrypt known data\n    CryptSymmetricEncrypt(encrypted,\n\t\t\t  test->alg,\n\t\t\t  test->keyBits,\n\t\t\t  test->key,\n\t\t\t  &iv,\n\t\t\t  mode,\n\t\t\t  test->dataInOutSize,\n\t\t\t  test->dataIn);\n    // Check that it matches the expected value\n    if(!MemoryEqual(\n\t\t    encrypted, test->dataOut[mode - TPM_ALG_CTR], test->dataInOutSize))\n\tSELF_TEST_FAILURE;\n    // Reinitialize the iv for decryption\n    MakeIv(mode, test->ivSize, iv.t.buffer);\n    CryptSymmetricDecrypt(decrypted,\n\t\t\t  test->alg,\n\t\t\t  test->keyBits,\n\t\t\t  test->key,\n\t\t\t  &iv,\n\t\t\t  mode,\n\t\t\t  test->dataInOutSize,\n\t\t\t  test->dataOut[mode - TPM_ALG_CTR]);\n    // Make sure that it matches what we started with\n    if(!MemoryEqual(decrypted, test->dataIn, test->dataInOutSize))\n\tSELF_TEST_FAILURE;\n}\n\n//*** AllSymsAreDone()\n// Checks if both symmetric algorithms have been tested. This is put here\n// so that addition of a symmetric algorithm will be relatively easy to handle.\n//\n//  Return Type: BOOL\n//      TRUE(1)         all symmetric algorithms tested\n//      FALSE(0)        not all symmetric algorithms tested\nstatic BOOL AllSymsAreDone(ALGORITHM_VECTOR* toTest)\n{\n    return (!TEST_BOTH(TPM_ALG_AES) && !TEST_BOTH(TPM_ALG_SM4));\n}\n\n//*** AllModesAreDone()\n// Checks if all the modes have been tested.\n//\n//  Return Type: BOOL\n//      TRUE(1)         all modes tested\n//      FALSE(0)        all modes not tested\nstatic BOOL AllModesAreDone(ALGORITHM_VECTOR* toTest)\n{\n    TPM_ALG_ID alg;\n    for(alg = SYM_MODE_FIRST; alg <= SYM_MODE_LAST; alg++)\n\tif(TEST_BOTH(alg))\n\t    return FALSE;\n    return TRUE;\n}\n\n//*** TestSymmetric()\n// If 'alg' is a symmetric block cipher, then all of the modes that are selected are\n// tested. If 'alg' is a mode, then all algorithms of that mode are tested.\nstatic TPM_RC TestSymmetric(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest)\n{\n    SYM_INDEX  index;\n    TPM_ALG_ID mode;\n    //\n    if(!TEST_BIT(alg, *toTest))\n\treturn TPM_RC_SUCCESS;\n    if(alg == TPM_ALG_AES || alg == TPM_ALG_SM4 || alg == TPM_ALG_CAMELLIA)\n\t{\n\t    // Will test the algorithm for all modes and key sizes\n\t    CLEAR_BOTH(alg);\n\n\t    // A test this algorithm for all modes\n\t    for(index = 0; index < NUM_SYMS; index++)\n\t\t{\n\t\t    if(c_symTestValues[index].alg == alg)\n\t\t\t{\n\t\t\t    for(mode = SYM_MODE_FIRST; mode <= SYM_MODE_LAST; mode++)\n\t\t\t\t{\n\t\t\t\t    if(TEST_BIT(mode, *toTest))\n\t\t\t\t\tTestSymmetricAlgorithm(&c_symTestValues[index], mode);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t    // if all the symmetric tests are done\n\t    if(AllSymsAreDone(toTest))\n\t\t{\n\t\t    // all symmetric algorithms tested so no modes should be set\n\t\t    for(alg = SYM_MODE_FIRST; alg <= SYM_MODE_LAST; alg++)\n\t\t\tCLEAR_BOTH(alg);\n\t\t}\n\t}\n    else if(SYM_MODE_FIRST <= alg && alg <= SYM_MODE_LAST)\n\t{\n\t    // Test this mode for all key sizes and algorithms\n\t    for(index = 0; index < NUM_SYMS; index++)\n\t\t{\n\t\t    // The mode testing only comes into play when doing self tests\n\t\t    // by command. When doing self tests by command, the block ciphers are\n\t\t    // tested first. That means that all of their modes would have been\n\t\t    // tested for all key sizes. If there is no block cipher left to\n\t\t    // test, then clear this mode bit.\n\t\t    if(!TEST_BIT(TPM_ALG_AES, *toTest) && !TEST_BIT(TPM_ALG_SM4, *toTest))\n\t\t\t{\n\t\t\t    CLEAR_BOTH(alg);\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    for(index = 0; index < NUM_SYMS; index++)\n\t\t\t\t{\n\t\t\t\t    if(TEST_BIT(c_symTestValues[index].alg, *toTest))\n\t\t\t\t\tTestSymmetricAlgorithm(&c_symTestValues[index], alg);\n\t\t\t\t}\n\t\t\t    // have tested this mode for all algorithms\n\t\t\t    CLEAR_BOTH(alg);\n\t\t\t}\n\t\t}\n\t    if(AllModesAreDone(toTest))\n\t\t{\n\t\t    CLEAR_BOTH(TPM_ALG_AES);\n\t\t    CLEAR_BOTH(TPM_ALG_SM4);\n\t\t}\n\t}\n    else\n\tpAssert(alg == 0 && alg != 0);\n    return TPM_RC_SUCCESS;\n}\n\n//** RSA Tests\n#  if ALG_RSA\n\n//*** Introduction\n// The tests are for public key only operations and for private key operations.\n// Signature verification and encryption are public key operations. They are tested\n// by using a KVT. For signature verification, this means that a known good\n// signature is checked by CryptRsaValidateSignature(). If it fails, then the\n// TPM enters failure mode. For encryption, the TPM encrypts known values using\n// the selected scheme and checks that the returned value matches the expected\n// value.\n//\n// For private key operations, a full scheme check is used. For a signing key, a\n// known key is used to sign a known message. Then that signature is verified.\n// since the signature may involve use of random values, the signature will be\n// different each time and we can't always check that the signature matches a\n// known value. The same technique is used for decryption (RSADP/RSAEP).\n//\n// When an operation uses the public key and the verification has not been\n// tested, the TPM will do a KVT.\n//\n// The test for the signing algorithm is built into the call for the algorithm\n\n//*** RsaKeyInitialize()\n// The test key is defined by a public modulus and a private prime. The TPM's RSA\n// code computes the second prime and the private exponent.\nstatic void RsaKeyInitialize(OBJECT* testObject)\n{\n    MemoryCopy2B(&testObject->publicArea.unique.rsa.b,\n\t\t (P2B)&c_rsaPublicModulus,\n\t\t sizeof(c_rsaPublicModulus));\n    MemoryCopy2B(&testObject->sensitive.sensitive.rsa.b,\n\t\t (P2B)&c_rsaPrivatePrime,\n\t\t sizeof(testObject->sensitive.sensitive.rsa.t.buffer));\n    testObject->publicArea.parameters.rsaDetail.keyBits = RSA_TEST_KEY_SIZE * 8;\n    // Use the default exponent\n    testObject->publicArea.parameters.rsaDetail.exponent = 0;\n}\n\n//*** TestRsaEncryptDecrypt()\n// These tests are for a public key encryption that uses a random value.\nstatic TPM_RC TestRsaEncryptDecrypt(TPM_ALG_ID        scheme,  // IN: the scheme\n\t\t\t\t    ALGORITHM_VECTOR* toTest   //\n\t\t\t\t    )\n{\n    static TPM2B_PUBLIC_KEY_RSA testInput;\n    static TPM2B_PUBLIC_KEY_RSA testOutput;\n    static OBJECT               testObject;\n    const TPM2B_RSA_TEST_KEY*   kvtValue  = NULL;\n    TPM_RC                      result    = TPM_RC_SUCCESS;\n    const TPM2B*                testLabel = NULL;\n    TPMT_RSA_DECRYPT            rsaScheme;\n    //\n    // Don't need to initialize much of the test object\n    RsaKeyInitialize(&testObject);\n    rsaScheme.scheme                 = scheme;\n    rsaScheme.details.anySig.hashAlg = DEFAULT_TEST_HASH;\n    CLEAR_BOTH(scheme);\n    CLEAR_BOTH(TPM_ALG_NULL);\n    if(scheme == TPM_ALG_NULL)\n\t{\n\t    // This is an encryption scheme using the private key without any encoding.\n\t    memcpy(testInput.t.buffer, c_RsaTestValue, sizeof(c_RsaTestValue));\n\t    testInput.t.size = sizeof(c_RsaTestValue);\n\t    if(TPM_RC_SUCCESS\n\t       != CryptRsaEncrypt(\n\t\t\t\t  &testOutput, &testInput.b, &testObject, &rsaScheme, NULL, NULL))\n\t\tSELF_TEST_FAILURE;\n\t    if(!MemoryEqual(testOutput.t.buffer, c_RsaepKvt.buffer, c_RsaepKvt.size))\n\t\tSELF_TEST_FAILURE;\n\t    MemoryCopy2B(&testInput.b, &testOutput.b, sizeof(testInput.t.buffer));\n\t    if(TPM_RC_SUCCESS\n\t       != CryptRsaDecrypt(\n\t\t\t\t  &testOutput.b, &testInput.b, &testObject, &rsaScheme, NULL))\n\t\tSELF_TEST_FAILURE;\n\t    if(!MemoryEqual(testOutput.t.buffer, c_RsaTestValue, sizeof(c_RsaTestValue)))\n\t\tSELF_TEST_FAILURE;\n\t}\n    else\n\t{\n\t    // TPM_ALG_RSAES:\n\t    // This is an decryption scheme using padding according to\n\t    // PKCS#1v2.1, 7.2. This padding uses random bits. To test a public\n\t    // key encryption that uses random data, encrypt a value and then\n\t    // decrypt the value and see that we get the encrypted data back.\n\t    // The hash is not used by this encryption so it can be TMP_ALG_NULL\n\n\t    // TPM_ALG_OAEP:\n\t    // This is also an decryption scheme and it also uses a\n\t    // pseudo-random\n\t    // value. However, this also uses a hash algorithm. So, we may need\n\t    // to test that algorithm before use.\n\t    if(scheme == TPM_ALG_OAEP)\n\t\t{\n\t\t    TEST_DEFAULT_TEST_HASH(toTest);\n\t\t    kvtValue  = &c_OaepKvt;\n\t\t    testLabel = OAEP_TEST_STRING;\n\t\t}\n\t    else if(scheme == TPM_ALG_RSAES)\n\t\t{\n\t\t    kvtValue  = &c_RsaesKvt;\n\t\t    testLabel = NULL;\n\t\t}\n\t    else\n\t\tSELF_TEST_FAILURE;\n\t    // Only use a digest-size portion of the test value\n\t    memcpy(testInput.t.buffer, c_RsaTestValue, DEFAULT_TEST_DIGEST_SIZE);\n\t    testInput.t.size = DEFAULT_TEST_DIGEST_SIZE;\n\n\t    // See if the encryption works\n\t    if(TPM_RC_SUCCESS\n\t       != CryptRsaEncrypt(\n\t\t\t\t  &testOutput, &testInput.b, &testObject, &rsaScheme, testLabel, NULL))\n\t\tSELF_TEST_FAILURE;\n\t    MemoryCopy2B(&testInput.b, &testOutput.b, sizeof(testInput.t.buffer));\n\t    // see if we can decrypt this value and get the original data back\n\t    if(TPM_RC_SUCCESS\n\t       != CryptRsaDecrypt(\n\t\t\t\t  &testOutput.b, &testInput.b, &testObject, &rsaScheme, testLabel))\n\t\tSELF_TEST_FAILURE;\n\t    // See if the results compare\n\t    if(testOutput.t.size != DEFAULT_TEST_DIGEST_SIZE\n\t       || !MemoryEqual(\n\t\t\t       testOutput.t.buffer, c_RsaTestValue, DEFAULT_TEST_DIGEST_SIZE))\n\t\tSELF_TEST_FAILURE;\n\t    // Now check that the decryption works on a known value\n\t    MemoryCopy2B(&testInput.b, (P2B)kvtValue, sizeof(testInput.t.buffer));\n\t    if(TPM_RC_SUCCESS\n\t       != CryptRsaDecrypt(\n\t\t\t\t  &testOutput.b, &testInput.b, &testObject, &rsaScheme, testLabel))\n\t\tSELF_TEST_FAILURE;\n\t    if(testOutput.t.size != DEFAULT_TEST_DIGEST_SIZE\n\t       || !MemoryEqual(\n\t\t\t       testOutput.t.buffer, c_RsaTestValue, DEFAULT_TEST_DIGEST_SIZE))\n\t\tSELF_TEST_FAILURE;\n\t}\n    return result;\n}\n\n//*** TestRsaSignAndVerify()\n// This function does the testing of the RSA sign and verification functions. This\n// test does a KVT.\nstatic TPM_RC TestRsaSignAndVerify(TPM_ALG_ID scheme, ALGORITHM_VECTOR* toTest)\n{\n    TPM_RC                result = TPM_RC_SUCCESS;\n    static OBJECT         testObject;\n    static TPM2B_DIGEST   testDigest;\n    static TPMT_SIGNATURE testSig;\n\n    // Do a sign and signature verification.\n    // RSASSA:\n    // This is a signing scheme according to PKCS#1-v2.1 8.2. It does not\n    // use random data so there is a KVT for the signing operation. On\n    // first use of the scheme for signing, use the TPM's RSA key to\n    // sign a portion of c_RsaTestData and compare the results to c_RsassaKvt. Then\n    // decrypt the data to see that it matches the starting value. This verifies\n    // the signature with a KVT\n\n    // Clear the bits indicating that the function has not been checked. This is to\n    // prevent looping\n    CLEAR_BOTH(scheme);\n    CLEAR_BOTH(TPM_ALG_NULL);\n    CLEAR_BOTH(TPM_ALG_RSA);\n\n    RsaKeyInitialize(&testObject);\n    memcpy(testDigest.t.buffer, (BYTE*)c_RsaTestValue, DEFAULT_TEST_DIGEST_SIZE);\n    testDigest.t.size             = DEFAULT_TEST_DIGEST_SIZE;\n    testSig.sigAlg                = scheme;\n    testSig.signature.rsapss.hash = DEFAULT_TEST_HASH;\n\n    // RSAPSS:\n    // This is a signing scheme a according to PKCS#1-v2.2 8.1 it uses\n    // random data in the signature so there is no KVT for the signing\n    // operation. To test signing, the TPM will use the TPM's RSA key\n    // to sign a portion of c_RsaTestValue and then it will verify the\n    // signature. For verification, c_RsapssKvt is verified before the\n    // user signature blob is verified. The worst case for testing of this\n    // algorithm is two private and one public key operation.\n\n    // The process is to sign known data. If RSASSA is being done, verify that the\n    // signature matches the precomputed value. For both, use the signed value and\n    // see that the verification says that it is a good signature. Then\n    // if testing RSAPSS, do a verify of a known good signature. This ensures that\n    // the validation function works.\n\n    if(TPM_RC_SUCCESS != CryptRsaSign(&testSig, &testObject, &testDigest, NULL))\n\tSELF_TEST_FAILURE;\n    // For RSASSA, make sure the results is what we are looking for\n    if(testSig.sigAlg == TPM_ALG_RSASSA)\n\t{\n\t    if(testSig.signature.rsassa.sig.t.size != RSA_TEST_KEY_SIZE\n\t       || !MemoryEqual(c_RsassaKvt.buffer,\n\t\t\t       testSig.signature.rsassa.sig.t.buffer,\n\t\t\t       RSA_TEST_KEY_SIZE))\n\t\tSELF_TEST_FAILURE;\n\t}\n    // See if the TPM will validate its own signatures\n    if(TPM_RC_SUCCESS\n       != CryptRsaValidateSignature(&testSig, &testObject, &testDigest))\n\tSELF_TEST_FAILURE;\n    // If this is RSAPSS, check the verification with known signature\n    // Have to copy because  CrytpRsaValidateSignature() eats the signature\n    if(TPM_ALG_RSAPSS == scheme)\n\t{\n\t    MemoryCopy2B(&testSig.signature.rsapss.sig.b,\n\t\t\t (P2B)&c_RsapssKvt,\n\t\t\t sizeof(testSig.signature.rsapss.sig.t.buffer));\n\t    if(TPM_RC_SUCCESS\n\t       != CryptRsaValidateSignature(&testSig, &testObject, &testDigest))\n\t\tSELF_TEST_FAILURE;\n\t}\n    return result;\n}\n\n//*** TestRSA()\n// Function uses the provided vector to indicate which tests to run. It will clear\n// the vector after each test is run and also clear g_toTest\nstatic TPM_RC TestRsa(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest)\n{\n    TPM_RC result = TPM_RC_SUCCESS;\n    //\n    switch(alg)\n\t{\n\t  case TPM_ALG_NULL:\n\t    // This is the RSAEP/RSADP function. If we are processing a list, don't\n\t    // need to test these now because any other test will validate\n\t    // RSAEP/RSADP. Can tell this is list of test by checking to see if\n\t    // 'toTest' is pointing at g_toTest. If so, this is an isolated test\n\t    // an need to go ahead and do the test;\n\t    if((toTest == &g_toTest)\n\t       || (!TEST_BIT(TPM_ALG_RSASSA, *toTest)\n\t\t   && !TEST_BIT(TPM_ALG_RSAES, *toTest)\n\t\t   && !TEST_BIT(TPM_ALG_RSAPSS, *toTest)\n\t\t   && !TEST_BIT(TPM_ALG_OAEP, *toTest)))\n\t\t// Not running a list of tests or no other tests on the list\n\t\t// so run the test now\n\t\tresult = TestRsaEncryptDecrypt(alg, toTest);\n\t    // if not running the test now, leave the bit on, just in case things\n\t    // get interrupted\n\t    break;\n\t  case TPM_ALG_OAEP:\n\t  case TPM_ALG_RSAES:\n\t    result = TestRsaEncryptDecrypt(alg, toTest);\n\t    break;\n\t  case TPM_ALG_RSAPSS:\n\t  case TPM_ALG_RSASSA:\n\t    result = TestRsaSignAndVerify(alg, toTest);\n\t    break;\n\t  default:\n\t    SELF_TEST_FAILURE;\n\t}\n    return result;\n}\n\n#  endif  // ALG_RSA\n\n//** ECC Tests\n\n#  if ALG_ECC\n\n//*** LoadEccParameter()\n// This function is mostly for readability and type checking\nstatic void LoadEccParameter(TPM2B_ECC_PARAMETER* to,   // target\n\t\t\t     const TPM2B_EC_TEST* from  // source\n\t\t\t     )\n{\n    MemoryCopy2B(&to->b, &from->b, sizeof(to->t.buffer));\n}\n\n//*** LoadEccPoint()\nstatic void LoadEccPoint(TPMS_ECC_POINT*      point,  // target\n\t\t\t const TPM2B_EC_TEST* x,      // source\n\t\t\t const TPM2B_EC_TEST* y)\n{\n    MemoryCopy2B(&point->x.b, (TPM2B*)x, sizeof(point->x.t.buffer));\n    MemoryCopy2B(&point->y.b, (TPM2B*)y, sizeof(point->y.t.buffer));\n}\n\n//*** TestECDH()\n// This test does a KVT on a point multiply.\nstatic TPM_RC TestECDH(TPM_ALG_ID        scheme,  // IN: for consistency\n\t\t       ALGORITHM_VECTOR* toTest  // IN/OUT: modified after test is run\n\t\t       )\n{\n    static TPMS_ECC_POINT      Z;\n    static TPMS_ECC_POINT      Qe;\n    static TPM2B_ECC_PARAMETER ds;\n    TPM_RC                     result = TPM_RC_SUCCESS;\n    //\n    NOT_REFERENCED(scheme);\n    CLEAR_BOTH(TPM_ALG_ECDH);\n    LoadEccParameter(&ds, &c_ecTestKey_ds);\n    LoadEccPoint(&Qe, &c_ecTestKey_QeX, &c_ecTestKey_QeY);\n    if(TPM_RC_SUCCESS != CryptEccPointMultiply(&Z, c_testCurve, &Qe, &ds, NULL, NULL))\n\tSELF_TEST_FAILURE;\n    if(!MemoryEqual2B(&c_ecTestEcdh_X.b, &Z.x.b)\n       || !MemoryEqual2B(&c_ecTestEcdh_Y.b, &Z.y.b))\n\tSELF_TEST_FAILURE;\n    return result;\n}\n\n//*** TestEccSignAndVerify()\nstatic TPM_RC TestEccSignAndVerify(TPM_ALG_ID scheme, ALGORITHM_VECTOR* toTest)\n{\n    static OBJECT          testObject;\n    static TPMT_SIGNATURE  testSig;\n    static TPMT_ECC_SCHEME eccScheme;\n\n    testSig.sigAlg                   = scheme;\n    testSig.signature.ecdsa.hash     = DEFAULT_TEST_HASH;\n\n    eccScheme.scheme                 = scheme;\n    eccScheme.details.anySig.hashAlg = DEFAULT_TEST_HASH;\n\n    CLEAR_BOTH(scheme);\n    CLEAR_BOTH(TPM_ALG_ECDH);\n\n    // ECC signature verification testing uses a KVT.\n    switch(scheme)\n\t{\n\t  case TPM_ALG_ECDSA:\n\t    LoadEccParameter(&testSig.signature.ecdsa.signatureR, &c_TestEcDsa_r);\n\t    LoadEccParameter(&testSig.signature.ecdsa.signatureS, &c_TestEcDsa_s);\n\t    break;\n\t  case TPM_ALG_ECSCHNORR:\n\t    LoadEccParameter(&testSig.signature.ecschnorr.signatureR,\n\t\t\t     &c_TestEcSchnorr_r);\n\t    LoadEccParameter(&testSig.signature.ecschnorr.signatureS,\n\t\t\t     &c_TestEcSchnorr_s);\n\t    break;\n\t  case TPM_ALG_SM2:\n\t    // don't have a test for SM2\n\t    return TPM_RC_SUCCESS;\n\t  default:\n\t    SELF_TEST_FAILURE;\n\t    break;\n\t}\n    TEST_DEFAULT_TEST_HASH(toTest);\n\n    // Have to copy the key. This is because the size used in the test vectors\n    // is the size of the ECC parameter for the test key while the size of a point\n    // is TPM dependent\n    MemoryCopy2B(&testObject.sensitive.sensitive.ecc.b,\n\t\t &c_ecTestKey_ds.b,\n\t\t sizeof(testObject.sensitive.sensitive.ecc.t.buffer));\n    LoadEccPoint(\n\t\t &testObject.publicArea.unique.ecc, &c_ecTestKey_QsX, &c_ecTestKey_QsY);\n    testObject.publicArea.parameters.eccDetail.curveID = c_testCurve;\n\n    if(TPM_RC_SUCCESS\n       != CryptEccValidateSignature(\n\t\t\t\t    &testSig, &testObject, (TPM2B_DIGEST*)&c_ecTestValue.b))\n\t{\n\t    SELF_TEST_FAILURE;\n\t}\n    CHECK_CANCELED;\n\n    // Now sign and verify some data\n    if(TPM_RC_SUCCESS\n       != CryptEccSign(\n\t\t       &testSig, &testObject, (TPM2B_DIGEST*)&c_ecTestValue, &eccScheme, NULL))\n\tSELF_TEST_FAILURE;\n\n    CHECK_CANCELED;\n\n    if(TPM_RC_SUCCESS\n       != CryptEccValidateSignature(\n\t\t\t\t    &testSig, &testObject, (TPM2B_DIGEST*)&c_ecTestValue))\n\tSELF_TEST_FAILURE;\n\n    CHECK_CANCELED;\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** TestKDFa()\nstatic TPM_RC TestKDFa(ALGORITHM_VECTOR* toTest)\n{\n    static TPM2B_KDF_TEST_KEY keyOut;\n    UINT32                    counter = 0;\n    //\n    CLEAR_BOTH(TPM_ALG_KDF1_SP800_108);\n\n    keyOut.t.size = CryptKDFa(KDF_TEST_ALG,\n\t\t\t      &c_kdfTestKeyIn.b,\n\t\t\t      &c_kdfTestLabel.b,\n\t\t\t      &c_kdfTestContextU.b,\n\t\t\t      &c_kdfTestContextV.b,\n\t\t\t      TEST_KDF_KEY_SIZE * 8,\n\t\t\t      keyOut.t.buffer,\n\t\t\t      &counter,\n\t\t\t      FALSE);\n    if(keyOut.t.size != TEST_KDF_KEY_SIZE\n       || !MemoryEqual(keyOut.t.buffer, c_kdfTestKeyOut.t.buffer, TEST_KDF_KEY_SIZE))\n\tSELF_TEST_FAILURE;\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** TestEcc()\nstatic TPM_RC TestEcc(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest)\n{\n    TPM_RC result = TPM_RC_SUCCESS;\n    NOT_REFERENCED(toTest);\n    switch(alg)\n\t{\n\t  case TPM_ALG_ECC:\n\t  case TPM_ALG_ECDH:\n\t    // If this is in a loop then see if another test is going to deal with\n\t    // this.\n\t    // If toTest is not a self-test list\n\t    if((toTest == &g_toTest)\n\t       // or this is the only ECC test in the list\n\t       || !(TEST_BIT(TPM_ALG_ECDSA, *toTest)\n\t\t    || TEST_BIT(ALG_ECSCHNORR, *toTest)\n\t\t    || TEST_BIT(TPM_ALG_SM2, *toTest)))\n\t\t{\n\t\t    result = TestECDH(alg, toTest);\n\t\t}\n\t    break;\n\t  case TPM_ALG_ECDSA:\n\t  case TPM_ALG_ECSCHNORR:\n\t  case TPM_ALG_SM2:\n\t    result = TestEccSignAndVerify(alg, toTest);\n\t    break;\n\t  default:\n\t    SELF_TEST_FAILURE;\n\t    break;\n\t}\n    return result;\n}\n\n#  endif  // ALG_ECC\n\n//*** TestAlgorithm()\n// Dispatches to the correct test function for the algorithm or gets a list of\n// testable algorithms.\n//\n// If 'toTest' is not NULL, then the test decisions are based on the algorithm\n// selections in 'toTest'. Otherwise, 'g_toTest' is used. When bits are clear in\n// 'g_toTest' they will also be cleared 'toTest'.\n//\n// If there doesn't happen to be a test for the algorithm, its associated bit is\n// quietly cleared.\n//\n// If 'alg' is zero (TPM_ALG_ERROR), then the toTest vector is cleared of any bits\n// for which there is no test (i.e. no tests are actually run but the vector is\n// cleared).\n//\n// Note: 'toTest' will only ever have bits set for implemented algorithms but 'alg'\n// can be anything.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_CANCELED     test was canceled\nLIB_EXPORT\nTPM_RC\nTestAlgorithm(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest)\n{\n    TPM_ALG_ID first  = (alg == TPM_ALG_ERROR) ? TPM_ALG_FIRST : alg;\n    TPM_ALG_ID last   = (alg == TPM_ALG_ERROR) ? TPM_ALG_LAST : alg;\n    BOOL       doTest = (alg != TPM_ALG_ERROR);\n    TPM_RC     result = TPM_RC_SUCCESS;\n\n    if(toTest == NULL)\n\ttoTest = &g_toTest;\n\n    // This is kind of strange. This function will either run a test of the selected\n    // algorithm or just clear a bit if there is no test for the algorithm. So,\n    // either this loop will be executed once for the selected algorithm or once for\n    // each of the possible algorithms. If it is executed more than once ('alg' ==\n    // ALG_ERROR), then no test will be run but bits will be cleared for\n    // unimplemented algorithms. This was done this way so that there is only one\n    // case statement with all of the algorithms. It was easier to have one case\n    // statement than to have multiple ones to manage whenever an algorithm ID is\n    // added.\n    for(alg = first; (alg <= last); alg++)\n\t{\n\t    // if 'alg' was TPM_ALG_ERROR, then we will be cycling through\n\t    // values, some of which may not be implemented. If the bit in toTest\n\t    // happens to be set, then we could either generated an assert, or just\n\t    // silently CLEAR it. Decided to just clear.\n\t    if(!TEST_BIT(alg, g_implementedAlgorithms))\n\t\t{\n\t\t    CLEAR_BIT(alg, *toTest);\n\t\t    continue;\n\t\t}\n\t    // Process whatever is left.\n\t    // NOTE: since this switch will only be called if the algorithm is\n\t    // implemented, it is not necessary to modify this list except to comment\n\t    // out the algorithms for which there is no test\n\t    switch(alg)\n\t\t{\n\t\t    // Symmetric block ciphers\n#  if ALG_AES\n\t\t  case TPM_ALG_AES:\n#  endif  // ALG_AES\n#  if ALG_SM4\n\t\t    // if SM4 is implemented, its test is like other block ciphers but there\n\t\t    // aren't any test vectors for it yet\n\t\t    //            case TPM_ALG_SM4:\n#  endif  // ALG_SM4\n#  if ALG_CAMELLIA\n\t\t    // no test vectors for camellia\n\t\t    //            case TPM_ALG_CAMELLIA:\n#  endif\n\t\t    // Symmetric modes\n#  if !ALG_CFB\n#    error CFB is required in all TPM implementations\n#  endif  // !ALG_CFB\n\t\t  case TPM_ALG_CFB:\n\t\t    if(doTest)\n\t\t\tresult = TestSymmetric(alg, toTest);\n\t\t    break;\n#  if ALG_CTR\n\t\t  case TPM_ALG_CTR:\n#  endif  // ALG_CRT\n#  if ALG_OFB\n\t\t  case TPM_ALG_OFB:\n#  endif  // ALG_OFB\n#  if ALG_CBC\n\t\t  case TPM_ALG_CBC:\n#  endif  // ALG_CBC\n#  if ALG_ECB\n\t\t  case TPM_ALG_ECB:\n#  endif\n\t\t    if(doTest)\n\t\t\tresult = TestSymmetric(alg, toTest);\n\t\t    else\n\t\t\t// If doing the initialization of g_toTest vector, only need\n\t\t\t// to test one of the modes for the symmetric algorithms. If\n\t\t\t// initializing for a SelfTest(FULL_TEST), allow all the modes.\n\t\t\tif(toTest == &g_toTest)\n\t\t\t    CLEAR_BIT(alg, *toTest);\n\t\t    break;\n#  if !ALG_HMAC\n#    error HMAC is required in all TPM implementations\n#  endif\n\t\t  case TPM_ALG_HMAC:\n\t\t    // Clear the bit that indicates that HMAC is required because\n\t\t    // HMAC is used as the basic test for all hash algorithms.\n\t\t    CLEAR_BOTH(alg);\n\t\t    // Testing HMAC means test the default hash\n\t\t    if(doTest)\n\t\t\tTestHash(DEFAULT_TEST_HASH, toTest);\n\t\t    else\n\t\t\t// If not testing, then indicate that the hash needs to be\n\t\t\t// tested because this uses HMAC\n\t\t\tSET_BOTH(DEFAULT_TEST_HASH);\n\t\t    break;\n\t\t    // Have to use two arguments for the macro even though only the first is used in the\n\t\t    // expansion.\n#  define HASH_CASE_TEST(HASH, hash) case ALG_##HASH##_VALUE:\n\t\t    FOR_EACH_HASH(HASH_CASE_TEST)\n#  undef HASH_CASE_TEST\n\t\t\tif(doTest)\n\t\t\t    result = TestHash(alg, toTest);\n\t\t    break;\n\t\t    // RSA-dependent\n#  if ALG_RSA\n\t\t  case TPM_ALG_RSA:\n\t\t    CLEAR_BOTH(alg);\n\t\t    if(doTest)\n\t\t\tresult = TestRsa(TPM_ALG_NULL, toTest);\n\t\t    else\n\t\t\tSET_BOTH(TPM_ALG_NULL);\n\t\t    break;\n\t\t  case TPM_ALG_RSASSA:\n\t\t  case TPM_ALG_RSAES:\n\t\t  case TPM_ALG_RSAPSS:\n\t\t  case TPM_ALG_OAEP:\n\t\t  case TPM_ALG_NULL:  // used or RSADP\n\t\t    if(doTest)\n\t\t\tresult = TestRsa(alg, toTest);\n\t\t    break;\n#  endif  // ALG_RSA\n#  if ALG_KDF1_SP800_108\n\t\t  case TPM_ALG_KDF1_SP800_108:\n\t\t    if(doTest)\n\t\t\tresult = TestKDFa(toTest);\n\t\t    break;\n#  endif  // ALG_KDF1_SP800_108\n#  if ALG_ECC\n\t\t    // ECC dependent but no tests\n\t\t    //        case TPM_ALG_ECDAA:\n\t\t    //        case TPM_ALG_ECMQV:\n\t\t    //        case TPM_ALG_KDF1_SP800_56a:\n\t\t    //        case TPM_ALG_KDF2:\n\t\t    //        case TPM_ALG_MGF1:\n\t\t  case TPM_ALG_ECC:\n\t\t    CLEAR_BOTH(alg);\n\t\t    if(doTest)\n\t\t\tresult = TestEcc(TPM_ALG_ECDH, toTest);\n\t\t    else\n\t\t\tSET_BOTH(TPM_ALG_ECDH);\n\t\t    break;\n\t\t  case TPM_ALG_ECDSA:\n\t\t  case TPM_ALG_ECDH:\n\t\t  case TPM_ALG_ECSCHNORR:\n\t\t    //            case TPM_ALG_SM2:\n\t\t    if(doTest)\n\t\t\tresult = TestEcc(alg, toTest);\n\t\t    break;\n#  endif  // ALG_ECC\n\t\t  default:\n\t\t    CLEAR_BIT(alg, *toTest);\n\t\t    break;\n\t\t}\n\t    if(result != TPM_RC_SUCCESS)\n\t\tbreak;\n\t}\n    return result;\n}\n\n#endif  // ENABLE_SELF_TESTS\n"
  },
  {
    "path": "ftpm-opensbi/src/AsymmetricCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Asymmetric Commands   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"RSA_Encrypt_fp.h\"\n\nextern int verbose;\n\n#if CC_RSA_Encrypt  // Conditional expansion of this file\nTPM_RC\nTPM2_RSA_Encrypt(\n\t\t RSA_Encrypt_In      *in,            // IN: input parameter list\n\t\t RSA_Encrypt_Out     *out            // OUT: output parameter list\n\t\t )\n{\n    TPM_RC                  result;\n    OBJECT                  *rsaKey;\n    TPMT_RSA_DECRYPT        *scheme;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_RSA_Encrypt: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    rsaKey = HandleToObject(in->keyHandle);\n    // selected key must be an RSA key\n    if(rsaKey->publicArea.type != TPM_ALG_RSA)\n\treturn TPM_RCS_KEY + RC_RSA_Encrypt_keyHandle;\n    // selected key must have the decryption attribute\n    if(!IS_ATTRIBUTE(rsaKey->publicArea.objectAttributes, TPMA_OBJECT, decrypt))\n\treturn TPM_RCS_ATTRIBUTES + RC_RSA_Encrypt_keyHandle;\n    // Is there a label?\n    if(!IsLabelProperlyFormatted(&in->label.b))\n\treturn TPM_RCS_VALUE + RC_RSA_Encrypt_label;\n    // Command Output\n    // Select a scheme for encryption\n    scheme = CryptRsaSelectScheme(in->keyHandle, &in->inScheme);\n    if(scheme == NULL)\n\treturn TPM_RCS_SCHEME + RC_RSA_Encrypt_inScheme;\n    // Encryption.  TPM_RC_VALUE, or TPM_RC_SCHEME errors my be returned buy\n    // CryptEncyptRSA.\n    out->outData.t.size = sizeof(out->outData.t.buffer);\n    result = CryptRsaEncrypt(&out->outData, &in->message.b, rsaKey, scheme,\n\t\t\t     &in->label.b, NULL);\n    return result;\n}\n#endif // CC_RSA_Encrypt\n#include \"Tpm.h\"\n#include \"RSA_Decrypt_fp.h\"\n#if CC_RSA_Decrypt  // Conditional expansion of this file\nTPM_RC\nTPM2_RSA_Decrypt(\n\t\t RSA_Decrypt_In      *in,            // IN: input parameter list\n\t\t RSA_Decrypt_Out     *out            // OUT: output parameter list\n\t\t )\n{\n    TPM_RC                       result;\n    OBJECT                      *rsaKey;\n    TPMT_RSA_DECRYPT            *scheme;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_RSA_Decrypt: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    rsaKey = HandleToObject(in->keyHandle);\n    // The selected key must be an RSA key\n    if(rsaKey->publicArea.type != TPM_ALG_RSA)\n\treturn TPM_RCS_KEY + RC_RSA_Decrypt_keyHandle;\n    // The selected key must be an unrestricted decryption key\n    if(IS_ATTRIBUTE(rsaKey->publicArea.objectAttributes, TPMA_OBJECT, restricted)\n       || !IS_ATTRIBUTE(rsaKey->publicArea.objectAttributes, TPMA_OBJECT, decrypt))\n\treturn TPM_RCS_ATTRIBUTES + RC_RSA_Decrypt_keyHandle;\n    // NOTE: Proper operation of this command requires that the sensitive area\n    // of the key is loaded. This is assured because authorization is required\n    // to use the sensitive area of the key. In order to check the authorization,\n    // the sensitive area has to be loaded, even if authorization is with policy.\n    // If label is present, make sure that it is a NULL-terminated string\n    if(!IsLabelProperlyFormatted(&in->label.b))\n\treturn TPM_RCS_VALUE + RC_RSA_Decrypt_label;\n    // Command Output\n    // Select a scheme for decrypt.\n    scheme = CryptRsaSelectScheme(in->keyHandle, &in->inScheme);\n    if(scheme == NULL)\n\treturn TPM_RCS_SCHEME + RC_RSA_Decrypt_inScheme;\n    // Decryption.  TPM_RC_VALUE, TPM_RC_SIZE, and TPM_RC_KEY error may be\n    // returned by CryptRsaDecrypt.\n    // NOTE: CryptRsaDecrypt can also return TPM_RC_ATTRIBUTES or TPM_RC_BINDING\n    // when the key is not a decryption key but that was checked above.\n    out->message.t.size = sizeof(out->message.t.buffer);\n    result = CryptRsaDecrypt(&out->message.b, &in->cipherText.b, rsaKey,\n\t\t\t     scheme, &in->label.b);\n    return result;\n}\n#endif // CC_RSA_Decrypt\n#include \"Tpm.h\"\n#include \"ECDH_KeyGen_fp.h\"\n#if CC_ECDH_KeyGen  // Conditional expansion of this file\nTPM_RC\nTPM2_ECDH_KeyGen(\n\t\t ECDH_KeyGen_In      *in,            // IN: input parameter list\n\t\t ECDH_KeyGen_Out     *out            // OUT: output parameter list\n\t\t )\n{\n    OBJECT                  *eccKey;\n    TPM2B_ECC_PARAMETER      sensitive;\n    TPM_RC                   result;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ECDH_KeyGen: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    eccKey = HandleToObject(in->keyHandle);\n    // Referenced key must be an ECC key\n    if(eccKey->publicArea.type != TPM_ALG_ECC)\n\treturn TPM_RCS_KEY + RC_ECDH_KeyGen_keyHandle;\n    // Command Output\n    do\n\t{\n\t    TPMT_PUBLIC         *keyPublic = &eccKey->publicArea;\n\t    // Create ephemeral ECC key\n\t    result = CryptEccNewKeyPair(&out->pubPoint.point, &sensitive,\n\t\t\t\t\tkeyPublic->parameters.eccDetail.curveID);\n\t    if(result == TPM_RC_SUCCESS)\n\t        {\n\t            // Compute Z\n\t            result = CryptEccPointMultiply(&out->zPoint.point,\n\t                                           keyPublic->parameters.eccDetail.curveID,\n\t                                           &keyPublic->unique.ecc,\n\t                                           &sensitive,\n\t                                           NULL, NULL);\n\t\t    // The point in the key is not on the curve. Indicate\n\t\t    // that the key is bad.\n\t            if(result == TPM_RC_ECC_POINT)\n\t                return TPM_RCS_KEY + RC_ECDH_KeyGen_keyHandle;\n\t\t    // The other possible error from CryptEccPointMultiply is\n\t\t    // TPM_RC_NO_RESULT indicating that the multiplication resulted in\n\t\t    // the point at infinity, so get a new random key and start over\n\t\t    // BTW, this never happens.\n\t        }\n\t} while(result == TPM_RC_NO_RESULT);\n    return result;\n}\n#endif // CC_ECDH_KeyGen\n#include \"Tpm.h\"\n#include \"ECDH_ZGen_fp.h\"\n#if CC_ECDH_ZGen  // Conditional expansion of this file\nTPM_RC\nTPM2_ECDH_ZGen(\n\t       ECDH_ZGen_In    *in,            // IN: input parameter list\n\t       ECDH_ZGen_Out   *out            // OUT: output parameter list\n\t       )\n{\n    TPM_RC                   result;\n    OBJECT                  *eccKey;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ECDH_ZGen: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    eccKey = HandleToObject(in->keyHandle);\n    // Selected key must be a non-restricted, decrypt ECC key\n    if(eccKey->publicArea.type != TPM_ALG_ECC)\n\treturn TPM_RCS_KEY + RC_ECDH_ZGen_keyHandle;\n    // Selected key needs to be unrestricted with the 'decrypt' attribute\n    if(IS_ATTRIBUTE(eccKey->publicArea.objectAttributes, TPMA_OBJECT, restricted)\n       || !IS_ATTRIBUTE(eccKey->publicArea.objectAttributes, TPMA_OBJECT, decrypt))\n\treturn TPM_RCS_ATTRIBUTES + RC_ECDH_ZGen_keyHandle;\n    // Make sure the scheme allows this use\n    if(eccKey->publicArea.parameters.eccDetail.scheme.scheme != TPM_ALG_ECDH\n       &&  eccKey->publicArea.parameters.eccDetail.scheme.scheme != TPM_ALG_NULL)\n\treturn TPM_RCS_SCHEME + RC_ECDH_ZGen_keyHandle;\n    // Command Output\n    // Compute Z. TPM_RC_ECC_POINT or TPM_RC_NO_RESULT may be returned here.\n    result = CryptEccPointMultiply(&out->outPoint.point,\n\t\t\t\t   eccKey->publicArea.parameters.eccDetail.curveID,\n\t\t\t\t   &in->inPoint.point,\n\t\t\t\t   &eccKey->sensitive.sensitive.ecc,\n\t\t\t\t   NULL, NULL);\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, RC_ECDH_ZGen_inPoint);\n    return result;\n}\n#endif // CC_ECDH_ZGen\n#include \"Tpm.h\"\n#include \"ECC_Parameters_fp.h\"\n#if CC_ECC_Parameters  // Conditional expansion of this file\nTPM_RC\nTPM2_ECC_Parameters(\n\t\t    ECC_Parameters_In   *in,            // IN: input parameter list\n\t\t    ECC_Parameters_Out  *out            // OUT: output parameter list\n\t\t    )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ECC_Parameters: curveID %04x\\n\", in->curveID);\n\t// fclose(f);\n  //   }\n    // Command Output\n    // Get ECC curve parameters\n    if(CryptEccGetParameters(in->curveID, &out->parameters))\n\treturn TPM_RC_SUCCESS;\n    else\n\treturn TPM_RCS_VALUE + RC_ECC_Parameters_curveID;\n}\n#endif // CC_ECC_Parameters\n#include \"Tpm.h\"\n#include \"ZGen_2Phase_fp.h\"\n#if CC_ZGen_2Phase  // Conditional expansion of this file\nTPM_RC\nTPM2_ZGen_2Phase(\n\t\t ZGen_2Phase_In      *in,            // IN: input parameter list\n\t\t ZGen_2Phase_Out     *out            // OUT: output parameter list\n\t\t )\n{\n    TPM_RC                   result;\n    OBJECT                  *eccKey;\n    TPM2B_ECC_PARAMETER      r;\n    TPM_ALG_ID               scheme;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ZGen_2Phase: keyA %08x\\n\", in->keyA);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    eccKey = HandleToObject(in->keyA);\n    // keyA must be an ECC key\n    if(eccKey->publicArea.type != TPM_ALG_ECC)\n\treturn TPM_RCS_KEY + RC_ZGen_2Phase_keyA;\n    // keyA must not be restricted and must be a decrypt key\n    if(IS_ATTRIBUTE(eccKey->publicArea.objectAttributes, TPMA_OBJECT, restricted)\n       || !IS_ATTRIBUTE(eccKey->publicArea.objectAttributes, TPMA_OBJECT, decrypt))\n\treturn TPM_RCS_ATTRIBUTES + RC_ZGen_2Phase_keyA;\n    // if the scheme of keyA is TPM_ALG_NULL, then use the input scheme; otherwise\n    // the input scheme must be the same as the scheme of keyA\n    scheme = eccKey->publicArea.parameters.asymDetail.scheme.scheme;\n    if(scheme != TPM_ALG_NULL)\n\t{\n\t    if(scheme != in->inScheme)\n\t\treturn TPM_RCS_SCHEME + RC_ZGen_2Phase_inScheme;\n\t}\n    else\n\tscheme = in->inScheme;\n    if(scheme == TPM_ALG_NULL)\n\treturn TPM_RCS_SCHEME + RC_ZGen_2Phase_inScheme;\n    // Input points must be on the curve of keyA\n    if(!CryptEccIsPointOnCurve(eccKey->publicArea.parameters.eccDetail.curveID,\n\t\t\t       &in->inQsB.point))\n\treturn TPM_RCS_ECC_POINT + RC_ZGen_2Phase_inQsB;\n    if(!CryptEccIsPointOnCurve(eccKey->publicArea.parameters.eccDetail.curveID,\n\t\t\t       &in->inQeB.point))\n\treturn TPM_RCS_ECC_POINT + RC_ZGen_2Phase_inQeB;\n    if(!CryptGenerateR(&r, &in->counter,\n\t\t       eccKey->publicArea.parameters.eccDetail.curveID,\n\t\t       NULL))\n\treturn TPM_RCS_VALUE + RC_ZGen_2Phase_counter;\n    // Command Output\n    result = CryptEcc2PhaseKeyExchange(&out->outZ1.point,\n\t\t\t\t       &out->outZ2.point,\n\t\t\t\t       eccKey->publicArea.parameters.eccDetail.curveID,\n\t\t\t\t       scheme,\n\t\t\t\t       &eccKey->sensitive.sensitive.ecc,\n\t\t\t\t       &r,\n\t\t\t\t       &in->inQsB.point,\n\t\t\t\t       &in->inQeB.point);\n    if(result == TPM_RC_SCHEME)\n\treturn TPM_RCS_SCHEME + RC_ZGen_2Phase_inScheme;\n    if(result == TPM_RC_SUCCESS)\n\tCryptEndCommit(in->counter);\n    return result;\n}\n#endif // CC_ZGen_2Phase\n#include \"Tpm.h\"\n#include \"ECC_Encrypt_fp.h\"\n\n#if CC_ECC_Encrypt  // Conditional expansion of this file\nTPM_RC\nTPM2_ECC_Encrypt(\n\t\t ECC_Encrypt_In   *in,            // IN: input parameter list\n\t\t ECC_Encrypt_Out  *out            // OUT: output parameter list\n\t\t )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ECC_Encrypt: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    OBJECT          *pubKey = HandleToObject(in->keyHandle);\n    // Parameter validation\n    if (pubKey->publicArea.type != TPM_ALG_ECC)\n\treturn TPM_RC_KEY + RC_ECC_Encrypt_keyHandle;\n    // Have to have a scheme selected\n    if(!CryptEccSelectScheme(pubKey, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_ECC_Encrypt_inScheme;\n    //  Command Output\n    return CryptEccEncrypt(pubKey, &in->inScheme, &in->plainText,\n\t\t\t   &out->C1.point, &out->C2, &out->C3);\n}\n#endif // CC_ECC_Encrypt\n#include \"Tpm.h\"\n#include \"ECC_Decrypt_fp.h\"\n#include \"CryptEccCrypt_fp.h\"\n\n#if CC_ECC_Decrypt  // Conditional expansion of this file\nTPM_RC\nTPM2_ECC_Decrypt(\n\t\t ECC_Decrypt_In   *in,            // IN: input parameter list\n\t\t ECC_Decrypt_Out  *out            // OUT: output parameter list\n\t\t )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ECC_Decrypt: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    OBJECT          *key = HandleToObject(in->keyHandle);\n    // Parameter validation\n    // Must be the correct type of key with correct attributes\n    if (key->publicArea.type != TPM_ALG_ECC)\n\treturn TPM_RC_KEY + RC_ECC_Decrypt_keyHandle;\n    if (IS_ATTRIBUTE(key->publicArea.objectAttributes, TPMA_OBJECT, restricted)\n\t|| !IS_ATTRIBUTE(key->publicArea.objectAttributes, TPMA_OBJECT, decrypt))\n\treturn TPM_RCS_ATTRIBUTES + RC_ECC_Decrypt_keyHandle;\n    // Have to have a scheme selected\n    if(!CryptEccSelectScheme(key, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_ECC_Decrypt_inScheme;\n    //  Command Output\n    return CryptEccDecrypt(key, &in->inScheme, &out->plainText,\n\t\t\t   &in->C1.point, &in->C2, &in->C3);\n}\n#endif // CC_ECC_Decrypt\n\n"
  },
  {
    "path": "ftpm-opensbi/src/Attest_spt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Attest_spt.c 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"Attest_spt_fp.h\"\n/* 7.2.2 Functions */\n/* 7.2.2.1 FillInAttestInfo() */\n/* Fill in common fields of TPMS_ATTEST structure. */\nvoid\nFillInAttestInfo(\n\t\t TPMI_DH_OBJECT       signHandle,    // IN: handle of signing object\n\t\t TPMT_SIG_SCHEME     *scheme,        // IN/OUT: scheme to be used for signing\n\t\t TPM2B_DATA          *data,          // IN: qualifying data\n\t\t TPMS_ATTEST         *attest         // OUT: attest structure\n\t\t )\n{\n    OBJECT              *signObject = HandleToObject(signHandle);\n    // Magic number\n    attest->magic = TPM_GENERATED_VALUE;\n    if(signObject == NULL)\n\t{\n\t    // The name for a null handle is TPM_RH_NULL\n\t    // This is defined because UINT32_TO_BYTE_ARRAY does a cast. If the\n\t    // size of the cast is smaller than a constant, the compiler warns\n\t    // about the truncation of a constant value.\n\t    TPM_HANDLE      nullHandle = TPM_RH_NULL;\n\t    attest->qualifiedSigner.t.size = sizeof(TPM_HANDLE);\n\t    UINT32_TO_BYTE_ARRAY(nullHandle, attest->qualifiedSigner.t.name);\n\t}\n    else\n\t{\n\t    // Certifying object qualified name\n\t    // if the scheme is anonymous, this is an empty buffer\n\t    if(CryptIsSchemeAnonymous(scheme->scheme))\n\t\tattest->qualifiedSigner.t.size = 0;\n\t    else\n\t\tattest->qualifiedSigner = signObject->qualifiedName;\n\t}\n    // current clock in plain text\n    TimeFillInfo(&attest->clockInfo);\n    // Firmware version in plain text\n    attest->firmwareVersion = ((UINT64)gp.firmwareV1 << (sizeof(UINT32) * 8));\n    attest->firmwareVersion += gp.firmwareV2;\n    // Check the hierarchy of sign object.  For NULL sign handle, the hierarchy\n    // will be TPM_RH_NULL\n    if((signObject == NULL)\n       || (!signObject->attributes.epsHierarchy\n\t   && !signObject->attributes.ppsHierarchy))\n\t{\n\t    // For signing key that is not in platform or endorsement hierarchy,\n\t    // obfuscate the reset, restart and firmware version information\n\t    UINT64          obfuscation[2];\n\t    CryptKDFa(CONTEXT_INTEGRITY_HASH_ALG, &gp.shProof.b, OBFUSCATE_STRING,\n\t\t      &attest->qualifiedSigner.b, NULL, 128,\n\t\t      (BYTE *)&obfuscation[0], NULL, FALSE);\n\t    // Obfuscate data\n\t    attest->firmwareVersion += obfuscation[0];\n\t    attest->clockInfo.resetCount += (UINT32)(obfuscation[1] >> 32);\n\t    attest->clockInfo.restartCount += (UINT32)obfuscation[1];\n\t}\n    // External data\n    if(CryptIsSchemeAnonymous(scheme->scheme))\n\tattest->extraData.t.size = 0;\n    else\n\t{\n\t    // If we move the data to the attestation structure, then it is not\n\t    // used in the signing operation except as part of the signed data\n\t    attest->extraData = *data;\n\t    data->t.size = 0;\n\t}\n}\n/* 7.2.2.2 SignAttestInfo() */\n/* Sign a TPMS_ATTEST structure. If signHandle is TPM_RH_NULL, a null signature is returned. */\n/* Error Returns Meaning */\n/* TPM_RC_ATTRIBUTES signHandle references not a signing key */\n/* TPM_RC_SCHEME scheme is not compatible with signHandle type */\n/* TPM_RC_VALUE digest generated for the given scheme is greater than the modulus of signHandle (for\n   an RSA key); invalid commit status or failed to generate r value (for an ECC key) */\nTPM_RC\nSignAttestInfo(\n\t       OBJECT              *signKey,           // IN: sign object\n\t       TPMT_SIG_SCHEME     *scheme,            // IN: sign scheme\n\t       TPMS_ATTEST         *certifyInfo,       // IN: the data to be signed\n\t       TPM2B_DATA          *qualifyingData,    // IN: extra data for the signing\n\t       //     process\n\t       TPM2B_ATTEST        *attest,            // OUT: marshaled attest blob to be\n\t       //     signed\n\t       TPMT_SIGNATURE      *signature          // OUT: signature\n\t       )\n{\n    BYTE                    *buffer;\n    HASH_STATE              hashState;\n    TPM2B_DIGEST            digest;\n    TPM_RC                  result;\n    // Marshal TPMS_ATTEST structure for hash\n    buffer = attest->t.attestationData;\n    attest->t.size = TPMS_ATTEST_Marshal(certifyInfo, &buffer, NULL);\n    if(signKey == NULL)\n\t{\n\t    signature->sigAlg = TPM_ALG_NULL;\n\t    result = TPM_RC_SUCCESS;\n\t}\n    else\n\t{\n\t    TPMI_ALG_HASH           hashAlg;\n\t    // Compute hash\n\t    hashAlg = scheme->details.any.hashAlg;\n\t    // need to set the receive buffer to get something put in it\n\t    digest.t.size = sizeof(digest.t.buffer);\n\t    digest.t.size = CryptHashBlock(hashAlg, attest->t.size,\n\t\t\t\t\t   attest->t.attestationData,\n\t\t\t\t\t   digest.t.size, digest.t.buffer);\n\t    // If there is qualifying data, need to rehash the data\n\t    // hash(qualifyingData || hash(attestationData))\n\t    if(qualifyingData->t.size != 0)\n\t\t{\n\t\t    CryptHashStart(&hashState, hashAlg);\n\t\t    CryptDigestUpdate2B(&hashState, &qualifyingData->b);\n\t\t    CryptDigestUpdate2B(&hashState, &digest.b);\n\t\t    CryptHashEnd2B(&hashState, &digest.b);\n\t\t}\n\t    // Sign the hash. A TPM_RC_VALUE, TPM_RC_SCHEME, or\n\t    // TPM_RC_ATTRIBUTES error may be returned at this point\n\t    result = CryptSign(signKey, scheme, &digest, signature);\n\t    // Since the clock is used in an attestation, the state in NV is no longer\n\t    // \"orderly\" with respect to the data in RAM if the signature is valid\n\t    if(result == TPM_RC_SUCCESS)\n\t\t{\n\t\t    // Command uses the clock so need to clear the orderly state if it is\n\t\t    // set.\n\t\t    result = NvClearOrderly();\n\t\t}\n\t}\n    return result;\n}\n/* 7.2.2.3 IsSigningObject() */\n/* Checks to see if the object is OK for signing. This is here rather than in Object_spt.c because\n   all the attestation commands use this file but not Object_spt.c. */\n/* Return Values Meaning */\n/* TRUE object may sign */\n/* FALSE object may not sign */\nBOOL\nIsSigningObject(\n\t\tOBJECT          *object         // IN:\n\t\t)\n{\n    return ((object == NULL)\n\t    || ((IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, sign)\n\t\t && object->publicArea.type != TPM_ALG_SYMCIPHER)));\n}\n\n"
  },
  {
    "path": "ftpm-opensbi/src/AttestationCommands.c",
    "content": "\n/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Attestation Commands  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: AttestationCommands.c 1658 2021-01-22 23:14:01Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source CoDe must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"Attest_spt_fp.h\"\n#include \"Certify_fp.h\"\n\nextern int verbose;\n\n#if CC_Certify  // Conditional expansion of this file\nTPM_RC\nTPM2_Certify(\n\t     Certify_In      *in,            // IN: input parameter list\n\t     Certify_Out     *out            // OUT: output parameter list\n\t     )\n{\n    TPMS_ATTEST             certifyInfo;\n    OBJECT                  *signObject = HandleToObject(in->signHandle);\n    OBJECT                  *certifiedObject = HandleToObject(in->objectHandle);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Certify: signHandle %08x\\n\", in->signHandle);\n\t// fprintf(f, \"TPM2_Certify: objectHandle %08x\\n\", in->objectHandle);\n\t// fclose(f);\n  //   }\n    // Input validation\n    if(!IsSigningObject(signObject))\n\treturn TPM_RCS_KEY + RC_Certify_signHandle;\n    if(!CryptSelectSignScheme(signObject, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_Certify_inScheme;\n    // Command Output\n    // Filling in attest information\n    // Common fields\n    FillInAttestInfo(in->signHandle, &in->inScheme, &in->qualifyingData,\n\t\t     &certifyInfo);\n    // Certify specific fields\n    certifyInfo.type = TPM_ST_ATTEST_CERTIFY;\n    // NOTE: the certified object is not allowed to be TPM_ALG_NULL so\n    // 'certifiedObject' will never be NULL\n    certifyInfo.attested.certify.name = certifiedObject->name;\n\n    // When using an anonymous signing scheme, need to set the qualified Name to the\n    // empty buffer to avoid correlation between keys\n    if(CryptIsSchemeAnonymous(in->inScheme.scheme))\n\tcertifyInfo.attested.certify.qualifiedName.t.size = 0;\n    else\n\tcertifyInfo.attested.certify.qualifiedName = certifiedObject->qualifiedName;\n\n    // Sign attestation structure.  A NULL signature will be returned if\n    // signHandle is TPM_RH_NULL.  A TPM_RC_NV_UNAVAILABLE, TPM_RC_NV_RATE,\n    // TPM_RC_VALUE, TPM_RC_SCHEME or TPM_RC_ATTRIBUTES error may be returned\n    // by SignAttestInfo()\n    return SignAttestInfo(signObject, &in->inScheme, &certifyInfo,\n\t\t\t  &in->qualifyingData, &out->certifyInfo, &out->signature);\n}\n#endif // CC_Certify\n#include \"Tpm.h\"\n#include \"Attest_spt_fp.h\"\n#include \"CertifyCreation_fp.h\"\n#if CC_CertifyCreation  // Conditional expansion of this file\nTPM_RC\nTPM2_CertifyCreation(\n\t\t     CertifyCreation_In      *in,            // IN: input parameter list\n\t\t     CertifyCreation_Out     *out            // OUT: output parameter list\n\t\t     )\n{\n    TPMT_TK_CREATION        ticket;\n    TPMS_ATTEST             certifyInfo;\n    OBJECT                  *certified = HandleToObject(in->objectHandle);\n    OBJECT                  *signObject = HandleToObject(in->signHandle);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_CertifyCreation: signHandle %08x\\n\", in->signHandle);\n\t// fprintf(f, \"TPM2_CertifyCreation: objectHandle %08x\\n\", in->objectHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    if(!IsSigningObject(signObject))\n\treturn TPM_RCS_KEY + RC_CertifyCreation_signHandle;\n    if(!CryptSelectSignScheme(signObject, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_CertifyCreation_inScheme;\n    // CertifyCreation specific input validation\n    // Re-compute ticket\n    TicketComputeCreation(in->creationTicket.hierarchy, &certified->name,\n\t\t\t  &in->creationHash, &ticket);\n    // Compare ticket\n    if(!MemoryEqual2B(&ticket.digest.b, &in->creationTicket.digest.b))\n\treturn TPM_RCS_TICKET + RC_CertifyCreation_creationTicket;\n    // Command Output\n    // Common fields\n    FillInAttestInfo(in->signHandle, &in->inScheme, &in->qualifyingData,\n\t\t     &certifyInfo);\n    // CertifyCreation specific fields\n    // Attestation type\n    certifyInfo.type = TPM_ST_ATTEST_CREATION;\n    certifyInfo.attested.creation.objectName = certified->name;\n    // Copy the creationHash\n    certifyInfo.attested.creation.creationHash = in->creationHash;\n    // Sign attestation structure.  A NULL signature will be returned if\n    // signObject is TPM_RH_NULL.  A TPM_RC_NV_UNAVAILABLE, TPM_RC_NV_RATE,\n    // TPM_RC_VALUE, TPM_RC_SCHEME or TPM_RC_ATTRIBUTES error may be returned at\n    // this point\n    return SignAttestInfo(signObject, &in->inScheme, &certifyInfo,\n\t\t\t  &in->qualifyingData, &out->certifyInfo,\n\t\t\t  &out->signature);\n}\n#endif // CC_CertifyCreation\n#include \"Tpm.h\"\n#include \"Attest_spt_fp.h\"\n#include \"Quote_fp.h\"\n#if CC_Quote  // Conditional expansion of this file\nTPM_RC\nTPM2_Quote(\n\t   Quote_In        *in,            // IN: input parameter list\n\t   Quote_Out       *out            // OUT: output parameter list\n\t   )\n{\n    TPMI_ALG_HASH            hashAlg;\n    TPMS_ATTEST              quoted;\n    OBJECT                 *signObject = HandleToObject(in->signHandle);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Quote: signHandle %08x\\n\", in->signHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    if(!IsSigningObject(signObject))\n\treturn TPM_RCS_KEY + RC_Quote_signHandle;\n    if(!CryptSelectSignScheme(signObject, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_Quote_inScheme;\n    // Command Output\n    // Filling in attest information\n    // Common fields\n    // FillInAttestInfo may return TPM_RC_SCHEME or TPM_RC_KEY\n    FillInAttestInfo(in->signHandle, &in->inScheme, &in->qualifyingData, &quoted);\n    // Quote specific fields\n    // Attestation type\n    quoted.type = TPM_ST_ATTEST_QUOTE;\n    // Get hash algorithm in sign scheme.  This hash algorithm is used to\n    // compute PCR digest. If there is no algorithm, then the PCR cannot\n    // be digested and this command returns TPM_RC_SCHEME\n    hashAlg = in->inScheme.details.any.hashAlg;\n    if(hashAlg == TPM_ALG_NULL)\n\treturn TPM_RCS_SCHEME + RC_Quote_inScheme;\n    // Compute PCR digest\n    PCRComputeCurrentDigest(hashAlg, &in->PCRselect,\n\t\t\t    &quoted.attested.quote.pcrDigest);\n    // Copy PCR select.  \"PCRselect\" is modified in PCRComputeCurrentDigest\n    // function\n    quoted.attested.quote.pcrSelect = in->PCRselect;\n    // Sign attestation structure.  A NULL signature will be returned if\n    // signObject is NULL.\n    return SignAttestInfo(signObject, &in->inScheme, &quoted, &in->qualifyingData,\n\t\t\t  &out->quoted, &out->signature);\n}\n#endif // CC_Quote\n#include \"Tpm.h\"\n#include \"Attest_spt_fp.h\"\n#include \"GetSessionAuditDigest_fp.h\"\n#if CC_GetSessionAuditDigest  // Conditional expansion of this file\nTPM_RC\nTPM2_GetSessionAuditDigest(\n\t\t\t   GetSessionAuditDigest_In    *in,            // IN: input parameter list\n\t\t\t   GetSessionAuditDigest_Out   *out            // OUT: output parameter list\n\t\t\t   )\n{\n    SESSION                 *session = SessionGet(in->sessionHandle);\n    TPMS_ATTEST              auditInfo;\n    OBJECT                 *signObject = HandleToObject(in->signHandle);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_GetSessionAuditDigest: signHandle %08x\\n\", in->signHandle);\n\t// fprintf(f, \"TPM2_GetSessionAuditDigest: sessionHandle %08x\\n\", in->sessionHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    if(!IsSigningObject(signObject))\n\treturn TPM_RCS_KEY + RC_GetSessionAuditDigest_signHandle;\n    if(!CryptSelectSignScheme(signObject, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_GetSessionAuditDigest_inScheme;\n    // session must be an audit session\n    if(session->attributes.isAudit == CLEAR)\n\treturn TPM_RCS_TYPE + RC_GetSessionAuditDigest_sessionHandle;\n    // Command Output\n    // Fill in attest information common fields\n    FillInAttestInfo(in->signHandle, &in->inScheme, &in->qualifyingData,\n\t\t     &auditInfo);\n    // SessionAuditDigest specific fields\n    auditInfo.type = TPM_ST_ATTEST_SESSION_AUDIT;\n    auditInfo.attested.sessionAudit.sessionDigest = session->u2.auditDigest;\n    // Exclusive audit session\n    auditInfo.attested.sessionAudit.exclusiveSession\n\t= (g_exclusiveAuditSession == in->sessionHandle);\n    // Sign attestation structure.  A NULL signature will be returned if\n    // signObject is NULL.\n    return SignAttestInfo(signObject, &in->inScheme, &auditInfo,\n\t\t\t  &in->qualifyingData, &out->auditInfo,\n\t\t\t  &out->signature);\n}\n#endif // CC_GetSessionAuditDigest\n#include \"Tpm.h\"\n#include \"Attest_spt_fp.h\"\n#include \"GetCommandAuditDigest_fp.h\"\n#if CC_GetCommandAuditDigest  // Conditional expansion of this file\nTPM_RC\nTPM2_GetCommandAuditDigest(\n\t\t\t   GetCommandAuditDigest_In    *in,            // IN: input parameter list\n\t\t\t   GetCommandAuditDigest_Out   *out            // OUT: output parameter list\n\t\t\t   )\n{\n    TPM_RC                  result;\n    TPMS_ATTEST             auditInfo;\n    OBJECT                 *signObject = HandleToObject(in->signHandle);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_GetCommandAuditDigest: signHandle %08x\\n\", in->signHandle);\n\t// fclose(f);\n  //   }\n    // Input validation\n    if(!IsSigningObject(signObject))\n\treturn TPM_RCS_KEY + RC_GetCommandAuditDigest_signHandle;\n    if(!CryptSelectSignScheme(signObject, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_GetCommandAuditDigest_inScheme;\n    // Command Output\n    // Fill in attest information common fields\n    FillInAttestInfo(in->signHandle, &in->inScheme, &in->qualifyingData,\n\t\t     &auditInfo);\n    // CommandAuditDigest specific fields\n    auditInfo.type = TPM_ST_ATTEST_COMMAND_AUDIT;\n    auditInfo.attested.commandAudit.digestAlg = gp.auditHashAlg;\n    auditInfo.attested.commandAudit.auditCounter = gp.auditCounter;\n    // Copy command audit log\n    auditInfo.attested.commandAudit.auditDigest = gr.commandAuditDigest;\n    CommandAuditGetDigest(&auditInfo.attested.commandAudit.commandDigest);\n    // Sign attestation structure.  A NULL signature will be returned if\n    // signHandle is TPM_RH_NULL.  A TPM_RC_NV_UNAVAILABLE, TPM_RC_NV_RATE,\n    // TPM_RC_VALUE, TPM_RC_SCHEME or TPM_RC_ATTRIBUTES error may be returned at\n    // this point\n    result = SignAttestInfo(signObject, &in->inScheme, &auditInfo,\n\t\t\t    &in->qualifyingData, &out->auditInfo,\n\t\t\t    &out->signature);\n    // Internal Data Update\n    if(result == TPM_RC_SUCCESS && in->signHandle != TPM_RH_NULL)\n\t// Reset log\n\tgr.commandAuditDigest.t.size = 0;\n    return result;\n}\n#endif // CC_GetCommandAuditDigest\n#include \"Tpm.h\"\n#include \"Attest_spt_fp.h\"\n#include \"GetTime_fp.h\"\n#if CC_GetTime  // Conditional expansion of this file\nTPM_RC\nTPM2_GetTime(\n\t     GetTime_In      *in,            // IN: input parameter list\n\t     GetTime_Out     *out            // OUT: output parameter list\n\t     )\n{\n    TPMS_ATTEST             timeInfo;\n    OBJECT                 *signObject = HandleToObject(in->signHandle);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_GetTime: signHandle %08x\\n\", in->signHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    if(!IsSigningObject(signObject))\n\treturn TPM_RCS_KEY + RC_GetTime_signHandle;\n    if(!CryptSelectSignScheme(signObject, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_GetTime_inScheme;\n    // Command Output\n    // Fill in attest common fields\n    FillInAttestInfo(in->signHandle, &in->inScheme, &in->qualifyingData, &timeInfo);\n    // GetClock specific fields\n    timeInfo.type = TPM_ST_ATTEST_TIME;\n    timeInfo.attested.time.time.time = g_time;\n    TimeFillInfo(&timeInfo.attested.time.time.clockInfo);\n    // Firmware version in plain text\n    timeInfo.attested.time.firmwareVersion\n\t= (((UINT64)gp.firmwareV1) << 32) + gp.firmwareV2;\n    // Sign attestation structure.  A NULL signature will be returned if\n    // signObject is NULL.\n    return SignAttestInfo(signObject, &in->inScheme, &timeInfo, &in->qualifyingData,\n\t\t\t  &out->timeInfo, &out->signature);\n}\n#endif // CC_GetTime\n#include \"Tpm.h\"\n#include \"CertifyX509_fp.h\"\n#include \"X509.h\"\n#include \"TpmASN1_fp.h\"\n#include \"X509_spt_fp.h\"\n#include \"Attest_spt_fp.h\"\n#if CC_CertifyX509 // Conditional expansion of this file\n#if CERTIFYX509_DEBUG\n#  include \"tpm_to_platform_interface.h\"\n#endif\n\n/* Error Returns\tMeaning*/\n/* TPM_RC_ATTRIBUTES\tthe attributes of objectHandle are not compatible with the KeyUsage() or TPMA_OBJECT values in the extensions fields */\n/* TPM_RC_BINDING\tthe public and private portions of the key are not properly bound. */\n/* TPM_RC_HASH\tthe hash algorithm in the scheme is not supported */\n/* TPM_RC_KEY\tsignHandle does not reference a signing key; */\n/* TPM_RC_SCHEME\tthe scheme is not compatible with sign key type, or input scheme is not compatible with default scheme, or the chosen scheme is not a valid sign scheme */\n    /* TPM_RC_VALUE\tmost likely a problem with the format of partialCertificate */\nTPM_RC\nTPM2_CertifyX509(\n\t\t CertifyX509_In          *in,          // IN: input parameter list\n\t\t CertifyX509_Out         *out            // OUT: output parameter list\n\t\t )\n{\n    TPM_RC                   result;\n    OBJECT                  *signKey = HandleToObject(in->signHandle);\n    OBJECT                  *object = HandleToObject(in->objectHandle);\n    HASH_STATE               hash;\n    INT16                    length;        // length for a tagged element\n    ASN1UnmarshalContext     ctx;\n    ASN1MarshalContext       ctxOut;\n    // certTBS holds an array of pointers and lengths. Each entry references the\n    // corresponding value in a TBSCertificate structure. For example, the 1th\n    // element references the version number\n    stringRef                certTBS[REF_COUNT] = {{0}};\n#define ALLOWED_SEQUENCES   (SUBJECT_PUBLIC_KEY_REF - SIGNATURE_REF)\n    stringRef                partial[ALLOWED_SEQUENCES] = {{0}};\n    INT16                    countOfSequences = 0;\n    INT16                    i;\n    //\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_CertifyX509: signHandle %08x\\n\", in->signHandle);\n\t// fprintf(f, \"TPM2_CertifyX509: objectHandle %08x\\n\", in->objectHandle);\n\t// fclose(f);\n  //   }\n#if CERTIFYX509_DEBUG\n    DebugFileInit();\n    DebugDumpBuffer(in->partialCertificate.t.size, in->partialCertificate.t.buffer,\n\t\t    \"partialCertificate\");\n#endif\n\n    // Input Validation\n    if(in->reserved.b.size != 0)\n\treturn TPM_RC_SIZE + RC_CertifyX509_reserved;\n    // signing key must be able to sign\n    if(!IsSigningObject(signKey))\n\treturn TPM_RCS_KEY + RC_CertifyX509_signHandle;\n    // Pick a scheme for sign.  If the input sign scheme is not compatible with\n    // the default scheme, return an error.\n    if(!CryptSelectSignScheme(signKey, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_CertifyX509_inScheme;\n    // Make sure that the public Key encoding is known\n    if(X509AddPublicKey(NULL, object) == 0)\n\treturn TPM_RCS_ASYMMETRIC + RC_CertifyX509_objectHandle;\n    // Unbundle 'partialCertificate'.\n    // Initialize the unmarshaling context\n    if(!ASN1UnmarshalContextInitialize(&ctx, in->partialCertificate.t.size,\n\t\t\t\t       in->partialCertificate.t.buffer))\n\treturn TPM_RCS_VALUE + RC_CertifyX509_partialCertificate;\n    // Make sure that this is a constructed SEQUENCE\n    length = ASN1NextTag(&ctx);\n    // Must be a constructed SEQUENCE that uses all of the input parameter\n    if((ctx.tag != (ASN1_CONSTRUCTED_SEQUENCE))\n       || ((ctx.offset + length) != in->partialCertificate.t.size))\n\treturn TPM_RCS_SIZE + RC_CertifyX509_partialCertificate;\n    \n    // This scans through the contents of the outermost SEQUENCE. This would be the\n    // 'issuer', 'validity', 'subject', 'issuerUniqueID' (optional),\n    // 'subjectUniqueID' (optional), and 'extensions.'\n    while(ctx.offset < ctx.size)\n\t{\n\t    INT16           startOfElement = ctx.offset;\n\t    //\n\t    // Read the next tag and length field.\n\t    length = ASN1NextTag(&ctx);\n\t    if(length < 0)\n\t\tbreak;\n\t    if(ctx.tag == ASN1_CONSTRUCTED_SEQUENCE)\n\t        {\n\t            partial[countOfSequences].buf = &ctx.buffer[startOfElement];\n\t            ctx.offset += length;\n\t            partial[countOfSequences].len = (INT16)ctx.offset - startOfElement;\n\t            if(++countOfSequences > ALLOWED_SEQUENCES)\n\t                break;\n\t        }\n\t    else if(ctx.tag  == X509_EXTENSIONS)\n\t        {\n\t            if(certTBS[EXTENSIONS_REF].len != 0)\n\t                return TPM_RCS_VALUE + RC_CertifyX509_partialCertificate;\n\t            certTBS[EXTENSIONS_REF].buf = &ctx.buffer[startOfElement];\n\t            ctx.offset += length;\n\t            certTBS[EXTENSIONS_REF].len =\n\t                (INT16)ctx.offset - startOfElement;\n\t        }\n\t    else\n\t\treturn TPM_RCS_VALUE + RC_CertifyX509_partialCertificate;\n\t}\n    // Make sure that we used all of the data and found at least the required\n    // number of elements.\n    if((ctx.offset != ctx.size) || (countOfSequences < 3)\n       || (countOfSequences > 4)\n       || (certTBS[EXTENSIONS_REF].buf == NULL))\n\treturn TPM_RCS_VALUE + RC_CertifyX509_partialCertificate;\n    // Now that we know how many sequences there were, we can put them where they\n    // belong\n    for(i = 0; i < countOfSequences; i++)\n\tcertTBS[SUBJECT_KEY_REF - i] = partial[countOfSequences - 1 - i];\n\n    // If only three SEQUENCES, then the TPM needs to produce the signature algorithm.\n    // See if it can\n    if((countOfSequences == 3) &&\n       (X509AddSigningAlgorithm(NULL, signKey, &in->inScheme) == 0))\n\treturn TPM_RCS_SCHEME + RC_CertifyX509_signHandle;\n\n    // Process the extensions\n    result = X509ProcessExtensions(object, &certTBS[EXTENSIONS_REF]);\n    if(result != TPM_RC_SUCCESS)\n\t// If the extension has the TPMA_OBJECT extension and the attributes don't\n\t// match, then the error code will be TPM_RCS_ATTRIBUTES. Otherwise, the error\n\t// indicates a malformed partialCertificate.\n\treturn result + ((result == TPM_RCS_ATTRIBUTES)\n\t\t\t ? RC_CertifyX509_objectHandle\n\t\t\t : RC_CertifyX509_partialCertificate);\n    // Command Output\n    // Create the addedToCertificate values\n\n    // Build the addedToCertificate from the bottom up.\n    // Initialize the context structure\n    ASN1InitialializeMarshalContext(&ctxOut, sizeof(out->addedToCertificate.t.buffer),\n\t\t\t\t    out->addedToCertificate.t.buffer);\n    // Place a marker for the overall context\n    ASN1StartMarshalContext(&ctxOut);  // SEQUENCE for addedToCertificate\n\n    // Add the subject public key descriptor\n    certTBS[SUBJECT_PUBLIC_KEY_REF].len = X509AddPublicKey(&ctxOut, object);\n    certTBS[SUBJECT_PUBLIC_KEY_REF].buf = ctxOut.buffer + ctxOut.offset;\n    // If the caller didn't provide the algorithm identifier, create it\n    if(certTBS[SIGNATURE_REF].len == 0)\n\t{\n\t    certTBS[SIGNATURE_REF].len = X509AddSigningAlgorithm(&ctxOut, signKey,\n\t\t\t\t\t\t\t\t &in->inScheme);\n\t    certTBS[SIGNATURE_REF].buf = ctxOut.buffer + ctxOut.offset;\n\t}\n    // Create the serial number value. Use the out->tbsDigest as scratch.\n    {\n\tTPM2B                   *digest = &out->tbsDigest.b;\n\t//\n\tdigest->size = (INT16)CryptHashStart(&hash, signKey->publicArea.nameAlg);\n\tpAssert(digest->size != 0);\n\n\t// The serial number size is the smaller of the digest and the vendor-defined\n\t// value\n\tdigest->size = MIN(digest->size, SIZE_OF_X509_SERIAL_NUMBER);\n\t// Add all the parts of the certificate other than the serial number\n\t// and version number\n\tfor(i = SIGNATURE_REF; i < REF_COUNT; i++)\n\t    CryptDigestUpdate(&hash, certTBS[i].len, certTBS[i].buf);\n\t// throw in the Name of the signing key...\n\tCryptDigestUpdate2B(&hash, &signKey->name.b);\n\t// ...and the Name of the signed key.\n\tCryptDigestUpdate2B(&hash, &object->name.b);\n\t// Done\n\tCryptHashEnd2B(&hash, digest);\n    }\n\n    // Add the serial number\n    certTBS[SERIAL_NUMBER_REF].len =\n\tASN1PushInteger(&ctxOut, out->tbsDigest.t.size, out->tbsDigest.t.buffer);\n    certTBS[SERIAL_NUMBER_REF].buf = ctxOut.buffer + ctxOut.offset;\n\n    // Add the static version number\n    ASN1StartMarshalContext(&ctxOut);\n    ASN1PushUINT(&ctxOut, 2);\n    certTBS[VERSION_REF].len =\n\tASN1EndEncapsulation(&ctxOut, ASN1_APPLICAIION_SPECIFIC);\n    certTBS[VERSION_REF].buf = ctxOut.buffer + ctxOut.offset;\n\n    // Create a fake tag and length for the TBS in the space used for\n    // 'addedToCertificate'\n    {\n\tfor(length = 0, i = 0; i < REF_COUNT; i++)\n\t    length += certTBS[i].len;\n\t// Put a fake tag and length into the buffer for use in the tbsDigest\n\tcertTBS[ENCODED_SIZE_REF].len =\n\t    ASN1PushTagAndLength(&ctxOut, ASN1_CONSTRUCTED_SEQUENCE, length);\n\tcertTBS[ENCODED_SIZE_REF].buf = ctxOut.buffer + ctxOut.offset;\n\t// Restore the buffer pointer to add back the number of octets used for the\n\t// tag and length\n\tctxOut.offset += certTBS[ENCODED_SIZE_REF].len;\n    }\n    // sanity check\n    if(ctxOut.offset < 0)\n\treturn TPM_RC_FAILURE;\n    // Create the tbsDigest to sign\n    out->tbsDigest.t.size = CryptHashStart(&hash, in->inScheme.details.any.hashAlg);\n    for(i = 0; i < REF_COUNT; i++)\n\tCryptDigestUpdate(&hash, certTBS[i].len, certTBS[i].buf);\n    CryptHashEnd2B(&hash, &out->tbsDigest.b);\n\n#if CERTIFYX509_DEBUG\n    {\n\tBYTE                 fullTBS[4096];\n\tBYTE                *fill = fullTBS;\n\tint                  j;\n\tfor (j = 0; j < REF_COUNT; j++)\n\t    {\n\t\tMemoryCopy(fill, certTBS[j].buf, certTBS[j].len);\n\t\tfill += certTBS[j].len;\n\t    }\n\tDebugDumpBuffer((int)(fill - &fullTBS[0]), fullTBS, \"\\nfull TBS\");\n    }\n#endif\n\n    // Finish up the processing of addedToCertificate\n    // Create the actual tag and length for the addedToCertificate structure\n    out->addedToCertificate.t.size =\n\tASN1EndEncapsulation(&ctxOut, ASN1_CONSTRUCTED_SEQUENCE);\n    // Now move all the addedToContext to the start of the buffer\n    MemoryCopy(out->addedToCertificate.t.buffer, ctxOut.buffer + ctxOut.offset,\n\t       out->addedToCertificate.t.size);\n#if CERTIFYX509_DEBUG\n    DebugDumpBuffer(out->addedToCertificate.t.size, out->addedToCertificate.t.buffer,\n\t\t    \"\\naddedToCertificate\");\n#endif\n    // only thing missing is the signature\n    result = CryptSign(signKey, &in->inScheme, &out->tbsDigest, &out->signature);\n\n    return result;\n}\n#endif // CC_CertifyX509\n"
  },
  {
    "path": "ftpm-opensbi/src/AuditCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   \tCommand Audit  \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"SetCommandCodeAuditStatus_fp.h\"\n\nextern int verbose;\n\n#if CC_SetCommandCodeAuditStatus  // Conditional expansion of this file\nTPM_RC\nTPM2_SetCommandCodeAuditStatus(\n\t\t\t       SetCommandCodeAuditStatus_In    *in\t// IN: input parameter list\n\t\t\t       )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_SetCommandCodeAuditStatus: auth %08x\\n\", in->auth);\n\t// fclose(f);\n  //   }\n    // The command needs NV update.  Check if NV is available.\n    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at\n    // this point\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Internal Data Update\n    // Update hash algorithm\n    if(in->auditAlg != TPM_ALG_NULL && in->auditAlg != gp.auditHashAlg)\n\t{\n\t    // Can't change the algorithm and command list at the same time\n\t    if(in->setList.count != 0 || in->clearList.count != 0)\n\t\treturn TPM_RCS_VALUE + RC_SetCommandCodeAuditStatus_auditAlg;\n\t    // Change the hash algorithm for audit\n\t    gp.auditHashAlg = in->auditAlg;\n\t    // Set the digest size to a unique value that indicates that the digest\n\t    // algorithm has been changed. The size will be cleared to zero in the\n\t    // command audit processing on exit.\n\t    gr.commandAuditDigest.t.size = 1;\n\t    // Save the change of command audit data (this sets g_updateNV so that NV\n\t    // will be updated on exit.)\n\t    NV_SYNC_PERSISTENT(auditHashAlg);\n\t}\n    else\n\t{\n\t    UINT32          i;\n\t    BOOL            changed = FALSE;\n\t    // Process set list\n\t    for(i = 0; i < in->setList.count; i++)\n\t\t// If change is made in CommandAuditSet, set changed flag\n\t\tif(CommandAuditSet(in->setList.commandCodes[i]))\n\t\t    changed = TRUE;\n\t    // Process clear list\n\t    for(i = 0; i < in->clearList.count; i++)\n\t\t// If change is made in CommandAuditClear, set changed flag\n\t\tif(CommandAuditClear(in->clearList.commandCodes[i]))\n\t\t    changed = TRUE;\n\t    // if change was made to command list, update NV\n\t    if(changed)\n\t\t// this sets g_updateNV so that NV will be updated on exit.\n\t\tNV_SYNC_PERSISTENT(auditCommands);\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_SetCommandCodeAuditStatus\n"
  },
  {
    "path": "ftpm-opensbi/src/Bits.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Bit Manipulation Routines   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Bits.c 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.2 Bits.c */\n/* 9.2.1 Introduction */\n/* This file contains bit manipulation routines.  They operate on bit arrays. */\n/* The 0th bit in the array is the right-most bit in the 0th octet in the array. */\n/* NOTE: If pAssert() is defined, the functions will assert if the indicated bit number is outside\n   of the range of bArray. How the assert is handled is implementation dependent. */\n/* 9.2.2 Includes */\n#include \"Tpm.h\"\n/* 9.2.3 Functions */\n/* 9.2.3.1 TestBit() */\n/* This function is used to check the setting of a bit in an array of bits. */\n/* Return Values Meaning */\n/* TRUE bit is set */\n/* FALSE bit is not set */\n\nBOOL\nTestBit(\n\tunsigned int     bitNum,        // IN: number of the bit in 'bArray'\n\tBYTE            *bArray,        // IN: array containing the bits\n\tunsigned int     bytesInArray   // IN: size in bytes of 'bArray'\n\t)\n{\n    pAssert(bytesInArray > (bitNum >> 3));\n    return((bArray[bitNum >> 3] & (1 << (bitNum & 7))) != 0);\n}\n\n/* 9.2.3.2 SetBit() */\n/* This function will set the indicated bit in bArray. */\n\nvoid\nSetBit(\n       unsigned int     bitNum,        // IN: number of the bit in 'bArray'\n       BYTE            *bArray,        // IN: array containing the bits\n       unsigned int     bytesInArray   // IN: size in bytes of 'bArray'\n       )\n{\n    pAssert(bytesInArray > (bitNum >> 3));\n    bArray[bitNum >> 3] |= (1 << (bitNum & 7));\n}\n\n/* 9.2.3.3 ClearBit() */\n/* This function will clear the indicated bit in bArray. */\n\nvoid\nClearBit(\n\t unsigned int     bitNum,        // IN: number of the bit in 'bArray'.\n\t BYTE            *bArray,        // IN: array containing the bits\n\t unsigned int     bytesInArray   // IN: size in bytes of 'bArray'\n\t )\n{\n    pAssert(bytesInArray > (bitNum >> 3));\n    bArray[bitNum >> 3] &= ~(1 << (bitNum & 7));\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/BnConvert.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tconversion functions that will convert TPM2B to/from internal format\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the basic conversion functions that will convert TPM2B\n// to/from the internal format. The internal format is a bigNum,\n//\n\n//** Includes\n\n#include \"TpmBigNum.h\"\n\n//** Functions\n\n//*** BnFromBytes()\n// This function will convert a big-endian byte array to the internal number\n// format. If bn is NULL, then the output is NULL. If bytes is null or the\n// required size is 0, then the output is set to zero\nLIB_EXPORT bigNum BnFromBytes(bigNum bn, const BYTE* bytes, NUMBYTES nBytes)\n{\n    const BYTE*   pFrom;  // 'p' points to the least significant bytes of source\n    BYTE*         pTo;    // points to least significant bytes of destination\n    crypt_uword_t size;\n    //\n\n    size = (bytes != NULL) ? BYTES_TO_CRYPT_WORDS(nBytes) : 0;\n\n    // If nothing in, nothing out\n    if(bn == NULL)\n\treturn NULL;\n\n    // make sure things fit\n    pAssert(BnGetAllocated(bn) >= size);\n\n    if(size > 0)\n\t{\n\t    // Clear the topmost word in case it is not filled with data\n\t    bn->d[size - 1] = 0;\n\t    // Moving the input bytes from the end of the list (LSB) end\n\t    pFrom = bytes + nBytes - 1;\n\t    // To the LS0 of the LSW of the bigNum.\n\t    pTo = (BYTE*)bn->d;\n\t    for(; nBytes != 0; nBytes--)\n\t\t*pTo++ = *pFrom--;\n\t    // For a little-endian machine, the conversion is a straight byte\n\t    // reversal. For a big-endian machine, we have to put the words in\n\t    // big-endian byte order\n#if BIG_ENDIAN_TPM\n\t    {\n\t\tcrypt_word_t t;\n\t\tfor(t = (crypt_word_t)size - 1; t >= 0; t--)\n\t\t    bn->d[t] = SWAP_CRYPT_WORD(bn->d[t]);\n\t    }\n#endif\n\t}\n    BnSetTop(bn, size);\n    return bn;\n}\n\n//*** BnFrom2B()\n// Convert an TPM2B to a BIG_NUM.\n// If the input value does not exist, or the output does not exist, or the input\n// will not fit into the output the function returns NULL\nLIB_EXPORT bigNum BnFrom2B(bigNum       bn,  // OUT:\n\t\t\t   const TPM2B* a2B  // IN: number to convert\n\t\t\t   )\n{\n    if(a2B != NULL)\n\treturn BnFromBytes(bn, a2B->buffer, a2B->size);\n    // Make sure that the number has an initialized value rather than whatever\n    // was there before\n    BnSetTop(bn, 0);  // Function accepts NULL\n    return NULL;\n}\n\n//*** BnToBytes()\n// This function converts a BIG_NUM to a byte array. It converts the bigNum to a\n// big-endian byte string and sets 'size' to the normalized value. If  'size' is an\n// input 0, then the receiving buffer is guaranteed to be large enough for the result\n// and the size will be set to the size required for bigNum (leading zeros\n// suppressed).\n//\n// The conversion for a little-endian machine simply requires that all significant\n// bytes of the bigNum be reversed. For a big-endian machine, rather than\n// unpack each word individually, the bigNum is converted to little-endian words,\n// copied, and then converted back to big-endian.\nLIB_EXPORT BOOL BnToBytes(bigConst  bn,\n\t\t\t  BYTE*     buffer,\n\t\t\t  NUMBYTES* size  // This the number of bytes that are\n\t\t\t  // available in the buffer. The result\n\t\t\t  // should be this big.\n\t\t\t  )\n{\n    crypt_uword_t requiredSize;\n    BYTE*         pFrom;\n    BYTE*         pTo;\n    crypt_uword_t count;\n    //\n    // validate inputs\n    pAssert(bn && buffer && size);\n\n    requiredSize = (BnSizeInBits(bn) + 7) / 8;\n    if(requiredSize == 0)\n\t{\n\t    // If the input value is 0, return a byte of zero\n\t    *size   = 1;\n\t    *buffer = 0;\n\t}\n    else\n\t{\n#if BIG_ENDIAN_TPM\n\t    // Copy the constant input value into a modifiable value\n\t    BN_VAR(bnL, LARGEST_NUMBER_BITS * 2);\n\t    BnCopy(bnL, bn);\n\t    // byte swap the words in the local value to make them little-endian\n\t    for(count = 0; count < bnL->size; count++)\n\t\tbnL->d[count] = SWAP_CRYPT_WORD(bnL->d[count]);\n\t    bn = (bigConst)bnL;\n#endif\n\t    if(*size == 0)\n\t\t*size = (NUMBYTES)requiredSize;\n\t    pAssert(requiredSize <= *size);\n\t    // Byte swap the number (not words but the whole value)\n\t    count = *size;\n\t    // Start from the least significant word and offset to the most significant\n\t    // byte which is in some high word\n\t    pFrom = (BYTE*)(&bn->d[0]) + requiredSize - 1;\n\t    pTo   = buffer;\n\n\t    // If the number of output bytes is larger than the number bytes required\n\t    // for the input number, pad with zeros\n\t    for(count = *size; count > requiredSize; count--)\n\t\t*pTo++ = 0;\n\t    // Move the most significant byte at the end of the BigNum to the next most\n\t    // significant byte position of the 2B and repeat for all significant bytes.\n\t    for(; requiredSize > 0; requiredSize--)\n\t\t*pTo++ = *pFrom--;\n\t}\n    return TRUE;\n}\n\n//*** BnTo2B()\n// Function to convert a BIG_NUM to TPM2B.\n// The TPM2B size is set to the requested 'size' which may require padding.\n// If 'size' is non-zero and less than required by the value in 'bn' then an error\n// is returned. If 'size' is zero, then the TPM2B is assumed to be large enough\n// for the data and a2b->size will be adjusted accordingly.\nLIB_EXPORT BOOL BnTo2B(bigConst bn,   // IN:\n\t\t       TPM2B*   a2B,  // OUT:\n\t\t       NUMBYTES size  // IN: the desired size\n\t\t       )\n{\n    // Set the output size\n    if(bn && a2B)\n\t{\n\t    a2B->size = size;\n\t    return BnToBytes(bn, a2B->buffer, &a2B->size);\n\t}\n    return FALSE;\n}\n\n#if ALG_ECC\n\n//*** BnPointFromBytes()\n// Function to create a BIG_POINT structure from a byte buffer in big-endian order.\n// A point is going to be two ECC values in the same buffer. The values are going\n// to be the size of the modulus.  They are in modular form.\nLIB_EXPORT bn_point_t* BnPointFromBytes(\n\t\t\t\t\tbigPoint    ecP,  // OUT: the preallocated point structure\n\t\t\t\t\tconst BYTE* x,\n\t\t\t\t\tNUMBYTES    nBytesX,\n\t\t\t\t\tconst BYTE* y,\n\t\t\t\t\tNUMBYTES    nBytesY)\n{\n    if(x == NULL || y == NULL)\n\treturn NULL;\n\n    if(NULL != ecP)\n\t{\n\t    BnFromBytes(ecP->x, x, nBytesX);\n\t    BnFromBytes(ecP->y, y, nBytesY);\n\t    BnSetWord(ecP->z, 1);\n\t}\n    return ecP;\n}\n\n//*** BnPointToBytes()\n// This function extracts coordinates from a BIG_POINT into\n// most-significant-byte-first memory buffers (the native format of\n// a TPMS_ECC_POINT.)\n// on input the NUMBYTES* parameters indicate the maximum buffer size.\n// on output, they represent the amount of significant data in that buffer.\nLIB_EXPORT BOOL BnPointToBytes(\n\t\t\t       pointConst ecP,  // OUT: the preallocated point structure\n\t\t\t       BYTE*      x,\n\t\t\t       NUMBYTES*  pBytesX,\n\t\t\t       BYTE*      y,\n\t\t\t       NUMBYTES*  pBytesY)\n{\n    pAssert(ecP && x && y && pBytesX && pBytesY);\n    pAssert(BnEqualWord(ecP->z, 1));\n    BOOL result = BnToBytes(ecP->x, x, pBytesX);\n    result      = result && BnToBytes(ecP->y, y, pBytesY);\n    // TODO: zeroize on error?\n    return result;\n}\n\n#endif  // ALG_ECC\n"
  },
  {
    "path": "ftpm-opensbi/src/BnEccConstants.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmStructures; Version 4.4 Mar 26, 2019\n *  Date: Aug 30, 2019  Time: 02:11:52PM\n */\n#include \"TpmBigNum.h\"\n//#include \"Tpm.h\"\n// TODO_RENAME_INC_FOLDER:private refers to the TPM_CoreLib private headers\n#include \"OIDs.h\"\n\n#if ALG_ECC\n\n// define macros expected by EccConstantData to convert the data to BigNum format\n\n#  define TO_ECC_64                      TO_CRYPT_WORD_64\n#  define TO_ECC_56(a, b, c, d, e, f, g) TO_ECC_64(0, a, b, c, d, e, f, g)\n#  define TO_ECC_48(a, b, c, d, e, f)    TO_ECC_64(0, 0, a, b, c, d, e, f)\n#  define TO_ECC_40(a, b, c, d, e)       TO_ECC_64(0, 0, 0, a, b, c, d, e)\n#  if RADIX_BITS > 32\n#    define TO_ECC_32(a, b, c, d) TO_ECC_64(0, 0, 0, 0, a, b, c, d)\n#    define TO_ECC_24(a, b, c)    TO_ECC_64(0, 0, 0, 0, 0, a, b, c)\n#    define TO_ECC_16(a, b)       TO_ECC_64(0, 0, 0, 0, 0, 0, a, b)\n#    define TO_ECC_8(a)           TO_ECC_64(0, 0, 0, 0, 0, 0, 0, a)\n#  else  // RADIX_BITS == 32\n#    define TO_ECC_32          BIG_ENDIAN_BYTES_TO_UINT32\n#    define TO_ECC_24(a, b, c) TO_ECC_32(0, a, b, c)\n#    define TO_ECC_16(a, b)    TO_ECC_32(0, 0, a, b)\n#    define TO_ECC_8(a)        TO_ECC_32(0, 0, 0, a)\n#  endif\n#  define TO_ECC_192(a, b, c)                      c, b, a\n#  define TO_ECC_224(a, b, c, d)                   d, c, b, a\n#  define TO_ECC_256(a, b, c, d)                   d, c, b, a\n#  define TO_ECC_384(a, b, c, d, e, f)             f, e, d, c, b, a\n#  define TO_ECC_528(a, b, c, d, e, f, g, h, i)    i, h, g, f, e, d, c, b, a\n#  define TO_ECC_640(a, b, c, d, e, f, g, h, i, j) j, i, h, g, f, e, d, c, b, a\n\n#  define BN_MIN_ALLOC(bytes)\t\t\t\t\t\t\\\n    (BYTES_TO_CRYPT_WORDS(bytes) == 0) ? 1 : BYTES_TO_CRYPT_WORDS(bytes)\n#  define ECC_CONST(NAME, bytes, initializer)\t\t\t    \\\n    const struct\t\t\t\t\t\t    \\\n    {\t\t\t\t\t\t\t\t    \\\n\tcrypt_uword_t allocate, size, d[BN_MIN_ALLOC(bytes)];\t\t\\\n    } NAME = {BN_MIN_ALLOC(bytes), BYTES_TO_CRYPT_WORDS(bytes), {initializer}}\n\n// This file contains the raw data for ECC curve constants. The data is wrapped\n// in macros so this file can be included in other files that format the data in\n// a memory format desired by the user.  This file itself is never used alone.\n#  include \"EccConstantData.inl\"\n\n// now define the TPMBN_ECC_CURVE_CONSTANTS objects for the known curves\n\n#  if ECC_NIST_P192\nconst TPMBN_ECC_CURVE_CONSTANTS NIST_P192 = {TPM_ECC_NIST_P192,\n\t\t\t\t\t     (bigNum)&NIST_P192_p,\n\t\t\t\t\t     (bigNum)&NIST_P192_n,\n\t\t\t\t\t     (bigNum)&NIST_P192_h,\n\t\t\t\t\t     (bigNum)&NIST_P192_a,\n\t\t\t\t\t     (bigNum)&NIST_P192_b,\n\t\t\t\t\t     {(bigNum)&NIST_P192_gX,\n\t\t\t\t\t      (bigNum)&NIST_P192_gY,\n\t\t\t\t\t      (bigNum)&NIST_P192_gZ}};\n#  endif  // ECC_NIST_P192\n\n#  if ECC_NIST_P224\nconst TPMBN_ECC_CURVE_CONSTANTS NIST_P224 = {TPM_ECC_NIST_P224,\n\t\t\t\t\t     (bigNum)&NIST_P224_p,\n\t\t\t\t\t     (bigNum)&NIST_P224_n,\n\t\t\t\t\t     (bigNum)&NIST_P224_h,\n\t\t\t\t\t     (bigNum)&NIST_P224_a,\n\t\t\t\t\t     (bigNum)&NIST_P224_b,\n\t\t\t\t\t     {(bigNum)&NIST_P224_gX,\n\t\t\t\t\t      (bigNum)&NIST_P224_gY,\n\t\t\t\t\t      (bigNum)&NIST_P224_gZ}};\n#  endif  // ECC_NIST_P224\n\n#  if ECC_NIST_P256\nconst TPMBN_ECC_CURVE_CONSTANTS NIST_P256 = {TPM_ECC_NIST_P256,\n\t\t\t\t\t     (bigNum)&NIST_P256_p,\n\t\t\t\t\t     (bigNum)&NIST_P256_n,\n\t\t\t\t\t     (bigNum)&NIST_P256_h,\n\t\t\t\t\t     (bigNum)&NIST_P256_a,\n\t\t\t\t\t     (bigNum)&NIST_P256_b,\n\t\t\t\t\t     {(bigNum)&NIST_P256_gX,\n\t\t\t\t\t      (bigNum)&NIST_P256_gY,\n\t\t\t\t\t      (bigNum)&NIST_P256_gZ}};\n#  endif  // ECC_NIST_P256\n\n#  if ECC_NIST_P384\nconst TPMBN_ECC_CURVE_CONSTANTS NIST_P384 = {TPM_ECC_NIST_P384,\n\t\t\t\t\t     (bigNum)&NIST_P384_p,\n\t\t\t\t\t     (bigNum)&NIST_P384_n,\n\t\t\t\t\t     (bigNum)&NIST_P384_h,\n\t\t\t\t\t     (bigNum)&NIST_P384_a,\n\t\t\t\t\t     (bigNum)&NIST_P384_b,\n\t\t\t\t\t     {(bigNum)&NIST_P384_gX,\n\t\t\t\t\t      (bigNum)&NIST_P384_gY,\n\t\t\t\t\t      (bigNum)&NIST_P384_gZ}};\n#  endif  // ECC_NIST_P384\n\n#  if ECC_NIST_P521\nconst TPMBN_ECC_CURVE_CONSTANTS NIST_P521 = {TPM_ECC_NIST_P521,\n\t\t\t\t\t     (bigNum)&NIST_P521_p,\n\t\t\t\t\t     (bigNum)&NIST_P521_n,\n\t\t\t\t\t     (bigNum)&NIST_P521_h,\n\t\t\t\t\t     (bigNum)&NIST_P521_a,\n\t\t\t\t\t     (bigNum)&NIST_P521_b,\n\t\t\t\t\t     {(bigNum)&NIST_P521_gX,\n\t\t\t\t\t      (bigNum)&NIST_P521_gY,\n\t\t\t\t\t      (bigNum)&NIST_P521_gZ}};\n#  endif  // ECC_NIST_P521\n\n#  if ECC_BN_P256\nconst TPMBN_ECC_CURVE_CONSTANTS BN_P256 = {TPM_ECC_BN_P256,\n\t\t\t\t\t   (bigNum)&BN_P256_p,\n\t\t\t\t\t   (bigNum)&BN_P256_n,\n\t\t\t\t\t   (bigNum)&BN_P256_h,\n\t\t\t\t\t   (bigNum)&BN_P256_a,\n\t\t\t\t\t   (bigNum)&BN_P256_b,\n\t\t\t\t\t   {(bigNum)&BN_P256_gX,\n\t\t\t\t\t    (bigNum)&BN_P256_gY,\n\t\t\t\t\t    (bigNum)&BN_P256_gZ}};\n#  endif  // ECC_BN_P256\n\n#  if ECC_BN_P638\nconst TPMBN_ECC_CURVE_CONSTANTS BN_P638 = {TPM_ECC_BN_P638,\n\t\t\t\t\t   (bigNum)&BN_P638_p,\n\t\t\t\t\t   (bigNum)&BN_P638_n,\n\t\t\t\t\t   (bigNum)&BN_P638_h,\n\t\t\t\t\t   (bigNum)&BN_P638_a,\n\t\t\t\t\t   (bigNum)&BN_P638_b,\n\t\t\t\t\t   {(bigNum)&BN_P638_gX,\n\t\t\t\t\t    (bigNum)&BN_P638_gY,\n\t\t\t\t\t    (bigNum)&BN_P638_gZ}};\n#  endif  // ECC_BN_P638\n\n#  if ECC_SM2_P256\nconst TPMBN_ECC_CURVE_CONSTANTS SM2_P256 = {TPM_ECC_SM2_P256,\n\t\t\t\t\t    (bigNum)&SM2_P256_p,\n\t\t\t\t\t    (bigNum)&SM2_P256_n,\n\t\t\t\t\t    (bigNum)&SM2_P256_h,\n\t\t\t\t\t    (bigNum)&SM2_P256_a,\n\t\t\t\t\t    (bigNum)&SM2_P256_b,\n\t\t\t\t\t    {(bigNum)&SM2_P256_gX,\n\t\t\t\t\t     (bigNum)&SM2_P256_gY,\n\t\t\t\t\t     (bigNum)&SM2_P256_gZ}};\n#  endif  // ECC_SM2_P256\n\n#  define comma\nconst TPMBN_ECC_CURVE_CONSTANTS* bnEccCurveData[] = {\n#  if ECC_NIST_P192\n    &NIST_P192,\n#  endif\n#  if ECC_NIST_P224\n    &NIST_P224,\n#  endif\n#  if ECC_NIST_P256\n    &NIST_P256,\n#  endif\n#  if ECC_NIST_P384\n    &NIST_P384,\n#  endif\n#  if ECC_NIST_P521\n    &NIST_P521,\n#  endif\n#  if ECC_BN_P256\n    &BN_P256,\n#  endif\n#  if ECC_BN_P638\n    &BN_P638,\n#  endif\n#  if ECC_SM2_P256\n    &SM2_P256,\n#  endif\n};\n\nMUST_BE((sizeof(bnEccCurveData) / sizeof(bnEccCurveData[0])) == (ECC_CURVE_COUNT));\n\n//*** BnGetCurveData()\n// This function returns the pointer for the constant parameter data\n// associated with a curve.\nconst TPMBN_ECC_CURVE_CONSTANTS* BnGetCurveData(TPM_ECC_CURVE curveId)\n{\n    for(int i = 0; i < ECC_CURVE_COUNT; i++)\n\t{\n\t    if(bnEccCurveData[i]->curveId == curveId)\n\t\treturn bnEccCurveData[i];\n\t}\n    return NULL;\n}\n\n#endif  // TPM_ALG_ECC\n"
  },
  {
    "path": "ftpm-opensbi/src/BnMath.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tSimple Operations on Big Numbers     \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// The simulator code uses the canonical form whenever possible in order to make\n// the code in Part 3 more accessible. The canonical data formats are simple and\n// not well suited for complex big number computations. When operating on big\n// numbers, the data format is changed for easier manipulation. The format is native\n// words in little-endian format. As the magnitude of the number decreases, the\n// length of the array containing the number decreases but the starting address\n// doesn't change.\n//\n// The functions in this file perform simple operations on these big numbers. Only\n// the more complex operations are passed to the underlying support library.\n// Although the support library would have most of these functions, the interface\n// code to convert the format for the values is greater than the size of the\n// code to implement the functions here. So, rather than incur the overhead of\n// conversion, they are done here.\n//\n// If an implementer would prefer, the underlying library can be used simply by\n// making code substitutions here.\n//\n// NOTE: There is an intention to continue to augment these functions so that there\n// would be no need to use an external big number library.\n//\n// Many of these functions have no error returns and will always return TRUE. This\n// is to allow them to be used in \"guarded\" sequences. That is:\n//    OK = OK || BnSomething(s);\n// where the BnSomething() function should not be called if OK isn't true.\n\n//** Includes\n#include \"TpmBigNum.h\"\nextern BOOL g_inFailureMode;  // can't use global.h because we can't use tpm.h\n\n// A constant value of zero as a stand in for NULL bigNum values\nconst bignum_t BnConstZero = {1, 0, {0}};\n\n//** Functions\n\n//*** AddSame()\n// Adds two values that are the same size. This function allows 'result' to be\n// the same as either of the addends. This is a nice function to put into assembly\n// because handling the carry for multi-precision stuff is not as easy in C\n// (unless there is a REALLY smart compiler). It would be nice if there were idioms\n// in a language that a compiler could recognize what is going on and optimize\n// loops like this.\n//  Return Type: int\n//      0           no carry out\n//      1           carry out\nstatic BOOL AddSame(crypt_uword_t*       result,\n\t\t    const crypt_uword_t* op1,\n\t\t    const crypt_uword_t* op2,\n\t\t    int                  count)\n{\n    int carry = 0;\n    int i;\n\n    for(i = 0; i < count; i++)\n\t{\n\t    crypt_uword_t a   = op1[i];\n\t    crypt_uword_t sum = a + op2[i];\n\t    result[i]         = sum + carry;\n\t    // generate a carry if the sum is less than either of the inputs\n\t    // propagate a carry if there was a carry and the sum + carry is zero\n\t    // do this using bit operations rather than logical operations so that\n\t    // the time is about the same.\n\t    //             propagate term      | generate term\n\t    carry = ((result[i] == 0) & carry) | (sum < a);\n\t}\n    return carry;\n}\n\n//*** CarryProp()\n// Propagate a carry\nstatic int CarryProp(\n\t\t     crypt_uword_t* result, const crypt_uword_t* op, int count, int carry)\n{\n    for(; count; count--)\n\tcarry = ((*result++ = *op++ + carry) == 0) & carry;\n    return carry;\n}\n\nstatic void CarryResolve(bigNum result, int stop, int carry)\n{\n    if(carry)\n\t{\n\t    pAssert((unsigned)stop < result->allocated);\n\t    result->d[stop++] = 1;\n\t}\n    BnSetTop(result, stop);\n}\n\n//*** BnAdd()\n// This function adds two bigNum values. This function always returns TRUE.\nLIB_EXPORT BOOL BnAdd(bigNum result, bigConst op1, bigConst op2)\n{\n    crypt_uword_t   stop;\n    int             carry;\n    const bignum_t* n1 = op1;\n    const bignum_t* n2 = op2;\n\n    //\n    if(n2->size > n1->size)\n\t{\n\t    n1 = op2;\n\t    n2 = op1;\n\t}\n    pAssert(result->allocated >= n1->size);\n    stop  = MIN(n1->size, n2->allocated);\n    carry = (int)AddSame(result->d, n1->d, n2->d, (int)stop);\n    if(n1->size > stop)\n\tcarry =\n\t    CarryProp(&result->d[stop], &n1->d[stop], (int)(n1->size - stop), carry);\n    CarryResolve(result, (int)n1->size, carry);\n    return TRUE;\n}\n\n//*** BnAddWord()\n// This function adds a word value to a bigNum. This function always returns TRUE.\nLIB_EXPORT BOOL BnAddWord(bigNum result, bigConst op, crypt_uword_t word)\n{\n    int carry;\n    //\n    carry = (result->d[0] = op->d[0] + word) < word;\n    carry = CarryProp(&result->d[1], &op->d[1], (int)(op->size - 1), carry);\n    CarryResolve(result, (int)op->size, carry);\n    return TRUE;\n}\n\n//*** SubSame()\n// This function subtracts two values that have the same size.\nstatic int SubSame(crypt_uword_t*       result,\n\t\t   const crypt_uword_t* op1,\n\t\t   const crypt_uword_t* op2,\n\t\t   int                  count)\n{\n    int borrow = 0;\n    int i;\n    for(i = 0; i < count; i++)\n\t{\n\t    crypt_uword_t a    = op1[i];\n\t    crypt_uword_t diff = a - op2[i];\n\t    result[i]          = diff - borrow;\n\t    //       generate   |      propagate\n\t    borrow = (diff > a) | ((diff == 0) & borrow);\n\t}\n    return borrow;\n}\n\n//*** BorrowProp()\n// This propagates a borrow. If borrow is true when the end\n// of the array is reached, then it means that op2 was larger than\n// op1 and we don't handle that case so an assert is generated.\n// This design choice was made because our only bigNum computations\n// are on large positive numbers (primes) or on fields.\n// Propagate a borrow.\nstatic int BorrowProp(\n\t\t      crypt_uword_t* result, const crypt_uword_t* op, int size, int borrow)\n{\n    for(; size > 0; size--)\n\tborrow = ((*result++ = *op++ - borrow) == MAX_CRYPT_UWORD) && borrow;\n    return borrow;\n}\n\n//*** BnSub()\n// This function does subtraction of two bigNum values and returns result = op1 - op2\n// when op1 is greater than op2. If op2 is greater than op1, then a fault is\n// generated. This function always returns TRUE.\nLIB_EXPORT BOOL BnSub(bigNum result, bigConst op1, bigConst op2)\n{\n    int borrow;\n    int stop = (int)MIN(op1->size, op2->allocated);\n    //\n    // Make sure that op2 is not obviously larger than op1\n    pAssert(op1->size >= op2->size);\n    borrow = SubSame(result->d, op1->d, op2->d, stop);\n    if(op1->size > (crypt_uword_t)stop)\n\tborrow = BorrowProp(\n\t\t\t    &result->d[stop], &op1->d[stop], (int)(op1->size - stop), borrow);\n    pAssert(!borrow);\n    BnSetTop(result, op1->size);\n    return TRUE;\n}\n\n//*** BnSubWord()\n// This function subtracts a word value from a bigNum. This function always\n// returns TRUE.\nLIB_EXPORT BOOL BnSubWord(bigNum result, bigConst op, crypt_uword_t word)\n{\n    int borrow;\n    //\n    pAssert(op->size > 1 || word <= op->d[0]);\n    borrow       = word > op->d[0];\n    result->d[0] = op->d[0] - word;\n    borrow       = BorrowProp(&result->d[1], &op->d[1], (int)(op->size - 1), borrow);\n    pAssert(!borrow);\n    BnSetTop(result, op->size);\n    return TRUE;\n}\n\n//*** BnUnsignedCmp()\n// This function performs a comparison of op1 to op2. The compare is approximately\n// constant time if the size of the values used in the compare is consistent\n// across calls (from the same line in the calling code).\n//  Return Type: int\n//      < 0             op1 is less than op2\n//      0               op1 is equal to op2\n//      > 0             op1 is greater than op2\nLIB_EXPORT int BnUnsignedCmp(bigConst op1, bigConst op2)\n{\n    int retVal;\n    int diff;\n    int i;\n    //\n    pAssert((op1 != NULL) && (op2 != NULL));\n    retVal = (int)(op1->size - op2->size);\n    if(retVal == 0)\n\t{\n\t    for(i = (int)(op1->size - 1); i >= 0; i--)\n\t\t{\n\t\t    diff   = (op1->d[i] < op2->d[i]) ? -1 : (op1->d[i] != op2->d[i]);\n\t\t    retVal = retVal == 0 ? diff : retVal;\n\t\t}\n\t}\n    else\n\tretVal = (retVal < 0) ? -1 : 1;\n    return retVal;\n}\n\n//*** BnUnsignedCmpWord()\n// Compare a bigNum to a crypt_uword_t.\n//  Return Type: int\n//      -1              op1 is less that word\n//      0               op1 is equal to word\n//      1               op1 is greater than word\nLIB_EXPORT int BnUnsignedCmpWord(bigConst op1, crypt_uword_t word)\n{\n    if(op1->size > 1)\n\treturn 1;\n    else if(op1->size == 1)\n\treturn (op1->d[0] < word) ? -1 : (op1->d[0] > word);\n    else  // op1 is zero\n\t// equal if word is zero\n\treturn (word == 0) ? 0 : -1;\n}\n\n//*** BnModWord()\n// This function does modular division of a big number when the modulus is a\n// word value.\nLIB_EXPORT crypt_word_t BnModWord(bigConst numerator, crypt_word_t modulus)\n{\n    BN_MAX(remainder);\n    BN_VAR(mod, RADIX_BITS);\n    //\n    mod->d[0] = modulus;\n    mod->size = (modulus != 0);\n    BnDiv(NULL, remainder, numerator, mod);\n    return remainder->d[0];\n}\n\n//*** Msb()\n// This function returns the bit number of the most significant bit of a\n// crypt_uword_t. The number for the least significant bit of any bigNum value is 0.\n// The maximum return value is RADIX_BITS - 1,\n//  Return Type: int\n//      -1              the word was zero\n//      n               the bit number of the most significant bit in the word\nstatic int Msb(crypt_uword_t word)\n{\n    int retVal = -1;\n    //\n#if RADIX_BITS == 64\n    if(word & 0xffffffff00000000)\n\t{\n\t    retVal += 32;\n\t    word >>= 32;\n\t}\n#endif\n    if(word & 0xffff0000)\n\t{\n\t    retVal += 16;\n\t    word >>= 16;\n\t}\n    if(word & 0x0000ff00)\n\t{\n\t    retVal += 8;\n\t    word >>= 8;\n\t}\n    if(word & 0x000000f0)\n\t{\n\t    retVal += 4;\n\t    word >>= 4;\n\t}\n    if(word & 0x0000000c)\n\t{\n\t    retVal += 2;\n\t    word >>= 2;\n\t}\n    if(word & 0x00000002)\n\t{\n\t    retVal += 1;\n\t    word >>= 1;\n\t}\n    return retVal + (int)word;\n}\n\n//*** BnMsb()\n// This function returns the number of the MSb of a bigNum value.\n//  Return Type: int\n//      -1              the word was zero or 'bn' was NULL\n//      n               the bit number of the most significant bit in the word\nLIB_EXPORT int BnMsb(bigConst bn)\n{\n    // If the value is NULL, or the size is zero then treat as zero and return -1\n    if(bn != NULL && bn->size > 0)\n\t{\n\t    int retVal = Msb(bn->d[bn->size - 1]);\n\t    retVal += (int)(bn->size - 1) * RADIX_BITS;\n\t    return retVal;\n\t}\n    else\n\treturn -1;\n}\n\n//*** BnSizeInBits()\n// This function returns the number of bits required to hold a number. It is one\n// greater than the Msb.\n//\nLIB_EXPORT unsigned BnSizeInBits(bigConst n)\n{\n    int bits = BnMsb(n) + 1;\n    //\n    return bits < 0 ? 0 : (unsigned)bits;\n}\n\n//*** BnSetWord()\n// Change the value of a bignum_t to a word value.\nLIB_EXPORT bigNum BnSetWord(bigNum n, crypt_uword_t w)\n{\n    if(n != NULL)\n\t{\n\t    pAssert(n->allocated > 1);\n\t    n->d[0] = w;\n\t    BnSetTop(n, (w != 0) ? 1 : 0);\n\t}\n    return n;\n}\n\n//*** BnSetBit()\n// This function will SET a bit in a bigNum. Bit 0 is the least-significant bit in\n// the 0th digit_t.  The function will return FALSE if the bitNum is invalid, else TRUE.\nLIB_EXPORT BOOL BnSetBit(bigNum       bn,     // IN/OUT: big number to modify\n\t\t\t unsigned int bitNum  // IN: Bit number to SET\n\t\t\t )\n{\n    crypt_uword_t offset = bitNum / RADIX_BITS;\n    if(bitNum > bn->allocated * RADIX_BITS)\n\t{\n\t    // out of range\n\t    return FALSE;\n\t}\n    // Grow the number if necessary to set the bit.\n    while(bn->size <= offset)\n\tbn->d[bn->size++] = 0;\n    bn->d[offset] |= ((crypt_uword_t)1 << RADIX_MOD(bitNum));\n    return TRUE;\n}\n\n//*** BnTestBit()\n// This function is used to check to see if a bit is SET in a bignum_t. The 0th bit\n// is the LSb of d[0].\n//  Return Type: BOOL\n//      TRUE(1)         the bit is set\n//      FALSE(0)        the bit is not set or the number is out of range\nLIB_EXPORT BOOL BnTestBit(bigNum       bn,     // IN: number to check\n\t\t\t  unsigned int bitNum  // IN: bit to test\n\t\t\t  )\n{\n    crypt_uword_t offset = RADIX_DIV(bitNum);\n    //\n    if(bn->size > offset)\n\treturn ((bn->d[offset] & (((crypt_uword_t)1) << RADIX_MOD(bitNum))) != 0);\n    else\n\treturn FALSE;\n}\n\n//***BnMaskBits()\n// This function is used to mask off high order bits of a big number.\n// The returned value will have no more than 'maskBit' bits\n// set.\n// Note: There is a requirement that unused words of a bignum_t are set to zero.\n//  Return Type: BOOL\n//      TRUE(1)         result masked\n//      FALSE(0)        the input was not as large as the mask\nLIB_EXPORT BOOL BnMaskBits(bigNum        bn,      // IN/OUT: number to mask\n\t\t\t   crypt_uword_t maskBit  // IN: the bit number for the mask.\n\t\t\t   )\n{\n    crypt_uword_t finalSize;\n    BOOL          retVal;\n\n    finalSize = BITS_TO_CRYPT_WORDS(maskBit);\n    retVal    = (finalSize <= bn->allocated);\n    if(retVal && (finalSize > 0))\n\t{\n\t    crypt_uword_t mask;\n\t    mask = ~((crypt_uword_t)0) >> RADIX_MOD(maskBit);\n\t    bn->d[finalSize - 1] &= mask;\n\t}\n    BnSetTop(bn, finalSize);\n    return retVal;\n}\n\n//*** BnShiftRight()\n// This function will shift a bigNum to the right by the shiftAmount.\n// This function always returns TRUE.\nLIB_EXPORT BOOL BnShiftRight(bigNum result, bigConst toShift, uint32_t shiftAmount)\n{\n    uint32_t      offset = (shiftAmount >> RADIX_LOG2);\n    uint32_t      i;\n    uint32_t      shiftIn;\n    crypt_uword_t finalSize;\n    //\n    shiftAmount = shiftAmount & RADIX_MASK;\n    shiftIn     = RADIX_BITS - shiftAmount;\n\n    // The end size is toShift->size - offset less one additional\n    // word if the shiftAmount would make the upper word == 0\n    if(toShift->size > offset)\n\t{\n\t    finalSize = toShift->size - offset;\n\t    finalSize -= (toShift->d[toShift->size - 1] >> shiftAmount) == 0 ? 1 : 0;\n\t}\n    else\n\tfinalSize = 0;\n\n    pAssert(finalSize <= result->allocated);\n    if(finalSize != 0)\n\t{\n\t    for(i = 0; i < finalSize; i++)\n\t\t{\n\t\t    result->d[i] = (toShift->d[i + offset] >> shiftAmount)\n\t\t\t\t   | (toShift->d[i + offset + 1] << shiftIn);\n\t\t}\n\t    if(offset == 0)\n\t\tresult->d[i] = toShift->d[i] >> shiftAmount;\n\t}\n    BnSetTop(result, finalSize);\n    return TRUE;\n}\n\n//*** BnIsPointOnCurve()\n// This function checks if a point is on the curve.\nBOOL BnIsPointOnCurve(pointConst Q, const TPMBN_ECC_CURVE_CONSTANTS* C)\n{\n    BN_VAR(right, (MAX_ECC_KEY_BITS * 3));\n    BN_VAR(left, (MAX_ECC_KEY_BITS * 2));\n    bigConst prime = BnCurveGetPrime(C);\n    //\n    // Show that point is on the curve y^2 = x^3 + ax + b;\n    // Or y^2 = x(x^2 + a) + b\n    // y^2\n    BnMult(left, Q->y, Q->y);\n\n    BnMod(left, prime);\n    // x^2\n    BnMult(right, Q->x, Q->x);\n\n    // x^2 + a\n    BnAdd(right, right, BnCurveGet_a(C));\n\n    //    ExtMath_Mod(right, CurveGetPrime(C));\n    // x(x^2 + a)\n    BnMult(right, right, Q->x);\n\n    // x(x^2 + a) + b\n    BnAdd(right, right, BnCurveGet_b(C));\n\n    BnMod(right, prime);\n    if(BnUnsignedCmp(left, right) == 0)\n\treturn TRUE;\n    else\n\treturn FALSE;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/BnMemory.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: BnMemory.c 1262 2018-07-11 21:03:43Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 10.2.5 BnMemory.c */\n/* 10.2.5.1 Introduction */\n/* This file contains the memory setup functions used by the bigNum functions in CryptoEngine() */\n/* 10.2.5.2 Includes */\n#include \"Tpm.h\"\n/* 10.2.5.3 Functions */\n/* 10.2.5.3.1 BnSetTop() */\n/* This function is used when the size of a bignum_t is changed. It makes sure that the unused words\n   are set to zero and that any significant words of zeros are eliminated from the used size\n   indicator. */\nLIB_EXPORT bigNum\nBnSetTop(\n\t bigNum           bn,        // IN/OUT: number to clean\n\t crypt_uword_t    top        // IN: the new top\n\t )\n{\n    if(bn != NULL)\n\t{\n\t    pAssert(top <= bn->allocated);\n\t    // If forcing the size to be decreased, make sure that the words being\n\t    // discarded are being set to 0\n\t    while(bn->size > top)\n\t\tbn->d[--bn->size] = 0;\n\t    bn->size = top;\n\t    // Now make sure that the words that are left are 'normalized' (no high-order\n\t    // words of zero.\n\t    while((bn->size > 0) && (bn->d[bn->size - 1] == 0))\n\t\tbn->size -= 1;\n\t}\n    return bn;\n}\n/* 10.2.5.3.2 BnClearTop() */\n/* This function will make sure that all unused words are zero. */\nLIB_EXPORT bigNum\nBnClearTop(\n\t   bigNum          bn\n\t   )\n{\n    crypt_uword_t       i;\n    //\n    if(bn != NULL)\n\t{\n\t    for(i = bn->size; i < bn->allocated; i++)\n\t\tbn->d[i] = 0;\n\t    while((bn->size > 0) && (bn->d[bn->size] == 0))\n\t\tbn->size -= 1;\n\t}\n    return bn;\n}\n/* 10.2.5.3.3 BnInitializeWord() */\n/* This function is used to initialize an allocated bigNum with a word value. The bigNum does not\n   have to be allocated with a single word. */\nLIB_EXPORT bigNum\nBnInitializeWord(\n\t\t bigNum          bn,         // IN:\n\t\t crypt_uword_t   allocated,  // IN:\n\t\t crypt_uword_t   word        // IN:\n\t\t )\n{\n    bn->allocated = allocated;\n    bn->size = (word != 0);\n    bn->d[0] = word;\n    while(allocated > 1)\n\tbn->d[--allocated] = 0;\n    return bn;\n}\n/* 10.2.5.3.4 BnInit() */\n/* This function initializes a stack allocated bignum_t. It initializes allocated and size and zeros\n   the words of d. */\nLIB_EXPORT bigNum\nBnInit(\n       bigNum               bn,\n       crypt_uword_t        allocated\n       )\n{\n    if(bn != NULL)\n\t{\n\t    bn->allocated = allocated;\n\t    bn->size = 0;\n\t    while(allocated != 0)\n\t\tbn->d[--allocated] = 0;\n\t}\n    return bn;\n}\n/* 10.2.5.3.5 BnCopy() */\n/* Function to copy a bignum_t. If the output is NULL, then nothing happens. If the input is NULL,\n   the output is set to zero. */\nLIB_EXPORT BOOL\nBnCopy(\n       bigNum           out,\n       bigConst         in\n       )\n{\n    if(in == out)\n\tBnSetTop(out, BnGetSize(out));\n    else if(out != NULL)\n\t{\n\t    if(in != NULL)\n\t\t{\n\t\t    unsigned int         i;\n\t\t    pAssert(BnGetAllocated(out) >= BnGetSize(in));\n\t\t    for(i = 0; i < BnGetSize(in); i++)\n\t\t\tout->d[i] = in->d[i];\n\t\t    BnSetTop(out, BnGetSize(in));\n\t\t}\n\t    else\n\t\tBnSetTop(out, 0);\n\t}\n    return TRUE;\n}\n#if ALG_ECC\n/* 10.2.5.3.6 BnPointCopy() */\n/* Function to copy a bn point. */\nLIB_EXPORT BOOL\nBnPointCopy(\n\t    bigPoint                 pOut,\n\t    pointConst               pIn\n\t    )\n{\n    return BnCopy(pOut->x, pIn->x)\n\t&& BnCopy(pOut->y, pIn->y)\n\t&& BnCopy(pOut->z, pIn->z);\n}\n/* 10.2.5.3.7 BnInitializePoint() */\n/* This function is used to initialize a point structure with the addresses of the coordinates. */\nLIB_EXPORT bn_point_t *\nBnInitializePoint(\n\t\t  bigPoint             p,     // OUT: structure to receive pointers\n\t\t  bigNum               x,     // IN: x coordinate\n\t\t  bigNum               y,     // IN: y coordinate\n\t\t  bigNum               z      // IN: x coordinate\n\t\t  )\n{\n    p->x = x;\n    p->y = y;\n    p->z = z;\n    BnSetWord(z, 1);\n    return p;\n}\n#endif // TPM_ALG_ECC\n"
  },
  {
    "path": "ftpm-opensbi/src/BnToOsslMath.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// The functions in this file provide the low-level interface between the TPM code\n// and the big number and elliptic curve math routines in OpenSSL.\n//\n// Most math on big numbers require a context. The context contains the memory in\n// which OpenSSL creates and manages the big number values. When a OpenSSL math\n// function will be called that modifies a BIGNUM value, that value must be created in\n// an OpenSSL context. The first line of code in such a function must be:\n// OSSL_ENTER(); and the last operation before returning must be OSSL_LEAVE().\n// OpenSSL variables can then be created with BnNewVariable(). Constant values to be\n// used by OpenSSL are created from the bigNum values passed to the functions in this\n// file. Space for the BIGNUM control block is allocated in the stack of the\n// function and then it is initialized by calling BigInitialized(). That function\n// sets up the values in the BIGNUM structure and sets the data pointer to point to\n// the data in the bignum_t. This is only used when the value is known to be a\n// constant in the called function.\n//\n// Because the allocations of constants is on the local stack and the\n// OSSL_ENTER()/OSSL_LEAVE() pair flushes everything created in OpenSSL memory, there\n// should be no chance of a memory leak.\n\n//** Includes and Defines\n//#include \"Tpm.h\"\n#include \"BnOssl.h\"\n\n#ifdef MATH_LIB_OSSL\n#  include \"BnToOsslMath_fp.h\"\n\n//** Functions\n\n//*** OsslToTpmBn()\n// This function converts an OpenSSL BIGNUM to a TPM bigNum. In this implementation\n// it is assumed that OpenSSL uses a different control structure but the same data\n// layout -- an array of native-endian words in little-endian order.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure because value will not fit or OpenSSL variable doesn't\n//                      exist\nBOOL OsslToTpmBn(bigNum bn, BIGNUM* osslBn)\n{\n    GOTO_ERROR_UNLESS(osslBn != NULL);\n    // If the bn is NULL, it means that an output value pointer was NULL meaning that\n    // the results is simply to be discarded.\n    if(bn != NULL)\n\t{\n\t    int i;\n\t    //\n\t    GOTO_ERROR_UNLESS((unsigned)osslBn->top <= BnGetAllocated(bn));\n\t    for(i = 0; i < osslBn->top; i++)\n\t\tbn->d[i] = osslBn->d[i];\n\t    BnSetTop(bn, osslBn->top);\n\t}\n    return TRUE;\n Error:\n    return FALSE;\n}\n\n//*** BigInitialized()\n// This function initializes an OSSL BIGNUM from a TPM bigConst. Do not use this for\n// values that are passed to OpenSLL when they are not declared as const in the\n// function prototype. Instead, use BnNewVariable().\nBIGNUM* BigInitialized(BIGNUM* toInit, bigConst initializer)\n{\n    if(initializer == NULL)\n\tFAIL(FATAL_ERROR_PARAMETER);\n    if(toInit == NULL || initializer == NULL)\n\treturn NULL;\n    toInit->d     = (BN_ULONG*)&initializer->d[0];\n    toInit->dmax  = (int)initializer->allocated;\n    toInit->top   = (int)initializer->size;\n    toInit->neg   = 0;\n    toInit->flags = 0;\n    return toInit;\n}\n\n#  ifndef OSSL_DEBUG\n#    define BIGNUM_PRINT(label, bn, eol)\n#    define DEBUG_PRINT(x)\n#  else\n#    define DEBUG_PRINT(x)               printf(\"%s\", x)\n#    define BIGNUM_PRINT(label, bn, eol) BIGNUM_print((label), (bn), (eol))\n\n//*** BIGNUM_print()\nstatic void BIGNUM_print(const char* label, const BIGNUM* a, BOOL eol)\n{\n    BN_ULONG* d;\n    int       i;\n    int       notZero = FALSE;\n\n    if(label != NULL)\n\tprintf(\"%s\", label);\n    if(a == NULL)\n\t{\n\t    printf(\"NULL\");\n\t    goto done;\n\t}\n    if(a->neg)\n\tprintf(\"-\");\n    for(i = a->top, d = &a->d[i - 1]; i > 0; i--)\n\t{\n\t    int      j;\n\t    BN_ULONG l = *d--;\n\t    for(j = BN_BITS2 - 8; j >= 0; j -= 8)\n\t\t{\n\t\t    BYTE b  = (BYTE)((l >> j) & 0xFF);\n\t\t    notZero = notZero || (b != 0);\n\t\t    if(notZero)\n\t\t\tprintf(\"%02x\", b);\n\t\t}\n\t    if(!notZero)\n\t\tprintf(\"0\");\n\t}\n done:\n    if(eol)\n\tprintf(\"\\n\");\n    return;\n}\n#  endif\n\n//*** BnNewVariable()\n// This function allocates a new variable in the provided context. If the context\n// does not exist or the allocation fails, it is a catastrophic failure.\nstatic BIGNUM* BnNewVariable(BN_CTX* CTX)\n{\n    BIGNUM* new;\n    //\n    // This check is intended to protect against calling this function without\n    // having initialized the CTX.\n    if((CTX == NULL) || ((new = BN_CTX_get(CTX)) == NULL))\n\tFAIL(FATAL_ERROR_ALLOCATION);\n    return new;\n}\n\n#  if LIBRARY_COMPATIBILITY_CHECK\n\n//*** MathLibraryCompatibilityCheck()\nBOOL BnMathLibraryCompatibilityCheck(void)\n{\n    OSSL_ENTER();\n    BIGNUM*       osslTemp = BnNewVariable(CTX);\n    crypt_uword_t i;\n    BYTE test[] = {0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x17, 0x16, 0x15,\n\t\t   0x14, 0x13, 0x12, 0x11, 0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A,\n\t\t   0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};\n    BN_VAR(tpmTemp, sizeof(test) * 8);  // allocate some space for a test value\n    //\n    // Convert the test data to a bigNum\n    BnFromBytes(tpmTemp, test, sizeof(test));\n    // Convert the test data to an OpenSSL BIGNUM\n    BN_bin2bn(test, sizeof(test), osslTemp);\n    // Make sure the values are consistent\n    GOTO_ERROR_UNLESS(osslTemp->top == (int)tpmTemp->size);\n    for(i = 0; i < tpmTemp->size; i++)\n\tGOTO_ERROR_UNLESS(osslTemp->d[i] == tpmTemp->d[i]);\n    OSSL_LEAVE();\n    return 1;\n Error:\n    return 0;\n}\n#  endif\n\n//*** BnModMult()\n// This function does a modular multiply. It first does a multiply and then a divide\n// and returns the remainder of the divide.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation\nLIB_EXPORT BOOL BnModMult(bigNum result, bigConst op1, bigConst op2, bigConst modulus)\n{\n    OSSL_ENTER();\n    BOOL    OK       = TRUE;\n    BIGNUM* bnResult = BN_NEW();\n    BIGNUM* bnTemp   = BN_NEW();\n    BIG_INITIALIZED(bnOp1, op1);\n    BIG_INITIALIZED(bnOp2, op2);\n    BIG_INITIALIZED(bnMod, modulus);\n    //\n    GOTO_ERROR_UNLESS(BN_mul(bnTemp, bnOp1, bnOp2, CTX));\n    GOTO_ERROR_UNLESS(BN_div(NULL, bnResult, bnTemp, bnMod, CTX));\n    GOTO_ERROR_UNLESS(OsslToTpmBn(result, bnResult));\n    goto Exit;\n Error:\n    OK = FALSE;\n Exit:\n    OSSL_LEAVE();\n    return OK;\n}\n\n//*** BnMult()\n// Multiplies two numbers\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation\nLIB_EXPORT BOOL BnMult(bigNum result, bigConst multiplicand, bigConst multiplier)\n{\n    OSSL_ENTER();\n    BIGNUM* bnTemp = BN_NEW();\n    BOOL    OK     = TRUE;\n    BIG_INITIALIZED(bnA, multiplicand);\n    BIG_INITIALIZED(bnB, multiplier);\n    //\n    GOTO_ERROR_UNLESS(BN_mul(bnTemp, bnA, bnB, CTX));\n    GOTO_ERROR_UNLESS(OsslToTpmBn(result, bnTemp));\n    goto Exit;\n Error:\n    OK = FALSE;\n Exit:\n    OSSL_LEAVE();\n    return OK;\n}\n\n//*** BnDiv()\n// This function divides two bigNum values. The function returns FALSE if\n// there is an error in the operation.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation\nLIB_EXPORT BOOL BnDiv(\n\t\t      bigNum quotient, bigNum remainder, bigConst dividend, bigConst divisor)\n{\n    OSSL_ENTER();\n    BIGNUM* bnQ = BN_NEW();\n    BIGNUM* bnR = BN_NEW();\n    BOOL    OK  = TRUE;\n    BIG_INITIALIZED(bnDend, dividend);\n    BIG_INITIALIZED(bnSor, divisor);\n    //\n    if(BnEqualZero(divisor))\n\tFAIL(FATAL_ERROR_DIVIDE_ZERO);\n    GOTO_ERROR_UNLESS(BN_div(bnQ, bnR, bnDend, bnSor, CTX));\n    GOTO_ERROR_UNLESS(OsslToTpmBn(quotient, bnQ));\n    GOTO_ERROR_UNLESS(OsslToTpmBn(remainder, bnR));\n    DEBUG_PRINT(\"In BnDiv:\\n\");\n    BIGNUM_PRINT(\"   bnDividend: \", bnDend, TRUE);\n    BIGNUM_PRINT(\"    bnDivisor: \", bnSor, TRUE);\n    BIGNUM_PRINT(\"   bnQuotient: \", bnQ, TRUE);\n    BIGNUM_PRINT(\"  bnRemainder: \", bnR, TRUE);\n    goto Exit;\n Error:\n    OK = FALSE;\n Exit:\n    OSSL_LEAVE();\n    return OK;\n}\n\n#  if ALG_RSA\n//*** BnGcd()\n// Get the greatest common divisor of two numbers\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation\nLIB_EXPORT BOOL BnGcd(bigNum   gcd,      // OUT: the common divisor\n\t\t      bigConst number1,  // IN:\n\t\t      bigConst number2   // IN:\n\t\t      )\n{\n    OSSL_ENTER();\n    BIGNUM* bnGcd = BN_NEW();\n    BOOL    OK    = TRUE;\n    BIG_INITIALIZED(bn1, number1);\n    BIG_INITIALIZED(bn2, number2);\n    //\n    GOTO_ERROR_UNLESS(BN_gcd(bnGcd, bn1, bn2, CTX));\n    GOTO_ERROR_UNLESS(OsslToTpmBn(gcd, bnGcd));\n    goto Exit;\n Error:\n    OK = FALSE;\n Exit:\n    OSSL_LEAVE();\n    return OK;\n}\n\n//***BnModExp()\n// Do modular exponentiation using bigNum values. The conversion from a bignum_t to\n// a bigNum is trivial as they are based on the same structure\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation\nLIB_EXPORT BOOL BnModExp(bigNum   result,    // OUT: the result\n\t\t\t bigConst number,    // IN: number to exponentiate\n\t\t\t bigConst exponent,  // IN:\n\t\t\t bigConst modulus    // IN:\n\t\t\t )\n{\n    OSSL_ENTER();\n    BIGNUM* bnResult = BN_NEW();\n    BOOL    OK       = TRUE;\n    BIG_INITIALIZED(bnN, number);\n    BIG_INITIALIZED(bnE, exponent);\n    BIG_INITIALIZED(bnM, modulus);\n    //\n    GOTO_ERROR_UNLESS(BN_mod_exp(bnResult, bnN, bnE, bnM, CTX));\n    GOTO_ERROR_UNLESS(OsslToTpmBn(result, bnResult));\n    goto Exit;\n Error:\n    OK = FALSE;\n Exit:\n    OSSL_LEAVE();\n    return OK;\n}\n#  endif  // ALG_RSA\n\n//*** BnModInverse()\n// Modular multiplicative inverse\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation\nLIB_EXPORT BOOL BnModInverse(bigNum result, bigConst number, bigConst modulus)\n{\n    OSSL_ENTER();\n    BIGNUM* bnResult = BN_NEW();\n    BOOL    OK       = TRUE;\n    BIG_INITIALIZED(bnN, number);\n    BIG_INITIALIZED(bnM, modulus);\n    //\n    GOTO_ERROR_UNLESS(BN_mod_inverse(bnResult, bnN, bnM, CTX) != NULL);\n    GOTO_ERROR_UNLESS(OsslToTpmBn(result, bnResult));\n    goto Exit;\n Error:\n    OK = FALSE;\n Exit:\n    OSSL_LEAVE();\n    return OK;\n}\n\n#  if ALG_ECC\n\n//*** PointFromOssl()\n// Function to copy the point result from an OSSL function to a bigNum\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation\nstatic BOOL PointFromOssl(bigPoint            pOut,  // OUT: resulting point\n\t\t\t  EC_POINT*           pIn,   // IN: the point to return\n\t\t\t  const bigCurveData* E      // IN: the curve\n\t\t\t  )\n{\n    BIGNUM* x = NULL;\n    BIGNUM* y = NULL;\n    BOOL    OK;\n    BN_CTX_start(E->CTX);\n    //\n    x = BN_CTX_get(E->CTX);\n    y = BN_CTX_get(E->CTX);\n\n    if(y == NULL)\n\tFAIL(FATAL_ERROR_ALLOCATION);\n    // If this returns false, then the point is at infinity\n    OK = EC_POINT_get_affine_coordinates_GFp(E->G, pIn, x, y, E->CTX);\n    if(OK)\n\t{\n\t    OsslToTpmBn(pOut->x, x);\n\t    OsslToTpmBn(pOut->y, y);\n\t    BnSetWord(pOut->z, 1);\n\t}\n    else\n\tBnSetWord(pOut->z, 0);\n    BN_CTX_end(E->CTX);\n    return OK;\n}\n\n//*** EcPointInitialized()\n// Allocate and initialize a point.\nstatic EC_POINT* EcPointInitialized(pointConst initializer, const bigCurveData* E)\n{\n    EC_POINT* P = NULL;\n\n    if(initializer != NULL)\n\t{\n\t    BIG_INITIALIZED(bnX, initializer->x);\n\t    BIG_INITIALIZED(bnY, initializer->y);\n\t    if(E == NULL)\n\t\tFAIL(FATAL_ERROR_ALLOCATION);\n\t    P = EC_POINT_new(E->G);\n\t    if(!EC_POINT_set_affine_coordinates_GFp(E->G, P, bnX, bnY, E->CTX))\n\t\tP = NULL;\n\t}\n    return P;\n}\n\n//*** BnCurveInitialize()\n// This function initializes the OpenSSL curve information structure. This\n// structure points to the TPM-defined values for the curve, to the context for the\n// number values in the frame, and to the OpenSSL-defined group values.\n//  Return Type: bigCurveData*\n//      NULL        the TPM_ECC_CURVE is not valid or there was a problem in\n//                  in initializing the curve data\n//      non-NULL    points to 'E'\nLIB_EXPORT bigCurveData* BnCurveInitialize(\n\t\t\t\t\t   bigCurveData* E,       // IN: curve structure to initialize\n\t\t\t\t\t   TPM_ECC_CURVE curveId  // IN: curve identifier\n\t\t\t\t\t   )\n{\n    const TPMBN_ECC_CURVE_CONSTANTS* C = BnGetCurveData(curveId);\n    if(C == NULL)\n\tE = NULL;\n    if(E != NULL)\n\t{\n\t    // This creates the OpenSSL memory context that stays in effect as long as the\n\t    // curve (E) is defined.\n\t    OSSL_ENTER();  // if the allocation fails, the TPM fails\n\t    EC_POINT* P = NULL;\n\t    BIG_INITIALIZED(bnP, C->prime);\n\t    BIG_INITIALIZED(bnA, C->a);\n\t    BIG_INITIALIZED(bnB, C->b);\n\t    BIG_INITIALIZED(bnX, C->base.x);\n\t    BIG_INITIALIZED(bnY, C->base.y);\n\t    BIG_INITIALIZED(bnN, C->order);\n\t    BIG_INITIALIZED(bnH, C->h);\n\t    //\n\t    E->C   = C;\n\t    E->CTX = CTX;\n\n\t    // initialize EC group, associate a generator point and initialize the point\n\t    // from the parameter data\n\t    // Create a group structure\n\t    E->G = EC_GROUP_new_curve_GFp(bnP, bnA, bnB, CTX);\n\t    GOTO_ERROR_UNLESS(E->G != NULL);\n\n\t    // Allocate a point in the group that will be used in setting the\n\t    // generator. This is not needed after the generator is set.\n\t    P = EC_POINT_new(E->G);\n\t    GOTO_ERROR_UNLESS(P != NULL);\n\n\t    // Need to use this in case Montgomery method is being used\n\t    GOTO_ERROR_UNLESS(\n\t\t\t      EC_POINT_set_affine_coordinates_GFp(E->G, P, bnX, bnY, CTX));\n\t    // Now set the generator\n\t    GOTO_ERROR_UNLESS(EC_GROUP_set_generator(E->G, P, bnN, bnH));\n\n\t    EC_POINT_free(P);\n\t    goto Exit;\n\tError:\n\t    EC_POINT_free(P);\n\t    BnCurveFree(E);\n\t    E = NULL;\n\t}\n Exit:\n    return E;\n}\n\n//*** BnCurveFree()\n// This function will free the allocated components of the curve and end the\n// frame in which the curve data exists\nLIB_EXPORT void BnCurveFree(bigCurveData* E)\n{\n    if(E)\n\t{\n\t    EC_GROUP_free(E->G);\n\t    OsslContextLeave(E->CTX);\n\t}\n}\n\n//*** BnEccModMult()\n// This function does a point multiply of the form R = [d]S\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation; treat as result being point at infinity\nLIB_EXPORT BOOL BnEccModMult(bigPoint   R,  // OUT: computed point\n\t\t\t     pointConst S,  // IN: point to multiply by 'd' (optional)\n\t\t\t     bigConst   d,  // IN: scalar for [d]S\n\t\t\t     const bigCurveData* E)\n{\n    EC_POINT* pR = EC_POINT_new(E->G);\n    EC_POINT* pS = EcPointInitialized(S, E);\n    BIG_INITIALIZED(bnD, d);\n\n    if(S == NULL)\n\tEC_POINT_mul(E->G, pR, bnD, NULL, NULL, E->CTX);\n    else\n\tEC_POINT_mul(E->G, pR, NULL, pS, bnD, E->CTX);\n    PointFromOssl(R, pR, E);\n    EC_POINT_free(pR);\n    EC_POINT_free(pS);\n    return !BnEqualZero(R->z);\n}\n\n//*** BnEccModMult2()\n// This function does a point multiply of the form R = [d]G + [u]Q\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation; treat as result being point at infinity\nLIB_EXPORT BOOL BnEccModMult2(bigPoint            R,  // OUT: computed point\n\t\t\t      pointConst          S,  // IN: optional point\n\t\t\t      bigConst            d,  // IN: scalar for [d]S or [d]G\n\t\t\t      pointConst          Q,  // IN: second point\n\t\t\t      bigConst            u,  // IN: second scalar\n\t\t\t      const bigCurveData* E   // IN: curve\n\t\t\t      )\n{\n    EC_POINT* pR = EC_POINT_new(E->G);\n    EC_POINT* pS = EcPointInitialized(S, E);\n    BIG_INITIALIZED(bnD, d);\n    EC_POINT* pQ = EcPointInitialized(Q, E);\n    BIG_INITIALIZED(bnU, u);\n\n    if(S == NULL || S == (pointConst) & (AccessCurveConstants(E)->base))\n\tEC_POINT_mul(E->G, pR, bnD, pQ, bnU, E->CTX);\n    else\n\t{\n\t    const EC_POINT* points[2];\n\t    const BIGNUM*   scalars[2];\n\t    points[0]  = pS;\n\t    points[1]  = pQ;\n\t    scalars[0] = bnD;\n\t    scalars[1] = bnU;\n\t    EC_POINTs_mul(E->G, pR, NULL, 2, points, scalars, E->CTX);\n\t}\n    PointFromOssl(R, pR, E);\n    EC_POINT_free(pR);\n    EC_POINT_free(pS);\n    EC_POINT_free(pQ);\n    return !BnEqualZero(R->z);\n}\n\n//** BnEccAdd()\n// This function does addition of two points.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure in operation; treat as result being point at infinity\nLIB_EXPORT BOOL BnEccAdd(bigPoint            R,  // OUT: computed point\n\t\t\t pointConst          S,  // IN: first point to add\n\t\t\t pointConst          Q,  // IN: second point\n\t\t\t const bigCurveData* E   // IN: curve\n\t\t\t )\n{\n    EC_POINT* pR = EC_POINT_new(E->G);\n    EC_POINT* pS = EcPointInitialized(S, E);\n    EC_POINT* pQ = EcPointInitialized(Q, E);\n    //\n    EC_POINT_add(E->G, pR, pS, pQ, E->CTX);\n\n    PointFromOssl(R, pR, E);\n    EC_POINT_free(pR);\n    EC_POINT_free(pS);\n    EC_POINT_free(pQ);\n    return !BnEqualZero(R->z);\n}\n\n#  endif  // ALG_ECC\n\n#endif  // MATHLIB OSSL\n"
  },
  {
    "path": "ftpm-opensbi/src/BnUtil.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// Utility functions to support TpmBigNum library\n\n#include \"TpmBigNum.h\"\n"
  },
  {
    "path": "ftpm-opensbi/src/Cancel.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tSimulates the cancel pins on the TPM.\t \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Cancel.c 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.2 Cancel.c */\n/* C.2.1. Description */\n/* This module simulates the cancel pins on the TPM. */\n/* C.2.2. Includes, Typedefs, Structures, and Defines */\n#include \"Platform.h\"\n/* C.2.3. Functions */\n/* C.2.3.1. _plat__IsCanceled() */\n/* Check if the cancel flag is set */\n/* Return Values Meaning */\n/* TRUE(1) if cancel flag is set */\n/* FALSE(0) if cancel flag is not set */\nLIB_EXPORT int\n_plat__IsCanceled(\n\t\t  void\n\t\t  )\n{\n    // return cancel flag\n    return s_isCanceled;\n}\n/* C.2.3.2. _plat__SetCancel() */\n/* Set cancel flag. */\nLIB_EXPORT void\n_plat__SetCancel(\n\t\t void\n\t\t )\n{\n    s_isCanceled = TRUE;\n    return;\n}\n/* C.2.3.3. _plat__ClearCancel() */\n/* Clear cancel flag */\nLIB_EXPORT void\n_plat__ClearCancel(\n\t\t   void\n\t\t   )\n{\n    s_isCanceled = FALSE;\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/CapabilityCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  \tCapability Commands   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"GetCapability_fp.h\"\n\nextern int verbose;\n\n#if CC_GetCapability  // Conditional expansion of this file\nTPM_RC\nTPM2_GetCapability(\n\t\t   GetCapability_In    *in,            // IN: input parameter list\n\t\t   GetCapability_Out   *out            // OUT: output parameter list\n\t\t   )\n{\n    TPMU_CAPABILITIES   *data = &out->capabilityData.data;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_GetCapability: capability %x\\n\", in->capability);\n\t// fclose(f);\n  //   }\n    // Command Output\n    // Set output capability type the same as input type\n    out->capabilityData.capability = in->capability;\n    switch(in->capability)\n\t{\n\t  case TPM_CAP_ALGS:\n\t    out->moreData = AlgorithmCapGetImplemented((TPM_ALG_ID)in->property,\n\t\t\t\t\t\t       in->propertyCount,\n\t\t\t\t\t\t       &data->algorithms);\n\t    break;\n\t  case TPM_CAP_HANDLES:\n\t    switch(HandleGetType((TPM_HANDLE)in->property))\n\t\t{\n\t\t  case TPM_HT_TRANSIENT:\n\t\t    // Get list of handles of loaded transient objects\n\t\t    out->moreData = ObjectCapGetLoaded((TPM_HANDLE)in->property,\n\t\t\t\t\t\t       in->propertyCount,\n\t\t\t\t\t\t       &data->handles);\n\t\t    break;\n\t\t  case TPM_HT_PERSISTENT:\n\t\t    // Get list of handles of persistent objects\n\t\t    out->moreData = NvCapGetPersistent((TPM_HANDLE)in->property,\n\t\t\t\t\t\t       in->propertyCount,\n\t\t\t\t\t\t       &data->handles);\n\t\t    break;\n\t\t  case TPM_HT_NV_INDEX:\n\t\t    // Get list of defined NV index\n\t\t    out->moreData = NvCapGetIndex((TPM_HANDLE)in->property,\n\t\t\t\t\t\t  in->propertyCount,\n\t\t\t\t\t\t  &data->handles);\n\t\t    break;\n\t\t  case TPM_HT_LOADED_SESSION:\n\t\t    // Get list of handles of loaded sessions\n\t\t    out->moreData = SessionCapGetLoaded((TPM_HANDLE)in->property,\n\t\t\t\t\t\t\tin->propertyCount,\n\t\t\t\t\t\t\t&data->handles);\n\t\t    break;\n#ifdef TPM_HT_SAVED_SESSION\n\t\t  case TPM_HT_SAVED_SESSION:\n#else\n\t\t  case TPM_HT_ACTIVE_SESSION:\n#endif\n\t            // Get list of handles of\n\t\t    out->moreData = SessionCapGetSaved((TPM_HANDLE)in->property,\n\t\t\t\t\t\t       in->propertyCount,\n\t\t\t\t\t\t       &data->handles);\n\t\t    break;\n\t\t  case TPM_HT_PCR:\n\t\t    // Get list of handles of PCR\n\t\t    out->moreData = PCRCapGetHandles((TPM_HANDLE)in->property,\n\t\t\t\t\t\t     in->propertyCount,\n\t\t\t\t\t\t     &data->handles);\n\t\t    break;\n\t\t  case TPM_HT_PERMANENT:\n\t\t    // Get list of permanent handles\n\t\t    out->moreData = PermanentCapGetHandles((TPM_HANDLE)in->property,\n\t\t\t\t\t\t\t   in->propertyCount,\n\t\t\t\t\t\t\t   &data->handles);\n\t\t    break;\n\t\t  default:\n\t\t    // Unsupported input handle type\n\t\t    return TPM_RCS_HANDLE + RC_GetCapability_property;\n\t\t    break;\n\t\t}\n\t    break;\n\t  case TPM_CAP_COMMANDS:\n\t    out->moreData = CommandCapGetCCList((TPM_CC)in->property,\n\t\t\t\t\t\tin->propertyCount,\n\t\t\t\t\t\t&data->command);\n\t    break;\n\t  case TPM_CAP_PP_COMMANDS:\n\t    out->moreData = PhysicalPresenceCapGetCCList((TPM_CC)in->property,\n\t\t\t\t\t\t\t in->propertyCount,\n\t\t\t\t\t\t\t &data->ppCommands);\n\t    break;\n\t  case TPM_CAP_AUDIT_COMMANDS:\n\t    out->moreData = CommandAuditCapGetCCList((TPM_CC)in->property,\n\t\t\t\t\t\t     in->propertyCount,\n\t\t\t\t\t\t     &data->auditCommands);\n\t    break;\n\t  case TPM_CAP_PCRS:\n\t    // Input property must be 0\n\t    if(in->property != 0)\n\t\treturn TPM_RCS_VALUE + RC_GetCapability_property;\n\t    out->moreData = PCRCapGetAllocation(in->propertyCount,\n\t\t\t\t\t\t&data->assignedPCR);\n\t    break;\n\t  case TPM_CAP_PCR_PROPERTIES:\n\t    out->moreData = PCRCapGetProperties((TPM_PT_PCR)in->property,\n\t\t\t\t\t\tin->propertyCount,\n\t\t\t\t\t\t&data->pcrProperties);\n\t    break;\n\t  case TPM_CAP_TPM_PROPERTIES:\n\t    out->moreData = TPMCapGetProperties((TPM_PT)in->property,\n\t\t\t\t\t\tin->propertyCount,\n\t\t\t\t\t\t&data->tpmProperties);\n\t    break;\n#if ALG_ECC\n\t  case TPM_CAP_ECC_CURVES:\n\t    out->moreData = CryptCapGetECCCurve((TPM_ECC_CURVE)in->property,\n\t\t\t\t\t\tin->propertyCount,\n\t\t\t\t\t\t&data->eccCurves);\n\t    break;\n#endif // TPM_ALG_ECC\n\t  case TPM_CAP_AUTH_POLICIES:\n\t    if(HandleGetType((TPM_HANDLE)in->property) != TPM_HT_PERMANENT)\n\t\treturn TPM_RCS_VALUE + RC_GetCapability_property;\n\t    out->moreData = PermanentHandleGetPolicy((TPM_HANDLE)in->property,\n\t\t\t\t\t\t     in->propertyCount,\n\t\t\t\t\t\t     &data->authPolicies);\n\t    break;\n\t  // case TPM_CAP_ACT:\n\t  //   if(((TPM_RH)in->property < TPM_RH_ACT_0)\n\t  //      || ((TPM_RH)in->property > TPM_RH_ACT_F))\n\t\t// return TPM_RCS_VALUE + RC_GetCapability_property;\n\t  //   out->moreData = ActGetCapabilityData((TPM_HANDLE)in->property,\n\t\t// \t\t\t\t in->propertyCount,\n\t\t// \t\t\t\t &data->actData);\n\t  //   break;\n\t  case TPM_CAP_VENDOR_PROPERTY:\n\t    // vendor property is not implemented\n\t  default:\n\t    // Unsupported TPM_CAP value\n\t    return TPM_RCS_VALUE + RC_GetCapability_capability;\n\t    break;\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_GetCapability\n\n#include \"Tpm.h\"\n#include \"TestParms_fp.h\"\n#if CC_TestParms  // Conditional expansion of this file\nTPM_RC\nTPM2_TestParms(\n\t       TestParms_In    *in             // IN: input parameter list\n\t       )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_TestParms:\\n\");\n\t// fclose(f);\n  //   }\n    // Input parameter is not reference in command action\n    NOT_REFERENCED(in);\n    // The parameters are tested at unmarshal process.  We do nothing in command\n    // action\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_TestParms\n\n#include \"Tpm.h\"\n#include \"SetCapability_fp.h\"\n\n#if CC_SetCapability  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// This command allows configuration of the TPM's capabilities.\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_HANDLE       value of 'property' is in an unsupported handle range\n//                          for the TPM_CAP_HANDLES 'capability' value\n//      TPM_RC_VALUE        invalid 'capability'\nTPM_RC\nTPM2_SetCapability(SetCapability_In* in  // IN: input parameter list\n\t\t   )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_SetCapability:\\n\");\n\t// fclose(f);\n  //   }\n    // This reference implementation does not implement any settable capabilities.\n    return TPM_RCS_VALUE + SetCapability_setCapabilityData;\n}\n\n#endif  // CC_SetCapability\n"
  },
  {
    "path": "ftpm-opensbi/src/Clock.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t Used by the simulator to mimic a hardware clock  \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n//\n// This file contains the routines that are used by the simulator to mimic\n// a hardware clock on a TPM.\n//\n// In this implementation, all the time values are measured in millisecond.\n// However, the precision of the clock functions may be implementation dependent.\n\n//** Includes and Data Definitions\n#include <assert.h>\n#include \"Platform.h\"\n#include \"intercept.h\"\n// #include \"umode_clock.h\"\n\n// CLOCK_NOMINAL is the number of hardware ticks per ms. A value of 30000 means\n// that the nominal clock rate used to drive the hardware clock is 30 MHz. The\n// adjustment rates are used to determine the conversion of the hardware ticks to\n// internal hardware clock value. In practice, we would expect that there would be\n// a hardware register will accumulated mS. It would be incremented by the output\n// of a pre-scaler. The pre-scaler would divide the ticks from the clock by some\n// value that would compensate for the difference between clock time and real time.\n// The code in Clock does the emulation of this function.\n#define CLOCK_NOMINAL 30000\n// A 1% change in rate is 300 counts\n#define CLOCK_ADJUST_COARSE 300\n// A 0.1% change in rate is 30 counts\n#define CLOCK_ADJUST_MEDIUM 30\n// A minimum change in rate is 1 count\n#define CLOCK_ADJUST_FINE 1\n// The clock tolerance is +/-15% (4500 counts)\n// Allow some guard band (16.7%)\n#define CLOCK_ADJUST_LIMIT 5000\n\n//** Simulator Functions\n//*** Introduction\n// This set of functions is intended to be called by the simulator environment in\n// order to simulate hardware events.\n\n//***_plat__TimerReset()\n// This function sets current system clock time as t0 for counting TPM time.\n// This function is called at a power on event to reset the clock. When the clock\n// is reset, the indication that the clock was stopped is also set.\nLIB_EXPORT void _plat__TimerReset(void)\n{\n    s_lastSystemTime = 0;\n    s_tpmTime        = 0;\n    s_adjustRate     = CLOCK_NOMINAL;\n    s_timerReset     = TRUE;\n    s_timerStopped   = TRUE;\n    return;\n}\n\n//*** _plat__TimerRestart()\n// This function should be called in order to simulate the restart of the timer\n// should it be stopped while power is still applied.\nLIB_EXPORT void _plat__TimerRestart(void)\n{\n    s_timerStopped = TRUE;\n    return;\n}\n\n//** Functions Used by TPM\n//*** Introduction\n// These functions are called by the TPM code. They should be replaced by\n// appropriated hardware functions.\n\n#include <time.h>\nclock_t debugTime;\n\n//*** _plat__RealTime()\n// This is another, probably futile, attempt to define a portable function\n// that will return a 64-bit clock value that has mSec resolution.\nLIB_EXPORT uint64_t _plat__RealTime(void)\n{\n    clock64_t time;\n#ifdef _MSC_VER\n    struct _timeb sysTime;\n    //\n    _ftime_s(&sysTime);\n    time = (clock64_t)(sysTime.time) * 1000 + sysTime.millitm;\n    // set the time back by one hour if daylight savings\n    if(sysTime.dstflag)\n\ttime -= 1000 * 60 * 60;  // mSec/sec * sec/min * min/hour = ms/hour\n#else\n    // hopefully, this will work with most UNIX systems\n    struct timespec systime;\n    //\n    // clock_gettime(CLOCK_MONOTONIC, &systime);\n    clock_gettime(0, &systime);\n    time = (clock64_t)systime.tv_sec * 1000 + (systime.tv_nsec / 1000000);\n#endif\n    return time;\n}\n\n//***_plat__TimerRead()\n// This function provides access to the tick timer of the platform. The TPM code\n// uses this value to drive the TPM Clock.\n//\n// The tick timer is supposed to run when power is applied to the device. This timer\n// should not be reset by time events including _TPM_Init. It should only be reset\n// when TPM power is re-applied.\n//\n// If the TPM is run in a protected environment, that environment may provide the\n// tick time to the TPM as long as the time provided by the environment is not\n// allowed to go backwards. If the time provided by the system can go backwards\n// during a power discontinuity, then the _plat__Signal_PowerOn should call\n// _plat__TimerReset().\nLIB_EXPORT uint64_t _plat__TimerRead(void)\n{\n#ifdef HARDWARE_CLOCK\n#  error \"need a defintion for reading the hardware clock\"\n    return HARDWARE_CLOCK\n#else\n\tclock64_t timeDiff;\n    clock64_t adjustedTimeDiff;\n    clock64_t timeNow;\n    clock64_t readjustedTimeDiff;\n\n    // This produces a timeNow that is basically locked to the system clock.\n    timeNow = _plat__RealTime();\n\n    // if this hasn't been initialized, initialize it\n    if(s_lastSystemTime == 0)\n\t{\n\t    s_lastSystemTime   = timeNow;\n\t    // debugTime          = clock();\n\t    s_lastReportedTime = 0;\n\t    s_realTimePrevious = 0;\n\t}\n    // The system time can bounce around and that's OK as long as we don't allow\n    // time to go backwards. When the time does appear to go backwards, set\n    // lastSystemTime to be the new value and then update the reported time.\n    if(timeNow < s_lastReportedTime)\n\ts_lastSystemTime = timeNow;\n    s_lastReportedTime = s_lastReportedTime + timeNow - s_lastSystemTime;\n    s_lastSystemTime   = timeNow;\n    timeNow            = s_lastReportedTime;\n\n    // The code above produces a timeNow that is similar to the value returned\n    // by Clock(). The difference is that timeNow does not max out, and it is\n    // at a ms. rate rather than at a CLOCKS_PER_SEC rate. The code below\n    // uses that value and does the rate adjustment on the time value.\n    // If there is no difference in time, then skip all the computations\n    if(s_realTimePrevious >= timeNow)\n\treturn s_tpmTime;\n    // Compute the amount of time since the last update of the system clock\n    timeDiff = timeNow - s_realTimePrevious;\n\n    // Do the time rate adjustment and conversion from CLOCKS_PER_SEC to mSec\n    adjustedTimeDiff = (timeDiff * CLOCK_NOMINAL) / ((uint64_t)s_adjustRate);\n\n    // update the TPM time with the adjusted timeDiff\n    s_tpmTime += (clock64_t)adjustedTimeDiff;\n\n    // Might have some rounding error that would loose CLOCKS. See what is not\n    // being used. As mentioned above, this could result in putting back more than\n    // is taken out. Here, we are trying to recreate timeDiff.\n    readjustedTimeDiff = (adjustedTimeDiff * (uint64_t)s_adjustRate) / CLOCK_NOMINAL;\n\n    // adjusted is now converted back to being the amount we should advance the\n    // previous sampled time. It should always be less than or equal to timeDiff.\n    // That is, we could not have use more time than we started with.\n    s_realTimePrevious = s_realTimePrevious + readjustedTimeDiff;\n\n#  ifdef DEBUGGING_TIME\n    // Put this in so that TPM time will pass much faster than real time when\n    // doing debug.\n    // A value of 1000 for DEBUG_TIME_MULTIPLER will make each ms into a second\n    // A good value might be 100\n    return (s_tpmTime * DEBUG_TIME_MULTIPLIER);\n#  endif\n    return s_tpmTime;\n#endif\n}\n\n//*** _plat__TimerWasReset()\n// This function is used to interrogate the flag indicating if the tick timer has\n// been reset.\n//\n// If the resetFlag parameter is SET, then the flag will be CLEAR before the\n// function returns.\nLIB_EXPORT int _plat__TimerWasReset(void)\n{\n    int retVal   = s_timerReset;\n    s_timerReset = FALSE;\n    return retVal;\n}\n\n//*** _plat__TimerWasStopped()\n// This function is used to interrogate the flag indicating if the tick timer has\n// been stopped. If so, this is typically a reason to roll the nonce.\n//\n// This function will CLEAR the s_timerStopped flag before returning. This provides\n// functionality that is similar to status register that is cleared when read. This\n// is the model used here because it is the one that has the most impact on the TPM\n// code as the flag can only be accessed by one entity in the TPM. Any other\n// implementation of the hardware can be made to look like a read-once register.\nLIB_EXPORT int _plat__TimerWasStopped(void)\n{\n    int retVal     = s_timerStopped;\n    s_timerStopped = FALSE;\n    return retVal;\n}\n\n//***_plat__ClockAdjustRate()\n// Adjust the clock rate\nLIB_EXPORT void _plat__ClockRateAdjust(_plat__ClockAdjustStep adjust)\n{\n    // We expect the caller should only use a fixed set of constant values to\n    // adjust the rate\n    switch(adjust)\n\t{\n\t    // slower increases the divisor\n\t  case PLAT_TPM_CLOCK_ADJUST_COARSE_SLOWER:\n\t    s_adjustRate += CLOCK_ADJUST_COARSE;\n\t    break;\n\t  case PLAT_TPM_CLOCK_ADJUST_MEDIUM_SLOWER:\n\t    s_adjustRate += CLOCK_ADJUST_MEDIUM;\n\t    break;\n\t  case PLAT_TPM_CLOCK_ADJUST_FINE_SLOWER:\n\t    s_adjustRate += CLOCK_ADJUST_FINE;\n\t    break;\n\t    // faster decreases the divisor\n\t  case PLAT_TPM_CLOCK_ADJUST_FINE_FASTER:\n\t    s_adjustRate -= CLOCK_ADJUST_FINE;\n\t    break;\n\t  case PLAT_TPM_CLOCK_ADJUST_MEDIUM_FASTER:\n\t    s_adjustRate -= CLOCK_ADJUST_MEDIUM;\n\t    break;\n\t  case PLAT_TPM_CLOCK_ADJUST_COARSE_FASTER:\n\t    s_adjustRate -= CLOCK_ADJUST_COARSE;\n\t    break;\n\t}\n\n    if(s_adjustRate > (CLOCK_NOMINAL + CLOCK_ADJUST_LIMIT))\n\ts_adjustRate = CLOCK_NOMINAL + CLOCK_ADJUST_LIMIT;\n    if(s_adjustRate < (CLOCK_NOMINAL - CLOCK_ADJUST_LIMIT))\n\ts_adjustRate = CLOCK_NOMINAL - CLOCK_ADJUST_LIMIT;\n\n    return;\n}\n\n#if 0\n\n/* added for portability because Linux clock is 32 bits */\n\n#include <stdint.h>\n#include <stdio.h>\n#include <time.h>\n\n#include \"TpmFail_fp.h\"\n\nLIB_EXPORT uint64_t\n_plat__RealTime(\n\t\tvoid\n\t\t)\n{\n    clock64_t           time;\n    //#ifdef _MSC_VER\tkgold\n#ifdef TPM_WINDOWS\n    #include <sys/timeb.h>\n    struct _timeb       sysTime;\n    //\n    _ftime(&sysTime);\t/* kgold, mingw doesn't have _ftime_s */\n    time = (clock64_t)(sysTime.time) * 1000 + sysTime.millitm;\n    // set the time back by one hour if daylight savings\n    if(sysTime.dstflag)\n\ttime -= 1000 * 60 * 60;  // mSec/sec * sec/min * min/hour = ms/hour\n#else\n    // hopefully, this will work with most UNIX systems\n    struct timespec     systime;\n    //\n    #clock_gettime(CLOCK_MONOTONIC, &systime);\n    umode_clock_gettime(CLOCK_MONOTONIC, &systime);\n    time = (clock64_t)systime.tv_sec * 1000 + (systime.tv_nsec / 1000000);\n#endif\n    return time;\n}\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/src/ClockCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Clocks and Timers\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"ReadClock_fp.h\"\n\nextern int verbose;\n\n#if CC_ReadClock  // Conditional expansion of this file\nTPM_RC\nTPM2_ReadClock(\n\t       ReadClock_Out   *out            // OUT: output parameter list\n\t       )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ReadClock:\\n\");\n\t// fclose(f);\n  //   }\n    // Command Output\n    out->currentTime.time = g_time;\n    TimeFillInfo(&out->currentTime.clockInfo);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_ReadClock\n#include \"Tpm.h\"\n#include \"ClockSet_fp.h\"\n#if CC_ClockSet  // Conditional expansion of this file\nTPM_RC\nTPM2_ClockSet(\n\t      ClockSet_In     *in             // IN: input parameter list\n\t      )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ClockSet: auth %08x\\n\", in->auth);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // new time can not be bigger than 0xFFFF000000000000 or smaller than\n    // current clock\n    if(in->newTime > 0xFFFF000000000000ULL\n       || in->newTime < go.clock)\n\treturn TPM_RCS_VALUE + RC_ClockSet_newTime;\n    // Internal Data Update\n    // Can't modify the clock if NV is not available.\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    TimeClockUpdate(in->newTime);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_ClockSet\n#include \"Tpm.h\"\n#include \"ClockRateAdjust_fp.h\"\n#if CC_ClockRateAdjust  // Conditional expansion of this file\nTPM_RC\nTPM2_ClockRateAdjust(\n\t\t     ClockRateAdjust_In  *in             // IN: input parameter list\n\t\t     )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ClockRateAdjust: auth %08x\\n\", in->auth);\n\t// fclose(f);\n  //   }\n    // Internal Data Update\n    TimeSetAdjustRate(in->rateAdjust);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_ClockRateAdjust\n"
  },
  {
    "path": "ftpm-opensbi/src/CommandAudit.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Functions That Support Command Audit \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the functions that support command audit.\n\n//** Includes\n#include \"Tpm.h\"\n\n//** Functions\n\n//*** CommandAuditPreInstall_Init()\n// This function initializes the command audit list. This function simulates\n// the behavior of manufacturing. A function is used instead of a structure\n// definition because this is easier than figuring out the initialization value\n// for a bit array.\n//\n// This function would not be implemented outside of a manufacturing or\n// simulation environment.\nvoid CommandAuditPreInstall_Init(void)\n{\n    // Clear all the audit commands\n    MemorySet(gp.auditCommands, 0x00, sizeof(gp.auditCommands));\n\n    // TPM_CC_SetCommandCodeAuditStatus always being audited\n    CommandAuditSet(TPM_CC_SetCommandCodeAuditStatus);\n\n    // Set initial command audit hash algorithm to be context integrity hash\n    // algorithm\n    gp.auditHashAlg = CONTEXT_INTEGRITY_HASH_ALG;\n\n    // Set up audit counter to be 0\n    gp.auditCounter = 0;\n\n    // Write command audit persistent data to NV\n    NV_SYNC_PERSISTENT(auditCommands);\n    NV_SYNC_PERSISTENT(auditHashAlg);\n    NV_SYNC_PERSISTENT(auditCounter);\n\n    return;\n}\n\n//*** CommandAuditStartup()\n// This function clears the command audit digest on a TPM Reset.\nBOOL CommandAuditStartup(STARTUP_TYPE type  // IN: start up type\n\t\t\t )\n{\n    if((type != SU_RESTART) && (type != SU_RESUME))\n\t{\n\t    // Reset the digest size to initialize the digest\n\t    gr.commandAuditDigest.t.size = 0;\n\t}\n    return TRUE;\n}\n\n//*** CommandAuditSet()\n// This function will SET the audit flag for a command. This function\n// will not SET the audit flag for a command that is not implemented. This\n// ensures that the audit status is not SET when TPM2_GetCapability() is\n// used to read the list of audited commands.\n//\n// This function is only used by TPM2_SetCommandCodeAuditStatus().\n//\n// The actions in TPM2_SetCommandCodeAuditStatus() are expected to cause the\n// changes to be saved to NV after it is setting and clearing bits.\n//  Return Type: BOOL\n//      TRUE(1)         command code audit status was changed\n//      FALSE(0)        command code audit status was not changed\nBOOL CommandAuditSet(TPM_CC commandCode  // IN: command code\n\t\t     )\n{\n    COMMAND_INDEX commandIndex = CommandCodeToCommandIndex(commandCode);\n\n    // Only SET a bit if the corresponding command is implemented\n    if(commandIndex != UNIMPLEMENTED_COMMAND_INDEX)\n\t{\n\t    // Can't audit shutdown\n\t    if(commandCode != TPM_CC_Shutdown)\n\t\t{\n\t\t    if(!TEST_BIT(commandIndex, gp.auditCommands))\n\t\t\t{\n\t\t\t    // Set bit\n\t\t\t    SET_BIT(commandIndex, gp.auditCommands);\n\t\t\t    return TRUE;\n\t\t\t}\n\t\t}\n\t}\n    // No change\n    return FALSE;\n}\n\n//*** CommandAuditClear()\n// This function will CLEAR the audit flag for a command. It will not CLEAR the\n// audit flag for TPM_CC_SetCommandCodeAuditStatus().\n//\n// This function is only used by TPM2_SetCommandCodeAuditStatus().\n//\n// The actions in TPM2_SetCommandCodeAuditStatus() are expected to cause the\n// changes to be saved to NV after it is setting and clearing bits.\n//  Return Type: BOOL\n//      TRUE(1)         command code audit status was changed\n//      FALSE(0)        command code audit status was not changed\nBOOL CommandAuditClear(TPM_CC commandCode  // IN: command code\n\t\t       )\n{\n    COMMAND_INDEX commandIndex = CommandCodeToCommandIndex(commandCode);\n\n    // Do nothing if the command is not implemented\n    if(commandIndex != UNIMPLEMENTED_COMMAND_INDEX)\n\t{\n\t    // The bit associated with TPM_CC_SetCommandCodeAuditStatus() cannot be\n\t    // cleared\n\t    if(commandCode != TPM_CC_SetCommandCodeAuditStatus)\n\t\t{\n\t\t    if(TEST_BIT(commandIndex, gp.auditCommands))\n\t\t\t{\n\t\t\t    // Clear bit\n\t\t\t    CLEAR_BIT(commandIndex, gp.auditCommands);\n\t\t\t    return TRUE;\n\t\t\t}\n\t\t}\n\t}\n    // No change\n    return FALSE;\n}\n\n//*** CommandAuditIsRequired()\n// This function indicates if the audit flag is SET for a command.\n//  Return Type: BOOL\n//      TRUE(1)         command is audited\n//      FALSE(0)        command is not audited\nBOOL CommandAuditIsRequired(COMMAND_INDEX commandIndex  // IN: command index\n\t\t\t    )\n{\n    // Check the bit map.  If the bit is SET, command audit is required\n    return (TEST_BIT(commandIndex, gp.auditCommands));\n}\n\n//*** CommandAuditCapGetCCList()\n// This function returns a list of commands that have their audit bit SET.\n//\n// The list starts at the input commandCode.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more command code available\n//      NO          all the available command code has been returned\nTPMI_YES_NO\nCommandAuditCapGetCCList(TPM_CC   commandCode,  // IN: start command code\n\t\t\t UINT32   count,        // IN: count of returned TPM_CC\n\t\t\t TPML_CC* commandList   // OUT: list of TPM_CC\n\t\t\t )\n{\n    TPMI_YES_NO   more = NO;\n    COMMAND_INDEX commandIndex;\n\n    // Initialize output handle list\n    commandList->count = 0;\n\n    // The maximum count of command we may return is MAX_CAP_CC\n    if(count > MAX_CAP_CC)\n\tcount = MAX_CAP_CC;\n\n    // Find the implemented command that has a command code that is the same or\n    // higher than the input\n    // Collect audit commands\n    for(commandIndex = GetClosestCommandIndex(commandCode);\n\tcommandIndex != UNIMPLEMENTED_COMMAND_INDEX;\n\tcommandIndex = GetNextCommandIndex(commandIndex))\n\t{\n\t    if(CommandAuditIsRequired(commandIndex))\n\t\t{\n\t\t    if(commandList->count < count)\n\t\t\t{\n\t\t\t    // If we have not filled up the return list, add this command\n\t\t\t    // code to its\n\t\t\t    TPM_CC cc =\n\t\t\t\tGET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex);\n\t\t\t    if(IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V))\n\t\t\t\tcc += (1 << 29);\n\t\t\t    commandList->commandCodes[commandList->count] = cc;\n\t\t\t    commandList->count++;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // If the return list is full but we still have command\n\t\t\t    // available, report this and stop iterating\n\t\t\t    more = YES;\n\t\t\t    break;\n\t\t\t}\n\t\t}\n\t}\n\n    return more;\n}\n\n//*** CommandAuditCapGetOneCC()\n// This function returns true if a command has its audit bit set.\nBOOL CommandAuditCapGetOneCC(TPM_CC commandCode)  // IN: command code\n{\n    COMMAND_INDEX commandIndex = CommandCodeToCommandIndex(commandCode);\n    if(commandIndex != UNIMPLEMENTED_COMMAND_INDEX)\n\t{\n\t    return CommandAuditIsRequired(commandIndex);\n\t}\n    return FALSE;\n}\n\n//*** CommandAuditGetDigest\n// This command is used to create a digest of the commands being audited. The\n// commands are processed in ascending numeric order with a list of TPM_CC being\n// added to a hash. This operates as if all the audited command codes were\n// concatenated and then hashed.\nvoid CommandAuditGetDigest(TPM2B_DIGEST* digest  // OUT: command digest\n\t\t\t   )\n{\n    TPM_CC        commandCode;\n    COMMAND_INDEX commandIndex;\n    HASH_STATE    hashState;\n\n    // Start hash\n    digest->t.size = CryptHashStart(&hashState, gp.auditHashAlg);\n\n    // Add command code\n    for(commandIndex = 0; commandIndex < COMMAND_COUNT; commandIndex++)\n\t{\n\t    if(CommandAuditIsRequired(commandIndex))\n\t\t{\n\t\t    commandCode = GetCommandCode(commandIndex);\n\t\t    CryptDigestUpdateInt(&hashState, sizeof(commandCode), commandCode);\n\t\t}\n\t}\n\n    // Complete hash\n    CryptHashEnd2B(&hashState, &digest->b);\n\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/CommandCodeAttributes.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tFunctions for testing various command properties\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.3 CommandCodeAttributes.c */\n/* 9.3.1 Introduction */\n/* This file contains the functions for testing various command properties. */\n/* 9.3.2 Includes and Defines */\n#include \"Tpm.h\"\n#include \"CommandCodeAttributes_fp.h\"\n/* Set the default value for CC_VEND if not already set */\n#ifndef CC_VEND\n#define     CC_VEND     (TPM_CC)(0x20000000)\n#endif\ntypedef UINT16          ATTRIBUTE_TYPE;\n/* The following file is produced from the command tables in part 3 of the specification. It defines\n   the attributes for each of the commands. */\n/* NOTE: This file is currently produced by an automated process. Files produced from Part 2 or Part\n   3 tables through automated processes are not included in the specification so that there is no\n   ambiguity about the table containing the information being the normative definition. */\n#define _COMMAND_CODE_ATTRIBUTES_\n#include    \"CommandAttributeData.h\"\n/* 9.3.3 Command Attribute Functions */\n/* 9.3.3.1 NextImplementedIndex() */\n/* This function is used when the lists are not compressed. In a compressed list, only the\n   implemented commands are present. So, a search might find a value but that value may not be\n   implemented. This function checks to see if the input commandIndex points to an implemented\n   command and, if not, it searches upwards until it finds one. When the list is compressed, this\n   function gets defined as a no-op. */\n/* Return Value\tMeaning */\n/* UNIMPLEMENTED_COMMAND_INDEX\tcommand is not implemented */\n/* other\tindex of the command */\n\n#if !COMPRESSED_LISTS\nstatic COMMAND_INDEX\nNextImplementedIndex(\n\t\t     COMMAND_INDEX       commandIndex\n\t\t     )\n{\n    for(;commandIndex < COMMAND_COUNT; commandIndex++)\n\t{\n\t    if(s_commandAttributes[commandIndex] & IS_IMPLEMENTED)\n\t\treturn commandIndex;\n\t}\n    return UNIMPLEMENTED_COMMAND_INDEX;\n}\n#else\n#define NextImplementedIndex(x) (x)\n#endif\n/* 9.3.3.2 GetClosestCommandIndex() */\n/* This function returns the command index for the command with a value that is equal to or greater\n   than the input value */\n/* Return Value\tMeaning */\n/* UNIMPLEMENTED_COMMAND_INDEX\tcommand is not implemented */\n/* other\tindex of the command */\n\nCOMMAND_INDEX\nGetClosestCommandIndex(\n\t\t       TPM_CC           commandCode    // IN: the command code to start at\n\t\t       )\n{\n    BOOL                vendor = (commandCode & CC_VEND) != 0;\n    COMMAND_INDEX       searchIndex = (COMMAND_INDEX)commandCode;\n    // The commandCode is a UINT32 and the search index is UINT16. We are going to\n    // search for a match but need to make sure that the commandCode value is not\n    // out of range. To do this, need to clear the vendor bit of the commandCode\n    // (if set) and compare the result to the 16-bit searchIndex value. If it is\n    // out of range, indicate that the command is not implemented\n    if((commandCode & ~CC_VEND) != searchIndex)\n\treturn UNIMPLEMENTED_COMMAND_INDEX;\n    // if there is at least one vendor command, the last entry in the array will\n    // have the v bit set. If the input commandCode is larger than the last\n    // vendor-command, then it is out of range.\n    if(vendor)\n\t{\n#if VENDOR_COMMAND_ARRAY_SIZE > 0\n\t    COMMAND_INDEX       commandIndex;\n\t    COMMAND_INDEX       min;\n\t    COMMAND_INDEX       max;\n\t    int                 diff;\n#if LIBRARY_COMMAND_ARRAY_SIZE == COMMAND_COUNT\n#error \"Constants are not consistent.\"\n#endif\n\t    // Check to see if the value is equal to or below the minimum\n\t    // entry.\n\t    // Note: Put this check first so that the typical case of only one vendor-\n\t    // specific command doesn't waste any more time.\n\t    if(GET_ATTRIBUTE(s_ccAttr[LIBRARY_COMMAND_ARRAY_SIZE], TPMA_CC,\n\t\t\t     commandIndex) >= searchIndex)\n\t\t{\n\t\t    // the vendor array is always assumed to be packed so there is\n\t\t    // no need to check to see if the command is implemented\n\t\t    return LIBRARY_COMMAND_ARRAY_SIZE;\n\t\t}\n\t    // See if this is out of range on the top\n\t    if(GET_ATTRIBUTE(s_ccAttr[COMMAND_COUNT - 1], TPMA_CC, commandIndex)\n\t       < searchIndex)\n\t\t{\n\t\t    return UNIMPLEMENTED_COMMAND_INDEX;\n\t\t}\n\t    commandIndex = UNIMPLEMENTED_COMMAND_INDEX; // Needs initialization to keep\n\t    // compiler happy\n\t    min = LIBRARY_COMMAND_ARRAY_SIZE;       // first vendor command\n\t    max = COMMAND_COUNT - 1;                // last vendor command\n\t    diff = 1;                               // needs initialization to keep\n\t    // compiler happy\n\t    while(min <= max)\n\t\t{\n\t\t    commandIndex = (min + max + 1) / 2;\n\t\t    diff = GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex)\n\t\t\t   - searchIndex;\n\t\t    if(diff == 0)\n\t\t\treturn commandIndex;\n\t\t    if(diff > 0)\n\t\t\tmax = commandIndex - 1;\n\t\t    else\n\t\t\tmin = commandIndex + 1;\n\t\t}\n\t    // didn't find and exact match. commandIndex will be pointing at the last\n\t    // item tested. If 'diff' is positive, then the last item tested was\n\t    // larger index of the command code so it is the smallest value\n\t    // larger than the requested value.\n\t    if(diff > 0)\n\t\treturn commandIndex;\n\t    // if 'diff' is negative, then the value tested was smaller than\n\t    // the commandCode index and the next higher value is the correct one.\n\t    // Note: this will necessarily be in range because of the earlier check\n\t    // that the index was within range.\n\t    return commandIndex + 1;\n#else\n\t    // If there are no vendor commands so anything with the vendor bit set is out\n\t    // of range\n\t    return UNIMPLEMENTED_COMMAND_INDEX;\n#endif\n\t}\n    // Get here if the V-Bit was not set in 'commandCode'\n    if(GET_ATTRIBUTE(s_ccAttr[LIBRARY_COMMAND_ARRAY_SIZE - 1], TPMA_CC,\n\t\t     commandIndex) < searchIndex)\n\t{\n\t    // requested index is out of the range to the top\n#if VENDOR_COMMAND_ARRAY_SIZE > 0\n\t    // If there are vendor commands, then the first vendor command\n\t    // is the next value greater than the commandCode.\n\t    // NOTE: we got here if the starting index did not have the V bit but we\n\t    // reached the end of the array of library commands (non-vendor). Since\n\t    // there is at least one vendor command, and vendor commands are always\n\t    // in a compressed list that starts after the library list, the next\n\t    // index value contains a valid vendor command.\n\t    return LIBRARY_COMMAND_ARRAY_SIZE;\n#else\n\t    // if there are no vendor commands, then this is out of range\n\t    return UNIMPLEMENTED_COMMAND_INDEX;\n#endif\n\t}\n    // If the request is lower than any value in the array, then return\n    // the lowest value (needs to be an index for an implemented command\n    if(GET_ATTRIBUTE(s_ccAttr[0], TPMA_CC, commandIndex) >= searchIndex)\n\t{\n\t    return NextImplementedIndex(0);\n\t}\n    else\n\t{\n#if COMPRESSED_LISTS\n\t    COMMAND_INDEX       commandIndex = UNIMPLEMENTED_COMMAND_INDEX;\n\t    COMMAND_INDEX       min = 0;\n\t    COMMAND_INDEX       max = LIBRARY_COMMAND_ARRAY_SIZE - 1;\n\t    int                 diff = 1;\n#if LIBRARY_COMMAND_ARRAY_SIZE == 0\n#error  \"Something is terribly wrong\"\n#endif\n\t    // The s_ccAttr array contains an extra entry at the end (a zero value).\n\t    // Don't count this as an array entry. This means that max should start\n\t    // out pointing to the last valid entry in the array which is - 2\n\t    pAssert(max == (sizeof(s_ccAttr) / sizeof(TPMA_CC)\n\t\t\t    - VENDOR_COMMAND_ARRAY_SIZE - 2));\n\t    while(min <= max)\n\t\t{\n\t\t    commandIndex = (min + max + 1) / 2;\n\t\t    diff = GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC,\n\t\t\t\t\t commandIndex) - searchIndex;\n\t\t    if(diff == 0)\n\t\t\treturn commandIndex;\n\t\t    if(diff > 0)\n\t\t\tmax = commandIndex - 1;\n\t\t    else\n\t\t\tmin = commandIndex + 1;\n\t\t}\n\t    // didn't find and exact match. commandIndex will be pointing at the\n\t    // last item tested. If diff is positive, then the last item tested was\n\t    // larger index of the command code so it is the smallest value\n\t    // larger than the requested value.\n\t    if(diff > 0)\n\t\treturn commandIndex;\n\t    // if diff is negative, then the value tested was smaller than\n\t    // the commandCode index and the next higher value is the correct one.\n\t    // Note: this will necessarily be in range because of the earlier check\n\t    // that the index was within range.\n\t    return commandIndex + 1;\n#else\n\t    // The list is not compressed so offset into the array by the command\n\t    // code value of the first entry in the list. Then go find the first\n\t    // implemented command.\n\t    return NextImplementedIndex(searchIndex\n\t\t\t\t\t- (COMMAND_INDEX)s_ccAttr[0].commandIndex);\n#endif\n\t}\n}\n/* 9.3.3.3 CommandCodeToComandIndex() */\n/* This function returns the index in the various attributes arrays of the command. */\n/* Return Values Meaning */\n/* UNIMPLEMENTED_COMMAND_INDEX command is not implemented */\n/* other index of the command */\nCOMMAND_INDEX\nCommandCodeToCommandIndex(\n\t\t\t  TPM_CC           commandCode    // IN: the command code to look up\n\t\t\t  )\n{\n    // Extract the low 16-bits of the command code to get the starting search index\n    COMMAND_INDEX       searchIndex = (COMMAND_INDEX)commandCode;\n    BOOL                vendor = (commandCode & CC_VEND) != 0;\n    COMMAND_INDEX       commandIndex;\n#if !COMPRESSED_LISTS\n    if(!vendor)\n\t{\n\t    commandIndex = searchIndex - (COMMAND_INDEX)s_ccAttr[0].commandIndex;\n\t    // Check for out of range or unimplemented.\n\t    // Note, since a COMMAND_INDEX is unsigned, if searchIndex is smaller than\n\t    // the lowest value of command, it will become a 'negative' number making\n\t    // it look like a large unsigned number, this will cause it to fail\n\t    // the unsigned check below.\n\t    if(commandIndex >= LIBRARY_COMMAND_ARRAY_SIZE\n\t       || (s_commandAttributes[commandIndex] & IS_IMPLEMENTED) == 0)\n\t\treturn UNIMPLEMENTED_COMMAND_INDEX;\n\t    return commandIndex;\n\t}\n#endif\n    // Need this code for any vendor code lookup or for compressed lists\n    commandIndex = GetClosestCommandIndex(commandCode);\n    // Look at the returned value from get closest. If it isn't the one that was\n    // requested, then the command is not implemented.\n    if(commandIndex != UNIMPLEMENTED_COMMAND_INDEX)\n\t{\n\t    if((GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex)\n\t\t!= searchIndex)\n\t       || (IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V)) != vendor)\n\t\tcommandIndex = UNIMPLEMENTED_COMMAND_INDEX;\n\t}\n    return commandIndex;\n}\n/* 9.3.3.4 GetNextCommandIndex() */\n/* This function returns the index of the next implemented command. */\n/* Return Values Meaning */\n/* UNIMPLEMENTED_COMMAND_INDEX no more implemented commands */\n/* other the index of the next implemented command */\nCOMMAND_INDEX\nGetNextCommandIndex(\n\t\t    COMMAND_INDEX    commandIndex   // IN: the starting index\n\t\t    )\n{\n    while(++commandIndex < COMMAND_COUNT)\n\t{\n#if !COMPRESSED_LISTS\n\t    if(s_commandAttributes[commandIndex] & IS_IMPLEMENTED)\n#endif\n\t\treturn commandIndex;\n\t}\n    return UNIMPLEMENTED_COMMAND_INDEX;\n}\n/* 9.3.3.5 GetCommandCode() */\n/* This function returns the commandCode associated with the command index */\nTPM_CC\nGetCommandCode(\n\t       COMMAND_INDEX    commandIndex   // IN: the command index\n\t       )\n{\n    TPM_CC           commandCode = GET_ATTRIBUTE(s_ccAttr[commandIndex],\n\t\t\t\t\t\t TPMA_CC, commandIndex);\n    if(IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V))\n\tcommandCode += CC_VEND;\n    return commandCode;\n}\n/* 9.3.3.6 CommandAuthRole() */\n/* This function returns the authorization role required of a handle. */\n/* Return Values Meaning */\n/* AUTH_NONE no authorization is required */\n/* AUTH_USER user role authorization is required */\n/* AUTH_ADMIN admin role authorization is required */\n/* AUTH_DUP duplication role authorization is required */\nAUTH_ROLE\nCommandAuthRole(\n\t\tCOMMAND_INDEX    commandIndex,  // IN: command index\n\t\tUINT32           handleIndex    // IN: handle index (zero based)\n\t\t)\n{\n    if(0 == handleIndex)\n\t{\n\t    // Any authorization role set?\n\t    COMMAND_ATTRIBUTES  properties = s_commandAttributes[commandIndex];\n\t    if(properties & HANDLE_1_USER)\n\t\treturn AUTH_USER;\n\t    if(properties & HANDLE_1_ADMIN)\n\t\treturn AUTH_ADMIN;\n\t    if(properties & HANDLE_1_DUP)\n\t\treturn AUTH_DUP;\n\t}\n    else if(1 == handleIndex)\n\t{\n\t    if(s_commandAttributes[commandIndex] & HANDLE_2_USER)\n\t\treturn AUTH_USER;\n\t}\n    return AUTH_NONE;\n}\n/* 9.3.3.7 EncryptSize() */\n/* This function returns the size of the decrypt size field. This function returns 0 if encryption\n   is not allowed */\n/* Return Values Meaning */\n/* 0 encryption not allowed */\n/* 2 size field is two bytes */\n/* 4 size field is four bytes */\n\nint\nEncryptSize(\n\t    COMMAND_INDEX    commandIndex   // IN: command index\n\t    )\n{\n    return ((s_commandAttributes[commandIndex] & ENCRYPT_2) ? 2 :\n\t    (s_commandAttributes[commandIndex] & ENCRYPT_4) ? 4 : 0);\n}\n\n/* 9.3.3.8 DecryptSize() */\n/* This function returns the size of the decrypt size field. This function returns 0 if decryption\n   is not allowed */\n/* Return Values Meaning */\n/* 0 encryption not allowed */\n/* 2 size field is two bytes */\n/* 4 size field is four bytes */\n\nint\nDecryptSize(\n\t    COMMAND_INDEX    commandIndex   // IN: command index\n\t    )\n{\n    return ((s_commandAttributes[commandIndex] & DECRYPT_2) ? 2 :\n\t    (s_commandAttributes[commandIndex] & DECRYPT_4) ? 4 : 0);\n}\n\n/* 9.3.3.9 IsSessionAllowed() */\n/* This function indicates if the command is allowed to have sessions. */\n/* This function must not be called if the command is not known to be implemented. */\n/* Return Values Meaning */\n/* TRUE session is allowed with this command */\n/* FALSE session is not allowed with this command */\n\nBOOL\nIsSessionAllowed(\n\t\t COMMAND_INDEX    commandIndex   // IN: the command to be checked\n\t\t )\n{\n    return ((s_commandAttributes[commandIndex] & NO_SESSIONS) == 0);\n}\n\n/* 9.3.3.10 IsHandleInResponse() */\n/* This function determines if a command has a handle in the response */\n\nBOOL\nIsHandleInResponse(\n\t\t   COMMAND_INDEX    commandIndex\n\t\t   )\n{\n    return ((s_commandAttributes[commandIndex] & R_HANDLE) != 0);\n}\n\n/* 9.3.3.11 IsWriteOperation() */\n/* Checks to see if an operation will write to an NV Index and is subject to being blocked by\n   read-lock */\nBOOL\nIsWriteOperation(\n\t\t COMMAND_INDEX    commandIndex   // IN: Command to check\n\t\t )\n{\n#ifdef  WRITE_LOCK\n    return ((s_commandAttributes[commandIndex] & WRITE_LOCK) != 0);\n#else\n    if(!IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V))\n\t{\n\t    switch(GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex))\n\t\t{\n\t\t  case TPM_CC_NV_Write:\n#if CC_NV_Increment\n\t\t  case TPM_CC_NV_Increment:\n#endif\n#if CC_NV_SetBits\n\t\t  case TPM_CC_NV_SetBits:\n#endif\n#if CC_NV_Extend\n\t\t  case TPM_CC_NV_Extend:\n#endif\n#if CC_AC_Send\n\t\t  case TPM_CC_AC_Send:\n#endif\n\t\t    // NV write lock counts as a write operation for authorization purposes.\n\t\t    // We check to see if the NV is write locked before we do the\n\t\t    // authorization. If it is locked, we fail the command early.\n\t\t  case TPM_CC_NV_WriteLock:\n\t\t    return TRUE;\n\t\t  default:\n\t\t    break;\n\t\t}\n\t}\n    return FALSE;\n#endif\n}\n/* 9.3.3.12 IsReadOperation() */\n/* Checks to see if an operation will write to an NV Index and is subject to being blocked by\n   write-lock. */\nBOOL\nIsReadOperation(\n\t\tCOMMAND_INDEX    commandIndex   // IN: Command to check\n\t\t)\n{\n#ifdef  READ_LOCK\n    return ((s_commandAttributes[commandIndex] & READ_LOCK) != 0);\n#else\n    if(!IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V))\n\t{\n\t    switch(GET_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, commandIndex))\n\t\t{\n\t\t  case TPM_CC_NV_Read:\n\t\t  case TPM_CC_PolicyNV:\n\t\t  case TPM_CC_NV_Certify:\n\t\t    // NV read lock counts as a read operation for authorization purposes.\n\t\t    // We check to see if the NV is read locked before we do the\n\t\t    // authorization. If it is locked, we fail the command early.\n\t\t  case TPM_CC_NV_ReadLock:\n\t\t    return TRUE;\n\t\t  default:\n\t\t    break;\n\t\t}\n\t}\n    return FALSE;\n#endif\n}\n/* 9.3.3.13 CommandCapGetCCList() */\n/* This function returns a list of implemented commands and command attributes starting from the\n   command in commandCode. */\n/* Return Values Meaning */\n/* YES more command attributes are available */\n/* NO no more command attributes are available */\nTPMI_YES_NO\nCommandCapGetCCList(\n\t\t    TPM_CC           commandCode,   // IN: start command code\n\t\t    UINT32           count,         // IN: maximum count for number of entries in\n\t\t    //     'commandList'\n\t\t    TPML_CCA        *commandList    // OUT: list of TPMA_CC\n\t\t    )\n{\n    TPMI_YES_NO      more = NO;\n    COMMAND_INDEX    commandIndex;\n    // initialize output handle list count\n    commandList->count = 0;\n    for(commandIndex = GetClosestCommandIndex(commandCode);\n\tcommandIndex != UNIMPLEMENTED_COMMAND_INDEX;\n\tcommandIndex = GetNextCommandIndex(commandIndex))\n\t{\n#if !COMPRESSED_LISTS\n\t    // this check isn't needed for compressed lists.\n\t    if(!(s_commandAttributes[commandIndex] & IS_IMPLEMENTED))\n\t\tcontinue;\n#endif\n\t    if(commandList->count < count)\n\t\t{\n\t\t    // If the list is not full, add the attributes for this command.\n\t\t    commandList->commandAttributes[commandList->count]\n\t\t\t= s_ccAttr[commandIndex];\n\t\t    commandList->count++;\n\t\t}\n\t    else\n\t\t{\n\t\t    // If the list is full but there are more commands to report,\n\t\t    // indicate this and return.\n\t\t    more = YES;\n\t\t    break;\n\t\t}\n\t}\n    return more;\n}\n//*** CommandCapGetOneCC()\n// This function checks whether a command is implemented, and returns its\n// attributes if so.\nBOOL CommandCapGetOneCC(TPM_CC   commandCode,       // IN: command code\n\t\t\tTPMA_CC* commandAttributes  // OUT: command attributes\n\t\t\t)\n{\n    COMMAND_INDEX commandIndex = CommandCodeToCommandIndex(commandCode);\n    if(commandIndex != UNIMPLEMENTED_COMMAND_INDEX)\n\t{\n\t    *commandAttributes = s_ccAttr[commandIndex];\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n/* 9.3.3.14 IsVendorCommand() */\n/* Function indicates if a command index references a vendor command. */\n/* Return Values Meaning */\n/* TRUE command is a vendor command */\n/* FALSE command is not a vendor command */\n\nBOOL\nIsVendorCommand(\n\t\tCOMMAND_INDEX    commandIndex   // IN: command index to check\n\t\t)\n{\n    return (IS_ATTRIBUTE(s_ccAttr[commandIndex], TPMA_CC, V));\n}\n\n"
  },
  {
    "path": "ftpm-opensbi/src/CommandDispatcher.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Command Dispatcher\t  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CommandDispatcher.c 1658 2021-01-22 23:14:01Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 6.3 CommandDispatcher.c */\n/* CommandDispatcher() performs the following operations: */\n/* *\tunmarshals command parameters from the input buffer; */\n/* NOTE Unlike other unmarshaling functions, parmBufferStart does not advance.  parmBufferSize Is\n   reduced.  */\n/* *\tinvokes the function that performs the command actions; */\n/* *\tmarshals the returned handles, if any; and */\n/* *\tmarshals the returned parameters, if any, into the output buffer putting in the\n   *\tparameterSize field if authorization sessions are present. */\n/* NOTE 1 The output buffer is the return from the MemoryGetResponseBuffer() function.  It includes\n   the header, handles, response parameters, and authorization area. respParmSize is the response\n   parameter size, and does not include the header, handles, or authorization area. */\n/* NOTE 2 The reference implementation is permitted to do compare operations over a union as a byte\n   array.  Therefore, the command parameter in structure must be initialized (e.g., zeroed) before\n   unmarshaling so that the compare operation is valid in cases where some bytes are unused. */\n/* 6.3.1.1 Includes and Typedefs */\n#include \"Tpm.h\"\n// #include \"Marshal.h\" kgold\n\n#if TABLE_DRIVEN_DISPATCH\ntypedef TPM_RC(NoFlagFunction)(void *target, BYTE **buffer, INT32 *size);\ntypedef TPM_RC(FlagFunction)(void *target, BYTE **buffer, INT32 *size, BOOL flag);\ntypedef FlagFunction *UNMARSHAL_t;\ntypedef INT16(MarshalFunction)(void *source, BYTE **buffer, INT32 *size);\ntypedef MarshalFunction *MARSHAL_t;\ntypedef TPM_RC(COMMAND_NO_ARGS)(void);\ntypedef TPM_RC(COMMAND_IN_ARG)(void *in);\ntypedef TPM_RC(COMMAND_OUT_ARG)(void *out);\ntypedef TPM_RC(COMMAND_INOUT_ARG)(void *in, void *out);\ntypedef union\n{\n    COMMAND_NO_ARGS         *noArgs;\n    COMMAND_IN_ARG          *inArg;\n    COMMAND_OUT_ARG         *outArg;\n    COMMAND_INOUT_ARG       *inOutArg;\n} COMMAND_t;\ntypedef struct\n{\n    COMMAND_t       command;        // Address of the command\n    UINT16          inSize;         // Maximum size of the input structure\n    UINT16          outSize;        // Maximum size of the output structure\n    UINT16          typesOffset;    // address of the types field\n    UINT16          offsets[1];\n} COMMAND_DESCRIPTOR_t;\n#if COMPRESSED_LISTS\n#   define PAD_LIST 0\n#else\n#   define PAD_LIST 1\n#endif\n#define _COMMAND_TABLE_DISPATCH_\n#include \"CommandDispatchData.h\"\n#define TEST_COMMAND    TPM_CC_Startup\n#define NEW_CC\n#else\n#include \"Commands.h\"\n#endif\n\n/* 6.3.1.2   Marshal/Unmarshal Functions */\n/* 6.3.1.2.1 ParseHandleBuffer() */\n/* This is the table-driven version of the handle buffer unmarshaling code */\n\nTPM_RC\nParseHandleBuffer(\n\t\t  COMMAND                 *command\n\t\t  )\n{\n    TPM_RC                   result;\n#if TABLE_DRIVEN_DISPATCH\n    COMMAND_DESCRIPTOR_t    *desc;\n    BYTE                    *types;\n    BYTE                     type;\n    BYTE                     dType;\n    // Make sure that nothing strange has happened\n    pAssert(command->index\n\t    < sizeof(s_CommandDataArray) / sizeof(COMMAND_DESCRIPTOR_t *));\n    // Get the address of the descriptor for this command\n    desc = s_CommandDataArray[command->index];\n    pAssert(desc != NULL);\n    // Get the associated list of unmarshaling data types.\n    types = &((BYTE *)desc)[desc->typesOffset];\n    //    if(s_ccAttr[commandIndex].commandIndex == TEST_COMMAND)\n    //        commandIndex = commandIndex;\n    // No handles yet\n    command->handleNum = 0;\n    // Get the first type value\n    for(type = *types++;\n\t// check each byte to make sure that we have not hit the start\n\t// of the parameters\n\t(dType = (type & 0x7F)) < PARAMETER_FIRST_TYPE;\n\t// get the next type\n\ttype = *types++)\n\t{\n#if TABLE_DRIVEN_MARSHAL\n\tmarshalIndex_t      index;\n    index = unmarshalArray[dType] | ((type & 0x80) ? NULL_FLAG : 0);\n    result = Unmarshal(index, &(command->handles[command->handleNum]),\n\t\t       &command->parameterBuffer, &command->parameterSize);\n    \n#else\n\n\t    // See if unmarshaling of this handle type requires a flag\n\t    if(dType < HANDLE_FIRST_FLAG_TYPE)\n\t\t{\n\t\t    // Look up the function to do the unmarshaling\n\t\t    NoFlagFunction  *f = (NoFlagFunction *)unmarshalArray[dType];\n\t\t    // call it\n\t\t    result = f(&(command->handles[command->handleNum]),\n\t\t\t       &command->parameterBuffer,\n\t\t\t       &command->parameterSize);\n\t\t}\n\t    else\n\t\t{\n\t\t    //  Look up the function\n\t\t    FlagFunction    *f = unmarshalArray[dType];\n\t\t    // Call it setting the flag to the appropriate value\n\t\t    result = f(&(command->handles[command->handleNum]),\n\t\t\t       &command->parameterBuffer,\n\t\t\t       &command->parameterSize, (type & 0x80) != 0);\n\t\t}\n#endif\n\t    // Got a handle\n\t    // We do this first so that the match for the handle offset of the\n\t    // response code works correctly.\n\t    command->handleNum += 1;\n\t    if(result != TPM_RC_SUCCESS)\n\t\t// if the unmarshaling failed, return the response code with the\n\t\t// handle indication set\n\t\treturn result + TPM_RC_H + (command->handleNum * TPM_RC_1);\n\t}\n#else\n    BYTE            **handleBufferStart = &command->parameterBuffer;\n    INT32           *bufferRemainingSize = &command->parameterSize;\n    TPM_HANDLE      *handles = &command->handles[0];\n    UINT32          *handleCount = &command->handleNum;\n    *handleCount = 0;\n    switch(command->code)\n\t{\n#include \"HandleProcess.h\"\n#undef handles\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n#endif\n    return TPM_RC_SUCCESS;\n}\n\n/* 6.3.1.2.2\tCommandDispatcher() */\n/* Function to unmarshal the command parameters, call the selected action code, and marshal the\n   response parameters. */\n\nTPM_RC\nCommandDispatcher(\n\t\t  COMMAND                 *command\n\t\t  )\n{\n#if !TABLE_DRIVEN_DISPATCH\n    TPM_RC       result;\n    BYTE        **paramBuffer = &command->parameterBuffer;\n    INT32       *paramBufferSize = &command->parameterSize;\n    BYTE        **responseBuffer = &command->responseBuffer;\n    INT32       *respParmSize = &command->parameterSize;\n    INT32        rSize;\n    TPM_HANDLE  *handles = &command->handles[0];\n\n    command->handleNum = 0;\t/* The command-specific code knows how many handles there are. This\n\t\t\t\t   is for cataloging the number of response handles */\n    MemoryIoBufferAllocationReset();        /* Initialize so that allocation will work properly */\n    switch(GetCommandCode(command->index))\n\t{\n#include \"CommandDispatcher.h\"\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n Exit:\n    MemoryIoBufferZero();\n    return result;\n#else\n    COMMAND_DESCRIPTOR_t    *desc;\n    BYTE                    *types;\n    BYTE                     type;\n    UINT16                  *offsets;\n    UINT16                   offset = 0;\n    UINT32                   maxInSize;\n    BYTE                    *commandIn;\n    INT32                    maxOutSize;\n    BYTE                    *commandOut;\n    COMMAND_t                cmd;\n    TPM_HANDLE              *handles;\n    UINT32                   hasInParameters = 0;\n    BOOL                     hasOutParameters = FALSE;\n    UINT32                   pNum = 0;\n    BYTE                     dType;     // dispatch type\n    TPM_RC                   result;\n    //\n    // Get the address of the descriptor for this command\n    pAssert(command->index\n\t    < sizeof(s_CommandDataArray) / sizeof(COMMAND_DESCRIPTOR_t *));\n    desc = s_CommandDataArray[command->index];\n    // Get the list of parameter types for this command\n    pAssert(desc != NULL);\n    types = &((BYTE *)desc)[desc->typesOffset];\n    // Get a pointer to the list of parameter offsets\n    offsets = &desc->offsets[0];\n    // pointer to handles\n    handles = command->handles;\n    // Get the size required to hold all the unmarshaled parameters for this command\n    maxInSize = desc->inSize;\n    // and the size of the output parameter structure returned by this command\n    maxOutSize = desc->outSize;\n    MemoryIoBufferAllocationReset();\n    // Get a buffer for the input parameters\n    commandIn = MemoryGetInBuffer(maxInSize);\n    // And the output parameters\n    commandOut = (BYTE *)MemoryGetOutBuffer((UINT32)maxOutSize);\n    // Get the address of the action code dispatch\n    cmd = desc->command;\n    // Copy any handles into the input buffer\n    for(type = *types++; (type & 0x7F) < PARAMETER_FIRST_TYPE; type = *types++)\n\t{\n\t    // 'offset' was initialized to zero so the first unmarshaling will always\n\t    // be to the start of the data structure\n\t    *(TPM_HANDLE *)&(commandIn[offset]) = *handles++;\n\t    // This check is used so that we don't have to add an additional offset\n\t    // value to the offsets list to correspond to the stop value in the\n\t    // command parameter list.\n\t    if(*types != 0xFF)\n\t\toffset = *offsets++;\n\t    //        maxInSize -= sizeof(TPM_HANDLE);\n\t    hasInParameters++;\n\t}\n    // Exit loop with type containing the last value read from types\n    // maxInSize has the amount of space remaining in the command action input\n    // buffer. Make sure that we don't have more data to unmarshal than is going to\n    // fit.\n    // type contains the last value read from types so it is not necessary to\n    // reload it, which is good because *types now points to the next value\n    for(; (dType = (type & 0x7F)) <= PARAMETER_LAST_TYPE; type = *types++)\n\t{\n\t    pNum++;\n#if TABLE_DRIVEN_MARSHAL\n\t    {\n\t\tmarshalIndex_t      index = unmarshalArray[dType];\n\t\tindex |= (type & 0x80) ? NULL_FLAG : 0;\n\t\tresult = Unmarshal(index, &commandIn[offset], &command->parameterBuffer,\n\t\t\t\t   &command->parameterSize);\n\t    }\n#else\n\t    if(dType < PARAMETER_FIRST_FLAG_TYPE)\n\t\t{\n\t\t    NoFlagFunction      *f = (NoFlagFunction *)unmarshalArray[dType];\n\t\t    result = f(&commandIn[offset], &command->parameterBuffer,\n\t\t\t       &command->parameterSize);\n\t\t}\n\t    else\n\t\t{\n\t\t    FlagFunction        *f = unmarshalArray[dType];\n\t\t    result = f(&commandIn[offset], &command->parameterBuffer,\n\t\t\t       &command->parameterSize,\n\t\t\t       (type & 0x80) != 0);\n\t\t}\n#endif\n\t    if(result != TPM_RC_SUCCESS)\n\t\t{\n\t\t    result += TPM_RC_P + (TPM_RC_1 * pNum);\n\t\t    goto Exit;\n\t\t}\n\t    // This check is used so that we don't have to add an additional offset\n\t    // value to the offsets list to correspond to the stop value in the\n\t    // command parameter list.\n\t    if(*types != 0xFF)\n\t\toffset = *offsets++;\n\t    hasInParameters++;\n\t}\n    // Should have used all the bytes in the input\n    if(command->parameterSize != 0)\n\t{\n\t    result = TPM_RC_SIZE;\n\t    goto Exit;\n\t}\n    // The command parameter unmarshaling stopped when it hit a value that was out\n    // of range for unmarshaling values and left *types pointing to the first\n    // marshaling type. If that type happens to be the STOP value, then there\n    // are no response parameters. So, set the flag to indicate if there are\n    // output parameters.\n    hasOutParameters = *types != 0xFF;\n    // There are four cases for calling, with and without input parameters and with\n    // and without output parameters.\n    if(hasInParameters > 0)\n\t{\n\t    if(hasOutParameters)\n\t\tresult = cmd.inOutArg(commandIn, commandOut);\n\t    else\n\t\tresult = cmd.inArg(commandIn);\n\t}\n    else\n\t{\n\t    if(hasOutParameters)\n\t\tresult = cmd.outArg(commandOut);\n\t    else\n\t\tresult = cmd.noArgs();\n\t}\n    if(result != TPM_RC_SUCCESS)\n\tgoto Exit;\n    // Offset in the marshaled output structure\n    offset = 0;\n    // Process the return handles, if any\n    command->handleNum = 0;\n    // Could make this a loop to process output handles but there is only ever\n    // one handle in the outputs (for now).\n    type = *types++;\n    if((dType = (type & 0x7F)) < RESPONSE_PARAMETER_FIRST_TYPE)\n\t{\n\t    // The out->handle value was referenced as TPM_HANDLE in the\n\t    // action code so it has to be properly aligned.\n\t    command->handles[command->handleNum++] =\n\t\t*((TPM_HANDLE *)&(commandOut[offset]));\n\t    maxOutSize -= sizeof(UINT32);\n\t    type = *types++;\n\t    offset = *offsets++;\n\t}\n    // Use the size of the command action output buffer as the maximum for the\n    // number of bytes that can get marshaled. Since the marshaling code has\n    // no pointers to data, all of the data being returned has to be in the\n    // command action output buffer. If we try to marshal more bytes than\n    // could fit into the output buffer, we need to fail.\n    for(;(dType = (type & 0x7F)) <= RESPONSE_PARAMETER_LAST_TYPE\n\t    && !g_inFailureMode; type = *types++)\n\t{\n#if TABLE_DRIVEN_MARSHAL\n\t    marshalIndex_t      index = marshalArray[dType];\n\t    command->parameterSize += Marshal(index, &commandOut[offset],\n\t\t\t\t\t      &command->responseBuffer,\n\t\t\t\t\t      &maxOutSize);\n#else\n\t    const MARSHAL_t     f = marshalArray[dType];\n\t    command->parameterSize += f(&commandOut[offset], &command->responseBuffer,\n\t\t\t\t\t&maxOutSize);\n#endif\n\t    offset = *offsets++;\n\t}\n    result = (maxOutSize < 0) ? TPM_RC_FAILURE : TPM_RC_SUCCESS;\n Exit:\n    MemoryIoBufferZero();\n    return result;\n#endif\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/ContextCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Context Management\t  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\nextern int verbose;\n\n#include \"Tpm.h\"\n\n#if CC_ContextSave  // Conditional expansion of this file\n\n#  include \"ContextSave_fp.h\"\n#  include \"Marshal.h\"\n#  include \"Context_spt_fp.h\"\n\n/*(See part 3 specification)\n  Save context\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_CONTEXT_GAP          a contextID could not be assigned for a session\n//                                  context save\n//      TPM_RC_TOO_MANY_CONTEXTS    no more contexts can be saved as the counter has\n//                                  maxed out\nTPM_RC\nTPM2_ContextSave(ContextSave_In*  in,  // IN: input parameter list\n\t\t ContextSave_Out* out  // OUT: output parameter list\n\t\t )\n{\n    TPM_RC result = TPM_RC_SUCCESS;\n    UINT16 fingerprintSize;  // The size of fingerprint in context\n    // blob.\n    UINT64        contextID = 0;  // session context ID\n    TPM2B_SYM_KEY symKey;\n    TPM2B_IV      iv;\n\n    TPM2B_DIGEST  integrity;\n    UINT16        integritySize;\n    BYTE*         buffer;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ContextSave: %08x\\n\", in->saveHandle);\n\t// fclose(f);\n  //   }\n\n    // This command may cause the orderlyState to be cleared due to\n    // the update of state reset data. If the state is orderly and\n    // cannot be changed, exit early.\n    RETURN_IF_ORDERLY;\n\n    // Internal Data Update\n\n    // This implementation does not do things in quite the same way as described in\n    // Part 2 of the specification. In Part 2, it indicates that the\n    // TPMS_CONTEXT_DATA contains two TPM2B values. That is not how this is\n    // implemented. Rather, the size field of the TPM2B_CONTEXT_DATA is used to\n    // determine the amount of data in the encrypted data. That part is not\n    // independently sized. This makes the actual size 2 bytes smaller than\n    // calculated using Part 2. Since this is opaque to the caller, it is not\n    // necessary to fix. The actual size is returned by TPM2_GetCapabilties().\n\n    // Initialize output handle.  At the end of command action, the output\n    // handle of an object will be replaced, while the output handle\n    // for a session will be the same as input\n    out->context.savedHandle = in->saveHandle;\n\n    // Get the size of fingerprint in context blob.  The sequence value in\n    // TPMS_CONTEXT structure is used as the fingerprint\n    fingerprintSize = sizeof(out->context.sequence);\n\n    // Compute the integrity size at the beginning of context blob\n    integritySize =\n\tsizeof(integrity.t.size) + CryptHashGetDigestSize(CONTEXT_INTEGRITY_HASH_ALG);\n\n    // Perform object or session specific context save\n    switch(HandleGetType(in->saveHandle))\n\t{\n\t  case TPM_HT_TRANSIENT:\n\t      {\n\t\t  OBJECT*            object = HandleToObject(in->saveHandle);\n\t\t  ANY_OBJECT_BUFFER* outObject;\n\t\t  UINT16 objectSize = ObjectIsSequence(object) ? sizeof(HASH_OBJECT)\n\t\t\t\t      : sizeof(OBJECT);\n\n\t\t  outObject         = (ANY_OBJECT_BUFFER*)(out->context.contextBlob.t.buffer\n\t\t\t\t\t\t\t   + integritySize + fingerprintSize);\n\n\t\t  // Set size of the context data.  The contents of context blob is vendor\n\t\t  // defined.  In this implementation, the size is size of integrity\n\t\t  // plus fingerprint plus the whole internal OBJECT structure\n\t\t  out->context.contextBlob.t.size =\n\t\t      integritySize + fingerprintSize + objectSize;\n#  if ALG_RSA\n\t\t  // For an RSA key, make sure that the key has had the private exponent\n\t\t  // computed before saving.\n\t\t  if(object->publicArea.type == TPM_ALG_RSA\n\t\t     && !(object->attributes.publicOnly))\n\t\t      CryptRsaLoadPrivateExponent(&object->publicArea, &object->sensitive);\n#  endif\n\t\t  // Make sure things fit\n\t\t  pAssert(out->context.contextBlob.t.size\n\t\t\t  <= sizeof(out->context.contextBlob.t.buffer));\n\t\t  // Copy the whole internal OBJECT structure to context blob\n\t\t  MemoryCopy(outObject, object, objectSize);\n\n\t\t  // Increment object context ID\n\t\t  gr.objectContextID++;\n\t\t  // If object context ID overflows, TPM should be put in failure mode\n\t\t  if(gr.objectContextID == 0)\n\t\t      FAIL(FATAL_ERROR_INTERNAL);\n\n\t\t  // Fill in other return values for an object.\n\t\t  out->context.sequence = gr.objectContextID;\n\t\t  // For regular object, savedHandle is 0x80000000.  For sequence object,\n\t\t  // savedHandle is 0x80000001.  For object with stClear, savedHandle\n\t\t  // is 0x80000002\n\t\t  if(ObjectIsSequence(object))\n\t\t      {\n\t\t\t  out->context.savedHandle = 0x80000001;\n\t\t\t  SequenceDataExport((HASH_OBJECT*)object,\n\t\t\t\t\t     (HASH_OBJECT_BUFFER*)outObject);\n\t\t      }\n\t\t  else\n\t\t      out->context.savedHandle =\n\t\t\t  (object->attributes.stClear == SET) ? 0x80000002 : 0x80000000;\n\t\t  // Get object hierarchy\n\t\t  out->context.hierarchy = object->hierarchy;\n\n\t\t  break;\n\t      }\n\t  case TPM_HT_HMAC_SESSION:\n\t  case TPM_HT_POLICY_SESSION:\n\t      {\n\t\t  SESSION* session = SessionGet(in->saveHandle);\n\n\t\t  // Set size of the context data.  The contents of context blob is vendor\n\t\t  // defined.  In this implementation, the size of context blob is the\n\t\t  // size of a internal session structure plus the size of\n\t\t  // fingerprint plus the size of integrity\n\t\t  out->context.contextBlob.t.size =\n\t\t      integritySize + fingerprintSize + sizeof(*session);\n\n\t\t  // Make sure things fit\n\t\t  pAssert(out->context.contextBlob.t.size\n\t\t\t  < sizeof(out->context.contextBlob.t.buffer));\n\n\t\t  // Copy the whole internal SESSION structure to context blob.\n\t\t  // Save space for fingerprint at the beginning of the buffer\n\t\t  // This is done before anything else so that the actual context\n\t\t  // can be reclaimed after this call\n\t\t  pAssert(sizeof(*session) <= sizeof(out->context.contextBlob.t.buffer)\n\t\t\t  - integritySize - fingerprintSize);\n\t\t  MemoryCopy(\n\t\t\t     out->context.contextBlob.t.buffer + integritySize + fingerprintSize,\n\t\t\t     session,\n\t\t\t     sizeof(*session));\n\t\t  // Fill in the other return parameters for a session\n\t\t  // Get a context ID and set the session tracking values appropriately\n\t\t  // TPM_RC_CONTEXT_GAP is a possible error.\n\t\t  // SessionContextSave() will flush the in-memory context\n\t\t  // so no additional errors may occur after this call.\n\t\t  result = SessionContextSave(out->context.savedHandle, &contextID);\n\t\t  if(result != TPM_RC_SUCCESS)\n\t\t      return result;\n\t\t  // sequence number is the current session contextID\n\t\t  out->context.sequence = contextID;\n\n\t\t  // use TPM_RH_NULL as hierarchy for session context\n\t\t  out->context.hierarchy = TPM_RH_NULL;\n\n\t\t  break;\n\t      }\n\t  default:\n\t    // SaveContext may only take an object handle or a session handle.\n\t    // All the other handle type should be filtered out at unmarshal\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n\n    // Save fingerprint at the beginning of encrypted area of context blob.\n    // Reserve the integrity space\n    pAssert(sizeof(out->context.sequence)\n\t    <= sizeof(out->context.contextBlob.t.buffer) - integritySize);\n    MemoryCopy(out->context.contextBlob.t.buffer + integritySize,\n\t       &out->context.sequence,\n\t       sizeof(out->context.sequence));\n\n    // Compute context encryption key\n    result = ComputeContextProtectionKey(&out->context, &symKey, &iv);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Encrypt context blob\n    CryptSymmetricEncrypt(out->context.contextBlob.t.buffer + integritySize,\n\t\t\t  CONTEXT_ENCRYPT_ALG,\n\t\t\t  CONTEXT_ENCRYPT_KEY_BITS,\n\t\t\t  symKey.t.buffer,\n\t\t\t  &iv,\n\t\t\t  TPM_ALG_CFB,\n\t\t\t  out->context.contextBlob.t.size - integritySize,\n\t\t\t  out->context.contextBlob.t.buffer + integritySize);\n\n    // Compute integrity hash for the object\n    // In this implementation, the same routine is used for both sessions\n    // and objects.\n    result = ComputeContextIntegrity(&out->context, &integrity);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // add integrity at the beginning of context blob\n    buffer = out->context.contextBlob.t.buffer;\n    TPM2B_DIGEST_Marshal(&integrity, &buffer, NULL);\n\n    // orderly state should be cleared because of the update of state reset and\n    // state clear data\n    g_clearOrderly = TRUE;\n\n    return result;\n}\n\n#endif  // CC_ContextSave\n\n#include \"Tpm.h\"\n\n#if CC_ContextLoad  // Conditional expansion of this file\n\n#  include \"ContextLoad_fp.h\"\n#  include \"Marshal.h\"\n#  include \"Context_spt_fp.h\"\n\n/*(See part 3 specification)\n// Load context\n*/\n\n//  Return Type: TPM_RC\n//      TPM_RC_CONTEXT_GAP          there is only one available slot and this is not\n//                                  the oldest saved session context\n//      TPM_RC_HANDLE               'context.savedHandle' does not reference a saved\n//                                  session\n//      TPM_RC_HIERARCHY            'context.hierarchy' is disabled\n//      TPM_RC_INTEGRITY            'context' integrity check fail\n//      TPM_RC_OBJECT_MEMORY        no free slot for an object\n//      TPM_RC_SESSION_MEMORY       no free session slots\n//      TPM_RC_SIZE                 incorrect context blob size\nTPM_RC\nTPM2_ContextLoad(ContextLoad_In*  in,  // IN: input parameter list\n\t\t ContextLoad_Out* out  // OUT: output parameter list\n\t\t )\n{\n    TPM_RC        result;\n    TPM2B_DIGEST  integrityToCompare;\n    TPM2B_DIGEST  integrity;\n    BYTE*         buffer;  // defined to save some typing\n    INT32         size;    // defined to save some typing\n    TPM_HT        handleType;\n    TPM2B_SYM_KEY symKey;\n    TPM2B_IV      iv;\n\n    // Input Validation\n\n    // See discussion about the context format in TPM2_ContextSave Detailed Actions\n\n    // IF this is a session context, make sure that the sequence number is\n    // consistent with the version in the slot\n\n    // Check context blob size\n    handleType = HandleGetType(in->context.savedHandle);\n\n    // Get integrity from context blob\n    buffer = in->context.contextBlob.t.buffer;\n    size   = (INT32)in->context.contextBlob.t.size;\n    result = TPM2B_DIGEST_Unmarshal(&integrity, &buffer, &size);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // the size of the integrity value has to match the size of digest produced\n    // by the integrity hash\n    if(integrity.t.size != CryptHashGetDigestSize(CONTEXT_INTEGRITY_HASH_ALG))\n\treturn TPM_RCS_SIZE + RC_ContextLoad_context;\n\n    // Make sure that the context blob has enough space for the fingerprint. This\n    // is elastic pants to go with the belt and suspenders we already have to make\n    // sure that the context is complete and untampered.\n    if((unsigned)size < sizeof(in->context.sequence))\n\treturn TPM_RCS_SIZE + RC_ContextLoad_context;\n\n    // After unmarshaling the integrity value, 'buffer' is pointing at the first\n    // byte of the integrity protected and encrypted buffer and 'size' is the number\n    // of integrity protected and encrypted bytes.\n\n    // Compute context integrity\n    result = ComputeContextIntegrity(&in->context, &integrityToCompare);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Compare integrity\n    if(!MemoryEqual2B(&integrity.b, &integrityToCompare.b))\n\treturn TPM_RCS_INTEGRITY + RC_ContextLoad_context;\n    // Compute context encryption key\n    result = ComputeContextProtectionKey(&in->context, &symKey, &iv);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Decrypt context data in place\n    CryptSymmetricDecrypt(buffer,\n\t\t\t  CONTEXT_ENCRYPT_ALG,\n\t\t\t  CONTEXT_ENCRYPT_KEY_BITS,\n\t\t\t  symKey.t.buffer,\n\t\t\t  &iv,\n\t\t\t  TPM_ALG_CFB,\n\t\t\t  size,\n\t\t\t  buffer);\n    // See if the fingerprint value matches. If not, it is symptomatic of either\n    // a broken TPM or that the TPM is under attack so go into failure mode.\n    if(!MemoryEqual(buffer, &in->context.sequence, sizeof(in->context.sequence)))\n\tFAIL(FATAL_ERROR_INTERNAL);\n\n    // step over fingerprint\n    buffer += sizeof(in->context.sequence);\n\n    // set the remaining size of the context\n    size -= sizeof(in->context.sequence);\n\n    // Perform object or session specific input check\n    switch(handleType)\n\t{\n\t  case TPM_HT_TRANSIENT:\n\t      {\n\t\t  OBJECT* outObject;\n\n\t\t  if(size > (INT32)sizeof(OBJECT))\n\t\t      FAIL(FATAL_ERROR_INTERNAL);\n\n\t\t  // Discard any changes to the handle that the TRM might have made\n\t\t  in->context.savedHandle = TRANSIENT_FIRST;\n\n\t\t  // If hierarchy is disabled, no object context can be loaded in this\n\t\t  // hierarchy\n\t\t  if(!HierarchyIsEnabled(in->context.hierarchy))\n\t\t      return TPM_RCS_HIERARCHY + RC_ContextLoad_context;\n\n\t\t  // Restore object. If there is no empty space, indicate as much\n\t\t  outObject =\n\t\t      ObjectContextLoad((ANY_OBJECT_BUFFER*)buffer, &out->loadedHandle);\n\t\t  if(outObject == NULL)\n\t\t      return TPM_RC_OBJECT_MEMORY;\n\n\t\t  break;\n\t      }\n\t  case TPM_HT_POLICY_SESSION:\n\t  case TPM_HT_HMAC_SESSION:\n\t      {\n\t\t  if(size != sizeof(SESSION))\n\t\t      FAIL(FATAL_ERROR_INTERNAL);\n\n\t\t  // This command may cause the orderlyState to be cleared due to\n\t\t  // the update of state reset data.  If this is the case, check if NV is\n\t\t  // available first\n\t\t  RETURN_IF_ORDERLY;\n\n\t\t  // Check if input handle points to a valid saved session and that the\n\t\t  // sequence number makes sense\n\t\t  if(!SequenceNumberForSavedContextIsValid(&in->context))\n\t\t      return TPM_RCS_HANDLE + RC_ContextLoad_context;\n\n\t\t  // Restore session.  A TPM_RC_SESSION_MEMORY, TPM_RC_CONTEXT_GAP error\n\t\t  // may be returned at this point\n\t\t  result =\n\t\t      SessionContextLoad((SESSION_BUF*)buffer, &in->context.savedHandle);\n\t\t  if(result != TPM_RC_SUCCESS)\n\t\t      return result;\n\n\t\t  out->loadedHandle = in->context.savedHandle;\n\n\t\t  // orderly state should be cleared because of the update of state\n\t\t  // reset and state clear data\n\t\t  g_clearOrderly = TRUE;\n\n\t\t  break;\n\t      }\n\t  default:\n\t    // Context blob may only have an object handle or a session handle.\n\t    // All the other handle type should be filtered out at unmarshal\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ContextLoad: %08x\\n\", out->loadedHandle);\n\t// fclose(f);\n  //   }\n    return TPM_RC_SUCCESS;\n}\n\n#endif // CC_ContextLoad\n\n#include \"Tpm.h\"\n#include \"FlushContext_fp.h\"\n#if CC_FlushContext  // Conditional expansion of this file\nTPM_RC\nTPM2_FlushContext(\n\t\t  FlushContext_In     *in             // IN: input parameter list\n\t\t  )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_FlushContext: %08x\\n\", in->flushHandle);\n\t// fclose(f);\n  //   }\n    // Internal Data Update\n    // Call object or session specific routine to flush\n    switch(HandleGetType(in->flushHandle))\n\t{\n\t  case TPM_HT_TRANSIENT:\n\t    if(!IsObjectPresent(in->flushHandle))\n\t\treturn TPM_RCS_HANDLE + RC_FlushContext_flushHandle;\n\t    // Flush object\n\t    FlushObject(in->flushHandle);\n\t    break;\n\t  case TPM_HT_HMAC_SESSION:\n\t  case TPM_HT_POLICY_SESSION:\n\t    if(!SessionIsLoaded(in->flushHandle)\n\t       && !SessionIsSaved(in->flushHandle)\n\t       )\n\t\treturn TPM_RCS_HANDLE + RC_FlushContext_flushHandle;\n\t    // If the session to be flushed is the exclusive audit session, then\n\t    // indicate that there is no exclusive audit session any longer.\n\t    if(in->flushHandle == g_exclusiveAuditSession)\n\t\tg_exclusiveAuditSession = TPM_RH_UNASSIGNED;\n\t    // Flush session\n\t    SessionFlush(in->flushHandle);\n\t    break;\n\t  default:\n\t    // This command only takes object or session handle.  Other handles\n\t    // should be filtered out at handle unmarshal\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_FlushContext\n\n#include \"Tpm.h\"\n#include \"EvictControl_fp.h\"\n\n#if CC_EvictControl  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Make a transient object persistent or evict a persistent object\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES   an object with 'temporary', 'stClear' or 'publicOnly'\n//                          attribute SET cannot be made persistent\n//      TPM_RC_HIERARCHY    'auth' cannot authorize the operation in the hierarchy\n//                          of 'evictObject';\n//                          an object in a firmware-bound or SVN-bound hierarchy\n//                          cannot be made persistent.\n//      TPM_RC_HANDLE       'evictHandle' of the persistent object to be evicted is\n//                          not the same as the 'persistentHandle' argument\n//      TPM_RC_NV_HANDLE    'persistentHandle' is unavailable\n//      TPM_RC_NV_SPACE     no space in NV to make 'evictHandle' persistent\n//      TPM_RC_RANGE        'persistentHandle' is not in the range corresponding to\n//                          the hierarchy of 'evictObject'\nTPM_RC\nTPM2_EvictControl(EvictControl_In* in  // IN: input parameter list\n\t\t  )\n{\n    TPM_RC  result;\n    OBJECT* evictObject;\n\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"EvictControl: persistentHandle %08x\\n\", in->persistentHandle);\n\t// fprintf(f, \"EvictControl: objectHandle %08x\\n\", in->objectHandle);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n\n    // Get internal object pointer\n    evictObject = HandleToObject(in->objectHandle);\n\n    // Objects in a firmware-limited or SVN-limited hierarchy cannot be made\n    // persistent.\n    if(HierarchyIsFirmwareLimited(evictObject->hierarchy)\n       || HierarchyIsSvnLimited(evictObject->hierarchy))\n\treturn TPM_RCS_HIERARCHY + RC_EvictControl_objectHandle;\n\n    // Temporary, stClear or public only objects can not be made persistent\n    if(evictObject->attributes.temporary == SET\n       || evictObject->attributes.stClear == SET\n       || evictObject->attributes.publicOnly == SET)\n\treturn TPM_RCS_ATTRIBUTES + RC_EvictControl_objectHandle;\n\n    // If objectHandle refers to a persistent object, it should be the same as\n    // input persistentHandle\n    if(evictObject->attributes.evict == SET\n       && evictObject->evictHandle != in->persistentHandle)\n\treturn TPM_RCS_HANDLE + RC_EvictControl_objectHandle;\n\n    // Additional authorization validation\n    if(in->auth == TPM_RH_PLATFORM)\n\t{\n\t    // To make persistent\n\t    if(evictObject->attributes.evict == CLEAR)\n\t\t{\n\t\t    // PlatformAuth can not set evict object in storage or endorsement\n\t\t    // hierarchy\n\t\t    if(evictObject->attributes.ppsHierarchy == CLEAR)\n\t\t\treturn TPM_RCS_HIERARCHY + RC_EvictControl_objectHandle;\n\t\t    // Platform cannot use a handle outside of platform persistent range.\n\t\t    if(!NvIsPlatformPersistentHandle(in->persistentHandle))\n\t\t\treturn TPM_RCS_RANGE + RC_EvictControl_persistentHandle;\n\t\t}\n\t    // PlatformAuth can delete any persistent object\n\t}\n    else if(in->auth == TPM_RH_OWNER)\n\t{\n\t    // OwnerAuth can not set or clear evict object in platform hierarchy\n\t    if(evictObject->attributes.ppsHierarchy == SET)\n\t\treturn TPM_RCS_HIERARCHY + RC_EvictControl_objectHandle;\n\n\t    // Owner cannot use a handle outside of owner persistent range.\n\t    if(evictObject->attributes.evict == CLEAR\n\t       && !NvIsOwnerPersistentHandle(in->persistentHandle))\n\t\treturn TPM_RCS_RANGE + RC_EvictControl_persistentHandle;\n\t}\n    else\n\t{\n\t    // Other authorization is not allowed in this command and should have been\n\t    // filtered out in unmarshal process\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t}\n    // Internal Data Update\n    // Change evict state\n    if(evictObject->attributes.evict == CLEAR)\n\t{\n\t    // Make object persistent\n\t    if(NvFindHandle(in->persistentHandle) != 0)\n\t\treturn TPM_RC_NV_DEFINED;\n\t    // A TPM_RC_NV_HANDLE or TPM_RC_NV_SPACE error may be returned at this\n\t    // point\n\t    result = NvAddEvictObject(in->persistentHandle, evictObject);\n\t}\n    else\n\t{\n\t    // Delete the persistent object in NV\n\t    result = NvDeleteEvict(evictObject->evictHandle);\n\t}\n    return result;\n}\n\n#endif  // CC_EvictControl\n"
  },
  {
    "path": "ftpm-opensbi/src/Context_spt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tContext Management Command Support   \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes\n\n#include \"Tpm.h\"\n#include \"Context_spt_fp.h\"\n\n//** Functions\n\n//*** ComputeContextProtectionKey()\n// This function retrieves the symmetric protection key for context encryption\n// It is used by TPM2_ConextSave and TPM2_ContextLoad to create the symmetric\n// encryption key and iv\n/*(See part 1 specification)\n  KDFa is used to generate the symmetric encryption key and IV. The parameters\n  of the call are:\n  Symkey = KDFa(hashAlg, hProof, vendorString, sequence, handle, bits)\n  where\n  hashAlg         a vendor-defined hash algorithm\n  hProof          the hierarchy proof as selected by the hierarchy parameter\n  of the TPMS_CONTEXT\n  vendorString    a value used to differentiate the uses of the KDF\n  sequence        the sequence parameter of the TPMS_CONTEXT\n  handle          the handle parameter of the TPMS_CONTEXT\n  bits            the number of bits needed for a symmetric key and IV for\n  the context encryption\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects or the TPM failed\n//                              to derive the Firmware Secret.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the TPM\n//                              failed to derive the Firmware SVN Secret for the\n//                              requested SVN.\nTPM_RC ComputeContextProtectionKey(TPMS_CONTEXT*  contextBlob,  // IN: context blob\n\t\t\t\t   TPM2B_SYM_KEY* symKey,  // OUT: the symmetric key\n\t\t\t\t   TPM2B_IV*      iv       // OUT: the IV.\n\t\t\t\t   )\n{\n    TPM_RC result = TPM_RC_SUCCESS;\n    UINT16 symKeyBits;  // number of bits in the parent's\n    //   symmetric key\n    TPM2B_PROOF proof;  // the proof value to use\n\n    BYTE        kdfResult[sizeof(TPMU_HA) * 2];  // Value produced by the KDF\n\n    TPM2B_DATA  sequence2B, handle2B;\n\n    // Get sequence value in 2B format\n    sequence2B.t.size = sizeof(contextBlob->sequence);\n    MUST_BE(sizeof(contextBlob->sequence) <= sizeof(sequence2B.t.buffer));\n    MemoryCopy(sequence2B.t.buffer, &contextBlob->sequence, sequence2B.t.size);\n\n    // Get handle value in 2B format\n    handle2B.t.size = sizeof(contextBlob->savedHandle);\n    MUST_BE(sizeof(contextBlob->savedHandle) <= sizeof(handle2B.t.buffer));\n    MemoryCopy(handle2B.t.buffer, &contextBlob->savedHandle, handle2B.t.size);\n\n    // Get the symmetric encryption key size\n    symKey->t.size = CONTEXT_ENCRYPT_KEY_BYTES;\n    symKeyBits     = CONTEXT_ENCRYPT_KEY_BITS;\n    // Get the size of the IV for the algorithm\n    iv->t.size = CryptGetSymmetricBlockSize(CONTEXT_ENCRYPT_ALG, symKeyBits);\n\n    // Get proof value\n    result = HierarchyGetProof(contextBlob->hierarchy, &proof);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // KDFa to generate symmetric key and IV value\n    CryptKDFa(CONTEXT_INTEGRITY_HASH_ALG,\n\t      &proof.b,\n\t      CONTEXT_KEY,\n\t      &sequence2B.b,\n\t      &handle2B.b,\n\t      (symKey->t.size + iv->t.size) * 8,\n\t      kdfResult,\n\t      NULL,\n\t      FALSE);\n\n    MemorySet(proof.b.buffer, 0, proof.b.size);\n\n    // Copy part of the returned value as the key\n    pAssert(symKey->t.size <= sizeof(symKey->t.buffer));\n    MemoryCopy(symKey->t.buffer, kdfResult, symKey->t.size);\n\n    // Copy the rest as the IV\n    pAssert(iv->t.size <= sizeof(iv->t.buffer));\n    MemoryCopy(iv->t.buffer, &kdfResult[symKey->t.size], iv->t.size);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** ComputeContextIntegrity()\n// Generate the integrity hash for a context\n//       It is used by TPM2_ContextSave to create an integrity hash\n//       and by TPM2_ContextLoad to compare an integrity hash\n/*(See part 1 specification)\n  The HMAC integrity computation for a saved context is:\n  HMACvendorAlg(hProof, resetValue {|| clearCount} || sequence || handle ||\n  encContext)\n  where\n  HMACvendorAlg       HMAC using a vendor-defined hash algorithm\n  hProof              the hierarchy proof as selected by the hierarchy\n  parameter of the TPMS_CONTEXT\n  resetValue          either a counter value that increments on each TPM Reset\n  and is not reset over the lifetime of the TPM or a random\n  value that changes on each TPM Reset and has the size of\n  the digest produced by vendorAlg\n  clearCount          a counter value that is incremented on each TPM Reset\n  or TPM Restart. This value is only included if the handle\n  value is 0x80000002.\n  sequence            the sequence parameter of the TPMS_CONTEXT\n  handle              the handle parameter of the TPMS_CONTEXT\n  encContext          the encrypted context blob\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects or the TPM failed\n//                              to derive the Firmware Secret.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the TPM\n//                              failed to derive the Firmware SVN Secret for the\n//                              requested SVN.\nTPM_RC ComputeContextIntegrity(TPMS_CONTEXT* contextBlob,  // IN: context blob\n\t\t\t       TPM2B_DIGEST* integrity     // OUT: integrity\n\t\t\t       )\n{\n    TPM_RC      result = TPM_RC_SUCCESS;\n    HMAC_STATE  hmacState;\n    TPM2B_PROOF proof;\n    UINT16      integritySize;\n\n    // Get proof value\n    result = HierarchyGetProof(contextBlob->hierarchy, &proof);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Start HMAC\n    integrity->t.size =\n\tCryptHmacStart2B(&hmacState, CONTEXT_INTEGRITY_HASH_ALG, &proof.b);\n\n    MemorySet(proof.b.buffer, 0, proof.b.size);\n\n    // Compute integrity size at the beginning of context blob\n    integritySize = sizeof(integrity->t.size) + integrity->t.size;\n\n    // Adding total reset counter so that the context cannot be\n    // used after a TPM Reset\n    CryptDigestUpdateInt(\n\t\t\t &hmacState.hashState, sizeof(gp.totalResetCount), gp.totalResetCount);\n\n    // If this is a ST_CLEAR object, add the clear count\n    // so that this contest cannot be loaded after a TPM Restart\n    if(contextBlob->savedHandle == 0x80000002)\n\tCryptDigestUpdateInt(\n\t\t\t     &hmacState.hashState, sizeof(gr.clearCount), gr.clearCount);\n\n    // Adding sequence number to the HMAC to make sure that it doesn't\n    // get changed\n    CryptDigestUpdateInt(\n\t\t\t &hmacState.hashState, sizeof(contextBlob->sequence), contextBlob->sequence);\n\n    // Protect the handle\n    CryptDigestUpdateInt(&hmacState.hashState,\n\t\t\t sizeof(contextBlob->savedHandle),\n\t\t\t contextBlob->savedHandle);\n\n    // Adding sensitive contextData, skip the leading integrity area\n    CryptDigestUpdate(&hmacState.hashState,\n\t\t      contextBlob->contextBlob.t.size - integritySize,\n\t\t      contextBlob->contextBlob.t.buffer + integritySize);\n\n    // Complete HMAC\n    CryptHmacEnd2B(&hmacState, &integrity->b);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** SequenceDataExport();\n// This function is used scan through the sequence object and\n// either modify the hash state data for export (contextSave) or to\n// import it into the internal format (contextLoad).\n// This function should only be called after the sequence object has been copied\n// to the context buffer (contextSave) or from the context buffer into the sequence\n// object. The presumption is that the context buffer version of the data is the\n// same size as the internal representation so nothing outsize of the hash context\n// area gets modified.\nvoid SequenceDataExport(\n\t\t\tHASH_OBJECT*        object,       // IN: an internal hash object\n\t\t\tHASH_OBJECT_BUFFER* exportObject  // OUT: a sequence context in a buffer\n\t\t\t)\n{\n    // If the hash object is not an event, then only one hash context is needed\n    int count = (object->attributes.eventSeq) ? HASH_COUNT : 1;\n\n    for(count--; count >= 0; count--)\n\t{\n\t    HASH_STATE* hash       = &object->state.hashState[count];\n\t    size_t      offset     = (BYTE*)hash - (BYTE*)object;\n\t    BYTE*       exportHash = &((BYTE*)exportObject)[offset];\n\n\t    CryptHashExportState(hash, (EXPORT_HASH_STATE*)exportHash);\n\t}\n}\n\n//*** SequenceDataImport();\n// This function is used scan through the sequence object and\n// either modify the hash state data for export (contextSave) or to\n// import it into the internal format (contextLoad).\n// This function should only be called after the sequence object has been copied\n// to the context buffer (contextSave) or from the context buffer into the sequence\n// object. The presumption is that the context buffer version of the data is the\n// same size as the internal representation so nothing outsize of the hash context\n// area gets modified.\nvoid SequenceDataImport(\n\t\t\tHASH_OBJECT*        object,       // IN/OUT: an internal hash object\n\t\t\tHASH_OBJECT_BUFFER* exportObject  // IN/OUT: a sequence context in a buffer\n\t\t\t)\n{\n    // If the hash object is not an event, then only one hash context is needed\n    int count = (object->attributes.eventSeq) ? HASH_COUNT : 1;\n\n    for(count--; count >= 0; count--)\n\t{\n\t    HASH_STATE* hash       = &object->state.hashState[count];\n\t    size_t      offset     = (BYTE*)hash - (BYTE*)object;\n\t    BYTE*       importHash = &((BYTE*)exportObject)[offset];\n\t    //\n\t    CryptHashImportState(hash, (EXPORT_HASH_STATE*)importHash);\n\t}\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptCmac.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tMessage Authentication Codes Based on a Symmetric Block Cipher\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2018 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// This file contains the implementation of the message authentication codes based\n// on a symmetric block cipher. These functions only use the single block\n// encryption functions of the selected symmetric cryptographic library.\n\n//** Includes, Defines, and Typedefs\n#define _CRYPT_HASH_C_\n#include \"Tpm.h\"\n#include \"CryptSym.h\"\n\n#if ALG_CMAC\n\n//** Functions\n\n//*** CryptCmacStart()\n// This is the function to start the CMAC sequence operation. It initializes the\n// dispatch functions for the data and end operations for CMAC and initializes the\n// parameters that are used for the processing of data, including the key, key size\n// and block cipher algorithm.\nUINT16\nCryptCmacStart(\n\t       SMAC_STATE* state, TPMU_PUBLIC_PARMS* keyParms, TPM_ALG_ID macAlg, TPM2B* key)\n{\n    tpmCmacState_t*      cState = &state->state.cmac;\n    TPMT_SYM_DEF_OBJECT* def    = &keyParms->symDetail.sym;\n    //\n    if(macAlg != TPM_ALG_CMAC)\n\treturn 0;\n    // set up the encryption algorithm and parameters\n    cState->symAlg      = def->algorithm;\n    cState->keySizeBits = def->keyBits.sym;\n    cState->iv.t.size = CryptGetSymmetricBlockSize(def->algorithm, def->keyBits.sym);\n    MemoryCopy2B(&cState->symKey.b, key, sizeof(cState->symKey.t.buffer));\n    \n    // Set up the dispatch methods for the CMAC\n    state->smacMethods.data = CryptCmacData;\n    state->smacMethods.end  = CryptCmacEnd;\n    return cState->iv.t.size;\n}\n\n//*** CryptCmacData()\n// This function is used to add data to the CMAC sequence computation. The function\n// will XOR new data into the IV. If the buffer is full, and there is additional\n// input data, the data is encrypted into the IV buffer, the new data is then\n// XOR into the IV. When the data runs out, the function returns without encrypting\n// even if the buffer is full. The last data block of a sequence will not be\n// encrypted until the call to CryptCmacEnd(). This is to allow the proper subkey\n// to be computed and applied before the last block is encrypted.\nvoid CryptCmacData(SMAC_STATES* state, UINT32 size, const BYTE* buffer)\n{\n    tpmCmacState_t*         cmacState     = &state->cmac;\n    TPM_ALG_ID              algorithm     = cmacState->symAlg;\n    BYTE*                   key           = cmacState->symKey.t.buffer;\n    UINT16                  keySizeInBits = cmacState->keySizeBits;\n    tpmCryptKeySchedule_t   keySchedule;\n    TpmCryptSetSymKeyCall_t encrypt;\n    //\n    // Set up the encryption values based on the algorithm\n    switch(algorithm)\n\t{\n\t    FOR_EACH_SYM(ENCRYPT_CASE)\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t}\n    while(size > 0)\n\t{\n\t    if(cmacState->bcount == cmacState->iv.t.size)\n\t\t{\n\t\t    ENCRYPT(&keySchedule, cmacState->iv.t.buffer, cmacState->iv.t.buffer);\n\t\t    cmacState->bcount = 0;\n\t\t}\n\t    for(; (size > 0) && (cmacState->bcount < cmacState->iv.t.size);\n\t\tsize--, cmacState->bcount++)\n\t\t{\n\t\t    cmacState->iv.t.buffer[cmacState->bcount] ^= *buffer++;\n\t\t}\n\t}\n}\n\n//*** CryptCmacEnd()\n// This is the completion function for the CMAC. It does padding, if needed, and\n// selects the subkey to be applied before the last block is encrypted.\nUINT16\nCryptCmacEnd(SMAC_STATES* state, UINT32 outSize, BYTE* outBuffer)\n{\n    tpmCmacState_t* cState = &state->cmac;\n    // Need to set algorithm, key, and keySizeInBits in the local context so that\n    // the SELECT and ENCRYPT macros will work here\n    TPM_ALG_ID              algorithm     = cState->symAlg;\n    BYTE*                   key           = cState->symKey.t.buffer;\n    UINT16                  keySizeInBits = cState->keySizeBits;\n    tpmCryptKeySchedule_t   keySchedule;\n    TpmCryptSetSymKeyCall_t encrypt;\n    TPM2B_IV                subkey = {{0, {0}}};\n    BOOL                    xorVal;\n    UINT16                  i;\n    \n    subkey.t.size = cState->iv.t.size;\n    // Encrypt a block of zero\n    // Set up the encryption values based on the algorithm\n    switch(algorithm)\n\t{\n\t    FOR_EACH_SYM(ENCRYPT_CASE)\n\t  default:\n\t    return 0;\n\t}\n    ENCRYPT(&keySchedule, subkey.t.buffer, subkey.t.buffer);\n    \n    // shift left by 1 and XOR with 0x0...87 if the MSb was 0\n    xorVal = ((subkey.t.buffer[0] & 0x80) == 0) ? 0 : 0x87;\n    ShiftLeft(&subkey.b);\n    subkey.t.buffer[subkey.t.size - 1] ^= xorVal;\n    // this is a sanity check to make sure that the algorithm is working properly.\n    // remove this check when debug is done\n    pAssert(cState->bcount <= cState->iv.t.size);\n    // If the buffer is full then no need to compute subkey 2.\n    if(cState->bcount < cState->iv.t.size)\n\t{\n\t    //Pad the data\n\t    cState->iv.t.buffer[cState->bcount++] ^= 0x80;\n\t    // The rest of the data is a pad of zero which would simply be XORed\n\t    // with the iv value so nothing to do...\n\t    // Now compute K2\n\t    xorVal = ((subkey.t.buffer[0] & 0x80) == 0) ? 0 : 0x87;\n\t    ShiftLeft(&subkey.b);\n\t    subkey.t.buffer[subkey.t.size - 1] ^= xorVal;\n\t}\n    // XOR the subkey into the IV\n    for(i = 0; i < subkey.t.size; i++)\n\tcState->iv.t.buffer[i] ^= subkey.t.buffer[i];\n    ENCRYPT(&keySchedule, cState->iv.t.buffer, cState->iv.t.buffer);\n    i = (UINT16)MIN(cState->iv.t.size, outSize);\n    MemoryCopy(outBuffer, cState->iv.t.buffer, i);\n    \n    return i;\n}\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptDes.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Functions Required for TDES  \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 10.2.9 CryptDes.c */\n/* 10.2.9.1 Introduction */\n/* This file contains the extra functions required for TDES. */\n/* 10.2.9.2 Includes, Defines, and Typedefs */\n#include \"Tpm.h\"\n#if ALG_TDES\n#define DES_NUM_WEAK 64\nconst UINT64 DesWeakKeys[DES_NUM_WEAK] = {\n    0x0101010101010101ULL, 0xFEFEFEFEFEFEFEFEULL, 0xE0E0E0E0F1F1F1F1ULL, 0x1F1F1F1F0E0E0E0EULL,\n    0x011F011F010E010EULL, 0x1F011F010E010E01ULL, 0x01E001E001F101F1ULL, 0xE001E001F101F101ULL,\n    0x01FE01FE01FE01FEULL, 0xFE01FE01FE01FE01ULL, 0x1FE01FE00EF10EF1ULL, 0xE01FE01FF10EF10EULL,\n    0x1FFE1FFE0EFE0EFEULL, 0xFE1FFE1FFE0EFE0EULL, 0xE0FEE0FEF1FEF1FEULL, 0xFEE0FEE0FEF1FEF1ULL,\n    0x01011F1F01010E0EULL, 0x1F1F01010E0E0101ULL, 0xE0E01F1FF1F10E0EULL, 0x0101E0E00101F1F1ULL,\n    0x1F1FE0E00E0EF1F1ULL, 0xE0E0FEFEF1F1FEFEULL, 0x0101FEFE0101FEFEULL, 0x1F1FFEFE0E0EFEFEULL,\n    0xE0FE011FF1FE010EULL, 0x011F1F01010E0E01ULL, 0x1FE001FE0EF101FEULL, 0xE0FE1F01F1FE0E01ULL,\n    0x011FE0FE010EF1FEULL, 0x1FE0E01F0EF1F10EULL, 0xE0FEFEE0F1FEFEF1ULL, 0x011FFEE0010EFEF1ULL,\n    0x1FE0FE010EF1FE01ULL, 0xFE0101FEFE0101FEULL, 0x01E01FFE01F10EFEULL, 0x1FFE01E00EFE01F1ULL,\n    0xFE011FE0FE010EF1ULL, 0xFE01E01FFE01F10EULL, 0x1FFEE0010EFEF101ULL, 0xFE1F01E0FE0E01F1ULL,\n    0x01E0E00101F1F101ULL, 0x1FFEFE1F0EFEFE0EULL, 0xFE1FE001FE0EF101ULL, 0x01E0FE1F01F1FE0EULL,\n    0xE00101E0F10101F1ULL, 0xFE1F1FFEFE0E0EFEULL, 0x01FE1FE001FE0EF1ULL, 0xE0011FFEF1010EFEULL,\n    0xFEE0011FFEF1010EULL, 0x01FEE01F01FEF10EULL, 0xE001FE1FF101FE0EULL, 0xFEE01F01FEF10E01ULL,\n    0x01FEFE0101FEFE01ULL, 0xE01F01FEF10E01FEULL, 0xFEE0E0FEFEF1F1FEULL, 0x1F01011F0E01010EULL,\n    0xE01F1FE0F10E0EF1ULL, 0xFEFE0101FEFE0101ULL, 0x1F01E0FE0E01F1FEULL, 0xE01FFE01F10EFE01ULL,\n    0xFEFE1F1FFEFE0E0EULL, 0x1F01FEE00E01FEF1ULL, 0xE0E00101F1F10101ULL, 0xFEFEE0E0FEFEF1F1ULL};\n/* 10.2.9.2.1 CryptSetOddByteParity() */\n/* This function sets the per byte parity of a 64-bit value. The least-significant bit is of each\n   byte is replaced with the odd parity of the other 7 bits in the byte. With odd parity, no byte\n   will ever be 0x00. */\nUINT64\nCryptSetOddByteParity(\n\t\t      UINT64          k\n\t\t      )\n{\n#define PMASK 0x0101010101010101ULL\n    UINT64          out;\n    k |= PMASK;     // set the parity bit\n    out = k;\n    k ^= k >> 4;\n    k ^= k >> 2;\n    k ^= k >> 1;\n    k &= PMASK;     // odd parity extracted\n    out ^= k;       // out is now even parity because parity bit was already set\n    out ^= PMASK;   // out is now even parity\n    return out;\n}\n/* 10.2.9.2.2 CryptDesIsWeakKey() */\n/* Check to see if a DES key is on the list of weak, semi-weak, or possibly weak keys. */\n/* Return Value\tMeaning */\n/* TRUE(1)\tDES key is weak */\n/* FALSE(0)\tDES key is not weak */\nstatic BOOL\nCryptDesIsWeakKey(\n\t\t  UINT64            k\n\t\t  )\n{\n    int              i;\n    //\n    for(i = 0; i < DES_NUM_WEAK; i++)\n\t{\n\t    if(k == DesWeakKeys[i])\n\t\treturn TRUE;\n\t}\n    return FALSE;\n}\n/* 10.2.9.2.3 CryptDesValidateKey() */\n/* Function to check to see if the input key is a valid DES key where the definition of valid is\n   that none of the elements are on the list of weak, semi-weak, or possibly weak keys; and that for\n   two keys, K1!=K2, and for three keys that K1!=K2 and K2!=K3. */\nBOOL\nCryptDesValidateKey(\n\t\t    TPM2B_SYM_KEY       *desKey     // IN: key to validate\n\t\t    )\n{\n    UINT64               k[3];\n    int                  i;\n    int                  keys = (desKey->t.size + 7) / 8;\n    BYTE                *pk = desKey->t.buffer;\n    BOOL                 ok;\n    //\n    // Note: 'keys' is the number of keys, not the maximum index for 'k'\n    ok = ((keys == 2) || (keys == 3)) && ((desKey->t.size % 8) == 0);\n    for(i = 0; ok && i < keys; pk += 8, i++)\n\t{\n\t    k[i] = CryptSetOddByteParity(BYTE_ARRAY_TO_UINT64(pk));\n\t    ok = !CryptDesIsWeakKey(k[i]);\n\t}\n    ok = ok && k[0] != k[1];\n    if(keys == 3)\n\tok = ok && k[1] != k[2];\n    return ok;\n}\n/* 10.2.9.2.4 CryptGenerateKeyDes() */\n/* This function is used to create a DES key of the appropriate size. The key will have odd parity\n   in the bytes. */\nTPM_RC\nCryptGenerateKeyDes(\n\t\t    TPMT_PUBLIC             *publicArea,        // IN/OUT: The public area template\n\t\t    //     for the new key.\n\t\t    TPMT_SENSITIVE          *sensitive,         // OUT: sensitive area\n\t\t    RAND_STATE              *rand               // IN: the \"entropy\" source for\n\t\t    )\n{\n    // Assume that the publicArea key size has been validated and is a supported\n    // number of bits.\n    sensitive->sensitive.sym.t.size =\n\tBITS_TO_BYTES(publicArea->parameters.symDetail.sym.keyBits.sym);\n    // Because we use BYTE_ARRAY_TO_UINT64 below, require the requested DES key\n    // to be a multiple of 8 bytes in size.\n    if((sensitive->sensitive.sym.t.size % 8) != 0)\n\t{\n\t    return TPM_RC_SYMMETRIC;\n\t}\n    do\n\t{\n\t    BYTE                    *pK = sensitive->sensitive.sym.t.buffer;\n\t    int                      i = (sensitive->sensitive.sym.t.size + 7) / 8;\n\t    // Use the random number generator to generate the required number of bits\n\t    if(DRBG_Generate(rand, pK, sensitive->sensitive.sym.t.size) == 0)\n\t\treturn TPM_RC_NO_RESULT;\n\t    for(; i > 0; pK += 8, i--)\n\t\t{\n\t\t    UINT64      k = BYTE_ARRAY_TO_UINT64(pK);\n\t\t    k = CryptSetOddByteParity(k);\n\t\t    UINT64_TO_BYTE_ARRAY(k, pK);\n\t\t}\n\t} while(!CryptDesValidateKey(&sensitive->sensitive.sym));\n    return TPM_RC_SUCCESS;\n}\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptEccCrypt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Asymmetric ECC Commands   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2022 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes and Defines\n#include \"Tpm.h\"\n#include \"TpmMath_Util_fp.h\"\n#include \"TpmEcc_Util_fp.h\"\n\n#if CC_ECC_Encrypt || CC_ECC_Encrypt\n\n//** Functions\n\n//*** CryptEccSelectScheme()\n// This function is used by TPM2_ECC_Decrypt and TPM2_ECC_Encrypt.  It sets scheme\n// either the input scheme or the key scheme. If they key scheme is not TPM_ALG_NULL\n// then the input scheme must be TPM_ALG_NULL or the same as the key scheme. If\n// not, then the function returns FALSE.\n//  Return Type: BOOL\n//      TRUE        'scheme' is set\n//      FALSE       'scheme' is not valid (it may have been changed).\nBOOL CryptEccSelectScheme(OBJECT*          key,    //IN: key containing default scheme\n\t\t\t  TPMT_KDF_SCHEME* scheme  // IN: a decrypt scheme\n\t\t\t  )\n{\n    TPMT_KDF_SCHEME* keyScheme = &key->publicArea.parameters.eccDetail.kdf;\n\n    // Get sign object pointer\n    if(scheme->scheme == TPM_ALG_NULL)\n\t*scheme = *keyScheme;\n    if(keyScheme->scheme == TPM_ALG_NULL)\n\tkeyScheme = scheme;\n    return (\n\t    scheme->scheme != TPM_ALG_NULL\n\t    && (keyScheme->scheme == scheme->scheme\n\t\t&& keyScheme->details.anyKdf.hashAlg == scheme->details.anyKdf.hashAlg));\n}\n\n//*** CryptEccEncrypt()\n//This function performs ECC-based data obfuscation. The only scheme that is currently\n// supported is MGF1 based. See Part 1, Annex D for details.\n//  Return Type: TPM_RC\n//      TPM_RC_CURVE            unsupported curve\n//      TPM_RC_HASH             hash not allowed\n//      TPM_RC_SCHEME           'scheme' is not supported\n//      TPM_RC_NO_RESULT        internal error in big number processing\nLIB_EXPORT TPM_RC CryptEccEncrypt(\n\t\t\t\t  OBJECT*           key,        // IN: public key of recipient\n\t\t\t\t  TPMT_KDF_SCHEME*  scheme,     // IN: scheme to use.\n\t\t\t\t  TPM2B_MAX_BUFFER* plainText,  // IN: the text to obfuscate\n\t\t\t\t  TPMS_ECC_POINT*   c1,         // OUT: public ephemeral key\n\t\t\t\t  TPM2B_MAX_BUFFER* c2,         // OUT: obfuscated text\n\t\t\t\t  TPM2B_DIGEST*     c3          // OUT: digest of ephemeral key\n\t\t\t\t  //      and plainText\n\t\t\t\t  )\n{\n    CRYPT_CURVE_INITIALIZED(E, key->publicArea.parameters.eccDetail.curveID);\n    CRYPT_POINT_INITIALIZED(PB, &key->publicArea.unique.ecc);\n    CRYPT_POINT_VAR(Px);\n    TPMS_ECC_POINT p2;\n    CRYPT_ECC_NUM(D);\n    TPM2B_TYPE(2ECC, MAX_ECC_KEY_BYTES * 2);\n    TPM2B_2ECC z;\n    int        i;\n    HASH_STATE hashState;\n    TPM_RC     retVal = TPM_RC_SUCCESS;\n    //\n#  if defined DEBUG_ECC_ENCRYPT && DEBUG_ECC_ENCRYPT == YES\n    RND_DEBUG dbg;\n    // This value is one less than the value from the reference so that it\n    // will become the correct value after having one added\n    TPM2B_ECC_PARAMETER k = {24, {0x38, 0x4F, 0x30, 0x35, 0x30, 0x73, 0xAE, 0xEC,\n\t\t\t\t  0xE7, 0xA1, 0x65, 0x43, 0x30, 0xA9, 0x62, 0x04,\n\t\t\t\t  0xD3, 0x79, 0x82, 0xA3, 0xE1, 0x5B, 0x2C, 0xB4}};\n    RND_DEBUG_Instantiate(&dbg, &k.b);\n#    define RANDOM (RAND_STATE*)&dbg\n\n#  else\n#    define RANDOM NULL\n#  endif\n    if(E == NULL)\n\tERROR_EXIT(TPM_RC_CURVE);\n    if(TPM_ALG_KDF2 != scheme->scheme)\n\tERROR_EXIT(TPM_RC_SCHEME);\n    // generate an ephemeral key from a random k\n    if(!TpmEcc_GenerateKeyPair(D, Px, E, RANDOM)\n       // C1 is the public part of the ephemeral key\n       || !TpmEcc_PointTo2B(c1, Px, E)\n       // Compute P2\n       || (TpmEcc_PointMult(Px, PB, D, NULL, NULL, E) != TPM_RC_SUCCESS)\n       || !TpmEcc_PointTo2B(&p2, Px, E))\n\tERROR_EXIT(TPM_RC_NO_RESULT);\n\n    //Compute the C3 value hash(x2 || M || y2)\n    if(0 == CryptHashStart(&hashState, scheme->details.mgf1.hashAlg))\n\tERROR_EXIT(TPM_RC_HASH);\n    CryptDigestUpdate2B(&hashState, &p2.x.b);\n    CryptDigestUpdate2B(&hashState, &plainText->b);\n    CryptDigestUpdate2B(&hashState, &p2.y.b);\n    c3->t.size = CryptHashEnd(&hashState, sizeof(c3->t.buffer), c3->t.buffer);\n\n    MemoryCopy2B(&z.b, &p2.x.b, sizeof(z.t.buffer));\n    MemoryConcat2B(&z.b, &p2.y.b, sizeof(z.t.buffer));\n    // Generate the mask value from MGF1 and put it in the return buffer\n    c2->t.size = CryptMGF_KDF(plainText->t.size,\n\t\t\t      c2->t.buffer,\n\t\t\t      scheme->details.mgf1.hashAlg,\n\t\t\t      z.t.size,\n\t\t\t      z.t.buffer,\n\t\t\t      1);\n    // XOR the plainText into the generated mask to create the obfuscated data\n    for(i = 0; i < plainText->t.size; i++)\n\tc2->t.buffer[i] ^= plainText->t.buffer[i];\n Exit:\n    CRYPT_CURVE_FREE(E);\n    return retVal;\n}\n\n//*** CryptEccDecrypt()\n// This function performs ECC decryption and integrity check of the input data.\n//  Return Type: TPM_RC\n//      TPM_RC_CURVE            unsupported curve\n//      TPM_RC_HASH             hash not allowed\n//      TPM_RC_SCHEME           'scheme' is not supported\n//      TPM_RC_NO_RESULT        internal error in big number processing\n//      TPM_RC_VALUE            C3 did not match hash of recovered data\nLIB_EXPORT TPM_RC CryptEccDecrypt(\n\t\t\t\t  OBJECT*           key,        // IN: key used for data recovery\n\t\t\t\t  TPMT_KDF_SCHEME*  scheme,     // IN: scheme to use.\n\t\t\t\t  TPM2B_MAX_BUFFER* plainText,  // OUT: the recovered text\n\t\t\t\t  TPMS_ECC_POINT*   c1,         // IN: public ephemeral key\n\t\t\t\t  TPM2B_MAX_BUFFER* c2,         // IN: obfuscated text\n\t\t\t\t  TPM2B_DIGEST*     c3          // IN: digest of ephemeral key\n\t\t\t\t  //      and plainText\n\t\t\t\t  )\n{\n    CRYPT_CURVE_INITIALIZED(E, key->publicArea.parameters.eccDetail.curveID);\n    CRYPT_ECC_INITIALIZED(D, &key->sensitive.sensitive.ecc.b);\n    CRYPT_POINT_INITIALIZED(C1, c1);\n    TPMS_ECC_POINT p2;\n    TPM2B_TYPE(2ECC, MAX_ECC_KEY_BYTES * 2);\n    TPM2B_DIGEST check;\n    TPM2B_2ECC   z;\n    int          i;\n    HASH_STATE   hashState;\n    TPM_RC       retVal = TPM_RC_SUCCESS;\n    //\n    if(E == NULL)\n\tERROR_EXIT(TPM_RC_CURVE);\n    if(TPM_ALG_KDF2 != scheme->scheme)\n\tERROR_EXIT(TPM_RC_SCHEME);\n    // Generate the Z value\n    TpmEcc_PointMult(C1, C1, D, NULL, NULL, E);\n    TpmEcc_PointTo2B(&p2, C1, E);\n\n    // Start the hash to check the algorithm\n    if(0 == CryptHashStart(&hashState, scheme->details.mgf1.hashAlg))\n\tERROR_EXIT(TPM_RC_HASH);\n    CryptDigestUpdate2B(&hashState, &p2.x.b);\n\n    MemoryCopy2B(&z.b, &p2.x.b, sizeof(z.t.buffer));\n    MemoryConcat2B(&z.b, &p2.y.b, sizeof(z.t.buffer));\n\n    // Generate the mask\n    plainText->t.size = CryptMGF_KDF(c2->t.size,\n\t\t\t\t     plainText->t.buffer,\n\t\t\t\t     scheme->details.mgf1.hashAlg,\n\t\t\t\t     z.t.size,\n\t\t\t\t     z.t.buffer,\n\t\t\t\t     1);\n    // XOR the obfuscated data into the generated mask to create the plainText data\n    for(i = 0; i < plainText->t.size; i++)\n\tplainText->t.buffer[i] ^= c2->t.buffer[i];\n\n    // Complete the hash and verify the data\n    CryptDigestUpdate2B(&hashState, &plainText->b);\n    CryptDigestUpdate2B(&hashState, &p2.y.b);\n    check.t.size = CryptHashEnd(&hashState, sizeof(check.t.buffer), check.t.buffer);\n    if(!MemoryEqual2B(&check.b, &c3->b))\n\tERROR_EXIT(TPM_RC_VALUE);\n Exit:\n    CRYPT_CURVE_FREE(E);\n    return retVal;\n}\n\n#endif  // CC_ECC_Encrypt || CC_ECC_Encrypt\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptEccData.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tECC curve data \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2018 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/*(Auto-generated)\n *  Created by TpmStructures; Version 4.4 Mar 26, 2019\n *  Date: Aug 30, 2019  Time: 02:11:52PM\n */\n\n#include \"Tpm.h\"\n#include \"OIDs.h\"\n\n#if ALG_ECC\n\n// This file contains the TPM Specific ECC curve metadata and pointers to the ecc-lib specific\n// constant structure.\n// The CURVE_NAME macro is used to remove the name string from normal builds, but leaves the\n// string available in the initialization lists for potenial use during debugging by changing this\n// macro (and the structure declaration)\n#  define CURVE_NAME(N)\n\n#  define comma\nconst TPM_ECC_CURVE_METADATA eccCurves[] = {\n#  if ECC_NIST_P192\n    comma{TPM_ECC_NIST_P192,\n\t  192,\n\t  {TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA256}}},\n\t  {TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t  OID_ECC_NIST_P192 CURVE_NAME(\"NIST_P192\")}\n#    undef comma\n#    define comma ,\n#  endif  // ECC_NIST_P192\n#  if ECC_NIST_P224\n    comma{TPM_ECC_NIST_P224,\n\t    224,\n\t\t{TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA256}}},\n\t\t    {TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t    OID_ECC_NIST_P224 CURVE_NAME(\"NIST_P224\")}\n#    undef comma\n#    define comma ,\n#  endif  // ECC_NIST_P224\n#  if ECC_NIST_P256\n    comma{TPM_ECC_NIST_P256,\n\t    256,\n\t\t{TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA256}}},\n\t\t    {TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t    OID_ECC_NIST_P256 CURVE_NAME(\"NIST_P256\")}\n#    undef comma\n#    define comma ,\n#  endif  // ECC_NIST_P256\n#  if ECC_NIST_P384\n    comma{TPM_ECC_NIST_P384,\n\t    384,\n\t\t{TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA384}}},\n\t\t    {TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t    OID_ECC_NIST_P384 CURVE_NAME(\"NIST_P384\")}\n#    undef comma\n#    define comma ,\n#  endif  // ECC_NIST_P384\n#  if ECC_NIST_P521\n    comma{TPM_ECC_NIST_P521,\n\t    521,\n\t\t{TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SHA512}}},\n\t\t    {TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t    OID_ECC_NIST_P521 CURVE_NAME(\"NIST_P521\")}\n#    undef comma\n#    define comma ,\n#  endif  // ECC_NIST_P521\n#  if ECC_BN_P256\n    comma{TPM_ECC_BN_P256,\n\t    256,\n\t\t{TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t\t    {TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t    OID_ECC_BN_P256 CURVE_NAME(\"BN_P256\")}\n#    undef comma\n#    define comma ,\n#  endif  // ECC_BN_P256\n#  if ECC_BN_P638\n    comma{TPM_ECC_BN_P638,\n\t    638,\n\t\t{TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t\t    {TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t    OID_ECC_BN_P638 CURVE_NAME(\"BN_P638\")}\n#    undef comma\n#    define comma ,\n#  endif  // ECC_BN_P638\n#  if ECC_SM2_P256\n    comma{TPM_ECC_SM2_P256,\n\t    256,\n\t\t{TPM_ALG_KDF1_SP800_56A, {{TPM_ALG_SM3_256}}},\n\t\t    {TPM_ALG_NULL, {{TPM_ALG_NULL}}},\n\t    OID_ECC_SM2_P256 CURVE_NAME(\"SM2_P256\")}\n#    undef comma\n#    define comma ,\n#  endif  // ECC_SM2_P256\n};\n\n#endif  // TPM_ALG_ECC\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptEccKeyExchange.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tFunctions that are used for the two-phase, ECC, key-exchange protocols\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the functions that are used for the two-phase, ECC,\n// key-exchange protocols\n\n#include \"Tpm.h\"\n#include \"TpmMath_Util_fp.h\"\n#include \"TpmEcc_Util_fp.h\"\n\n#if CC_ZGen_2Phase == YES\n\n//** Functions\n\n#  if ALG_ECMQV\n\n//*** avf1()\n// This function does the associated value computation required by MQV key\n// exchange.\n// Process:\n// 1. Convert 'xQ' to an integer 'xqi' using the convention specified in Appendix C.3.\n// 2. Calculate\n//        xqm = xqi mod 2^ceil(f/2) (where f = ceil(log2(n)).\n// 3. Calculate the associate value function\n//        avf(Q) = xqm + 2ceil(f / 2)\n// Always returns TRUE(1).\nstatic BOOL avf1(Crypt_Int* bnX,  // IN/OUT: the reduced value\n\t\t Crypt_Int* bnN   // IN: the order of the curve\n\t\t )\n{\n    // compute f = 2^(ceil(ceil(log2(n)) / 2))\n    int f = (ExtMath_SizeInBits(bnN) + 1) / 2;\n    // x' = 2^f + (x mod 2^f)\n    ExtMath_MaskBits(bnX, f);  // This is mod 2*2^f but it doesn't matter because\n    // the next operation will SET the extra bit anyway\n    if(!ExtMath_SetBit(bnX, f))\n\t{\n\t    FAIL(FATAL_ERROR_CRYPTO);\n\t}\n    return TRUE;\n}\n\n//*** C_2_2_MQV()\n// This function performs the key exchange defined in SP800-56A\n// 6.1.1.4 Full MQV, C(2, 2, ECC MQV).\n//\n// CAUTION: Implementation of this function may require use of essential claims in\n// patents not owned by TCG members.\n//\n// Points 'QsB' and 'QeB' are required to be on the curve of 'inQsA'. The function\n// will fail, possibly catastrophically, if this is not the case.\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        the value for dsA does not give a valid point on the\n//                              curve\nstatic TPM_RC C_2_2_MQV(TPMS_ECC_POINT* outZ,   // OUT: the computed point\n\t\t\tTPM_ECC_CURVE curveId,  // IN: the curve for the computations\n\t\t\tTPM2B_ECC_PARAMETER* dsA,  // IN: static private TPM key\n\t\t\tTPM2B_ECC_PARAMETER* deA,  // IN: ephemeral private TPM key\n\t\t\tTPMS_ECC_POINT*      QsB,  // IN: static public party B key\n\t\t\tTPMS_ECC_POINT*      QeB   // IN: ephemeral public party B key\n\t\t\t)\n{\n    CRYPT_CURVE_INITIALIZED(E, curveId);\n    CRYPT_POINT_VAR(pQeA);\n    CRYPT_POINT_INITIALIZED(pQeB, QeB);\n    CRYPT_POINT_INITIALIZED(pQsB, QsB);\n    CRYPT_ECC_NUM(bnTa);\n    CRYPT_ECC_INITIALIZED(bnDeA, deA);\n    CRYPT_ECC_INITIALIZED(bnDsA, dsA);\n    CRYPT_ECC_NUM(bnN);\n    CRYPT_ECC_NUM(bnXeB);\n    TPM_RC retVal;\n    //\n    // Parameter checks\n    if(E == NULL)\n\tERROR_EXIT(TPM_RC_VALUE);\n    pAssert(\n\t    outZ != NULL && pQeB != NULL && pQsB != NULL && deA != NULL && dsA != NULL);\n    // Process:\n    //  1. implicitsigA = (de,A + avf(Qe,A)ds,A ) mod n.\n    //  2. P = h(implicitsigA)(Qe,B + avf(Qe,B)Qs,B).\n    //  3. If P = O, output an error indicator.\n    //  4. Z=xP, where xP is the x-coordinate of P.\n\n    // Compute the public ephemeral key pQeA = [de,A]G\n    if((retVal =\n\tTpmEcc_PointMult(pQeA, ExtEcc_CurveGetG(curveId), bnDeA, NULL, NULL, E))\n       != TPM_RC_SUCCESS)\n\tgoto Exit;\n\n    //  1. implicitsigA = (de,A + avf(Qe,A)ds,A ) mod n.\n    //  tA := (ds,A + de,A  avf(Xe,A)) mod n    (3)\n    //  Compute 'tA' = ('deA' +  'dsA'  avf('XeA')) mod n\n    // Ta = avf(XeA);\n    ExtMath_Copy(bnTa, ExtEcc_PointX(pQeA));\n    avf1(bnTa, bnN);\n    // do Ta = ds,A * Ta mod n = dsA * avf(XeA) mod n\n    ExtMath_ModMult(bnTa, bnDsA, bnTa, bnN);\n    // now Ta = deA + Ta mod n =  deA + dsA * avf(XeA) mod n\n    ExtMath_Add(bnTa, bnTa, bnDeA);\n    ExtMath_Mod(bnTa, bnN);\n\n    //  2. P = h(implicitsigA)(Qe,B + avf(Qe,B)Qs,B).\n    // Put this in because almost every case of h is == 1 so skip the call when\n    // not necessary.\n    if(!ExtMath_IsEqualWord(ExtEcc_CurveGetCofactor(curveId), 1))\n\t// Cofactor is not 1 so compute Ta := Ta * h mod n\n\tExtMath_ModMult(bnTa,\n\t\t\tbnTa,\n\t\t\tExtEcc_CurveGetCofactor(curveId),\n\t\t\tExtEcc_CurveGetOrder(curveId));\n\n    // Now that 'tA' is (h * 'tA' mod n)\n    // 'outZ' = (tA)(Qe,B + avf(Qe,B)Qs,B).\n\n    // first, compute XeB = avf(XeB)\n    avf1(bnXeB, bnN);\n\n    // QsB := [XeB]QsB\n    TpmEcc_PointMult(pQsB, pQsB, bnXeB, NULL, NULL, E);\n    ExtEcc_PointAdd(pQeB, pQeB, pQsB, E);\n\n    // QeB := [tA]QeB = [tA](QsB + [Xe,B]QeB) and check for at infinity\n    // If the result is not the point at infinity, return QeB\n    TpmEcc_PointMult(pQeB, pQeB, bnTa, NULL, NULL, E);\n    if(ExtEcc_IsInfinityPoint(pQeB))\n\tERROR_EXIT(TPM_RC_NO_RESULT);\n    // Convert Crypt_Int* E to TPM2B E\n    TpmEcc_PointTo2B(outZ, pQeB, E);\n\n Exit:\n    CRYPT_CURVE_FREE(E);\n    return retVal;\n}\n\n#  endif  // ALG_ECMQV\n\n//*** C_2_2_ECDH()\n// This function performs the two phase key exchange defined in SP800-56A,\n// 6.1.1.2 Full Unified Model, C(2, 2, ECC CDH).\n//\nstatic TPM_RC C_2_2_ECDH(TPMS_ECC_POINT* outZs,  // OUT: Zs\n\t\t\t TPMS_ECC_POINT* outZe,  // OUT: Ze\n\t\t\t TPM_ECC_CURVE curveId,  // IN: the curve for the computations\n\t\t\t TPM2B_ECC_PARAMETER* dsA,  // IN: static private TPM key\n\t\t\t TPM2B_ECC_PARAMETER* deA,  // IN: ephemeral private TPM key\n\t\t\t TPMS_ECC_POINT*      QsB,  // IN: static public party B key\n\t\t\t TPMS_ECC_POINT*      QeB  // IN: ephemeral public party B key\n\t\t\t )\n{\n    CRYPT_CURVE_INITIALIZED(E, curveId);\n    CRYPT_ECC_INITIALIZED(bnAs, dsA);\n    CRYPT_ECC_INITIALIZED(bnAe, deA);\n    CRYPT_POINT_INITIALIZED(ecBs, QsB);\n    CRYPT_POINT_INITIALIZED(ecBe, QeB);\n    CRYPT_POINT_VAR(ecZ);\n    TPM_RC retVal;\n    //\n    // Parameter checks\n    if(E == NULL)\n\tERROR_EXIT(TPM_RC_CURVE);\n    pAssert(\n\t    outZs != NULL && dsA != NULL && deA != NULL && QsB != NULL && QeB != NULL);\n\n    // Do the point multiply for the Zs value ([dsA]QsB)\n    retVal = TpmEcc_PointMult(ecZ, ecBs, bnAs, NULL, NULL, E);\n    if(retVal == TPM_RC_SUCCESS)\n\t{\n\t    // Convert the Zs value.\n\t    TpmEcc_PointTo2B(outZs, ecZ, E);\n\t    // Do the point multiply for the Ze value ([deA]QeB)\n\t    retVal = TpmEcc_PointMult(ecZ, ecBe, bnAe, NULL, NULL, E);\n\t    if(retVal == TPM_RC_SUCCESS)\n\t\tTpmEcc_PointTo2B(outZe, ecZ, E);\n\t}\n Exit:\n    CRYPT_CURVE_FREE(E);\n    return retVal;\n}\n\n//*** CryptEcc2PhaseKeyExchange()\n// This function is the dispatch routine for the EC key exchange functions that use\n// two ephemeral and two static keys.\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME             scheme is not defined\nLIB_EXPORT TPM_RC CryptEcc2PhaseKeyExchange(\n\t\t\t\t\t    TPMS_ECC_POINT*      outZ1,    // OUT: a computed point\n\t\t\t\t\t    TPMS_ECC_POINT*      outZ2,    // OUT: and optional second point\n\t\t\t\t\t    TPM_ECC_CURVE        curveId,  // IN: the curve for the computations\n\t\t\t\t\t    TPM_ALG_ID           scheme,   // IN: the key exchange scheme\n\t\t\t\t\t    TPM2B_ECC_PARAMETER* dsA,      // IN: static private TPM key\n\t\t\t\t\t    TPM2B_ECC_PARAMETER* deA,      // IN: ephemeral private TPM key\n\t\t\t\t\t    TPMS_ECC_POINT*      QsB,      // IN: static public party B key\n\t\t\t\t\t    TPMS_ECC_POINT*      QeB       // IN: ephemeral public party B key\n\t\t\t\t\t    )\n{\n    pAssert(\n\t    outZ1 != NULL && dsA != NULL && deA != NULL && QsB != NULL && QeB != NULL);\n\n    // Initialize the output points so that they are empty until one of the\n    // functions decides otherwise\n    outZ1->x.b.size = 0;\n    outZ1->y.b.size = 0;\n    if(outZ2 != NULL)\n\t{\n\t    outZ2->x.b.size = 0;\n\t    outZ2->y.b.size = 0;\n\t}\n    switch(scheme)\n\t{\n\t  case TPM_ALG_ECDH:\n\t    return C_2_2_ECDH(outZ1, outZ2, curveId, dsA, deA, QsB, QeB);\n\t    break;\n#  if ALG_ECMQV\n\t  case TPM_ALG_ECMQV:\n\t    return C_2_2_MQV(outZ1, curveId, dsA, deA, QsB, QeB);\n\t    break;\n#  endif\n#  if ALG_SM2\n\t  case TPM_ALG_SM2:\n\t    return SM2KeyExchange(outZ1, curveId, dsA, deA, QsB, QeB);\n\t    break;\n#  endif\n\t  default:\n\t    return TPM_RC_SCHEME;\n\t}\n}\n\n#  if ALG_SM2\n\n//*** ComputeWForSM2()\n// Compute the value for w used by SM2\nstatic UINT32 ComputeWForSM2(TPM_ECC_CURVE curveId)\n{\n    //  w := ceil(ceil(log2(n)) / 2) - 1\n    return (ExtMath_MostSigBitNum(ExtEcc_CurveGetOrder(curveId)) / 2 - 1);\n}\n\n//*** avfSm2()\n// This function does the associated value computation required by SM2 key\n// exchange. This is different from the avf() in the international standards\n// because it returns a value that is half the size of the value returned by the\n// standard avf(). For example, if 'n' is 15, 'Ws' ('w' in the standard) is 2 but\n// the 'W' here is 1. This means that an input value of 14 (1110b) would return a\n// value of 110b with the standard but 10b with the scheme in SM2.\nstatic Crypt_Int* avfSm2(Crypt_Int* bn,  // IN/OUT: the reduced value\n\t\t\t UINT32     w    // IN: the value of w\n\t\t\t )\n{\n    // a)   set w := ceil(ceil(log2(n)) / 2) - 1\n    // b)   set x' := 2^w + ( x & (2^w - 1))\n    // This is just like the avf for MQV where x' = 2^w + (x mod 2^w)\n\n    ExtMath_MaskBits(bn, w);  // as with avf1, this is too big by a factor of 2 but\n    // it doesn't matter because we SET the extra bit\n    // anyway\n    if(!ExtMath_SetBit(bn, w))\n\t{\n\t    FAIL(FATAL_ERROR_CRYPTO);\n\t}\n    return bn;\n}\n\n//*** SM2KeyExchange()\n// This function performs the key exchange defined in SM2.\n// The first step is to compute\n//  'tA' = ('dsA' + 'deA'  avf(Xe,A)) mod 'n'\n// Then, compute the 'Z' value from\n// 'outZ' = ('h'  'tA' mod 'n') ('QsA' + [avf('QeB.x')]('QeB')).\n// The function will compute the ephemeral public key from the ephemeral\n// private key.\n// All points are required to be on the curve of 'inQsA'. The function will fail\n// catastrophically if this is not the case\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        the value for dsA does not give a valid point on the\n//                              curve\nLIB_EXPORT TPM_RC SM2KeyExchange(\n\t\t\t\t TPMS_ECC_POINT*      outZ,     // OUT: the computed point\n\t\t\t\t TPM_ECC_CURVE        curveId,  // IN: the curve for the computations\n\t\t\t\t TPM2B_ECC_PARAMETER* dsAIn,    // IN: static private TPM key\n\t\t\t\t TPM2B_ECC_PARAMETER* deAIn,    // IN: ephemeral private TPM key\n\t\t\t\t TPMS_ECC_POINT*      QsBIn,    // IN: static public party B key\n\t\t\t\t TPMS_ECC_POINT*      QeBIn     // IN: ephemeral public party B key\n\t\t\t\t )\n{\n    CRYPT_CURVE_INITIALIZED(E, curveId);\n    CRYPT_ECC_INITIALIZED(dsA, dsAIn);\n    CRYPT_ECC_INITIALIZED(deA, deAIn);\n    CRYPT_POINT_INITIALIZED(QsB, QsBIn);\n    CRYPT_POINT_INITIALIZED(QeB, QeBIn);\n    CRYPT_INT_WORD_INITIALIZED(One, 1);\n    CRYPT_POINT_VAR(QeA);\n    CRYPT_ECC_NUM(XeB);\n    CRYPT_POINT_VAR(Z);\n    CRYPT_ECC_NUM(Ta);\n    CRYPT_ECC_NUM(QeA_X);\n    UINT32 w;\n    TPM_RC retVal = TPM_RC_NO_RESULT;\n    //\n    // Parameter checks\n    if(E == NULL)\n\tERROR_EXIT(TPM_RC_CURVE);\n    pAssert(outZ != NULL && dsA != NULL && deA != NULL && QsB != NULL && QeB != NULL);\n\n    // Compute the value for w\n    w = ComputeWForSM2(curveId);\n\n    // Compute the public ephemeral key pQeA = [de,A]G\n    if(!ExtEcc_PointMultiply(QeA, ExtEcc_CurveGetG(curveId), deA, E))\n\tgoto Exit;\n\n    //  tA := (ds,A + de,A  avf(Xe,A)) mod n    (3)\n    //  Compute 'tA' = ('dsA' +  'deA'  avf('XeA')) mod n\n    // Ta = avf(XeA);\n    // do Ta = de,A * Ta = deA * avf(XeA)\n    ExtMath_Copy(QeA_X, ExtEcc_PointX(QeA));  // create mutable copy\n    ExtMath_Multiply(Ta, deA, avfSm2(QeA_X, w));\n    // now Ta = dsA + Ta =  dsA + deA * avf(XeA)\n    ExtMath_Add(Ta, dsA, Ta);\n    ExtMath_Mod(Ta, ExtEcc_CurveGetOrder(curveId));\n\n    //  outZ = [h  tA mod n] (Qs,B + [avf(Xe,B)](Qe,B)) (4)\n    // Put this in because almost every case of h is == 1 so skip the call when\n    // not necessary.\n    if(!ExtMath_IsEqualWord(ExtEcc_CurveGetCofactor(curveId), 1))\n\t// Cofactor is not 1 so compute Ta := Ta * h mod n\n\tExtMath_ModMult(\n\t\t\tTa, Ta, ExtEcc_CurveGetCofactor(curveId), ExtEcc_CurveGetOrder(curveId));\n    // Now that 'tA' is (h * 'tA' mod n)\n    // 'outZ' = ['tA'](QsB + [avf(QeB.x)](QeB)).\n    ExtMath_Copy(XeB, ExtEcc_PointX(QeB));\n    if(!ExtEcc_PointMultiplyAndAdd(Z, QsB, One, QeB, avfSm2(XeB, w), E))\n\tgoto Exit;\n    // QeB := [tA]QeB = [tA](QsB + [Xe,B]QeB) and check for at infinity\n    if(!ExtEcc_PointMultiply(Z, Z, Ta, E))\n\tgoto Exit;\n    // Convert Crypt_Int* E to TPM2B E\n    TpmEcc_PointTo2B(outZ, Z, E);\n    retVal = TPM_RC_SUCCESS;\n Exit:\n    CRYPT_CURVE_FREE(E);\n    return retVal;\n}\n#  endif\n\n#endif  // CC_ZGen_2Phase\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptEccMain.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \tECC Main\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes and Defines\n#include \"Tpm.h\"\n#include \"TpmMath_Util_fp.h\"\n#include \"TpmEcc_Util_fp.h\"\n#include \"TpmEcc_Signature_ECDSA_fp.h\"  // required for pairwise test in key generation\n#if ALG_ECC\n//** Functions\n\n#  if SIMULATION\nvoid EccSimulationEnd(void)\n{\n#    if SIMULATION\n    // put things to be printed at the end of the simulation here\n#    endif\n}\n#  endif  // SIMULATION\n\n//*** CryptEccInit()\n// This function is called at _TPM_Init\nBOOL CryptEccInit(void)\n{\n    return TRUE;\n}\n\n//*** CryptEccStartup()\n// This function is called at TPM2_Startup().\nBOOL CryptEccStartup(void)\n{\n    return TRUE;\n}\n\n//*** ClearPoint2B(generic)\n// Initialize the size values of a TPMS_ECC_POINT structure.\nvoid ClearPoint2B(TPMS_ECC_POINT* p  // IN: the point\n\t\t  )\n{\n    if(p != NULL)\n\t{\n\t    p->x.t.size = 0;\n\t    p->y.t.size = 0;\n\t}\n}\n\n//*** CryptEccGetParametersByCurveId()\n// This function returns a pointer to the curve data that is associated with\n// the indicated curveId.\n// If there is no curve with the indicated ID, the function returns NULL. This\n// function is in this module so that it can be called by GetCurve data.\n//  Return Type: const TPM_ECC_CURVE_METADATA\n//      NULL            curve with the indicated TPM_ECC_CURVE is not implemented\n//      != NULL         pointer to the curve data\nLIB_EXPORT const TPM_ECC_CURVE_METADATA* CryptEccGetParametersByCurveId(\n\t\t\t\t\t\t\t\t\tTPM_ECC_CURVE curveId  // IN: the curveID\n\t\t\t\t\t\t\t\t\t)\n{\n    int i;\n    for(i = 0; i < ECC_CURVE_COUNT; i++)\n\t{\n\t    if(eccCurves[i].curveId == curveId)\n\t\treturn &eccCurves[i];\n\t}\n    return NULL;\n}\n\n//*** CryptEccGetKeySizeForCurve()\n// This function returns the key size in bits of the indicated curve.\nLIB_EXPORT UINT16 CryptEccGetKeySizeForCurve(TPM_ECC_CURVE curveId  // IN: the curve\n\t\t\t\t\t     )\n{\n    const TPM_ECC_CURVE_METADATA* curve = CryptEccGetParametersByCurveId(curveId);\n    UINT16                        keySizeInBits;\n    //\n    keySizeInBits = (curve != NULL) ? curve->keySizeBits : 0;\n    return keySizeInBits;\n}\n\n//***CryptEccGetOID()\nconst BYTE* CryptEccGetOID(TPM_ECC_CURVE curveId)\n{\n    const TPM_ECC_CURVE_METADATA* curve = CryptEccGetParametersByCurveId(curveId);\n    return (curve != NULL) ? curve->OID : NULL;\n}\n\n//*** CryptEccGetCurveByIndex()\n// This function returns the number of the 'i'-th implemented curve. The normal\n// use would be to call this function with 'i' starting at 0. When the 'i' is greater\n// than or equal to the number of implemented curves, TPM_ECC_NONE is returned.\nLIB_EXPORT TPM_ECC_CURVE CryptEccGetCurveByIndex(UINT16 i)\n{\n    if(i >= ECC_CURVE_COUNT)\n\treturn TPM_ECC_NONE;\n    return eccCurves[i].curveId;\n}\n\n//*** CryptCapGetECCCurve()\n// This function returns the list of implemented ECC curves.\n//  Return Type: TPMI_YES_NO\n//      YES             if no more ECC curve is available\n//      NO              if there are more ECC curves not reported\nTPMI_YES_NO\nCryptCapGetECCCurve(TPM_ECC_CURVE   curveID,   // IN: the starting ECC curve\n\t\t    UINT32          maxCount,  // IN: count of returned curves\n\t\t    TPML_ECC_CURVE* curveList  // OUT: ECC curve list\n\t\t    )\n{\n    TPMI_YES_NO   more = NO;\n    UINT16        i;\n    UINT32        count = ECC_CURVE_COUNT;\n    TPM_ECC_CURVE curve;\n\n    // Initialize output property list\n    curveList->count = 0;\n\n    // The maximum count of curves we may return is MAX_ECC_CURVES\n    if(maxCount > MAX_ECC_CURVES)\n\tmaxCount = MAX_ECC_CURVES;\n\n    // Scan the eccCurveValues array\n    for(i = 0; i < count; i++)\n\t{\n\t    curve = CryptEccGetCurveByIndex(i);\n\t    // If curveID is less than the starting curveID, skip it\n\t    if(curve < curveID)\n\t\tcontinue;\n\t    if(curveList->count < maxCount)\n\t\t{\n\t\t    // If we have not filled up the return list, add more curves to\n\t\t    // it\n\t\t    curveList->eccCurves[curveList->count] = curve;\n\t\t    curveList->count++;\n\t\t}\n\t    else\n\t\t{\n\t\t    // If the return list is full but we still have curves\n\t\t    // available, report this and stop iterating\n\t\t    more = YES;\n\t\t    break;\n\t\t}\n\t}\n    return more;\n}\n\n//*** CryptCapGetOneECCCurve()\n// This function returns whether the ECC curve is implemented.\nBOOL CryptCapGetOneECCCurve(TPM_ECC_CURVE curveID  // IN: the  ECC curve\n\t\t\t    )\n{\n    UINT16 i;\n\n    // Scan the eccCurveValues array\n    for(i = 0; i < ECC_CURVE_COUNT; i++)\n\t{\n\t    if(CryptEccGetCurveByIndex(i) == curveID)\n\t\t{\n\t\t    return TRUE;\n\t\t}\n\t}\n    return FALSE;\n}\n\n//*** CryptGetCurveSignScheme()\n// This function will return a pointer to the scheme of the curve.\nconst TPMT_ECC_SCHEME* CryptGetCurveSignScheme(\n\t\t\t\t\t       TPM_ECC_CURVE curveId  // IN: The curve selector\n\t\t\t\t\t       )\n{\n    const TPM_ECC_CURVE_METADATA* curve = CryptEccGetParametersByCurveId(curveId);\n\n    if(curve != NULL)\n\treturn &(curve->sign);\n    else\n\treturn NULL;\n}\n\n//*** CryptGenerateR()\n// This function computes the commit random value for a split signing scheme.\n//\n// If 'c' is NULL, it indicates that 'r' is being generated\n// for TPM2_Commit.\n// If 'c' is not NULL, the TPM will validate that the 'gr.commitArray'\n// bit associated with the input value of 'c' is SET. If not, the TPM\n// returns FALSE and no 'r' value is generated.\n//  Return Type: BOOL\n//      TRUE(1)         r value computed\n//      FALSE(0)        no r value computed\nBOOL CryptGenerateR(TPM2B_ECC_PARAMETER* r,        // OUT: the generated random value\n\t\t    UINT16*              c,        // IN/OUT: count value.\n\t\t    TPMI_ECC_CURVE       curveID,  // IN: the curve for the value\n\t\t    TPM2B_NAME*          name      // IN: optional name of a key to\n\t\t    //     associate with 'r'\n\t\t    )\n{\n    // This holds the marshaled g_commitCounter.\n    TPM2B_TYPE(8B, 8);\n    TPM2B_8B            cntr = {{8, {0}}};\n    UINT32              iterations;\n    TPM2B_ECC_PARAMETER n;\n    UINT64              currentCount = gr.commitCounter;\n    UINT16              t1;\n    //\n    if(!TpmMath_IntTo2B(ExtEcc_CurveGetOrder(curveID), (TPM2B*)&n, 0))\n\treturn FALSE;\n\n    // If this is the commit phase, use the current value of the commit counter\n    if(c != NULL)\n\t{\n\t    // if the array bit is not set, can't use the value.\n\t    if(!TEST_BIT((*c & COMMIT_INDEX_MASK), gr.commitArray))\n\t\treturn FALSE;\n\n\t    // If it is the sign phase, figure out what the counter value was\n\t    // when the commitment was made.\n\t    //\n\t    // When gr.commitArray has less than 64K bits, the extra\n\t    // bits of 'c' are used as a check to make sure that the\n\t    // signing operation is not using an out of range count value\n\t    t1 = (UINT16)currentCount;\n\n\t    // If the lower bits of c are greater or equal to the lower bits of t1\n\t    // then the upper bits of t1 must be one more than the upper bits\n\t    // of c\n\t    if((*c & COMMIT_INDEX_MASK) >= (t1 & COMMIT_INDEX_MASK))\n\t\t// Since the counter is behind, reduce the current count\n\t\tcurrentCount = currentCount - (COMMIT_INDEX_MASK + 1);\n\n\t    t1 = (UINT16)currentCount;\n\t    if((t1 & ~COMMIT_INDEX_MASK) != (*c & ~COMMIT_INDEX_MASK))\n\t\treturn FALSE;\n\t    // set the counter to the value that was\n\t    // present when the commitment was made\n\t    currentCount = (currentCount & 0xffffffffffff0000) | *c;\n\t}\n    // Marshal the count value to a TPM2B buffer for the KDF\n    cntr.t.size = sizeof(currentCount);\n    UINT64_TO_BYTE_ARRAY(currentCount, cntr.t.buffer);\n\n    // Now can do the KDF to create the random value for the signing operation\n    // During the creation process, we may generate an r that does not meet the\n    // requirements of the random value.\n    // want to generate a new r.\n    r->t.size = n.t.size;\n\n    for(iterations = 1; iterations < 1000000;)\n\t{\n\t    int i;\n\t    CryptKDFa(CONTEXT_INTEGRITY_HASH_ALG,\n\t\t      &gr.commitNonce.b,\n\t\t      COMMIT_STRING,\n\t\t      &name->b,\n\t\t      &cntr.b,\n\t\t      n.t.size * 8,\n\t\t      r->t.buffer,\n\t\t      &iterations,\n\t\t      FALSE);\n\n\t    // \"random\" value must be less than the prime\n\t    if(UnsignedCompareB(r->b.size, r->b.buffer, n.t.size, n.t.buffer) >= 0)\n\t\tcontinue;\n\n\t    // in this implementation it is required that at least bit\n\t    // in the upper half of the number be set\n\t    for(i = n.t.size / 2; i >= 0; i--)\n\t\tif(r->b.buffer[i] != 0)\n\t\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//*** CryptCommit()\n// This function is called when the count value is committed. The 'gr.commitArray'\n// value associated with the current count value is SET and g_commitCounter is\n// incremented. The low-order 16 bits of old value of the counter is returned.\nUINT16\nCryptCommit(void)\n{\n    UINT16 oldCount = (UINT16)gr.commitCounter;\n    gr.commitCounter++;\n    SET_BIT(oldCount & COMMIT_INDEX_MASK, gr.commitArray);\n    return oldCount;\n}\n\n//*** CryptEndCommit()\n// This function is called when the signing operation using the committed value\n// is completed. It clears the gr.commitArray bit associated with the count\n// value so that it can't be used again.\nvoid CryptEndCommit(UINT16 c  // IN: the counter value of the commitment\n\t\t    )\n{\n    ClearBit((c & COMMIT_INDEX_MASK), gr.commitArray, sizeof(gr.commitArray));\n}\n\n//*** CryptEccGetParameters()\n// This function returns the ECC parameter details of the given curve.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        unsupported ECC curve ID\nBOOL CryptEccGetParameters(\n\t\t\t   TPM_ECC_CURVE              curveId,    // IN: ECC curve ID\n\t\t\t   TPMS_ALGORITHM_DETAIL_ECC* parameters  // OUT: ECC parameters\n\t\t\t   )\n{\n    const TPM_ECC_CURVE_METADATA* curve = CryptEccGetParametersByCurveId(curveId);\n    BOOL                          found = curve != NULL;\n\n    if(found)\n\t{\n\t    parameters->curveID = curve->curveId;\n\t    parameters->keySize = curve->keySizeBits;\n\t    parameters->kdf     = curve->kdf;\n\t    parameters->sign    = curve->sign;\n\t    //        BnTo2B(data->prime, &parameters->p.b, 0);\n\t    found = found\n\t\t    && TpmMath_IntTo2B(ExtEcc_CurveGetPrime(curveId),\n\t\t\t\t       &parameters->p.b,\n\t\t\t\t       parameters->p.t.size);\n\t    found = found\n\t\t    && TpmMath_IntTo2B(ExtEcc_CurveGet_a(curveId), &parameters->a.b, 0);\n\t    found = found\n\t\t    && TpmMath_IntTo2B(ExtEcc_CurveGet_b(curveId), &parameters->b.b, 0);\n\t    found = found\n\t\t    && TpmMath_IntTo2B(ExtEcc_CurveGetGx(curveId),\n\t\t\t\t       &parameters->gX.b,\n\t\t\t\t       parameters->p.t.size);\n\t    found = found\n\t\t    && TpmMath_IntTo2B(ExtEcc_CurveGetGy(curveId),\n\t\t\t\t       &parameters->gY.b,\n\t\t\t\t       parameters->p.t.size);\n\t    //        BnTo2B(data->base.x, &parameters->gX.b, 0);\n\t    //        BnTo2B(data->base.y, &parameters->gY.b, 0);\n\t    found =\n\t\tfound\n\t\t&& TpmMath_IntTo2B(ExtEcc_CurveGetOrder(curveId), &parameters->n.b, 0);\n\t    found =\n\t\tfound\n\t\t&& TpmMath_IntTo2B(ExtEcc_CurveGetCofactor(curveId), &parameters->h.b, 0);\n\t    // if we got into this IF but failed to get a parameter from the external\n\t    // library, our crypto systems are broken; enter failure mode.\n\t    if(!found)\n\t\t{\n\t\t    FAIL(FATAL_ERROR_MATHLIBRARY);\n\t\t}\n\t}\n    return found;\n}\n\n//*** TpmEcc_IsValidPrivateEcc()\n// Checks that 0 < 'x' < 'q'\nBOOL TpmEcc_IsValidPrivateEcc(const Crypt_Int*      x,  // IN: private key to check\n\t\t\t      const Crypt_EccCurve* E   // IN: the curve to check\n\t\t\t      )\n{\n    BOOL retVal;\n    retVal =\n\t(!ExtMath_IsZero(x)\n\t && (ExtMath_UnsignedCmp(x, ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E)))\n\t     < 0));\n    return retVal;\n}\n\nLIB_EXPORT BOOL CryptEccIsValidPrivateKey(TPM2B_ECC_PARAMETER* d,\n\t\t\t\t\t  TPM_ECC_CURVE        curveId)\n{\n    CRYPT_INT_INITIALIZED(bnD, MAX_ECC_PARAMETER_BYTES * 8, d);\n    return !ExtMath_IsZero(bnD)\n\t&& (ExtMath_UnsignedCmp(bnD, ExtEcc_CurveGetOrder(curveId)) < 0);\n}\n\n//*** TpmEcc_PointMult()\n// This function does a point multiply of the form 'R' = ['d']'S' + ['u']'Q' where the\n// parameters are Crypt_Int* values. If 'S' is NULL and d is not NULL, then it computes\n// 'R' = ['d']'G' + ['u']'Q'  or just 'R' = ['d']'G' if 'u' and 'Q' are NULL.\n// If 'skipChecks' is TRUE, then the function will not verify that the inputs are\n// correct for the domain. This would be the case when the values were created by the\n// CryptoEngine code.\n// It will return TPM_RC_NO_RESULT if the resulting point is the point at infinity.\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        result of multiplication is a point at infinity\n//      TPM_RC_ECC_POINT        'S' or 'Q' is not on the curve\n//      TPM_RC_VALUE            'd' or 'u' is not < n\nTPM_RC\nTpmEcc_PointMult(Crypt_Point*          R,  // OUT: computed point\n\t\t const Crypt_Point*    S,  // IN: optional point to multiply by 'd'\n\t\t const Crypt_Int*      d,  // IN: scalar for [d]S or [d]G\n\t\t const Crypt_Point*    Q,  // IN: optional second point\n\t\t const Crypt_Int*      u,  // IN: optional second scalar\n\t\t const Crypt_EccCurve* E   // IN: curve parameters\n\t\t )\n{\n    BOOL OK;\n    //\n    TPM_DO_SELF_TEST(TPM_ALG_ECDH);\n\n    // Need one scalar\n    OK = (d != NULL || u != NULL);\n\n    // If S is present, then d has to be present. If S is not\n    // present, then d may or may not be present\n    OK = OK && (((S == NULL) == (d == NULL)) || (d != NULL));\n\n    // either both u and Q have to be provided or neither can be provided (don't\n    // know what to do if only one is provided.\n    OK = OK && ((u == NULL) == (Q == NULL));\n\n    OK = OK && (E != NULL);\n    if(!OK)\n\treturn TPM_RC_VALUE;\n\n    OK = (S == NULL) || ExtEcc_IsPointOnCurve(S, E);\n    OK = OK && ((Q == NULL) || ExtEcc_IsPointOnCurve(Q, E));\n    if(!OK)\n\treturn TPM_RC_ECC_POINT;\n\n    if((d != NULL) && (S == NULL))\n\tS = ExtEcc_CurveGetG(ExtEcc_CurveGetCurveId(E));\n    // If only one scalar, don't need Shamir's trick\n    if((d == NULL) || (u == NULL))\n\t{\n\t    if(d == NULL)\n\t\tOK = ExtEcc_PointMultiply(R, Q, u, E);\n\t    else\n\t\tOK = ExtEcc_PointMultiply(R, S, d, E);\n\t}\n    else\n\t{\n\t    OK = ExtEcc_PointMultiplyAndAdd(R, S, d, Q, u, E);\n\t}\n    return (OK ? TPM_RC_SUCCESS : TPM_RC_NO_RESULT);\n}\n\n//***TpmEcc_GenPrivateScalar()\n// This function gets random values that are the size of the key plus 64 bits. The\n// value is reduced (mod ('q' - 1)) and incremented by 1 ('q' is the order of the\n// curve. This produces a value ('d') such that 1 <= 'd' < 'q'. This is the method\n// of FIPS 186-4 Section B.4.1 \"\"Key Pair Generation Using Extra Random Bits\"\".\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure generating private key\nBOOL TpmEcc_GenPrivateScalar(\n\t\t\t     Crypt_Int*            dOut,  // OUT: the qualified random value\n\t\t\t     const Crypt_EccCurve* E,     // IN: curve for which the private key\n\t\t\t     //     needs to be appropriate\n\t\t\t     RAND_STATE* rand             // IN: state for DRBG\n\t\t\t     )\n{\n    TPM_ECC_CURVE    curveId = ExtEcc_CurveGetCurveId(E);\n    const Crypt_Int* order   = ExtEcc_CurveGetOrder(curveId);\n    BOOL             OK;\n    UINT32           orderBits  = ExtMath_SizeInBits(order);\n    UINT32           orderBytes = BITS_TO_BYTES(orderBits);\n    CRYPT_INT_VAR(bnExtraBits, MAX_ECC_KEY_BITS + 64);\n    CRYPT_INT_VAR(nMinus1, MAX_ECC_KEY_BITS);\n    //\n    OK = TpmMath_GetRandomInteger(bnExtraBits, (orderBytes * 8) + 64, rand);\n    OK = OK && ExtMath_SubtractWord(nMinus1, order, 1);\n    OK = OK && ExtMath_Mod(bnExtraBits, nMinus1);\n    OK = OK && ExtMath_AddWord(dOut, bnExtraBits, 1);\n    return OK && !g_inFailureMode;\n}\n\n//*** TpmEcc_GenerateKeyPair()\n// This function gets a private scalar from the source of random bits and does\n// the point multiply to get the public key.\nBOOL TpmEcc_GenerateKeyPair(Crypt_Int*            bnD,  // OUT: private scalar\n\t\t\t    Crypt_Point*          ecQ,  // OUT: public point\n\t\t\t    const Crypt_EccCurve* E,    // IN: curve for the point\n\t\t\t    RAND_STATE*           rand  // IN: DRBG state to use\n\t\t\t    )\n{\n    BOOL OK = FALSE;\n    // Get a private scalar\n    OK = TpmEcc_GenPrivateScalar(bnD, E, rand);\n\n    // Do a point multiply\n    OK = OK && ExtEcc_PointMultiply(ecQ, NULL, bnD, E);\n    return OK;\n}\n\n//***CryptEccNewKeyPair(***)\n// This function creates an ephemeral ECC. It is ephemeral in that\n// is expected that the private part of the key will be discarded\nLIB_EXPORT TPM_RC CryptEccNewKeyPair(\n\t\t\t\t     TPMS_ECC_POINT*      Qout,    // OUT: the public point\n\t\t\t\t     TPM2B_ECC_PARAMETER* dOut,    // OUT: the private scalar\n\t\t\t\t     TPM_ECC_CURVE        curveId  // IN: the curve for the key\n\t\t\t\t     )\n{\n    CRYPT_CURVE_INITIALIZED(E, curveId);\n    CRYPT_POINT_VAR(ecQ);\n    CRYPT_ECC_NUM(bnD);\n    BOOL OK;\n\n    if(E == NULL)\n\treturn TPM_RC_CURVE;\n\n    TPM_DO_SELF_TEST(TPM_ALG_ECDH);\n    OK = TpmEcc_GenerateKeyPair(bnD, ecQ, E, NULL);\n    if(OK)\n\t{\n\t    TpmEcc_PointTo2B(Qout, ecQ, E);\n\t    TpmMath_IntTo2B(bnD, &dOut->b, Qout->x.t.size);\n\t}\n    else\n\t{\n\t    Qout->x.t.size = Qout->y.t.size = dOut->t.size = 0;\n\t}\n    CRYPT_CURVE_FREE(E);\n    return OK ? TPM_RC_SUCCESS : TPM_RC_NO_RESULT;\n}\n\n//*** CryptEccPointMultiply()\n// This function computes 'R' := ['dIn']'G' + ['uIn']'QIn'. Where 'dIn' and\n// 'uIn' are scalars, 'G' and 'QIn' are points on the specified curve and 'G' is the\n// default generator of the curve.\n//\n// The 'xOut' and 'yOut' parameters are optional and may be set to NULL if not\n// used.\n//\n// It is not necessary to provide 'uIn' if 'QIn' is specified but one of 'uIn' and\n// 'dIn' must be provided. If 'dIn' and 'QIn' are specified but 'uIn' is not\n// provided, then 'R' = ['dIn']'QIn'.\n//\n// If the multiply produces the point at infinity, the TPM_RC_NO_RESULT is returned.\n//\n// The sizes of 'xOut' and yOut' will be set to be the size of the degree of\n// the curve\n//\n// It is a fatal error if 'dIn' and 'uIn' are both unspecified (NULL) or if 'Qin'\n// or 'Rout' is unspecified.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_ECC_POINT         the point 'Pin' or 'Qin' is not on the curve\n//      TPM_RC_NO_RESULT         the product point is at infinity\n//      TPM_RC_CURVE             bad curve\n//      TPM_RC_VALUE             'dIn' or 'uIn' out of range\n//\nLIB_EXPORT TPM_RC CryptEccPointMultiply(\n\t\t\t\t\tTPMS_ECC_POINT*      Rout,     // OUT: the product point R\n\t\t\t\t\tTPM_ECC_CURVE        curveId,  // IN: the curve to use\n\t\t\t\t\tTPMS_ECC_POINT*      Pin,      // IN: first point (can be null)\n\t\t\t\t\tTPM2B_ECC_PARAMETER* dIn,      // IN: scalar value for [dIn]Qin\n\t\t\t\t\t//     the Pin\n\t\t\t\t\tTPMS_ECC_POINT*      Qin,      // IN: point Q\n\t\t\t\t\tTPM2B_ECC_PARAMETER* uIn       // IN: scalar value for the multiplier\n\t\t\t\t\t//     of Q\n\t\t\t\t\t)\n{\n    CRYPT_CURVE_INITIALIZED(E, curveId);\n    CRYPT_POINT_INITIALIZED(ecP, Pin);\n    CRYPT_ECC_INITIALIZED(bnD, dIn);  // If dIn is null, then bnD is null\n    CRYPT_ECC_INITIALIZED(bnU, uIn);\n    CRYPT_POINT_INITIALIZED(ecQ, Qin);\n    CRYPT_POINT_VAR(ecR);\n    TPM_RC retVal;\n    //\n    retVal = TpmEcc_PointMult(ecR, ecP, bnD, ecQ, bnU, E);\n\n    if(retVal == TPM_RC_SUCCESS)\n\tTpmEcc_PointTo2B(Rout, ecR, E);\n    else\n\tClearPoint2B(Rout);\n    CRYPT_CURVE_FREE(E);\n    return retVal;\n}\n\n//*** CryptEccIsPointOnCurve()\n// This function is used to test if a point is on a defined curve. It does this\n// by checking that 'y'^2 mod 'p' = 'x'^3 + 'a'*'x' + 'b' mod 'p'.\n//\n// It is a fatal error if 'Q' is not specified (is NULL).\n//  Return Type: BOOL\n//      TRUE(1)         point is on curve\n//      FALSE(0)        point is not on curve or curve is not supported\nLIB_EXPORT BOOL CryptEccIsPointOnCurve(\n\t\t\t\t       TPM_ECC_CURVE   curveId,  // IN: the curve selector\n\t\t\t\t       TPMS_ECC_POINT* Qin       // IN: the point.\n\t\t\t\t       )\n{\n    CRYPT_CURVE_INITIALIZED(E, curveId);\n    CRYPT_POINT_INITIALIZED(ecQ, Qin);\n    BOOL OK;\n    //\n    pAssert(Qin != NULL);\n    OK = (E != NULL && (ExtEcc_IsPointOnCurve(ecQ, E)));\n    return OK;\n}\n\n//*** CryptEccGenerateKey()\n// This function generates an ECC key pair based on the input parameters.\n// This routine uses KDFa to produce candidate numbers. The method is according\n// to FIPS 186-3, section B.1.2 \"Key Pair Generation by Testing Candidates.\"\n// According to the method in FIPS 186-3, the resulting private value 'd' should be\n// 1 <= 'd' < 'n' where 'n' is the order of the base point.\n//\n// It is a fatal error if 'Qout', 'dOut', is not provided (is NULL).\n//\n// If the curve is not supported\n// If 'seed' is not provided, then a random number will be used for the key\n//  Return Type: TPM_RC\n//      TPM_RC_CURVE            curve is not supported\n//      TPM_RC_NO_RESULT        could not verify key with signature (FIPS only)\nLIB_EXPORT TPM_RC CryptEccGenerateKey(\n\t\t\t\t      TPMT_PUBLIC* publicArea,    // IN/OUT: The public area template for\n\t\t\t\t      //      the new key. The public key\n\t\t\t\t      //      area will be replaced computed\n\t\t\t\t      //      ECC public key\n\t\t\t\t      TPMT_SENSITIVE* sensitive,  // OUT: the sensitive area will be\n\t\t\t\t      //      updated to contain the private\n\t\t\t\t      //      ECC key and the symmetric\n\t\t\t\t      //      encryption key\n\t\t\t\t      RAND_STATE* rand            // IN: if not NULL, the deterministic\n\t\t\t\t      //     RNG state\n\t\t\t\t      )\n{\n    CRYPT_CURVE_INITIALIZED(E, publicArea->parameters.eccDetail.curveID);\n    CRYPT_ECC_NUM(bnD);\n    CRYPT_POINT_VAR(ecQ);\n    BOOL   OK;\n    TPM_RC retVal;\n    //\n    TPM_DO_SELF_TEST(TPM_ALG_ECDSA);  // ECDSA is used to verify each key\n\n    // Validate parameters\n    if(E == NULL)\n\tERROR_EXIT(TPM_RC_CURVE);\n\n    publicArea->unique.ecc.x.t.size = 0;\n    publicArea->unique.ecc.y.t.size = 0;\n    sensitive->sensitive.ecc.t.size = 0;\n\n    OK                              = TpmEcc_GenerateKeyPair(bnD, ecQ, E, rand);\n    if(OK)\n\t{\n\t    TpmEcc_PointTo2B(&publicArea->unique.ecc, ecQ, E);\n\t    TpmMath_IntTo2B(\n\t\t\t    bnD, &sensitive->sensitive.ecc.b, publicArea->unique.ecc.x.t.size);\n\t}\n#  if FIPS_COMPLIANT\n    // See if PWCT is required\n    if(OK && IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sign))\n\t{\n\t    CRYPT_ECC_NUM(bnT);\n\t    CRYPT_ECC_NUM(bnS);\n\t    TPM2B_DIGEST digest;\n\t    //\n\t    TPM_DO_SELF_TEST(TPM_ALG_ECDSA);\n\t    digest.t.size = MIN(sensitive->sensitive.ecc.t.size, sizeof(digest.t.buffer));\n\t    // Get a random value to sign using the built in DRBG state\n\t    DRBG_Generate(NULL, digest.t.buffer, digest.t.size);\n\t    if(g_inFailureMode)\n\t\treturn TPM_RC_FAILURE;\n\t    TpmEcc_SignEcdsa(bnT, bnS, E, bnD, &digest, NULL);\n\t    // and make sure that we can validate the signature\n\t    OK = TpmEcc_ValidateSignatureEcdsa(bnT, bnS, E, ecQ, &digest)\n\t\t == TPM_RC_SUCCESS;\n\t}\n#  endif\n    retVal = (OK) ? TPM_RC_SUCCESS : TPM_RC_NO_RESULT;\n Exit:\n    CRYPT_CURVE_FREE(E);\n    return retVal;\n}\n\n#endif  // ALG_ECC\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptEccSignature.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     ECC Signatures\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes and Defines\n#include \"Tpm.h\"\n#include \"TpmEcc_Signature_ECDSA_fp.h\"\n#include \"TpmEcc_Signature_ECDAA_fp.h\"\n#include \"TpmEcc_Signature_Schnorr_fp.h\"\n#include \"TpmEcc_Signature_SM2_fp.h\"\n#include \"TpmEcc_Util_fp.h\"\n#include \"TpmMath_Util_fp.h\"\n#include \"CryptEccSignature_fp.h\"\n\n#if ALG_ECC\n\n//** Utility Functions\n\n//** Signing Functions\n\n//*** CryptEccSign()\n// This function is the dispatch function for the various ECC-based\n// signing schemes.\n// There is a bit of ugliness to the parameter passing. In order to test this,\n// we sometime would like to use a deterministic RNG so that we can get the same\n// signatures during testing. The easiest way to do this for most schemes is to\n// pass in a deterministic RNG and let it return canned values during testing.\n// There is a competing need for a canned parameter to use in ECDAA. To accommodate\n// both needs with minimal fuss, a special type of RAND_STATE is defined to carry\n// the address of the commit value. The setup and handling of this is not very\n// different for the caller than what was in previous versions of the code.\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME            'scheme' is not supported\nLIB_EXPORT TPM_RC CryptEccSign(TPMT_SIGNATURE* signature,  // OUT: signature\n\t\t\t       OBJECT* signKey,  // IN: ECC key to sign the hash\n\t\t\t       const TPM2B_DIGEST* digest,  // IN: digest to sign\n\t\t\t       TPMT_ECC_SCHEME*    scheme,  // IN: signing scheme\n\t\t\t       RAND_STATE*         rand)\n{\n    CRYPT_CURVE_INITIALIZED(E, signKey->publicArea.parameters.eccDetail.curveID);\n    CRYPT_ECC_INITIALIZED(bnD, &signKey->sensitive.sensitive.ecc.b);\n    CRYPT_ECC_NUM(bnR);\n    CRYPT_ECC_NUM(bnS);\n    TPM_RC retVal = TPM_RC_SCHEME;\n    //\n    NOT_REFERENCED(scheme);\n    if(E == NULL)\n\tERROR_EXIT(TPM_RC_VALUE);\n    signature->signature.ecdaa.signatureR.t.size =\n\tsizeof(signature->signature.ecdaa.signatureR.t.buffer);\n    signature->signature.ecdaa.signatureS.t.size =\n\tsizeof(signature->signature.ecdaa.signatureS.t.buffer);\n    TPM_DO_SELF_TEST(signature->sigAlg);\n    switch(signature->sigAlg)\n\t{\n\t  case TPM_ALG_ECDSA:\n\t    retVal = TpmEcc_SignEcdsa(bnR, bnS, E, bnD, digest, rand);\n\t    break;\n#  if ALG_ECDAA\n\t  case TPM_ALG_ECDAA:\n\t    retVal = TpmEcc_SignEcdaa(&signature->signature.ecdaa.signatureR,\n\t\t\t\t      bnS,\n\t\t\t\t      E,\n\t\t\t\t      bnD,\n\t\t\t\t      digest,\n\t\t\t\t      scheme,\n\t\t\t\t      signKey,\n\t\t\t\t      rand);\n\t    bnR    = NULL;\n\t    break;\n#  endif\n#  if ALG_ECSCHNORR\n\t  case TPM_ALG_ECSCHNORR:\n\t    retVal = TpmEcc_SignEcSchnorr(\n\t\t\t\t\t  bnR, bnS, E, bnD, digest, signature->signature.ecschnorr.hash, rand);\n\t    break;\n#  endif\n#  if ALG_SM2\n\t  case TPM_ALG_SM2:\n\t    retVal = TpmEcc_SignEcSm2(bnR, bnS, E, bnD, digest, rand);\n\t    break;\n#  endif\n\t  default:\n\t    break;\n\t}\n    // If signature generation worked, convert the results.\n    if(retVal == TPM_RC_SUCCESS)\n\t{\n\t    NUMBYTES orderBytes = (NUMBYTES)BITS_TO_BYTES(\n\t\t\t\t\t\t\t  ExtMath_SizeInBits(ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E))));\n\t    if(bnR != NULL)\n\t\tTpmMath_IntTo2B(\n\t\t\t\tbnR, &signature->signature.ecdaa.signatureR.b, orderBytes);\n\t    if(bnS != NULL)\n\t\tTpmMath_IntTo2B(\n\t\t\t\tbnS, &signature->signature.ecdaa.signatureS.b, orderBytes);\n\t}\n Exit:\n    CRYPT_CURVE_FREE(E);\n    return retVal;\n}\n\n//********************* Signature Validation   ********************\n\n//*** CryptEccValidateSignature()\n// This function validates an EcDsa or EcSchnorr signature.\n// The point 'Qin' needs to have been validated to be on the curve of 'curveId'.\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE            not a valid signature\nLIB_EXPORT TPM_RC CryptEccValidateSignature(\n\t\t\t\t\t    TPMT_SIGNATURE*     signature,  // IN: signature to be verified\n\t\t\t\t\t    OBJECT*             signKey,    // IN: ECC key signed the hash\n\t\t\t\t\t    const TPM2B_DIGEST* digest      // IN: digest that was signed\n\t\t\t\t\t    )\n{\n    CRYPT_CURVE_INITIALIZED(E, signKey->publicArea.parameters.eccDetail.curveID);\n    CRYPT_ECC_NUM(bnR);\n    CRYPT_ECC_NUM(bnS);\n    CRYPT_POINT_INITIALIZED(ecQ, &signKey->publicArea.unique.ecc);\n    const Crypt_Int* order;\n    TPM_RC           retVal;\n\n    if(E == NULL)\n\tERROR_EXIT(TPM_RC_VALUE);\n\n    order = ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E));\n\n    //    // Make sure that the scheme is valid\n    switch(signature->sigAlg)\n\t{\n\t  case TPM_ALG_ECDSA:\n#  if ALG_ECSCHNORR\n\t  case TPM_ALG_ECSCHNORR:\n#  endif\n#  if ALG_SM2\n\t  case TPM_ALG_SM2:\n#  endif\n\t    break;\n\t  default:\n\t    ERROR_EXIT(TPM_RC_SCHEME);\n\t    break;\n\t}\n    // Can convert r and s after determining that the scheme is an ECC scheme. If\n    // this conversion doesn't work, it means that the unmarshaling code for\n    // an ECC signature is broken.\n    TpmMath_IntFrom2B(bnR, &signature->signature.ecdsa.signatureR.b);\n    TpmMath_IntFrom2B(bnS, &signature->signature.ecdsa.signatureS.b);\n\n    // r and s have to be greater than 0 but less than the curve order\n    if(ExtMath_IsZero(bnR) || ExtMath_IsZero(bnS))\n\tERROR_EXIT(TPM_RC_SIGNATURE);\n    if((ExtMath_UnsignedCmp(bnS, order) >= 0)\n       || (ExtMath_UnsignedCmp(bnR, order) >= 0))\n\tERROR_EXIT(TPM_RC_SIGNATURE);\n\n    switch(signature->sigAlg)\n\t{\n\t  case TPM_ALG_ECDSA:\n\t    retVal = TpmEcc_ValidateSignatureEcdsa(bnR, bnS, E, ecQ, digest);\n\t    break;\n\n#  if ALG_ECSCHNORR\n\t  case TPM_ALG_ECSCHNORR:\n\t    retVal = TpmEcc_ValidateSignatureEcSchnorr(\n\t\t\t\t\t\t       bnR, bnS, signature->signature.any.hashAlg, E, ecQ, digest);\n\t    break;\n#  endif\n#  if ALG_SM2\n\t  case TPM_ALG_SM2:\n\t    retVal = TpmEcc_ValidateSignatureEcSm2(bnR, bnS, E, ecQ, digest);\n\t    break;\n#  endif\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t}\n Exit:\n    CRYPT_CURVE_FREE(E);\n    return retVal;\n}\n\n//***CryptEccCommitCompute()\n// This function performs the point multiply operations required by TPM2_Commit.\n//\n// If 'B' or 'M' is provided, they must be on the curve defined by 'curveId'. This\n// routine does not check that they are on the curve and results are unpredictable\n// if they are not.\n//\n// It is a fatal error if 'r' is NULL. If 'B' is not NULL, then it is a\n// fatal error if 'd' is NULL or if 'K' and 'L' are both NULL.\n// If 'M' is not NULL, then it is a fatal error if 'E' is NULL.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        if 'K', 'L' or 'E' was computed to be the point\n//                              at infinity\n//      TPM_RC_CANCELED         a cancel indication was asserted during this\n//                              function\nLIB_EXPORT TPM_RC CryptEccCommitCompute(\n\t\t\t\t\tTPMS_ECC_POINT*      K,        // OUT: [d]B or [r]Q\n\t\t\t\t\tTPMS_ECC_POINT*      L,        // OUT: [r]B\n\t\t\t\t\tTPMS_ECC_POINT*      E,        // OUT: [r]M\n\t\t\t\t\tTPM_ECC_CURVE        curveId,  // IN: the curve for the computations\n\t\t\t\t\tTPMS_ECC_POINT*      M,        // IN: M (optional)\n\t\t\t\t\tTPMS_ECC_POINT*      B,        // IN: B (optional)\n\t\t\t\t\tTPM2B_ECC_PARAMETER* d,        // IN: d (optional)\n\t\t\t\t\tTPM2B_ECC_PARAMETER* r         // IN: the computed r value (required)\n\t\t\t\t\t)\n{\n    // Normally initialize E as the curve, but\n    // E means something else in this function\n    CRYPT_CURVE_INITIALIZED(curve, curveId);\n    CRYPT_ECC_INITIALIZED(bnR, r);\n    TPM_RC retVal = TPM_RC_SUCCESS;\n    //\n    // Validate that the required parameters are provided.\n    // Note: E has to be provided if computing E := [r]Q or E := [r]M. Will do\n    // E := [r]Q if both M and B are NULL.\n    pAssert(r != NULL && E != NULL);\n\n    // Initialize the output points in case they are not computed\n    ClearPoint2B(K);\n    ClearPoint2B(L);\n    ClearPoint2B(E);\n\n    // Sizes of the r parameter may not be zero\n    pAssert(r->t.size > 0);\n\n    // If B is provided, compute K=[d]B and L=[r]B\n    if(B != NULL)\n\t{\n\t    CRYPT_ECC_INITIALIZED(bnD, d);\n\t    CRYPT_POINT_INITIALIZED(pB, B);\n\t    CRYPT_POINT_VAR(pK);\n\t    CRYPT_POINT_VAR(pL);\n\t    //\n\t    pAssert(d != NULL && K != NULL && L != NULL);\n\n\t    if(!ExtEcc_IsPointOnCurve(pB, curve))\n\t\tERROR_EXIT(TPM_RC_VALUE);\n\t    // do the math for K = [d]B\n\t    if((retVal = TpmEcc_PointMult(pK, pB, bnD, NULL, NULL, curve))\n\t       != TPM_RC_SUCCESS)\n\t\tgoto Exit;\n\t    // Convert BN K to TPM2B K\n\t    TpmEcc_PointTo2B(K, pK, curve);\n\t    //  compute L= [r]B after checking for cancel\n\t    if(_plat__IsCanceled())\n\t\tERROR_EXIT(TPM_RC_CANCELED);\n\t    // compute L = [r]B\n\t    if(!TpmEcc_IsValidPrivateEcc(bnR, curve))\n\t\tERROR_EXIT(TPM_RC_VALUE);\n\t    if((retVal = TpmEcc_PointMult(pL, pB, bnR, NULL, NULL, curve))\n\t       != TPM_RC_SUCCESS)\n\t\tgoto Exit;\n\t    // Convert BN L to TPM2B L\n\t    TpmEcc_PointTo2B(L, pL, curve);\n\t}\n    if((M != NULL) || (B == NULL))\n\t{\n\t    CRYPT_POINT_INITIALIZED(pM, M);\n\t    CRYPT_POINT_VAR(pE);\n\t    //\n\t    // Make sure that a place was provided for the result\n\t    pAssert(E != NULL);\n\n\t    // if this is the third point multiply, check for cancel first\n\t    if((B != NULL) && _plat__IsCanceled())\n\t\tERROR_EXIT(TPM_RC_CANCELED);\n\n\t    // If M provided, then pM will not be NULL and will compute E = [r]M.\n\t    // However, if M was not provided, then pM will be NULL and E = [r]G\n\t    // will be computed\n\t    if((retVal = TpmEcc_PointMult(pE, pM, bnR, NULL, NULL, curve))\n\t       != TPM_RC_SUCCESS)\n\t\tgoto Exit;\n\t    // Convert E to 2B format\n\t    TpmEcc_PointTo2B(E, pE, curve);\n\t}\n Exit:\n    CRYPT_CURVE_FREE(curve);\n    return retVal;\n}\n\n#endif  // ALG_ECC\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptHash.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tImplementation of cryptographic functions for hashing.\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n//\n// This file contains implementation of cryptographic functions for hashing.\n//\n//** Includes, Defines, and Types\n\n#define _CRYPT_HASH_C_\n#include \"Tpm.h\"\n#include \"CryptHash_fp.h\"\n#include \"CryptHash.h\"\n#include \"OIDs.h\"\n\n// Instance each of the hash descriptors based on the implemented algorithms\nFOR_EACH_HASH(HASH_DEF_TEMPLATE)\n// Instance a 'null' def.\n     HASH_DEF NULL_Def = {{0}};\n\n// Create a table of pointers to the defined hash definitions\n#define HASH_DEF_ENTRY(HASH, Hash) &Hash##_Def,\nPHASH_DEF HashDefArray[] = {\n    // for each implemented HASH, expands to: &HASH_Def,\n    FOR_EACH_HASH(HASH_DEF_ENTRY) & NULL_Def};\n#undef HASH_DEF_ENTRY\n\n//** Obligatory Initialization Functions\n\n//*** CryptHashInit()\n// This function is called by _TPM_Init do perform the initialization operations for\n// the library.\nBOOL CryptHashInit(void)\n{\n    LibHashInit();\n    return TRUE;\n}\n\n//*** CryptHashStartup()\n// This function is called by TPM2_Startup(). It checks that the size of the\n// HashDefArray is consistent with the HASH_COUNT.\nBOOL CryptHashStartup(void)\n{\n    int i = sizeof(HashDefArray) / sizeof(PHASH_DEF) - 1;\n    return (i == HASH_COUNT);\n}\n\n//** Hash Information Access Functions\n//*** Introduction\n// These functions provide access to the hash algorithm description information.\n\n//*** CryptGetHashDef()\n// This function accesses the hash descriptor associated with a hash a\n// algorithm. The function returns a pointer to a 'null' descriptor if hashAlg is\n// TPM_ALG_NULL or not a defined algorithm.\nPHASH_DEF\nCryptGetHashDef(TPM_ALG_ID hashAlg)\n{\n#define GET_DEF(HASH, Hash)\t       \\\n    case ALG_##HASH##_VALUE:\t       \\\n      return &Hash##_Def;\n    switch(hashAlg)\n\t{\n\t    FOR_EACH_HASH(GET_DEF)\n\t  default:\n\t    return &NULL_Def;\n\t}\n#undef GET_DEF\n}\n\n//*** CryptHashIsValidAlg()\n// This function tests to see if an algorithm ID is a valid hash algorithm. If\n// flag is true, then TPM_ALG_NULL is a valid hash.\n//  Return Type: BOOL\n//      TRUE(1)         hashAlg is a valid, implemented hash on this TPM\n//      FALSE(0)        hashAlg is not valid for this TPM\nBOOL CryptHashIsValidAlg(TPM_ALG_ID hashAlg,  // IN: the algorithm to check\n\t\t\t BOOL       flag  // IN: TRUE if TPM_ALG_NULL is to be treated\n\t\t\t //     as a valid hash\n\t\t\t )\n{\n    if(hashAlg == TPM_ALG_NULL)\n\treturn flag;\n    return CryptGetHashDef(hashAlg) != &NULL_Def;\n}\n\n//*** CryptHashGetAlgByIndex()\n// This function is used to iterate through the hashes. TPM_ALG_NULL\n// is returned for all indexes that are not valid hashes.\n// If the TPM implements 3 hashes, then an 'index' value of 0 will\n// return the first implemented hash and an 'index' of 2 will return the\n// last. All other index values will return TPM_ALG_NULL.\n//\n//  Return Type: TPM_ALG_ID\n// TPM_ALG_xxx         a hash algorithm\n// TPM_ALG_NULL        this can be used as a stop value\nLIB_EXPORT TPM_ALG_ID CryptHashGetAlgByIndex(UINT32 index  // IN: the index\n\t\t\t\t\t     )\n{\n    TPM_ALG_ID hashAlg;\n    if(index >= HASH_COUNT)\n\thashAlg = TPM_ALG_NULL;\n    else\n\thashAlg = HashDefArray[index]->hashAlg;\n    return hashAlg;\n}\n\n//*** CryptHashGetDigestSize()\n// Returns the size of the digest produced by the hash. If 'hashAlg' is not a hash\n// algorithm, the TPM will FAIL.\n//  Return Type: UINT16\n//   0       TPM_ALG_NULL\n//   > 0     the digest size\n//\nLIB_EXPORT UINT16 CryptHashGetDigestSize(\n\t\t\t\t\t TPM_ALG_ID hashAlg  // IN: hash algorithm to look up\n\t\t\t\t\t )\n{\n    return CryptGetHashDef(hashAlg)->digestSize;\n}\n\n//*** CryptHashGetBlockSize()\n// Returns the size of the block used by the hash. If 'hashAlg' is not a hash\n// algorithm, the TPM will FAIL.\n//  Return Type: UINT16\n//   0       TPM_ALG_NULL\n//   > 0     the digest size\n//\nLIB_EXPORT UINT16 CryptHashGetBlockSize(\n\t\t\t\t\tTPM_ALG_ID hashAlg  // IN: hash algorithm to look up\n\t\t\t\t\t)\n{\n    return CryptGetHashDef(hashAlg)->blockSize;\n}\n\n//*** CryptHashGetOid()\n// This function returns a pointer to DER=encoded OID for a hash algorithm. All OIDs\n// are full OID values including the Tag (0x06) and length byte.\nLIB_EXPORT const BYTE* CryptHashGetOid(TPM_ALG_ID hashAlg)\n{\n    return CryptGetHashDef(hashAlg)->OID;\n}\n\n//***  CryptHashGetContextAlg()\n// This function returns the hash algorithm associated with a hash context.\nTPM_ALG_ID\nCryptHashGetContextAlg(PHASH_STATE state  // IN: the context to check\n\t\t       )\n{\n    return state->hashAlg;\n}\n\n//** State Import and Export\n\n//*** CryptHashCopyState\n// This function is used to clone a HASH_STATE.\nLIB_EXPORT void CryptHashCopyState(HASH_STATE* out,  // OUT: destination of the state\n\t\t\t\t   const HASH_STATE* in  // IN: source of the state\n\t\t\t\t   )\n{\n    pAssert(out->type == in->type);\n    out->hashAlg = in->hashAlg;\n    out->def     = in->def;\n    if(in->hashAlg != TPM_ALG_NULL)\n\t{\n\t    HASH_STATE_COPY(out, in);\n\t}\n    if(in->type == HASH_STATE_HMAC)\n\t{\n\t    const HMAC_STATE* hIn  = (HMAC_STATE*)in;\n\t    HMAC_STATE*       hOut = (HMAC_STATE*)out;\n\t    hOut->hmacKey          = hIn->hmacKey;\n\t}\n    return;\n}\n\n//*** CryptHashExportState()\n// This function is used to export a hash or HMAC hash state. This function\n// would be called when preparing to context save a sequence object.\nvoid CryptHashExportState(\n\t\t\t  PCHASH_STATE internalFmt,       // IN: the hash state formatted for use by\n\t\t\t  //     library\n\t\t\t  PEXPORT_HASH_STATE externalFmt  // OUT: the exported hash state\n\t\t\t  )\n{\n    BYTE* outBuf = (BYTE*)externalFmt;\n    //\n    MUST_BE(sizeof(HASH_STATE) <= sizeof(EXPORT_HASH_STATE));\n    // the following #define is used to move data from an aligned internal data\n    // structure to a byte buffer (external format data.\n#define CopyToOffset(value)\t\t\t\t   \\\n    memcpy(&outBuf[offsetof(HASH_STATE, value)],\t\t\t\\\n\t   &internalFmt->value,\t\t\t\t\t\t\\\n\t   sizeof(internalFmt->value))\n    // Copy the hashAlg\n    CopyToOffset(hashAlg);\n    CopyToOffset(type);\n#ifdef HASH_STATE_SMAC\n    if(internalFmt->type == HASH_STATE_SMAC)\n\t{\n\t    memcpy(outBuf, internalFmt, sizeof(HASH_STATE));\n\t    return;\n\t}\n#endif\n    if(internalFmt->type == HASH_STATE_HMAC)\n\t{\n\t    HMAC_STATE* from = (HMAC_STATE*)internalFmt;\n\t    memcpy(&outBuf[offsetof(HMAC_STATE, hmacKey)],\n\t\t   &from->hmacKey,\n\t\t   sizeof(from->hmacKey));\n\t}\n    if(internalFmt->hashAlg != TPM_ALG_NULL)\n\tHASH_STATE_EXPORT(externalFmt, internalFmt);\n}\n\n//*** CryptHashImportState()\n// This function is used to import the hash state. This function\n// would be called to import a hash state when the context of a sequence object\n// was being loaded.\nvoid CryptHashImportState(\n\t\t\t  PHASH_STATE internalFmt,         // OUT: the hash state formatted for use by\n\t\t\t  //     the library\n\t\t\t  PCEXPORT_HASH_STATE externalFmt  // IN: the exported hash state\n\t\t\t  )\n{\n    BYTE* inBuf = (BYTE*)externalFmt;\n    //\n#define CopyFromOffset(value)\t\t\t\t  \\\n    memcpy(&internalFmt->value,\t\t\t\t\t       \\\n\t   &inBuf[offsetof(HASH_STATE, value)],\t\t\t       \\\n\t   sizeof(internalFmt->value))\n\n    // Copy the hashAlg of the byte-aligned input structure to the structure-aligned\n    // internal structure.\n    CopyFromOffset(hashAlg);\n    CopyFromOffset(type);\n    if(internalFmt->hashAlg != TPM_ALG_NULL)\n\t{\n#ifdef HASH_STATE_SMAC\n\t    if(internalFmt->type == HASH_STATE_SMAC)\n\t\t{\n\t\t    memcpy(internalFmt, inBuf, sizeof(HASH_STATE));\n\t\t    return;\n\t\t}\n#endif\n\t    internalFmt->def = CryptGetHashDef(internalFmt->hashAlg);\n\t    HASH_STATE_IMPORT(internalFmt, inBuf);\n\t    if(internalFmt->type == HASH_STATE_HMAC)\n\t\t{\n\t\t    HMAC_STATE* to = (HMAC_STATE*)internalFmt;\n\t\t    memcpy(&to->hmacKey,\n\t\t\t   &inBuf[offsetof(HMAC_STATE, hmacKey)],\n\t\t\t   sizeof(to->hmacKey));\n\t\t}\n\t}\n}\n\n//** State Modification Functions\n\n//***HashEnd()\n// Local function to complete a hash that uses the hashDef instead of an algorithm\n// ID. This function is used to complete the hash and only return a partial digest.\n// The return value is the size of the data copied.\nstatic UINT16 HashEnd(PHASH_STATE hashState,  // IN: the hash state\n\t\t      UINT32      dOutSize,   // IN: the size of receive buffer\n\t\t      PBYTE       dOut        // OUT: the receive buffer\n\t\t      )\n{\n    BYTE temp[MAX_DIGEST_SIZE];\n    if((hashState->hashAlg == TPM_ALG_NULL) || (hashState->type != HASH_STATE_HASH))\n\tdOutSize = 0;\n    if(dOutSize > 0)\n\t{\n\t    hashState->def = CryptGetHashDef(hashState->hashAlg);\n\t    // Set the final size\n\t    dOutSize = MIN(dOutSize, hashState->def->digestSize);\n\t    // Complete into the temp buffer and then copy\n\t    HASH_END(hashState, temp);\n\t    // Don't want any other functions calling the HASH_END method\n\t    // directly.\n#undef HASH_END\n\t    memcpy(dOut, &temp, dOutSize);\n\t}\n    hashState->type = HASH_STATE_EMPTY;\n    return (UINT16)dOutSize;\n}\n\n//*** CryptHashStart()\n// Functions starts a hash stack\n// Start a hash stack and returns the digest size. As a side effect, the\n// value of 'stateSize' in hashState is updated to indicate the number of bytes\n// of state that were saved. This function calls GetHashServer() and that function\n// will put the TPM into failure mode if the hash algorithm is not supported.\n//\n// This function does not use the sequence parameter. If it is necessary to import\n// or export context, this will start the sequence in a local state\n// and export the state to the input buffer. Will need to add a flag to the state\n// structure to indicate that it needs to be imported before it can be used.\n// (BLEH).\n//  Return Type: UINT16\n//  0           hash is TPM_ALG_NULL\n// >0           digest size\nLIB_EXPORT UINT16 CryptHashStart(\n\t\t\t\t PHASH_STATE hashState,  // OUT: the running hash state\n\t\t\t\t TPM_ALG_ID  hashAlg     // IN: hash algorithm\n\t\t\t\t )\n{\n    UINT16 retVal;\n\n    TPM_DO_SELF_TEST(hashAlg);\n\n    hashState->hashAlg = hashAlg;\n    if(hashAlg == TPM_ALG_NULL)\n\t{\n\t    retVal = 0;\n\t}\n    else\n\t{\n\t    hashState->def = CryptGetHashDef(hashAlg);\n\t    HASH_START(hashState);\n\t    retVal = hashState->def->digestSize;\n\t}\n#undef HASH_START\n    hashState->type = HASH_STATE_HASH;\n    return retVal;\n}\n\n//*** CryptDigestUpdate()\n// Add data to a hash or HMAC, SMAC stack.\n//\nvoid CryptDigestUpdate(PHASH_STATE hashState,  // IN: the hash context information\n\t\t       UINT32      dataSize,   // IN: the size of data to be added\n\t\t       const BYTE* data        // IN: data to be hashed\n\t\t       )\n{\n    if(hashState->hashAlg != TPM_ALG_NULL)\n\t{\n\t    if((hashState->type == HASH_STATE_HASH)\n\t       || (hashState->type == HASH_STATE_HMAC))\n\t\tHASH_DATA(hashState, dataSize, (BYTE*)data);\n#if SMAC_IMPLEMENTED\n\t    else if(hashState->type == HASH_STATE_SMAC)\n\t\t(hashState->state.smac.smacMethods.data)(\n\t\t\t\t\t\t\t &hashState->state.smac.state, dataSize, data);\n#endif  // SMAC_IMPLEMENTED\n\t    else\n\t\tFAIL(FATAL_ERROR_INTERNAL);\n\t}\n    return;\n}\n\n//*** CryptHashEnd()\n// Complete a hash or HMAC computation. This function will place the smaller of\n// 'digestSize' or the size of the digest in 'dOut'. The number of bytes in the\n// placed in the buffer is returned. If there is a failure, the returned value\n// is <= 0.\n//  Return Type: UINT16\n//       0      no data returned\n//      > 0     the number of bytes in the digest or dOutSize, whichever is smaller\nLIB_EXPORT UINT16 CryptHashEnd(PHASH_STATE hashState,  // IN: the state of hash stack\n\t\t\t       UINT32      dOutSize,   // IN: size of digest buffer\n\t\t\t       BYTE*       dOut        // OUT: hash digest\n\t\t\t       )\n{\n    pAssert(hashState->type == HASH_STATE_HASH);\n    return HashEnd(hashState, dOutSize, dOut);\n}\n\n//*** CryptHashBlock()\n// Start a hash, hash a single block, update 'digest' and return the size of\n// the results.\n//\n// The 'digestSize' parameter can be smaller than the digest. If so, only the more\n// significant bytes are returned.\n//  Return Type: UINT16\n//  >= 0        number of bytes placed in 'dOut'\nLIB_EXPORT UINT16 CryptHashBlock(TPM_ALG_ID  hashAlg,   // IN: The hash algorithm\n\t\t\t\t UINT32      dataSize,  // IN: size of buffer to hash\n\t\t\t\t const BYTE* data,      // IN: the buffer to hash\n\t\t\t\t UINT32 dOutSize,  // IN: size of the digest buffer\n\t\t\t\t BYTE*  dOut       // OUT: digest buffer\n\t\t\t\t )\n{\n    HASH_STATE state;\n    CryptHashStart(&state, hashAlg);\n    CryptDigestUpdate(&state, dataSize, data);\n    return HashEnd(&state, dOutSize, dOut);\n}\n\n//*** CryptDigestUpdate2B()\n// This function updates a digest (hash or HMAC) with a TPM2B.\n//\n// This function can be used for both HMAC and hash functions so the\n// 'digestState' is void so that either state type can be passed.\nLIB_EXPORT void CryptDigestUpdate2B(PHASH_STATE  state,  // IN: the digest state\n\t\t\t\t    const TPM2B* bIn     // IN: 2B containing the data\n\t\t\t\t    )\n{\n    // Only compute the digest if a pointer to the 2B is provided.\n    // In CryptDigestUpdate(), if size is zero or buffer is NULL, then no change\n    // to the digest occurs. This function should not provide a buffer if bIn is\n    // not provided.\n    pAssert(bIn != NULL);\n    CryptDigestUpdate(state, bIn->size, bIn->buffer);\n    return;\n}\n\n//*** CryptHashEnd2B()\n// This function is the same as CryptCompleteHash() but the digest is\n// placed in a TPM2B. This is the most common use and this is provided\n// for specification clarity. 'digest.size' should be set to indicate the number of\n// bytes to place in the buffer\n//  Return Type: UINT16\n//      >=0     the number of bytes placed in 'digest.buffer'\nLIB_EXPORT UINT16 CryptHashEnd2B(\n\t\t\t\t PHASH_STATE state,  // IN: the hash state\n\t\t\t\t P2B         digest  // IN: the size of the buffer Out: requested\n\t\t\t\t //     number of bytes\n\t\t\t\t )\n{\n    return CryptHashEnd(state, digest->size, digest->buffer);\n}\n\n//*** CryptDigestUpdateInt()\n// This function is used to include an integer value to a hash stack. The function\n// marshals the integer into its canonical form before calling CryptDigestUpdate().\nLIB_EXPORT void CryptDigestUpdateInt(\n\t\t\t\t     void*  state,    // IN: the state of hash stack\n\t\t\t\t     UINT32 intSize,  // IN: the size of 'intValue' in bytes\n\t\t\t\t     UINT64 intValue  // IN: integer value to be hashed\n\t\t\t\t     )\n{\n#if LITTLE_ENDIAN_TPM\n    intValue = REVERSE_ENDIAN_64(intValue);\n#endif\n    CryptDigestUpdate(state, intSize, &((BYTE*)&intValue)[8 - intSize]);\n}\n\n//** HMAC Functions\n\n//*** CryptHmacStart()\n// This function is used to start an HMAC using a temp\n// hash context. The function does the initialization\n// of the hash with the HMAC key XOR iPad and updates the\n// HMAC key XOR oPad.\n//\n// The function returns the number of bytes in a digest produced by 'hashAlg'.\n//  Return Type: UINT16\n//  >= 0        number of bytes in digest produced by 'hashAlg' (may be zero)\n//\nLIB_EXPORT UINT16 CryptHmacStart(PHMAC_STATE state,    // IN/OUT: the state buffer\n\t\t\t\t TPM_ALG_ID  hashAlg,  // IN: the algorithm to use\n\t\t\t\t UINT16      keySize,  // IN: the size of the HMAC key\n\t\t\t\t const BYTE* key       // IN: the HMAC key\n\t\t\t\t )\n{\n    PHASH_DEF hashDef;\n    BYTE*     pb;\n    UINT32    i;\n    //\n    hashDef = CryptGetHashDef(hashAlg);\n    if(hashDef->digestSize != 0)\n\t{\n\t    // If the HMAC key is larger than the hash block size, it has to be reduced\n\t    // to fit. The reduction is a digest of the hashKey.\n\t    if(keySize > hashDef->blockSize)\n\t\t{\n\t\t    // if the key is too big, reduce it to a digest of itself\n\t\t    state->hmacKey.t.size = CryptHashBlock(\n\t\t\t\t\t\t\t   hashAlg, keySize, key, hashDef->digestSize, state->hmacKey.t.buffer);\n\t\t}\n\t    else\n\t\t{\n\t\t    memcpy(state->hmacKey.t.buffer, key, keySize);\n\t\t    state->hmacKey.t.size = keySize;\n\t\t}\n\t    // XOR the key with iPad (0x36)\n\t    pb = state->hmacKey.t.buffer;\n\t    for(i = state->hmacKey.t.size; i > 0; i--)\n\t\t*pb++ ^= 0x36;\n\n\t    // if the keySize is smaller than a block, fill the rest with 0x36\n\t    for(i = hashDef->blockSize - state->hmacKey.t.size; i > 0; i--)\n\t\t*pb++ = 0x36;\n\n\t    // Increase the oPadSize to a full block\n\t    state->hmacKey.t.size = hashDef->blockSize;\n\n\t    // Start a new hash with the HMAC key\n\t    // This will go in the caller's state structure and may be a sequence or not\n\t    CryptHashStart((PHASH_STATE)state, hashAlg);\n\t    CryptDigestUpdate(\n\t\t\t      (PHASH_STATE)state, state->hmacKey.t.size, state->hmacKey.t.buffer);\n\t    // XOR the key block with 0x5c ^ 0x36\n\t    for(pb = state->hmacKey.t.buffer, i = hashDef->blockSize; i > 0; i--)\n\t\t*pb++ ^= (0x5c ^ 0x36);\n\t}\n    // Set the hash algorithm\n    state->hashState.hashAlg = hashAlg;\n    // Set the hash state type\n    state->hashState.type = HASH_STATE_HMAC;\n\n    return hashDef->digestSize;\n}\n\n//*** CryptHmacEnd()\n// This function is called to complete an HMAC. It will finish the current\n// digest, and start a new digest. It will then add the oPadKey and the\n// completed digest and return the results in dOut. It will not return more\n// than dOutSize bytes.\n//  Return Type: UINT16\n//  >= 0        number of bytes in 'dOut' (may be zero)\nLIB_EXPORT UINT16 CryptHmacEnd(PHMAC_STATE state,     // IN: the hash state buffer\n\t\t\t       UINT32      dOutSize,  // IN: size of digest buffer\n\t\t\t       BYTE*       dOut       // OUT: hash digest\n\t\t\t       )\n{\n    BYTE        temp[MAX_DIGEST_SIZE];\n    PHASH_STATE hState = (PHASH_STATE)&state->hashState;\n\n#if SMAC_IMPLEMENTED\n    if(hState->type == HASH_STATE_SMAC)\n\treturn (state->hashState.state.smac.smacMethods.end)(\n\t\t\t\t\t\t\t     &state->hashState.state.smac.state, dOutSize, dOut);\n#endif\n    pAssert(hState->type == HASH_STATE_HMAC);\n    hState->def = CryptGetHashDef(hState->hashAlg);\n    // Change the state type for completion processing\n    hState->type = HASH_STATE_HASH;\n    if(hState->hashAlg == TPM_ALG_NULL)\n\tdOutSize = 0;\n    else\n\t{\n\t    // Complete the current hash\n\t    HashEnd(hState, hState->def->digestSize, temp);\n\t    // Do another hash starting with the oPad\n\t    CryptHashStart(hState, hState->hashAlg);\n\t    CryptDigestUpdate(hState, state->hmacKey.t.size, state->hmacKey.t.buffer);\n\t    CryptDigestUpdate(hState, hState->def->digestSize, temp);\n\t}\n    return HashEnd(hState, dOutSize, dOut);\n}\n\n//*** CryptHmacStart2B()\n// This function starts an HMAC and returns the size of the digest\n// that will be produced.\n//\n// This function is provided to support the most common use of starting an HMAC\n// with a TPM2B key.\n//\n// The caller must provide a block of memory in which the hash sequence state\n// is kept.  The caller should not alter the contents of this buffer until the\n// hash sequence is completed or abandoned.\n//\n//  Return Type: UINT16\n//      > 0     the digest size of the algorithm\n//      = 0     the hashAlg was TPM_ALG_NULL\nLIB_EXPORT UINT16 CryptHmacStart2B(\n\t\t\t\t   PHMAC_STATE hmacState,  // OUT: the state of HMAC stack. It will be used\n\t\t\t\t   //     in HMAC update and completion\n\t\t\t\t   TPMI_ALG_HASH hashAlg,  // IN: hash algorithm\n\t\t\t\t   P2B           key       // IN: HMAC key\n\t\t\t\t   )\n{\n    return CryptHmacStart(hmacState, hashAlg, key->size, key->buffer);\n}\n\n//*** CryptHmacEnd2B()\n//   This function is the same as CryptHmacEnd() but the HMAC result\n//   is returned in a TPM2B which is the most common use.\n//  Return Type: UINT16\n//      >=0     the number of bytes placed in 'digest'\nLIB_EXPORT UINT16 CryptHmacEnd2B(\n\t\t\t\t PHMAC_STATE hmacState,  // IN: the state of HMAC stack\n\t\t\t\t P2B         digest      // OUT: HMAC\n\t\t\t\t )\n{\n    return CryptHmacEnd(hmacState, digest->size, digest->buffer);\n}\n\n//** Mask and Key Generation Functions\n//*** CryptMGF_KDF()\n// This function performs MGF1/KDF1 or KDF2 using the selected hash. KDF1 and KDF2 are\n// T('n') = T('n'-1) || H('seed' || 'counter') with the difference being that, with\n// KDF1, 'counter' starts at 0 but with KDF2, 'counter' starts at 1. The caller\n// determines which version by setting the initial value of counter to either 0 or 1.\n// Note: Any value that is not 0 is considered to be 1.\n//\n// This function returns the length of the mask produced which\n// could be zero if the digest algorithm is not supported\n//  Return Type: UINT16\n//      0       hash algorithm was TPM_ALG_NULL\n//    > 0       should be the same as 'mSize'\nLIB_EXPORT UINT16 CryptMGF_KDF(UINT32 mSize,  // IN: length of the mask to be produced\n\t\t\t       BYTE*  mask,   // OUT: buffer to receive the mask\n\t\t\t       TPM_ALG_ID hashAlg,   // IN: hash to use\n\t\t\t       UINT32     seedSize,  // IN: size of the seed\n\t\t\t       BYTE*      seed,      // IN: seed size\n\t\t\t       UINT32     counter    // IN: counter initial value\n\t\t\t       )\n{\n    HASH_STATE hashState;\n    PHASH_DEF  hDef = CryptGetHashDef(hashAlg);\n    UINT32     hLen;\n    UINT32     bytes;\n    //\n    // If there is no digest to compute return\n    if((hDef->digestSize == 0) || (mSize == 0))\n\treturn 0;\n    if(counter != 0)\n\tcounter = 1;\n    hLen = hDef->digestSize;\n    for(bytes = 0; bytes < mSize; bytes += hLen)\n\t{\n\t    // Start the hash and include the seed and counter\n\t    CryptHashStart(&hashState, hashAlg);\n\t    CryptDigestUpdate(&hashState, seedSize, seed);\n\t    CryptDigestUpdateInt(&hashState, 4, counter);\n\t    // Get as much as will fit.\n\t    CryptHashEnd(&hashState, MIN((mSize - bytes), hLen), &mask[bytes]);\n\t    counter++;\n\t}\n    return (UINT16)mSize;\n}\n\n//*** CryptKDFa()\n// This function performs the key generation according to Part 1 of the\n// TPM specification.\n//\n// This function returns the number of bytes generated which may be zero.\n//\n// The 'key' and 'keyStream' pointers are not allowed to be NULL. The other\n// pointer values may be NULL. The value of 'sizeInBits' must be no larger\n// than (2^18)-1 = 256K bits (32385 bytes).\n//\n// The 'once' parameter is set to allow incremental generation of a large\n// value. If this flag is TRUE, 'sizeInBits' will be used in the HMAC computation\n// but only one iteration of the KDF is performed. This would be used for\n// XOR obfuscation so that the mask value can be generated in digest-sized\n// chunks rather than having to be generated all at once in an arbitrarily\n// large buffer and then XORed into the result. If 'once' is TRUE, then\n// 'sizeInBits' must be a multiple of 8.\n//\n// Any error in the processing of this command is considered fatal.\n//  Return Type: UINT16\n//     0            hash algorithm is not supported or is TPM_ALG_NULL\n//    > 0           the number of bytes in the 'keyStream' buffer\nLIB_EXPORT UINT16 CryptKDFa(\n\t\t\t    TPM_ALG_ID   hashAlg,       // IN: hash algorithm used in HMAC\n\t\t\t    const TPM2B* key,           // IN: HMAC key\n\t\t\t    const TPM2B* label,         // IN: a label for the KDF\n\t\t\t    const TPM2B* contextU,      // IN: context U\n\t\t\t    const TPM2B* contextV,      // IN: context V\n\t\t\t    UINT32       sizeInBits,    // IN: size of generated key in bits\n\t\t\t    BYTE*        keyStream,     // OUT: key buffer\n\t\t\t    UINT32*      counterInOut,  // IN/OUT: caller may provide the iteration\n\t\t\t    //     counter for incremental operations to\n\t\t\t    //     avoid large intermediate buffers.\n\t\t\t    UINT16 blocks               // IN: If non-zero, this is the maximum number\n\t\t\t    //     of blocks to be returned, regardless\n\t\t\t    //     of sizeInBits\n\t\t\t    )\n{\n    UINT32     counter = 0;  // counter value\n    INT16      bytes;        // number of bytes to produce\n    UINT16     generated;    // number of bytes generated\n    BYTE*      stream = keyStream;\n    HMAC_STATE hState;\n    UINT16     digestSize = CryptHashGetDigestSize(hashAlg);\n\n    pAssert(key != NULL && keyStream != NULL);\n\n    TPM_DO_SELF_TEST(TPM_ALG_KDF1_SP800_108);\n\n    if(digestSize == 0)\n\treturn 0;\n\n    if(counterInOut != NULL)\n\tcounter = *counterInOut;\n\n    // If the size of the request is larger than the numbers will handle,\n    // it is a fatal error.\n    pAssert(((sizeInBits + 7) / 8) <= INT16_MAX);\n\n    // The number of bytes to be generated is the smaller of the sizeInBits bytes or\n    // the number of requested blocks. The number of blocks is the smaller of the\n    // number requested or the number allowed by sizeInBits. A partial block is\n    // a full block.\n    bytes = (blocks > 0) ? blocks * digestSize : (UINT16)BITS_TO_BYTES(sizeInBits);\n    generated = bytes;\n\n    // Generate required bytes\n    for(; bytes > 0; bytes -= digestSize)\n\t{\n\t    counter++;\n\t    // Start HMAC\n\t    if(CryptHmacStart(&hState, hashAlg, key->size, key->buffer) == 0)\n\t\treturn 0;\n\t    // Adding counter\n\t    CryptDigestUpdateInt(&hState.hashState, 4, counter);\n\n\t    // Adding label\n\t    if(label != NULL)\n\t\tHASH_DATA(&hState.hashState, label->size, (BYTE*)label->buffer);\n\t    // Add a null. SP108 is not very clear about when the 0 is needed but to\n\t    // make this like the previous version that did not add an 0x00 after\n\t    // a null-terminated string, this version will only add a null byte\n\t    // if the label parameter did not end in a null byte, or if no label\n\t    // is present.\n\t    if((label == NULL) || (label->size == 0)\n\t       || (label->buffer[label->size - 1] != 0))\n\t\tCryptDigestUpdateInt(&hState.hashState, 1, 0);\n\t    // Adding contextU\n\t    if(contextU != NULL)\n\t\tHASH_DATA(&hState.hashState, contextU->size, contextU->buffer);\n\t    // Adding contextV\n\t    if(contextV != NULL)\n\t\tHASH_DATA(&hState.hashState, contextV->size, contextV->buffer);\n\t    // Adding size in bits\n\t    CryptDigestUpdateInt(&hState.hashState, 4, sizeInBits);\n\n\t    // Complete and put the data in the buffer\n\t    CryptHmacEnd(&hState, bytes, stream);\n\t    stream = &stream[digestSize];\n\t}\n    // Masking in the KDF is disabled. If the calling function wants something\n    // less than even number of bytes, then the caller should do the masking\n    // because there is no universal way to do it here\n    if(counterInOut != NULL)\n\t*counterInOut = counter;\n    return generated;\n}\n\n//*** CryptKDFe()\n// This function implements KDFe() as defined in TPM specification part 1.\n//\n// This function returns the number of bytes generated which may be zero.\n//\n// The 'Z' and 'keyStream' pointers are not allowed to be NULL. The other\n// pointer values may be NULL. The value of 'sizeInBits' must be no larger\n// than (2^18)-1 = 256K bits (32385 bytes).\n// Any error in the processing of this command is considered fatal.\n//  Return Type: UINT16\n//     0            hash algorithm is not supported or is TPM_ALG_NULL\n//    > 0           the number of bytes in the 'keyStream' buffer\n//\nLIB_EXPORT UINT16 CryptKDFe(TPM_ALG_ID   hashAlg,  // IN: hash algorithm used in HMAC\n\t\t\t    TPM2B*       Z,        // IN: Z\n\t\t\t    const TPM2B* label,    // IN: a label value for the KDF\n\t\t\t    TPM2B*       partyUInfo,  // IN: PartyUInfo\n\t\t\t    TPM2B*       partyVInfo,  // IN: PartyVInfo\n\t\t\t    UINT32 sizeInBits,  // IN: size of generated key in bits\n\t\t\t    BYTE*  keyStream    // OUT: key buffer\n\t\t\t    )\n{\n    HASH_STATE hashState;\n    PHASH_DEF  hashDef = CryptGetHashDef(hashAlg);\n\n    UINT32     counter = 0;  // counter value\n    UINT16     hLen;\n    BYTE*      stream = keyStream;\n    INT16      bytes;  // number of bytes to generate\n\n    pAssert(keyStream != NULL && Z != NULL && ((sizeInBits + 7) / 8) < INT16_MAX);\n    //\n    hLen  = hashDef->digestSize;\n    bytes = (INT16)((sizeInBits + 7) / 8);\n    if(hashAlg == TPM_ALG_NULL || bytes == 0)\n\treturn 0;\n\n    // Generate required bytes\n    //The inner loop of that KDF uses:\n    //  Hash[i] := H(counter | Z | OtherInfo) (5)\n    // Where:\n    //  Hash[i]         the hash generated on the i-th iteration of the loop.\n    //  H()             an approved hash function\n    //  counter         a 32-bit counter that is initialized to 1 and incremented\n    //                  on each iteration\n    //  Z               the X coordinate of the product of a public ECC key and a\n    //                  different private ECC key.\n    //  OtherInfo       a collection of qualifying data for the KDF defined below.\n    //  In this specification, OtherInfo will be constructed by:\n    //      OtherInfo := Use | PartyUInfo  | PartyVInfo\n    for(; bytes > 0; stream = &stream[hLen], bytes = bytes - hLen)\n\t{\n\t    if(bytes < hLen)\n\t\thLen = bytes;\n\t    counter++;\n\t    // Do the hash\n\t    CryptHashStart(&hashState, hashAlg);\n\t    // Add counter\n\t    CryptDigestUpdateInt(&hashState, 4, counter);\n\n\t    // Add Z\n\t    if(Z != NULL)\n\t\tCryptDigestUpdate2B(&hashState, Z);\n\t    // Add label\n\t    if(label != NULL)\n\t\tCryptDigestUpdate2B(&hashState, label);\n\n\t    // NIST.SP.800-56Cr2.pdf section 4.1 states that no NULL\n\t    // character is required here.\n\t    // Note, this is different from KDFa which is specified in\n\t    // NIST.SP.800-108r1.pdf section 4 (a NULL character is required\n\t    // for that case).\n\n\t    // Add PartyUInfo\n\t    if(partyUInfo != NULL)\n\t\tCryptDigestUpdate2B(&hashState, partyUInfo);\n\n\t    // Add PartyVInfo\n\t    if(partyVInfo != NULL)\n\t\tCryptDigestUpdate2B(&hashState, partyVInfo);\n\n\t    // Compute Hash. hLen was changed to be the smaller of bytes or hLen\n\t    // at the start of each iteration.\n\t    CryptHashEnd(&hashState, hLen, stream);\n\t}\n\n    // Mask off bits if the required bits is not a multiple of byte size\n    if((sizeInBits % 8) != 0)\n\tkeyStream[0] &= ((1 << (sizeInBits % 8)) - 1);\n\n    return (UINT16)((sizeInBits + 7) / 8);\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptPrime.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Code for prime validation. \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the code for prime validation.\n\n#include \"Tpm.h\"\n#include \"CryptPrime_fp.h\"\n#include \"TpmMath_Util_fp.h\"\n\n//#define CPRI_PRIME\n//#include \"PrimeTable.h\"\n\n#include \"CryptPrimeSieve_fp.h\"\n\nextern const uint32_t      s_LastPrimeInTable;\nextern const uint32_t      s_PrimeTableSize;\nextern const uint32_t      s_PrimesInTable;\nextern const unsigned char s_PrimeTable[];\nextern const Crypt_Int*    s_CompositeOfSmallPrimes;\n\n//** Functions\n\n//*** Root2()\n// This finds ceil(sqrt(n)) to use as a stopping point for searching the prime\n// table.\nstatic uint32_t Root2(uint32_t n)\n{\n    int32_t last = (int32_t)(n >> 2);\n    int32_t next = (int32_t)(n >> 1);\n    int32_t diff;\n    int32_t stop = 10;\n    //\n    // get a starting point\n    for(; next != 0; last >>= 1, next >>= 2)\n\t;\n    last++;\n    do\n\t{\n\t    next = (last + (n / last)) >> 1;\n\t    diff = next - last;\n\t    last = next;\n\t    if(stop-- == 0)\n\t\tFAIL(FATAL_ERROR_INTERNAL);\n\t} while(diff < -1 || diff > 1);\n    if((n / next) > (unsigned)next)\n\tnext++;\n    pAssert(next != 0);\n    pAssert(((n / next) <= (unsigned)next) && (n / (next + 1) < (unsigned)next));\n    return next;\n}\n\n//*** IsPrimeInt()\n// This will do a test of a word of up to 32-bits in size.\nBOOL IsPrimeInt(uint32_t n)\n{\n    uint32_t i;\n    uint32_t stop;\n    if(n < 3 || ((n & 1) == 0))\n\treturn (n == 2);\n    if(n <= s_LastPrimeInTable)\n\t{\n\t    n >>= 1;\n\t    return ((s_PrimeTable[n >> 3] >> (n & 7)) & 1);\n\t}\n    // Need to search\n    stop = Root2(n) >> 1;\n    // starting at 1 is equivalent to staring at  (1 << 1) + 1 = 3\n    for(i = 1; i < stop; i++)\n\t{\n\t    if((s_PrimeTable[i >> 3] >> (i & 7)) & 1)\n\t\t// see if this prime evenly divides the number\n\t\tif((n % ((i << 1) + 1)) == 0)\n\t\t    return FALSE;\n\t}\n    return TRUE;\n}\n\n//*** TpmMath_IsProbablyPrime()\n// This function is used when the key sieve is not implemented. This function\n// Will try to eliminate some of the obvious things before going on\n// to perform MillerRabin as a final verification of primeness.\nBOOL TpmMath_IsProbablyPrime(Crypt_Int*  prime,  // IN:\n\t\t\t     RAND_STATE* rand    // IN: the random state just\n\t\t\t     //     in case Miller-Rabin is required\n\t\t\t     )\n{\n    uint32_t leastSignificant32 = ExtMath_GetLeastSignificant32bits(prime);\n    // is even?\n    if((leastSignificant32 & 0x1) == 0)\n\treturn FALSE;\n\n    if(ExtMath_SizeInBits(prime) <= 32)\n\treturn IsPrimeInt(leastSignificant32);\n\n    // this s_LastPrimeInTable check guarantees that the full prime table check\n    // is incorporated in IsPrimeInt.  If this fails then something like this\n    // old code needs to be added back.\n    // if(ExtMath_UnsignedCmpWord(prime, s_LastPrimeInTable) <= 0)\n    // {\n    //     // check fast prime table before doing slower checks\n    //     crypt_uword_t temp = prime->d[0] >> 1;\n    //     return ((s_PrimeTable[temp >> 3] >> (temp & 7)) & 1);\n    // }\n    MUST_BE(sizeof(s_LastPrimeInTable) <= 4);\n\n    // check using GCD before doing a full Miller Rabin.\n    {\n\tCRYPT_INT_VAR(gcd, LARGEST_NUMBER_BITS);\n\tExtMath_GCD(gcd, prime, s_CompositeOfSmallPrimes);\n\tif(!ExtMath_IsEqualWord(gcd, 1))\n\t    return FALSE;\n    }\n    return MillerRabin(prime, rand);\n}\n\n//*** MillerRabinRounds()\n// Function returns the number of Miller-Rabin rounds necessary to give an\n// error probability equal to the security strength of the prime. These values\n// are from FIPS 186-3.\nUINT32\nMillerRabinRounds(UINT32 bits  // IN: Number of bits in the RSA prime\n\t\t  )\n{\n    if(bits < 511)\n\treturn 8;  // don't really expect this\n    if(bits < 1536)\n\treturn 5;  // for 512 and 1K primes\n    return 4;      // for 3K public modulus and greater\n}\n\n//*** MillerRabin()\n// This function performs a Miller-Rabin test from FIPS 186-3. It does\n// 'iterations' trials on the number. In all likelihood, if the number\n// is not prime, the first test fails.\n//  Return Type: BOOL\n//      TRUE(1)         probably prime\n//      FALSE(0)        composite\nBOOL MillerRabin(Crypt_Int* bnW, RAND_STATE* rand)\n{\n    CRYPT_INT_MAX(bnWm1);\n    CRYPT_PRIME_VAR(bnM);\n    CRYPT_PRIME_VAR(bnB);\n    CRYPT_PRIME_VAR(bnZ);\n    BOOL         ret = FALSE;  // Assumed composite for easy exit\n    unsigned int a;\n    unsigned int j;\n    int          wLen;\n    int          i;\n    int          iterations = MillerRabinRounds(ExtMath_SizeInBits(bnW));\n    //\n    INSTRUMENT_INC(MillerRabinTrials[PrimeIndex]);\n\n    pAssert(bnW->size > 1);\n    // Let a be the largest integer such that 2^a divides w1.\n    ExtMath_SubtractWord(bnWm1, bnW, 1);\n    pAssert(bnWm1->size != 0);\n\n    // Since w is odd (w-1) is even so start at bit number 1 rather than 0\n    // Get the number of bits in bnWm1 so that it doesn't have to be recomputed\n    // on each iteration.\n    i = (int)(bnWm1->size * RADIX_BITS);\n    // Now find the largest power of 2 that divides w1\n    for(a = 1; (a < (bnWm1->size * RADIX_BITS)) && (ExtMath_TestBit(bnWm1, a) == 0);\n\ta++)\n\t{\n\t}\n    // 2. m = (w1) / 2^a\n    ExtMath_ShiftRight(bnM, bnWm1, a);\n    // 3. wlen = len (w).\n    wLen = ExtMath_SizeInBits(bnW);\n    // 4. For i = 1 to iterations do\n    for(i = 0; i < iterations; i++)\n\t{\n\t    // 4.1 Obtain a string b of wlen bits from an RBG.\n\t    // Ensure that 1 < b < w1.\n\t    // 4.2 If ((b <= 1) or (b >= w1)), then go to step 4.1.\n\t    while(TpmMath_GetRandomInteger(bnB, wLen, rand)\n\t\t  && ((ExtMath_UnsignedCmpWord(bnB, 1) <= 0)\n\t\t      || (ExtMath_UnsignedCmp(bnB, bnWm1) >= 0)))\n\t\t;\n\t    if(g_inFailureMode)\n\t\treturn FALSE;\n\n\t    // 4.3 z = b^m mod w.\n\t    // if ModExp fails, then say this is not\n\t    // prime and bail out.\n\t    ExtMath_ModExp(bnZ, bnB, bnM, bnW);\n\n\t    // 4.4 If ((z == 1) or (z = w == 1)), then go to step 4.7.\n\t    if((ExtMath_UnsignedCmpWord(bnZ, 1) == 0)\n\t       || (ExtMath_UnsignedCmp(bnZ, bnWm1) == 0))\n\t\tgoto step4point7;\n\t    // 4.5 For j = 1 to a  1 do.\n\t    for(j = 1; j < a; j++)\n\t\t{\n\t\t    // 4.5.1 z = z^2 mod w.\n\t\t    ExtMath_ModMult(bnZ, bnZ, bnZ, bnW);\n\t\t    // 4.5.2 If (z = w1), then go to step 4.7.\n\t\t    if(ExtMath_UnsignedCmp(bnZ, bnWm1) == 0)\n\t\t\tgoto step4point7;\n\t\t    // 4.5.3 If (z = 1), then go to step 4.6.\n\t\t    if(ExtMath_IsEqualWord(bnZ, 1))\n\t\t\tgoto step4point6;\n\t\t}\n\t    // 4.6 Return COMPOSITE.\n\tstep4point6:\n\t    INSTRUMENT_INC(failedAtIteration[i]);\n\t    goto end;\n\t    // 4.7 Continue. Comment: Increment i for the do-loop in step 4.\n\tstep4point7:\n\t    continue;\n\t}\n    // 5. Return PROBABLY PRIME\n    ret = TRUE;\n end:\n    return ret;\n}\n\n#if ALG_RSA\n\n//*** RsaCheckPrime()\n// This will check to see if a number is prime and appropriate for an\n// RSA prime.\n//\n// This has different functionality based on whether we are using key\n// sieving or not. If not, the number checked to see if it is divisible by\n// the public exponent, then the number is adjusted either up or down\n// in order to make it a better candidate. It is then checked for being\n// probably prime.\n//\n// If sieving is used, the number is used to root a sieving process.\n//\nTPM_RC\nRsaCheckPrime(Crypt_Int* prime, UINT32 exponent, RAND_STATE* rand)\n{\n#  if !RSA_KEY_SIEVE\n    TPM_RC retVal = TPM_RC_SUCCESS;\n    UINT32 modE   = ExtMath_ModWord(prime, exponent);\n\n    NOT_REFERENCED(rand);\n\n    if(modE == 0)\n\t// evenly divisible so add two keeping the number odd\n\tExtMath_AddWord(prime, prime, 2);\n    // want 0 != (p - 1) mod e\n    // which is 1 != p mod e\n    else if(modE == 1)\n\t// subtract 2 keeping number odd and insuring that\n\t// 0 != (p - 1) mod e\n\tExtMath_SubtractWord(prime, prime, 2);\n\n    if(TpmMath_IsProbablyPrime(prime, rand) == 0)\n\tERROR_EXIT(g_inFailureMode ? TPM_RC_FAILURE : TPM_RC_VALUE);\n Exit:\n    return retVal;\n#  else\n    return PrimeSelectWithSieve(prime, exponent, rand);\n#  endif\n}\n\n//*** RsaAdjustPrimeCandiate()\n//\n// For this math, we assume that the RSA numbers are fixed-point numbers with\n// the decimal point to the \"left\" of the most significant bit. This approach helps\n// make it clear what is happening with the MSb of the values.\n// The two RSA primes have to be large enough so that their product will be a number\n// with the necessary number of significant bits. For example, we want to be able\n// to multiply two 1024-bit numbers to produce a number with 2028 significant bits. If\n// we accept any 1024-bit prime that has its MSb set, then it is possible to produce a\n// product that does not have the MSb SET. For example, if we use tiny keys of 16 bits\n// and have two 8-bit 'primes' of 0x80, then the public key would be 0x4000 which is\n// only 15-bits. So, what we need to do is made sure that each of the primes is large\n// enough so that the product of the primes is twice as large as each prime. A little\n// arithmetic will show that the only way to do this is to make sure that each of the\n// primes is no less than root(2)/2. That's what this functions does.\n// This function adjusts the candidate prime so that it is odd and >= root(2)/2.\n// This allows the product of these two numbers to be .5, which, in fixed point\n// notation means that the most significant bit is 1.\n// For this routine, the root(2)/2 (0.7071067811865475) approximated with 0xB505\n// which is, in fixed point, 0.7071075439453125 or an error of 0.000108%. Just setting\n// the upper two bits would give a value > 0.75 which is an error of > 6%. Given the\n// amount of time all the other computations take, reducing the error is not much of\n// a cost, but it isn't totally required either.\n//\n// This function can be replaced with a function that just sets the two most\n// significant bits of each prime candidate without introducing any computational\n// issues.\n//\nstatic void RsaAdjustPrimeCandidate(BYTE* bigNumberBuffer, size_t bufSize)\n{\n    // first, ensure the last byte is odd, making the entire value odd\n    bigNumberBuffer[bufSize - 1] |= 1;\n\n    // second, get the most significant 32 bits.\n    uint32_t msw = (bigNumberBuffer[0] << 24) | (bigNumberBuffer[1] << 16)\n\t\t   | (bigNumberBuffer[2] << 8) | (bigNumberBuffer[3] << 0);\n\n    // Multiplying 0xff...f by 0x4AFB gives 0xff..f - 0xB5050...0\n    uint32_t adjusted = (msw >> 16) * 0x4AFB;\n    adjusted += ((msw & 0xFFFF) * 0x4AFB) >> 16;\n    adjusted += 0xB5050000UL;\n\n    // put the value back\n    bigNumberBuffer[0] = (uint8_t)(adjusted >> 24);\n    bigNumberBuffer[1] = (uint8_t)(adjusted >> 16);\n    bigNumberBuffer[2] = (uint8_t)(adjusted >> 8);\n    bigNumberBuffer[3] = (uint8_t)(adjusted >> 0);\n}\n\n//***TpmRsa_GeneratePrimeForRSA()\n// Function to generate a prime of the desired size with the proper attributes\n// for an RSA prime.\n// succeeds, or enters failure mode.\nTPM_RC TpmRsa_GeneratePrimeForRSA(\n\t\t\t\t  Crypt_Int* prime,      // IN/OUT: points to the BN that will get the\n\t\t\t\t  //  random value\n\t\t\t\t  UINT32      bits,      // IN: number of bits to get\n\t\t\t\t  UINT32      exponent,  // IN: the exponent\n\t\t\t\t  RAND_STATE* rand       // IN: the random state\n\t\t\t\t  )\n{\n    // Only try to handle specific sizes of keys.\n    // this is necessary so the RsaAdjustPrimeCandidate function works correctly.\n    pAssert((bits % 32) == 0);\n\n    // create buffer large enough for the largest key\n    TPM2B_TYPE(LARGEST, LARGEST_NUMBER);\n    TPM2B_LARGEST large;\n\n    NUMBYTES      bytes = (NUMBYTES)BITS_TO_BYTES(bits);\n    BOOL          OK    = (bytes <= sizeof(large.t.buffer));\n    BOOL          found = FALSE;\n    while(OK && !found)\n\t{\n\t    OK           = TpmMath_GetRandomBits(large.t.buffer, bits, rand);  // new\n\t    large.t.size = bytes;\n\t    RsaAdjustPrimeCandidate(large.t.buffer, bytes);\n\t    // convert from 2B to Integer for prime checks\n\t    OK = OK\n\t\t && (ExtMath_IntFromBytes(prime, large.t.buffer, large.t.size) != NULL);\n\t    found = OK && (RsaCheckPrime(prime, exponent, rand) == TPM_RC_SUCCESS);\n\t}\n\n    if(!OK)\n\t{\n\t    FAIL(FATAL_ERROR_CRYPTO);\n\t}\n\n    return (OK && found) ? TPM_RC_SUCCESS : TPM_RC_FAILURE;\n}\n\n#endif  // ALG_RSA\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptPrimeSieve.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     CryptPrimeSieve\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes and defines\n\n#include \"Tpm.h\"\n\n#if RSA_KEY_SIEVE\n\n#  include \"CryptPrimeSieve_fp.h\"\n\n// This determines the number of bits in the largest sieve field.\n#  define MAX_FIELD_SIZE 2048\n\nextern const uint32_t      s_LastPrimeInTable;\nextern const uint32_t      s_PrimeTableSize;\nextern const uint32_t      s_PrimesInTable;\nextern const unsigned char s_PrimeTable[];\n\n// This table is set of prime markers. Each entry is the prime value\n// for the ((n + 1) * 1024) prime. That is, the entry in s_PrimeMarkers[1]\n// is the value for the 2,048th prime. This is used in the PrimeSieve\n// to adjust the limit for the prime search. When processing smaller\n// prime candidates, fewer primes are checked directly before going to\n// Miller-Rabin. As the prime grows, it is worth spending more time eliminating\n// primes as, a) the density is lower, and b) the cost of Miller-Rabin is\n// higher.\nconst uint32_t s_PrimeMarkersCount = 6;\nconst uint32_t s_PrimeMarkers[]    = {8167, 17881, 28183, 38891, 49871, 60961};\nuint32_t       primeLimit;\n\n//** Functions\n\n//*** RsaAdjustPrimeLimit()\n// This used during the sieve process. The iterator for getting the\n// next prime (RsaNextPrime()) will return primes until it hits the\n// limit (primeLimit) set up by this function. This causes the sieve\n// process to stop when an appropriate number of primes have been\n// sieved.\nLIB_EXPORT void RsaAdjustPrimeLimit(uint32_t requestedPrimes)\n{\n    if(requestedPrimes == 0 || requestedPrimes > s_PrimesInTable)\n\trequestedPrimes = s_PrimesInTable;\n    requestedPrimes = (requestedPrimes - 1) / 1024;\n    if(requestedPrimes < s_PrimeMarkersCount)\n\tprimeLimit = s_PrimeMarkers[requestedPrimes];\n    else\n\tprimeLimit = s_LastPrimeInTable;\n    primeLimit >>= 1;\n}\n\n//*** RsaNextPrime()\n// This the iterator used during the sieve process. The input is the\n// last prime returned (or any starting point) and the output is the\n// next higher prime. The function returns 0 when the primeLimit is\n// reached.\nLIB_EXPORT uint32_t RsaNextPrime(uint32_t lastPrime)\n{\n    if(lastPrime == 0)\n\treturn 0;\n    lastPrime >>= 1;\n    for(lastPrime += 1; lastPrime <= primeLimit; lastPrime++)\n\t{\n\t    if(((s_PrimeTable[lastPrime >> 3] >> (lastPrime & 0x7)) & 1) == 1)\n\t\treturn ((lastPrime << 1) + 1);\n\t}\n    return 0;\n}\n\n// This table contains a previously sieved table. It has\n// the bits for 3, 5, and 7 removed. Because of the\n// factors, it needs to be aligned to 105 and has\n// a repeat of 105.\nconst BYTE seedValues[] = {0x16, 0x29, 0xcb, 0xa4, 0x65, 0xda, 0x30, 0x6c, 0x99, 0x96,\n\t\t\t   0x4c, 0x53, 0xa2, 0x2d, 0x52, 0x96, 0x49, 0xcb, 0xb4, 0x61,\n\t\t\t   0xd8, 0x32, 0x2d, 0x99, 0xa6, 0x44, 0x5b, 0xa4, 0x2c, 0x93,\n\t\t\t   0x96, 0x69, 0xc3, 0xb0, 0x65, 0x5a, 0x32, 0x4d, 0x89, 0xb6,\n\t\t\t   0x48, 0x59, 0x26, 0x2d, 0xd3, 0x86, 0x61, 0xcb, 0xb4, 0x64,\n\t\t\t   0x9a, 0x12, 0x6d, 0x91, 0xb2, 0x4c, 0x5a, 0xa6, 0x0d, 0xc3,\n\t\t\t   0x96, 0x69, 0xc9, 0x34, 0x25, 0xda, 0x22, 0x65, 0x99, 0xb4,\n\t\t\t   0x4c, 0x1b, 0x86, 0x2d, 0xd3, 0x92, 0x69, 0x4a, 0xb4, 0x45,\n\t\t\t   0xca, 0x32, 0x69, 0x99, 0x36, 0x0c, 0x5b, 0xa6, 0x25, 0xd3,\n\t\t\t   0x94, 0x68, 0x8b, 0x94, 0x65, 0xd2, 0x32, 0x6d, 0x18, 0xb6,\n\t\t\t   0x4c, 0x4b, 0xa6, 0x29, 0xd1};\n\n#  define USE_NIBBLE\n\n#  ifndef USE_NIBBLE\nstatic const BYTE bitsInByte[256] =\n    {0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x03, 0x01, 0x02, 0x02, 0x03, 0x02,\n     0x03, 0x03, 0x04, 0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03,\n     0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x01, 0x02, 0x02, 0x03, 0x02, 0x03, 0x03,\n     0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x02, 0x03, 0x03, 0x04,\n     0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x01,\n     0x02, 0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04,\n     0x04, 0x05, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04,\n     0x05, 0x04, 0x05, 0x05, 0x06, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05,\n     0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x03, 0x04, 0x04, 0x05, 0x04,\n     0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, 0x01, 0x02,\n     0x02, 0x03, 0x02, 0x03, 0x03, 0x04, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04,\n     0x05, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05,\n     0x04, 0x05, 0x05, 0x06, 0x02, 0x03, 0x03, 0x04, 0x03, 0x04, 0x04, 0x05, 0x03,\n     0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05,\n     0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06, 0x07, 0x02, 0x03, 0x03,\n     0x04, 0x03, 0x04, 0x04, 0x05, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06,\n     0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05, 0x05, 0x06, 0x05,\n     0x06, 0x06, 0x07, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05, 0x05, 0x06, 0x04, 0x05,\n     0x05, 0x06, 0x05, 0x06, 0x06, 0x07, 0x04, 0x05, 0x05, 0x06, 0x05, 0x06, 0x06,\n     0x07, 0x05, 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x08};\n#    define BitsInByte(x) bitsInByte[(unsigned char)x]\n#  else\nconst BYTE bitsInNibble[16] = {0x00,\n\t\t\t       0x01,\n\t\t\t       0x01,\n\t\t\t       0x02,\n\t\t\t       0x01,\n\t\t\t       0x02,\n\t\t\t       0x02,\n\t\t\t       0x03,\n\t\t\t       0x01,\n\t\t\t       0x02,\n\t\t\t       0x02,\n\t\t\t       0x03,\n\t\t\t       0x02,\n\t\t\t       0x03,\n\t\t\t       0x03,\n\t\t\t       0x04};\n#    define BitsInByte(x)\t\t\t\\\n    (bitsInNibble[(unsigned char)(x)&0xf]\t\t\t\t\\\n     + bitsInNibble[((unsigned char)(x) >> 4) & 0xf])\n#  endif\n\n//*** BitsInArry()\n// This function counts the number of bits set in an array of bytes.\nstatic int BitsInArray(const unsigned char* a,  // IN: A pointer to an array of bytes\n\t\t       unsigned int         aSize  // IN: the number of bytes to sum\n\t\t       )\n{\n    int j = 0;\n    for(; aSize; a++, aSize--)\n\tj += BitsInByte(*a);\n    return j;\n}\n\n//*** FindNthSetBit()\n// This function finds the nth SET bit in a bit array. The 'n' parameter is\n// between 1 and the number of bits in the array (always a multiple of 8).\n// If called when the array does not have n bits set, it will return -1\n//  Return Type: unsigned int\n//      <0      no bit is set or no bit with the requested number is set\n//      >=0    the number of the bit in the array that is the nth set\nLIB_EXPORT int FindNthSetBit(\n\t\t\t     const UINT16 aSize,  // IN: the size of the array to check\n\t\t\t     const BYTE*  a,      // IN: the array to check\n\t\t\t     const UINT32 n       // IN, the number of the SET bit\n\t\t\t     )\n{\n    UINT16 i;\n    int    retValue;\n    UINT32 sum = 0;\n    BYTE   sel;\n\n    //find the bit\n    for(i = 0; (i < (int)aSize) && (sum < n); i++)\n\tsum += BitsInByte(a[i]);\n    i--;\n    // The chosen bit is in the byte that was just accessed\n    // Compute the offset to the start of that byte\n    retValue = i * 8 - 1;\n    sel      = a[i];\n    // Subtract the bits in the last byte added.\n    sum -= BitsInByte(sel);\n    // Now process the byte, one bit at a time.\n    for(; (sel != 0) && (sum != n); retValue++, sel = sel >> 1)\n\tsum += (sel & 1) != 0;\n    return (sum == n) ? retValue : -1;\n}\n\ntypedef struct\n{\n    UINT32 prime;\n    UINT16 count;\n} SIEVE_MARKS;\n\nconst SIEVE_MARKS sieveMarks[6] = {{31, 7},\n\t\t\t\t   {73, 5},\n\t\t\t\t   {241, 4},\n\t\t\t\t   {1621, 3},\n\t\t\t\t   {UINT16_MAX, 2},\n\t\t\t\t   {UINT32_MAX, 1}};\n\nconst size_t MAX_SIEVE_MARKS = (sizeof(sieveMarks) / sizeof(sieveMarks[0]));\n\n//*** PrimeSieve()\n// This function does a prime sieve over the input 'field' which has as its\n// starting address the value in bnN. Since this initializes the Sieve\n// using a precomputed field with the bits associated with 3, 5 and 7 already\n// turned off, the value of pnN may need to be adjusted by a few counts to allow\n// the precomputed field to be used without modification.\n//\n// To get better performance, one could address the issue of developing the\n// composite numbers. When the size of the prime gets large, the time for doing\n// the divisions goes up, noticeably. It could be better to develop larger composite\n// numbers even if they need to be Crypt_Int*'s themselves. The object would be to\n// reduce the number of times that the large prime is divided into a few large\n// divides and then use smaller divides to get to the final 16 bit (or smaller)\n// remainders.\nLIB_EXPORT UINT32 PrimeSieve(Crypt_Int* bnN,    // IN/OUT: number to sieve\n\t\t\t     UINT32 fieldSize,  // IN: size of the field area in bytes\n\t\t\t     BYTE*  field       // IN: field\n\t\t\t     )\n{\n    UINT32 i;\n    UINT32 j;\n    UINT32 fieldBits = fieldSize * 8;\n    UINT32 r;\n    BYTE*  pField;\n    INT32  iter;\n    UINT32 adjust;\n    UINT32 mark  = 0;\n    UINT32 count = sieveMarks[0].count;\n    UINT32 stop  = sieveMarks[0].prime;\n    UINT32 composite;\n    UINT32 pList[8];\n    UINT32 next;\n\n    pAssert(field != NULL && bnN != NULL);\n\n    // If the remainder is odd, then subtracting the value will give an even number,\n    // but we want an odd number, so subtract the 105+rem. Otherwise, just subtract\n    // the even remainder.\n    adjust = (UINT32)ExtMath_ModWord(bnN, 105);\n    if(adjust & 1)\n\tadjust += 105;\n\n    // Adjust the input number so that it points to the first number in a\n    // aligned field.\n    ExtMath_SubtractWord(bnN, bnN, adjust);\n    //    pAssert(ExtMath_ModWord(bnN, 105) == 0);\n    pField = field;\n    for(i = fieldSize; i >= sizeof(seedValues);\n\tpField += sizeof(seedValues), i -= sizeof(seedValues))\n\t{\n\t    memcpy(pField, seedValues, sizeof(seedValues));\n\t}\n    if(i != 0)\n\tmemcpy(pField, seedValues, i);\n\n    // Cycle through the primes, clearing bits\n    // Have already done 3, 5, and 7\n    iter = 7;\n\n#  define NEXT_PRIME(iter) (iter = RsaNextPrime(iter))\n    // Get the next N primes where N is determined by the mark in the sieveMarks\n    while((composite = NEXT_PRIME(iter)) != 0)\n\t{\n\t    next       = 0;\n\t    i          = count;\n\t    pList[i--] = composite;\n\t    for(; i > 0; i--)\n\t\t{\n\t\t    next     = NEXT_PRIME(iter);\n\t\t    pList[i] = next;\n\t\t    if(next != 0)\n\t\t\tcomposite *= next;\n\t\t}\n\t    // Get the remainder when dividing the base field address\n\t    // by the composite\n\t    composite = (UINT32)ExtMath_ModWord(bnN, composite);\n\t    // 'composite' is divisible by the composite components. for each of the\n\t    // composite components, divide 'composite'. That remainder (r) is used to\n\t    // pick a starting point for clearing the array. The stride is equal to the\n\t    // composite component. Note, the field only contains odd numbers. If the\n\t    // field were expanded to contain all numbers, then half of the bits would\n\t    // have already been cleared. We can save the trouble of clearing them a\n\t    // second time by having a stride of 2*next. Or we can take all of the even\n\t    // numbers out of the field and use a stride of 'next'\n\t    for(i = count; i > 0; i--)\n\t\t{\n\t\t    next = pList[i];\n\t\t    if(next == 0)\n\t\t\tgoto done;\n\t\t    r = composite % next;\n\t\t    // these computations deal with the fact that we have picked a field-sized\n\t\t    // range that is aligned to a 105 count boundary. The problem is, this field\n\t\t    // only contains odd numbers. If we take our prime guess and walk through all\n\t\t    // the numbers using that prime as the 'stride', then every other 'stride' is\n\t\t    // going to be an even number. So, we are actually counting by 2 * the stride\n\t\t    // We want the count to start on an odd number at the start of our field. That\n\t\t    // is, we want to assume that we have counted up to the edge of the field by\n\t\t    // the 'stride' and now we are going to start flipping bits in the field as we\n\t\t    // continue to count up by 'stride'. If we take the base of our field and\n\t\t    // divide by the stride, we find out how much we find out how short the last\n\t\t    // count was from reaching the edge of the bit field. Say we get a quotient of\n\t\t    // 3 and remainder of 1. This means that after 3 strides, we are 1 short of\n\t\t    // the start of the field and the next stride will either land within the\n\t\t    // field or step completely over it. The confounding factor is that our field\n\t\t    // only contains odd numbers and our stride is actually 2 * stride. If the\n\t\t    // quoitent is even, then that means that when we add 2 * stride, we are going\n\t\t    // to hit another even number. So, we have to know if we need to back off\n\t\t    // by 1 stride before we start couting by 2 * stride.\n\t\t    // We can tell from the remainder whether we are on an even or odd\n\t\t    // stride when we hit the beginning of the table. If we are on an odd stride\n\t\t    // (r & 1), we would start half a stride in (next - r)/2. If we are on an\n\t\t    // even stride, we need 0.5 strides (next - r/2) because the table only has\n\t\t    // odd numbers. If the remainder happens to be zero, then the start of the\n\t\t    // table is on stride so no adjustment is necessary.\n\t\t    if(r & 1)\n\t\t\tj = (next - r) / 2;\n\t\t    else if(r == 0)\n\t\t\tj = 0;\n\t\t    else\n\t\t\tj = next - (r / 2);\n\t\t    for(; j < fieldBits; j += next)\n\t\t\tClearBit(j, field, fieldSize);\n\t\t}\n\t    if(next >= stop)\n\t\t{\n\t\t    mark++;\n\t\t    if(mark >= MAX_SIEVE_MARKS)\n\t\t\t{\n\t\t\t    // prime iteration should have broken out of the loop before this.\n\t\t\t    FAIL_EXIT(FATAL_ERROR_INTERNAL, i, 0);\n\t\t\t}\n\t\t    count = sieveMarks[mark].count;\n\t\t    stop  = sieveMarks[mark].prime;\n\t\t}\n\t}\n done:\n    i = BitsInArray(field, fieldSize);\n\n Exit:\n    INSTRUMENT_INC(totalFieldsSieved[PrimeIndex]);\n    INSTRUMENT_ADD(bitsInFieldAfterSieve[PrimeIndex], i);\n    INSTRUMENT_ADD(emptyFieldsSieved[PrimeIndex], (i == 0));\n    return i;\n}\n\n#  ifdef SIEVE_DEBUG\nstatic uint32_t fieldSize = 210;\n\n//***SetFieldSize()\n// Function to set the field size used for prime generation. Used for tuning.\nLIB_EXPORT uint32_t SetFieldSize(uint32_t newFieldSize)\n{\n    if(newFieldSize == 0 || newFieldSize > MAX_FIELD_SIZE)\n\tfieldSize = MAX_FIELD_SIZE;\n    else\n\tfieldSize = newFieldSize;\n    return fieldSize;\n}\n#  endif  // SIEVE_DEBUG\n\n//*** PrimeSelectWithSieve()\n// This function will sieve the field around the input prime candidate. If the\n// sieve field is not empty, one of the one bits in the field is chosen for testing\n// with Miller-Rabin. If the value is prime, 'pnP' is updated with this value\n// and the function returns success. If this value is not prime, another\n// pseudo-random candidate is chosen and tested. This process repeats until\n// all values in the field have been checked. If all bits in the field have\n// been checked and none is prime, the function returns FALSE and a new random\n// value needs to be chosen.\n//  Return Type: TPM_RC\n//      TPM_RC_FAILURE      TPM in failure mode, probably due to entropy source\n//      TPM_RC_SUCCESS      candidate is probably prime\n//      TPM_RC_NO_RESULT    candidate is not prime and couldn't find and alternative\n//                          in the field\nLIB_EXPORT TPM_RC PrimeSelectWithSieve(\n\t\t\t\t       Crypt_Int*  candidate,  // IN/OUT: The candidate to filter\n\t\t\t\t       UINT32      e,          // IN: the exponent\n\t\t\t\t       RAND_STATE* rand    // IN: the random number generator state\n\t\t\t\t       )\n{\n    BYTE   field[MAX_FIELD_SIZE];\n    UINT32 ones;\n    INT32  chosen;\n    CRYPT_PRIME_VAR(test);\n    UINT32 modE;\n#  ifndef SIEVE_DEBUG\n    UINT32 fieldSize = MAX_FIELD_SIZE;\n#  endif\n    UINT32 primeSize;\n    //\n    // Adjust the field size and prime table list to fit the size of the prime\n    // being tested. This is done to try to optimize the trade-off between the\n    // dividing done for sieving and the time for Miller-Rabin. When the size\n    // of the prime is large, the cost of Miller-Rabin is fairly high, as is the\n    // cost of the sieving. However, the time for Miller-Rabin goes up considerably\n    // faster than the cost of dividing by a number of primes.\n    primeSize = ExtMath_SizeInBits(candidate);\n\n    if(primeSize <= 512)\n\t{\n\t    RsaAdjustPrimeLimit(1024);  // Use just the first 1024 primes\n\t}\n    else if(primeSize <= 1024)\n\t{\n\t    RsaAdjustPrimeLimit(4096);  // Use just the first 4K primes\n\t}\n    else\n\t{\n\t    RsaAdjustPrimeLimit(0);  // Use all available\n\t}\n\n    // Save the low-order word to use as a search generator and make sure that\n    // it has some interesting range to it\n    uint32_t first = ExtMath_GetLeastSignificant32bits(candidate);\n    first |= 0x80000000;\n\n    // Sieve the field\n    ones = PrimeSieve(candidate, fieldSize, field);\n\n    // PrimeSieve shouldn't fail, but does call functions that may.\n    if(!g_inFailureMode)\n\t{\n\t    pAssert(ones > 0 && ones < (fieldSize * 8));\n\t    for(; ones > 0; ones--)\n\t\t{\n\t\t    // Decide which bit to look at and find its offset\n\t\t    chosen = FindNthSetBit((UINT16)fieldSize, field, ((first % ones) + 1));\n\n\t\t    if((chosen < 0) || (chosen >= (INT32)(fieldSize * 8)))\n\t\t\tFAIL(FATAL_ERROR_INTERNAL);\n\n\t\t    // Set this as the trial prime\n\t\t    ExtMath_AddWord(test, candidate, (crypt_uword_t)(chosen * 2));\n\n\t\t    // The exponent might not have been one of the tested primes so\n\t\t    // make sure that it isn't divisible and make sure that 0 != (p-1) mod e\n\t\t    // Note: This is the same as 1 != p mod e\n\t\t    modE = (UINT32)ExtMath_ModWord(test, e);\n\t\t    if((modE != 0) && (modE != 1) && MillerRabin(test, rand))\n\t\t\t{\n\t\t\t    ExtMath_Copy(candidate, test);\n\t\t\t    return TPM_RC_SUCCESS;\n\t\t\t}\n\t\t    // Clear the bit just tested\n\t\t    ClearBit(chosen, field, fieldSize);\n\t\t}\n\t    // Ran out of bits and couldn't find a prime in this field\n\t    INSTRUMENT_INC(noPrimeFields[PrimeIndex]);\n\t}\n    return (g_inFailureMode ? TPM_RC_FAILURE : TPM_RC_NO_RESULT);\n}\n\n#  if RSA_INSTRUMENT\nstatic char a[256];\n\n//*** PrintTuple()\nchar* PrintTuple(UINT32* i)\n{\n    sprintf(a, \"{%d, %d, %d}\", i[0], i[1], i[2]);\n    return a;\n}\n\n#    define CLEAR_VALUE(x) memset(x, 0, sizeof(x))\n\n//*** RsaSimulationEnd()\nvoid RsaSimulationEnd(void)\n{\n    int    i;\n    UINT32 averages[3];\n    UINT32 nonFirst = 0;\n    if((PrimeCounts[0] + PrimeCounts[1] + PrimeCounts[2]) != 0)\n\t{\n\t    printf(\"Primes generated = %s\\n\", PrintTuple(PrimeCounts));\n\t    printf(\"Fields sieved = %s\\n\", PrintTuple(totalFieldsSieved));\n\t    printf(\"Fields with no primes = %s\\n\", PrintTuple(noPrimeFields));\n\t    printf(\"Primes checked with Miller-Rabin = %s\\n\",\n\t\t   PrintTuple(MillerRabinTrials));\n\t    for(i = 0; i < 3; i++)\n\t\taverages[i] = (totalFieldsSieved[i] != 0\n\t\t\t       ? bitsInFieldAfterSieve[i] / totalFieldsSieved[i]\n\t\t\t       : 0);\n\t    printf(\"Average candidates in field %s\\n\", PrintTuple(averages));\n\t    for(i = 1; i < (sizeof(failedAtIteration) / sizeof(failedAtIteration[0]));\n\t\ti++)\n\t\tnonFirst += failedAtIteration[i];\n\t    printf(\"Miller-Rabin failures not in first round = %d\\n\", nonFirst);\n\t}\n    CLEAR_VALUE(PrimeCounts);\n    CLEAR_VALUE(totalFieldsSieved);\n    CLEAR_VALUE(noPrimeFields);\n    CLEAR_VALUE(MillerRabinTrials);\n    CLEAR_VALUE(bitsInFieldAfterSieve);\n}\n\n//*** GetSieveStats()\nLIB_EXPORT void GetSieveStats(\n\t\t\t      uint32_t* trials, uint32_t* emptyFields, uint32_t* averageBits)\n{\n    uint32_t totalBits;\n    uint32_t fields;\n    *trials      = MillerRabinTrials[0] + MillerRabinTrials[1] + MillerRabinTrials[2];\n    *emptyFields = noPrimeFields[0] + noPrimeFields[1] + noPrimeFields[2];\n    fields       = totalFieldsSieved[0] + totalFieldsSieved[1] + totalFieldsSieved[2];\n    totalBits    = bitsInFieldAfterSieve[0] + bitsInFieldAfterSieve[1]\n\t\t   + bitsInFieldAfterSieve[2];\n    if(fields != 0)\n\t*averageBits = totalBits / fields;\n    else\n\t*averageBits = 0;\n    CLEAR_VALUE(PrimeCounts);\n    CLEAR_VALUE(totalFieldsSieved);\n    CLEAR_VALUE(noPrimeFields);\n    CLEAR_VALUE(MillerRabinTrials);\n    CLEAR_VALUE(bitsInFieldAfterSieve);\n}\n#  endif\n\n#endif  // RSA_KEY_SIEVE\n\n#if !RSA_INSTRUMENT\n\n//*** RsaSimulationEnd()\n// Stub for call when not doing instrumentation.\nvoid RsaSimulationEnd(void)\n{\n    return;\n}\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptRand.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tDRBG with a behavior according to SP800-90A\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file implements a DRBG with a behavior according to SP800-90A using\n// a block cypher. This is also compliant to ISO/IEC 18031:2011(E) C.3.2.\n//\n// A state structure is created for use by TPM.lib and functions\n// within the CryptoEngine my use their own state structures when they need to have\n// deterministic values.\n//\n// A debug mode is available that allows the random numbers generated for TPM.lib\n// to be repeated during runs of the simulator. The switch for it is in\n// TpmBuildSwitches.h. It is USE_DEBUG_RNG.\n//\n//\n// This is the implementation layer of CTR DRGB mechanism as defined in SP800-90A\n// and the functions are organized as closely as practical to the organization in\n// SP800-90A. It is intended to be compiled as a separate module that is linked\n// with a secure application so that both reside inside the same boundary\n// [SP 800-90A 8.5]. The secure application in particular manages the accesses\n// protected storage for the state of the DRBG instantiations, and supplies the\n// implementation functions here with a valid pointer to the working state of the\n// given instantiations (as a DRBG_STATE structure).\n//\n// This DRBG mechanism implementation does not support prediction resistance. Thus\n// 'prediction_resistance_flag' is omitted from Instantiate_function(),\n// Reseed_function(), Generate_function() argument lists [SP 800-90A 9.1, 9.2,\n// 9.3], as well as from the working state data structure DRBG_STATE [SP 800-90A\n// 9.1].\n//\n// This DRBG mechanism implementation always uses the highest security strength of\n// available in the block ciphers. Thus 'requested_security_strength' parameter is\n// omitted from Instantiate_function() and Generate_function() argument lists\n// [SP 800-90A 9.1, 9.2, 9.3], as well as from the working state data structure\n// DRBG_STATE [SP 800-90A 9.1].\n//\n// Internal functions (ones without Crypt prefix) expect validated arguments and\n// therefore use assertions instead of runtime parameter checks and mostly return\n// void instead of a status value.\n\n#include \"Tpm.h\"\n\n// Pull in the test vector definitions and define the space\n#include \"PRNG_TestVectors.h\"\n\nconst BYTE DRBG_NistTestVector_Entropy[]         = {DRBG_TEST_INITIATE_ENTROPY};\nconst BYTE DRBG_NistTestVector_GeneratedInterm[] = {DRBG_TEST_GENERATED_INTERM};\n\nconst BYTE DRBG_NistTestVector_EntropyReseed[]   = {DRBG_TEST_RESEED_ENTROPY};\nconst BYTE DRBG_NistTestVector_Generated[]       = {DRBG_TEST_GENERATED};\n\n//** Derivation Functions\n//*** Description\n// The functions in this section are used to reduce the personalization input values\n// to make them usable as input for reseeding and instantiation. The overall\n// behavior is intended to produce the same results as described in SP800-90A,\n// section 10.4.2 \"Derivation Function Using a Block Cipher Algorithm\n// (Block_Cipher_df).\" The code is broken into several subroutines to deal with the\n// fact that the data used for personalization may come in several separate blocks\n// such as a Template hash and a proof value and a primary seed.\n\n//*** Derivation Function Defines and Structures\n\n#define DF_COUNT (DRBG_KEY_SIZE_WORDS / DRBG_IV_SIZE_WORDS + 1)\n#if DRBG_KEY_SIZE_BITS != 128 && DRBG_KEY_SIZE_BITS != 256\n#  error \"CryptRand.c only written for AES with 128- or 256-bit keys.\"\n#endif\n\ntypedef tpmKeyScheduleAES DRBG_KEY_SCHEDULE;\n\ntypedef struct\n{\n    DRBG_KEY_SCHEDULE keySchedule;\n    DRBG_IV           iv[DF_COUNT];\n    DRBG_IV           out1;\n    DRBG_IV           buf;\n    int               contents;\n} DF_STATE, *PDF_STATE;\n\n//*** DfCompute()\n// This function does the incremental update of the derivation function state. It\n// encrypts the 'iv' value and XOR's the results into each of the blocks of the\n// output. This is equivalent to processing all of input data for each output block.\nstatic void DfCompute(PDF_STATE dfState)\n{\n    int            i;\n    int            iv;\n    crypt_uword_t* pIv;\n    crypt_uword_t  temp[DRBG_IV_SIZE_WORDS] = {0};\n    //\n    for(iv = 0; iv < DF_COUNT; iv++)\n\t{\n\t    pIv = (crypt_uword_t*)&dfState->iv[iv].words[0];\n\t    for(i = 0; i < DRBG_IV_SIZE_WORDS; i++)\n\t\t{\n\t\t    temp[i] ^= pIv[i] ^ dfState->buf.words[i];\n\t\t}\n\t    DRBG_ENCRYPT(&dfState->keySchedule, &temp, pIv);\n\t}\n    for(i = 0; i < DRBG_IV_SIZE_WORDS; i++)\n\tdfState->buf.words[i] = 0;\n    dfState->contents = 0;\n}\n\n//*** DfStart()\n// This initializes the output blocks with an encrypted counter value and\n// initializes the key schedule.\nstatic void DfStart(PDF_STATE dfState, uint32_t inputLength)\n{\n    BYTE       init[8];\n    int        i;\n    UINT32     drbgSeedSize = sizeof(DRBG_SEED);\n\n    const BYTE dfKey[DRBG_KEY_SIZE_BYTES] =\n\t{ 0x00,\n\t  0x01,\n\t  0x02,\n\t  0x03,\n\t  0x04,\n\t  0x05,\n\t  0x06,\n\t  0x07,\n\t  0x08,\n\t  0x09,\n\t  0x0a,\n\t  0x0b,\n\t  0x0c,\n\t  0x0d,\n\t  0x0e,\n\t  0x0f\n#if DRBG_KEY_SIZE_BYTES > 16\n\t  ,\n\t  0x10,\n\t  0x11,\n\t  0x12,\n\t  0x13,\n\t  0x14,\n\t  0x15,\n\t  0x16,\n\t  0x17,\n\t  0x18,\n\t  0x19,\n\t  0x1a,\n\t  0x1b,\n\t  0x1c,\n\t  0x1d,\n\t  0x1e,\n\t  0x1f\n#endif\n\t};\n    memset(dfState, 0, sizeof(DF_STATE));\n    DRBG_ENCRYPT_SETUP(&dfKey[0], DRBG_KEY_SIZE_BITS, &dfState->keySchedule);\n    // Create the first chaining values\n    for(i = 0; i < DF_COUNT; i++)\n\t((BYTE*)&dfState->iv[i])[3] = (BYTE)i;\n    DfCompute(dfState);\n    // initialize the first 64 bits of the IV in a way that doesn't depend\n    // on the size of the words used.\n    UINT32_TO_BYTE_ARRAY(inputLength, init);\n    UINT32_TO_BYTE_ARRAY(drbgSeedSize, &init[4]);\n    memcpy(&dfState->iv[0], init, 8);\n    dfState->contents = 4;\n}\n\n//*** DfUpdate()\n// This updates the state with the input data. A byte at a time is moved into the\n// state buffer until it is full and then that block is encrypted by DfCompute().\nstatic void DfUpdate(PDF_STATE dfState, int size, const BYTE* data)\n{\n    while(size > 0)\n\t{\n\t    int toFill = DRBG_IV_SIZE_BYTES - dfState->contents;\n\t    if(size < toFill)\n\t\ttoFill = size;\n\t    // Copy as many bytes as there are or until the state buffer is full\n\t    memcpy(&dfState->buf.bytes[dfState->contents], data, toFill);\n\t    // Reduce the size left by the amount copied\n\t    size -= toFill;\n\t    // Advance the data pointer by the amount copied\n\t    data += toFill;\n\t    // increase the buffer contents count by the amount copied\n\t    dfState->contents += toFill;\n\t    pAssert(dfState->contents <= DRBG_IV_SIZE_BYTES);\n\t    // If we have a full buffer, do a computation pass.\n\t    if(dfState->contents == DRBG_IV_SIZE_BYTES)\n\t\tDfCompute(dfState);\n\t}\n}\n\n//*** DfEnd()\n// This function is called to get the result of the derivation function computation.\n// If the buffer is not full, it is padded with zeros. The output buffer is\n// structured to be the same as a DRBG_SEED value so that the function can return\n// a pointer to the DRBG_SEED value in the DF_STATE structure.\nstatic DRBG_SEED* DfEnd(PDF_STATE dfState)\n{\n    // Since DfCompute is always called when a buffer is full, there is always\n    // space in the buffer for the terminator\n    dfState->buf.bytes[dfState->contents++] = 0x80;\n    // If the buffer is not full, pad with zeros\n    while(dfState->contents < DRBG_IV_SIZE_BYTES)\n\tdfState->buf.bytes[dfState->contents++] = 0;\n    // Do a final state update\n    DfCompute(dfState);\n    return (DRBG_SEED*)&dfState->iv;\n}\n\n//*** DfBuffer()\n// Function to take an input buffer and do the derivation function to produce a\n// DRBG_SEED value that can be used in DRBG_Reseed();\nstatic DRBG_SEED* DfBuffer(DRBG_SEED* output,  // OUT: receives the result\n\t\t\t   int        size,    // IN: size of the buffer to add\n\t\t\t   BYTE*      buf      // IN: address of the buffer\n\t\t\t   )\n{\n    DF_STATE dfState;\n    if(size == 0 || buf == NULL)\n\treturn NULL;\n    // Initialize the derivation function\n    DfStart(&dfState, size);\n    DfUpdate(&dfState, size, buf);\n    DfEnd(&dfState);\n    memcpy(output, &dfState.iv[0], sizeof(DRBG_SEED));\n    return output;\n}\n\n//*** DRBG_GetEntropy()\n// Even though this implementation never fails, it may get blocked\n// indefinitely long in the call to get entropy from the platform\n// (DRBG_GetEntropy32()).\n// This function is only used during instantiation of the DRBG for\n// manufacturing and on each start-up after an non-orderly shutdown.\n//\n//  Return Type: BOOL\n//      TRUE(1)         requested entropy returned\n//      FALSE(0)        entropy Failure\nBOOL DRBG_GetEntropy(UINT32 requiredEntropy,  // IN: requested number of bytes of full\n\t\t     //     entropy\n\t\t     BYTE* entropy  // OUT: buffer to return collected entropy\n\t\t     )\n{\n#if !USE_DEBUG_RNG\n\n    UINT32 obtainedEntropy;\n    INT32  returnedEntropy;\n\n    // If in debug mode, always use the self-test values for initialization\n    if(IsSelfTest())\n\t{\n#endif\n\t    // If doing simulated DRBG, then check to see if the\n\t    // entropyFailure condition is being tested\n\t    if(!IsEntropyBad())\n\t\t{\n\t\t    // In self-test, the caller should be asking for exactly the seed\n\t\t    // size of entropy.\n\t\t    pAssert(requiredEntropy == sizeof(DRBG_NistTestVector_Entropy));\n\t\t    memcpy(entropy,\n\t\t\t   DRBG_NistTestVector_Entropy,\n\t\t\t   sizeof(DRBG_NistTestVector_Entropy));\n\t\t}\n#if !USE_DEBUG_RNG\n\t}\n    else if(!IsEntropyBad())\n\t{\n\t    // Collect entropy\n\t    // Note: In debug mode, the only \"entropy\" value ever returned\n\t    // is the value of the self-test vector.\n\t    for(returnedEntropy = 1, obtainedEntropy = 0;\n\t\tobtainedEntropy < requiredEntropy && !IsEntropyBad();\n\t\tobtainedEntropy += returnedEntropy)\n\t\t{\n\t\t    returnedEntropy = _plat__GetEntropy(&entropy[obtainedEntropy],\n\t\t\t\t\t\t\trequiredEntropy - obtainedEntropy);\n\t\t    if(returnedEntropy <= 0)\n\t\t\tSetEntropyBad();\n\t\t}\n\t}\n#endif\n    return !IsEntropyBad();\n}\n\n//*** IncrementIv()\n// This function increments the IV value by 1. It is used by EncryptDRBG().\nvoid IncrementIv(DRBG_IV* iv)\n{\n    BYTE* ivP = ((BYTE*)iv) + DRBG_IV_SIZE_BYTES;\n    while((--ivP >= (BYTE*)iv) && ((*ivP = ((*ivP + 1) & 0xFF)) == 0))\n\t;\n}\n\n//*** EncryptDRBG()\n// This does the encryption operation for the DRBG. It will encrypt\n// the input state counter (IV) using the state key. Into the output\n// buffer for as many times as it takes to generate the required\n// number of bytes.\nstatic BOOL EncryptDRBG(BYTE*              dOut,\n\t\t\tUINT32             dOutBytes,\n\t\t\tDRBG_KEY_SCHEDULE* keySchedule,\n\t\t\tDRBG_IV*           iv,\n\t\t\tUINT32* lastValue  // Points to the last output value\n\t\t\t)\n{\n#if FIPS_COMPLIANT\n    // For FIPS compliance, the DRBG has to do a continuous self-test to make sure that\n    // no two consecutive values are the same. This overhead is not incurred if the TPM\n    // is not required to be FIPS compliant\n    //\n    UINT32 temp[DRBG_IV_SIZE_BYTES / sizeof(UINT32)];\n    int    i;\n    BYTE*  p;\n\n    for(; dOutBytes > 0;)\n\t{\n\t    // Increment the IV before each encryption (this is what makes this\n\t    // different from normal counter-mode encryption\n\t    IncrementIv(iv);\n\t    DRBG_ENCRYPT(keySchedule, iv, temp);\n\t    // Expect a 16 byte block\n#  if DRBG_IV_SIZE_BITS != 128\n#    error \"Unsuppored IV size in DRBG\"\n#  endif\n\t    if((lastValue[0] == temp[0]) && (lastValue[1] == temp[1])\n\t       && (lastValue[2] == temp[2]) && (lastValue[3] == temp[3]))\n\t\t{\n\t\t    FAIL_BOOL(FATAL_ERROR_ENTROPY);\n\t\t}\n\t    lastValue[0] = temp[0];\n\t    lastValue[1] = temp[1];\n\t    lastValue[2] = temp[2];\n\t    lastValue[3] = temp[3];\n\t    i            = MIN(dOutBytes, DRBG_IV_SIZE_BYTES);\n\t    dOutBytes -= i;\n\t    for(p = (BYTE*)temp; i > 0; i--)\n\t\t*dOut++ = *p++;\n\t}\n#else  // version without continuous self-test\n    NOT_REFERENCED(lastValue);\n    for(; dOutBytes >= DRBG_IV_SIZE_BYTES;\n\tdOut = &dOut[DRBG_IV_SIZE_BYTES], dOutBytes -= DRBG_IV_SIZE_BYTES)\n\t{\n\t    // Increment the IV\n\t    IncrementIv(iv);\n\t    DRBG_ENCRYPT(keySchedule, iv, dOut);\n\t}\n    // If there is a partial, generate into a block-sized\n    // temp buffer and copy to the output.\n    if(dOutBytes != 0)\n\t{\n\t    BYTE temp[DRBG_IV_SIZE_BYTES];\n\t    // Increment the IV\n\t    IncrementIv(iv);\n\t    DRBG_ENCRYPT(keySchedule, iv, temp);\n\t    memcpy(dOut, temp, dOutBytes);\n\t}\n#endif\n    return TRUE;\n}\n\n//*** DRBG_Update()\n// This function performs the state update function.\n// According to SP800-90A, a temp value is created by doing CTR mode\n// encryption of 'providedData' and replacing the key and IV with\n// these values. The one difference is that, with counter mode, the\n// IV is incremented after each block is encrypted and in this\n// operation, the counter is incremented before each block is\n// encrypted. This function implements an 'optimized' version\n// of the algorithm in that it does the update of the drbgState->seed\n// in place and then 'providedData' is XORed into drbgState->seed\n// to complete the encryption of 'providedData'. This works because\n// the IV is the last thing that gets encrypted.\n//\nstatic BOOL DRBG_Update(\n\t\t\tDRBG_STATE*        drbgState,    // IN:OUT state to update\n\t\t\tDRBG_KEY_SCHEDULE* keySchedule,  // IN: the key schedule (optional)\n\t\t\tDRBG_SEED*         providedData  // IN: additional data\n\t\t\t)\n{\n    UINT32            i;\n    BYTE*             temp = (BYTE*)&drbgState->seed;\n    DRBG_KEY*         key  = pDRBG_KEY(&drbgState->seed);\n    DRBG_IV*          iv   = pDRBG_IV(&drbgState->seed);\n    DRBG_KEY_SCHEDULE localKeySchedule;\n    //\n    pAssert(drbgState->magic == DRBG_MAGIC);\n\n    // If an key schedule was not provided, make one\n    if(keySchedule == NULL)\n\t{\n\t    if(DRBG_ENCRYPT_SETUP((BYTE*)key, DRBG_KEY_SIZE_BITS, &localKeySchedule) != 0)\n\t\t{\n\t\t    FAIL_BOOL(FATAL_ERROR_INTERNAL);\n\t\t}\n\t    keySchedule = &localKeySchedule;\n\t}\n    // Encrypt the temp value\n\n    EncryptDRBG(temp, sizeof(DRBG_SEED), keySchedule, iv, drbgState->lastValue);\n    if(providedData != NULL)\n\t{\n\t    BYTE* pP = (BYTE*)providedData;\n\t    for(i = DRBG_SEED_SIZE_BYTES; i != 0; i--)\n\t\t*temp++ ^= *pP++;\n\t}\n    // Since temp points to the input key and IV, we are done and\n    // don't need to copy the resulting 'temp' to drbgState->seed\n    return TRUE;\n}\n\n//*** DRBG_Reseed()\n// This function is used when reseeding of the DRBG is required. If\n// entropy is provided, it is used in lieu of using hardware entropy.\n// Note: the provided entropy must be the required size.\n//\n//  Return Type: BOOL\n//      TRUE(1)         reseed succeeded\n//      FALSE(0)        reseed failed, probably due to the entropy generation\nBOOL DRBG_Reseed(DRBG_STATE* drbgState,        // IN: the state to update\n\t\t DRBG_SEED*  providedEntropy,  // IN: entropy\n\t\t DRBG_SEED*  additionalData    // IN:\n\t\t )\n{\n    DRBG_SEED seed;\n\n    pAssert((drbgState != NULL) && (drbgState->magic == DRBG_MAGIC));\n\n    if(providedEntropy == NULL)\n\t{\n\t    providedEntropy = &seed;\n\t    if(!DRBG_GetEntropy(sizeof(DRBG_SEED), (BYTE*)providedEntropy))\n\t\treturn FALSE;\n\t}\n    if(additionalData != NULL)\n\t{\n\t    unsigned int i;\n\n\t    // XOR the provided data into the provided entropy\n\t    for(i = 0; i < sizeof(DRBG_SEED); i++)\n\t\t((BYTE*)providedEntropy)[i] ^= ((BYTE*)additionalData)[i];\n\t}\n    DRBG_Update(drbgState, NULL, providedEntropy);\n\n    drbgState->reseedCounter = 1;\n\n    return TRUE;\n}\n\n//*** DRBG_SelfTest()\n// This is run when the DRBG is instantiated and at startup.\n//\n//  Return Type: BOOL\n//      TRUE(1)         test OK\n//      FALSE(0)        test failed\nBOOL DRBG_SelfTest(void)\n{\n    BYTE       buf[sizeof(DRBG_NistTestVector_Generated)];\n    DRBG_SEED  seed;\n    UINT32     i;\n    BYTE*      p;\n    DRBG_STATE testState;\n    //\n    pAssert(!IsSelfTest());\n\n    SetSelfTest();\n    SetDrbgTested();\n    // Do an instantiate\n    if(!DRBG_Instantiate(&testState, 0, NULL))\n\treturn FALSE;\n#if DRBG_DEBUG_PRINT\n    dbgDumpMemBlock(\n\t\t    pDRBG_KEY(&testState), DRBG_KEY_SIZE_BYTES, \"Key after Instantiate\");\n    dbgDumpMemBlock(\n\t\t    pDRBG_IV(&testState), DRBG_IV_SIZE_BYTES, \"Value after Instantiate\");\n#endif\n    if(DRBG_Generate((RAND_STATE*)&testState, buf, sizeof(buf)) == 0)\n\treturn FALSE;\n#if DRBG_DEBUG_PRINT\n    dbgDumpMemBlock(\n\t\t    pDRBG_KEY(&testState.seed), DRBG_KEY_SIZE_BYTES, \"Key after 1st Generate\");\n    dbgDumpMemBlock(\n\t\t    pDRBG_IV(&testState.seed), DRBG_IV_SIZE_BYTES, \"Value after 1st Generate\");\n#endif\n    if(memcmp(buf, DRBG_NistTestVector_GeneratedInterm, sizeof(buf)) != 0)\n\treturn FALSE;\n    memcpy(seed.bytes, DRBG_NistTestVector_EntropyReseed, sizeof(seed));\n    DRBG_Reseed(&testState, &seed, NULL);\n#if DRBG_DEBUG_PRINT\n    dbgDumpMemBlock((BYTE*)pDRBG_KEY(&testState.seed),\n\t\t    DRBG_KEY_SIZE_BYTES,\n\t\t    \"Key after 2nd Generate\");\n    dbgDumpMemBlock((BYTE*)pDRBG_IV(&testState.seed),\n\t\t    DRBG_IV_SIZE_BYTES,\n\t\t    \"Value after 2nd Generate\");\n    dbgDumpMemBlock(buf, sizeof(buf), \"2nd Generated\");\n#endif\n    if(DRBG_Generate((RAND_STATE*)&testState, buf, sizeof(buf)) == 0)\n\treturn FALSE;\n    if(memcmp(buf, DRBG_NistTestVector_Generated, sizeof(buf)) != 0)\n\treturn FALSE;\n    ClearSelfTest();\n\n    DRBG_Uninstantiate(&testState);\n    for(p = (BYTE*)&testState, i = 0; i < sizeof(DRBG_STATE); i++)\n\t{\n\t    if(*p++)\n\t\treturn FALSE;\n\t}\n    // Simulate hardware failure to make sure that we get an error when\n    // trying to instantiate\n    SetEntropyBad();\n    if(DRBG_Instantiate(&testState, 0, NULL))\n\treturn FALSE;\n    ClearEntropyBad();\n\n    return TRUE;\n}\n\n//** Public Interface\n//*** Description\n// The functions in this section are the interface to the RNG. These\n// are the functions that are used by TPM.lib.\n\n//*** CryptRandomStir()\n// This function is used to cause a reseed. A DRBG_SEED amount of entropy is\n// collected from the hardware and then additional data is added.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        failure of the entropy generator\nLIB_EXPORT TPM_RC CryptRandomStir(UINT16 additionalDataSize, BYTE* additionalData)\n{\n#if !USE_DEBUG_RNG\n    DRBG_SEED tmpBuf;\n    DRBG_SEED dfResult;\n    //\n    // All reseed with outside data starts with a buffer full of entropy\n    if(!DRBG_GetEntropy(sizeof(tmpBuf), (BYTE*)&tmpBuf))\n\treturn TPM_RC_NO_RESULT;\n\n    DRBG_Reseed(&drbgDefault,\n\t\t&tmpBuf,\n\t\tDfBuffer(&dfResult, additionalDataSize, additionalData));\n    drbgDefault.reseedCounter = 1;\n\n    return TPM_RC_SUCCESS;\n\n#else\n    // If doing debug, use the input data as the initial setting for the RNG state\n    // so that the test can be reset at any time.\n    // Note: If this is called with a data size of 0 or less, nothing happens. The\n    // presumption is that, in a debug environment, the caller will have specific\n    // values for initialization, so this check is just a simple way to prevent\n    // inadvertent programming errors from screwing things up. This doesn't use an\n    // pAssert() because the non-debug version of this function will accept these\n    // parameters as meaning that there is no additionalData and only hardware\n    // entropy is used.\n    if((additionalDataSize > 0) && (additionalData != NULL))\n\t{\n\t    memset(drbgDefault.seed.bytes, 0, sizeof(drbgDefault.seed.bytes));\n\t    memcpy(drbgDefault.seed.bytes,\n\t\t   additionalData,\n\t\t   MIN(additionalDataSize, sizeof(drbgDefault.seed.bytes)));\n\t}\n    drbgDefault.reseedCounter = 1;\n\n    return TPM_RC_SUCCESS;\n#endif\n}\n\n//*** CryptRandomGenerate()\n// Generate a 'randomSize' number or random bytes.\nLIB_EXPORT UINT16 CryptRandomGenerate(UINT16 randomSize, BYTE* buffer)\n{\n    return DRBG_Generate((RAND_STATE*)&drbgDefault, buffer, randomSize);\n}\n\n//*** DRBG_InstantiateSeededKdf()\n// This function is used to instantiate a KDF-based RNG. This is used for derivations.\n// This function always returns TRUE.\nLIB_EXPORT BOOL DRBG_InstantiateSeededKdf(\n\t\t\t\t\t  KDF_STATE*   state,    // OUT: buffer to hold the state\n\t\t\t\t\t  TPM_ALG_ID   hashAlg,  // IN: hash algorithm\n\t\t\t\t\t  TPM_ALG_ID   kdf,      // IN: the KDF to use\n\t\t\t\t\t  TPM2B*       seed,     // IN: the seed to use\n\t\t\t\t\t  const TPM2B* label,    // IN: a label for the generation process.\n\t\t\t\t\t  TPM2B*       context,  // IN: the context value\n\t\t\t\t\t  UINT32       limit     // IN: Maximum number of bits from the KDF\n\t\t\t\t\t  )\n{\n    state->magic           = KDF_MAGIC;\n    state->limit           = limit;\n    state->seed            = seed;\n    state->hash            = hashAlg;\n    state->kdf             = kdf;\n    state->label           = label;\n    state->context         = context;\n    state->digestSize      = CryptHashGetDigestSize(hashAlg);\n    state->counter         = 0;\n    state->residual.t.size = 0;\n    return TRUE;\n}\n\n//*** DRBG_AdditionalData()\n// Function to reseed the DRBG with additional entropy. This is normally called\n// before computing the protection value of a primary key in the Endorsement\n// hierarchy.\nLIB_EXPORT void DRBG_AdditionalData(DRBG_STATE* drbgState,  // IN:OUT state to update\n\t\t\t\t    TPM2B* additionalData  // IN: value to incorporate\n\t\t\t\t    )\n{\n    DRBG_SEED dfResult;\n    if(drbgState->magic == DRBG_MAGIC)\n\t{\n\t    DfBuffer(&dfResult, additionalData->size, additionalData->buffer);\n\t    DRBG_Reseed(drbgState, &dfResult, NULL);\n\t}\n}\n\n//*** DRBG_InstantiateSeeded()\n// This function is used to instantiate a random number generator from seed values.\n// The nominal use of this generator is to create sequences of pseudo-random\n// numbers from a seed value.\n//\n// Return Type: TPM_RC\n//  TPM_RC_FAILURE      DRBG self-test failure\nLIB_EXPORT TPM_RC DRBG_InstantiateSeeded(\n\t\t\t\t\t DRBG_STATE*  drbgState,  // IN/OUT: buffer to hold the state\n\t\t\t\t\t const TPM2B* seed,       // IN: the seed to use\n\t\t\t\t\t const TPM2B* purpose,    // IN: a label for the generation process.\n\t\t\t\t\t const TPM2B* name,       // IN: name of the object\n\t\t\t\t\t const TPM2B* additional  // IN: additional data\n\t\t\t\t\t )\n{\n    DF_STATE dfState;\n    int      totalInputSize;\n    // DRBG should have been tested, but...\n    if(!IsDrbgTested() && !DRBG_SelfTest())\n\t{\n\t    FAIL_RC(FATAL_ERROR_SELF_TEST);\n\t}\n    // Initialize the DRBG state\n    memset(drbgState, 0, sizeof(DRBG_STATE));\n    drbgState->magic = DRBG_MAGIC;\n\n    // Size all of the values\n    totalInputSize = (seed != NULL) ? seed->size : 0;\n    totalInputSize += (purpose != NULL) ? purpose->size : 0;\n    totalInputSize += (name != NULL) ? name->size : 0;\n    totalInputSize += (additional != NULL) ? additional->size : 0;\n\n    // Initialize the derivation\n    DfStart(&dfState, totalInputSize);\n\n    // Run all the input strings through the derivation function\n    if(seed != NULL)\n\tDfUpdate(&dfState, seed->size, seed->buffer);\n    if(purpose != NULL)\n\tDfUpdate(&dfState, purpose->size, purpose->buffer);\n    if(name != NULL)\n\tDfUpdate(&dfState, name->size, name->buffer);\n    if(additional != NULL)\n\tDfUpdate(&dfState, additional->size, additional->buffer);\n\n    // Used the derivation function output as the \"entropy\" input. This is not\n    // how it is described in SP800-90A but this is the equivalent function\n    DRBG_Reseed(((DRBG_STATE*)drbgState), DfEnd(&dfState), NULL);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptRandStartup()\n// This function is called when TPM_Startup is executed. This function always returns\n// TRUE.\nLIB_EXPORT BOOL CryptRandStartup(void)\n{\n#if !_DRBG_STATE_SAVE\n    // If not saved in NV, re-instantiate on each startup\n    return DRBG_Instantiate(&drbgDefault, 0, NULL);\n#else\n    // If the running state is saved in NV, NV has to be loaded before it can\n    // be updated\n    if(go.drbgState.magic == DRBG_MAGIC)\n\treturn DRBG_Reseed(&go.drbgState, NULL, NULL);\n    else\n\treturn DRBG_Instantiate(&go.drbgState, 0, NULL);\n#endif\n}\n\n//*** CryptRandInit()\n// This function is called when _TPM_Init is being processed.\n//\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure\nLIB_EXPORT BOOL CryptRandInit(void)\n{\n#if !USE_DEBUG_RNG\n    _plat__GetEntropy(NULL, 0);\n#endif\n    return DRBG_SelfTest();\n}\n\n//*** DRBG_Generate()\n// This function generates a random sequence according SP800-90A.\n// If 'random' is not NULL, then 'randomSize' bytes of random values are generated.\n// If 'random' is NULL or 'randomSize' is zero, then the function returns\n// zero without generating any bits or updating the reseed counter.\n// This function returns the number of bytes produced which could be less than the\n// number requested if the request is too large (\"too large\" is implementation\n// dependent.)\nLIB_EXPORT UINT16 DRBG_Generate(\n\t\t\t\tRAND_STATE* state,\n\t\t\t\tBYTE*       random,     // OUT: buffer to receive the random values\n\t\t\t\tUINT16      randomSize  // IN: the number of bytes to generate\n\t\t\t\t)\n{\n    if(state == NULL)\n\tstate = (RAND_STATE*)&drbgDefault;\n    if(random == NULL)\n\treturn 0;\n\n    // If the caller used a KDF state, generate a sequence from the KDF not to\n    // exceed the limit.\n    if(state->kdf.magic == KDF_MAGIC)\n\t{\n\t    KDF_STATE* kdf       = (KDF_STATE*)state;\n\t    UINT32     counter   = (UINT32)kdf->counter;\n\t    INT32      bytesLeft = randomSize;\n\t    //\n\t    // If the number of bytes to be returned would put the generator\n\t    // over the limit, then return 0\n\t    if((((kdf->counter * kdf->digestSize) + randomSize) * 8) > kdf->limit)\n\t\treturn 0;\n\t    // Process partial and full blocks until all requested bytes provided\n\t    while(bytesLeft > 0)\n\t\t{\n\t\t    // If there is any residual data in the buffer, copy it to the output\n\t\t    // buffer\n\t\t    if(kdf->residual.t.size > 0)\n\t\t\t{\n\t\t\t    INT32 size;\n\t\t\t    //\n\t\t\t    // Don't use more of the residual than will fit or more than are\n\t\t\t    // available\n\t\t\t    size = MIN(kdf->residual.t.size, bytesLeft);\n\n\t\t\t    // Copy some or all of the residual to the output. The residual is\n\t\t\t    // at the end of the buffer. The residual might be a full buffer.\n\t\t\t    MemoryCopy(\n\t\t\t\t       random,\n\t\t\t\t       &kdf->residual.t.buffer[kdf->digestSize - kdf->residual.t.size],\n\t\t\t\t       size);\n\n\t\t\t    // Advance the buffer pointer\n\t\t\t    random += size;\n\n\t\t\t    // Reduce the number of bytes left to get\n\t\t\t    bytesLeft -= size;\n\n\t\t\t    // And reduce the residual size appropriately\n\t\t\t    kdf->residual.t.size -= (UINT16)size;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    UINT16 blocks = (UINT16)(bytesLeft / kdf->digestSize);\n\t\t\t    //\n\t\t\t    // Get the number of required full blocks\n\t\t\t    if(blocks > 0)\n\t\t\t\t{\n\t\t\t\t    UINT16 size = blocks * kdf->digestSize;\n\t\t\t\t    // Get some number of full blocks and put them in the return buffer\n\t\t\t\t    CryptKDFa(kdf->hash,\n\t\t\t\t\t      kdf->seed,\n\t\t\t\t\t      kdf->label,\n\t\t\t\t\t      kdf->context,\n\t\t\t\t\t      NULL,\n\t\t\t\t\t      kdf->limit,\n\t\t\t\t\t      random,\n\t\t\t\t\t      &counter,\n\t\t\t\t\t      blocks);\n\n\t\t\t\t    // reduce the size remaining to be moved and advance the pointer\n\t\t\t\t    bytesLeft -= size;\n\t\t\t\t    random += size;\n\t\t\t\t}\n\t\t\t    else\n\t\t\t\t{\n\t\t\t\t    // Fill the residual buffer with a full block and then loop to\n\t\t\t\t    // top to get part of it copied to the output.\n\t\t\t\t    kdf->residual.t.size = CryptKDFa(kdf->hash,\n\t\t\t\t\t\t\t\t     kdf->seed,\n\t\t\t\t\t\t\t\t     kdf->label,\n\t\t\t\t\t\t\t\t     kdf->context,\n\t\t\t\t\t\t\t\t     NULL,\n\t\t\t\t\t\t\t\t     kdf->limit,\n\t\t\t\t\t\t\t\t     kdf->residual.t.buffer,\n\t\t\t\t\t\t\t\t     &counter,\n\t\t\t\t\t\t\t\t     1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t    kdf->counter = counter;\n\t    return randomSize;\n\t}\n    else if(state->drbg.magic == DRBG_MAGIC)\n\t{\n\t    DRBG_STATE*       drbgState = (DRBG_STATE*)state;\n\t    DRBG_KEY_SCHEDULE keySchedule;\n\t    DRBG_SEED*        seed = &drbgState->seed;\n\n\t    if(drbgState->reseedCounter >= CTR_DRBG_MAX_REQUESTS_PER_RESEED)\n\t\t{\n\t\t    if(drbgState == &drbgDefault)\n\t\t\t{\n\t\t\t    DRBG_Reseed(drbgState, NULL, NULL);\n\t\t\t    if(IsEntropyBad() && !IsSelfTest())\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // If this is a PRNG then the only way to get\n\t\t\t    // here is if the SW has run away.\n\t\t\t    FAIL_IMMEDIATE(FATAL_ERROR_INTERNAL, 0);\n\t\t\t}\n\t\t}\n\t    // if the allowed number of bytes in a request is larger than the\n\t    // less than the number of bytes that can be requested, then check\n#if UINT16_MAX >= CTR_DRBG_MAX_BYTES_PER_REQUEST\n\t    if(randomSize > CTR_DRBG_MAX_BYTES_PER_REQUEST)\n\t\trandomSize = CTR_DRBG_MAX_BYTES_PER_REQUEST;\n#endif\n\t    // Create  encryption schedule\n\t    if(DRBG_ENCRYPT_SETUP(\n\t\t\t\t  (BYTE*)pDRBG_KEY(seed), DRBG_KEY_SIZE_BITS, &keySchedule)\n\t       != 0)\n\t\t{\n\t\t    FAIL_IMMEDIATE(FATAL_ERROR_INTERNAL, 0);\n\t\t}\n\t    // Generate the random data\n\t    EncryptDRBG(\n\t\t\trandom, randomSize, &keySchedule, pDRBG_IV(seed), drbgState->lastValue);\n\t    // Do a key update\n\t    DRBG_Update(drbgState, &keySchedule, NULL);\n\n\t    // Increment the reseed counter\n\t    drbgState->reseedCounter += 1;\n\t}\n    else\n\t{\n\t    // invalid DRBG state structure\n\t    FAIL_IMMEDIATE(FATAL_ERROR_INTERNAL, 0);\n\t}\n    return randomSize;\n}\n\n//*** DRBG_Instantiate()\n// This is CTR_DRBG_Instantiate_algorithm() from [SP 800-90A 10.2.1.3.1].\n// This is called when a the TPM DRBG is to be instantiated. This is\n// called to instantiate a DRBG used by the TPM for normal\n// operations.\n//\n//  Return Type: BOOL\n//      TRUE(1)         instantiation succeeded\n//      FALSE(0)        instantiation failed\nLIB_EXPORT BOOL DRBG_Instantiate(\n\t\t\t\t DRBG_STATE* drbgState,       // OUT: the instantiated value\n\t\t\t\t UINT16      pSize,           // IN: Size of personalization string\n\t\t\t\t BYTE*       personalization  // IN: The personalization string\n\t\t\t\t )\n{\n    DRBG_SEED seed;\n    DRBG_SEED dfResult;\n    //\n    pAssert((pSize == 0) || (pSize <= sizeof(seed)) || (personalization != NULL));\n    // If the DRBG has not been tested, test when doing an instantiation. Since\n    // Instantiation is called during self test, make sure we don't get stuck in a\n    // loop.\n    if(!IsDrbgTested() && !IsSelfTest() && !DRBG_SelfTest())\n\treturn FALSE;\n    // If doing a self test, DRBG_GetEntropy will return the NIST\n    // test vector value.\n    if(!DRBG_GetEntropy(sizeof(seed), (BYTE*)&seed))\n\treturn FALSE;\n    // set everything to zero\n    memset(drbgState, 0, sizeof(DRBG_STATE));\n    drbgState->magic = DRBG_MAGIC;\n\n    // Steps 1, 2, 3, 6, 7 of SP 800-90A 10.2.1.3.1 are exactly what\n    // reseeding does. So, do a reduction on the personalization value (if any)\n    // and do a reseed.\n    DRBG_Reseed(drbgState, &seed, DfBuffer(&dfResult, pSize, personalization));\n\n    return TRUE;\n}\n\n//*** DRBG_Uninstantiate()\n// This is Uninstantiate_function() from [SP 800-90A 9.4].\n//\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE        not a valid state\nLIB_EXPORT TPM_RC DRBG_Uninstantiate(\n\t\t\t\t     DRBG_STATE* drbgState  // IN/OUT: working state to erase\n\t\t\t\t     )\n{\n    if((drbgState == NULL) || (drbgState->magic != DRBG_MAGIC))\n\treturn TPM_RC_VALUE;\n    memset(drbgState, 0, sizeof(DRBG_STATE));\n    return TPM_RC_SUCCESS;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptRsa.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tImplementation of cryptographic primitives for RSA\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// This file contains implementation of cryptographic primitives for RSA.\n// Vendors may replace the implementation in this file with their own library\n// functions.\n\n//**  Includes\n// Need this define to get the 'private' defines for this function\n#define CRYPT_RSA_C\n#include \"Tpm.h\"\n#include \"TpmMath_Util_fp.h\"\n\n#if ALG_RSA\n\n//**  Obligatory Initialization Functions\n\n//*** CryptRsaInit()\n// Function called at _TPM_Init().\nBOOL CryptRsaInit(void)\n{\n    return TRUE;\n}\n\n//*** CryptRsaStartup()\n// Function called at TPM2_Startup()\nBOOL CryptRsaStartup(void)\n{\n    return TRUE;\n}\n\n//** Internal Functions\n\n//*** RsaInitializeExponent()\n// This function initializes the bignum data structure that holds the private\n// exponent. This function returns the pointer to the private exponent value so that\n// it can be used in an initializer for a data declaration.\n\nstatic privateExponent* RsaInitializeExponent(privateExponent* Z)\n{\n    // verify privateExponent packing matches the usage of the bn pointer as an\n    // array in below function\n    MUST_BE(offsetof(privateExponent, Q) == SIZEOF_MEMBER(privateExponent, P));\n\n    Crypt_Int** bn = (Crypt_Int**)&Z->P;\n    int         i;\n    //\n    for(i = 0; i < 5; i++)\n\t{\n\t    bn[i] = (Crypt_Int*)&(Z->entries[i]);\n\t    ExtMath_Initialize_Int(bn[i], MAX_RSA_KEY_BITS / 2);\n\t}\n    return Z;\n}\n\n//*** MakePgreaterThanQ()\n// This function swaps the pointers for P and Q if Q happens to be larger than Q.\nstatic void MakePgreaterThanQ(privateExponent* Z)\n{\n    if(ExtMath_UnsignedCmp(Z->P, Z->Q) < 0)\n\t{\n\t    Crypt_Int* bnT = Z->P;\n\t    Z->P           = Z->Q;\n\t    Z->Q           = bnT;\n\t}\n}\n\n//*** PackExponent()\n// This function takes the bignum private exponent and converts it into TPM2B form.\n// In this form, the size field contains the overall size of the packed data. The\n// buffer contains 5, equal sized values in P, Q, dP, dQ, qInv order. For example, if\n// a key has a 2Kb public key, then the packed private key will contain 5, 1Kb values.\n// This form makes it relatively easy to load and save the values without changing\n// the normal unmarshaling to do anything more than allow a larger TPM2B for the\n// private key. Also, when exporting the value, all that is needed is to change the\n// size field of the private key in order to save just the P value.\n//  Return Type: BOOL\n//      TRUE(1)     success\n//      FALSE(0)    failure         // The data is too big to fit\nstatic BOOL PackExponent(TPM2B_PRIVATE_KEY_RSA* packed, privateExponent* Z)\n{\n    int    i;\n    UINT16 primeSize = (UINT16)BITS_TO_BYTES(ExtMath_MostSigBitNum(Z->P));\n    UINT16 pS        = primeSize;\n    //\n    pAssert((primeSize * 5) <= sizeof(packed->t.buffer));\n    packed->t.size = (primeSize * 5) + RSA_prime_flag;\n    for(i = 0; i < 5; i++)\n\tif(!ExtMath_IntToBytes(\n\t\t\t       (Crypt_Int*)&Z->entries[i], &packed->t.buffer[primeSize * i], &pS))\n\t    return FALSE;\n    if(pS != primeSize)\n\treturn FALSE;\n    return TRUE;\n}\n\n//*** UnpackExponent()\n// This function unpacks the private exponent from its TPM2B form into its bignum\n// form.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        TPM2B is not the correct size\nstatic BOOL UnpackExponent(TPM2B_PRIVATE_KEY_RSA* b, privateExponent* Z)\n{\n    UINT16      primeSize = b->t.size & ~RSA_prime_flag;\n    int         i;\n    Crypt_Int** bn = &Z->P;\n    //\n    GOTO_ERROR_UNLESS(b->t.size & RSA_prime_flag);\n    RsaInitializeExponent(Z);\n    GOTO_ERROR_UNLESS((primeSize % 5) == 0);\n    primeSize /= 5;\n    for(i = 0; i < 5; i++)\n\tGOTO_ERROR_UNLESS(\n\t\t\t  ExtMath_IntFromBytes(bn[i], &b->t.buffer[primeSize * i], primeSize)\n\t\t\t  != NULL);\n    MakePgreaterThanQ(Z);\n    return TRUE;\n Error:\n    return FALSE;\n}\n\n//*** ComputePrivateExponent()\n// This function computes the private exponent from the primes.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure\nstatic BOOL ComputePrivateExponent(\n\t\t\t\t   Crypt_Int*       pubExp,  // IN: the public exponent\n\t\t\t\t   privateExponent* Z        // IN/OUT: on input, has primes P and Q. On\n\t\t\t\t   //         output, has P, Q, dP, dQ, and pInv\n\t\t\t\t   )\n{\n    BOOL pOK;\n    BOOL qOK;\n    CRYPT_PRIME_VAR(pT);\n    //\n    // make p the larger value so that m2 is always less than p\n    MakePgreaterThanQ(Z);\n\n    //dP = (1/e) mod (p-1)\n    pOK = ExtMath_SubtractWord(pT, Z->P, 1);\n    pOK = pOK && ExtMath_ModInverse(Z->dP, pubExp, pT);\n    //dQ = (1/e) mod (q-1)\n    qOK = ExtMath_SubtractWord(pT, Z->Q, 1);\n    qOK = qOK && ExtMath_ModInverse(Z->dQ, pubExp, pT);\n    // qInv = (1/q) mod p\n    if(pOK && qOK)\n\tpOK = qOK = ExtMath_ModInverse(Z->qInv, Z->Q, Z->P);\n    if(!pOK)\n\tExtMath_SetWord(Z->P, 0);\n    if(!qOK)\n\tExtMath_SetWord(Z->Q, 0);\n    return pOK && qOK;\n}\n\n//*** RsaPrivateKeyOp()\n// This function is called to do the exponentiation with the private key. Compile\n// options allow use of the simple (but slow) private exponent, or the more complex\n// but faster CRT method.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure\nstatic BOOL RsaPrivateKeyOp(Crypt_Int* inOut,  // IN/OUT: number to be exponentiated\n\t\t\t    privateExponent* Z)\n{\n    CRYPT_RSA_VAR(M1);\n    CRYPT_RSA_VAR(M2);\n    CRYPT_RSA_VAR(M);\n    CRYPT_RSA_VAR(H);\n    //\n    MakePgreaterThanQ(Z);\n    // m1 = cdP mod p\n    GOTO_ERROR_UNLESS(ExtMath_ModExp(M1, inOut, Z->dP, Z->P));\n    // m2 = cdQ mod q\n    GOTO_ERROR_UNLESS(ExtMath_ModExp(M2, inOut, Z->dQ, Z->Q));\n    // h = qInv * (m1 - m2) mod p = qInv * (m1 + P - m2) mod P because Q < P\n    // so m2 < P\n    GOTO_ERROR_UNLESS(ExtMath_Subtract(H, Z->P, M2));\n    GOTO_ERROR_UNLESS(ExtMath_Add(H, H, M1));\n    GOTO_ERROR_UNLESS(ExtMath_ModMult(H, H, Z->qInv, Z->P));\n    // m = m2 + h * q\n    GOTO_ERROR_UNLESS(ExtMath_Multiply(M, H, Z->Q));\n    GOTO_ERROR_UNLESS(ExtMath_Add(inOut, M2, M));\n    return TRUE;\n Error:\n    return FALSE;\n}\n\n//*** RSAEP()\n// This function performs the RSAEP operation defined in PKCS#1v2.1. It is\n// an exponentiation of a value ('m') with the public exponent ('e'), modulo\n// the public ('n').\n//\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE     number to exponentiate is larger than the modulus\n//\nstatic TPM_RC RSAEP(TPM2B* dInOut,  // IN: size of the encrypted block and the size of\n\t\t    //     the encrypted value. It must be the size of\n\t\t    //     the modulus.\n\t\t    // OUT: the encrypted data. Will receive the\n\t\t    //      decrypted value\n\t\t    OBJECT* key     // IN: the key to use\n\t\t    )\n{\n    TPM2B_TYPE(4BYTES, 4);\n    TPM2B_4BYTES e2B;\n    UINT32       e = key->publicArea.parameters.rsaDetail.exponent;\n    //\n    if(e == 0)\n\te = RSA_DEFAULT_PUBLIC_EXPONENT;\n    UINT32_TO_BYTE_ARRAY(e, e2B.t.buffer);\n    e2B.t.size = 4;\n    return ModExpB(dInOut->size,\n\t\t   dInOut->buffer,\n\t\t   dInOut->size,\n\t\t   dInOut->buffer,\n\t\t   e2B.t.size,\n\t\t   e2B.t.buffer,\n\t\t   key->publicArea.unique.rsa.t.size,\n\t\t   key->publicArea.unique.rsa.t.buffer);\n}\n\n//*** RSADP()\n// This function performs the RSADP operation defined in PKCS#1v2.1. It is\n// an exponentiation of a value ('c') with the private exponent ('d'), modulo\n// the public modulus ('n'). The decryption is in place.\n//\n// This function also checks the size of the private key. If the size indicates\n// that only a prime value is present, the key is converted to being a private\n// exponent.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SIZE         the value to decrypt is larger than the modulus\n//\nstatic TPM_RC RSADP(TPM2B*  inOut,  // IN/OUT: the value to encrypt\n\t\t    OBJECT* key     // IN: the key\n\t\t    )\n{\n    CRYPT_RSA_INITIALIZED(bnM, inOut);\n    NEW_PRIVATE_EXPONENT(Z);\n    if(UnsignedCompareB(inOut->size,\n\t\t\tinOut->buffer,\n\t\t\tkey->publicArea.unique.rsa.t.size,\n\t\t\tkey->publicArea.unique.rsa.t.buffer)\n       >= 0)\n\treturn TPM_RC_SIZE;\n    // private key operation requires that private exponent be loaded\n    // During self-test, this might not be the case so load it up if it hasn't\n    // already done\n    // been done\n    if((key->sensitive.sensitive.rsa.t.size & RSA_prime_flag) == 0)\n\t{\n\t    if(CryptRsaLoadPrivateExponent(&key->publicArea, &key->sensitive)\n\t       != TPM_RC_SUCCESS)\n\t\treturn TPM_RC_BINDING;\n\t}\n    GOTO_ERROR_UNLESS(UnpackExponent(&key->sensitive.sensitive.rsa, Z));\n    GOTO_ERROR_UNLESS(RsaPrivateKeyOp(bnM, Z));\n    GOTO_ERROR_UNLESS(TpmMath_IntTo2B(bnM, inOut, inOut->size));\n    return TPM_RC_SUCCESS;\n Error:\n    return TPM_RC_FAILURE;\n}\n\n//*** OaepEncode()\n// This function performs OAEP padding. The size of the buffer to receive the\n// OAEP padded data must equal the size of the modulus\n//\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE     'hashAlg' is not valid or message size is too large\n//\nstatic TPM_RC OaepEncode(\n\t\t\t TPM2B*       padded,   // OUT: the pad data\n\t\t\t TPM_ALG_ID   hashAlg,  // IN: algorithm to use for padding\n\t\t\t const TPM2B* label,    // IN: null-terminated string (may be NULL)\n\t\t\t TPM2B*       message,  // IN: the message being padded\n\t\t\t RAND_STATE*  rand      // IN: the random number generator to use\n\t\t\t )\n{\n    INT32  padLen;\n    INT32  dbSize;\n    INT32  i;\n    BYTE   mySeed[MAX_DIGEST_SIZE];\n    BYTE*  seed = mySeed;\n    UINT16 hLen = CryptHashGetDigestSize(hashAlg);\n    BYTE   mask[MAX_RSA_KEY_BYTES];\n    BYTE*  pp;\n    BYTE*  pm;\n    TPM_RC retVal = TPM_RC_SUCCESS;\n\n    pAssert(padded != NULL && message != NULL);\n\n    // A value of zero is not allowed because the KDF can't produce a result\n    // if the digest size is zero.\n    if(hLen == 0)\n\treturn TPM_RC_VALUE;\n\n    // Basic size checks\n    //  make sure digest isn't too big for key size\n    if(padded->size < (2 * hLen) + 2)\n\tERROR_EXIT(TPM_RC_HASH);\n\n    // and that message will fit messageSize <= k - 2hLen - 2\n    if(message->size > (padded->size - (2 * hLen) - 2))\n\tERROR_EXIT(TPM_RC_VALUE);\n\n    // Hash L even if it is null\n    // Offset into padded leaving room for masked seed and byte of zero\n    pp = &padded->buffer[hLen + 1];\n    if(CryptHashBlock(hashAlg, label->size, (BYTE*)label->buffer, hLen, pp) != hLen)\n\tERROR_EXIT(TPM_RC_FAILURE);\n\n    // concatenate PS of k  mLen  2hLen  2\n    padLen = padded->size - message->size - (2 * hLen) - 2;\n    MemorySet(&pp[hLen], 0, padLen);\n    pp[hLen + padLen] = 0x01;\n    padLen += 1;\n    memcpy(&pp[hLen + padLen], message->buffer, message->size);\n\n    // The total size of db = hLen + pad + mSize;\n    dbSize = hLen + padLen + message->size;\n\n    DRBG_Generate(rand, mySeed, (UINT16)hLen);\n    if(g_inFailureMode)\n\tERROR_EXIT(TPM_RC_FAILURE);\n    // mask = MGF1 (seed, nSize  hLen  1)\n    CryptMGF_KDF(dbSize, mask, hashAlg, hLen, seed, 0);\n\n    // Create the masked db\n    pm = mask;\n    for(i = dbSize; i > 0; i--)\n\t*pp++ ^= *pm++;\n    pp = &padded->buffer[hLen + 1];\n\n    // Run the masked data through MGF1\n    if(CryptMGF_KDF(hLen, &padded->buffer[1], hashAlg, dbSize, pp, 0)\n       != (unsigned)hLen)\n\tERROR_EXIT(TPM_RC_VALUE);\n    // Now XOR the seed to create masked seed\n    pp = &padded->buffer[1];\n    pm = seed;\n    for(i = hLen; i > 0; i--)\n\t*pp++ ^= *pm++;\n    // Set the first byte to zero\n    padded->buffer[0] = 0x00;\n Exit:\n    return retVal;\n}\n\n//*** OaepDecode()\n// This function performs OAEP padding checking. The size of the buffer to receive\n// the recovered data. If the padding is not valid, the 'dSize' size is set to zero\n// and the function returns TPM_RC_VALUE.\n//\n// The 'dSize' parameter is used as an input to indicate the size available in the\n// buffer.\n\n// If insufficient space is available, the size is not changed and the return code\n// is TPM_RC_VALUE.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE        the value to decode was larger than the modulus, or\n//                          the padding is wrong or the buffer to receive the\n//                          results is too small\n//\n//\nstatic TPM_RC OaepDecode(\n\t\t\t TPM2B*       dataOut,  // OUT: the recovered data\n\t\t\t TPM_ALG_ID   hashAlg,  // IN: algorithm to use for padding\n\t\t\t const TPM2B* label,    // IN: null-terminated string (may be NULL)\n\t\t\t TPM2B*       padded    // IN: the padded data\n\t\t\t )\n{\n    UINT32 i;\n    BYTE   seedMask[MAX_DIGEST_SIZE];\n    UINT32 hLen = CryptHashGetDigestSize(hashAlg);\n\n    BYTE   mask[MAX_RSA_KEY_BYTES];\n    BYTE*  pp;\n    BYTE*  pm;\n    TPM_RC retVal = TPM_RC_SUCCESS;\n\n    // Strange size (anything smaller can't be an OAEP padded block)\n    // Also check for no leading 0\n    if((padded->size < (unsigned)((2 * hLen) + 2)) || (padded->buffer[0] != 0))\n\tERROR_EXIT(TPM_RC_VALUE);\n    // Use the hash size to determine what to put through MGF1 in order\n    // to recover the seedMask\n    CryptMGF_KDF(hLen,\n\t\t seedMask,\n\t\t hashAlg,\n\t\t padded->size - hLen - 1,\n\t\t &padded->buffer[hLen + 1],\n\t\t 0);\n\n    // Recover the seed into seedMask\n    pAssert(hLen <= sizeof(seedMask));\n    pp = &padded->buffer[1];\n    pm = seedMask;\n    for(i = hLen; i > 0; i--)\n\t*pm++ ^= *pp++;\n\n    // Use the seed to generate the data mask\n    CryptMGF_KDF(padded->size - hLen - 1, mask, hashAlg, hLen, seedMask, 0);\n\n    // Use the mask generated from seed to recover the padded data\n    pp = &padded->buffer[hLen + 1];\n    pm = mask;\n    for(i = (padded->size - hLen - 1); i > 0; i--)\n\t*pm++ ^= *pp++;\n\n    // Make sure that the recovered data has the hash of the label\n    // Put trial value in the seed mask\n    if((CryptHashBlock(hashAlg, label->size, (BYTE*)label->buffer, hLen, seedMask))\n       != hLen)\n\tFAIL(FATAL_ERROR_INTERNAL);\n    if(memcmp(seedMask, mask, hLen) != 0)\n\tERROR_EXIT(TPM_RC_VALUE);\n\n    // find the start of the data\n    pm = &mask[hLen];\n    for(i = (UINT32)padded->size - (2 * hLen) - 1; i > 0; i--)\n\t{\n\t    if(*pm++ != 0)\n\t\tbreak;\n\t}\n    // If we ran out of data or didn't end with 0x01, then return an error\n    if(i == 0 || pm[-1] != 0x01)\n\tERROR_EXIT(TPM_RC_VALUE);\n\n    // pm should be pointing at the first part of the data\n    // and i is one greater than the number of bytes to move\n    i--;\n    if(i > dataOut->size)\n\t// Special exit to preserve the size of the output buffer\n\treturn TPM_RC_VALUE;\n    memcpy(dataOut->buffer, pm, i);\n    dataOut->size = (UINT16)i;\n Exit:\n    if(retVal != TPM_RC_SUCCESS)\n\tdataOut->size = 0;\n    return retVal;\n}\n\n//*** PKCS1v1_5Encode()\n// This function performs the encoding for RSAES-PKCS1-V1_5-ENCRYPT as defined in\n// PKCS#1V2.1\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE     message size is too large\n//\nstatic TPM_RC RSAES_PKCS1v1_5Encode(TPM2B* padded,   // OUT: the pad data\n\t\t\t\t    TPM2B* message,  // IN: the message being padded\n\t\t\t\t    RAND_STATE* rand)\n{\n    UINT32 ps = padded->size - message->size - 3;\n    //\n    if(message->size > padded->size - 11)\n\treturn TPM_RC_VALUE;\n    // move the message to the end of the buffer\n    memcpy(&padded->buffer[padded->size - message->size],\n\t   message->buffer,\n\t   message->size);\n    // Set the first byte to 0x00 and the second to 0x02\n    padded->buffer[0] = 0;\n    padded->buffer[1] = 2;\n\n    // Fill with random bytes\n    DRBG_Generate(rand, &padded->buffer[2], (UINT16)ps);\n    if(g_inFailureMode)\n\treturn TPM_RC_FAILURE;\n\n    // Set the delimiter for the random field to 0\n    padded->buffer[2 + ps] = 0;\n\n    // Now, the only messy part. Make sure that all the 'ps' bytes are non-zero\n    // In this implementation, use the value of the current index\n    for(ps++; ps > 1; ps--)\n\t{\n\t    if(padded->buffer[ps] == 0)\n\t\tpadded->buffer[ps] = 0x55;  // In the < 0.5% of the cases that the\n\t    // random value is 0, just pick a value to\n\t    // put into the spot.\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** RSAES_Decode()\n// This function performs the decoding for RSAES-PKCS1-V1_5-ENCRYPT as defined in\n// PKCS#1V2.1\n//\n//  Return Type: TPM_RC\n//      TPM_RC_FAIL      decoding error or results would no fit into provided buffer\n//\nstatic TPM_RC RSAES_Decode(TPM2B* message,  // OUT: the recovered message\n\t\t\t   TPM2B* coded     // IN: the encoded message\n\t\t\t   )\n{\n    BOOL   fail = FALSE;\n    UINT16 pSize;\n\n    fail = (coded->size < 11);\n    fail = (coded->buffer[0] != 0x00) | fail;\n    fail = (coded->buffer[1] != 0x02) | fail;\n    for(pSize = 2; pSize < coded->size; pSize++)\n\t{\n\t    if(coded->buffer[pSize] == 0)\n\t\tbreak;\n\t}\n    pSize++;\n\n    // Make sure that pSize has not gone over the end and that there are at least 8\n    // bytes of pad data.\n    fail = (pSize > coded->size) | fail;\n    fail = ((pSize - 2) <= 8) | fail;\n    if((message->size < (UINT16)(coded->size - pSize)) || fail)\n\treturn TPM_RC_VALUE;\n    message->size = coded->size - pSize;\n    memcpy(message->buffer, &coded->buffer[pSize], coded->size - pSize);\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptRsaPssSaltSize()\n// This function computes the salt size used in PSS. It is broken out so that\n// the X509 code can get the same value that is used by the encoding function in this\n// module.\nINT16\nCryptRsaPssSaltSize(INT16 hashSize, INT16 outSize)\n{\n    INT16 saltSize;\n    //\n    // (Mask Length) = (outSize - hashSize - 1);\n    // Max saltSize is (Mask Length) - 1\n    saltSize = (outSize - hashSize - 1) - 1;\n    // Use the maximum salt size allowed by FIPS 186-4\n    if(saltSize > hashSize)\n\tsaltSize = hashSize;\n    else if(saltSize < 0)\n\tsaltSize = 0;\n    return saltSize;\n}\n\n//*** PssEncode()\n// This function creates an encoded block of data that is the size of modulus.\n// The function uses the maximum salt size that will fit in the encoded block.\n//\n//  Returns TPM_RC_SUCCESS or goes into failure mode.\nstatic TPM_RC PssEncode(TPM2B*      out,      // OUT: the encoded buffer\n\t\t\tTPM_ALG_ID  hashAlg,  // IN: hash algorithm for the encoding\n\t\t\tTPM2B*      digest,   // IN: the digest\n\t\t\tRAND_STATE* rand      // IN: random number source\n\t\t\t)\n{\n    UINT32     hLen = CryptHashGetDigestSize(hashAlg);\n    BYTE       salt[MAX_RSA_KEY_BYTES - 1];\n    UINT16     saltSize;\n    BYTE*      ps = salt;\n    BYTE*      pOut;\n    UINT16     mLen;\n    HASH_STATE hashState;\n\n    // These are fatal errors indicating bad TPM firmware\n    pAssert(out != NULL && hLen > 0 && digest != NULL);\n\n    // Get the size of the mask\n    mLen = (UINT16)(out->size - hLen - 1);\n\n    // Set the salt size\n    saltSize = CryptRsaPssSaltSize((INT16)hLen, (INT16)out->size);\n\n    //using eOut for scratch space\n    // Set the first 8 bytes to zero\n    pOut = out->buffer;\n    memset(pOut, 0, 8);\n\n    // Get set the salt\n    DRBG_Generate(rand, salt, saltSize);\n    if(g_inFailureMode)\n\treturn TPM_RC_FAILURE;\n\n    // Create the hash of the pad || input hash || salt\n    CryptHashStart(&hashState, hashAlg);\n    CryptDigestUpdate(&hashState, 8, pOut);\n    CryptDigestUpdate2B(&hashState, digest);\n    CryptDigestUpdate(&hashState, saltSize, salt);\n    CryptHashEnd(&hashState, hLen, &pOut[out->size - hLen - 1]);\n\n    // Create a mask\n    if(CryptMGF_KDF(mLen, pOut, hashAlg, hLen, &pOut[mLen], 0) != mLen)\n\tFAIL(FATAL_ERROR_INTERNAL);\n\n    // Since this implementation uses key sizes that are all even multiples of\n    // 8, just need to make sure that the most significant bit is CLEAR\n    *pOut &= 0x7f;\n\n    // Before we mess up the pOut value, set the last byte to 0xbc\n    pOut[out->size - 1] = 0xbc;\n\n    // XOR a byte of 0x01 at the position just before where the salt will be XOR'ed\n    pOut = &pOut[mLen - saltSize - 1];\n    *pOut++ ^= 0x01;\n\n    // XOR the salt data into the buffer\n    for(; saltSize > 0; saltSize--)\n\t*pOut++ ^= *ps++;\n\n    // and we are done\n    return TPM_RC_SUCCESS;\n}\n\n//*** PssDecode()\n// This function checks that the PSS encoded block was built from the\n// provided digest. If the check is successful, TPM_RC_SUCCESS is returned.\n// Any other value indicates an error.\n//\n// This implementation of PSS decoding is intended for the reference TPM\n// implementation and is not at all generalized.  It is used to check\n// signatures over hashes and assumptions are made about the sizes of values.\n// Those assumptions are enforce by this implementation.\n// This implementation does allow for a variable size salt value to have been\n// used by the creator of the signature.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME       'hashAlg' is not a supported hash algorithm\n//      TPM_RC_VALUE         decode operation failed\n//\nstatic TPM_RC PssDecode(\n\t\t\tTPM_ALG_ID hashAlg,  // IN: hash algorithm to use for the encoding\n\t\t\tTPM2B*     dIn,      // In: the digest to compare\n\t\t\tTPM2B*     eIn       // IN: the encoded data\n\t\t\t)\n{\n    UINT32     hLen = CryptHashGetDigestSize(hashAlg);\n    BYTE       mask[MAX_RSA_KEY_BYTES];\n    BYTE*      pm = mask;\n    BYTE*      pe;\n    BYTE       pad[8] = {0};\n    UINT32     i;\n    UINT32     mLen;\n    BYTE       fail;\n    TPM_RC     retVal = TPM_RC_SUCCESS;\n    HASH_STATE hashState;\n\n    // These errors are indicative of failures due to programmer error\n    pAssert(dIn != NULL && eIn != NULL);\n    pe = eIn->buffer;\n\n    // check the hash scheme\n    if(hLen == 0)\n\tERROR_EXIT(TPM_RC_SCHEME);\n\n    // most significant bit must be zero\n    fail = pe[0] & 0x80;\n\n    // last byte must be 0xbc\n    fail |= pe[eIn->size - 1] ^ 0xbc;\n\n    // Use the hLen bytes at the end of the buffer to generate a mask\n    // Doesn't start at the end which is a flag byte\n    mLen = eIn->size - hLen - 1;\n    CryptMGF_KDF(mLen, mask, hashAlg, hLen, &pe[mLen], 0);\n\n    // Clear the MSO of the mask to make it consistent with the encoding.\n    mask[0] &= 0x7F;\n\n    pAssert(mLen <= sizeof(mask));\n    // XOR the data into the mask to recover the salt. This sequence\n    // advances eIn so that it will end up pointing to the seed data\n    // which is the hash of the signature data\n    for(i = mLen; i > 0; i--)\n\t*pm++ ^= *pe++;\n\n    // Find the first byte of 0x01 after a string of all 0x00\n    for(pm = mask, i = mLen; i > 0; i--)\n\t{\n\t    if(*pm == 0x01)\n\t\tbreak;\n\t    else\n\t\tfail |= *pm++;\n\t}\n    // i should not be zero\n    fail |= (i == 0);\n\n    // if we have failed, will continue using the entire mask as the salt value so\n    // that the timing attacks will not disclose anything (I don't think that this\n    // is a problem for TPM applications but, usually, we don't fail so this\n    // doesn't cost anything).\n    if(fail)\n\t{\n\t    i  = mLen;\n\t    pm = mask;\n\t}\n    else\n\t{\n\t    pm++;\n\t    i--;\n\t}\n    // i contains the salt size and pm points to the salt. Going to use the input\n    // hash and the seed to recreate the hash in the lower portion of eIn.\n    CryptHashStart(&hashState, hashAlg);\n\n    // add the pad of 8 zeros\n    CryptDigestUpdate(&hashState, 8, pad);\n\n    // add the provided digest value\n    CryptDigestUpdate(&hashState, dIn->size, dIn->buffer);\n\n    // and the salt\n    CryptDigestUpdate(&hashState, i, pm);\n\n    // get the result\n    fail |= (CryptHashEnd(&hashState, hLen, mask) != hLen);\n\n    // Compare all bytes\n    for(pm = mask; hLen > 0; hLen--)\n\t// don't use fail = because that could skip the increment and compare\n\t// operations after the first failure and that gives away timing\n\t// information.\n\tfail |= *pm++ ^ *pe++;\n\n    retVal = (fail != 0) ? TPM_RC_VALUE : TPM_RC_SUCCESS;\n Exit:\n    return retVal;\n}\n\n//*** MakeDerTag()\n// Construct the DER value that is used in RSASSA\n//  Return Type: INT16\n//   > 0        size of value\n//   <= 0       no hash exists\nINT16\nMakeDerTag(TPM_ALG_ID hashAlg, INT16 sizeOfBuffer, BYTE* buffer)\n{\n    //    0x30, 0x31,       // SEQUENCE (2 elements) 1st\n    //        0x30, 0x0D,   // SEQUENCE (2 elements)\n    //            0x06, 0x09,   // HASH OID\n    //                0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01,\n    //             0x05, 0x00,  // NULL\n    //        0x04, 0x20  //  OCTET STRING\n    HASH_DEF* info = CryptGetHashDef(hashAlg);\n    INT16     oidSize;\n    // If no OID, can't do encode\n    GOTO_ERROR_UNLESS(info != NULL);\n    oidSize = 2 + (info->OID)[1];\n    // make sure this fits in the buffer\n    GOTO_ERROR_UNLESS(sizeOfBuffer >= (oidSize + 8));\n    *buffer++ = 0x30;  // 1st SEQUENCE\n    // Size of the 1st SEQUENCE is 6 bytes + size of the hash OID + size of the\n    // digest size\n    *buffer++ = (BYTE)(6 + oidSize + info->digestSize);  //\n    *buffer++ = 0x30;                                    // 2nd SEQUENCE\n    // size is 4 bytes of overhead plus the side of the OID\n    *buffer++ = (BYTE)(2 + oidSize);\n    MemoryCopy(buffer, info->OID, oidSize);\n    buffer += oidSize;\n    *buffer++ = 0x05;  // Add a NULL\n    *buffer++ = 0x00;\n\n    *buffer++ = 0x04;\n    *buffer++ = (BYTE)(info->digestSize);\n    return oidSize + 8;\n Error:\n    return 0;\n}\n\n//*** RSASSA_Encode()\n// Encode a message using PKCS1v1.5 method.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME       'hashAlg' is not a supported hash algorithm\n//      TPM_RC_SIZE         'eOutSize' is not large enough\n//      TPM_RC_VALUE        'hInSize' does not match the digest size of hashAlg\nstatic TPM_RC RSASSA_Encode(TPM2B* pOut,  // IN:OUT on in, the size of the public key\n\t\t\t    //        on out, the encoded area\n\t\t\t    TPM_ALG_ID hashAlg,  // IN: hash algorithm for PKCS1v1_5\n\t\t\t    TPM2B*     hIn       // IN: digest value to encode\n\t\t\t    )\n{\n    BYTE   DER[20];\n    BYTE*  der     = DER;\n    INT32  derSize = MakeDerTag(hashAlg, sizeof(DER), DER);\n    BYTE*  eOut;\n    INT32  fillSize;\n    TPM_RC retVal = TPM_RC_SUCCESS;\n\n    // Can't use this scheme if the algorithm doesn't have a DER string defined.\n    if(derSize == 0)\n\tERROR_EXIT(TPM_RC_SCHEME);\n\n    // If the digest size of 'hashAl' doesn't match the input digest size, then\n    // the DER will misidentify the digest so return an error\n    if(CryptHashGetDigestSize(hashAlg) != hIn->size)\n\tERROR_EXIT(TPM_RC_VALUE);\n    fillSize = pOut->size - derSize - hIn->size - 3;\n    eOut     = pOut->buffer;\n\n    // Make sure that this combination will fit in the provided space\n    if(fillSize < 8)\n\tERROR_EXIT(TPM_RC_SIZE);\n\n    // Start filling\n    *eOut++ = 0;  // initial byte of zero\n    *eOut++ = 1;  // byte of 0x01\n    for(; fillSize > 0; fillSize--)\n\t*eOut++ = 0xff;  // bunch of 0xff\n    *eOut++ = 0;         // another 0\n    for(; derSize > 0; derSize--)\n\t*eOut++ = *der++;  // copy the DER\n    der = hIn->buffer;\n    for(fillSize = hIn->size; fillSize > 0; fillSize--)\n\t*eOut++ = *der++;  // copy the hash\n Exit:\n    return retVal;\n}\n\n//*** RSASSA_Decode()\n// This function performs the RSASSA decoding of a signature.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE          decode unsuccessful\n//      TPM_RC_SCHEME        'haslAlg' is not supported\n//\nstatic TPM_RC RSASSA_Decode(\n\t\t\t    TPM_ALG_ID hashAlg,  // IN: hash algorithm to use for the encoding\n\t\t\t    TPM2B*     hIn,      // In: the digest to compare\n\t\t\t    TPM2B*     eIn       // IN: the encoded data\n\t\t\t    )\n{\n    BYTE   fail;\n    BYTE   DER[20];\n    BYTE*  der     = DER;\n    INT32  derSize = MakeDerTag(hashAlg, sizeof(DER), DER);\n    BYTE*  pe;\n    INT32  hashSize = CryptHashGetDigestSize(hashAlg);\n    INT32  fillSize;\n    TPM_RC retVal;\n    BYTE*  digest;\n    UINT16 digestSize;\n\n    pAssert(hIn != NULL && eIn != NULL);\n    pe = eIn->buffer;\n\n    // Can't use this scheme if the algorithm doesn't have a DER string\n    // defined or if the provided hash isn't the right size\n    if(derSize == 0 || (unsigned)hashSize != hIn->size)\n\tERROR_EXIT(TPM_RC_SCHEME);\n\n    // Make sure that this combination will fit in the provided space\n    // Since no data movement takes place, can just walk though this\n    // and accept nearly random values. This can only be called from\n    // CryptValidateSignature() so eInSize is known to be in range.\n    fillSize = eIn->size - derSize - hashSize - 3;\n\n    // Start checking (fail will become non-zero if any of the bytes do not have\n    // the expected value.\n    fail = *pe++;       // initial byte of zero\n    fail |= *pe++ ^ 1;  // byte of 0x01\n    for(; fillSize > 0; fillSize--)\n\tfail |= *pe++ ^ 0xff;  // bunch of 0xff\n    fail |= *pe++;             // another 0\n    for(; derSize > 0; derSize--)\n\tfail |= *pe++ ^ *der++;  // match the DER\n    digestSize = hIn->size;\n    digest     = hIn->buffer;\n    for(; digestSize > 0; digestSize--)\n\tfail |= *pe++ ^ *digest++;  // match the hash\n    retVal = (fail != 0) ? TPM_RC_VALUE : TPM_RC_SUCCESS;\n Exit:\n    return retVal;\n}\n\n//** Externally Accessible Functions\n\n//*** CryptRsaSelectScheme()\n// This function is used by TPM2_RSA_Decrypt and TPM2_RSA_Encrypt.  It sets up\n// the rules to select a scheme between input and object default.\n// This function assume the RSA object is loaded.\n// If a default scheme is defined in object, the default scheme should be chosen,\n// otherwise, the input scheme should be chosen.\n// In the case that both the object and 'scheme' are not TPM_ALG_NULL, then\n// if the schemes are the same, the input scheme will be chosen.\n// if the scheme are not compatible, a NULL pointer will be returned.\n//\n// The return pointer may point to a TPM_ALG_NULL scheme.\nTPMT_RSA_DECRYPT* CryptRsaSelectScheme(\n\t\t\t\t       TPMI_DH_OBJECT    rsaHandle,  // IN: handle of an RSA key\n\t\t\t\t       TPMT_RSA_DECRYPT* scheme      // IN: a sign or decrypt scheme\n\t\t\t\t       )\n{\n    OBJECT*           rsaObject;\n    TPMT_ASYM_SCHEME* keyScheme;\n    TPMT_RSA_DECRYPT* retVal = NULL;\n\n    // Get sign object pointer\n    rsaObject = HandleToObject(rsaHandle);\n    keyScheme = &rsaObject->publicArea.parameters.asymDetail.scheme;\n\n    // if the default scheme of the object is TPM_ALG_NULL, then select the\n    // input scheme\n    if(keyScheme->scheme == TPM_ALG_NULL)\n\t{\n\t    retVal = scheme;\n\t}\n    // if the object scheme is not TPM_ALG_NULL and the input scheme is\n    // TPM_ALG_NULL, then select the default scheme of the object.\n    else if(scheme->scheme == TPM_ALG_NULL)\n\t{\n\t    // if input scheme is NULL\n\t    retVal = (TPMT_RSA_DECRYPT*)keyScheme;\n\t}\n    // get here if both the object scheme and the input scheme are\n    // not TPM_ALG_NULL. Need to insure that they are the same.\n    // IMPLEMENTATION NOTE: This could cause problems if future versions have\n    // schemes that have more values than just a hash algorithm. A new function\n    // (IsSchemeSame()) might be needed then.\n    else if(keyScheme->scheme == scheme->scheme\n\t    && keyScheme->details.anySig.hashAlg == scheme->details.anySig.hashAlg)\n\t{\n\t    retVal = scheme;\n\t}\n    // two different, incompatible schemes specified will return NULL\n    return retVal;\n}\n\n//*** CryptRsaLoadPrivateExponent()\n// This function is called to generate the private exponent of an RSA key.\n//  Return Type: TPM_RC\n//      TPM_RC_BINDING      public and private parts of 'rsaKey' are not matched\nTPM_RC\nCryptRsaLoadPrivateExponent(TPMT_PUBLIC* publicArea, TPMT_SENSITIVE* sensitive)\n{\n    //\n    if((sensitive->sensitive.rsa.t.size & RSA_prime_flag) == 0)\n\t{\n\t    if((sensitive->sensitive.rsa.t.size * 2) == publicArea->unique.rsa.t.size)\n\t\t{\n\t\t    NEW_PRIVATE_EXPONENT(Z);\n\t\t    CRYPT_RSA_INITIALIZED(bnN, &publicArea->unique.rsa);\n\t\t    CRYPT_RSA_VAR(bnQr);\n\t\t    CRYPT_INT_VAR(bnE, RADIX_BITS);\n\n\t\t    TPM_DO_SELF_TEST(TPM_ALG_NULL);\n\n\t\t    GOTO_ERROR_UNLESS((sensitive->sensitive.rsa.t.size * 2)\n\t\t\t\t      == publicArea->unique.rsa.t.size);\n\t\t    // Initialize the exponent\n\t\t    ExtMath_SetWord(bnE, publicArea->parameters.rsaDetail.exponent);\n\t\t    if(ExtMath_IsZero(bnE))\n\t\t\tExtMath_SetWord(bnE, RSA_DEFAULT_PUBLIC_EXPONENT);\n\t\t    // Convert first prime to 2B\n\t\t    GOTO_ERROR_UNLESS(\n\t\t\t\t      TpmMath_IntFrom2B(Z->P, &sensitive->sensitive.rsa.b) != NULL);\n\n\t\t    // Find the second prime by division. This uses 'bQ' rather than Z->Q\n\t\t    // because the division could make the quotient larger than a prime during\n\t\t    // some intermediate step.\n\t\t    GOTO_ERROR_UNLESS(ExtMath_Divide(Z->Q, bnQr, bnN, Z->P));\n\t\t    GOTO_ERROR_UNLESS(ExtMath_IsZero(bnQr));\n\t\t    // Compute the private exponent and return it if found\n\t\t    GOTO_ERROR_UNLESS(ComputePrivateExponent(bnE, Z));\n\t\t    GOTO_ERROR_UNLESS(PackExponent(&sensitive->sensitive.rsa, Z));\n\t\t}\n\t    else\n\t\tGOTO_ERROR_UNLESS(((sensitive->sensitive.rsa.t.size / 5) * 2)\n\t\t\t\t  == publicArea->unique.rsa.t.size);\n\t    sensitive->sensitive.rsa.t.size |= RSA_prime_flag;\n\t}\n    return TPM_RC_SUCCESS;\n Error:\n    return TPM_RC_BINDING;\n}\n\n//*** CryptRsaEncrypt()\n// This is the entry point for encryption using RSA. Encryption is\n// use of the public exponent. The padding parameter determines what\n// padding will be used.\n//\n// The 'cOutSize' parameter must be at least as large as the size of the key.\n//\n// If the padding is RSA_PAD_NONE, 'dIn' is treated as a number. It must be\n// lower in value than the key modulus.\n// NOTE: If dIn has fewer bytes than cOut, then we don't add low-order zeros to\n//       dIn to make it the size of the RSA key for the call to RSAEP. This is\n//       because the high order bytes of dIn might have a numeric value that is\n//       greater than the value of the key modulus. If this had low-order zeros\n//       added, it would have a numeric value larger than the modulus even though\n//       it started out with a lower numeric value.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE     'cOutSize' is too small (must be the size\n//                        of the modulus)\n//      TPM_RC_SCHEME    'padType' is not a supported scheme\n//\nLIB_EXPORT TPM_RC CryptRsaEncrypt(\n\t\t\t\t  TPM2B_PUBLIC_KEY_RSA* cOut,    // OUT: the encrypted data\n\t\t\t\t  TPM2B*                dIn,     // IN: the data to encrypt\n\t\t\t\t  OBJECT*               key,     // IN: the key used for encryption\n\t\t\t\t  TPMT_RSA_DECRYPT*     scheme,  // IN: the type of padding and hash\n\t\t\t\t  //     if needed\n\t\t\t\t  const TPM2B* label,            // IN: in case it is needed\n\t\t\t\t  RAND_STATE*  rand              // IN: random number generator\n\t\t\t\t  //     state (mostly for testing)\n\t\t\t\t  )\n{\n    TPM_RC               retVal = TPM_RC_SUCCESS;\n    TPM2B_PUBLIC_KEY_RSA dataIn;\n    //\n    // if the input and output buffers are the same, copy the input to a scratch\n    // buffer so that things don't get messed up.\n    if(dIn == &cOut->b)\n\t{\n\t    MemoryCopy2B(&dataIn.b, dIn, sizeof(dataIn.t.buffer));\n\t    dIn = &dataIn.b;\n\t}\n    // All encryption schemes return the same size of data\n    cOut->t.size = key->publicArea.unique.rsa.t.size;\n    TPM_DO_SELF_TEST(scheme->scheme);\n\n    switch(scheme->scheme)\n\t{\n\t  case TPM_ALG_NULL:  // 'raw' encryption\n\t      {\n\t\t  INT32 i;\n\t\t  INT32 dSize = dIn->size;\n\t\t  // dIn can have more bytes than cOut as long as the extra bytes\n\t\t  // are zero. Note: the more significant bytes of a number in a byte\n\t\t  // buffer are the bytes at the start of the array.\n\t\t  for(i = 0; (i < dSize) && (dIn->buffer[i] == 0); i++)\n\t\t      ;\n\t\t  dSize -= i;\n\t\t  if(dSize > cOut->t.size)\n\t\t      ERROR_EXIT(TPM_RC_VALUE);\n\t\t  // Pad cOut with zeros if dIn is smaller\n\t\t  memset(cOut->t.buffer, 0, cOut->t.size - dSize);\n\t\t  // And copy the rest of the value\n\t\t  memcpy(&cOut->t.buffer[cOut->t.size - dSize], &dIn->buffer[i], dSize);\n\n\t\t  // If the size of dIn is the same as cOut dIn could be larger than\n\t\t  // the modulus. If it is, then RSAEP() will catch it.\n\t      }\n\t      break;\n\t  case TPM_ALG_RSAES:\n\t    retVal = RSAES_PKCS1v1_5Encode(&cOut->b, dIn, rand);\n\t    break;\n\t  case TPM_ALG_OAEP:\n\t    retVal =\n\t\tOaepEncode(&cOut->b, scheme->details.oaep.hashAlg, label, dIn, rand);\n\t    break;\n\t  default:\n\t    ERROR_EXIT(TPM_RC_SCHEME);\n\t    break;\n\t}\n    // All the schemes that do padding will come here for the encryption step\n    // Check that the Encoding worked\n    if(retVal == TPM_RC_SUCCESS)\n\t// Padding OK so do the encryption\n\tretVal = RSAEP(&cOut->b, key);\n Exit:\n    return retVal;\n}\n\n//*** CryptRsaDecrypt()\n// This is the entry point for decryption using RSA. Decryption is\n// use of the private exponent. The 'padType' parameter determines what\n// padding was used.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SIZE        'cInSize' is not the same as the size of the public\n//                          modulus of 'key'; or numeric value of the encrypted\n//                          data is greater than the modulus\n//      TPM_RC_VALUE       'dOutSize' is not large enough for the result\n//      TPM_RC_SCHEME      'padType' is not supported\n//\nLIB_EXPORT TPM_RC CryptRsaDecrypt(\n\t\t\t\t  TPM2B*            dOut,    // OUT: the decrypted data\n\t\t\t\t  TPM2B*            cIn,     // IN: the data to decrypt\n\t\t\t\t  OBJECT*           key,     // IN: the key to use for decryption\n\t\t\t\t  TPMT_RSA_DECRYPT* scheme,  // IN: the padding scheme\n\t\t\t\t  const TPM2B*      label    // IN: in case it is needed for the scheme\n\t\t\t\t  )\n{\n    TPM_RC retVal;\n\n    // Make sure that the necessary parameters are provided\n    pAssert(cIn != NULL && dOut != NULL && key != NULL);\n\n    // Size is checked to make sure that the encrypted value is the right size\n    if(cIn->size != key->publicArea.unique.rsa.t.size)\n\tERROR_EXIT(TPM_RC_SIZE);\n\n    TPM_DO_SELF_TEST(scheme->scheme);\n\n    // For others that do padding, do the decryption in place and then\n    // go handle the decoding.\n    retVal = RSADP(cIn, key);\n    if(retVal == TPM_RC_SUCCESS)\n\t{\n\t    // Remove padding\n\t    switch(scheme->scheme)\n\t\t{\n\t\t  case TPM_ALG_NULL:\n\t\t    if(dOut->size < cIn->size)\n\t\t\treturn TPM_RC_VALUE;\n\t\t    MemoryCopy2B(dOut, cIn, dOut->size);\n\t\t    break;\n\t\t  case TPM_ALG_RSAES:\n\t\t    retVal = RSAES_Decode(dOut, cIn);\n\t\t    break;\n\t\t  case TPM_ALG_OAEP:\n\t\t    retVal = OaepDecode(dOut, scheme->details.oaep.hashAlg, label, cIn);\n\t\t    break;\n\t\t  default:\n\t\t    retVal = TPM_RC_SCHEME;\n\t\t    break;\n\t\t}\n\t}\n Exit:\n    return retVal;\n}\n\n//*** CryptRsaSign()\n// This function is used to generate an RSA signature of the type indicated in\n// 'scheme'.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME       'scheme' or 'hashAlg' are not supported\n//      TPM_RC_VALUE        'hInSize' does not match 'hashAlg' (for RSASSA)\n//\nLIB_EXPORT TPM_RC CryptRsaSign(TPMT_SIGNATURE* sigOut,\n\t\t\t       OBJECT*         key,  // IN: key to use\n\t\t\t       TPM2B_DIGEST*   hIn,  // IN: the digest to sign\n\t\t\t       RAND_STATE* rand  // IN: the random number generator\n\t\t\t       //      to use (mostly for testing)\n\t\t\t       )\n{\n    TPM_RC retVal = TPM_RC_SUCCESS;\n    UINT16 modSize;\n\n    // parameter checks\n    pAssert(sigOut != NULL && key != NULL && hIn != NULL);\n\n    modSize = key->publicArea.unique.rsa.t.size;\n\n    // for all non-null signatures, the size is the size of the key modulus\n    sigOut->signature.rsapss.sig.t.size = modSize;\n\n    TPM_DO_SELF_TEST(sigOut->sigAlg);\n\n    switch(sigOut->sigAlg)\n\t{\n\t  case TPM_ALG_NULL:\n\t    sigOut->signature.rsapss.sig.t.size = 0;\n\t    return TPM_RC_SUCCESS;\n\t  case TPM_ALG_RSAPSS:\n\t    retVal = PssEncode(&sigOut->signature.rsapss.sig.b,\n\t\t\t       sigOut->signature.rsapss.hash,\n\t\t\t       &hIn->b,\n\t\t\t       rand);\n\t    break;\n\t  case TPM_ALG_RSASSA:\n\t    retVal = RSASSA_Encode(&sigOut->signature.rsassa.sig.b,\n\t\t\t\t   sigOut->signature.rsassa.hash,\n\t\t\t\t   &hIn->b);\n\t    break;\n\t  default:\n\t    retVal = TPM_RC_SCHEME;\n\t}\n    if(retVal == TPM_RC_SUCCESS)\n\t{\n\t    // Do the encryption using the private key\n\t    retVal = RSADP(&sigOut->signature.rsapss.sig.b, key);\n\t}\n    return retVal;\n}\n\n//*** CryptRsaValidateSignature()\n// This function is used to validate an RSA signature. If the signature is valid\n// TPM_RC_SUCCESS is returned. If the signature is not valid, TPM_RC_SIGNATURE is\n// returned. Other return codes indicate either parameter problems or fatal errors.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE    the signature does not check\n//      TPM_RC_SCHEME       unsupported scheme or hash algorithm\n//\nLIB_EXPORT TPM_RC CryptRsaValidateSignature(\n\t\t\t\t\t    TPMT_SIGNATURE* sig,    // IN: signature\n\t\t\t\t\t    OBJECT*         key,    // IN: public modulus\n\t\t\t\t\t    TPM2B_DIGEST*   digest  // IN: The digest being validated\n\t\t\t\t\t    )\n{\n    TPM_RC retVal;\n    //\n    // Fatal programming errors\n    pAssert(key != NULL && sig != NULL && digest != NULL);\n    switch(sig->sigAlg)\n\t{\n\t  case TPM_ALG_RSAPSS:\n\t  case TPM_ALG_RSASSA:\n\t    break;\n\t  default:\n\t    return TPM_RC_SCHEME;\n\t}\n\n    // Errors that might be caused by calling parameters\n    if(sig->signature.rsassa.sig.t.size != key->publicArea.unique.rsa.t.size)\n\tERROR_EXIT(TPM_RC_SIGNATURE);\n\n    TPM_DO_SELF_TEST(sig->sigAlg);\n\n    // Decrypt the block\n    retVal = RSAEP(&sig->signature.rsassa.sig.b, key);\n    if(retVal == TPM_RC_SUCCESS)\n\t{\n\t    switch(sig->sigAlg)\n\t\t{\n\t\t  case TPM_ALG_RSAPSS:\n\t\t    retVal = PssDecode(sig->signature.any.hashAlg,\n\t\t\t\t       &digest->b,\n\t\t\t\t       &sig->signature.rsassa.sig.b);\n\t\t    break;\n\t\t  case TPM_ALG_RSASSA:\n\t\t    retVal = RSASSA_Decode(sig->signature.any.hashAlg,\n\t\t\t\t\t   &digest->b,\n\t\t\t\t\t   &sig->signature.rsassa.sig.b);\n\t\t    break;\n\t\t  default:\n\t\t    return TPM_RC_SCHEME;\n\t\t}\n\t}\n Exit:\n    return (retVal != TPM_RC_SUCCESS) ? TPM_RC_SIGNATURE : TPM_RC_SUCCESS;\n}\n\n#  if SIMULATION && USE_RSA_KEY_CACHE\nextern int s_rsaKeyCacheEnabled;\nint        GetCachedRsaKey(\n\t\t\t   TPMT_PUBLIC* publicArea, TPMT_SENSITIVE* sensitive, RAND_STATE* rand);\n#    define GET_CACHED_KEY(publicArea, sensitive, rand)\t\t\t\\\n    (s_rsaKeyCacheEnabled && GetCachedRsaKey(publicArea, sensitive, rand))\n#  else\n#    define GET_CACHED_KEY(key, rand)\n#  endif\n\n//*** CryptRsaGenerateKey()\n// Generate an RSA key from a provided seed\n/*(See part 1 specification)\n//  The formulation is:\n//      KDFa(hash, seed, label, Name, Counter, bits)\n//  Where:\n//      hash        the nameAlg from the public template\n//      seed        a seed (will be a primary seed for a primary key)\n//      label       a distinguishing label including vendor ID and\n//                  vendor-assigned part number for the TPM.\n//      Name        the nameAlg from the template and the hash of the template\n//                  using nameAlg.\n//      Counter     a 32-bit integer that is incremented each time the KDF is\n//                  called in order to produce a specific key. This value\n//                  can be a 32-bit integer in host format and does not need\n//                  to be put in canonical form.\n//      bits        the number of bits needed for the key.\n//  The following process is implemented to find a RSA key pair:\n//  1. pick a random number with enough bits from KDFa as a prime candidate\n//  2. set the first two significant bits and the least significant bit of the\n//     prime candidate\n//  3. check if the number is a prime. if not, pick another random number\n//  4. Make sure the difference between the two primes are more than 2^104.\n//     Otherwise, restart the process for the second prime\n//  5. If the counter has reached its maximum but we still can not find a valid\n//     RSA key pair, return an internal error. This is an artificial bound.\n//     Other implementation may choose a smaller number to indicate how many\n//     times they are willing to try.\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_CANCELED     operation was canceled\n//      TPM_RC_RANGE        public exponent is not supported\n//      TPM_RC_VALUE        could not find a prime using the provided parameters\nLIB_EXPORT TPM_RC CryptRsaGenerateKey(\n\t\t\t\t      TPMT_PUBLIC*    publicArea,\n\t\t\t\t      TPMT_SENSITIVE* sensitive,\n\t\t\t\t      RAND_STATE*     rand  // IN: if not NULL, the deterministic\n\t\t\t\t      //     RNG state\n\t\t\t\t      )\n{\n    UINT32 i;\n    CRYPT_RSA_VAR(bnD);\n    CRYPT_RSA_VAR(bnN);\n    CRYPT_INT_WORD(bnPubExp);\n    UINT32 e = publicArea->parameters.rsaDetail.exponent;\n    int    keySizeInBits;\n    TPM_RC retVal = TPM_RC_NO_RESULT;\n    NEW_PRIVATE_EXPONENT(Z);\n    //\n\n    // Need to make sure that the caller did not specify an exponent that is\n    // not supported\n    e = publicArea->parameters.rsaDetail.exponent;\n    if(e == 0)\n\te = RSA_DEFAULT_PUBLIC_EXPONENT;\n    else\n\t{\n\t    if(e < 65537)\n\t\tERROR_EXIT(TPM_RC_RANGE);\n\t    // Check that e is prime\n\t    if(!IsPrimeInt(e))\n\t\tERROR_EXIT(TPM_RC_RANGE);\n\t}\n    ExtMath_SetWord(bnPubExp, e);\n\n    // check for supported key size.\n    keySizeInBits = publicArea->parameters.rsaDetail.keyBits;\n    if(((keySizeInBits % 1024) != 0)\n       || (keySizeInBits > MAX_RSA_KEY_BITS)  // this might be redundant, but...\n       || (keySizeInBits == 0))\n\tERROR_EXIT(TPM_RC_VALUE);\n\n    // Set the prime size for instrumentation purposes\n    INSTRUMENT_SET(PrimeIndex, PRIME_INDEX(keySizeInBits / 2));\n\n#  if SIMULATION && USE_RSA_KEY_CACHE\n    if(GET_CACHED_KEY(publicArea, sensitive, rand))\n\treturn TPM_RC_SUCCESS;\n#  endif\n\n    // Make sure that key generation has been tested\n    TPM_DO_SELF_TEST(TPM_ALG_NULL);\n\n    // The prime is computed in P. When a new prime is found, Q is checked to\n    // see if it is zero.  If so, P is copied to Q and a new P is found.\n    // When both P and Q are non-zero, the modulus and\n    // private exponent are computed and a trial encryption/decryption is\n    // performed.  If the encrypt/decrypt fails, assume that at least one of the\n    // primes is composite. Since we don't know which one, set Q to zero and start\n    // over and find a new pair of primes.\n\n    for(i = 1; (retVal == TPM_RC_NO_RESULT) && (i != 100); i++)\n\t{\n\t    if(_plat__IsCanceled())\n\t\tERROR_EXIT(TPM_RC_CANCELED);\n\n\t    if(TpmRsa_GeneratePrimeForRSA(Z->P, keySizeInBits / 2, e, rand)\n\t       == TPM_RC_FAILURE)\n\t\t{\n\t\t    retVal = TPM_RC_FAILURE;\n\t\t    goto Exit;\n\t\t}\n\n\t    INSTRUMENT_INC(PrimeCounts[PrimeIndex]);\n\n\t    // If this is the second prime, make sure that it differs from the\n\t    // first prime by at least 2^100\n\t    if(ExtMath_IsZero(Z->Q))\n\t\t{\n\t\t    // copy p to q and compute another prime in p\n\t\t    ExtMath_Copy(Z->Q, Z->P);\n\t\t    continue;\n\t\t}\n\t    // Make sure that the difference is at least 100 bits. Need to do it this\n\t    // way because the big numbers are only positive values\n\t    if(ExtMath_UnsignedCmp(Z->P, Z->Q) < 0)\n\t\tExtMath_Subtract(bnD, Z->Q, Z->P);\n\t    else\n\t\tExtMath_Subtract(bnD, Z->P, Z->Q);\n\t    if(ExtMath_MostSigBitNum(bnD) < 100)\n\t\tcontinue;\n\n\t    //Form the public modulus and set the unique value\n\t    ExtMath_Multiply(bnN, Z->P, Z->Q);\n\t    TpmMath_IntTo2B(\n\t\t\t    bnN, &publicArea->unique.rsa.b, (NUMBYTES)BITS_TO_BYTES(keySizeInBits));\n\t    // Make sure everything came out right. The MSb of the values must be one\n\t    if(((publicArea->unique.rsa.t.buffer[0] & 0x80) == 0)\n\t       || (publicArea->unique.rsa.t.size\n\t\t   != (NUMBYTES)BITS_TO_BYTES(keySizeInBits)))\n\t\tFAIL(FATAL_ERROR_INTERNAL);\n\n\t    // Make sure that we can form the private exponent values\n\t    if(ComputePrivateExponent(bnPubExp, Z) != TRUE)\n\t\t{\n\t\t    // If ComputePrivateExponent could not find an inverse for\n\t\t    // Q, then copy P and recompute P. This might\n\t\t    // cause both to be recomputed if P is also zero\n\t\t    if(ExtMath_IsZero(Z->Q))\n\t\t\tExtMath_Copy(Z->Q, Z->P);\n\t\t    continue;\n\t\t}\n\n\t    // Pack the private exponent into the sensitive area\n\t    PackExponent(&sensitive->sensitive.rsa, Z);\n\t    // Make sure everything came out right. The MSb of the values must be one\n\t    if(((publicArea->unique.rsa.t.buffer[0] & 0x80) == 0)\n\t       || ((sensitive->sensitive.rsa.t.buffer[0] & 0x80) == 0))\n\t\tFAIL(FATAL_ERROR_INTERNAL);\n\n\t    retVal = TPM_RC_SUCCESS;\n\t    // Do a trial encryption decryption if this is a signing key\n\t    if(IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sign))\n\t\t{\n\t\t    CRYPT_RSA_VAR(temp1);\n\t\t    CRYPT_RSA_VAR(temp2);\n\t\t    TpmMath_GetRandomInRange(temp1, bnN, rand);\n\n\t\t    // Encrypt with public exponent...\n\t\t    ExtMath_ModExp(temp2, temp1, bnPubExp, bnN);\n\t\t    // ...  then decrypt with private exponent\n\t\t    RsaPrivateKeyOp(temp2, Z);\n\n\t\t    // If the starting and ending values are not the same,\n\t\t    // start over )-;\n\t\t    if(ExtMath_UnsignedCmp(temp2, temp1) != 0)\n\t\t\t{\n\t\t\t    ExtMath_SetWord(Z->Q, 0);\n\t\t\t    retVal = TPM_RC_NO_RESULT;\n\t\t\t}\n\t\t}\n\t}\n Exit:\n    return retVal;\n}\n\n#endif  // ALG_RSA\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptSelfTest.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tSelf-Test of Cryptographic Functions \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// The functions in this file are designed to support self-test of cryptographic\n// functions in the TPM. The TPM allows the user to decide whether to run self-test\n// on a demand basis or to run all the self-tests before proceeding.\n//\n// The self-tests are controlled by a set of bit vectors. The\n// 'g_untestedDecryptionAlgorithms' vector has a bit for each decryption algorithm\n// that needs to be tested and 'g_untestedEncryptionAlgorithms' has a bit for\n// each encryption algorithm that needs to be tested. Before an algorithm\n// is used, the appropriate vector is checked (indexed using the algorithm ID).\n// If the bit is 1, then the test function should be called.\n//\n// For more information, see TpmSelfTests.txt\n\n#include \"Tpm.h\"\n\n//** Functions\n\n//*** RunSelfTest()\n// Local function to run self-test\nstatic TPM_RC CryptRunSelfTests(\n\t\t\t\tALGORITHM_VECTOR* toTest  // IN: the vector of the algorithms to test\n\t\t\t\t)\n{\n    TPM_ALG_ID alg;\n\n    // For each of the algorithms that are in the toTestVecor, need to run a\n    // test\n    for(alg = TPM_ALG_FIRST; alg <= TPM_ALG_LAST; alg++)\n\t{\n\t    if(TEST_BIT(alg, *toTest))\n\t\t{\n\t\t    TPM_RC result = CryptTestAlgorithm(alg, toTest);\n\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\treturn result;\n\t\t}\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptSelfTest()\n// This function is called to start/complete a full self-test.\n// If 'fullTest' is NO, then only the untested algorithms will be run. If\n// 'fullTest' is YES, then 'g_untestedDecryptionAlgorithms' is reinitialized and then\n// all tests are run.\n// This implementation of the reference design does not support processing outside\n// the framework of a TPM command. As a consequence, this command does not\n// complete until all tests are done. Since this can take a long time, the TPM\n// will check after each test to see if the command is canceled. If so, then the\n// TPM will returned TPM_RC_CANCELLED. To continue with the self-tests, call\n// TPM2_SelfTest(fullTest == No) and the TPM will complete the testing.\n//  Return Type: TPM_RC\n//      TPM_RC_CANCELED        if the command is canceled\nLIB_EXPORT\nTPM_RC\nCryptSelfTest(TPMI_YES_NO fullTest  // IN: if full test is required\n\t      )\n{\n#if ALLOW_FORCE_FAILURE_MODE\n    if(g_forceFailureMode)\n\tFAIL(FATAL_ERROR_FORCED);\n#endif\n\n    // If the caller requested a full test, then reset the to test vector so that\n    // all the tests will be run\n    if(fullTest == YES)\n\t{\n\t    MemoryCopy(g_toTest, g_implementedAlgorithms, sizeof(g_toTest));\n\t}\n    return CryptRunSelfTests(&g_toTest);\n}\n\n//*** CryptIncrementalSelfTest()\n// This function is used to perform an incremental self-test. This implementation\n// will perform the toTest values before returning. That is, it assumes that the\n// TPM cannot perform background tasks between commands.\n//\n// This command may be canceled. If it is, then there is no return result.\n// However, this command can be run again and the incremental progress will not\n// be lost.\n//  Return Type: TPM_RC\n//      TPM_RC_CANCELED         processing of this command was canceled\n//      TPM_RC_TESTING          if toTest list is not empty\n//      TPM_RC_VALUE            an algorithm in the toTest list is not implemented\nTPM_RC\nCryptIncrementalSelfTest(TPML_ALG* toTest,   // IN: list of algorithms to be tested\n\t\t\t TPML_ALG* toDoList  // OUT: list of algorithms needing test\n\t\t\t )\n{\n    ALGORITHM_VECTOR toTestVector = {0};\n    TPM_ALG_ID       alg;\n    UINT32           i;\n\n    pAssert(toTest != NULL && toDoList != NULL);\n    if(toTest->count > 0)\n\t{\n\t    // Transcribe the toTest list into the toTestVector\n\t    for(i = 0; i < toTest->count; i++)\n\t\t{\n\t\t    alg = toTest->algorithms[i];\n\n\t\t    // make sure that the algorithm value is not out of range\n\t\t    if((alg > TPM_ALG_LAST) || !TEST_BIT(alg, g_implementedAlgorithms))\n\t\t\treturn TPM_RC_VALUE;\n\t\t    SET_BIT(alg, toTestVector);\n\t\t}\n\t    // Run the test\n\t    if(CryptRunSelfTests(&toTestVector) == TPM_RC_CANCELED)\n\t\treturn TPM_RC_CANCELED;\n\t}\n    // Fill in the toDoList with the algorithms that are still untested\n    toDoList->count = 0;\n\n    for(alg = TPM_ALG_FIRST;\n\ttoDoList->count < MAX_ALG_LIST_SIZE && alg <= TPM_ALG_LAST;\n\talg++)\n\t{\n\t    if(TEST_BIT(alg, g_toTest))\n\t\ttoDoList->algorithms[toDoList->count++] = alg;\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptInitializeToTest()\n// This function will initialize the data structures for testing all the\n// algorithms. This should not be called unless CryptAlgsSetImplemented() has\n// been called\nvoid CryptInitializeToTest(void)\n{\n    // Indicate that nothing has been tested\n    memset(&g_cryptoSelfTestState, 0, sizeof(g_cryptoSelfTestState));\n\n    // Copy the implemented algorithm vector\n    MemoryCopy(g_toTest, g_implementedAlgorithms, sizeof(g_toTest));\n\n    // Setting the algorithm to null causes the test function to just clear\n    // out any algorithms for which there is no test.\n    CryptTestAlgorithm(TPM_ALG_ERROR, &g_toTest);\n\n    return;\n}\n\n//*** CryptTestAlgorithm()\n// Only point of contact with the actual self tests. If a self-test fails, there\n// is no return and the TPM goes into failure mode.\n// The call to TestAlgorithm uses an algorithm selector and a bit vector. When the\n// test is run, the corresponding bit in 'toTest' and in 'g_toTest' is CLEAR. If\n// 'toTest' is NULL, then only the bit in 'g_toTest' is CLEAR.\n// There is a special case for the call to TestAlgorithm(). When 'alg' is\n// ALG_ERROR, TestAlgorithm() will CLEAR any bit in 'toTest' for which it has\n// no test. This allows the knowledge about which algorithms have test to be\n// accessed through the interface that provides the test.\n//  Return Type: TPM_RC\n//      TPM_RC_CANCELED     test was canceled\nLIB_EXPORT\nTPM_RC\nCryptTestAlgorithm(TPM_ALG_ID alg, ALGORITHM_VECTOR* toTest)\n{\n    TPM_RC result;\n#if ENABLE_SELF_TESTS\n    result = TestAlgorithm(alg, toTest);\n#else\n    // If this is an attempt to determine the algorithms for which there is a\n    // self test, pretend that all of them do. We do that by not clearing any\n    // of the algorithm bits. When/if this function is called to run tests, it\n    // will over report. This can be changed so that any call to check on which\n    // algorithms have tests, 'toTest' can be cleared.\n    if(alg != TPM_ALG_ERROR)\n\t{\n\t    CLEAR_BIT(alg, g_toTest);\n\t    if(toTest != NULL)\n\t\tCLEAR_BIT(alg, *toTest);\n\t}\n    result = TPM_RC_SUCCESS;\n#endif\n    return result;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptSmac.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tMessage Authentication Codes Based on a Symmetric Block Cipher\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: CryptSmac.c 1658 2021-01-22 23:14:01Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2018 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 10.2.20\tCryptSmac.c */\n/* 10.2.20.1\tIntroduction */\n/* This file contains the implementation of the message authentication codes based on a symmetric\n   block cipher. These functions only use the single block encryption functions of the selected\n   symmetric cryptographic library. */\n/* 10.2.20.2\tIncludes, Defines, and Typedefs */\n#define _CRYPT_HASH_C_\n#include \"Tpm.h\"\n#if SMAC_IMPLEMENTED\n    /* 10.2.20.2.1\tCryptSmacStart() */\n    /* Function to start an SMAC. */\nUINT16\nCryptSmacStart(\n\t       HASH_STATE              *state,\n\t       TPMU_PUBLIC_PARMS       *keyParameters,\n\t       TPM_ALG_ID               macAlg,          // IN: the type of MAC\n\t       TPM2B                   *key\n\t       )\n{\n    UINT16                  retVal = 0;\n    //\n    // Make sure that the key size is correct. This should have been checked\n    // at key load, but...\n    if(BITS_TO_BYTES(keyParameters->symDetail.sym.keyBits.sym) == key->size)\n\t{\n\t    switch(macAlg)\n\t\t{\n#if ALG_CMAC\n\t\t  case TPM_ALG_CMAC:\n\t\t    retVal = CryptCmacStart(&state->state.smac, keyParameters,\n\t\t\t\t\t    macAlg, key);\n\t\t    break;\n#endif\n\t\t  default:\n\t\t    break;\n\t\t}\n\t}\n    state->type = (retVal != 0) ? HASH_STATE_SMAC : HASH_STATE_EMPTY;\n    return retVal;\n}\n/* 10.2.20.2.2\tCryptMacStart() */\n/* Function to start either an HMAC or an SMAC. Cannot reuse the CryptHmacStart() function because\n   of the difference in number of parameters. */\nUINT16\nCryptMacStart(\n\t      HMAC_STATE              *state,\n\t      TPMU_PUBLIC_PARMS       *keyParameters,\n\t      TPM_ALG_ID               macAlg,          // IN: the type of MAC\n\t      TPM2B                   *key\n\t      )\n{\n    MemorySet(state, 0, sizeof(HMAC_STATE));\n    if(CryptHashIsValidAlg(macAlg, FALSE))\n\t{\n\t    return CryptHmacStart(state, macAlg, key->size, key->buffer);\n\t}\n    else if(CryptSmacIsValidAlg(macAlg, FALSE))\n\t{\n\t    return CryptSmacStart(&state->hashState, keyParameters, macAlg, key);\n\t}\n    else\n\treturn 0;\n}\n/* 10.2.20.2.3\tCryptMacEnd() */\n/* Dispatch to the MAC end function using a size and buffer pointer. */\nUINT16\nCryptMacEnd(\n\t    HMAC_STATE          *state,\n\t    UINT32               size,\n\t    BYTE                *buffer\n\t    )\n{\n    UINT16              retVal = 0;\n    if(state->hashState.type == HASH_STATE_SMAC)\n\tretVal = (state->hashState.state.smac.smacMethods.end)(\n\t\t\t\t\t\t\t       &state->hashState.state.smac.state, size, buffer);\n    else if(state->hashState.type == HASH_STATE_HMAC)\n\tretVal = CryptHmacEnd(state, size, buffer);\n    state->hashState.type = HASH_STATE_EMPTY;\n    return retVal;\n}\n/* 10.2.20.2.4\tCryptMacEnd2B() */\n/* Dispatch to the MAC end function using a 2B. */\nUINT16\nCryptMacEnd2B (\n\t       HMAC_STATE          *state,\n\t       TPM2B               *data\n\t       )\n{\n    return CryptMacEnd(state, data->size, data->buffer);\n}\n#endif // SMAC_IMPLEMENTED\n\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptSym.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Symmetric block cipher modes\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 10.2.19 CryptSym.c */\n/* 10.2.19.1 Introduction */\n/* This file contains the implementation of the symmetric block cipher modes allowed for a\n   TPM. These functions only use the single block encryption functions of the selected symmetric\n   crypto library. */\n\n/* 10.2.19.2\tIncludes, Defines, and Typedefs */\n#include \"Tpm.h\"\n#include \"CryptSym.h\"\n\n\n#define     KEY_BLOCK_SIZES(ALG, alg)\t\t\t\t\t\\\n    static const INT16       alg##KeyBlockSizes[] = {\t\t\t\\\n\t\t\t\t\t\t     ALG##_KEY_SIZES_BITS, -1, ALG##_BLOCK_SIZES };\n\nFOR_EACH_SYM(KEY_BLOCK_SIZES)\n\n/* 10.2.19.3\tInitialization and Data Access Functions */\n/* 10.2.19.3.1\tCryptSymInit() */\n/* This function is called to do _TPM_Init() processing */\nBOOL\nCryptSymInit(\n\t     void\n\t     )\n{\n    return TRUE;\n}\n/* 10.2.19.3.2\tCryptSymStartup() */\n/* This function is called to do TPM2_Startup() processing */\nBOOL\nCryptSymStartup(\n\t\tvoid\n\t\t)\n{\n    return TRUE;\n}\n/* 10.2.20.4 Data Access Functions */\n/* 10.2.20.4.1 CryptGetSymmetricBlockSize() */\n/* This function returns the block size of the algorithm. The table of bit sizes has an entry for\n   each allowed key size. The entry for a key size is 0 if the TPM does not implement that key\n   size. The key size table is delimited with a negative number (-1). After the delimiter is a list\n   of block sizes with each entry corresponding to the key bit size. For most symmetric algorithms,\n   the block size is the same regardless of the key size but this arrangement allows them to be\n   different. */\n/* Return Values Meaning */\n/* <= 0 cipher not supported */\n/* > 0 the cipher block size in bytes */\n\nLIB_EXPORT INT16\nCryptGetSymmetricBlockSize(\n\t\t\t   TPM_ALG_ID      symmetricAlg,   // IN: the symmetric algorithm\n\t\t\t   UINT16          keySizeInBits   // IN: the key size\n\t\t\t   )\n{\n    const INT16    *sizes;\n    INT16            i;\n#define ALG_CASE(SYM, sym)  case TPM_ALG_##SYM: sizes = sym##KeyBlockSizes; break\n    switch(symmetricAlg)\n\t{\n#define GET_KEY_BLOCK_POINTER(SYM, sym)\t\t\t\t\t\\\n\t    case TPM_ALG_##SYM:\t\t\t\t\t\t\\\n\t      sizes =  sym##KeyBlockSizes;\t\t\t\t\\\n\t      break;\n\t    // Get the pointer to the block size array\n\t    FOR_EACH_SYM(GET_KEY_BLOCK_POINTER);\n\n\t  default:\n\t    return 0;\n\t}\n    // Find the index of the indicated keySizeInBits\n    for(i = 0; *sizes >= 0; i++, sizes++)\n\t{\n\t    if(*sizes == keySizeInBits)\n\t\tbreak;\n\t}\n    // If sizes is pointing at the end of the list of key sizes, then the desired\n    // key size was not found so set the block size to zero.\n    if(*sizes++ < 0)\n\treturn 0;\n    // Advance until the end of the list is found\n    while(*sizes++ >= 0);\n    // sizes is pointing to the first entry in the list of block sizes. Use the\n    // ith index to find the block size for the corresponding key size.\n    return sizes[i];\n}\n\n/* 10.2.20.5 Symmetric Encryption */\n/* This function performs symmetric encryption based on the mode. */\n/* Error Returns Meaning */\n/* TPM_RC_SIZE dSize is not a multiple of the block size for an algorithm that requires it */\n/* TPM_RC_FAILURE Fatal error */\nLIB_EXPORT TPM_RC\nCryptSymmetricEncrypt(\n\t\t      BYTE                *dOut,          // OUT:\n\t\t      TPM_ALG_ID           algorithm,     // IN: the symmetric algorithm\n\t\t      UINT16               keySizeInBits, // IN: key size in bits\n\t\t      const BYTE          *key,           // IN: key buffer. The size of this buffer\n\t\t      //     in bytes is (keySizeInBits + 7) / 8\n\t\t      TPM2B_IV            *ivInOut,       // IN/OUT: IV for decryption.\n\t\t      TPM_ALG_ID           mode,          // IN: Mode to use\n\t\t      INT32                dSize,         // IN: data size (may need to be a\n\t\t      //     multiple of the blockSize)\n\t\t      const BYTE          *dIn            // IN: data buffer\n\t\t      )\n{\n    BYTE                *pIv;\n    int                  i;\n    BYTE                 tmp[MAX_SYM_BLOCK_SIZE];\n    BYTE                *pT;\n    tpmCryptKeySchedule_t        keySchedule;\n    INT16                blockSize;\n    TpmCryptSetSymKeyCall_t        encrypt;\n    BYTE                *iv;\n    BYTE                 defaultIv[MAX_SYM_BLOCK_SIZE] = {0};\n    //\n    pAssert(dOut != NULL && key != NULL && dIn != NULL);\n    memset((void *)&keySchedule, 0, sizeof(keySchedule));\t/* silence false positive */\n    memset(tmp, 0, sizeof(tmp));\n    if(dSize == 0)\n\treturn TPM_RC_SUCCESS;\n    TPM_DO_SELF_TEST(algorithm);\n    blockSize = CryptGetSymmetricBlockSize(algorithm, keySizeInBits);\n    if(blockSize == 0)\n\treturn TPM_RC_FAILURE;\n    // If the iv is provided, then it is expected to be block sized. In some cases,\n    // the caller is providing an array of 0's that is equal to [MAX_SYM_BLOCK_SIZE]\n    // with no knowledge of the actual block size. This function will set it.\n    if((ivInOut != NULL) && (mode != TPM_ALG_ECB))\n\t{\n\t    ivInOut->t.size = blockSize;\n\t    iv = ivInOut->t.buffer;\n\t}\n    else\n\tiv = defaultIv;\n    pIv = iv;\n    // Create encrypt key schedule and set the encryption function pointer.\n    switch (algorithm)\n\t{\n\t    FOR_EACH_SYM(ENCRYPT_CASE)\n\n\t  default:\n\t    return TPM_RC_SYMMETRIC;\n\t}\n    switch(mode)\n\t{\n#if ALG_CTR\n\t  case TPM_ALG_CTR:\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    // Encrypt the current value of the IV(counter)\n\t\t    ENCRYPT(&keySchedule, iv, tmp);\n\t\t    //increment the counter (counter is big-endian so start at end)\n\t\t    for(i = blockSize - 1; i >= 0; i--)\n\t\t\tif((iv[i] += 1) != 0)\n\t\t\t    break;\n\t\t    // XOR the encrypted counter value with input and put into output\n\t\t    pT = tmp;\n\t\t    for(i = (dSize < blockSize) ? dSize : blockSize; i > 0; i--)\n\t\t\t*dOut++ = *dIn++ ^ *pT++;\n\t\t}\n\t    break;\n#endif\n#if ALG_OFB\n\t  case TPM_ALG_OFB:\n\t    // This is written so that dIn and dOut may be the same\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    // Encrypt the current value of the \"IV\"\n\t\t    ENCRYPT(&keySchedule, iv, iv);\n\t\t    // XOR the encrypted IV into dIn to create the cipher text (dOut)\n\t\t    pIv = iv;\n\t\t    for(i = (dSize < blockSize) ? dSize : blockSize; i > 0; i--)\n\t\t\t*dOut++ = (*pIv++ ^ *dIn++);\n\t\t}\n\t    break;\n#endif\n#if ALG_CBC\n\t  case TPM_ALG_CBC:\n\t    // For CBC the data size must be an even multiple of the\n\t    // cipher block size\n\t    if((dSize % blockSize) != 0)\n\t\treturn TPM_RC_SIZE;\n\t    // XOR the data block into the IV, encrypt the IV into the IV\n\t    // and then copy the IV to the output\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    pIv = iv;\n\t\t    for(i = blockSize; i > 0; i--)\n\t\t\t*pIv++ ^= *dIn++;\n\t\t    ENCRYPT(&keySchedule, iv, iv);\n\t\t    pIv = iv;\n\t\t    for(i = blockSize; i > 0; i--)\n\t\t\t*dOut++ = *pIv++;\n\t\t}\n\t    break;\n#endif\n\t    // CFB is not optional\n\t  case TPM_ALG_CFB:\n\t    // Encrypt the IV into the IV, XOR in the data, and copy to output\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    // Encrypt the current value of the IV\n\t\t    ENCRYPT(&keySchedule, iv, iv);\n\t\t    pIv = iv;\n\t\t    for(i = (int)(dSize < blockSize) ? dSize : blockSize; i > 0; i--)\n\t\t\t// XOR the data into the IV to create the cipher text\n\t\t\t// and put into the output\n\t\t\t*dOut++ = *pIv++ ^= *dIn++;\n\t\t}\n\t    // If the inner loop (i loop) was smaller than blockSize, then dSize\n\t    // would have been smaller than blockSize and it is now negative. If\n\t    // it is negative, then it indicates how many bytes are needed to pad\n\t    // out the IV for the next round.\n\t    for(; dSize < 0; dSize++)\n\t\t*pIv++ = 0;\n\t    break;\n#if ALG_ECB\n\t  case TPM_ALG_ECB:\n\t    // For ECB the data size must be an even multiple of the\n\t    // cipher block size\n\t    if((dSize % blockSize) != 0)\n\t\treturn TPM_RC_SIZE;\n\t    // Encrypt the input block to the output block\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    ENCRYPT(&keySchedule, dIn, dOut);\n\t\t    dIn = &dIn[blockSize];\n\t\t    dOut = &dOut[blockSize];\n\t\t}\n\t    break;\n#endif\n\t  default:\n\t    return TPM_RC_FAILURE;\n\t}\n    return TPM_RC_SUCCESS;\n}\n/* 10.2.20.5.1 CryptSymmetricDecrypt() */\n/* This function performs symmetric decryption based on the mode. */\n/* Error Returns Meaning */\n/* TPM_RC_FAILURE A fatal error */\n/* TPM_RCS_SIZE dSize is not a multiple of the block size for an algorithm that requires it */\nLIB_EXPORT TPM_RC\nCryptSymmetricDecrypt(\n\t\t      BYTE                *dOut,          // OUT: decrypted data\n\t\t      TPM_ALG_ID           algorithm,     // IN: the symmetric algorithm\n\t\t      UINT16               keySizeInBits, // IN: key size in bits\n\t\t      const BYTE          *key,           // IN: key buffer. The size of this buffer\n\t\t      //     in bytes is (keySizeInBits + 7) / 8\n\t\t      TPM2B_IV            *ivInOut,       // IN/OUT: IV for decryption.\n\t\t      TPM_ALG_ID           mode,          // IN: Mode to use\n\t\t      INT32                dSize,         // IN: data size (may need to be a\n\t\t      //     multiple of the blockSize)\n\t\t      const BYTE          *dIn            // IN: data buffer\n\t\t      )\n{\n    BYTE                *pIv;\n    int                  i;\n    BYTE                 tmp[MAX_SYM_BLOCK_SIZE];\n    BYTE                *pT;\n    tpmCryptKeySchedule_t        keySchedule;\n    INT16                blockSize;\n    BYTE                *iv;\n    TpmCryptSetSymKeyCall_t        encrypt;\n    TpmCryptSetSymKeyCall_t        decrypt;\n    BYTE                 defaultIv[MAX_SYM_BLOCK_SIZE] = {0};\n\n    memset((void *)&keySchedule, 0, sizeof(keySchedule));\t/* silence false positive */\n    memset(tmp, 0, sizeof(tmp));\n    // These are used but the compiler can't tell because they are initialized\n    // in case statements and it can't tell if they are always initialized\n    // when needed, so... Comment these out if the compiler can tell or doesn't\n    // care that these are initialized before use.\n    encrypt = NULL;\n    decrypt = NULL;\n    pAssert(dOut != NULL && key != NULL && dIn != NULL);\n    if(dSize == 0)\n\treturn TPM_RC_SUCCESS;\n    TPM_DO_SELF_TEST(algorithm);\n    blockSize = CryptGetSymmetricBlockSize(algorithm, keySizeInBits);\n    if(blockSize == 0)\n\treturn TPM_RC_FAILURE;\n    // If the iv is provided, then it is expected to be block sized. In some cases,\n    // the caller is providing an array of 0's that is equal to [MAX_SYM_BLOCK_SIZE]\n    // with no knowledge of the actual block size. This function will set it.\n    if((ivInOut != NULL) && (mode != TPM_ALG_ECB))\n\t{\n\t    ivInOut->t.size = blockSize;\n\t    iv = ivInOut->t.buffer;\n\t}\n    else\n\tiv = defaultIv;\n    pIv = iv;\n    // Use the mode to select the key schedule to create. Encrypt always uses the\n    // encryption schedule. Depending on the mode, decryption might use either\n    // the decryption or encryption schedule.\n    switch(mode)\n\t{\n#if ALG_CBC || ALG_ECB\n\t  case TPM_ALG_CBC: // decrypt = decrypt\n\t  case TPM_ALG_ECB:\n\t    // For ECB and CBC, the data size must be an even multiple of the\n\t    // cipher block size\n\t    if((dSize % blockSize) != 0)\n\t\treturn TPM_RC_SIZE;\n\t    switch (algorithm)\n\t\t{\n\t\t    FOR_EACH_SYM(DECRYPT_CASE)\n\t\t  default:\n\t\t    return TPM_RC_SYMMETRIC;\n\t\t}\n\t    break;\n#endif\n\t  default:\n\t    // For the remaining stream ciphers, use encryption to decrypt\n\t    switch (algorithm)\n\t\t{\n\t\t    FOR_EACH_SYM(ENCRYPT_CASE)\n\t\t  default:\n\t\t    return TPM_RC_SYMMETRIC;\n\t\t}\n\t}\n    // Now do the mode-dependent decryption\n    switch(mode)\n\t{\n#if ALG_CBC\n\t  case TPM_ALG_CBC:\n\t    // Copy the input data to a temp buffer, decrypt the buffer into the\n\t    // output, XOR in the IV, and copy the temp buffer to the IV and repeat.\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    pT = tmp;\n\t\t    for(i = blockSize; i > 0; i--)\n\t\t\t*pT++ = *dIn++;\n\t\t    DECRYPT(&keySchedule, tmp, dOut);\n\t\t    pIv = iv;\n\t\t    pT = tmp;\n\t\t    for(i = blockSize; i > 0; i--)\n\t\t\t{\n\t\t\t    *dOut++ ^= *pIv;\n\t\t\t    *pIv++ = *pT++;\n\t\t\t}\n\t\t}\n\t    break;\n#endif\n\t  case TPM_ALG_CFB:\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    // Encrypt the IV into the temp buffer\n\t\t    ENCRYPT(&keySchedule, iv, tmp);\n\t\t    pT = tmp;\n\t\t    pIv = iv;\n\t\t    for(i = (dSize < blockSize) ? dSize : blockSize; i > 0; i--)\n\t\t\t// Copy the current cipher text to IV, XOR\n\t\t\t// with the temp buffer and put into the output\n\t\t\t*dOut++ = *pT++ ^ (*pIv++ = *dIn++);\n\t\t}\n\t    // If the inner loop (i loop) was smaller than blockSize, then dSize\n\t    // would have been smaller than blockSize and it is now negative\n\t    // If it is negative, then it indicates how may fill bytes\n\t    // are needed to pad out the IV for the next round.\n\t    for(; dSize < 0; dSize++)\n\t\t*pIv++ = 0;\n\t    break;\n#if ALG_CTR\n\t  case TPM_ALG_CTR:\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    // Encrypt the current value of the IV(counter)\n\t\t    ENCRYPT(&keySchedule, iv, tmp);\n\t\t    //increment the counter (counter is big-endian so start at end)\n\t\t    for(i = blockSize - 1; i >= 0; i--)\n\t\t\tif((iv[i] += 1) != 0)\n\t\t\t    break;\n\t\t    // XOR the encrypted counter value with input and put into output\n\t\t    pT = tmp;\n\t\t    for(i = (dSize < blockSize) ? dSize : blockSize; i > 0; i--)\n\t\t\t*dOut++ = *dIn++ ^ *pT++;\n\t\t}\n\t    break;\n#endif\n#if ALG_ECB\n\t  case TPM_ALG_ECB:\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    DECRYPT(&keySchedule, dIn, dOut);\n\t\t    dIn = &dIn[blockSize];\n\t\t    dOut = &dOut[blockSize];\n\t\t}\n\t    break;\n#endif\n#if ALG_OFB\n\t  case TPM_ALG_OFB:\n\t    // This is written so that dIn and dOut may be the same\n\t    for(; dSize > 0; dSize -= blockSize)\n\t\t{\n\t\t    // Encrypt the current value of the \"IV\"\n\t\t    ENCRYPT(&keySchedule, iv, iv);\n\t\t    // XOR the encrypted IV into dIn to create the cipher text (dOut)\n\t\t    pIv = iv;\n\t\t    for(i = (dSize < blockSize) ? dSize : blockSize; i > 0; i--)\n\t\t\t*dOut++ = (*pIv++ ^ *dIn++);\n\t\t}\n\t    break;\n#endif\n\t  default:\n\t    return TPM_RC_FAILURE;\n\t}\n    return TPM_RC_SUCCESS;\n}\n/* 10.2.20.5.2 CryptSymKeyValidate() */\n/* Validate that a provided symmetric key meets the requirements of the TPM */\n/* Error Returns Meaning */\n/* TPM_RC_KEY_SIZE Key size specifiers do not match */\n/* TPM_RC_KEY Key is not allowed */\nTPM_RC\nCryptSymKeyValidate(\n\t\t    TPMT_SYM_DEF_OBJECT *symDef,\n\t\t    TPM2B_SYM_KEY       *key\n\t\t    )\n{\n    if(key->t.size != BITS_TO_BYTES(symDef->keyBits.sym))\n\treturn TPM_RCS_KEY_SIZE;\n#if ALG_TDES\n    if(symDef->algorithm == TPM_ALG_TDES && !CryptDesValidateKey(key))\n\treturn TPM_RCS_KEY;\n#endif // TPM_ALG_TDES\n    return TPM_RC_SUCCESS;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/CryptUtil.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tInterfaces to the Crypto Engine\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n//  This module contains the interfaces to the CryptoEngine and provides\n//  miscellaneous cryptographic functions in support of the TPM.\n//\n\n//** Includes\n#include \"Tpm.h\"\n#include \"Marshal.h\"\n\n//****************************************************************************/\n//**     Hash/HMAC Functions\n//****************************************************************************/\n\n//*** CryptHmacSign()\n// Sign a digest using an HMAC key. This an HMAC of a digest, not an HMAC of a\n// message.\n//  Return Type: TPM_RC\n//      TPM_RC_HASH         not a valid hash\nstatic TPM_RC CryptHmacSign(TPMT_SIGNATURE* signature,  // OUT: signature\n\t\t\t    OBJECT*         signKey,    // IN: HMAC key sign the hash\n\t\t\t    TPM2B_DIGEST*   hashData    // IN: hash to be signed\n\t\t\t    )\n{\n    HMAC_STATE hmacState;\n    UINT32     digestSize;\n\n    digestSize = CryptHmacStart2B(&hmacState,\n\t\t\t\t  signature->signature.any.hashAlg,\n\t\t\t\t  &signKey->sensitive.sensitive.bits.b);\n    CryptDigestUpdate2B(&hmacState.hashState, &hashData->b);\n    CryptHmacEnd(&hmacState, digestSize, (BYTE*)&signature->signature.hmac.digest);\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptHMACVerifySignature()\n// This function will verify a signature signed by a HMAC key.\n// Note that a caller needs to prepare 'signature' with the signature algorithm\n// (TPM_ALG_HMAC) and the hash algorithm to use. This function then builds a\n// signature of that type.\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME           not the proper scheme for this key type\n//      TPM_RC_SIGNATURE        if invalid input or signature is not genuine\nstatic TPM_RC CryptHMACVerifySignature(\n\t\t\t\t       OBJECT*         signKey,   // IN: HMAC key signed the hash\n\t\t\t\t       TPM2B_DIGEST*   hashData,  // IN: digest being verified\n\t\t\t\t       TPMT_SIGNATURE* signature  // IN: signature to be verified\n\t\t\t\t       )\n{\n    TPMT_SIGNATURE         test;\n    TPMT_KEYEDHASH_SCHEME* keyScheme =\n\t&signKey->publicArea.parameters.keyedHashDetail.scheme;\n    //\n    if((signature->sigAlg != TPM_ALG_HMAC)\n       || (signature->signature.hmac.hashAlg == TPM_ALG_NULL))\n\treturn TPM_RC_SCHEME;\n    // This check is not really needed for verification purposes. However, it does\n    // prevent someone from trying to validate a signature using a weaker hash\n    // algorithm than otherwise allowed by the key. That is, a key with a scheme\n    // other than TMP_ALG_NULL can only be used to validate signatures that have\n    // a matching scheme.\n    if((keyScheme->scheme != TPM_ALG_NULL)\n       && ((keyScheme->scheme != signature->sigAlg)\n\t   || (keyScheme->details.hmac.hashAlg != signature->signature.any.hashAlg)))\n\treturn TPM_RC_SIGNATURE;\n    test.sigAlg                 = signature->sigAlg;\n    test.signature.hmac.hashAlg = signature->signature.hmac.hashAlg;\n\n    CryptHmacSign(&test, signKey, hashData);\n\n    // Compare digest\n    if(!MemoryEqual(&test.signature.hmac.digest,\n\t\t    &signature->signature.hmac.digest,\n\t\t    CryptHashGetDigestSize(signature->signature.any.hashAlg)))\n\treturn TPM_RC_SIGNATURE;\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptGenerateKeyedHash()\n// This function creates a keyedHash object.\n// Return type: TPM_RC\n//      TPM_RC_NO_RESULT    cannot get values from random number generator\n//      TPM_RC_SIZE         sensitive data size is larger than allowed for\n//                          the scheme\nstatic TPM_RC CryptGenerateKeyedHash(\n\t\t\t\t     TPMT_PUBLIC* publicArea,                 // IN/OUT: the public area template\n\t\t\t\t     //     for the new key.\n\t\t\t\t     TPMT_SENSITIVE*        sensitive,        // OUT: sensitive area\n\t\t\t\t     TPMS_SENSITIVE_CREATE* sensitiveCreate,  // IN: sensitive creation data\n\t\t\t\t     RAND_STATE*            rand              // IN: \"entropy\" source\n\t\t\t\t     )\n{\n    TPMT_KEYEDHASH_SCHEME* scheme;\n    TPM_ALG_ID             hashAlg;\n    UINT16                 digestSize;\n\n    scheme = &publicArea->parameters.keyedHashDetail.scheme;\n\n    if(publicArea->type != TPM_ALG_KEYEDHASH)\n\treturn TPM_RC_FAILURE;\n\n    // Pick the limiting hash algorithm\n    if(scheme->scheme == TPM_ALG_NULL)\n\thashAlg = publicArea->nameAlg;\n    else if(scheme->scheme == TPM_ALG_XOR)\n\thashAlg = scheme->details.xorr.hashAlg;\n    else\n\thashAlg = scheme->details.hmac.hashAlg;\n    digestSize = CryptHashGetDigestSize(hashAlg);\n\n    // if this is a signing or a decryption key, then the limit\n    // for the data size is the block size of the hash. This limit\n    // is set because larger values have lower entropy because of the\n    // HMAC function. The lower limit is 1/2 the size of the digest\n    //\n    //If the user provided the key, check that it is a proper size\n    if(sensitiveCreate->data.t.size != 0)\n\t{\n\t    if(IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, decrypt)\n\t       || IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sign))\n\t\t{\n\t\t    if(sensitiveCreate->data.t.size > CryptHashGetBlockSize(hashAlg))\n\t\t\treturn TPM_RC_SIZE;\n#if 0  // May make this a FIPS-mode requirement\n\t\t    if(sensitiveCreate->data.t.size < (digestSize / 2))\n\t\t\treturn TPM_RC_SIZE;\n#endif\n\t\t}\n\t    // If this is a data blob, then anything that will get past the unmarshaling\n\t    // is OK\n\t    MemoryCopy2B(&sensitive->sensitive.bits.b,\n\t\t\t &sensitiveCreate->data.b,\n\t\t\t sizeof(sensitive->sensitive.bits.t.buffer));\n\t}\n    else\n\t{\n\t    // The TPM is going to generate the data so set the size to be the\n\t    // size of the digest of the algorithm\n\t    sensitive->sensitive.bits.t.size =\n\t\tDRBG_Generate(rand, sensitive->sensitive.bits.t.buffer, digestSize);\n\t    if(sensitive->sensitive.bits.t.size == 0)\n\t\treturn (g_inFailureMode) ? TPM_RC_FAILURE : TPM_RC_NO_RESULT;\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptIsSchemeAnonymous()\n// This function is used to test a scheme to see if it is an anonymous scheme\n// The only anonymous scheme is ECDAA. ECDAA can be used to do things\n// like U-Prove.\nBOOL CryptIsSchemeAnonymous(TPM_ALG_ID scheme  // IN: the scheme algorithm to test\n\t\t\t    )\n{\n    return scheme == TPM_ALG_ECDAA;\n}\n\n//**** ************************************************************************\n//** Symmetric Functions\n//**** ************************************************************************\n\n//*** ParmDecryptSym()\n//  This function performs parameter decryption using symmetric block cipher.\n/*(See Part 1 specification)\n// Symmetric parameter decryption\n//      When parameter decryption uses a symmetric block cipher, a decryption\n//      key and IV will be generated from:\n//      KDFa(hash, sessionAuth, \"CFB\", nonceNewer, nonceOlder, bits)    (24)\n//      Where:\n//      hash            the hash function associated with the session\n//      sessionAuth     the sessionAuth associated with the session\n//      nonceNewer      nonceCaller for a command\n//      nonceOlder      nonceTPM for a command\n//      bits            the number of bits required for the symmetric key\n//                      plus an IV\n*/\nvoid ParmDecryptSym(TPM_ALG_ID symAlg,         // IN: the symmetric algorithm\n\t\t    TPM_ALG_ID hash,           // IN: hash algorithm for KDFa\n\t\t    UINT16     keySizeInBits,  // IN: the key size in bits\n\t\t    TPM2B*     key,            // IN: KDF HMAC key\n\t\t    TPM2B*     nonceCaller,    // IN: nonce caller\n\t\t    TPM2B*     nonceTpm,       // IN: nonce TPM\n\t\t    UINT32     dataSize,       // IN: size of parameter buffer\n\t\t    BYTE*      data            // OUT: buffer to be decrypted\n\t\t    )\n{\n    // KDF output buffer\n    // It contains parameters for the CFB encryption\n    // From MSB to LSB, they are the key and iv\n    BYTE symParmString[MAX_SYM_KEY_BYTES + MAX_SYM_BLOCK_SIZE];\n    // Symmetric key size in byte\n    UINT16   keySize = (keySizeInBits + 7) / 8;\n    TPM2B_IV iv;\n\n    iv.t.size = CryptGetSymmetricBlockSize(symAlg, keySizeInBits);\n    // If there is decryption to do...\n    if(iv.t.size > 0)\n\t{\n\t    // Generate key and iv\n\t    CryptKDFa(hash,\n\t\t      key,\n\t\t      CFB_KEY,\n\t\t      nonceCaller,\n\t\t      nonceTpm,\n\t\t      keySizeInBits + (iv.t.size * 8),\n\t\t      symParmString,\n\t\t      NULL,\n\t\t      FALSE);\n\t    MemoryCopy(iv.t.buffer, &symParmString[keySize], iv.t.size);\n\n\t    CryptSymmetricDecrypt(data,\n\t\t\t\t  symAlg,\n\t\t\t\t  keySizeInBits,\n\t\t\t\t  symParmString,\n\t\t\t\t  &iv,\n\t\t\t\t  TPM_ALG_CFB,\n\t\t\t\t  dataSize,\n\t\t\t\t  data);\n\t}\n    return;\n}\n\n//*** ParmEncryptSym()\n//  This function performs parameter encryption using symmetric block cipher.\n/*(See part 1 specification)\n//      When parameter decryption uses a symmetric block cipher, an encryption\n//      key and IV will be generated from:\n//      KDFa(hash, sessionAuth, \"CFB\", nonceNewer, nonceOlder, bits)    (24)\n//      Where:\n//      hash            the hash function associated with the session\n//      sessionAuth     the sessionAuth associated with the session\n//      nonceNewer      nonceTPM for a response\n//      nonceOlder      nonceCaller for a response\n//      bits            the number of bits required for the symmetric key\n//                      plus an IV\n*/\nvoid ParmEncryptSym(TPM_ALG_ID symAlg,         // IN: symmetric algorithm\n\t\t    TPM_ALG_ID hash,           // IN: hash algorithm for KDFa\n\t\t    UINT16     keySizeInBits,  // IN: symmetric key size in bits\n\t\t    TPM2B*     key,            // IN: KDF HMAC key\n\t\t    TPM2B*     nonceCaller,    // IN: nonce caller\n\t\t    TPM2B*     nonceTpm,       // IN: nonce TPM\n\t\t    UINT32     dataSize,       // IN: size of parameter buffer\n\t\t    BYTE*      data            // OUT: buffer to be encrypted\n\t\t    )\n{\n    // KDF output buffer\n    // It contains parameters for the CFB encryption\n    BYTE symParmString[MAX_SYM_KEY_BYTES + MAX_SYM_BLOCK_SIZE];\n\n    // Symmetric key size in bytes\n    UINT16   keySize = (keySizeInBits + 7) / 8;\n\n    TPM2B_IV iv;\n\n    iv.t.size = CryptGetSymmetricBlockSize(symAlg, keySizeInBits);\n    // See if there is any encryption to do\n    if(iv.t.size > 0)\n\t{\n\t    // Generate key and iv\n\t    CryptKDFa(hash,\n\t\t      key,\n\t\t      CFB_KEY,\n\t\t      nonceTpm,\n\t\t      nonceCaller,\n\t\t      keySizeInBits + (iv.t.size * 8),\n\t\t      symParmString,\n\t\t      NULL,\n\t\t      FALSE);\n\t    MemoryCopy(iv.t.buffer, &symParmString[keySize], iv.t.size);\n\n\t    CryptSymmetricEncrypt(data,\n\t\t\t\t  symAlg,\n\t\t\t\t  keySizeInBits,\n\t\t\t\t  symParmString,\n\t\t\t\t  &iv,\n\t\t\t\t  TPM_ALG_CFB,\n\t\t\t\t  dataSize,\n\t\t\t\t  data);\n\t}\n    return;\n}\n\n//*** CryptGenerateKeySymmetric()\n// This function generates a symmetric cipher key. The derivation process is\n// determined by the type of the provided 'rand'\n// Return type: TPM_RC\n//      TPM_RC_NO_RESULT    cannot get a random value\n//      TPM_RC_KEY_SIZE     key size in the public area does not match the size\n//                          in the sensitive creation area\n//      TPM_RC_KEY          provided key value is not allowed\nstatic TPM_RC CryptGenerateKeySymmetric(\n\t\t\t\t\tTPMT_PUBLIC* publicArea,                 // IN/OUT: The public area template\n\t\t\t\t\t//     for the new key.\n\t\t\t\t\tTPMT_SENSITIVE*        sensitive,        // OUT: sensitive area\n\t\t\t\t\tTPMS_SENSITIVE_CREATE* sensitiveCreate,  // IN: sensitive creation data\n\t\t\t\t\tRAND_STATE*            rand              // IN: the \"entropy\" source for\n\t\t\t\t\t)\n{\n    UINT16 keyBits = publicArea->parameters.symDetail.sym.keyBits.sym;\n    TPM_RC result;\n    //\n    // only do multiples of RADIX_BITS\n    if((keyBits % RADIX_BITS) != 0)\n\treturn TPM_RC_KEY_SIZE;\n    // If this is not a new key, then the provided key data must be the right size\n    if(sensitiveCreate->data.t.size != 0)\n\t{\n\t    result = CryptSymKeyValidate(&publicArea->parameters.symDetail.sym,\n\t\t\t\t\t (TPM2B_SYM_KEY*)&sensitiveCreate->data);\n\t             if(result == TPM_RC_SUCCESS)\n\t\t\t MemoryCopy2B(&sensitive->sensitive.sym.b,\n\t\t\t\t      &sensitiveCreate->data.b,\n\t\t\t\t      sizeof(sensitive->sensitive.sym.t.buffer));\n\t}\n    else\n\t{\n\t    sensitive->sensitive.sym.t.size = DRBG_Generate(\n\t\t\t\t\t\t\t    rand, sensitive->sensitive.sym.t.buffer, BITS_TO_BYTES(keyBits));\n\t    if(g_inFailureMode)\n\t\tresult = TPM_RC_FAILURE;\n\t    else if(sensitive->sensitive.sym.t.size == 0)\n\t\tresult = TPM_RC_NO_RESULT;\n\t    else\n\t\tresult = TPM_RC_SUCCESS;\n\t}\n    return result;\n}\n\n//*** CryptXORObfuscation()\n// This function implements XOR obfuscation. It should not be called if the\n// hash algorithm is not implemented. The only return value from this function\n// is TPM_RC_SUCCESS.\nvoid CryptXORObfuscation(TPM_ALG_ID hash,      // IN: hash algorithm for KDF\n\t\t\t TPM2B*     key,       // IN: KDF key\n\t\t\t TPM2B*     contextU,  // IN: contextU\n\t\t\t TPM2B*     contextV,  // IN: contextV\n\t\t\t UINT32     dataSize,  // IN: size of data buffer\n\t\t\t BYTE*      data       // IN/OUT: data to be XORed in place\n\t\t\t )\n{\n    BYTE   mask[MAX_DIGEST_SIZE];  // Allocate a digest sized buffer\n    BYTE*  pm;\n    UINT32 i;\n    UINT32 counter     = 0;\n    UINT16 hLen        = CryptHashGetDigestSize(hash);\n    UINT32 requestSize = dataSize * 8;\n    INT32  remainBytes = (INT32)dataSize;\n\n    pAssert((key != NULL) && (data != NULL) && (hLen != 0));\n\n    // Call KDFa to generate XOR mask\n    for(; remainBytes > 0; remainBytes -= hLen)\n\t{\n\t    // Make a call to KDFa to get next iteration\n\t    CryptKDFa(hash,\n\t\t      key,\n\t\t      XOR_KEY,\n\t\t      contextU,\n\t\t      contextV,\n\t\t      requestSize,\n\t\t      mask,\n\t\t      &counter,\n\t\t      TRUE);\n\n\t    // XOR next piece of the data\n\t    pm = mask;\n\t    for(i = hLen < remainBytes ? hLen : remainBytes; i > 0; i--)\n\t\t*data++ ^= *pm++;\n\t}\n    return;\n}\n\n//****************************************************************************\n//** Initialization and shut down\n//****************************************************************************\n\n//*** CryptInit()\n// This function is called when the TPM receives a _TPM_Init indication.\n//\n// NOTE: The hash algorithms do not have to be tested, they just need to be\n// available. They have to be tested before the TPM can accept HMAC authorization\n// or return any result that relies on a hash algorithm.\n//  Return Type: BOOL\n//      TRUE(1)         initializations succeeded\n//      FALSE(0)        initialization failed and caller should place the TPM into\n//                      Failure Mode\nBOOL CryptInit(void)\n{\n    BOOL ok;\n    // Initialize the vector of implemented algorithms\n    AlgorithmGetImplementedVector(&g_implementedAlgorithms);\n\n    // Indicate that all test are necessary\n    CryptInitializeToTest();\n\n    // Do any library initializations that are necessary. If any fails,\n    // the caller should go into failure mode;\n    ok = ExtMath_LibInit();\n    ok = ok && CryptSymInit();\n    ok = ok && CryptRandInit();\n    ok = ok && CryptHashInit();\n#if ALG_RSA\n    ok = ok && CryptRsaInit();\n#endif  // ALG_RSA\n#if ALG_ECC\n    ok = ok && CryptEccInit();\n#endif  // ALG_ECC\n    return ok;\n}\n\n//*** CryptStartup()\n// This function is called by TPM2_Startup() to initialize the functions in\n// this cryptographic library and in the provided CryptoLibrary. This function\n// and CryptUtilInit() are both provided so that the implementation may move the\n// initialization around to get the best interaction.\n//  Return Type: BOOL\n//      TRUE(1)         startup succeeded\n//      FALSE(0)        startup failed and caller should place the TPM into\n//                      Failure Mode\nBOOL CryptStartup(STARTUP_TYPE type  // IN: the startup type\n\t\t  )\n{\n    BOOL OK;\n    NOT_REFERENCED(type);\n\n    OK = CryptSymStartup() && CryptRandStartup() && CryptHashStartup()\n#if ALG_RSA\n\t && CryptRsaStartup()\n#endif  // ALG_RSA\n#if ALG_ECC\n\t && CryptEccStartup()\n#endif  // ALG_ECC\n\t ;\n#if ALG_ECC\n    // Don't directly check for SU_RESET because that is the default\n    if(OK && (type != SU_RESTART) && (type != SU_RESUME))\n\t{\n\t    // If the shutdown was orderly, then the values recovered from NV will\n\t    // be OK to use.\n\t    // Get a new  random commit nonce\n\t    gr.commitNonce.t.size = sizeof(gr.commitNonce.t.buffer);\n\t    CryptRandomGenerate(gr.commitNonce.t.size, gr.commitNonce.t.buffer);\n\t    // Reset the counter and commit array\n\t    gr.commitCounter = 0;\n\t    MemorySet(gr.commitArray, 0, sizeof(gr.commitArray));\n\t}\n#endif  // ALG_ECC\n    return OK;\n}\n\n//****************************************************************************\n//** Algorithm-Independent Functions\n//****************************************************************************\n//*** Introduction\n// These functions are used generically when a function of a general type\n// (e.g., symmetric encryption) is required.  The functions will modify the\n// parameters as required to interface to the indicated algorithms.\n//\n//*** CryptIsAsymAlgorithm()\n// This function indicates if an algorithm is an asymmetric algorithm.\n//  Return Type: BOOL\n//      TRUE(1)         if it is an asymmetric algorithm\n//      FALSE(0)        if it is not an asymmetric algorithm\nBOOL CryptIsAsymAlgorithm(TPM_ALG_ID algID  // IN: algorithm ID\n\t\t\t  )\n{\n    switch(algID)\n\t{\n#if ALG_RSA\n\t  case TPM_ALG_RSA:\n#endif\n#if ALG_ECC\n\t  case TPM_ALG_ECC:\n#endif\n\t    return TRUE;\n\t    break;\n\t  default:\n\t    break;\n\t}\n    return FALSE;\n}\n\n//*** CryptSecretEncrypt()\n// This function creates a secret value and its associated secret structure using\n// an asymmetric algorithm.\n//\n// This function is used by TPM2_Rewrap() TPM2_MakeCredential(),\n// and TPM2_Duplicate().\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES   'keyHandle' does not reference a valid decryption key\n//      TPM_RC_KEY          invalid ECC key (public point is not on the curve)\n//      TPM_RC_SCHEME       RSA key with an unsupported padding scheme\n//      TPM_RC_VALUE        numeric value of the data to be decrypted is greater\n//                          than the RSA key modulus\nTPM_RC\nCryptSecretEncrypt(OBJECT*      encryptKey,  // IN: encryption key object\n\t\t   const TPM2B* label,       // IN: a null-terminated string as L\n\t\t   TPM2B_DATA*  data,        // OUT: secret value\n\t\t   TPM2B_ENCRYPTED_SECRET* secret  // OUT: secret structure\n\t\t   )\n{\n    TPM_RC result = TPM_RC_SUCCESS;\n    //\n    if(data == NULL || secret == NULL)\n\treturn TPM_RC_FAILURE;\n\n    // CryptKDFe was fixed to not add a NULL byte as per NIST.SP.800-56Cr2.pdf\n    // (required for ACVP tests). This check ensures backwards compatibility with\n    // previous versions of the TPM reference code by verifying the label itself\n    // has a NULL terminator.  Note the TPM spec specifies that the label must be NULL\n    // terminated.  This is only a \"new\" failure path in the sense that it adds a\n    // runtime check of hardcoded constants; provided the code is correct it will never\n    // fail, and running the compliance tests will verify this isn't hit.\n    if((label == NULL) || (label->size == 0) || (label->buffer[label->size - 1] != 0))\n\treturn TPM_RC_FAILURE;\n\n    // The output secret value has the size of the digest produced by the nameAlg.\n    data->t.size = CryptHashGetDigestSize(encryptKey->publicArea.nameAlg);\n\n    if(!IS_ATTRIBUTE(encryptKey->publicArea.objectAttributes, TPMA_OBJECT, decrypt))\n\treturn TPM_RC_ATTRIBUTES;\n    switch(encryptKey->publicArea.type)\n\t{\n#if ALG_RSA\n\t  case TPM_ALG_RSA:\n\t      {\n\t\t  // The encryption scheme is OAEP using the nameAlg of the encrypt key.\n\t\t  TPMT_RSA_DECRYPT scheme;\n\t\t  scheme.scheme                 = TPM_ALG_OAEP;\n\t\t  scheme.details.anySig.hashAlg = encryptKey->publicArea.nameAlg;\n\n\t\t  // Create secret data from RNG\n\t\t  CryptRandomGenerate(data->t.size, data->t.buffer);\n\n\t\t  // Encrypt the data by RSA OAEP into encrypted secret\n\t\t  result = CryptRsaEncrypt((TPM2B_PUBLIC_KEY_RSA*)secret,\n\t\t\t\t\t   &data->b,\n\t\t\t\t\t   encryptKey,\n\t\t\t\t\t   &scheme,\n\t\t\t\t\t   label,\n\t\t\t\t\t   NULL);\n\t      }\n\t      break;\n#endif  // ALG_RSA\n\n#if ALG_ECC\n\t  case TPM_ALG_ECC:\n\t      {\n\t\t  TPMS_ECC_POINT      eccPublic;\n\t\t  TPM2B_ECC_PARAMETER eccPrivate;\n\t\t  TPMS_ECC_POINT      eccSecret;\n\t\t  BYTE*               buffer = secret->t.secret;\n\n\t\t  // Need to make sure that the public point of the key is on the\n\t\t  // curve defined by the key.\n\t\t  if(!CryptEccIsPointOnCurve(\n\t\t\t\t\t     encryptKey->publicArea.parameters.eccDetail.curveID,\n\t\t\t\t\t     &encryptKey->publicArea.unique.ecc))\n\t\t      result = TPM_RC_KEY;\n\t\t  else\n\t\t      {\n\t\t\t  // Call crypto engine to create an auxiliary ECC key\n\t\t\t  // We assume crypt engine initialization should always success.\n\t\t\t  // Otherwise, TPM should go to failure mode.\n\n\t\t\t  CryptEccNewKeyPair(\n\t\t\t\t\t     &eccPublic,\n\t\t\t\t\t     &eccPrivate,\n\t\t\t\t\t     encryptKey->publicArea.parameters.eccDetail.curveID);\n\t\t\t  // Marshal ECC public to secret structure. This will be used by the\n\t\t\t  // recipient to decrypt the secret with their private key.\n\t\t\t  secret->t.size = TPMS_ECC_POINT_Marshal(&eccPublic, &buffer, NULL);\n\n\t\t\t  // Compute ECDH shared secret which is R = [d]Q where d is the\n\t\t\t  // private part of the ephemeral key and Q is the public part of a\n\t\t\t  // TPM key. TPM_RC_KEY error return from CryptComputeECDHSecret\n\t\t\t  // because the auxiliary ECC key is just created according to the\n\t\t\t  // parameters of input ECC encrypt key.\n\t\t\t  if(CryptEccPointMultiply(\n\t\t\t\t\t\t   &eccSecret,\n\t\t\t\t\t\t   encryptKey->publicArea.parameters.eccDetail.curveID,\n\t\t\t\t\t\t   &encryptKey->publicArea.unique.ecc,\n\t\t\t\t\t\t   &eccPrivate,\n\t\t\t\t\t\t   NULL,\n\t\t\t\t\t\t   NULL)\n\t\t\t     != TPM_RC_SUCCESS)\n\t\t\t      result = TPM_RC_KEY;\n\t\t\t  else\n\t\t\t      {\n\t\t\t\t  // The secret value is computed from Z using KDFe as:\n\t\t\t\t  // secret := KDFe(HashID, Z, Use, PartyUInfo, PartyVInfo, bits)\n\t\t\t\t  // Where:\n\t\t\t\t  //  HashID  the nameAlg of the decrypt key\n\t\t\t\t  //  Z   the x coordinate (Px) of the product (P) of the point\n\t\t\t\t  //      (Q) of the secret and the private x coordinate (de,V)\n\t\t\t\t  //      of the decryption key\n\t\t\t\t  //  Use a null-terminated string containing \"SECRET\"\n\t\t\t\t  //  PartyUInfo  the x coordinate of the point in the secret\n\t\t\t\t  //              (Qe,U )\n\t\t\t\t  //  PartyVInfo  the x coordinate of the public key (Qs,V )\n\t\t\t\t  //  bits    the number of bits in the digest of HashID\n\t\t\t\t  // Retrieve seed from KDFe\n\t\t\t\t  CryptKDFe(encryptKey->publicArea.nameAlg,\n\t\t\t\t\t    &eccSecret.x.b,\n\t\t\t\t\t    label,\n\t\t\t\t\t    &eccPublic.x.b,\n\t\t\t\t\t    &encryptKey->publicArea.unique.ecc.x.b,\n\t\t\t\t\t    data->t.size * 8,\n\t\t\t\t\t    data->t.buffer);\n\t\t\t      }\n\t\t      }\n\t      }\n\t      break;\n#endif  // ALG_ECC\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    return result;\n}\n\n//*** CryptSecretDecrypt()\n// Decrypt a secret value by asymmetric (or symmetric) algorithm\n// This function is used for ActivateCredential and Import for asymmetric\n// decryption, and StartAuthSession for both asymmetric and symmetric\n// decryption process\n//\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES        RSA key is not a decryption key\n//      TPM_RC_BINDING           Invalid RSA key (public and private parts are not\n//                               cryptographically bound.\n//      TPM_RC_ECC_POINT         ECC point in the secret is not on the curve\n//      TPM_RC_INSUFFICIENT      failed to retrieve ECC point from the secret\n//      TPM_RC_NO_RESULT         multiplication resulted in ECC point at infinity\n//      TPM_RC_SIZE              data to decrypt is not of the same size as RSA key\n//      TPM_RC_VALUE             For RSA key, numeric value of the encrypted data is\n//                               greater than the modulus, or the recovered data is\n//                               larger than the output buffer.\n//                               For keyedHash or symmetric key, the secret is\n//                               larger than the size of the digest produced by\n//                               the name algorithm.\n//      TPM_RC_FAILURE           internal error\nTPM_RC\nCryptSecretDecrypt(OBJECT*      decryptKey,   // IN: decrypt key\n\t\t   TPM2B_NONCE* nonceCaller,  // IN: nonceCaller.  It is needed for\n\t\t   //     symmetric decryption.  For\n\t\t   //     asymmetric decryption, this\n\t\t   //     parameter is NULL\n\t\t   const TPM2B*            label,   // IN: a value for L\n\t\t   TPM2B_ENCRYPTED_SECRET* secret,  // IN: input secret\n\t\t   TPM2B_DATA*             data     // OUT: decrypted secret value\n\t\t   )\n{\n    TPM_RC result = TPM_RC_SUCCESS;\n\n    // CryptKDFe was fixed to not add a NULL byte as per NIST.SP.800-56Cr2.pdf\n    // (required for ACVP tests). This check ensures backwards compatibility with\n    // previous versions of the TPM reference code by verifying the label itself\n    // has a NULL terminator.  Note the TPM spec specifies that the label must be NULL\n    // terminated.  This is only a \"new\" failure path in the sense that it adds a\n    // runtime check of hardcoded constants; provided the code is correct it will never\n    // fail, and running the compliance tests will verify this isn't hit.\n    if((label == NULL) || (label->size == 0) || (label->buffer[label->size - 1] != 0))\n\treturn TPM_RC_FAILURE;\n\n    // Decryption for secret\n    switch(decryptKey->publicArea.type)\n\t{\n#if ALG_RSA\n\t  case TPM_ALG_RSA:\n\t      {\n\t\t  TPMT_RSA_DECRYPT scheme;\n\t\t  TPMT_RSA_SCHEME* keyScheme =\n\t\t      &decryptKey->publicArea.parameters.rsaDetail.scheme;\n\t\t  UINT16 digestSize;\n\n\t\t  scheme = *(TPMT_RSA_DECRYPT*)keyScheme;\n\t\t  // If the key scheme is TPM_ALG_NULL, set the scheme to OAEP and\n\t\t  // set the algorithm to the name algorithm.\n\t\t  if(scheme.scheme == TPM_ALG_NULL)\n\t\t      {\n\t\t\t  // Use OAEP scheme\n\t\t\t  scheme.scheme               = TPM_ALG_OAEP;\n\t\t\t  scheme.details.oaep.hashAlg = decryptKey->publicArea.nameAlg;\n\t\t      }\n\t\t  // use the digestSize as an indicator of whether or not the scheme\n\t\t  // is using a supported hash algorithm.\n\t\t  // Note: depending on the scheme used for encryption, a hashAlg might\n\t\t  // not be needed. However, the return value has to have some upper\n\t\t  // limit on the size. In this case, it is the size of the digest of the\n\t\t  // hash algorithm. It is checked after the decryption is done but, there\n\t\t  // is no point in doing the decryption if the size is going to be\n\t\t  // 'wrong' anyway.\n\t\t  digestSize = CryptHashGetDigestSize(scheme.details.oaep.hashAlg);\n\t\t  if(scheme.scheme != TPM_ALG_OAEP || digestSize == 0)\n\t\t      return TPM_RC_SCHEME;\n\n\t\t  // Set the output buffer capacity\n\t\t  data->t.size = sizeof(data->t.buffer);\n\n\t\t  // Decrypt seed by RSA OAEP\n\t\t  result =\n\t\t      CryptRsaDecrypt(&data->b, &secret->b, decryptKey, &scheme, label);\n\t\t  if((result == TPM_RC_SUCCESS) && (data->t.size > digestSize))\n\t\t      result = TPM_RC_VALUE;\n\t      }\n\t      break;\n#endif  // ALG_RSA\n#if ALG_ECC\n\t  case TPM_ALG_ECC:\n\t      {\n\t\t  TPMS_ECC_POINT eccPublic;\n\t\t  TPMS_ECC_POINT eccSecret;\n\t\t  BYTE*          buffer = secret->t.secret;\n\t\t  INT32          size   = secret->t.size;\n\n\t\t  // Retrieve ECC point from secret buffer\n\t\t  result = TPMS_ECC_POINT_Unmarshal(&eccPublic, &buffer, &size);\n\t\t  if(result == TPM_RC_SUCCESS)\n\t\t      {\n\t\t\t  result = CryptEccPointMultiply(\n\t\t\t\t\t\t\t &eccSecret,\n\t\t\t\t\t\t\t decryptKey->publicArea.parameters.eccDetail.curveID,\n\t\t\t\t\t\t\t &eccPublic,\n\t\t\t\t\t\t\t &decryptKey->sensitive.sensitive.ecc,\n\t\t\t\t\t\t\t NULL,\n\t\t\t\t\t\t\t NULL);\n\t\t\t  if(result == TPM_RC_SUCCESS)\n\t\t\t      {\n\t\t\t\t  // Set the size of the \"recovered\" secret value to be the size\n\t\t\t\t  // of the digest produced by the nameAlg.\n\t\t\t\t  data->t.size =\n\t\t\t\t      CryptHashGetDigestSize(decryptKey->publicArea.nameAlg);\n\n\t\t\t\t  // The secret value is computed from Z using KDFe as:\n\t\t\t\t  // secret := KDFe(HashID, Z, Use, PartyUInfo, PartyVInfo, bits)\n\t\t\t\t  // Where:\n\t\t\t\t  //  HashID -- the nameAlg of the decrypt key\n\t\t\t\t  //  Z --  the x coordinate (Px) of the product (P) of the point\n\t\t\t\t  //        (Q) of the secret and the private x coordinate (de,V)\n\t\t\t\t  //        of the decryption key\n\t\t\t\t  //  Use -- a null-terminated string containing \"SECRET\"\n\t\t\t\t  //  PartyUInfo -- the x coordinate of the point in the secret\n\t\t\t\t  //              (Qe,U )\n\t\t\t\t  //  PartyVInfo -- the x coordinate of the public key (Qs,V )\n\t\t\t\t  //  bits -- the number of bits in the digest of HashID\n\t\t\t\t  // Retrieve seed from KDFe\n\t\t\t\t  CryptKDFe(decryptKey->publicArea.nameAlg,\n\t\t\t\t\t    &eccSecret.x.b,\n\t\t\t\t\t    label,\n\t\t\t\t\t    &eccPublic.x.b,\n\t\t\t\t\t    &decryptKey->publicArea.unique.ecc.x.b,\n\t\t\t\t\t    data->t.size * 8,\n\t\t\t\t\t    data->t.buffer);\n\t\t\t      }\n\t\t      }\n\t      }\n\t      break;\n#endif  // ALG_ECC\n#if !ALG_KEYEDHASH\n#  error \"KEYEDHASH support is required\"\n#endif\n\t  case TPM_ALG_KEYEDHASH:\n\t    // The seed size can not be bigger than the digest size of nameAlg\n\t    if(secret->t.size\n\t       > CryptHashGetDigestSize(decryptKey->publicArea.nameAlg))\n\t\tresult = TPM_RC_VALUE;\n\t    else\n\t\t{\n\t\t    // Retrieve seed by XOR Obfuscation:\n\t\t    //    seed = XOR(secret, hash, key, nonceCaller, nullNonce)\n\t\t    //    where:\n\t\t    //    secret  the secret parameter from the TPM2_StartAuthHMAC\n\t\t    //            command that contains the seed value\n\t\t    //    hash    nameAlg  of tpmKey\n\t\t    //    key     the key or data value in the object referenced by\n\t\t    //            entityHandle in the TPM2_StartAuthHMAC command\n\t\t    //    nonceCaller the parameter from the TPM2_StartAuthHMAC command\n\t\t    //    nullNonce   a zero-length nonce\n\t\t    // XOR Obfuscation in place\n\t\t    CryptXORObfuscation(decryptKey->publicArea.nameAlg,\n\t\t\t\t\t&decryptKey->sensitive.sensitive.bits.b,\n\t\t\t\t\t&nonceCaller->b,\n\t\t\t\t\tNULL,\n\t\t\t\t\tsecret->t.size,\n\t\t\t\t\tsecret->t.secret);\n\t\t    // Copy decrypted seed\n\t\t    MemoryCopy2B(&data->b, &secret->b, sizeof(data->t.buffer));\n\t\t}\n\t    break;\n\t  case TPM_ALG_SYMCIPHER:\n\t      {\n\t\t  TPM2B_IV             iv = {{0}};\n\t\t  TPMT_SYM_DEF_OBJECT* symDef;\n\t\t  // The seed size can not be bigger than the digest size of nameAlg\n\t\t  if(secret->t.size\n\t\t     > CryptHashGetDigestSize(decryptKey->publicArea.nameAlg))\n\t\t      result = TPM_RC_VALUE;\n\t\t  else\n\t\t      {\n\t\t\t  symDef    = &decryptKey->publicArea.parameters.symDetail.sym;\n\t\t\t  iv.t.size = CryptGetSymmetricBlockSize(symDef->algorithm,\n\t\t\t\t\t\t\t\t symDef->keyBits.sym);\n\t\t\t  if(iv.t.size == 0)\n\t\t\t      return TPM_RC_FAILURE;\n\t\t\t  if(nonceCaller->t.size >= iv.t.size)\n\t\t\t      {\n\t\t\t\t  MemoryCopy(iv.t.buffer, nonceCaller->t.buffer, iv.t.size);\n\t\t\t      }\n\t\t\t  else\n\t\t\t      {\n\t\t\t\t  if(nonceCaller->t.size > sizeof(iv.t.buffer))\n\t\t\t\t      return TPM_RC_FAILURE;\n\t\t\t\t  MemoryCopy(\n\t\t\t\t\t     iv.b.buffer, nonceCaller->t.buffer, nonceCaller->t.size);\n\t\t\t      }\n\t\t\t  // make sure secret will fit\n\t\t\t  if(secret->t.size > sizeof(data->t.buffer))\n\t\t\t      return TPM_RC_FAILURE;\n\t\t\t  data->t.size = secret->t.size;\n\t\t\t  // CFB decrypt, using nonceCaller as iv\n\t\t\t  CryptSymmetricDecrypt(data->t.buffer,\n\t\t\t\t\t\tsymDef->algorithm,\n\t\t\t\t\t\tsymDef->keyBits.sym,\n\t\t\t\t\t\tdecryptKey->sensitive.sensitive.sym.t.buffer,\n\t\t\t\t\t\t&iv,\n\t\t\t\t\t\tTPM_ALG_CFB,\n\t\t\t\t\t\tsecret->t.size,\n\t\t\t\t\t\tsecret->t.secret);\n\t\t      }\n\t      }\n\t      break;\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    return result;\n}\n\n//*** CryptParameterEncryption()\n// This function does in-place encryption of a response parameter.\nvoid CryptParameterEncryption(\n\t\t\t      TPM_HANDLE handle,             // IN: encrypt session handle\n\t\t\t      TPM2B*     nonceCaller,        // IN: nonce caller\n\t\t\t      INT32      bufferSize,         // IN: size of parameter buffer\n\t\t\t      UINT16     leadingSizeInByte,  // IN: the size of the leading size field in\n\t\t\t      //     bytes\n\t\t\t      TPM2B_AUTH* extraKey,          // IN: additional key material other than\n\t\t\t      //     sessionAuth\n\t\t\t      BYTE* buffer                   // IN/OUT: parameter buffer to be encrypted\n\t\t\t      )\n{\n    SESSION* session = SessionGet(handle);  // encrypt session\n    TPM2B_TYPE(TEMP_KEY,\n\t       (sizeof(extraKey->t.buffer) + sizeof(session->sessionKey.t.buffer)));\n    TPM2B_TEMP_KEY key;             // encryption key\n    UINT16         cipherSize = 0;  // size of cipher text\n\n    if(bufferSize < leadingSizeInByte)\n\t{\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    return;\n\t}\n\n    // Parameter encryption for a non-2B is not supported.\n    if(leadingSizeInByte != 2)\n\t{\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    return;\n\t}\n\n    // Retrieve encrypted data size.\n    if(UINT16_Unmarshal(&cipherSize, &buffer, &bufferSize) != TPM_RC_SUCCESS)\n\t{\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    return;\n\t}\n\n    if(cipherSize > bufferSize)\n\t{\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    return;\n\t}\n\n    // Compute encryption key by concatenating sessionKey with extra key\n    MemoryCopy2B(&key.b, &session->sessionKey.b, sizeof(key.t.buffer));\n    MemoryConcat2B(&key.b, &extraKey->b, sizeof(key.t.buffer));\n\n    if(session->symmetric.algorithm == TPM_ALG_XOR)\n\n\t// XOR parameter encryption formulation:\n\t//    XOR(parameter, hash, sessionAuth, nonceNewer, nonceOlder)\n\tCryptXORObfuscation(session->authHashAlg,\n\t\t\t    &(key.b),\n\t\t\t    &(session->nonceTPM.b),\n\t\t\t    nonceCaller,\n\t\t\t    (UINT32)cipherSize,\n\t\t\t    buffer);\n    else\n\tParmEncryptSym(session->symmetric.algorithm,\n\t\t       session->authHashAlg,\n\t\t       session->symmetric.keyBits.aes,\n\t\t       &(key.b),\n\t\t       nonceCaller,\n\t\t       &(session->nonceTPM.b),\n\t\t       (UINT32)cipherSize,\n\t\t       buffer);\n    return;\n}\n\n//*** CryptParameterDecryption()\n// This function does in-place decryption of a command parameter.\n//  Return Type: TPM_RC\n//      TPM_RC_SIZE             The number of bytes in the input buffer is less than\n//                              the number of bytes to be decrypted.\nTPM_RC\nCryptParameterDecryption(\n\t\t\t TPM_HANDLE handle,             // IN: encrypted session handle\n\t\t\t TPM2B*     nonceCaller,        // IN: nonce caller\n\t\t\t INT32      bufferSize,         // IN: size of parameter buffer\n\t\t\t UINT16     leadingSizeInByte,  // IN: the size of the leading size field in\n\t\t\t //     byte\n\t\t\t TPM2B_AUTH* extraKey,          // IN: the authValue\n\t\t\t BYTE*       buffer             // IN/OUT: parameter buffer to be decrypted\n\t\t\t )\n{\n    SESSION* session = SessionGet(handle);  // encrypt session\n    // The HMAC key is going to be the concatenation of the session key and any\n    // additional key material (like the authValue). The size of both of these\n    // is the size of the buffer which can contain a TPMT_HA.\n    TPM2B_TYPE(HMAC_KEY,\n\t       (sizeof(extraKey->t.buffer) + sizeof(session->sessionKey.t.buffer)));\n    TPM2B_HMAC_KEY key;             // decryption key\n    UINT16         cipherSize = 0;  // size of ciphertext\n\n    if(bufferSize < leadingSizeInByte)\n\t{\n\t    return TPM_RC_INSUFFICIENT;\n\t}\n\n    // Parameter encryption for a non-2B is not supported.\n    if(leadingSizeInByte != 2)\n\t{\n\t    FAIL_RC(FATAL_ERROR_INTERNAL);\n\t}\n\n    // Retrieve encrypted data size.\n    if(UINT16_Unmarshal(&cipherSize, &buffer, &bufferSize) != TPM_RC_SUCCESS)\n\t{\n\t    return TPM_RC_INSUFFICIENT;\n\t}\n\n    if(cipherSize > bufferSize)\n\t{\n\t    return TPM_RC_SIZE;\n\t}\n\n    // Compute decryption key by concatenating sessionAuth with extra input key\n    MemoryCopy2B(&key.b, &session->sessionKey.b, sizeof(key.t.buffer));\n    MemoryConcat2B(&key.b, &extraKey->b, sizeof(key.t.buffer));\n\n    if(session->symmetric.algorithm == TPM_ALG_XOR)\n\t// XOR parameter decryption formulation:\n\t//    XOR(parameter, hash, sessionAuth, nonceNewer, nonceOlder)\n\t// Call XOR obfuscation function\n\tCryptXORObfuscation(session->authHashAlg,\n\t\t\t    &key.b,\n\t\t\t    nonceCaller,\n\t\t\t    &(session->nonceTPM.b),\n\t\t\t    (UINT32)cipherSize,\n\t\t\t    buffer);\n    else\n\t// Assume that it is one of the symmetric block ciphers.\n\tParmDecryptSym(session->symmetric.algorithm,\n\t\t       session->authHashAlg,\n\t\t       session->symmetric.keyBits.sym,\n\t\t       &key.b,\n\t\t       nonceCaller,\n\t\t       &session->nonceTPM.b,\n\t\t       (UINT32)cipherSize,\n\t\t       buffer);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptComputeSymmetricUnique()\n// This function computes the unique field in public area for symmetric objects.\nvoid CryptComputeSymmetricUnique(\n\t\t\t\t TPMT_PUBLIC*    publicArea,  // IN: the object's public area\n\t\t\t\t TPMT_SENSITIVE* sensitive,   // IN: the associated sensitive area\n\t\t\t\t TPM2B_DIGEST*   unique       // OUT: unique buffer\n\t\t\t\t )\n{\n    // For parents (symmetric and derivation), use an HMAC to compute\n    // the 'unique' field\n    if(IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, restricted)\n       && IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, decrypt))\n\t{\n\t    // Unique field is HMAC(sensitive->seedValue, sensitive->sensitive)\n\t    HMAC_STATE hmacState;\n\t    unique->b.size = CryptHmacStart2B(\n\t\t\t\t\t      &hmacState, publicArea->nameAlg, &sensitive->seedValue.b);\n\t    CryptDigestUpdate2B(&hmacState.hashState, &sensitive->sensitive.any.b);\n\t    CryptHmacEnd2B(&hmacState, &unique->b);\n\t}\n    else\n\t{\n\t    HASH_STATE hashState;\n\t    // Unique := Hash(sensitive->seedValue || sensitive->sensitive)\n\t    unique->t.size = CryptHashStart(&hashState, publicArea->nameAlg);\n\t    CryptDigestUpdate2B(&hashState, &sensitive->seedValue.b);\n\t    CryptDigestUpdate2B(&hashState, &sensitive->sensitive.any.b);\n\t    CryptHashEnd2B(&hashState, &unique->b);\n\t}\n    return;\n}\n\n//*** CryptCreateObject()\n// This function creates an object.\n// For an asymmetric key, it will create a key pair and, for a parent key, a seed\n// value for child protections.\n//\n// For an symmetric object, (TPM_ALG_SYMCIPHER or TPM_ALG_KEYEDHASH), it will\n// create a secret key if the caller did not provide one. It will create a random\n// secret seed value that is hashed with the secret value to create the public\n// unique value.\n//\n// 'publicArea', 'sensitive', and 'sensitiveCreate' are the only required parameters\n// and are the only ones that are used by TPM2_Create(). The other parameters\n// are optional and are used when the generated Object needs to be deterministic.\n// This is the case for both Primary Objects and Derived Objects.\n//\n// When a seed value is provided, a RAND_STATE will be populated and used for\n// all operations in the object generation that require a random number. In the\n// simplest case, TPM2_CreatePrimary() will use 'seed', 'label' and 'context' with\n// context being the hash of the template. If the Primary Object is in\n// the Endorsement hierarchy, it will also populate 'proof' with ehProof.\n//\n// For derived keys, 'seed' will be the secret value from the parent, 'label' and\n// 'context' will be set according to the parameters of TPM2_CreateLoaded() and\n// 'hashAlg' will be set which causes the RAND_STATE to be a KDF generator.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_KEY          a provided key is not an allowed value\n//      TPM_RC_KEY_SIZE     key size in the public area does not match the size\n//                          in the sensitive creation area for a symmetric key\n//      TPM_RC_NO_RESULT    unable to get random values (only in derivation)\n//      TPM_RC_RANGE        for an RSA key, the exponent is not supported\n//      TPM_RC_SIZE         sensitive data size is larger than allowed for the\n//                          scheme for a keyed hash object\n//      TPM_RC_VALUE        exponent is not prime or could not find a prime using\n//                          the provided parameters for an RSA key;\n//                          unsupported name algorithm for an ECC key\nTPM_RC\nCryptCreateObject(OBJECT*                object,  // IN: new object structure pointer\n\t\t  TPMS_SENSITIVE_CREATE* sensitiveCreate,  // IN: sensitive creation\n\t\t  RAND_STATE*            rand  // IN: the random number generator\n\t\t  //      to use\n\t\t  )\n{\n    TPMT_PUBLIC*    publicArea = &object->publicArea;\n    TPMT_SENSITIVE* sensitive  = &object->sensitive;\n    TPM_RC          result     = TPM_RC_SUCCESS;\n    //\n    // Set the sensitive type for the object\n    sensitive->sensitiveType = publicArea->type;\n\n    // For all objects, copy the initial authorization data\n    sensitive->authValue = sensitiveCreate->userAuth;\n\n    // If the TPM is the source of the data, set the size of the provided data to\n    // zero so that there's no confusion about what to do.\n    if(IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sensitiveDataOrigin))\n\tsensitiveCreate->data.t.size = 0;\n\n    // Generate the key and unique fields for the asymmetric keys and just the\n    // sensitive value for symmetric object\n    switch(publicArea->type)\n\t{\n#if ALG_RSA\n\t    // Create RSA key\n\t  case TPM_ALG_RSA:\n\t    // RSA uses full object so that it has a place to put the private\n\t    // exponent\n\t    result = CryptRsaGenerateKey(publicArea, sensitive, rand);\n\t    break;\n#endif  // ALG_RSA\n\n#if ALG_ECC\n\t    // Create ECC key\n\t  case TPM_ALG_ECC:\n\t    result = CryptEccGenerateKey(publicArea, sensitive, rand);\n\t    break;\n#endif  // ALG_ECC\n\t  case TPM_ALG_SYMCIPHER:\n\t    result = CryptGenerateKeySymmetric(\n\t\t\t\t\t       publicArea, sensitive, sensitiveCreate, rand);\n\t    break;\n\t  case TPM_ALG_KEYEDHASH:\n\t    result =\n\t\tCryptGenerateKeyedHash(publicArea, sensitive, sensitiveCreate, rand);\n\t    break;\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Create the sensitive seed value\n    // If this is a primary key in the endorsement hierarchy, stir the DRBG state\n    // This implementation uses both shProof and ehProof to make sure that there\n    // is no leakage of either.\n    if(object->attributes.primary && object->attributes.epsHierarchy)\n\t{\n\t    DRBG_AdditionalData((DRBG_STATE*)rand, &gp.shProof.b);\n\t    DRBG_AdditionalData((DRBG_STATE*)rand, &gp.ehProof.b);\n\t}\n    // Generate a seedValue that is the size of the digest produced by nameAlg\n    sensitive->seedValue.t.size =\n\tDRBG_Generate(rand,\n\t\t      sensitive->seedValue.t.buffer,\n\t\t      CryptHashGetDigestSize(publicArea->nameAlg));\n    if(g_inFailureMode)\n\treturn TPM_RC_FAILURE;\n    else if(sensitive->seedValue.t.size == 0)\n\treturn TPM_RC_NO_RESULT;\n    // For symmetric objects, need to compute the unique value for the public area\n    if(publicArea->type == TPM_ALG_SYMCIPHER || publicArea->type == TPM_ALG_KEYEDHASH)\n\t{\n\t    CryptComputeSymmetricUnique(publicArea, sensitive, &publicArea->unique.sym);\n\t}\n    else\n\t{\n\t    // if this is an asymmetric key and it isn't a parent, then\n\t    // get rid of the seed.\n\t    if(IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sign)\n\t       || !IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, restricted))\n\t\tmemset(&sensitive->seedValue, 0, sizeof(sensitive->seedValue));\n\t}\n    // Compute the name\n    PublicMarshalAndComputeName(publicArea, &object->name);\n    return result;\n}\n\n//*** CryptGetSignHashAlg()\n// Get the hash algorithm of signature from a TPMT_SIGNATURE structure.\n// It assumes the signature is not NULL\n//  This is a function for easy access\nTPMI_ALG_HASH\nCryptGetSignHashAlg(TPMT_SIGNATURE* auth  // IN: signature\n\t\t    )\n{\n    if(auth->sigAlg == TPM_ALG_NULL)\n\tFAIL(FATAL_ERROR_INTERNAL);\n\n    // Get authHash algorithm based on signing scheme\n    switch(auth->sigAlg)\n\t{\n#if ALG_RSA\n\t    // If RSA is supported, both RSASSA and RSAPSS are required\n#  if !defined TPM_ALG_RSASSA || !defined TPM_ALG_RSAPSS\n#    error \"RSASSA and RSAPSS are required for RSA\"\n#  endif\n\t  case TPM_ALG_RSASSA:\n\t    return auth->signature.rsassa.hash;\n\t  case TPM_ALG_RSAPSS:\n\t    return auth->signature.rsapss.hash;\n#endif  // ALG_RSA\n\n#if ALG_ECC\n\t    // If ECC is defined, ECDSA is mandatory\n#  if !ALG_ECDSA\n#    error \"ECDSA is requried for ECC\"\n#  endif\n\t  case TPM_ALG_ECDSA:\n\t    // SM2 and ECSCHNORR are optional\n\n#  if ALG_SM2\n\t  case TPM_ALG_SM2:\n#  endif\n#  if ALG_ECSCHNORR\n\t  case TPM_ALG_ECSCHNORR:\n#  endif\n\t    //all ECC signatures look the same\n\t    return auth->signature.ecdsa.hash;\n\n#  if ALG_ECDAA\n\t    // Don't know how to verify an ECDAA signature\n\t  case TPM_ALG_ECDAA:\n\t    break;\n#  endif\n\n#endif  // ALG_ECC\n\n\t  case TPM_ALG_HMAC:\n\t    return auth->signature.hmac.hashAlg;\n\n\t  default:\n\t    break;\n\t}\n    return TPM_ALG_NULL;\n}\n\n//*** CryptIsSplitSign()\n// This function us used to determine if the signing operation is a split\n// signing operation that required a TPM2_Commit().\n//\nBOOL CryptIsSplitSign(TPM_ALG_ID scheme  // IN: the algorithm selector\n\t\t      )\n{\n    switch(scheme)\n\t{\n#if ALG_ECDAA\n\t  case TPM_ALG_ECDAA:\n\t    return TRUE;\n\t    break;\n#endif  // ALG_ECDAA\n\t  default:\n\t    return FALSE;\n\t    break;\n\t}\n}\n\n//*** CryptIsAsymSignScheme()\n// This function indicates if a scheme algorithm is a sign algorithm.\nBOOL CryptIsAsymSignScheme(TPMI_ALG_PUBLIC      publicType,  // IN: Type of the object\n\t\t\t   TPMI_ALG_ASYM_SCHEME scheme       // IN: the scheme\n\t\t\t   )\n{\n    BOOL isSignScheme = TRUE;\n\n    switch(publicType)\n\t{\n#if ALG_RSA\n\t  case TPM_ALG_RSA:\n\t    switch(scheme)\n\t\t{\n#  if !ALG_RSASSA || !ALG_RSAPSS\n#    error \"RSASSA and PSAPSS required if RSA used.\"\n#  endif\n\t\t  case TPM_ALG_RSASSA:\n\t\t  case TPM_ALG_RSAPSS:\n\t\t    break;\n\t\t  default:\n\t\t    isSignScheme = FALSE;\n\t\t    break;\n\t\t}\n\t    break;\n#endif  // ALG_RSA\n\n#if ALG_ECC\n\t    // If ECC is implemented ECDSA is required\n\t  case TPM_ALG_ECC:\n\t    switch(scheme)\n\t\t{\n\t\t    // Support for ECDSA is required for ECC\n\t\t  case TPM_ALG_ECDSA:\n#  if ALG_ECDAA  // ECDAA is optional\n\t\t  case TPM_ALG_ECDAA:\n#  endif\n#  if ALG_ECSCHNORR  // Schnorr is also optional\n\t\t  case TPM_ALG_ECSCHNORR:\n#  endif\n#  if ALG_SM2  // SM2 is optional\n\t\t  case TPM_ALG_SM2:\n#  endif\n\t\t    break;\n\t\t  default:\n\t\t    isSignScheme = FALSE;\n\t\t    break;\n\t\t}\n\t    break;\n#endif  // ALG_ECC\n\t  default:\n\t    isSignScheme = FALSE;\n\t    break;\n\t}\n    return isSignScheme;\n}\n\n//*** CryptIsAsymDecryptScheme()\n// This function indicate if a scheme algorithm is a decrypt algorithm.\nBOOL CryptIsAsymDecryptScheme(TPMI_ALG_PUBLIC publicType,  // IN: Type of the object\n\t\t\t      TPMI_ALG_ASYM_SCHEME scheme  // IN: the scheme\n\t\t\t      )\n{\n    BOOL isDecryptScheme = TRUE;\n\n    switch(publicType)\n\t{\n#if ALG_RSA\n\t  case TPM_ALG_RSA:\n\t    switch(scheme)\n\t\t{\n\t\t  case TPM_ALG_RSAES:\n\t\t  case TPM_ALG_OAEP:\n\t\t    break;\n\t\t  default:\n\t\t    isDecryptScheme = FALSE;\n\t\t    break;\n\t\t}\n\t    break;\n#endif  // ALG_RSA\n\n#if ALG_ECC\n\t    // If ECC is implemented ECDH is required\n\t  case TPM_ALG_ECC:\n\t    switch(scheme)\n\t\t{\n#  if !ALG_ECDH\n#    error \"ECDH is required for ECC\"\n#  endif\n\t\t  case TPM_ALG_ECDH:\n#  if ALG_SM2\n\t\t  case TPM_ALG_SM2:\n#  endif\n#  if ALG_ECMQV\n\t\t  case TPM_ALG_ECMQV:\n#  endif\n\t\t    break;\n\t\t  default:\n\t\t    isDecryptScheme = FALSE;\n\t\t    break;\n\t\t}\n\t    break;\n#endif  // ALG_ECC\n\t  default:\n\t    isDecryptScheme = FALSE;\n\t    break;\n\t}\n    return isDecryptScheme;\n}\n\n//*** CryptSelectSignScheme()\n// This function is used by the attestation and signing commands.  It implements\n// the rules for selecting the signature scheme to use in signing. This function\n// requires that the signing key either be TPM_RH_NULL or be loaded.\n//\n// If a default scheme is defined in object, the default scheme should be chosen,\n// otherwise, the input scheme should be chosen.\n// In the case that  both object and input scheme has a non-NULL scheme\n// algorithm, if the schemes are compatible, the input scheme will be chosen.\n//\n// This function should not be called if 'signObject->publicArea.type' ==\n// ALG_SYMCIPHER.\n//\n//  Return Type: BOOL\n//      TRUE(1)         scheme selected\n//      FALSE(0)        both 'scheme' and key's default scheme are empty; or\n//                      'scheme' is empty while key's default scheme requires\n//                      explicit input scheme (split signing); or\n//                      non-empty default key scheme differs from 'scheme'\nBOOL CryptSelectSignScheme(OBJECT*          signObject,  // IN: signing key\n\t\t\t   TPMT_SIG_SCHEME* scheme       // IN/OUT: signing scheme\n\t\t\t   )\n{\n    TPMT_SIG_SCHEME* objectScheme;\n    TPMT_PUBLIC*     publicArea;\n    BOOL             OK;\n\n    // If the signHandle is TPM_RH_NULL, then the NULL scheme is used, regardless\n    // of the setting of scheme\n    if(signObject == NULL)\n\t{\n\t    OK                          = TRUE;\n\t    scheme->scheme              = TPM_ALG_NULL;\n\t    scheme->details.any.hashAlg = TPM_ALG_NULL;\n\t}\n    else\n\t{\n\t    // assignment to save typing.\n\t    publicArea = &signObject->publicArea;\n\n\t    // A symmetric cipher can be used to encrypt and decrypt but it can't\n\t    // be used for signing\n\t    if(publicArea->type == TPM_ALG_SYMCIPHER)\n\t\treturn FALSE;\n\t    // Point to the scheme object\n\t    if(CryptIsAsymAlgorithm(publicArea->type))\n\t\tobjectScheme =\n\t\t    (TPMT_SIG_SCHEME*)&publicArea->parameters.asymDetail.scheme;\n\t    else\n\t\tobjectScheme =\n\t\t    (TPMT_SIG_SCHEME*)&publicArea->parameters.keyedHashDetail.scheme;\n\n\t    // If the object doesn't have a default scheme, then use the\n\t    // input scheme.\n\t    if(objectScheme->scheme == TPM_ALG_NULL)\n\t\t{\n\t\t    // Input and default can't both be NULL\n\t\t    OK = (scheme->scheme != TPM_ALG_NULL);\n\t\t    // Assume that the scheme is compatible with the key. If not,\n\t\t    // an error will be generated in the signing operation.\n\t\t}\n\t    else if(scheme->scheme == TPM_ALG_NULL)\n\t\t{\n\t\t    // input scheme is NULL so use default\n\n\t\t    // First, check to see if the default requires that the caller\n\t\t    // provided scheme data\n\t\t    OK = !CryptIsSplitSign(objectScheme->scheme);\n\t\t    if(OK)\n\t\t\t{\n\t\t\t    // The object has a scheme and the input is TPM_ALG_NULL so copy\n\t\t\t    // the object scheme as the final scheme. It is better to use a\n\t\t\t    // structure copy than a copy of the individual fields.\n\t\t\t    *scheme = *objectScheme;\n\t\t\t}\n\t\t}\n\t    else\n\t\t{\n\t\t    // Both input and object have scheme selectors\n\t\t    // If the scheme and the hash are not the same then...\n\t\t    // NOTE: the reason that there is no copy here is that the input\n\t\t    // might contain extra data for a split signing scheme and that\n\t\t    // data is not in the object so, it has to be preserved.\n\t\t    OK =\n\t\t\t(objectScheme->scheme == scheme->scheme)\n\t\t\t&& (objectScheme->details.any.hashAlg == scheme->details.any.hashAlg);\n\t\t}\n\t}\n    return OK;\n}\n\n//*** CryptSign()\n// Sign a digest with asymmetric key or HMAC.\n// This function is called by attestation commands and the generic TPM2_Sign\n// command.\n// This function checks the key scheme and digest size.  It does not\n// check if the sign operation is allowed for restricted key.  It should be\n// checked before the function is called.\n// The function will assert if the key is not a signing key.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME      'signScheme' is not compatible with the signing key type\n//      TPM_RC_VALUE       'digest' value is greater than the modulus of\n//                         'signHandle' or size of 'hashData' does not match hash\n//                         algorithm in'signScheme' (for an RSA key);\n//                         invalid commit status or failed to generate \"r\" value\n//                         (for an ECC key)\nTPM_RC\nCryptSign(OBJECT*          signKey,     // IN: signing key\n\t  TPMT_SIG_SCHEME* signScheme,  // IN: sign scheme.\n\t  TPM2B_DIGEST*    digest,      // IN: The digest being signed\n\t  TPMT_SIGNATURE*  signature    // OUT: signature\n\t  )\n{\n    TPM_RC result = TPM_RC_SCHEME;\n\n    // Initialize signature scheme\n    signature->sigAlg = signScheme->scheme;\n\n    // If the signature algorithm is TPM_ALG_NULL or the signing key is NULL,\n    // then we are done\n    if((signature->sigAlg == TPM_ALG_NULL) || (signKey == NULL))\n\treturn TPM_RC_SUCCESS;\n\n    // Initialize signature hash\n    // Note: need to do the check for TPM_ALG_NULL first because the null scheme\n    // doesn't have a hashAlg member.\n    signature->signature.any.hashAlg = signScheme->details.any.hashAlg;\n\n    // perform sign operation based on different key type\n    switch(signKey->publicArea.type)\n\t{\n#if ALG_RSA\n\t  case TPM_ALG_RSA:\n\t    result = CryptRsaSign(signature, signKey, digest, NULL);\n\t    break;\n#endif  // ALG_RSA\n#if ALG_ECC\n\t  case TPM_ALG_ECC:\n\t    // The reason that signScheme is passed to CryptEccSign but not to the\n\t    // other signing methods is that the signing for ECC may be split and\n\t    // need the 'r' value that is in the scheme but not in the signature.\n\t    result = CryptEccSign(\n\t\t\t\t  signature, signKey, digest, (TPMT_ECC_SCHEME*)signScheme, NULL);\n\t    break;\n#endif  // ALG_ECC\n\t  case TPM_ALG_KEYEDHASH:\n\t    result = CryptHmacSign(signature, signKey, digest);\n\t    break;\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    return result;\n}\n\n//*** CryptValidateSignature()\n// This function is used to verify a signature.  It is called by\n// TPM2_VerifySignature() and TPM2_PolicySigned.\n//\n// Since this operation only requires use of a public key, no consistency\n// checks are necessary for the key to signature type because a caller can load\n// any public key that they like with any scheme that they like. This routine\n// simply makes sure that the signature is correct, whatever the type.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE            the signature is not genuine\n//      TPM_RC_SCHEME               the scheme is not supported\n//      TPM_RC_HANDLE               an HMAC key was selected but the\n//                                  private part of the key is not loaded\nTPM_RC\nCryptValidateSignature(TPMI_DH_OBJECT  keyHandle,  // IN: The handle of sign key\n\t\t       TPM2B_DIGEST*   digest,     // IN: The digest being validated\n\t\t       TPMT_SIGNATURE* signature   // IN: signature\n\t\t       )\n{\n    // NOTE: HandleToObject will either return a pointer to a loaded object or\n    // will assert. It will never return a non-valid value. This makes it save\n    // to initialize 'publicArea' with the return value from HandleToObject()\n    // without checking it first.\n    OBJECT*      signObject = HandleToObject(keyHandle);\n    TPMT_PUBLIC* publicArea = &signObject->publicArea;\n    TPM_RC       result     = TPM_RC_SCHEME;\n\n    // The input unmarshaling should prevent any input signature from being\n    // a NULL signature, but just in case\n    if(signature->sigAlg == TPM_ALG_NULL)\n\treturn TPM_RC_SIGNATURE;\n\n    switch(publicArea->type)\n\t{\n#if ALG_RSA\n\t  case TPM_ALG_RSA:\n\t      {\n\t\t  //\n\t\t  // Call RSA code to verify signature\n\t\t  result = CryptRsaValidateSignature(signature, signObject, digest);\n\t\t  break;\n\t      }\n#endif  // ALG_RSA\n\n#if ALG_ECC\n\t  case TPM_ALG_ECC:\n\t    result = CryptEccValidateSignature(signature, signObject, digest);\n\t    break;\n#endif  // ALG_ECC\n\n\t  case TPM_ALG_KEYEDHASH:\n\t    if(signObject->attributes.publicOnly)\n\t\tresult = TPM_RCS_HANDLE;\n\t    else\n\t\tresult = CryptHMACVerifySignature(signObject, digest, signature);\n\t    break;\n\t  default:\n\t    break;\n\t}\n    return result;\n}\n\n//*** CryptGetTestResult\n// This function returns the results of a self-test function.\n// Note: the behavior in this function is NOT the correct behavior for a real\n// TPM implementation.  An artificial behavior is placed here due to the\n// limitation of a software simulation environment.  For the correct behavior,\n// consult the part 3 specification for TPM2_GetTestResult().\nTPM_RC\nCryptGetTestResult(TPM2B_MAX_BUFFER* outData  // OUT: test result data\n\t\t   )\n{\n    outData->t.size = 0;\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptValidateKeys()\n// This function is used to verify that the key material of and object is valid.\n// For a 'publicOnly' object, the key is verified for size and, if it is an ECC\n// key, it is verified to be on the specified curve. For a key with a sensitive\n// area, the binding between the public and private parts of the key are verified.\n// If the nameAlg of the key is TPM_ALG_NULL, then the size of the sensitive area\n// is verified but the public portion is not verified, unless the key is an RSA key.\n// For an RSA key, the reason for loading the sensitive area is to use it. The\n// only way to use a private RSA key is to compute the private exponent. To compute\n// the private exponent, the public modulus is used.\n//  Return Type: TPM_RC\n//      TPM_RC_BINDING      the public and private parts are not cryptographically\n//                          bound\n//      TPM_RC_HASH         cannot have a publicOnly key with nameAlg of TPM_ALG_NULL\n//      TPM_RC_KEY          the public unique is not valid\n//      TPM_RC_KEY_SIZE     the private area key is not valid\n//      TPM_RC_TYPE         the types of the sensitive and private parts do not match\nTPM_RC\nCryptValidateKeys(TPMT_PUBLIC*    publicArea,\n\t\t  TPMT_SENSITIVE* sensitive,\n\t\t  TPM_RC          blamePublic,\n\t\t  TPM_RC          blameSensitive)\n{\n    TPM_RC             result;\n    UINT16             keySizeInBytes;\n    UINT16             digestSize = CryptHashGetDigestSize(publicArea->nameAlg);\n    TPMU_PUBLIC_PARMS* params     = &publicArea->parameters;\n    TPMU_PUBLIC_ID*    unique     = &publicArea->unique;\n\n    if(sensitive != NULL)\n\t{\n\t    // Make sure that the types of the public and sensitive are compatible\n\t    if(publicArea->type != sensitive->sensitiveType)\n\t\treturn TPM_RCS_TYPE + blameSensitive;\n\t    // Make sure that the authValue is not bigger than allowed\n\t    // If there is no name algorithm, then the size just needs to be less than\n\t    // the maximum size of the buffer used for authorization. That size check\n\t    // was made during unmarshaling of the sensitive area\n\t    if((sensitive->authValue.t.size) > digestSize && (digestSize > 0))\n\t\treturn TPM_RCS_SIZE + blameSensitive;\n\t}\n    switch(publicArea->type)\n\t{\n#if ALG_RSA\n\t  case TPM_ALG_RSA:\n\t    keySizeInBytes = BITS_TO_BYTES(params->rsaDetail.keyBits);\n\n\t    // Regardless of whether there is a sensitive area, the public modulus\n\t    // needs to have the correct size. Otherwise, it can't be used for\n\t    // any public key operation nor can it be used to compute the private\n\t    // exponent.\n\t    // NOTE: This implementation only supports key sizes that are multiples\n\t    // of 1024 bits which means that the MSb of the 0th byte will always be\n\t    // SET in any prime and in the public modulus.\n\t    if((unique->rsa.t.size != keySizeInBytes)\n\t       || (unique->rsa.t.buffer[0] < 0x80))\n\t\treturn TPM_RCS_KEY + blamePublic;\n\t    if(params->rsaDetail.exponent != 0 && params->rsaDetail.exponent < 7)\n\t\treturn TPM_RCS_VALUE + blamePublic;\n\t    if(sensitive != NULL)\n\t\t{\n\t\t    // If there is a sensitive area, it has to be the correct size\n\t\t    // including having the correct high order bit SET.\n\t\t    if(((sensitive->sensitive.rsa.t.size * 2) != keySizeInBytes)\n\t\t       || (sensitive->sensitive.rsa.t.buffer[0] < 0x80))\n\t\t\treturn TPM_RCS_KEY_SIZE + blameSensitive;\n\t\t}\n\t    break;\n#endif\n#if ALG_ECC\n\t  case TPM_ALG_ECC:\n\t      {\n\t\t  TPMI_ECC_CURVE curveId;\n\t\t  curveId        = params->eccDetail.curveID;\n\t\t  keySizeInBytes = BITS_TO_BYTES(CryptEccGetKeySizeForCurve(curveId));\n\t\t  if(sensitive == NULL)\n\t\t      {\n\t\t\t  // Validate the public key size\n\t\t\t  if(unique->ecc.x.t.size != keySizeInBytes\n\t\t\t     || unique->ecc.y.t.size != keySizeInBytes)\n\t\t\t      return TPM_RCS_KEY + blamePublic;\n\t\t\t  if(publicArea->nameAlg != TPM_ALG_NULL)\n\t\t\t      {\n\t\t\t\t  if(!CryptEccIsPointOnCurve(curveId, &unique->ecc))\n\t\t\t\t      return TPM_RCS_ECC_POINT + blamePublic;\n\t\t\t      }\n\t\t      }\n\t\t  else\n\t\t      {\n\t\t\t  // If the nameAlg is TPM_ALG_NULL, then only verify that the\n\t\t\t  // private part of the key is OK.\n\t\t\t  if(!CryptEccIsValidPrivateKey(&sensitive->sensitive.ecc, curveId))\n\t\t\t      return TPM_RCS_KEY_SIZE;\n\t\t\t  if(publicArea->nameAlg != TPM_ALG_NULL)\n\t\t\t      {\n\t\t\t\t  // Full key load, verify that the public point belongs to the\n\t\t\t\t  // private key.\n\t\t\t\t  TPMS_ECC_POINT toCompare;\n\t\t\t\t  result = CryptEccPointMultiply(&toCompare,\n\t\t\t\t\t\t\t\t curveId,\n\t\t\t\t\t\t\t\t NULL,\n\t\t\t\t\t\t\t\t &sensitive->sensitive.ecc,\n\t\t\t\t\t\t\t\t NULL,\n\t\t\t\t\t\t\t\t NULL);\n\t\t\t\t  if(result != TPM_RC_SUCCESS)\n\t\t\t\t      return TPM_RCS_BINDING;\n\t\t\t\t  else\n\t\t\t\t      {\n\t\t\t\t\t  // Make sure that the private key generated the public key.\n\t\t\t\t\t  // The input values and the values produced by the point\n\t\t\t\t\t  // multiply may not be the same size so adjust the computed\n\t\t\t\t\t  // value to match the size of the input value by adding or\n\t\t\t\t\t  // removing zeros.\n\t\t\t\t\t  AdjustNumberB(&toCompare.x.b, unique->ecc.x.t.size);\n\t\t\t\t\t  AdjustNumberB(&toCompare.y.b, unique->ecc.y.t.size);\n\t\t\t\t\t  if(!MemoryEqual2B(&unique->ecc.x.b, &toCompare.x.b)\n\t\t\t\t\t     || !MemoryEqual2B(&unique->ecc.y.b, &toCompare.y.b))\n\t\t\t\t\t      return TPM_RCS_BINDING;\n\t\t\t\t      }\n\t\t\t      }\n\t\t      }\n\t\t  break;\n\t      }\n#endif\n\t  default:\n\t    // Checks for SYMCIPHER and KEYEDHASH are largely the same\n\t    // If public area has a nameAlg, then validate the public area size\n\t    // and if there is also a sensitive area, validate the binding\n\n\t    // For consistency, if the object is public-only just make sure that\n\t    // the unique field is consistent with the name algorithm\n\t    if(sensitive == NULL)\n\t\t{\n\t\t    if(unique->sym.t.size != digestSize)\n\t\t\treturn TPM_RCS_KEY + blamePublic;\n\t\t}\n\t    else\n\t\t{\n\t\t    // Make sure that the key size in the sensitive area is consistent.\n\t\t    if(publicArea->type == TPM_ALG_SYMCIPHER)\n\t\t\t{\n\t\t\t    result = CryptSymKeyValidate(&params->symDetail.sym,\n\t\t\t\t\t\t\t &sensitive->sensitive.sym);\n\t\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\t\treturn result + blameSensitive;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // For a keyed hash object, the key has to be less than the\n\t\t\t    // smaller of the block size of the hash used in the scheme or\n\t\t\t    // 128 bytes. The worst case value is limited by the\n\t\t\t    // unmarshaling code so the only thing left to be checked is\n\t\t\t    // that it does not exceed the block size of the hash.\n\t\t\t    // by the hash algorithm of the scheme.\n\t\t\t    TPMT_KEYEDHASH_SCHEME* scheme;\n\t\t\t    UINT16                 maxSize;\n\t\t\t    scheme = &params->keyedHashDetail.scheme;\n\t\t\t    if(scheme->scheme == TPM_ALG_XOR)\n\t\t\t\t{\n\t\t\t\t    maxSize = CryptHashGetBlockSize(scheme->details.xorr.hashAlg);\n\t\t\t\t}\n\t\t\t    else if(scheme->scheme == TPM_ALG_HMAC)\n\t\t\t\t{\n\t\t\t\t    maxSize = CryptHashGetBlockSize(scheme->details.hmac.hashAlg);\n\t\t\t\t}\n\t\t\t    else if(scheme->scheme == TPM_ALG_NULL)\n\t\t\t\t{\n\t\t\t\t    // Not signing or xor so must be a data block\n\t\t\t\t    maxSize = 128;\n\t\t\t\t}\n\t\t\t    else\n\t\t\t\treturn TPM_RCS_SCHEME + blamePublic;\n\t\t\t    if(sensitive->sensitive.bits.t.size > maxSize)\n\t\t\t\treturn TPM_RCS_KEY_SIZE + blameSensitive;\n\t\t\t}\n\t\t    // If there is a nameAlg, check the binding\n\t\t    if(publicArea->nameAlg != TPM_ALG_NULL)\n\t\t\t{\n\t\t\t    TPM2B_DIGEST compare;\n\t\t\t    if(sensitive->seedValue.t.size != digestSize)\n\t\t\t\treturn TPM_RCS_KEY_SIZE + blameSensitive;\n\n\t\t\t    CryptComputeSymmetricUnique(publicArea, sensitive, &compare);\n\t\t\t    if(!MemoryEqual2B(&unique->sym.b, &compare.b))\n\t\t\t\treturn TPM_RC_BINDING;\n\t\t\t}\n\t\t}\n\t    break;\n\t}\n    // For a parent, need to check that the seedValue is the correct size for\n    // protections. It should be at least half the size of the nameAlg\n    if(IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, restricted)\n       && IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, decrypt)\n       && sensitive != NULL && publicArea->nameAlg != TPM_ALG_NULL)\n\t{\n\t    if((sensitive->seedValue.t.size < (digestSize / 2))\n\t       || (sensitive->seedValue.t.size > digestSize))\n\t\treturn TPM_RCS_SIZE + blameSensitive;\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptSelectMac()\n// This function is used to set the MAC scheme based on the key parameters and\n// the input scheme.\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME       the scheme is not a valid mac scheme\n//      TPM_RC_TYPE         the input key is not a type that supports a mac\n//      TPM_RC_VALUE        the input scheme and the key scheme are not compatible\nTPM_RC\nCryptSelectMac(TPMT_PUBLIC* publicArea, TPMI_ALG_MAC_SCHEME* inMac)\n{\n    TPM_ALG_ID macAlg = TPM_ALG_NULL;\n    switch(publicArea->type)\n\t{\n\t  case TPM_ALG_KEYEDHASH:\n\t      {\n\t\t  // Local value to keep lines from getting too long\n\t\t  TPMT_KEYEDHASH_SCHEME* scheme;\n\t\t  scheme = &publicArea->parameters.keyedHashDetail.scheme;\n\t\t  // Expect that the scheme is either HMAC or NULL\n\t\t  if(scheme->scheme != TPM_ALG_NULL)\n\t\t      macAlg = scheme->details.hmac.hashAlg;\n\t\t  break;\n\t      }\n\t  case TPM_ALG_SYMCIPHER:\n\t      {\n\t\t  TPMT_SYM_DEF_OBJECT* scheme;\n\t\t  scheme = &publicArea->parameters.symDetail.sym;\n\t\t  // Expect that the scheme is either valid symmetric cipher or NULL\n\t\t  if(scheme->algorithm != TPM_ALG_NULL)\n\t\t      macAlg = scheme->mode.sym;\n\t\t  break;\n\t      }\n\t  default:\n\t    return TPM_RCS_TYPE;\n\t}\n    // If the input value is not TPM_ALG_NULL ...\n    if(*inMac != TPM_ALG_NULL)\n\t{\n\t    // ... then either the scheme in the key must be TPM_ALG_NULL or the input\n\t    // value must match\n\t    if((macAlg != TPM_ALG_NULL) && (*inMac != macAlg))\n\t\treturn TPM_RCS_VALUE;\n\t}\n    else\n\t{\n\t    // Since the input value is TPM_ALG_NULL, then the key value can't be\n\t    // TPM_ALG_NULL\n\t    if(macAlg == TPM_ALG_NULL)\n\t\treturn TPM_RCS_VALUE;\n\t    *inMac = macAlg;\n\t}\n    if(!CryptMacIsValidForKey(publicArea->type, *inMac, FALSE))\n\treturn TPM_RCS_SCHEME;\n    return TPM_RC_SUCCESS;\n}\n\n//*** CryptMacIsValidForKey()\n// Check to see if the key type is compatible with the mac type\nBOOL CryptMacIsValidForKey(TPM_ALG_ID keyType, TPM_ALG_ID macAlg, BOOL flag)\n{\n    switch(keyType)\n\t{\n\t  case TPM_ALG_KEYEDHASH:\n\t    return CryptHashIsValidAlg(macAlg, flag);\n\t    break;\n\t  case TPM_ALG_SYMCIPHER:\n\t    return CryptSmacIsValidAlg(macAlg, flag);\n\t    break;\n\t  default:\n\t    break;\n\t}\n    return FALSE;\n}\n\n//*** CryptSmacIsValidAlg()\n// This function is used to test if an algorithm is a supported SMAC algorithm. It\n// needs to be updated as new algorithms are added.\nBOOL CryptSmacIsValidAlg(TPM_ALG_ID alg,\n\t\t\t BOOL       FLAG  // IN: Indicates if TPM_ALG_NULL is valid\n\t\t\t )\n{\n    switch(alg)\n\t{\n#if ALG_CMAC\n\t  case TPM_ALG_CMAC:\n\t    return TRUE;\n\t    break;\n#endif\n\t  case TPM_ALG_NULL:\n\t    return FLAG;\n\t    break;\n\t  default:\n\t    return FALSE;\n\t}\n}\n\n//*** CryptSymModeIsValid()\n// Function checks to see if an algorithm ID is a valid, symmetric block cipher\n// mode for the TPM. If 'flag' is SET, them TPM_ALG_NULL is a valid mode.\n// not include the modes used for SMAC\nBOOL CryptSymModeIsValid(TPM_ALG_ID mode, BOOL flag)\n{\n    switch(mode)\n\t{\n#if ALG_CTR\n\t  case TPM_ALG_CTR:\n#endif  // ALG_CTR\n#if ALG_OFB\n\t  case TPM_ALG_OFB:\n#endif  // ALG_OFB\n#if ALG_CBC\n\t  case TPM_ALG_CBC:\n#endif  // ALG_CBC\n#if ALG_CFB\n\t  case TPM_ALG_CFB:\n#endif  // ALG_CFB\n#if ALG_ECB\n\t  case TPM_ALG_ECB:\n#endif  // ALG_ECB\n\t    return TRUE;\n\t  case TPM_ALG_NULL:\n\t    return flag;\n\t    break;\n\t  default:\n\t    break;\n\t}\n    return FALSE;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/DA.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Dictionary Attack Logic.  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: DA.c 1658 2021-01-22 23:14:01Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 8.2 DA.c */\n/* 8.2.1 Introduction */\n/* This file contains the functions and data definitions relating to the dictionary attack logic. */\n/* 8.2.2 Includes and Data Definitions */\n#define DA_C\n#include \"Tpm.h\"\n/* 8.2.3 Functions */\n/* 8.2.3.1 DAPreInstall_Init() */\n/* This function initializes the DA parameters to their manufacturer-default values. The default\n   values are determined by a platform-specific specification. */\n/* This function should not be called outside of a manufacturing or simulation environment. */\n/* The DA parameters will be restored to these initial values by TPM2_Clear(). */\nvoid\nDAPreInstall_Init(\n\t\t  void\n\t\t  )\n{\n    gp.failedTries = 0;\n    gp.maxTries = 3;\n    gp.recoveryTime = 1000;         // in seconds (~16.67 minutes)\n    gp.lockoutRecovery = 1000;      // in seconds\n    gp.lockOutAuthEnabled = TRUE;   // Use of lockoutAuth is enabled\n    // Record persistent DA parameter changes to NV\n    NV_SYNC_PERSISTENT(failedTries);\n    NV_SYNC_PERSISTENT(maxTries);\n    NV_SYNC_PERSISTENT(recoveryTime);\n    NV_SYNC_PERSISTENT(lockoutRecovery);\n    NV_SYNC_PERSISTENT(lockOutAuthEnabled);\n    return;\n}\n/* 8.2.3.2 DAStartup() */\n/* This function is called by TPM2_Startup() to initialize the DA parameters. In the case of\n   Startup(CLEAR), use of lockoutAuth will be enabled if the lockout recovery time is 0. Otherwise,\n   lockoutAuth will not be enabled until the TPM has been continuously powered for the\n   lockoutRecovery time. */\n/* This function requires that NV be available and not rate limiting. */\nBOOL\nDAStartup(\n\t  STARTUP_TYPE     type           // IN: startup type\n\t  )\n{\n    NOT_REFERENCED(type);\n#if !ACCUMULATE_SELF_HEAL_TIMER\n    _plat__TimerWasReset();\n    s_selfHealTimer = 0;\n    s_lockoutTimer = 0;\n#else\n    if(_plat__TimerWasReset())\n\t{\n\t    if(!NV_IS_ORDERLY)\n\t\t{\n\t\t    // If shutdown was not orderly, then don't really know if go.time has\n\t\t    // any useful value so reset the timer to 0. This is what the tick\n\t\t    // was reset to\n\t\t    s_selfHealTimer = 0;\n\t\t    s_lockoutTimer = 0;\n\t\t}\n\t    else\n\t\t{\n\t\t    // If we know how much time was accumulated at the last orderly shutdown\n\t\t    // subtract that from the saved timer values so that they effectively\n\t\t    // have the accumulated values\n\t\t    s_selfHealTimer -= go.time;\n\t\t    s_lockoutTimer -= go.time;\n\t\t}\n\t}\n#endif\n    // For any Startup(), if lockoutRecovery is 0, enable use of lockoutAuth.\n    if(gp.lockoutRecovery == 0)\n\t{\n\t    gp.lockOutAuthEnabled = TRUE;\n\t    // Record the changes to NV\n\t    NV_SYNC_PERSISTENT(lockOutAuthEnabled);\n\t}\n    // If DA has not been disabled and the previous shutdown is not orderly\n    // failedTries is not already at its maximum then increment 'failedTries'\n    if(gp.recoveryTime != 0\n       && gp.failedTries < gp.maxTries\n       && !IS_ORDERLY(g_prevOrderlyState))\n\t{\n#if USE_DA_USED\n\t    gp.failedTries += g_daUsed;\n\t    g_daUsed = FALSE;\n#else\n\t    gp.failedTries++;\n#endif\n\t    // Record the change to NV\n\t    NV_SYNC_PERSISTENT(failedTries);\n\t}\n    // Before Startup, the TPM will not do clock updates. At startup, need to\n    // do a time update which will do the DA update.\n    TimeUpdate();\n    return TRUE;\n}\n/* 8.2.3.3 DARegisterFailure() */\n/* This function is called when an authorization failure occurs on an entity that is subject to\n   dictionary-attack protection. When a DA failure is triggered, register the failure by resetting\n   the relevant self-healing timer to the current time. */\nvoid\nDARegisterFailure(\n\t\t  TPM_HANDLE       handle         // IN: handle for failure\n\t\t  )\n{\n    // Reset the timer associated with lockout if the handle is the lockoutAuth.\n    if(handle == TPM_RH_LOCKOUT)\n\ts_lockoutTimer = g_time;\n    else\n\ts_selfHealTimer = g_time;\n    return;\n}\n/* 8.2.3.4 DASelfHeal() */\n/* This function is called to check if sufficient time has passed to allow decrement of failedTries\n   or to re-enable use of lockoutAuth. */\n/* This function should be called when the time interval is updated. */\nvoid\nDASelfHeal(\n\t   void\n\t   )\n{\n    // Regular authorization self healing logic\n    // If no failed authorization tries, do nothing.  Otherwise, try to\n    // decrease failedTries\n    if(gp.failedTries != 0)\n\t{\n\t    // if recovery time is 0, DA logic has been disabled.  Clear failed tries\n\t    // immediately\n\t    if(gp.recoveryTime == 0)\n\t\t{\n\t\t    gp.failedTries = 0;\n\t\t    // Update NV record\n\t\t    NV_SYNC_PERSISTENT(failedTries);\n\t\t}\n\t    else\n\t\t{\n\t\t    UINT64          decreaseCount;\n#if 0 // Errata eliminates this code\n\t\t    // In the unlikely event that failedTries should become larger than\n\t\t    // maxTries\n\t\t    if(gp.failedTries > gp.maxTries)\n\t\t\tgp.failedTries = gp.maxTries;\n#endif\n\t\t    // How much can failedTries be decreased\n\t\t    // Cast s_selfHealTimer to an int in case it became negative at\n\t\t    // startup\n\t\t    decreaseCount = ((g_time - (INT64)s_selfHealTimer) / 1000)\n\t\t\t\t    / gp.recoveryTime;\n\t\t    if(gp.failedTries <= (UINT32)decreaseCount)\n\t\t\t// should not set failedTries below zero\n\t\t\tgp.failedTries = 0;\n\t\t    else\n\t\t\tgp.failedTries -= (UINT32)decreaseCount;\n\t\t    // the cast prevents overflow of the product\n\t\t    s_selfHealTimer += (decreaseCount * (UINT64)gp.recoveryTime) * 1000;\n\t\t    if(decreaseCount != 0)\n\t\t\t// If there was a change to the failedTries, record the changes\n\t\t\t// to NV\n\t\t\tNV_SYNC_PERSISTENT(failedTries);\n\t\t}\n\t}\n    // LockoutAuth self healing logic\n    // If lockoutAuth is enabled, do nothing.  Otherwise, try to see if we\n    // may enable it\n    if(!gp.lockOutAuthEnabled)\n\t{\n\t    // if lockout authorization recovery time is 0, a reboot is required to\n\t    // re-enable use of lockout authorization.  Self-healing would not\n\t    // apply in this case.\n\t    if(gp.lockoutRecovery != 0)\n\t\t{\n\t\t    if(((g_time - (INT64)s_lockoutTimer) / 1000) >= gp.lockoutRecovery)\n\t\t\t{\n\t\t\t    gp.lockOutAuthEnabled = TRUE;\n\t\t\t    // Record the changes to NV\n\t\t\t    NV_SYNC_PERSISTENT(lockOutAuthEnabled);\n\t\t\t}\n\t\t}\n\t}\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/DebugHelpers.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tDebug Helper\t\t\t\t \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: DebugHelpers.c 1658 2021-01-22 23:14:01Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.13\tDebugHelpers.c */\n/* C.13.1.\tDescription */\n/* This file contains the NV read and write access methods. This implementation uses RAM/file and\n   does not manage the RAM/file as NV blocks. The implementation may become more sophisticated over\n   time. */\n/* C.13.2.\tIncludes and Local */\n#include    <stdio.h>\n#include    <time.h>\n#include \"Platform.h\"\n#include \"DebugHelpers_fp.h\"\n\n#if CERTIFYX509_DEBUG\nconst char       *debugFileName = \"DebugFile.txt\";\n\n/* C.13.2.1.\tfileOpen() */\n\n/* This exists to allow use of the safe version of fopen() with a MS runtime. */\n\nstatic FILE *\nfileOpen(\n\t const char       *fn,\n\t const char       *mode\n\t )\n{\n    FILE        *f;\n#   if defined _MSC_VER\n    if(fopen_s(&f, fn, mode) != 0)\n\tf = NULL;\n#   else\n    f = fopen(fn, mode);\n#   endif\n    return f;\n}\n/* C.13.2.2.\tDebugFileInit() */\n/* This function initializes the file containing the debug data with the time of the file\n   creation. */\n/* This function opens the file used to hold the debug data. */\n/* Return Value\tMeaning */\n/* 0\tsuccess */\n/* != 0\terror */\n// int\n// DebugFileInit(\n// \t      void\n// \t      )\n// {\n//     FILE\t*f = NULL;\n//     time_t\tt = time(NULL);\n//     //\n//     // Get current date and time.\n// #   if defined _MSC_VER\n//     char                 timeString[100];\n//     ctime_s(timeString, (size_t)sizeof(timeString), &t);\n// #   else\n//     char                *timeString;\n//     timeString = ctime(&t);\n// #   endif\n//     // Try to open the debug file\n//     f = fileOpen(debugFileName, \"w\");\n//     if(f)\n// \t{\n// \t    /* Initialize the contents with the time. */\n// \t    fprintf(f, \"%s\\n\", timeString);\n// \t    fclose(f);\n// \t    return 0;\n// \t}\n//     return -1;\n// }\n\n/* C.13.2.3.\tDebugDumpBuffer() */\n\n// void\n// DebugDumpBuffer(\n// \t\tint             size,\n// \t\tunsigned char   *buf,\n// \t\tconst char      *identifier\n// \t\t)\n// {\n//     int             i;\n//     //\n//     FILE *f = fileOpen(debugFileName, \"a\");\n//     if(!f)\n// \treturn;\n//     if(identifier)\n// \tfprintf(f, \"%s\\n\", identifier);\n//     if(buf)\n// \t{\n// \t    for(i = 0; i < size; i++)\n// \t\t{\n// \t\t    if(((i % 16) == 0) && (i))\n// \t\t\tfprintf(f, \"\\n\");\n// \t\t    fprintf(f, \" %02X\", buf[i]);\n// \t\t}\n// \t    if((size % 16) != 0)\n// \t\tfprintf(f, \"\\n\");\n// \t}\n//     fclose(f);\n// }\n\n#endif // CERTIFYX509_DEBUG\n"
  },
  {
    "path": "ftpm-opensbi/src/DictionaryCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Dictionary Attack Functions  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: DictionaryCommands.c 1490 2019-07-26 21:13:22Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"DictionaryAttackLockReset_fp.h\"\n\nextern int verbose;\n\n#if CC_DictionaryAttackLockReset  // Conditional expansion of this file\nTPM_RC\nTPM2_DictionaryAttackLockReset(\n\t\t\t       DictionaryAttackLockReset_In    *in             // IN: input parameter list\n\t\t\t       )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_DictionaryAttackLockReset: lockHandle %08x\\n\", in->lockHandle);\n\t// fclose(f);\n  //   }\n    // Input parameter is not reference in command action\n    NOT_REFERENCED(in);\n    // The command needs NV update.\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Internal Data Update\n    // Set failed tries to 0\n    gp.failedTries = 0;\n    // Record the changes to NV\n    NV_SYNC_PERSISTENT(failedTries);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_DictionaryAttackLockReset\n#include \"Tpm.h\"\n#include \"DictionaryAttackParameters_fp.h\"\n#if CC_DictionaryAttackParameters  // Conditional expansion of this file\nTPM_RC\nTPM2_DictionaryAttackParameters(\n\t\t\t\tDictionaryAttackParameters_In   *in             // IN: input parameter list\n\t\t\t\t)\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_DictionaryAttackParameters: lockHandle %08x\\n\", in->lockHandle);\n\t// fclose(f);\n  //   }\n    // The command needs NV update.\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Internal Data Update\n    // Set dictionary attack parameters\n    gp.maxTries = in->newMaxTries;\n    gp.recoveryTime = in->newRecoveryTime;\n    gp.lockoutRecovery = in->lockoutRecovery;\n    // Record the changes to NV\n    NV_SYNC_PERSISTENT(failedTries);\n    NV_SYNC_PERSISTENT(maxTries);\n    NV_SYNC_PERSISTENT(recoveryTime);\n    NV_SYNC_PERSISTENT(lockoutRecovery);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_DictionaryAttackParameters\n"
  },
  {
    "path": "ftpm-opensbi/src/DuplicationCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Duplication Commands \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: DuplicationCommands.c 1490 2019-07-26 21:13:22Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"Duplicate_fp.h\"\n#if CC_Duplicate  // Conditional expansion of this file\n#include \"Object_spt_fp.h\"\n\nextern int verbose;\n\nTPM_RC\nTPM2_Duplicate(\n\t       Duplicate_In    *in,            // IN: input parameter list\n\t       Duplicate_Out   *out            // OUT: output parameter list\n\t       )\n{\n    TPM_RC                  result = TPM_RC_SUCCESS;\n    TPMT_SENSITIVE          sensitive;\n    UINT16                  innerKeySize = 0; // encrypt key size for inner wrap\n    OBJECT                  *object;\n    OBJECT                  *newParent;\n    TPM2B_DATA              data;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Duplicate: newParentHandle %08x\\n\", in->newParentHandle);\n\t// fprintf(f, \"TPM2_Duplicate: objectHandle %08x\\n\", in->objectHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Get duplicate object pointer\n    object = HandleToObject(in->objectHandle);\n    // Get new parent\n    newParent = HandleToObject(in->newParentHandle);\n    // duplicate key must have fixParent bit CLEAR.\n    if(IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, fixedParent))\n\treturn TPM_RCS_ATTRIBUTES + RC_Duplicate_objectHandle;\n    // Do not duplicate object with NULL nameAlg\n    if(object->publicArea.nameAlg == TPM_ALG_NULL)\n\treturn TPM_RCS_TYPE + RC_Duplicate_objectHandle;\n    // new parent key must be a storage object or TPM_RH_NULL\n    if(in->newParentHandle != TPM_RH_NULL\n       && !ObjectIsStorage(in->newParentHandle))\n\treturn TPM_RCS_TYPE + RC_Duplicate_newParentHandle;\n    // If the duplicated object has encryptedDuplication SET, then there must be\n    // an inner wrapper and the new parent may not be TPM_RH_NULL\n    if(IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT,\n\t\t    encryptedDuplication))\n\t{\n\t    if(in->symmetricAlg.algorithm == TPM_ALG_NULL)\n\t\treturn TPM_RCS_SYMMETRIC + RC_Duplicate_symmetricAlg;\n\t    if(in->newParentHandle == TPM_RH_NULL)\n\t\treturn TPM_RCS_HIERARCHY + RC_Duplicate_newParentHandle;\n\t}\n    if(in->symmetricAlg.algorithm == TPM_ALG_NULL)\n\t{\n\t    // if algorithm is TPM_ALG_NULL, input key size must be 0\n\t    if(in->encryptionKeyIn.t.size != 0)\n\t\treturn TPM_RCS_SIZE + RC_Duplicate_encryptionKeyIn;\n\t}\n    else\n\t{\n\t    // Get inner wrap key size\n\t    innerKeySize = in->symmetricAlg.keyBits.sym;\n\t    // If provided the input symmetric key must match the size of the algorithm\n\t    if(in->encryptionKeyIn.t.size != 0\n\t       && in->encryptionKeyIn.t.size != (innerKeySize + 7) / 8)\n\t\treturn TPM_RCS_SIZE + RC_Duplicate_encryptionKeyIn;\n\t}\n    // Command Output\n    if(in->newParentHandle != TPM_RH_NULL)\n\t{\n\t    // Make encrypt key and its associated secret structure.  A TPM_RC_KEY\n\t    // error may be returned at this point\n\t    out->outSymSeed.t.size = sizeof(out->outSymSeed.t.secret);\n\t    result = CryptSecretEncrypt(newParent, DUPLICATE_STRING, &data,\n\t\t\t\t\t&out->outSymSeed);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t}\n    else\n\t{\n\t    // Do not apply outer wrapper\n\t    data.t.size = 0;\n\t    out->outSymSeed.t.size = 0;\n\t}\n    // Copy sensitive area\n    sensitive = object->sensitive;\n    // Prepare output private data from sensitive.\n    // Note: If there is no encryption key, one will be provided by\n    // SensitiveToDuplicate(). This is why the assignment of encryptionKeyIn to\n    // encryptionKeyOut will work properly and is not conditional.\n    SensitiveToDuplicate(&sensitive, &object->name.b, newParent,\n\t\t\t object->publicArea.nameAlg, &data.b,\n\t\t\t &in->symmetricAlg, &in->encryptionKeyIn,\n\t\t\t &out->duplicate);\n    out->encryptionKeyOut = in->encryptionKeyIn;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_Duplicate\n#include \"Tpm.h\"\n#include \"Rewrap_fp.h\"\n#if CC_Rewrap  // Conditional expansion of this file\n#include \"Object_spt_fp.h\"\nTPM_RC\nTPM2_Rewrap(\n\t    Rewrap_In       *in,            // IN: input parameter list\n\t    Rewrap_Out      *out            // OUT: output parameter list\n\t    )\n{\n    TPM_RC                  result = TPM_RC_SUCCESS;\n    TPM2B_DATA              data;               // symmetric key\n    UINT16                  hashSize = 0;\n    TPM2B_PRIVATE           privateBlob;        // A temporary private blob\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Rewrap: oldParent %08x\\n\", in->oldParent);\n\t// fprintf(f, \"TPM2_Rewrap: newParent %08x\\n\", in->newParent);\n\t// fclose(f);\n  //   }\n    // to transit between old\n    // and new wrappers\n    // Input Validation\n    if((in->inSymSeed.t.size == 0 && in->oldParent != TPM_RH_NULL)\n       || (in->inSymSeed.t.size != 0 && in->oldParent == TPM_RH_NULL))\n\treturn TPM_RCS_HANDLE + RC_Rewrap_oldParent;\n    if(in->oldParent != TPM_RH_NULL)\n\t{\n\t    OBJECT              *oldParent = HandleToObject(in->oldParent);\n\t    // old parent key must be a storage object\n\t    if(!ObjectIsStorage(in->oldParent))\n\t\treturn TPM_RCS_TYPE + RC_Rewrap_oldParent;\n\t    // Decrypt input secret data via asymmetric decryption.  A\n\t    // TPM_RC_VALUE, TPM_RC_KEY or unmarshal errors may be returned at this\n\t    // point\n\t    result = CryptSecretDecrypt(oldParent, NULL, DUPLICATE_STRING,\n\t\t\t\t\t&in->inSymSeed, &data);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn TPM_RCS_VALUE + RC_Rewrap_inSymSeed;\n\t    // Unwrap Outer\n\t    result = UnwrapOuter(oldParent, &in->name.b,\n\t\t\t\t oldParent->publicArea.nameAlg, &data.b,\n\t\t\t\t FALSE,\n\t\t\t\t in->inDuplicate.t.size, in->inDuplicate.t.buffer);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn RcSafeAddToResult(result, RC_Rewrap_inDuplicate);\n\t    // Copy unwrapped data to temporary variable, remove the integrity field\n\t    hashSize = sizeof(UINT16) +\n\t\t       CryptHashGetDigestSize(oldParent->publicArea.nameAlg);\n\t    privateBlob.t.size = in->inDuplicate.t.size - hashSize;\n\t    pAssert(privateBlob.t.size <= sizeof(privateBlob.t.buffer));\n\t    MemoryCopy(privateBlob.t.buffer, in->inDuplicate.t.buffer + hashSize,\n\t\t       privateBlob.t.size);\n\t}\n    else\n\t{\n\t    // No outer wrap from input blob.  Direct copy.\n\t    privateBlob = in->inDuplicate;\n\t}\n    if(in->newParent != TPM_RH_NULL)\n\t{\n\t    OBJECT          *newParent;\n\t    newParent = HandleToObject(in->newParent);\n\t    // New parent must be a storage object\n\t    if(!ObjectIsStorage(in->newParent))\n\t\treturn TPM_RCS_TYPE + RC_Rewrap_newParent;\n\t    // Make new encrypt key and its associated secret structure.  A\n\t    // TPM_RC_VALUE error may be returned at this point if RSA algorithm is\n\t    // enabled in TPM\n\t    out->outSymSeed.t.size = sizeof(out->outSymSeed.t.secret);\n\t    result = CryptSecretEncrypt(newParent, DUPLICATE_STRING, &data,\n\t\t\t\t\t&out->outSymSeed);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t    // Copy temporary variable to output, reserve the space for integrity\n\t    hashSize = sizeof(UINT16) +\n\t\t       CryptHashGetDigestSize(newParent->publicArea.nameAlg);\n\t    // Make sure that everything fits into the output buffer\n\t    // Note: this is mostly only an issue if there was no outer wrapper on\n\t    // 'inDuplicate'. It could be as large as a TPM2B_PRIVATE buffer. If we add\n\t    // a digest for an outer wrapper, it won't fit anymore.\n\t    if((privateBlob.t.size + hashSize) > sizeof(out->outDuplicate.t.buffer))\n\t\treturn TPM_RCS_VALUE + RC_Rewrap_inDuplicate;\n\t    // Command output\n\t    out->outDuplicate.t.size = privateBlob.t.size;\n\t    pAssert(privateBlob.t.size\n\t\t    <= sizeof(out->outDuplicate.t.buffer) - hashSize);\n\t    MemoryCopy(out->outDuplicate.t.buffer + hashSize, privateBlob.t.buffer,\n\t\t       privateBlob.t.size);\n\t    // Produce outer wrapper for output\n\t    out->outDuplicate.t.size = ProduceOuterWrap(newParent, &in->name.b,\n\t\t\t\t\t\t\tnewParent->publicArea.nameAlg,\n\t\t\t\t\t\t\t&data.b,\n\t\t\t\t\t\t\tFALSE,\n\t\t\t\t\t\t\tout->outDuplicate.t.size,\n\t\t\t\t\t\t\tout->outDuplicate.t.buffer);\n\t}\n    else  // New parent is a null key so there is no seed\n\t{\n\t    out->outSymSeed.t.size = 0;\n\t    // Copy privateBlob directly\n\t    out->outDuplicate = privateBlob;\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_Rewrap\n#include \"Tpm.h\"\n#include \"Import_fp.h\"\n#if CC_Import  // Conditional expansion of this file\n#include \"Object_spt_fp.h\"\nTPM_RC\nTPM2_Import(\n\t    Import_In       *in,            // IN: input parameter list\n\t    Import_Out      *out            // OUT: output parameter list\n\t    )\n{\n    TPM_RC                   result = TPM_RC_SUCCESS;\n    OBJECT                  *parentObject;\n    TPM2B_DATA               data;                   // symmetric key\n    TPMT_SENSITIVE           sensitive;\n    TPM2B_NAME               name;\n    TPMA_OBJECT              attributes;\n    UINT16                   innerKeySize = 0;       // encrypt key size for inner\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Import: %08x\\n\", in->parentHandle);\n\t// fclose(f);\n  //   }\n   // wrapper\n    // Input Validation\n    // to save typing\n    attributes = in->objectPublic.publicArea.objectAttributes;\n    // FixedTPM and fixedParent must be CLEAR\n    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM)\n       || IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedParent))\n\treturn TPM_RCS_ATTRIBUTES + RC_Import_objectPublic;\n    // Get parent pointer\n    parentObject = HandleToObject(in->parentHandle);\n    if(!ObjectIsParent(parentObject))\n\treturn TPM_RCS_TYPE + RC_Import_parentHandle;\n    if(in->symmetricAlg.algorithm != TPM_ALG_NULL)\n\t{\n\t    // Get inner wrap key size\n\t    innerKeySize = in->symmetricAlg.keyBits.sym;\n\t    // Input symmetric key must match the size of algorithm.\n\t    if(in->encryptionKey.t.size != (innerKeySize + 7) / 8)\n\t\treturn TPM_RCS_SIZE + RC_Import_encryptionKey;\n\t}\n    else\n\t{\n\t    // If input symmetric algorithm is NULL, input symmetric key size must\n\t    // be 0 as well\n\t    if(in->encryptionKey.t.size != 0)\n\t\treturn TPM_RCS_SIZE + RC_Import_encryptionKey;\n\t    // If encryptedDuplication is SET, then the object must have an inner\n\t    // wrapper\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, encryptedDuplication))\n\t\treturn TPM_RCS_ATTRIBUTES + RC_Import_encryptionKey;\n\t}\n    // See if there is an outer wrapper\n    if(in->inSymSeed.t.size != 0)\n\t{\n\t    // in->inParentHandle is a parent, but in order to decrypt an outer wrapper,\n\t    // it must be able to do key exchange and a symmetric key can't do that.\n\t    if(parentObject->publicArea.type == TPM_ALG_SYMCIPHER)\n\t\treturn TPM_RCS_TYPE + RC_Import_parentHandle;\n\t    // Decrypt input secret data via asymmetric decryption. TPM_RC_ATTRIBUTES,\n\t    // TPM_RC_ECC_POINT, TPM_RC_INSUFFICIENT, TPM_RC_KEY, TPM_RC_NO_RESULT,\n\t    // TPM_RC_SIZE, TPM_RC_VALUE may be returned at this point\n\t    result = CryptSecretDecrypt(parentObject, NULL, DUPLICATE_STRING,\n\t\t\t\t\t&in->inSymSeed, &data);\n\t    pAssert(result != TPM_RC_BINDING);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn RcSafeAddToResult(result, RC_Import_inSymSeed);\n\t}\n    else\n\t{\n\t    // If encrytpedDuplication is set, then the object must have an outer\n\t    // wrapper\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, encryptedDuplication))\n\t\treturn TPM_RCS_ATTRIBUTES + RC_Import_inSymSeed;\n\t    data.t.size = 0;\n\t}\n    // Compute name of object\n    PublicMarshalAndComputeName(&(in->objectPublic.publicArea), &name);\n    if(name.t.size == 0)\n\treturn TPM_RCS_HASH + RC_Import_objectPublic;\n    // Retrieve sensitive from private.\n    // TPM_RC_INSUFFICIENT, TPM_RC_INTEGRITY, TPM_RC_SIZE may be returned here.\n    result = DuplicateToSensitive(&in->duplicate.b, &name.b, parentObject,\n\t\t\t\t  in->objectPublic.publicArea.nameAlg,\n\t\t\t\t  &data.b, &in->symmetricAlg,\n\t\t\t\t  &in->encryptionKey.b, &sensitive);\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, RC_Import_duplicate);\n    // If the parent of this object has fixedTPM SET, then validate this\n    // object as if it were being loaded so that validation can be skipped\n    // when it is actually loaded.\n    if(IS_ATTRIBUTE(parentObject->publicArea.objectAttributes, TPMA_OBJECT, fixedTPM))\n\t{\n\t    result = ObjectLoad(NULL, NULL, &in->objectPublic.publicArea,\n\t\t\t\t&sensitive, RC_Import_objectPublic, RC_Import_duplicate,\n\t\t\t\tNULL);\n\t}\n    // Command output\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    // Prepare output private data from sensitive\n\t    SensitiveToPrivate(&sensitive, &name, parentObject,\n\t\t\t       in->objectPublic.publicArea.nameAlg,\n\t\t\t       &out->outPrivate);\n\t}\n    return result;\n}\n#endif // CC_Import\n"
  },
  {
    "path": "ftpm-opensbi/src/EACommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Enhanced Authorization Commands\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"Policy_spt_fp.h\"\n#include \"PolicySigned_fp.h\"\n\nextern int verbose;\n\n#include \"Tpm.h\"\n#include \"Policy_spt_fp.h\"\n#include \"PolicySigned_fp.h\"\n\n#if CC_PolicySigned  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Include an asymmetrically signed authorization to the policy evaluation\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_CPHASH           cpHash was previously set to a different value\n//      TPM_RC_EXPIRED          'expiration' indicates a time in the past or\n//                              'expiration' is non-zero but no nonceTPM is present\n//      TPM_RC_NONCE            'nonceTPM' is not the nonce associated with the\n//                              'policySession'\n//      TPM_RC_SCHEME           the signing scheme of 'auth' is not supported by the\n//                              TPM\n//      TPM_RC_SIGNATURE        the signature is not genuine\n//      TPM_RC_SIZE             input cpHash has wrong size\nTPM_RC\nTPM2_PolicySigned(PolicySigned_In*  in,  // IN: input parameter list\n\t\t  PolicySigned_Out* out  // OUT: output parameter list\n\t\t  )\n{\n    TPM_RC       result = TPM_RC_SUCCESS;\n    SESSION*     session;\n    TPM2B_NAME   entityName;\n    TPM2B_DIGEST authHash;\n    HASH_STATE   hashState;\n    UINT64       authTimeout = 0;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicySigned: authObject %08x\\n\", in->authObject);\n\t// fprintf(f, \"TPM2_PolicySigned: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Set up local pointers\n    session = SessionGet(in->policySession);  // the session structure\n\n    // Only do input validation if this is not a trial policy session\n    if(session->attributes.isTrialPolicy == CLEAR)\n\t{\n\t    authTimeout = ComputeAuthTimeout(session, in->expiration, &in->nonceTPM);\n\n\t    result      = PolicyParameterChecks(session,\n\t\t\t\t\t\tauthTimeout,\n\t\t\t\t\t\t&in->cpHashA,\n\t\t\t\t\t\t&in->nonceTPM,\n\t\t\t\t\t\tRC_PolicySigned_nonceTPM,\n\t\t\t\t\t\tRC_PolicySigned_cpHashA,\n\t\t\t\t\t\tRC_PolicySigned_expiration);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t    // Re-compute the digest being signed\n\t    /*(See part 3 specification)\n\t    // The digest is computed as:\n\t    //     aHash := hash ( nonceTPM | expiration | cpHashA | policyRef)\n\t    //  where:\n\t    //      hash()      the hash associated with the signed authorization\n\t    //      nonceTPM    the nonceTPM value from the TPM2_StartAuthSession .\n\t    //                  response If the authorization is not limited to this\n\t    //                  session, the size of this value is zero.\n\t    //      expiration  time limit on authorization set by authorizing object.\n\t    //                  This 32-bit value is set to zero if the expiration\n\t    //                  time is not being set.\n\t    //      cpHashA     hash of the command parameters for the command being\n\t    //                  approved using the hash algorithm of the PSAP session.\n\t    //                  Set to NULLauth if the authorization is not limited\n\t    //                  to a specific command.\n\t    //      policyRef   hash of an opaque value determined by the authorizing\n\t    //                  object.  Set to the NULLdigest if no hash is present.\n\t    */\n\t    // Start hash\n\t    authHash.t.size = CryptHashStart(&hashState, CryptGetSignHashAlg(&in->auth));\n\t    // If there is no digest size, then we don't have a verification function\n\t    // for this algorithm (e.g. TPM_ALG_ECDAA) so indicate that it is a\n\t    // bad scheme.\n\t    if(authHash.t.size == 0)\n\t\treturn TPM_RCS_SCHEME + RC_PolicySigned_auth;\n\n\t    //  nonceTPM\n\t    CryptDigestUpdate2B(&hashState, &in->nonceTPM.b);\n\n\t    //  expiration\n\t    CryptDigestUpdateInt(&hashState, sizeof(UINT32), in->expiration);\n\n\t    //  cpHashA\n\t    CryptDigestUpdate2B(&hashState, &in->cpHashA.b);\n\n\t    //  policyRef\n\t    CryptDigestUpdate2B(&hashState, &in->policyRef.b);\n\n\t    //  Complete digest\n\t    CryptHashEnd2B(&hashState, &authHash.b);\n\n\t    // Validate Signature.  A TPM_RC_SCHEME, TPM_RC_HANDLE or TPM_RC_SIGNATURE\n\t    // error may be returned at this point\n\t    result = CryptValidateSignature(in->authObject, &authHash, &in->auth);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn RcSafeAddToResult(result, RC_PolicySigned_auth);\n\t}\n    // Internal Data Update\n    // Update policy with input policyRef and name of authorization key\n    // These values are updated even if the session is a trial session\n    PolicyContextUpdate(TPM_CC_PolicySigned,\n\t\t\tEntityGetName(in->authObject, &entityName),\n\t\t\t&in->policyRef,\n\t\t\t&in->cpHashA,\n\t\t\tauthTimeout,\n\t\t\tsession);\n    // Command Output\n    // Create ticket and timeout buffer if in->expiration < 0 and this is not\n    // a trial session.\n    // NOTE: PolicyParameterChecks() makes sure that nonceTPM is present\n    // when expiration is non-zero.\n    if(in->expiration < 0 && session->attributes.isTrialPolicy == CLEAR)\n\t{\n\t    BOOL expiresOnReset = (in->nonceTPM.t.size == 0);\n\t    // Compute policy ticket\n\t    authTimeout &= ~EXPIRATION_BIT;\n\n\t    result = TicketComputeAuth(TPM_ST_AUTH_SIGNED,\n\t\t\t\t       EntityGetHierarchy(in->authObject),\n\t\t\t\t       authTimeout,\n\t\t\t\t       expiresOnReset,\n\t\t\t\t       &in->cpHashA,\n\t\t\t\t       &in->policyRef,\n\t\t\t\t       &entityName,\n\t\t\t\t       &out->policyTicket);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\n\t    // Generate timeout buffer.  The format of output timeout buffer is\n\t    // TPM-specific.\n\t    // Note: In this implementation, the timeout buffer value is computed after\n\t    // the ticket is produced so, when the ticket is checked, the expiration\n\t    // flag needs to be extracted before the ticket is checked.\n\t    // In the Windows compatible version, the least-significant bit of the\n\t    // timeout value is used as a flag to indicate if the authorization expires\n\t    // on reset. The flag is the MSb.\n\t    out->timeout.t.size = sizeof(authTimeout);\n\t    if(expiresOnReset)\n\t\tauthTimeout |= EXPIRATION_BIT;\n\t    UINT64_TO_BYTE_ARRAY(authTimeout, out->timeout.t.buffer);\n\t}\n    else\n\t{\n\t    // Generate a null ticket.\n\t    // timeout buffer is null\n\t    out->timeout.t.size = 0;\n\n\t    // authorization ticket is null\n\t    out->policyTicket.tag           = TPM_ST_AUTH_SIGNED;\n\t    out->policyTicket.hierarchy     = TPM_RH_NULL;\n\t    out->policyTicket.digest.t.size = 0;\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicySigned\n\n\n#include \"Tpm.h\"\n#include \"PolicySecret_fp.h\"\n\n#if CC_PolicySecret  // Conditional expansion of this file\n\n#  include \"Policy_spt_fp.h\"\n#  include \"NV_spt_fp.h\"\n\n/*(See part 3 specification)\n// Add a secret-based authorization to the policy evaluation\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_CPHASH           cpHash for policy was previously set to a\n//                              value that is not the same as 'cpHashA'\n//      TPM_RC_EXPIRED          'expiration' indicates a time in the past\n//      TPM_RC_NONCE            'nonceTPM' does not match the nonce associated\n//                              with 'policySession'\n//      TPM_RC_SIZE             'cpHashA' is not the size of a digest for the\n//                              hash associated with 'policySession'\nTPM_RC\nTPM2_PolicySecret(PolicySecret_In*  in,  // IN: input parameter list\n\t\t  PolicySecret_Out* out  // OUT: output parameter list\n\t\t  )\n{\n    TPM_RC     result;\n    SESSION*   session;\n    TPM2B_NAME entityName;\n    UINT64     authTimeout = 0;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicySecret: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_PolicySecret: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    //Only do input validation if this is not a trial policy session\n    if(session->attributes.isTrialPolicy == CLEAR)\n\t{\n\t    authTimeout = ComputeAuthTimeout(session, in->expiration, &in->nonceTPM);\n\n\t    result      = PolicyParameterChecks(session,\n\t\t\t\t\t\tauthTimeout,\n\t\t\t\t\t\t&in->cpHashA,\n\t\t\t\t\t\t&in->nonceTPM,\n\t\t\t\t\t\tRC_PolicySecret_nonceTPM,\n\t\t\t\t\t\tRC_PolicySecret_cpHashA,\n\t\t\t\t\t\tRC_PolicySecret_expiration);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t}\n    // Internal Data Update\n    // Update policy context with input policyRef and name of authorizing key\n    // This value is computed even for trial sessions. Possibly update the cpHash\n    PolicyContextUpdate(TPM_CC_PolicySecret,\n\t\t\tEntityGetName(in->authHandle, &entityName),\n\t\t\t&in->policyRef,\n\t\t\t&in->cpHashA,\n\t\t\tauthTimeout,\n\t\t\tsession);\n    // Command Output\n    // Create ticket and timeout buffer if in->expiration < 0 and this is not\n    // a trial session.\n    // NOTE: PolicyParameterChecks() makes sure that nonceTPM is present\n    // when expiration is non-zero.\n    if(in->expiration < 0 && session->attributes.isTrialPolicy == CLEAR\n       && !NvIsPinPassIndex(in->authHandle))\n\t{\n\t    BOOL expiresOnReset = (in->nonceTPM.t.size == 0);\n\t    // Compute policy ticket\n\t    authTimeout &= ~EXPIRATION_BIT;\n\t    result = TicketComputeAuth(TPM_ST_AUTH_SECRET,\n\t\t\t\t       EntityGetHierarchy(in->authHandle),\n\t\t\t\t       authTimeout,\n\t\t\t\t       expiresOnReset,\n\t\t\t\t       &in->cpHashA,\n\t\t\t\t       &in->policyRef,\n\t\t\t\t       &entityName,\n\t\t\t\t       &out->policyTicket);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\n\t    // Generate timeout buffer.  The format of output timeout buffer is\n\t    // TPM-specific.\n\t    // Note: In this implementation, the timeout buffer value is computed after\n\t    // the ticket is produced so, when the ticket is checked, the expiration\n\t    // flag needs to be extracted before the ticket is checked.\n\t    out->timeout.t.size = sizeof(authTimeout);\n\t    // In the Windows compatible version, the least-significant bit of the\n\t    // timeout value is used as a flag to indicate if the authorization expires\n\t    // on reset. The flag is the MSb.\n\t    if(expiresOnReset)\n\t\tauthTimeout |= EXPIRATION_BIT;\n\t    UINT64_TO_BYTE_ARRAY(authTimeout, out->timeout.t.buffer);\n\t}\n    else\n\t{\n\t    // timeout buffer is null\n\t    out->timeout.t.size = 0;\n\n\t    // authorization ticket is null\n\t    out->policyTicket.tag           = TPM_ST_AUTH_SECRET;\n\t    out->policyTicket.hierarchy     = TPM_RH_NULL;\n\t    out->policyTicket.digest.t.size = 0;\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicySecret\n\n#include \"Tpm.h\"\n#include \"PolicyTicket_fp.h\"\n\n#if CC_PolicyTicket  // Conditional expansion of this file\n\n#  include \"Policy_spt_fp.h\"\n\n/*(See part 3 specification)\n// Include ticket to the policy evaluation\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_CPHASH           policy's cpHash was previously set to a different\n//                              value\n//      TPM_RC_EXPIRED          'timeout' value in the ticket is in the past and the\n//                              ticket has expired\n//      TPM_RC_SIZE             'timeout' or 'cpHash' has invalid size for the\n//      TPM_RC_TICKET           'ticket' is not valid\nTPM_RC\nTPM2_PolicyTicket(PolicyTicket_In* in  // IN: input parameter list\n\t\t  )\n{\n    TPM_RC       result;\n    SESSION*     session;\n    UINT64       authTimeout;\n    TPMT_TK_AUTH ticketToCompare;\n    TPM_CC       commandCode = TPM_CC_PolicySecret;\n    BOOL         expiresOnReset;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyTicket: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // NOTE: A trial policy session is not allowed to use this command.\n    // A ticket is used in place of a previously given authorization. Since\n    // a trial policy doesn't actually authenticate, the validated\n    // ticket is not necessary and, in place of using a ticket, one\n    // should use the intended authorization for which the ticket\n    // would be a substitute.\n    if(session->attributes.isTrialPolicy)\n\treturn TPM_RCS_ATTRIBUTES + RC_PolicyTicket_policySession;\n    // Restore timeout data.  The format of timeout buffer is TPM-specific.\n    // In this implementation, the most significant bit of the timeout value is\n    // used as the flag to indicate that the ticket expires on TPM Reset or\n    // TPM Restart. The flag has to be removed before the parameters and ticket\n    // are checked.\n    if(in->timeout.t.size != sizeof(UINT64))\n\treturn TPM_RCS_SIZE + RC_PolicyTicket_timeout;\n    authTimeout = BYTE_ARRAY_TO_UINT64(in->timeout.t.buffer);\n\n    // extract the flag\n    expiresOnReset = (authTimeout & EXPIRATION_BIT) != 0;\n    authTimeout &= ~EXPIRATION_BIT;\n\n    // Do the normal checks on the cpHashA and timeout values\n    result = PolicyParameterChecks(session,\n\t\t\t\t   authTimeout,\n\t\t\t\t   &in->cpHashA,\n\t\t\t\t   NULL,  // no nonce\n\t\t\t\t   0,     // no bad nonce return\n\t\t\t\t   RC_PolicyTicket_cpHashA,\n\t\t\t\t   RC_PolicyTicket_timeout);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Validate Ticket\n    // Re-generate policy ticket by input parameters\n    result = TicketComputeAuth(in->ticket.tag,\n\t\t\t       in->ticket.hierarchy,\n\t\t\t       authTimeout,\n\t\t\t       expiresOnReset,\n\t\t\t       &in->cpHashA,\n\t\t\t       &in->policyRef,\n\t\t\t       &in->authName,\n\t\t\t       &ticketToCompare);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Compare generated digest with input ticket digest\n    if(!MemoryEqual2B(&in->ticket.digest.b, &ticketToCompare.digest.b))\n\treturn TPM_RCS_TICKET + RC_PolicyTicket_ticket;\n\n    // Internal Data Update\n\n    // Is this ticket to take the place of a TPM2_PolicySigned() or\n    // a TPM2_PolicySecret()?\n    if(in->ticket.tag == TPM_ST_AUTH_SIGNED)\n\tcommandCode = TPM_CC_PolicySigned;\n    else if(in->ticket.tag == TPM_ST_AUTH_SECRET)\n\tcommandCode = TPM_CC_PolicySecret;\n    else\n\t// There could only be two possible tag values.  Any other value should\n\t// be caught by the ticket validation process.\n\tFAIL(FATAL_ERROR_INTERNAL);\n\n    // Update policy context\n    PolicyContextUpdate(commandCode,\n\t\t\t&in->authName,\n\t\t\t&in->policyRef,\n\t\t\t&in->cpHashA,\n\t\t\tauthTimeout,\n\t\t\tsession);\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyTicket\n\n#include \"Tpm.h\"\n#include \"PolicyOR_fp.h\"\n\n#if CC_PolicyOR  // Conditional expansion of this file\n\n#  include \"Policy_spt_fp.h\"\n\n/*(See part 3 specification)\n// PolicyOR command\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE            no digest in 'pHashList' matched the current\n//                              value of policyDigest for 'policySession'\nTPM_RC\nTPM2_PolicyOR(PolicyOR_In* in  // IN: input parameter list\n\t      )\n{\n    SESSION* session;\n    UINT32   i;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyOR: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Input Validation and Update\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // Compare and Update Internal Session policy if match\n    for(i = 0; i < in->pHashList.count; i++)\n\t{\n\t    if(session->attributes.isTrialPolicy == SET\n\t       || (MemoryEqual2B(&session->u2.policyDigest.b,\n\t\t\t\t &in->pHashList.digests[i].b)))\n\t\t{\n\t\t    // Found a match\n\t\t    HASH_STATE hashState;\n\t\t    TPM_CC     commandCode = TPM_CC_PolicyOR;\n\n\t\t    // Start hash\n\t\t    session->u2.policyDigest.t.size =\n\t\t\tCryptHashStart(&hashState, session->authHashAlg);\n\t\t    // Set policyDigest to 0 string and add it to hash\n\t\t    MemorySet(session->u2.policyDigest.t.buffer,\n\t\t\t      0,\n\t\t\t      session->u2.policyDigest.t.size);\n\t\t    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n\t\t    // add command code\n\t\t    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n\t\t    // Add each of the hashes in the list\n\t\t    for(i = 0; i < in->pHashList.count; i++)\n\t\t\t{\n\t\t\t    // Extend policyDigest\n\t\t\t    CryptDigestUpdate2B(&hashState, &in->pHashList.digests[i].b);\n\t\t\t}\n\t\t    // Complete digest\n\t\t    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n\t\t    return TPM_RC_SUCCESS;\n\t\t}\n\t}\n    // None of the values in the list matched the current policyDigest\n    return TPM_RCS_VALUE + RC_PolicyOR_pHashList;\n}\n\n#endif  // CC_PolicyOR\n\n#include \"Tpm.h\"\n\n#if CC_PolicyPCR  // Conditional expansion of this file\n\n#  include \"PolicyPCR_fp.h\"\n#  include \"Marshal.h\"\n\n/*(See part 3 specification)\n// Add a PCR gate for a policy session\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE          if provided, 'pcrDigest' does not match the\n//                            current PCR settings\n//      TPM_RC_PCR_CHANGED    a previous TPM2_PolicyPCR() set\n//                            pcrCounter and it has changed\nTPM_RC\nTPM2_PolicyPCR(PolicyPCR_In* in  // IN: input parameter list\n\t       )\n{\n    SESSION*     session;\n    TPM2B_DIGEST pcrDigest;\n    BYTE         pcrs[sizeof(TPML_PCR_SELECTION)];\n    UINT32       pcrSize;\n    BYTE*        buffer;\n    TPM_CC       commandCode = TPM_CC_PolicyPCR;\n    HASH_STATE   hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyPCR: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // Compute current PCR digest\n    PCRComputeCurrentDigest(session->authHashAlg, &in->pcrs, &pcrDigest);\n\n    // Do validation for non trial session\n    if(session->attributes.isTrialPolicy == CLEAR)\n\t{\n\t    // Make sure that this is not going to invalidate a previous PCR check\n\t    if(session->pcrCounter != 0 && session->pcrCounter != gr.pcrCounter)\n\t\treturn TPM_RC_PCR_CHANGED;\n\n\t    // If the caller specified the PCR digest and it does not\n\t    // match the current PCR settings, return an error..\n\t    if(in->pcrDigest.t.size != 0)\n\t\t{\n\t\t    if(!MemoryEqual2B(&in->pcrDigest.b, &pcrDigest.b))\n\t\t\treturn TPM_RCS_VALUE + RC_PolicyPCR_pcrDigest;\n\t\t}\n\t}\n    else\n\t{\n\t    // For trial session, just use the input PCR digest if one provided\n\t    // Note: It can't be too big because it is a TPM2B_DIGEST and the size\n\t    // would have been checked during unmarshaling\n\t    if(in->pcrDigest.t.size != 0)\n\t\tpcrDigest = in->pcrDigest;\n\t}\n    // Internal Data Update\n    // Update policy hash\n    // policyDigestnew = hash(   policyDigestold || TPM_CC_PolicyPCR\n    //                      || PCRS || pcrDigest)\n    //  Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add PCRS\n    buffer  = pcrs;\n    pcrSize = TPML_PCR_SELECTION_Marshal(&in->pcrs, &buffer, NULL);\n    CryptDigestUpdate(&hashState, pcrSize, pcrs);\n\n    //  add PCR digest\n    CryptDigestUpdate2B(&hashState, &pcrDigest.b);\n\n    //  complete the hash and get the results\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    //  update pcrCounter in session context for non trial session\n    if(session->attributes.isTrialPolicy == CLEAR)\n\t{\n\t    session->pcrCounter = gr.pcrCounter;\n\t}\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyPCR\n\n#include \"Tpm.h\"\n#include \"PolicyPhysicalPresence_fp.h\"\n\n#if CC_PolicyPhysicalPresence  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// indicate that physical presence will need to be asserted at the time the\n// authorization is performed\n*/\nTPM_RC\nTPM2_PolicyPhysicalPresence(PolicyPhysicalPresence_In* in  // IN: input parameter list\n\t\t\t    )\n{\n    SESSION*   session;\n    TPM_CC     commandCode = TPM_CC_PolicyPhysicalPresence;\n    HASH_STATE hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyPhysicalPresence: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Internal Data Update\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyPhysicalPresence)\n    //  Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  complete the digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    // update session attribute\n    session->attributes.isPPRequired = SET;\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyPhysicalPresence\n\n\n#include \"Tpm.h\"\n#include \"PolicyLocality_fp.h\"\n#include \"Marshal.h\"\n\n#if CC_PolicyLocality  // Conditional expansion of this file\n\n//  Return Type: TPM_RC\n//      TPM_RC_RANGE          all the locality values selected by\n//                            'locality' have been disabled\n//                            by previous TPM2_PolicyLocality() calls.\nTPM_RC\nTPM2_PolicyLocality(PolicyLocality_In* in  // IN: input parameter list\n\t\t    )\n{\n    SESSION*   session;\n    BYTE       marshalBuffer[sizeof(TPMA_LOCALITY)];\n    BYTE       prevSetting[sizeof(TPMA_LOCALITY)];\n    UINT32     marshalSize;\n    BYTE*      buffer;\n    TPM_CC     commandCode = TPM_CC_PolicyLocality;\n    HASH_STATE hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyLocality: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // Get new locality setting in canonical form\n    marshalBuffer[0] = 0;  // Code analysis says that this is not initialized\n    buffer           = marshalBuffer;\n    marshalSize      = TPMA_LOCALITY_Marshal(&in->locality, &buffer, NULL);\n\n    // Its an error if the locality parameter is zero\n    if(marshalBuffer[0] == 0)\n\treturn TPM_RCS_RANGE + RC_PolicyLocality_locality;\n\n    // Get existing locality setting in canonical form\n    prevSetting[0] = 0;  // Code analysis says that this is not initialized\n    buffer         = prevSetting;\n    TPMA_LOCALITY_Marshal(&session->commandLocality, &buffer, NULL);\n\n    // If the locality has previously been set\n    if(prevSetting[0] != 0\n       // then the current locality setting and the requested have to be the same\n       // type (that is, either both normal or both extended\n       && ((prevSetting[0] < 32) != (marshalBuffer[0] < 32)))\n\treturn TPM_RCS_RANGE + RC_PolicyLocality_locality;\n\n    // See if the input is a regular or extended locality\n    if(marshalBuffer[0] < 32)\n\t{\n\t    // if there was no previous setting, start with all normal localities\n\t    // enabled\n\t    if(prevSetting[0] == 0)\n\t\tprevSetting[0] = 0x1F;\n\n\t    // AND the new setting with the previous setting and store it in prevSetting\n\t    prevSetting[0] &= marshalBuffer[0];\n\n\t    // The result setting can not be 0\n\t    if(prevSetting[0] == 0)\n\t\treturn TPM_RCS_RANGE + RC_PolicyLocality_locality;\n\t}\n    else\n\t{\n\t    // for extended locality\n\t    // if the locality has already been set, then it must match the\n\t    if(prevSetting[0] != 0 && prevSetting[0] != marshalBuffer[0])\n\t\treturn TPM_RCS_RANGE + RC_PolicyLocality_locality;\n\n\t    // Setting is OK\n\t    prevSetting[0] = marshalBuffer[0];\n\t}\n\n    // Internal Data Update\n\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyLocality || locality)\n    // Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    // add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    // add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    // add input locality\n    CryptDigestUpdate(&hashState, marshalSize, marshalBuffer);\n\n    // complete the digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    // update session locality by unmarshal function.  The function must succeed\n    // because both input and existing locality setting have been validated.\n    buffer = prevSetting;\n    TPMA_LOCALITY_Unmarshal(&session->commandLocality, &buffer, (INT32*)&marshalSize);\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyLocality\n\n\n\n#include \"Tpm.h\"\n#include \"PolicyNV_fp.h\"\n\n#if CC_PolicyNV  // Conditional expansion of this file\n\n#  include \"Policy_spt_fp.h\"\n\n/*(See part 3 specification)\n// Do comparison to NV location\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_AUTH_TYPE            NV index authorization type is not correct\n//      TPM_RC_NV_LOCKED            NV index read locked\n//      TPM_RC_NV_UNINITIALIZED     the NV index has not been initialized\n//      TPM_RC_POLICY               the comparison to the NV contents failed\n//      TPM_RC_SIZE                 the size of 'nvIndex' data starting at 'offset'\n//                                  is less than the size of 'operandB'\n//      TPM_RC_VALUE                'offset' is too large\nTPM_RC\nTPM2_PolicyNV(PolicyNV_In* in  // IN: input parameter list\n\t      )\n{\n    TPM_RC       result;\n    SESSION*     session;\n    NV_REF       locator;\n    NV_INDEX*    nvIndex;\n    BYTE         nvBuffer[sizeof(in->operandB.t.buffer)];\n    TPM2B_NAME   nvName;\n    TPM_CC       commandCode = TPM_CC_PolicyNV;\n    HASH_STATE   hashState;\n    TPM2B_DIGEST argHash;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyNV: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_PolicyNV: nvIndex %08x\\n\", in->nvIndex);\n\t// fprintf(f, \"TPM2_PolicyNV: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    //If this is a trial policy, skip all validations and the operation\n    if(session->attributes.isTrialPolicy == CLEAR)\n\t{\n\t    // No need to access the actual NV index information for a trial policy.\n\t    nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n\n\t    // Common read access checks. NvReadAccessChecks() may return\n\t    // TPM_RC_NV_AUTHORIZATION, TPM_RC_NV_LOCKED, or TPM_RC_NV_UNINITIALIZED\n\t    result = NvReadAccessChecks(\n\t\t\t\t\tin->authHandle, in->nvIndex, nvIndex->publicArea.attributes);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\n\t    // Make sure that offset is within range\n\t    if(in->offset > nvIndex->publicArea.dataSize)\n\t\treturn TPM_RCS_VALUE + RC_PolicyNV_offset;\n\n\t    // Valid NV data size should not be smaller than input operandB size\n\t    if((nvIndex->publicArea.dataSize - in->offset) < in->operandB.t.size)\n\t\treturn TPM_RCS_SIZE + RC_PolicyNV_operandB;\n\n\t    // Get NV data.  The size of NV data equals the input operand B size\n\t    NvGetIndexData(nvIndex, locator, in->offset, in->operandB.t.size, nvBuffer);\n\n\t    // Check to see if the condition is valid\n\t    if(!PolicySptCheckCondition(in->operation, nvBuffer,\n\t\t\t\t\tin->operandB.t.buffer, in->operandB.t.size))\n\t\treturn TPM_RC_POLICY;\n\t}\n    // Internal Data Update\n\n    // Start argument hash\n    argHash.t.size = CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add operandB\n    CryptDigestUpdate2B(&hashState, &in->operandB.b);\n\n    //  add offset\n    CryptDigestUpdateInt(&hashState, sizeof(UINT16), in->offset);\n\n    //  add operation\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_EO), in->operation);\n\n    //  complete argument digest\n    CryptHashEnd2B(&hashState, &argHash.b);\n\n    // Update policyDigest\n    //  Start digest\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add argument digest\n    CryptDigestUpdate2B(&hashState, &argHash.b);\n\n    // Adding nvName\n    CryptDigestUpdate2B(&hashState, &EntityGetName(in->nvIndex, &nvName)->b);\n\n    // complete the digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyNV\n\n\n#include \"Tpm.h\"\n#include \"PolicyCounterTimer_fp.h\"\n\n#if CC_PolicyCounterTimer  // Conditional expansion of this file\n\n#  include \"Policy_spt_fp.h\"\n\n/*(See part 3 specification)\n// Add a conditional gating of a policy based on the contents of the\n// TPMS_TIME_INFO structure.\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_POLICY           the comparison of the selected portion of the\n//                              TPMS_TIME_INFO with 'operandB' failed\n//      TPM_RC_RANGE            'offset' + 'size' exceed size of TPMS_TIME_INFO\n//                              structure\nTPM_RC\nTPM2_PolicyCounterTimer(PolicyCounterTimer_In* in  // IN: input parameter list\n\t\t\t)\n{\n    SESSION*     session;\n    TIME_INFO    infoData;  // data buffer of  TPMS_TIME_INFO\n    BYTE*        pInfoData = (BYTE*)&infoData;\n    UINT16       infoDataSize;\n    TPM_CC       commandCode = TPM_CC_PolicyCounterTimer;\n    HASH_STATE   hashState;\n    TPM2B_DIGEST argHash;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyCounterTimer: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n    // Get a marshaled time structure\n    infoDataSize = TimeGetMarshaled(&infoData);\n    // Make sure that the referenced stays within the bounds of the structure.\n    // NOTE: the offset checks are made even for a trial policy because the policy\n    // will not make any sense if the references are out of bounds of the timer\n    // structure.\n    if(in->offset > infoDataSize)\n\treturn TPM_RCS_VALUE + RC_PolicyCounterTimer_offset;\n    if((UINT32)in->offset + (UINT32)in->operandB.t.size > infoDataSize)\n\treturn TPM_RCS_RANGE;\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    //If this is a trial policy, skip the check to see if the condition is met.\n    if(session->attributes.isTrialPolicy == CLEAR)\n\t{\n\t    // If the command is going to use any part of the counter or timer, need\n\t    // to verify that time is advancing.\n\t    // The time and clock vales are the first two 64-bit values in the clock\n\t    if(in->offset < sizeof(UINT64) + sizeof(UINT64))\n\t\t{\n\t\t    // Using Clock or Time so see if clock is running. Clock doesn't\n\t\t    // run while NV is unavailable.\n\t\t    // TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned here.\n\t\t    RETURN_IF_NV_IS_NOT_AVAILABLE;\n\t\t}\n\t    // offset to the starting position\n\t    pInfoData = (BYTE*)infoData;\n\t    // Check to see if the condition is valid\n\t    if(!PolicySptCheckCondition(in->operation,\n\t\t\t\t\tpInfoData + in->offset,\n\t\t\t\t\tin->operandB.t.buffer,\n\t\t\t\t\tin->operandB.t.size))\n\t\treturn TPM_RC_POLICY;\n\t}\n    // Internal Data Update\n    // Start argument list hash\n    argHash.t.size = CryptHashStart(&hashState, session->authHashAlg);\n    //  add operandB\n    CryptDigestUpdate2B(&hashState, &in->operandB.b);\n    //  add offset\n    CryptDigestUpdateInt(&hashState, sizeof(UINT16), in->offset);\n    //  add operation\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_EO), in->operation);\n    //  complete argument hash\n    CryptHashEnd2B(&hashState, &argHash.b);\n\n    // update policyDigest\n    //  start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add argument digest\n    CryptDigestUpdate2B(&hashState, &argHash.b);\n\n    // complete the digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyCounterTimer\n\n\n\n#include \"Tpm.h\"\n#include \"PolicyCommandCode_fp.h\"\n\n#if CC_PolicyCommandCode  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Add a Command Code restriction to the policyDigest\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE        'commandCode' of 'policySession' previously set to\n//                          a different value\n\nTPM_RC\nTPM2_PolicyCommandCode(PolicyCommandCode_In* in  // IN: input parameter list\n\t\t       )\n{\n    SESSION*   session;\n    TPM_CC     commandCode = TPM_CC_PolicyCommandCode;\n    HASH_STATE hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyCommandCode: policySession %08x\\n\", in->policySession);\n\t// fprintf(f, \"TPM2_PolicyCommandCode: code %08x\\n\", in->code);\n\t// fclose(f);\n  //   }\n    // Input validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    if(session->commandCode != 0 && session->commandCode != in->code)\n\treturn TPM_RCS_VALUE + RC_PolicyCommandCode_code;\n    if(CommandCodeToCommandIndex(in->code) == UNIMPLEMENTED_COMMAND_INDEX)\n\treturn TPM_RCS_POLICY_CC + RC_PolicyCommandCode_code;\n\n    // Internal Data Update\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyCommandCode || code)\n    //  Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add input commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), in->code);\n\n    //  complete the hash and get the results\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    // update commandCode value in session context\n    session->commandCode = in->code;\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyCommandCode\n\n\n#include \"Tpm.h\"\n#include \"PolicyCpHash_fp.h\"\n\n#if CC_PolicyCpHash  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Add a cpHash restriction to the policyDigest\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_CPHASH           cpHash of 'policySession' has previously been set\n//                              to a different value\n//      TPM_RC_SIZE             'cpHashA' is not the size of a digest produced\n//                              by the hash algorithm associated with\n//                              'policySession'\nTPM_RC\nTPM2_PolicyCpHash(PolicyCpHash_In* in  // IN: input parameter list\n\t\t  )\n{\n    SESSION*   session;\n    TPM_CC     commandCode = TPM_CC_PolicyCpHash;\n    HASH_STATE hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyCpHash: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // A valid cpHash must have the same size as session hash digest\n    // NOTE: the size of the digest can't be zero because TPM_ALG_NULL\n    // can't be used for the authHashAlg.\n    if(in->cpHashA.t.size != CryptHashGetDigestSize(session->authHashAlg))\n\treturn TPM_RCS_SIZE + RC_PolicyCpHash_cpHashA;\n\n    // error if the cpHash in session context is not empty and is not the same\n    // as the input or is not a cpHash\n    if((IsCpHashUnionOccupied(session->attributes))\n       && (!session->attributes.isCpHashDefined\n\t   || !MemoryEqual2B(&in->cpHashA.b, &session->u1.cpHash.b)))\n\treturn TPM_RC_CPHASH;\n\n    // Internal Data Update\n\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyCpHash || cpHashA)\n    //  Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add cpHashA\n    CryptDigestUpdate2B(&hashState, &in->cpHashA.b);\n\n    //  complete the digest and get the results\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    // update cpHash in session context\n    session->u1.cpHash                  = in->cpHashA;\n    session->attributes.isCpHashDefined = SET;\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyCpHash\n\n\n#include \"Tpm.h\"\n#include \"PolicyNameHash_fp.h\"\n\n#if CC_PolicyNameHash  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Add a nameHash restriction to the policyDigest\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_CPHASH     'nameHash' has been previously set to a different value\n//      TPM_RC_SIZE       'nameHash' is not the size of the digest produced by the\n//                        hash algorithm associated with 'policySession'\nTPM_RC\nTPM2_PolicyNameHash(PolicyNameHash_In* in  // IN: input parameter list\n\t\t    )\n{\n    SESSION*   session;\n    TPM_CC     commandCode = TPM_CC_PolicyNameHash;\n    HASH_STATE hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyNameHash: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // A valid nameHash must have the same size as session hash digest\n    // Since the authHashAlg for a session cannot be TPM_ALG_NULL, the digest size\n    // is always non-zero.\n    if(in->nameHash.t.size != CryptHashGetDigestSize(session->authHashAlg))\n\treturn TPM_RCS_SIZE + RC_PolicyNameHash_nameHash;\n\n    // error if the nameHash in session context is not empty\n    if(IsCpHashUnionOccupied(session->attributes))\n\treturn TPM_RC_CPHASH;\n\n    // Internal Data Update\n\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyNameHash || nameHash)\n    //  Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add nameHash\n    CryptDigestUpdate2B(&hashState, &in->nameHash.b);\n\n    //  complete the digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    // update nameHash in session context\n    session->u1.nameHash                  = in->nameHash;\n    session->attributes.isNameHashDefined = SET;\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyNameHash\n\n\n#include \"Tpm.h\"\n#include \"PolicyDuplicationSelect_fp.h\"\n\n#if CC_PolicyDuplicationSelect  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// allows qualification of duplication so that it a specific new parent may be\n// selected or a new parent selected for a specific object.\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_COMMAND_CODE   'commandCode' of 'policySession' is not empty\n//      TPM_RC_CPHASH         'nameHash' of 'policySession' is not empty\nTPM_RC\nTPM2_PolicyDuplicationSelect(\n\t\t\t     PolicyDuplicationSelect_In* in  // IN: input parameter list\n\t\t\t     )\n{\n    SESSION*   session;\n    HASH_STATE hashState;\n    TPM_CC     commandCode = TPM_CC_PolicyDuplicationSelect;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyDuplicationSelect: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // nameHash in session context must be empty\n    if(session->u1.nameHash.t.size != 0)\n\treturn TPM_RC_CPHASH;\n\n    // commandCode in session context must be empty\n    if(session->commandCode != 0)\n\treturn TPM_RC_COMMAND_CODE;\n\n    // Internal Data Update\n\n    // Update name hash\n    session->u1.nameHash.t.size = CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add objectName\n    CryptDigestUpdate2B(&hashState, &in->objectName.b);\n\n    //  add new parent name\n    CryptDigestUpdate2B(&hashState, &in->newParentName.b);\n\n    //  complete hash\n    CryptHashEnd2B(&hashState, &session->u1.nameHash.b);\n    session->attributes.isNameHashDefined = SET;\n\n    // update policy hash\n    // Old policyDigest size should be the same as the new policyDigest size since\n    // they are using the same hash algorithm\n    session->u2.policyDigest.t.size =\n\tCryptHashStart(&hashState, session->authHashAlg);\n    //  add old policy\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add command code\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add objectName\n    if(in->includeObject == YES)\n\tCryptDigestUpdate2B(&hashState, &in->objectName.b);\n\n    //  add new parent name\n    CryptDigestUpdate2B(&hashState, &in->newParentName.b);\n\n    //  add includeObject\n    CryptDigestUpdateInt(&hashState, sizeof(TPMI_YES_NO), in->includeObject);\n\n    //  complete digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    // set commandCode in session context\n    session->commandCode = TPM_CC_Duplicate;\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyDuplicationSelect\n\n\n#include \"Tpm.h\"\n#include \"PolicyAuthorize_fp.h\"\n\n#if CC_PolicyAuthorize  // Conditional expansion of this file\n\n#  include \"Policy_spt_fp.h\"\n\n/*(See part 3 specification)\n// Change policy by a signature from authority\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_HASH         hash algorithm in 'keyName' is not supported\n//      TPM_RC_SIZE         'keyName' is not the correct size for its hash algorithm\n//      TPM_RC_VALUE        the current policyDigest of 'policySession' does not\n//                          match 'approvedPolicy'; or 'checkTicket' doesn't match\n//                          the provided values\nTPM_RC\nTPM2_PolicyAuthorize(PolicyAuthorize_In* in  // IN: input parameter list\n\t\t     )\n{\n    TPM_RC           result = TPM_RC_SUCCESS;\n    SESSION*         session;\n    TPM2B_DIGEST     authHash;\n    HASH_STATE       hashState;\n    TPMT_TK_VERIFIED ticket;\n    TPM_ALG_ID       hashAlg;\n    UINT16           digestSize;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyAuthorize: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    if(in->keySign.t.size < 2)\n\t{\n\t    return TPM_RCS_SIZE + RC_PolicyAuthorize_keySign;\n\t}\n\n    // Extract from the Name of the key, the algorithm used to compute its Name\n    hashAlg = BYTE_ARRAY_TO_UINT16(in->keySign.t.name);\n\n    // 'keySign' parameter needs to use a supported hash algorithm, otherwise\n    // can't tell how large the digest should be\n    if(!CryptHashIsValidAlg(hashAlg, FALSE))\n\treturn TPM_RCS_HASH + RC_PolicyAuthorize_keySign;\n\n    digestSize = CryptHashGetDigestSize(hashAlg);\n    if(digestSize != (in->keySign.t.size - 2))\n\treturn TPM_RCS_SIZE + RC_PolicyAuthorize_keySign;\n\n    //If this is a trial policy, skip all validations\n    if(session->attributes.isTrialPolicy == CLEAR)\n\t{\n\t    // Check that \"approvedPolicy\" matches the current value of the\n\t    // policyDigest in policy session\n\t    if(!MemoryEqual2B(&session->u2.policyDigest.b, &in->approvedPolicy.b))\n\t\treturn TPM_RCS_VALUE + RC_PolicyAuthorize_approvedPolicy;\n\n\t    // Validate ticket TPMT_TK_VERIFIED\n\t    // Compute aHash.  The authorizing object sign a digest\n\t    //  aHash := hash(approvedPolicy || policyRef).\n\t    // Start hash\n\t    authHash.t.size = CryptHashStart(&hashState, hashAlg);\n\n\t    // add approvedPolicy\n\t    CryptDigestUpdate2B(&hashState, &in->approvedPolicy.b);\n\n\t    // add policyRef\n\t    CryptDigestUpdate2B(&hashState, &in->policyRef.b);\n\n\t    // complete hash\n\t    CryptHashEnd2B(&hashState, &authHash.b);\n\n\t    // re-compute TPMT_TK_VERIFIED\n\t    result = TicketComputeVerified(in->checkTicket.hierarchy, &authHash,\n\t\t\t\t\t   &in->keySign, &ticket);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\n\t    // Compare ticket digest.  If not match, return error\n\t    if(!MemoryEqual2B(&in->checkTicket.digest.b, &ticket.digest.b))\n\t\treturn TPM_RCS_VALUE + RC_PolicyAuthorize_checkTicket;\n\t}\n\n    // Internal Data Update\n\n    // Set policyDigest to zero digest\n    PolicyDigestClear(session);\n\n    // Update policyDigest\n    PolicyContextUpdate(\n\t\t\tTPM_CC_PolicyAuthorize, &in->keySign, &in->policyRef, NULL, 0, session);\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyAuthorize\n\n\n#include \"Tpm.h\"\n#include \"PolicyAuthValue_fp.h\"\n\n#if CC_PolicyAuthValue  // Conditional expansion of this file\n\n#  include \"Policy_spt_fp.h\"\n\n/*(See part 3 specification)\n// allows a policy to be bound to the authorization value of the authorized\n// object\n*/\nTPM_RC\nTPM2_PolicyAuthValue(PolicyAuthValue_In* in  // IN: input parameter list\n\t\t     )\n{\n    SESSION*   session;\n    TPM_CC     commandCode = TPM_CC_PolicyAuthValue;\n    HASH_STATE hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyAuthValue: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Internal Data Update\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyAuthValue)\n    //   Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  complete the hash and get the results\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    // update isAuthValueNeeded bit in the session context\n    session->attributes.isAuthValueNeeded = SET;\n    session->attributes.isPasswordNeeded  = CLEAR;\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyAuthValue\n\n\n#include \"Tpm.h\"\n#include \"PolicyPassword_fp.h\"\n\n#if CC_PolicyPassword  // Conditional expansion of this file\n\n#  include \"Policy_spt_fp.h\"\n\n/*(See part 3 specification)\n// allows a policy to be bound to the authorization value of the authorized\n// object\n*/\nTPM_RC\nTPM2_PolicyPassword(PolicyPassword_In* in  // IN: input parameter list\n\t\t    )\n{\n    SESSION*   session;\n    TPM_CC     commandCode = TPM_CC_PolicyAuthValue;\n    HASH_STATE hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyPassword: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Internal Data Update\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyAuthValue)\n    //  Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  complete the digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    //  Update isPasswordNeeded bit\n    session->attributes.isPasswordNeeded  = SET;\n    session->attributes.isAuthValueNeeded = CLEAR;\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyPassword\n\n\n#include \"Tpm.h\"\n#include \"PolicyGetDigest_fp.h\"\n#if CC_PolicyGetDigest  // Conditional expansion of this file\nTPM_RC\nTPM2_PolicyGetDigest(\n\t\t     PolicyGetDigest_In      *in,            // IN: input parameter list\n\t\t     PolicyGetDigest_Out     *out            // OUT: output parameter list\n\t\t     )\n{\n    SESSION     *session;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyGetDigest: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Command Output\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n    out->policyDigest = session->u2.policyDigest;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PolicyGetDigest\n\n#include \"Tpm.h\"\n#include \"PolicyNvWritten_fp.h\"\n\n#if CC_PolicyNvWritten  // Conditional expansion of this file\n\n// Make an NV Index policy dependent on the state of the TPMA_NV_WRITTEN\n// attribute of the index.\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE         a conflicting request for the attribute has\n//                           already been processed\nTPM_RC\nTPM2_PolicyNvWritten(PolicyNvWritten_In* in  // IN: input parameter list\n\t\t     )\n{\n    SESSION*   session;\n    TPM_CC     commandCode = TPM_CC_PolicyNvWritten;\n    HASH_STATE hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyNvWritten: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // If already set is this a duplicate (the same setting)? If it\n    // is a conflicting setting, it is an error\n    if(session->attributes.checkNvWritten == SET)\n\t{\n\t    if(((session->attributes.nvWrittenState == SET) != (in->writtenSet == YES)))\n\t\treturn TPM_RCS_VALUE + RC_PolicyNvWritten_writtenSet;\n\t}\n\n    // Internal Data Update\n\n    // Set session attributes so that the NV Index needs to be checked\n    session->attributes.checkNvWritten = SET;\n    session->attributes.nvWrittenState = (in->writtenSet == YES);\n\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyNvWritten\n    //                          || writtenSet)\n    // Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    // add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    // add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    // add the byte of writtenState\n    CryptDigestUpdateInt(&hashState, sizeof(TPMI_YES_NO), in->writtenSet);\n\n    // complete the digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyNvWritten\n\n#include \"Tpm.h\"\n#include \"PolicyTemplate_fp.h\"\n\n#if CC_PolicyTemplate  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Add a cpHash restriction to the policyDigest\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_CPHASH           cpHash of 'policySession' has previously been set\n//                              to a different value\n//      TPM_RC_SIZE             'templateHash' is not the size of a digest produced\n//                              by the hash algorithm associated with\n//                              'policySession'\nTPM_RC\nTPM2_PolicyTemplate(PolicyTemplate_In* in  // IN: input parameter list\n\t\t    )\n{\n    SESSION*   session;\n    TPM_CC     commandCode = TPM_CC_PolicyTemplate;\n    HASH_STATE hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyTemplate: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // error if the templateHash in session context is not empty and is not the\n    // same as the input or is not a template\n    if((IsCpHashUnionOccupied(session->attributes))\n       && (!session->attributes.isTemplateHashDefined\n\t   || !MemoryEqual2B(&in->templateHash.b, &session->u1.templateHash.b)))\n\treturn TPM_RC_CPHASH;\n\n    // A valid templateHash must have the same size as session hash digest\n    if(in->templateHash.t.size != CryptHashGetDigestSize(session->authHashAlg))\n\treturn TPM_RCS_SIZE + RC_PolicyTemplate_templateHash;\n\n    // Internal Data Update\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyCpHash\n    //  || cpHashA.buffer)\n    //  Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add cpHashA\n    CryptDigestUpdate2B(&hashState, &in->templateHash.b);\n\n    //  complete the digest and get the results\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    // update templateHash in session context\n    session->u1.templateHash                  = in->templateHash;\n    session->attributes.isTemplateHashDefined = SET;\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyTemplate\n\n#include \"Tpm.h\"\n\n#if CC_PolicyAuthorizeNV  // Conditional expansion of this file\n\n#  include \"PolicyAuthorizeNV_fp.h\"\n#  include \"Policy_spt_fp.h\"\n#  include \"Marshal.h\"\n\n/*(See part 3 specification)\n// Change policy by a signature from authority\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_HASH         hash algorithm in 'keyName' is not supported or is not\n//                          the same as the hash algorithm of the policy session\n//      TPM_RC_SIZE         'keyName' is not the correct size for its hash algorithm\n//      TPM_RC_VALUE        the current policyDigest of 'policySession' does not\n//                          match 'approvedPolicy'; or 'checkTicket' doesn't match\n//                          the provided values\nTPM_RC\nTPM2_PolicyAuthorizeNV(PolicyAuthorizeNV_In* in)\n{\n    SESSION*   session;\n    TPM_RC     result;\n    NV_REF     locator;\n    NV_INDEX*  nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n    TPM2B_NAME name;\n    TPMT_HA    policyInNv;\n    BYTE       nvTemp[sizeof(TPMT_HA)];\n    BYTE*      buffer = nvTemp;\n    INT32      size;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyAuthorizeNV: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_PolicyAuthorizeNV: nvIndex %08x\\n\", in->nvIndex);\n\t// fprintf(f, \"TPM2_PolicyAuthorizeNV: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // Skip checks if this is a trial policy\n    if(!session->attributes.isTrialPolicy)\n\t{\n\t    // Check the authorizations for reading\n\t    // Common read access checks. NvReadAccessChecks() returns\n\t    // TPM_RC_NV_AUTHORIZATION, TPM_RC_NV_LOCKED, or TPM_RC_NV_UNINITIALIZED\n\t    // error may be returned at this point\n\t    result = NvReadAccessChecks(\n\t\t\t\t\tin->authHandle, in->nvIndex, nvIndex->publicArea.attributes);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\n\t    // Read the contents of the index into a temp buffer\n\t    size = MIN(nvIndex->publicArea.dataSize, sizeof(TPMT_HA));\n\t    NvGetIndexData(nvIndex, locator, 0, (UINT16)size, nvTemp);\n\n\t    // Unmarshal the contents of the buffer into the internal format of a\n\t    // TPMT_HA so that the hash and digest elements can be accessed from the\n\t    // structure rather than the byte array that is in the Index (written by\n\t    // user of the Index).\n\t    result = TPMT_HA_Unmarshal(&policyInNv, &buffer, &size, FALSE);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\n\t    // Verify that the hash is the same\n\t    if(policyInNv.hashAlg != session->authHashAlg)\n\t\treturn TPM_RC_HASH;\n\n\t    // See if the contents of the digest in the Index matches the value\n\t    // in the policy\n\t    if(!MemoryEqual(&policyInNv.digest,\n\t\t\t    &session->u2.policyDigest.t.buffer,\n\t\t\t    session->u2.policyDigest.t.size))\n\t\treturn TPM_RC_VALUE;\n\t}\n\n    // Internal Data Update\n\n    // Set policyDigest to zero digest\n    PolicyDigestClear(session);\n\n    // Update policyDigest\n    PolicyContextUpdate(TPM_CC_PolicyAuthorizeNV,\n\t\t\tEntityGetName(in->nvIndex, &name),\n\t\t\tNULL,\n\t\t\tNULL,\n\t\t\t0,\n\t\t\tsession);\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyAuthorizeNV\n\n#include \"Tpm.h\"\n#include \"PolicyCapability_fp.h\"\n#include \"Policy_spt_fp.h\"\n#include \"ACT_spt_fp.h\"\n#include \"AlgorithmCap_fp.h\"\n#include \"CommandAudit_fp.h\"\n#include \"CommandCodeAttributes_fp.h\"\n#include \"CryptEccMain_fp.h\"\n#include \"Handle_fp.h\"\n#include \"NVDynamic_fp.h\"\n#include \"Object_fp.h\"\n#include \"PCR_fp.h\"\n#include \"PP_fp.h\"\n#include \"PropertyCap_fp.h\"\n#include \"Session_fp.h\"\n\n#if CC_PolicyCapability  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// This command performs an immediate policy assertion against the current\n// value of a TPM Capability.\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_HANDLE       value of 'property' is in an unsupported handle range\n//                          for the TPM_CAP_HANDLES 'capability' value\n//      TPM_RC_VALUE        invalid 'capability'; or 'property' is not 0 for the\n//                          TPM_CAP_PCRS 'capability' value\n//      TPM_RC_SIZE         'operandB' is larger than the size of the capability\n//                          data minus 'offset'.\nTPM_RC\nTPM2_PolicyCapability(PolicyCapability_In* in  // IN: input parameter list\n\t\t      )\n{\n    union\n    {\n\tTPMS_ALG_PROPERTY      alg;\n\tTPM_HANDLE             handle;\n\tTPMA_CC                commandAttributes;\n\tTPM_CC                 command;\n\tTPMS_TAGGED_PCR_SELECT pcrSelect;\n\tTPMS_TAGGED_PROPERTY   tpmProperty;\n#  if ALG_ECC\n\tTPM_ECC_CURVE curve;\n#  endif  // ALG_ECC\n\tTPMS_TAGGED_POLICY policy;\n#  if ACT_SUPPORT\n\tTPMS_ACT_DATA act;\n#  endif  // ACT_SUPPORT\n    } propertyUnion;\n\n    SESSION*     session;\n    BYTE         propertyData[sizeof(propertyUnion)];\n    UINT16       propertySize = 0;\n    BYTE*        buffer       = propertyData;\n    INT32        bufferSize   = sizeof(propertyData);\n    TPM_CC       commandCode  = TPM_CC_PolicyCapability;\n    HASH_STATE   hashState;\n    TPM2B_DIGEST argHash;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyCapability: policySession %08x\\n\", in->policySession );\n\t// fclose(f);\n  //   }\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    if(session->attributes.isTrialPolicy == CLEAR)\n\t{\n\t    switch(in->capability)\n\t\t{\n\t\t  case TPM_CAP_ALGS:\n\t\t    if(AlgorithmCapGetOneImplemented((TPM_ALG_ID)in->property,\n\t\t\t\t\t\t     &propertyUnion.alg))\n\t\t\t{\n\t\t\t    propertySize = TPMS_ALG_PROPERTY_Marshal\n\t\t\t\t\t   (&propertyUnion.alg, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n\t\t  case TPM_CAP_HANDLES: ;\n\t\t    BOOL foundHandle = FALSE;\n\t\t    switch(HandleGetType((TPM_HANDLE)in->property))\n\t\t\t{\n\t\t\t  case TPM_HT_TRANSIENT:\n\t\t\t    foundHandle = ObjectCapGetOneLoaded((TPM_HANDLE)in->property);\n\t\t\t    break;\n\t\t\t  case TPM_HT_PERSISTENT:\n\t\t\t    foundHandle = NvCapGetOnePersistent((TPM_HANDLE)in->property);\n\t\t\t    break;\n\t\t\t  case TPM_HT_NV_INDEX:\n\t\t\t    foundHandle = NvCapGetOneIndex((TPM_HANDLE)in->property);\n\t\t\t    break;\n\t\t\t  case TPM_HT_LOADED_SESSION:\n\t\t\t    foundHandle =\n\t\t\t\tSessionCapGetOneLoaded((TPM_HANDLE)in->property);\n\t\t\t    break;\n\t\t\t  case TPM_HT_SAVED_SESSION:\n\t\t\t    foundHandle = SessionCapGetOneSaved((TPM_HANDLE)in->property);\n\t\t\t    break;\n\t\t\t  case TPM_HT_PCR:\n\t\t\t    foundHandle = PCRCapGetOneHandle((TPM_HANDLE)in->property);\n\t\t\t    break;\n\t\t\t  case TPM_HT_PERMANENT:\n\t\t\t    foundHandle =\n\t\t\t\tPermanentCapGetOneHandle((TPM_HANDLE)in->property);\n\t\t\t    break;\n\t\t\t  default:\n\t\t\t    // Unsupported input handle type\n\t\t\t    return TPM_RCS_HANDLE + RC_PolicyCapability_property;\n\t\t\t    break;\n\t\t\t}\n\t\t    if(foundHandle)\n\t\t\t{\n\t\t\t    TPM_HANDLE handle = (TPM_HANDLE)in->property;\n\t\t\t    propertySize = TPM_HANDLE_Marshal(&handle, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n\t\t  case TPM_CAP_COMMANDS:\n\t\t    if(CommandCapGetOneCC((TPM_CC)in->property,\n\t\t\t\t\t  &propertyUnion.commandAttributes))\n\t\t\t{\n\t\t\t    propertySize = TPMA_CC_Marshal\n\t\t\t\t\t   (&propertyUnion.commandAttributes, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n\t\t  case TPM_CAP_PP_COMMANDS:\n\t\t    if(PhysicalPresenceCapGetOneCC((TPM_CC)in->property))\n\t\t\t{\n\t\t\t    TPM_CC cc    = (TPM_CC)in->property;\n\t\t\t    propertySize = TPM_CC_Marshal(&cc, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n\t\t  case TPM_CAP_AUDIT_COMMANDS:\n\t\t    if(CommandAuditCapGetOneCC((TPM_CC)in->property))\n\t\t\t{\n\t\t\t    TPM_CC cc    = (TPM_CC)in->property;\n\t\t\t    propertySize = TPM_CC_Marshal(&cc, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n\t\t    // NOTE: TPM_CAP_PCRS can't work for PolicyCapability since CAP_PCRS\n\t\t    // requires property to be 0 and always returns all the PCR banks.\n\t\t  case TPM_CAP_PCR_PROPERTIES:\n\t\t    if(PCRGetProperty((TPM_PT_PCR)in->property, &propertyUnion.pcrSelect))\n\t\t\t{\n\t\t\t    propertySize = TPMS_TAGGED_PCR_SELECT_Marshal\n\t\t\t\t\t   (&propertyUnion.pcrSelect, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n\t\t  case TPM_CAP_TPM_PROPERTIES:\n\t\t    if(TPMCapGetOneProperty((TPM_PT)in->property,\n\t\t\t\t\t    &propertyUnion.tpmProperty))\n\t\t\t{\n\t\t\t    propertySize = TPMS_TAGGED_PROPERTY_Marshal\n\t\t\t\t\t   (&propertyUnion.tpmProperty, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n#  if ALG_ECC\n\t\t  case TPM_CAP_ECC_CURVES: ;\n\t\t    TPM_ECC_CURVE curve = (TPM_ECC_CURVE)in->property;\n\t\t    if(CryptCapGetOneECCCurve(curve))\n\t\t\t{\n\t\t\t    propertySize =\n\t\t\t\tTPM_ECC_CURVE_Marshal(&curve, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n#  endif  // ALG_ECC\n\t\t  case TPM_CAP_AUTH_POLICIES:\n\t\t    if(HandleGetType((TPM_HANDLE)in->property) != TPM_HT_PERMANENT)\n\t\t\treturn TPM_RCS_VALUE + RC_PolicyCapability_property;\n\t\t    if(PermanentHandleGetOnePolicy((TPM_HANDLE)in->property,\n\t\t\t\t\t\t   &propertyUnion.policy))\n\t\t\t{\n\t\t\t    propertySize = TPMS_TAGGED_POLICY_Marshal\n\t\t\t\t\t   (&propertyUnion.policy, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n#  if ACT_SUPPORT\n\t\t  case TPM_CAP_ACT:\n\t\t    if(((TPM_RH)in->property < TPM_RH_ACT_0)\n\t\t       || ((TPM_RH)in->property > TPM_RH_ACT_F))\n\t\t\treturn TPM_RCS_VALUE + RC_PolicyCapability_property;\n\t\t    if(ActGetOneCapability((TPM_HANDLE)in->property, &propertyUnion.act))\n\t\t\t{\n\t\t\t    propertySize = TPMS_ACT_DATA_Marshal\n\t\t\t\t\t   (&propertyUnion.act, &buffer, &bufferSize);\n\t\t\t}\n\t\t    break;\n#  endif  // ACT_SUPPORT\n\t\t  case TPM_CAP_VENDOR_PROPERTY:\n\t\t    // vendor property is not implemented\n\t\t  default:\n\t\t    // Unsupported TPM_CAP value\n\t\t    return TPM_RCS_VALUE + RC_PolicyCapability_capability;\n\t\t    break;\n\t\t}\n\n\t    if(propertySize == 0)\n\t\t{\n\t\t    // A property that doesn't exist trivially satisfies NEQ, and\n\t\t    // trivially can't satisfy any other operation.\n\t\t    if(in->operation != TPM_EO_NEQ)\n\t\t\t{\n\t\t\t    return TPM_RC_POLICY;\n\t\t\t}\n\t\t}\n\t    else\n\t\t{\n\t\t    // The property was found, so we need to perform the comparison.\n\n\t\t    // Make sure that offset is within range\n\t\t    if(in->offset > propertySize)\n\t\t\t{\n\t\t\t    return TPM_RCS_VALUE + RC_PolicyCapability_offset;\n\t\t\t}\n\n\t\t    // Property data size should not be smaller than input operandB size\n\t\t    if((propertySize - in->offset) < in->operandB.t.size)\n\t\t\t{\n\t\t\t    return TPM_RCS_SIZE + RC_PolicyCapability_operandB;\n\t\t\t}\n\n\t\t    if(!PolicySptCheckCondition(in->operation,\n\t\t\t\t\t\tpropertyData + in->offset,\n\t\t\t\t\t\tin->operandB.t.buffer,\n\t\t\t\t\t\tin->operandB.t.size))\n\t\t\t{\n\t\t\t    return TPM_RC_POLICY;\n\t\t\t}\n\t\t}\n\t}\n    // Internal Data Update\n\n    // Start argument hash\n    argHash.t.size = CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add operandB\n    CryptDigestUpdate2B(&hashState, &in->operandB.b);\n\n    //  add offset\n    CryptDigestUpdateInt(&hashState, sizeof(UINT16), in->offset);\n\n    //  add operation\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_EO), in->operation);\n\n    //  add capability\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CAP), in->capability);\n\n    //  add property\n    CryptDigestUpdateInt(&hashState, sizeof(UINT32), in->property);\n\n    //  complete argument digest\n    CryptHashEnd2B(&hashState, &argHash.b);\n\n    // Update policyDigest\n    //  Start digest\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add argument digest\n    CryptDigestUpdate2B(&hashState, &argHash.b);\n\n    // complete the digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyCapability\n\n#include \"Tpm.h\"\n#include \"PolicyParameters_fp.h\"\n\n#if CC_PolicyParameters  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Add a parameters restriction to the policyDigest\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_CPHASH     cpHash of 'policySession' has previously been set\n//                        to a different value\n//      TPM_RC_SIZE       'pHash' is not the size of the digest produced by the\n//                        hash algorithm associated with 'policySession'\nTPM_RC\nTPM2_PolicyParameters(PolicyParameters_In* in  // IN: input parameter list\n\t\t      )\n{\n    SESSION*   session;\n    TPM_CC     commandCode = TPM_CC_PolicyParameters;\n    HASH_STATE hashState;\n\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyParameters: policySession %08x\\n\", in->policySession);\n\t// fclose(f);\n  //   }\n    // Input Validation\n\n    // Get pointer to the session structure\n    session = SessionGet(in->policySession);\n\n    // A valid pHash must have the same size as session hash digest\n    // Since the authHashAlg for a session cannot be TPM_ALG_NULL, the digest size\n    // is always non-zero.\n    if(in->pHash.t.size != CryptHashGetDigestSize(session->authHashAlg))\n\treturn TPM_RCS_SIZE + RC_PolicyParameters_pHash;\n\n    // error if the pHash in session context is not empty\n    if(IsCpHashUnionOccupied(session->attributes))\n\treturn TPM_RC_CPHASH;\n\n    // Internal Data Update\n\n    // Update policy hash\n    // policyDigestnew = hash(policyDigestold || TPM_CC_PolicyParameters || pHash)\n    //  Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n\n    //  add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\n    //  add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), commandCode);\n\n    //  add pHash\n    CryptDigestUpdate2B(&hashState, &in->pHash.b);\n\n    //  complete the digest\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\n    // update pHash in session context\n    session->u1.pHash                           = in->pHash;\n    session->attributes.isParametersHashDefined = SET;\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_PolicyParameters\n"
  },
  {
    "path": "ftpm-opensbi/src/EccConstantData.inl",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* Microsoft Reference Implementation for TPM 2.0\n *\n *  The copyright in this software is being made available under the BSD License,\n *  included below. This software may be subject to other third party and\n *  contributor rights, including patent rights, and no such rights are granted\n *  under this license.\n *\n *  Copyright (c) Microsoft Corporation\n *\n *  All rights reserved.\n *\n *  BSD License\n *\n *  Redistribution and use in source and binary forms, with or without modification,\n *  are permitted provided that the following conditions are met:\n *\n *  Redistributions of source code must retain the above copyright notice, this list\n *  of conditions and the following disclaimer.\n *\n *  Redistributions in binary form must reproduce the above copyright notice, this\n *  list of conditions and the following disclaimer in the documentation and/or\n *  other materials provided with the distribution.\n *\n *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"\"AS IS\"\"\n *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\n *  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n// This file contains the ECC curve data. The data is contained in macros so this\n// file can be included in other format-specific header files that reformat the\n// constant data in any format desired. This file itself is never used alone.\n\n// Expected macros:\n//\n// TO_ECC_<bits>:\n//      <bits> <= 64:\n//          \"N\" byte arguments in most-significant to least-significant order The number\n//          of arguments depends on the bit length, which must be a multiple of 8.\n//      <bits> > 64:\n//          \"Q\" macro arguments from the <bits> <= 64 group to produce the total number\n//          of requested bits.\n//\n// ECC_CONST:\n//      Parameters:\n//          Name, Bytes, initial value; either a single byte value or a combination of TO_ECC macros\n\n#if ALG_ECC\n\nECC_CONST(ECC_ZERO, 1, 0);\nECC_CONST(ECC_ONE, 1, 1);\n\n#  if ECC_NIST_P192\nECC_CONST(NIST_P192_p,\n          24,\n          TO_ECC_192(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF)));\nECC_CONST(NIST_P192_a,\n          24,\n          TO_ECC_192(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC)));\nECC_CONST(NIST_P192_b,\n          24,\n          TO_ECC_192(TO_ECC_64(0x64, 0x21, 0x05, 0x19, 0xE5, 0x9C, 0x80, 0xE7),\n                     TO_ECC_64(0x0F, 0xA7, 0xE9, 0xAB, 0x72, 0x24, 0x30, 0x49),\n                     TO_ECC_64(0xFE, 0xB8, 0xDE, 0xEC, 0xC1, 0x46, 0xB9, 0xB1)));\nECC_CONST(NIST_P192_gX,\n          24,\n          TO_ECC_192(TO_ECC_64(0x18, 0x8D, 0xA8, 0x0E, 0xB0, 0x30, 0x90, 0xF6),\n                     TO_ECC_64(0x7C, 0xBF, 0x20, 0xEB, 0x43, 0xA1, 0x88, 0x00),\n                     TO_ECC_64(0xF4, 0xFF, 0x0A, 0xFD, 0x82, 0xFF, 0x10, 0x12)));\nECC_CONST(NIST_P192_gY,\n          24,\n          TO_ECC_192(TO_ECC_64(0x07, 0x19, 0x2B, 0x95, 0xFF, 0xC8, 0xDA, 0x78),\n                     TO_ECC_64(0x63, 0x10, 0x11, 0xED, 0x6B, 0x24, 0xCD, 0xD5),\n                     TO_ECC_64(0x73, 0xF9, 0x77, 0xA1, 0x1E, 0x79, 0x48, 0x11)));\nECC_CONST(NIST_P192_n,\n          24,\n          TO_ECC_192(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0x99, 0xDE, 0xF8, 0x36),\n                     TO_ECC_64(0x14, 0x6B, 0xC9, 0xB1, 0xB4, 0xD2, 0x28, 0x31)));\n#    define NIST_P192_h  ECC_ONE\n#    define NIST_P192_gZ ECC_ONE\n\n#  endif  // ECC_NIST_P192\n\n#  if ECC_NIST_P224\nECC_CONST(NIST_P224_p,\n          28,\n          TO_ECC_224(TO_ECC_32(0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01)));\nECC_CONST(NIST_P224_a,\n          28,\n          TO_ECC_224(TO_ECC_32(0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE)));\nECC_CONST(NIST_P224_b,\n          28,\n          TO_ECC_224(TO_ECC_32(0xB4, 0x05, 0x0A, 0x85),\n                     TO_ECC_64(0x0C, 0x04, 0xB3, 0xAB, 0xF5, 0x41, 0x32, 0x56),\n                     TO_ECC_64(0x50, 0x44, 0xB0, 0xB7, 0xD7, 0xBF, 0xD8, 0xBA),\n                     TO_ECC_64(0x27, 0x0B, 0x39, 0x43, 0x23, 0x55, 0xFF, 0xB4)));\nECC_CONST(NIST_P224_gX,\n          28,\n          TO_ECC_224(TO_ECC_32(0xB7, 0x0E, 0x0C, 0xBD),\n                     TO_ECC_64(0x6B, 0xB4, 0xBF, 0x7F, 0x32, 0x13, 0x90, 0xB9),\n                     TO_ECC_64(0x4A, 0x03, 0xC1, 0xD3, 0x56, 0xC2, 0x11, 0x22),\n                     TO_ECC_64(0x34, 0x32, 0x80, 0xD6, 0x11, 0x5C, 0x1D, 0x21)));\nECC_CONST(NIST_P224_gY,\n          28,\n          TO_ECC_224(TO_ECC_32(0xBD, 0x37, 0x63, 0x88),\n                     TO_ECC_64(0xB5, 0xF7, 0x23, 0xFB, 0x4C, 0x22, 0xDF, 0xE6),\n                     TO_ECC_64(0xCD, 0x43, 0x75, 0xA0, 0x5A, 0x07, 0x47, 0x64),\n                     TO_ECC_64(0x44, 0xD5, 0x81, 0x99, 0x85, 0x00, 0x7E, 0x34)));\nECC_CONST(NIST_P224_n,\n          28,\n          TO_ECC_224(TO_ECC_32(0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0x16, 0xA2, 0xE0, 0xB8, 0xF0, 0x3E),\n                     TO_ECC_64(0x13, 0xDD, 0x29, 0x45, 0x5C, 0x5C, 0x2A, 0x3D)));\n#    define NIST_P224_h  ECC_ONE\n#    define NIST_P224_gZ ECC_ONE\n\n#  endif  // ECC_NIST_P224\n\n#  if ECC_NIST_P256\nECC_CONST(NIST_P256_p,\n          32,\n          TO_ECC_256(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF)));\nECC_CONST(NIST_P256_a,\n          32,\n          TO_ECC_256(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC)));\nECC_CONST(NIST_P256_b,\n          32,\n          TO_ECC_256(TO_ECC_64(0x5A, 0xC6, 0x35, 0xD8, 0xAA, 0x3A, 0x93, 0xE7),\n                     TO_ECC_64(0xB3, 0xEB, 0xBD, 0x55, 0x76, 0x98, 0x86, 0xBC),\n                     TO_ECC_64(0x65, 0x1D, 0x06, 0xB0, 0xCC, 0x53, 0xB0, 0xF6),\n                     TO_ECC_64(0x3B, 0xCE, 0x3C, 0x3E, 0x27, 0xD2, 0x60, 0x4B)));\nECC_CONST(NIST_P256_gX,\n          32,\n          TO_ECC_256(TO_ECC_64(0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 0x47),\n                     TO_ECC_64(0xF8, 0xBC, 0xE6, 0xE5, 0x63, 0xA4, 0x40, 0xF2),\n                     TO_ECC_64(0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 0xA0),\n                     TO_ECC_64(0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 0x96)));\nECC_CONST(NIST_P256_gY,\n          32,\n          TO_ECC_256(TO_ECC_64(0x4F, 0xE3, 0x42, 0xE2, 0xFE, 0x1A, 0x7F, 0x9B),\n                     TO_ECC_64(0x8E, 0xE7, 0xEB, 0x4A, 0x7C, 0x0F, 0x9E, 0x16),\n                     TO_ECC_64(0x2B, 0xCE, 0x33, 0x57, 0x6B, 0x31, 0x5E, 0xCE),\n                     TO_ECC_64(0xCB, 0xB6, 0x40, 0x68, 0x37, 0xBF, 0x51, 0xF5)));\nECC_CONST(NIST_P256_n,\n          32,\n          TO_ECC_256(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84),\n                     TO_ECC_64(0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51)));\n#    define NIST_P256_h  ECC_ONE\n#    define NIST_P256_gZ ECC_ONE\n\n#  endif  // ECC_NIST_P256\n\n#  if ECC_NIST_P384\nECC_CONST(NIST_P384_p,\n          48,\n          TO_ECC_384(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF)));\nECC_CONST(NIST_P384_a,\n          48,\n          TO_ECC_384(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFC)));\nECC_CONST(NIST_P384_b,\n          48,\n          TO_ECC_384(TO_ECC_64(0xB3, 0x31, 0x2F, 0xA7, 0xE2, 0x3E, 0xE7, 0xE4),\n                     TO_ECC_64(0x98, 0x8E, 0x05, 0x6B, 0xE3, 0xF8, 0x2D, 0x19),\n                     TO_ECC_64(0x18, 0x1D, 0x9C, 0x6E, 0xFE, 0x81, 0x41, 0x12),\n                     TO_ECC_64(0x03, 0x14, 0x08, 0x8F, 0x50, 0x13, 0x87, 0x5A),\n                     TO_ECC_64(0xC6, 0x56, 0x39, 0x8D, 0x8A, 0x2E, 0xD1, 0x9D),\n                     TO_ECC_64(0x2A, 0x85, 0xC8, 0xED, 0xD3, 0xEC, 0x2A, 0xEF)));\nECC_CONST(NIST_P384_gX,\n          48,\n          TO_ECC_384(TO_ECC_64(0xAA, 0x87, 0xCA, 0x22, 0xBE, 0x8B, 0x05, 0x37),\n                     TO_ECC_64(0x8E, 0xB1, 0xC7, 0x1E, 0xF3, 0x20, 0xAD, 0x74),\n                     TO_ECC_64(0x6E, 0x1D, 0x3B, 0x62, 0x8B, 0xA7, 0x9B, 0x98),\n                     TO_ECC_64(0x59, 0xF7, 0x41, 0xE0, 0x82, 0x54, 0x2A, 0x38),\n                     TO_ECC_64(0x55, 0x02, 0xF2, 0x5D, 0xBF, 0x55, 0x29, 0x6C),\n                     TO_ECC_64(0x3A, 0x54, 0x5E, 0x38, 0x72, 0x76, 0x0A, 0xB7)));\nECC_CONST(NIST_P384_gY,\n          48,\n          TO_ECC_384(TO_ECC_64(0x36, 0x17, 0xDE, 0x4A, 0x96, 0x26, 0x2C, 0x6F),\n                     TO_ECC_64(0x5D, 0x9E, 0x98, 0xBF, 0x92, 0x92, 0xDC, 0x29),\n                     TO_ECC_64(0xF8, 0xF4, 0x1D, 0xBD, 0x28, 0x9A, 0x14, 0x7C),\n                     TO_ECC_64(0xE9, 0xDA, 0x31, 0x13, 0xB5, 0xF0, 0xB8, 0xC0),\n                     TO_ECC_64(0x0A, 0x60, 0xB1, 0xCE, 0x1D, 0x7E, 0x81, 0x9D),\n                     TO_ECC_64(0x7A, 0x43, 0x1D, 0x7C, 0x90, 0xEA, 0x0E, 0x5F)));\nECC_CONST(NIST_P384_n,\n          48,\n          TO_ECC_384(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xC7, 0x63, 0x4D, 0x81, 0xF4, 0x37, 0x2D, 0xDF),\n                     TO_ECC_64(0x58, 0x1A, 0x0D, 0xB2, 0x48, 0xB0, 0xA7, 0x7A),\n                     TO_ECC_64(0xEC, 0xEC, 0x19, 0x6A, 0xCC, 0xC5, 0x29, 0x73)));\n#    define NIST_P384_h  ECC_ONE\n#    define NIST_P384_gZ ECC_ONE\n\n#  endif  // ECC_NIST_P384\n\n#  if ECC_NIST_P521\nECC_CONST(NIST_P521_p,\n          66,\n          TO_ECC_528(TO_ECC_16(0x01, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF)));\nECC_CONST(NIST_P521_a,\n          66,\n          TO_ECC_528(TO_ECC_16(0x01, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC)));\nECC_CONST(NIST_P521_b,\n          66,\n          TO_ECC_528(TO_ECC_16(0x00, 0x51),\n                     TO_ECC_64(0x95, 0x3E, 0xB9, 0x61, 0x8E, 0x1C, 0x9A, 0x1F),\n                     TO_ECC_64(0x92, 0x9A, 0x21, 0xA0, 0xB6, 0x85, 0x40, 0xEE),\n                     TO_ECC_64(0xA2, 0xDA, 0x72, 0x5B, 0x99, 0xB3, 0x15, 0xF3),\n                     TO_ECC_64(0xB8, 0xB4, 0x89, 0x91, 0x8E, 0xF1, 0x09, 0xE1),\n                     TO_ECC_64(0x56, 0x19, 0x39, 0x51, 0xEC, 0x7E, 0x93, 0x7B),\n                     TO_ECC_64(0x16, 0x52, 0xC0, 0xBD, 0x3B, 0xB1, 0xBF, 0x07),\n                     TO_ECC_64(0x35, 0x73, 0xDF, 0x88, 0x3D, 0x2C, 0x34, 0xF1),\n                     TO_ECC_64(0xEF, 0x45, 0x1F, 0xD4, 0x6B, 0x50, 0x3F, 0x00)));\nECC_CONST(NIST_P521_gX,\n          66,\n          TO_ECC_528(TO_ECC_16(0x00, 0xC6),\n                     TO_ECC_64(0x85, 0x8E, 0x06, 0xB7, 0x04, 0x04, 0xE9, 0xCD),\n                     TO_ECC_64(0x9E, 0x3E, 0xCB, 0x66, 0x23, 0x95, 0xB4, 0x42),\n                     TO_ECC_64(0x9C, 0x64, 0x81, 0x39, 0x05, 0x3F, 0xB5, 0x21),\n                     TO_ECC_64(0xF8, 0x28, 0xAF, 0x60, 0x6B, 0x4D, 0x3D, 0xBA),\n                     TO_ECC_64(0xA1, 0x4B, 0x5E, 0x77, 0xEF, 0xE7, 0x59, 0x28),\n                     TO_ECC_64(0xFE, 0x1D, 0xC1, 0x27, 0xA2, 0xFF, 0xA8, 0xDE),\n                     TO_ECC_64(0x33, 0x48, 0xB3, 0xC1, 0x85, 0x6A, 0x42, 0x9B),\n                     TO_ECC_64(0xF9, 0x7E, 0x7E, 0x31, 0xC2, 0xE5, 0xBD, 0x66)));\nECC_CONST(NIST_P521_gY,\n          66,\n          TO_ECC_528(TO_ECC_16(0x01, 0x18),\n                     TO_ECC_64(0x39, 0x29, 0x6A, 0x78, 0x9A, 0x3B, 0xC0, 0x04),\n                     TO_ECC_64(0x5C, 0x8A, 0x5F, 0xB4, 0x2C, 0x7D, 0x1B, 0xD9),\n                     TO_ECC_64(0x98, 0xF5, 0x44, 0x49, 0x57, 0x9B, 0x44, 0x68),\n                     TO_ECC_64(0x17, 0xAF, 0xBD, 0x17, 0x27, 0x3E, 0x66, 0x2C),\n                     TO_ECC_64(0x97, 0xEE, 0x72, 0x99, 0x5E, 0xF4, 0x26, 0x40),\n                     TO_ECC_64(0xC5, 0x50, 0xB9, 0x01, 0x3F, 0xAD, 0x07, 0x61),\n                     TO_ECC_64(0x35, 0x3C, 0x70, 0x86, 0xA2, 0x72, 0xC2, 0x40),\n                     TO_ECC_64(0x88, 0xBE, 0x94, 0x76, 0x9F, 0xD1, 0x66, 0x50)));\nECC_CONST(NIST_P521_n,\n          66,\n          TO_ECC_528(TO_ECC_16(0x01, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFA),\n                     TO_ECC_64(0x51, 0x86, 0x87, 0x83, 0xBF, 0x2F, 0x96, 0x6B),\n                     TO_ECC_64(0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09, 0xA5, 0xD0),\n                     TO_ECC_64(0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C, 0x47, 0xAE),\n                     TO_ECC_64(0xBB, 0x6F, 0xB7, 0x1E, 0x91, 0x38, 0x64, 0x09)));\n#    define NIST_P521_h  ECC_ONE\n#    define NIST_P521_gZ ECC_ONE\n\n#  endif  // ECC_NIST_P521\n\n#  if ECC_BN_P256\nECC_CONST(BN_P256_p,\n          32,\n          TO_ECC_256(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD),\n                     TO_ECC_64(0x46, 0xE5, 0xF2, 0x5E, 0xEE, 0x71, 0xA4, 0x9F),\n                     TO_ECC_64(0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x98, 0x0A, 0x82),\n                     TO_ECC_64(0xD3, 0x29, 0x2D, 0xDB, 0xAE, 0xD3, 0x30, 0x13)));\n#    define BN_P256_a ECC_ZERO\nECC_CONST(BN_P256_b, 1, TO_ECC_8(3));\n#    define BN_P256_gX ECC_ONE\nECC_CONST(BN_P256_gY, 1, TO_ECC_8(2));\nECC_CONST(BN_P256_n,\n          32,\n          TO_ECC_256(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xCD),\n                     TO_ECC_64(0x46, 0xE5, 0xF2, 0x5E, 0xEE, 0x71, 0xA4, 0x9E),\n                     TO_ECC_64(0x0C, 0xDC, 0x65, 0xFB, 0x12, 0x99, 0x92, 0x1A),\n                     TO_ECC_64(0xF6, 0x2D, 0x53, 0x6C, 0xD1, 0x0B, 0x50, 0x0D)));\n#    define BN_P256_h  ECC_ONE\n#    define BN_P256_gZ ECC_ONE\n\n#  endif  // ECC_BN_P256\n\n#  if ECC_BN_P638\nECC_CONST(BN_P638_p,\n          80,\n          TO_ECC_640(TO_ECC_64(0x23, 0xFF, 0xFF, 0xFD, 0xC0, 0x00, 0x00, 0x0D),\n                     TO_ECC_64(0x7F, 0xFF, 0xFF, 0xB8, 0x00, 0x00, 0x01, 0xD3),\n                     TO_ECC_64(0xFF, 0xFF, 0xF9, 0x42, 0xD0, 0x00, 0x16, 0x5E),\n                     TO_ECC_64(0x3F, 0xFF, 0x94, 0x87, 0x00, 0x00, 0xD5, 0x2F),\n                     TO_ECC_64(0xFF, 0xFD, 0xD0, 0xE0, 0x00, 0x08, 0xDE, 0x55),\n                     TO_ECC_64(0xC0, 0x00, 0x86, 0x52, 0x00, 0x21, 0xE5, 0x5B),\n                     TO_ECC_64(0xFF, 0xFF, 0xF5, 0x1F, 0xFF, 0xF4, 0xEB, 0x80),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x4C, 0x80, 0x01, 0x5A, 0xCD),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0xE0),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67)));\n#    define BN_P638_a ECC_ZERO\nECC_CONST(BN_P638_b, 2, TO_ECC_16(0x01, 0x01));\nECC_CONST(BN_P638_gX,\n          80,\n          TO_ECC_640(TO_ECC_64(0x23, 0xFF, 0xFF, 0xFD, 0xC0, 0x00, 0x00, 0x0D),\n                     TO_ECC_64(0x7F, 0xFF, 0xFF, 0xB8, 0x00, 0x00, 0x01, 0xD3),\n                     TO_ECC_64(0xFF, 0xFF, 0xF9, 0x42, 0xD0, 0x00, 0x16, 0x5E),\n                     TO_ECC_64(0x3F, 0xFF, 0x94, 0x87, 0x00, 0x00, 0xD5, 0x2F),\n                     TO_ECC_64(0xFF, 0xFD, 0xD0, 0xE0, 0x00, 0x08, 0xDE, 0x55),\n                     TO_ECC_64(0xC0, 0x00, 0x86, 0x52, 0x00, 0x21, 0xE5, 0x5B),\n                     TO_ECC_64(0xFF, 0xFF, 0xF5, 0x1F, 0xFF, 0xF4, 0xEB, 0x80),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x4C, 0x80, 0x01, 0x5A, 0xCD),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEC, 0xE0),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66)));\nECC_CONST(BN_P638_gY, 1, TO_ECC_8(0x10));\nECC_CONST(BN_P638_n,\n          80,\n          TO_ECC_640(TO_ECC_64(0x23, 0xFF, 0xFF, 0xFD, 0xC0, 0x00, 0x00, 0x0D),\n                     TO_ECC_64(0x7F, 0xFF, 0xFF, 0xB8, 0x00, 0x00, 0x01, 0xD3),\n                     TO_ECC_64(0xFF, 0xFF, 0xF9, 0x42, 0xD0, 0x00, 0x16, 0x5E),\n                     TO_ECC_64(0x3F, 0xFF, 0x94, 0x87, 0x00, 0x00, 0xD5, 0x2F),\n                     TO_ECC_64(0xFF, 0xFD, 0xD0, 0xE0, 0x00, 0x08, 0xDE, 0x55),\n                     TO_ECC_64(0x60, 0x00, 0x86, 0x55, 0x00, 0x21, 0xE5, 0x55),\n                     TO_ECC_64(0xFF, 0xFF, 0xF5, 0x4F, 0xFF, 0xF4, 0xEA, 0xC0),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x49, 0x80, 0x01, 0x54, 0xD9),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED, 0xA0),\n                     TO_ECC_64(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61)));\n#    define BN_P638_h  ECC_ONE\n#    define BN_P638_gZ ECC_ONE\n\n#  endif  // ECC_BN_P638\n\n#  if ECC_SM2_P256\nECC_CONST(SM2_P256_p,\n          32,\n          TO_ECC_256(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF)));\nECC_CONST(SM2_P256_a,\n          32,\n          TO_ECC_256(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC)));\nECC_CONST(SM2_P256_b,\n          32,\n          TO_ECC_256(TO_ECC_64(0x28, 0xE9, 0xFA, 0x9E, 0x9D, 0x9F, 0x5E, 0x34),\n                     TO_ECC_64(0x4D, 0x5A, 0x9E, 0x4B, 0xCF, 0x65, 0x09, 0xA7),\n                     TO_ECC_64(0xF3, 0x97, 0x89, 0xF5, 0x15, 0xAB, 0x8F, 0x92),\n                     TO_ECC_64(0xDD, 0xBC, 0xBD, 0x41, 0x4D, 0x94, 0x0E, 0x93)));\nECC_CONST(SM2_P256_gX,\n          32,\n          TO_ECC_256(TO_ECC_64(0x32, 0xC4, 0xAE, 0x2C, 0x1F, 0x19, 0x81, 0x19),\n                     TO_ECC_64(0x5F, 0x99, 0x04, 0x46, 0x6A, 0x39, 0xC9, 0x94),\n                     TO_ECC_64(0x8F, 0xE3, 0x0B, 0xBF, 0xF2, 0x66, 0x0B, 0xE1),\n                     TO_ECC_64(0x71, 0x5A, 0x45, 0x89, 0x33, 0x4C, 0x74, 0xC7)));\nECC_CONST(SM2_P256_gY,\n          32,\n          TO_ECC_256(TO_ECC_64(0xBC, 0x37, 0x36, 0xA2, 0xF4, 0xF6, 0x77, 0x9C),\n                     TO_ECC_64(0x59, 0xBD, 0xCE, 0xE3, 0x6B, 0x69, 0x21, 0x53),\n                     TO_ECC_64(0xD0, 0xA9, 0x87, 0x7C, 0xC6, 0x2A, 0x47, 0x40),\n                     TO_ECC_64(0x02, 0xDF, 0x32, 0xE5, 0x21, 0x39, 0xF0, 0xA0)));\nECC_CONST(SM2_P256_n,\n          32,\n          TO_ECC_256(TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF),\n                     TO_ECC_64(0x72, 0x03, 0xDF, 0x6B, 0x21, 0xC6, 0x05, 0x2B),\n                     TO_ECC_64(0x53, 0xBB, 0xF4, 0x09, 0x39, 0xD5, 0x41, 0x23)));\n#    define SM2_P256_h  ECC_ONE\n#    define SM2_P256_gZ ECC_ONE\n\n#  endif  // ECC_SM2_P256\n\n#endif  // TPM_ALG_ECC\n"
  },
  {
    "path": "ftpm-opensbi/src/EncryptDecrypt_spt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t \tEncrypt Decrypt Support \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: EncryptDecrypt_spt.c 1658 2021-01-22 23:14:01Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 7.7 Encrypt Decrypt Support (EncryptDecrypt_spt.c) */\n#include \"Tpm.h\"\n#include \"EncryptDecrypt_fp.h\"\n#include \"EncryptDecrypt_spt_fp.h\"\n#if CC_EncryptDecrypt2\n/* Error Returns Meaning */\n/* TPM_RC_KEY is not a symmetric decryption key with both public and private portions loaded */\n/* TPM_RC_SIZE IvIn size is incompatible with the block cipher mode; or inData size is not an even\n   multiple of the block size for CBC or ECB mode */\n/* TPM_RC_VALUE keyHandle is restricted and the argument mode does not match the key's mode */\nTPM_RC\nEncryptDecryptShared(\n\t\t     TPMI_DH_OBJECT        keyHandleIn,\n\t\t     TPMI_YES_NO           decryptIn,\n\t\t     TPMI_ALG_SYM_MODE     modeIn,\n\t\t     TPM2B_IV              *ivIn,\n\t\t     TPM2B_MAX_BUFFER      *inData,\n\t\t     EncryptDecrypt_Out    *out\n\t\t     )\n{\n    OBJECT              *symKey;\n    UINT16               keySize;\n    UINT16               blockSize;\n    BYTE                *key;\n    TPM_ALG_ID           alg;\n    TPM_ALG_ID           mode;\n    TPM_RC               result;\n    BOOL                 OK;\n    // Input Validation\n    symKey = HandleToObject(keyHandleIn);\n    mode = symKey->publicArea.parameters.symDetail.sym.mode.sym;\n    // The input key should be a symmetric key\n    if(symKey->publicArea.type != TPM_ALG_SYMCIPHER)\n\treturn TPM_RCS_KEY + RC_EncryptDecrypt_keyHandle;\n    // The key must be unrestricted and allow the selected operation\n    OK = !IS_ATTRIBUTE(symKey->publicArea.objectAttributes,\n\t\t       TPMA_OBJECT, restricted);\n    if(YES == decryptIn)\n\tOK = OK && IS_ATTRIBUTE(symKey->publicArea.objectAttributes,\n\t\t\t\tTPMA_OBJECT, decrypt);\n    else\n\tOK = OK && IS_ATTRIBUTE(symKey->publicArea.objectAttributes,\n\t\t\t\tTPMA_OBJECT, sign);\n    if(!OK)\n\treturn TPM_RCS_ATTRIBUTES + RC_EncryptDecrypt_keyHandle;\n    // Make sure that key is an encrypt/decrypt key and not SMAC\n    if(!CryptSymModeIsValid(mode, TRUE))\n\treturn TPM_RCS_MODE + RC_EncryptDecrypt_keyHandle;\n    // If the key mode is not TPM_ALG_NULL...\n    // or TPM_ALG_NULL\n    if(mode != TPM_ALG_NULL)\n\t{\n\t    // then the input mode has to be TPM_ALG_NULL or the same as the key\n\t    if((modeIn != TPM_ALG_NULL) && (modeIn != mode))\n\t\treturn TPM_RCS_MODE + RC_EncryptDecrypt_mode;\n\t}\n    else\n\t{\n\t    // if the key mode is null, then the input can't be null\n\t    if(modeIn == TPM_ALG_NULL)\n\t\treturn TPM_RCS_MODE + RC_EncryptDecrypt_mode;\n\t    mode = modeIn;\n\t}\n    // The input iv for ECB mode should be an Empty Buffer.  All the other modes\n    // should have an iv size same as encryption block size\n    keySize = symKey->publicArea.parameters.symDetail.sym.keyBits.sym;\n    alg = symKey->publicArea.parameters.symDetail.sym.algorithm;\n    blockSize = CryptGetSymmetricBlockSize(alg, keySize);\n    // reverify the algorithm. This is mainly to keep static analysis tools happy\n    if(blockSize == 0)\n\treturn TPM_RCS_KEY + RC_EncryptDecrypt_keyHandle;\n    if(((mode == TPM_ALG_ECB) && (ivIn->t.size != 0))\n       || ((mode != TPM_ALG_ECB) && (ivIn->t.size != blockSize)))\n\treturn TPM_RCS_SIZE + RC_EncryptDecrypt_ivIn;\n    // The input data size of CBC mode or ECB mode must be an even multiple of\n    // the symmetric algorithm's block size\n    if(((mode == TPM_ALG_CBC) || (mode == TPM_ALG_ECB))\n       && ((inData->t.size % blockSize) != 0))\n\treturn TPM_RCS_SIZE + RC_EncryptDecrypt_inData;\n    // Copy IV\n    // Note: This is copied here so that the calls to the encrypt/decrypt functions\n    // will modify the output buffer, not the input buffer\n    out->ivOut = *ivIn;\n    // Command Output\n    key = symKey->sensitive.sensitive.sym.t.buffer;\n    // For symmetric encryption, the cipher data size is the same as plain data\n    // size.\n    out->outData.t.size = inData->t.size;\n    if(decryptIn == YES)\n\t{\n\t    // Decrypt data to output\n\t    result = CryptSymmetricDecrypt(out->outData.t.buffer, alg, keySize, key,\n\t\t\t\t\t   &(out->ivOut), mode, inData->t.size,\n\t\t\t\t\t   inData->t.buffer);\n\t}\n    else\n\t{\n\t    // Encrypt data to output\n\t    result = CryptSymmetricEncrypt(out->outData.t.buffer, alg, keySize, key,\n\t\t\t\t\t   &(out->ivOut), mode, inData->t.size,\n\t\t\t\t\t   inData->t.buffer);\n\t}\n    return result;\n}\n#endif // CC_EncryptDecrypt\n"
  },
  {
    "path": "ftpm-opensbi/src/Entity.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tAccessing properties for handles of various types\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n// The functions in this file are used for accessing properties for handles of\n// various types. Functions in other files require handles of a specific\n// type but the functions in this file allow use of any handle type.\n\n//** Includes\n\n#include \"Tpm.h\"\n\n//** Functions\n//*** EntityGetLoadStatus()\n// This function will check that all the handles access loaded entities.\n//  Return Type: TPM_RC\n//      TPM_RC_HANDLE           handle type does not match\n//      TPM_RC_REFERENCE_Hx     entity is not present\n//      TPM_RC_HIERARCHY        entity belongs to a disabled hierarchy\n//      TPM_RC_OBJECT_MEMORY    handle is an evict object but there is no\n//                               space to load it to RAM\nTPM_RC\nEntityGetLoadStatus(COMMAND* command  // IN/OUT: command parsing structure\n\t\t    )\n{\n    UINT32 i;\n    TPM_RC result = TPM_RC_SUCCESS;\n    //\n    for(i = 0; i < command->handleNum; i++)\n\t{\n\t    TPM_HANDLE handle = command->handles[i];\n\t    switch(HandleGetType(handle))\n\t\t{\n\t\t    // For handles associated with hierarchies, the entity is present\n\t\t    // only if the associated enable is SET.\n\t\t  case TPM_HT_PERMANENT:\n\t\t    switch(handle)\n\t\t\t{\n\t\t\t    // First handle non-hierarchy cases\n#if VENDOR_PERMANENT_AUTH_ENABLED == YES\n\t\t\t  case VENDOR_PERMANENT_AUTH_HANDLE:\n\t\t\t    if(!gc.ehEnable)\n\t\t\t\tresult = TPM_RC_HIERARCHY;\n\t\t\t    break;\n#endif\n\t\t\t    // PW session handle and lockout handle are always available\n\t\t\t  case TPM_RS_PW:\n\t\t\t    // Need to be careful for lockout. Lockout is always available\n\t\t\t    // for policy checks but not always available when authValue\n\t\t\t    // is being checked.\n\t\t\t  case TPM_RH_LOCKOUT:\n\t\t\t    // Rather than have #ifdefs all over the code,\n\t\t\t    // CASE_ACT_HANDLE is defined in ACT.h. It is 'case TPM_RH_ACT_x:'\n\t\t\t    // FOR_EACH_ACT(CASE_ACT_HANDLE) creates a simple\n\t\t\t    // case TPM_RH_ACT_x: // for each of the implemented ACT.\n\t\t\t    FOR_EACH_ACT(CASE_ACT_HANDLE)\n\t\t\t\tbreak;\n\t\t\t  default:\n\t\t\t    // If the implementation has a manufacturer-specific value\n\t\t\t    // then test for it here. Since this implementation does\n\t\t\t    // not have any, this implementation returns the same failure\n\t\t\t    // that unmarshaling of a bad handle would produce.\n\t\t\t    if(((TPM_RH)handle >= TPM_RH_AUTH_00)\n\t\t\t       && ((TPM_RH)handle <= TPM_RH_AUTH_FF))\n\t\t\t\t// if the implementation has a manufacturer-specific value\n\t\t\t\tresult = TPM_RC_VALUE;\n\t\t\t    else\n\t\t\t\t// The handle either refers to a hierarchy or is invalid.\n\t\t\t\tresult = ValidateHierarchy(handle);\n\t\t\t    break;\n\t\t\t}\n\t\t    break;\n\t\t  case TPM_HT_TRANSIENT:\n\t\t    // For a transient object, check if the handle is associated\n\t\t    // with a loaded object.\n\t\t    if(!IsObjectPresent(handle))\n\t\t\tresult = TPM_RC_REFERENCE_H0;\n\t\t    break;\n\t\t  case TPM_HT_PERSISTENT:\n\t\t    // Persistent object\n\t\t    // Copy the persistent object to RAM and replace the handle with the\n\t\t    // handle of the assigned slot.  A TPM_RC_OBJECT_MEMORY,\n\t\t    // TPM_RC_HIERARCHY or TPM_RC_REFERENCE_H0 error may be returned by\n\t\t    // ObjectLoadEvict()\n\t\t    result = ObjectLoadEvict(&command->handles[i], command->index);\n\t\t    break;\n\t\t  case TPM_HT_HMAC_SESSION:\n\t\t    // For an HMAC session, see if the session is loaded\n\t\t    // and if the session in the session slot is actually\n\t\t    // an HMAC session.\n\t\t    if(SessionIsLoaded(handle))\n\t\t\t{\n\t\t\t    SESSION* session;\n\t\t\t    session = SessionGet(handle);\n\t\t\t    // Check if the session is a HMAC session\n\t\t\t    if(session->attributes.isPolicy == SET)\n\t\t\t\tresult = TPM_RC_HANDLE;\n\t\t\t}\n\t\t    else\n\t\t\tresult = TPM_RC_REFERENCE_H0;\n\t\t    break;\n\t\t  case TPM_HT_POLICY_SESSION:\n\t\t    // For a policy session, see if the session is loaded\n\t\t    // and if the session in the session slot is actually\n\t\t    // a policy session.\n\t\t    if(SessionIsLoaded(handle))\n\t\t\t{\n\t\t\t    SESSION* session;\n\t\t\t    session = SessionGet(handle);\n\t\t\t    // Check if the session is a policy session\n\t\t\t    if(session->attributes.isPolicy == CLEAR)\n\t\t\t\tresult = TPM_RC_HANDLE;\n\t\t\t}\n\t\t    else\n\t\t\tresult = TPM_RC_REFERENCE_H0;\n\t\t    break;\n\t\t  case TPM_HT_NV_INDEX:\n\t\t    // For an NV Index, use the TPM-specific routine\n\t\t    // to search the IN Index space.\n\t\t    result = NvIndexIsAccessible(handle);\n\t\t    break;\n\t\t  case TPM_HT_PCR:\n\t\t    // Any PCR handle that is unmarshaled successfully referenced\n\t\t    // a PCR that is defined.\n\t\t    break;\n#if CC_AC_Send\n\t\t  case TPM_HT_AC:\n\t\t    // Use the TPM-specific routine to search for the AC\n\t\t    result = AcIsAccessible(handle);\n\t\t    break;\n#endif\n\t\t  case TPM_HT_EXTERNAL_NV:\n\t\t  case TPM_HT_PERMANENT_NV:\n\t\t    // Not yet supported.\n\t\t    result = TPM_RC_VALUE;\n\t\t    break;\n\t\t  default:\n\t\t    // Any other handle type is a defect in the unmarshaling code.\n\t\t    FAIL(FATAL_ERROR_INTERNAL);\n\t\t    break;\n\t\t}\n\t    if(result != TPM_RC_SUCCESS)\n\t\t{\n\t\t    if(result == TPM_RC_REFERENCE_H0)\n\t\t\tresult = result + i;\n\t\t    else\n\t\t\tresult = RcSafeAddToResult(result, TPM_RC_H + g_rcIndex[i]);\n\t\t    break;\n\t\t}\n\t}\n    return result;\n}\n\n//*** EntityGetAuthValue()\n// This function is used to access the 'authValue' associated with a handle.\n// This function assumes that the handle references an entity that is accessible\n// and the handle is not for a persistent objects. That is EntityGetLoadStatus()\n// should have been called. Also, the accessibility of the authValue should have\n// been verified by IsAuthValueAvailable().\n//\n// This function copies the authorization value of the entity to 'auth'.\n// Return Type: UINT16\n//      count           number of bytes in the authValue with 0's stripped\nUINT16\nEntityGetAuthValue(TPMI_DH_ENTITY handle,  // IN: handle of entity\n                   TPM2B_AUTH*    auth     // OUT: authValue of the entity\n\t\t   )\n{\n    TPM2B_AUTH* pAuth = NULL;\n\n    auth->t.size      = 0;\n\n    switch(HandleGetType(handle))\n\t{\n\t  case TPM_HT_PERMANENT:\n\t      {\n\t\t  switch(HierarchyNormalizeHandle(handle))\n\t\t      {\n\t\t\tcase TPM_RH_OWNER:\n\t\t\t  // ownerAuth for TPM_RH_OWNER\n\t\t\t  pAuth = &gp.ownerAuth;\n\t\t\t  break;\n\t\t\tcase TPM_RH_ENDORSEMENT:\n\t\t\t  // endorsementAuth for TPM_RH_ENDORSEMENT\n\t\t\t  pAuth = &gp.endorsementAuth;\n\t\t\t  break;\n\n\t\t\t  // The ACT use platformAuth for auth\n\t\t\t  FOR_EACH_ACT(CASE_ACT_HANDLE)\n\n\t\t\tcase TPM_RH_PLATFORM:\n\t\t\t  // platformAuth for TPM_RH_PLATFORM\n\t\t\t  pAuth = &gc.platformAuth;\n\t\t\t  break;\n\t\t\tcase TPM_RH_LOCKOUT:\n\t\t\t  // lockoutAuth for TPM_RH_LOCKOUT\n\t\t\t  pAuth = &gp.lockoutAuth;\n\t\t\t  break;\n\t\t\tcase TPM_RH_NULL:\n\t\t\t  // nullAuth for TPM_RH_NULL. Return 0 directly here\n\t\t\t  return 0;\n\t\t\t  break;\n#if VENDOR_PERMANENT_AUTH_ENABLED == YES\n\t\t\tcase VENDOR_PERMANENT_AUTH_HANDLE:\n\t\t\t  // vendor authorization value\n\t\t\t  pAuth = &g_platformUniqueAuth;\n#endif\n\t\t\tdefault:\n\t\t\t  // If any other permanent handle is present it is\n\t\t\t  // a code defect.\n\t\t\t  FAIL(FATAL_ERROR_INTERNAL);\n\t\t\t  break;\n\t\t      }\n\t\t  break;\n\t      }\n\t  case TPM_HT_TRANSIENT:\n            // authValue for an object\n            // A persistent object would have been copied into RAM\n            // and would have an transient object handle here.\n\t      {\n\t\t  OBJECT* object;\n\n\t\t  object = HandleToObject(handle);\n\t\t  // special handling if this is a sequence object\n\t\t  if(ObjectIsSequence(object))\n\t\t      {\n\t\t\t  pAuth = &((HASH_OBJECT*)object)->auth;\n\t\t      }\n\t\t  else\n\t\t      {\n\t\t\t  // Authorization is available only when the private portion of\n\t\t\t  // the object is loaded.  The check should be made before\n\t\t\t  // this function is called\n\t\t\t  pAssert(object->attributes.publicOnly == CLEAR);\n\t\t\t  pAuth = &object->sensitive.authValue;\n\t\t      }\n\t      }\n\t      break;\n\t  case TPM_HT_NV_INDEX:\n            // authValue for an NV index\n\t      {\n\t\t  NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL);\n\t\t  pAssert(nvIndex != NULL);\n\t\t  pAuth = &nvIndex->authValue;\n\t      }\n\t      break;\n\t  case TPM_HT_PCR:\n            // authValue for PCR\n            pAuth = PCRGetAuthValue(handle);\n            break;\n\t  default:\n            // If any other handle type is present here, then there is a defect\n            // in the unmarshaling code.\n            FAIL(FATAL_ERROR_INTERNAL);\n            break;\n\t}\n    // Copy the authValue\n    MemoryCopy2B((TPM2B*)auth, (TPM2B*)pAuth, sizeof(auth->t.buffer));\n    MemoryRemoveTrailingZeros(auth);\n    return auth->t.size;\n}\n\n//*** EntityGetAuthPolicy()\n// This function is used to access the 'authPolicy' associated with a handle.\n// This function assumes that the handle references an entity that is accessible\n// and the handle is not for a persistent objects. That is EntityGetLoadStatus()\n// should have been called. Also, the accessibility of the authPolicy should have\n// been verified by IsAuthPolicyAvailable().\n//\n// This function copies the authorization policy of the entity to 'authPolicy'.\n//\n//  The return value is the hash algorithm for the policy.\nTPMI_ALG_HASH\nEntityGetAuthPolicy(TPMI_DH_ENTITY handle,     // IN: handle of entity\n                    TPM2B_DIGEST*  authPolicy  // OUT: authPolicy of the entity\n\t\t    )\n{\n    TPMI_ALG_HASH hashAlg = TPM_ALG_NULL;\n    authPolicy->t.size    = 0;\n\n    switch(HandleGetType(handle))\n\t{\n\t  case TPM_HT_PERMANENT:\n            switch(HierarchyNormalizeHandle(handle))\n\t\t{\n\t\t  case TPM_RH_OWNER:\n                    // ownerPolicy for TPM_RH_OWNER\n                    *authPolicy = gp.ownerPolicy;\n                    hashAlg     = gp.ownerAlg;\n                    break;\n\t\t  case TPM_RH_ENDORSEMENT:\n                    // endorsementPolicy for TPM_RH_ENDORSEMENT\n                    *authPolicy = gp.endorsementPolicy;\n                    hashAlg     = gp.endorsementAlg;\n                    break;\n\t\t  case TPM_RH_PLATFORM:\n                    // platformPolicy for TPM_RH_PLATFORM\n                    *authPolicy = gc.platformPolicy;\n                    hashAlg     = gc.platformAlg;\n                    break;\n\t\t  case TPM_RH_LOCKOUT:\n                    // lockoutPolicy for TPM_RH_LOCKOUT\n                    *authPolicy = gp.lockoutPolicy;\n                    hashAlg     = gp.lockoutAlg;\n                    break;\n#define ACT_GET_POLICY(N)\t\t\t\t\t\\\n\t\t    case TPM_RH_ACT_##N:\t\t\t\\\n\t\t      *authPolicy = go.ACT_##N.authPolicy;\t\\\n\t\t      hashAlg     = go.ACT_##N.hashAlg;\t\t\\\n\t\t      break;\n                    // Get the policy for each implemented ACT\n                    FOR_EACH_ACT(ACT_GET_POLICY)\n\t\t  default:\n                    hashAlg = TPM_ALG_ERROR;\n                    break;\n\t\t}\n            break;\n\t  case TPM_HT_TRANSIENT:\n            // authPolicy for an object\n\t      {\n\t\t  OBJECT* object = HandleToObject(handle);\n\t\t  *authPolicy    = object->publicArea.authPolicy;\n\t\t  hashAlg        = object->publicArea.nameAlg;\n\t      }\n\t      break;\n\t  case TPM_HT_NV_INDEX:\n            // authPolicy for a NV index\n\t      {\n\t\t  NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL);\n\t\t  pAssert(nvIndex != 0);\n\t\t  *authPolicy = nvIndex->publicArea.authPolicy;\n\t\t  hashAlg     = nvIndex->publicArea.nameAlg;\n\t      }\n\t      break;\n\t  case TPM_HT_PCR:\n            // authPolicy for a PCR\n            hashAlg = PCRGetAuthPolicy(handle, authPolicy);\n            break;\n\t  default:\n            // If any other handle type is present it is a code defect.\n            FAIL(FATAL_ERROR_INTERNAL);\n            break;\n\t}\n    return hashAlg;\n}\n\n//*** EntityGetName()\n// This function returns the Name associated with a handle.\nTPM2B_NAME* EntityGetName(TPMI_DH_ENTITY handle,  // IN: handle of entity\n                          TPM2B_NAME*    name     // OUT: name of entity\n\t\t\t  )\n{\n    switch(HandleGetType(handle))\n\t{\n\t  case TPM_HT_TRANSIENT:\n\t      {\n\t\t  // Name for an object\n\t\t  OBJECT* object = HandleToObject(handle);\n\t\t  // an object with no nameAlg has no name\n\t\t  if(object->publicArea.nameAlg == TPM_ALG_NULL)\n\t\t      name->b.size = 0;\n\t\t  else\n\t\t      *name = object->name;\n\t\t  break;\n\t      }\n\t  case TPM_HT_NV_INDEX:\n            // Name for a NV index\n            NvGetNameByIndexHandle(handle, name);\n            break;\n\t  default:\n            // For all other types, the handle is the Name\n            name->t.size = sizeof(TPM_HANDLE);\n            UINT32_TO_BYTE_ARRAY(handle, name->t.name);\n            break;\n\t}\n    return name;\n}\n\n//*** EntityGetHierarchy()\n// This function returns the hierarchy handle associated with an entity.\n// a) A handle that is a hierarchy handle is associated with itself.\n// b) An NV index belongs to TPM_RH_PLATFORM if TPMA_NV_PLATFORMCREATE,\n//    is SET, otherwise it belongs to TPM_RH_OWNER\n// c) An object handle belongs to its hierarchy.\nTPMI_RH_HIERARCHY\nEntityGetHierarchy(TPMI_DH_ENTITY handle  // IN :handle of entity\n\t\t   )\n{\n    TPMI_RH_HIERARCHY hierarchy = TPM_RH_NULL;\n\n    switch(HandleGetType(handle))\n\t{\n\t  case TPM_HT_PERMANENT:\n            // hierarchy for a permanent handle\n\n            if(HierarchyIsFirmwareLimited(handle) || HierarchyIsSvnLimited(handle))\n\t\t{\n\t\t    hierarchy = handle;\n\t\t    break;\n\t\t}\n\n            switch(handle)\n\t\t{\n\t\t  case TPM_RH_PLATFORM:\n\t\t  case TPM_RH_ENDORSEMENT:\n\t\t  case TPM_RH_NULL:\n                    hierarchy = handle;\n                    break;\n\t\t    // all other permanent handles are associated with the owner\n\t\t    // hierarchy. (should only be TPM_RH_OWNER and TPM_RH_LOCKOUT)\n\t\t  default:\n                    hierarchy = TPM_RH_OWNER;\n                    break;\n\t\t}\n            break;\n\t  case TPM_HT_NV_INDEX:\n            // hierarchy for NV index\n\t      {\n\t\t  NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL);\n\t\t  pAssert(nvIndex != NULL);\n\n\t\t  // If only the platform can delete the index, then it is\n\t\t  // considered to be in the platform hierarchy, otherwise it\n\t\t  // is in the owner hierarchy.\n\t\t  if(IS_ATTRIBUTE(\n\t\t\t\t  nvIndex->publicArea.attributes, TPMA_NV, PLATFORMCREATE))\n\t\t      hierarchy = TPM_RH_PLATFORM;\n\t\t  else\n\t\t      hierarchy = TPM_RH_OWNER;\n\t      }\n\t      break;\n\t  case TPM_HT_TRANSIENT:\n            // hierarchy for an object\n\t      {\n\t\t  OBJECT* object;\n\t\t  object = HandleToObject(handle);\n\t\t  if(object->attributes.ppsHierarchy)\n\t\t      {\n\t\t\t  hierarchy = TPM_RH_PLATFORM;\n\t\t      }\n\t\t  else if(object->attributes.epsHierarchy)\n\t\t      {\n\t\t\t  hierarchy = TPM_RH_ENDORSEMENT;\n\t\t      }\n\t\t  else if(object->attributes.spsHierarchy)\n\t\t      {\n\t\t\t  hierarchy = TPM_RH_OWNER;\n\t\t      }\n\t      }\n\t      break;\n\t  case TPM_HT_PCR:\n            hierarchy = TPM_RH_OWNER;\n            break;\n\t  default:\n            FAIL(FATAL_ERROR_INTERNAL);\n            break;\n\t}\n    // this is unreachable but it provides a return value for the default\n    // case which makes the complier happy\n    return hierarchy;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/Entropy.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Entropy\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Entropy.c 1661 2021-03-18 19:00:58Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.4 Entropy.c */\n/* C.4.1. Includes and Local values*/\n#define _CRT_RAND_S\n#include <stdlib.h>\n#include <memory.h>\n#include <time.h>\n#include \"Platform.h\"\n#include \"intercept.h\"\n\n#if defined _MSC_VER || defined _MINGW\n#include <process.h>\n#else\n#include <unistd.h>\n#endif\n\n/* This is the last 32-bits of hardware entropy produced. We have to check to see that two\n   consecutive 32-bit values are not the same because (according to FIPS 140-2, annex C */\n/* \"If each call to a RNG produces blocks of n bits (where n > 15), the first n-bit block generated\n   after power-up, initialization, or reset shall not be used, but shall be saved for comparison\n   with the next n-bit block to be generated. Each subsequent generation of an n-bit block shall be\n   compared with the previously generated block. The test shall fail if any two compared n-bit\n   blocks are equal.\" */\nextern uint32_t        lastEntropy;\n\n/* C.4.2.\tFunctions */\n/* C.4.2.1.\trand32() */\n/* Local function to get a 32-bit random number */\n\nstatic uint32_t\nrand32(\n       void\n       )\n{\n    uint32_t    rndNum = rand();\n#if RAND_MAX < UINT16_MAX\n    // If the maximum value of the random number is a 15-bit number, then shift it up\n    // 15 bits, get 15 more bits, shift that up 2 and then XOR in another value to get\n    // a full 32 bits.\n    rndNum = (rndNum << 15) ^ rand();\n    rndNum = (rndNum << 2) ^ rand();\n#elif RAND_MAX == UINT16_MAX\n    // If the maximum size is 16-bits, shift it and add another 16 bits\n    rndNum = (rndNum << 16) ^ rand();\n#elif RAND_MAX < UINT32_MAX\n    // If 31 bits, then shift 1 and include another random value to get the extra bit\n    rndNum = (rndNum << 1) ^ rand();\n#endif\n    return rndNum;\n}\n\n/* C.4.2.2 _plat__GetEntropy() */\n/* This function is used to get available hardware entropy. In a hardware implementation of this\n   function, there would be no call to the system to get entropy. */\n/* Return Values Meaning */\n/* < 0 hardware failure of the entropy generator, this is sticky */\n/* >= 0 the returned amount of entropy (bytes) */\nLIB_EXPORT int32_t\n_plat__GetEntropy(\n\t\t  unsigned char       *entropy,           // output buffer\n\t\t  uint32_t             amount             // amount requested\n\t\t  )\n{\n    uint32_t            rndNum;\n    int32_t             ret;\n    //\n    if(amount == 0)\n\t{\n\t    // Seed the platform entropy source if the entropy source is software. There is\n\t    // no reason to put a guard macro (#if or #ifdef) around this code because this\n\t    // code would not be here if someone was changing it for a system with actual\n\t    // hardware.\n\t    //\n\t    // NOTE 1: The following command does not provide proper cryptographic entropy.\n\t    // Its primary purpose to make sure that different instances of the simulator,\n\t    // possibly started by a script on the same machine, are seeded differently.\n\t    // Vendors of the actual TPMs need to ensure availability of proper entropy\n\t    // using their platform specific means.\n\t    //\n\t    // NOTE 2: In debug builds by default the reference implementation will seed\n\t    // its RNG deterministically (without using any platform provided randomness).\n\t    // See the USE_DEBUG_RNG macro and DRBG_GetEntropy() function.\n// #if defined _MSC_VER || defined _MINGW\n// \t    srand((unsigned)_plat__RealTime() ^ _getpid());\n// #else\n// \t    srand((unsigned)_plat__RealTime() ^ getpid());\n// #endif\n    //   srand((unsigned)_plat__RealTime());\n\t    lastEntropy = rand32();\n\t    ret = 0;\n\t}\n    else\n\t{\n\t    rndNum = rand32();\n\t    if(rndNum == lastEntropy)\n\t\t{\n\t\t    ret = -1;\n\t\t}\n\t    else\n\t\t{\n\t\t    lastEntropy = rndNum;\n\t\t    // Each process will have its random number generator initialized according\n\t\t    // to the process id and the initialization time. This is not a lot of\n\t\t    // entropy so, to add a bit more, XOR the current time value into the\n\t\t    // returned entropy value.\n\t\t    // NOTE: the reason for including the time here rather than have it in\n\t\t    // in the value assigned to lastEntropy is that rand() could be broken and\n\t\t    // using the time would in the lastEntropy value would hide this.\n\t\t    rndNum ^= (uint32_t)_plat__RealTime();\n\t\t    // Only provide entropy 32 bits at a time to test the ability\n\t\t    // of the caller to deal with partial results.\n\t\t    ret = MIN(amount, sizeof(rndNum));\n\t\t    memcpy(entropy, &rndNum, ret);\n\t\t}\n\t}\n    return ret;\n}\n\n"
  },
  {
    "path": "ftpm-opensbi/src/EphemeralCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t \tEphemeral EC Keys    \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\nextern int verbose;\n\n#include \"Tpm.h\"\n#include \"Commit_fp.h\"\n#include \"TpmMath_Util_fp.h\"\n\n#if CC_Commit  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// This command performs the point multiply operations for anonymous signing\n// scheme.\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES       'keyHandle' references a restricted key that is not a\n//                              signing key\n//      TPM_RC_ECC_POINT        either 'P1' or the point derived from 's2' is not on\n//                              the curve of 'keyHandle'\n//      TPM_RC_HASH             invalid name algorithm in 'keyHandle'\n//      TPM_RC_KEY              'keyHandle' does not reference an ECC key\n//      TPM_RC_SCHEME           the scheme of 'keyHandle' is not an anonymous scheme\n//      TPM_RC_NO_RESULT        'K', 'L' or 'E' was a point at infinity; or\n//                              failed to generate \"r\" value\n//      TPM_RC_SIZE             's2' is empty but 'y2' is not or 's2' provided but\n//                              'y2' is not\nTPM_RC\nTPM2_Commit(Commit_In*  in,  // IN: input parameter list\n\t    Commit_Out* out  // OUT: output parameter list\n\t    )\n{\n    OBJECT*             eccKey;\n    TPMS_ECC_POINT      P2;\n    TPMS_ECC_POINT*     pP2 = NULL;\n    TPMS_ECC_POINT*     pP1 = NULL;\n    TPM2B_ECC_PARAMETER r;\n    TPM2B_ECC_PARAMETER p;\n    TPM_RC              result;\n    TPMS_ECC_PARMS*     parms;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Commit: signHandle %08x\\n\", in->signHandle);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n\n    eccKey = HandleToObject(in->signHandle);\n    parms  = &eccKey->publicArea.parameters.eccDetail;\n\n    // Input key must be an ECC key\n    if(eccKey->publicArea.type != TPM_ALG_ECC)\n\treturn TPM_RCS_KEY + RC_Commit_signHandle;\n\n    // This command may only be used with a sign-only key using an anonymous\n    // scheme.\n    // NOTE: a sign + decrypt key has no scheme so it will not be an anonymous one\n    // and an unrestricted sign key might no have a signing scheme but it can't\n    // be use in Commit()\n    if(!CryptIsSchemeAnonymous(parms->scheme.scheme))\n\treturn TPM_RCS_SCHEME + RC_Commit_signHandle;\n\n    // Make sure that both parts of P2 are present if either is present\n    if((in->s2.t.size == 0) != (in->y2.t.size == 0))\n\treturn TPM_RCS_SIZE + RC_Commit_y2;\n\n    // Get prime modulus for the curve. This is needed later but getting this now\n    // allows confirmation that the curve exists.\n    if(!TpmMath_IntTo2B(ExtEcc_CurveGetPrime(parms->curveID), &p.b, 0))\n\treturn TPM_RCS_KEY + RC_Commit_signHandle;\n\n    // Get the random value that will be used in the point multiplications\n    // Note: this does not commit the count.\n    if(!CryptGenerateR(&r, NULL, parms->curveID, &eccKey->name))\n\treturn TPM_RC_NO_RESULT;\n\n    // Set up P2 if s2 and Y2 are provided\n    if(in->s2.t.size != 0)\n\t{\n\t    TPM2B_DIGEST x2;\n\n\t    pP2 = &P2;\n\n\t    // copy y2 for P2\n\t    P2.y = in->y2;\n\n\t    // Compute x2  HnameAlg(s2) mod p\n\t    //      do the hash operation on s2 with the size of curve 'p'\n\t    x2.t.size = CryptHashBlock(eccKey->publicArea.nameAlg,\n\t\t\t\t       in->s2.t.size,\n\t\t\t\t       in->s2.t.buffer,\n\t\t\t\t       sizeof(x2.t.buffer),\n\t\t\t\t       x2.t.buffer);\n\n\t    // If there were error returns in the hash routine, indicate a problem\n\t    // with the hash algorithm selection\n\t    if(x2.t.size == 0)\n\t\treturn TPM_RCS_HASH + RC_Commit_signHandle;\n\t    // The size of the remainder will be same as the size of p. DivideB() will\n\t    // pad the results (leading zeros) if necessary to make the size the same\n\t    P2.x.t.size = p.t.size;\n\t    //  set p2.x = hash(s2) mod p\n\t    if(DivideB(&x2.b, &p.b, NULL, &P2.x.b) != TPM_RC_SUCCESS)\n\t\treturn TPM_RC_NO_RESULT;\n\n\t    if(!CryptEccIsPointOnCurve(parms->curveID, pP2))\n\t\treturn TPM_RCS_ECC_POINT + RC_Commit_s2;\n\n\t    if(eccKey->attributes.publicOnly == SET)\n\t\treturn TPM_RCS_KEY + RC_Commit_signHandle;\n\t}\n    // If there is a P1, make sure that it is on the curve\n    // NOTE: an \"empty\" point has two UINT16 values which are the size values\n    // for each of the coordinates.\n    if(in->P1.size > 4)\n\t{\n\t    pP1 = &in->P1.point;\n\t    if(!CryptEccIsPointOnCurve(parms->curveID, pP1))\n\t\treturn TPM_RCS_ECC_POINT + RC_Commit_P1;\n\t}\n\n    // Pass the parameters to CryptCommit.\n    // The work is not done in-line because it does several point multiplies\n    // with the same curve.  It saves work by not having to reload the curve\n    // parameters multiple times.\n    result = CryptEccCommitCompute(&out->K.point,\n\t\t\t\t   &out->L.point,\n\t\t\t\t   &out->E.point,\n\t\t\t\t   parms->curveID,\n\t\t\t\t   pP1,\n\t\t\t\t   pP2,\n\t\t\t\t   &eccKey->sensitive.sensitive.ecc,\n\t\t\t\t   &r);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // The commit computation was successful so complete the commit by setting\n    // the bit\n    out->counter = CryptCommit();\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_Commit\n\n#include \"Tpm.h\"\n#include \"EC_Ephemeral_fp.h\"\n#if CC_EC_Ephemeral  // Conditional expansion of this file\nTPM_RC\nTPM2_EC_Ephemeral(\n\t\t  EC_Ephemeral_In     *in,            // IN: input parameter list\n\t\t  EC_Ephemeral_Out    *out            // OUT: output parameter list\n\t\t  )\n{\n    TPM2B_ECC_PARAMETER      r;\n    TPM_RC                   result;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_EC_Ephemeral:\\n\");\n\t// fclose(f);\n  //   }\n    //\n    do\n\t{\n\t    // Get the random value that will be used in the point multiplications\n\t    // Note: this does not commit the count.\n\t    if(!CryptGenerateR(&r, NULL, in->curveID, NULL))\n\t\treturn TPM_RC_NO_RESULT;\n\t    // do a point multiply\n\t    result = CryptEccPointMultiply(&out->Q.point, in->curveID, NULL, &r,\n\t\t\t\t\t   NULL, NULL);\n\t    // commit the count value if either the r value results in the point at\n\t    // infinity or if the value is good. The commit on the r value for infinity\n\t    // is so that the r value will be skipped.\n\t    if((result == TPM_RC_SUCCESS) || (result == TPM_RC_NO_RESULT))\n\t\tout->counter = CryptCommit();\n\t} while(result == TPM_RC_NO_RESULT);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_EC_Ephemeral\n"
  },
  {
    "path": "ftpm-opensbi/src/ExecCommand.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     ExecCommand\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 6.2 ExecCommand.c */\n/* This file contains the entry function ExecuteCommand() which provides the main control flow for\n   TPM command execution. */\n#include \"Tpm.h\"\n#include \"ExecCommand_fp.h\"\n\nextern int verbose;\n\n/* Uncomment this next #include if doing static command/response buffer sizing */\n// #include \"CommandResponseSizes_fp.h\"\n// The function performs the following steps.\n// a)\tParses the command header from input buffer.\n// b)\tCalls ParseHandleBuffer() to parse the handle area of the command.\n//     c)\tValidates that each of the handles references a loaded entity.\n//     d)\tCalls ParseSessionBuffer() () to:\n// 1)\tunmarshal and parse the session area;\n// 2)\tcheck the authorizations; and\n// 3)\twhen necessary, decrypt a parameter.\n//       e)\tCalls CommandDispatcher() to:\n// 1)\tunmarshal the command parameters from the command buffer;\n// 2)\tcall the routine that performs the command actions; and\n// 3)\tmarshal the responses into the response buffer.\n// f)\tIf any error occurs in any of the steps above create the error response and return.\n// g)\tCalls BuildResponseSession() to:\n// 1)\twhen necessary, encrypt a parameter\n//       2)\tbuild the response authorization sessions\n//       3)\tupdate the audit sessions and nonces\n//       h)\tCalls BuildResponseHeader() to complete the construction of the response.\n\n// \t  responseSize is set by the caller to the maximum number of bytes available in the output\n// \t  buffer. ExecuteCommand() will adjust the value and return the number of bytes placed in\n// \t  the buffer.\n// \t  response is also set by the caller to indicate the buffer into which ExecuteCommand() is\n// \t  to place the response.\n// \t  request and response may point to the same buffer\n// \t  NOTE: As of February, 2016, the failure processing has been moved to the platform-specific\n// \t  code. When the TPM code encounters an unrecoverable failure, it will SET g_inFailureMode\n// \t  and call _plat__Fail(). That function should not return but may call ExecuteCommand().\nLIB_EXPORT void\nExecuteCommand(\n\t       uint32_t         requestSize,   // IN: command buffer size\n\t       unsigned char   *request,       // IN: command buffer\n\t       uint32_t        *responseSize,  // IN/OUT: response buffer size\n\t       unsigned char   **response      // IN/OUT: response buffer\n\t       )\n{\n    // Command local variables\n    UINT32               commandSize;\n    COMMAND              command;\n    // Response local variables\n    UINT32               maxResponse = *responseSize;\n    TPM_RC               result;            // return code for the command\n\n    /* check for an unreasonably large command size, since it's cast to a signed integer later */\n    if (requestSize > INT32_MAX) {\n\tresult = TPM_RC_SUCCESS;\n\tgoto Cleanup;\n    }\n    // This next function call is used in development to size the command and response\n    // buffers. The values printed are the sizes of the internal structures and\n    // not the sizes of the canonical forms of he command response structures. Also,\n    // the sizes do not include the tag, command.code, requestSize, or the authorization\n    // fields.\n    //CommandResponseSizes();\n    // Set flags for NV access state. This should happen before any other\n    // operation that may require a NV write. Note, that this needs to be done\n    // even when in failure mode. Otherwise, g_updateNV would stay SET while in\n    // Failure mode and the NV would be written on each call.\n    g_updateNV = UT_NONE;\n    g_clearOrderly = FALSE;\n    if(g_inFailureMode)\n\t{\n\t    // Do failure mode processing\n\t    TpmFailureMode(requestSize, request, responseSize, response);\n\t    return;\n\t}\n    // Query platform to get the NV state.  The result state is saved internally\n    // and will be reported by NvIsAvailable(). The reference code requires that\n    // accessibility of NV does not change during the execution of a command.\n    // Specifically, if NV is available when the command execution starts and then\n    // is not available later when it is necessary to write to NV, then the TPM\n    // will go into failure mode.\n    NvCheckState();\n    // Due to the limitations of the simulation, TPM clock must be explicitly\n    // synchronized with the system clock whenever a command is received.\n    // This function call is not necessary in a hardware TPM. However, taking\n    // a snapshot of the hardware timer at the beginning of the command allows\n    // the time value to be consistent for the duration of the command execution.\n    TimeUpdateToCurrent();\n    // Any command through this function will unceremoniously end the\n    // _TPM_Hash_Data/_TPM_Hash_End sequence.\n    if(g_DRTMHandle != TPM_RH_UNASSIGNED)\n\tObjectTerminateEvent();\n    // Get command buffer size and command buffer.\n    command.parameterBuffer = request;\n    command.parameterSize = requestSize;\n    // Parse command header: tag, commandSize and command.code.\n    // First parse the tag. The unmarshaling routine will validate\n    // that it is either TPM_ST_SESSIONS or TPM_ST_NO_SESSIONS.\n    result = TPMI_ST_COMMAND_TAG_Unmarshal(&command.tag,\n\t\t\t\t\t   &command.parameterBuffer,\n\t\t\t\t\t   &command.parameterSize);\n    if(result != TPM_RC_SUCCESS)\n\tgoto Cleanup;\n    // Unmarshal the commandSize indicator.\n    result = UINT32_Unmarshal(&commandSize,\n\t\t\t      &command.parameterBuffer,\n\t\t\t      &command.parameterSize);\n    if(result != TPM_RC_SUCCESS)\n\tgoto Cleanup;\n    // On a TPM that receives bytes on a port, the number of bytes that were\n    // received on that port is requestSize it must be identical to commandSize.\n    // In addition, commandSize must not be larger than MAX_COMMAND_SIZE allowed\n    // by the implementation. The check against MAX_COMMAND_SIZE may be redundant\n    // as the input processing (the function that receives the command bytes and\n    // places them in the input buffer) would likely have the input truncated when\n    // it reaches MAX_COMMAND_SIZE, and requestSize would not equal commandSize.\n    if(commandSize != requestSize || commandSize > MAX_COMMAND_SIZE)\n\t{\n\t    result = TPM_RC_COMMAND_SIZE;\n\t    goto Cleanup;\n\t}\n    // Unmarshal the command code.\n    result = TPM_CC_Unmarshal(&command.code, &command.parameterBuffer,\n\t\t\t      &command.parameterSize);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"\\t\\tCommand Code %08x\\n\", command.code);\n\t// fclose(f);\n  //   }\n    if(result != TPM_RC_SUCCESS)\n\tgoto Cleanup;\n    // Check to see if the command is implemented.\n    command.index = CommandCodeToCommandIndex(command.code);\n    if(UNIMPLEMENTED_COMMAND_INDEX == command.index)\n\t{\n\t    result = TPM_RC_COMMAND_CODE;\n\t    goto Cleanup;\n\t}\n#if  FIELD_UPGRADE_IMPLEMENTED  == YES\n    // If the TPM is in FUM, then the only allowed command is\n    // TPM_CC_FieldUpgradeData.\n    if(IsFieldUgradeMode() && (command.code != TPM_CC_FieldUpgradeData))\n\t{\n\t    result = TPM_RC_UPGRADE;\n\t    goto Cleanup;\n\t}\n    else\n#endif\n\t// Excepting FUM, the TPM only accepts TPM2_Startup() after\n\t// _TPM_Init. After getting a TPM2_Startup(), TPM2_Startup()\n\t// is no longer allowed.\n\tif((!TPMIsStarted() && command.code != TPM_CC_Startup)\n\t   || (TPMIsStarted() && command.code == TPM_CC_Startup))\n\t    {\n\t\tresult = TPM_RC_INITIALIZE;\n\t\tgoto Cleanup;\n\t    }\n    // Start regular command process.\n    NvIndexCacheInit();\n    // Parse Handle buffer.\n    result = ParseHandleBuffer(&command);\n    if(result != TPM_RC_SUCCESS)\n\tgoto Cleanup;\n    // All handles in the handle area are required to reference TPM-resident\n    // entities.\n    result = EntityGetLoadStatus(&command);\n    if(result != TPM_RC_SUCCESS)\n\tgoto Cleanup;\n    // Authorization session handling for the command.\n    ClearCpRpHashes(&command);\n    if(command.tag == TPM_ST_SESSIONS)\n\t{\n\t    // Find out session buffer size.\n\t    result = UINT32_Unmarshal((UINT32 *)&command.authSize,\n\t\t\t\t      &command.parameterBuffer,\n\t\t\t\t      &command.parameterSize);\n\t    if(result != TPM_RC_SUCCESS)\n\t\tgoto Cleanup;\n\t    // Perform sanity check on the unmarshaled value. If it is smaller than\n\t    // the smallest possible session or larger than the remaining size of\n\t    // the command, then it is an error. NOTE: This check could pass but the\n\t    // session size could still be wrong. That will be determined after the\n\t    // sessions are unmarshaled.\n\t    if(command.authSize < 9\n\t       || command.authSize > command.parameterSize)\n\t\t{\n\t\t    result = TPM_RC_SIZE;\n\t\t    goto Cleanup;\n\t\t}\n\t    command.parameterSize -= command.authSize;\n\t    // The actions of ParseSessionBuffer() are described in the introduction.\n\t    // As the sessions are parsed command.parameterBuffer is advanced so, on a\n\t    // successful return, command.parameterBuffer should be pointing at the\n\t    // first byte of the parameters.\n\t    result = ParseSessionBuffer(&command);\n\t    if(result != TPM_RC_SUCCESS)\n\t\tgoto Cleanup;\n\t}\n    else\n\t{\n\t    command.authSize = 0;\n\t    // The command has no authorization sessions.\n\t    // If the command requires authorizations, then CheckAuthNoSession() will\n\t    // return an error.\n\t    result = CheckAuthNoSession(&command);\n\t    if(result != TPM_RC_SUCCESS)\n\t\tgoto Cleanup;\n\t}\n    // Set up the response buffer pointers. CommandDispatch will marshal the\n    // response parameters starting at the address in command.responseBuffer.\n    //    *response = MemoryGetResponseBuffer(command.index);\n    // leave space for the command header\n    command.responseBuffer = *response + STD_RESPONSE_HEADER;\n    // leave space for the parameter size field if needed\n    if(command.tag == TPM_ST_SESSIONS)\n\tcommand.responseBuffer += sizeof(UINT32);\n    if(IsHandleInResponse(command.index))\n\tcommand.responseBuffer += sizeof(TPM_HANDLE);\n    // CommandDispatcher returns a response handle buffer and a response parameter\n    // buffer if it succeeds. It will also set the parameterSize field in the\n    // buffer if the tag is TPM_RC_SESSIONS.\n    result = CommandDispatcher(&command);\n    if(result != TPM_RC_SUCCESS)\n\tgoto Cleanup;\n    // Build the session area at the end of the parameter area.\n    result = BuildResponseSession(&command);\n    if(result != TPM_RC_SUCCESS)\n\t{\n\t    goto Cleanup;\n\t}\n Cleanup:\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"\\t\\tReturn Code %08x\\n\", result);\n\t// fclose(f);\n  //   }\n    if(g_clearOrderly == TRUE\n       && NV_IS_ORDERLY)\n\t{\n#if USE_DA_USED\n\t    gp.orderlyState = g_daUsed ? SU_DA_USED_VALUE : SU_NONE_VALUE;\n#else\n\t    gp.orderlyState = SU_NONE_VALUE;\n#endif\n\t    NV_SYNC_PERSISTENT(orderlyState);\n\t}\n    // This implementation loads an \"evict\" object to a transient object slot in\n    // RAM whenever an \"evict\" object handle is used in a command so that the\n    // access to any object is the same. These temporary objects need to be\n    // cleared from RAM whether the command succeeds or fails.\n    ObjectCleanupEvict();\n    // The parameters and sessions have been marshaled. Now tack on the header and\n    // set the sizes\n    BuildResponseHeader(&command, *response, result);\n    // Try to commit all the writes to NV if any NV write happened during this\n    // command execution. This check should be made for both succeeded and failed\n    // commands, because a failed one may trigger a NV write in DA logic as well.\n    // This is the only place in the command execution path that may call the NV\n    // commit. If the NV commit fails, the TPM should be put in failure mode.\n    if((g_updateNV != UT_NONE) && !g_inFailureMode)\n\t{\n\t    if(g_updateNV == UT_ORDERLY)\n\t\tNvUpdateIndexOrderlyData();\n\t    if(!NvCommit())\n\t\tFAIL(FATAL_ERROR_INTERNAL);\n\t    g_updateNV = UT_NONE;\n\t}\n    pAssert((UINT32)command.parameterSize <= maxResponse);\n    // Clear unused bits in response buffer.\n    MemorySet(*response + *responseSize, 0, maxResponse - *responseSize);\n    // as a final act, and not before, update the response size.\n    *responseSize = (UINT32)command.parameterSize;\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/ExtraData.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n//\n// This file contains routines that are called by the core library to allow the\n// platform to use the Core storage structures for small amounts of related data.\n//\n// In this implementation, the buffers are all just set to 0xFF\n\n//** Includes and Data Definitions\n#include <assert.h>\n#include <stdio.h>\n#include <string.h>\n#include \"Platform.h\"\n\n//** _plat__GetPlatformManufactureData\n\n// This function allows the platform to provide a small amount of data to be\n// stored as part of the TPM's PERSISTENT_DATA structure during manufacture.  Of\n// course the platform can store data separately as well, but this allows a\n// simple platform implementation to store a few bytes of data without\n// implementing a multi-layer storage system.  This function is called on\n// manufacture and CLEAR.  The buffer will contain the last value provided\n// to the Core library.\nLIB_EXPORT void _plat__GetPlatformManufactureData(uint8_t* pPlatformPersistentData,\n\t\t\t\t\t\t  uint32_t bufferSize)\n{\n    if(bufferSize != 0)\n\t{\n\t    memset((void*)pPlatformPersistentData, 0xFF, bufferSize);\n\t}\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/Global.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tTPM variables that are not stack allocated\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n// This file will instance the TPM variables that are not stack allocated.\n\n// Descriptions of global variables are in Global.h. There macro macro definitions\n// that allows a variable to be instanced or simply defined as an external variable.\n// When global.h is included from this .c file, GLOBAL_C is defined and values are\n// instanced (and possibly initialized), but when global.h is included by any other\n// file, they are simply defined as external values. DO NOT DEFINE GLOBAL_C IN ANY\n// OTHER FILE.\n//\n// NOTE: This is a change from previous implementations where Global.h just contained\n// the extern declaration and values were instanced in this file. This change keeps\n// the definition and instance in one file making maintenance easier. The instanced\n// data will still be in the global.obj file.\n//\n// The OIDs.h file works in a way that is similar to the Global.h with the definition\n// of the values in OIDs.h such that they are instanced in global.obj. The macros\n// that are defined in Global.h are used in OIDs.h in the same way as they are in\n// Global.h.\n\n//** Defines and Includes\n#define GLOBAL_C\n#include \"Tpm.h\"\n#include \"OIDs.h\"\n\n#if CC_CertifyX509\n#  include \"X509.h\"\n#endif  // CC_CertifyX509\n\n// Global string constants for consistency in KDF function calls.\n// These string constants are shared across functions to make sure that they\n// are all using consistent string values.\n\n// each instance must define a different struct since the buffer sizes vary.\n#define TPM2B_STRING(name, value)\t\t\t\t     \\\n    typedef union name##_\t\t\t\t\t     \\\n    {\t\t\t\t\t\t\t\t\t\\\n\tstruct\t\t\t\t\t\t\t\t\\\n\t{\t\t\t\t\t\t\t\t\\\n\t    UINT16 size;\t\t\t\t\t\t\\\n\t    BYTE   buffer[sizeof(value)];\t\t\t\t\\\n\t} t;\t\t\t\t\t\t\t\t\\\n\tTPM2B b;\t\t\t\t\t\t\t\\\n    } TPM2B_##name##_;\t\t\t\t\t\t\t\\\n    const TPM2B_##name##_ name##_data = {{sizeof(value), {value}}};\t\\\n    const TPM2B*          name        = &name##_data.b\n\nTPM2B_STRING(PRIMARY_OBJECT_CREATION, \"Primary Object Creation\");\nTPM2B_STRING(CFB_KEY, \"CFB\");\nTPM2B_STRING(CONTEXT_KEY, \"CONTEXT\");\nTPM2B_STRING(INTEGRITY_KEY, \"INTEGRITY\");\nTPM2B_STRING(SECRET_KEY, \"SECRET\");\nTPM2B_STRING(HIERARCHY_PROOF_SECRET_LABEL, \"H_PROOF_SECRET\");\nTPM2B_STRING(HIERARCHY_SEED_SECRET_LABEL, \"H_SEED_SECRET\");\nTPM2B_STRING(HIERARCHY_FW_SECRET_LABEL, \"H_FW_SECRET\");\nTPM2B_STRING(HIERARCHY_SVN_SECRET_LABEL, \"H_SVN_SECRET\");\nTPM2B_STRING(SESSION_KEY, \"ATH\");\nTPM2B_STRING(STORAGE_KEY, \"STORAGE\");\nTPM2B_STRING(XOR_KEY, \"XOR\");\nTPM2B_STRING(COMMIT_STRING, \"ECDAA Commit\");\nTPM2B_STRING(DUPLICATE_STRING, \"DUPLICATE\");\nTPM2B_STRING(IDENTITY_STRING, \"IDENTITY\");\nTPM2B_STRING(OBFUSCATE_STRING, \"OBFUSCATE\");\n#if ENABLE_SELF_TESTS\nTPM2B_STRING(OAEP_TEST_STRING, \"OAEP Test Value\");\n#endif  // ENABLE_SELF_TESTS\n\n//*** g_rcIndex[]\nconst UINT16 g_rcIndex[15]  = {TPM_RC_1,\n\t\t\t       TPM_RC_2,\n\t\t\t       TPM_RC_3,\n\t\t\t       TPM_RC_4,\n\t\t\t       TPM_RC_5,\n\t\t\t       TPM_RC_6,\n\t\t\t       TPM_RC_7,\n\t\t\t       TPM_RC_8,\n\t\t\t       TPM_RC_9,\n\t\t\t       TPM_RC_A,\n\t\t\t       TPM_RC_B,\n\t\t\t       TPM_RC_C,\n\t\t\t       TPM_RC_D,\n\t\t\t       TPM_RC_E,\n\t\t\t       TPM_RC_F};\n\nBOOL         g_manufactured = FALSE;\n"
  },
  {
    "path": "ftpm-opensbi/src/Handle.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tfUnctions that return the type of a handle.\t     \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n// This file contains the functions that return the type of a handle.\n\n//** Includes\n#include \"Tpm.h\"\n\n//** Functions\n\n//*** HandleGetType()\n// This function returns the type of a handle which is the MSO of the handle.\nTPM_HT\nHandleGetType(TPM_HANDLE handle  // IN: a handle to be checked\n\t      )\n{\n    // return the upper bytes of input data\n    return (TPM_HT)((handle & HR_RANGE_MASK) >> HR_SHIFT);\n}\n\n//*** NextPermanentHandle()\n// This function returns the permanent handle that is equal to the input value or\n// is the next higher value. If there is no handle with the input value and there\n// is no next higher value, it returns 0:\nTPM_HANDLE\nNextPermanentHandle(TPM_HANDLE inHandle  // IN: the handle to check\n\t\t    )\n{\n    // If inHandle is below the start of the range of permanent handles\n    // set it to the start and scan from there\n    if(inHandle < TPM_RH_FIRST)\n\tinHandle = TPM_RH_FIRST;\n    // scan from input value until we find an implemented permanent handle\n    // or go out of range\n    for(; inHandle <= TPM_RH_LAST; inHandle++)\n\t{\n\t    // Skip over gaps in the reserved handle space.\n\t    if(inHandle > TPM_RH_FW_NULL && inHandle < SVN_OWNER_FIRST)\n\t\tinHandle = SVN_OWNER_FIRST;\n\t    if(inHandle > SVN_OWNER_FIRST && inHandle <= SVN_OWNER_LAST)\n\t\tinHandle = SVN_ENDORSEMENT_FIRST;\n\t    if(inHandle > SVN_ENDORSEMENT_FIRST && inHandle <= SVN_ENDORSEMENT_LAST)\n\t\tinHandle = SVN_PLATFORM_FIRST;\n\t    if(inHandle > SVN_PLATFORM_FIRST && inHandle <= SVN_PLATFORM_LAST)\n\t\tinHandle = SVN_NULL_FIRST;\n\t    if(inHandle > SVN_NULL_FIRST)\n\t\tinHandle = TPM_RH_LAST;\n\t    \n\t    switch(inHandle)\n\t\t{\n\t\t  case TPM_RH_OWNER:\n\t\t  case TPM_RH_NULL:\n\t\t  case TPM_RS_PW:\n\t\t  case TPM_RH_LOCKOUT:\n\t\t  case TPM_RH_ENDORSEMENT:\n\t\t  case TPM_RH_PLATFORM:\n\t\t  case TPM_RH_PLATFORM_NV:\n#if FW_LIMITED_SUPPORT\n\t\t  case TPM_RH_FW_OWNER:\n\t\t  case TPM_RH_FW_ENDORSEMENT:\n\t\t  case TPM_RH_FW_PLATFORM:\n\t\t  case TPM_RH_FW_NULL:\n#endif\n#if SVN_LIMITED_SUPPORT\n\t\t  case TPM_RH_SVN_OWNER_BASE:\n\t\t  case TPM_RH_SVN_ENDORSEMENT_BASE:\n\t\t  case TPM_RH_SVN_PLATFORM_BASE:\n\t\t  case TPM_RH_SVN_NULL_BASE:\n#endif\n#if VENDOR_PERMANENT_AUTH_ENABLED == YES\n\t\t  case VENDOR_PERMANENT_AUTH_HANDLE:\n#endif\n\t\t    // Each of the implemented ACT\n#define ACT_IMPLEMENTED_CASE(N) case TPM_RH_ACT_##N:\n\t\t    \n\t\t    FOR_EACH_ACT(ACT_IMPLEMENTED_CASE)\n\t\t\t\n\t\t\treturn inHandle;\n\t\t    break;\n\t\t  default:\n\t\t    break;\n\t\t}\n\t}\n    // Out of range on the top\n    return 0;\n}\n\n//*** PermanentCapGetHandles()\n// This function returns a list of the permanent handles of PCR, started from\n// 'handle'. If 'handle' is larger than the largest permanent handle, an empty list\n// will be returned with 'more' set to NO.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles available\n//      NO          all the available handles has been returned\nTPMI_YES_NO\nPermanentCapGetHandles(TPM_HANDLE   handle,     // IN: start handle\n\t\t       UINT32       count,      // IN: count of returned handles\n\t\t       TPML_HANDLE* handleList  // OUT: list of handle\n\t\t       )\n{\n    TPMI_YES_NO more = NO;\n    UINT32      i;\n    \n    pAssert(HandleGetType(handle) == TPM_HT_PERMANENT);\n    \n    // Initialize output handle list\n    handleList->count = 0;\n    \n    // The maximum count of handles we may return is MAX_CAP_HANDLES\n    if(count > MAX_CAP_HANDLES)\n\tcount = MAX_CAP_HANDLES;\n    \n    // Iterate permanent handle range\n    for(i = NextPermanentHandle(handle); i != 0; i = NextPermanentHandle(i + 1))\n\t{\n\t    if(handleList->count < count)\n\t\t{\n\t\t    // If we have not filled up the return list, add this permanent\n\t\t    // handle to it\n\t\t    handleList->handle[handleList->count] = i;\n\t\t    handleList->count++;\n\t\t}\n\t    else\n\t\t{\n\t\t    // If the return list is full but we still have permanent handle\n\t\t    // available, report this and stop iterating\n\t\t    more = YES;\n\t\t    break;\n\t\t}\n\t}\n    return more;\n}\n\n//*** PermanentCapGetOneHandle()\n// This function returns whether a permanent handle exists.\nBOOL PermanentCapGetOneHandle(TPM_HANDLE handle)  // IN: handle\n{\n    UINT32 i;\n    \n    pAssert(HandleGetType(handle) == TPM_HT_PERMANENT);\n    \n    // Iterate permanent handle range\n    for(i = NextPermanentHandle(handle); i != 0; i = NextPermanentHandle(i + 1))\n\t{\n\t    if(i == handle)\n\t\t{\n\t\t    return TRUE;\n\t\t}\n\t}\n    return FALSE;\n}\n\n//*** PermanentHandleGetPolicy()\n// This function returns a list of the permanent handles of PCR, started from\n// 'handle'. If 'handle' is larger than the largest permanent handle, an empty list\n// will be returned with 'more' set to NO.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles available\n//      NO          all the available handles has been returned\nTPMI_YES_NO\nPermanentHandleGetPolicy(TPM_HANDLE handle,  // IN: start handle\n\t\t\t UINT32     count,   // IN: max count of returned handles\n\t\t\t TPML_TAGGED_POLICY* policyList  // OUT: list of handle\n\t\t\t )\n{\n    TPMI_YES_NO more = NO;\n    \n    pAssert(HandleGetType(handle) == TPM_HT_PERMANENT);\n    \n    // Initialize output handle list\n    policyList->count = 0;\n    \n    // The maximum count of policies we may return is MAX_TAGGED_POLICIES\n    if(count > MAX_TAGGED_POLICIES)\n\tcount = MAX_TAGGED_POLICIES;\n    \n    // Iterate permanent handle range\n    for(handle = NextPermanentHandle(handle); handle != 0;\n\thandle = NextPermanentHandle(handle + 1))\n\t{\n\t    TPM2B_DIGEST policyDigest;\n\t    TPM_ALG_ID   policyAlg;\n\t    // Check to see if this permanent handle has a policy\n\t    policyAlg = EntityGetAuthPolicy(handle, &policyDigest);\n\t    if(policyAlg == TPM_ALG_ERROR)\n\t\tcontinue;\n\t    if(policyList->count < count)\n\t\t{\n\t\t    // If we have not filled up the return list, add this\n\t\t    // policy to the list;\n\t\t    policyList->policies[policyList->count].handle             = handle;\n\t\t    policyList->policies[policyList->count].policyHash.hashAlg = policyAlg;\n\t\t    MemoryCopy(&policyList->policies[policyList->count].policyHash.digest,\n\t\t\t       policyDigest.t.buffer,\n\t\t\t       policyDigest.t.size);\n\t\t    policyList->count++;\n\t\t}\n\t    else\n\t\t{\n\t\t    // If the return list is full but we still have permanent handle\n\t\t    // available, report this and stop iterating\n\t\t    more = YES;\n\t\t    break;\n\t\t}\n\t}\n    return more;\n}\n\n//*** PermanentHandleGetOnePolicy()\n// This function returns a permanent handle's policy, if present.\nBOOL PermanentHandleGetOnePolicy(TPM_HANDLE          handle,  // IN: handle\n\t\t\t\t TPMS_TAGGED_POLICY* policy   // OUT: tagged policy\n\t\t\t\t )\n{\n    pAssert(HandleGetType(handle) == TPM_HT_PERMANENT);\n    \n    if(NextPermanentHandle(handle) == handle)\n\t{\n\t    TPM2B_DIGEST policyDigest;\n\t    TPM_ALG_ID   policyAlg;\n\t    // Check to see if this permanent handle has a policy\n\t    policyAlg = EntityGetAuthPolicy(handle, &policyDigest);\n\t    if(policyAlg == TPM_ALG_ERROR)\n\t\t{\n\t\t    return FALSE;\n\t\t}\n\t    policy->handle             = handle;\n\t    policy->policyHash.hashAlg = policyAlg;\n\t    MemoryCopy(\n\t\t       &policy->policyHash.digest, policyDigest.t.buffer, policyDigest.t.size);\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/HashCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tHash/HMAC/Event Sequences\t     \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: HashCommands.c 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"HMAC_Start_fp.h\"\n\nextern int verbose;\n\n#if CC_HMAC_Start  // Conditional expansion of this file\nTPM_RC\nTPM2_HMAC_Start(\n\t\tHMAC_Start_In   *in,            // IN: input parameter list\n\t\tHMAC_Start_Out  *out            // OUT: output parameter list\n\t\t)\n{\n    OBJECT                  *keyObject;\n    TPMT_PUBLIC             *publicArea;\n    TPM_ALG_ID               hashAlg;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_HMAC_Start: handle %08x\\n\", in->handle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Get HMAC key object and public area pointers\n    keyObject = HandleToObject(in->handle);\n    publicArea = &keyObject->publicArea;\n    // Make sure that the key is an HMAC key\n    if(publicArea->type != TPM_ALG_KEYEDHASH)\n\treturn TPM_RCS_TYPE + RC_HMAC_Start_handle;\n    // and that it is unrestricted\n    if (IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, restricted))\n\treturn TPM_RCS_ATTRIBUTES + RC_HMAC_Start_handle;\n    // and that it is a signing key\n    if (!IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sign))\n\treturn TPM_RCS_KEY + RC_HMAC_Start_handle;\n    // See if the key has a default\n    if(publicArea->parameters.keyedHashDetail.scheme.scheme == TPM_ALG_NULL)\n\t// it doesn't so use the input value\n\thashAlg = in->hashAlg;\n    else\n\t{\n\t    // key has a default so use it\n\t    hashAlg\n\t\t= publicArea->parameters.keyedHashDetail.scheme.details.hmac.hashAlg;\n\t    // and verify that the input was either the  TPM_ALG_NULL or the default\n\t    if(in->hashAlg != TPM_ALG_NULL && in->hashAlg != hashAlg)\n\t\thashAlg = TPM_ALG_NULL;\n\t}\n    // if we ended up without a hash algorithm then return an error\n    if(hashAlg == TPM_ALG_NULL)\n\treturn TPM_RCS_VALUE + RC_HMAC_Start_hashAlg;\n    // Internal Data Update\n    // Create a HMAC sequence object. A TPM_RC_OBJECT_MEMORY error may be\n    // returned at this point\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_HMAC_Start: sequenceHandle %08x\\n\", out->sequenceHandle);\n\t// fclose(f);\n  //   }\n    return ObjectCreateHMACSequence(hashAlg,\n\t\t\t\t    keyObject,\n\t\t\t\t    &in->auth,\n\t\t\t\t    &out->sequenceHandle);\n}\n#endif // CC_HMAC_Start\n#include \"Tpm.h\"\n#include \"MAC_Start_fp.h\"\n#if CC_MAC_Start  // Conditional expansion of this file\n/* Error Returns Meaning */\n/* TPM_RC_ATTRIBUTES key referenced by handle is not a signing key or is restricted */\n/* TPM_RC_OBJECT_MEMORY no space to create an internal object */\n/* TPM_RC_KEY key referenced by handle is not an HMAC key */\n/* TPM_RC_VALUE hashAlg is not compatible with the hash algorithm of the scheme of the object\n   referenced by handle */\nTPM_RC\nTPM2_MAC_Start(\n\t       MAC_Start_In   *in,            // IN: input parameter list\n\t       MAC_Start_Out  *out            // OUT: output parameter list\n\t       )\n{\n    OBJECT                  *keyObject;\n    TPMT_PUBLIC             *publicArea;\n    TPM_RC                   result;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_MAC_Start: handle %08x\\n\", in->handle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Get HMAC key object and public area pointers\n    keyObject = HandleToObject(in->handle);\n    publicArea = &keyObject->publicArea;\n    // Make sure that the key can do what is required\n    result = CryptSelectMac(publicArea, &in->inScheme);\n    // If the key is not able to do a MAC, indicate that the handle selects an\n    // object that can't do a MAC\n    if(result == TPM_RCS_TYPE)\n\treturn TPM_RCS_TYPE + RC_MAC_Start_handle;\n    // If there is another error type, indicate that the scheme and key are not\n    // compatible\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, RC_MAC_Start_inScheme);\n    // Make sure that the key is not restricted\n    if(IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, restricted))\n\treturn TPM_RCS_ATTRIBUTES + RC_MAC_Start_handle;\n    // and that it is a signing key\n    if(!IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sign))\n\treturn TPM_RCS_KEY + RC_MAC_Start_handle;\n    // Internal Data Update\n    // Create a HMAC sequence object. A TPM_RC_OBJECT_MEMORY error may be\n    // returned at this point\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_MAC_Start: sequenceHandle %08x\\n\", out->sequenceHandle);\n\t// fclose(f);\n  //   }\n    return ObjectCreateHMACSequence(in->inScheme,\n\t\t\t\t    keyObject,\n\t\t\t\t    &in->auth,\n\t\t\t\t    &out->sequenceHandle);\n}\n#endif // CC_MAC_Start\n#include \"Tpm.h\"\n#include \"HashSequenceStart_fp.h\"\n#if CC_HashSequenceStart  // Conditional expansion of this file\nTPM_RC\nTPM2_HashSequenceStart(\n\t\t       HashSequenceStart_In    *in,            // IN: input parameter list\n\t\t       HashSequenceStart_Out   *out            // OUT: output parameter list\n\t\t       )\n{\n    // Internal Data Update\n    if(in->hashAlg == TPM_ALG_NULL)\n\t// Start a event sequence.  A TPM_RC_OBJECT_MEMORY error may be\n\t// returned at this point\n\treturn ObjectCreateEventSequence(&in->auth, &out->sequenceHandle);\n    // Start a hash sequence.  A TPM_RC_OBJECT_MEMORY error may be\n    // returned at this point\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_HashSequenceStart: sequenceHandle %08x\\n\", out->sequenceHandle);\n\t// fclose(f);\n  //   }\n    return ObjectCreateHashSequence(in->hashAlg, &in->auth, &out->sequenceHandle);\n}\n#endif // CC_HashSequenceStart\n#include \"Tpm.h\"\n#include \"SequenceUpdate_fp.h\"\n#if CC_SequenceUpdate  // Conditional expansion of this file\nTPM_RC\nTPM2_SequenceUpdate(\n\t\t    SequenceUpdate_In   *in             // IN: input parameter list\n\t\t    )\n{\n    OBJECT                  *object;\n    HASH_OBJECT             *hashObject;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_SequenceUpdate: sequenceHandle %08x\\n\", in->sequenceHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Get sequence object pointer\n    object = HandleToObject(in->sequenceHandle);\n    hashObject = (HASH_OBJECT *)object;\n    // Check that referenced object is a sequence object.\n    if(!ObjectIsSequence(object))\n\treturn TPM_RCS_MODE + RC_SequenceUpdate_sequenceHandle;\n    // Internal Data Update\n    if(object->attributes.eventSeq == SET)\n\t{\n\t    // Update event sequence object\n\t    UINT32           i;\n\t    for(i = 0; i < HASH_COUNT; i++)\n\t        {\n\t            // Update sequence object\n\t            CryptDigestUpdate2B(&hashObject->state.hashState[i], &in->buffer.b);\n\t        }\n\t}\n    else\n\t{\n\t    // Update hash/HMAC sequence object\n\t    if(hashObject->attributes.hashSeq == SET)\n\t        {\n\t            // Is this the first block of the sequence\n\t            if(hashObject->attributes.firstBlock == CLEAR)\n\t\t\t{\n\t\t\t    // If so, indicate that first block was received\n\t\t\t    hashObject->attributes.firstBlock = SET;\n\t\t\t    // Check the first block to see if the first block can contain\n\t\t\t    // the TPM_GENERATED_VALUE.  If it does, it is not safe for\n\t\t\t    // a ticket.\n\t\t\t    if(TicketIsSafe(&in->buffer.b))\n\t\t\t\thashObject->attributes.ticketSafe = SET;\n\t\t\t}\n\t            // Update sequence object hash/HMAC stack\n\t            CryptDigestUpdate2B(&hashObject->state.hashState[0], &in->buffer.b);\n\t        }\n\t    else if(object->attributes.hmacSeq == SET)\n\t        {\n\t            // Update sequence object HMAC stack\n\t            CryptDigestUpdate2B(&hashObject->state.hmacState.hashState,\n\t                                &in->buffer.b);\n\t        }\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_SequenceUpdate\n#include \"Tpm.h\"\n#include \"SequenceComplete_fp.h\"\n#if CC_SequenceComplete  // Conditional expansion of this file\n/* Error Returns Meaning */\n/* TPM_RC_MODE sequenceHandle does not reference a hash or HMAC sequence object */\nTPM_RC\nTPM2_SequenceComplete(\n\t\t      SequenceComplete_In     *in,            // IN: input parameter list\n\t\t      SequenceComplete_Out    *out            // OUT: output parameter list\n\t\t      )\n{\n    HASH_OBJECT                      *hashObject;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_SequenceComplete: sequenceHandle %08x\\n\", in->sequenceHandle);\n\t// fclose(f);\n  //   }\n    // Input validation\n    // Get hash object pointer\n    hashObject = (HASH_OBJECT *)HandleToObject(in->sequenceHandle);\n    // input handle must be a hash or HMAC sequence object.\n    if(hashObject->attributes.hashSeq == CLEAR\n       && hashObject->attributes.hmacSeq == CLEAR)\n\treturn TPM_RCS_MODE + RC_SequenceComplete_sequenceHandle;\n    // Command Output\n    if(hashObject->attributes.hashSeq == SET)           // sequence object for hash\n\t{\n\t    // Get the hash algorithm before the algorithm is lost in CryptHashEnd\n\t    TPM_ALG_ID       hashAlg = hashObject->state.hashState[0].hashAlg;\n\t    // Update last piece of the data\n\t    CryptDigestUpdate2B(&hashObject->state.hashState[0], &in->buffer.b);\n\t    // Complete hash\n\t    out->result.t.size = CryptHashEnd(&hashObject->state.hashState[0],\n\t\t\t\t\t      sizeof(out->result.t.buffer),\n\t\t\t\t\t      out->result.t.buffer);\n\t    // Check if the first block of the sequence has been received\n\t    if(hashObject->attributes.firstBlock == CLEAR)\n\t\t{\n\t\t    // If not, then this is the first block so see if it is 'safe'\n\t\t    // to sign.\n\t\t    if(TicketIsSafe(&in->buffer.b))\n\t\t\thashObject->attributes.ticketSafe = SET;\n\t\t}\n\t    // Output ticket\n\t    out->validation.tag = TPM_ST_HASHCHECK;\n\t    out->validation.hierarchy = in->hierarchy;\n\t    if(in->hierarchy == TPM_RH_NULL)\n\t\t{\n\t\t    // Ticket is not required\n\t\t    out->validation.digest.t.size = 0;\n\t\t}\n\t    else if(hashObject->attributes.ticketSafe == CLEAR)\n\t\t{\n\t\t    // Ticket is not safe to generate\n\t\t    out->validation.hierarchy = TPM_RH_NULL;\n\t\t    out->validation.digest.t.size = 0;\n\t\t}\n\t    else\n\t\t{\n\t\t    // Compute ticket\n\t\t    TicketComputeHashCheck(out->validation.hierarchy, hashAlg,\n\t\t\t\t\t   &out->result, &out->validation);\n\t\t}\n\t}\n    else\n\t{\n\t    //   Update last piece of data\n\t    CryptDigestUpdate2B(&hashObject->state.hmacState.hashState, &in->buffer.b);\n#if !SMAC_IMPLEMENTED\n\t    // Complete HMAC\n\t    out->result.t.size = CryptHmacEnd(&(hashObject->state.hmacState),\n\t\t\t\t\t      sizeof(out->result.t.buffer),\n\t\t\t\t\t      out->result.t.buffer);\n#else\n\t    // Complete the MAC\n\t    out->result.t.size = CryptMacEnd(&hashObject->state.hmacState,\n\t\t\t\t\t     sizeof(out->result.t.buffer),\n\t\t\t\t\t     out->result.t.buffer);\n#endif\n\t    // No ticket is generated for HMAC sequence\n\t    out->validation.tag = TPM_ST_HASHCHECK;\n\t    out->validation.hierarchy = TPM_RH_NULL;\n\t    out->validation.digest.t.size = 0;\n\t}\n    // Internal Data Update\n    // mark sequence object as evict so it will be flushed on the way out\n    hashObject->attributes.evict = SET;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_SequenceComplete\n#include \"Tpm.h\"\n#include \"EventSequenceComplete_fp.h\"\n#if CC_EventSequenceComplete  // Conditional expansion of this file\nTPM_RC\nTPM2_EventSequenceComplete(\n\t\t\t   EventSequenceComplete_In    *in,            // IN: input parameter list\n\t\t\t   EventSequenceComplete_Out   *out            // OUT: output parameter list\n\t\t\t   )\n{\n    HASH_OBJECT         *hashObject;\n    UINT32               i;\n    TPM_ALG_ID           hashAlg;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_EventSequenceComplete: pcrHandle %u\\n\", in->pcrHandle);\n\t// fprintf(f, \"TPM2_EventSequenceComplete: sequenceHandle %08x\\n\", in->sequenceHandle);\n\t// fclose(f);\n  //   }\n    // Input validation\n    // get the event sequence object pointer\n    hashObject = (HASH_OBJECT *)HandleToObject(in->sequenceHandle);\n    // input handle must reference an event sequence object\n    if(hashObject->attributes.eventSeq != SET)\n\treturn TPM_RCS_MODE + RC_EventSequenceComplete_sequenceHandle;\n    // see if a PCR extend is requested in call\n    if(in->pcrHandle != TPM_RH_NULL)\n\t{\n\t    // see if extend of the PCR is allowed at the locality of the command,\n\t    if(!PCRIsExtendAllowed(in->pcrHandle))\n\t\treturn TPM_RC_LOCALITY;\n\t    // if an extend is going to take place, then check to see if there has\n\t    // been an orderly shutdown. If so, and the selected PCR is one of the\n\t    // state saved PCR, then the orderly state has to change. The orderly state\n\t    // does not change for PCR that are not preserved.\n\t    // NOTE: This doesn't just check for Shutdown(STATE) because the orderly\n\t    // state will have to change if this is a state-saved PCR regardless\n\t    // of the current state. This is because a subsequent Shutdown(STATE) will\n\t    // check to see if there was an orderly shutdown and not do anything if\n\t    // there was. So, this must indicate that a future Shutdown(STATE) has\n\t    // something to do.\n\t    if(PCRIsStateSaved(in->pcrHandle))\n\t\tRETURN_IF_ORDERLY;\n\t}\n    // Command Output\n    out->results.count = 0;\n    for(i = 0; i < HASH_COUNT; i++)\n\t{\n\t    hashAlg = CryptHashGetAlgByIndex(i);\n\t    // Update last piece of data\n\t    CryptDigestUpdate2B(&hashObject->state.hashState[i], &in->buffer.b);\n\t    // Complete hash\n\t    out->results.digests[out->results.count].hashAlg = hashAlg;\n\t    CryptHashEnd(&hashObject->state.hashState[i],\n\t\t\t CryptHashGetDigestSize(hashAlg),\n\t\t\t (BYTE *)&out->results.digests[out->results.count].digest);\n\t    // Extend PCR\n\t    if(in->pcrHandle != TPM_RH_NULL)\n\t\tPCRExtend(in->pcrHandle, hashAlg,\n\t\t\t  CryptHashGetDigestSize(hashAlg),\n\t\t\t  (BYTE *)&out->results.digests[out->results.count].digest);\n\t    out->results.count++;\n\t}\n    // Internal Data Update\n    // mark sequence object as evict so it will be flushed on the way out\n    hashObject->attributes.evict = SET;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_EventSequenceComplete\n"
  },
  {
    "path": "ftpm-opensbi/src/Hierarchy.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tManaging and accessing the hierarchy-related values   \t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the functions used for managing and accessing the\n// hierarchy-related values.\n\n//** Includes\n\n#include \"Tpm.h\"\n\n//**HIERARCHY_MODIFIER_TYPE\n// This enumerates the possible hierarchy modifiers.\ntypedef enum\n    {\n\tHM_NONE = 0,\n\tHM_FW_LIMITED,  // Hierarchy is firmware-limited.\n\tHM_SVN_LIMITED  // Hierarchy is SVN-limited.\n    } HIERARCHY_MODIFIER_TYPE;\n\n//*** HIERARCHY_MODIFIER Structure\n// A HIERARCHY_MODIFIER structure holds metadata about an OBJECT's\n// hierarchy modifier.\ntypedef struct HIERARCHY_MODIFIER\n{\n    HIERARCHY_MODIFIER_TYPE type;  // The type of modification.\n    uint16_t min_svn;  // The minimum SVN to which the hierarchy is limited.\n    // Only valid if 'type' is HM_SVN_LIMITED.\n} HIERARCHY_MODIFIER;\n\n//** Functions\n\n//*** HierarchyPreInstall()\n// This function performs the initialization functions for the hierarchy\n// when the TPM is simulated. This function should not be called if the\n// TPM is not in a manufacturing mode at the manufacturer, or in a simulated\n// environment.\nvoid HierarchyPreInstall_Init(void)\n{\n    // Allow lockout clear command\n    gp.disableClear = FALSE;\n\n    // Initialize Primary Seeds\n    gp.EPSeed.t.size = sizeof(gp.EPSeed.t.buffer);\n    gp.SPSeed.t.size = sizeof(gp.SPSeed.t.buffer);\n    gp.PPSeed.t.size = sizeof(gp.PPSeed.t.buffer);\n#if(defined USE_PLATFORM_EPS) && (USE_PLATFORM_EPS != NO)\n    _plat__GetEPS(gp.EPSeed.t.size, gp.EPSeed.t.buffer);\n#else\n    CryptRandomGenerate(gp.EPSeed.t.size, gp.EPSeed.t.buffer);\n#endif\n    CryptRandomGenerate(gp.SPSeed.t.size, gp.SPSeed.t.buffer);\n    CryptRandomGenerate(gp.PPSeed.t.size, gp.PPSeed.t.buffer);\n\n    // Initialize owner, endorsement and lockout authorization\n    gp.ownerAuth.t.size       = 0;\n    gp.endorsementAuth.t.size = 0;\n    gp.lockoutAuth.t.size     = 0;\n\n    // Initialize owner, endorsement, and lockout policy\n    gp.ownerAlg                 = TPM_ALG_NULL;\n    gp.ownerPolicy.t.size       = 0;\n    gp.endorsementAlg           = TPM_ALG_NULL;\n    gp.endorsementPolicy.t.size = 0;\n    gp.lockoutAlg               = TPM_ALG_NULL;\n    gp.lockoutPolicy.t.size     = 0;\n\n    // Initialize ehProof, shProof and phProof\n    gp.phProof.t.size = sizeof(gp.phProof.t.buffer);\n    gp.shProof.t.size = sizeof(gp.shProof.t.buffer);\n    gp.ehProof.t.size = sizeof(gp.ehProof.t.buffer);\n    CryptRandomGenerate(gp.phProof.t.size, gp.phProof.t.buffer);\n    CryptRandomGenerate(gp.shProof.t.size, gp.shProof.t.buffer);\n    CryptRandomGenerate(gp.ehProof.t.size, gp.ehProof.t.buffer);\n\n    // Write hierarchy data to NV\n    NV_SYNC_PERSISTENT(disableClear);\n    NV_SYNC_PERSISTENT(EPSeed);\n    NV_SYNC_PERSISTENT(SPSeed);\n    NV_SYNC_PERSISTENT(PPSeed);\n    NV_SYNC_PERSISTENT(ownerAuth);\n    NV_SYNC_PERSISTENT(endorsementAuth);\n    NV_SYNC_PERSISTENT(lockoutAuth);\n    NV_SYNC_PERSISTENT(ownerAlg);\n    NV_SYNC_PERSISTENT(ownerPolicy);\n    NV_SYNC_PERSISTENT(endorsementAlg);\n    NV_SYNC_PERSISTENT(endorsementPolicy);\n    NV_SYNC_PERSISTENT(lockoutAlg);\n    NV_SYNC_PERSISTENT(lockoutPolicy);\n    NV_SYNC_PERSISTENT(phProof);\n    NV_SYNC_PERSISTENT(shProof);\n    NV_SYNC_PERSISTENT(ehProof);\n\n    return;\n}\n\n//*** HierarchyStartup()\n// This function is called at TPM2_Startup() to initialize the hierarchy\n// related values.\nBOOL HierarchyStartup(STARTUP_TYPE type  // IN: start up type\n\t\t      )\n{\n    // phEnable is SET on any startup\n    g_phEnable = TRUE;\n\n    // Reset platformAuth, platformPolicy; enable SH and EH at TPM_RESET and\n    // TPM_RESTART\n    if(type != SU_RESUME)\n\t{\n\t    gc.platformAuth.t.size   = 0;\n\t    gc.platformPolicy.t.size = 0;\n\t    gc.platformAlg           = TPM_ALG_NULL;\n\n\t    // enable the storage and endorsement hierarchies and the platformNV\n\t    gc.shEnable = gc.ehEnable = gc.phEnableNV = TRUE;\n\t}\n\n    // nullProof and nullSeed are updated at every TPM_RESET\n    if((type != SU_RESTART) && (type != SU_RESUME))\n\t{\n\t    gr.nullProof.t.size = sizeof(gr.nullProof.t.buffer);\n\t    CryptRandomGenerate(gr.nullProof.t.size, gr.nullProof.t.buffer);\n\t    gr.nullSeed.t.size = sizeof(gr.nullSeed.t.buffer);\n\t    CryptRandomGenerate(gr.nullSeed.t.size, gr.nullSeed.t.buffer);\n\t}\n\n    return TRUE;\n}\n\n//*** DecomposeHandle()\n// This function extracts the base hierarchy and modifier from a given handle.\n// Returns the base hierarchy.\nstatic TPMI_RH_HIERARCHY DecomposeHandle(TPMI_RH_HIERARCHY   handle,   // IN\n\t\t\t\t\t HIERARCHY_MODIFIER* modifier  // OUT\n\t\t\t\t\t )\n{\n    TPMI_RH_HIERARCHY base_hierarchy = handle;\n\n    modifier->type                   = HM_NONE;\n\n    // See if the handle is firmware-bound.\n    switch(handle)\n\t{\n\t  case TPM_RH_FW_OWNER:\n\t      {\n\t\t  modifier->type = HM_FW_LIMITED;\n\t\t  base_hierarchy = TPM_RH_OWNER;\n\t\t  break;\n\t      }\n\t  case TPM_RH_FW_ENDORSEMENT:\n\t      {\n\t\t  modifier->type = HM_FW_LIMITED;\n\t\t  base_hierarchy = TPM_RH_ENDORSEMENT;\n\t\t  break;\n\t      }\n\t  case TPM_RH_FW_PLATFORM:\n\t      {\n\t\t  modifier->type = HM_FW_LIMITED;\n\t\t  base_hierarchy = TPM_RH_PLATFORM;\n\t\t  break;\n\t      }\n\t  case TPM_RH_FW_NULL:\n\t      {\n\t\t  modifier->type = HM_FW_LIMITED;\n\t\t  base_hierarchy = TPM_RH_NULL;\n\t\t  break;\n\t      }\n\t}\n\n    if(modifier->type == HM_FW_LIMITED)\n\t{\n\t    return base_hierarchy;\n\t}\n\n    // See if the handle is SVN-bound.\n    switch(handle & 0xFFFF0000)\n\t{\n\t  case TPM_RH_SVN_OWNER_BASE:\n\t    modifier->type = HM_SVN_LIMITED;\n\t    base_hierarchy = TPM_RH_OWNER;\n\t    break;\n\t  case TPM_RH_SVN_ENDORSEMENT_BASE:\n\t    modifier->type = HM_SVN_LIMITED;\n\t    base_hierarchy = TPM_RH_ENDORSEMENT;\n\t    break;\n\t  case TPM_RH_SVN_PLATFORM_BASE:\n\t    modifier->type = HM_SVN_LIMITED;\n\t    base_hierarchy = TPM_RH_PLATFORM;\n\t    break;\n\t  case TPM_RH_SVN_NULL_BASE:\n\t    modifier->type = HM_SVN_LIMITED;\n\t    base_hierarchy = TPM_RH_NULL;\n\t    break;\n\t}\n\n    if(modifier->type == HM_SVN_LIMITED)\n\t{\n\t    modifier->min_svn = handle & 0x0000FFFF;\n\t    return base_hierarchy;\n\t}\n\n    // Handle is neither FW- nor SVN-bound; return it unmodified.\n    return handle;\n}\n\n//*** GetAdditionalSecret()\n// Retrieve the additional secret for the given hierarchy modifier, along with the\n// label that should be used when mixing the secret into a KDF. If the hierarchy\n// needs no additional secret, secret_buffer's size is set to zero and secret_label\n// is set to NULL.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects or the TPM failed\n//                              to derive the Firmware Secret.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the TPM failed\n//                              to derive the Firmware SVN Secret for the requested\n//                              SVN.\nstatic TPM_RC GetAdditionalSecret(const HIERARCHY_MODIFIER* modifier,       // IN\n\t\t\t\t  TPM2B_SEED*               secret_buffer,  // OUT\n\t\t\t\t  const TPM2B**             secret_label    // OUT\n\t\t\t\t  )\n{\n    switch(modifier->type)\n\t{\n\t  case HM_FW_LIMITED:\n\t      {\n#if FW_LIMITED_SUPPORT\n\t\t  if(_plat__GetTpmFirmwareSecret(sizeof(secret_buffer->t.buffer),\n\t\t\t\t\t\t secret_buffer->t.buffer,\n\t\t\t\t\t\t &secret_buffer->t.size)\n\t\t     != 0)\n\t\t      {\n\t\t\t  return TPM_RC_FW_LIMITED;\n\t\t      }\n\n\t\t  *secret_label = HIERARCHY_FW_SECRET_LABEL;\n\t\t  break;\n#else\n\t\t  return TPM_RC_FW_LIMITED;\n#endif  // FW_LIMITED_SUPPORT\n\t      }\n\t  case HM_SVN_LIMITED:\n\t      {\n#if SVN_LIMITED_SUPPORT\n\t\t  if(_plat__GetTpmFirmwareSvnSecret(modifier->min_svn,\n\t\t\t\t\t\t    sizeof(secret_buffer->t.buffer),\n\t\t\t\t\t\t    secret_buffer->t.buffer,\n\t\t\t\t\t\t    &secret_buffer->t.size)\n\t\t     != 0)\n\t\t      {\n\t\t\t  return TPM_RC_SVN_LIMITED;\n\t\t      }\n\n\t\t  *secret_label = HIERARCHY_SVN_SECRET_LABEL;\n\t\t  break;\n#else\n\t\t  return TPM_RC_SVN_LIMITED;\n#endif  // SVN_LIMITED_SUPPORT\n\t      }\n\t  case HM_NONE:\n\t  default:\n\t      {\n\t\t  secret_buffer->t.size = 0;\n\t\t  *secret_label         = NULL;\n\t\t  break;\n\t      }\n\t}\n\n    return TPM_RC_SUCCESS;\n}\n\n//***MixAdditionalSecret()\n// This function obtains the additional secret for the hierarchy and\n// mixes it into the base secret. The output buffer must have the same\n// capacity as the base secret. The output buffer's size is set to the\n// base secret size. If no additional secret is needed, the base secret\n// is copied to the output buffer.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects or the TPM failed\n//                              to derive the Firmware Secret.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the TPM failed\n//                              to derive the Firmware SVN Secret for the requested\n//                              SVN.\nstatic TPM_RC MixAdditionalSecret(const HIERARCHY_MODIFIER* modifier,           // IN\n\t\t\t\t  const TPM2B*              base_secret_label,  // IN\n\t\t\t\t  const TPM2B*              base_secret,        // IN\n\t\t\t\t  TPM2B*                    output_secret       // OUT\n\t\t\t\t  )\n{\n    TPM_RC       result = TPM_RC_SUCCESS;\n    TPM2B_SEED   additional_secret;\n    const TPM2B* additional_secret_label = NULL;\n\n    result =\n\tGetAdditionalSecret(modifier, &additional_secret, &additional_secret_label);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    output_secret->size = base_secret->size;\n\n    if(additional_secret.b.size == 0)\n\t{\n\t    memcpy(output_secret->buffer, base_secret->buffer, base_secret->size);\n\t}\n    else\n\t{\n\t    CryptKDFa(CONTEXT_INTEGRITY_HASH_ALG,\n\t\t      base_secret,\n\t\t      base_secret_label,\n\t\t      &additional_secret.b,\n\t\t      additional_secret_label,\n\t\t      base_secret->size * 8,\n\t\t      output_secret->buffer,\n\t\t      NULL,\n\t\t      FALSE);\n\t}\n\n    MemorySet(additional_secret.b.buffer, 0, additional_secret.b.size);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** HierarchyGetProof()\n// This function derives the proof value associated with a hierarchy. It returns a\n// buffer containing the proof value.\nTPM_RC HierarchyGetProof(TPMI_RH_HIERARCHY hierarchy,  // IN: hierarchy constant\n\t\t\t TPM2B_PROOF*      proof       // OUT: proof buffer\n\t\t\t )\n{\n    TPM2B_PROOF*       base_proof = NULL;\n    HIERARCHY_MODIFIER modifier;\n\n    switch(DecomposeHandle(hierarchy, &modifier))\n\t{\n\t  case TPM_RH_PLATFORM:\n\t    // phProof for TPM_RH_PLATFORM\n\t    base_proof = &gp.phProof;\n\t    break;\n\t  case TPM_RH_ENDORSEMENT:\n\t    // ehProof for TPM_RH_ENDORSEMENT\n\t    base_proof = &gp.ehProof;\n\t    break;\n\t  case TPM_RH_OWNER:\n\t    // shProof for TPM_RH_OWNER\n\t    base_proof = &gp.shProof;\n\t    break;\n\t  default:\n\t    // nullProof for TPM_RH_NULL or anything else\n\t    base_proof = &gr.nullProof;\n\t    break;\n\t}\n\n    return MixAdditionalSecret(\n\t\t\t       &modifier, HIERARCHY_PROOF_SECRET_LABEL, &base_proof->b, &proof->b);\n}\n\n//*** HierarchyGetPrimarySeed()\n// This function derives the primary seed of a hierarchy.\nTPM_RC HierarchyGetPrimarySeed(TPMI_RH_HIERARCHY hierarchy,  // IN: hierarchy\n\t\t\t       TPM2B_SEED*       seed        // OUT: seed buffer\n\t\t\t       )\n{\n    TPM2B_SEED*        base_seed = NULL;\n    HIERARCHY_MODIFIER modifier;\n\n    switch(DecomposeHandle(hierarchy, &modifier))\n\t{\n\t  case TPM_RH_PLATFORM:\n\t    base_seed = &gp.PPSeed;\n\t    break;\n\t  case TPM_RH_OWNER:\n\t    base_seed = &gp.SPSeed;\n\t    break;\n\t  case TPM_RH_ENDORSEMENT:\n\t    base_seed = &gp.EPSeed;\n\t    break;\n\t  default:\n\t    base_seed = &gr.nullSeed;\n\t    break;\n\t}\n\n    return MixAdditionalSecret(\n\t\t\t       &modifier, HIERARCHY_SEED_SECRET_LABEL, &base_seed->b, &seed->b);\n}\n\n//*** ValidateHierarchy()\n// This function ensures a given hierarchy is valid and enabled.\n//  Return Type: TPM_RC\n//      TPM_RC_HIERARCHY        Hierarchy is disabled\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the given SVN\n//                              is greater than the TPM's current SVN.\n//      TPM_RC_VALUE            Hierarchy is not valid\nTPM_RC ValidateHierarchy(TPMI_RH_HIERARCHY hierarchy  // IN: hierarchy\n\t\t\t )\n{\n    BOOL               enabled;\n    HIERARCHY_MODIFIER modifier;\n\n    hierarchy = DecomposeHandle(hierarchy, &modifier);\n\n    // Modifier-specific checks.\n    switch(modifier.type)\n\t{\n\t  case HM_NONE:\n\t    break;\n\t  case HM_FW_LIMITED:\n\t      {\n#if FW_LIMITED_SUPPORT\n\t\t  break;\n#else\n\t\t  return TPM_RC_FW_LIMITED;\n#endif  // FW_LIMITED_SUPPORT\n\t      }\n\t  case HM_SVN_LIMITED:\n\t      {\n#if SVN_LIMITED_SUPPORT\n\t\t  // SVN-limited hierarchies are only enabled for SVNs less than or\n\t\t  // equal to the current firmware's SVN.\n\t\t  if(modifier.min_svn > _plat__GetTpmFirmwareSvn())\n\t\t      {\n\t\t\t  return TPM_RC_SVN_LIMITED;\n\t\t      }\n\t\t  break;\n#else\n\t\t  return TPM_RC_SVN_LIMITED;\n#endif  // SVN_LIMITED_SUPPORT\n\t      }\n\t}\n\n    switch(hierarchy)\n\t{\n\t  case TPM_RH_PLATFORM:\n\t    enabled = g_phEnable;\n\t    break;\n\t  case TPM_RH_OWNER:\n\t    enabled = gc.shEnable;\n\t    break;\n\t  case TPM_RH_ENDORSEMENT:\n\t    enabled = gc.ehEnable;\n\t    break;\n\t  case TPM_RH_NULL:\n\t    enabled = TRUE;\n\t    break;\n\t  default:\n\t    return TPM_RC_VALUE;\n\t}\n\n    return enabled ? TPM_RC_SUCCESS : TPM_RC_HIERARCHY;\n}\n\n//*** HierarchyIsEnabled()\n// This function checks to see if a hierarchy is enabled.\n// NOTE: The TPM_RH_NULL hierarchy is always enabled.\n//  Return Type: BOOL\n//      TRUE(1)         hierarchy is enabled\n//      FALSE(0)        hierarchy is disabled\nBOOL HierarchyIsEnabled(TPMI_RH_HIERARCHY hierarchy  // IN: hierarchy\n\t\t\t)\n{\n    return ValidateHierarchy(hierarchy) == TPM_RC_SUCCESS;\n}\n\n//*** HierarchyNormalizeHandle\n// This function accepts a handle that may or may not be FW- or SVN-bound,\n// and returns the base hierarchy to which the handle refers.\nTPMI_RH_HIERARCHY HierarchyNormalizeHandle(TPMI_RH_HIERARCHY handle  // IN: handle\n\t\t\t\t\t   )\n{\n    HIERARCHY_MODIFIER unused_modifier;\n\n    return DecomposeHandle(handle, &unused_modifier);\n}\n\n//*** HierarchyIsFirmwareLimited\n// This function accepts a hierarchy handle and returns whether it is firmware-\n// limited.\nBOOL HierarchyIsFirmwareLimited(TPMI_RH_HIERARCHY handle  // IN\n\t\t\t\t)\n{\n    HIERARCHY_MODIFIER modifier;\n\n    DecomposeHandle(handle, &modifier);\n\n    return modifier.type == HM_FW_LIMITED;\n}\n//*** HierarchyIsSvnLimited\n// This function accepts a hierarchy handle and returns whether it is SVN-\n// limited.\nBOOL HierarchyIsSvnLimited(TPMI_RH_HIERARCHY handle  // IN\n\t\t\t   )\n{\n    HIERARCHY_MODIFIER modifier;\n\n    DecomposeHandle(handle, &modifier);\n\n    return modifier.type == HM_SVN_LIMITED;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/HierarchyCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Hierarchy Commands\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"CreatePrimary_fp.h\"\n\nextern int verbose;\n\n#if CC_CreatePrimary  // Conditional expansion of this file\nTPM_RC\nTPM2_CreatePrimary(\n\t\t   CreatePrimary_In    *in,            // IN: input parameter list\n\t\t   CreatePrimary_Out   *out            // OUT: output parameter list\n\t\t   )\n{\n    TPM_RC              result = TPM_RC_SUCCESS;\n    TPMT_PUBLIC         *publicArea;\n    DRBG_STATE           rand;\n    OBJECT              *newObject;\n    TPM2B_NAME           name;\n    TPM2B_SEED     \tprimary_seed;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_CreatePrimary: primaryHandle %08x\\n\", in->primaryHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Will need a place to put the result\n    newObject = FindEmptyObjectSlot(&out->objectHandle);\n    if(newObject == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    // Get the address of the public area in the new object\n    // (this is just to save typing)\n    publicArea  = &newObject->publicArea;\n\n    *publicArea = in->inPublic.publicArea;\n\n    // Check attributes in input public area. CreateChecks() checks the things that\n    // are unique to creation and then validates the attributes and values that are\n    // common to create and load.\n    result = CreateChecks(\n\t\t\t  NULL, in->primaryHandle, publicArea, in->inSensitive.sensitive.data.t.size);\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, RC_CreatePrimary_inPublic);\n    // Validate the sensitive area values\n    if(!AdjustAuthSize(&in->inSensitive.sensitive.userAuth, publicArea->nameAlg))\n\treturn TPM_RCS_SIZE + RC_CreatePrimary_inSensitive;\n    // Command output\n    // Compute the name using out->name as a scratch area (this is not the value\n    // that ultimately will be returned, then instantiate the state that will be\n    // used as a random number generator during the object creation.\n    // The caller does not know the seed values so the actual name does not have\n    // to be over the input, it can be over the unmarshaled structure.\n\n    result = HierarchyGetPrimarySeed(in->primaryHandle, &primary_seed);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    result =\n\tDRBG_InstantiateSeeded(&rand,\n\t\t\t       &primary_seed.b,\n\t\t\t       PRIMARY_OBJECT_CREATION,\n\t\t\t       (TPM2B*)PublicMarshalAndComputeName(publicArea, &name),\n\t\t\t       &in->inSensitive.sensitive.data.b);\n    MemorySet(primary_seed.b.buffer, 0, primary_seed.b.size);\n\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    newObject->attributes.primary = SET;\n\t    if(HierarchyNormalizeHandle(in->primaryHandle) == TPM_RH_ENDORSEMENT)\n\t\tnewObject->attributes.epsHierarchy = SET;\n\n\t    // Create the primary object.\n\t    result = CryptCreateObject(\n\t\t\t\t       newObject, &in->inSensitive.sensitive, (RAND_STATE*)&rand);\n\t    DRBG_Uninstantiate(&rand);\n\t}\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Set the publicArea and name from the computed values\n    out->outPublic.publicArea = newObject->publicArea;\n    out->name                 = newObject->name;\n\n    // Fill in creation data\n    FillInCreationData(in->primaryHandle,\n\t\t       publicArea->nameAlg,\n\t\t       &in->creationPCR,\n\t\t       &in->outsideInfo,\n\t\t       &out->creationData,\n\t\t       &out->creationHash);\n\n    // Compute creation ticket\n    result = TicketComputeCreation(EntityGetHierarchy(in->primaryHandle),\n\t\t\t\t   &out->name,\n\t\t\t\t   &out->creationHash,\n\t\t\t\t   &out->creationTicket);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Set the remaining attributes for a loaded object\n    ObjectSetLoadedAttributes(newObject, in->primaryHandle);\n    return result;\n\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_CreatePrimary: objectHandle %08x\\n\", out->objectHandle);\n\t// fclose(f);\n  //   }\n    return result;\n}\n#endif // CC_CreatePrimary\n#include \"Tpm.h\"\n#include \"HierarchyControl_fp.h\"\n#if CC_HierarchyControl  // Conditional expansion of this file\nTPM_RC\nTPM2_HierarchyControl(\n\t\t      HierarchyControl_In     *in             // IN: input parameter list\n\t\t      )\n{\n    BOOL        select = (in->state == YES);\n    BOOL        *selected = NULL;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_HierarchyControl: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    switch(in->enable)\n\t{\n\t    // Platform hierarchy has to be disabled by PlatformAuth\n\t    // If the platform hierarchy has already been disabled, only a reboot\n\t    // can enable it again\n\t  case TPM_RH_PLATFORM:\n\t  case TPM_RH_PLATFORM_NV:\n\t    if(in->authHandle != TPM_RH_PLATFORM)\n\t\treturn TPM_RC_AUTH_TYPE;\n\t    break;\n\t    // ShEnable may be disabled if PlatformAuth/PlatformPolicy or\n\t    // OwnerAuth/OwnerPolicy is provided.  If ShEnable is disabled, then it\n\t    // may only be enabled if PlatformAuth/PlatformPolicy is provided.\n\t  case TPM_RH_OWNER:\n\t    if(in->authHandle != TPM_RH_PLATFORM\n\t       && in->authHandle != TPM_RH_OWNER)\n\t\treturn TPM_RC_AUTH_TYPE;\n\t    if(gc.shEnable == FALSE && in->state == YES\n\t       && in->authHandle != TPM_RH_PLATFORM)\n\t\treturn TPM_RC_AUTH_TYPE;\n\t    break;\n\t    // EhEnable may be disabled if either PlatformAuth/PlatformPolicy or\n\t    // EndosementAuth/EndorsementPolicy is provided.  If EhEnable is disabled,\n\t    // then it may only be enabled if PlatformAuth/PlatformPolicy is\n\t    // provided.\n\t  case TPM_RH_ENDORSEMENT:\n\t    if(in->authHandle != TPM_RH_PLATFORM\n\t       && in->authHandle != TPM_RH_ENDORSEMENT)\n\t\treturn TPM_RC_AUTH_TYPE;\n\t    if(gc.ehEnable == FALSE && in->state == YES\n\t       && in->authHandle != TPM_RH_PLATFORM)\n\t\treturn TPM_RC_AUTH_TYPE;\n\t    break;\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    // Internal Data Update\n    // Enable or disable the selected hierarchy\n    // Note: the authorization processing for this command may keep these\n    // command actions from being executed. For example, if phEnable is\n    // CLEAR, then platformAuth cannot be used for authorization. This\n    // means that would not be possible to use platformAuth to change the\n    // state of phEnable from CLEAR to SET.\n    // If it is decided that platformPolicy can still be used when phEnable\n    // is CLEAR, then this code could SET phEnable when proper platform\n    // policy is provided.\n    switch(in->enable)\n\t{\n\t  case TPM_RH_OWNER:\n\t    selected = &gc.shEnable;\n\t    break;\n\t  case TPM_RH_ENDORSEMENT:\n\t    selected = &gc.ehEnable;\n\t    break;\n\t  case TPM_RH_PLATFORM:\n\t    selected = &g_phEnable;\n\t    break;\n\t  case TPM_RH_PLATFORM_NV:\n\t    selected = &gc.phEnableNV;\n\t    break;\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    if(selected != NULL && *selected != select)\n\t{\n\t    // Before changing the internal state, make sure that NV is available.\n\t    // Only need to update NV if changing the orderly state\n\t    RETURN_IF_ORDERLY;\n\t    // state is changing and NV is available so modify\n\t    *selected = select;\n\t    // If a hierarchy was just disabled, flush it\n\t    if(select == CLEAR && in->enable != TPM_RH_PLATFORM_NV)\n\t        // Flush hierarchy\n\t\tObjectFlushHierarchy(in->enable);\n\t    // orderly state should be cleared because of the update to state clear data\n\t    // This gets processed in ExecuteCommand() on the way out.\n\t    g_clearOrderly = TRUE;\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_HierarchyControl\n#include \"Tpm.h\"\n#include \"SetPrimaryPolicy_fp.h\"\n#if CC_SetPrimaryPolicy  // Conditional expansion of this file\nTPM_RC\nTPM2_SetPrimaryPolicy(\n\t\t      SetPrimaryPolicy_In     *in             // IN: input parameter list\n\t\t      )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_SetPrimaryPolicy: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Check the authPolicy consistent with hash algorithm. If the policy size is\n    // zero, then the algorithm is required to be TPM_ALG_NULL\n    if(in->authPolicy.t.size != CryptHashGetDigestSize(in->hashAlg))\n\treturn TPM_RCS_SIZE + RC_SetPrimaryPolicy_authPolicy;\n    // The command need NV update for OWNER and ENDORSEMENT hierarchy, and\n    // might need orderlyState update for PLATFROM hierarchy.\n    // Check if NV is available.  A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE\n    // error may be returned at this point\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Internal Data Update\n    // Set hierarchy policy\n    switch(in->authHandle)\n\t{\n\t  case TPM_RH_OWNER:\n\t    gp.ownerAlg = in->hashAlg;\n\t    gp.ownerPolicy = in->authPolicy;\n\t    NV_SYNC_PERSISTENT(ownerAlg);\n\t    NV_SYNC_PERSISTENT(ownerPolicy);\n\t    break;\n\t  case TPM_RH_ENDORSEMENT:\n\t    gp.endorsementAlg = in->hashAlg;\n\t    gp.endorsementPolicy = in->authPolicy;\n\t    NV_SYNC_PERSISTENT(endorsementAlg);\n\t    NV_SYNC_PERSISTENT(endorsementPolicy);\n\t    break;\n\t  case TPM_RH_PLATFORM:\n\t    gc.platformAlg = in->hashAlg;\n\t    gc.platformPolicy = in->authPolicy;\n\t    // need to update orderly state\n\t    g_clearOrderly = TRUE;\n\t    break;\n\t  case TPM_RH_LOCKOUT:\n\t    gp.lockoutAlg = in->hashAlg;\n\t    gp.lockoutPolicy = in->authPolicy;\n\t    NV_SYNC_PERSISTENT(lockoutAlg);\n\t    NV_SYNC_PERSISTENT(lockoutPolicy);\n\t    break;\n\n#define SET_ACT_POLICY(N)\t\t\t\t\t\t\\\n\t    case TPM_RH_ACT_##N:\t\t\t\t\t\\\n\t      go.ACT_##N.hashAlg = in->hashAlg;\t\t\t\t\\\n\t      go.ACT_##N.authPolicy = in->authPolicy;\t\t\t\\\n\t      g_clearOrderly = TRUE;\t\t\t\t\t\\\n\t      break;\n\n\t    FOR_EACH_ACT(SET_ACT_POLICY)\n\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_SetPrimaryPolicy\n#include \"Tpm.h\"\n#include \"ChangePPS_fp.h\"\n#if CC_ChangePPS  // Conditional expansion of this file\nTPM_RC\nTPM2_ChangePPS(\n\t       ChangePPS_In    *in             // IN: input parameter list\n\t       )\n{\n    UINT32          i;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ChangePPS: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // Check if NV is available.  A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE\n    // error may be returned at this point\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Input parameter is not reference in command action\n    NOT_REFERENCED(in);\n    // Internal Data Update\n    // Reset platform hierarchy seed from RNG\n    CryptRandomGenerate(sizeof(gp.PPSeed.t.buffer), gp.PPSeed.t.buffer);\n    // Create a new phProof value from RNG to prevent the saved platform\n    // hierarchy contexts being loaded\n    CryptRandomGenerate(sizeof(gp.phProof.t.buffer), gp.phProof.t.buffer);\n    // Set platform authPolicy to null\n    gc.platformAlg = TPM_ALG_NULL;\n    gc.platformPolicy.t.size = 0;\n    // Flush loaded object in platform hierarchy\n    ObjectFlushHierarchy(TPM_RH_PLATFORM);\n    // Flush platform evict object and index in NV\n    NvFlushHierarchy(TPM_RH_PLATFORM);\n    // Save hierarchy changes to NV\n    NV_SYNC_PERSISTENT(PPSeed);\n    NV_SYNC_PERSISTENT(phProof);\n    // Re-initialize PCR policies\n#if defined NUM_POLICY_PCR_GROUP && NUM_POLICY_PCR_GROUP > 0\n    for(i = 0; i < NUM_POLICY_PCR_GROUP; i++)\n\t{\n\t    gp.pcrPolicies.hashAlg[i] = TPM_ALG_NULL;\n\t    gp.pcrPolicies.policy[i].t.size = 0;\n\t}\n    NV_SYNC_PERSISTENT(pcrPolicies);\n#endif\n    // orderly state should be cleared because of the update to state clear data\n    g_clearOrderly = TRUE;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_ChangePPS\n#include \"Tpm.h\"\n#include \"ChangeEPS_fp.h\"\n#if CC_ChangeEPS  // Conditional expansion of this file\nTPM_RC\nTPM2_ChangeEPS(\n\t       ChangeEPS_In    *in             // IN: input parameter list\n\t       )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ChangeEPS: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // The command needs NV update.  Check if NV is available.\n    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at\n    // this point\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Input parameter is not reference in command action\n    NOT_REFERENCED(in);\n    // Internal Data Update\n    // Reset endorsement hierarchy seed from RNG\n    CryptRandomGenerate(sizeof(gp.EPSeed.t.buffer), gp.EPSeed.t.buffer);\n    // Create new ehProof value from RNG\n    CryptRandomGenerate(sizeof(gp.ehProof.t.buffer), gp.ehProof.t.buffer);\n    // Enable endorsement hierarchy\n    gc.ehEnable = TRUE;\n    // set authValue buffer to zeros\n    MemorySet(gp.endorsementAuth.t.buffer, 0, gp.endorsementAuth.t.size);\n    // Set endorsement authValue to null\n    gp.endorsementAuth.t.size = 0;\n    // Set endorsement authPolicy to null\n    gp.endorsementAlg = TPM_ALG_NULL;\n    gp.endorsementPolicy.t.size = 0;\n    // Flush loaded object in endorsement hierarchy\n    ObjectFlushHierarchy(TPM_RH_ENDORSEMENT);\n    // Flush evict object of endorsement hierarchy stored in NV\n    NvFlushHierarchy(TPM_RH_ENDORSEMENT);\n    // Save hierarchy changes to NV\n    NV_SYNC_PERSISTENT(EPSeed);\n    NV_SYNC_PERSISTENT(ehProof);\n    NV_SYNC_PERSISTENT(endorsementAuth);\n    NV_SYNC_PERSISTENT(endorsementAlg);\n    NV_SYNC_PERSISTENT(endorsementPolicy);\n    // orderly state should be cleared because of the update to state clear data\n    g_clearOrderly = TRUE;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_ChangeEPS\n#include \"Tpm.h\"\n#include \"Clear_fp.h\"\n#if CC_Clear  // Conditional expansion of this file\nTPM_RC\nTPM2_Clear(\n\t   Clear_In        *in             // IN: input parameter list\n\t   )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Clear: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // Input parameter is not reference in command action\n    NOT_REFERENCED(in);\n    // The command needs NV update.  Check if NV is available.\n    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at\n    // this point\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Input Validation\n    // If Clear command is disabled, return an error\n    if(gp.disableClear)\n\treturn TPM_RC_DISABLED;\n    // Internal Data Update\n    // Reset storage hierarchy seed from RNG\n    CryptRandomGenerate(sizeof(gp.SPSeed.t.buffer), gp.SPSeed.t.buffer);\n    // Create new shProof and ehProof value from RNG\n    CryptRandomGenerate(sizeof(gp.shProof.t.buffer), gp.shProof.t.buffer);\n    CryptRandomGenerate(sizeof(gp.ehProof.t.buffer), gp.ehProof.t.buffer);\n    // Enable storage and endorsement hierarchy\n    gc.shEnable = gc.ehEnable = TRUE;\n    // set the authValue buffers to zero\n    MemorySet(&gp.ownerAuth, 0, sizeof(gp.ownerAuth));\n    MemorySet(&gp.endorsementAuth, 0, sizeof(gp.endorsementAuth));\n    MemorySet(&gp.lockoutAuth, 0, sizeof(gp.lockoutAuth));\n    // Set storage, endorsement, and lockout authPolicy to null\n    gp.ownerAlg = gp.endorsementAlg = gp.lockoutAlg = TPM_ALG_NULL;\n    MemorySet(&gp.ownerPolicy, 0, sizeof(gp.ownerPolicy));\n    MemorySet(&gp.endorsementPolicy, 0, sizeof(gp.endorsementPolicy));\n    MemorySet(&gp.lockoutPolicy, 0, sizeof(gp.lockoutPolicy));\n    // Flush loaded object in storage and endorsement hierarchy\n    ObjectFlushHierarchy(TPM_RH_OWNER);\n    ObjectFlushHierarchy(TPM_RH_ENDORSEMENT);\n    // Flush owner and endorsement object and owner index in NV\n    NvFlushHierarchy(TPM_RH_OWNER);\n    NvFlushHierarchy(TPM_RH_ENDORSEMENT);\n    // Initialize dictionary attack parameters\n    DAPreInstall_Init();\n    // Reset clock\n    go.clock = 0;\n    go.clockSafe = YES;\n    NvWrite(NV_ORDERLY_DATA, sizeof(ORDERLY_DATA), &go);\n    // Reset counters\n    gp.resetCount = gr.restartCount = gr.clearCount = 0;\n    gp.auditCounter = 0;\n    // Save persistent data changes to NV\n    // Note: since there are so many changes to the persistent data structure, the\n    // entire PERSISTENT_DATA structure is written as a unit\n    NvWrite(NV_PERSISTENT_DATA, sizeof(PERSISTENT_DATA), &gp);\n    // Reset the PCR authValues (this does not change the PCRs)\n    PCR_ClearAuth();\n    // Bump the PCR counter\n    PCRChanged(0);\n    // orderly state should be cleared because of the update to state clear data\n    g_clearOrderly = TRUE;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_Clear\n#include \"Tpm.h\"\n#include \"ClearControl_fp.h\"\n#if CC_ClearControl  // Conditional expansion of this file\nTPM_RC\nTPM2_ClearControl(\n\t\t  ClearControl_In     *in             // IN: input parameter list\n\t\t  )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ClearControl: auth %08x\\n\", in->auth);\n\t// fclose(f);\n  //   }\n    // The command needs NV update.\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Input Validation\n    // LockoutAuth may be used to set disableLockoutClear to TRUE but not to FALSE\n    if(in->auth == TPM_RH_LOCKOUT && in->disable == NO)\n\treturn TPM_RC_AUTH_FAIL;\n    // Internal Data Update\n    if(in->disable == YES)\n\tgp.disableClear = TRUE;\n    else\n\tgp.disableClear = FALSE;\n    // Record the change to NV\n    NV_SYNC_PERSISTENT(disableClear);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_ClearControl\n#include \"Tpm.h\"\n#include \"HierarchyChangeAuth_fp.h\"\n#if CC_HierarchyChangeAuth  // Conditional expansion of this file\n#include \"Object_spt_fp.h\"\nTPM_RC\nTPM2_HierarchyChangeAuth(\n\t\t\t HierarchyChangeAuth_In  *in             // IN: input parameter list\n\t\t\t )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_HierarchyChangeAuth: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // The command needs NV update.\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Make sure that the authorization value is a reasonable size (not larger than\n    // the size of the digest produced by the integrity hash. The integrity\n    // hash is assumed to produce the longest digest of any hash implemented\n    // on the TPM. This will also remove trailing zeros from the authValue.\n    if(MemoryRemoveTrailingZeros(&in->newAuth) > CONTEXT_INTEGRITY_HASH_SIZE)\n\treturn TPM_RCS_SIZE + RC_HierarchyChangeAuth_newAuth;\n    // Set hierarchy authValue\n    switch(in->authHandle)\n\t{\n\t  case TPM_RH_OWNER:\n\t    gp.ownerAuth = in->newAuth;\n\t    NV_SYNC_PERSISTENT(ownerAuth);\n\t    break;\n\t  case TPM_RH_ENDORSEMENT:\n\t    gp.endorsementAuth = in->newAuth;\n\t    NV_SYNC_PERSISTENT(endorsementAuth);\n\t    break;\n\t  case TPM_RH_PLATFORM:\n\t    gc.platformAuth = in->newAuth;\n\t    // orderly state should be cleared\n\t    g_clearOrderly = TRUE;\n\t    break;\n\t  case TPM_RH_LOCKOUT:\n\t    gp.lockoutAuth = in->newAuth;\n\t    NV_SYNC_PERSISTENT(lockoutAuth);\n\t    break;\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_HierarchyChangeAuth\n"
  },
  {
    "path": "ftpm-opensbi/src/IntegrityCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Integrity Collection (PCR)   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: IntegrityCommands.c 1490 2019-07-26 21:13:22Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"PCR_Extend_fp.h\"\n\nextern int verbose;\n\n#if CC_PCR_Extend  // Conditional expansion of this file\nTPM_RC\nTPM2_PCR_Extend(\n\t\tPCR_Extend_In   *in             // IN: input parameter list\n\t\t)\n{\n    UINT32              i;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PCR_Extend: pcrHandle %u\\n\", in->pcrHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // NOTE: This function assumes that the unmarshaling function for 'digests' will\n    // have validated that all of the indicated hash algorithms are valid. If the\n    // hash algorithms are correct, the unmarshaling code will unmarshal a digest\n    // of the size indicated by the hash algorithm. If the overall size is not\n    // consistent, the unmarshaling code will run out of input data or have input\n    // data left over. In either case, it will cause an unmarshaling error and this\n    // function will not be called.\n    // For NULL handle, do nothing and return success\n    if(in->pcrHandle == TPM_RH_NULL)\n\treturn TPM_RC_SUCCESS;\n    // Check if the extend operation is allowed by the current command locality\n    if(!PCRIsExtendAllowed(in->pcrHandle))\n\treturn TPM_RC_LOCALITY;\n    // If PCR is state saved and we need to update orderlyState, check NV\n    // availability\n    if(PCRIsStateSaved(in->pcrHandle))\n\tRETURN_IF_ORDERLY;\n    // Internal Data Update\n    // Iterate input digest list to extend\n    for(i = 0; i < in->digests.count; i++)\n\t{\n\t    PCRExtend(in->pcrHandle, in->digests.digests[i].hashAlg,\n\t\t      CryptHashGetDigestSize(in->digests.digests[i].hashAlg),\n\t\t      (BYTE *)&in->digests.digests[i].digest);\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PCR_Extend\n#include \"Tpm.h\"\n#include \"PCR_Event_fp.h\"\n#if CC_PCR_Event  // Conditional expansion of this file\nTPM_RC\nTPM2_PCR_Event(\n\t       PCR_Event_In    *in,            // IN: input parameter list\n\t       PCR_Event_Out   *out            // OUT: output parameter list\n\t       )\n{\n    HASH_STATE          hashState;\n    UINT32              i;\n    UINT16              size;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PCR_Event: pcrHandle %u\\n\", in->pcrHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // If a PCR extend is required\n    if(in->pcrHandle != TPM_RH_NULL)\n\t{\n\t    // If the PCR is not allow to extend, return error\n\t    if(!PCRIsExtendAllowed(in->pcrHandle))\n\t\treturn TPM_RC_LOCALITY;\n\t    // If PCR is state saved and we need to update orderlyState, check NV\n\t    // availability\n\t    if(PCRIsStateSaved(in->pcrHandle))\n\t\tRETURN_IF_ORDERLY;\n\t}\n    // Internal Data Update\n    out->digests.count = HASH_COUNT;\n    // Iterate supported PCR bank algorithms to extend\n    for(i = 0; i < HASH_COUNT; i++)\n\t{\n\t    TPM_ALG_ID  hash = CryptHashGetAlgByIndex(i);\n\t    out->digests.digests[i].hashAlg = hash;\n\t    size = CryptHashStart(&hashState, hash);\n\t    CryptDigestUpdate2B(&hashState, &in->eventData.b);\n\t    CryptHashEnd(&hashState, size,\n\t\t\t (BYTE *)&out->digests.digests[i].digest);\n\t    if(in->pcrHandle != TPM_RH_NULL)\n\t\tPCRExtend(in->pcrHandle, hash, size,\n\t\t\t  (BYTE *)&out->digests.digests[i].digest);\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PCR_Event\n#include \"Tpm.h\"\n#include \"PCR_Read_fp.h\"\n#if CC_PCR_Read  // Conditional expansion of this file\nTPM_RC\nTPM2_PCR_Read(\n\t      PCR_Read_In     *in,            // IN: input parameter list\n\t      PCR_Read_Out    *out            // OUT: output parameter list\n\t      )\n{\n    // Command Output\n    // Call PCR read function.  input pcrSelectionIn parameter could be changed\n    // to reflect the actual PCR being returned\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PCR_Read:\\n\");\n\t// fclose(f);\n  //   }\n    PCRRead(&in->pcrSelectionIn, &out->pcrValues, &out->pcrUpdateCounter);\n    out->pcrSelectionOut = in->pcrSelectionIn;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PCR_Read\n#include \"Tpm.h\"\n#include \"PCR_Allocate_fp.h\"\n#if CC_PCR_Allocate  // Conditional expansion of this file\nTPM_RC\nTPM2_PCR_Allocate(\n\t\t  PCR_Allocate_In     *in,            // IN: input parameter list\n\t\t  PCR_Allocate_Out    *out            // OUT: output parameter list\n\t\t  )\n{\n    TPM_RC      result;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PCR_Allocate: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // The command needs NV update.  Check if NV is available.\n    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at\n    // this point.\n    // Note: These codes are not listed in the return values above because it is\n    // an implementation choice to check in this routine rather than in a common\n    // function that is called before these actions are called. These return values\n    // are described in the Response Code section of Part 3.\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Command Output\n    // Call PCR Allocation function.\n    result = PCRAllocate(&in->pcrAllocation, &out->maxPCR,\n\t\t\t &out->sizeNeeded, &out->sizeAvailable);\n    if(result == TPM_RC_PCR)\n\treturn result;\n    //\n    out->allocationSuccess = (result == TPM_RC_SUCCESS);\n    // if re-configuration succeeds, set the flag to indicate PCR configuration is\n    // going to be changed in next boot\n    if(out->allocationSuccess == YES)\n\tg_pcrReConfig = TRUE;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PCR_Allocate\n#include \"Tpm.h\"\n#include \"PCR_SetAuthPolicy_fp.h\"\n#if CC_PCR_SetAuthPolicy  // Conditional expansion of this file\nTPM_RC\nTPM2_PCR_SetAuthPolicy(\n\t\t       PCR_SetAuthPolicy_In    *in             // IN: input parameter list\n\t\t       )\n{\n    UINT32      groupIndex;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PCR_SetAuthPolicy: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // The command needs NV update.  Check if NV is available.\n    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at\n    // this point\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Input Validation:\n    // Check the authPolicy consistent with hash algorithm\n    if(in->authPolicy.t.size != CryptHashGetDigestSize(in->hashAlg))\n\treturn TPM_RCS_SIZE + RC_PCR_SetAuthPolicy_authPolicy;\n    // If PCR does not belong to a policy group, return TPM_RC_VALUE\n    if(!PCRBelongsPolicyGroup(in->pcrNum, &groupIndex))\n\treturn TPM_RCS_VALUE + RC_PCR_SetAuthPolicy_pcrNum;\n    // Internal Data Update\n    // Set PCR policy\n    gp.pcrPolicies.hashAlg[groupIndex] = in->hashAlg;\n    gp.pcrPolicies.policy[groupIndex] = in->authPolicy;\n    // Save new policy to NV\n    NV_SYNC_PERSISTENT(pcrPolicies);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PCR_SetAuthPolicy\n#include \"Tpm.h\"\n#include \"PCR_SetAuthValue_fp.h\"\n#if CC_PCR_SetAuthValue  // Conditional expansion of this file\n// CC_PCR_SetAuthPolicy\nTPM_RC\nTPM2_PCR_SetAuthValue(\n\t\t      PCR_SetAuthValue_In     *in             // IN: input parameter list\n\t\t      )\n{\n    UINT32      groupIndex;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PCR_SetAuthValue: pcrHandle %d\\n\", in->pcrHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation:\n    // If PCR does not belong to an auth group, return TPM_RC_VALUE\n    if(!PCRBelongsAuthGroup(in->pcrHandle, &groupIndex))\n\treturn TPM_RC_VALUE;\n    // The command may cause the orderlyState to be cleared due to the update of\n    // state clear data.  If this is the case, Check if NV is available.\n    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at\n    // this point\n    RETURN_IF_ORDERLY;\n    // Internal Data Update\n    // Set PCR authValue\n    MemoryRemoveTrailingZeros(&in->auth);\n    gc.pcrAuthValues.auth[groupIndex] = in->auth;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PCR_SetAuthValue\n#include \"Tpm.h\"\n#include \"PCR_Reset_fp.h\"\n#if CC_PCR_Reset  // Conditional expansion of this file\nTPM_RC\nTPM2_PCR_Reset(\n\t       PCR_Reset_In    *in             // IN: input parameter list\n\t       )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PCR_Reset: pcrHandle %d\\n\", in->pcrHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Check if the reset operation is allowed by the current command locality\n    if(!PCRIsResetAllowed(in->pcrHandle))\n\treturn TPM_RC_LOCALITY;\n    // If PCR is state saved and we need to update orderlyState, check NV\n    // availability\n    if(PCRIsStateSaved(in->pcrHandle))\n\tRETURN_IF_ORDERLY;\n    // Internal Data Update\n    // Reset selected PCR in all banks to 0\n    PCRSetValue(in->pcrHandle, 0);\n    // Indicate that the PCR changed so that pcrCounter will be incremented if\n    // necessary.\n    PCRChanged(in->pcrHandle);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PCR_Reset\n\n#include \"Tpm.h\"\n/* This function is called to process a _TPM_Hash_Start() indication. */\nLIB_EXPORT void\n_TPM_Hash_Start(\n\t\tvoid\n\t\t)\n{\n    TPM_RC              result;\n    TPMI_DH_OBJECT      handle;\n    // If a DRTM sequence object exists, free it up\n    if(g_DRTMHandle != TPM_RH_UNASSIGNED)\n\t{\n\t    FlushObject(g_DRTMHandle);\n\t    g_DRTMHandle = TPM_RH_UNASSIGNED;\n\t}\n    // Create an event sequence object and store the handle in global\n    // g_DRTMHandle. A TPM_RC_OBJECT_MEMORY error may be returned at this point\n    // The NULL value for the first parameter will cause the sequence structure to\n    // be allocated without being set as present. This keeps the sequence from\n    // being left behind if the sequence is terminated early.\n    result = ObjectCreateEventSequence(NULL, &g_DRTMHandle);\n    // If a free slot was not available, then free up a slot.\n    if(result != TPM_RC_SUCCESS)\n\t{\n\t    // An implementation does not need to have a fixed relationship between\n\t    // slot numbers and handle numbers. To handle the general case, scan for\n\t    // a handle that is assigned and free it for the DRTM sequence.\n\t    // In the reference implementation, the relationship between handles and\n\t    // slots is fixed. So, if the call to ObjectCreateEvenSequence()\n\t    // failed indicating that all slots are occupied, then the first handle we\n\t    // are going to check (TRANSIENT_FIRST) will be occupied. It will be freed\n\t    // so that it can be assigned for use as the DRTM sequence object.\n\t    for(handle = TRANSIENT_FIRST; handle < TRANSIENT_LAST; handle++)\n\t\t{\n\t\t    // try to flush the first object\n\t\t    if(IsObjectPresent(handle))\n\t\t\tbreak;\n\t\t}\n\t    // If the first call to find a slot fails but none of the slots is occupied\n\t    // then there's a big problem\n\t    pAssert(handle < TRANSIENT_LAST);\n\t    // Free the slot\n\t    FlushObject(handle);\n\t    // Try to create an event sequence object again.  This time, we must\n\t    // succeed.\n\t    result = ObjectCreateEventSequence(NULL, &g_DRTMHandle);\n\t    if(result != TPM_RC_SUCCESS)\n\t\tFAIL(FATAL_ERROR_INTERNAL);\n\t}\n    return;\n}\n\n#include \"Tpm.h\"\n/* This function is called to process a _TPM_Hash_Data() indication. */\nLIB_EXPORT void\n_TPM_Hash_Data(\n\t       uint32_t         dataSize,      // IN: size of data to be extend\n\t       unsigned char   *data           // IN: data buffer\n\t       )\n{\n    UINT32           i;\n    HASH_OBJECT     *hashObject;\n    TPMI_DH_PCR      pcrHandle = TPMIsStarted()\n\t\t\t\t ? PCR_FIRST + DRTM_PCR : PCR_FIRST + HCRTM_PCR;\n    // If there is no DRTM sequence object, then _TPM_Hash_Start\n    // was not called so this function returns without doing\n    // anything.\n    if(g_DRTMHandle == TPM_RH_UNASSIGNED)\n\treturn;\n    hashObject = (HASH_OBJECT *)HandleToObject(g_DRTMHandle);\n    pAssert(hashObject->attributes.eventSeq);\n    // For each of the implemented hash algorithms, update the digest with the\n    // data provided.\n    for(i = 0; i < HASH_COUNT; i++)\n\t{\n\t    // make sure that the PCR is implemented for this algorithm\n\t    if(PcrIsAllocated(pcrHandle,\n\t\t\t      hashObject->state.hashState[i].hashAlg))\n\t\t// Update sequence object\n\t\tCryptDigestUpdate(&hashObject->state.hashState[i], dataSize, data);\n\t}\n    return;\n}\n\n#include \"Tpm.h\"\n/* This function is called to process a _TPM_Hash_End() indication. */\nLIB_EXPORT void\n_TPM_Hash_End(\n\t      void\n\t      )\n{\n    UINT32          i;\n    TPM2B_DIGEST    digest;\n    HASH_OBJECT    *hashObject;\n    TPMI_DH_PCR     pcrHandle;\n    // If the DRTM handle is not being used, then either _TPM_Hash_Start has not\n    // been called, _TPM_Hash_End was previously called, or some other command\n    // was executed and the sequence was aborted.\n    if(g_DRTMHandle == TPM_RH_UNASSIGNED)\n\treturn;\n    // Get DRTM sequence object\n    hashObject = (HASH_OBJECT *)HandleToObject(g_DRTMHandle);\n    // Is this _TPM_Hash_End after Startup or before\n    if(TPMIsStarted())\n\t{\n\t    // After\n\t    // Reset the DRTM PCR\n\t    PCRResetDynamics();\n\t    // Extend the DRTM_PCR.\n\t    pcrHandle = PCR_FIRST + DRTM_PCR;\n\t    // DRTM sequence increments restartCount\n\t    gr.restartCount++;\n\t}\n    else\n\t{\n\t    pcrHandle = PCR_FIRST + HCRTM_PCR;\n\t    g_DrtmPreStartup = TRUE;\n\t}\n    // Complete hash and extend PCR, or if this is an HCRTM, complete\n    // the hash, reset the H-CRTM register (PCR[0]) to 0...04, and then\n    // extend the H-CRTM data\n    for(i = 0; i < HASH_COUNT; i++)\n\t{\n\t    TPMI_ALG_HASH       hash = CryptHashGetAlgByIndex(i);\n\t    // make sure that the PCR is implemented for this algorithm\n\t    if(PcrIsAllocated(pcrHandle,\n\t\t\t      hashObject->state.hashState[i].hashAlg))\n\t\t{\n\t\t    // Complete hash\n\t\t    digest.t.size = CryptHashGetDigestSize(hash);\n\t\t    CryptHashEnd2B(&hashObject->state.hashState[i], &digest.b);\n\t\t    PcrDrtm(pcrHandle, hash, &digest);\n\t\t}\n\t}\n    // Flush sequence object.\n    FlushObject(g_DRTMHandle);\n    g_DRTMHandle = TPM_RH_UNASSIGNED;\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/IoBuffers.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    I/O Buffers\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: IoBuffers.c 1311 2018-08-23 21:39:29Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.7\tIoBuffers.c */\n/* 9.7.1\tIncludes and Data Definitions */\n/* This definition allows this module to see the values that are private to this module but kept in\n   Global.c for ease of state migration. */\n#define IO_BUFFER_C\n#include \"Tpm.h\"\n#include \"IoBuffers_fp.h\"\n/* 9.7.2\tBuffers and Functions */\n/* These buffers are set aside to hold command and response values. In this implementation, it is\n   not guaranteed that the code will stop accessing the s_actionInputBuffer before starting to put\n   values in the s_actionOutputBuffer so different buffers are required. */\n/*     9.7.2.1 MemoryIoBufferAllocationReset() */\n/*     This function is used to reset the allocation of buffers. */\nvoid\nMemoryIoBufferAllocationReset(\n\t\t\t      void\n\t\t\t      )\n{\n    s_actionIoAllocation = 0;\n}\n/* 9.7.2.2\tMemoryIoBufferZero() */\n/* Function zeros the action I/O buffer at the end of a command. Calling this is not mandatory for\n   proper functionality. */\nvoid\nMemoryIoBufferZero(\n\t\t   void\n\t\t   )\n{\n    memset(s_actionIoBuffer, 0, s_actionIoAllocation);\n}\n/* 9.7.2.3\tMemoryGetInBuffer() */\n/* This function returns the address of the buffer into which the command parameters will be\n   unmarshaled in preparation for calling the command actions. */\nBYTE *\nMemoryGetInBuffer(\n\t\t  UINT32           size           // Size, in bytes, required for the input\n\t\t  // unmarshaling\n\t\t  )\n{\n    pAssert(size <= sizeof(s_actionIoBuffer));\n    // In this implementation, a static buffer is set aside for the command action\n    // buffers. The buffer is shared between input and output. This is because\n    // there is no need to allocate for the worst case input and worst case output\n    // at the same time.\n    // Round size up\n#define UoM  (sizeof(s_actionIoBuffer[0]))\n    size = (size + (UoM - 1)) & (UINT32_MAX - (UoM - 1));\n    memset(s_actionIoBuffer, 0, size);\n    s_actionIoAllocation = size;\n    return (BYTE *)&s_actionIoBuffer[0];\n}\n/* 9.7.2.4\tMemoryGetOutBuffer() */\n/* This function returns the address of the buffer into which the command action code places its\n   output values. */\nBYTE *\nMemoryGetOutBuffer(\n\t\t   UINT32           size           // required size of the buffer\n\t\t   )\n{\n    BYTE        *retVal = (BYTE *)(&s_actionIoBuffer[s_actionIoAllocation / UoM]);\n    pAssert((size + s_actionIoAllocation) < (sizeof(s_actionIoBuffer)));\n    // In this implementation, a static buffer is set aside for the command action\n    // output buffer.\n    memset(retVal, 0, size);\n    s_actionIoAllocation += size;\n    return retVal;\n}\n/* 9.7.2.5\tIsLabelProperlyFormatted() */\n/* This function checks that a label is a null-terminated string. */\n/* NOTE:\tthis function is here because there was no better place for it. */\n/* Return Value\tMeaning */\n/* FALSE\tstring is not null terminated */\n/* TRUE\tstring is null terminated */\n\nBOOL\nIsLabelProperlyFormatted(\n\t\t\t TPM2B           *x\n\t\t\t )\n{\n    return (((x)->size == 0) || ((x)->buffer[(x)->size - 1] == 0));\n}\n\n\n\n"
  },
  {
    "path": "ftpm-opensbi/src/LICENSE",
    "content": "$Id: LICENSE 1577 2020-02-24 14:49:35Z kgoldman $\n\n  Licenses and Notices\n\n  1. Copyright Licenses:\n\n  - Trusted Computing Group (TCG) grants to the user of the source code in\n    this specification (the \"Source Code\") a worldwide, irrevocable,\n    nonexclusive, royalty free, copyright license to reproduce, create\n    derivative works, distribute, display and perform the Source Code and\n    derivative works thereof, and to grant others the rights granted herein.\n\n  - The TCG grants to the user of the other parts of the specification\n    (other than the Source Code) the rights to reproduce, distribute,\n    display, and perform the specification solely for the purpose of\n    developing products based on such documents.\n\t\t\t\n  2. Source Code Distribution Conditions:\n\t\t\t\t\n  - Redistributions of Source Code must retain the above copyright licenses,\n    this list of conditions and the following disclaimers.\n\n  - Redistributions in binary form must reproduce the above copyright\n    licenses, this list of conditions\tand the following disclaimers in the\n    documentation and/or other materials provided with the distribution.\n\n  3. Disclaimers:\n\n  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\n  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\n  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\n  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\n  Contact TCG Administration (admin@trustedcomputinggroup.org) for\n  information on specification licensing rights available through TCG\n  membership agreements.\n\n  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED\n    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR\n    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR\n    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY\n    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\n\n  - Without limitation, TCG and its members and licensors disclaim all\n    liability, including liability for infringement of any proprietary\n    rights, relating to use of information in this specification and to the\n    implementation of this specification, and TCG disclaims all liability for\n    cost of procurement of substitute goods or services, lost profits, loss\n    of use, loss of data or any incidental, consequential, direct, indirect,\n    or special damages, whether under contract, tort, warranty or otherwise,\n    arising in any way out of use or reliance upon this specification or any\n    information herein.\n\n  (c) Copyright IBM Corp. and others, 2016 - 2019\n\n"
  },
  {
    "path": "ftpm-opensbi/src/Locality.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Locality.c 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016, 2017\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.8 Locality.c */\n/* 9.8.1 Includes */\n#include \"Tpm.h\"\n/* 9.8.2 LocalityGetAttributes() */\n/* This function will convert a locality expressed as an integer into TPMA_LOCALITY form. */\n/* The function returns the locality attribute. */\nTPMA_LOCALITY\nLocalityGetAttributes(\n\t\t      UINT8            locality       // IN: locality value\n\t\t      )\n{\n    TPMA_LOCALITY            locality_attributes;\n    BYTE                    *localityAsByte = (BYTE *)&locality_attributes;\n    MemorySet(&locality_attributes, 0, sizeof(TPMA_LOCALITY));\n    switch(locality)\n\t{\n\t  case 0:\n\t    SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_ZERO);\n\t    break;\n\t  case 1:\n\t    SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_ONE);\n\t    break;\n\t  case 2:\n\t    SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_TWO);\n\t    break;\n\t  case 3:\n\t    SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_THREE);\n\t    break;\n\t  case 4:\n\t    SET_ATTRIBUTE(locality_attributes, TPMA_LOCALITY, TPM_LOC_FOUR);\n\t    break;\n\t  default:\n\t    pAssert(locality > 31);\n\t    *localityAsByte = locality;\n\t    break;\n\t}\n    return locality_attributes;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/LocalityPlat.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Platform Locality Support\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: LocalityPlat.c 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.5 LocalityPlat.c */\n/* C.5.1. Includes */\n#include \"Platform.h\"\n/* C.5.2. Functions */\n/* C.5.2.1. _plat__LocalityGet() */\n/* Get the most recent command locality in locality value form. This is an integer value for\n   locality and not a locality structure The locality can be 0-4 or 32-255. 5-31 is not allowed. */\nLIB_EXPORT unsigned char\n_plat__LocalityGet(\n\t\t   void\n\t\t   )\n{\n    return s_locality;\n}\n/* C.5.2.2. _plat__LocalitySet() */\n/* Set the most recent command locality in locality value form */\nLIB_EXPORT void\n_plat__LocalitySet(\n\t\t   unsigned char    locality\n\t\t   )\n{\n    if(locality > 4 && locality < 32)\n\tlocality = 0;\n    s_locality = locality;\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/ManagementCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tMiscellaneous Management Functions\t   \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: ManagementCommands.c 1490 2019-07-26 21:13:22Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"PP_Commands_fp.h\"\n\nextern int verbose;\n\n#if CC_PP_Commands  // Conditional expansion of this file\nTPM_RC\nTPM2_PP_Commands(\n\t\t PP_Commands_In  *in             // IN: input parameter list\n\t\t )\n{\n    UINT32          i;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PP_Commands: auth %08x\\n\", in->auth);\n\t// fclose(f);\n  //   }\n    // The command needs NV update.  Check if NV is available.\n    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at\n    // this point\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Internal Data Update\n    // Process set list\n    for(i = 0; i < in->setList.count; i++)\n\t// If command is implemented, set it as PP required.  If the input\n\t// command is not a PP command, it will be ignored at\n\t// PhysicalPresenceCommandSet().\n\t// Note: PhysicalPresenceCommandSet() checks if the command is implemented.\n\tPhysicalPresenceCommandSet(in->setList.commandCodes[i]);\n    // Process clear list\n    for(i = 0; i < in->clearList.count; i++)\n\t// If command is implemented, clear it as PP required.  If the input\n\t// command is not a PP command, it will be ignored at\n\t// PhysicalPresenceCommandClear().  If the input command is\n\t// TPM2_PP_Commands, it will be ignored as well\n\tPhysicalPresenceCommandClear(in->clearList.commandCodes[i]);\n    // Save the change of PP list\n    NV_SYNC_PERSISTENT(ppList);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PP_Commands\n#include \"Tpm.h\"\n#include \"SetAlgorithmSet_fp.h\"\n#if CC_SetAlgorithmSet  // Conditional expansion of this file\nTPM_RC\nTPM2_SetAlgorithmSet(\n\t\t     SetAlgorithmSet_In  *in             // IN: input parameter list\n\t\t     )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_SetAlgorithmSet: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // The command needs NV update.  Check if NV is available.\n    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at\n    // this point\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Internal Data Update\n    gp.algorithmSet = in->algorithmSet;\n    // Write the algorithm set changes to NV\n    NV_SYNC_PERSISTENT(algorithmSet);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_SetAlgorithmSet\n"
  },
  {
    "path": "ftpm-opensbi/src/Manufacture.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tPerforms the manufacturing of the TPM \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.9 Manufacture.c */\n/* 9.9.1 Description */\n/* This file contains the function that performs the manufacturing of the TPM in a simulated\n   environment. These functions should not be used outside of a manufacturing or simulation\n   environment. */\n/* 9.9.2 Includes and Data Definitions */\n#define MANUFACTURE_C\n#include \"Tpm.h\"\n#include \"TpmSizeChecks_fp.h\"\n/* 9.9.3 Functions */\n/* 9.9.3.1 TPM_Manufacture() */\n/* This function initializes the TPM values in preparation for the TPMs first use. This function\n   will fail if previously called. The TPM can be re-manufactured by calling TPM_Teardown() first\n   and then calling this function again. */\n/* Return Values Meaning */\n/* -1 failure */\n/* 0 success */\n/* 1 manufacturing process previously performed */\nLIB_EXPORT int\nTPM_Manufacture(\n\t\tint             firstTime       // IN: indicates if this is the first call from\n\t\t\t\t\t\t// main()\n\t\t)\n{\n    TPM_SU          orderlyShutdown;\n\n#if RUNTIME_SIZE_CHECKS\n    // Call the function to verify the sizes of values that result from different\n    // compile options.\n    if(!TpmSizeChecks())\n\treturn MANUF_INVALID_CONFIG;\n#endif\n\n#if LIBRARY_COMPATIBILITY_CHECK\n    // Make sure that the attached library performs as expected.\n    if(!ExtMath_Debug_CompatibilityCheck())\n\treturn MANUF_INVALID_CONFIG;\n#endif\n\n    // If TPM has been manufactured, return indication.\n    if(!firstTime && g_manufactured)\n\treturn MANUF_ALREADY_DONE;\n    // trigger failure mode if called in error.\n\n    int nvReadyState = _plat__GetNvReadyState();\n    pAssert(nvReadyState == NV_READY);  // else failure mode\n    if(nvReadyState != NV_READY)\n\t{\n\t    return MANUF_NV_NOT_READY;\n\t}    // Do power on initializations of the cryptographic libraries.\n    CryptInit();\n    s_DAPendingOnNV = FALSE;\n\n    // initialize NV\n    NvManufacture();\n\n    // Clear the magic value in the DRBG state\n    go.drbgState.magic = 0;\n\n    CryptStartup(SU_RESET);\n\n    // default configuration for PCR\n    PCRManufacture();\n\n    // initialize pre-installed hierarchy data\n    // This should happen after NV is initialized because hierarchy data is\n    // stored in NV.\n    HierarchyPreInstall_Init();\n    // initialize dictionary attack parameters\n    DAPreInstall_Init();\n    // initialize PP list\n    PhysicalPresencePreInstall_Init();\n    // initialize command audit list\n    CommandAuditPreInstall_Init();\n    // first start up is required to be Startup(CLEAR)\n    orderlyShutdown = TPM_SU_CLEAR;\n    NV_WRITE_PERSISTENT(orderlyState, orderlyShutdown);\n    // initialize the firmware version\n    gp.firmwareV1 = _plat__GetTpmFirmwareVersionHigh();\n    gp.firmwareV2 = _plat__GetTpmFirmwareVersionLow();\n\n    _plat__GetPlatformManufactureData(gp.platformReserved,\n\t\t\t\t      sizeof(gp.platformReserved));\n\n    NV_SYNC_PERSISTENT(platformReserved);\n\n    NV_SYNC_PERSISTENT(firmwareV1);\n    NV_SYNC_PERSISTENT(firmwareV2);\n\n    // initialize the total reset counter to 0\n    gp.totalResetCount = 0;\n    NV_SYNC_PERSISTENT(totalResetCount);\n    // initialize the clock stuff\n    go.clock = 0;\n    go.clockSafe = YES;\n    NvWrite(NV_ORDERLY_DATA, sizeof(ORDERLY_DATA), &go);\n    // Commit NV writes.  Manufacture process is an artificial process existing\n    // only in simulator environment and it is not defined in the specification\n    // that what should be the expected behavior if the NV write fails at this\n    // point.  Therefore, it is assumed the NV write here is always success and\n    // no return code of this function is checked.\n    NvCommit();\n    g_manufactured = TRUE;\n    return 0;\n}\n/* 9.9.3.2 TPM_TearDown() */\n/* This function prepares the TPM for re-manufacture. It should not be implemented in anything other\n   than a simulated TPM. */\n/* In this implementation, all that is needs is to stop the cryptographic units and set a flag to\n   indicate that the TPM can be re-manufactured. This should be all that is necessary to start the\n   manufacturing process again. */\n/* Return Values Meaning */\n/* 0 success */\n/* 1 TPM not previously manufactured */\nLIB_EXPORT int\nTPM_TearDown(\n\t     void\n\t     )\n{\n    g_manufactured = FALSE;\n    return 0;\n}\n/* 9.9.3.3 TpmEndSimulation() */\n/* This function is called at the end of the simulation run. It is used to provoke printing of any\n   statistics that might be needed. */\nLIB_EXPORT void\nTpmEndSimulation(\n\t\t void\n\t\t )\n{\n#if SIMULATION\n    HashLibSimulationEnd();\n    SymLibSimulationEnd();\n    MathLibSimulationEnd();\n#if ALG_RSA\n    RsaSimulationEnd();\n#endif\n#if ALG_ECC\n    EccSimulationEnd();\n#endif\n#endif // SIMULATION\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/Marshal.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Parameter Marshaling   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include <string.h>\n\n#include \"Tpm.h\"\n#include \"Marshal_fp.h\"\n\nUINT16\nUINT8_Marshal(UINT8 *source, BYTE **buffer, INT32 *size)\n{\n    if (buffer != NULL) {\n\tif ((size == NULL) || ((UINT32)*size >= sizeof(UINT8))) {\n\n\t    (*buffer)[0] = *source;\n\t    *buffer += sizeof(UINT8);\n\n\t    if (size != NULL) {\n\t\t*size -= sizeof(UINT8);\n\t    }\n\t}\n\telse {\n\t    pAssert(FALSE);\n\t}\n    }\n    return sizeof(UINT8);\n}\n\nUINT16\nUINT16_Marshal(UINT16 *source, BYTE **buffer, INT32 *size)\n{\n    if (buffer != NULL) {\n\tif ((size == NULL) || ((UINT32)*size >= sizeof(UINT16))) {\n\n\t    (*buffer)[0] = (BYTE)((*source >> 8) & 0xff);\n\t    (*buffer)[1] = (BYTE)((*source >> 0) & 0xff);\n\t    *buffer += sizeof(UINT16);\n\n\t    if (size != NULL) {\n\t\t*size -= sizeof(UINT16);\n\t    }\n\t}\n\telse {\n\t    pAssert(FALSE);\n\t}\n    }\n    return sizeof(UINT16);\n}\n\nUINT16\nUINT32_Marshal(UINT32 *source, BYTE **buffer, INT32 *size)\n{\n    if (buffer != NULL) {\n\tif ((size == NULL) || ((UINT32)*size >= sizeof(UINT32))) {\n\n\t    (*buffer)[0] = (BYTE)((*source >> 24) & 0xff);\n\t    (*buffer)[1] = (BYTE)((*source >> 16) & 0xff);\n\t    (*buffer)[2] = (BYTE)((*source >>  8) & 0xff);\n\t    (*buffer)[3] = (BYTE)((*source >>  0) & 0xff);\n\t    *buffer += sizeof(UINT32);\n\n\t    if (size != NULL) {\n\t\t*size -= sizeof(UINT32);\n\t    }\n\t}\n\telse {\n\t    pAssert(FALSE);\n\t}\n    }\n    return sizeof(UINT32);\n}\n\nUINT16\nUINT64_Marshal(UINT64 *source, BYTE **buffer, INT32 *size)\n{\n    if (buffer != NULL) {\n\tif ((size == NULL) || ((UINT32)*size >= sizeof(UINT64))) {\n\n\t    (*buffer)[0] = (BYTE)((*source >> 56) & 0xff);\n\t    (*buffer)[1] = (BYTE)((*source >> 48) & 0xff);\n\t    (*buffer)[2] = (BYTE)((*source >> 40) & 0xff);\n\t    (*buffer)[3] = (BYTE)((*source >> 32) & 0xff);\n\t    (*buffer)[4] = (BYTE)((*source >> 24) & 0xff);\n\t    (*buffer)[5] = (BYTE)((*source >> 16) & 0xff);\n\t    (*buffer)[6] = (BYTE)((*source >>  8) & 0xff);\n\t    (*buffer)[7] = (BYTE)((*source >>  0) & 0xff);\n\t    *buffer += sizeof(UINT64);\n\n\t    if (size != NULL) {\n\t\t*size -= sizeof(UINT64);\n\t    }\n\t}\n\telse {\n\t    pAssert(FALSE);\n\t}\n    }\n    return sizeof(UINT64);\n}\n\nUINT16\nArray_Marshal(BYTE *sourceBuffer, UINT16 sourceSize, BYTE **buffer, INT32 *size)\n{\n    if (buffer != NULL) {\n\tif ((size == NULL) || (*size >= sourceSize)) {\n\t    memcpy(*buffer, sourceBuffer, sourceSize);\n\n\t    *buffer += sourceSize;\n\n\t    if (size != NULL) {\n\t\t*size -= sourceSize;\n\t    }\n\t}\n\telse {\n\t    pAssert(FALSE);\n\t}\n    }\n    return sourceSize;\n}\n\nUINT16\nTPM2B_Marshal(TPM2B *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT16_Marshal(&(source->size), buffer, size);\n    written += Array_Marshal(source->buffer, source->size, buffer, size);\n    return written;\n}\n\n/* Table 2:5 - Definition of Types for Documentation Clarity (TypedefTable()) */\n\nUINT16\nTPM_KEY_BITS_Marshal(TPM_KEY_BITS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT16_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:7 - Definition of TPM_CONSTANTS32 Constants (EnumTable()) */\nUINT16\nTPM_CONSTANTS32_Marshal(TPM_CONSTANTS32 *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */\n\nUINT16\nTPM_ALG_ID_Marshal(TPM_ALG_ID *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT16_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */\n\n#if ALG_ECC\nUINT16\nTPM_ECC_CURVE_Marshal(TPM_ECC_CURVE *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT16_Marshal(source, buffer, size);\n    return written;\n}\n#endif\n\n/* Table 12 - Definition of TPM_CC Constants */\n\nUINT16\nTPM_CC_Marshal(TPM_CC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:16 - Definition of TPM_RC Constants (EnumTable()) */\n\nUINT16\nTPM_RC_Marshal(TPM_RC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:19 - Definition of TPM_ST Constants (EnumTable()) */\n\nUINT16\nTPM_ST_Marshal(TPM_ST *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT16_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:22 - Definition of TPM_CAP Constants (EnumTable()) */\n\nINT16\nTPM_CAP_Marshal(TPM_CAP *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:23 - Definition of TPM_PT Constants (EnumTable()) */\n\nUINT16\nTPM_PT_Marshal(TPM_PT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:24 - Definition of TPM_PT_PCR Constants (EnumTable()) */\n\nUINT16\nTPM_PT_PCR_Marshal(TPM_PT_PCR *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:26 - Definition of Types for Handles (TypedefTable()) */\n\nUINT16\nTPM_HANDLE_Marshal(TPM_HANDLE *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:30 - Definition of TPMA_ALGORITHM Bits (BitsTable()) */\n\nUINT16\nTPMA_ALGORITHM_Marshal(TPMA_ALGORITHM *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal((UINT32 *)source, buffer, size);\n    return written;\n}\n\n/* Table 2:31 - Definition of TPMA_OBJECT Bits (BitsTable()) */\n\nUINT16\nTPMA_OBJECT_Marshal(TPMA_OBJECT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal((UINT32 *)source, buffer, size);\n    return written;\n}\n\n/* Table 2:32 - Definition of TPMA_SESSION Bits (BitsTable()) */\n\nUINT16\nTPMA_SESSION_Marshal(TPMA_SESSION *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT8_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:33 - Definition of TPMA_LOCALITY Bits (BitsTable()) */\n\nUINT16\nTPMA_LOCALITY_Marshal(TPMA_LOCALITY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT8_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:37 - Definition of TPMA_CC Bits (BitsTable()) */\n\nUINT16\nTPMA_CC_Marshal(TPMA_CC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal((UINT32 *)source, buffer, size);\n    return written;\n}\n\n/* Table 2:39 - Definition of TPMI_YES_NO Type (InterfaceTable()) */\n\nUINT16\nTPMI_YES_NO_Marshal(TPMI_YES_NO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT8_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 40 - Definition of (UINT32) TPMA_ACT Bits */\n\nUINT16\nTPMA_ACT_Marshal(TPMA_ACT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal((UINT32 *)source, buffer, size);\n    return written;\n}\n\n/* Table 2:49 - Definition of TPMI_DH_SAVED Type (InterfaceTable()) */\n\nUINT16\nTPMI_DH_SAVED_Marshal(TPMI_DH_CONTEXT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_HANDLE_Marshal(source, buffer, size);\n    return written;\n}\n\n//* Table 2:49 - Definition of TPMI_RH_HIERARCHY Type (InterfaceTable()) */\n\nUINT16\nTPMI_RH_HIERARCHY_Marshal(TPMI_RH_HIERARCHY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_HANDLE_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:59 - Definition of TPMI_RH_NV_INDEX Type (InterfaceTable()) */\n\nUINT16\nTPMI_RH_NV_INDEX_Marshal(TPMI_RH_NV_INDEX *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_HANDLE_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 69 - Definition of (TPM_HANDLE) TPMI_RH_NV_ EXP_INDEX Type <IN/OUT> */\n\nUINT16\nTPMI_RH_NV_EXP_INDEX_Marshal(TPMI_RH_NV_INDEX *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_HANDLE_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:60 - Definition of TPMI_ALG_HASH Type (InterfaceTable()) */\n\nUINT16\nTPMI_ALG_HASH_Marshal(TPMI_ALG_HASH *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ALG_ID_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:63 - Definition of TPMI_ALG_SYM_OBJECT Type (InterfaceTable()) */\n\nUINT16\nTPMI_ALG_SYM_OBJECT_Marshal(TPMI_ALG_SYM_OBJECT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ALG_ID_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:64 - Definition of TPMI_ALG_SYM_MODE Type (InterfaceTable()) */\n\nUINT16\nTPMI_ALG_SYM_MODE_Marshal(TPMI_ALG_SYM_MODE *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ALG_ID_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:65 - Definition of TPMI_ALG_KDF Type (InterfaceTable()) */\n\nUINT16\nTPMI_ALG_KDF_Marshal(TPMI_ALG_KDF *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ALG_ID_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:66 - Definition of TPMI_ALG_SIG_SCHEME Type (InterfaceTable()) */\n\nUINT16\nTPMI_ALG_SIG_SCHEME_Marshal(TPMI_ALG_SIG_SCHEME *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ALG_ID_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:71 - Definition of TPMU_HA Union (StructuresTable()) */\n\nUINT16\nTPMU_HA_Marshal(TPMU_HA *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n#if ALG_SHA1\n      case TPM_ALG_SHA1:\n\twritten += Array_Marshal(&source->sha1[0], SHA1_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#if ALG_SHA256\n      case TPM_ALG_SHA256:\n\twritten += Array_Marshal(&source->sha256[0], SHA256_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#if ALG_SHA384\n      case TPM_ALG_SHA384:\n\twritten += Array_Marshal(&source->sha384[0], SHA384_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#if ALG_SHA512\n      case TPM_ALG_SHA512:\n\twritten += Array_Marshal(&source->sha512[0], SHA512_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM3_256\n      case TPM_ALG_SM3_256:\n\twritten += Array_Marshal(&source->sm3_256[0], SM3_256_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:72 - Definition of TPMT_HA Structure (StructuresTable()) */\n\nUINT16\nTPMT_HA_Marshal(TPMT_HA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMI_ALG_HASH_Marshal(&source->hashAlg, buffer, size);\n    written += TPMU_HA_Marshal(&source->digest, buffer, size, source->hashAlg);\n    return written;\n}\n\n/* Table 2:73 - Definition of TPM2B_DIGEST Structure (StructuresTable()) */\n\nUINT16\nTPM2B_DIGEST_Marshal(TPM2B_DIGEST *source, BYTE **buffer, INT32 *size)\n{\nUINT16 written = 0;\nwritten += TPM2B_Marshal(&source->b, buffer, size);\nreturn written;\n}\n\n/* Table 2:74 - Definition of TPM2B_DATA Structure (StructuresTable()) */\n\nUINT16\nTPM2B_DATA_Marshal(TPM2B_DATA *source, BYTE **buffer, INT32 *size)\n{\nUINT16 written = 0;\nwritten += TPM2B_Marshal(&source->b, buffer, size);\nreturn written;\n}\n\n/* Table 2:75 - Definition of Types for TPM2B_NONCE (TypedefTable()) */\n\nUINT16\nTPM2B_NONCE_Marshal(TPM2B_NONCE *source, BYTE **buffer, INT32 *size)\n{\nUINT16 written = 0;\nwritten += TPM2B_DIGEST_Marshal(source, buffer, size);\nreturn written;\n}\n\n/* Table 2:76 - Definition of Types for TPM2B_AUTH (TypedefTable()) */\n\nUINT16\nTPM2B_AUTH_Marshal(TPM2B_AUTH *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_DIGEST_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:79 - Definition of TPM2B_MAX_BUFFER Structure (StructuresTable()) */\n\nUINT16\nTPM2B_MAX_BUFFER_Marshal(TPM2B_MAX_BUFFER *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:80 - Definition of TPM2B_MAX_NV_BUFFER Structure (StructuresTable()) */\n\nUINT16\nTPM2B_MAX_NV_BUFFER_Marshal(TPM2B_MAX_NV_BUFFER *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 80 - Definition of TPM2B_TIMEOUT Structure <IN/OUT> */\nUINT16\nTPM2B_TIMEOUT_Marshal(TPM2B_TIMEOUT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:82 - Definition of TPM2B_IV Structure (StructuresTable()) */\n\nUINT16\nTPM2B_IV_Marshal(TPM2B_IV *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:84 - Definition of TPM2B_NAME Structure (StructuresTable()) */\n\nUINT16\nTPM2B_NAME_Marshal(TPM2B_NAME *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:86 - Definition of TPMS_PCR_SELECTION Structure (StructuresTable()) */\n\nUINT16\nTPMS_PCR_SELECTION_Marshal(TPMS_PCR_SELECTION *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_HASH_Marshal(&source->hash, buffer, size);\n    written += UINT8_Marshal(&source->sizeofSelect, buffer, size);\n    written += Array_Marshal(&source->pcrSelect[0], source->sizeofSelect, buffer, size);\n    return written;\n}\n\n/* Table 2:89 - Definition of TPMT_TK_CREATION Structure (StructuresTable()) */\n\nUINT16\nTPMT_TK_CREATION_Marshal(TPMT_TK_CREATION *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_ST_Marshal(&source->tag, buffer, size);\n    written += TPMI_RH_HIERARCHY_Marshal(&source->hierarchy, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->digest, buffer, size);\n    return written;\n}\n\n/* Table 2:90 - Definition of TPMT_TK_VERIFIED Structure (StructuresTable()) */\n\nUINT16\nTPMT_TK_VERIFIED_Marshal(TPMT_TK_VERIFIED *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_ST_Marshal(&source->tag, buffer, size);\n    written += TPMI_RH_HIERARCHY_Marshal(&source->hierarchy, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->digest, buffer, size);\n    return written;\n}\n\n/* Table 2:91 - Definition of TPMT_TK_AUTH Structure (StructuresTable()) */\n\nUINT16\nTPMT_TK_AUTH_Marshal(TPMT_TK_AUTH *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_ST_Marshal(&source->tag, buffer, size);\n    written += TPMI_RH_HIERARCHY_Marshal(&source->hierarchy, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->digest, buffer, size);\n    return written;\n}\n\n/* Table 2:92 - Definition of TPMT_TK_HASHCHECK Structure (StructuresTable()) */\n\nUINT16\nTPMT_TK_HASHCHECK_Marshal(TPMT_TK_HASHCHECK *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_ST_Marshal(&source->tag, buffer, size);\n    written += TPMI_RH_HIERARCHY_Marshal(&source->hierarchy, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->digest, buffer, size);\n    return written;\n}\n\n/* Table 2:93 - Definition of TPMS_ALG_PROPERTY Structure (StructuresTable()) */\n\nUINT16\nTPMS_ALG_PROPERTY_Marshal(TPMS_ALG_PROPERTY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_ALG_ID_Marshal(&source->alg, buffer, size);\n    written += TPMA_ALGORITHM_Marshal(&source->algProperties, buffer, size);\n    return written;\n}\n\n/* Table 2:95 - Definition of TPMS_TAGGED_PCR_SELECT Structure (StructuresTable()) */\n\nUINT16\nTPMS_TAGGED_PCR_SELECT_Marshal(TPMS_TAGGED_PCR_SELECT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_PT_PCR_Marshal(&source->tag, buffer, size);\n    written += UINT8_Marshal(&source->sizeofSelect, buffer, size);\n    written += Array_Marshal(&source->pcrSelect[0], source->sizeofSelect, buffer, size);\n    return written;\n}\n\n/* Table 2:96 - Definition of TPMS_TAGGED_POLICY Structure (StructuresTable()) */\n\nUINT16\nTPMS_TAGGED_POLICY_Marshal(TPMS_TAGGED_POLICY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_HANDLE_Marshal(&source->handle, buffer, size);\n    written += TPMT_HA_Marshal(&source->policyHash, buffer, size);\n    return written;\n}\n\n/* Table 105 - Definition of TPMS_ACT_DATA Structure <OUT> */\n\nUINT16\nTPMS_ACT_DATA_Marshal(TPMS_ACT_DATA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_HANDLE_Marshal(&source->handle, buffer, size);\n    written += UINT32_Marshal(&source->timeout, buffer, size);\n    written += TPMA_ACT_Marshal(&source->attributes, buffer, size);\n    return written;\n}\n\n/* Table 2:94 - Definition of TPMS_TAGGED_PROPERTY Structure (StructuresTable()) */\n\nUINT16\nTPMS_TAGGED_PROPERTY_Marshal(TPMS_TAGGED_PROPERTY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_PT_Marshal(&source->property, buffer, size);\n    written += UINT32_Marshal(&source->value, buffer, size);\n    return written;\n}\n\n/* Table 2:97 - Definition of TPML_CC Structure (StructuresTable()) */\n\nUINT16\nTPML_CC_Marshal(TPML_CC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPM_CC_Marshal(&source->commandCodes[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:98 - Definition of TPML_CCA Structure (StructuresTable()) */\n\nUINT16\nTPML_CCA_Marshal(TPML_CCA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPMA_CC_Marshal(&source->commandAttributes[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:99 - Definition of TPML_ALG Structure (StructuresTable()) */\n\nUINT16\nTPML_ALG_Marshal(TPML_ALG *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPM_ALG_ID_Marshal(&source->algorithms[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:100 - Definition of TPML_HANDLE Structure (StructuresTable()) */\n\nUINT16\nTPML_HANDLE_Marshal(TPML_HANDLE *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPM_HANDLE_Marshal(&source->handle[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:101 - Definition of TPML_DIGEST Structure (StructuresTable()) */\n\nUINT16\nTPML_DIGEST_Marshal(TPML_DIGEST *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPM2B_DIGEST_Marshal(&source->digests[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:102 - Definition of TPML_DIGEST_VALUES Structure (StructuresTable()) */\n\nUINT16\nTPML_DIGEST_VALUES_Marshal(TPML_DIGEST_VALUES *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPMT_HA_Marshal(&source->digests[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:104 - Definition of TPML_PCR_SELECTION Structure (StructuresTable()) */\n\nUINT16\nTPML_PCR_SELECTION_Marshal(TPML_PCR_SELECTION *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPMS_PCR_SELECTION_Marshal(&source->pcrSelections[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:105 - Definition of TPML_ALG_PROPERTY Structure (StructuresTable()) */\n\n\nUINT16\nTPML_ALG_PROPERTY_Marshal(TPML_ALG_PROPERTY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPMS_ALG_PROPERTY_Marshal(&source->algProperties[i], buffer, size);\n    }\n    return written;\n}\n\n//* Table 2:106 - Definition of TPML_TAGGED_TPM_PROPERTY Structure (StructuresTable()) */\n\nUINT16\nTPML_TAGGED_TPM_PROPERTY_Marshal(TPML_TAGGED_TPM_PROPERTY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPMS_TAGGED_PROPERTY_Marshal(&source->tpmProperty[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:107 - Definition of TPML_TAGGED_PCR_PROPERTY Structure (StructuresTable()) */\n\nUINT16\nTPML_TAGGED_PCR_PROPERTY_Marshal(TPML_TAGGED_PCR_PROPERTY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPMS_TAGGED_PCR_SELECT_Marshal(&source->pcrProperty[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:108 - Definition of TPML_ECC_CURVE Structure (StructuresTable()) */\n\nUINT16\nTPML_ECC_CURVE_Marshal(TPML_ECC_CURVE *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPM_ECC_CURVE_Marshal(&source->eccCurves[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:109 - Definition of TPML_TAGGED_POLICY Structure (StructuresTable()) */\n\nUINT16\nTPML_TAGGED_POLICY_Marshal(TPML_TAGGED_POLICY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPMS_TAGGED_POLICY_Marshal(&source->policies[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:118 - Definition of TPML_ACT_DATA Structure (StructuresTable()) */\n\nUINT16\nTPML_ACT_DATA_Marshal(TPML_ACT_DATA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPMS_ACT_DATA_Marshal(&source->actData[i], buffer, size);\n    }\n    return written;\n}\n\n/* Table 2:110 - Definition of TPMU_CAPABILITIES Union (StructuresTable()) */\n\nUINT16\nTPMU_CAPABILITIES_Marshal(TPMU_CAPABILITIES *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n      case TPM_CAP_ALGS:\n\twritten += TPML_ALG_PROPERTY_Marshal(&source->algorithms, buffer, size);\n\tbreak;\n      case TPM_CAP_HANDLES:\n\twritten += TPML_HANDLE_Marshal(&source->handles, buffer, size);\n\tbreak;\n      case TPM_CAP_COMMANDS:\n\twritten += TPML_CCA_Marshal(&source->command, buffer, size);\n\tbreak;\n      case TPM_CAP_PP_COMMANDS:\n\twritten += TPML_CC_Marshal(&source->ppCommands, buffer, size);\n\tbreak;\n      case TPM_CAP_AUDIT_COMMANDS:\n\twritten += TPML_CC_Marshal(&source->auditCommands, buffer, size);\n\tbreak;\n      case TPM_CAP_PCRS:\n\twritten += TPML_PCR_SELECTION_Marshal(&source->assignedPCR, buffer, size);\n\tbreak;\n      case TPM_CAP_TPM_PROPERTIES:\n\twritten += TPML_TAGGED_TPM_PROPERTY_Marshal(&source->tpmProperties, buffer, size);\n\tbreak;\n      case TPM_CAP_PCR_PROPERTIES:\n\twritten += TPML_TAGGED_PCR_PROPERTY_Marshal(&source->pcrProperties, buffer, size);\n\tbreak;\n      case TPM_CAP_ECC_CURVES:\n\twritten += TPML_ECC_CURVE_Marshal(&source->eccCurves, buffer, size);\n\tbreak;\n      case TPM_CAP_AUTH_POLICIES:\n\twritten += TPML_TAGGED_POLICY_Marshal(&source->authPolicies, buffer, size);\n\tbreak;\n      case TPM_CAP_ACT:\n\twritten += TPML_ACT_DATA_Marshal(&source->actData, buffer, size);\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:111 - Definition of TPMS_CAPABILITY_DATA Structure (StructuresTable()) */\n\nUINT16\nTPMS_CAPABILITY_DATA_Marshal(TPMS_CAPABILITY_DATA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_CAP_Marshal(&source->capability, buffer, size);\n    written += TPMU_CAPABILITIES_Marshal(&source->data, buffer, size, source->capability);\n    return written;\n}\n\n/* Table 2:112 - Definition of TPMS_CLOCK_INFO Structure (StructuresTable()) */\n\nUINT16\nTPMS_CLOCK_INFO_Marshal(TPMS_CLOCK_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += UINT64_Marshal(&source->clock, buffer, size);\n    written += UINT32_Marshal(&source->resetCount, buffer, size);\n    written += UINT32_Marshal(&source->restartCount, buffer, size);\n    written += TPMI_YES_NO_Marshal(&source->safe, buffer, size);\n    return written;\n}\n\n/* Table 2:113 - Definition of TPMS_TIME_INFO Structure (StructuresTable()) */\n\nUINT16\nTPMS_TIME_INFO_Marshal(TPMS_TIME_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += UINT64_Marshal(&source->time, buffer, size);\n    written += TPMS_CLOCK_INFO_Marshal(&source->clockInfo, buffer, size);\n    return written;\n}\n\n/* Table 2:114 - Definition of TPMS_TIME_ATTEST_INFO Structure (StructuresTable()) */\n\nUINT16\nTPMS_TIME_ATTEST_INFO_Marshal(TPMS_TIME_ATTEST_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMS_TIME_INFO_Marshal(&source->time, buffer, size);\n    written += UINT64_Marshal(&source->firmwareVersion, buffer, size);\n    return written;\n}\n\n/* Table 2:115 - Definition of TPMS_CERTIFY_INFO Structure (StructuresTable()) */\n\nUINT16\nTPMS_CERTIFY_INFO_Marshal(TPMS_CERTIFY_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM2B_NAME_Marshal(&source->name, buffer, size);\n    written += TPM2B_NAME_Marshal(&source->qualifiedName, buffer, size);\n    return written;\n}\n\n/* Table 2:116 - Definition of TPMS_QUOTE_INFO Structure (StructuresTable()) */\n\nUINT16\nTPMS_QUOTE_INFO_Marshal(TPMS_QUOTE_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPML_PCR_SELECTION_Marshal(&source->pcrSelect, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->pcrDigest, buffer, size);\n    return written;\n}\n\n/* Table 2:117 - Definition of TPMS_COMMAND_AUDIT_INFO Structure (StructuresTable()) */\n\nUINT16\nTPMS_COMMAND_AUDIT_INFO_Marshal(TPMS_COMMAND_AUDIT_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += UINT64_Marshal(&source->auditCounter, buffer, size);\n    written += TPM_ALG_ID_Marshal(&source->digestAlg, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->auditDigest, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->commandDigest, buffer, size);\n    return written;\n}\n\n/* Table 2:118 - Definition of TPMS_SESSION_AUDIT_INFO Structure (StructuresTable()) */\n\nUINT16\nTPMS_SESSION_AUDIT_INFO_Marshal(TPMS_SESSION_AUDIT_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_YES_NO_Marshal(&source->exclusiveSession, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->sessionDigest, buffer, size);\n    return written;\n}\n\n/* Table 2:119 - Definition of TPMS_CREATION_INFO Structure (StructuresTable()) */\n\nUINT16\nTPMS_CREATION_INFO_Marshal(TPMS_CREATION_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM2B_NAME_Marshal(&source->objectName, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->creationHash, buffer, size);\n    return written;\n}\n\n/* Table 2:120 - Definition of TPMS_NV_CERTIFY_INFO Structure (StructuresTable()) */\n\nUINT16\nTPMS_NV_CERTIFY_INFO_Marshal(TPMS_NV_CERTIFY_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM2B_NAME_Marshal(&source->indexName, buffer, size);\n    written += UINT16_Marshal(&source->offset, buffer, size);\n    written += TPM2B_MAX_NV_BUFFER_Marshal(&source->nvContents, buffer, size);\n    return written;\n}\n\n/* Table 125 - Definition of TPMS_NV_DIGEST_CERTIFY_INFO Structure <OUT> */\nUINT16\nTPMS_NV_DIGEST_CERTIFY_INFO_Marshal(TPMS_NV_DIGEST_CERTIFY_INFO *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_NAME_Marshal(&source->indexName, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->nvDigest, buffer, size);\n    return written;\n}\n\n/* Table 2:121 - Definition of TPMI_ST_ATTEST Type (InterfaceTable()) */\n\nUINT16\nTPMI_ST_ATTEST_Marshal(TPMI_ST_ATTEST *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ST_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:122 - Definition of TPMU_ATTEST Union (StructuresTable()) */\n\nUINT16\nTPMU_ATTEST_Marshal(TPMU_ATTEST  *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n      case TPM_ST_ATTEST_CERTIFY:\n\twritten += TPMS_CERTIFY_INFO_Marshal(&source->certify, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_CREATION:\n\twritten += TPMS_CREATION_INFO_Marshal(&source->creation, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_QUOTE:\n\twritten += TPMS_QUOTE_INFO_Marshal(&source->quote, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_COMMAND_AUDIT:\n\twritten += TPMS_COMMAND_AUDIT_INFO_Marshal(&source->commandAudit, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_SESSION_AUDIT:\n\twritten += TPMS_SESSION_AUDIT_INFO_Marshal(&source->sessionAudit, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_TIME:\n\twritten += TPMS_TIME_ATTEST_INFO_Marshal(&source->time, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_NV:\n\twritten += TPMS_NV_CERTIFY_INFO_Marshal(&source->nv, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_NV_DIGEST:\n\twritten += TPMS_NV_DIGEST_CERTIFY_INFO_Marshal(&source->nvDigest, buffer, size);\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:123 - Definition of TPMS_ATTEST Structure (StructuresTable()) */\n\nUINT16\nTPMS_ATTEST_Marshal(TPMS_ATTEST  *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_CONSTANTS32_Marshal(&source->magic, buffer, size);\n    written += TPMI_ST_ATTEST_Marshal(&source->type, buffer, size);\n    written += TPM2B_NAME_Marshal(&source->qualifiedSigner, buffer, size);\n    written += TPM2B_DATA_Marshal(&source->extraData, buffer, size);\n    written += TPMS_CLOCK_INFO_Marshal(&source->clockInfo, buffer, size);\n    written += UINT64_Marshal(&source->firmwareVersion, buffer, size);\n    written += TPMU_ATTEST_Marshal(&source->attested, buffer, size,source->type);\n    return written;\n}\n\n/* Table 2:124 - Definition of TPM2B_ATTEST Structure (StructuresTable()) */\n\nUINT16\nTPM2B_ATTEST_Marshal(TPM2B_ATTEST *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:127 - Definition of TPMI_AES_KEY_BITS Type (InterfaceTable()) */\n\nUINT16\nTPMI_AES_KEY_BITS_Marshal(TPMI_AES_KEY_BITS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_KEY_BITS_Marshal(source, buffer, size);\n    return written;\n}\n\nUINT16\nTPMI_CAMELLIA_KEY_BITS_Marshal(TPMI_CAMELLIA_KEY_BITS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_KEY_BITS_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:128 - Definition of TPMU_SYM_KEY_BITS Union (StructuresTable()) */\n\nUINT16\nTPMU_SYM_KEY_BITS_Marshal(TPMU_SYM_KEY_BITS *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch(selector) {\n#if ALG_AES\n      case TPM_ALG_AES:\n\twritten += TPMI_AES_KEY_BITS_Marshal(&source->aes, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM4\n      case TPM_ALG_SM4:\n\twritten += TPMI_SM4_KEY_BITS_Marshal(&source->sm4, buffer, size);\n\tbreak;\n#endif\n#if ALG_CAMELLIA\n      case TPM_ALG_CAMELLIA:\n\twritten += TPMI_CAMELLIA_KEY_BITS_Marshal(&source->camellia, buffer, size);\n\tbreak;\n#endif\n#if ALG_XOR\n      case TPM_ALG_XOR:\n\twritten += TPMI_ALG_HASH_Marshal(&source->xorr, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:129 - Definition of TPMU_SYM_MODE Union (StructuresTable()) */\n\nUINT16\nTPMU_SYM_MODE_Marshal(TPMU_SYM_MODE *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n#if ALG_AES\n      case TPM_ALG_AES:\n\twritten += TPMI_ALG_SYM_MODE_Marshal(&source->aes, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM4\n      case TPM_ALG_SM4:\n\twritten += TPMI_ALG_SYM_MODE_Marshal(&source->sm4, buffer, size);\n\tbreak;\n#endif\n#if ALG_CAMELLIA\n      case TPM_ALG_CAMELLIA:\n\twritten += TPMI_ALG_SYM_MODE_Marshal(&source->camellia, buffer, size);\n\tbreak;\n#endif\n#if ALG_XOR\n      case TPM_ALG_XOR:\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:132 - Definition of TPMT_SYM_DEF_OBJECT Structure (StructuresTable()) */\n\nUINT16\nTPMT_SYM_DEF_OBJECT_Marshal(TPMT_SYM_DEF_OBJECT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_SYM_OBJECT_Marshal(&source->algorithm, buffer, size);\n    written += TPMU_SYM_KEY_BITS_Marshal(&source->keyBits, buffer, size, source->algorithm);\n    written += TPMU_SYM_MODE_Marshal(&source->mode, buffer, size, source->algorithm);\n    return written;\n}\n\n/* Table 2:133 - Definition of TPM2B_SYM_KEY Structure (StructuresTable()) */\n\nUINT16\nTPM2B_SYM_KEY_Marshal(TPM2B_SYM_KEY *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:134 - Definition of TPMS_SYMCIPHER_PARMS Structure (StructuresTable()) */\n\nUINT16\nTPMS_SYMCIPHER_PARMS_Marshal(TPMS_SYMCIPHER_PARMS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMT_SYM_DEF_OBJECT_Marshal(&source->sym, buffer, size);\n    return written;\n}\n\n/* Table 2:139 - Definition of TPM2B_SENSITIVE_DATA Structure (StructuresTable()) */\n\nUINT16\nTPM2B_SENSITIVE_DATA_Marshal(TPM2B_SENSITIVE_DATA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:142 - Definition of TPMS_SCHEME_HASH Structure (StructuresTable()) */\n\nUINT16\nTPMS_SCHEME_HASH_Marshal(TPMS_SCHEME_HASH *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_HASH_Marshal(&source->hashAlg, buffer, size);\n    return written;\n}\n\n/* Table 2:143 - Definition of TPMS_SCHEME_ECDAA Structure (StructuresTable()) */\n\nUINT16\nTPMS_SCHEME_ECDAA_Marshal(TPMS_SCHEME_ECDAA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_HASH_Marshal(&source->hashAlg, buffer, size);\n    written += UINT16_Marshal(&source->count, buffer, size);\n    return written;\n}\n\n/* Table 2:144 - Definition of TPMI_ALG_KEYEDHASH_SCHEME Type (InterfaceTable()) */\n\nUINT16\nTPMI_ALG_KEYEDHASH_SCHEME_Marshal(TPMI_ALG_KEYEDHASH_SCHEME *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ALG_ID_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:145 - Definition of Types for HMAC_SIG_SCHEME (TypedefTable()) */\n\nUINT16\nTPMS_SCHEME_HMAC_Marshal(TPMS_SCHEME_HMAC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:146 - Definition of TPMS_SCHEME_XOR Structure (StructuresTable()) */\n\nUINT16\nTPMS_SCHEME_XOR_Marshal(TPMS_SCHEME_XOR *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_HASH_Marshal(&source->hashAlg, buffer, size);\n    written += TPMI_ALG_KDF_Marshal(&source->kdf, buffer, size);\n    return written;\n}\n\n/* Table 2:148 - Definition of TPMT_KEYEDHASH_SCHEME Structure (StructuresTable()) */\n\nUINT16\nTPMT_KEYEDHASH_SCHEME_Marshal(TPMT_KEYEDHASH_SCHEME *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_KEYEDHASH_SCHEME_Marshal(&source->scheme, buffer, size);\n    written += TPMU_SCHEME_KEYEDHASH_Marshal(&source->details, buffer, size, source->scheme);\n    return written;\n}\n\n/* Table 2:149 - Definition of Types for RSA Signature Schemes (TypedefTable()) */\n\nUINT16\nTPMS_SIG_SCHEME_RSASSA_Marshal(TPMS_SIG_SCHEME_RSASSA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\n\nUINT16\nTPMS_SIG_SCHEME_RSAPSS_Marshal(TPMS_SIG_SCHEME_RSAPSS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:150 - Definition of Types for ECC Signature Schemes (TypedefTable()) */\n\nUINT16\nTPMS_SIG_SCHEME_ECDSA_Marshal(TPMS_SIG_SCHEME_ECDSA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\nUINT16\nTPMS_SIG_SCHEME_SM2_Marshal(TPMS_SIG_SCHEME_SM2 *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\nUINT16\nTPMS_SIG_SCHEME_ECSCHNORR_Marshal(TPMS_SIG_SCHEME_ECSCHNORR *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\nUINT16\nTPMS_SIG_SCHEME_ECDAA_Marshal(TPMS_SIG_SCHEME_ECDAA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_ECDAA_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:153 - Definition of Types for Encryption Schemes (TypedefTable()) */\n\nUINT16\nTPMS_ENC_SCHEME_OAEP_Marshal(TPMS_ENC_SCHEME_OAEP *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 146 - Definition of Types for {RSA} Encryption Schemes */\n\nUINT16\nTPMS_ENC_SCHEME_RSAES_Marshal(TPMS_ENC_SCHEME_RSAES *source, BYTE **buffer, INT32 *size)\n{\n    source = source;\n    buffer = buffer;\n    size = size;\n    return 0;\n}\n\n/* Table 2:147 - Definition of TPMU_SCHEME_KEYEDHASH Union (StructuresTable()) */\n\nUINT16\nTPMU_SCHEME_KEYEDHASH_Marshal(TPMU_SCHEME_KEYEDHASH *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n#if ALG_HMAC\n      case TPM_ALG_HMAC:\n\twritten += TPMS_SCHEME_HMAC_Marshal(&source->hmac, buffer, size);\n\tbreak;\n#endif\n#if ALG_XOR\n      case TPM_ALG_XOR:\n\twritten += TPMS_SCHEME_XOR_Marshal(&source->xorr, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:154 - Definition of Types for ECC Key Exchange (TypedefTable()) */\n\nUINT16\nTPMS_KEY_SCHEME_ECDH_Marshal(TPMS_KEY_SCHEME_ECDH *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\n\nUINT16\nTPMS_KEY_SCHEME_ECMQV_Marshal(TPMS_KEY_SCHEME_ECMQV*source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:155 - Definition of Types for KDF Schemes (TypedefTable()) */\nUINT16\nTPMS_KDF_SCHEME_MGF1_Marshal(TPMS_KDF_SCHEME_MGF1 *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\nUINT16\nTPMS_KDF_SCHEME_KDF1_SP800_56A_Marshal(TPMS_KDF_SCHEME_KDF1_SP800_56A *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\nUINT16\nTPMS_KDF_SCHEME_KDF2_Marshal(TPMS_KDF_SCHEME_KDF2 *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\nUINT16\nTPMS_KDF_SCHEME_KDF1_SP800_108_Marshal(TPMS_KDF_SCHEME_KDF1_SP800_108 *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SCHEME_HASH_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:156 - Definition of TPMU_KDF_SCHEME Union (StructuresTable()) */\n\nUINT16\nTPMU_KDF_SCHEME_Marshal(TPMU_KDF_SCHEME *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n\n    switch (selector) {\n#if ALG_MGF1\n      case TPM_ALG_MGF1:\n\twritten += TPMS_KDF_SCHEME_MGF1_Marshal(&source->mgf1, buffer, size);\n\tbreak;\n#endif\n#if ALG_KDF1_SP800_56A\n      case TPM_ALG_KDF1_SP800_56A:\n\twritten += TPMS_KDF_SCHEME_KDF1_SP800_56A_Marshal(&source->kdf1_sp800_56a, buffer, size);\n\tbreak;\n#endif\n#if ALG_KDF2\n      case TPM_ALG_KDF2:\n\twritten += TPMS_KDF_SCHEME_KDF2_Marshal(&source->kdf2, buffer, size);\n\tbreak;\n#endif\n#if ALG_KDF1_SP800_108\n      case TPM_ALG_KDF1_SP800_108:\n\twritten += TPMS_KDF_SCHEME_KDF1_SP800_108_Marshal(&source->kdf1_sp800_108, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:157 - Definition of TPMT_KDF_SCHEME Structure (StructuresTable()) */\n\nUINT16\nTPMT_KDF_SCHEME_Marshal(TPMT_KDF_SCHEME *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_KDF_Marshal(&source->scheme, buffer, size);\n    written += TPMU_KDF_SCHEME_Marshal(&source->details, buffer, size, source->scheme);\n    return written;\n}\n\n/* Table 2:159 - Definition of TPMU_ASYM_SCHEME Union (StructuresTable()) */\n\nUINT16\nTPMU_ASYM_SCHEME_Marshal(TPMU_ASYM_SCHEME  *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n#if ALG_ECDH\n      case TPM_ALG_ECDH:\n\twritten += TPMS_KEY_SCHEME_ECDH_Marshal(&source->ecdh, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECMQV\n      case TPM_ALG_ECMQV:\n\twritten += TPMS_KEY_SCHEME_ECMQV_Marshal(&source->ecmqv, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\twritten += TPMS_SIG_SCHEME_RSASSA_Marshal(&source->rsassa, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\twritten += TPMS_SIG_SCHEME_RSAPSS_Marshal(&source->rsapss, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\twritten += TPMS_SIG_SCHEME_ECDSA_Marshal(&source->ecdsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\twritten += TPMS_SIG_SCHEME_ECDAA_Marshal(&source->ecdaa, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM2\n      case TPM_ALG_SM2:\n\twritten += TPMS_SIG_SCHEME_SM2_Marshal(&source->sm2, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\twritten += TPMS_SIG_SCHEME_ECSCHNORR_Marshal(&source->ecschnorr, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSAES\n      case TPM_ALG_RSAES:\n\twritten += TPMS_ENC_SCHEME_RSAES_Marshal(&source->rsaes, buffer, size);\n\tbreak;\n#endif\n#if ALG_OAEP\n      case TPM_ALG_OAEP:\n\twritten += TPMS_ENC_SCHEME_OAEP_Marshal(&source->oaep, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:161 - Definition of TPMI_ALG_RSA_SCHEME Type (InterfaceTable()) */\n\nUINT16\nTPMI_ALG_RSA_SCHEME_Marshal(TPMI_ALG_RSA_SCHEME *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ALG_ID_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:162 - Definition of TPMT_RSA_SCHEME Structure (StructuresTable()) */\n\nUINT16\nTPMT_RSA_SCHEME_Marshal(TPMT_RSA_SCHEME *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_RSA_SCHEME_Marshal(&source->scheme, buffer, size);\n    written += TPMU_ASYM_SCHEME_Marshal(&source->details, buffer, size, source->scheme);\n    return written;\n}\n\n/* Table 2:165 - Definition of TPM2B_PUBLIC_KEY_RSA Structure (StructuresTable()) */\n\nUINT16\nTPM2B_PUBLIC_KEY_RSA_Marshal(TPM2B_PUBLIC_KEY_RSA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:166 - Definition of TPMI_RSA_KEY_BITS Type (InterfaceTable()) */\n\nUINT16\nTPMI_RSA_KEY_BITS_Marshal(TPMI_RSA_KEY_BITS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_KEY_BITS_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:167 - Definition of TPM2B_PRIVATE_KEY_RSA Structure (StructuresTable()) */\n\nUINT16\nTPM2B_PRIVATE_KEY_RSA_Marshal(TPM2B_PRIVATE_KEY_RSA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:168 - Definition of TPM2B_ECC_PARAMETER Structure (StructuresTable()) */\n\nUINT16\nTPM2B_ECC_PARAMETER_Marshal(TPM2B_ECC_PARAMETER *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:169 - Definition of TPMS_ECC_POINT Structure (StructuresTable()) */\n\nUINT16\nTPMS_ECC_POINT_Marshal(TPMS_ECC_POINT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->x, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->y, buffer, size);\n    return written;\n}\n\n/* Table 2:170 - Definition of TPM2B_ECC_POINT Structure (StructuresTable()) */\n\nUINT16\nTPM2B_ECC_POINT_Marshal(TPM2B_ECC_POINT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n    \t*buffer += sizeof(UINT16);\n    }\n    written += TPMS_ECC_POINT_Marshal(&source->point, buffer, size);\n    if (buffer != NULL) {\n\twritten += UINT16_Marshal(&written, &sizePtr, size);\n    }\n    else {\n\twritten += sizeof(UINT16);\n    }\n    return written;\n}\n\n/* Table 2:171 - Definition of TPMI_ALG_ECC_SCHEME Type (InterfaceTable()) */\n\nUINT16\nTPMI_ALG_ECC_SCHEME_Marshal(TPMI_ALG_ECC_SCHEME *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ALG_ID_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:172 - Definition of TPMI_ECC_CURVE Type (InterfaceTable()) */\n\nUINT16\nTPMI_ECC_CURVE_Marshal(TPMI_ECC_CURVE *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ECC_CURVE_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:173 - Definition of TPMT_ECC_SCHEME Structure (StructuresTable()) */\n\nUINT16\nTPMT_ECC_SCHEME_Marshal(TPMT_ECC_SCHEME *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_ECC_SCHEME_Marshal(&source->scheme, buffer, size);\n    written += TPMU_ASYM_SCHEME_Marshal(&source->details, buffer, size, source->scheme);\n    return written;\n}\n\n/* Table 2:174 - Definition of TPMS_ALGORITHM_DETAIL_ECC Structure (StructuresTable()) */\n\nUINT16\nTPMS_ALGORITHM_DETAIL_ECC_Marshal(TPMS_ALGORITHM_DETAIL_ECC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_ECC_CURVE_Marshal(&source->curveID, buffer, size);\n    written += UINT16_Marshal(&source->keySize, buffer, size);\n    written += TPMT_KDF_SCHEME_Marshal(&source->kdf, buffer, size);\n    written += TPMT_ECC_SCHEME_Marshal(&source->sign, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->p, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->a, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->b, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->gX, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->gY, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->n, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->h, buffer, size);\n    return written;\n}\n\n/* Table 2:175 - Definition of TPMS_SIGNATURE_RSA Structure (StructuresTable()) */\n\nUINT16\nTPMS_SIGNATURE_RSA_Marshal(TPMS_SIGNATURE_RSA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_HASH_Marshal(&source->hash, buffer, size);\n    written += TPM2B_PUBLIC_KEY_RSA_Marshal(&source->sig, buffer, size);\n    return written;\n}\n\n/* Table 2:176 - Definition of Types for Signature (TypedefTable()) */\nUINT16\nTPMS_SIGNATURE_RSASSA_Marshal(TPMS_SIGNATURE_RSASSA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SIGNATURE_RSA_Marshal(source, buffer, size);\n    return written;\n}\nUINT16\nTPMS_SIGNATURE_RSAPSS_Marshal(TPMS_SIGNATURE_RSAPSS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SIGNATURE_RSA_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:177 - Definition of TPMS_SIGNATURE_ECC Structure (StructuresTable()) */\n\nUINT16\nTPMS_SIGNATURE_ECC_Marshal(TPMS_SIGNATURE_ECC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_HASH_Marshal(&source->hash, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->signatureR, buffer, size);\n    written += TPM2B_ECC_PARAMETER_Marshal(&source->signatureS, buffer, size);\n    return written;\n}\n\n/* Table 2:178 - Definition of Types for TPMS_SIGNATURE_ECC (TypedefTable()) */\n\nUINT16\nTPMS_SIGNATURE_ECDSA_Marshal(TPMS_SIGNATURE_ECDSA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SIGNATURE_ECC_Marshal(source, buffer, size);\n    return written;\n}\n\nUINT16\nTPMS_SIGNATURE_ECDAA_Marshal(TPMS_SIGNATURE_ECDAA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SIGNATURE_ECC_Marshal(source, buffer, size);\n    return written;\n}\n\nUINT16\nTPMS_SIGNATURE_SM2_Marshal(TPMS_SIGNATURE_SM2 *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SIGNATURE_ECC_Marshal(source, buffer, size);\n    return written;\n}\n\nUINT16\nTPMS_SIGNATURE_ECSCHNORR_Marshal(TPMS_SIGNATURE_ECSCHNORR *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMS_SIGNATURE_ECC_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:179 - Definition of TPMU_SIGNATURE Union (StructuresTable()) */\nUINT16\nTPMU_SIGNATURE_Marshal(TPMU_SIGNATURE *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n#if ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\twritten += TPMS_SIGNATURE_RSASSA_Marshal(&source->rsassa, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\twritten += TPMS_SIGNATURE_RSAPSS_Marshal(&source->rsapss, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\twritten += TPMS_SIGNATURE_ECDSA_Marshal(&source->ecdsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\twritten += TPMS_SIGNATURE_ECDAA_Marshal(&source->ecdaa, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM2\n      case TPM_ALG_SM2:\n\twritten += TPMS_SIGNATURE_SM2_Marshal(&source->sm2, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\twritten += TPMS_SIGNATURE_ECSCHNORR_Marshal(&source->ecschnorr, buffer, size);\n\tbreak;\n#endif\n#if ALG_HMAC\n      case TPM_ALG_HMAC:\n\twritten += TPMT_HA_Marshal(&source->hmac, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:180 - Definition of TPMT_SIGNATURE Structure (StructuresTable()) */\n\nUINT16\nTPMT_SIGNATURE_Marshal(TPMT_SIGNATURE *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_SIG_SCHEME_Marshal(&source->sigAlg, buffer, size);\n    written += TPMU_SIGNATURE_Marshal(&source->signature, buffer, size, source->sigAlg);\n    return written;\n}\n\n/* Table 2:182 - Definition of TPM2B_ENCRYPTED_SECRET Structure (StructuresTable()) */\n\nUINT16\nTPM2B_ENCRYPTED_SECRET_Marshal(TPM2B_ENCRYPTED_SECRET *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:183 - Definition of TPMI_ALG_PUBLIC Type (InterfaceTable()) */\n\n\nUINT16\nTPMI_ALG_PUBLIC_Marshal(TPMI_ALG_PUBLIC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM_ALG_ID_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:184 - Definition of TPMU_PUBLIC_ID Union (StructuresTable()) */\nUINT16\nTPMU_PUBLIC_ID_Marshal(TPMU_PUBLIC_ID *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n#if ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\twritten += TPM2B_DIGEST_Marshal(&source->keyedHash, buffer, size);\n\tbreak;\n#endif\n#if ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\twritten += TPM2B_DIGEST_Marshal(&source->sym, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSA\n      case TPM_ALG_RSA:\n\twritten += TPM2B_PUBLIC_KEY_RSA_Marshal(&source->rsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECC\n      case TPM_ALG_ECC:\n\twritten += TPMS_ECC_POINT_Marshal(&source->ecc, buffer, size);\n\tbreak;\n#endif\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:185 - Definition of TPMS_KEYEDHASH_PARMS Structure (StructuresTable()) */\n\nUINT16\nTPMS_KEYEDHASH_PARMS_Marshal(TPMS_KEYEDHASH_PARMS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMT_KEYEDHASH_SCHEME_Marshal(&source->scheme, buffer, size);\n    return written;\n}\n\n/* Table 2:187 - Definition of TPMS_RSA_PARMS Structure (StructuresTable()) */\n\nUINT16\nTPMS_RSA_PARMS_Marshal(TPMS_RSA_PARMS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMT_SYM_DEF_OBJECT_Marshal(&source->symmetric, buffer, size);\n    written += TPMT_RSA_SCHEME_Marshal(&source->scheme, buffer, size);\n    written += TPMI_RSA_KEY_BITS_Marshal(&source->keyBits, buffer, size);\n    written += UINT32_Marshal(&source->exponent, buffer, size);\n    return written;\n}\n\n/* Table 2:188 - Definition of TPMS_ECC_PARMS Structure (StructuresTable()) */\n\nUINT16\nTPMS_ECC_PARMS_Marshal(TPMS_ECC_PARMS *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMT_SYM_DEF_OBJECT_Marshal(&source->symmetric, buffer, size);\n    written += TPMT_ECC_SCHEME_Marshal(&source->scheme, buffer, size);\n    written += TPMI_ECC_CURVE_Marshal(&source->curveID, buffer, size);\n    written += TPMT_KDF_SCHEME_Marshal(&source->kdf, buffer, size);\n    return written;\n}\n\n/* Table 2:189 - Definition of TPMU_PUBLIC_PARMS Union (StructuresTable()) */\n\nUINT16\nTPMU_PUBLIC_PARMS_Marshal(TPMU_PUBLIC_PARMS *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n#if ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\twritten += TPMS_KEYEDHASH_PARMS_Marshal(&source->keyedHashDetail, buffer, size);\n\tbreak;\n#endif\n#if ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\twritten += TPMS_SYMCIPHER_PARMS_Marshal(&source->symDetail, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSA\n      case TPM_ALG_RSA:\n\twritten += TPMS_RSA_PARMS_Marshal(&source->rsaDetail, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECC\n      case TPM_ALG_ECC:\n\twritten += TPMS_ECC_PARMS_Marshal(&source->eccDetail, buffer, size);\n\tbreak;\n#endif\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:191 - Definition of TPMT_PUBLIC Structure (StructuresTable()) */\n\nUINT16\nTPMT_PUBLIC_Marshal(TPMT_PUBLIC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPMI_ALG_PUBLIC_Marshal(&source->type, buffer, size);\n    written += TPMI_ALG_HASH_Marshal(&source->nameAlg, buffer, size);\n    written += TPMA_OBJECT_Marshal(&source->objectAttributes, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->authPolicy, buffer, size);\n    written += TPMU_PUBLIC_PARMS_Marshal(&source->parameters, buffer, size, source->type);\n    written += TPMU_PUBLIC_ID_Marshal(&source->unique, buffer, size, source->type);\n    return written;\n}\n\n/* Table 2:192 - Definition of TPM2B_PUBLIC Structure (StructuresTable()) */\n\nUINT16\nTPM2B_PUBLIC_Marshal(TPM2B_PUBLIC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n   \t*buffer += sizeof(UINT16);\n    }\n    written += TPMT_PUBLIC_Marshal(&source->publicArea, buffer, size);\n    if (buffer != NULL) {\n        written += UINT16_Marshal(&written, &sizePtr, size);\n    }\n    else {\n\twritten += sizeof(UINT16);\n    }\n    return written;\n}\n\n/* Table 2:195 - Definition of TPMU_SENSITIVE_COMPOSITE Union (StructuresTable()) */\n\nUINT16\nTPMU_SENSITIVE_COMPOSITE_Marshal(TPMU_SENSITIVE_COMPOSITE *source, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n#if ALG_RSA\n      case TPM_ALG_RSA:\n\twritten += TPM2B_PRIVATE_KEY_RSA_Marshal(&source->rsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECC\n      case TPM_ALG_ECC:\n\twritten += TPM2B_ECC_PARAMETER_Marshal(&source->ecc, buffer, size);\n\tbreak;\n#endif\n#if ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\twritten += TPM2B_SENSITIVE_DATA_Marshal(&source->bits, buffer, size);\n\tbreak;\n#endif\n#if ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\twritten += TPM2B_SYM_KEY_Marshal(&source->sym, buffer, size);\n\tbreak;\n#endif\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 2:196 - Definition of TPMT_SENSITIVE Structure (StructuresTable()) */\n\nUINT16\nTPMT_SENSITIVE_Marshal(TPMT_SENSITIVE *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_ALG_PUBLIC_Marshal(&source->sensitiveType, buffer, size);\n    written += TPM2B_AUTH_Marshal(&source->authValue, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->seedValue, buffer, size);\n    written += TPMU_SENSITIVE_COMPOSITE_Marshal(&source->sensitive, buffer, size, source->sensitiveType);\n    return written;\n}\n\n/* Table 2:199 - Definition of TPM2B_PRIVATE Structure (StructuresTable()) */\n\nUINT16\nTPM2B_PRIVATE_Marshal(TPM2B_PRIVATE *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:201 - Definition of TPM2B_ID_OBJECT Structure (StructuresTable()) */\n\nUINT16\nTPM2B_ID_OBJECT_Marshal(TPM2B_ID_OBJECT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:205 - Definition of TPMA_NV Bits (BitsTable()) */\n\nUINT16\nTPMA_NV_Marshal(TPMA_NV *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 226 - Definition of (UINT64) TPMA_NV_EXP Bits */\nUINT16\nTPMA_NV_EXP_Marshal(TPMA_NV_EXP *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT64_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 2:206 - Definition of TPMS_NV_PUBLIC Structure (StructuresTable()) */\n\nUINT16\nTPMS_NV_PUBLIC_Marshal(TPMS_NV_PUBLIC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_RH_NV_INDEX_Marshal(&source->nvIndex, buffer, size);\n    written += TPMI_ALG_HASH_Marshal(&source->nameAlg, buffer, size);\n    written += TPMA_NV_Marshal(&source->attributes, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->authPolicy, buffer, size);\n    written += UINT16_Marshal(&source->dataSize, buffer, size);\n    return written;\n}\n\n/* Table 2:207 - Definition of TPM2B_NV_PUBLIC Structure (StructuresTable()) */\n\nUINT16\nTPM2B_NV_PUBLIC_Marshal(TPM2B_NV_PUBLIC *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n    \t*buffer += sizeof(UINT16);\n    }\n    written += TPMS_NV_PUBLIC_Marshal(&source->nvPublic, buffer, size);\n    if (buffer != NULL) {\n\twritten += UINT16_Marshal(&written, &sizePtr, size);\n    }\n    else {\n\twritten += sizeof(UINT16);\n    }\n    return written;\n}\n\n/* Table 229 - Definition of TPMS_NV_PUBLIC_EXP_ATTR Structure */\nUINT16\nTPMS_NV_PUBLIC_EXP_ATTR_Marshal(TPMS_NV_PUBLIC_EXP_ATTR *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPMI_RH_NV_EXP_INDEX_Marshal(&source->nvIndex, buffer, size);\n    written += TPMI_ALG_HASH_Marshal(&source->nameAlg, buffer, size);\n    written += TPMA_NV_EXP_Marshal(&source->attributes, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->authPolicy, buffer, size);\n    written += UINT16_Marshal(&source->dataSize, buffer, size);\n    return written;\n}\n\n/* Table 230 - Definition of TPMU_NV_PUBLIC_2 Union */\n\nUINT16\nTPMU_NV_PUBLIC_2_Marshal(TPMU_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size, UINT8 selector)\n{\n    UINT16 written = 0;\n\n    switch (selector) {\n\n      case TPM_HT_NV_INDEX:\n\twritten += TPMS_NV_PUBLIC_Marshal(&source->nvIndex, buffer, size);\n\tbreak;\n      case TPM_HT_EXTERNAL_NV:\n\twritten += TPMS_NV_PUBLIC_EXP_ATTR_Marshal(&source->externalNV, buffer, size);\n\tbreak;\n      case TPM_HT_PERMANENT_NV:\n\twritten +=  TPMS_NV_PUBLIC_Marshal(&source->permanentNV, buffer, size);\n\tbreak;\n      default:\n\tpAssert(FALSE);\n    }\n    return written;\n}\n\n/* Table 231 - Definition of TPMT_NV_PUBLIC_2 Structure */\n\nUINT16\nTPMT_NV_PUBLIC_2_Marshal(TPMT_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += UINT8_Marshal(&source->handleType, buffer, size);\n    written += TPMU_NV_PUBLIC_2_Marshal(&source->nvPublic2, buffer, size, source->handleType);\n    return written;\n}\n\n/* Table 232 - Definition of TPM2B_NV_PUBLIC_2 Structure */\n\nUINT16\nTPM2B_NV_PUBLIC_2_Marshal(TPM2B_NV_PUBLIC_2 *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n    \t*buffer += sizeof(UINT16);\n    }\n    written += TPMT_NV_PUBLIC_2_Marshal(&source->nvPublic2, buffer, size);\n    if (buffer != NULL) {\n\twritten += UINT16_Marshal(&written, &sizePtr, size);\n    }\n    else {\n\twritten += sizeof(UINT16);\n    }\n    return written;\n}\n\n/* Table 2:210 - Definition of TPM2B_CONTEXT_DATA Structure (StructuresTable()) */\n\nUINT16\nTPM2B_CONTEXT_DATA_Marshal(TPM2B_CONTEXT_DATA  *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += TPM2B_Marshal(&source->b, buffer, size);\n    return written;\n}\n\n/* Table 2:211 - Definition of TPMS_CONTEXT Structure (StructuresTable()) */\n\nUINT16\nTPMS_CONTEXT_Marshal(TPMS_CONTEXT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += UINT64_Marshal(&source->sequence, buffer, size);\n    written += TPMI_DH_SAVED_Marshal(&source->savedHandle, buffer, size);\n    written += TPMI_RH_HIERARCHY_Marshal(&source->hierarchy, buffer, size);\n    written += TPM2B_CONTEXT_DATA_Marshal(&source->contextBlob, buffer, size);\n    return written;\n}\n\n/* Table 2:213 - Definition of TPMS_CREATION_DATA Structure (StructuresTable()) */\n\nUINT16\nTPMS_CREATION_DATA_Marshal(TPMS_CREATION_DATA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPML_PCR_SELECTION_Marshal(&source->pcrSelect, buffer, size);\n    written += TPM2B_DIGEST_Marshal(&source->pcrDigest, buffer, size);\n    written += TPMA_LOCALITY_Marshal(&source->locality, buffer, size);\n    written += TPM_ALG_ID_Marshal(&source->parentNameAlg, buffer, size);\n    written += TPM2B_NAME_Marshal(&source->parentName, buffer, size);\n    written += TPM2B_NAME_Marshal(&source->parentQualifiedName, buffer, size);\n    written += TPM2B_DATA_Marshal(&source->outsideInfo, buffer, size);\n    return written;\n}\n\n/* Table 2:214 - Definition of TPM2B_CREATION_DATA Structure (StructuresTable()) */\n\nUINT16\nTPM2B_CREATION_DATA_Marshal(TPM2B_CREATION_DATA *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    BYTE *sizePtr = NULL;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n    \t*buffer += sizeof(UINT16);\n    }\n    written += TPMS_CREATION_DATA_Marshal(&source->creationData, buffer, size);\n    if (buffer != NULL) {\n\twritten += UINT16_Marshal(&written, &sizePtr, size);\n    }\n    else {\n\twritten += sizeof(UINT16);\n    }\n    return written;\n}\n\n/* Table 225 - Definition of (UINT32) TPM_AT Constants */\n\nUINT16\nTPM_AT_Marshal(TPM_AT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    written += UINT32_Marshal(source, buffer, size);\n    return written;\n}\n\n/* Table 227 - Definition of TPMS_AC_OUTPUT Structure <OUT> */\n\nUINT16\nTPMS_AC_OUTPUT_Marshal(TPMS_AC_OUTPUT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n\n    written += TPM_AT_Marshal(&source->tag, buffer, size);\n    written += UINT32_Marshal(&source->data, buffer, size);\n    return written;\n}\n\n/* Table 228 - Definition of TPML_AC_CAPABILITIES Structure <OUT> */\n\nUINT16\nTPML_AC_CAPABILITIES_Marshal(TPML_AC_CAPABILITIES *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    UINT32 i;\n\n    written += UINT32_Marshal(&source->count, buffer, size);\n    for (i = 0 ; i < source->count ; i++) {\n\twritten += TPMS_AC_OUTPUT_Marshal(&source->acCapabilities[i], buffer, size);\n    }\n    return written;\n}\n\n"
  },
  {
    "path": "ftpm-opensbi/src/MathOnByteBuffers.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tMath functions performed with canonical integers in byte buffers\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// This file contains implementation of the math functions that are performed\n// with canonical integers in byte buffers. The canonical integer is\n// big-endian bytes.\n//\n#include \"Tpm.h\"\n#include \"TpmMath_Util_fp.h\"\n\n//** Functions\n\n//*** UnsignedCmpB\n// This function compare two unsigned values. The values are byte-aligned,\n// big-endian numbers (e.g, a hash).\n//  Return Type: int\n//      1          if (a > b)\n//      0          if (a = b)\n//      -1         if (a < b)\nLIB_EXPORT int UnsignedCompareB(UINT32      aSize,  // IN: size of a\n\t\t\t\tconst BYTE* a,      // IN: a\n\t\t\t\tUINT32      bSize,  // IN: size of b\n\t\t\t\tconst BYTE* b       // IN: b\n\t\t\t\t)\n{\n    UINT32 i;\n    if(aSize > bSize)\n\treturn 1;\n    else if(aSize < bSize)\n\treturn -1;\n    else\n\t{\n\t    for(i = 0; i < aSize; i++)\n\t\t{\n\t\t    if(a[i] != b[i])\n\t\t\treturn (a[i] > b[i]) ? 1 : -1;\n\t\t}\n\t}\n    // Will return == if sizes are both zero\n    return 0;\n}\n\n//***SignedCompareB()\n// Compare two signed integers:\n//  Return Type: int\n//      1         if a > b\n//      0         if a = b\n//      -1        if a < b\nint SignedCompareB(const UINT32 aSize,  // IN: size of a\n\t\t   const BYTE*  a,      // IN: a buffer\n\t\t   const UINT32 bSize,  // IN: size of b\n\t\t   const BYTE*  b       // IN: b buffer\n\t\t   )\n{\n    // are the signs different ?\n    if(((a[0] ^ b[0]) & 0x80) > 0)\n\t// if the signs are different, then a is less than b if a is negative.\n\treturn a[0] & 0x80 ? -1 : 1;\n    else\n\t// do unsigned compare function\n\treturn UnsignedCompareB(aSize, a, bSize, b);\n}\n\n#if ALG_RSA\n//*** ModExpB\n// This function is used to do modular exponentiation in support of RSA.\n// The most typical uses are: 'c' = 'm'^'e' mod 'n' (RSA encrypt) and\n// 'm' = 'c'^'d' mod 'n' (RSA decrypt).  When doing decryption, the 'e' parameter\n// of the function will contain the private exponent 'd' instead of the public\n// exponent 'e'.\n//\n// If the results will not fit in the provided buffer,\n// an error is returned (CRYPT_ERROR_UNDERFLOW). If the results is smaller\n// than the buffer, the results is de-normalized.\n//\n// This version is intended for use with RSA and requires that 'm' be\n// less than 'n'.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SIZE         number to exponentiate is larger than the modulus\n//      TPM_RC_NO_RESULT    result will not fit into the provided buffer\n//\nTPM_RC\nModExpB(UINT32 cSize,  // IN: the size of the output buffer. It will\n\t//     need to be the same size as the modulus\n\tBYTE* c,       // OUT: the buffer to receive the results\n\t//     (c->size must be set to the maximum size\n\t//     for the returned value)\n\tconst UINT32 mSize,\n\tconst BYTE*  m,  // IN: number to exponentiate\n\tconst UINT32 eSize,\n\tconst BYTE*  e,  // IN: power\n\tconst UINT32 nSize,\n\tconst BYTE*  n  // IN: modulus\n\t)\n{\n    CRYPT_INT_MAX(bnC);\n    CRYPT_INT_MAX(bnM);\n    CRYPT_INT_MAX(bnE);\n    CRYPT_INT_MAX(bnN);\n    NUMBYTES tSize  = (NUMBYTES)nSize;\n    TPM_RC   retVal = TPM_RC_SUCCESS;\n    \n    // Convert input parameters\n    ExtMath_IntFromBytes(bnM, m, (NUMBYTES)mSize);\n    ExtMath_IntFromBytes(bnE, e, (NUMBYTES)eSize);\n    ExtMath_IntFromBytes(bnN, n, (NUMBYTES)nSize);\n    \n    // Make sure that the output is big enough to hold the result\n    // and that 'm' is less than 'n' (the modulus)\n    if(cSize < nSize)\n\tERROR_EXIT(TPM_RC_NO_RESULT);\n    if(ExtMath_UnsignedCmp(bnM, bnN) >= 0)\n\tERROR_EXIT(TPM_RC_SIZE);\n    ExtMath_ModExp(bnC, bnM, bnE, bnN);\n    ExtMath_IntToBytes(bnC, c, &tSize);\n Exit:\n    return retVal;\n}\n#endif  // ALG_RSA\n\n//*** DivideB()\n// Divide an integer ('n') by an integer ('d') producing a quotient ('q') and\n// a remainder ('r'). If 'q' or 'r' is not needed, then the pointer to them\n// may be set to NULL.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT         'q' or 'r' is too small to receive the result\n//\nLIB_EXPORT TPM_RC DivideB(const TPM2B* n,  // IN: numerator\n\t\t\t  const TPM2B* d,  // IN: denominator\n\t\t\t  TPM2B*       q,  // OUT: quotient\n\t\t\t  TPM2B*       r   // OUT: remainder\n\t\t\t  )\n{\n    CRYPT_INT_MAX_INITIALIZED(bnN, n);\n    CRYPT_INT_MAX_INITIALIZED(bnD, d);\n    CRYPT_INT_MAX(bnQ);\n    CRYPT_INT_MAX(bnR);\n    //\n    // Do divide with converted values\n    ExtMath_Divide(bnQ, bnR, bnN, bnD);\n    \n    // Convert the Crypt_Int* result back to 2B format using the size of the original\n    // number\n    if(q != NULL)\n\tif(!TpmMath_IntTo2B(bnQ, q, q->size))\n\t    return TPM_RC_NO_RESULT;\n    if(r != NULL)\n\tif(!TpmMath_IntTo2B(bnR, r, r->size))\n\t    return TPM_RC_NO_RESULT;\n    return TPM_RC_SUCCESS;\n}\n\n//*** AdjustNumberB()\n// Remove/add leading zeros from a number in a TPM2B. Will try to make the number\n// by adding or removing leading zeros. If the number is larger than the requested\n// size, it will make the number as small as possible. Setting 'requestedSize' to\n// zero is equivalent to requesting that the number be normalized.\nUINT16\nAdjustNumberB(TPM2B* num, UINT16 requestedSize)\n{\n    BYTE*  from;\n    UINT16 i;\n    // See if number is already the requested size\n    if(num->size == requestedSize)\n\treturn requestedSize;\n    from = num->buffer;\n    if(num->size > requestedSize)\n\t{\n\t    // This is a request to shift the number to the left (remove leading zeros)\n\t    // Find the first non-zero byte. Don't look past the point where removing\n\t    // more zeros would make the number smaller than requested, and don't throw\n\t    // away any significant digits.\n\t    for(i = num->size; *from == 0 && i > requestedSize; from++, i--)\n\t\t;\n\t    if(i < num->size)\n\t\t{\n\t\t    num->size = i;\n\t\t    MemoryCopy(num->buffer, from, i);\n\t\t}\n\t}\n    // This is a request to shift the number to the right (add leading zeros)\n    else\n\t{\n\t    MemoryCopy(&num->buffer[requestedSize - num->size], num->buffer, num->size);\n\t    MemorySet(num->buffer, 0, requestedSize - num->size);\n\t    num->size = requestedSize;\n\t}\n    return num->size;\n}\n\n//*** ShiftLeft()\n// This function shifts a byte buffer (a TPM2B) one byte to the left. That is,\n// the most significant bit of the most significant byte is lost.\nTPM2B* ShiftLeft(TPM2B* value  // IN/OUT: value to shift and shifted value out\n\t\t )\n{\n    UINT16 count  = value->size;\n    BYTE*  buffer = value->buffer;\n    if(count > 0)\n\t{\n\t    for(count -= 1; count > 0; buffer++, count--)\n\t\t{\n\t\t    buffer[0] = (buffer[0] << 1) + ((buffer[1] & 0x80) ? 1 : 0);\n\t\t}\n\t    *buffer <<= 1;\n\t}\n    return value;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/Memory.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t Miscellaneous Memory Manipulation Routines    \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Memory.c 1658 2021-01-22 23:14:01Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.12 Memory.c */\n/* 9.12.1 Description */\n/* This file contains a set of miscellaneous memory manipulation routines. Many of the functions\n   have the same semantics as functions defined in string.h. Those functions are not used directly\n   in the TPM because they are not safe */\n/* This version uses string.h after adding guards.  This is because the math libraries invariably\n   use those functions so it is not practical to prevent those library functions from being pulled\n   into the build. */\n/* 9.12.2 Includes and Data Definitions */\n#include \"Tpm.h\"\n#include \"Memory_fp.h\"\n/* 9.12.3 Functions */\n/* 9.12.3.1 MemoryCopy() */\n/* This is an alias for memmove. This is used in place of memcpy because some of the moves may\n   overlap and rather than try to make sure that memmove is used when necessary, it is always\n   used. */\n\nvoid\nMemoryCopy(\n\t   void        *dest,\n\t   const void  *src,\n\t   int          sSize\n\t   )\n{\n    if (dest != src)\n\tmemmove(dest, src, sSize);\n}\n\n/* 9.12.3.2 MemoryEqual() */\n/* This function indicates if two buffers have the same values in the indicated number of bytes. */\n/* Return Values Meaning */\n/* TRUE all octets are the same */\n/* FALSE all octets are not the same */\nBOOL\nMemoryEqual(\n\t    const void      *buffer1,       // IN: compare buffer1\n\t    const void      *buffer2,       // IN: compare buffer2\n\t    unsigned int     size           // IN: size of bytes being compared\n\t    )\n{\n    BYTE         equal = 0;\n    const BYTE  *b1 = (BYTE *)buffer1;\n    const BYTE  *b2 = (BYTE *)buffer2;\n    //\n    // Compare all bytes so that there is no leakage of information\n    // due to timing differences.\n    for(; size > 0; size--)\n\tequal |= (*b1++ ^ *b2++);\n    return (equal == 0);\n}\n/* 9.12.3.3 MemoryCopy2B() */\n/* This function copies a TPM2B. This can be used when the TPM2B types are the same or different. */\n/* This function returns the number of octets in the data buffer of the TPM2B. */\nLIB_EXPORT INT16\nMemoryCopy2B(\n\t     TPM2B           *dest,          // OUT: receiving TPM2B\n\t     const TPM2B     *source,        // IN: source TPM2B\n\t     unsigned int     dSize          // IN: size of the receiving buffer\n\t     )\n{\n    pAssert(dest != NULL);\n    if(source == NULL)\n\tdest->size = 0;\n    else\n\t{\n\t    pAssert(source->size <= dSize);\n\t    MemoryCopy(dest->buffer, source->buffer, source->size);\n\t    dest->size = source->size;\n\t}\n    return dest->size;\n}\n/* 9.12.3.4 MemoryConcat2B() */\n/* This function will concatenate the buffer contents of a TPM2B to the buffer contents of\n   another TPM2B and adjust the size accordingly (a := (a | b)). */\nvoid\nMemoryConcat2B(\n\t       TPM2B           *aInOut,        // IN/OUT: destination 2B\n\t       TPM2B           *bIn,           // IN: second 2B\n\t       unsigned int     aMaxSize       // IN: The size of aInOut.buffer (max values for\n\t       //     aInOut.size)\n\t       )\n{\n    pAssert(bIn->size <= aMaxSize - aInOut->size);\n    MemoryCopy(&aInOut->buffer[aInOut->size], &bIn->buffer, bIn->size);\n    aInOut->size = aInOut->size + bIn->size;\n    return;\n}\n/* 9.12.3.5 MemoryEqual2B() */\n/* This function will compare two TPM2B structures. To be equal, they need to be the same size and\n   the buffer contexts need to be the same in all octets. */\n/* Return Values Meaning */\n/* TRUE size and buffer contents are the same */\n/* FALSE size or buffer contents are not the same */\nBOOL\nMemoryEqual2B(\n\t      const TPM2B     *aIn,           // IN: compare value\n\t      const TPM2B     *bIn            // IN: compare value\n\t      )\n{\n    if(aIn->size != bIn->size)\n\treturn FALSE;\n    return MemoryEqual(aIn->buffer, bIn->buffer, aIn->size);\n}\n/* 9.12.3.6 MemorySet() */\n/* This function will set all the octets in the specified memory range to the specified octet\n   value. */\n/* NOTE: A previous version had an additional parameter (dSize) that was intended to make sure that\n   the destination would not be overrun. The problem is that, in use, all that was happening was\n   that the value of size was used for dSize so there was no benefit in the extra parameter. */\n\nvoid\nMemorySet(\n\t  void            *dest,\n\t  int              value,\n\t  size_t           size\n\t  )\n{\n    memset(dest, value, size);\n}\n\n/* 9.12.3.7 MemoryPad2B() */\n/* Function to pad a TPM2B with zeros and adjust the size. */\n\nvoid\nMemoryPad2B(\n\t    TPM2B           *b,\n\t    UINT16           newSize\n\t    )\n{\n    MemorySet(&b->buffer[b->size], 0, newSize - b->size);\n    b->size = newSize;\n}\n\n/* 9.12.3.8 Uint16ToByteArray() */\n/* Function to write an integer to a byte array */\n\nvoid\nUint16ToByteArray(\n\t\t  UINT16              i,\n\t\t  BYTE                *a\n\t\t  )\n{\n    a[1] = (BYTE)(i); i >>= 8;\n    a[0] = (BYTE)(i);\n}\n\n/* 9.12.3.9 Uint32ToByteArray() */\n/* Function to write an integer to a byte array */\n\nvoid\nUint32ToByteArray(\n\t\t  UINT32              i,\n\t\t  BYTE                *a\n\t\t  )\n{\n    a[3] = (BYTE)(i); i >>= 8;\n    a[2] = (BYTE)(i); i >>= 8;\n    a[1] = (BYTE)(i); i >>= 8;\n    a[0] = (BYTE)(i);\n}\n\n/* 9.12.3.10 Uint64ToByteArray() */\n/* Function to write an integer to a byte array */\n\nvoid\nUint64ToByteArray(\n\t\t  UINT64               i,\n\t\t  BYTE                *a\n\t\t  )\n{\n    a[7] = (BYTE)(i); i >>= 8;\n    a[6] = (BYTE)(i); i >>= 8;\n    a[5] = (BYTE)(i); i >>= 8;\n    a[4] = (BYTE)(i); i >>= 8;\n    a[3] = (BYTE)(i); i >>= 8;\n    a[2] = (BYTE)(i); i >>= 8;\n    a[1] = (BYTE)(i); i >>= 8;\n    a[0] = (BYTE)(i);\n}\n\n/* 9.12.3.11\tByteArrayToUint8() */\n/* Function to write a UINT8 to a byte array. This is included for completeness and to allow certain\n   macro expansions */\nUINT8\nByteArrayToUint8(\n\t\t BYTE                *a\n\t\t )\n{\n    return          *a;\n}\n\n/* 9.12.3.12 ByteArrayToUint16() */\n/* Function to write an integer to a byte array */\n\nUINT16\nByteArrayToUint16(\n\t\t  BYTE                *a\n\t\t  )\n{\n    return ((UINT16)a[0] << 8) + a[1];\n}\n\n/* 9.12.3.13 ByteArrayToUint32() */\n/* Function to write an integer to a byte array */\n\nUINT32\nByteArrayToUint32(\n\t\t  BYTE                *a\n\t\t  )\n{\n    return (UINT32)((((((UINT32)a[0] << 8) + a[1]) << 8) + (UINT32)a[2]) << 8) + a[3];\n}\n\n/* 9.12.3.14 ByteArrayToUint64() */\n/* Function to write an integer to a byte array */\n\nUINT64\nByteArrayToUint64(\n\t\t  BYTE                *a\n\t\t  )\n{\n    return (((UINT64)BYTE_ARRAY_TO_UINT32(a)) << 32) + BYTE_ARRAY_TO_UINT32(&a[4]);\n}\n\n"
  },
  {
    "path": "ftpm-opensbi/src/NVCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Non-Volatile Storage \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"NV_DefineSpace_fp.h\"\n\nextern int verbose;\n\n#if CC_NV_DefineSpace  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_DefineSpace(\n\t\t    NV_DefineSpace_In   *in             // IN: input parameter list\n\t\t    )\n{\n    TPMA_NV         attributes = in->publicInfo.nvPublic.attributes;\n    UINT16          nameSize;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_DefineSpace: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_DefineSpace: nvIndex %08x attributes %08x\\n\",\n\t// \tin->publicInfo.nvPublic.nvIndex, in->publicInfo.nvPublic.attributes);\n\t// fclose(f);\n  //   }\n    nameSize = CryptHashGetDigestSize(in->publicInfo.nvPublic.nameAlg);\n    // Input Validation\n    // Checks not specific to type\n    // If the UndefineSpaceSpecial command is not implemented, then can't have\n    // an index that can only be deleted with policy\n#if CC_NV_UndefineSpaceSpecial == NO\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, POLICY_DELETE))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n#endif\n    // check that the authPolicy consistent with hash algorithm\n    if(in->publicInfo.nvPublic.authPolicy.t.size != 0\n       && in->publicInfo.nvPublic.authPolicy.t.size != nameSize)\n\treturn TPM_RCS_SIZE + RC_NV_DefineSpace_publicInfo;\n    // make sure that the authValue is not too large\n    if(MemoryRemoveTrailingZeros(&in->auth)\n       > CryptHashGetDigestSize(in->publicInfo.nvPublic.nameAlg))\n\treturn TPM_RCS_SIZE + RC_NV_DefineSpace_auth;\n    // If an index is being created by the owner and shEnable is\n    // clear, then we would not reach this point because ownerAuth\n    // can't be given when shEnable is CLEAR. However, if phEnable\n    // is SET but phEnableNV is CLEAR, we have to check here\n    if(in->authHandle == TPM_RH_PLATFORM && gc.phEnableNV == CLEAR)\n\treturn TPM_RCS_HIERARCHY + RC_NV_DefineSpace_authHandle;\n    // Attribute checks\n    // Eliminate the unsupported types\n    switch(GET_TPM_NT(attributes))\n\t{\n#if CC_NV_Increment == YES\n\t  case TPM_NT_COUNTER:\n#endif\n#if CC_NV_SetBits == YES\n\t  case TPM_NT_BITS:\n#endif\n#if CC_NV_Extend == YES\n\t  case TPM_NT_EXTEND:\n#endif\n#if CC_PolicySecret == YES && defined TPM_NT_PIN_PASS\n\t  case TPM_NT_PIN_PASS:\n\t  case TPM_NT_PIN_FAIL:\n#endif\n\t  case TPM_NT_ORDINARY:\n\t    break;\n\t  default:\n\t    return TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n\t    break;\n\t}\n    // Check that the sizes are OK based on the type\n    switch(GET_TPM_NT(attributes))\n\t{\n\t  case TPM_NT_ORDINARY:\n\t    // Can't exceed the allowed size for the implementation\n\t    if(in->publicInfo.nvPublic.dataSize > MAX_NV_INDEX_SIZE)\n\t\treturn TPM_RCS_SIZE + RC_NV_DefineSpace_publicInfo;\n\t    break;\n\t  case TPM_NT_EXTEND:\n\t    if(in->publicInfo.nvPublic.dataSize != nameSize)\n\t\treturn TPM_RCS_SIZE + RC_NV_DefineSpace_publicInfo;\n\t    break;\n\t  default:\n\t    // Everything else needs a size of 8\n\t    if(in->publicInfo.nvPublic.dataSize != 8)\n\t\treturn TPM_RCS_SIZE + RC_NV_DefineSpace_publicInfo;\n\t    break;\n\t}\n    // Handle other specifics\n    switch(GET_TPM_NT(attributes))\n\t{\n\t  case TPM_NT_COUNTER:\n\t    // Counter can't have TPMA_NV_CLEAR_STCLEAR SET (don't clear counters)\n\t    if(IS_ATTRIBUTE(attributes, TPMA_NV, CLEAR_STCLEAR))\n\t\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n\t    break;\n#ifdef TPM_NT_PIN_FAIL\n\t  case TPM_NT_PIN_FAIL:\n\t    // NV_NO_DA must be SET and AUTHWRITE must be CLEAR\n\t    // NOTE: As with a PIN_PASS index, the authValue of the index is not\n\t    // available until the index is written. If AUTHWRITE is the only way to\n\t    // write then index, it could never be written. Rather than go through\n\t    // all of the other possible ways to write the Index, it is simply\n\t    // prohibited to write the index with the authValue. Other checks\n\t    // below will insure that there seems to be a way to write the index\n\t    // (i.e., with platform authorization , owner authorization,\n\t    // or with policyAuth.)\n\t    // It is not allowed to create a PIN Index that can't be modified.\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_NV, NO_DA))\n\t\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n#endif\n#ifdef TPM_NT_PIN_PASS\n\t  case TPM_NT_PIN_PASS:\n\t    // AUTHWRITE must be CLEAR (see note above to TPM_NT_PIN_FAIL)\n\t    if(IS_ATTRIBUTE(attributes, TPMA_NV, AUTHWRITE)\n\t       || IS_ATTRIBUTE(attributes, TPMA_NV, GLOBALLOCK)\n\t       || IS_ATTRIBUTE(attributes, TPMA_NV, WRITEDEFINE))\n\t\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n#endif  // this comes before break because PIN_FAIL falls through\n\t    break;\n\t  default:\n\t    break;\n\t}\n    // Locks may not be SET and written cannot be SET\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, WRITTEN)\n       || IS_ATTRIBUTE(attributes, TPMA_NV, WRITELOCKED)\n       || IS_ATTRIBUTE(attributes, TPMA_NV, READLOCKED))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n    // There must be a way to read the index.\n    if(!IS_ATTRIBUTE(attributes, TPMA_NV, OWNERREAD)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, PPREAD)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, AUTHREAD)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, POLICYREAD))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n    // There must be a way to write the index\n    if(!IS_ATTRIBUTE(attributes, TPMA_NV, OWNERWRITE)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, PPWRITE)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, AUTHWRITE)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, POLICYWRITE))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n    // An index with TPMA_NV_CLEAR_STCLEAR can't have TPMA_NV_WRITEDEFINE SET\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, CLEAR_STCLEAR)\n       &&  IS_ATTRIBUTE(attributes, TPMA_NV, WRITEDEFINE))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n    // Make sure that the creator of the index can delete the index\n    if((IS_ATTRIBUTE(attributes, TPMA_NV, PLATFORMCREATE)\n\t&& in->authHandle == TPM_RH_OWNER)\n       || (!IS_ATTRIBUTE(attributes, TPMA_NV, PLATFORMCREATE)\n\t   && in->authHandle == TPM_RH_PLATFORM))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_authHandle;\n    // If TPMA_NV_POLICY_DELETE is SET, then the index must be defined by\n    // the platform\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, POLICY_DELETE)\n       &&  TPM_RH_PLATFORM != in->authHandle)\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace_publicInfo;\n    // Make sure that the TPMA_NV_WRITEALL is not set if the index size is larger\n    // than the allowed NV buffer size.\n    if(in->publicInfo.nvPublic.dataSize > MAX_NV_BUFFER_SIZE\n       &&  IS_ATTRIBUTE(attributes, TPMA_NV, WRITEALL))\n\treturn TPM_RCS_SIZE + RC_NV_DefineSpace_publicInfo;\n    // And finally, see if the index is already defined.\n    if(NvIndexIsDefined(in->publicInfo.nvPublic.nvIndex))\n\treturn TPM_RC_NV_DEFINED;\n    // Internal Data Update\n    // define the space.  A TPM_RC_NV_SPACE error may be returned at this point\n    return NvDefineIndex(&in->publicInfo.nvPublic, &in->auth);\n}\n#endif // CC_NV_DefineSpace\n#include \"Tpm.h\"\n#include \"NV_UndefineSpace_fp.h\"\n#if CC_NV_UndefineSpace  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_UndefineSpace(\n\t\t      NV_UndefineSpace_In     *in             // IN: input parameter list\n\t\t      )\n{\n    NV_REF           locator;\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_UndefineSpace: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_UndefineSpace: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // This command can't be used to delete an index with TPMA_NV_POLICY_DELETE SET\n    if(IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, POLICY_DELETE))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_UndefineSpace_nvIndex;\n    // The owner may only delete an index that was defined with ownerAuth. The\n    // platform may delete an index that was created with either authorization.\n    if(in->authHandle == TPM_RH_OWNER\n       && IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, PLATFORMCREATE))\n\treturn TPM_RC_NV_AUTHORIZATION;\n    // Internal Data Update\n    // Call implementation dependent internal routine to delete NV index\n    return NvDeleteIndex(nvIndex, locator);\n}\n#endif // CC_NV_UndefineSpace\n#include \"Tpm.h\"\n#include \"NV_UndefineSpaceSpecial_fp.h\"\n#include \"SessionProcess_fp.h\"\n#if CC_NV_UndefineSpaceSpecial  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_UndefineSpaceSpecial(\n\t\t\t     NV_UndefineSpaceSpecial_In  *in             // IN: input parameter list\n\t\t\t     )\n{\n    TPM_RC           result;\n    NV_REF           locator;\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_UndefineSpaceSpecial: nvIndex %08x\\n\", in->nvIndex);\n\t// fprintf(f, \"TPM2_NV_UndefineSpaceSpecial: platform %08x\\n\", in->platform );\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // This operation only applies when the TPMA_NV_POLICY_DELETE attribute is SET\n    if(!IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, POLICY_DELETE))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_UndefineSpaceSpecial_nvIndex;\n    // Internal Data Update\n    // Call implementation dependent internal routine to delete NV index\n    result = NvDeleteIndex(nvIndex, locator);\n    // If we just removed the index providing the authorization, make sure that the\n    // authorization session computation is modified so that it doesn't try to\n    // access the authValue of the just deleted index\n    if(result == TPM_RC_SUCCESS)\n\tSessionRemoveAssociationToHandle(in->nvIndex);\n    return result;\n}\n#endif // CC_NV_UndefineSpaceSpecial\n#include \"Tpm.h\"\n#include \"NV_ReadPublic_fp.h\"\n#if CC_NV_ReadPublic  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_ReadPublic(\n\t\t   NV_ReadPublic_In    *in,            // IN: input parameter list\n\t\t   NV_ReadPublic_Out   *out            // OUT: output parameter list\n\t\t   )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_ReadPublic: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, NULL);\n    // Command Output\n    // Copy index public data to output\n    out->nvPublic.nvPublic = nvIndex->publicArea;\n    // Compute NV name\n    NvGetIndexName(nvIndex, &out->nvName);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_NV_ReadPublic\n#include \"Tpm.h\"\n#include \"NV_Write_fp.h\"\n#if CC_NV_Write  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_Write(\n\t      NV_Write_In     *in             // IN: input parameter list\n\t      )\n{\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, NULL);\n    TPMA_NV          attributes = nvIndex->publicArea.attributes;\n    TPM_RC           result;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_Write: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_Write: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION\n    // or TPM_RC_NV_LOCKED\n    result = NvWriteAccessChecks(in->authHandle,\n\t\t\t\t in->nvIndex,\n\t\t\t\t attributes);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Bits index, extend index or counter index may not be updated by\n    // TPM2_NV_Write\n    if(IsNvCounterIndex(attributes)\n       || IsNvBitsIndex(attributes)\n       || IsNvExtendIndex(attributes))\n\treturn TPM_RC_ATTRIBUTES;\n    // Make sure that the offset is not too large\n    if(in->offset > nvIndex->publicArea.dataSize)\n\treturn TPM_RCS_VALUE + RC_NV_Write_offset;\n    // Make sure that the selection is within the range of the Index\n    if(in->data.t.size > (nvIndex->publicArea.dataSize - in->offset))\n\treturn TPM_RC_NV_RANGE;\n    // If this index requires a full sized write, make sure that input range is\n    // full sized.\n    // Note: if the requested size is the same as the Index data size, then offset\n    // will have to be zero. Otherwise, the range check above would have failed.\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, WRITEALL)\n       && in->data.t.size < nvIndex->publicArea.dataSize)\n\treturn TPM_RC_NV_RANGE;\n    // Internal Data Update\n    // Perform the write.  This called routine will SET the TPMA_NV_WRITTEN\n    // attribute if it has not already been SET. If NV isn't available, an error\n    // will be returned.\n    return NvWriteIndexData(nvIndex, in->offset, in->data.t.size,\n\t\t\t    in->data.t.buffer);\n}\n#endif // CC_NV_Write\n#include \"Tpm.h\"\n#include \"NV_Increment_fp.h\"\n#if CC_NV_Increment  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_Increment(\n\t\t  NV_Increment_In     *in             // IN: input parameter list\n\t\t  )\n{\n    TPM_RC           result;\n    NV_REF           locator;\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n    UINT64           countValue;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_Increment: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_Increment: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION\n    // or TPM_RC_NV_LOCKED\n    result = NvWriteAccessChecks(in->authHandle,\n\t\t\t\t in->nvIndex,\n\t\t\t\t nvIndex->publicArea.attributes);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Make sure that this is a counter\n    if(!IsNvCounterIndex(nvIndex->publicArea.attributes))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_Increment_nvIndex;\n    // Internal Data Update\n    // If counter index is not been written, initialize it\n    if(!IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, WRITTEN))\n\tcountValue = NvReadMaxCount();\n    else\n\t// Read NV data in native format for TPM CPU.\n\tcountValue = NvGetUINT64Data(nvIndex, locator);\n    // Do the increment\n    countValue++;\n    // Write NV data back. A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may\n    // be returned at this point. If necessary, this function will set the\n    // TPMA_NV_WRITTEN attribute\n    result = NvWriteUINT64Data(nvIndex, countValue);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    // If a counter just rolled over, then force the NV update.\n\t    // Note, if this is an orderly counter, then the write-back needs to be\n\t    // forced, for other counters, the write-back will happen anyway\n\t    if(IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, ORDERLY)\n\t       && (countValue & MAX_ORDERLY_COUNT) == 0 )\n\t\t{\n\t\t    // Need to force an NV update of orderly data\n\t\t    SET_NV_UPDATE(UT_ORDERLY);\n\t\t}\n\t}\n    return result;\n}\n#endif // CC_NV_Increment\n#include \"Tpm.h\"\n#include \"NV_Extend_fp.h\"\n#if CC_NV_Extend  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_Extend(\n\t       NV_Extend_In    *in             // IN: input parameter list\n\t       )\n{\n    TPM_RC                   result;\n    NV_REF                   locator;\n    NV_INDEX                *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n    TPM2B_DIGEST            oldDigest;\n    TPM2B_DIGEST            newDigest;\n    HASH_STATE              hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_Extend: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_Extend: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION\n    // or TPM_RC_NV_LOCKED\n    result = NvWriteAccessChecks(in->authHandle,\n\t\t\t\t in->nvIndex,\n\t\t\t\t nvIndex->publicArea.attributes);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Make sure that this is an extend index\n    if(!IsNvExtendIndex(nvIndex->publicArea.attributes))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_Extend_nvIndex;\n    // Internal Data Update\n    // Perform the write.\n    oldDigest.t.size = CryptHashGetDigestSize(nvIndex->publicArea.nameAlg);\n    pAssert(oldDigest.t.size <= sizeof(oldDigest.t.buffer));\n    if(IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, WRITTEN))\n\t{\n\t    NvGetIndexData(nvIndex, locator, 0, oldDigest.t.size, oldDigest.t.buffer);\n\t}\n    else\n\t{\n\t    MemorySet(oldDigest.t.buffer, 0, oldDigest.t.size);\n\t}\n    // Start hash\n    newDigest.t.size = CryptHashStart(&hashState, nvIndex->publicArea.nameAlg);\n    // Adding old digest\n    CryptDigestUpdate2B(&hashState, &oldDigest.b);\n    // Adding new data\n    CryptDigestUpdate2B(&hashState, &in->data.b);\n    // Complete hash\n    CryptHashEnd2B(&hashState, &newDigest.b);\n    // Write extended hash back.\n    // Note, this routine will SET the TPMA_NV_WRITTEN attribute if necessary\n    return NvWriteIndexData(nvIndex, 0, newDigest.t.size, newDigest.t.buffer);\n}\n#endif // CC_NV_Extend\n#include \"Tpm.h\"\n#include \"NV_SetBits_fp.h\"\n#if CC_NV_SetBits  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_SetBits(\n\t\tNV_SetBits_In   *in             // IN: input parameter list\n\t\t)\n{\n    TPM_RC           result;\n    NV_REF           locator;\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n    UINT64           oldValue;\n    UINT64           newValue;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_SetBits: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_SetBits: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION\n    // or TPM_RC_NV_LOCKED\n    result = NvWriteAccessChecks(in->authHandle,\n\t\t\t\t in->nvIndex,\n\t\t\t\t nvIndex->publicArea.attributes);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Make sure that this is a bit field\n    if(!IsNvBitsIndex(nvIndex->publicArea.attributes))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_SetBits_nvIndex;\n    // If index is not been written, initialize it\n    if(!IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, WRITTEN))\n\toldValue = 0;\n    else\n\t// Read index data\n\toldValue = NvGetUINT64Data(nvIndex, locator);\n    // Figure out what the new value is going to be\n    newValue = oldValue | in->bits;\n    // Internal Data Update\n    return  NvWriteUINT64Data(nvIndex, newValue);\n}\n#endif // CC_NV_SetBits\n#include \"Tpm.h\"\n#include \"NV_WriteLock_fp.h\"\n#if CC_NV_WriteLock  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_WriteLock(\n\t\t  NV_WriteLock_In     *in             // IN: input parameter list\n\t\t  )\n{\n    TPM_RC           result;\n    NV_REF           locator;\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n    TPMA_NV          nvAttributes = nvIndex->publicArea.attributes;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_WriteLock: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_WriteLock: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // Input Validation:\n    // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION\n    // or TPM_RC_NV_LOCKED\n    result = NvWriteAccessChecks(in->authHandle, in->nvIndex, nvAttributes);\n    if(result != TPM_RC_SUCCESS)\n\t{\n\t    if(result == TPM_RC_NV_AUTHORIZATION)\n\t\treturn result;\n\t    // If write access failed because the index is already locked, then it is\n\t    // no error.\n\t    return TPM_RC_SUCCESS;\n\t}\n    // if neither TPMA_NV_WRITEDEFINE nor TPMA_NV_WRITE_STCLEAR is set, the index\n    // can not be write-locked\n    if(!IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITEDEFINE)\n       && !IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITE_STCLEAR))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_WriteLock_nvIndex;\n    // Internal Data Update\n    // Set the WRITELOCK attribute.\n    // Note: if TPMA_NV_WRITELOCKED were already SET, then the write access check\n    // above would have failed and this code isn't executed.\n    SET_ATTRIBUTE(nvAttributes, TPMA_NV, WRITELOCKED);\n    // Write index info back\n    return NvWriteIndexAttributes(nvIndex->publicArea.nvIndex, locator,\n\t\t\t\t  nvAttributes);\n}\n#endif // CC_NV_WriteLock\n#include \"Tpm.h\"\n#include \"NV_GlobalWriteLock_fp.h\"\n#if CC_NV_GlobalWriteLock  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_GlobalWriteLock(\n\t\t\tNV_GlobalWriteLock_In   *in             // IN: input parameter list\n\t\t\t)\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_GlobalWriteLock: authHandle %08x\\n\", in->authHandle);\n\t// fclose(f);\n  //   }\n    // Input parameter (the authorization handle) is not reference in command action.\n    NOT_REFERENCED(in);\n    // Internal Data Update\n    // Implementation dependent method of setting the global lock\n    return NvSetGlobalLock();\n}\n#endif // CC_NV_GlobalWriteLock\n#include \"Tpm.h\"\n#include \"NV_Read_fp.h\"\n#if CC_NV_Read  // Conditional expansion of this file\n/* TPM_RC_NV_AUTHORIZATION the authorization was valid but the authorizing entity (authHandle) is\n   not allowed to read from the Index referenced by nvIndex */\n/* TPM_RC_NV_LOCKED the Index referenced by nvIndex is read locked */\n/* TPM_RC_NV_RANGE read range defined by size and offset is outside the range of the Index\n   referenced by nvIndex */\n/* TPM_RC_NV_UNINITIALIZED the Index referenced by nvIndex has not been initialized (written) */\n/* TPM_RC_VALUE the read size is larger than the MAX_NV_BUFFER_SIZE */\nTPM_RC\nTPM2_NV_Read(\n\t     NV_Read_In      *in,            // IN: input parameter list\n\t     NV_Read_Out     *out            // OUT: output parameter list\n\t     )\n{\n    NV_REF           locator;\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n    TPM_RC           result;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_Read: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_Read: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Common read access checks. NvReadAccessChecks() may return\n    // TPM_RC_NV_AUTHORIZATION, TPM_RC_NV_LOCKED, or TPM_RC_NV_UNINITIALIZED\n    result = NvReadAccessChecks(in->authHandle, in->nvIndex,\n\t\t\t\tnvIndex->publicArea.attributes);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Make sure the data will fit the return buffer\n    if(in->size > MAX_NV_BUFFER_SIZE)\n\treturn TPM_RCS_VALUE + RC_NV_Read_size;\n    // Verify that the offset is not too large\n    if(in->offset > nvIndex->publicArea.dataSize)\n\treturn TPM_RCS_VALUE + RC_NV_Read_offset;\n    // Make sure that the selection is within the range of the Index\n    if(in->size > (nvIndex->publicArea.dataSize - in->offset))\n\treturn TPM_RC_NV_RANGE;\n    // Command Output\n    // Set the return size\n    out->data.t.size = in->size;\n    // Perform the read\n    NvGetIndexData(nvIndex, locator, in->offset, in->size, out->data.t.buffer);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_NV_Read\n#include \"Tpm.h\"\n#include \"NV_ReadLock_fp.h\"\n#if CC_NV_ReadLock  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_ReadLock(\n\t\t NV_ReadLock_In  *in             // IN: input parameter list\n\t\t )\n{\n    TPM_RC           result;\n    NV_REF           locator;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_ReadLock: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_ReadLock: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // The referenced index has been checked multiple times before this is called\n    // so it must be present and will be loaded into cache\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n    TPMA_NV          nvAttributes = nvIndex->publicArea.attributes;\n    // Input Validation\n    // Common read access checks. NvReadAccessChecks() may return\n    // TPM_RC_NV_AUTHORIZATION, TPM_RC_NV_LOCKED, or TPM_RC_NV_UNINITIALIZED\n    result = NvReadAccessChecks(in->authHandle,\n\t\t\t\tin->nvIndex,\n\t\t\t\tnvAttributes);\n    if(result == TPM_RC_NV_AUTHORIZATION)\n\treturn TPM_RC_NV_AUTHORIZATION;\n    // Index is already locked for write\n    else if(result == TPM_RC_NV_LOCKED)\n\treturn TPM_RC_SUCCESS;\n    // If NvReadAccessChecks return TPM_RC_NV_UNINITALIZED, then continue.\n    // It is not an error to read lock an uninitialized Index.\n    // if TPMA_NV_READ_STCLEAR is not set, the index can not be read-locked\n    if(!IS_ATTRIBUTE(nvAttributes, TPMA_NV, READ_STCLEAR))\n\treturn TPM_RCS_ATTRIBUTES + RC_NV_ReadLock_nvIndex;\n    // Internal Data Update\n    // Set the READLOCK attribute\n    SET_ATTRIBUTE(nvAttributes, TPMA_NV, READLOCKED);\n    // Write NV info back\n    return NvWriteIndexAttributes(nvIndex->publicArea.nvIndex,\n\t\t\t\t  locator,\n\t\t\t\t  nvAttributes);\n}\n#endif // CC_NV_ReadLock\n#include \"Tpm.h\"\n#include \"NV_ChangeAuth_fp.h\"\n#if CC_NV_ChangeAuth  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_ChangeAuth(\n\t\t   NV_ChangeAuth_In    *in             // IN: input parameter list\n\t\t   )\n{\n    NV_REF           locator;\n    NV_INDEX        *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_ChangeAuth: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Remove trailing zeros and make sure that the result is not larger than the\n    // digest of the nameAlg.\n    if(MemoryRemoveTrailingZeros(&in->newAuth)\n       > CryptHashGetDigestSize(nvIndex->publicArea.nameAlg))\n\treturn TPM_RCS_SIZE + RC_NV_ChangeAuth_newAuth;\n    // Internal Data Update\n    // Change authValue\n    return NvWriteIndexAuth(locator, &in->newAuth);\n}\n#endif // CC_NV_ChangeAuth\n#include \"Tpm.h\"\n#include \"Attest_spt_fp.h\"\n#include \"NV_Certify_fp.h\"\n#if CC_NV_Certify  // Conditional expansion of this file\nTPM_RC\nTPM2_NV_Certify(\n\t\tNV_Certify_In   *in,            // IN: input parameter list\n\t\tNV_Certify_Out  *out            // OUT: output parameter list\n\t\t)\n{\n    TPM_RC                  result;\n    NV_REF                   locator;\n    NV_INDEX                *nvIndex = NvGetIndexInfo(in->nvIndex, &locator);\n    TPMS_ATTEST              certifyInfo;\n    OBJECT                 *signObject = HandleToObject(in->signHandle);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_Certify: signHandle %08x\\n\", in->signHandle);\n\t// fprintf(f, \"TPM2_NV_Certify: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_Certify: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    if(!IsSigningObject(signObject))\n\treturn TPM_RCS_KEY + RC_NV_Certify_signHandle;\n    if(!CryptSelectSignScheme(signObject, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_NV_Certify_inScheme;\n    // Common access checks, NvWriteAccessCheck() may return TPM_RC_NV_AUTHORIZATION\n    // or TPM_RC_NV_LOCKED\n    result = NvReadAccessChecks(in->authHandle, in->nvIndex,\n\t\t\t\tnvIndex->publicArea.attributes);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // make sure that the selection is within the range of the Index (cast to avoid\n    // any wrap issues with addition)\n    if((UINT32)in->size + (UINT32)in->offset > (UINT32)nvIndex->publicArea.dataSize)\n\treturn TPM_RC_NV_RANGE;\n    // Make sure the data will fit the return buffer\n    // NOTE: This check may be modified if the output buffer will not hold the\n    // maximum sized NV buffer as part of the certified data. The difference in\n    // size could be substantial if the signature scheme was produced a large\n    // signature (e.g., RSA 4096).\n    if(in->size > MAX_NV_BUFFER_SIZE)\n\treturn TPM_RCS_VALUE + RC_NV_Certify_size;\n    // Command Output\n\n    // Fill in attest information common fields\n    FillInAttestInfo(in->signHandle, &in->inScheme, &in->qualifyingData,\n\t\t     &certifyInfo);\n\n    // Get the name of the index\n    NvGetIndexName(nvIndex, &certifyInfo.attested.nv.indexName);\n\n    // See if this is old format or new format\n    if ((in->size != 0) || (in->offset != 0))\n\t{\n\t    // NV certify specific fields\n\t    // Attestation type\n\t    certifyInfo.type = TPM_ST_ATTEST_NV;\n\n\t    // Set the return size\n\t    certifyInfo.attested.nv.nvContents.t.size = in->size;\n\n\t    // Set the offset\n\t    certifyInfo.attested.nv.offset = in->offset;\n\n\t    // Perform the read\n\t    NvGetIndexData(nvIndex, locator, in->offset, in->size,\n\t\t\t   certifyInfo.attested.nv.nvContents.t.buffer);\n\t}\n    else\n\t{\n\t    HASH_STATE                  hashState;\n\t    // This is to sign a digest of the data\n\t    certifyInfo.type = TPM_ST_ATTEST_NV_DIGEST;\n\t    // Initialize the hash before calling the function to add the Index data to\n\t    // the hash.\n\t    certifyInfo.attested.nvDigest.nvDigest.t.size =\n\t\tCryptHashStart(&hashState, in->inScheme.details.any.hashAlg);\n\t    NvHashIndexData(&hashState, nvIndex, locator, 0,\n\t\t\t    nvIndex->publicArea.dataSize);\n\t    CryptHashEnd2B(&hashState, &certifyInfo.attested.nvDigest.nvDigest.b);\n\t}\n    // Sign attestation structure.  A NULL signature will be returned if\n    // signObject is NULL.\n    return SignAttestInfo(signObject, &in->inScheme, &certifyInfo,\n\t\t\t  &in->qualifyingData, &out->certifyInfo, &out->signature);\n}\n#endif // CC_NV_Certify\n\n#include \"Tpm.h\"\n#include \"NV_ReadPublic2_fp.h\"\n\n#if CC_NV_ReadPublic2  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Read the public information of a NV index\n*/\nTPM_RC\nTPM2_NV_ReadPublic2(NV_ReadPublic2_In*  in,  // IN: input parameter list\n\t\t    NV_ReadPublic2_Out* out  // OUT: output parameter list\n\t\t    )\n{\n    TPM_RC    result;\n    NV_INDEX* nvIndex;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_ReadPublic2: nvIndex %08x\\n\", in->nvIndex);\n\t// fclose(f);\n  //   }\n\n    nvIndex = NvGetIndexInfo(in->nvIndex, NULL);\n\n    // Command Output\n\n    // The reference code stores its NV indices in the legacy form, because\n    // it doesn't support any extended attributes.\n    // Translate the legacy form to the general form.\n    result = NvPublic2FromNvPublic(&nvIndex->publicArea, &out->nvPublic.nvPublic2);\n    if(result != TPM_RC_SUCCESS)\n\t{\n\t    return RcSafeAddToResult(result, RC_NV_ReadPublic2_nvIndex);\n\t}\n\n    // Compute NV name\n    NvGetIndexName(nvIndex, &out->nvName);\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_NV_ReadPublic2\n\n#include \"Tpm.h\"\n#include \"NV_DefineSpace2_fp.h\"\n\n#if CC_NV_DefineSpace2  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Define a NV index space\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_HIERARCHY            for authorizations using TPM_RH_PLATFORM\n//                                  phEnable_NV is clear preventing access to NV\n//                                  data in the platform hierarchy.\n//      TPM_RC_ATTRIBUTES           attributes of the index are not consistent\n//      TPM_RC_NV_DEFINED           index already exists\n//      TPM_RC_NV_SPACE             insufficient space for the index\n//      TPM_RC_SIZE                 'auth->size' or 'publicInfo->authPolicy.size' is\n//                                  larger than the digest size of\n//                                  'publicInfo->nameAlg'; or 'publicInfo->dataSize'\n//                                  is not consistent with 'publicInfo->attributes'\n//                                  (this includes the case when the index is\n//                                   larger than a MAX_NV_BUFFER_SIZE but the\n//                                   TPMA_NV_WRITEALL attribute is SET)\nTPM_RC\nTPM2_NV_DefineSpace2(NV_DefineSpace2_In* in  // IN: input parameter list\n\t\t     )\n{\n    TPM_RC         result;\n    TPMS_NV_PUBLIC legacyPublic;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_NV_DefineSpace2: authHandle %08x\\n\", in->authHandle);\n\t// fprintf(f, \"TPM2_NV_DefineSpace2: nvIndex %08x\\n\",\n\t// \tin->publicInfo.nvPublic2.nvPublic2.nvIndex.nvIndex);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n\n    // Validate the handle type and the (handle-type-specific) attributes.\n    switch(in->publicInfo.nvPublic2.handleType)\n\t{\n\t  case TPM_HT_NV_INDEX:\n\t    break;\n#  if EXTERNAL_NV\n\t  case TPM_HT_EXTERNAL_NV:\n\t    // The reference implementation may let you define an \"external\" NV\n\t    // index, but it doesn't currently support setting any of the extended\n\t    // bits for customizing the behavior of external NV.\n\t    if((TPMA_NV_EXP_TO_UINT64(\n\t\t\t\t      in->publicInfo.nvPublic2.nvPublic2.externalNV.attributes)\n\t\t& 0xffffffff00000000)\n\t       != 0)\n\t\t{\n\t\t    return TPM_RCS_ATTRIBUTES + RC_NV_DefineSpace2_publicInfo;\n\t\t}\n\t    break;\n#  endif\n\t  default:\n\t    return TPM_RCS_HANDLE + RC_NV_DefineSpace2_publicInfo;\n\t}\n\n    result = NvPublicFromNvPublic2(&in->publicInfo.nvPublic2, &legacyPublic);\n    if(result != TPM_RC_SUCCESS)\n\t{\n\t    return RcSafeAddToResult(result, RC_NV_DefineSpace2_publicInfo);\n\t}\n\n    return NvDefineSpace(in->authHandle,\n\t\t\t &in->auth,\n\t\t\t &legacyPublic,\n\t\t\t RC_NV_DefineSpace2_authHandle,\n\t\t\t RC_NV_DefineSpace2_auth,\n\t\t\t RC_NV_DefineSpace2_publicInfo);\n}\n\n#endif  // CC_NV_DefineSpace\n"
  },
  {
    "path": "ftpm-opensbi/src/NVDynamic.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tDynamic space for user defined NV      \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n\n// The NV memory is divided into two areas: dynamic space for user defined NV\n// indexes and evict objects, and reserved space for TPM persistent and state save\n// data.\n//\n// The entries in dynamic space are a linked list of entries. Each entry has, as its\n// first field, a size. If the size field is zero, it marks the end of the\n// list.\n//\n// An Index allocation will contain an NV_INDEX structure. If the Index does not\n// have the orderly attribute, the NV_INDEX is followed immediately by the NV data.\n//\n// An evict object entry contains a handle followed by an OBJECT structure. This\n// results in both the Index and Evict Object having an identifying handle as the\n// first field following the size field.\n//\n// When an Index has the orderly attribute, the data is kept in RAM. This RAM is\n// saved to backing store in NV memory on any orderly shutdown. The entries in\n// orderly memory are also a linked list using a size field as the first entry.\n//\n// The attributes of an orderly index are maintained in RAM memory in order to\n// reduce the number of NV writes needed for orderly data. When an orderly index\n// is created, an entry is made in the dynamic NV memory space that holds the Index\n// authorizations (authPolicy and authValue) and the size of the data. This entry is\n// only modified if the authValue  of the index is changed. The more volatile data\n// of the index is kept in RAM. When an orderly Index is created or deleted, the\n// RAM data is copied to NV backing store so that the image in the backing store\n// matches the layout of RAM. In normal operation. The RAM data is also copied on\n// any orderly shutdown. In normal operation, the only other reason for writing\n// to the backing store for RAM is when a counter is first written (TPMA_NV_WRITTEN\n// changes from CLEAR to SET) or when a counter \"\"rolls over\"\".\n//\n// Static space contains items that are individually modifiable. The values are in\n// the 'gp' PERSISTENT_DATA structure in RAM and mapped to locations in NV.\n//\n\n//** Includes, Defines and Data Definitions\n#define NV_C\n#include \"Tpm.h\"\n#include \"Marshal.h\"\n\n//** Local Functions\n\n//*** NvNext()\n//  This function provides a method to traverse every data entry in NV dynamic\n//  area.\n//\n//  To begin with, parameter 'iter' should be initialized to NV_REF_INIT\n//  indicating the first element.  Every time this function is called, the\n//  value in 'iter' would be adjusted pointing to the next element in\n//  traversal.  If there is no next element, 'iter' value would be 0.\n//  This function returns the address of the 'data entry' pointed by the\n//  'iter'.  If there are no more elements in the set, a 0 value is returned\n//  indicating the end of traversal.\n//\nstatic NV_REF NvNext(NV_REF*     iter,   // IN/OUT: the list iterator\n\t\t     TPM_HANDLE* handle  // OUT: the handle of the next item.\n\t\t     )\n{\n    NV_REF          currentAddr;\n    NV_ENTRY_HEADER header;\n    //\n    // If iterator is at the beginning of list\n    if(*iter == NV_REF_INIT)\n\t{\n\t    // Initialize iterator\n\t    *iter = NV_USER_DYNAMIC;\n\t}\n    // Step over the size field and point to the handle\n    currentAddr = *iter + sizeof(UINT32);\n\n    // read the header of the next entry\n    NvRead(&header, *iter, sizeof(NV_ENTRY_HEADER));\n\n    // if the size field is zero, then we have hit the end of the list\n    if(header.size == 0)\n\t// leave the *iter pointing at the end of the list\n\treturn 0;\n    // advance the header by the size of the entry\n    *iter += header.size;\n\n    if(handle != NULL)\n\t*handle = header.handle;\n    return currentAddr;\n}\n\n//*** NvNextByType()\n// This function returns a reference to the next NV entry of the desired type\n//  Return Type: NV_REF\n//      0               end of list\n//      != 0            the next entry of the indicated type\nstatic NV_REF NvNextByType(\n\t\t\t   TPM_HANDLE* handle,  // OUT: the handle of the found type or 0\n\t\t\t   NV_REF*     iter,    // IN: the iterator\n\t\t\t   TPM_HT      type     // IN: the handle type to look for\n\t\t\t   )\n{\n    NV_REF     addr;\n    TPM_HANDLE nvHandle = 0;\n    //\n    while((addr = NvNext(iter, &nvHandle)) != 0)\n\t{\n\t    // addr: the address of the location containing the handle of the value\n\t    // iter: the next location.\n\t    if(HandleGetType(nvHandle) == type)\n\t\tbreak;\n\t}\n    if(handle != NULL)\n\t*handle = nvHandle;\n    return addr;\n}\n\n//*** NvNextIndex()\n// This function returns the reference to the next NV Index entry.  A value\n// of 0 indicates the end of the list.\n//  Return Type: NV_REF\n//      0               end of list\n//      != 0            the next reference\n#define NvNextIndex(handle, iter) NvNextByType(handle, iter, TPM_HT_NV_INDEX)\n\n//*** NvNextEvict()\n// This function returns the offset in NV of the next evict object entry.  A value\n// of 0 indicates the end of the list.\n#define NvNextEvict(handle, iter) NvNextByType(handle, iter, TPM_HT_PERSISTENT)\n\n//*** NvGetEnd()\n// Function to find the end of the NV dynamic data list\nstatic NV_REF NvGetEnd(void)\n{\n    NV_REF iter = NV_REF_INIT;\n    NV_REF currentAddr;\n    //\n    // Scan until the next address is 0\n    while((currentAddr = NvNext(&iter, NULL)) != 0)\n\t;\n    return iter;\n}\n\n//*** NvGetFreeBytes\n// This function returns the number of free octets in NV space.\nstatic UINT32 NvGetFreeBytes(void)\n{\n    // This does not have an overflow issue because NvGetEnd() cannot return a value\n    // that is larger than s_evictNvEnd. This is because there is always a 'stop'\n    // word in the NV memory that terminates the search for the end before the\n    // value can go past s_evictNvEnd.\n    return s_evictNvEnd - NvGetEnd();\n}\n\n//*** NvTestSpace()\n// This function will test if there is enough space to add a new entity.\n//  Return Type: BOOL\n//      TRUE(1)         space available\n//      FALSE(0)        no enough space\nstatic BOOL NvTestSpace(UINT32 size,      // IN: size of the entity to be added\n\t\t\tBOOL   isIndex,   // IN: TRUE if the entity is an index\n\t\t\tBOOL   isCounter  // IN: TRUE if the index is a counter\n\t\t\t)\n{\n    UINT32 remainBytes = NvGetFreeBytes();\n    UINT32 reserved    = sizeof(UINT32)  // size of the forward pointer\n\t\t\t + sizeof(NV_LIST_TERMINATOR);\n    //\n    // Do a compile time sanity check on the setting for NV_MEMORY_SIZE\n#if NV_MEMORY_SIZE < 1024\n#  error \"NV_MEMORY_SIZE probably isn't large enough\"\n#endif\n\n    // For NV Index, need to make sure that we do not allocate an Index if this\n    // would mean that the TPM cannot allocate the minimum number of evict\n    // objects.\n    if(isIndex)\n\t{\n\t    // Get the number of persistent objects allocated\n\t    UINT32 persistentNum = NvCapGetPersistentNumber();\n\n\t    // If we have not allocated the requisite number of evict objects, then we\n\t    // need to reserve space for them.\n\t    // NOTE: some of this is not written as simply as it might seem because\n\t    // the values are all unsigned and subtracting needs to be done carefully\n\t    // so that an underflow doesn't cause problems.\n\t    if(persistentNum < MIN_EVICT_OBJECTS)\n\t\treserved += (MIN_EVICT_OBJECTS - persistentNum) * NV_EVICT_OBJECT_SIZE;\n\t}\n    // If this is not an index or is not a counter, reserve space for the\n    // required number of counter indexes\n    if(!isIndex || !isCounter)\n\t{\n\t    // Get the number of counters\n\t    UINT32 counterNum = NvCapGetCounterNumber();\n\n\t    // If the required number of counters have not been allocated, reserved\n\t    // space for the extra needed counters\n\t    if(counterNum < MIN_COUNTER_INDICES)\n\t\treserved += (MIN_COUNTER_INDICES - counterNum) * NV_INDEX_COUNTER_SIZE;\n\t}\n    // Check that the requested allocation will fit after making sure that there\n    // will be no chance of overflow\n    return ((reserved < remainBytes) && (size <= remainBytes)\n\t    && (size + reserved <= remainBytes));\n}\n\n//*** NvWriteNvListEnd()\n// Function to write the list terminator.\nNV_REF\nNvWriteNvListEnd(NV_REF end)\n{\n    // Marker is initialized with zeros\n    BYTE   listEndMarker[sizeof(NV_LIST_TERMINATOR)] = {0};\n    UINT64 maxCount                                  = NvReadMaxCount();\n    //\n    // This is a constant check that can be resolved at compile time.\n    MUST_BE(sizeof(UINT64) <= sizeof(NV_LIST_TERMINATOR) - sizeof(UINT32));\n\n    // Copy the maxCount value to the marker buffer\n    MemoryCopy(&listEndMarker[sizeof(UINT32)], &maxCount, sizeof(UINT64));\n    pAssert(end + sizeof(NV_LIST_TERMINATOR) <= s_evictNvEnd);\n\n    // Write it to memory\n    NvWrite(end, sizeof(NV_LIST_TERMINATOR), &listEndMarker);\n    return end + sizeof(NV_LIST_TERMINATOR);\n}\n\n//*** NvAdd()\n// This function adds a new entity to NV.\n//\n// This function requires that there is enough space to add a new entity (i.e.,\n// that NvTestSpace() has been called and the available space is at least as\n// large as the required space).\n//\n// The 'totalSize' will be the size of 'entity'. If a handle is added, this\n// function will increase the size accordingly.\nstatic TPM_RC NvAdd(UINT32 totalSize,  // IN: total size needed for this entity For\n\t\t    //     evict object, totalSize is the same as\n\t\t    //     bufferSize.  For NV Index, totalSize is\n\t\t    //     bufferSize plus index data size\n\t\t    UINT32     bufferSize,  // IN: size of initial buffer\n\t\t    TPM_HANDLE handle,      // IN: optional handle\n\t\t    BYTE*      entity       // IN: initial buffer\n\t\t    )\n{\n    NV_REF newAddr;  // IN: where the new entity will start\n    NV_REF nextAddr;\n    //\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n\n    // Get the end of data list\n    newAddr = NvGetEnd();\n\n    // Step over the forward pointer\n    nextAddr = newAddr + sizeof(UINT32);\n\n    // Optionally write the handle. For indexes, the handle is TPM_RH_UNASSIGNED\n    // so that the handle in the nvIndex is used instead of writing this value\n    if(handle != TPM_RH_UNASSIGNED)\n\t{\n\t    NvWrite((UINT32)nextAddr, sizeof(TPM_HANDLE), &handle);\n\t    nextAddr += sizeof(TPM_HANDLE);\n\t}\n    // Write entity data\n    NvWrite((UINT32)nextAddr, bufferSize, entity);\n\n    // Advance the pointer by the amount of the total\n    nextAddr += totalSize;\n\n    // Finish by writing the link value\n\n    // Write the next offset (relative addressing)\n    totalSize = nextAddr - newAddr;\n\n    // Write link value\n    NvWrite((UINT32)newAddr, sizeof(UINT32), &totalSize);\n\n    // Write the list terminator\n    NvWriteNvListEnd(nextAddr);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** NvDelete()\n// This function is used to delete an NV Index or persistent object from NV memory.\nstatic TPM_RC NvDelete(NV_REF entityRef  // IN: reference to entity to be deleted\n\t\t       )\n{\n    UINT32 entrySize;\n    // adjust entityAddr to back up and point to the forward pointer\n    NV_REF entryRef = entityRef - sizeof(UINT32);\n    NV_REF endRef   = NvGetEnd();\n    NV_REF nextAddr;  // address of the next entry\n    //\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n\n    // Get the offset of the next entry. That is, back up and point to the size\n    // field of the entry\n    NvRead(&entrySize, entryRef, sizeof(UINT32));\n\n    // The next entry after the one being deleted is at a relative offset\n    // from the current entry\n    nextAddr = entryRef + entrySize;\n\n    // If this is not the last entry, move everything up\n    if(nextAddr < endRef)\n\t{\n\t    pAssert(nextAddr > entryRef);\n\t    _plat__NvMemoryMove(nextAddr, entryRef, (endRef - nextAddr));\n\t}\n    // The end of the used space is now moved up by the amount of space we just\n    // reclaimed\n    endRef -= entrySize;\n\n    // Write the end marker, and make the new end equal to the first byte after\n    // the just added end value. This will automatically update the NV value for\n    // maxCounter.\n    // NOTE: This is the call that sets flag to cause NV to be updated\n    endRef = NvWriteNvListEnd(endRef);\n\n    // Clear the reclaimed memory\n    _plat__NvMemoryClear(endRef, entrySize);\n\n    return TPM_RC_SUCCESS;\n}\n\n//************************************************\n//** RAM-based NV Index Data Access Functions\n//************************************************\n//*** Introduction\n// The data layout in ram buffer is {size of(NV_handle + attributes + data\n// NV_handle, attributes, data}\n// for each NV Index data stored in RAM.\n//\n// NV storage associated with orderly data is updated when a NV Index is added\n// but NOT when the data or attributes are changed. Orderly data is only updated\n// to NV on an orderly shutdown (TPM2_Shutdown())\n\n//*** NvRamNext()\n// This function is used to iterate trough the list of Ram Index values. *iter needs\n// to be initialized by calling\nstatic NV_RAM_REF NvRamNext(NV_RAM_REF* iter,   // IN/OUT: the list iterator\n\t\t\t    TPM_HANDLE* handle  // OUT: the handle of the next item.\n\t\t\t    )\n{\n    NV_RAM_REF    currentAddr;\n    NV_RAM_HEADER header;\n    //\n    // If iterator is at the beginning of list\n    if(*iter == NV_RAM_REF_INIT)\n\t{\n\t    // Initialize iterator\n\t    *iter = &s_indexOrderlyRam[0];\n\t}\n    // if we are going to return what the iter is currently pointing to...\n    currentAddr = *iter;\n\n    // If iterator reaches the end of NV space, then don't advance and return\n    // that we are at the end of the list. The end of the list occurs when\n    // we don't have space for a size and a handle\n    if(currentAddr + sizeof(NV_RAM_HEADER) > RAM_ORDERLY_END)\n\treturn NULL;\n    // read the header of the next entry\n    MemoryCopy(&header, currentAddr, sizeof(NV_RAM_HEADER));\n\n    // if the size field is zero, then we have hit the end of the list\n    if(header.size == 0)\n\t// leave the *iter pointing at the end of the list\n\treturn NULL;\n    // advance the header by the size of the entry\n    *iter = currentAddr + header.size;\n\n    //    pAssert(*iter <= RAM_ORDERLY_END);\n    if(handle != NULL)\n\t*handle = header.handle;\n    return currentAddr;\n}\n\n//*** NvRamGetEnd()\n// This routine performs the same function as NvGetEnd() but for the RAM data.\nstatic NV_RAM_REF NvRamGetEnd(void)\n{\n    NV_RAM_REF iter = NV_RAM_REF_INIT;\n    NV_RAM_REF currentAddr;\n    //\n    // Scan until the next address is 0\n    while((currentAddr = NvRamNext(&iter, NULL)) != 0)\n\t;\n    return iter;\n}\n\n//*** NvRamTestSpaceIndex()\n// This function indicates if there is enough RAM space to add a data for a\n// new NV Index.\n//  Return Type: BOOL\n//      TRUE(1)         space available\n//      FALSE(0)        no enough space\nstatic BOOL NvRamTestSpaceIndex(\n\t\t\t\tUINT32 size  // IN: size of the data to be added to RAM\n\t\t\t\t)\n{\n    UINT32 remaining = (UINT32)(RAM_ORDERLY_END - NvRamGetEnd());\n    UINT32 needed    = sizeof(NV_RAM_HEADER) + size;\n    //\n    // NvRamGetEnd points to the next available byte.\n    return remaining >= needed;\n}\n\n//*** NvRamGetIndex()\n// This function returns the offset of NV data in the RAM buffer\n//\n// This function requires that NV Index is in RAM. That is, the\n// index must be known to exist.\nstatic NV_RAM_REF NvRamGetIndex(TPMI_RH_NV_INDEX handle  // IN: NV handle\n\t\t\t\t)\n{\n    NV_RAM_REF iter = NV_RAM_REF_INIT;\n    NV_RAM_REF currentAddr;\n    TPM_HANDLE foundHandle;\n    //\n    while((currentAddr = NvRamNext(&iter, &foundHandle)) != 0)\n\t{\n\t    if(handle == foundHandle)\n\t\tbreak;\n\t}\n    return currentAddr;\n}\n\n//*** NvUpdateIndexOrderlyData()\n// This function is used to cause an update of the orderly data to the NV backing\n// store.\nvoid NvUpdateIndexOrderlyData(void)\n{\n    // Write reserved RAM space to NV\n    NvWrite(NV_INDEX_RAM_DATA, sizeof(s_indexOrderlyRam), s_indexOrderlyRam);\n}\n\n//*** NvAddRAM()\n// This function adds a new data area to RAM.\n//\n// This function requires that enough free RAM space is available to add\n// the new data.\n//\n// This function should be called after the NV Index space has been updated\n// and the index removed. This insures that NV is available so that checking\n// for NV availability is not required during this function.\nstatic void NvAddRAM(TPMS_NV_PUBLIC* index  // IN: the index descriptor\n\t\t     )\n{\n    NV_RAM_HEADER header;\n    NV_RAM_REF    end = NvRamGetEnd();\n    //\n    header.size   = sizeof(NV_RAM_HEADER) + index->dataSize;\n    header.handle = index->nvIndex;\n    MemoryCopy(&header.attributes, &index->attributes, sizeof(TPMA_NV));\n\n    pAssert(ORDERLY_RAM_ADDRESS_OK(end, header.size));\n\n    // Copy the header to the memory\n    MemoryCopy(end, &header, sizeof(NV_RAM_HEADER));\n\n    // Clear the data area (just in case)\n    MemorySet(end + sizeof(NV_RAM_HEADER), 0, index->dataSize);\n\n    // Step over this new entry\n    end += header.size;\n\n    // If the end marker will fit, add it\n    if(end + sizeof(UINT32) < RAM_ORDERLY_END)\n\tMemorySet(end, 0, sizeof(UINT32));\n    // Write reserved RAM space to NV to reflect the newly added NV Index\n    SET_NV_UPDATE(UT_ORDERLY);\n\n    return;\n}\n\n//*** NvDeleteRAM()\n// This function is used to delete a RAM-backed NV Index data area.\n// The space used by the entry are overwritten by the contents of the\n// Index data that comes after (the data is moved up to fill the hole left\n// by removing this index. The reclaimed space is cleared to zeros.\n// This function assumes the data of NV Index exists in RAM.\n//\n// This function should be called after the NV Index space has been updated\n// and the index removed. This insures that NV is available so that checking\n// for NV availability is not required during this function.\nstatic void NvDeleteRAM(TPMI_RH_NV_INDEX handle  // IN: NV handle\n\t\t\t)\n{\n    NV_RAM_REF nodeAddress;\n    NV_RAM_REF nextNode;\n    UINT32     size;\n    NV_RAM_REF lastUsed = NvRamGetEnd();\n    //\n    nodeAddress = NvRamGetIndex(handle);\n\n    pAssert(nodeAddress != 0);\n\n    // Get node size\n    MemoryCopy(&size, nodeAddress, sizeof(size));\n\n    // Get the offset of next node\n    nextNode = nodeAddress + size;\n\n    // Copy the data\n    MemoryCopy(nodeAddress, nextNode, (int)(lastUsed - nextNode));\n\n    // Clear out the reclaimed space\n    MemorySet(lastUsed - size, 0, size);\n\n    // Write reserved RAM space to NV to reflect the newly delete NV Index\n    SET_NV_UPDATE(UT_ORDERLY);\n\n    return;\n}\n\n//*** NvReadIndex()\n// This function is used to read the NV Index NV_INDEX. This is used so that the\n// index information can be compressed and only this function would be needed\n// to decompress it. Mostly, compression would only be able to save the space\n// needed by the policy.\nvoid NvReadNvIndexInfo(NV_REF    ref,     // IN: points to NV where index is located\n\t\t       NV_INDEX* nvIndex  // OUT: place to receive index data\n\t\t       )\n{\n    pAssert(nvIndex != NULL);\n    NvRead(nvIndex, ref, sizeof(NV_INDEX));\n    return;\n}\n\n//*** NvReadObject()\n// This function is used to read a persistent object. This is used so that the\n// object information can be compressed and only this function would be needed\n// to uncompress it.\nvoid NvReadObject(NV_REF  ref,    // IN: points to NV where index is located\n\t\t  OBJECT* object  // OUT: place to receive the object data\n\t\t  )\n{\n    NvRead(object, (ref + sizeof(TPM_HANDLE)), sizeof(OBJECT));\n    return;\n}\n\n//*** NvFindEvict()\n// This function will return the NV offset of an evict object\n//  Return Type: UINT32\n//      0               evict object not found\n//      != 0            offset of evict object\nstatic NV_REF NvFindEvict(TPM_HANDLE nvHandle, OBJECT* object)\n{\n    NV_REF found = NvFindHandle(nvHandle);\n    //\n    // If we found the handle and the request included an object pointer, fill it in\n    if(found != 0 && object != NULL)\n\tNvReadObject(found, object);\n    return found;\n}\n\n//*** NvIndexIsDefined()\n// See if an index is already defined\nBOOL NvIndexIsDefined(TPM_HANDLE nvHandle  // IN: Index to look for\n\t\t      )\n{\n    return (NvFindHandle(nvHandle) != 0);\n}\n\n//*** NvConditionallyWrite()\n// Function to check if the data to be written has changed\n// and write it if it has\n//  Return Type: TPM_RC\n//      TPM_RC_NV_RATE           NV is unavailable because of rate limit\n//      TPM_RC_NV_UNAVAILABLE    NV is inaccessible\nstatic TPM_RC NvConditionallyWrite(NV_REF entryAddr,  // IN: stating address\n\t\t\t\t   UINT32 size,       // IN: size of the data to write\n\t\t\t\t   void*  data        // IN: the data to write\n\t\t\t\t   )\n{\n    // If the index data is actually changed, then a write to NV is required\n    int isDifferent = _plat__NvGetChangedStatus(entryAddr, size, data);\n    if(isDifferent == NV_INVALID_LOCATION)\n\t{\n\t    // invalid request, we should be in failure mode by now.\n\t    return TPM_RC_FAILURE;\n\t}\n    else if(isDifferent == NV_HAS_CHANGED)\n\t{\n\t    // Write the data if NV is available\n\t    if(g_NvStatus == TPM_RC_SUCCESS)\n\t\t{\n\t\t    NvWrite(entryAddr, size, data);\n\t\t}\n\t    return g_NvStatus;\n\t}\n    else if(isDifferent == NV_IS_SAME)\n\t{\n\t    return TPM_RC_SUCCESS;\n\t}\n    // the platform gave us an invalid response.\n    FAIL_RC(FATAL_ERROR_PLATFORM);\n}\n\n//*** NvReadNvIndexAttributes()\n// This function returns the attributes of an NV Index.\nstatic TPMA_NV NvReadNvIndexAttributes(NV_REF locator  // IN: reference to an NV index\n\t\t\t\t       )\n{\n    TPMA_NV attributes;\n    //\n    NvRead(&attributes,\n\t   locator + offsetof(NV_INDEX, publicArea.attributes),\n\t   sizeof(TPMA_NV));\n    return attributes;\n}\n\n//*** NvReadRamIndexAttributes()\n// This function returns the attributes from the RAM header structure. This function\n// is used to deal with the fact that the header structure is only byte aligned.\nstatic TPMA_NV NvReadRamIndexAttributes(\n\t\t\t\t\tNV_RAM_REF ref  // IN: pointer to a NV_RAM_HEADER\n\t\t\t\t\t)\n{\n    TPMA_NV attributes;\n    //\n    MemoryCopy(\n\t       &attributes, ref + offsetof(NV_RAM_HEADER, attributes), sizeof(TPMA_NV));\n    return attributes;\n}\n\n//*** NvWriteNvIndexAttributes()\n// This function is used to write just the attributes of an index to NV.\n//  Return type: TPM_RC\n//      TPM_RC_NV_RATE          NV is rate limiting so retry\n//      TPM_RC_NV_UNAVAILABLE   NV is not available\nstatic TPM_RC NvWriteNvIndexAttributes(NV_REF  locator,  // IN: location of the index\n\t\t\t\t       TPMA_NV attributes  // IN: attributes to write\n\t\t\t\t       )\n{\n    return NvConditionallyWrite(locator + offsetof(NV_INDEX, publicArea.attributes),\n\t\t\t\tsizeof(TPMA_NV),\n\t\t\t\t&attributes);\n}\n\n//*** NvWriteRamIndexAttributes()\n// This function is used to write the index attributes into an unaligned structure\nstatic void NvWriteRamIndexAttributes(\n\t\t\t\t      NV_RAM_REF ref,        // IN: address of the header\n\t\t\t\t      TPMA_NV    attributes  // IN: the attributes to write\n\t\t\t\t      )\n{\n    MemoryCopy(\n\t       ref + offsetof(NV_RAM_HEADER, attributes), &attributes, sizeof(TPMA_NV));\n    return;\n}\n\n//************************************************\n//** Externally Accessible Functions\n//************************************************\n\n//*** NvIsPlatformPersistentHandle()\n// This function indicates if a handle references a persistent object in the\n// range belonging to the platform.\n//  Return Type: BOOL\n//      TRUE(1)         handle references a platform persistent object\n//      FALSE(0)        handle does not reference platform persistent object\nBOOL NvIsPlatformPersistentHandle(TPM_HANDLE handle  // IN: handle\n\t\t\t\t  )\n{\n    return (handle >= PLATFORM_PERSISTENT && handle <= PERSISTENT_LAST);\n}\n\n//*** NvIsOwnerPersistentHandle()\n// This function indicates if a handle references a persistent object in the\n// range belonging to the owner.\n//  Return Type: BOOL\n//      TRUE(1)         handle is owner persistent handle\n//      FALSE(0)        handle is not owner persistent handle and may not be\n//                      a persistent handle at all\nBOOL NvIsOwnerPersistentHandle(TPM_HANDLE handle  // IN: handle\n\t\t\t       )\n{\n    return (handle >= PERSISTENT_FIRST && handle < PLATFORM_PERSISTENT);\n}\n\n//*** NvIndexIsAccessible()\n//\n// This function validates that a handle references a defined NV Index and\n// that the Index is currently accessible.\n//  Return Type: TPM_RC\n//      TPM_RC_HANDLE           the handle points to an undefined NV Index\n//                              If shEnable is CLEAR, this would include an index\n//                              created using ownerAuth. If phEnableNV is CLEAR,\n//                              this would include and index created using\n//                              platformAuth\n//      TPM_RC_NV_READLOCKED    Index is present but locked for reading and command\n//                              does not write to the index\n//      TPM_RC_NV_WRITELOCKED   Index is present but locked for writing and command\n//                              writes to the index\nTPM_RC\nNvIndexIsAccessible(TPMI_RH_NV_INDEX handle  // IN: handle\n\t\t    )\n{\n    NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL);\n    //\n    if(nvIndex == NULL)\n\t// If index is not found, return TPM_RC_HANDLE\n\treturn TPM_RC_HANDLE;\n    if(gc.shEnable == FALSE || gc.phEnableNV == FALSE)\n\t{\n\t    // if shEnable is CLEAR, an ownerCreate NV Index should not be\n\t    // indicated as present\n\t    if(!IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, PLATFORMCREATE))\n\t\t{\n\t\t    if(gc.shEnable == FALSE)\n\t\t\treturn TPM_RC_HANDLE;\n\t\t}\n\t    // if phEnableNV is CLEAR, a platform created Index should not\n\t    // be visible\n\t    else if(gc.phEnableNV == FALSE)\n\t\treturn TPM_RC_HANDLE;\n\t}\n#if 0  // Writelock test for debug\n    // If the Index is write locked and this is an NV Write operation...\n    if(IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, WRITELOCKED)\n       &&  IsWriteOperation(commandIndex))\n\t{\n\t    // then return a locked indication unless the command is TPM2_NV_WriteLock\n\t    if(GetCommandCode(commandIndex) != TPM_CC_NV_WriteLock)\n\t\treturn TPM_RC_NV_LOCKED;\n\t    return TPM_RC_SUCCESS;\n\t}\n#endif\n#if 0  // Readlock Test for debug\n    // If the Index is read locked and this is an NV Read operation...\n    if(IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, READLOCKED)\n       && IsReadOperation(commandIndex))\n\t{\n\t    // then return a locked indication unless the command is TPM2_NV_ReadLock\n\t    if(GetCommandCode(commandIndex) != TPM_CC_NV_ReadLock)\n\t\treturn TPM_RC_NV_LOCKED;\n\t}\n#endif\n    // NV Index is accessible\n    return TPM_RC_SUCCESS;\n}\n\n//*** NvGetEvictObject()\n// This function is used to dereference an evict object handle and get a pointer\n// to the object.\n//  Return Type: TPM_RC\n//      TPM_RC_HANDLE           the handle does not point to an existing\n//                              persistent object\nTPM_RC\nNvGetEvictObject(TPM_HANDLE handle,  // IN: handle\n\t\t OBJECT*    object   // OUT: object data\n\t\t )\n{\n    NV_REF entityAddr;  // offset points to the entity\n    //\n    // Find the address of evict object and copy to object\n    entityAddr = NvFindEvict(handle, object);\n\n    // whether there is an error or not, make sure that the evict\n    // status of the object is set so that the slot will get freed on exit\n    // Must do this after NvFindEvict loads the object\n    object->attributes.evict = SET;\n\n    // If handle is not found, return an error\n    if(entityAddr == 0)\n\treturn TPM_RC_HANDLE;\n    return TPM_RC_SUCCESS;\n}\n\n//*** NvIndexCacheInit()\n// Function to initialize the Index cache\nvoid NvIndexCacheInit(void)\n{\n    s_cachedNvRef                      = NV_REF_INIT;\n    s_cachedNvRamRef                   = NV_RAM_REF_INIT;\n    s_cachedNvIndex.publicArea.nvIndex = TPM_RH_UNASSIGNED;\n    return;\n}\n\n//*** NvGetIndexData()\n// This function is used to access the data in an NV Index. The data is returned\n// as a byte sequence.\n//\n// This function requires that the NV Index be defined, and that the\n// required data is within the data range.  It also requires that TPMA_NV_WRITTEN\n// of the Index is SET.\nvoid NvGetIndexData(NV_INDEX* nvIndex,  // IN: the in RAM index descriptor\n\t\t    NV_REF    locator,  // IN: where the data is located\n\t\t    UINT32    offset,   // IN: offset of NV data\n\t\t    UINT16    size,     // IN: number of octets of NV data to read\n\t\t    void*     data      // OUT: data buffer\n\t\t    )\n{\n    TPMA_NV nvAttributes;\n    //\n    pAssert(nvIndex != NULL);\n\n    nvAttributes = nvIndex->publicArea.attributes;\n\n    pAssert(IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITTEN));\n\n    if(IS_ATTRIBUTE(nvAttributes, TPMA_NV, ORDERLY))\n\t{\n\t    // Get data from RAM buffer\n\t    NV_RAM_REF ramAddr = NvRamGetIndex(nvIndex->publicArea.nvIndex);\n\t    pAssert(ramAddr != 0\n\t\t    && (size <= ((NV_RAM_HEADER*)ramAddr)->size - sizeof(NV_RAM_HEADER)\n\t\t\t- offset));\n\t    MemoryCopy(data, ramAddr + sizeof(NV_RAM_HEADER) + offset, size);\n\t}\n    else\n\t{\n\t    // Validate that read falls within range of the index\n\t    pAssert(offset <= nvIndex->publicArea.dataSize\n\t\t    && size <= (nvIndex->publicArea.dataSize - offset));\n\t    NvRead(data, locator + sizeof(NV_INDEX) + offset, size);\n\t}\n    return;\n}\n\n//*** NvHashIndexData()\n// This function adds Index data to a hash. It does this in parts to avoid large stack\n// buffers.\nvoid NvHashIndexData(HASH_STATE* hashState,  // IN: Initialized hash state\n\t\t     NV_INDEX*   nvIndex,    // IN: Index\n\t\t     NV_REF      locator,    // IN: where the data is located\n\t\t     UINT32      offset,     // IN: starting offset\n\t\t     UINT16      size        // IN: amount to hash\n\t\t     )\n{\n#define BUFFER_SIZE 64\n    BYTE buffer[BUFFER_SIZE];\n    if(offset > nvIndex->publicArea.dataSize)\n\treturn;\n    // Make sure that we don't try to read off the end.\n    if((offset + size) > nvIndex->publicArea.dataSize)\n\tsize = nvIndex->publicArea.dataSize - (UINT16)offset;\n#if BUFFER_SIZE >= MAX_NV_INDEX_SIZE\n    NvGetIndexData(nvIndex, locator, offset, size, buffer);\n    CryptDigestUpdate(hashState, size, buffer);\n#else\n    {\n\tINT16  i;\n\tUINT16 readSize;\n\t//\n\tfor(i = size; i > 0; offset += readSize, i -= readSize)\n\t    {\n\t\treadSize = (i < BUFFER_SIZE) ? i : BUFFER_SIZE;\n\t\tNvGetIndexData(nvIndex, locator, offset, readSize, buffer);\n\t\tCryptDigestUpdate(hashState, readSize, buffer);\n\t    }\n    }\n#endif  // BUFFER_SIZE >= MAX_NV_INDEX_SIZE\n#undef BUFFER_SIZE\n}\n\n//*** NvGetUINT64Data()\n// Get data in integer format of a bit or counter NV Index.\n//\n// This function requires that the NV Index is defined and that the NV Index\n// previously has been written.\nUINT64\nNvGetUINT64Data(NV_INDEX* nvIndex,  // IN: the in RAM index descriptor\n\t\tNV_REF    locator   // IN: where index exists in NV\n\t\t)\n{\n    UINT64 intVal;\n    //\n    // Read the value and convert it to internal format\n    NvGetIndexData(nvIndex, locator, 0, 8, &intVal);\n    return BYTE_ARRAY_TO_UINT64(((BYTE*)&intVal));\n}\n\n//*** NvWriteIndexAttributes()\n// This function is used to write just the attributes of an index.\n//  Return type: TPM_RC\n//      TPM_RC_NV_RATE          NV is rate limiting so retry\n//      TPM_RC_NV_UNAVAILABLE   NV is not available\nTPM_RC\nNvWriteIndexAttributes(TPM_HANDLE handle,\n\t\t       NV_REF     locator,    // IN: location of the index\n\t\t       TPMA_NV    attributes  // IN: attributes to write\n\t\t       )\n{\n    TPM_RC result;\n    //\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, ORDERLY))\n\t{\n\t    NV_RAM_REF ram = NvRamGetIndex(handle);\n\t    NvWriteRamIndexAttributes(ram, attributes);\n\t    result = TPM_RC_SUCCESS;\n\t}\n    else\n\t{\n\t    result = NvWriteNvIndexAttributes(locator, attributes);\n\t}\n    return result;\n}\n\n//*** NvWriteIndexAuth()\n// This function is used to write the authValue of an index. It is used by\n// TPM2_NV_ChangeAuth()\n//  Return type: TPM_RC\n//      TPM_RC_NV_RATE          NV is rate limiting so retry\n//      TPM_RC_NV_UNAVAILABLE   NV is not available\nTPM_RC\nNvWriteIndexAuth(NV_REF      locator,   // IN: location of the index\n\t\t TPM2B_AUTH* authValue  // IN: the authValue to write\n\t\t )\n{\n    TPM_RC result;\n    //\n    // If the locator is pointing to the cached index value...\n    if(locator == s_cachedNvRef)\n\t{\n\t    // copy the authValue to the cached index so it will be there if we\n\t    // look for it. This is a safety thing.\n\t    MemoryCopy2B(&s_cachedNvIndex.authValue.b,\n\t\t\t &authValue->b,\n\t\t\t sizeof(s_cachedNvIndex.authValue.t.buffer));\n\t}\n    result = NvConditionallyWrite(locator + offsetof(NV_INDEX, authValue),\n\t\t\t\t  sizeof(UINT16) + authValue->t.size,\n\t\t\t\t  authValue);\n    return result;\n}\n\n//*** NvGetIndexInfo()\n// This function loads the nvIndex Info into the NV cache and returns a pointer\n// to the NV_INDEX. If the returned value is zero, the index was not found.\n// The 'locator' parameter, if not NULL, will be set to the offset in NV of the\n// Index (the location of the handle of the Index).\n//\n// This function will set the index cache. If the index is orderly, the attributes\n// from RAM are substituted for the attributes in the cached index\nNV_INDEX* NvGetIndexInfo(TPM_HANDLE nvHandle,  // IN: the index handle\n\t\t\t NV_REF*    locator    // OUT: location of the index\n\t\t\t )\n{\n    if(s_cachedNvIndex.publicArea.nvIndex != nvHandle)\n\t{\n\t    s_cachedNvIndex.publicArea.nvIndex = TPM_RH_UNASSIGNED;\n\t    s_cachedNvRamRef                   = 0;\n\t    s_cachedNvRef                      = NvFindHandle(nvHandle);\n\t    if(s_cachedNvRef == 0)\n\t\treturn NULL;\n\t    NvReadNvIndexInfo(s_cachedNvRef, &s_cachedNvIndex);\n\t    if(IS_ATTRIBUTE(s_cachedNvIndex.publicArea.attributes, TPMA_NV, ORDERLY))\n\t\t{\n\t\t    s_cachedNvRamRef = NvRamGetIndex(nvHandle);\n\t\t    s_cachedNvIndex.publicArea.attributes =\n\t\t\tNvReadRamIndexAttributes(s_cachedNvRamRef);\n\t\t}\n\t}\n    if(locator != NULL)\n\t*locator = s_cachedNvRef;\n    return &s_cachedNvIndex;\n}\n\n//*** NvWriteIndexData()\n// This function is used to write NV index data. It is intended to be used to\n// update the data associated with the default index.\n//\n// This function requires that the NV Index is defined, and the data is\n// within the defined data range for the index.\n//\n// Index data is only written due to a command that modifies the data in a single\n// index. There is no case where changes are made to multiple indexes data at the\n// same time. Multiple attributes may be change but not multiple index data. This\n// is important because we will normally be handling the index for which we have\n// the cached pointer values.\n//  Return type: TPM_RC\n//      TPM_RC_NV_RATE          NV is rate limiting so retry\n//      TPM_RC_NV_UNAVAILABLE   NV is not available\nTPM_RC\nNvWriteIndexData(NV_INDEX* nvIndex,  // IN: the description of the index\n\t\t UINT32    offset,   // IN: offset of NV data\n\t\t UINT32    size,     // IN: size of NV data\n\t\t void*     data      // IN: data buffer\n\t\t )\n{\n    TPM_RC result = TPM_RC_SUCCESS;\n    //\n    pAssert(nvIndex != NULL);\n    // Make sure that this is dealing with the 'default' index.\n    // Note: it is tempting to change the calling sequence so that the 'default' is\n    // presumed.\n    pAssert(nvIndex->publicArea.nvIndex == s_cachedNvIndex.publicArea.nvIndex);\n\n    // Validate that write falls within range of the index\n    pAssert(offset <= nvIndex->publicArea.dataSize\n\t    && size <= (nvIndex->publicArea.dataSize - offset));\n\n    // Update TPMA_NV_WRITTEN bit if necessary\n    if(!IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, WRITTEN))\n\t{\n\t    // Update the in memory version of the attributes\n\t    SET_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, WRITTEN);\n\n\t    // If this is not orderly, then update the NV version of\n\t    // the attributes\n\t    if(!IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, ORDERLY))\n\t\t{\n\t\t    result = NvWriteNvIndexAttributes(s_cachedNvRef,\n\t\t\t\t\t\t      nvIndex->publicArea.attributes);\n\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\treturn result;\n\t\t    // If this is a partial write of an ordinary index, clear the whole\n\t\t    // index.\n\t\t    if(IsNvOrdinaryIndex(nvIndex->publicArea.attributes)\n\t\t       && (nvIndex->publicArea.dataSize > size))\n\t\t\t_plat__NvMemoryClear(s_cachedNvRef + sizeof(NV_INDEX),\n\t\t\t\t\t     nvIndex->publicArea.dataSize);\n\t\t}\n\t    else\n\t\t{\n\t\t    // This is orderly so update the RAM version\n\t\t    MemoryCopy(s_cachedNvRamRef + offsetof(NV_RAM_HEADER, attributes),\n\t\t\t       &nvIndex->publicArea.attributes,\n\t\t\t       sizeof(TPMA_NV));\n\t\t    // If setting WRITTEN for an orderly counter, make sure that the\n\t\t    // state saved version of the counter is saved\n\t\t    if(IsNvCounterIndex(nvIndex->publicArea.attributes))\n\t\t\tSET_NV_UPDATE(UT_ORDERLY);\n\t\t    // If setting the written attribute on an ordinary index, make sure that\n\t\t    // the data is all cleared out in case there is a partial write. This\n\t\t    // is only necessary for ordinary indexes because all of the other types\n\t\t    // are always written in total.\n\t\t    else if(IsNvOrdinaryIndex(nvIndex->publicArea.attributes))\n\t\t\tMemorySet(s_cachedNvRamRef + sizeof(NV_RAM_HEADER),\n\t\t\t\t  0,\n\t\t\t\t  nvIndex->publicArea.dataSize);\n\t\t}\n\t}\n    // If this is orderly data, write it to RAM\n    if(IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, ORDERLY))\n\t{\n\t    // Note: if this is the first write to a counter, the code above will queue\n\t    // the write to NV of the RAM data in order to update TPMA_NV_WRITTEN. In\n\t    // process of doing that write, it will also write the initial counter value\n\n\t    // Update RAM\n\t    MemoryCopy(s_cachedNvRamRef + sizeof(NV_RAM_HEADER) + offset, data, size);\n\n\t    // And indicate that the TPM is no longer orderly\n\t    g_clearOrderly = TRUE;\n\t}\n    else\n\t{\n\t    // Offset into the index to the first byte of the data to be written to NV\n\t    result = NvConditionallyWrite(\n\t\t\t\t\t  s_cachedNvRef + sizeof(NV_INDEX) + offset, size, data);\n\t}\n    return result;\n}\n\n//*** NvWriteUINT64Data()\n// This function to write back a UINT64 value. The various UINT64 values (bits,\n// counters, and PINs) are kept in canonical format but manipulate in native\n// format. This takes a native format value converts it and saves it back as\n// in canonical format.\n//\n// This function will return the value from NV or RAM depending on the type of the\n// index (orderly or not)\n//\nTPM_RC\nNvWriteUINT64Data(NV_INDEX* nvIndex,  // IN: the description of the index\n\t\t  UINT64    intValue  // IN: the value to write\n\t\t  )\n{\n    BYTE bytes[8];\n    UINT64_TO_BYTE_ARRAY(intValue, bytes);\n    //\n    return NvWriteIndexData(nvIndex, 0, 8, &bytes);\n}\n\n//*** NvGetNameByIndexHandle()\n// This function is used to compute the Name of an NV Index referenced by handle.\n//\n// The 'name' buffer receives the bytes of the Name and the return value\n// is the number of octets in the Name.\n//\n// This function requires that the NV Index is defined.\nTPM2B_NAME* NvGetNameByIndexHandle(\n\t\t\t\t   TPMI_RH_NV_INDEX handle,  // IN: handle of the index\n\t\t\t\t   TPM2B_NAME*      name     // OUT: name of the index\n\t\t\t\t   )\n{\n    NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL);\n    //\n    return NvGetIndexName(nvIndex, name);\n}\n\n//*** NvDefineIndex()\n// This function is used to assign NV memory to an NV Index.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_NV_SPACE         insufficient NV space\nTPM_RC\nNvDefineIndex(TPMS_NV_PUBLIC* publicArea,  // IN: A template for an area to create.\n\t      TPM2B_AUTH*     authValue    // IN: The initial authorization value\n\t      )\n{\n    // The buffer to be written to NV memory\n    NV_INDEX nvIndex;    // the index data\n    UINT16   entrySize;  // size of entry\n    TPM_RC   result;\n    //\n    entrySize = sizeof(NV_INDEX);\n\n    // only allocate data space for indexes that are going to be written to NV.\n    // Orderly indexes don't need space.\n    if(!IS_ATTRIBUTE(publicArea->attributes, TPMA_NV, ORDERLY))\n\tentrySize += publicArea->dataSize;\n    // Check if we have enough space to create the NV Index\n    // In this implementation, the only resource limitation is the available NV\n    // space (and possibly RAM space.)  Other implementation may have other\n    // limitation on counter or on NV slots\n    if(!NvTestSpace(entrySize, TRUE, IsNvCounterIndex(publicArea->attributes)))\n\treturn TPM_RC_NV_SPACE;\n\n    // if the index to be defined is RAM backed, check RAM space availability\n    // as well\n    if(IS_ATTRIBUTE(publicArea->attributes, TPMA_NV, ORDERLY)\n       && !NvRamTestSpaceIndex(publicArea->dataSize))\n\treturn TPM_RC_NV_SPACE;\n    // Copy input value to nvBuffer\n    nvIndex.publicArea = *publicArea;\n\n    // Copy the authValue\n    nvIndex.authValue = *authValue;\n\n    // Add index to NV memory\n    result = NvAdd(entrySize, sizeof(NV_INDEX), TPM_RH_UNASSIGNED, (BYTE*)&nvIndex);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    // If the data of NV Index is RAM backed, add the data area in RAM as well\n\t    if(IS_ATTRIBUTE(publicArea->attributes, TPMA_NV, ORDERLY))\n\t\tNvAddRAM(publicArea);\n\t}\n    return result;\n}\n\n//*** NvAddEvictObject()\n// This function is used to assign NV memory to a persistent object.\n//  Return Type: TPM_RC\n//      TPM_RC_NV_HANDLE        the requested handle is already in use\n//      TPM_RC_NV_SPACE         insufficient NV space\nTPM_RC\nNvAddEvictObject(TPMI_DH_OBJECT evictHandle,  // IN: new evict handle\n\t\t OBJECT*        object        // IN: object to be added\n\t\t )\n{\n    TPM_HANDLE temp = object->evictHandle;\n    TPM_RC     result;\n    //\n    // Check if we have enough space to add the evict object\n    // An evict object needs 8 bytes in index table + sizeof OBJECT\n    // In this implementation, the only resource limitation is the available NV\n    // space.  Other implementation may have other limitation on evict object\n    // handle space\n    if(!NvTestSpace(sizeof(OBJECT) + sizeof(TPM_HANDLE), FALSE, FALSE))\n\treturn TPM_RC_NV_SPACE;\n\n    // Set evict attribute and handle\n    object->attributes.evict = SET;\n    object->evictHandle      = evictHandle;\n\n    // Now put this in NV\n    result = NvAdd(sizeof(OBJECT), sizeof(OBJECT), evictHandle, (BYTE*)object);\n\n    // Put things back the way they were\n    object->attributes.evict = CLEAR;\n    object->evictHandle      = temp;\n\n    return result;\n}\n\n//*** NvDeleteIndex()\n// This function is used to delete an NV Index.\n//  Return Type: TPM_RC\n//      TPM_RC_NV_UNAVAILABLE   NV is not accessible\n//      TPM_RC_NV_RATE          NV is rate limiting\nTPM_RC\nNvDeleteIndex(NV_INDEX* nvIndex,    // IN: an in RAM index descriptor\n\t      NV_REF    entityAddr  // IN: location in NV\n\t      )\n{\n    TPM_RC result;\n    //\n    if(nvIndex != NULL)\n\t{\n\t    // Whenever a counter is deleted, make sure that the MaxCounter value is\n\t    // updated to reflect the value\n\t    if(IsNvCounterIndex(nvIndex->publicArea.attributes)\n\t       && IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, WRITTEN))\n\t\tNvUpdateMaxCount(NvGetUINT64Data(nvIndex, entityAddr));\n\t    result = NvDelete(entityAddr);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t    // If the NV Index is RAM backed, delete the RAM data as well\n\t    if(IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, ORDERLY))\n\t\tNvDeleteRAM(nvIndex->publicArea.nvIndex);\n\t    NvIndexCacheInit();\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** NvDeleteEvict()\n// This function will delete a NV evict object.\n// Will return success if object deleted or if it does not exist\n\nTPM_RC\nNvDeleteEvict(TPM_HANDLE handle  // IN: handle of entity to be deleted\n\t      )\n{\n    NV_REF entityAddr = NvFindEvict(handle, NULL);  // pointer to entity\n    TPM_RC result     = TPM_RC_SUCCESS;\n    //\n    if(entityAddr != 0)\n\tresult = NvDelete(entityAddr);\n    return result;\n}\n\n//*** NvFlushHierarchy()\n// This function will delete persistent objects belonging to the indicated hierarchy.\n// If the storage hierarchy is selected, the function will also delete any\n// NV Index defined using ownerAuth.\n//  Return Type: TPM_RC\n//      TPM_RC_NV_RATE           NV is unavailable because of rate limit\n//      TPM_RC_NV_UNAVAILABLE    NV is inaccessible\nTPM_RC\nNvFlushHierarchy(TPMI_RH_HIERARCHY hierarchy  // IN: hierarchy to be flushed.\n\t\t )\n{\n    NV_REF     iter = NV_REF_INIT;\n    NV_REF     currentAddr;\n    TPM_HANDLE entityHandle;\n    TPM_RC     result = TPM_RC_SUCCESS;\n    //\n    while((currentAddr = NvNext(&iter, &entityHandle)) != 0)\n\t{\n\t    if(HandleGetType(entityHandle) == TPM_HT_NV_INDEX)\n\t\t{\n\t\t    NV_INDEX nvIndex;\n\t\t    //\n\t\t    // If flush endorsement or platform hierarchy, no NV Index would be\n\t\t    // flushed\n\t\t    if(hierarchy == TPM_RH_ENDORSEMENT || hierarchy == TPM_RH_PLATFORM)\n\t\t\tcontinue;\n\t\t    // Get the index information\n\t\t    NvReadNvIndexInfo(currentAddr, &nvIndex);\n\n\t\t    // For storage hierarchy, flush OwnerCreated index\n\t\t    if(!IS_ATTRIBUTE(nvIndex.publicArea.attributes, TPMA_NV, PLATFORMCREATE))\n\t\t\t{\n\t\t\t    // Delete the index (including RAM for orderly)\n\t\t\t    result = NvDeleteIndex(&nvIndex, currentAddr);\n\t\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\t\tbreak;\n\t\t\t    // Re-iterate from beginning after a delete\n\t\t\t    iter = NV_REF_INIT;\n\t\t\t}\n\t\t}\n\t    else if(HandleGetType(entityHandle) == TPM_HT_PERSISTENT)\n\t\t{\n\t\t    OBJECT_ATTRIBUTES attributes;\n\t\t    //\n\t\t    NvRead(&attributes,\n\t\t\t   (UINT32)(currentAddr + sizeof(TPM_HANDLE)\n\t\t\t\t    + offsetof(OBJECT, attributes)),\n\t\t\t   sizeof(OBJECT_ATTRIBUTES));\n\t\t    // If the evict object belongs to the hierarchy to be flushed...\n\t\t    if((hierarchy == TPM_RH_PLATFORM && attributes.ppsHierarchy == SET)\n\t\t       || (hierarchy == TPM_RH_OWNER && attributes.spsHierarchy == SET)\n\t\t       || (hierarchy == TPM_RH_ENDORSEMENT && attributes.epsHierarchy == SET))\n\t\t\t{\n\t\t\t    // ...then delete the evict object\n\t\t\t    result = NvDelete(currentAddr);\n\t\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\t\tbreak;\n\t\t\t    // Re-iterate from beginning after a delete\n\t\t\t    iter = NV_REF_INIT;\n\t\t\t}\n\t\t}\n\t    else\n\t\t{\n\t\t    FAIL(FATAL_ERROR_INTERNAL);\n\t\t}\n\t}\n    return result;\n}\n\n//*** NvSetGlobalLock()\n// This function is used to SET the TPMA_NV_WRITELOCKED attribute for all\n// NV indexes that have TPMA_NV_GLOBALLOCK SET. This function is use by\n// TPM2_NV_GlobalWriteLock().\n//  Return Type: TPM_RC\n//      TPM_RC_NV_RATE           NV is unavailable because of rate limit\n//      TPM_RC_NV_UNAVAILABLE    NV is inaccessible\nTPM_RC\nNvSetGlobalLock(void)\n{\n    NV_REF     iter    = NV_REF_INIT;\n    NV_RAM_REF ramIter = NV_RAM_REF_INIT;\n    NV_REF     currentAddr;\n    NV_RAM_REF currentRamAddr;\n    TPM_RC     result = TPM_RC_SUCCESS;\n    //\n    // Check all normal indexes\n    while((currentAddr = NvNextIndex(NULL, &iter)) != 0)\n\t{\n\t    TPMA_NV attributes = NvReadNvIndexAttributes(currentAddr);\n\t    //\n\t    // See if it should be locked\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_NV, ORDERLY)\n\t       && IS_ATTRIBUTE(attributes, TPMA_NV, GLOBALLOCK))\n\t\t{\n\t\t    SET_ATTRIBUTE(attributes, TPMA_NV, WRITELOCKED);\n\t\t    result = NvWriteNvIndexAttributes(currentAddr, attributes);\n\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\treturn result;\n\t\t}\n\t}\n    // Now search all the orderly attributes\n    while((currentRamAddr = NvRamNext(&ramIter, NULL)) != 0)\n\t{\n\t    // See if it should be locked\n\t    TPMA_NV attributes = NvReadRamIndexAttributes(currentRamAddr);\n\t    if(IS_ATTRIBUTE(attributes, TPMA_NV, GLOBALLOCK))\n\t\t{\n\t\t    SET_ATTRIBUTE(attributes, TPMA_NV, WRITELOCKED);\n\t\t    NvWriteRamIndexAttributes(currentRamAddr, attributes);\n\t\t}\n\t}\n    return result;\n}\n\n//***InsertSort()\n// Sort a handle into handle list in ascending order.  The total handle number in\n// the list should not exceed MAX_CAP_HANDLES\nstatic void InsertSort(TPML_HANDLE* handleList,  // IN/OUT: sorted handle list\n\t\t       UINT32       count,  // IN: maximum count in the handle list\n\t\t       TPM_HANDLE   entityHandle  // IN: handle to be inserted\n\t\t       )\n{\n    UINT32 i, j;\n    UINT32 originalCount;\n    //\n    // For a corner case that the maximum count is 0, do nothing\n    if(count == 0)\n\treturn;\n    // For empty list, add the handle at the beginning and return\n    if(handleList->count == 0)\n\t{\n\t    handleList->handle[0] = entityHandle;\n\t    handleList->count++;\n\t    return;\n\t}\n    // Check if the maximum of the list has been reached\n    originalCount = handleList->count;\n    if(originalCount < count)\n\thandleList->count++;\n    // Insert the handle to the list\n    for(i = 0; i < originalCount; i++)\n\t{\n\t    if(handleList->handle[i] > entityHandle)\n\t\t{\n\t\t    for(j = handleList->count - 1; j > i; j--)\n\t\t\t{\n\t\t\t    handleList->handle[j] = handleList->handle[j - 1];\n\t\t\t}\n\t\t    break;\n\t\t}\n\t}\n    // If a slot was found, insert the handle in this position\n    if(i < originalCount || handleList->count > originalCount)\n\thandleList->handle[i] = entityHandle;\n    return;\n}\n\n//*** NvCapGetPersistent()\n// This function is used to get a list of handles of the persistent objects,\n// starting at 'handle'.\n//\n// 'Handle' must be in valid persistent object handle range, but does not\n// have to reference an existing persistent object.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles available\n//      NO          all the available handles has been returned\nTPMI_YES_NO\nNvCapGetPersistent(TPMI_DH_OBJECT handle,  // IN: start handle\n\t\t   UINT32         count,   // IN: maximum number of returned handles\n\t\t   TPML_HANDLE*   handleList  // OUT: list of handle\n\t\t   )\n{\n    TPMI_YES_NO more = NO;\n    NV_REF      iter = NV_REF_INIT;\n    NV_REF      currentAddr;\n    TPM_HANDLE  entityHandle;\n    //\n    pAssert(HandleGetType(handle) == TPM_HT_PERSISTENT);\n\n    // Initialize output handle list\n    handleList->count = 0;\n\n    // The maximum count of handles we may return is MAX_CAP_HANDLES\n    if(count > MAX_CAP_HANDLES)\n\tcount = MAX_CAP_HANDLES;\n\n    while((currentAddr = NvNextEvict(&entityHandle, &iter)) != 0)\n\t{\n\t    // Ignore persistent handles that have values less than the input handle\n\t    if(entityHandle < handle)\n\t\tcontinue;\n\t    // if the handles in the list have reached the requested count, and there\n\t    // are still handles need to be inserted, indicate that there are more.\n\t    if(handleList->count == count)\n\t\tmore = YES;\n\t    // A handle with a value larger than start handle is a candidate\n\t    // for return. Insert sort it to the return list.  Insert sort algorithm\n\t    // is chosen here for simplicity based on the assumption that the total\n\t    // number of NV indexes is small.  For an implementation that may allow\n\t    // large number of NV indexes, a more efficient sorting algorithm may be\n\t    // used here.\n\t    InsertSort(handleList, count, entityHandle);\n\t}\n    return more;\n}\n\n//*** NvCapGetOnePersistent()\n// This function returns whether a given persistent handle exists.\n//\n// 'Handle' must be in valid persistent object handle range.\nBOOL NvCapGetOnePersistent(TPMI_DH_OBJECT handle)  // IN: handle\n{\n    NV_REF     iter = NV_REF_INIT;\n    NV_REF     currentAddr;\n    TPM_HANDLE entityHandle;\n\n    pAssert(HandleGetType(handle) == TPM_HT_PERSISTENT);\n\n    while((currentAddr = NvNextEvict(&entityHandle, &iter)) != 0)\n\t{\n\t    if(entityHandle == handle)\n\t\t{\n\t\t    return TRUE;\n\t\t}\n\t}\n    return FALSE;\n}\n\n//*** NvCapGetIndex()\n// This function returns a list of handles of NV indexes, starting from 'handle'.\n// 'Handle' must be in the range of NV indexes, but does not have to reference\n// an existing NV Index.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles to report\n//      NO          all the available handles has been reported\nTPMI_YES_NO\nNvCapGetIndex(TPMI_DH_OBJECT handle,     // IN: start handle\n\t      UINT32         count,      // IN: max number of returned handles\n\t      TPML_HANDLE*   handleList  // OUT: list of handle\n\t      )\n{\n    TPMI_YES_NO more = NO;\n    NV_REF      iter = NV_REF_INIT;\n    NV_REF      currentAddr;\n    TPM_HANDLE  nvHandle;\n    //\n    pAssert(HandleGetType(handle) == TPM_HT_NV_INDEX);\n\n    // Initialize output handle list\n    handleList->count = 0;\n\n    // The maximum count of handles we may return is MAX_CAP_HANDLES\n    if(count > MAX_CAP_HANDLES)\n\tcount = MAX_CAP_HANDLES;\n\n    while((currentAddr = NvNextIndex(&nvHandle, &iter)) != 0)\n\t{\n\t    // Ignore index handles that have values less than the 'handle'\n\t    if(nvHandle < handle)\n\t\tcontinue;\n\t    // if the count of handles in the list has reached the requested count,\n\t    // and there are still handles to report, set more.\n\t    if(handleList->count == count)\n\t\tmore = YES;\n\t    // A handle with a value larger than start handle is a candidate\n\t    // for return. Insert sort it to the return list.  Insert sort algorithm\n\t    // is chosen here for simplicity based on the assumption that the total\n\t    // number of NV indexes is small.  For an implementation that may allow\n\t    // large number of NV indexes, a more efficient sorting algorithm may be\n\t    // used here.\n\t    InsertSort(handleList, count, nvHandle);\n\t}\n    return more;\n}\n\n//*** NvCapGetOneIndex()\n// This function whether an NV index exists.\nBOOL NvCapGetOneIndex(TPMI_DH_OBJECT handle)  // IN: handle\n{\n    NV_REF     iter = NV_REF_INIT;\n    NV_REF     currentAddr;\n    TPM_HANDLE nvHandle;\n\n    pAssert(HandleGetType(handle) == TPM_HT_NV_INDEX);\n\n    while((currentAddr = NvNextIndex(&nvHandle, &iter)) != 0)\n\t{\n\t    if(nvHandle == handle)\n\t\t{\n\t\t    return TRUE;\n\t\t}\n\t}\n    return FALSE;\n}\n\n//*** NvCapGetIndexNumber()\n// This function returns the count of NV Indexes currently defined.\nUINT32\nNvCapGetIndexNumber(void)\n{\n    UINT32 num  = 0;\n    NV_REF iter = NV_REF_INIT;\n    //\n    while(NvNextIndex(NULL, &iter) != 0)\n\tnum++;\n    return num;\n}\n\n//*** NvCapGetPersistentNumber()\n// Function returns the count of persistent objects currently in NV memory.\nUINT32\nNvCapGetPersistentNumber(void)\n{\n    UINT32     num  = 0;\n    NV_REF     iter = NV_REF_INIT;\n    TPM_HANDLE handle;\n    //\n    while(NvNextEvict(&handle, &iter) != 0)\n\tnum++;\n    return num;\n}\n\n//*** NvCapGetPersistentAvail()\n// This function returns an estimate of the number of additional persistent\n// objects that could be loaded into NV memory.\nUINT32\nNvCapGetPersistentAvail(void)\n{\n    UINT32 availNVSpace;\n    UINT32 counterNum = NvCapGetCounterNumber();\n    UINT32 reserved   = sizeof(NV_LIST_TERMINATOR);\n    //\n    // Get the available space in NV storage\n    availNVSpace = NvGetFreeBytes();\n\n    if(counterNum < MIN_COUNTER_INDICES)\n\t{\n\t    // Some space has to be reserved for counter objects.\n\t    reserved += (MIN_COUNTER_INDICES - counterNum) * NV_INDEX_COUNTER_SIZE;\n\t    if(reserved > availNVSpace)\n\t\tavailNVSpace = 0;\n\t    else\n\t\tavailNVSpace -= reserved;\n\t}\n    return availNVSpace / NV_EVICT_OBJECT_SIZE;\n}\n\n//*** NvCapGetCounterNumber()\n// Get the number of defined NV Indexes that are counter indexes.\nUINT32\nNvCapGetCounterNumber(void)\n{\n    NV_REF iter = NV_REF_INIT;\n    NV_REF currentAddr;\n    UINT32 num = 0;\n    //\n    while((currentAddr = NvNextIndex(NULL, &iter)) != 0)\n\t{\n\t    TPMA_NV attributes = NvReadNvIndexAttributes(currentAddr);\n\t    if(IsNvCounterIndex(attributes))\n\t\tnum++;\n\t}\n    return num;\n}\n\n//*** NvSetStartupAttributes()\n// Local function to set the attributes of an Index at TPM Reset and TPM Restart.\nstatic TPMA_NV NvSetStartupAttributes(TPMA_NV attributes,  // IN: attributes to change\n\t\t\t\t      STARTUP_TYPE type    // IN: start up type\n\t\t\t\t      )\n{\n    // Clear read lock\n    CLEAR_ATTRIBUTE(attributes, TPMA_NV, READLOCKED);\n\n    // Will change a non counter index to the unwritten state if:\n    // a) TPMA_NV_CLEAR_STCLEAR is SET\n    // b) orderly and TPM Reset\n    if(!IsNvCounterIndex(attributes))\n\t{\n\t    if(IS_ATTRIBUTE(attributes, TPMA_NV, CLEAR_STCLEAR)\n\t       || (IS_ATTRIBUTE(attributes, TPMA_NV, ORDERLY) && (type == SU_RESET)))\n\t\tCLEAR_ATTRIBUTE(attributes, TPMA_NV, WRITTEN);\n\t}\n    // Unlock any index that is not written or that does not have\n    // TPMA_NV_WRITEDEFINE SET.\n    if(!IS_ATTRIBUTE(attributes, TPMA_NV, WRITTEN)\n       || !IS_ATTRIBUTE(attributes, TPMA_NV, WRITEDEFINE))\n\tCLEAR_ATTRIBUTE(attributes, TPMA_NV, WRITELOCKED);\n    return attributes;\n}\n\n//*** NvEntityStartup()\n//  This function is called at TPM_Startup(). If the startup completes\n//  a TPM Resume cycle, no action is taken. If the startup is a TPM Reset\n//  or a TPM Restart, then this function will:\n//  a) clear read/write lock;\n//  b) reset NV Index data that has TPMA_NV_CLEAR_STCLEAR SET; and\n//  c) set the lower bits in orderly counters to 1 for a non-orderly startup\n//\n//  It is a prerequisite that NV be available for writing before this\n//  function is called.\nBOOL NvEntityStartup(STARTUP_TYPE type  // IN: start up type\n\t\t     )\n{\n    NV_REF     iter    = NV_REF_INIT;\n    NV_RAM_REF ramIter = NV_RAM_REF_INIT;\n    NV_REF     currentAddr;  // offset points to the current entity\n    NV_RAM_REF currentRamAddr;\n    TPM_HANDLE nvHandle;\n    TPMA_NV    attributes;\n    //\n    // Restore RAM index data\n    NvRead(s_indexOrderlyRam, NV_INDEX_RAM_DATA, sizeof(s_indexOrderlyRam));\n\n    // Initialize the max NV counter value\n    NvSetMaxCount(NvGetMaxCount());\n\n    // If recovering from state save, do nothing else\n    if(type == SU_RESUME)\n\treturn TRUE;\n    // Iterate all the NV Index to clear the locks\n    while((currentAddr = NvNextIndex(&nvHandle, &iter)) != 0)\n\t{\n\t    attributes = NvReadNvIndexAttributes(currentAddr);\n\n\t    // If this is an orderly index, defer processing until loop below\n\t    if(IS_ATTRIBUTE(attributes, TPMA_NV, ORDERLY))\n\t\tcontinue;\n\t    // Set the attributes appropriate for this startup type\n\t    attributes = NvSetStartupAttributes(attributes, type);\n\t    NvWriteNvIndexAttributes(currentAddr, attributes);\n\t}\n    // Iterate all the orderly indexes to clear the locks and initialize counters\n    while((currentRamAddr = NvRamNext(&ramIter, NULL)) != 0)\n\t{\n\t    attributes = NvReadRamIndexAttributes(currentRamAddr);\n\n\t    attributes = NvSetStartupAttributes(attributes, type);\n\n\t    // update attributes in RAM\n\t    NvWriteRamIndexAttributes(currentRamAddr, attributes);\n\n\t    // Set the lower bits in an orderly counter to 1 for a non-orderly startup\n\t    if(IsNvCounterIndex(attributes) && (g_prevOrderlyState == SU_NONE_VALUE))\n\t\t{\n\t\t    UINT64 counter;\n\t\t    //\n\t\t    // Read the counter value last saved to NV.\n\t\t    counter = BYTE_ARRAY_TO_UINT64(currentRamAddr + sizeof(NV_RAM_HEADER));\n\n\t\t    // Set the lower bits of counter to 1's\n\t\t    counter |= MAX_ORDERLY_COUNT;\n\n\t\t    // Write back to RAM\n\t\t    // NOTE: Do not want to force a write to NV here. The counter value will\n\t\t    // stay in RAM until the next shutdown or rollover.\n\t\t    UINT64_TO_BYTE_ARRAY(counter, currentRamAddr + sizeof(NV_RAM_HEADER));\n\t\t}\n\t}\n    return TRUE;\n}\n\n//*** NvCapGetCounterAvail()\n// This function returns an estimate of the number of additional counter type\n// NV indexes that can be defined.\nUINT32\nNvCapGetCounterAvail(void)\n{\n    UINT32 availNVSpace;\n    UINT32 availRAMSpace;\n    UINT32 persistentNum = NvCapGetPersistentNumber();\n    UINT32 reserved      = sizeof(NV_LIST_TERMINATOR);\n    //\n    // Get the available space in NV storage\n    availNVSpace = NvGetFreeBytes();\n\n    if(persistentNum < MIN_EVICT_OBJECTS)\n\t{\n\t    // Some space has to be reserved for evict object. Adjust availNVSpace.\n\t    reserved += (MIN_EVICT_OBJECTS - persistentNum) * NV_EVICT_OBJECT_SIZE;\n\t    if(reserved > availNVSpace)\n\t\tavailNVSpace = 0;\n\t    else\n\t\tavailNVSpace -= reserved;\n\t}\n    // Compute the available space in RAM\n    availRAMSpace = (int)(RAM_ORDERLY_END - NvRamGetEnd());\n\n    // Return the min of counter number in NV and in RAM\n    if(availNVSpace / NV_INDEX_COUNTER_SIZE\n       > availRAMSpace / NV_RAM_INDEX_COUNTER_SIZE)\n\treturn availRAMSpace / NV_RAM_INDEX_COUNTER_SIZE;\n    else\n\treturn availNVSpace / NV_INDEX_COUNTER_SIZE;\n}\n\n//*** NvFindHandle()\n// this function returns the offset in NV memory of the entity associated\n// with the input handle.  A value of zero indicates that handle does not\n//  exist reference an existing persistent object or defined NV Index.\nNV_REF\nNvFindHandle(TPM_HANDLE handle)\n{\n    NV_REF     addr;\n    NV_REF     iter = NV_REF_INIT;\n    TPM_HANDLE nextHandle;\n    //\n    while((addr = NvNext(&iter, &nextHandle)) != 0)\n\t{\n\t    if(nextHandle == handle)\n\t\tbreak;\n\t}\n    return addr;\n}\n\n//** NV Max Counter\n//*** Introduction\n// The TPM keeps track of the highest value of a deleted counter index. When an\n// index is deleted, this value is updated if the deleted counter index is greater\n// than the previous value. When a new index is created and first incremented, it\n// will get a value that is at least one greater than any other index than any\n// previously deleted index. This insures that it is not possible to roll back an\n// index.\n//\n// The highest counter value is kept in NV in a special end-of-list marker. This\n// marker is only updated when an index is deleted. Otherwise it just moves.\n//\n// When the TPM starts up, it searches NV for the end of list marker and initializes\n// an in memory value (s_maxCounter).\n\n//*** NvReadMaxCount()\n// This function returns the max NV counter value.\n//\nUINT64\nNvReadMaxCount(void)\n{\n    return s_maxCounter;\n}\n\n//*** NvUpdateMaxCount()\n// This function updates the max counter value to NV memory. This is just staging\n// for the actual write that will occur when the NV index memory is modified.\n//\nvoid NvUpdateMaxCount(UINT64 count)\n{\n    if(count > s_maxCounter)\n\ts_maxCounter = count;\n}\n\n//*** NvSetMaxCount()\n// This function is used at NV initialization time to set the initial value of\n// the maximum counter.\nvoid NvSetMaxCount(UINT64 value)\n{\n    s_maxCounter = value;\n}\n\n//*** NvGetMaxCount()\n// Function to get the NV max counter value from the end-of-list marker\nUINT64\nNvGetMaxCount(void)\n{\n    NV_REF iter = NV_REF_INIT;\n    NV_REF currentAddr;\n    UINT64 maxCount;\n    //\n    // Find the end of list marker and initialize the NV Max Counter value.\n    while((currentAddr = NvNext(&iter, NULL)) != 0)\n\t;\n    // 'iter' should be pointing at the end of list marker so read in the current\n    // value of the s_maxCounter.\n    NvRead(&maxCount, iter + sizeof(UINT32), sizeof(maxCount));\n\n    return maxCount;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/NVMem.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t NV read and write access methods\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n//\n//    This file contains the NV read and write access methods.  This implementation\n//    uses RAM/file and does not manage the RAM/file as NV blocks.\n//    The implementation may become more sophisticated over time.\n//\n\n//** Includes and Local\n#include <memory.h>\n#include <string.h>\n#include <assert.h>\n#include \"Platform.h\"\n#if FILE_BACKED_NV\n// #  include <stdio.h>\n// #include <sbi/sbi_console.h>\n#include \"intercept.h\"\n#include \"ftpm.h\"\n// aes\n// #include \"openssl/aes.h\"\n// #include \"openssl/rand.h\"\nint sbi_printf(const char *format, ...);\n\nstatic FILE* s_NvFile           = NULL;\nstatic int   s_NeedsManufacture = FALSE;\n#endif\n\n//**Functions\n\n#if FILE_BACKED_NV\nconst char* s_NvFilePath = \"NVChip\";\n\n//*** NvFileOpen()\n// This function opens the file used to hold the NV image.\n//  Return Type: int\n//  >= 0        success\n//  -1          error\n// static int NvFileOpen(const char* mode)\n// {\n//     // Try to open an exist NVChip file for read/write\n// #  if defined _MSC_VER && 1\n//     if(fopen_s(&s_NvFile, s_NvFilePath, mode) != 0)\n// \t{\n// \t    s_NvFile = NULL;\n// \t}\n// #  else\n//     s_NvFile = fopen(s_NvFilePath, mode);\n// #  endif\n//     return (s_NvFile == NULL) ? -1 : 0;\n// }\n\nstatic int NvFileOpen(const char* mode)\n{\n\tif (!strcmp(mode, \"r+b\"))\n\t{\n\t\ts_NvFile = fopen(s_NvFilePath, FA_READ | FA_WRITE);\n\t} else if (!strcmp(mode, \"w+b\")) {\n\t\ts_NvFile = fopen(s_NvFilePath, FA_CREATE_ALWAYS | FA_READ | FA_WRITE);\n\t} else {\n\t\tsbi_printf(\"[ftpm] NvFileOpen(): Invalid mode: %s\\n\", mode);\n\t}\n\treturn (s_NvFile == NULL) ? -1 : 0;\n}\n\n//*** NvFileCommit()\n// Write all of the contents of the NV image to a file.\n//  Return Type: int\n//      TRUE(1)         success\n//      FALSE(0)        failure\nstatic int NvFileCommit(void)\n{\n    int OK;\n    // If NV file is not available, return failure\n    if(s_NvFile == NULL)\n\treturn 1;\n    // Write RAM data to NV\n    // fseek(s_NvFile, 0, SEEK_SET);\n\tfrewind(s_NvFile);\n\n\t// s_NV -> s_NV_ENC\n\taes_cbc_encrypt_decrypt(&nv_enc_key, s_NV, s_NV_ENC, nv_iv, sizeof(s_NV), 1);\n\t// sbi_printf(\"[fTPM] NvFileCommit(): len(s_NV_ENC)=%d\\n\", sizeof());\n\n\tOK = (NV_MEMORY_SIZE == fwrite(s_NV_ENC, 1, NV_MEMORY_SIZE, s_NvFile));\n    // OK = (NV_MEMORY_SIZE == fwrite(s_NV, 1, NV_MEMORY_SIZE, s_NvFile));\n\n    OK = OK && (0 == fflush(s_NvFile));\n    assert(OK);\n    return OK;\n}\n\n//*** NvFileSize()\n// This function gets the size of the NV file and puts the file pointer where desired\n// using the seek method values. SEEK_SET => beginning; SEEK_CUR => current position\n// and SEEK_END => to the end of the file.\n// static long NvFileSize(int leaveAt)\n// {\n//     long fileSize;\n//     long filePos = ftell(s_NvFile);\n//     //\n//     assert(NULL != s_NvFile);\n\n//     int fseek_result = fseek(s_NvFile, 0, SEEK_END);\n//     NOT_REFERENCED(fseek_result);  // Fix compiler warning for NDEBUG\n//     assert(fseek_result == 0);\n//     fileSize = ftell(s_NvFile);\n//     assert(fileSize >= 0);\n//     switch(leaveAt)\n// \t{\n// \t  case SEEK_SET:\n// \t    filePos = 0;\n// \t  case SEEK_CUR:\n// \t    fseek(s_NvFile, filePos, SEEK_SET);\n// \t    break;\n// \t  case SEEK_END:\n// \t    break;\n// \t  default:\n// \t    assert(FALSE);\n// \t    break;\n// \t}\n//     return fileSize;\n// }\n\nstatic long NvFileSize()\n{\n    long fileSize;\n    //\n    assert(NULL != s_NvFile);\n\n    fileSize = fsize(s_NvFile);\n    assert(fileSize >= 0);\n\n\tfrewind(s_NvFile);\n\tsbi_printf(\"[debug] NvFileSize(): s_NvFile=%p, fileSize=%x\\n\", s_NvFile, fileSize);\n\n    return fileSize;\n}\n#endif\n\n//*** _plat__NvErrors()\n// This function is used by the simulator to set the error flags in the NV\n// subsystem to simulate an error in the NV loading process\nLIB_EXPORT void _plat__NvErrors(int recoverable, int unrecoverable)\n{\n    s_NV_unrecoverable = unrecoverable;\n    s_NV_recoverable   = recoverable;\n}\n\n//***_plat__NVEnable()\n// Enable NV memory.\n//\n// This version just pulls in data from a file. In a real TPM, with NV on chip,\n// this function would verify the integrity of the saved context. If the NV\n// memory was not on chip but was in something like RPMB, the NV state would be\n// read in, decrypted and integrity checked.\n//\n// The recovery from an integrity failure depends on where the error occurred. It\n// it was in the state that is discarded by TPM Reset, then the error is\n// recoverable if the TPM is reset. Otherwise, the TPM must go into failure mode.\n//  Return Type: int\n//      0           if success\n//      > 0         if receive recoverable error\n//      <0          if unrecoverable error\n#define NV_ENABLE_SUCCESS 0\n#define NV_ENABLE_FAILED  (-1)\nLIB_EXPORT int _plat__NVEnable(\n\t\t\t       void*  platParameter,  // platform specific parameter\n\t\t\t       size_t paramSize       // size of parameter. If size == 0, then\n\t\t\t       // parameter is a sizeof(void*) scalar and should\n\t\t\t       // be cast to an integer (intptr_t), not dereferenced.\n\t\t\t       )\n{\n    NOT_REFERENCED(platParameter);  // to keep compiler quiet\n    NOT_REFERENCED(paramSize);      // to keep compiler quiet\n\n    // Start assuming everything is OK\n    s_NV_unrecoverable = FALSE;\n    s_NV_recoverable   = FALSE;\n#if FILE_BACKED_NV\n    if(s_NvFile != NULL)\n\treturn NV_ENABLE_SUCCESS;\n    // Initialize all the bytes in the ram copy of the NV\n    _plat__NvMemoryClear(0, NV_MEMORY_SIZE);\n\n    // If the file exists\n    if(NvFileOpen(\"r+b\") >= 0)\n\t{\n\t    //long fileSize = NvFileSize(SEEK_SET);  // get the file size and leave the\n\t\tlong fileSize = NvFileSize();\n\t\t// long fileSize = 0;\n\t    // file pointer at the start\n\t    //\n\t    // If the size is right, read the data\n\t    if(NV_MEMORY_SIZE == fileSize)\n\t\t{\t\n\t\t\t\n\t\t    // s_NeedsManufacture = fread(s_NV, 1, NV_MEMORY_SIZE, s_NvFile)\n\t\t\t// \t\t != NV_MEMORY_SIZE;\n\t\t\tuint64_t begin_cycle, end_cycle;\n\t\t\tasm volatile (\"rdcycle %0\" : \"=r\"(begin_cycle));\n\t\t    s_NeedsManufacture = fread(s_NV_ENC, 1, NV_MEMORY_SIZE, s_NvFile)\n\t\t\t\t\t != NV_MEMORY_SIZE;\n\t\t\tasm volatile (\"rdcycle %0\" : \"=r\"(end_cycle));\n\t\t\tsbi_printf(\"[BENCH] NV fread(): %lu\\n\", end_cycle - begin_cycle);\n\n\t\t\tasm volatile (\"rdcycle %0\" : \"=r\"(begin_cycle));\n\t\t\taes_cbc_encrypt_decrypt(&nv_dec_key, s_NV_ENC, s_NV, nv_iv, sizeof(s_NV), 0);\n\t\t\tasm volatile (\"rdcycle %0\" : \"=r\"(end_cycle));\n\t\t\tsbi_printf(\"[BENCH] NV decrypt(): %lu\\n\", end_cycle - begin_cycle);\n\n\t\t}\n\t    else\n\t\t{\n\t\t    NvFileCommit();  // for any other size, initialize it\n\t\t    s_NeedsManufacture = TRUE;\n\t\t}\n\t}\n    // If NVChip file does not exist, try to create it for read/write.\n    else if(NvFileOpen(\"w+b\") >= 0)\n\t{\n\t    NvFileCommit();  // Initialize the file\n\t    s_NeedsManufacture = TRUE;\n\t}\n    assert(NULL != s_NvFile);  // Just in case we are broken for some reason.\n#endif\n    // NV contents have been initialized and the error checks have been performed. For\n    // simulation purposes, use the signaling interface to indicate if an error is\n    // to be simulated and the type of the error.\n    if(s_NV_unrecoverable)\n\treturn NV_ENABLE_FAILED;\n    s_NvIsAvailable = TRUE;\n    return s_NV_recoverable;\n}\n\n//***_plat__NVDisable()\n// Disable NV memory\nLIB_EXPORT void _plat__NVDisable(\n\t\t\t\t void*  platParameter,  // platform specific parameter\n\t\t\t\t size_t paramSize       // size of parameter. If size == 0, then\n\t\t\t\t // parameter is a sizeof(void*) scalar and should\n\t\t\t\t // be cast to an integer (intptr_t), not dereferenced.\n\t\t\t\t )\n{\n    NOT_REFERENCED(paramSize);  // to keep compiler quiet\n    int delete = ((intptr_t)platParameter != 0)\n\t\t ? TRUE\n\t\t : FALSE;  // IN: If TRUE (!=0), delete the NV contents.\n\n#if FILE_BACKED_NV\n    if(NULL != s_NvFile)\n\t{\n\t    fclose(s_NvFile);  // Close NV file\n\t    // Alternative to deleting the file is to set its size to 0. This will not\n\t    // match the NV size so the TPM will need to be remanufactured.\n\t    if(delete)\n\t\t{\n\t\t    // Open for writing at the start. Sets the size to zero.\n\t\t    if(NvFileOpen(\"w\") >= 0)\n\t\t\t{\n\t\t\t    fflush(s_NvFile);\n\t\t\t    fclose(s_NvFile);\n\t\t\t}\n\t\t}\n\t}\n    s_NvFile = NULL;  // Set file handle to NULL\n#endif\n    s_NvIsAvailable = FALSE;\n    return;\n}\n\n//***_plat__GetNvReadyState()\n// Check if NV is available\n//  Return Type: int\n//      0               NV is available\n//      1               NV is not available due to write failure\n//      2               NV is not available due to rate limit\nLIB_EXPORT int _plat__GetNvReadyState(void)\n{\n    int retVal = NV_READY;\n    if(!s_NvIsAvailable)\n\tretVal = NV_WRITEFAILURE;\n#if FILE_BACKED_NV\n    else\n\tretVal = (s_NvFile == NULL);\n#endif\n    return retVal;\n}\n\n//***_plat__NvMemoryRead()\n// Function: Read a chunk of NV memory\n//  Return Type: int\n//      TRUE(1)         offset and size is within available NV size\n//      FALSE(0)        otherwise; also trigger failure mode\nLIB_EXPORT int _plat__NvMemoryRead(unsigned int startOffset,  // IN: read start\n\t\t\t\t   unsigned int size,  // IN: size of bytes to read\n\t\t\t\t   void*        data   // OUT: data buffer\n\t\t\t\t   )\n{\n    assert(startOffset + size <= NV_MEMORY_SIZE);\n    if(startOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    memcpy(data, &s_NV[startOffset], size);  // Copy data from RAM\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//*** _plat__NvGetChangedStatus()\n// This function checks to see if the NV is different from the test value. This is\n// so that NV will not be written if it has not changed.\n//  Return Type: int\n//      NV_HAS_CHANGED(1)       the NV location is different from the test value\n//      NV_IS_SAME(0)           the NV location is the same as the test value\n//      NV_INVALID_LOCATION(-1) the NV location is invalid; also triggers failure mode\nLIB_EXPORT int _plat__NvGetChangedStatus(\n\t\t\t\t\t unsigned int startOffset,  // IN: read start\n\t\t\t\t\t unsigned int size,         // IN: size of bytes to read\n\t\t\t\t\t void*        data          // IN: data buffer\n\t\t\t\t\t )\n{\n    assert(startOffset + size <= NV_MEMORY_SIZE);\n    if(startOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    return (memcmp(&s_NV[startOffset], data, size) != 0);\n\t}\n    // the NV location is invalid; the assert above should have triggered failure\n    // mode\n    return NV_INVALID_LOCATION;\n}\n\n//***_plat__NvMemoryWrite()\n// This function is used to update NV memory. The \"write\" is to a memory copy of\n// NV. At the end of the current command, any changes are written to\n// the actual NV memory.\n// NOTE: A useful optimization would be for this code to compare the current\n// contents of NV with the local copy and note the blocks that have changed. Then\n// only write those blocks when _plat__NvCommit() is called.\n//  Return Type: int\n//      TRUE(1)         offset and size is within available NV size\n//      FALSE(0)        otherwise; also trigger failure mode\nLIB_EXPORT int _plat__NvMemoryWrite(unsigned int startOffset,  // IN: write start\n\t\t\t\t    unsigned int size,  // IN: size of bytes to write\n\t\t\t\t    void*        data   // OUT: data buffer\n\t\t\t\t    )\n{\n    assert(startOffset + size <= NV_MEMORY_SIZE);\n    if(startOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    memcpy(&s_NV[startOffset], data, size);  // Copy the data to the NV image\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//***_plat__NvMemoryClear()\n// Function is used to set a range of NV memory bytes to an implementation-dependent\n// value. The value represents the erase state of the memory.\nLIB_EXPORT int _plat__NvMemoryClear(unsigned int startOffset,  // IN: clear start\n\t\t\t\t    unsigned int size  // IN: number of bytes to clear\n\t\t\t\t    )\n{\n    assert(startOffset + size <= NV_MEMORY_SIZE);\n    if(startOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    // In this implementation, assume that the erase value for NV is all 1s\n\t    memset(&s_NV[startOffset], 0xff, size);\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//***_plat__NvMemoryMove()\n// Function: Move a chunk of NV memory from source to destination\n//      This function should ensure that if there overlap, the original data is\n//      copied before it is written\nLIB_EXPORT int _plat__NvMemoryMove(unsigned int sourceOffset,  // IN: source offset\n\t\t\t\t   unsigned int destOffset,  // IN: destination offset\n\t\t\t\t   unsigned int size  // IN: size of data being moved\n\t\t\t\t   )\n{\n    assert(sourceOffset + size <= NV_MEMORY_SIZE);\n    assert(destOffset + size <= NV_MEMORY_SIZE);\n    if(sourceOffset + size <= NV_MEMORY_SIZE && destOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    memmove(&s_NV[destOffset], &s_NV[sourceOffset], size);  // Move data in RAM\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//***_plat__NvCommit()\n// This function writes the local copy of NV to NV for permanent store. It will write\n// NV_MEMORY_SIZE bytes to NV. If a file is use, the entire file is written.\n//  Return Type: int\n//  0       NV write success\n//  non-0   NV write fail\nLIB_EXPORT int _plat__NvCommit(void)\n{\n#if FILE_BACKED_NV\n    return (NvFileCommit() ? 0 : 1);\n#else\n    return 0;\n#endif\n}\n\n//***_plat__TearDown\n// notify platform that TPM_TearDown was called so platform can cleanup or\n// zeroize anything in the Platform.  This should zeroize NV as well.\nLIB_EXPORT void _plat__TearDown(void)\n{\n#if FILE_BACKED_NV\n    // remove(s_NvFilePath);\n#endif\n}\n\n//***_plat__SetNvAvail()\n// Set the current NV state to available.  This function is for testing purpose\n// only.  It is not part of the platform NV logic\nLIB_EXPORT void _plat__SetNvAvail(void)\n{\n    s_NvIsAvailable = TRUE;\n    return;\n}\n\n//***_plat__ClearNvAvail()\n// Set the current NV state to unavailable.  This function is for testing purpose\n// only.  It is not part of the platform NV logic\nLIB_EXPORT void _plat__ClearNvAvail(void)\n{\n    s_NvIsAvailable = FALSE;\n    return;\n}\n\n//*** _plat__NVNeedsManufacture()\n// This function is used by the simulator to determine when the TPM's NV state\n// needs to be manufactured.\nLIB_EXPORT int _plat__NVNeedsManufacture(void)\n{\n#if FILE_BACKED_NV\n    return s_NeedsManufacture;\n#else\n    return FALSE;\n#endif\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/NVMem.c.bak",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t NV read and write access methods\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n//\n//    This file contains the NV read and write access methods.  This implementation\n//    uses RAM/file and does not manage the RAM/file as NV blocks.\n//    The implementation may become more sophisticated over time.\n//\n\n//** Includes and Local\n#include <memory.h>\n#include <string.h>\n#include <assert.h>\n#include \"Platform.h\"\n#if FILE_BACKED_NV\n#  include <stdio.h>\n#include \"intercept.h\"\nstatic FILE* s_NvFile           = NULL;\nstatic int   s_NeedsManufacture = FALSE;\n#endif\n\n//**Functions\n\n#if FILE_BACKED_NV\nconst char* s_NvFilePath = \"NVChip\";\n\n//*** NvFileOpen()\n// This function opens the file used to hold the NV image.\n//  Return Type: int\n//  >= 0        success\n//  -1          error\nstatic int NvFileOpen(const char* mode)\n{\n    // Try to open an exist NVChip file for read/write\n#  if defined _MSC_VER && 1\n    if(fopen_s(&s_NvFile, s_NvFilePath, mode) != 0)\n\t{\n\t    s_NvFile = NULL;\n\t}\n#  else\n    s_NvFile = fopen(s_NvFilePath, mode);\n#  endif\n    return (s_NvFile == NULL) ? -1 : 0;\n}\n\n//*** NvFileCommit()\n// Write all of the contents of the NV image to a file.\n//  Return Type: int\n//      TRUE(1)         success\n//      FALSE(0)        failure\nstatic int NvFileCommit(void)\n{\n    int OK;\n    // If NV file is not available, return failure\n    if(s_NvFile == NULL)\n\treturn 1;\n    // Write RAM data to NV\n    fseek(s_NvFile, 0, SEEK_SET);\n    OK = (NV_MEMORY_SIZE == fwrite(s_NV, 1, NV_MEMORY_SIZE, s_NvFile));\n    OK = OK && (0 == fflush(s_NvFile));\n    assert(OK);\n    return OK;\n}\n\n//*** NvFileSize()\n// This function gets the size of the NV file and puts the file pointer where desired\n// using the seek method values. SEEK_SET => beginning; SEEK_CUR => current position\n// and SEEK_END => to the end of the file.\nstatic long NvFileSize(int leaveAt)\n{\n    long fileSize;\n    long filePos = ftell(s_NvFile);\n    //\n    assert(NULL != s_NvFile);\n\n    int fseek_result = fseek(s_NvFile, 0, SEEK_END);\n    NOT_REFERENCED(fseek_result);  // Fix compiler warning for NDEBUG\n    assert(fseek_result == 0);\n    fileSize = ftell(s_NvFile);\n    assert(fileSize >= 0);\n    switch(leaveAt)\n\t{\n\t  case SEEK_SET:\n\t    filePos = 0;\n\t  case SEEK_CUR:\n\t    fseek(s_NvFile, filePos, SEEK_SET);\n\t    break;\n\t  case SEEK_END:\n\t    break;\n\t  default:\n\t    assert(FALSE);\n\t    break;\n\t}\n    return fileSize;\n}\n#endif\n\n//*** _plat__NvErrors()\n// This function is used by the simulator to set the error flags in the NV\n// subsystem to simulate an error in the NV loading process\nLIB_EXPORT void _plat__NvErrors(int recoverable, int unrecoverable)\n{\n    s_NV_unrecoverable = unrecoverable;\n    s_NV_recoverable   = recoverable;\n}\n\n//***_plat__NVEnable()\n// Enable NV memory.\n//\n// This version just pulls in data from a file. In a real TPM, with NV on chip,\n// this function would verify the integrity of the saved context. If the NV\n// memory was not on chip but was in something like RPMB, the NV state would be\n// read in, decrypted and integrity checked.\n//\n// The recovery from an integrity failure depends on where the error occurred. It\n// it was in the state that is discarded by TPM Reset, then the error is\n// recoverable if the TPM is reset. Otherwise, the TPM must go into failure mode.\n//  Return Type: int\n//      0           if success\n//      > 0         if receive recoverable error\n//      <0          if unrecoverable error\n#define NV_ENABLE_SUCCESS 0\n#define NV_ENABLE_FAILED  (-1)\nLIB_EXPORT int _plat__NVEnable(\n\t\t\t       void*  platParameter,  // platform specific parameter\n\t\t\t       size_t paramSize       // size of parameter. If size == 0, then\n\t\t\t       // parameter is a sizeof(void*) scalar and should\n\t\t\t       // be cast to an integer (intptr_t), not dereferenced.\n\t\t\t       )\n{\n    NOT_REFERENCED(platParameter);  // to keep compiler quiet\n    NOT_REFERENCED(paramSize);      // to keep compiler quiet\n\n    // Start assuming everything is OK\n    s_NV_unrecoverable = FALSE;\n    s_NV_recoverable   = FALSE;\n#if FILE_BACKED_NV\n    if(s_NvFile != NULL)\n\treturn NV_ENABLE_SUCCESS;\n    // Initialize all the bytes in the ram copy of the NV\n    _plat__NvMemoryClear(0, NV_MEMORY_SIZE);\n\n    // If the file exists\n    if(NvFileOpen(\"r+b\") >= 0)\n\t{\n\t    long fileSize = NvFileSize(SEEK_SET);  // get the file size and leave the\n\t    // file pointer at the start\n\t    //\n\t    // If the size is right, read the data\n\t    if(NV_MEMORY_SIZE == fileSize)\n\t\t{\n\t\t    s_NeedsManufacture = fread(s_NV, 1, NV_MEMORY_SIZE, s_NvFile)\n\t\t\t\t\t != NV_MEMORY_SIZE;\n\t\t}\n\t    else\n\t\t{\n\t\t    NvFileCommit();  // for any other size, initialize it\n\t\t    s_NeedsManufacture = TRUE;\n\t\t}\n\t}\n    // If NVChip file does not exist, try to create it for read/write.\n    else if(NvFileOpen(\"w+b\") >= 0)\n\t{\n\t    NvFileCommit();  // Initialize the file\n\t    s_NeedsManufacture = TRUE;\n\t}\n    assert(NULL != s_NvFile);  // Just in case we are broken for some reason.\n#endif\n    // NV contents have been initialized and the error checks have been performed. For\n    // simulation purposes, use the signaling interface to indicate if an error is\n    // to be simulated and the type of the error.\n    if(s_NV_unrecoverable)\n\treturn NV_ENABLE_FAILED;\n    s_NvIsAvailable = TRUE;\n    return s_NV_recoverable;\n}\n\n//***_plat__NVDisable()\n// Disable NV memory\nLIB_EXPORT void _plat__NVDisable(\n\t\t\t\t void*  platParameter,  // platform specific parameter\n\t\t\t\t size_t paramSize       // size of parameter. If size == 0, then\n\t\t\t\t // parameter is a sizeof(void*) scalar and should\n\t\t\t\t // be cast to an integer (intptr_t), not dereferenced.\n\t\t\t\t )\n{\n    NOT_REFERENCED(paramSize);  // to keep compiler quiet\n    int delete = ((intptr_t)platParameter != 0)\n\t\t ? TRUE\n\t\t : FALSE;  // IN: If TRUE (!=0), delete the NV contents.\n\n#if FILE_BACKED_NV\n    if(NULL != s_NvFile)\n\t{\n\t    fclose(s_NvFile);  // Close NV file\n\t    // Alternative to deleting the file is to set its size to 0. This will not\n\t    // match the NV size so the TPM will need to be remanufactured.\n\t    if(delete)\n\t\t{\n\t\t    // Open for writing at the start. Sets the size to zero.\n\t\t    if(NvFileOpen(\"w\") >= 0)\n\t\t\t{\n\t\t\t    fflush(s_NvFile);\n\t\t\t    fclose(s_NvFile);\n\t\t\t}\n\t\t}\n\t}\n    s_NvFile = NULL;  // Set file handle to NULL\n#endif\n    s_NvIsAvailable = FALSE;\n    return;\n}\n\n//***_plat__GetNvReadyState()\n// Check if NV is available\n//  Return Type: int\n//      0               NV is available\n//      1               NV is not available due to write failure\n//      2               NV is not available due to rate limit\nLIB_EXPORT int _plat__GetNvReadyState(void)\n{\n    int retVal = NV_READY;\n    if(!s_NvIsAvailable)\n\tretVal = NV_WRITEFAILURE;\n#if FILE_BACKED_NV\n    else\n\tretVal = (s_NvFile == NULL);\n#endif\n    return retVal;\n}\n\n//***_plat__NvMemoryRead()\n// Function: Read a chunk of NV memory\n//  Return Type: int\n//      TRUE(1)         offset and size is within available NV size\n//      FALSE(0)        otherwise; also trigger failure mode\nLIB_EXPORT int _plat__NvMemoryRead(unsigned int startOffset,  // IN: read start\n\t\t\t\t   unsigned int size,  // IN: size of bytes to read\n\t\t\t\t   void*        data   // OUT: data buffer\n\t\t\t\t   )\n{\n    assert(startOffset + size <= NV_MEMORY_SIZE);\n    if(startOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    memcpy(data, &s_NV[startOffset], size);  // Copy data from RAM\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//*** _plat__NvGetChangedStatus()\n// This function checks to see if the NV is different from the test value. This is\n// so that NV will not be written if it has not changed.\n//  Return Type: int\n//      NV_HAS_CHANGED(1)       the NV location is different from the test value\n//      NV_IS_SAME(0)           the NV location is the same as the test value\n//      NV_INVALID_LOCATION(-1) the NV location is invalid; also triggers failure mode\nLIB_EXPORT int _plat__NvGetChangedStatus(\n\t\t\t\t\t unsigned int startOffset,  // IN: read start\n\t\t\t\t\t unsigned int size,         // IN: size of bytes to read\n\t\t\t\t\t void*        data          // IN: data buffer\n\t\t\t\t\t )\n{\n    assert(startOffset + size <= NV_MEMORY_SIZE);\n    if(startOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    return (memcmp(&s_NV[startOffset], data, size) != 0);\n\t}\n    // the NV location is invalid; the assert above should have triggered failure\n    // mode\n    return NV_INVALID_LOCATION;\n}\n\n//***_plat__NvMemoryWrite()\n// This function is used to update NV memory. The \"write\" is to a memory copy of\n// NV. At the end of the current command, any changes are written to\n// the actual NV memory.\n// NOTE: A useful optimization would be for this code to compare the current\n// contents of NV with the local copy and note the blocks that have changed. Then\n// only write those blocks when _plat__NvCommit() is called.\n//  Return Type: int\n//      TRUE(1)         offset and size is within available NV size\n//      FALSE(0)        otherwise; also trigger failure mode\nLIB_EXPORT int _plat__NvMemoryWrite(unsigned int startOffset,  // IN: write start\n\t\t\t\t    unsigned int size,  // IN: size of bytes to write\n\t\t\t\t    void*        data   // OUT: data buffer\n\t\t\t\t    )\n{\n    assert(startOffset + size <= NV_MEMORY_SIZE);\n    if(startOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    memcpy(&s_NV[startOffset], data, size);  // Copy the data to the NV image\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//***_plat__NvMemoryClear()\n// Function is used to set a range of NV memory bytes to an implementation-dependent\n// value. The value represents the erase state of the memory.\nLIB_EXPORT int _plat__NvMemoryClear(unsigned int startOffset,  // IN: clear start\n\t\t\t\t    unsigned int size  // IN: number of bytes to clear\n\t\t\t\t    )\n{\n    assert(startOffset + size <= NV_MEMORY_SIZE);\n    if(startOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    // In this implementation, assume that the erase value for NV is all 1s\n\t    memset(&s_NV[startOffset], 0xff, size);\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//***_plat__NvMemoryMove()\n// Function: Move a chunk of NV memory from source to destination\n//      This function should ensure that if there overlap, the original data is\n//      copied before it is written\nLIB_EXPORT int _plat__NvMemoryMove(unsigned int sourceOffset,  // IN: source offset\n\t\t\t\t   unsigned int destOffset,  // IN: destination offset\n\t\t\t\t   unsigned int size  // IN: size of data being moved\n\t\t\t\t   )\n{\n    assert(sourceOffset + size <= NV_MEMORY_SIZE);\n    assert(destOffset + size <= NV_MEMORY_SIZE);\n    if(sourceOffset + size <= NV_MEMORY_SIZE && destOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    memmove(&s_NV[destOffset], &s_NV[sourceOffset], size);  // Move data in RAM\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//***_plat__NvCommit()\n// This function writes the local copy of NV to NV for permanent store. It will write\n// NV_MEMORY_SIZE bytes to NV. If a file is use, the entire file is written.\n//  Return Type: int\n//  0       NV write success\n//  non-0   NV write fail\nLIB_EXPORT int _plat__NvCommit(void)\n{\n#if FILE_BACKED_NV\n    return (NvFileCommit() ? 0 : 1);\n#else\n    return 0;\n#endif\n}\n\n//***_plat__TearDown\n// notify platform that TPM_TearDown was called so platform can cleanup or\n// zeroize anything in the Platform.  This should zeroize NV as well.\nLIB_EXPORT void _plat__TearDown(void)\n{\n#if FILE_BACKED_NV\n    // remove(s_NvFilePath);\n#endif\n}\n\n//***_plat__SetNvAvail()\n// Set the current NV state to available.  This function is for testing purpose\n// only.  It is not part of the platform NV logic\nLIB_EXPORT void _plat__SetNvAvail(void)\n{\n    s_NvIsAvailable = TRUE;\n    return;\n}\n\n//***_plat__ClearNvAvail()\n// Set the current NV state to unavailable.  This function is for testing purpose\n// only.  It is not part of the platform NV logic\nLIB_EXPORT void _plat__ClearNvAvail(void)\n{\n    s_NvIsAvailable = FALSE;\n    return;\n}\n\n//*** _plat__NVNeedsManufacture()\n// This function is used by the simulator to determine when the TPM's NV state\n// needs to be manufactured.\nLIB_EXPORT int _plat__NVNeedsManufacture(void)\n{\n#if FILE_BACKED_NV\n    return s_NeedsManufacture;\n#else\n    return FALSE;\n#endif\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/NVReserved.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tNV TPM persistent and state save data  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n\n// The NV memory is divided into two areas: dynamic space for user defined NV\n// Indices and evict objects, and reserved space for TPM persistent and state save\n// data.\n//\n// The entries in dynamic space are a linked list of entries. Each entry has, as its\n// first field, a size. If the size field is zero, it marks the end of the\n// list.\n//\n// An allocation of an Index or evict object may use almost all of the remaining\n// NV space such that the size field will not fit. The functions that search the\n// list are aware of this and will terminate the search if they either find a zero\n// size or recognize that there is insufficient space for the size field.\n//\n// An Index allocation will contain an NV_INDEX structure. If the Index does not\n// have the orderly attribute, the NV_INDEX is followed immediately by the NV data.\n//\n// An evict object entry contains a handle followed by an OBJECT structure. This\n// results in both the Index and Evict Object having an identifying handle as the\n// first field following the size field.\n//\n// When an Index has the orderly attribute, the data is kept in RAM. This RAM is\n// saved to backing store in NV memory on any orderly shutdown. The entries in\n// orderly memory are also a linked list using a size field as the first entry. As\n// with the NV memory, the list is terminated by a zero size field or when the last\n// entry leaves insufficient space for the terminating size field.\n//\n// The attributes of an orderly index are maintained in RAM memory in order to\n// reduce the number of NV writes needed for orderly data. When an orderly index\n// is created, an entry is made in the dynamic NV memory space that holds the Index\n// authorizations (authPolicy and authValue) and the size of the data. This entry is\n// only modified if the authValue  of the index is changed. The more volatile data\n// of the index is kept in RAM. When an orderly Index is created or deleted, the\n// RAM data is copied to NV backing store so that the image in the backing store\n// matches the layout of RAM. In normal operation. The RAM data is also copied on\n// any orderly shutdown. In normal operation, the only other reason for writing\n// to the backing store for RAM is when a counter is first written (TPMA_NV_WRITTEN\n// changes from CLEAR to SET) or when a counter \"rolls over.\"\n//\n// Static space contains items that are individually modifiable. The values are in\n// the 'gp' PERSISTENT_DATA structure in RAM and mapped to locations in NV.\n//\n\n//** Includes, Defines\n#define NV_C\n#include \"Tpm.h\"\n\n//************************************************\n//** Functions\n//************************************************\n\n//*** NvInitStatic()\n// This function initializes the static variables used in the NV subsystem.\nstatic void NvInitStatic(void)\n{\n    // In some implementations, the end of NV is variable and is set at boot time.\n    // This value will be the same for each boot, but is not necessarily known\n    // at compile time.\n    s_evictNvEnd = (NV_REF)NV_MEMORY_SIZE;\n    return;\n}\n\n//*** NvCheckState()\n// Function to check the NV state by accessing the platform-specific function\n// to get the NV state.  The result state is registered in s_NvIsAvailable\n// that will be reported by NvIsAvailable.\n//\n// This function is called at the beginning of ExecuteCommand before any potential\n// check of g_NvStatus.\nvoid NvCheckState(void)\n{\n    int func_return;\n    //\n    func_return = _plat__GetNvReadyState();\n    if(func_return == NV_READY)\n\t{\n\t    g_NvStatus = TPM_RC_SUCCESS;\n\t}\n    else if(func_return == NV_WRITEFAILURE)\n\t{\n\t    g_NvStatus = TPM_RC_NV_UNAVAILABLE;\n\t}\n    else\n\t{\n\t    // if(func_return == NV_RATE_LIMIT) or anything else\n\t    // assume retry later might work\n\t    g_NvStatus = TPM_RC_NV_RATE;\n\t}\n    \n    return;\n}\n\n//*** NvCommit\n// This is a wrapper for the platform function to commit pending NV writes.\nBOOL NvCommit(void)\n{\n    return (_plat__NvCommit() == 0);\n}\n\n//*** NvPowerOn()\n//  This function is called at _TPM_Init to initialize the NV environment.\n//  Return Type: BOOL\n//      TRUE(1)         all NV was initialized\n//      FALSE(0)        the NV containing saved state had an error and\n//                      TPM2_Startup(CLEAR) is required\nBOOL NvPowerOn(void)\n{\n    int nvError = 0;\n    // If power was lost, need to re-establish the RAM data that is loaded from\n    // NV and initialize the static variables\n    if(g_powerWasLost)\n\t{\n\t    if((nvError = _plat__NVEnable(NULL, 0)) < 0)\n\t\tFAIL(FATAL_ERROR_NV_UNRECOVERABLE);\n\t    NvInitStatic();\n\t}\n    return nvError == 0;\n}\n\n//*** NvManufacture()\n// This function initializes the NV system at pre-install time.\n//\n// This function should only be called in a manufacturing environment or in a\n// simulation.\n//\n// The layout of NV memory space is an implementation choice.\nvoid NvManufacture(void)\n{\n#if SIMULATION\n    // Simulate the NV memory being in the erased state.\n    _plat__NvMemoryClear(0, NV_MEMORY_SIZE);\n#endif\n    // Initialize static variables\n    NvInitStatic();\n    // Clear the RAM used for Orderly Index data\n    MemorySet(s_indexOrderlyRam, 0, RAM_INDEX_SPACE);\n    // Write that Orderly Index data to NV\n    NvUpdateIndexOrderlyData();\n    // Initialize the next offset of the first entry in evict/index list to 0 (the\n    // end of list marker) and the initial s_maxCounterValue;\n    NvSetMaxCount(0);\n    // Put the end of list marker at the end of memory. This contains the MaxCount\n    // value as well as the end marker.\n    NvWriteNvListEnd(NV_USER_DYNAMIC);\n    return;\n}\n\n//*** NvRead()\n// This function is used to move reserved data from NV memory to RAM.\nvoid NvRead(void*  outBuffer,  // OUT: buffer to receive data\n\t    UINT32 nvOffset,   // IN: offset in NV of value\n\t    UINT32 size        // IN: size of the value to read\n\t    )\n{\n    // Input type should be valid\n    pAssert(nvOffset + size < NV_MEMORY_SIZE);\n    _plat__NvMemoryRead(nvOffset, size, outBuffer);\n    return;\n}\n\n//*** NvWrite()\n// This function is used to post reserved data for writing to NV memory. Before\n// the TPM completes the operation, the value will be written.\nBOOL NvWrite(UINT32 nvOffset,  // IN: location in NV to receive data\n\t     UINT32 size,      // IN: size of the data to move\n\t     void*  inBuffer   // IN: location containing data to write\n\t     )\n{\n    // Input type should be valid\n    if(nvOffset + size <= NV_MEMORY_SIZE)\n\t{\n\t    // Set the flag that a NV write happened\n\t    SET_NV_UPDATE(UT_NV);\n\t    return _plat__NvMemoryWrite(nvOffset, size, inBuffer);\n\t}\n    return FALSE;\n}\n\n//*** NvUpdatePersistent()\n// This function is used to update a value in the PERSISTENT_DATA structure and\n// commits the value to NV.\nvoid NvUpdatePersistent(\n\t\t\tUINT32 offset,  // IN: location in PERMANENT_DATA to be updated\n\t\t\tUINT32 size,    // IN: size of the value\n\t\t\tvoid*  buffer   // IN: the new data\n\t\t\t)\n{\n    pAssert(offset + size <= sizeof(gp));\n    MemoryCopy(&gp + offset, buffer, size);\n    NvWrite(offset, size, buffer);\n}\n\n//*** NvClearPersistent()\n// This function is used to clear a persistent data entry and commit it to NV\nvoid NvClearPersistent(UINT32 offset,  // IN: the offset in the PERMANENT_DATA\n\t\t       //     structure to be cleared (zeroed)\n\t\t       UINT32 size     // IN: number of bytes to clear\n\t\t       )\n{\n    pAssert(offset + size <= sizeof(gp));\n    MemorySet((&gp) + offset, 0, size);\n    NvWrite(offset, size, (&gp) + offset);\n}\n\n//*** NvReadPersistent()\n// This function reads persistent data to the RAM copy of the 'gp' structure.\nvoid NvReadPersistent(void)\n{\n    NvRead(&gp, NV_PERSISTENT_DATA, sizeof(gp));\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/NV_spt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 -2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes\n#include \"Tpm.h\"\n#include \"NV_spt_fp.h\"\n\n//** Functions\n\n//*** NvReadAccessChecks()\n// Common routine for validating a read\n// Used by TPM2_NV_Read, TPM2_NV_ReadLock and TPM2_PolicyNV\n//  Return Type: TPM_RC\n//      TPM_RC_NV_AUTHORIZATION     autHandle is not allowed to authorize read\n//                                  of the index\n//      TPM_RC_NV_LOCKED            Read locked\n//      TPM_RC_NV_UNINITIALIZED     Try to read an uninitialized index\n//\nTPM_RC\nNvReadAccessChecks(TPM_HANDLE authHandle,  // IN: the handle that provided the\n\t\t   //     authorization\n\t\t   TPM_HANDLE nvHandle,   // IN: the handle of the NV index to be read\n\t\t   TPMA_NV    attributes  // IN: the attributes of 'nvHandle'\n\t\t   )\n{\n    // If data is read locked, returns an error\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, READLOCKED))\n\treturn TPM_RC_NV_LOCKED;\n    // If the authorization was provided by the owner or platform, then check\n    // that the attributes allow the read.  If the authorization handle\n    // is the same as the index, then the checks were made when the authorization\n    // was checked..\n    if(authHandle == TPM_RH_OWNER)\n\t{\n\t    // If Owner provided authorization then ONWERWRITE must be SET\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_NV, OWNERREAD))\n\t\treturn TPM_RC_NV_AUTHORIZATION;\n\t}\n    else if(authHandle == TPM_RH_PLATFORM)\n\t{\n\t    // If Platform provided authorization then PPWRITE must be SET\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_NV, PPREAD))\n\t\treturn TPM_RC_NV_AUTHORIZATION;\n\t}\n    // If neither Owner nor Platform provided authorization, make sure that it was\n    // provided by this index.\n    else if(authHandle != nvHandle)\n\treturn TPM_RC_NV_AUTHORIZATION;\n\n    // If the index has not been written, then the value cannot be read\n    // NOTE: This has to come after other access checks to make sure that\n    // the proper authorization is given to TPM2_NV_ReadLock()\n    if(!IS_ATTRIBUTE(attributes, TPMA_NV, WRITTEN))\n\treturn TPM_RC_NV_UNINITIALIZED;\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** NvWriteAccessChecks()\n// Common routine for validating a write\n// Used by TPM2_NV_Write, TPM2_NV_Increment, TPM2_SetBits, and TPM2_NV_WriteLock\n//  Return Type: TPM_RC\n//      TPM_RC_NV_AUTHORIZATION     Authorization fails\n//      TPM_RC_NV_LOCKED            Write locked\n//\nTPM_RC\nNvWriteAccessChecks(\n\t\t    TPM_HANDLE authHandle,  // IN: the handle that provided the\n\t\t    //     authorization\n\t\t    TPM_HANDLE nvHandle,    // IN: the handle of the NV index to be written\n\t\t    TPMA_NV    attributes   // IN: the attributes of 'nvHandle'\n\t\t    )\n{\n    // If data is write locked, returns an error\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, WRITELOCKED))\n\treturn TPM_RC_NV_LOCKED;\n    // If the authorization was provided by the owner or platform, then check\n    // that the attributes allow the write.  If the authorization handle\n    // is the same as the index, then the checks were made when the authorization\n    // was checked..\n    if(authHandle == TPM_RH_OWNER)\n\t{\n\t    // If Owner provided authorization then ONWERWRITE must be SET\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_NV, OWNERWRITE))\n\t\treturn TPM_RC_NV_AUTHORIZATION;\n\t}\n    else if(authHandle == TPM_RH_PLATFORM)\n\t{\n\t    // If Platform provided authorization then PPWRITE must be SET\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_NV, PPWRITE))\n\t\treturn TPM_RC_NV_AUTHORIZATION;\n\t}\n    // If neither Owner nor Platform provided authorization, make sure that it was\n    // provided by this index.\n    else if(authHandle != nvHandle)\n\treturn TPM_RC_NV_AUTHORIZATION;\n    return TPM_RC_SUCCESS;\n}\n\n//*** NvClearOrderly()\n// This function is used to cause gp.orderlyState to be cleared to the\n// non-orderly state.\nTPM_RC\nNvClearOrderly(void)\n{\n    if(gp.orderlyState < SU_DA_USED_VALUE)\n\tRETURN_IF_NV_IS_NOT_AVAILABLE;\n    g_clearOrderly = TRUE;\n    return TPM_RC_SUCCESS;\n}\n\n//*** NvIsPinPassIndex()\n// Function to check to see if an NV index is a PIN Pass Index\n//  Return Type: BOOL\n//      TRUE(1)         is pin pass\n//      FALSE(0)        is not pin pass\nBOOL NvIsPinPassIndex(TPM_HANDLE index  // IN: Handle to check\n\t\t      )\n{\n    if(HandleGetType(index) == TPM_HT_NV_INDEX)\n\t{\n\t    NV_INDEX* nvIndex = NvGetIndexInfo(index, NULL);\n\n\t    return IsNvPinPassIndex(nvIndex->publicArea.attributes);\n\t}\n    return FALSE;\n}\n\n//*** NvGetIndexName()\n// This function computes the Name of an index\n// The 'name' buffer receives the bytes of the Name and the return value\n// is the number of octets in the Name.\n//\n// This function requires that the NV Index is defined.\nTPM2B_NAME* NvGetIndexName(\n\t\t\t   NV_INDEX* nvIndex,  // IN: the index over which the name is to be\n\t\t\t   //     computed\n\t\t\t   TPM2B_NAME* name    // OUT: name of the index\n\t\t\t   )\n{\n    UINT16           dataSize, digestSize;\n    BYTE             marshalBuffer[sizeof(TPMU_NV_PUBLIC_2)];\n    BYTE*            buffer;\n    INT32            bufferSize = sizeof(marshalBuffer);\n    HASH_STATE       hashState;\n    TPMT_NV_PUBLIC_2 public2;\n\n    // Convert the legacy representation into the tagged-union representation.\n    NvPublic2FromNvPublic(&nvIndex->publicArea, &public2);\n\n    // Marshal the whole public area, but not the TPM_HT selector:\n    // This is safe, because the TPM_HT is the first byte of the handle value,\n    // which is already in every element of TPMT_NV_PUBLIC_2.\n    // This allows the Name of an NV index calculated based on the\n    // TPMT_NV_PUBLIC_2 to be consistent with the Name of the same index if it\n    // has a TPMS_NV_PUBLIC representation.\n    buffer = marshalBuffer;\n    dataSize =\n\tTPMU_NV_PUBLIC_2_Marshal(&public2.nvPublic2,\n\t\t\t\t &buffer,\n\t\t\t\t &bufferSize,\n\t\t\t\t (UINT32)HandleGetType(nvIndex->publicArea.nvIndex));\n\n    // hash public area\n    digestSize = CryptHashStart(&hashState, nvIndex->publicArea.nameAlg);\n    CryptDigestUpdate(&hashState, dataSize, marshalBuffer);\n\n    // Complete digest leaving room for the nameAlg\n    CryptHashEnd(&hashState, digestSize, &name->b.buffer[2]);\n\n    // Include the nameAlg\n    UINT16_TO_BYTE_ARRAY(nvIndex->publicArea.nameAlg, name->b.buffer);\n    name->t.size = digestSize + 2;\n    return name;\n}\n\n// NOTE: This is a lossy conversion: any expanded attributes are lost here.\n// Calling code should return an error to the user, instead of dropping their\n// data, if any of the expanded attributes are SET.\nstatic TPMA_NV LegacyAttributesFromExpanded(TPMA_NV_EXP attributes)\n{\n    UINT64 attributes64;\n    UINT32 attributes32;\n\n    attributes64 = TPMA_NV_EXP_TO_UINT64(attributes);\n    attributes32 = (UINT32)attributes64;\n\n    return UINT32_TO_TPMA_NV(attributes32);\n}\n\nstatic TPMA_NV_EXP ExpandedAttributesFromLegacy(TPMA_NV attributes)\n{\n    UINT32 attributes32;\n    UINT64 attributes64;\n\n    attributes32 = TPMA_NV_TO_UINT32(attributes);\n    attributes64 = (UINT64)attributes32;\n\n    return UINT64_TO_TPMA_NV_EXP(attributes64);\n}\n\n//*** NvPublic2FromNvPublic()\n// This function converts a legacy-form NV public (TPMS_NV_PUBLIC) into the\n// generalized TPMT_NV_PUBLIC_2 tagged-union representation.\nTPM_RC NvPublic2FromNvPublic(\n\t\t\t     TPMS_NV_PUBLIC*   nvPublic,  // IN: the source S-form NV public area\n\t\t\t     TPMT_NV_PUBLIC_2* nvPublic2  // OUT: the T-form NV public area to populate\n\t\t\t     )\n{\n    TPM_HT handleType = HandleGetType(nvPublic->nvIndex);\n\n    switch(handleType)\n\t{\n\t  case TPM_HT_NV_INDEX:\n\t    nvPublic2->nvPublic2.nvIndex = *nvPublic;\n\t    break;\n\t  case TPM_HT_PERMANENT_NV:\n\t    nvPublic2->nvPublic2.permanentNV = *nvPublic;\n\t    break;\n#if EXTERNAL_NV\n\t  case TPM_HT_EXTERNAL_NV:\n\t      {\n\t\t  TPMS_NV_PUBLIC_EXP_ATTR* pub = &nvPublic2->nvPublic2.externalNV;\n\n\t\t  pub->attributes = ExpandedAttributesFromLegacy(nvPublic->attributes);\n\t\t  pub->authPolicy = nvPublic->authPolicy;\n\t\t  pub->dataSize   = nvPublic->dataSize;\n\t\t  pub->nameAlg    = nvPublic->nameAlg;\n\t\t  pub->nvIndex    = nvPublic->nvIndex;\n\t\t  break;\n\t      }\n#endif\n\t  default:\n\t    return TPM_RCS_HANDLE;\n\t}\n\n    nvPublic2->handleType = handleType;\n    return TPM_RC_SUCCESS;\n}\n\n//*** NvPublicFromNvPublic2()\n// This function converts a tagged-union NV public (TPMT_NV_PUBLIC_2) into the\n// legacy TPMS_NV_PUBLIC representation. This is a lossy conversion: any\n// bits in the extended area of the attributes are lost, and the Name cannot be\n// computed based on it.\nTPM_RC NvPublicFromNvPublic2(\n\t\t\t     TPMT_NV_PUBLIC_2* nvPublic2,  // IN: the source T-form NV public area\n\t\t\t     TPMS_NV_PUBLIC*   nvPublic    // OUT: the S-form NV public area to populate\n\t\t\t     )\n{\n    switch(nvPublic2->handleType)\n\t{\n\t  case TPM_HT_NV_INDEX:\n\t    *nvPublic = nvPublic2->nvPublic2.nvIndex;\n\t    break;\n\t  case TPM_HT_PERMANENT_NV:\n\t    *nvPublic = nvPublic2->nvPublic2.permanentNV;\n\t    break;\n#if EXTERNAL_NV\n\t  case TPM_HT_EXTERNAL_NV:\n\t      {\n\t\t  TPMS_NV_PUBLIC_EXP_ATTR* pub = &nvPublic2->nvPublic2.externalNV;\n\n\t\t  nvPublic->attributes = LegacyAttributesFromExpanded(pub->attributes);\n\t\t  nvPublic->authPolicy = pub->authPolicy;\n\t\t  nvPublic->dataSize   = pub->dataSize;\n\t\t  nvPublic->nameAlg    = pub->nameAlg;\n\t\t  break;\n\t      }\n#endif\n\t  default:\n\t    return TPM_RCS_HANDLE;\n\t}\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** NvDefineSpace()\n// This function combines the common functionality of TPM2_NV_DefineSpace and\n// TPM2_NV_DefineSpace2.\nTPM_RC NvDefineSpace(TPMI_RH_PROVISION authHandle,\n\t\t     TPM2B_AUTH*       auth,\n\t\t     TPMS_NV_PUBLIC*   publicInfo,\n\t\t     TPM_RC            blameAuthHandle,\n\t\t     TPM_RC            blameAuth,\n\t\t     TPM_RC            blamePublic)\n{\n    TPMA_NV attributes = publicInfo->attributes;\n    UINT16  nameSize;\n\n    nameSize = CryptHashGetDigestSize(publicInfo->nameAlg);\n\n    // Input Validation\n\n    // Checks not specific to type\n\n    // If the UndefineSpaceSpecial command is not implemented, then can't have\n    // an index that can only be deleted with policy\n#if CC_NV_UndefineSpaceSpecial == NO\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, POLICY_DELETE))\n\treturn TPM_RCS_ATTRIBUTES + blamePublic;\n#endif\n\n    // check that the authPolicy consistent with hash algorithm\n\n    if(publicInfo->authPolicy.t.size != 0\n       && publicInfo->authPolicy.t.size != nameSize)\n\treturn TPM_RCS_SIZE + blamePublic;\n\n    // make sure that the authValue is not too large\n    if(MemoryRemoveTrailingZeros(auth) > CryptHashGetDigestSize(publicInfo->nameAlg))\n\treturn TPM_RCS_SIZE + blameAuth;\n\n    // If an index is being created by the owner and shEnable is\n    // clear, then we would not reach this point because ownerAuth\n    // can't be given when shEnable is CLEAR. However, if phEnable\n    // is SET but phEnableNV is CLEAR, we have to check here\n    if(authHandle == TPM_RH_PLATFORM && gc.phEnableNV == CLEAR)\n\treturn TPM_RCS_HIERARCHY + blameAuthHandle;\n\n    // Attribute checks\n    // Eliminate the unsupported types\n    switch(GET_TPM_NT(attributes))\n\t{\n#if CC_NV_Increment == YES\n\t  case TPM_NT_COUNTER:\n#endif\n#if CC_NV_SetBits == YES\n\t  case TPM_NT_BITS:\n#endif\n#if CC_NV_Extend == YES\n\t  case TPM_NT_EXTEND:\n#endif\n#if CC_PolicySecret == YES && defined TPM_NT_PIN_PASS\n\t  case TPM_NT_PIN_PASS:\n\t  case TPM_NT_PIN_FAIL:\n#endif\n\t  case TPM_NT_ORDINARY:\n\t    break;\n\t  default:\n\t    return TPM_RCS_ATTRIBUTES + blamePublic;\n\t    break;\n\t}\n    // Check that the sizes are OK based on the type\n    switch(GET_TPM_NT(attributes))\n\t{\n\t  case TPM_NT_ORDINARY:\n\t    // Can't exceed the allowed size for the implementation\n\t    if(publicInfo->dataSize > MAX_NV_INDEX_SIZE)\n\t\treturn TPM_RCS_SIZE + blamePublic;\n\t    break;\n\t  case TPM_NT_EXTEND:\n\t    if(publicInfo->dataSize != nameSize)\n\t\treturn TPM_RCS_SIZE + blamePublic;\n\t    break;\n\t  default:\n\t    // Everything else needs a size of 8\n\t    if(publicInfo->dataSize != 8)\n\t\treturn TPM_RCS_SIZE + blamePublic;\n\t    break;\n\t}\n    // Handle other specifics\n    switch(GET_TPM_NT(attributes))\n\t{\n\t  case TPM_NT_COUNTER:\n\t    // Counter can't have TPMA_NV_CLEAR_STCLEAR SET (don't clear counters)\n\t    if(IS_ATTRIBUTE(attributes, TPMA_NV, CLEAR_STCLEAR))\n\t\treturn TPM_RCS_ATTRIBUTES + blamePublic;\n\t    break;\n#ifdef TPM_NT_PIN_FAIL\n\t  case TPM_NT_PIN_FAIL:\n\t    // NV_NO_DA must be SET and AUTHWRITE must be CLEAR\n\t    // NOTE: As with a PIN_PASS index, the authValue of the index is not\n\t    // available until the index is written. If AUTHWRITE is the only way to\n\t    // write then index, it could never be written. Rather than go through\n\t    // all of the other possible ways to write the Index, it is simply\n\t    // prohibited to write the index with the authValue. Other checks\n\t    // below will insure that there seems to be a way to write the index\n\t    // (i.e., with platform authorization , owner authorization,\n\t    // or with policyAuth.)\n\t    // It is not allowed to create a PIN Index that can't be modified.\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_NV, NO_DA))\n\t\treturn TPM_RCS_ATTRIBUTES + blamePublic;\n#endif\n#ifdef TPM_NT_PIN_PASS\n\t  case TPM_NT_PIN_PASS:\n\t    // AUTHWRITE must be CLEAR (see note above to TPM_NT_PIN_FAIL)\n\t    if(IS_ATTRIBUTE(attributes, TPMA_NV, AUTHWRITE)\n\t       || IS_ATTRIBUTE(attributes, TPMA_NV, GLOBALLOCK)\n\t       || IS_ATTRIBUTE(attributes, TPMA_NV, WRITEDEFINE))\n\t\treturn TPM_RCS_ATTRIBUTES + blamePublic;\n#endif  // this comes before break because PIN_FAIL falls through\n\t    break;\n\t  default:\n\t    break;\n\t}\n\n    // Locks may not be SET and written cannot be SET\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, WRITTEN)\n       || IS_ATTRIBUTE(attributes, TPMA_NV, WRITELOCKED)\n       || IS_ATTRIBUTE(attributes, TPMA_NV, READLOCKED))\n\treturn TPM_RCS_ATTRIBUTES + blamePublic;\n\n    // There must be a way to read the index.\n    if(!IS_ATTRIBUTE(attributes, TPMA_NV, OWNERREAD)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, PPREAD)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, AUTHREAD)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, POLICYREAD))\n\treturn TPM_RCS_ATTRIBUTES + blamePublic;\n\n    // There must be a way to write the index\n    if(!IS_ATTRIBUTE(attributes, TPMA_NV, OWNERWRITE)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, PPWRITE)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, AUTHWRITE)\n       && !IS_ATTRIBUTE(attributes, TPMA_NV, POLICYWRITE))\n\treturn TPM_RCS_ATTRIBUTES + blamePublic;\n\n    // An index with TPMA_NV_CLEAR_STCLEAR can't have TPMA_NV_WRITEDEFINE SET\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, CLEAR_STCLEAR)\n       && IS_ATTRIBUTE(attributes, TPMA_NV, WRITEDEFINE))\n\treturn TPM_RCS_ATTRIBUTES + blamePublic;\n\n    // Make sure that the creator of the index can delete the index\n    if((IS_ATTRIBUTE(attributes, TPMA_NV, PLATFORMCREATE)\n\t&& authHandle == TPM_RH_OWNER)\n       || (!IS_ATTRIBUTE(attributes, TPMA_NV, PLATFORMCREATE)\n\t   && authHandle == TPM_RH_PLATFORM))\n\treturn TPM_RCS_ATTRIBUTES + blameAuthHandle;\n\n    // If TPMA_NV_POLICY_DELETE is SET, then the index must be defined by\n    // the platform\n    if(IS_ATTRIBUTE(attributes, TPMA_NV, POLICY_DELETE)\n       && TPM_RH_PLATFORM != authHandle)\n\treturn TPM_RCS_ATTRIBUTES + blamePublic;\n\n    // Make sure that the TPMA_NV_WRITEALL is not set if the index size is larger\n    // than the allowed NV buffer size.\n    if(publicInfo->dataSize > MAX_NV_BUFFER_SIZE\n       && IS_ATTRIBUTE(attributes, TPMA_NV, WRITEALL))\n\treturn TPM_RCS_SIZE + blamePublic;\n\n    // And finally, see if the index is already defined.\n    if(NvIndexIsDefined(publicInfo->nvIndex))\n\treturn TPM_RC_NV_DEFINED;\n\n    // Internal Data Update\n    // define the space.  A TPM_RC_NV_SPACE error may be returned at this point\n    return NvDefineIndex(publicInfo, auth);\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/Object.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tManage the object store of the TPM.    \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the functions that manage the object store of the TPM.\n\n//** Includes and Data Definitions\n#define OBJECT_C\n\n#include \"Tpm.h\"\n#include \"Marshal.h\"\n\n//** Functions\n\n//*** ObjectFlush()\n// This function marks an object slot as available.\n// Since there is no checking of the input parameters, it should be used\n// judiciously.\n// Note: This could be converted to a macro.\nvoid ObjectFlush(OBJECT* object)\n{\n    object->attributes.occupied = CLEAR;\n}\n\n//*** ObjectSetInUse()\n// This access function sets the occupied attribute of an object slot.\nvoid ObjectSetInUse(OBJECT* object)\n{\n    object->attributes.occupied = SET;\n}\n\n//*** ObjectStartup()\n// This function is called at TPM2_Startup() to initialize the object subsystem.\nBOOL ObjectStartup(void)\n{\n    UINT32 i;\n    //\n    // object slots initialization\n    for(i = 0; i < MAX_LOADED_OBJECTS; i++)\n\t{\n\t    //Set the slot to not occupied\n\t    ObjectFlush(&s_objects[i]);\n\t}\n    return TRUE;\n}\n\n//*** ObjectCleanupEvict()\n//\n// In this implementation, a persistent object is moved from NV into an object slot\n// for processing. It is flushed after command execution. This function is called\n// from ExecuteCommand().\nvoid ObjectCleanupEvict(void)\n{\n    UINT32 i;\n    //\n    // This has to be iterated because a command may have two handles\n    // and they may both be persistent.\n    // This could be made to be more efficient so that a search is not needed.\n    for(i = 0; i < MAX_LOADED_OBJECTS; i++)\n\t{\n\t    // If an object is a temporary evict object, flush it from slot\n\t    OBJECT* object = &s_objects[i];\n\t    if(object->attributes.evict == SET)\n\t\tObjectFlush(object);\n\t}\n    return;\n}\n\n//*** IsObjectPresent()\n// This function checks to see if a transient handle references a loaded\n// object.  This routine should not be called if the handle is not a\n// transient handle. The function validates that the handle is in the\n// implementation-dependent allowed in range for loaded transient objects.\n//  Return Type: BOOL\n//      TRUE(1)         handle references a loaded object\n//      FALSE(0)        handle is not an object handle, or it does not\n//                      reference to a loaded object\nBOOL IsObjectPresent(TPMI_DH_OBJECT handle  // IN: handle to be checked\n\t\t     )\n{\n    UINT32 slotIndex = handle - TRANSIENT_FIRST;\n    // Since the handle is just an index into the array that is zero based, any\n    // handle value outsize of the range of:\n    //    TRANSIENT_FIRST -- (TRANSIENT_FIRST + MAX_LOADED_OBJECT - 1)\n    // will now be greater than or equal to MAX_LOADED_OBJECTS\n    if(slotIndex >= MAX_LOADED_OBJECTS)\n\treturn FALSE;\n    // Indicate if the slot is occupied\n    return (s_objects[slotIndex].attributes.occupied == TRUE);\n}\n\n//*** ObjectIsSequence()\n// This function is used to check if the object is a sequence object. This function\n// should not be called if the handle does not reference a loaded object.\n//  Return Type: BOOL\n//      TRUE(1)         object is an HMAC, hash, or event sequence object\n//      FALSE(0)        object is not an HMAC, hash, or event sequence object\nBOOL ObjectIsSequence(OBJECT* object  // IN: handle to be checked\n\t\t      )\n{\n    pAssert(object != NULL);\n    return (object->attributes.hmacSeq == SET || object->attributes.hashSeq == SET\n\t    || object->attributes.eventSeq == SET);\n}\n\n//*** HandleToObject()\n// This function is used to find the object structure associated with a handle.\n//\n// This function requires that 'handle' references a loaded object or a permanent\n// handle.\nOBJECT* HandleToObject(TPMI_DH_OBJECT handle  // IN: handle of the object\n\t\t       )\n{\n    UINT32 index;\n    //\n    // Return NULL if the handle references a permanent handle because there is no\n    // associated OBJECT.\n    if(HandleGetType(handle) == TPM_HT_PERMANENT)\n\treturn NULL;\n    // In this implementation, the handle is determined by the slot occupied by the\n    // object.\n    index = handle - TRANSIENT_FIRST;\n    pAssert(index < MAX_LOADED_OBJECTS);\n    pAssert(s_objects[index].attributes.occupied);\n    return &s_objects[index];\n}\n\n//*** GetQualifiedName()\n// This function returns the Qualified Name of the object. In this implementation,\n// the Qualified Name is computed when the object is loaded and is saved in the\n// internal representation of the object. The alternative would be to retain the\n// Name of the parent and compute the QN when needed. This would take the same\n// amount of space so it is not recommended that the alternate be used.\n//\n// This function requires that 'handle' references a loaded object.\nvoid GetQualifiedName(TPMI_DH_OBJECT handle,     // IN: handle of the object\n\t\t      TPM2B_NAME* qualifiedName  // OUT: qualified name of the object\n\t\t      )\n{\n    OBJECT* object;\n    //\n    switch(HandleGetType(handle))\n\t{\n\t  case TPM_HT_PERMANENT:\n\t    qualifiedName->t.size = sizeof(TPM_HANDLE);\n\t    UINT32_TO_BYTE_ARRAY(handle, qualifiedName->t.name);\n\t    break;\n\t  case TPM_HT_TRANSIENT:\n\t    object = HandleToObject(handle);\n\t    if(object == NULL || object->publicArea.nameAlg == TPM_ALG_NULL)\n\t\tqualifiedName->t.size = 0;\n\t    else\n\t\t// Copy the name\n\t\t*qualifiedName = object->qualifiedName;\n\t    break;\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t}\n    return;\n}\n\n//*** GetHierarchy()\n// This function returns the handle of the hierarchy to which a handle belongs.\n//\n// This function requires that 'handle' references a loaded object.\nTPMI_RH_HIERARCHY\nGetHierarchy(TPMI_DH_OBJECT handle  // IN :object handle\n\t     )\n{\n    return HandleToObject(handle)->hierarchy;\n}\n\n//*** FindEmptyObjectSlot()\n// This function finds an open object slot, if any. It will clear the attributes\n// but will not set the occupied attribute. This is so that a slot may be used\n// and discarded if everything does not go as planned.\n//  Return Type: OBJECT *\n//      NULL        no open slot found\n//      != NULL     pointer to available slot\nOBJECT* FindEmptyObjectSlot(TPMI_DH_OBJECT* handle  // OUT: (optional)\n\t\t\t    )\n{\n    UINT32  i;\n    OBJECT* object;\n    //\n    for(i = 0; i < MAX_LOADED_OBJECTS; i++)\n\t{\n\t    object = &s_objects[i];\n\t    if(object->attributes.occupied == CLEAR)\n\t\t{\n\t\t    if(handle)\n\t\t\t*handle = i + TRANSIENT_FIRST;\n\t\t    // Initialize the object attributes\n\t\t    MemorySet(&object->attributes, 0, sizeof(OBJECT_ATTRIBUTES));\n\t\t    object->hierarchy = TPM_RH_NULL;\n\t\t    return object;\n\t\t}\n\t}\n    return NULL;\n}\n\n//*** ObjectAllocateSlot()\n// This function is used to allocate a slot in internal object array.\nOBJECT* ObjectAllocateSlot(TPMI_DH_OBJECT* handle  // OUT: handle of allocated object\n\t\t\t   )\n{\n    OBJECT* object = FindEmptyObjectSlot(handle);\n    //\n    if(object != NULL)\n\t{\n\t    // if found, mark as occupied\n\t    ObjectSetInUse(object);\n\t}\n    return object;\n}\n\n//*** ObjectSetLoadedAttributes()\n// This function sets the internal attributes for a loaded object. It is called to\n// finalize the OBJECT attributes (not the TPMA_OBJECT attributes) for a loaded\n// object.\nvoid ObjectSetLoadedAttributes(OBJECT* object,  // IN: object attributes to finalize\n\t\t\t       TPM_HANDLE parentHandle  // IN: the parent handle\n\t\t\t       )\n{\n    OBJECT*     parent           = HandleToObject(parentHandle);\n    TPMA_OBJECT objectAttributes = object->publicArea.objectAttributes;\n    //\n    // Copy the stClear attribute from the public area. This could be overwritten\n    // if the parent has stClear SET\n    object->attributes.stClear = IS_ATTRIBUTE(objectAttributes, TPMA_OBJECT, stClear);\n    // If parent handle is a permanent handle, it is a primary (unless it is NULL\n    if(parent == NULL)\n\t{\n\t    object->hierarchy          = parentHandle;\n\t    object->attributes.primary = SET;\n\t    switch(HierarchyNormalizeHandle(object->hierarchy))\n\t\t{\n\t\t  case TPM_RH_ENDORSEMENT:\n\t\t    object->attributes.epsHierarchy = SET;\n\t\t    break;\n\t\t  case TPM_RH_OWNER:\n\t\t    object->attributes.spsHierarchy = SET;\n\t\t    break;\n\t\t  case TPM_RH_PLATFORM:\n\t\t    object->attributes.ppsHierarchy = SET;\n\t\t    break;\n\t\t  default:\n\t\t    // Treat the temporary attribute as a hierarchy\n\t\t    object->attributes.temporary = SET;\n\t\t    object->attributes.primary   = CLEAR;\n\t\t    break;\n\t\t}\n\t}\n    else\n\t{\n\t    // is this a stClear object\n\t    object->attributes.stClear =\n\t\t(IS_ATTRIBUTE(objectAttributes, TPMA_OBJECT, stClear)\n\t\t || (parent->attributes.stClear == SET));\n\t    object->attributes.epsHierarchy = parent->attributes.epsHierarchy;\n\t    object->attributes.spsHierarchy = parent->attributes.spsHierarchy;\n\t    object->attributes.ppsHierarchy = parent->attributes.ppsHierarchy;\n\t    // An object is temporary if its parent is temporary or if the object\n\t    // is external\n\t    object->attributes.temporary = parent->attributes.temporary\n\t\t\t\t\t   || object->attributes.external;\n\t    object->hierarchy = parent->hierarchy;\n\t}\n    // If this is an external object, set the QN == name but don't SET other\n    // key properties ('parent' or 'derived')\n    if(object->attributes.external)\n\tobject->qualifiedName = object->name;\n    else\n\t{\n\t    // check attributes for different types of parents\n\t    if(IS_ATTRIBUTE(objectAttributes, TPMA_OBJECT, restricted)\n\t       && !object->attributes.publicOnly\n\t       && IS_ATTRIBUTE(objectAttributes, TPMA_OBJECT, decrypt)\n\t       && object->publicArea.nameAlg != TPM_ALG_NULL)\n\t\t{\n\t\t    // This is a parent. If it is not a KEYEDHASH, it is an ordinary parent.\n\t\t    // Otherwise, it is a derivation parent.\n\t\t    if(object->publicArea.type == TPM_ALG_KEYEDHASH)\n\t\t\tobject->attributes.derivation = SET;\n\t\t    else\n\t\t\tobject->attributes.isParent = SET;\n\t\t}\n\t    ComputeQualifiedName(parentHandle,\n\t\t\t\t object->publicArea.nameAlg,\n\t\t\t\t &object->name,\n\t\t\t\t &object->qualifiedName);\n\t}\n    // Set slot occupied\n    ObjectSetInUse(object);\n    return;\n}\n\n//*** ObjectLoad()\n// Common function to load a non-primary object (i.e., either an Ordinary Object,\n// or an External Object). A loaded object has its public area validated\n// (unless its 'nameAlg' is TPM_ALG_NULL). If a sensitive part is loaded, it is\n// verified to be correct and if both public and sensitive parts are loaded, then\n// the cryptographic binding between the objects is validated. This function does\n// not cause the allocated slot to be marked as in use.\nTPM_RC\nObjectLoad(OBJECT* object,           // IN: pointer to object slot\n\t   //     object\n\t   OBJECT*      parent,      // IN: (optional) the parent object\n\t   TPMT_PUBLIC* publicArea,  // IN: public area to be installed in the object\n\t   TPMT_SENSITIVE* sensitive,  // IN: (optional) sensitive area to be\n\t   //      installed in the object\n\t   TPM_RC blamePublic,         // IN: parameter number to associate with the\n\t   //     publicArea errors\n\t   TPM_RC blameSensitive,      // IN: parameter number to associate with the\n\t   //     sensitive area errors\n\t   TPM2B_NAME* name            // IN: (optional)\n\t   )\n{\n    TPM_RC result = TPM_RC_SUCCESS;\n    //\n    // Do validations of public area object descriptions\n    pAssert(publicArea != NULL);\n\n    // Is this public only or a no-name object?\n    if(sensitive == NULL || publicArea->nameAlg == TPM_ALG_NULL)\n\t{\n\t    // Need to have schemes checked so that we do the right thing with the\n\t    // public key.\n\t    result = SchemeChecks(NULL, publicArea);\n\t}\n    else\n\t{\n\t    // For any sensitive area, make sure that the seedSize is no larger than the\n\t    // digest size of nameAlg\n\t    if(sensitive->seedValue.t.size > CryptHashGetDigestSize(publicArea->nameAlg))\n\t\treturn TPM_RCS_KEY_SIZE + blameSensitive;\n\t    // Check attributes and schemes for consistency\n\t    // For the purposes of attributes validation on this non-primary object,\n\t    // either:\n\t    // - parent is not NULL and therefore its attributes are checked for\n\t    //   consistency with the parent, OR\n\t    // - parent is NULL but the object is not a primary object, either\n\t    result =\n\t\tPublicAttributesValidation(parent, /*primaryHierarchy = */ 0, publicArea);\n\t}\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, blamePublic);\n\n    // Sensitive area and binding checks\n\n    // On load, check nothing if the parent is fixedTPM.\n    // If the parent is fixedTPM, then this TPM produced this key blob (either\n    // by import, or creation). If the parent is not fixedTPM, then an external\n    // copy of the parent's protection seed might have been used to create the\n    // blob, and we have to validate it.\n    // NOTE: By the time a TPMT_SENSITIVE has been decrypted and passed to this\n    // function, it has been validated against the corresponding TPMT_PUBLIC.\n    // For more information about this check, see PrivateToSensitive.\n    if((parent == NULL)\n       || ((parent != NULL)\n\t   && !IS_ATTRIBUTE(\n\t\t\t    parent->publicArea.objectAttributes, TPMA_OBJECT, fixedTPM)))\n\t{\n\t    // Do the cryptographic key validation\n\t    result =\n\t\tCryptValidateKeys(publicArea, sensitive, blamePublic, blameSensitive);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t}\n#if ALG_RSA\n    // If this is an RSA key, then expand the private exponent.\n    // Note: ObjectLoad() is only called by TPM2_Import() if the parent is fixedTPM.\n    // For any key that does not have a fixedTPM parent, the exponent is computed\n    // whenever it is loaded\n    if((publicArea->type == TPM_ALG_RSA) && (sensitive != NULL))\n\t{\n\t    result = CryptRsaLoadPrivateExponent(publicArea, sensitive);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t}\n#endif  // ALG_RSA\n    // See if there is an object to populate\n    if((result == TPM_RC_SUCCESS) && (object != NULL))\n\t{\n\t    // Initialize public\n\t    object->publicArea = *publicArea;\n\t    // Copy sensitive if there is one\n\t    if(sensitive == NULL)\n\t\tobject->attributes.publicOnly = SET;\n\t    else\n\t\tobject->sensitive = *sensitive;\n\t    // Set the name, if one was provided\n\t    if(name != NULL)\n\t\tobject->name = *name;\n\t    else\n\t\tobject->name.t.size = 0;\n\t}\n    return result;\n}\n\n//*** AllocateSequenceSlot()\n// This function allocates a sequence slot and initializes the parts that\n// are used by the normal objects so that a sequence object is not inadvertently\n// used for an operation that is not appropriate for a sequence.\n//\nstatic HASH_OBJECT* AllocateSequenceSlot(\n\t\t\t\t\t TPM_HANDLE* newHandle,  // OUT: receives the allocated handle\n\t\t\t\t\t TPM2B_AUTH* auth        // IN: the authValue for the slot\n\t\t\t\t\t )\n{\n    HASH_OBJECT* object = (HASH_OBJECT*)ObjectAllocateSlot(newHandle);\n    //\n    // Validate that the proper location of the hash state data relative to the\n    // object state data. It would be good if this could have been done at compile\n    // time but it can't so do it in something that can be removed after debug.\n    MUST_BE(offsetof(HASH_OBJECT, auth) == offsetof(OBJECT, publicArea.authPolicy));\n\n    if(object != NULL)\n\t{\n\n\t    // Set the common values that a sequence object shares with an ordinary object\n\t    // First, clear all attributes\n\t    MemorySet(&object->objectAttributes, 0, sizeof(TPMA_OBJECT));\n\n\t    // The type is TPM_ALG_NULL\n\t    object->type = TPM_ALG_NULL;\n\n\t    // This has no name algorithm and the name is the Empty Buffer\n\t    object->nameAlg = TPM_ALG_NULL;\n\n\t    // A sequence object is considered to be in the NULL hierarchy so it should\n\t    // be marked as temporary so that it can't be persisted\n\t    object->attributes.temporary = SET;\n\n\t    // A sequence object is DA exempt.\n\t    SET_ATTRIBUTE(object->objectAttributes, TPMA_OBJECT, noDA);\n\n\t    // Copy the authorization value\n\t    if(auth != NULL)\n\t\tobject->auth = *auth;\n\t    else\n\t\tobject->auth.t.size = 0;\n\t}\n    return object;\n}\n\n#if CC_HMAC_Start || CC_MAC_Start\n//*** ObjectCreateHMACSequence()\n// This function creates an internal HMAC sequence object.\n//  Return Type: TPM_RC\n//      TPM_RC_OBJECT_MEMORY        if there is no free slot for an object\nTPM_RC\nObjectCreateHMACSequence(\n\t\t\t TPMI_ALG_HASH   hashAlg,    // IN: hash algorithm\n\t\t\t OBJECT*         keyObject,  // IN: the object containing the HMAC key\n\t\t\t TPM2B_AUTH*     auth,       // IN: authValue\n\t\t\t TPMI_DH_OBJECT* newHandle   // OUT: HMAC sequence object handle\n\t\t\t )\n{\n    HASH_OBJECT* hmacObject;\n    //\n    // Try to allocate a slot for new object\n    hmacObject = AllocateSequenceSlot(newHandle, auth);\n\n    if(hmacObject == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    // Set HMAC sequence bit\n    hmacObject->attributes.hmacSeq = SET;\n\n#  if !SMAC_IMPLEMENTED\n    if(CryptHmacStart(&hmacObject->state.hmacState,\n\t\t      hashAlg,\n\t\t      keyObject->sensitive.sensitive.bits.b.size,\n\t\t      keyObject->sensitive.sensitive.bits.b.buffer)\n       == 0)\n#  else\n\tif(CryptMacStart(&hmacObject->state.hmacState,\n\t\t\t &keyObject->publicArea.parameters,\n\t\t\t hashAlg,\n\t\t\t &keyObject->sensitive.sensitive.any.b)\n\t   == 0)\n#  endif  // SMAC_IMPLEMENTED\n\t    return TPM_RC_FAILURE;\n    return TPM_RC_SUCCESS;\n}\n#endif\n\n//*** ObjectCreateHashSequence()\n// This function creates a hash sequence object.\n//  Return Type: TPM_RC\n//      TPM_RC_OBJECT_MEMORY        if there is no free slot for an object\nTPM_RC\nObjectCreateHashSequence(TPMI_ALG_HASH   hashAlg,   // IN: hash algorithm\n\t\t\t TPM2B_AUTH*     auth,      // IN: authValue\n\t\t\t TPMI_DH_OBJECT* newHandle  // OUT: sequence object handle\n\t\t\t )\n{\n    HASH_OBJECT* hashObject = AllocateSequenceSlot(newHandle, auth);\n    //\n    // See if slot allocated\n    if(hashObject == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    // Set hash sequence bit\n    hashObject->attributes.hashSeq = SET;\n\n    // Start hash for hash sequence\n    CryptHashStart(&hashObject->state.hashState[0], hashAlg);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** ObjectCreateEventSequence()\n// This function creates an event sequence object.\n//  Return Type: TPM_RC\n//      TPM_RC_OBJECT_MEMORY        if there is no free slot for an object\nTPM_RC\nObjectCreateEventSequence(TPM2B_AUTH*     auth,      // IN: authValue\n\t\t\t  TPMI_DH_OBJECT* newHandle  // OUT: sequence object handle\n\t\t\t  )\n{\n    HASH_OBJECT* hashObject = AllocateSequenceSlot(newHandle, auth);\n    UINT32       count;\n    TPM_ALG_ID   hash;\n    //\n    // See if slot allocated\n    if(hashObject == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    // Set the event sequence attribute\n    hashObject->attributes.eventSeq = SET;\n\n    // Initialize hash states for each implemented PCR algorithms\n    for(count = 0; (hash = CryptHashGetAlgByIndex(count)) != TPM_ALG_NULL; count++)\n\tCryptHashStart(&hashObject->state.hashState[count], hash);\n    return TPM_RC_SUCCESS;\n}\n\n//*** ObjectTerminateEvent()\n// This function is called to close out the event sequence and clean up the hash\n// context states.\nvoid ObjectTerminateEvent(void)\n{\n    HASH_OBJECT* hashObject;\n    int          count;\n    BYTE         buffer[MAX_DIGEST_SIZE];\n    //\n    hashObject = (HASH_OBJECT*)HandleToObject(g_DRTMHandle);\n\n    // Don't assume that this is a proper sequence object\n    if(hashObject->attributes.eventSeq)\n\t{\n\t    // If it is, close any open hash contexts. This is done in case\n\t    // the cryptographic implementation has some context values that need to be\n\t    // cleaned up (hygiene).\n\t    //\n\t    for(count = 0; CryptHashGetAlgByIndex(count) != TPM_ALG_NULL; count++)\n\t\t{\n\t\t    CryptHashEnd(&hashObject->state.hashState[count], 0, buffer);\n\t\t}\n\t    // Flush sequence object\n\t    FlushObject(g_DRTMHandle);\n\t}\n    g_DRTMHandle = TPM_RH_UNASSIGNED;\n}\n\n//*** ObjectContextLoad()\n// This function loads an object from a saved object context.\n//  Return Type: OBJECT *\n//      NULL        if there is no free slot for an object\n//      != NULL     points to the loaded object\nOBJECT* ObjectContextLoad(\n\t\t\t  ANY_OBJECT_BUFFER* object,  // IN: pointer to object structure in saved\n\t\t\t  //     context\n\t\t\t  TPMI_DH_OBJECT* handle      // OUT: object handle\n\t\t\t  )\n{\n    OBJECT* newObject = ObjectAllocateSlot(handle);\n    //\n    // Try to allocate a slot for new object\n    if(newObject != NULL)\n\t{\n\t    // Copy the first part of the object\n\t    MemoryCopy(newObject, object, offsetof(HASH_OBJECT, state));\n\t    // See if this is a sequence object\n\t    if(ObjectIsSequence(newObject))\n\t\t{\n\t\t    // If this is a sequence object, import the data\n\t\t    SequenceDataImport((HASH_OBJECT*)newObject, (HASH_OBJECT_BUFFER*)object);\n\t\t}\n\t    else\n\t\t{\n\t\t    // Copy input object data to internal structure\n\t\t    MemoryCopy(newObject, object, sizeof(OBJECT));\n\t\t}\n\t}\n    return newObject;\n}\n\n//*** FlushObject()\n// This function frees an object slot.\n//\n// This function requires that the object is loaded.\nvoid FlushObject(TPMI_DH_OBJECT handle  // IN: handle to be freed\n\t\t )\n{\n    UINT32 index = handle - TRANSIENT_FIRST;\n    //\n    pAssert(index < MAX_LOADED_OBJECTS);\n    // Clear all the object attributes\n    MemorySet((BYTE*)&(s_objects[index].attributes), 0, sizeof(OBJECT_ATTRIBUTES));\n    return;\n}\n\n//*** ObjectFlushHierarchy()\n// This function is called to flush all the loaded transient objects associated\n// with a hierarchy when the hierarchy is disabled.\nvoid ObjectFlushHierarchy(TPMI_RH_HIERARCHY hierarchy  // IN: hierarchy to be flush\n\t\t\t  )\n{\n    UINT16 i;\n    //\n    // iterate object slots\n    for(i = 0; i < MAX_LOADED_OBJECTS; i++)\n\t{\n\t    if(s_objects[i].attributes.occupied)  // If found an occupied slot\n\t\t{\n\t\t    switch(hierarchy)\n\t\t\t{\n\t\t\t  case TPM_RH_PLATFORM:\n\t\t\t    if(s_objects[i].attributes.ppsHierarchy == SET)\n\t\t\t\ts_objects[i].attributes.occupied = FALSE;\n\t\t\t    break;\n\t\t\t  case TPM_RH_OWNER:\n\t\t\t    if(s_objects[i].attributes.spsHierarchy == SET)\n\t\t\t\ts_objects[i].attributes.occupied = FALSE;\n\t\t\t    break;\n\t\t\t  case TPM_RH_ENDORSEMENT:\n\t\t\t    if(s_objects[i].attributes.epsHierarchy == SET)\n\t\t\t\ts_objects[i].attributes.occupied = FALSE;\n\t\t\t    break;\n\t\t\t  default:\n\t\t\t    FAIL(FATAL_ERROR_INTERNAL);\n\t\t\t    break;\n\t\t\t}\n\t\t}\n\t}\n\n    return;\n}\n\n//*** ObjectLoadEvict()\n// This function loads a persistent object into a transient object slot.\n//\n// This function requires that 'handle' is associated with a persistent object.\n//  Return Type: TPM_RC\n//      TPM_RC_HANDLE               the persistent object does not exist\n//                                  or the associated hierarchy is disabled.\n//      TPM_RC_OBJECT_MEMORY        no object slot\nTPM_RC\nObjectLoadEvict(TPM_HANDLE* handle,  // IN:OUT: evict object handle.  If success, it\n\t\t// will be replace by the loaded object handle\n\t\tCOMMAND_INDEX commandIndex  // IN: the command being processed\n\t\t)\n{\n    TPM_RC     result;\n    TPM_HANDLE evictHandle = *handle;  // Save the evict handle\n    OBJECT*    object;\n    //\n    // If this is an index that references a persistent object created by\n    // the platform, then return TPM_RH_HANDLE if the phEnable is FALSE\n    if(*handle >= PLATFORM_PERSISTENT)\n\t{\n\t    // belongs to platform\n\t    if(g_phEnable == CLEAR)\n\t\treturn TPM_RC_HANDLE;\n\t}\n    // belongs to owner\n    else if(gc.shEnable == CLEAR)\n\treturn TPM_RC_HANDLE;\n    // Try to allocate a slot for an object\n    object = ObjectAllocateSlot(handle);\n    if(object == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    // Copy persistent object to transient object slot.  A TPM_RC_HANDLE\n    // may be returned at this point. This will mark the slot as containing\n    // a transient object so that it will be flushed at the end of the\n    // command\n    result = NvGetEvictObject(evictHandle, object);\n\n    // Bail out if this failed\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // check the object to see if it is in the endorsement hierarchy\n    // if it is and this is not a TPM2_EvictControl() command, indicate\n    // that the hierarchy is disabled.\n    // If the associated hierarchy is disabled, make it look like the\n    // handle is not defined\n    if(HierarchyNormalizeHandle(object->hierarchy) == TPM_RH_ENDORSEMENT\n       && gc.ehEnable == CLEAR && GetCommandCode(commandIndex) != TPM_CC_EvictControl)\n\treturn TPM_RC_HANDLE;\n\n    return result;\n}\n\n//*** ObjectComputeName()\n// This does the name computation from a public area (can be marshaled or not).\nTPM2B_NAME* ObjectComputeName(UINT32     size,  // IN: the size of the area to digest\n\t\t\t      BYTE*      publicArea,  // IN: the public area to digest\n\t\t\t      TPM_ALG_ID nameAlg,     // IN: the hash algorithm to use\n\t\t\t      TPM2B_NAME* name        // OUT: Computed name\n\t\t\t      )\n{\n    // Hash the publicArea into the name buffer leaving room for the nameAlg\n    name->t.size = CryptHashBlock(\n\t\t\t\t  nameAlg, size, publicArea, sizeof(name->t.name) - 2, &name->t.name[2]);\n    // set the nameAlg\n    UINT16_TO_BYTE_ARRAY(nameAlg, name->t.name);\n    name->t.size += 2;\n    return name;\n}\n\n//*** PublicMarshalAndComputeName()\n// This function computes the Name of an object from its public area.\nTPM2B_NAME* PublicMarshalAndComputeName(\n\t\t\t\t\tTPMT_PUBLIC* publicArea,  // IN: public area of an object\n\t\t\t\t\tTPM2B_NAME*  name         // OUT: name of the object\n\t\t\t\t\t)\n{\n    // Will marshal a public area into a template. This is because the internal\n    // format for a TPM2B_PUBLIC is a structure and not a simple BYTE buffer.\n    TPM2B_TEMPLATE marshaled;  // this is big enough to hold a\n    //  marshaled TPMT_PUBLIC\n    BYTE* buffer = (BYTE*)&marshaled.t.buffer;\n    //\n    // if the nameAlg is NULL then there is no name.\n    if(publicArea->nameAlg == TPM_ALG_NULL)\n\tname->t.size = 0;\n    else\n\t{\n\t    // Marshal the public area into its canonical form\n\t    marshaled.t.size = TPMT_PUBLIC_Marshal(publicArea, &buffer, NULL);\n\t    // and compute the name\n\t    ObjectComputeName(\n\t\t\t      marshaled.t.size, marshaled.t.buffer, publicArea->nameAlg, name);\n\t}\n    return name;\n}\n\n//*** ComputeQualifiedName()\n// This function computes the qualified name of an object.\nvoid ComputeQualifiedName(\n\t\t\t  TPM_HANDLE  parentHandle,  // IN: parent's handle\n\t\t\t  TPM_ALG_ID  nameAlg,       // IN: name hash\n\t\t\t  TPM2B_NAME* name,          // IN: name of the object\n\t\t\t  TPM2B_NAME* qualifiedName  // OUT: qualified name of the object\n\t\t\t  )\n{\n    HASH_STATE hashState;  // hash state\n    TPM2B_NAME parentName;\n    //\n    if(parentHandle == TPM_RH_UNASSIGNED)\n\t{\n\t    MemoryCopy2B(&qualifiedName->b, &name->b, sizeof(qualifiedName->t.name));\n\t    *qualifiedName = *name;\n\t}\n    else\n\t{\n\t    GetQualifiedName(parentHandle, &parentName);\n\n\t    //      QN_A = hash_A (QN of parent || NAME_A)\n\n\t    // Start hash\n\t    qualifiedName->t.size = CryptHashStart(&hashState, nameAlg);\n\n\t    // Add parent's qualified name\n\t    CryptDigestUpdate2B(&hashState, &parentName.b);\n\n\t    // Add self name\n\t    CryptDigestUpdate2B(&hashState, &name->b);\n\n\t    // Complete hash leaving room for the name algorithm\n\t    CryptHashEnd(&hashState, qualifiedName->t.size, &qualifiedName->t.name[2]);\n\t    UINT16_TO_BYTE_ARRAY(nameAlg, qualifiedName->t.name);\n\t    qualifiedName->t.size += 2;\n\t}\n    return;\n}\n\n//*** ObjectIsStorage()\n// This function determines if an object has the attributes associated\n// with a parent. A parent is an asymmetric or symmetric block cipher key\n// that has its 'restricted' and 'decrypt' attributes SET, and 'sign' CLEAR.\n//  Return Type: BOOL\n//      TRUE(1)         object is a storage key\n//      FALSE(0)        object is not a storage key\nBOOL ObjectIsStorage(TPMI_DH_OBJECT handle  // IN: object handle\n\t\t     )\n{\n    OBJECT*      object     = HandleToObject(handle);\n    TPMT_PUBLIC* publicArea = ((object != NULL) ? &object->publicArea : NULL);\n    //\n    return (publicArea != NULL\n\t    && IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, restricted)\n\t    && IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, decrypt)\n\t    && !IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sign)\n\t    && (object->publicArea.type == TPM_ALG_RSA\n\t\t|| object->publicArea.type == TPM_ALG_ECC));\n}\n\n//*** ObjectCapGetLoaded()\n// This function returns a list of handles of loaded object, starting from\n// 'handle'. 'Handle' must be in the range of valid transient object handles,\n// but does not have to be the handle of a loaded transient object.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles available\n//      NO          all the available handles has been returned\nTPMI_YES_NO\nObjectCapGetLoaded(TPMI_DH_OBJECT handle,     // IN: start handle\n\t\t   UINT32         count,      // IN: count of returned handles\n\t\t   TPML_HANDLE*   handleList  // OUT: list of handle\n\t\t   )\n{\n    TPMI_YES_NO more = NO;\n    UINT32      i;\n    //\n    pAssert(HandleGetType(handle) == TPM_HT_TRANSIENT);\n\n    // Initialize output handle list\n    handleList->count = 0;\n\n    // The maximum count of handles we may return is MAX_CAP_HANDLES\n    if(count > MAX_CAP_HANDLES)\n\tcount = MAX_CAP_HANDLES;\n\n    // Iterate object slots to get loaded object handles\n    for(i = handle - TRANSIENT_FIRST; i < MAX_LOADED_OBJECTS; i++)\n\t{\n\t    if(s_objects[i].attributes.occupied == TRUE)\n\t\t{\n\t\t    // A valid transient object can not be the copy of a persistent object\n\t\t    pAssert(s_objects[i].attributes.evict == CLEAR);\n\n\t\t    if(handleList->count < count)\n\t\t\t{\n\t\t\t    // If we have not filled up the return list, add this object\n\t\t\t    // handle to it\n\t\t\t    handleList->handle[handleList->count] = i + TRANSIENT_FIRST;\n\t\t\t    handleList->count++;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // If the return list is full but we still have loaded object\n\t\t\t    // available, report this and stop iterating\n\t\t\t    more = YES;\n\t\t\t    break;\n\t\t\t}\n\t\t}\n\t}\n\n    return more;\n}\n\n//*** ObjectCapGetOneLoaded()\n// This function returns whether a handle is loaded.\nBOOL ObjectCapGetOneLoaded(TPMI_DH_OBJECT handle)  // IN: handle\n{\n    UINT32 i;\n\n    pAssert(HandleGetType(handle) == TPM_HT_TRANSIENT);\n\n    // Iterate object slots to get loaded object handles\n    for(i = handle - TRANSIENT_FIRST; i < MAX_LOADED_OBJECTS; i++)\n\t{\n\t    if(s_objects[i].attributes.occupied == TRUE)\n\t\t{\n\t\t    // A valid transient object can not be the copy of a persistent object\n\t\t    pAssert(s_objects[i].attributes.evict == CLEAR);\n\n\t\t    return TRUE;\n\t\t}\n\t}\n\n    return FALSE;\n}\n\n//*** ObjectCapGetTransientAvail()\n// This function returns an estimate of the number of additional transient\n// objects that could be loaded into the TPM.\nUINT32\nObjectCapGetTransientAvail(void)\n{\n    UINT32 i;\n    UINT32 num = 0;\n    //\n    // Iterate object slot to get the number of unoccupied slots\n    for(i = 0; i < MAX_LOADED_OBJECTS; i++)\n\t{\n\t    if(s_objects[i].attributes.occupied == FALSE)\n\t\tnum++;\n\t}\n\n    return num;\n}\n\n//*** ObjectGetPublicAttributes()\n// Returns the attributes associated with an object handles.\nTPMA_OBJECT\nObjectGetPublicAttributes(TPM_HANDLE handle)\n{\n    return HandleToObject(handle)->publicArea.objectAttributes;\n}\n\nOBJECT_ATTRIBUTES\nObjectGetProperties(TPM_HANDLE handle)\n{\n    return HandleToObject(handle)->attributes;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/ObjectCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Object Commands\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\nextern int verbose;\n\n#include \"Tpm.h\"\n#include \"Object_spt_fp.h\"\n#include \"Create_fp.h\"\n\n#if CC_Create  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// Create a regular object\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES       'sensitiveDataOrigin' is CLEAR when 'sensitive.data'\n//                              is an Empty Buffer, or is SET when 'sensitive.data' is\n//                              not empty;\n//                              'fixedTPM', 'fixedParent', or 'encryptedDuplication'\n//                              attributes are inconsistent between themselves or with\n//                              those of the parent object;\n//                              inconsistent 'restricted', 'decrypt' and 'sign'\n//                              attributes;\n//                              attempt to inject sensitive data for an asymmetric\n//                              key;\n//      TPM_RC_HASH             non-duplicable storage key and its parent have\n//                              different name algorithm\n//      TPM_RC_KDF              incorrect KDF specified for decrypting keyed hash\n//                              object\n//      TPM_RC_KEY              invalid key size values in an asymmetric key public\n//                              area or a provided symmetric key has a value that is\n//                              not allowed\n//      TPM_RC_KEY_SIZE         key size in public area for symmetric key differs from\n//                              the size in the sensitive creation area; may also be\n//                              returned if the TPM does not allow the key size to be\n//                              used for a Storage Key\n//      TPM_RC_OBJECT_MEMORY    a free slot is not available as scratch memory for\n//                              object creation\n//      TPM_RC_RANGE            the exponent value of an RSA key is not supported.\n//      TPM_RC_SCHEME           inconsistent attributes 'decrypt', 'sign', or\n//                              'restricted' and key's scheme ID; or hash algorithm is\n//                              inconsistent with the scheme ID for keyed hash object\n//      TPM_RC_SIZE             size of public authPolicy or sensitive authValue does\n//                              not match digest size of the name algorithm\n//                              sensitive data size for the keyed hash object is\n//                              larger than is allowed for the scheme\n//      TPM_RC_SYMMETRIC        a storage key with no symmetric algorithm specified;\n//                              or non-storage key with symmetric algorithm different\n//                              from TPM_ALG_NULL\n//      TPM_RC_TYPE             unknown object type;\n//                              'parentHandle' does not reference a restricted\n//                              decryption key in the storage hierarchy with both\n//                              public and sensitive portion loaded\n//      TPM_RC_VALUE            exponent is not prime or could not find a prime using\n//                              the provided parameters for an RSA key;\n//                              unsupported name algorithm for an ECC key\n//      TPM_RC_OBJECT_MEMORY    there is no free slot for the object\nTPM_RC\nTPM2_Create(Create_In*  in,  // IN: input parameter list\n\t    Create_Out* out  // OUT: output parameter list\n\t    )\n{\n    TPM_RC       result = TPM_RC_SUCCESS;\n    OBJECT*      parentObject;\n    OBJECT*      newObject;\n    TPMT_PUBLIC* publicArea;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Create: parentHandle %08x\\n\", in->parentHandle);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n    parentObject = HandleToObject(in->parentHandle);\n    pAssert(parentObject != NULL);\n\n    // Does parent have the proper attributes?\n    if(!ObjectIsParent(parentObject))\n\treturn TPM_RCS_TYPE + RC_Create_parentHandle;\n\n    // Get a slot for the creation\n    newObject = FindEmptyObjectSlot(NULL);\n    if(newObject == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    // If the TPM2B_PUBLIC was passed as a structure, marshal it into is canonical\n    // form for processing\n\n    // to save typing.\n    publicArea = &newObject->publicArea;\n\n    // Copy the input structure to the allocated structure\n    *publicArea = in->inPublic.publicArea;\n\n    // Check attributes in input public area. CreateChecks() checks the things that\n    // are unique to creation and then validates the attributes and values that are\n    // common to create and load.\n    result = CreateChecks(parentObject,\n\t\t\t  /* primaryHierarchy = */ 0,\n\t\t\t  publicArea,\n\t\t\t  in->inSensitive.sensitive.data.t.size);\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, RC_Create_inPublic);\n    // Clean up the authValue if necessary\n    if(!AdjustAuthSize(&in->inSensitive.sensitive.userAuth, publicArea->nameAlg))\n\treturn TPM_RCS_SIZE + RC_Create_inSensitive;\n\n    // Command Output\n    // Create the object using the default TPM random-number generator\n    result = CryptCreateObject(newObject, &in->inSensitive.sensitive, NULL);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Fill in creation data\n    FillInCreationData(in->parentHandle,\n\t\t       publicArea->nameAlg,\n\t\t       &in->creationPCR,\n\t\t       &in->outsideInfo,\n\t\t       &out->creationData,\n\t\t       &out->creationHash);\n\n    // Compute creation ticket\n    result = TicketComputeCreation(EntityGetHierarchy(in->parentHandle),\n\t\t\t\t   &newObject->name,\n\t\t\t\t   &out->creationHash,\n\t\t\t\t   &out->creationTicket);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Prepare output private data from sensitive\n    SensitiveToPrivate(&newObject->sensitive,\n\t\t       &newObject->name,\n\t\t       parentObject,\n\t\t       publicArea->nameAlg,\n\t\t       &out->outPrivate);\n\n    newObject->hierarchy = parentObject->hierarchy;\n\n    // Finish by copying the remaining return values\n    out->outPublic.publicArea = newObject->publicArea;\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_Create\n\n#include \"Tpm.h\"\n#include \"Load_fp.h\"\n#if CC_Load  // Conditional expansion of this file\n#include \"Object_spt_fp.h\"\nTPM_RC\nTPM2_Load(\n\t  Load_In         *in,            // IN: input parameter list\n\t  Load_Out        *out            // OUT: output parameter list\n\t  )\n{\n    TPM_RC                   result = TPM_RC_SUCCESS;\n    TPMT_SENSITIVE           sensitive;\n    OBJECT                  *parentObject;\n    OBJECT                  *newObject;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Load: parentHandle %08x\\n\", in->parentHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Don't get invested in loading if there is no place to put it.\n    newObject = FindEmptyObjectSlot(&out->objectHandle);\n    if(newObject == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    if(in->inPrivate.t.size == 0)\n\treturn TPM_RCS_SIZE + RC_Load_inPrivate;\n    parentObject = HandleToObject(in->parentHandle);\n    pAssert(parentObject != NULL);\n    // Is the object that is being used as the parent actually a parent.\n    if(!ObjectIsParent(parentObject))\n\treturn TPM_RCS_TYPE + RC_Load_parentHandle;\n    // Compute the name of object. If there isn't one, it is because the nameAlg is\n    // not valid.\n    PublicMarshalAndComputeName(&in->inPublic.publicArea, &out->name);\n    if(out->name.t.size == 0)\n\treturn TPM_RCS_HASH + RC_Load_inPublic;\n    // Retrieve sensitive data.\n    result = PrivateToSensitive(&in->inPrivate.b, &out->name.b, parentObject,\n\t\t\t\tin->inPublic.publicArea.nameAlg,\n\t\t\t\t&sensitive);\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, RC_Load_inPrivate);\n    // Internal Data Update\n    // Load and validate object\n    result = ObjectLoad(newObject, parentObject,\n\t\t\t&in->inPublic.publicArea, &sensitive,\n\t\t\tRC_Load_inPublic, RC_Load_inPrivate,\n\t\t\t&out->name);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    // Set the common OBJECT attributes for a loaded object.\n\t    ObjectSetLoadedAttributes(newObject, in->parentHandle);\n\t}\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Load: objectHandle %08x\\n\", out->objectHandle);\n\t// fclose(f);\n  //   }\n    return result;\n}\n#endif // CC_Load\n#include \"Tpm.h\"\n#include \"LoadExternal_fp.h\"\n#if CC_LoadExternal  // Conditional expansion of this file\n#include \"Object_spt_fp.h\"\nTPM_RC\nTPM2_LoadExternal(\n\t\t  LoadExternal_In     *in,            // IN: input parameter list\n\t\t  LoadExternal_Out    *out            // OUT: output parameter list\n\t\t  )\n{\n    TPM_RC               result;\n    OBJECT              *object;\n    TPMT_SENSITIVE      *sensitive = NULL;\n    // Input Validation\n    // Don't get invested in loading if there is no place to put it.\n    object = FindEmptyObjectSlot(&out->objectHandle);\n    if(object == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n    // If the hierarchy to be associated with this object is turned off, the object\n    // cannot be loaded.\n    if(!HierarchyIsEnabled(in->hierarchy))\n\treturn TPM_RCS_HIERARCHY + RC_LoadExternal_hierarchy;\n    // For loading an object with both public and sensitive\n    if(in->inPrivate.size != 0)\n\t{\n\t    // An external object with a sensitive area can only be loaded in the\n\t    // NULL hierarchy\n\t    if(in->hierarchy != TPM_RH_NULL)\n\t\treturn TPM_RCS_HIERARCHY + RC_LoadExternal_hierarchy;\n\t    // An external object with a sensitive area must have fixedTPM == CLEAR\n\t    // fixedParent == CLEAR so that it does not appear to be a key created by\n\t    // this TPM.\n\t    if(IS_ATTRIBUTE(in->inPublic.publicArea.objectAttributes, TPMA_OBJECT, fixedTPM)\n\t       || IS_ATTRIBUTE(in->inPublic.publicArea.objectAttributes, TPMA_OBJECT,\n\t\t\t       fixedParent)\n\t       || IS_ATTRIBUTE(in->inPublic.publicArea.objectAttributes, TPMA_OBJECT,\n\t\t\t       restricted))\n\t\treturn TPM_RCS_ATTRIBUTES + RC_LoadExternal_inPublic;\n\t    // Have sensitive point to something other than NULL so that object\n\t    // initialization will load the sensitive part too\n\t    sensitive = &in->inPrivate.sensitiveArea;\n\t}\n    // Need the name to initialize the object structure\n    PublicMarshalAndComputeName(&in->inPublic.publicArea, &out->name);\n    // Load and validate key\n    result = ObjectLoad(object, NULL,\n\t\t\t&in->inPublic.publicArea, sensitive,\n\t\t\tRC_LoadExternal_inPublic, RC_LoadExternal_inPrivate,\n\t\t\t&out->name);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    object->attributes.external = SET;\n\t    // Set the common OBJECT attributes for a loaded object.\n\t    ObjectSetLoadedAttributes(object, in->hierarchy);\n\t}\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_LoadExternal: objectHandle %08x\\n\", out->objectHandle);\n\t// fclose(f);\n  //   }\n    return result;\n}\n#endif // CC_LoadExternal\n#include \"Tpm.h\"\n#include \"ReadPublic_fp.h\"\n#if CC_ReadPublic  // Conditional expansion of this file\nTPM_RC\nTPM2_ReadPublic(\n\t\tReadPublic_In   *in,            // IN: input parameter list\n\t\tReadPublic_Out  *out            // OUT: output parameter list\n\t\t)\n{\n    OBJECT                  *object = HandleToObject(in->objectHandle);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ReadPublic: objectHandle %08x\\n\", in->objectHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Can not read public area of a sequence object\n    if(ObjectIsSequence(object))\n\treturn TPM_RC_SEQUENCE;\n    // Command Output\n    out->outPublic.publicArea = object->publicArea;\n    out->name = object->name;\n    out->qualifiedName = object->qualifiedName;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_ReadPublic\n#include \"Tpm.h\"\n#include \"ActivateCredential_fp.h\"\n#if CC_ActivateCredential  // Conditional expansion of this file\n#include \"Object_spt_fp.h\"\nTPM_RC\nTPM2_ActivateCredential(\n\t\t\tActivateCredential_In   *in,            // IN: input parameter list\n\t\t\tActivateCredential_Out  *out            // OUT: output parameter list\n\t\t\t)\n{\n    TPM_RC                   result = TPM_RC_SUCCESS;\n    OBJECT                  *object;            // decrypt key\n    OBJECT                  *activateObject;    // key associated with credential\n    TPM2B_DATA               data;          // credential data\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ActivateCredential: activateHandle %08x\\n\", in->activateHandle);\n\t// fprintf(f, \"TPM2_ActivateCredential: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Get decrypt key pointer\n    object = HandleToObject(in->keyHandle);\n    // Get certificated object pointer\n    activateObject = HandleToObject(in->activateHandle);\n    // input decrypt key must be an asymmetric, restricted decryption key\n    if(!CryptIsAsymAlgorithm(object->publicArea.type)\n       || !IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, decrypt)\n       || !IS_ATTRIBUTE(object->publicArea.objectAttributes,\n\t\t\tTPMA_OBJECT, restricted))\n\treturn TPM_RCS_TYPE + RC_ActivateCredential_keyHandle;\n    // Command output\n    // Decrypt input credential data via asymmetric decryption.  A\n    // TPM_RC_VALUE, TPM_RC_KEY or unmarshal errors may be returned at this\n    // point\n    result = CryptSecretDecrypt(object, NULL, IDENTITY_STRING, &in->secret, &data);\n    if(result != TPM_RC_SUCCESS)\n\t{\n\t    if(result == TPM_RC_KEY)\n\t\treturn TPM_RC_FAILURE;\n\t    return RcSafeAddToResult(result, RC_ActivateCredential_secret);\n\t}\n    // Retrieve secret data.  A TPM_RC_INTEGRITY error or unmarshal\n    // errors may be returned at this point\n    result = CredentialToSecret(&in->credentialBlob.b,\n\t\t\t\t&activateObject->name.b,\n\t\t\t\t&data.b,\n\t\t\t\tobject,\n\t\t\t\t&out->certInfo);\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, RC_ActivateCredential_credentialBlob);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"ActivateCredential: activateHandle %08x\\n\", in->activateHandle);\n\t// fprintf(f, \"ActivateCredential: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_ActivateCredential\n#include \"Tpm.h\"\n#include \"MakeCredential_fp.h\"\n#if CC_MakeCredential  // Conditional expansion of this file\n#include \"Object_spt_fp.h\"\nTPM_RC\nTPM2_MakeCredential(\n\t\t    MakeCredential_In   *in,            // IN: input parameter list\n\t\t    MakeCredential_Out  *out            // OUT: output parameter list\n\t\t    )\n{\n    TPM_RC               result = TPM_RC_SUCCESS;\n    OBJECT              *object;\n    TPM2B_DATA           data;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_MakeCredential: handle %08x\\n\", in->handle);\n\t// fclose(f);\n  //   }\n   // Input Validation\n    // Get object pointer\n    object = HandleToObject(in->handle);\n    // input key must be an asymmetric, restricted decryption key\n    // NOTE: Needs to be restricted to have a symmetric value.\n    if(!CryptIsAsymAlgorithm(object->publicArea.type)\n       || !IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, decrypt)\n       || !IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, restricted))\n\treturn TPM_RCS_TYPE + RC_MakeCredential_handle;\n    // The credential information may not be larger than the digest size used for\n    // the Name of the key associated with handle.\n    if(in->credential.t.size > CryptHashGetDigestSize(object->publicArea.nameAlg))\n\treturn TPM_RCS_SIZE + RC_MakeCredential_credential;\n    // Command Output\n    // Make encrypt key and its associated secret structure.\n    out->secret.t.size = sizeof(out->secret.t.secret);\n    result = CryptSecretEncrypt(object, IDENTITY_STRING, &data, &out->secret);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Prepare output credential data from secret\n    SecretToCredential(&in->credential, &in->objectName.b, &data.b,\n\t\t       object, &out->credentialBlob);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_MakeCredential\n#include \"Tpm.h\"\n#include \"Unseal_fp.h\"\n#if CC_Unseal  // Conditional expansion of this file\nTPM_RC\nTPM2_Unseal(\n\t    Unseal_In           *in,\n\t    Unseal_Out          *out\n\t    )\n{\n    OBJECT                  *object;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Unseal: itemHandle %08x\\n\", in->itemHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Get pointer to loaded object\n    object = HandleToObject(in->itemHandle);\n    // Input handle must be a data object\n    if(object->publicArea.type != TPM_ALG_KEYEDHASH)\n\treturn TPM_RCS_TYPE + RC_Unseal_itemHandle;\n    if(IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, decrypt)\n       || IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, sign)\n       || IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, restricted))\n\treturn TPM_RCS_ATTRIBUTES + RC_Unseal_itemHandle;\n    // Command Output\n    // Copy data\n    out->outData = object->sensitive.sensitive.bits;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_Unseal\n#include \"Tpm.h\"\n#include \"ObjectChangeAuth_fp.h\"\n#if CC_ObjectChangeAuth  // Conditional expansion of this file\n#include \"Object_spt_fp.h\"\nTPM_RC\nTPM2_ObjectChangeAuth(\n\t\t      ObjectChangeAuth_In     *in,            // IN: input parameter list\n\t\t      ObjectChangeAuth_Out    *out            // OUT: output parameter list\n\t\t      )\n{\n    TPMT_SENSITIVE           sensitive;\n    OBJECT                  *object = HandleToObject(in->objectHandle);\n    TPM2B_NAME               QNCompare;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_ObjectChangeAuth: objectHandle %08x\\n\", in->objectHandle);\n\t// fprintf(f, \"TPM2_ObjectChangeAuth: parentHandle %08x\\n\", in->parentHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Can not change authorization on sequence object\n    if(ObjectIsSequence(object))\n\treturn TPM_RCS_TYPE + RC_ObjectChangeAuth_objectHandle;\n    // Make sure that the authorization value is consistent with the nameAlg\n    if(!AdjustAuthSize(&in->newAuth, object->publicArea.nameAlg))\n\treturn TPM_RCS_SIZE + RC_ObjectChangeAuth_newAuth;\n    // Parent handle should be the parent of object handle.  In this\n    // implementation we verify this by checking the QN of object.  Other\n    // implementation may choose different method to verify this attribute.\n    ComputeQualifiedName(in->parentHandle,\n\t\t\t object->publicArea.nameAlg,\n\t\t\t &object->name, &QNCompare);\n    if(!MemoryEqual2B(&object->qualifiedName.b, &QNCompare.b))\n\treturn TPM_RCS_TYPE + RC_ObjectChangeAuth_parentHandle;\n    // Command Output\n    // Prepare the sensitive area with the new authorization value\n    sensitive = object->sensitive;\n    sensitive.authValue = in->newAuth;\n    // Protect the sensitive area\n    SensitiveToPrivate(&sensitive, &object->name, HandleToObject(in->parentHandle),\n\t\t       object->publicArea.nameAlg,\n\t\t       &out->outPrivate);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_ObjectChangeAuth\n\n#include \"Tpm.h\"\n#include \"CreateLoaded_fp.h\"\n\n#if CC_CreateLoaded  // Conditional expansion of this file\n\n/*(See part 3 of specification)\n * Create and load any type of key, including a temporary key.\n * The input template is a marshaled public area rather than an unmarshaled one as\n * used in Create and CreatePrimary. This is so that the label and context that\n * could be in the template can be processed without changing the formats for the\n * calls to Create and CreatePrimary.\n */\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES       'sensitiveDataOrigin' is CLEAR when 'sensitive.data'\n//                              is an Empty Buffer;\n//                              'fixedTPM', 'fixedParent', or 'encryptedDuplication'\n//                              attributes are inconsistent between themselves or with\n//                              those of the parent object;\n//                              inconsistent 'restricted', 'decrypt' and 'sign'\n//                              attributes;\n//                              attempt to inject sensitive data for an asymmetric\n//                              key;\n//                              attempt to create a symmetric cipher key that is not\n//                              a decryption key\n//      TPM_RC_FW_LIMITED       The requested hierarchy is FW-limited, but the TPM\n//                              does not support FW-limited objects or the TPM failed\n//                              to derive the Firmware Secret.\n//      TPM_RC_SVN_LIMITED      The requested hierarchy is SVN-limited, but the TPM\n//                              does not support SVN-limited objects or the TPM failed\n//                              to derive the Firmware SVN Secret for the requested\n//                              SVN.\n//      TPM_RC_KDF              incorrect KDF specified for decrypting keyed hash\n//                              object\n//      TPM_RC_KEY              the value of a provided symmetric key is not allowed\n//      TPM_RC_OBJECT_MEMORY    there is no free slot for the object\n//      TPM_RC_SCHEME           inconsistent attributes 'decrypt', 'sign',\n//                              'restricted' and key's scheme ID; or hash algorithm is\n//                              inconsistent with the scheme ID for keyed hash object\n//      TPM_RC_SIZE             size of public authorization policy or sensitive\n//                              authorization value does not match digest size of the\n//                              name algorithm sensitive data size for the keyed hash\n//                              object is larger than is allowed for the scheme\n//      TPM_RC_SYMMETRIC        a storage key with no symmetric algorithm specified;\n//                              or non-storage key with symmetric algorithm different\n//                              from TPM_ALG_NULL\n//      TPM_RC_TYPE             cannot create the object of the indicated type\n//                              (usually only occurs if trying to derive an RSA key).\nTPM_RC\nTPM2_CreateLoaded(CreateLoaded_In*  in,  // IN: input parameter list\n\t\t  CreateLoaded_Out* out  // OUT: output parameter list\n\t\t  )\n{\n    TPM_RC       result = TPM_RC_SUCCESS;\n    OBJECT*      parent = HandleToObject(in->parentHandle);\n    OBJECT*      newObject;\n    BOOL         derivation;\n    TPMT_PUBLIC* publicArea;\n    RAND_STATE   randState;\n    RAND_STATE*  rand = &randState;\n    TPMS_DERIVE  labelContext;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_CreateLoaded: parentHandle %08x\\n\", in->parentHandle);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n\n    // How the public area is unmarshaled is determined by the parent, so\n    // see if parent is a derivation parent\n    derivation = (parent != NULL && parent->attributes.derivation);\n\n    // If the parent is an object, then make sure that it is either a parent or\n    // derivation parent\n    if(parent != NULL && !parent->attributes.isParent && !derivation)\n\treturn TPM_RCS_TYPE + RC_CreateLoaded_parentHandle;\n\n    // Get a spot in which to create the newObject\n    newObject = FindEmptyObjectSlot(&out->objectHandle);\n    if(newObject == NULL)\n\treturn TPM_RC_OBJECT_MEMORY;\n\n    // Do this to save typing\n    publicArea = &newObject->publicArea;\n\n    // Unmarshal the template into the object space. TPM2_Create() and\n    // TPM2_CreatePrimary() have the publicArea unmarshaled by CommandDispatcher.\n    // This command is different because of an unfortunate property of the\n    // unique field of an ECC key. It is a structure rather than a single TPM2B. If\n    // if had been a TPM2B, then the label and context could be within a TPM2B and\n    // unmarshaled like other public areas. Since it is not, this command needs its\n    // on template that is a TPM2B that is unmarshaled as a BYTE array with a\n    // its own unmarshal function.\n    result = UnmarshalToPublic(publicArea, &in->inPublic, derivation, &labelContext);\n    if(result != TPM_RC_SUCCESS)\n\treturn result + RC_CreateLoaded_inPublic;\n\n    // Validate that the authorization size is appropriate\n    if(!AdjustAuthSize(&in->inSensitive.sensitive.userAuth, publicArea->nameAlg))\n\treturn TPM_RCS_SIZE + RC_CreateLoaded_inSensitive;\n\n    // Command output\n    if(derivation)\n\t{\n\t    TPMT_KEYEDHASH_SCHEME* scheme;\n\t    scheme = &parent->publicArea.parameters.keyedHashDetail.scheme;\n\n\t    // SP800-108 is the only KDF supported by this implementation and there is\n\t    // no default hash algorithm.\n\t    pAssert(scheme->details.xorr.hashAlg != TPM_ALG_NULL\n\t\t    && scheme->details.xorr.kdf == TPM_ALG_KDF1_SP800_108);\n\t    // Don't derive RSA keys\n\t    if(publicArea->type == TPM_ALG_RSA)\n\t\treturn TPM_RCS_TYPE + RC_CreateLoaded_inPublic;\n\t    // sensitiveDataOrigin has to be CLEAR in a derived object. Since this\n\t    // is specific to a derived object, it is checked here.\n\t    if(IS_ATTRIBUTE(\n\t\t\t    publicArea->objectAttributes, TPMA_OBJECT, sensitiveDataOrigin))\n\t\treturn TPM_RCS_ATTRIBUTES;\n\t    // Check the rest of the attributes\n\t    result = PublicAttributesValidation(parent, 0, publicArea);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn RcSafeAddToResult(result, RC_CreateLoaded_inPublic);\n\t    // Process the template and sensitive areas to get the actual 'label' and\n\t    // 'context' values to be used for this derivation.\n\t    result = SetLabelAndContext(&labelContext, &in->inSensitive.sensitive.data);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t    // Set up the KDF for object generation\n\t    DRBG_InstantiateSeededKdf((KDF_STATE*)rand,\n\t\t\t\t      scheme->details.xorr.hashAlg,\n\t\t\t\t      scheme->details.xorr.kdf,\n\t\t\t\t      &parent->sensitive.sensitive.bits.b,\n\t\t\t\t      &labelContext.label.b,\n\t\t\t\t      &labelContext.context.b,\n\t\t\t\t      TPM_MAX_DERIVATION_BITS);\n\t    // Clear the sensitive size so that the creation functions will not try\n\t    // to use this value.\n\t    in->inSensitive.sensitive.data.t.size = 0;\n\t}\n    else\n\t{\n\t    // Check attributes in input public area. CreateChecks() checks the things\n\t    // that are unique to creation and then validates the attributes and values\n\t    // that are common to create and load.\n\t    result = CreateChecks(parent,\n\t\t\t\t  (parent == NULL) ? in->parentHandle : 0,\n\t\t\t\t  publicArea,\n\t\t\t\t  in->inSensitive.sensitive.data.t.size);\n\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn RcSafeAddToResult(result, RC_CreateLoaded_inPublic);\n\t    // Creating a primary object\n\t    if(parent == NULL)\n\t\t{\n\t\t    TPM2B_NAME name;\n\t\t    TPM2B_SEED primary_seed;\n\n\t\t    newObject->attributes.primary = SET;\n\t\t    if(HierarchyNormalizeHandle(in->parentHandle) == TPM_RH_ENDORSEMENT)\n\t\t\tnewObject->attributes.epsHierarchy = SET;\n\n\t\t    result = HierarchyGetPrimarySeed(in->parentHandle, &primary_seed);\n\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\treturn result;\n\n\t\t    // If so, use the primary seed and the digest of the template\n\t\t    // to seed the DRBG\n\t\t    result = DRBG_InstantiateSeeded(\n\t\t\t\t\t\t    (DRBG_STATE*)rand,\n\t\t\t\t\t\t    &primary_seed.b,\n\t\t\t\t\t\t    PRIMARY_OBJECT_CREATION,\n\t\t\t\t\t\t    (TPM2B*)PublicMarshalAndComputeName(publicArea, &name),\n\t\t\t\t\t\t    &in->inSensitive.sensitive.data.b);\n\t\t    MemorySet(primary_seed.b.buffer, 0, primary_seed.b.size);\n\n\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\treturn result;\n\t\t}\n\t    else\n\t\t{\n\t\t    // This is an ordinary object so use the normal random number generator\n\t\t    rand = NULL;\n\t\t}\n\t}\n    // Internal data update\n    // Create the object\n    result = CryptCreateObject(newObject, &in->inSensitive.sensitive, rand);\n    DRBG_Uninstantiate((DRBG_STATE*)rand);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // if this is not a Primary key and not a derived key, then return the sensitive\n    // area\n    if(parent != NULL && !derivation)\n\t// Prepare output private data from sensitive\n\tSensitiveToPrivate(&newObject->sensitive,\n\t\t\t   &newObject->name,\n\t\t\t   parent,\n\t\t\t   newObject->publicArea.nameAlg,\n\t\t\t   &out->outPrivate);\n    else\n\tout->outPrivate.t.size = 0;\n    // Set the remaining return values\n    out->outPublic.publicArea = newObject->publicArea;\n    out->name                 = newObject->name;\n    // Set the remaining attributes for a loaded object\n    ObjectSetLoadedAttributes(newObject, in->parentHandle);\n\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_CreateLoaded: objectHandle %08x\\n\", out->objectHandle);\n\t// fclose(f);\n  //   }\n   return result;\n}\n\n#endif  // CC_CreateLoaded\n"
  },
  {
    "path": "ftpm-opensbi/src/Object_spt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Object Command Support \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes\n#include \"Tpm.h\"\n#include \"Object_spt_fp.h\"\n#include \"Marshal.h\"\n#include \"TpmTypes.h\"\t\t// kgold\n\n//** Local Functions\n\n//*** GetIV2BSize()\n// Get the size of TPM2B_IV in canonical form that will be append to the start of\n// the sensitive data.  It includes both size of size field and size of iv data\nstatic UINT16 GetIV2BSize(OBJECT* protector  // IN: the protector handle\n\t\t\t  )\n{\n    TPM_ALG_ID symAlg;\n    UINT16     keyBits;\n\n    // Determine the symmetric algorithm and size of key\n    if(protector == NULL)\n\t{\n\t    // Use the context encryption algorithm and key size\n\t    symAlg  = CONTEXT_ENCRYPT_ALG;\n\t    keyBits = CONTEXT_ENCRYPT_KEY_BITS;\n\t}\n    else\n\t{\n\t    symAlg  = protector->publicArea.parameters.asymDetail.symmetric.algorithm;\n\t    keyBits = protector->publicArea.parameters.asymDetail.symmetric.keyBits.sym;\n\t}\n\n    // The IV size is a UINT16 size field plus the block size of the symmetric\n    // algorithm\n    return sizeof(UINT16) + CryptGetSymmetricBlockSize(symAlg, keyBits);\n}\n\n//*** ComputeProtectionKeyParms()\n// This function retrieves the symmetric protection key parameters for\n// the sensitive data\n// The parameters retrieved from this function include encryption algorithm,\n// key size in bit, and a TPM2B_SYM_KEY containing the key material as well as\n// the key size in bytes\n// This function is used for any action that requires encrypting or decrypting of\n// the sensitive area of an object or a credential blob\n//\n/*(See part 1 specification)\n  KDF for generating the protection key material:\n  KDFa(hashAlg, seed, \"STORAGE\", Name, NULL , bits)\n  where\n  hashAlg     for a Primary Object, an algorithm chosen by the TPM vendor\n  for derivations from Primary Seeds. For all other objects,\n  the nameAlg of the object's parent.\n  seed        for a Primary Object in the Platform Hierarchy, the PPS.\n  For Primary Objects in either Storage or Endorsement Hierarchy,\n  the SPS. For Temporary Objects, the context encryption seed.\n  For all other objects, the symmetric seed value in the\n  sensitive area of the object's parent.\n  STORAGE     label to differentiate use of KDFa() (see 4.7)\n  Name        the Name of the object being encrypted\n  bits        the number of bits required for a  symmetric key and IV\n*/\n//  Return Type: void\nstatic void ComputeProtectionKeyParms(\n\t\t\t\t      OBJECT*    protector,    // IN: the protector object\n\t\t\t\t      TPM_ALG_ID hashAlg,      // IN: hash algorithm for KDFa\n\t\t\t\t      TPM2B*     name,         // IN: name of the object\n\t\t\t\t      TPM2B*     seedIn,       // IN: optional seed for duplication blob.\n\t\t\t\t      //     For non duplication blob, this\n\t\t\t\t      //     parameter should be NULL\n\t\t\t\t      TPM_ALG_ID*    symAlg,   // OUT: the symmetric algorithm\n\t\t\t\t      UINT16*        keyBits,  // OUT: the symmetric key size in bits\n\t\t\t\t      TPM2B_SYM_KEY* symKey    // OUT: the symmetric key\n\t\t\t\t      )\n{\n    const TPM2B* seed = seedIn;\n\n    // Determine the algorithms for the KDF and the encryption/decryption\n    // For TPM_RH_NULL, using context settings\n    if(protector == NULL)\n\t{\n\t    // Use the context encryption algorithm and key size\n\t    *symAlg        = CONTEXT_ENCRYPT_ALG;\n\t    symKey->t.size = CONTEXT_ENCRYPT_KEY_BYTES;\n\t    *keyBits       = CONTEXT_ENCRYPT_KEY_BITS;\n\t}\n    else\n\t{\n\t    TPMT_SYM_DEF_OBJECT* symDef;\n\t    symDef         = &protector->publicArea.parameters.asymDetail.symmetric;\n\t    *symAlg        = symDef->algorithm;\n\t    *keyBits       = symDef->keyBits.sym;\n\t    symKey->t.size = (*keyBits + 7) / 8;\n\t}\n    // Get seed for KDF\n    if(seed == NULL)\n\tseed = GetSeedForKDF(protector);\n    // KDFa to generate symmetric key and IV value\n    CryptKDFa(hashAlg,\n\t      seed,\n\t      STORAGE_KEY,\n\t      name,\n\t      NULL,\n\t      symKey->t.size * 8,\n\t      symKey->t.buffer,\n\t      NULL,\n\t      FALSE);\n    return;\n}\n\n//*** ComputeOuterIntegrity()\n// The sensitive area parameter is a buffer that holds a space for\n// the integrity value and the marshaled sensitive area. The caller should\n// skip over the area set aside for the integrity value\n// and compute the hash of the remainder of the object.\n// The size field of sensitive is in unmarshaled form and the\n// sensitive area contents is an array of bytes.\n/*(See part 1 specification)\n  KDFa(hashAlg, seed, \"INTEGRITY\", NULL, NULL , bits)   (38)\n  where\n  hashAlg     for a Primary Object, the nameAlg of the object. For all other\n  objects the nameAlg of the object's parent.\n  seed        for a Primary Object in the Platform Hierarchy, the PPS. For\n  Primary Objects in either Storage or Endorsement Hierarchy,\n  the SPS. For a Temporary Object, the context encryption key.\n  For all other objects, the symmetric seed value in the sensitive\n  area of the object's parent.\n  \"INTEGRITY\" a value used to differentiate the uses of the KDF.\n  bits        the number of bits in the digest produced by hashAlg.\n  Key is then used in the integrity computation.\n  HMACnameAlg(HMACkey, encSensitive || Name )\n  where\n  HMACnameAlg()   the HMAC function using nameAlg of the object's parent\n  HMACkey         value derived from the parent symmetric protection value\n  encSensitive    symmetrically encrypted sensitive area\n  Name            the Name of the object being protected\n*/\n//  Return Type: void\nstatic void ComputeOuterIntegrity(\n\t\t\t\t  TPM2B*  name,                 // IN: the name of the object\n\t\t\t\t  OBJECT* protector,            // IN: the object that\n\t\t\t\t  //     provides protection. For an object,\n\t\t\t\t  //     it is a parent. For a credential, it\n\t\t\t\t  //     is the encrypt object. For\n\t\t\t\t  //     a Temporary Object, it is NULL\n\t\t\t\t  TPMI_ALG_HASH hashAlg,        // IN: algorithm to use for integrity\n\t\t\t\t  TPM2B*        seedIn,         // IN: an external seed may be provided for\n\t\t\t\t  //     duplication blob. For non duplication\n\t\t\t\t  //     blob, this parameter should be NULL\n\t\t\t\t  UINT32        sensitiveSize,  // IN: size of the marshaled sensitive data\n\t\t\t\t  BYTE*         sensitiveData,  // IN: sensitive area\n\t\t\t\t  TPM2B_DIGEST* integrity       // OUT: integrity\n\t\t\t\t  )\n{\n    HMAC_STATE   hmacState;\n    TPM2B_DIGEST hmacKey;\n    const TPM2B* seed = seedIn;\n    //\n    // Get seed for KDF\n    if(seed == NULL)\n\tseed = GetSeedForKDF(protector);\n    // Determine the HMAC key bits\n    hmacKey.t.size = CryptHashGetDigestSize(hashAlg);\n\n    // KDFa to generate HMAC key\n    CryptKDFa(hashAlg,\n\t      seed,\n\t      INTEGRITY_KEY,\n\t      NULL,\n\t      NULL,\n\t      hmacKey.t.size * 8,\n\t      hmacKey.t.buffer,\n\t      NULL,\n\t      FALSE);\n    // Start HMAC and get the size of the digest which will become the integrity\n    integrity->t.size = CryptHmacStart2B(&hmacState, hashAlg, &hmacKey.b);\n\n    // Adding the marshaled sensitive area to the integrity value\n    CryptDigestUpdate(&hmacState.hashState, sensitiveSize, sensitiveData);\n\n    // Adding name\n    CryptDigestUpdate2B(&hmacState.hashState, name);\n\n    // Compute HMAC\n    CryptHmacEnd2B(&hmacState, &integrity->b);\n\n    return;\n}\n\n//*** ComputeInnerIntegrity()\n// This function computes the integrity of an inner wrap\nstatic void ComputeInnerIntegrity(\n\t\t\t\t  TPM_ALG_ID    hashAlg,        // IN: hash algorithm for inner wrap\n\t\t\t\t  TPM2B*        name,           // IN: the name of the object\n\t\t\t\t  UINT16        dataSize,       // IN: the size of sensitive data\n\t\t\t\t  BYTE*         sensitiveData,  // IN: sensitive data\n\t\t\t\t  TPM2B_DIGEST* integrity       // OUT: inner integrity\n\t\t\t\t  )\n{\n    HASH_STATE hashState;\n    //\n    // Start hash and get the size of the digest which will become the integrity\n    integrity->t.size = CryptHashStart(&hashState, hashAlg);\n\n    // Adding the marshaled sensitive area to the integrity value\n    CryptDigestUpdate(&hashState, dataSize, sensitiveData);\n\n    // Adding name\n    CryptDigestUpdate2B(&hashState, name);\n\n    // Compute hash\n    CryptHashEnd2B(&hashState, &integrity->b);\n\n    return;\n}\n\n//*** ProduceInnerIntegrity()\n// This function produces an inner integrity for regular private, credential or\n// duplication blob\n// It requires the sensitive data being marshaled to the innerBuffer, with the\n// leading bytes reserved for integrity hash.  It assume the sensitive data\n// starts at address (innerBuffer + integrity size).\n// This function integrity at the beginning of the inner buffer\n// It returns the total size of buffer with the inner wrap\nstatic UINT16 ProduceInnerIntegrity(\n\t\t\t\t    TPM2B*     name,      // IN: the name of the object\n\t\t\t\t    TPM_ALG_ID hashAlg,   // IN: hash algorithm for inner wrap\n\t\t\t\t    UINT16     dataSize,  // IN: the size of sensitive data, excluding the\n\t\t\t\t    //     leading integrity buffer size\n\t\t\t\t    BYTE* innerBuffer     // IN/OUT: inner buffer with sensitive data in\n\t\t\t\t    //     it.  At input, the leading bytes of this\n\t\t\t\t    //     buffer is reserved for integrity\n\t\t\t\t    )\n{\n    BYTE*        sensitiveData;  // pointer to the sensitive data\n    TPM2B_DIGEST integrity;\n    UINT16       integritySize;\n    BYTE*        buffer;  // Auxiliary buffer pointer\n    //\n    // sensitiveData points to the beginning of sensitive data in innerBuffer\n    integritySize = sizeof(UINT16) + CryptHashGetDigestSize(hashAlg);\n    sensitiveData = innerBuffer + integritySize;\n\n    ComputeInnerIntegrity(hashAlg, name, dataSize, sensitiveData, &integrity);\n\n    // Add integrity at the beginning of inner buffer\n    buffer = innerBuffer;\n    TPM2B_DIGEST_Marshal(&integrity, &buffer, NULL);\n\n    return dataSize + integritySize;\n}\n\n//*** CheckInnerIntegrity()\n// This function check integrity of inner blob\n//  Return Type: TPM_RC\n//      TPM_RC_INTEGRITY        if the outer blob integrity is bad\n//      unmarshal errors        unmarshal errors while unmarshaling integrity\nstatic TPM_RC CheckInnerIntegrity(\n\t\t\t\t  TPM2B*     name,      // IN: the name of the object\n\t\t\t\t  TPM_ALG_ID hashAlg,   // IN: hash algorithm for inner wrap\n\t\t\t\t  UINT16     dataSize,  // IN: the size of sensitive data, including the\n\t\t\t\t  //     leading integrity buffer size\n\t\t\t\t  BYTE* innerBuffer     // IN/OUT: inner buffer with sensitive data in\n\t\t\t\t  //     it\n\t\t\t\t  )\n{\n    TPM_RC       result;\n    TPM2B_DIGEST integrity;\n    TPM2B_DIGEST integrityToCompare;\n    BYTE*        buffer;  // Auxiliary buffer pointer\n    INT32        size;\n    //\n    // Unmarshal integrity\n    buffer = innerBuffer;\n    size   = (INT32)dataSize;\n    result = TPM2B_DIGEST_Unmarshal(&integrity, &buffer, &size);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    // Compute integrity to compare\n\t    ComputeInnerIntegrity(\n\t\t\t\t  hashAlg, name, (UINT16)size, buffer, &integrityToCompare);\n\t    // Compare outer blob integrity\n\t    if(!MemoryEqual2B(&integrity.b, &integrityToCompare.b))\n\t\tresult = TPM_RC_INTEGRITY;\n\t}\n    return result;\n}\n\n//** Public Functions\n\n//*** AdjustAuthSize()\n// This function will validate that the input authValue is no larger than the\n// digestSize for the nameAlg. It will then pad with zeros to the size of the\n// digest.\nBOOL AdjustAuthSize(TPM2B_AUTH*   auth,    // IN/OUT: value to adjust\n\t\t    TPMI_ALG_HASH nameAlg  // IN:\n\t\t    )\n{\n    UINT16 digestSize;\n    //\n    // If there is no nameAlg, then this is a LoadExternal and the authVale can\n    // be any size up to the maximum allowed by the implementation\n    digestSize = (nameAlg == TPM_ALG_NULL) ? sizeof(TPMU_HA)\n\t\t : CryptHashGetDigestSize(nameAlg);\n    if(digestSize < MemoryRemoveTrailingZeros(auth))\n\treturn FALSE;\n    else if(digestSize > auth->t.size)\n\tMemoryPad2B(&auth->b, digestSize);\n    auth->t.size = digestSize;\n\n    return TRUE;\n}\n\n//*** AreAttributesForParent()\n// This function is called by create, load, and import functions.\n//\n// Note: The 'isParent' attribute is SET when an object is loaded and it has\n// attributes that are suitable for a parent object.\n//  Return Type: BOOL\n//      TRUE(1)         properties are those of a parent\n//      FALSE(0)        properties are not those of a parent\nBOOL ObjectIsParent(OBJECT* parentObject  // IN: parent handle\n\t\t    )\n{\n    return parentObject->attributes.isParent;\n}\n\n//*** CreateChecks()\n// Attribute checks that are unique to creation.\n// If parentObject is not NULL, then this function checks the object's\n// attributes as an Ordinary or Derived Object with the given parent.\n// If parentObject is NULL, and primaryHandle is not 0, then this function\n// checks the object's attributes as a Primary Object in the given hierarchy.\n// If parentObject is NULL, and primaryHandle is 0, then this function checks\n// the object's attributes as an External Object.\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES   sensitiveDataOrigin is not consistent with the\n//                          object type\n//      other               returns from PublicAttributesValidation()\nTPM_RC\nCreateChecks(OBJECT*           parentObject,\n\t     TPMI_RH_HIERARCHY primaryHierarchy,\n\t     TPMT_PUBLIC*      publicArea,\n\t     UINT16            sensitiveDataSize)\n{\n    TPMA_OBJECT attributes = publicArea->objectAttributes;\n    TPM_RC      result     = TPM_RC_SUCCESS;\n    //\n    // If the caller indicates that they have provided the data, then make sure that\n    // they have provided some data.\n    if((!IS_ATTRIBUTE(attributes, TPMA_OBJECT, sensitiveDataOrigin))\n       && (sensitiveDataSize == 0))\n\treturn TPM_RCS_ATTRIBUTES;\n    // For an ordinary object, data can only be provided when sensitiveDataOrigin\n    // is CLEAR\n    if((parentObject != NULL)\n       && (IS_ATTRIBUTE(attributes, TPMA_OBJECT, sensitiveDataOrigin))\n       && (sensitiveDataSize != 0))\n\treturn TPM_RCS_ATTRIBUTES;\n    switch(publicArea->type)\n\t{\n\t  case TPM_ALG_KEYEDHASH:\n\t    // if this is a data object (sign == decrypt == CLEAR) then the\n\t    // TPM cannot be the data source.\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_OBJECT, sign)\n\t       && !IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt)\n\t       && IS_ATTRIBUTE(attributes, TPMA_OBJECT, sensitiveDataOrigin))\n\t\tresult = TPM_RC_ATTRIBUTES;\n\t    // comment out the next line in order to prevent a fixedTPM derivation\n\t    // parent\n\t    //            break;\n\t  case TPM_ALG_SYMCIPHER:\n\t    // A restricted key symmetric key (SYMCIPHER and KEYEDHASH)\n\t    // must have sensitiveDataOrigin SET unless it has fixedParent and\n\t    // fixedTPM CLEAR.\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, restricted))\n\t\tif(!IS_ATTRIBUTE(attributes, TPMA_OBJECT, sensitiveDataOrigin))\n\t\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedParent)\n\t\t       || IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM))\n\t\t\tresult = TPM_RCS_ATTRIBUTES;\n\t    break;\n\t  default:  // Asymmetric keys cannot have the sensitive portion provided\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_OBJECT, sensitiveDataOrigin))\n\t\tresult = TPM_RCS_ATTRIBUTES;\n\t    break;\n\t}\n    if(TPM_RC_SUCCESS == result)\n\t{\n\t    result =\n\t\tPublicAttributesValidation(parentObject, primaryHierarchy, publicArea);\n\t}\n    return result;\n}\n\n//*** SchemeChecks\n// This function is called by TPM2_LoadExternal() and PublicAttributesValidation().\n// This function validates the schemes in the public area of an object.\n//  Return Type: TPM_RC\n//      TPM_RC_HASH         non-duplicable storage key and its parent have different\n//                          name algorithm\n//      TPM_RC_KDF          incorrect KDF specified for decrypting keyed hash object\n//      TPM_RC_KEY          invalid key size values in an asymmetric key public area\n//      TPM_RCS_SCHEME       inconsistent attributes 'decrypt', 'sign', 'restricted'\n//                          and key's scheme ID; or hash algorithm is inconsistent\n//                          with the scheme ID for keyed hash object\n//      TPM_RC_SYMMETRIC    a storage key with no symmetric algorithm specified; or\n//                          non-storage key with symmetric algorithm different from\n//                          TPM_ALG_NULL\nTPM_RC\nSchemeChecks(OBJECT*      parentObject,  // IN: parent (null if primary seed)\n\t     TPMT_PUBLIC* publicArea     // IN: public area of the object\n\t     )\n{\n    TPMT_SYM_DEF_OBJECT* symAlgs    = NULL;\n    TPM_ALG_ID           scheme     = TPM_ALG_NULL;\n    TPMA_OBJECT          attributes = publicArea->objectAttributes;\n    TPMU_PUBLIC_PARMS*   parms      = &publicArea->parameters;\n    //\n    switch(publicArea->type)\n\t{\n\t  case TPM_ALG_SYMCIPHER:\n\t    symAlgs = &parms->symDetail.sym;\n\t    // If this is a decrypt key, then only the block cipher modes (not\n\t    // SMAC) are valid. TPM_ALG_NULL is OK too. If this is a 'sign' key,\n\t    // then any mode that got through the unmarshaling is OK.\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt)\n\t       && !CryptSymModeIsValid(symAlgs->mode.sym, TRUE))\n\t\treturn TPM_RCS_SCHEME;\n\t    break;\n\t  case TPM_ALG_KEYEDHASH:\n\t    scheme = parms->keyedHashDetail.scheme.scheme;\n\t    // if both sign and decrypt\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, sign)\n\t       == IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt))\n\t\t{\n\t\t    // if both sign and decrypt are set or clear, then need\n\t\t    // TPM_ALG_NULL as scheme\n\t\t    if(scheme != TPM_ALG_NULL)\n\t\t\treturn TPM_RCS_SCHEME;\n\t\t}\n\t    else if(\n\t\t    IS_ATTRIBUTE(attributes, TPMA_OBJECT, sign) && scheme != TPM_ALG_HMAC)\n\t\treturn TPM_RCS_SCHEME;\n\t    else if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt))\n\t\t{\n\t\t    if(scheme != TPM_ALG_XOR)\n\t\t\treturn TPM_RCS_SCHEME;\n\t\t    // If this is a derivation parent, then the KDF needs to be\n\t\t    // SP800-108 for this implementation. This is the only derivation\n\t\t    // supported by this implementation. Other implementations could\n\t\t    // support additional schemes. There is no default.\n\t\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, restricted))\n\t\t\t{\n\t\t\t    if(parms->keyedHashDetail.scheme.details.\n\t\t\t       xorr.kdf != TPM_ALG_KDF1_SP800_108)\n\t\t\t\treturn TPM_RCS_SCHEME;\n\t\t\t    // Must select a digest.\n\t\t\t    if(CryptHashGetDigestSize(\n\t\t\t\t\t\t      parms->keyedHashDetail.scheme.details.xorr.hashAlg)\n\t\t\t       == 0)\n\t\t\t\treturn TPM_RCS_HASH;\n\t\t\t}\n\t\t}\n\t    break;\n\t  default:  // handling for asymmetric\n\t    scheme  = parms->asymDetail.scheme.scheme;\n\t    symAlgs = &parms->asymDetail.symmetric;\n\t    // if the key is both sign and decrypt, then the scheme must be\n\t    // TPM_ALG_NULL because there is no way to specify both a sign and a\n\t    // decrypt scheme in the key.\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, sign)\n\t       == IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt))\n\t\t{\n\t\t    // scheme must be TPM_ALG_NULL\n\t\t    if(scheme != TPM_ALG_NULL)\n\t\t\treturn TPM_RCS_SCHEME;\n\t\t}\n\t    else if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, sign))\n\t\t{\n\t\t    // If this is a signing key, see if it has a signing scheme\n\t\t    if(CryptIsAsymSignScheme(publicArea->type, scheme))\n\t\t\t{\n\t\t\t    // if proper signing scheme then it needs a proper hash\n\t\t\t    if(parms->asymDetail.scheme.details.anySig.hashAlg\n\t\t\t       == TPM_ALG_NULL)\n\t\t\t\treturn TPM_RCS_SCHEME;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // signing key that does not have a proper signing scheme.\n\t\t\t    // This is OK if the key is not restricted and its scheme\n\t\t\t    // is TPM_ALG_NULL\n\t\t\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, restricted)\n\t\t\t       || scheme != TPM_ALG_NULL)\n\t\t\t\treturn TPM_RCS_SCHEME;\n\t\t\t}\n\t\t}\n\t    else if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt))\n\t\t{\n\t\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, restricted))\n\t\t\t{\n\t\t\t    // for a restricted decryption key (a parent), scheme\n\t\t\t    // is required to be TPM_ALG_NULL\n\t\t\t    if(scheme != TPM_ALG_NULL)\n\t\t\t\treturn TPM_RCS_SCHEME;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // For an unrestricted decryption key, the scheme has to\n\t\t\t    // be a valid scheme or TPM_ALG_NULL\n\t\t\t    if(scheme != TPM_ALG_NULL\n\t\t\t       && !CryptIsAsymDecryptScheme(publicArea->type, scheme))\n\t\t\t\treturn TPM_RCS_SCHEME;\n\t\t\t}\n\t\t}\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_OBJECT, restricted)\n\t       || !IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt))\n\t\t{\n\t\t    // For an asymmetric key that is not a parent, the symmetric\n\t\t    // algorithms must be TPM_ALG_NULL\n\t\t    if(symAlgs->algorithm != TPM_ALG_NULL)\n\t\t\treturn TPM_RCS_SYMMETRIC;\n\t\t}\n\t    // Special checks for an ECC key\n#if ALG_ECC\n\t    if(publicArea->type == TPM_ALG_ECC)\n\t\t{\n\t\t    TPM_ECC_CURVE          curveID;\n\t\t    const TPMT_ECC_SCHEME* curveScheme;\n\n\t\t    curveID     = publicArea->parameters.eccDetail.curveID;\n\t\t    curveScheme = CryptGetCurveSignScheme(curveID);\n\t\t    // The curveId must be valid or the unmarshaling is busted.\n\t\t    pAssert(curveScheme != NULL);\n\n\t\t    // If the curveID requires a specific scheme, then the key must\n\t\t    // select the same scheme\n\t\t    if(curveScheme->scheme != TPM_ALG_NULL)\n\t\t\t{\n\t\t\t    TPMS_ECC_PARMS* ecc = &publicArea->parameters.eccDetail;\n\t\t\t    if(scheme != curveScheme->scheme)\n\t\t\t\treturn TPM_RCS_SCHEME;\n\t\t\t    // The scheme can allow any hash, or not...\n\t\t\t    if(curveScheme->details.anySig.hashAlg != TPM_ALG_NULL\n\t\t\t       && (ecc->scheme.details.anySig.hashAlg\n\t\t\t\t   != curveScheme->details.anySig.hashAlg))\n\t\t\t\treturn TPM_RCS_SCHEME;\n\t\t\t}\n\t\t    // For now, the KDF must be TPM_ALG_NULL\n\t\t    if(publicArea->parameters.eccDetail.kdf.scheme != TPM_ALG_NULL)\n\t\t\treturn TPM_RCS_KDF;\n\t\t}\n#endif\n\t    break;\n\t}\n    // If this is a restricted decryption key with symmetric algorithms, then it\n    // is an ordinary parent (not a derivation parent). It needs to specific\n    // symmetric algorithms other than TPM_ALG_NULL\n    if(symAlgs != NULL && IS_ATTRIBUTE(attributes, TPMA_OBJECT, restricted)\n       && IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt))\n\t{\n\t    if(symAlgs->algorithm == TPM_ALG_NULL)\n\t\treturn TPM_RCS_SYMMETRIC;\n#if 0  //??\n\t    // This next check is under investigation. Need to see if it will break Windows\n\t    // before it is enabled. If it does not, then it should be default because a\n\t    // the mode used with a parent is always CFB and Part 2 indicates as much.\n\t    if(symAlgs->mode.sym != TPM_ALG_CFB)\n\t\treturn TPM_RCS_MODE;\n#endif\n\t    // If this parent is not duplicable, then the symmetric algorithms\n\t    // (encryption and hash) must match those of its parent\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedParent)\n\t       && (parentObject != NULL))\n\t\t{\n\t\t    if(publicArea->nameAlg != parentObject->publicArea.nameAlg)\n\t\t\treturn TPM_RCS_HASH;\n\t\t    if(!MemoryEqual(symAlgs,\n\t\t\t\t    &parentObject->publicArea.parameters,\n\t\t\t\t    sizeof(TPMT_SYM_DEF_OBJECT)))\n\t\t\treturn TPM_RCS_SYMMETRIC;\n\t\t}\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** PublicAttributesValidation()\n// This function validates the values in the public area of an object.\n// This function is used in the processing of TPM2_Create, TPM2_CreatePrimary,\n// TPM2_CreateLoaded(), TPM2_Load(),  TPM2_Import(), and TPM2_LoadExternal().\n// For TPM2_Import() this is only used if the new parent has fixedTPM SET. For\n// TPM2_LoadExternal(), this is not used for a public-only key\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES   'fixedTPM', 'fixedParent', or 'encryptedDuplication'\n//                          attributes are inconsistent between themselves or with\n//                          those of the parent object;\n//                          inconsistent 'restricted', 'decrypt' and 'sign'\n//                          attributes;\n//                          attempt to inject sensitive data for an asymmetric key;\n//                          attempt to create a symmetric cipher key that is not\n//                          a decryption key\n//      TPM_RC_HASH         nameAlg is TPM_ALG_NULL\n//      TPM_RC_SIZE         'authPolicy' size does not match digest size of the name\n//                          algorithm in 'publicArea'\n//   other                  returns from SchemeChecks()\nTPM_RC\nPublicAttributesValidation(\n\t\t\t   // IN: input parent object (if ordinary or derived object; NULL otherwise)\n\t\t\t   OBJECT* parentObject,\n\t\t\t   // IN: hierarchy (if primary object; 0 otherwise)\n\t\t\t   TPMI_RH_HIERARCHY primaryHierarchy,\n\t\t\t   // IN: public area of the object\n\t\t\t   TPMT_PUBLIC* publicArea)\n{\n    TPMA_OBJECT attributes       = publicArea->objectAttributes;\n    TPMA_OBJECT parentAttributes = TPMA_ZERO_INITIALIZER();\n\n    if(parentObject != NULL)\n\tparentAttributes = parentObject->publicArea.objectAttributes;\n    if(publicArea->nameAlg == TPM_ALG_NULL)\n\treturn TPM_RCS_HASH;\n    // If there is an authPolicy, it needs to be the size of the digest produced\n    // by the nameAlg of the object\n    if((publicArea->authPolicy.t.size != 0\n\t&& (publicArea->authPolicy.t.size\n\t    != CryptHashGetDigestSize(publicArea->nameAlg))))\n\treturn TPM_RCS_SIZE;\n    // If the parent is fixedTPM (including a Primary Object) the object must have\n    // the same value for fixedTPM and fixedParent\n    if(parentObject == NULL || IS_ATTRIBUTE(parentAttributes, TPMA_OBJECT, fixedTPM))\n\t{\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedParent)\n\t       != IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM))\n\t\treturn TPM_RCS_ATTRIBUTES;\n\t}\n    else\n\t{\n\t    // The parent is not fixedTPM so the object can't be fixedTPM\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM))\n\t\treturn TPM_RCS_ATTRIBUTES;\n\t}\n    // See if sign and decrypt are the same\n    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, sign)\n       == IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt))\n\t{\n\t    // a restricted key cannot have both SET or both CLEAR\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, restricted))\n\t\treturn TPM_RC_ATTRIBUTES;\n\t    // only a data object may have both sign and decrypt CLEAR\n\t    // BTW, since we know that decrypt==sign, no need to check both\n\t    if(publicArea->type != TPM_ALG_KEYEDHASH\n\t       && !IS_ATTRIBUTE(attributes, TPMA_OBJECT, sign))\n\t\treturn TPM_RC_ATTRIBUTES;\n\t}\n    // If the object can't be duplicated (directly or indirectly) then there\n    // is no justification for having encryptedDuplication SET\n    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM)\n       && IS_ATTRIBUTE(attributes, TPMA_OBJECT, encryptedDuplication))\n\treturn TPM_RCS_ATTRIBUTES;\n    // If a parent object has fixedTPM CLEAR, the child must have the\n    // same encryptedDuplication value as its parent.\n    // Primary objects are considered to have a fixedTPM parent (the seeds).\n    if(parentObject != NULL && !IS_ATTRIBUTE(parentAttributes, TPMA_OBJECT, fixedTPM))\n\t{\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, encryptedDuplication)\n\t       != IS_ATTRIBUTE(parentAttributes, TPMA_OBJECT, encryptedDuplication))\n\t\treturn TPM_RCS_ATTRIBUTES;\n\t}\n#define TPMA_OBJECT_firmwareLimited         ((TPMA_OBJECT)(1 << 8))\n#define TPMA_OBJECT_svnLimited              ((TPMA_OBJECT)(1 << 9))\n\n    // firmwareLimited/svnLimited can only be set if fixedTPM is also set.\n    if((IS_ATTRIBUTE(attributes, TPMA_OBJECT, firmwareLimited)\n\t|| IS_ATTRIBUTE(attributes, TPMA_OBJECT, svnLimited))\n       && !IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM))\n\t{\n\t    return TPM_RCS_ATTRIBUTES;\n\t}\n\n    // firmwareLimited/svnLimited also impose requirements on the parent key or\n    // primary handle.\n    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, firmwareLimited))\n\t{\n\t    if(parentObject != NULL)\n\t\t{\n\t\t    // For an ordinary object, firmwareLimited can only be set if its\n\t\t    // parent is also firmwareLimited.\n\t\t    if(!IS_ATTRIBUTE(parentAttributes, TPMA_OBJECT, firmwareLimited))\n\t\t\treturn TPM_RCS_ATTRIBUTES;\n\t\t}\n\t    else if(primaryHierarchy != 0)\n\t\t{\n\t\t    // For a primary object, firmwareLimited can only be set if its\n\t\t    // hierarchy is a firmware-limited hierarchy.\n\t\t    if(!HierarchyIsFirmwareLimited(primaryHierarchy))\n\t\t\treturn TPM_RCS_ATTRIBUTES;\n\t\t}\n\t    else\n\t\t{\n\t\t    return TPM_RCS_ATTRIBUTES;\n\t\t}\n\t}\n    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, svnLimited))\n\t{\n\t    if(parentObject != NULL)\n\t\t{\n\t\t    // For an ordinary object, svnLimited can only be set if its\n\t\t    // parent is also svnLimited.\n\t\t    if(!IS_ATTRIBUTE(parentAttributes, TPMA_OBJECT, svnLimited))\n\t\t\treturn TPM_RCS_ATTRIBUTES;\n\t\t}\n\t    else if(primaryHierarchy != 0)\n\t\t{\n\t\t    // For a primary object, svnLimited can only be set if its\n\t\t    // hierarchy is an svn-limited hierarchy.\n\t\t    if(!HierarchyIsSvnLimited(primaryHierarchy))\n\t\t\treturn TPM_RCS_ATTRIBUTES;\n\t\t}\n\t    else\n\t\t{\n\t\t    return TPM_RCS_ATTRIBUTES;\n\t\t}\n\t}\n\n    // Special checks for derived objects\n    if((parentObject != NULL) && (parentObject->attributes.derivation == SET))\n\t{\n\t    // A derived object has the same settings for fixedTPM as its parent\n\t    if(IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM)\n\t       != IS_ATTRIBUTE(parentAttributes, TPMA_OBJECT, fixedTPM))\n\t\treturn TPM_RCS_ATTRIBUTES;\n\t    // A derived object is required to be fixedParent\n\t    if(!IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedParent))\n\t\treturn TPM_RCS_ATTRIBUTES;\n\t}\n    return SchemeChecks(parentObject, publicArea);\n}\n\n//*** FillInCreationData()\n// Fill in creation data for an object.\n//  Return Type: void\nvoid FillInCreationData(\n\t\t\tTPMI_DH_OBJECT       parentHandle,   // IN: handle of parent\n\t\t\tTPMI_ALG_HASH        nameHashAlg,    // IN: name hash algorithm\n\t\t\tTPML_PCR_SELECTION*  creationPCR,    // IN: PCR selection\n\t\t\tTPM2B_DATA*          outsideData,    // IN: outside data\n\t\t\tTPM2B_CREATION_DATA* outCreation,    // OUT: creation data for output\n\t\t\tTPM2B_DIGEST*        creationDigest  // OUT: creation digest\n\t\t\t)\n{\n    BYTE       creationBuffer[sizeof(TPMS_CREATION_DATA)];\n    BYTE*      buffer;\n    HASH_STATE hashState;\n    //\n    // Fill in TPMS_CREATION_DATA in outCreation\n\n    // Compute PCR digest\n    PCRComputeCurrentDigest(\n\t\t\t    nameHashAlg, creationPCR, &outCreation->creationData.pcrDigest);\n\n    // Put back PCR selection list\n    outCreation->creationData.pcrSelect = *creationPCR;\n\n    // Get locality\n    outCreation->creationData.locality = LocalityGetAttributes(_plat__LocalityGet());\n    outCreation->creationData.parentNameAlg = TPM_ALG_NULL;\n\n    // If the parent is either a primary seed or TPM_ALG_NULL, then  the Name\n    // and QN of the parent are the parent's handle.\n    if(HandleGetType(parentHandle) == TPM_HT_PERMANENT)\n\t{\n\t    buffer = &outCreation->creationData.parentName.t.name[0];\n\t    outCreation->creationData.parentName.t.size =\n\t\tTPM_HANDLE_Marshal(&parentHandle, &buffer, NULL);\n\t    // For a primary or temporary object, the parent name (a handle) and the\n\t    // parent's QN are the same\n\t    outCreation->creationData.parentQualifiedName =\n\t\toutCreation->creationData.parentName;\n\t}\n    else  // Regular object\n\t{\n\t    OBJECT* parentObject = HandleToObject(parentHandle);\n\t    //\n\t    // Set name algorithm\n\t    outCreation->creationData.parentNameAlg = parentObject->publicArea.nameAlg;\n\n\t    // Copy parent name\n\t    outCreation->creationData.parentName = parentObject->name;\n\n\t    // Copy parent qualified name\n\t    outCreation->creationData.parentQualifiedName = parentObject->qualifiedName;\n\t}\n    // Copy outside information\n    outCreation->creationData.outsideInfo = *outsideData;\n\n    // Marshal creation data to canonical form\n    buffer = creationBuffer;\n    outCreation->size =\n\tTPMS_CREATION_DATA_Marshal(&outCreation->creationData, &buffer, NULL);\n    // Compute hash for creation field in public template\n    creationDigest->t.size = CryptHashStart(&hashState, nameHashAlg);\n    CryptDigestUpdate(&hashState, outCreation->size, creationBuffer);\n    CryptHashEnd2B(&hashState, &creationDigest->b);\n\n    return;\n}\n\n//*** GetSeedForKDF()\n// Get a seed for KDF.  The KDF for encryption and HMAC key use the same seed.\nconst TPM2B* GetSeedForKDF(OBJECT* protector  // IN: the protector handle\n\t\t\t   )\n{\n    // Get seed for encryption key.  Use input seed if provided.\n    // Otherwise, using protector object's seedValue.  TPM_RH_NULL is the only\n    // exception that we may not have a loaded object as protector.  In such a\n    // case, use nullProof as seed.\n    if(protector == NULL)\n\treturn &gr.nullProof.b;\n    else\n\treturn &protector->sensitive.seedValue.b;\n}\n\n//*** ProduceOuterWrap()\n// This function produce outer wrap for a buffer containing the sensitive data.\n// It requires the sensitive data being marshaled to the outerBuffer, with the\n// leading bytes reserved for integrity hash.  If iv is used, iv space should\n// be reserved at the beginning of the buffer.  It assumes the sensitive data\n// starts at address (outerBuffer + integrity size [+ iv size]).\n// This function performs:\n//  1. Add IV before sensitive area if required\n//  2. encrypt sensitive data, if iv is required, encrypt by iv.  otherwise,\n//     encrypted by a NULL iv\n//  3. add HMAC integrity at the beginning of the buffer\n// It returns the total size of blob with outer wrap\nUINT16\nProduceOuterWrap(OBJECT* protector,   // IN: The handle of the object that provides\n\t\t //     protection.  For object, it is parent\n\t\t //     handle. For credential, it is the handle\n\t\t //     of encrypt object.\n\t\t TPM2B*     name,     // IN: the name of the object\n\t\t TPM_ALG_ID hashAlg,  // IN: hash algorithm for outer wrap\n\t\t TPM2B*     seed,     // IN: an external seed may be provided for\n\t\t //     duplication blob. For non duplication\n\t\t //     blob, this parameter should be NULL\n\t\t BOOL   useIV,        // IN: indicate if an IV is used\n\t\t UINT16 dataSize,     // IN: the size of sensitive data, excluding the\n\t\t //     leading integrity buffer size or the\n\t\t //     optional iv size\n\t\t BYTE* outerBuffer    // IN/OUT: outer buffer with sensitive data in\n\t\t //     it\n\t\t )\n{\n    TPM_ALG_ID    symAlg;\n    UINT16        keyBits;\n    TPM2B_SYM_KEY symKey;\n    TPM2B_IV      ivRNG;  // IV from RNG\n    TPM2B_IV*     iv     = NULL;\n    UINT16        ivSize = 0;     // size of iv area, including the size field\n    BYTE*         sensitiveData;  // pointer to the sensitive data\n    TPM2B_DIGEST  integrity;\n    UINT16        integritySize;\n    BYTE*         buffer;  // Auxiliary buffer pointer\n    //\n    // Compute the beginning of sensitive data.  The outer integrity should\n    // always exist if this function is called to make an outer wrap\n    integritySize = sizeof(UINT16) + CryptHashGetDigestSize(hashAlg);\n    sensitiveData = outerBuffer + integritySize;\n\n    // If iv is used, adjust the pointer of sensitive data and add iv before it\n    if(useIV)\n\t{\n\t    ivSize = GetIV2BSize(protector);\n\n\t    // Generate IV from RNG.  The iv data size should be the total IV area\n\t    // size minus the size of size field\n\t    ivRNG.t.size = ivSize - sizeof(UINT16);\n\t    CryptRandomGenerate(ivRNG.t.size, ivRNG.t.buffer);\n\n\t    // Marshal IV to buffer\n\t    buffer = sensitiveData;\n\t    TPM2B_IV_Marshal(&ivRNG, &buffer, NULL);\n\n\t    // adjust sensitive data starting after IV area\n\t    sensitiveData += ivSize;\n\n\t    // Use iv for encryption\n\t    iv = &ivRNG;\n\t}\n    // Compute symmetric key parameters for outer buffer encryption\n    ComputeProtectionKeyParms(\n\t\t\t      protector, hashAlg, name, seed, &symAlg, &keyBits, &symKey);\n    // Encrypt inner buffer in place\n    CryptSymmetricEncrypt(sensitiveData,\n\t\t\t  symAlg,\n\t\t\t  keyBits,\n\t\t\t  symKey.t.buffer,\n\t\t\t  iv,\n\t\t\t  TPM_ALG_CFB,\n\t\t\t  dataSize,\n\t\t\t  sensitiveData);\n    // Compute outer integrity.  Integrity computation includes the optional IV\n    // area\n    ComputeOuterIntegrity(name,\n\t\t\t  protector,\n\t\t\t  hashAlg,\n\t\t\t  seed,\n\t\t\t  dataSize + ivSize,\n\t\t\t  outerBuffer + integritySize,\n\t\t\t  &integrity);\n    // Add integrity at the beginning of outer buffer\n    buffer = outerBuffer;\n    TPM2B_DIGEST_Marshal(&integrity, &buffer, NULL);\n\n    // return the total size in outer wrap\n    return dataSize + integritySize + ivSize;\n}\n\n//*** UnwrapOuter()\n// This function remove the outer wrap of a blob containing sensitive data\n// This function performs:\n//  1. check integrity of outer blob\n//  2. decrypt outer blob\n//\n//  Return Type: TPM_RC\n//      TPM_RCS_INSUFFICIENT     error during sensitive data unmarshaling\n//      TPM_RCS_INTEGRITY        sensitive data integrity is broken\n//      TPM_RCS_SIZE             error during sensitive data unmarshaling\n//      TPM_RCS_VALUE            IV size for CFB does not match the encryption\n//                               algorithm block size\nTPM_RC\nUnwrapOuter(OBJECT* protector,   // IN: The object that provides\n\t    //     protection.  For object, it is parent\n\t    //     handle. For credential, it is the\n\t    //     encrypt object.\n\t    TPM2B*     name,     // IN: the name of the object\n\t    TPM_ALG_ID hashAlg,  // IN: hash algorithm for outer wrap\n\t    TPM2B*     seed,     // IN: an external seed may be provided for\n\t    //     duplication blob. For non duplication\n\t    //     blob, this parameter should be NULL.\n\t    BOOL   useIV,        // IN: indicates if an IV is used\n\t    UINT16 dataSize,     // IN: size of sensitive data in outerBuffer,\n\t    //     including the leading integrity buffer\n\t    //     size, and an optional iv area\n\t    BYTE* outerBuffer    // IN/OUT: sensitive data\n\t    )\n{\n    TPM_RC        result;\n    TPM_ALG_ID    symAlg = TPM_ALG_NULL;\n    TPM2B_SYM_KEY symKey;\n    UINT16        keyBits = 0;\n    TPM2B_IV      ivIn;  // input IV retrieved from input buffer\n    TPM2B_IV*     iv = NULL;\n    BYTE*         sensitiveData;  // pointer to the sensitive data\n    TPM2B_DIGEST  integrityToCompare;\n    TPM2B_DIGEST  integrity;\n    INT32         size;\n    //\n    // Unmarshal integrity\n    sensitiveData = outerBuffer;\n    size          = (INT32)dataSize;\n    result        = TPM2B_DIGEST_Unmarshal(&integrity, &sensitiveData, &size);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    // Compute integrity to compare\n\t    ComputeOuterIntegrity(name,\n\t\t\t\t  protector,\n\t\t\t\t  hashAlg,\n\t\t\t\t  seed,\n\t\t\t\t  (UINT16)size,\n\t\t\t\t  sensitiveData,\n\t\t\t\t  &integrityToCompare);\n\t    // Compare outer blob integrity\n\t    if(!MemoryEqual2B(&integrity.b, &integrityToCompare.b))\n\t\treturn TPM_RCS_INTEGRITY;\n\t    // Get the symmetric algorithm parameters used for encryption\n\t    ComputeProtectionKeyParms(\n\t\t\t\t      protector, hashAlg, name, seed, &symAlg, &keyBits, &symKey);\n\t    // Retrieve IV if it is used\n\t    if(useIV)\n\t\t{\n\t\t    result = TPM2B_IV_Unmarshal(&ivIn, &sensitiveData, &size);\n\t\t    if(result == TPM_RC_SUCCESS)\n\t\t\t{\n\t\t\t    // The input iv size for CFB must match the encryption algorithm\n\t\t\t    // block size\n\t\t\t    if(ivIn.t.size != CryptGetSymmetricBlockSize(symAlg, keyBits))\n\t\t\t\tresult = TPM_RC_VALUE;\n\t\t\t    else\n\t\t\t\tiv = &ivIn;\n\t\t\t}\n\t\t}\n\t}\n    // If no errors, decrypt private in place. Since this function uses CFB,\n    // CryptSymmetricDecrypt() will not return any errors. It may fail but it will\n    // not return an error.\n    if(result == TPM_RC_SUCCESS)\n\tCryptSymmetricDecrypt(sensitiveData,\n\t\t\t      symAlg,\n\t\t\t      keyBits,\n\t\t\t      symKey.t.buffer,\n\t\t\t      iv,\n\t\t\t      TPM_ALG_CFB,\n\t\t\t      (UINT16)size,\n\t\t\t      sensitiveData);\n    return result;\n}\n\n//*** MarshalSensitive()\n// This function is used to marshal a sensitive area. Among other things, it\n// adjusts the size of the authValue to be no smaller than the digest of\n// 'nameAlg'\n// Returns the size of the marshaled area.\nstatic UINT16 MarshalSensitive(\n\t\t\t       OBJECT*         parent,     // IN: the object parent (optional)\n\t\t\t       BYTE*           buffer,     // OUT: receiving buffer\n\t\t\t       TPMT_SENSITIVE* sensitive,  // IN: the sensitive area to marshal\n\t\t\t       TPMI_ALG_HASH   nameAlg     // IN:\n\t\t\t       )\n{\n    BYTE* sizeField = buffer;  // saved so that size can be\n    // marshaled after it is known\n    UINT16 retVal;\n    //\n    // Pad the authValue if needed\n    MemoryPad2B(&sensitive->authValue.b, CryptHashGetDigestSize(nameAlg));\n    buffer += 2;\n\n    // Marshal the structure\n#if ALG_RSA\n    // If the sensitive size is the special case for a prime in the type\n    if((sensitive->sensitive.rsa.t.size & RSA_prime_flag) > 0)\n\t{\n\t    UINT16 sizeSave = sensitive->sensitive.rsa.t.size;\n\t    //\n\t    // Turn off the flag that indicates that the sensitive->sensitive contains\n\t    // the CRT form of the exponent.\n\t    sensitive->sensitive.rsa.t.size &= ~(RSA_prime_flag);\n\t    // If the parent isn't fixedTPM, then truncate the sensitive data to be\n\t    // the size of the prime. Otherwise, leave it at the current size which\n\t    // is the full CRT size.\n\t    if(parent == NULL\n\t       || !IS_ATTRIBUTE(\n\t\t\t\tparent->publicArea.objectAttributes, TPMA_OBJECT, fixedTPM))\n\t\tsensitive->sensitive.rsa.t.size /= 5;\n\t    retVal = TPMT_SENSITIVE_Marshal(sensitive, &buffer, NULL);\n\t    // Restore the flag and the size.\n\t    sensitive->sensitive.rsa.t.size = sizeSave;\n\t}\n    else\n#endif\n\tretVal = TPMT_SENSITIVE_Marshal(sensitive, &buffer, NULL);\n\n    // Marshal the size\n    retVal = (UINT16)(retVal + UINT16_Marshal(&retVal, &sizeField, NULL));\n\n    return retVal;\n}\n\n//*** SensitiveToPrivate()\n// This function prepare the private blob for off the chip storage\n// The operations in this function:\n//  1. marshal TPM2B_SENSITIVE structure into the buffer of TPM2B_PRIVATE\n//  2. apply encryption to the sensitive area.\n//  3. apply outer integrity computation.\nvoid SensitiveToPrivate(\n\t\t\tTPMT_SENSITIVE* sensitive,  // IN: sensitive structure\n\t\t\tTPM2B_NAME*     name,       // IN: the name of the object\n\t\t\tOBJECT*         parent,     // IN: The parent object\n\t\t\tTPM_ALG_ID      nameAlg,    // IN: hash algorithm in public area.  This\n\t\t\t//     parameter is used when parentHandle is\n\t\t\t//     NULL, in which case the object is\n\t\t\t//     temporary.\n\t\t\tTPM2B_PRIVATE* outPrivate   // OUT: output private structure\n\t\t\t)\n{\n    BYTE*         sensitiveData;  // pointer to the sensitive data\n    UINT16        dataSize;       // data blob size\n    TPMI_ALG_HASH hashAlg;        // hash algorithm for integrity\n    UINT16        integritySize;\n    UINT16        ivSize;\n    //\n    pAssert(name != NULL && name->t.size != 0);\n\n    // Find the hash algorithm for integrity computation\n    if(parent == NULL)\n\t{\n\t    // For Temporary Object, using self name algorithm\n\t    hashAlg = nameAlg;\n\t}\n    else\n\t{\n\t    // Otherwise, using parent's name algorithm\n\t    hashAlg = parent->publicArea.nameAlg;\n\t}\n    // Starting of sensitive data without wrappers\n    sensitiveData = outPrivate->t.buffer;\n\n    // Compute the integrity size\n    integritySize = sizeof(UINT16) + CryptHashGetDigestSize(hashAlg);\n\n    // Reserve space for integrity\n    sensitiveData += integritySize;\n\n    // Get iv size\n    ivSize = GetIV2BSize(parent);\n\n    // Reserve space for iv\n    sensitiveData += ivSize;\n\n    // Marshal the sensitive area including authValue size adjustments.\n    dataSize = MarshalSensitive(parent, sensitiveData, sensitive, nameAlg);\n\n    //Produce outer wrap, including encryption and HMAC\n    outPrivate->t.size = ProduceOuterWrap(\n\t\t\t\t\t  parent, &name->b, hashAlg, NULL, TRUE, dataSize, outPrivate->t.buffer);\n    return;\n}\n\n//*** PrivateToSensitive()\n// Unwrap an input private area; check the integrity; decrypt and retrieve data\n// to a sensitive structure.\n// The operations in this function:\n//  1. check the integrity HMAC of the input private area\n//  2. decrypt the private buffer\n//  3. unmarshal TPMT_SENSITIVE structure into the buffer of TPMT_SENSITIVE\n//\n//  Return Type: TPM_RC\n//      TPM_RCS_INTEGRITY       if the private area integrity is bad\n//      TPM_RC_SENSITIVE        unmarshal errors while unmarshaling TPMS_ENCRYPT\n//                              from input private\n//      TPM_RCS_SIZE            error during sensitive data unmarshaling\n//      TPM_RCS_VALUE           outer wrapper does not have an iV of the correct\n//                              size\nTPM_RC\nPrivateToSensitive(TPM2B*     inPrivate,  // IN: input private structure\n\t\t   TPM2B*     name,       // IN: the name of the object\n\t\t   OBJECT*    parent,     // IN: parent object\n\t\t   TPM_ALG_ID nameAlg,    // IN: hash algorithm in public area.  It is\n\t\t   //     passed separately because we only pass\n\t\t   //     name, rather than the whole public area\n\t\t   //     of the object.  This parameter is used in\n\t\t   //     the following two cases: 1. primary\n\t\t   //     objects. 2. duplication blob with inner\n\t\t   //     wrap.  In other cases, this parameter\n\t\t   //     will be ignored\n\t\t   TPMT_SENSITIVE* sensitive  // OUT: sensitive structure\n\t\t   )\n{\n    TPM_RC        result;\n    BYTE*         buffer;\n    INT32         size;\n    BYTE*         sensitiveData;  // pointer to the sensitive data\n    UINT16        dataSize;\n    UINT16        dataSizeInput;\n    TPMI_ALG_HASH hashAlg;  // hash algorithm for integrity\n    UINT16        integritySize;\n    UINT16        ivSize;\n    //\n    // Make sure that name is provided\n    pAssert(name != NULL && name->size != 0);\n\n    // Find the hash algorithm for integrity computation\n    // For Temporary Object (parent == NULL) use self name algorithm;\n    // Otherwise, using parent's name algorithm\n    hashAlg = (parent == NULL) ? nameAlg : parent->publicArea.nameAlg;\n\n    // unwrap outer\n    result = UnwrapOuter(\n\t\t\t parent, name, hashAlg, NULL, TRUE, inPrivate->size, inPrivate->buffer);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Compute the inner integrity size.\n    integritySize = sizeof(UINT16) + CryptHashGetDigestSize(hashAlg);\n\n    // Get iv size\n    ivSize = GetIV2BSize(parent);\n\n    // The starting of sensitive data and data size without outer wrapper\n    sensitiveData = inPrivate->buffer + integritySize + ivSize;\n    dataSize      = inPrivate->size - integritySize - ivSize;\n\n    // Unmarshal input data size\n    buffer = sensitiveData;\n    size   = (INT32)dataSize;\n    result = UINT16_Unmarshal(&dataSizeInput, &buffer, &size);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    if((dataSizeInput + sizeof(UINT16)) != dataSize)\n\t\tresult = TPM_RC_SENSITIVE;\n\t    else\n\t\t{\n\t\t    // Unmarshal sensitive buffer to sensitive structure\n\t\t    result = TPMT_SENSITIVE_Unmarshal(sensitive, &buffer, &size);\n\t\t    if(result != TPM_RC_SUCCESS || size != 0)\n\t\t\t{\n\t\t\t    result = TPM_RC_SENSITIVE;\n\t\t\t}\n\t\t}\n\t}\n    return result;\n}\n\n//*** SensitiveToDuplicate()\n// This function prepare the duplication blob from the sensitive area.\n// The operations in this function:\n//  1. marshal TPMT_SENSITIVE structure into the buffer of TPM2B_PRIVATE\n//  2. apply inner wrap to the sensitive area if required\n//  3. apply outer wrap if required\nvoid SensitiveToDuplicate(\n\t\t\t  TPMT_SENSITIVE* sensitive,    // IN: sensitive structure\n\t\t\t  TPM2B*          name,         // IN: the name of the object\n\t\t\t  OBJECT*         parent,       // IN: The new parent object\n\t\t\t  TPM_ALG_ID      nameAlg,      // IN: hash algorithm in public area. It\n\t\t\t  //     is passed separately because we\n\t\t\t  //     only pass name, rather than the\n\t\t\t  //     whole public area of the object.\n\t\t\t  TPM2B* seed,                  // IN: the external seed. If external\n\t\t\t  //     seed is provided with size of 0,\n\t\t\t  //     no outer wrap should be applied\n\t\t\t  //     to duplication blob.\n\t\t\t  TPMT_SYM_DEF_OBJECT* symDef,  // IN: Symmetric key definition. If the\n\t\t\t  //     symmetric key algorithm is NULL,\n\t\t\t  //     no inner wrap should be applied.\n\t\t\t  TPM2B_DATA* innerSymKey,      // IN/OUT: a symmetric key may be\n\t\t\t  //     provided to encrypt the inner\n\t\t\t  //     wrap of a duplication blob. May\n\t\t\t  //     be generated here if needed.\n\t\t\t  TPM2B_PRIVATE* outPrivate     // OUT: output private structure\n\t\t\t  )\n{\n    BYTE*         sensitiveData;             // pointer to the sensitive data\n    TPMI_ALG_HASH outerHash = TPM_ALG_NULL;  // The hash algorithm for outer wrap\n    TPMI_ALG_HASH innerHash = TPM_ALG_NULL;  // The hash algorithm for inner wrap\n    UINT16        dataSize;                  // data blob size\n    BOOL          doInnerWrap = FALSE;\n    BOOL          doOuterWrap = FALSE;\n    //\n    // Make sure that name is provided\n    pAssert(name != NULL && name->size != 0);\n\n    // Make sure symDef and innerSymKey are not NULL\n    pAssert(symDef != NULL && innerSymKey != NULL);\n\n    // Starting of sensitive data without wrappers\n    sensitiveData = outPrivate->t.buffer;\n\n    // Find out if inner wrap is required\n    if(symDef->algorithm != TPM_ALG_NULL)\n\t{\n\t    doInnerWrap = TRUE;\n\n\t    // Use self nameAlg as inner hash algorithm\n\t    innerHash = nameAlg;\n\n\t    // Adjust sensitive data pointer\n\t    sensitiveData += sizeof(UINT16) + CryptHashGetDigestSize(innerHash);\n\t}\n    // Find out if outer wrap is required\n    if(seed->size != 0)\n\t{\n\t    doOuterWrap = TRUE;\n\n\t    // Use parent nameAlg as outer hash algorithm\n\t    outerHash = parent->publicArea.nameAlg;\n\n\t    // Adjust sensitive data pointer\n\t    sensitiveData += sizeof(UINT16) + CryptHashGetDigestSize(outerHash);\n\t}\n    // Marshal sensitive area\n    dataSize = MarshalSensitive(NULL, sensitiveData, sensitive, nameAlg);\n\n    // Apply inner wrap for duplication blob.  It includes both integrity and\n    // encryption\n    if(doInnerWrap)\n\t{\n\t    BYTE* innerBuffer = NULL;\n\t    BOOL  symKeyInput = TRUE;\n\t    innerBuffer       = outPrivate->t.buffer;\n\t    // Skip outer integrity space\n\t    if(doOuterWrap)\n\t\tinnerBuffer += sizeof(UINT16) + CryptHashGetDigestSize(outerHash);\n\t    dataSize = ProduceInnerIntegrity(name, innerHash, dataSize, innerBuffer);\n\t    // Generate inner encryption key if needed\n\t    if(innerSymKey->t.size == 0)\n\t\t{\n\t\t    innerSymKey->t.size = (symDef->keyBits.sym + 7) / 8;\n\t\t    CryptRandomGenerate(innerSymKey->t.size, innerSymKey->t.buffer);\n\n\t\t    // TPM generates symmetric encryption.  Set the flag to FALSE\n\t\t    symKeyInput = FALSE;\n\t\t}\n\t    else\n\t\t{\n\t\t    // assume the input key size should matches the symmetric definition\n\t\t    pAssert(innerSymKey->t.size == (symDef->keyBits.sym + 7) / 8);\n\t\t}\n\n\t    // Encrypt inner buffer in place\n\t    CryptSymmetricEncrypt(innerBuffer,\n\t\t\t\t  symDef->algorithm,\n\t\t\t\t  symDef->keyBits.sym,\n\t\t\t\t  innerSymKey->t.buffer,\n\t\t\t\t  NULL,\n\t\t\t\t  TPM_ALG_CFB,\n\t\t\t\t  dataSize,\n\t\t\t\t  innerBuffer);\n\n\t    // If the symmetric encryption key is imported, clear the buffer for\n\t    // output\n\t    if(symKeyInput)\n\t\tinnerSymKey->t.size = 0;\n\t}\n    // Apply outer wrap for duplication blob.  It includes both integrity and\n    // encryption\n    if(doOuterWrap)\n\t{\n\t    dataSize = ProduceOuterWrap(\n\t\t\t\t\tparent, name, outerHash, seed, FALSE, dataSize, outPrivate->t.buffer);\n\t}\n    // Data size for output\n    outPrivate->t.size = dataSize;\n\n    return;\n}\n\n//*** DuplicateToSensitive()\n// Unwrap a duplication blob.  Check the integrity, decrypt and retrieve data\n// to a sensitive structure.\n// The operations in this function:\n//  1. check the integrity HMAC of the input private area\n//  2. decrypt the private buffer\n//  3. unmarshal TPMT_SENSITIVE structure into the buffer of TPMT_SENSITIVE\n//\n//  Return Type: TPM_RC\n//      TPM_RC_INSUFFICIENT      unmarshaling sensitive data from 'inPrivate' failed\n//      TPM_RC_INTEGRITY         'inPrivate' data integrity is broken\n//      TPM_RC_SIZE              unmarshaling sensitive data from 'inPrivate' failed\nTPM_RC\nDuplicateToSensitive(\n\t\t     TPM2B*     inPrivate,         // IN: input private structure\n\t\t     TPM2B*     name,              // IN: the name of the object\n\t\t     OBJECT*    parent,            // IN: the parent\n\t\t     TPM_ALG_ID nameAlg,           // IN: hash algorithm in public area.\n\t\t     TPM2B*     seed,              // IN: an external seed may be provided.\n\t\t     //     If external seed is provided with\n\t\t     //     size of 0, no outer wrap is\n\t\t     //     applied\n\t\t     TPMT_SYM_DEF_OBJECT* symDef,  // IN: Symmetric key definition. If the\n\t\t     //     symmetric key algorithm is NULL,\n\t\t     //     no inner wrap is applied\n\t\t     TPM2B* innerSymKey,           // IN: a symmetric key may be provided\n\t\t     //     to decrypt the inner wrap of a\n\t\t     //     duplication blob.\n\t\t     TPMT_SENSITIVE* sensitive     // OUT: sensitive structure\n\t\t     )\n{\n    TPM_RC result;\n    BYTE*  buffer;\n    INT32  size;\n    BYTE*  sensitiveData;  // pointer to the sensitive data\n    UINT16 dataSize;\n    UINT16 dataSizeInput;\n    //\n    // Make sure that name is provided\n    pAssert(name != NULL && name->size != 0);\n\n    // Make sure symDef and innerSymKey are not NULL\n    pAssert(symDef != NULL && innerSymKey != NULL);\n\n    // Starting of sensitive data\n    sensitiveData = inPrivate->buffer;\n    dataSize      = inPrivate->size;\n\n    // Find out if outer wrap is applied\n    if(seed->size != 0)\n\t{\n\t    // Use parent nameAlg as outer hash algorithm\n\t    TPMI_ALG_HASH outerHash = parent->publicArea.nameAlg;\n\n\t    result                  = UnwrapOuter(\n\t\t\t\t\t\t  parent, name, outerHash, seed, FALSE, dataSize, sensitiveData);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t    // Adjust sensitive data pointer and size\n\t    sensitiveData += sizeof(UINT16) + CryptHashGetDigestSize(outerHash);\n\t    dataSize -= sizeof(UINT16) + CryptHashGetDigestSize(outerHash);\n\t}\n    // Find out if inner wrap is applied\n    if(symDef->algorithm != TPM_ALG_NULL)\n\t{\n\t    // assume the input key size matches the symmetric definition\n\t    pAssert(innerSymKey->size == (symDef->keyBits.sym + 7) / 8);\n\n\t    // Decrypt inner buffer in place\n\t    CryptSymmetricDecrypt(sensitiveData,\n\t\t\t\t  symDef->algorithm,\n\t\t\t\t  symDef->keyBits.sym,\n\t\t\t\t  innerSymKey->buffer,\n\t\t\t\t  NULL,\n\t\t\t\t  TPM_ALG_CFB,\n\t\t\t\t  dataSize,\n\t\t\t\t  sensitiveData);\n\t    // Check inner integrity\n\t    result = CheckInnerIntegrity(name, nameAlg, dataSize, sensitiveData);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t    // Adjust sensitive data pointer and size\n\t    sensitiveData += sizeof(UINT16) + CryptHashGetDigestSize(nameAlg);\n\t    dataSize -= sizeof(UINT16) + CryptHashGetDigestSize(nameAlg);\n\t}\n    // Unmarshal input data size\n    buffer = sensitiveData;\n    size   = (INT32)dataSize;\n    result = UINT16_Unmarshal(&dataSizeInput, &buffer, &size);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    if((dataSizeInput + sizeof(UINT16)) != dataSize)\n\t\tresult = TPM_RC_SIZE;\n\t    else\n\t\t{\n\t\t    // Unmarshal sensitive buffer to sensitive structure\n\t\t    result = TPMT_SENSITIVE_Unmarshal(sensitive, &buffer, &size);\n\n\t\t    // if the results is OK make sure that all the data was unmarshaled\n\t\t    if(result == TPM_RC_SUCCESS && size != 0)\n\t\t\tresult = TPM_RC_SIZE;\n\t\t}\n\t}\n    return result;\n}\n\n//*** SecretToCredential()\n// This function prepare the credential blob from a secret (a TPM2B_DIGEST)\n// The operations in this function:\n//  1. marshal TPM2B_DIGEST structure into the buffer of TPM2B_ID_OBJECT\n//  2. encrypt the private buffer, excluding the leading integrity HMAC area\n//  3. compute integrity HMAC and append to the beginning of the buffer.\n//  4. Set the total size of TPM2B_ID_OBJECT buffer\nvoid SecretToCredential(TPM2B_DIGEST*    secret,      // IN: secret information\n\t\t\tTPM2B*           name,        // IN: the name of the object\n\t\t\tTPM2B*           seed,        // IN: an external seed.\n\t\t\tOBJECT*          protector,   // IN: the protector\n\t\t\tTPM2B_ID_OBJECT* outIDObject  // OUT: output credential\n\t\t\t)\n{\n    BYTE*         buffer;         // Auxiliary buffer pointer\n    BYTE*         sensitiveData;  // pointer to the sensitive data\n    TPMI_ALG_HASH outerHash;      // The hash algorithm for outer wrap\n    UINT16        dataSize;       // data blob size\n    //\n    pAssert(secret != NULL && outIDObject != NULL);\n\n    // use protector's name algorithm as outer hash ????\n    outerHash = protector->publicArea.nameAlg;\n\n    // Marshal secret area to credential buffer, leave space for integrity\n    sensitiveData = outIDObject->t.credential + sizeof(UINT16)\n\t\t    + CryptHashGetDigestSize(outerHash);\n    // Marshal secret area\n    buffer   = sensitiveData;\n    dataSize = TPM2B_DIGEST_Marshal(secret, &buffer, NULL);\n\n    // Apply outer wrap\n    outIDObject->t.size = ProduceOuterWrap(\n\tprotector, name, outerHash, seed, FALSE, dataSize, outIDObject->t.credential);\n    return;\n}\n\n//*** CredentialToSecret()\n// Unwrap a credential.  Check the integrity, decrypt and retrieve data\n// to a TPM2B_DIGEST structure.\n// The operations in this function:\n//  1. check the integrity HMAC of the input credential area\n//  2. decrypt the credential buffer\n//  3. unmarshal TPM2B_DIGEST structure into the buffer of TPM2B_DIGEST\n//\n//  Return Type: TPM_RC\n//      TPM_RC_INSUFFICIENT      error during credential unmarshaling\n//      TPM_RC_INTEGRITY         credential integrity is broken\n//      TPM_RC_SIZE              error during credential unmarshaling\n//      TPM_RC_VALUE             IV size does not match the encryption algorithm\n//                               block size\nTPM_RC\nCredentialToSecret(TPM2B*        inIDObject,  // IN: input credential blob\n\t\t   TPM2B*        name,        // IN: the name of the object\n\t\t   TPM2B*        seed,        // IN: an external seed.\n\t\t   OBJECT*       protector,   // IN: the protector\n\t\t   TPM2B_DIGEST* secret       // OUT: secret information\n\t\t   )\n{\n    TPM_RC        result;\n    BYTE*         buffer;\n    INT32         size;\n    TPMI_ALG_HASH outerHash;      // The hash algorithm for outer wrap\n    BYTE*         sensitiveData;  // pointer to the sensitive data\n    UINT16        dataSize;\n    //\n    // use protector's name algorithm as outer hash\n    outerHash = protector->publicArea.nameAlg;\n\n    // Unwrap outer, a TPM_RC_INTEGRITY error may be returned at this point\n    result = UnwrapOuter(protector,\n\t\t\t name,\n\t\t\t outerHash,\n\t\t\t seed,\n\t\t\t FALSE,\n\t\t\t inIDObject->size,\n\t\t\t inIDObject->buffer);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    // Compute the beginning of sensitive data\n\t    sensitiveData =\n\t\tinIDObject->buffer + sizeof(UINT16) + CryptHashGetDigestSize(outerHash);\n\t    dataSize =\n\t\tinIDObject->size - (sizeof(UINT16) + CryptHashGetDigestSize(outerHash));\n\t    // Unmarshal secret buffer to TPM2B_DIGEST structure\n\t    buffer = sensitiveData;\n\t    size   = (INT32)dataSize;\n\t    result = TPM2B_DIGEST_Unmarshal(secret, &buffer, &size);\n\n\t    // If there were no other unmarshaling errors, make sure that the\n\t    // expected amount of data was recovered\n\t    if(result == TPM_RC_SUCCESS && size != 0)\n\t\treturn TPM_RC_SIZE;\n\t}\n    return result;\n}\n\n//*** MemoryRemoveTrailingZeros()\n// This function is used to adjust the length of an authorization value.\n// It adjusts the size of the TPM2B so that it does not include octets\n// at the end of the buffer that contain zero.\n// The function returns the number of non-zero octets in the buffer.\nUINT16\nMemoryRemoveTrailingZeros(TPM2B_AUTH* auth  // IN/OUT: value to adjust\n\t\t\t  )\n{\n    while((auth->t.size > 0) && (auth->t.buffer[auth->t.size - 1] == 0))\n\tauth->t.size--;\n    return auth->t.size;\n}\n\n//*** SetLabelAndContext()\n// This function sets the label and context for a derived key. It is possible\n// that 'label' or 'context' can end up being an Empty Buffer.\nTPM_RC\nSetLabelAndContext(TPMS_DERIVE* labelContext,       // IN/OUT: the recovered label and\n\t\t   //      context\n\t\t   TPM2B_SENSITIVE_DATA* sensitive  // IN: the sensitive data\n\t\t   )\n{\n    TPMS_DERIVE sensitiveValue;\n    TPM_RC      result;\n    INT32       size;\n    BYTE*       buff;\n    //\n    // Unmarshal a TPMS_DERIVE from the TPM2B_SENSITIVE_DATA buffer\n    // If there is something to unmarshal...\n    if(sensitive->t.size != 0)\n\t{\n\t    size   = sensitive->t.size;\n\t    buff   = sensitive->t.buffer;\n\t    result = TPMS_DERIVE_Unmarshal(&sensitiveValue, &buff, &size);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t    // If there was a label in the public area leave it there, otherwise, copy\n\t    // the new value\n\t    if(labelContext->label.t.size == 0)\n\t\tMemoryCopy2B(&labelContext->label.b,\n\t\t\t     &sensitiveValue.label.b,\n\t\t\t     sizeof(labelContext->label.t.buffer));\n\t    // if there was a context string in publicArea, it overrides\n\t    if(labelContext->context.t.size == 0)\n\t\tMemoryCopy2B(&labelContext->context.b,\n\t\t\t     &sensitiveValue.context.b,\n\t\t\t     sizeof(labelContext->label.t.buffer));\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** UnmarshalToPublic()\n// Support function to unmarshal the template. This is used because the\n// Input may be a TPMT_TEMPLATE and that structure does not have the same\n// size as a TPMT_PUBLIC because of the difference between the 'unique' and\n// 'seed' fields.\n// If 'derive' is not NULL, then the 'seed' field is assumed to contain\n// a 'label' and 'context' that are unmarshaled into 'derive'.\nTPM_RC\nUnmarshalToPublic(TPMT_PUBLIC*    tOut,  // OUT: output\n\t\t  TPM2B_TEMPLATE* tIn,   // IN:\n\t\t  BOOL derivation,       // IN: indicates if this is for a derivation\n\t\t  TPMS_DERIVE* labelContext  // OUT: label and context if derivation\n\t\t  )\n{\n    BYTE*  buffer = tIn->t.buffer;\n    INT32  size   = tIn->t.size;\n    TPM_RC result;\n    //\n    // make sure that tOut is zeroed so that there are no remnants from previous\n    // uses\n    MemorySet(tOut, 0, sizeof(TPMT_PUBLIC));\n    // Unmarshal the components of the TPMT_PUBLIC up to the unique field\n    result = TPMI_ALG_PUBLIC_Unmarshal(&tOut->type, &buffer, &size);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    result = TPMI_ALG_HASH_Unmarshal(&tOut->nameAlg, &buffer, &size, FALSE);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    result = TPMA_OBJECT_Unmarshal(&tOut->objectAttributes, &buffer, &size);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    result = TPM2B_DIGEST_Unmarshal(&tOut->authPolicy, &buffer, &size);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    result =\n\tTPMU_PUBLIC_PARMS_Unmarshal(&tOut->parameters, &buffer, &size, tOut->type);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // Now unmarshal a TPMS_DERIVE if this is for derivation\n    if(derivation)\n\tresult = TPMS_DERIVE_Unmarshal(labelContext, &buffer, &size);\n    else\n\t// otherwise, unmarshal a TPMU_PUBLIC_ID\n\tresult = TPMU_PUBLIC_ID_Unmarshal(&tOut->unique, &buffer, &size, tOut->type);\n    // Make sure the template was used up\n    if((result == TPM_RC_SUCCESS) && (size != 0))\n\tresult = TPM_RC_SIZE;\n    return result;\n}\n\n//*** ObjectSetExternal()\n// Set the external attributes for an object.\nvoid ObjectSetExternal(OBJECT* object)\n{\n    object->attributes.external = SET;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/PCR.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   PCR access and manipulation \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// This function contains the functions needed for PCR access and manipulation.\n//\n// This implementation uses a static allocation for the PCR. The amount of\n// memory is allocated based on the number of PCR in the implementation and\n// the number of implemented hash algorithms. This is not the expected\n// implementation. PCR SPACE DEFINITIONS.\n//\n// In the definitions below, the g_hashPcrMap is a bit array that indicates\n// which of the PCR are implemented. The g_hashPcr array is an array of digests.\n// In this implementation, the space is allocated whether the PCR is implemented\n// or not.\n\n//** Includes, Defines, and Data Definitions\n#define PCR_C\n#include \"Tpm.h\"\n\n// verify values from pcrstruct.h. not <= because group #0 is reserved\n// indicating no auth/policy support\nTPM_STATIC_ASSERT(NUM_AUTHVALUE_PCR_GROUP < (1 << MAX_PCR_GROUP_BITS));\nTPM_STATIC_ASSERT(NUM_POLICY_PCR_GROUP < (1 << MAX_PCR_GROUP_BITS));\n\n//** Functions\n\n//*** PCRBelongsAuthGroup()\n// This function indicates if a PCR belongs to a group that requires an authValue\n// in order to modify the PCR.  If it does, 'groupIndex' is set to value of\n// the group index.  This feature of PCR is decided by the platform specification.\n//\n//  Return Type: BOOL\n//      TRUE(1)         PCR belongs an authorization group\n//      FALSE(0)        PCR does not belong an authorization group\nBOOL PCRBelongsAuthGroup(TPMI_DH_PCR handle,     // IN: handle of PCR\n\t\t\t UINT32*     groupIndex  // OUT: group array index if PCR\n\t\t\t //      belongs to a group that allows authValue.  If PCR\n\t\t\t //      does not belong to an authorization\n\t\t\t //      group, the value in this parameter is zero\n\t\t\t )\n{\n    *groupIndex = 0;\n\n#if defined NUM_AUTHVALUE_PCR_GROUP && NUM_AUTHVALUE_PCR_GROUP > 0\n    // Platform specification determines to which authorization group a PCR belongs\n    // (if any). In this implementation, we assume there is only\n    // one authorization group which contains PCR[20-22].  If the platform\n    // specification requires differently, the implementation should be changed\n    // accordingly\n    UINT32         pcr = handle - PCR_FIRST;\n    PCR_Attributes currentPcrAttributes =\n\t_platPcr__GetPcrInitializationAttributes(pcr);\n\n    if(currentPcrAttributes.authValuesGroup != 0)\n\t{\n\t    // turn 1-based group number into actual array index expected by callers\n\t    *groupIndex = currentPcrAttributes.authValuesGroup - 1;\n\t    pAssert_BOOL(*groupIndex < NUM_AUTHVALUE_PCR_GROUP);\n\t    return TRUE;\n\t}\n\n#endif\n    return FALSE;\n}\n\n//*** PCRBelongsPolicyGroup()\n// This function indicates if a PCR belongs to a group that requires a policy\n// authorization in order to modify the PCR.  If it does, 'groupIndex' is set\n// to value of the group index.  This feature of PCR is decided by the platform\n// specification.\n// return type: BOOL\n//      TRUE:           PCR belongs a policy group\n//      FALSE:          PCR does not belong a policy group\nBOOL PCRBelongsPolicyGroup(\n\t\t\t   TPMI_DH_PCR handle,     // IN: handle of PCR\n\t\t\t   UINT32*     groupIndex  // OUT: group index if PCR belongs a group that\n\t\t\t   //     allows policy.  If PCR does not belong to\n\t\t\t   //     a policy group, the value in this\n\t\t\t   //     parameter is zero\n\t\t\t   )\n{\n    *groupIndex = 0;\n\n#if defined NUM_POLICY_PCR_GROUP && NUM_POLICY_PCR_GROUP > 0\n    // Platform specification decides if a PCR belongs to a policy group and\n    // belongs to which group.\n    UINT32         pcr = handle - PCR_FIRST;\n    PCR_Attributes currentPcrAttributes =\n\t_platPcr__GetPcrInitializationAttributes(pcr);\n    if(currentPcrAttributes.policyAuthGroup != 0)\n\t{\n\t    // turn 1-based group number into actual array index expected by callers\n\t    *groupIndex = currentPcrAttributes.policyAuthGroup - 1;\n\t    pAssert_BOOL(*groupIndex < NUM_POLICY_PCR_GROUP);\n\t    return TRUE;\n\t}\n#endif\n    return FALSE;\n}\n\n//*** PCRBelongsTCBGroup()\n// This function indicates if a PCR belongs to the TCB group.\n// return type: BOOL\n//      TRUE:           PCR belongs to TCB group\n//      FALSE:          PCR does not belong to TCB group\nstatic BOOL PCRBelongsTCBGroup(TPMI_DH_PCR handle  // IN: handle of PCR\n\t\t\t       )\n{\n#if ENABLE_PCR_NO_INCREMENT == YES\n    // Platform specification decides if a PCR belongs to a TCB group.\n    UINT32         pcr = handle - PCR_FIRST;\n    PCR_Attributes currentPcrAttributes =\n\t_platPcr__GetPcrInitializationAttributes(pcr);\n    return currentPcrAttributes.doNotIncrementPcrCounter;\n#else\n    return FALSE;\n#endif\n}\n\n//*** PCRPolicyIsAvailable()\n// This function indicates if a policy is available for a PCR.\n// return type: BOOL\n//      TRUE        the PCR may be authorized by policy\n//      FALSE       the PCR does not allow policy\nBOOL PCRPolicyIsAvailable(TPMI_DH_PCR handle  // IN: PCR handle\n\t\t\t  )\n{\n    UINT32 groupIndex;\n\n    return PCRBelongsPolicyGroup(handle, &groupIndex);\n}\n\n//*** PCRGetAuthValue()\n// This function is used to access the authValue of a PCR.  If PCR does not\n// belong to an authValue group, an EmptyAuth will be returned.\nTPM2B_AUTH* PCRGetAuthValue(TPMI_DH_PCR handle  // IN: PCR handle\n\t\t\t    )\n{\n    UINT32 groupIndex;\n\n    if(PCRBelongsAuthGroup(handle, &groupIndex))\n\t{\n\t    return &gc.pcrAuthValues.auth[groupIndex];\n\t}\n    else\n\t{\n\t    return NULL;\n\t}\n}\n\n//*** PCRGetAuthPolicy()\n// This function is used to access the authorization policy of a PCR. It sets\n// 'policy' to the authorization policy and returns the hash algorithm for policy\n//  If the PCR does not allow a policy, TPM_ALG_NULL is returned.\nTPMI_ALG_HASH\nPCRGetAuthPolicy(TPMI_DH_PCR   handle,  // IN: PCR handle\n\t\t TPM2B_DIGEST* policy   // OUT: policy of PCR\n\t\t )\n{\n    UINT32 groupIndex;\n\n    if(PCRBelongsPolicyGroup(handle, &groupIndex))\n\t{\n\t    *policy = gp.pcrPolicies.policy[groupIndex];\n\t    return gp.pcrPolicies.hashAlg[groupIndex];\n\t}\n    else\n\t{\n\t    policy->t.size = 0;\n\t    return TPM_ALG_NULL;\n\t}\n}\n\n//*** PCRManufacture()\n// This function is used to initialize the policies when a TPM is manufactured.\n// This function would only be called in a manufacturing environment or in\n// a TPM simulator.\nvoid PCRManufacture(void)\n{\n    UINT32 i;\n#if defined NUM_POLICY_PCR_GROUP && NUM_POLICY_PCR_GROUP > 0\n    for(i = 0; i < NUM_POLICY_PCR_GROUP; i++)\n\t{\n\t    gp.pcrPolicies.hashAlg[i]       = TPM_ALG_NULL;\n\t    gp.pcrPolicies.policy[i].t.size = 0;\n\t}\n#endif\n#if defined NUM_AUTHVALUE_PCR_GROUP && NUM_AUTHVALUE_PCR_GROUP > 0\n    for(i = 0; i < NUM_AUTHVALUE_PCR_GROUP; i++)\n\t{\n\t    gc.pcrAuthValues.auth[i].t.size = 0;\n\t}\n#endif\n    // We need to give an initial configuration on allocated PCR before\n    // receiving any TPM2_PCR_Allocate command to change this configuration\n    // When the simulation environment starts, we allocate all the PCRs\n    for(gp.pcrAllocated.count = 0; gp.pcrAllocated.count < HASH_COUNT;\n\tgp.pcrAllocated.count++)\n\t{\n\t    TPM_ALG_ID currentBank  = CryptHashGetAlgByIndex(gp.pcrAllocated.count);\n\t    BOOL       isBankActive = _platPcr_IsPcrBankDefaultActive(currentBank);\n\n\t    gp.pcrAllocated.pcrSelections[gp.pcrAllocated.count].hash = currentBank;\n\n\t    gp.pcrAllocated.pcrSelections[gp.pcrAllocated.count].sizeofSelect =\n\t\tPCR_SELECT_MAX;\n\t    for(i = 0; i < PCR_SELECT_MAX; i++)\n\t\t{\n\t\t    gp.pcrAllocated.pcrSelections[gp.pcrAllocated.count].pcrSelect[i] =\n\t\t\tisBankActive ? 0xFF : 0;\n\t\t}\n\t}\n\n    // Store the initial configuration to NV\n    NV_SYNC_PERSISTENT(pcrPolicies);\n    NV_SYNC_PERSISTENT(pcrAllocated);\n\n    return;\n}\n\n//*** GetSavedPcrPointer()\n// This function returns the address of an array of state saved PCR based\n// on the hash algorithm.\n//\n//  Return Type: BYTE *\n//      NULL            no such algorithm\n//      != NULL         pointer to the 0th byte of the 0th PCR\nstatic BYTE* GetSavedPcrPointer(TPM_ALG_ID alg,      // IN: algorithm for bank\n\t\t\t\tUINT32     pcrIndex  // IN: PCR index in PCR_SAVE\n\t\t\t\t)\n{\n    BYTE* retVal = NULL;\n    switch(alg)\n\t{\n#define HASH_CASE(HASH, Hash)\t\t\t\t\t\\\n\t    case TPM_ALG_##HASH:\t\t\t\t\\\n\t      retVal = gc.pcrSave.Hash[pcrIndex];\t\t\\\n\t      break;\n\n\t    FOR_EACH_HASH(HASH_CASE)\n#undef HASH_CASE\n\n\t  default:\n\t    FAIL_NULL(FATAL_ERROR_INTERNAL);\n\t}\n    return retVal;\n}\n\n//*** PcrIsAllocated()\n// This function indicates if a PCR number for the particular hash algorithm\n// is allocated.\n//  Return Type: BOOL\n//      TRUE(1)         PCR is allocated\n//      FALSE(0)        PCR is not allocated\nBOOL PcrIsAllocated(UINT32        pcr,     // IN: The number of the PCR\n\t\t    TPMI_ALG_HASH hashAlg  // IN: The PCR algorithm\n\t\t    )\n{\n    UINT32 i;\n    BOOL   allocated = FALSE;\n\n    if(pcr < IMPLEMENTATION_PCR)\n\t{\n\t    for(i = 0; i < gp.pcrAllocated.count; i++)\n\t\t{\n\t\t    if(gp.pcrAllocated.pcrSelections[i].hash == hashAlg)\n\t\t\t{\n\t\t\t    if(((gp.pcrAllocated.pcrSelections[i].pcrSelect[pcr / 8])\n\t\t\t\t& (1 << (pcr % 8)))\n\t\t\t       != 0)\n\t\t\t\tallocated = TRUE;\n\t\t\t    else\n\t\t\t\tallocated = FALSE;\n\t\t\t    break;\n\t\t\t}\n\t\t}\n\t}\n    return allocated;\n}\n\n// Get pointer to particular PCR from bank (array)\n// CAUTION: This function does not validate the pcrNumber\n// vs the size of the array.\n// See Also: GetPcrPointerIfAllocated\nstatic BYTE* GetPcrPointerFromPcrArray(PCR*       pPcrArray,\n\t\t\t\t       TPM_ALG_ID alg,       // IN: algorithm for bank\n\t\t\t\t       UINT32     pcrNumber  // IN: PCR number\n\t\t\t\t       )\n{\n    switch(alg)\n\t{\n#if ALG_SHA1\n\t  case TPM_ALG_SHA1:\n\t    return pPcrArray[pcrNumber].Sha1Pcr;\n#endif\n#if ALG_SHA256\n\t  case TPM_ALG_SHA256:\n\t    return pPcrArray[pcrNumber].Sha256Pcr;\n#endif\n#if ALG_SHA384\n\t  case TPM_ALG_SHA384:\n\t    return pPcrArray[pcrNumber].Sha384;\n#endif\n#if ALG_SHA512\n\t  case TPM_ALG_SHA512:\n\t    return pPcrArray[pcrNumber].Sha512;\n#endif\n#if ALG_SM3_256\n\t  case TPM_ALG_SM3_256:\n\t    return pPcrArray[pcrNumber].Sm3_256;\n#endif\n#if ALG_SHA3_256\n\t  case TPM_ALG_SHA3_256:\n\t    return pPcrArray[pcrNumber].Sha3_256;\n#endif\n#if ALG_SHA3_384\n\t  case TPM_ALG_SHA3_384:\n\t    return pPcrArray[pcrNumber].Sha3_384;\n#endif\n#if ALG_SHA3_512\n\t  case TPM_ALG_SHA3_512:\n\t    return pPcrArray[pcrNumber].Sha3_512;\n#endif\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    return NULL;\n}\n\nBYTE* GetPcrPointerIfAllocated(PCR*       pPcrArray,\n\t\t\t       TPM_ALG_ID alg,       // IN: algorithm for bank\n\t\t\t       UINT32     pcrNumber  // IN: PCR number\n\t\t\t       )\n{\n    //\n    if(!PcrIsAllocated(pcrNumber, alg))\n\treturn NULL;\n\n    return GetPcrPointerFromPcrArray(pPcrArray,\n\t\t\t\t     alg,       // IN: algorithm for bank\n\t\t\t\t     pcrNumber  // IN: PCR number\n\t\t\t\t     );\n}\n\n//*** GetPcrPointer()\n// This function returns the address of an array of PCR based on the\n// hash algorithm.\n//\n//  Return Type: BYTE *\n//      NULL            no such algorithm\n//      != NULL         pointer to the 0th byte of the requested PCR\nBYTE* GetPcrPointer(TPM_ALG_ID alg,       // IN: algorithm for bank\n\t\t    UINT32     pcrNumber  // IN: PCR number\n\t\t    )\n{\n    return GetPcrPointerIfAllocated(s_pcrs, alg, pcrNumber);\n}\n\n//*** IsPcrSelected()\n// This function indicates if an indicated PCR number is selected by the bit map in\n// 'selection'.\n//\n//  Return Type: BOOL\n//      TRUE(1)         PCR is selected\n//      FALSE(0)        PCR is not selected\nstatic BOOL IsPcrSelected(\n\t\t\t  UINT32              pcr,       // IN: The number of the PCR\n\t\t\t  TPMS_PCR_SELECTION* selection  // IN: The selection structure\n\t\t\t  )\n{\n    BOOL selected;\n    selected = (pcr < IMPLEMENTATION_PCR\n\t\t&& ((selection->pcrSelect[pcr / 8]) & (1 << (pcr % 8))) != 0);\n    return selected;\n}\n\n//*** FilterPcr()\n// This function modifies a PCR selection array based on the implemented\n// PCR.\nstatic void FilterPcr(TPMS_PCR_SELECTION* selection  // IN: input PCR selection\n\t\t      )\n{\n    UINT32              i;\n    TPMS_PCR_SELECTION* allocated = NULL;\n\n    // If size of select is less than PCR_SELECT_MAX, zero the unspecified PCR\n    for(i = selection->sizeofSelect; i < PCR_SELECT_MAX; i++)\n\tselection->pcrSelect[i] = 0;\n\n    // Find the internal configuration for the bank\n    for(i = 0; i < gp.pcrAllocated.count; i++)\n\t{\n\t    if(gp.pcrAllocated.pcrSelections[i].hash == selection->hash)\n\t\t{\n\t\t    allocated = &gp.pcrAllocated.pcrSelections[i];\n\t\t    break;\n\t\t}\n\t}\n\n    for(i = 0; i < selection->sizeofSelect; i++)\n\t{\n\t    if(allocated == NULL)\n\t\t{\n\t\t    // If the required bank does not exist, clear input selection\n\t\t    selection->pcrSelect[i] = 0;\n\t\t}\n\t    else\n\t\tselection->pcrSelect[i] &= allocated->pcrSelect[i];\n\t}\n\n    return;\n}\n\n//*** PcrDrtm()\n// This function does the DRTM and H-CRTM processing it is called from\n// _TPM_Hash_End.\nvoid PcrDrtm(const TPMI_DH_PCR pcrHandle,  // IN: the index of the PCR to be\n\t     //     modified\n\t     const TPMI_ALG_HASH hash,     // IN: the bank identifier\n\t     const TPM2B_DIGEST* digest    // IN: the digest to modify the PCR\n\t     )\n{\n    BYTE* pcrData = GetPcrPointer(hash, pcrHandle);\n\n    if(pcrData != NULL)\n\t{\n\t    // Rest the PCR to zeros\n\t    MemorySet(pcrData, 0, digest->t.size);\n\n\t    // if the TPM has not started, then set the PCR to 0...04 and then extend\n\t    if(!TPMIsStarted())\n\t\t{\n\t\t    pcrData[digest->t.size - 1] = 4;\n\t\t}\n\t    // Now, extend the value\n\t    PCRExtend(pcrHandle, hash, digest->t.size, (BYTE*)digest->t.buffer);\n\t}\n}\n\n//*** PCR_ClearAuth()\n// This function is used to reset the PCR authorization values. It is called\n// on TPM2_Startup(CLEAR) and TPM2_Clear().\nvoid PCR_ClearAuth(void)\n{\n#if defined NUM_AUTHVALUE_PCR_GROUP && NUM_AUTHVALUE_PCR_GROUP > 0\n    int j;\n    for(j = 0; j < NUM_AUTHVALUE_PCR_GROUP; j++)\n\t{\n\t    gc.pcrAuthValues.auth[j].t.size = 0;\n\t}\n#endif\n}\n\n//*** PCRStartup()\n// This function initializes the PCR subsystem at TPM2_Startup().\nBOOL PCRStartup(STARTUP_TYPE type,     // IN: startup type\n\t\tBYTE         locality  // IN: startup locality\n\t\t)\n{\n    UINT32 pcr, j;\n    UINT32 saveIndex = 0;\n\n    g_pcrReConfig    = FALSE;\n\n    // Don't test for SU_RESET because that should be the default when nothing\n    // else is selected\n    if(type != SU_RESUME && type != SU_RESTART)\n\t{\n\t    // PCR generation counter is cleared at TPM_RESET\n\t    gr.pcrCounter = 0;\n\t}\n\n    // check the TPM library and platform are properly paired.\n    // if this fails the platform and library are compiled with different\n    // definitions of the number of PCRs - immediately enter FAILURE mode and\n    // return FALSE\n    pAssert_BOOL(_platPcr__NumberOfPcrs() == IMPLEMENTATION_PCR);\n\n    // Initialize/Restore PCR values\n    for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)\n\t{\n\t    // On resume, need to know if this PCR had its state saved or not\n\t    UINT32 stateSaved;\n\t    // note structure is a bitfield and returned by value.\n\t    PCR_Attributes currentPcrAttributes =\n\t\t_platPcr__GetPcrInitializationAttributes(pcr);\n\n\t    if(type == SU_RESUME && currentPcrAttributes.stateSave == SET)\n\t\t{\n\t\t    stateSaved = 1;\n\t\t}\n\t    else\n\t\t{\n\t\t    stateSaved = 0;\n\t\t    PCRChanged(pcr);\n\t\t}\n\n\t    // If this is the H-CRTM PCR and we are not doing a resume and we\n\t    // had an H-CRTM event, then we don't change this PCR\n\t    if(pcr == HCRTM_PCR && type != SU_RESUME && g_DrtmPreStartup == TRUE)\n\t\tcontinue;\n\n\t    // Iterate each hash algorithm bank\n\t    for(j = 0; j < gp.pcrAllocated.count; j++)\n\t\t{\n\t\t    TPMI_ALG_HASH hash    = gp.pcrAllocated.pcrSelections[j].hash;\n\t\t    BYTE*         pcrData = GetPcrPointer(hash, pcr);\n\t\t    UINT16        pcrSize = CryptHashGetDigestSize(hash);\n\t\t    if(pcrData != NULL)\n\t\t\t{\n\t\t\t    // if state was saved\n\t\t\t    if(stateSaved == 1)\n\t\t\t\t{\n\t\t\t\t    // Restore saved PCR value\n\t\t\t\t    BYTE* pcrSavedData;\n\t\t\t\t    pcrSavedData = GetSavedPcrPointer(hash, saveIndex);\n\t\t\t\t    if(pcrSavedData == NULL)\n\t\t\t\t\treturn FALSE;\n\t\t\t\t    MemoryCopy(pcrData, pcrSavedData, pcrSize);\n\t\t\t\t}\n\t\t\t    else  // PCR was not restored by state save\n\t\t\t\t{\n\t\t\t\t    // give platform opportunity to provide the PCR initialization\n\t\t\t\t    // value and it's length. this provides a platform specification\n\t\t\t\t    // the ability to change the default values without affecting the\n\t\t\t\t    // core library. if the platform doesn't have a value, then the\n\t\t\t\t    // result is expected to be TPM_RC_PCR and the size to be 0 and we\n\t\t\t\t    // provide the original defaults.\n\t\t\t\t    uint16_t pcrLength        = 0;\n\t\t\t\t    TPM_RC   pcrInitialResult = _platPcr__GetInitialValueForPcr(\n\t\t\t\t\tpcr, hash, locality, pcrData, pcrSize, &pcrLength);\n\n\t\t\t\t    // any other result is a fatal error\n\t\t\t\t    pAssert_BOOL(pcrInitialResult == TPM_RC_SUCCESS\n\t\t\t\t\t\t || pcrInitialResult == TPM_RC_PCR);\n\t\t\t\t    if(pcrInitialResult == TPM_RC_SUCCESS && pcrLength == pcrSize)\n\t\t\t\t\t{\n\t\t\t\t\t    // just use the PCR initialized by platform\n\t\t\t\t\t}\n\t\t\t\t    else\n\t\t\t\t\t{\n\t\t\t\t\t    // If the reset locality contains locality 4, then this\n\t\t\t\t\t    // indicates a DRTM PCR where the reset value is all ones,\n\t\t\t\t\t    // otherwise it is all zero.  Don't check with equal because\n\t\t\t\t\t    // resetLocality is a bitfield of multiple values and does\n\t\t\t\t\t    // not support extended localities.\n\t\t\t\t\t    BYTE defaultValue = 0;\n\t\t\t\t\t    if((currentPcrAttributes.resetLocality & 0x10) != 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t    defaultValue = 0xFF;\n\t\t\t\t\t\t}\n\t\t\t\t\t    MemorySet(pcrData, defaultValue, pcrSize);\n\t\t\t\t\t    if(pcr == HCRTM_PCR)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t    pcrData[pcrSize - 1] = locality;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t    saveIndex += stateSaved;\n\t}\n    // Reset authValues on TPM2_Startup(CLEAR)\n    if(type != SU_RESUME)\n\tPCR_ClearAuth();\n    return TRUE;\n}\n\n//*** PCRStateSave()\n// This function is used to save the PCR values that will be restored on TPM Resume.\nvoid PCRStateSave(TPM_SU type  // IN: startup type\n\t\t  )\n{\n    UINT32 pcr, j;\n    UINT32 saveIndex = 0;\n\n    // if state save CLEAR, nothing to be done.  Return here\n    if(type == TPM_SU_CLEAR)\n\treturn;\n\n    // Copy PCR values to the structure that should be saved to NV\n    for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)\n\t{\n\t    PCR_Attributes currentPcrAttributes =\n\t\t_platPcr__GetPcrInitializationAttributes(pcr);\n\n\t    UINT32 stateSaved = (currentPcrAttributes.stateSave == SET) ? 1 : 0;\n\n\t    // Iterate each hash algorithm bank\n\t    for(j = 0; j < gp.pcrAllocated.count; j++)\n\t\t{\n\t\t    BYTE*  pcrData;\n\t\t    UINT32 pcrSize;\n\n\t\t    pcrData = GetPcrPointer(gp.pcrAllocated.pcrSelections[j].hash, pcr);\n\n\t\t    if(pcrData != NULL)\n\t\t\t{\n\t\t\t    pcrSize =\n\t\t\t\tCryptHashGetDigestSize(gp.pcrAllocated.pcrSelections[j].hash);\n\n\t\t\t    if(stateSaved == 1)\n\t\t\t\t{\n\t\t\t\t    // Restore saved PCR value\n\t\t\t\t    BYTE* pcrSavedData;\n\t\t\t\t    pcrSavedData = GetSavedPcrPointer(\n\t\t\t\t\t\t\t\t      gp.pcrAllocated.pcrSelections[j].hash, saveIndex);\n\t\t\t\t    MemoryCopy(pcrSavedData, pcrData, pcrSize);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t    saveIndex += stateSaved;\n\t}\n\n    return;\n}\n\n//*** PCRIsStateSaved()\n// This function indicates if the selected PCR is a PCR that is state saved\n// on TPM2_Shutdown(STATE). The return value is based on PCR attributes.\n//  Return Type: BOOL\n//      TRUE(1)         PCR is state saved\n//      FALSE(0)        PCR is not state saved\nBOOL PCRIsStateSaved(TPMI_DH_PCR handle  // IN: PCR handle to be extended\n\t\t     )\n{\n    UINT32         pcr = handle - PCR_FIRST;\n    PCR_Attributes currentPcrAttributes =\n\t_platPcr__GetPcrInitializationAttributes(pcr);\n\n    if(currentPcrAttributes.stateSave == SET)\n\treturn TRUE;\n    else\n\treturn FALSE;\n}\n\n//*** PCRIsResetAllowed()\n// This function indicates if a PCR may be reset by the current command locality.\n// The return value is based on PCR attributes, and not the PCR allocation.\n//  Return Type: BOOL\n//      TRUE(1)         TPM2_PCR_Reset is allowed\n//      FALSE(0)        TPM2_PCR_Reset is not allowed\nBOOL PCRIsResetAllowed(TPMI_DH_PCR handle  // IN: PCR handle to be extended\n\t\t       )\n{\n    UINT8          commandLocality;\n    UINT8          localityBits = 1;\n    UINT32         pcr          = handle - PCR_FIRST;\n    PCR_Attributes currentPcrAttributes =\n\t_platPcr__GetPcrInitializationAttributes(pcr);\n\n    // Check for the locality\n    commandLocality = _plat__LocalityGet();\n\n#ifdef DRTM_PCR\n    // For a TPM that does DRTM, Reset is not allowed at locality 4\n    if(commandLocality == 4)\n\treturn FALSE;\n#endif\n\n    localityBits = localityBits << commandLocality;\n    if((localityBits & currentPcrAttributes.resetLocality) == 0)\n\treturn FALSE;\n    else\n\treturn TRUE;\n}\n\n//*** PCRChanged()\n// This function checks a PCR handle to see if the attributes for the PCR are set\n// so that any change to the PCR causes an increment of the pcrCounter. If it does,\n// then the function increments the counter. Will also bump the counter if the\n// handle is zero which means that PCR 0 can not be in the TCB group. Bump on zero\n// is used by TPM2_Clear().\nvoid PCRChanged(TPM_HANDLE pcrHandle  // IN: the handle of the PCR that changed.\n\t\t)\n{\n    // For the reference implementation, the only change that does not cause\n    // increment is a change to a PCR in the TCB group.\n    if((pcrHandle == 0) || !PCRBelongsTCBGroup(pcrHandle))\n\t{\n\t    gr.pcrCounter++;\n\t    if(gr.pcrCounter == 0)\n\t\tFAIL(FATAL_ERROR_COUNTER_OVERFLOW);\n\t}\n}\n\n//*** PCRIsExtendAllowed()\n// This function indicates a PCR may be extended at the current command locality.\n// The return value is based on PCR attributes, and not the PCR allocation.\n//  Return Type: BOOL\n//      TRUE(1)         extend is allowed\n//      FALSE(0)        extend is not allowed\nBOOL PCRIsExtendAllowed(TPMI_DH_PCR handle  // IN: PCR handle to be extended\n\t\t\t)\n{\n    UINT8          commandLocality;\n    UINT8          localityBits = 1;\n    UINT32         pcr          = handle - PCR_FIRST;\n    PCR_Attributes currentPcrAttributes =\n\t_platPcr__GetPcrInitializationAttributes(pcr);\n\n    // Check for the locality\n    commandLocality = _plat__LocalityGet();\n    localityBits    = localityBits << commandLocality;\n    if((localityBits & currentPcrAttributes.extendLocality) == 0)\n\treturn FALSE;\n    else\n\treturn TRUE;\n}\n\n//*** PCRExtend()\n// This function is used to extend a PCR in a specific bank.\nvoid PCRExtend(TPMI_DH_PCR   handle,  // IN: PCR handle to be extended\n\t       TPMI_ALG_HASH hash,    // IN: hash algorithm of PCR\n\t       UINT32        size,    // IN: size of data to be extended\n\t       BYTE*         data     // IN: data to be extended\n\t       )\n{\n    BYTE*      pcrData;\n    HASH_STATE hashState;\n    UINT16     pcrSize;\n\n    pcrData = GetPcrPointer(hash, handle - PCR_FIRST);\n\n    // Extend PCR if it is allocated\n    if(pcrData != NULL)\n\t{\n\t    pcrSize = CryptHashGetDigestSize(hash);\n\t    CryptHashStart(&hashState, hash);\n\t    CryptDigestUpdate(&hashState, pcrSize, pcrData);\n\t    CryptDigestUpdate(&hashState, size, data);\n\t    CryptHashEnd(&hashState, pcrSize, pcrData);\n\n\t    // PCR has changed so update the pcrCounter if necessary\n\t    PCRChanged(handle);\n\t}\n\n    return;\n}\n\n//*** PCRComputeCurrentDigest()\n// This function computes the digest of the selected PCR.\n//\n// As a side-effect, 'selection' is modified so that only the implemented PCR\n// will have their bits still set.\nvoid PCRComputeCurrentDigest(\n\t\t\t     TPMI_ALG_HASH       hashAlg,    // IN: hash algorithm to compute digest\n\t\t\t     TPML_PCR_SELECTION* selection,  // IN/OUT: PCR selection (filtered on\n\t\t\t     //     output)\n\t\t\t     TPM2B_DIGEST* digest            // OUT: digest\n\t\t\t     )\n{\n    HASH_STATE          hashState;\n    TPMS_PCR_SELECTION* select;\n    BYTE*               pcrData;  // will point to a digest\n    UINT32              pcrSize;\n    UINT32              pcr;\n    UINT32              i;\n\n    // Initialize the hash\n    digest->t.size = CryptHashStart(&hashState, hashAlg);\n    pAssert(digest->t.size > 0 && digest->t.size < UINT16_MAX);\n\n    // Iterate through the list of PCR selection structures\n    for(i = 0; i < selection->count; i++)\n\t{\n\t    // Point to the current selection\n\t    select = &selection->pcrSelections[i];  // Point to the current selection\n\t    FilterPcr(select);  // Clear out the bits for unimplemented PCR\n\n\t    // Need the size of each digest\n\t    pcrSize = CryptHashGetDigestSize(selection->pcrSelections[i].hash);\n\n\t    // Iterate through the selection\n\t    for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)\n\t\t{\n\t\t    if(IsPcrSelected(pcr, select))  // Is this PCR selected\n\t\t\t{\n\t\t\t    // Get pointer to the digest data for the bank\n\t\t\t    pcrData = GetPcrPointer(selection->pcrSelections[i].hash, pcr);\n\t\t\t    pAssert(pcrData != NULL);\n\t\t\t    CryptDigestUpdate(&hashState, pcrSize, pcrData);  // add to digest\n\t\t\t}\n\t\t}\n\t}\n    // Complete hash stack\n    CryptHashEnd2B(&hashState, &digest->b);\n\n    return;\n}\n\n//*** PCRRead()\n// This function is used to read a list of selected PCR.  If the requested PCR\n// number exceeds the maximum number that can be output, the 'selection' is\n// adjusted to reflect the actual output PCR.\nvoid PCRRead(TPML_PCR_SELECTION* selection,  // IN/OUT: PCR selection (filtered on\n\t     //     output)\n\t     TPML_DIGEST* digest,            // OUT: digest\n\t     UINT32*      pcrCounter  // OUT: the current value of PCR generation\n\t     //     number\n\t     )\n{\n    TPMS_PCR_SELECTION* select;\n    BYTE*               pcrData;  // will point to a digest\n    UINT32              pcr;\n    UINT32              i;\n\n    digest->count = 0;\n\n    // Iterate through the list of PCR selection structures\n    for(i = 0; i < selection->count; i++)\n\t{\n\t    // Point to the current selection\n\t    select = &selection->pcrSelections[i];  // Point to the current selection\n\t    FilterPcr(select);  // Clear out the bits for unimplemented PCR\n\n\t    // Iterate through the selection\n\t    for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)\n\t\t{\n\t\t    if(IsPcrSelected(pcr, select))  // Is this PCR selected\n\t\t\t{\n\t\t\t    // Check if number of digest exceed upper bound\n\t\t\t    if(digest->count > 7)\n\t\t\t\t{\n\t\t\t\t    // Clear rest of the current select bitmap\n\t\t\t\t    while(pcr < IMPLEMENTATION_PCR\n\t\t\t\t\t  // do not round up!\n\t\t\t\t\t  && (pcr / 8) < select->sizeofSelect)\n\t\t\t\t\t{\n\t\t\t\t\t    // do not round up!\n\t\t\t\t\t    select->pcrSelect[pcr / 8] &= (BYTE) ~(1 << (pcr % 8));\n\t\t\t\t\t    pcr++;\n\t\t\t\t\t}\n\t\t\t\t    // Exit inner loop\n\t\t\t\t    break;\n\t\t\t\t}\n\t\t\t    // Need the size of each digest\n\t\t\t    digest->digests[digest->count].t.size =\n\t\t\t\tCryptHashGetDigestSize(selection->pcrSelections[i].hash);\n\n\t\t\t    // Get pointer to the digest data for the bank\n\t\t\t    pcrData = GetPcrPointer(selection->pcrSelections[i].hash, pcr);\n\t\t\t    pAssert(pcrData != NULL);\n\t\t\t    // Add to the data to digest\n\t\t\t    MemoryCopy(digest->digests[digest->count].t.buffer,\n\t\t\t\t       pcrData,\n\t\t\t\t       digest->digests[digest->count].t.size);\n\t\t\t    digest->count++;\n\t\t\t}\n\t\t}\n\t    // If we exit inner loop because we have exceed the output upper bound\n\t    if(digest->count > 7 && pcr < IMPLEMENTATION_PCR)\n\t\t{\n\t\t    // Clear rest of the selection\n\t\t    while(i < selection->count)\n\t\t\t{\n\t\t\t    MemorySet(selection->pcrSelections[i].pcrSelect,\n\t\t\t\t      0,\n\t\t\t\t      selection->pcrSelections[i].sizeofSelect);\n\t\t\t    i++;\n\t\t\t}\n\t\t    // exit outer loop\n\t\t    break;\n\t\t}\n\t}\n\n    *pcrCounter = gr.pcrCounter;\n\n    return;\n}\n\n//*** PCRAllocate()\n// This function is used to change the PCR allocation.\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        allocate failed\n//      TPM_RC_PCR              improper allocation\nTPM_RC\nPCRAllocate(TPML_PCR_SELECTION* allocate,      // IN: required allocation\n\t    UINT32*             maxPCR,        // OUT: Maximum number of PCR\n\t    UINT32*             sizeNeeded,    // OUT: required space\n\t    UINT32*             sizeAvailable  // OUT: available space\n\t    )\n{\n    UINT32             i, j, k;\n    TPML_PCR_SELECTION newAllocate;\n    // Initialize the flags to indicate if HCRTM PCR and DRTM PCR are allocated.\n    BOOL pcrHcrtm = FALSE;\n    BOOL pcrDrtm  = FALSE;\n\n    // Create the expected new PCR allocation based on the existing allocation\n    // and the new input:\n    //  1. if a PCR bank does not appear in the new allocation, the existing\n    //     allocation of this PCR bank will be preserved.\n    //  2. if a PCR bank appears multiple times in the new allocation, only the\n    //     last one will be in effect.\n    newAllocate = gp.pcrAllocated;\n    for(i = 0; i < allocate->count; i++)\n\t{\n\t    for(j = 0; j < newAllocate.count; j++)\n\t\t{\n\t\t    // If hash matches, the new allocation covers the old allocation\n\t\t    // for this particular bank.\n\t\t    // The assumption is the initial PCR allocation (from manufacture)\n\t\t    // has all the supported hash algorithms with an assigned bank\n\t\t    // (possibly empty).  So there must be a match for any new bank\n\t\t    // allocation from the input.\n\t\t    if(newAllocate.pcrSelections[j].hash == allocate->pcrSelections[i].hash)\n\t\t\t{\n\t\t\t    newAllocate.pcrSelections[j] = allocate->pcrSelections[i];\n\t\t\t    break;\n\t\t\t}\n\t\t}\n\t    // The j loop must exit with a match.\n\t    pAssert(j < newAllocate.count);\n\t}\n\n    // Max PCR in a bank is MIN(implemented PCR, PCR with attributes defined)\n    *maxPCR = _platPcr__NumberOfPcrs();\n    if(*maxPCR > IMPLEMENTATION_PCR)\n\t*maxPCR = IMPLEMENTATION_PCR;\n\n    // Compute required size for allocation\n    *sizeNeeded = 0;\n    for(i = 0; i < newAllocate.count; i++)\n\t{\n\t    UINT32 digestSize = CryptHashGetDigestSize(newAllocate.pcrSelections[i].hash);\n#if defined(DRTM_PCR)\n\t    // Make sure that we end up with at least one DRTM PCR\n\t    pcrDrtm = pcrDrtm\n\t\t      || TestBit(DRTM_PCR,\n\t\t\t\t newAllocate.pcrSelections[i].pcrSelect,\n\t\t\t\t newAllocate.pcrSelections[i].sizeofSelect);\n\n#else  // if DRTM PCR is not required, indicate that the allocation is OK\n\t    pcrDrtm  = TRUE;\n#endif\n\n#if defined(HCRTM_PCR)\n\t    // and one HCRTM PCR (since this is usually PCR 0...)\n\t    pcrHcrtm = pcrHcrtm\n\t\t       || TestBit(HCRTM_PCR,\n\t\t\t\t  newAllocate.pcrSelections[i].pcrSelect,\n\t\t\t\t  newAllocate.pcrSelections[i].sizeofSelect);\n#else\n\t    pcrHcrtm = TRUE;\n#endif\n\t    for(j = 0; j < newAllocate.pcrSelections[i].sizeofSelect; j++)\n\t\t{\n\t\t    BYTE mask = 1;\n\t\t    for(k = 0; k < 8; k++)\n\t\t\t{\n\t\t\t    if((newAllocate.pcrSelections[i].pcrSelect[j] & mask) != 0)\n\t\t\t\t*sizeNeeded += digestSize;\n\t\t\t    mask = mask << 1;\n\t\t\t}\n\t\t}\n\t}\n\n    if(!pcrDrtm || !pcrHcrtm)\n\treturn TPM_RC_PCR;\n\n    // In this particular implementation, we always have enough space to\n    // allocate PCR.  Different implementation may return a sizeAvailable less\n    // than the sizeNeed.\n    *sizeAvailable = sizeof(s_pcrs);\n\n    // Save the required allocation to NV.  Note that after NV is written, the\n    // PCR allocation in NV is no longer consistent with the RAM data\n    // gp.pcrAllocated.  The NV version reflect the allocate after next\n    // TPM_RESET, while the RAM version reflects the current allocation\n    NV_WRITE_PERSISTENT(pcrAllocated, newAllocate);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** PCRSetValue()\n// This function is used to set the designated PCR in all banks to an initial value.\n// The initial value is signed and will be sign extended into the entire PCR.\n//\nvoid PCRSetValue(TPM_HANDLE handle,       // IN: the handle of the PCR to set\n\t\t INT8       initialValue  // IN: the value to set\n\t\t )\n{\n    int           i;\n    UINT32        pcr = handle - PCR_FIRST;\n    TPMI_ALG_HASH hash;\n    UINT16        digestSize;\n    BYTE*         pcrData;\n\n    // Iterate supported PCR bank algorithms to reset\n    for(i = 0; i < HASH_COUNT; i++)\n\t{\n\t    hash = CryptHashGetAlgByIndex(i);\n\t    // Prevent runaway\n\t    if(hash == TPM_ALG_NULL)\n\t\tbreak;\n\n\t    // Get a pointer to the data\n\t    pcrData = GetPcrPointer(gp.pcrAllocated.pcrSelections[i].hash, pcr);\n\n\t    // If the PCR is allocated\n\t    if(pcrData != NULL)\n\t\t{\n\t\t    // And the size of the digest\n\t\t    digestSize = CryptHashGetDigestSize(hash);\n\n\t\t    // Set the LSO to the input value\n\t\t    pcrData[digestSize - 1] = initialValue;\n\n\t\t    // Sign extend\n\t\t    if(initialValue >= 0)\n\t\t\tMemorySet(pcrData, 0, digestSize - 1);\n\t\t    else\n\t\t\tMemorySet(pcrData, -1, digestSize - 1);\n\t\t}\n\t}\n}\n\n//*** PCRResetDynamics\n// This function is used to reset a dynamic PCR to 0.  This function is used in\n// DRTM sequence.\nvoid PCRResetDynamics(void)\n{\n    UINT32 pcr, i;\n\n    // Initialize PCR values\n    for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)\n\t{\n\t    // Iterate each hash algorithm bank\n\t    for(i = 0; i < gp.pcrAllocated.count; i++)\n\t\t{\n\t\t    BYTE*          pcrData;\n\t\t    UINT32         pcrSize;\n\t\t    PCR_Attributes currentPcrAttributes =\n\t\t\t_platPcr__GetPcrInitializationAttributes(pcr);\n\n\t\t    pcrData = GetPcrPointer(gp.pcrAllocated.pcrSelections[i].hash, pcr);\n\n\t\t    if(pcrData != NULL)\n\t\t\t{\n\t\t\t    pcrSize =\n\t\t\t\tCryptHashGetDigestSize(gp.pcrAllocated.pcrSelections[i].hash);\n\n\t\t\t    // Reset PCR\n\t\t\t    // Any PCR can be reset by locality 4 should be reset to 0\n\t\t\t    if((currentPcrAttributes.resetLocality & 0x10) != 0)\n\t\t\t\tMemorySet(pcrData, 0, pcrSize);\n\t\t\t}\n\t\t}\n\t}\n    return;\n}\n\n//*** PCRCapGetAllocation()\n// This function is used to get the current allocation of PCR banks.\n//  Return Type: TPMI_YES_NO\n//      YES         if the return count is 0\n//      NO          if the return count is not 0\nTPMI_YES_NO\nPCRCapGetAllocation(UINT32              count,        // IN: count of return\n\t\t    TPML_PCR_SELECTION* pcrSelection  // OUT: PCR allocation list\n\t\t    )\n{\n    if(count == 0)\n\t{\n\t    pcrSelection->count = 0;\n\t    return YES;\n\t}\n    else\n\t{\n\t    *pcrSelection = gp.pcrAllocated;\n\t    return NO;\n\t}\n}\n\n//*** PCRSetSelectBit()\n// This function sets a bit in a bitmap array.\nstatic void PCRSetSelectBit(UINT32 pcr,    // IN: PCR number\n\t\t\t    BYTE*  bitmap  // OUT: bit map to be set\n\t\t\t    )\n{\n    bitmap[pcr / 8] |= (1 << (pcr % 8));\n    return;\n}\n\n//*** PCRGetProperty()\n// This function returns the selected PCR property.\n//  Return Type: BOOL\n//      TRUE(1)         the property type is implemented\n//      FALSE(0)        the property type is not implemented\nBOOL PCRGetProperty(TPM_PT_PCR property, TPMS_TAGGED_PCR_SELECT* select)\n{\n    UINT32 pcr;\n    UINT32 groupIndex;\n\n    select->tag = property;\n    // Always set the bitmap to be the size of all PCR\n    select->sizeofSelect = (IMPLEMENTATION_PCR + 7) / 8;\n\n    // Initialize bitmap\n    MemorySet(select->pcrSelect, 0, select->sizeofSelect);\n\n    // Collecting properties\n    for(pcr = 0; pcr < IMPLEMENTATION_PCR; pcr++)\n\t{\n\t    PCR_Attributes currentPcrAttributes =\n\t\t_platPcr__GetPcrInitializationAttributes(pcr);\n\n\t    switch(property)\n\t\t{\n\t\t  case TPM_PT_PCR_SAVE:\n\t\t    if(currentPcrAttributes.stateSave == SET)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_EXTEND_L0:\n\t\t    if((currentPcrAttributes.extendLocality & 0x01) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_RESET_L0:\n\t\t    if((currentPcrAttributes.resetLocality & 0x01) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_EXTEND_L1:\n\t\t    if((currentPcrAttributes.extendLocality & 0x02) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_RESET_L1:\n\t\t    if((currentPcrAttributes.resetLocality & 0x02) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_EXTEND_L2:\n\t\t    if((currentPcrAttributes.extendLocality & 0x04) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_RESET_L2:\n\t\t    if((currentPcrAttributes.resetLocality & 0x04) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_EXTEND_L3:\n\t\t    if((currentPcrAttributes.extendLocality & 0x08) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_RESET_L3:\n\t\t    if((currentPcrAttributes.resetLocality & 0x08) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_EXTEND_L4:\n\t\t    if((currentPcrAttributes.extendLocality & 0x10) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_RESET_L4:\n\t\t    if((currentPcrAttributes.resetLocality & 0x10) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n\t\t  case TPM_PT_PCR_DRTM_RESET:\n\t\t    // DRTM reset PCRs are the PCR reset by locality 4\n\t\t    if((currentPcrAttributes.resetLocality & 0x10) != 0)\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n#if defined NUM_POLICY_PCR_GROUP && NUM_POLICY_PCR_GROUP > 0\n\t\t  case TPM_PT_PCR_POLICY:\n\t\t    if(PCRBelongsPolicyGroup(pcr + PCR_FIRST, &groupIndex))\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n#endif\n#if defined NUM_AUTHVALUE_PCR_GROUP && NUM_AUTHVALUE_PCR_GROUP > 0\n\t\t  case TPM_PT_PCR_AUTH:\n\t\t    if(PCRBelongsAuthGroup(pcr + PCR_FIRST, &groupIndex))\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n#endif\n#if ENABLE_PCR_NO_INCREMENT == YES\n\t\t  case TPM_PT_PCR_NO_INCREMENT:\n\t\t    if(PCRBelongsTCBGroup(pcr + PCR_FIRST))\n\t\t\tPCRSetSelectBit(pcr, select->pcrSelect);\n\t\t    break;\n#endif\n\t\t  default:\n\t\t    // If property is not supported, stop scanning PCR attributes\n\t\t    // and return.\n\t\t    return FALSE;\n\t\t    break;\n\t\t}\n\t}\n    return TRUE;\n}\n\n//*** PCRCapGetProperties()\n// This function returns a list of PCR properties starting at 'property'.\n//  Return Type: TPMI_YES_NO\n//      YES         if no more property is available\n//      NO          if there are more properties not reported\nTPMI_YES_NO\nPCRCapGetProperties(TPM_PT_PCR property,  // IN: the starting PCR property\n\t\t    UINT32     count,     // IN: count of returned properties\n\t\t    TPML_TAGGED_PCR_PROPERTY* select  // OUT: PCR select\n\t\t    )\n{\n    TPMI_YES_NO more = NO;\n    UINT32      i;\n\n    // Initialize output property list\n    select->count = 0;\n\n    // The maximum count of properties we may return is MAX_PCR_PROPERTIES\n    if(count > MAX_PCR_PROPERTIES)\n\tcount = MAX_PCR_PROPERTIES;\n\n    // TPM_PT_PCR_FIRST is defined as 0 in spec.  It ensures that property\n    // value would never be less than TPM_PT_PCR_FIRST\n    MUST_BE(TPM_PT_PCR_FIRST == 0);\n\n    // Iterate PCR properties. TPM_PT_PCR_LAST is the index of the last property\n    // implemented on the TPM.\n    for(i = property; i <= TPM_PT_PCR_LAST; i++)\n\t{\n\t    if(select->count < count)\n\t\t{\n\t\t    // If we have not filled up the return list, add more properties to it\n\t\t    if(PCRGetProperty(i, &select->pcrProperty[select->count]))\n\t\t\t// only increment if the property is implemented\n\t\t\tselect->count++;\n\t\t}\n\t    else\n\t\t{\n\t\t    // If the return list is full but we still have properties\n\t\t    // available, report this and stop iterating.\n\t\t    more = YES;\n\t\t    break;\n\t\t}\n\t}\n    return more;\n}\n\n//*** PCRCapGetHandles()\n// This function is used to get a list of handles of PCR, started from 'handle'.\n// If 'handle' exceeds the maximum PCR handle range, an empty list will be\n// returned and the return value will be NO.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles available\n//      NO          all the available handles has been returned\nTPMI_YES_NO\nPCRCapGetHandles(TPMI_DH_PCR  handle,     // IN: start handle\n\t\t UINT32       count,      // IN: count of returned handles\n\t\t TPML_HANDLE* handleList  // OUT: list of handle\n\t\t )\n{\n    TPMI_YES_NO more = NO;\n    UINT32      i;\n\n    pAssert(HandleGetType(handle) == TPM_HT_PCR);\n\n    // Initialize output handle list\n    handleList->count = 0;\n\n    // The maximum count of handles we may return is MAX_CAP_HANDLES\n    if(count > MAX_CAP_HANDLES)\n\tcount = MAX_CAP_HANDLES;\n\n    // Iterate PCR handle range\n    for(i = handle & HR_HANDLE_MASK; i <= PCR_LAST; i++)\n\t{\n\t    if(handleList->count < count)\n\t\t{\n\t\t    // If we have not filled up the return list, add this PCR\n\t\t    // handle to it\n\t\t    handleList->handle[handleList->count] = i + PCR_FIRST;\n\t\t    handleList->count++;\n\t\t}\n\t    else\n\t\t{\n\t\t    // If the return list is full but we still have PCR handle\n\t\t    // available, report this and stop iterating\n\t\t    more = YES;\n\t\t    break;\n\t\t}\n\t}\n    return more;\n}\n\n//*** PCRCapGetOneHandle()\n// This function is used to check whether a PCR handle exists.\nBOOL PCRCapGetOneHandle(TPMI_DH_PCR handle)  // IN: handle\n{\n    pAssert(HandleGetType(handle) == TPM_HT_PCR);\n\n    if((handle & HR_HANDLE_MASK) <= PCR_LAST)\n\t{\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/PP.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 8.8 PP.c */\n/* 8.8.1 Introduction */\n/* This file contains the functions that support the physical presence operations of the TPM. */\n/* 8.8.2 Includes */\n#include \"Tpm.h\"\n/* 8.8.3 Functions */\n/* 8.8.3.1 PhysicalPresencePreInstall_Init() */\n/* This function is used to initialize the array of commands that always require confirmation with\n   physical presence. The array is an array of bits that has a correspondence with the command\n   code. */\n/* This command should only ever be executable in a manufacturing setting or in a simulation. */\n/* When set, these cannot be cleared. */\nvoid\nPhysicalPresencePreInstall_Init(\n\t\t\t\tvoid\n\t\t\t\t)\n{\n    COMMAND_INDEX        commandIndex;\n    // Clear all the PP commands\n    MemorySet(&gp.ppList, 0, sizeof(gp.ppList));\n    // Any command that is PP_REQUIRED should be SET\n    for(commandIndex = 0; commandIndex < COMMAND_COUNT; commandIndex++)\n\t{\n\t    if(s_commandAttributes[commandIndex] & IS_IMPLEMENTED\n\t       &&  s_commandAttributes[commandIndex] & PP_REQUIRED)\n\t\tSET_BIT(commandIndex, gp.ppList);\n\t}\n    // Write PP list to NV\n    NV_SYNC_PERSISTENT(ppList);\n    return;\n}\n/* 8.8.3.2 PhysicalPresenceCommandSet() */\n/* This function is used to set the indicator that a command requires PP confirmation. */\nvoid\nPhysicalPresenceCommandSet(\n\t\t\t   TPM_CC           commandCode    // IN: command code\n\t\t\t   )\n{\n    COMMAND_INDEX       commandIndex = CommandCodeToCommandIndex(commandCode);\n    // if the command isn't implemented, the do nothing\n    if(commandIndex == UNIMPLEMENTED_COMMAND_INDEX)\n\treturn;\n    // only set the bit if this is a command for which PP is allowed\n    if(s_commandAttributes[commandIndex] & PP_COMMAND)\n\tSET_BIT(commandIndex, gp.ppList);\n    return;\n}\n/* 8.8.3.3 PhysicalPresenceCommandClear() */\n/* This function is used to clear the indicator that a command requires PP confirmation. */\nvoid\nPhysicalPresenceCommandClear(\n\t\t\t     TPM_CC           commandCode    // IN: command code\n\t\t\t     )\n{\n    COMMAND_INDEX       commandIndex = CommandCodeToCommandIndex(commandCode);\n    // If the command isn't implemented, then don't do anything\n    if(commandIndex == UNIMPLEMENTED_COMMAND_INDEX)\n\treturn;\n    // Only clear the bit if the command does not require PP\n    if((s_commandAttributes[commandIndex] & PP_REQUIRED) == 0)\n\tCLEAR_BIT(commandIndex, gp.ppList);\n    return;\n}\n/* 8.8.3.4 PhysicalPresenceIsRequired() */\n/* This function indicates if PP confirmation is required for a command. */\n/* Return Values Meaning */\n/* TRUE if physical presence is required */\n/* FALSE if physical presence is not required */\nBOOL\nPhysicalPresenceIsRequired(\n\t\t\t   COMMAND_INDEX    commandIndex   // IN: command index\n\t\t\t   )\n{\n    // Check the bit map.  If the bit is SET, PP authorization is required\n    return (TEST_BIT(commandIndex, gp.ppList));\n}\n/* 8.8.3.5 PhysicalPresenceCapGetCCList() */\n/* This function returns a list of commands that require PP confirmation. The list starts from the\n   first implemented command that has a command code that the same or greater than commandCode. */\n/* Return Values Meaning */\n/* YES if there are more command codes available */\n/* NO all the available command codes have been returned */\nTPMI_YES_NO\nPhysicalPresenceCapGetCCList(\n\t\t\t     TPM_CC           commandCode,   // IN: start command code\n\t\t\t     UINT32           count,         // IN: count of returned TPM_CC\n\t\t\t     TPML_CC         *commandList    // OUT: list of TPM_CC\n\t\t\t     )\n{\n    TPMI_YES_NO     more = NO;\n    COMMAND_INDEX   commandIndex;\n    // Initialize output handle list\n    commandList->count = 0;\n    // The maximum count of command we may return is MAX_CAP_CC\n    if(count > MAX_CAP_CC) count = MAX_CAP_CC;\n    // Collect PP commands\n    for(commandIndex = GetClosestCommandIndex(commandCode);\n\tcommandIndex != UNIMPLEMENTED_COMMAND_INDEX;\n\tcommandIndex = GetNextCommandIndex(commandIndex))\n\t{\n\t    if(PhysicalPresenceIsRequired(commandIndex))\n\t\t{\n\t\t    if(commandList->count < count)\n\t\t\t{\n\t\t\t    // If we have not filled up the return list, add this command\n\t\t\t    // code to it\n\t\t\t    commandList->commandCodes[commandList->count]\n\t\t\t\t= GetCommandCode(commandIndex);\n\t\t\t    commandList->count++;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // If the return list is full but we still have PP command\n\t\t\t    // available, report this and stop iterating\n\t\t\t    more = YES;\n\t\t\t    break;\n\t\t\t}\n\t\t}\n\t}\n    return more;\n}\n\n//*** PhysicalPresenceCapGetOneCC()\n// This function returns true if the command requires Physical Presence.\nBOOL PhysicalPresenceCapGetOneCC(TPM_CC commandCode)  // IN: command code\n{\n    COMMAND_INDEX commandIndex = CommandCodeToCommandIndex(commandCode);\n    if(commandIndex != UNIMPLEMENTED_COMMAND_INDEX)\n\t{\n\t    return PhysicalPresenceIsRequired(commandIndex);\n\t}\n    return FALSE;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/PPPlat.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tSimulates the Physical Present Interface\t     \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PPPlat.c 1490 2019-07-26 21:13:22Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.10 PPPlat.c */\n/* C.10.1. Description */\n/* This module simulates the physical presence interface pins on the TPM. */\n/* C.10.2. Includes */\n#include \"Platform.h\"\n/* C.10.3. Functions */\n/* C.10.3.1. _plat__PhysicalPresenceAsserted() */\n/* Check if physical presence is signaled */\n/* Return Values Meaning */\n/* TRUE(1) if physical presence is signaled */\n/* FALSE(0) if physical presence is not signaled */\nLIB_EXPORT int\n_plat__PhysicalPresenceAsserted(\n\t\t\t\tvoid\n\t\t\t\t)\n{\n    // Do not know how to check physical presence without real hardware.\n    // so always return TRUE;\n    return s_physicalPresence;\n}\n/* C.10.3.2. _plat__Signal_PhysicalPresenceOn() */\n/* Signal physical presence on */\nLIB_EXPORT void\n_plat__Signal_PhysicalPresenceOn(\n\t\t\t\t void\n\t\t\t\t )\n{\n    s_physicalPresence = TRUE;\n    return;\n}\n/* C.10.3.3. _plat__Signal_PhysicalPresenceOff() */\n/* Signal physical presence off */\nLIB_EXPORT void\n_plat__Signal_PhysicalPresenceOff(\n\t\t\t\t  void\n\t\t\t\t  )\n{\n    s_physicalPresence = FALSE;\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/PlatformACT.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t Platform Authenticated Countdown Timer\t\t  \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PlatformACT.c 1594 2020-03-26 22:15:48Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n/* C.16\tPlatformACT.c */\n/* C.16.1.\tIncludes */\n#include \"Platform.h\"\n#include \"PlatformACT_fp.h\"\n/* C.16.2.\tFunctions */\n/* C.16.2.1.\tActSignal() */\n/* Function called when there is an ACT event to signal or unsignal */\nstatic void\nActSignal(\n\t  P_ACT_DATA          actData,\n\t  int                 on\n\t  )\n{\n    if(actData == NULL)\n\treturn;\n    // If this is to turn a signal on, don't do anything if it is already on. If this\n    // is to turn the signal off, do it anyway because this might be for\n    // initialization.\n    if(on && (actData->signaled == TRUE))\n\treturn;\n    actData->signaled = (uint8_t)on;\n    \n    // If there is an action, then replace the \"Do something\" with the correct action.\n    // It should test 'on' to see if it is turning the signal on or off.\n    switch(actData->number)\n\t{\n#if RH_ACT_0\n\t  case 0: // Do something\n\t    return;\n#endif\n#if RH_ACT_1\n\t  case 1: // Do something\n\t    return;\n#endif\n#if RH_ACT_2\n\t  case 2: // Do something\n\t    return;\n#endif\n#if RH_ACT_3\n\t  case 3: // Do something\n\t    return;\n#endif\n#if RH_ACT_4\n\t  case 4: // Do something\n\t    return;\n#endif\n#if RH_ACT_5\n\t  case 5: // Do something\n\t    return;\n#endif\n#if RH_ACT_6\n\t  case 6: // Do something\n\t    return;\n#endif\n#if RH_ACT_7\n\t  case 7: // Do something\n\t    return;\n#endif\n#if RH_ACT_8\n\t  case 8: // Do something\n\t    return;\n#endif\n#if RH_ACT_9\n\t  case 9: // Do something\n\t    return;\n#endif\n#if RH_ACT_A\n\t  case 0xA: // Do something\n\t    return;\n#endif\n#if RH_ACT_B\n\t  case 0xB:\n\t    // Do something\n\t    return;\n#endif\n#if RH_ACT_C\n\t  case 0xC: // Do something\n\t    return;\n#endif\n#if RH_ACT_D\n\t  case 0xD: // Do something\n\t    return;\n#endif\n#if RH_ACT_E\n\t  case 0xE: // Do something\n\t    return;\n#endif\n#if RH_ACT_F\n\t  case 0xF: // Do something\n\t    return;\n#endif\n\t  default:\n\t    return;\n\t}\n}\n/* C.16.2.2.\tActGetDataPointer() */\nstatic P_ACT_DATA\nActGetDataPointer(\n\t\t  uint32_t            act\n\t\t  )\n{\n    \n#define RETURN_ACT_POINTER(N)  if(0x##N == act) return &ACT_##N;\n    \n    FOR_EACH_ACT(RETURN_ACT_POINTER)\n\t\n\treturn (P_ACT_DATA)NULL;\n}\n/* C.16.2.3.\t_plat__ACT_GetImplemented() */\n/* This function tests to see if an ACT is implemented. It is a belt and suspenders function because\n   the TPM should not be calling to manipulate an ACT that is not implemented. However, this\n   could help the simulator code which doesn't necessarily know if an ACT is implemented or not. */\nLIB_EXPORT int\n_plat__ACT_GetImplemented(\n\t\t\t  uint32_t            act\n\t\t\t  )\n{\n    return (ActGetDataPointer(act) != NULL);\n}\n/* C.16.2.4.\t_plat__ACT_GetRemaining() */\n/* This function returns the remaining time. If an update is pending, newValue is\n   returned. Otherwise, the current counter value is returned. Note that since the timers keep\n   running, the returned value can get stale immediately. The actual count value will be no greater\n   than the returned value. */\nLIB_EXPORT uint32_t\n_plat__ACT_GetRemaining(\n\t\t\tuint32_t            act             //IN: the ACT selector\n\t\t\t)\n{\n    P_ACT_DATA              actData = ActGetDataPointer(act);\n    uint32_t                remain;\n    //\n    if(actData == NULL)\n\treturn 0;\n    remain = actData->remaining;\n    if(actData->pending)\n\tremain = actData->newValue;\n    return remain;\n}\n/* C.16.2.5.\t_plat__ACT_GetSignaled() */\nLIB_EXPORT int\n_plat__ACT_GetSignaled(\n\t\t       uint32_t            act         //IN: number of ACT to check\n\t\t       )\n{\n    P_ACT_DATA              actData = ActGetDataPointer(act);\n    //\n    if(actData == NULL)\n\treturn 0;\n    return (int)actData->signaled;\n}\n/* C.16.2.6.\t_plat__ACT_SetSignaled() */\nLIB_EXPORT void\n_plat__ACT_SetSignaled(\n\t\t       uint32_t            act,\n\t\t       int                 on\n\t\t       )\n{\n    ActSignal(ActGetDataPointer(act), on);\n}\n/* C.16.2.7.\t_plat__ACT_GetPending() */\nLIB_EXPORT int\n_plat__ACT_GetPending(\n\t\t      uint32_t            act         //IN: number of ACT to check\n\t\t      )\n{\n    P_ACT_DATA              actData = ActGetDataPointer(act);\n    //\n    if(actData == NULL)\n\treturn 0;\n    return (int)actData->pending;\n}\n/* C.16.2.8.\t_plat__ACT_UpdateCounter() */\n/* This function is used to write the newValue for the counter. If an update is pending, then no\n   update occurs and the function returns FALSE. If setSignaled is TRUE, then the ACT signaled state\n   is SET and if newValue is 0, nothing is posted. */\nLIB_EXPORT int\n_plat__ACT_UpdateCounter(\n\t\t\t uint32_t            act,        // IN: ACT to update\n\t\t\t uint32_t            newValue   // IN: the value to post\n\t\t\t )\n{\n    P_ACT_DATA          actData = ActGetDataPointer(act);\n    //\n    if(actData == NULL)\n\t// actData doesn't exist but pretend update is pending rather than indicate\n\t// that a retry is necessary.\n\treturn TRUE;\n    // if an update is pending then return FALSE so that there will be a retry\n    if(actData->pending != 0)\n\treturn FALSE;\n    actData->newValue = newValue;\n    actData->pending = TRUE;\n    \n    return TRUE;\n}\n/* C.16.2.9.\t_plat__ACT_EnableTicks() */\n/* This enables and disables the processing of the once-per-second ticks. This should be turned off\n   (enable = FALSE) by _TPM_Init() and turned on (enable = TRUE) by TPM2_Startup() after all the\n   initializations have completed. */\nLIB_EXPORT void\n_plat__ACT_EnableTicks(\n\t\t       int \tenable\n\t\t       )\n{\n    actTicksAllowed = enable;\n}\n/* C.16.2.10.\tActDecrement() */\n/* If newValue is non-zero it is copied to remaining and then newValue is set to zero. Then\n   remaining is decremented by one if it is not already zero. If the value is decremented to zero,\n   then the associated event is signaled. If setting remaining causes it to be greater than 1, then\n   the signal associated with the ACT is turned off. */\nstatic void\nActDecrement(\n\t     P_ACT_DATA            actData\n\t     )\n{\n    // Check to see if there is an update pending\n    if(actData->pending)\n\t{\n\t    // If this update will cause the count to go from non-zero to zero, set\n\t    // the newValue to 1 so that it will timeout when decremented below.\n\t    if((actData->newValue == 0) && (actData->remaining != 0))\n\t\tactData->newValue = 1;\n\t    actData->remaining = actData->newValue;\n\t    \n\t    // Update processed\n\t    actData->pending = 0;\n\t}\n    // no update so countdown if the count is non-zero but not max\n    if((actData->remaining != 0) && (actData->remaining != UINT32_MAX))\n\t{\n\t    // If this countdown causes the count to go to zero, then turn the signal for\n\t    // the ACT on.\n\t    if((actData->remaining -= 1) == 0)\n\t\tActSignal(actData, TRUE);\n\t}\n    // If the current value of the counter is non-zero, then the signal should be\n    // off.\n    if(actData->signaled && (actData->remaining > 0))\n\tActSignal(actData, FALSE);\n}\n/* C.16.2.11.\t_plat__ACT_Tick() */\n/* This processes the once-per-second clock tick from the hardware. This is set up for the simulator to use the control interface to send ticks to the TPM. These ticks do not have to be on a per second basis. They can be as slow or as fast as desired so that the simulation can be tested. */\nLIB_EXPORT void\n_plat__ACT_Tick(\n\t\tvoid\n\t\t)\n{\n    // Ticks processing is turned off at certain times just to make sure that nothing\n    // strange is happening before pointers and things are\n    if(actTicksAllowed)\n\t{\n\t    // Handle the update for each counter.\n#define DECREMENT_COUNT(N)   ActDecrement(&ACT_##N);\n\t    \n\t    FOR_EACH_ACT(DECREMENT_COUNT)\n\t\t}\n}\n/* C.16.2.12.\tActZero() */\n/* This function initializes a single ACT */\nstatic void\nActZero(\n\tuint32_t        act,\n\tP_ACT_DATA      actData\n\t)\n{\n    actData->remaining = 0;\n    actData->newValue = 0;\n    actData->pending = 0;\n    actData->number = (uint8_t)act;\n    ActSignal(actData, FALSE);\n}\n/* C.16.2.13.\t_plat__ACT_Initialize() */\n/* This function initializes the ACT hardware and data structures */\nLIB_EXPORT int\n_plat__ACT_Initialize(\n\t\t      void\n\t\t      )\n{\n    actTicksAllowed = 0;\n#define ZERO_ACT(N)  ActZero(0x##N, &ACT_##N);\n    FOR_EACH_ACT(ZERO_ACT)\n\t\n\treturn TRUE;\n}\n\n"
  },
  {
    "path": "ftpm-opensbi/src/PlatformData.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tTPM variables that are not stack allocated\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PlatformData.c 1519 2019-11-15 20:43:51Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.9 PlatformData.c */\n/* C.9.1. Description */\n/* This file will instance the TPM variables that are not stack allocated. The descriptions for\n   these variables are in Global.h for this project. */\n/* C.9.2. Includes */\n\n#define _PLATFORM_DATA_C_\n#include    \"Platform.h\"\n\n"
  },
  {
    "path": "ftpm-opensbi/src/PlatformPCR.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// PCR platform interface functions\n#include \"Platform.h\"\n#include \"TpmAlgorithmDefines.h\"\n\n// use this as a convenient lookup for hash size for PCRs.\nUINT16 CryptHashGetDigestSize(TPM_ALG_ID hashAlg  // IN: hash algorithm to look up\n\t\t\t      );\nvoid   MemorySet(void* dest, int value, size_t size);\n\n// The initial value of PCR attributes.  The value of these fields should be\n// consistent with PC Client specification.  The bitfield meanings are defined by\n// the TPM Reference code.\n// In this implementation, we assume the total number of implemented PCR is 24.\nstatic const PCR_Attributes s_initAttributes[] = {\n    //\n    // PCR 0 - 15, static RTM\n    // PCR[0]\n    {\n\t1,  // save state\n\t0,  // in the \"do not increment the PcrCounter\" group? (0 = increment the PcrCounter)\n\t0,  // supportsPolicyAuth group number? 0 = policyAuth not supported for this PCR.\n\t0,  // supportsAuthValue group number? 0 = AuthValue not supported for this PCR.\n\t0,    // 0 = reset localities (cannot reset)\n\t0x1F  // 0x1F = extendlocalities [0,4]\n    },\n    {1, 0, 0, 0, 0, 0x1F},  // PCR 1-3\n    {1, 0, 0, 0, 0, 0x1F},\n    {1, 0, 0, 0, 0, 0x1F},\n    {1, 0, 0, 0, 0, 0x1F},  // PCR 4-6\n    {1, 0, 0, 0, 0, 0x1F},\n    {1, 0, 0, 0, 0, 0x1F},\n    {1, 0, 0, 0, 0, 0x1F},  // PCR 7-9\n    {1, 0, 0, 0, 0, 0x1F},\n    {1, 0, 0, 0, 0, 0x1F},\n    {1, 0, 0, 0, 0, 0x1F},  // PCR 10-12\n    {1, 0, 0, 0, 0, 0x1F},\n    {1, 0, 0, 0, 0, 0x1F},\n    {1, 0, 0, 0, 0, 0x1F},  // PCR 13-15\n    {1, 0, 0, 0, 0, 0x1F},\n    {1, 0, 0, 0, 0, 0x1F},\n\n    // these PCRs are never saved\n    {0, 1, 0, 0, 0x0F, 0x1F},  // PCR 16, Debug, reset allowed, extend all\n    {0, 0, 0, 0, 0x10, 0x1C},  // PCR 17, Locality 4, extend loc 2+\n    {0, 0, 0, 0, 0x10, 0x1C},  // PCR 18, Locality 3, extend loc 2+\n    {0, 0, 0, 0, 0x10, 0x0C},  // PCR 19, Locality 2, extend loc 2, 3\n    // these three support doNotIncrement, PolicyAuth, and AuthValue.\n    // this is consistent with the existing behavior of the TPM Reference code\n    // but differs from the behavior of the PC client spec.\n    {0, 0, 0, 0, 0x1C, 0x0E},  // PCR 20, Locality 1, extend loc 1, 2, 3\n    {0, 1, 0, 0, 0x1C, 0x04},  // PCR 21, Dynamic OS, extend loc 2\n    {0, 1, 0, 0, 0x1C, 0x04},  // PCR 22, Dynamic OS, extend loc 2\n    {0, 1, 0, 0, 0x0F, 0x1F},  // PCR 23, reset allowed, App specific, extend all\n};\n\n#ifndef ARRAYSIZE\n#  define ARRAYSIZE(a) (sizeof(a) / sizeof(a[0]))\n#endif\n\nMUST_BE(ARRAYSIZE(s_initAttributes) == IMPLEMENTATION_PCR);\n\n#if ALG_SHA256 != YES && ALG_SHA384 != YES\n#  error No default PCR banks defined\n#endif\n\nstatic const TPM_ALG_ID DefaultActivePcrBanks[] = {\n#if ALG_SHA256\n    TPM_ALG_SHA256\n#endif\n#if ALG_SHA384\n#  if ALG_SHA256\n    ,\n#  endif\n    TPM_ALG_SHA384\n#endif\n};\n\nUINT32 _platPcr__NumberOfPcrs()\n{\n    return ARRAYSIZE(s_initAttributes);\n}\n\n// return the initialization attributes of a given PCR.\n// pcrNumber expected to be in [0, _platPcr__NumberOfPcrs)\n// returns the attributes for PCR[0] if the requested pcrNumber is out of range.\nPCR_Attributes _platPcr__GetPcrInitializationAttributes(UINT32 pcrNumber)\n{\n    if(pcrNumber >= _platPcr__NumberOfPcrs())\n\t{\n\t    pcrNumber = 0;\n\t}\n    return s_initAttributes[pcrNumber];\n}\n\n// should the given PCR algorithm default to active in a new TPM?\nBOOL _platPcr_IsPcrBankDefaultActive(TPM_ALG_ID pcrAlg)\n{\n    // brute force search is fast enough for a small array.\n    for(size_t i = 0; i < ARRAYSIZE(DefaultActivePcrBanks); i++)\n\t{\n\t    if(DefaultActivePcrBanks[i] == pcrAlg)\n\t\t{\n\t\t    return TRUE;\n\t\t}\n\t}\n    return FALSE;\n}\n\n// Fill a given buffer with the PCR initialization value for a particular PCR and hash\n// combination, and return its length.  If the platform doesn't have a value, then\n// the result size is expected to be zero, and the rfunction will return TPM_RC_PCR.\n// If a valid is not available, then the core TPM library will ignore the value and\n// treat it as non-existant and provide a default.\n// If the buffer is not large enough for a pcr consistent with pcrAlg, then the\n// platform will return TPM_RC_FAILURE.\nTPM_RC _platPcr__GetInitialValueForPcr(\n\t\t\t\t       UINT32     pcrNumber,        // IN: PCR to be initialized\n\t\t\t\t       TPM_ALG_ID pcrAlg,           // IN: Algorithm of the PCR Bank being initialized\n\t\t\t\t       BYTE       startupLocality,  // IN: locality where startup is being called from\n\t\t\t\t       BYTE*      pcrData,          // OUT: buffer to put PCR initialization value into\n\t\t\t\t       uint16_t   bufferSize,       // IN: maximum size of value buffer can hold\n\t\t\t\t       uint16_t*  pcrLength  // OUT: size of initialization value returned in pcrBuffer\n\t\t\t\t       )\n{\n    // If the reset locality contains locality 4, then this\n    // indicates a DRTM PCR where the reset value is all ones,\n    // otherwise it is all zero.  Don't check with equal because\n    // resetLocality is a bitfield of multiple values and does\n    // not support extended localities.\n    uint16_t pcrSize = CryptHashGetDigestSize(pcrAlg);\n    pAssert_RC(pcrNumber < _platPcr__NumberOfPcrs());\n    pAssert_RC(bufferSize >= pcrSize) pAssert_RC(pcrLength != NULL);\n\n    PCR_Attributes pcrAttributes =\n\t_platPcr__GetPcrInitializationAttributes(pcrNumber);\n    BYTE defaultValue = 0;\n    // PCRs that can be cleared from locality 4 are DRTM and initialize to all 0xFF\n    if((pcrAttributes.resetLocality & 0x10) != 0)\n\t{\n\t    defaultValue = 0xFF;\n\t}\n    MemorySet(pcrData, defaultValue, pcrSize);\n    if(pcrNumber == HCRTM_PCR)\n\t{\n\t    pcrData[pcrSize - 1] = startupLocality;\n\t}\n\n    // platform could provide a value here if the platform has initialization rules\n    // different from the original PC Client spec (the default used by the Core library).\n    *pcrLength = pcrSize;\n    return TPM_RC_SUCCESS;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/Policy_spt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Policy Command Support    \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Policy_spt.c 1594 2020-03-26 22:15:48Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 7.4 Policy Command Support (Policy_spt.c) */\n#include \"Tpm.h\"\n#include \"Policy_spt_fp.h\"\n#include \"PolicySigned_fp.h\"\n#include \"PolicySecret_fp.h\"\n#include \"PolicyTicket_fp.h\"\n/* 7.4.1 PolicyParameterChecks() */\n/* This function validates the common parameters of TPM2_PolicySiged() and TPM2_PolicySecret(). The\n   common parameters are nonceTPM, expiration, and cpHashA. */\nTPM_RC\nPolicyParameterChecks(\n\t\t      SESSION         *session,\n\t\t      UINT64           authTimeout,\n\t\t      TPM2B_DIGEST    *cpHashA,\n\t\t      TPM2B_NONCE     *nonce,\n\t\t      TPM_RC           blameNonce,\n\t\t      TPM_RC           blameCpHash,\n\t\t      TPM_RC           blameExpiration\n\t\t      )\n{\n    // Validate that input nonceTPM is correct if present\n    if(nonce != NULL && nonce->t.size != 0)\n\t{\n\t    if(!MemoryEqual2B(&nonce->b, &session->nonceTPM.b))\n\t\treturn TPM_RCS_NONCE + blameNonce;\n\t}\n    // If authTimeout is set (expiration != 0...\n    if(authTimeout != 0)\n\t{\n\t    // Validate input expiration.\n\t    // Cannot compare time if clock stop advancing.  A TPM_RC_NV_UNAVAILABLE\n\t    // or TPM_RC_NV_RATE error may be returned here.\n\t    RETURN_IF_NV_IS_NOT_AVAILABLE;\n\t    // if the time has already passed or the time epoch has changed then the\n\t    // time value is no longer good.\n\t    if((authTimeout < g_time)\n\t       || (session->epoch != g_timeEpoch))\n\t\treturn TPM_RCS_EXPIRED + blameExpiration;\n\t}\n    // If the cpHash is present, then check it\n    if(cpHashA != NULL && cpHashA->t.size != 0)\n\t{\n\t    // The cpHash input has to have the correct size\n\t    if(cpHashA->t.size != session->u2.policyDigest.t.size)\n\t\treturn TPM_RCS_SIZE + blameCpHash;\n\t    // If the cpHash has already been set, then this input value\n\t    // must match the current value.\n\t    if(session->u1.cpHash.b.size != 0\n\t       && !MemoryEqual2B(&cpHashA->b, &session->u1.cpHash.b))\n\t\treturn TPM_RC_CPHASH;\n\t}\n    return TPM_RC_SUCCESS;\n}\n/* 7.4.2 PolicyContextUpdate() */\n/* Update policy hash Update the policyDigest in policy session by extending policyRef and\n   objectName to it. This will also update the cpHash if it is present. */\nvoid\nPolicyContextUpdate(\n\t\t    TPM_CC           commandCode,   // IN: command code\n\t\t    TPM2B_NAME      *name,          // IN: name of entity\n\t\t    TPM2B_NONCE     *ref,           // IN: the reference data\n\t\t    TPM2B_DIGEST    *cpHash,        // IN: the cpHash (optional)\n\t\t    UINT64           policyTimeout, // IN: the timeout value for the policy\n\t\t    SESSION         *session        // IN/OUT: policy session to be updated\n\t\t    )\n{\n    HASH_STATE           hashState;\n    // Start hash\n    CryptHashStart(&hashState, session->authHashAlg);\n    // policyDigest size should always be the digest size of session hash algorithm.\n    pAssert(session->u2.policyDigest.t.size\n\t    == CryptHashGetDigestSize(session->authHashAlg));\n    // add old digest\n    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n    // add commandCode\n    CryptDigestUpdateInt(&hashState, sizeof(commandCode), commandCode);\n    // add name if applicable\n    if(name != NULL)\n\tCryptDigestUpdate2B(&hashState, &name->b);\n    // Complete the digest and get the results\n    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n    // If the policy reference is not null, do a second update to the digest.\n    if(ref != NULL)\n\t{\n\t    // Start second hash computation\n\t    CryptHashStart(&hashState, session->authHashAlg);\n\t    // add policyDigest\n\t    CryptDigestUpdate2B(&hashState, &session->u2.policyDigest.b);\n\t    // add policyRef\n\t    CryptDigestUpdate2B(&hashState, &ref->b);\n\t    // Complete second digest\n\t    CryptHashEnd2B(&hashState, &session->u2.policyDigest.b);\n\t}\n    // Deal with the cpHash. If the cpHash value is present\n    // then it would have already been checked to make sure that\n    // it is compatible with the current value so all we need\n    // to do here is copy it and set the isCpHashDefined attribute\n    if(cpHash != NULL && cpHash->t.size != 0)\n\t{\n\t    session->u1.cpHash = *cpHash;\n\t    session->attributes.isCpHashDefined = SET;\n\t}\n    // update the timeout if it is specified\n    if(policyTimeout != 0)\n\t{\n\t    // If the timeout has not been set, then set it to the new value\n\t    // than the current timeout then set it to the new value\n\t    if(session->timeout == 0 || session->timeout > policyTimeout)\n\t\tsession->timeout = policyTimeout;\n\t}\n    return;\n}\n/* 7.4.2.1 ComputeAuthTimeout() */\n/* This function is used to determine what the authorization timeout value for the session should\n   be. */\nUINT64\nComputeAuthTimeout(\n\t\t   SESSION         *session,               // IN: the session containing the time\n\t\t   //     values\n\t\t   INT32            expiration,            // IN: either the number of seconds from\n\t\t   //     the start of the session or the\n\t\t   //     time in g_timer;\n\t\t   TPM2B_NONCE     *nonce                  // IN: indicator of the time base\n\t\t   )\n{\n    UINT64           policyTime;\n    // If no expiration, policy time is 0\n    if(expiration == 0)\n\tpolicyTime = 0;\n    else\n\t{\n\t    if(expiration < 0)\n\t\texpiration = -expiration;\n\t    if(nonce->t.size == 0)\n\t\t// The input time is absolute Time (not Clock), but it is expressed\n\t\t// in seconds. To make sure that we don't time out too early, take the\n\t\t// current value of milliseconds in g_time and add that to the input\n\t\t// seconds value.\n\t\tpolicyTime = (((UINT64)expiration) * 1000) + g_time % 1000;\n\t    else\n\t\t// The policy timeout is the absolute value of the expiration in seconds\n\t\t// added to the start time of the policy.\n\t\tpolicyTime = session->startTime + (((UINT64)expiration) * 1000);\n\t}\n    return policyTime;\n}\n/* 7.4.2.2 PolicyDigestClear() */\n/* Function to reset the policyDigest of a session */\nvoid\nPolicyDigestClear(\n\t\t  SESSION         *session\n\t\t  )\n{\n    session->u2.policyDigest.t.size = CryptHashGetDigestSize(session->authHashAlg);\n    MemorySet(session->u2.policyDigest.t.buffer, 0,\n\t      session->u2.policyDigest.t.size);\n}\n\n/* 7.4.2.5\tPolicySptCheckCondition() */\n/* Checks to see if the condition in the policy is satisfied. */\n\nBOOL\nPolicySptCheckCondition(\n\t\t\tTPM_EO          operation,\n\t\t\tBYTE            *opA,\n\t\t\tBYTE            *opB,\n\t\t\tUINT16           size\n\t\t\t)\n{\n    // Arithmetic Comparison\n    switch(operation)\n\t{\n\t  case TPM_EO_EQ:\n\t    // compare A = B\n\t    return (UnsignedCompareB(size, opA, size, opB) == 0);\n\t    break;\n\t  case TPM_EO_NEQ:\n\t    // compare A != B\n\t    return (UnsignedCompareB(size, opA, size, opB) != 0);\n\t    break;\n\t  case TPM_EO_SIGNED_GT:\n\t    // compare A > B signed\n\t    return (SignedCompareB(size, opA, size, opB) > 0);\n\t    break;\n\t  case TPM_EO_UNSIGNED_GT:\n\t    // compare A > B unsigned\n\t    return (UnsignedCompareB(size, opA, size, opB) > 0);\n\t    break;\n\t  case TPM_EO_SIGNED_LT:\n\t    // compare A < B signed\n\t    return (SignedCompareB(size, opA, size, opB) < 0);\n\t    break;\n\t  case TPM_EO_UNSIGNED_LT:\n\t    // compare A < B unsigned\n\t    return (UnsignedCompareB(size, opA, size, opB) < 0);\n\t    break;\n\t  case TPM_EO_SIGNED_GE:\n\t    // compare A >= B signed\n\t    return (SignedCompareB(size, opA, size, opB) >= 0);\n\t    break;\n\t  case TPM_EO_UNSIGNED_GE:\n\t    // compare A >= B unsigned\n\t    return (UnsignedCompareB(size, opA, size, opB) >= 0);\n\t    break;\n\t  case TPM_EO_SIGNED_LE:\n\t    // compare A <= B signed\n\t    return (SignedCompareB(size, opA, size, opB) <= 0);\n\t    break;\n\t  case TPM_EO_UNSIGNED_LE:\n\t    // compare A <= B unsigned\n\t    return (UnsignedCompareB(size, opA, size, opB) <= 0);\n\t    break;\n\t  case TPM_EO_BITSET:\n\t    // All bits SET in B are SET in A. ((A&B)=B)\n\t      {\n\t\t  UINT32 i;\n\t\t  for(i = 0; i < size; i++)\n\t\t      if((opA[i] & opB[i]) != opB[i])\n\t\t\t  return FALSE;\n\t      }\n\t      break;\n\t  case TPM_EO_BITCLEAR:\n\t    // All bits SET in B are CLEAR in A. ((A&B)=0)\n\t      {\n\t\t  UINT32 i;\n\t\t  for(i = 0; i < size; i++)\n\t\t      if((opA[i] & opB[i]) != 0)\n\t\t\t  return FALSE;\n\t      }\n\t      break;\n\t  default:\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n    return TRUE;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/Power.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tSimulated Power State Transitions of the TPM\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Power.c 1490 2019-07-26 21:13:22Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.13 Power.c */\n/* 9.13.1 Description */\n/* This file contains functions that receive the simulated power state transitions of the TPM. */\n/* 9.13.2 Includes and Data Definitions */\n#define POWER_C\n#include \"Tpm.h\"\n/* 9.13.3 Functions */\n/* 9.13.3.1 TPMInit() */\n/* This function is used to process a power on event. */\n\nvoid\nTPMInit(\n\tvoid\n\t)\n{\n    // Set state as not initialized. This means that Startup is required\n    g_initialized = FALSE;\n    return;\n}\n\n/* 9.13.3.2 TPMRegisterStartup() */\n/* This function registers the fact that the TPM has been initialized (a TPM2_Startup() has\n   completed successfully). */\n\nBOOL\nTPMRegisterStartup(\n\t\t   void\n\t\t   )\n{\n    g_initialized = TRUE;\n    return TRUE;\n}\n\n/* 9.13.3.3 TPMIsStarted() */\n/* Indicates if the TPM has been initialized (a TPM2_Startup() has completed successfully after a\n   _TPM_Init()). */\n/* Return Values Meaning */\n/* TRUE TPM has been initialized */\n/* FALSE TPM has not been initialized */\n\nBOOL\nTPMIsStarted(\n\t     void\n\t     )\n{\n    return g_initialized;\n}\n\n"
  },
  {
    "path": "ftpm-opensbi/src/PowerPlat.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t Platform Power Support    \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: PowerPlat.c 1529 2019-11-21 23:29:01Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.7 PowerPlat.c */\n/* C.7.1. Includes and Function Prototypes */\n#include    \"Platform.h\"\n#include    \"PlatformACT_fp.h\"\t\t/* added kgold */\n#include    \"_TPM_Init_fp.h\"\n/* C.7.2. Functions */\n/* C.7.2.1. _plat__Signal_PowerOn() */\n/* Signal platform power on */\nLIB_EXPORT int\n_plat__Signal_PowerOn(\n\t\t      void\n\t\t      )\n{\n    // Reset the timer\n    _plat__TimerReset();\n    // Need to indicate that we lost power\n    s_powerLost = TRUE;\n    return 0;\n}\n/* C.7.2.2. _plat__WasPowerLost() */\n/* Test whether power was lost before a _TPM_Init(). */\n/* This function will clear the hardware indication of power loss before return. This means that\n   there can only be one spot in the TPM code where this value gets read. This method is used here\n   as it is the most difficult to manage in the TPM code and, if the hardware actually works this\n   way, it is hard to make it look like anything else. So, the burden is placed on the TPM code\n   rather than the platform code */\n/* Return Values Meaning */\n/* TRUE(1) power was lost */\n/* FALSE(0)\tpower was not lost */\nLIB_EXPORT int\n_plat__WasPowerLost(\n\t\t    void\n\t\t    )\n{\n    int retVal = s_powerLost;\n    s_powerLost = FALSE;\n    return retVal;\n}\n/* C.7.2.3. _plat_Signal_Reset() */\n/* This a TPM reset without a power loss. */\nLIB_EXPORT int\n_plat__Signal_Reset(\n\t\t    void\n\t\t    )\n{\n    // Initialize locality\n    s_locality = 0;\n    // Command cancel\n    s_isCanceled = FALSE;\n    _TPM_Init();\n    // if we are doing reset but did not have a power failure, then we should\n    // not need to reload NV ...\n    return 0;\n}\n/* C.7.2.4. _plat__Signal_PowerOff() */\n/* Signal platform power off */\nLIB_EXPORT void\n_plat__Signal_PowerOff(\n\t\t       void\n\t\t       )\n{\n    // Prepare NV memory for power off\n    _plat__NVDisable((void*)FALSE, 0);\n#if ACT_SUPPORT\n    // Disable tick ACT tick processing\n    _plat__ACT_EnableTicks(FALSE);\n#endif    // Disable tick ACT tick processing\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/PrimeData.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tProduct of all of the Primes up to 1000\t     \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n\n// This table is the product of all of the primes up to 1000.\n// Checking to see if there is a GCD between a prime candidate\n// and this number will eliminate many prime candidates from\n// consideration before running Miller-Rabin on the result.\n\nconst CRYPT_INT_BUF(smallprimecomp, 43 * RADIX_BITS) s_CompositeOfSmallPrimes_ =\n    {44, 44, {0x2ED42696, 0x2BBFA177, 0x4820594F, 0xF73F4841, 0xBFAC313A, 0xCAC3EB81,\n\t      0xF6F26BF8, 0x7FAB5061, 0x59746FB7, 0xF71377F6, 0x3B19855B, 0xCBD03132,\n\t      0xBB92EF1B, 0x3AC3152C, 0xE87C8273, 0xC0AE0E69, 0x74A9E295, 0x448CCE86,\n\t      0x63CA1907, 0x8A0BF944, 0xF8CC3BE0, 0xC26F0AF5, 0xC501C02F, 0x6579441A,\n\t      0xD1099CDA, 0x6BC76A00, 0xC81A3228, 0xBFB1AB25, 0x70FA3841, 0x51B3D076,\n\t      0xCC2359ED, 0xD9EE0769, 0x75E47AF0, 0xD45FF31E, 0x52CCE4F6, 0x04DBC891,\n\t      0x96658ED2, 0x1753EFE5, 0x3AE4A5A6, 0x8FD4A97F, 0x8B15E7EB, 0x0243C3E1,\n\t      0xE0F0C31D, 0x0000000B}};\n\nconst Crypt_Int* s_CompositeOfSmallPrimes =\n    (const Crypt_Int*)&s_CompositeOfSmallPrimes_;\n\n// This table contains a bit for each of the odd values between 1 and 2^16 + 1.\n// This table allows fast checking of the primes in that range.\n// Don't change the size of this table unless you are prepared to do redo\n// IsPrimeInt().\n\nconst uint32_t      s_LastPrimeInTable = 65537;\nconst uint32_t      s_PrimeTableSize   = 4097;\nconst uint32_t      s_PrimesInTable    = 6542;\nconst unsigned char s_PrimeTable[] =\n    {0x6e, 0xcb, 0xb4, 0x64, 0x9a, 0x12, 0x6d, 0x81, 0x32, 0x4c, 0x4a, 0x86, 0x0d,\n     0x82, 0x96, 0x21, 0xc9, 0x34, 0x04, 0x5a, 0x20, 0x61, 0x89, 0xa4, 0x44, 0x11,\n     0x86, 0x29, 0xd1, 0x82, 0x28, 0x4a, 0x30, 0x40, 0x42, 0x32, 0x21, 0x99, 0x34,\n     0x08, 0x4b, 0x06, 0x25, 0x42, 0x84, 0x48, 0x8a, 0x14, 0x05, 0x42, 0x30, 0x6c,\n     0x08, 0xb4, 0x40, 0x0b, 0xa0, 0x08, 0x51, 0x12, 0x28, 0x89, 0x04, 0x65, 0x98,\n     0x30, 0x4c, 0x80, 0x96, 0x44, 0x12, 0x80, 0x21, 0x42, 0x12, 0x41, 0xc9, 0x04,\n     0x21, 0xc0, 0x32, 0x2d, 0x98, 0x00, 0x00, 0x49, 0x04, 0x08, 0x81, 0x96, 0x68,\n     0x82, 0xb0, 0x25, 0x08, 0x22, 0x48, 0x89, 0xa2, 0x40, 0x59, 0x26, 0x04, 0x90,\n     0x06, 0x40, 0x43, 0x30, 0x44, 0x92, 0x00, 0x69, 0x10, 0x82, 0x08, 0x08, 0xa4,\n     0x0d, 0x41, 0x12, 0x60, 0xc0, 0x00, 0x24, 0xd2, 0x22, 0x61, 0x08, 0x84, 0x04,\n     0x1b, 0x82, 0x01, 0xd3, 0x10, 0x01, 0x02, 0xa0, 0x44, 0xc0, 0x22, 0x60, 0x91,\n     0x14, 0x0c, 0x40, 0xa6, 0x04, 0xd2, 0x94, 0x20, 0x09, 0x94, 0x20, 0x52, 0x00,\n     0x08, 0x10, 0xa2, 0x4c, 0x00, 0x82, 0x01, 0x51, 0x10, 0x08, 0x8b, 0xa4, 0x25,\n     0x9a, 0x30, 0x44, 0x81, 0x10, 0x4c, 0x03, 0x02, 0x25, 0x52, 0x80, 0x08, 0x49,\n     0x84, 0x20, 0x50, 0x32, 0x00, 0x18, 0xa2, 0x40, 0x11, 0x24, 0x28, 0x01, 0x84,\n     0x01, 0x01, 0xa0, 0x41, 0x0a, 0x12, 0x45, 0x00, 0x36, 0x08, 0x00, 0x26, 0x29,\n     0x83, 0x82, 0x61, 0xc0, 0x80, 0x04, 0x10, 0x10, 0x6d, 0x00, 0x22, 0x48, 0x58,\n     0x26, 0x0c, 0xc2, 0x10, 0x48, 0x89, 0x24, 0x20, 0x58, 0x20, 0x45, 0x88, 0x24,\n     0x00, 0x19, 0x02, 0x25, 0xc0, 0x10, 0x68, 0x08, 0x14, 0x01, 0xca, 0x32, 0x28,\n     0x80, 0x00, 0x04, 0x4b, 0x26, 0x00, 0x13, 0x90, 0x60, 0x82, 0x80, 0x25, 0xd0,\n     0x00, 0x01, 0x10, 0x32, 0x0c, 0x43, 0x86, 0x21, 0x11, 0x00, 0x08, 0x43, 0x24,\n     0x04, 0x48, 0x10, 0x0c, 0x90, 0x92, 0x00, 0x43, 0x20, 0x2d, 0x00, 0x06, 0x09,\n     0x88, 0x24, 0x40, 0xc0, 0x32, 0x09, 0x09, 0x82, 0x00, 0x53, 0x80, 0x08, 0x80,\n     0x96, 0x41, 0x81, 0x00, 0x40, 0x48, 0x10, 0x48, 0x08, 0x96, 0x48, 0x58, 0x20,\n     0x29, 0xc3, 0x80, 0x20, 0x02, 0x94, 0x60, 0x92, 0x00, 0x20, 0x81, 0x22, 0x44,\n     0x10, 0xa0, 0x05, 0x40, 0x90, 0x01, 0x49, 0x20, 0x04, 0x0a, 0x00, 0x24, 0x89,\n     0x34, 0x48, 0x13, 0x80, 0x2c, 0xc0, 0x82, 0x29, 0x00, 0x24, 0x45, 0x08, 0x00,\n     0x08, 0x98, 0x36, 0x04, 0x52, 0x84, 0x04, 0xd0, 0x04, 0x00, 0x8a, 0x90, 0x44,\n     0x82, 0x32, 0x65, 0x18, 0x90, 0x00, 0x0a, 0x02, 0x01, 0x40, 0x02, 0x28, 0x40,\n     0xa4, 0x04, 0x92, 0x30, 0x04, 0x11, 0x86, 0x08, 0x42, 0x00, 0x2c, 0x52, 0x04,\n     0x08, 0xc9, 0x84, 0x60, 0x48, 0x12, 0x09, 0x99, 0x24, 0x44, 0x00, 0x24, 0x00,\n     0x03, 0x14, 0x21, 0x00, 0x10, 0x01, 0x1a, 0x32, 0x05, 0x88, 0x20, 0x40, 0x40,\n     0x06, 0x09, 0xc3, 0x84, 0x40, 0x01, 0x30, 0x60, 0x18, 0x02, 0x68, 0x11, 0x90,\n     0x0c, 0x02, 0xa2, 0x04, 0x00, 0x86, 0x29, 0x89, 0x14, 0x24, 0x82, 0x02, 0x41,\n     0x08, 0x80, 0x04, 0x19, 0x80, 0x08, 0x10, 0x12, 0x68, 0x42, 0xa4, 0x04, 0x00,\n     0x02, 0x61, 0x10, 0x06, 0x0c, 0x10, 0x00, 0x01, 0x12, 0x10, 0x20, 0x03, 0x94,\n     0x21, 0x42, 0x12, 0x65, 0x18, 0x94, 0x0c, 0x0a, 0x04, 0x28, 0x01, 0x14, 0x29,\n     0x0a, 0xa4, 0x40, 0xd0, 0x00, 0x40, 0x01, 0x90, 0x04, 0x41, 0x20, 0x2d, 0x40,\n     0x82, 0x48, 0xc1, 0x20, 0x00, 0x10, 0x30, 0x01, 0x08, 0x24, 0x04, 0x59, 0x84,\n     0x24, 0x00, 0x02, 0x29, 0x82, 0x00, 0x61, 0x58, 0x02, 0x48, 0x81, 0x16, 0x48,\n     0x10, 0x00, 0x21, 0x11, 0x06, 0x00, 0xca, 0xa0, 0x40, 0x02, 0x00, 0x04, 0x91,\n     0xb0, 0x00, 0x42, 0x04, 0x0c, 0x81, 0x06, 0x09, 0x48, 0x14, 0x25, 0x92, 0x20,\n     0x25, 0x11, 0xa0, 0x00, 0x0a, 0x86, 0x0c, 0xc1, 0x02, 0x48, 0x00, 0x20, 0x45,\n     0x08, 0x32, 0x00, 0x98, 0x06, 0x04, 0x13, 0x22, 0x00, 0x82, 0x04, 0x48, 0x81,\n     0x14, 0x44, 0x82, 0x12, 0x24, 0x18, 0x10, 0x40, 0x43, 0x80, 0x28, 0xd0, 0x04,\n     0x20, 0x81, 0x24, 0x64, 0xd8, 0x00, 0x2c, 0x09, 0x12, 0x08, 0x41, 0xa2, 0x00,\n     0x00, 0x02, 0x41, 0xca, 0x20, 0x41, 0xc0, 0x10, 0x01, 0x18, 0xa4, 0x04, 0x18,\n     0xa4, 0x20, 0x12, 0x94, 0x20, 0x83, 0xa0, 0x40, 0x02, 0x32, 0x44, 0x80, 0x04,\n     0x00, 0x18, 0x00, 0x0c, 0x40, 0x86, 0x60, 0x8a, 0x00, 0x64, 0x88, 0x12, 0x05,\n     0x01, 0x82, 0x00, 0x4a, 0xa2, 0x01, 0xc1, 0x10, 0x61, 0x09, 0x04, 0x01, 0x88,\n     0x00, 0x60, 0x01, 0xb4, 0x40, 0x08, 0x06, 0x01, 0x03, 0x80, 0x08, 0x40, 0x94,\n     0x04, 0x8a, 0x20, 0x29, 0x80, 0x02, 0x0c, 0x52, 0x02, 0x01, 0x42, 0x84, 0x00,\n     0x80, 0x84, 0x64, 0x02, 0x32, 0x48, 0x00, 0x30, 0x44, 0x40, 0x22, 0x21, 0x00,\n     0x02, 0x08, 0xc3, 0xa0, 0x04, 0xd0, 0x20, 0x40, 0x18, 0x16, 0x40, 0x40, 0x00,\n     0x28, 0x52, 0x90, 0x08, 0x82, 0x14, 0x01, 0x18, 0x10, 0x08, 0x09, 0x82, 0x40,\n     0x0a, 0xa0, 0x20, 0x93, 0x80, 0x08, 0xc0, 0x00, 0x20, 0x52, 0x00, 0x05, 0x01,\n     0x10, 0x40, 0x11, 0x06, 0x0c, 0x82, 0x00, 0x00, 0x4b, 0x90, 0x44, 0x9a, 0x00,\n     0x28, 0x80, 0x90, 0x04, 0x4a, 0x06, 0x09, 0x43, 0x02, 0x28, 0x00, 0x34, 0x01,\n     0x18, 0x00, 0x65, 0x09, 0x80, 0x44, 0x03, 0x00, 0x24, 0x02, 0x82, 0x61, 0x48,\n     0x14, 0x41, 0x00, 0x12, 0x28, 0x00, 0x34, 0x08, 0x51, 0x04, 0x05, 0x12, 0x90,\n     0x28, 0x89, 0x84, 0x60, 0x12, 0x10, 0x49, 0x10, 0x26, 0x40, 0x49, 0x82, 0x00,\n     0x91, 0x10, 0x01, 0x0a, 0x24, 0x40, 0x88, 0x10, 0x4c, 0x10, 0x04, 0x00, 0x50,\n     0xa2, 0x2c, 0x40, 0x90, 0x48, 0x0a, 0xb0, 0x01, 0x50, 0x12, 0x08, 0x00, 0xa4,\n     0x04, 0x09, 0xa0, 0x28, 0x92, 0x02, 0x00, 0x43, 0x10, 0x21, 0x02, 0x20, 0x41,\n     0x81, 0x32, 0x00, 0x08, 0x04, 0x0c, 0x52, 0x00, 0x21, 0x49, 0x84, 0x20, 0x10,\n     0x02, 0x01, 0x81, 0x10, 0x48, 0x40, 0x22, 0x01, 0x01, 0x84, 0x69, 0xc1, 0x30,\n     0x01, 0xc8, 0x02, 0x44, 0x88, 0x00, 0x0c, 0x01, 0x02, 0x2d, 0xc0, 0x12, 0x61,\n     0x00, 0xa0, 0x00, 0xc0, 0x30, 0x40, 0x01, 0x12, 0x08, 0x0b, 0x20, 0x00, 0x80,\n     0x94, 0x40, 0x01, 0x84, 0x40, 0x00, 0x32, 0x00, 0x10, 0x84, 0x00, 0x0b, 0x24,\n     0x00, 0x01, 0x06, 0x29, 0x8a, 0x84, 0x41, 0x80, 0x10, 0x08, 0x08, 0x94, 0x4c,\n     0x03, 0x80, 0x01, 0x40, 0x96, 0x40, 0x41, 0x20, 0x20, 0x50, 0x22, 0x25, 0x89,\n     0xa2, 0x40, 0x40, 0xa4, 0x20, 0x02, 0x86, 0x28, 0x01, 0x20, 0x21, 0x4a, 0x10,\n     0x08, 0x00, 0x14, 0x08, 0x40, 0x04, 0x25, 0x42, 0x02, 0x21, 0x43, 0x10, 0x04,\n     0x92, 0x00, 0x21, 0x11, 0xa0, 0x4c, 0x18, 0x22, 0x09, 0x03, 0x84, 0x41, 0x89,\n     0x10, 0x04, 0x82, 0x22, 0x24, 0x01, 0x14, 0x08, 0x08, 0x84, 0x08, 0xc1, 0x00,\n     0x09, 0x42, 0xb0, 0x41, 0x8a, 0x02, 0x00, 0x80, 0x36, 0x04, 0x49, 0xa0, 0x24,\n     0x91, 0x00, 0x00, 0x02, 0x94, 0x41, 0x92, 0x02, 0x01, 0x08, 0x06, 0x08, 0x09,\n     0x00, 0x01, 0xd0, 0x16, 0x28, 0x89, 0x80, 0x60, 0x00, 0x00, 0x68, 0x01, 0x90,\n     0x0c, 0x50, 0x20, 0x01, 0x40, 0x80, 0x40, 0x42, 0x30, 0x41, 0x00, 0x20, 0x25,\n     0x81, 0x06, 0x40, 0x49, 0x00, 0x08, 0x01, 0x12, 0x49, 0x00, 0xa0, 0x20, 0x18,\n     0x30, 0x05, 0x01, 0xa6, 0x00, 0x10, 0x24, 0x28, 0x00, 0x02, 0x20, 0xc8, 0x20,\n     0x00, 0x88, 0x12, 0x0c, 0x90, 0x92, 0x00, 0x02, 0x26, 0x01, 0x42, 0x16, 0x49,\n     0x00, 0x04, 0x24, 0x42, 0x02, 0x01, 0x88, 0x80, 0x0c, 0x1a, 0x80, 0x08, 0x10,\n     0x00, 0x60, 0x02, 0x94, 0x44, 0x88, 0x00, 0x69, 0x11, 0x30, 0x08, 0x12, 0xa0,\n     0x24, 0x13, 0x84, 0x00, 0x82, 0x00, 0x65, 0xc0, 0x10, 0x28, 0x00, 0x30, 0x04,\n     0x03, 0x20, 0x01, 0x11, 0x06, 0x01, 0xc8, 0x80, 0x00, 0xc2, 0x20, 0x08, 0x10,\n     0x82, 0x0c, 0x13, 0x02, 0x0c, 0x52, 0x06, 0x40, 0x00, 0xb0, 0x61, 0x40, 0x10,\n     0x01, 0x98, 0x86, 0x04, 0x10, 0x84, 0x08, 0x92, 0x14, 0x60, 0x41, 0x80, 0x41,\n     0x1a, 0x10, 0x04, 0x81, 0x22, 0x40, 0x41, 0x20, 0x29, 0x52, 0x00, 0x41, 0x08,\n     0x34, 0x60, 0x10, 0x00, 0x28, 0x01, 0x10, 0x40, 0x00, 0x84, 0x08, 0x42, 0x90,\n     0x20, 0x48, 0x04, 0x04, 0x52, 0x02, 0x00, 0x08, 0x20, 0x04, 0x00, 0x82, 0x0d,\n     0x00, 0x82, 0x40, 0x02, 0x10, 0x05, 0x48, 0x20, 0x40, 0x99, 0x00, 0x00, 0x01,\n     0x06, 0x24, 0xc0, 0x00, 0x68, 0x82, 0x04, 0x21, 0x12, 0x10, 0x44, 0x08, 0x04,\n     0x00, 0x40, 0xa6, 0x20, 0xd0, 0x16, 0x09, 0xc9, 0x24, 0x41, 0x02, 0x20, 0x0c,\n     0x09, 0x92, 0x40, 0x12, 0x00, 0x00, 0x40, 0x00, 0x09, 0x43, 0x84, 0x20, 0x98,\n     0x02, 0x01, 0x11, 0x24, 0x00, 0x43, 0x24, 0x00, 0x03, 0x90, 0x08, 0x41, 0x30,\n     0x24, 0x58, 0x20, 0x4c, 0x80, 0x82, 0x08, 0x10, 0x24, 0x25, 0x81, 0x06, 0x41,\n     0x09, 0x10, 0x20, 0x18, 0x10, 0x44, 0x80, 0x10, 0x00, 0x4a, 0x24, 0x0d, 0x01,\n     0x94, 0x28, 0x80, 0x30, 0x00, 0xc0, 0x02, 0x60, 0x10, 0x84, 0x0c, 0x02, 0x00,\n     0x09, 0x02, 0x82, 0x01, 0x08, 0x10, 0x04, 0xc2, 0x20, 0x68, 0x09, 0x06, 0x04,\n     0x18, 0x00, 0x00, 0x11, 0x90, 0x08, 0x0b, 0x10, 0x21, 0x82, 0x02, 0x0c, 0x10,\n     0xb6, 0x08, 0x00, 0x26, 0x00, 0x41, 0x02, 0x01, 0x4a, 0x24, 0x21, 0x1a, 0x20,\n     0x24, 0x80, 0x00, 0x44, 0x02, 0x00, 0x2d, 0x40, 0x02, 0x00, 0x8b, 0x94, 0x20,\n     0x10, 0x00, 0x20, 0x90, 0xa6, 0x40, 0x13, 0x00, 0x2c, 0x11, 0x86, 0x61, 0x01,\n     0x80, 0x41, 0x10, 0x02, 0x04, 0x81, 0x30, 0x48, 0x48, 0x20, 0x28, 0x50, 0x80,\n     0x21, 0x8a, 0x10, 0x04, 0x08, 0x10, 0x09, 0x10, 0x10, 0x48, 0x42, 0xa0, 0x0c,\n     0x82, 0x92, 0x60, 0xc0, 0x20, 0x05, 0xd2, 0x20, 0x40, 0x01, 0x00, 0x04, 0x08,\n     0x82, 0x2d, 0x82, 0x02, 0x00, 0x48, 0x80, 0x41, 0x48, 0x10, 0x00, 0x91, 0x04,\n     0x04, 0x03, 0x84, 0x00, 0xc2, 0x04, 0x68, 0x00, 0x00, 0x64, 0xc0, 0x22, 0x40,\n     0x08, 0x32, 0x44, 0x09, 0x86, 0x00, 0x91, 0x02, 0x28, 0x01, 0x00, 0x64, 0x48,\n     0x00, 0x24, 0x10, 0x90, 0x00, 0x43, 0x00, 0x21, 0x52, 0x86, 0x41, 0x8b, 0x90,\n     0x20, 0x40, 0x20, 0x08, 0x88, 0x04, 0x44, 0x13, 0x20, 0x00, 0x02, 0x84, 0x60,\n     0x81, 0x90, 0x24, 0x40, 0x30, 0x00, 0x08, 0x10, 0x08, 0x08, 0x02, 0x01, 0x10,\n     0x04, 0x20, 0x43, 0xb4, 0x40, 0x90, 0x12, 0x68, 0x01, 0x80, 0x4c, 0x18, 0x00,\n     0x08, 0xc0, 0x12, 0x49, 0x40, 0x10, 0x24, 0x1a, 0x00, 0x41, 0x89, 0x24, 0x4c,\n     0x10, 0x00, 0x04, 0x52, 0x10, 0x09, 0x4a, 0x20, 0x41, 0x48, 0x22, 0x69, 0x11,\n     0x14, 0x08, 0x10, 0x06, 0x24, 0x80, 0x84, 0x28, 0x00, 0x10, 0x00, 0x40, 0x10,\n     0x01, 0x08, 0x26, 0x08, 0x48, 0x06, 0x28, 0x00, 0x14, 0x01, 0x42, 0x84, 0x04,\n     0x0a, 0x20, 0x00, 0x01, 0x82, 0x08, 0x00, 0x82, 0x24, 0x12, 0x04, 0x40, 0x40,\n     0xa0, 0x40, 0x90, 0x10, 0x04, 0x90, 0x22, 0x40, 0x10, 0x20, 0x2c, 0x80, 0x10,\n     0x28, 0x43, 0x00, 0x04, 0x58, 0x00, 0x01, 0x81, 0x10, 0x48, 0x09, 0x20, 0x21,\n     0x83, 0x04, 0x00, 0x42, 0xa4, 0x44, 0x00, 0x00, 0x6c, 0x10, 0xa0, 0x44, 0x48,\n     0x80, 0x00, 0x83, 0x80, 0x48, 0xc9, 0x00, 0x00, 0x00, 0x02, 0x05, 0x10, 0xb0,\n     0x04, 0x13, 0x04, 0x29, 0x10, 0x92, 0x40, 0x08, 0x04, 0x44, 0x82, 0x22, 0x00,\n     0x19, 0x20, 0x00, 0x19, 0x20, 0x01, 0x81, 0x90, 0x60, 0x8a, 0x00, 0x41, 0xc0,\n     0x02, 0x45, 0x10, 0x04, 0x00, 0x02, 0xa2, 0x09, 0x40, 0x10, 0x21, 0x49, 0x20,\n     0x01, 0x42, 0x30, 0x2c, 0x00, 0x14, 0x44, 0x01, 0x22, 0x04, 0x02, 0x92, 0x08,\n     0x89, 0x04, 0x21, 0x80, 0x10, 0x05, 0x01, 0x20, 0x40, 0x41, 0x80, 0x04, 0x00,\n     0x12, 0x09, 0x40, 0xb0, 0x64, 0x58, 0x32, 0x01, 0x08, 0x90, 0x00, 0x41, 0x04,\n     0x09, 0xc1, 0x80, 0x61, 0x08, 0x90, 0x00, 0x9a, 0x00, 0x24, 0x01, 0x12, 0x08,\n     0x02, 0x26, 0x05, 0x82, 0x06, 0x08, 0x08, 0x00, 0x20, 0x48, 0x20, 0x00, 0x18,\n     0x24, 0x48, 0x03, 0x02, 0x00, 0x11, 0x00, 0x09, 0x00, 0x84, 0x01, 0x4a, 0x10,\n     0x01, 0x98, 0x00, 0x04, 0x18, 0x86, 0x00, 0xc0, 0x00, 0x20, 0x81, 0x80, 0x04,\n     0x10, 0x30, 0x05, 0x00, 0xb4, 0x0c, 0x4a, 0x82, 0x29, 0x91, 0x02, 0x28, 0x00,\n     0x20, 0x44, 0xc0, 0x00, 0x2c, 0x91, 0x80, 0x40, 0x01, 0xa2, 0x00, 0x12, 0x04,\n     0x09, 0xc3, 0x20, 0x00, 0x08, 0x02, 0x0c, 0x10, 0x22, 0x04, 0x00, 0x00, 0x2c,\n     0x11, 0x86, 0x00, 0xc0, 0x00, 0x00, 0x12, 0x32, 0x40, 0x89, 0x80, 0x40, 0x40,\n     0x02, 0x05, 0x50, 0x86, 0x60, 0x82, 0xa4, 0x60, 0x0a, 0x12, 0x4d, 0x80, 0x90,\n     0x08, 0x12, 0x80, 0x09, 0x02, 0x14, 0x48, 0x01, 0x24, 0x20, 0x8a, 0x00, 0x44,\n     0x90, 0x04, 0x04, 0x01, 0x02, 0x00, 0xd1, 0x12, 0x00, 0x0a, 0x04, 0x40, 0x00,\n     0x32, 0x21, 0x81, 0x24, 0x08, 0x19, 0x84, 0x20, 0x02, 0x04, 0x08, 0x89, 0x80,\n     0x24, 0x02, 0x02, 0x68, 0x18, 0x82, 0x44, 0x42, 0x00, 0x21, 0x40, 0x00, 0x28,\n     0x01, 0x80, 0x45, 0x82, 0x20, 0x40, 0x11, 0x80, 0x0c, 0x02, 0x00, 0x24, 0x40,\n     0x90, 0x01, 0x40, 0x20, 0x20, 0x50, 0x20, 0x28, 0x19, 0x00, 0x40, 0x09, 0x20,\n     0x08, 0x80, 0x04, 0x60, 0x40, 0x80, 0x20, 0x08, 0x30, 0x49, 0x09, 0x34, 0x00,\n     0x11, 0x24, 0x24, 0x82, 0x00, 0x41, 0xc2, 0x00, 0x04, 0x92, 0x02, 0x24, 0x80,\n     0x00, 0x0c, 0x02, 0xa0, 0x00, 0x01, 0x06, 0x60, 0x41, 0x04, 0x21, 0xd0, 0x00,\n     0x01, 0x01, 0x00, 0x48, 0x12, 0x84, 0x04, 0x91, 0x12, 0x08, 0x00, 0x24, 0x44,\n     0x00, 0x12, 0x41, 0x18, 0x26, 0x0c, 0x41, 0x80, 0x00, 0x52, 0x04, 0x20, 0x09,\n     0x00, 0x24, 0x90, 0x20, 0x48, 0x18, 0x02, 0x00, 0x03, 0xa2, 0x09, 0xd0, 0x14,\n     0x00, 0x8a, 0x84, 0x25, 0x4a, 0x00, 0x20, 0x98, 0x14, 0x40, 0x00, 0xa2, 0x05,\n     0x00, 0x00, 0x00, 0x40, 0x14, 0x01, 0x58, 0x20, 0x2c, 0x80, 0x84, 0x00, 0x09,\n     0x20, 0x20, 0x91, 0x02, 0x08, 0x02, 0xb0, 0x41, 0x08, 0x30, 0x00, 0x09, 0x10,\n     0x00, 0x18, 0x02, 0x21, 0x02, 0x02, 0x00, 0x00, 0x24, 0x44, 0x08, 0x12, 0x60,\n     0x00, 0xb2, 0x44, 0x12, 0x02, 0x0c, 0xc0, 0x80, 0x40, 0xc8, 0x20, 0x04, 0x50,\n     0x20, 0x05, 0x00, 0xb0, 0x04, 0x0b, 0x04, 0x29, 0x53, 0x00, 0x61, 0x48, 0x30,\n     0x00, 0x82, 0x20, 0x29, 0x00, 0x16, 0x00, 0x53, 0x22, 0x20, 0x43, 0x10, 0x48,\n     0x00, 0x80, 0x04, 0xd2, 0x00, 0x40, 0x00, 0xa2, 0x44, 0x03, 0x80, 0x29, 0x00,\n     0x04, 0x08, 0xc0, 0x04, 0x64, 0x40, 0x30, 0x28, 0x09, 0x84, 0x44, 0x50, 0x80,\n     0x21, 0x02, 0x92, 0x00, 0xc0, 0x10, 0x60, 0x88, 0x22, 0x08, 0x80, 0x00, 0x00,\n     0x18, 0x84, 0x04, 0x83, 0x96, 0x00, 0x81, 0x20, 0x05, 0x02, 0x00, 0x45, 0x88,\n     0x84, 0x00, 0x51, 0x20, 0x20, 0x51, 0x86, 0x41, 0x4b, 0x94, 0x00, 0x80, 0x00,\n     0x08, 0x11, 0x20, 0x4c, 0x58, 0x80, 0x04, 0x03, 0x06, 0x20, 0x89, 0x00, 0x05,\n     0x08, 0x22, 0x05, 0x90, 0x00, 0x40, 0x00, 0x82, 0x09, 0x50, 0x00, 0x00, 0x00,\n     0xa0, 0x41, 0xc2, 0x20, 0x08, 0x00, 0x16, 0x08, 0x40, 0x26, 0x21, 0xd0, 0x90,\n     0x08, 0x81, 0x90, 0x41, 0x00, 0x02, 0x44, 0x08, 0x10, 0x0c, 0x0a, 0x86, 0x09,\n     0x90, 0x04, 0x00, 0xc8, 0xa0, 0x04, 0x08, 0x30, 0x20, 0x89, 0x84, 0x00, 0x11,\n     0x22, 0x2c, 0x40, 0x00, 0x08, 0x02, 0xb0, 0x01, 0x48, 0x02, 0x01, 0x09, 0x20,\n     0x04, 0x03, 0x04, 0x00, 0x80, 0x02, 0x60, 0x42, 0x30, 0x21, 0x4a, 0x10, 0x44,\n     0x09, 0x02, 0x00, 0x01, 0x24, 0x00, 0x12, 0x82, 0x21, 0x80, 0xa4, 0x20, 0x10,\n     0x02, 0x04, 0x91, 0xa0, 0x40, 0x18, 0x04, 0x00, 0x02, 0x06, 0x69, 0x09, 0x00,\n     0x05, 0x58, 0x02, 0x01, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x03, 0x92, 0x20,\n     0x00, 0x34, 0x01, 0xc8, 0x20, 0x48, 0x08, 0x30, 0x08, 0x42, 0x80, 0x20, 0x91,\n     0x90, 0x68, 0x01, 0x04, 0x40, 0x12, 0x02, 0x61, 0x00, 0x12, 0x08, 0x01, 0xa0,\n     0x00, 0x11, 0x04, 0x21, 0x48, 0x04, 0x24, 0x92, 0x00, 0x0c, 0x01, 0x84, 0x04,\n     0x00, 0x00, 0x01, 0x12, 0x96, 0x40, 0x01, 0xa0, 0x41, 0x88, 0x22, 0x28, 0x88,\n     0x00, 0x44, 0x42, 0x80, 0x24, 0x12, 0x14, 0x01, 0x42, 0x90, 0x60, 0x1a, 0x10,\n     0x04, 0x81, 0x10, 0x48, 0x08, 0x06, 0x29, 0x83, 0x02, 0x40, 0x02, 0x24, 0x64,\n     0x80, 0x10, 0x05, 0x80, 0x10, 0x40, 0x02, 0x02, 0x08, 0x42, 0x84, 0x01, 0x09,\n     0x20, 0x04, 0x50, 0x00, 0x60, 0x11, 0x30, 0x40, 0x13, 0x02, 0x04, 0x81, 0x00,\n     0x09, 0x08, 0x20, 0x45, 0x4a, 0x10, 0x61, 0x90, 0x26, 0x0c, 0x08, 0x02, 0x21,\n     0x91, 0x00, 0x60, 0x02, 0x04, 0x00, 0x02, 0x00, 0x0c, 0x08, 0x06, 0x08, 0x48,\n     0x84, 0x08, 0x11, 0x02, 0x00, 0x80, 0xa4, 0x00, 0x5a, 0x20, 0x00, 0x88, 0x04,\n     0x04, 0x02, 0x00, 0x09, 0x00, 0x14, 0x08, 0x49, 0x14, 0x20, 0xc8, 0x00, 0x04,\n     0x91, 0xa0, 0x40, 0x59, 0x80, 0x00, 0x12, 0x10, 0x00, 0x80, 0x80, 0x65, 0x00,\n     0x00, 0x04, 0x00, 0x80, 0x40, 0x19, 0x00, 0x21, 0x03, 0x84, 0x60, 0xc0, 0x04,\n     0x24, 0x1a, 0x12, 0x61, 0x80, 0x80, 0x08, 0x02, 0x04, 0x09, 0x42, 0x12, 0x20,\n     0x08, 0x34, 0x04, 0x90, 0x20, 0x01, 0x01, 0xa0, 0x00, 0x0b, 0x00, 0x08, 0x91,\n     0x92, 0x40, 0x02, 0x34, 0x40, 0x88, 0x10, 0x61, 0x19, 0x02, 0x00, 0x40, 0x04,\n     0x25, 0xc0, 0x80, 0x68, 0x08, 0x04, 0x21, 0x80, 0x22, 0x04, 0x00, 0xa0, 0x0c,\n     0x01, 0x84, 0x20, 0x41, 0x00, 0x08, 0x8a, 0x00, 0x20, 0x8a, 0x00, 0x48, 0x88,\n     0x04, 0x04, 0x11, 0x82, 0x08, 0x40, 0x86, 0x09, 0x49, 0xa4, 0x40, 0x00, 0x10,\n     0x01, 0x01, 0xa2, 0x04, 0x50, 0x80, 0x0c, 0x80, 0x00, 0x48, 0x82, 0xa0, 0x01,\n     0x18, 0x12, 0x41, 0x01, 0x04, 0x48, 0x41, 0x00, 0x24, 0x01, 0x00, 0x00, 0x88,\n     0x14, 0x00, 0x02, 0x00, 0x68, 0x01, 0x20, 0x08, 0x4a, 0x22, 0x08, 0x83, 0x80,\n     0x00, 0x89, 0x04, 0x01, 0xc2, 0x00, 0x00, 0x00, 0x34, 0x04, 0x00, 0x82, 0x28,\n     0x02, 0x02, 0x41, 0x4a, 0x90, 0x05, 0x82, 0x02, 0x09, 0x80, 0x24, 0x04, 0x41,\n     0x00, 0x01, 0x92, 0x80, 0x28, 0x01, 0x14, 0x00, 0x50, 0x20, 0x4c, 0x10, 0xb0,\n     0x04, 0x43, 0xa4, 0x21, 0x90, 0x04, 0x01, 0x02, 0x00, 0x44, 0x48, 0x00, 0x64,\n     0x08, 0x06, 0x00, 0x42, 0x20, 0x08, 0x02, 0x92, 0x01, 0x4a, 0x00, 0x20, 0x50,\n     0x32, 0x25, 0x90, 0x22, 0x04, 0x09, 0x00, 0x08, 0x11, 0x80, 0x21, 0x01, 0x10,\n     0x05, 0x00, 0x32, 0x08, 0x88, 0x94, 0x08, 0x08, 0x24, 0x0d, 0xc1, 0x80, 0x40,\n     0x0b, 0x20, 0x40, 0x18, 0x12, 0x04, 0x00, 0x22, 0x40, 0x10, 0x26, 0x05, 0xc1,\n     0x82, 0x00, 0x01, 0x30, 0x24, 0x02, 0x22, 0x41, 0x08, 0x24, 0x48, 0x1a, 0x00,\n     0x25, 0xd2, 0x12, 0x28, 0x42, 0x00, 0x04, 0x40, 0x30, 0x41, 0x00, 0x02, 0x00,\n     0x13, 0x20, 0x24, 0xd1, 0x84, 0x08, 0x89, 0x80, 0x04, 0x52, 0x00, 0x44, 0x18,\n     0xa4, 0x00, 0x00, 0x06, 0x20, 0x91, 0x10, 0x09, 0x42, 0x20, 0x24, 0x40, 0x30,\n     0x28, 0x00, 0x84, 0x40, 0x40, 0x80, 0x08, 0x10, 0x04, 0x09, 0x08, 0x04, 0x40,\n     0x08, 0x22, 0x00, 0x19, 0x02, 0x00, 0x00, 0x80, 0x2c, 0x02, 0x02, 0x21, 0x01,\n     0x90, 0x20, 0x40, 0x00, 0x0c, 0x00, 0x34, 0x48, 0x58, 0x20, 0x01, 0x43, 0x04,\n     0x20, 0x80, 0x14, 0x00, 0x90, 0x00, 0x6d, 0x11, 0x00, 0x00, 0x40, 0x20, 0x00,\n     0x03, 0x10, 0x40, 0x88, 0x30, 0x05, 0x4a, 0x00, 0x65, 0x10, 0x24, 0x08, 0x18,\n     0x84, 0x28, 0x03, 0x80, 0x20, 0x42, 0xb0, 0x40, 0x00, 0x10, 0x69, 0x19, 0x04,\n     0x00, 0x00, 0x80, 0x04, 0xc2, 0x04, 0x00, 0x01, 0x00, 0x05, 0x00, 0x22, 0x25,\n     0x08, 0x96, 0x04, 0x02, 0x22, 0x00, 0xd0, 0x10, 0x29, 0x01, 0xa0, 0x60, 0x08,\n     0x10, 0x04, 0x01, 0x16, 0x44, 0x10, 0x02, 0x28, 0x02, 0x82, 0x48, 0x40, 0x84,\n     0x20, 0x90, 0x22, 0x28, 0x80, 0x04, 0x00, 0x40, 0x04, 0x24, 0x00, 0x80, 0x29,\n     0x03, 0x10, 0x60, 0x48, 0x00, 0x00, 0x81, 0xa0, 0x00, 0x51, 0x20, 0x0c, 0xd1,\n     0x00, 0x01, 0x41, 0x20, 0x04, 0x92, 0x00, 0x00, 0x10, 0x92, 0x00, 0x42, 0x04,\n     0x05, 0x01, 0x86, 0x40, 0x80, 0x10, 0x20, 0x52, 0x20, 0x21, 0x00, 0x10, 0x48,\n     0x0a, 0x02, 0x00, 0xd0, 0x12, 0x41, 0x48, 0x80, 0x04, 0x00, 0x00, 0x48, 0x09,\n     0x22, 0x04, 0x00, 0x24, 0x00, 0x43, 0x10, 0x60, 0x0a, 0x00, 0x44, 0x12, 0x20,\n     0x2c, 0x08, 0x20, 0x44, 0x00, 0x84, 0x09, 0x40, 0x06, 0x08, 0xc1, 0x00, 0x40,\n     0x80, 0x20, 0x00, 0x98, 0x12, 0x48, 0x10, 0xa2, 0x20, 0x00, 0x84, 0x48, 0xc0,\n     0x10, 0x20, 0x90, 0x12, 0x08, 0x98, 0x82, 0x00, 0x0a, 0xa0, 0x04, 0x03, 0x00,\n     0x28, 0xc3, 0x00, 0x44, 0x42, 0x10, 0x04, 0x08, 0x04, 0x40, 0x00, 0x00, 0x05,\n     0x10, 0x00, 0x21, 0x03, 0x80, 0x04, 0x88, 0x12, 0x69, 0x10, 0x00, 0x04, 0x08,\n     0x04, 0x04, 0x02, 0x84, 0x48, 0x49, 0x04, 0x20, 0x18, 0x02, 0x64, 0x80, 0x30,\n     0x08, 0x01, 0x02, 0x00, 0x52, 0x12, 0x49, 0x08, 0x20, 0x41, 0x88, 0x10, 0x48,\n     0x08, 0x34, 0x00, 0x01, 0x86, 0x05, 0xd0, 0x00, 0x00, 0x83, 0x84, 0x21, 0x40,\n     0x02, 0x41, 0x10, 0x80, 0x48, 0x40, 0xa2, 0x20, 0x51, 0x00, 0x00, 0x49, 0x00,\n     0x01, 0x90, 0x20, 0x40, 0x18, 0x02, 0x40, 0x02, 0x22, 0x05, 0x40, 0x80, 0x08,\n     0x82, 0x10, 0x20, 0x18, 0x00, 0x05, 0x01, 0x82, 0x40, 0x58, 0x00, 0x04, 0x81,\n     0x90, 0x29, 0x01, 0xa0, 0x64, 0x00, 0x22, 0x40, 0x01, 0xa2, 0x00, 0x18, 0x04,\n     0x0d, 0x00, 0x00, 0x60, 0x80, 0x94, 0x60, 0x82, 0x10, 0x0d, 0x80, 0x30, 0x0c,\n     0x12, 0x20, 0x00, 0x00, 0x12, 0x40, 0xc0, 0x20, 0x21, 0x58, 0x02, 0x41, 0x10,\n     0x80, 0x44, 0x03, 0x02, 0x04, 0x13, 0x90, 0x29, 0x08, 0x00, 0x44, 0xc0, 0x00,\n     0x21, 0x00, 0x26, 0x00, 0x1a, 0x80, 0x01, 0x13, 0x14, 0x20, 0x0a, 0x14, 0x20,\n     0x00, 0x32, 0x61, 0x08, 0x00, 0x40, 0x42, 0x20, 0x09, 0x80, 0x06, 0x01, 0x81,\n     0x80, 0x60, 0x42, 0x00, 0x68, 0x90, 0x82, 0x08, 0x42, 0x80, 0x04, 0x02, 0x80,\n     0x09, 0x0b, 0x04, 0x00, 0x98, 0x00, 0x0c, 0x81, 0x06, 0x44, 0x48, 0x84, 0x28,\n     0x03, 0x92, 0x00, 0x01, 0x80, 0x40, 0x0a, 0x00, 0x0c, 0x81, 0x02, 0x08, 0x51,\n     0x04, 0x28, 0x90, 0x02, 0x20, 0x09, 0x10, 0x60, 0x00, 0x00, 0x09, 0x81, 0xa0,\n     0x0c, 0x00, 0xa4, 0x09, 0x00, 0x02, 0x28, 0x80, 0x20, 0x00, 0x02, 0x02, 0x04,\n     0x81, 0x14, 0x04, 0x00, 0x04, 0x09, 0x11, 0x12, 0x60, 0x40, 0x20, 0x01, 0x48,\n     0x30, 0x40, 0x11, 0x00, 0x08, 0x0a, 0x86, 0x00, 0x00, 0x04, 0x60, 0x81, 0x04,\n     0x01, 0xd0, 0x02, 0x41, 0x18, 0x90, 0x00, 0x0a, 0x20, 0x00, 0xc1, 0x06, 0x01,\n     0x08, 0x80, 0x64, 0xca, 0x10, 0x04, 0x99, 0x80, 0x48, 0x01, 0x82, 0x20, 0x50,\n     0x90, 0x48, 0x80, 0x84, 0x20, 0x90, 0x22, 0x00, 0x19, 0x00, 0x04, 0x18, 0x20,\n     0x24, 0x10, 0x86, 0x40, 0xc2, 0x00, 0x24, 0x12, 0x10, 0x44, 0x00, 0x16, 0x08,\n     0x10, 0x24, 0x00, 0x12, 0x06, 0x01, 0x08, 0x90, 0x00, 0x12, 0x02, 0x4d, 0x10,\n     0x80, 0x40, 0x50, 0x22, 0x00, 0x43, 0x10, 0x01, 0x00, 0x30, 0x21, 0x0a, 0x00,\n     0x00, 0x01, 0x14, 0x00, 0x10, 0x84, 0x04, 0xc1, 0x10, 0x29, 0x0a, 0x00, 0x01,\n     0x8a, 0x00, 0x20, 0x01, 0x12, 0x0c, 0x49, 0x20, 0x04, 0x81, 0x00, 0x48, 0x01,\n     0x04, 0x60, 0x80, 0x12, 0x0c, 0x08, 0x10, 0x48, 0x4a, 0x04, 0x28, 0x10, 0x00,\n     0x28, 0x40, 0x84, 0x45, 0x50, 0x10, 0x60, 0x10, 0x06, 0x44, 0x01, 0x80, 0x09,\n     0x00, 0x86, 0x01, 0x42, 0xa0, 0x00, 0x90, 0x00, 0x05, 0x90, 0x22, 0x40, 0x41,\n     0x00, 0x08, 0x80, 0x02, 0x08, 0xc0, 0x00, 0x01, 0x58, 0x30, 0x49, 0x09, 0x14,\n     0x00, 0x41, 0x02, 0x0c, 0x02, 0x80, 0x40, 0x89, 0x00, 0x24, 0x08, 0x10, 0x05,\n     0x90, 0x32, 0x40, 0x0a, 0x82, 0x08, 0x00, 0x12, 0x61, 0x00, 0x04, 0x21, 0x00,\n     0x22, 0x04, 0x10, 0x24, 0x08, 0x0a, 0x04, 0x01, 0x10, 0x00, 0x20, 0x40, 0x84,\n     0x04, 0x88, 0x22, 0x20, 0x90, 0x12, 0x00, 0x53, 0x06, 0x24, 0x01, 0x04, 0x40,\n     0x0b, 0x14, 0x60, 0x82, 0x02, 0x0d, 0x10, 0x90, 0x0c, 0x08, 0x20, 0x09, 0x00,\n     0x14, 0x09, 0x80, 0x80, 0x24, 0x82, 0x00, 0x40, 0x01, 0x02, 0x44, 0x01, 0x20,\n     0x0c, 0x40, 0x84, 0x40, 0x0a, 0x10, 0x41, 0x00, 0x30, 0x05, 0x09, 0x80, 0x44,\n     0x08, 0x20, 0x20, 0x02, 0x00, 0x49, 0x43, 0x20, 0x21, 0x00, 0x20, 0x00, 0x01,\n     0xb6, 0x08, 0x40, 0x04, 0x08, 0x02, 0x80, 0x01, 0x41, 0x80, 0x40, 0x08, 0x10,\n     0x24, 0x00, 0x20, 0x04, 0x12, 0x86, 0x09, 0xc0, 0x12, 0x21, 0x81, 0x14, 0x04,\n     0x00, 0x02, 0x20, 0x89, 0xb4, 0x44, 0x12, 0x80, 0x00, 0xd1, 0x00, 0x69, 0x40,\n     0x80, 0x00, 0x42, 0x12, 0x00, 0x18, 0x04, 0x00, 0x49, 0x06, 0x21, 0x02, 0x04,\n     0x28, 0x02, 0x84, 0x01, 0xc0, 0x10, 0x68, 0x00, 0x20, 0x08, 0x40, 0x00, 0x08,\n     0x91, 0x10, 0x01, 0x81, 0x24, 0x04, 0xd2, 0x10, 0x4c, 0x88, 0x86, 0x00, 0x10,\n     0x80, 0x0c, 0x02, 0x14, 0x00, 0x8a, 0x90, 0x40, 0x18, 0x20, 0x21, 0x80, 0xa4,\n     0x00, 0x58, 0x24, 0x20, 0x10, 0x10, 0x60, 0xc1, 0x30, 0x41, 0x48, 0x02, 0x48,\n     0x09, 0x00, 0x40, 0x09, 0x02, 0x05, 0x11, 0x82, 0x20, 0x4a, 0x20, 0x24, 0x18,\n     0x02, 0x0c, 0x10, 0x22, 0x0c, 0x0a, 0x04, 0x00, 0x03, 0x06, 0x48, 0x48, 0x04,\n     0x04, 0x02, 0x00, 0x21, 0x80, 0x84, 0x00, 0x18, 0x00, 0x0c, 0x02, 0x12, 0x01,\n     0x00, 0x14, 0x05, 0x82, 0x10, 0x41, 0x89, 0x12, 0x08, 0x40, 0xa4, 0x21, 0x01,\n     0x84, 0x48, 0x02, 0x10, 0x60, 0x40, 0x02, 0x28, 0x00, 0x14, 0x08, 0x40, 0xa0,\n     0x20, 0x51, 0x12, 0x00, 0xc2, 0x00, 0x01, 0x1a, 0x30, 0x40, 0x89, 0x12, 0x4c,\n     0x02, 0x80, 0x00, 0x00, 0x14, 0x01, 0x01, 0xa0, 0x21, 0x18, 0x22, 0x21, 0x18,\n     0x06, 0x40, 0x01, 0x80, 0x00, 0x90, 0x04, 0x48, 0x02, 0x30, 0x04, 0x08, 0x00,\n     0x05, 0x88, 0x24, 0x08, 0x48, 0x04, 0x24, 0x02, 0x06, 0x00, 0x80, 0x00, 0x00,\n     0x00, 0x10, 0x65, 0x11, 0x90, 0x00, 0x0a, 0x82, 0x04, 0xc3, 0x04, 0x60, 0x48,\n     0x24, 0x04, 0x92, 0x02, 0x44, 0x88, 0x80, 0x40, 0x18, 0x06, 0x29, 0x80, 0x10,\n     0x01, 0x00, 0x00, 0x44, 0xc8, 0x10, 0x21, 0x89, 0x30, 0x00, 0x4b, 0xa0, 0x01,\n     0x10, 0x14, 0x00, 0x02, 0x94, 0x40, 0x00, 0x20, 0x65, 0x00, 0xa2, 0x0c, 0x40,\n     0x22, 0x20, 0x81, 0x12, 0x20, 0x82, 0x04, 0x01, 0x10, 0x00, 0x08, 0x88, 0x00,\n     0x00, 0x11, 0x80, 0x04, 0x42, 0x80, 0x40, 0x41, 0x14, 0x00, 0x40, 0x32, 0x2c,\n     0x80, 0x24, 0x04, 0x19, 0x00, 0x00, 0x91, 0x00, 0x20, 0x83, 0x00, 0x05, 0x40,\n     0x20, 0x09, 0x01, 0x84, 0x40, 0x40, 0x20, 0x20, 0x11, 0x00, 0x40, 0x41, 0x90,\n     0x20, 0x00, 0x00, 0x40, 0x90, 0x92, 0x48, 0x18, 0x06, 0x08, 0x81, 0x80, 0x48,\n     0x01, 0x34, 0x24, 0x10, 0x20, 0x04, 0x00, 0x20, 0x04, 0x18, 0x06, 0x2d, 0x90,\n     0x10, 0x01, 0x00, 0x90, 0x00, 0x0a, 0x22, 0x01, 0x00, 0x22, 0x00, 0x11, 0x84,\n     0x01, 0x01, 0x00, 0x20, 0x88, 0x00, 0x44, 0x00, 0x22, 0x01, 0x00, 0xa6, 0x40,\n     0x02, 0x06, 0x20, 0x11, 0x00, 0x01, 0xc8, 0xa0, 0x04, 0x8a, 0x00, 0x28, 0x19,\n     0x80, 0x00, 0x52, 0xa0, 0x24, 0x12, 0x12, 0x09, 0x08, 0x24, 0x01, 0x48, 0x00,\n     0x04, 0x00, 0x24, 0x40, 0x02, 0x84, 0x08, 0x00, 0x04, 0x48, 0x40, 0x90, 0x60,\n     0x0a, 0x22, 0x01, 0x88, 0x14, 0x08, 0x01, 0x02, 0x08, 0xd3, 0x00, 0x20, 0xc0,\n     0x90, 0x24, 0x10, 0x00, 0x00, 0x01, 0xb0, 0x08, 0x0a, 0xa0, 0x00, 0x80, 0x00,\n     0x01, 0x09, 0x00, 0x20, 0x52, 0x02, 0x25, 0x00, 0x24, 0x04, 0x02, 0x84, 0x24,\n     0x10, 0x92, 0x40, 0x02, 0xa0, 0x40, 0x00, 0x22, 0x08, 0x11, 0x04, 0x08, 0x01,\n     0x22, 0x00, 0x42, 0x14, 0x00, 0x09, 0x90, 0x21, 0x00, 0x30, 0x6c, 0x00, 0x00,\n     0x0c, 0x00, 0x22, 0x09, 0x90, 0x10, 0x28, 0x40, 0x00, 0x20, 0xc0, 0x20, 0x00,\n     0x90, 0x00, 0x40, 0x01, 0x82, 0x05, 0x12, 0x12, 0x09, 0xc1, 0x04, 0x61, 0x80,\n     0x02, 0x28, 0x81, 0x24, 0x00, 0x49, 0x04, 0x08, 0x10, 0x86, 0x29, 0x41, 0x80,\n     0x21, 0x0a, 0x30, 0x49, 0x88, 0x90, 0x00, 0x41, 0x04, 0x29, 0x81, 0x80, 0x41,\n     0x09, 0x00, 0x40, 0x12, 0x10, 0x40, 0x00, 0x10, 0x40, 0x48, 0x02, 0x05, 0x80,\n     0x02, 0x21, 0x40, 0x20, 0x00, 0x58, 0x20, 0x60, 0x00, 0x90, 0x48, 0x00, 0x80,\n     0x28, 0xc0, 0x80, 0x48, 0x00, 0x00, 0x44, 0x80, 0x02, 0x00, 0x09, 0x06, 0x00,\n     0x12, 0x02, 0x01, 0x00, 0x10, 0x08, 0x83, 0x10, 0x45, 0x12, 0x00, 0x2c, 0x08,\n     0x04, 0x44, 0x00, 0x20, 0x20, 0xc0, 0x10, 0x20, 0x01, 0x00, 0x05, 0xc8, 0x20,\n     0x04, 0x98, 0x10, 0x08, 0x10, 0x00, 0x24, 0x02, 0x16, 0x40, 0x88, 0x00, 0x61,\n     0x88, 0x12, 0x24, 0x80, 0xa6, 0x00, 0x42, 0x00, 0x08, 0x10, 0x06, 0x48, 0x40,\n     0xa0, 0x00, 0x50, 0x20, 0x04, 0x81, 0xa4, 0x40, 0x18, 0x00, 0x08, 0x10, 0x80,\n     0x01, 0x01};\n\n#if RSA_KEY_SIEVE && SIMULATION && RSA_INSTRUMENT\nUINT32 PrimeIndex               = 0;\nUINT32 failedAtIteration[10]    = {0};\nUINT32 PrimeCounts[3]           = {0};\nUINT32 MillerRabinTrials[3]     = {0};\nUINT32 totalFieldsSieved[3]     = {0};\nUINT32 bitsInFieldAfterSieve[3] = {0};\nUINT32 emptyFieldsSieved[3]     = {0};\nUINT32 noPrimeFields[3]         = {0};\nUINT32 primesChecked[3]         = {0};\nUINT16 lastSievePrime           = 0;\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/src/PropertyCap.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tFor accessing the TPM_CAP_TPM_PROPERTY values\t  \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.14 PropertyCap.c */\n/* 9.14.1 Description */\n/* This file contains the functions that are used for accessing the TPM_CAP_TPM_PROPERTY values. */\n/* 9.14.2 Includes */\n#include \"Tpm.h\"\n/* 9.14.3 Functions */\n/* 9.14.3.1 TPMPropertyIsDefined() */\n/* This function accepts a property selection and, if so, sets value to the value of the\n   property. */\n/* All the fixed values are vendor dependent or determined by a platform-specific specification. The\n   values in the table below are examples and should be changed by the vendor. */\n/* Return Values Meaning */\n/* TRUE referenced property exists and value set */\n/* FALSE referenced property does not exist */\nstatic BOOL\nTPMPropertyIsDefined(\n\t\t     TPM_PT           property,      // IN: property\n\t\t     UINT32          *value          // OUT: property value\n\t\t     )\n{\n    switch(property)\n\t{\n\t  case TPM_PT_FAMILY_INDICATOR:\n\t    // from the title page of the specification\n\t    // For this specification, the value is \"2.0\".\n\t    *value = TPM_SPEC_FAMILY;\n\t    break;\n\t  case TPM_PT_LEVEL:\n\t    // from the title page of the specification\n\t    *value = TPM_SPEC_LEVEL;\n\t    break;\n\t  case TPM_PT_REVISION:\n\t    // from the title page of the specification\n\t    *value = TPM_SPEC_VERSION;\n\t    break;\n\t  case TPM_PT_DAY_OF_YEAR:\n\t    // computed from the date value on the title page of the specification\n\t    *value = TPM_SPEC_DAY_OF_YEAR;\n\t    break;\n\t  case TPM_PT_YEAR:\n\t    // from the title page of the specification\n\t    *value = TPM_SPEC_YEAR;\n\t    break;\n\t  case TPM_PT_MANUFACTURER:\n\t    *value = _plat__GetManufacturerCapabilityCode();\n\t    // vendor ID unique to each TPM manufacturer\n\t    break;\n\t  case TPM_PT_VENDOR_STRING_1:\n\t    // first four characters of the vendor ID string\n\t    *value = _plat__GetVendorCapabilityCode(1);\n\t    break;\n\t  case TPM_PT_VENDOR_STRING_2:\n\t    *value = _plat__GetVendorCapabilityCode(2);\n\t    break;\n\t  case TPM_PT_VENDOR_STRING_3:\n\t    // third four characters of the vendor ID string\n\t    *value = _plat__GetVendorCapabilityCode(3);\n\t    break;\n\t  case TPM_PT_VENDOR_STRING_4:\n\t    // fourth four characters of the vendor ID string\n\t    *value = _plat__GetVendorCapabilityCode(4);\n\t    break;\n\t  case TPM_PT_VENDOR_TPM_TYPE:\n\t    *value = _plat__GetTpmType();\n\t    break;\n\t  case TPM_PT_FIRMWARE_VERSION_1:\n\t    // more significant 32-bits of a vendor-specific value\n\t    *value = gp.firmwareV1;\n\t    break;\n\t  case TPM_PT_FIRMWARE_VERSION_2:\n\t    // less significant 32-bits of a vendor-specific value\n\t    *value = gp.firmwareV2;\n\t    break;\n\t  case TPM_PT_INPUT_BUFFER:\n\t    // maximum size of TPM2B_MAX_BUFFER\n\t    *value = MAX_DIGEST_BUFFER;\n\t    break;\n\t  case TPM_PT_HR_TRANSIENT_MIN:\n\t    // minimum number of transient objects that can be held in TPM\n\t    // RAM\n\t    *value = MAX_LOADED_OBJECTS;\n\t    break;\n\t  case TPM_PT_HR_PERSISTENT_MIN:\n\t    // minimum number of persistent objects that can be held in\n\t    // TPM NV memory\n\t    // In this implementation, there is no minimum number of\n\t    // persistent objects.\n\t    *value = MIN_EVICT_OBJECTS;\n\t    break;\n\t  case TPM_PT_HR_LOADED_MIN:\n\t    // minimum number of authorization sessions that can be held in\n\t    // TPM RAM\n\t    *value = MAX_LOADED_SESSIONS;\n\t    break;\n\t  case TPM_PT_ACTIVE_SESSIONS_MAX:\n\t    // number of authorization sessions that may be active at a time\n\t    *value = MAX_ACTIVE_SESSIONS;\n\t    break;\n\t  case TPM_PT_PCR_COUNT:\n\t    // number of PCR implemented\n\t    *value = IMPLEMENTATION_PCR;\n\t    break;\n\t  case TPM_PT_PCR_SELECT_MIN:\n\t    // minimum number of bytes in a TPMS_PCR_SELECT.sizeOfSelect\n\t    *value = PCR_SELECT_MIN;\n\t    break;\n\t  case TPM_PT_CONTEXT_GAP_MAX:\n\t    // maximum allowed difference (unsigned) between the contextID\n\t    // values of two saved session contexts\n\t    *value = ((UINT32)1 << (sizeof(CONTEXT_SLOT) * 8)) - 1;\n\t    break;\n\t  case TPM_PT_NV_COUNTERS_MAX:\n\t    // maximum number of NV indexes that are allowed to have the\n\t    // TPMA_NV_COUNTER attribute SET\n\t    // In this implementation, there is no limitation on the number\n\t    // of counters, except for the size of the NV Index memory.\n\t    *value = 0;\n\t    break;\n\t  case TPM_PT_NV_INDEX_MAX:\n\t    // maximum size of an NV index data area\n\t    *value = MAX_NV_INDEX_SIZE;\n\t    break;\n\t  case TPM_PT_MEMORY:\n\t    // a TPMA_MEMORY indicating the memory management method for the TPM\n\t      {\n\t\t  union\n\t\t  {\n\t\t      TPMA_MEMORY     att;\n\t\t      UINT32          u32;\n\t\t  } attributes = { TPMA_ZERO_INITIALIZER() };\n\t\t  SET_ATTRIBUTE(attributes.att, TPMA_MEMORY, sharedNV);\n\t\t  SET_ATTRIBUTE(attributes.att, TPMA_MEMORY, objectCopiedToRam);\n\t\t  // Note: For a LSb0 machine, the bits in a bit field are in the correct\n\t\t  // order even if the machine is MSB0. For a MSb0 machine, a TPMA will\n\t\t  // be an integer manipulated by masking (USE_BIT_FIELD_STRUCTURES will\n\t\t  // NO) so the bits are manipulated correctly.\n\t\t  *value = attributes.u32;\n\t\t  break;\n\t      }\n\t  case TPM_PT_CLOCK_UPDATE:\n\t    // interval, in seconds, between updates to the copy of\n\t    // TPMS_TIME_INFO .clock in NV\n\t    *value = (1 << NV_CLOCK_UPDATE_INTERVAL);\n\t    break;\n\t  case TPM_PT_CONTEXT_HASH:\n\t    // algorithm used for the integrity hash on saved contexts and\n\t    // for digesting the fuData of TPM2_FirmwareRead()\n\t    *value = CONTEXT_INTEGRITY_HASH_ALG;\n\t    break;\n\t  case TPM_PT_CONTEXT_SYM:\n\t    // algorithm used for encryption of saved contexts\n\t    *value = CONTEXT_ENCRYPT_ALG;\n\t    break;\n\t  case TPM_PT_CONTEXT_SYM_SIZE:\n\t    // size of the key used for encryption of saved contexts\n\t    *value = CONTEXT_ENCRYPT_KEY_BITS;\n\t    break;\n\t  case TPM_PT_ORDERLY_COUNT:\n\t    // maximum difference between the volatile and non-volatile\n\t    // versions of TPMA_NV_COUNTER that have TPMA_NV_ORDERLY SET\n\t    *value = MAX_ORDERLY_COUNT;\n\t    break;\n\t  case TPM_PT_MAX_COMMAND_SIZE:\n\t    // maximum value for 'commandSize'\n\t    *value = MAX_COMMAND_SIZE;\n\t    break;\n\t  case TPM_PT_MAX_RESPONSE_SIZE:\n\t    // maximum value for 'responseSize'\n\t    *value = MAX_RESPONSE_SIZE;\n\t    break;\n\t  case TPM_PT_MAX_DIGEST:\n\t    // maximum size of a digest that can be produced by the TPM\n\t    *value = sizeof(TPMU_HA);\n\t    break;\n\t  case TPM_PT_MAX_OBJECT_CONTEXT:\n\t    // Header has 'sequence', 'handle' and 'hierarchy'\n#define SIZE_OF_CONTEXT_HEADER\t\t\t\t\t\t\\\n\t    sizeof(UINT64) + sizeof(TPMI_DH_CONTEXT) + sizeof(TPMI_RH_HIERARCHY)\n#define SIZE_OF_CONTEXT_INTEGRITY (sizeof(UINT16) + CONTEXT_INTEGRITY_HASH_SIZE)\n#define SIZE_OF_FINGERPRINT     sizeof(UINT64)\n#define SIZE_OF_CONTEXT_BLOB_OVERHEAD\t\t\t\t\t\\\n\t    (sizeof(UINT16)  + SIZE_OF_CONTEXT_INTEGRITY + SIZE_OF_FINGERPRINT)\n#define SIZE_OF_CONTEXT_OVERHEAD\t\t\t\t\t\\\n\t    (SIZE_OF_CONTEXT_HEADER + SIZE_OF_CONTEXT_BLOB_OVERHEAD)\n#if 0\n\t    // maximum size of a TPMS_CONTEXT that will be returned by\n\t    // TPM2_ContextSave for object context\n\t    *value = 0;\n\t    // adding sequence, saved handle and hierarchy\n\t    *value += sizeof(UINT64) + sizeof(TPMI_DH_CONTEXT) +\n\t\t      sizeof(TPMI_RH_HIERARCHY);\n\t    // add size field in TPM2B_CONTEXT\n\t    *value += sizeof(UINT16);\n\t    // add integrity hash size\n\t    *value += sizeof(UINT16) +\n\t\t      CryptHashGetDigestSize(CONTEXT_INTEGRITY_HASH_ALG);\n\t    // Add fingerprint size, which is the same as sequence size\n\t    *value += sizeof(UINT64);\n\t    // Add OBJECT structure size\n\t    *value += sizeof(OBJECT);\n#else\n\t    // the maximum size of a TPMS_CONTEXT that will be returned by\n\t    // TPM2_ContextSave for object context\n\t    *value = SIZE_OF_CONTEXT_OVERHEAD + sizeof(OBJECT);\n#endif\n\t    break;\n\t  case TPM_PT_MAX_SESSION_CONTEXT:\n#if 0\n\t    // the maximum size of a TPMS_CONTEXT that will be returned by\n\t    // TPM2_ContextSave for object context\n\t    *value = 0;\n\t    // adding sequence, saved handle and hierarchy\n\t    *value += sizeof(UINT64) + sizeof(TPMI_DH_CONTEXT) +\n\t\t      sizeof(TPMI_RH_HIERARCHY);\n\t    // Add size field in TPM2B_CONTEXT\n\t    *value += sizeof(UINT16);\n\t    // Add integrity hash size\n\t    *value += sizeof(UINT16) +\n\t\t      CryptHashGetDigestSize(CONTEXT_INTEGRITY_HASH_ALG);\n\t    // Add fingerprint size, which is the same as sequence size\n\t    *value += sizeof(UINT64);\n\t    // Add SESSION structure size\n\t    *value += sizeof(SESSION);\n#else\n\t    // the maximum size of a TPMS_CONTEXT that will be returned by\n\t    // TPM2_ContextSave for object context\n\t    *value = SIZE_OF_CONTEXT_OVERHEAD + sizeof(SESSION);\n#endif\n\t    break;\n\t  case TPM_PT_PS_FAMILY_INDICATOR:\n\t    // platform specific values for the TPM_PT_PS parameters from\n\t    // the relevant platform-specific specification\n\t    // In this reference implementation, all of these values are 0.\n\t    *value = PLATFORM_FAMILY;\n\t    break;\n\t  case TPM_PT_PS_LEVEL:\n\t    // level of the platform-specific specification\n\t    *value = PLATFORM_LEVEL;\n\t    break;\n\t  case TPM_PT_PS_REVISION:\n\t    // specification Revision times 100 for the platform-specific\n\t    // specification\n\t    *value = PLATFORM_VERSION;\n\t    break;\n\t  case TPM_PT_PS_DAY_OF_YEAR:\n\t    // platform-specific specification day of year using TCG calendar\n\t    *value = PLATFORM_DAY_OF_YEAR;\n\t    break;\n\t  case TPM_PT_PS_YEAR:\n\t    // platform-specific specification year using the CE\n\t    *value = PLATFORM_YEAR;\n\t    break;\n\t  case TPM_PT_SPLIT_MAX:\n\t    // number of split signing operations supported by the TPM\n\t    *value = 0;\n#if ALG_ECC\n\t    *value = sizeof(gr.commitArray) * 8;\n#endif\n\t    break;\n\t  case TPM_PT_TOTAL_COMMANDS:\n\t    // total number of commands implemented in the TPM\n\t    // Since the reference implementation does not have any\n\t    // vendor-defined commands, this will be the same as the\n\t    // number of library commands.\n\t      {\n#if COMPRESSED_LISTS\n\t\t  (*value) = COMMAND_COUNT;\n#else\n\t\t  COMMAND_INDEX       commandIndex;\n\t\t  *value = 0;\n\t\t  // scan all implemented commands\n\t\t  for(commandIndex = GetClosestCommandIndex(0);\n\t\t      commandIndex != UNIMPLEMENTED_COMMAND_INDEX;\n\t\t      commandIndex = GetNextCommandIndex(commandIndex))\n\t\t      {\n\t\t\t  (*value)++;     // count of all implemented\n\t\t      }\n#endif\n\t\t  break;\n\t      }\n\t  case TPM_PT_LIBRARY_COMMANDS:\n\t    // number of commands from the TPM library that are implemented\n\t      {\n#if COMPRESSED_LISTS\n\t\t  *value = LIBRARY_COMMAND_ARRAY_SIZE;\n#else\n\t\t  COMMAND_INDEX       commandIndex;\n\t\t  *value = 0;\n\t\t  // scan all implemented commands\n\t\t  for(commandIndex = GetClosestCommandIndex(0);\n\t\t      commandIndex < LIBRARY_COMMAND_ARRAY_SIZE;\n\t\t      commandIndex = GetNextCommandIndex(commandIndex))\n\t\t      {\n\t\t\t  (*value)++;\n\t\t      }\n#endif\n\t\t  break;\n\t      }\n\t  case TPM_PT_VENDOR_COMMANDS:\n\t    // number of vendor commands that are implemented\n\t    *value = VENDOR_COMMAND_ARRAY_SIZE;\n\t    break;\n\t  case TPM_PT_NV_BUFFER_MAX:\n\t    // Maximum data size in an NV write command\n\t    *value = MAX_NV_BUFFER_SIZE;\n\t    break;\n\t  case TPM_PT_MODES:\n#if FIPS_COMPLIANT\n\t    *value = 1;\n#else\n\t    *value = 0;\n#endif\n\t    break;\n\t  case TPM_PT_MAX_CAP_BUFFER:\n\t    *value = MAX_CAP_BUFFER;\n\t    break;\n\t    // Start of variable commands\n\t  case TPM_PT_PERMANENT:\n\t    // TPMA_PERMANENT\n\t      {\n\t\t  union {\n\t\t      TPMA_PERMANENT      attr;\n\t\t      UINT32              u32;\n\t\t  } flags = { TPMA_ZERO_INITIALIZER() };\n\t\t  if(gp.ownerAuth.t.size != 0)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, ownerAuthSet);\n\t\t  if(gp.endorsementAuth.t.size != 0)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, endorsementAuthSet);\n\t\t  if(gp.lockoutAuth.t.size != 0)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, lockoutAuthSet);\n\t\t  if(gp.disableClear)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, disableClear);\n\t\t  if(gp.failedTries >= gp.maxTries)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, inLockout);\n\t\t  // In this implementation, EPS is always generated by TPM\n\t\t  SET_ATTRIBUTE(flags.attr, TPMA_PERMANENT, tpmGeneratedEPS);\n\t\t  // Note: For a LSb0 machine, the bits in a bit field are in the correct\n\t\t  // order even if the machine is MSB0. For a MSb0 machine, a TPMA will\n\t\t  // be an integer manipulated by masking (USE_BIT_FIELD_STRUCTURES will\n\t\t  // be NO ) so the bits are manipulate correctly.\n\t\t  *value = flags.u32;\n\t\t  break;\n\t      }\n\t  case TPM_PT_STARTUP_CLEAR:\n\t    // TPMA_STARTUP_CLEAR\n\t      {\n\t\t  union {\n\t\t      TPMA_STARTUP_CLEAR  attr;\n\t\t      UINT32              u32;\n\t\t  } flags =  { TPMA_ZERO_INITIALIZER() };\n\t\t  //\n\t\t  if(g_phEnable)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, phEnable);\n\t\t  if(gc.shEnable)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, shEnable);\n\t\t  if(gc.ehEnable)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, ehEnable);\n\t\t  if(gc.phEnableNV)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, phEnableNV);\n\t\t  if(g_prevOrderlyState != SU_NONE_VALUE)\n\t\t      SET_ATTRIBUTE(flags.attr, TPMA_STARTUP_CLEAR, orderly);\n\t\t  // Note: For a LSb0 machine, the bits in a bit field are in the correct\n\t\t  // order even if the machine is MSB0. For a MSb0 machine, a TPMA will\n\t\t  // be an integer manipulated by masking (USE_BIT_FIELD_STRUCTURES will\n\t\t  // be NO) so the bits are manipulate correctly.\n\t\t  *value = flags.u32;\n\t\t  break;\n\t      }\n\t  case TPM_PT_HR_NV_INDEX:\n\t    // number of NV indexes currently defined\n\t    *value = NvCapGetIndexNumber();\n\t    break;\n\t  case TPM_PT_HR_LOADED:\n\t    // number of authorization sessions currently loaded into TPM\n\t    // RAM\n\t    *value = SessionCapGetLoadedNumber();\n\t    break;\n\t  case TPM_PT_HR_LOADED_AVAIL:\n\t    // number of additional authorization sessions, of any type,\n\t    // that could be loaded into TPM RAM\n\t    *value = SessionCapGetLoadedAvail();\n\t    break;\n\t  case TPM_PT_HR_ACTIVE:\n\t    // number of active authorization sessions currently being\n\t    // tracked by the TPM\n\t    *value = SessionCapGetActiveNumber();\n\t    break;\n\t  case TPM_PT_HR_ACTIVE_AVAIL:\n\t    // number of additional authorization sessions, of any type,\n\t    // that could be created\n\t    *value = SessionCapGetActiveAvail();\n\t    break;\n\t  case TPM_PT_HR_TRANSIENT_AVAIL:\n\t    // estimate of the number of additional transient objects that\n\t    // could be loaded into TPM RAM\n\t    *value = ObjectCapGetTransientAvail();\n\t    break;\n\t  case TPM_PT_HR_PERSISTENT:\n\t    // number of persistent objects currently loaded into TPM\n\t    // NV memory\n\t    *value = NvCapGetPersistentNumber();\n\t    break;\n\t  case TPM_PT_HR_PERSISTENT_AVAIL:\n\t    // number of additional persistent objects that could be loaded\n\t    // into NV memory\n\t    *value = NvCapGetPersistentAvail();\n\t    break;\n\t  case TPM_PT_NV_COUNTERS:\n\t    // number of defined NV indexes that have NV TPMA_NV_COUNTER\n\t    // attribute SET\n\t    *value = NvCapGetCounterNumber();\n\t    break;\n\t  case TPM_PT_NV_COUNTERS_AVAIL:\n\t    // number of additional NV indexes that can be defined with their\n\t    // TPMA_NV_COUNTER attribute SET\n\t    *value = NvCapGetCounterAvail();\n\t    break;\n\t  case TPM_PT_ALGORITHM_SET:\n\t    // region code for the TPM\n\t    *value = gp.algorithmSet;\n\t    break;\n\t  case TPM_PT_LOADED_CURVES:\n#if ALG_ECC\n\t    // number of loaded ECC curves\n\t    *value = ECC_CURVE_COUNT;\n#else // ALG_ECC\n\t    *value = 0;\n#endif // ALG_ECC\n\t    break;\n\t  case TPM_PT_LOCKOUT_COUNTER:\n\t    // current value of the lockout counter\n\t    *value = gp.failedTries;\n\t    break;\n\t  case TPM_PT_MAX_AUTH_FAIL:\n\t    // number of authorization failures before DA lockout is invoked\n\t    *value = gp.maxTries;\n\t    break;\n\t  case TPM_PT_LOCKOUT_INTERVAL:\n\t    // number of seconds before the value reported by\n\t    // TPM_PT_LOCKOUT_COUNTER is decremented\n\t    *value = gp.recoveryTime;\n\t    break;\n\t  case TPM_PT_LOCKOUT_RECOVERY:\n\t    // number of seconds after a lockoutAuth failure before use of\n\t    // lockoutAuth may be attempted again\n\t    *value = gp.lockoutRecovery;\n\t    break;\n\t  case TPM_PT_NV_WRITE_RECOVERY:\n\t    // number of milliseconds before the TPM will accept another command\n\t    // that will modify NV.\n\t    // This should make a call to the platform code that is doing rate\n\t    // limiting of NV. Rate limiting is not implemented in the reference\n\t    // code so no call is made.\n\t    *value = 0;\n\t    break;\n\t  case TPM_PT_AUDIT_COUNTER_0:\n\t    // high-order 32 bits of the command audit counter\n\t    *value = (UINT32)(gp.auditCounter >> 32);\n\t    break;\n\t  case TPM_PT_AUDIT_COUNTER_1:\n\t    // low-order 32 bits of the command audit counter\n\t    *value = (UINT32)(gp.auditCounter);\n\t    break;\n\t  default:\n\t    // property is not defined\n\t    return FALSE;\n\t    break;\n\t}\n    return TRUE;\n}\n/* 9.14.3.2 TPMCapGetProperties() */\n/* This function is used to get the TPM_PT values. The search of properties will start at property\n   and continue until propertyList has as many values as will fit, or the last property has been\n   reported, or the list has as many values as requested in count. */\n/* Return Values Meaning */\n/* YES more properties are available */\n/* NO no more properties to be reported */\nTPMI_YES_NO\nTPMCapGetProperties(\n\t\t    TPM_PT                       property,      // IN: the starting TPM property\n\t\t    UINT32                       count,         // IN: maximum number of returned\n\t\t    //     properties\n\t\t    TPML_TAGGED_TPM_PROPERTY    *propertyList   // OUT: property list\n\t\t    )\n{\n    TPMI_YES_NO     more = NO;\n    UINT32          i;\n    UINT32          nextGroup;\n    // initialize output property list\n    propertyList->count = 0;\n    // maximum count of properties we may return is MAX_PCR_PROPERTIES\n    if(count > MAX_TPM_PROPERTIES) count = MAX_TPM_PROPERTIES;\n    // if property is less than PT_FIXED, start from PT_FIXED\n    if(property < PT_FIXED)\n\tproperty = PT_FIXED;\n    // There is only the fixed and variable groups with the variable group coming\n    // last\n    if(property >= (PT_VAR + PT_GROUP))\n\treturn more;\n    // Don't read past the end of the selected group\n    nextGroup = ((property / PT_GROUP) * PT_GROUP) + PT_GROUP;\n    // Scan through the TPM properties of the requested group.\n    for(i = property; i < nextGroup; i++)\n\t{\n\t    UINT32          value;\n\t    // if we have hit the end of the group, quit\n\t    if(i != property && ((i % PT_GROUP) == 0))\n\t\tbreak;\n\t    if(TPMPropertyIsDefined((TPM_PT)i, &value))\n\t\t{\n\t\t    if(propertyList->count < count)\n\t\t\t{\n\t\t\t    // If the list is not full, add this property\n\t\t\t    propertyList->tpmProperty[propertyList->count].property =\n\t\t\t\t(TPM_PT)i;\n\t\t\t    propertyList->tpmProperty[propertyList->count].value = value;\n\t\t\t    propertyList->count++;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // If the return list is full but there are more properties\n\t\t\t    // available, set the indication and exit the loop.\n\t\t\t    more = YES;\n\t\t\t    break;\n\t\t\t}\n\t\t}\n\t}\n    return more;\n}\n\n//*** TPMCapGetOneProperty()\n// This function returns a single TPM property, if present.\nBOOL TPMCapGetOneProperty(TPM_PT                pt,       // IN: the TPM property\n\t\t\t  TPMS_TAGGED_PROPERTY* property  // OUT: tagged property\n\t\t\t  )\n{\n    UINT32 value;\n\n    if(TPMPropertyIsDefined((TPM_PT)pt, &value))\n\t{\n\t    property->property = (TPM_PT)pt;\n\t    property->value    = value;\n\t    return TRUE;\n\t}\n\n    return FALSE;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/RandomCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Random Number Generator \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: RandomCommands.c 1671 2021-06-03 18:30:41Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"GetRandom_fp.h\"\n\nextern int verbose;\n\n#if CC_GetRandom  // Conditional expansion of this file\nTPM_RC\nTPM2_GetRandom(\n\t       GetRandom_In    *in,            // IN: input parameter list\n\t       GetRandom_Out   *out            // OUT: output parameter list\n\t       )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_GetRandom: bytesRequested %hu\\n\", in->bytesRequested);\n\t// fclose(f);\n  //   }\n    // Command Output\n    // if the requested bytes exceed the output buffer size, generates the\n    // maximum bytes that the output buffer allows\n    if(in->bytesRequested > sizeof(TPMU_HA))\n\tout->randomBytes.t.size = sizeof(TPMU_HA);\n    else\n\tout->randomBytes.t.size = in->bytesRequested;\n    CryptRandomGenerate(out->randomBytes.t.size, out->randomBytes.t.buffer);\n   return TPM_RC_SUCCESS;\n}\n#endif // CC_GetRandom\n#include \"Tpm.h\"\n#include \"StirRandom_fp.h\"\n#if CC_StirRandom  // Conditional expansion of this file\nTPM_RC\nTPM2_StirRandom(\n\t\tStirRandom_In   *in             // IN: input parameter list\n\t\t)\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_StirRandom:\\n\");\n\t// fclose(f);\n  //   }\n    // Internal Data Update\n    CryptRandomStir(in->inData.t.size, in->inData.t.buffer);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_StirRandom\n"
  },
  {
    "path": "ftpm-opensbi/src/Response.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Response.c 1259 2018-07-10 19:11:09Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.15 Response.c */\n/* 9.15.1 Description */\n/* This file contains the common code for building a response header, including setting the size of\n   the structure. command may be NULL if result is not TPM_RC_SUCCESS. */\n/* 9.15.2 Includes and Defines */\n#include \"Tpm.h\"\n/*     9.15.3 BuildResponseHeader() */\n/* Adds the response header to the response. It will update command->parameterSize to indicate the\n   total size of the response. */\nvoid\nBuildResponseHeader(\n\t\t    COMMAND         *command,       // IN: main control structure\n\t\t    BYTE            *buffer,        // OUT: the output buffer\n\t\t    TPM_RC           result         // IN: the response code\n\t\t    )\n{\n    TPM_ST              tag;\n    UINT32              size;\n    if(result != TPM_RC_SUCCESS)\n\t{\n\t    tag = TPM_ST_NO_SESSIONS;\n\t    size = 10;\n\t}\n    else\n\t{\n\t    tag = command->tag;\n\t    // Compute the overall size of the response\n\t    size = STD_RESPONSE_HEADER + command->handleNum * sizeof(TPM_HANDLE);\n\t    size += command->parameterSize;\n\t    size += (command->tag == TPM_ST_SESSIONS) ?\n\t\t    command->authSize + sizeof(UINT32) : 0;\n\t}\n    TPM_ST_Marshal(&tag, &buffer, NULL);\n    UINT32_Marshal(&size, &buffer, NULL);\n    TPM_RC_Marshal(&result, &buffer, NULL);\n    if(result == TPM_RC_SUCCESS)\n\t{\n\t    if(command->handleNum > 0)\n\t\tTPM_HANDLE_Marshal(&command->handles[0], &buffer, NULL);\n\t    if(tag == TPM_ST_SESSIONS)\n\t\tUINT32_Marshal((UINT32 *)&command->parameterSize, &buffer, NULL);\n\t}\n    command->parameterSize = size;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/ResponseCodeProcessing.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tMiscellaneous Functions For Processing Response Codes\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*      $Id: ResponseCodeProcessing.c 1259 2018-07-10 19:11:09Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2018\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.16 ResponseCodeProcessing.c */\n/* 9.16.1 Description */\n/* This file contains the miscellaneous functions for processing response codes. */\n/* NOTE: Currently, there is only one. */\n/* 9.16.2 Includes and Defines */\n#include \"Tpm.h\"\n/* 9.16.3 RcSafeAddToResult() */\n/* Adds a modifier to a response code as long as the response code allows a modifier and no modifier\n   has already been added. */\nTPM_RC\nRcSafeAddToResult(\n\t\t  TPM_RC          responseCode,\n\t\t  TPM_RC          modifier\n\t\t  )\n{\n    if((responseCode & RC_FMT1) && !(responseCode & 0xf40))\n\treturn responseCode + modifier;\n    else\n\treturn responseCode;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/RsaKeyCache.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     The RSA key cache \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the functions to implement the RSA key cache that can be used\n// to speed up simulation.\n//\n// Only one key is created for each supported key size and it is returned whenever\n// a key of that size is requested.\n//\n// If desired, the key cache can be populated from a file. This allows multiple\n// TPM to run with the same RSA keys. Also, when doing simulation, the DRBG will\n// use preset sequences so it is not too hard to repeat sequences for debug or\n// profile or stress.\n//\n// When the key cache is enabled, a call to CryptRsaGenerateKey() will call the\n// GetCachedRsaKey(). If the cache is enabled and populated, then the cached key\n// of the requested size is returned. If a key of the requested size is not\n// available, the no key is loaded and the requested key will need to be generated.\n// If the cache is not populated, the TPM will open a file that has the appropriate\n// name for the type of keys required (CRT or no-CRT). If the file is the right\n// size, it is used. If the file doesn't exist or the file does not have the correct\n// size, the TMP will populate the cache with new keys of the required size and\n// write the cache data to the file so that they will be available the next time.\n//\n// Currently, if two simulations are being run with TPM's that have different RSA\n// key sizes (e.g,, one with 1024 and 2048 and another with 2048 and 3072, then the\n// files will not match for the both of them and they will both try to overwrite\n// the other's cache file. I may try to do something about this if necessary.\n\n//** Includes, Types, Locals, and Defines\n\n#include \"Tpm.h\"\n\n#if USE_RSA_KEY_CACHE\n\n#  include <stdio.h>\n#  include \"RsaKeyCache_fp.h\"\n\n#  if CRT_FORMAT_RSA == YES\n#    define CACHE_FILE_NAME \"RsaKeyCacheCrt.data\"\n#  else\n#    define CACHE_FILE_NAME \"RsaKeyCacheNoCrt.data\"\n#  endif\n\ntypedef struct _RSA_KEY_CACHE_\n{\n    TPM2B_PUBLIC_KEY_RSA  publicModulus;\n    TPM2B_PRIVATE_KEY_RSA privateExponent;\n} RSA_KEY_CACHE;\n\n// Determine the number of RSA key sizes for the cache\nTPMI_RSA_KEY_BITS SupportedRsaKeySizes[] = {\n#  if RSA_1024\n    1024,\n#  endif\n#  if RSA_2048\n    2048,\n#  endif\n#  if RSA_3072\n    3072,\n#  endif\n#  if RSA_4096\n    4096,\n#  endif\n    0};\n\n#  define RSA_KEY_CACHE_ENTRIES (RSA_1024 + RSA_2048 + RSA_3072 + RSA_4096)\n\n// The key cache holds one entry for each of the supported key sizes\nRSA_KEY_CACHE s_rsaKeyCache[RSA_KEY_CACHE_ENTRIES];\n// Indicates if the key cache is loaded. It can be loaded and enabled or disabled.\nBOOL s_keyCacheLoaded = 0;\n\n// Indicates if the key cache is enabled\nint s_rsaKeyCacheEnabled = FALSE;\n\n//*** RsaKeyCacheControl()\n// Used to enable and disable the RSA key cache.\nLIB_EXPORT void RsaKeyCacheControl(int state)\n{\n    s_rsaKeyCacheEnabled = state;\n}\n\n//*** InitializeKeyCache()\n// This will initialize the key cache and attempt to write it to a file for later\n// use.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure\nstatic BOOL InitializeKeyCache(TPMT_PUBLIC*    publicArea,\n\t\t\t       TPMT_SENSITIVE* sensitive,\n\t\t\t       RAND_STATE* rand  // IN: if not NULL, the deterministic\n\t\t\t       //     RNG state\n\t\t\t       )\n{\n    int          index;\n    TPM_KEY_BITS keySave = publicArea->parameters.rsaDetail.keyBits;\n    BOOL         OK      = TRUE;\n    //\n    s_rsaKeyCacheEnabled = FALSE;\n    for(index = 0; OK && index < RSA_KEY_CACHE_ENTRIES; index++)\n\t{\n\t    publicArea->parameters.rsaDetail.keyBits = SupportedRsaKeySizes[index];\n\t    OK = (CryptRsaGenerateKey(publicArea, sensitive, rand) == TPM_RC_SUCCESS);\n\t    if(OK)\n\t\t{\n\t\t    s_rsaKeyCache[index].publicModulus   = publicArea->unique.rsa;\n\t\t    s_rsaKeyCache[index].privateExponent = sensitive->sensitive.rsa;\n\t\t}\n\t}\n    publicArea->parameters.rsaDetail.keyBits = keySave;\n    s_keyCacheLoaded                         = OK;\n#  if SIMULATION && USE_RSA_KEY_CACHE && USE_KEY_CACHE_FILE\n    if(OK)\n\t{\n\t    FILE*       cacheFile;\n\t    const char* fn = CACHE_FILE_NAME;\n\n#    if defined     _MSC_VER\n\t    if(fopen_s(&cacheFile, fn, \"w+b\") != 0)\n#    else\n\t\tcacheFile = fopen(fn, \"w+b\");\n\t    if(NULL == cacheFile)\n#    endif\n\t\t{\n\t\t    printf(\"Can't open %s for write.\\n\", fn);\n\t\t}\n\t    else\n\t\t{\n\t\t    fseek(cacheFile, 0, SEEK_SET);\n\t\t    if(fwrite(s_rsaKeyCache, 1, sizeof(s_rsaKeyCache), cacheFile)\n\t\t       != sizeof(s_rsaKeyCache))\n\t\t\t{\n\t\t\t    printf(\"Error writing cache to %s.\", fn);\n\t\t\t}\n\t\t}\n\t    if(cacheFile)\n\t\tfclose(cacheFile);\n\t}\n#  endif\n    return s_keyCacheLoaded;\n}\n\n//*** KeyCacheLoaded()\n// Checks that key cache is loaded.\n//  Return Type: BOOL\n//      TRUE(1)         cache loaded\n//      FALSE(0)        cache not loaded\nstatic BOOL KeyCacheLoaded(TPMT_PUBLIC*    publicArea,\n\t\t\t   TPMT_SENSITIVE* sensitive,\n\t\t\t   RAND_STATE*     rand  // IN: if not NULL, the deterministic\n\t\t\t   //     RNG state\n\t\t\t   )\n{\n#  if SIMULATION && USE_RSA_KEY_CACHE && USE_KEY_CACHE_FILE\n    if(!s_keyCacheLoaded)\n\t{\n\t    FILE*       cacheFile;\n\t    const char* fn = CACHE_FILE_NAME;\n#    if defined     _MSC_VER && 1\n\t    if(fopen_s(&cacheFile, fn, \"r+b\") == 0)\n#    else\n\t\tcacheFile = fopen(fn, \"r+b\");\n\t    if(NULL != cacheFile)\n#    endif\n\t\t{\n\t\t    fseek(cacheFile, 0L, SEEK_END);\n\t\t    if(ftell(cacheFile) == sizeof(s_rsaKeyCache))\n\t\t\t{\n\t\t\t    fseek(cacheFile, 0L, SEEK_SET);\n\t\t\t    s_keyCacheLoaded =\n\t\t\t\t(fread(&s_rsaKeyCache, 1, sizeof(s_rsaKeyCache), cacheFile)\n\t\t\t\t == sizeof(s_rsaKeyCache));\n\t\t\t}\n\t\t    fclose(cacheFile);\n\t\t}\n\t}\n#  endif\n    if(!s_keyCacheLoaded)\n\ts_rsaKeyCacheEnabled = InitializeKeyCache(publicArea, sensitive, rand);\n    return s_keyCacheLoaded;\n}\n\n//*** GetCachedRsaKey()\n//  Return Type: BOOL\n//      TRUE(1)         key loaded\n//      FALSE(0)        key not loaded\nBOOL GetCachedRsaKey(TPMT_PUBLIC*    publicArea,\n\t\t     TPMT_SENSITIVE* sensitive,\n\t\t     RAND_STATE*     rand  // IN: if not NULL, the deterministic\n\t\t     //     RNG state\n\t\t     )\n{\n    int keyBits = publicArea->parameters.rsaDetail.keyBits;\n    int index;\n    //\n    if(KeyCacheLoaded(publicArea, sensitive, rand))\n\t{\n\t    for(index = 0; index < RSA_KEY_CACHE_ENTRIES; index++)\n\t\t{\n\t\t    if((s_rsaKeyCache[index].publicModulus.t.size * 8) == keyBits)\n\t\t\t{\n\t\t\t    publicArea->unique.rsa   = s_rsaKeyCache[index].publicModulus;\n\t\t\t    sensitive->sensitive.rsa = s_rsaKeyCache[index].privateExponent;\n\t\t\t    return TRUE;\n\t\t\t}\n\t\t}\n\t    return FALSE;\n\t}\n    return s_keyCacheLoaded;\n}\n#endif  // defined SIMULATION && defined USE_RSA_KEY_CACHE\n"
  },
  {
    "path": "ftpm-opensbi/src/RunCommand.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tPlatform specific entry and fail processing\t   \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: RunCommand.c 1476 2019-06-10 19:32:03Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* C.11 RunCommand.c */\n/* C.11.1. Introduction */\n/* This module provides the platform specific entry and fail processing. The _plat__RunCommand()\n   function is used to call to ExecuteCommand() in the TPM code. This function does whatever\n   processing is necessary to set up the platform in anticipation of the call to the TPM including\n   settup for error processing. */\n/* The _plat__Fail() function is called when there is a failure in the TPM. The TPM code will have\n   set the flag to indicate that the TPM is in failure mode. This call will then recursively call\n   ExecuteCommand() in order to build the failure mode response. When ExecuteCommand() returns to\n   _plat__Fail(), the platform will do some platform specific operation to return to the environment\n   in which the TPM is executing. For a simulator, setjmp/longjmp is used. For an OS, a system exit\n   to the OS would be appropriate. */\n/* C.11.2. Includes and locals */\n#include \"Platform.h\"\n#include <setjmp.h>\n#include \"ExecCommand_fp.h\"\njmp_buf              s_jumpBuffer;\n/* C.11.3. Functions */\n/* C.11.3.1. _plat__RunCommand() */\n/* This version of RunCommand() will set up a jum_buf and call ExecuteCommand(). If the command\n   executes without failing, it will return and RunCommand() will return. If there is a failure in\n   the command, then _plat__Fail() is called and it will longjump back to RunCommand() which will\n   call ExecuteCommand() again. However, this time, the TPM will be in failure mode so\n   ExecuteCommand() will simply build a failure response and return. */\nLIB_EXPORT void\n_plat__RunCommand(\n\t\t  uint32_t         requestSize,   // IN: command buffer size\n\t\t  unsigned char   *request,       // IN: command buffer\n\t\t  uint32_t        *responseSize,  // IN/OUT: response buffer size\n\t\t  unsigned char   **response      // IN/OUT: response buffer\n\t\t  )\n{\n    // setjmp(s_jumpBuffer);\n    ExecuteCommand(requestSize, request, responseSize, response);\n}\n/* C.11.3.2. _plat__Fail() */\n/* This is the platform depended failure exit for the TPM. */\n// LIB_EXPORT NORETURN void\n// _plat__Fail(\n// \t    void\n// \t    )\n// {\n//     // longjmp(&s_jumpBuffer[0], 1);\n// }"
  },
  {
    "path": "ftpm-opensbi/src/Session.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Manage the session context counter \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//**Introduction\n/*\n  The code in this file is used to manage the session context counter.\n  The scheme implemented here is a \"truncated counter\".\n  This scheme allows the TPM to not need TPM_SU_CLEAR for a\n  very long period of time and still not have the context\n  count for a session repeated.\n\n  The counter (contextCounter)in this implementation is a UINT64 but\n  can be smaller.  The \"tracking array\" (contextArray) only\n  has 16-bits per context.  The tracking array is the data\n  that needs to be saved and restored across TPM_SU_STATE so that\n  sessions are not lost when the system enters the sleep state.\n  Also, when the TPM is active, the tracking array is kept in\n  RAM making it important that the number of bytes for each\n  entry be kept as small as possible.\n\n  The TPM prevents \"collisions\" of these truncated values by\n  not allowing a contextID to be assigned if it would be the\n  same as an existing value.  Since the array holds 16 bits,\n  after a context has been saved, an additional 2^16-1 contexts\n  may be saved before the count would again match.  The normal\n  expectation is that the context will be flushed before its count\n  value is needed again but it is always possible to have long-lived\n  sessions.\n\n  The contextID is assigned when the context is saved (TPM2_ContextSave()).\n  At that time, the TPM will compare the low-order 16 bits of\n  contextCounter to the existing values in contextArray and if one\n  matches, the TPM will return TPM_RC_CONTEXT_GAP (by construction,\n  the entry that contains the matching value is the oldest\n  context).\n\n  The expected remediation by the TRM is to load the oldest saved\n  session context (the one found by the TPM), and save it.  Since loading\n  the oldest session also eliminates its contextID value from\n  contextArray, there TPM will always be able to load and save the oldest\n  existing context.\n\n  In the worst case, software may have to load and save several contexts\n  in order to save an additional one.  This should happen very infrequently.\n\n  When the TPM searches contextArray and finds that none of the contextIDs\n  match the low-order 16-bits of contextCount, the TPM can copy the low bits\n  to the contextArray associated with the session, and increment contextCount.\n\n  There is one entry in contextArray for each of the active sessions\n  allowed by the TPM implementation.  This array contains either a\n  context count, an index, or a value indicating the slot is available (0).\n\n  The index into the contextArray is the handle for the session with the region\n  selector byte of the session set to zero.  If an entry in contextArray contains\n  0, then the corresponding handle may be assigned to a session.  If the entry\n  contains a value that is less than or equal to the number of loaded sessions\n  for the TPM, then the array entry is the slot in which the context is loaded.\n\n  EXAMPLE:    If the TPM allows 8 loaded sessions, then the slot numbers would\n  be 1-8 and a contextArrary value in that range would represent the loaded\n  session.\n\n  NOTE:   When the TPM firmware determines that the array entry is for a loaded\n  session, it will subtract 1 to create the zero-based slot number.\n\n  There is one significant corner case in this scheme.  When the contextCount\n  is equal to a value in the contextArray, the oldest session needs to be\n  recycled or flushed. In order to recycle the session, it must be loaded.\n  To be loaded, there must be an available slot.  Rather than require that a\n  spare slot be available all the time, the TPM will check to see if the\n  contextCount is equal to some value in the contextArray when a session is\n  created.  This prevents the last session slot from being used when it\n  is likely that a session will need to be recycled.\n\n  If a TPM with both 1.2 and 2.0 functionality uses this scheme for both\n  1.2 and 2.0 sessions, and the list of active contexts is read with\n  TPM_GetCapabiltiy(), the TPM will create 32-bit representations of the\n  list that contains 16-bit values (the TPM2_GetCapability() returns a list\n  of handles for active sessions rather than a list of contextID).  The full\n  contextID has high-order bits that are either the same as the current\n  contextCount or one less.  It is one less if the 16-bits\n  of the contextArray has a value that is larger than the low-order 16 bits\n  of contextCount.\n*/\n\n//** Includes, Defines, and Local Variables\n#define SESSION_C\n#include \"Tpm.h\"\n\n//** File Scope Function -- ContextIdSetOldest()\n/*\n  This function is called when the oldest contextID is being loaded or deleted.\n  Once a saved context becomes the oldest, it stays the oldest until it is\n  deleted.\n\n  Finding the oldest is a bit tricky.  It is not just the numeric comparison of\n  values but is dependent on the value of contextCounter.\n\n  Assume we have a small contextArray with 8, 4-bit values with values 1 and 2\n  used to indicate the loaded context slot number.  Also assume that the array\n  contains hex values of (0 0 1 0 3 0 9 F) and that the contextCounter is an\n  8-bit counter with a value of 0x37. Since the low nibble is 7, that means\n  that values above 7 are older than values below it and, in this example,\n  9 is the oldest value.\n\n  Note if we subtract the counter value, from each slot that contains a saved\n  contextID we get (- - - - B - 2 - 8) and the oldest entry is now easy to find.\n*/\nstatic void ContextIdSetOldest(void)\n{\n    CONTEXT_SLOT lowBits;\n    CONTEXT_SLOT entry;\n    CONTEXT_SLOT smallest = ((CONTEXT_SLOT)~0);\n    UINT32       i;\n\n    // Set oldestSaveContext to a value indicating none assigned\n    s_oldestSavedSession = MAX_ACTIVE_SESSIONS + 1;\n\n    lowBits              = (CONTEXT_SLOT)gr.contextCounter;\n    for(i = 0; i < MAX_ACTIVE_SESSIONS; i++)\n\t{\n\t    entry = gr.contextArray[i];\n\n\t    // only look at entries that are saved contexts\n\t    if(entry > MAX_LOADED_SESSIONS)\n\t\t{\n\t\t    // Use a less than or equal in case the oldest\n\t\t    // is brand new (= lowBits-1) and equal to our initial\n\t\t    // value for smallest.\n\t\t    if(((CONTEXT_SLOT)(entry - lowBits)) <= smallest)\n\t\t\t{\n\t\t\t    smallest             = (entry - lowBits);\n\t\t\t    s_oldestSavedSession = i;\n\t\t\t}\n\t\t}\n\t}\n    // When we finish, either the s_oldestSavedSession still has its initial\n    // value, or it has the index of the oldest saved context.\n}\n\n//** Startup Function -- SessionStartup()\n// This function initializes the session subsystem on TPM2_Startup().\nBOOL SessionStartup(STARTUP_TYPE type)\n{\n    UINT32 i;\n\n    // Initialize session slots.  At startup, all the in-memory session slots\n    // are cleared and marked as not occupied\n    for(i = 0; i < MAX_LOADED_SESSIONS; i++)\n\ts_sessions[i].occupied = FALSE;  // session slot is not occupied\n\n    // The free session slots the number of maximum allowed loaded sessions\n    s_freeSessionSlots = MAX_LOADED_SESSIONS;\n\n    // Initialize context ID data.  On a ST_SAVE or hibernate sequence, it will\n    // scan the saved array of session context counts, and clear any entry that\n    // references a session that was in memory during the state save since that\n    // memory was not preserved over the ST_SAVE.\n    if(type == SU_RESUME || type == SU_RESTART)\n\t{\n\t    // On ST_SAVE we preserve the contexts that were saved but not the ones\n\t    // in memory\n\t    for(i = 0; i < MAX_ACTIVE_SESSIONS; i++)\n\t\t{\n\t\t    // If the array value is unused or references a loaded session then\n\t\t    // that loaded session context is lost and the array entry is\n\t\t    // reclaimed.\n\t\t    if(gr.contextArray[i] <= MAX_LOADED_SESSIONS)\n\t\t\tgr.contextArray[i] = 0;\n\t\t}\n\t    // Find the oldest session in context ID data and set it in\n\t    // s_oldestSavedSession\n\t    ContextIdSetOldest();\n\t}\n    else\n\t{\n\t    // For STARTUP_CLEAR, clear out the contextArray\n\t    for(i = 0; i < MAX_ACTIVE_SESSIONS; i++)\n\t\tgr.contextArray[i] = 0;\n\n\t    // reset the context counter\n\t    gr.contextCounter = MAX_LOADED_SESSIONS + 1;\n\n\t    // Initialize oldest saved session\n\t    s_oldestSavedSession = MAX_ACTIVE_SESSIONS + 1;\n\t}\n    return TRUE;\n}\n\n//************************************************\n//** Access Functions\n//************************************************\n\n//*** SessionIsLoaded()\n// This function test a session handle references a loaded session.  The handle\n// must have previously been checked to make sure that it is a valid handle for\n// an authorization session.\n// NOTE:    A PWAP authorization does not have a session.\n//\n//  Return Type: BOOL\n//      TRUE(1)         session is loaded\n//      FALSE(0)        session is not loaded\n//\nBOOL SessionIsLoaded(TPM_HANDLE handle  // IN: session handle\n\t\t     )\n{\n    pAssert(HandleGetType(handle) == TPM_HT_POLICY_SESSION\n\t    || HandleGetType(handle) == TPM_HT_HMAC_SESSION);\n\n    handle = handle & HR_HANDLE_MASK;\n\n    // if out of range of possible active session, or not assigned to a loaded\n    // session return false\n    if(handle >= MAX_ACTIVE_SESSIONS || gr.contextArray[handle] == 0\n       || gr.contextArray[handle] > MAX_LOADED_SESSIONS)\n\treturn FALSE;\n\n    return TRUE;\n}\n\n//*** SessionIsSaved()\n// This function test a session handle references a saved session.  The handle\n// must have previously been checked to make sure that it is a valid handle for\n// an authorization session.\n// NOTE:    An password authorization does not have a session.\n//\n// This function requires that the handle be a valid session handle.\n//\n//  Return Type: BOOL\n//      TRUE(1)         session is saved\n//      FALSE(0)        session is not saved\n//\nBOOL SessionIsSaved(TPM_HANDLE handle  // IN: session handle\n\t\t    )\n{\n    pAssert(HandleGetType(handle) == TPM_HT_POLICY_SESSION\n\t    || HandleGetType(handle) == TPM_HT_HMAC_SESSION);\n\n    handle = handle & HR_HANDLE_MASK;\n    // if out of range of possible active session, or not assigned, or\n    // assigned to a loaded session, return false\n    if(handle >= MAX_ACTIVE_SESSIONS || gr.contextArray[handle] == 0\n       || gr.contextArray[handle] <= MAX_LOADED_SESSIONS)\n\treturn FALSE;\n\n    return TRUE;\n}\n\n//*** SequenceNumberForSavedContextIsValid()\n// This function validates that the sequence number and handle value within a\n// saved context are valid.\nBOOL SequenceNumberForSavedContextIsValid(\n\t\t\t\t\t  TPMS_CONTEXT* context  // IN: pointer to a context structure to be\n\t\t\t\t\t  //     validated\n\t\t\t\t\t  )\n{\n#define MAX_CONTEXT_GAP ((UINT64)((CONTEXT_SLOT)~0) + 1)\n\n    TPM_HANDLE handle = context->savedHandle & HR_HANDLE_MASK;\n\n    if(  // Handle must be with the range of active sessions\n\t handle >= MAX_ACTIVE_SESSIONS\n\t // the array entry must be for a saved context\n\t || gr.contextArray[handle] <= MAX_LOADED_SESSIONS\n\t // the array entry must agree with the sequence number\n\t || gr.contextArray[handle] != (CONTEXT_SLOT)context->sequence\n\t // the provided sequence number has to be less than the current counter\n\t || context->sequence > gr.contextCounter\n\t // but not so much that it could not be a valid sequence number\n\t || gr.contextCounter - context->sequence > MAX_CONTEXT_GAP)\n\treturn FALSE;\n\n    return TRUE;\n}\n\n//*** SessionPCRValueIsCurrent()\n//\n// This function is used to check if PCR values have been updated since the\n// last time they were checked in a policy session.\n//\n// This function requires the session is loaded.\n//  Return Type: BOOL\n//      TRUE(1)         PCR value is current\n//      FALSE(0)        PCR value is not current\nBOOL SessionPCRValueIsCurrent(SESSION* session  // IN: session structure\n\t\t\t      )\n{\n    if(session->pcrCounter != 0 && session->pcrCounter != gr.pcrCounter)\n\treturn FALSE;\n    else\n\treturn TRUE;\n}\n\n//*** SessionGet()\n// This function returns a pointer to the session object associated with a\n// session handle.\n//\n// The function requires that the session is loaded.\nSESSION* SessionGet(TPM_HANDLE handle  // IN: session handle\n\t\t    )\n{\n    size_t       slotIndex;\n    CONTEXT_SLOT sessionIndex;\n\n    pAssert(HandleGetType(handle) == TPM_HT_POLICY_SESSION\n\t    || HandleGetType(handle) == TPM_HT_HMAC_SESSION);\n\n    slotIndex = handle & HR_HANDLE_MASK;\n\n    pAssert(slotIndex < MAX_ACTIVE_SESSIONS);\n\n    // get the contents of the session array.  Because session is loaded, we\n    // should always get a valid sessionIndex\n    sessionIndex = gr.contextArray[slotIndex] - 1;\n\n    pAssert(sessionIndex < MAX_LOADED_SESSIONS);\n\n    return &s_sessions[sessionIndex].session;\n}\n\n//************************************************\n//** Utility Functions\n//************************************************\n\n//*** ContextIdSessionCreate()\n//\n//  This function is called when a session is created.  It will check\n//  to see if the current gap would prevent a context from being saved.  If\n//  so it will return TPM_RC_CONTEXT_GAP.  Otherwise, it will try to find\n//  an open slot in contextArray, set contextArray to the slot.\n//\n//  This routine requires that the caller has determined the session array\n//  index for the session.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_CONTEXT_GAP      can't assign a new contextID until the oldest\n//                              saved session context is recycled\n//      TPM_RC_SESSION_HANDLE   there is no slot available in the context array\n//                              for tracking of this session context\nstatic TPM_RC ContextIdSessionCreate(\n\t\t\t\t     TPM_HANDLE* handle,  // OUT: receives the assigned handle. This will\n\t\t\t\t     //     be an index that must be adjusted by the\n\t\t\t\t     //     caller according to the type of the\n\t\t\t\t     //     session created\n\t\t\t\t     UINT32 sessionIndex  // IN: The session context array entry that will\n\t\t\t\t     //     be occupied by the created session\n\t\t\t\t     )\n{\n    pAssert(sessionIndex < MAX_LOADED_SESSIONS);\n\n    // check to see if creating the context is safe\n    // Is this going to be an assignment for the last session context\n    // array entry?  If so, then there will be no room to recycle the\n    // oldest context if needed.  If the gap is not at maximum, then\n    // it will be possible to save a context if it becomes necessary.\n    if(s_oldestSavedSession < MAX_ACTIVE_SESSIONS && s_freeSessionSlots == 1)\n\t{\n\t    // See if the gap is at maximum\n\t    // The current value of the contextCounter will be assigned to the next\n\t    // saved context. If the value to be assigned would make the same as an\n\t    // existing context, then we can't use it because of the ambiguity it would\n\t    // create.\n\t    if((CONTEXT_SLOT)gr.contextCounter == gr.contextArray[s_oldestSavedSession])\n\t\treturn TPM_RC_CONTEXT_GAP;\n\t}\n\n    // Find an unoccupied entry in the contextArray\n    for(*handle = 0; *handle < MAX_ACTIVE_SESSIONS; (*handle)++)\n\t{\n\t    if(gr.contextArray[*handle] == 0)\n\t\t{\n\t\t    // indicate that the session associated with this handle\n\t\t    // references a loaded session\n\t\t    gr.contextArray[*handle] = (CONTEXT_SLOT)(sessionIndex + 1);\n\t\t    return TPM_RC_SUCCESS;\n\t\t}\n\t}\n    return TPM_RC_SESSION_HANDLES;\n}\n\n//*** SessionCreate()\n//\n//  This function does the detailed work for starting an authorization session.\n//  This is done in a support routine rather than in the action code because\n//  the session management may differ in implementations.  This implementation\n//  uses a fixed memory allocation to hold sessions and a fixed allocation\n//  to hold the contextID for the saved contexts.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_CONTEXT_GAP          need to recycle sessions\n//      TPM_RC_SESSION_HANDLE       active session space is full\n//      TPM_RC_SESSION_MEMORY       loaded session space is full\nTPM_RC\nSessionCreate(TPM_SE         sessionType,    // IN: the session type\n\t      TPMI_ALG_HASH  authHash,       // IN: the hash algorithm\n\t      TPM2B_NONCE*   nonceCaller,    // IN: initial nonceCaller\n\t      TPMT_SYM_DEF*  symmetric,      // IN: the symmetric algorithm\n\t      TPMI_DH_ENTITY bind,           // IN: the bind object\n\t      TPM2B_DATA*    seed,           // IN: seed data\n\t      TPM_HANDLE*    sessionHandle,  // OUT: the session handle\n\t      TPM2B_NONCE*   nonceTpm        // OUT: the session nonce\n\t      )\n{\n    TPM_RC       result = TPM_RC_SUCCESS;\n    CONTEXT_SLOT slotIndex;\n    SESSION*     session = NULL;\n\n    pAssert(sessionType == TPM_SE_HMAC || sessionType == TPM_SE_POLICY\n\t    || sessionType == TPM_SE_TRIAL);\n\n    // If there are no open spots in the session array, then no point in searching\n    if(s_freeSessionSlots == 0)\n\treturn TPM_RC_SESSION_MEMORY;\n\n    // Find a space for loading a session\n    for(slotIndex = 0; slotIndex < MAX_LOADED_SESSIONS; slotIndex++)\n\t{\n\t    // Is this available?\n\t    if(s_sessions[slotIndex].occupied == FALSE)\n\t\t{\n\t\t    session = &s_sessions[slotIndex].session;\n\t\t    break;\n\t\t}\n\t}\n    // if no spot found, then this is an internal error\n    if(slotIndex >= MAX_LOADED_SESSIONS)\n\tFAIL(FATAL_ERROR_INTERNAL);\n\n    // Call context ID function to get a handle.  TPM_RC_SESSION_HANDLE may be\n    // returned from ContextIdHandelAssign()\n    result = ContextIdSessionCreate(sessionHandle, slotIndex);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    //*** Only return from this point on is TPM_RC_SUCCESS\n\n    // Can now indicate that the session array entry is occupied.\n    s_freeSessionSlots--;\n    s_sessions[slotIndex].occupied = TRUE;\n\n    // Initialize the session data\n    MemorySet(session, 0, sizeof(SESSION));\n\n    // Initialize internal session data\n    session->authHashAlg = authHash;\n    // Initialize session type\n    if(sessionType == TPM_SE_HMAC)\n\t{\n\t    *sessionHandle += HMAC_SESSION_FIRST;\n\t}\n    else\n\t{\n\t    *sessionHandle += POLICY_SESSION_FIRST;\n\n\t    // For TPM_SE_POLICY or TPM_SE_TRIAL\n\t    session->attributes.isPolicy = SET;\n\t    if(sessionType == TPM_SE_TRIAL)\n\t\tsession->attributes.isTrialPolicy = SET;\n\n\t    SessionSetStartTime(session);\n\n\t    // Initialize policyDigest.  policyDigest is initialized with a string of 0\n\t    // of session algorithm digest size. Since the session is already clear.\n\t    // Just need to set the size\n\t    session->u2.policyDigest.t.size =\n\t\tCryptHashGetDigestSize(session->authHashAlg);\n\t}\n    // Create initial session nonce\n    session->nonceTPM.t.size = nonceCaller->t.size;\n    CryptRandomGenerate(session->nonceTPM.t.size, session->nonceTPM.t.buffer);\n    MemoryCopy2B(&nonceTpm->b, &session->nonceTPM.b, sizeof(nonceTpm->t.buffer));\n\n    // Set up session parameter encryption algorithm\n    session->symmetric = *symmetric;\n\n    // If there is a bind object or a session secret, then need to compute\n    // a sessionKey.\n    if(bind != TPM_RH_NULL || seed->t.size != 0)\n\t{\n\t    // sessionKey = KDFa(hash, (authValue || seed), \"ATH\", nonceTPM,\n\t    //                      nonceCaller, bits)\n\t    // The HMAC key for generating the sessionSecret can be the concatenation\n\t    // of an authorization value and a seed value\n\t    TPM2B_TYPE(KEY, (sizeof(TPMT_HA) + sizeof(seed->t.buffer)));\n\t    TPM2B_KEY key;\n\n\t    // Get hash size, which is also the length of sessionKey\n\t    session->sessionKey.t.size = CryptHashGetDigestSize(session->authHashAlg);\n\n\t    // Get authValue of associated entity\n\t    EntityGetAuthValue(bind, (TPM2B_AUTH*)&key);\n\t    pAssert(key.t.size + seed->t.size <= sizeof(key.t.buffer));\n\n\t    // Concatenate authValue and seed\n\t    MemoryConcat2B(&key.b, &seed->b, sizeof(key.t.buffer));\n\n\t    // Compute the session key\n\t    CryptKDFa(session->authHashAlg,\n\t\t      &key.b,\n\t\t      SESSION_KEY,\n\t\t      &session->nonceTPM.b,\n\t\t      &nonceCaller->b,\n\t\t      session->sessionKey.t.size * 8,\n\t\t      session->sessionKey.t.buffer,\n\t\t      NULL,\n\t\t      FALSE);\n\t}\n\n    // Copy the name of the entity that the HMAC session is bound to\n    // Policy session is not bound to an entity\n    if(bind != TPM_RH_NULL && sessionType == TPM_SE_HMAC)\n\t{\n\t    session->attributes.isBound = SET;\n\t    SessionComputeBoundEntity(bind, &session->u1.boundEntity);\n\t}\n    // If there is a bind object and it is subject to DA, then use of this session\n    // is subject to DA regardless of how it is used.\n    session->attributes.isDaBound = (bind != TPM_RH_NULL)\n\t\t\t\t    && (IsDAExempted(bind) == FALSE);\n\n    // If the session is bound, then check to see if it is bound to lockoutAuth\n    session->attributes.isLockoutBound = (session->attributes.isDaBound == SET)\n\t\t\t\t\t && (bind == TPM_RH_LOCKOUT);\n    return TPM_RC_SUCCESS;\n}\n\n//*** SessionContextSave()\n// This function is called when a session context is to be saved.  The\n// contextID of the saved session is returned.  If no contextID can be\n// assigned, then the routine returns TPM_RC_CONTEXT_GAP.\n// If the function completes normally, the session slot will be freed.\n//\n// This function requires that 'handle' references a loaded session.\n// Otherwise, it should not be called at the first place.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_CONTEXT_GAP              a contextID could not be assigned\n//      TPM_RC_TOO_MANY_CONTEXTS        the counter maxed out\n//\nTPM_RC\nSessionContextSave(TPM_HANDLE       handle,    // IN: session handle\n\t\t   CONTEXT_COUNTER* contextID  // OUT: assigned contextID\n\t\t   )\n{\n    UINT32       contextIndex;\n    CONTEXT_SLOT slotIndex;\n\n    pAssert(SessionIsLoaded(handle));\n\n    // check to see if the gap is already maxed out\n    // Need to have a saved session\n    if(s_oldestSavedSession < MAX_ACTIVE_SESSIONS\n       // if the oldest saved session has the same value as the low bits\n       // of the contextCounter, then the GAP is maxed out.\n       && gr.contextArray[s_oldestSavedSession] == (CONTEXT_SLOT)gr.contextCounter)\n\treturn TPM_RC_CONTEXT_GAP;\n\n    // if the caller wants the context counter, set it\n    if(contextID != NULL)\n\t*contextID = gr.contextCounter;\n\n    contextIndex = handle & HR_HANDLE_MASK;\n    pAssert(contextIndex < MAX_ACTIVE_SESSIONS);\n\n    // Extract the session slot number referenced by the contextArray\n    // because we are going to overwrite this with the low order\n    // contextID value.\n    slotIndex = gr.contextArray[contextIndex] - 1;\n\n    // Set the contextID for the contextArray\n    gr.contextArray[contextIndex] = (CONTEXT_SLOT)gr.contextCounter;\n\n    // Increment the counter\n    gr.contextCounter++;\n\n    // In the unlikely event that the 64-bit context counter rolls over...\n    if(gr.contextCounter == 0)\n\t{\n\t    // back it up\n\t    gr.contextCounter--;\n\t    // return an error\n\t    return TPM_RC_TOO_MANY_CONTEXTS;\n\t}\n    // if the low-order bits wrapped, need to advance the value to skip over\n    // the values used to indicate that a session is loaded\n    if(((CONTEXT_SLOT)gr.contextCounter) == 0)\n\tgr.contextCounter += MAX_LOADED_SESSIONS + 1;\n\n    // If no other sessions are saved, this is now the oldest.\n    if(s_oldestSavedSession >= MAX_ACTIVE_SESSIONS)\n\ts_oldestSavedSession = contextIndex;\n\n    // Mark the session slot as unoccupied\n    s_sessions[slotIndex].occupied = FALSE;\n\n    // and indicate that there is an additional open slot\n    s_freeSessionSlots++;\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** SessionContextLoad()\n// This function is used to load a session from saved context.  The session\n// handle must be for a saved context.\n//\n// If the gap is at a maximum, then the only session that can be loaded is\n// the oldest session, otherwise TPM_RC_CONTEXT_GAP is returned.\n//\n// This function requires that 'handle' references a valid saved session.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SESSION_MEMORY       no free session slots\n//      TPM_RC_CONTEXT_GAP          the gap count is maximum and this\n//                                  is not the oldest saved context\n//\nTPM_RC\nSessionContextLoad(SESSION_BUF* session,  // IN: session structure from saved context\n\t\t   TPM_HANDLE*  handle    // IN/OUT: session handle\n\t\t   )\n{\n    UINT32       contextIndex;\n    CONTEXT_SLOT slotIndex;\n\n    pAssert(HandleGetType(*handle) == TPM_HT_POLICY_SESSION\n\t    || HandleGetType(*handle) == TPM_HT_HMAC_SESSION);\n\n    // Don't bother looking if no openings\n    if(s_freeSessionSlots == 0)\n\treturn TPM_RC_SESSION_MEMORY;\n\n    // Find a free session slot to load the session\n    for(slotIndex = 0; slotIndex < MAX_LOADED_SESSIONS; slotIndex++)\n\tif(s_sessions[slotIndex].occupied == FALSE)\n\t    break;\n\n    // if no spot found, then this is an internal error\n    pAssert(slotIndex < MAX_LOADED_SESSIONS);\n\n    contextIndex = *handle & HR_HANDLE_MASK;  // extract the index\n\n    // If there is only one slot left, and the gap is at maximum, the only session\n    // context that we can safely load is the oldest one.\n    if(s_oldestSavedSession < MAX_ACTIVE_SESSIONS && s_freeSessionSlots == 1\n       && (CONTEXT_SLOT)gr.contextCounter == gr.contextArray[s_oldestSavedSession]\n       && contextIndex != s_oldestSavedSession)\n\treturn TPM_RC_CONTEXT_GAP;\n\n    pAssert(contextIndex < MAX_ACTIVE_SESSIONS);\n\n    // set the contextArray value to point to the session slot where\n    // the context is loaded\n    gr.contextArray[contextIndex] = slotIndex + 1;\n\n    // if this was the oldest context, find the new oldest\n    if(contextIndex == s_oldestSavedSession)\n\tContextIdSetOldest();\n\n    // Copy session data to session slot\n    MemoryCopy(&s_sessions[slotIndex].session, session, sizeof(SESSION));\n\n    // Set session slot as occupied\n    s_sessions[slotIndex].occupied = TRUE;\n\n    // Reduce the number of open spots\n    s_freeSessionSlots--;\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** SessionFlush()\n// This function is used to flush a session referenced by its handle.  If the\n// session associated with 'handle' is loaded, the session array entry is\n// marked as available.\n//\n// This function requires that 'handle' be a valid active session.\n//\nvoid SessionFlush(TPM_HANDLE handle  // IN: loaded or saved session handle\n\t\t  )\n{\n    CONTEXT_SLOT slotIndex;\n    UINT32       contextIndex;  // Index into contextArray\n\n    pAssert((HandleGetType(handle) == TPM_HT_POLICY_SESSION\n\t     || HandleGetType(handle) == TPM_HT_HMAC_SESSION)\n\t    && (SessionIsLoaded(handle) || SessionIsSaved(handle)));\n\n    // Flush context ID of this session\n    // Convert handle to an index into the contextArray\n    contextIndex = handle & HR_HANDLE_MASK;\n\n    pAssert(contextIndex < sizeof(gr.contextArray) / sizeof(gr.contextArray[0]));\n\n    // Get the current contents of the array\n    slotIndex = gr.contextArray[contextIndex];\n\n    // Mark context array entry as available\n    gr.contextArray[contextIndex] = 0;\n\n    // Is this a saved session being flushed\n    if(slotIndex > MAX_LOADED_SESSIONS)\n\t{\n\t    // Flushing the oldest session?\n\t    if(contextIndex == s_oldestSavedSession)\n\t\t// If so, find a new value for oldest.\n\t\tContextIdSetOldest();\n\t}\n    else\n\t{\n\t    // Adjust slot index to point to session array index\n\t    slotIndex -= 1;\n\n\t    // Free session array index\n\t    s_sessions[slotIndex].occupied = FALSE;\n\t    s_freeSessionSlots++;\n\t}\n\n    return;\n}\n\n//*** SessionComputeBoundEntity()\n// This function computes the binding value for a session.  The binding value\n// for a reserved handle is the handle itself.  For all the other entities,\n// the authValue at the time of binding is included to prevent squatting.\n// For those values, the Name and the authValue are concatenated\n// into the bind buffer.  If they will not both fit, the will be overlapped\n// by XORing bytes.  If XOR is required, the bind value will be full.\nvoid SessionComputeBoundEntity(TPMI_DH_ENTITY entityHandle,  // IN: handle of entity\n\t\t\t       TPM2B_NAME*    bind           // OUT: binding value\n\t\t\t       )\n{\n    TPM2B_AUTH auth;\n    BYTE*      pAuth = auth.t.buffer;\n    UINT16     i;\n\n    // Get name\n    EntityGetName(entityHandle, bind);\n\n    //    // The bound value of a reserved handle is the handle itself\n    //    if(bind->t.size == sizeof(TPM_HANDLE)) return;\n\n    // For all the other entities, concatenate the authorization value to the name.\n    // Get a local copy of the authorization value because some overlapping\n    // may be necessary.\n    EntityGetAuthValue(entityHandle, &auth);\n\n    // Make sure that the extra space is zeroed\n    MemorySet(&bind->t.name[bind->t.size], 0, sizeof(bind->t.name) - bind->t.size);\n    // XOR the authValue at the end of the name\n    for(i = sizeof(bind->t.name) - auth.t.size; i < sizeof(bind->t.name); i++)\n\tbind->t.name[i] ^= *pAuth++;\n\n    // Set the bind value to the maximum size\n    bind->t.size = sizeof(bind->t.name);\n\n    return;\n}\n\n//*** SessionSetStartTime()\n// This function is used to initialize the session timing\nvoid SessionSetStartTime(SESSION* session  // IN: the session to update\n\t\t\t )\n{\n    session->startTime = g_time;\n    session->epoch     = g_timeEpoch;\n    session->timeout   = 0;\n}\n\n//*** SessionResetPolicyData()\n// This function is used to reset the policy data without changing the nonce\n// or the start time of the session.\nvoid SessionResetPolicyData(SESSION* session  // IN: the session to reset\n\t\t\t    )\n{\n    SESSION_ATTRIBUTES oldAttributes;\n    pAssert(session != NULL);\n\n    // Will need later\n    oldAttributes = session->attributes;\n\n    // No command\n    session->commandCode = 0;\n\n    // No locality selected\n    MemorySet(&session->commandLocality, 0, sizeof(session->commandLocality));\n\n    // The cpHash size to zero\n    session->u1.cpHash.b.size = 0;\n\n    // No timeout\n    session->timeout = 0;\n\n    // Reset the pcrCounter\n    session->pcrCounter = 0;\n\n    // Reset the policy hash\n    MemorySet(&session->u2.policyDigest.t.buffer, 0, session->u2.policyDigest.t.size);\n\n    // Reset the session attributes\n    MemorySet(&session->attributes, 0, sizeof(SESSION_ATTRIBUTES));\n\n    // Restore the policy attributes\n    session->attributes.isPolicy      = SET;\n    session->attributes.isTrialPolicy = oldAttributes.isTrialPolicy;\n\n    // Restore the bind attributes\n    session->attributes.isDaBound      = oldAttributes.isDaBound;\n    session->attributes.isLockoutBound = oldAttributes.isLockoutBound;\n}\n\n//*** SessionCapGetLoaded()\n// This function returns a list of handles of loaded session, started\n// from input 'handle'\n//\n// 'Handle' must be in valid loaded session handle range, but does not\n// have to point to a loaded session.\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles available\n//      NO          all the available handles has been returned\nTPMI_YES_NO\nSessionCapGetLoaded(TPMI_SH_POLICY handle,     // IN: start handle\n\t\t    UINT32         count,      // IN: count of returned handles\n\t\t    TPML_HANDLE*   handleList  // OUT: list of handle\n\t\t    )\n{\n    TPMI_YES_NO more = NO;\n    UINT32      i;\n\n    pAssert(HandleGetType(handle) == TPM_HT_LOADED_SESSION);\n\n    // Initialize output handle list\n    handleList->count = 0;\n\n    // The maximum count of handles we may return is MAX_CAP_HANDLES\n    if(count > MAX_CAP_HANDLES)\n\tcount = MAX_CAP_HANDLES;\n\n    // Iterate session context ID slots to get loaded session handles\n    for(i = handle & HR_HANDLE_MASK; i < MAX_ACTIVE_SESSIONS; i++)\n\t{\n\t    // If session is active\n\t    if(gr.contextArray[i] != 0)\n\t\t{\n\t\t    // If session is loaded\n\t\t    if(gr.contextArray[i] <= MAX_LOADED_SESSIONS)\n\t\t\t{\n\t\t\t    if(handleList->count < count)\n\t\t\t\t{\n\t\t\t\t    SESSION* session;\n\n\t\t\t\t    // If we have not filled up the return list, add this\n\t\t\t\t    // session handle to it\n\t\t\t\t    // assume that this is going to be an HMAC session\n\t\t\t\t    handle  = i + HMAC_SESSION_FIRST;\n\t\t\t\t    session = SessionGet(handle);\n\t\t\t\t    if(session->attributes.isPolicy)\n\t\t\t\t\thandle = i + POLICY_SESSION_FIRST;\n\t\t\t\t    handleList->handle[handleList->count] = handle;\n\t\t\t\t    handleList->count++;\n\t\t\t\t}\n\t\t\t    else\n\t\t\t\t{\n\t\t\t\t    // If the return list is full but we still have loaded object\n\t\t\t\t    // available, report this and stop iterating\n\t\t\t\t    more = YES;\n\t\t\t\t    break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n    return more;\n}\n\n//*** SessionCapGetOneLoaded()\n// This function returns whether a session handle exists and is loaded.\nBOOL SessionCapGetOneLoaded(TPMI_SH_POLICY handle)  // IN: handle\n{\n    pAssert(HandleGetType(handle) == TPM_HT_LOADED_SESSION);\n\n    if((handle & HR_HANDLE_MASK) < MAX_ACTIVE_SESSIONS\n       && gr.contextArray[(handle & HR_HANDLE_MASK)])\n\t{\n\t    return TRUE;\n\t}\n\n    return FALSE;\n}\n\n//*** SessionCapGetSaved()\n// This function returns a list of handles for saved session, starting at\n// 'handle'.\n//\n// 'Handle' must be in a valid handle range, but does not have to point to a\n// saved session\n//\n//  Return Type: TPMI_YES_NO\n//      YES         if there are more handles available\n//      NO          all the available handles has been returned\nTPMI_YES_NO\nSessionCapGetSaved(TPMI_SH_HMAC handle,     // IN: start handle\n\t\t   UINT32       count,      // IN: count of returned handles\n\t\t   TPML_HANDLE* handleList  // OUT: list of handle\n\t\t   )\n{\n    TPMI_YES_NO more = NO;\n    UINT32      i;\n\n    pAssert(HandleGetType(handle) == TPM_HT_SAVED_SESSION);\n\n    // Initialize output handle list\n    handleList->count = 0;\n\n    // The maximum count of handles we may return is MAX_CAP_HANDLES\n    if(count > MAX_CAP_HANDLES)\n\tcount = MAX_CAP_HANDLES;\n\n    // Iterate session context ID slots to get loaded session handles\n    for(i = handle & HR_HANDLE_MASK; i < MAX_ACTIVE_SESSIONS; i++)\n\t{\n\t    // If session is active\n\t    if(gr.contextArray[i] != 0)\n\t\t{\n\t\t    // If session is saved\n\t\t    if(gr.contextArray[i] > MAX_LOADED_SESSIONS)\n\t\t\t{\n\t\t\t    if(handleList->count < count)\n\t\t\t\t{\n\t\t\t\t    // If we have not filled up the return list, add this\n\t\t\t\t    // session handle to it\n\t\t\t\t    handleList->handle[handleList->count] = i + HMAC_SESSION_FIRST;\n\t\t\t\t    handleList->count++;\n\t\t\t\t}\n\t\t\t    else\n\t\t\t\t{\n\t\t\t\t    // If the return list is full but we still have loaded object\n\t\t\t\t    // available, report this and stop iterating\n\t\t\t\t    more = YES;\n\t\t\t\t    break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n    return more;\n}\n\n//*** SessionCapGetOneSaved()\n// This function returns whether a session handle exists and is saved.\nBOOL SessionCapGetOneSaved(TPMI_SH_HMAC handle)  // IN: handle\n{\n    pAssert(HandleGetType(handle) == TPM_HT_SAVED_SESSION);\n\n    if((handle & HR_HANDLE_MASK) < MAX_ACTIVE_SESSIONS\n       && gr.contextArray[(handle & HR_HANDLE_MASK)])\n\t{\n\t    return TRUE;\n\t}\n\n    return FALSE;\n}\n\n//*** SessionCapGetLoadedNumber()\n// This function return the number of authorization sessions currently\n// loaded into TPM RAM.\nUINT32\nSessionCapGetLoadedNumber(void)\n{\n    return MAX_LOADED_SESSIONS - s_freeSessionSlots;\n}\n\n//*** SessionCapGetLoadedAvail()\n// This function returns the number of additional authorization sessions, of\n// any type, that could be loaded into TPM RAM.\n// NOTE: In other implementations, this number may just be an estimate. The only\n//       requirement for the estimate is, if it is one or more, then at least one\n//       session must be loadable.\nUINT32\nSessionCapGetLoadedAvail(void)\n{\n    return s_freeSessionSlots;\n}\n\n//*** SessionCapGetActiveNumber()\n// This function returns the number of active authorization sessions currently\n// being tracked by the TPM.\nUINT32\nSessionCapGetActiveNumber(void)\n{\n    UINT32 i;\n    UINT32 num = 0;\n\n    // Iterate the context array to find the number of non-zero slots\n    for(i = 0; i < MAX_ACTIVE_SESSIONS; i++)\n\t{\n\t    if(gr.contextArray[i] != 0)\n\t\tnum++;\n\t}\n\n    return num;\n}\n\n//*** SessionCapGetActiveAvail()\n// This function returns the number of additional authorization sessions, of any\n// type, that could be created. This not the number of slots for sessions, but\n// the number of additional sessions that the TPM is capable of tracking.\nUINT32\nSessionCapGetActiveAvail(void)\n{\n    UINT32 i;\n    UINT32 num = 0;\n\n    // Iterate the context array to find the number of zero slots\n    for(i = 0; i < MAX_ACTIVE_SESSIONS; i++)\n\t{\n\t    if(gr.contextArray[i] == 0)\n\t\tnum++;\n\t}\n\n    return num;\n}\n\n//*** IsCpHashUnionOccupied()\n// This function indicates whether the session attributes indicate that one of\n// the members of the union containing `cpHash` are set.\nBOOL IsCpHashUnionOccupied(SESSION_ATTRIBUTES attrs)\n{\n    return attrs.isBound || attrs.isCpHashDefined || attrs.isNameHashDefined\n\t|| attrs.isParametersHashDefined || attrs.isTemplateHashDefined;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/SessionCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \tSession Commands\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: SessionCommands.c 1519 2019-11-15 20:43:51Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"StartAuthSession_fp.h\"\n\nextern int verbose;\n\n#if CC_StartAuthSession  // Conditional expansion of this file\nTPM_RC\nTPM2_StartAuthSession(\n\t\t      StartAuthSession_In     *in,            // IN: input parameter buffer\n\t\t      StartAuthSession_Out    *out            // OUT: output parameter buffer\n\t\t      )\n{\n    TPM_RC                   result = TPM_RC_SUCCESS;\n    OBJECT                  *tpmKey;                // TPM key for decrypt salt\n    TPM2B_DATA               salt;\n    // Input Validation\n    // Check input nonce size.  IT should be at least 16 bytes but not larger\n    // than the digest size of session hash.\n    if(in->nonceCaller.t.size < 16\n       || in->nonceCaller.t.size > CryptHashGetDigestSize(in->authHash))\n\treturn TPM_RCS_SIZE + RC_StartAuthSession_nonceCaller;\n    // If an decrypt key is passed in, check its validation\n    if(in->tpmKey != TPM_RH_NULL)\n\t{\n\t    // Get pointer to loaded decrypt key\n\t    tpmKey = HandleToObject(in->tpmKey);\n\t    // key must be asymmetric with its sensitive area loaded. Since this\n\t    // command does not require authorization, the presence of the sensitive\n\t    // area was not already checked as it is with most other commands that\n\t    // use the sensitive are so check it here\n\t    if(!CryptIsAsymAlgorithm(tpmKey->publicArea.type))\n\t\treturn TPM_RCS_KEY + RC_StartAuthSession_tpmKey;\n\t    // secret size cannot be 0\n\t    if(in->encryptedSalt.t.size == 0)\n\t\treturn TPM_RCS_VALUE + RC_StartAuthSession_encryptedSalt;\n\t    // Decrypting salt requires accessing the private portion of a key.\n\t    // Therefore, tmpKey can not be a key with only public portion loaded\n\t    if(tpmKey->attributes.publicOnly)\n\t\treturn TPM_RCS_HANDLE + RC_StartAuthSession_tpmKey;\n\t    // HMAC session input handle check.\n\t    // tpmKey should be a decryption key\n\t    if(!IS_ATTRIBUTE(tpmKey->publicArea.objectAttributes, TPMA_OBJECT, decrypt))\n\t\treturn TPM_RCS_ATTRIBUTES + RC_StartAuthSession_tpmKey;\n\t    // Secret Decryption.  A TPM_RC_VALUE, TPM_RC_KEY or Unmarshal errors\n\t    // may be returned at this point\n\t    result = CryptSecretDecrypt(tpmKey, &in->nonceCaller, SECRET_KEY,\n\t\t\t\t\t&in->encryptedSalt, &salt);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn TPM_RCS_VALUE + RC_StartAuthSession_encryptedSalt;\n\t}\n    else\n\t{\n\t    // secret size must be 0\n\t    if(in->encryptedSalt.t.size != 0)\n\t\treturn TPM_RCS_VALUE + RC_StartAuthSession_encryptedSalt;\n\t    salt.t.size = 0;\n\t}\n    switch(HandleGetType(in->bind))\n\t{\n\t  case TPM_HT_TRANSIENT:\n\t      {\n\t\t  OBJECT      *object = HandleToObject(in->bind);\n\t\t  // If the bind handle references a transient object, make sure that we\n\t\t  // can get to the authorization value. Also, make sure that the object\n\t\t  // has a proper Name (nameAlg != TPM_ALG_NULL). If it doesn't, then\n\t\t  // it might be possible to bind to an object where the authValue is\n\t\t  // known. This does not create a real issue in that, if you know the\n\t\t  // authorization value, you can actually bind to the object. However,\n\t\t  // there is a potential\n\t\t  if(object->attributes.publicOnly == SET)\n\t\t      return TPM_RCS_HANDLE + RC_StartAuthSession_bind;\n\t\t  break;\n\t      }\n\t  case TPM_HT_NV_INDEX:\n\t    // a PIN index can't be a bind object\n\t      {\n\t\t  NV_INDEX       *nvIndex = NvGetIndexInfo(in->bind, NULL);\n\t\t  if(IsNvPinPassIndex(nvIndex->publicArea.attributes)\n\t\t     || IsNvPinFailIndex(nvIndex->publicArea.attributes))\n\t\t      return TPM_RCS_HANDLE + RC_StartAuthSession_bind;\n\t\t  break;\n\t      }\n\t  default:\n\t    break;\n\t}\n    // If 'symmetric' is a symmetric block cipher (not TPM_ALG_NULL or TPM_ALG_XOR)\n    // then the mode must be CFB.\n    if(in->symmetric.algorithm != TPM_ALG_NULL\n       && in->symmetric.algorithm != TPM_ALG_XOR\n       && in->symmetric.mode.sym != TPM_ALG_CFB)\n\treturn TPM_RCS_MODE + RC_StartAuthSession_symmetric;\n    // Internal Data Update and command output\n    // Create internal session structure.  TPM_RC_CONTEXT_GAP, TPM_RC_NO_HANDLES\n    // or TPM_RC_SESSION_MEMORY errors may be returned at this point.\n    //\n    // The detailed actions for creating the session context are not shown here\n    // as the details are implementation dependent\n    // SessionCreate sets the output handle and nonceTPM\n    result = SessionCreate(in->sessionType, in->authHash, &in->nonceCaller,\n\t\t\t   &in->symmetric, in->bind, &salt, &out->sessionHandle,\n\t\t\t   &out->nonceTPM);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_StartAuthSession: sessionHandle %08x\\n\", out->sessionHandle);\n\t// fclose(f);\n  //   }\n    return result;\n}\n#endif // CC_StartAuthSession\n#include \"Tpm.h\"\n#include \"PolicyRestart_fp.h\"\n#if CC_PolicyRestart  // Conditional expansion of this file\nTPM_RC\nTPM2_PolicyRestart(\n\t\t   PolicyRestart_In    *in             // IN: input parameter list\n\t\t   )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_PolicyRestart: sessionHandle %08x\\n\", in->sessionHandle);\n\t// fclose(f);\n  //   }\n    // Initialize policy session data\n    SessionResetPolicyData(SessionGet(in->sessionHandle));\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_PolicyRestart\n"
  },
  {
    "path": "ftpm-opensbi/src/SessionProcess.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tProcess the Authorization Sessions     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//**  Introduction\n// This file contains the subsystem that process the authorization sessions\n// including implementation of the Dictionary Attack logic. ExecCommand() uses\n// ParseSessionBuffer() to process the authorization session area of a command and\n// BuildResponseSession() to create the authorization session area of a response.\n\n//**  Includes and Data Definitions\n\n#define SESSION_PROCESS_C\n\n#include \"Tpm.h\"\n#include \"ACT.h\"\n#include \"Marshal.h\"\n\n//\n//**  Authorization Support Functions\n//\n\n//*** IsDAExempted()\n// This function indicates if a handle is exempted from DA logic.\n// A handle is exempted if it is:\n//  a) a primary seed handle;\n//  b) an object with noDA bit SET;\n//  c) an NV Index with TPMA_NV_NO_DA bit SET; or\n//  d) a PCR handle.\n//\n//  Return Type: BOOL\n//      TRUE(1)         handle is exempted from DA logic\n//      FALSE(0)        handle is not exempted from DA logic\nBOOL IsDAExempted(TPM_HANDLE handle  // IN: entity handle\n\t\t  )\n{\n    BOOL result = FALSE;\n    //\n    switch(HandleGetType(handle))\n\t{\n\t  case TPM_HT_PERMANENT:\n\t    // All permanent handles, other than TPM_RH_LOCKOUT, are exempt from\n\t    // DA protection.\n\t    result = (handle != TPM_RH_LOCKOUT);\n\t    break;\n\t    // When this function is called, a persistent object will have been loaded\n\t    // into an object slot and assigned a transient handle.\n\t  case TPM_HT_TRANSIENT:\n\t      {\n\t\t  TPMA_OBJECT attributes = ObjectGetPublicAttributes(handle);\n\t\t  result                 = IS_ATTRIBUTE(attributes, TPMA_OBJECT, noDA);\n\t\t  break;\n\t      }\n\t  case TPM_HT_NV_INDEX:\n\t      {\n\t\t  NV_INDEX* nvIndex = NvGetIndexInfo(handle, NULL);\n\t\t  result = IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, NO_DA);\n\t\t  break;\n\t      }\n\t  case TPM_HT_PCR:\n\t    // PCRs are always exempted from DA.\n\t    result = TRUE;\n\t    break;\n\t  default:\n\t    break;\n\t}\n    return result;\n}\n\n//*** IncrementLockout()\n// This function is called after an authorization failure that involves use of\n// an authValue. If the entity referenced by the handle is not exempt from DA\n// protection, then the failedTries counter will be incremented.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_AUTH_FAIL    authorization failure that caused DA lockout to increment\n//      TPM_RC_BAD_AUTH     authorization failure did not cause DA lockout to\n//                          increment\nstatic TPM_RC IncrementLockout(UINT32 sessionIndex)\n{\n    TPM_HANDLE handle        = s_associatedHandles[sessionIndex];\n    TPM_HANDLE sessionHandle = s_sessionHandles[sessionIndex];\n    SESSION*   session       = NULL;\n    //\n    // Don't increment lockout unless the handle associated with the session\n    // is DA protected or the session is bound to a DA protected entity.\n    if(sessionHandle == TPM_RS_PW)\n\t{\n\t    if(IsDAExempted(handle))\n\t\treturn TPM_RC_BAD_AUTH;\n\t}\n    else\n\t{\n\t    session = SessionGet(sessionHandle);\n\t    // If the session is bound to lockout, then use that as the relevant\n\t    // handle. This means that an authorization failure with a bound session\n\t    // bound to lockoutAuth will take precedence over any other\n\t    // lockout check\n\t    if(session->attributes.isLockoutBound == SET)\n\t\thandle = TPM_RH_LOCKOUT;\n\t    if(session->attributes.isDaBound == CLEAR\n\t       && (IsDAExempted(handle) || session->attributes.includeAuth == CLEAR))\n\t\t// If the handle was changed to TPM_RH_LOCKOUT, this will not return\n\t\t// TPM_RC_BAD_AUTH\n\t\treturn TPM_RC_BAD_AUTH;\n\t}\n    if(handle == TPM_RH_LOCKOUT)\n\t{\n\t    pAssert(gp.lockOutAuthEnabled == TRUE);\n\n\t    // lockout is no longer enabled\n\t    gp.lockOutAuthEnabled = FALSE;\n\n\t    // For TPM_RH_LOCKOUT, if lockoutRecovery is 0, no need to update NV since\n\t    // the lockout authorization will be reset at startup.\n\t    if(gp.lockoutRecovery != 0)\n\t\t{\n\t\t    if(NV_IS_AVAILABLE)\n\t\t\t// Update NV.\n\t\t\tNV_SYNC_PERSISTENT(lockOutAuthEnabled);\n\t\t    else\n\t\t\t// No NV access for now. Put the TPM in pending mode.\n\t\t\ts_DAPendingOnNV = TRUE;\n\t\t}\n\t}\n    else\n\t{\n\t    if(gp.recoveryTime != 0)\n\t\t{\n\t\t    gp.failedTries++;\n\t\t    if(NV_IS_AVAILABLE)\n\t\t\t// Record changes to NV. NvWrite will SET g_updateNV\n\t\t\tNV_SYNC_PERSISTENT(failedTries);\n\t\t    else\n\t\t\t// No NV access for now.  Put the TPM in pending mode.\n\t\t\ts_DAPendingOnNV = TRUE;\n\t\t}\n\t}\n    // Register a DA failure and reset the timers.\n    DARegisterFailure(handle);\n\n    return TPM_RC_AUTH_FAIL;\n}\n\n//*** IsSessionBindEntity()\n// This function indicates if the entity associated with the handle is the entity,\n// to which this session is bound. The binding would occur by making the \"bind\"\n// parameter in TPM2_StartAuthSession() not equal to TPM_RH_NULL. The binding only\n// occurs if the session is an HMAC session. The bind value is a combination of\n// the Name and the authValue of the entity.\n//\n//  Return Type: BOOL\n//      TRUE(1)         handle points to the session start entity\n//      FALSE(0)        handle does not point to the session start entity\nstatic BOOL IsSessionBindEntity(\n\t\t\t\tTPM_HANDLE associatedHandle,  // IN: handle to be authorized\n\t\t\t\tSESSION*   session            // IN: associated session\n\t\t\t\t)\n{\n    TPM2B_NAME entity;  // The bind value for the entity\n    //\n    // If the session is not bound, return FALSE.\n    if(session->attributes.isBound)\n\t{\n\t    // Compute the bind value for the entity.\n\t    SessionComputeBoundEntity(associatedHandle, &entity);\n\n\t    // Compare to the bind value in the session.\n\t    return MemoryEqual2B(&entity.b, &session->u1.boundEntity.b);\n\t}\n    return FALSE;\n}\n\n//*** IsPolicySessionRequired()\n// Checks if a policy session is required for a command. If a command requires\n// DUP or ADMIN role authorization, then the handle that requires that role is the\n// first handle in the command. This simplifies this checking. If a new command\n// is created that requires multiple ADMIN role authorizations, then it will\n// have to be special-cased in this function.\n// A policy session is required if:\n// a) the command requires the DUP role;\n// b) the command requires the ADMIN role and the authorized entity\n//    is an object and its adminWithPolicy bit is SET;\n// c) the command requires the ADMIN role and the authorized entity\n//    is a permanent handle or an NV Index; or\n// d) the authorized entity is a PCR belonging to a policy group, and\n//    has its policy initialized\n//  Return Type: BOOL\n//      TRUE(1)         policy session is required\n//      FALSE(0)        policy session is not required\nstatic BOOL IsPolicySessionRequired(COMMAND_INDEX commandIndex,  // IN: command index\n\t\t\t\t    UINT32        sessionIndex   // IN: session index\n\t\t\t\t    )\n{\n    AUTH_ROLE role = CommandAuthRole(commandIndex, sessionIndex);\n    TPM_HT    type = HandleGetType(s_associatedHandles[sessionIndex]);\n    //\n    if(role == AUTH_DUP)\n\treturn TRUE;\n    if(role == AUTH_ADMIN)\n\t{\n\t    // We allow an exception for ADMIN role in a transient object. If the object\n\t    // allows ADMIN role actions with authorization, then policy is not\n\t    // required. For all other cases, there is no way to override the command\n\t    // requirement that a policy be used\n\t    if(type == TPM_HT_TRANSIENT)\n\t\t{\n\t\t    OBJECT* object = HandleToObject(s_associatedHandles[sessionIndex]);\n\n\t\t    if(!IS_ATTRIBUTE(object->publicArea.objectAttributes, TPMA_OBJECT, adminWithPolicy))\n\t\t\treturn FALSE;\n\t\t}\n\t    return TRUE;\n\t}\n\n    if(type == TPM_HT_PCR)\n\t{\n\t    if(PCRPolicyIsAvailable(s_associatedHandles[sessionIndex]))\n\t\t{\n\t\t    TPM2B_DIGEST  policy;\n\t\t    TPMI_ALG_HASH policyAlg;\n\t\t    policyAlg = PCRGetAuthPolicy(s_associatedHandles[sessionIndex], &policy);\n\t\t    if(policyAlg != TPM_ALG_NULL)\n\t\t\treturn TRUE;\n\t\t}\n\t}\n    return FALSE;\n}\n\n//*** IsAuthValueAvailable()\n// This function indicates if authValue is available and allowed for USER role\n// authorization of an entity.\n//\n// This function is similar to IsAuthPolicyAvailable() except that it does not\n// check the size of the authValue as IsAuthPolicyAvailable() does (a null\n// authValue is a valid authorization, but a null policy is not a valid policy).\n//\n// This function does not check that the handle reference is valid or if the entity\n// is in an enabled hierarchy. Those checks are assumed to have been performed\n// during the handle unmarshaling.\n//\n//  Return Type: BOOL\n//      TRUE(1)         authValue is available\n//      FALSE(0)        authValue is not available\nstatic BOOL IsAuthValueAvailable(TPM_HANDLE    handle,        // IN: handle of entity\n\t\t\t\t COMMAND_INDEX commandIndex,  // IN: command index\n\t\t\t\t UINT32        sessionIndex   // IN: session index\n\t\t\t\t )\n{\n    BOOL result = FALSE;\n    //\n    switch(HandleGetType(handle))\n\t{\n\t  case TPM_HT_PERMANENT:\n\t    switch(handle)\n\t\t{\n\t\t    // At this point hierarchy availability has already been\n\t\t    // checked so primary seed handles are always available here\n\t\t  case TPM_RH_OWNER:\n\t\t  case TPM_RH_ENDORSEMENT:\n\t\t  case TPM_RH_PLATFORM:\n#if VENDOR_PERMANENT_AUTH_ENABLED == YES\n\t\t    // This vendor defined handle associated with the\n\t\t    // manufacturer's shared secret\n\t\t  case VENDOR_PERMANENT_AUTH_HANDLE:\n#endif\n\t\t    // The DA checking has been performed on LockoutAuth but we\n\t\t    // bypass the DA logic if we are using lockout policy. The\n\t\t    // policy would allow execution to continue an lockoutAuth\n\t\t    // could be used, even if direct use of lockoutAuth is disabled\n\t\t  case TPM_RH_LOCKOUT:\n\t\t    // NullAuth is always available.\n\t\t  case TPM_RH_NULL:\n\t\t    result = TRUE;\n\t\t    break;\n\n#if ACT_SUPPORT\n\t\t    FOR_EACH_ACT(CASE_ACT_HANDLE)\n\t\t\t{\n\t\t\t    // The ACT auth value is not available if the platform is disabled\n\t\t\t    result = g_phEnable == SET;\n\t\t\t    break;\n\t\t\t}\n#endif  // ACT_SUPPORT\n\n\t\t  default:\n\t\t    // Otherwise authValue is not available.\n\t\t    break;\n\t\t}\n\t    break;\n\t  case TPM_HT_TRANSIENT:\n\t    // A persistent object has already been loaded and the internal\n\t    // handle changed.\n\t      {\n\t\t  OBJECT*     object;\n\t\t  TPMA_OBJECT attributes;\n\t\t  //\n\t\t  object     = HandleToObject(handle);\n\t\t  attributes = object->publicArea.objectAttributes;\n\n\t\t  // authValue is always available for a sequence object.\n\t\t  // An alternative for this is to\n\t\t  // SET_ATTRIBUTE(object->publicArea, TPMA_OBJECT, userWithAuth) when the\n\t\t  // sequence is started.\n\t\t  if(ObjectIsSequence(object))\n\t\t      {\n\t\t\t  result = TRUE;\n\t\t\t  break;\n\t\t      }\n\t\t  // authValue is available for an object if it has its sensitive\n\t\t  // portion loaded and\n\t\t  //  a) userWithAuth bit is SET, or\n\t\t  //  b) ADMIN role is required\n\t\t  if(object->attributes.publicOnly == CLEAR\n\t\t     && (IS_ATTRIBUTE(attributes, TPMA_OBJECT, userWithAuth)\n\t\t\t || (CommandAuthRole(commandIndex, sessionIndex) == AUTH_ADMIN\n\t\t\t     && !IS_ATTRIBUTE(\n\t\t\t\t\t      attributes, TPMA_OBJECT, adminWithPolicy))))\n\t\t      result = TRUE;\n\t      }\n\t      break;\n\t  case TPM_HT_NV_INDEX:\n\t    // NV Index.\n\t      {\n\t\t  NV_REF    locator;\n\t\t  NV_INDEX* nvIndex = NvGetIndexInfo(handle, &locator);\n\t\t  TPMA_NV   nvAttributes;\n\t\t  //\n\t\t  pAssert(nvIndex != 0);\n\n\t\t  nvAttributes = nvIndex->publicArea.attributes;\n\n\t\t  if(IsWriteOperation(commandIndex))\n\t\t      {\n\t\t\t  // AuthWrite can't be set for a PIN index\n\t\t\t  if(IS_ATTRIBUTE(nvAttributes, TPMA_NV, AUTHWRITE))\n\t\t\t      result = TRUE;\n\t\t      }\n\t\t  else\n\t\t      {\n\t\t\t  // A \"read\" operation\n\t\t\t  // For a PIN Index, the authValue is available as long as the\n\t\t\t  // Index has been written and the pinCount is less than pinLimit\n\t\t\t  if(IsNvPinFailIndex(nvAttributes)\n\t\t\t     || IsNvPinPassIndex(nvAttributes))\n\t\t\t      {\n\t\t\t\t  NV_PIN pin;\n\t\t\t\t  if(!IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITTEN))\n\t\t\t\t      break;  // return false\n\t\t\t\t  // get the index values\n\t\t\t\t  pin.intVal = NvGetUINT64Data(nvIndex, locator);\n\t\t\t\t  if(pin.pin.pinCount < pin.pin.pinLimit)\n\t\t\t\t      result = TRUE;\n\t\t\t      }\n\t\t\t  // For non-PIN Indexes, need to allow use of the authValue\n\t\t\t  else if(IS_ATTRIBUTE(nvAttributes, TPMA_NV, AUTHREAD))\n\t\t\t      result = TRUE;\n\t\t      }\n\t      }\n\t      break;\n\t  case TPM_HT_PCR:\n\t    // PCR handle.\n\t    // authValue is always allowed for PCR\n\t    result = TRUE;\n\t    break;\n\t  default:\n\t    // Otherwise, authValue is not available\n\t    break;\n\t}\n    return result;\n}\n\n//*** IsAuthPolicyAvailable()\n// This function indicates if an authPolicy is available and allowed.\n//\n// This function does not check that the handle reference is valid or if the entity\n// is in an enabled hierarchy. Those checks are assumed to have been performed\n// during the handle unmarshaling.\n//\n//  Return Type: BOOL\n//      TRUE(1)         authPolicy is available\n//      FALSE(0)        authPolicy is not available\nstatic BOOL IsAuthPolicyAvailable(TPM_HANDLE    handle,        // IN: handle of entity\n\t\t\t\t  COMMAND_INDEX commandIndex,  // IN: command index\n\t\t\t\t  UINT32        sessionIndex   // IN: session index\n\t\t\t\t  )\n{\n    BOOL result = FALSE;\n    //\n    switch(HandleGetType(handle))\n\t{\n\t  case TPM_HT_PERMANENT:\n\t    switch(handle)\n\t\t{\n\t\t    // At this point hierarchy availability has already been checked.\n\t\t  case TPM_RH_OWNER:\n\t\t    if(gp.ownerPolicy.t.size != 0)\n\t\t\tresult = TRUE;\n\t\t    break;\n\t\t  case TPM_RH_ENDORSEMENT:\n\t\t    if(gp.endorsementPolicy.t.size != 0)\n\t\t\tresult = TRUE;\n\t\t    break;\n\t\t  case TPM_RH_PLATFORM:\n\t\t    if(gc.platformPolicy.t.size != 0)\n\t\t\tresult = TRUE;\n\t\t    break;\n#if ACT_SUPPORT\n\n#  define ACT_GET_POLICY(N)\t\t\t\t\t\t\\\n\t\t    case TPM_RH_ACT_##N:\t\t\t\t\\\n\t\t      if(go.ACT_##N.authPolicy.t.size != 0)\t\t\\\n\t\t\t  result = TRUE;\t\t\t\t\\\n\t\t      break;\n\n\t\t    FOR_EACH_ACT(ACT_GET_POLICY)\n#endif  // ACT_SUPPORT\n\n\t\t  case TPM_RH_LOCKOUT:\n\t\t    if(gp.lockoutPolicy.t.size != 0)\n\t\t\tresult = TRUE;\n\t\t    break;\n\t\t  default:\n\t\t    break;\n\t\t}\n\t    break;\n\t  case TPM_HT_TRANSIENT:\n\t      {\n\t\t  // Object handle.\n\t\t  // An evict object would already have been loaded and given a\n\t\t  // transient object handle by this point.\n\t\t  OBJECT* object = HandleToObject(handle);\n\t\t  // Policy authorization is not available for an object with only\n\t\t  // public portion loaded.\n\t\t  if(object->attributes.publicOnly == CLEAR)\n\t\t      {\n\t\t\t  // Policy authorization is always available for an object but\n\t\t\t  // is never available for a sequence.\n\t\t\t  if(!ObjectIsSequence(object))\n\t\t\t      result = TRUE;\n\t\t      }\n\t\t  break;\n\t      }\n\t  case TPM_HT_NV_INDEX:\n\t    // An NV Index.\n\t      {\n\t\t  NV_INDEX* nvIndex      = NvGetIndexInfo(handle, NULL);\n\t\t  TPMA_NV   nvAttributes = nvIndex->publicArea.attributes;\n\t\t  //\n\t\t  // If the policy size is not zero, check if policy can be used.\n\t\t  if(nvIndex->publicArea.authPolicy.t.size != 0)\n\t\t      {\n\t\t\t  // If policy session is required for this handle, always\n\t\t\t  // uses policy regardless of the attributes bit setting\n\t\t\t  if(IsPolicySessionRequired(commandIndex, sessionIndex))\n\t\t\t      result = TRUE;\n\t\t\t  // Otherwise, the presence of the policy depends on the NV\n\t\t\t  // attributes.\n\t\t\t  else if(IsWriteOperation(commandIndex))\n\t\t\t      {\n\t\t\t\t  if(IS_ATTRIBUTE(nvAttributes, TPMA_NV, POLICYWRITE))\n\t\t\t\t      result = TRUE;\n\t\t\t      }\n\t\t\t  else\n\t\t\t      {\n\t\t\t\t  if(IS_ATTRIBUTE(nvAttributes, TPMA_NV, POLICYREAD))\n\t\t\t\t      result = TRUE;\n\t\t\t      }\n\t\t      }\n\t      }\n\t      break;\n\t  case TPM_HT_PCR:\n\t    // PCR handle.\n\t    if(PCRPolicyIsAvailable(handle))\n\t\tresult = TRUE;\n\t    break;\n\t  default:\n\t    break;\n\t}\n    return result;\n}\n\n//**  Session Parsing Functions\n\n//*** ClearCpRpHashes()\nvoid ClearCpRpHashes(COMMAND* command)\n{\n    // The macros expand according to the implemented hash algorithms. An IDE may\n    // complain that COMMAND does not contain SHA1CpHash or SHA1RpHash because of the\n    // complexity of the macro expansion where the data space is defined; but, if SHA1\n    // is implemented, it actually does  and the compiler is happy.\n#define CLEAR_CP_HASH(HASH, Hash) command->Hash##CpHash.b.size = 0;\n    FOR_EACH_HASH(CLEAR_CP_HASH)\n#define CLEAR_RP_HASH(HASH, Hash) command->Hash##RpHash.b.size = 0;\n\tFOR_EACH_HASH(CLEAR_RP_HASH)\n\t}\n\n//*** GetCpHashPointer()\n// Function to get a pointer to the cpHash of the command\nstatic TPM2B_DIGEST* GetCpHashPointer(COMMAND* command, TPMI_ALG_HASH hashAlg)\n{\n    TPM2B_DIGEST* retVal;\n    //\n    // Define the macro that will expand for each implemented algorithm in the switch\n    // statement below.\n#define GET_CP_HASH_POINTER(HASH, Hash)\t\t\t\t    \\\n    case ALG_##HASH##_VALUE:\t\t\t\t\t    \\\n      retVal = (TPM2B_DIGEST*)&command->Hash##CpHash;\t\t    \\\n      break;\n\n    switch(hashAlg)\n\t{\n\t    // For each implemented hash, this will expand as defined above\n\t    // by GET_CP_HASH_POINTER. Your IDE may complain that\n\t    // 'struct \"COMMAND\" has no field \"SHA1CpHash\"' but the compiler says\n\t    // it does, so...\n\t    FOR_EACH_HASH(GET_CP_HASH_POINTER)\n\t  default:\n\t    retVal = NULL;\n\t    break;\n\t}\n    return retVal;\n}\n\n//*** GetRpHashPointer()\n// Function to get a pointer to the RpHash of the command\nstatic TPM2B_DIGEST* GetRpHashPointer(COMMAND* command, TPMI_ALG_HASH hashAlg)\n{\n    TPM2B_DIGEST* retVal;\n    //\n    // Define the macro that will expand for each implemented algorithm in the switch\n    // statement below.\n#define GET_RP_HASH_POINTER(HASH, Hash)\t\t\t\t    \\\n    case ALG_##HASH##_VALUE:\t\t\t\t\t    \\\n      retVal = (TPM2B_DIGEST*)&command->Hash##RpHash;\t\t    \\\n      break;\n\n    switch(hashAlg)\n\t{\n\t    // For each implemented hash, this will expand as defined above\n\t    // by GET_RP_HASH_POINTER. Your IDE may complain that\n\t    // 'struct \"COMMAND\" has no field 'SHA1RpHash'\" but the compiler says\n\t    // it does, so...\n\t    FOR_EACH_HASH(GET_RP_HASH_POINTER)\n\t  default:\n\t    retVal = NULL;\n\t    break;\n\t}\n    return retVal;\n}\n\n//*** ComputeCpHash()\n// This function computes the cpHash as defined in Part 2 and described in Part 1.\nstatic TPM2B_DIGEST* ComputeCpHash(COMMAND* command,  // IN: command parsing structure\n\t\t\t\t   TPMI_ALG_HASH hashAlg  // IN: hash algorithm\n\t\t\t\t   )\n{\n    UINT32        i;\n    HASH_STATE    hashState;\n    TPM2B_NAME    name;\n    TPM2B_DIGEST* cpHash;\n    //\n    // cpHash = hash(commandCode [ || authName1\n    //                           [ || authName2\n    //                           [ || authName 3 ]]]\n    //                           [ || parameters])\n    // A cpHash can contain just a commandCode only if the lone session is\n    // an audit session.\n    // Get pointer to the hash value\n    cpHash = GetCpHashPointer(command, hashAlg);\n    if(cpHash->t.size == 0)\n\t{\n\t    cpHash->t.size = CryptHashStart(&hashState, hashAlg);\n\t    //  Add commandCode.\n\t    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), command->code);\n\t    //  Add authNames for each of the handles.\n\t    for(i = 0; i < command->handleNum; i++)\n\t\tCryptDigestUpdate2B(&hashState,\n\t\t\t\t    &EntityGetName(command->handles[i], &name)->b);\n\t    //  Add the parameters.\n\t    CryptDigestUpdate(\n\t\t\t      &hashState, command->parameterSize, command->parameterBuffer);\n\t    //  Complete the hash.\n\t    CryptHashEnd2B(&hashState, &cpHash->b);\n\t}\n    return cpHash;\n}\n\n//*** GetCpHash()\n// This function is used to access a precomputed cpHash.\nstatic TPM2B_DIGEST* GetCpHash(COMMAND* command, TPMI_ALG_HASH hashAlg)\n{\n    TPM2B_DIGEST* cpHash = GetCpHashPointer(command, hashAlg);\n    //\n    pAssert(cpHash->t.size != 0);\n    return cpHash;\n}\n\n//*** CompareTemplateHash()\n// This function computes the template hash and compares it to the session\n// templateHash. It is the hash of the second parameter\n// assuming that the command is TPM2_Create(), TPM2_CreatePrimary(), or\n// TPM2_CreateLoaded()\n//  Return Type: BOOL\n//      TRUE(1)         template hash equal to session->templateHash\n//      FALSE(0)        template hash not equal to session->templateHash\nstatic BOOL CompareTemplateHash(COMMAND* command,  // IN: parsing structure\n\t\t\t\tSESSION* session   // IN: session data\n\t\t\t\t)\n{\n    BYTE*        pBuffer = command->parameterBuffer;\n    INT32        pSize   = command->parameterSize;\n    TPM2B_DIGEST tHash;\n    UINT16       size;\n    //\n    // Only try this for the three commands for which it is intended\n    if(command->code != TPM_CC_Create && command->code != TPM_CC_CreatePrimary\n#if CC_CreateLoaded\n       && command->code != TPM_CC_CreateLoaded\n#endif\n       )\n\treturn FALSE;\n    // Assume that the first parameter is a TPM2B and unmarshal the size field\n    // Note: this will not affect the parameter buffer and size in the calling\n    // function.\n    if(UINT16_Unmarshal(&size, &pBuffer, &pSize) != TPM_RC_SUCCESS)\n\treturn FALSE;\n    // reduce the space in the buffer.\n    // NOTE: this could make pSize go negative if the parameters are not correct but\n    // the unmarshaling code does not try to unmarshal if the remaining size is\n    // negative.\n    pSize -= size;\n\n    // Advance the pointer\n    pBuffer += size;\n\n    // Get the size of what should be the template\n    if(UINT16_Unmarshal(&size, &pBuffer, &pSize) != TPM_RC_SUCCESS)\n\treturn FALSE;\n    // See if this is reasonable\n    if(size > pSize)\n\treturn FALSE;\n    // Hash the template data\n    tHash.t.size = CryptHashBlock(\n\t\t\t\t  session->authHashAlg, size, pBuffer, sizeof(tHash.t.buffer), tHash.t.buffer);\n    return (MemoryEqual2B(&session->u1.templateHash.b, &tHash.b));\n}\n\n//*** CompareNameHash()\n// This function computes the name hash and compares it to the nameHash in the\n// session data, returning true if they are equal.\nBOOL CompareNameHash(COMMAND* command,  // IN: main parsing structure\n\t\t     SESSION* session   // IN: session structure with nameHash\n\t\t     )\n{\n    HASH_STATE   hashState;\n    TPM2B_DIGEST nameHash;\n    UINT32       i;\n    TPM2B_NAME   name;\n    //\n    nameHash.t.size = CryptHashStart(&hashState, session->authHashAlg);\n    //  Add names.\n    for(i = 0; i < command->handleNum; i++)\n\tCryptDigestUpdate2B(&hashState,\n\t\t\t    &EntityGetName(command->handles[i], &name)->b);\n    //  Complete hash.\n    CryptHashEnd2B(&hashState, &nameHash.b);\n    // and compare\n    return MemoryEqual(\n\t\t       session->u1.nameHash.t.buffer, nameHash.t.buffer, nameHash.t.size);\n}\n\n//*** CompareParametersHash()\n// This function computes the parameters hash and compares it to the pHash in\n// the session data, returning true if they are equal.\nBOOL CompareParametersHash(COMMAND* command,  // IN: main parsing structure\n\t\t\t   SESSION* session   // IN: session structure with pHash\n\t\t\t   )\n{\n    HASH_STATE   hashState;\n    TPM2B_DIGEST pHash;\n    //\n    pHash.t.size = CryptHashStart(&hashState, session->authHashAlg);\n    //  Add commandCode.\n    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), command->code);\n    //  Add the parameters.\n    CryptDigestUpdate(&hashState, command->parameterSize, command->parameterBuffer);\n    //  Complete hash.\n    CryptHashEnd2B(&hashState, &pHash.b);\n    // and compare\n    return MemoryEqual2B(&session->u1.pHash.b, &pHash.b);\n}\n\n//*** CheckPWAuthSession()\n// This function validates the authorization provided in a PWAP session. It\n// compares the input value to authValue of the authorized entity. Argument\n// sessionIndex is used to get handles handle of the referenced entities from\n// s_inputAuthValues[] and s_associatedHandles[].\n//\n//  Return Type: TPM_RC\n//        TPM_RC_AUTH_FAIL          authorization fails and increments DA failure\n//                                  count\n//        TPM_RC_BAD_AUTH           authorization fails but DA does not apply\n//\nstatic TPM_RC CheckPWAuthSession(\n\t\t\t\t UINT32 sessionIndex  // IN: index of session to be processed\n\t\t\t\t )\n{\n    TPM2B_AUTH authValue;\n    TPM_HANDLE associatedHandle = s_associatedHandles[sessionIndex];\n    //\n    // Strip trailing zeros from the password.\n    MemoryRemoveTrailingZeros(&s_inputAuthValues[sessionIndex]);\n\n    // Get the authValue with trailing zeros removed\n    EntityGetAuthValue(associatedHandle, &authValue);\n\n    // Success if the values are identical.\n    if(MemoryEqual2B(&s_inputAuthValues[sessionIndex].b, &authValue.b))\n\t{\n\t    return TPM_RC_SUCCESS;\n\t}\n    else  // if the digests are not identical\n\t{\n\t    // Invoke DA protection if applicable.\n\t    return IncrementLockout(sessionIndex);\n\t}\n}\n\n//*** ComputeCommandHMAC()\n// This function computes the HMAC for an authorization session in a command.\n/*(See part 1 specification -- this tag keeps this comment from showing up in\n// merged document which is probably good because this comment doesn't look right.\n//      The sessionAuth value\n//      authHMAC := HMACsHash((sessionKey | authValue),\n//                  (pHash | nonceNewer | nonceOlder  | nonceTPMencrypt-only\n//                   | nonceTPMaudit   | sessionAttributes))\n// Where:\n//      HMACsHash()     The HMAC algorithm using the hash algorithm specified\n//                      when the session was started.\n//\n//      sessionKey      A value that is computed in a protocol-dependent way,\n//                      using KDFa. When used in an HMAC or KDF, the size field\n//                      for this value is not included.\n//\n//      authValue       A value that is found in the sensitive area of an entity.\n//                      When used in an HMAC or KDF, the size field for this\n//                      value is not included.\n//\n//      pHash           Hash of the command (cpHash) using the session hash.\n//                      When using a pHash in an HMAC computation, only the\n//                      digest is used.\n//\n//      nonceNewer      A value that is generated by the entity using the\n//                      session. A new nonce is generated on each use of the\n//                      session. For a command, this will be nonceCaller.\n//                      When used in an HMAC or KDF, the size field is not used.\n//\n//      nonceOlder      A TPM2B_NONCE that was received the previous time the\n//                      session was used. For a command, this is nonceTPM.\n//                      When used in an HMAC or KDF, the size field is not used.\n//\n//      nonceTPMdecrypt     The nonceTPM of the decrypt session is included in\n//                          the HMAC, but only in the command.\n//\n//      nonceTPMencrypt     The nonceTPM of the encrypt session is included in\n//                          the HMAC but only in the command.\n//\n//      sessionAttributes   A byte indicating the attributes associated with the\n//                          particular use of the session.\n*/\nstatic TPM2B_DIGEST* ComputeCommandHMAC(\n\t\t\t\t\tCOMMAND*      command,       // IN: primary control structure\n\t\t\t\t\tUINT32        sessionIndex,  // IN: index of session to be processed\n\t\t\t\t\tTPM2B_DIGEST* hmac           // OUT: authorization HMAC\n\t\t\t\t\t)\n{\n    TPM2B_TYPE(KEY, (sizeof(AUTH_VALUE) * 2));\n    TPM2B_KEY    key;\n    BYTE         marshalBuffer[sizeof(TPMA_SESSION)];\n    BYTE*        buffer;\n    UINT32       marshalSize;\n    HMAC_STATE   hmacState;\n    TPM2B_NONCE* nonceDecrypt;\n    TPM2B_NONCE* nonceEncrypt;\n    SESSION*     session;\n    //\n    nonceDecrypt = NULL;\n    nonceEncrypt = NULL;\n\n    // Determine if extra nonceTPM values are going to be required.\n    // If this is the first session (sessionIndex = 0) and it is an authorization\n    // session that uses an HMAC, then check if additional session nonces are to be\n    // included.\n    if(sessionIndex == 0 && s_associatedHandles[sessionIndex] != TPM_RH_UNASSIGNED)\n\t{\n\t    // If there is a decrypt session and if this is not the decrypt session,\n\t    // then an extra nonce may be needed.\n\t    if(s_decryptSessionIndex != UNDEFINED_INDEX\n\t       && s_decryptSessionIndex != sessionIndex)\n\t\t{\n\t\t    // Will add the nonce for the decrypt session.\n\t\t    SESSION* decryptSession =\n\t\t\tSessionGet(s_sessionHandles[s_decryptSessionIndex]);\n\t\t    nonceDecrypt = &decryptSession->nonceTPM;\n\t\t}\n\t    // Now repeat for the encrypt session.\n\t    if(s_encryptSessionIndex != UNDEFINED_INDEX\n\t       && s_encryptSessionIndex != sessionIndex\n\t       && s_encryptSessionIndex != s_decryptSessionIndex)\n\t\t{\n\t\t    // Have to have the nonce for the encrypt session.\n\t\t    SESSION* encryptSession =\n\t\t\tSessionGet(s_sessionHandles[s_encryptSessionIndex]);\n\t\t    nonceEncrypt = &encryptSession->nonceTPM;\n\t\t}\n\t}\n\n    // Continue with the HMAC processing.\n    session = SessionGet(s_sessionHandles[sessionIndex]);\n\n    // Generate HMAC key.\n    MemoryCopy2B(&key.b, &session->sessionKey.b, sizeof(key.t.buffer));\n\n    // Check if the session has an associated handle and if the associated entity\n    // is the one to which the session is bound. If not, add the authValue of\n    // this entity to the HMAC key.\n    // If the session is bound to the object or the session is a policy session\n    // with no authValue required, do not include the authValue in the HMAC key.\n    // Note: For a policy session, its isBound attribute is CLEARED.\n    //\n    // Include the entity authValue if it is needed\n    if(session->attributes.includeAuth == SET)\n\t{\n\t    TPM2B_AUTH authValue;\n\t    // Get the entity authValue with trailing zeros removed\n\t    EntityGetAuthValue(s_associatedHandles[sessionIndex], &authValue);\n\t    // add the authValue to the HMAC key\n\t    MemoryConcat2B(&key.b, &authValue.b, sizeof(key.t.buffer));\n\t}\n    // if the HMAC key size is 0, a NULL string HMAC is allowed\n    if(key.t.size == 0 && s_inputAuthValues[sessionIndex].t.size == 0)\n\t{\n\t    hmac->t.size = 0;\n\t    return hmac;\n\t}\n    // Start HMAC\n    hmac->t.size = CryptHmacStart2B(&hmacState, session->authHashAlg, &key.b);\n\n    //  Add cpHash\n    CryptDigestUpdate2B(&hmacState.hashState,\n\t\t\t&ComputeCpHash(command, session->authHashAlg)->b);\n    //  Add nonces as required\n    CryptDigestUpdate2B(&hmacState.hashState, &s_nonceCaller[sessionIndex].b);\n    CryptDigestUpdate2B(&hmacState.hashState, &session->nonceTPM.b);\n    if(nonceDecrypt != NULL)\n\tCryptDigestUpdate2B(&hmacState.hashState, &nonceDecrypt->b);\n    if(nonceEncrypt != NULL)\n\tCryptDigestUpdate2B(&hmacState.hashState, &nonceEncrypt->b);\n    //  Add sessionAttributes\n    buffer      = marshalBuffer;\n    marshalSize = TPMA_SESSION_Marshal(&(s_attributes[sessionIndex]), &buffer, NULL);\n    CryptDigestUpdate(&hmacState.hashState, marshalSize, marshalBuffer);\n    // Complete the HMAC computation\n    CryptHmacEnd2B(&hmacState, &hmac->b);\n\n    return hmac;\n}\n\n//*** CheckSessionHMAC()\n// This function checks the HMAC of in a session. It uses ComputeCommandHMAC()\n// to compute the expected HMAC value and then compares the result with the\n// HMAC in the authorization session. The authorization is successful if they\n// are the same.\n//\n// If the authorizations are not the same, IncrementLockout() is called. It will\n// return TPM_RC_AUTH_FAIL if the failure caused the failureCount to increment.\n// Otherwise, it will return TPM_RC_BAD_AUTH.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_AUTH_FAIL        authorization failure caused failureCount increment\n//      TPM_RC_BAD_AUTH         authorization failure did not cause failureCount\n//                              increment\n//\nstatic TPM_RC CheckSessionHMAC(\n\t\t\t       COMMAND* command,      // IN: primary control structure\n\t\t\t       UINT32   sessionIndex  // IN: index of session to be processed\n\t\t\t       )\n{\n    TPM2B_DIGEST hmac;  // authHMAC for comparing\n    //\n    // Compute authHMAC\n    ComputeCommandHMAC(command, sessionIndex, &hmac);\n\n    // Compare the input HMAC with the authHMAC computed above.\n    if(!MemoryEqual2B(&s_inputAuthValues[sessionIndex].b, &hmac.b))\n\t{\n\t    // If an HMAC session has a failure, invoke the anti-hammering\n\t    // if it applies to the authorized entity or the session.\n\t    // Otherwise, just indicate that the authorization is bad.\n\t    return IncrementLockout(sessionIndex);\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** CheckPolicyAuthSession()\n//  This function is used to validate the authorization in a policy session.\n//  This function performs the following comparisons to see if a policy\n//  authorization is properly provided. The check are:\n//  a) compare policyDigest in session with authPolicy associated with\n//     the entity to be authorized;\n//  b) compare timeout if applicable;\n//  c) compare commandCode if applicable;\n//  d) compare cpHash if applicable; and\n//  e) see if PCR values have changed since computed.\n//\n// If all the above checks succeed, the handle is authorized.\n// The order of these comparisons is not important because any failure will\n// result in the same error code.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_PCR_CHANGED          PCR value is not current\n//      TPM_RC_POLICY_FAIL          policy session fails\n//      TPM_RC_LOCALITY             command locality is not allowed\n//      TPM_RC_POLICY_CC            CC doesn't match\n//      TPM_RC_EXPIRED              policy session has expired\n//      TPM_RC_PP                   PP is required but not asserted\n//      TPM_RC_NV_UNAVAILABLE       NV is not available for write\n//      TPM_RC_NV_RATE              NV is rate limiting\nstatic TPM_RC CheckPolicyAuthSession(\n\t\t\t\t     COMMAND* command,      // IN: primary parsing structure\n\t\t\t\t     UINT32   sessionIndex  // IN: index of session to be processed\n\t\t\t\t     )\n{\n    SESSION*      session;\n    TPM2B_DIGEST  authPolicy;\n    TPMI_ALG_HASH policyAlg;\n    UINT8         locality;\n    //\n    // Initialize pointer to the authorization session.\n    session = SessionGet(s_sessionHandles[sessionIndex]);\n\n    // If the command is TPM2_PolicySecret(), make sure that\n    // either password or authValue is required\n    if(command->code == TPM_CC_PolicySecret\n       && session->attributes.isPasswordNeeded == CLEAR\n       && session->attributes.isAuthValueNeeded == CLEAR)\n\treturn TPM_RC_MODE;\n    // See if the PCR counter for the session is still valid.\n    if(!SessionPCRValueIsCurrent(session))\n\treturn TPM_RC_PCR_CHANGED;\n    // Get authPolicy.\n    policyAlg = EntityGetAuthPolicy(s_associatedHandles[sessionIndex], &authPolicy);\n    // Compare authPolicy.\n    if(!MemoryEqual2B(&session->u2.policyDigest.b, &authPolicy.b))\n\treturn TPM_RC_POLICY_FAIL;\n    // Policy is OK so check if the other factors are correct\n\n    // Compare policy hash algorithm.\n    if(policyAlg != session->authHashAlg)\n\treturn TPM_RC_POLICY_FAIL;\n\n    // Compare timeout.\n    if(session->timeout != 0)\n\t{\n\t    // Cannot compare time if clock stop advancing.  An TPM_RC_NV_UNAVAILABLE\n\t    // or TPM_RC_NV_RATE error may be returned here. This doesn't mean that\n\t    // a new nonce will be created just that, because TPM time can't advance\n\t    // we can't do time-based operations.\n\t    RETURN_IF_NV_IS_NOT_AVAILABLE;\n\n\t    if((session->timeout < g_time) || (session->epoch != g_timeEpoch))\n\t\treturn TPM_RC_EXPIRED;\n\t}\n    // If command code is provided it must match\n    if(session->commandCode != 0)\n\t{\n\t    if(session->commandCode != command->code)\n\t\treturn TPM_RC_POLICY_CC;\n\t}\n    else\n\t{\n\t    // If command requires a DUP or ADMIN authorization, the session must have\n\t    // command code set.\n\t    AUTH_ROLE role = CommandAuthRole(command->index, sessionIndex);\n\t    if(role == AUTH_ADMIN || role == AUTH_DUP)\n\t\treturn TPM_RC_POLICY_FAIL;\n\t}\n    // Check command locality.\n    {\n\tBYTE  sessionLocality[sizeof(TPMA_LOCALITY)];\n\tBYTE* buffer = sessionLocality;\n\n\t// Get existing locality setting in canonical form\n\tsessionLocality[0] = 0;\n\tTPMA_LOCALITY_Marshal(&session->commandLocality, &buffer, NULL);\n\n\t// See if the locality has been set\n\tif(sessionLocality[0] != 0)\n\t    {\n\t\t// If so, get the current locality\n\t\tlocality = _plat__LocalityGet();\n\t\tif(locality < 5)\n\t\t    {\n\t\t\tif(((sessionLocality[0] & (1 << locality)) == 0)\n\t\t\t   || sessionLocality[0] > 31)\n\t\t\t    return TPM_RC_LOCALITY;\n\t\t    }\n\t\telse if(locality > 31)\n\t\t    {\n\t\t\tif(sessionLocality[0] != locality)\n\t\t\t    return TPM_RC_LOCALITY;\n\t\t    }\n\t\telse\n\t\t    {\n\t\t\t// Could throw an assert here but a locality error is just\n\t\t\t// as good. It just means that, whatever the locality is, it isn't\n\t\t\t// the locality requested so...\n\t\t\treturn TPM_RC_LOCALITY;\n\t\t    }\n\t    }\n    }  // end of locality check\n    // Check physical presence.\n    if(session->attributes.isPPRequired == SET && !_plat__PhysicalPresenceAsserted())\n\treturn TPM_RC_PP;\n    // Compare cpHash/nameHash/pHash/templateHash if defined.\n    if(session->u1.cpHash.b.size != 0)\n\t{\n\t    BOOL OK = FALSE;\n\t    if(session->attributes.isCpHashDefined)\n\t\t// Compare cpHash.\n\t\tOK = MemoryEqual2B(&session->u1.cpHash.b,\n\t\t\t\t   &ComputeCpHash(command, session->authHashAlg)->b);\n\t    else if(session->attributes.isNameHashDefined)\n\t\tOK = CompareNameHash(command, session);\n\t    else if(session->attributes.isParametersHashDefined)\n\t\tOK = CompareParametersHash(command, session);\n\t    else if(session->attributes.isTemplateHashDefined)\n\t\tOK = CompareTemplateHash(command, session);\n\t    if(!OK)\n\t\treturn TPM_RCS_POLICY_FAIL;\n\t}\n    if(session->attributes.checkNvWritten)\n\t{\n\t    NV_REF    locator;\n\t    NV_INDEX* nvIndex;\n\t    //\n\t    // If this is not an NV index, the policy makes no sense so fail it.\n\t    if(HandleGetType(s_associatedHandles[sessionIndex]) != TPM_HT_NV_INDEX)\n\t\treturn TPM_RC_POLICY_FAIL;\n\t    // Get the index data\n\t    nvIndex = NvGetIndexInfo(s_associatedHandles[sessionIndex], &locator);\n\n\t    // Make sure that the TPMA_WRITTEN_ATTRIBUTE has the desired state\n\t    if((IS_ATTRIBUTE(nvIndex->publicArea.attributes, TPMA_NV, WRITTEN))\n\t       != (session->attributes.nvWrittenState == SET))\n\t\treturn TPM_RC_POLICY_FAIL;\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** RetrieveSessionData()\n// This function will unmarshal the sessions in the session area of a command. The\n// values are placed in the arrays that are defined at the beginning of this file.\n// The normal unmarshaling errors are possible.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_SUCCSS       unmarshaled without error\n//      TPM_RC_SIZE         the number of bytes unmarshaled is not the same\n//                          as the value for authorizationSize in the command\n//\nstatic TPM_RC RetrieveSessionData(\n\t\t\t\t  COMMAND* command  // IN: main parsing structure for command\n\t\t\t\t  )\n{\n    int          i;\n    TPM_RC       result;\n    SESSION*     session;\n    TPMA_SESSION sessionAttributes;\n    TPM_HT       sessionType;\n    INT32        sessionIndex;\n    TPM_RC       errorIndex;\n    //\n    s_decryptSessionIndex = UNDEFINED_INDEX;\n    s_encryptSessionIndex = UNDEFINED_INDEX;\n    s_auditSessionIndex   = UNDEFINED_INDEX;\n\n    for(sessionIndex = 0; command->authSize > 0; sessionIndex++)\n\t{\n\t    errorIndex = TPM_RC_S + g_rcIndex[sessionIndex];\n\n\t    // If maximum allowed number of sessions has been parsed, return a size\n\t    // error with a session number that is larger than the number of allowed\n\t    // sessions\n\t    if(sessionIndex == MAX_SESSION_NUM)\n\t\treturn TPM_RCS_SIZE + errorIndex;\n\t    // make sure that the associated handle for each session starts out\n\t    // unassigned\n\t    s_associatedHandles[sessionIndex] = TPM_RH_UNASSIGNED;\n\n\t    // First parameter: Session handle.\n\t    result = TPMI_SH_AUTH_SESSION_Unmarshal(&s_sessionHandles[sessionIndex],\n\t\t\t\t\t\t    &command->parameterBuffer,\n\t\t\t\t\t\t    &command->authSize,\n\t\t\t\t\t\t    TRUE);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result + TPM_RC_S + g_rcIndex[sessionIndex];\n\t    // Second parameter: Nonce.\n\t    result = TPM2B_NONCE_Unmarshal(&s_nonceCaller[sessionIndex],\n\t\t\t\t\t   &command->parameterBuffer,\n\t\t\t\t\t   &command->authSize);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result + TPM_RC_S + g_rcIndex[sessionIndex];\n\t    // Third parameter: sessionAttributes.\n\t    result = TPMA_SESSION_Unmarshal(&s_attributes[sessionIndex],\n\t\t\t\t\t    &command->parameterBuffer,\n\t\t\t\t\t    &command->authSize);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result + TPM_RC_S + g_rcIndex[sessionIndex];\n\t    // Fourth parameter: authValue (PW or HMAC).\n\t    result = TPM2B_AUTH_Unmarshal(&s_inputAuthValues[sessionIndex],\n\t\t\t\t\t  &command->parameterBuffer,\n\t\t\t\t\t  &command->authSize);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result + errorIndex;\n\n\t    sessionAttributes = s_attributes[sessionIndex];\n\t    if(s_sessionHandles[sessionIndex] == TPM_RS_PW)\n\t\t{\n\t\t    // A PWAP session needs additional processing.\n\t\t    //     Can't have any attributes set other than continueSession bit\n\t\t    if(IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, encrypt)\n\t\t       || IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, decrypt)\n\t\t       || IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, audit)\n\t\t       || IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, auditExclusive)\n\t\t       || IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, auditReset))\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\t\t    //     The nonce size must be zero.\n\t\t    if(s_nonceCaller[sessionIndex].t.size != 0)\n\t\t\treturn TPM_RCS_NONCE + errorIndex;\n\t\t    continue;\n\t\t}\n\t    // For not password sessions...\n\t    // Find out if the session is loaded.\n\t    if(!SessionIsLoaded(s_sessionHandles[sessionIndex]))\n\t\treturn TPM_RC_REFERENCE_S0 + sessionIndex;\n\t    sessionType = HandleGetType(s_sessionHandles[sessionIndex]);\n\t    session     = SessionGet(s_sessionHandles[sessionIndex]);\n\n\t    // Check if the session is an HMAC/policy session.\n\t    if((session->attributes.isPolicy == SET && sessionType == TPM_HT_HMAC_SESSION)\n\t       || (session->attributes.isPolicy == CLEAR\n\t\t   && sessionType == TPM_HT_POLICY_SESSION))\n\t\treturn TPM_RCS_HANDLE + errorIndex;\n\t    // Check that this handle has not previously been used.\n\t    for(i = 0; i < sessionIndex; i++)\n\t\t{\n\t\t    if(s_sessionHandles[i] == s_sessionHandles[sessionIndex])\n\t\t\treturn TPM_RCS_HANDLE + errorIndex;\n\t\t}\n\t    // If the session is used for parameter encryption or audit as well, set\n\t    // the corresponding Indexes.\n\n\t    // First process decrypt.\n\t    if(IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, decrypt))\n\t\t{\n\t\t    // Check if the commandCode allows command parameter encryption.\n\t\t    if(DecryptSize(command->index) == 0)\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\t\t    // Encrypt attribute can only appear in one session\n\t\t    if(s_decryptSessionIndex != UNDEFINED_INDEX)\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\t\t    // Can't decrypt if the session's symmetric algorithm is TPM_ALG_NULL\n\t\t    if(session->symmetric.algorithm == TPM_ALG_NULL)\n\t\t\treturn TPM_RCS_SYMMETRIC + errorIndex;\n\t\t    // All checks passed, so set the index for the session used to decrypt\n\t\t    // a command parameter.\n\t\t    s_decryptSessionIndex = sessionIndex;\n\t\t}\n\t    // Now process encrypt.\n\t    if(IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, encrypt))\n\t\t{\n\t\t    // Check if the commandCode allows response parameter encryption.\n\t\t    if(EncryptSize(command->index) == 0)\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\t\t    // Encrypt attribute can only appear in one session.\n\t\t    if(s_encryptSessionIndex != UNDEFINED_INDEX)\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\t\t    // Can't encrypt if the session's symmetric algorithm is TPM_ALG_NULL\n\t\t    if(session->symmetric.algorithm == TPM_ALG_NULL)\n\t\t\treturn TPM_RCS_SYMMETRIC + errorIndex;\n\t\t    // All checks passed, so set the index for the session used to encrypt\n\t\t    // a response parameter.\n\t\t    s_encryptSessionIndex = sessionIndex;\n\t\t}\n\t    // At last process audit.\n\t    if(IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, audit))\n\t\t{\n\t\t    // Audit attribute can only appear in one session.\n\t\t    if(s_auditSessionIndex != UNDEFINED_INDEX)\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\t\t    // An audit session can not be policy session.\n\t\t    if(HandleGetType(s_sessionHandles[sessionIndex]) == TPM_HT_POLICY_SESSION)\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\t\t    // If this is a reset of the audit session, or the first use\n\t\t    // of the session as an audit session, it doesn't matter what\n\t\t    // the exclusive state is. The session will become exclusive.\n\t\t    if(!IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, auditReset)\n\t\t       && session->attributes.isAudit == SET)\n\t\t\t{\n\t\t\t    // Not first use or reset. If auditExlusive is SET, then this\n\t\t\t    // session must be the current exclusive session.\n\t\t\t    if(IS_ATTRIBUTE(sessionAttributes, TPMA_SESSION, auditExclusive)\n\t\t\t       && g_exclusiveAuditSession != s_sessionHandles[sessionIndex])\n\t\t\t\treturn TPM_RC_EXCLUSIVE;\n\t\t\t}\n\t\t    s_auditSessionIndex = sessionIndex;\n\t\t}\n\t    // Initialize associated handle as undefined. This will be changed when\n\t    // the handles are processed.\n\t    s_associatedHandles[sessionIndex] = TPM_RH_UNASSIGNED;\n\t}\n    command->sessionNum = sessionIndex;\n    return TPM_RC_SUCCESS;\n}\n\n//*** CheckLockedOut()\n// This function checks to see if the TPM is in lockout. This function should only\n// be called if the entity being checked is subject to DA protection. The TPM\n// is in lockout if the NV is not available and a DA write is pending. Otherwise\n// the TPM is locked out if checking for lockoutAuth ('lockoutAuthCheck' == TRUE)\n// and use of lockoutAuth is disabled, or 'failedTries' >= 'maxTries'\n//  Return Type: TPM_RC\n//      TPM_RC_NV_RATE          NV is rate limiting\n//      TPM_RC_NV_UNAVAILABLE   NV is not available at this time\n//      TPM_RC_LOCKOUT          TPM is in lockout\nstatic TPM_RC CheckLockedOut(\n\t\t\t     BOOL lockoutAuthCheck  // IN: TRUE if checking is for lockoutAuth\n\t\t\t     )\n{\n    // If NV is unavailable, and current cycle state recorded in NV is not\n    // SU_NONE_VALUE, refuse to check any authorization because we would\n    // not be able to handle a DA failure.\n    if(!NV_IS_AVAILABLE && NV_IS_ORDERLY)\n\treturn g_NvStatus;\n    // Check if DA info needs to be updated in NV.\n    if(s_DAPendingOnNV)\n\t{\n\t    // If NV is accessible,\n\t    RETURN_IF_NV_IS_NOT_AVAILABLE;\n\n\t    // ... write the pending DA data and proceed.\n\t    NV_SYNC_PERSISTENT(lockOutAuthEnabled);\n\t    NV_SYNC_PERSISTENT(failedTries);\n\t    s_DAPendingOnNV = FALSE;\n\t}\n    // Lockout is in effect if checking for lockoutAuth and use of lockoutAuth\n    // is disabled...\n    if(lockoutAuthCheck)\n\t{\n\t    if(gp.lockOutAuthEnabled == FALSE)\n\t\treturn TPM_RC_LOCKOUT;\n\t}\n    else\n\t{\n\t    // ... or if the number of failed tries has been maxed out.\n\t    if(gp.failedTries >= gp.maxTries)\n\t\treturn TPM_RC_LOCKOUT;\n#if USE_DA_USED\n\t    // If the daUsed flag is not SET, then no DA validation until the\n\t    // daUsed state is written to NV\n\t    if(!g_daUsed)\n\t\t{\n\t\t    RETURN_IF_NV_IS_NOT_AVAILABLE;\n\t\t    g_daUsed        = TRUE;\n\t\t    gp.orderlyState = SU_DA_USED_VALUE;\n\t\t    NV_SYNC_PERSISTENT(orderlyState);\n\t\t    return TPM_RC_RETRY;\n\t\t}\n#endif\n\t}\n    return TPM_RC_SUCCESS;\n}\n\n//*** CheckAuthSession()\n// This function checks that the authorization session properly authorizes the\n// use of the associated handle.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_LOCKOUT              entity is protected by DA and TPM is in\n//                                  lockout, or TPM is locked out on NV update\n//                                  pending on DA parameters\n//\n//      TPM_RC_PP                   Physical Presence is required but not provided\n//      TPM_RC_AUTH_FAIL            HMAC or PW authorization failed\n//                                  with DA side-effects (can be a policy session)\n//\n//      TPM_RC_BAD_AUTH             HMAC or PW authorization failed without DA\n//                                  side-effects (can be a policy session)\n//\n//      TPM_RC_POLICY_FAIL          if policy session fails\n//      TPM_RC_POLICY_CC            command code of policy was wrong\n//      TPM_RC_EXPIRED              the policy session has expired\n//      TPM_RC_PCR\n//      TPM_RC_AUTH_UNAVAILABLE     authValue or authPolicy unavailable\nstatic TPM_RC CheckAuthSession(\n\t\t\t       COMMAND* command,      // IN: primary parsing structure\n\t\t\t       UINT32   sessionIndex  // IN: index of session to be processed\n\t\t\t       )\n{\n    TPM_RC     result            = TPM_RC_SUCCESS;\n    SESSION*   session           = NULL;\n    TPM_HANDLE sessionHandle     = s_sessionHandles[sessionIndex];\n    TPM_HANDLE associatedHandle  = s_associatedHandles[sessionIndex];\n    TPM_HT     sessionHandleType = HandleGetType(sessionHandle);\n    BOOL       authUsed;\n    //\n    pAssert(sessionHandle != TPM_RH_UNASSIGNED);\n\n    // Take care of physical presence\n    if(associatedHandle == TPM_RH_PLATFORM)\n\t{\n\t    // If the physical presence is required for this command, check for PP\n\t    // assertion. If it isn't asserted, no point going any further.\n\t    if(PhysicalPresenceIsRequired(command->index)\n\t       && !_plat__PhysicalPresenceAsserted())\n\t\treturn TPM_RC_PP;\n\t}\n    if(sessionHandle != TPM_RS_PW)\n\t{\n\t    session = SessionGet(sessionHandle);\n\n\t    // Set includeAuth to indicate if DA checking will be required and if the\n\t    // authValue will be included in any HMAC.\n\t    if(sessionHandleType == TPM_HT_POLICY_SESSION)\n\t\t{\n\t\t    // For a policy session, will check the DA status of the entity if either\n\t\t    // isAuthValueNeeded or isPasswordNeeded is SET.\n\t\t    session->attributes.includeAuth = session->attributes.isAuthValueNeeded\n\t\t\t\t\t\t      || session->attributes.isPasswordNeeded;\n\t\t}\n\t    else\n\t\t{\n\t\t    // For an HMAC session, need to check unless the session\n\t\t    // is bound.\n\t\t    session->attributes.includeAuth =\n\t\t\t!IsSessionBindEntity(s_associatedHandles[sessionIndex], session);\n\t\t}\n\t    authUsed = session->attributes.includeAuth;\n\t}\n    else\n\t// Password session\n\tauthUsed = TRUE;\n    // If the authorization session is going to use an authValue, then make sure\n    // that access to that authValue isn't locked out.\n    if(authUsed)\n\t{\n\t    // See if entity is subject to lockout.\n\t    if(!IsDAExempted(associatedHandle))\n\t\t{\n\t\t    // See if in lockout\n\t\t    result = CheckLockedOut(associatedHandle == TPM_RH_LOCKOUT);\n\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\treturn result;\n\t\t}\n\t}\n    // Policy or HMAC+PW?\n    if(sessionHandleType != TPM_HT_POLICY_SESSION)\n\t{\n\t    // for non-policy session make sure that a policy session is not required\n\t    if(IsPolicySessionRequired(command->index, sessionIndex))\n\t\treturn TPM_RC_AUTH_TYPE;\n\t    // The authValue must be available.\n\t    // Note: The authValue is going to be \"used\" even if it is an EmptyAuth.\n\t    // and the session is bound.\n\t    if(!IsAuthValueAvailable(associatedHandle, command->index, sessionIndex))\n\t\treturn TPM_RC_AUTH_UNAVAILABLE;\n\t}\n    else\n\t{\n\t    // ... see if the entity has a policy, ...\n\t    // Note: IsAuthPolicyAvalable will return FALSE if the sensitive area of the\n\t    // object is not loaded\n\t    if(!IsAuthPolicyAvailable(associatedHandle, command->index, sessionIndex))\n\t\treturn TPM_RC_AUTH_UNAVAILABLE;\n\t    // ... and check the policy session.\n\t    result = CheckPolicyAuthSession(command, sessionIndex);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t}\n    // Check authorization according to the type\n    if((TPM_RS_PW == sessionHandle) || (session->attributes.isPasswordNeeded == SET))\n\tresult = CheckPWAuthSession(sessionIndex);\n    else\n\tresult = CheckSessionHMAC(command, sessionIndex);\n    // Do processing for PIN Indexes are only three possibilities for 'result' at\n    // this point: TPM_RC_SUCCESS, TPM_RC_AUTH_FAIL, and TPM_RC_BAD_AUTH.\n    // For all these cases, we would have to process a PIN index if the\n    // authValue of the index was used for authorization.\n    if((TPM_HT_NV_INDEX == HandleGetType(associatedHandle)) && authUsed)\n\t{\n\t    NV_REF    locator;\n\t    NV_INDEX* nvIndex = NvGetIndexInfo(associatedHandle, &locator);\n\t    NV_PIN    pinData;\n\t    TPMA_NV   nvAttributes;\n\t    //\n\t    pAssert(nvIndex != NULL);\n\t    nvAttributes = nvIndex->publicArea.attributes;\n\t    // If this is a PIN FAIL index and the value has been written\n\t    // then we can update the counter (increment or clear)\n\t    if(IsNvPinFailIndex(nvAttributes)\n\t       && IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITTEN))\n\t\t{\n\t\t    pinData.intVal = NvGetUINT64Data(nvIndex, locator);\n\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\tpinData.pin.pinCount++;\n\t\t    else\n\t\t\tpinData.pin.pinCount = 0;\n\t\t    NvWriteUINT64Data(nvIndex, pinData.intVal);\n\t\t}\n\t    // If this is a PIN PASS Index, increment if we have used the\n\t    // authorization value.\n\t    // NOTE: If the counter has already hit the limit, then we\n\t    // would not get here because the authorization value would not\n\t    // be available and the TPM would have returned before it gets here\n\t    else if(IsNvPinPassIndex(nvAttributes)\n\t\t    && IS_ATTRIBUTE(nvAttributes, TPMA_NV, WRITTEN)\n\t\t    && result == TPM_RC_SUCCESS)\n\t\t{\n\t\t    // If the access is valid, then increment the use counter\n\t\t    pinData.intVal = NvGetUINT64Data(nvIndex, locator);\n\t\t    pinData.pin.pinCount++;\n\t\t    NvWriteUINT64Data(nvIndex, pinData.intVal);\n\t\t}\n\t}\n    return result;\n}\n\n#if CC_GetCommandAuditDigest\n//*** CheckCommandAudit()\n// This function is called before the command is processed if audit is enabled\n// for the command. It will check to see if the audit can be performed and\n// will ensure that the cpHash is available for the audit.\n//  Return Type: TPM_RC\n//      TPM_RC_NV_UNAVAILABLE       NV is not available for write\n//      TPM_RC_NV_RATE              NV is rate limiting\nstatic TPM_RC CheckCommandAudit(COMMAND* command)\n{\n    // If the audit digest is clear and command audit is required, NV must be\n    // available so that TPM2_GetCommandAuditDigest() is able to increment\n    // audit counter. If NV is not available, the function bails out to prevent\n    // the TPM from attempting an operation that would fail anyway.\n    if(gr.commandAuditDigest.t.size == 0\n       || GetCommandCode(command->index) == TPM_CC_GetCommandAuditDigest)\n\t{\n\t    RETURN_IF_NV_IS_NOT_AVAILABLE;\n\t}\n    // Make sure that the cpHash is computed for the algorithm\n    ComputeCpHash(command, gp.auditHashAlg);\n    return TPM_RC_SUCCESS;\n}\n#endif\n\n//*** ParseSessionBuffer()\n// This function is the entry function for command session processing.\n// It iterates sessions in session area and reports if the required authorization\n// has been properly provided. It also processes audit session and passes the\n// information of encryption sessions to parameter encryption module.\n//\n//  Return Type: TPM_RC\n//        various           parsing failure or authorization failure\n//\nTPM_RC\nParseSessionBuffer(COMMAND* command  // IN: the structure that contains\n\t\t   )\n{\n    TPM_RC     result;\n    UINT32     i;\n    INT32      size = 0;\n    TPM2B_AUTH extraKey;\n    UINT32     sessionIndex;\n    TPM_RC     errorIndex;\n    SESSION*   session = NULL;\n    //\n    // Check if a command allows any session in its session area.\n    if(!IsSessionAllowed(command->index))\n\treturn TPM_RC_AUTH_CONTEXT;\n    // Default-initialization.\n    command->sessionNum = 0;\n\n    result              = RetrieveSessionData(command);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n    // There is no command in the TPM spec that has more handles than\n    // MAX_SESSION_NUM.\n    pAssert(command->handleNum <= MAX_SESSION_NUM);\n\n    // Associate the session with an authorization handle.\n    for(i = 0; i < command->handleNum; i++)\n\t{\n\t    if(CommandAuthRole(command->index, i) != AUTH_NONE)\n\t\t{\n\t\t    // If the received session number is less than the number of handles\n\t\t    // that requires authorization, an error should be returned.\n\t\t    // Note: for all the TPM 2.0 commands, handles requiring\n\t\t    // authorization come first in a command input and there are only ever\n\t\t    // two values requiring authorization\n\t\t    if(i > (command->sessionNum - 1))\n\t\t\treturn TPM_RC_AUTH_MISSING;\n\t\t    // Record the handle associated with the authorization session\n\t\t    s_associatedHandles[i] = HierarchyNormalizeHandle(command->handles[i]);\n\t\t}\n\t}\n    // Consistency checks are done first to avoid authorization failure when the\n    // command will not be executed anyway.\n    for(sessionIndex = 0; sessionIndex < command->sessionNum; sessionIndex++)\n\t{\n\t    errorIndex = TPM_RC_S + g_rcIndex[sessionIndex];\n\t    // PW session must be an authorization session\n\t    if(s_sessionHandles[sessionIndex] == TPM_RS_PW)\n\t\t{\n\t\t    if(s_associatedHandles[sessionIndex] == TPM_RH_UNASSIGNED)\n\t\t\treturn TPM_RCS_HANDLE + errorIndex;\n\t\t    // a password session can't be audit, encrypt or decrypt\n\t\t    if(IS_ATTRIBUTE(s_attributes[sessionIndex], TPMA_SESSION, audit)\n\t\t       || IS_ATTRIBUTE(s_attributes[sessionIndex], TPMA_SESSION, encrypt)\n\t\t       || IS_ATTRIBUTE(s_attributes[sessionIndex], TPMA_SESSION, decrypt))\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\t\t    session = NULL;\n\t\t}\n\t    else\n\t\t{\n\t\t    session = SessionGet(s_sessionHandles[sessionIndex]);\n\n\t\t    // A trial session can not appear in session area, because it cannot\n\t\t    // be used for authorization, audit or encrypt/decrypt.\n\t\t    if(session->attributes.isTrialPolicy == SET)\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\n\t\t    // See if the session is bound to a DA protected entity\n\t\t    // NOTE: Since a policy session is never bound, a policy is still\n\t\t    // usable even if the object is DA protected and the TPM is in\n\t\t    // lockout.\n\t\t    if(session->attributes.isDaBound == SET)\n\t\t\t{\n\t\t\t    result = CheckLockedOut(session->attributes.isLockoutBound == SET);\n\t\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\t\treturn result;\n\t\t\t}\n\t\t    // If this session is for auditing, make sure the cpHash is computed.\n\t\t    if(IS_ATTRIBUTE(s_attributes[sessionIndex], TPMA_SESSION, audit))\n\t\t\tComputeCpHash(command, session->authHashAlg);\n\t\t}\n\n\t    // if the session has an associated handle, check the authorization\n\t    if(s_associatedHandles[sessionIndex] != TPM_RH_UNASSIGNED)\n\t\t{\n\t\t    result = CheckAuthSession(command, sessionIndex);\n\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\treturn RcSafeAddToResult(result, errorIndex);\n\t\t}\n\t    else\n\t\t{\n\t\t    // a session that is not for authorization must either be encrypt,\n\t\t    // decrypt, or audit\n\t\t    if(!IS_ATTRIBUTE(s_attributes[sessionIndex], TPMA_SESSION, audit)\n\t\t       && !IS_ATTRIBUTE(s_attributes[sessionIndex], TPMA_SESSION, encrypt)\n\t\t       && !IS_ATTRIBUTE(s_attributes[sessionIndex], TPMA_SESSION, decrypt))\n\t\t\treturn TPM_RCS_ATTRIBUTES + errorIndex;\n\n\t\t    // no authValue included in any of the HMAC computations\n\t\t    pAssert(session != NULL);\n\t\t    session->attributes.includeAuth = CLEAR;\n\n\t\t    // check HMAC for encrypt/decrypt/audit only sessions\n\t\t    result = CheckSessionHMAC(command, sessionIndex);\n\t\t    if(result != TPM_RC_SUCCESS)\n\t\t\treturn RcSafeAddToResult(result, errorIndex);\n\t\t}\n\t}\n#if CC_GetCommandAuditDigest\n    // Check if the command should be audited. Need to do this before any parameter\n    // encryption so that the cpHash for the audit is correct\n    if(CommandAuditIsRequired(command->index))\n\t{\n\t    result = CheckCommandAudit(command);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;  // No session number to reference\n\t}\n#endif\n    // Decrypt the first parameter if applicable. This should be the last operation\n    // in session processing.\n    // If the encrypt session is associated with a handle and the handle's\n    // authValue is available, then authValue is concatenated with sessionKey to\n    // generate encryption key, no matter if the handle is the session bound entity\n    // or not.\n    if(s_decryptSessionIndex != UNDEFINED_INDEX)\n\t{\n\t    // If this is an authorization session, include the authValue in the\n\t    // generation of the decryption key\n\t    if(s_associatedHandles[s_decryptSessionIndex] != TPM_RH_UNASSIGNED)\n\t\t{\n\t\t    EntityGetAuthValue(s_associatedHandles[s_decryptSessionIndex], &extraKey);\n\t\t}\n\t    else\n\t\t{\n\t\t    extraKey.b.size = 0;\n\t\t}\n\t    size   = DecryptSize(command->index);\n\t    result = CryptParameterDecryption(s_sessionHandles[s_decryptSessionIndex],\n\t\t\t\t\t      &s_nonceCaller[s_decryptSessionIndex].b,\n\t\t\t\t\t      command->parameterSize,\n\t\t\t\t\t      (UINT16)size,\n\t\t\t\t\t      &extraKey,\n\t\t\t\t\t      command->parameterBuffer);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn RcSafeAddToResult(result,\n\t\t\t\t\t TPM_RC_S + g_rcIndex[s_decryptSessionIndex]);\n\t}\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** CheckAuthNoSession()\n// Function to process a command with no session associated.\n// The function makes sure all the handles in the command require no authorization.\n//\n//  Return Type: TPM_RC\n//      TPM_RC_AUTH_MISSING         failure - one or more handles require\n//                                  authorization\nTPM_RC\nCheckAuthNoSession(COMMAND* command  // IN: command parsing structure\n\t\t   )\n{\n    UINT32 i;\n#if CC_GetCommandAuditDigest\n    TPM_RC result = TPM_RC_SUCCESS;\n#endif\n    //\n    // Check if the command requires authorization\n    for(i = 0; i < command->handleNum; i++)\n\t{\n\t    if(CommandAuthRole(command->index, i) != AUTH_NONE)\n\t\treturn TPM_RC_AUTH_MISSING;\n\t}\n#if CC_GetCommandAuditDigest\n    // Check if the command should be audited.\n    if(CommandAuditIsRequired(command->index))\n\t{\n\t    result = CheckCommandAudit(command);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t}\n#endif\n    // Initialize number of sessions to be 0\n    command->sessionNum = 0;\n\n    return TPM_RC_SUCCESS;\n}\n\n//** Response Session Processing\n//*** Introduction\n//\n//  The following functions build the session area in a response and handle\n//  the audit sessions (if present).\n//\n\n//*** ComputeRpHash()\n// Function to compute rpHash (Response Parameter Hash). The rpHash is only\n// computed if there is an HMAC authorization session and the return code is\n// TPM_RC_SUCCESS.\nstatic TPM2B_DIGEST* ComputeRpHash(\n\t\t\t\t   COMMAND*   command,  // IN: command structure\n\t\t\t\t   TPM_ALG_ID hashAlg   // IN: hash algorithm to compute rpHash\n\t\t\t\t   )\n{\n    TPM2B_DIGEST* rpHash = GetRpHashPointer(command, hashAlg);\n    HASH_STATE    hashState;\n    //\n    if(rpHash->t.size == 0)\n\t{\n\t    //   rpHash := hash(responseCode || commandCode || parameters)\n\n\t    // Initiate hash creation.\n\t    rpHash->t.size = CryptHashStart(&hashState, hashAlg);\n\n\t    // Add hash constituents.\n\t    CryptDigestUpdateInt(&hashState, sizeof(TPM_RC), TPM_RC_SUCCESS);\n\t    CryptDigestUpdateInt(&hashState, sizeof(TPM_CC), command->code);\n\t    CryptDigestUpdate(\n\t\t\t      &hashState, command->parameterSize, command->parameterBuffer);\n\t    // Complete hash computation.\n\t    CryptHashEnd2B(&hashState, &rpHash->b);\n\t}\n    return rpHash;\n}\n\n//*** InitAuditSession()\n// This function initializes the audit data in an audit session.\nstatic void InitAuditSession(SESSION* session  // session to be initialized\n\t\t\t     )\n{\n    // Mark session as an audit session.\n    session->attributes.isAudit = SET;\n\n    // Audit session can not be bound.\n    session->attributes.isBound = CLEAR;\n\n    // Size of the audit log is the size of session hash algorithm digest.\n    session->u2.auditDigest.t.size = CryptHashGetDigestSize(session->authHashAlg);\n\n    // Set the original digest value to be 0.\n    MemorySet(&session->u2.auditDigest.t.buffer, 0, session->u2.auditDigest.t.size);\n    return;\n}\n\n//*** UpdateAuditDigest\n// Function to update an audit digest\nstatic void UpdateAuditDigest(\n\t\t\t      COMMAND* command, TPMI_ALG_HASH hashAlg, TPM2B_DIGEST* digest)\n{\n    HASH_STATE    hashState;\n    TPM2B_DIGEST* cpHash = GetCpHash(command, hashAlg);\n    TPM2B_DIGEST* rpHash = ComputeRpHash(command, hashAlg);\n    //\n    pAssert(cpHash != NULL);\n\n    // digestNew :=  hash (digestOld || cpHash || rpHash)\n    // Start hash computation.\n    digest->t.size = CryptHashStart(&hashState, hashAlg);\n    // Add old digest.\n    CryptDigestUpdate2B(&hashState, &digest->b);\n    // Add cpHash\n    CryptDigestUpdate2B(&hashState, &cpHash->b);\n    // Add rpHash\n    CryptDigestUpdate2B(&hashState, &rpHash->b);\n    // Finalize the hash.\n    CryptHashEnd2B(&hashState, &digest->b);\n}\n\n//*** Audit()\n//This function updates the audit digest in an audit session.\nstatic void Audit(COMMAND* command,      // IN: primary control structure\n\t\t  SESSION* auditSession  // IN: loaded audit session\n\t\t  )\n{\n    UpdateAuditDigest(\n\t\t      command, auditSession->authHashAlg, &auditSession->u2.auditDigest);\n    return;\n}\n\n#if CC_GetCommandAuditDigest\n//*** CommandAudit()\n// This function updates the command audit digest.\nstatic void CommandAudit(COMMAND* command  // IN:\n\t\t\t )\n{\n    // If the digest.size is one, it indicates the special case of changing\n    // the audit hash algorithm. For this case, no audit is done on exit.\n    // NOTE: When the hash algorithm is changed, g_updateNV is set in order to\n    // force an update to the NV on exit so that the change in digest will\n    // be recorded. So, it is safe to exit here without setting any flags\n    // because the digest change will be written to NV when this code exits.\n    if(gr.commandAuditDigest.t.size == 1)\n\t{\n\t    gr.commandAuditDigest.t.size = 0;\n\t    return;\n\t}\n    // If the digest size is zero, need to start a new digest and increment\n    // the audit counter.\n    if(gr.commandAuditDigest.t.size == 0)\n\t{\n\t    gr.commandAuditDigest.t.size = CryptHashGetDigestSize(gp.auditHashAlg);\n\t    MemorySet(gr.commandAuditDigest.t.buffer, 0, gr.commandAuditDigest.t.size);\n\n\t    // Bump the counter and save its value to NV.\n\t    gp.auditCounter++;\n\t    NV_SYNC_PERSISTENT(auditCounter);\n\t}\n    UpdateAuditDigest(command, gp.auditHashAlg, &gr.commandAuditDigest);\n    return;\n}\n#endif\n\n//*** UpdateAuditSessionStatus()\n// This function updates the internal audit related states of a session. It will:\n//  a) initialize the session as audit session and set it to be exclusive if this\n//     is the first time it is used for audit or audit reset was requested;\n//  b) report exclusive audit session;\n//  c) extend audit log; and\n//  d) clear exclusive audit session if no audit session found in the command.\nstatic void UpdateAuditSessionStatus(\n\t\t\t\t     COMMAND* command  // IN: primary control structure\n\t\t\t\t     )\n{\n    UINT32     i;\n    TPM_HANDLE auditSession = TPM_RH_UNASSIGNED;\n    //\n    // Iterate through sessions\n    for(i = 0; i < command->sessionNum; i++)\n\t{\n\t    SESSION* session;\n\t    //\n\t    // PW session do not have a loaded session and can not be an audit\n\t    // session either.  Skip it.\n\t    if(s_sessionHandles[i] == TPM_RS_PW)\n\t\tcontinue;\n\t    session = SessionGet(s_sessionHandles[i]);\n\n\t    // If a session is used for audit\n\t    if(IS_ATTRIBUTE(s_attributes[i], TPMA_SESSION, audit))\n\t\t{\n\t\t    // An audit session has been found\n\t\t    auditSession = s_sessionHandles[i];\n\n\t\t    // If the session has not been an audit session yet, or\n\t\t    // the auditSetting bits indicate a reset, initialize it and set\n\t\t    // it to be the exclusive session\n\t\t    if(session->attributes.isAudit == CLEAR\n\t\t       || IS_ATTRIBUTE(s_attributes[i], TPMA_SESSION, auditReset))\n\t\t\t{\n\t\t\t    InitAuditSession(session);\n\t\t\t    g_exclusiveAuditSession = auditSession;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // Check if the audit session is the current exclusive audit\n\t\t\t    // session and, if not, clear previous exclusive audit session.\n\t\t\t    if(g_exclusiveAuditSession != auditSession)\n\t\t\t\tg_exclusiveAuditSession = TPM_RH_UNASSIGNED;\n\t\t\t}\n\t\t    // Report audit session exclusivity.\n\t\t    if(g_exclusiveAuditSession == auditSession)\n\t\t\t{\n\t\t\t    SET_ATTRIBUTE(s_attributes[i], TPMA_SESSION, auditExclusive);\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    CLEAR_ATTRIBUTE(s_attributes[i], TPMA_SESSION, auditExclusive);\n\t\t\t}\n\t\t    // Extend audit log.\n\t\t    Audit(command, session);\n\t\t}\n\t}\n    // If no audit session is found in the command, and the command allows\n    // a session then, clear the current exclusive\n    // audit session.\n    if(auditSession == TPM_RH_UNASSIGNED && IsSessionAllowed(command->index))\n\t{\n\t    g_exclusiveAuditSession = TPM_RH_UNASSIGNED;\n\t}\n    return;\n}\n\n//*** ComputeResponseHMAC()\n// Function to compute HMAC for authorization session in a response.\n/*(See part 1 specification)\n// Function: Compute HMAC for response sessions\n//      The sessionAuth value\n//          authHMAC := HMACsHASH((sessionAuth | authValue),\n//                    (pHash | nonceTPM | nonceCaller | sessionAttributes))\n//  Where:\n//      HMACsHASH()     The HMAC algorithm using the hash algorithm specified when\n//                      the session was started.\n//\n//      sessionAuth     A TPMB_MEDIUM computed in a protocol-dependent way, using\n//                      KDFa. In an HMAC or KDF, only sessionAuth.buffer is used.\n//\n//      authValue       A TPM2B_AUTH that is found in the sensitive area of an\n//                      object. In an HMAC or KDF, only authValue.buffer is used\n//                      and all trailing zeros are removed.\n//\n//      pHash           Response parameters (rpHash) using the session hash. When\n//                      using a pHash in an HMAC computation, both the algorithm ID\n//                      and the digest are included.\n//\n//      nonceTPM        A TPM2B_NONCE that is generated by the entity using the\n//                      session. In an HMAC or KDF, only nonceTPM.buffer is used.\n//\n//      nonceCaller     a TPM2B_NONCE that was received the previous time the\n//                      session was used. In an HMAC or KDF, only\n//                      nonceCaller.buffer is used.\n//\n//      sessionAttributes   A TPMA_SESSION that indicates the attributes associated\n//                          with a particular use of the session.\n*/\nstatic void ComputeResponseHMAC(\n\t\t\t\tCOMMAND*      command,       // IN: command structure\n\t\t\t\tUINT32        sessionIndex,  // IN: session index to be processed\n\t\t\t\tSESSION*      session,       // IN: loaded session\n\t\t\t\tTPM2B_DIGEST* hmac           // OUT: authHMAC\n\t\t\t\t)\n{\n    TPM2B_TYPE(KEY, (sizeof(AUTH_VALUE) * 2));\n    TPM2B_KEY     key;  // HMAC key\n    BYTE          marshalBuffer[sizeof(TPMA_SESSION)];\n    BYTE*         buffer;\n    UINT32        marshalSize;\n    HMAC_STATE    hmacState;\n    TPM2B_DIGEST* rpHash = ComputeRpHash(command, session->authHashAlg);\n    //\n    // Generate HMAC key\n    MemoryCopy2B(&key.b, &session->sessionKey.b, sizeof(key.t.buffer));\n\n    // Add the object authValue if required\n    if(session->attributes.includeAuth == SET)\n\t{\n\t    // Note: includeAuth may be SET for a policy that is used in\n\t    // UndefineSpaceSpecial(). At this point, the Index has been deleted\n\t    // so the includeAuth will have no meaning. However, the\n\t    // s_associatedHandles[] value for the session is now set to TPM_RH_NULL so\n\t    // this will return the authValue associated with TPM_RH_NULL and that is\n\t    // and empty buffer.\n\t    TPM2B_AUTH authValue;\n\t    //\n\t    // Get the authValue with trailing zeros removed\n\t    EntityGetAuthValue(s_associatedHandles[sessionIndex], &authValue);\n\n\t    // Add it to the key\n\t    MemoryConcat2B(&key.b, &authValue.b, sizeof(key.t.buffer));\n\t}\n\n    // if the HMAC key size is 0, the response HMAC is computed according to the\n    // input HMAC\n    if(key.t.size == 0 && s_inputAuthValues[sessionIndex].t.size == 0)\n\t{\n\t    hmac->t.size = 0;\n\t    return;\n\t}\n    // Start HMAC computation.\n    hmac->t.size = CryptHmacStart2B(&hmacState, session->authHashAlg, &key.b);\n\n    // Add hash components.\n    CryptDigestUpdate2B(&hmacState.hashState, &rpHash->b);\n    CryptDigestUpdate2B(&hmacState.hashState, &session->nonceTPM.b);\n    CryptDigestUpdate2B(&hmacState.hashState, &s_nonceCaller[sessionIndex].b);\n\n    // Add session attributes.\n    buffer      = marshalBuffer;\n    marshalSize = TPMA_SESSION_Marshal(&s_attributes[sessionIndex], &buffer, NULL);\n    CryptDigestUpdate(&hmacState.hashState, marshalSize, marshalBuffer);\n\n    // Finalize HMAC.\n    CryptHmacEnd2B(&hmacState, &hmac->b);\n\n    return;\n}\n\n//*** UpdateInternalSession()\n// This function updates internal sessions by:\n// a) restarting session time; and\n// b) clearing a policy session since nonce is rolling.\nstatic void UpdateInternalSession(SESSION* session,  // IN: the session structure\n\t\t\t\t  UINT32   i         // IN: session number\n\t\t\t\t  )\n{\n    // If nonce is rolling in a policy session, the policy related data\n    // will be re-initialized.\n    if(HandleGetType(s_sessionHandles[i]) == TPM_HT_POLICY_SESSION\n       && IS_ATTRIBUTE(s_attributes[i], TPMA_SESSION, continueSession))\n\t{\n\t    // When the nonce rolls it starts a new timing interval for the\n\t    // policy session.\n\t    SessionResetPolicyData(session);\n\t    SessionSetStartTime(session);\n\t}\n    return;\n}\n\n//*** BuildSingleResponseAuth()\n//   Function to compute response HMAC value for a policy or HMAC session.\nstatic TPM2B_NONCE* BuildSingleResponseAuth(\n\t\t\t\t\t    COMMAND*    command,       // IN: command structure\n\t\t\t\t\t    UINT32      sessionIndex,  // IN: session index to be processed\n\t\t\t\t\t    TPM2B_AUTH* auth           // OUT: authHMAC\n\t\t\t\t\t    )\n{\n    // Fill in policy/HMAC based session response.\n    SESSION* session = SessionGet(s_sessionHandles[sessionIndex]);\n    //\n    // If the session is a policy session with isPasswordNeeded SET, the\n    // authorization field is empty.\n    if(HandleGetType(s_sessionHandles[sessionIndex]) == TPM_HT_POLICY_SESSION\n       && session->attributes.isPasswordNeeded == SET)\n\tauth->t.size = 0;\n    else\n\t// Compute response HMAC.\n\tComputeResponseHMAC(command, sessionIndex, session, auth);\n\n    UpdateInternalSession(session, sessionIndex);\n    return &session->nonceTPM;\n}\n\n//*** UpdateAllNonceTPM()\n// Updates TPM nonce for all sessions in command.\nstatic void UpdateAllNonceTPM(COMMAND* command  // IN: controlling structure\n\t\t\t      )\n{\n    UINT32   i;\n    SESSION* session;\n    //\n    for(i = 0; i < command->sessionNum; i++)\n\t{\n\t    // If not a PW session, compute the new nonceTPM.\n\t    if(s_sessionHandles[i] != TPM_RS_PW)\n\t\t{\n\t\t    session = SessionGet(s_sessionHandles[i]);\n\t\t    // Update nonceTPM in both internal session and response.\n\t\t    CryptRandomGenerate(session->nonceTPM.t.size, session->nonceTPM.t.buffer);\n\t\t}\n\t}\n    return;\n}\n\n//*** BuildResponseSession()\n// Function to build Session buffer in a response. The authorization data is added\n// to the end of command->responseBuffer. The size of the authorization area is\n// accumulated in command->authSize.\n// When this is called, command->responseBuffer is pointing at the next location\n// in the response buffer to be filled. This is where the authorization sessions\n// will go, if any. command->parameterSize is the number of bytes that have been\n// marshaled as parameters in the output buffer.\nTPM_RC\nBuildResponseSession(COMMAND* command  // IN: structure that has relevant command\n\t\t     //     information\n\t\t     )\n{\n    TPM_RC result = TPM_RC_SUCCESS;\n\n    pAssert(command->authSize == 0);\n\n    // Reset the parameter buffer to point to the start of the parameters so that\n    // there is a starting point for any rpHash that might be generated and so there\n    // is a place where parameter encryption would start\n    command->parameterBuffer = command->responseBuffer - command->parameterSize;\n\n    // Session nonces should be updated before parameter encryption\n    if(command->tag == TPM_ST_SESSIONS)\n\t{\n\t    UpdateAllNonceTPM(command);\n\n\t    // Encrypt first parameter if applicable. Parameter encryption should\n\t    // happen after nonce update and before any rpHash is computed.\n\t    // If the encrypt session is associated with a handle, the authValue of\n\t    // this handle will be concatenated with sessionKey to generate\n\t    // encryption key, no matter if the handle is the session bound entity\n\t    // or not. The authValue is added to sessionKey only when the authValue\n\t    // is available.\n\t    if(s_encryptSessionIndex != UNDEFINED_INDEX)\n\t\t{\n\t\t    UINT32     size;\n\t\t    TPM2B_AUTH extraKey;\n\t\t    //\n\t\t    extraKey.b.size = 0;\n\t\t    // If this is an authorization session, include the authValue in the\n\t\t    // generation of the encryption key\n\t\t    if(s_associatedHandles[s_encryptSessionIndex] != TPM_RH_UNASSIGNED)\n\t\t\t{\n\t\t\t    EntityGetAuthValue(s_associatedHandles[s_encryptSessionIndex],\n\t\t\t\t\t       &extraKey);\n\t\t\t}\n\t\t    size = EncryptSize(command->index);\n\t\t    // This function operates on internally-generated data that is\n\t\t    // expected to be well-formed for parameter encryption.\n\t\t    // In the event that there is a bug elsewhere in the code and the\n\t\t    // input data is not well-formed, CryptParameterEncryption will\n\t\t    // put the TPM into failure mode instead of allowing the out-of-\n\t\t    // band write.\n\t\t    CryptParameterEncryption(s_sessionHandles[s_encryptSessionIndex],\n\t\t\t\t\t     &s_nonceCaller[s_encryptSessionIndex].b,\n\t\t\t\t\t     command->parameterSize,\n\t\t\t\t\t     (UINT16)size,\n\t\t\t\t\t     &extraKey,\n\t\t\t\t\t     command->parameterBuffer);\n\t\t    if(g_inFailureMode)\n\t\t\t{\n\t\t\t    result = TPM_RC_FAILURE;\n\t\t\t    goto Cleanup;\n\t\t\t}\n\t\t}\n\t}\n    // Audit sessions should be processed regardless of the tag because\n    // a command with no session may cause a change of the exclusivity state.\n    UpdateAuditSessionStatus(command);\n#if CC_GetCommandAuditDigest\n    // Command Audit\n    if(CommandAuditIsRequired(command->index))\n\tCommandAudit(command);\n#endif\n    // Process command with sessions.\n    if(command->tag == TPM_ST_SESSIONS)\n\t{\n\t    UINT32 i;\n\t    //\n\t    pAssert(command->sessionNum > 0);\n\n\t    // Iterate over each session in the command session area, and create\n\t    // corresponding sessions for response.\n\t    for(i = 0; i < command->sessionNum; i++)\n\t\t{\n\t\t    TPM2B_NONCE* nonceTPM;\n\t\t    TPM2B_DIGEST responseAuth;\n\t\t    // Make sure that continueSession is SET on any Password session.\n\t\t    // This makes it marginally easier for the management software\n\t\t    // to keep track of the closed sessions.\n\t\t    if(s_sessionHandles[i] == TPM_RS_PW)\n\t\t\t{\n\t\t\t    SET_ATTRIBUTE(s_attributes[i], TPMA_SESSION, continueSession);\n\t\t\t    responseAuth.t.size = 0;\n\t\t\t    nonceTPM            = (TPM2B_NONCE*)&responseAuth;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    // Compute the response HMAC and get a pointer to the nonce used.\n\t\t\t    // This function will also update the values if needed. Note, the\n\t\t\t    nonceTPM = BuildSingleResponseAuth(command, i, &responseAuth);\n\t\t\t}\n\t\t    command->authSize +=\n\t\t\tTPM2B_NONCE_Marshal(nonceTPM, &command->responseBuffer, NULL);\n\t\t    command->authSize += TPMA_SESSION_Marshal(\n\t\t\t\t\t\t\t      &s_attributes[i], &command->responseBuffer, NULL);\n\t\t    command->authSize +=\n\t\t\tTPM2B_DIGEST_Marshal(&responseAuth, &command->responseBuffer, NULL);\n\t\t    if(!IS_ATTRIBUTE(s_attributes[i], TPMA_SESSION, continueSession))\n\t\t\tSessionFlush(s_sessionHandles[i]);\n\t\t}\n\t}\n\n Cleanup:\n    return result;\n}\n\n//*** SessionRemoveAssociationToHandle()\n// This function deals with the case where an entity associated with an authorization\n// is deleted during command processing. The primary use of this is to support\n// UndefineSpaceSpecial().\nvoid SessionRemoveAssociationToHandle(TPM_HANDLE handle)\n{\n    UINT32 i;\n    //\n    for(i = 0; i < MAX_SESSION_NUM; i++)\n\t{\n\t    if(s_associatedHandles[i] == HierarchyNormalizeHandle(handle))\n\t\t{\n\t\t    s_associatedHandles[i] = TPM_RH_NULL;\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/SigningCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tSigning and Signature Verification\t   \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"VerifySignature_fp.h\"\n\nextern int verbose;\n\n#include \"Tpm.h\"\n#include \"VerifySignature_fp.h\"\n\n#if CC_VerifySignature  // Conditional expansion of this file\n\n/*(See part 3 specification)\n// This command uses loaded key to validate an asymmetric signature on a message\n// with the message digest passed to the TPM.\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_ATTRIBUTES         'keyHandle' does not reference a signing key\n//      TPM_RC_SIGNATURE          signature is not genuine\n//      TPM_RC_SCHEME             CryptValidateSignature()\n//      TPM_RC_HANDLE             the input handle is references an HMAC key but\n//                                the private portion is not loaded\nTPM_RC\nTPM2_VerifySignature(VerifySignature_In*  in,  // IN: input parameter list\n\t\t     VerifySignature_Out* out  // OUT: output parameter list\n\t\t     )\n{\n    TPM_RC            result;\n    OBJECT*           signObject = HandleToObject(in->keyHandle);\n    TPMI_RH_HIERARCHY hierarchy;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_VerifySignature: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n\n    // Input Validation\n    // The object to validate the signature must be a signing key.\n    if(!IS_ATTRIBUTE(signObject->publicArea.objectAttributes, TPMA_OBJECT, sign))\n\treturn TPM_RCS_ATTRIBUTES + RC_VerifySignature_keyHandle;\n\n    // Validate Signature.  TPM_RC_SCHEME, TPM_RC_HANDLE or TPM_RC_SIGNATURE\n    // error may be returned by CryptCVerifySignatrue()\n    result = CryptValidateSignature(in->keyHandle, &in->digest, &in->signature);\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, RC_VerifySignature_signature);\n\n    // Command Output\n\n    hierarchy = GetHierarchy(in->keyHandle);\n    if(hierarchy == TPM_RH_NULL || signObject->publicArea.nameAlg == TPM_ALG_NULL)\n\t{\n\t    // produce empty ticket if hierarchy is TPM_RH_NULL or nameAlg is\n\t    // TPM_ALG_NULL\n\t    out->validation.tag           = TPM_ST_VERIFIED;\n\t    out->validation.hierarchy     = TPM_RH_NULL;\n\t    out->validation.digest.t.size = 0;\n\t}\n    else\n\t{\n\t    // Compute ticket\n\t    result = TicketComputeVerified(\n\t\t\t\t\t   hierarchy, &in->digest, &signObject->name, &out->validation);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\t}\n\n    return TPM_RC_SUCCESS;\n}\n\n#endif  // CC_VerifySignature\n\n#include \"Tpm.h\"\n#include \"Sign_fp.h\"\n\n#if CC_Sign  // Conditional expansion of this file\n\n#  include \"Attest_spt_fp.h\"\n\n/*(See part 3 specification)\n// sign an externally provided hash using an asymmetric signing key\n*/\n//  Return Type: TPM_RC\n//      TPM_RC_BINDING          The public and private portions of the key are not\n//                              properly bound.\n//      TPM_RC_KEY              'signHandle' does not reference a signing key;\n//      TPM_RC_SCHEME           the scheme is not compatible with sign key type,\n//                              or input scheme is not compatible with default\n//                              scheme, or the chosen scheme is not a valid\n//                              sign scheme\n//      TPM_RC_TICKET           'validation' is not a valid ticket\n//      TPM_RC_VALUE            the value to sign is larger than allowed for the\n//                              type of 'keyHandle'\n\nTPM_RC\nTPM2_Sign(Sign_In*  in,  // IN: input parameter list\n\t  Sign_Out* out  // OUT: output parameter list\n\t  )\n{\n    TPM_RC            result;\n    TPMT_TK_HASHCHECK ticket;\n    OBJECT*           signObject = HandleToObject(in->keyHandle);\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Sign: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    //\n    // Input Validation\n    if(!IsSigningObject(signObject))\n\treturn TPM_RCS_KEY + RC_Sign_keyHandle;\n\n    // A key that will be used for x.509 signatures can't be used in TPM2_Sign().\n    if(IS_ATTRIBUTE(signObject->publicArea.objectAttributes, TPMA_OBJECT, x509sign))\n\treturn TPM_RCS_ATTRIBUTES + RC_Sign_keyHandle;\n\n    // pick a scheme for sign.  If the input sign scheme is not compatible with\n    // the default scheme, return an error.\n    if(!CryptSelectSignScheme(signObject, &in->inScheme))\n\treturn TPM_RCS_SCHEME + RC_Sign_inScheme;\n\n    // If validation is provided, or the key is restricted, check the ticket\n    if(in->validation.digest.t.size != 0\n       || IS_ATTRIBUTE(\n\t\t       signObject->publicArea.objectAttributes, TPMA_OBJECT, restricted))\n\t{\n\t    // Compute and compare ticket\n\t    result = TicketComputeHashCheck(in->validation.hierarchy,\n\t\t\t\t\t    in->inScheme.details.any.hashAlg,\n\t\t\t\t\t    &in->digest,\n\t\t\t\t\t    &ticket);\n\t    if(result != TPM_RC_SUCCESS)\n\t\treturn result;\n\n\t    if(!MemoryEqual2B(&in->validation.digest.b, &ticket.digest.b))\n\t\treturn TPM_RCS_TICKET + RC_Sign_validation;\n\t}\n    else\n\t// If we don't have a ticket, at least verify that the provided 'digest'\n\t// is the size of the scheme hashAlg digest.\n\t// NOTE: this does not guarantee that the 'digest' is actually produced using\n\t// the indicated hash algorithm, but at least it might be.\n\t{\n\t    if(in->digest.t.size\n\t       != CryptHashGetDigestSize(in->inScheme.details.any.hashAlg))\n\t\treturn TPM_RCS_SIZE + RC_Sign_digest;\n\t}\n\n    // Command Output\n    // Sign the hash. A TPM_RC_VALUE or TPM_RC_SCHEME\n    // error may be returned at this point\n    result = CryptSign(signObject, &in->inScheme, &in->digest, &out->signature);\n\n    return result;\n}\n\n#endif  // CC_Sign\n"
  },
  {
    "path": "ftpm-opensbi/src/StartupCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t \tStartup Commands   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\nextern int verbose;\n\n#include \"Tpm.h\"\n// TODO_RENAME_INC_FOLDER:platform_interface refers to the TPM_CoreLib platform interface\n#include \"_TPM_Init_fp.h\"\n\n// This function is used to process a _TPM_Init indication.\nLIB_EXPORT void _TPM_Init(void)\n{\n    g_powerWasLost = g_powerWasLost | _plat__WasPowerLost();\n\n#if SIMULATION && DEBUG\n    // If power was lost and this was a simulation, put canary in RAM used by NV\n    // so that uninitialized memory can be detected more easily\n    if(g_powerWasLost)\n\t{\n\t    memset(&gc, 0xbb, sizeof(gc));\n\t    memset(&gr, 0xbb, sizeof(gr));\n\t    memset(&gp, 0xbb, sizeof(gp));\n\t    memset(&go, 0xbb, sizeof(go));\n\t}\n#endif\n\n#if ALLOW_FORCE_FAILURE_MODE\n    // Clear the flag that forces failure on self-test\n    g_forceFailureMode = FALSE;\n#endif\n\n    // Disable the tick processing\n#if ACT_SUPPORT\n    _plat__ACT_EnableTicks(FALSE);\n#endif\n\n    // Set initialization state\n    TPMInit();\n\n    // Set g_DRTMHandle as unassigned\n    g_DRTMHandle = TPM_RH_UNASSIGNED;\n\n    // No H-CRTM, yet.\n    g_DrtmPreStartup = FALSE;\n\n    // Initialize the NvEnvironment.\n    g_nvOk = NvPowerOn();\n\n    // Initialize cryptographic functions\n    g_inFailureMode = (g_nvOk == FALSE) || (CryptInit() == FALSE);\n    if(!g_inFailureMode)\n\t{\n\t    // Load the persistent data\n\t    NvReadPersistent();\n\n\t    // Load the orderly data (clock and DRBG state).\n\t    // If this is not done here, things break\n\t    NvRead(&go, NV_ORDERLY_DATA, sizeof(go));\n\n\t    // Start clock. Need to do this after NV has been restored.\n\t    TimePowerOn();\n\t}\n    return;\n}\n\n#include \"Tpm.h\"\n#include \"Startup_fp.h\"\n#if CC_Startup\t // Conditional expansion of this file\nTPM_RC\nTPM2_Startup(\n\t     Startup_In      *in             // IN: input parameter list\n\t     )\n{\n    STARTUP_TYPE         startup;\n    BYTE                 locality = _plat__LocalityGet();\n    BOOL                 OK = TRUE;    // The command needs NV update.\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Startup:\\n\");\n\t// fclose(f);\n  //   }\n    // Get the flags for the current startup locality and the H-CRTM.\n    // Rather than generalizing the locality setting, this code takes advantage\n    // of the fact that the PC Client specification only allows Startup()\n    // from locality 0 and 3. To generalize this probably would require a\n    // redo of the NV space and since this is a feature that is hardly ever used\n    // outside of the PC Client, this code just support the PC Client needs.\n    // Input Validation\n    // Check that the locality is a supported value\n    if(locality != 0 && locality != 3)\n\treturn TPM_RC_LOCALITY;\n    // If there was a H-CRTM, then treat the locality as being 3\n    // regardless of what the Startup() was. This is done to preserve the\n    // H-CRTM PCR so that they don't get overwritten with the normal\n    // PCR startup initialization. This basically means that g_StartupLocality3\n    // and g_DrtmPreStartup can't both be SET at the same time.\n    if(g_DrtmPreStartup)\n\tlocality = 0;\n    g_StartupLocality3 = (locality == 3);\n#if USE_DA_USED\n    // If there was no orderly shutdown, then there might have been a write to\n    // failedTries that didn't get recorded but only if g_daUsed was SET in the\n    // shutdown state\n    g_daUsed = (gp.orderlyState == SU_DA_USED_VALUE);\n    if(g_daUsed)\n\tgp.orderlyState = SU_NONE_VALUE;\n#endif\n    g_prevOrderlyState = gp.orderlyState;\n    // If there was a proper shutdown, then the startup modifiers are in the\n    // orderlyState. Turn them off in the copy.\n    if(IS_ORDERLY(g_prevOrderlyState))\n\tg_prevOrderlyState &=  ~(PRE_STARTUP_FLAG | STARTUP_LOCALITY_3);\n    // If this is a Resume,\n    if(in->startupType == TPM_SU_STATE)\n\t{\n\t    // then there must have been a prior TPM2_ShutdownState(STATE)\n\t    if(g_prevOrderlyState != TPM_SU_STATE)\n\t\treturn TPM_RCS_VALUE + RC_Startup_startupType;\n\t    // and the part of NV used for state save must have been recovered\n\t    // correctly.\n\t    // NOTE: if this fails, then the caller will need to do Startup(CLEAR). The\n\t    // code for Startup(Clear) cannot fail if the NV can't be read correctly\n\t    // because that would prevent the TPM from ever getting unstuck.\n\t    if(g_nvOk == FALSE)\n\t\treturn TPM_RC_NV_UNINITIALIZED;\n\t    // For Resume, the H-CRTM has to be the same as the previous boot\n\t    if(g_DrtmPreStartup != ((gp.orderlyState & PRE_STARTUP_FLAG) != 0))\n\t\treturn TPM_RCS_VALUE + RC_Startup_startupType;\n\t    if(g_StartupLocality3 != ((gp.orderlyState & STARTUP_LOCALITY_3) != 0))\n\t\treturn TPM_RC_LOCALITY;\n\t}\n    // Clean up the gp state\n    gp.orderlyState = g_prevOrderlyState;\n\n    // Internal Date Update\n    if((gp.orderlyState == TPM_SU_STATE) && (g_nvOk == TRUE))\n\t{\n\t    // Always read the data that is only cleared on a Reset because this is not\n\t    // a reset\n\t    NvRead(&gr, NV_STATE_RESET_DATA, sizeof(gr));\n\t    if(in->startupType == TPM_SU_STATE)\n\t        {\n\t            // If this is a startup STATE (a Resume) need to read the data\n\t            // that is cleared on a startup CLEAR because this is not a Reset\n\t            // or Restart.\n\t            NvRead(&gc, NV_STATE_CLEAR_DATA, sizeof(gc));\n\t            startup = SU_RESUME;\n\t        }\n\t    else\n\t\tstartup = SU_RESTART;\n\t}\n    else\n\t// Will do a TPM reset if Shutdown(CLEAR) and Startup(CLEAR) or no shutdown\n\t// or there was a failure reading the NV data.\n\tstartup = SU_RESET;\n    // Startup for cryptographic library. Don't do this until after the orderly\n    // state has been read in from NV.\n    OK = OK && CryptStartup(startup);\n    // When the cryptographic library has been started, indicate that a TPM2_Startup\n    // command has been received.\n    OK = OK && TPMRegisterStartup();\n\n#  if VENDOR_PERMANENT_AUTH_ENABLED == YES\n    // Read the platform unique value that is used as VENDOR_PERMANENT_AUTH_HANDLE\n    // authorization value\n    g_platformUniqueAuth.t.size = (UINT16)_plat__GetUniqueAuth\n\t\t\t\t  ((g_platformUniqueAuth.t.buffer), g_platformUniqueAuth.t.buffer);\n#  endif\n\n    // Start up subsystems\n    // Start set the safe flag\n    OK = OK && TimeStartup(startup);\n    // Start dictionary attack subsystem\n    OK = OK && DAStartup(startup);\n    // Enable hierarchies\n    OK = OK && HierarchyStartup(startup);\n    // Restore/Initialize PCR\n    OK = OK && PCRStartup(startup, locality);\n    // Restore/Initialize command audit information\n    OK = OK && CommandAuditStartup(startup);\n    // Restore the ACT\n    // OK = OK && ActStartup(startup);\n    //// The following code was moved from Time.c where it made no sense\n    if (OK)\n\t{\n\t    switch (startup)\n\t\t{\n\t\t  case SU_RESUME:\n\t\t    // Resume sequence\n\t\t    gr.restartCount++;\n\t\t    break;\n\t\t  case SU_RESTART:\n\t\t    // Hibernate sequence\n\t\t    gr.clearCount++;\n\t\t    gr.restartCount++;\n\t\t    break;\n\t\t  default:\n\t\t    // Reset object context ID to 0\n\t\t    gr.objectContextID = 0;\n\t\t    // Reset clearCount to 0\n\t\t    gr.clearCount = 0;\n\t\t    // Reset sequence\n\t\t    // Increase resetCount\n\t\t    gp.resetCount++;\n\t\t    // Write resetCount to NV\n\t\t    NV_SYNC_PERSISTENT(resetCount);\n\t\t    gp.totalResetCount++;\n\t\t    // We do not expect the total reset counter overflow during the life\n\t\t    // time of TPM.  if it ever happens, TPM will be put to failure mode\n\t\t    // and there is no way to recover it.\n\t\t    // The reason that there is no recovery is that we don't increment\n\t\t    // the NV totalResetCount when incrementing would make it 0. When the\n\t\t    // TPM starts up again, the old value of totalResetCount will be read\n\t\t    // and we will get right back to here with the increment failing.\n\t\t    if(gp.totalResetCount == 0)\n\t\t\tFAIL(FATAL_ERROR_INTERNAL);\n\t\t    // Write total reset counter to NV\n\t\t    NV_SYNC_PERSISTENT(totalResetCount);\n\t\t    // Reset restartCount\n\t\t    gr.restartCount = 0;\n\t\t    break;\n\t\t}\n\t}\n    // Initialize session table\n    OK = OK && SessionStartup(startup);\n    // Initialize object table\n    OK = OK && ObjectStartup();\n    // Initialize index/evict data.  This function clears read/write locks\n    // in NV index\n    OK = OK && NvEntityStartup(startup);\n    // Initialize the orderly shut down flag for this cycle to SU_NONE_VALUE.\n    gp.orderlyState = SU_NONE_VALUE;\n    OK = OK && NV_SYNC_PERSISTENT(orderlyState);\n    // This can be reset after the first completion of a TPM2_Startup() after\n    // a power loss. It can probably be reset earlier but this is an OK place.\n    if (OK)\n\tg_powerWasLost = FALSE;\n    return (OK) ? TPM_RC_SUCCESS : TPM_RC_FAILURE;\n}\n#endif // CC_Startup\n#include \"Tpm.h\"\n#include \"Shutdown_fp.h\"\n#if CC_Shutdown  // Conditional expansion of this file\nTPM_RC\nTPM2_Shutdown(\n\t      Shutdown_In     *in             // IN: input parameter list\n\t      )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Shutdown:\\n\");\n\t// fclose(f);\n  //   }\n    // The command needs NV update.  Check if NV is available.\n    // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at\n    // this point\n    RETURN_IF_NV_IS_NOT_AVAILABLE;\n    // Input Validation\n    // If PCR bank has been reconfigured, a CLEAR state save is required\n    if(g_pcrReConfig && in->shutdownType == TPM_SU_STATE)\n\treturn TPM_RCS_TYPE + RC_Shutdown_shutdownType;\n    // Internal Data Update\n    gp.orderlyState = in->shutdownType;\n#if USE_DA_USED\n    // CLEAR g_daUsed so that any future DA-protected access will cause the\n    // shutdown to become non-orderly. It is not sufficient to invalidate the\n    // shutdown state after a DA failure because an attacker can inhibit access\n    // to NV and use the fact that an update of failedTries was attempted as an\n    // indication of an authorization failure. By making sure that the orderly state\n    // is CLEAR before any DA attempt, this prevents the possibility of this 'attack.'\n    g_daUsed = FALSE;\n#endif\n    // PCR private date state save\n    PCRStateSave(in->shutdownType);\n    // Save the ACT state\n    // ActShutdown(in->shutdownType);\n    // Save RAM backed NV index data\n    NvUpdateIndexOrderlyData();\n#if ACCUMULATE_SELF_HEAL_TIMER\n    // Save the current time value\n    go.time = g_time;\n#endif\n    // Save all orderly data\n    NvWrite(NV_ORDERLY_DATA, sizeof(ORDERLY_DATA), &go);\n    if(in->shutdownType == TPM_SU_STATE)\n\t{\n\t    // Save STATE_RESET and STATE_CLEAR data\n\t    NvWrite(NV_STATE_CLEAR_DATA, sizeof(STATE_CLEAR_DATA), &gc);\n\t    NvWrite(NV_STATE_RESET_DATA, sizeof(STATE_RESET_DATA), &gr);\n\t    // Save the startup flags for resume\n\t    if(g_DrtmPreStartup)\n\t\tgp.orderlyState = TPM_SU_STATE | PRE_STARTUP_FLAG;\n\t    else if(g_StartupLocality3)\n\t\tgp.orderlyState = TPM_SU_STATE | STARTUP_LOCALITY_3;\n\t}\n    // only two shutdown options\n    else if(in->shutdownType != TPM_SU_CLEAR)\n\t{\n\t    return TPM_RCS_VALUE + RC_Shutdown_shutdownType;\n\t}\n    NV_SYNC_PERSISTENT(orderlyState);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_Shutdown\n"
  },
  {
    "path": "ftpm-opensbi/src/SymmetricCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \tSymmetric Commands\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: SymmetricCommands.c 1658 2021-01-22 23:14:01Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"EncryptDecrypt_fp.h\"\n#if CC_EncryptDecrypt2\n#include  \"EncryptDecrypt_spt_fp.h\"\n#endif\n\nextern int verbose;\n\n#if CC_EncryptDecrypt  // Conditional expansion of this file\nTPM_RC\nTPM2_EncryptDecrypt(\n\t\t    EncryptDecrypt_In   *in,            // IN: input parameter list\n\t\t    EncryptDecrypt_Out  *out            // OUT: output parameter list\n\t\t    )\n{\n#if CC_EncryptDecrypt2\n    return EncryptDecryptShared(in->keyHandle, in->decrypt, in->mode,\n\t\t\t\t&in->ivIn, &in->inData, out);\n#else\n    OBJECT              *symKey;\n    UINT16               keySize;\n    UINT16               blockSize;\n    BYTE                *key;\n    TPM_ALG_ID           alg;\n    TPM_ALG_ID           mode;\n    TPM_RC               result;\n    BOOL                 OK;\n    TPMA_OBJECT          attributes;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_EncryptDecrypt: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    symKey = HandleToObject(in->keyHandle);\n    mode = symKey->publicArea.parameters.symDetail.sym.mode.sym;\n    attributes = symKey->publicArea.objectAttributes;\n    // The input key should be a symmetric key\n    if(symKey->publicArea.type != TPM_ALG_SYMCIPHER)\n\treturn TPM_RCS_KEY + RC_EncryptDecrypt_keyHandle;\n    // The key must be unrestricted and allow the selected operation\n    OK = IS_ATTRIBUTE(attributes, TPMA_OBJECT, restricted)\n     if(YES == in->decrypt)\n\t OK = OK && IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt);\n     else\n\t OK = OK && IS_ATTRIBUTE(attributes, TPMA_OBJECT, sign);\n    if(!OK)\n\treturn TPM_RCS_ATTRIBUTES + RC_EncryptDecrypt_keyHandle;\n    // If the key mode is not TPM_ALG_NULL...\n    // or TPM_ALG_NULL\n    if(mode != TPM_ALG_NULL)\n\t{\n\t    // then the input mode has to be TPM_ALG_NULL or the same as the key\n\t    if((in->mode != TPM_ALG_NULL) && (in->mode != mode))\n\t\treturn TPM_RCS_MODE + RC_EncryptDecrypt_mode;\n\t}\n    else\n\t{\n\t    // if the key mode is null, then the input can't be null\n\t    if(in->mode == TPM_ALG_NULL)\n\t\treturn TPM_RCS_MODE + RC_EncryptDecrypt_mode;\n\t    mode = in->mode;\n\t}\n    // The input iv for ECB mode should be an Empty Buffer.  All the other modes\n    // should have an iv size same as encryption block size\n    keySize = symKey->publicArea.parameters.symDetail.sym.keyBits.sym;\n    alg = symKey->publicArea.parameters.symDetail.sym.algorithm;\n    blockSize = CryptGetSymmetricBlockSize(alg, keySize);\n    // reverify the algorithm. This is mainly to keep static analysis tools happy\n    if(blockSize == 0)\n\treturn TPM_RCS_KEY + RC_EncryptDecrypt_keyHandle;\n    // Note: When an algorithm is not supported by a TPM, the TPM_ALG_xxx for that\n    // algorithm is not defined. However, it is assumed that the TPM_ALG_xxx for\n    // the algorithm is always defined. Both have the same numeric value.\n    // TPM_ALG_xxx is used here so that the code does not get cluttered with\n    // #ifdef's. Having this check does not mean that the algorithm is supported.\n    // If it was not supported the unmarshaling code would have rejected it before\n    // this function were called. This means that, depending on the implementation,\n    // the check could be redundant but it doesn't hurt.\n    if(((mode == TPM_ALG_ECB) && (in->ivIn.t.size != 0))\n       || ((mode != TPM_ALG_ECB) && (in->ivIn.t.size != blockSize)))\n\treturn TPM_RCS_SIZE + RC_EncryptDecrypt_ivIn;\n    // The input data size of CBC mode or ECB mode must be an even multiple of\n    // the symmetric algorithm's block size\n    if(((mode == TPM_ALG_CBC) || (mode == TPM_ALG_ECB))\n       && ((in->inData.t.size % blockSize) != 0))\n\treturn TPM_RCS_SIZE + RC_EncryptDecrypt_inData;\n    // Copy IV\n    // Note: This is copied here so that the calls to the encrypt/decrypt functions\n    // will modify the output buffer, not the input buffer\n    out->ivOut = in->ivIn;\n    // Command Output\n    key = symKey->sensitive.sensitive.sym.t.buffer;\n    // For symmetric encryption, the cipher data size is the same as plain data\n    // size.\n    out->outData.t.size = in->inData.t.size;\n    if(in->decrypt == YES)\n\t{\n\t    // Decrypt data to output\n\t    result = CryptSymmetricDecrypt(out->outData.t.buffer, alg, keySize, key,\n\t\t\t\t\t   &(out->ivOut), mode, in->inData.t.size,\n\t\t\t\t\t   in->inData.t.buffer);\n\t}\n    else\n\t{\n\t    // Encrypt data to output\n\t    result = CryptSymmetricEncrypt(out->outData.t.buffer, alg, keySize, key,\n\t\t\t\t\t   &(out->ivOut), mode, in->inData.t.size,\n\t\t\t\t\t   in->inData.t.buffer);\n\t}\n    return result;\n#endif // CC_EncryptDecrypt2\n}\n#endif // CC_EncryptDecrypt\n#include \"Tpm.h\"\n#include \"EncryptDecrypt2_fp.h\"\n#include \"EncryptDecrypt_spt_fp.h\"\n#if CC_EncryptDecrypt2  // Conditional expansion of this file\nTPM_RC\nTPM2_EncryptDecrypt2(\n\t\t     EncryptDecrypt2_In   *in,            // IN: input parameter list\n\t\t     EncryptDecrypt2_Out  *out            // OUT: output parameter list\n\t\t     )\n{\n    TPM_RC                result;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_EncryptDecrypt2: keyHandle %08x\\n\", in->keyHandle);\n\t// fclose(f);\n  //   }\n    // EncryptDecyrptShared() performs the operations as shown in\n    // TPM2_EncrypDecrypt\n    result = EncryptDecryptShared(in->keyHandle, in->decrypt, in->mode,\n\t\t\t\t  &in->ivIn, &in->inData,\n\t\t\t\t  (EncryptDecrypt_Out *)out);\n    // Handle response code swizzle.\n    switch(result)\n\t{\n\t  case TPM_RCS_MODE + RC_EncryptDecrypt_mode:\n\t    result = TPM_RCS_MODE + RC_EncryptDecrypt2_mode;\n\t    break;\n\t  case TPM_RCS_SIZE + RC_EncryptDecrypt_ivIn:\n\t    result = TPM_RCS_SIZE + RC_EncryptDecrypt2_ivIn;\n\t    break;\n\t  case TPM_RCS_SIZE + RC_EncryptDecrypt_inData:\n\t    result = TPM_RCS_SIZE + RC_EncryptDecrypt2_inData;\n\t    break;\n\t  default:\n\t    break;\n\t}\n    return result;\n}\n#endif // CC_EncryptDecrypt2\n#include \"Tpm.h\"\n#include \"Hash_fp.h\"\n#if CC_Hash  // Conditional expansion of this file\nTPM_RC\nTPM2_Hash(\n\t  Hash_In         *in,            // IN: input parameter list\n\t  Hash_Out        *out            // OUT: output parameter list\n\t  )\n{\n    HASH_STATE          hashState;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_Hash:\\n\");\n\t// fclose(f);\n  //   }\n    // Command Output\n    // Output hash\n    // Start hash stack\n    out->outHash.t.size = CryptHashStart(&hashState, in->hashAlg);\n    // Adding hash data\n    CryptDigestUpdate2B(&hashState, &in->data.b);\n    // Complete hash\n    CryptHashEnd2B(&hashState, &out->outHash.b);\n    // Output ticket\n    out->validation.tag = TPM_ST_HASHCHECK;\n    out->validation.hierarchy = in->hierarchy;\n    if(in->hierarchy == TPM_RH_NULL)\n\t{\n\t    // Ticket is not required\n\t    out->validation.hierarchy = TPM_RH_NULL;\n\t    out->validation.digest.t.size = 0;\n\t}\n    else if(in->data.t.size >= sizeof(TPM_GENERATED_VALUE)\n\t    && !TicketIsSafe(&in->data.b))\n\t{\n\t    // Ticket is not safe\n\t    out->validation.hierarchy = TPM_RH_NULL;\n\t    out->validation.digest.t.size = 0;\n\t}\n    else\n\t{\n\t    // Compute ticket\n\t    TicketComputeHashCheck(in->hierarchy, in->hashAlg,\n\t\t\t\t   &out->outHash, &out->validation);\n\t}\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_Hash\n#include \"Tpm.h\"\n#include \"HMAC_fp.h\"\n#if CC_HMAC  // Conditional expansion of this file\nTPM_RC\nTPM2_HMAC(\n\t  HMAC_In         *in,            // IN: input parameter list\n\t  HMAC_Out        *out            // OUT: output parameter list\n\t  )\n{\n    HMAC_STATE               hmacState;\n    OBJECT                  *hmacObject;\n    TPMI_ALG_HASH            hashAlg;\n    TPMT_PUBLIC             *publicArea;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_HMAC: handle %08x\\n\", in->handle);\n\t// fclose(f);\n  //   }\n    // Input Validation\n    // Get HMAC key object and public area pointers\n    hmacObject = HandleToObject(in->handle);\n    publicArea = &hmacObject->publicArea;\n    // Make sure that the key is an HMAC key\n    if(publicArea->type != TPM_ALG_KEYEDHASH)\n\treturn TPM_RCS_TYPE + RC_HMAC_handle;\n    // and that it is unrestricted\n    if (IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, restricted))\n\treturn TPM_RCS_ATTRIBUTES + RC_HMAC_handle;\n    // and that it is a signing key\n    if (!IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sign))\n\treturn TPM_RCS_KEY + RC_HMAC_handle;\n    // See if the key has a default\n    if(publicArea->parameters.keyedHashDetail.scheme.scheme == TPM_ALG_NULL)\n\t// it doesn't so use the input value\n\thashAlg = in->hashAlg;\n    else\n\t{\n\t    // key has a default so use it\n\t    hashAlg\n\t\t= publicArea->parameters.keyedHashDetail.scheme.details.hmac.hashAlg;\n\t    // and verify that the input was either the  TPM_ALG_NULL or the default\n\t    if(in->hashAlg != TPM_ALG_NULL && in->hashAlg != hashAlg)\n\t\thashAlg = TPM_ALG_NULL;\n\t}\n    // if we ended up without a hash algorithm then return an error\n    if(hashAlg == TPM_ALG_NULL)\n\treturn TPM_RCS_VALUE + RC_HMAC_hashAlg;\n    // Command Output\n    // Start HMAC stack\n    out->outHMAC.t.size = CryptHmacStart2B(&hmacState, hashAlg,\n\t\t\t\t\t   &hmacObject->sensitive.sensitive.bits.b);\n    // Adding HMAC data\n    CryptDigestUpdate2B(&hmacState.hashState, &in->buffer.b);\n    // Complete HMAC\n    CryptHmacEnd2B(&hmacState, &out->outHMAC.b);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_HMAC\n\n#include \"Tpm.h\"\n#include \"MAC_fp.h\"\n#if CC_MAC  // Conditional expansion of this file\n/* Error Returns Meaning */\n/* TPM_RC_ATTRIBUTES key referenced by handle is a restricted key */\n/* TPM_RC_KEY handle does not reference a signing key */\n/* TPM_RC_TYPE key referenced by handle is not an HMAC key */\n/* TPM_RC_VALUE hashAlg is not compatible with the hash algorithm of the scheme of the object\n   referenced by handle */\nTPM_RC\nTPM2_MAC(\n\t MAC_In         *in,            // IN: input parameter list\n\t MAC_Out        *out            // OUT: output parameter list\n\t )\n{\n    OBJECT                  *keyObject;\n    HMAC_STATE               state;\n    TPMT_PUBLIC             *publicArea;\n    TPM_RC                   result;\n    // Input Validation\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_HMAC: handle %08x\\n\", in->handle);\n\t// fclose(f);\n  //   }\n    // Get MAC key object and public area pointers\n    keyObject = HandleToObject(in->handle);\n    publicArea = &keyObject->publicArea;\n    // If the key is not able to do a MAC, indicate that the handle selects an\n    // object that can't do a MAC\n    result = CryptSelectMac(publicArea, &in->inScheme);\n    if(result == TPM_RCS_TYPE)\n\treturn TPM_RCS_TYPE + RC_MAC_handle;\n    // If there is another error type, indicate that the scheme and key are not\n    // compatible\n    if(result != TPM_RC_SUCCESS)\n\treturn RcSafeAddToResult(result, RC_MAC_inScheme);\n    // Make sure that the key is not restricted\n    if(IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, restricted))\n\treturn TPM_RCS_ATTRIBUTES + RC_MAC_handle;\n    // and that it is a signing key\n    if(!IS_ATTRIBUTE(publicArea->objectAttributes, TPMA_OBJECT, sign))\n\treturn TPM_RCS_KEY + RC_MAC_handle;\n    // Command Output\n    out->outMAC.t.size = CryptMacStart(&state, &publicArea->parameters,\n\t\t\t\t       in->inScheme,\n\t\t\t\t       &keyObject->sensitive.sensitive.any.b);\n    // If the mac can't start, treat it as a fatal error\n    if(out->outMAC.t.size == 0)\n\treturn TPM_RC_FAILURE;\n    CryptDigestUpdate2B(&state.hashState, &in->buffer.b);\n    // If the MAC result is not what was expected, it is a fatal error\n    if(CryptHmacEnd2B(&state, &out->outMAC.b) != out->outMAC.t.size)\n\treturn TPM_RC_FAILURE;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_MAC\n"
  },
  {
    "path": "ftpm-opensbi/src/TPMCmdp.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Process the commands    \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Description\n// This file contains the functions that process the commands received on the\n// control port or the command port of the simulator. The control port is used\n// to allow simulation of hardware events (such as, _TPM_Hash_Start) to test\n// the simulated TPM's reaction to those events. This improves code coverage\n// of the testing.\n\n//** Includes and Data Definitions\n#include \"simulatorPrivate.h\"\n\nstatic bool s_isPowerOn = false;\n\n//** Functions\n\n//*** Signal_PowerOn()\n// This function processes a power-on indication. Among other things, it\n// calls the _TPM_Init() handler.\nvoid _rpc__Signal_PowerOn(bool isReset)\n{\n    // if power is on and this is not a call to do TPM reset then return\n    if(s_isPowerOn && !isReset)\n\treturn;\n    // If this is a reset but power is not on, then return\n    if(isReset && !s_isPowerOn)\n\treturn;\n    // Unless this is just a reset, pass power on signal to platform\n    if(!isReset)\n\t_plat__Signal_PowerOn();\n    // Power on and reset both lead to _TPM_Init()\n    _plat__Signal_Reset();\n\n    // Set state as power on\n    s_isPowerOn = true;\n}\n\n//*** Signal_Restart()\n// This function processes the clock restart indication. All it does is call\n// the platform function.\nvoid _rpc__Signal_Restart(void)\n{\n    _plat__TimerRestart();\n}\n\n//***Signal_PowerOff()\n// This function processes the power off indication. Its primary function is\n// to set a flag indicating that the next power on indication should cause\n// _TPM_Init() to be called.\nvoid _rpc__Signal_PowerOff(void)\n{\n    if(s_isPowerOn)\n\t// Pass power off signal to platform\n\t_plat__Signal_PowerOff();\n    // This could be redundant, but...\n    s_isPowerOn = false;\n\n    return;\n}\n\n//*** _rpc__ForceFailureMode()\n// This function is used to debug the Failure Mode logic of the TPM. It will set\n// a flag in the TPM code such that the next call to TPM2_SelfTest() will result\n// in a failure, putting the TPM into Failure Mode.\nvoid _rpc__ForceFailureMode(void)\n{\n#if SIMULATION\n    SetForceFailureMode();\n#endif\n    return;\n}\n\n//*** _rpc__Signal_PhysicalPresenceOn()\n// This function is called to simulate activation of the physical presence \"pin\".\nvoid _rpc__Signal_PhysicalPresenceOn(void)\n{\n    // If TPM power is on...\n    if(s_isPowerOn)\n\t// ... pass physical presence on to platform\n\t_plat__Signal_PhysicalPresenceOn();\n    return;\n}\n\n//*** _rpc__Signal_PhysicalPresenceOff()\n// This function is called to simulate deactivation of the physical presence \"pin\".\nvoid _rpc__Signal_PhysicalPresenceOff(void)\n{\n    // If TPM is power on...\n    if(s_isPowerOn)\n\t// ... pass physical presence off to platform\n\t_plat__Signal_PhysicalPresenceOff();\n    return;\n}\n\n//*** _rpc__Signal_Hash_Start()\n// This function is called to simulate a _TPM_Hash_Start event. It will call\n//\nvoid _rpc__Signal_Hash_Start(void)\n{\n    // If TPM power is on...\n    if(s_isPowerOn)\n\t// ... pass _TPM_Hash_Start signal to TPM\n\t_TPM_Hash_Start();\n    return;\n}\n\n//*** _rpc__Signal_Hash_Data()\n// This function is called to simulate a _TPM_Hash_Data event.\nvoid _rpc__Signal_Hash_Data(_IN_BUFFER input)\n{\n    // If TPM power is on...\n    if(s_isPowerOn)\n\t// ... pass _TPM_Hash_Data signal to TPM\n\t_TPM_Hash_Data(input.BufferSize, input.Buffer);\n    return;\n}\n\n//*** _rpc__Signal_HashEnd()\n// This function is called to simulate a _TPM_Hash_End event.\nvoid _rpc__Signal_HashEnd(void)\n{\n    // If TPM power is on...\n    if(s_isPowerOn)\n\t// ... pass _TPM_HashEnd signal to TPM\n\t_TPM_Hash_End();\n    return;\n}\n\n//*** _rpc__Send_Command()\n// This is the interface to the TPM code.\n//  Return Type: void\nvoid _rpc__Send_Command(\n\t\t\tunsigned char locality, _IN_BUFFER request, _OUT_BUFFER* response)\n{\n    // If TPM is power off, reject any commands.\n    if(!s_isPowerOn)\n\t{\n\t    response->BufferSize = 0;\n\t    return;\n\t}\n    // Set the locality of the command so that it doesn't change during the command\n    _plat__LocalitySet(locality);\n    // Do implementation-specific command dispatch\n    _plat__RunCommand(\n\t\t      request.BufferSize, request.Buffer, &response->BufferSize, &response->Buffer);\n    return;\n}\n\n//*** _rpc__Signal_CancelOn()\n// This function is used to turn on the indication to cancel a command in process.\n// An executing command is not interrupted. The command code may periodically check\n// this indication to see if it should abort the current command processing and\n// returned TPM_RC_CANCELLED.\nvoid _rpc__Signal_CancelOn(void)\n{\n    // If TPM power is on...\n    if(s_isPowerOn)\n\t// ... set the platform canceling flag.\n\t_plat__SetCancel();\n    return;\n}\n\n//*** _rpc__Signal_CancelOff()\n// This function is used to turn off the indication to cancel a command in process.\nvoid _rpc__Signal_CancelOff(void)\n{\n    // If TPM power is on...\n    if(s_isPowerOn)\n\t// ... set the platform canceling flag.\n\t_plat__ClearCancel();\n    return;\n}\n\n//*** _rpc__Signal_NvOn()\n// In a system where the NV memory used by the TPM is not within the TPM, the\n// NV may not always be available. This function turns on the indicator that\n// indicates that NV is available.\nvoid _rpc__Signal_NvOn(void)\n{\n    // If TPM power is on...\n    if(s_isPowerOn)\n\t// ... make the NV available\n\t_plat__SetNvAvail();\n    return;\n}\n\n//*** _rpc__Signal_NvOff()\n// This function is used to set the indication that NV memory is no\n// longer available.\nvoid _rpc__Signal_NvOff(void)\n{\n    // If TPM power is on...\n    if(s_isPowerOn)\n\t// ... make NV not available\n\t_plat__ClearNvAvail();\n    return;\n}\n\nvoid RsaKeyCacheControl(int state);\n\n//*** _rpc__RsaKeyCacheControl()\n// This function is used to enable/disable the use of the RSA key cache during\n// simulation.\nvoid _rpc__RsaKeyCacheControl(int state)\n{\n#if USE_RSA_KEY_CACHE\n    RsaKeyCacheControl(state);\n#else\n    NOT_REFERENCED(state);\n#endif\n    return;\n}\n\n//*** _rpc__ACT_GetSignaled()\n// This function is used to count the ACT second tick.\nbool _rpc__ACT_GetSignaled(uint32_t actHandle)\n{\n#if ACT_SUPPORT\n    // If TPM power is on...\n    if(s_isPowerOn)\n\t// ... query the platform\n\treturn _plat__ACT_GetSignaled(actHandle - TPM_RH_ACT_0);\n#else   // ACT_SUPPORT\n    NOT_REFERENCED(actHandle);\n#endif  // ACT_SUPPORT\n    return false;\n}\n\n//*** _rpc__SetTpmFirmwareHash()\n// This function is used to modify the firmware's hash during simulation.\nvoid _rpc__SetTpmFirmwareHash(uint32_t hash)\n{\n#if SIMULATION\n    _plat__SetTpmFirmwareHash(hash);\n#endif\n}\n\n//*** _rpc__SetTpmFirmwareSvn()\n// This function is used to modify the firmware's SVN during simulation.\nvoid _rpc__SetTpmFirmwareSvn(uint16_t svn)\n{\n#if SIMULATION\n    _plat__SetTpmFirmwareSvn(svn);\n#endif\n}\n#if 0\n/* D.4 TPMCmdp.c */\n/* D.4.1. Description */\n/* This file contains the functions that process the commands received on the control port or the\n   command port of the simulator. The control port is used to allow simulation of hardware events\n   (such as, _TPM_Hash_Start()) to test the simulated TPM's reaction to those events. This improves\n   code coverage of the testing. */\n/* D.4.2. Includes and Data Definitions */\n#include <stdlib.h>\n#include <stdio.h>\n#include <setjmp.h>\n#include <stdbool.h>\n#include \"TpmBuildSwitches.h\"\n#ifdef TPM_WINDOWS\n#include <windows.h>\n#include <winsock.h>\n#endif\n//#include \"Platform_fp.h\"\n#include \"PlatformACT_fp.h\"\n#include \"ExecCommand_fp.h\"\n#include \"Manufacture_fp.h\"\n#include \"_TPM_Init_fp.h\"\n#include \"_TPM_Hash_Start_fp.h\"\n#include \"_TPM_Hash_Data_fp.h\"\n#include \"_TPM_Hash_End_fp.h\"\n#include \"TpmFail_fp.h\"\n#include \"TpmTcpProtocol.h\"\n#include \"Simulator_fp.h\"\n#ifdef TPM_WINDOWS\n#include \"TcpServer_fp.h\"\t/* kgold */\n#endif\n#ifdef TPM_POSIX\n#include \"TcpServerPosix_fp.h\"\t/* kgold */\n#endif\n#include \"TpmProfile.h\"\t\t/* kgold */\n\n\n\n\n#define TPM_RH_ACT_0        0x40000110\n\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/src/TableDrivenMarshal.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t Table Driven Marshal\t\t\t    \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TableDrivenMarshal.c 1628 2020-05-27 19:35:29Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.10.8.1\tTableDrivenMarshal.c */\n\n#include <assert.h>\n#include \"Tpm.h\"\n#include \"Marshal.h\"\n#include \"TableMarshal.h\"\n#if TABLE_DRIVEN_MARSHAL\nextern ArrayMarshal_mst ArrayLookupTable[];\n\nextern UINT16 MarshalLookupTable[];\n\ntypedef struct { int a; } External_Structure_t;\n\nextern struct Exernal_Structure_t MarshalData;\n\n#define IS_SUCCESS(UNMARSHAL_FUNCTION)\t\t\t\t\\\n    (TPM_RC_SUCCESS == (result = (UNMARSHAL_FUNCTION)))\nmarshalIndex_t IntegerDispatch[] = {\n    UINT8_MARSHAL_REF, UINT16_MARSHAL_REF, UINT32_MARSHAL_REF, UINT64_MARSHAL_REF,\n    INT8_MARSHAL_REF,  INT16_MARSHAL_REF,  INT32_MARSHAL_REF,  INT64_MARSHAL_REF\n};\n\n#if 1\n#define GetDescriptor(reference)\t\t\t\t\t\\\n    ((MarshalHeader_mst *)(((BYTE *)(&MarshalData)) + (reference & NULL_MASK)))\n#else\nstatic const MarshalHeader_mst *GetDescriptor(marshalIndex_t index)\n{\n    const MarshalHeader_mst    *mst = MarshalLookupTable[index & NULL_MASK];\n    return mst;\n}\n#endif\n#define GetUnionDescriptor(_index_)\t\t\t\t\\\n    ((UnionMarshal_mst *)GetDescriptor(_index_))\n#define GetArrayDescriptor(_index_)\t\t\t\t\t\\\n    ((ArrayMarshal_mst *))(ArrayLookupTable[_index_ & NULL_MASK])\n\n//*** GetUnmarshaledInteger()\n// Gets the unmarshaled value and normalizes it to a UIN32 for other\n// processing (comparisons and such).\nstatic UINT32 GetUnmarshaledInteger(\n\t\t\t\t    marshalIndex_t       type,\n\t\t\t\t    const void          *target\n\t\t\t\t    )\n{\n    int     size = (type & SIZE_MASK);\n    //\n    if(size == FOUR_BYTES)\n\treturn *((UINT32 *)target);\n    if(type & IS_SIGNED)\n\t{\n\t    if(size == TWO_BYTES)\n\t\treturn (UINT32)*((int16_t *)target);\n\t    return (UINT32)*((int8_t *)target);\n\t}\n    if(size == TWO_BYTES)\n\treturn (UINT32)*((UINT16 *)target);\n    return (UINT32)*((UINT8 *)target);\n}\nstatic UINT32 GetSelector(\n\t\t\t  void                *structure,\n\t\t\t  const UINT16        *values,\n\t\t\t  UINT16               descriptor\n\t\t\t  )\n{\n    unsigned            sel = GET_ELEMENT_NUMBER(descriptor);\n    // Get the offset of the value in the unmarshaled structure\n    const UINT16        *entry = &values[(sel * 3)];\n    //\n    return GetUnmarshaledInteger(GET_ELEMENT_SIZE(entry[0]),\n\t\t\t\t ((UINT8 *)structure) + entry[2]);\n}\nstatic TPM_RC UnmarshalBytes(\n\t\t\t     UINT8               *target,        // IN/OUT: place to put the bytes\n\t\t\t     UINT8               **buffer,       // IN/OUT: source of the input data\n\t\t\t     *size,          // IN/OUT: remaining bytes in the input buffer\n\t\t\t     int                  count          // IN: number of bytes to get\n\t\t\t     )\n{\n    if((*size -= count) >= 0)\n\t{\n\t    memcpy(target, *buffer, count);\n\t    *buffer += count;\n\t    return TPM_RC_SUCCESS;\n\t}\n    return TPM_RC_INSUFFICIENT;\n}\n\n/* 9.10.8.1.1.1\tMarshalBytes() */\n/* Marshal an array of bytes. */\nstatic UINT16 MarshalBytes(\n\t\t\t   UINT8               *source,\n\t\t\t   UINT8               **buffer,\n\t\t\t   INT32               *size,\n\t\t\t   int32_t              count\n\t\t\t   )\n{\n    if(buffer != NULL)\n\t{\n\t    if(size != NULL && (size -= count) < 0)\n\t\treturn 0;\n\t    memcpy(*buffer, source, count);\n\t    *buffer += count;\n\t}\n    return (UINT16)count;\n}\n/* 9.10.8.1.1.2\tArrayUnmarshal() */\n/* Unmarshal an array. The index is of the form: type_ARRAY_MARSHAL_INDEX. */\nstatic TPM_RC ArrayUnmarshal(\n\t\t\t     UINT16               index,         // IN: the type of the array\n\t\t\t     UINT8               *target,        // IN: target for the data\n\t\t\t     UINT8               **buffer,       // IN/OUT: place to get the data\n\t\t\t     INT32               *size,          // IN/OUT: remaining unmarshal data\n\t\t\t     UINT32               count          // IN: number of values of 'index' to\n\t\t\t     //      unmarshal\n\t\t\t     )\n{\n    marshalIndex_t       which = ArrayLookupTable[index & NULL_MASK].type;\n    UINT16               stride = ArrayLookupTable[index & NULL_MASK].stride;\n    TPM_RC               result;\n    //\n    if(stride == 1) // A byte array\n\tresult = UnmarshalBytes(target, buffer, size, count);\n    else\n\t{\n\t    which |= index & NULL_FLAG;\n\t    for(result = TPM_RC_SUCCESS; count > 0; target += stride, count--)\n\t\tif(!IS_SUCCESS(Unmarshal(which, target, buffer, size)))\n\t\t    break;\n\t}\n    return result;\n}\n/* 9.10.8.1.1.3\tArrayMarshal() */\nstatic UINT16 ArrayMarshal(\n\t\t\t   UINT16               index,         // IN: the type of the array\n\t\t\t   UINT8               *source,        // IN: source of the data\n\t\t\t   UINT8               **buffer,       // IN/OUT: place to put the data\n\t\t\t   INT32               *size,          // IN/OUT: amount of space for the data\n\t\t\t   UINT32               count          // IN: number of values of 'index' to marshal\n\t\t\t   )\n{\n    marshalIndex_t      which = ArrayLookupTable[index & NULL_MASK].type;\n    UINT16              stride = ArrayLookupTable[index & NULL_MASK].stride;\n    UINT16              retVal;\n    //\n    if(stride == 1) // A byte array\n\treturn MarshalBytes(source, buffer, size, count);\n    which |= index & NULL_FLAG;\n    for(retVal = 0\n\t\t ; count > 0\n     ; source += stride, count--)\n\tretVal += Marshal(which, source, buffer, size);\n    \n    return retVal;\n}\n/* 9.10.8.1.1.4\tUnmarshalUnion() */\nTPM_RC\nUnmarshalUnion(\n\t       UINT16               typeIndex,         // IN: the thing to unmarshal\n\t       void                *target,            // IN: were the data goes to\n\t       UINT8               **buffer,           // IN/OUT: the data source buffer\n\t       INT32               *size,              // IN/OUT: the remaining size\n\t       UINT32               selector\n\t       )\n{\n    int                  i;\n    UnionMarshal_mst    *ut = GetUnionDescriptor(typeIndex);\n    marshalIndex_t       selected;\n    //\n    for(i = 0; i < ut->countOfselectors; i++)\n\t{\n\t    if(selector == ut->selectors[i])\n\t\t{\n\t\t    UINT8           *offset = ((UINT8 *)ut) + ut->offsetOfUnmarshalTypes;\n\t\t    // Get the selected thing to unmarshal\n\t\t    selected = ((marshalIndex_t *)offset)[i];\n\t\t    if(ut->modifiers & IS_ARRAY_UNION)\n\t\t\treturn UnmarshalBytes(target, buffer, size, selected);\n\t\t    else\n\t\t\t{\n\t\t\t    // Propagate NULL_FLAG if the null flag was\n\t\t\t    // propagated to the structure containing the union\n\t\t\t    selected |= (typeIndex & NULL_FLAG);\n\t\t\t    return Unmarshal(selected, target, buffer, size);\n\t\t\t}\n\t\t}\n\t}\n    // Didn't find the value.\n    return TPM_RC_SELECTOR;\n}\n/* 9.10.8.1.1.5\tMarshalUnion() */\nUINT16\nMarshalUnion(\n\t     UINT16               typeIndex,         // IN: the thing to marshal\n\t     void                *source,            // IN: were the data comes from\n\t     UINT8               **buffer,           // IN/OUT: the data source buffer\n\t     INT32               *size,              // IN/OUT: the remaining size\n\t     UINT32               selector           // IN: the union selector\n\t     )\n{\n    int                  i;\n    UnionMarshal_mst    *ut = GetUnionDescriptor(typeIndex);\n    marshalIndex_t       selected;\n    //\n    for(i = 0; i < ut->countOfselectors; i++)\n\t{\n\t    if(selector == ut->selectors[i])\n\t\t{\n\t\t    UINT8           *offset = ((UINT8 *)ut) + ut->offsetOfUnmarshalTypes;\n\t\t    // Get the selected thing to unmarshal\n\t\t    selected = ((marshalIndex_t *)offset)[i];\n\t\t    if(ut->modifiers & IS_ARRAY_UNION)\n\t\t\treturn MarshalBytes(source, buffer, size, selected);\n\t\t    else\n\t\t\treturn Marshal(selected, source, buffer, size);\n\t\t}\n\t}\n    if(size != NULL)\n\t*size = -1;\n    return 0;\n}\nTPM_RC\nUnmarshalInteger(\n\t\t int                  iSize,             // IN: Number of bytes in the integer\n\t\t void                *target,            // OUT: receives the integer\n\t\t UINT8               **buffer,           // IN/OUT: source of the data\n\t\t INT32               *size,              // IN/OUT: amount of data available\n\t\t UINT32              *value              // OUT: optional copy of 'target'\n\t\t )\n{\n    // This is just to save typing\n#define _MB_ (*buffer)\n    // The size is a power of two so convert to regular integer\n    int              bytes = (1 << (iSize & SIZE_MASK));\n    //\n    // Check to see if there is enough data to fulfill the request\n    if((*size -= bytes) >= 0)\n\t{\n\t    // The most comon size\n\t    if(bytes == 4)\n\t\t{\n\t\t    *((UINT32 *)target) = (UINT32)((((((_MB_[0] << 8) | _MB_[1]) << 8)\n\t\t\t\t\t\t     | _MB_[2]) << 8) | _MB_[3]);\n\t\t    // If a copy is needed, copy it.\n\t\t    if(value != NULL)\n\t\t\t*value = *((UINT32 *)target);\n\t\t}\n\t    else if(bytes == 2)\n\t\t{\n\t\t    *((UINT16 *)target) = (UINT16)((_MB_[0] << 8) | _MB_[1]);\n\t\t    // If a copy is needed, copy with the appropriate sign extension\n\t\t    if(value != NULL)\n\t\t\t{\n\t\t\t    if(iSize & IS_SIGNED)\n\t\t\t\t*value = (UINT32)(*((INT16 *)target));\n\t\t\t    else\n\t\t\t\t*value = (UINT32)(*((UINT16 *)target));\n\t\t\t}\n\t\t}\n\t    else if(bytes == 1)\n\t\t{\n\t\t    *((UINT8*)target) = (UINT8)_MB_[0];\n\t\t    // If a copy is needed, copy with the appropriate sign extension\n\t\t    if(value != NULL)\n\t\t\t{\n\t\t\t    if(iSize & IS_SIGNED)\n\t\t\t\t*value = (UINT32)(*((INT8 *)target));\n\t\t\t    else\n\t\t\t\t*value = (UINT32)(*((UINT8 *)target));\n\t\t\t}\n\t\t}\n\t    else\n\t\t{\n\t\t    // There is no input type that is a 64-bit value other than a UINT64. So\n\t\t    // there is no reason to do anything other than unmarshal it.\n\t\t    *((UINT64 *)target) = BYTE_ARRAY_TO_UINT64(*buffer);\n\t\t}\n\t    *buffer += bytes;\n\t    return TPM_RC_SUCCESS;\n#undef _MB_\n\t}\n    return TPM_RC_INSUFFICIENT;\n}\n/* 9.10.8.1.1.6\tUnmarshal() */\n/* This is the function that performs unmarshaling of different numbered types. Each TPM type has a\n   number. The number is used to lookup the address of the data structure that describes how to\n   unmarshal that data type. */\nTPM_RC\nUnmarshal(\n\t  UINT16               typeIndex,         // IN: the thing to marshal\n\t  void                *target,            // IN: were the data goes from\n\t  UINT8               **buffer,           // IN/OUT: the data source buffer\n\t  INT32               *size               // IN/OUT: the remaining size\n\t  )\n{\n    const MarshalHeader_mst     *sel;\n    TPM_RC                       result;\n    //\n    sel = GetDescriptor(typeIndex);\n    switch(sel->marshalType)\n\t{\n\t  case UINT_MTYPE:\n\t      {\n\t\t  // A simple signed or unsigned integer value.\n\t\t  return UnmarshalInteger(sel->modifiers, target,\n\t\t\t\t\t  buffer, size, NULL);\n\t      }\n\t  case VALUES_MTYPE:\n\t      {\n\t\t  // This is the general-purpose structure that can handle things like\n\t\t  // TPMI_DH_PARENT that has multiple ranges, multiple singles and a\n\t\t  // 'null' value. When things cover a large range with holes in the range\n\t\t  // they can be turned into multiple ranges. There is no option for a bit\n\t\t  // field.\n\t\t  // The structure is:\n\t\t  //  typedef const struct ValuesMarshal_mst\n\t\t  //  {\n\t\t  //      UINT8           marshalType;        // VALUES_MTYPE\n\t\t  //      UINT8           modifiers;\n\t\t  //      UINT8           errorCode;\n\t\t  //      UINT8           singles;\n\t\t  //      UINT32          values[singles + 1 if TAKES_NULL];\n\t\t  //  } ValuesMarshal_mst;\n\t\t  // Unmarshal the base type\n\t\t  UINT32                   val;\n\t\t  if(IS_SUCCESS(UnmarshalInteger(sel->modifiers, target,\n\t\t\t\t\t\t buffer, size, &val)))\n\t\t      {\n\t\t\t  ValuesMarshal_mst   *vmt = ((ValuesMarshal_mst *)sel);\n\t\t\t  const UINT32        *check = vmt->values;\n\t\t\t  //\n\t\t\t  // if the TAKES_NULL flag is set, then the first entry in the values\n\t\t\t  // list is the NULL value. Iy is not included in the 'ranges' or\n\t\t\t  // 'singles' count.\n\t\t\t  if((vmt->modifiers & TAKES_NULL) && (val == *check++))\n\t\t\t      {\n\t\t\t\t  if((typeIndex & NULL_FLAG) == 0)\n\t\t\t\t      result = (TPM_RC)(sel->errorCode);\n\t\t\t      }\n\t\t\t  // No NULL value or input is not the NULL value\n\t\t\t  else\n\t\t\t      {\n\t\t\t\t  int               i;\n\t\t\t\t  //\n\t\t\t\t  // Check all the min-max ranges.\n\t\t\t\t  for(i = vmt->ranges - 1; i >= 0; check = &check[2], i--)\n\t\t\t\t      if((UINT32)(val - check[0]) <= check[1])\n\t\t\t\t\t  break;\n\t\t\t\t  // if the input is in a selected range, then i >= 0\n\t\t\t\t  if(i < 0)\n\t\t\t\t      {\n\t\t\t\t\t  // Not in any range, so check sigles\n\t\t\t\t\t  for(i = vmt->singles - 1; i >= 0; i--)\n\t\t\t\t\t      if(val == check[i])\n\t\t\t\t\t\t  break;\n\t\t\t\t      }\n\t\t\t\t  // If input not in range and not in any single so return error\n\t\t\t\t  if(i < 0)\n\t\t\t\t      result = (TPM_RC)(sel->errorCode);\n\t\t\t      }\n\t\t      }\n\t\t  break;\n\t      }\n\t  case TABLE_MTYPE:\n\t      {\n\t\t  // This is a table with or without bit checking. The input is checked\n\t\t  // against each value in the table. If the value is in the table, and\n\t\t  // a bits table is present, then the bit field is checked to see if the\n\t\t  // indicated value is implemented. For example, if there is a table of\n\t\t  // allowed RSA key sizes and the 2nd entry matches, then the 2nd bit in\n\t\t  // thed bit field is checked to see if that allowed size is implemented in\n\t\t  // this TPM.\n\t\t  //  typedef const struct TableMarshal_mst\n\t\t  //  {\n\t\t  //      UINT8           marshalType;        // TABLE_MTYPE\n\t\t  //      UINT8           modifiers;\n\t\t  //      UINT8           errorCode;\n\t\t  //      UINT8           singles;\n\t\t  //      UINT32          values[singles + 1 if TAKES_NULL];\n\t\t  //  } TableMarshal_mst;\n\t\t  \n\t\t  UINT32                  val;\n\t\t  //\n\t\t  // Unmarshal the base type\n\t\t  if(IS_SUCCESS(UnmarshalInteger(sel->modifiers, target,\n\t\t\t\t\t\t buffer, size, &val)))\n\t\t      {\n\t\t\t  TableMarshal_mst    *tmt = ((TableMarshal_mst *)sel);\n\t\t\t  const UINT32        *check = tmt->values;\n\t\t\t  //\n\t\t\t  // If this type has a null value, then it is the first value in the\n\t\t\t  // list of values. It does not count in the count of values\n\t\t\t  if((tmt->modifiers & TAKES_NULL) && (val == *check++))\n\t\t\t      {\n\t\t\t\t  if((typeIndex & NULL_FLAG) == 0)\n\t\t\t\t      result = (TPM_RC)(sel->errorCode);\n\t\t\t      }\n\t\t\t  else\n\t\t\t      {\n\t\t\t\t  int               i;\n\t\t\t\t  //\n\t\t\t\t  // Process the singles\n\t\t\t\t  for(i = tmt->singles - 1; i >= 0; i--)\n\t\t\t\t      {\n\t\t\t\t\t  // does the input value match the value in the table\n\t\t\t\t\t  if(val == check[i])\n\t\t\t\t\t      {\n\t\t\t\t\t\t  // If there is an associated bit table, make sure that\n\t\t\t\t\t\t  // the corresponding bit is SET\n\t\t\t\t\t\t  if((HAS_BITS & tmt->modifiers)\n\t\t\t\t\t\t     && (!IS_BIT_SET32(i, &(check[tmt->singles]))))\n\t\t\t\t\t\t      // if not SET, then this is a failure.\n\t\t\t\t\t\t      i = -1;\n\t\t\t\t\t\t  break;\n\t\t\t\t\t      }\n\t\t\t\t      }\n\t\t\t\t  // error if not found or bit not SET\n\t\t\t\t  if(i < 0)\n\t\t\t\t      result = (TPM_RC)(sel->errorCode);\n\t\t\t      }\n\t\t      }\n\t\t  break;\n\t      }\n\t  case MIN_MAX_MTYPE:\n\t      {\n\t\t  // A MIN_MAX is a range. It can have a bit field and a NULL value that is\n\t\t  // outside of the range. If the input value is in the min-max range then\n\t\t  // it is valid unless there is an associated bit field. Otherwise, it\n\t\t  // it is only valid if the corresponding value in the bit field is SET.\n\t\t  // The min value is 'values[0]' or 'values[1]' if there is a NULL value.\n\t\t  // The max value is the value after min. The max value is in the table as\n\t\t  // max minus min. This allows 'val' to be subtracted from min and then\n\t\t  // checked against max with one unsigned comparison. If present, the bit\n\t\t  // field will be the first 'values' after max.\n\t\t  //  typedef const struct MinMaxMarshal_mst\n\t\t  //  {\n\t\t  //      UINT8           marshalType;        // MIN_MAX_MTYPE\n\t\t  //      UINT8           modifiers;\n\t\t  //      UINT8           errorCode;\n\t\t  //      UINT32          values[2 + 1 if TAKES_NULL];\n\t\t  //  } MinMaxMarshal_mst;\n\t\t  UINT32               val;\n\t\t  //\n\t\t  // A min-max has a range. It can have a bit-field that is indexed to the\n\t\t  // min value (something that matches min has a bit at 0. This is useful\n\t\t  // for algorithms. The min-max define a range of algorithms to be checked\n\t\t  // and the bit field can check to see if the algorithm in that range is\n\t\t  // allowed.\n\t\t  if(IS_SUCCESS(UnmarshalInteger(sel->modifiers, target,\n\t\t\t\t\t\t buffer, size, &val)))\n\t\t      {\n\t\t\t  MinMaxMarshal_mst   *mmt = (MinMaxMarshal_mst *)sel;\n\t\t\t  const UINT32        *check = mmt->values;\n\t\t\t  //\n\t\t\t  // If this type takes a NULL, see if it matches. This\n\t\t\t  if((mmt->modifiers & TAKES_NULL) && (val == *check++))\n\t\t\t      {\n\t\t\t\t  if((typeIndex & NULL_FLAG) == 0)\n\t\t\t\t      result = (TPM_RC)(mmt->errorCode);\n\t\t\t      }\n\t\t\t  else\n\t\t\t      {\n\t\t\t\t  val -= *check;\n\t\t\t\t  if((val > check[1])\n\t\t\t\t     || ((mmt->modifiers & HAS_BITS) &&\n\t\t\t\t\t !IS_BIT_SET32(val, &check[2])))\n\t\t\t\t      result = (TPM_RC)(mmt->errorCode);\n\t\t\t      }\n\t\t      }\n\t\t  break;\n\t      }\n\t  case ATTRIBUTES_MTYPE:\n\t      {\n\t\t  //  This is used for TPMA values.\n\t\t  UINT32                   mask;\n\t\t  AttributesMarshal_mst   *amt = (AttributesMarshal_mst *)sel;\n\t\t  //\n\t\t  if(IS_SUCCESS(UnmarshalInteger(sel->modifiers, target,\n\t\t\t\t\t\t buffer, size, &mask)))\n\t\t      {\n\t\t\t  if((mask & amt->attributeMask) != 0)\n\t\t\t      result = TPM_RC_RESERVED_BITS;\n\t\t      }\n\t\t  break;\n\t      }\n\t  case STRUCTURE_MTYPE:\n\t      {\n\t\t  // A structure (not a union). A structure has elements (one defined per\n\t\t  // row). Three UINT16 values are used for each row. The first indicates\n\t\t  // the type of the entry. They choices are: simple, union, or array. A\n\t\t  // simple type can be a simple integer or another structure. It can also\n\t\t  // be a specific \"interface type.\" For example, when a structure entry is\n\t\t  // a value that is used define the dimension of an array, the entry of\n\t\t  // the structure will reference a \"synthetic\" interface type, most often\n\t\t  // a min-max value. If the type of the entry is union or array, then the\n\t\t  // first value indicates which of the previous elements provides the union\n\t\t  // selector or the array dimension. That previous entry is referenced in\n\t\t  // the unmarshaled structure in memory (Not the marshaled buffer). The\n\t\t  // previous entry indicates the location in the structure of the value.\n\t\t  // The second entry of each structure entry indicated the index of the\n\t\t  // type associated with the entry. This is an index into the array of\n\t\t  // arrays or the union table (merged with the normal table in this\n\t\t  // implementation). The final entry is the offset in the unmarshaled\n\t\t  // structure where the value is located. This is the offsetof(STRUcTURE,\n\t\t  // element). This value is added to the input 'target' or 'source' value\n\t\t  // to determine where the value goes.\n\t\t  StructMarshal_mst   *mst = (StructMarshal_mst *)sel;\n\t\t  int                  i;\n\t\t  const UINT16        *value = mst->values;\n\t\t  //\n\t\t  for(result = TPM_RC_SUCCESS, i = mst->elements\n\t\t\t       ; (TPM_RC_SUCCESS == result) && (i > 0)\n\t\t     ; value = &value[3], i--)\n\t\t      {\n\t\t\t  UINT16           descriptor = value[0];\n\t\t\t  marshalIndex_t   index = value[1];\n\t\t\t  // The offset of the object in the structure is in the last value in\n\t\t\t  // the triplet. Add that value to the start of the structure\n\t\t\t  UINT8           *offset = ((UINT8 *)target) + value[2];\n\t\t\t  //\n\t\t\t  if ((ELEMENT_PROPAGATE & descriptor)\n\t\t\t      && (typeIndex & NULL_FLAG))\n\t\t\t      index |= NULL_FLAG;\n\t\t\t  switch(GET_ELEMENT_TYPE(descriptor))\n\t\t\t      {\n\t\t\t\tcase SIMPLE_STYPE:\n\t\t\t\t    {\n\t\t\t\t\tresult = Unmarshal(index, offset, buffer, size);\n\t\t\t\t\tbreak;\n\t\t\t\t    }\n\t\t\t\tcase UNION_STYPE:\n\t\t\t\t    {\n\t\t\t\t\tUINT32               choice;\n\t\t\t\t\t//\n\t\t\t\t\t// Get the selector or array dimension value\n\t\t\t\t\tchoice = GetSelector(target, mst->values, descriptor);\n\t\t\t\t\tresult = UnmarshalUnion(index, offset, buffer, size, choice);\n\t\t\t\t\tbreak;\n\t\t\t\t    }\n\t\t\t\tcase ARRAY_STYPE:\n\t\t\t\t    {\n\t\t\t\t\tUINT32            dimension;\n\t\t\t\t\t//\n\t\t\t\t\tdimension = GetSelector(target, mst->values, descriptor);\n\t\t\t\t\tresult = ArrayUnmarshal(index, offset, buffer,\n\t\t\t\t\t\t\t\tsize, dimension);\n\t\t\t\t\tbreak;\n\t\t\t\t    }\n\t\t\t\tdefault:\n\t\t\t\t  result = TPM_RC_FAILURE;\n\t\t\t\t  break;\n\t\t\t      }\n\t\t      }\n\t\t  break;\n\t      }\n\t  case TPM2B_MTYPE:\n\t      {\n\t\t  // A primitive TPM2B. A size and byte buffer. The single value (other than\n\t\t  // the tag) references the synthetic 'interface' value for the size\n\t\t  // parameter.\n\t\t  Tpm2bMarshal_mst        *m2bt = (Tpm2bMarshal_mst *)sel;\n\t\t  //\n\t\t  if(IS_SUCCESS(Unmarshal(m2bt->sizeIndex, target, buffer, size)))\n\t\t      result = UnmarshalBytes(((TPM2B *)target)->buffer,\n\t\t\t\t\t      buffer, size, *((UINT16 *)target));\n\t\t  break;\n\t      }\n\t  case TPM2BS_MTYPE:\n\t      {\n\t\t  // This is used when a TPM2B contains a structure.\n\t\t  Tpm2bsMarshal_mst   *m2bst = (Tpm2bsMarshal_mst *)sel;\n\t\t  INT32          count;\n\t\t  //\n\t\t  if(IS_SUCCESS(Unmarshal(m2bst->sizeIndex, target, buffer, size)))\n\t\t      {\n\t\t\t  // fetch the size value and convert it to a 32-bit count value\n\t\t\t  count = (int32_t)*((UINT16 *)target);\n\t\t\t  if(count == 0)\n\t\t\t      {\n\t\t\t\t  if(m2bst->modifiers & SIZE_EQUAL)\n\t\t\t\t      result = TPM_RC_SIZE;\n\t\t\t      }\n\t\t\t  else if((*size -= count) >= 0)\n\t\t\t      {\n\t\t\t\t  marshalIndex_t  index = m2bst->dataIndex;\n\t\t\t\t  //\n\t\t\t\t  // If this type propigates a null (PROPIGATE_NULL), propigate it\n\t\t\t\t  if ((m2bst->modifiers & PROPAGATE_NULL)\n\t\t\t\t      && (typeIndex & typeIndex))\n\t\t\t\t      index |= NULL_FLAG;\n\t\t\t\t  // The structure might not start two bytes after the start of the\n\t\t\t\t  // size field. The offset to the start of the structure is between\n\t\t\t\t  // 2 and 8 bytes. This is encoded into the low 4 bits of the\n\t\t\t\t  // modifiers byte byte\n\t\t\t\t  if(IS_SUCCESS(Unmarshal(index,\n\t\t\t\t\t\t\t  ((UINT8 *)target) + (m2bst->modifiers & OFFSET_MASK),\n\t\t\t\t\t\t\t  buffer, &count)))\n\t\t\t\t      {\n\t\t\t\t\t  if(count != 0)\n\t\t\t\t\t      result = TPM_RC_SIZE;\n\t\t\t\t      }\n\t\t\t      }\n\t\t\t  else\n\t\t\t      result = TPM_RC_INSUFFICIENT;\n\t\t      }\n\t\t  break;\n\t      }\n\t  case LIST_MTYPE:\n\t      {\n\t\t  // Used for a list. A list is a qualified 32-bit 'count' value followed\n\t\t  // by a type indicator.\n\t\t  ListMarshal_mst     *mlt = (ListMarshal_mst *)sel;\n\t\t  marshalIndex_t      index = mlt->arrayRef;\n\t\t  //\n\t\t  if(IS_SUCCESS(Unmarshal(mlt->sizeIndex, target, buffer, size)))\n\t\t      {\n\t\t\t  // If this type propigates a null (PROPIGATE_NULL), propigate it\n\t\t\t  if ((mlt->modifiers & PROPAGATE_NULL)\n\t\t\t      && (typeIndex & NULL_FLAG))\n\t\t\t      index |= NULL_FLAG;\n\t\t\t  result = ArrayUnmarshal(index,\n\t\t\t\t\t\t  ((UINT8 *)target) +(mlt->modifiers & OFFSET_MASK),\n\t\t\t\t\t\t  buffer, size, *((UINT32 *)target));\n\t\t      }\n\t\t  break;\n\t      }\n\t  case NULL_MTYPE:\n\t      {\n\t\t  result = TPM_RC_SUCCESS;\n\t\t  break;\n\t      }\n#if 0\n\t  case COMPOSITE_MTYPE:\n\t      {\n\t\t  CompositeMarshal_mst    *mct = (CompositeMarshal_mst *)sel;\n\t\t  int                      i;\n\t\t  UINT8                   *buf = *buffer;\n\t\t  INT32                   sz = *size;\n\t\t  //\n\t\t  result = TPM_RC_VALUE;\n\t\t  for(i = GET_ELEMENT_COUNT(mct->modifiers) - 1; i <= 0; i--)\n\t\t      {\n\t\t\t  marshalIndex_t      index = mct->types[i];\n\t\t\t  //\n\t\t\t  // This type might take a null so set it in each called value, just\n\t\t\t  // in case it is needed in that value. Only one value in each\n\t\t\t  // composite should have the takes null SET.\n\t\t\t  index |= typeIndex & NULL_MASK;\n\t\t\t  result = Unmarshal(index, target, buffer, size);\n\t\t\t  if(result == TPM_RC_SUCCESS)\n\t\t\t      break;\n\t\t\t  // Each of the composite values does its own unmarshaling. This\n\t\t\t  // has some execution overhead if it is unmarshaled multiple times\n\t\t\t  // but it saves code size in not having to reproduce the various\n\t\t\t  // unmarshaling types that can be in a composite. So, what this means\n\t\t\t  // is that the buffer pointer and size have to be reset for each\n\t\t\t  // unmarshaled value.\n\t\t\t  *buffer = buf;\n\t\t\t  *size = sz;\n\t\t      }\n\t\t  break;\n\t      }\n#endof // 0\n\t  default:\n\t      {\n\t\t  result = TPM_RC_FAILURE;\n\t\t  break;\n\t      }\n\t}\n    return result;\n}\n/* 9.10.8.1.1.7\tMarshal() */\n/* This is the function that drives marshaling of output. Because there is no validation of the\n   output, there is a lot less code. */\nUINT16 Marshal(\n\t       UINT16               typeIndex,         // IN: the thing to marshal\n\t       void                *source,            // IN: were the data comes from\n\t       UINT8               **buffer,           // IN/OUT: the data source buffer\n\t       INT32               *size               // IN/OUT: the remaining size\n\t       )\n{\n#define _source  ((UINT8 *)source)\n    \n    const MarshalHeader_mst     *sel;\n    UINT16                       retVal;\n    //\n    sel = GetDescriptor(typeIndex);\n    switch(sel->marshalType)\n\t{\n\t  case VALUES_MTYPE:\n\t  case UINT_MTYPE:\n\t  case TABLE_MTYPE:\n\t  case MIN_MAX_MTYPE:\n\t  case ATTRIBUTES_MTYPE:\n\t  case COMPOSITE_MTYPE:\n\t      {\n#if BIG_ENDIAN_TPM\n#define MM16    0\n#define MM32    0\n#define MM64    0\n#else\n\t\t  // These flip the constant index values so that they count in reverse order when doing\n\t\t  // little-endian stuff\n#define MM16    1\n#define MM32    3\n#define MM64    7\n#endif\n\t\t  // Just change the name and cast the type of the input parameters for typing purposes\n#define mb (*buffer)\n#define _source ((UINT8 *)source)\n\t\t  retVal = (1 << (sel->modifiers & SIZE_MASK));\n\t\t  if(buffer != NULL)\n\t\t      {\n\t\t\t  if((size == NULL) || ((*size -= retVal) >= 0))\n\t\t\t      {\n\t\t\t\t  if(retVal == 4)\n\t\t\t\t      {\n\t\t\t\t\t  mb[0 ^ MM32] = _source[0];\n\t\t\t\t\t  mb[1 ^ MM32] = _source[1];\n\t\t\t\t\t  mb[2 ^ MM32] = _source[2];\n\t\t\t\t\t  mb[3 ^ MM32] = _source[3];\n\t\t\t\t      }\n\t\t\t\t  else if(retVal == 2)\n\t\t\t\t      {\n\t\t\t\t\t  mb[0 ^ MM16] = _source[0];\n\t\t\t\t\t  mb[1 ^ MM16] = _source[1];\n\t\t\t\t      }\n\t\t\t\t  else if(retVal == 1)\n\t\t\t\t      mb[0] = _source[0];\n\t\t\t\t  else\n\t\t\t\t      {\n\t\t\t\t\t  mb[0 ^ MM64] = _source[0];\n\t\t\t\t\t  mb[1 ^ MM64] = _source[1];\n\t\t\t\t\t  mb[2 ^ MM64] = _source[2];\n\t\t\t\t\t  mb[3 ^ MM64] = _source[3];\n\t\t\t\t\t  mb[4 ^ MM64] = _source[4];\n\t\t\t\t\t  mb[5 ^ MM64] = _source[5];\n\t\t\t\t\t  mb[6 ^ MM64] = _source[6];\n\t\t\t\t\t  mb[7 ^ MM64] = _source[7];\n\t\t\t\t      }\n\t\t\t\t  *buffer += retVal;\n\t\t\t      }\n\t\t      }\n\t\t  break;\n\t      }\n\t  case STRUCTURE_MTYPE:\n\t      {\n\t\t  //#define _mst  ((StructMarshal_mst *)sel)\n\t\t  StructMarshal_mst *mst = ((StructMarshal_mst *)sel);\n\t\t  int              i;\n\t\t  const UINT16  *value = mst->values;\n\t\t  \n\t\t  //\n\t\t  for(retVal = 0, i = mst->elements; i > 0; value = &value[3], i--)\n\t\t      {\n\t\t\t  UINT16           des = value[0];\n\t\t\t  marshalIndex_t   index = value[1];\n\t\t\t  UINT8           *offset = _source + value[2];\n\t\t\t  //\n\t\t\t  switch(GET_ELEMENT_TYPE(des))\n\t\t\t      {\n\t\t\t\tcase UNION_STYPE:\n\t\t\t\t    {\n\t\t\t\t\tUINT32           choice;\n\t\t\t\t\t//\n\t\t\t\t\tchoice = GetSelector(source, mst->values, des);\n\t\t\t\t\tretVal += MarshalUnion(index, offset, buffer, size, choice);\n\t\t\t\t\tbreak;\n\t\t\t\t    }\n\t\t\t\tcase ARRAY_STYPE:\n\t\t\t\t    {\n\t\t\t\t\tUINT32               count;\n\t\t\t\t\t//\n\t\t\t\t\tcount = GetSelector(source, mst->values, des);\n\t\t\t\t\tretVal += ArrayMarshal(index, offset, buffer, size, count);\n\t\t\t\t\tbreak;\n\t\t\t\t    }\n\t\t\t\tcase SIMPLE_STYPE:\n\t\t\t\tdefault:\n\t\t\t\t    {\n\t\t\t\t\t// This is either another structure or a simple type\n\t\t\t\t\tretVal += Marshal(index, offset, buffer, size);\n\t\t\t\t\tbreak;\n\t\t\t\t    }\n\t\t\t      }\n\t\t      }\n\t\t  break;\n\t      }\n\t  case TPM2B_MTYPE:\n\t      {\n\t\t  // Get the number of bytes being marshaled\n\t\t  INT32         val = (int32_t)*((UINT16 *)source);\n\t\t  //\n\t\t  retVal = Marshal(UINT16_MARSHAL_REF, source, buffer, size);\n\t\t  \n\t\t  // This is a standard 2B with a byte buffer\n\t\t  retVal += MarshalBytes(((TPM2B *)_source)->buffer, buffer, size, val);\n\t\t  break;\n\t      }\n\t  case TPM2BS_MTYPE: // A structure in a TPM2B\n\t      {\n\t\t  Tpm2bsMarshal_mst       *m2bst = (Tpm2bsMarshal_mst *)sel;\n\t\t  UINT8                   *offset;\n\t\t  UINT16                   amount;\n\t\t  UINT8                   *marshaledSize;\n\t\t  //\n\t\t  // Save the address of where the size should go\n\t\t  marshaledSize = *buffer;\n\t\t  \n\t\t  // marshal the size (checks the space and advanced the pointer)\n\t\t  retVal = Marshal(UINT16_MARSHAL_REF, source, buffer, size);\n\t\t  \n\t\t  // This gets the offsetof the structure to marshal. It was placed in the\n\t\t  // modifiers byte because the offset from the start of the TPM2B to the\n\t\t  // start of the structure is going to be less than 8 and the modifiers\n\t\t  // byte isn't needed for anything else.\n\t\t  offset = _source + (m2bst->modifiers & SIGNED_MASK);\n\t\t  \n\t\t  // Marshal the structure and get its size\n\t\t  amount = Marshal(m2bst->dataIndex, offset, buffer, size);\n\t\t  \n\t\t  // put the size in the space used when the size was marshaled.\n\t\t  if(buffer != NULL)\n\t\t      UINT16_TO_BYTE_ARRAY(amount, marshaledSize);\n\t\t  retVal += amount;\n\t\t  break;\n\t      }\n\t  case LIST_MTYPE:\n\t      {\n\t\t  ListMarshal_mst *    mlt = ((ListMarshal_mst *)sel);\n\t\t  UINT8               *offset = _source + (mlt->modifiers & SIGNED_MASK);\n\t\t  retVal = Marshal(UINT32_MARSHAL_REF, source, buffer, size);\n\t\t  retVal += ArrayMarshal((marshalIndex_t)(mlt->arrayRef), offset,\n\t\t\t\t\t buffer, size, *((UINT32 *)source));\n\t\t  break;\n\t      }\n\t  case NULL_MTYPE:\n\t    retVal = 0;\n\t    break;\n\t  case ERROR_MTYPE:\n\t  default:\n\t      {\n\t\t  if(size != NULL)\n\t\t      *size = -1;\n\t\t  retVal = 0;\n\t\t  break;\n\t      }\n\t}\n    return retVal;\n    \n}\n#endif\n#endif // TABLE_DRIVEN_MARSHAL\n"
  },
  {
    "path": "ftpm-opensbi/src/TableMarshalData.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM Size Checks\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TableMarshalData.c 1628 2020-05-27 19:35:29Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* 9.10.8.2\tTableMarshalData.c */\n/* This file contains the data initializer used for the table-driven marshaling code. */\n\n#include \"Tpm.h\"\n#if TABLE_DRIVEN_MARSHAL\n#include \"TableMarshal.h\"\n#include \"Marshal.h\"\n\n/* The array marshaling table */\n\nArrayMarshal_mst   ArrayLookupTable[] = {\n    ARRAY_MARSHAL_ENTRY(UINT8),\n    ARRAY_MARSHAL_ENTRY(TPM_CC),\n    ARRAY_MARSHAL_ENTRY(TPMA_CC),\n    ARRAY_MARSHAL_ENTRY(TPM_ALG_ID),\n    ARRAY_MARSHAL_ENTRY(TPM_HANDLE),\n    ARRAY_MARSHAL_ENTRY(TPM2B_DIGEST),\n    ARRAY_MARSHAL_ENTRY(TPMT_HA),\n    ARRAY_MARSHAL_ENTRY(TPMS_PCR_SELECTION),\n    ARRAY_MARSHAL_ENTRY(TPMS_ALG_PROPERTY),\n    ARRAY_MARSHAL_ENTRY(TPMS_TAGGED_PROPERTY),\n    ARRAY_MARSHAL_ENTRY(TPMS_TAGGED_PCR_SELECT),\n    ARRAY_MARSHAL_ENTRY(TPM_ECC_CURVE),\n    ARRAY_MARSHAL_ENTRY(TPMS_TAGGED_POLICY),\n    ARRAY_MARSHAL_ENTRY(TPMS_ACT_DATA),\n    ARRAY_MARSHAL_ENTRY(TPMS_AC_OUTPUT)};\n\n/* The main marshaling structure */\n\nMarshalData_st MarshalData = {\n    // UINT8_DATA\n    {UINT_MTYPE, 0},\n    // UINT16_DATA\n    {UINT_MTYPE, 1},\n    // UINT32_DATA\n    {UINT_MTYPE, 2},\n    // UINT64_DATA\n    {UINT_MTYPE, 3},\n    // INT8_DATA\n    {UINT_MTYPE, 0 + IS_SIGNED},\n    // INT16_DATA\n    {UINT_MTYPE, 1 + IS_SIGNED},\n    // INT32_DATA\n    {UINT_MTYPE, 2 + IS_SIGNED},\n    // INT64_DATA\n    {UINT_MTYPE, 3 + IS_SIGNED},\n    // UINT0_DATA\n    {NULL_MTYPE, 0},\n    // TPM_ECC_CURVE_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_CURVE,\n     {TPM_ECC_NONE,\n      RANGE(1, 32, UINT16),\n      (UINT32)((ECC_NIST_P192 << 0) | (ECC_NIST_P224 << 1) | (ECC_NIST_P256 << 2) |\n\t       (ECC_NIST_P384 << 3) | (ECC_NIST_P521 << 4) | (ECC_BN_P256 << 15)  |\n\t       (ECC_BN_P638 << 16)  | (ECC_SM2_P256 << 31))}},\n    // TPM_CLOCK_ADJUST_DATA\n    {MIN_MAX_MTYPE, ONE_BYTES|IS_SIGNED, (UINT8)TPM_RC_VALUE,\n     {RANGE(TPM_CLOCK_COARSE_SLOWER, TPM_CLOCK_COARSE_FASTER, INT8)}},\n    // TPM_EO_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_VALUE,\n     {RANGE(TPM_EO_EQ, TPM_EO_BITCLEAR, UINT16)}},\n    // TPM_SU_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_VALUE, 2,\n     {TPM_SU_CLEAR, TPM_SU_STATE}},\n    // TPM_SE_DATA\n    {TABLE_MTYPE, ONE_BYTES, (UINT8)TPM_RC_VALUE, 3,\n     {TPM_SE_HMAC, TPM_SE_POLICY, TPM_SE_TRIAL}},\n    // TPM_CAP_DATA\n    {VALUES_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 1, 1,\n     {RANGE(TPM_CAP_ALGS, TPM_CAP_ACT, UINT32),\n      TPM_CAP_VENDOR_PROPERTY}},\n    // TPMA_ALGORITHM_DATA\n    {ATTRIBUTES_MTYPE, FOUR_BYTES, 0xFFFFF8F0},\n    // TPMA_OBJECT_DATA\n    {ATTRIBUTES_MTYPE, FOUR_BYTES, 0xFFF0F309},\n    // TPMA_SESSION_DATA\n    {ATTRIBUTES_MTYPE, ONE_BYTES, 0x00000018},\n    // TPMA_ACT_DATA\n    {ATTRIBUTES_MTYPE, FOUR_BYTES, 0xFFFFFFFC},\n    // TPMI_YES_NO_DATA\n    {TABLE_MTYPE, ONE_BYTES, (UINT8)TPM_RC_VALUE, 2,\n     {NO, YES}},\n    // TPMI_DH_OBJECT_DATA\n    {VALUES_MTYPE, FOUR_BYTES|TAKES_NULL, (UINT8)TPM_RC_VALUE, 2, 0,\n     {TPM_RH_NULL,\n      RANGE(TRANSIENT_FIRST, TRANSIENT_LAST, UINT32),\n      RANGE(PERSISTENT_FIRST, PERSISTENT_LAST, UINT32)}},\n    // TPMI_DH_PARENT_DATA\n    {VALUES_MTYPE, FOUR_BYTES|TAKES_NULL, (UINT8)TPM_RC_VALUE, 2, 3,\n     {TPM_RH_NULL,\n      RANGE(TRANSIENT_FIRST, TRANSIENT_LAST, UINT32),\n      RANGE(PERSISTENT_FIRST, PERSISTENT_LAST, UINT32),\n      TPM_RH_OWNER, TPM_RH_ENDORSEMENT, TPM_RH_PLATFORM}},\n    // TPMI_DH_PERSISTENT_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE,\n     {RANGE(PERSISTENT_FIRST, PERSISTENT_LAST, UINT32)}},\n    // TPMI_DH_ENTITY_DATA\n    {VALUES_MTYPE, FOUR_BYTES|TAKES_NULL, (UINT8)TPM_RC_VALUE, 5, 4,\n     {TPM_RH_NULL,\n      RANGE(TRANSIENT_FIRST, TRANSIENT_LAST, UINT32),\n      RANGE(PERSISTENT_FIRST, PERSISTENT_LAST, UINT32),\n      RANGE(NV_INDEX_FIRST, NV_INDEX_LAST, UINT32),\n      RANGE(PCR_FIRST, PCR_LAST, UINT32),\n      RANGE(TPM_RH_AUTH_00, TPM_RH_AUTH_FF, UINT32),\n      TPM_RH_OWNER, TPM_RH_LOCKOUT, TPM_RH_ENDORSEMENT, TPM_RH_PLATFORM}},\n    // TPMI_DH_PCR_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES|TAKES_NULL, (UINT8)TPM_RC_VALUE,\n     {TPM_RH_NULL,\n      RANGE(PCR_FIRST, PCR_LAST, UINT32)}},\n    // TPMI_SH_AUTH_SESSION_DATA\n    {VALUES_MTYPE, FOUR_BYTES|TAKES_NULL, (UINT8)TPM_RC_VALUE, 2, 0,\n     {TPM_RS_PW,\n      RANGE(HMAC_SESSION_FIRST, HMAC_SESSION_LAST, UINT32),\n      RANGE(POLICY_SESSION_FIRST, POLICY_SESSION_LAST, UINT32)}},\n    // TPMI_SH_HMAC_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE,\n     {RANGE(HMAC_SESSION_FIRST, HMAC_SESSION_LAST, UINT32)}},\n    // TPMI_SH_POLICY_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE,\n     {RANGE(POLICY_SESSION_FIRST, POLICY_SESSION_LAST, UINT32)}},\n    // TPMI_DH_CONTEXT_DATA\n    {VALUES_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 3, 0,\n     {RANGE(HMAC_SESSION_FIRST, HMAC_SESSION_LAST, UINT32),\n      RANGE(POLICY_SESSION_FIRST, POLICY_SESSION_LAST, UINT32),\n      RANGE(TRANSIENT_FIRST, TRANSIENT_LAST, UINT32)}},\n    // TPMI_DH_SAVED_DATA\n    {VALUES_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 2, 3,\n     {RANGE(HMAC_SESSION_FIRST, HMAC_SESSION_LAST, UINT32),\n      RANGE(POLICY_SESSION_FIRST, POLICY_SESSION_LAST, UINT32),\n      0x80000000, 0x80000001, 0x80000002}},\n    // TPMI_RH_HIERARCHY_DATA\n    {TABLE_MTYPE, FOUR_BYTES|TAKES_NULL, (UINT8)TPM_RC_VALUE, 3,\n     {TPM_RH_NULL,\n      TPM_RH_OWNER, TPM_RH_ENDORSEMENT, TPM_RH_PLATFORM}},\n    // TPMI_RH_ENABLES_DATA\n    {TABLE_MTYPE, FOUR_BYTES|TAKES_NULL, (UINT8)TPM_RC_VALUE, 4,\n     {TPM_RH_NULL,\n      TPM_RH_OWNER, TPM_RH_ENDORSEMENT, TPM_RH_PLATFORM, TPM_RH_PLATFORM_NV}},\n    // TPMI_RH_HIERARCHY_AUTH_DATA\n    {TABLE_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 4,\n     {TPM_RH_OWNER, TPM_RH_LOCKOUT, TPM_RH_ENDORSEMENT, TPM_RH_PLATFORM}},\n    // TPMI_RH_HIERARCHY_POLICY_DATA\n    {VALUES_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 1, 4,\n     {RANGE(TPM_RH_ACT_0, TPM_RH_ACT_F, UINT32),\n      TPM_RH_OWNER, TPM_RH_LOCKOUT, TPM_RH_ENDORSEMENT, TPM_RH_PLATFORM}},\n    // TPMI_RH_PLATFORM_DATA\n    {TABLE_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 1,\n     {TPM_RH_PLATFORM}},\n    // TPMI_RH_OWNER_DATA\n    {TABLE_MTYPE, FOUR_BYTES|TAKES_NULL, (UINT8)TPM_RC_VALUE, 1,\n     {TPM_RH_NULL,\n      TPM_RH_OWNER}},\n    // TPMI_RH_ENDORSEMENT_DATA\n    {TABLE_MTYPE, FOUR_BYTES|TAKES_NULL, (UINT8)TPM_RC_VALUE, 1,\n     {TPM_RH_NULL,\n      TPM_RH_ENDORSEMENT}},\n    // TPMI_RH_PROVISION_DATA\n    {TABLE_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 2,\n     {TPM_RH_OWNER, TPM_RH_PLATFORM}},\n    // TPMI_RH_CLEAR_DATA\n    {TABLE_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 2,\n     {TPM_RH_LOCKOUT, TPM_RH_PLATFORM}},\n    // TPMI_RH_NV_AUTH_DATA\n    {VALUES_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 1, 2,\n     {RANGE(NV_INDEX_FIRST, NV_INDEX_LAST, UINT32),\n      TPM_RH_OWNER, TPM_RH_PLATFORM}},\n    // TPMI_RH_LOCKOUT_DATA\n    {TABLE_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 1,\n     {TPM_RH_LOCKOUT}},\n    // TPMI_RH_NV_INDEX_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE,\n     {RANGE(NV_INDEX_FIRST, NV_INDEX_LAST, UINT32)}},\n    // TPMI_RH_AC_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE,\n     {RANGE(AC_FIRST, AC_LAST, UINT32)}},\n    // TPMI_RH_ACT_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE,\n     {RANGE(TPM_RH_ACT_0, TPM_RH_ACT_F, UINT32)}},\n    // TPMI_ALG_HASH_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_HASH,\n     {TPM_ALG_NULL,\n      RANGE(4, 41, UINT16),\n      (UINT32)((ALG_SHA1 << 0)   | (ALG_SHA256 << 7) | (ALG_SHA384 << 8) |\n\t       (ALG_SHA512 << 9) | (ALG_SM3_256 << 14)),\n      (UINT32)((ALG_SHA3_256 << 3)|(ALG_SHA3_384 << 4)|(ALG_SHA3_512 << 5))}},\n    // TPMI_ALG_ASYM_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_ASYMMETRIC,\n     {TPM_ALG_NULL,\n      RANGE(1, 35, UINT16),\n      (UINT32)((ALG_RSA << 0)),\n      (UINT32)((ALG_ECC << 2))}},\n    // TPMI_ALG_SYM_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_SYMMETRIC,\n     {TPM_ALG_NULL,\n      RANGE(3, 38, UINT16),\n      (UINT32)((ALG_TDES << 0)|(ALG_AES << 3)|(ALG_XOR << 7)|(ALG_SM4 << 16)),\n      (UINT32)((ALG_CAMELLIA << 3))}},\n    // TPMI_ALG_SYM_OBJECT_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_SYMMETRIC,\n     {TPM_ALG_NULL,\n      RANGE(3, 38, UINT16),\n      ((ALG_TDES << 0)|(ALG_AES << 3)|(ALG_SM4 << 16)),\n      ((ALG_CAMELLIA << 3))}},\n    // TPMI_ALG_SYM_MODE_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_MODE,\n     {TPM_ALG_NULL,\n      RANGE(63, 68, UINT16),\n      (UINT32)((ALG_CMAC << 0) | (ALG_CTR << 1)  | (ALG_OFB << 2) |\n\t       (ALG_CBC << 3) | (ALG_CFB << 4)  | (ALG_ECB << 5))}},\n    // TPMI_ALG_KDF_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_KDF,\n     {TPM_ALG_NULL,\n      RANGE(7, 34, UINT16),\n      (UINT32)((ALG_MGF1 << 0)            | (ALG_KDF1_SP800_56A << 25) |\n\t       (ALG_KDF2 << 26)           | (ALG_KDF1_SP800_108 << 27))}},\n    // TPMI_ALG_SIG_SCHEME_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_SCHEME,\n     {TPM_ALG_NULL,\n      RANGE(5, 28, UINT16),\n      (UINT32)((ALG_HMAC << 0)    | (ALG_RSASSA << 15) | (ALG_RSAPSS << 17) |\n\t       (ALG_ECDSA << 19)  | (ALG_ECDAA << 21)  | (ALG_SM2 << 22)    |\n\t       (ALG_ECSCHNORR << 23))}},\n    // TPMI_ECC_KEY_EXCHANGE_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_SCHEME,\n     {TPM_ALG_NULL,\n      RANGE(25, 29, UINT16),\n      (UINT32)((ALG_ECDH << 0)|(ALG_SM2 << 2)|(ALG_ECMQV << 4))}},\n    // TPMI_ST_COMMAND_TAG_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_BAD_TAG, 2,\n     {TPM_ST_NO_SESSIONS, TPM_ST_SESSIONS}},\n    // TPMI_ALG_MAC_SCHEME_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_SYMMETRIC,\n     {TPM_ALG_NULL,\n      RANGE(4, 63, UINT16),\n      (UINT32)((ALG_SHA1 << 0)   | (ALG_SHA256 << 7) | (ALG_SHA384 << 8) |\n\t       (ALG_SHA512 << 9) | (ALG_SM3_256 << 14)),\n      (UINT32)((ALG_SHA3_256 << 3) | (ALG_SHA3_384 << 4) | (ALG_SHA3_512 << 5) |\n\t       (ALG_CMAC << 27))}},\n    // TPMI_ALG_CIPHER_MODE_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_MODE,\n     {TPM_ALG_NULL,\n      RANGE(64, 68, UINT16),\n      (UINT32)((ALG_CTR << 0) | (ALG_OFB << 1) | (ALG_CBC << 2) | (ALG_CFB << 3) |\n\t       (ALG_ECB << 4))}},\n    // TPMS_EMPTY_DATA\n    {STRUCTURE_MTYPE, 1,\n     {SET_ELEMENT_TYPE(SIMPLE_STYPE), UINT0_MARSHAL_REF, 0}},\n    // TPMS_ALGORITHM_DESCRIPTION_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPM_ALG_ID_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DESCRIPTION, alg)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMA_ALGORITHM_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DESCRIPTION, attributes))}},\n    // TPMU_HA_DATA\n    {9, IS_ARRAY_UNION, (UINT16)(offsetof(TPMU_HA_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_SHA1,     (UINT32)TPM_ALG_SHA256,   (UINT32)TPM_ALG_SHA384,\n      (UINT32)TPM_ALG_SHA512,   (UINT32)TPM_ALG_SM3_256,  (UINT32)TPM_ALG_SHA3_256,\n      (UINT32)TPM_ALG_SHA3_384, (UINT32)TPM_ALG_SHA3_512, (UINT32)TPM_ALG_NULL},\n     {(UINT16)(SHA1_DIGEST_SIZE),     (UINT16)(SHA256_DIGEST_SIZE),\n      (UINT16)(SHA384_DIGEST_SIZE),   (UINT16)(SHA512_DIGEST_SIZE),\n      (UINT16)(SM3_256_DIGEST_SIZE),  (UINT16)(SHA3_256_DIGEST_SIZE),\n      (UINT16)(SHA3_384_DIGEST_SIZE), (UINT16)(SHA3_512_DIGEST_SIZE),\n      (UINT16)(0)}\n    },\n    // TPMT_HA_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_HASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_HA, hashAlg)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_HA_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_HA, digest))}},\n    // TPM2B_DIGEST_DATA\n    {TPM2B_MTYPE, Type00_MARSHAL_REF},\n    // TPM2B_DATA_DATA\n    {TPM2B_MTYPE, Type01_MARSHAL_REF},\n    // TPM2B_EVENT_DATA\n    {TPM2B_MTYPE, Type02_MARSHAL_REF},\n    // TPM2B_MAX_BUFFER_DATA\n    {TPM2B_MTYPE, Type03_MARSHAL_REF},\n    // TPM2B_MAX_NV_BUFFER_DATA\n    {TPM2B_MTYPE, Type04_MARSHAL_REF},\n    // TPM2B_TIMEOUT_DATA\n    {TPM2B_MTYPE, Type05_MARSHAL_REF},\n    // TPM2B_IV_DATA\n    {TPM2B_MTYPE, Type06_MARSHAL_REF},\n    // NULL_UNION_DATA\n    {0},\n    // TPM2B_NAME_DATA\n    {TPM2B_MTYPE, Type07_MARSHAL_REF},\n    // TPMS_PCR_SELECT_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(ONE_BYTES),\n\t    Type08_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_PCR_SELECT, sizeofSelect)),\n\t    SET_ELEMENT_TYPE(ARRAY_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    UINT8_ARRAY_MARSHAL_INDEX,\n\t    (UINT16)(offsetof(TPMS_PCR_SELECT, pcrSelect))}},\n    // TPMS_PCR_SELECTION_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_HASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_PCR_SELECTION, hash)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(ONE_BYTES),\n\t    Type08_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_PCR_SELECTION, sizeofSelect)),\n\t    SET_ELEMENT_TYPE(ARRAY_STYPE)|SET_ELEMENT_NUMBER(1),\n\t    UINT8_ARRAY_MARSHAL_INDEX,\n\t    (UINT16)(offsetof(TPMS_PCR_SELECTION, pcrSelect))}},\n    // TPMT_TK_CREATION_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    Type10_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_TK_CREATION, tag)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMI_RH_HIERARCHY_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMT_TK_CREATION, hierarchy)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_TK_CREATION, digest))}},\n    // TPMT_TK_VERIFIED_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    Type11_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_TK_VERIFIED, tag)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMI_RH_HIERARCHY_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMT_TK_VERIFIED, hierarchy)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_TK_VERIFIED, digest))}},\n    // TPMT_TK_AUTH_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    Type12_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_TK_AUTH, tag)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMI_RH_HIERARCHY_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMT_TK_AUTH, hierarchy)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_TK_AUTH, digest))}},\n    // TPMT_TK_HASHCHECK_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    Type13_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_TK_HASHCHECK, tag)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMI_RH_HIERARCHY_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMT_TK_HASHCHECK, hierarchy)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_TK_HASHCHECK, digest))}},\n    // TPMS_ALG_PROPERTY_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPM_ALG_ID_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALG_PROPERTY, alg)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMA_ALGORITHM_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALG_PROPERTY, algProperties))}},\n    // TPMS_TAGGED_PROPERTY_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPM_PT_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TAGGED_PROPERTY, property)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    UINT32_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TAGGED_PROPERTY, value))}},\n    // TPMS_TAGGED_PCR_SELECT_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPM_PT_PCR_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TAGGED_PCR_SELECT, tag)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(ONE_BYTES),\n\t    Type08_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TAGGED_PCR_SELECT, sizeofSelect)),\n\t    SET_ELEMENT_TYPE(ARRAY_STYPE)|SET_ELEMENT_NUMBER(1),\n\t    UINT8_ARRAY_MARSHAL_INDEX,\n\t    (UINT16)(offsetof(TPMS_TAGGED_PCR_SELECT, pcrSelect))}},\n    // TPMS_TAGGED_POLICY_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPM_HANDLE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TAGGED_POLICY, handle)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_HA_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TAGGED_POLICY, policyHash))}},\n    // TPMS_ACT_DATA_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPM_HANDLE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ACT_DATA, handle)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    UINT32_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ACT_DATA, timeout)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMA_ACT_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ACT_DATA, attributes))}},\n    // TPML_CC_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_CC, commandCodes)),\n     Type15_MARSHAL_REF,\n     TPM_CC_ARRAY_MARSHAL_INDEX},\n    // TPML_CCA_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_CCA, commandAttributes)),\n     Type15_MARSHAL_REF,\n     TPMA_CC_ARRAY_MARSHAL_INDEX},\n    // TPML_ALG_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_ALG, algorithms)),\n     Type17_MARSHAL_REF,\n     TPM_ALG_ID_ARRAY_MARSHAL_INDEX},\n    // TPML_HANDLE_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_HANDLE, handle)),\n     Type18_MARSHAL_REF,\n     TPM_HANDLE_ARRAY_MARSHAL_INDEX},\n    // TPML_DIGEST_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_DIGEST, digests)),\n     Type19_MARSHAL_REF,\n     TPM2B_DIGEST_ARRAY_MARSHAL_INDEX},\n    // TPML_DIGEST_VALUES_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_DIGEST_VALUES, digests)),\n     Type20_MARSHAL_REF,\n     TPMT_HA_ARRAY_MARSHAL_INDEX},\n    // TPML_PCR_SELECTION_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_PCR_SELECTION, pcrSelections)),\n     Type20_MARSHAL_REF,\n     TPMS_PCR_SELECTION_ARRAY_MARSHAL_INDEX},\n    // TPML_ALG_PROPERTY_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_ALG_PROPERTY, algProperties)),\n     Type22_MARSHAL_REF,\n     TPMS_ALG_PROPERTY_ARRAY_MARSHAL_INDEX},\n    // TPML_TAGGED_TPM_PROPERTY_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_TAGGED_TPM_PROPERTY, tpmProperty)),\n     Type23_MARSHAL_REF,\n     TPMS_TAGGED_PROPERTY_ARRAY_MARSHAL_INDEX},\n    // TPML_TAGGED_PCR_PROPERTY_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_TAGGED_PCR_PROPERTY, pcrProperty)),\n     Type24_MARSHAL_REF,\n     TPMS_TAGGED_PCR_SELECT_ARRAY_MARSHAL_INDEX},\n    // TPML_ECC_CURVE_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_ECC_CURVE, eccCurves)),\n     Type25_MARSHAL_REF,\n     TPM_ECC_CURVE_ARRAY_MARSHAL_INDEX},\n    // TPML_TAGGED_POLICY_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_TAGGED_POLICY, policies)),\n     Type26_MARSHAL_REF,\n     TPMS_TAGGED_POLICY_ARRAY_MARSHAL_INDEX},\n    // TPML_ACT_DATA_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_ACT_DATA, actData)),\n     Type27_MARSHAL_REF,\n     TPMS_ACT_DATA_ARRAY_MARSHAL_INDEX},\n    // TPMU_CAPABILITIES_DATA\n    {11, 0, (UINT16)(offsetof(TPMU_CAPABILITIES_mst, marshalingTypes)),\n     {(UINT32)TPM_CAP_ALGS,           (UINT32)TPM_CAP_HANDLES,\n      (UINT32)TPM_CAP_COMMANDS,       (UINT32)TPM_CAP_PP_COMMANDS,\n      (UINT32)TPM_CAP_AUDIT_COMMANDS, (UINT32)TPM_CAP_PCRS,\n      (UINT32)TPM_CAP_TPM_PROPERTIES, (UINT32)TPM_CAP_PCR_PROPERTIES,\n      (UINT32)TPM_CAP_ECC_CURVES,     (UINT32)TPM_CAP_AUTH_POLICIES,\n      (UINT32)TPM_CAP_ACT},\n     {(UINT16)(TPML_ALG_PROPERTY_MARSHAL_REF),\n      (UINT16)(TPML_HANDLE_MARSHAL_REF),\n      (UINT16)(TPML_CCA_MARSHAL_REF),\n      (UINT16)(TPML_CC_MARSHAL_REF),\n      (UINT16)(TPML_CC_MARSHAL_REF),\n      (UINT16)(TPML_PCR_SELECTION_MARSHAL_REF),\n      (UINT16)(TPML_TAGGED_TPM_PROPERTY_MARSHAL_REF),\n      (UINT16)(TPML_TAGGED_PCR_PROPERTY_MARSHAL_REF),\n      (UINT16)(TPML_ECC_CURVE_MARSHAL_REF),\n      (UINT16)(TPML_TAGGED_POLICY_MARSHAL_REF),\n      (UINT16)(TPML_ACT_DATA_MARSHAL_REF)}\n    },\n    // TPMS_CAPABILITY_DATA_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPM_CAP_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CAPABILITY_DATA, capability)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_CAPABILITIES_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CAPABILITY_DATA, data))}},\n    // TPMS_CLOCK_INFO_DATA\n    {STRUCTURE_MTYPE, 4, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(EIGHT_BYTES),\n\t    UINT64_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CLOCK_INFO, clock)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    UINT32_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CLOCK_INFO, resetCount)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    UINT32_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CLOCK_INFO, restartCount)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(ONE_BYTES),\n\t    TPMI_YES_NO_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CLOCK_INFO, safe))}},\n    // TPMS_TIME_INFO_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(EIGHT_BYTES),\n\t    UINT64_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TIME_INFO, time)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMS_CLOCK_INFO_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TIME_INFO, clockInfo))}},\n    // TPMS_TIME_ATTEST_INFO_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMS_TIME_INFO_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TIME_ATTEST_INFO, time)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(EIGHT_BYTES),\n\t    UINT64_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_TIME_ATTEST_INFO, firmwareVersion))}},\n    // TPMS_CERTIFY_INFO_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NAME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CERTIFY_INFO, name)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NAME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CERTIFY_INFO, qualifiedName))}},\n    // TPMS_QUOTE_INFO_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPML_PCR_SELECTION_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_QUOTE_INFO, pcrSelect)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_QUOTE_INFO, pcrDigest))}},\n    // TPMS_COMMAND_AUDIT_INFO_DATA\n    {STRUCTURE_MTYPE, 4, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(EIGHT_BYTES),\n\t    UINT64_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_COMMAND_AUDIT_INFO, auditCounter)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPM_ALG_ID_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_COMMAND_AUDIT_INFO, digestAlg)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_COMMAND_AUDIT_INFO, auditDigest)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_COMMAND_AUDIT_INFO, commandDigest))}},\n    // TPMS_SESSION_AUDIT_INFO_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(ONE_BYTES),\n\t    TPMI_YES_NO_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SESSION_AUDIT_INFO, exclusiveSession)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SESSION_AUDIT_INFO, sessionDigest))}},\n    // TPMS_CREATION_INFO_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NAME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CREATION_INFO, objectName)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CREATION_INFO, creationHash))}},\n    // TPMS_NV_CERTIFY_INFO_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NAME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_CERTIFY_INFO, indexName)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    UINT16_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_CERTIFY_INFO, offset)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_MAX_NV_BUFFER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_CERTIFY_INFO, nvContents))}},\n    // TPMS_NV_DIGEST_CERTIFY_INFO_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NAME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_DIGEST_CERTIFY_INFO, indexName)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_DIGEST_CERTIFY_INFO, nvDigest))}},\n    // TPMI_ST_ATTEST_DATA\n    {VALUES_MTYPE, TWO_BYTES, (UINT8)TPM_RC_VALUE, 1, 1,\n     {RANGE(TPM_ST_ATTEST_NV, TPM_ST_ATTEST_CREATION, UINT16),\n      TPM_ST_ATTEST_NV_DIGEST}},\n    // TPMU_ATTEST_DATA\n    {8, 0, (UINT16)(offsetof(TPMU_ATTEST_mst, marshalingTypes)),\n     {(UINT32)TPM_ST_ATTEST_CERTIFY,       (UINT32)TPM_ST_ATTEST_CREATION,\n      (UINT32)TPM_ST_ATTEST_QUOTE,         (UINT32)TPM_ST_ATTEST_COMMAND_AUDIT,\n      (UINT32)TPM_ST_ATTEST_SESSION_AUDIT, (UINT32)TPM_ST_ATTEST_TIME,\n      (UINT32)TPM_ST_ATTEST_NV,            (UINT32)TPM_ST_ATTEST_NV_DIGEST},\n     {(UINT16)(TPMS_CERTIFY_INFO_MARSHAL_REF),\n      (UINT16)(TPMS_CREATION_INFO_MARSHAL_REF),\n      (UINT16)(TPMS_QUOTE_INFO_MARSHAL_REF),\n      (UINT16)(TPMS_COMMAND_AUDIT_INFO_MARSHAL_REF),\n      (UINT16)(TPMS_SESSION_AUDIT_INFO_MARSHAL_REF),\n      (UINT16)(TPMS_TIME_ATTEST_INFO_MARSHAL_REF),\n      (UINT16)(TPMS_NV_CERTIFY_INFO_MARSHAL_REF),\n      (UINT16)(TPMS_NV_DIGEST_CERTIFY_INFO_MARSHAL_REF)}\n    },\n    // TPMS_ATTEST_DATA\n    {STRUCTURE_MTYPE, 7, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPM_CONSTANTS32_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ATTEST, magic)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ST_ATTEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ATTEST, type)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NAME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ATTEST, qualifiedSigner)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DATA_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ATTEST, extraData)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMS_CLOCK_INFO_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ATTEST, clockInfo)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(EIGHT_BYTES),\n\t    UINT64_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ATTEST, firmwareVersion)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(1),\n\t    TPMU_ATTEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ATTEST, attested))}},\n    // TPM2B_ATTEST_DATA\n    {TPM2B_MTYPE, Type28_MARSHAL_REF},\n    // TPMS_AUTH_COMMAND_DATA\n    {STRUCTURE_MTYPE, 4, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMI_SH_AUTH_SESSION_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_AUTH_COMMAND, sessionHandle)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NONCE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_AUTH_COMMAND, nonce)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(ONE_BYTES),\n\t    TPMA_SESSION_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_AUTH_COMMAND, sessionAttributes)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_AUTH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_AUTH_COMMAND, hmac))}},\n    // TPMS_AUTH_RESPONSE_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NONCE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_AUTH_RESPONSE, nonce)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(ONE_BYTES),\n\t    TPMA_SESSION_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_AUTH_RESPONSE, sessionAttributes)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_AUTH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_AUTH_RESPONSE, hmac))}},\n    // TPMI_TDES_KEY_BITS_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_VALUE, 1,\n     {128*TDES_128}},\n    // TPMI_AES_KEY_BITS_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_VALUE, 3,\n     {192*AES_192, 128*AES_128, 256*AES_256}},\n    // TPMI_SM4_KEY_BITS_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_VALUE, 1,\n     {128*SM4_128}},\n    // TPMI_CAMELLIA_KEY_BITS_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_VALUE, 3,\n     {192*CAMELLIA_192, 128*CAMELLIA_128, 256*CAMELLIA_256}},\n    // TPMU_SYM_KEY_BITS_DATA\n    {6, 0, (UINT16)(offsetof(TPMU_SYM_KEY_BITS_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_TDES,     (UINT32)TPM_ALG_AES,      (UINT32)TPM_ALG_SM4,\n      (UINT32)TPM_ALG_CAMELLIA, (UINT32)TPM_ALG_XOR,      (UINT32)TPM_ALG_NULL},\n     {(UINT16)(TPMI_TDES_KEY_BITS_MARSHAL_REF),\n      (UINT16)(TPMI_AES_KEY_BITS_MARSHAL_REF),\n      (UINT16)(TPMI_SM4_KEY_BITS_MARSHAL_REF),\n      (UINT16)(TPMI_CAMELLIA_KEY_BITS_MARSHAL_REF),\n      (UINT16)(TPMI_ALG_HASH_MARSHAL_REF),\n      (UINT16)(UINT0_MARSHAL_REF)}\n    },\n    // TPMU_SYM_MODE_DATA\n    {6, 0, (UINT16)(offsetof(TPMU_SYM_MODE_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_TDES,     (UINT32)TPM_ALG_AES,      (UINT32)TPM_ALG_SM4,\n      (UINT32)TPM_ALG_CAMELLIA, (UINT32)TPM_ALG_XOR,      (UINT32)TPM_ALG_NULL},\n     {(UINT16)(TPMI_ALG_SYM_MODE_MARSHAL_REF|NULL_FLAG),\n      (UINT16)(TPMI_ALG_SYM_MODE_MARSHAL_REF|NULL_FLAG),\n      (UINT16)(TPMI_ALG_SYM_MODE_MARSHAL_REF|NULL_FLAG),\n      (UINT16)(TPMI_ALG_SYM_MODE_MARSHAL_REF|NULL_FLAG),\n      (UINT16)(UINT0_MARSHAL_REF),\n      (UINT16)(UINT0_MARSHAL_REF)}\n    },\n    // TPMT_SYM_DEF_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_SYM_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SYM_DEF, algorithm)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_SYM_KEY_BITS_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SYM_DEF, keyBits)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_SYM_MODE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SYM_DEF, mode))}},\n    // TPMT_SYM_DEF_OBJECT_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_SYM_OBJECT_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SYM_DEF_OBJECT, algorithm)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_SYM_KEY_BITS_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SYM_DEF_OBJECT, keyBits)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_SYM_MODE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SYM_DEF_OBJECT, mode))}},\n    // TPM2B_SYM_KEY_DATA\n    {TPM2B_MTYPE, Type29_MARSHAL_REF},\n    // TPMS_SYMCIPHER_PARMS_DATA\n    {STRUCTURE_MTYPE, 1, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_SYM_DEF_OBJECT_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SYMCIPHER_PARMS, sym))}},\n    // TPM2B_LABEL_DATA\n    {TPM2B_MTYPE, Type30_MARSHAL_REF},\n    // TPMS_DERIVE_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_LABEL_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_DERIVE, label)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_LABEL_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_DERIVE, context))}},\n    // TPM2B_DERIVE_DATA\n    {TPM2B_MTYPE, Type31_MARSHAL_REF},\n    // TPM2B_SENSITIVE_DATA_DATA\n    {TPM2B_MTYPE, Type32_MARSHAL_REF},\n    // TPMS_SENSITIVE_CREATE_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_AUTH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SENSITIVE_CREATE, userAuth)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_SENSITIVE_DATA_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SENSITIVE_CREATE, data))}},\n    // TPM2B_SENSITIVE_CREATE_DATA\n    {TPM2BS_MTYPE,\n     (UINT8)(offsetof(TPM2B_SENSITIVE_CREATE, sensitive))|SIZE_EQUAL,\n     UINT16_MARSHAL_REF,\n     TPMS_SENSITIVE_CREATE_MARSHAL_REF},\n    // TPMS_SCHEME_HASH_DATA\n    {STRUCTURE_MTYPE, 1, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_HASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SCHEME_HASH, hashAlg))}},\n    // TPMS_SCHEME_ECDAA_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_HASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SCHEME_ECDAA, hashAlg)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    UINT16_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SCHEME_ECDAA, count))}},\n    // TPMI_ALG_KEYEDHASH_SCHEME_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_VALUE,\n     {TPM_ALG_NULL,\n      RANGE(5, 10, UINT16),\n      (UINT32)((ALG_HMAC << 0) | (ALG_XOR << 5))}},\n    // TPMS_SCHEME_XOR_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_HASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SCHEME_XOR, hashAlg)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_KDF_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_SCHEME_XOR, kdf))}},\n    // TPMU_SCHEME_KEYEDHASH_DATA\n    {3, 0, (UINT16)(offsetof(TPMU_SCHEME_KEYEDHASH_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_HMAC, (UINT32)TPM_ALG_XOR, (UINT32)TPM_ALG_NULL},\n     {(UINT16)(TPMS_SCHEME_HMAC_MARSHAL_REF),\n      (UINT16)(TPMS_SCHEME_XOR_MARSHAL_REF),\n      (UINT16)(UINT0_MARSHAL_REF)}\n    },\n    // TPMT_KEYEDHASH_SCHEME_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_KEYEDHASH_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_KEYEDHASH_SCHEME, scheme)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_SCHEME_KEYEDHASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_KEYEDHASH_SCHEME, details))}},\n    // TPMU_SIG_SCHEME_DATA\n    {8, 0, (UINT16)(offsetof(TPMU_SIG_SCHEME_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_ECDAA,     (UINT32)TPM_ALG_RSASSA,\n      (UINT32)TPM_ALG_RSAPSS,    (UINT32)TPM_ALG_ECDSA,\n      (UINT32)TPM_ALG_SM2,       (UINT32)TPM_ALG_ECSCHNORR,\n      (UINT32)TPM_ALG_HMAC,      (UINT32)TPM_ALG_NULL},\n     {(UINT16)(TPMS_SIG_SCHEME_ECDAA_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_RSASSA_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_RSAPSS_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_ECDSA_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_SM2_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_ECSCHNORR_MARSHAL_REF),\n      (UINT16)(TPMS_SCHEME_HMAC_MARSHAL_REF),\n      (UINT16)(UINT0_MARSHAL_REF)}\n    },\n    // TPMT_SIG_SCHEME_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_SIG_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SIG_SCHEME, scheme)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_SIG_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SIG_SCHEME, details))}},\n    // TPMU_KDF_SCHEME_DATA\n    {5, 0, (UINT16)(offsetof(TPMU_KDF_SCHEME_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_MGF1,           (UINT32)TPM_ALG_KDF1_SP800_56A,\n      (UINT32)TPM_ALG_KDF2,           (UINT32)TPM_ALG_KDF1_SP800_108,\n      (UINT32)TPM_ALG_NULL},\n     {(UINT16)(TPMS_SCHEME_MGF1_MARSHAL_REF),\n      (UINT16)(TPMS_SCHEME_KDF1_SP800_56A_MARSHAL_REF),\n      (UINT16)(TPMS_SCHEME_KDF2_MARSHAL_REF),\n      (UINT16)(TPMS_SCHEME_KDF1_SP800_108_MARSHAL_REF),\n      (UINT16)(UINT0_MARSHAL_REF)}\n    },\n    // TPMT_KDF_SCHEME_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_KDF_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_KDF_SCHEME, scheme)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_KDF_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_KDF_SCHEME, details))}},\n    // TPMI_ALG_ASYM_SCHEME_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_VALUE,\n     {TPM_ALG_NULL,\n      RANGE(20, 29, UINT16),\n      (UINT32)((ALG_RSASSA << 0)    | (ALG_RSAES << 1)     | (ALG_RSAPSS << 2)    |\n\t       (ALG_OAEP << 3)      | (ALG_ECDSA << 4)     | (ALG_ECDH << 5)      |\n\t       (ALG_ECDAA << 6)     | (ALG_SM2 << 7)       | (ALG_ECSCHNORR << 8) |\n\t       (ALG_ECMQV << 9))}},\n    // TPMU_ASYM_SCHEME_DATA\n    {11, 0, (UINT16)(offsetof(TPMU_ASYM_SCHEME_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_ECDH,      (UINT32)TPM_ALG_ECMQV,\n      (UINT32)TPM_ALG_ECDAA,     (UINT32)TPM_ALG_RSASSA,\n      (UINT32)TPM_ALG_RSAPSS,    (UINT32)TPM_ALG_ECDSA,\n      (UINT32)TPM_ALG_SM2,       (UINT32)TPM_ALG_ECSCHNORR,\n      (UINT32)TPM_ALG_RSAES,     (UINT32)TPM_ALG_OAEP,\n      (UINT32)TPM_ALG_NULL},\n     {(UINT16)(TPMS_KEY_SCHEME_ECDH_MARSHAL_REF),\n      (UINT16)(TPMS_KEY_SCHEME_ECMQV_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_ECDAA_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_RSASSA_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_RSAPSS_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_ECDSA_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_SM2_MARSHAL_REF),\n      (UINT16)(TPMS_SIG_SCHEME_ECSCHNORR_MARSHAL_REF),\n      (UINT16)(TPMS_ENC_SCHEME_RSAES_MARSHAL_REF),\n      (UINT16)(TPMS_ENC_SCHEME_OAEP_MARSHAL_REF),\n      (UINT16)(UINT0_MARSHAL_REF)}\n    },\n    // TPMI_ALG_RSA_SCHEME_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_VALUE,\n     {TPM_ALG_NULL,\n      RANGE(20, 23, UINT16),\n      ((ALG_RSASSA << 0)|(ALG_RSAES << 1)|(ALG_RSAPSS << 2)|(ALG_OAEP << 3))}},\n    // TPMT_RSA_SCHEME_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_RSA_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_RSA_SCHEME, scheme)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_ASYM_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_RSA_SCHEME, details))}},\n    // TPMI_ALG_RSA_DECRYPT_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_VALUE,\n     {TPM_ALG_NULL,\n      RANGE(21, 23, UINT16),\n      (UINT32)((ALG_RSAES << 0) | (ALG_OAEP << 2))}},\n    // TPMT_RSA_DECRYPT_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_RSA_DECRYPT_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_RSA_DECRYPT, scheme)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_ASYM_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_RSA_DECRYPT, details))}},\n    // TPM2B_PUBLIC_KEY_RSA_DATA\n    {TPM2B_MTYPE, Type33_MARSHAL_REF},\n    // TPMI_RSA_KEY_BITS_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_VALUE, 3,\n     {3072*RSA_3072, 1024*RSA_1024, 2048*RSA_2048}},\n    // TPM2B_PRIVATE_KEY_RSA_DATA\n    {TPM2B_MTYPE, Type34_MARSHAL_REF},\n    // TPM2B_ECC_PARAMETER_DATA\n    {TPM2B_MTYPE, Type35_MARSHAL_REF},\n    // TPMS_ECC_POINT_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ECC_POINT, x)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ECC_POINT, y))}},\n    // TPM2B_ECC_POINT_DATA\n    {TPM2BS_MTYPE,\n     (UINT8)(offsetof(TPM2B_ECC_POINT, point))|SIZE_EQUAL,\n     UINT16_MARSHAL_REF,\n     TPMS_ECC_POINT_MARSHAL_REF},\n    // TPMI_ALG_ECC_SCHEME_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|TAKES_NULL|HAS_BITS, (UINT8)TPM_RC_SCHEME,\n     {TPM_ALG_NULL,\n      RANGE(24, 29, UINT16),\n      (UINT32)((ALG_ECDSA << 0)     | (ALG_ECDH << 1)      | (ALG_ECDAA << 2)     |\n\t       (ALG_SM2 << 3)       | (ALG_ECSCHNORR << 4) | (ALG_ECMQV << 5))}},\n    // TPMI_ECC_CURVE_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES | HAS_BITS, (UINT8)TPM_RC_CURVE,\n     {RANGE(1, 32, UINT16),\n      (UINT32)((ECC_NIST_P192 << 0) | (ECC_NIST_P224 << 1) | (ECC_NIST_P256 << 2) |\n\t       (ECC_NIST_P384 << 3) | (ECC_NIST_P521 << 4) | (ECC_BN_P256 << 15)  |\n\t       (ECC_BN_P638 << 16)  | (ECC_SM2_P256 << 31))}},\n    // TPMT_ECC_SCHEME_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_ECC_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_ECC_SCHEME, scheme)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_ASYM_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_ECC_SCHEME, details))}},\n    // TPMS_ALGORITHM_DETAIL_ECC_DATA\n    {STRUCTURE_MTYPE, 11, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPM_ECC_CURVE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, curveID)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    UINT16_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, keySize)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_KDF_SCHEME_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, kdf)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_ECC_SCHEME_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, sign)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, p)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, a)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, b)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, gX)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, gY)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, n)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ALGORITHM_DETAIL_ECC, h))}},\n    // TPMS_SIGNATURE_RSA_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_HASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SIGNATURE_RSA, hash)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_PUBLIC_KEY_RSA_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SIGNATURE_RSA, sig))}},\n    // TPMS_SIGNATURE_ECC_DATA\n    {STRUCTURE_MTYPE, 3, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_HASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SIGNATURE_ECC, hash)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SIGNATURE_ECC, signatureR)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_ECC_PARAMETER_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_SIGNATURE_ECC, signatureS))}},\n    // TPMU_SIGNATURE_DATA\n    {8, 0, (UINT16)(offsetof(TPMU_SIGNATURE_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_ECDAA,     (UINT32)TPM_ALG_RSASSA,\n      (UINT32)TPM_ALG_RSAPSS,    (UINT32)TPM_ALG_ECDSA,\n      (UINT32)TPM_ALG_SM2,       (UINT32)TPM_ALG_ECSCHNORR,\n      (UINT32)TPM_ALG_HMAC,      (UINT32)TPM_ALG_NULL},\n     {(UINT16)(TPMS_SIGNATURE_ECDAA_MARSHAL_REF),\n      (UINT16)(TPMS_SIGNATURE_RSASSA_MARSHAL_REF),\n      (UINT16)(TPMS_SIGNATURE_RSAPSS_MARSHAL_REF),\n      (UINT16)(TPMS_SIGNATURE_ECDSA_MARSHAL_REF),\n      (UINT16)(TPMS_SIGNATURE_SM2_MARSHAL_REF),\n      (UINT16)(TPMS_SIGNATURE_ECSCHNORR_MARSHAL_REF),\n      (UINT16)(TPMT_HA_MARSHAL_REF),\n      (UINT16)(UINT0_MARSHAL_REF)}\n    },\n    // TPMT_SIGNATURE_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_SIG_SCHEME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SIGNATURE, sigAlg)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_SIGNATURE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SIGNATURE, signature))}},\n    // TPMU_ENCRYPTED_SECRET_DATA\n    {4, IS_ARRAY_UNION, (UINT16)(offsetof(TPMU_ENCRYPTED_SECRET_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_ECC,       (UINT32)TPM_ALG_RSA,\n      (UINT32)TPM_ALG_SYMCIPHER, (UINT32)TPM_ALG_KEYEDHASH},\n     {(UINT16)(sizeof(TPMS_ECC_POINT)), (UINT16)(MAX_RSA_KEY_BYTES),\n      (UINT16)(sizeof(TPM2B_DIGEST)),   (UINT16)(sizeof(TPM2B_DIGEST))}\n    },\n    // TPM2B_ENCRYPTED_SECRET_DATA\n    {TPM2B_MTYPE, Type36_MARSHAL_REF},\n    // TPMI_ALG_PUBLIC_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES|HAS_BITS, (UINT8)TPM_RC_TYPE,\n     {RANGE(1, 37, UINT16),\n      (UINT32)((ALG_RSA << 0)|(ALG_KEYEDHASH << 7)),\n      (UINT32)((ALG_ECC << 2)|(ALG_SYMCIPHER << 4))}},\n    // TPMU_PUBLIC_ID_DATA\n    {4, 0, (UINT16)(offsetof(TPMU_PUBLIC_ID_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_KEYEDHASH, (UINT32)TPM_ALG_SYMCIPHER,\n      (UINT32)TPM_ALG_RSA,       (UINT32)TPM_ALG_ECC},\n     {(UINT16)(TPM2B_DIGEST_MARSHAL_REF),\n      (UINT16)(TPM2B_DIGEST_MARSHAL_REF),\n      (UINT16)(TPM2B_PUBLIC_KEY_RSA_MARSHAL_REF),\n      (UINT16)(TPMS_ECC_POINT_MARSHAL_REF)}\n    },\n    // TPMS_KEYEDHASH_PARMS_DATA\n    {STRUCTURE_MTYPE, 1, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_KEYEDHASH_SCHEME_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_KEYEDHASH_PARMS, scheme))}},\n    // TPMS_RSA_PARMS_DATA\n    {STRUCTURE_MTYPE, 4, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_SYM_DEF_OBJECT_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_RSA_PARMS, symmetric)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_RSA_SCHEME_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_RSA_PARMS, scheme)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_RSA_KEY_BITS_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_RSA_PARMS, keyBits)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    UINT32_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_RSA_PARMS, exponent))}},\n    // TPMS_ECC_PARMS_DATA\n    {STRUCTURE_MTYPE, 4, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_SYM_DEF_OBJECT_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_ECC_PARMS, symmetric)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_ECC_SCHEME_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_ECC_PARMS, scheme)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ECC_CURVE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_ECC_PARMS, curveID)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPMT_KDF_SCHEME_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_ECC_PARMS, kdf))}},\n    // TPMU_PUBLIC_PARMS_DATA\n    {4, 0, (UINT16)(offsetof(TPMU_PUBLIC_PARMS_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_KEYEDHASH, (UINT32)TPM_ALG_SYMCIPHER,\n      (UINT32)TPM_ALG_RSA,       (UINT32)TPM_ALG_ECC},\n     {(UINT16)(TPMS_KEYEDHASH_PARMS_MARSHAL_REF),\n      (UINT16)(TPMS_SYMCIPHER_PARMS_MARSHAL_REF),\n      (UINT16)(TPMS_RSA_PARMS_MARSHAL_REF),\n      (UINT16)(TPMS_ECC_PARMS_MARSHAL_REF)}\n    },\n    // TPMT_PUBLIC_PARMS_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_PUBLIC_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_PUBLIC_PARMS, type)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_PUBLIC_PARMS_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_PUBLIC_PARMS, parameters))}},\n    // TPMT_PUBLIC_DATA\n    {STRUCTURE_MTYPE, 6, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_PUBLIC_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_PUBLIC, type)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES)|ELEMENT_PROPAGATE,\n\t    TPMI_ALG_HASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_PUBLIC, nameAlg)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMA_OBJECT_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_PUBLIC, objectAttributes)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_PUBLIC, authPolicy)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_PUBLIC_PARMS_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_PUBLIC, parameters)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_PUBLIC_ID_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_PUBLIC, unique))}},\n    // TPM2B_PUBLIC_DATA\n    {TPM2BS_MTYPE,\n     (UINT8)(offsetof(TPM2B_PUBLIC, publicArea))|SIZE_EQUAL|ELEMENT_PROPAGATE,\n     UINT16_MARSHAL_REF,\n     TPMT_PUBLIC_MARSHAL_REF},\n    // TPM2B_TEMPLATE_DATA\n    {TPM2B_MTYPE, Type37_MARSHAL_REF},\n    // TPM2B_PRIVATE_VENDOR_SPECIFIC_DATA\n    {TPM2B_MTYPE, Type38_MARSHAL_REF},\n    // TPMU_SENSITIVE_COMPOSITE_DATA\n    {4, 0, (UINT16)(offsetof(TPMU_SENSITIVE_COMPOSITE_mst, marshalingTypes)),\n     {(UINT32)TPM_ALG_RSA,       (UINT32)TPM_ALG_ECC,\n      (UINT32)TPM_ALG_KEYEDHASH, (UINT32)TPM_ALG_SYMCIPHER},\n     {(UINT16)(TPM2B_PRIVATE_KEY_RSA_MARSHAL_REF),\n      (UINT16)(TPM2B_ECC_PARAMETER_MARSHAL_REF),\n      (UINT16)(TPM2B_SENSITIVE_DATA_MARSHAL_REF),\n      (UINT16)(TPM2B_SYM_KEY_MARSHAL_REF)}\n    },\n    // TPMT_SENSITIVE_DATA\n    {STRUCTURE_MTYPE, 4, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_PUBLIC_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SENSITIVE, sensitiveType)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_AUTH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SENSITIVE, authValue)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SENSITIVE, seedValue)),\n\t    SET_ELEMENT_TYPE(UNION_STYPE)|SET_ELEMENT_NUMBER(0),\n\t    TPMU_SENSITIVE_COMPOSITE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMT_SENSITIVE, sensitive))}},\n    // TPM2B_SENSITIVE_DATA\n    {TPM2BS_MTYPE,\n     (UINT8)(offsetof(TPM2B_SENSITIVE, sensitiveArea)),\n     UINT16_MARSHAL_REF,\n     TPMT_SENSITIVE_MARSHAL_REF},\n    // TPM2B_PRIVATE_DATA\n    {TPM2B_MTYPE, Type39_MARSHAL_REF},\n    // TPM2B_ID_OBJECT_DATA\n    {TPM2B_MTYPE, Type40_MARSHAL_REF},\n    // TPMS_NV_PIN_COUNTER_PARAMETERS_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    UINT32_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_PIN_COUNTER_PARAMETERS, pinCount)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    UINT32_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_PIN_COUNTER_PARAMETERS, pinLimit))}},\n    // TPMA_NV_DATA\n    {ATTRIBUTES_MTYPE, FOUR_BYTES, 0x01F00300},\n    // TPMS_NV_PUBLIC_DATA\n    {STRUCTURE_MTYPE, 5, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMI_RH_NV_INDEX_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_PUBLIC, nvIndex)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPMI_ALG_HASH_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_PUBLIC, nameAlg)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMA_NV_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_PUBLIC, attributes)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_PUBLIC, authPolicy)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    Type41_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_NV_PUBLIC, dataSize))}},\n    // TPM2B_NV_PUBLIC_DATA\n    {TPM2BS_MTYPE,\n     (UINT8)(offsetof(TPM2B_NV_PUBLIC, nvPublic))|SIZE_EQUAL,\n     UINT16_MARSHAL_REF,\n     TPMS_NV_PUBLIC_MARSHAL_REF},\n    // TPM2B_CONTEXT_SENSITIVE_DATA\n    {TPM2B_MTYPE, Type42_MARSHAL_REF},\n    // TPMS_CONTEXT_DATA_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CONTEXT_DATA, integrity)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_CONTEXT_SENSITIVE_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CONTEXT_DATA, encrypted))}},\n    // TPM2B_CONTEXT_DATA_DATA\n    {TPM2B_MTYPE, Type43_MARSHAL_REF},\n    // TPMS_CONTEXT_DATA\n    {STRUCTURE_MTYPE, 4, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(EIGHT_BYTES),\n\t    UINT64_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CONTEXT, sequence)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMI_DH_SAVED_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CONTEXT, savedHandle)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPMI_RH_HIERARCHY_MARSHAL_REF|NULL_FLAG,\n\t    (UINT16)(offsetof(TPMS_CONTEXT, hierarchy)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_CONTEXT_DATA_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CONTEXT, contextBlob))}},\n    // TPMS_CREATION_DATA_DATA\n    {STRUCTURE_MTYPE, 7, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPML_PCR_SELECTION_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CREATION_DATA, pcrSelect)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DIGEST_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CREATION_DATA, pcrDigest)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(ONE_BYTES),\n\t    TPMA_LOCALITY_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CREATION_DATA, locality)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(TWO_BYTES),\n\t    TPM_ALG_ID_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CREATION_DATA, parentNameAlg)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NAME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CREATION_DATA, parentName)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_NAME_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CREATION_DATA, parentQualifiedName)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE),\n\t    TPM2B_DATA_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_CREATION_DATA, outsideInfo))}},\n    // TPM2B_CREATION_DATA_DATA\n    {TPM2BS_MTYPE,\n     (UINT8)(offsetof(TPM2B_CREATION_DATA, creationData))|SIZE_EQUAL,\n     UINT16_MARSHAL_REF,\n     TPMS_CREATION_DATA_MARSHAL_REF},\n    // TPM_AT_DATA\n    {TABLE_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_VALUE, 4,\n     {TPM_AT_ANY, TPM_AT_ERROR, TPM_AT_PV1, TPM_AT_VEND}},\n    // TPMS_AC_OUTPUT_DATA\n    {STRUCTURE_MTYPE, 2, {\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    TPM_AT_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_AC_OUTPUT, tag)),\n\t    SET_ELEMENT_TYPE(SIMPLE_STYPE)|SET_ELEMENT_SIZE(FOUR_BYTES),\n\t    UINT32_MARSHAL_REF,\n\t    (UINT16)(offsetof(TPMS_AC_OUTPUT, data))}},\n    // TPML_AC_CAPABILITIES_DATA\n    {LIST_MTYPE,\n     (UINT8)(offsetof(TPML_AC_CAPABILITIES, acCapabilities)),\n     Type44_MARSHAL_REF,\n     TPMS_AC_OUTPUT_ARRAY_MARSHAL_INDEX},\n    // Type00_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMU_HA), UINT16)}},\n    // Type01_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMT_HA), UINT16)}},\n    // Type02_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, 1024, UINT16)}},\n    // Type03_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_DIGEST_BUFFER, UINT16)}},\n    // Type04_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_NV_BUFFER_SIZE, UINT16)}},\n    // Type05_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(UINT64), UINT16)}},\n    // Type06_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_SYM_BLOCK_SIZE, UINT16)}},\n    // Type07_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMU_NAME), UINT16)}},\n    // Type08_DATA\n    {MIN_MAX_MTYPE, ONE_BYTES, (UINT8)TPM_RC_VALUE,\n     {RANGE(PCR_SELECT_MIN, PCR_SELECT_MAX, UINT8)}},\n    // Type10_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_TAG, 1,\n     {TPM_ST_CREATION}},\n    // Type11_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_TAG, 1,\n     {TPM_ST_VERIFIED}},\n    // Type12_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_TAG, 2,\n     {TPM_ST_AUTH_SECRET, TPM_ST_AUTH_SIGNED}},\n    // Type13_DATA\n    {TABLE_MTYPE, TWO_BYTES, (UINT8)TPM_RC_TAG, 1,\n     {TPM_ST_HASHCHECK}},\n    // Type15_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_CAP_CC, UINT32)}},\n    // Type17_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_ALG_LIST_SIZE, UINT32)}},\n    // Type18_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_CAP_HANDLES, UINT32)}},\n    // Type19_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(2, 8, UINT32)}},\n    // Type20_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, HASH_COUNT, UINT32)}},\n    // Type22_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_CAP_ALGS, UINT32)}},\n    // Type23_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_TPM_PROPERTIES, UINT32)}},\n    // Type24_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_PCR_PROPERTIES, UINT32)}},\n    // Type25_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_ECC_CURVES, UINT32)}},\n    // Type26_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_TAGGED_POLICIES, UINT32)}},\n    // Type27_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_ACT_DATA, UINT32)}},\n    // Type28_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMS_ATTEST), UINT16)}},\n    // Type29_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_SYM_KEY_BYTES, UINT16)}},\n    // Type30_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, LABEL_MAX_BUFFER, UINT16)}},\n    // Type31_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMS_DERIVE), UINT16)}},\n    // Type32_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMU_SENSITIVE_CREATE), UINT16)}},\n    // Type33_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_RSA_KEY_BYTES, UINT16)}},\n    // Type34_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, RSA_PRIVATE_SIZE, UINT16)}},\n    // Type35_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_ECC_KEY_BYTES, UINT16)}},\n    // Type36_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMU_ENCRYPTED_SECRET), UINT16)}},\n    // Type37_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMT_PUBLIC), UINT16)}},\n    // Type38_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, PRIVATE_VENDOR_SPECIFIC_BYTES, UINT16)}},\n    // Type39_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(_PRIVATE), UINT16)}},\n    // Type40_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMS_ID_OBJECT), UINT16)}},\n    // Type41_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_NV_INDEX_SIZE, UINT16)}},\n    // Type42_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_CONTEXT_SIZE, UINT16)}},\n    // Type43_DATA\n    {MIN_MAX_MTYPE, TWO_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, sizeof(TPMS_CONTEXT_DATA), UINT16)}},\n    // Type44_DATA\n    {MIN_MAX_MTYPE, FOUR_BYTES, (UINT8)TPM_RC_SIZE,\n     {RANGE(0, MAX_AC_CAPABILITIES, UINT32)}}\n};\n#endif // TABLE_DRIVEN_MARSHAL\n"
  },
  {
    "path": "ftpm-opensbi/src/TestingCommands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TestingCommands.c 1490 2019-07-26 21:13:22Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2021\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"SelfTest_fp.h\"\n\nextern int verbose;\n\n#if CC_SelfTest  // Conditional expansion of this file\nTPM_RC\nTPM2_SelfTest(\n\t      SelfTest_In     *in             // IN: input parameter list\n\t      )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_SelfTest:\\n\");\n\t// fclose(f);\n  //   }\n    // Command Output\n    // Call self test function in crypt module\n    return CryptSelfTest(in->fullTest);\n}\n#endif // CC_SelfTest\n#include \"Tpm.h\"\n#include \"IncrementalSelfTest_fp.h\"\n#if CC_IncrementalSelfTest  // Conditional expansion of this file\nTPM_RC\nTPM2_IncrementalSelfTest(\n\t\t\t IncrementalSelfTest_In      *in,            // IN: input parameter list\n\t\t\t IncrementalSelfTest_Out     *out            // OUT: output parameter list\n\t\t\t )\n{\n    TPM_RC                       result;\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_IncrementalSelfTest:\\n\");\n\t// fclose(f);\n  //   }\n    // Command Output\n    // Call incremental self test function in crypt module. If this function\n    // returns TPM_RC_VALUE, it means that an algorithm on the 'toTest' list is\n    // not implemented.\n    result = CryptIncrementalSelfTest(&in->toTest, &out->toDoList);\n    if(result == TPM_RC_VALUE)\n\treturn TPM_RCS_VALUE + RC_IncrementalSelfTest_toTest;\n    return result;\n}\n#endif // CC_IncrementalSelfTest\n#include \"Tpm.h\"\n#include \"GetTestResult_fp.h\"\n#if CC_GetTestResult  // Conditional expansion of this file\nTPM_RC\nTPM2_GetTestResult(\n\t\t   GetTestResult_Out   *out            // OUT: output parameter list\n\t\t   )\n{\n  //   if (verbose) {\n\t// FILE *f = fopen(\"trace.txt\", \"a\");\n\t// fprintf(f, \"TPM2_GetTestResult:\\n\");\n\t// fclose(f);\n  //   }\n    // Command Output\n    // Call incremental self test function in crypt module\n    out->testResult = CryptGetTestResult(&out->outData);\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_GetTestResult\n"
  },
  {
    "path": "ftpm-opensbi/src/Ticket.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tFunctions used for ticket computations.\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n/*\n  This clause contains the functions used for ticket computations.\n*/\n\n//** Includes\n#include \"Tpm.h\"\n#include \"Marshal.h\"\n\n//** Functions\n\n//*** TicketIsSafe()\n// This function indicates if producing a ticket is safe.\n// It checks if the leading bytes of an input buffer is TPM_GENERATED_VALUE\n// or its substring of canonical form.  If so, it is not safe to produce ticket\n// for an input buffer claiming to be TPM generated buffer\n//  Return Type: BOOL\n//      TRUE(1)         safe to produce ticket\n//      FALSE(0)        not safe to produce ticket\nBOOL TicketIsSafe(TPM2B* buffer)\n{\n    TPM_CONSTANTS32 valueToCompare = TPM_GENERATED_VALUE;\n    BYTE            bufferToCompare[sizeof(valueToCompare)];\n    BYTE*           marshalBuffer;\n    //\n    // If the buffer size is less than the size of TPM_GENERATED_VALUE, assume\n    // it is not safe to generate a ticket\n    if(buffer->size < sizeof(valueToCompare))\n\treturn FALSE;\n    marshalBuffer = bufferToCompare;\n    TPM_CONSTANTS32_Marshal(&valueToCompare, &marshalBuffer, NULL);\n    if(MemoryEqual(buffer->buffer, bufferToCompare, sizeof(valueToCompare)))\n\treturn FALSE;\n    else\n\treturn TRUE;\n}\n\n//*** TicketComputeVerified()\n// This function creates a TPMT_TK_VERIFIED ticket.\n/*(See part 2 specification)\n//  The ticket is computed as:\n//      HMAC(proof, (TPM_ST_VERIFIED | digest | keyName))\n//  Where:\n//      HMAC()              an HMAC using the hash of proof\n//      proof               a TPM secret value associated with the hierarchy\n//                          associated with keyName\n//      TPM_ST_VERIFIED     a value to differentiate the tickets\n//      digest              the signed digest\n//      keyName             the Name of the key that signed digest\n*/\nTPM_RC TicketComputeVerified(\n\t\t\t     TPMI_RH_HIERARCHY hierarchy,  // IN: hierarchy constant for ticket\n\t\t\t     TPM2B_DIGEST*     digest,     // IN: digest\n\t\t\t     TPM2B_NAME*       keyName,    // IN: name of key that signed the values\n\t\t\t     TPMT_TK_VERIFIED* ticket      // OUT: verified ticket\n\t\t\t     )\n{\n    TPM_RC      result = TPM_RC_SUCCESS;\n    TPM2B_PROOF proof;\n    HMAC_STATE  hmacState;\n    //\n    // Fill in ticket fields\n    ticket->tag       = TPM_ST_VERIFIED;\n    ticket->hierarchy = hierarchy;\n    result            = HierarchyGetProof(hierarchy, &proof);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Start HMAC using the proof value of the hierarchy as the HMAC key\n    ticket->digest.t.size =\n\tCryptHmacStart2B(&hmacState, CONTEXT_INTEGRITY_HASH_ALG, &proof.b);\n    MemorySet(proof.b.buffer, 0, proof.b.size);\n\n    //  TPM_ST_VERIFIED\n    CryptDigestUpdateInt(&hmacState, sizeof(TPM_ST), ticket->tag);\n    //  digest\n    CryptDigestUpdate2B(&hmacState.hashState, &digest->b);\n    // key name\n    CryptDigestUpdate2B(&hmacState.hashState, &keyName->b);\n    // done\n    CryptHmacEnd2B(&hmacState, &ticket->digest.b);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** TicketComputeAuth()\n// This function creates a TPMT_TK_AUTH ticket.\n/*(See part 2 specification)\n//  The ticket is computed as:\n//      HMAC(proof, (type || timeout || timeEpoch || cpHash\n//                        || policyRef || keyName))\n//  where:\n//      HMAC()      an HMAC using the hash of proof\n//      proof       a TPM secret value associated with the hierarchy of the key\n//                  associated with keyName.\n//      type        a value to differentiate the tickets.  It could be either\n//                  TPM_ST_AUTH_SECRET or TPM_ST_AUTH_SIGNED\n//      timeout     TPM-specific value indicating when the authorization expires\n//      timeEpoch   TPM-specific value indicating the epoch for the timeout\n//      cpHash      optional hash (digest only) of the authorized command\n//      policyRef   optional reference to a policy value\n//      keyName name of the key that signed the authorization\n*/\nTPM_RC TicketComputeAuth(\n\t\t\t TPM_ST            type,            // IN: the type of ticket.\n\t\t\t TPMI_RH_HIERARCHY hierarchy,       // IN: hierarchy constant for ticket\n\t\t\t UINT64            timeout,         // IN: timeout\n\t\t\t BOOL              expiresOnReset,  // IN: flag to indicate if ticket expires on\n\t\t\t //      TPM Reset\n\t\t\t TPM2B_DIGEST* cpHashA,             // IN: input cpHashA\n\t\t\t TPM2B_NONCE*  policyRef,           // IN: input policyRef\n\t\t\t TPM2B_NAME*   entityName,          // IN: name of entity\n\t\t\t TPMT_TK_AUTH* ticket               // OUT: Created ticket\n\t\t\t )\n{\n    TPM_RC      result = TPM_RC_SUCCESS;\n    TPM2B_PROOF proof;\n    HMAC_STATE  hmacState;\n    //\n    // Get proper proof\n    result = HierarchyGetProof(hierarchy, &proof);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Fill in ticket fields\n    ticket->tag       = type;\n    ticket->hierarchy = hierarchy;\n\n    // Start HMAC with hierarchy proof as the HMAC key\n    ticket->digest.t.size =\n\tCryptHmacStart2B(&hmacState, CONTEXT_INTEGRITY_HASH_ALG, &proof.b);\n    MemorySet(proof.b.buffer, 0, proof.b.size);\n\n    //  TPM_ST_AUTH_SECRET or TPM_ST_AUTH_SIGNED,\n    CryptDigestUpdateInt(&hmacState, sizeof(UINT16), ticket->tag);\n    // cpHash\n    CryptDigestUpdate2B(&hmacState.hashState, &cpHashA->b);\n    //  policyRef\n    CryptDigestUpdate2B(&hmacState.hashState, &policyRef->b);\n    //  keyName\n    CryptDigestUpdate2B(&hmacState.hashState, &entityName->b);\n    //  timeout\n    CryptDigestUpdateInt(&hmacState, sizeof(timeout), timeout);\n    if(timeout != 0)\n\t{\n\t    //  epoch\n\t    CryptDigestUpdateInt(&hmacState.hashState, sizeof(CLOCK_NONCE), g_timeEpoch);\n\t    // reset count\n\t    if(expiresOnReset)\n\t\tCryptDigestUpdateInt(\n\t\t\t\t     &hmacState.hashState, sizeof(gp.totalResetCount), gp.totalResetCount);\n\t}\n    // done\n    CryptHmacEnd2B(&hmacState, &ticket->digest.b);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** TicketComputeHashCheck()\n// This function creates a TPMT_TK_HASHCHECK ticket.\n/*(See part 2 specification)\n//  The ticket is computed as:\n//      HMAC(proof, (TPM_ST_HASHCHECK || digest ))\n//  where:\n//      HMAC()  an HMAC using the hash of proof\n//      proof   a TPM secret value associated with the hierarchy\n//      TPM_ST_HASHCHECK\n//              a value to differentiate the tickets\n//      digest  the digest of the data\n*/\nTPM_RC TicketComputeHashCheck(\n\t\t\t      TPMI_RH_HIERARCHY  hierarchy,  // IN: hierarchy constant for ticket\n\t\t\t      TPM_ALG_ID         hashAlg,    // IN: the hash algorithm for 'digest'\n\t\t\t      TPM2B_DIGEST*      digest,     // IN: input digest\n\t\t\t      TPMT_TK_HASHCHECK* ticket      // OUT: Created ticket\n\t\t\t      )\n{\n    TPM_RC      result = TPM_RC_SUCCESS;\n    TPM2B_PROOF proof;\n    HMAC_STATE  hmacState;\n    //\n    // Get proper proof\n    result = HierarchyGetProof(hierarchy, &proof);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Fill in ticket fields\n    ticket->tag       = TPM_ST_HASHCHECK;\n    ticket->hierarchy = hierarchy;\n\n    // Start HMAC using hierarchy proof as HMAC key\n    ticket->digest.t.size =\n\tCryptHmacStart2B(&hmacState, CONTEXT_INTEGRITY_HASH_ALG, &proof.b);\n    MemorySet(proof.b.buffer, 0, proof.b.size);\n\n    //  TPM_ST_HASHCHECK\n    CryptDigestUpdateInt(&hmacState, sizeof(TPM_ST), ticket->tag);\n    //  hash algorithm\n    CryptDigestUpdateInt(&hmacState, sizeof(hashAlg), hashAlg);\n    //  digest\n    CryptDigestUpdate2B(&hmacState.hashState, &digest->b);\n    // done\n    CryptHmacEnd2B(&hmacState, &ticket->digest.b);\n\n    return TPM_RC_SUCCESS;\n}\n\n//*** TicketComputeCreation()\n// This function creates a TPMT_TK_CREATION ticket.\n/*(See part 2 specification)\n// The ticket is computed as:\n//      HMAC(proof, (TPM_ST_CREATION || Name || hash(TPMS_CREATION_DATA)))\n//  Where:\n//  HMAC()  an HMAC using the hash of proof\n//  proof   a TPM secret value associated with the hierarchy associated with Name\n//  TPM_ST_VERIFIED     a value to differentiate the tickets\n//  Name    the Name of the object to which the creation data is to be associated\n//  TPMS_CREATION_DATA  the creation data structure associated with Name\n*/\nTPM_RC TicketComputeCreation(TPMI_RH_HIERARCHY hierarchy,  // IN: hierarchy for ticket\n\t\t\t     TPM2B_NAME*       name,       // IN: object name\n\t\t\t     TPM2B_DIGEST*     creation,   // IN: creation hash\n\t\t\t     TPMT_TK_CREATION* ticket      // OUT: created ticket\n\t\t\t     )\n{\n    TPM_RC      result = TPM_RC_SUCCESS;\n    TPM2B_PROOF proof;\n    HMAC_STATE  hmacState;\n\n    // Get proper proof\n    result = HierarchyGetProof(hierarchy, &proof);\n    if(result != TPM_RC_SUCCESS)\n\treturn result;\n\n    // Fill in ticket fields\n    ticket->tag       = TPM_ST_CREATION;\n    ticket->hierarchy = hierarchy;\n\n    // Start HMAC using hierarchy proof as HMAC key\n    ticket->digest.t.size =\n\tCryptHmacStart2B(&hmacState, CONTEXT_INTEGRITY_HASH_ALG, &proof.b);\n    MemorySet(proof.b.buffer, 0, proof.b.size);\n\n    //  TPM_ST_CREATION\n    CryptDigestUpdateInt(&hmacState, sizeof(TPM_ST), ticket->tag);\n    //  name if provided\n    if(name != NULL)\n\tCryptDigestUpdate2B(&hmacState.hashState, &name->b);\n    //  creation hash\n    CryptDigestUpdate2B(&hmacState.hashState, &creation->b);\n    // Done\n    CryptHmacEnd2B(&hmacState, &ticket->digest.b);\n\n    return TPM_RC_SUCCESS;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/Time.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tFunctions relating to the TPM's time functions \t \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains the functions relating to the TPM's time functions including\n// the interface to the implementation-specific time functions.\n//\n//** Includes\n#include \"Tpm.h\"\n#include \"Marshal.h\"\n\n//** Functions\n\n//*** TimePowerOn()\n// This function initialize time info at _TPM_Init().\n//\n// This function is called at _TPM_Init() so that the TPM time can start counting\n// as soon as the TPM comes out of reset and doesn't have to wait until\n// TPM2_Startup() in order to begin the new time epoch. This could be significant\n// for systems that could get powered up but not run any TPM commands for some\n// period of time.\n//\nvoid TimePowerOn(void)\n{\n    g_time = _plat__TimerRead();\n}\n\n//*** TimeNewEpoch()\n// This function does the processing to generate a new time epoch nonce and\n// set NV for update. This function is only called when NV is known to be available\n// and the clock is running. The epoch is updated to persistent data.\nstatic void TimeNewEpoch(void)\n{\n#if CLOCK_STOPS\n    CryptRandomGenerate(sizeof(CLOCK_NONCE), (BYTE*)&g_timeEpoch);\n#else\n    // if the epoch is kept in NV, update it.\n    gp.timeEpoch++;\n    NV_SYNC_PERSISTENT(timeEpoch);\n#endif\n    // Clean out any lingering state\n    _plat__TimerWasStopped();\n}\n\n//*** TimeStartup()\n// This function updates the resetCount and restartCount components of\n// TPMS_CLOCK_INFO structure at TPM2_Startup().\n//\n// This function will deal with the deferred creation of a new epoch.\n// TimeUpdateToCurrent() will not start a new epoch even if one is due when\n// TPM_Startup() has not been run. This is because the state of NV is not known\n// until startup completes. When Startup is done, then it will create the epoch\n// nonce to complete the initializations by calling this function.\nBOOL TimeStartup(STARTUP_TYPE type  // IN: start up type\n\t\t )\n{\n    NOT_REFERENCED(type);\n    // If the previous cycle is orderly shut down, the value of the safe bit\n    // the same as previously saved.  Otherwise, it is not safe.\n    if(!NV_IS_ORDERLY)\n\tgo.clockSafe = NO;\n    return TRUE;\n}\n\n//*** TimeClockUpdate()\n// This function updates go.clock. If 'newTime' requires an update of NV, then\n// NV is checked for availability. If it is not available or is rate limiting, then\n// go.clock is not updated and the function returns an error. If 'newTime' would\n// not cause an NV write, then go.clock is updated. If an NV write occurs, then\n// go.safe is SET.\nvoid TimeClockUpdate(UINT64 newTime  // IN: New time value in mS.\n\t\t     )\n{\n#define CLOCK_UPDATE_MASK ((1ULL << NV_CLOCK_UPDATE_INTERVAL) - 1)\n\n    // Check to see if the update will cause a need for an nvClock update\n    if((newTime | CLOCK_UPDATE_MASK) > (go.clock | CLOCK_UPDATE_MASK))\n\t{\n\t    pAssert(g_NvStatus == TPM_RC_SUCCESS);\n\n\t    // Going to update the NV time state so SET the safe flag\n\t    go.clockSafe = YES;\n\n\t    // update the time\n\t    go.clock = newTime;\n\n\t    NvWrite(NV_ORDERLY_DATA, sizeof(go), &go);\n\t}\n    else\n\t// No NV update needed so just update\n\tgo.clock = newTime;\n}\n\n//*** TimeUpdate()\n// This function is used to update the time and clock values. If the TPM\n// has run TPM2_Startup(), this function is called at the start of each command.\n// If the TPM has not run TPM2_Startup(), this is called from TPM2_Startup() to\n// get the clock values initialized. It is not called on command entry because, in\n// this implementation, the go structure is not read from NV until TPM2_Startup().\n// The reason for this is that the initialization code (_TPM_Init()) may run before\n// NV is accessible.\nvoid TimeUpdate(void)\n{\n    UINT64 elapsed;\n    //\n    // Make sure that we consume the current _plat__TimerWasStopped() state.\n    if(_plat__TimerWasStopped())\n\t{\n\t    TimeNewEpoch();\n\t}\n    // Get the difference between this call and the last time we updated the tick\n    // timer.\n    elapsed = _plat__TimerRead() - g_time;\n    // Don't read +\n    g_time += elapsed;\n\n    // Don't need to check the result because it has to be success because have\n    // already checked that NV is available.\n    TimeClockUpdate(go.clock + elapsed);\n\n    // Call self healing logic for dictionary attack parameters\n    DASelfHeal();\n}\n\n//*** TimeUpdateToCurrent()\n// This function updates the 'Time' and 'Clock' in the global\n// TPMS_TIME_INFO structure.\n//\n// In this implementation, 'Time' and 'Clock' are updated at the beginning\n// of each command and the values are unchanged for the duration of the\n// command.\n//\n// Because 'Clock' updates may require a write to NV memory, 'Time' and 'Clock'\n// are not allowed to advance if NV is not available. When clock is not advancing,\n// any function that uses 'Clock' will fail and return TPM_RC_NV_UNAVAILABLE or\n// TPM_RC_NV_RATE.\n//\n// This implementation does not do rate limiting. If the implementation does do\n// rate limiting, then the 'Clock' update should not be inhibited even when doing\n// rate limiting.\nvoid TimeUpdateToCurrent(void)\n{\n    // Can't update time during the dark interval or when rate limiting so don't\n    // make any modifications to the internal clock value. Also, defer any clock\n    // processing until TPM has run TPM2_Startup()\n    if(!NV_IS_AVAILABLE || !TPMIsStarted())\n\treturn;\n\n    TimeUpdate();\n}\n\n//*** TimeSetAdjustRate()\n// This function is used to perform rate adjustment on 'Time' and 'Clock'.\nvoid TimeSetAdjustRate(TPM_CLOCK_ADJUST adjust  // IN: adjust constant\n\t\t       )\n{\n    switch(adjust)\n\t{\n\t  case TPM_CLOCK_COARSE_SLOWER:\n\t    _plat__ClockRateAdjust(PLAT_TPM_CLOCK_ADJUST_COARSE_SLOWER);\n\t    break;\n\t  case TPM_CLOCK_COARSE_FASTER:\n\t    _plat__ClockRateAdjust(PLAT_TPM_CLOCK_ADJUST_COARSE_FASTER);\n\t    break;\n\t  case TPM_CLOCK_MEDIUM_SLOWER:\n\t    _plat__ClockRateAdjust(PLAT_TPM_CLOCK_ADJUST_MEDIUM_SLOWER);\n\t    break;\n\t  case TPM_CLOCK_MEDIUM_FASTER:\n\t    _plat__ClockRateAdjust(PLAT_TPM_CLOCK_ADJUST_MEDIUM_FASTER);\n\t    break;\n\t  case TPM_CLOCK_FINE_SLOWER:\n\t    _plat__ClockRateAdjust(PLAT_TPM_CLOCK_ADJUST_FINE_SLOWER);\n\t    break;\n\t  case TPM_CLOCK_FINE_FASTER:\n\t    _plat__ClockRateAdjust(PLAT_TPM_CLOCK_ADJUST_FINE_FASTER);\n\t    break;\n\t  case TPM_CLOCK_NO_CHANGE:\n\t    break;\n\t  default:\n\t    // should have been blocked sooner\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t    break;\n\t}\n\n    return;\n}\n\n//*** TimeGetMarshaled()\n// This function is used to access TPMS_TIME_INFO in canonical form.\n// The function collects the time information and marshals it into 'dataBuffer'\n// and returns the marshaled size\nUINT16\nTimeGetMarshaled(TIME_INFO* dataBuffer  // OUT: result buffer\n\t\t )\n{\n    TPMS_TIME_INFO timeInfo;\n\n    // Fill TPMS_TIME_INFO structure\n    timeInfo.time = g_time;\n    TimeFillInfo(&timeInfo.clockInfo);\n\n    // Marshal TPMS_TIME_INFO to canonical form\n    return TPMS_TIME_INFO_Marshal(&timeInfo, (BYTE**)&dataBuffer, NULL);\n}\n\n//*** TimeFillInfo\n// This function gathers information to fill in a TPMS_CLOCK_INFO structure.\nvoid TimeFillInfo(TPMS_CLOCK_INFO* clockInfo)\n{\n    clockInfo->clock        = go.clock;\n    clockInfo->resetCount   = gp.resetCount;\n    clockInfo->restartCount = gr.restartCount;\n\n    // If NV is not available, clock stopped advancing and the value reported is\n    // not \"safe\".\n    if(NV_IS_AVAILABLE)\n\tclockInfo->safe = go.clockSafe;\n    else\n\tclockInfo->safe = NO;\n\n    return;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmAsn1.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM ASN.1\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes\n#include \"Tpm.h\"\n#define _OIDS_\n#include \"OIDs.h\"\n#include \"TpmASN1.h\"\n#include \"TpmASN1_fp.h\"\n\n#if CC_CertifyX509\n\n//** Unmarshaling Functions\n\n//*** ASN1UnmarshalContextInitialize()\n// Function does standard initialization of a context.\n//  Return Type: BOOL\n//      TRUE(1)     success\n//      FALSE(0)    failure\nBOOL ASN1UnmarshalContextInitialize(\n\t\t\t\t    ASN1UnmarshalContext* ctx, INT16 size, BYTE* buffer)\n{\n    GOTO_ERROR_UNLESS(buffer != NULL);\n    GOTO_ERROR_UNLESS(size > 0);\n    ctx->buffer = buffer;\n    ctx->size   = size;\n    ctx->offset = 0;\n    ctx->tag    = 0xFF;\n    return TRUE;\n Error:\n    return FALSE;\n}\n\n//***ASN1DecodeLength()\n// This function extracts the length of an element from 'buffer' starting at 'offset'.\n// Return Type: UINT16\n//      >=0         the extracted length\n//      <0          an error\nINT16\nASN1DecodeLength(ASN1UnmarshalContext* ctx)\n{\n    BYTE  first;  // Next octet in buffer\n    INT16 value;\n    //\n    GOTO_ERROR_UNLESS(ctx->offset < ctx->size);\n    first = NEXT_OCTET(ctx);\n    // If the number of octets of the entity is larger than 127, then the first octet\n    // is the number of octets in the length specifier.\n    if(first >= 0x80)\n\t{\n\t    // Make sure that this length field is contained with the structure being\n\t    // parsed\n\t    CHECK_SIZE(ctx, (first & 0x7F));\n\t    if(first == 0x82)\n\t\t{\n\t\t    // Two octets of size\n\t\t    // get the next value\n\t\t    value = (INT16)NEXT_OCTET(ctx);\n\t\t    // Make sure that the result will fit in an INT16\n\t\t    GOTO_ERROR_UNLESS(value < 0x0080);\n\t\t    // Shift up and add next octet\n\t\t    value = (value << 8) + NEXT_OCTET(ctx);\n\t\t}\n\t    else if(first == 0x81)\n\t\tvalue = NEXT_OCTET(ctx);\n\t    // Sizes larger than will fit in a INT16 are an error\n\t    else\n\t\tgoto Error;\n\t}\n    else\n\tvalue = first;\n    // Make sure that the size defined something within the current context\n    CHECK_SIZE(ctx, value);\n    return value;\n Error:\n    ctx->size = -1;  // Makes everything fail from now on.\n    return -1;\n}\n\n//***ASN1NextTag()\n// This function extracts the next type from 'buffer' starting at 'offset'.\n// It advances 'offset' as it parses the type and the length of the type. It returns\n// the length of the type. On return, the 'length' octets starting at 'offset' are the\n// octets of the type.\n// Return Type: UINT\n//     >=0          the number of octets in 'type'\n//     <0           an error\nINT16\nASN1NextTag(ASN1UnmarshalContext* ctx)\n{\n    // A tag to get?\n    GOTO_ERROR_UNLESS(ctx->offset < ctx->size);\n    // Get it\n    ctx->tag = NEXT_OCTET(ctx);\n    // Make sure that it is not an extended tag\n    GOTO_ERROR_UNLESS((ctx->tag & 0x1F) != 0x1F);\n    // Get the length field and return that\n    return ASN1DecodeLength(ctx);\n\n Error:\n    // Attempt to read beyond the end of the context or an illegal tag\n    ctx->size = -1;  // Persistent failure\n    ctx->tag  = 0xFF;\n    return -1;\n}\n\n//*** ASN1GetBitStringValue()\n// Try to parse a bit string of up to 32 bits from a value that is expected to be\n// a bit string. The bit string is left justified so that the MSb of the input is\n// the MSb of the returned value.\n// If there is a general parsing error, the context->size is set to -1.\n//  Return Type: BOOL\n//      TRUE(1)     success\n//      FALSE(0)    failure\nBOOL ASN1GetBitStringValue(ASN1UnmarshalContext* ctx, UINT32* val)\n{\n    int    shift;\n    INT16  length;\n    UINT32 value = 0;\n    int    inputBits;\n    //\n    length = ASN1NextTag(ctx);\n    GOTO_ERROR_UNLESS(length >= 1);\n    GOTO_ERROR_UNLESS(ctx->tag == ASN1_BITSTRING);\n    // Get the shift value for the bit field (how many bits to lop off of the end)\n    shift = NEXT_OCTET(ctx);\n    length--;\n    // Get the number of bits in the input\n    inputBits = (8 * length) - shift;\n    // the shift count has to make sense\n    GOTO_ERROR_UNLESS((shift < 8) && ((length > 0) || (shift == 0)));\n    // if there are any bytes left\n    for(; length > 1; length--)\n\t{\n\n\t    // for all but the last octet, just shift and add the new octet\n\t    GOTO_ERROR_UNLESS((value & 0xFF000000) == 0);  // can't loose significant bits\n\t    value = (value << 8) + NEXT_OCTET(ctx);\n\t}\n    if(length == 1)\n\t{\n\t    // for the last octet, just shift the accumulated value enough to\n\t    // accept the significant bits in the last octet and shift the last\n\t    // octet down\n\t    GOTO_ERROR_UNLESS(((value & (0xFF000000 << (8 - shift)))) == 0);\n\t    value = (value << (8 - shift)) + (NEXT_OCTET(ctx) >> shift);\n\t}\n    // 'Left justify' the result\n    if(inputBits > 0)\n\tvalue <<= (32 - inputBits);\n    *val = value;\n    return TRUE;\n Error:\n    ctx->size = -1;\n    return FALSE;\n}\n\n//*******************************************************************\n//** Marshaling Functions\n//*******************************************************************\n\n//*** Introduction\n// Marshaling of an ASN.1 structure is accomplished from the bottom up. That is,\n// the things that will be at the end of the structure are added last. To manage the\n// collecting of the relative sizes, start a context for the outermost container, if\n// there is one, and then placing items in from the bottom up. If the bottom-most\n// item is also within a structure, create a nested context by calling\n// ASN1StartMarshalingContext().\n//\n// The context control structure contains a 'buffer' pointer, an 'offset', an 'end'\n// and a stack. 'offset' is the offset from the start of the buffer of the last added\n// byte. When 'offset' reaches 0, the buffer is full. 'offset' is a signed value so\n// that, when it becomes negative, there is an overflow. Only two functions are\n// allowed to move bytes into the buffer: ASN1PushByte() and ASN1PushBytes(). These\n// functions make sure that no data is written beyond the end of the buffer.\n//\n// When a new context is started, the current value of 'end' is pushed\n// on the stack and 'end' is set to 'offset. As bytes are added, offset gets smaller.\n// At any time, the count of bytes in the current context is simply 'end' - 'offset'.\n//\n// Since starting a new context involves setting 'end' = 'offset', the number of bytes\n// in the context starts at 0. The nominal way of ending a context is to use\n// 'end' - 'offset' to set the length value, and then a tag is added to the buffer.\n// Then the previous 'end' value is popped meaning that the context just ended\n// becomes a member of the now current context.\n//\n// The nominal strategy for building a completed ASN.1 structure is to push everything\n// into the buffer and then move everything to the start of the buffer. The move is\n// simple as the size of the move is the initial 'end' value minus the final 'offset'\n// value. The destination is 'buffer' and the source is 'buffer' + 'offset'. As Skippy\n// would say \"Easy peasy, Joe.\"\n//\n// It is not necessary to provide a buffer into which the data is placed. If no buffer\n// is provided, then the marshaling process will return values needed for marshaling.\n// On strategy for filling the buffer would be to execute the process for building\n// the structure without using a buffer. This would return the overall size of the\n// structure. Then that amount of data could be allocated for the buffer and the fill\n// process executed again with the data going into the buffer. At the end, the data\n// would be in its final resting place.\n\n//*** ASN1InitialializeMarshalContext()\n// This creates a structure for handling marshaling of an ASN.1 formatted data\n// structure.\nvoid ASN1InitialializeMarshalContext(\n\t\t\t\t     ASN1MarshalContext* ctx, INT16 length, BYTE* buffer)\n{\n    ctx->buffer = buffer;\n    if(buffer)\n\tctx->offset = length;\n    else\n\tctx->offset = INT16_MAX;\n    ctx->end   = ctx->offset;\n    ctx->depth = -1;\n}\n\n//*** ASN1StartMarshalContext()\n// This starts a new constructed element. It is constructed on 'top' of the value\n// that was previously placed in the structure.\nvoid ASN1StartMarshalContext(ASN1MarshalContext* ctx)\n{\n    pAssert((ctx->depth + 1) < MAX_DEPTH);\n    ctx->depth++;\n    ctx->ends[ctx->depth] = ctx->end;\n    ctx->end              = ctx->offset;\n}\n\n//*** ASN1EndMarshalContext()\n// This function restores the end pointer for an encapsulating structure.\n//  Return Type: INT16\n//      > 0             the size of the encapsulated structure that was just ended\n//      <= 0            an error\nINT16\nASN1EndMarshalContext(ASN1MarshalContext* ctx)\n{\n    INT16 length;\n    pAssert(ctx->depth >= 0);\n    length   = ctx->end - ctx->offset;\n    ctx->end = ctx->ends[ctx->depth--];\n    return length;\n}\n\n//***ASN1EndEncapsulation()\n// This function puts a tag and length in the buffer. In this function, an embedded\n// BIT_STRING is assumed to be a collection of octets. To indicate that all bits\n// are used, a byte of zero is prepended. If a raw bit-string is needed, a new\n// function like ASN1PushInteger() would be needed.\n//  Return Type: INT16\n//      > 0         number of octets in the encapsulation\n//      == 0        failure\nUINT16\nASN1EndEncapsulation(ASN1MarshalContext* ctx, BYTE tag)\n{\n    // only add a leading zero for an encapsulated BIT STRING\n    if(tag == ASN1_BITSTRING)\n\tASN1PushByte(ctx, 0);\n    ASN1PushTagAndLength(ctx, tag, ctx->end - ctx->offset);\n    return ASN1EndMarshalContext(ctx);\n}\n\n//*** ASN1PushByte()\nBOOL ASN1PushByte(ASN1MarshalContext* ctx, BYTE b)\n{\n    if(ctx->offset > 0)\n\t{\n\t    ctx->offset -= 1;\n\t    if(ctx->buffer)\n\t\tctx->buffer[ctx->offset] = b;\n\t    return TRUE;\n\t}\n    ctx->offset = -1;\n    return FALSE;\n}\n\n//*** ASN1PushBytes()\n// Push some raw bytes onto the buffer. 'count' cannot be zero.\n//  Return Type: IN16\n//      > 0             count bytes\n//      == 0            failure unless count was zero\nINT16\nASN1PushBytes(ASN1MarshalContext* ctx, INT16 count, const BYTE* buffer)\n{\n    // make sure that count is not negative which would mess up the math; and that\n    // if there is a count, there is a buffer\n    GOTO_ERROR_UNLESS((count >= 0) && ((buffer != NULL) || (count == 0)));\n    // back up the offset to determine where the new octets will get pushed\n    ctx->offset -= count;\n    // can't go negative\n    GOTO_ERROR_UNLESS(ctx->offset >= 0);\n    // if there are buffers, move the data, otherwise, assume that this is just a\n    // test.\n    if(count && buffer && ctx->buffer)\n\tMemoryCopy(&ctx->buffer[ctx->offset], buffer, count);\n    return count;\n Error:\n    ctx->offset = -1;\n    return 0;\n}\n\n//*** ASN1PushNull()\n//  Return Type: IN16\n//      > 0             count bytes\n//      == 0            failure unless count was zero\nINT16\nASN1PushNull(ASN1MarshalContext* ctx)\n{\n    ASN1PushByte(ctx, 0);\n    ASN1PushByte(ctx, ASN1_NULL);\n    return (ctx->offset >= 0) ? 2 : 0;\n}\n\n//*** ASN1PushLength()\n// Push a length value. This will only handle length values that fit in an INT16.\n//  Return Type: UINT16\n//      > 0         number of bytes added\n//      == 0        failure\nINT16\nASN1PushLength(ASN1MarshalContext* ctx, INT16 len)\n{\n    UINT16 start = ctx->offset;\n    GOTO_ERROR_UNLESS(len >= 0);\n    if(len <= 127)\n\tASN1PushByte(ctx, (BYTE)len);\n    else\n\t{\n\t    ASN1PushByte(ctx, (BYTE)(len & 0xFF));\n\t    len >>= 8;\n\t    if(len == 0)\n\t\tASN1PushByte(ctx, 0x81);\n\t    else\n\t\t{\n\t\t    ASN1PushByte(ctx, (BYTE)(len));\n\t\t    ASN1PushByte(ctx, 0x82);\n\t\t}\n\t}\n    goto Exit;\n Error:\n    ctx->offset = -1;\n Exit:\n    return (ctx->offset > 0) ? start - ctx->offset : 0;\n}\n\n//*** ASN1PushTagAndLength()\n//  Return Type: INT16\n//      > 0         number of bytes added\n//      == 0        failure\nINT16\nASN1PushTagAndLength(ASN1MarshalContext* ctx, BYTE tag, INT16 length)\n{\n    INT16 bytes;\n    bytes = ASN1PushLength(ctx, length);\n    bytes += (INT16)ASN1PushByte(ctx, tag);\n    return (ctx->offset < 0) ? 0 : bytes;\n}\n\n//*** ASN1PushTaggedOctetString()\n// This function will push a random octet string.\n//  Return Type: INT16\n//      > 0         number of bytes added\n//      == 0        failure\nINT16\nASN1PushTaggedOctetString(\n\t\t\t  ASN1MarshalContext* ctx, INT16 size, const BYTE* string, BYTE tag)\n{\n    ASN1PushBytes(ctx, size, string);\n    // PushTagAndLenght just tells how many octets it added so the total size of this\n    // element is the sum of those octets and input size.\n    size += ASN1PushTagAndLength(ctx, tag, size);\n    return size;\n}\n\n//*** ASN1PushUINT()\n// This function pushes an native-endian integer value. This just changes a\n// native-endian integer into a big-endian byte string and calls ASN1PushInteger().\n// That function will remove leading zeros and make sure that the number is positive.\n//  Return Type: IN16\n//      > 0             count bytes\n//      == 0            failure unless count was zero\nINT16\nASN1PushUINT(ASN1MarshalContext* ctx, UINT32 integer)\n{\n    BYTE marshaled[4];\n    UINT32_TO_BYTE_ARRAY(integer, marshaled);\n    return ASN1PushInteger(ctx, 4, marshaled);\n}\n\n//*** ASN1PushInteger\n// Push a big-endian integer on the end of the buffer\n//  Return Type: UINT16\n//      > 0         the number of bytes marshaled for the integer\n//      == 0        failure\nINT16\nASN1PushInteger(ASN1MarshalContext* ctx,     // IN/OUT: buffer context\n\t\tINT16               iLen,    // IN: octets of the integer\n\t\tBYTE*               integer  // IN: big-endian integer\n\t\t)\n{\n    // no leading 0's\n    while((*integer == 0) && (--iLen > 0))\n\tinteger++;\n    // Move the bytes to the buffer\n    ASN1PushBytes(ctx, iLen, integer);\n    // if needed, add a leading byte of 0 to make the number positive\n    if(*integer & 0x80)\n\tiLen += (INT16)ASN1PushByte(ctx, 0);\n    // PushTagAndLenght just tells how many octets it added so the total size of this\n    // element is the sum of those octets and the adjusted input size.\n    iLen += ASN1PushTagAndLength(ctx, ASN1_INTEGER, iLen);\n    return iLen;\n}\n\n//*** ASN1PushOID()\n// This function is used to add an OID. An OID is 0x06 followed by a byte of size\n// followed by size bytes. This is used to avoid having to do anything special in the\n// definition of an OID.\n//  Return Type: UINT16\n//      > 0         the number of bytes marshaled for the integer\n//      == 0        failure\nINT16\nASN1PushOID(ASN1MarshalContext* ctx, const BYTE* OID)\n{\n    if((*OID == ASN1_OBJECT_IDENTIFIER) && ((OID[1] & 0x80) == 0))\n\t{\n\t    return ASN1PushBytes(ctx, OID[1] + 2, OID);\n\t}\n    ctx->offset = -1;\n    return 0;\n}\n\n#endif  // CC_CertifyX509\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmBigNumThunks.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t  \t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains BN Thunks between the MathInterfaceLibrary types and the\n// bignum_t types.\n\n#include \"TpmBigNum.h\"\n\n// Note - these were moved out of TPM_INLINE to build correctly on GCC.  On MSVC\n// link time code generation correctly handles the inline versions, but\n// it isn't portable to GCC.\n\n// ***************************************************************************\n// Library Level Functions\n// ***************************************************************************\n\n// Called when system is initializing to allow math libraries to perform\n// startup actions.\nLIB_EXPORT int ExtMath_LibInit(void)\n{\n    return BnSupportLibInit();\n}\n\n//** MathLibraryCompatibililtyCheck()\n// This function is only used during development to make sure that the library\n// that is being referenced is using the same size of data structures as the TPM.\nLIB_EXPORT BOOL ExtMath_Debug_CompatibilityCheck(void)\n{\n    return BnMathLibraryCompatibilityCheck();\n}\n\n// ***************************************************************************\n// Integer/Number Functions (non-ECC)\n// ***************************************************************************\n// #################\n// type initializers\n// #################\nLIB_EXPORT Crypt_Int* ExtMath_Initialize_Int(Crypt_Int* var, NUMBYTES bitCount)\n{\n    return (Crypt_Int*)BnInit((bigNum)var, BN_STRUCT_ALLOCATION(bitCount));\n}\n\n// #################\n// Buffer Converters\n// #################\nLIB_EXPORT Crypt_Int* ExtMath_IntFromBytes(\n\t\t\t\t\t   Crypt_Int* buffer, const BYTE* input, NUMBYTES byteCount)\n{\n    return (Crypt_Int*)BnFromBytes((bigNum)buffer, input, byteCount);\n}\n\nLIB_EXPORT BOOL ExtMath_IntToBytes(\n\t\t\t\t   const Crypt_Int* value, BYTE* output, NUMBYTES* pByteCount)\n{\n    return BnToBytes((bigConst)value, output, pByteCount);\n}\n\nLIB_EXPORT Crypt_Int* ExtMath_SetWord(Crypt_Int* n, crypt_uword_t w)\n{\n    return (Crypt_Int*)BnSetWord((bigNum)n, w);\n}\n// #################\n// Copy Functions\n// #################\nLIB_EXPORT BOOL ExtMath_Copy(Crypt_Int* out, const Crypt_Int* in)\n{\n    return BnCopy((bigNum)out, (bigConst)in);\n}\n\n// ###############################\n// Ordinary Arithmetic, writ large\n// ###############################\n\n//** ExtMath_Multiply()\n// Multiplies two numbers and returns the result\nLIB_EXPORT BOOL ExtMath_Multiply(\n\t\t\t\t Crypt_Int* result, const Crypt_Int* multiplicand, const Crypt_Int* multiplier)\n{\n    return BnMult((bigNum)result, (bigConst)multiplicand, (bigConst)multiplier);\n}\n\n//** ExtMath_Divide()\n// This function divides two Crypt_Int* values. The function returns FALSE if there is\n// an error in the operation. Quotient may be null, in which case this function returns\n// only the remainder.\nLIB_EXPORT BOOL ExtMath_Divide(Crypt_Int*       quotient,\n\t\t\t       Crypt_Int*       remainder,\n\t\t\t       const Crypt_Int* dividend,\n\t\t\t       const Crypt_Int* divisor)\n{\n    return BnDiv(\n\t\t (bigNum)quotient, (bigNum)remainder, (bigConst)dividend, (bigConst)divisor);\n}\n\n#if ALG_RSA\n//** ExtMath_GCD()\n// Get the greatest common divisor of two numbers. This function is only needed\n// when the TPM implements RSA.\nLIB_EXPORT BOOL ExtMath_GCD(\n\t\t\t    Crypt_Int* gcd, const Crypt_Int* number1, const Crypt_Int* number2)\n{\n    return BnGcd((bigNum)gcd, (bigConst)number1, (bigConst)number2);\n}\n#endif  // ALG_RSA\n\n\t//*** ExtMath_Add()\n\t// This function adds two Crypt_Int* values. This function always returns TRUE.\nLIB_EXPORT BOOL ExtMath_Add(\n\t\t\t    Crypt_Int* result, const Crypt_Int* op1, const Crypt_Int* op2)\n{\n    return BnAdd((bigNum)result, (bigConst)op1, (bigConst)op2);\n}\n\n//*** ExtMath_AddWord()\n// This function adds a word value to a Crypt_Int*. This function always returns TRUE.\nLIB_EXPORT BOOL ExtMath_AddWord(\n\t\t\t\tCrypt_Int* result, const Crypt_Int* op, crypt_uword_t word)\n{\n    return BnAddWord((bigNum)result, (bigConst)op, word);\n}\n\n//*** ExtMath_Subtract()\n// This function does subtraction of two Crypt_Int* values and returns result = op1 - op2\n// when op1 is greater than op2. If op2 is greater than op1, then a fault is\n// generated. This function always returns TRUE.\nLIB_EXPORT BOOL ExtMath_Subtract(\n\t\t\t\t Crypt_Int* result, const Crypt_Int* op1, const Crypt_Int* op2)\n{\n    return BnSub((bigNum)result, (bigConst)op1, (bigConst)op2);\n}\n\n//*** ExtMath_SubtractWord()\n// This function subtracts a word value from a Crypt_Int*. This function always\n// returns TRUE.\nLIB_EXPORT BOOL ExtMath_SubtractWord(\n\t\t\t\t     Crypt_Int* result, const Crypt_Int* op, crypt_uword_t word)\n{\n    return BnSubWord((bigNum)result, (bigConst)op, word);\n}\n\n// ###############################\n// Modular Arithmetic, writ large\n// ###############################\n// define Mod in terms of Divide\nLIB_EXPORT BOOL ExtMath_Mod(Crypt_Int* valueAndResult, const Crypt_Int* modulus)\n{\n    return ExtMath_Divide(NULL, valueAndResult, valueAndResult, modulus);\n}\n\n//** ExtMath_ModMult()\n// Does 'op1' * 'op2' and divide by 'modulus' returning the remainder of the divide.\nLIB_EXPORT BOOL ExtMath_ModMult(Crypt_Int*       result,\n\t\t\t\tconst Crypt_Int* op1,\n\t\t\t\tconst Crypt_Int* op2,\n\t\t\t\tconst Crypt_Int* modulus)\n{\n    return BnModMult((bigNum)result, (bigConst)op1, (bigConst)op2, (bigConst)modulus);\n}\n\n#if ALG_RSA\n//** ExtMath_ModExp()\n// Do modular exponentiation using Crypt_Int* values. This function is only needed\n// when the TPM implements RSA.\nLIB_EXPORT BOOL ExtMath_ModExp(Crypt_Int*       result,\n\t\t\t       const Crypt_Int* number,\n\t\t\t       const Crypt_Int* exponent,\n\t\t\t       const Crypt_Int* modulus)\n{\n    return BnModExp(\n\t\t    (bigNum)result, (bigConst)number, (bigConst)exponent, (bigConst)modulus);\n}\n#endif  // ALG_RSA\n\n\t//** ExtMath_ModInverse()\n\t// Modular multiplicative inverse.\nLIB_EXPORT BOOL ExtMath_ModInverse(\n\t\t\t\t   Crypt_Int* result, const Crypt_Int* number, const Crypt_Int* modulus)\n{\n    return BnModInverse((bigNum)result, (bigConst)number, (bigConst)modulus);\n}\n\n//*** ExtMath_ModWord()\n// This function does modular division of a big number when the modulus is a\n// word value.\nLIB_EXPORT crypt_word_t ExtMath_ModWord(const Crypt_Int* numerator,\n\t\t\t\t\tcrypt_word_t     modulus)\n{\n    return BnModWord((bigConst)numerator, modulus);\n}\n\n// ###############################\n// Queries\n// ###############################\n\n//*** ExtMath_UnsignedCmp()\n// This function performs a comparison of op1 to op2. The compare is approximately\n// constant time if the size of the values used in the compare is consistent\n// across calls (from the same line in the calling code).\n//  Return Type: int\n//      < 0             op1 is less than op2\n//      0               op1 is equal to op2\n//      > 0             op1 is greater than op2\nLIB_EXPORT int ExtMath_UnsignedCmp(const Crypt_Int* op1, const Crypt_Int* op2)\n{\n    return BnUnsignedCmp((bigConst)op1, (bigConst)op2);\n}\n\n//*** ExtMath_UnsignedCmpWord()\n// Compare a Crypt_Int* to a crypt_uword_t.\n//  Return Type: int\n//      -1              op1 is less that word\n//      0               op1 is equal to word\n//      1               op1 is greater than word\nLIB_EXPORT int ExtMath_UnsignedCmpWord(const Crypt_Int* op1, crypt_uword_t word)\n{\n    return BnUnsignedCmpWord((bigConst)op1, word);\n}\n\nLIB_EXPORT BOOL ExtMath_IsEqualWord(const Crypt_Int* bn, crypt_uword_t word)\n{\n    return BnEqualWord((bigConst)bn, word);\n}\n\nLIB_EXPORT BOOL ExtMath_IsZero(const Crypt_Int* op1)\n{\n    return BnEqualZero((bigConst)op1);\n}\n\n//*** ExtMath_MostSigBitNum()\n// This function returns the number of the MSb of a Crypt_Int* value.\n//  Return Type: int\n//      -1              the word was zero or 'bn' was NULL\n//      n               the bit number of the most significant bit in the word\nLIB_EXPORT int ExtMath_MostSigBitNum(const Crypt_Int* bn)\n{\n    return BnMsb((bigConst)bn);\n}\n\nLIB_EXPORT uint32_t ExtMath_GetLeastSignificant32bits(const Crypt_Int* bn)\n{\n    MUST_BE(RADIX_BITS >= 32);\n#if RADIX_BITS == 32\n    return BnGetWord(bn, 0);\n#else\n    // RADIX_BITS must be > 32 by MUST_BE above.\n    return (uint32_t)(BnGetWord(bn, 0) & 0xFFFFFFFF);\n#endif\n}\n\n//*** ExtMath_SizeInBits()\n// This function returns the number of bits required to hold a number. It is one\n// greater than the Msb.\nLIB_EXPORT unsigned ExtMath_SizeInBits(const Crypt_Int* n)\n{\n    return BnSizeInBits((bigConst)n);\n}\n\n// ###############################\n// Bitwise Operations\n// ###############################\n\nLIB_EXPORT BOOL ExtMath_SetBit(Crypt_Int* bn, unsigned int bitNum)\n{\n    return BnSetBit((bigNum)bn, bitNum);\n}\n\n// This function is used to check to see if a bit is SET in a bigNum_t. The 0th bit\n//*** ExtMath_TestBit()\n// is the LSb of d[0].\n//  Return Type: BOOL\n//      TRUE(1)         the bit is set\n//      FALSE(0)        the bit is not set or the number is out of range\nLIB_EXPORT BOOL ExtMath_TestBit(Crypt_Int*   bn,     // IN: number to check\n\t\t\t\tunsigned int bitNum  // IN: bit to test\n\t\t\t\t)\n{\n    return BnTestBit((bigNum)bn, bitNum);\n}\n\n//***ExtMath_MaskBits()\n// This function is used to mask off high order bits of a big number.\n// The returned value will have no more than 'maskBit' bits\n// set.\n// Note: There is a requirement that unused words of a bigNum_t are set to zero.\n//  Return Type: BOOL\n//      TRUE(1)         result masked\n//      FALSE(0)        the input was not as large as the mask\nLIB_EXPORT BOOL ExtMath_MaskBits(\n\t\t\t\t Crypt_Int*    bn,      // IN/OUT: number to mask\n\t\t\t\t crypt_uword_t maskBit  // IN: the bit number for the mask.\n\t\t\t\t )\n{\n    return BnMaskBits((bigNum)bn, maskBit);\n}\n\n//*** ExtMath_ShiftRight()\n// This function will shift a Crypt_Int* to the right by the shiftAmount.\n// This function always returns TRUE.\nLIB_EXPORT BOOL ExtMath_ShiftRight(\n\t\t\t\t   Crypt_Int* result, const Crypt_Int* toShift, uint32_t shiftAmount)\n{\n    return BnShiftRight((bigNum)result, (bigConst)toShift, shiftAmount);\n}\n\n// ***************************************************************************\n// ECC Functions\n// ***************************************************************************\n// ##################\n// Point initializers\n// ##################\nLIB_EXPORT Crypt_Point* ExtEcc_Initialize_Point(Crypt_Point* point, NUMBYTES bitCount)\n{\n    // Since we define the structure, we know that BN_POINT_BUFs are a bn_point_t followed by bignums.\n    // and that the size is always the MAX_ECC_KEY_SIZE\n    // tell the individual bignums how large they are:\n    bn_fullpoint_t* pBuf = (bn_fullpoint_t*)point;\n    BnInit((bigNum) & (pBuf->x), BN_STRUCT_ALLOCATION(bitCount));\n    BnInit((bigNum) & (pBuf->y), BN_STRUCT_ALLOCATION(bitCount));\n    BnInit((bigNum) & (pBuf->z), BN_STRUCT_ALLOCATION(bitCount));\n    \n    // now feed the addresses of those coordinates to the bn_point_t structure\n    bn_point_t* bnPoint = (bn_point_t*)point;\n    BnInitializePoint(\n\t\t      bnPoint, (bigNum) & (pBuf->x), (bigNum) & (pBuf->y), (bigNum) & (pBuf->z));\n    return point;\n}\n\n// ##################\n// Curve initializers\n// ##################\nLIB_EXPORT const Crypt_EccCurve* ExtEcc_CurveInitialize(Crypt_EccCurve* E,\n\t\t\t\t\t\t\tTPM_ECC_CURVE   curveId)\n{\n    return BnCurveInitialize((bigCurveData*)E, curveId);\n}\n\n// #################\n// Curve DESTRUCTOR\n// #################\n// WARNING: Not guaranteed to be called in presence of LONGJMP.\nLIB_EXPORT void ExtEcc_CurveFree(const Crypt_EccCurve* E)\n{\n    BnCurveFree((bigCurveData*)E);\n}\n\n// #################\n// Buffer Converters\n// #################\n//*** BnPointFromBytes()\n// Function to create a BIG_POINT structure from a 2B point.\n// A point is going to be two ECC values in the same buffer. The values are going\n// to be the size of the modulus.  They are in modular form.\nLIB_EXPORT Crypt_Point* ExtEcc_PointFromBytes(Crypt_Point* point,\n\t\t\t\t\t      const BYTE*  x,\n\t\t\t\t\t      NUMBYTES     nBytesX,\n\t\t\t\t\t      const BYTE*  y,\n\t\t\t\t\t      NUMBYTES     nBytesY)\n{\n    return (Crypt_Point*)BnPointFromBytes((bigPoint)point, x, nBytesX, y, nBytesY);\n}\n\nLIB_EXPORT BOOL ExtEcc_PointToBytes(const Crypt_Point* point,\n\t\t\t\t    BYTE* x, NUMBYTES* pBytesX,\n\t\t\t\t    BYTE* y, NUMBYTES* pBytesY)\n{\n    return BnPointToBytes((pointConst)point, x, pBytesX, y, pBytesY);\n}\n\n// ####################\n// ECC Point Operations\n// ####################\n//** ExtEcc_PointMultiply()\n// This function does a point multiply of the form R = [d]S. A return of FALSE\n// indicates that the result was the point at infinity. This function is only needed\n// if the TPM supports ECC.\nLIB_EXPORT BOOL ExtEcc_PointMultiply(\n\t\t\t\t     Crypt_Point* R, const Crypt_Point* S, const Crypt_Int* d, const Crypt_EccCurve* E)\n{\n    return BnEccModMult((bigPoint)R, (pointConst)S, (bigConst)d, (bigCurveData*)E);\n}\n\n//** ExtEcc_PointMultiplyAndAdd()\n// This function does a point multiply of the form R = [d]S + [u]Q. A return of\n// FALSE indicates that the result was the point at infinity. This function is only\n// needed if the TPM supports ECC.\nLIB_EXPORT BOOL ExtEcc_PointMultiplyAndAdd(Crypt_Point*          R,\n\t\t\t\t\t   const Crypt_Point*    S,\n\t\t\t\t\t   const Crypt_Int*      d,\n\t\t\t\t\t   const Crypt_Point*    Q,\n\t\t\t\t\t   const Crypt_Int*      u,\n\t\t\t\t\t   const Crypt_EccCurve* E)\n{\n    return BnEccModMult2((bigPoint)R,\n\t\t\t (pointConst)S,\n\t\t\t (bigConst)d,\n\t\t\t (pointConst)Q,\n\t\t\t (bigConst)u,\n\t\t\t (bigCurveData*)E);\n}\n\nLIB_EXPORT BOOL ExtEcc_PointAdd(Crypt_Point*          R,\n\t\t\t\tconst Crypt_Point*    S,\n\t\t\t\tconst Crypt_Point*    Q,\n\t\t\t\tconst Crypt_EccCurve* E)\n{\n    return BnEccAdd((bigPoint)R, (pointConst)S, (pointConst)Q, (bigCurveData*)E);\n}\n\n// #####################\n// ECC Point Information\n// #####################\nLIB_EXPORT BOOL ExtEcc_IsPointOnCurve(const Crypt_Point* Q, const Crypt_EccCurve* E)\n{\n    return BnIsPointOnCurve((pointConst)Q, AccessCurveConstants(E));\n}\n\nLIB_EXPORT const Crypt_Int* ExtEcc_PointX(const Crypt_Point* point)\n{\n    return (const Crypt_Int*)(((pointConst)point)->x);\n}\n\nLIB_EXPORT BOOL ExtEcc_IsInfinityPoint(const Crypt_Point* point)\n{\n    return BnEqualZero(((pointConst)point)->z);\n}\n\n// #####################\n// ECC Curve Information\n// #####################\nLIB_EXPORT const Crypt_Int* ExtEcc_CurveGetPrime(TPM_ECC_CURVE curveId)\n{\n    return (const Crypt_Int*)BnCurveGetPrime(BnGetCurveData(curveId));\n}\n\nLIB_EXPORT const Crypt_Int* ExtEcc_CurveGetOrder(TPM_ECC_CURVE curveId)\n{\n    return (const Crypt_Int*)BnCurveGetOrder(BnGetCurveData(curveId));\n}\n\nLIB_EXPORT const Crypt_Int* ExtEcc_CurveGetCofactor(TPM_ECC_CURVE curveId)\n{\n    return (const Crypt_Int*)BnCurveGetCofactor(BnGetCurveData(curveId));\n}\n\nLIB_EXPORT const Crypt_Int* ExtEcc_CurveGet_a(TPM_ECC_CURVE curveId)\n{\n    return (const Crypt_Int*)BnCurveGet_a(BnGetCurveData(curveId));\n}\n\nLIB_EXPORT const Crypt_Int* ExtEcc_CurveGet_b(TPM_ECC_CURVE curveId)\n{\n    return (const Crypt_Int*)BnCurveGet_b(BnGetCurveData(curveId));\n}\n\nLIB_EXPORT const Crypt_Point* ExtEcc_CurveGetG(TPM_ECC_CURVE curveId)\n{\n    return (const Crypt_Point*)BnCurveGetG(BnGetCurveData(curveId));\n}\n\nLIB_EXPORT const Crypt_Int* ExtEcc_CurveGetGx(TPM_ECC_CURVE curveId)\n{\n    return (const Crypt_Int*)BnCurveGetGx(BnGetCurveData(curveId));\n}\n\nLIB_EXPORT const Crypt_Int* ExtEcc_CurveGetGy(TPM_ECC_CURVE curveId)\n{\n    return (const Crypt_Int*)BnCurveGetGy(BnGetCurveData(curveId));\n}\n\nLIB_EXPORT TPM_ECC_CURVE ExtEcc_CurveGetCurveId(const Crypt_EccCurve* E)\n{\n    return BnCurveGetCurveId(AccessCurveConstants(E));\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmEcc_Signature_ECDAA.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"TpmEcc_Signature_ECDAA_fp.h\"\n#include \"TpmEcc_Signature_Util_fp.h\"\n#include \"TpmMath_Debug_fp.h\"\n#include \"TpmMath_Util_fp.h\"\n\n#if ALG_ECC && ALG_ECDAA\n\n//*** TpmEcc_SignEcdaa()\n//\n// This function performs 's' = 'r' + 'T' * 'd' mod 'q' where\n// 1) 'r' is a random, or pseudo-random value created in the commit phase\n// 2) 'nonceK' is a TPM-generated, random value 0 < 'nonceK' < 'n'\n// 3) 'T' is mod 'q' of \"Hash\"('nonceK' || 'digest'), and\n// 4) 'd' is a private key.\n//\n// The signature is the tuple ('nonceK', 's')\n//\n// Regrettably, the parameters in this function kind of collide with the parameter\n// names used in ECSCHNORR making for a lot of confusion.\n//  Return Type: TPM_RC\n//      TPM_RC_SCHEME       unsupported hash algorithm\n//      TPM_RC_NO_RESULT    cannot get values from random number generator\nTPM_RC TpmEcc_SignEcdaa(\n\t\t\tTPM2B_ECC_PARAMETER*  nonceK,  // OUT: 'nonce' component of the signature\n\t\t\tCrypt_Int*            bnS,     // OUT: 's' component of the signature\n\t\t\tconst Crypt_EccCurve* E,       // IN: the curve used in signing\n\t\t\tCrypt_Int*            bnD,     // IN: the private key\n\t\t\tconst TPM2B_DIGEST*   digest,  // IN: the value to sign (mod 'q')\n\t\t\tTPMT_ECC_SCHEME*      scheme,  // IN: signing scheme (contains the\n\t\t\t//      commit count value).\n\t\t\tOBJECT*     eccKey,            // IN: The signing key\n\t\t\tRAND_STATE* rand               // IN: a random number state\n\t\t\t)\n{\n    TPM_RC              retVal;\n    TPM2B_ECC_PARAMETER r;\n    HASH_STATE          state;\n    TPM2B_DIGEST        T;\n    CRYPT_INT_MAX(bnT);\n    //\n    NOT_REFERENCED(rand);\n    if(!CryptGenerateR(&r,\n\t\t       &scheme->details.ecdaa.count,\n\t\t       eccKey->publicArea.parameters.eccDetail.curveID,\n\t\t       &eccKey->name))\n\tretVal = TPM_RC_VALUE;\n    else\n\t{\n\t    // This allocation is here because 'r' doesn't have a value until\n\t    // CrypGenerateR() is done.\n\t    CRYPT_ECC_INITIALIZED(bnR, &r);\n\t    do\n\t\t{\n\t\t    // generate nonceK such that 0 < nonceK < n\n\t\t    // use bnT as a temp.\n\t\t    if(!TpmEcc_GenPrivateScalar(bnT, E, rand))\n\t\t\t{\n\t\t\t    retVal = TPM_RC_NO_RESULT;\n\t\t\t    break;\n\t\t\t}\n\t\t    TpmMath_IntTo2B(bnT, &nonceK->b, 0);\n\n\t\t    T.t.size = CryptHashStart(&state, scheme->details.ecdaa.hashAlg);\n\t\t    if(T.t.size == 0)\n\t\t\t{\n\t\t\t    retVal = TPM_RC_SCHEME;\n\t\t\t}\n\t\t    else\n\t\t\t{\n\t\t\t    CryptDigestUpdate2B(&state, &nonceK->b);\n\t\t\t    CryptDigestUpdate2B(&state, &digest->b);\n\t\t\t    CryptHashEnd2B(&state, &T.b);\n\t\t\t    TpmMath_IntFrom2B(bnT, &T.b);\n\t\t\t    // Watch out for the name collisions in this call!!\n\t\t\t    retVal = TpmEcc_SchnorrCalculateS(\n\t\t\t\t\t\t\t      bnS,\n\t\t\t\t\t\t\t      bnR,\n\t\t\t\t\t\t\t      bnT,\n\t\t\t\t\t\t\t      bnD,\n\t\t\t\t\t\t\t      ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E)));\n\t\t\t}\n\t\t} while(retVal == TPM_RC_NO_RESULT);\n\t    // Because the rule is that internal state is not modified if the command\n\t    // fails, only end the commit if the command succeeds.\n\t    // NOTE that if the result of the Schnorr computation was zero\n\t    // it will probably not be worthwhile to run the same command again because\n\t    // the result will still be zero. This means that the Commit command will\n\t    // need to be run again to get a new commit value for the signature.\n\t    if(retVal == TPM_RC_SUCCESS)\n\t\tCryptEndCommit(scheme->details.ecdaa.count);\n\t}\n    return retVal;\n}\n\n#endif  // ALG_ECC && ALG_ECDAA\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmEcc_Signature_ECDSA.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"TpmEcc_Signature_ECDSA_fp.h\"\n#include \"TpmMath_Debug_fp.h\"\n#include \"TpmMath_Util_fp.h\"\n\n#if ALG_ECC && ALG_ECDSA\n//*** TpmEcc_AdjustEcdsaDigest()\n// Function to adjust the digest so that it is no larger than the order of the\n// curve. This is used for ECDSA sign and verification.\nstatic Crypt_Int* TpmEcc_AdjustEcdsaDigest(\n\t\t\t\t\t   Crypt_Int*          bnD,     // OUT: the adjusted digest\n\t\t\t\t\t   const TPM2B_DIGEST* digest,  // IN: digest to adjust\n\t\t\t\t\t   const Crypt_Int*    max      // IN: value that indicates the maximum\n\t\t\t\t\t   //     number of bits in the results\n\t\t\t\t\t   )\n{\n    int bitsInMax = ExtMath_SizeInBits(max);\n    int shift;\n    //\n    if(digest == NULL)\n\tExtMath_SetWord(bnD, 0);\n    else\n\t{\n\t    ExtMath_IntFromBytes(bnD,\n\t\t\t\t digest->t.buffer,\n\t\t\t\t (NUMBYTES)MIN(digest->t.size, BITS_TO_BYTES(bitsInMax)));\n\t    shift = ExtMath_SizeInBits(bnD) - bitsInMax;\n\t    if(shift > 0)\n\t\tExtMath_ShiftRight(bnD, bnD, shift);\n\t}\n    return bnD;\n}\n\n//*** TpmEcc_SignEcdsa()\n// This function implements the ECDSA signing algorithm. The method is described\n// in the comments below.\nTPM_RC\nTpmEcc_SignEcdsa(Crypt_Int*            bnR,   // OUT: 'r' component of the signature\n\t\t Crypt_Int*            bnS,   // OUT: 's' component of the signature\n\t\t const Crypt_EccCurve* E,     // IN: the curve used in the signature\n\t\t //     process\n\t\t Crypt_Int*          bnD,     // IN: private signing key\n\t\t const TPM2B_DIGEST* digest,  // IN: the digest to sign\n\t\t RAND_STATE*         rand     // IN: used in debug of signing\n\t\t )\n{\n    CRYPT_ECC_NUM(bnK);\n    CRYPT_ECC_NUM(bnIk);\n    CRYPT_INT_VAR(bnE, MAX_ECC_KEY_BITS);\n    CRYPT_POINT_VAR(ecR);\n    CRYPT_ECC_NUM(bnX);\n    const Crypt_Int* order  = ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E));\n    TPM_RC           retVal = TPM_RC_SUCCESS;\n    INT32            tries  = 10;\n    BOOL             OK     = FALSE;\n    //\n    pAssert(digest != NULL);\n    // The algorithm as described in \"Suite B Implementer's Guide to FIPS\n    // 186-3(ECDSA)\"\n    // 1. Use one of the routines in Appendix A.2 to generate (k, k^-1), a\n    //    per-message secret number and its inverse modulo n. Since n is prime,\n    //    the output will be invalid only if there is a failure in the RBG.\n    // 2. Compute the elliptic curve point R = [k]G = (xR, yR) using EC scalar\n    //    multiplication (see [Routines]), where G is the base point included in\n    //    the set of domain parameters.\n    // 3. Compute r = xR mod n. If r = 0, then return to Step 1. 1.\n    // 4. Use the selected hash function to compute H = Hash(M).\n    // 5. Convert the bit string H to an integer e as described in Appendix B.2.\n    // 6. Compute s = (k^-1 *  (e + d *  r)) mod q. If s = 0, return to Step 1.2.\n    // 7. Return (r, s).\n    // In the code below, q is n (that it, the order of the curve is p)\n\n    do  // This implements the loop at step 6. If s is zero, start over.\n\t{\n\t    for(; tries > 0; tries--)\n\t\t{\n\t\t    // Step 1 and 2 -- generate an ephemeral key and the modular inverse\n\t\t    // of the private key.\n\t\t    if(!TpmEcc_GenerateKeyPair(bnK, ecR, E, rand))\n\t\t\tcontinue;\n\t\t    // get mutable copy of X coordinate\n\t\t    ExtMath_Copy(bnX, ExtEcc_PointX(ecR));\n\t\t    // x coordinate is mod p.  Make it mod q\n\t\t    ExtMath_Mod(bnX, order);\n\t\t    // Make sure that it is not zero;\n\t\t    if(ExtMath_IsZero(bnX))\n\t\t\tcontinue;\n\t\t    // write the modular reduced version of r as part of the signature\n\t\t    ExtMath_Copy(bnR, bnX);\n\t\t    // Make sure that a modular inverse exists and try again if not\n\t\t    OK = (ExtMath_ModInverse(bnIk, bnK, order));\n\t\t    if(OK)\n\t\t\tbreak;\n\t\t}\n\t    if(!OK)\n\t\tgoto Exit;\n\n\t    TpmEcc_AdjustEcdsaDigest(bnE, digest, order);\n\n\t    // now have inverse of K (bnIk), e (bnE), r (bnR),  d (bnD) and\n\t    // ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E))\n\t    // Compute s = k^-1 (e + r*d)(mod q)\n\t    //  first do s = r*d mod q\n\t    ExtMath_ModMult(bnS, bnR, bnD, order);\n\t    // s = e + s = e + r * d\n\t    ExtMath_Add(bnS, bnE, bnS);\n\t    // s = k^(-1)s (mod n) = k^(-1)(e + r * d)(mod n)\n\t    ExtMath_ModMult(bnS, bnIk, bnS, order);\n\n\t    // If S is zero, try again\n\t} while(ExtMath_IsZero(bnS));\n Exit:\n    return retVal;\n}\n\n//*** TpmEcc_ValidateSignatureEcdsa()\n// This function validates an ECDSA signature. rIn and sIn should have been checked\n// to make sure that they are in the range 0 < 'v' < 'n'\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE           signature not valid\nTPM_RC\nTpmEcc_ValidateSignatureEcdsa(\n\t\t\t      Crypt_Int*            bnR,  // IN: 'r' component of the signature\n\t\t\t      Crypt_Int*            bnS,  // IN: 's' component of the signature\n\t\t\t      const Crypt_EccCurve* E,    // IN: the curve used in the signature\n\t\t\t      //     process\n\t\t\t      const Crypt_Point*  ecQ,    // IN: the public point of the key\n\t\t\t      const TPM2B_DIGEST* digest  // IN: the digest that was signed\n\t\t\t      )\n{\n    // Make sure that the allocation for the digest is big enough for a maximum\n    // digest\n    CRYPT_INT_VAR(bnE, MAX_ECC_KEY_BITS);\n    CRYPT_POINT_VAR(ecR);\n    CRYPT_ECC_NUM(bnU1);\n    CRYPT_ECC_NUM(bnU2);\n    CRYPT_ECC_NUM(bnW);\n    CRYPT_ECC_NUM(bnV);\n    const Crypt_Int* order  = ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E));\n    TPM_RC           retVal = TPM_RC_SIGNATURE;\n    //\n    // Get adjusted digest\n    TpmEcc_AdjustEcdsaDigest(bnE, digest, order);\n    // 1. If r and s are not both integers in the interval [1, n - 1], output\n    //    INVALID.\n    //  bnR  and bnS were validated by the caller\n    // 2. Use the selected hash function to compute H0 = Hash(M0).\n    // This is an input parameter\n    // 3. Convert the bit string H0 to an integer e as described in Appendix B.2.\n    // Done at entry\n    // 4. Compute w = (s')^-1 mod n, using the routine in Appendix B.1.\n    if(!ExtMath_ModInverse(bnW, bnS, order))\n\tgoto Exit;\n    // 5. Compute u1 = (e' *   w) mod n, and compute u2 = (r' *  w) mod n.\n    ExtMath_ModMult(bnU1, bnE, bnW, order);\n    ExtMath_ModMult(bnU2, bnR, bnW, order);\n    // 6. Compute the elliptic curve point R = (xR, yR) = u1G+u2Q, using EC\n    //    scalar multiplication and EC addition (see [Routines]). If R is equal to\n    //    the point at infinity O, output INVALID.\n    if(TpmEcc_PointMult(\n\t\t\tecR, ExtEcc_CurveGetG(ExtEcc_CurveGetCurveId(E)), bnU1, ecQ, bnU2, E)\n       != TPM_RC_SUCCESS)\n\tgoto Exit;\n    // 7. Compute v = Rx mod n.\n    ExtMath_Copy(bnV, ExtEcc_PointX(ecR));\n    ExtMath_Mod(bnV, order);\n    // 8. Compare v and r0. If v = r0, output VALID; otherwise, output INVALID\n    if(ExtMath_UnsignedCmp(bnV, bnR) != 0)\n\tgoto Exit;\n\n    retVal = TPM_RC_SUCCESS;\n Exit:\n    return retVal;\n}\n\n#endif  // ALG_ECC && ALG_ECDSA\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmEcc_Signature_SM2.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"TpmEcc_Signature_SM2_fp.h\"\n#include \"TpmMath_Debug_fp.h\"\n#include \"TpmMath_Util_fp.h\"\n\n#if ALG_ECC && ALG_SM2\n\n//*** TpmEcc_SignEcSm2()\n// This function signs a digest using the method defined in SM2 Part 2. The method\n// in the standard will add a header to the message to be signed that is a hash of\n// the values that define the key. This then hashed with the message to produce a\n// digest ('e'). This function signs 'e'.\n//  Return Type: TPM_RC\n//      TPM_RC_VALUE         bad curve\nTPM_RC TpmEcc_SignEcSm2(Crypt_Int* bnR,  // OUT: 'r' component of the signature\n\t\t\tCrypt_Int* bnS,  // OUT: 's' component of the signature\n\t\t\tconst Crypt_EccCurve* E,    // IN: the curve used in signing\n\t\t\tCrypt_Int*            bnD,  // IN: the private key\n\t\t\tconst TPM2B_DIGEST*   digest,  // IN: the digest to sign\n\t\t\tRAND_STATE* rand  // IN: random number generator (mostly for\n\t\t\t//     debug)\n\t\t\t)\n{\n    CRYPT_INT_MAX_INITIALIZED(bnE, digest);  // Don't know how big digest might be\n    CRYPT_ECC_NUM(bnN);\n    CRYPT_ECC_NUM(bnK);\n    CRYPT_ECC_NUM(bnT);  // temp\n    CRYPT_POINT_VAR(Q1);\n    const Crypt_Int* order =\n\t(E != NULL) ? ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E)) : NULL;\n    //\n#  ifdef _SM2_SIGN_DEBUG\n    TpmEccDebug_FromHex(bnE,\n\t\t\t\"B524F552CD82B8B028476E005C377FB1\"\n\t\t\t\"9A87E6FC682D48BB5D42E3D9B9EFFE76\",\n\t\t\tMAX_ECC_KEY_BYTES);\n    TpmEccDebug_FromHex(bnD,\n\t\t\t\"128B2FA8BD433C6C068C8D803DFF7979\"\n\t\t\t\"2A519A55171B1B650C23661D15897263\",\n\t\t\tMAX_ECC_KEY_BYTES);\n#  endif\n    // A3: Use random number generator to generate random number 1 <= k <= n-1;\n    // NOTE: Ax: numbers are from the SM2 standard\n loop:\n    {\n\t// Get a random number 0 < k < n\n\tTpmMath_GetRandomInRange(bnK, order, rand);\n#  ifdef _SM2_SIGN_DEBUG\n\tTpmEccDebug_FromHex(bnK,\n\t\t\t    \"6CB28D99385C175C94F94E934817663F\"\n\t\t\t    \"C176D925DD72B727260DBAAE1FB2F96F\",\n\t\t\t    MAX_ECC_KEY_BYTES);\n#  endif\n\t// A4: Figure out the point of elliptic curve (x1, y1)=[k]G, and according\n\t// to details specified in 4.2.7 in Part 1 of this document, transform the\n\t// data type of x1 into an integer;\n\tif(!ExtEcc_PointMultiply(Q1, NULL, bnK, E))\n\t    goto loop;\n\t// A5: Figure out 'r' = ('e' + 'x1') mod 'n',\n\tExtMath_Add(bnR, bnE, ExtEcc_PointX(Q1));\n\tExtMath_Mod(bnR, order);\n#  ifdef _SM2_SIGN_DEBUG\n\tpAssert(TpmEccDebug_HexEqual(bnR,\n\t\t\t\t     \"40F1EC59F793D9F49E09DCEF49130D41\"\n\t\t\t\t     \"94F79FB1EED2CAA55BACDB49C4E755D1\"));\n#  endif\n\t// if r=0 or r+k=n, return to A3;\n\tif(ExtMath_IsZero(bnR))\n\t    goto loop;\n\tExtMath_Add(bnT, bnK, bnR);\n\tif(ExtMath_UnsignedCmp(bnT, bnN) == 0)\n\t    goto loop;\n\t// A6: Figure out s = ((1 + dA)^-1  (k - r  dA)) mod n,\n\t// if s=0, return to A3;\n\t// compute t = (1+dA)^-1\n\tExtMath_AddWord(bnT, bnD, 1);\n\tExtMath_ModInverse(bnT, bnT, order);\n#  ifdef _SM2_SIGN_DEBUG\n\tpAssert(TpmEccDebug_HexEqual(bnT,\n\t\t\t\t     \"79BFCF3052C80DA7B939E0C6914A18CB\"\n\t\t\t\t     \"B2D96D8555256E83122743A7D4F5F956\"));\n#  endif\n\t// compute s = t * (k - r * dA) mod n\n\tExtMath_ModMult(bnS, bnR, bnD, order);\n\t// k - r * dA mod n = k + n - ((r * dA) mod n)\n\tExtMath_Subtract(bnS, order, bnS);\n\tExtMath_Add(bnS, bnK, bnS);\n\tExtMath_ModMult(bnS, bnS, bnT, order);\n#  ifdef _SM2_SIGN_DEBUG\n\tpAssert(TpmEccDebug_HexEqual(bnS,\n\t\t\t\t     \"6FC6DAC32C5D5CF10C77DFB20F7C2EB6\"\n\t\t\t\t     \"67A457872FB09EC56327A67EC7DEEBE7\"));\n#  endif\n\tif(ExtMath_IsZero(bnS))\n\t    goto loop;\n    }\n    // A7: According to details specified in 4.2.1 in Part 1 of this document,\n    // transform the data type of r, s into bit strings, signature of message M\n    // is (r, s).\n    // This is handled by the common return code\n#  ifdef _SM2_SIGN_DEBUG\n    pAssert(TpmEccDebug_HexEqual(bnR,\n\t\t\t\t \"40F1EC59F793D9F49E09DCEF49130D41\"\n\t\t\t\t \"94F79FB1EED2CAA55BACDB49C4E755D1\"));\n    pAssert(TpmEccDebug_HexEqual(bnS,\n\t\t\t\t \"6FC6DAC32C5D5CF10C77DFB20F7C2EB6\"\n\t\t\t\t \"67A457872FB09EC56327A67EC7DEEBE7\"));\n#  endif\n    return TPM_RC_SUCCESS;\n}\n\n//*** TpmEcc_ValidateSignatureEcSm2()\n// This function is used to validate an SM2 signature.\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE            signature not valid\nTPM_RC TpmEcc_ValidateSignatureEcSm2(\n\t\t\t\t     Crypt_Int*            bnR,  // IN: 'r' component of the signature\n\t\t\t\t     Crypt_Int*            bnS,  // IN: 's' component of the signature\n\t\t\t\t     const Crypt_EccCurve* E,    // IN: the curve used in the signature\n\t\t\t\t     //     process\n\t\t\t\t     Crypt_Point*        ecQ,    // IN: the public point of the key\n\t\t\t\t     const TPM2B_DIGEST* digest  // IN: the digest that was signed\n\t\t\t\t     )\n{\n    CRYPT_POINT_VAR(P);\n    CRYPT_ECC_NUM(bnRp);\n    CRYPT_ECC_NUM(bnT);\n    CRYPT_INT_MAX_INITIALIZED(bnE, digest);\n    BOOL             OK;\n    const Crypt_Int* order = ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E));\n\n#  ifdef _SM2_SIGN_DEBUG\n    // Make sure that the input signature is the test signature\n    pAssert(TpmEccDebug_HexEqual(bnR,\n\t\t\t\t \"40F1EC59F793D9F49E09DCEF49130D41\"\n\t\t\t\t \"94F79FB1EED2CAA55BACDB49C4E755D1\"));\n    pAssert(TpmEccDebug_HexEqual(bnS,\n\t\t\t\t \"6FC6DAC32C5D5CF10C77DFB20F7C2EB6\"\n\t\t\t\t \"67A457872FB09EC56327A67EC7DEEBE7\"));\n#  endif\n    // b)   compute t  := (r + s) mod n\n    ExtMath_Add(bnT, bnR, bnS);\n    ExtMath_Mod(bnT, order);\n#  ifdef _SM2_SIGN_DEBUG\n    pAssert(TpmEccDebug_HexEqual(bnT,\n\t\t\t\t \"2B75F07ED7ECE7CCC1C8986B991F441A\"\n\t\t\t\t \"D324D6D619FE06DD63ED32E0C997C801\"));\n#  endif\n    // c)   verify that t > 0\n    OK = !ExtMath_IsZero(bnT);\n    if(!OK)\n\t// set T to a value that should allow rest of the computations to run\n\t// without trouble\n\tExtMath_Copy(bnT, bnS);\n    // d)   compute (x, y) := [s]G + [t]Q\n    OK = ExtEcc_PointMultiplyAndAdd(P, NULL, bnS, ecQ, bnT, E);\n#  ifdef _SM2_SIGN_DEBUG\n    pAssert(OK\n\t    && TpmEccDebug_HexEqual(ExtEcc_PointX(P),\n\t\t\t\t    \"110FCDA57615705D5E7B9324AC4B856D\"\n\t\t\t\t    \"23E6D9188B2AE47759514657CE25D112\"));\n#  endif\n    // e)   compute r' := (e + x) mod n (the x coordinate is in bnT)\n    OK = OK && ExtMath_Add(bnRp, bnE, ExtEcc_PointX(P));\n    OK = OK && ExtMath_Mod(bnRp, order);\n\n    // f)   verify that r' = r\n    OK = OK && (ExtMath_UnsignedCmp(bnR, bnRp) == 0);\n\n    if(!OK)\n\treturn TPM_RC_SIGNATURE;\n    else\n\treturn TPM_RC_SUCCESS;\n}\n\n#endif  // ALG_ECC && ALG_SM2\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmEcc_Signature_Schnorr.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"TpmEcc_Signature_Schnorr_fp.h\"\n#include \"TpmEcc_Signature_Util_fp.h\"\n#include \"TpmMath_Debug_fp.h\"\n#include \"TpmMath_Util_fp.h\"\n\n#if ALG_ECC && ALG_ECSCHNORR\n\n//*** SchnorrReduce()\n// Function to reduce a hash result if it's magnitude is too large. The size of\n// 'number' is set so that it has no more bytes of significance than 'reference'\n// value. If the resulting number can have more bits of significance than\n// 'reference'.\nstatic void SchnorrReduce(TPM2B*           number,    // IN/OUT: Value to reduce\n\t\t\t  const Crypt_Int* reference  // IN: the reference value\n\t\t\t  )\n{\n    UINT16 maxBytes = (UINT16)BITS_TO_BYTES(ExtMath_SizeInBits(reference));\n    if(number->size > maxBytes)\n\tnumber->size = maxBytes;\n}\n\n//*** SchnorrEcc()\n// This function is used to perform a modified Schnorr signature.\n//\n// This function will generate a random value 'k' and compute\n// a) ('xR', 'yR') = ['k']'G'\n// b) 'r' = \"Hash\"('xR' || 'P')(mod 'q')\n// c) 'rT' = truncated 'r'\n// d) 's'= 'k' + 'rT' * 'ds' (mod 'q')\n// e) return the tuple 'rT', 's'\n//\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        failure in the Schnorr sign process\n//      TPM_RC_SCHEME           hashAlg can't produce zero-length digest\nTPM_RC TpmEcc_SignEcSchnorr(\n\t\t\t    Crypt_Int*            bnR,      // OUT: 'r' component of the signature\n\t\t\t    Crypt_Int*            bnS,      // OUT: 's' component of the signature\n\t\t\t    const Crypt_EccCurve* E,        // IN: the curve used in signing\n\t\t\t    Crypt_Int*            bnD,      // IN: the signing key\n\t\t\t    const TPM2B_DIGEST*   digest,   // IN: the digest to sign\n\t\t\t    TPM_ALG_ID            hashAlg,  // IN: signing scheme (contains a hash)\n\t\t\t    RAND_STATE*           rand      // IN: non-NULL when testing\n\t\t\t    )\n{\n    HASH_STATE hashState;\n    UINT16     digestSize = CryptHashGetDigestSize(hashAlg);\n    TPM2B_TYPE(T, MAX(MAX_DIGEST_SIZE, MAX_ECC_KEY_BYTES));\n    TPM2B_T          T2b;\n    TPM2B*           e      = &T2b.b;\n    TPM_RC           retVal = TPM_RC_NO_RESULT;\n    const Crypt_Int* order;\n    const Crypt_Int* prime;\n    CRYPT_ECC_NUM(bnK);\n    CRYPT_POINT_VAR(ecR);\n    //\n    // Parameter checks\n    if(E == NULL)\n\tERROR_EXIT(TPM_RC_VALUE);\n\n    order = ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E));\n    prime = ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E));\n\n    // If the digest does not produce a hash, then null the signature and return\n    // a failure.\n    if(digestSize == 0)\n\t{\n\t    ExtMath_SetWord(bnR, 0);\n\t    ExtMath_SetWord(bnS, 0);\n\t    ERROR_EXIT(TPM_RC_SCHEME);\n\t}\n    do\n\t{\n\t    // Generate a random key pair\n\t    if(!TpmEcc_GenerateKeyPair(bnK, ecR, E, rand))\n\t\tbreak;\n\t    // Convert R.x to a string\n\t    TpmMath_IntTo2B(ExtEcc_PointX(ecR),\n\t\t\t    e,\n\t\t\t    (NUMBYTES)BITS_TO_BYTES(ExtMath_SizeInBits(prime)));\n\n\t    // f) compute r = Hash(e || P) (mod n)\n\t    CryptHashStart(&hashState, hashAlg);\n\t    CryptDigestUpdate2B(&hashState, e);\n\t    CryptDigestUpdate2B(&hashState, &digest->b);\n\t    e->size = CryptHashEnd(&hashState, digestSize, e->buffer);\n\t    // Reduce the hash size if it is larger than the curve order\n\t    SchnorrReduce(e, order);\n\t    // Convert hash to number\n\t    TpmMath_IntFrom2B(bnR, e);\n\t    // Do the Schnorr computation\n\t    retVal = TpmEcc_SchnorrCalculateS(\n\t\t\t\t\t      bnS, bnK, bnR, bnD, ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E)));\n\t} while(retVal == TPM_RC_NO_RESULT);\n Exit:\n    return retVal;\n}\n\n//*** TpmEcc_ValidateSignatureEcSchnorr()\n// This function is used to validate an EC Schnorr signature.\n//  Return Type: TPM_RC\n//      TPM_RC_SIGNATURE        signature not valid\nTPM_RC TpmEcc_ValidateSignatureEcSchnorr(\n\t\t\t\t\t Crypt_Int*            bnR,      // IN: 'r' component of the signature\n\t\t\t\t\t Crypt_Int*            bnS,      // IN: 's' component of the signature\n\t\t\t\t\t TPM_ALG_ID            hashAlg,  // IN: hash algorithm of the signature\n\t\t\t\t\t const Crypt_EccCurve* E,        // IN: the curve used in the signature\n\t\t\t\t\t //     process\n\t\t\t\t\t Crypt_Point*        ecQ,        // IN: the public point of the key\n\t\t\t\t\t const TPM2B_DIGEST* digest      // IN: the digest that was signed\n\t\t\t\t\t )\n{\n    CRYPT_INT_MAX(bnRn);\n    CRYPT_POINT_VAR(ecE);\n    CRYPT_INT_MAX(bnEx);\n    const Crypt_Int* order      = ExtEcc_CurveGetOrder(ExtEcc_CurveGetCurveId(E));\n    UINT16           digestSize = CryptHashGetDigestSize(hashAlg);\n    HASH_STATE       hashState;\n    TPM2B_TYPE(BUFFER, MAX(MAX_ECC_PARAMETER_BYTES, MAX_DIGEST_SIZE));\n    TPM2B_BUFFER Ex2 = {{sizeof(Ex2.t.buffer), {0}}};\n    BOOL         OK;\n    //\n    // E = [s]G - [r]Q\n    ExtMath_Mod(bnR, order);\n    // Make -r = n - r\n    ExtMath_Subtract(bnRn, order, bnR);\n    // E = [s]G + [-r]Q\n    OK = TpmEcc_PointMult(\n\t\t\t  ecE, ExtEcc_CurveGetG(ExtEcc_CurveGetCurveId(E)), bnS, ecQ, bnRn, E)\n\t == TPM_RC_SUCCESS;\n    //   // reduce the x portion of E mod q\n    //    OK = OK && ExtMath_Mod(ecE->x, order);\n    // Convert to byte string\n    OK = OK\n\t && TpmMath_IntTo2B(ExtEcc_PointX(ecE),\n\t\t\t    &Ex2.b,\n\t\t\t    (NUMBYTES)(BITS_TO_BYTES(ExtMath_SizeInBits(order))));\n    if(OK)\n\t{\n\t    // Ex = h(pE.x || digest)\n\t    CryptHashStart(&hashState, hashAlg);\n\t    CryptDigestUpdate(&hashState, Ex2.t.size, Ex2.t.buffer);\n\t    CryptDigestUpdate(&hashState, digest->t.size, digest->t.buffer);\n\t    Ex2.t.size = CryptHashEnd(&hashState, digestSize, Ex2.t.buffer);\n\t    SchnorrReduce(&Ex2.b, order);\n\t    TpmMath_IntFrom2B(bnEx, &Ex2.b);\n\t    // see if Ex matches R\n\t    OK = ExtMath_UnsignedCmp(bnEx, bnR) == 0;\n\t}\n    return (OK) ? TPM_RC_SUCCESS : TPM_RC_SIGNATURE;\n}\n\n#endif  // ALG_ECC && ALG_ECSCHNORR\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmEcc_Signature_Util.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// functions shared by multiple signature algorithms\n#include \"Tpm.h\"\n#include \"TpmEcc_Signature_Util_fp.h\"\n#include \"TpmMath_Debug_fp.h\"\n#include \"TpmMath_Util_fp.h\"\n\n#if(ALG_ECC && (ALG_ECSCHNORR || ALG_ECDAA))\n\n//*** TpmEcc_SchnorrCalculateS()\n// This contains the Schnorr signature (S) computation. It is used by both ECDAA and\n// Schnorr signing. The result is computed as: ['s' = 'k' + 'r' * 'd' (mod 'n')]\n// where\n// 1) 's' is the signature\n// 2) 'k' is a random value\n// 3) 'r' is the value to sign\n// 4) 'd' is the private EC key\n// 5) 'n' is the order of the curve\n//  Return Type: TPM_RC\n//      TPM_RC_NO_RESULT        the result of the operation was zero or 'r' (mod 'n')\n//                              is zero\nTPM_RC TpmEcc_SchnorrCalculateS(\n\t\t\t\tCrypt_Int*       bnS,  // OUT: 's' component of the signature\n\t\t\t\tconst Crypt_Int* bnK,  // IN: a random value\n\t\t\t\tCrypt_Int*       bnR,  // IN: the signature 'r' value\n\t\t\t\tconst Crypt_Int* bnD,  // IN: the private key\n\t\t\t\tconst Crypt_Int* bnN   // IN: the order of the curve\n\t\t\t\t)\n{\n    // Need a local temp value to store the intermediate computation because product\n    // size can be larger than will fit in bnS.\n    CRYPT_INT_VAR(bnT1, MAX_ECC_PARAMETER_BYTES * 2 * 8);\n    //\n    // Reduce bnR without changing the input value\n    ExtMath_Divide(NULL, bnT1, bnR, bnN);\n    if(ExtMath_IsZero(bnT1))\n\treturn TPM_RC_NO_RESULT;\n    // compute s = (k + r * d)(mod n)\n    // r * d\n    ExtMath_Multiply(bnT1, bnT1, bnD);\n    // k + r * d\n    ExtMath_Add(bnT1, bnT1, bnK);\n    // k + r * d (mod n)\n    ExtMath_Divide(NULL, bnS, bnT1, bnN);\n    return (ExtMath_IsZero(bnS)) ? TPM_RC_NO_RESULT : TPM_RC_SUCCESS;\n}\n\n#endif  // (ALG_ECC && (ALG_ECSCHNORR || ALG_ECDAA))\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmEcc_Util.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains utility functions to help using the external Math library\n// for Ecc functions.\n#include \"Tpm.h\"\n#include \"TpmMath_Util_fp.h\"\n#include \"TpmEcc_Util_fp.h\"\n\n#if ALG_ECC\n\n//***\n// TpmEcc_PointFrom2B() Function to create a Crypt_Point structure from a 2B\n// point. The target point is expected to have memory allocated and\n// uninitialized. A TPMS_ECC_POINT is going to be two ECC values in the same\n// buffer. The values are going to be the size of the modulus. They are in\n// modular form.\n//\n// NOTE: This function considers both parameters optional because of use\n// cases where points may not be specified in the calling function. If the\n// initializer or point buffer is NULL, then NULL is returned. As a result, the\n// only error detection when the initializer value is invalid is to return NULL\n// in that error case as well. If a caller wants to handle that error case\n// differently, then the caller must perform the correct validation before/after\n// this function.\nLIB_EXPORT Crypt_Point* TpmEcc_PointFrom2B(\n\t\t\t\t\t   Crypt_Point*    ecP,  // OUT: the preallocated point structure\n\t\t\t\t\t   TPMS_ECC_POINT* p     // IN: the number to convert\n\t\t\t\t\t   )\n{\n   if(p == NULL)\n\treturn NULL;\n\n    if(ecP != NULL)\n\t{\n\t    return ExtEcc_PointFromBytes(\n\t\t\t\t\t ecP, p->x.t.buffer, p->x.t.size, p->y.t.buffer, p->y.t.size);\n\t}\n    return ecP;  // will return NULL if ecP is NULL.\n}\n\n//*** TpmEcc_PointTo2B()\n// This function converts a BIG_POINT into a TPMS_ECC_POINT. A TPMS_ECC_POINT\n// contains two TPM2B_ECC_PARAMETER values. The maximum size of the parameters\n// is dependent on the maximum EC key size used in an implementation.\n// The presumption is that the TPMS_ECC_POINT is large enough to hold 2 TPM2B\n// values, each as large as a MAX_ECC_PARAMETER_BYTES\nLIB_EXPORT BOOL TpmEcc_PointTo2B(\n\t\t\t\t TPMS_ECC_POINT*       p,    // OUT: the converted 2B structure\n\t\t\t\t const Crypt_Point*    ecP,  // IN: the values to be converted\n\t\t\t\t const Crypt_EccCurve* E     // IN: curve descriptor for the point\n\t\t\t\t )\n{\n    pAssert(p && ecP && E);\n    TPM_ECC_CURVE curveId = ExtEcc_CurveGetCurveId(E);\n    NUMBYTES      size    = CryptEccGetKeySizeForCurve(curveId);\n    size                  = (UINT16)BITS_TO_BYTES(size);\n    MemorySet(p, 0, sizeof(*p));\n    p->x.t.size = size;\n    p->y.t.size = size;\n    return ExtEcc_PointToBytes(\n\t\t\t       ecP, p->x.t.buffer, &p->x.t.size, p->y.t.buffer, &p->y.t.size);\n}\n\n#endif  // ALG_ECC\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmFail.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Failure Mode Handling\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes, Defines, and Types\n#define TPM_FAIL_C\n#include \"Tpm.h\"\n\n// On MS C compiler, can save the alignment state and set the alignment to 1 for\n// the duration of the TpmTypes.h include.  This will avoid a lot of alignment\n// warnings from the compiler for the unaligned structures. The alignment of the\n// structures is not important as this function does not use any of the structures\n// in TpmTypes.h and only include it for the #defines of the capabilities,\n// properties, and command code values.\n#include \"TpmTypes.h\"\n\n//** Typedefs\n// These defines are used primarily for sizing of the local response buffer.\ntypedef struct\n{\n    TPM_ST tag;\n    UINT32 size;\n    TPM_RC code;\n} HEADER;\n\ntypedef struct\n{\n    BYTE tag[sizeof(TPM_ST)];\n    BYTE size[sizeof(UINT32)];\n    BYTE code[sizeof(TPM_RC)];\n} PACKED_HEADER;\n\ntypedef struct\n{\n    BYTE size[sizeof(UINT16)];\n    struct\n    {\n\tBYTE function[sizeof(UINT32)];\n\tBYTE line[sizeof(UINT32)];\n\tBYTE code[sizeof(UINT32)];\n    } values;\n    BYTE returnCode[sizeof(TPM_RC)];\n} GET_TEST_RESULT_PARAMETERS;\n\ntypedef struct\n{\n    BYTE moreData[sizeof(TPMI_YES_NO)];\n    BYTE capability[sizeof(TPM_CAP)];  // Always TPM_CAP_TPM_PROPERTIES\n    BYTE tpmProperty[sizeof(TPML_TAGGED_TPM_PROPERTY)];\n} GET_CAPABILITY_PARAMETERS;\n\ntypedef struct\n{\n    BYTE header[sizeof(PACKED_HEADER)];\n    BYTE getTestResult[sizeof(GET_TEST_RESULT_PARAMETERS)];\n} TEST_RESPONSE;\n\ntypedef struct\n{\n    BYTE header[sizeof(PACKED_HEADER)];\n    BYTE getCap[sizeof(GET_CAPABILITY_PARAMETERS)];\n} CAPABILITY_RESPONSE;\n\ntypedef union\n{\n    BYTE test[sizeof(TEST_RESPONSE)];\n    BYTE cap[sizeof(CAPABILITY_RESPONSE)];\n} RESPONSES;\n\n// Buffer to hold the responses. This may be a little larger than\n// required due to padding that a compiler might add.\n// Note: This is not in Global.c because of the specialized data definitions above.\n// Since the data contained in this structure is not relevant outside of the\n// execution of a single command (when the TPM is in failure mode. There is no\n// compelling reason to move all the typedefs to Global.h and this structure\n// to Global.c.\n#ifndef __IGNORE_STATE__  // Don't define this value\nstatic BYTE response[sizeof(RESPONSES)];\n#endif\n\n//** Local Functions\n\n//*** MarshalUint16()\n// Function to marshal a 16 bit value to the output buffer.\nstatic INT32 MarshalUint16(UINT16 integer, BYTE** buffer)\n{\n    UINT16_TO_BYTE_ARRAY(integer, *buffer);\n    *buffer += 2;\n    return 2;\n}\n\n//*** MarshalUint32()\n// Function to marshal a 32 bit value to the output buffer.\nstatic INT32 MarshalUint32(UINT32 integer, BYTE** buffer)\n{\n    UINT32_TO_BYTE_ARRAY(integer, *buffer);\n    *buffer += 4;\n    return 4;\n}\n\n//***Unmarshal32()\nstatic BOOL Unmarshal32(UINT32* target, BYTE** buffer, INT32* size)\n{\n    if((*size -= 4) < 0)\n\treturn FALSE;\n    *target = BYTE_ARRAY_TO_UINT32(*buffer);\n    *buffer += 4;\n    return TRUE;\n}\n\n//***Unmarshal16()\nstatic BOOL Unmarshal16(UINT16* target, BYTE** buffer, INT32* size)\n{\n    if((*size -= 2) < 0)\n\treturn FALSE;\n    *target = BYTE_ARRAY_TO_UINT16(*buffer);\n    *buffer += 2;\n    return TRUE;\n}\n\n//** Public Functions\n\n//*** SetForceFailureMode()\n// This function is called by the simulator to enable failure mode testing.\n#if ALLOW_FORCE_FAILURE_MODE\nLIB_EXPORT void SetForceFailureMode(void)\n{\n    g_forceFailureMode = TRUE;\n    return;\n}\n#endif  // ALLOW_FORCE_FAILURE_MODE\n\n//*** TpmFail()\n// This function is called by TPM.lib when a failure occurs. It will set up the\n// failure values to be returned on TPM2_GetTestResult().\n// NORETURN void TpmFail(\nvoid TpmFail(\n#if FAIL_TRACE\n\t\t      const char* function,\n\t\t      int         line,\n#else\n\t\t      uint64_t locationCode,\n#endif\n\t\t      int failureCode)\n{\n    // Save the values that indicate where the error occurred.\n    // On a 64-bit machine, this may truncate the address of the string\n    // of the function name where the error occurred.\n#if FAIL_TRACE\n    s_failFunctionName = function;\n    s_failFunction     = (UINT32)(ptrdiff_t)function;\n    s_failLine         = line;\n#else\n    s_failFunction = (UINT32)(locationCode >> 32);\n    s_failLine     = (UINT32)(locationCode);\n#endif\n    s_failCode = failureCode;\n\n    // We are in failure mode\n    g_inFailureMode = TRUE;\n\n    // Notify the platform that we hit a failure.\n    //\n    // In the LONGJMP case, the reference platform code is expected to long-jmp\n    // back to the ExecuteCommand call and output a failure response.\n    //\n    // In the NO_LONGJMP case, this is a notification to the platform, and the\n    // platform may take any (implementation-defined) behavior, including no-op,\n    // debugging, or whatever. The core library is expected to surface the failure\n    // back to ExecuteCommand through error propagation and return an appropriate\n    // failure reply.\n    // _plat__Fail();\n}\n\n//*** TpmFailureMode(\n// This function is called by the interface code when the platform is in failure\n// mode.\nvoid TpmFailureMode(uint32_t        inRequestSize,    // IN: command buffer size\n\t\t    unsigned char*  inRequest,        // IN: command buffer\n\t\t    uint32_t*       outResponseSize,  // OUT: response buffer size\n\t\t    unsigned char** outResponse       // OUT: response buffer\n\t\t    )\n{\n    UINT32 marshalSize;\n    UINT32 capability;\n    HEADER header;  // unmarshaled command header\n    UINT32 pt;      // unmarshaled property type\n    UINT32 count;   // unmarshaled property count\n    UINT8* buffer = inRequest;\n    INT32  size   = inRequestSize;\n\n    // If there is no command buffer, then just return TPM_RC_FAILURE\n    if(inRequestSize == 0 || inRequest == NULL)\n\tgoto FailureModeReturn;\n    // If the header is not correct for TPM2_GetCapability() or\n    // TPM2_GetTestResult() then just return the in failure mode response;\n    if(!(Unmarshal16(&header.tag, &buffer, &size)\n\t && Unmarshal32(&header.size, &buffer, &size)\n\t && Unmarshal32(&header.code, &buffer, &size)))\n\tgoto FailureModeReturn;\n    if(header.tag != TPM_ST_NO_SESSIONS || header.size < 10)\n\tgoto FailureModeReturn;\n    switch(header.code)\n\t{\n\t  case TPM_CC_GetTestResult:\n\t    // make sure that the command size is correct\n\t    if(header.size != 10)\n\t\tgoto FailureModeReturn;\n\t    buffer      = &response[10];\n\t    marshalSize = MarshalUint16(3 * sizeof(UINT32), &buffer);\n\t    marshalSize += MarshalUint32(s_failFunction, &buffer);\n\t    marshalSize += MarshalUint32(s_failLine, &buffer);\n\t    marshalSize += MarshalUint32(s_failCode, &buffer);\n\t    if(s_failCode == FATAL_ERROR_NV_UNRECOVERABLE)\n\t\tmarshalSize += MarshalUint32(TPM_RC_NV_UNINITIALIZED, &buffer);\n\t    else\n\t\tmarshalSize += MarshalUint32(TPM_RC_FAILURE, &buffer);\n\t    break;\n\t  case TPM_CC_GetCapability:\n\t    // make sure that the size of the command is exactly the size\n\t    // returned for the capability, property, and count\n\t    if(header.size != (10 + (3 * sizeof(UINT32)))\n\t       // also verify that this is requesting TPM properties\n\t       || !Unmarshal32(&capability, &buffer, &size)\n\t       || capability != TPM_CAP_TPM_PROPERTIES\n\t       || !Unmarshal32(&pt, &buffer, &size)\n\t       || !Unmarshal32(&count, &buffer, &size))\n\t\tgoto FailureModeReturn;\n\n\t    if(count > 0)\n\t\tcount = 1;\n\t    else if(pt > TPM_PT_FIRMWARE_VERSION_2)\n\t\tcount = 0;\n\t    if(pt < TPM_PT_MANUFACTURER)\n\t\tpt = TPM_PT_MANUFACTURER;\n\t    // set up for return\n\t    buffer = &response[10];\n\t    // if the request was for a PT less than the last one\n\t    // then we indicate more, otherwise, not.\n\t    if(pt < TPM_PT_FIRMWARE_VERSION_2)\n\t\t*buffer++ = YES;\n\t    else\n\t\t*buffer++ = NO;\n\t    marshalSize = 1;\n\n\t    // indicate the capability type\n\t    marshalSize += MarshalUint32(capability, &buffer);\n\t    // indicate the number of values that are being returned (0 or 1)\n\t    marshalSize += MarshalUint32(count, &buffer);\n\t    // indicate the property\n\t    marshalSize += MarshalUint32(pt, &buffer);\n\n\t    if(count > 0)\n\t\tswitch(pt)\n\t\t    {\n\t\t      case TPM_PT_MANUFACTURER:\n\t\t\t// the vendor ID unique to each TPM manufacturer\n\t\t\tpt = _plat__GetManufacturerCapabilityCode();\n\t\t\tbreak;\n\n\t\t      case TPM_PT_VENDOR_STRING_1:\n\t\t\t// the first four characters of the vendor ID string\n\t\t\tpt = _plat__GetVendorCapabilityCode(1);\n\t\t\tbreak;\n\n\t\t      case TPM_PT_VENDOR_STRING_2:\n\t\t\t// the second four characters of the vendor ID string\n\t\t\tpt = _plat__GetVendorCapabilityCode(2);\n\t\t\tbreak;\n\n\t\t      case TPM_PT_VENDOR_STRING_3:\n\t\t\t// the third four characters of the vendor ID string\n\t\t\tpt = _plat__GetVendorCapabilityCode(3);\n\t\t\tbreak;\n\n\t\t      case TPM_PT_VENDOR_STRING_4:\n\t\t\t// the fourth four characters of the vendor ID string\n\t\t\tpt = _plat__GetVendorCapabilityCode(4);\n\t\t\tbreak;\n\n\t\t      case TPM_PT_VENDOR_TPM_TYPE:\n\t\t\t// vendor-defined value indicating the TPM model\n\t\t\t// We just make up a number here\n\t\t\tpt = _plat__GetTpmType();\n\t\t\tbreak;\n\n\t\t      case TPM_PT_FIRMWARE_VERSION_1:\n\t\t\t// the more significant 32-bits of a vendor-specific value\n\t\t\t// indicating the version of the firmware\n\t\t\tpt = _plat__GetTpmFirmwareVersionHigh();\n\t\t\tbreak;\n\n\t\t      default:  // TPM_PT_FIRMWARE_VERSION_2:\n\t\t\t// the less significant 32-bits of a vendor-specific value\n\t\t\t// indicating the version of the firmware\n\t\t\tpt = _plat__GetTpmFirmwareVersionLow();\n\t\t\tbreak;\n\t\t    }\n\t    marshalSize += MarshalUint32(pt, &buffer);\n\t    break;\n\t  default:  // default for switch (cc)\n\t    goto FailureModeReturn;\n\t}\n    // Now do the header\n    buffer      = response;\n    marshalSize = marshalSize + 10;              // Add the header size to the\n    // stuff already marshaled\n    MarshalUint16(TPM_ST_NO_SESSIONS, &buffer);  // structure tag\n    MarshalUint32(marshalSize, &buffer);         // responseSize\n    MarshalUint32(TPM_RC_SUCCESS, &buffer);      // response code\n\n    *outResponseSize = marshalSize;\n    *outResponse     = (unsigned char*)&response;\n    return;\n FailureModeReturn:\n    buffer      = response;\n    marshalSize = MarshalUint16(TPM_ST_NO_SESSIONS, &buffer);\n    marshalSize += MarshalUint32(10, &buffer);\n    marshalSize += MarshalUint32(TPM_RC_FAILURE, &buffer);\n    *outResponseSize = marshalSize;\n    *outResponse     = (unsigned char*)response;\n    return;\n}\n\n//*** UnmarshalFail()\n// This is a stub that is used to catch an attempt to unmarshal an entry\n// that is not defined. Don't ever expect this to be called but...\nvoid UnmarshalFail(void* type, BYTE** buffer, INT32* size)\n{\n    NOT_REFERENCED(type);\n    NOT_REFERENCED(buffer);\n    NOT_REFERENCED(size);\n    FAIL(FATAL_ERROR_INTERNAL);\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmMath_Debug.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains debug utility functions to help testing Ecc.\n#include \"Tpm.h\"\n#include \"TpmEcc_Util_fp.h\"\n#include \"TpmMath_Debug_fp.h\"\n\n#if ALG_SM2\n#  ifdef _SM2_SIGN_DEBUG\n\n//*** SafeGetStringLength()\n// self-implemented version of strnlen_s.  This is necessary because\n// some environments don't have a C-runtime library, or are limited to\n// C99, and strnlen_s was standardized in C11.\nstatic size_t SafeGetStringLength(const char* string, size_t maxsize)\n{\n    // strnlen_s has two boundary conditions:\n    // return 0 if pointer is nullptr, or\n    // maxsize if no null character is found.\n    if(string == NULL)\n\treturn 0;\n    \n    const char* pos  = string;\n    size_t      size = 0;\n    \n    while(*pos != '\\0' && size < maxsize)\n\t{\n\t    pos++;\n\t    size++;\n\t}\n    return size;\n}\n\n// convert from hex value.  If invalid, result will be out of range.\nstatic LIB_EXPORT BYTE FromHex(unsigned char c)\n{\n    // hack for the ASCII characters we care about\n    BYTE upper = (c & (~0x20));\n    if(c >= '0' && c <= '9')\n\treturn c - '0';\n    else if(c >= 'A' && c <= 'F')\n\treturn c - 'A';\n    \n    return 255;\n}\n\n//*** TpmEccDebug_FromHex()\n// Convert a hex string into a Crypt_Int*. This is primarily used in debugging.\nLIB_EXPORT Crypt_Int* TpmEccDebug_FromHex(\n\t\t\t\t\t  Crypt_Int*           bn,         // OUT:\n\t\t\t\t\t  const unsigned char* hex,        // IN:\n\t\t\t\t\t  size_t               maxsizeHex  // IN: maximum size of hex\n\t\t\t\t\t  )\n{\n    // if value is larger than this, then fail\n    BYTE tempBuf[MAX_ECC_KEY_BYTES];\n    MemorySet(tempBuf, 0, sizeof(tempBuf));\n    ExtMath_SetWord(bn, 0);\n    \n    size_t len = SafeGetStringLength(hex, maxsizeHex);\n    BOOL   OK  = FALSE;\n    if((len % 2) == 0)\n\t{\n\t    OK = TRUE;\n\t    for(size_t i = 0; i < len; i += 2)\n\t\t{\n\t\t    BYTE highNibble = FromHex(*hex);\n\t\t    hex++;\n\t\t    BYTE lowNibble = FromHex(*hex);\n\t\t    hex++;\n\t\t    // unsigned, no need to check zero\n\t\t    if(highNibble > 15 || lowNibble > 15)\n\t\t\t{\n\t\t\t    OK = FALSE;\n\t\t\t    break;\n\t\t\t}\n\t\t    BYTE b         = ((highNibble << 4) | lowNibble);\n\t\t    tempBuf[i / 2] = b;\n\t\t}\n\t    if(OK)\n\t\t{\n\t\t    ExtMath_IntFromBytes(bn, tempBuf, (NUMBYTES)(len / 2));\n\t\t}\n\t}\n    \n    if(!OK)\n\t{\n\t    // this should only be called in testing, so any\n\t    // errors are fatal.\n\t    FAIL(FATAL_ERROR_INTERNAL);\n\t}\n    return bn;\n}\n\n//*** TpmEccDebug_HexEqual()\n// This function compares a bignum value to a hex string.\n// using TpmEcc namespace because code assumes the max size\n// is correct for ECC.\n//  Return Type: BOOL\n//      TRUE(1)         values equal\n//      FALSE(0)        values not equal\nBOOL TpmEccDebug_HexEqual(const Crypt_Int* bn,  //IN: big number value\n\t\t\t  const char*      c    //IN: character string number\n\t\t\t  )\n{\n    CRYPT_ECC_NUM(bnC);\n    TpmEccDebug_FromHex(bnC, c, MAX_ECC_KEY_BYTES * 2 + 1);\n    return (ExtMath_UnsignedCmp(bn, bnC) == 0);\n}\n#  endif  // _SM2_SIGN_DEBUG\n#endif    // ALG_SM2\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmMath_Util.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// This file contains utility functions to help using the external Math library\n#include \"Tpm.h\"\n#include \"TpmMath_Util_fp.h\"\n\n//*** TpmMath_IntFrom2B()\n// Convert an TPM2B to a Crypt_Int.\n// If the input value does not exist, or the output does not exist, or the input\n// will not fit into the output the function returns NULL\nLIB_EXPORT Crypt_Int* TpmMath_IntFrom2B(Crypt_Int*   value,  // OUT:\n\t\t\t\t\tconst TPM2B* a2B     // IN: number to convert\n\t\t\t\t\t)\n{\n    if(value != NULL && a2B != NULL)\n\treturn ExtMath_IntFromBytes(value, a2B->buffer, a2B->size);\n    return NULL;\n}\n\n//*** TpmMath_IntTo2B()\n//\n// Function to convert a Crypt_Int to TPM2B. The TPM2B bytes are\n// always in big-endian ordering (most significant byte first). If 'size' is\n// non-zero and less than required by `value` then an error is returned. If\n// `size` is non-zero and larger than `value`, the result buffer is padded\n// with zeros. If `size` is zero, then the TPM2B is assumed to be large enough\n// for the data and a2b->size will be adjusted accordingly.\nLIB_EXPORT BOOL TpmMath_IntTo2B(\n\t\t\t\tconst Crypt_Int* value,  // IN: value to convert\n\t\t\t\tTPM2B*           a2B,    // OUT: buffer for output\n\t\t\t\tNUMBYTES         size    // IN: Size of output buffer - see comments.\n\t\t\t\t)\n{\n    // Set the output size\n    if(value && a2B)\n\t{\n\t    a2B->size = size;\n\t    return ExtMath_IntToBytes(value, a2B->buffer, &a2B->size);\n\t}\n    return FALSE;\n}\n\n//*** TpmMath_GetRandomBits()\n// This function gets random bits for use in various places.\n//\n// One consequence of the generation scheme is that, if the number of bits requested\n// is not a multiple of 8, then the high-order bits are set to zero. This would come\n// into play when generating a 521-bit ECC key. A 66-byte (528-bit) value is\n// generated and the high order 7 bits are masked off (CLEAR).\n// In this situation, the highest order byte is the first byte (big-endian/TPM2B format)\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure\nLIB_EXPORT BOOL TpmMath_GetRandomBits(BYTE* pBuffer, size_t bits, RAND_STATE* rand)\n{\n    // buffer is assumed to be large enough for the number of bits rounded up to\n    // bytes.\n    NUMBYTES byteCount = (NUMBYTES)BITS_TO_BYTES(bits);\n    if(DRBG_Generate(rand, pBuffer, byteCount) == byteCount)\n\t{\n\t    // now flip the buffer order - this exists only to maintain\n\t    // compatibility with existing Known-value tests that expect the\n\t    // GetRandomInteger behavior of generating the value in little-endian\n\t    // order.\n\t    BYTE* pFrom = pBuffer + byteCount - 1;\n\t    BYTE* pTo   = pBuffer;\n\t    while(pTo < pFrom)\n\t\t{\n\t\t    BYTE t = *pTo;\n\t\t    *pTo   = *pFrom;\n\t\t    *pFrom = t;\n\t\t    pTo++;\n\t\t    pFrom--;\n\t\t}\n\t    // For a little-endian machine, the conversion is a straight byte\n\t    // reversal, done above. For a big-endian machine, we have to put the\n\t    // words in big-endian byte order.  COMPATIBILITY NOTE: This code does\n\t    // not exactly reproduce the original code, because the original big-num\n\t    // code always generated data in units of crypt_word_t sizes.  I.e. you\n\t    // couldn't generate just 9 bits for example.  This revised version of\n\t    // the function could; and would generate 2 bytes with the first byte\n\t    // masked to 1 bit.  In order to avoid running over the buffer when\n\t    // swapping crypt_uword_t blocks, this loop intentionally doesn't swap\n\t    // the last word if it is smaller than crypt_word_t size (which is the\n\t    // same as saying the buffer isn't an integral number of crypt_word_t\n\t    // units.) This is okay in this particular case _because_ this whole\n\t    // block of swapping code is to maintain compatibilty with existing\n\t    // KNOWN ANSWER TESTS, and said existing tests use sizes that this\n\t    // assumption is true for.  Any new code with a different size where\n\t    // this last partial value isn't swapped will be creating a new KAT, and\n\t    // thus any (cryptographically valid) value is still random; swapping\n\t    // doesn't make a cryptographic random buffer more or less random, so\n\t    // the failure to swap is fine.\n#if BIG_ENDIAN_TPM\n\t    crypt_uword_t* pTemp = (crypt_uword_t*)pBuffer;\n\t    for(size_t t = 0; t < (byteCount / sizeof(crypt_uword_t)); t++)\n\t\t*pTemp = SWAP_CRYPT_WORD(*pTemp);\n#endif\n\t    // if the number of bits % 8 != 0, mask the high order (first) byte to the relevant number of bits\n\t    // bits % 8     desired mask   right-shift of 0xFF\n\t    //     0           0xFF             0 = (8 - 0) % 8\n\t    //     1           0x01             7 = (8 - 1) % 8\n\t    //     2           0x03             6 = (8 - 2) % 8\n\t    //     ... etc ...\n\t    //     7           0x7F             1 = (8 - 7) % 8\n\t    int  excessBits = bits % 8;\n\t    int  shift      = (8 - excessBits) % 8;\n\t    BYTE mask       = ~(0xFF >> shift);\n\t    pBuffer[0]      = pBuffer[0] & mask;\n\t    return TRUE;\n\t}\n    return FALSE;\n}\n\n//*** TpmMath_GetRandomInteger()\n// This function gets random bits for use in various places. To make sure that the\n// number is generated in a portable format, it is created as a TPM2B and then\n// converted to the internal format.\n//\n// One consequence of the generation scheme is that, if the number of bits requested\n// is not a multiple of 8, then the high-order bits are set to zero. This would come\n// into play when generating a 521-bit ECC key. A 66-byte (528-bit) value is\n// generated an the high order 7 bits are masked off (CLEAR).\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure\nLIB_EXPORT BOOL TpmMath_GetRandomInteger(Crypt_Int* n, size_t bits, RAND_STATE* rand)\n{\n    // Since this could be used for ECC key generation using the extra bits method,\n    // make sure that the value is large enough\n    TPM2B_TYPE(LARGEST, LARGEST_NUMBER + 8);\n    TPM2B_LARGEST large;\n    //\n    large.b.size = (UINT16)BITS_TO_BYTES(bits);\n    if(DRBG_Generate(rand, large.t.buffer, large.t.size) == large.t.size)\n\t{\n\t    if(TpmMath_IntFrom2B(n, &large.b) != NULL)\n\t\t{\n\t\t    if(ExtMath_MaskBits(n, (crypt_uword_t)bits))\n\t\t\treturn TRUE;\n\t\t}\n\t}\n    return FALSE;\n}\n\n//*** BnGenerateRandomInRange()\n// This function is used to generate a random number r in the range 1 <= r < limit.\n// The function gets a random number of bits that is the size of limit. There is some\n// some probability that the returned number is going to be greater than or equal\n// to the limit. If it is, try again. There is no more than 50% chance that the\n// next number is also greater, so try again. We keep trying until we get a\n// value that meets the criteria. Since limit is very often a number with a LOT of\n// high order ones, this rarely would need a second try.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure ('limit' is too small)\nLIB_EXPORT BOOL TpmMath_GetRandomInRange(\n\t\t\t\t\t Crypt_Int* dest, const Crypt_Int* limit, RAND_STATE* rand)\n{\n    size_t bits = ExtMath_SizeInBits(limit);\n    //\n    if(bits < 2)\n\t{\n\t    ExtMath_SetWord(dest, 0);\n\t    return FALSE;\n\t}\n    else\n\t{\n\t    while(TpmMath_GetRandomInteger(dest, bits, rand)\n\t\t  && (ExtMath_IsZero(dest) || (ExtMath_UnsignedCmp(dest, limit) >= 0)))\n\t\t;\n\t}\n    return !g_inFailureMode;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmSizeChecks.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM Size Checks\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: TpmSizeChecks.c 1628 2020-05-27 19:35:29Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2020\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes, Defines, and Types\n#include    \"Tpm.h\"\n#include    \"PlatformACT_fp.h\"\t\t/* kgold */\n#include    \"TpmSizeChecks_fp.h\"\n#include    <stdio.h>\n#include    <assert.h>\n\n#if RUNTIME_SIZE_CHECKS\n\n#if TABLE_DRIVEN_MARSHAL\nextern uint32_t    MarshalDataSize;\n#endif\n\n#if DEBUG\nstatic      int once = 0;\n#endif\n\n//** TpmSizeChecks()\n// This function is used during the development process to make sure that the\n// vendor-specific values result in a consistent implementation. When possible,\n// the code contains #if to do compile-time checks. However, in some cases, the\n// values require the use of \"sizeof()\" and that can't be used in an #if.\nBOOL\nTpmSizeChecks(\n\t      void\n\t      )\n{\n    BOOL        PASS = TRUE;\n#if DEBUG\n    //\n    if(once++ != 0)\n        return 1;\n    {\n        UINT32      maxAsymSecurityStrength = MAX_ASYM_SECURITY_STRENGTH;\n        UINT32      maxHashSecurityStrength = MAX_HASH_SECURITY_STRENGTH;\n        UINT32      maxSymSecurityStrength = MAX_SYM_SECURITY_STRENGTH;\n        UINT32      maxSecurityStrengthBits = MAX_SECURITY_STRENGTH_BITS;\n        UINT32      proofSize = PROOF_SIZE;\n        UINT32      compliantProofSize = COMPLIANT_PROOF_SIZE;\n        UINT32      compliantPrimarySeedSize = COMPLIANT_PRIMARY_SEED_SIZE;\n        UINT32      primarySeedSize = PRIMARY_SEED_SIZE;\n\n        UINT32      cmacState = sizeof(tpmCmacState_t);\n        UINT32      hashState = sizeof(HASH_STATE);\n        UINT32      keyScheduleSize = sizeof(tpmCryptKeySchedule_t);\n\t//\n        NOT_REFERENCED(cmacState);\n        NOT_REFERENCED(hashState);\n        NOT_REFERENCED(keyScheduleSize);\n        NOT_REFERENCED(maxAsymSecurityStrength);\n        NOT_REFERENCED(maxHashSecurityStrength);\n        NOT_REFERENCED(maxSymSecurityStrength);\n        NOT_REFERENCED(maxSecurityStrengthBits);\n        NOT_REFERENCED(proofSize);\n        NOT_REFERENCED(compliantProofSize);\n        NOT_REFERENCED(compliantPrimarySeedSize);\n        NOT_REFERENCED(primarySeedSize);\n\n\n        {\n            TPMT_SENSITIVE           *p;\n            // This assignment keeps compiler from complaining about a conditional\n            // comparison being between two constants\n            UINT16                    max_rsa_key_bytes = MAX_RSA_KEY_BYTES;\n            if((max_rsa_key_bytes / 2) != (sizeof(p->sensitive.rsa.t.buffer) / 5))\n\t\t{\n\t\t    printf(\"Sensitive part of TPMT_SENSITIVE is undersized. May be caused\"\n\t\t\t   \" by use of wrong version of Part 2.\\n\");\n\t\t    PASS = FALSE;\n\t\t}\n        }\n#if TABLE_DRIVEN_MARSHAL\n        printf(\"sizeof(MarshalData) = %zu\\n\", sizeof(MarshalData_st));\n#endif\n\n        printf(\"Size of OBJECT = %zu\\n\", sizeof(OBJECT));\n        printf(\"Size of components in TPMT_SENSITIVE = %zu\\n\", sizeof(TPMT_SENSITIVE));\n        printf(\"    TPMI_ALG_PUBLIC                 %zu\\n\", sizeof(TPMI_ALG_PUBLIC));\n        printf(\"    TPM2B_AUTH                      %zu\\n\", sizeof(TPM2B_AUTH));\n        printf(\"    TPM2B_DIGEST                    %zu\\n\", sizeof(TPM2B_DIGEST));\n        printf(\"    TPMU_SENSITIVE_COMPOSITE        %zu\\n\",\n               sizeof(TPMU_SENSITIVE_COMPOSITE));\n    }\n    // Make sure that the size of the context blob is large enough for the largest\n    // context\n    // TPMS_CONTEXT_DATA contains two TPM2B values. That is not how this is\n    // implemented. Rather, the size field of the TPM2B_CONTEXT_DATA is used to\n    // determine the amount of data in the encrypted data. That part is not\n    // independently sized. This makes the actual size 2 bytes smaller than\n    // calculated using Part 2. Since this is opaque to the caller, it is not\n    // necessary to fix. The actual size is returned by TPM2_GetCapabilties().\n\n    // Initialize output handle.  At the end of command action, the output\n    // handle of an object will be replaced, while the output handle\n    // for a session will be the same as input\n\n    // Get the size of fingerprint in context blob.  The sequence value in\n    // TPMS_CONTEXT structure is used as the fingerprint\n    {\n        UINT32  fingerprintSize = sizeof(UINT64);\n        UINT32  integritySize = sizeof(UINT16)\n\t\t\t\t+ CryptHashGetDigestSize(CONTEXT_INTEGRITY_HASH_ALG);\n        UINT32  biggestObject = MAX(MAX(sizeof(HASH_OBJECT), sizeof(OBJECT)),\n                                    sizeof(SESSION));\n        UINT32  biggestContext = fingerprintSize + integritySize + biggestObject;\n\n        // round required size up to nearest 8 byte boundary.\n        biggestContext = 8 * ((biggestContext + 7) / 8);\n\n        if(MAX_CONTEXT_SIZE < biggestContext)\n\t    {\n\t\tprintf(\"MAX_CONTEXT_SIZE needs to be increased to at least to %d (%d)\\n\",\n\t\t       biggestContext, MAX_CONTEXT_SIZE);\n\t\tPASS = FALSE;\n\t    }\n\telse if (MAX_CONTEXT_SIZE > biggestContext)\n\t    {\n\t\tprintf(\"MAX_CONTEXT_SIZE can be reduced to %d (%d)\\n\",\n\t\t       biggestContext, MAX_CONTEXT_SIZE);\n\t    }\n    }\n    {\n        union u\n        {\n            TPMA_OBJECT             attributes;\n            UINT32                  uint32Value;\n        } u;\n        // these are defined so that compiler doesn't complain about conditional\n        // expressions comparing two constants.\n        int                         aSize = sizeof(u.attributes);\n        int                         uSize = sizeof(u.uint32Value);\n        u.uint32Value = 0;\n        SET_ATTRIBUTE(u.attributes, TPMA_OBJECT, fixedTPM);\n        if(u.uint32Value != 2)\n\t    {\n\t\tprintf(\"The bit allocation in a TPMA_OBJECT is not as expected\");\n\t\tPASS = FALSE;\n\t    }\n        if(aSize != uSize)  // comparison of two sizeof() values annoys compiler\n\t    {\n\t\tprintf(\"A TPMA_OBJECT is not the expected size.\");\n\t\tPASS = FALSE;\n\t    }\n    }\n    // Check that the platform implements each of the ACT that the TPM thinks are present\n    {\n        uint32_t            act;\n        for(act = 0; act < 16; act++)\n\t    {\n\t\tswitch(act)\n\t\t    {\n\t\t\tFOR_EACH_ACT(CASE_ACT_NUMBER)\n\t\t\t    if(!_plat__ACT_GetImplemented(act))\n\t\t\t\t{\n\t\t\t\t    printf(\"TPM_RH_ACT_%1X is not implemented by platform\\n\",\n\t\t\t\t\t   act);\n\t\t\t\t    PASS = FALSE;\n\t\t\t\t}\n\t\t      default:\n\t\t\tbreak;\n\t\t    }\n\t    }\n    }\n#endif // DEBUG\n    return (PASS);\n}\n\n#endif // RUNTIME_SIZE_CHECKS\n\n\n"
  },
  {
    "path": "ftpm-opensbi/src/TpmToOsslSupport.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tInitialization of the Interface to the OpenSSL Library.\t   \t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n//\n// The functions in this file are used for initialization of the interface to the\n// OpenSSL library.\n\n//** Defines and Includes\n\n#include \"BnOssl.h\"\n\n#if defined(HASH_LIB_OSSL) || defined(MATH_LIB_OSSL) || defined(SYM_LIB_OSSL)\n// Used to pass the pointers to the correct sub-keys\ntypedef const BYTE* desKeyPointers[3];\n\n//*** BnSupportLibInit()\n// This does any initialization required by the support library.\nLIB_EXPORT int BnSupportLibInit(void)\n{\n    return TRUE;\n}\n\n//*** OsslContextEnter()\n// This function is used to initialize an OpenSSL context at the start of a function\n// that will call to an OpenSSL math function.\nBN_CTX* OsslContextEnter(void)\n{\n    BN_CTX* CTX = BN_CTX_new();\n    //\n    return OsslPushContext(CTX);\n}\n\n//*** OsslContextLeave()\n// This is the companion function to OsslContextEnter().\nvoid OsslContextLeave(BN_CTX* CTX)\n{\n    OsslPopContext(CTX);\n    BN_CTX_free(CTX);\n}\n\n//*** OsslPushContext()\n// This function is used to create a frame in a context. All values allocated within\n// this context after the frame is started will be automatically freed when the\n// context (OsslPopContext()\nBN_CTX* OsslPushContext(BN_CTX* CTX)\n{\n    if(CTX == NULL)\n\tFAIL(FATAL_ERROR_ALLOCATION);\n    BN_CTX_start(CTX);\n    return CTX;\n}\n\n//*** OsslPopContext()\n// This is the companion function to OsslPushContext().\nvoid OsslPopContext(BN_CTX* CTX)\n{\n    // BN_CTX_end can't be called with NULL. It will blow up.\n    if(CTX != NULL)\n\tBN_CTX_end(CTX);\n}\n\n#endif  // HASH_LIB_OSSL || MATH_LIB_OSSL || SYM_LIB_OSSL\n"
  },
  {
    "path": "ftpm-opensbi/src/Unique.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Secret Value to the TPM   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// In some implementations of the TPM, the hardware can provide a secret\n// value to the TPM. This secret value is statistically unique to the\n// instance of the TPM. Typical uses of this value are to provide\n// personalization to the random number generation and as a shared secret\n// between the TPM and the manufacturer.\n\n//** Includes\n#include \"Platform.h\"\n\n#if VENDOR_PERMANENT_AUTH_ENABLED == YES\n\nconst char notReallyUnique[] = \"This is not really a unique value. A real \"\n\t\t\t       \"unique value should\"\n\t\t\t       \" be generated by the platform.\";\n\n//** _plat__GetUnique()\n// This function is used to access the platform-specific vendor unique values.\n// This function places the unique value in the provided buffer ('b')\n// and returns the number of bytes transferred. The function will not\n// copy more data than 'bSize'.\n// NOTE: If a platform unique value has unequal distribution of uniqueness\n// and 'bSize' is smaller than the size of the unique value, the 'bSize'\n// portion with the most uniqueness should be returned.\n//\n// 'which' indicates the unique value to return:\n// 0 = RESERVED, do not use\n// 1 = the VENDOR_PERMANENT_AUTH_HANDLE authorization value for this device\nLIB_EXPORT uint32_t _plat__GetUnique(uint32_t which,  // which vendor value to return?\n\t\t\t\t     uint32_t bSize,  // size of the buffer\n\t\t\t\t     unsigned char* b  // output buffer\n\t\t\t\t     )\n{\n    const char* from   = notReallyUnique;\n    uint32_t    retVal = 0;\n\n    if(which == 1)\n\t{\n\t    const size_t uSize =\n\t\tsizeof(notReallyUnique) <= bSize ? sizeof(notReallyUnique) : bSize;\n\t    MemoryCopy(b, notReallyUnique, uSize);\n\t}\n    // else fall through to default 0\n\n    return retVal;\n}\n\n#endif\n"
  },
  {
    "path": "ftpm-opensbi/src/Unmarshal.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Parameter Unmarshaling\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2024\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* rev 136 */\n\n#include <string.h>\n\n#include \"Unmarshal_fp.h\"\n\nTPM_RC\nUINT8_Unmarshal(UINT8 *target, BYTE **buffer, INT32 *size)\n{\n    if ((UINT32)*size < sizeof(UINT8)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = (*buffer)[0];\n    *buffer += sizeof(UINT8);\n    *size -= sizeof(UINT8);\n    return TPM_RC_SUCCESS;\n}\n\nTPM_RC\nINT8_Unmarshal(INT8 *target, BYTE **buffer, INT32 *size)\n{\n    return UINT8_Unmarshal((UINT8 *)target, buffer, size);\n}\n\nTPM_RC\nUINT16_Unmarshal(UINT16 *target, BYTE **buffer, INT32 *size)\n{\n    if ((UINT32)*size < sizeof(UINT16)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = ((UINT16)((*buffer)[0]) << 8) |\n\t      ((UINT16)((*buffer)[1]) << 0);\n    *buffer += sizeof(UINT16);\n    *size -= sizeof(UINT16);\n    return TPM_RC_SUCCESS;\n}\n\nTPM_RC\nUINT32_Unmarshal(UINT32 *target, BYTE **buffer, INT32 *size)\n{\n    if ((UINT32)*size < sizeof(UINT32)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = ((UINT32)((*buffer)[0]) << 24) |\n\t      ((UINT32)((*buffer)[1]) << 16) |\n\t      ((UINT32)((*buffer)[2]) <<  8) |\n\t      ((UINT32)((*buffer)[3]) <<  0);\n    *buffer += sizeof(UINT32);\n    *size -= sizeof(UINT32);\n    return TPM_RC_SUCCESS;\n}\n\nTPM_RC\nUINT64_Unmarshal(UINT64 *target, BYTE **buffer, INT32 *size)\n{\n    if ((UINT32)*size < sizeof(UINT64)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = ((UINT64)((*buffer)[0]) << 56) |\n\t      ((UINT64)((*buffer)[1]) << 48) |\n\t      ((UINT64)((*buffer)[2]) << 40) |\n\t      ((UINT64)((*buffer)[3]) << 32) |\n\t      ((UINT64)((*buffer)[4]) << 24) |\n\t      ((UINT64)((*buffer)[5]) << 16) |\n\t      ((UINT64)((*buffer)[6]) <<  8) |\n\t      ((UINT64)((*buffer)[7]) <<  0);\n    *buffer += sizeof(UINT64);\n    *size -= sizeof(UINT64);\n    return TPM_RC_SUCCESS;\n}\n\nTPM_RC\nArray_Unmarshal(BYTE *targetBuffer, UINT16 targetSize, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (targetSize > *size) {\n\trc = TPM_RC_INSUFFICIENT;\n    }\n    else {\n\tmemcpy(targetBuffer, *buffer, targetSize);\n\t*buffer += targetSize;\n\t*size -= targetSize;\n    }\n    return rc;\n}\n\nTPM_RC\nTPM2B_Unmarshal(TPM2B *target, UINT16 targetSize, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size > targetSize) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = Array_Unmarshal(target->buffer, target->size, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 5 - Definition of Types for Documentation Clarity */\n\nTPM_RC\nTPM_KEY_BITS_Unmarshal(TPM_KEY_BITS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 7 - Definition of (UINT32) TPM_GENERATED Constants <O> */\n\n#if 0\nTPM_RC\nTPM_GENERATED_Unmarshal(TPM_GENERATED *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (*target != TPM_GENERATED_VALUE) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n#endif\n\n/* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */\n\nTPM_RC\nTPM_ALG_ID_Unmarshal(TPM_ALG_ID *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */\n\n#if ALG_ECC\nTPM_RC\nTPM_ECC_CURVE_Unmarshal(TPM_ECC_CURVE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_ECC_NONE:\n#  if ECC_NIST_P192\n\t  case TPM_ECC_NIST_P192:\n#  endif  // ECC_NIST_P192\n#  if ECC_NIST_P224\n \t  case TPM_ECC_NIST_P224:\n#  endif  // ECC_NIST_P224\n#  if ECC_NIST_P256\n \t  case TPM_ECC_NIST_P256:\n#  endif  // ECC_NIST_P256\n#  if ECC_NIST_P384\n \t  case TPM_ECC_NIST_P384:\n#  endif  // ECC_NIST_P384\n#  if ECC_NIST_P521\n\t  case TPM_ECC_NIST_P521:\n#  endif  // ECC_NIST_P521\n#  if ECC_BN_P256\n\t  case TPM_ECC_BN_P256:\n#  endif  // ECC_BN_P256\n#  if ECC_BN_P638\n \t  case TPM_ECC_BN_P638:\n#  endif  // ECC_BN_P638\n#  if ECC_SM2_P256\n\t  case TPM_ECC_SM2_P256:\n#  endif  // ECC_SM2_P256\n#  if ECC_BP_P256_R1\n\t  case TPM_ECC_BP_P256_R1:\n#  endif  // ECC_BP_P256_R1\n#  if ECC_BP_P384_R1\n\t  case TPM_ECC_BP_P384_R1:\n#  endif  // ECC_BP_P384_R1\n#  if ECC_BP_P512_R1\n\t  case TPM_ECC_BP_P512_R1:\n#  endif  // ECC_BP_P512_R1\n#  if ECC_CURVE_25519\n\t  case TPM_ECC_CURVE_25519:\n#  endif  // ECC_CURVE_25519\n#  if ECC_CURVE_448\n\t  case TPM_ECC_CURVE_448:\n#  endif  // ECC_CURVE_448\n\t    break;\n\t  default:\n\t    rc = TPM_RC_CURVE;\n\t}\n    }\n    return rc;\n}\n#endif\n\n/* Table 13 - Definition of (UINT32) TPM_CC Constants (Numeric Order) <IN/OUT, S> */\n\nTPM_RC\nTPM_CC_Unmarshal(TPM_RC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 18 - Definition of (INT8) TPM_CLOCK_ADJUST Constants <IN> */\n\nTPM_RC\nTPM_CLOCK_ADJUST_Unmarshal(TPM_CLOCK_ADJUST *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = INT8_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_CLOCK_COARSE_SLOWER:\n\t  case TPM_CLOCK_MEDIUM_SLOWER:\n\t  case TPM_CLOCK_FINE_SLOWER:\n\t  case TPM_CLOCK_NO_CHANGE:\n\t  case TPM_CLOCK_FINE_FASTER:\n\t  case TPM_CLOCK_MEDIUM_FASTER:\n\t  case TPM_CLOCK_COARSE_FASTER:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 19 - Definition of (UINT16) TPM_EO Constants <IN/OUT> */\n\nTPM_RC\nTPM_EO_Unmarshal(TPM_EO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_EO_EQ:\n\t  case TPM_EO_NEQ:\n\t  case TPM_EO_SIGNED_GT:\n\t  case TPM_EO_UNSIGNED_GT:\n\t  case TPM_EO_SIGNED_LT:\n\t  case TPM_EO_UNSIGNED_LT:\n\t  case TPM_EO_SIGNED_GE:\n\t  case TPM_EO_UNSIGNED_GE:\n\t  case TPM_EO_SIGNED_LE:\n\t  case TPM_EO_UNSIGNED_LE:\n\t  case TPM_EO_BITSET:\n\t  case TPM_EO_BITCLEAR:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 20 - Definition of (UINT16) TPM_ST Constants <IN/OUT, S> */\n\nTPM_RC\nTPM_ST_Unmarshal(TPM_ST *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_ST_RSP_COMMAND:\n\t  case TPM_ST_NULL:\n\t  case TPM_ST_NO_SESSIONS:\n\t  case TPM_ST_SESSIONS:\n\t  case TPM_ST_ATTEST_NV:\n\t  case TPM_ST_ATTEST_COMMAND_AUDIT:\n\t  case TPM_ST_ATTEST_SESSION_AUDIT:\n\t  case TPM_ST_ATTEST_CERTIFY:\n\t  case TPM_ST_ATTEST_QUOTE:\n\t  case TPM_ST_ATTEST_TIME:\n\t  case TPM_ST_ATTEST_CREATION:\n\t  case TPM_ST_CREATION:\n\t  case TPM_ST_VERIFIED:\n\t  case TPM_ST_AUTH_SECRET:\n\t  case TPM_ST_HASHCHECK:\n\t  case TPM_ST_AUTH_SIGNED:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 20 - Definition of (UINT16) TPM_SU Constants <IN> */\n\nTPM_RC\nTPM_SU_Unmarshal(TPM_SU *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_SU_CLEAR:\n\t  case TPM_SU_STATE:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 21 - Definition of (UINT8) TPM_SE Constants <IN> */\n\nTPM_RC\nTPM_SE_Unmarshal(TPM_SE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT8_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_SE_HMAC:\n\t  case TPM_SE_POLICY:\n\t  case TPM_SE_TRIAL:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 22 - Definition of (UINT32) TPM_CAP Constants  */\n\nTPM_RC\nTPM_CAP_Unmarshal(TPM_CAP *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_CAP_ALGS:\n\t  case TPM_CAP_HANDLES:\n\t  case TPM_CAP_COMMANDS:\n\t  case TPM_CAP_PP_COMMANDS:\n\t  case TPM_CAP_AUDIT_COMMANDS:\n\t  case TPM_CAP_PCRS:\n\t  case TPM_CAP_TPM_PROPERTIES:\n\t  case TPM_CAP_PCR_PROPERTIES:\n\t  case TPM_CAP_ECC_CURVES:\n\t  case TPM_CAP_AUTH_POLICIES:\n\t  case TPM_CAP_ACT:\n\t  case TPM_CAP_VENDOR_PROPERTY:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 24 - Definition of (UINT32) TPM_PT Constants <IN/OUT, S> */\n\nTPM_RC\nTPM_PT_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 25 - Definition of (UINT32) TPM_PT_PCR Constants <IN/OUT, S> */\n\nTPM_RC\nTPM_PT_PCR_Unmarshal(TPM_PT_PCR *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 27 - Definition of Types for Handles */\n\nTPM_RC\nTPM_HANDLE_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 31 - Definition of (UINT32) TPMA_ALGORITHM Bits */\n\nTPM_RC\nTPMA_ALGORITHM_Unmarshal(TPMA_ALGORITHM *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (*target & TPMA_ALGORITHM_reserved) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 32 - Definition of (UINT32) TPMA_OBJECT Bits */\n\nTPM_RC\nTPMA_OBJECT_Unmarshal(TPMA_OBJECT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (*target & TPMA_OBJECT_reserved) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 33 - Definition of (UINT8) TPMA_SESSION Bits <IN/OUT> */\n\nTPM_RC\nTPMA_SESSION_Unmarshal(TPMA_SESSION *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT8_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (*target & TPMA_SESSION_reserved) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 34 - Definition of (UINT8) TPMA_LOCALITY Bits <IN/OUT> */\n\nTPM_RC\nTPMA_LOCALITY_Unmarshal(TPMA_LOCALITY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT8_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 38 - Definition of (TPM_CC) TPMA_CC Bits <OUT> */\n\nTPM_RC\nTPMA_CC_Unmarshal(TPMA_CC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (*target & TPMA_CC_reserved) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 39 - Definition of (BYTE) TPMI_YES_NO Type */\n\nTPM_RC\nTPMI_YES_NO_Unmarshal(TPMI_YES_NO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT8_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case NO:\n\t  case YES:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 40 - Definition of (TPM_HANDLE) TPMI_DH_OBJECT Type */\n\nTPM_RC\nTPMI_DH_OBJECT_Unmarshal(TPMI_DH_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST);\n\tBOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST);\n\tBOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull;\n\tif (isNotTransient &&\n\t    isNotPersistent &&\n\t    isNotLegalNull) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 2:41 - Definition of TPMI_DH_PARENT Type (InterfaceTable()) */\n\nTPM_RC\nTPMI_DH_PARENT_Unmarshal(TPMI_DH_PARENT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST);\n\tBOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST);\n\tBOOL isNotOwner = *target != TPM_RH_OWNER;\n\tBOOL isNotPlatform = *target != TPM_RH_PLATFORM;\n\tBOOL isNotEndorsement = *target != TPM_RH_ENDORSEMENT;\n\tBOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull;\n\tif (isNotTransient &&\n\t    isNotPersistent &&\n\t    isNotOwner &&\n\t    isNotPlatform &&\n\t    isNotEndorsement &&\n\t    isNotLegalNull) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 41 - Definition of (TPM_HANDLE) TPMI_DH_PERSISTENT Type */\n\nTPM_RC\nTPMI_DH_PERSISTENT_Unmarshal(TPMI_DH_PERSISTENT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST);\n\tif (isNotPersistent) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 42 - Definition of (TPM_HANDLE) TPMI_DH_ENTITY Type <IN> */\n\nTPM_RC\nTPMI_DH_ENTITY_Unmarshal(TPMI_DH_ENTITY *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotOwner = *target != TPM_RH_OWNER;\n\tBOOL isNotEndorsement = *target != TPM_RH_ENDORSEMENT;\n\tBOOL isNotPlatform = *target != TPM_RH_PLATFORM;\n\tBOOL isNotLockout = *target != TPM_RH_LOCKOUT;\n\tBOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST);\n\tBOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST);\n\tBOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);\n\tBOOL isNotPcr = (*target > PCR_LAST);\n\tBOOL isNotAuth = (*target < TPM_RH_AUTH_00) || (*target > TPM_RH_AUTH_FF);\n\tBOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull;\n\tif (isNotOwner &&\n\t    isNotEndorsement &&\n\t    isNotPlatform &&\n\t    isNotLockout &&\n\t    isNotTransient &&\n\t    isNotPersistent &&\n\t    isNotNv &&\n\t    isNotPcr &&\n\t    isNotAuth &&\n\t    isNotLegalNull) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 43 - Definition of (TPM_HANDLE) TPMI_DH_PCR Type <IN> */\n\nTPM_RC\nTPMI_DH_PCR_Unmarshal(TPMI_DH_PCR *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotPcr = (*target > PCR_LAST);\n\tBOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull;\n\tif (isNotPcr &&\n\t    isNotLegalNull) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 44 - Definition of (TPM_HANDLE) TPMI_SH_AUTH_SESSION Type <IN/OUT> */\n\nTPM_RC\nTPMI_SH_AUTH_SESSION_Unmarshal(TPMI_SH_AUTH_SESSION *target, BYTE **buffer, INT32 *size, BOOL allowPwd)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST);\n\tBOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST);\n\tBOOL isNotLegalPwd = (*target != TPM_RS_PW) || !allowPwd;\n\tif (isNotHmacSession &&\n\t    isNotPolicySession &&\n\t    isNotLegalPwd) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 45 - Definition of (TPM_HANDLE) TPMI_SH_HMAC Type <IN/OUT> */\n\nTPM_RC\nTPMI_SH_HMAC_Unmarshal(TPMI_SH_HMAC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST);\n\tif (isNotHmacSession) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 46 - Definition of (TPM_HANDLE) TPMI_SH_POLICY Type <IN/OUT> */\n\nTPM_RC\nTPMI_SH_POLICY_Unmarshal(TPMI_SH_POLICY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST);\n\tif (isNotPolicySession) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 47 - Definition of (TPM_HANDLE) TPMI_DH_CONTEXT Type  */\n\nTPM_RC\nTPMI_DH_CONTEXT_Unmarshal(TPMI_DH_CONTEXT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST);\n\tBOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST);\n\tBOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST);\n\tif (isNotHmacSession &&\n\t    isNotPolicySession &&\n\t    isNotTransient) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 49 - Definition of (TPM_HANDLE) TPMI_DH_SAVED Type */\n\nTPM_RC\nTPMI_DH_SAVED_Unmarshal(TPMI_DH_SAVED *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST);\n\tBOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST);\n\tBOOL isNotTransientObject = (*target != 0x80000000);\n\tBOOL isNotSequenceObject = (*target != 0x80000001);\n\tBOOL isNotTransientStClear = (*target != 0x80000002);\n\tif (isNotHmacSession &&\n\t    isNotPolicySession &&\n\t    isNotTransientObject &&\n\t    isNotSequenceObject &&\n\t    isNotTransientStClear) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 48 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY Type  */\n\nTPM_RC\nTPMI_RH_HIERARCHY_Unmarshal(TPMI_RH_HIERARCHY *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t  case TPM_RH_ENDORSEMENT:\n\t    break;\n\t  case TPM_RH_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 49 - Definition of (TPM_HANDLE) TPMI_RH_ENABLES Type */\n\nTPM_RC\nTPMI_RH_ENABLES_Unmarshal(TPMI_RH_ENABLES *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t  case TPM_RH_ENDORSEMENT:\n\t  case TPM_RH_PLATFORM_NV:\n\t    break;\n\t  case TPM_RH_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 50 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY_AUTH Type <IN> */\n\nTPM_RC\nTPMI_RH_HIERARCHY_AUTH_Unmarshal(TPMI_RH_HIERARCHY_AUTH *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t  case TPM_RH_ENDORSEMENT:\n\t  case TPM_RH_LOCKOUT:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 50 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY_POLICY Type <IN> */\n\nTPM_RC\nTPMI_RH_HIERARCHY_POLICY_Unmarshal(TPMI_RH_HIERARCHY_POLICY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t  case TPM_RH_ENDORSEMENT:\n\t  case TPM_RH_LOCKOUT:\n\t    break;\n\t  default:\n\t      {\n\t\t  BOOL isNotHP =  (*target < TPM_RH_ACT_0) || (*target > TPM_RH_ACT_F);\n\t\t  if (isNotHP) {\n\t\t      rc = TPM_RC_VALUE;\n\t\t  }\n\t      }\n\t}\n    }\n    return rc;\n}\n\n/* Table 51 - Definition of (TPM_HANDLE) TPMI_RH_PLATFORM Type <IN> */\n\nTPM_RC\nTPMI_RH_PLATFORM_Unmarshal(TPMI_RH_PLATFORM *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_PLATFORM:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 53 - Definition of (TPM_HANDLE) TPMI_RH_ENDORSEMENT Type <IN> */\n\nTPM_RC\nTPMI_RH_ENDORSEMENT_Unmarshal(TPMI_RH_ENDORSEMENT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_ENDORSEMENT:\n\t    break;\n\t  case TPM_RH_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 54 - Definition of (TPM_HANDLE) TPMI_RH_PROVISION Type <IN> */\n\nTPM_RC\nTPMI_RH_PROVISION_Unmarshal(TPMI_RH_PROVISION *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 55 - Definition of (TPM_HANDLE) TPMI_RH_CLEAR Type <IN> */\n\nTPM_RC\nTPMI_RH_CLEAR_Unmarshal(TPMI_RH_CLEAR *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_LOCKOUT:\n\t  case TPM_RH_PLATFORM:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 56 - Definition of (TPM_HANDLE) TPMI_RH_NV_AUTH Type <IN> */\n\nTPM_RC\nTPMI_RH_NV_AUTH_Unmarshal(TPMI_RH_NV_AUTH *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t    break;\n\t  default:\n\t      {\n\t\t  BOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);\n\t\t  if (isNotNv) {\n\t\t      rc = TPM_RC_VALUE;\n\t\t  }\n\t      }\n\t}\n    }\n    return rc;\n}\n\n/* Table 65 - Definition of (TPM_HANDLE) TPMI_RH_LOCKOUT Type <IN> */\n\nTPM_RC\nTPMI_RH_LOCKOUT_Unmarshal(TPMI_RH_LOCKOUT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_LOCKOUT:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 66 - Definition of (TPM_HANDLE) TPMI_RH_NV_INDEX Type <IN/OUT> */\n\nTPM_RC\nTPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);\n\tBOOL isNotExternalNV = (*target < EXTERNAL_NV_FIRST) || (*target > EXTERNAL_NV_LAST);\n\tBOOL isNotPermamentNV = (*target < PERMANENT_NV_FIRST) || (*target > PERMANENT_NV_LAST);\n\n\tif (isNotNv &&\n\t    isNotExternalNV &&\n\t    isNotPermamentNV) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 67 - Definition of (TPM_HANDLE) TPMI_RH_NV_DEFINED_INDEX Type <IN> */\n\nTPM_RC\nTPMI_RH_NV_DEFINED_INDEX_Unmarshal(TPMI_RH_NV_DEFINED_INDEX *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);\n\tBOOL isNotExternalNV = (*target < EXTERNAL_NV_FIRST) || (*target > EXTERNAL_NV_LAST);\n\n\tif (isNotNv &&\n\t    isNotExternalNV) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 68 - Definition of (TPM_HANDLE) TPMI_RH_NV_LEGACY_INDEX Type <IN/OUT> */\nTPM_RC\nTPMI_RH_NV_LEGACY_INDEX_Unmarshal(TPMI_RH_NV_LEGACY_INDEX *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);\n\n\tif (isNotNv) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 69 - Definition of (TPM_HANDLE) TPMI_RH_NV_EXP_INDEX Type <IN/OUT> */\n\nTPM_RC\nTPMI_RH_NV_EXP_INDEX_Unmarshal(TPMI_RH_NV_EXP_INDEX *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotExternalNV = (*target < EXTERNAL_NV_FIRST) || (*target > EXTERNAL_NV_LAST);\n\n\tif (isNotExternalNV) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 64 - Definition of (TPM_HANDLE) TPMI_RH_AC Type <IN> */\n\nTPM_RC\nTPMI_RH_AC_Unmarshal(TPMI_RH_AC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotAC = (*target < AC_FIRST) || (*target > AC_LAST);\n\tif (isNotAC) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 65 - Definition of (TPM_HANDLE) TPMI_RH_ACT Type <IN> */\n\nTPM_RC\nTPMI_RH_ACT_Unmarshal( TPMI_RH_ACT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotACT = (*target < TPM_RH_ACT_0) || (*target > TPM_RH_ACT_F);\n\tif (isNotACT) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type  */\n\nTPM_RC\nTPMI_ALG_HASH_Unmarshal(TPMI_ALG_HASH *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_SHA1\n\t  case TPM_ALG_SHA1:\n#endif\n#if ALG_SHA256\n\t  case TPM_ALG_SHA256:\n#endif\n#if ALG_SHA384\n\t  case \tTPM_ALG_SHA384:\n#endif\n#if ALG_SHA512\n\t  case \tTPM_ALG_SHA512:\n#endif\n#if ALG_SM3_256\n\t  case TPM_ALG_SM3_256:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_HASH;\n\t}\n    }\n    return rc;\n}\n\n/* Table 61 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM Type */\n\nTPM_RC\nTPMI_ALG_SYM_Unmarshal(TPMI_ALG_SYM *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_AES\n\t  case TPM_ALG_AES:\n#endif\n#if ALG_SM4\n\t  case TPM_ALG_SM4:\n#endif\n#if ALG_CAMELLIA\n\t  case TPM_ALG_CAMELLIA:\n#endif\n#if ALG_XOR\n\t  case TPM_ALG_XOR:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_SYMMETRIC;\n\t}\n    }\n    return rc;\n}\n\n/* Table 62 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_OBJECT Type */\n\nTPM_RC\nTPMI_ALG_SYM_OBJECT_Unmarshal(TPMI_ALG_SYM_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_AES\n\t  case TPM_ALG_AES:\n#endif\n#if ALG_SM4\n\t  case TPM_ALG_SM4:\n#endif\n#if ALG_CAMELLIA\n\t  case TPM_ALG_CAMELLIA:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_SYMMETRIC;\n\t}\n    }\n    return rc;\n}\n\n/* Table 63 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_MODE Type */\n\nTPM_RC\nTPMI_ALG_SYM_MODE_Unmarshal(TPMI_ALG_SYM_MODE *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_CTR\n\t  case TPM_ALG_CTR:\n#endif\n#if ALG_OFB\n\t  case TPM_ALG_OFB:\n#endif\n#if ALG_CBC\n\t  case TPM_ALG_CBC:\n#endif\n#if ALG_CFB\n\t  case TPM_ALG_CFB:\n#endif\n#if ALG_ECB\n\t  case TPM_ALG_ECB:\n#endif\n#if ALG_CMAC\n\t  case TPM_ALG_CMAC:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_MODE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 64 - Definition of (TPM_ALG_ID) TPMI_ALG_KDF Type */\n\nTPM_RC\nTPMI_ALG_KDF_Unmarshal(TPMI_ALG_KDF *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_MGF1\n\t  case TPM_ALG_MGF1:\n#endif\n#if ALG_KDF1_SP800_56A\n\t  case TPM_ALG_KDF1_SP800_56A:\n#endif\n#if ALG_KDF2\n\t  case TPM_ALG_KDF2:\n#endif\n#if ALG_KDF1_SP800_108\n\t  case TPM_ALG_KDF1_SP800_108:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_KDF;\n\t}\n    }\n    return rc;\n}\n\n/* Table 65 - Definition of (TPM_ALG_ID) TPMI_ALG_SIG_SCHEME Type */\n\nTPM_RC\nTPMI_ALG_SIG_SCHEME_Unmarshal(TPMI_ALG_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_HMAC\n\t  case TPM_ALG_HMAC:\n#endif\n#if ALG_RSASSA\n\t  case TPM_ALG_RSASSA:\n#endif\n#if ALG_RSAPSS\n\t  case TPM_ALG_RSAPSS:\n#endif\n#if ALG_ECDSA\n\t  case TPM_ALG_ECDSA:\n#endif\n#if ALG_ECDAA\n\t  case TPM_ALG_ECDAA:\n#endif\n#if ALG_SM2\n\t  case TPM_ALG_SM2:\n#endif\n#if ALG_ECSCHNORR\n\t  case TPM_ALG_ECSCHNORR:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_SCHEME;\n\t}\n    }\n    return rc;\n}\n\n/* Table 66 - Definition of (TPM_ALG_ID) TPMI_ECC_KEY_EXCHANGE Type */\n\nTPM_RC\nTPMI_ECC_KEY_EXCHANGE_Unmarshal(TPMI_ECC_KEY_EXCHANGE *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_ECDH\n\t  case TPM_ALG_ECDH:\n#endif\n#if ALG_ECMQV\n\t  case TPM_ALG_ECMQV:\n#endif\n#if ALG_SM2\n\t  case TPM_ALG_SM2:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_SCHEME;\n\t}\n    }\n    return rc;\n}\n\n\n/* Table 67 - Definition of (TPM_ST) TPMI_ST_COMMAND_TAG Type */\n\nTPM_RC\nTPMI_ST_COMMAND_TAG_Unmarshal(TPMI_ST_COMMAND_TAG *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ST_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_ST_NO_SESSIONS:\n\t  case TPM_ST_SESSIONS:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_BAD_TAG;\n\t}\n    }\n    return rc;\n}\n\n/* Table 70 TPMI_ALG_MAC_SCHEME */\n\nTPM_RC\nTPMI_ALG_MAC_SCHEME_Unmarshal(TPMI_ALG_MAC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_SHA1\n\t  case TPM_ALG_SHA1:\n#endif\n#if ALG_SHA256\n\t  case TPM_ALG_SHA256:\n#endif\n#if ALG_SHA384\n\t  case \tTPM_ALG_SHA384:\n#endif\n#if ALG_SHA512\n\t  case \tTPM_ALG_SHA512:\n#endif\n#if ALG_SM3_256\n\t  case TPM_ALG_SM3_256:\n#endif\n#if ALG_CMAC\n\t  case TPM_ALG_CMAC:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_SYMMETRIC;\n\t}\n    }\n    return rc;\n}\n\n/* Table 70 TPMI_ALG_CIPHER_MODE */\n\nTPM_RC\nTPMI_ALG_CIPHER_MODE_Unmarshal(TPMI_ALG_CIPHER_MODE*target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_CTR\n\t  case TPM_ALG_CTR:\n#endif\n#if ALG_OFB\n\t  case TPM_ALG_OFB:\n#endif\n#if ALG_CBC\n\t  case TPM_ALG_CBC:\n#endif\n#if ALG_CFB\n\t  case TPM_ALG_CFB:\n#endif\n#if ALG_ECB\n\t  case TPM_ALG_ECB:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_MODE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 68 - Definition of TPMS_EMPTY Structure <IN/OUT> */\n\nTPM_RC\nTPMS_EMPTY_Unmarshal(TPMS_EMPTY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    target = target;\n    buffer = buffer;\n    size = size;\n    return rc;\n}\n\n/* Table 70 - Definition of TPMU_HA Union <IN/OUT, S> */\n\nTPM_RC\nTPMU_HA_Unmarshal(TPMU_HA *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_SHA1\n      case TPM_ALG_SHA1:\n\trc = Array_Unmarshal(target->sha1, SHA1_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#if ALG_SHA256\n      case TPM_ALG_SHA256:\n\trc = Array_Unmarshal(target->sha256, SHA256_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#if ALG_SHA384\n      case TPM_ALG_SHA384:\n\trc = Array_Unmarshal(target->sha384, SHA384_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#if ALG_SHA512\n      case TPM_ALG_SHA512:\n\trc = Array_Unmarshal(target->sha512, SHA512_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM3_256\n      case TPM_ALG_SM3_256:\n\trc = Array_Unmarshal(target->sm3_256, SM3_256_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 71 - Definition of TPMT_HA Structure <IN/OUT> */\n\nTPM_RC\nTPMT_HA_Unmarshal(TPMT_HA *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->hashAlg, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_HA_Unmarshal(&target->digest, buffer, size, target->hashAlg);\n    }\n    return rc;\n}\n\n/* Table 72 - Definition of TPM2B_DIGEST Structure */\n\nTPM_RC\nTPM2B_DIGEST_Unmarshal(TPM2B_DIGEST *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(TPMU_HA), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 73 - Definition of TPM2B_DATA Structure */\n\nTPM_RC\nTPM2B_DATA_Unmarshal(TPM2B_DATA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(TPMT_HA), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 74 - Definition of Types for TPM2B_NONCE */\n\nTPM_RC\nTPM2B_NONCE_Unmarshal(TPM2B_NONCE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 75 - Definition of Types for TPM2B_AUTH */\n\nTPM_RC\nTPM2B_AUTH_Unmarshal(TPM2B_AUTH *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 77 - Definition of TPM2B_EVENT Structure */\n\nTPM_RC\nTPM2B_EVENT_Unmarshal(TPM2B_EVENT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(TPM2B_EVENT) - sizeof(UINT16), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 78 - Definition of TPM2B_MAX_BUFFER Structure */\n\nTPM_RC\nTPM2B_MAX_BUFFER_Unmarshal(TPM2B_MAX_BUFFER *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, MAX_DIGEST_BUFFER, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 79 - Definition of TPM2B_MAX_NV_BUFFER Structure */\n\nTPM_RC\nTPM2B_MAX_NV_BUFFER_Unmarshal(TPM2B_MAX_NV_BUFFER *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, MAX_NV_BUFFER_SIZE, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 80 - Definition of TPM2B_TIMEOUT Structure <IN/OUT> */\n\nTPM_RC\nTPM2B_TIMEOUT_Unmarshal(TPM2B_TIMEOUT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 81 - Definition of TPM2B_IV Structure <IN/OUT> */\n\nTPM_RC\nTPM2B_IV_Unmarshal(TPM2B_IV *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, MAX_SYM_BLOCK_SIZE, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 83 - Definition of TPM2B_NAME Structure */\n\nTPM_RC\nTPM2B_NAME_Unmarshal(TPM2B_NAME *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(TPMU_NAME), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 85 - Definition of TPMS_PCR_SELECTION Structure */\n\nTPM_RC\nTPMS_PCR_SELECTION_Unmarshal(TPMS_PCR_SELECTION *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->hash, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT8_Unmarshal(&target->sizeofSelect, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif ((target->sizeofSelect < PCR_SELECT_MIN) ||\n\t    (target->sizeofSelect > PCR_SELECT_MAX)) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = Array_Unmarshal(target->pcrSelect, target->sizeofSelect, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 88 - Definition of TPMT_TK_CREATION Structure */\n\nTPM_RC\nTPMT_TK_CREATION_Unmarshal(TPMT_TK_CREATION *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ST_Unmarshal(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->tag != TPM_ST_CREATION) {\n\t    rc = TPM_RC_TAG;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_RH_HIERARCHY_Unmarshal(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->digest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 89 - Definition of TPMT_TK_VERIFIED Structure */\n\nTPM_RC\nTPMT_TK_VERIFIED_Unmarshal(TPMT_TK_VERIFIED *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ST_Unmarshal(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->tag != TPM_ST_VERIFIED) {\n\t    rc = TPM_RC_TAG;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_RH_HIERARCHY_Unmarshal(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->digest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 90 - Definition of TPMT_TK_AUTH Structure */\n\nTPM_RC\nTPMT_TK_AUTH_Unmarshal(TPMT_TK_AUTH *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ST_Unmarshal(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif ((target->tag != TPM_ST_AUTH_SIGNED) &&\n\t    (target->tag != TPM_ST_AUTH_SECRET)) {\n\t    rc = TPM_RC_TAG;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_RH_HIERARCHY_Unmarshal(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->digest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 91 - Definition of TPMT_TK_HASHCHECK Structure */\n\nTPM_RC\nTPMT_TK_HASHCHECK_Unmarshal(TPMT_TK_HASHCHECK *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ST_Unmarshal(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->tag != TPM_ST_HASHCHECK) {\n\t    rc = TPM_RC_TAG;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_RH_HIERARCHY_Unmarshal(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->digest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 92 - Definition of TPMS_ALG_PROPERTY Structure <OUT> */\n\nTPM_RC\nTPMS_ALG_PROPERTY_Unmarshal(TPMS_ALG_PROPERTY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(&target->alg, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMA_ALGORITHM_Unmarshal(&target->algProperties, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 93 - Definition of TPMS_TAGGED_PROPERTY Structure <OUT> */\n\nTPM_RC\nTPMS_TAGGED_PROPERTY_Unmarshal(TPMS_TAGGED_PROPERTY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_PT_Unmarshal(&target->property, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->value, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 94 - Definition of TPMS_TAGGED_PCR_SELECT Structure <OUT> */\n\nTPM_RC\nTPMS_TAGGED_PCR_SELECT_Unmarshal(TPMS_TAGGED_PCR_SELECT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_PT_PCR_Unmarshal(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT8_Unmarshal(&target->sizeofSelect, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = Array_Unmarshal(target->pcrSelect, target->sizeofSelect, buffer, size);\n    }\n     return rc;\n}\n\n/* Table 95 - Definition of TPML_CC Structure */\n\nTPM_RC\nTPML_CC_Unmarshal(TPML_CC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_CAP_CC) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPM_CC_Unmarshal(&target->commandCodes[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 2:96 - Definition of TPMS_TAGGED_POLICY Structure (StructuresTable()) */\n\nTPM_RC\nTPMS_TAGGED_POLICY_Unmarshal(TPMS_TAGGED_POLICY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_HANDLE_Unmarshal(&target->handle, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_HA_Unmarshal(&target->policyHash, buffer, size, NO);\n    }\n    return rc;\n}\n\n/* Table 96 - Definition of TPML_CCA Structure <OUT> */\n\nTPM_RC\nTPML_CCA_Unmarshal(TPML_CCA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_CAP_CC) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPMA_CC_Unmarshal(&target->commandAttributes[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 97 - Definition of TPML_ALG Structure */\n\nTPM_RC\nTPML_ALG_Unmarshal(TPML_ALG *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_ALG_LIST_SIZE) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPM_ALG_ID_Unmarshal(&target->algorithms[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 98 - Definition of TPML_HANDLE Structure <OUT> */\n\nTPM_RC\nTPML_HANDLE_Unmarshal(TPML_HANDLE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_CAP_HANDLES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPM_HANDLE_Unmarshal(&target->handle[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 99 - Definition of TPML_DIGEST Structure */\n\n/* PolicyOr has a restriction of at least a count of two.  This function is also used to unmarshal\n   PCR_Read, where a count of one is permitted.\n*/\n\nTPM_RC\nTPML_DIGEST_Unmarshal(TPML_DIGEST *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\t/* TPM side is hard coded to 2 minimum */\n\tif (target->count < 2) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > 8) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->digests[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 100 - Definition of TPML_DIGEST_VALUES Structure */\n\nTPM_RC\nTPML_DIGEST_VALUES_Unmarshal(TPML_DIGEST_VALUES *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > HASH_COUNT) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPMT_HA_Unmarshal(&target->digests[i], buffer, size, NO);\n    }\n    return rc;\n}\n\n/* Table 102 - Definition of TPML_PCR_SELECTION Structure */\n\nTPM_RC\nTPML_PCR_SELECTION_Unmarshal(TPML_PCR_SELECTION *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > HASH_COUNT) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPMS_PCR_SELECTION_Unmarshal(&target->pcrSelections[i], buffer, size);\n    }\n    return rc;\n}\n\n\n#if 0\n\n/* Table 103 - Definition of TPML_ALG_PROPERTY Structure <OUT> */\n\nTPM_RC\nTPML_ALG_PROPERTY_Unmarshal(TPML_ALG_PROPERTY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n   if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_CAP_ALGS) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPMS_ALG_PROPERTY_Unmarshal(&target->algProperties[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 104 - Definition of TPML_TAGGED_TPM_PROPERTY Structure <OUT> */\n\nTPM_RC\nTPML_TAGGED_TPM_PROPERTY_Unmarshal(TPML_TAGGED_TPM_PROPERTY  *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_TPM_PROPERTIES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPMS_TAGGED_PROPERTY_Unmarshal(&target->tpmProperty[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 105 - Definition of TPML_TAGGED_PCR_PROPERTY Structure <OUT> */\n\nTPM_RC\nTPML_TAGGED_PCR_PROPERTY_Unmarshal(TPML_TAGGED_PCR_PROPERTY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_PCR_PROPERTIES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPMS_TAGGED_PCR_SELECT_Unmarshal(&target->pcrProperty[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 106 - Definition of {ECC} TPML_ECC_CURVE Structure <OUT> */\n\n#if 0\nTPM_RC\nTPML_ECC_CURVE_Unmarshal(TPML_ECC_CURVE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_ECC_CURVES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPM_ECC_CURVE_Unmarshal(&target->eccCurves[i], buffer, size);\n    }\n    return rc;\n}\n#endif\n\n/* Table 2:109 - Definition of TPML_TAGGED_POLICY Structure (StructuresTable()) */\n\nTPM_RC\nTPML_TAGGED_POLICY_Unmarshal(TPML_TAGGED_POLICY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    UINT32 i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_TAGGED_POLICIES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TPMS_TAGGED_POLICY_Unmarshal(&target->policies[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 2:110 - Definition of TPMU_CAPABILITIES Union (StructuresTable()) */\n\n#if 0\nTPM_RC\nTPMU_CAPABILITIES_Unmarshal(TPMU_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n      case TPM_CAP_ALGS:\n\trc = TPML_ALG_PROPERTY_Unmarshal(&target->algorithms, buffer, size);\n\tbreak;\n      case TPM_CAP_HANDLES:\n\trc = TPML_HANDLE_Unmarshal(&target->handles, buffer, size);\n\tbreak;\n      case TPM_CAP_COMMANDS:\n\trc = TPML_CCA_Unmarshal(&target->command, buffer, size);\n\tbreak;\n      case TPM_CAP_PP_COMMANDS:\n\trc = TPML_CC_Unmarshal(&target->ppCommands, buffer, size);\n\tbreak;\n      case TPM_CAP_AUDIT_COMMANDS:\n\trc = TPML_CC_Unmarshal(&target->auditCommands, buffer, size);\n\tbreak;\n      case TPM_CAP_PCRS:\n\trc = TPML_PCR_SELECTION_Unmarshal(&target->assignedPCR, buffer, size);\n\tbreak;\n      case TPM_CAP_TPM_PROPERTIES:\n\trc = TPML_TAGGED_TPM_PROPERTY_Unmarshal(&target->tpmProperties, buffer, size);\n\tbreak;\n      case TPM_CAP_PCR_PROPERTIES:\n\trc = TPML_TAGGED_PCR_PROPERTY_Unmarshal(&target->pcrProperties, buffer, size);\n\tbreak;\n      case TPM_CAP_ECC_CURVES:\n\trc = TPML_ECC_CURVE_Unmarshal(&target->eccCurves, buffer, size);\n\tbreak;\n      case TPM_CAP_AUTH_POLICIES:\n\trc = TPML_TAGGED_POLICY_Unmarshal(&target->authPolicies, buffer, size);\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n#endif\n\n/* Table 128 - Definition of TPMS_CAPABILITY_DATA Structure (StructuresTable()) */\n\n#if 0\nTPM_RC\nTPMS_CAPABILITY_DATA_Unmarshal(TPMS_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_CAP_Unmarshal(&target->capability, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_CAPABILITIES_Unmarshal(&target->data, buffer, size, target->capability);\n    }\n    return rc;\n}\n#endif\n\n/* NOTE The TPMU_SET_CAPABILITIES structure may be defined by a TCG Registry. */\nTPM_RC\nTPMU_SET_CAPABILITIES_Unmarshal(TPMU_SET_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    switch (selector) {\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 129 - Definition of TPMS_SET_CAPABILITY_DATA Structure <IN> */\nTPM_RC\nTPMS_SET_CAPABILITY_DATA_Unmarshal(TPMS_SET_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_CAP_Unmarshal(&target->setCapability, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SET_CAPABILITIES_Unmarshal(&target->data, buffer, size, target->setCapability);\n    }\n    return rc;\n}\n\n/* Table 130 - Definition of TPM2B_SET_CAPABILITY_DATA Structure <IN> */\nTPM_RC\nTPM2B_SET_CAPABILITY_DATA_Unmarshal(TPM2B_SET_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    INT32 startSize;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SET_CAPABILITY_DATA_Unmarshal(&target->setCapabilityData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\ntypedef struct {\n    UINT16\t\t\t\tsize;\n    TPMS_SET_CAPABILITY_DATA\tsetCapabilityData;\n} TPM2B_SET_CAPABILITY_DATA;\n\n\n/* Table 109 - Definition of TPMS_CLOCK_INFO Structure */\n\nTPM_RC\nTPMS_CLOCK_INFO_Unmarshal(TPMS_CLOCK_INFO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT64_Unmarshal(&target->clock, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->resetCount, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->restartCount, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_YES_NO_Unmarshal(&target->safe, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 110 - Definition of TPMS_TIME_INFO Structure */\n\nTPM_RC\nTPMS_TIME_INFO_Unmarshal(TPMS_TIME_INFO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT64_Unmarshal(&target->time, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_CLOCK_INFO_Unmarshal(&target->clockInfo, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 111 - Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */\n\nTPM_RC\nTPMS_TIME_ATTEST_INFO_Unmarshal(TPMS_TIME_ATTEST_INFO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_TIME_INFO_Unmarshal(&target->time, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT64_Unmarshal(&target->firmwareVersion, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 112 - Definition of TPMS_CERTIFY_INFO Structure <OUT> */\n\nTPM_RC\nTPMS_CERTIFY_INFO_Unmarshal(TPMS_CERTIFY_INFO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_NAME_Unmarshal(&target->name, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_NAME_Unmarshal(&target->qualifiedName, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 113 - Definition of TPMS_QUOTE_INFO Structure <OUT> */\n\nTPM_RC\nTPMS_QUOTE_INFO_Unmarshal(TPMS_QUOTE_INFO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPML_PCR_SELECTION_Unmarshal(&target->pcrSelect, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->pcrDigest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 114 - Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */\n\nTPM_RC\nTPMS_COMMAND_AUDIT_INFO_Unmarshal(TPMS_COMMAND_AUDIT_INFO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT64_Unmarshal(&target->auditCounter, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(&target->digestAlg, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->auditDigest, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->commandDigest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 115 - Definition of TPMS_SESSION_AUDIT_INFO Structure <OUT> */\n\nTPM_RC\nTPMS_SESSION_AUDIT_INFO_Unmarshal(TPMS_SESSION_AUDIT_INFO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_YES_NO_Unmarshal(&target->exclusiveSession, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->sessionDigest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 116 - Definition of TPMS_CREATION_INFO Structure <OUT> */\n\nTPM_RC\nTPMS_CREATION_INFO_Unmarshal(TPMS_CREATION_INFO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_NAME_Unmarshal(&target->objectName, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->creationHash, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 117 - Definition of TPMS_NV_CERTIFY_INFO Structure <OUT> */\n\nTPM_RC\nTPMS_NV_CERTIFY_INFO_Unmarshal(TPMS_NV_CERTIFY_INFO *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_NAME_Unmarshal(&target->indexName, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->offset, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_MAX_NV_BUFFER_Unmarshal(&target->nvContents, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 118 - Definition of (TPM_ST) TPMI_ST_ATTEST Type <OUT> */\n\nTPM_RC\nTPMI_ST_ATTEST_Unmarshal(TPMI_ST_ATTEST *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ST_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_ST_ATTEST_CERTIFY:\n\t  case TPM_ST_ATTEST_CREATION:\n\t  case TPM_ST_ATTEST_QUOTE:\n\t  case TPM_ST_ATTEST_COMMAND_AUDIT:\n\t  case TPM_ST_ATTEST_SESSION_AUDIT:\n\t  case TPM_ST_ATTEST_TIME:\n\t  case TPM_ST_ATTEST_NV:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_SELECTOR;\n\t}\n    }\n    return rc;\n}\n\n/*  Table 119 - Definition of TPMU_ATTEST Union <OUT> */\n\nTPM_RC\nTPMU_ATTEST_Unmarshal(TPMU_ATTEST *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n      case TPM_ST_ATTEST_CERTIFY:\n\trc = TPMS_CERTIFY_INFO_Unmarshal(&target->certify, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_CREATION:\n\trc = TPMS_CREATION_INFO_Unmarshal(&target->creation, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_QUOTE:\n\trc = TPMS_QUOTE_INFO_Unmarshal(&target->quote, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_COMMAND_AUDIT:\n\trc = TPMS_COMMAND_AUDIT_INFO_Unmarshal(&target->commandAudit, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_SESSION_AUDIT:\n\trc = TPMS_SESSION_AUDIT_INFO_Unmarshal(&target->sessionAudit, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_TIME:\n\trc = TPMS_TIME_ATTEST_INFO_Unmarshal(&target->time, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_NV:\n\trc = TPMS_NV_CERTIFY_INFO_Unmarshal(&target->nv, buffer, size);\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n\n    }\n    return rc;\n}\n\n/* Table 120 - Definition of TPMS_ATTEST Structure <OUT> */\n\nTPM_RC\nTPMS_ATTEST_Unmarshal(TPMS_ATTEST *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_GENERATED_Unmarshal(&target->magic, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ST_ATTEST_Unmarshal(&target->type, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_NAME_Unmarshal(&target->qualifiedSigner, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DATA_Unmarshal(&target->extraData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_CLOCK_INFO_Unmarshal(&target->clockInfo, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT64_Unmarshal(&target->firmwareVersion, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_ATTEST_Unmarshal(&target->attested, buffer, size, target->type);\n    }\n    return rc;\n}\n\n/* Table 121 - Definition of TPM2B_ATTEST Structure <OUT> */\n\nTPM_RC\nTPM2B_ATTEST_Unmarshal(TPM2B_ATTEST *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(TPMS_ATTEST), buffer, size);\n    }\n    return rc;\n}\n\n#endif\n\n/* Table 124 - Definition of {!ALG.S} (TPM_KEY_BITS) TPMI_!ALG.S_KEY_BITS Type */\n\n#if ALG_AES\nTPM_RC\nTPMI_AES_KEY_BITS_Unmarshal(TPMI_AES_KEY_BITS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_KEY_BITS_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case 128:\n\t  case 256:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n#endif\n\n#if ALG_CAMELLIA\nTPM_RC\nTPMI_CAMELLIA_KEY_BITS_Unmarshal(TPMI_CAMELLIA_KEY_BITS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_KEY_BITS_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case 128:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n#endif\n\n#if ALG_SM4\nTPM_RC\nTPMI_SM4_KEY_BITS_Unmarshal(TPMI_SM4_KEY_BITS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_KEY_BITS_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case 128:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n#endif\n\n/* Table 125 - Definition of TPMU_SYM_KEY_BITS Union */\n\nTPM_RC\nTPMU_SYM_KEY_BITS_Unmarshal(TPMU_SYM_KEY_BITS *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_AES\n      case TPM_ALG_AES:\n\trc = TPMI_AES_KEY_BITS_Unmarshal(&target->aes, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM4\n      case TPM_ALG_SM4:\n\trc = TPMI_SM4_KEY_BITS_Unmarshal(&target->sm4, buffer, size);\n\tbreak;\n#endif\n#if ALG_CAMELLIA\n      case TPM_ALG_CAMELLIA:\n\trc = TPMI_CAMELLIA_KEY_BITS_Unmarshal(&target->camellia, buffer, size);\n\tbreak;\n#endif\n#if ALG_XOR\n      case TPM_ALG_XOR:\n\trc = TPMI_ALG_HASH_Unmarshal(&target->xorr, buffer, size, NO);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 126 - Definition of TPMU_SYM_MODE Union */\n\nTPM_RC\nTPMU_SYM_MODE_Unmarshal(TPMU_SYM_MODE *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_AES\n      case TPM_ALG_AES:\n\trc = TPMI_ALG_SYM_MODE_Unmarshal(&target->aes, buffer, size, YES);\n\tbreak;\n#endif\n#if ALG_SM4\n      case TPM_ALG_SM4:\n\trc = TPMI_ALG_SYM_MODE_Unmarshal(&target->sm4, buffer, size, YES);\n\tbreak;\n#endif\n#if ALG_CAMELLIA\n      case TPM_ALG_CAMELLIA:\n\trc = TPMI_ALG_SYM_MODE_Unmarshal(&target->camellia, buffer, size, YES);\n\tbreak;\n#endif\n      case TPM_ALG_XOR:\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 131 - Definition of TPMT_SYM_DEF Structure */\n\nTPM_RC\nTPMT_SYM_DEF_Unmarshal(TPMT_SYM_DEF *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_SYM_Unmarshal(&target->algorithm, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SYM_KEY_BITS_Unmarshal(&target->keyBits, buffer, size, target->algorithm);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SYM_MODE_Unmarshal(&target->mode, buffer, size, target->algorithm);\n    }\n    return rc;\n}\n\n/* Table 132 - Definition of TPMT_SYM_DEF_OBJECT Structure */\n\nTPM_RC\nTPMT_SYM_DEF_OBJECT_Unmarshal(TPMT_SYM_DEF_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_SYM_OBJECT_Unmarshal(&target->algorithm, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SYM_KEY_BITS_Unmarshal(&target->keyBits, buffer, size, target->algorithm);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SYM_MODE_Unmarshal(&target->mode, buffer, size, target->algorithm);\n    }\n    return rc;\n}\n\n/* Table 133 - Definition of TPM2B_SYM_KEY Structure */\n\nTPM_RC\nTPM2B_SYM_KEY_Unmarshal(TPM2B_SYM_KEY *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, MAX_SYM_KEY_BYTES, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 134 - Definition of TPMS_SYMCIPHER_PARMS Structure */\n\nTPM_RC\nTPMS_SYMCIPHER_PARMS_Unmarshal(TPMS_SYMCIPHER_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_SYM_DEF_OBJECT_Unmarshal(&target->sym, buffer, size, NO);\n    }\n    return rc;\n}\n\n/* Table 2:135 - Definition of TPM2B_LABEL Structure (StructuresTable()) */\n\nTPM_RC\nTPM2B_LABEL_Unmarshal(TPM2B_LABEL *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, LABEL_MAX_BUFFER, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 2:136 - Definition of TPMS_DERIVE Structure (StructuresTable()) */\n\nTPM_RC\nTPMS_DERIVE_Unmarshal(TPMS_DERIVE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_LABEL_Unmarshal(&target->label, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_LABEL_Unmarshal(&target->context, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 139 - Definition of TPM2B_SENSITIVE_DATA Structure */\n\nTPM_RC\nTPM2B_SENSITIVE_DATA_Unmarshal(TPM2B_SENSITIVE_DATA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, MAX_SYM_DATA, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 133 - Definition of TPMS_SENSITIVE_CREATE Structure <IN> */\n\nTPM_RC\nTPMS_SENSITIVE_CREATE_Unmarshal(TPMS_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_AUTH_Unmarshal(&target->userAuth, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_SENSITIVE_DATA_Unmarshal(&target->data, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 134 - Definition of TPM2B_SENSITIVE_CREATE Structure <IN, S> */\n\nTPM_RC\nTPM2B_SENSITIVE_CREATE_Unmarshal(TPM2B_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    INT32 startSize;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SENSITIVE_CREATE_Unmarshal(&target->sensitive, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\nTPM_RC\nTPMS_SCHEME_HASH_Unmarshal(TPMS_SCHEME_HASH *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->hashAlg, buffer, size, NO);\n    }\n    return rc;\n}\n\n/* Table 136 - Definition of {ECC} TPMS_SCHEME_ECDAA Structure */\n\nTPM_RC\nTPMS_SCHEME_ECDAA_Unmarshal(TPMS_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->hashAlg, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->count, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 137 - Definition of (TPM_ALG_ID) TPMI_ALG_KEYEDHASH_SCHEME Type */\n\nTPM_RC\nTPMI_ALG_KEYEDHASH_SCHEME_Unmarshal(TPMI_ALG_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_HMAC\n\t  case TPM_ALG_HMAC:\n#endif\n#if ALG_XOR\n\t  case TPM_ALG_XOR:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 138 - Definition of Types for HMAC_SIG_SCHEME */\n\nTPM_RC\nTPMS_SCHEME_HMAC_Unmarshal(TPMS_SCHEME_HMAC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 139 - Definition of TPMS_SCHEME_XOR Structure */\n\nTPM_RC\nTPMS_SCHEME_XOR_Unmarshal(TPMS_SCHEME_XOR *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->hashAlg, buffer, size, NO);\t/* as of rev 147 */\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_KDF_Unmarshal(&target->kdf, buffer, size, YES);\n    }\n    return rc;\n}\n\n/* Table 140 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */\n\nTPM_RC\nTPMU_SCHEME_KEYEDHASH_Unmarshal(TPMU_SCHEME_KEYEDHASH *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_HMAC\n      case TPM_ALG_HMAC:\n\trc = TPMS_SCHEME_HMAC_Unmarshal(&target->hmac, buffer, size);\n\tbreak;\n#endif\n#if ALG_XOR\n      case TPM_ALG_XOR:\n\trc = TPMS_SCHEME_XOR_Unmarshal(&target->xorr, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 141 - Definition of TPMT_KEYEDHASH_SCHEME Structure */\n\nTPM_RC\nTPMT_KEYEDHASH_SCHEME_Unmarshal(TPMT_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_KEYEDHASH_SCHEME_Unmarshal(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SCHEME_KEYEDHASH_Unmarshal(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\nTPM_RC\nTPMS_SIG_SCHEME_RSAPSS_Unmarshal(TPMS_SIG_SCHEME_RSAPSS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\nTPM_RC\nTPMS_SIG_SCHEME_RSASSA_Unmarshal(TPMS_SIG_SCHEME_RSASSA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTPMS_SIG_SCHEME_ECDAA_Unmarshal(TPMS_SIG_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_ECDAA_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTPMS_SIG_SCHEME_ECDSA_Unmarshal(TPMS_SIG_SCHEME_ECDSA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTPMS_SIG_SCHEME_ECSCHNORR_Unmarshal(TPMS_SIG_SCHEME_ECSCHNORR *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTPMS_SIG_SCHEME_SM2_Unmarshal(TPMS_SIG_SCHEME_SM2 *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\nTPM_RC\nTPMU_SIG_SCHEME_Unmarshal(TPMU_SIG_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\trc = TPMS_SIG_SCHEME_RSASSA_Unmarshal(&target->rsassa, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\trc = TPMS_SIG_SCHEME_RSAPSS_Unmarshal(&target->rsapss, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\trc = TPMS_SIG_SCHEME_ECDSA_Unmarshal(&target->ecdsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\trc = TPMS_SIG_SCHEME_ECDAA_Unmarshal(&target->ecdaa, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM2\n      case TPM_ALG_SM2:\n\trc = TPMS_SIG_SCHEME_SM2_Unmarshal(&target->sm2, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\trc = TPMS_SIG_SCHEME_ECSCHNORR_Unmarshal(&target->ecschnorr, buffer, size);\n\tbreak;\n#endif\n#if ALG_HMAC\n      case TPM_ALG_HMAC:\n\trc = TPMS_SCHEME_HMAC_Unmarshal(&target->hmac, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\nTPM_RC\nTPMT_SIG_SCHEME_Unmarshal(TPMT_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_SIG_SCHEME_Unmarshal(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SIG_SCHEME_Unmarshal(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* Table 146 - Definition of Types for {RSA} Encryption Schemes */\n\nTPM_RC\nTPMS_ENC_SCHEME_OAEP_Unmarshal(TPMS_ENC_SCHEME_OAEP *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 146 - Definition of Types for {RSA} Encryption Schemes */\n\nTPM_RC\nTPMS_ENC_SCHEME_RSAES_Unmarshal(TPMS_ENC_SCHEME_RSAES *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_EMPTY_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 147 - Definition of Types for {ECC} ECC Key Exchange */\n\nTPM_RC\nTPMS_KEY_SCHEME_ECDH_Unmarshal(TPMS_KEY_SCHEME_ECDH *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 147 - Definition of Types for {ECC} ECC Key Exchange */\n\nTPM_RC\nTPMS_KEY_SCHEME_ECMQV_Unmarshal(TPMS_KEY_SCHEME_ECMQV *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */\n\nTPM_RC\nTPMS_KDF_SCHEME_KDF1_SP800_108_Unmarshal(TPMS_KDF_SCHEME_KDF1_SP800_108 *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */\n\nTPM_RC\nTPMS_KDF_SCHEME_KDF1_SP800_56A_Unmarshal(TPMS_KDF_SCHEME_KDF1_SP800_56A *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */\n\nTPM_RC\nTPMS_KDF_SCHEME_KDF2_Unmarshal(TPMS_KDF_SCHEME_KDF2 *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */\n\nTPM_RC\nTPMS_KDF_SCHEME_MGF1_Unmarshal(TPMS_KDF_SCHEME_MGF1 *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SCHEME_HASH_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 149 - Definition of TPMU_KDF_SCHEME Union <IN/OUT, S> */\n\nTPM_RC\nTPMU_KDF_SCHEME_Unmarshal(TPMU_KDF_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_MGF1\n      case TPM_ALG_MGF1:\n\trc = TPMS_KDF_SCHEME_MGF1_Unmarshal(&target->mgf1, buffer, size);\n\tbreak;\n#endif\n#if ALG_KDF1_SP800_56A\n      case TPM_ALG_KDF1_SP800_56A:\n\trc = TPMS_KDF_SCHEME_KDF1_SP800_56A_Unmarshal(&target->kdf1_sp800_56a, buffer, size);\n\tbreak;\n#endif\n#if ALG_KDF2\n      case TPM_ALG_KDF2:\n\trc = TPMS_KDF_SCHEME_KDF2_Unmarshal(&target->kdf2, buffer, size);\n\tbreak;\n#endif\n#if ALG_KDF1_SP800_108\n      case TPM_ALG_KDF1_SP800_108:\n\trc = TPMS_KDF_SCHEME_KDF1_SP800_108_Unmarshal(&target->kdf1_sp800_108, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 150 - Definition of TPMT_KDF_SCHEME Structure */\n\nTPM_RC\nTPMT_KDF_SCHEME_Unmarshal(TPMT_KDF_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_KDF_Unmarshal(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_KDF_SCHEME_Unmarshal(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* Table 151 - Definition of (TPM_ALG_ID) TPMI_ALG_ASYM_SCHEME Type <> */\n\n#if 0\nTPM_RC\nTPMI_ALG_ASYM_SCHEME_Unmarshal(TPMI_ALG_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_ECDH\n\t  case TPM_ALG_ECDH:\n#endif\n#if ALG_ECMQV\n\t  case TPM_ALG_ECMQV:\n#endif\n#if ALG_RSASSA\n\t  case TPM_ALG_RSASSA:\n#endif\n#if ALG_RSAPSS\n\t  case TPM_ALG_RSAPSS:\n#endif\n#if ALG_ECDSA\n\t  case TPM_ALG_ECDSA:\n#endif\n#if ALG_ECDAA\n\t  case TPM_ALG_ECDAA:\n#endif\n#if ALG_SM2\n\t  case TPM_ALG_SM2:\n#endif\n#if ALG_ECSCHNORR\n\t  case TPM_ALG_ECSCHNORR:\n#endif\n#if ALG_RSAES\n\t  case TPM_ALG_RSAES:\n#endif\n#if ALG_OAEP\n\t  case TPM_ALG_OAEP:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n#endif\n\n/* Table 152 - Definition of TPMU_ASYM_SCHEME Union */\n\nTPM_RC\nTPMU_ASYM_SCHEME_Unmarshal(TPMU_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_ECDH\n      case TPM_ALG_ECDH:\n\trc = TPMS_KEY_SCHEME_ECDH_Unmarshal(&target->ecdh, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECMQV\n      case TPM_ALG_ECMQV:\n\trc = TPMS_KEY_SCHEME_ECMQV_Unmarshal(&target->ecmqv, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\trc = TPMS_SIG_SCHEME_RSASSA_Unmarshal(&target->rsassa, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\trc = TPMS_SIG_SCHEME_RSAPSS_Unmarshal(&target->rsapss, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\trc = TPMS_SIG_SCHEME_ECDSA_Unmarshal(&target->ecdsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\trc = TPMS_SIG_SCHEME_ECDAA_Unmarshal(&target->ecdaa, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM2\n      case TPM_ALG_SM2:\n\trc = TPMS_SIG_SCHEME_SM2_Unmarshal(&target->sm2, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\trc = TPMS_SIG_SCHEME_ECSCHNORR_Unmarshal(&target->ecschnorr, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSAES\n      case TPM_ALG_RSAES:\n\trc = TPMS_ENC_SCHEME_RSAES_Unmarshal(&target->rsaes, buffer, size);\n\tbreak;\n#endif\n#if ALG_OAEP\n      case TPM_ALG_OAEP:\n\trc = TPMS_ENC_SCHEME_OAEP_Unmarshal(&target->oaep, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 154 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_SCHEME Type */\n\nTPM_RC\nTPMI_ALG_RSA_SCHEME_Unmarshal(TPMI_ALG_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_RSASSA\n\t  case TPM_ALG_RSASSA:\n#endif\n#if ALG_RSAPSS\n\t  case TPM_ALG_RSAPSS:\n#endif\n#if ALG_RSAES\n\t  case TPM_ALG_RSAES:\n#endif\n#if ALG_OAEP\n\t  case TPM_ALG_OAEP:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 155 - Definition of {RSA} TPMT_RSA_SCHEME Structure */\n\nTPM_RC\nTPMT_RSA_SCHEME_Unmarshal(TPMT_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_RSA_SCHEME_Unmarshal(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_ASYM_SCHEME_Unmarshal(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* Table 156 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_DECRYPT Type */\n\nTPM_RC\nTPMI_ALG_RSA_DECRYPT_Unmarshal(TPMI_ALG_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_RSAES\n\t  case TPM_ALG_RSAES:\n#endif\n#if ALG_OAEP\n\t  case TPM_ALG_OAEP:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 157 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */\n\nTPM_RC\nTPMT_RSA_DECRYPT_Unmarshal(TPMT_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_RSA_DECRYPT_Unmarshal(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_ASYM_SCHEME_Unmarshal(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* Table 158 - Definition of {RSA} TPM2B_PUBLIC_KEY_RSA Structure */\n\nTPM_RC\nTPM2B_PUBLIC_KEY_RSA_Unmarshal(TPM2B_PUBLIC_KEY_RSA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, MAX_RSA_KEY_BYTES, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 159 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type */\n\nTPM_RC\nTPMI_RSA_KEY_BITS_Unmarshal(TPMI_RSA_KEY_BITS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_KEY_BITS_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case 1024:\n\t  case 2048:\n\t  case 3072:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 160 - Definition of {RSA} TPM2B_PRIVATE_KEY_RSA Structure */\n\nTPM_RC\nTPM2B_PRIVATE_KEY_RSA_Unmarshal(TPM2B_PRIVATE_KEY_RSA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, RSA_PRIVATE_SIZE, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 161 - Definition of {ECC} TPM2B_ECC_PARAMETER Structure */\n\nTPM_RC\nTPM2B_ECC_PARAMETER_Unmarshal(TPM2B_ECC_PARAMETER *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n     \trc = TPM2B_Unmarshal(&target->b, MAX_ECC_KEY_BYTES, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 162 - Definition of {ECC} TPMS_ECC_POINT Structure */\n\nTPM_RC\nTPMS_ECC_POINT_Unmarshal(TPMS_ECC_POINT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_ECC_PARAMETER_Unmarshal(&target->x, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_ECC_PARAMETER_Unmarshal(&target->y, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 163 - Definition of {ECC} TPM2B_ECC_POINT Structure */\n\nTPM_RC\nTPM2B_ECC_POINT_Unmarshal(TPM2B_ECC_POINT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    INT32 startSize;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_ECC_POINT_Unmarshal(&target->point, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 164 - Definition of (TPM_ALG_ID) {ECC} TPMI_ALG_ECC_SCHEME Type */\n\nTPM_RC\nTPMI_ALG_ECC_SCHEME_Unmarshal(TPMI_ALG_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_ECDSA\n\t  case TPM_ALG_ECDSA:\n#endif\n#if ALG_SM2\n\t  case TPM_ALG_SM2:\n#endif\n#if ALG_ECDAA\n\t  case TPM_ALG_ECDAA:\n#endif\n#if ALG_ECSCHNORR\n\t  case TPM_ALG_ECSCHNORR:\n#endif\n#if ALG_ECDH\n\t  case TPM_ALG_ECDH:\n#endif\n#if ALG_ECMQV\n\t  case TPM_ALG_ECMQV:\n#endif\n\t    break;\n\t  case TPM_ALG_NULL:\n\t    if (allowNull) {\n\t\tbreak;\n\t    }\n\t  default:\n\t    rc = TPM_RC_SCHEME;\n\t}\n    }\n    return rc;\n}\n\n/* Table 165 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */\n\nTPM_RC\nTPMI_ECC_CURVE_Unmarshal(TPMI_ECC_CURVE *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ECC_CURVE_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif ((*target == TPM_ECC_NONE) && !allowNull) {\n\t    rc = TPM_RC_CURVE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 166 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure */\n\nTPM_RC\nTPMT_ECC_SCHEME_Unmarshal(TPMT_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_ECC_SCHEME_Unmarshal(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_ASYM_SCHEME_Unmarshal(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* Table 168 - Definition of {RSA} TPMS_SIGNATURE_RSA Structure */\n\nTPM_RC\nTPMS_SIGNATURE_RSA_Unmarshal(TPMS_SIGNATURE_RSA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->hash, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_PUBLIC_KEY_RSA_Unmarshal(&target->sig, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 169 - Definition of Types for {RSA} Signature */\n\nTPM_RC\nTPMS_SIGNATURE_RSASSA_Unmarshal(TPMS_SIGNATURE_RSASSA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SIGNATURE_RSA_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 169 - Definition of Types for {RSA} Signature */\n\nTPM_RC\nTPMS_SIGNATURE_RSAPSS_Unmarshal(TPMS_SIGNATURE_RSAPSS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SIGNATURE_RSA_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 170 - Definition of {ECC} TPMS_SIGNATURE_ECC Structure */\n\nTPM_RC\nTPMS_SIGNATURE_ECC_Unmarshal(TPMS_SIGNATURE_ECC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->hash, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_ECC_PARAMETER_Unmarshal(&target->signatureR, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_ECC_PARAMETER_Unmarshal(&target->signatureS, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 171 - Definition of Types for {ECC} TPMS_SIGNATURE_ECC */\n\nTPM_RC\nTPMS_SIGNATURE_ECDSA_Unmarshal(TPMS_SIGNATURE_ECDSA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SIGNATURE_ECC_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTPMS_SIGNATURE_ECDAA_Unmarshal(TPMS_SIGNATURE_ECDAA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SIGNATURE_ECC_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTPMS_SIGNATURE_SM2_Unmarshal(TPMS_SIGNATURE_SM2 *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SIGNATURE_ECC_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTPMS_SIGNATURE_ECSCHNORR_Unmarshal(TPMS_SIGNATURE_ECSCHNORR *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SIGNATURE_ECC_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 172 - Definition of TPMU_SIGNATURE Union <IN/OUT, S> */\n\nTPM_RC\nTPMU_SIGNATURE_Unmarshal(TPMU_SIGNATURE *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\trc = TPMS_SIGNATURE_RSASSA_Unmarshal(&target->rsassa, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\trc = TPMS_SIGNATURE_RSAPSS_Unmarshal(&target->rsapss, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\trc = TPMS_SIGNATURE_ECDSA_Unmarshal(&target->ecdsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\trc = TPMS_SIGNATURE_ECDAA_Unmarshal(&target->ecdaa, buffer, size);\n\tbreak;\n#endif\n#if ALG_SM2\n      case TPM_ALG_SM2:\n\trc = TPMS_SIGNATURE_SM2_Unmarshal(&target->sm2, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\trc = TPMS_SIGNATURE_ECSCHNORR_Unmarshal(&target->ecschnorr, buffer, size);\n\tbreak;\n#endif\n#if ALG_HMAC\n      case TPM_ALG_HMAC:\n\trc = TPMT_HA_Unmarshal(&target->hmac, buffer, size, NO);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 173 - Definition of TPMT_SIGNATURE Structure */\n\nTPM_RC\nTPMT_SIGNATURE_Unmarshal(TPMT_SIGNATURE *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_SIG_SCHEME_Unmarshal(&target->sigAlg, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SIGNATURE_Unmarshal(&target->signature, buffer, size, target->sigAlg);\n    }\n    return rc;\n}\n\n/* Table 175 - Definition of TPM2B_ENCRYPTED_SECRET Structure */\n\nTPM_RC\nTPM2B_ENCRYPTED_SECRET_Unmarshal(TPM2B_ENCRYPTED_SECRET *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(TPMU_ENCRYPTED_SECRET), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 176 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */\n\nTPM_RC\nTPMI_ALG_PUBLIC_Unmarshal(TPMI_ALG_PUBLIC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_ALG_ID_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n#if ALG_KEYEDHASH\n\t  case TPM_ALG_KEYEDHASH:\n#endif\n#if ALG_RSA\n\t  case TPM_ALG_RSA:\n#endif\n#if ALG_ECC\n\t  case TPM_ALG_ECC:\n#endif\n#if ALG_SYMCIPHER\n\t  case TPM_ALG_SYMCIPHER:\n#endif\n\t    break;\n\t  default:\n\t    rc = TPM_RC_TYPE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 177 - Definition of TPMU_PUBLIC_ID Union <IN/OUT, S> */\n\nTPM_RC\nTPMU_PUBLIC_ID_Unmarshal(TPMU_PUBLIC_ID *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\trc = TPM2B_DIGEST_Unmarshal(&target->keyedHash, buffer, size);\n\tbreak;\n#endif\n#if ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\trc = TPM2B_DIGEST_Unmarshal(&target->sym, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSA\n      case TPM_ALG_RSA:\n\trc = TPM2B_PUBLIC_KEY_RSA_Unmarshal(&target->rsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECC\n      case TPM_ALG_ECC:\n\trc = TPMS_ECC_POINT_Unmarshal(&target->ecc, buffer, size);\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 178 - Definition of TPMS_KEYEDHASH_PARMS Structure */\n\nTPM_RC\nTPMS_KEYEDHASH_PARMS_Unmarshal(TPMS_KEYEDHASH_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_KEYEDHASH_SCHEME_Unmarshal(&target->scheme, buffer, size, YES);\n    }\n    return rc;\n}\n\n/* Table 180 - Definition of {RSA} TPMS_RSA_PARMS Structure */\n\nTPM_RC\nTPMS_RSA_PARMS_Unmarshal(TPMS_RSA_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_SYM_DEF_OBJECT_Unmarshal(&target->symmetric, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_RSA_SCHEME_Unmarshal(&target->scheme, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_RSA_KEY_BITS_Unmarshal(&target->keyBits, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(&target->exponent, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 181 - Definition of {ECC} TPMS_ECC_PARMS Structure */\n\nTPM_RC\nTPMS_ECC_PARMS_Unmarshal(TPMS_ECC_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_SYM_DEF_OBJECT_Unmarshal(&target->symmetric, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_ECC_SCHEME_Unmarshal(&target->scheme, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ECC_CURVE_Unmarshal(&target->curveID, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_KDF_SCHEME_Unmarshal(&target->kdf, buffer, size, YES);\n    }\n    return rc;\n}\n\n/* Table 182 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */\n\nTPM_RC\nTPMU_PUBLIC_PARMS_Unmarshal(TPMU_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\trc = TPMS_KEYEDHASH_PARMS_Unmarshal(&target->keyedHashDetail, buffer, size);\n\tbreak;\n#endif\n#if ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\trc = TPMS_SYMCIPHER_PARMS_Unmarshal(&target->symDetail, buffer, size);\n\tbreak;\n#endif\n#if ALG_RSA\n      case TPM_ALG_RSA:\n\trc = TPMS_RSA_PARMS_Unmarshal(&target->rsaDetail, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECC\n      case TPM_ALG_ECC:\n\trc = TPMS_ECC_PARMS_Unmarshal(&target->eccDetail, buffer, size);\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 183 - Definition of TPMT_PUBLIC_PARMS Structure */\n\nTPM_RC\nTPMT_PUBLIC_PARMS_Unmarshal(TPMT_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_PUBLIC_Unmarshal(&target->type, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_PUBLIC_PARMS_Unmarshal(&target->parameters, buffer, size, target->type);\n    }\n    return rc;\n}\n\n/* Table 191 - Definition of TPMT_PUBLIC Structure */\n\nTPM_RC\nTPMT_PUBLIC_Unmarshal(TPMT_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_PUBLIC_Unmarshal(&target->type, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->nameAlg, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMA_OBJECT_Unmarshal(&target->objectAttributes, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->authPolicy, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_PUBLIC_PARMS_Unmarshal(&target->parameters, buffer, size, target->type);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_PUBLIC_ID_Unmarshal(&target->unique, buffer, size, target->type);\n    }\n    return rc;\n}\n\n/* Table 192 - Definition of TPM2B_PUBLIC Structure */\n\nTPM_RC\nTPM2B_PUBLIC_Unmarshal(TPM2B_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    INT32 startSize;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_PUBLIC_Unmarshal(&target->publicArea, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 2:193 - Definition of TPM2B_TEMPLATE Structure (StructuresTable()) */\n\nTPM_RC\nTPM2B_TEMPLATE_Unmarshal(TPM2B_TEMPLATE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(TPMT_PUBLIC), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 187 - Definition of TPMU_SENSITIVE_COMPOSITE Union <IN/OUT, S> */\n\nTPM_RC\nTPMU_SENSITIVE_COMPOSITE_Unmarshal(TPMU_SENSITIVE_COMPOSITE *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#if ALG_RSA\n      case TPM_ALG_RSA:\n\trc = TPM2B_PRIVATE_KEY_RSA_Unmarshal(&target->rsa, buffer, size);\n\tbreak;\n#endif\n#if ALG_ECC\n      case TPM_ALG_ECC:\n\trc = TPM2B_ECC_PARAMETER_Unmarshal(&target->ecc, buffer, size);\n\tbreak;\n#endif\n#if ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\trc = TPM2B_SENSITIVE_DATA_Unmarshal(&target->bits, buffer, size);\n\tbreak;\n#endif\n#if ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\trc = TPM2B_SYM_KEY_Unmarshal(&target->sym, buffer, size);\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 188 - Definition of TPMT_SENSITIVE Structure */\n\nTPM_RC\nTPMT_SENSITIVE_Unmarshal(TPMT_SENSITIVE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_PUBLIC_Unmarshal(&target->sensitiveType, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_AUTH_Unmarshal(&target->authValue, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->seedValue, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SENSITIVE_COMPOSITE_Unmarshal(&target->sensitive, buffer, size, target->sensitiveType);\n    }\n    return rc;\n}\n\n/* Table 189 - Definition of TPM2B_SENSITIVE Structure <IN/OUT> */\n\nTPM_RC\nTPM2B_SENSITIVE_Unmarshal(TPM2B_SENSITIVE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    INT32 startSize;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->size, buffer, size);\n    }\n    if (target->size != 0) {\n\tif (rc == TPM_RC_SUCCESS) {\n\t    startSize = *size;\n\t}\n\tif (rc == TPM_RC_SUCCESS) {\n\t    rc = TPMT_SENSITIVE_Unmarshal(&target->sensitiveArea, buffer, size);\n\t}\n\tif (rc == TPM_RC_SUCCESS) {\n\t    if (target->size != startSize - *size) {\n\t\trc = TPM_RC_SIZE;\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* Table 191 - Definition of TPM2B_PRIVATE Structure <IN/OUT, S> */\n\nTPM_RC\nTPM2B_PRIVATE_Unmarshal(TPM2B_PRIVATE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(_PRIVATE), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 193 - Definition of TPM2B_ID_OBJECT Structure <IN/OUT> */\n\nTPM_RC\nTPM2B_ID_OBJECT_Unmarshal(TPM2B_ID_OBJECT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(TPMS_ID_OBJECT), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 196 - Definition of (UINT32) TPMA_NV Bits */\n\nTPM_RC\nTPMA_NV_Unmarshal(TPMA_NV *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (*target & TPMA_NV_RESERVED) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 197 - Definition of TPMS_NV_PUBLIC Structure */\n\nTPM_RC\nTPMS_NV_PUBLIC_Unmarshal(TPMS_NV_PUBLIC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_RH_NV_INDEX_Unmarshal(&target->nvIndex, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->nameAlg, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMA_NV_Unmarshal(&target->attributes, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->authPolicy, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->dataSize, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->dataSize > MAX_NV_INDEX_SIZE) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 198 - Definition of TPM2B_NV_PUBLIC Structure */\n\nTPM_RC\nTPM2B_NV_PUBLIC_Unmarshal(TPM2B_NV_PUBLIC *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    INT32 startSize;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_NV_PUBLIC_Unmarshal(&target->nvPublic, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 226 - Definition of (UINT64) TPMA_NV_EXP Bits */\n\nTPM_RC\nTPMA_NV_EXP_Unmarshal(TPMA_NV_EXP *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT64_Unmarshal(target, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (*target & TPMA_NV_EXP_reserved) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 229 - Definition of TPMS_NV_PUBLIC_EXP_ATTR Structure */\n\nTPM_RC\nTPMS_NV_PUBLIC_EXP_ATTR_Unmarshal(TPMS_NV_PUBLIC_EXP_ATTR *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_RH_NV_EXP_INDEX_Unmarshal(&target->nvIndex, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_ALG_HASH_Unmarshal(&target->nameAlg, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMA_NV_EXP_Unmarshal(&target->attributes, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_DIGEST_Unmarshal(&target->authPolicy, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->dataSize, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->dataSize > MAX_NV_INDEX_SIZE) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 230 - Definition of TPMU_NV_PUBLIC_2 Union */\n\nTPM_RC\nTPMU_NV_PUBLIC_2_Unmarshal( TPMU_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size, UINT8 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n      case TPM_HT_NV_INDEX:\n\trc = TPMS_NV_PUBLIC_Unmarshal(&target->nvIndex, buffer, size);\n\tbreak;\n      case TPM_HT_EXTERNAL_NV:\n\trc = TPMS_NV_PUBLIC_EXP_ATTR_Unmarshal(&target->externalNV, buffer, size);\n\tbreak;\n      case TPM_HT_PERMANENT_NV:\n\trc = TPMS_NV_PUBLIC_Unmarshal(&target->permanentNV, buffer, size);\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 231 - Definition of TPMT_NV_PUBLIC_2 Structure */\n\nTPM_RC\nTPMT_NV_PUBLIC_2_Unmarshal(TPMT_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT8_Unmarshal(&target->handleType, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_NV_PUBLIC_2_Unmarshal(&target->nvPublic2, buffer, size, target->handleType);\n    }\n    return rc;\n}\n\n/* Table 232 - Definition of TPM2B_NV_PUBLIC_2 Structure */\nTPM_RC\nTPM2B_NV_PUBLIC_2_Unmarshal(TPM2B_NV_PUBLIC_2 *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    INT32 startSize;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMT_NV_PUBLIC_2_Unmarshal(&target->nvPublic2, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n/* Table 199 - Definition of TPM2B_CONTEXT_SENSITIVE Structure <IN/OUT> */\n\nTPM_RC\nTPM2B_CONTEXT_SENSITIVE_Unmarshal(TPM2B_CONTEXT_SENSITIVE *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, MAX_CONTEXT_SIZE, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 201 - Definition of TPM2B_CONTEXT_DATA Structure <IN/OUT> */\n\nTPM_RC\nTPM2B_CONTEXT_DATA_Unmarshal(TPM2B_CONTEXT_DATA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_Unmarshal(&target->b, sizeof(TPMS_CONTEXT_DATA), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 202 - Definition of TPMS_CONTEXT Structure */\n\nTPM_RC\nTPMS_CONTEXT_Unmarshal(TPMS_CONTEXT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT64_Unmarshal(&target->sequence, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_DH_SAVED_Unmarshal(&target->savedHandle, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMI_RH_HIERARCHY_Unmarshal(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM2B_CONTEXT_DATA_Unmarshal(&target->contextBlob, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 225 - Definition of (UINT32) TPM_AT Constants */\n\nTPM_RC\nTPM_AT_Unmarshal(TPM_AT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT32_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTPMU_SET_CAPABILITIES_Unmarshal(TPMU_SET_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\nTPM_RC\nTPMS_SET_CAPABILITY_DATA_Unmarshal(TPMS_SET_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPM_CAP_Unmarshal(&target->setCapability, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMU_SET_CAPABILITIES_Unmarshal(&target->data, buffer, size, target->setCapability);\n    }\n    return rc;\n}\n\nTPM_RC\nTPM2B_SET_CAPABILITY_DATA_Unmarshal(TPM2B_SET_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    INT32 startSize;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = UINT16_Unmarshal(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TPMS_SET_CAPABILITY_DATA_Unmarshal(&target->setCapabilityData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/VendorInfo.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Introduction\n// Provide vendor-specific version and identifiers to core TPM library for\n// return in capabilities.  These may not be compile time constants and therefore\n// are provided by platform callbacks.  These platform functions are expected to\n// always be available, even in failure mode.\n//\n//** Includes\n#include \"Platform.h\"\n\n// In this sample platform, these are compile time constants, but are not required to be.\n#define MANUFACTURER    \"IBM \"\n#define VENDOR_STRING_1 \"SW  \"\n#define VENDOR_STRING_2 \" TPM\"\n#define VENDOR_STRING_3 \"\\0\\0\\0\\0\"\n#define VENDOR_STRING_4 \"\\0\\0\\0\\0\"\n#define FIRMWARE_V1     (0x20240125)\n#define FIRMWARE_V2     (0x00120000)\n#define MAX_SVN         255\n\nstatic uint32_t currentHash = FIRMWARE_V2;\nstatic uint16_t currentSvn  = 10;\n\n// Similar to the Core Library's ByteArrayToUint32, but usable in Platform code.\nstatic uint32_t StringToUint32(char s[4])\n{\n    uint8_t* b = (uint8_t*)s;  // Avoid promotion to a signed integer type\n    return (((uint32_t)b[0] << 8 | b[1]) << 8 | b[2]) << 8 | b[3];\n}\n\n// return the 4 character Manufacturer Capability code.  This\n// should come from the platform library since that is provided by the manufacturer\nLIB_EXPORT uint32_t _plat__GetManufacturerCapabilityCode()\n{\n    return StringToUint32(MANUFACTURER);\n}\n\n// return the 4 character VendorStrings for Capabilities.\n// Index is ONE-BASED, and may be in the range [1,4] inclusive.\n// Any other index returns all zeros. The return value will be interpreted\n// as an array of 4 ASCII characters (with no null terminator)\nLIB_EXPORT uint32_t _plat__GetVendorCapabilityCode(int index)\n{\n    switch(index)\n\t{\n\t  case 1:\n\t    return StringToUint32(VENDOR_STRING_1);\n\t  case 2:\n\t    return StringToUint32(VENDOR_STRING_2);\n\t  case 3:\n\t    return StringToUint32(VENDOR_STRING_3);\n\t  case 4:\n\t    return StringToUint32(VENDOR_STRING_4);\n\t}\n    return 0;\n}\n\n// return the most-significant 32-bits of the TPM Firmware Version reported by\n// getCapability.\nLIB_EXPORT uint32_t _plat__GetTpmFirmwareVersionHigh()\n{\n    return FIRMWARE_V1;\n}\n\n// return the least-significant 32-bits of the TPM Firmware Version reported by\n// getCapability.\nLIB_EXPORT uint32_t _plat__GetTpmFirmwareVersionLow()\n{\n    return FIRMWARE_V2;\n}\n\n// return the TPM Firmware SVN reported by getCapability.\nLIB_EXPORT uint16_t _plat__GetTpmFirmwareSvn(void)\n{\n    return currentSvn;\n}\n\n// return the TPM Firmware maximum SVN reported by getCapability.\nLIB_EXPORT uint16_t _plat__GetTpmFirmwareMaxSvn(void)\n{\n    return MAX_SVN;\n}\n\n// Called by the simulator to set the TPM Firmware SVN reported by\n// getCapability.\nLIB_EXPORT void _plat__SetTpmFirmwareHash(uint32_t hash)\n{\n    currentHash = hash;\n}\n\n// Called by the simulator to set the TPM Firmware SVN reported by\n// getCapability.\nLIB_EXPORT void _plat__SetTpmFirmwareSvn(uint16_t svn)\n{\n    currentSvn = MIN(svn, MAX_SVN);\n}\n\n#if SVN_LIMITED_SUPPORT\n// Dummy implmenentation for obtaining a Firmware SVN Secret bound\n// to the given SVN.\nLIB_EXPORT int _plat__GetTpmFirmwareSvnSecret(uint16_t  svn,\n\t\t\t\t\t      uint16_t  secret_buf_size,\n\t\t\t\t\t      uint8_t*  secret_buf,\n\t\t\t\t\t      uint16_t* secret_size)\n{\n    int i;\n\n    if(svn > currentSvn)\n\t{\n\t    return -1;\n\t}\n\n    // INSECURE dummy implementation: repeat the SVN into the secret buffer.\n    for(i = 0; i < secret_buf_size; ++i)\n\t{\n\t    secret_buf[i] = ((uint8_t*)&svn)[i % sizeof(svn)];\n\t}\n\n    *secret_size = secret_buf_size;\n\n    return 0;\n}\n#endif  // SVN_LIMITED_SUPPORT\n\n#if FW_LIMITED_SUPPORT\n// Dummy implmenentation for obtaining a Firmware Secret bound\n// to the current firmware image.\nLIB_EXPORT int _plat__GetTpmFirmwareSecret\n    (uint16_t secret_buf_size, uint8_t* secret_buf, uint16_t* secret_size)\n{\n    int i;\n\n    // INSECURE dummy implementation: repeat the firmware hash into the\n    // secret buffer.\n    for(i = 0; i < secret_buf_size; ++i)\n\t{\n\t    secret_buf[i] = ((uint8_t*)&currentHash)[i % sizeof(currentHash)];\n\t}\n\n    *secret_size = secret_buf_size;\n\n    return 0;\n}\n#endif  // FW_LIMITED_SUPPORT\n\n\t// return the TPM Type returned by TPM_PT_VENDOR_TPM_TYPE\nLIB_EXPORT uint32_t _plat__GetTpmType()\n{\n    return 1;  // just the value the reference code has returned in the past.\n}\n\n"
  },
  {
    "path": "ftpm-opensbi/src/Vendor_TCG_Test.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Vendor_TCG_Test.c 1548 2019-12-13 23:15:40Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2016\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n#include \"Tpm.h\"\n#include \"Vendor_TCG_Test_fp.h\"\n#include \"Marshal_fp.h\"\n#if CC_Vendor_TCG_Test\n/* A dummy function for testing. */\nTPM_RC\nTPM2_Vendor_TCG_Test(\n\t\t     Vendor_TCG_Test_In        *in,            // IN: input parameter list\n\t\t     Vendor_TCG_Test_Out       *out            // OUT: output parameter list\n\t\t     )\n{\n    out->outputData = in->inputData;\n    return TPM_RC_SUCCESS;\n}\n#endif // CC_Vendor_TCG_Test\n"
  },
  {
    "path": "ftpm-opensbi/src/X509_ECC.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM X509 ECC\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes\n#include \"Tpm.h\"\n#include \"X509.h\"\n#include \"OIDs.h\"\n#include \"TpmASN1_fp.h\"\n#include \"X509_ECC_fp.h\"\n#include \"X509_spt_fp.h\"\n#include \"CryptHash_fp.h\"\n\n//** Functions\n\n//*** X509PushPoint()\n// This seems like it might be used more than once so...\n//  Return Type: INT16\n//      > 0         number of bytes added\n//     == 0         failure\nINT16\nX509PushPoint(ASN1MarshalContext* ctx, TPMS_ECC_POINT* p)\n{\n    // Push a bit string containing the public key. For now, push the x, and y\n    // coordinates of the public point, bottom up\n    ASN1StartMarshalContext(ctx);  // BIT STRING\n    {\n\tASN1PushBytes(ctx, p->y.t.size, p->y.t.buffer);\n\tASN1PushBytes(ctx, p->x.t.size, p->x.t.buffer);\n\tASN1PushByte(ctx, 0x04);\n    }\n    return ASN1EndEncapsulation(ctx, ASN1_BITSTRING);  // Ends BIT STRING\n}\n\n//*** X509AddSigningAlgorithmECC()\n// This creates the singing algorithm data.\n//  Return Type: INT16\n//      > 0         number of bytes added\n//     == 0         failure\nINT16\nX509AddSigningAlgorithmECC(\n\t\t\t   OBJECT* signKey, TPMT_SIG_SCHEME* scheme, ASN1MarshalContext* ctx)\n{\n    PHASH_DEF hashDef = CryptGetHashDef(scheme->details.any.hashAlg);\n    //\n    NOT_REFERENCED(signKey);\n    // If the desired hashAlg definition wasn't found...\n    if(hashDef->hashAlg != scheme->details.any.hashAlg)\n\treturn 0;\n\n    switch(scheme->scheme)\n\t{\n#if ALG_ECDSA\n\t  case TPM_ALG_ECDSA:\n\t    // Make sure that we have an OID for this hash and ECC\n\t    if((hashDef->ECDSA)[0] != ASN1_OBJECT_IDENTIFIER)\n\t\tbreak;\n\t    // if this is just an implementation check, indicate that this\n\t    // combination is supported\n\t    if(!ctx)\n\t\treturn 1;\n\t    ASN1StartMarshalContext(ctx);\n\t    ASN1PushOID(ctx, hashDef->ECDSA);\n\t    return ASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE);\n#endif  //  ALG_ECDSA\n\t  default:\n\t    break;\n\t}\n    return 0;\n}\n\n//*** X509AddPublicECC()\n// This function will add the publicKey description to the DER data. If ctx is\n// NULL, then no data is transferred and this function will indicate if the TPM\n// has the values for DER-encoding of the public key.\n//  Return Type: INT16\n//      > 0         number of bytes added\n//     == 0         failure\nINT16\nX509AddPublicECC(OBJECT* object, ASN1MarshalContext* ctx)\n{\n    const BYTE* curveOid =\n\tCryptEccGetOID(object->publicArea.parameters.eccDetail.curveID);\n    if((curveOid == NULL) || (*curveOid != ASN1_OBJECT_IDENTIFIER))\n\treturn 0;\n    //\n    //\n    //  SEQUENCE (2 elem) 1st\n    //    SEQUENCE (2 elem) 2nd\n    //      OBJECT IDENTIFIER 1.2.840.10045.2.1 ecPublicKey (ANSI X9.62 public key type)\n    //      OBJECT IDENTIFIER 1.2.840.10045.3.1.7 prime256v1 (ANSI X9.62 named curve)\n    //    BIT STRING (520 bit) 000001001010000111010101010111001001101101000100000010...\n    //\n    // If this is a check to see if the key can be encoded, it can.\n    // Need to mark the end sequence\n    if(ctx == NULL)\n\treturn 1;\n    ASN1StartMarshalContext(ctx);  // SEQUENCE (2 elem) 1st\n    {\n\tX509PushPoint(ctx, &object->publicArea.unique.ecc);  // BIT STRING\n\tASN1StartMarshalContext(ctx);                        // SEQUENCE (2 elem) 2nd\n\t{\n\t    ASN1PushOID(ctx, curveOid);        // curve dependent\n\t    ASN1PushOID(ctx, OID_ECC_PUBLIC);  // (1.2.840.10045.2.1)\n\t}\n\tASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE);  // Ends SEQUENCE 2nd\n    }\n    return ASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE);  // Ends SEQUENCE 1st\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/X509_RSA.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM X509 RSA\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2023\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes\n#include \"Tpm.h\"\n#include \"X509.h\"\n#include \"TpmASN1_fp.h\"\n#include \"X509_RSA_fp.h\"\n#include \"X509_spt_fp.h\"\n#include \"CryptHash_fp.h\"\n#include \"CryptRsa_fp.h\"\n\n//** Functions\n\n#if ALG_RSA\n\n//*** X509AddSigningAlgorithmRSA()\n// This creates the singing algorithm data.\n//  Return Type: INT16\n//      > 0         number of bytes added\n//     == 0         failure\nINT16\nX509AddSigningAlgorithmRSA(\n\t\t\t   OBJECT* signKey, TPMT_SIG_SCHEME* scheme, ASN1MarshalContext* ctx)\n{\n    TPM_ALG_ID hashAlg = scheme->details.any.hashAlg;\n    PHASH_DEF  hashDef = CryptGetHashDef(hashAlg);\n    //\n    NOT_REFERENCED(signKey);\n    // return failure if hash isn't implemented\n    if(hashDef->hashAlg != hashAlg)\n\treturn 0;\n    switch(scheme->scheme)\n\t{\n\t  case TPM_ALG_RSASSA:\n\t      {\n\t\t  // if the hash is implemented but there is no PKCS1 OID defined\n\t\t  // then this is not a valid signing combination.\n\t\t  if(hashDef->PKCS1[0] != ASN1_OBJECT_IDENTIFIER)\n\t\t      break;\n\t\t  if(ctx == NULL)\n\t\t      return 1;\n\t\t  return X509PushAlgorithmIdentifierSequence(ctx, hashDef->PKCS1);\n\t      }\n\t  case TPM_ALG_RSAPSS:\n\t    // leave if this is just an implementation check\n\t    if(ctx == NULL)\n\t\treturn 1;\n\t    // In the case of SHA1, everything is default and RFC4055 says that\n\t    // implementations that do signature generation MUST omit the parameter\n\t    // when defaults are used. )-:\n\t    if(hashDef->hashAlg == TPM_ALG_SHA1)\n\t\t{\n\t\t    return X509PushAlgorithmIdentifierSequence(ctx, OID_RSAPSS);\n\t\t}\n\t    else\n\t\t{\n\t\t    // Going to build something that looks like:\n\t\t    //  SEQUENCE (2 elem)\n\t\t    //     OBJECT IDENTIFIER 1.2.840.113549.1.1.10 rsaPSS (PKCS #1)\n\t\t    //     SEQUENCE (3 elem)\n\t\t    //       [0] (1 elem)\n\t\t    //         SEQUENCE (2 elem)\n\t\t    //           OBJECT IDENTIFIER 2.16.840.1.101.3.4.2.1 sha-256\n\t\t    //           NULL\n\t\t    //       [1] (1 elem)\n\t\t    //         SEQUENCE (2 elem)\n\t\t    //           OBJECT IDENTIFIER 1.2.840.113549.1.1.8 pkcs1-MGF\n\t\t    //           SEQUENCE (2 elem)\n\t\t    //             OBJECT IDENTIFIER 2.16.840.1.101.3.4.2.1 sha-256\n\t\t    //             NULL\n\t\t    //       [2] (1 elem)  salt length\n\t\t    //         INTEGER 32\n\n\t\t    // The indentation is just to keep track of where we are in the\n\t\t    // structure\n\t\t    ASN1StartMarshalContext(ctx);  // SEQUENCE (2 elements)\n\t\t    {\n\t\t\tASN1StartMarshalContext(ctx);  // SEQUENCE (3 elements)\n\t\t\t{\n\t\t\t    // [2] (1 elem)  salt length\n\t\t\t    //    INTEGER 32\n\t\t\t    ASN1StartMarshalContext(ctx);\n\t\t\t    {\n\t\t\t\tINT16 saltSize = CryptRsaPssSaltSize(\n\t\t\t\t\t\t\t\t     (INT16)hashDef->digestSize,\n\t\t\t\t\t\t\t\t     (INT16)signKey->publicArea.unique.rsa.t.size);\n\t\t\t\tASN1PushUINT(ctx, saltSize);\n\t\t\t    }\n\t\t\t    ASN1EndEncapsulation(ctx, ASN1_APPLICAIION_SPECIFIC + 2);\n\n\t\t\t    // Add the mask generation algorithm\n\t\t\t    // [1] (1 elem)\n\t\t\t    //    SEQUENCE (2 elem) 1st\n\t\t\t    //      OBJECT IDENTIFIER 1.2.840.113549.1.1.8 pkcs1-MGF\n\t\t\t    //      SEQUENCE (2 elem) 2nd\n\t\t\t    //        OBJECT IDENTIFIER 2.16.840.1.101.3.4.2.1 sha-256\n\t\t\t    //        NULL\n\t\t\t    ASN1StartMarshalContext(ctx);  // mask context [1] (1 elem)\n\t\t\t    {\n\t\t\t\tASN1StartMarshalContext(ctx);  // SEQUENCE (2 elem) 1st\n\t\t\t\t// Handle the 2nd Sequence (sequence (object, null))\n\t\t\t\t{\n\t\t\t\t    // This adds a NULL, then an OID and a SEQUENCE\n\t\t\t\t    // wrapper.\n\t\t\t\t    X509PushAlgorithmIdentifierSequence(ctx,\n\t\t\t\t\t\t\t\t\thashDef->OID);\n\t\t\t\t    // add the pkcs1-MGF OID\n\t\t\t\t    ASN1PushOID(ctx, OID_MGF1);\n\t\t\t\t}\n\t\t\t\t// End outer sequence\n\t\t\t\tASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE);\n\t\t\t    }\n\t\t\t    // End the [1]\n\t\t\t    ASN1EndEncapsulation(ctx, ASN1_APPLICAIION_SPECIFIC + 1);\n\n\t\t\t    // Add the hash algorithm\n\t\t\t    // [0] (1 elem)\n\t\t\t    //   SEQUENCE (2 elem) (done by\n\t\t\t    //              X509PushAlgorithmIdentifierSequence)\n\t\t\t    //     OBJECT IDENTIFIER 2.16.840.1.101.3.4.2.1 sha-256 (NIST)\n\t\t\t    //     NULL\n\t\t\t    ASN1StartMarshalContext(ctx);  // [0] (1 elem)\n\t\t\t    {\n\t\t\t\tX509PushAlgorithmIdentifierSequence(ctx, hashDef->OID);\n\t\t\t    }\n\t\t\t    ASN1EndEncapsulation(ctx, (ASN1_APPLICAIION_SPECIFIC + 0));\n\t\t\t}\n\t\t\t//  SEQUENCE (3 elements) end\n\t\t\tASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE);\n\n\t\t\t// RSA PSS OID\n\t\t\t// OBJECT IDENTIFIER 1.2.840.113549.1.1.10 rsaPSS (PKCS #1)\n\t\t\tASN1PushOID(ctx, OID_RSAPSS);\n\t\t    }\n\t\t    // End Sequence (2 elements)\n\t\t    return ASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE);\n\t\t}\n\t  default:\n\t    break;\n\t}\n    return 0;\n}\n\n//*** X509AddPublicRSA()\n// This function will add the publicKey description to the DER data. If fillPtr is\n// NULL, then no data is transferred and this function will indicate if the TPM\n// has the values for DER-encoding of the public key.\n//  Return Type: INT16\n//      > 0         number of bytes added\n//     == 0         failure\nINT16\nX509AddPublicRSA(OBJECT* object, ASN1MarshalContext* ctx)\n{\n    UINT32 exp = object->publicArea.parameters.rsaDetail.exponent;\n    //\n    /*\n      SEQUENCE (2 elem) 1st\n      SEQUENCE (2 elem) 2nd\n      OBJECT IDENTIFIER 1.2.840.113549.1.1.1 rsaEncryption (PKCS #1)\n      NULL\n      BIT STRING (1 elem)\n      SEQUENCE (2 elem) 3rd\n      INTEGER (2048 bit) 2197304513741227955725834199357401\n      INTEGER 65537\n    */\n    // If this is a check to see if the key can be encoded, it can.\n    // Need to mark the end sequence\n    if(ctx == NULL)\n\treturn 1;\n    ASN1StartMarshalContext(ctx);  // SEQUENCE (2 elem) 1st\n    ASN1StartMarshalContext(ctx);  // BIT STRING\n    ASN1StartMarshalContext(ctx);  // SEQUENCE *(2 elem) 3rd\n\n    // Get public exponent in big-endian byte order.\n    if(exp == 0)\n\texp = RSA_DEFAULT_PUBLIC_EXPONENT;\n\n    // Push a 4 byte integer. This might get reduced if there are leading zeros or\n    // extended if the high order byte is negative.\n    ASN1PushUINT(ctx, exp);\n    // Push the public key as an integer\n    ASN1PushInteger(ctx,\n\t\t    object->publicArea.unique.rsa.t.size,\n\t\t    object->publicArea.unique.rsa.t.buffer);\n    // Embed this in a SEQUENCE tag and length in for the key, exponent sequence\n    ASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE);  // SEQUENCE (3rd)\n\n    // Embed this in a BIT STRING\n    ASN1EndEncapsulation(ctx, ASN1_BITSTRING);\n\n    // Now add the formatted SEQUENCE for the RSA public key OID. This is a\n    // fully constructed value so it doesn't need to have a context started\n    X509PushAlgorithmIdentifierSequence(ctx, OID_PKCS1_PUB);\n\n    return ASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE);\n}\n\n#endif  // ALG_RSA\n"
  },
  {
    "path": "ftpm-opensbi/src/X509_spt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tX509 Support\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG rants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2019 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n//** Includes\n#include \"Tpm.h\"\n#include \"TpmASN1.h\"\n#include \"TpmASN1_fp.h\"\n#define _X509_SPT_\n#include \"X509.h\"\n#include \"X509_spt_fp.h\"\n#if ALG_RSA\n#  include \"X509_RSA_fp.h\"\n#endif  // ALG_RSA\n#if ALG_ECC\n#  include \"X509_ECC_fp.h\"\n#endif  // ALG_ECC\n#if ALG_SM2\n//#   include \"X509_SM2_fp.h\"\n#endif  // ALG_RSA\n\n#if CC_CertifyX509\n\n//** Unmarshaling Functions\n\n//*** X509FindExtensionByOID()\n// This will search a list of X509 extensions to find an extension with the\n// requested OID. If the extension is found, the output context ('ctx') is set up\n// to point to the OID in the extension.\n//  Return Type: BOOL\n//      TRUE(1)         success\n//      FALSE(0)        failure (could be catastrophic)\nBOOL X509FindExtensionByOID(ASN1UnmarshalContext* ctxIn,  // IN: the context to search\n\t\t\t    ASN1UnmarshalContext* ctx,  // OUT: the extension context\n\t\t\t    const BYTE*           OID   // IN: oid to search for\n\t\t\t    )\n{\n    INT16 length;\n    //\n    pAssert(ctxIn != NULL);\n    // Make the search non-destructive of the input if ctx provided. Otherwise, use\n    // the provided context.\n    if(ctx == NULL)\n\tctx = ctxIn;\n    // if the provided search context is different from the context of the extension,\n    // then copy the search context to the search context.\n    else if(ctx != ctxIn)\n\t*ctx = *ctxIn;\n    // Now, search in the extension context\n    for(; ctx->size > ctx->offset; ctx->offset += length)\n\t{\n\t    GOTO_ERROR_UNLESS((length = ASN1NextTag(ctx)) >= 0);\n\t    // If this is not a constructed sequence, then it doesn't belong\n\t    // in the extensions.\n\t    GOTO_ERROR_UNLESS(ctx->tag == ASN1_CONSTRUCTED_SEQUENCE);\n\t    // Make sure that this entry could hold the OID\n\t    if(length >= OID_SIZE(OID))\n\t\t{\n\t\t    // See if this is a match for the provided object identifier.\n\t\t    if(MemoryEqual(OID, &(ctx->buffer[ctx->offset]), OID_SIZE(OID)))\n\t\t\t{\n\t\t\t    // Return with ' ctx' set to point to the start of the OID with the size\n\t\t\t    // set to be the size of the SEQUENCE\n\t\t\t    ctx->buffer += ctx->offset;\n\t\t\t    ctx->offset = 0;\n\t\t\t    ctx->size   = length;\n\t\t\t    return TRUE;\n\t\t\t}\n\t\t}\n\t}\n    GOTO_ERROR_UNLESS(ctx->offset == ctx->size);\n    return FALSE;\n Error:\n    ctxIn->size = -1;\n    ctx->size   = -1;\n    return FALSE;\n}\n\n//*** X509GetExtensionBits()\n// This function will extract a bit field from an extension. If the extension doesn't\n// contain a bit string, it will fail.\n// Return Type: BOOL\n//  TRUE(1)         success\n//  FALSE(0)        failure\nUINT32\nX509GetExtensionBits(ASN1UnmarshalContext* ctx, UINT32* value)\n{\n    INT16 length;\n    //\n    while(((length = ASN1NextTag(ctx)) > 0) && (ctx->size > ctx->offset))\n\t{\n\t    // Since this is an extension, the extension value will be in an OCTET STRING\n\t    if(ctx->tag == ASN1_OCTET_STRING)\n\t\t{\n\t\t    return ASN1GetBitStringValue(ctx, value);\n\t\t}\n\t    ctx->offset += length;\n\t}\n    ctx->size = -1;\n    return FALSE;\n}\n\n//***X509ProcessExtensions()\n// This function is used to process the TPMA_OBJECT and KeyUsage extensions. It is not\n// in the CertifyX509.c code because it makes the code harder to follow.\n// Return Type: TPM_RC\n//      TPM_RCS_ATTRIBUTES      the attributes of object are not consistent with\n//                              the extension setting\n//      TPM_RC_VALUE            problem parsing the extensions\nTPM_RC\nX509ProcessExtensions(\n\t\t      OBJECT* object,       // IN: The object with the attributes to\n\t\t      //      check\n\t\t      stringRef* extension  // IN: The start and length of the extensions\n\t\t      )\n{\n    ASN1UnmarshalContext ctx;\n    ASN1UnmarshalContext extensionCtx;\n    INT16                length;\n    UINT32               value;\n    TPMA_OBJECT          attributes = object->publicArea.objectAttributes;\n    //\n    if(!ASN1UnmarshalContextInitialize(&ctx, extension->len, extension->buf)\n       || ((length = ASN1NextTag(&ctx)) < 0) || (ctx.tag != X509_EXTENSIONS))\n\treturn TPM_RCS_VALUE;\n    if(((length = ASN1NextTag(&ctx)) < 0) || (ctx.tag != (ASN1_CONSTRUCTED_SEQUENCE)))\n\treturn TPM_RCS_VALUE;\n\n    // Get the extension for the TPMA_OBJECT if there is one\n    if(X509FindExtensionByOID(&ctx, &extensionCtx, OID_TCG_TPMA_OBJECT)\n       && X509GetExtensionBits(&extensionCtx, &value))\n\t{\n\t    // If an keyAttributes extension was found, it must be exactly the same as the\n\t    // attributes of the object.\n\t    // NOTE: MemoryEqual() is used rather than a simple UINT32 compare to avoid\n\t    // type-punned pointer warning/error.\n\t    if(!MemoryEqual(&value, &attributes, sizeof(value)))\n\t\treturn TPM_RCS_ATTRIBUTES;\n\t}\n    // Make sure the failure to find the value wasn't because of a fatal error\n    else if(extensionCtx.size < 0)\n\treturn TPM_RCS_VALUE;\n\n    // Get the keyUsage extension. This one is required\n    if(X509FindExtensionByOID(&ctx, &extensionCtx, OID_KEY_USAGE_EXTENSION)\n       && X509GetExtensionBits(&extensionCtx, &value))\n\t{\n\t    x509KeyUsageUnion keyUsage;\n\t    BOOL              badSign;\n\t    BOOL              badDecrypt;\n\t    BOOL              badFixedTPM;\n\t    BOOL              badRestricted;\n\n\t    //\n\t    keyUsage.integer = value;\n\t    // see if any reserved bits are set\n\t    if(keyUsage.integer & ~(TPMA_X509_KEY_USAGE_ALLOWED_BITS))\n\t\treturn TPM_RCS_RESERVED_BITS;\t    // For KeyUsage:\n\t    // 1) 'sign' is SET if Key Usage includes signing\n\t    badSign = ((KEY_USAGE_SIGN.integer & keyUsage.integer) != 0)\n\t\t      && !IS_ATTRIBUTE(attributes, TPMA_OBJECT, sign);\n\t    // 2) 'decrypt' is SET if Key Usage includes decryption uses\n\t    badDecrypt = ((KEY_USAGE_DECRYPT.integer & keyUsage.integer) != 0)\n\t\t\t && !IS_ATTRIBUTE(attributes, TPMA_OBJECT, decrypt);\n\t    // 3) 'fixedTPM' is SET if Key Usage is non-repudiation\n\t    badFixedTPM = IS_ATTRIBUTE(keyUsage.x509, TPMA_X509_KEY_USAGE, nonrepudiation)\n\t\t\t  && !IS_ATTRIBUTE(attributes, TPMA_OBJECT, fixedTPM);\n\t    // 4)'restricted' is SET if Key Usage is for key encipherment.\n\t    badRestricted =\n\t\tIS_ATTRIBUTE(keyUsage.x509, TPMA_X509_KEY_USAGE, keyEncipherment)\n\t\t&& !IS_ATTRIBUTE(attributes, TPMA_OBJECT, restricted);\n\t    if(badSign || badDecrypt || badFixedTPM || badRestricted)\n\t\treturn TPM_RCS_VALUE;\n\t}\n    else\n\t// The KeyUsage extension is required\n\treturn TPM_RCS_VALUE;\n\n    return TPM_RC_SUCCESS;\n}\n\n//** Marshaling Functions\n\n//*** X509AddSigningAlgorithm()\n// This creates the singing algorithm data.\n// Return Type: INT16\n//  > 0                 number of octets added\n// <= 0                 failure\nINT16\nX509AddSigningAlgorithm(\n\t\t\tASN1MarshalContext* ctx, OBJECT* signKey, TPMT_SIG_SCHEME* scheme)\n{\n    switch(signKey->publicArea.type)\n\t{\n#  if ALG_RSA\n\t  case TPM_ALG_RSA:\n\t    return X509AddSigningAlgorithmRSA(signKey, scheme, ctx);\n#  endif  // ALG_RSA\n#  if ALG_ECC\n\t  case TPM_ALG_ECC:\n\t    return X509AddSigningAlgorithmECC(signKey, scheme, ctx);\n#  endif  // ALG_ECC\n#  if ALG_SM2\n\t  case TPM_ALG_SM2:\n\t    break;  // no signing algorithm for SM2 yet\n\t    //            return X509AddSigningAlgorithmSM2(signKey, scheme, ctx);\n#  endif  // ALG_SM2\n\t  default:\n\t    break;\n\t}\n    return 0;\n}\n\n//*** X509AddPublicKey()\n// This function will add the publicKey description to the DER data. If fillPtr is\n// NULL, then no data is transferred and this function will indicate if the TPM\n// has the values for DER-encoding of the public key.\n//  Return Type: INT16\n//      > 0         number of octets added\n//      == 0        failure\nINT16\nX509AddPublicKey(ASN1MarshalContext* ctx, OBJECT* object)\n{\n    switch(object->publicArea.type)\n\t{\n#  if ALG_RSA\n\t  case TPM_ALG_RSA:\n\t    return X509AddPublicRSA(object, ctx);\n#  endif\n#  if ALG_ECC\n\t  case TPM_ALG_ECC:\n\t    return X509AddPublicECC(object, ctx);\n#  endif\n#  if ALG_SM2\n\t  case TPM_ALG_SM2:\n\t    break;\n#  endif\n\t  default:\n\t    break;\n\t}\n    return FALSE;\n}\n\n//*** X509PushAlgorithmIdentifierSequence()\n// The function adds the algorithm identifier sequence.\n//  Return Type: INT16\n//      > 0         number of bytes added\n//     == 0         failure\nINT16\nX509PushAlgorithmIdentifierSequence(ASN1MarshalContext* ctx, const BYTE* OID)\n{\n    // An algorithm ID sequence is:\n    //  SEQUENCE\n    //      OID\n    //      NULL\n    ASN1StartMarshalContext(ctx);  // hash algorithm\n    ASN1PushNull(ctx);\n    ASN1PushOID(ctx, OID);\n    return ASN1EndEncapsulation(ctx, ASN1_CONSTRUCTED_SEQUENCE);\n}\n\n#endif  // CC_CertifyX509\n"
  },
  {
    "path": "ftpm-opensbi/src/ftpm-sbi-opensbi.c",
    "content": "#include <sbi/sbi_trap.h>\n#include <sbi/sbi_error.h>\n#include <sbi/sbi_tlb.h>\n#include <sbi/sbi_ipi.h>\n#include <sbi/sbi_string.h>\n#include <sbi/riscv_locks.h>\n#include <sbi/sbi_console.h>\n#include <sbi/sbi_scratch.h>\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_ecall.h>\n// #include \"sm-sbi-opensbi.h\"\n// #include \"pmp.h\"\n// #include \"sm-sbi.h\"\n// #include \"sm.h\"\n// #include \"cpu.h\"\n\n#include \"ftpm.h\"\n\n#define SBI_EXT_EXPERIMENTAL_FTPM 0x08424b45\n#define SBI_FTPM_RUN_COMMAND    2001\n\n\nstatic int sbi_ecall_ftpm_handler(unsigned long extid, unsigned long funcid,\n\t\t\t\t const struct sbi_trap_regs *regs,\n\t\t\t\t unsigned long *out_val,\n\t\t\t\t struct sbi_trap_info *out_trap)\n{\n  uintptr_t ret;\n\n  // sbi_printf(\"[SM] TPM sbi_ecall_ftpm_handler()!!!\\n\");\n\n  switch (funcid) {\n    case SBI_FTPM_RUN_COMMAND:\n      // ret = sbi_ftpm_run_command(&out->value, regs->a0);\n      ret = sbi_ftpm_run_command(0, regs->a0);\n      break;\n    \n    default:\n      ret = SBI_ENOTSUPP;\n      break;\n  }\n\n  return ret;\n}\n\nstruct sbi_ecall_extension ecall_ftpm = {\n  .extid_start = SBI_EXT_EXPERIMENTAL_FTPM,\n  .extid_end = SBI_EXT_EXPERIMENTAL_FTPM,\n  .handle = sbi_ecall_ftpm_handler,\n};\n"
  },
  {
    "path": "ftpm-opensbi/src/ftpm.c",
    "content": "#include <sbi/sbi_console.h>\n#include <sbi/sbi_ecall.h>\n#include <sbi/riscv_encoding.h>\n#include <sbi/riscv_asm.h>\n#include <sbi/sbi_hart.h>\n#include <unistd.h>\n#include <stdint.h>\n#include <stdbool.h>\n#include \"string.h\"\n#include <stdlib.h>\n#include \"TpmTcpProtocol.h\"\n#include \"simulatorPrivate.h\"\n#include \"ftpm.h\"\n#include \"mprv.h\"\n\n#include \"intercept.h\"\n#include \"fatfs/ff.h\"\n#include \"fatfs/diskio.h\"\n\n#include \"openssl/aes.h\"\n#include \"openssl/rand.h\"\n\n\n// #define MAX_BUFFER 1048576\n#define MAX_BUFFER 81920\n\nchar InputBuffer[MAX_BUFFER];       //The input data buffer for the simulator.\nchar OutputBuffer[MAX_BUFFER];  \n\n// fs\nFATFS fatfs __attribute__((section(\".bss\")));\nextern int errno;\n\n// aes\nunsigned char nv_key[128] = \"fbcca5ebfc38658e48251d72e9fa5f56\";\nunsigned char nv_iv[128] = \"623e7aa9a2aa92a8ff80fc977462dcc5\";\n\nAES_KEY nv_enc_key, nv_dec_key;\n\n// heap\nextern char _heap_start;\nextern char _heap_end;\nstatic char *heap_ptr = &_heap_start;\n\nextern struct sbi_ecall_extension ecall_ftpm;\n\nstatic inline unsigned long copy_to_ftpm(void* dst, uintptr_t src, size_t len) {\n    int region_overlap = copy_to_sm(dst, src, len);\n    if (region_overlap)\n    {\n        sbi_printf(\"[FTPM] !!!ERROR!!! in copy_to_ftpm()\\n\");\n    }\n    \n    if (region_overlap)\n        return -1;\n    else\n        return 0;\n}\n\nstatic inline unsigned long copy_from_ftpm(uintptr_t dst, void* src, size_t len) {\n    int region_overlap = copy_from_sm(dst, src, len);\n    if (region_overlap)\n    {\n        sbi_printf(\"[FTPM] !!!ERROR!!! in copy_from_ftpm()\\n\");\n    }\n    \n    if (region_overlap)\n        return -1;\n    else\n        return 0;\n}\n\n\nint ftpm_cmd_handler(struct tss_ftpm_context* cnx) {\n\n    uint32_t \t\t length;\n    uint8_t \t\t locality;\n    _IN_BUFFER           InBuffer;\n    _OUT_BUFFER          OutBuffer;\n\n    locality = 0;\n    length = cnx->written;\n//   length = cmd->length;\n//   memcpy(InputBuffer, cmd->buffer, length);\n    csr_set(CSR_MSTATUS, MSTATUS_SUM);\n    copy_to_ftpm((void*)InputBuffer, cnx->commandBuffer, length);\n\n\tInBuffer.Buffer = (uint8_t *) InputBuffer;\n\tInBuffer.BufferSize = length;\n\tOutBuffer.BufferSize = MAX_BUFFER;\n\tOutBuffer.Buffer = (_OUTPUT_BUFFER) OutputBuffer;\n\n  // umode_printf(\"[RTPM] rtpm_cmd_handler(): in_buffer_size=%lx\\n\", InBuffer.BufferSize);\n  // for (size_t i = 0; i < InBuffer.BufferSize; i++)\n  // {\n  //   umode_printf(\"[RTPM] rtpm_cmd_handler(): in_buffer[%lx]=%x\\n\", i, InBuffer.Buffer[i]);\n  // }\n  \n\n\t_rpc__Send_Command(locality, InBuffer, &OutBuffer);\n\n//   cmd->length = OutBuffer.BufferSize;\n//   memcpy(cmd->buffer, OutBuffer.Buffer, OutBuffer.BufferSize);\n    cnx->read = OutBuffer.BufferSize;\n    copy_from_ftpm(cnx->responseBuffer, OutBuffer.Buffer, OutBuffer.BufferSize);\n\n\n    // sbi_printf(\"[RTPM] rtpm_cmd_handler(): out_buffer_size=%x\\n\", OutBuffer.BufferSize);\n    // for (size_t i = 0; i < OutBuffer.BufferSize; i++)\n    // {\n    //     sbi_printf(\"[RTPM] rtpm_cmd_handler(): out_buffer[%lx]=%x\\n\", i, OutBuffer.Buffer[i]);\n    // }\n\n    csr_clear(CSR_MSTATUS, MSTATUS_SUM);\n\n    return 0;\n}\n\n\nunsigned long sbi_ftpm_run_command(unsigned long out, uintptr_t cnx) {\n\n    struct tss_ftpm_context local_cnx;\n    unsigned long ret;\n\n    ret = copy_to_ftpm(&local_cnx, cnx, sizeof(struct tss_ftpm_context));\n    if (ret)\n        return ret;\n\n    ftpm_cmd_handler(&local_cnx);\n\n    ret = copy_from_ftpm(cnx, &local_cnx, sizeof(struct tss_ftpm_context));\n    if (ret)\n        return ret;\n\n    return ret;\n}\n\n// heap\nvoid* _sbrk(ptrdiff_t incr) {\n    char *prev_heap_ptr = heap_ptr;\n    if (heap_ptr + incr > &_heap_end) {\n        // 堆内存溢出\n        sbi_printf(\"[FTPM] !!!HEAP OVERFLOW!!!\\n\");\n        sbi_hart_hang();\n        return (void*)-1;\n    }\n    heap_ptr += incr;\n    return (void*)prev_heap_ptr;\n}\n\n// aes-cbc\nvoid aes_cbc_encrypt_decrypt(AES_KEY *key, unsigned char *input, unsigned char *output,\n                             unsigned char *iv, size_t len, int encrypt) {\n\n    unsigned char iv_copy[AES_BLOCK_SIZE];\n    memcpy(iv_copy, iv, AES_BLOCK_SIZE);\n\n    if (encrypt) {\n        AES_cbc_encrypt(input, output, len, key, iv_copy, AES_ENCRYPT);\n    } else {\n        AES_cbc_encrypt(input, output, len, key, iv_copy, AES_DECRYPT);\n    }\n}\n\n\nstatic int aes_test() {\n\n    sbi_printf(\"[fTPM] test AES!!!\\n\");\n\n    unsigned char plaintext[32] = \"Hello, this is a test message!\";\n    unsigned char ciphertext[sizeof(plaintext)];\n    unsigned char decryptedtext[sizeof(plaintext)];\n\n    int len = sizeof(plaintext);\n\n    aes_cbc_encrypt_decrypt(&nv_enc_key, plaintext, ciphertext, nv_iv, len, 1);\n\n    sbi_printf(\"Ciphertext:\\n\");\n    for (int i = 0; i < len; i++) {\n        sbi_printf(\"%02x\", ciphertext[i]);\n    }\n    sbi_printf(\"\\n\");\n\n    aes_cbc_encrypt_decrypt(&nv_dec_key, ciphertext, decryptedtext, nv_iv, len, 0);\n\n    sbi_printf(\"Decrypted text: %s\\n\", decryptedtext);\n\n    return 0;\n}\n\n\n// #if defined(PLATFORM_TYPE) && (PLATFORM_TYPE == 2)\n\n\n// const char * errno_to_str(void);\n\n// char tmp[100] = \"\";\n// char nvram[32768] = \"hello\";\n\n// void nvtest(void) {\n//     // unsigned char nvram[512];\n//     // unsigned char hello[16] = \"hello, jay.\";\n\n\n\n//     // disk_initialize(0);\n\n//     // // if(disk_read(0, nvram, 2050, 1) != RES_OK) sbi_printf(\"nvtest(): sector_read(0) %s\\n\", errno_to_str());\n//     // // for (size_t i = 0; i < 512; i++)\n//     // // {\n//     // //     sbi_printf(\"[nvtest] s[0][%lx]: %x\\n\", i, nvram[i]);\n//     // // }\n\n//     // // if(disk_read(0, nvram, 62333777, 1) != RES_OK) sbi_printf(\"nvtest(): sector_read(62333777) %s\\n\", errno_to_str());\n//     // // for (size_t i = 0; i < 16; i++)\n//     // // {\n//     // //     sbi_printf(\"[nvtest] s[62333777][%lx]: %x\\n\", i, nvram[i]);\n//     // // }\n\n//     // if(disk_write(0, hello, 62330000, 4) != RES_OK) sbi_printf(\"nvtest(): sector_write(62330000) %s\\n\", errno_to_str());\n\n//     // if(disk_read(0, nvram, 62330000, 4) != RES_OK) sbi_printf(\"nvtest(): sector_read(62330000) %s\\n\", errno_to_str());\n//     // for (size_t i = 0; i < 16; i++)\n//     // {\n//     //     sbi_printf(\"[nvtest] s[62330000][%lx]: %c\\n\", i, nvram[i]);\n//     // } \n\n// ///////////////////////////////////////////////////////////////////////////////////////////////////////\n    \n//     FILE* nvtest = fopen(\"nvram.bin\", FA_CREATE_ALWAYS | FA_READ | FA_WRITE);\n\n//     // FIL nv;\n//     // FIL* nvtest = &nv;\n//     // errno = f_open((FIL*)nvtest, \"nvram.bin\", FA_CREATE_ALWAYS | FA_READ | FA_WRITE);\n//     // if (errno) sbi_printf(\"Cannot access SD: %s\\n\", errno_to_str());\n\n\n//     UINT bw = fwrite(nvram, 1, NV_MEMORY_SIZE, nvtest);\n//     // UINT bw = fwrite(nvram, 1, 20, nvtest);\n//     // UINT bw;\n//     // f_write((FIL*)nvtest, nvram, 32768, &bw);\n//     sbi_printf(\"[NVTEST] write nvram: bw=%x\\n\", bw);\n\n//     // f_sync((FIL*)nvtest);\n//     frewind(nvtest);\n\n//     fclose(nvtest);\n\n//     //errno = f_open((FIL*)nvtest, \"nvram.bin\", FA_READ | FA_WRITE);\n//     //if (errno) sbi_printf(\"Cannot access SD: %s\\n\", errno_to_str());\n//     nvtest = fopen(\"nvram.bin\", FA_READ | FA_WRITE);\n\n//     UINT sz = fsize(nvtest);\n\n//     UINT br;\n//     br = fread(tmp, 1, 32, nvtest);\n//     // f_read((FIL*)nvtest, tmp, 32, &br);\n//     sbi_printf(\"[NVTEST] read nvram: br=%x, size=%x\\n\", br, sz);\n\n//     sbi_printf(\"[NVTEST] nvram=%s\\n\", tmp);\n\n//     fclose(nvtest);\n\n// }\n// #endif\n\nstatic inline uint64_t read_cycle() {\n    uint64_t cycle;\n    asm volatile (\"rdcycle %0\" : \"=r\"(cycle));\n    return cycle;\n}\n\nvoid ftpm_init(void) {\n\n    if (AES_set_encrypt_key(nv_key, 128, &nv_enc_key) < 0 \n                    || AES_set_decrypt_key(nv_key, 128, &nv_dec_key) < 0) {\n        sbi_printf(\"[fTPM] ftpm_init(): set aes key failed!!!\\n\");\n    }\n\n    // if (AES_set_decrypt_key(nv_key, 128, &nv_dec_key) < 0) {\n    //     sbi_printf(\"AES_set_decrypt_key failed\\n\");\n    // }\n\n    // aes_test();\n\n#if defined(PLATFORM_TYPE) && (PLATFORM_TYPE == 1)\n    sbi_printf(\"[fTPM] ftpm_init(): virt!!!\\n\");\n    _plat__NVEnable(NULL, 0);\n    TPM_Manufacture(1);\n    _plat__NVDisable((void*)FALSE, 0);\n\n#elif defined(PLATFORM_TYPE) && (PLATFORM_TYPE == 2)\n    sbi_printf(\"[fTPM] ftpm_init(): vivado!!!\\n\");\n\n    disk_initialize(0);\n    errno = f_mount(&fatfs, \"\", 1);\n    if (errno) {\n        sbi_printf(\"[fTPM] ftpm_init(): Cannot mount SD: %s\\n\", errno_to_str());\n    }\n\n\tuint64_t begin_cycle = read_cycle();\n    _plat__NVEnable(NULL, 0);\n\tuint64_t end_cycle = read_cycle();\n\tsbi_printf(\"[BENCH] _plat__NVEnable(): cycle=%lu\\n\", end_cycle - begin_cycle);\n\n    if(_plat__NVNeedsManufacture()) {\n        sbi_printf(\"[fTPM] Manufacturing NV state...\\n\");\n\t    if(TPM_Manufacture(1) != 0)\n\t\t{\n\t\t    // if the manufacture didn't work, then make sure that the NV file doesn't\n\t\t    // survive. This prevents manufacturing failures from being ignored the\n\t\t    // next time the code is run.\n\t\t    _plat__NVDisable((void*)TRUE, 0);\n            sbi_printf(\"[fTPM] TPM_Manufacture(1) != 0!!!\\n\");\n\t\t    //exit(1);\n\t\t}\n    }\n    _plat__NVDisable((void*)FALSE, 0);\n#else\n    sbi_printf(\"[fTPM] ftpm_init(): unsupported platform!!!\\n\");\n#endif\n\n    _rpc__Signal_PowerOn(FALSE);\n    _rpc__Signal_NvOn();\n    sbi_printf(\"[fTPM] ftpm_init(): finished!!!\\n\");\n\n    sbi_ecall_register_extension(&ecall_ftpm);\n}"
  },
  {
    "path": "ftpm-opensbi/src/intercept.c",
    "content": "// #include <time.h>\n// #include <stdio.h>\n#include <stdint.h>\n#include <sbi/sbi_console.h>\n#include \"intercept.h\"\n\n#define RISC_V\n\nint intercept_clock_gettime (clockid_t __clock_id, struct timespec *__tp) {\n    uint32_t hi, lo;\n  #ifdef RISC_V\n    uint64_t cycles;\n    asm volatile (\"rdcycle %0\" : \"=r\" (cycles));\n    hi = cycles >> 32;\n    lo = cycles;\n  #else\n    __asm__ __volatile__ (\"rdtsc\" : \"=a\"(lo), \"=d\"(hi));\n  #endif\n   __tp->tv_sec = hi;\n   __tp->tv_nsec = lo;\n   return 1;\n}\n\n\nint intercept_rand(void) {\n  static uint64_t w = 0, s = 0xb5ad4eceda1ce2a9;\n  unsigned long cycles;\n  asm volatile (\"rdcycle %0\" : \"=r\" (cycles));\n  uint64_t x = cycles;\n  x *= x;\n  x += (w += s);\n\n  return (int)((x>>32) | (x<<32));\n}\n\n#if defined(PLATFORM_TYPE) && (PLATFORM_TYPE == 2)\n\nconst char * errno_to_str(void);\n\n// static int errno __attribute__((section(\".bss\")));\n\nextern int errno;\n\n// static FIL nvram_fd;\nFIL nvram_fd;\n\nFILE *intercept_fopen(const char *pathname, BYTE mode) {\n  errno = f_open(&nvram_fd, pathname, mode);\n  //if (errno) sbi_printf(\"Cannot access SD: %s\\n\", errno_to_str());\n  if (errno) return NULL;\n  //sbi_printf(\"[debug] intercept_fopen(): pathname=%s, mode=%x, &nvram_fd=%p\\n\", pathname, mode, (void*)&nvram_fd);\n  return (FILE*)&nvram_fd;\n}\n\nsize_t intercept_fread(void *ptr, size_t size, size_t count, FILE *stream) {\n\n  UINT rd;\n  errno = f_read((FIL*)stream, ptr, count*size, &rd);\n  //if (errno) sbi_printf(\"Cannot access SD: %s\\n\", errno_to_str());\n  if (errno) return -1;\n  //sbi_printf(\"[debug] intercept_fread(): &nvram_fd=%p, ptr=%p, btr=%lx, rd=%x\\n\", (void*)stream, ptr, size*count, rd);\n  return rd;\n}\n\nsize_t intercept_fwrite(const void *ptr, size_t size, size_t count, FILE *stream) {\n\n  UINT bw;\n  errno = f_write((FIL*)stream, ptr, count*size, &bw);\n  //if (errno) sbi_printf(\"intercept_fwrite(): %s\\n\", errno_to_str());\n  if (errno) return -1;\n  // errno = f_sync((FIL*)stream);\n  // if (errno) sbi_printf(\"intercept_fwrite2(): %s\\n\", errno_to_str());\n  //sbi_printf(\"[debug] intercept_fwrite(): &nvram_fd=%p, ptr=%p, btw=%lx, bw=%x\\n\", (void*)stream, ptr, count*size, bw);\n  // sbi_printf(\"[debug] intercept_fwrite(): f_size=%x\\n\", f_size((FIL*)stream));\n  return bw;\n}\n\nint intercept_fclose(FILE *stream) {\n  //sbi_printf(\"[debug] intercept_fclose()\\n\");\n  return f_close((FIL*)stream);\n}\n\nint intercept_frewind(FILE *stream) {\n  //sbi_printf(\"[debug] intercept_frewind()\\n\");\n  return f_rewind((FIL*)stream);\n}\n\nlong intercept_fsize(FILE *stream) {\n  //sbi_printf(\"[debug] intercept_fsize()\\n\");\n  return f_size((FIL*)stream);\n}\n\nlong intercept_ftell(FILE *stream) {\n  //sbi_printf(\"[debug] intercept_ftell()\\n\");\n  return f_tell((FIL*)stream);\n}\n\nint intercept_fflush(FILE *stream) {\n  //sbi_printf(\"[debug] intercept_fflush()\\n\");\n  // errno = f_sync((FIL*)stream);\n  // if (errno) sbi_printf(\"Cannot access SD: %s\\n\", errno_to_str());\n  // if (errno) return -1;\n  return 0;\n}\n\n#endif"
  },
  {
    "path": "ftpm-opensbi/src/makefile.mac",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\t\tMac TPM2 Makefile\t\t\t\t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t      $Id: makefile.mac 1101 2017-11-28 23:00:09Z kgoldman $\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2017\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n\nCC = /usr/bin/gcc\n\nCCFLAGS =\t\t\t\t\\\n\t-Wmissing-prototypes -Wnested-externs \\\n\t-Wsign-compare -Wno-self-assign\t\\\n\t -c -ggdb -O0 \t\t\t\\\n\t-DTPM_POSIX\t\t\t\\\n\t-D_POSIX_\t\t\t\\\n\t-I../utils\t\t\t\\\n\t-I.\t\t\t\t\\\n\t-I/usr/local/Cellar/openssl/1.0.2m/include/\n\n# another user suggested \n#\t-I/opt/local/include\t\t\\\n\nLNFLAGS = -ggdb \t\t\t\\\n\t-DTPM_POSIX\t\t\t\\\n\t-lcrypto\t\t\t\\\n\t-lpthread\t\t\t\\\n\t-L/usr/local/Cellar/openssl/1.0.2m/lib\t\\\n\t-I.\n\nall:\ttpm_server\n\nCRYPTO_SUBSYSTEM = openssl\n\ninclude makefile-common\n\nOBJFILES += TcpServerPosix.o\n\nTcpServerPosix.o\t: $(HEADERS)\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\ntpm_server:\t$(OBJFILES)\n\t\t$(CC) $(OBJFILES) $(LNFLAGS) -o tpm_server\n\nclean:\t\t\n\t\trm -f *.o tpm_server *~\n\n%.o:\t\t%.c\n\t\t$(CC) $(CCFLAGS) $< -o $@\n\n"
  },
  {
    "path": "ftpm-opensbi/src/makefile.mak",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\tWindows MinGW TPM2 Makefile OpenSSL 64-bit\t\t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2014 - 2023\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n\n# Windows OpenSSL 3.1 64-bit with mingw64\n\nCC = \"c:/program files/mingw/bin/gcc.exe\"\n\nCCFLAGS = -Wall  \t\t\t\t\\\n\t-ggdb -O0 -c -Wnested-externs\t\t\\\n\t-Wno-deprecated-declarations\t\t\\\n\t-DTPM_WINDOWS -D_NO_OLDNAMES -D_MINGW\t\\\n\t-D_ISOC99_SOURCE -D_WIN32_WINNT=0x0603\t\\\n\t-I\"c:/program files/MinGW/include\"\t\\\n\t-I\"c:/program files/openssl/include\"\t\\\n\t-I.\t\t\t\t\t\\\n\t-DTPM_NUVOTON\n\nLNFLAGS = -D_MT\t\t\t\t\t\\\n\t-DTPM_WINDOWS\t\t\t\t\\\n\t-I.\t\t\t\t\t\\\n\t-ggdb \t\t\t\t\t\\\n\t-L.\n\n# Shining Light OpenSSL 3.1 64-bit\n\nLNLIBS =  \t\"c:/program files/openssl/bin/libcrypto-3-x64.dll\" -lws2_32\n\nall:\ttpm_server.exe\n\nCRYPTO_SUBSYSTEM = openssl\ninclude makefile-common\n\nOBJFILES += TcpServer.o\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\ntpm_server.exe:\t$(OBJFILES) applink.o\n\t\t$(CC) $(LNFLAGS) $(OBJFILES) -o tpm_server.exe applink.o $(LNLIBS)\n\nclean:\n\t\trm *.o *.exe\n\n%.o:\t\t%.c\n\t\t$(CC) $(CCFLAGS) $< -o $@\n\n"
  },
  {
    "path": "ftpm-opensbi/src/makefile11",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\t\tLinux gcc TPM2 Makefile for Local OpenSSL \t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2015 - 2022\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n\nCC = /usr/bin/gcc\n\nCCFLAGS = -Wall  \t\t\t\\\n\t-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \\\n\t-Werror -Wsign-compare \\\n\t -c -ggdb -O0 \t\t\t\\\n\t-DTPM_POSIX -Wno-deprecated-declarations\t\t\t\\\n\t-D_POSIX_\t\t\t\\\n\t-DTPM_NUVOTON\n\n# example of pointing to a locally built openssl\nCCFLAGS += \t-I/home/openssl/include\n\nLNFLAGS = -ggdb \t\t\t\\\n\t-lcrypto\t\t\t\\\n\t-lpthread\t\t\t\\\n\t-lrt\t\t\t\t\\\n\t-I.\n\n# example of pointing to a locally built openssl\nLNFLAGS +=\t -L/home/openssl\n\n# This also requires setting the environment variable LD_LIBRARY_PATH.  E.g.,\n# setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/openssl\n\nall:\ttpm_server\n\ninclude makefile-common\n\nOBJFILES += TcpServerPosix.o\n\nTcpServerPosix.o\t: $(HEADERS)\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\ntpm_server:\t$(OBJFILES)\n\t\t$(CC) $(OBJFILES) $(LNFLAGS) -o tpm_server\n\nclean:\n\t\trm -f *.o tpm_server *~\n\n%.o:\t\t%.c\n\t\t$(CC) $(CCFLAGS) $< -o $@\n\n"
  },
  {
    "path": "ftpm-opensbi/src/mprv.S",
    "content": "#if __riscv_xlen == 64\n# define STORE    sd\n# define LOAD     ld\n# define LOG_REGBYTES 3\n#elif __riscv_xlen == 32\n# define STORE    sw\n# define LOAD     lw\n# define LOG_REGBYTES 2\n#endif\n\n#define REGBYTES (1 << LOG_REGBYTES)\n\n.text\n\n#define TRY(tryname, r_mtvec, r_mepc, r_mcause, r_mstatus) \\\n    la r_mtvec, tryname##_err     ;\\\n    csrrw r_mtvec, mtvec, r_mtvec ;\\\n    csrr r_mepc, mepc             ;\\\n    csrr r_mcause, mcause         ;\\\n    csrr r_mstatus, mstatus\n\n#define CATCH_ERR(tryname, r_mepc) \\\n        j tryname##_ok    ;\\\n        .align 4          ;\\\n    tryname##_err :       ;\\\n        la r_mepc, tryname##_err_real ;\\\n        csrw mepc, r_mepc ;\\\n        mret              ;\\\n        .align 4          ;\\\n    tryname##_err_real :\n\n#define TRY_END(tryname, r_mtvec, r_mepc, r_mcause, r_mstatus) \\\n    tryname##_ok :             ;\\\n        csrw mtvec, r_mtvec    ;\\\n        csrw mepc, r_mepc      ;\\\n        csrw mcause, r_mcause  ;\\\n        csrw mstatus, r_mstatus\n\n\n#define SET_MPRV(reg)  \\\n    li reg, 1         ;\\\n    slli reg, reg, 17 ;\\\n    csrs mstatus, reg\n\n#define UNSET_MPRV(reg) \\\n    li reg, 1          ;\\\n    slli reg, reg, 17  ;\\\n    csrc mstatus, reg\n\n\n\n.global copy_block_to_sm\ncopy_block_to_sm:\n    # Arguments:\n    # a0: dst\n    # a1: src\n    # Temporaries\n    # a2: mtvec\n    # a3: mepc\n    # a4: mcause\n    # a5: mstatus\nTRY(copy_block_in_check, a2, a3, a4, a5)\n    SET_MPRV(t0)\n    LOAD t0, 0*REGBYTES(a1)\n    LOAD t1, 1*REGBYTES(a1)\n    LOAD t2, 2*REGBYTES(a1)\n    LOAD t3, 3*REGBYTES(a1)\n    LOAD t4, 4*REGBYTES(a1)\n    LOAD t5, 5*REGBYTES(a1)\n    LOAD t6, 6*REGBYTES(a1)\n    LOAD a6, 7*REGBYTES(a1)\n    UNSET_MPRV(a1)\n    STORE t0, 0*REGBYTES(a0)\n    STORE t1, 1*REGBYTES(a0)\n    STORE t2, 2*REGBYTES(a0)\n    STORE t3, 3*REGBYTES(a0)\n    STORE t4, 4*REGBYTES(a0)\n    STORE t5, 5*REGBYTES(a0)\n    STORE t6, 6*REGBYTES(a0)\n    STORE a6, 7*REGBYTES(a0)\n    li a0, 0\nCATCH_ERR(copy_block_in_check, a1)\n    li a0, -1\nTRY_END(copy_block_in_check, a2, a3, a4, a5)\n\n    UNSET_MPRV(t0)\n    ret\n\n\n.global copy_word_to_sm\ncopy_word_to_sm:\n    # a0: dst\n    # a1: src\nTRY(copy_word_in_check, t1, t2, t3, t4)\n    SET_MPRV(t5)\n    LOAD t0, 0x00(a1)\n    UNSET_MPRV(t5)\n    STORE t0, 0x00(a0)\n    li a0, 0\nCATCH_ERR(copy_word_in_check, t5)\n    li a0, -1\nTRY_END(copy_word_in_check, t1, t2, t3, t4)\n\n    UNSET_MPRV(t5)\n    ret\n\n\n.global copy1_to_sm\ncopy1_to_sm:\n    # a0: dst\n    # a1: src\nTRY(copy1in_check, t1, t2, t3, t4)\n    SET_MPRV(t5)\n    lb t0, 0x00(a1)\n    UNSET_MPRV(t5)\n    sb t0, 0x00(a0)\n    li a0, 0\nCATCH_ERR(copy1in_check, t5)\n    li a0, -1\nTRY_END(copy1in_check, t1, t2, t3, t4)\n\n    UNSET_MPRV(t5)\n    ret\n\n\n.global copy_block_from_sm\ncopy_block_from_sm:\n    # Arguments:\n    # a0: dst\n    # a1: src\n    # Temporaries\n    # a2: mtvec\n    # a3: mepc\n    # a4: mcause\n    # a5: mstatus\nTRY(copy_block_out_check, a2, a3, a4, a5)\n    LOAD t0, 0*REGBYTES(a1)\n    LOAD t1, 1*REGBYTES(a1)\n    LOAD t2, 2*REGBYTES(a1)\n    LOAD t3, 3*REGBYTES(a1)\n    LOAD t4, 4*REGBYTES(a1)\n    LOAD t5, 5*REGBYTES(a1)\n    LOAD t6, 6*REGBYTES(a1)\n    LOAD a6, 7*REGBYTES(a1)\n    SET_MPRV(a1)\n    STORE t0, 0*REGBYTES(a0)\n    STORE t1, 1*REGBYTES(a0)\n    STORE t2, 2*REGBYTES(a0)\n    STORE t3, 3*REGBYTES(a0)\n    STORE t4, 4*REGBYTES(a0)\n    STORE t5, 5*REGBYTES(a0)\n    STORE t6, 6*REGBYTES(a0)\n    STORE a6, 7*REGBYTES(a0)\n    UNSET_MPRV(a1)\n    li a0, 0\nCATCH_ERR(copy_block_out_check, a1)\n    li a0, -1\nTRY_END(copy_block_out_check, a2, a3, a4, a5)\n\n    UNSET_MPRV(a1)\n    ret\n\n\n.global copy_word_from_sm\ncopy_word_from_sm:\n    # a0: dst\n    # a1: src\nTRY(copy_word_out_check, t1, t2, t3, t4)\n    LOAD t0, 0x00(a1)\n    SET_MPRV(t5)\n    STORE t0, 0x00(a0)\n    li a0, 0\nCATCH_ERR(copy_word_out_check, t5)\n    li a0, -1\nTRY_END(copy_word_out_check, t1, t2, t3, t4)\n\n    UNSET_MPRV(t5)\n    ret\n\n\n.global copy1_from_sm\ncopy1_from_sm:\n    # a0: dst\n    # a1: src\nTRY(copy1out_check, t1, t2, t3, t4)\n    lb t0, 0x00(a1)\n    SET_MPRV(t5)\n    sb t0, 0x00(a0)\n    li a0, 0\nCATCH_ERR(copy1out_check, t5)\n    li a0, -1\nTRY_END(copy1out_check, t1, t2, t3, t4)\n\n    UNSET_MPRV(t5)\n    ret\n\n"
  },
  {
    "path": "ftpm-opensbi/src/ntc2.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tNuvoton Proprietary Command Emulation\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: ntc2.c 1055 2017-08-08 20:30:09Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015, 2017\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* This emulation does not store the configuration in NV memory.  Thus, it does not persist.\n */\n\n#include \"ntc2_fp.h\"\n\n/* config state has some required or default values */\n\nstatic NTC2_CFG_STRUCT ntc2state = {\n    .i2cLoc1_2  =\t0xff,\n    .i2cLoc3_4  =\t0xff,\n    .AltCfg \t= \t0x13,\n    .Direction \t=  \t0x00,\n    .PullUp \t=   \t0xff,\n    .PushPull \t=   \t0xff,\n    .CFG_A \t=   \t0xff,\n    .CFG_B \t=   \t0xff,\n    .CFG_C \t=   \t0xff,\n    .CFG_D \t=   \t0xff,\n    .CFG_E \t=   \t0xff,\n    .CFG_F \t=   \t0xff,\n    .CFG_G \t=   \t0xff,\n    .CFG_H \t=   \t0xff,\n    .CFG_I \t=   \t0xff,\n    .CFG_J \t=   \t0xff,\n    .IsValid \t=   \t0xaa,\n    .IsLocked \t= \t0xff\n};\n\nTPM_RC\nNTC2_PreConfig(NTC2_PreConfig_In *in)\n{\n    // Input Validation\n    if (ntc2state.IsLocked == 0xaa) {\n\treturn TPM_RC_DISABLED;\n    }\n    ntc2state = in->preConfig;\n    ntc2state.IsLocked = 0xff;\t/* cannot be set by PreConfig */\n    return TPM_RC_SUCCESS;\n}\n\nTPM_RC\nNTC2_LockPreConfig(void)\n{\n    ntc2state.IsLocked = 0xaa;\n    return TPM_RC_SUCCESS;\n}\n\nTPM_RC\nNTC2_GetConfig(NTC2_GetConfig_Out *out)\n{\n    out->preConfig = ntc2state;\n    return TPM_RC_SUCCESS;\n}\n"
  },
  {
    "path": "ftpm-opensbi/src/ntc2lib.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t     \tTPM2 Novoton Proprietary Command Utilities\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: ntc2lib.c 1055 2017-08-08 20:30:09Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015, 2017\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"Unmarshal_fp.h\"\n#include \"Marshal_fp.h\"\n#include \"ntc2lib.h\"\n\n/* Marshal and Unmarshal Functions */\n\nTPM_RC\nNTC2_CFG_STRUCT_Unmarshal(NTC2_CFG_STRUCT *target, BYTE **buffer, INT32 *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    /* assumes that the NTC2_CFG_STRUCT structure are all uint8_t so that there are no endian\n       issues */\n    if (rc == TPM_RC_SUCCESS) {\n\trc = Array_Unmarshal((BYTE *)target, sizeof(NTC2_CFG_STRUCT), buffer, size);\n    }\n    return rc;\n}\n    \nUINT16\nNTC2_CFG_STRUCT_Marshal(NTC2_CFG_STRUCT *source, BYTE **buffer, INT32 *size)\n{\n    UINT16 written = 0;\n    /* assumes that the NTC2_CFG_STRUCT structure are all uint8_t so that there are no endian\n       issues */\n    written += Array_Marshal((BYTE *)source, sizeof(NTC2_CFG_STRUCT), buffer, size);\n    return written;\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/.gitignore",
    "content": "# 忽略所有文件\n*\n\n# 追踪 .c 文件\n!*.c\n!makefile*\n!Makefile*\n\n# 保留 .gitignore 文件\n!.gitignore\n"
  },
  {
    "path": "ibmtss-ftpm/CommandAttributeData.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Command Attributes Table   \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n// 9.3\tCommandAttributeData.c\n\n#ifdef TPM_TPM12\n#include <ibmtss/tpmconstants12.h>\n#endif\n\n#include \"CommandAttributes.h\"\n#if defined COMPRESSED_LISTS\n#   define      PAD_LIST    0\n#else\n#   define      PAD_LIST    1\n#endif\n\n// This is the command code attribute array for GetCapability(). Both this array and\n// s_commandAttributes provides command code attributes, but tuned for different purpose\n\n/* bitfield is:\n\n   command index\n   reserved\n   nv\n   extensive\n   flushed\n   cHandles\n   rHandle\n   V\n   reserved, flags TPM 1.2 command\n*/\n\n#include \"tssccattributes.h\"\n\nconst TPMA_CC_TSS    s_ccAttr [] = {\n\n#if (PAD_LIST || CC_NV_UndefineSpaceSpecial)\n    {{0x011f, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_NV_UndefineSpaceSpecial\n#endif\n#if (PAD_LIST || CC_EvictControl)\n    {{0x0120, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_EvictControl\n#endif\n#if (PAD_LIST || CC_HierarchyControl)\n    {{0x0121, 0, 1, 1, 0, 1, 0, 0, 0}},     // TPM_CC_HierarchyControl\n#endif\n#if (PAD_LIST || CC_NV_UndefineSpace)\n    {{0x0122, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_NV_UndefineSpace\n#endif\n#if (PAD_LIST)\n    {{0x0123, 0, 0, 0, 0, 0, 0, 0, 0}},     // No command\n#endif\n#if (PAD_LIST || CC_ChangeEPS)\n    {{0x0124, 0, 1, 1, 0, 1, 0, 0, 0}},     // TPM_CC_ChangeEPS\n#endif\n#if (PAD_LIST || CC_ChangePPS)\n    {{0x0125, 0, 1, 1, 0, 1, 0, 0, 0}},     // TPM_CC_ChangePPS\n#endif\n#if (PAD_LIST || CC_Clear)\n    {{0x0126, 0, 1, 1, 0, 1, 0, 0, 0}},     // TPM_CC_Clear\n#endif\n#if (PAD_LIST || CC_ClearControl)\n    {{0x0127, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ClearControl\n#endif\n#if (PAD_LIST || CC_ClockSet)\n    {{0x0128, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ClockSet\n#endif\n#if (PAD_LIST || CC_HierarchyChangeAuth)\n    {{0x0129, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_HierarchyChangeAuth\n#endif\n#if (PAD_LIST || CC_NV_DefineSpace)\n    {{0x012a, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_NV_DefineSpace\n#endif\n#if (PAD_LIST || CC_PCR_Allocate)\n    {{0x012b, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PCR_Allocate\n#endif\n#if (PAD_LIST || CC_PCR_SetAuthPolicy)\n    {{0x012c, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PCR_SetAuthPolicy\n#endif\n#if (PAD_LIST || CC_PP_Commands)\n    {{0x012d, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PP_Commands\n#endif\n#if (PAD_LIST || CC_SetPrimaryPolicy)\n    {{0x012e, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_SetPrimaryPolicy\n#endif\n#if (PAD_LIST || CC_FieldUpgradeStart)\n    {{0x012f, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_FieldUpgradeStart\n#endif\n#if (PAD_LIST || CC_ClockRateAdjust)\n    {{0x0130, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ClockRateAdjust\n#endif\n#if (PAD_LIST || CC_CreatePrimary)\n    {{0x0131, 0, 0, 0, 0, 1, 1, 0, 0}},     // TPM_CC_CreatePrimary\n#endif\n#if (PAD_LIST || CC_NV_GlobalWriteLock)\n    {{0x0132, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_NV_GlobalWriteLock\n#endif\n#if (PAD_LIST || CC_GetCommandAuditDigest)\n    {{0x0133, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_GetCommandAuditDigest\n#endif\n#if (PAD_LIST || CC_NV_Increment)\n    {{0x0134, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_NV_Increment\n#endif\n#if (PAD_LIST || CC_NV_SetBits)\n    {{0x0135, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_NV_SetBits\n#endif\n#if (PAD_LIST || CC_NV_Extend)\n    {{0x0136, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_NV_Extend\n#endif\n#if (PAD_LIST || CC_NV_Write)\n    {{0x0137, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_NV_Write\n#endif\n#if (PAD_LIST || CC_NV_WriteLock)\n    {{0x0138, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_NV_WriteLock\n#endif\n#if (PAD_LIST || CC_DictionaryAttackLockReset)\n    {{0x0139, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_DictionaryAttackLockReset\n#endif\n#if (PAD_LIST || CC_DictionaryAttackParameters)\n    {{0x013a, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_DictionaryAttackParameters\n#endif\n#if (PAD_LIST || CC_NV_ChangeAuth)\n    {{0x013b, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_NV_ChangeAuth\n#endif\n#if (PAD_LIST || CC_PCR_Event)\n    {{0x013c, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PCR_Event\n#endif\n#if (PAD_LIST || CC_PCR_Reset)\n    {{0x013d, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PCR_Reset\n#endif\n#if (PAD_LIST || CC_SequenceComplete)\n    {{0x013e, 0, 0, 0, 1, 1, 0, 0, 0}},     // TPM_CC_SequenceComplete\n#endif\n#if (PAD_LIST || CC_SetAlgorithmSet)\n    {{0x013f, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_SetAlgorithmSet\n#endif\n#if (PAD_LIST || CC_SetCommandCodeAuditStatus)\n    {{0x0140, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_SetCommandCodeAuditStatus\n#endif\n#if (PAD_LIST || CC_FieldUpgradeData)\n    {{0x0141, 0, 1, 0, 0, 0, 0, 0, 0}},     // TPM_CC_FieldUpgradeData\n#endif\n#if (PAD_LIST || CC_IncrementalSelfTest)\n    {{0x0142, 0, 1, 0, 0, 0, 0, 0, 0}},     // TPM_CC_IncrementalSelfTest\n#endif\n#if (PAD_LIST || CC_SelfTest)\n    {{0x0143, 0, 1, 0, 0, 0, 0, 0, 0}},     // TPM_CC_SelfTest\n#endif\n#if (PAD_LIST || CC_Startup)\n    {{0x0144, 0, 1, 0, 0, 0, 0, 0, 0}},     // TPM_CC_Startup\n#endif\n#if (PAD_LIST || CC_Shutdown)\n    {{0x0145, 0, 1, 0, 0, 0, 0, 0, 0}},     // TPM_CC_Shutdown\n#endif\n#if (PAD_LIST || CC_StirRandom)\n    {{0x0146, 0, 1, 0, 0, 0, 0, 0, 0}},     // TPM_CC_StirRandom\n#endif\n#if (PAD_LIST || CC_ActivateCredential)\n    {{0x0147, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_ActivateCredential\n#endif\n#if (PAD_LIST || CC_Certify)\n    {{0x0148, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_Certify\n#endif\n#if (PAD_LIST || CC_PolicyNV)\n    {{0x0149, 0, 0, 0, 0, 3, 0, 0, 0}},     // TPM_CC_PolicyNV\n#endif\n#if (PAD_LIST || CC_CertifyCreation)\n    {{0x014a, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_CertifyCreation\n#endif\n#if (PAD_LIST || CC_CertifyX509)\n    {{0x0197, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_CertifyX509\n#endif\n#if (PAD_LIST || CC_Duplicate)\n    {{0x014b, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_Duplicate\n#endif\n#if (PAD_LIST || CC_GetTime)\n    {{0x014c, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_GetTime\n#endif\n#if (PAD_LIST || CC_GetSessionAuditDigest)\n    {{0x014d, 0, 0, 0, 0, 3, 0, 0, 0}},     // TPM_CC_GetSessionAuditDigest\n#endif\n#if (PAD_LIST || CC_NV_Read)\n    {{0x014e, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_NV_Read\n#endif\n#if (PAD_LIST || CC_NV_ReadLock)\n    {{0x014f, 0, 1, 0, 0, 2, 0, 0, 0}},     // TPM_CC_NV_ReadLock\n#endif\n#if (PAD_LIST || CC_ObjectChangeAuth)\n    {{0x0150, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_ObjectChangeAuth\n#endif\n#if (PAD_LIST || CC_PolicySecret)\n    {{0x0151, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_PolicySecret\n#endif\n#if (PAD_LIST || CC_Rewrap)\n    {{0x0152, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_Rewrap\n#endif\n#if (PAD_LIST || CC_Create)\n    {{0x0153, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_Create\n#endif\n#if (PAD_LIST || CC_ECDH_ZGen)\n    {{0x0154, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ECDH_ZGen\n#endif\n#if (PAD_LIST || CC_HMAC)\n    {{0x0155, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_HMAC\n#endif\n#if (PAD_LIST || CC_Import)\n    {{0x0156, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_Import\n#endif\n#if (PAD_LIST || CC_Load)\n    {{0x0157, 0, 0, 0, 0, 1, 1, 0, 0}},     // TPM_CC_Load\n#endif\n#if (PAD_LIST || CC_Quote)\n    {{0x0158, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_Quote\n#endif\n#if (PAD_LIST || CC_RSA_Decrypt)\n    {{0x0159, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_RSA_Decrypt\n#endif\n#if (PAD_LIST)\n    {{0x015a, 0, 0, 0, 0, 0, 0, 0, 0}},     // No command\n#endif\n#if (PAD_LIST || CC_HMAC_Start)\n    {{0x015b, 0, 0, 0, 0, 1, 1, 0, 0}},     // TPM_CC_HMAC_Start\n#endif\n#if (PAD_LIST || CC_SequenceUpdate)\n    {{0x015c, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_SequenceUpdate\n#endif\n#if (PAD_LIST || CC_Sign)\n    {{0x015d, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_Sign\n#endif\n#if (PAD_LIST || CC_Unseal)\n    {{0x015e, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_Unseal\n#endif\n#if (PAD_LIST)\n    {{0x015f, 0, 0, 0, 0, 0, 0, 0, 0}},     // No command\n#endif\n#if (PAD_LIST || CC_PolicySigned)\n    {{0x0160, 0, 0, 0, 0, 2, 0, 0, 0}},     // TPM_CC_PolicySigned\n#endif\n#if (PAD_LIST || CC_ContextLoad)\n    {{0x0161, 0, 0, 0, 0, 0, 1, 0, 0}},     // TPM_CC_ContextLoad\n#endif\n#if (PAD_LIST || CC_ContextSave)\n    {{0x0162, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ContextSave\n#endif\n#if (PAD_LIST || CC_ECDH_KeyGen)\n    {{0x0163, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ECDH_KeyGen\n#endif\n#if (PAD_LIST || CC_EncryptDecrypt)\n    {{0x0164, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_EncryptDecrypt\n#endif\n#if (PAD_LIST || CC_FlushContext)\n    {{0x0165, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_FlushContext\n#endif\n#if (PAD_LIST)\n    {{0x0166, 0, 0, 0, 0, 0, 0, 0, 0}},     // No command\n#endif\n#if (PAD_LIST || CC_LoadExternal)\n    {{0x0167, 0, 0, 0, 0, 0, 1, 0, 0}},     // TPM_CC_LoadExternal\n#endif\n#if (PAD_LIST || CC_MakeCredential)\n    {{0x0168, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_MakeCredential\n#endif\n#if (PAD_LIST || CC_NV_ReadPublic)\n    {{0x0169, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_NV_ReadPublic\n#endif\n#if (PAD_LIST || CC_PolicyAuthorize)\n    {{0x016a, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyAuthorize\n#endif\n#if (PAD_LIST || CC_PolicyAuthValue)\n    {{0x016b, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyAuthValue\n#endif\n#if (PAD_LIST || CC_PolicyCommandCode)\n    {{0x016c, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyCommandCode\n#endif\n#if (PAD_LIST || CC_PolicyCounterTimer)\n    {{0x016d, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyCounterTimer\n#endif\n#if (PAD_LIST || CC_PolicyCpHash)\n    {{0x016e, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyCpHash\n#endif\n#if (PAD_LIST || CC_PolicyLocality)\n    {{0x016f, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyLocality\n#endif\n#if (PAD_LIST || CC_PolicyNameHash)\n    {{0x0170, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyNameHash\n#endif\n#if (PAD_LIST || CC_PolicyOR)\n    {{0x0171, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyOR\n#endif\n#if (PAD_LIST || CC_PolicyTicket)\n    {{0x0172, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyTicket\n#endif\n#if (PAD_LIST || CC_ReadPublic)\n    {{0x0173, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ReadPublic\n#endif\n#if (PAD_LIST || CC_RSA_Encrypt)\n    {{0x0174, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_RSA_Encrypt\n#endif\n#if (PAD_LIST)\n    {{0x0175, 0, 0, 0, 0, 0, 0, 0, 0}},     // No command\n#endif\n#if (PAD_LIST || CC_StartAuthSession)\n    {{0x0176, 0, 0, 0, 0, 2, 1, 0, 0}},     // TPM_CC_StartAuthSession\n#endif\n#if (PAD_LIST || CC_VerifySignature)\n    {{0x0177, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_VerifySignature\n#endif\n#if (PAD_LIST || CC_ECC_Encrypt)\n    {{0x0199, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ECC_Encrypt\n#endif\n#if (PAD_LIST || CC_ECC_Decrypt)\n    {{0x019a, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ECC_Decrypt\n#endif\n#if (PAD_LIST || CC_ECC_Parameters)\n    {{0x0178, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_ECC_Parameters\n#endif\n#if (PAD_LIST || CC_FirmwareRead)\n    {{0x0179, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_FirmwareRead\n#endif\n#if (PAD_LIST || CC_GetCapability)\n    {{0x017a, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_GetCapability\n#endif\n#if (PAD_LIST || CC_GetRandom)\n    {{0x017b, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_GetRandom\n#endif\n#if (PAD_LIST || CC_GetTestResult)\n    {{0x017c, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_GetTestResult\n#endif\n#if (PAD_LIST || CC_Hash)\n    {{0x017d, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_Hash\n#endif\n#if (PAD_LIST || CC_PCR_Read)\n    {{0x017e, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_PCR_Read\n#endif\n#if (PAD_LIST || CC_PolicyPCR)\n    {{0x017f, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyPCR\n#endif\n#if (PAD_LIST || CC_PolicyRestart)\n    {{0x0180, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyRestart\n#endif\n#if (PAD_LIST || CC_ReadClock)\n    {{0x0181, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_ReadClock\n#endif\n#if (PAD_LIST || CC_PCR_Extend)\n    {{0x0182, 0, 1, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PCR_Extend\n#endif\n#if (PAD_LIST || CC_PCR_SetAuthValue)\n    {{0x0183, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PCR_SetAuthValue\n#endif\n#if (PAD_LIST || CC_NV_Certify)\n    {{0x0184, 0, 0, 0, 0, 3, 0, 0, 0}},     // TPM_CC_NV_Certify\n#endif\n#if (PAD_LIST || CC_EventSequenceComplete)\n    {{0x0185, 0, 1, 0, 1, 2, 0, 0, 0}},     // TPM_CC_EventSequenceComplete\n#endif\n#if (PAD_LIST || CC_HashSequenceStart)\n    {{0x0186, 0, 0, 0, 0, 0, 1, 0, 0}},     // TPM_CC_HashSequenceStart\n#endif\n#if (PAD_LIST || CC_PolicyPhysicalPresence)\n    {{0x0187, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyPhysicalPresence\n#endif\n#if (PAD_LIST || CC_PolicyDuplicationSelect)\n    {{0x0188, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyDuplicationSelect\n#endif\n#if (PAD_LIST || CC_PolicyGetDigest)\n    {{0x0189, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyGetDigest\n#endif\n#if (PAD_LIST || CC_TestParms)\n    {{0x018a, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_TestParms\n#endif\n#if (PAD_LIST || CC_Commit)\n    {{0x018b, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_Commit\n#endif\n#if (PAD_LIST || CC_PolicyPassword)\n    {{0x018c, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyPassword\n#endif\n#if (PAD_LIST || CC_ZGen_2Phase)\n    {{0x018d, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_ZGen_2Phase\n#endif\n#if (PAD_LIST || CC_EC_Ephemeral)\n    {{0x018e, 0, 0, 0, 0, 0, 0, 0, 0}},     // TPM_CC_EC_Ephemeral\n#endif\n#if (PAD_LIST || CC_PolicyNvWritten)\n    {{0x018f, 0, 0, 0, 0, 1, 0, 0, 0}},     // TPM_CC_PolicyNvWritten\n#endif\n#if (PAD_LIST || CC_PolicyTemplate)\n    {{0x0190, 0, 0, 0, 0, 1, 0, 0, 0}},       // TPM_CC_PolicyTemplate\n#endif\n#if (PAD_LIST || CC_PolicyCapability)\n    {{0x019b, 0, 0, 0, 0, 1, 0, 0, 0}},       // TPM_CC_PolicyCapability\n#endif\n#if (PAD_LIST || CC_PolicyParameters)\n    {{0x019c, 0, 0, 0, 0, 1, 0, 0, 0}},       // TPM_CC_PolicyParameters\n#endif\n#if (PAD_LIST || CC_CreateLoaded)\n    {{0x0191, 0, 0, 0, 0, 1, 1, 0, 0}},       // TPM_CC_CreateLoaded\n#endif\n#if (PAD_LIST || CC_PolicyAuthorizeNV)\n    {{0x0192, 0, 0, 0, 0, 3, 0, 0, 0}},       // TPM_CC_PolicyAuthorizeNV\n#endif\n#if (PAD_LIST || CC_EncryptDecrypt2)\n    {{0x0193, 0, 0, 0, 0, 1, 0, 0, 0}},       // TPM_CC_EncryptDecrypt2\n#endif\n\n#if (PAD_LIST || CC_Vendor_TCG_Test)\n    {{0x0000, 0, 0, 0, 0, 0, 0, 1, 0}},     // TPM_CC_Vendor_TCG_Test\n#endif\n\n#if (PAD_LIST || CC_NTC2_PreConfig)\n    {{0x20000211, 0, 1, 0, 0, 0, 0, 1, 0}}, // TPM_CC_NTC2_PreConfig\n#endif\n\n#if (PAD_LIST || CC_NTC2_LockPreConfig)\n    {{0x20000212, 0, 1, 0, 0, 0, 0, 1, 0}}, // TPM_CC_NTC2_LockPreConfig\n#endif\n\n#if (PAD_LIST || CC_NTC2_GetConfig)\n    {{0x20000213, 0, 1, 0, 0, 0, 0, 1, 0}}, // TPM_CC_NTC2_GetConfig\n#endif\n\n    {{0x0000, 0, 0, 0, 0, 0, 0, 0, 0}},     // kg - terminator?\n};\n\n// This is the command code attribute structure.\n\nconst COMMAND_ATTRIBUTES    s_commandAttributes [] = {\n#if (PAD_LIST || CC_NV_UndefineSpaceSpecial)\n    (COMMAND_ATTRIBUTES)(CC_NV_UndefineSpaceSpecial    *  // 0x011f\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_ADMIN+HANDLE_2_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_EvictControl)\n    (COMMAND_ATTRIBUTES)(CC_EvictControl               *  // 0x0120\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_HierarchyControl)\n    (COMMAND_ATTRIBUTES)(CC_HierarchyControl           *  // 0x0121\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_NV_UndefineSpace)\n    (COMMAND_ATTRIBUTES)(CC_NV_UndefineSpace           *  // 0x0122\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST)\n    (COMMAND_ATTRIBUTES)(0),                              // 0x0123\n#endif\n#if (PAD_LIST || CC_ChangeEPS)\n    (COMMAND_ATTRIBUTES)(CC_ChangeEPS                  *  // 0x0124\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_ChangePPS)\n    (COMMAND_ATTRIBUTES)(CC_ChangePPS                  *  // 0x0125\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_Clear)\n    (COMMAND_ATTRIBUTES)(CC_Clear                      *  // 0x0126\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_ClearControl)\n    (COMMAND_ATTRIBUTES)(CC_ClearControl               *  // 0x0127\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_ClockSet)\n    (COMMAND_ATTRIBUTES)(CC_ClockSet                   *  // 0x0128\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_HierarchyChangeAuth)\n    (COMMAND_ATTRIBUTES)(CC_HierarchyChangeAuth        *  // 0x0129\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_NV_DefineSpace)\n    (COMMAND_ATTRIBUTES)(CC_NV_DefineSpace             *  // 0x012a\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_PCR_Allocate)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Allocate               *  // 0x012b\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_PCR_SetAuthPolicy)\n    (COMMAND_ATTRIBUTES)(CC_PCR_SetAuthPolicy          *  // 0x012c\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_PP_Commands)\n    (COMMAND_ATTRIBUTES)(CC_PP_Commands                *  // 0x012d\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_REQUIRED)),\n#endif\n#if (PAD_LIST || CC_SetPrimaryPolicy)\n    (COMMAND_ATTRIBUTES)(CC_SetPrimaryPolicy           *  // 0x012e\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_FieldUpgradeStart)\n    (COMMAND_ATTRIBUTES)(CC_FieldUpgradeStart          *  // 0x012f\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_ClockRateAdjust)\n    (COMMAND_ATTRIBUTES)(CC_ClockRateAdjust            *  // 0x0130\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_CreatePrimary)\n    (COMMAND_ATTRIBUTES)(CC_CreatePrimary              *  // 0x0131\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST || CC_NV_GlobalWriteLock)\n    (COMMAND_ATTRIBUTES)(CC_NV_GlobalWriteLock         *  // 0x0132\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_GetCommandAuditDigest)\n    (COMMAND_ATTRIBUTES)(CC_GetCommandAuditDigest      *  // 0x0133\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_NV_Increment)\n    (COMMAND_ATTRIBUTES)(CC_NV_Increment               *  // 0x0134\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_NV_SetBits)\n    (COMMAND_ATTRIBUTES)(CC_NV_SetBits                 *  // 0x0135\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_NV_Extend)\n    (COMMAND_ATTRIBUTES)(CC_NV_Extend                  *  // 0x0136\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_NV_Write)\n    (COMMAND_ATTRIBUTES)(CC_NV_Write                   *  // 0x0137\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_NV_WriteLock)\n    (COMMAND_ATTRIBUTES)(CC_NV_WriteLock               *  // 0x0138\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_DictionaryAttackLockReset)\n    (COMMAND_ATTRIBUTES)(CC_DictionaryAttackLockReset  *  // 0x0139\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_DictionaryAttackParameters)\n    (COMMAND_ATTRIBUTES)(CC_DictionaryAttackParameters *  // 0x013a\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_NV_ChangeAuth)\n    (COMMAND_ATTRIBUTES)(CC_NV_ChangeAuth              *  // 0x013b\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN)),\n#endif\n#if (PAD_LIST || CC_PCR_Event)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Event                  *  // 0x013c\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_PCR_Reset)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Reset                  *  // 0x013d\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_SequenceComplete)\n    (COMMAND_ATTRIBUTES)(CC_SequenceComplete           *  // 0x013e\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_SetAlgorithmSet)\n    (COMMAND_ATTRIBUTES)(CC_SetAlgorithmSet            *  // 0x013f\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_SetCommandCodeAuditStatus)\n    (COMMAND_ATTRIBUTES)(CC_SetCommandCodeAuditStatus  *  // 0x0140\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+PP_COMMAND)),\n#endif\n#if (PAD_LIST || CC_FieldUpgradeData)\n    (COMMAND_ATTRIBUTES)(CC_FieldUpgradeData           *  // 0x0141\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2)),\n#endif\n#if (PAD_LIST || CC_IncrementalSelfTest)\n    (COMMAND_ATTRIBUTES)(CC_IncrementalSelfTest        *  // 0x0142\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST || CC_SelfTest)\n    (COMMAND_ATTRIBUTES)(CC_SelfTest                   *  // 0x0143\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST || CC_Startup)\n    (COMMAND_ATTRIBUTES)(CC_Startup                    *  // 0x0144\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST || CC_Shutdown)\n    (COMMAND_ATTRIBUTES)(CC_Shutdown                   *  // 0x0145\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST || CC_StirRandom)\n    (COMMAND_ATTRIBUTES)(CC_StirRandom                 *  // 0x0146\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2)),\n#endif\n#if (PAD_LIST || CC_ActivateCredential)\n    (COMMAND_ATTRIBUTES)(CC_ActivateCredential         *  // 0x0147\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_Certify)\n    (COMMAND_ATTRIBUTES)(CC_Certify                    *  // 0x0148\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_PolicyNV)\n    (COMMAND_ATTRIBUTES)(CC_PolicyNV                   *  // 0x0149\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_CertifyCreation)\n    (COMMAND_ATTRIBUTES)(CC_CertifyCreation            *  // 0x014a\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_CertifyX509)\n    (COMMAND_ATTRIBUTES)(CC_CertifyX509                *  // 0x0197\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_Duplicate)\n    (COMMAND_ATTRIBUTES)(CC_Duplicate                  *  // 0x014b\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_DUP+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_GetTime)\n    (COMMAND_ATTRIBUTES)(CC_GetTime                    *  // 0x014c\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_GetSessionAuditDigest)\n    (COMMAND_ATTRIBUTES)(CC_GetSessionAuditDigest      *  // 0x014d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_NV_Read)\n    (COMMAND_ATTRIBUTES)(CC_NV_Read                    *  // 0x014e\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_NV_ReadLock)\n    (COMMAND_ATTRIBUTES)(CC_NV_ReadLock                *  // 0x014f\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_ObjectChangeAuth)\n    (COMMAND_ATTRIBUTES)(CC_ObjectChangeAuth           *  // 0x0150\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_ADMIN+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_PolicySecret)\n    (COMMAND_ATTRIBUTES)(CC_PolicySecret               *  // 0x0151\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ALLOW_TRIAL+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_Rewrap)\n    (COMMAND_ATTRIBUTES)(CC_Rewrap                     *  // 0x0152\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_Create)\n    (COMMAND_ATTRIBUTES)(CC_Create                     *  // 0x0153\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_ECDH_ZGen)\n    (COMMAND_ATTRIBUTES)(CC_ECDH_ZGen                  *  // 0x0154\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_HMAC)\n    (COMMAND_ATTRIBUTES)(CC_HMAC                       *  // 0x0155\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_Import)\n    (COMMAND_ATTRIBUTES)(CC_Import                     *  // 0x0156\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_Load)\n    (COMMAND_ATTRIBUTES)(CC_Load                       *  // 0x0157\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST || CC_Quote)\n    (COMMAND_ATTRIBUTES)(CC_Quote                      *  // 0x0158\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_RSA_Decrypt)\n    (COMMAND_ATTRIBUTES)(CC_RSA_Decrypt                *  // 0x0159\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST)\n    (COMMAND_ATTRIBUTES)(0),                              // 0x015a\n#endif\n#if (PAD_LIST || CC_HMAC_Start)\n    (COMMAND_ATTRIBUTES)(CC_HMAC_Start                 *  // 0x015b\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+R_HANDLE)),\n#endif\n#if (PAD_LIST || CC_SequenceUpdate)\n    (COMMAND_ATTRIBUTES)(CC_SequenceUpdate             *  // 0x015c\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_Sign)\n    (COMMAND_ATTRIBUTES)(CC_Sign                       *  // 0x015d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_Unseal)\n    (COMMAND_ATTRIBUTES)(CC_Unseal                     *  // 0x015e\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST)\n    (COMMAND_ATTRIBUTES)(0),                              // 0x015f\n#endif\n#if (PAD_LIST || CC_PolicySigned)\n    (COMMAND_ATTRIBUTES)(CC_PolicySigned               *  // 0x0160\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_ContextLoad)\n    (COMMAND_ATTRIBUTES)(CC_ContextLoad                *  // 0x0161\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS+R_HANDLE)),\n#endif\n#if (PAD_LIST || CC_ContextSave)\n    (COMMAND_ATTRIBUTES)(CC_ContextSave                *  // 0x0162\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST || CC_ECDH_KeyGen)\n    (COMMAND_ATTRIBUTES)(CC_ECDH_KeyGen                *  // 0x0163\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_EncryptDecrypt)\n    (COMMAND_ATTRIBUTES)(CC_EncryptDecrypt             *  // 0x0164\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_FlushContext)\n    (COMMAND_ATTRIBUTES)(CC_FlushContext               *  // 0x0165\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST)\n    (COMMAND_ATTRIBUTES)(0),                              // 0x0166\n#endif\n#if (PAD_LIST || CC_LoadExternal)\n    (COMMAND_ATTRIBUTES)(CC_LoadExternal               *  // 0x0167\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST || CC_MakeCredential)\n    (COMMAND_ATTRIBUTES)(CC_MakeCredential             *  // 0x0168\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_NV_ReadPublic)\n    (COMMAND_ATTRIBUTES)(CC_NV_ReadPublic              *  // 0x0169\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_PolicyAuthorize)\n    (COMMAND_ATTRIBUTES)(CC_PolicyAuthorize            *  // 0x016a\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyAuthValue)\n    (COMMAND_ATTRIBUTES)(CC_PolicyAuthValue            *  // 0x016b\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyCommandCode)\n    (COMMAND_ATTRIBUTES)(CC_PolicyCommandCode          *  // 0x016c\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyCounterTimer)\n    (COMMAND_ATTRIBUTES)(CC_PolicyCounterTimer         *  // 0x016d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyCpHash)\n    (COMMAND_ATTRIBUTES)(CC_PolicyCpHash               *  // 0x016e\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyLocality)\n    (COMMAND_ATTRIBUTES)(CC_PolicyLocality             *  // 0x016f\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyNameHash)\n    (COMMAND_ATTRIBUTES)(CC_PolicyNameHash             *  // 0x0170\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyOR)\n    (COMMAND_ATTRIBUTES)(CC_PolicyOR                   *  // 0x0171\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyTicket)\n    (COMMAND_ATTRIBUTES)(CC_PolicyTicket               *  // 0x0172\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_ReadPublic)\n    (COMMAND_ATTRIBUTES)(CC_ReadPublic                 *  // 0x0173\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_RSA_Encrypt)\n    (COMMAND_ATTRIBUTES)(CC_RSA_Encrypt                *  // 0x0174\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n#if (PAD_LIST)\n    (COMMAND_ATTRIBUTES)(0),                              // 0x0175\n#endif\n#if (PAD_LIST || CC_StartAuthSession)\n    (COMMAND_ATTRIBUTES)(CC_StartAuthSession           *  // 0x0176\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST || CC_VerifySignature)\n    (COMMAND_ATTRIBUTES)(CC_VerifySignature            *  // 0x0177\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2)),\n#endif\n#if (PAD_LIST || CC_ECC_Encrypt)\n    (COMMAND_ATTRIBUTES)(CC_ECC_Encrypt                *  // 0x0199\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_ECC_Decrypt)\n    (COMMAND_ATTRIBUTES)(CC_ECC_Decrypt                *  // 0x019a\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_ECC_Parameters)\n    (COMMAND_ATTRIBUTES)(CC_ECC_Parameters             *  // 0x0178\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST || CC_FirmwareRead)\n    (COMMAND_ATTRIBUTES)(CC_FirmwareRead               *  // 0x0179\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_GetCapability)\n    (COMMAND_ATTRIBUTES)(CC_GetCapability              *  // 0x017a\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST || CC_GetRandom)\n    (COMMAND_ATTRIBUTES)(CC_GetRandom                  *  // 0x017b\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_GetTestResult)\n    (COMMAND_ATTRIBUTES)(CC_GetTestResult              *  // 0x017c\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_Hash)\n    (COMMAND_ATTRIBUTES)(CC_Hash                       *  // 0x017d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_PCR_Read)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Read                   *  // 0x017e\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST || CC_PolicyPCR)\n    (COMMAND_ATTRIBUTES)(CC_PolicyPCR                  *  // 0x017f\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyRestart)\n    (COMMAND_ATTRIBUTES)(CC_PolicyRestart              *  // 0x0180\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_ReadClock)\n    (COMMAND_ATTRIBUTES)(CC_ReadClock                  *  // 0x0181\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST || CC_PCR_Extend)\n    (COMMAND_ATTRIBUTES)(CC_PCR_Extend                 *  // 0x0182\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_PCR_SetAuthValue)\n    (COMMAND_ATTRIBUTES)(CC_PCR_SetAuthValue           *  // 0x0183\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER)),\n#endif\n#if (PAD_LIST || CC_NV_Certify)\n    (COMMAND_ATTRIBUTES)(CC_NV_Certify                 *  // 0x0184\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_EventSequenceComplete)\n    (COMMAND_ATTRIBUTES)(CC_EventSequenceComplete      *  // 0x0185\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+HANDLE_2_USER)),\n#endif\n#if (PAD_LIST || CC_HashSequenceStart)\n    (COMMAND_ATTRIBUTES)(CC_HashSequenceStart          *  // 0x0186\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST || CC_PolicyPhysicalPresence)\n    (COMMAND_ATTRIBUTES)(CC_PolicyPhysicalPresence     *  // 0x0187\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyDuplicationSelect)\n    (COMMAND_ATTRIBUTES)(CC_PolicyDuplicationSelect    *  // 0x0188\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyGetDigest)\n    (COMMAND_ATTRIBUTES)(CC_PolicyGetDigest            *  // 0x0189\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_TestParms)\n    (COMMAND_ATTRIBUTES)(CC_TestParms                  *  // 0x018a\n\t\t\t (IS_IMPLEMENTED)),\n#endif\n#if (PAD_LIST || CC_Commit)\n    (COMMAND_ATTRIBUTES)(CC_Commit                     *  // 0x018b\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_PolicyPassword)\n    (COMMAND_ATTRIBUTES)(CC_PolicyPassword             *  // 0x018c\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_ZGen_2Phase)\n    (COMMAND_ATTRIBUTES)(CC_ZGen_2Phase                *  // 0x018d\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_EC_Ephemeral)\n    (COMMAND_ATTRIBUTES)(CC_EC_Ephemeral               *  // 0x018e\n\t\t\t (IS_IMPLEMENTED+ENCRYPT_2)),\n#endif\n#if (PAD_LIST || CC_PolicyNvWritten)\n    (COMMAND_ATTRIBUTES)(CC_PolicyNvWritten            *  // 0x018f\n\t\t\t (IS_IMPLEMENTED+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyTemplate)\n    (COMMAND_ATTRIBUTES)(CC_PolicyTemplate             *  // 0x0190\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyCapability)\n    (COMMAND_ATTRIBUTES)(CC_PolicyCapability           *  // 0x019b\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_PolicyParameters)\n    (COMMAND_ATTRIBUTES)(CC_PolicyParameters           *  // 0x019c\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_CreateLoaded)\n    (COMMAND_ATTRIBUTES)(CC_CreateLoaded               *  // 0x0191\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+PP_COMMAND+ENCRYPT_2+R_HANDLE)),\n#endif\n#if (PAD_LIST || CC_PolicyAuthorizeNV)\n    (COMMAND_ATTRIBUTES)(CC_PolicyAuthorizeNV          *  // 0x0192\n\t\t\t (IS_IMPLEMENTED+HANDLE_1_USER+ALLOW_TRIAL)),\n#endif\n#if (PAD_LIST || CC_EncryptDecrypt2)\n    (COMMAND_ATTRIBUTES)(CC_EncryptDecrypt2            *  // 0x0193\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+HANDLE_1_USER+ENCRYPT_2)),\n#endif\n\n#if (PAD_LIST || CC_Vendor_TCG_Test)\n    (COMMAND_ATTRIBUTES)(CC_Vendor_TCG_Test            *  // 0x0000\n\t\t\t (IS_IMPLEMENTED+DECRYPT_2+ENCRYPT_2)),\n#endif\n\n#ifdef TPM_TSS_NUVOTON\n#if (PAD_LIST || CC_NTC2_PreConfig)\n    (COMMAND_ATTRIBUTES)(CC_NTC2_PreConfig             *  // 0x20000211\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST || CC_NTC2_LockPreConfig)\n    (COMMAND_ATTRIBUTES)(CC_NTC2_LockPreConfig         *  // 0x20000212\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#if (PAD_LIST || CC_NTC2_GetConfig)\n    (COMMAND_ATTRIBUTES)(CC_NTC2_GetConfig             *  // 0x20000213\n\t\t\t (IS_IMPLEMENTED+NO_SESSIONS)),\n#endif\n#endif\t/* TPM_TSS_NUVOTON */\n\n    0\n};\n"
  },
  {
    "path": "ibmtss-ftpm/CommandAttributeData12.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Command Attributes Table for TPM 1.2\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2018 - 2019\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n\n#include <ibmtss/tpmconstants12.h>\n\n#include \"CommandAttributes.h\"\n#if defined COMPRESSED_LISTS\n#   define      PAD_LIST    0\n#else\n#   define      PAD_LIST    1\n#endif\n\n// This is the command code attribute array for GetCapability(). Both this array and\n// s_commandAttributes provides command code attributes, but tuned for different purpose\n\n/* bitfield is:\n   \n   command index\n   reserved\n   nv\n   extensive\n   flushed\n   cHandles not included in HMAC\n   rHandle not included in HMAC\n   V\n   reserved, flags TPM 1.2 command\n*/\n   \n#include \"tssccattributes.h\"\nconst TPMA_CC_TSS    s_ccAttr12 [] = {\n    \n    /*                                  R  N  E  F  C  R  V  R */\n\n    {{TPM_ORD_ActivateIdentity,\t\t0, 0, 0, 0, 1, 0, 0, 1}},\n    {{TPM_ORD_ContinueSelfTest,\t\t0, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_CreateEndorsementKeyPair,\t0, 1, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_CreateWrapKey,\t\t0, 0, 0, 0, 1, 0, 0, 1}},\n    {{TPM_ORD_Extend,\t\t\t0, 0, 0, 0, 1, 0, 0, 1}},\n    {{TPM_ORD_FlushSpecific,\t\t0, 0, 0, 0, 1, 0, 0, 1}},\n    {{TPM_ORD_GetCapability,\t\t0, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_LoadKey2, \t\t0, 0, 0, 0, 1, 1, 0, 1}},\n    {{TPM_ORD_MakeIdentity, \t\t0, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_NV_DefineSpace, \t\t1, 1, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_NV_ReadValueAuth,\t\t1, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_NV_ReadValue,\t\t1, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_NV_WriteValue,\t\t1, 1, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_NV_WriteValueAuth,\t1, 1, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_OIAP, \t\t\t0, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_OSAP, \t\t\t0, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_OwnerReadInternalPub,\t0, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_OwnerSetDisable, \t\t0, 1, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_PcrRead,\t\t\t0, 0, 0, 0, 1, 0, 0, 1}},\n    {{TPM_ORD_PCR_Reset,\t\t0, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_ReadPubek, \t\t0, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_Quote2, \t\t\t0, 0, 0, 0, 1, 0, 0, 1}},\n    {{TPM_ORD_Sign, \t\t\t0, 0, 0, 0, 1, 0, 0, 1}},\n    {{TPM_ORD_Startup, \t\t\t0, 1, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_TakeOwnership,\t\t0, 0, 0, 0, 0, 0, 0, 1}},\n    {{TPM_ORD_Init, \t\t\t0, 0, 0, 0, 0, 0, 0, 1}},\n\n    {{0x0000, \t\t\t\t0, 0, 0, 0, 0, 0, 0, 0}},     // kg - terminator?\n};\n\n"
  },
  {
    "path": "ibmtss-ftpm/Commands.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t  Command Parameter Unmarshaling\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  Licenses and Notices\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  1. Copyright Licenses:\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Trusted Computing Group (TCG) grants to the user of the source code in\t*/\n/*    this specification (the \"Source Code\") a worldwide, irrevocable, \t\t*/\n/*    nonexclusive, royalty free, copyright license to reproduce, create \t*/\n/*    derivative works, distribute, display and perform the Source Code and\t*/\n/*    derivative works thereof, and to grant others the rights granted herein.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - The TCG grants to the user of the other parts of the specification \t*/\n/*    (other than the Source Code) the rights to reproduce, distribute, \t*/\n/*    display, and perform the specification solely for the purpose of \t\t*/\n/*    developing products based on such documents.\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  2. Source Code Distribution Conditions:\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions of Source Code must retain the above copyright licenses, \t*/\n/*    this list of conditions and the following disclaimers.\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Redistributions in binary form must reproduce the above copyright \t*/\n/*    licenses, this list of conditions\tand the following disclaimers in the \t*/\n/*    documentation and/or other materials provided with the distribution.\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  3. Disclaimers:\t\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF\t*/\n/*  LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH\t*/\n/*  RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES)\t*/\n/*  THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE.\t\t*/\n/*  Contact TCG Administration (admin@trustedcomputinggroup.org) for \t\t*/\n/*  information on specification licensing rights available through TCG \t*/\n/*  membership agreements.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - THIS SPECIFICATION IS PROVIDED \"AS IS\" WITH NO EXPRESS OR IMPLIED \t*/\n/*    WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR \t*/\n/*    FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR \t\t*/\n/*    NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY \t\t*/\n/*    OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE.\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  - Without limitation, TCG and its members and licensors disclaim all \t*/\n/*    liability, including liability for infringement of any proprietary \t*/\n/*    rights, relating to use of information in this specification and to the\t*/\n/*    implementation of this specification, and TCG disclaims all liability for\t*/\n/*    cost of procurement of substitute goods or services, lost profits, loss \t*/\n/*    of use, loss of data or any incidental, consequential, direct, indirect, \t*/\n/*    or special damages, whether under contract, tort, warranty or otherwise, \t*/\n/*    arising in any way out of use or reliance upon this specification or any \t*/\n/*    information herein.\t\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*  (c) Copyright IBM Corp. and others, 2012 - 2024\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/********************************************************************************/\n\n/* The TSS using the command parameter unmarshaling to validate caller input parameters before\n   sending them to the TPM.\n\n   It is essentially the same as the TPM side code.\n*/\n\n#include \"Commands_fp.h\"\n#include <ibmtss/Parameters.h>\n\n#include <ibmtss/Unmarshal_fp.h>\n\n#ifndef TPM_TSS_NOCMDCHECK\n\n/*\n  In_Unmarshal - shared by TPM and TSS\n*/\n\nTPM_RC\nStartup_In_Unmarshal(Startup_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_SU_Unmarshalu(&target->startupType, buffer, size);\t\n\tif (rc != TPM_RC_SUCCESS) {\t\n\t    rc += RC_Startup_startupType;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nShutdown_In_Unmarshal(Shutdown_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_SU_Unmarshalu(&target->shutdownType, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Shutdown_shutdownType;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nSelfTest_In_Unmarshal(SelfTest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->fullTest, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SelfTest_fullTest;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nIncrementalSelfTest_In_Unmarshal(IncrementalSelfTest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_ALG_Unmarshalu(&target->toTest, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_IncrementalSelfTest_toTest;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nStartAuthSession_In_Unmarshal(StartAuthSession_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->tpmKey = handles[0];\n\ttarget->bind = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceCaller, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_StartAuthSession_nonceCaller;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->encryptedSalt, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_StartAuthSession_encryptedSalt;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_SE_Unmarshalu(&target->sessionType, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_StartAuthSession_sessionType;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SYM_DEF_Unmarshalu(&target->symmetric, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_StartAuthSession_symmetric;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->authHash, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_StartAuthSession_authHash;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyRestart_In_Unmarshal(PolicyRestart_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->sessionHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nCreate_In_Unmarshal(Create_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->parentHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(&target->inSensitive, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Create_inSensitive;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->inPublic, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Create_inPublic;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->outsideInfo, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Create_outsideInfo;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->creationPCR, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Create_creationPCR;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nLoad_In_Unmarshal(Load_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->parentHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->inPrivate, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Load_inPrivate;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->inPublic, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Load_inPublic;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nLoadExternal_In_Unmarshal(LoadExternal_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_SENSITIVE_Unmarshalu(&target->inPrivate, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_LoadExternal_inPrivate;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->inPublic, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_LoadExternal_inPublic;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_LoadExternal_hierarchy;\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nReadPublic_In_Unmarshal(ReadPublic_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->objectHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nActivateCredential_In_Unmarshal(ActivateCredential_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->activateHandle = handles[0];\n\ttarget->keyHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ID_OBJECT_Unmarshalu(&target->credentialBlob, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ActivateCredential_credentialBlob;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->secret, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ActivateCredential_secret;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nMakeCredential_In_Unmarshal(MakeCredential_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->handle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->credential, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_MakeCredential_credential;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->objectName, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_MakeCredential_objectName;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nUnseal_In_Unmarshal(Unseal_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->itemHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nObjectChangeAuth_In_Unmarshal(ObjectChangeAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->objectHandle = handles[0];\n\ttarget->parentHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->newAuth, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nCreateLoaded_In_Unmarshal(CreateLoaded_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->parentHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(&target->inSensitive, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Create_inSensitive;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_TEMPLATE_Unmarshalu(&target->inPublic, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CreateLoaded_inPublic;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nDuplicate_In_Unmarshal(Duplicate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->objectHandle = handles[0];\n\ttarget->newParentHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->encryptionKeyIn, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Duplicate_encryptionKeyIn;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetricAlg, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Duplicate_symmetricAlg;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nRewrap_In_Unmarshal(Rewrap_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->oldParent = handles[0];\n\ttarget->newParent = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->inDuplicate, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Rewrap_inDuplicate;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Rewrap_name;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->inSymSeed, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Rewrap_inSymSeed;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nImport_In_Unmarshal(Import_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->parentHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->encryptionKey, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->objectPublic, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Import_objectPublic;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->duplicate, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Import_duplicate;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->inSymSeed, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Import_inSymSeed;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetricAlg, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Import_symmetricAlg;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nRSA_Encrypt_In_Unmarshal(RSA_Encrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->message, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_RSA_Encrypt_message;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_RSA_DECRYPT_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_RSA_Encrypt_inScheme;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->label, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_RSA_Encrypt_label;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nRSA_Decrypt_In_Unmarshal(RSA_Decrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->cipherText, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_RSA_Decrypt_cipherText;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_RSA_DECRYPT_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_RSA_Decrypt_inScheme;\n\t}\n   }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->label, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_RSA_Decrypt_label;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nECDH_KeyGen_In_Unmarshal(ECDH_KeyGen_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nECDH_ZGen_In_Unmarshal(ECDH_ZGen_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->inPoint, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ECDH_ZGen_inPoint;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nECC_Encrypt_In_Unmarshal(ECC_Encrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->plainText, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ECC_Encrypt_plainText;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_KDF_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ECC_Encrypt_inScheme;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nECC_Decrypt_In_Unmarshal(ECC_Decrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->C1, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ECC_Decrypt_C1;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->C2, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ECC_Decrypt_C2;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->C3, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ECC_Decrypt_C3;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_KDF_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ECC_Decrypt_inScheme;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nECC_Parameters_In_Unmarshal(ECC_Parameters_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ECC_CURVE_Unmarshalu(&target->curveID, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ECC_Parameters_curveID;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nZGen_2Phase_In_Unmarshal(ZGen_2Phase_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyA = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->inQsB, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ZGen_2Phase_inQsB;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->inQeB, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ZGen_2Phase_inQeB;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ECC_KEY_EXCHANGE_Unmarshalu(&target->inScheme, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ZGen_2Phase_inScheme;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->counter, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ZGen_2Phase_counter;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nEncryptDecrypt_In_Unmarshal(EncryptDecrypt_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->decrypt, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EncryptDecrypt_decrypt;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->mode, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EncryptDecrypt_mode;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_IV_Unmarshalu(&target->ivIn, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EncryptDecrypt_ivIn;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->inData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EncryptDecrypt_inData;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nEncryptDecrypt2_In_Unmarshal(EncryptDecrypt2_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->inData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EncryptDecrypt2_inData;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->decrypt, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EncryptDecrypt2_decrypt;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->mode, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EncryptDecrypt2_mode;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_IV_Unmarshalu(&target->ivIn, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EncryptDecrypt2_ivIn;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nHash_In_Unmarshal(Hash_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->data, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Hash_data;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Hash_hashAlg;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Hash_hierarchy;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nHMAC_In_Unmarshal(HMAC_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->handle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->buffer, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_HMAC_buffer;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_HMAC_hashAlg;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nGetRandom_In_Unmarshal(GetRandom_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->bytesRequested, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetRandom_bytesRequested;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nStirRandom_In_Unmarshal(StirRandom_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->inData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_StirRandom_inData;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nHMAC_Start_In_Unmarshal(HMAC_Start_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->handle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->auth, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_HMAC_Start_auth;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_HMAC_Start_hashAlg;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nHashSequenceStart_In_Unmarshal(HashSequenceStart_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->auth, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_HashSequenceStart_auth;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_HashSequenceStart_hashAlg;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nSequenceUpdate_In_Unmarshal(SequenceUpdate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->sequenceHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->buffer, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SequenceUpdate_buffer;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nSequenceComplete_In_Unmarshal(SequenceComplete_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->sequenceHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->buffer, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SequenceComplete_buffer;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SequenceComplete_hierarchy;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nEventSequenceComplete_In_Unmarshal(EventSequenceComplete_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->pcrHandle = handles[0];\n\ttarget->sequenceHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->buffer, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EventSequenceComplete_buffer;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nCertify_In_Unmarshal(Certify_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->objectHandle = handles[0];\n\ttarget->signHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Certify_qualifyingData;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Certify_inScheme;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nCertifyX509_In_Unmarshal(CertifyX509_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->objectHandle = handles[0];\n\ttarget->signHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->reserved, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CertifyX509_reserved;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CertifyX509_inScheme;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->partialCertificate, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CertifyX509_partialCertificate;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nCertifyCreation_In_Unmarshal(CertifyCreation_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->signHandle = handles[0];\n\ttarget->objectHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CertifyCreation_creationHash;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->creationHash, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CertifyCreation_creationHash;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CertifyCreation_inScheme;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_CREATION_Unmarshalu(&target->creationTicket, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CertifyCreation_creationTicket;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nQuote_In_Unmarshal(Quote_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->signHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Quote_qualifyingData;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Quote_inScheme;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->PCRselect, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Quote_PCRselect;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nGetSessionAuditDigest_In_Unmarshal(GetSessionAuditDigest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->privacyAdminHandle = handles[0];\n\ttarget->signHandle = handles[1];\n\ttarget->sessionHandle = handles[2];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetSessionAuditDigest_qualifyingData;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetSessionAuditDigest_inScheme;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nGetCommandAuditDigest_In_Unmarshal(GetCommandAuditDigest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->privacyHandle = handles[0];\n\ttarget->signHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetCommandAuditDigest_qualifyingData;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetCommandAuditDigest_inScheme;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nGetTime_In_Unmarshal(GetTime_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->privacyAdminHandle = handles[0];\n\ttarget->signHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetTime_qualifyingData;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetTime_inScheme;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nCommit_In_Unmarshal(Commit_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->signHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->P1, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Commit_P1;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->s2, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Commit_s2;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->y2, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Commit_y2;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nEC_Ephemeral_In_Unmarshal(EC_Ephemeral_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ECC_CURVE_Unmarshalu(&target->curveID, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EC_Ephemeral_curveID;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nVerifySignature_In_Unmarshal(VerifySignature_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_VerifySignature_digest;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_VerifySignature_signature;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nSign_In_Unmarshal(Sign_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Sign_digest;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Sign_inScheme;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_HASHCHECK_Unmarshalu(&target->validation, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_Sign_validation;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nSetCommandCodeAuditStatus_In_Unmarshal(SetCommandCodeAuditStatus_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->auth = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->auditAlg, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SetCommandCodeAuditStatus_auditAlg;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_CC_Unmarshalu(&target->setList, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SetCommandCodeAuditStatus_setList;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_CC_Unmarshalu(&target->clearList, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SetCommandCodeAuditStatus_clearList;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPCR_Extend_In_Unmarshal(PCR_Extend_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->pcrHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_DIGEST_VALUES_Unmarshalu(&target->digests, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PCR_Extend_digests;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPCR_Event_In_Unmarshal(PCR_Event_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->pcrHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_EVENT_Unmarshalu(&target->eventData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PCR_Event_eventData;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPCR_Read_In_Unmarshal(PCR_Read_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrSelectionIn, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PCR_Read_pcrSelectionIn;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPCR_Allocate_In_Unmarshal(PCR_Allocate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrAllocation, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PCR_Allocate_pcrAllocation;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPCR_SetAuthPolicy_In_Unmarshal(PCR_SetAuthPolicy_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->authPolicy, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PCR_SetAuthPolicy_authPolicy;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PCR_SetAuthPolicy_hashAlg;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_DH_PCR_Unmarshalu(&target->pcrNum, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PCR_SetAuthPolicy_pcrNum;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPCR_SetAuthValue_In_Unmarshal(PCR_SetAuthValue_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->pcrHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->auth, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PCR_SetAuthValue_auth;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPCR_Reset_In_Unmarshal(PCR_Reset_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->pcrHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nPolicySigned_In_Unmarshal(PolicySigned_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authObject = handles[0];\n\ttarget->policySession = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceTPM, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicySigned_nonceTPM;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->cpHashA, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicySigned_cpHashA;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->policyRef, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicySigned_policyRef;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_INT32_Unmarshalu(&target->expiration, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicySigned_expiration;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->auth, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicySigned_auth;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicySecret_In_Unmarshal(PolicySecret_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n\ttarget->policySession = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceTPM, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicySecret_nonceTPM;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->cpHashA, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicySecret_cpHashA;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->policyRef, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicySecret_policyRef;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_INT32_Unmarshalu(&target->expiration, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicySecret_expiration;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyTicket_In_Unmarshal(PolicyTicket_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_TIMEOUT_Unmarshalu(&target->timeout, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyTicket_timeout;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->cpHashA, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyTicket_cpHashA;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->policyRef, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyTicket_policyRef;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->authName, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyTicket_authName;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_AUTH_Unmarshalu(&target->ticket, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyTicket_ticket;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyOR_In_Unmarshal(PolicyOR_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\t/* Policy OR requires at least two OR terms */\n\trc = TSS_TPML_DIGEST_Unmarshalu(&target->pHashList, buffer, size, 2);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyOR_pHashList;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyPCR_In_Unmarshal(PolicyPCR_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->pcrDigest, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyPCR_pcrDigest;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrs, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyPCR_pcrs;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyLocality_In_Unmarshal(PolicyLocality_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMA_LOCALITY_Unmarshalu(&target->locality, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyLocality_locality;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyNV_In_Unmarshal(PolicyNV_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n\ttarget->nvIndex = handles[1];\n\ttarget->policySession = handles[2];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_OPERAND_Unmarshalu(&target->operandB, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyNV_operandB;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyNV_offset;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_EO_Unmarshalu(&target->operation, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyNV_operation;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyAuthorizeNV_In_Unmarshal(PolicyAuthorizeNV_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n\ttarget->nvIndex = handles[1];\n\ttarget->policySession = handles[2];\n    }\n    return rc;\n}\nTPM_RC\nPolicyCounterTimer_In_Unmarshal(PolicyCounterTimer_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_OPERAND_Unmarshalu(&target->operandB, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCounterTimer_operandB;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCounterTimer_offset;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_EO_Unmarshalu(&target->operation, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCounterTimer_operation;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyCommandCode_In_Unmarshal(PolicyCommandCode_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_CC_Unmarshalu(&target->code, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCommandCode_code;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyPhysicalPresence_In_Unmarshal(PolicyPhysicalPresence_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nPolicyCpHash_In_Unmarshal(PolicyCpHash_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->cpHashA, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCpHash_cpHashA;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyNameHash_In_Unmarshal(PolicyNameHash_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->nameHash, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyNameHash_nameHash;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyDuplicationSelect_In_Unmarshal(PolicyDuplicationSelect_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->objectName, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyDuplicationSelect_objectName;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->newParentName, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyDuplicationSelect_newParentName;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->includeObject, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyDuplicationSelect_includeObject;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyAuthorize_In_Unmarshal(PolicyAuthorize_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->approvedPolicy, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyAuthorize_approvedPolicy;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->policyRef, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyAuthorize_policyRef;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->keySign, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyAuthorize_keySign;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_VERIFIED_Unmarshalu(&target->checkTicket, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyAuthorize_checkTicket;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyAuthValue_In_Unmarshal(PolicyAuthValue_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nPolicyPassword_In_Unmarshal(PolicyPassword_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nPolicyGetDigest_In_Unmarshal(PolicyGetDigest_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nPolicyNvWritten_In_Unmarshal(PolicyNvWritten_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->writtenSet, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyNvWritten_writtenSet;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyTemplate_In_Unmarshal(PolicyTemplate_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->templateHash, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyTemplate_templateHash;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyCapability_In_Unmarshal(PolicyCapability_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_OPERAND_Unmarshalu(&target->operandB, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCapability_operandB;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCapability_offset;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_EO_Unmarshalu(&target->operation, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCapability_operation;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_CAP_Unmarshalu(&target->capability, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCapability_capability;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->property, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyCapability_property;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPolicyParameters_In_Unmarshal(PolicyParameters_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->policySession = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->pHash, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PolicyParameters_pHash;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nCreatePrimary_In_Unmarshal(CreatePrimary_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->primaryHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(&target->inSensitive, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CreatePrimary_inSensitive;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->inPublic, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CreatePrimary_inPublic;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->outsideInfo, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CreatePrimary_outsideInfo;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->creationPCR, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_CreatePrimary_creationPCR;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nHierarchyControl_In_Unmarshal(HierarchyControl_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_ENABLES_Unmarshalu(&target->enable, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_HierarchyControl_enable;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->state, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_HierarchyControl_state;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nSetPrimaryPolicy_In_Unmarshal(SetPrimaryPolicy_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->authPolicy, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SetPrimaryPolicy_authPolicy;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SetPrimaryPolicy_hashAlg;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nChangePPS_In_Unmarshal(ChangePPS_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nChangeEPS_In_Unmarshal(ChangeEPS_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nClear_In_Unmarshal(Clear_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nClearControl_In_Unmarshal(ClearControl_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->auth = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->disable, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ClearControl_disable;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nHierarchyChangeAuth_In_Unmarshal(HierarchyChangeAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->newAuth, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_HierarchyChangeAuth_newAuth;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nDictionaryAttackLockReset_In_Unmarshal(DictionaryAttackLockReset_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->lockHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nDictionaryAttackParameters_In_Unmarshal(DictionaryAttackParameters_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->lockHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->newMaxTries, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_DictionaryAttackParameters_newMaxTries;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->newRecoveryTime, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_DictionaryAttackParameters_newRecoveryTime;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->lockoutRecovery, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_DictionaryAttackParameters_lockoutRecovery;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nPP_Commands_In_Unmarshal(PP_Commands_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->auth = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_CC_Unmarshalu(&target->setList, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PP_Commands_setList;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_CC_Unmarshalu(&target->clearList, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_PP_Commands_clearList;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nSetAlgorithmSet_In_Unmarshal(SetAlgorithmSet_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->algorithmSet, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_SetAlgorithmSet_algorithmSet;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nContextSave_In_Unmarshal(ContextSave_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->saveHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nContextLoad_In_Unmarshal(ContextLoad_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_CONTEXT_Unmarshalu(&target->context, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ContextLoad_context;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nFlushContext_In_Unmarshal(FlushContext_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_DH_CONTEXT_Unmarshalu(&target->flushHandle, buffer, size, NO);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_FlushContext_flushHandle;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nEvictControl_In_Unmarshal(EvictControl_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->auth = handles[0];\n\ttarget->objectHandle = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_DH_PERSISTENT_Unmarshalu(&target->persistentHandle, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_EvictControl_persistentHandle;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nClockSet_In_Unmarshal(ClockSet_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->auth = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT64_Unmarshalu(&target->newTime, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ClockSet_newTime;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nClockRateAdjust_In_Unmarshal(ClockRateAdjust_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->auth = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_CLOCK_ADJUST_Unmarshalu(&target->rateAdjust, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_ClockRateAdjust_rateAdjust;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nGetCapability_In_Unmarshal(GetCapability_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_CAP_Unmarshalu(&target->capability, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetCapability_capability;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->property, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetCapability_property;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->propertyCount, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_GetCapability_propertyCount;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nTestParms_In_Unmarshal(TestParms_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_PUBLIC_PARMS_Unmarshalu(&target->parameters, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_TestParms_parameters;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nNV_DefineSpace_In_Unmarshal(NV_DefineSpace_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->auth, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_DefineSpace_auth;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NV_PUBLIC_Unmarshalu(&target->publicInfo, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_DefineSpace_publicInfo;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nNV_UndefineSpace_In_Unmarshal(NV_UndefineSpace_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n\ttarget->nvIndex = handles[1];\n    }\n    return rc;\n}\nTPM_RC\nNV_UndefineSpaceSpecial_In_Unmarshal(NV_UndefineSpaceSpecial_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->nvIndex = handles[0];\n\ttarget->platform = handles[1];\n    }\n    return rc;\n}\nTPM_RC\nNV_ReadPublic_In_Unmarshal(NV_ReadPublic_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->nvIndex = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nNV_Write_In_Unmarshal(NV_Write_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n\ttarget->nvIndex = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(&target->data, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_Write_data;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_Write_offset;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nNV_Increment_In_Unmarshal(NV_Increment_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n\ttarget->nvIndex = handles[1];\n    }\n    return rc;\n}\nTPM_RC\nNV_Extend_In_Unmarshal(NV_Extend_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n \ttarget->nvIndex = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(&target->data, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_Extend_data;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nNV_SetBits_In_Unmarshal(NV_SetBits_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n\ttarget->nvIndex = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT64_Unmarshalu(&target->bits, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_SetBits_bits;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nNV_WriteLock_In_Unmarshal(NV_WriteLock_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n\ttarget->nvIndex = handles[1];\n    }\n    return rc;\n}\nTPM_RC\nNV_GlobalWriteLock_In_Unmarshal(NV_GlobalWriteLock_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n    }\n    return rc;\n}\nTPM_RC\nNV_Read_In_Unmarshal(NV_Read_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n \ttarget->nvIndex = handles[1];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->size, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_Read_size;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_Read_offset;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nNV_ReadLock_In_Unmarshal(NV_ReadLock_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    buffer = buffer;\n    size = size;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->authHandle = handles[0];\n \ttarget->nvIndex = handles[1];\n    }\n    return rc;\n}\nTPM_RC\nNV_ChangeAuth_In_Unmarshal(NV_ChangeAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->nvIndex = handles[0];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->newAuth, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_ChangeAuth_newAuth;\n\t}\n    }\n    return rc;\n}\nTPM_RC\nNV_Certify_In_Unmarshal(NV_Certify_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\ttarget->signHandle = handles[0];\n\ttarget->authHandle = handles[1];\n\ttarget->nvIndex = handles[2];\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->qualifyingData, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_Certify_qualifyingData;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIG_SCHEME_Unmarshalu(&target->inScheme, buffer, size, YES);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_Certify_inScheme;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->size, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_Certify_size;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size);\n\tif (rc != TPM_RC_SUCCESS) {\n\t    rc += RC_NV_Certify_offset;\n\t}\n    }\n    return rc;\n}\n\n#endif /* TPM_TSS_NOCMDCHECK */\n"
  },
  {
    "path": "ibmtss-ftpm/Commands12.c",
    "content": "/********************************************************************************/\n/*                                                                              */\n/*                              \t                                   \t*/\n/*                           Written by Ken Goldman                             */\n/*                     IBM Thomas J. Watson Research Center                     */\n/*            $Id: Commands12.c 1285 2018-07-27 18:33:41Z kgoldman $         \t*/\n/*                                                                              */\n/* (c) Copyright IBM Corporation 2018\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include \"Commands12_fp.h\"\n#include <ibmtss/Parameters.h>\n\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/Unmarshal12_fp.h>\n\nCOMMAND_PARAMETERS in;\nRESPONSE_PARAMETERS out;\n\n/*\n  In_Unmarshal\n*/\n\nTPM_RC\nActivateIdentity_In_Unmarshal(ActivateIdentity_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n    if (rc == 0) {\n\ttarget->idKeyHandle = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->blobSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\tif (target->blobSize > sizeof(target->blob)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->blob, target->blobSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nCreateEndorsementKeyPair_In_Unmarshal(CreateEndorsementKeyPair_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->antiReplay, TPM_NONCE_SIZE, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_KEY_PARMS_Unmarshalu(&target->keyInfo, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nCreateWrapKey_In_Unmarshal(CreateWrapKey_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\ttarget->parentHandle = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->dataUsageAuth, SHA1_DIGEST_SIZE, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->dataMigrationAuth, SHA1_DIGEST_SIZE, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Unmarshalu(&target->keyInfo, buffer, size);\n    \tif (rc != 0) {\n    \t    rc += (TPM_RC_P + TPM_RC_3);\n    \t}\n    }\n    return rc;\n}\n\nTPM_RC\nExtend_In_Unmarshal(Extend_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\ttarget->pcrNum = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->inDigest, SHA1_DIGEST_SIZE, buffer, size);\n    \tif (rc != 0) {\n    \t    rc += (TPM_RC_P + TPM_RC_1);\n    \t}\n    }\n    return rc;\n}\n\nTPM_RC\nFlushSpecific_In_Unmarshal(FlushSpecific_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\ttarget->handle = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->resourceType, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nGetCapability12_In_Unmarshal(GetCapability12_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->capArea, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->subCapSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    if (rc == 0) {\n\tif (target->subCapSize > sizeof(target->subCap)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->subCap, target->subCapSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_3);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nLoadKey2_In_Unmarshal(LoadKey2_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\ttarget->parentHandle = handles[0];\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Unmarshalu(&target->inKey, buffer, size);\n    \tif (rc != 0) {\n    \t    rc += (TPM_RC_P + TPM_RC_1);\n    \t}\n    }\n    return rc;\n}\n\nTPM_RC\nMakeIdentity_In_Unmarshal(MakeIdentity_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->identityAuth, SHA1_DIGEST_SIZE, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->labelPrivCADigest, SHA1_DIGEST_SIZE, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Unmarshalu(&target->idKeyParams, buffer, size);\n    \tif (rc != 0) {\n    \t    rc += (TPM_RC_P + TPM_RC_3);\n    \t}\n    }\n    return rc;\n}\n\nTPM_RC\nNV_DefineSpace12_In_Unmarshal(NV_DefineSpace12_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n    if (rc == 0) {\n\trc = TSS_TPM_NV_DATA_PUBLIC_Unmarshalu(&target->pubInfo, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->encAuth, SHA1_DIGEST_SIZE, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nNV_ReadValueAuth_In_Unmarshal(NV_ReadValueAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\ttarget->nvIndex = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->offset, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->dataSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nNV_ReadValue_In_Unmarshal(NV_ReadValue_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\ttarget->nvIndex = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->offset, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->dataSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nNV_WriteValue_In_Unmarshal(NV_WriteValue_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\ttarget->nvIndex = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->offset, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->dataSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    if (rc == 0) {\n\tif (target->dataSize > sizeof(target->data)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->data, target->dataSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_3);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nNV_WriteValueAuth_In_Unmarshal(NV_WriteValueAuth_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\ttarget->nvIndex = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->offset, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->dataSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    if (rc == 0) {\n\tif (target->dataSize > sizeof(target->data)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->data, target->dataSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_3);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nOSAP_In_Unmarshal(OSAP_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->entityType, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->entityValue, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->nonceOddOSAP, SHA1_DIGEST_SIZE, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_3);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nOwnerSetDisable_In_Unmarshal(OwnerSetDisable_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->disableState, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nOwnerReadInternalPub_In_Unmarshal(OwnerReadInternalPub_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->keyHandle , buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nPcrRead12_In_Unmarshal(PcrRead12_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    buffer = buffer;\n    size = size;\n\n    if (rc == 0) {\n\ttarget->pcrIndex = handles[0];\n    }\n    return rc;\n}\n\nTPM_RC\nPCR_Reset12_In_Unmarshal(PCR_Reset12_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n    if (rc == 0) {\n    \trc = TSS_TPM_PCR_SELECTION_Unmarshalu(&target->pcrSelection, buffer, size);\n    \tif (rc != 0) {\n    \t    rc += (TPM_RC_P + TPM_RC_1);\n    \t}\n    }\n    return rc;\n}\n\nTPM_RC\nQuote2_In_Unmarshal(Quote2_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->externalData, SHA1_DIGEST_SIZE, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_SELECTION_Unmarshalu(&target->targetPCR, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->addVersion, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_3);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nReadPubek_In_Unmarshal(ReadPubek_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->antiReplay, TPM_NONCE_SIZE, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nSign12_In_Unmarshal(Sign12_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\ttarget->keyHandle = handles[0];\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->areaToSignSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    if (rc == 0) {\n\tif (target->areaToSignSize > sizeof(target->areaToSign)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->areaToSign, target->areaToSignSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nStartup12_In_Unmarshal(Startup12_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n    if (rc == 0) {\n\trc = TSS_TPM_STARTUP_TYPE_Unmarshalu(&target->startupType, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nTakeOwnership_In_Unmarshal(TakeOwnership_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = 0;\n    handles = handles;\n\n   if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->protocolID, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_1);\n\t}\n    }\n   if (rc == 0) {\n       rc = TSS_UINT32_Unmarshalu(&target->encOwnerAuthSize, buffer, size);\t\n       if (rc != 0) {\t\n\t   rc += (TPM_RC_P + TPM_RC_1);\n       }\n   }\n     if (rc == 0) {\n\t if (target->encOwnerAuthSize > sizeof(target->encOwnerAuth)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->encOwnerAuth, target->encOwnerAuthSize , buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_2);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->encSrkAuthSize, buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_3);\n\t}\n    }\n    if (rc == 0) {\n\tif (target->encSrkAuthSize > sizeof(target->encSrkAuth)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->encSrkAuth, target->encSrkAuthSize , buffer, size);\t\n\tif (rc != 0) {\t\n\t    rc += (TPM_RC_P + TPM_RC_4);\n\t}\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Unmarshalu(&target->srkParams, buffer, size);\n    \tif (rc != 0) {\n    \t    rc += (TPM_RC_P + TPM_RC_5);\n    \t}\n    }\n    return rc;\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/Makefile.am",
    "content": "transform=s&^&tss&\n\ncheck-local:\n\t./reg.sh -a\n\n\nlib_LTLIBRARIES = libibmtss.la\n#if CONFIG_TPM20\nlib_LTLIBRARIES += libibmtssutils.la\n#endif\n\n# default TSS Library\nlibibmtss_la_SOURCES = tssfile.c tsscryptoh.c tsscrypto.c\nlibibmtss_la_LIBADD = $(LIBCRYPTO_LIBS)\n\n# TSS shared library object files (utils/makefile-common)\nlibibmtss_la_SOURCES += tss.c tssproperties.c tssmarshal.c tssauth.c tssutils.c tsssocket.c tssdev.c tsstransmit.c tssresponsecode.c tssccattributes.c tssprint.c Unmarshal.c CommandAttributeData.c\n\n# TPM 2.0\n# TSS share libarary object files\nif CONFIG_TPM20\nlibibmtss_la_SOURCES += tss20.c tssauth20.c Commands.c tssprintcmd.c\nlibibmtss_la_SOURCES += ntc2lib.c tssntc.c\nendif\n\n# (from utils/makefile-common12)\nif CONFIG_TPM12\nlibibmtss_la_SOURCES += tss12.c tssauth12.c tssmarshal12.c Unmarshal12.c Commands12.c tssccattributes12.c CommandAttributeData12.c\nendif\n\nlibibmtss_la_CFLAGS = -fPIC\nif CONFIG_HWTPM\nlibibmtss_la_CFLAGS += -DTPM_INTERFACE_TYPE_DEFAULT=\"\\\"dev\\\"\"\nendif\n\nif CONFIG_RMTPM\nlibibmtss_la_CFLAGS += -DTPM_DEVICE_DEFAULT=\"\\\"/dev/tpmrm0\\\"\"\nendif\n\nif CONFIG_TPM20\nlibibmtss_la_CFLAGS += -DTPM_TPM20 -DTPM_TSS_NUVOTON\nendif\n\nif CONFIG_TPM12\nlibibmtss_la_CFLAGS += -DTPM_TPM12\nendif\n\nif CONFIG_TSS_NOPRINT\nlibibmtss_la_CFLAGS += -DTPM_TSS_NO_PRINT\nendif\n\nif CONFIG_TSS_NOFILE\nlibibmtss_la_CFLAGS += -DTPM_TSS_NOFILE\nif CONFIG_TSS_NOCRYPTO\nlibibmtss_la_CFLAGS += -DTPM_TSS_NOCRYPTO\nendif\nendif\n\nif CONFIG_TSS_NOECC\nlibibmtss_la_CFLAGS += -DTPM_TSS_NOECC\nendif\n\nif CONFIG_TSS_NODEPRECATEDALGS\nlibibmtss_la_CFLAGS += -DTPM_TSS_NODEPRECATEDALGS\nendif\n\nlibibmtss_la_CCFLAGS = -Wall -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wformat=2 -Wold-style-definition -Wno-self-assign -ggdb\nlibibmtss_la_LDFLAGS = -version-info @TSSLIB_VERSION_INFO@\n\nlibibmtssutils_la_SOURCES = cryptoutils.c ekutils.c imalib.c eventlib.c efilib.c\nlibibmtssutils_la_CFLAGS = -fPIC $(EFIBOOT_CFLAGS)\n\nif CONFIG_TPM20\nlibibmtssutils_la_CFLAGS += -DTPM_TPM20 -DTPM_TSS_NUVOTON\nendif\n\nif CONFIG_TPM12\nlibibmtssutils_la_CFLAGS += -DTPM_TPM12\nendif\n\nif CONFIG_TSS_NOECC\nlibibmtssutils_la_CFLAGS += -DTPM_TSS_NOECC\nendif\n\nif CONFIG_TSS_NODEPRECATEDALGS\nlibibmtssutils_la_CFLAGS += -DTPM_TSS_NODEPRECATEDALGS\nendif\n\n#current[:revision[:age]]\n#result: [current-age].age.revision\nlibibmtssutils_la_LDFLAGS = -version-info @TSSLIB_VERSION_INFO@\nlibibmtssutils_la_LIBADD = libibmtss.la $(LIBCRYPTO_LIBS) $(EFIBOOT_LIBS)\n\nnoinst_HEADERS = CommandAttributes.h imalib.h tssdev.h ntc2lib.h tssntc.h Commands_fp.h objecttemplates.h tssproperties.h cryptoutils.h Platform.h tssauth.h tsssocket.h ekutils.h eventlib.h efilib.h tssccattributes.h\n# install every header in ibmtss\nnobase_include_HEADERS = ibmtss/*.h\n\nnotrans_man_MANS = man/man1/*.1\n\nif CONFIG_TPM20\nnoinst_HEADERS += tss20.h tssauth20.h ibmtss/tssprintcmd.h\nendif\n\nif CONFIG_TPM12\nnoinst_HEADERS += tss12.h Commands12_fp.h tssauth12.h tssccattributes12.h ibmtss/Unmarshal12_fp.h ibmtss/Parameters12.h ibmtss/tpmstructures12.h ibmtss/tpmconstants12.h ibmtss/tpmtypes12.h\nendif\n\nif CONFIG_TPM20\nif !CONFIG_TSS_NOPRINT\nbin_PROGRAMS = activatecredential eventextend imaextend certify certifycreation certifyx509 \\\n\tchangeeps changepps clear clearcontrol clockrateadjust clockset commit contextload \\\n\tcontextsave create createloaded createprimary dictionaryattacklockreset \\\n\tdictionaryattackparameters duplicate eccparameters eccencrypt eccdecrypt ecephemeral \\\n\tencryptdecrypt eventsequencecomplete evictcontrol flushcontext getcommandauditdigest \\\n\tgetcapability getcryptolibrary getrandom gettestresult getsessionauditdigest gettime \\\n\thashsequencestart hash hierarchycontrol hierarchychangeauth hmac hmacstart import \\\n\timportpem load loadexternal makecredential nvcertify nvchangeauth nvdefinespace \\\n\tnvextend nvglobalwritelock nvincrement nvread nvreadlock nvreadpublic nvsetbits \\\n\tnvundefinespace nvundefinespacespecial nvwrite nvwritelock objectchangeauth \\\n\tpcrallocate pcrevent pcrextend pcrread pcrreset policyauthorize policyauthvalue \\\n\tpolicycapability policycommandcode policycphash policynamehash policycountertimer \\\n\tpolicyduplicationselect policygetdigest policymaker policymakerpcr policyauthorizenv \\\n\tpolicynv policynvwritten policyor policypassword policyparameters policypcr policyrestart \\\n\tpolicysigned policysecret policytemplate policyticket quote powerup readclock \\\n\treadpublic returncode rewrap rsadecrypt rsaencrypt sequenceupdate sequencecomplete \\\n\tsetcommandcodeauditstatus setprimarypolicy shutdown sign startauthsession startup \\\n\tstirrandom unseal verifysignature zgen2phase signapp writeapp createek createekcert \\\n\ttpm2pem tpmpublic2eccpoint ntc2getconfig ntc2preconfig ntc2lockconfig publicname \\\n\ttpmcmd printattr tpmproxy\n\nif !CONFIG_TSS_NOFILE\nbin_PROGRAMS += timepacket\nendif\n\nUTILS_CFLAGS =\n\nif CONFIG_TSS_NOECC\nUTILS_CFLAGS += -DTPM_TSS_NOECC\nendif\n\nif CONFIG_TSS_NODEPRECATEDALGS\nUTILS_CFLAGS += -DTPM_TSS_NODEPRECATEDALGS\nendif\n\nactivatecredential_SOURCES = activatecredential.c\nactivatecredential_CFLAGS = $(UTILS_CFLAGS)\nactivatecredential_LDADD = libibmtssutils.la libibmtss.la\n\neventextend_SOURCES = eventextend.c\neventextend_CFLAGS = $(UTILS_CFLAGS)\neventextend_LDADD = libibmtssutils.la libibmtss.la\n\nimaextend_SOURCES = imaextend.c\nimaextend_CFLAGS = $(UTILS_CFLAGS)\nimaextend_LDADD = libibmtssutils.la libibmtss.la\n\ncertify_SOURCES = certify.c\ncertify_CFLAGS = $(UTILS_CFLAGS)\ncertify_LDADD = libibmtssutils.la libibmtss.la\n\ncertifycreation_SOURCES = certifycreation.c\ncertifycreation_CFLAGS = $(UTILS_CFLAGS)\ncertifycreation_LDADD = libibmtssutils.la libibmtss.la\n\ncertifyx509_SOURCES = certifyx509.c\ncertifyx509_CFLAGS = $(UTILS_CFLAGS)\ncertifyx509_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\n\nchangeeps_SOURCES = changeeps.c\nchangeeps_CFLAGS = $(UTILS_CFLAGS)\nchangeeps_LDADD = libibmtssutils.la libibmtss.la\n\nchangepps_SOURCES = changepps.c\nchangepps_CFLAGS = $(UTILS_CFLAGS) -DTPM_POSIX\nchangepps_LDADD = libibmtssutils.la libibmtss.la\n\nclear_SOURCES = clear.c\nclear_CFLAGS = $(UTILS_CFLAGS)\nclear_LDADD = libibmtssutils.la libibmtss.la\n\nclearcontrol_SOURCES = clearcontrol.c\nclearcontrol_CFLAGS = $(UTILS_CFLAGS)\nclearcontrol_LDADD = libibmtssutils.la libibmtss.la\n\nclockrateadjust_SOURCES = clockrateadjust.c\nclockrateadjust_CFLAGS = $(UTILS_CFLAGS)\nclockrateadjust_LDADD = libibmtssutils.la libibmtss.la\n\nclockset_SOURCES = clockset.c\nclockset_CFLAGS = $(UTILS_CFLAGS)\nclockset_LDADD = libibmtssutils.la libibmtss.la\n\ncommit_SOURCES = commit.c\ncommit_CFLAGS = $(UTILS_CFLAGS)\ncommit_LDADD = libibmtssutils.la libibmtss.la\n\ncontextload_SOURCES = contextload.c\ncontextload_CFLAGS = $(UTILS_CFLAGS)\ncontextload_LDADD = libibmtssutils.la libibmtss.la\n\ncontextsave_SOURCES = contextsave.c\ncontextsave_CFLAGS = $(UTILS_CFLAGS)\ncontextsave_LDADD = libibmtssutils.la libibmtss.la\n\ncreate_SOURCES = create.c objecttemplates.c\ncreate_CFLAGS = $(UTILS_CFLAGS)\ncreate_LDADD = libibmtssutils.la libibmtss.la\n\ncreateloaded_SOURCES = createloaded.c objecttemplates.c\ncreateloaded_CFLAGS = $(UTILS_CFLAGS)\ncreateloaded_LDADD = libibmtssutils.la libibmtss.la\n\ncreateprimary_SOURCES = createprimary.c objecttemplates.c\ncreateprimary_CFLAGS = $(UTILS_CFLAGS)\ncreateprimary_LDADD = libibmtssutils.la libibmtss.la\n\ndictionaryattacklockreset_SOURCES = dictionaryattacklockreset.c\ndictionaryattacklockreset_CFLAGS = $(UTILS_CFLAGS)\ndictionaryattacklockreset_LDADD = libibmtssutils.la libibmtss.la\n\ndictionaryattackparameters_SOURCES = dictionaryattackparameters.c\ndictionaryattackparameters_CFLAGS = $(UTILS_CFLAGS)\ndictionaryattackparameters_LDADD = libibmtssutils.la libibmtss.la\n\nduplicate_SOURCES = duplicate.c\nduplicate_CFLAGS = $(UTILS_CFLAGS)\nduplicate_LDADD = libibmtssutils.la libibmtss.la\n\neccparameters_SOURCES = eccparameters.c\neccparameters_CFLAGS = $(UTILS_CFLAGS)\neccparameters_LDADD = libibmtssutils.la libibmtss.la\n\neccencrypt_SOURCES = eccencrypt.c\neccencrypt_CFLAGS = $(UTILS_CFLAGS)\neccencrypt_LDADD = libibmtssutils.la libibmtss.la\n\neccdecrypt_SOURCES = eccdecrypt.c\neccdecrypt_CFLAGS = $(UTILS_CFLAGS)\neccdecrypt_LDADD = libibmtssutils.la libibmtss.la\n\necephemeral_SOURCES = ecephemeral.c\necephemeral_CFLAGS = $(UTILS_CFLAGS)\necephemeral_LDADD = libibmtssutils.la libibmtss.la\n\nencryptdecrypt_SOURCES = encryptdecrypt.c\nencryptdecrypt_CFLAGS = $(UTILS_CFLAGS)\nencryptdecrypt_LDADD = libibmtssutils.la libibmtss.la\n\neventsequencecomplete_SOURCES = eventsequencecomplete.c\neventsequencecomplete_CFLAGS = $(UTILS_CFLAGS)\neventsequencecomplete_LDADD = libibmtssutils.la libibmtss.la\n\nevictcontrol_SOURCES = evictcontrol.c\nevictcontrol_CFLAGS = $(UTILS_CFLAGS)\nevictcontrol_LDADD = libibmtssutils.la libibmtss.la\n\nflushcontext_SOURCES = flushcontext.c\nflushcontext_CFLAGS = $(UTILS_CFLAGS)\nflushcontext_LDADD = libibmtssutils.la libibmtss.la\n\ngetcommandauditdigest_SOURCES = getcommandauditdigest.c\ngetcommandauditdigest_CFLAGS = $(UTILS_CFLAGS)\ngetcommandauditdigest_LDADD = libibmtssutils.la libibmtss.la\n\ngetcapability_SOURCES = getcapability.c\ngetcapability_CFLAGS = $(UTILS_CFLAGS)\ngetcapability_LDADD = libibmtssutils.la libibmtss.la\n\ngetcryptolibrary_SOURCES = getcryptolibrary.c\ngetcryptolibrary_CFLAGS = $(UTILS_CFLAGS)\ngetcryptolibrary_LDADD = libibmtssutils.la libibmtss.la\n\ngetrandom_SOURCES = getrandom.c\ngetrandom_CFLAGS = $(UTILS_CFLAGS)\ngetrandom_LDADD = libibmtssutils.la libibmtss.la\n\ngettestresult_SOURCES = gettestresult.c\ngettestresult_CFLAGS = $(UTILS_CFLAGS)\ngettestresult_LDADD = libibmtssutils.la libibmtss.la\n\ngetsessionauditdigest_SOURCES = getsessionauditdigest.c\ngetsessionauditdigest_CFLAGS = $(UTILS_CFLAGS)\ngetsessionauditdigest_LDADD = libibmtssutils.la libibmtss.la\n\ngettime_SOURCES = gettime.c\ngettime_CFLAGS = $(UTILS_CFLAGS)\ngettime_LDADD = libibmtssutils.la libibmtss.la\n\nhashsequencestart_SOURCES = hashsequencestart.c\nhashsequencestart_CFLAGS = $(UTILS_CFLAGS)\nhashsequencestart_LDADD = libibmtssutils.la libibmtss.la\n\nhash_SOURCES = hash.c\nhash_CFLAGS = $(UTILS_CFLAGS)\nhash_LDADD = libibmtssutils.la libibmtss.la\n\nhierarchycontrol_SOURCES = hierarchycontrol.c\nhierarchycontrol_CFLAGS = $(UTILS_CFLAGS)\nhierarchycontrol_LDADD = libibmtssutils.la libibmtss.la\n\nhierarchychangeauth_SOURCES = hierarchychangeauth.c\nhierarchychangeauth_CFLAGS = $(UTILS_CFLAGS)\nhierarchychangeauth_LDADD = libibmtssutils.la libibmtss.la\n\nhmac_SOURCES = hmac.c\nhmac_CFLAGS = $(UTILS_CFLAGS)\nhmac_LDADD = libibmtssutils.la libibmtss.la\n\nhmacstart_SOURCES = hmacstart.c\nhmacstart_CFLAGS = $(UTILS_CFLAGS)\nhmacstart_LDADD = libibmtssutils.la libibmtss.la\n\nimport_SOURCES = import.c\nimport_CFLAGS = $(UTILS_CFLAGS)\nimport_LDADD = libibmtssutils.la libibmtss.la\n\nimportpem_SOURCES = importpem.c objecttemplates.c\nimportpem_CFLAGS = $(UTILS_CFLAGS)\nimportpem_LDADD = libibmtssutils.la libibmtss.la\n\nload_SOURCES = load.c\nload_CFLAGS = $(UTILS_CFLAGS)\nload_LDADD = libibmtssutils.la libibmtss.la\n\nloadexternal_SOURCES = loadexternal.c\nloadexternal_CFLAGS = $(UTILS_CFLAGS)\nloadexternal_LDADD = libibmtssutils.la libibmtss.la\n\nmakecredential_SOURCES = makecredential.c\nmakecredential_CFLAGS = $(UTILS_CFLAGS)\nmakecredential_LDADD = libibmtssutils.la libibmtss.la\n\nnvcertify_SOURCES = nvcertify.c\nnvcertify_CFLAGS = $(UTILS_CFLAGS)\nnvcertify_LDADD = libibmtssutils.la libibmtss.la\n\nnvchangeauth_SOURCES = nvchangeauth.c\nnvchangeauth_CFLAGS = $(UTILS_CFLAGS)\nnvchangeauth_LDADD = libibmtssutils.la libibmtss.la\n\nnvdefinespace_SOURCES = nvdefinespace.c\nnvdefinespace_CFLAGS = $(UTILS_CFLAGS)\nnvdefinespace_LDADD = libibmtssutils.la libibmtss.la\n\nnvextend_SOURCES = nvextend.c\nnvextend_CFLAGS = $(UTILS_CFLAGS)\nnvextend_LDADD = libibmtssutils.la libibmtss.la\n\nnvglobalwritelock_SOURCES = nvglobalwritelock.c\nnvglobalwritelock_CFLAGS = $(UTILS_CFLAGS)\nnvglobalwritelock_LDADD = libibmtssutils.la libibmtss.la\n\nnvincrement_SOURCES = nvincrement.c\nnvincrement_CFLAGS = $(UTILS_CFLAGS)\nnvincrement_LDADD = libibmtssutils.la libibmtss.la\n\nnvread_SOURCES = nvread.c\nnvread_CFLAGS = $(UTILS_CFLAGS)\nnvread_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\n\nnvreadlock_SOURCES = nvreadlock.c\nnvreadlock_CFLAGS = $(UTILS_CFLAGS)\nnvreadlock_LDADD = libibmtssutils.la libibmtss.la\n\nnvreadpublic_SOURCES = nvreadpublic.c\nnvreadpublic_CFLAGS = $(UTILS_CFLAGS)\nnvreadpublic_LDADD = libibmtssutils.la libibmtss.la\n\nnvsetbits_SOURCES = nvsetbits.c\nnvsetbits_CFLAGS = $(UTILS_CFLAGS)\nnvsetbits_LDADD = libibmtssutils.la libibmtss.la\n\nnvundefinespace_SOURCES = nvundefinespace.c\nnvundefinespace_CFLAGS = $(UTILS_CFLAGS)\nnvundefinespace_LDADD = libibmtssutils.la libibmtss.la\n\nnvundefinespacespecial_SOURCES = nvundefinespacespecial.c\nnvundefinespacespecial_CFLAGS = $(UTILS_CFLAGS)\nnvundefinespacespecial_LDADD = libibmtssutils.la libibmtss.la\n\nnvwrite_SOURCES = nvwrite.c\nnvwrite_CFLAGS = $(UTILS_CFLAGS)\nnvwrite_LDADD = libibmtssutils.la libibmtss.la\n\nnvwritelock_SOURCES = nvwritelock.c\nnvwritelock_CFLAGS = $(UTILS_CFLAGS)\nnvwritelock_LDADD = libibmtssutils.la libibmtss.la\n\nobjectchangeauth_SOURCES = objectchangeauth.c\nobjectchangeauth_CFLAGS = $(UTILS_CFLAGS)\nobjectchangeauth_LDADD = libibmtssutils.la libibmtss.la\n\npcrallocate_SOURCES = pcrallocate.c\npcrallocate_CFLAGS = $(UTILS_CFLAGS)\npcrallocate_LDADD = libibmtssutils.la libibmtss.la\n\npcrevent_SOURCES = pcrevent.c\npcrevent_CFLAGS = $(UTILS_CFLAGS)\npcrevent_LDADD = libibmtssutils.la libibmtss.la\n\npcrextend_SOURCES = pcrextend.c\npcrextend_CFLAGS = $(UTILS_CFLAGS)\npcrextend_LDADD = libibmtssutils.la libibmtss.la\n\npcrread_SOURCES = pcrread.c\npcrread_CFLAGS = $(UTILS_CFLAGS)\npcrread_LDADD = libibmtssutils.la libibmtss.la\n\npcrreset_SOURCES = pcrreset.c\npcrreset_CFLAGS = $(UTILS_CFLAGS)\npcrreset_LDADD = libibmtssutils.la libibmtss.la\n\npolicyauthorize_SOURCES = policyauthorize.c\npolicyauthorize_CFLAGS = $(UTILS_CFLAGS)\npolicyauthorize_LDADD = libibmtssutils.la libibmtss.la\n\npolicyauthvalue_SOURCES = policyauthvalue.c\npolicyauthvalue_CFLAGS = $(UTILS_CFLAGS)\npolicyauthvalue_LDADD = libibmtssutils.la libibmtss.la\n\npolicycapability_SOURCES = policycapability.c\npolicycapability_CFLAGS = $(UTILS_CFLAGS)\npolicycapability_LDADD = libibmtssutils.la libibmtss.la\n\npolicycommandcode_SOURCES = policycommandcode.c\npolicycommandcode_CFLAGS = $(UTILS_CFLAGS)\npolicycommandcode_LDADD = libibmtssutils.la libibmtss.la\n\npolicycphash_SOURCES = policycphash.c\npolicycphash_CFLAGS = $(UTILS_CFLAGS)\npolicycphash_LDADD = libibmtssutils.la libibmtss.la\n\npolicynamehash_SOURCES = policynamehash.c\npolicynamehash_CFLAGS = $(UTILS_CFLAGS)\npolicynamehash_LDADD = libibmtssutils.la libibmtss.la\n\npolicycountertimer_SOURCES = policycountertimer.c\npolicycountertimer_CFLAGS = $(UTILS_CFLAGS)\npolicycountertimer_LDADD = libibmtssutils.la libibmtss.la\n\npolicyduplicationselect_SOURCES = policyduplicationselect.c\npolicyduplicationselect_CFLAGS = $(UTILS_CFLAGS)\npolicyduplicationselect_LDADD = libibmtssutils.la libibmtss.la\n\npolicygetdigest_SOURCES = policygetdigest.c\npolicygetdigest_CFLAGS = $(UTILS_CFLAGS)\npolicygetdigest_LDADD = libibmtssutils.la libibmtss.la\n\npolicymaker_SOURCES = policymaker.c\npolicymaker_CFLAGS = $(UTILS_CFLAGS)\npolicymaker_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\n\npolicymakerpcr_SOURCES = policymakerpcr.c\npolicymakerpcr_CFLAGS = $(UTILS_CFLAGS)\npolicymakerpcr_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\n\npolicyauthorizenv_SOURCES = policyauthorizenv.c\npolicyauthorizenv_CFLAGS = $(UTILS_CFLAGS)\npolicyauthorizenv_LDADD = libibmtssutils.la libibmtss.la\n\npolicynv_SOURCES = policynv.c\npolicynv_CFLAGS = $(UTILS_CFLAGS)\npolicynv_LDADD = libibmtssutils.la libibmtss.la\n\npolicynvwritten_SOURCES = policynvwritten.c\npolicynvwritten_CFLAGS = $(UTILS_CFLAGS)\npolicynvwritten_LDADD = libibmtssutils.la libibmtss.la\n\npolicyor_SOURCES = policyor.c\npolicyor_CFLAGS = $(UTILS_CFLAGS)\npolicyor_LDADD = libibmtssutils.la libibmtss.la\n\npolicyparameters_SOURCES = policyparameters.c\npolicyparameters_CFLAGS = $(UTILS_CFLAGS)\npolicyparameters_LDADD = libibmtssutils.la libibmtss.la\n\npolicypassword_SOURCES = policypassword.c\npolicypassword_CFLAGS = $(UTILS_CFLAGS)\npolicypassword_LDADD = libibmtssutils.la libibmtss.la\n\npolicypcr_SOURCES = policypcr.c\npolicypcr_CFLAGS = $(UTILS_CFLAGS)\npolicypcr_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\n\npolicyrestart_SOURCES = policyrestart.c\npolicyrestart_CFLAGS = $(UTILS_CFLAGS)\npolicyrestart_LDADD = libibmtssutils.la libibmtss.la\n\npolicysigned_SOURCES = policysigned.c\npolicysigned_CFLAGS = $(UTILS_CFLAGS)\npolicysigned_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\n\npolicysecret_SOURCES = policysecret.c\npolicysecret_CFLAGS = $(UTILS_CFLAGS)\npolicysecret_LDADD = libibmtssutils.la libibmtss.la\n\npolicytemplate_SOURCES = policytemplate.c\npolicytemplate_CFLAGS = $(UTILS_CFLAGS)\npolicytemplate_LDADD = libibmtssutils.la libibmtss.la\n\npolicyticket_SOURCES = policyticket.c\npolicyticket_CFLAGS = $(UTILS_CFLAGS)\npolicyticket_LDADD = libibmtssutils.la libibmtss.la\n\nquote_SOURCES = quote.c\nquote_CFLAGS = $(UTILS_CFLAGS)\nquote_LDADD = libibmtssutils.la libibmtss.la\n\npowerup_SOURCES = powerup.c\npowerup_CFLAGS = $(UTILS_CFLAGS)\npowerup_LDADD = libibmtssutils.la libibmtss.la\n\nreadclock_SOURCES = readclock.c\nreadclock_CFLAGS = $(UTILS_CFLAGS)\nreadclock_LDADD = libibmtssutils.la libibmtss.la\n\nreadpublic_SOURCES = readpublic.c\nreadpublic_CFLAGS = $(UTILS_CFLAGS)\nreadpublic_LDADD = libibmtssutils.la libibmtss.la\n\nreturncode_SOURCES = returncode.c\nreturncode_CFLAGS = $(UTILS_CFLAGS)\nreturncode_LDADD = libibmtssutils.la libibmtss.la\n\nrewrap_SOURCES = rewrap.c\nrewrap_CFLAGS = $(UTILS_CFLAGS)\nrewrap_LDADD = libibmtssutils.la libibmtss.la\n\nrsadecrypt_SOURCES = rsadecrypt.c\nrsadecrypt_CFLAGS = $(UTILS_CFLAGS)\nrsadecrypt_LDADD = libibmtssutils.la libibmtss.la\n\nrsaencrypt_SOURCES = rsaencrypt.c\nrsaencrypt_CFLAGS = $(UTILS_CFLAGS)\nrsaencrypt_LDADD = libibmtssutils.la libibmtss.la\n\nsequenceupdate_SOURCES = sequenceupdate.c\nsequenceupdate_CFLAGS = $(UTILS_CFLAGS)\nsequenceupdate_LDADD = libibmtssutils.la libibmtss.la\n\nsequencecomplete_SOURCES = sequencecomplete.c\nsequencecomplete_CFLAGS = $(UTILS_CFLAGS)\nsequencecomplete_LDADD = libibmtssutils.la libibmtss.la\n\nsetcommandcodeauditstatus_SOURCES = setcommandcodeauditstatus.c\nsetcommandcodeauditstatus_CFLAGS = $(UTILS_CFLAGS)\nsetcommandcodeauditstatus_LDADD = libibmtssutils.la libibmtss.la\n\nsetprimarypolicy_SOURCES = setprimarypolicy.c\nsetprimarypolicy_CFLAGS = $(UTILS_CFLAGS)\nsetprimarypolicy_LDADD = libibmtssutils.la libibmtss.la\n\nshutdown_SOURCES = shutdown.c\nshutdown_CFLAGS = $(UTILS_CFLAGS)\nshutdown_LDADD = libibmtssutils.la libibmtss.la\n\nsign_SOURCES = sign.c\nsign_CFLAGS = $(UTILS_CFLAGS)\nsign_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\n\nstartauthsession_SOURCES = startauthsession.c\nstartauthsession_CFLAGS = $(UTILS_CFLAGS)\nstartauthsession_LDADD = libibmtssutils.la libibmtss.la\n\nstartup_SOURCES = startup.c\nstartup_CFLAGS = $(UTILS_CFLAGS)\nstartup_LDADD = libibmtssutils.la libibmtss.la\n\nstirrandom_SOURCES = stirrandom.c\nstirrandom_CFLAGS = $(UTILS_CFLAGS)\nstirrandom_LDADD = libibmtssutils.la libibmtss.la\n\nunseal_SOURCES = unseal.c\nunseal_CFLAGS = $(UTILS_CFLAGS)\nunseal_LDADD = libibmtssutils.la libibmtss.la\n\nverifysignature_SOURCES = verifysignature.c\nverifysignature_CFLAGS = $(UTILS_CFLAGS)\nverifysignature_LDADD = libibmtssutils.la libibmtss.la\n\nzgen2phase_SOURCES = zgen2phase.c\nzgen2phase_CFLAGS = $(UTILS_CFLAGS)\nzgen2phase_LDADD = libibmtssutils.la libibmtss.la\n\nsignapp_SOURCES = signapp.c\nsignapp_CFLAGS = $(UTILS_CFLAGS)\nsignapp_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\n\nwriteapp_SOURCES = writeapp.c\nwriteapp_CFLAGS = $(UTILS_CFLAGS)\nwriteapp_LDADD = libibmtssutils.la libibmtss.la\n\nif !CONFIG_TSS_NOFILE\ntimepacket_SOURCES = timepacket.c\ntimepacket_CFLAGS = $(UTILS_CFLAGS)\ntimepacket_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\nendif\n\ncreateek_SOURCES = createek.c\ncreateek_CFLAGS = $(UTILS_CFLAGS)\ncreateek_LDADD = libibmtssutils.la libibmtss.la $(LIBCRYPTO_LIBS)\n\ncreateekcert_SOURCES = createekcert.c\ncreateekcert_CFLAGS = $(UTILS_CFLAGS)\ncreateekcert_LDADD = libibmtssutils.la libibmtss.la\n\ntpm2pem_SOURCES = tpm2pem.c\ntpm2pem_CFLAGS = $(UTILS_CFLAGS)\ntpm2pem_LDADD = libibmtssutils.la libibmtss.la\n\ntpmpublic2eccpoint_SOURCES = tpmpublic2eccpoint.c\ntpmpublic2eccpoint_CFLAGS = $(UTILS_CFLAGS)\ntpmpublic2eccpoint_LDADD = libibmtssutils.la libibmtss.la\n\nntc2getconfig_SOURCES = ntc2getconfig.c\nntc2getconfig_CFLAGS = $(UTILS_CFLAGS)\nntc2getconfig_LDADD = libibmtssutils.la libibmtss.la\n\nntc2preconfig_SOURCES = ntc2preconfig.c\nntc2preconfig_CFLAGS = $(UTILS_CFLAGS)\nntc2preconfig_LDADD = libibmtssutils.la libibmtss.la\n\nntc2lockconfig_SOURCES = ntc2lockconfig.c\nntc2lockconfig_CFLAGS = $(UTILS_CFLAGS)\nntc2lockconfig_LDADD = $(OPENSSL_LIBS) libibmtssutils.la libibmtss.la\n\npublicname_SOURCES = publicname.c\npublicname_CFLAGS = $(OPENSSL_CFLAGS)\npublicname_LDADD = $(OPENSSL_LIBS) libibmtssutils.la libibmtss.la\n\ntpmcmd_SOURCES = tpmcmd.c\ntpmcmd_CFLAGS = $(OPENSSL_CFLAGS)\ntpmcmd_LDADD = $(OPENSSL_LIBS) libibmtssutils.la libibmtss.la\n\nprintattr_SOURCES = printattr.c\nprintattr_CFLAGS = $(OPENSSL_CFLAGS)\nprintattr_LDADD = $(OPENSSL_LIBS) libibmtssutils.la libibmtss.la\n\ntpmproxy_SOURCES = tpmproxy.c\ntpmproxy_CFLAGS = $(OPENSSL_CFLAGS)\ntpmproxy_LDADD = $(OPENSSL_LIBS) libibmtssutils.la libibmtss.la\n\nendif\nendif\n"
  },
  {
    "path": "ibmtss-ftpm/Unmarshal.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Parameter Unmarshaling\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <string.h>\n\n#include <ibmtss/Unmarshal_fp.h>\n\n/* The functions with the TSS_ prefix are preferred.  They use an unsigned size.  The functions\n   without the prefix are deprecated.  */\n\n/* TPM_TSS_NOCMDCHECK is not used but flags the unmarshal functions used for command parameter\n   checking. They can be stripped if not needed by applications, including the command line\n   utilities..\n\n   TPM_TSS_NODEPRECATED\tdefines strips the deprecated functions that used a signed size\n*/\n\n/* The int and array functions are common to TPM 1.2 and TPM 2.0 */\n\nTPM_RC\nTSS_UINT8_Unmarshalu(UINT8 *target, BYTE **buffer, uint32_t *size)\n{\n    if (*size < sizeof(UINT8)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = (*buffer)[0];\n    *buffer += sizeof(UINT8);\n    *size -= sizeof(UINT8);\n    return TPM_RC_SUCCESS;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\nTPM_RC\nTSS_INT8_Unmarshalu(INT8 *target, BYTE **buffer, uint32_t *size)\n{\n    return TSS_UINT8_Unmarshalu((UINT8 *)target, buffer, size);\n}\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\nTPM_RC\nTSS_UINT16_Unmarshalu(uint16_t *target, BYTE **buffer, uint32_t *size)\n{\n    if (*size < sizeof(uint16_t)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = ((uint16_t)((*buffer)[0]) << 8) |\n\t      ((uint16_t)((*buffer)[1]) << 0);\n    *buffer += sizeof(uint16_t);\n    *size -= sizeof(uint16_t);\n    return TPM_RC_SUCCESS;\n}\n\nTPM_RC\nTSS_UINT32_Unmarshalu(UINT32 *target, BYTE **buffer, uint32_t *size)\n{\n    if (*size < sizeof(uint32_t)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = ((uint32_t)((*buffer)[0]) << 24) |\n\t      ((uint32_t)((*buffer)[1]) << 16) |\n\t      ((uint32_t)((*buffer)[2]) <<  8) |\n\t      ((uint32_t)((*buffer)[3]) <<  0);\n    *buffer += sizeof(uint32_t);\n    *size -= sizeof(uint32_t);\n    return TPM_RC_SUCCESS;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\nTPM_RC\nTSS_INT32_Unmarshalu(INT32 *target, BYTE **buffer, uint32_t *size)\n{\n    return TSS_UINT32_Unmarshalu((UINT32 *)target, buffer, size);\n}\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\nTPM_RC\nTSS_UINT64_Unmarshalu(UINT64 *target, BYTE **buffer, uint32_t *size)\n{\n    if (*size < sizeof(UINT64)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = ((UINT64)((*buffer)[0]) << 56) |\n\t      ((UINT64)((*buffer)[1]) << 48) |\n\t      ((UINT64)((*buffer)[2]) << 40) |\n\t      ((UINT64)((*buffer)[3]) << 32) |\n\t      ((UINT64)((*buffer)[4]) << 24) |\n\t      ((UINT64)((*buffer)[5]) << 16) |\n\t      ((UINT64)((*buffer)[6]) <<  8) |\n\t      ((UINT64)((*buffer)[7]) <<  0);\n    *buffer += sizeof(UINT64);\n    *size -= sizeof(UINT64);\n    return TPM_RC_SUCCESS;\n}\n\nTPM_RC\nTSS_Array_Unmarshalu(BYTE *targetBuffer, uint16_t targetSize, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (*size < targetSize) {\n\trc = TPM_RC_INSUFFICIENT;\n    }\n    else {\n\tmemcpy(targetBuffer, *buffer, targetSize);\n\t*buffer += targetSize;\n\t*size -= targetSize;\n    }\n    return rc;\n}\n\n#ifndef TPM_TSS_NODEPRECATED\n/* #ifndef TPM_TSS_NOCMDCHECK */\nTPM_RC UINT8_Unmarshal(UINT8 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_UINT8_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC INT8_Unmarshal(INT8 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_INT8_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC UINT16_Unmarshal(UINT16 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_UINT16_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC UINT32_Unmarshal(UINT32 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_UINT32_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC INT32_Unmarshal(INT32 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_INT32_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC UINT64_Unmarshal(UINT64 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_UINT64_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC Array_Unmarshal(BYTE *targetBuffer, UINT16 targetSize, BYTE **buffer, INT32 *size)\n{\n    return TSS_Array_Unmarshalu(targetBuffer, targetSize, buffer, (uint32_t *)size);\n}\n\n/* #endif TPM_TSS_NOCMDCHECK */\n#endif /* TPM_TSS_NODEPRECATED */\n#ifdef TPM_TPM20\n\nTPM_RC\nTSS_TPM2B_Unmarshalu(TPM2B *target, uint16_t targetSize, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size > targetSize) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_Array_Unmarshalu(target->buffer, target->size, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 5 - Definition of Types for Documentation Clarity */\n\nTPM_RC\nTSS_TPM_KEY_BITS_Unmarshalu(TPM_KEY_BITS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 7 - Definition of (UINT32) TPM_GENERATED Constants <O> */\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\nTPM_RC\nTSS_TPM_GENERATED_Unmarshalu(TPM_GENERATED *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (*target != TPM_GENERATED_VALUE) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM_ALG_ID_Unmarshalu(TPM_ALG_ID *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */\n\n#ifdef TPM_ALG_ECC\nTPM_RC\nTSS_TPM_ECC_CURVE_Unmarshalu(TPM_ECC_CURVE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n#endif\t/*  TPM_ALG_ECC */\n\n/* Table 13 - Definition of (UINT32) TPM_CC Constants (Numeric Order) <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM_CC_Unmarshalu(TPM_RC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 17 - Definition of (UINT32) TPM_RC Constants (Actions) <OUT> */\n\nTPM_RC\nTSS_TPM_RC_Unmarshalu(TPM_RC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 18 - Definition of (INT8) TPM_CLOCK_ADJUST Constants <IN> */\n\nTPM_RC\nTSS_TPM_CLOCK_ADJUST_Unmarshalu(TPM_CLOCK_ADJUST *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_INT8_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_CLOCK_COARSE_SLOWER:\n\t  case TPM_CLOCK_MEDIUM_SLOWER:\n\t  case TPM_CLOCK_FINE_SLOWER:\n\t  case TPM_CLOCK_NO_CHANGE:\n\t  case TPM_CLOCK_FINE_FASTER:\n\t  case TPM_CLOCK_MEDIUM_FASTER:\n\t  case TPM_CLOCK_COARSE_FASTER:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 19 - Definition of (UINT16) TPM_EO Constants <IN/OUT> */\n\nTPM_RC\nTSS_TPM_EO_Unmarshalu(TPM_EO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_EO_EQ:\n\t  case TPM_EO_NEQ:\n\t  case TPM_EO_SIGNED_GT:\n\t  case TPM_EO_UNSIGNED_GT:\n\t  case TPM_EO_SIGNED_LT:\n\t  case TPM_EO_UNSIGNED_LT:\n\t  case TPM_EO_SIGNED_GE:\n\t  case TPM_EO_UNSIGNED_GE:\n\t  case TPM_EO_SIGNED_LE:\n\t  case TPM_EO_UNSIGNED_LE:\n\t  case TPM_EO_BITSET:\n\t  case TPM_EO_BITCLEAR:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 20 - Definition of (UINT16) TPM_ST Constants <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM_ST_Unmarshalu(TPM_ST *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n/* Table 21 - Definition of (UINT16) TPM_SU Constants <IN> */\n\nTPM_RC\nTSS_TPM_SU_Unmarshalu(TPM_SU *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_SU_CLEAR:\n\t  case TPM_SU_STATE:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 22 - Definition of (UINT8) TPM_SE Constants <IN> */\n\nTPM_RC\nTSS_TPM_SE_Unmarshalu(TPM_SE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT8_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_SE_HMAC:\n\t  case TPM_SE_POLICY:\n\t  case TPM_SE_TRIAL:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 23 - Definition of (UINT32) TPM_CAP Constants  */\n\nTPM_RC\nTSS_TPM_CAP_Unmarshalu(TPM_CAP *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 24 - Definition of (UINT32) TPM_PT Constants <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM_PT_Unmarshalu(TPM_HANDLE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 25 - Definition of (UINT32) TPM_PT_PCR Constants <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM_PT_PCR_Unmarshalu(TPM_PT_PCR *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 27 - Definition of Types for Handles */\n\nTPM_RC\nTSS_TPM_HANDLE_Unmarshalu(TPM_HANDLE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 31 - Definition of (UINT32) TPMA_ALGORITHM Bits */\n\nTPM_RC\nTSS_TPMA_ALGORITHM_Unmarshalu(TPMA_ALGORITHM *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->val, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->val & TPMA_ALGORITHM_RESERVED) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 32 - Definition of (UINT32) TPMA_OBJECT Bits */\n\nTPM_RC\nTSS_TPMA_OBJECT_Unmarshalu(TPMA_OBJECT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->val, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->val & TPMA_OBJECT_RESERVED) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 33 - Definition of (UINT8) TPMA_SESSION Bits <IN/OUT> */\n\nTPM_RC\nTSS_TPMA_SESSION_Unmarshalu(TPMA_SESSION *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT8_Unmarshalu(&target->val, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->val & TPMA_SESSION_RESERVED) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 34 - Definition of (UINT8) TPMA_LOCALITY Bits <IN/OUT> */\n\nTPM_RC\nTSS_TPMA_LOCALITY_Unmarshalu(TPMA_LOCALITY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT8_Unmarshalu(&target->val, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 38 - Definition of (TPM_CC) TPMA_CC Bits <OUT> */\n\nTPM_RC\nTSS_TPMA_CC_Unmarshalu(TPMA_CC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->val, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->val & TPMA_CC_RESERVED) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 40 - Definition of (UINT32) TPMA_ACT Bits */\n\nTPM_RC\nTSS_TPMA_ACT_Unmarshalu(TPMA_ACT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 39 - Definition of (BYTE) TPMI_YES_NO Type */\n\nTPM_RC\nTSS_TPMI_YES_NO_Unmarshalu(TPMI_YES_NO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT8_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 40 - Definition of (TPM_HANDLE) TPMI_DH_OBJECT Type */\n\nTPM_RC\nTSS_TPMI_DH_OBJECT_Unmarshalu(TPMI_DH_OBJECT *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST);\n\tBOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST);\n\tBOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull;\n\tif (isNotTransient &&\n\t    isNotPersistent &&\n\t    isNotLegalNull) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n/* Table 41 - Definition of (TPM_HANDLE) TPMI_DH_PERSISTENT Type */\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\nTPM_RC\nTSS_TPMI_DH_PERSISTENT_Unmarshalu(TPMI_DH_PERSISTENT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST);\n\tif (isNotPersistent) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 42 - Definition of (TPM_HANDLE) TPMI_DH_ENTITY Type <IN> */\n\nTPM_RC\nTSS_TPMI_DH_ENTITY_Unmarshalu(TPMI_DH_ENTITY *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotOwner = *target != TPM_RH_OWNER;\n\tBOOL isNotEndorsement = *target != TPM_RH_ENDORSEMENT;\n\tBOOL isNotPlatform = *target != TPM_RH_PLATFORM;\n\tBOOL isNotLockout = *target != TPM_RH_LOCKOUT;\n\tBOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST);\n\tBOOL isNotPersistent = (*target < PERSISTENT_FIRST) || (*target > PERSISTENT_LAST);\n\tBOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);\n\tBOOL isNotPcr = (*target > PCR_LAST);\n\tBOOL isNotAuth = (*target < TPM_RH_AUTH_00) || (*target > TPM_RH_AUTH_FF);\n\tBOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull;\n\tif (isNotOwner &&\n\t    isNotEndorsement &&\n\t    isNotPlatform &&\n\t    isNotLockout &&\n\t    isNotTransient &&\n\t    isNotPersistent &&\n\t    isNotNv &&\n\t    isNotPcr &&\n\t    isNotAuth &&\n\t    isNotLegalNull) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 43 - Definition of (TPM_HANDLE) TPMI_DH_PCR Type <IN> */\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\nTPM_RC\nTSS_TPMI_DH_PCR_Unmarshalu(TPMI_DH_PCR *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotPcr = (*target > PCR_LAST);\n\tBOOL isNotLegalNull = (*target != TPM_RH_NULL) || !allowNull;\n\tif (isNotPcr &&\n\t    isNotLegalNull) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 44 - Definition of (TPM_HANDLE) TPMI_SH_AUTH_SESSION Type <IN/OUT> */\n\nTPM_RC\nTSS_TPMI_SH_AUTH_SESSION_Unmarshalu(TPMI_SH_AUTH_SESSION *target, BYTE **buffer, uint32_t *size, BOOL allowPwd)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST);\n\tBOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST);\n\tBOOL isNotLegalPwd = (*target != TPM_RS_PW) || !allowPwd;\n\tif (isNotHmacSession &&\n\t    isNotPolicySession &&\n\t    isNotLegalPwd) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 45 - Definition of (TPM_HANDLE) TPMI_SH_HMAC Type <IN/OUT> */\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\nTPM_RC\nTSS_TPMI_SH_HMAC_Unmarshalu(TPMI_SH_HMAC *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST);\n\tif (isNotHmacSession) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 46 - Definition of (TPM_HANDLE) TPMI_SH_POLICY Type <IN/OUT> */\n\nTPM_RC\nTSS_TPMI_SH_POLICY_Unmarshalu(TPMI_SH_POLICY *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST);\n\tif (isNotPolicySession) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 47 - Definition of (TPM_HANDLE) TPMI_DH_CONTEXT Type  */\n\nTPM_RC\nTSS_TPMI_DH_CONTEXT_Unmarshalu(TPMI_DH_CONTEXT *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST);\n\tBOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST);\n\tBOOL isNotTransient = (*target < TRANSIENT_FIRST) || (*target > TRANSIENT_LAST);\n\tif (isNotHmacSession &&\n\t    isNotPolicySession &&\n\t    isNotTransient) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 49 - Definition of (TPM_HANDLE) TPMI_DH_SAVED Type  */\n\nTPM_RC\nTSS_TPMI_DH_SAVED_Unmarshalu(TPMI_DH_SAVED *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotHmacSession = (*target < HMAC_SESSION_FIRST ) || (*target > HMAC_SESSION_LAST);\n\tBOOL isNotPolicySession = (*target < POLICY_SESSION_FIRST) || (*target > POLICY_SESSION_LAST);\n\tBOOL isNotTransient = (*target != 0x80000000);\n\tBOOL isNotSequence = (*target != 0x80000001);\n\tBOOL isNotTransientStClear = (*target != 0x80000002);\n\n\tif (isNotHmacSession &&\n\t    isNotPolicySession &&\n\t    isNotTransient && \n\t    isNotSequence &&\n\t    isNotTransientStClear) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 48 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY Type  */\n\nTPM_RC\nTSS_TPMI_RH_HIERARCHY_Unmarshalu(TPMI_RH_HIERARCHY *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t  case TPM_RH_ENDORSEMENT:\n\t    break;\n\t  case TPM_RH_NULL:\n\t    if (!allowNull) {\n\t\trc = TPM_RC_VALUE;\n\t    }\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n/* Table 49 - Definition of (TPM_HANDLE) TPMI_RH_ENABLES Type */\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\nTPM_RC\nTSS_TPMI_RH_ENABLES_Unmarshalu(TPMI_RH_ENABLES *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t  case TPM_RH_ENDORSEMENT:\n\t  case TPM_RH_PLATFORM_NV:\n\t    break;\n\t  case TPM_RH_NULL:\n\t    if (!allowNull) {\n\t\trc = TPM_RC_VALUE;\n\t    }\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 50 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY_AUTH Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_HIERARCHY_AUTH_Unmarshalu(TPMI_RH_HIERARCHY_AUTH *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t  case TPM_RH_ENDORSEMENT:\n\t  case TPM_RH_LOCKOUT:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 51 - Definition of (TPM_HANDLE) TPMI_RH_PLATFORM Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_PLATFORM_Unmarshalu(TPMI_RH_PLATFORM *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_PLATFORM:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 53 - Definition of (TPM_HANDLE) TPMI_RH_ENDORSEMENT Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_ENDORSEMENT_Unmarshalu(TPMI_RH_ENDORSEMENT *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_ENDORSEMENT:\n\t    break;\n\t  case TPM_RH_NULL:\n\t    if (!allowNull) {\n\t\trc = TPM_RC_VALUE;\n\t    }\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 54 - Definition of (TPM_HANDLE) TPMI_RH_PROVISION Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_PROVISION_Unmarshalu(TPMI_RH_PROVISION *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 55 - Definition of (TPM_HANDLE) TPMI_RH_CLEAR Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_CLEAR_Unmarshalu(TPMI_RH_CLEAR *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_LOCKOUT:\n\t  case TPM_RH_PLATFORM:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 56 - Definition of (TPM_HANDLE) TPMI_RH_NV_AUTH Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_NV_AUTH_Unmarshalu(TPMI_RH_NV_AUTH *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_OWNER:\n\t  case TPM_RH_PLATFORM:\n\t    break;\n\t  default:\n\t      {\n\t\t  BOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);\n\t\t  if (isNotNv) {\n\t\t      rc = TPM_RC_VALUE;\n\t\t  }\n\t      }\n\t}\n    }\n    return rc;\n}\n\n/* Table 57 - Definition of (TPM_HANDLE) TPMI_RH_LOCKOUT Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_LOCKOUT_Unmarshalu(TPMI_RH_LOCKOUT *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_RH_LOCKOUT:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 58 - Definition of (TPM_HANDLE) TPMI_RH_NV_INDEX Type <IN/OUT> */\n\nTPM_RC\nTSS_TPMI_RH_NV_INDEX_Unmarshalu(TPMI_RH_NV_INDEX *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tBOOL isNotNv = (*target < NV_INDEX_FIRST) || (*target > NV_INDEX_LAST);\n\tif (isNotNv) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type  */\n\nTPM_RC\nTSS_TPMI_ALG_HASH_Unmarshalu(TPMI_ALG_HASH *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 61 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM Type */\n\nTPM_RC\nTSS_TPMI_ALG_SYM_Unmarshalu(TPMI_ALG_SYM *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 62 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_OBJECT Type */\n\nTPM_RC\nTSS_TPMI_ALG_SYM_OBJECT_Unmarshalu(TPMI_ALG_SYM_OBJECT *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 63 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_MODE Type */\n\nTPM_RC\nTSS_TPMI_ALG_SYM_MODE_Unmarshalu(TPMI_ALG_SYM_MODE *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 64 - Definition of (TPM_ALG_ID) TPMI_ALG_KDF Type */\n\nTPM_RC\nTSS_TPMI_ALG_KDF_Unmarshalu(TPMI_ALG_KDF *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n   \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 65 - Definition of (TPM_ALG_ID) TPMI_ALG_SIG_SCHEME Type */\n\nTPM_RC\nTSS_TPMI_ALG_SIG_SCHEME_Unmarshalu(TPMI_ALG_SIG_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 66 - Definition of (TPM_ALG_ID) TPMI_ECC_KEY_EXCHANGE Type */\n\nTPM_RC\nTSS_TPMI_ECC_KEY_EXCHANGE_Unmarshalu(TPMI_ECC_KEY_EXCHANGE *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 67 - Definition of (TPM_ST) TPMI_ST_COMMAND_TAG Type */\n\nTPM_RC\nTSS_TPMI_ST_COMMAND_TAG_Unmarshalu(TPMI_ST_COMMAND_TAG *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ST_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_ST_NO_SESSIONS:\n\t  case TPM_ST_SESSIONS:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_BAD_TAG;\n\t}\n    }\n    return rc;\n}\n\n/* Table 70 TPMI_ALG_MAC_SCHEME */\n\nTPM_RC\nTSS_TPMI_ALG_MAC_SCHEME_Unmarshalu(TPMI_ALG_MAC_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n    \n/* Table 70 TPMI_ALG_CIPHER_MODE */\n\nTPM_RC\nTSS_TPMI_ALG_CIPHER_MODE_Unmarshalu(TPMI_ALG_CIPHER_MODE*target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 68 - Definition of TPMS_EMPTY Structure <IN/OUT> */\n\n/* NOTE: Marked as const function in header */\n\nTPM_RC\nTSS_TPMS_EMPTY_Unmarshalu(TPMS_EMPTY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    target = target;\n    buffer = buffer;\n    size = size;\n    return rc;\n}\n\n/* Table 70 - Definition of TPMU_HA Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_HA_Unmarshalu(TPMU_HA *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_SHA1\n      case TPM_ALG_SHA1:\n\trc = TSS_Array_Unmarshalu(target->sha1, SHA1_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA256\n      case TPM_ALG_SHA256:\n\trc = TSS_Array_Unmarshalu(target->sha256, SHA256_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA384\n      case TPM_ALG_SHA384:\n\trc =TSS_Array_Unmarshalu(target->sha384, SHA384_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA512\n      case TPM_ALG_SHA512:\n\trc = TSS_Array_Unmarshalu(target->sha512, SHA512_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM3_256\n      case TPM_ALG_SM3_256:\n\trc = TSS_Array_Unmarshalu(target->sm3_256, SM3_256_DIGEST_SIZE, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 71 - Definition of TPMT_HA Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPMT_HA_Unmarshalu(TPMT_HA *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_HA_Unmarshalu(&target->digest, buffer, size, target->hashAlg);\n    }\n    return rc;\n}\n\n/* Table 72 - Definition of TPM2B_DIGEST Structure */\n\nTPM_RC\nTSS_TPM2B_DIGEST_Unmarshalu(TPM2B_DIGEST *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 73 - Definition of TPM2B_DATA Structure */\n\nTPM_RC\nTSS_TPM2B_DATA_Unmarshalu(TPM2B_DATA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 74 - Definition of Types for TPM2B_NONCE */\n\nTPM_RC\nTSS_TPM2B_NONCE_Unmarshalu(TPM2B_NONCE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 75 - Definition of Types for TPM2B_AUTH */\n\nTPM_RC\nTSS_TPM2B_AUTH_Unmarshalu(TPM2B_AUTH *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 76 - Definition of Types for TPM2B_OPERAND */\n\nTPM_RC\nTSS_TPM2B_OPERAND_Unmarshalu(TPM2B_OPERAND *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 77 - Definition of TPM2B_EVENT Structure */\n\nTPM_RC\nTSS_TPM2B_EVENT_Unmarshalu(TPM2B_EVENT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n \n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 78 - Definition of TPM2B_MAX_BUFFER Structure */\n\nTPM_RC\nTSS_TPM2B_MAX_BUFFER_Unmarshalu(TPM2B_MAX_BUFFER *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 79 - Definition of TPM2B_MAX_NV_BUFFER Structure */\n\nTPM_RC\nTSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(TPM2B_MAX_NV_BUFFER *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 80 - Definition of TPM2B_TIMEOUT Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_TIMEOUT_Unmarshalu(TPM2B_TIMEOUT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 81 - Definition of TPM2B_IV Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_IV_Unmarshalu(TPM2B_IV *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 83 - Definition of TPM2B_NAME Structure */\n\nTPM_RC\nTSS_TPM2B_NAME_Unmarshalu(TPM2B_NAME *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.name), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 85 - Definition of TPMS_PCR_SELECTION Structure */\n\nTPM_RC\nTSS_TPMS_PCR_SELECTION_Unmarshalu(TPMS_PCR_SELECTION *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hash, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT8_Unmarshalu(&target->sizeofSelect, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->sizeofSelect > PCR_SELECT_MAX) {\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_Array_Unmarshalu(target->pcrSelect, target->sizeofSelect, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 88 - Definition of TPMT_TK_CREATION Structure */\n\nTPM_RC\nTSS_TPMT_TK_CREATION_Unmarshalu(TPMT_TK_CREATION *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ST_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->tag != TPM_ST_CREATION) {\n\t    rc = TPM_RC_TAG;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 89 - Definition of TPMT_TK_VERIFIED Structure */\n\nTPM_RC\nTSS_TPMT_TK_VERIFIED_Unmarshalu(TPMT_TK_VERIFIED *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ST_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->tag != TPM_ST_VERIFIED) {\n\t    rc = TPM_RC_TAG;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 90 - Definition of TPMT_TK_AUTH Structure */\n\nTPM_RC\nTSS_TPMT_TK_AUTH_Unmarshalu(TPMT_TK_AUTH *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ST_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif ((target->tag != TPM_ST_AUTH_SIGNED) &&\n\t    (target->tag != TPM_ST_AUTH_SECRET)) {\n\t    rc = TPM_RC_TAG;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 91 - Definition of TPMT_TK_HASHCHECK Structure */\n\nTPM_RC\nTSS_TPMT_TK_HASHCHECK_Unmarshalu(TPMT_TK_HASHCHECK *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ST_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->tag != TPM_ST_HASHCHECK) {\n\t    rc = TPM_RC_TAG;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 92 - Definition of TPMS_ALG_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_ALG_PROPERTY_Unmarshalu(TPMS_ALG_PROPERTY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(&target->alg, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMA_ALGORITHM_Unmarshalu(&target->algProperties, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 93 - Definition of TPMS_TAGGED_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_TAGGED_PROPERTY_Unmarshalu(TPMS_TAGGED_PROPERTY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_PT_Unmarshalu(&target->property, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->value, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 94 - Definition of TPMS_TAGGED_PCR_SELECT Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_TAGGED_PCR_SELECT_Unmarshalu(TPMS_TAGGED_PCR_SELECT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_PT_PCR_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT8_Unmarshalu(&target->sizeofSelect, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_Array_Unmarshalu(target->pcrSelect, target->sizeofSelect, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 100 - Definition of TPMS_TAGGED_POLICY Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_TAGGED_POLICY_Unmarshalu(TPMS_TAGGED_POLICY *target, BYTE **buffer, uint32_t *size) \n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(&target->handle, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_HA_Unmarshalu(&target->policyHash, buffer, size, YES);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPMS_ACT_DATA_Unmarshalu(TPMS_ACT_DATA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(&target->handle, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->timeout, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMA_ACT_Unmarshalu(&target->attributes, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 95 - Definition of TPML_CC Structure */\n\nTPM_RC\nTSS_TPML_CC_Unmarshalu(TPML_CC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_CAP_CC) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPM_CC_Unmarshalu(&target->commandCodes[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 96 - Definition of TPML_CCA Structure <OUT> */\n\nTPM_RC\nTSS_TPML_CCA_Unmarshalu(TPML_CCA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_CAP_CC) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPMA_CC_Unmarshalu(&target->commandAttributes[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 97 - Definition of TPML_ALG Structure */\n\nTPM_RC\nTSS_TPML_ALG_Unmarshalu(TPML_ALG *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_ALG_LIST_SIZE) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(&target->algorithms[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 98 - Definition of TPML_HANDLE Structure <OUT> */\n\nTPM_RC\nTSS_TPML_HANDLE_Unmarshalu(TPML_HANDLE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_CAP_HANDLES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(&target->handle[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 99 - Definition of TPML_DIGEST Structure */\n\n/* PolicyOr has a restriction of at least a count of two.  This function is also used to unmarshal\n   PCR_Read, where a count of one is permitted.\n*/\n\nTPM_RC\nTSS_TPML_DIGEST_Unmarshalu(TPML_DIGEST *target, BYTE **buffer, uint32_t *size, uint32_t minCount)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count < minCount) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > 8) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->digests[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 100 - Definition of TPML_DIGEST_VALUES Structure */\n\nTPM_RC\nTSS_TPML_DIGEST_VALUES_Unmarshalu(TPML_DIGEST_VALUES *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > HASH_COUNT) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPMT_HA_Unmarshalu(&target->digests[i], buffer, size, NO);\n    }\n    return rc;\n}\n\n/* Table 102 - Definition of TPML_PCR_SELECTION Structure */\n\nTPM_RC\nTSS_TPML_PCR_SELECTION_Unmarshalu(TPML_PCR_SELECTION *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > HASH_COUNT) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPMS_PCR_SELECTION_Unmarshalu(&target->pcrSelections[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 103 - Definition of TPML_ALG_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPML_ALG_PROPERTY_Unmarshalu(TPML_ALG_PROPERTY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_CAP_ALGS) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPMS_ALG_PROPERTY_Unmarshalu(&target->algProperties[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 104 - Definition of TPML_TAGGED_TPM_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPML_TAGGED_TPM_PROPERTY_Unmarshalu(TPML_TAGGED_TPM_PROPERTY  *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_TPM_PROPERTIES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPMS_TAGGED_PROPERTY_Unmarshalu(&target->tpmProperty[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 105 - Definition of TPML_TAGGED_PCR_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPML_TAGGED_PCR_PROPERTY_Unmarshalu(TPML_TAGGED_PCR_PROPERTY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_PCR_PROPERTIES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPMS_TAGGED_PCR_SELECT_Unmarshalu(&target->pcrProperty[i], buffer, size);\n    }\n    return rc;\n}\n\n/* Table 106 - Definition of {ECC} TPML_ECC_CURVE Structure <OUT> */\n\nTPM_RC\nTSS_TPML_ECC_CURVE_Unmarshalu(TPML_ECC_CURVE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_ECC_CURVES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPM_ECC_CURVE_Unmarshalu(&target->eccCurves[i], buffer, size);\n    }\n    return rc;\t\n}\n\n/* Table 112 - Definition of TPML_TAGGED_POLICY Structure <OUT> */\n\nTPM_RC\nTSS_TPML_TAGGED_POLICY_Unmarshalu(TPML_TAGGED_POLICY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    uint32_t i;  \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_TAGGED_POLICIES) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPMS_TAGGED_POLICY_Unmarshalu(&target->policies[i], buffer, size);\n    }\n    return rc;\t\n}\n\n/* Table 112 - Definition of TPML_ACT_DATA Structure <OUT> */\n\nTPM_RC\nTSS_TPML_ACT_DATA_Unmarshalu(TPML_ACT_DATA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    uint32_t i;  \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > MAX_ACT_DATA) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPMS_ACT_DATA_Unmarshalu(&target->actData[i], buffer, size);\n    }\n    return rc;\t\n}\n\n/* Table 107 - Definition of TPMU_CAPABILITIES Union <OUT> */\n\nTPM_RC\nTSS_TPMU_CAPABILITIES_Unmarshalu(TPMU_CAPABILITIES *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n      case TPM_CAP_ALGS:\n\trc = TSS_TPML_ALG_PROPERTY_Unmarshalu(&target->algorithms, buffer, size);\n\tbreak;\n      case TPM_CAP_HANDLES:\n\trc = TSS_TPML_HANDLE_Unmarshalu(&target->handles, buffer, size);\n\tbreak;\n      case TPM_CAP_COMMANDS:\n\trc = TSS_TPML_CCA_Unmarshalu(&target->command, buffer, size);\n\tbreak;\n      case TPM_CAP_PP_COMMANDS:\n\trc = TSS_TPML_CC_Unmarshalu(&target->ppCommands, buffer, size);\n\tbreak;\n      case TPM_CAP_AUDIT_COMMANDS:\n\trc = TSS_TPML_CC_Unmarshalu(&target->auditCommands, buffer, size);\n\tbreak;\n      case TPM_CAP_PCRS:\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->assignedPCR, buffer, size);\n\tbreak;\n      case TPM_CAP_TPM_PROPERTIES:\n\trc = TSS_TPML_TAGGED_TPM_PROPERTY_Unmarshalu(&target->tpmProperties, buffer, size);\n\tbreak;\n      case TPM_CAP_PCR_PROPERTIES:\n\trc = TSS_TPML_TAGGED_PCR_PROPERTY_Unmarshalu(&target->pcrProperties, buffer, size);\n\tbreak;\n      case TPM_CAP_ECC_CURVES:\n\trc = TSS_TPML_ECC_CURVE_Unmarshalu(&target->eccCurves, buffer, size);\n\tbreak;\n      case TPM_CAP_AUTH_POLICIES:\n\trc = TSS_TPML_TAGGED_POLICY_Unmarshalu(&target->authPolicies, buffer, size);\n\tbreak;\n      case TPM_CAP_ACT:\n\trc = TSS_TPML_ACT_DATA_Unmarshalu(&target->actData, buffer, size);\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 108 - Definition of TPMS_CAPABILITY_DATA Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_CAPABILITY_DATA_Unmarshalu(TPMS_CAPABILITY_DATA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n  \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_CAP_Unmarshalu(&target->capability, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_CAPABILITIES_Unmarshalu(&target->data, buffer, size, target->capability);\n    }\n    return rc;\n}\n\n/* Table 109 - Definition of TPMS_CLOCK_INFO Structure */\n\nTPM_RC\nTSS_TPMS_CLOCK_INFO_Unmarshalu(TPMS_CLOCK_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT64_Unmarshalu(&target->clock, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->resetCount, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->restartCount, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->safe, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 110 - Definition of TPMS_TIME_INFO Structure */\n\nTPM_RC\nTSS_TPMS_TIME_INFO_Unmarshalu(TPMS_TIME_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT64_Unmarshalu(&target->time, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_CLOCK_INFO_Unmarshalu(&target->clockInfo, buffer, size);\n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 111 - Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_TIME_ATTEST_INFO_Unmarshalu(TPMS_TIME_ATTEST_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_TIME_INFO_Unmarshalu(&target->time, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT64_Unmarshalu(&target->firmwareVersion, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 112 - Definition of TPMS_CERTIFY_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_CERTIFY_INFO_Unmarshalu(TPMS_CERTIFY_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->qualifiedName, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 113 - Definition of TPMS_QUOTE_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_QUOTE_INFO_Unmarshalu(TPMS_QUOTE_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrSelect, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->pcrDigest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 114 - Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_COMMAND_AUDIT_INFO_Unmarshalu(TPMS_COMMAND_AUDIT_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT64_Unmarshalu(&target->auditCounter, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(&target->digestAlg, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->auditDigest, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->commandDigest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 115 - Definition of TPMS_SESSION_AUDIT_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_SESSION_AUDIT_INFO_Unmarshalu(TPMS_SESSION_AUDIT_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->exclusiveSession, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->sessionDigest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 116 - Definition of TPMS_CREATION_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_CREATION_INFO_Unmarshalu(TPMS_CREATION_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->objectName, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->creationHash, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 117 - Definition of TPMS_NV_CERTIFY_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_NV_CERTIFY_INFO_Unmarshalu(TPMS_NV_CERTIFY_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->indexName, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->offset, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(&target->nvContents, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 125 - Definition of TPMS_NV_DIGEST_CERTIFY_INFO Structure <OUT> */\nTPM_RC\nTSS_TPMS_NV_DIGEST_CERTIFY_INFO_Unmarshalu(TPMS_NV_DIGEST_CERTIFY_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->indexName, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->nvDigest, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 118 - Definition of (TPM_ST) TPMI_ST_ATTEST Type <OUT> */\n\nTPM_RC\nTSS_TPMI_ST_ATTEST_Unmarshalu(TPMI_ST_ATTEST *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ST_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/*  Table 119 - Definition of TPMU_ATTEST Union <OUT> */\n\nTPM_RC\nTSS_TPMU_ATTEST_Unmarshalu(TPMU_ATTEST *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n      case TPM_ST_ATTEST_CERTIFY:\n\trc = TSS_TPMS_CERTIFY_INFO_Unmarshalu(&target->certify, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_CREATION:\n\trc = TSS_TPMS_CREATION_INFO_Unmarshalu(&target->creation, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_QUOTE:\n\trc = TSS_TPMS_QUOTE_INFO_Unmarshalu(&target->quote, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_COMMAND_AUDIT:\n\trc = TSS_TPMS_COMMAND_AUDIT_INFO_Unmarshalu(&target->commandAudit, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_SESSION_AUDIT:\n\trc = TSS_TPMS_SESSION_AUDIT_INFO_Unmarshalu(&target->sessionAudit, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_TIME:\n\trc = TSS_TPMS_TIME_ATTEST_INFO_Unmarshalu(&target->time, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_NV:\n\trc = TSS_TPMS_NV_CERTIFY_INFO_Unmarshalu(&target->nv, buffer, size);\n\tbreak;\n      case TPM_ST_ATTEST_NV_DIGEST:\n\trc = TSS_TPMS_NV_DIGEST_CERTIFY_INFO_Unmarshalu(&target->nvDigest, buffer, size);\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n\t\n    }\n    return rc;\n}\n\n/* Table 120 - Definition of TPMS_ATTEST Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_ATTEST_Unmarshalu(TPMS_ATTEST *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_GENERATED_Unmarshalu(&target->magic, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ST_ATTEST_Unmarshalu(&target->type, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->qualifiedSigner, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->extraData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_CLOCK_INFO_Unmarshalu(&target->clockInfo, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT64_Unmarshalu(&target->firmwareVersion, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_ATTEST_Unmarshalu(&target->attested, buffer, size, target->type);\n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 121 - Definition of TPM2B_ATTEST Structure <OUT> */\n\nTPM_RC\nTSS_TPM2B_ATTEST_Unmarshalu(TPM2B_ATTEST *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.attestationData), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 123 - Definition of TPMS_AUTH_RESPONSE Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_AUTH_RESPONSE_Unmarshalu(TPMS_AUTH_RESPONSE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonce, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMA_SESSION_Unmarshalu(&target->sessionAttributes, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->hmac, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 124 - Definition of {!ALG.S} (TPM_KEY_BITS) TPMI_!ALG.S_KEY_BITS Type */\n\n#ifdef TPM_ALG_AES\n\nTPM_RC\nTSS_TPMI_AES_KEY_BITS_Unmarshalu(TPMI_AES_KEY_BITS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n#endif\t/* TPM_ALG_AES */\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n#ifdef TPM_ALG_CAMELLIA\nTPM_RC\nTSS_TPMI_CAMELLIA_KEY_BITS_Unmarshalu(TPMI_CAMELLIA_KEY_BITS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n#endif\t/*  TPM_ALG_CAMELLIA */\n\n#ifdef TPM_ALG_SM4\nTPM_RC\nTSS_TPMI_SM4_KEY_BITS_Unmarshalu(TPMI_SM4_KEY_BITS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n#endif\t/* TPM_ALG_SM4 */\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 125 - Definition of TPMU_SYM_KEY_BITS Union */\n\nTPM_RC\nTSS_TPMU_SYM_KEY_BITS_Unmarshalu(TPMU_SYM_KEY_BITS *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_AES\n      case TPM_ALG_AES:\n\trc = TSS_TPMI_AES_KEY_BITS_Unmarshalu(&target->aes, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM4\n      case TPM_ALG_SM4:\n\trc = TSS_TPMI_SM4_KEY_BITS_Unmarshalu(&target->sm4, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_CAMELLIA\n      case TPM_ALG_CAMELLIA:\n\trc = TSS_TPMI_CAMELLIA_KEY_BITS_Unmarshalu(&target->camellia, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_XOR\n      case TPM_ALG_XOR:\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->xorr, buffer, size, NO);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 126 - Definition of TPMU_SYM_MODE Union */\n\nTPM_RC\nTSS_TPMU_SYM_MODE_Unmarshalu(TPMU_SYM_MODE *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_AES\n      case TPM_ALG_AES:\n\trc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->aes, buffer, size, YES);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM4\n      case TPM_ALG_SM4:\n\trc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->sm4, buffer, size, YES);\n\tbreak;\n#endif\n#ifdef TPM_ALG_CAMELLIA\n      case TPM_ALG_CAMELLIA:\n\trc = TSS_TPMI_ALG_SYM_MODE_Unmarshalu(&target->camellia, buffer, size, YES);\n\tbreak;\n#endif\n      case TPM_ALG_XOR:\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 128 - Definition of TPMT_SYM_DEF Structure */\n\nTPM_RC\nTSS_TPMT_SYM_DEF_Unmarshalu(TPMT_SYM_DEF *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_SYM_Unmarshalu(&target->algorithm, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_SYM_KEY_BITS_Unmarshalu(&target->keyBits, buffer, size, target->algorithm);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_SYM_MODE_Unmarshalu(&target->mode, buffer, size, target->algorithm);\n    }\n    return rc;\n}\n\n/* Table 129 - Definition of TPMT_SYM_DEF_OBJECT Structure */\n\nTPM_RC\nTSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(TPMT_SYM_DEF_OBJECT *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_SYM_OBJECT_Unmarshalu(&target->algorithm, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_SYM_KEY_BITS_Unmarshalu(&target->keyBits, buffer, size, target->algorithm);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_SYM_MODE_Unmarshalu(&target->mode, buffer, size, target->algorithm);\n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 130 - Definition of TPM2B_SYM_KEY Structure */\n\nTPM_RC\nTSS_TPM2B_SYM_KEY_Unmarshalu(TPM2B_SYM_KEY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 131 - Definition of TPMS_SYMCIPHER_PARMS Structure */\n\nTPM_RC\nTSS_TPMS_SYMCIPHER_PARMS_Unmarshalu(TPMS_SYMCIPHER_PARMS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->sym, buffer, size, NO);\n    }\n    return rc;\n}\n\n/* Table 132 - Definition of TPM2B_SENSITIVE_DATA Structure */\n\nTPM_RC\nTSS_TPM2B_SENSITIVE_DATA_Unmarshalu(TPM2B_SENSITIVE_DATA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 133 - Definition of TPMS_SENSITIVE_CREATE Structure <IN> */\n\nTPM_RC\nTSS_TPMS_SENSITIVE_CREATE_Unmarshalu(TPMS_SENSITIVE_CREATE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->userAuth, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->data, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 134 - Definition of TPM2B_SENSITIVE_CREATE Structure <IN, S> */\n\nTPM_RC\nTSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(TPM2B_SENSITIVE_CREATE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t startSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SENSITIVE_CREATE_Unmarshalu(&target->sensitive, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\nTPM_RC\nTSS_TPMS_SCHEME_HASH_Unmarshalu(TPMS_SCHEME_HASH *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, NO);\n    }\n    return rc;\n}\n\n/* Table 136 - Definition of {ECC} TPMS_SCHEME_ECDAA Structure */\n\nTPM_RC\nTSS_TPMS_SCHEME_ECDAA_Unmarshalu(TPMS_SCHEME_ECDAA *target, BYTE **buffer, uint32_t *size) \n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, NO);\t\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->count, buffer, size);\t\n    }\n    return rc;\n}\n\n/* Table 137 - Definition of (TPM_ALG_ID) TPMI_ALG_KEYEDHASH_SCHEME Type */\n\nTPM_RC\nTSS_TPMI_ALG_KEYEDHASH_SCHEME_Unmarshalu(TPMI_ALG_KEYEDHASH_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 138 - Definition of Types for HMAC_SIG_SCHEME */\n\nTPM_RC\nTSS_TPMS_SCHEME_HMAC_Unmarshalu(TPMS_SCHEME_HMAC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 139 - Definition of TPMS_SCHEME_XOR Structure */\n\nTPM_RC\nTSS_TPMS_SCHEME_XOR_Unmarshalu(TPMS_SCHEME_XOR *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hashAlg, buffer, size, NO);\t/* as of rev 147 */\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_KDF_Unmarshalu(&target->kdf, buffer, size, YES);\n    }\n    return rc;\n}\n\n/* Table 140 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_SCHEME_KEYEDHASH_Unmarshalu(TPMU_SCHEME_KEYEDHASH *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_HMAC\n      case TPM_ALG_HMAC:\n\trc = TSS_TPMS_SCHEME_HMAC_Unmarshalu(&target->hmac, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_XOR\n      case TPM_ALG_XOR:\n\trc = TSS_TPMS_SCHEME_XOR_Unmarshalu(&target->xorr, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 141 - Definition of TPMT_KEYEDHASH_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_KEYEDHASH_SCHEME_Unmarshalu(TPMT_KEYEDHASH_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_KEYEDHASH_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_SCHEME_KEYEDHASH_Unmarshalu(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_RSAPSS_Unmarshalu(TPMS_SIG_SCHEME_RSAPSS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_RSASSA_Unmarshalu(TPMS_SIG_SCHEME_RSASSA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_ECDAA_Unmarshalu(TPMS_SIG_SCHEME_ECDAA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_ECDAA_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_ECDSA_Unmarshalu(TPMS_SIG_SCHEME_ECDSA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_ECSCHNORR_Unmarshalu(TPMS_SIG_SCHEME_ECSCHNORR *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_SM2_Unmarshalu(TPMS_SIG_SCHEME_SM2 *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_SIG_SCHEME_Unmarshalu(TPMU_SIG_SCHEME *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\trc = TSS_TPMS_SIG_SCHEME_RSASSA_Unmarshalu(&target->rsassa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\trc = TSS_TPMS_SIG_SCHEME_RSAPSS_Unmarshalu(&target->rsapss, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\trc = TSS_TPMS_SIG_SCHEME_ECDSA_Unmarshalu(&target->ecdsa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\trc = TSS_TPMS_SIG_SCHEME_ECDAA_Unmarshalu(&target->ecdaa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM2\n      case TPM_ALG_SM2:\n\trc = TSS_TPMS_SIG_SCHEME_SM2_Unmarshalu(&target->sm2, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\trc = TSS_TPMS_SIG_SCHEME_ECSCHNORR_Unmarshalu(&target->ecSchnorr, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_HMAC\n      case TPM_ALG_HMAC:\n\trc = TSS_TPMS_SCHEME_HMAC_Unmarshalu(&target->hmac, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_SIG_SCHEME_Unmarshalu(TPMT_SIG_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_SIG_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_SIG_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 146 - Definition of Types for {RSA} Encryption Schemes */\n\nTPM_RC\nTSS_TPMS_ENC_SCHEME_OAEP_Unmarshalu(TPMS_ENC_SCHEME_OAEP *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 146 - Definition of Types for {RSA} Encryption Schemes */\n\n/* NOTE: Marked as const function in header */\n\nTPM_RC\nTSS_TPMS_ENC_SCHEME_RSAES_Unmarshalu(TPMS_ENC_SCHEME_RSAES *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_EMPTY_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 147 - Definition of Types for {ECC} ECC Key Exchange */\n\nTPM_RC\nTSS_TPMS_KEY_SCHEME_ECDH_Unmarshalu(TPMS_KEY_SCHEME_ECDH *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); \n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 147 - Definition of Types for {ECC} ECC Key Exchange */\n\nTPM_RC\nTSS_TPMS_KEY_SCHEME_ECMQV_Unmarshalu(TPMS_KEY_SCHEME_ECMQV *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); \n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */\n\nTPM_RC\nTSS_TPMS_SCHEME_KDF1_SP800_108_Unmarshalu(TPMS_SCHEME_KDF1_SP800_108 *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); \n    }\n    return rc;\n}\n\n/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */\n\nTPM_RC\nTSS_TPMS_SCHEME_KDF1_SP800_56A_Unmarshalu(TPMS_SCHEME_KDF1_SP800_56A *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size); \n    }\n    return rc;\n}\n\n/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */\n\nTPM_RC\nTSS_TPMS_SCHEME_KDF2_Unmarshalu(TPMS_SCHEME_KDF2 *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */\n\nTPM_RC\nTSS_TPMS_SCHEME_MGF1_Unmarshalu(TPMS_SCHEME_MGF1 *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 149 - Definition of TPMU_KDF_SCHEME Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_KDF_SCHEME_Unmarshalu(TPMU_KDF_SCHEME *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_MGF1\n      case TPM_ALG_MGF1:\n\trc = TSS_TPMS_SCHEME_MGF1_Unmarshalu(&target->mgf1, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_KDF1_SP800_56A\n      case TPM_ALG_KDF1_SP800_56A:\n\trc = TSS_TPMS_SCHEME_KDF1_SP800_56A_Unmarshalu(&target->kdf1_SP800_56a, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_KDF2\n      case TPM_ALG_KDF2:\n\trc = TSS_TPMS_SCHEME_KDF2_Unmarshalu(&target->kdf2, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_KDF1_SP800_108\n      case TPM_ALG_KDF1_SP800_108:\n\trc = TSS_TPMS_SCHEME_KDF1_SP800_108_Unmarshalu(&target->kdf1_sp800_108, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 150 - Definition of TPMT_KDF_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_KDF_SCHEME_Unmarshalu(TPMT_KDF_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_KDF_Unmarshalu(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_KDF_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* Table 151 - Definition of (TPM_ALG_ID) TPMI_ALG_ASYM_SCHEME Type <> */\n\n#if 0\nTPM_RC\nTSS_TPMI_ALG_ASYM_SCHEME_Unmarshalu(TPMI_ALG_ASYM_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n#endif\t/* 0 */\n\n/* Table 152 - Definition of TPMU_ASYM_SCHEME Union */\n\nTPM_RC\nTSS_TPMU_ASYM_SCHEME_Unmarshalu(TPMU_ASYM_SCHEME *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_ECDH\n      case TPM_ALG_ECDH:\n\trc = TSS_TPMS_KEY_SCHEME_ECDH_Unmarshalu(&target->ecdh, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECMQV\n      case TPM_ALG_ECMQV:\n\trc = TSS_TPMS_KEY_SCHEME_ECMQV_Unmarshalu(&target->ecmqvh, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\trc = TSS_TPMS_SIG_SCHEME_RSASSA_Unmarshalu(&target->rsassa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\trc = TSS_TPMS_SIG_SCHEME_RSAPSS_Unmarshalu(&target->rsapss, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\trc = TSS_TPMS_SIG_SCHEME_ECDSA_Unmarshalu(&target->ecdsa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\trc = TSS_TPMS_SIG_SCHEME_ECDAA_Unmarshalu(&target->ecdaa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM2\n      case TPM_ALG_SM2:\n\trc = TSS_TPMS_SIG_SCHEME_SM2_Unmarshalu(&target->sm2, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\trc = TSS_TPMS_SIG_SCHEME_ECSCHNORR_Unmarshalu(&target->ecSchnorr, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAES\n      case TPM_ALG_RSAES:\n\trc = TSS_TPMS_ENC_SCHEME_RSAES_Unmarshalu(&target->rsaes, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_OAEP\n      case TPM_ALG_OAEP:\n\trc = TSS_TPMS_ENC_SCHEME_OAEP_Unmarshalu(&target->oaep, buffer, size);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 153 - Definition of TPMT_ASYM_SCHEME Structure <> */\n\n#if 0\nTPM_RC\nTSS_TPMT_ASYM_SCHEME_Unmarshalu(TPMT_ASYM_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_ASYM_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_ASYM_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n#endif\t/* 0 */\n\n/* Table 154 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_SCHEME Type */\n\nTPM_RC\nTSS_TPMI_ALG_RSA_SCHEME_Unmarshalu(TPMI_ALG_RSA_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 155 - Definition of {RSA} TPMT_RSA_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_RSA_SCHEME_Unmarshalu(TPMT_RSA_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_RSA_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_ASYM_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 156 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_DECRYPT Type */\n\nTPM_RC\nTSS_TPMI_ALG_RSA_DECRYPT_Unmarshalu(TPMI_ALG_RSA_DECRYPT *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 157 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */\n\nTPM_RC\nTSS_TPMT_RSA_DECRYPT_Unmarshalu(TPMT_RSA_DECRYPT *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_RSA_DECRYPT_Unmarshalu(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_ASYM_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* #endif TPM_TSS_NOCMDCHECK */\n\n/* Table 158 - Definition of {RSA} TPM2B_PUBLIC_KEY_RSA Structure */\nTPM_RC\nTSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(TPM2B_PUBLIC_KEY_RSA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 159 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type */\n\nTPM_RC\nTSS_TPMI_RSA_KEY_BITS_Unmarshalu(TPMI_RSA_KEY_BITS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 160 - Definition of {RSA} TPM2B_PRIVATE_KEY_RSA Structure */\n\nTPM_RC\nTSS_TPM2B_PRIVATE_KEY_RSA_Unmarshalu(TPM2B_PRIVATE_KEY_RSA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n \n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 161 - Definition of {ECC} TPM2B_ECC_PARAMETER Structure */\n\nTPM_RC\nTSS_TPM2B_ECC_PARAMETER_Unmarshalu(TPM2B_ECC_PARAMETER *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n     \trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 162 - Definition of {ECC} TPMS_ECC_POINT Structure */\n\nTPM_RC\nTSS_TPMS_ECC_POINT_Unmarshalu(TPMS_ECC_POINT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->x, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->y, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 163 - Definition of {ECC} TPM2B_ECC_POINT Structure */\n\nTPM_RC\nTSS_TPM2B_ECC_POINT_Unmarshalu(TPM2B_ECC_POINT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t startSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_ECC_POINT_Unmarshalu(&target->point, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* Table 164 - Definition of (TPM_ALG_ID) {ECC} TPMI_ALG_ECC_SCHEME Type */\n\nTPM_RC\nTSS_TPMI_ALG_ECC_SCHEME_Unmarshalu(TPMI_ALG_ECC_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 165 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */\n\nTPM_RC\nTSS_TPMI_ECC_CURVE_Unmarshalu(TPMI_ECC_CURVE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ECC_CURVE_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 166 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_ECC_SCHEME_Unmarshalu(TPMT_ECC_SCHEME *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_ECC_SCHEME_Unmarshalu(&target->scheme, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_ASYM_SCHEME_Unmarshalu(&target->details, buffer, size, target->scheme);\n    }\n    return rc;\n}\n\n/* Table 167 - Definition of {ECC} TPMS_ALGORITHM_DETAIL_ECC Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_ALGORITHM_DETAIL_ECC_Unmarshalu(TPMS_ALGORITHM_DETAIL_ECC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ECC_CURVE_Unmarshalu(&target->curveID, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->keySize, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_KDF_SCHEME_Unmarshalu(&target->kdf, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_ECC_SCHEME_Unmarshalu(&target->sign, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->p, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->a, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->b, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->gX, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->gY, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->n, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->h, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 168 - Definition of {RSA} TPMS_SIGNATURE_RSA Structure */\n\nTPM_RC\nTSS_TPMS_SIGNATURE_RSA_Unmarshalu(TPMS_SIGNATURE_RSA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hash, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->sig, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 169 - Definition of Types for {RSA} Signature */\n\nTPM_RC\nTSS_TPMS_SIGNATURE_RSASSA_Unmarshalu(TPMS_SIGNATURE_RSASSA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SIGNATURE_RSA_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 169 - Definition of Types for {RSA} Signature */\n    \nTPM_RC\nTSS_TPMS_SIGNATURE_RSAPSS_Unmarshalu(TPMS_SIGNATURE_RSAPSS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SIGNATURE_RSA_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 170 - Definition of {ECC} TPMS_SIGNATURE_ECC Structure */\n\nTPM_RC\nTSS_TPMS_SIGNATURE_ECC_Unmarshalu(TPMS_SIGNATURE_ECC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->hash, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->signatureR, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->signatureS, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 171 - Definition of Types for {ECC} TPMS_SIGNATURE_ECC */\n\nTPM_RC\nTSS_TPMS_SIGNATURE_ECDSA_Unmarshalu(TPMS_SIGNATURE_ECDSA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n     \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPMS_SIGNATURE_ECDAA_Unmarshalu(TPMS_SIGNATURE_ECDAA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n     \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPMS_SIGNATURE_SM2_Unmarshalu(TPMS_SIGNATURE_SM2 *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n     \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPMS_SIGNATURE_ECSCHNORR_Unmarshalu(TPMS_SIGNATURE_ECSCHNORR *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n     \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 172 - Definition of TPMU_SIGNATURE Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_SIGNATURE_Unmarshalu(TPMU_SIGNATURE *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\trc = TSS_TPMS_SIGNATURE_RSASSA_Unmarshalu(&target->rsassa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\trc = TSS_TPMS_SIGNATURE_RSAPSS_Unmarshalu(&target->rsapss, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\trc = TSS_TPMS_SIGNATURE_ECDSA_Unmarshalu(&target->ecdsa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\trc = TSS_TPMS_SIGNATURE_ECDAA_Unmarshalu(&target->ecdaa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM2\n      case TPM_ALG_SM2:\n\trc = TSS_TPMS_SIGNATURE_SM2_Unmarshalu(&target->sm2, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\trc = TSS_TPMS_SIGNATURE_ECSCHNORR_Unmarshalu(&target->ecschnorr, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_HMAC\n      case TPM_ALG_HMAC:\n\trc = TSS_TPMT_HA_Unmarshalu(&target->hmac, buffer, size, NO);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 173 - Definition of TPMT_SIGNATURE Structure */\n\nTPM_RC\nTSS_TPMT_SIGNATURE_Unmarshalu(TPMT_SIGNATURE *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_SIG_SCHEME_Unmarshalu(&target->sigAlg, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_SIGNATURE_Unmarshalu(&target->signature, buffer, size, target->sigAlg);\n    }\n    return rc;\n}\n\n/* Table 175 - Definition of TPM2B_ENCRYPTED_SECRET Structure */\n\nTPM_RC\nTSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(TPM2B_ENCRYPTED_SECRET *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.secret), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 176 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */\n\nTPM_RC\nTSS_TPMI_ALG_PUBLIC_Unmarshalu(TPMI_ALG_PUBLIC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(target, buffer, size);  \n    }\n    return rc;\n}\n\n/* Table 177 - Definition of TPMU_PUBLIC_ID Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_PUBLIC_ID_Unmarshalu(TPMU_PUBLIC_ID *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->keyedHash, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->sym, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA: \n\trc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->rsa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\trc = TSS_TPMS_ECC_POINT_Unmarshalu(&target->ecc, buffer, size);\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 178 - Definition of TPMS_KEYEDHASH_PARMS Structure */\n\nTPM_RC\nTSS_TPMS_KEYEDHASH_PARMS_Unmarshalu(TPMS_KEYEDHASH_PARMS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_KEYEDHASH_SCHEME_Unmarshalu(&target->scheme, buffer, size, YES);\n    }\n    return rc;\n}\n\n/* Table 179 - Definition of TPMS_ASYM_PARMS Structure <> */\n\n#if 0\nTPM_RC\nTSS_TPMS_ASYM_PARMS_Unmarshalu(TPMS_ASYM_PARMS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetric, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_ASYM_SCHEME_Unmarshalu(&target->scheme, buffer, size, YES);\n    }\n    return rc;\n}\n#endif\n\n/* Table 180 - Definition of {RSA} TPMS_RSA_PARMS Structure */\n\nTPM_RC\nTSS_TPMS_RSA_PARMS_Unmarshalu(TPMS_RSA_PARMS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetric, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_RSA_SCHEME_Unmarshalu(&target->scheme, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RSA_KEY_BITS_Unmarshalu(&target->keyBits, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->exponent, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 181 - Definition of {ECC} TPMS_ECC_PARMS Structure */\n\nTPM_RC\nTSS_TPMS_ECC_PARMS_Unmarshalu(TPMS_ECC_PARMS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(&target->symmetric, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_ECC_SCHEME_Unmarshalu(&target->scheme, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ECC_CURVE_Unmarshalu(&target->curveID, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_KDF_SCHEME_Unmarshalu(&target->kdf, buffer, size, YES);\n    }\n    return rc;\n}\n\n/* Table 182 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_PUBLIC_PARMS_Unmarshalu(TPMU_PUBLIC_PARMS *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\trc = TSS_TPMS_KEYEDHASH_PARMS_Unmarshalu(&target->keyedHashDetail, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\trc = TSS_TPMS_SYMCIPHER_PARMS_Unmarshalu(&target->symDetail, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA:\n\trc = TSS_TPMS_RSA_PARMS_Unmarshalu(&target->rsaDetail, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\trc = TSS_TPMS_ECC_PARMS_Unmarshalu(&target->eccDetail, buffer, size);\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 183 - Definition of TPMT_PUBLIC_PARMS Structure */\n\nTPM_RC\nTSS_TPMT_PUBLIC_PARMS_Unmarshalu(TPMT_PUBLIC_PARMS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_PUBLIC_Unmarshalu(&target->type, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_PUBLIC_PARMS_Unmarshalu(&target->parameters, buffer, size, target->type);\n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 184 - Definition of TPMT_PUBLIC Structure */\n\nTPM_RC\nTSS_TPMT_PUBLIC_Unmarshalu(TPMT_PUBLIC *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_PUBLIC_Unmarshalu(&target->type, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->nameAlg, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMA_OBJECT_Unmarshalu(&target->objectAttributes, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->authPolicy, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_PUBLIC_PARMS_Unmarshalu(&target->parameters, buffer, size, target->type);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_PUBLIC_ID_Unmarshalu(&target->unique, buffer, size, target->type);\n    }\n    return rc;\n}\n\n/* Table 185 - Definition of TPM2B_PUBLIC Structure */\n\nTPM_RC\nTSS_TPM2B_PUBLIC_Unmarshalu(TPM2B_PUBLIC *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t startSize = 0;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_PUBLIC_Unmarshalu(&target->publicArea, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 192 - Definition of TPM2B_TEMPLATE Structure */\n\nTPM_RC\nTSS_TPM2B_TEMPLATE_Unmarshalu(TPM2B_TEMPLATE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n    \n/* Table 187 - Definition of TPMU_SENSITIVE_COMPOSITE Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_SENSITIVE_COMPOSITE_Unmarshalu(TPMU_SENSITIVE_COMPOSITE *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    switch (selector) {\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA:\n\trc = TSS_TPM2B_PRIVATE_KEY_RSA_Unmarshalu(&target->rsa, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\trc = TSS_TPM2B_ECC_PARAMETER_Unmarshalu(&target->ecc, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\trc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->bits, buffer, size);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\trc = TSS_TPM2B_SYM_KEY_Unmarshalu(&target->sym, buffer, size);\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 188 - Definition of TPMT_SENSITIVE Structure */\n\nTPM_RC\nTSS_TPMT_SENSITIVE_Unmarshalu(TPMT_SENSITIVE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_PUBLIC_Unmarshalu(&target->sensitiveType, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->authValue, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->seedValue, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_SENSITIVE_COMPOSITE_Unmarshalu(&target->sensitive, buffer, size, target->sensitiveType);\n    }\n    return rc;\n}\n\n/* Table 189 - Definition of TPM2B_SENSITIVE Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_SENSITIVE_Unmarshalu(TPM2B_SENSITIVE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t startSize = 0;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->t.size, buffer, size);\n    }\n    if (target->t.size != 0) {\n\tif (rc == TPM_RC_SUCCESS) {\n\t    startSize = *size;\n\t}\n\tif (rc == TPM_RC_SUCCESS) {\n\t    rc = TSS_TPMT_SENSITIVE_Unmarshalu(&target->t.sensitiveArea, buffer, size);\n\t}\n\tif (rc == TPM_RC_SUCCESS) {\n\t    if (target->t.size != startSize - *size) {\n\t\trc = TPM_RC_SIZE;\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 191 - Definition of TPM2B_PRIVATE Structure <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM2B_PRIVATE_Unmarshalu(TPM2B_PRIVATE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 193 - Definition of TPM2B_ID_OBJECT Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_ID_OBJECT_Unmarshalu(TPM2B_ID_OBJECT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.credential), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 196 - Definition of (UINT32) TPMA_NV Bits */\n\nTPM_RC\nTSS_TPMA_NV_Unmarshalu(TPMA_NV *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->val, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->val & TPMA_NV_RESERVED) {\n\t    rc = TPM_RC_RESERVED_BITS;\n\t}\n    }\n    return rc;\n}\n\n/* Table 197 - Definition of TPMS_NV_PUBLIC Structure */\n\nTPM_RC\nTSS_TPMS_NV_PUBLIC_Unmarshalu(TPMS_NV_PUBLIC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_NV_INDEX_Unmarshalu(&target->nvIndex, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->nameAlg, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMA_NV_Unmarshalu(&target->attributes, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->authPolicy, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->dataSize, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 198 - Definition of TPM2B_NV_PUBLIC Structure */\n\nTPM_RC\nTSS_TPM2B_NV_PUBLIC_Unmarshalu(TPM2B_NV_PUBLIC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t startSize = 0;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_NV_PUBLIC_Unmarshalu(&target->nvPublic, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* #ifndef TPM_TSS_NOCMDCHECK */\n\n/* Table 199 - Definition of TPM2B_CONTEXT_SENSITIVE Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_CONTEXT_SENSITIVE_Unmarshalu(TPM2B_CONTEXT_SENSITIVE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 200 - Definition of TPMS_CONTEXT_DATA Structure <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMS_CONTEXT_DATA_Unmarshalu(TPMS_CONTEXT_DATA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->integrity, buffer, size);\t\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_CONTEXT_SENSITIVE_Unmarshalu(&target->encrypted, buffer, size);\n    }\n    return rc;\n}\n\n/* #endif\tTPM_TSS_NOCMDCHECK */\n\n/* Table 201 - Definition of TPM2B_CONTEXT_DATA Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_CONTEXT_DATA_Unmarshalu(TPM2B_CONTEXT_DATA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_Unmarshalu(&target->b, sizeof(target->t.buffer), buffer, size);\n    }\n    return rc;\n}\n\n/* Table 202 - Definition of TPMS_CONTEXT Structure */\n\nTPM_RC\nTSS_TPMS_CONTEXT_Unmarshalu(TPMS_CONTEXT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT64_Unmarshalu(&target->sequence, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_DH_SAVED_Unmarshalu(&target->savedHandle, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_RH_HIERARCHY_Unmarshalu(&target->hierarchy, buffer, size, YES);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_CONTEXT_DATA_Unmarshalu(&target->contextBlob, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 204 - Definition of TPMS_CREATION_DATA Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_CREATION_DATA_Unmarshalu(TPMS_CREATION_DATA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrSelect, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->pcrDigest, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMA_LOCALITY_Unmarshalu(&target->locality, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_Unmarshalu(&target->parentNameAlg, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->parentName, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->parentQualifiedName, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->outsideInfo, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 205 - Definition of TPM2B_CREATION_DATA Structure <OUT> */\n\nTPM_RC\nTSS_TPM2B_CREATION_DATA_Unmarshalu(TPM2B_CREATION_DATA *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t startSize = 0;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->size, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tstartSize = *size;\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_CREATION_DATA_Unmarshalu(&target->creationData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->size != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n#ifndef TPM_TSS_NODEPRECATED\n\n/* Deprecated functions that use a sized value for the size parameter.  The recommended functions\n   use an unsigned value.\n\n*/\n\nTPM_RC TPM2B_Unmarshal(TPM2B *target, UINT16 targetSize, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_Unmarshalu(target, targetSize, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_KEY_BITS_Unmarshal(TPM_KEY_BITS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_KEY_BITS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_GENERATED_Unmarshal(TPM_GENERATED *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_GENERATED_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_ALG_ID_Unmarshal(TPM_ALG_ID *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_ALG_ID_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_ECC_CURVE_Unmarshal(TPM_ECC_CURVE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_ECC_CURVE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_CC_Unmarshal(TPM_RC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_CC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_RC_Unmarshal(TPM_RC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_RC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_CLOCK_ADJUST_Unmarshal(TPM_CLOCK_ADJUST *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_CLOCK_ADJUST_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_EO_Unmarshal(TPM_EO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_EO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_ST_Unmarshal(TPM_ST *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_ST_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_SU_Unmarshal(TPM_SU *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_SU_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_SE_Unmarshal(TPM_SE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_SE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_CAP_Unmarshal(TPM_CAP *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_CAP_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_PT_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_PT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_PT_PCR_Unmarshal(TPM_PT_PCR *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_PT_PCR_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM_HANDLE_Unmarshal(TPM_HANDLE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_HANDLE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMA_ALGORITHM_Unmarshal(TPMA_ALGORITHM *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_ALGORITHM_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMA_OBJECT_Unmarshal(TPMA_OBJECT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMA_SESSION_Unmarshal(TPMA_SESSION *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_SESSION_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMA_LOCALITY_Unmarshal(TPMA_LOCALITY *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_LOCALITY_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMA_CC_Unmarshal(TPMA_CC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_CC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_YES_NO_Unmarshal(TPMI_YES_NO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_YES_NO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_DH_OBJECT_Unmarshal(TPMI_DH_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_DH_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\n#if 0\nTPM_RC TPMI_DH_PARENT_Unmarshal(TPMI_DH_PARENT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_DH_PARENT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n#endif\n\nTPM_RC TPMI_DH_PERSISTENT_Unmarshal(TPMI_DH_PERSISTENT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_DH_PERSISTENT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_DH_ENTITY_Unmarshal(TPMI_DH_ENTITY *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_DH_ENTITY_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_DH_PCR_Unmarshal(TPMI_DH_PCR *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_DH_PCR_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_SH_AUTH_SESSION_Unmarshal(TPMI_SH_AUTH_SESSION *target, BYTE **buffer, INT32 *size, BOOL allowPwd)\n{\n    return TSS_TPMI_SH_AUTH_SESSION_Unmarshalu(target, buffer, (uint32_t *)size, allowPwd);\n}\n\nTPM_RC TPMI_SH_HMAC_Unmarshal(TPMI_SH_HMAC *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_SH_HMAC_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_SH_POLICY_Unmarshal(TPMI_SH_POLICY *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_SH_POLICY_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_DH_CONTEXT_Unmarshal(TPMI_DH_CONTEXT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_DH_CONTEXT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_HIERARCHY_Unmarshal(TPMI_RH_HIERARCHY *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_HIERARCHY_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_ENABLES_Unmarshal(TPMI_RH_ENABLES *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_ENABLES_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_HIERARCHY_AUTH_Unmarshal(TPMI_RH_HIERARCHY_AUTH *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_HIERARCHY_AUTH_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_PLATFORM_Unmarshal(TPMI_RH_PLATFORM *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_PLATFORM_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_ENDORSEMENT_Unmarshal(TPMI_RH_ENDORSEMENT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_ENDORSEMENT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_PROVISION_Unmarshal(TPMI_RH_PROVISION *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_PROVISION_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_CLEAR_Unmarshal(TPMI_RH_CLEAR *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_CLEAR_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_NV_AUTH_Unmarshal(TPMI_RH_NV_AUTH *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_NV_AUTH_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_LOCKOUT_Unmarshal(TPMI_RH_LOCKOUT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_LOCKOUT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_RH_NV_INDEX_Unmarshal(TPMI_RH_NV_INDEX *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_RH_NV_INDEX_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ALG_HASH_Unmarshal(TPMI_ALG_HASH *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_HASH_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ALG_SYM_Unmarshal(TPMI_ALG_SYM *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_SYM_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ALG_SYM_OBJECT_Unmarshal(TPMI_ALG_SYM_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_SYM_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ALG_SYM_MODE_Unmarshal(TPMI_ALG_SYM_MODE *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_SYM_MODE_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ALG_KDF_Unmarshal(TPMI_ALG_KDF *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_KDF_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ALG_SIG_SCHEME_Unmarshal(TPMI_ALG_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_SIG_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ECC_KEY_EXCHANGE_Unmarshal(TPMI_ECC_KEY_EXCHANGE *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ECC_KEY_EXCHANGE_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ST_COMMAND_TAG_Unmarshal(TPMI_ST_COMMAND_TAG *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ST_COMMAND_TAG_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_ALG_MAC_SCHEME_Unmarshal(TPMI_ALG_MAC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_MAC_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ALG_CIPHER_MODE_Unmarshal(TPMI_ALG_CIPHER_MODE *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_CIPHER_MODE_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\n/* NOTE: Marked as const function in header */\n\nTPM_RC TPMS_EMPTY_Unmarshal(TPMS_EMPTY *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_EMPTY_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_HA_Unmarshal(TPMU_HA *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_HA_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMT_HA_Unmarshal(TPMT_HA *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_HA_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPM2B_DIGEST_Unmarshal(TPM2B_DIGEST *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_DIGEST_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_DATA_Unmarshal(TPM2B_DATA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_DATA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_NONCE_Unmarshal(TPM2B_NONCE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_NONCE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_AUTH_Unmarshal(TPM2B_AUTH *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_AUTH_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_OPERAND_Unmarshal(TPM2B_OPERAND *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_OPERAND_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_EVENT_Unmarshal(TPM2B_EVENT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_EVENT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_MAX_BUFFER_Unmarshal(TPM2B_MAX_BUFFER *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_MAX_BUFFER_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_MAX_NV_BUFFER_Unmarshal(TPM2B_MAX_NV_BUFFER *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_TIMEOUT_Unmarshal(TPM2B_TIMEOUT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_TIMEOUT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_IV_Unmarshal(TPM2B_IV *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_IV_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_NAME_Unmarshal(TPM2B_NAME *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_NAME_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_PCR_SELECTION_Unmarshal(TPMS_PCR_SELECTION *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_PCR_SELECTION_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMT_TK_CREATION_Unmarshal(TPMT_TK_CREATION *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_TK_CREATION_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMT_TK_VERIFIED_Unmarshal(TPMT_TK_VERIFIED *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_TK_VERIFIED_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMT_TK_AUTH_Unmarshal(TPMT_TK_AUTH *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_TK_AUTH_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMT_TK_HASHCHECK_Unmarshal(TPMT_TK_HASHCHECK *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_TK_HASHCHECK_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_ALG_PROPERTY_Unmarshal(TPMS_ALG_PROPERTY *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ALG_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_TAGGED_PROPERTY_Unmarshal(TPMS_TAGGED_PROPERTY *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_TAGGED_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_TAGGED_PCR_SELECT_Unmarshal(TPMS_TAGGED_PCR_SELECT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_TAGGED_PCR_SELECT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_CC_Unmarshal(TPML_CC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_CC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_CCA_Unmarshal(TPML_CCA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_CCA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_ALG_Unmarshal(TPML_ALG *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_ALG_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_HANDLE_Unmarshal(TPML_HANDLE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_HANDLE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_DIGEST_Unmarshal(TPML_DIGEST *target, BYTE **buffer, INT32 *size,uint32_t minCount)\n{\n    return TSS_TPML_DIGEST_Unmarshalu(target, buffer, (uint32_t *)size, minCount);\n}\n\nTPM_RC TPML_DIGEST_VALUES_Unmarshal(TPML_DIGEST_VALUES *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_DIGEST_VALUES_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_PCR_SELECTION_Unmarshal(TPML_PCR_SELECTION *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_PCR_SELECTION_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_ALG_PROPERTY_Unmarshal(TPML_ALG_PROPERTY *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_ALG_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_TAGGED_TPM_PROPERTY_Unmarshal(TPML_TAGGED_TPM_PROPERTY  *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_TAGGED_TPM_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_TAGGED_PCR_PROPERTY_Unmarshal(TPML_TAGGED_PCR_PROPERTY  *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_TAGGED_PCR_PROPERTY_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPML_ECC_CURVE_Unmarshal(TPML_ECC_CURVE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_ECC_CURVE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\n#if 0\nTPM_RC TPML_TAGGED_POLICY_Unmarshal(TPML_TAGGED_POLICY *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_TAGGED_POLICY_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n#endif\n\nTPM_RC TPMU_CAPABILITIES_Unmarshal(TPMU_CAPABILITIES *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_CAPABILITIES_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMS_CLOCK_INFO_Unmarshal(TPMS_CLOCK_INFO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CLOCK_INFO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_TIME_INFO_Unmarshal(TPMS_TIME_INFO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_TIME_INFO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_TIME_ATTEST_INFO_Unmarshal(TPMS_TIME_ATTEST_INFO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_TIME_ATTEST_INFO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_CERTIFY_INFO_Unmarshal(TPMS_CERTIFY_INFO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CERTIFY_INFO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_QUOTE_INFO_Unmarshal(TPMS_QUOTE_INFO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_QUOTE_INFO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_COMMAND_AUDIT_INFO_Unmarshal(TPMS_COMMAND_AUDIT_INFO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_COMMAND_AUDIT_INFO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SESSION_AUDIT_INFO_Unmarshal(TPMS_SESSION_AUDIT_INFO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SESSION_AUDIT_INFO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_CREATION_INFO_Unmarshal(TPMS_CREATION_INFO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CREATION_INFO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_NV_CERTIFY_INFO_Unmarshal(TPMS_NV_CERTIFY_INFO *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_NV_CERTIFY_INFO_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_ST_ATTEST_Unmarshal(TPMI_ST_ATTEST *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ST_ATTEST_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_ATTEST_Unmarshal(TPMU_ATTEST *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_ATTEST_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMS_ATTEST_Unmarshal(TPMS_ATTEST *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ATTEST_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_ATTEST_Unmarshal(TPM2B_ATTEST *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ATTEST_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_CAPABILITY_DATA_Unmarshal(TPMS_CAPABILITY_DATA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CAPABILITY_DATA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_AUTH_RESPONSE_Unmarshal(TPMS_AUTH_RESPONSE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_AUTH_RESPONSE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_AES_KEY_BITS_Unmarshal(TPMI_AES_KEY_BITS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_AES_KEY_BITS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_SYM_KEY_BITS_Unmarshal(TPMU_SYM_KEY_BITS *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SYM_KEY_BITS_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMU_SYM_MODE_Unmarshal(TPMU_SYM_MODE *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SYM_MODE_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMT_SYM_DEF_Unmarshal(TPMT_SYM_DEF *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_SYM_DEF_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMT_SYM_DEF_OBJECT_Unmarshal(TPMT_SYM_DEF_OBJECT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_SYM_DEF_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPM2B_SYM_KEY_Unmarshal(TPM2B_SYM_KEY *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_SYM_KEY_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SYMCIPHER_PARMS_Unmarshal(TPMS_SYMCIPHER_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SYMCIPHER_PARMS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\n#if 0\nTPM_RC TPM2B_LABEL_Unmarshal(TPM2B_LABEL *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_LABEL_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n#endif\n\nTPM_RC TPM2B_SENSITIVE_DATA_Unmarshal(TPM2B_SENSITIVE_DATA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SENSITIVE_CREATE_Unmarshal(TPMS_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SENSITIVE_CREATE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_SENSITIVE_CREATE_Unmarshal(TPM2B_SENSITIVE_CREATE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_SENSITIVE_CREATE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SCHEME_HASH_Unmarshal(TPMS_SCHEME_HASH *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_HASH_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SCHEME_ECDAA_Unmarshal(TPMS_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size) \n{\n    return TSS_TPMS_SCHEME_ECDAA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_ALG_KEYEDHASH_SCHEME_Unmarshal(TPMI_ALG_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_KEYEDHASH_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMS_SCHEME_HMAC_Unmarshal(TPMS_SCHEME_HMAC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_HMAC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SCHEME_XOR_Unmarshal(TPMS_SCHEME_XOR *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_XOR_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_SCHEME_KEYEDHASH_Unmarshal(TPMU_SCHEME_KEYEDHASH *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SCHEME_KEYEDHASH_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMT_KEYEDHASH_SCHEME_Unmarshal(TPMT_KEYEDHASH_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_KEYEDHASH_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMS_SIG_SCHEME_ECDAA_Unmarshal(TPMS_SIG_SCHEME_ECDAA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_ECDAA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIG_SCHEME_ECDSA_Unmarshal(TPMS_SIG_SCHEME_ECDSA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_ECDSA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIG_SCHEME_ECSCHNORR_Unmarshal(TPMS_SIG_SCHEME_ECSCHNORR *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_ECSCHNORR_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIG_SCHEME_RSAPSS_Unmarshal(TPMS_SIG_SCHEME_RSAPSS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_RSAPSS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIG_SCHEME_RSASSA_Unmarshal(TPMS_SIG_SCHEME_RSASSA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_RSASSA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIG_SCHEME_SM2_Unmarshal(TPMS_SIG_SCHEME_SM2 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_SM2_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_SIG_SCHEME_Unmarshal(TPMU_SIG_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SIG_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMT_SIG_SCHEME_Unmarshal(TPMT_SIG_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_SIG_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMS_ENC_SCHEME_OAEP_Unmarshal(TPMS_ENC_SCHEME_OAEP *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ENC_SCHEME_OAEP_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\n/* NOTE: Marked as const function in header */\n\nTPM_RC TPMS_ENC_SCHEME_RSAES_Unmarshal(TPMS_ENC_SCHEME_RSAES *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ENC_SCHEME_RSAES_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_KEY_SCHEME_ECDH_Unmarshal(TPMS_KEY_SCHEME_ECDH *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_KEY_SCHEME_ECDH_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_KEY_SCHEME_ECMQV_Unmarshal(TPMS_KEY_SCHEME_ECMQV *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_KEY_SCHEME_ECMQV_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SCHEME_KDF1_SP800_108_Unmarshal(TPMS_SCHEME_KDF1_SP800_108 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_KDF1_SP800_108_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SCHEME_KDF1_SP800_56A_Unmarshal(TPMS_SCHEME_KDF1_SP800_56A *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_KDF1_SP800_56A_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SCHEME_KDF2_Unmarshal(TPMS_SCHEME_KDF2 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_KDF2_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SCHEME_MGF1_Unmarshal(TPMS_SCHEME_MGF1 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_MGF1_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_KDF_SCHEME_Unmarshal(TPMU_KDF_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_KDF_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMT_KDF_SCHEME_Unmarshal(TPMT_KDF_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_KDF_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\n#if 0\nTPM_RC TPMI_ALG_ASYM_SCHEME_Unmarshal(TPMI_ALG_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_ASYM_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n#endif\n\nTPM_RC TPMU_ASYM_SCHEME_Unmarshal(TPMU_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_ASYM_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\n#if 0\nTPM_RC TPMT_ASYM_SCHEME_Unmarshal(TPMT_ASYM_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_ASYM_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n#endif\n\nTPM_RC TPMI_ALG_RSA_SCHEME_Unmarshal(TPMI_ALG_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_RSA_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMT_RSA_SCHEME_Unmarshal(TPMT_RSA_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_RSA_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ALG_RSA_DECRYPT_Unmarshal(TPMI_ALG_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_RSA_DECRYPT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMT_RSA_DECRYPT_Unmarshal(TPMT_RSA_DECRYPT *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_RSA_DECRYPT_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPM2B_PUBLIC_KEY_RSA_Unmarshal(TPM2B_PUBLIC_KEY_RSA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_RSA_KEY_BITS_Unmarshal(TPMI_RSA_KEY_BITS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RSA_KEY_BITS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_PRIVATE_KEY_RSA_Unmarshal(TPM2B_PRIVATE_KEY_RSA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_PRIVATE_KEY_RSA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_ECC_PARAMETER_Unmarshal(TPM2B_ECC_PARAMETER *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ECC_PARAMETER_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_ECC_POINT_Unmarshal(TPMS_ECC_POINT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ECC_POINT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_ECC_POINT_Unmarshal(TPM2B_ECC_POINT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ECC_POINT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_ALG_ECC_SCHEME_Unmarshal(TPMI_ALG_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMI_ALG_ECC_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMI_ECC_CURVE_Unmarshal(TPMI_ECC_CURVE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ECC_CURVE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMT_ECC_SCHEME_Unmarshal(TPMT_ECC_SCHEME *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_ECC_SCHEME_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPMS_ALGORITHM_DETAIL_ECC_Unmarshal(TPMS_ALGORITHM_DETAIL_ECC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ALGORITHM_DETAIL_ECC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIGNATURE_RSA_Unmarshal(TPMS_SIGNATURE_RSA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_RSA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIGNATURE_RSASSA_Unmarshal(TPMS_SIGNATURE_RSASSA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_RSASSA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIGNATURE_RSAPSS_Unmarshal(TPMS_SIGNATURE_RSAPSS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_RSAPSS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIGNATURE_ECC_Unmarshal(TPMS_SIGNATURE_ECC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_ECC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIGNATURE_ECDSA_Unmarshal(TPMS_SIGNATURE_ECDSA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_ECDSA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIGNATURE_ECDAA_Unmarshal(TPMS_SIGNATURE_ECDAA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_ECDAA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIGNATURE_SM2_Unmarshal(TPMS_SIGNATURE_SM2 *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_SM2_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_SIGNATURE_ECSCHNORR_Unmarshal(TPMS_SIGNATURE_ECSCHNORR *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_ECSCHNORR_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_SIGNATURE_Unmarshal(TPMU_SIGNATURE *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SIGNATURE_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMT_SIGNATURE_Unmarshal(TPMT_SIGNATURE *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_SIGNATURE_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPM2B_ENCRYPTED_SECRET_Unmarshal(TPM2B_ENCRYPTED_SECRET *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMI_ALG_PUBLIC_Unmarshal(TPMI_ALG_PUBLIC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_PUBLIC_ID_Unmarshal(TPMU_PUBLIC_ID *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_PUBLIC_ID_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMS_KEYEDHASH_PARMS_Unmarshal(TPMS_KEYEDHASH_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_KEYEDHASH_PARMS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\n#if 0\nTPM_RC TPMS_ASYM_PARMS_Unmarshal(TPMS_ASYM_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ASYM_PARMS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n#endif\n\nTPM_RC TPMS_RSA_PARMS_Unmarshal(TPMS_RSA_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_RSA_PARMS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_ECC_PARMS_Unmarshal(TPMS_ECC_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ECC_PARMS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_PUBLIC_PARMS_Unmarshal(TPMU_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_PUBLIC_PARMS_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMT_PUBLIC_PARMS_Unmarshal(TPMT_PUBLIC_PARMS *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_PUBLIC_PARMS_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMT_PUBLIC_Unmarshal(TPMT_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPMT_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPM2B_PUBLIC_Unmarshal(TPM2B_PUBLIC *target, BYTE **buffer, INT32 *size, BOOL allowNull)\n{\n    return TSS_TPM2B_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size, allowNull);\n}\n\nTPM_RC TPM2B_TEMPLATE_Unmarshal(TPM2B_TEMPLATE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_TEMPLATE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMU_SENSITIVE_COMPOSITE_Unmarshal(TPMU_SENSITIVE_COMPOSITE *target, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SENSITIVE_COMPOSITE_Unmarshalu(target, buffer, (uint32_t *)size, selector);\n}\n\nTPM_RC TPMT_SENSITIVE_Unmarshal(TPMT_SENSITIVE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_SENSITIVE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_SENSITIVE_Unmarshal(TPM2B_SENSITIVE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_SENSITIVE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_PRIVATE_Unmarshal(TPM2B_PRIVATE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_PRIVATE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_ID_OBJECT_Unmarshal(TPM2B_ID_OBJECT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ID_OBJECT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMA_NV_Unmarshal(TPMA_NV *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_NV_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_NV_PUBLIC_Unmarshal(TPMS_NV_PUBLIC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_NV_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_NV_PUBLIC_Unmarshal(TPM2B_NV_PUBLIC *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_NV_PUBLIC_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_CONTEXT_SENSITIVE_Unmarshal(TPM2B_CONTEXT_SENSITIVE *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_CONTEXT_SENSITIVE_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_CONTEXT_DATA_Unmarshal(TPMS_CONTEXT_DATA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CONTEXT_DATA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_CONTEXT_DATA_Unmarshal(TPM2B_CONTEXT_DATA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_CONTEXT_DATA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_CONTEXT_Unmarshal(TPMS_CONTEXT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CONTEXT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPMS_CREATION_DATA_Unmarshal(TPMS_CREATION_DATA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CREATION_DATA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\nTPM_RC TPM2B_CREATION_DATA_Unmarshal(TPM2B_CREATION_DATA *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_CREATION_DATA_Unmarshalu(target, buffer, (uint32_t *)size);\n}\n\n#endif \t/* TPM_TSS_NODEPRECATED */\n\n#endif /* TPM_TPM20 */\n"
  },
  {
    "path": "ibmtss-ftpm/Unmarshal12.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Parameter Unmarshaling\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*            $Id: Unmarshal12.c 1285 2018-07-27 18:33:41Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015, 2017\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <string.h>\n\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tpmconstants12.h>\n#include <ibmtss/Unmarshal12_fp.h>\n\nTPM_RC\nTSS_TPM_STARTUP_TYPE_Unmarshalu(TPM_STARTUP_TYPE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_ST_CLEAR:\n\t  case TPM_ST_STATE:\n\t  case TPM_ST_DEACTIVATED:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* 5.0 */\n\n\nTPM_RC\nTSS_TPM_VERSION_Unmarshalu(TPM_VERSION *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->major, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->minor, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->revMajor, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->revMinor, buffer, size);\n    }\n    return rc;\n}\n\n/* 6.0 */\n\nTPM_RC\nTSS_TPM_TAG_Unmarshalu(TPM_TAG *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(target, buffer, size);  \n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tswitch (*target) {\n\t  case TPM_TAG_RSP_COMMAND:\n\t  case TPM_TAG_RSP_AUTH1_COMMAND:\n\t  case TPM_TAG_RSP_AUTH2_COMMAND:\n\t    break;\n\t  default:\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n \n/* 8.0 */\n\nTPM_RC\nTSS_TPM_PCR_SELECTION_Unmarshalu(TPM_PCR_SELECTION *target, BYTE **buffer, uint32_t *size)\n{ \n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->sizeOfSelect, buffer, size);   \n    }\n    if (rc == 0) {\n\tif (target->sizeOfSelect > sizeof(target->pcrSelect)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->pcrSelect, target->sizeOfSelect, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM4B_TPM_PCR_INFO_LONG_Unmarshalu(TPM_PCR_INFO_LONG *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t sizeRead32;\n    uint32_t startSize;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&sizeRead32, buffer, size);\n    }\n    if (rc == 0) {\n\tif (sizeRead32 == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == 0) {\n\tstartSize = *size;\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_INFO_LONG_Unmarshalu(target, buffer, size);\n    }\n    if (rc == 0) {\n\tif (sizeRead32 != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_PCR_INFO_LONG_Unmarshalu(TPM_PCR_INFO_LONG *target, BYTE **buffer, uint32_t *size)\n{ \n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->tag, buffer, size);                      \n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->localityAtCreation, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->localityAtRelease, buffer, size);   \n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_SELECTION_Unmarshalu(&target->creationPCRSelection, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_SELECTION_Unmarshalu(&target->releasePCRSelection, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->digestAtCreation, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->digestAtRelease, SHA1_DIGEST_SIZE, buffer, size); \n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_PCR_INFO_SHORT_Unmarshalu(TPM_PCR_INFO_SHORT *target, BYTE **buffer, uint32_t *size)\n{ \n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_SELECTION_Unmarshalu(&target->pcrSelection, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->localityAtRelease, buffer, size);   \n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->digestAtRelease, SHA1_DIGEST_SIZE, buffer, size); \n    }\n    return rc;\n}\n\n/* 9.0 */\n\nTPM_RC\nTSS_TPM_SYMMETRIC_KEY_Unmarshalu(TPM_SYMMETRIC_KEY *target, BYTE **buffer, uint32_t *size)\n{ \n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->algId, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->encScheme, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->size, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->size > sizeof(target->data)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->data, target->size, buffer, size); \n    }\n    return rc;\n}\n\n/* 10.0 */\n\nTPM_RC\nTSS_TPM_RSA_KEY_PARMS_Unmarshalu(TPM_RSA_KEY_PARMS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->keyLength, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->numPrimes, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->exponentSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->exponentSize > sizeof(target->exponent)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->exponent, target->exponentSize, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPMU_PARMS_Unmarshalu(TPMU_PARMS *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n      case TPM_ALG_RSA:\t\t/* A structure of type TPM_RSA_KEY_PARMS */\n\trc = TSS_TPM_RSA_KEY_PARMS_Unmarshalu(&target->rsaParms, buffer, size);\n\tbreak;\n      case TPM_ALG_AES128:\t/* A structure of type TPM_SYMMETRIC_KEY_PARMS */\n\t/* not implemented yet */\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM4B_TPMU_PARMS_Unmarshalu(TPMU_PARMS *target, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    uint32_t sizeRead32;\n    uint32_t startSize;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&sizeRead32, buffer, size);\n    }\n    if (rc == 0) {\n\tif (sizeRead32 == 0) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == 0) {\n\tstartSize = *size;\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_PARMS_Unmarshalu(target, buffer, size, selector);\n    }\n    if (rc == 0) {\n\tif (sizeRead32 != startSize - *size) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_KEY_PARMS_Unmarshalu(TPM_KEY_PARMS *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->algorithmID, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->encScheme, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->sigScheme, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_TPM4B_TPMU_PARMS_Unmarshalu(&target->parms, buffer, size, target->algorithmID);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_KEY12_Unmarshalu(TPM_KEY12 *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->fill, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->keyUsage, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->keyFlags, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->authDataUsage, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_KEY_PARMS_Unmarshalu(&target->algorithmParms, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM4B_TPM_PCR_INFO_LONG_Unmarshalu(&target->PCRInfo, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_STORE_PUBKEY_Unmarshalu(&target->pubKey, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_STORE_PUBKEY_Unmarshalu(&target->encData, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_STORE_PUBKEY_Unmarshalu(TPM_STORE_PUBKEY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->keyLength, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->keyLength > sizeof(target->key)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->key, target->keyLength, buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n\nTPM_RC\nTSS_TPM_PUBKEY_Unmarshalu(TPM_PUBKEY *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_KEY_PARMS_Unmarshalu(&target->algorithmParms, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_TPM_STORE_PUBKEY_Unmarshalu(&target->pubKey, buffer, size);\n    }\n    return rc;\n}\n\n/* 19 */\n\nTPM_RC\nTSS_TPM_NV_ATTRIBUTES_Unmarshalu(TPM_NV_ATTRIBUTES *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->tag, buffer, size);                      \n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->attributes, buffer, size);                      \n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_NV_DATA_PUBLIC_Unmarshalu(TPM_NV_DATA_PUBLIC *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->tag, buffer, size);                      \n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->nvIndex, buffer, size);                      \n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_INFO_SHORT_Unmarshalu(&target->pcrInfoRead, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_INFO_SHORT_Unmarshalu(&target->pcrInfoWrite, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_NV_ATTRIBUTES_Unmarshalu(&target->permission, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->bReadSTClear, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->bWriteSTClear, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->bWriteDefine, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->dataSize, buffer, size);                      \n    }\n    return rc;\n}\t\t\t\t\t\t  \n\n/* 21 */\n\nTPM_RC\nTSS_TPM_CAP_VERSION_INFO_Unmarshalu(TPM_CAP_VERSION_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_VERSION_Unmarshalu(&target->version, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->specLevel, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->errataRev, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->tpmVendorID, sizeof(target->tpmVendorID), buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->vendorSpecificSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->vendorSpecificSize > sizeof(target->vendorSpecific)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->vendorSpecific, target->vendorSpecificSize, buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n\nTPM_RC\nTSS_TPM_DA_INFO_Unmarshalu(TPM_DA_INFO *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->state, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->currentCount, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->thresholdCount, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_DA_ACTION_TYPE_Unmarshalu(&target->actionAtThreshold, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->actionDependValue, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->vendorDataSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->vendorDataSize > sizeof(target->vendorData)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->vendorData, target->vendorDataSize , buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n\nTPM_RC\nTSS_TPM_DA_INFO_LIMITED_Unmarshalu(TPM_DA_INFO_LIMITED *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->state, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_DA_ACTION_TYPE_Unmarshalu(&target->actionAtThreshold, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->vendorDataSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->vendorDataSize > sizeof(target->vendorData)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->vendorData, target->vendorDataSize , buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n\nTPM_RC\nTSS_TPM_DA_ACTION_TYPE_Unmarshalu(TPM_DA_ACTION_TYPE *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->tag, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->actions, buffer, size);\n    }\n    return rc;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/activatecredential.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    ActivateCredential\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ActivateCredential_In \tin;\n    ActivateCredential_Out \tout;\n    TPMI_DH_OBJECT\t\tactivateHandle = 0;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    const char\t\t\t*inputCredentialFilename = NULL;\n    const char\t\t\t*secretFilename = NULL;\n    const char\t\t\t*outputCredentialFilename = NULL;\n    const char\t\t\t*activatePassword = NULL; \n    const char\t\t\t*keyPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-icred\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinputCredentialFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-icred option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ocred\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutputCredentialFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ocred option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-is\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsecretFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-is option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &activateHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tactivatePassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (activateHandle == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n     if (inputCredentialFilename == NULL) {\n\tprintf(\"Missing name parameter -icred\\n\");\n\tprintUsage();\n    }\n    if (secretFilename == NULL) {\n\tprintf(\"Missing name parameter -is\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.activateHandle = activateHandle;\n\tin.keyHandle = keyHandle;\n    }\n    /* read the credential */\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.credentialBlob,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPM2B_ID_OBJECT_Unmarshalu,\n\t\t\t\t    inputCredentialFilename);\n    }\n    /* read the secret */\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.secret,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu,\n\t\t\t\t    secretFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ActivateCredential,\n\t\t\t sessionHandle0, activatePassword, sessionAttributes0,\n\t\t\t sessionHandle1, keyPassword, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* optionally save the certInfo */\n    if ((rc == 0) && (outputCredentialFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.certInfo.t.buffer,\n\t\t\t\t      out.certInfo.t.size,\n\t\t\t\t      outputCredentialFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"activatecredential: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"activatecredential: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"activatecredential\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ActivateCredential\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tactivation handle of object associated with the certificate\\n\");\n    printf(\"\\t-hk\\thandle of loaded decryption key\\n\");\n    printf(\"\\t-icred\\tinput credential file name\\n\");\n    printf(\"\\t-is\\tsecret file name\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwda\\tpassword for activation key (default empty)]\\n\");\n    printf(\"\\t[-pwdk\\tpassword for decryption key (default empty)]\\n\");\n    printf(\"\\t[-ocred\\t output credential file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2]\\tsession handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/applink.c",
    "content": "#define APPLINK_STDIN\t1\n#define APPLINK_STDOUT\t2\n#define APPLINK_STDERR\t3\n#define APPLINK_FPRINTF\t4\n#define APPLINK_FGETS\t5\n#define APPLINK_FREAD\t6\n#define APPLINK_FWRITE\t7\n#define APPLINK_FSETMOD\t8\n#define APPLINK_FEOF\t9\n#define APPLINK_FCLOSE \t10\t/* should not be used */\n\n#define APPLINK_FOPEN\t11\t/* solely for completeness */\n#define APPLINK_FSEEK\t12\n#define APPLINK_FTELL\t13\n#define APPLINK_FFLUSH\t14\n#define APPLINK_FERROR\t15\n#define APPLINK_CLEARERR 16\n#define APPLINK_FILENO\t17\t/* to be used with below */\n\n#define APPLINK_OPEN\t18\t/* formally can't be used, as flags can vary */\n#define APPLINK_READ\t19\n#define APPLINK_WRITE\t20\n#define APPLINK_LSEEK\t21\n#define APPLINK_CLOSE\t22\n#define APPLINK_MAX\t22\t/* always same as last macro */\n\n#ifndef APPMACROS_ONLY\n#include <stdio.h>\n#include <io.h>\n#include <fcntl.h>\n\nstatic void *app_stdin(void)\t\t{ return stdin;  }\nstatic void *app_stdout(void)\t\t{ return stdout; }\nstatic void *app_stderr(void)\t\t{ return stderr; }\nstatic int   app_feof(FILE *fp)\t\t{ return feof(fp); }\nstatic int   app_ferror(FILE *fp)\t{ return ferror(fp); }\nstatic void  app_clearerr(FILE *fp)\t{ clearerr(fp); }\nstatic int   app_fileno(FILE *fp)\t{ return _fileno(fp); }\nstatic int   app_fsetmod(FILE *fp,char mod)\n{ return _setmode (_fileno(fp),mod=='b'?_O_BINARY:_O_TEXT); }\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n    /* function prototype */\n__declspec(dllexport)\nvoid **\n#if defined(__BORLANDC__)\n    __stdcall\t/* __stdcall appears to be the only way to get the name\n\t\t * decoration right with Borland C. Otherwise it works\n\t\t * purely incidentally, as we pass no parameters. */\n#else\n    __cdecl\n#endif\n    OPENSSL_Applink(void);\n\n    /* function implementation */\n    __declspec(dllexport)\nvoid **\n#if defined(__BORLANDC__)\n__stdcall\t/* __stdcall appears to be the only way to get the name\n\t\t * decoration right with Borland C. Otherwise it works\n\t\t * purely incidentally, as we pass no parameters. */\n#else\n__cdecl\n#endif\nOPENSSL_Applink(void)\n{ static int once=1;\n  static void *OPENSSL_ApplinkTable[APPLINK_MAX+1]={(void *)APPLINK_MAX};\n\n    if (once)\n    {\tOPENSSL_ApplinkTable[APPLINK_STDIN]\t= app_stdin;\n\tOPENSSL_ApplinkTable[APPLINK_STDOUT]\t= app_stdout;\n\tOPENSSL_ApplinkTable[APPLINK_STDERR]\t= app_stderr;\n\tOPENSSL_ApplinkTable[APPLINK_FPRINTF]\t= fprintf;\n\tOPENSSL_ApplinkTable[APPLINK_FGETS]\t= fgets;\n\tOPENSSL_ApplinkTable[APPLINK_FREAD]\t= fread;\n\tOPENSSL_ApplinkTable[APPLINK_FWRITE]\t= fwrite;\n\tOPENSSL_ApplinkTable[APPLINK_FSETMOD]\t= app_fsetmod;\n\tOPENSSL_ApplinkTable[APPLINK_FEOF]\t= app_feof;\n\tOPENSSL_ApplinkTable[APPLINK_FCLOSE]\t= fclose;\n\n\tOPENSSL_ApplinkTable[APPLINK_FOPEN]\t= fopen;\n\tOPENSSL_ApplinkTable[APPLINK_FSEEK]\t= fseek;\n\tOPENSSL_ApplinkTable[APPLINK_FTELL]\t= ftell;\n\tOPENSSL_ApplinkTable[APPLINK_FFLUSH]\t= fflush;\n\tOPENSSL_ApplinkTable[APPLINK_FERROR]\t= app_ferror;\n\tOPENSSL_ApplinkTable[APPLINK_CLEARERR]\t= app_clearerr;\n\tOPENSSL_ApplinkTable[APPLINK_FILENO]\t= app_fileno;\n\n\tOPENSSL_ApplinkTable[APPLINK_OPEN]\t= _open;\n\tOPENSSL_ApplinkTable[APPLINK_READ]\t= _read;\n\tOPENSSL_ApplinkTable[APPLINK_WRITE]\t= _write;\n\tOPENSSL_ApplinkTable[APPLINK_LSEEK]\t= _lseek;\n\tOPENSSL_ApplinkTable[APPLINK_CLOSE]\t= _close;\n\n\tonce = 0;\n    }\n\n  return OPENSSL_ApplinkTable;\n}\n\n#ifdef __cplusplus\n}\n#endif\n#endif\n"
  },
  {
    "path": "ibmtss-ftpm/certify.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Certify\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Certify_In \t\t\tin;\n    Certify_Out \t\tout;\n    TPMI_DH_OBJECT\t\tobjectHandle = 0;\n    TPMI_DH_OBJECT\t\tsignHandle = 0;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    const char\t\t\t*keyPassword = NULL; \n    const char\t\t\t*objectPassword = NULL; \n    const char\t\t\t*signatureFilename = NULL;\n    const char\t\t\t*attestInfoFilename = NULL;\n    const char\t\t\t*qualifyingDataFilename = NULL;\n    TPM_ALG_ID\t\t\tsigAlg = TPM_ALG_RSA;\n    TPMS_ATTEST \t\ttpmsAttest;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ho\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&objectHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ho\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdo\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tobjectPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdo option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&signHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-salg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsa\") == 0) {\n\t\t    sigAlg = TPM_ALG_RSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"ecc\") == 0) {\n\t\t    sigAlg = TPM_ALG_ECDSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"hmac\") == 0) {\n\t\t    sigAlg = TPM_ALG_HMAC;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -salg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-salg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oa\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tattestInfoFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oa option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-qd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tqualifyingDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-qd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (objectHandle == 0) {\n\tprintf(\"Missing object handle parameter -ho\\n\");\n\tprintUsage();\n    }\n    if (signHandle == 0) {\n\tprintf(\"Missing sign handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform certifying */\n\tin.objectHandle = objectHandle;\n\tin.signHandle = signHandle;\n\tif (sigAlg == TPM_ALG_RSA) {\n\t    /* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\t    in.inScheme.scheme = TPM_ALG_RSASSA;\t\n\t    /* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\t    /* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t    /* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t    in.inScheme.details.rsassa.hashAlg = halg;\n\t}\n\telse if (sigAlg == TPM_ALG_ECDSA) {\n\t    in.inScheme.scheme = TPM_ALG_ECDSA;\t\n\t    in.inScheme.details.ecdsa.hashAlg = halg;\n\t}\n\telse {\t/* HMAC */\n\t    in.inScheme.scheme = TPM_ALG_HMAC;\t\n\t    in.inScheme.details.hmac.hashAlg = halg;\n\t}\n    }\n    /* data supplied by the caller */\n    if (rc == 0) {\n\tif (qualifyingDataFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.qualifyingData.b,\n\t\t\t\t sizeof(in.qualifyingData.t.buffer),\n\t\t\t\t qualifyingDataFilename);\n\t}\n\telse {\n\t    in.qualifyingData.t.size = 0;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Certify,\n\t\t\t sessionHandle0, objectPassword, sessionAttributes0,\n\t\t\t sessionHandle1, keyPassword, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tuint8_t *tmpBuffer = out.certifyInfo.t.attestationData;\n\tuint32_t tmpSize = out.certifyInfo.t.size;\n\trc = TSS_TPMS_ATTEST_Unmarshalu(&tpmsAttest, &tmpBuffer, &tmpSize);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMS_ATTEST_Print(&tpmsAttest, 0);\n    }\n    /* For an attestation command using the ECDAA scheme, both the qualifiedSigner and extraData\n       fields in the attestation block (a TPMS_ATTEST) are set to be the Empty Buffer */\n    if ((rc == 0) && (in.inScheme.scheme != ALG_ECDAA_VALUE)) {\n\tint match;\n\tmatch = TSS_TPM2B_Compare(&in.qualifyingData.b, &tpmsAttest.extraData.b);\n\tif (!match) {\n\t    printf(\"certify: failed, extraData != qualifyingData\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if ((rc == 0) && (signatureFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.signature,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_SIGNATURE_Marshalu,\n\t\t\t\t     signatureFilename);\n    }\n    if ((rc == 0) && (attestInfoFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.certifyInfo.t.attestationData,\n\t\t\t\t      out.certifyInfo.t.size,\n\t\t\t\t      attestInfoFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMT_SIGNATURE_Print(&out.signature, 0);\n\tif (tssUtilsVerbose) printf(\"certify: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"certify: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"certify\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Certify\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ho\\tobject handle\\n\");\n    printf(\"\\t[-pwdo\\tpassword for object (default empty)]\\n\");\n    printf(\"\\t-hk\\tcertifying key handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384 sha512) (default sha256)]\\n\");\n    printf(\"\\t[-salg\\tsignature algorithm (rsa, ecc, hmac) (default rsa)]\\n\");\n    printf(\"\\t[-qd\\tqualifying data file name]\\n\");\n    printf(\"\\t[-os\\tsignature file name (default do not save)]\\n\");\n    printf(\"\\t[-oa\\tattestation output file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/certifycreation.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    CertifyCreation\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2017 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    CertifyCreation_In \t\tin;\n    CertifyCreation_Out \tout;\n    TPMI_DH_OBJECT\t\tobjectHandle = 0;\n    TPMI_DH_OBJECT\t\tsignHandle = 0;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    const char\t\t\t*keyPassword = NULL; \n    const char\t\t\t*signatureFilename = NULL;\n    const char\t\t\t*attestInfoFilename = NULL;\n    const char\t\t\t*qualifyingDataFilename = NULL;\n    const char\t\t\t*ticketFilename = NULL;\n    const char\t\t\t*creationHashFilename = NULL;\n    unsigned char \t\t*buffer = NULL;\n    size_t \t\t\tlength;\n    int\t\t\t\tuseRsa = 1;\n    TPMS_ATTEST \t\ttpmsAttest;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ho\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&objectHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ho\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&signHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-salg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsa\") == 0) {\n\t\t    useRsa = 1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"ecc\") == 0) {\n\t\t    useRsa = 0;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -salg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-salg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oa\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tattestInfoFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oa option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-qd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tqualifyingDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-qd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ch\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcreationHashFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ch option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (objectHandle == 0) {\n\tprintf(\"Missing object handle parameter -ho\\n\");\n\tprintUsage();\n    }\n    if (signHandle == 0) {\n\tprintf(\"Missing sign handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (ticketFilename == NULL) {\n\tprintf(\"Missing ticket parameter -tk\\n\");\n\tprintUsage();\n    }\n    if (creationHashFilename == NULL) {\n\tprintf(\"Missing creation hash file parameter -ch\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform certifying */\n\tin.objectHandle = objectHandle;\n\tin.signHandle = signHandle;\n\tif (useRsa) {\n\t    /* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\t    in.inScheme.scheme = TPM_ALG_RSASSA;\t\n\t    /* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\t    /* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t    /* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t    in.inScheme.details.rsassa.hashAlg = halg;\n\t}\n\telse {\t/* ecc */\n\t    in.inScheme.scheme = TPM_ALG_ECDSA;\t\n\t    in.inScheme.details.ecdsa.hashAlg = halg;\n\t}\n    }\n    /* qualifyingData supplied by the caller */\n    if (rc == 0) {\n\tif (qualifyingDataFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.qualifyingData.b,\n\t\t\t\t sizeof(in.qualifyingData.t.buffer),\n\t\t\t\t qualifyingDataFilename);\n\t}\n\telse {\n\t    in.qualifyingData.t.size = 0;\n\t}\n    }\n    /* creationTicket */\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.creationTicket,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPMT_TK_CREATION_Unmarshalu,\n\t\t\t\t    ticketFilename);\n    }\n    /* creationHash */\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,\t/* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     creationHashFilename);\n    }\n    if (rc == 0) {\n\tif (length > sizeof(TPMU_HA)) {\n\t    printf(\"Size of creationHash %lu greater than hash size %lu\\n\",\n\t\t   (unsigned long)length, (unsigned long)sizeof(TPMU_HA));\n\t    rc = 1;\t\n\t}\n    }\n    if (rc == 0) {\n\tin.creationHash.t.size = (uint16_t)length;\n\tmemcpy(in.creationHash.t.buffer, buffer, length);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_CertifyCreation,\n\t\t\t sessionHandle0, keyPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tuint8_t *tmpBuffer = out.certifyInfo.t.attestationData;\n\tuint32_t tmpSize = out.certifyInfo.t.size;\n\trc = TSS_TPMS_ATTEST_Unmarshalu(&tpmsAttest, &tmpBuffer, &tmpSize);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMS_ATTEST_Print(&tpmsAttest, 0);\n    }\n    if (rc == 0) {\n\tint match;\n\tmatch = TSS_TPM2B_Compare(&in.qualifyingData.b, &tpmsAttest.extraData.b);\n\tif (!match) {\n\t    printf(\"certifycreation: failed, extraData != qualifyingData\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if (rc == 0) {\n\tint match;\n\tmatch = TSS_TPM2B_Compare(&in.creationHash.b, &tpmsAttest.attested.creation.creationHash.b);\n\tif (!match) {\n\t    printf(\"certifycreation: failed, in creationHash != out creationHash\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if ((rc == 0) && (signatureFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.signature,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_SIGNATURE_Marshalu,\n\t\t\t\t     signatureFilename);\n    }\n    if ((rc == 0) && (attestInfoFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.certifyInfo.t.attestationData,\n\t\t\t\t      out.certifyInfo.t.size,\n\t\t\t\t      attestInfoFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMT_SIGNATURE_Print(&out.signature, 0);\n\tif (tssUtilsVerbose) printf(\"certifycreation: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"certifycreation: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"certifycreation\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_CertifyCreation\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ho\\tobject handle\\n\");\n    printf(\"\\t-hk\\tcertifying key handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384) (default sha256)]\\n\");\n    printf(\"\\t[-salg\\tsignature algorithm (rsa, ecc) (default rsa)]\\n\");\n    printf(\"\\t[-qd\\tqualifying data file name]\\n\");\n    printf(\"\\t-tk\\tinput ticket file name\\n\");\n    printf(\"\\t-ch\\tinput creation hash file name\\n\");\n    printf(\"\\t[-os\\tsignature file name] (default do not save)\\n\");\n    printf(\"\\t[-oa\\tattestation output file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/certifyx509.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    CertifyX509\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2019 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* CertifyX509 exercises the TPM2_CertifyX509 command.  It:\n\n   - Creates a partialCertificate parameter\n   - Runs the TPM2_CertifyX509 command\n   - Reconstructs the X509 certificate from the addedToCertificate and signature outputs\n*/\n\n/* mbedtls does not support this utility */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <openssl/asn1.h>\n#include <openssl/asn1t.h>\n#include <openssl/x509.h>\n#include <openssl/x509v3.h>\n\n#include \"cryptoutils.h\"\n\n#ifndef TPM_TSS_MBEDTLS\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tssfile.h>\n\n/* NOTE: This is currently openssl only. */\n#include <ekutils.h>\n\n/* definition of the partial certificate, from Part 3 TPM2_CertifyX509.\n   1)\tSignature Algorithm Identifier (optional)\n   2)\tIssuer (mandatory)\n   3)\tValidity (mandatory)\n   4)\tSubject Name (mandatory)\n   5)\tExtensions (mandatory)\n*/\n\ntypedef struct {\n    ASN1_TIME *notBefore;\n    ASN1_TIME *notAfter;\n} TPM_PARTIAL_CERT_VALIDITY;\n\n/* partial certificate TPM input parameter entire structure */\ntypedef struct {\n    X509_ALGOR *algorithm;\t/* signature algorithm */\n    X509_NAME *issuer;\n    TPM_PARTIAL_CERT_VALIDITY *validity;\n    X509_NAME *subject;\n    STACK_OF(X509_EXTENSION) *extensions;\n} TPM_PARTIAL_CERT;\n\nASN1_SEQUENCE(TPM_PARTIAL_CERT_VALIDITY) = {\n    ASN1_SIMPLE(TPM_PARTIAL_CERT_VALIDITY, notBefore, ASN1_TIME),\n    ASN1_SIMPLE(TPM_PARTIAL_CERT_VALIDITY, notAfter, ASN1_TIME),\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n} ASN1_SEQUENCE_END(TPM_PARTIAL_CERT_VALIDITY)\n#else\n} static_ASN1_SEQUENCE_END(TPM_PARTIAL_CERT_VALIDITY)\n#endif\n\n/* the signature algorithm is optional while the extension list is mandatory */\nASN1_SEQUENCE(TPM_PARTIAL_CERT) = {\n    ASN1_OPT(TPM_PARTIAL_CERT, algorithm, X509_ALGOR),\n    ASN1_SIMPLE(TPM_PARTIAL_CERT, issuer, X509_NAME),\n    ASN1_SIMPLE(TPM_PARTIAL_CERT, validity, TPM_PARTIAL_CERT_VALIDITY),\n    ASN1_SIMPLE(TPM_PARTIAL_CERT, subject, X509_NAME),\n    ASN1_EXP_SEQUENCE_OF(TPM_PARTIAL_CERT, extensions, X509_EXTENSION, 3),\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n} ASN1_SEQUENCE_END(TPM_PARTIAL_CERT)\n#else\n} static_ASN1_SEQUENCE_END(TPM_PARTIAL_CERT)\n#endif\n\nDECLARE_ASN1_FUNCTIONS(TPM_PARTIAL_CERT)\nIMPLEMENT_ASN1_FUNCTIONS(TPM_PARTIAL_CERT)\n\n/* add to signature TPM output parameter */\n\ntypedef struct  {\n    ASN1_INTEGER *version;\n    ASN1_INTEGER *serialNumber;\n    X509_ALGOR   *signatureAlgorithm;\n    X509_PUBKEY  *key;\n} TPM_ADDTOCERT;\n\nASN1_SEQUENCE(TPM_ADDTOCERT) = {\n    ASN1_EXP_OPT(TPM_ADDTOCERT, version, ASN1_INTEGER, 0),\n    ASN1_SIMPLE(TPM_ADDTOCERT, serialNumber, ASN1_INTEGER),\n    ASN1_SIMPLE(TPM_ADDTOCERT, signatureAlgorithm, X509_ALGOR),\n    ASN1_SIMPLE(TPM_ADDTOCERT, key, X509_PUBKEY),\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n} ASN1_SEQUENCE_END(TPM_ADDTOCERT)\n#else\n} static_ASN1_SEQUENCE_END(TPM_ADDTOCERT)\n#endif\n\nDECLARE_ASN1_FUNCTIONS(TPM_ADDTOCERT)\nIMPLEMENT_ASN1_FUNCTIONS(TPM_ADDTOCERT)\n\nstatic void printUsage(void);\n\nTPM_RC addPartialCertExtension(TPM_PARTIAL_CERT *partialCertificate,\n\t\t\t       X509 \t\t*x509Certificate,\n\t\t\t       int nid, const char *value);\nTPM_RC addPartialCertExtensionTpmaOid(TPM_PARTIAL_CERT  *partialCertificate,\n\t\t\t\t      X509 \t\t*x509Certificate,\n\t\t\t\t      uint32_t \t\ttpmaObject);\nTPM_RC createPartialCertificate(TPM_PARTIAL_CERT *certificate,\n\t\t\t\tX509 *x509Certificate,\n\t\t\t\tuint8_t *partialCertificateDer,\n\t\t\t\tuint16_t *partialCertificateDerLength,\n\t\t\t\tsize_t partialCertificateDerSize,\n\t\t\t\tconst char *keyUsage,\n\t\t\t\tuint32_t tpmaObject,\n\t\t\t\tint addTpmaObject,\n\t\t\t\tint subeqiss);\nTPM_RC reformCertificate(X509 \t\t\t*x509Certificate,\n\t\t\t TPMI_ALG_HASH\t\thalg,\n\t\t\t TPMI_ALG_SIG_SCHEME   \tscheme,\n\t\t\t const TPM_ADDTOCERT\t*addToCert,\n\t\t\t TPMT_SIGNATURE \t*tSignature);\nTPM_RC addSignatureRsa(X509 \t\t*x509Certificate,\n\t\t       TPMI_ALG_HASH\thalg,\n\t\t       TPMT_SIGNATURE \t*tSignature);\n#ifndef TPM_TSS_NOECC\nTPM_RC addSignatureEcc(X509 \t\t*x509Certificate,\n\t\t       TPMI_ALG_HASH\thalg,\n\t\t       TPMT_SIGNATURE \t*signature);\n#endif\t/* TPM_TSS_NOECC */\n\nint verbose = FALSE;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    CertifyX509_In \t\tin;\n    CertifyX509_Out \t\tout;\n    TPMI_DH_OBJECT\t\tobjectHandle = 0;\n    TPMI_DH_OBJECT\t\tsignHandle = 0;\n    unsigned int\t\talgCount = 0;\n    TPMI_ALG_SIG_SCHEME    \tscheme = TPM_ALG_ERROR;\n    TPMI_RSA_KEY_BITS \t\tkeyBits = 0;\n    TPMI_ECC_CURVE\t\tcurveID = 0;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    unsigned int \t\tbit = 0;\n    int \t\t\ttestBit = FALSE;\n    const char\t\t\t*keyPassword = NULL;\n    const char\t\t\t*objectPassword = NULL;\n    const char\t\t\t*outPartialCertificateFilename = NULL;\n    const char\t\t\t*outCertificateFilename = NULL;\n    const char\t\t\t*addedToCertificateFilename = NULL;\n    const char\t\t\t*tbsDigestFilename = NULL;\n    const char\t\t\t*signatureFilename = NULL;\n\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    int\t\t\t\tsubeqiss = FALSE;\t/* TRUE: subject = issuer */\n    const char \t\t\t*keyUsage = \"critical,digitalSignature,keyCertSign,cRLSign\";\n    uint32_t\t\t\ttpmaObject = 0;\n    int\t\t\t\taddTpmaObject = FALSE;\n    X509 \t\t\t*x509Certificate = NULL;\n    unsigned char \t\t*x509Der = NULL;\n    uint32_t \t\t\tx509DerLength = 0;\n    TPM_PARTIAL_CERT \t\t*partialCertificate = NULL;\n    TPM_ADDTOCERT \t\t*addToCert = NULL;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n\n    curveID = curveID;\t\t/* no longer used, get from parent */\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ho\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&objectHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ho\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdo\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tobjectPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdo option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&signHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    scheme = TPM_ALG_RSASSA;\n\t    algCount++;\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%hu\", &keyBits);\n\t    }\n\t    else {\n\t\tprintf(\"Missing keysize parameter for -rsa\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n#ifndef TPM_TSS_NOECC\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    scheme = TPM_ALG_ECDSA;\n\t    algCount++;\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"nistp256\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp384\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad curve parameter %s for -ecc\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-ecc option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n#endif\t/* TPM_TSS_NOECC */\n\telse if (strcmp(argv[i],\"-ku\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyUsage = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ku option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-iob\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\taddTpmaObject = TRUE;\n\t\tsscanf(argv[i], \"%x\", &tpmaObject);\n\t    }\n\t    else {\n\t\tprintf(\"-iob option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sub\") == 0) {\n\t    subeqiss = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-opc\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutPartialCertificateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opc option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ocert\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutCertificateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ocert option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oa\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\taddedToCertificateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oa option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-otbs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\ttbsDigestFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-otbs option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    verbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (objectHandle == 0) {\n\tprintf(\"Missing object handle parameter -ho\\n\");\n\tprintUsage();\n    }\n    if (signHandle == 0) {\n\tprintf(\"Missing sign handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (algCount == 0) {\n\tprintf(\"One of -rsa, -ecc must be specified\\n\");\n\tprintUsage();\n    }\n    if (algCount > 1) {\n\tprintf(\"Only one of -rsa, -ecc can be specified\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* Handle of the object to be certified */\n\tin.objectHandle = objectHandle;\n\t/* Handle of key that will perform certifying */\n\tin.signHandle = signHandle;\n\tin.inScheme.scheme = scheme;\n\tif (scheme == TPM_ALG_RSASSA) {\n\t    /* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\t    /* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\t    /* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t    /* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t    in.inScheme.details.rsassa.hashAlg = halg;\n\t}\n\telse {\t/* ecc */\n\t    in.inScheme.details.ecdsa.hashAlg = halg;\n\t}\n\tin.reserved.t.size = 0;\n    }\n    /* initialize a new, empty X509 structure.  It will be used to reform the certificate from\n       the response parameters. */\n    if (rc == 0) {\n\tx509Certificate = X509_new();\t\t\t\t/* freed @1 */\n\tif (x509Certificate == NULL) {\n\t    printf(\"main: Error in X509_new\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* initialize a new, empty TPM_PARTIAL_CERT structure.  It will be used to form the\n       partialCertificate command parameter */\n    if (rc == 0) {\n\tpartialCertificate = TPM_PARTIAL_CERT_new();\t\t/* freed @2 */\n\tif (partialCertificate == NULL) {\n\t    printf(\"main: Error in TPM_PARTIAL_CERT_new\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* form partial certificate and populate the X509 certificate with the values */\n    if (rc == 0) {\n\trc = createPartialCertificate(partialCertificate,\n\t\t\t\t      x509Certificate,\n\t\t\t\t      in.partialCertificate.t.buffer,\n\t\t\t\t      &in.partialCertificate.b.size,\n\t\t\t\t      sizeof(in.partialCertificate.t.buffer),\n\t\t\t\t      keyUsage,\n\t\t\t\t      tpmaObject,\n\t\t\t\t      addTpmaObject,\n\t\t\t\t      subeqiss);\n    }\n    /* for debug testing */\n    if ((rc == 0) && (testBit)) {\n\tunsigned int bitInByte = bit % 8;\n\tunsigned int byteInDer = bit / 8;\n\tif (byteInDer <= in.partialCertificate.b.size) {\n\t    if (verbose) {\n\t\tprintf(\"main: Testing byte %u bit %u\\n\", byteInDer, bitInByte);\n\t\tprintf(\"main: Byte was %02x\\n\", in.partialCertificate.t.buffer[byteInDer]);\n\t    }\n\t    in.partialCertificate.t.buffer[byteInDer] ^= (1 << bitInByte);\n\t    if (verbose) printf(\"main: Byte is %02x\\n\", in.partialCertificate.t.buffer[byteInDer]);\n\t}\n\telse {\n\t    printf(\"Bad -bit parameter, byte %u, DER length %u\\n\",\n\t\t   byteInDer, in.partialCertificate.b.size);\n\t    rc = TSS_RC_BAD_PROPERTY;\n\t}\n    }\n    /* for debug, or stop here for sample of how to create the partialCertificate parameter */\n    if (rc == 0) {\n\tif (outPartialCertificateFilename != NULL) {\n\t    rc = TSS_File_WriteBinaryFile(in.partialCertificate.b.buffer,\n\t\t\t\t\t  in.partialCertificate.b.size,\n\t\t\t\t\t  outPartialCertificateFilename);\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_CertifyX509,\n\t\t\t sessionHandle0, objectPassword, sessionAttributes0,\n\t\t\t sessionHandle1, keyPassword, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc != 0) {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"certifyx509: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    /*\n      write response parameters for debug\n    */\n    /* added to certificate */\n    if ((rc == 0) && (addedToCertificateFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.addedToCertificate.t.buffer,\n\t\t\t\t      out.addedToCertificate.t.size,\n\t\t\t\t      addedToCertificateFilename);\n    }\n    /*  to be signed digest */\n    if ((rc == 0) && (tbsDigestFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.tbsDigest.t.buffer,\n\t\t\t\t      out.tbsDigest.t.size,\n\t\t\t\t      tbsDigestFilename);\n    }\n    /* signature */\n    if ((rc == 0) && (signatureFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.signature,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_SIGNATURE_Marshalu,\n\t\t\t\t     signatureFilename);\n    }\n    if (rc == 0) {\n\tif (verbose) TSS_TPMT_SIGNATURE_Print(&out.signature, 0);\n    }\n    /* convert the TPM output addedToCertificate DER to the OpenSSL structure */\n    if (rc == 0) {\n\tconst unsigned char *tmpptr = out.addedToCertificate.t.buffer;\n\taddToCert = d2i_TPM_ADDTOCERT(NULL,\t\t/* freed @3 */\n\t\t\t\t      &tmpptr, out.addedToCertificate.t.size);\n\tif (addToCert == NULL) {\n\t    printf(\"d2i_TPM_ADDTOCERT failed %p\\n\", addToCert);\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    /* reform the signed certificate from the original X509 input plus the response parameters */\n    if (rc == 0) {\n\trc = reformCertificate(x509Certificate,\n\t\t\t       halg, scheme,\n\t\t\t       addToCert,\n\t\t\t       &out.signature);\n    }\n    if (rc == 0) {\n\tif (verbose) X509_print_fp(stdout, x509Certificate);\t/* for debug */\n\trc = convertX509ToDer(&x509DerLength,\n\t\t\t      &x509Der,\t\t\t\t/* freed @4 */\n\t\t\t      x509Certificate);\n    }\n    if ((rc == 0) && (outCertificateFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(x509Der, x509DerLength,\n\t\t\t\t      outCertificateFilename);\n    }\n    if (x509Certificate != NULL) {\n\tX509_free(x509Certificate);\t\t\t/* @1 */\n    }\n    if (partialCertificate != NULL) {\n\tTPM_PARTIAL_CERT_free(partialCertificate);\t/* @2 */\n    }\n    if (addToCert != NULL) {\n\tTPM_ADDTOCERT_free(addToCert);\t\t\t/* @3 */\n    }\n    free(x509Der);\t\t\t\t\t/* @4 */\n    return rc;\n}\n\n/* example of a 20 year validity */\n#define CERT_DURATION (60 * 60 * 24 * ((365 * 20) + 5))\t\t/* +5 for leap years */\n\n/* in this test, the issuer and subject are the same, making a self signed certificate.  This is\n   simply so that openssl can be used to verify the certificate signature.\n */\n\nchar *issuerEntries[] = {\n    \"US\"\t\t\t,\n    \"NY\"\t\t\t,\n    \"Yorktown\"\t\t\t,\n    \"IBM\"\t\t\t,\n    NULL\t\t\t,\n    \"CA\"\t\t\t,\n    NULL\n};\n\nchar *subjectEntries[] = {\n    \"US\"\t\t\t,\n    \"NY\"\t\t\t,\n    \"Yorktown\"\t\t\t,\n    \"IBM\"\t\t\t,\n    NULL\t\t\t,\n    \"Subject\"\t\t\t,\n    NULL\n};\n\n/* createPartialCertificate() forms the partialCertificate DER.  It starts with an empty X509 and\n   TPM_PARTIAL_CERT structures.  It adds the needed parameters to both structures.  It then\n   serializes the TPM_PARTIAL_CERT structure to partialCertificateDer;\n\n   subeqiss FALSE: subject name is independent of issuer name\n   subeqiss TRUE:  subject name is the same as the issuer name\n*/\n\nTPM_RC createPartialCertificate(TPM_PARTIAL_CERT *partialCertificate,\t/* input / output */\n\t\t\t\tX509 *x509Certificate,\t\t\t/* input / output */\n\t\t\t\tuint8_t *partialCertificateDer,\t\t/* output */\n\t\t\t\tuint16_t *partialCertificateDerLength,\n\t\t\t\tsize_t partialCertificateDerSize,\t/* input, size of\n\t\t\t\t\t\t\t\t\t   partialCertificateDer */\n\t\t\t\tconst char *keyUsage,\n\t\t\t\tuint32_t tpmaObject,\n\t\t\t\tint addTpmaObject,\n\t\t\t\tint subeqiss)\t\t\t\t/* subject variation */\n{\n    TPM_RC \trc = 0;\n    int\t\tirc;\n    ASN1_TIME\t*arc;\t\t\t/* return code */\n\n    size_t\tissuerEntriesSize = sizeof(issuerEntries)/sizeof(char *);\n    size_t\tsubjectEntriesSize = sizeof(subjectEntries)/sizeof(char *);\n    uint8_t \t*tmpPartialDer = NULL;\t/* for the i2d */\n\n    /* add issuer */\n    if (rc == 0) {\n\tif (verbose) printf(\"createPartialCertificate: Adding issuer, size %lu\\n\",\n\t\t\t    (unsigned long)issuerEntriesSize);\n\t/* _new allocates the member.  free it because createX509Name() allocates a new structure */\n\tX509_NAME_free(partialCertificate->issuer);\n\tpartialCertificate->issuer = NULL;\n\trc = createX509Name(&partialCertificate->issuer,\t/* freed @1 */\n\t\t\t    issuerEntriesSize,\n\t\t\t    issuerEntries);\n    }\n    if (rc == 0) {\n\tirc = X509_set_issuer_name(x509Certificate, partialCertificate->issuer);\n\tif (irc != 1) {\n\t    printf(\"createPartialCertificate: Error setting issuer\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /*\n      validity before\n    */\n    if (rc == 0) {\n\t/* set to today */\n\tarc = X509_gmtime_adj(partialCertificate->validity->notBefore ,0L);\n\tif (arc == NULL) {\n\t    printf(\"createPartialCertificate: Error setting notBefore time\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\tirc = X509_set1_notBefore(x509Certificate, partialCertificate->validity->notBefore);\n\tif (irc == 0) {\n\t    printf(\"createPartialCertificate: Error setting notBefore time\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /*\n      validity after\n    */\n    if (rc == 0) {\n\t/* set to duration */\n\tarc = X509_gmtime_adj(partialCertificate->validity->notAfter, CERT_DURATION);\n\tif (arc == NULL) {\n\t    printf(\"createPartialCertificate: Error setting notAfter time\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\tirc = X509_set1_notAfter(x509Certificate,partialCertificate->validity->notAfter);\n\tif (irc == 0) {\n\t    printf(\"createPartialCertificate: Error setting notAfter time\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* add subject */\n    if (rc == 0) {\n\t/* normal case */\n\tif (!subeqiss) {\n\t    if (verbose) printf(\"createPartialCertificate: Adding subject, size %lu\\n\",\n\t\t\t\t(unsigned long)subjectEntriesSize);\n\t    X509_NAME_free(partialCertificate->subject);\n\t    partialCertificate->subject = NULL;\n\t    rc = createX509Name(&partialCertificate->subject,\t/* freed @2 */\n\t\t\t\tsubjectEntriesSize,\n\t\t\t\tsubjectEntries);\n\t}\n\t/* special case, self signed CA, make the subject the same as the issuer */\n\telse {\n\t    if (verbose) printf(\"createPartialCertificate: Adding subject (issuer), size %lu\\n\",\n\t\t\t\t(unsigned long)issuerEntriesSize);\n\t    X509_NAME_free(partialCertificate->subject);\n\t    partialCertificate->subject = NULL;\n\t    rc = createX509Name(&partialCertificate->subject,\t/* freed @2 */\n\t\t\t\tissuerEntriesSize,\n\t\t\t\tissuerEntries);\n\t}\n    }\n    if (rc == 0) {\n\tirc = X509_set_subject_name(x509Certificate, partialCertificate->subject);\n\tif (irc != 1) {\n\t    printf(\"createPartialCertificate: Error setting subject\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* add some certificate extensions, requires corresponding bits in subject key */\n    if (rc == 0) {\n\tif (verbose) printf(\"createPartialCertificate: Adding extensions\\n\");\n\trc = addPartialCertExtension(partialCertificate,\n\t\t\t\t     x509Certificate,\n\t\t\t\t     NID_key_usage, keyUsage);\n    }\n    /* optional TPMA_OBJECT extension */\n    /* From TCG OID registry tcg-tpmaObject 2.23.133.10.1.1.1  */\n    if (rc == 0) {\n\tif (addTpmaObject) {\n\t    rc = addPartialCertExtensionTpmaOid(partialCertificate,\n\t\t\t\t\t\tx509Certificate,\n\t\t\t\t\t\ttpmaObject);\n\t}\n    }\n    /* serialize the openSSL partial certificate structure to a DER stream */\n    if (rc == 0) {\n\t*partialCertificateDerLength =\n\t    (uint16_t)i2d_TPM_PARTIAL_CERT(partialCertificate,\n\t\t\t\t\t   &tmpPartialDer);\t/* freed @3 */\n    }\n    /* check the i2d size, and copy the DER to the TPM input parameter */\n    if (rc == 0) {\n\tif (*partialCertificateDerLength <= partialCertificateDerSize) {\n\t    memcpy(partialCertificateDer, tmpPartialDer, *partialCertificateDerLength);\n\t}\n\telse {\n\t    printf(\"createPartialCertificate: Partial cert size %u too large\\n\",\n\t\t   *partialCertificateDerLength);\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n#if 0\n    /* for debug.  The X509 structure is incomplete and so will trace with errors */\n    if (rc == 0) {\n\tif (verbose) printf(\"createPartialCertificate: Trace preliminary certificate\\n\");\n\tif (verbose) X509_print_fp(stdout, x509Certificate);\n    }\n#endif\n    OPENSSL_free(tmpPartialDer);\t/* @3 */\n    return rc;\n}\n\n/* addPartialCertExtension() adds the extension type 'nid' to the partial certificate\n\n */\n\nTPM_RC addPartialCertExtension(TPM_PARTIAL_CERT *partialCertificate,\n\t\t\t       X509 \t\t*x509Certificate,\n\t\t\t       int nid, const char *value)\n{\n    TPM_RC \t\trc = 0;\n    X509_EXTENSION \t*extension = NULL;\t/* freed @1 */\n\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n\t/* the cast is required for the older openssl 1.0 API */\n\textension = X509V3_EXT_conf_nid(NULL, NULL,\t/* freed @1 */\n\t\t\t\t\tnid, (char *)value);\n#else\n\textension = X509V3_EXT_conf_nid(NULL, NULL,\t/* freed @1 */\n\t\t\t\t\tnid, value);\n#endif\n\tif (extension == NULL) {\n\t    printf(\"addPartialCertExtension: Error creating nid %i extension %s\\n\",\n\t\t   nid, value);\n\t    rc = -1;\n\t}\n    }\n    if (rc == 0) {\n\tSTACK_OF(X509_EXTENSION) *src =\n\t    X509v3_add_ext(&partialCertificate->extensions,\n\t\t\t   extension,\t/* the extension to add */\n\t\t\t   -1);\t\t/* location - append */\n\tif (src == NULL) {\n\t    printf(\"addPartialCertExtension: Error adding nid %i extension %s\\n\",\n\t\t   nid, value);\n\t}\n    }\n    if (rc == 0) {\n\tint irc = X509_add_ext(x509Certificate,\n\t\t\t       extension,\t/* the extension to add */\n\t\t\t       -1);\t\t/* location - append */\n\tif (irc != 1) {\n\t    printf(\"addCertExtension: Error adding oid to extension\\n\");\n\t}\n    }\n    if (extension != NULL) {\n\tX509_EXTENSION_free(extension);\t\t/* @1 */\n    }\n    return rc;\n}\n\n/* addPartialCertExtensionTpmaOid() adds the tpmaObject extension oid to the X509 certificate\n\n */\n\nTPM_RC addPartialCertExtensionTpmaOid(TPM_PARTIAL_CERT  *partialCertificate,\n\t\t\t\t      X509 \t\t*x509Certificate,\n\t\t\t\t      uint32_t \t\ttpmaObject)\n{\n    TPM_RC \t\trc = 0;\n    X509_EXTENSION \t*extension = NULL;\t/* freed @1 */\n\n\n    uint8_t tpmaObjectOid[] = {0x06, 0x07, 0x67, 0x81, 0x05, 0x0A, 0x01, 0x01, 0x01};\n    const uint8_t *tmpOidPtr;\t/* const for d2i_ASN1_OBJECT */\n\n    /* BIT STRING 0x03 length 5 no padding 0, 4 dummy bytes of TPMA_OBJECT */\n    uint8_t tpmaObjectData[] = {0x03, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00};\n    ASN1_OBJECT *object = NULL;\n    ASN1_OCTET_STRING *osData = NULL;\n    uint8_t *tmpOdPtr;\n    uint32_t tpmaObjectNbo = htonl(tpmaObject);\n\n\n    /* create the object */\n    if (rc == 0) {\n\ttmpOidPtr = tpmaObjectOid;\n\tobject = d2i_ASN1_OBJECT(NULL, &tmpOidPtr, sizeof(tpmaObjectOid));\t/* freed @2 */\n\tif (object ==  NULL) {\n\t    printf(\"addPartialCertExtensionTpmaOid: d2i_ASN1_OBJECT failed\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\tosData = ASN1_OCTET_STRING_new();\t/* freed @3 */\n\tif (osData == NULL) {\n\t    printf(\"addPartialCertExtensionTpmaOid: ASN1_OCTET_STRING_new failed\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* copy the TPMA_OBJECT bytes to the BIT STRING place holder, set the result in the\n       ASN1_OCTET_STRING */\n    if (rc == 0) {\n\ttmpOdPtr = tpmaObjectData;\n\tmemcpy(tmpOdPtr + 3, &tpmaObjectNbo, sizeof(uint32_t));\n\tASN1_OCTET_STRING_set(osData, tmpOdPtr, sizeof (tpmaObjectData));\n    }\n    /* create the extension with the TPMA_OBJECT in the ASN1_OBJECT */\n    if (rc == 0) {\n\textension = X509_EXTENSION_create_by_OBJ(NULL,\t\t/* freed @1 */\n\t\t\t\t\t\t object,\n\t\t\t\t\t\t 0,\t\t/* int crit */\n\t\t\t\t\t\t osData);\n\tif (extension == NULL) {\n\t    printf(\"addPartialCertExtensionTpmaOid: X509_EXTENSION_create_by_OBJ failed\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* append the extensions to the partial certificate stack */\n    if (rc == 0) {\n\tSTACK_OF(X509_EXTENSION) *src  = X509v3_add_ext(&partialCertificate->extensions,\n\t\t\t\t\t\t\textension,\t/* the extension to add */\n\t\t\t\t\t\t\t-1);\t\t/* location - append */\n\tif (src == NULL) {\n\t    printf(\"addPartialCertExtensionTpmaOid: Error adding oid to extension\\n\");\n\t}\n    }\n    /* append the extensions to the X509 certificate */\n    if (rc == 0) {\n\tint irc = X509_add_ext(x509Certificate,\t\t/* the certificate */\n\t\t\t       extension,\t\t/* the extension to add */\n\t\t\t       -1);\t\t\t/* location - append */\n\tif (irc != 1) {\n\t    printf(\"addPartialCertExtensionTpmaOid: Error adding oid to extension\\n\");\n\t}\n    }\n    if (extension != NULL) {\n\tX509_EXTENSION_free(extension);\t/* @1 */\n    }\n    if (object != NULL) {\n\tASN1_OBJECT_free(object);\t/* @2 */\n    }\n    if (osData != NULL) {\n\tASN1_OCTET_STRING_free(osData);\t/* @3 */\n    }\n    return rc;\n}\n\n/* reformCertificate() starts with the X509 certificate filled with the input partialCertificate\n   parameter.  It adds the output addedToCertificate and signature values to reform the X509\n   certificate that the TPM signed.  */\n\nTPM_RC reformCertificate(X509 \t\t\t*x509Certificate,\n\t\t\t TPMI_ALG_HASH\t\thalg,\n\t\t\t TPMI_ALG_SIG_SCHEME   \tscheme,\n\t\t\t const TPM_ADDTOCERT\t*addToCert,\n\t\t\t TPMT_SIGNATURE \t*tSignature)\n{\n    TPM_RC \t\trc = 0;\n    int\t\t\tirc;\n    long\t\tversionl;\n    EVP_PKEY \t\t*evpPubkey = NULL;\t/* EVP format public key to be certified */\n\n    /* version */\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n    /* Older openssl does not has the uint64 function.  This function is deprecated but OK since\n       X509 certificates never have a negative version. */\n    if (rc == 0) {\n\tversionl= ASN1_INTEGER_get(addToCert->version);\n\tif (versionl < 0) {\n\t    printf(\"reformCertificate: Error in ASN1_INTEGER_get version\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n#else\n    if (rc == 0) {\n\tuint64_t\t\tversion64;\n\tirc = ASN1_INTEGER_get_uint64(&version64, addToCert->version);\n\tif (irc != 1) {\n\t    printf(\"reformCertificate: Error in ASN1_INTEGER_get_uint64 version\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n\telse if (version64 > LONG_MAX) {\n\t    printf(\"reformCertificate: Version out of range\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n\telse {\n\t    versionl = (long)version64;\n\t}\n    }\n#endif\n    if (rc == 0) {\n\tirc = X509_set_version(x509Certificate, versionl);\n\tif (irc != 1) {\n\t    printf(\"reformCertificate: Error in X509_set_version\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* serial number */\n    if (rc == 0) {\n\tirc = X509_set_serialNumber(x509Certificate, addToCert->serialNumber);\n\tif (irc != 1) {\n\t    printf(\"reformCertificate: Error in X509_set_serialNumber\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* public key including algorithm */\n    if (rc == 0) {\n\tevpPubkey = X509_PUBKEY_get(addToCert->key); \t/* freed @1 */\n\tif (evpPubkey == NULL) {\n\t    printf(\"reformCertificate: X509_PUBKEY_get failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tirc = X509_set_pubkey(x509Certificate, evpPubkey);\n\tif (irc != 1) {\n\t    printf(\"reformCertificate: Error X509_set_pubkey failed\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* add certificate signature */\n    if (rc == 0) {\n\tif (scheme == TPM_ALG_RSASSA) {\n\t    if (rc == 0) {\n\t\trc = addSignatureRsa(x509Certificate, halg, tSignature);\n\t    }\n\t}\n\telse {\t/* scheme == TPM_ALG_ECDSA */\n\t    if (rc == 0) {\n\t\trc = addSignatureEcc(x509Certificate, halg, tSignature);\n\t    }\n\t}\n    }\n    EVP_PKEY_free(evpPubkey);\t/* @1 **/\n    return rc;\n}\n\n/* addSignatureRsa() copies the TPMT_SIGNATURE output of the TPM2_CertifyX509 command to the X509\n   certificate.\n */\n\nTPM_RC addSignatureRsa(X509 \t\t*x509Certificate,\n\t\t       TPMI_ALG_HASH\thalg,\n\t\t       TPMT_SIGNATURE \t*tSignature)\n{\n    TPM_RC \t\trc = 0;\n    int \t\tirc;\n    X509_ALGOR \t\t*signatureAlgorithm = NULL;\n    X509_ALGOR \t\t*certSignatureAlgorithm = NULL;\n    ASN1_BIT_STRING \t*asn1Signature = NULL;\n\n    /* FIXME check sign length */\n\n    if (rc == 0) {\n\tcertSignatureAlgorithm = (X509_ALGOR *)X509_get0_tbs_sigalg(x509Certificate);\n\tX509_get0_signature((OSSLCONST ASN1_BIT_STRING**)&asn1Signature,\n\t\t\t    (OSSLCONST X509_ALGOR **)&signatureAlgorithm,\n\t\t\t    x509Certificate);\n    }\n    /* set the algorithm in the top level structure */\n    /* set the algorithm in the to be signed structure */\n    if (rc == 0) {\n\tswitch (halg) {\n\t  case TPM_ALG_SHA256:\n\t    X509_ALGOR_set0(signatureAlgorithm,\n\t\t\t    OBJ_nid2obj(NID_sha256WithRSAEncryption), V_ASN1_NULL, NULL);\n\t    X509_ALGOR_set0(certSignatureAlgorithm,\n\t\t\t    OBJ_nid2obj(NID_sha256WithRSAEncryption), V_ASN1_NULL, NULL);\n\t    break;\n\t  case TPM_ALG_SHA384:\n\t    X509_ALGOR_set0(signatureAlgorithm,\n\t\t\t    OBJ_nid2obj(NID_sha384WithRSAEncryption), V_ASN1_NULL, NULL);\n\t    X509_ALGOR_set0(certSignatureAlgorithm,\n\t\t\t    OBJ_nid2obj(NID_sha384WithRSAEncryption), V_ASN1_NULL, NULL);\n\t    break;\n\t  default:\n\t    printf(\"addSignatureRsa: Unsupported hash algorithm %04x\\n\", halg);\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n    /* ASN1_BIT_STRING x509Certificate->signature contains a BIT STRING with the RSA signature */\n    if (rc == 0) {\n\tirc = ASN1_BIT_STRING_set(asn1Signature,\n\t\t\t\t  tSignature->signature.rsassa.sig.t.buffer,\n\t\t\t\t  tSignature->signature.rsassa.sig.t.size);\n\tasn1Signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);\n\tasn1Signature->flags |= ASN1_STRING_FLAG_BITS_LEFT;\n\tif (irc == 0) {\n\t    printf(\"addSignatureRsa: Error in ASN1_BIT_STRING_set for signature\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    return rc;\n}\n\n#ifndef TPM_TSS_NOECC\n\n/* addSignatureEcc() copies the TPMT_SIGNATURE output of the TPM2_CertifyX509 command to the X509\n   certificate.\n*/\n\nTPM_RC addSignatureEcc(X509 \t\t*x509Certificate,\n\t\t       TPMI_ALG_HASH\thalg,\n\t\t       TPMT_SIGNATURE \t*tSignature)\n{\n    TPM_RC \t\trc = 0;\n    int \t\tirc;\n    X509_ALGOR \t\t*signatureAlgorithm = NULL;\n    X509_ALGOR \t\t*certSignatureAlgorithm = NULL;\n    ASN1_BIT_STRING \t*asn1Signature = NULL;\n    BIGNUM \t\t*rSig = NULL;\n    BIGNUM \t\t*sSig = NULL;\n    ECDSA_SIG \t\t*ecdsaSig = NULL;\n    unsigned char \t*ecdsaSigBin = NULL;\n    int \t\tecdsaSigBinLength;\n\n    /* FIXME check sign length */\n\n    if (rc == 0) {\n\tcertSignatureAlgorithm = (X509_ALGOR *)X509_get0_tbs_sigalg(x509Certificate);\n\tX509_get0_signature((OSSLCONST ASN1_BIT_STRING**)&asn1Signature,\n\t\t\t    (OSSLCONST X509_ALGOR **)&signatureAlgorithm,\n\t\t\t    x509Certificate);\n    }\n    /* set the algorithm in the top level structure */\n    /* set the algorithm in the to be signed structure */\n    if (rc == 0) {\n\tswitch (halg) {\n\t  case TPM_ALG_SHA256:\n\t    X509_ALGOR_set0(signatureAlgorithm,\n\t\t\t    OBJ_nid2obj(NID_ecdsa_with_SHA256), V_ASN1_UNDEF, NULL);\n\t    X509_ALGOR_set0(certSignatureAlgorithm,\n\t\t\t    OBJ_nid2obj(NID_ecdsa_with_SHA256), V_ASN1_UNDEF, NULL);\n\t    break;\n\t  case TPM_ALG_SHA384:\n\t    X509_ALGOR_set0(signatureAlgorithm,\n\t\t\t    OBJ_nid2obj(NID_ecdsa_with_SHA384), V_ASN1_UNDEF, NULL);\n\t    X509_ALGOR_set0(certSignatureAlgorithm,\n\t\t\t    OBJ_nid2obj(NID_ecdsa_with_SHA384), V_ASN1_UNDEF, NULL);\n\t    break;\n\t  default:\n\t    printf(\"addSignatureEcc: Unsupported hash algorithm %04x\\n\", halg);\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n    /* ASN1_BIT_STRING x509Certificate->signature contains a sequence with two INTEGER, R and S */\n    /* construct DER and then ASN1_BIT_STRING_set into X509 */\n    if (rc == 0) {\n\trSig = BN_new();\n\tif (rSig == NULL) {\n\t    printf(\"addSignatureEcc: BN_new() failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tsSig = BN_new();\n\tif (sSig == NULL) {\n\t    printf(\"addSignatureEcc: BN_new() failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n        rSig = BN_bin2bn(tSignature->signature.ecdsa.signatureR.b.buffer,\n\t\t\t tSignature->signature.ecdsa.signatureR.b.size, rSig);\n        if (rSig == NULL) {\n            printf(\"addSignatureEcc: Error in BN_bin2bn\\n\");\n            rc = TSS_RC_BIGNUM;\n        }\n    }\n    if (rc == 0) {\n        sSig = BN_bin2bn(tSignature->signature.ecdsa.signatureS.b.buffer,\n\t\t\t tSignature->signature.ecdsa.signatureS.b.size, sSig);\n        if (sSig == NULL) {\n            printf(\"addSignatureEcc: Error in BN_bin2bn\\n\");\n            rc = TSS_RC_BIGNUM;\n        }\n    }\n    if (rc == 0) {\n\tecdsaSig = ECDSA_SIG_new();\t\t/* freed @1 */\n\tif (ecdsaSig == NULL) {\n\t    printf(\"addSignatureEcc: ECDSA_SIG_new() failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tirc = ECDSA_SIG_set0(ecdsaSig, rSig, sSig);\n\tif (irc != 1) {\n\t    printf(\"addSignatureEcc: Error in ECDSA_SIG_set0\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* serialize the signature to DER */\n    if (rc == 0) {\n\tecdsaSigBinLength = i2d_ECDSA_SIG(ecdsaSig, &ecdsaSigBin);\t/* freed @2 */\n\tif (ecdsaSigBinLength < 0) {\n\t    printf(\"addSignatureEcc: Error in signature serialization i2d_ECDSA_SIG()\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* add the DER signature to the certificate */\n    if (rc == 0) {\n\tirc = ASN1_BIT_STRING_set(asn1Signature,\n\t\t\t\t  ecdsaSigBin,\n\t\t\t\t  ecdsaSigBinLength);\n\tasn1Signature->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07);\n\tasn1Signature->flags|=ASN1_STRING_FLAG_BITS_LEFT;\n\tif (irc == 0) {\n\t    printf(\"addSignatureEcc: Error in ASN1_BIT_STRING_set for signature\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* freed by ECDSA_SIG_free */\n    if (ecdsaSig == NULL) {\n\tBN_free(rSig);\n\tBN_free(sSig);\n    }\n    ECDSA_SIG_free(ecdsaSig);\t\t/* @1 */\n    OPENSSL_free(ecdsaSigBin);\t\t/* @2 */\n    return rc;\n}\n#endif\t/* TPM_TSS_NOECC */\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"certifyx509\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Certifyx509\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ho\\tobject handle\\n\");\n    printf(\"\\t[-pwdo\\tpassword for object (default empty)]\\n\");\n    printf(\"\\t-hk\\tcertifying key handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha256, sha384) (default sha256)]\\n\");\n\n    printf(\"\\t-rsa keybits\\n\");\n    printf(\"\\t\\t2048\\n\");\n    printf(\"\\t\\t3072\\n\");\n    printf(\"\\t-ecc curve\\n\");\n    printf(\"\\t\\tnistp256\\n\");\n    printf(\"\\t\\tnistp384\\n\");\n\n    printf(\"\\t[-ku\\tX509 key usage - string - comma separated, no spaces]\\n\");\n    printf(\"\\t[-iob\\tTPMA_OBJECT - 4 byte hex]\\n\");\n    printf(\"\\t\\te.g. sign: critical,digitalSignature,keyCertSign,cRLSign (default)\\n\");\n    printf(\"\\t\\te.g. decrypt: critical,dataEncipherment,keyAgreement,encipherOnly,decipherOnly\\n\");\n    printf(\"\\t\\te.g. fixedTPM: critical,nonRepudiation\\n\");\n    printf(\"\\t\\te.g. parent (restrict decrypt): critical,keyEncipherment\\n\");\n\n    printf(\"\\t[-bit\\tbit in partialCertificate to toggle]\\n\");\n    printf(\"\\t[-sub\\tsubject same as issuer for self signed (root) certificate]\\n\");\n    printf(\"\\t[-opc\\tpartial certificate file name (default do not save)]\\n\");\n    printf(\"\\t[-oa\\taddedToCertificate file name (default do not save)]\\n\");\n    printf(\"\\t[-otbs\\tsigned tbsDigest file name (default do not save)]\\n\");\n    printf(\"\\t[-os\\tsignature file name (default do not save)]\\n\");\n    printf(\"\\t[-ocert\\t reconstructed certificate file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\n}\n\n#endif\t/* TPM_TSS_MBEDTLS */\n\n#ifdef TPM_TSS_MBEDTLS\n\nint verbose;\n\nint main(int argc, char *argv[])\n{\n    argc = argc;\n    argv = argv;\n    printf(\"certifyx509 not supported with mbedtls yet\\n\");\n    return 0;\n}\n\n#endif\t/* TPM_TSS_MBEDTLS */\n"
  },
  {
    "path": "ibmtss-ftpm/changeeps.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    ChangeEPS \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ChangeEPS_In \t\tin;\n    const char\t\t\t*authPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tin.authHandle = TPM_RH_PLATFORM;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ChangeEPS,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"changeeps: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"changeeps: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"changeeps\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ChangeEPS\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-pwda\\tauthorization password (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/changepps.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    ChangePPS \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ChangePPS_In \t\tin;\n    const char\t\t\t*authPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tin.authHandle = TPM_RH_PLATFORM;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ChangePPS,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"changepps: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"changepps: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"changepps\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ChangePPS\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-pwda\\tauthorization password (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/clear.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Clear \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Clear_In \t\t\tin;\n    char \t\t\tauthHandleChar = 0;\n    const char\t\t\t*authPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthHandleChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (authHandleChar == 'l') {\n\t    in.authHandle = TPM_RH_LOCKOUT;\n\t}\n\telse if (authHandleChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Clear,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\t\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"clear: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"clear: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"clear\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Clear\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hi\\tauthhandle hierarchy (l, p)\\n\");\n    printf(\"\\t\\tl lockout, p platform\\n\");\n    printf(\"\\t-pwda\\tauthorization password (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/clearcontrol.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    ClearControl \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ClearControl_In \t\tin;\n    char \t\t\tauthHandleChar = 0;\n    const char\t\t\t*authPassword = NULL; \n    int\t\t\t\tstate = 1;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthHandleChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-state\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tstate = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-state option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (authHandleChar == 'l') {\n\t    in.auth = TPM_RH_LOCKOUT;\n\t}\n\telse if (authHandleChar == 'p') {\n\t    in.auth = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tif (state != 0) {\n\t    in.disable = YES;\n\t}\n\telse {\n\t    in.disable = NO;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ClearControl,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"clearcontrol: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"clearcontrol: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"clearcontrol\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ClearControl\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hi\\tauthhandle hierarchy (l, p)\\n\");\n    printf(\"\\t\\tl lockout, p platform\\n\");\n    printf(\"\\t-pwda\\tauthorization password (default empty)\\n\");\n    printf(\"\\t-state\\t0 to disable, 1 to enable (default enable)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/clockrateadjust.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   ClockRateAdjust\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <inttypes.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ClockRateAdjust_In \t\tin;\n    char \t\t\thierarchyChar = 'p';\n    TPMI_RH_HIERARCHY\t\tauthHandle = TPM_RH_PLATFORM;\n    const char\t\t\t*parentPassword = NULL; \n    TPM_CLOCK_ADJUST \t\trateAdjust = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-adj\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tint tmp;\t/* sscanf with char is not portable */\n\t\tsscanf(argv[i],\"%d\", &tmp);\n\t\trateAdjust = tmp;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -adj\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.rateAdjust = rateAdjust;\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY authHandle */\n    if (rc == 0) {\n\tif (hierarchyChar == 'o') {\n\t    authHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    authHandle = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Bad parameter %c for -hi\\n\", hierarchyChar);\n\t    printUsage();\n\t}\n\tin.auth = authHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ClockRateAdjust,\n\t\t\t sessionHandle0, parentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"clockrateadjust: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"clockrateadjust: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"clockrateadjust\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ClockRateAdjust\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hi\\thierarchy auth (p, o) (default p)]\\n\"); \n    printf(\"\\t[-pwdp\\thierarchy password (default empty)]\\n\");\n    printf(\"\\t[-adj\\trate adjust (default 0)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/clockset.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   ClockSet\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <inttypes.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ClockSet_In \t\tin;\n    char \t\t\thierarchyChar = 'p';\n    TPMI_RH_HIERARCHY\t\tauthHandle = TPM_RH_PLATFORM;\n    const char\t\t\t*parentPassword = NULL; \n    uint64_t\t\t\tnewClock = 0;\n    unsigned int\t\taddSec = 0;\n    const char\t\t\t*clockFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-clock\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%\"SCNu64, &newClock);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -clock\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-addsec\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &addSec);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -addsec\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-iclock\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tclockFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-iclock option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((newClock == 0) && (clockFilename == NULL)) {\n\tprintf(\"Missing -clock or -iclock\\n\");\n\tprintUsage();\n    }\n    if ((newClock != 0) && (clockFilename != NULL)) {\n\tprintf(\"Cannot have both -clock and -iclock\\n\");\n\tprintUsage();\n    }\n    if ((rc == 0) && (newClock != 0)) {\n\tin.newTime = newClock;\n    }\n    if ((rc == 0) && (clockFilename != NULL)) {\n\tunsigned char *data = NULL;\n\tsize_t length;\n\tif (rc == 0) {\n\t    rc = TSS_File_ReadBinaryFile(&data, &length, clockFilename);\t/* freed @1 */\n\t}\n\tif (rc == 0) {\n\t    if (length != sizeof(in.newTime)) {\n\t\tprintf(\"Clock file %s length %lu should be %lu\\n\",\n\t\t       clockFilename, (unsigned long)length, (unsigned long)sizeof(in.newTime));\n\t    }\n\t}\n\tif (rc == 0) {\n\t    memcpy((uint8_t *)&in.newTime, data, length);\n\t}\n\tfree(data);\t/* @1 */\n    }\t\n    /* Table 50 - TPMI_RH_HIERARCHY authHandle */\n    if (rc == 0) {\n\t/* cast avoids overflow in multiplication */\n\tin.newTime += ((uint64_t)addSec * 1000);\t/* new clock is in msec */\n\tif (tssUtilsVerbose) printf(\"clockset: New clock %\"PRIu64\"\\n\", in.newTime);\n\tif (hierarchyChar == 'o') {\n\t    authHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    authHandle = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Bad parameter %c for -hi\\n\", hierarchyChar);\n\t    printUsage();\n\t}\n\tin.auth = authHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ClockSet,\n\t\t\t sessionHandle0, parentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"clockset: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"clockset: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"clockset\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ClockSet\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-clock\\t\\tnew clock\\n\");\n    printf(\"\\t-iclock\\t\\tnew clock file name\\n\");\n    printf(\"\\t[-addsec\\tseconds to add to new clock]\\n\");\n    printf(\"\\t-hi\\t\\thierarchy (o, p) (default platform)\\n\");\n    printf(\"\\t\\to owner, p platform\\n\");\n    printf(\"\\t-pwdp\\t\\tpassword for hierarchy (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2]\\t session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/commit.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Commit\t\t\t\t\t\t*/\n/*\t     \t\tWritten by Bill Martin \t\t\t\t\t*/\n/*                 Green Hills Integrity Software Services \t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2017 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n#include \"objecttemplates.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC \t\t\trc = 0;\n    int \t\t\ti;    /* argc iterator */\n    TSS_CONTEXT \t\t*tssContext = NULL;\n    Commit_In   \t\tin;\n    Commit_Out   \t\tout;\n    TPMI_DH_OBJECT      \tsignHandle = 0;\n    TPMA_OBJECT         \tobjectAttributes;\n    const char          \t*s2Filename = NULL;\n    const char          \t*y2Filename = NULL;\n    const char \t\t\t*dataFilename = NULL;\n    const char       \t\t*Kfilename = NULL;\n    const char          \t*Lfilename = NULL;\n    const char          \t*Efilename = NULL;\n    const char                  *counterFilename = NULL;\n    const char          \t*keyPassword = NULL;\n    TPMI_SH_AUTH_SESSION        sessionHandle0 = TPM_RS_PW;\n    unsigned int                sessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION        sessionHandle1 = TPM_RH_NULL;\n    unsigned int                sessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION        sessionHandle2 = TPM_RH_NULL;\n    unsigned int                sessionAttributes2 = 0;\n \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    objectAttributes.val = 0;\n    objectAttributes.val |= TPMA_OBJECT_NODA;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n        if (strcmp(argv[i], \"-hk\") == 0) {\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &signHandle);\n            }\n            else {\n                printf(\"Missing parameter for -hk\\n\");\n                printUsage();\n            }\n        }\n\telse if (strcmp(argv[i], \"-pt\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdataFilename = argv[i];\n\t    } else {\n\t\tprintf(\"-pt option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n        // for inSensitive data s2 see stirrandom.c\n        // I think this is gX put in array form\n        else if (strcmp(argv[i],\"-s2\") == 0) {\n            i++;\n            if (i < argc) {\n                s2Filename = argv[i];\n            }\n            else {\n                printf(\"-s2 option needs a value\\n\");\n                printUsage();\n            }\n        }\n        // for inSensitive data y2 see stirrandom.c\n        // I think this is gX put in array form\n        else if (strcmp(argv[i],\"-y2\") == 0) {\n            i++;\n            if (i < argc) {\n                y2Filename = argv[i];\n            }\n            else {\n                printf(\"-y2 option needs a value\\n\");\n                printUsage();\n            }\n        }\n\telse if (strcmp(argv[i], \"-Kf\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tKfilename = argv[i];\n\t    } else {\n\t\tprintf(\"-Kf option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-Lf\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n                Lfilename = argv[i];\n\t    } else {\n\t\tprintf(\"-Lf option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-Ef\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tEfilename = argv[i];\n\t    } else {\n\t\tprintf(\"-Ef option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n        else if (strcmp(argv[i], \"-cf\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcounterFilename = argv[i];\n\t    } else {\n\t\tprintf(\"-cf option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n        else if (strcmp(argv[i],\"-pwdk\") == 0) {\n            i++;\n            if (i < argc) {\n                keyPassword = argv[i];\n            }\n            else {\n                printf(\"-pwdk option needs a value\\n\");\n                printUsage();\n            }\n        }\n        else if (strcmp(argv[i],\"-se0\") == 0) {\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionHandle0);\n            }\n            else {\n                printf(\"Missing parameter for -se0\\n\");\n                printUsage();\n            }\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionAttributes0);\n                if (sessionAttributes0 > 0xff) {\n                    printf(\"Out of range session attributes for -se0\\n\");\n                    printUsage();\n                }\n            }\n            else {\n                printf(\"Missing parameter for -se0\\n\");\n                printUsage();\n            }\n        }\n        else if (strcmp(argv[i],\"-se1\") == 0) {\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionHandle1);\n            }\n            else {\n                printf(\"Missing parameter for -se1\\n\");\n                printUsage();\n            }\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionAttributes1);\n                if (sessionAttributes1 > 0xff) {\n                    printf(\"Out of range session attributes for -se1\\n\");\n                    printUsage();\n                }\n            }\n            else {\n                printf(\"Missing parameter for -se1\\n\");\n                printUsage();\n            }\n        }\n        else if (strcmp(argv[i],\"-se2\") == 0) {\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionHandle2);\n            }\n            else {\n                printf(\"Missing parameter for -se2\\n\");\n                printUsage();\n            }\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionAttributes2);\n                if (sessionAttributes2 > 0xff) {\n                    printf(\"Out of range session attributes for -se2\\n\");\n                    printUsage();\n                }\n            }\n            else {\n                printf(\"Missing parameter for -se2\\n\");\n                printUsage();\n            }\n        }\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (signHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform signing */\n\tin.signHandle = signHandle;\n    }\n    /* set P1 */\n    if (rc == 0) {\n\tif (dataFilename != NULL) {\n\t    rc = TSS_File_ReadStructure(&in.P1,\n\t\t\t\t\t(UnmarshalFunction_t)TSS_TPM2B_ECC_POINT_Unmarshalu,\n\t\t\t\t\tdataFilename);\n\t}\n\telse {\n\t    in.P1.point.x.t.size = 0;\n\t    in.P1.point.y.t.size = 0;\n\t}\n    }\n    /* set S2 */\n    if (rc == 0) {\n\tif (s2Filename != NULL) {\n\t    rc = TSS_File_Read2B(&in.s2.b,\n\t\t\t\t sizeof(in.s2.t.buffer),\n\t\t\t\t s2Filename);\n\t}\n\telse {\n\t    in.s2.t.size = 0;\n\t}\n    }\n    /* set y2 */\n    if (rc == 0) {\n\tif (y2Filename != NULL) {\n\t    rc = TSS_File_Read2B(&in.y2.b,\n\t\t\t\t sizeof(in.y2.t.buffer),\n\t\t\t\t y2Filename);\n\t}\n\telse {\n\t    in.y2.t.size = 0;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Commit,\n                         sessionHandle0, keyPassword, sessionAttributes0,\n                         sessionHandle1, NULL, sessionAttributes1,\n                         sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (Kfilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.K,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_ECC_POINT_Marshalu,\n\t\t\t\t     Kfilename);\n\n\n    }\n    if ((rc == 0) && (Lfilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.L,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_ECC_POINT_Marshalu,\n\t\t\t\t     Lfilename);\n\n\n    }\n    if ((rc == 0) && (Efilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.E,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_ECC_POINT_Marshalu,\n\t\t\t\t     Efilename);\n\n\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"counter is %d\\n\", out.counter);\n        if (counterFilename != NULL)  {\n\t    rc = TSS_File_WriteStructure(&out.counter,\n\t\t\t\t\t (MarshalFunction_t)TSS_UINT16_Marshalu,\n\t\t\t\t\t counterFilename);\n        }\n    } \n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"commit: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"commit: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"commit\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Commit\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t[-pt\\tpoint input file name (default empty)]\\n\");\n    printf(\"\\t[-s2\\ts2 input file name (default empty)]\\n\");\n    printf(\"\\t[-y2\\ty2 input file name (default empty)]\\n\");\n    printf(\"\\t[-Kf\\tK output data file name (default do not save)]\\n\");\n    printf(\"\\t[-Lf\\toutput data file name (default do not save)]\\n\");\n    printf(\"\\t[-Ef\\toutput data file name (default do not save)]\\n\");\n    printf(\"\\t[-cf\\toutput counter file name (default do not save)]\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1); \n}\n\n\n\n"
  },
  {
    "path": "ibmtss-ftpm/contextload.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   ContextLoad \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ContextLoad_In \t\tin;\n    ContextLoad_Out\t\tout;\n    const char\t\t\t*contextFilename = NULL;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcontextFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (contextFilename == NULL) {\n\tprintf(\"Missing context file parameter -if\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.context,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPMS_CONTEXT_Unmarshalu,\n\t\t\t\t    contextFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ContextLoad,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"Handle %08x\\n\", out.loadedHandle);\n\tif (tssUtilsVerbose) printf(\"contextload: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"contextload: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"contextload\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ContextLoad\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-if\\tcontext file name\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/contextsave.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   ContextSave \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ContextSave_In \t\tin;\n    ContextSave_Out \t\tout;\n    TPMI_DH_CONTEXT\t\tsaveHandle = 0;\n    const char\t\t\t*contextFilename = NULL;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &saveHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-of\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcontextFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (saveHandle == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.saveHandle = saveHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ContextSave,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* save the context */\n    if ((rc == 0) && (contextFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.context,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMS_CONTEXT_Marshalu,\n\t\t\t\t     contextFilename );\n    }\n    if (rc == 0) {\n\tprintf(\"TPMS_CONTEXT.savedHandle %08x\\n\", out.context.savedHandle);\n\tif (tssUtilsVerbose) printf(\"contextsave: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"contextsave: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"contextsave\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ContextSave\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\thandle\\n\");\n    printf(\"\\t[-of\\tcontext file name (default do not save)]\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/create.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Create \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2023\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n#include \"objecttemplates.h\"\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Create_In \t\t\tin;\n    Create_Out \t\t\tout;\n    TPMI_DH_OBJECT\t\tparentHandle = 0;\n    TPMA_OBJECT\t\t\taddObjectAttributes;\n    TPMA_OBJECT\t\t\tdeleteObjectAttributes;\n    int\t\t\t\tkeyType = 0;\n    uint32_t \t\t\tkeyTypeSpecified = 0;\n    int\t\t\t\trev116 = FALSE;\n    TPMI_ALG_PUBLIC \t\talgPublic = TPM_ALG_RSA;\n    TPMI_ECC_CURVE\t\tcurveID = TPM_ECC_NONE;\n    TPMI_RSA_KEY_BITS \t\tkeyBits = 2048;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_ALG_HASH\t\tnalg = TPM_ALG_SHA256;\n    const char\t\t\t*policyFilename = NULL;\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*privateKeyFilename = NULL;\n    const char\t\t\t*pemFilename = NULL;\n    const char\t\t\t*ticketFilename = NULL;\n    const char\t\t\t*creationHashFilename = NULL;\n    const char\t\t\t*creationDataFilename = NULL;\n    const char \t\t\t*dataFilename = NULL;\n    const char\t\t\t*keyPassword = NULL; \n    const char\t\t\t*parentPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    addObjectAttributes.val = 0;\n    addObjectAttributes.val |= TPMA_OBJECT_NODA;\n    deleteObjectAttributes.val = 0;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &parentHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-bl\") == 0) {\n\t    keyType = TYPE_BL;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-den\") == 0) {\n\t    keyType = TYPE_DEN;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-deo\") == 0) {\n\t    keyType = TYPE_DEO;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dee\") == 0) {\n\t    keyType = TYPE_DEE;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-des\") == 0) {\n\t    keyType = TYPE_DES;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-st\") == 0) {\n\t    keyType = TYPE_ST;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-si\") == 0) {\n\t    keyType = TYPE_SI;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dau\") == 0) {\n\t    keyType = TYPE_DAA;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dar\") == 0) {\n\t    keyType = TYPE_DAAR;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-sir\") == 0) {\n\t    keyType = TYPE_SIR;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-kh\") == 0) {\n\t    keyType = TYPE_KH;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-khr\") == 0) {\n\t    keyType = TYPE_KHR;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dp\") == 0) {\n\t    keyType = TYPE_DP;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-gp\") == 0) {\n\t    keyType = TYPE_GP;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-116\") == 0) {\n\t    rev116 = TRUE;\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    algPublic = TPM_ALG_RSA;\n\t    /* if next argument is keysize */\n\t    if (((i + 1) < argc) && (argv[i+1][0] != '-')) {\n\t\ti++;\n\t\tsscanf(argv[i],\"%hu\", &keyBits);\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    algPublic = TPM_ALG_ECC;\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"bnp256\") == 0) {\n\t\t    curveID = TPM_ECC_BN_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp256\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp384\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -ecc\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-ecc option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-kt\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i], \"f\") == 0) {\n\t\t    addObjectAttributes.val |= TPMA_OBJECT_FIXEDTPM;\n   \t\t}\n\t\telse if (strcmp(argv[i], \"p\") == 0) {\n\t\t    addObjectAttributes.val |= TPMA_OBJECT_FIXEDPARENT;\n\t\t}\n\t\telse if (strcmp(argv[i], \"nf\") == 0) {\n\t\t    deleteObjectAttributes.val |= TPMA_OBJECT_FIXEDTPM;\n\t\t}\n\t\telse if (strcmp(argv[i], \"np\")  == 0) {\n\t\t    deleteObjectAttributes.val |= TPMA_OBJECT_FIXEDPARENT;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ed\")  == 0) {\n\t\t    addObjectAttributes.val |= TPMA_OBJECT_ENCRYPTEDDUPLICATION;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -kt\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -kt\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-uwa\") == 0) {\n\t    deleteObjectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\t}\n\telse if (strcmp(argv[i], \"-da\") == 0) {\n\t    addObjectAttributes.val &= ~TPMA_OBJECT_NODA;\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    nalg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    nalg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    nalg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    nalg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -nalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-nalg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tprivateKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opr option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opem\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opem option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ch\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcreationHashFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ch option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-cd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcreationDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-cd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pol\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pol option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdeleteObjectAttributes.val |= TPMA_OBJECT_SENSITIVEDATAORIGIN;\n\t\tdataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (parentHandle == 0) {\n\tprintf(\"Missing handle parameter -hp\\n\");\n\tprintUsage();\n    }\n    if (keyTypeSpecified != 1) {\n\tprintf(\"Missing or too many key attributes\\n\");\n\tprintUsage();\n    }\n    switch (keyType) {\n      case TYPE_BL:\n\tif (dataFilename == NULL) {\n\t    printf(\"-bl needs -if (sealed data object needs data to seal)\\n\");\n\t    printUsage();\n\t}\n\tbreak;\n      case TYPE_DAA:\n      case TYPE_DAAR:\n\tif (algPublic != TPM_ALG_ECC) {\n\t    printf(\"-dau and -dar need -ecc\\n\");\n \t    printUsage();\n\t}\n\tif (dataFilename != NULL) {\n\t    printf(\"asymmetric key cannot have -if (sensitive data)\\n\");\n\t    printUsage();\n\t}\n\tbreak;\n      case TYPE_ST:\n      case TYPE_DEN:\n      case TYPE_DEO:\n      case TYPE_DEE:\n      case TYPE_SI:\n      case TYPE_SIR:\n      case TYPE_GP:\n\tif (dataFilename != NULL) {\n\t    printf(\"asymmetric key cannot have -if (sensitive data)\\n\");\n\t    printUsage();\n\t}\n\tbreak;\n      case TYPE_DES:\n      case TYPE_KH:\n      case TYPE_KHR:\n      case TYPE_DP:\n\t/* inSensitive optional for symmetric keys */\n\tbreak;\n    }\n    if (rc == 0) {\n\tin.parentHandle = parentHandle;\n    }\n    /* Table 134 - Definition of TPM2B_SENSITIVE_CREATE inSensitive */\n    if (rc == 0) {\n\t/* Table 133 - Definition of TPMS_SENSITIVE_CREATE Structure <IN>sensitive  */\n\t/* Table 75 - Definition of Types for TPM2B_AUTH userAuth */\n\tif (keyPassword == NULL) {\n\t    in.inSensitive.sensitive.userAuth.t.size = 0;\n\t}\n\telse {\n\t    rc = TSS_TPM2B_StringCopy(&in.inSensitive.sensitive.userAuth.b,\n\t\t\t\t      keyPassword,\n\t\t\t\t      sizeof(in.inSensitive.sensitive.userAuth.t.buffer));\n\t}\n    }\n    if (rc == 0) {\n\t/* Table 132 - Definition of TPM2B_SENSITIVE_DATA Structure data */\n\tif (dataFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.inSensitive.sensitive.data.b,\n\t\t\t\t sizeof(in.inSensitive.sensitive.data.t.buffer),\n\t\t\t\t dataFilename);\n\t}\n\telse {\n\t    in.inSensitive.sensitive.data.t.size = 0;\n\t}\n    }\n    /* TPM2B_PUBLIC */\n    if (rc == 0) {\n\tswitch (keyType) {\n\t  case TYPE_BL:\n\t    rc = blPublicTemplate(&in.inPublic.publicArea,\n\t\t\t\t  addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t  nalg,\n\t\t\t\t  policyFilename);\n\t    break;\n\t  case TYPE_ST:\n\t  case TYPE_DAA:\n\t  case TYPE_DAAR:\n\t  case TYPE_DEN:\n\t  case TYPE_DEO:\n\t  case TYPE_DEE:\n\t  case TYPE_SI:\n\t  case TYPE_SIR:\n\t  case TYPE_GP:\n\t    rc = asymPublicTemplate(&in.inPublic.publicArea,\n\t\t\t\t    addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t    keyType, algPublic, keyBits, curveID, nalg, halg,\n\t\t\t\t    policyFilename);\n\t    break;\n\t  case TYPE_DES:\n\t    rc = symmetricCipherTemplate(&in.inPublic.publicArea,\n\t\t\t\t\t addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t\t nalg, rev116,\n\t\t\t\t\t policyFilename);\n\t    break;\n\t  case TYPE_KH:\n\t  case TYPE_KHR:\n\t    rc = keyedHashPublicTemplate(&in.inPublic.publicArea,\n\t\t\t\t\t addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t\t keyType, nalg, halg,\n\t\t\t\t\t policyFilename);\n\t    break;\n\t  case TYPE_DP:\n\t    rc = derivationParentPublicTemplate(&in.inPublic.publicArea,\n\t\t\t\t\t\taddObjectAttributes, deleteObjectAttributes,\n\t\t\t\t\t\tnalg, halg,\n\t\t\t\t\t\tpolicyFilename);\n\t} \n    }\n    if (rc == 0) {\n\t/* TPM2B_DATA outsideInfo */\n\tin.outsideInfo.t.size = 0;\n\t/* Table 102 - TPML_PCR_SELECTION creationPCR */\n\tin.creationPCR.count = 0;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Create,\n\t\t\t sessionHandle0, parentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /*\n      validate the creation data\n    */\n    {\n\tuint16_t\twritten = 0;\n\tuint8_t\t\t*buffer = NULL;\t\t/* for the free */\n\tuint32_t \tsizeInBytes;\n\tTPMT_HA\t\tdigest;\n\n\t/* get the digest size from the Name algorithm */\n\tif (rc == 0) {\n\t    sizeInBytes = TSS_GetDigestSize(nalg);\n\t    if (out.creationHash.b.size != sizeInBytes) {\n\t\tprintf(\"create: failed, \"\n\t\t       \"creationHash size %u incompatible with name algorithm %04x\\n\",\n\t\t       out.creationHash.b.size, nalg);\n\t\trc = EXIT_FAILURE;\n\t    }\n\t}\n\t/* re-marshal the output structure */\n\tif (rc == 0) {\n\t    rc = TSS_Structure_Marshal(&buffer,\t/* freed @1 */\n\t\t\t\t       &written,\n\t\t\t\t       &out.creationData.creationData,\n\t\t\t\t       (MarshalFunction_t)TSS_TPMS_CREATION_DATA_Marshalu);\n\t}\n\t/* recalculate the creationHash from creationData */\n\tif (rc == 0) {\n\t    digest.hashAlg = nalg;\t\t\t/* Name digest algorithm */\n\t    rc = TSS_Hash_Generate(&digest,\t\n\t\t\t\t   written, buffer,\n\t\t\t\t   0, NULL);\n\t}\n\t/* compare the digest to creation hash */\n\tif (rc == 0) {\n\t    int irc;\n\t    irc = memcmp((uint8_t *)&digest.digest, &out.creationHash.b.buffer, sizeInBytes);\n\t    if (irc != 0) {\n\t\tprintf(\"create: failed, creationData hash does not match creationHash\\n\");\n\t\trc = EXIT_FAILURE;\n\t    }\n\t}\n\tfree(buffer);\t/* @1 */\n    }\n    /* save the private key */\n    if ((rc == 0) && (privateKeyFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.outPrivate,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PRIVATE_Marshalu,\n\t\t\t\t     privateKeyFilename);\n    }\n    /* save the public key */\n    if ((rc == 0) && (publicKeyFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.outPublic,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PUBLIC_Marshalu,\n\t\t\t\t     publicKeyFilename);\n    }\n    /* save the optional PEM public key */\n    if ((rc == 0) && (pemFilename != NULL)) {\n\trc = convertPublicToPEM(&out.outPublic,\n\t\t\t\tpemFilename);\n    }\n    /* save the optional creation ticket */\n    if ((rc == 0) && (ticketFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.creationTicket,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_TK_CREATION_Marshalu,\n\t\t\t\t     ticketFilename);\n    }\n    /* save the optional creation hash */\n    if ((rc == 0) && (creationHashFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.creationHash.b.buffer,\n\t\t\t\t      out.creationHash.b.size,\n\t\t\t\t      creationHashFilename);\n    }\n    /* save the optional creation data */\n    if ((rc == 0) && (creationDataFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.creationData.creationData,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMS_CREATION_DATA_Marshalu,\n\t\t\t\t     creationDataFilename);\n    }\n    /* regression test sanity check */\n    if ((rc == 0) && (creationDataFilename != NULL)) {\n\tTPMS_CREATION_DATA creationDataTest;\n\trc = TSS_File_ReadStructure(&creationDataTest,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPMS_CREATION_DATA_Unmarshalu,\n\t\t\t\t    creationDataFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"create: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"create: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"create\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Create\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hp parent handle\\n\");\n    printf(\"\\n\");\n    printUsageTemplate();\n    printf(\"\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-pwdp\\tpassword for parent key (default empty)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-opu\\tpublic key file name (default do not save)]\\n\");\n    printf(\"\\t[-opr\\tprivate key file name (default do not save)]\\n\");\n    printf(\"\\t[-opem\\tpublic key PEM format file name (default do not save)]\\n\");\n    printf(\"\\t[-tk\\toutput ticket file name (default do not save)]\\n\");\n    printf(\"\\t[-ch\\toutput creation hash file name (default do not save)]\\n\");\n    printf(\"\\t[-cd\\toutput creation data file name]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/createek.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     IWG EK Index Parsing\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* This demo application shows the EK createprimary process.\n\n   It reads the EK template at 01c00004 (RSA) 01c0000c (EC)\n\n   It reads the EK nonce at 01c00003 (RSA) 01c0000b (EC)\n\n   It constructs an EK createprimary input and runs the command\n\n   Optionally:\n\n   It reads the EK certificate at 01c00002 (RSA) 01c0000a (EC) \n\n   It compares the public key from the createprimary to that of the certificate.\n\n   Optionally:\n\n   If validates the EK certificate against the TPM vendor root CA certificate.\n\n   To validate certificate against the root, it must be in a file in PEM format.  The root typically\n   comes from the TPM vendor in DER (binary) format.  Convert using openssl, approximately:\n\n   > openssl x509 -inform der -outform pem -in certificate.der -out certificate.pem\n\n   This is a one time operation.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n/* Windows 10 crypto API clashes with openssl */\n#ifdef TPM_WINDOWS\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n#include \"ekutils.h\"\n\n/* local function prototypes */\n\nstatic void printUsage(void);\n\n/* possible utility commands */\n\n#define EKTemplateType\t\t1\n#define EKNonceType\t\t2\n#define EKCertType\t\t3\n#define CreateprimaryType\t4\n\n/* RSA or ECC algorithm */\n\n#define AlgRSA\t\t\t1\n#define AlgEC\t\t\t2\n\n/* EK on low or high range, EK spec 2.3 */\n\n#define LowRange\t1\n#define HighRange\t2\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    unsigned int\t\tui;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    int\t\t\t\tinputType = 0;\n    const char \t\t\t*listFilename = NULL;\n    unsigned int\t\tinputCount = 0;\n    unsigned int\t\talgCount = 0;\n    int\t\t\t\trange = LowRange;\t/* default low range */\n    TPMI_ALG_PUBLIC \t\talgPublic = 0;\n    TPMI_RSA_KEY_BITS \t\tkeyBits = 0;\n    /* initialized to suppress false gcc -O3 warning */\n    const char\t\t\t*endorsementPassword = NULL; \n    const char\t\t\t*keyPassword = NULL; \n    TPMI_RH_NV_INDEX\t\tekCertIndex = 0;\n    TPMI_RH_NV_INDEX\t\tekNonceIndex = 0;\n    TPMI_RH_NV_INDEX\t\tekTemplateIndex = 0;\n    TPMT_PUBLIC \t\ttpmtPublic;\n    char\t\t\t*rootFilename[MAX_ROOTS];\n    unsigned int\t\trootFileCount = 0;\n    unsigned char \t\t*nonce = NULL; \t\t/* freed @1 */\n    uint16_t \t\t\tnonceSize;\n    void \t\t\t*ekCertificate = NULL;\n    uint8_t \t\t\t*modulusBin = NULL;\n    int\t\t\t\tmodulusBytes;\n    unsigned int \t\tnoFlush = 0;\t\t/* default flush after validation */\n    unsigned int \t\tnoPub = 0;\t\t/* default validate public key */\n    TPM_HANDLE \t\t\tkeyHandle;\t\t/* primary key handle */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    /* for free */\n    for (i = 0 ; i < MAX_ROOTS ; i++) {\n\trootFilename[i] = NULL;\n    }\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-te\") == 0) {\n\t    inputType = EKTemplateType;\n\t    inputCount++;\n\t}\n\telse if (strcmp(argv[i],\"-no\") == 0) {\n\t    inputType = EKNonceType;\n\t    inputCount++;\n\t}\n\telse if (strcmp(argv[i],\"-ce\") == 0) {\n\t    inputType = EKCertType;\n\t    inputCount++;\n\t}\n\telse if (strcmp(argv[i],\"-cp\") == 0) {\n\t    inputType = CreateprimaryType;\n\t    inputCount++;\n\t}\n\telse if (strcmp(argv[i],\"-pwde\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tendorsementPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwde option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-high\") == 0) {\n\t    range = HighRange;\n\t    if (algPublic != 0) {\n\t\tprintf(\"-high must be specified before -rsa or -ecc\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-root\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tlistFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-root option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    algPublic = TPM_ALG_RSA;\n\t    algCount++;\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%hu\", &keyBits);\n\t\tswitch (keyBits) {\n\t\t  case 2048:\n\t\t    if (range == LowRange) {\n\t\t\tekCertIndex = EK_CERT_RSA_INDEX;\n\t\t\tekNonceIndex = EK_NONCE_RSA_INDEX;\n\t\t\tekTemplateIndex = EK_TEMPLATE_RSA_INDEX;\n\t\t    }\n\t\t    else {\t/* high range */\n\t\t\tekCertIndex = EK_CERT_RSA_2048_INDEX_H1;\n\t\t    }\n\t\t    break;\n\t\t  case 3072:\n\t\t    ekCertIndex = EK_CERT_RSA_3072_INDEX_H6;\n\t\t    break;\n\t\t  case 4096:\n\t\t    ekCertIndex = EK_CERT_RSA_4096_INDEX_H7;\n\t\t    break;\n\t\t  default:\n\t\t    printf(\"Bad key size %s for -rsa\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing keysize parameter for -rsa\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    algPublic = TPM_ALG_ECC;\n\t    algCount++;\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"nistp256\") == 0) {\n\t\t    if (range == LowRange) {\n\t\t\tekCertIndex = EK_CERT_EC_INDEX;\n\t\t\tekNonceIndex = EK_NONCE_EC_INDEX;\n\t\t\tekTemplateIndex = EK_TEMPLATE_EC_INDEX;\n\t\t    }\n\t\t    else {\t/* high range */\n\t\t\tekCertIndex = EK_CERT_ECC_NISTP256_INDEX_H2;\n\t\t    }\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp384\") == 0) {\n\t\t    ekCertIndex = EK_CERT_ECC_NISTP384_INDEX_H3;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp521\") == 0) {\n\t\t    ekCertIndex = EK_CERT_ECC_NISTP521_INDEX_H4;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad curve parameter %s for -ecc\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-ecc option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-noflush\") == 0) {\n\t    noFlush = 1;\n\t}\n\telse if (strcmp(argv[i],\"-nopub\") == 0) {\n\t    noPub = 1;\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n \t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (inputCount > 1) {\n\tprintf(\"Only one of -te, -no, -ce can be specified\\n\");\n\tprintUsage();\n    }\n    if (algCount == 0) {\n\tprintf(\"One of -rsa, -ecc must be specified\\n\");\n\tprintUsage();\n    }\n    if (algCount > 1) {\n\tprintf(\"Only one of -rsa, -ecc can be specified\\n\");\n\tprintUsage();\n    }\n    if ((inputCount == 0) && (listFilename == NULL)) {\n\tprintf(\"Nothing to do\\n\");\n\tprintUsage();\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    if (rc == 0) {\n\tswitch (inputType) {\n\t  case EKTemplateType:\n\t    if (rc == 0) {\n\t\tif (ekTemplateIndex == 0) {\n\t\t    rc = TSS_RC_X509_ERROR;\n\t\t}\n\t    }\n\t    if (rc == 0) {\n\t\trc = processEKTemplate(tssContext, &tpmtPublic, ekTemplateIndex, TRUE);\n\t    }\n\t    if (rc != 0) {\n\t\tprintf(\"No EK template for EK certifcate index %08x\\n\", ekCertIndex);\n\t    }\n\t    break;\n\t  case EKNonceType:\n\t    if (rc == 0) {\n\t\tif (ekNonceIndex == 0) {\n\t\t    rc = TSS_RC_X509_ERROR;\n\t\t}\n\t    }\n\t    if (rc == 0) {\n\t\trc = processEKNonce(tssContext, &nonce, &nonceSize, ekNonceIndex, TRUE);\n\t    }\n\t    if (rc != 0) {\n\t\tprintf(\"No EK nonce for EK certifcate index %08x\\n\", ekCertIndex);\n\t    }\n\t    break;\n\t  case EKCertType:\n\t    rc = processEKCertificate(tssContext,\n\t\t\t\t      &ekCertificate,\t\t\t/* freed @2 */\n\t\t\t\t      &modulusBin, &modulusBytes,\t/* freed @3 */\n\t\t\t\t      ekCertIndex,\n\t\t\t\t      TRUE);\t\t/* print the EK certificate */\n\t    break;\n\t  case CreateprimaryType:\n\t    rc = processPrimaryEN(tssContext, &keyHandle,\n\t\t\t\t  endorsementPassword, keyPassword,\n\t\t\t\t  ekCertIndex,\n\t\t\t\t  ekNonceIndex, ekTemplateIndex,\n\t\t\t\t  noFlush, noPub, TRUE);\n\t    break;\n\t}\n    }\n    if (listFilename != NULL) {\n\t/* get the list of of root EK CA certificate file names */\n\tif (rc == 0) {\n\t    rc = getRootCertificateFilenames(rootFilename,\t/* freed @4 */\n\t\t\t\t\t     &rootFileCount,\n\t\t\t\t\t     listFilename,\n\t\t\t\t\t     tssUtilsVerbose);\n\t}\n\t/* validate the EK certificate at ekCertIndex against the EK CA certifcates */\n\tif (rc == 0) {\n\t    rc = processRoot(tssContext,\n\t\t\t     ekCertIndex,\n\t\t\t     (const char **)rootFilename,\n\t\t\t     rootFileCount,\n\t\t\t     TRUE);\n\t}\n    }\n    if ((rc == 0) && noFlush && (inputType == CreateprimaryType)) {\n\tprintf(\"Primary key Handle %08x\\n\", keyHandle);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc != 0) {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"createek: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(nonce);\t\t\t/* @1 */\n    x509FreeStructure(ekCertificate);  \t/* @2 */\n    free(modulusBin);\t\t\t/* @3 */\n    for (ui = 0 ; ui < rootFileCount ; ui++) {\n\tfree(rootFilename[ui]);\t\t/* @4 */\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"createek\\n\");\n    printf(\"\\n\");\n    printf(\"createek provides several options regarding the IWG standard EKs\\n\");\n    printf(\"\\n\");\n    printf(\"-cp creates an EK primary key based on the EK NV indexes.\\n\"\n\t   \"By default, the EK is flushed, but -noflush will override that.\\n\"\n\t   \"By default, the EK public key is verified against the EK certificate,\\n\"\n\t   \"but -nopub will skip the check.\\n\");\n    printf(\"\\n\");\n    printf(\"-root reads the EK certificate and validates it agains the EK CA certificates\\n\");\n    printf(\"\\n\");\n    printf(\"-ce prints provisioned EK certificates\\n\");\n    printf(\"\\n\");\n    printf(\"-te and -no print the deprecated EK template and nonce if present\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwde\\t\\tendorsement hierarchy password (default empty)]\\n\");\n    printf(\"\\t[-pwdk\\t\\tpassword for endorsement key (default empty)]\");\n    printf(\"\\n\");\n    printf(\"\\t[-high\\t\\tUse the IWG NV high range. Specify before algorithm]\\n\");\n    printf(\"\\t-rsa keybits\\n\");\n    printf(\"\\t\\t2048\\n\");\n    printf(\"\\t\\t3072\\n\");\n    printf(\"\\t\\t4096\\n\");\n    printf(\"\\t-ecc curve\\n\");\n    printf(\"\\t\\tnistp256\\n\");\n    printf(\"\\t\\tnistp384\\n\");\n    printf(\"\\t\\tnistp521\\n\");\n    printf(\"\\t-te\\tprint EK Template \\n\");\n    printf(\"\\t-no\\tprint EK nonce \\n\");\n    printf(\"\\t-ce\\tprint EK certificate \\n\");\n    printf(\"\\t-cp\\tCreatePrimary  the EK\\n\");\n    printf(\"\\t[-noflush\\tDo not flush the primary key after validation]\\n\");\n    printf(\"\\t[-nopub\\t\\tDo not verify the public key against the certificate]\\n\");\n    printf(\"\\t[-root\\tfilename - validate EK certificate against the root]\\n\");\n    printf(\"\\t\\tfilename contains a list of PEM format CA root certificate\\n\"\n\t   \"\\t\\tfilenames, one per line.\\n\");\n    printf(\"\\t\\tThe list may contain up to %u certificates.\\n\", MAX_ROOTS);\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/createekcert.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tTPM 2.0 Attestation - Client EK and EK certificate  \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2016 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* This program provisions an EK certificate.  It is required only for a SW TPM, which does not, of\n   course, come with a certificate.  The NV resident EK template and EK nonce are not used.\n\n   NOTE This is a one time operation unless the EPS is changed, typically through the TSS regression\n   test.\n\n   Steps implemented:\n\n   Create a primary key using the an IWG template\n \n   Create a certificate using the CA key cakey.pem\n\n   Create NV Index if not already provisioned.\n\n   Write the certificate to NV.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n/* Windows 10 crypto API clashes with openssl */\n#ifdef TPM_WINDOWS\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsscrypto.h>\n#include \"ekutils.h\"\n\n/* local function prototypes */\n\nstatic void printUsage(void);\n\nstatic TPM_RC defineEKCertIndex(TSS_CONTEXT *tssContext,\n\t\t\t\tuint32_t certLength,\n\t\t\t\tTPMI_RH_NV_INDEX nvIndex,\n\t\t\t\tconst char *platformPassword);\nstatic TPM_RC storeEkCertificate(TSS_CONTEXT *tssContext,\n\t\t\t\t uint32_t certLength,\n\t\t\t\t unsigned char *certificate,\n\t\t\t\t TPMI_RH_NV_INDEX nvIndex,\n\t\t\t\t const char *platformPassword);\n\n/* EK on low or high range, EK spec 2.3 */\n\n#define LowRange\t1\n#define HighRange\t2\n\nint vverbose = 0;\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    int \t\trc = 0;\n    int\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT \t*tssContext = NULL;\n    int\t\t\tnoFlush = FALSE;\n    unsigned int\talgCount = 0;\n    int\t\t\trange = LowRange;\t/* default low range */\n    TPMI_ALG_PUBLIC \talgPublic = 0;\n    TPMI_RSA_KEY_BITS \tkeyBits = 0;\n    const char\t\t*certificateFilename = NULL;\n    TPMI_RH_NV_INDEX\tekCertIndex = EK_CERT_RSA_INDEX;\n    /* the CA for endorsement key certificates */\n    const char \t\t*caKeyFileName = NULL;\n    const char \t\t*caKeyPassword = \"\";\n    const char\t\t*platformPassword = NULL;\n    const char\t\t*endorsementPassword = NULL;\n    const char\t\t*keyPassword = NULL; \n    TPMT_PUBLIC \ttpmtPublicOut;\t\t/* primary key public part */\n    char \t\t*x509CertString = NULL;\n    char \t\t*pemCertString = NULL;\n    uint32_t \t\tcertLength;\n    unsigned char \t*certificate = NULL;\n\n    /* FIXME may be better from command line or config file */\n    char *subjectEntries[] = {\n\t\"US\",\t\t/* 0 country */\n\t\"NY\",\t\t/* 1 state */\n\t\"Yorktown\",\t/* 2 locality*/\n\t\"IBM\",\t\t/* 3 organization */\n\tNULL,\t\t/* 4 organization unit */\n\t\"IBM's SW TPM\",\t/* 5 common name */\n\tNULL\t\t/* 6 email */\n    };\n    /* FIXME should come from root certificate, cacert.pem, cacertec.pem */\n    char *rootIssuerEntriesRsa[] = {\n\t\"US\"\t\t\t,\n\t\"NY\"\t\t\t,\n\t\"Yorktown\"\t\t,\n\t\"IBM\"\t\t\t,\n\tNULL\t\t\t,\n\t\"EK CA\"\t\t\t,\n\tNULL\n    };\n    char *rootIssuerEntriesEc[] = {\n\t\"US\"\t\t\t,\n\t\"NY\"\t\t\t,\n\t\"Yorktown\"\t\t,\n\t\"IBM\"\t\t\t,\n\tNULL\t\t\t,\n\t\"EK EC CA\"\t\t,\n\tNULL\n    };\n    /* default RSA */\n    char \t\t**issuerEntries = rootIssuerEntriesRsa;\n    size_t\t\tissuerEntriesSize = sizeof(rootIssuerEntriesRsa)/sizeof(char *);\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-noflush\") == 0) {\n\t    noFlush = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-of\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcertificateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-high\") == 0) {\n\t    range = HighRange;\n\t    if (algPublic != 0) {\n\t\tprintf(\"-high must be specified before -rsa or -ecc\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    algPublic = TPM_ALG_RSA;\n\t    algCount++;\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%hu\", &keyBits);\n\t\tswitch (keyBits) {\n\t\t  case 2048:\n\t\t    if (range == LowRange) {\n\t\t\tekCertIndex = EK_CERT_RSA_INDEX;\n\t\t    }\n\t\t    else {\t/* high range */\n\t\t\tekCertIndex = EK_CERT_RSA_2048_INDEX_H1;\n\t\t    }\n\t\t    break;\n\t\t  case 3072:\n\t\t    ekCertIndex = EK_CERT_RSA_3072_INDEX_H6;\n\t\t    break;\n\t\t  case 4096:\n\t\t    ekCertIndex = EK_CERT_RSA_4096_INDEX_H7;\n\t\t    break;\n\t\t  default:\n\t\t    printf(\"Bad key size %s for -rsa\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing keysize parameter for -rsa\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    algPublic = TPM_ALG_ECC;\n\t    algCount++;\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"nistp256\") == 0) {\n\t\t    if (range == LowRange) {\n\t\t\tekCertIndex = EK_CERT_EC_INDEX;\n\t\t    }\n\t\t    else {\t/* high range */\n\t\t\tekCertIndex = EK_CERT_ECC_NISTP256_INDEX_H2;\n\t\t    }\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp384\") == 0) {\n\t\t    ekCertIndex = EK_CERT_ECC_NISTP384_INDEX_H3;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp521\") == 0) {\n\t\t    ekCertIndex = EK_CERT_ECC_NISTP521_INDEX_H4;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad curve parameter %s for -ecc\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-ecc option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-caalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsa\") == 0) {\n\t\t    issuerEntries = rootIssuerEntriesRsa;\n\t\t    issuerEntriesSize = sizeof(rootIssuerEntriesRsa)/sizeof(char *);\n\t\t}\n\t\telse if (strcmp(argv[i],\"ec\") == 0) {\n\t\t    issuerEntries = rootIssuerEntriesEc;\n\t\t    issuerEntriesSize = sizeof(rootIssuerEntriesEc)/sizeof(char *);\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -caalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-caalg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-cakey\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcaKeyFileName = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: Missing parameter for -cakey\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-capwd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcaKeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: Missing parameter for -capwd\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tplatformPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwde\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tendorsementPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwde option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = 1;\n\t}\n\telse if (strcmp(argv[i],\"-vv\") == 0) {\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\t/* trace entire TSS */\n\t    tssUtilsVerbose = 1;\n\t    vverbose = 1;\n\t}\n\telse {\n \t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (algCount == 0) {\n\tprintf(\"One of -rsa, -ecc must be specified\\n\");\n\tprintUsage();\n    }\n    if (algCount > 1) {\n\tprintf(\"Only one of -rsa, -ecc can be specified\\n\");\n\tprintUsage();\n    }\n    if (caKeyFileName == NULL) {\n\tprintf(\"ERROR: Missing -cakey\\n\");\n\tprintUsage();\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* create a primary EK using the default IWG template */\n    if (rc == 0) {\n\tTPM_HANDLE keyHandle;\n\trc = processCreatePrimaryE(tssContext,\n\t\t\t\t   &keyHandle,\n\t\t\t\t   endorsementPassword,\n\t\t\t\t   keyPassword,\t\t/* used in high range only */\n\t\t\t\t   ekCertIndex,\t\t/* RSA or EC */\n\t\t\t\t   NULL, 0,\t\t/* EK nonce, can be NULL */\n\t\t\t\t   NULL,\t\t/* template */\n\t\t\t\t   &tpmtPublicOut,\t/* primary key */\n\t\t\t\t   noFlush,\n\t\t\t\t   tssUtilsVerbose);\t/* print errors */\n    }\n    /* create the EK certificate from the EK public key, using the above issuer and subject */\n    if (rc == 0) {\n\trc = createCertificate(&x509CertString,\t\t\t/* freed @3 */\n\t\t\t       &pemCertString,\t\t\t/* freed @2 */\n\t\t\t       &certLength,\n\t\t\t       &certificate,\t\t\t/* output, freed @1 */\n\t\t\t       &tpmtPublicOut,\t\t\t/* public key to be certified */\n\t\t\t       caKeyFileName,\t\t\t/* CA signing key */\n\t\t\t       issuerEntriesSize,\n\t\t\t       issuerEntries,\t\t\t/* certificate issuer */\n\t\t\t       sizeof(subjectEntries)/sizeof(char *),\n\t\t\t       subjectEntries,\t\t\t/* certificate subject */\n\t\t\t       caKeyPassword);\t\t\t/* CA signing key password */\n    }\n    /* If the NV index is not defined, define it */\n    if (rc == 0) {\n\trc = defineEKCertIndex(tssContext,\n\t\t\t       certLength,\n\t\t\t       ekCertIndex,\n\t\t\t       platformPassword);\n    }\n    /* store the EK certificate in NV */\n    if (rc == 0) {\n\trc = storeEkCertificate(tssContext,\n\t\t\t\tcertLength, certificate,\n\t\t\t\tekCertIndex,\n\t\t\t\tplatformPassword);\n    }\n    /* optionally store the certificate in DER format */\n    if ((rc == 0) && (certificateFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(certificate, certLength, certificateFilename);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    free(certificate);\t\t\t/* @1 */\n    free(pemCertString);\t\t/* @2 */\n    free(x509CertString);\t\t/* @3 */\n    return rc;\n}\n\n/* defineEKCertIndex() defines the EK certificate index if it is not already defined */\n\nstatic TPM_RC defineEKCertIndex(TSS_CONTEXT *tssContext,\n\t\t\t\tuint32_t certLength,\t\n\t\t\t\tTPMI_RH_NV_INDEX nvIndex,\n\t\t\t\tconst char *platformPassword)\n{\n    TPM_RC \t\trc = 0;\n    NV_ReadPublic_In \tnvReadPublicIn;\n    NV_ReadPublic_Out\tnvReadPublicOut;\n    NV_DefineSpace_In \tnvDefineSpaceIn;\n    \n    /* read metadata to make sure the index is there, the size is sufficient, and get the Name */\n    if (tssUtilsVerbose) printf(\"defineEKCertIndex: certificate length %u\\n\", certLength);\n    if (rc == 0) {\n\tnvReadPublicIn.nvIndex = nvIndex;\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&nvReadPublicOut,\n\t\t\t (COMMAND_PARAMETERS *)&nvReadPublicIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_ReadPublic,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    /* if already defined, check the size */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"defineEKCertIndex: defined data size %u\\n\",\n\t\t\t    nvReadPublicOut.nvPublic.nvPublic.dataSize);\n\tif (nvReadPublicOut.nvPublic.nvPublic.dataSize < certLength) {\n\t    printf(\"defineEKCertIndex: data size %u insufficient for certificate %u\\n\",\n\t\t   nvReadPublicOut.nvPublic.nvPublic.dataSize, certLength);\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    else if ((rc & 0xff) == TPM_RC_HANDLE) {\n\trc = 0;\t\t/* not an error yet, define the index for the EK certificate */\n\tnvDefineSpaceIn.authHandle = TPM_RH_PLATFORM;\n\tnvDefineSpaceIn.auth.b.size = 0;\t\t\t\t\t/* empty auth */\n\tnvDefineSpaceIn.publicInfo.nvPublic.authPolicy.t.size = 0;\t\t/* empty policy */\n\tnvDefineSpaceIn.publicInfo.nvPublic.nvIndex = nvIndex;\t/* handle of the data area */\n\tnvDefineSpaceIn.publicInfo.nvPublic.nameAlg = TPM_ALG_SHA256; \t/* name hash algorithm */\n\tnvDefineSpaceIn.publicInfo.nvPublic.attributes.val = 0;\n\t/* PC Client specification */\n\tnvDefineSpaceIn.publicInfo.nvPublic.attributes.val |= TPMA_NVA_ORDINARY;\n\tnvDefineSpaceIn.publicInfo.nvPublic.attributes.val |= TPMA_NVA_PLATFORMCREATE;\n\tnvDefineSpaceIn.publicInfo.nvPublic.attributes.val |= TPMA_NVA_AUTHREAD;\n\tnvDefineSpaceIn.publicInfo.nvPublic.attributes.val |= TPMA_NVA_NO_DA;\n\tnvDefineSpaceIn.publicInfo.nvPublic.attributes.val |= TPMA_NVA_PPWRITE;\n\t/* required for Microsoft Windows certification test */\n\tnvDefineSpaceIn.publicInfo.nvPublic.attributes.val |= TPMA_NVA_OWNERREAD; \n\tif (certLength < 1000) {\n\t    nvDefineSpaceIn.publicInfo.nvPublic.dataSize = 1000;\t\t/* minimum size */\n\t}\n\telse {\n\t    nvDefineSpaceIn.publicInfo.nvPublic.dataSize = certLength;\n\t}\n\t/* call TSS to execute the command */\n\tif (rc == 0) {\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     NULL,\n\t\t\t     (COMMAND_PARAMETERS *)&nvDefineSpaceIn,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_NV_DefineSpace,\n\t\t\t     TPM_RS_PW, platformPassword, 0,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n    }\n    if (rc != 0) {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"defineEKCertIndex: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\tprintf(\"ERROR: defineEKCertIndex: requires certificate min length %u at index %08x\\n\",\n\t       certLength, nvIndex);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n/* storeEkCertificate() writes the EK certificate at the specified NV index.  It does not define the\n   NV index.  */\n\nstatic TPM_RC storeEkCertificate(TSS_CONTEXT *tssContext,\n\t\t\t\t uint32_t certLength,\n\t\t\t\t unsigned char *certificate,\t\n\t\t\t\t TPMI_RH_NV_INDEX nvIndex,\n\t\t\t\t const char *platformPassword)\n{\n    TPM_RC \t\trc = 0;\n    NV_Write_In \tnvWriteIn;\n    uint32_t \t\tnvBufferMax;\t\t/* max write in one chunk */\n    uint16_t \t\tbytesWritten;\t\t/* bytes written so far */\n    int\t\t\tdone = FALSE;\n\n    if (rc == 0) {\n\trc = readNvBufferMax(tssContext,\n\t\t\t     &nvBufferMax);\n    }    \n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"storeEkCertificate: writing %u bytes to %08x\\n\",\n\t\t\t    certLength, nvIndex);\n\tnvWriteIn.authHandle = TPM_RH_PLATFORM;  \n\tnvWriteIn.nvIndex = nvIndex;\n\tnvWriteIn.offset = 0;\n\tbytesWritten = 0;\t/* bytes written so far */\n    }\n    while ((rc == 0) && !done) {\n\tuint16_t writeBytes;\t\t/* bytes to write in this pass */\n\tif (rc == 0) {\n\t    nvWriteIn.offset = bytesWritten;\n\t    if ((uint32_t)(certLength - bytesWritten) < nvBufferMax) {\n\t\twriteBytes = certLength - bytesWritten;\t/* last chunk */\n\t    }\n\t    else {\n\t\twriteBytes = nvBufferMax;\t/* next chunk */\n\t    }\n\t    rc = TSS_TPM2B_Create(&nvWriteIn.data.b, certificate + bytesWritten, writeBytes,\n\t\t\t\t  sizeof(nvWriteIn.data.t.buffer));\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     NULL,\n\t\t\t     (COMMAND_PARAMETERS *)&nvWriteIn,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_NV_Write,\n\t\t\t     TPM_RS_PW, platformPassword, 0,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n\tif (rc == 0) {\n\t    bytesWritten += writeBytes;\n\t    if (bytesWritten == certLength) {\n\t\tdone = TRUE;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"storeEkCertificate: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"storeEkCertificate: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\tif (rc == TSS_RC_FILE_OPEN) {\n\t    printf(\"Possible cause: missing nvreadpublic before nvwrite\\n\");\n\t}\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"createekcert\\n\");\n    printf(\"\\n\");\n    printf(\"Provisions an EK certificate using the default IWG template\\n\");\n    printf(\"E.g.,\\n\");\n    printf(\"\\n\");\n    printf(\"Usage: createekcert -rsa 2048     -cakey cakey.pem    -capwd rrrr -v\\n\");\n    printf(\"or:    createekcert -ecc nistp256 -cakey cakeyecc.pem -capwd rrrr -caalg ec -v\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwdp\\t\\tplatform    hierarchy password (default empty)]\\n\");\n    printf(\"\\t[-pwde\\t\\tendorsement hierarchy password (default empty)]\\n\");\n    printf(\"\\t[-pwdk\\t\\tpassword for endorsement key (default empty)]\\n\");\n    printf(\"\\t-cakey\\t\\tCA PEM key file name\\n\");\n    printf(\"\\t[-capwd\\t\\tCA PEM key password (default empty)]\\n\");\n    printf(\"\\t[-caalg\\t\\tCA key algorithm (rsa or ecc) (default rsa)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-high\\t\\tUse the NV high range.  Specify before algorithm]\\n\");\n    printf(\"\\t-rsa keybits\\n\");\n    printf(\"\\t\\t2048\\n\");\n    printf(\"\\t\\t3072\\n\");\n    printf(\"\\t-ecc curve\\n\");\n    printf(\"\\t\\tnistp256\\n\");\n    printf(\"\\t\\tnistp384\\n\");\n    printf(\"\\t\\tnistp521\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-noflush\\tdo not flush the primary key]\\n\");\n    printf(\"\\t[-of\\t\\tDER certificate output file name]\\n\");\n    printf(\"\\n\");\n    printf(\"Currently:\\n\");\n    printf(\"\\n\");\n    printf(\"\\tCertificate issuer, subject, and validity are hard coded.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/createloaded.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Create Loaded\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\n#include \"objecttemplates.h\"\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    CreateLoaded_In \t\tin;\n    CreateLoaded_Out\t\tout;\n    TPMT_PUBLIC\t\t\tpublicArea;\n    TPMI_DH_OBJECT\t\tparentHandle = 0;\n    TPMA_OBJECT\t\t\taddObjectAttributes;\n    TPMA_OBJECT\t\t\tdeleteObjectAttributes;\n    int \t\t\tderived = FALSE;\t/* parent is derivation parent */\n    int\t\t\t\tkeyType = 0;\n    uint32_t \t\t\tkeyTypeSpecified = 0;\n    int\t\t\t\trev116 = FALSE;\n    TPMI_ALG_PUBLIC \t\talgPublic = TPM_ALG_RSA;\n    TPMI_RSA_KEY_BITS \t\tkeyBits = 2048;\n    TPMI_ECC_CURVE\t\tcurveID = TPM_ECC_NONE;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_ALG_HASH\t\tnalg = TPM_ALG_SHA256;\n    const char\t\t\t*policyFilename = NULL;\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*privateKeyFilename = NULL;\n    const char\t\t\t*pemFilename = NULL;\n    const char \t\t\t*dataFilename = NULL;\n    const char\t\t\t*keyPassword = NULL; \n    const char\t\t\t*parentPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    addObjectAttributes.val = 0;\n    addObjectAttributes.val |= TPMA_OBJECT_NODA;\n    deleteObjectAttributes.val = 0;\n \t\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &parentHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-bl\") == 0) {\n\t    keyType = TYPE_BL;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-den\") == 0) {\n\t    keyType = TYPE_DEN;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-deo\") == 0) {\n\t    keyType = TYPE_DEO;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dee\") == 0) {\n\t    keyType = TYPE_DEE;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-des\") == 0) {\n\t    keyType = TYPE_DES;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-st\") == 0) {\n\t    keyType = TYPE_ST;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-si\") == 0) {\n\t    keyType = TYPE_SI;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-sir\") == 0) {\n\t    keyType = TYPE_SIR;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-kh\") == 0) {\n\t    keyType = TYPE_KH;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-khr\") == 0) {\n\t    keyType = TYPE_KHR;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dp\") == 0) {\n\t    keyType = TYPE_DP;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-gp\") == 0) {\n\t    keyType = TYPE_GP;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-116\") == 0) {\n\t    rev116 = TRUE;\n\t}\n\telse if (strcmp(argv[i], \"-der\") == 0) {\n\t    derived = TRUE;\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    algPublic = TPM_ALG_RSA;\n\t    /* if next argument is keysize */\n\t    if (((i + 1) < argc) && (argv[i+1][0] != '-')) {\n\t\ti++;\n\t\tsscanf(argv[i],\"%hu\", &keyBits);\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    algPublic = TPM_ALG_ECC;\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"bnp256\") == 0) {\n\t\t    curveID = TPM_ECC_BN_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp256\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp384\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -ecc\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-ecc option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-kt\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (i < argc) {\n\t\t    if (strcmp(argv[i], \"f\") == 0) {\n\t\t\taddObjectAttributes.val |= TPMA_OBJECT_FIXEDTPM;\n\t\t    }\n\t\t    else if (strcmp(argv[i], \"p\") == 0) {\n\t\t\taddObjectAttributes.val |= TPMA_OBJECT_FIXEDPARENT;\n\t\t    }\n\t\t    else if (strcmp(argv[i], \"nf\") == 0) {\n\t\t\tdeleteObjectAttributes.val |= TPMA_OBJECT_FIXEDTPM;\n\t\t    }\n\t\t    else if (strcmp(argv[i], \"np\")  == 0) {\n\t\t\tdeleteObjectAttributes.val |= TPMA_OBJECT_FIXEDPARENT;\n\t\t    }\n\t\t    else if (strcmp(argv[i], \"ed\")  == 0) {\n\t\t\taddObjectAttributes.val |= TPMA_OBJECT_ENCRYPTEDDUPLICATION;\n\t\t    }\n\t\t    else {\n\t\t\tprintf(\"Bad parameter %c for -kt\\n\", argv[i][0]);\n\t\t\tprintUsage();\n\t\t    }\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -kt\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-uwa\") == 0) {\n\t    deleteObjectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\t}\n\telse if (strcmp(argv[i], \"-da\") == 0) {\n\t    addObjectAttributes.val &= ~TPMA_OBJECT_NODA;\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    nalg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    nalg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    nalg = TPM_ALG_SHA384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -nalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-nalg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tprivateKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opr option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opem\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opem option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pol\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pol option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (parentHandle == 0) {\n\tprintf(\"Missing handle parameter -hp\\n\");\n\tprintUsage();\n    }\n    if (keyTypeSpecified != 1) {\n\tprintf(\"Missing key attributes\\n\");\n\tprintUsage();\n    }\n    switch (keyType) {\n      case TYPE_BL:\n\tif (dataFilename == NULL) {\n\t    printf(\"-bl needs -if (sealed data object needs data to seal)\\n\");\n\t    printUsage();\n\t}\n\tbreak;\n      case TYPE_ST:\n      case TYPE_DEN:\n      case TYPE_DEO:\n      case TYPE_DEE:\n      case TYPE_SI:\n      case TYPE_SIR:\n      case TYPE_GP:\n\tif (dataFilename != NULL) {\n\t    printf(\"asymmetric key cannot have -if (sensitive data)\\n\");\n\t    printUsage();\n\t}\n      case TYPE_DES:\n      case TYPE_KH:\n      case TYPE_KHR:\n      case TYPE_DP:\n\t/* inSensitive optional for symmetric keys */\n\tbreak;\n    }\n    if (rc == 0) {\n\tin.parentHandle = parentHandle;\n    }\n    /* Table 134 - Definition of TPM2B_SENSITIVE_CREATE inSensitive */\n    if (rc == 0) {\n\t/* Table 133 - Definition of TPMS_SENSITIVE_CREATE Structure <IN>sensitive  */\n\t/* Table 75 - Definition of Types for TPM2B_AUTH userAuth */\n\tif (keyPassword == NULL) {\n\t    in.inSensitive.sensitive.userAuth.t.size = 0;\n\t}\n\telse {\n\t    rc = TSS_TPM2B_StringCopy(&in.inSensitive.sensitive.userAuth.b,\n\t\t\t\t      keyPassword,\n\t\t\t\t      sizeof(in.inSensitive.sensitive.userAuth.t.buffer));\n\t}\n    }\n    if (rc == 0) {\n\t/* Table 132 - Definition of TPM2B_SENSITIVE_DATA Structure data */\n\tif (dataFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.inSensitive.sensitive.data.b,\n\t\t\t\t sizeof(in.inSensitive.sensitive.data.t.buffer),\n\t\t\t\t dataFilename);\n\t}\n\telse {\n\t    in.inSensitive.sensitive.data.t.size = 0;\n\t}\n    }\n    /* TPM2B_PUBLIC */\n    if (rc == 0) {\n\tswitch (keyType) {\n\t  case TYPE_BL:\n\t    rc = blPublicTemplate(&publicArea,\n\t\t\t\t  addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t  nalg,\n\t\t\t\t  policyFilename);\n\t    break;\n\t  case TYPE_ST:\n\t  case TYPE_DEN:\n\t  case TYPE_DEO:\n\t  case TYPE_DEE:\n\t  case TYPE_SI:\n\t  case TYPE_SIR:\n\t  case TYPE_GP:\n\t    rc = asymPublicTemplate(&publicArea,\n\t\t\t\t    addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t    keyType, algPublic, keyBits, curveID, nalg, halg,\n\t\t\t\t    policyFilename);\n\t    break;\n\t  case TYPE_DES:\n\t    rc = symmetricCipherTemplate(&publicArea,\n\t\t\t\t\t addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t\t nalg, rev116,\n\t\t\t\t\t policyFilename);\n\t    break;\n\t  case TYPE_KH:\n\t  case TYPE_KHR:\n\t    rc = keyedHashPublicTemplate(&publicArea,\n\t\t\t\t\t addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t\t keyType, nalg, halg,\n\t\t\t\t\t policyFilename);\n\t    break;\n\t  case TYPE_DP:\n\t    rc = derivationParentPublicTemplate(&publicArea,\n\t\t\t\t\t\taddObjectAttributes, deleteObjectAttributes,\n\t\t\t\t\t\tnalg, halg,\n\t\t\t\t\t\tpolicyFilename);\n\t} \n    }\n    /* marshal the TPMT_PUBLIC into the TPM2B_TEMPLATE */\n    if (rc == 0) {\n\tuint16_t written = 0;\n\tuint32_t size = sizeof(in.inPublic.t.buffer);\n\tuint8_t *buffer = in.inPublic.t.buffer;\n\tif (!derived) {\t\t/* not derivation parent */\n\t    rc = TSS_TPMT_PUBLIC_Marshalu(&publicArea, &written, &buffer, &size);\n\t}\n\telse {\t\t\t/* derivation parent */\n\t    /* The API changed from rev 142 to 146.  This is the 146 API.  It is unlikely that any\n\t       138 HW TPM will implement the 142 errata, but care must be taken to use a current SW\n\t       TPM. */\n\t    /* derived key has TPMS_CONTEXT parameter */\n\t    publicArea.unique.derive.label.t.size = 0;\n\t    publicArea.unique.derive.context.t.size = 0;\n\t    /* sensitiveDataOrigin has to be CLEAR in a derived object */\t\n\t    publicArea.objectAttributes.val &= ~TPMA_OBJECT_SENSITIVEDATAORIGIN;\n\t    rc = TSS_TPMT_PUBLIC_D_Marshalu(&publicArea, &written, &buffer, &size);\n\t}\n\tin.inPublic.t.size = written;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_CreateLoaded,\n\t\t\t sessionHandle0, parentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* save the private key */\n    if ((rc == 0) && (privateKeyFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.outPrivate,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PRIVATE_Marshalu,\n\t\t\t\t     privateKeyFilename);\n    }\n    /* save the public key */\n    if ((rc == 0) && (publicKeyFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.outPublic,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PUBLIC_Marshalu,\n\t\t\t\t     publicKeyFilename);\n    }\n    /* save the optional PEM public key */\n    if ((rc == 0) && (pemFilename != NULL)) {\n\trc = convertPublicToPEM(&out.outPublic,\n\t\t\t\tpemFilename);\n    }\n    if (rc == 0) {\n\tprintf(\"Handle %08x\\n\", out.objectHandle);\n\tif (tssUtilsVerbose) printf(\"createloaded: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"createloaded: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"createloaded\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_CreateLoaded\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hp parent handle (can be hierarchy)\\n\");\n    printf(\"\\t\\t40000001 Owner\\n\");\n    printf(\"\\t\\t4000000c Platform\\n\");\n    printf(\"\\t\\t4000000b Endorsement\\n\");\n    printf(\"\\n\");\n    printUsageTemplate();\n    printf(\"\\n\");\n    printf(\"\\t[-der\\tobject's parent is a derivation parent]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-pwdp\\tpassword for parent key (default empty)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-opu\\tpublic key file name (default do not save)]\\n\");\n    printf(\"\\t[-opr\\tprivate key file name (default do not save)]\\n\");\n    printf(\"\\t[-opem\\tpublic key PEM format file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/createprimary.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Create Primary\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2023.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n#include \"objecttemplates.h\"\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    CreatePrimary_In \t\tin;\n    CreatePrimary_Out \t\tout;\n    char \t\t\thierarchyChar = 'n';\n    TPMI_RH_HIERARCHY\t\tprimaryHandle = TPM_RH_NULL;\n    TPMA_OBJECT\t\t\taddObjectAttributes;\n    TPMA_OBJECT\t\t\tdeleteObjectAttributes;\n    int\t\t\t\tkeyType = TYPE_ST;\n    uint32_t \t\t\tkeyTypeSpecified = 0;\n    int\t\t\t\trev116 = FALSE;\n    const char \t\t\t*uniqueFilename = NULL;\n    TPMI_ALG_PUBLIC \t\talgPublic = TPM_ALG_RSA;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_ALG_HASH\t\tnalg = TPM_ALG_SHA256;\n    TPMI_RSA_KEY_BITS \t\tkeyBits = 2048;\n    TPMI_ECC_CURVE\t\tcurveID = TPM_ECC_NONE;\n    const char\t\t\t*policyFilename = NULL;\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*pemFilename = NULL;\n    const char\t\t\t*ticketFilename = NULL;\n    const char\t\t\t*creationHashFilename = NULL;\n    const char\t\t\t*creationDataFilename = NULL;\n    const char \t\t\t*dataFilename = NULL;\n    const char\t\t\t*keyPassword = NULL; \n    const char\t\t\t*parentPassword = NULL; \n    const char\t\t\t*parentPasswordFilename = NULL; \n    const char\t\t\t*parentPasswordPtr = NULL; \n    uint8_t\t\t\t*parentPasswordBuffer = NULL;\t\t/* for the free */\n    size_t \t\t\tparentPasswordLength = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    addObjectAttributes.val = 0;\n    addObjectAttributes.val |= TPMA_OBJECT_NODA;\n    addObjectAttributes.val |= TPMA_OBJECT_FIXEDTPM;\n    addObjectAttributes.val |= TPMA_OBJECT_FIXEDPARENT;\n    deleteObjectAttributes.val = 0;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-bl\") == 0) {\n\t    keyType = TYPE_BL;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-den\") == 0) {\n\t    keyType = TYPE_DEN;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-deo\") == 0) {\n\t    keyType = TYPE_DEO;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dee\") == 0) {\n\t    keyType = TYPE_DEE;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-des\") == 0) {\n\t    keyType = TYPE_DES;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-st\") == 0) {\n\t    keyType = TYPE_ST;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-si\") == 0) {\n\t    keyType = TYPE_SI;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-sir\") == 0) {\n\t    keyType = TYPE_SIR;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dau\") == 0) {\n\t    keyType = TYPE_DAA;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dar\") == 0) {\n\t    keyType = TYPE_DAAR;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-kh\") == 0) {\n\t    keyType = TYPE_KH;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-khr\") == 0) {\n\t    keyType = TYPE_KHR;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-dp\") == 0) {\n\t    keyType = TYPE_DP;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-gp\") == 0) {\n\t    keyType = TYPE_GP;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-116\") == 0) {\n\t    rev116 = TRUE;\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    /* if next argument is keysize */\n\t    algPublic = TPM_ALG_RSA;\n\t    if (((i + 1) < argc) && (argv[i+1][0] != '-')) {\n\t\ti++;\n\t\tsscanf(argv[i],\"%hu\", &keyBits);\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    algPublic = TPM_ALG_ECC;\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"bnp256\") == 0) {\n\t\t    curveID = TPM_ECC_BN_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp256\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp384\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -ecc\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-ecc option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-kt\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i], \"f\") == 0) {\n\t\t    addObjectAttributes.val |= TPMA_OBJECT_FIXEDTPM;\n   \t\t}\n\t\telse if (strcmp(argv[i], \"p\") == 0) {\n\t\t    addObjectAttributes.val |= TPMA_OBJECT_FIXEDPARENT;\n\t\t}\n\t\telse if (strcmp(argv[i], \"nf\") == 0) {\n\t\t    deleteObjectAttributes.val |= TPMA_OBJECT_FIXEDTPM;\n\t\t}\n\t\telse if (strcmp(argv[i], \"np\")  == 0) {\n\t\t    deleteObjectAttributes.val |= TPMA_OBJECT_FIXEDPARENT;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ed\")  == 0) {\n\t\t    addObjectAttributes.val |= TPMA_OBJECT_ENCRYPTEDDUPLICATION;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -kt\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -kt\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-uwa\") == 0) {\n\t    deleteObjectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\t}\n\telse if (strcmp(argv[i], \"-da\") == 0) {\n\t    addObjectAttributes.val &= ~TPMA_OBJECT_NODA;\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    nalg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    nalg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    nalg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    nalg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -nalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-nalg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdpi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPasswordFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdpi option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-iu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tuniqueFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-iu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opem\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opem option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ch\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcreationHashFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ch option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-cd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcreationDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-cd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pol\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pol option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (keyTypeSpecified > 1) {\n\tprintf(\"Too many key attributes\\n\");\n\tprintUsage();\n    }\n    switch (keyType) {\n      case TYPE_BL:\n\tif (dataFilename == NULL) {\n\t    printf(\"-bl needs -if (sealed data object needs data to seal)\\n\");\n\t    printUsage();\n\t}\n\tbreak;\n      case TYPE_DAA:\n      case TYPE_DAAR:\n\tif (algPublic != TPM_ALG_ECC) {\n\t    printf(\"-dau and -dar need -ecc\\n\");\n \t    printUsage();\n\t}\n\tif (dataFilename != NULL) {\n\t    printf(\"asymmetric key cannot have -if (sensitive data)\\n\");\n\t    printUsage();\n\t}\n\tbreak;\n      case TYPE_ST:\n      case TYPE_DEN:\n      case TYPE_DEO:\n      case TYPE_DEE:\n      case TYPE_SI:\n      case TYPE_SIR:\n      case TYPE_GP:\n\tif (dataFilename != NULL) {\n\t    printf(\"asymmetric key cannot have -if (sensitive data)\\n\");\n\t    printUsage();\n\t}\n\tbreak;\n      case TYPE_DES:\n      case TYPE_KH:\n      case TYPE_KHR:\n      case TYPE_DP:\n\t/* inSensitive optional for symmetric keys */\n\tbreak;\n    }\n    if (rc == 0) {\n\tif ((parentPassword != NULL) && (parentPasswordFilename != NULL)) {\n\t    printf(\"Cannot specify both -pwdp and -pwdpi\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\t/* command auth from string */\n\tif (parentPassword != NULL) {\n\t    parentPasswordPtr = parentPassword; \n\t}\n\t/* command parent from file */\n\telse if (parentPasswordFilename != NULL) {\n\t    if (rc == 0) {\n\t\t/* must be freed by caller */\n\t\trc = TSS_File_ReadBinaryFile(&parentPasswordBuffer,\t/* freed @1 */\n\t\t\t\t\t     &parentPasswordLength,\n\t\t\t\t\t     parentPasswordFilename);\n\t    }\n\t    if (rc == 0) {\n\t\tif ((parentPasswordLength > sizeof(TPMU_HA)) ||\n\t\t    (parentPasswordLength == 0) ||\n\t\t    (parentPasswordBuffer[parentPasswordLength-1] != '\\0')) {\n\t\t    printf(\"-pwdpi file must be nul terminated\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    if (rc == 0) {\n\t\tparentPasswordPtr = (const char *)parentPasswordBuffer;\n\t    }\n\t}\n\t/* no command parent specified */\n\telse {\n\t    parentPasswordPtr = NULL;\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (hierarchyChar == 'e') {\n\t    primaryHandle = TPM_RH_ENDORSEMENT;\n\t}\n\telse if (hierarchyChar == 'o') {\n\t    primaryHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    primaryHandle = TPM_RH_PLATFORM;\n\t}\n\telse if (hierarchyChar == 'n') {\n\t    primaryHandle = TPM_RH_NULL;\n\t}\n\telse {\n\t    printf(\"Bad parameter %c for -hi\\n\", hierarchyChar);\n\t    printUsage();\n\t}\n\tin.primaryHandle = primaryHandle;\n    }\n    /* Table 134 - TPM2B_SENSITIVE_CREATE inSensitive */\n    if (rc == 0) {\n\t/* Table 133 - TPMS_SENSITIVE_CREATE */\n\t{\n\t    if (keyPassword == NULL) {\n\t\tin.inSensitive.sensitive.userAuth.t.size = 0;\n\t    }\n\t    else {\n\t\trc = TSS_TPM2B_StringCopy(&in.inSensitive.sensitive.userAuth.b,\n\t\t\t\t\t  keyPassword,\n\t\t\t\t\t  sizeof(in.inSensitive.sensitive.userAuth.t.buffer));\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\t/* Table 132 - Definition of TPM2B_SENSITIVE_DATA Structure data */\n\tif (dataFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.inSensitive.sensitive.data.b,\n\t\t\t\t sizeof(in.inSensitive.sensitive.data.t.buffer),\n\t\t\t\t dataFilename);\n\t}\n\telse {\n\t    in.inSensitive.sensitive.data.t.size = 0;\n\t}\n    }\n    /* Table 185 - TPM2B_PUBLIC\tinPublic */\n    if (rc == 0) {\n\tswitch (keyType) {\n\t  case TYPE_BL:\n\t    rc = blPublicTemplate(&in.inPublic.publicArea,\n\t\t\t\t  addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t  nalg,\n\t\t\t\t  policyFilename);\n\t    break;\n\t  case TYPE_ST:\n\t  case TYPE_DAA:\n\t  case TYPE_DAAR:\n\t  case TYPE_DEN:\n\t  case TYPE_DEO:\n\t  case TYPE_DEE:\n\t  case TYPE_SI:\n\t  case TYPE_SIR:\n\t  case TYPE_GP:\n\t    rc = asymPublicTemplate(&in.inPublic.publicArea,\n\t\t\t\t    addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t    keyType, algPublic, keyBits, curveID, nalg, halg,\n\t\t\t\t    policyFilename);\n\t    break;\n\t  case TYPE_DES:\n\t    rc = symmetricCipherTemplate(&in.inPublic.publicArea,\n\t\t\t\t\t addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t\t nalg, rev116,\n\t\t\t\t\t policyFilename);\n\t    break;\n\t  case TYPE_KH:\n\t  case TYPE_KHR:\n\t    rc = keyedHashPublicTemplate(&in.inPublic.publicArea,\n\t\t\t\t\t addObjectAttributes, deleteObjectAttributes,\n\t\t\t\t\t keyType, nalg, halg,\n\t\t\t\t\t policyFilename);\n\t    break;\n\t  case TYPE_DP:\n\t    rc = derivationParentPublicTemplate(&in.inPublic.publicArea,\n\t\t\t\t\t\taddObjectAttributes, deleteObjectAttributes,\n\t\t\t\t\t\tnalg, halg,\n\t\t\t\t\t\tpolicyFilename);\n\t    break;\n\t}\n    }\n    /* Table 177 - TPMU_PUBLIC_ID unique */\n    /* Table 158 - TPM2B_PUBLIC_KEY_RSA rsa */\n    if (rc == 0) {\n\tif (uniqueFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.inPublic.publicArea.unique.rsa.b,\n\t\t\t\t sizeof(in.inPublic.publicArea.unique.rsa.t.buffer),\n\t\t\t\t uniqueFilename);\n\t}\n\telse {\n\t    in.inPublic.publicArea.unique.rsa.t.size = 0;\n\t}\n    }\n    /* TPM2B_DATA outsideInfo */\n    if (rc == 0) {\n\tin.outsideInfo.t.size = 0;\n    }\n    /* Table 102 - TPML_PCR_SELECTION */\n    /* TPML_PCR_SELECTION\tcreationPCR */\n    if (rc == 0) {\n\tin.creationPCR.count = 0;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_CreatePrimary,\n\t\t\t sessionHandle0, parentPasswordPtr, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /*\n      validate the creation data\n    */\n    {\n\tuint16_t\twritten = 0;\n\tuint8_t\t\t*buffer = NULL;\t\t/* for the free */\n\tuint32_t \tsizeInBytes;\n\tTPMT_HA\t\tdigest;\n\n\t/* get the digest size from the Name algorithm */\n\tif (rc == 0) {\n\t    sizeInBytes = TSS_GetDigestSize(nalg);\n\t    if (out.creationHash.b.size != sizeInBytes) {\n\t\tprintf(\"createprimary: failed, \"\n\t\t       \"creationHash size %u incompatible with name algorithm %04x\\n\",\n\t\t       out.creationHash.b.size, nalg);\n\t\trc = EXIT_FAILURE;\n\t    }\n\t}\n\t/* re-marshal the output structure */\n\tif (rc == 0) {\n\t    rc = TSS_Structure_Marshal(&buffer,\t/* freed @1 */\n\t\t\t\t       &written,\n\t\t\t\t       &out.creationData.creationData,\n\t\t\t\t       (MarshalFunction_t)TSS_TPMS_CREATION_DATA_Marshalu);\n\t}\n\t/* recalculate the creationHash from creationData */\n\tif (rc == 0) {\n\t    digest.hashAlg = nalg;\t\t\t/* Name digest algorithm */\n\t    rc = TSS_Hash_Generate(&digest,\t\n\t\t\t\t   written, buffer,\n\t\t\t\t   0, NULL);\n\t}\n\t/* compare the digest to creation hash */\n\tif (rc == 0) {\n\t    int irc;\n\t    irc = memcmp((uint8_t *)&digest.digest, &out.creationHash.b.buffer, sizeInBytes);\n\t    if (irc != 0) {\n\t\tprintf(\"createprimary: failed, creationData hash does not match creationHash\\n\");\n\t\trc = EXIT_FAILURE;\n\t    }\n\t}\n\tfree(buffer);\t/* @1 */\n    }\n    /* save the public key */\n    if ((rc == 0) && (publicKeyFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.outPublic,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PUBLIC_Marshalu,\n\t\t\t\t     publicKeyFilename);\n    }\n    /* save the optional PEM public key */\n    if ((rc == 0) && (pemFilename != NULL)) {\n\trc = convertPublicToPEM(&out.outPublic,\n\t\t\t\tpemFilename);\n    }\n    /* save the optional creation ticket */\n    if ((rc == 0) && (ticketFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.creationTicket,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_TK_CREATION_Marshalu,\n\t\t\t\t     ticketFilename);\n    }\n    /* save the optional creation hash */\n    if ((rc == 0) && (creationHashFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.creationHash.b.buffer,\n\t\t\t\t      out.creationHash.b.size,\n\t\t\t\t      creationHashFilename);\n    }\n    /* save the optional creation data */\n    if ((rc == 0) && (creationDataFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.creationData.creationData,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMS_CREATION_DATA_Marshalu,\n\t\t\t\t     creationDataFilename);\n    }\n    /* regression test sanity check */\n    if ((rc == 0) && (creationDataFilename != NULL)) {\n\tTPMS_CREATION_DATA creationDataTest;\n\trc = TSS_File_ReadStructure(&creationDataTest,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPMS_CREATION_DATA_Unmarshalu,\n\t\t\t\t    creationDataFilename);\n    }\n    if (rc == 0) {\n\tprintf(\"Handle %08x\\n\", out.objectHandle);\n\tif (algPublic == TPM_ALG_RSA) {\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"createprimary: public modulus\",\n\t\t\t\t      out.outPublic.publicArea.unique.rsa.t.buffer,\n\t\t\t\t      out.outPublic.publicArea.unique.rsa.t.size);\n\t}\n\telse if (algPublic == TPM_ALG_ECC) {\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"createprimary: public point X\",\n\t\t\t\t      out.outPublic.publicArea.unique.ecc.x.t.buffer,\n\t\t\t\t      out.outPublic.publicArea.unique.ecc.x.t.size);\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"createprimary: public point Y\",\n\t\t\t\t      out.outPublic.publicArea.unique.ecc.y.t.buffer,\n\t\t\t\t      out.outPublic.publicArea.unique.ecc.y.t.size);\n\t}\n\tif (tssUtilsVerbose) TSS_TPMS_CREATION_DATA_Print(&out.creationData.creationData, 2);\n\tif (tssUtilsVerbose) printf(\"createprimary: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"createprimary: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(parentPasswordBuffer);\t\t/* @1 */\n    parentPasswordBuffer = NULL;\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"createprimary creates a primary storage key\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_CreatePrimary\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hi\\t\\thierarchy (e, o, p, n) (default null)]\\n\");\n    printf(\"\\t[-pwdp\\t\\tpassword for hierarchy (default empty)]\\n\");\n    printf(\"\\t[-pwdpi\\t\\tpassword file name for hierarchy (default empty)]\\n\");\n    printf(\"\\t[-pwdk\\t\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-iu\\t\\tinPublic unique field file (default none)]\\n\");\n    printf(\"\\t[-opu\\t\\tpublic key file name (default do not save)]\\n\");\n    printf(\"\\t[-opem\\t\\tpublic key PEM format file name (default do not save)]\\n\");\n    printf(\"\\t[-tk\\t\\toutput ticket file name]\\n\");\n    printf(\"\\t[-ch\\t\\toutput creation hash file name]\\n\");\n    printf(\"\\t[-cd\\t\\toutput creation data file name]\\n\");\n    printf(\"\\n\");\n    printUsageTemplate();\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/cryptoutils.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tOpenSSL Crypto Utilities\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2018 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* These functions are worthwhile sample code that probably (judgment call) do not belong in the TSS\n   library.\n\n   They abstract out crypto library functions.\n\n   They show how to convert public or private EC or RSA among PEM format <-> EVP format <-> EC_KEY\n   or RSA format <-> binary arrays <-> TPM format TPM2B_PRIVATE, TPM2B_SENSITIVE, TPM2B_PUBLIC\n   usable for loadexternal or import.\n\n   There are functions to convert public keys from TPM <-> RSA, ECC <-> PEM, and to verify a TPM\n   signature using a PEM format public key.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <limits.h>\n\n#ifndef TPM_TSS_NORSA\n#include <openssl/rsa.h>\n#endif /* TPM_TSS_NORSA */\n#include <openssl/objects.h>\n#include <openssl/evp.h>\n#include <openssl/pem.h>\n#if OPENSSL_VERSION_NUMBER >= 0x30000000\n#include <openssl/core_names.h>\n#include <openssl/param_build.h>\n#endif\n\n#ifndef TPM_TSS_NOECC\n#include <openssl/ec.h>\n#endif\n\n#ifndef TPM_TSS_NOFILE\n#include <ibmtss/tssfile.h>\n#endif\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/Implementation.h>\n\nTPM_RC TSS_Hash_GetMd(const EVP_MD **md,\n\t\t      TPMI_ALG_HASH hashAlg);\n\n#include \"objecttemplates.h\"\n#include \"cryptoutils.h\"\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\nstatic TPM_RC getEcModulusBytes(int\t*modulusBytes,\n\t\t\t\tint\t*pointBytes,\n\t\t\t\tTPMI_ECC_CURVE curveID);\nstatic TPM_RC getEcNid(int\t\t*nid,\n\t\t       TPMI_ECC_CURVE \tcurveID);\n#if OPENSSL_VERSION_NUMBER < 0x30000000\nstatic TPM_RC getEcCurve(TPMI_ECC_CURVE *curveID,\n\t\t\t int \t\t*privateKeyBytes,\n\t\t\t const EC_KEY \t*ecKey);\n#else\nstatic TPM_RC getEcCurveString(const char **curveString,\n\t\t\t       int nid);\nstatic TPM_RC getEccKeyParts(uint8_t **priv,\n\t\t\t     int *privLen,\n\t\t\t     uint8_t **pub,\n\t\t\t     int *pubLen,\n\t\t\t     const EVP_PKEY *eccKey);\nstatic TPM_RC getEcCurve(TPMI_ECC_CURVE *curveID,\n\t\t\t int \t\t*privateKeyBytes,\n\t\t\t const EVP_PKEY *ecKey);\n#endif\n\n\n#endif /* TPM_TSS_NOECC */\n#endif /* TPM_TPM20 */\n\n/* verbose tracing flag shared by command line utilities */\n\nint tssUtilsVerbose;\n\n/* openssl compatibility functions, during the transition from 1.0.1, 1.0.2, 1.1.0, 1.1.1.  Some\n   structures were made opaque, with gettters and setters.  Some parameters were made const.  Some\n   function names changed. */\n\n/* Some functions add const to parameters as of openssl 1.1.0 */\n\n/* These functions are only required for OpenSSL 1.0.  OpenSSL 1.1 has them, and the structures are\n   opaque. */\n\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n\nint ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)\n{\n    if (r == NULL || s == NULL)\n\treturn 0;\n    BN_clear_free(sig->r);\n    BN_clear_free(sig->s);\n    sig->r = r;\n    sig->s = s;\n    return 1;\n}\n\nvoid ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)\n{\n    if (pr != NULL) {\n\t*pr = sig->r;\n    }\n    if (ps != NULL) {\n\t*ps = sig->s;\n    }\n    return;\n}\n\nconst X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x)\n{\n    return x->cert_info->signature;\n}\n\nvoid RSA_get0_key(const RSA *rsaKey,\n\t\t  const BIGNUM **n,\n\t\t  const BIGNUM **e,\n\t\t  const BIGNUM **d)\n{\n    if (n != NULL) {\n\t*n = rsaKey->n;\n    }\n    if (e != NULL) {\n\t*e = rsaKey->e;\n    }\n    if (d != NULL) {\n\t*d = rsaKey->d;\n    }\n    return;\n}\n\nvoid RSA_get0_factors(const RSA *rsaKey,\n\t\t      const BIGNUM **p,\n\t\t      const BIGNUM **q)\n{\n    if (p != NULL) {\n\t*p = rsaKey->p;\n    }\n    if (q != NULL) {\n\t*q = rsaKey->q;\n    }\n    return;\n}\n\nstatic int ossl_x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm);\n\nint X509_set1_notBefore(X509 *x, const ASN1_TIME *tm)\n{\n    if (x == NULL)\n        return 0;\n    return ossl_x509_set1_time(&x->cert_info->validity->notBefore, tm);\n}\n\nint X509_set1_notAfter(X509 *x, const ASN1_TIME *tm)\n{\n    if (x == NULL)\n        return 0;\n    return ossl_x509_set1_time(&x->cert_info->validity->notAfter, tm);\n}\n\nstatic int ossl_x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm)\n{\n    ASN1_TIME *in;\n    in = *ptm;\n    if (in != tm) {\n        in = ASN1_STRING_dup(tm);\n        if (in != NULL) {\n            ASN1_TIME_free(*ptm);\n            *ptm = in;\n        }\n    }\n    return (in != NULL);\n}\n\n#endif\t/* pre openssl 1.1 */\n\n/* These functions are only required for OpenSSL 1.0.1 OpenSSL 1.0.2 has them, and the structures\n   are opaque.   In 1.1.0, the parameters became const.  */\n\n#if OPENSSL_VERSION_NUMBER < 0x10002000\n\nvoid X509_get0_signature(OSSLCONST ASN1_BIT_STRING **psig,\n                         OSSLCONST X509_ALGOR **palg, const X509 *x)\n{\n    *psig = x->signature;\n    *palg = x->sig_alg;\n    return;\n}\n\n#endif\t/* pre openssl 1.0.2 */\n\n#ifndef TPM_TSS_NOFILE\n\n/* getCryptoLibrary() returns a string indicating the underlying crypto library.\n\n   It can be used for programs that must account for library differences.\n*/\n\nvoid getCryptoLibrary(const char **name)\n{\n    *name = \"openssl\";\n    return;\n}\n    \n/* convertPemToEvpPrivKey() converts a PEM key file to an openssl EVP_PKEY key pair */\n\nTPM_RC convertPemToEvpPrivKey(EVP_PKEY **evpPkey,\t\t/* freed by caller */\n\t\t\t      const char *pemKeyFilename,\n\t\t\t      const char *password)\n{\n    TPM_RC \trc = 0;\n    FILE \t*pemKeyFile = NULL;\n\n    if (rc == 0) {\n\trc = TSS_File_Open(&pemKeyFile, pemKeyFilename, \"rb\"); \t/* closed @2 */\n    }\n    if (rc == 0) {\n\t*evpPkey = PEM_read_PrivateKey(pemKeyFile, NULL, NULL, (void *)password);\n\tif (*evpPkey == NULL) {\n\t    printf(\"convertPemToEvpPrivKey: Error reading key file %s\\n\", pemKeyFilename);\n\t    rc = TSS_RC_PEM_ERROR;\n\t}\n    }\n    if (pemKeyFile != NULL) {\n\tfclose(pemKeyFile);\t\t\t/* @2 */\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOFILE */\n\n#ifndef TPM_TSS_NOFILE\n\n/* convertPemToEvpPubKey() converts a PEM public key file to an openssl EVP_PKEY public key */\n\nTPM_RC convertPemToEvpPubKey(EVP_PKEY **evpPkey,\t\t/* freed by caller */\n\t\t\t     const char *pemKeyFilename)\n{\n    TPM_RC \trc = 0;\n    FILE \t*pemKeyFile = NULL;\n\n    if (rc == 0) {\n\trc = TSS_File_Open(&pemKeyFile, pemKeyFilename, \"rb\"); \t/* closed @2 */\n    }\n    if (rc == 0) {\n\t*evpPkey = PEM_read_PUBKEY(pemKeyFile, NULL, NULL, NULL);\n\tif (*evpPkey == NULL) {\n\t    printf(\"convertPemToEvpPubKey: Error reading key file %s\\n\", pemKeyFilename);\n\t    rc = TSS_RC_PEM_ERROR;\n\t}\n    }\n    if (pemKeyFile != NULL) {\n\tfclose(pemKeyFile);\t\t\t/* @2 */\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOFILE */\n\n#ifndef TPM_TSS_NOFILE\n\n/* convertPemToRsaPrivKey() converts a PEM format keypair file to a library specific RSA key\n   token.\n\n   The return is void because the structure is opaque to the caller.  This accomodates other crypto\n   libraries.\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nTPM_RC convertPemToRsaPrivKey(void **rsaKey,\t\t/* freed by caller */\n\t\t\t      const char *pemKeyFilename,\n\t\t\t      const char *password)\n{\n    TPM_RC \trc = 0;\n    FILE \t*pemKeyFile = NULL;\n\n    if (rc == 0) {\n\trc = TSS_File_Open(&pemKeyFile, pemKeyFilename, \"rb\"); \t/* closed @1 */\n    }\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t*rsaKey = (void *)PEM_read_RSAPrivateKey(pemKeyFile, NULL, NULL, (void *)password);\n#else\n\t*rsaKey = (void *)PEM_read_PrivateKey(pemKeyFile, NULL, NULL, (void *)password);\n#endif\n\tif (*rsaKey == NULL) {\n\t    printf(\"convertPemToRsaPrivKey: Error in OpenSSL PEM_read_RSAPrivateKey()\\n\");\n\t    rc = TSS_RC_PEM_ERROR;\n\t}\n    }\n    if (pemKeyFile != NULL) {\n\tfclose(pemKeyFile);\t\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOFILE */\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\n/* convertEvpPkeyToEckey retrieves the EC_KEY key token from the EVP_PKEY */\n\nTPM_RC convertEvpPkeyToEckey(EC_KEY **ecKey,\t\t/* freed by caller */\n\t\t\t     EVP_PKEY *evpPkey)\n{\n    TPM_RC \trc = 0;\n    \n    if (rc == 0) {\n\t*ecKey = EVP_PKEY_get1_EC_KEY(evpPkey);\n\tif (*ecKey == NULL) {\n\t    printf(\"convertEvpPkeyToEckey: Error extracting EC key from EVP_PKEY\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    return rc;\n}\n#endif\n\n#endif /* TPM_TSS_NOECC */\n#endif /* TPM_TPM20 */\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\n/* convertEvpPkeyToRsakey() retrieves the RSA key token from the EVP_PKEY */\n\nTPM_RC convertEvpPkeyToRsakey(RSA **rsaKey,\t\t/* freed by caller */\n\t\t\t      EVP_PKEY *evpPkey)\n{\n    TPM_RC \trc = 0;\n    \n    if (rc == 0) {\n\t*rsaKey = EVP_PKEY_get1_RSA(evpPkey);\n\tif (*rsaKey == NULL) {\n\t    printf(\"convertEvpPkeyToRsakey: EVP_PKEY_get1_RSA failed\\n\");  \n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    return rc;\n}\n#endif\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* convertEcKeyToPrivateKeyBin() converts an OpenSSL ECC key token to a binary array\n\n   Only supports NIST P256 and P384 curves.\n\n   For Openssl < 3, ecKey is an EC_KEY structure.\n   For Openssl 3, ecKey is an EVP_PKEY,\n*/\n\nTPM_RC convertEcKeyToPrivateKeyBin(int \t\t*privateKeyBytes,\n\t\t\t\t   uint8_t \t**privateKeyBin,\t/* freed by caller */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t\t\t   const EC_KEY *ecKey)\n#else\n    const EVP_PKEY *ecKey)\n#endif\n{\n    TPM_RC \t\trc = 0;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    const BIGNUM \t*privateKeyBn = NULL;\n    int \t\tbnBytes;\n    if (rc == 0) {\n\tTPMI_ECC_CURVE curveID;\t\t/* not used */\n\trc = getEcCurve(&curveID,\n\t\t\tprivateKeyBytes, \n\t\t\tecKey);\n    }\n    /* get the ECC private key as a BIGNUM from the EC_KEY */\n    if (rc == 0) {\n\tprivateKeyBn = EC_KEY_get0_private_key(ecKey);\n    }\n    /* sanity check the BN size against the curve */\n    if (rc == 0) {\n\tbnBytes = BN_num_bytes(privateKeyBn);\n\tif (bnBytes > *privateKeyBytes) {\n\t    printf(\"convertEcKeyToPrivateKeyBin: Error, private key %d bytes too large for curve\\n\",\n\t\t   bnBytes);\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* allocate a buffer for the private key array  based on the curve */\n    if (rc == 0) {\n\trc = TSS_Malloc(privateKeyBin, *privateKeyBytes);\n    }\n    /* convert the private key bignum to binary */\n    if (rc == 0) {\n\t/* TPM rev 116 required the ECC private key to be zero padded in the duplicate parameter of\n\t   import */\n\tsize_t padSize = (size_t)(*privateKeyBytes) - (size_t)bnBytes;\n\tmemset(*privateKeyBin, 0, padSize);\n\tBN_bn2bin(privateKeyBn, (*privateKeyBin) + padSize);\n\tif (tssUtilsVerbose) TSS_PrintAll(\"convertEcKeyToPrivateKeyBin:\",\n\t\t\t\t\t  *privateKeyBin, *privateKeyBytes);\n    }\n#else\n    if (rc == 0) {\n\trc = getEccKeyParts(privateKeyBin,\t\t/* freed by caller */\n\t\t\t    privateKeyBytes,\n\t\t\t    NULL,\n\t\t\t    NULL,\n\t\t\t    ecKey);\n    }\n#endif\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif  /* TPM_TPM20 */\n\n/* convertRsaKeyToPrivateKeyBin() converts an OpenSSL RSA key token private prime p to a binary\n   array\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nTPM_RC convertRsaKeyToPrivateKeyBin(int \t*privateKeyBytes,\n\t\t\t\t    uint8_t \t**privateKeyBin,\t/* freed by caller */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t\t\t    const RSA\t*rsaKey)\n#else\n    const EVP_PKEY *rsaKey)\n#endif\n{\n    TPM_RC \t\trc = 0;\n    const BIGNUM \t*p = NULL;\n\n    /* get the private primes */\n    if (rc == 0) {\n\trc = getRsaKeyParts(NULL, NULL, NULL, &p, NULL, rsaKey);\t/* freed @2 */\n    }\n    /* allocate a buffer for the private key array */\n    if (rc == 0) {\n\t*privateKeyBytes = BN_num_bytes(p);\n\trc = TSS_Malloc(privateKeyBin, *privateKeyBytes);\n    }\n    /* convert the private key bignum to binary */\n    if (rc == 0) {\n\tBN_bn2bin(p, *privateKeyBin);\n    }\n#if OPENSSL_VERSION_NUMBER >= 0x30000000\n    BN_free((BIGNUM *)p);\t\t/* @2 */\n#endif\n    return rc;\n}\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* convertEcKeyToPublicKeyBin() converts an OpenSSL EC_KEY public key token to a binary array */\n\nTPM_RC convertEcKeyToPublicKeyBin(int \t\t*modulusBytes,\n\t\t\t\t  uint8_t \t**modulusBin,\t/* freed by caller */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t\t\t  const EC_KEY \t*ecKey)\n#else\n    const EVP_PKEY \t\t*ecKey)\n#endif\n{\n    TPM_RC \t\trc = 0;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    const EC_POINT \t*ecPoint = NULL;\n    const EC_GROUP \t*ecGroup = NULL;\n\n    if (rc == 0) {\n\tecPoint = EC_KEY_get0_public_key(ecKey);\n\tif (ecPoint == NULL) {\n\t    printf(\"convertEcKeyToPublicKeyBin: Error extracting EC point from EC public key\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tecGroup = EC_KEY_get0_group(ecKey);\n\tif (ecGroup == NULL) {\n\t    printf(\"convertEcKeyToPublicKeyBin: Error extracting EC group from EC public key\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* get the public modulus */\n    if (rc == 0) {\n\t*modulusBytes = (int)EC_POINT_point2oct(ecGroup, ecPoint,\n\t\t\t\t\t\tPOINT_CONVERSION_UNCOMPRESSED,\n\t\t\t\t\t\tNULL, 0, NULL);\n    }\n    if (rc == 0) {\n\trc = TSS_Malloc(modulusBin, *modulusBytes);\n    }\n    if (rc == 0) {\n\tEC_POINT_point2oct(ecGroup, ecPoint,\n\t\t\t   POINT_CONVERSION_UNCOMPRESSED,\n\t\t\t   *modulusBin, *modulusBytes, NULL);\n\tif (tssUtilsVerbose) TSS_PrintAll(\"convertEcKeyToPublicKeyBin:\", *modulusBin, *modulusBytes);\n    }\n#else\n    if (rc == 0) {\n\trc = getEccKeyParts(NULL,\n\t\t\t    NULL,\n\t\t\t    modulusBin,\t\t/* freed by caller */\n\t\t\t    modulusBytes,\n\t\t\t    ecKey);\n     }\n#endif\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif  /* TPM_TPM20 */\n\n/* convertRsaKeyToPublicKeyBin() converts from an openssl RSA key token to a public modulus\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nTPM_RC convertRsaKeyToPublicKeyBin(int \t\t*modulusBytes,\n\t\t\t\t   uint8_t \t**modulusBin,\t/* freed by caller */\n\t\t\t\t   void \t*rsaKey)\n{\n    TPM_RC \t\trc = 0;\n    const BIGNUM \t*n = NULL;\n\n    /* get the public modulus from the RSA key token */\n    if (rc == 0) {\n\trc = getRsaKeyParts(&n, NULL, NULL, NULL, NULL, rsaKey);\n    }\n    if (rc == 0) {\n\t*modulusBytes = BN_num_bytes(n);\n    }\n    if (rc == 0) {   \n\trc = TSS_Malloc(modulusBin, *modulusBytes);\n    }\n    if (rc == 0) {\n\tBN_bn2bin(n, *modulusBin);\n    }\n#if OPENSSL_VERSION_NUMBER >= 0x30000000\n    BN_free((BIGNUM *)n);\t\t/* @2 */\n#endif\n   return rc;\n}\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n#if OPENSSL_VERSION_NUMBER >= 0x30000000\n\n/* getEccKeyParts() gets the ECC key parts from an OpenSSL ECC key token.\n\n   For openssl >= 3.0.0, the octet strings are allocated and must be freed.\n*/\n\nstatic TPM_RC getEccKeyParts(uint8_t **priv,\t/* freed by caller */\n\t\t\t     int *privLen,\n\t\t\t     uint8_t **pub,\t/* freed by caller */\n\t\t\t     int *pubLen,\n\t\t\t     const EVP_PKEY *eccKey)\n{\n    TPM_RC  \trc = 0;\n    int\t\tirc;\n\n    if (priv != NULL) {\n\tBIGNUM *bnpriv = NULL;\t/* freed @1 */\n\tif (rc == 0) {\n\t    irc = EVP_PKEY_get_bn_param(eccKey, OSSL_PKEY_PARAM_PRIV_KEY, &bnpriv);\n\t    if (irc != 1) {\n\t\tprintf(\"getEccKeyParts: Error getting priv\\n\");\n\t\trc = TSS_RC_EC_KEY_CONVERT;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    *privLen = BN_num_bytes(bnpriv);\n\t    rc = TSS_Malloc(priv, *privLen);\n\t}\n\tif (rc == 0) {\n\t    BN_bn2bin(bnpriv, *priv);\n\t    BN_free(bnpriv);\t\t/* @1 */\n#if 0\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"getEccKeyParts: priv\",\n\t\t\t\t\t      *priv, *privLen);\n#endif\n\t}\n    }\n    if (pub != NULL) {\n\tBIGNUM *bnx = NULL;\t/* free @1 */\n\tBIGNUM *bny = NULL;\t/* free @2 */\n\tint \tbnxBytes;\n\tint \tbnyBytes;\n\tTPMI_ECC_CURVE \tcurveID;\t/* not used */\n\tint \t\tprivateKeyBytes;\n\n\t/* the public key is assembled from X and Y.  In openssl 3.0.0, these are bignums and the\n\t   leading zero can be truncated when converting to bin.  Get the size based on the ECC\n\t   curve, so that it can be zero padded if necessary. */\n\tif (rc == 0) {\n\t    rc = getEcCurve(&curveID,\n\t\t\t    &privateKeyBytes,\n\t\t\t    eccKey);\n\t}\n\t/* X point as BIGNUM */\n\tif (rc == 0) {\n\t    irc = EVP_PKEY_get_bn_param(eccKey, OSSL_PKEY_PARAM_EC_PUB_X, &bnx);\n\t    if (irc != 1) {\n\t\tprintf(\"getEccKeyParts: Error getting x\\n\");\n\t\trc = TSS_RC_EC_KEY_CONVERT;\n\t    }\n\t}\n\t/* Y point as BIGNUM */\n\tif (rc == 0) {\n\t    irc = EVP_PKEY_get_bn_param(eccKey, OSSL_PKEY_PARAM_EC_PUB_Y, &bny);\n\t    if (irc != 1) {\n\t\tprintf(\"getEccKeyParts: Error getting y\\n\");\n\t\trc = TSS_RC_EC_KEY_CONVERT;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    bnxBytes = BN_num_bytes(bnx);\t/* public key point sizes */\n\t    bnyBytes = BN_num_bytes(bny);\n\t    /* sanity check against the curve */\n\t    if ((bnxBytes > privateKeyBytes) ||\n\t\t(bnyBytes > privateKeyBytes)) {\n\t\tprintf(\"getEccKeyParts: size of X %d or Y %d is greater than private key %d\\n\",\n\t\t       bnxBytes, bnyBytes, privateKeyBytes);\n\t    }\n\t}\n\t/* public key bin is 2x the point size plus 1 for the compression indicator byte */\n\tif (rc == 0) {\n\t    *pubLen = privateKeyBytes + privateKeyBytes +1;\n\t    rc = TSS_Malloc(pub, *pubLen);\n\t}\n\tif (rc == 0) {\n\t    memset(*pub , 0 ,*pubLen);\t\t/* for zero padding */ \n\t    (*pub)[0] = 0x04; \t\t\t/* uncompressed */\n\t    /* convert to bin, normally the entire point, but occasionally have to add the zero\n\t       pad */\n\t    BN_bn2bin(bnx, (*pub) + 1 + privateKeyBytes - bnxBytes);\n\t    BN_bn2bin(bny, (*pub) + 1 + privateKeyBytes + privateKeyBytes - bnyBytes);\n\t    BN_free(bnx);\t\t/* @1 */\n\t    BN_free(bny);\t\t/* @2 */\n#if 0\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"getEccKeyParts: pub\",\n\t\t\t\t\t      *pub, *pubLen);\n#endif\n\t}\n    }\n    return rc;\n}\n\n#endif\n\n/* convertEcPrivateKeyBinToPrivate() converts an EC 'privateKeyBin' to either a\n   TPM2B_PRIVATE or a TPM2B_SENSITIVE\n\n*/\n\nTPM_RC convertEcPrivateKeyBinToPrivate(TPM2B_PRIVATE \t*objectPrivate,\n\t\t\t\t       TPM2B_SENSITIVE \t*objectSensitive,\n\t\t\t\t       int \t\tprivateKeyBytes,\n\t\t\t\t       uint8_t \t\t*privateKeyBin,\n\t\t\t\t       const char \t*password)\n{\n    TPM_RC \t\trc = 0;\n    TPMT_SENSITIVE\ttSensitive;\n    TPM2B_SENSITIVE\tbSensitive;\n\n    if (rc == 0) {\n\tif (((objectPrivate == NULL) && (objectSensitive == NULL)) ||\n\t    ((objectPrivate != NULL) && (objectSensitive != NULL))) {\n\t    printf(\"convertEcPrivateKeyBinToPrivate: Only one result supported\\n\");\n\t    rc = TSS_RC_NULL_PARAMETER;\n\t}\n    }\n    /* In some cases, the sensitive data is not encrypted and the integrity value is not present.\n       When an integrity value is not needed, it is not present and it is not represented by an\n       Empty Buffer.\n\n       In this case, the TPM2B_PRIVATE will just be a marshaled TPM2B_SENSITIVE, which is a\n       marshaled TPMT_SENSITIVE */\t\n\n    /* construct TPMT_SENSITIVE\t*/\n    if (rc == 0) {\n\t/* This shall be the same as the type parameter of the associated public area. */\n\ttSensitive.sensitiveType = TPM_ALG_ECC;\n\ttSensitive.seedValue.b.size = 0;\n\t/* key password converted to TPM2B */\n\trc = TSS_TPM2B_StringCopy(&tSensitive.authValue.b, password,\n\t\t\t\t  sizeof(tSensitive.authValue.t.buffer));\n    }\n    if (rc == 0) {\n\tif ((size_t)privateKeyBytes > sizeof(tSensitive.sensitive.ecc.t.buffer)) {\n\t    printf(\"convertEcPrivateKeyBinToPrivate: Error, private key size %u not 32\\n\",\n\t\t   privateKeyBytes);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\ttSensitive.sensitive.ecc.t.size = privateKeyBytes;\n\tmemcpy(tSensitive.sensitive.ecc.t.buffer, privateKeyBin, privateKeyBytes);\n    }\n    /* FIXME common code for EC and RSA */\n    /* marshal the TPMT_SENSITIVE into a TPM2B_SENSITIVE */\t\n    if (rc == 0) {\n\tif (objectPrivate != NULL) {\n\t    uint32_t size = sizeof(bSensitive.t.sensitiveArea);\t/* max size */\n\t    uint8_t *buffer = bSensitive.b.buffer;\t\t/* pointer that can move */\n\t    bSensitive.t.size = 0;\t\t\t\t/* required before marshaling */\n\t    rc = TSS_TPMT_SENSITIVE_Marshalu(&tSensitive,\n\t\t\t\t\t    &bSensitive.b.size,\t/* marshaled size */\n\t\t\t\t\t    &buffer,\t\t/* marshal here */\n\t\t\t\t\t    &size);\t\t/* max size */\n\t}\n\telse {\t/* return TPM2B_SENSITIVE */\n\t    objectSensitive->t.sensitiveArea = tSensitive;\n\t}\t\n    }\n    /* marshal the TPM2B_SENSITIVE (as a TPM2B_PRIVATE, see above) into a TPM2B_PRIVATE */\n    if (rc == 0) {\n\tif (objectPrivate != NULL) {\n\t    uint32_t size = sizeof(objectPrivate->t.buffer);\t/* max size */\n\t    uint8_t *buffer = objectPrivate->t.buffer;\t\t/* pointer that can move */\n\t    objectPrivate->t.size = 0;\t\t\t\t/* required before marshaling */\n\t    rc = TSS_TPM2B_PRIVATE_Marshalu((TPM2B_PRIVATE *)&bSensitive,\n\t\t\t\t\t   &objectPrivate->t.size,\t/* marshaled size */\n\t\t\t\t\t   &buffer,\t\t/* marshal here */\n\t\t\t\t\t   &size);\t\t/* max size */\n\t}\n    }\n    return rc;\n}\n\n#endif \t/* TPM_TSS_NOECC */\n#endif \t/* TPM_TPM20 */\n\n#ifdef TPM_TPM20\n\n/* convertRsaPrivateKeyBinToPrivate() converts an RSA prime 'privateKeyBin' to either a\n   TPM2B_PRIVATE or a TPM2B_SENSITIVE\n\n*/\n\nTPM_RC convertRsaPrivateKeyBinToPrivate(TPM2B_PRIVATE \t*objectPrivate,\n\t\t\t\t\tTPM2B_SENSITIVE *objectSensitive,\n\t\t\t\t\tint \t\tprivateKeyBytes,\n\t\t\t\t\tuint8_t \t*privateKeyBin,\n\t\t\t\t\tconst char \t*password)\n{\n    TPM_RC \t\trc = 0;\n    TPMT_SENSITIVE\ttSensitive;\n    TPM2B_SENSITIVE\tbSensitive;\n\n    if (rc == 0) {\n\tif (((objectPrivate == NULL) && (objectSensitive == NULL)) ||\n\t    ((objectPrivate != NULL) && (objectSensitive != NULL))) {\n\t    printf(\"convertRsaPrivateKeyBinToPrivate: Only one result supported\\n\");\n\t    rc = TSS_RC_NULL_PARAMETER;\n\t}\n    }\n    /* In some cases, the sensitive data is not encrypted and the integrity value is not present.\n       When an integrity value is not needed, it is not present and it is not represented by an\n       Empty Buffer.\n\n       In this case, the TPM2B_PRIVATE will just be a marshaled TPM2B_SENSITIVE, which is a\n       marshaled TPMT_SENSITIVE */\t\n\n    /* construct TPMT_SENSITIVE\t*/\n    if (rc == 0) {\n\t/* This shall be the same as the type parameter of the associated public area. */\n\ttSensitive.sensitiveType = TPM_ALG_RSA;\n\t/* generate a seed for storage keys */\n\ttSensitive.seedValue.b.size = 32; \t/* FIXME hard coded seed length */\n\trc = TSS_RandBytes(tSensitive.seedValue.b.buffer, tSensitive.seedValue.b.size);\n    }\n    /* key password converted to TPM2B */\n    if (rc == 0) {\n\trc = TSS_TPM2B_StringCopy(&tSensitive.authValue.b, password,\n\t\t\t\t  sizeof(tSensitive.authValue.t.buffer));\n    }\n    if (rc == 0) {\n\tif ((size_t)privateKeyBytes > sizeof(tSensitive.sensitive.rsa.t.buffer)) {\n\t    printf(\"convertRsaPrivateKeyBinToPrivate: \"\n\t\t   \"Error, private key modulus %d greater than %lu\\n\",\n\t\t   privateKeyBytes, (unsigned long)sizeof(tSensitive.sensitive.rsa.t.buffer));\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\ttSensitive.sensitive.rsa.t.size = privateKeyBytes;\n\tmemcpy(tSensitive.sensitive.rsa.t.buffer, privateKeyBin, privateKeyBytes);\n    }\n    /* FIXME common code for EC and RSA */\n    /* marshal the TPMT_SENSITIVE into a TPM2B_SENSITIVE */\t\n    if (rc == 0) {\n\tif (objectPrivate != NULL) {\n\t    uint32_t size = sizeof(bSensitive.t.sensitiveArea);\t/* max size */\n\t    uint8_t *buffer = bSensitive.b.buffer;\t\t/* pointer that can move */\n\t    bSensitive.t.size = 0;\t\t\t\t/* required before marshaling */\n\t    rc = TSS_TPMT_SENSITIVE_Marshalu(&tSensitive,\n\t\t\t\t\t    &bSensitive.b.size,\t/* marshaled size */\n\t\t\t\t\t    &buffer,\t\t/* marshal here */\n\t\t\t\t\t    &size);\t\t/* max size */\n\t}\n\telse {\t/* return TPM2B_SENSITIVE */\n\t    objectSensitive->t.sensitiveArea = tSensitive;\n\t}\t\n    }\n    /* marshal the TPM2B_SENSITIVE (as a TPM2B_PRIVATE, see above) into a TPM2B_PRIVATE */\n    if (rc == 0) {\n\tif (objectPrivate != NULL) {\n\t    uint32_t size = sizeof(objectPrivate->t.buffer);\t/* max size */\n\t    uint8_t *buffer = objectPrivate->t.buffer;\t\t/* pointer that can move */\n\t    objectPrivate->t.size = 0;\t\t\t\t/* required before marshaling */\n\t    rc = TSS_TPM2B_PRIVATE_Marshalu((TPM2B_PRIVATE *)&bSensitive,\n\t\t\t\t\t   &objectPrivate->t.size,\t/* marshaled size */\n\t\t\t\t\t   &buffer,\t\t/* marshal here */\n\t\t\t\t\t   &size);\t\t/* max size */\n\t}\n    }\n    return rc;\n}\n\n#endif /* TPM_TPM20 */\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* convertEcPublicKeyBinToPublic() converts an EC modulus and other parameters to a TPM2B_PUBLIC\n\n*/\n\nTPM_RC convertEcPublicKeyBinToPublic(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t\t     int\t\t\tkeyType,\n\t\t\t\t     TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t\t     TPMI_ALG_HASH \t\tnalg,\n\t\t\t\t     TPMI_ALG_HASH\t\thalg,\n\t\t\t\t     TPMI_ECC_CURVE \t\tcurveID,\n\t\t\t\t     int \t\t\tmodulusBytes,\n\t\t\t\t     uint8_t \t\t\t*modulusBin)\n{\n    TPM_RC \trc = 0;\n    int\t\tpointBytes;\n    int\t\tcurveModulusBytes;\n\n    scheme = scheme;\t/* scheme parameter not supported yet */\n     if (rc == 0) {\n\t rc = getEcModulusBytes(&curveModulusBytes, &pointBytes, curveID);\n     }\n     if (rc == 0) {\n\tif (modulusBytes != curveModulusBytes) {\n\t    printf(\"convertEcPublicKeyBinToPublic: public modulus expected %u bytes, actual %u\\n\",\n\t\t   curveModulusBytes, modulusBytes);\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\t/* Table 184 - Definition of TPMT_PUBLIC Structure */\n\tobjectPublic->publicArea.type = TPM_ALG_ECC;\n\tobjectPublic->publicArea.nameAlg = nalg;\n\tobjectPublic->publicArea.objectAttributes.val = TPMA_OBJECT_NODA;\n\tobjectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\tswitch (keyType) {\n\t  case TYPE_SI:\n\t    objectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_SIGN;\n\t    objectPublic->publicArea.parameters.eccDetail.symmetric.algorithm = TPM_ALG_NULL;\n\t    objectPublic->publicArea.parameters.eccDetail.scheme.scheme = TPM_ALG_ECDSA;\n\t    break;\n\t  case TYPE_ST:\t\t/* for public part only */\n\t    objectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_DECRYPT;\n\t    objectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_RESTRICTED;\n\t    objectPublic->publicArea.parameters.eccDetail.symmetric.algorithm = TPM_ALG_AES;\n\t    objectPublic->publicArea.parameters.eccDetail.symmetric.keyBits.aes = 128;\n\t    objectPublic->publicArea.parameters.eccDetail.symmetric.mode.aes = TPM_ALG_CFB;\n\t    objectPublic->publicArea.parameters.eccDetail.scheme.scheme = TPM_ALG_NULL;\n\t    break;\n\t  case TYPE_DEN:\t/* for public and private part */\n\t    objectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_DECRYPT;\n\t    objectPublic->publicArea.objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\t    objectPublic->publicArea.parameters.eccDetail.symmetric.algorithm = TPM_ALG_NULL;\n\t    objectPublic->publicArea.parameters.eccDetail.scheme.scheme = TPM_ALG_ECDH;\n\t    break;\n\t}\n\tobjectPublic->publicArea.authPolicy.t.size = 0;\n\t/* Table 152 - Definition of TPMU_ASYM_SCHEME Union */\n\tobjectPublic->publicArea.parameters.eccDetail.scheme.details.ecdsa.hashAlg = halg;\n\tobjectPublic->publicArea.parameters.eccDetail.curveID = curveID;\t\n\tobjectPublic->publicArea.parameters.eccDetail.kdf.scheme = TPM_ALG_NULL;\n\tobjectPublic->publicArea.parameters.eccDetail.kdf.details.mgf1.hashAlg = halg;\n\n\tobjectPublic->publicArea.unique.ecc.x.t.size = pointBytes;\t\n\tmemcpy(objectPublic->publicArea.unique.ecc.x.t.buffer,\n\t       modulusBin +1, pointBytes);\t\n\n\tobjectPublic->publicArea.unique.ecc.y.t.size = pointBytes;\t\n\tmemcpy(objectPublic->publicArea.unique.ecc.y.t.buffer,\n\t       modulusBin +1 + pointBytes, pointBytes);\t\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif\t/* TPM_TPM20 */\n\n#ifdef TPM_TPM20\n\n/* convertRsaPublicKeyBinToPublic() converts a public modulus to a TPM2B_PUBLIC structure. */\n\nTPM_RC convertRsaPublicKeyBinToPublic(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t\t      int\t\t\tkeyType,\n\t\t\t\t      TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t\t      TPMI_ALG_HASH \t\tnalg,\n\t\t\t\t      TPMI_ALG_HASH\t\thalg,\n\t\t\t\t      int \t\t\tmodulusBytes,\n\t\t\t\t      uint8_t \t\t\t*modulusBin)\n{\n    TPM_RC \t\trc = 0;\n\n    if (rc == 0) {\n\tif ((size_t)modulusBytes > sizeof(objectPublic->publicArea.unique.rsa.t.buffer)) {\n\t    printf(\"convertRsaPublicKeyBinToPublic: Error, \"\n\t\t   \"public key modulus %d greater than %lu\\n\", modulusBytes,\n\t\t   (unsigned long)sizeof(objectPublic->publicArea.unique.rsa.t.buffer));\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\t/* Table 184 - Definition of TPMT_PUBLIC Structure */\n\tobjectPublic->publicArea.type = TPM_ALG_RSA;\n\tobjectPublic->publicArea.nameAlg = nalg;\n\tobjectPublic->publicArea.objectAttributes.val = TPMA_OBJECT_NODA;\n\tobjectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\tswitch (keyType) {\n\t  case TYPE_SI:\n\t    objectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_SIGN;\n\t    objectPublic->publicArea.parameters.rsaDetail.symmetric.algorithm = TPM_ALG_NULL;\n\t    break;\n\t  case TYPE_ST:\t\t/* for public part only */\n\t    objectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_DECRYPT;\n\t    objectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_RESTRICTED;\n\t    objectPublic->publicArea.parameters.rsaDetail.symmetric.algorithm = TPM_ALG_AES;\n\t    objectPublic->publicArea.parameters.rsaDetail.symmetric.keyBits.aes = 128;\n\t    objectPublic->publicArea.parameters.rsaDetail.symmetric.mode.aes = TPM_ALG_CFB;\n\t    break;\n\t  case TYPE_DEN:\t/* for public and private part */\n\t    objectPublic->publicArea.objectAttributes.val |= TPMA_OBJECT_DECRYPT;\n\t    objectPublic->publicArea.objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\t    objectPublic->publicArea.parameters.rsaDetail.symmetric.algorithm = TPM_ALG_NULL;\n\t    break;\n\t}\n\tobjectPublic->publicArea.authPolicy.t.size = 0;\n\t/* Table 182 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */\n\tobjectPublic->publicArea.parameters.rsaDetail.scheme.scheme = scheme;\n\tobjectPublic->publicArea.parameters.rsaDetail.scheme.details.rsassa.hashAlg = halg;\n\tobjectPublic->publicArea.parameters.rsaDetail.keyBits = modulusBytes * 8;\t\n\tobjectPublic->publicArea.parameters.rsaDetail.exponent = 0;\n\n\tobjectPublic->publicArea.unique.rsa.t.size = modulusBytes;\n\tmemcpy(objectPublic->publicArea.unique.rsa.t.buffer, modulusBin, modulusBytes);\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TPM20 */\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* convertEcKeyToPrivate() converts an openssl EC_KEY to token to either a TPM2B_PRIVATE or\n   TPM2B_SENSITIVE\n*/\n\nTPM_RC convertEcKeyToPrivate(TPM2B_PRIVATE \t*objectPrivate,\n\t\t\t     TPM2B_SENSITIVE \t*objectSensitive,\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t\t     EC_KEY \t\t*ecKey,\n#else\n\t\t\t     EVP_PKEY \t\t*ecKey,\n#endif\n\t\t\t     const char \t*password)\n{\n    TPM_RC \trc = 0;\n    int \tprivateKeyBytes;\n    uint8_t \t*privateKeyBin = NULL;\n\n    /* convert an openssl EC_KEY token to a binary array */\n    if (rc == 0) {\n\trc = convertEcKeyToPrivateKeyBin(&privateKeyBytes,\n\t\t\t\t\t &privateKeyBin,\t/* freed @1 */\n\t\t\t\t\t ecKey);\n    }\n    if (rc == 0) {\n\trc = convertEcPrivateKeyBinToPrivate(objectPrivate,\n\t\t\t\t\t     objectSensitive,\n\t\t\t\t\t     privateKeyBytes,\n\t\t\t\t\t     privateKeyBin,\n\t\t\t\t\t     password);\n    }\n    free(privateKeyBin);\t\t/* @1 */\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif  /* TPM_TPM20 */\n\n#ifdef TPM_TPM20\n\n/* convertRsaKeyToPrivate() converts an openssl RSA key token to either a TPM2B_PRIVATE or\n   TPM2B_SENSITIVE\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nTPM_RC convertRsaKeyToPrivate(TPM2B_PRIVATE \t*objectPrivate,\n\t\t\t      TPM2B_SENSITIVE \t*objectSensitive,\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t\t      RSA\t\t*rsaKey,\n#else\n\t\t\t      EVP_PKEY \t\t*rsaKey,\n#endif\n\t\t\t      const char \t*password)\n{\n    TPM_RC \trc = 0;\n    int \tprivateKeyBytes;\n    uint8_t \t*privateKeyBin = NULL;\n\n    /* convert an openssl RSA key token private prime p to a binary array */\n    if (rc == 0) {\n\trc = convertRsaKeyToPrivateKeyBin(&privateKeyBytes,\n\t\t\t\t\t  &privateKeyBin,\t/* freed @1 */\n\t\t\t\t\t  rsaKey);\n    }\n    /* convert an RSA prime 'privateKeyBin' to either a TPM2B_PRIVATE or a TPM2B_SENSITIVE */\n    if (rc == 0) {\n\trc = convertRsaPrivateKeyBinToPrivate(objectPrivate,\n\t\t\t\t\t      objectSensitive,\n\t\t\t\t\t      privateKeyBytes,\n\t\t\t\t\t      privateKeyBin,\n\t\t\t\t\t      password);\n    }\n    free(privateKeyBin);\t\t/* @1 */\n    return rc;\n}\n\n#endif /* TPM_TPM20 */\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* convertEcKeyToPublic() converts an EC_KEY to a TPM2B_PUBLIC */\n\nTPM_RC convertEcKeyToPublic(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t    int\t\t\t\tkeyType,\n\t\t\t    TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t    TPMI_ALG_HASH \t\tnalg,\n\t\t\t    TPMI_ALG_HASH\t\thalg,\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t\t    EC_KEY \t\t\t*ecKey)\n#else\n    EVP_PKEY \t\t*ecKey)\n#endif\n{\n    TPM_RC \t\trc = 0;\n    int \t\tmodulusBytes;\n    uint8_t \t\t*modulusBin = NULL;\n    TPMI_ECC_CURVE\tcurveID;\n    int \t\tprivateKeyBytes;\n\n    if (rc == 0) {\n\trc = convertEcKeyToPublicKeyBin(&modulusBytes,\n\t\t\t\t\t&modulusBin,\t\t/* freed @1 */\n\t\t\t\t\tecKey);\n    }\n    if (rc == 0) {\n\trc = getEcCurve(&curveID, &privateKeyBytes, ecKey);\n    }\n    if (rc == 0) {\n\trc = convertEcPublicKeyBinToPublic(objectPublic,\n\t\t\t\t\t   keyType,\n\t\t\t\t\t   scheme,\n\t\t\t\t\t   nalg,\n\t\t\t\t\t   halg,\n\t\t\t\t\t   curveID,\n\t\t\t\t\t   modulusBytes,\n\t\t\t\t\t   modulusBin);\n    }\n    free(modulusBin);\t\t/* @1 */\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif \t/* TPM_TPM20 */\n\n#ifdef TPM_TPM20\n\n/* convertRsaKeyToPublic() converts from an openssl RSA key token to a TPM2B_PUBLIC\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nTPM_RC convertRsaKeyToPublic(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t     int\t\t\tkeyType,\n\t\t\t     TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t     TPMI_ALG_HASH \t\tnalg,\n\t\t\t     TPMI_ALG_HASH\t\thalg,\n\t\t\t     void \t\t\t*rsaKey)\n{\n    TPM_RC \t\trc = 0;\n    int \t\tmodulusBytes;\n    uint8_t \t\t*modulusBin = NULL;\n    \n    /* openssl RSA key token to a public modulus */\n    if (rc == 0) {\n\trc = convertRsaKeyToPublicKeyBin(&modulusBytes,\n\t\t\t\t\t &modulusBin,\t\t/* freed @1 */\n\t\t\t\t\t rsaKey);\n    }\n    /* public modulus to TPM2B_PUBLIC */\n    if (rc == 0) {\n\trc = convertRsaPublicKeyBinToPublic(objectPublic,\n\t\t\t\t\t    keyType,\n\t\t\t\t\t    scheme,\n\t\t\t\t\t    nalg,\n\t\t\t\t\t    halg,\n\t\t\t\t\t    modulusBytes,\n\t\t\t\t\t    modulusBin);\n    }\n    free(modulusBin);\t\t/* @1 */\n    return rc;\n}\n\n#endif /* TPM_TPM20 */\n\n#ifndef TPM_TSS_NOFILE\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* convertEcPemToKeyPair() converts a PEM file to a TPM2B_PUBLIC and TPM2B_PRIVATE */\n\nTPM_RC convertEcPemToKeyPair(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t     TPM2B_PRIVATE \t\t*objectPrivate,\n\t\t\t     int\t\t\tkeyType,\n\t\t\t     TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t     TPMI_ALG_HASH \t\tnalg,\n\t\t\t     TPMI_ALG_HASH\t\thalg,\n\t\t\t     const char \t\t*pemKeyFilename,\n\t\t\t     const char \t\t*password)\n{\n    TPM_RC \trc = 0;\n    EVP_PKEY \t*evpPkey = NULL;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    EC_KEY \t*ecKey = NULL;\n#else\n    EVP_PKEY \t*ecKey = NULL;\n#endif\n\n    /* convert a PEM file to an openssl EVP_PKEY */\n    if (rc == 0) {\n\trc = convertPemToEvpPrivKey(&evpPkey,\t\t/* freed @1 */\n\t\t\t\t    pemKeyFilename,\n\t\t\t\t    password);\n    }\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\trc = convertEvpPkeyToEckey(&ecKey,\t\t/* freed @2 */\n\t\t\t\t   evpPkey);\n#else\n\t/* openssl 3.0.0 and up use the EVP_PKEY directly */\n\tecKey = evpPkey;\n#endif\n    }\n    if (rc == 0) {\n\trc = convertEcKeyToPrivate(objectPrivate,\t/* TPM2B_PRIVATE */\n\t\t\t\t   NULL,\t\t/* TPM2B_SENSITIVE */\n\t\t\t\t   ecKey,\n\t\t\t\t   password);\n    }\n    if (rc == 0) {\n\trc = convertEcKeyToPublic(objectPublic,\n\t\t\t\t  keyType,\n\t\t\t\t  scheme,\n\t\t\t\t  nalg,\n\t\t\t\t  halg,\n\t\t\t\t  ecKey);\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    EC_KEY_free(ecKey);   \t\t/* @2 */\n#endif\n    if (evpPkey != NULL) {\n\tEVP_PKEY_free(evpPkey);\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif  /* TPM_TPM20 */\n#endif  /* TPM_TSS_NOFILE */\n\n#ifndef TPM_TSS_NOFILE\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* convertEcPemToPublic() converts an ECC signing public key in PEM format to a\n   TPM2B_PUBLIC */\n\nTPM_RC convertEcPemToPublic(TPM2B_PUBLIC \t*objectPublic,\n\t\t\t    int\t\t\tkeyType,\n\t\t\t    TPMI_ALG_SIG_SCHEME scheme,\n\t\t\t    TPMI_ALG_HASH \tnalg,\n\t\t\t    TPMI_ALG_HASH\thalg,\n\t\t\t    const char\t\t*pemKeyFilename)\n{\n    TPM_RC\trc = 0;\n    EVP_PKEY  \t*evpPkey = NULL;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    EC_KEY \t*ecKey = NULL;\n#else\n    EVP_PKEY \t*ecKey = NULL;\n#endif\n\n    if (rc == 0) {\n\trc = convertPemToEvpPubKey(&evpPkey,\t\t/* freed @1 */\n\t\t\t\t   pemKeyFilename);\n    }\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\trc = convertEvpPkeyToEckey(&ecKey,\t\t/* freed @2 */\n\t\t\t\t   evpPkey);\n#else\n\t/* openssl 3.0.0 and up use the EVP_PKEY directly */\n\tecKey = evpPkey;\n#endif\n    }\n    if (rc == 0) {\n\trc = convertEcKeyToPublic(objectPublic,\n\t\t\t\t  keyType,\n\t\t\t\t  scheme,\n\t\t\t\t  nalg,\n\t\t\t\t  halg,\n\t\t\t\t  ecKey);\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (ecKey != NULL) {\n\tEC_KEY_free(ecKey);   \t\t/* @2 */\n    }\n#endif\n    if (evpPkey != NULL) {\n\tEVP_PKEY_free(evpPkey);\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif  /* TPM_TPM20 */\n#endif  /* TPM_TSS_NOFILE */\n\n#ifndef TPM_TSS_NOFILE\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NORSA\n\n/* convertRsaPemToKeyPair() converts an RSA PEM file to a TPM2B_PUBLIC and TPM2B_PRIVATE */\n\nTPM_RC convertRsaPemToKeyPair(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t      TPM2B_PRIVATE \t\t*objectPrivate,\n\t\t\t      int\t\t\tkeyType,\n\t\t\t      TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t      TPMI_ALG_HASH \t\tnalg,\n\t\t\t      TPMI_ALG_HASH\t\thalg,\n\t\t\t      const char \t\t*pemKeyFilename,\n\t\t\t      const char \t\t*password)\n{\n    TPM_RC \trc = 0;\n    EVP_PKEY \t*evpPkey = NULL;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    RSA\t\t*rsaKey = NULL;\n#else\n    EVP_PKEY \t*rsaKey = NULL;\n#endif\n\n    if (rc == 0) {\n\trc = convertPemToEvpPrivKey(&evpPkey,\t\t/* freed @1 */\n\t\t\t\t    pemKeyFilename,\n\t\t\t\t    password);\n    }\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\trc = convertEvpPkeyToRsakey(&rsaKey,\t\t/* freed @2 */\n\t\t\t\t    evpPkey);\n#else\n\t/* openssl 3.0.0 and up use the EVP_PKEY directly */\n\trsaKey = evpPkey;\n#endif\n    }\n    if (rc == 0) {\n\trc = convertRsaKeyToPrivate(objectPrivate,\t/* TPM2B_PRIVATE */\n\t\t\t\t    NULL,\t\t/* TPM2B_SENSITIVE */\n\t\t\t\t    rsaKey,\n\t\t\t\t    password);\n    }\n    if (rc == 0) {\n\trc = convertRsaKeyToPublic(objectPublic,\n\t\t\t\t   keyType,\n\t\t\t\t   scheme,\n\t\t\t\t   nalg,\n\t\t\t\t   halg,\n\t\t\t\t   rsaKey);\n    }\n    if (evpPkey != NULL) {\n\tEVP_PKEY_free(evpPkey);\t\t/* @1 */\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    TSS_RsaFree(rsaKey);\t\t/* @2 */\n#endif\n    return rc;\n}\n\n#endif /* TPM_TSS_NORSA */\n#endif /* TPM_TPM20 */\n#endif /* TPM_TSS_NOFILE */\n\n#ifndef TPM_TSS_NOFILE\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* convertEcDerToKeyPair() converts an EC keypair stored in DER to a TPM2B_PUBLIC and\n   TPM2B_SENSITIVE.  Useful for LoadExternal.\n\n*/\n\nTPM_RC convertEcDerToKeyPair(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t     TPM2B_SENSITIVE \t\t*objectSensitive,\n\t\t\t     int\t\t\tkeyType,\n\t\t\t     TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t     TPMI_ALG_HASH \t\tnalg,\n\t\t\t     TPMI_ALG_HASH\t\thalg,\n\t\t\t     const char\t\t\t*derKeyFilename,\n\t\t\t     const char \t\t*password)\n{\n    TPM_RC\t\trc = 0;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    EC_KEY\t\t*ecKey = NULL;\n#else\n    EVP_PKEY \t\t*ecKey = NULL;\n#endif\n    unsigned char\t*derBuffer = NULL;\n    size_t\t\tderSize;\n\n    /* read the DER file */\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&derBuffer,     \t/* freed @1 */\n\t\t\t\t     &derSize,\n\t\t\t\t     derKeyFilename); \n    }\n    if (rc == 0) {\n\tconst unsigned char *tmpPtr = derBuffer;\t/* because pointer moves */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\tecKey = d2i_ECPrivateKey(NULL, &tmpPtr, (long)derSize);\t/* freed @2 */\n#else\n\tecKey = d2i_PrivateKey(EVP_PKEY_EC, NULL,\n\t\t\t\t&tmpPtr, (long)derSize);\n#endif\n\tif (ecKey == NULL) {\n\t    printf(\"convertEcDerToKeyPair: could not convert key to EC_KEY\\n\");\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    if (rc == 0) {\n\trc = convertEcKeyToPrivate(NULL,\t\t/* TPM2B_PRIVATE */\n\t\t\t\t   objectSensitive,\t/* TPM2B_SENSITIVE */\n\t\t\t\t   ecKey,\n\t\t\t\t   password);\n    }\n    if (rc == 0) {\n\trc = convertEcKeyToPublic(objectPublic,\n\t\t\t\t  keyType,\n\t\t\t\t  scheme,\n\t\t\t\t  nalg,\n\t\t\t\t  halg,\n\t\t\t\t  ecKey);\n    }\n    free(derBuffer);\t\t/* @1 */\n    TSS_EccFree(ecKey);\t\t/* @2 */\n    return rc;\n}\n\n/* convertEcDerToPublic() converts an EC public key stored in DER to a TPM2B_PUBLIC.  Useful to\n   calculate a Name.\n\n*/\n\nTPM_RC convertEcDerToPublic(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t    int\t\t\t\tkeyType,\n\t\t\t    TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t    TPMI_ALG_HASH \t\tnalg,\n\t\t\t    TPMI_ALG_HASH\t\thalg,\n\t\t\t    const char\t\t\t*derKeyFilename)\n{\n    TPM_RC\t\trc = 0;\n    EVP_PKEY \t\t*evpPkey = NULL;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    EC_KEY\t\t*ecKey = NULL;\n#else\n    EVP_PKEY \t\t*ecKey = NULL;\n#endif\n    unsigned char\t*derBuffer = NULL;\n    size_t\t\tderSize;\n\n    /* read the DER file */\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&derBuffer,     \t/* freed @1 */\n\t\t\t\t     &derSize,\n\t\t\t\t     derKeyFilename); \n    }\n    if (rc == 0) {\n\tconst unsigned char *tmpPtr = derBuffer;\t/* because pointer moves */\n\tevpPkey = d2i_PUBKEY(NULL, &tmpPtr, (long)derSize);\t/* freed @2 */\n\tif (evpPkey == NULL) {\n\t    printf(\"convertEcDerToPublic: could not convert key to EVP_PKEY\\n\");\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\trc = convertEvpPkeyToEckey(&ecKey,\t\t/* freed @3 */\n\t\t\t\t   evpPkey);\n#else\n\t/* openssl 3.0.0 and up use the EVP_PKEY directly */\n\tecKey = evpPkey;\n#endif\n    }\n    if (rc == 0) {\n\trc = convertEcKeyToPublic(objectPublic,\n\t\t\t\t  keyType,\n\t\t\t\t  scheme,\n\t\t\t\t  nalg,\n\t\t\t\t  halg,\n\t\t\t\t  ecKey);\n    }\n    free(derBuffer);\t\t\t/* @1 */\n    if (evpPkey != NULL) {\n\tEVP_PKEY_free(evpPkey);\t\t/* @2 */\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    EC_KEY_free(ecKey);   \t\t/* @3 */\n#endif\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif  /* TPM_TPM20 */\n#endif  /* TPM_TSS_NOFILE */\n\n#ifndef TPM_TSS_NOFILE\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NORSA\n\n/* convertRsaDerToKeyPair() converts an RSA keypair stored in DER to a TPM2B_PUBLIC and\n   TPM2B_SENSITIVE.  Useful for LoadExternal.\n\n*/\n\nTPM_RC convertRsaDerToKeyPair(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t      TPM2B_SENSITIVE \t\t*objectSensitive,\n\t\t\t      int\t\t\tkeyType,\n\t\t\t      TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t      TPMI_ALG_HASH \t\tnalg,\n\t\t\t      TPMI_ALG_HASH\t\thalg,\n\t\t\t      const char\t\t*derKeyFilename,\n\t\t\t      const char \t\t*password)\n{\n    TPM_RC\t\trc = 0;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    RSA \t\t*rsaKey = NULL;\n#else\n    EVP_PKEY \t\t*rsaKey = NULL;\n#endif\n    unsigned char\t*derBuffer = NULL;\n    size_t\t\tderSize;\n\n    /* read the DER file */\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&derBuffer,     \t/* freed @1 */\n\t\t\t\t     &derSize,\n\t\t\t\t     derKeyFilename); \n    }\n    if (rc == 0) {\n\tconst unsigned char *tmpPtr = derBuffer;\t/* because pointer moves */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\trsaKey = d2i_RSAPrivateKey(NULL, &tmpPtr, (long)derSize);\t/* freed @2 */\n#else\n\trsaKey = d2i_PrivateKey(EVP_PKEY_RSA, NULL,\n\t\t\t\t&tmpPtr, (long)derSize);\n#endif\n\tif (rsaKey == NULL) {\n\t    printf(\"convertRsaDerToKeyPair: could not convert key to RSA\\n\");\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    if (rc == 0) {\n\trc = convertRsaKeyToPrivate(NULL,\t\t/* TPM2B_PRIVATE */\n\t\t\t\t    objectSensitive,\t/* TPM2B_SENSITIVE */\n\t\t\t\t    rsaKey,\n\t\t\t\t    password);\t\n    }\t\n    if (rc == 0) {\n\trc = convertRsaKeyToPublic(objectPublic,\n\t\t\t\t   keyType,\n\t\t\t\t   scheme,\n\t\t\t\t   nalg,\n\t\t\t\t   halg,\n\t\t\t\t   rsaKey);\n    }\n    free(derBuffer);\t\t\t/* @1 */\n    TSS_RsaFree(rsaKey);\t\t/* @2 */\n    return rc;\n}\n\n/* convertRsaDerToPublic() converts an RSA public key stored in DER to a TPM2B_PUBLIC.  Useful to\n   calculate a Name.\n\n*/\n\nTPM_RC convertRsaDerToPublic(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t     int\t\t\tkeyType,\n\t\t\t     TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t     TPMI_ALG_HASH \t\tnalg,\n\t\t\t     TPMI_ALG_HASH\t\thalg,\n\t\t\t     const char\t\t\t*derKeyFilename)\n{\n    TPM_RC\t\trc = 0;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    RSA \t\t*rsaKey = NULL;\n#else\n    EVP_PKEY \t\t*rsaKey = NULL;\n#endif\n    unsigned char\t*derBuffer = NULL;\n    size_t\t\tderSize;\n\n    /* read the DER file */\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&derBuffer,     \t/* freed @1 */\n\t\t\t\t     &derSize,\n\t\t\t\t     derKeyFilename); \n    }\n    if (rc == 0) {\n\tconst unsigned char *tmpPtr = derBuffer;\t/* because pointer moves */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\trsaKey = d2i_RSA_PUBKEY(NULL, &tmpPtr, (long)derSize);\t/* freed @2 */\n#else\n\trsaKey = d2i_PUBKEY(NULL, &tmpPtr, (long)derSize);\n#endif\n\tif (rsaKey == NULL) {\n\t    printf(\"convertRsaDerToPublic: could not convert key to RSA\\n\");\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    if (rc == 0) {\n\trc = convertRsaKeyToPublic(objectPublic,\n\t\t\t\t   keyType,\n\t\t\t\t   scheme,\n\t\t\t\t   nalg,\n\t\t\t\t   halg,\n\t\t\t\t   rsaKey);\n    }\n    free(derBuffer);\t\t\t/* @1 */\n    TSS_RsaFree(rsaKey);\t\t/* @2 */\n    return rc;\n}\n\n/* convertRsaPemToPublic() converts an RSA public key in PEM format to a TPM2B_PUBLIC */\n\nTPM_RC convertRsaPemToPublic(TPM2B_PUBLIC \t\t*objectPublic,\n\t\t\t     int\t\t\tkeyType,\n\t\t\t     TPMI_ALG_SIG_SCHEME \tscheme,\n\t\t\t     TPMI_ALG_HASH \t\tnalg,\n\t\t\t     TPMI_ALG_HASH\t\thalg,\n\t\t\t     const char \t\t*pemKeyFilename)\n{\n    TPM_RC\trc = 0;\n    EVP_PKEY \t*evpPkey = NULL;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    RSA\t\t*rsaKey = NULL;\n#else\n    EVP_PKEY \t*rsaKey = NULL;\n#endif\n\n    if (rc == 0) {\n\trc = convertPemToEvpPubKey(&evpPkey,\t\t/* freed @1 */\n\t\t\t\t   pemKeyFilename);\n    }\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\trc = convertEvpPkeyToRsakey(&rsaKey,\t\t/* freed @2 */\n\t\t\t\t    evpPkey);\n#else\n\t/* openssl 3.0.0 and up use the EVP_PKEY directly */\n\trsaKey = evpPkey;\n#endif\n    }\n    if (rc == 0) {\n\trc = convertRsaKeyToPublic(objectPublic,\n\t\t\t\t   keyType,\n\t\t\t\t   scheme,\n\t\t\t\t   nalg,\n\t\t\t\t   halg,\n\t\t\t\t   rsaKey);\n    }\n    if (evpPkey != NULL) {\n\tEVP_PKEY_free(evpPkey);\t\t/* @1 */\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    TSS_RsaFree(rsaKey);\t\t/* @2 */\n#endif\n    return rc;\n}\n\n#endif /* TPM_TSS_NORSA */\n#endif /* TPM_TPM20 */ \n#endif /* TPM_TSS_NOFILE */\n\n/* getRsaKeyParts() gets the RSA key parts from an OpenSSL RSA key token.\n\n   If n is not NULL, returns n, e, and d.  If p is not NULL, returns p and q.\n\n   For openssl < 3.0.0, the bignums are references to the RSA key and should not be freed separately.\n\n   For openssl >= 3.0.0, the bignums are allocated and must be freed.\n*/\n\nTPM_RC getRsaKeyParts(const BIGNUM **n,\n\t\t      const BIGNUM **e,\n\t\t      const BIGNUM **d,\n\t\t      const BIGNUM **p,\n\t\t      const BIGNUM **q,\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t      const RSA *rsaKey)\n#else\n    const EVP_PKEY *rsaKey)\n#endif\n{\n    TPM_RC  \trc = 0;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (n != NULL) {\n\tRSA_get0_key(rsaKey, n, e, d);\n    }\n    if (p != NULL) {\n\tRSA_get0_factors(rsaKey, p, q);\n    }\n#else\n    int\t\tirc;\n    if (rc == 0) {\n\tif (n != NULL) {\n\t    irc = EVP_PKEY_get_bn_param(rsaKey, OSSL_PKEY_PARAM_RSA_N, (BIGNUM **)n);\n\t    if (irc != 1) {\n\t\tprintf(\"getRsaKeyParts: Error getting n\\n\");\n\t\trc = TSS_RC_RSA_KEY_CONVERT;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (e != NULL) {\n\t    irc = EVP_PKEY_get_bn_param(rsaKey, OSSL_PKEY_PARAM_RSA_E, (BIGNUM **)e);\n\t    if (irc != 1) {\n\t\tprintf(\"getRsaKeyParts: Error getting e\\n\");\n\t\trc = TSS_RC_RSA_KEY_CONVERT;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (d != NULL) {\n\t    irc = EVP_PKEY_get_bn_param(rsaKey, OSSL_PKEY_PARAM_RSA_D, (BIGNUM **)d);\n\t    if (irc != 1) {\n\t\tprintf(\"getRsaKeyParts: Error getting d\\n\");\n\t\trc = TSS_RC_RSA_KEY_CONVERT;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (p != NULL) {\n\t    irc = EVP_PKEY_get_bn_param(rsaKey, OSSL_PKEY_PARAM_RSA_FACTOR1, (BIGNUM **)p);\n\t    if (irc != 1) {\n\t\tprintf(\"getRsaKeyParts: Error getting p\\n\");\n\t\trc = TSS_RC_RSA_KEY_CONVERT;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (q != NULL) {\n\t    irc = EVP_PKEY_get_bn_param(rsaKey, OSSL_PKEY_PARAM_RSA_FACTOR2, (BIGNUM **)q);\n\t    if (irc != 1) {\n\t\tprintf(\"getRsaKeyParts: Error getting q\\n\");\n\t\trc = TSS_RC_RSA_KEY_CONVERT;\n\t    }\n\t}\n    }\n#endif\n    return rc;\n}\n\n/* returns the type (EVP_PKEY_RSA or EVP_PKEY_EC) of the EVP_PKEY.\n\n */\n\nint getRsaPubkeyAlgorithm(EVP_PKEY *pkey)\n{\n    int \t\t\tpkeyType;\t/* RSA or EC */\n    pkeyType = EVP_PKEY_base_id(pkey);\n    return pkeyType;\n}\n\n#ifndef TPM_TSS_NOFILE\n\n/* convertPublicToPEM() saves a PEM format public key from a TPM2B_PUBLIC\n \n*/\n\nTPM_RC convertPublicToPEM(const TPM2B_PUBLIC *inPublic,\n\t\t\t  const char *pemFilename)\n{\n    TPM_RC \trc = 0;\n    EVP_PKEY \t*evpPubkey = NULL;          \t/* OpenSSL public key, EVP format */\n\n    /* convert TPM2B_PUBLIC to EVP_PKEY */\n    if (rc == 0) {\n\tswitch (inPublic->publicArea.type) {\n#ifndef TPM_TSS_NORSA\n\t  case TPM_ALG_RSA:\n\t    rc = convertRsaPublicToEvpPubKey(&evpPubkey,\t/* freed @1 */\n\t\t\t\t\t     &inPublic->publicArea.unique.rsa);\n\t    break;\n#endif /* TPM_TSS_NORSA */\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\t  case TPM_ALG_ECC:\n\t    rc = convertEcTPMTPublicToEvpPubKey(&evpPubkey,\t\t/* freed @1 */\n\t\t\t\t\t\t&inPublic->publicArea);\n\t    break;\n#endif /* TPM_TSS_NOECC */\n#endif /* TPM_TPM20 */\n\t  default:\n\t    printf(\"convertPublicToPEM: Unknown publicArea.type %04hx unsupported\\n\",\n\t\t   inPublic->publicArea.type);\n\t    rc = TSS_RC_NOT_IMPLEMENTED;\n\t    break;\n\t}\n    }\n    /* write the openssl structure in PEM format */\n    if (rc == 0) {\n\trc = convertEvpPubkeyToPem(evpPubkey,\n\t\t\t\t   pemFilename);\n\n    }\n    if (evpPubkey != NULL) {\n\tEVP_PKEY_free(evpPubkey);\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif /* TPM_TSS_NOFILE */\n\n#ifndef TPM_TSS_NORSA\n\n/* convertRsaPublicToEvpPubKey() converts an RSA TPM2B_PUBLIC to a EVP_PKEY.\n\n*/\n\nTPM_RC convertRsaPublicToEvpPubKey(EVP_PKEY **evpPubkey,\t/* freed by caller */\n\t\t\t\t   const TPM2B_PUBLIC_KEY_RSA *tpm2bRsa)\n{\n    TPM_RC \trc = 0;\n    /* public exponent */\n    unsigned char earr[3] = {0x01, 0x00, 0x01};\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    int\t\tirc;\n    RSA\t\t*rsaPubKey = NULL;\n#endif\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n\t*evpPubkey = EVP_PKEY_new();\t\t/* freed by caller */\n\tif (*evpPubkey == NULL) {\n\t    printf(\"convertRsaPublicToEvpPubKey: EVP_PKEY failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* TPM to RSA token */\n    if (rc == 0) {\n\t/* For Openssl < 3, rsaKey is an RSA structure. */\n\t/* For Openssl 3, rsaKey is an EVP_PKEY. */\n\trc = TSS_RSAGeneratePublicTokenI\n\t     ((void **)&rsaPubKey,\t\t/* freed by caller  */\n\t      tpm2bRsa->t.buffer,  \t\t/* public modulus */\n\t      tpm2bRsa->t.size,\n\t      earr,      \t\t\t/* public exponent */\n\t      sizeof(earr));\n    }\n    /* RSA token to EVP */\n    if (rc == 0) {\n\tirc  = EVP_PKEY_assign_RSA(*evpPubkey, rsaPubKey);\n\tif (irc == 0) {\n\t    TSS_RsaFree(rsaPubKey);\t/* because not assigned to EVP_PKEY */\n\t    printf(\"convertRsaPublicToEvpPubKey: EVP_PKEY_assign_RSA failed\\n\");\n\t    rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n#else\n    /* TPM to RSA token */\n    if (rc == 0) {\n\t/* For Openssl < 3, rsaKey is an RSA structure. */\n\t/* For Openssl 3, rsaKey is an EVP_PKEY. */\n\trc = TSS_RSAGeneratePublicTokenI\n\t     ((void **)evpPubkey,\t\t/* freed by caller  */\n\t      tpm2bRsa->t.buffer,  \t\t/* public modulus */\n\t      tpm2bRsa->t.size,\n\t      earr,      \t\t\t/* public exponent */\n\t      sizeof(earr));\n    }\n#endif\n    return rc;\n}\n\n#endif /* TPM_TSS_NORSA */\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\n/* convertEcPublicToEvpPubKey() converts an EC TPMS_ECC_POINT to an EVP_PKEY.\n\n   Deprecated: This is hard coded to NIST P256.  See convertEcTPMTPublicToEvpPubKey().\n */\n\nTPM_RC convertEcPublicToEvpPubKey(EVP_PKEY **evpPubkey,\t\t/* freed by caller */\n\t\t\t\t  const TPMS_ECC_POINT *tpmsEccPoint)\n{\n    TPM_RC \trc = 0;\n    int\t\tirc;\n    EC_GROUP \t*ecGroup = NULL;\n    EC_KEY \t*ecKey = NULL;\n    BIGNUM \t*x = NULL;\t\t/* freed @2 */\n    BIGNUM \t*y = NULL;\t\t/* freed @3 */\n    \n    if (rc == 0) {\n\tecKey = EC_KEY_new();\t\t/* freed @1 */\n\tif (ecKey == NULL) {\n\t    printf(\"convertEcPublicToEvpPubKey: Error creating EC_KEY\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tecGroup = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1);\t/* freed @4 */\n\tif (ecGroup == NULL) {\n\t    printf(\"convertEcPublicToEvpPubKey: Error in EC_GROUP_new_by_curve_name\\an\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\t/* returns void */\n\tEC_GROUP_set_asn1_flag(ecGroup, OPENSSL_EC_NAMED_CURVE);\n    }\n    /* assign curve to EC_KEY */\n    if (rc == 0) {\n\tirc = EC_KEY_set_group(ecKey, ecGroup);\n\tif (irc != 1) {\n\t    printf(\"convertEcPublicToEvpPubKey: Error in EC_KEY_set_group\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\trc = convertBin2Bn(&x,\t\t\t\t/* freed @2 */\n\t\t\t   tpmsEccPoint->x.t.buffer,\n\t\t\t   tpmsEccPoint->x.t.size);\t\n    }\n    if (rc == 0) {\n\trc = convertBin2Bn(&y,\t\t\t\t/* freed @3 */\n\t\t\t   tpmsEccPoint->y.t.buffer,\n\t\t\t   tpmsEccPoint->y.t.size);\n    }\n    if (rc == 0) {\n\tirc = EC_KEY_set_public_key_affine_coordinates(ecKey, x, y);\n\tif (irc != 1) {\n\t    printf(\"convertEcPublicToEvpPubKey: \"\n\t\t   \"Error converting public key from X Y to EC_KEY format\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\t*evpPubkey = EVP_PKEY_new();\t\t/* freed by caller */\n\tif (*evpPubkey == NULL) {\n\t    printf(\"convertEcPublicToEvpPubKey: EVP_PKEY failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_set1_EC_KEY(*evpPubkey, ecKey);\n\tif (irc != 1) {\n\t    printf(\"convertEcPublicToEvpPubKey: \"\n\t\t   \"Error converting public key from EC to EVP format\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (ecGroup != NULL) {\n\tEC_GROUP_free(ecGroup);\t/* @4 */\n    }\n    if (ecKey != NULL) {\n\tEC_KEY_free(ecKey);\t/* @1 */\n    }\n    if (x != NULL) {\n\tBN_free(x);\t\t/* @2 */\n    }\n    if (y != NULL) {\n\tBN_free(y);\t\t/* @3 */\n    }\n    return rc;\n}\n\n#endif\n\n/* convertEcTPMTPublicToEvpPubKey() converts an EC TPMT_PUBLIC to an EVP_PKEY.  The only items used\n   from the TPMT_PUBLIC are the curveID and X and Y points.\n\n   This is the replacement for convertEcPublicToEvpPubKey().\n */\n\nTPM_RC convertEcTPMTPublicToEvpPubKey(EVP_PKEY **evpPubkey,\t\t/* freed by caller */\n\t\t\t\t      const TPMT_PUBLIC *tpmtPublic)\n{\n    TPM_RC \trc = 0;\n    int\t\tirc;\n    BIGNUM \t*x = NULL;\t\t/* freed @1 */\n    BIGNUM \t*y = NULL;\t\t/* freed @2 */\n    int\t\tnid;\n    EC_GROUP \t*ecGroup = NULL;\t/* freed @4 */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    EC_KEY \t*ecKey = NULL;\t\t/* freed @3 */\n#else\n    EC_POINT\t\t*ecPoint = NULL;\n    uint8_t\t\t*pubBin = NULL;\t/* freed @7 */\n    size_t\t\tpubBinLength;\n    EVP_PKEY_CTX \t*ctx = NULL;\t\t/* freed @5 */\n    OSSL_PARAM_BLD \t*param_bld = NULL;\t/* freed @8 */\n    OSSL_PARAM \t\t*params = NULL;\t\t/* freed @6 */\n    const char \t\t*curveString = NULL;\n#endif\n    if (rc == 0) {\n\trc = convertBin2Bn(&x,\t\t\t\t/* freed @1 */\n\t\t\t   tpmtPublic->unique.ecc.x.t.buffer,\n\t\t\t   tpmtPublic->unique.ecc.x.t.size);\n    }\n    if (rc == 0) {\n\trc = convertBin2Bn(&y,\t\t\t\t/* freed @2 */\n\t\t\t   tpmtPublic->unique.ecc.y.t.buffer,\n\t\t\t   tpmtPublic->unique.ecc.y.t.size);\n    }\n    /* map from the TCG curve to the openssl nid */\n    if (rc == 0) {\n\trc = getEcNid(&nid, tpmtPublic->parameters.eccDetail.curveID);\n    }\n    if (rc == 0) {\n\tecGroup = EC_GROUP_new_by_curve_name(nid);\t/* freed @4 */\n\tif (ecGroup == NULL) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: Error in EC_GROUP_new_by_curve_name\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n\tecKey = EC_KEY_new();\t\t\t\t/* freed @3 */\n\tif (ecKey == NULL) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: Error creating EC_KEY\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\t/* returns void */\n\tEC_GROUP_set_asn1_flag(ecGroup, OPENSSL_EC_NAMED_CURVE);\n    }\n    /* assign curve to EC_KEY */\n    if (rc == 0) {\n\tirc = EC_KEY_set_group(ecKey, ecGroup);\n\tif (irc != 1) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: Error in EC_KEY_set_group\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EC_KEY_set_public_key_affine_coordinates(ecKey, x, y);\n\tif (irc != 1) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: \"\n\t\t   \"Error converting public key from X Y to EC_KEY format\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\t*evpPubkey = EVP_PKEY_new();\t\t/* freed by caller */\n\tif (*evpPubkey == NULL) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: EVP_PKEY failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_set1_EC_KEY(*evpPubkey, ecKey);\n\tif (irc != 1) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: \"\n\t\t   \"Error converting public key from EC to EVP format\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n#else\n    /* see EVP_PKEY-EC.html for constants */\n    if (rc == 0) {\n\tecPoint = EC_POINT_new(ecGroup);\t\t/* freed @4 */\n\tif (ecPoint== NULL) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: EC_POINT_new failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EC_POINT_set_affine_coordinates(ecGroup, ecPoint, x, y, NULL);\n\tif (irc != 1) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: \"\n\t\t   \"Error converting public key from X Y to EC_KEY format\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tpubBinLength = EC_POINT_point2buf(ecGroup, ecPoint,\n\t\t\t\t\t  POINT_CONVERSION_COMPRESSED,\n\t\t\t\t\t  &pubBin, NULL);\t/* freed @7 */\n\tif (pubBinLength == 0) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: \"\n\t\t   \"Error in EC_POINT_point2buf\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tparam_bld = OSSL_PARAM_BLD_new();\t\t/* freed @8 */\n\tif (param_bld == NULL) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey; \"\n\t\t   \"Error in OSSL_PARAM_BLD_new\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\trc = getEcCurveString(&curveString, nid);\n    }\n    if (rc == 0) {\n\tirc = OSSL_PARAM_BLD_push_utf8_string(param_bld, OSSL_PKEY_PARAM_GROUP_NAME,\n\t\t\t\t\t      curveString, 0);\n\tif (irc != 1) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey; \"\n\t\t   \"Error in OSSL_PARAM_BLD_push_utf8_string\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = OSSL_PARAM_BLD_push_octet_string(param_bld, OSSL_PKEY_PARAM_PUB_KEY,\n\t\t\t\t\t       pubBin, pubBinLength);\n  \tif (irc != 1) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey; \"\n\t\t   \"Error in OSSL_PARAM_BLD_push_utf8_string\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tparams = OSSL_PARAM_BLD_to_param(param_bld);\t\t/* freed @6 */\n\tif (params == NULL) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: \"\n\t\t   \"Error in OSSL_PARAM_BLD_to_param()\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tctx = EVP_PKEY_CTX_new_from_name(NULL, \"EC\", NULL);\t/* freed @5 */\n\tif (ctx == NULL) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: \"\n\t\t   \"Error in EVP_PKEY_CTX_new_from_name()\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_fromdata_init(ctx);\n\tif (irc != 1) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: \"\n\t\t   \"Error in EVP_PKEY_fromdata_init()\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_fromdata(ctx, evpPubkey,\t\t\t/* freed by caller */\n\t\t\t\tEVP_PKEY_PUBLIC_KEY, params);\n\tif (irc != 1) {\n\t    printf(\"convertEcTPMTPublicToEvpPubKey: \"\n\t\t   \"Error in EVP_PKEY_fromdata()\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n#endif\n    BN_free(x);\t\t\t/* @1 */\n    BN_free(y);\t\t\t/* @2 */\n    EC_GROUP_free(ecGroup);\t/* @4 */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (ecKey != NULL) {\n\tEC_KEY_free(ecKey);\t/* @3 */\n    }\n#else\n    OSSL_PARAM_BLD_free(param_bld);;\t/* @8 */\n    OSSL_PARAM_free(params); \t\t/* @6 */\n    EVP_PKEY_CTX_free(ctx);\t\t/* @5 */\n    OPENSSL_free(pubBin);\t\t/* @7 */\n#endif\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif  /* TPM_TPM20 */\n\n#ifndef TPM_TSS_NOFILE\n\nTPM_RC convertEvpPubkeyToPem(EVP_PKEY *evpPubkey,\n\t\t\t     const char *pemFilename)\n{\n    TPM_RC \trc = 0;\n    int\t\tirc;\n    FILE \t*pemFile = NULL; \n    \n    if (rc == 0) {\n\tpemFile = fopen(pemFilename, \"wb\");\t/* close @1 */\n\tif (pemFile == NULL) {\n\t    printf(\"convertEvpPubkeyToPem: Unable to open PEM file %s for write\\n\", pemFilename);\n\t    rc = TSS_RC_FILE_OPEN;\n\t}\n    }\n    if (rc == 0) {\n\tirc = PEM_write_PUBKEY(pemFile, evpPubkey);\n\tif (irc == 0) {\n\t    printf(\"convertEvpPubkeyToPem: Unable to write PEM file %s\\n\", pemFilename);\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    if (pemFile != NULL) {\n\tfclose(pemFile);\t\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\n#ifndef TPM_TSS_NOFILE\n\n/* verifySignatureFromPem() verifies the signature 'tSignature' against the digest 'message' using\n   the public key in the PEM format file 'pemFilename'.\n\n*/\n\nTPM_RC verifySignatureFromPem(unsigned char *message,\n\t\t\t      unsigned int messageSize,\n\t\t\t      TPMT_SIGNATURE *tSignature,\n\t\t\t      TPMI_ALG_HASH halg,\n\t\t\t      const char *pemFilename)\n{\n    TPM_RC \t\trc = 0;\n    EVP_PKEY \t\t*evpPkey = NULL;        /* OpenSSL public key, EVP format */\n#ifdef TPM_TSS_NORSA\n    halg = halg;\n#endif /* TPM_TSS_NORSA */\n\n    /* read the public key from PEM format */\n    if (rc == 0) {\n\trc = convertPemToEvpPubKey(&evpPkey,\t\t/* freed @1*/\n\t\t\t\t   pemFilename);\n    }\n    /* RSA or EC */\n    if (rc == 0) {\n\tswitch(tSignature->sigAlg) {\n#ifndef TPM_TSS_NORSA\n\t  case TPM_ALG_RSASSA:\n\t  case TPM_ALG_RSAPSS:\n\t    rc = verifyRSASignatureFromEvpPubKey(message,\n\t\t\t\t\t\t messageSize,\n\t\t\t\t\t\t tSignature,\n\t\t\t\t\t\t halg,\n\t\t\t\t\t\t evpPkey);\n\t    break;\n#endif /* TPM_TSS_NORSA */\n#ifndef TPM_TSS_NOECC\n\t  case TPM_ALG_ECDSA:\n\t    rc = verifyEcSignatureFromEvpPubKey(message,\n\t\t\t\t\t\tmessageSize,\n\t\t\t\t\t\ttSignature,\n\t\t\t\t\t\tevpPkey);\n\t    break;\n#endif\t/* TPM_TSS_NOECC */\n\t  default:\n\t    printf(\"verifySignatureFromPem: Unknown signature algorithm %04x\\n\", tSignature->sigAlg);\n\t    rc = TSS_RC_BAD_SIGNATURE_ALGORITHM;\n\t}\n    }\n    if (evpPkey != NULL) {\n\tEVP_PKEY_free(evpPkey);\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\n\n#ifndef TPM_TSS_NORSA\n\n/* verifyRSASignatureFromEvpPubKey() verifies the signature 'tSignature' against the digest\n   'message' using the RSA public key in evpPkey.\n\n*/\n\nTPM_RC verifyRSASignatureFromEvpPubKey(unsigned char *message,\n\t\t\t\t       unsigned int messageSize,\n\t\t\t\t       TPMT_SIGNATURE *tSignature,\n\t\t\t\t       TPMI_ALG_HASH halg,\n\t\t\t\t       EVP_PKEY *evpPkey)\n{\n    TPM_RC \t\trc = 0;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    RSA \t\t*rsaPubKey = NULL;\t/* OpenSSL public key, RSA format */\n\n    /* construct the RSA key token */\n    if (rc == 0) {\n\trsaPubKey = EVP_PKEY_get1_RSA(evpPkey);\t/* freed @1 */\n\tif (rsaPubKey == NULL) {\n\t    printf(\"verifyRSASignatureFromEvpPubKey: EVP_PKEY_get1_RSA failed\\n\");\n\t    rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n#else\n    EVP_PKEY *rsaPubKey = evpPkey;\n#endif\n    if (rc == 0) {\n\trc = verifyRSASignatureFromRSA(message,\n\t\t\t\t       messageSize,\n\t\t\t\t       tSignature,\n\t\t\t\t       halg,\n\t\t\t\t       rsaPubKey);\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    TSS_RsaFree(rsaPubKey);          \t/* @1 */\n#endif\n    return rc;\n}\n\n/* signRSAFromRSA() signs digest to signature, using rsaKey. \n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nTPM_RC signRSAFromRSA(uint8_t *signature, size_t *signatureLength,\n\t\t      size_t signatureSize,\n\t\t      const uint8_t *digest, size_t digestLength,\n\t\t      TPMI_ALG_HASH hashAlg,\n\t\t      void *rsaKey)\n{\n    TPM_RC \t\trc = 0;\n    int\t\t\tirc;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    int\t\t\tnid;\t\t\t/* openssl hash algorithm */\n\n    /* map the hash algorithm to the openssl NID */\n    if (rc == 0) {\n\tswitch (hashAlg) {\n#ifndef TPM_TSS_NODEPRECATEDALGS\n\t  case TPM_ALG_SHA1:\n\t    nid = NID_sha1;\n\t    break;\n#endif\n\t  case TPM_ALG_SHA256:\n\t    nid = NID_sha256;\n\t    break;\n\t  case TPM_ALG_SHA384:\n\t    nid = NID_sha384;\n\t    break;\n\t  case TPM_ALG_SHA512:\n\t    nid = NID_sha512;\n\t    break;\n\t  default:\n\t    printf(\"signRSAFromRSA: Error, hash algorithm %04hx unsupported\\n\", hashAlg);\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n    /* validate that the length of the resulting signature will fit in the\n       signature array */\n    if (rc == 0) {\n\tunsigned int keySize = RSA_size(rsaKey);\n\tif (keySize > signatureSize) {\n\t    printf(\"signRSAFromRSA: Error, private key length %u > signature buffer %u\\n\",\n\t\t   keySize, (unsigned int)signatureSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\tunsigned int siglen;\n\tirc = RSA_sign(nid,\n\t\t       digest, (unsigned int)digestLength,\n\t\t       signature, &siglen,\n\t\t       rsaKey);\n\t*signatureLength = siglen;\n\tif (irc != 1) {\n\t    printf(\"signRSAFromRSA: Error in OpenSSL RSA_sign()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n#else\n    EVP_PKEY_CTX \t*ctx = NULL;\n    const EVP_MD \t*md = NULL;\n\n    if (rc == 0) {\n\tctx = EVP_PKEY_CTX_new(rsaKey, NULL);\t\t/* freed @1 */\n\tif (ctx == NULL) {\n\t    printf(\"signRSAFromRSA: Error in EVP_PKEY_CTX_new()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_sign_init(ctx);\n\tif (irc != 1) {\n\t    printf(\"signRSAFromRSA: Error in EVP_PKEY_sign_init()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Hash_GetMd(&md, hashAlg);\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_CTX_set_signature_md(ctx, md);\n\tif (irc <= 0) {\n\t    printf(\"signRSAFromRSA: Error in EVP_PKEY_CTX_set_signature_md()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING);\n\tif (irc <= 0) {\n\t    printf(\"signRSAFromRSA: Error in EVP_PKEY_CTX_set_rsa_padding()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    if (rc == 0) {\n\tsize_t siglen = signatureSize;\n\tirc = EVP_PKEY_sign(ctx,\n\t\t\t    signature,  &siglen,\n\t\t\t    digest, (unsigned int)digestLength);\n\t*signatureLength = siglen;\n\tif (irc != 1) {\n\t    printf(\"signRSAFromRSA: Error in EVP_PKEY_sign()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    EVP_PKEY_CTX_free(ctx);\t/* @1 */\n#endif\n    return rc;\n}\n\n/* verifyRSASignatureFromRSA() verifies the signature 'tSignature' against the digest 'message'\n   using the RSA public key in the OpenSSL EVP_PKEY or RSA format.\n\n   Supports RSASSA and RSAPSS schemes.\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nTPM_RC verifyRSASignatureFromRSA(unsigned char *message,\n\t\t\t\t unsigned int messageSize,\n\t\t\t\t TPMT_SIGNATURE *tSignature,\n\t\t\t\t TPMI_ALG_HASH halg,\n\t\t\t\t void *rsaPubKey)\n{\n    TPM_RC \t\trc = 0;\n    int\t\t\tirc;\n    const EVP_MD \t*md = NULL;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    int \t\tnid = 0;\t/* initialized these two to suppress false gcc -O3\n\t\t\t\t\t   warnings */\n    /* map from hash algorithm to openssl nid */\n    if (rc == 0) {\n\tswitch (halg) {\n#ifndef TPM_TSS_NODEPRECATEDALGS\n\t  case TPM_ALG_SHA1:\n\t    nid = NID_sha1;\n\t    md = EVP_sha1();\n\t    break;\n#endif\n\t  case TPM_ALG_SHA256:\n\t    nid = NID_sha256;\n\t    md = EVP_sha256();\n\t    break;\n\t  case TPM_ALG_SHA384:\n\t    nid = NID_sha384;\n\t    md = EVP_sha384();\n\t    break;\n\t  case TPM_ALG_SHA512:\n\t    nid = NID_sha512;\n\t    md = EVP_sha512();\n\t    break;\n\t  default:\n\t    printf(\"verifyRSASignatureFromRSA: Unknown hash algorithm %04x\\n\", halg);\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n    /* verify the signature */\n    if (tSignature->sigAlg == TPM_ALG_RSASSA) {\n\tif (rc == 0) {\n\t    irc = RSA_verify(nid,\n\t\t\t     message, messageSize,\n\t\t\t     tSignature->signature.rsassa.sig.t.buffer,\n\t\t\t     tSignature->signature.rsassa.sig.t.size,\n\t\t\t     rsaPubKey);\n\t    if (irc != 1) {\n\t\tprintf(\"verifyRSASignatureFromRSA: Bad signature\\n\");\n\t\trc = TSS_RC_RSA_SIGNATURE;\n\t    }\n\t}\n    }\n    else if (tSignature->sigAlg == TPM_ALG_RSAPSS) {\n\tuint8_t decryptedSig[sizeof(tSignature->signature.rsapss.sig.t.buffer)];\n\tif (rc == 0) {\n\t    irc = RSA_public_decrypt(tSignature->signature.rsapss.sig.t.size,\n\t\t\t\t     tSignature->signature.rsapss.sig.t.buffer,\n\t\t\t\t     decryptedSig,\n\t\t\t\t     rsaPubKey,\n\t\t\t\t     RSA_NO_PADDING);\n\t    if (irc == -1) {\n\t\tprintf(\"verifyRSASignatureFromRSA: RSAPSS Bad signature\\n\");\n\t\trc = TSS_RC_RSA_SIGNATURE;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    irc = RSA_verify_PKCS1_PSS(rsaPubKey,\n\t\t\t\t       message,\n\t\t\t\t       md,\n\t\t\t\t       decryptedSig,\n\t\t\t\t       -2); /* salt length recovered from signature*/\n\t    if (irc != 1) {\n\t\tprintf(\"verifyRSASignatureFromRSA: RSAPSS Bad signature\\n\");\n\t\trc = TSS_RC_RSA_SIGNATURE;\n\t    }\n\t}\n    }\n    else {\n\tprintf(\"verifyRSASignatureFromRSA: Bad signature scheme %04x\\n\",\n\t       tSignature->sigAlg);\n\trc = TSS_RC_RSA_SIGNATURE;\n    }\n#else\n    EVP_PKEY_CTX \t*ctx = NULL;\n\n    if (rc == 0) {\n\tctx = EVP_PKEY_CTX_new(rsaPubKey, NULL);\t/* freed @1 */\n\tif (ctx == NULL) {\n\t    printf(\"verifyRSAFSignatureromRSA: Error in EVP_PKEY_CTX_new()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_verify_init(ctx);\n\tif (irc != 1) {\n\t    printf(\"verifyRSASignatureFromRSA: Error in EVP_PKEY_verify_init()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Hash_GetMd(&md, halg);\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_CTX_set_signature_md(ctx, md);\n\tif (irc <= 0) {\n\t    printf(\"verifyRSASignatureFromRSA: Error in EVP_PKEY_CTX_set_signature_md()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    /* verify the signature */\n    if (rc == 0) {\n\tif (tSignature->sigAlg == TPM_ALG_RSASSA) {\n\t    irc = EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING);\n\t}\n\telse if (tSignature->sigAlg == TPM_ALG_RSAPSS) {\n\t    irc = EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PSS_PADDING);\n\t}\n\telse {\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t    \tprintf(\"verifyRSASignatureFromRSA: Bad signature scheme %04x\\n\",\n\t\t       tSignature->sigAlg);\n\t}\n    }\n    if (rc == 0) {\n\tif (irc <= 0) {\n\t    printf(\"verifyRSASignatureFromRSA: Error in EVP_PKEY_CTX_set_rsa_padding()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_verify(ctx,\n\t\t\t      tSignature->signature.rsapss.sig.t.buffer,\n\t\t\t      tSignature->signature.rsapss.sig.t.size,\n\t\t\t      message, messageSize);\n \tif (irc != 1) {\n\t    printf(\"verifyRSASignatureFromRSA: Error in EVP_PKEY_verify()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    EVP_PKEY_CTX_free(ctx);\t/* @1 */\n#endif\n   return rc;\n}\n\n/* verifyRSASignatureFromRSA3() verifies the signature 'tSignature' against the digest 'message'\n   using the RSA public key in the OpenSSL EVP_PKEY format.\n\n   Supports RSASSA and RSAPSS schemes.\n\n   rsaPubKey is an EVP_PKEY,\n\n   Differs from verifyRSASignatureFromRSA3(), where the public key is openssl version dependent.\n*/\n\nTPM_RC verifyRSASignatureFromRSA3(const unsigned char *message,\n\t\t\t\t  unsigned int messageSize,\n\t\t\t\t  TPMT_SIGNATURE *tSignature,\n\t\t\t\t  TPMI_ALG_HASH halg,\n\t\t\t\t  void *rsaPubKey)\n{\n    TPM_RC \t\trc = 0;\n    int\t\t\tirc;\n    const EVP_MD \t*md = NULL;\n    EVP_PKEY_CTX \t*ctx = NULL;\n\n    if (rc == 0) {\n\tctx = EVP_PKEY_CTX_new(rsaPubKey, NULL);\t/* freed @1 */\n\tif (ctx == NULL) {\n\t    printf(\"verifyRSAFSignatureromRSA3: Error in EVP_PKEY_CTX_new()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_verify_init(ctx);\n\tif (irc != 1) {\n\t    printf(\"verifyRSASignatureFromRSA3: Error in EVP_PKEY_verify_init()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Hash_GetMd(&md, halg);\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_CTX_set_signature_md(ctx, md);\n\tif (irc <= 0) {\n\t    printf(\"verifyRSASignatureFromRSA3: Error in EVP_PKEY_CTX_set_signature_md()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    /* verify the signature */\n    if (rc == 0) {\n\tif (tSignature->sigAlg == TPM_ALG_RSASSA) {\n\t    irc = EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING);\n\t}\n\telse if (tSignature->sigAlg == TPM_ALG_RSAPSS) {\n\t    irc = EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PSS_PADDING);\n\t}\n\telse {\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t    printf(\"verifyRSASignatureFromRSA3: Bad signature scheme %04x\\n\",\n\t\t   tSignature->sigAlg);\n\t}\n    }\n    if (rc == 0) {\n\tif (irc <= 0) {\n\t    printf(\"verifyRSASignatureFromRSA3: Error in EVP_PKEY_CTX_set_rsa_padding()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_verify(ctx,\n\t\t\t      tSignature->signature.rsapss.sig.t.buffer,\n\t\t\t      tSignature->signature.rsapss.sig.t.size,\n\t\t\t      message, messageSize);\n \tif (irc != 1) {\n\t    printf(\"verifyRSASignatureFromRSA3: Error in EVP_PKEY_verify()\\n\");\n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n    }\n    EVP_PKEY_CTX_free(ctx);\t/* @1 */\n    return rc;\n}\n\n#endif /* TPM_TSS_NORSA */\n\n#ifndef TPM_TSS_NOECC\n\n/* verifyEcSignatureFromEvpPubKey() verifies the signature 'tSignature' against the digest 'message'\n   using the EC public key in evpPkey.\n\n*/\n\nTPM_RC verifyEcSignatureFromEvpPubKey(unsigned char *message,\n\t\t\t\t      unsigned int messageSize,\n\t\t\t\t      TPMT_SIGNATURE *tSignature,\n\t\t\t\t      EVP_PKEY *evpPkey)\n{\n    TPM_RC \t\trc = 0;\n    int\t\t\tirc;\n    BIGNUM \t\t*r = NULL;\n    BIGNUM \t\t*s = NULL;\n    ECDSA_SIG \t\t*ecdsaSig = NULL;\n    uint8_t \t\t*signature = NULL;\n    int \t\tsignatureSize;\n    EVP_PKEY_CTX \t*ctx = NULL;\n\n    /* construct the ECDSA_SIG signature token */\n    if (rc == 0) {\n\trc = convertBin2Bn(&r,\t\t\t/* freed @2 */\n\t\t\t   tSignature->signature.ecdsa.signatureR.t.buffer,\n\t\t\t   tSignature->signature.ecdsa.signatureR.t.size);\n    }\n    if (rc == 0) {\n\trc = convertBin2Bn(&s,\t\t\t/* freed @2 */\n\t\t\t   tSignature->signature.ecdsa.signatureS.t.buffer,\n\t\t\t   tSignature->signature.ecdsa.signatureS.t.size);\n    }\n    /* ECDSA_SIG_new() allocates an empty ECDSA_SIG structure.  */\n    if (rc == 0) {\n\tecdsaSig = ECDSA_SIG_new(); \t\t/* freed @2 */\n\tif (ecdsaSig == NULL) {\n\t    printf(\"verifyEcSignatureFromEvpPubKey: Error creating ECDSA_SIG_new\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tint irc = ECDSA_SIG_set0(ecdsaSig, r, s);\n\tif (irc != 1) {\n            printf(\"verifyEcSignatureFromEvpPubKey: Error in ECDSA_SIG_set0()\\n\");\n            rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* serialize the signature */\n    if (rc == 0) {\n\tsignatureSize = i2d_ECDSA_SIG(ecdsaSig, &signature);\t/* freed @3 */\n\tif (signatureSize < 0) {\n\t    printf(\"verifyEcSignatureFromEvpPubKey: Signature serialization failed\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* verify the signature */\n    if (rc == 0) {\n\tctx = EVP_PKEY_CTX_new(evpPkey, NULL);\t/* freed @1 */\n\tif (ctx == NULL) {\n\t    printf(\"verifyEcSignatureFromEvpPubKey: Error in EVP_PKEY_CTX_new()\\n\");\n\t    rc =TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_verify_init(ctx);\n\tif (irc != 1) {\n\t    printf(\"verifyEcSignatureFromEvpPubKey: Error in EVP_PKEY_verify_init()\\n\");\n\t    rc = TSS_RC_EC_SIGNATURE;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_verify(ctx,\n\t\t\t      signature, signatureSize,\n\t\t\t      message, messageSize);\n\tif (irc != 1) {\n\t    printf(\"verifyEcSignatureFromEvpPubKey: Error in EVP_PKEY_verify()\\n\");\n\t    rc = TSS_RC_EC_SIGNATURE;\n\t}\n    }\n    EVP_PKEY_CTX_free(ctx);\t\t/* @1 */\n    OPENSSL_free(signature);\t\t/* @3 */\n    /* if the ECDSA_SIG was allocated correctly, r and s are implicitly freed */\n    if (ecdsaSig != NULL) {\n\tECDSA_SIG_free(ecdsaSig);\t/* @2 */\n    }\n    /* if not, explicitly free */\n    else {\n\tif (r != NULL) BN_free(r);\t/* @2 */\n\tif (s != NULL) BN_free(s);\t/* @2 */\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n\n#ifndef TPM_TSS_NOFILE\n\n/* verifySignatureFromHmacKey() verifies the signature (MAC) against the digest 'message'\n   using the HMAC key in raw binary format.\n*/\n\nTPM_RC verifySignatureFromHmacKey(unsigned char *message,\n\t\t\t\t  unsigned int messageSize,\n\t\t\t\t  TPMT_SIGNATURE *tSignature,\n\t\t\t\t  TPMI_ALG_HASH halg,\n\t\t\t\t  const char *hmacKeyFilename)\n{\n    TPM_RC \t\trc = 0;\n    TPM2B_KEY \t\thmacKey;\n    uint32_t \t\tsizeInBytes;\n    \n    /* read the HMAC key */\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&hmacKey.b,\n\t\t\t     sizeof(hmacKey.t.buffer),\n\t\t\t     hmacKeyFilename);\n    }\n    if (rc == 0) {\n\tsizeInBytes = TSS_GetDigestSize(halg);\n\trc = TSS_HMAC_Verify(&tSignature->signature.hmac,\n\t\t\t     &hmacKey,\t\t/* input HMAC key */\n\t\t\t     sizeInBytes,\n\t\t\t     messageSize, message,\n\t\t\t     0, NULL);\n    }\n    return rc;\n}\n\n#endif /* TPM_TSS_NOFILE */\n\n/* convertRsaBinToTSignature() converts an RSA binary signature to a TPMT_SIGNATURE */\n\nTPM_RC convertRsaBinToTSignature(TPMT_SIGNATURE *tSignature,\n\t\t\t\t TPMI_ALG_HASH halg,\n\t\t\t\t const uint8_t *signatureBin,\n\t\t\t\t size_t signatureBinLen)\n{\n    TPM_RC rc = 0;\n\n    /* check that the signature size agrees with the TPMT_SIGNATURE  */\n    if (rc == 0) {\n\tsize_t signatureBinMax = sizeof(((TPMS_SIGNATURE_RSA *)NULL)->sig.t.buffer);\n\tif (signatureBinLen > signatureBinMax) {\n\t    printf(\"convertRsaBinToTSignature: signature length %lu greater than %lu\\n\",\n\t\t   (unsigned long)signatureBinLen, (unsigned long)signatureBinMax);\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    if (rc == 0) {\n\ttSignature->sigAlg = TPM_ALG_RSASSA;\n\ttSignature->signature.rsassa.hash = halg;\n\ttSignature->signature.rsassa.sig.t.size = (uint16_t)signatureBinLen;\n\tmemcpy(&tSignature->signature.rsassa.sig.t.buffer, signatureBin, signatureBinLen);\n    }\n    return rc;\n}\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* convertEcBinToTSignature() converts an EC binary signature to a TPMT_SIGNATURE */\n\nTPM_RC convertEcBinToTSignature(TPMT_SIGNATURE *tSignature,\n\t\t\t\tTPMI_ALG_HASH halg,\n\t\t\t\tconst uint8_t *signatureBin,\n\t\t\t\tsize_t signatureBinLen)\n{\n    TPM_RC rc = 0;\n    ECDSA_SIG \t\t*ecSig = NULL;\n    uint16_t\t\trBytes;\n    uint16_t \t\tsBytes;\n    const BIGNUM \t*pr = NULL;\n    const BIGNUM \t*ps = NULL;\n    \n    if (rc == 0) {\n\ttSignature->sigAlg = TPM_ALG_ECDSA;\n\ttSignature->signature.ecdsa.hash = halg;\n    }\n    /* convert DER to ECDSA_SIG */\n    if (rc == 0) {\n\tecSig = d2i_ECDSA_SIG(NULL, &signatureBin, (long)signatureBinLen);\t/* freed @1 */\n\tif (ecSig == NULL) {\n\t    printf(\"convertEcBinToTSignature: could not convert signature to ECDSA_SIG\\n\");\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    /* check that the signature size agrees with the currently hard coded P256 curve */\n    if (rc == 0) {\n\tECDSA_SIG_get0(ecSig, &pr, &ps);\n\trBytes = (uint16_t)BN_num_bytes(pr);\n\tsBytes = (uint16_t)BN_num_bytes(ps);\n\tif ((rBytes > sizeof(tSignature->signature.ecdsa.signatureR.t.buffer)) ||\n\t    (sBytes > sizeof(tSignature->signature.ecdsa.signatureS.t.buffer))) {\n\t    printf(\"convertEcBinToTSignature: signature rBytes %u or sBytes %u greater than %u\\n\",\n\t\t   rBytes, sBytes,\n\t\t   (unsigned int)sizeof(tSignature->signature.ecdsa.signatureR.t.buffer));\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    /* extract the raw signature bytes from the openssl structure BIGNUMs */\n    if (rc == 0) {\n\ttSignature->signature.ecdsa.signatureR.t.size = rBytes;\n\ttSignature->signature.ecdsa.signatureS.t.size = sBytes;\n\n\tBN_bn2bin(pr, (unsigned char *)&tSignature->signature.ecdsa.signatureR.t.buffer);\n\tBN_bn2bin(ps, (unsigned char *)&tSignature->signature.ecdsa.signatureS.t.buffer);\n\tif (tssUtilsVerbose) {\n\t    TSS_PrintAll(\"convertEcBinToTSignature: signature R\",\n\t\t\t tSignature->signature.ecdsa.signatureR.t.buffer,\n\t\t\t tSignature->signature.ecdsa.signatureR.t.size);\t\t\n\t    TSS_PrintAll(\"convertEcBinToTSignature: signature S\",\n\t\t\t tSignature->signature.ecdsa.signatureS.t.buffer,\n\t\t\t tSignature->signature.ecdsa.signatureS.t.size);\t\t\n\t}\n    }\n    if (ecSig != NULL) {\n\tECDSA_SIG_free(ecSig);\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n\n#ifndef TPM_TSS_NOECC\n\n/* getEcCurve() gets the TCG algorithm ID curve associated with the openssl EC_KEY.  Gets the length\n   of the private key (in bytes).\n*/\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\nstatic TPM_RC getEcCurve(TPMI_ECC_CURVE *curveID,\n\t\t\t int \t\t*privateKeyBytes, \n\t\t\t const EC_KEY \t*ecKey)\n{\n    TPM_RC \t\trc = 0;\n    const EC_GROUP \t*ecGroup;\n    int\t\t\tnid;\n\n    if (rc == 0) {\n\tecGroup = EC_KEY_get0_group(ecKey);\n\tnid = EC_GROUP_get_curve_name(ecGroup);\t/* openssl NID */\n\t/* NID to TCG curve ID */\n\tswitch (nid) {\n\t  case NID_X9_62_prime256v1:\n\t    *curveID = TPM_ECC_NIST_P256;\n\t    *privateKeyBytes = 32;\n\t    break;\n\t  case NID_secp384r1:\n\t    *curveID = TPM_ECC_NIST_P384;\n\t    *privateKeyBytes = 48;\n\t    break;\n\t  default:\n\t    printf(\"getEcCurve: Error, curve NID %u not supported \\n\", nid);\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    return rc;\n}\n\n#else\n\nstatic TPM_RC getEcCurve(TPMI_ECC_CURVE *curveID,\n\t\t\t int \t\t*privateKeyBytes,\n\t\t\t const EVP_PKEY *ecKey)\n{\n    TPM_RC  \trc = 0;\n    int\t\tirc;\n    char \tcurveName[64];\n\n    if (rc == 0) {\n\tirc = EVP_PKEY_get_utf8_string_param(ecKey, OSSL_PKEY_PARAM_GROUP_NAME,\n\t\t\t\t\t     curveName, sizeof(curveName), NULL);\n\tif (irc != 1) {\n\t    printf(\"getEcCurve: Error getting curve\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* FIXME make table */\n    if (rc == 0) {\n\tif (strcmp(curveName, \"prime256v1\") == 0) {\n\t    *curveID = TPM_ECC_NIST_P256;\n\t    *privateKeyBytes = 32;\n\t}\n\telse if (strcmp(curveName, \"secp384r1\") == 0) {\n\t    *curveID = TPM_ECC_NIST_P384;\n\t    *privateKeyBytes = 48;\n\t}\n\telse {\n\t    printf(\"getEcCurve: Error, curve %s not supported \\n\", curveName);\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\n\t}\n    }\n    return rc;\n}\n\n/* getEcCurveString() maps the TPM curve ID to the openssl utf-8 string */\n\nstatic TPM_RC getEcCurveString(const char **curveString,\n\t\t\t       int nid)\n{\n    TPM_RC  \trc = 0;\n\n    *curveString = OBJ_nid2sn(nid);\n    if (*curveString == NULL) {\n\tprintf(\"getEcCurveString: Error, nid %d not supported \\n\", nid);\n\trc = TSS_RC_EC_KEY_CONVERT;\n   }\n    return rc;\n}\n\n#endif\n\n/* getEcNid() gets the OpenSSL nid corresponding to the TCG algorithm ID curve */\n\nstatic TPM_RC getEcNid(int\t\t*nid,\n\t\t       TPMI_ECC_CURVE \tcurveID)\n{\n    TPM_RC \t\trc = 0;\n\n    switch (curveID) {\n      case TPM_ECC_NIST_P192:\n\t*nid = NID_X9_62_prime192v1;\t/* untested guess */\n\tbreak;\n      case TPM_ECC_NIST_P224:\n\t*nid = NID_secp224r1;\t\t/* untested guess */\n\tbreak;\n      case TPM_ECC_NIST_P256:\t\t/* TCG standard */\n\t*nid = NID_X9_62_prime256v1;\n\tbreak;\n      case TPM_ECC_NIST_P384:\t\t/* TCG standard */\n\t*nid = NID_secp384r1;\n\tbreak;\n      case TPM_ECC_NIST_P521:\n\t*nid = NID_secp521r1;\t\t/* untested guess */\n\tbreak;\n      case TPM_ECC_BN_P256:\n      case TPM_ECC_BN_P638:\n      case TPM_ECC_SM2_P256:\n      case TPM_ECC_BP_P256_R1:\n      case TPM_ECC_BP_P384_R1:\n      case TPM_ECC_BP_P512_R1:\n      case TPM_ECC_CURVE_25519:\n      default:\n\t*nid = NID_undef;\n\tprintf(\"getEcNid: Error, TCG curve %04x not supported \\n\", curveID);\n\trc = TSS_RC_EC_KEY_CONVERT;\n    }\n    return rc;\n}\n\n/* getEcModulusBytes() gets the modulus size and bytes on the point corresponding to the TCG\n   algorithm ID curve */\n\nstatic TPM_RC getEcModulusBytes(int\t*modulusBytes,\n\t\t\t\tint\t*pointBytes,\n\t\t\t\tTPMI_ECC_CURVE curveID)\n{\n    TPM_RC \t\trc = 0;\n\n    /* add 1 byte for point compression */\n    switch (curveID) {\n      case TPM_ECC_NIST_P192:\n\t*pointBytes = 24;\n\t*modulusBytes = 49;\t\t/* 1+24+24 untested guess */\n\tbreak;\n      case TPM_ECC_NIST_P224:\n\t*pointBytes = 28;\n\t*modulusBytes = 57;\t\t/* 1+28+28 untested guess */\n\tbreak;\n      case TPM_ECC_NIST_P256:\n\t*pointBytes = 32;\n\t*modulusBytes = 65;\t\t/* 1+32+32 TCG standard */\n\tbreak;\n      case TPM_ECC_NIST_P384:\n\t*pointBytes = 48;\n\t*modulusBytes = 97;\t\t/* 1+48+48 TCG standard */\n\tbreak;\n      case TPM_ECC_NIST_P521:\n      case TPM_ECC_BN_P256:\n      case TPM_ECC_BN_P638:\n      case TPM_ECC_SM2_P256:\n      case TPM_ECC_BP_P256_R1:\n      case TPM_ECC_BP_P384_R1:\n      case TPM_ECC_BP_P512_R1:\n      case TPM_ECC_CURVE_25519:\n      default:\n\t*modulusBytes = 0;\n\tprintf(\"getEcModulusBytes: Error, TCG curve %04x not supported \\n\", curveID);\n\trc = TSS_RC_EC_KEY_CONVERT;\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n#endif\n\n/* convertBin2Bn() wraps the openSSL function in an error handler\n\n   Converts a char array to bignum\n*/\n\nTPM_RC convertBin2Bn(BIGNUM **bn,\t\t\t/* freed by caller */\n\t\t     const unsigned char *bin,\n\t\t     unsigned int bytes)\n{\n    TPM_RC rc = 0;\n\n    /* BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);\n    \n       BN_bin2bn() converts the positive integer in big-endian form of length len at s into a BIGNUM\n       and places it in ret. If ret is NULL, a new BIGNUM is created.\n\n       BN_bin2bn() returns the BIGNUM, NULL on error.\n    */\n    if (rc == 0) {\n        *bn = BN_bin2bn(bin, bytes, *bn);\n        if (*bn == NULL) {\n            printf(\"convertBin2Bn: Error in BN_bin2bn\\n\");\n            rc = TSS_RC_BIGNUM;\n        }\n    }\n    return rc;\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/dictionaryattacklockreset.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    DictionaryAttackLockReset \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\t\trc = 0;\n    int\t\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    DictionaryAttackLockReset_In \tin;\n    const char\t\t\t\t*password = NULL; \n    TPMI_SH_AUTH_SESSION    \t\tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \t\tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \t\tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.lockHandle = TPM_RH_LOCKOUT;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_DictionaryAttackLockReset,\n\t\t\t sessionHandle0, password, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"dictionaryattacklockreset: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"dictionaryattacklockreset: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"dictionaryattacklockreset\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_DictionaryAttackLockReset\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwd\\tlockout auth password (default empty)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/dictionaryattackparameters.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    DictionaryAttackParameters \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\t\trc = 0;\n    int\t\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    DictionaryAttackParameters_In \tin;\n    const char\t\t\t\t*password = NULL;\n    uint32_t\t\t\t\tnewMaxTries = 1;\n    uint32_t\t\t\t\tnewRecoveryTime = 10;\n    uint32_t\t\t\t\tlockoutRecovery = 1;\n    TPMI_SH_AUTH_SESSION    \t\tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \t\tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \t\tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nmt\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnewMaxTries = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-nmt option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nrt\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnewRecoveryTime = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-nrt option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-lr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tlockoutRecovery = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-lr option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.lockHandle = TPM_RH_LOCKOUT;\n\tin.newMaxTries = newMaxTries ;\n\tin.newRecoveryTime = newRecoveryTime;\n\tin.lockoutRecovery = lockoutRecovery;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_DictionaryAttackParameters,\n\t\t\t sessionHandle0, password, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"dictionaryattackparameters: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"dictionaryattackparameters: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"dictionaryattackparameters\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_DictionaryAttackParameters\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwd\\tlockout auth password (default empty)]\\n\");\n    printf(\"\\t[-nmt\\tnew max tries (default 1 try)]\\n\");\n    printf(\"\\t[-nrt\\tnew recovery time (default 10 seconds)]\\n\");\n    printf(\"\\t[-lr\\tlockout recovery (default 1 second)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/duplicate.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Duplicate\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Duplicate_In \t\tin;\n    Duplicate_Out \t\tout;\n    TPMI_DH_OBJECT\t\tobjectHandle = 0;\n    TPMI_DH_OBJECT\t\tnewParentHandle = TPM_RH_NULL;\n    const char \t\t\t*encryptionKeyInFilename = NULL;\n    const char \t\t\t*encryptionKeyOutFilename = NULL;\n    const char\t\t\t*duplicateFilename = NULL;\n    const char\t\t\t*outSymSeedFilename = NULL;\n    const char\t\t\t*objectPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    /* Table 129 - Definition of TPMT_SYM_DEF_OBJECT Structure */\n    in.symmetricAlg.algorithm = TPM_ALG_NULL;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ho\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &objectHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ho\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdo\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tobjectPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdo option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &newParentHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ik\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tencryptionKeyInFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ik option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-salg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"aes\") == 0) {\n\t\t    in.symmetricAlg.algorithm = TPM_ALG_AES;\n\t\t    in.symmetricAlg.keyBits.aes = 128;\n\t\t    in.symmetricAlg.mode.aes = TPM_ALG_CFB;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -salg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-salg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oek\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tencryptionKeyOutFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oek option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-od\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tduplicateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-od option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oss\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutSymSeedFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oss option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (objectHandle == 0) {\n\tprintf(\"Missing or bad object handle parameter -ho\\n\");\n\tprintUsage();\n    }\n    if ((in.symmetricAlg.algorithm == TPM_ALG_NULL) &&\n\t(encryptionKeyInFilename != NULL)) {\n\tprintf(\"-ik needs -salg\\n\");\n\tprintUsage();\n    }\n    if ((in.symmetricAlg.algorithm != TPM_ALG_NULL) &&\n\t(encryptionKeyInFilename == NULL)) {\n\tprintf(\"-salg needs -ik\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.objectHandle = objectHandle;\n\tin.newParentHandle = newParentHandle;\n    }\n    /* optional symmetric encryption key */\n    if (encryptionKeyInFilename != NULL) {\n\trc = TSS_File_Read2B(&in.encryptionKeyIn.b,\n\t\t\t     sizeof(in.encryptionKeyIn.t.buffer),\n\t\t\t     encryptionKeyInFilename);\n    }\n    else {\n\tin.encryptionKeyIn.t.size = 0;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Duplicate,\n\t\t\t sessionHandle0, objectPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (encryptionKeyOutFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.encryptionKeyOut.t.buffer,\n\t\t\t\t      out.encryptionKeyOut.t.size,\n\t\t\t\t      encryptionKeyOutFilename);\n    }\n    if ((rc == 0) && (duplicateFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.duplicate.t.buffer,\n\t\t\t\t      out.duplicate.t.size,\n\t\t\t\t      duplicateFilename);\n    }\n    if ((rc == 0) && (outSymSeedFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.outSymSeed.t.secret,\n\t\t\t\t      out.outSymSeed.t.size,\n\t\t\t\t      outSymSeedFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"duplicate: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"duplicate: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"duplicate\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Duplicate\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ho\\tobject handle\\n\");\n    printf(\"\\t[-pwdo\\tpassword for object (default empty)]\\n\");\n    printf(\"\\t[-hp\\tnew parent handle (default TPM_RH_NULL)]\\n\");\n    printf(\"\\t[-ik\\tencryption key in file name]\\n\");\n    printf(\"\\t[-salg\\tsymmetric algorithm (aes)(default none)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-oek\\tencryption key out file name (default do not save)]\\n\");\n    printf(\"\\t[-od\\tduplicate private area file name (default do not save)]\\n\");\n    printf(\"\\t[-oss\\tsymmetric seed file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/eccdecrypt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   ECC_Decrypt\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2022\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ECC_Decrypt_In \t\tin;\n    ECC_Decrypt_Out \t\tout;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    const char\t\t\t*keyPassword = NULL;\n    const char\t\t\t*keyPasswordFilename = NULL;\n    uint8_t\t\t\t*keyPasswordBuffer = NULL;\n    size_t \t\t\tkeyPasswordBufferLength = 0;\n    const char\t\t\t*keyPasswordPtr = NULL;\n    const char\t\t\t*decryptFilename = NULL;\n    const char\t\t\t*c1Filename = NULL;\n    const char\t\t\t*c2Filename = NULL;\n    const char\t\t\t*c3Filename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    /* command line argument defaults */\n    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA256;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPasswordFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-od\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdecryptFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-od option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tc1Filename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic1 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tc2Filename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic2 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic3\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tc3Filename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic3 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if ((c1Filename == NULL) ||\n\t(c2Filename == NULL) ||\n\t(c3Filename  == NULL)) {\n\tprintf(\"Missing input -ic1 -ic2 -ic3\\n\");\n\tprintUsage();\n    }\n    if ((keyPassword != NULL) && (keyPasswordFilename != NULL)) {\n\tprintf(\"Only one of -pwdk and -ipwdk can be specified\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* use passsword from command line */\n\tif (keyPassword != NULL) {\n\t    keyPasswordPtr = keyPassword;\n\t}\n\t/* use password from file */\n\telse if (keyPasswordFilename != NULL) {\n\t    rc = TSS_File_ReadBinaryFile(&keyPasswordBuffer,     /* freed @2 */\n\t\t\t\t\t &keyPasswordBufferLength,\n\t\t\t\t\t keyPasswordFilename);\n\t    if ((keyPasswordBufferLength == 0) ||\n\t\t(keyPasswordBuffer[keyPasswordBufferLength -1] != '\\0')) {\n\t\tprintf(\"-ipwdk file must be nul terminated\\n\");\n\t\tprintUsage();\n\t    }\n\t    keyPasswordPtr = (const char *)keyPasswordBuffer;\n\t}\n\t/* empty password */\n\telse {\n\t    keyPasswordPtr = NULL;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    if ((rc == 0) && (c1Filename != NULL)) {\n\trc = TSS_File_ReadStructure(&in.C1,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPM2B_ECC_POINT_Unmarshalu,\n\t\t\t\t    c1Filename);\n    }\n    if ((rc == 0) && (c2Filename != NULL)) {\n\trc = TSS_File_ReadStructure(&in.C2,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPM2B_MAX_BUFFER_Unmarshalu,\n\t\t\t\t    c2Filename);\n    }\n    if ((rc == 0) && (c3Filename != NULL)) {\n \trc = TSS_File_ReadStructure(&in.C3,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPM2B_DIGEST_Unmarshalu,\n\t\t\t\t    c3Filename);\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform eccdecrypting */\n\tin.keyHandle = keyHandle;\n\t/* the only scheme that the TPM supports */\n\tin.inScheme.scheme = TPM_ALG_KDF2;\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n        printf(\"password is %s\\n\", keyPasswordPtr);\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ECC_Decrypt,\n\t\t\t sessionHandle0, keyPasswordPtr, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_File_WriteBinaryFile(out.plainText.t.buffer,\n\t\t\t\t      out.plainText.t.size,\n\t\t\t\t      decryptFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"eccdecrypt: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"eccdecrypt: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"eccdecrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ECC_Decrypt\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)[\\n\");\n    printf(\"\\t[-ipwdk\\tpassword file for key, nul terminated (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t-od\\tdecrypt file name\\n\");\n    printf(\"\\t-ic1\\tC1 ECC point file name\\n\");\n    printf(\"\\t-ic2\\tC2 data buffer file name\\n\");\n    printf(\"\\t-ic3\\tc3 integrity digest file name\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/eccencrypt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   ECC_Encrypt\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2022\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ECC_Encrypt_In \t\tin;\n    ECC_Encrypt_Out \t\tout;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    const char\t\t\t*decryptFilename = NULL;\n    const char\t\t\t*c1Filename = NULL;\n    const char\t\t\t*c2Filename = NULL;\n    const char\t\t\t*c3Filename = NULL;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    /* command line argument defaults */\n    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA256;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-id\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdecryptFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-id option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    in.inScheme.details.mgf1.hashAlg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oc1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tc1Filename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oc1 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oc2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tc2Filename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oc2 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oc3\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tc3Filename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oc3 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (decryptFilename == NULL) {\n\tprintf(\"Missing decrypted file -id\\n\");\n\tprintUsage();\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.plainText.b,\n\t\t\t     sizeof(in.plainText.t.buffer),\n\t\t\t     decryptFilename);\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform ecc encrypting */\n\tin.keyHandle = keyHandle;\n\t/* the only scheme that the TPM supports */\n\tin.inScheme.scheme = TPM_ALG_KDF2;\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ECC_Encrypt,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (c1Filename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.C1,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_ECC_POINT_Marshalu,\n\t\t\t\t     c1Filename);\n    }\n    if ((rc == 0) && (c2Filename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.C2,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_MAX_BUFFER_Marshalu,\n\t\t\t\t     c2Filename);\n    }\n    if ((rc == 0) && (c3Filename != NULL)) {\n \trc = TSS_File_WriteStructure(&out.C3,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_DIGEST_Marshalu,\n\t\t\t\t     c3Filename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"eccencrypt: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"eccencrypt: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"eccencrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ECC_Encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t-id\\tdecrypt file name\\n\");\n    printf(\"\\t[-oc1\\tC1 ECC point file name (default do not save)]\\n\");\n    printf(\"\\t[-oc2\\tC2 data buffer file name (default do not save)]\\n\");\n    printf(\"\\t[-oc3\\tc3 integrity digest file name (default do not save)]\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/eccparameters.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   ECC_Parameters\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ECC_Parameters_In \t\tin;\n    ECC_Parameters_Out \t\tout;\n    const char \t\t\t*datafilename = NULL;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    in.curveID = TPM_ECC_NONE;\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-cv\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"bnp256\") == 0) {\n\t\t    in.curveID = TPM_ECC_BN_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp256\") == 0) {\n\t\t    in.curveID = TPM_ECC_NIST_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp384\") == 0) {\n\t\t    in.curveID = TPM_ECC_NIST_P384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -cv\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-cv option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i], \"-of\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdatafilename = argv[i];\n\t    } else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (in.curveID == TPM_ECC_NONE) {\n\tprintf(\"Missing or bad parameter for -cv\\n\");\n\tprintUsage();\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ECC_Parameters,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (datafilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.parameters,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMS_ALGORITHM_DETAIL_ECC_Marshalu,\n\t\t\t\t     datafilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"eccparameters: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"eccparameters: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"eccparameters\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ECC_Parameters\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-cv\\tcurve ID\\n\");\n    printf(\"\\t\\tbnp256\\n\");\n    printf(\"\\t\\tnistp256\\n\");\n    printf(\"\\t\\tnistp384\\n\");\n    printf(\"\\t[-of data file, ECC parameters (default do not save)]\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/ecephemeral.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    EC_Ephemeral\t\t\t\t\t*/\n/*\t     \t\tWritten by Bill Martin \t\t\t\t\t*/\n/*                 Green Hills Integrity Software Services \t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2017 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n/* \n\n\n */\n\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC \t\t\trc = 0;\n    int \t\t\ti;    /* argc iterator */\n    TSS_CONTEXT \t\t*tssContext = NULL;\n    EC_Ephemeral_In \t\tin;\n    EC_Ephemeral_Out            out;\n    TPMI_ECC_CURVE              curveID = TPM_ECC_NONE;\n    const char                  *QFilename = NULL;\n    const char                  *counterFilename = NULL;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i], \"-ecc\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"bnp256\") == 0) {\n\t\t    curveID = TPM_ECC_BN_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp256\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"nistp384\") == 0) {\n\t\t    curveID = TPM_ECC_NIST_P384;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -ecc\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-ecc option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n        else if (strcmp(argv[i], \"-oq\") == 0) {\n            i++;\n            if (i < argc) {\n                QFilename = argv[i];\n            } else {\n                printf(\"-oq option needs a value\\n\");\n                printUsage();\n            }\n        }\n        else if (strcmp(argv[i], \"-cf\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcounterFilename = argv[i];\n\t    } else {\n\t\tprintf(\"-cf option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (curveID == TPM_ECC_NONE) {\n\tprintf(\"Missing curve ID -ecc\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n        in.curveID = curveID;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n                         (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_EC_Ephemeral,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t} \n    }\n    if ((rc == 0) && (QFilename != NULL)) {\n        rc = TSS_File_WriteStructure(&out.Q,\n                                     (MarshalFunction_t)TSS_TPM2B_ECC_POINT_Marshalu,\n\t\t\t\t     QFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"counter is %d\\n\", out.counter);\n\tif (counterFilename != NULL)  {\n\t    rc = TSS_File_WriteStructure(&out.counter,\n\t\t\t\t\t (MarshalFunction_t)TSS_UINT16_Marshalu,\n\t\t\t\t\t counterFilename);\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"ecephemeral: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"ecephemeral: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"ecephmeral\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_EC_Ephemeral\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ecc\\tcurve\\n\");\n    printf(\"\\t\\tbnp256\\n\");\n    printf(\"\\t\\tnistp256\\n\");\n    printf(\"\\t\\tnistp384\\n\");\n    printf(\"\\t[-oq\\toutput Q ephemeral public key file name (default do not save)]\\n\");\n    printf(\"\\t[-cf\\toutput counter file name (default do not save)]\\n\");\n    exit(1); \n}\n"
  },
  {
    "path": "ibmtss-ftpm/efilib.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t     \tEFI Measurement Log Common Routines\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2021.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* This module parses UEFI pre-OS event logs.\n\n   A typical usage is:\n\n   TSS_EFIData_Init() - initialize the structure\n   TSS_EFIData_ReadBuffer() - unmarshal an event into the structure\n   TSS_EFIData_Free() - free the structure\n\n   After TSS_EFIData_ReadBuffer(), the structure can be called with:\n\n   TSS_EFIData_Trace() to pretty print the structure to stdout\n\n   TSS_EFIData_ToJson() to output json in some TBD format and destination.  This has not been\n   implemented.  There are some placeholders.\n\n   See TCG PC Client Platform Firmware Profile Specification (PFP)\n*/\n\n#include <stddef.h>\n#include <ctype.h>\n\n#ifndef TPM_TSS_NO_OPENSSL\n#include <openssl/x509.h>\n#endif\t/* TPM_TSS_NO_OPENSSL */\n\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tsscrypto.h>\n\n#include \"eventlib.h\"\n#include \"efilib.h\"\n\n/* Used for input sanity check.  Keep below ffff_ffff so that cast to uint32_t is safe */\n#define EFI_LENGTH_MAX 0x100000\n\n/* Some PFP event contents are not completely specified.  Use these functions to guess at the\n   contents. */\n\nstatic void isUCS2String(int *isUCS2, uint8_t *buffer, uint32_t length);\nstatic void isAsciiString(int *isAscii, uint8_t *buffer, uint32_t length);\n\n/*\n  GUID Handling\n*/\n\n/* standard GUID values */\n\n/* a5c059a1-94e4-4aa7-87b5-ab155c2bf072 */\n#define EFI_CERT_X509_GUID\t\t\t\t\\\n    {0xa1, 0x59, 0xc0, 0xa5, 0xe4, 0x94, 0xa7, 0x4a,\t\\\n     0x87, 0xb5, 0xab, 0x15, 0x5c, 0x2b, 0xf0, 0x72}\n/* 8be4df61-93ca-11d2-aa0d-00e098032b8c */\n#define EFI_GLOBAL_VARIABLE\t\t\t\t\\\n    {0x61, 0xdf, 0xe4, 0x8b, 0xca, 0x93, 0xd2, 0x11,\t\\\n     0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c}\n/* d719b2cb-3d3a-4596-a3bc-dad00e67656f */\n#define EFI_IMAGE_SECURITY_DATABASE_GUID\t\t\\\n    {0xcb, 0xb2, 0x19, 0xd7, 0x3a, 0x3d, 0x96, 0x45,\t\\\n     0xa3, 0xbc, 0xda, 0xd0, 0x0e, 0x67, 0x65, 0x6f}\n/* f2fd1544-9794-4a2c-992e-e5bbcf20e394 */\n#define SMBIOS3_TABLE_GUID\t\t\t\t\\\n    {0x44, 0x15, 0xfd, 0xf2, 0x94, 0x97, 0x2c, 0x4a,\t\\\n     0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94}\n/* 7facc7b6-127f-4e9c-9c5d-080f98994345 */\n#define LENOVO2_GUID\t\t\t\t\t\\\n    {0xb6, 0xc7, 0xac, 0x7f, 0x7f, 0x12, 0x9c, 0x4e,\t\\\n     0x9c, 0x5d, 0x08, 0x0f, 0x98, 0x99, 0x43, 0x45}\n/* 77fa9abd-0359-4d32-bd60-28f4e78f784b */\n#define MICROSOFT_GUID\t\t\t\t\t\\\n    {0xbd, 0x9a, 0xfa, 0x77, 0x59, 0x03, 0x32, 0x4d, \t\\\n     0xbd, 0x60, 0x28, 0xf4, 0xe7, 0x8f, 0x78, 0x4b}\n/* 3cc24e96-22c7-41d8-8863-8e39dcdcc2cf */\n#define LENOVO_GUID\t\t\t\t\t\\\n    {0x96, 0x4e, 0xc2, 0x3c, 0xc7, 0x22, 0xd8, 0x41, \t\\\n     0x88, 0x63, 0x8e, 0x39, 0xdc, 0xdc, 0xc2, 0xcf}\n/* 70564dce-9afc-4ee3-85fc-949649d7e45c */\n#define DELL_PK_SIGNING_KEY\t\t\t\t\\\n    {0xce, 0x4d, 0x56, 0x70, 0xfc, 0x9a, 0xe3, 0x4e,\t\\\n     0x85, 0xfc, 0x94, 0x96, 0x49, 0xd7, 0xe4, 0x5c}\n/* c1c41626-504c-4092-aca9-41f936934328\t*/\n#define SHA256_GUID\t\t\t\t\t\\\n    {0x26, 0x16, 0xc4, 0xc1, 0x4c, 0x50, 0x92, 0x40,\t\\\n     0xac, 0xa9, 0x41, 0xf9, 0x36, 0x93, 0x43, 0x28}\n#define EFI_MP_SERVICES_PROTOCOL_GUID\t\t\t\\\n    {0x05, 0xa6, 0xdd, 0x3f, 0x6e, 0xa7, 0x46, 0x4f,\t\\\n     0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08}\n/* c12a7328-f81f-11d2-ba4b-00a0c93ec93b */\n#define EFI_SYSTEM_PARTITION_GUID\t\t\t\\\n    {0x28, 0x73, 0x2a, 0xc1, 0x1f, 0xf8, 0xd2, 0x11,\t\\\n     0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} \n/* e3c9e316-0b5c-4db8-817d-f92df00215ae */\n#define MICROSOFT_RESERVED_PARTITION_GUID\t\t\\\n    {0x16, 0xe3, 0xc9, 0xe3, 0x5c, 0x0b, 0xb8, 0x4d,\t\\\n     0x81, 0x7d, 0xf9, 0x2d, 0xf0, 0x02, 0x15, 0xae}\n/* ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 */\n#define BASIC_DATA_PARTITION_GUID\t\t\t\\\n    {0xa2, 0xa0, 0xd0, 0xeb, 0xe5, 0xb9, 0x33, 0x44,\t\\\n     0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7}\n/* de94bba4-06d1-4d40-a16a-bfd50179d6ac */\n#define WINDOWS_RECOVERY_ENVIRONMENT_GUID\t\t\\\n    {0xa4, 0xbb, 0x94, 0xde, 0xd1, 0x06, 0x40, 0x4d,\t\\\n     0xa1, 0x6a, 0xbf, 0xd5, 0x01, 0x79, 0xd6, 0xac}\n/* 0fc63daf-8483-4772-8e79-3d69d8477de4 */\n#define LINUX_FILESYSTEM_DATA_GUID\t\t\t\\\n    {0xaf, 0x3d, 0xc6, 0x0f, 0x83, 0x84, 0x72, 0x47,\t\\\n     0x8e, 0x79, 0x3d, 0x69, 0xd8, 0x47, 0x7d, 0xe4}\n/* 21686148-6449-6e6f-744e-656564454649 */\n#define BIOS_BOOT_PARTITION_GUID\t\t\t\\\n    {0x48, 0x61, 0x68, 0x21, 0x49, 0x64, 0x6f, 0x6e,\t\\\n\t    0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49}\n/* 605dab50-e046-4300-abb6-3dd810dd8b23 */\n#define SHIM_LOCK_GUID\t\t\t\t\t\\\n    {0x50, 0xab, 0x5d, 0x60, 0x46, 0xe0, 0x00, 0x43,\t\\\n\t    0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23}\n\n#if 0\t/* future GUIDs to be supported */\n#define SMBIOS_TABLE_GUID    \t\t\t\"eb9d2d31-2d88-11d3-9a16-0090273fc14d\"\n#define EFI_ACPI_20_TABLE_GUID \t\t\t\"8868e871-e4f1-11d3-bc22-0080c73c8881\"\n#define ACPI_TABLE_GUID    \t\t\t\"eb9d2d30-2d88-11d3-9a16-0090273fc14d\"\n#define SAL_SYSTEM_TABLE_GUID    \t\t\"eb9d2d32-2d88-11d3-9a16-0090273fc14d\"\n#define MPS_TABLE_GUID    \t\t\t\"eb9d2d2f-2d88-11d3-9a16-0090273fc14d\"\n#define EFI_JSON_CONFIG_DATA_TABLE_GUID\t\t\"87367f87-1119-41ce-aaec-8be0111f558a\"\n#define EFI_JSON_CAPSULE_DATA_TABLE_GUID    \t\"35e7a725-8dd2-4cac-8011-33cda8109056\"\n#define EFI_JSON_CAPSULE_RESULT_TABLE_GUID    \t\"dbc461c3-b3de-422a-b9b4-9886fd49a1e5\"\n/* these may not be endian correct */\n#define GRUB_EFI_CONSOLE_CONTROL_GUID\t\t\"f42f7782-012e-4c12-9956-49f94304f721\"\n#define GRUB_EFI_PCI_IO_GUID\t\t\t\"4cf5b200-68b8-4ca5-9eec-b23e3f50029a\"\n#define GRUB_EFI_PCI_ROOT_IO_GUID\t\t\"2F707EBB-4A1A-11d4-9A38-0090273FC14D\"\n#define GRUB_EFI_LOADED_IMAGE_GUID\t\t\"5b1b31a1-9562-11d2-8e3f-00a0c969723b\"\n#define GRUB_EFI_DISK_IO_GUID\t\t\t\"ce345171-ba0b-11d2-8e4f-00a0c969723b\"\n#define GRUB_EFI_BLOCK_IO_GUID\t\t\t\"964e5b21-6459-11d2-8e39-00a0c969723b\"\n#define GRUB_EFI_DEVICE_PATH_GUID\t\t\"09576e91-6d3f-11d2-8e39-00a0c969723b\"\n#define GRUB_EFI_DEVICE_PATH_FROM_TEXT_GUID\t\"05c99a21-c70f-4ad2-8a5f-35df3343f51e\"\n#define GRUB_EFI_GRAPHICS_OUTPUT_GUID\t\t\"042a9de-23dc-4a38- 96fb-7aded080516a\"\n#define GRUB_EFI_UGA_DRAW_GUID\t\t\t\"982c298b-f4fa-41cb-b838-77aa688fb839\"\n#define GRUB_EFI_UGA_IO_GUID\t\t\t\"61a4d49e-6f68-4f1b-b922-a86eed0b07a2\"\n#define GRUB_EFI_SIMPLE_FILE_SYSTEM_GUID\t\"964e5b22-6459-11d2-8e39-00a0c969723b\"\n#define GRUB_EFI_SERIAL_IO_GUID\t\t\t\"bb25cf6f-f1d4-11d2-9a0c-0090273Fc1fd\"\n#endif\n\n/* GUID data types - used to map content type */\n\n#define GUID_TYPE_UNSUPPORTED\t0\n#define GUID_TYPE_X509_CERT \t1\n#define GUID_TYPE_SHA256 \t2\n\n/* This table maps GUID to the data type.  It includes the text name of the GUID for tracing. */\n\ntypedef struct {\n    uint8_t guidBin[16];\t/* binary */\n    uint32_t type;\n    const char *guidText;\t/* trace text */\n} GUID_TABLE;\n\nconst GUID_TABLE guidTable [] =\n    {\n     {EFI_CERT_X509_GUID,\n      GUID_TYPE_X509_CERT,\n      \"EFI_CERT_X509_GUID\"},\n     {EFI_GLOBAL_VARIABLE,\n      GUID_TYPE_UNSUPPORTED,\n      \"EFI_GLOBAL_VARIABLE_GUID\"},\n     {EFI_IMAGE_SECURITY_DATABASE_GUID,\n      GUID_TYPE_X509_CERT,\n      \"EFI_IMAGE_SECURITY_DATABASE_GUID\"},\n     {SMBIOS3_TABLE_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"SMBIOS3_TABLE_GUID\"},\n     {LENOVO2_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"LENOVO2_GUID\"},\n     {MICROSOFT_GUID,\n      GUID_TYPE_X509_CERT,\n      \"MICROSOFT_GUID\"},\n     {LENOVO_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"LENOVO_GUID\"},\n     {DELL_PK_SIGNING_KEY,\n      GUID_TYPE_UNSUPPORTED,\n      \"DELL_PK_SIGNING_KEY_GUID\"},\n     {SHA256_GUID,\n      GUID_TYPE_SHA256,\n      \"SHA256_GUID\"},\n     {EFI_MP_SERVICES_PROTOCOL_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"EFI_MP_SERVICES_PROTOCOL_GUID\"},\n     {EFI_SYSTEM_PARTITION_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"EFI_SYSTEM_PARTITION_GUID\"},\n     {MICROSOFT_RESERVED_PARTITION_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"MICROSOFT_RESERVED_PARTITION_GUID\"},\n     {BASIC_DATA_PARTITION_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"BASIC_DATA_PARTITION_GUID\"},\n     {WINDOWS_RECOVERY_ENVIRONMENT_GUID,\n     GUID_TYPE_UNSUPPORTED,\n     \"WINDOWS_RECOVERY_ENVIRONMENT_GUID\"},\n     {LINUX_FILESYSTEM_DATA_GUID,\n     GUID_TYPE_UNSUPPORTED,\n     \"LINUX_FILESYSTEM_DATA_GUID\"},\n     {BIOS_BOOT_PARTITION_GUID,\n     GUID_TYPE_UNSUPPORTED,\n     \"BIOS_BOOT_PARTITION_GUID\"},\n     {SHIM_LOCK_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"SHIM_LOCK_GUID\"},\n#if 0\n     {EFI_ACPI_20_TABLE_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"EFI_ACPI_20_TABLE_GUID\"},\n     {ACPI_TABLE_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"ACPI_TABLE_GUID\"},\n     {SAL_SYSTEM_TABLE_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"SAL_SYSTEM_TABLE_GUID\"},\n     {SMBIOS_TABLE_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"SMBIOS_TABLE_GUID\"},\n     {MPS_TABLE_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"MPS_TABLE_GUID\"},\n     {EFI_JSON_CONFIG_DATA_TABLE_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"EFI_JSON_CONFIG_DATA_TABLE_GUID\"},\n     {EFI_JSON_CAPSULE_DATA_TABLE_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"EFI_JSON_CAPSaULE_DATA_TABLE_GUID\"},\n     {EFI_JSON_CAPSULE_RESULT_TABLE_GUID,\n      GUID_TYPE_UNSUPPORTED,\n      \"EFI_JSON_CAPSULE_RESULT_TABLE_GUID\"},\n#endif\n    };\n\nstatic uint32_t TSS_EFI_GetGuidIndex(size_t *index, const uint8_t *guidBin);\n\nstatic void guid_printf(const char *msg, uint8_t *guid);\n\n/* guid_printf() traces the input GUID, first as hexacsii and then as text.\n\n   It prepends msg to ther hexascii trace.  msg must not be NULL but can be \"\".\n   guid must be 16 bytes;\n*/\n\nstatic void guid_printf(const char *msg, uint8_t *guid)\n{\n    int rc;\n    size_t index;\n\n    printf(\"  %s: %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\\n\",\n\t   msg,\n\t   guid[3],guid[2],guid[1],guid[0],\n\t   guid[5],guid[4],\n\t   guid[7],guid[6],\n\t   guid[8],guid[9],\n\t   guid[10],guid[11],guid[12],guid[13],guid[14],guid[15]);\n    /* if the GUID is known, trace the GUID as text */\n    rc = TSS_EFI_GetGuidIndex(&index, guid);\n    if (rc == 0) {\n\tprintf(\"    %s\\n\", guidTable[index].guidText);\n    }\n    return;\n}\n\n/* TSS_EFI_GetGuidIndex() gets the index into the GUID table for the GUID array guidBin\n\n   Returns TSS_RC_NOT_IMPLEMENTED for an unimplemeted GUID.\n*/\n\nstatic uint32_t TSS_EFI_GetGuidIndex(size_t *index, const uint8_t *guidBin)\n{\n    for (*index = 0 ;\n\t *index < sizeof(guidTable) / sizeof(GUID_TABLE) ;\n\t (*index)++) {\n\tif (memcmp(guidTable[*index].guidBin, guidBin, 16) == 0) {\n\t    return 0;\t/* match */\n\t}\n    }\n    return TSS_RC_NOT_IMPLEMENTED;\t\t/* no match */\n}\n\n/*\n  UC16 String handling\n*/\n\n/* Standard UEFI UC16 Variable Name strings */\n\nconst unsigned char unknown[] = \"\\x00\";\nconst unsigned char SecureBoot[] =\n    \"\\x53\\x00\\x65\\x00\\x63\\x00\\x75\\x00\\x72\\x00\\x65\\x00\"\n    \"\\x42\\x00\\x6f\\x00\\x6f\\x00\\x74\";\nconst unsigned char AuditMode[] =\n    \"\\x41\\x00\\x75\\x00\\x64\\x00\\x69\\x00\\x74\\x00\\x4d\\x00\"\n    \"\\x6f\\x00\\x64\\x00\\x65\";\nconst unsigned char DeployedMode[] =\n    \"\\x44\\x00\\x65\\x00\\x70\\x00\\x6c\\x00\\x6f\\x00\\x79\\x00\"\n    \"\\x65\\x00\\x64\\x00\\x4d\\x00\\x6f\\x00\\x64\\x00\\x65\";\nconst unsigned char setupmode[] =\n    \"\\x53\\x00\\x65\\x00\\x74\\x00\\x75\\x00\\x70\\x00\\x4d\\x00\"\n    \"\\x6f\\x00\\x64\\x00\\x65\";\nconst unsigned char PK[]  = \"\\x50\\x00\\x4b\"; \nconst unsigned char KEK[] = \"\\x4b\\x00\\x45\\x00\\x4b\";\nconst unsigned char db[]  = \"\\x64\\x00\\x62\";\nconst unsigned char dbr[] = \"\\x64\\x00\\x62\\x00\\x72\";\nconst unsigned char dbt[] = \"\\x64\\x00\\x62\\x00\\x74\";\nconst unsigned char dbx[] = \"\\x64\\x00\\x62\\x00\\x78\";\nconst unsigned char BootOrder[] =\n    \"\\x42\\x00\\x6f\\x00\\x6f\\x00\\x74\\x00\\x4f\\x00\\x72\\x00\"\n    \"\\x64\\x00\\x65\\x00\\x72\";\nconst unsigned char Shim[] = \"\\x53\\x00\\x68\\x00\\x69\\x00\\x6d\";\nconst unsigned char MokList[] = \"\\x4d\\x00\\x6f\\x00\\x6b\\x00\\x4c\\x00\\x69\\x00\\x73\\x00\\x74\";\nconst unsigned char MokListX[] = \"\\x4d\\x00\\x6f\\x00\\x6b\\x00\\x4c\\x00\\x69\\x00\\x73\\x00\\x74\\x00\\x58\";\n\n/* This table maps UC16 Variable names to this implementation structure tags */\n\ntypedef struct {\n    const unsigned char *name;\n    uint32_t nameLength;\n    int tag;\n} TAG_TABLE;\n\nconst TAG_TABLE tagTable [] =\n    {\n     {unknown,\n      sizeof(unknown),\n      TSS_VAR_UNKNOWN},\n     {SecureBoot,\n      sizeof(SecureBoot),\n      TSS_VAR_SECUREBOOT},\n     {AuditMode,\n      sizeof(AuditMode),\n      TSS_VAR_AUDITMODE},\n     {DeployedMode,\n      sizeof(DeployedMode),\n      TSS_VAR_DEPLOYEDMODE},\n     {setupmode,\n      sizeof(setupmode),\n      TSS_VAR_SETUPMODE},\n     {PK,\n      sizeof(PK),\n      TSS_VAR_PK},\n     {KEK,\n      sizeof(KEK),\n      TSS_VAR_KEK},\n     {db,\n      sizeof(db),\n      TSS_VAR_DB},\n     {dbx,\n      sizeof(dbx),\n      TSS_VAR_DBX},\n     {dbt,\n      sizeof(dbt),\n      TSS_VAR_DBT},\n     {dbr,\n      sizeof(dbr),\n      TSS_VAR_DBR},\n     {BootOrder,\n      sizeof(BootOrder),\n      TSS_VAR_BOOTORDER},\n     {Shim,\n      sizeof(Shim),\n      TSS_VAR_SHIM},\n     {MokList,\n      sizeof(MokList),\n      TSS_VAR_MOKLIST},\n     {MokListX,\n      sizeof(MokListX),\n      TSS_VAR_MOKLISTX},\n     };\n\nstatic void TSS_EFI_GetNameIndex(size_t *index,\n\t\t\t\t const uint8_t *name, uint64_t nameLength);\n\n/* TSS_EFI_GetTagIndex() gets the index into the tag table for the name.\n\n   If the name does't match, returns index 0, which is the unknown name.\n*/\n\nstatic void TSS_EFI_GetNameIndex(size_t *index,\n\t\t\t\t const uint8_t *name,\n\t\t\t\t uint64_t nameLength)\t/* half the total bytes in array */\n{\n    int m1 = 0;\n    int m2 = 0;\n    for (*index = 0 ;\n\t *index < sizeof(tagTable) / sizeof(TAG_TABLE)  ;\n\t (*index)++) {\n\n\t/* length match */\n\tm1 = (nameLength * 2) == tagTable[*index].nameLength;\n\tif (m1) {\n\t    /* string match */\n\t    m2 = memcmp(name, tagTable[*index].name, (size_t)(nameLength * 2)) == 0;\n\t}\n\tif (m1 && m2) {\n\t    return;\n\t}\n    }\n    *index = 0;\t\t/* no match, unknown */\n    return;\n}\n\nstatic void ucs2_printf(const char *msg, uint8_t *ucs2, uint32_t length);\n\n/* Print UCS-2 character string.\n\n   This function doesn't support true UCS-2.  It assumes that odd bytes are all zero.\n\n   length is number of UCS-2 characters, which is the number of bytes in the ucs2 arrray.  ucs2\n   is a ucs2 array to be printed, not including an extra nul terminator.\n\n   It prepends msg to ther hexascii trace.  msg must not be NULL but can be \"\".\n*/\n\nstatic void ucs2_printf(const char *msg, uint8_t *ucs2, uint32_t length)\n{\n    uint32_t i;\n\n    printf(\"  %s\", msg);\n    for (i = 0; i < length ; i+=2) {\n        printf(\"%c\", ucs2[i]);\n    }\n    printf(\"\\n\");\n    return;\n}\n\n/* isUCS2String() guesses whether the buffer is printable UCS-2.  Checks for an even number of bytes\n   and every odd byte 0x00.\n */\n\nstatic void isUCS2String(int *isUCS2, uint8_t *buffer, uint32_t length)\n{\n    uint32_t i;\n\n    if ((length % 2) != 0) {\n\t*isUCS2 = 0;\n\treturn;\n    }\n    for (i = 1 ; i < length ; i+=2) {\n\tif (buffer[i] != 0x00) {\n\t    *isUCS2 = 0;\t/* UCS-2 typically has all odd bytes 0 */\n\t    return;\n\t}\n    }\n    *isUCS2 = 1;\n    return;\n}\n\n/* isAsciiString() checks whether all bytes in the buffer are printable.\n\n   length does not include a nul terminator\n*/\n\nstatic void isAsciiString(int *isAscii, uint8_t *buffer, uint32_t length)\n{\n    uint32_t i;\n    for (i = 1 ; i < length ; i++) {\n\tif (!isprint((int)buffer[i])) {\n\t    *isAscii = 0;\n\t    return;\n\t}\n    }\n    *isAscii = 1;\n    return;\n}\n\n\nuint32_t TSS_UCS2_Unmarshal(uint8_t **ucs2,\n\t\t\t    uint32_t *DescriptionLength,\n\t\t\t    uint8_t **event, uint32_t *eventSize);\n\n/* TSS_UCS2_Unmarshal() copies the event to a malloc'ed ucs2, not including the NUL terminator.\n\n   It returns the length, which is half the number of bytes in ucs2\n*/\n\nuint32_t TSS_UCS2_Unmarshal(uint8_t **ucs2,\t\t/* freed by caller */\n\t\t\t    uint32_t *DescriptionLength,\n\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t i;\n    uint32_t bytes;\t/* bytes to malloc and store from event */\n    int foundNul = 0;\n\n    *DescriptionLength = 0;\n    /* count the number of UCS-2 bytes */\n    for (i = 0 ; i < *eventSize ; i+= 2) {\n\tif ((i+1) > *eventSize) {\n\t    return TSS_RC_INSUFFICIENT_BUFFER;\t/* handle odd number of event bytes case */\n\t}\n\tif (((*event)[i] == 0) && ((*event)[i+1] == 0)) {\n\t    foundNul = 1;\n\t    break;\n\t}\n    }\n    if (!foundNul) {\n\treturn TSS_RC_INSUFFICIENT_BUFFER;\n    }\n    bytes = i;\n    *DescriptionLength = i/2;\n    *ucs2 = malloc(bytes);\n    if (*ucs2 == NULL) {\n\treturn TSS_RC_OUT_OF_MEMORY;\n    }\n    for (i = 0 ; i < bytes ; i++) {\n\t(*ucs2)[i] = **event;\n\t*event += 1;\n\t*eventSize -= 1;\n    }\n    /* index past the NUL */\n    *event += 2;\n    *eventSize -= 2;\n    return 0;\n}\n\n/*\n  EV_COMPACT_HASH Handler\n*/\n\n/* EV_COMPACT_HASH post-OS (PCR 11) Values, from Microsoft\n \n */\n\n#define EV_COMPACT_HASH_PRE10_SUCCESS\t\t\\\n    {0x00, 0x00, 0x00, 0x00}\n#define EV_COMPACT_HASH_PRE10_DEBUG\t\t\\\n    {0x01, 0x00, 0x00, 0x00}\n#define EV_COMPACT_HASH_PRE10_ERROR\t\t\\\n    {0x02, 0x00, 0x00, 0x00}\n#define EV_COMPACT_HASH_WIN10_SUCCESS\t\t\\\n    {0x10, 0x00, 0x00, 0x00}\n#define EV_COMPACT_HASH_WIN10_UNSAFE\t\t\\\n    {0xff, 0xff, 0x00, 0x00}\n\n/* This table maps the EV_COMPACT_HASH values to text */\n\ntypedef struct {\n    uint8_t value[4];\n    const char *text;\n} EV_COMPACT_HASH_TABLE;\n\nconst EV_COMPACT_HASH_TABLE compactHashTable [] =\n    {\n     {EV_COMPACT_HASH_PRE10_SUCCESS,\n      \"Pre-Windows 10 Bitlocker success\"},\n     {EV_COMPACT_HASH_PRE10_DEBUG,\n      \"Pre-Windows 10 Bitlocker detected debugger\"},\n     {EV_COMPACT_HASH_PRE10_ERROR,\n      \"Pre-Windows 10 Error\"},\n     {EV_COMPACT_HASH_WIN10_SUCCESS,\n      \"Windows 10 Bitlocker success\"},\n     {EV_COMPACT_HASH_WIN10_UNSAFE,\n      \"Windows 10 Unsafe Windows launch\"},\n    };\n\nstatic uint32_t TSS_EFI_GetCompactHashIndex(size_t *index,\n\t\t\t\t\t    const uint8_t *value);\n\n/* TSS_EFI_GetCompactHashIndex() matches the value to the EV_COMPACT_HASH_TABLE.\n\n   Returns TSS_RC_NOT_IMPLEMENTED on no match,\n*/\n\nstatic uint32_t TSS_EFI_GetCompactHashIndex(size_t *index,\n\t\t\t\t\t    const uint8_t *value)\n{\n    int m1;\n    for (*index = 0 ;\n\t *index < sizeof(compactHashTable) / sizeof(EV_COMPACT_HASH_TABLE)  ;\n\t (*index)++) {\n\n\tm1 = memcmp(value,\n\t\t    compactHashTable[*index].value,\n\t\t    sizeof(((EV_COMPACT_HASH_TABLE *)NULL)->value)) == 0;\n\tif (m1) {\n\t    return 0;\n\t}\n    }\n    /* no match */\n    return TSS_RC_NOT_IMPLEMENTED;\n}\n\n/*\n  Device Path Handler\n*/\n\n/* Used for EV_EFI_BOOT_SERVICES_DRIVER, EV_EFI_BOOT_SERVICES_APPLICATION, EV_EFI_VARIABLE_BOOT */\n\n/* EFI_DEVICE_PATH_PROTOCOL Type Table - mapping from Type to SubType Handler */\n\ntypedef uint32_t (*TSS_EFIDevicePath_ReadBuffer_Function_t)(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\t    uint8_t **event,\n\t\t\t\t\t\t\t    uint32_t *eventSize);\ntypedef void     (*TSS_EFIDevicePath_Trace_Function_t)(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n\ntypedef struct {\n    uint8_t type;\n    const char *text;\n    TSS_EFIDevicePath_ReadBuffer_Function_t \treadBufferFunction;\n    TSS_EFIDevicePath_Trace_Function_t\t\ttraceFunction;\n} EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE;\n\nstatic uint32_t TSS_EFI_GetDevicePathIndex(size_t *index, const uint8_t type,\n\t\t\t\t\t   size_t tableSize,\n\t\t\t\t\t   const EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE *table);\n\n/* TSS_EFI_GetDevicePathIndex() returns an index into several tables containing\n   EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE entries.\n\n   The 'type' parameter is the key.  It is sometimes the Device Path Type, sometimes the SubType;\n\n   Returns TSS_RC_NOT_IMPLEMENTED if 'type' is not found.\n*/\n\nstatic uint32_t TSS_EFI_GetDevicePathIndex(size_t *index, const uint8_t type,\n\t\t\t\t\t   size_t tableSize,\n\t\t\t\t\t   const EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE *table)\n{\n    int m1;\n#if 0\n    printf(\"TSS_EFI_GetDevicePathIndex: type %02x tableSize %lu iterate %lu\\n\",\n\t   type, tableSize, tableSize / sizeof(EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE));\n#endif\n    for (*index = 0 ;\n\t *index < tableSize / sizeof(EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE) ;\n\t (*index)++) {\n#if 0\n\tprintf(\"TSS_EFI_GetDevicePathIndex: type %02x index %lu table type %02x\\n\",\n\t       type, *index, table[*index].type);\n#endif\n\tm1 = (type == table[*index].type);\n\tif (m1) {\n\t    return 0;\t/* match */\n\t}\n    }\n    return TSS_RC_NOT_IMPLEMENTED;\t\t/* no match */\n}\n\n/* From UEFI 10.3.1 Table 44 Generic Device Path Structures */\n\n#define EFI_DEVICE_PATH_TYPE_HW  \t0x01\n#define EFI_DEVICE_PATH_TYPE_ACPI \t0x02\n#define EFI_DEVICE_PATH_TYPE_MSG  \t0x03\n#define EFI_DEVICE_PATH_TYPE_MEDIA \t0x04\n#define EFI_DEVICE_PATH_TYPE_BIOS \t0x05\n#define EFI_DEVICE_PATH_TYPE_END \t0x7F\n\nstatic uint32_t TSS_EfiDevicePathHw_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t       uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathAcpi_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsg_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMedia_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize);\n#if 0\nstatic uint32_t TSS_EfiDevicePathBios_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t uint8_t **event, uint32_t *eventSize);\n#endif\nstatic uint32_t TSS_EfiDevicePathEnd_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize);\n\nstatic void TSS_EfiDevicePathHw_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathAcpi_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathMsg_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathMedia_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#if 0\nstatic void TSS_EfiDevicePathBios_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#endif\nstatic void TSS_EfiDevicePathEnd_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n\nconst EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE efiDevicePathProtocolTypeTable [] =\n    {\n     {EFI_DEVICE_PATH_TYPE_HW,\n      \"Hardware Device Path\",\n      TSS_EfiDevicePathHw_ReadBuffer,\n      TSS_EfiDevicePathHw_Trace},\n     {EFI_DEVICE_PATH_TYPE_ACPI,\n      \"ACPI Device Path\",\n      TSS_EfiDevicePathAcpi_ReadBuffer,\n      TSS_EfiDevicePathAcpi_Trace},\n     {EFI_DEVICE_PATH_TYPE_MSG,\n      \"Messaging Device Path\",\n      TSS_EfiDevicePathMsg_ReadBuffer,\n      TSS_EfiDevicePathMsg_Trace},\n     {EFI_DEVICE_PATH_TYPE_MEDIA,\n      \"Media Device Path\",\n      TSS_EfiDevicePathMedia_ReadBuffer,\n      TSS_EfiDevicePathMedia_Trace},\n#if 0\n     {EFI_DEVICE_PATH_TYPE_BIOS,\n      \"BIOS Boot Specification Device Path\",\n      TSS_EfiDevicePathBios_ReadBuffer,\n      TSS_EfiDevicePathBios_Trace},\n#endif\n     {EFI_DEVICE_PATH_TYPE_END,\n      \"End of Hardware Device Path\",\n      TSS_EfiDevicePathEnd_ReadBuffer,\n      TSS_EfiDevicePathEnd_Trace},\n    };\n\n/* From UEFI 10.3.2 Hardware Device Path - Type 1 SubTypes */\n\n#define EFI_DEVICE_PATH_HW_SUBTYPE_PCI\t\t1\n#define EFI_DEVICE_PATH_HW_SUBTYPE_PCCARD\t2\n#define EFI_DEVICE_PATH_HW_SUBTYPE_MMAP\t\t3\n#define EFI_DEVICE_PATH_HW_SUBTYPE_VENDOR\t4\n#define EFI_DEVICE_PATH_HW_SUBTYPE_CTRLR\t5\n#define EFI_DEVICE_PATH_HW_SUBTYPE_BMC\t\t6\n\nstatic uint32_t TSS_UefiDevicePathList_ReadBuffer(TSS_UEFI_DEVICE_PATH **UefiDevicePath,\n\t\t\t\t\t\t  uint32_t *UefiDevicePathCount,\n\t\t\t\t\t\t  uint8_t *devicePath,\n\t\t\t\t\t\t  uint32_t lengthOfDevicePath);\n\nstatic uint32_t TSS_EfiDevicePathHwPCI_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize);\n#if 0\nstatic uint32_t TSS_EfiDevicePathHwPCCARD_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t     uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathHwMMAP_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t   uint8_t **event, uint32_t *eventSize);\n#endif\nstatic uint32_t TSS_EfiDevicePathHwVENDOR_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t     uint8_t **event, uint32_t *eventSize);\n#if 0\nstatic uint32_t TSS_EfiDevicePathHwCTRLR_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathHwBMC_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize);\n#endif\n\nstatic void TSS_EfiDevicePathHwPCI_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#if 0\nstatic void TSS_EfiDevicePathHwPCCARD_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathHwMMAP_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#endif\nstatic void TSS_EfiDevicePathHwVENDOR_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#if 0\nstatic void TSS_EfiDevicePatHwCTRLR_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathHwBMC_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#endif\n\nconst EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE efiDevicePathProtocolHwTypeTable [] =\n    {\n     {EFI_DEVICE_PATH_HW_SUBTYPE_PCI,\n      \"PCI\",\n      TSS_EfiDevicePathHwPCI_ReadBuffer,\n      TSS_EfiDevicePathHwPCI_Trace},\n#if 0\n     {EFI_DEVICE_PATH_HW_SUBTYPE_PCCARD,\n      \"PCCARD\",\n      TSS_EfiDevicePathHwPCCARD_ReadBuffer,\n      TSS_EfiDevicePathHwPCCARD_Trace},\n     {EFI_DEVICE_PATH_HW_SUBTYPE_MMAP,\n      \"Memory Mapped\",\n      TSS_EfiDevicePathHwMMAP_ReadBuffer,\n      TSS_EfiDevicePathHwMMAP_Trace},\n#endif\n     {EFI_DEVICE_PATH_HW_SUBTYPE_VENDOR,\n      \"Vendor\",\n      TSS_EfiDevicePathHwVENDOR_ReadBuffer,\n      TSS_EfiDevicePathHwVENDOR_Trace},\n#if 0\n     {EFI_DEVICE_PATH_HW_SUBTYPE_CTRLR,\n      \"Controller\",\n      TSS_EfiDevicePathHwCTRLR_ReadBuffer,\n      TSS_EfiDevicePathHwCTRLR_Trace},\n     {EFI_DEVICE_PATH_HW_SUBTYPE_BMC,\n      \"BMC\",\n      TSS_EfiDevicePathHwBMC_ReadBuffer,\n      TSS_EfiDevicePathHwBMC_Trace},\n#endif\n    };\n\n/* From UEFI 10.3.3 ACPI Device Path  - Type 2 SubTypes */\n\n#define EFI_DEVICE_PATH_ACPI_SUBTYPE_ACPI\t0x01\n#define EFI_DEVICE_PATH_ACPI_SUBTYPE_EXPACPI\t0x02\n#define EFI_DEVICE_PATH_ACPI_SUBTYPE_ADR\t0x03\n#define EFI_DEVICE_PATH_ACPI_SUBTYPE_NVDIMM\t0x04\n\nstatic uint32_t TSS_EfiDevicePathAcpiSubAcpi_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize);\n#if 0\nstatic uint32_t TSS_EfiDevicePathAcpiExpAcpi_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathAcpiAdr_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathAcpiNvdimm_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t       uint8_t **event, uint32_t *eventSize);\n#endif\n\nstatic void TSS_EfiDevicePathAcpiSubAcpi_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#if 0\nstatic void TSS_EfiDevicePathAcpiExpAcpi_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathAcpiAdr_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathAcpiNvdimm_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#endif\n\nconst EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE efiDevicePathProtocolAcpiTypeTable [] =\n    {\n     {EFI_DEVICE_PATH_ACPI_SUBTYPE_ACPI,\n      \"ACPI Device Path\",\n      TSS_EfiDevicePathAcpiSubAcpi_ReadBuffer,\n      TSS_EfiDevicePathAcpiSubAcpi_Trace},\n#if 0\n     {EFI_DEVICE_PATH_ACPI_SUBTYPE_EXPACPI,\n      \"Expanded ACPI Device Path\",\n      TSS_EfiDevicePathAcpiExpAcpi_ReadBuffer,\n      TSS_EfiDevicePathAcpiExpAcpi_Trace},\n     {EFI_DEVICE_PATH_ACPI_SUBTYPE_ADR,\n      \"_ADR Device Path\",\n      TSS_EfiDevicePathAcpiAdr_ReadBuffer,\n      TSS_EfiDevicePathAcpiAdr_Trace},\n     {EFI_DEVICE_PATH_ACPI_SUBTYPE_NVDIMM,\n      \"NVDIMM Device\",\n      TSS_EfiDevicePathAcpiNvdimm_ReadBuffer,\n      TSS_EfiDevicePathAcpiNvdimm_Trace},\n#endif\n    };\n\n/* From UEFI 10.3.4 Messaging Device Path  - Type 3 SubTypes */\n\n/* UEFI code uses the prefix MSG_ */\n\n#define EFI_DEVICE_PATH_MSG_ATAPI_DP              \t0x01\n#define EFI_DEVICE_PATH_MSG_SCSI_DP               \t0x02\n#define EFI_DEVICE_PATH_MSG_FIBRECHANNEL_DP       \t0x03\n#define EFI_DEVICE_PATH_MSG_1394_DP               \t0x04\n#define EFI_DEVICE_PATH_MSG_USB_DP                \t0x05\n#define EFI_DEVICE_PATH_MSG_I2O_DP                \t0x06\n#define EFI_DEVICE_PATH_MSG_INFINIBAND_DP         \t0x09\n#define EFI_DEVICE_PATH_MSG_VENDOR_DP             \t0x0a\n#define EFI_DEVICE_PATH_MSG_MAC_ADDR_DP           \t0x0b\n#define EFI_DEVICE_PATH_MSG_IPv4_DP               \t0x0c\n#define EFI_DEVICE_PATH_MSG_IPv6_DP               \t0x0d\n#define EFI_DEVICE_PATH_MSG_UART_DP               \t0x0e\n#define EFI_DEVICE_PATH_MSG_USB_CLASS_DP          \t0x0f\n#define EFI_DEVICE_PATH_MSG_USB_WWID_DP           \t0x10\n#define EFI_DEVICE_PATH_MSG_DEVICE_LOGICAL_UNIT_DP  \t0x11\n#define EFI_DEVICE_PATH_MSG_SATA_DP               \t0x12\n#define EFI_DEVICE_PATH_MSG_ISCSI_DP              \t0x13\n#define EFI_DEVICE_PATH_MSG_VLAN_DP               \t0x14\n#define EFI_DEVICE_PATH_MSG_FIBRECHANNELEX_DP     \t0x15\n#define EFI_DEVICE_PATH_MSG_SASEX_DP              \t0x16\n#define EFI_DEVICE_PATH_MSG_NVME_NAMESPACE_DP     \t0x17\n#define EFI_DEVICE_PATH_MSG_URI_DP                \t0x18\n#define EFI_DEVICE_PATH_MSG_UFS_DP                \t0x19\n#define EFI_DEVICE_PATH_MSG_SD_DP                 \t0x1A\n#define EFI_DEVICE_PATH_MSG_BLUETOOTH_DP     \t\t0x1b\n#define EFI_DEVICE_PATH_MSG_WIFI_DP               \t0x1C\n#define EFI_DEVICE_PATH_MSG_EMMC_DP                 \t0x1D\n#define EFI_DEVICE_PATH_MSG_BLUETOOTH_LE_DP       \t0x1E\n#define EFI_DEVICE_PATH_MSG_DNS_DP                \t0x1F\n#define EFI_DEVICE_PATH_MSG_NVDIMM_NAMESPACE_DP        \t0x20\n\nstatic uint32_t TSS_EfiDevicePathMsgScsi_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsgUsb_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t   uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsgUsbClass_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsgSata_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsgNvme_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsgMac_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t   uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsgIpv4_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsgIpv6_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsgUri_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMsgVendor_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t      uint8_t **event, uint32_t *eventSize);\n\nstatic void     TSS_EfiDevicePathMsgScsi_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void     TSS_EfiDevicePathMsgUsb_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void     TSS_EfiDevicePathMsgUsbClass_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void     TSS_EfiDevicePathMsgSata_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void     TSS_EfiDevicePathMsgNvme_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void \tTSS_EfiDevicePathMsgMac_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void     TSS_EfiDevicePathMsgIpv4_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void     TSS_EfiDevicePathMsgIpv6_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void     TSS_EfiDevicePathMsgUri_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void     TSS_EfiDevicePathMsgVendor_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n\nconst EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE efiDevicePathProtocolMsgTypeTable [] =\n    {\n     {EFI_DEVICE_PATH_MSG_SCSI_DP,\n      \"Message Device Path SCSI \",\n      TSS_EfiDevicePathMsgScsi_ReadBuffer,\n      TSS_EfiDevicePathMsgScsi_Trace},\n     {EFI_DEVICE_PATH_MSG_USB_DP,\n      \"Message Device Path USB\",\n      TSS_EfiDevicePathMsgUsb_ReadBuffer,\n      TSS_EfiDevicePathMsgUsb_Trace},\n     {EFI_DEVICE_PATH_MSG_USB_CLASS_DP,\n      \"Message Device Path USB Class\",\n      TSS_EfiDevicePathMsgUsbClass_ReadBuffer,\n      TSS_EfiDevicePathMsgUsbClass_Trace},\n     {EFI_DEVICE_PATH_MSG_NVME_NAMESPACE_DP,\n      \"Message Device Path NVME\",\n      TSS_EfiDevicePathMsgNvme_ReadBuffer,\n      TSS_EfiDevicePathMsgNvme_Trace},\n     {EFI_DEVICE_PATH_MSG_SATA_DP,\n      \"Message Device Path SATA \",\n      TSS_EfiDevicePathMsgSata_ReadBuffer,\n      TSS_EfiDevicePathMsgSata_Trace},\n     {EFI_DEVICE_PATH_MSG_MAC_ADDR_DP,\n      \"Message Device Path MAC Address\",\n      TSS_EfiDevicePathMsgMac_ReadBuffer,\n      TSS_EfiDevicePathMsgMac_Trace},\n     {EFI_DEVICE_PATH_MSG_IPv4_DP,\n      \"Message Device Path IPv4\",\n      TSS_EfiDevicePathMsgIpv4_ReadBuffer,\n      TSS_EfiDevicePathMsgIpv4_Trace},\n     {EFI_DEVICE_PATH_MSG_IPv6_DP,\n      \"Message Device Path IPv6\",\n      TSS_EfiDevicePathMsgIpv6_ReadBuffer,\n      TSS_EfiDevicePathMsgIpv6_Trace},\n     {EFI_DEVICE_PATH_MSG_URI_DP,\n      \"Message Device Path URI\",\n      TSS_EfiDevicePathMsgUri_ReadBuffer,\n      TSS_EfiDevicePathMsgUri_Trace},\n     {EFI_DEVICE_PATH_MSG_VENDOR_DP,\n      \"Message Device Path Vendor\",\n      TSS_EfiDevicePathMsgVendor_ReadBuffer,\n      TSS_EfiDevicePathMsgVendor_Trace},\n   };\n\n/* From UEFI 10.3.5 Media Device Path  - Type 4 SubTypes */\n\n#define EFI_DEVICE_PATH_MEDIA_SUBTYPE_HD\t0x01\n#define EFI_DEVICE_PATH_MEDIA_SUBTYPE_CDROM\t0x02\n#define EFI_DEVICE_PATH_MEDIA_SUBTYPE_VENDOR\t0x03\n#define EFI_DEVICE_PATH_MEDIA_SUBTYPE_FILE\t0x04\n#define EFI_DEVICE_PATH_MEDIA_SUBTYPE_MEDIA\t0x05\n#define EFI_DEVICE_PATH_MEDIA_SUBTYPE_PIWG_FILE\t0x06\n#define EFI_DEVICE_PATH_MEDIA_SUBTYPE_PIWG_FW\t0x07\n#define EFI_DEVICE_PATH_MEDIA_SUBTYPE_OFFSET\t0x08\n#define EFI_DEVICE_PATH_MEDIA_SUBTYPE_RAMDISK\t0x09\n\nstatic uint32_t TSS_EfiDevicePathMediaHd_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize);\n#if 0\nstatic uint32_t TSS_EfiDevicePathMediaCdrom_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t       uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMediaVendor_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize);\n#endif\nstatic uint32_t TSS_EfiDevicePathMediaFile_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t       uint8_t **event, uint32_t *eventSize);\n#if 0\nstatic uint32_t TSS_EfiDevicePathMediaMedia_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t       uint8_t **event, uint32_t *eventSize);\n#endif\nstatic uint32_t TSS_EfiDevicePathMediaPiwgFile_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMediaPiwgFw_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiDevicePathMediaOffset_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize);\n#if 0\nstatic uint32_t TSS_EfiDevicePathMediaRamdisk_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\t uint8_t **event, uint32_t *eventSize);\n#endif\n\nstatic void TSS_EfiDevicePathMediaHd_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#if 0\nstatic void TSS_EfiDevicePathMediaCdrom_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathMediaVendor_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#endif\nstatic void TSS_EfiDevicePathMediaFile_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#if 0\nstatic void TSS_EfiDevicePathMediaMedia_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#endif\nstatic void TSS_EfiDevicePathMediaPiwgFile_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathMediaPiwgFw_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void TSS_EfiDevicePathMediaOffset_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#if 0\nstatic void TSS_EfiDevicePathMediaRamdisk_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n#endif\n\nconst EFI_DEVICE_PATH_PROTOCOL_TYPE_TABLE efiDevicePathProtocolMediaTypeTable [] =\n    {\n     {EFI_DEVICE_PATH_MEDIA_SUBTYPE_HD,\n      \"Media Device Path HD\",\n      TSS_EfiDevicePathMediaHd_ReadBuffer,\n      TSS_EfiDevicePathMediaHd_Trace},\n#if 0\n     {EFI_DEVICE_PATH_MEDIA_SUBTYPE_CDROM,\n      \"Media Device Path CDROM\",\n      TSS_EfiDevicePathMediaCdrom_ReadBuffer,\n      TSS_EfiDevicePathMediaCdrom_Trace},z\n     {EFI_DEVICE_PATH_MEDIA_SUBTYPE_VENDOR,\n      \"Media Device Path Vendor\",\n      TSS_EfiDevicePathMediaVendor_ReadBuffer,\n      TSS_EfiDevicePathMediaVendor_Trace},\n#endif\n     {EFI_DEVICE_PATH_MEDIA_SUBTYPE_FILE,\n      \"Media Device Path File\",\n      TSS_EfiDevicePathMediaFile_ReadBuffer,\n      TSS_EfiDevicePathMediaFile_Trace},\n#if 0\n     {EFI_DEVICE_PATH_MEDIA_SUBTYPE_MEDIA,\n      \"Media Device Path Media\",\n      TSS_EfiDevicePathMediaMedia_ReadBuffer,\n      TSS_EfiDevicePathMediaMedia_Trace},\n#endif\n     {EFI_DEVICE_PATH_MEDIA_SUBTYPE_PIWG_FILE,\n      \"Media Device Path PIWG File\",\n      TSS_EfiDevicePathMediaPiwgFile_ReadBuffer,\n      TSS_EfiDevicePathMediaPiwgFile_Trace},\n     {EFI_DEVICE_PATH_MEDIA_SUBTYPE_PIWG_FW,\n      \"Media Device Path PIWG FW\",\n      TSS_EfiDevicePathMediaPiwgFw_ReadBuffer,\n      TSS_EfiDevicePathMediaPiwgFw_Trace},\n     {EFI_DEVICE_PATH_MEDIA_SUBTYPE_OFFSET,\n      \"Media Device Path Offset\",\n      TSS_EfiDevicePathMediaOffset_ReadBuffer,\n      TSS_EfiDevicePathMediaOffset_Trace},\n#if 0\n     {EFI_DEVICE_PATH_MEDIA_SUBTYPE_RAMDISK,\n      \"Media Device Path Ramdisk\",\n      TSS_EfiDevicePathMediaRamdisk_ReadBuffer,\n      TSS_EfiDevicePathMediaRamdisk_Trace},\n#endif\n    };\n\n\n/* From UEFI 10.3.1 Generic Device Path Structures */\n\nstatic uint32_t TSS_EfiDevicePathHw_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t       uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    size_t index;\n\n    if (rc == 0) {\n\trc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.SubType,\n\t\t\t\t\tsizeof(efiDevicePathProtocolHwTypeTable) ,\n\t\t\t\t\tefiDevicePathProtocolHwTypeTable);\n    }\n    if (rc == 0) {\n\trc = efiDevicePathProtocolHwTypeTable[index].readBufferFunction(uefiDevicePath,\n\t\t\t\t\t\t\t\t\tevent, eventSize);\n    }\n    else {\n\t/* SubType unknown / unsupported */\n\trc = TSS_Array_Unmarshalu(uefiDevicePath->data,\n\t\t\t\t  uefiDevicePath->protocol.Length -\n\t\t\t\t  sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL),\n\t\t\t\t  event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathAcpi_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    size_t index;\n\n    if (rc == 0) {\n\trc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.SubType,\n\t\t\t\t\tsizeof(efiDevicePathProtocolAcpiTypeTable) ,\n\t\t\t\t\tefiDevicePathProtocolAcpiTypeTable);\n    }\n    if (rc == 0) {\n\trc = efiDevicePathProtocolAcpiTypeTable[index].readBufferFunction(uefiDevicePath,\n\t\t\t\t\t\t\t\t\t  event, eventSize);\n    }\n    else {\n\t/* SubType unknown / unsupported */\n\trc = TSS_Array_Unmarshalu(uefiDevicePath->data,\n\t\t\t\t  uefiDevicePath->protocol.Length -\n\t\t\t\t  sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL),\n\t\t\t\t  event, eventSize);\n    }\n    return rc;\n}\nstatic uint32_t TSS_EfiDevicePathMsg_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    size_t index;\n\n    if (rc == 0) {\n\trc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.SubType,\n\t\t\t\t\tsizeof(efiDevicePathProtocolMsgTypeTable) ,\n\t\t\t\t\tefiDevicePathProtocolMsgTypeTable);\n    }\n    if (rc == 0) {\n\trc = efiDevicePathProtocolMsgTypeTable[index].readBufferFunction(uefiDevicePath,\n\t\t\t\t\t\t\t\t\t event, eventSize);\n    }\n    else {\n\t/* SubType unknown / unsupported */\n\trc = TSS_Array_Unmarshalu(uefiDevicePath->data,\n\t\t\t\t  uefiDevicePath->protocol.Length -\n\t\t\t\t  sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL),\n\t\t\t\t  event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMedia_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    size_t index;\n\n    if (rc == 0) {\n\trc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.SubType,\n\t\t\t\t\tsizeof(efiDevicePathProtocolMediaTypeTable) ,\n\t\t\t\t\tefiDevicePathProtocolMediaTypeTable);\n    }\n    if (rc == 0) {\n\trc = efiDevicePathProtocolMediaTypeTable[index].readBufferFunction(uefiDevicePath,\n\t\t\t\t\t\t\t\t\t   event, eventSize);\n    }\n    else {\n\t/* SubType unknown / unsupported */\n\trc = TSS_Array_Unmarshalu(uefiDevicePath->data,\n\t\t\t\t  uefiDevicePath->protocol.Length -\n\t\t\t\t  sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL),\n\t\t\t\t  event, eventSize);\n    }\n    return rc;\n}\n\n#if 0\nstatic uint32_t TSS_EfiDevicePathBios_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    return rc;\n}\n#endif\n\nstatic uint32_t TSS_EfiDevicePathEnd_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    /* End has no data */\n    uefiDevicePath = uefiDevicePath;\n    event = event;\n    eventSize = eventSize;\n    return rc;\n}\n\nstatic void TSS_EfiDevicePathHw_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    uint32_t rc = 0;\n    size_t index;\n\n    if (rc == 0) {\n\trc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.SubType,\n\t\t\t\t\tsizeof(efiDevicePathProtocolHwTypeTable) ,\n\t\t\t\t\tefiDevicePathProtocolHwTypeTable);\n    }\n    if (rc == 0) {\n\tefiDevicePathProtocolHwTypeTable[index].traceFunction(uefiDevicePath);\n    }\n    else {\n\tprintf(\"Type %02x SubType %02x HW trace not implemented\\n\",\n\t       uefiDevicePath->protocol.Type,\n\t       uefiDevicePath->protocol.SubType);\n    }\n    return;\n}\n\nstatic void TSS_EfiDevicePathAcpi_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    uint32_t rc = 0;\n    size_t index;\n\n    if (rc == 0) {\n\trc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.SubType,\n\t\t\t\t\tsizeof(efiDevicePathProtocolAcpiTypeTable) ,\n\t\t\t\t\tefiDevicePathProtocolAcpiTypeTable);\n    }\n    if (rc == 0) {\n\tefiDevicePathProtocolAcpiTypeTable[index].traceFunction(uefiDevicePath);\n    }\n    else {\n\tprintf(\"Type %02x SubType %02x ACPI trace not implemented\\n\",\n\t       uefiDevicePath->protocol.Type,\n\t       uefiDevicePath->protocol.SubType);\n    }\n    return;\n}\nstatic void TSS_EfiDevicePathMsg_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    uint32_t rc = 0;\n    size_t index;\n\n    if (rc == 0) {\n\trc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.SubType,\n\t\t\t\t\tsizeof(efiDevicePathProtocolMsgTypeTable) ,\n\t\t\t\t\tefiDevicePathProtocolMsgTypeTable);\n    }\n    if (rc == 0) {\n\tefiDevicePathProtocolMsgTypeTable[index].traceFunction(uefiDevicePath);\n    }\n    else {\n\tprintf(\"Type %02x SubType %02x Message trace not implemented\\n\",\n\t       uefiDevicePath->protocol.Type,\n\t       uefiDevicePath->protocol.SubType);\n    }\n    return;\n}\n\nstatic void TSS_EfiDevicePathMedia_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    uint32_t rc = 0;\n    size_t index;\n\n    if (rc == 0) {\n\trc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.SubType,\n\t\t\t\t\tsizeof(efiDevicePathProtocolMediaTypeTable) ,\n\t\t\t\t\tefiDevicePathProtocolMediaTypeTable);\n    }\n    if (rc == 0) {\n\tefiDevicePathProtocolMediaTypeTable[index].traceFunction(uefiDevicePath);\n    }\n    else {\n\tprintf(\"Type %02x SubType %02x Media trace not implemented\\n\",\n\t       uefiDevicePath->protocol.Type,\n\t       uefiDevicePath->protocol.SubType);\n    }\n    return;\n}\n\n#if 0\nstatic void TSS_EfiDevicePathBios_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x BIOS trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n#endif\n\nstatic void TSS_EfiDevicePathEnd_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    if (uefiDevicePath->protocol.SubType == 0xff) {\n\tprintf(\"    SubType %02x End Entire Device Path\\n\", uefiDevicePath->protocol.SubType);\n    }\n    else if (uefiDevicePath->protocol.SubType == 0x01) {\n\tprintf(\"    SubType %02x End This Device Path\\n\", uefiDevicePath->protocol.SubType);\n    }\n    else {\n\tprintf(\"    SubType %02x\\n\", uefiDevicePath->protocol.SubType);\n    }\n    return;\n}\n\n/* From UEFI 10.3.2 Hardware Device Path - Type 1 SubTypes */\n\nstatic uint32_t TSS_EfiDevicePathHwPCI_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_HW0101 *hw0101 = &uefiDevicePath->hw0101;\n\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&hw0101->Function, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&hw0101->Device, event, eventSize);\n    }\n    return rc;\n}\n\n#if 0\nstatic uint32_t TSS_EfiDevicePathHwPCCARD_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t     uint8_t **event, uint32_t *eventSize)\n{\n}\nstatic uint32_t TSS_EfiDevicePathHwMMAP_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t   uint8_t **event, uint32_t *eventSize)\n{\n}\n#endif\n\nstatic uint32_t TSS_EfiDevicePathHwVENDOR_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t     uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_HW0104 *hw0104 = &uefiDevicePath->hw0104;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(hw0104->Vendor_GUID,\n\t\t\t\t  sizeof(hw0104->Vendor_GUID),\n\t\t\t\t  event, eventSize);\n    }\n    /* if there is a URI */\n    if (uefiDevicePath->protocol.Length >\n\t(sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL) + sizeof(hw0104->Vendor_GUID))) {\n\n\tuefiDevicePath->unionBufferLength = uefiDevicePath->protocol.Length -\n\t\t\t\t\t    sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL) -\n\t\t\t\t\t    sizeof(hw0104->Vendor_GUID);\n\tif (rc == 0) {\n\t    uefiDevicePath->unionBuffer =\n\t\tmalloc(uefiDevicePath->unionBufferLength);\n\t    if (uefiDevicePath->unionBuffer == NULL) {\n\t\tprintf(\"TSS_EfiDevicePathHwVENDOR_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(uefiDevicePath->unionBufferLength));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Array_Unmarshalu(uefiDevicePath->unionBuffer,\n\t\t\t\t      uefiDevicePath->unionBufferLength,\n\t\t\t\t      event, eventSize);\n\t}\n    }\n    return rc;\n}\n\n#if 0\nstatic uint32_t TSS_EfiDevicePathHwCTRLR_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n}\nstatic uint32_t TSS_EfiDevicePathHwBMC_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize)\n{\n}\n#endif\n\nstatic void TSS_EfiDevicePathHwPCI_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_HW0101 *hw0101 = &uefiDevicePath->hw0101;\n\n    printf(\"    SubType %02x PCI\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      Function %02x\\n\",  hw0101->Function);\n    printf(\"      Device %02x\\n\",  hw0101->Device);\n    return;\n}\n\n#if 0\nstatic void TSS_EfiDevicePathHwPCCARD_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n\nstatic void TSS_EfiDevicePathhHwMMAP_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x Hw MMAP trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n#endif\n\nstatic void TSS_EfiDevicePathHwVENDOR_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_HW0104 *hw0104 = &uefiDevicePath->hw0104;\n    int isUCS2;\n\n    printf(\"    SubType %02x Vendor\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    guid_printf(\"    Vendor GUID\", hw0104->Vendor_GUID);\n    /* some Vendor data appears to be UCS-2 NUL terminated */\n    if (uefiDevicePath->unionBufferLength > 0) {\n\tisUCS2String(&isUCS2, uefiDevicePath->unionBuffer, uefiDevicePath->unionBufferLength);\n\tif (isUCS2) {\n\t    ucs2_printf(\"    Vendor: \", uefiDevicePath->unionBuffer,\n\t\t\t(uefiDevicePath->unionBufferLength -2));\n\t}\n\telse {\n\t    TSS_PrintAll(\"     Vendor\",\n\t\t\t uefiDevicePath->unionBuffer,\n\t\t\t uefiDevicePath->unionBufferLength);\n\t}\n    }\n    return;\n}\n\n#if 0\nstatic void TSS_EfiDevicePathHwCTRLR_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x Hw CTRLR trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\nstatic void TSS_EfiDevicePathHwBMC_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x Hw BMC trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n#endif\n\n/* From UEFI 10.3.3 ACPI Device Path  - Type 2 SubTypes */\n\nstatic uint32_t TSS_EfiDevicePathAcpiSubAcpi_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_ACPI0201 *acpi0201 = &uefiDevicePath->acpi0201;\n\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&acpi0201->HID, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&acpi0201->UID, event, eventSize);\n    }\n    return rc;\n}\n\n#if 0\nstatic uint32_t TSS_EfiDevicePathAcpiExpAcpi_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n}\n\nstatic uint32_t TSS_EfiDevicePathAcpiAdr_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n}\n\nstatic uint32_t TSS_EfiDevicePathAcpiNvdimm_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t       uint8_t **event, uint32_t *eventSize)\n{\n}\n#endif\n\nstatic void TSS_EfiDevicePathAcpiSubAcpi_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_ACPI0201 *acpi0201 = &uefiDevicePath->acpi0201;\n\n    printf(\"    SubType %02x ACPI Device Path\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      HID %08x\\n\",  acpi0201->HID);\n    printf(\"      UID %08x\\n\",  acpi0201->UID);\n    return;\n}\n\n#if 0\nstatic void TSS_EfiDevicePathAcpiExpAcpi_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n\nstatic void TSS_EfiDevicePathAcpiAdr_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n\nstatic void TSS_EfiDevicePathAcpiNvdimm_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n#endif\n\n/* From UEFI 10.3.4 Messaging Device Path - Type 3 SubTypes */\n\nstatic uint32_t TSS_EfiDevicePathMsgScsi_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MSG0302 *msg0302 = &uefiDevicePath->msg0302;\n\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg0302->TargetID, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg0302->LogicalUnitNumber, event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMsgUsb_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t   uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MSG0305 *msg0305 = &uefiDevicePath->msg0305;\n\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&msg0305->USBParentPort, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&msg0305->Interface, event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMsgUsbClass_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MSG030F *msg030f = &uefiDevicePath->msg030f;\n\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg030f->VendorID, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg030f->ProductID, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&msg030f->DeviceClass, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&msg030f->DeviceSubclass, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&msg030f->DeviceProtocol, event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMsgSata_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MSG0312 *msg0312 = &uefiDevicePath->msg0312;\n\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg0312->HBAPortNumber, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg0312->PortMultiplierPort, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg0312->LogicalUnitNumber, event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMsgNvme_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MSG0317 *msg0317 = &uefiDevicePath->msg0317;\n\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&msg0317->NamespaceId, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&msg0317->NamespaceUuid, event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMsgMac_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t   uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MSG030B *msg030b = &uefiDevicePath->msg030b;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(msg030b->Mac, sizeof(msg030b->Mac),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&msg030b->IfType, event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMsgIpv4_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MSG030C *msg030c = &uefiDevicePath->msg030c;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(msg030c->LocalIPAddress, sizeof(msg030c->LocalIPAddress),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(msg030c->RemoteIPAddress, sizeof(msg030c->RemoteIPAddress),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg030c->LocalPort, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg030c->RemotePort, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg030c->Protocol, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&msg030c->StaticIPAddress, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(msg030c->GatewayIPAddress, sizeof(msg030c->GatewayIPAddress),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(msg030c->SubnetMask, sizeof(msg030c->SubnetMask),\n\t\t\t\t  event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMsgIpv6_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MSG030D *msg030d = &uefiDevicePath->msg030d;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(msg030d->LocalIPAddress, sizeof(msg030d->LocalIPAddress),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(msg030d->RemoteIPAddress, sizeof(msg030d->RemoteIPAddress),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg030d->LocalPort, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg030d->RemotePort, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&msg030d->Protocol, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&msg030d->IPAddressOrigin, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&msg030d->PrefixLength, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(msg030d->GatewayIPAddress, sizeof(msg030d->GatewayIPAddress),\n\t\t\t\t  event, eventSize);\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMsgUri_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t   uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n\n    /* if there is a URI */\n    if (uefiDevicePath->protocol.Length > sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL)) {\n\tif (rc == 0) {\n\t    uefiDevicePath->unionBuffer =\n\t\tmalloc(uefiDevicePath->protocol.Length - sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL));\n\t    if (uefiDevicePath->unionBuffer == NULL) {\n\t\tprintf(\"TSS_EfiDevicePathMsgUri_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(uefiDevicePath->protocol.Length -\n\t\t\t\t      sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL)));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    uefiDevicePath->unionBufferLength = uefiDevicePath->protocol.Length -\n\t\t\t\t\t\tsizeof(TSS_EFI_DEVICE_PATH_PROTOCOL);\n\t    rc = TSS_Array_Unmarshalu(uefiDevicePath->unionBuffer,\n\t\t\t\t      uefiDevicePath->unionBufferLength,\n\t\t\t\t      event, eventSize);\n\t}\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMsgVendor_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t      uint8_t **event, uint32_t *eventSize)\n\n{\n    uint32_t rc = 0;\n    TSS_MSG030A *msg030a = &uefiDevicePath->msg030a;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(msg030a->VendorGUID, sizeof(msg030a->VendorGUID),\n\t\t\t\t  event, eventSize);\n    }\n    if (uefiDevicePath->protocol.Length >\n\t(sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL) + sizeof(msg030a->VendorGUID))) {\n\n\tuefiDevicePath->unionBufferLength = uefiDevicePath->protocol.Length -\n\t\t\t\t\t    sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL) -\n\t\t\t\t\t    sizeof(msg030a->VendorGUID);\n\tif (rc == 0) {\n\t    uefiDevicePath->unionBuffer = malloc(uefiDevicePath->unionBufferLength);\n\t    if (uefiDevicePath->unionBuffer == NULL) {\n\t\tprintf(\"TSS_EfiDevicePathMsgVendor_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(uefiDevicePath->unionBufferLength))\t;\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Array_Unmarshalu(uefiDevicePath->unionBuffer,\n\t\t\t\t      uefiDevicePath->unionBufferLength,\n\t\t\t\t      event, eventSize);\n\t}\n    }\n    return rc;\n}\n\nstatic void     TSS_EfiDevicePathMsgScsi_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MSG0302 *msg0302 = &uefiDevicePath->msg0302;\n\n    printf(\"    SubType %02x SCSI\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      Target ID %hu\\n\", msg0302->TargetID);\n    printf(\"      Logical Unit Number %hu\\n\", msg0302->LogicalUnitNumber);\n    return;\n}\n\nstatic void     TSS_EfiDevicePathMsgUsb_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MSG0305 *msg0305 = &uefiDevicePath->msg0305;\n\n    printf(\"    SubType %02x USB\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      USB Parent Port %u\\n\", msg0305->USBParentPort);\n    printf(\"      Interface %u\\n\", msg0305->Interface);\n    return;\n}\n\nstatic void     TSS_EfiDevicePathMsgUsbClass_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MSG030F *msg030f = &uefiDevicePath->msg030f;\n\n    printf(\"    SubType %02x USB Class\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      VendorID %04x\\n\", msg030f->VendorID);\n    printf(\"      Product ID %04x\\n\", msg030f->ProductID);\n    printf(\"      Device Class %02x\\n\", msg030f->DeviceClass);\n    printf(\"      Device Subclass %02x\\n\", msg030f->DeviceSubclass);\n    printf(\"      Device Protocol %02x\\n\", msg030f->DeviceProtocol);\n    return;\n}\n\nstatic void     TSS_EfiDevicePathMsgNvme_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MSG0317 *msg0317 = &uefiDevicePath->msg0317;\n\n    printf(\"    SubType %02x NVME\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      NamespaceId %08x\\n\",  msg0317->NamespaceId);\n    printf(\"      NamespaceUuid %016\" PRIx64 \"\\n\", msg0317->NamespaceUuid);\n    return;\n}\n\nstatic void     TSS_EfiDevicePathMsgSata_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MSG0312 *msg0312 = &uefiDevicePath->msg0312;\n\n    printf(\"    SubType %02x Sata\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      HBA Port Number %hu\\n\", msg0312->HBAPortNumber);\n    printf(\"      Port Multiplier Port %hu\\n\", msg0312->PortMultiplierPort);\n    printf(\"      Logical Unit Number %hu\\n\", msg0312->LogicalUnitNumber);\n    return;\n}\n\nstatic void \tTSS_EfiDevicePathMsgMac_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MSG030B *msg030b = &uefiDevicePath->msg030b;\n\n    printf(\"    SubType %02x MAC\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      MAC %02x:%02x:%02x:%02x:%02x:%02x\\n\",\n\t   msg030b->Mac[0], msg030b->Mac[1], msg030b->Mac[2],\n\t   msg030b->Mac[3], msg030b->Mac[4], msg030b->Mac[5]);\n    printf(\"      IF Type %u\\n\", msg030b->IfType);\n    return;\n}\n\nstatic void     TSS_EfiDevicePathMsgIpv4_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MSG030C *msg030c = &uefiDevicePath->msg030c;\n\n    printf(\"    SubType %02x Ipv4\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      Local IP Address %u.%u.%u.%u\\n\",\n\t   msg030c->LocalIPAddress[0], msg030c->LocalIPAddress[1],\n\t   msg030c->LocalIPAddress[2], msg030c->LocalIPAddress[3]);\n    printf(\"      Remote IP Address %u.%u.%u.%u\\n\",\n\t   msg030c->RemoteIPAddress[0], msg030c->RemoteIPAddress[1],\n\t   msg030c->RemoteIPAddress[2], msg030c->RemoteIPAddress[3]);\n    printf(\"      Local Port %hu\\n\", msg030c->LocalPort);\n    printf(\"      Remote Port %hu\\n\", msg030c->RemotePort);\n    printf(\"      Protocol %hu\\n\", msg030c->Protocol);\n    printf(\"      Static IP Address (bool) %u\\n\", msg030c->StaticIPAddress);\n    printf(\"      Local IP Address %u.%u.%u.%u\\n\",\n\t   msg030c->GatewayIPAddress[0], msg030c->GatewayIPAddress[1],\n\t   msg030c->GatewayIPAddress[2], msg030c->GatewayIPAddress[3]);\n    printf(\"      Subnet Mask %u.%u.%u.%u\\n\",\n\t   msg030c->SubnetMask[0], msg030c->SubnetMask[1],\n\t   msg030c->SubnetMask[2], msg030c->SubnetMask[3]);\n    return;\n}\n\n/* TSS_EfiDevicePathMsgIpv6_Trace() does not trace in https://tools.ietf.org/html/rfc5952 format */\n\nstatic void     TSS_EfiDevicePathMsgIpv6_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MSG030D *msg030d = &uefiDevicePath->msg030d;\n\n    printf(\"    SubType %02x Ipv6\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      Local IP Address \"\n\t   \"%02x%02x:%02x%02x:%02x%02x:%02x%02x:\"\n\t   \"%02x%02x:%02x%02x:%02x%02x:%02x%02x\"\n\t   \"\\n\",\n\t   msg030d->LocalIPAddress[ 0], msg030d->LocalIPAddress[ 1],\n\t   msg030d->LocalIPAddress[ 2], msg030d->LocalIPAddress[ 3],\n\t   msg030d->LocalIPAddress[ 4], msg030d->LocalIPAddress[ 5],\n\t   msg030d->LocalIPAddress[ 6], msg030d->LocalIPAddress[ 7],\n\t   msg030d->LocalIPAddress[ 8], msg030d->LocalIPAddress[ 9],\n\t   msg030d->LocalIPAddress[10], msg030d->LocalIPAddress[11],\n\t   msg030d->LocalIPAddress[12], msg030d->LocalIPAddress[13],\n\t   msg030d->LocalIPAddress[14], msg030d->LocalIPAddress[15]);\n    printf(\"      Remote IP Address \"\n\t   \"%02x%02x:%02x%02x:%02x%02x:%02x%02x:\"\n\t   \"%02x%02x:%02x%02x:%02x%02x:%02x%02x\"\n\t   \"\\n\",\n\t   msg030d->RemoteIPAddress[ 0], msg030d->RemoteIPAddress[ 1],\n\t   msg030d->RemoteIPAddress[ 2], msg030d->RemoteIPAddress[ 3],\n\t   msg030d->RemoteIPAddress[ 4], msg030d->RemoteIPAddress[ 5],\n\t   msg030d->RemoteIPAddress[ 6], msg030d->RemoteIPAddress[ 7],\n\t   msg030d->RemoteIPAddress[ 8], msg030d->RemoteIPAddress[ 9],\n\t   msg030d->RemoteIPAddress[10], msg030d->RemoteIPAddress[11],\n\t   msg030d->RemoteIPAddress[12], msg030d->RemoteIPAddress[13],\n\t   msg030d->RemoteIPAddress[14], msg030d->RemoteIPAddress[15]);\n    printf(\"      Local Port %hu\\n\", msg030d->LocalPort);\n    printf(\"      Remote Port %hu\\n\", msg030d->RemotePort);\n    printf(\"      Protocol %hu\\n\", msg030d->Protocol);\n    printf(\"      IP Address Origin %u\\n\", msg030d->IPAddressOrigin);\n    printf(\"      Prefix Length %u\\n\", msg030d->PrefixLength);\n    printf(\"      Gateway IP Address \"\n\t   \"%02x%02x:%02x%02x:%02x%02x:%02x%02x:\"\n\t   \"%02x%02x:%02x%02x:%02x%02x:%02x%02x\"\n\t   \"\\n\",\n\t   msg030d->GatewayIPAddress[ 0], msg030d->GatewayIPAddress[ 1],\n\t   msg030d->GatewayIPAddress[ 2], msg030d->GatewayIPAddress[ 3],\n\t   msg030d->GatewayIPAddress[ 4], msg030d->GatewayIPAddress[ 5],\n\t   msg030d->GatewayIPAddress[ 6], msg030d->GatewayIPAddress[ 7],\n\t   msg030d->GatewayIPAddress[ 8], msg030d->GatewayIPAddress[ 9],\n\t   msg030d->GatewayIPAddress[10], msg030d->GatewayIPAddress[11],\n\t   msg030d->GatewayIPAddress[12], msg030d->GatewayIPAddress[13],\n\t   msg030d->GatewayIPAddress[14], msg030d->GatewayIPAddress[15]);\n    return;\n}\n\nstatic void     TSS_EfiDevicePathMsgUri_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"    SubType %02x URI\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      URI: %.*s\\n\",\n\t   (int)uefiDevicePath->unionBufferLength,\n\t   uefiDevicePath->unionBuffer);\n}\n\nstatic void     TSS_EfiDevicePathMsgVendor_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MSG030A *msg030a = &uefiDevicePath->msg030a;\n\n    printf(\"    SubType %02x Vendor\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    guid_printf(\"    Vendor GUID\", msg030a->VendorGUID);\n    TSS_PrintAll(\"     Vendor\",\n\t\t uefiDevicePath->unionBuffer,\n\t\t uefiDevicePath->unionBufferLength);\n    return;\n}\n\n/* From UEFI 10.3.3 Media Device Path - Type 4 SubTypes */\n\nstatic uint32_t TSS_EfiDevicePathMediaHd_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t    uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MEDIA0401 *media0401 = &uefiDevicePath->media0401;\n\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&media0401->PartitionNumber, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&media0401->PartitionStart, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&media0401->PartitionSize, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(media0401->PartitionSignature,\n\t\t\t\t  sizeof(media0401->PartitionSignature),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&media0401->PartitionFormat, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&media0401->SignatureType, event, eventSize);\n    }\n    return rc;\n}\n\n#if 0\nstatic uint32_t TSS_EfiDevicePathMediaCdrom_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t       uint8_t **event, uint32_t *eventSize)\n{\n}\n\nstatic uint32_t TSS_EfiDevicePathMediaVendor_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize)\n{\n}\n#endif\n\nstatic uint32_t TSS_EfiDevicePathMediaFile_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t      uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n\n    /* if there is a path.  Zero should be an error because of the NUL termination */\n    if (uefiDevicePath->protocol.Length > sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL)) {\n\tif (rc == 0) {\n\t    uefiDevicePath->buffer =\n\t\tmalloc(uefiDevicePath->protocol.Length - sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL));\n\t    if (uefiDevicePath->buffer == NULL) {\n\t\tprintf(\"TSS_EfiDevicePathMediaFile_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(uefiDevicePath->protocol.Length -\n\t\t\t\t      sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL)));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    uefiDevicePath->bufferLength = uefiDevicePath->protocol.Length -\n\t\t\t\t\t   sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL);\n\t    rc = TSS_Array_Unmarshalu(uefiDevicePath->buffer,\n\t\t\t\t      uefiDevicePath->bufferLength,\n\t\t\t\t      event, eventSize);\n\t}\n    }\n    return rc;\n}\n\n#if 0\nstatic uint32_t TSS_EfiDevicePathMediaMedia_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t       uint8_t **event, uint32_t *eventSize)\n{\n}\n#endif\n\n/* Contents are defined in the UEFI PI Specification, seems to be a GUID. */\n\nstatic uint32_t TSS_EfiDevicePathMediaPiwgFile_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n\n    if (uefiDevicePath->protocol.Length > sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL)) {\n\tif (rc == 0) {\n\t    uefiDevicePath->buffer =\n\t\tmalloc(uefiDevicePath->protocol.Length - sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL));\n\t    if (uefiDevicePath->buffer == NULL) {\n\t\tprintf(\"TSS_EfiDevicePathMediaPiwgFile_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(uefiDevicePath->protocol.Length -\n\t\t\t\t      sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL)));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    uefiDevicePath->bufferLength = uefiDevicePath->protocol.Length -\n\t\t\t\t\t   sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL);\n\t    rc = TSS_Array_Unmarshalu(uefiDevicePath->buffer,\n\t\t\t\t      uefiDevicePath->bufferLength,\n\t\t\t\t      event, eventSize);\n\t}\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMediaPiwgFw_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n\n    /* if there is a path.  Zero should be an error because of the NUL termination */\n    if (uefiDevicePath->protocol.Length > sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL)) {\n\tif (rc == 0) {\n\t    uefiDevicePath->buffer =\n\t\tmalloc(uefiDevicePath->protocol.Length - sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL));\n\t    if (uefiDevicePath->buffer == NULL) {\n\t\tprintf(\"TSS_EfiDevicePathMediaPiwgFw_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(uefiDevicePath->protocol.Length -\n\t\t\t\t      sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL)));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    uefiDevicePath->bufferLength = uefiDevicePath->protocol.Length -\n\t\t\t\t\t   sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL);\n\t    rc = TSS_Array_Unmarshalu(uefiDevicePath->buffer,\n\t\t\t\t      uefiDevicePath->bufferLength,\n\t\t\t\t      event, eventSize);\n\t}\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiDevicePathMediaOffset_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_MEDIA0408 *media0408 = &uefiDevicePath->media0408;\n\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&media0408->Reserved, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&media0408->StartingOffset, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&media0408->EndingOffset, event, eventSize);\n    }\n    return rc;\n}\n\n#if 0\nstatic uint32_t TSS_EfiDevicePathMediaRamdisk_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t\t\t uint8_t **event, uint32_t *eventSize)\n{\n}\n#endif\n\nstatic void TSS_EfiDevicePathMediaHd_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MEDIA0401 *media0401 = &uefiDevicePath->media0401;\n\n    printf(\"    SubType %02x Media HD\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      Partition Number %u\\n\",  media0401->PartitionNumber);\n    printf(\"      Partition Start %016\" PRIx64 \"\\n\", media0401->PartitionStart);\n    printf(\"      Partition Size %016\" PRIx64 \"\\n\", media0401->PartitionSize);\n    if (media0401->PartitionFormat == 0x01) {\n\tprintf(\"      Partition Format PC AT MBR\\n\");\n    }\n    else if (media0401->PartitionFormat == 0x02) {\n\tprintf(\"      Partition Format GUID Partition Table\\n\");\n    }\n    else {\n\tprintf(\"      Partition Format %u unknown\\n\", media0401->PartitionFormat);\n    }\n    printf(\"      Signature Type %u\\n\", media0401->SignatureType);\n    if (media0401->SignatureType == 0x00) {\n\tprintf(\"      No Disk Signature\\n\");\n    }\n    else if (media0401->SignatureType == 0x02) {\n\tguid_printf(\"    Signature\", media0401->PartitionSignature);\n    }\n    else {\n\tTSS_PrintAll(\"    Signature\",\n\t\t     media0401->PartitionSignature,\n\t\t     sizeof(media0401->PartitionSignature));\n    }\n    return;\n}\n\n#if 0\nstatic void TSS_EfiDevicePathMediaCdrom_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n\nstatic void TSS_EfiDevicePathMediaVendor_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n#endif\n\nstatic void TSS_EfiDevicePathMediaFile_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    /* subtract 2 because this field is NUL terminated */\n    printf(\"    SubType %02x File Path\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    ucs2_printf(\"    Path Name: \", uefiDevicePath->buffer,\n\t\t(uefiDevicePath->bufferLength -2));\n    return;\n}\n\n#if 0\nstatic void TSS_EfiDevicePathMediaMedia_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n#endif\n\nstatic void TSS_EfiDevicePathMediaPiwgFile_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"    SubType %02x Firmware File\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    /* apparently, this value is a GUID */\n    if (uefiDevicePath->bufferLength == TSS_EFI_GUID_SIZE) {\n\tguid_printf(\"    Firmware File\", uefiDevicePath->buffer);\n    }\n    else {\n\tTSS_PrintAll(\"    Firmware File\",\n\t\t     uefiDevicePath->buffer,\n\t\t     uefiDevicePath->bufferLength);\n    }\n    return;\n}\n\nstatic void TSS_EfiDevicePathMediaPiwgFw_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"    SubType %02x Firmware Volume\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    /* apparently, this value is a GUID */\n    if (uefiDevicePath->bufferLength == TSS_EFI_GUID_SIZE) {\n\tguid_printf(\"    Firmware Volume\", uefiDevicePath->buffer);\n    }\n    else {\n\tTSS_PrintAll(\"    Firmware Volume\",\n\t\t     uefiDevicePath->buffer,\n\t\t     uefiDevicePath->bufferLength);\n    }\n    return;\n}\n\nstatic void TSS_EfiDevicePathMediaOffset_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    TSS_MEDIA0408 *media0408 = &uefiDevicePath->media0408;\n\n    printf(\"    SubType %02x Media Offset\\n\",\n\t   uefiDevicePath->protocol.SubType);\n    printf(\"      Starting Offset %016\" PRIx64 \"\\n\", media0408->StartingOffset);\n    printf(\"      Ending Offset %016\" PRIx64 \"\\n\", media0408->EndingOffset);\n\n    return;\n}\n\n#if 0\nstatic void TSS_EfiDevicePathMediaRamdisk_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    printf(\"Type %02x SubType %02x trace not implemented\\n\",\n\t   uefiDevicePath->protocol.Type,\n\t   uefiDevicePath->protocol.SubType);\n    return;\n}\n#endif\n\n/* EV_EFI_PLATFORM_FIRMWARE_BLOB */\n\nstatic uint32_t TSS_EfiPlatformFirmwareBlob_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\t       uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\t       uint32_t pcrIndex);\nstatic void     TSS_EfiPlatformFirmwareBlob_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiPlatformFirmwareBlob_ToJson(TSST_EFIData *efiData);\n\n/* EV_EFI_VARIABLE_DRIVER_CONFIG\n   EV_EFI_VARIABLE_BOOT\n   EV_EFI_VARIABLE_AUTHORITY\n*/\n\nstatic void     TSS_EfiVariableData_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiVariableData_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiVariableData_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t      uint8_t **event, uint32_t *eventSize);\nstatic void     TSS_EfiVariableData_Trace(TSST_EFIData *efiData);\n\n/* EV_EFI_VARIABLE_DRIVER_CONFIG */\n\nstatic void     TSS_EfiVariableDriverConfig_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiVariableDriverConfig_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiVariableDriverConfig_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\t      uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\t      uint32_t pcrIndex);\nstatic void     TSS_EfiVariableDriverConfig_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiVariableDriverConfig_ToJson(TSST_EFIData *efiData);\n\n/* EV_EFI_VARIABLE_BOOT */\n\nstatic void     TSS_EfiVariableBoot_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiVariableBoot_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiVariableBoot_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t      uint8_t *event, uint32_t eventSize, uint32_t pcrIndex);\nstatic void     TSS_EfiVariableBoot_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiVariableBoot_ToJson(TSST_EFIData *efiData);\n\n/* for BootOrder */\nstatic void     TSS_EfiVariableBootOrder_Init(TSS_VARIABLE_BOOT_ORDER *variableBootOrder);\nstatic void     TSS_EfiVariableBootOrder_Free(TSS_VARIABLE_BOOT_ORDER *variableBootOrder);\nstatic uint32_t TSS_EfiVariableBootOrder_ReadBuffer(TSS_VARIABLE_BOOT_ORDER *variableBootOrder,\n\t\t\t\t\t\t    uint8_t *VariableData, uint32_t VariableDataLength);\n/* for not BootOrder */\nstatic void     TSS_EfiVariableBootPath_Init(TSS_VARIABLE_BOOT *variableBoot);\nstatic void     TSS_EfiVariableBootPath_Free(TSS_VARIABLE_BOOT *variableBoot);\nstatic uint32_t TSS_EfiVariableBootPath_ReadBuffer(TSS_VARIABLE_BOOT *variableBoot,\n\t\t\t\t\t\t   void *VariableData, uint64_t VariableDataLength);\n\n/* EV_EFI_PLATFORM_FIRMWARE_BLOB */\n\nstatic uint32_t TSS_EfiPlatformFirmwareBlob_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\t      uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\t      uint32_t pcrIndex);\nstatic void     TSS_EfiPlatformFirmwareBlob_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiPlatformFirmwareBlob_ToJson(TSST_EFIData *efiData);\n\n/* TSS_EFI_SIGNATURE_LIST within TSS_UEFI_VARIABLE_DATA */\n\nstatic void     TSS_EfiSignatureList_Init(TSS_EFI_SIGNATURE_LIST *signatureList);\nstatic void     TSS_EfiSignatureList_Free(TSS_EFI_SIGNATURE_LIST *signatureList);\nstatic uint32_t TSS_EfiSignatureList_ReadBuffer(TSS_EFI_SIGNATURE_LIST *signatureList,\n\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize);\nstatic void     TSS_EfiSignatureList_Trace(TSS_EFI_SIGNATURE_LIST *signatureList);\n\n/* TSS_UEFI_VARIABLE_DATA for PK, KEK, db, dbx, dbr, dbt, etc. */\n\nstatic uint32_t TSS_EfiSignatureAllLists_ReadBuffer(TSS_EFI_SIGNATURE_LIST **signatureList,\n\t\t\t\t\t\t    uint32_t *signatureListCount,\n\t\t\t\t\t\t    uint8_t *VariableData,\n\t\t\t\t\t\t    uint32_t VariableDataLength);\n\n/* EV_EFI_VARIABLE_AUTHORITY */\n\nstatic void     TSS_EfiVariableAuthority_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiVariableAuthority_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiVariableAuthority_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\t   uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\t   uint32_t pcrIndex);\nstatic void     TSS_EfiVariableAuthority_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiVariableAuthority_ToJson(TSST_EFIData *efiData);\n\n/* EV_EFI_BOOT_SERVICES_APPLICATION\n   EV_EFI_BOOT_SERVICES_DRIVER\n*/\n\nstatic void     TSS_EfiBootServices_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiBootServices_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiBootServices_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t       uint8_t *event, uint32_t eventSize, uint32_t pcrIndex);\nstatic void     TSS_EfiBootServices_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiBootServices_ToJson(TSST_EFIData *efiData);\n\n/* TSS_UEFI_DEVICE_PATH  */\n\nstatic void     TSS_UefiDevicePath_Init(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic void     TSS_UefiDevicePath_Free(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic uint32_t TSS_UefiDevicePath_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t     uint8_t **event, uint32_t *eventSize);\nstatic void     TSS_UefiDevicePath_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\nstatic uint32_t TSS_UefiDevicePath_ToJson(TSS_UEFI_DEVICE_PATH *uefiDevicePath);\n\n/* EV_EFI_GPT_EVENT */\n\nstatic void     TSS_EfiGptEvent_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiGptEvent_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiGptEvent_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t  uint8_t *event, uint32_t eventSize, uint32_t pcrIndex);\nstatic void     TSS_EfiGptEvent_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiGptEvent_ToJson(TSST_EFIData *efiData);\n\n/* EV_EFI_GPT_EVENT */\n\nstatic uint32_t TSS_EfiPartitionHeader_ReadBuffer(TSS_UEFI_PARTITION_TABLE_HEADER *efiPartitionHeader,\n\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize);\nstatic uint32_t TSS_EfiPartitionEntry_ReadBuffer(TSS_UEFI_PARTITION_ENTRY *entry,\n\t\t\t\t\t\t uint8_t **event, uint32_t *eventSize);\nstatic void     TSS_EfiPartitionHeader_Trace(TSS_UEFI_PARTITION_TABLE_HEADER *efiPartitionHeader);\nstatic void     TSS_EfiPartitionEntry_Trace(TSS_UEFI_PARTITION_ENTRY *entry);\n\n/* EV_POST_CODE */\n\nstatic void     TSS_EfiPostCode_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiPostCode_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiPostCode_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t   uint8_t *event, uint32_t eventSize, uint32_t pcrIndex);\nstatic void     TSS_EfiPostCode_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiPostCode_ToJson(TSST_EFIData *efiData);\n\n/* EV_S_CRTM_VERSION\n   EV_COMPACT_HASH\n*/\n\nstatic void     TSS_Efi4bBuffer_Init(TSST_EFIData *efiData);\nstatic void     TSS_Efi4bBuffer_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_Efi4bBuffer_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t  uint8_t *event, uint32_t eventSize, uint32_t pcrIndex);\n\n/* EV_COMPACT_HASH */\n\nstatic void     TSS_EfiCompactHash_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiCompactHash_ToJson(TSST_EFIData *efiData);\n\n/* EV_IPL */\n\nstatic void     TSS_EfiIpl_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiIpl_ToJson(TSST_EFIData *efiData);\n\n/* EV_IPL_PARTITION_DATA */\n\nstatic void     TSS_EfiIplPartitionData_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiIplPartitionData_ToJson(TSST_EFIData *efiData);\n\n/* EV_S_CRTM_VERSION */\n\nstatic void     TSS_EfiCrtmVersion_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiCrtmVersion_ToJson(TSST_EFIData *efiData);\n\n/* EV_S_CRTM_CONTENTS */\n\nstatic void     TSS_EfiCrtmContents_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiCrtmContents_ToJson(TSST_EFIData *efiData);\n\n/* EV_EFI_ACTION */\n\nstatic void     TSS_EfiEfiAction_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiEfiAction_ToJson(TSST_EFIData *efiData);\n\n/* Event that is only a printable string */\n\n#if 0\nstatic uint32_t TSS_EfiChar_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t      uint8_t *event, uint32_t eventSize, uint32_t pcrIndex);\nstatic void     TSS_EfiChar_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiChar_ToJson(TSST_EFIData *efiData);\n\n#endif\n\n/* EV_NO_ACTION */\n\nstatic void     TSS_EvNoAction_Trace(TSST_EFIData *efiData);\n\n/* EV_SEPARATOR */\n\nstatic void     TSS_EfiSeparator_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiSeparator_ToJson(TSST_EFIData *efiData);\n\n/* EV_ACTION */\n\nstatic void     TSS_EfiAction_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiAction_ToJson(TSST_EFIData *efiData);\n\n/* EV_EVENT_TAG */\n\nstatic void     TSS_EfiEventTag_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiEventTag_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiEvent_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t       uint8_t *event, uint32_t eventSize,\n\t\t\t\t       uint32_t pcrIndex);\nstatic void     TSS_EfiEventTag_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiEventTag_ToJson(TSST_EFIData *efiData);\n\n/* EV_EFI_HANDOFF_TABLES\n   EV_EFI_HANDOFF_TABLES2\n   EV_TABLE_OF_DEVICES\n*/\n\nstatic void     TSS_EfiHandoffTables_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiHandoffTables_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiHandoffTables_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t       uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t       uint32_t pcrIndex);\nstatic void     TSS_EfiHandoffTables_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiHandoffTables_ToJson(TSST_EFIData *efiData);\n\nstatic void     TSS_EfiHandoffTables2_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiHandoffTables2_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiHandoffTables2_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\tuint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\tuint32_t pcrIndex);\nstatic void     TSS_EfiHandoffTables2_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiHandoffTables2_ToJson(TSST_EFIData *efiData);\n\n/* common code */\n\nstatic uint32_t\nTSS_EfiTablePointers_ReadBuffer(TSS_UEFI_HANDOFF_TABLE_POINTERS *uefiHandoffTablePointers,\n\t\t\t\tuint8_t **event, uint32_t *eventSize,\n\t\t\t\tuint32_t pcrIndex);\n\n\n/* EV_EFI_PLATFORM_FIRMWARE_BLOB2 */\n\nstatic void     TSS_EfiPlatformFirmwareBlob2_Init(TSST_EFIData *efiData);\nstatic void     TSS_EfiPlatformFirmwareBlob2_Free(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiPlatformFirmwareBlob2_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\t       uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\t       uint32_t pcrIndex);\nstatic void     TSS_EfiPlatformFirmwareBlob2_Trace(TSST_EFIData *efiData);\nstatic uint32_t TSS_EfiPlatformFirmwareBlob2_ToJson(TSST_EFIData *efiData);\n\n/* Table to map eventType to handling function callbacks.\n\n   Missing events return an TSS_RC_NOT_IMPLEMENTED.\n\n   Events with NULL for initFunction and freeFunction are legal, meaning that the readBufferFunction\n   will not malloc memory that needs pointers to be initialized to NULL and freed,\n\n   NULL entries for readBufferFunction, traceFunction, or toJsonFunction are errors.\n*/\n\n/* function prototypes for event callback table */\n\ntypedef void     (*TSS_EFIData_Init_Function_t)(TSST_EFIData *efiData);\ntypedef void     (*TSS_EFIData_Free_Function_t)(TSST_EFIData *efiData);\ntypedef uint32_t (*TSS_EFIData_ReadBuffer_Function_t)(TSST_EFIData *efiData,\n\t\t\t\t\t\t      uint8_t *event,\n\t\t\t\t\t\t      uint32_t eventSize,\n\t\t\t\t\t\t      uint32_t pcrIndex);\ntypedef void     (*TSS_EFIData_Trace_Function_t)(TSST_EFIData *efiData);\ntypedef uint32_t (*TSS_EFIData_ToJson_Function_t)(TSST_EFIData *efiData);\n\ntypedef struct {\n    uint32_t eventType;\t\t\t\t\t/* PC Client event */\n    TSS_EFIData_Init_Function_t\t\tinitFunction;\n    TSS_EFIData_Free_Function_t\t\tfreeFunction;\n    TSS_EFIData_ReadBuffer_Function_t\treadBufferFunction;\n    TSS_EFIData_Trace_Function_t\ttraceFunction;\n    TSS_EFIData_ToJson_Function_t\ttoJsonFunction;\n} EFI_EVENT_TYPE_TABLE;\n\nconst EFI_EVENT_TYPE_TABLE efiEventTypeTable [] =\n    {\n#if 0\t/* reserved for future use */\n     {EV_PREBOOT_CERT,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n#endif\n     {EV_POST_CODE,\n      TSS_EfiPostCode_Init,\n      TSS_EfiPostCode_Free,\n      TSS_EfiPostCode_ReadBuffer,\n      TSS_EfiPostCode_Trace,\n      TSS_EfiPostCode_ToJson},\n#if 0\t/* deprecated */\n     {EV_UNUSED,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n#endif\n     {EV_NO_ACTION,\n      TSS_Efi4bBuffer_Init,\n      TSS_Efi4bBuffer_Free,\n      TSS_Efi4bBuffer_ReadBuffer,\n      TSS_EvNoAction_Trace,\n      NULL},\n     {EV_SEPARATOR,\n      TSS_Efi4bBuffer_Init,\n      TSS_Efi4bBuffer_Free,\n      TSS_Efi4bBuffer_ReadBuffer,\n      TSS_EfiSeparator_Trace,\n      TSS_EfiSeparator_ToJson},\n     {EV_ACTION,\n      TSS_Efi4bBuffer_Init,\n      TSS_Efi4bBuffer_Free,\n      TSS_Efi4bBuffer_ReadBuffer,\n      TSS_EfiAction_Trace,\n      TSS_EfiAction_ToJson},\n     {EV_EVENT_TAG,\n      TSS_EfiEventTag_Init,\n      TSS_EfiEventTag_Free,\n      TSS_EfiEvent_ReadBuffer,\n      TSS_EfiEventTag_Trace,\n      TSS_EfiEventTag_ToJson},\n     {EV_S_CRTM_CONTENTS,\n      TSS_Efi4bBuffer_Init,\n      TSS_Efi4bBuffer_Free,\n      TSS_Efi4bBuffer_ReadBuffer,\n      TSS_EfiCrtmContents_Trace,\n      TSS_EfiCrtmContents_ToJson},\n     {EV_S_CRTM_VERSION,\n      TSS_Efi4bBuffer_Init,\n      TSS_Efi4bBuffer_Free,\n      TSS_Efi4bBuffer_ReadBuffer,\n      TSS_EfiCrtmVersion_Trace,\n      TSS_EfiCrtmVersion_ToJson},\n#if 0\t/* needs a test event log */\n     {EV_CPU_MICROCODE,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n     {EV_PLATFORM_CONFIG_FLAGS,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n#endif\n     {EV_TABLE_OF_DEVICES,\n      TSS_EfiHandoffTables_Init,\n      TSS_EfiHandoffTables_Free,\n      TSS_EfiHandoffTables_ReadBuffer,\n      TSS_EfiHandoffTables_Trace,\n      TSS_EfiHandoffTables_ToJson},\n     {EV_COMPACT_HASH,\n      TSS_Efi4bBuffer_Init,\n      TSS_Efi4bBuffer_Free,\n      TSS_Efi4bBuffer_ReadBuffer,\n      TSS_EfiCompactHash_Trace,\n      TSS_EfiCompactHash_ToJson},\n     {EV_IPL,\n      TSS_Efi4bBuffer_Init,\n      TSS_Efi4bBuffer_Free,\n      TSS_Efi4bBuffer_ReadBuffer,\n      TSS_EfiIpl_Trace,\n      TSS_EfiIpl_ToJson},\n     {EV_IPL_PARTITION_DATA,\n      TSS_Efi4bBuffer_Init,\n      TSS_Efi4bBuffer_Free,\n      TSS_Efi4bBuffer_ReadBuffer,\n      TSS_EfiIplPartitionData_Trace,\n      TSS_EfiIplPartitionData_ToJson},\n#if 0\t/* needs a test event log */\n     {EV_NONHOST_CODE,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n     {EV_NONHOST_CONFIG,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n     {EV_NONHOST_INFO,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n     {EV_OMIT_BOOT_DEVICE_EVENTS,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n#endif\n    {EV_EFI_VARIABLE_DRIVER_CONFIG,\n      TSS_EfiVariableDriverConfig_Init,\n      TSS_EfiVariableDriverConfig_Free,\n      TSS_EfiVariableDriverConfig_ReadBuffer,\n      TSS_EfiVariableDriverConfig_Trace,\n      TSS_EfiVariableDriverConfig_ToJson},\n     {EV_EFI_VARIABLE_BOOT,\n      TSS_EfiVariableBoot_Init,\n      TSS_EfiVariableBoot_Free,\n      TSS_EfiVariableBoot_ReadBuffer,\n      TSS_EfiVariableBoot_Trace,\n      TSS_EfiVariableBoot_ToJson},\n     {EV_EFI_BOOT_SERVICES_APPLICATION,\n      TSS_EfiBootServices_Init,\n      TSS_EfiBootServices_Free,\n      TSS_EfiBootServices_ReadBuffer,\n      TSS_EfiBootServices_Trace,\n      TSS_EfiBootServices_ToJson},\n     {EV_EFI_BOOT_SERVICES_DRIVER,\n      TSS_EfiBootServices_Init,\n      TSS_EfiBootServices_Free,\n      TSS_EfiBootServices_ReadBuffer,\n      TSS_EfiBootServices_Trace,\n      TSS_EfiBootServices_ToJson},\n#if 0\t/* needs a test event log */\n     {EV_EFI_RUNTIME_SERVICES_DRIVER,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n#endif\n     {EV_EFI_GPT_EVENT,\n      TSS_EfiGptEvent_Init,\n      TSS_EfiGptEvent_Free,\n      TSS_EfiGptEvent_ReadBuffer,\n      TSS_EfiGptEvent_Trace,\n      TSS_EfiGptEvent_ToJson},\n     {EV_EFI_ACTION,\n      TSS_Efi4bBuffer_Init,\n      TSS_Efi4bBuffer_Free,\n      TSS_Efi4bBuffer_ReadBuffer,\n      TSS_EfiEfiAction_Trace,\n      TSS_EfiEfiAction_ToJson},\n     {EV_EFI_PLATFORM_FIRMWARE_BLOB,\n      NULL,\n      NULL,\n      TSS_EfiPlatformFirmwareBlob_ReadBuffer,\n      TSS_EfiPlatformFirmwareBlob_Trace,\n      TSS_EfiPlatformFirmwareBlob_ToJson},\n     {EV_EFI_HANDOFF_TABLES,\n      TSS_EfiHandoffTables_Init,\n      TSS_EfiHandoffTables_Free,\n      TSS_EfiHandoffTables_ReadBuffer,\n      TSS_EfiHandoffTables_Trace,\n      TSS_EfiHandoffTables_ToJson},\n     {EV_EFI_HANDOFF_TABLES2,\n      TSS_EfiHandoffTables2_Init,\n      TSS_EfiHandoffTables2_Free,\n      TSS_EfiHandoffTables2_ReadBuffer,\n      TSS_EfiHandoffTables2_Trace,\n      TSS_EfiHandoffTables2_ToJson},\n     {EV_EFI_PLATFORM_FIRMWARE_BLOB2,\n      TSS_EfiPlatformFirmwareBlob2_Init,\n      TSS_EfiPlatformFirmwareBlob2_Free,\n      TSS_EfiPlatformFirmwareBlob2_ReadBuffer,\n      TSS_EfiPlatformFirmwareBlob2_Trace,\n      TSS_EfiPlatformFirmwareBlob2_ToJson},\n     {EV_EFI_HCRTM_EVENT,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n     {EV_EFI_VARIABLE_AUTHORITY,\n      TSS_EfiVariableAuthority_Init,\n      TSS_EfiVariableAuthority_Free,\n      TSS_EfiVariableAuthority_ReadBuffer,\n      TSS_EfiVariableAuthority_Trace,\n      TSS_EfiVariableAuthority_ToJson},\n     {EV_EFI_SUPERMICRO_1,\n      NULL,\n      NULL,\n      NULL,\n      NULL,\n      NULL},\n    };\n\nstatic uint32_t TSS_EFI_GetTableIndex(size_t *index, uint32_t eventType);\n\n/* TSS_EFI_GetTableIndex() searches the event type table for the event handlers.\n\n   Returns TSS_RC_NOT_IMPLEMENTED if the event type is unknown.\n*/\n\nstatic uint32_t TSS_EFI_GetTableIndex(size_t *index, uint32_t eventType)\n{\n    for (*index = 0 ;\n\t *index < sizeof(efiEventTypeTable) / sizeof(EFI_EVENT_TYPE_TABLE) ;\n\t (*index)++) {\n\tif (efiEventTypeTable[*index].eventType == eventType) {\n\t    return 0;\t/* match */\n\t}\n    }\n    return TSS_RC_NOT_IMPLEMENTED;\t\t/* no match */\n}\n\n/*\n  This is the library external interface\n*/\n\n/* TSS_EFIData_Init() initializes the efiData structure based on the EFI eventType so that\n   TSS_EFIData_Free() is safe.\n\n   Returns\n\n   TSS_RC_NOT_IMPLEMENTED: eventType is not supported\n   TSS_RC_OUT_OF_MEMORY: malloc failure\n*/\n\nuint32_t TSS_EFIData_Init(TSST_EFIData **efiData,\t/* freed by TSS_EFIData_Free */\n\t\t\t  uint32_t eventType,\n\t\t\t  const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    size_t index;\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n    /* if the eventType is supported */\n    if (rc == 0) {\n\trc = TSS_EFI_GetTableIndex(&index, eventType);\n    }\n    /* malloc the structure */\n    if (rc == 0) {\n\t*efiData = malloc(sizeof(TSST_EFIData));\t/* freed by caller */\n\tif (*efiData == NULL) {\n\t    printf(\"TSS_EFIData_Init: Error allocating %u bytes\\n\",\n\t\t   (unsigned int)sizeof(TSST_EFIData));\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\t(*efiData)->eventType = eventType;\n\t/* if there is an initialization function */\n\t/* eventType specific initialization */\n\tif (efiEventTypeTable[index].initFunction != NULL) {\n\t    efiEventTypeTable[index].initFunction(*efiData);\n\t}\n\t/* NULL is not an error, means that no read malloc will occur */\n    }\n    return rc;\n}\n\n/* TSS_EFIData_Free() the efiData structure based on the EFI eventType. */\n\nvoid TSS_EFIData_Free(TSST_EFIData *efiData,\n\t\t      const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    size_t index;\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n\n    if (efiData != NULL) {\n\t/* a failure here is a call sequence error */\n\tif (rc == 0) {\n\t    rc = TSS_EFI_GetTableIndex(&index, efiData->eventType);\n\t}\n\tif (rc == 0) {\n\t    /* eventType specific free */\n\t    if (efiEventTypeTable[index].freeFunction != NULL) {\n\t\tefiEventTypeTable[index].freeFunction(efiData);\n\t    }\n\t    /* NULL is not an error, means that no read malloc occured */\n\t}\n\tfree(efiData);\n    }\n    return;\n}\n\n/* TSS_EFIData_ReadBuffer() parses the event based on the EFI eventType.\n\n   Returns TSS_RC_NOT_IMPLEMENTED if the eventType is not supported.\n*/\n\nuint32_t TSS_EFIData_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\tuint8_t *event, uint32_t eventSize,\n\t\t\t\tuint32_t pcrIndex,\n\t\t\t\tconst TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    size_t index;\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n\n    /* save the PCR index because some subsequent functions depend on the PCR value */\n    if (rc == 0) {\n\tefiData->pcrIndex = pcrIndex;\n    }\n    /* a failure here is a call sequence error */\n    if (rc == 0) {\n\trc = TSS_EFI_GetTableIndex(&index, efiData->eventType);\n    }\n    if (rc == 0) {\n\t/* eventType specific read buffer */\n\tif (efiEventTypeTable[index].readBufferFunction != NULL) {\n\t    rc = efiEventTypeTable[index].readBufferFunction(efiData,\n\t\t\t\t\t\t\t     event, eventSize,\n\t\t\t\t\t\t\t     pcrIndex);\n\t}\n\t/* this should never occur, there should be no NULLs in the table */\n\telse {\n\t    rc = TSS_RC_NOT_IMPLEMENTED;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_EFIData_Trace() traces the efiData to stdout.\n\n   It assumes that the TSS_EFIData structure and eventType are valid.\n*/\n\nvoid TSS_EFIData_Trace(TSST_EFIData *efiData,\n\t\t       const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    size_t index;\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n\n    /* a failure here is a call sequence error */\n    if (rc == 0) {\n\trc = TSS_EFI_GetTableIndex(&index, efiData->eventType);\n\tif (rc != 0) {\n\t    printf(\"TSS_EFIData_Trace: eventType %08x is not in trace table\\n\",\n\t\t   efiData->eventType);\n\t}\n    }\n    if (rc == 0) {\n\t/* eventType specific traceFunction */\n\tif (efiEventTypeTable[index].traceFunction != NULL) {\n\t    efiEventTypeTable[index].traceFunction (efiData);\n\t}\n\t/* this should never occur, there should be no NULLs in the table */\n\telse {\n\t    printf(\"TSS_EFIData_Trace: eventType %08x has NULL trace function\\n\",\n\t\t   efiData->eventType);\n\t}\n    }\n    return;\n}\n\n/* TSS_EFIData_ToJson() outputs the efiData to stdout as json */\n\nuint32_t TSS_EFIData_ToJson(TSST_EFIData *efiData,\n\t\t\t    const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    size_t index;\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n\n    /* a failure here is a call sequence error */\n    if (rc == 0) {\n\trc = TSS_EFI_GetTableIndex(&index, efiData->eventType);\n    }\n    if (rc == 0) {\n\t/* eventType specific toJsonFunction */\n\tif (efiEventTypeTable[index].toJsonFunction != NULL) {\n\t    rc = efiEventTypeTable[index].toJsonFunction(efiData);\n\t}\n\t/* this should never occur, there should be no NULLs in the table */\n\telse {\n\t    rc = TSS_RC_NOT_IMPLEMENTED;\n\t}\n    }\n    return rc;\n}\n\n/* EV_POST_CODE handlers */\n\nstatic void     TSS_EfiPostCode_Init(TSST_EFIData *efiData)\n{\n    TSS_POST_CODE_TAGGED_EVENT *taggedEvent = &efiData->efiData.postTaggedEvent;\n    taggedEvent->tag = TSS_EV_POST_CODE_UNKNOWN;\n    taggedEvent->unionBufferLength = 0;\n    taggedEvent->unionBuffer = NULL;\n    return;\n}\n\nstatic void     TSS_EfiPostCode_Free(TSST_EFIData *efiData)\n{\n    TSS_POST_CODE_TAGGED_EVENT *taggedEvent = &efiData->efiData.postTaggedEvent;\n    free(taggedEvent->unionBuffer);\n    return;\n}\n\nstatic uint32_t TSS_EfiPostCode_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t   uint8_t *event, uint32_t eventSize, uint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_POST_CODE_TAGGED_EVENT *taggedEvent = &efiData->efiData.postTaggedEvent;\n    pcrIndex = pcrIndex;\n\n    /* allocate the taggedEventData */\n    if (eventSize > 0) {\n\tif (rc == 0) {\n\t    taggedEvent->unionBufferLength = eventSize;\n\t    taggedEvent->unionBuffer = malloc(eventSize);\n\t    if (taggedEvent->unionBuffer == NULL) {\n\t\tprintf(\"TSS_EfiPostCode_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(eventSize))\t;\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Array_Unmarshalu(taggedEvent->unionBuffer,\n\t\t\t\t      taggedEvent->unionBufferLength,\n\t\t\t\t      &event, &eventSize);\n\t}\n\t/* guess at the meaning of the event */\n\tif (rc == 0) {\n\t    if (taggedEvent->unionBufferLength == sizeof(TSS_UEFI_PLATFORM_FIRMWARE_BLOB)) {\n\n\t\tTSS_UEFI_PLATFORM_FIRMWARE_BLOB *firmwareBlob = &taggedEvent->postCode.firmwareBlob;\n\t\tuint8_t *tmpEvent = taggedEvent->unionBuffer;\n\t\tuint32_t tmpEventSize = taggedEvent->unionBufferLength;\n\n\t\ttaggedEvent->tag = TSS_EV_POST_CODE_BLOB;\n\t\tif (rc == 0) {\n\t\t    rc = TSS_UINT64LE_Unmarshal(&firmwareBlob->BlobBase, &tmpEvent , &tmpEventSize);\n\t\t}\n\t\tif (rc == 0) {\n\t\t    rc = TSS_UINT64LE_Unmarshal(&firmwareBlob->BlobLength, &tmpEvent , &tmpEventSize);\n\t\t}\n\t    }\n\t    else if ((taggedEvent->unionBufferLength > sizeof(TSS_UEFI_PLATFORM_FIRMWARE_BLOB) &&\n\t\t      taggedEvent->unionBufferLength == ((sizeof(uint8_t) +\n\t\t\t\t\t\t\t     sizeof(UEFI_PHYSICAL_ADDRESS) +\n\t\t\t\t\t\t\t     sizeof(uint64_t) +\n\t\t\t\t\t\t\t  taggedEvent->unionBuffer[0])))) {\n\n\t\tTSS_UEFI_PLATFORM_FIRMWARE_BLOB2 *firmwareBlob2 =\n\t\t    &taggedEvent->postCode.firmwareBlob2;\n\t\tuint8_t *tmpEvent = taggedEvent->unionBuffer;\n\t\tuint32_t tmpEventSize = taggedEvent->unionBufferLength;\n\n\t\ttaggedEvent->tag = TSS_EV_POST_CODE_BLOB2;\n\t\tif (rc == 0) {\n\t\t    rc = TSS_UINT8_Unmarshalu(&firmwareBlob2->BlobDescriptionSize,\n\t\t\t\t\t      &tmpEvent , &tmpEventSize);\n\t\t}\n\t\t/* skip the BlobDescription, a variable length buffer in the middle of the\n\t\t   structure */\n\t\tif (rc == 0) {\n\t\t    tmpEvent += taggedEvent->unionBuffer[0];\n\t\t    tmpEventSize -= taggedEvent->unionBuffer[0];\n\t\t}\n\t\tif (rc == 0) {\n\t\t    rc = TSS_UINT64LE_Unmarshal(&firmwareBlob2->BlobBase,\n\t\t\t\t\t\t&tmpEvent , &tmpEventSize);\n\t\t}\n\t\tif (rc == 0) {\n\t\t    rc = TSS_UINT64LE_Unmarshal(&firmwareBlob2->BlobLength,\n\t\t\t\t\t\t&tmpEvent , &tmpEventSize);\n\t\t}\n\t\t/* then copy just the BlobDescription, overwriting the rest of the already\n\t\t   unmarshaled event */\n\t\tif (rc == 0) {\n\t\t    memmove(taggedEvent->unionBuffer,\n\t\t\t    taggedEvent->unionBuffer + sizeof(uint8_t),\n\t\t\t    taggedEvent->unionBuffer[0]);\n\t\t}\n\t    }\n\t    else {\n\t\tint isAscii;\n\t\tisAsciiString(&isAscii,\n\t\t\t      taggedEvent->unionBuffer, taggedEvent->unionBufferLength);\n\t\tif (isAscii) {\n\t\t    taggedEvent->tag = TSS_EV_POST_CODE_ASCII;\n\t\t    /* string remains in unionBuffer */\n\t\t}\n\t\telse {\n\t\t    taggedEvent->tag = TSS_EV_POST_CODE_UNKNOWN;\n\t\t    /* event remains in unionBuffer */\n\t\t}\n\t    }\n\t}\n    }\n    else {\n\ttaggedEvent->tag = TSS_EV_POST_CODE_UNKNOWN;\n    }\n    return rc;\n}\n\nstatic void     TSS_EfiPostCode_Trace(TSST_EFIData *efiData)\n{\n    TSS_POST_CODE_TAGGED_EVENT *taggedEvent = &efiData->efiData.postTaggedEvent;\n\n    switch (taggedEvent->tag) {\n       case TSS_EV_POST_CODE_BLOB:\n\t printf(\"  BlobBase: %016\" PRIx64 \"\\n\", taggedEvent->postCode.firmwareBlob.BlobBase);\n\t printf(\"  BlobLength: %016\" PRIx64 \"\\n\", taggedEvent->postCode.firmwareBlob.BlobLength);\n\tbreak;\n      case TSS_EV_POST_CODE_BLOB2:\n\tprintf(\"  BlobDescription: %.*s\\n\", \n\t       (int)taggedEvent->postCode.firmwareBlob2.BlobDescriptionSize,\n\t       taggedEvent->unionBuffer);\n\n\tprintf(\"  BlobBase: %016\" PRIx64 \"\\n\", taggedEvent->postCode.firmwareBlob2.BlobBase);\n\tprintf(\"  BlobLength: %016\" PRIx64 \"\\n\", taggedEvent->postCode.firmwareBlob2.BlobLength);\n\tbreak;\n      case TSS_EV_POST_CODE_ASCII:\n\tprintf(\"  Post Code: %.*s\\n\",\n\t       (int)taggedEvent->unionBufferLength,\n\t       taggedEvent->unionBuffer);\n\tbreak;\n      case TSS_EV_POST_CODE_UNKNOWN:\n      default:\n\tTSS_PrintAll(\"   Data:\", taggedEvent->unionBuffer, taggedEvent->unionBufferLength);\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiPostCode_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_POST_CODE_TAGGED_EVENT *taggedEvent = &efiData->efiData.postTaggedEvent;\n    taggedEvent = taggedEvent;\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_EFI_PLATFORM_FIRMWARE_BLOB handlers */\n\nstatic uint32_t TSS_EfiPlatformFirmwareBlob_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\t      uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\t      uint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_PLATFORM_FIRMWARE_BLOB *uefiPlatformFirmwareBlob =\n\t&efiData->efiData.uefiPlatformFirmwareBlob;\n    pcrIndex = pcrIndex;\n\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiPlatformFirmwareBlob->BlobBase, &event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiPlatformFirmwareBlob->BlobLength, &event, &eventSize);\n    }\n    return rc;\n}\n\nstatic void TSS_EfiPlatformFirmwareBlob_Trace(TSST_EFIData *efiData)\n{\n    TSS_UEFI_PLATFORM_FIRMWARE_BLOB *uefiPlatformFirmwareBlob =\n\t&efiData->efiData.uefiPlatformFirmwareBlob;\n    printf(\"  BlobBase: %016\" PRIx64 \"\\n\", uefiPlatformFirmwareBlob->BlobBase);\n    printf(\"  BlobLength: %016\" PRIx64 \"\\n\", uefiPlatformFirmwareBlob->BlobLength);\n    return;\n}\n\nstatic uint32_t TSS_EfiPlatformFirmwareBlob_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_PLATFORM_FIRMWARE_BLOB *uefiPlatformFirmwareBlob =\n\t&efiData->efiData.uefiPlatformFirmwareBlob;\n    uefiPlatformFirmwareBlob = uefiPlatformFirmwareBlob; /* to silence compiler */\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_EFI_VARIABLE_DRIVER_CONFIG handlers */\n\nstatic void TSS_EfiVariableData_Init(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    uefiVariableData->UnicodeName = NULL;\n    uefiVariableData->VariableData = NULL;\n    uefiVariableData->variableDataTag = TSS_VAR_UNKNOWN;\n    return;\n}\n\nstatic void TSS_EfiVariableData_Free(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    free(uefiVariableData->UnicodeName);\n    free(uefiVariableData->VariableData);\n    return;\n}\n\n/* TSS_EfiVariableData_ReadBuffer()\n\n   Common code to several events.\n\n   Validates that the event has sufficient bytes for VariableDataLength\n*/\n\nstatic uint32_t TSS_EfiVariableData_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t      uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(uefiVariableData->VariableName,\n\t\t\t\t  sizeof(uefiVariableData->VariableName),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiVariableData->UnicodeNameLength,\n\t\t\t\t    event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiVariableData->VariableDataLength,\n\t\t\t\t    event, eventSize);\n    }\n    /* sanity check the lengths since the input is untrusted.  This also guarantees that a cast to\n       uint32_t is safe. */\n    if (rc == 0) {\n\tif (uefiVariableData->UnicodeNameLength > EFI_LENGTH_MAX/2) {\n\t    printf(\"TSS_EfiVariableData_ReadBuffer: UnicodeNameLength %\" PRIu64 \" too large\\n\",\n\t\t   uefiVariableData->UnicodeNameLength);\n\t    rc = TSS_RC_MALLOC_SIZE;\n\t}\n    }\n    if (rc == 0) {\n\tif (uefiVariableData->VariableDataLength > EFI_LENGTH_MAX) {\n\t    printf(\"TSS_EfiVariableData_ReadBuffer: VariableDataLength %\" PRIu64 \" too large\\n\",\n\t\t   uefiVariableData->VariableDataLength );\n\t    rc = TSS_RC_MALLOC_SIZE;\n\t}\n    }\n    /* allocate the UnicodeName array, unicode means byte array is length * 2 */\n    if (rc == 0) {\n\tif (uefiVariableData->UnicodeNameLength > 0) {\n\t    /* freed by TSS_EfiVariableData_Free */\n\t    uefiVariableData->UnicodeName =\n\t\tmalloc((size_t)(uefiVariableData->UnicodeNameLength) *2);\n\t    if (uefiVariableData->UnicodeName == NULL) {\n\t\tprintf(\"TSS_EfiVariableData_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(uefiVariableData->UnicodeNameLength) *2);\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n    }\n    /* unmarshal UnicodeName */\n    if (rc == 0) {\n\tif (uefiVariableData->UnicodeNameLength > 0) {\n\t    rc = TSS_Array_Unmarshalu(uefiVariableData->UnicodeName,\n\t\t\t\t      (uint16_t)(uefiVariableData->UnicodeNameLength) *2,\n\t\t\t\t      event, eventSize);\n\t}\n\telse {\n\t    /* FIXME is UnicodeNameLength zero an error ? */\n\t}\n    }\n    /* allocate the VariableData array */\n    if (rc == 0) {\n\tif (uefiVariableData->VariableDataLength > 0) {\n\t    /* freed by TSS_EfiVariableData_Free */\n\t    uefiVariableData->VariableData =\n\t\tmalloc((size_t)uefiVariableData->VariableDataLength);\n\t    if (uefiVariableData->VariableData == NULL) {\n\t\tprintf(\"TSS_EfiVariableData_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)uefiVariableData->VariableDataLength);\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n    }\n    /* unmarshal VariableData */\n    if (rc == 0) {\n\tif (uefiVariableData->VariableDataLength > 0) {\n\t    rc = TSS_Array_Unmarshalu(uefiVariableData->VariableData,\n\t\t\t\t      (uint16_t)uefiVariableData->VariableDataLength,\n\t\t\t\t      event, eventSize);\n\t}\n\telse {\n\t    /* FIXME is VariableDataLength zero an error ? */\n\t}\n    }\n    return rc;\n}\n\n/* common TSS_UEFI_VARIABLE_DATA trace */\n\nstatic void TSS_EfiVariableData_Trace(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    guid_printf(\"Variable GUID\", uefiVariableData->VariableName);\n    ucs2_printf(\"Variable: \", uefiVariableData->UnicodeName,\n\t\t(uint32_t)uefiVariableData->UnicodeNameLength * 2);\n    printf(\"  VariableDataLength: %\" PRIu64 \"\\n\", uefiVariableData->VariableDataLength);\n    return;\n}\n\n/* EV_EFI_VARIABLE_DRIVER_CONFIG */\n\nstatic void TSS_EfiVariableDriverConfig_Init(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    TSS_EfiVariableData_Init(efiData);\n    uefiVariableData->variableDriverConfig.signatureListCount = 0;\n    uefiVariableData->variableDriverConfig.signatureList = NULL;\n    return;\n}\n\nstatic void TSS_EfiVariableDriverConfig_Free(TSST_EFIData *efiData)\n{\n    uint32_t count;\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    for (count = 0 ; count < uefiVariableData->variableDriverConfig.signatureListCount ; count++) {\n\tTSS_EfiSignatureList_Free(uefiVariableData->variableDriverConfig.signatureList + count);\n    }\n    free(uefiVariableData->variableDriverConfig.signatureList);\n    TSS_EfiVariableData_Free(efiData);\n    return;\n}\n\nstatic uint32_t TSS_EfiVariableDriverConfig_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\t      uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\t      uint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    size_t index;\n    int enabled;\t/* boolean */\n    pcrIndex = pcrIndex;\n\n    /* common code for TSS_UEFI_VARIABLE_DATA */\n    if (rc == 0) {\n\trc = TSS_EfiVariableData_ReadBuffer(efiData, &event, &eventSize);\n    }\n    /* map from UnicodeName to structure tag */\n    if (rc == 0) {\n\tTSS_EFI_GetNameIndex(&index,\n\t\t\t     uefiVariableData->UnicodeName,\n\t\t\t     uefiVariableData->UnicodeNameLength);\n\tuefiVariableData->variableDataTag = tagTable[index].tag;\n    }\n    /*\n      Specific code for EV_EFI_VARIABLE_DRIVER_CONFIG\n    */\n    /* VariableDataLength 0 is treated as though its contents were zero.  Even though this\n       does not meet the UEFI spec, some platforms do this.  */\n    if (rc == 0) {\n\tif ((uefiVariableData->VariableDataLength == 0) ||\n\t    ((uefiVariableData->VariableDataLength == 1) &&\n\t     (uefiVariableData->VariableData[0] == 0))) {\n\t    enabled = 0;\t/* false */\n\t}\n\telse {\n\t    enabled = 1;\n\t}\n    }\n    if (rc == 0) {\n\tswitch (uefiVariableData->variableDataTag) {\n\t  case TSS_VAR_SECUREBOOT:\n\t  case TSS_VAR_AUDITMODE:\n\t  case TSS_VAR_DEPLOYEDMODE:\n\t  case TSS_VAR_SETUPMODE:\n\t    /* intentional fall through */\n\t    uefiVariableData->variableDriverConfig.enabled = enabled;\n\t    break;\n\t/* unmarshal TSS_EFI_SIGNATURE_LIST's */\n\t  case TSS_VAR_PK:\n\t  case TSS_VAR_KEK:\n\t  case TSS_VAR_DB:\n\t  case TSS_VAR_DBR:\n\t  case TSS_VAR_DBT:\n\t  case TSS_VAR_DBX:\n\t  case TSS_VAR_MOKLIST:\n\t  case TSS_VAR_MOKLISTX:\n\t    /* intentional fall through */\n\t    rc = TSS_EfiSignatureAllLists_ReadBuffer\n\t\t (&uefiVariableData->variableDriverConfig.signatureList,\n\t\t  &uefiVariableData->variableDriverConfig.signatureListCount,\n\t\t  uefiVariableData->VariableData,\n\t\t  (uint32_t)uefiVariableData->VariableDataLength);\n\t    /* trace the GUID and Var as errors */\n\t    if (rc != 0) {\n\t\tprintf(\"TSS_EfiVariableDriverConfig_ReadBuffer: \"\n\t\t       \"Error TSS_UEFI_VARIABLE_DATA structure, tag %u\\n\",\n\t\t       uefiVariableData->variableDataTag);\n\t\tTSS_EfiVariableData_Trace(efiData);\n\t    }\n\t    break;\n\t  default:\n\t    /* FIXME unknown Variable Name strings */\n\t    ;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_EfiSignatureAllLists_ReadBuffer() reads a VariableData containing zero or more\n   signature lists.\n*/\n\nstatic uint32_t TSS_EfiSignatureAllLists_ReadBuffer(TSS_EFI_SIGNATURE_LIST **signatureList,\n\t\t\t\t\t\t    uint32_t *signatureListCount,\n\t\t\t\t\t\t    uint8_t *VariableData,\n\t\t\t\t\t\t    uint32_t VariableDataLength)\n{\n    uint32_t rc = 0;\n\n    /* parse all the VariableData */\n    while ((rc == 0) && (VariableDataLength > 0)) {\n\t/* malloc an additional *TSS_EFI_SIGNATURE_LIST */\n\tif (rc == 0) {\n\t    void *tmpptr;\t\t\t/* for realloc */\n\n\t    /* freed by TSS_EfiVariableData_Free */\n\t    tmpptr = realloc(*signatureList,\n\t\t\t     sizeof(TSS_EFI_SIGNATURE_LIST) * ((size_t)(*signatureListCount)+1));\n\t    if (tmpptr != NULL) {\n\t\t*signatureList = tmpptr;\n\t\t(*signatureListCount)++;\n\t    }\n\t    else {\n\t\tprintf(\"TSS_EfiSignatureAllLists_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)sizeof(TSS_EFI_SIGNATURE_LIST) * *signatureListCount);\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\t/* unmarshal this TSS_EFI_SIGNATURE_LIST */\n\tif (rc == 0) {\n\t    TSS_EFI_SIGNATURE_LIST *nextSignatureList = (*signatureList) + *signatureListCount -1;\n\t    TSS_EfiSignatureList_Init(nextSignatureList);\t/* for safe free */\n\t    rc = TSS_EfiSignatureList_ReadBuffer(nextSignatureList,\n\t\t\t\t\t\t&VariableData, &VariableDataLength);\n\t}\n    }\n    return rc;\n}\n\nstatic void     TSS_EfiSignatureList_Init(TSS_EFI_SIGNATURE_LIST *signatureList)\n{\n    signatureList->SignatureHeader = NULL;\n    signatureList->Signatures = NULL;\n    signatureList->signaturesCount = 0;\n}\n\nstatic void     TSS_EfiSignatureList_Free(TSS_EFI_SIGNATURE_LIST *signatureList)\n{\n    uint32_t count;\n\n    free(signatureList->SignatureHeader);\n    /* free all the TSS_EFI_SIGNATURE_DATA */\n    for (count = 0 ; count < signatureList->signaturesCount ; count++) {\n\tfree((signatureList->Signatures + count)->SignatureData);\n    }\n    free(signatureList->Signatures);\n    return;\n}\n\n/* TSS_EfiSignatureList_ReadBuffer() reads one TSS_EFI_SIGNATURE_LIST from the event VariableData.\n   It moves the pointers since there can be more than one TSS_EFI_SIGNATURE_LIST event.\n */\n\nstatic uint32_t TSS_EfiSignatureList_ReadBuffer(TSS_EFI_SIGNATURE_LIST *signatureList,\n\t\t\t\t\t\tuint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    uint32_t signatureDataLength;\n    uint32_t tmpSignatureListSize;\t/* because cannot change SignatureSize */\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(signatureList->SignatureType,\n\t\t\t\t  sizeof(signatureList->SignatureType),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&signatureList->SignatureListSize, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&signatureList->SignatureHeaderSize, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&signatureList->SignatureSize, event, eventSize);\n    }\n    /* range check this untrusted value, to prevent a large malloc */\n    if (rc == 0) {\n\tif (signatureList->SignatureSize > *eventSize) {\n\t    printf(\"TSS_EfiSignatureList_ReadBuffer: Error in SignatureSize %u\\n\",\n\t\t   (unsigned int)(signatureList->SignatureSize));\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* the SignatureSize must have at least the mandatory SignatureOwner GUID */\n    if (rc == 0) {\n\tif (signatureList->SignatureSize >= sizeof(signatureList->Signatures->SignatureOwner)) {\n\t    signatureDataLength =\n\t\tsignatureList->SignatureSize - sizeof(signatureList->Signatures->SignatureOwner);\n\t}\n\telse {\n\t    /* malformed TSS_EFI_SIGNATURE_LIST, needs at least GUID SignatureOwner */\n\t    printf(\"TSS_EfiSignatureList_ReadBuffer: Error in SignatureSize %u\\n\",\n\t\t   (unsigned int)(signatureList->SignatureSize));\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* sanity check that the SignatureListSize is consistent with the SignatureSize.  Each signature\n       must be the same length. */\n    if (rc == 0) {\n\t/*  array of TSS_EFI_SIGNATURE_DATA is SignatureListSize minus header */\n\ttmpSignatureListSize = signatureList->SignatureListSize -\n\t\t\t       sizeof(signatureList->SignatureType)\n\t\t\t       - (sizeof(uint32_t) * 3);\n\tif ((tmpSignatureListSize % signatureList->SignatureSize) != 0) {\n\t    /* malformed TSS_EFI_SIGNATURE_LIST */\n\t    printf(\"TSS_EfiSignatureList_ReadBuffer: Error in SignatureSize %u\\n\",\n\t\t   (unsigned int)(signatureList->SignatureSize));\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n\n    /* FIXME handle SignatureHeaderSize, if not zero, this breaks, based on SignatureType GUID */\n\n    /* consume this TSS_EFI_SIGNATURE_LIST */\n    for ( ; (rc == 0) && (tmpSignatureListSize > 0) ;\n\t  tmpSignatureListSize-= signatureList->SignatureSize) {\n\n\tTSS_EFI_SIGNATURE_DATA *nextSignatureData;\n\t/* malloc an additional TSS_EFI_SIGNATURE_DATA */\n\tif (rc == 0) {\n\t    void *tmpptr;\t\t\t/* for realloc */\n\n\t    /* track the number of TSS_EFI_SIGNATURE_DATA in the TSS_EFI_SIGNATURE_LIST */\n\t    /* expand the array */\n\t    /* freed by TSS_EfiSignatureList_Free */\n\t    tmpptr = realloc(signatureList->Signatures,\n\t\t\t     sizeof(TSS_EFI_SIGNATURE_DATA) * ((size_t)(signatureList->signaturesCount)+1));\n\t    if (tmpptr != NULL) {\n\t\tsignatureList->Signatures = tmpptr;\n\t\t(signatureList->signaturesCount)++;\n\t\t/* point to next TSS_EFI_SIGNATURE_DATA in array */\n\t\tnextSignatureData = signatureList->Signatures + signatureList->signaturesCount-1;\n\t\tnextSignatureData->SignatureData = NULL;\t/* for free */\n\t    }\n\t    else {\n\t\tprintf(\"TSS_EfiSignatureList_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(sizeof(TSS_EFI_SIGNATURE_DATA) *\n\t\t\t\t      signatureList->signaturesCount));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\t/* unmarshal the signature owner */\n\tif (rc == 0) {\n\t    rc = TSS_Array_Unmarshalu(nextSignatureData->SignatureOwner,\n\t\t\t\t      sizeof(signatureList->SignatureType),\n\t\t\t\t      event, eventSize);\n\t}\n\t/* malloc an TSS_EFI_SIGNATURE_DATA SignatureData */\n\tif (rc == 0) {\n\t    void *tmpptr;\t\t\t/* for realloc */\n\t    /* SignatureData is SignatureSize less the GUID SignatureOwner */\n\t    /* freed by TSS_EfiSignatureList_Free */\n\t    tmpptr = malloc(signatureDataLength);\n\t    if (tmpptr != NULL) {\n\t\tnextSignatureData->SignatureData = tmpptr;\n\t    }\n\t    else {\n\t\tprintf(\"TSS_EfiSignatureList_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       signatureDataLength);\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\t/* unmarshal the signature data */\n\tif (rc == 0) {\n\t    rc = TSS_Array_Unmarshalu(nextSignatureData->SignatureData,\n\t\t\t\t      signatureDataLength,\n\t\t\t\t      event, eventSize);\n\t}\n    }\n    return rc;\n}\n\n/* TSS_EfiSignatureList_Trace() traces one TSS_EFI_SIGNATURE_LIST.\n\n   There can be more than one TSS_EFI_SIGNATURE_LIST in a TSS_UEFI_VARIABLE_DATA\n*/\n\nstatic void     TSS_EfiSignatureList_Trace(TSS_EFI_SIGNATURE_LIST *signatureList)\n{\n    int rc;\n    size_t guidIndex;\n    uint32_t count;\n\n    guid_printf(\"SignatureType GUID\", signatureList->SignatureType);\n    printf(\"  SignatureListSize %u\\n\", signatureList->SignatureListSize);\n    printf(\"  SignatureHeaderSize %u\\n\", signatureList->SignatureHeaderSize);\n    /* FIXME trace SignatureHeader if not NULL */\n    printf(\"  SignatureSize %u\\n\", signatureList->SignatureSize);\n    printf(\"  signaturesCount %u\\n\", signatureList->signaturesCount);\n\n    /* trace based on the guid type */\n    rc = TSS_EFI_GetGuidIndex(&guidIndex, signatureList->SignatureType);\n    if (rc != 0) {\n\tprintf(\"  GUID unknown\\n\");\n    }\n    for (count = 0 ; (rc == 0) && (count < signatureList->signaturesCount) ; count++) {\n\tguid_printf(\"SignatureOwner GUID\", (signatureList->Signatures + count)->SignatureOwner);\n\tswitch (guidTable[guidIndex].type) {\n\t  case GUID_TYPE_X509_CERT:\n#ifndef TPM_TSS_MBEDTLS\n\t      {\n\t\t  X509 *x509 = NULL;\n\t\t  unsigned char *tmpData = NULL;\n\t\t  /* tmp pointer because d2i moves the pointer */\n\t\t  tmpData = (signatureList->Signatures + count)->SignatureData;\n\t\t  x509 = d2i_X509(NULL,\t\t\t/* freed by caller */\n\t\t\t\t  (const unsigned char **)&tmpData,\n\t\t\t\t  signatureList->SignatureSize - TSS_EFI_GUID_SIZE);\n\t\t  if (x509 != NULL) {\n\t\t      X509_print_fp(stdout, x509);\n\t\t  }\n\t\t  else {\n\t\t      printf(\"  X509 Certificate invalid\\n\");\n\t\t  }\n\t\t  X509_free(x509);\n\t\t  x509 = NULL;\t/* for next time through loop */\n\t      }\n#endif\t/* TPM_TSS_MBEDTLS */\n\t    break;\n\t  case  GUID_TYPE_SHA256:\n\t    TSS_PrintAll(\"    SHA-256\",\n\t\t\t (signatureList->Signatures + count)->SignatureData,\n\t\t\t signatureList->SignatureSize - TSS_EFI_GUID_SIZE);\n\t    break;\n\t  case GUID_TYPE_UNSUPPORTED:\n\t  default:\n\t    /* FIXME add other types, need sample logs */\n\t    break;\n\t}\n    }\n    return;\n}\n\n/* EV_EFI_VARIABLE_DRIVER_CONFIG */\n\nstatic void TSS_EfiVariableDriverConfig_Trace(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    uint32_t count;\n\n    /* common TSS_UEFI_VARIABLE_DATA trace */\n    TSS_EfiVariableData_Trace(efiData);\n    /* EV_EFI_VARIABLE_DRIVER_CONFIG trace */\n    /* if the variable was SecureBoot */\n    switch (uefiVariableData->variableDataTag) {\n      case TSS_VAR_SECUREBOOT:\n      case TSS_VAR_AUDITMODE:\n      case TSS_VAR_DEPLOYEDMODE:\n      case TSS_VAR_SETUPMODE:\n\tprintf(\"  Enabled: %s\\n\",\n\t       uefiVariableData->variableDriverConfig.enabled ? \"yes\" : \"no\");\n\tbreak;\n      case TSS_VAR_PK:\n      case TSS_VAR_KEK:\n      case TSS_VAR_DB:\n      case TSS_VAR_DBR:\n      case TSS_VAR_DBT:\n      case TSS_VAR_DBX:\n      case TSS_VAR_MOKLIST:\n      case TSS_VAR_MOKLISTX:\n\t/* intentional fall through */\n\tprintf(\"  signatureListCount: %u\\n\",\n\t       uefiVariableData->variableDriverConfig.signatureListCount);\n\tfor (count = 0 ; count < uefiVariableData->variableDriverConfig.signatureListCount ;\n\t     count++) {\n\t    TSS_EfiSignatureList_Trace(uefiVariableData->variableDriverConfig.signatureList + count);\n\t}\n\tbreak;\n      default:\n\tTSS_PrintAll(\"    Variable unsupported:\",\n\t\t     uefiVariableData->VariableData,\n\t\t     (uint32_t)uefiVariableData->VariableDataLength);\n\tbreak;\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiVariableDriverConfig_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    uefiVariableData = uefiVariableData;\n\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* TSS_UEFI_VARIABLE_DATA handler for event EV_EFI_VARIABLE_BOOT\n\n   The event can either be the BootOrder (uint16_t) or a boot variable description.\n*/\n\nstatic void TSS_EfiVariableBoot_Init(TSST_EFIData *efiData)\n{\n    TSS_EfiVariableData_Init(efiData);\n    /* the union members are initialized when the tag is set */\n    return;\n}\n\nstatic void TSS_EfiVariableBoot_Free(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    if (uefiVariableData->variableDataTag == TSS_VAR_BOOTORDER) {\n\tTSS_EfiVariableBootOrder_Free(&uefiVariableData->variableBootOrder);\n    }\n    else if (uefiVariableData->variableDataTag == TSS_VAR_BOOTPATH) {\n\tTSS_EfiVariableBootPath_Free(&uefiVariableData->variableBoot);\n    }\n    TSS_EfiVariableData_Free(efiData);\n    return;\n}\n\n/* TSST_EFIData holds TSS_UEFI_VARIABLE_DATA.\n   TSS_UEFI_VARIABLE_DATA holds standard header, a tag, and a union.\n   The union here is either TSS_VARIABLE_BOOT_ORDER or TSS_VARIABLE_BOOT.\n*/\n\nstatic uint32_t TSS_EfiVariableBoot_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t       uint8_t *event, uint32_t eventSize, uint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    size_t index; \n    pcrIndex = pcrIndex;\n\n    /* common code for TSS_UEFI_VARIABLE_DATA */\n    if (rc == 0) {\n\trc = TSS_EfiVariableData_ReadBuffer(efiData, &event, &eventSize);\n    }\n    if (rc == 0) {\n\tTSS_EFI_GetNameIndex(&index,\n\t\t\t     uefiVariableData->UnicodeName,\n\t\t\t     uefiVariableData->UnicodeNameLength);\n\tuefiVariableData->variableDataTag = tagTable[index].tag;\n    }\n    /* specific code for EV_EFI_VARIABLE_BOOT */\n    /* is the UnicodeName string BootOrder */\n    if (rc == 0) {\n\t/* unmarshal BootOrder - List of uint16_t */\n\tif (uefiVariableData->variableDataTag == TSS_VAR_BOOTORDER) {\n\t    TSS_VARIABLE_BOOT_ORDER *variableBootOrder = &uefiVariableData->variableBootOrder;\n\t    TSS_EfiVariableBootOrder_Init(variableBootOrder);\n\t    rc = TSS_EfiVariableBootOrder_ReadBuffer(variableBootOrder,\n\t\t\t\t\t\t     uefiVariableData->VariableData,\n\t\t\t\t\t\t     (uint32_t)uefiVariableData->VariableDataLength);\n\t}\n\t/* unmarshal boot path */\n\telse {\n\t    TSS_VARIABLE_BOOT *variableBoot = &uefiVariableData->variableBoot;\n\t    /* default of not BootOrder, for the free */\n\t    uefiVariableData->variableDataTag = TSS_VAR_BOOTPATH;\n\t    TSS_EfiVariableBootPath_Init(variableBoot);\t\t/* for the free */\n\t    rc = TSS_EfiVariableBootPath_ReadBuffer(variableBoot,\n\t\t\t\t\t\t    uefiVariableData->VariableData,\n\t\t\t\t\t\t    uefiVariableData->VariableDataLength);\n\t}\n\t/* trace the GUID and Var as errors */\n\tif (rc != 0) {\n\t    printf(\"TSS_EfiVariableBoot_ReadBuffer: \"\n\t\t   \"Error in TSS_UEFI_VARIABLE_DATA structure tag %u\\n\",\n\t\t   uefiVariableData->variableDataTag);\n\t    TSS_EfiVariableData_Trace(efiData);\n\t}\n    }\n    return rc;\n}\n\nstatic void     TSS_EfiVariableBootOrder_Init(TSS_VARIABLE_BOOT_ORDER *variableBootOrder)\n{\n    variableBootOrder->bootOrderListCount = 0;\n    variableBootOrder->bootOrderList = NULL;\n    return;\n}\n\nstatic void     TSS_EfiVariableBootOrder_Free(TSS_VARIABLE_BOOT_ORDER *variableBootOrder)\n{\n    free(variableBootOrder->bootOrderList);\n    return;\n}\n\n/* TSS_EfiVariableBootOrder_ReadBuffer() unmarshals the BootOrder variable data into an array of uint16_t\n*/\n\nstatic uint32_t TSS_EfiVariableBootOrder_ReadBuffer(TSS_VARIABLE_BOOT_ORDER *variableBootOrder,\n\t\t\t\t\t\t    uint8_t *VariableData, uint32_t VariableDataLength)\n{\n    uint32_t rc = 0;\n    uint32_t count;\n\n    if (rc == 0) {\n\tif ((VariableDataLength % 2) == 0) {\n\t    variableBootOrder->bootOrderListCount = VariableDataLength / 2;\n\t}\n\telse {\n\t    printf(\"TSS_EfiVariableBootOrder_ReadBuffer: Error in VariableDataLength %u\\n\",\n\t\t   VariableDataLength);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* malloc the array of boot order uint16_t */\n    if (rc == 0) {\n        /* freed by TSS_EfiVariableData_Init */\n\tvariableBootOrder->bootOrderList =\n\t    malloc(variableBootOrder->bootOrderListCount * sizeof(uint16_t));\n\n\tif (variableBootOrder->bootOrderList == NULL) {\n\t    printf(\"TSS_EfiVariableBootOrder_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t   (unsigned int)(variableBootOrder->bootOrderListCount * sizeof(uint16_t)));\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* iterate and build the bootOrderList array of uint16_t */\n    for (count = 0 ; (rc == 0) && (count < variableBootOrder->bootOrderListCount) ; count++) {\n\tuint16_t *nextBootOrderList = variableBootOrder->bootOrderList + count;\n\trc = TSS_UINT16LE_Unmarshal(nextBootOrderList, \n\t\t\t\t    &VariableData, &VariableDataLength);\n    }\n    return rc;\n}\n\nstatic void     TSS_EfiVariableBootPath_Init(TSS_VARIABLE_BOOT *variableBoot)\n{\n    variableBoot->Description = NULL;\n    variableBoot->UefiDevicePathCount = 0;\n    variableBoot->UefiDevicePath = NULL;\n    return;\n}\n\nstatic void     TSS_EfiVariableBootPath_Free(TSS_VARIABLE_BOOT *variableBoot)\n{\n    uint32_t count;\n\n    free(variableBoot->Description);\n    for (count = 0 ; count < variableBoot->UefiDevicePathCount ; count++) {\n\tTSS_UEFI_DEVICE_PATH *uefiDevicePath = variableBoot->UefiDevicePath + count;\n\tTSS_UefiDevicePath_Free(uefiDevicePath);\n    }\n    free(variableBoot->UefiDevicePath);\n    return;\n}\n\nstatic uint32_t TSS_EfiVariableBootPath_ReadBuffer(TSS_VARIABLE_BOOT *variableBoot,\n\t\t\t\t\t\t   void *VariableData, uint64_t VariableDataLength)\n{\n    uint32_t rc = 0;\n    uint8_t *event = VariableData;\n    uint32_t eventSize = (uint32_t)VariableDataLength;\n\n    /* this parser is in-line, into the TSS_VARIABLE_BOOT structure */\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&variableBoot->Attributes,\n\t\t\t\t    &event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&variableBoot->FilePathListLength,\n\t\t\t\t    &event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UCS2_Unmarshal(&variableBoot->Description,\t/* must be freed */\n\t\t\t\t&variableBoot->DescriptionLength,\n\t\t\t\t&event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UefiDevicePathList_ReadBuffer(&variableBoot->UefiDevicePath,\n\t\t\t\t\t       &variableBoot->UefiDevicePathCount,\n\t\t\t\t\t       event, variableBoot->FilePathListLength);\n    }\n    return rc;\n}\n\nstatic void TSS_EfiVariableBoot_Trace(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    uint32_t count;\n\n    /* common TSS_UEFI_VARIABLE_DATA trace */\n    TSS_EfiVariableData_Trace(efiData);\n    /* is the UnicodeName string BootOrder */\n    if (uefiVariableData->variableDataTag == TSS_VAR_BOOTORDER) {\n\tTSS_VARIABLE_BOOT_ORDER *variableBootOrder = &uefiVariableData->variableBootOrder;\n\tprintf(\"  Boot Order: \");\n\tfor (count = 0 ; count < variableBootOrder->bootOrderListCount ; count++) {\n            printf(\"Boot%04x \", *(variableBootOrder->bootOrderList + count));\n\t}\n\tprintf(\"\\n\");\n    }\n    else if (uefiVariableData->variableDataTag == TSS_VAR_BOOTPATH) {\n\tTSS_VARIABLE_BOOT *variableBoot = &uefiVariableData->variableBoot;\n\tprintf(\"  Attributes: %08x\\n\", variableBoot->Attributes);\n\tprintf(\"  FilePathListLength: %hu\\n\", variableBoot->FilePathListLength);\n\tucs2_printf(\"Description: \", variableBoot->Description,\n\t\t    variableBoot->DescriptionLength * 2);\n\tfor (count = 0 ; count < variableBoot->UefiDevicePathCount ; count++) {\n\t    TSS_UefiDevicePath_Trace(variableBoot->UefiDevicePath + count);\n\t}\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiVariableBoot_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    uefiVariableData = uefiVariableData;\n\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_EFI_VARIABLE_AUTHORITY */\n\nstatic void     TSS_EfiVariableAuthority_Init(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    TSS_EfiVariableData_Init(efiData);\n    uefiVariableData->authoritySignatureData.SignatureData = NULL;\n    uefiVariableData->authoritySignatureData.SignatureLength = 0;\n   return;\n}\n\nstatic void     TSS_EfiVariableAuthority_Free(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    free(uefiVariableData->authoritySignatureData.SignatureData);\n    TSS_EfiVariableData_Free(efiData);\n    return;\n}\n\nstatic uint32_t TSS_EfiVariableAuthority_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\t   uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\t   uint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    size_t index; \n    pcrIndex = pcrIndex;\n\n    if (rc == 0) {\n\trc = TSS_EfiVariableData_ReadBuffer(efiData,\n\t\t\t\t\t   &event, &eventSize);\n    }\n    if (rc == 0) {\n\tTSS_EFI_GetNameIndex(&index,\n\t\t\t     uefiVariableData->UnicodeName,\n\t\t\t     uefiVariableData->UnicodeNameLength);\n\tuefiVariableData->variableDataTag = tagTable[index].tag;\n    }\n    if (rc == 0) {\n\tTSS_AUTHORITY_SIGNATURE_DATA *authoritySignatureData =\n\t    &uefiVariableData->authoritySignatureData;\n\t/* tmp because unmarshal moves pointers */\n\tuint8_t *tmpVarData = uefiVariableData->VariableData;\n\tuint32_t tmpVarDataLength = (uint32_t)uefiVariableData->VariableDataLength;\n\n\t/* db has an owner, shim does not */\n\tif (uefiVariableData->variableDataTag == TSS_VAR_DB) {\n\t    /* unmarshal the signature owner */\n\t    if (rc == 0) {\n\t\trc = TSS_Array_Unmarshalu(authoritySignatureData->SignatureOwner,\n\t\t\t\t\t  sizeof(authoritySignatureData->SignatureOwner),\n\t\t\t\t\t  &tmpVarData, &tmpVarDataLength);\n\t    }\n\t}\n\t/* intentional fall through for DB */\n\tif ((uefiVariableData->variableDataTag == TSS_VAR_DB) ||\n\t    (uefiVariableData->variableDataTag == TSS_VAR_SHIM) ||\n\t    (uefiVariableData->variableDataTag == TSS_VAR_MOKLIST)) {\n\n\t    /* assume the rest of the event is the certificate since there is no SignatureSize\n\t       field */\n\t    if (rc == 0) {\n\t\tauthoritySignatureData->SignatureLength = tmpVarDataLength;\n\t\tauthoritySignatureData->SignatureData =\n\t\t    malloc(authoritySignatureData->SignatureLength);\n\t\tif (authoritySignatureData->SignatureData == NULL) {\n\t\t    printf(\"TSS_EfiVariableAuthorityReadBuffer: Error allocating %u bytes\\n\",\n\t\t\t   (unsigned int)authoritySignatureData->SignatureLength);\n\t\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t\t}\n\t    }\n\t    /* unmarshal the signature data */\n\t    if (rc == 0) {\n\t\trc = TSS_Array_Unmarshalu(authoritySignatureData->SignatureData,\n\t\t\t\t\t  authoritySignatureData->SignatureLength,\n\t\t\t\t\t  &tmpVarData, &tmpVarDataLength);\n\t    }\n\t    /* trace the GUID and Var as errors */\n\t    if (rc != 0) {\n\t\tprintf(\"TSS_EfiVariableAuthorityReadBuffer: Error with tag %u\\n\",\n\t\t       uefiVariableData->variableDataTag);\n\t\tTSS_EfiVariableData_Trace(efiData);\n\t    }\n\t    /* FIXME sanity check for all consumed */\n\t    /* tmpVarDataLength should be zero.  This is underspecified in PFP */\n\t}\n    }\n    return rc;\n}\n\nstatic void TSS_EfiVariableAuthority_Trace(TSST_EFIData *efiData)\n{\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    TSS_AUTHORITY_SIGNATURE_DATA *authoritySignatureData =\n\t&uefiVariableData->authoritySignatureData;\n\n    /* common TSS_UEFI_VARIABLE_DATA trace */\n    TSS_EfiVariableData_Trace(efiData);\n    /* not part of UEFI structure */\n    printf(\"  SignatureLength: %u\\n\", authoritySignatureData->SignatureLength);\n    /* db has an owner, shim does not */\n    if (uefiVariableData->variableDataTag == TSS_VAR_DB) {\n\tguid_printf(\"SignatureOwner GUID\", authoritySignatureData->SignatureOwner);\n    }\n#ifndef TPM_TSS_MBEDTLS\n    if ((uefiVariableData->variableDataTag == TSS_VAR_DB) ||\n\t(uefiVariableData->variableDataTag == TSS_VAR_SHIM) ||\n\t(uefiVariableData->variableDataTag == TSS_VAR_MOKLIST)) {\n\n\tX509 *x509 = NULL;\n\tunsigned char *tmpData = NULL;\n\ttmpData = authoritySignatureData->SignatureData;\n\tx509 = d2i_X509(NULL,\t\t\t/* freed by caller */\n\t\t\t(const unsigned char **)&tmpData,\n\t\t\tauthoritySignatureData->SignatureLength);\n\tif (x509 != NULL) {\n\t    X509_print_fp(stdout, x509);\n\t}\n\telse {\n\t    printf(\"  X509 Certificate invalid\\n\");\n\t}\n\tX509_free(x509);\n\tx509 = NULL;\n    }\n#endif\t/* TPM_TSS_MBEDTLS */\n    return;\n}\n\nstatic uint32_t TSS_EfiVariableAuthority_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData = &efiData->efiData.uefiVariableData;\n    uefiVariableData = uefiVariableData ;\n\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_EFI_BOOT_SERVICES_APPLICATION, EV_EFI_BOOT_SERVICES_DRIVER handler\n\n   The event field MUST contain a TSS_UEFI_IMAGE_LOAD_EVENT structure.\n*/\n\nstatic void TSS_EfiBootServices_Init(TSST_EFIData *efiData)\n{\n    TSS_UEFI_IMAGE_LOAD_EVENT *uefiImageLoadEvent = &efiData->efiData.uefiImageLoadEvent;\n    uefiImageLoadEvent->DevicePath = NULL;\n    uefiImageLoadEvent->Path = NULL;\n    uefiImageLoadEvent->UefiDevicePathCount = 0;\n    uefiImageLoadEvent->UefiDevicePath = NULL;\n    return;\n}\n\nstatic void TSS_EfiBootServices_Free(TSST_EFIData *efiData)\n{\n    uint32_t count;\n    TSS_UEFI_IMAGE_LOAD_EVENT *uefiImageLoadEvent = &efiData->efiData.uefiImageLoadEvent;\n    free(uefiImageLoadEvent->DevicePath);\n    free(uefiImageLoadEvent->Path);\n    for (count = 0 ; count < uefiImageLoadEvent->UefiDevicePathCount ; count++) {\n\tTSS_UEFI_DEVICE_PATH *uefiDevicePath = uefiImageLoadEvent->UefiDevicePath + count;\n\tTSS_UefiDevicePath_Free(uefiDevicePath);\n    }\n    free(uefiImageLoadEvent->UefiDevicePath);\n    return;\n}\n\nstatic uint32_t TSS_EfiBootServices_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t       uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t       uint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_IMAGE_LOAD_EVENT *uefiImageLoadEvent = &efiData->efiData.uefiImageLoadEvent;\n    pcrIndex = pcrIndex;\n\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiImageLoadEvent->ImageLocationInMemory,\n\t\t\t\t    &event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiImageLoadEvent->ImageLengthInMemory,\n\t\t\t\t    &event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiImageLoadEvent->ImageLinkTimeAddress,\n\t\t\t\t    &event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiImageLoadEvent->LengthOfDevicePath,\n\t\t\t\t    &event, &eventSize);\n    }\n    /* sanity check the length since the input is untrusted.  This also guarantees that a cast to\n       uint32_t is safe. */\n    if (rc == 0) {\n\tif (uefiImageLoadEvent->LengthOfDevicePath > EFI_LENGTH_MAX) {\n\t    printf(\"TSS_EfiBootServices_ReadBuffer: LengthOfDevicePath %\" PRIu64 \" too large\\n\",\n\t\t   uefiImageLoadEvent->LengthOfDevicePath);\n\t    rc = TSS_RC_MALLOC_SIZE;\n\t}\n    }\n    /* allocate the DevicePath array */\n    if (rc == 0) {\n\tif (uefiImageLoadEvent->LengthOfDevicePath > 0) {\n\t    /* freed by TSS_EfiBootServices_Free */\n\t    uefiImageLoadEvent->DevicePath = malloc((size_t)uefiImageLoadEvent->LengthOfDevicePath);\n\t    if (uefiImageLoadEvent->DevicePath == NULL) {\n\t\tprintf(\"TSS_EfiBootServices_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(uefiImageLoadEvent->LengthOfDevicePath));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n    }\n    /* unmarshal DevicePath to byte stream */\n    if (rc == 0) {\n\tif (uefiImageLoadEvent->LengthOfDevicePath > 0) {\n\t    rc = TSS_Array_Unmarshalu(uefiImageLoadEvent->DevicePath,\n\t\t\t\t      (uint16_t)uefiImageLoadEvent->LengthOfDevicePath,\n\t\t\t\t      &event, &eventSize);\n\t}\n\telse {\n\t    /* FIXME is LengthOfDevicePath zero an error ? */\n\t}\n    }\n    /* unmarshal the device path array */\n    if (rc == 0) {\n\trc = TSS_UefiDevicePathList_ReadBuffer(&uefiImageLoadEvent->UefiDevicePath,\n\t\t\t\t\t       &uefiImageLoadEvent->UefiDevicePathCount,\n\t\t\t\t\t       uefiImageLoadEvent->DevicePath,\n\t\t\t\t\t       (uint32_t)uefiImageLoadEvent->LengthOfDevicePath);\n    }\n    return rc;\n}\n\nstatic void TSS_EfiBootServices_Trace(TSST_EFIData *efiData)\n{\n    TSS_UEFI_IMAGE_LOAD_EVENT *uefiImageLoadEvent = &efiData->efiData.uefiImageLoadEvent;\n    uint32_t count;\n\n    printf(\"  Image location in memory: %016\" PRIx64 \"\\n\", uefiImageLoadEvent->ImageLocationInMemory);\n    printf(\"  Image length in memory: %\" PRIu64 \"\\n\", uefiImageLoadEvent->ImageLengthInMemory);\n    printf(\"  Image link time address: %016\" PRIx64 \"\\n\", uefiImageLoadEvent->ImageLinkTimeAddress);\n    TSS_PrintAll(\"  DevicePath:\",\n\t\t uefiImageLoadEvent->DevicePath, (uint32_t)uefiImageLoadEvent->LengthOfDevicePath);\n    printf(\"  UefiDevicePathCount: %u\\n\", uefiImageLoadEvent->UefiDevicePathCount);\n\n    for (count = 0 ; count < uefiImageLoadEvent->UefiDevicePathCount ; count++) {\n\tTSS_UefiDevicePath_Trace(uefiImageLoadEvent->UefiDevicePath + count);\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiBootServices_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_IMAGE_LOAD_EVENT *uefiImageLoadEvent = &efiData->efiData.uefiImageLoadEvent;\n    /* needs iterator over count */\n    rc = TSS_UefiDevicePath_ToJson(uefiImageLoadEvent->UefiDevicePath);\n    return rc;\n}\n\n/* TSS_UEFI_DEVICE_PATH  */\n\n/* UefiDevicePath is an array of TSS_UEFI_DEVICE_PATH.  This is common code for\n   TSS_EfiBootServices_ReadBuffer() and TSS_EfiVariableBootPath_ReadBuffer(),\n\n   Loop through the event, realloc to grow the array, and unmarshal the next element.\n*/\n\nstatic uint32_t TSS_UefiDevicePathList_ReadBuffer(TSS_UEFI_DEVICE_PATH **UefiDevicePath,\n\t\t\t\t\t\t  uint32_t *UefiDevicePathCount,\n\t\t\t\t\t\t  uint8_t *devicePath,\n\t\t\t\t\t\t  uint32_t lengthOfDevicePath)\n{\n    uint32_t rc = 0;\n \n    while ((rc == 0) && (lengthOfDevicePath > 0)) {\n\tTSS_UEFI_DEVICE_PATH *nextDevicePath;\n\tif (rc == 0) {\n\t    void *tmpptr;\t\t\t\t/* for realloc */\n\t    /* freed by TSS_EfiBootServices_Free() */\n\t    tmpptr = realloc(*UefiDevicePath,\n\t\t\t     sizeof(TSS_UEFI_DEVICE_PATH) * ((size_t)(*UefiDevicePathCount)+1));\n\t    if (tmpptr != NULL) {\n\t\t*UefiDevicePath = tmpptr;\n\t\tnextDevicePath =\n\t\t    *UefiDevicePath + *UefiDevicePathCount;\n\t\t(*UefiDevicePathCount)++;\n\t    }\n\t    else {\n\t\tprintf(\"TSS_UefiDevicePathList_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)sizeof(TSS_UEFI_DEVICE_PATH) *\n\t\t       *UefiDevicePathCount);\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    TSS_UefiDevicePath_Init(nextDevicePath);\t/* for safe free */\n\t    rc = TSS_UefiDevicePath_ReadBuffer(nextDevicePath,\n\t\t\t\t\t       &devicePath, &lengthOfDevicePath);\n\t}\n    }\n    return rc;\n}\n\nstatic void TSS_UefiDevicePath_Init(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    uefiDevicePath->data = NULL;\n    uefiDevicePath->bufferLength = 0;\n    uefiDevicePath->buffer = NULL;\n    uefiDevicePath->unionBufferLength = 0;\n    uefiDevicePath->unionBuffer = NULL;\n   return;\n}\n\nstatic void TSS_UefiDevicePath_Free(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    free(uefiDevicePath->data);\n    free(uefiDevicePath->buffer);\n    free(uefiDevicePath->unionBuffer);\n    return;\n}\n\nstatic uint32_t TSS_UefiDevicePath_ReadBuffer(TSS_UEFI_DEVICE_PATH *uefiDevicePath,\n\t\t\t\t\t      uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    uint32_t trc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&uefiDevicePath->protocol.Type,\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&uefiDevicePath->protocol.SubType,\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&uefiDevicePath->protocol.Length,\n\t\t\t\t    event, eventSize);\n    }\n#if 0\n    printf(\"TSS_UefiDevicePath_ReadBuffer: Type %02x SubType %02x length %hu rc %08x\\n\",\n\t   uefiDevicePath->protocol.Type, uefiDevicePath->protocol.SubType,\n\t   uefiDevicePath->protocol.Length, rc);\n#endif\n    /* sanity check length, subtract because length includes protocol header  */\n    if (rc == 0) {\n\tif (uefiDevicePath->protocol.Length > (*eventSize + sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL))) {\n\t    printf(\"TSS_UefiDevicePath_ReadBuffer protocol.Length %u too large\\n\",\n\t\t   uefiDevicePath->protocol.Length);\n\t    rc = TSS_RC_MALLOC_SIZE;\n\t}\n    }\n    /* allocate the data array */\n    if (rc == 0) {\n\tif (uefiDevicePath->protocol.Length > sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL)) {\n\t    /* freed by TSS_EfiVariableData_Free, length is total, subtract the\n\t       TSS_EFI_DEVICE_PATH_PROTOCOL */\n\t    uefiDevicePath->data = malloc(uefiDevicePath->protocol.Length -\n\t\t\t\t\t  sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL));\n\t    if (uefiDevicePath->data == NULL) {\n\t\tprintf(\"TSS_UefiDevicePath_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)(uefiDevicePath->protocol.Length));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tsize_t index;\n\ttrc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.Type,\n\t\t\t\t\t sizeof(efiDevicePathProtocolTypeTable),\n\t\t\t\t\t efiDevicePathProtocolTypeTable);\n\tif (trc == 0) {\n\t    rc = efiDevicePathProtocolTypeTable[index].readBufferFunction(uefiDevicePath,\n\t\t\t\t\t\t\t\t\t  event, eventSize);\n\t}\n\t/* Type unknown / unsupported */\n\telse {\n\t    rc = TSS_Array_Unmarshalu(uefiDevicePath->data,\n\t\t\t\t      uefiDevicePath->protocol.Length -\n\t\t\t\t      sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL),\n\t\t\t\t      event, eventSize);\n\t}\n    }\n    return rc;\n}\n\nstatic void TSS_UefiDevicePath_Trace(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    uint32_t \trc;\n    size_t \tindex;\n\n    /* index into the EFI_DEVICE_PATH_PROTOCOL Type table */\n    rc = TSS_EFI_GetDevicePathIndex(&index, uefiDevicePath->protocol.Type,\n\t\t\t\t    sizeof(efiDevicePathProtocolTypeTable),\n\t\t\t\t    efiDevicePathProtocolTypeTable);\n    if (rc == 0) {\n\tprintf(\"    Type %02x %s\\n\",\n\t       uefiDevicePath->protocol.Type,\n\t       efiDevicePathProtocolTypeTable[index].text);\n\tefiDevicePathProtocolTypeTable[index].traceFunction(uefiDevicePath);\n    }\n    else {\n\tprintf(\"    Type    %02x\\n\", uefiDevicePath->protocol.Type);\n\tprintf(\"    SubType %02x\\n\", uefiDevicePath->protocol.SubType);\n\tTSS_PrintAll(\"   Data:\",\n\t\t     uefiDevicePath->data, uefiDevicePath->protocol.Length - \n\t\t     sizeof(TSS_EFI_DEVICE_PATH_PROTOCOL));\n    }\n    return;\n}\n\nstatic uint32_t TSS_UefiDevicePath_ToJson(TSS_UEFI_DEVICE_PATH *uefiDevicePath)\n{\n    uint32_t rc = 0;\n    uefiDevicePath = uefiDevicePath;\n    return rc;\n}\n\n/* EV_EFI_GPT_EVENT */\n\nstatic void TSS_EfiGptEvent_Init(TSST_EFIData *efiData)\n{\n    TSS_UEFI_GPT_DATA *uefiGptData = &efiData->efiData.uefiGptData;\n    uefiGptData->Partitions = NULL;\n    uefiGptData->UEFIPartitionHeader.Reserved2 = NULL;\n    return;\n}\n\nstatic void TSS_EfiGptEvent_Free(TSST_EFIData *efiData)\n{\n    TSS_UEFI_GPT_DATA *uefiGptData = &efiData->efiData.uefiGptData;\n    free(uefiGptData->Partitions);\n    free(uefiGptData->UEFIPartitionHeader.Reserved2);\n    return;\n}\n\nstatic uint32_t TSS_EfiGptEvent_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t  uint8_t *event, uint32_t eventSize,\n\t\t\t\t\t  uint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    uint64_t partitionCount;\n    TSS_UEFI_GPT_DATA *uefiGptData = &efiData->efiData.uefiGptData;\n    TSS_UEFI_PARTITION_TABLE_HEADER *efiPartitionHeader = &(uefiGptData->UEFIPartitionHeader);\n\n    pcrIndex = pcrIndex;\n    if (rc == 0) {\n\trc = TSS_EfiPartitionHeader_ReadBuffer(efiPartitionHeader,\n\t\t\t\t\t      &event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiGptData->NumberOfPartitions, &event, &eventSize);\n    }\n    if (rc == 0) {\n\tif (uefiGptData->NumberOfPartitions > EFI_LENGTH_MAX) {\n\t    printf(\"TSS_EfiVariableData_ReadBuffer: VariableDataLength %\" PRIu64 \" too large\\n\",\n\t\t   uefiGptData->NumberOfPartitions);\n\t    rc = TSS_RC_MALLOC_SIZE;\n\t}\n    }\n    if (rc == 0) {\n\tif (uefiGptData->NumberOfPartitions > 0) {\n\t    /* freed by TSS_EfiGptEvent_Free */\n\t    uefiGptData->Partitions =\n\t\tmalloc((size_t)uefiGptData->NumberOfPartitions * sizeof(TSS_UEFI_PARTITION_ENTRY));\n\t    if (uefiGptData->Partitions == NULL) {\n\t\tprintf(\"TSS_EfiGptEvent_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)\n\t\t       (uefiGptData->NumberOfPartitions * sizeof(TSS_UEFI_PARTITION_ENTRY)));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n    }\n    for (partitionCount = 0 ;\n\t (rc == 0) && (partitionCount < uefiGptData->NumberOfPartitions) ;\n\t partitionCount++) {\n\n\tTSS_UEFI_PARTITION_ENTRY *entry = uefiGptData->Partitions + partitionCount;\n\tif (rc == 0) {\n\t    rc = TSS_EfiPartitionEntry_ReadBuffer(entry, &event, &eventSize);\n\t}\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiPartitionHeader_ReadBuffer(TSS_UEFI_PARTITION_TABLE_HEADER *efiPartitionHeader,\n\t\t\t\t\t\t  uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    uint32_t startEventSize = *eventSize; /* track what was unmarshaled, excluding reserved */\n\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&efiPartitionHeader->Signature, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&efiPartitionHeader->Revision, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&efiPartitionHeader->HeaderSize, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&efiPartitionHeader->HeaderCRC32, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&efiPartitionHeader->Reserved1, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&efiPartitionHeader->MyLBA, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&efiPartitionHeader->AlternateLBA, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&efiPartitionHeader->FirstUsableLBA, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&efiPartitionHeader->LastUsableLBA, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(efiPartitionHeader->DiskGUID,\n\t\t\t\t  sizeof(efiPartitionHeader->DiskGUID),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&efiPartitionHeader->PartitionEntryLBA, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&efiPartitionHeader->NumberOfPartitionEntries, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&efiPartitionHeader->SizeOfPartitionEntry, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&efiPartitionHeader->PartitionEntryArrayCRC32, event, eventSize);\n    }\n    /* skip the reserved area for now */\n    if (rc == 0) {\n\tuint32_t endEventSize = *eventSize;\n\tuint32_t usedBytes = startEventSize - endEventSize;  \t\t/* used in the header */\n\tuint32_t skipBytes = efiPartitionHeader->HeaderSize - usedBytes; /* the reserved field */\n\tif (skipBytes <= *eventSize) {\t\t/* bounds check */\n\t    /* skip unused bytes that are reserved */\n\t    *event += skipBytes;\n\t    *eventSize -= skipBytes;\n\t}\n\telse {\t/* HeaderSize inconsistent with eventSize */\n\t    rc = TPM_RC_INSUFFICIENT;\n\t}\n    }\n    return rc;\n}\n\nstatic uint32_t TSS_EfiPartitionEntry_ReadBuffer(TSS_UEFI_PARTITION_ENTRY *entry,\n\t\t\t\t\t\t uint8_t **event, uint32_t *eventSize)\n{\n    uint32_t rc = 0;\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(entry->PartitionTypeGUID,\n\t\t\t\t  sizeof(entry->PartitionTypeGUID),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(entry->UniquePartitionGUID,\n\t\t\t\t  sizeof(entry->UniquePartitionGUID),\n\t\t\t\t  event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&entry->StartingLBA, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&entry->EndingLBA, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&entry->Attributes, event, eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(entry->PartitionName,\n\t\t\t\t  sizeof(entry->PartitionName),\n\t\t\t\t  event, eventSize);\n    }\n    return rc;\n}\n\nstatic void TSS_EfiGptEvent_Trace(TSST_EFIData *efiData)\n{\n    TSS_UEFI_GPT_DATA *uefiGptData = &efiData->efiData.uefiGptData;\n    TSS_UEFI_PARTITION_TABLE_HEADER *efiPartitionHeader = &(uefiGptData->UEFIPartitionHeader);\n    uint64_t partitionCount;\n\n    TSS_EfiPartitionHeader_Trace(efiPartitionHeader);\n    printf(\"  Number of Partitions: %\" PRIu64 \"\\n\\n\", uefiGptData->NumberOfPartitions);\n    for (partitionCount = 0 ;\n\t partitionCount < uefiGptData->NumberOfPartitions ;\n\t partitionCount++) {\n\n\tTSS_UEFI_PARTITION_ENTRY *entry = uefiGptData->Partitions + partitionCount;\n\tTSS_EfiPartitionEntry_Trace(entry);\n    }\n    return;\n}\n\nstatic void TSS_EfiPartitionHeader_Trace(TSS_UEFI_PARTITION_TABLE_HEADER *efiPartitionHeader)\n{\n    printf(\"  Signature %016\" PRIx64 \"\\n\", efiPartitionHeader->Signature);\n    printf(\"  Revision %08x\\n\", efiPartitionHeader->Revision);\n    printf(\"  HeaderSize %u\\n\", efiPartitionHeader->HeaderSize);\n    printf(\"  HeaderCRC32 %08x\\n\", efiPartitionHeader->HeaderCRC32);\n    printf(\"  Reserved1 %u\\n\", efiPartitionHeader->Reserved1);\n    printf(\"  MyLBA %016\" PRIx64 \"\\n\", efiPartitionHeader->MyLBA);\n    printf(\"  AlternateLBA %016\" PRIx64 \"\\n\", efiPartitionHeader->AlternateLBA);\n    printf(\"  FirstUsableLBA %016\" PRIx64 \"\\n\", efiPartitionHeader->FirstUsableLBA);\n    printf(\"  LastUsableLBA %016\" PRIx64 \"\\n\", efiPartitionHeader->LastUsableLBA);\n    guid_printf(\"DiskGUID\", efiPartitionHeader->DiskGUID);\n    printf(\"  PartitionEntryLBA %016\" PRIx64 \"\\n\", efiPartitionHeader->PartitionEntryLBA);\n    printf(\"  NumberOfPartitionEntries %u\\n\", efiPartitionHeader->NumberOfPartitionEntries);\n    printf(\"  SizeOfPartitionEntry %u\\n\", efiPartitionHeader->SizeOfPartitionEntry);\n    printf(\"  PartitionEntryArrayCRC32 %08x\\n\", efiPartitionHeader->PartitionEntryArrayCRC32);\n    return;\n}\n\nstatic void TSS_EfiPartitionEntry_Trace(TSS_UEFI_PARTITION_ENTRY *entry)\n{\n    guid_printf(\"  PartitionTypeGUID\", entry->PartitionTypeGUID);\n    guid_printf(\"  UniquePartitionGUID\", entry->UniquePartitionGUID);\n    printf(\"    StartingLBA %016\" PRIx64 \"\\n\", entry->StartingLBA);\n    printf(\"    EndingLBA %016\" PRIx64 \"\\n\",  entry->EndingLBA);\n    printf(\"    Attributes %016\" PRIx64 \"\\n\", entry->Attributes);\n    printf(\"    PartitionName %.*s\\n\", (int)sizeof(entry->PartitionName), entry->PartitionName);\n    printf(\"\\n\");\n    return;\n}\n\n\nstatic uint32_t TSS_EfiGptEvent_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_GPT_DATA *uefiGptData = &efiData->efiData.uefiGptData;\n    uefiGptData = uefiGptData;\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_S_CRTM_VERSION\n   EV_POST_CODE\n*/\n\nstatic void TSS_Efi4bBuffer_Init(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer->size = 0;\n    tss4bBuffer->buffer = NULL;\n    return;\n}\n\nstatic void TSS_Efi4bBuffer_Free(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    free(tss4bBuffer->buffer);\n    return;\n}\n\nstatic uint32_t TSS_Efi4bBuffer_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t  uint8_t *event, uint32_t eventSize, uint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    pcrIndex = pcrIndex;\n\n    if (rc == 0) {\n\ttss4bBuffer->size = eventSize;\n\t/* allocate the array*/\n\tif (tss4bBuffer->size > 0) {\n\t    /* freed by TSS_Efi4bBuffer_Free */\n\t    tss4bBuffer->buffer = malloc(tss4bBuffer->size);\n\t    if (tss4bBuffer->buffer == NULL) {\n\t\tprintf(\"TSS_Efi4bBuffer_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       tss4bBuffer->size);\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n    }\n    /* unmarshal UnicodeName */\n    if (rc == 0) {\n\tif (tss4bBuffer->size > 0) {\n\t    rc = TSS_Array_Unmarshalu(tss4bBuffer->buffer, tss4bBuffer->size,\n\t\t\t\t      &event, &eventSize);\n\t}\n\telse {\n\t    /* FIXME is zero an error ? */\n\t}\n    }\n    return rc;\n}\n\n/* EV_COMPACT_HASH */\n\nstatic void     TSS_EfiCompactHash_Trace(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    int done = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n\n    /* PCR 6 event holds a string */\n    if (efiData->pcrIndex == 6) {\n\tdone = 1;\n\tprintf(\"  Compact Hash: %.*s\\n\", tss4bBuffer->size, tss4bBuffer->buffer);\n    }\n    /* PCR 11 holds MS Bitlocker status, see EV_COMPACT_HASH_TABLE */\n    else if (efiData->pcrIndex == 11) {\n\tsize_t index = 0;\n\tif (tss4bBuffer->size == sizeof(((EV_COMPACT_HASH_TABLE *)NULL)->value)) {\n\t    rc = TSS_EFI_GetCompactHashIndex(&index, tss4bBuffer->buffer);\n\t}\n\tif (rc == 0) {\t\t/* found an entry */\n\t    const char *text = compactHashTable[index].text;\n\t    done = 1;\n\t    printf(\"  Compact Hash: %s\\n\", text);\n\t}\n    }\n    if (!done) {\n\tTSS_PrintAll(\"    Compact Hash unsupported\",\n\t\t     tss4bBuffer->buffer, tss4bBuffer->size);\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiCompactHash_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer = tss4bBuffer;\n\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_IPL */\n\nstatic void     TSS_EfiIpl_Trace(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    uint8_t type;\n    uint32_t length;\n    uint8_t *buffer = tss4bBuffer->buffer;\n    uint32_t size = tss4bBuffer->size;\n\n    /* unspecified, this is not in a structure yet, because this is just a guess */\n    while ((rc == 0) && (size > 0)) {\n\t/* if the first byte is printable, guess it's a nul terminated string */\n\tif (isprint(tss4bBuffer->buffer[0])) {\n\t    printf(\"  IPL: %.*s\\n\", tss4bBuffer->size, tss4bBuffer->buffer);\n\t    size = 0;\t/* consume the entire event */\n\t}\n\t/* else they are TLV tuples */\n\telse {\n\t    if (rc == 0) {\n\t\trc = TSS_UINT8_Unmarshalu(&type, &buffer, &size);\n\t    }\n\t    if (rc == 0) {\n\t\trc = TSS_UINT32_Unmarshalu(&length, &buffer, &size);\n\t    }\n\t    if (rc == 0) {\n\t\tif (length <= size) {\n\t\t    switch (type) {\n\t\t      case 0x02:\n\t\t\tTSS_PrintAll(\"  IPL: Digest\", buffer, length);\n\t\t\tbreak;\n\t\t      case 0x03:\n\t\t\tprintf(\"  IPL: %.*s\\n\", length, buffer);\n\t\t\tbreak;\n\t\t      default:\n\t\t\tbreak;\n\t\t    }\n\t\t    buffer += length;\n\t\t    size -= length;\n\t\t}\n\t\telse {\n\t\t    printf(\"  IPL: type %02x length %u > size %u\\n\", type, length, size);\n\t\t    size = 0;\t/* reject the rest of the buffer */\n\t\t}\n\t    }\n\t}\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiIpl_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer = tss4bBuffer;\n\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_IPL_PARTITION_DATA */\n\nstatic void     TSS_EfiIplPartitionData_Trace(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n\n    printf(\"  Partition Data: %.*s\\n\", tss4bBuffer->size, tss4bBuffer->buffer);\n    return;\n}\n\nstatic uint32_t TSS_EfiIplPartitionData_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer = tss4bBuffer;\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_S_CRTM_VERSION can be either a UCS-2 or a GUID. */\n\nstatic void TSS_EfiCrtmVersion_Trace(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    int isUCS2 = 1;\n    int isGuid = 1;\n\n    isUCS2String(&isUCS2, tss4bBuffer->buffer, tss4bBuffer->size);\n    /* if it's not UCS-2, it could be a GUID */\n    if (!isUCS2) {\n\tif (tss4bBuffer->size != TSS_EFI_GUID_SIZE) {\n\t    isGuid = 0;\n\t}\n    }\n    if (isUCS2) {\n\tucs2_printf(\"CRTM Version: \", tss4bBuffer->buffer, tss4bBuffer->size -2);\n    }\n    else if (isGuid) {\n\tguid_printf(\"CRTM Version GUID\", tss4bBuffer->buffer);\n    }\n    else {\t/* something else */\n\tTSS_PrintAll(\"CRTM Version\", tss4bBuffer->buffer, tss4bBuffer->size);\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiCrtmVersion_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer = tss4bBuffer;\n    if (rc == 0) {\n    }\n    if (rc == 0) {\n    }\n    if (rc == 0) {\n    }\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_S_CRTM_CONTENTS */\n\nstatic void TSS_EfiCrtmContents_Trace(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    printf(\"  CRTM Contents: %.*s\\n\", tss4bBuffer->size, tss4bBuffer->buffer);\n    return;\n}\n\nstatic uint32_t TSS_EfiCrtmContents_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer = tss4bBuffer;\n    if (rc == 0) {\n    }\n    if (rc == 0) {\n    }\n    if (rc == 0) {\n    }\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_EFI_ACTION */\n\nstatic void TSS_EfiEfiAction_Trace(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    printf(\"  EFI Action: %.*s\\n\", tss4bBuffer->size, tss4bBuffer->buffer);\n    return;\n}\n\nstatic uint32_t TSS_EfiEfiAction_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer = tss4bBuffer;\n    if (rc == 0) {\n    }\n    if (rc == 0) {\n    }\n    if (rc == 0) {\n    }\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* Event that is only a printable string */\n\n#if 0\n\nstatic uint32_t TSS_EfiChar_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t      uint8_t *event, uint32_t eventSize, uint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    pcrIndex = pcrIndex;\n    if (rc == 0) {\n\trc = TSS_Efi4bBuffer_ReadBuffer(efiData, event, eventSize, pcrIndex);\n    }a\n    return rc;\n}\n\nstatic void TSS_EfiChar_Trace(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    printf(\" %.*s\\n\", tss4bBuffer->size, tss4bBuffer->buffer);\n    return;\n}\n\nstatic uint32_t TSS_EfiChar_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer = tss4bBuffer;\n    if (rc == 0) {\n    }\n    return rc;\n}\n#endif\n\n/* EV_NO_ACTION */\n\nstatic void     TSS_EvNoAction_Trace(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    if (efiData->pcrIndex == 0) {\n\tprintf(\"  PCR 0: %.*s\\n\", tss4bBuffer->size, tss4bBuffer->buffer);\n\tprintf(\"  Locality %u\\n\", tss4bBuffer->buffer[tss4bBuffer->size-1]);\n    }\n    /* This is purely from guesses and decompiling the events, not from any spec */\n    else if (efiData->pcrIndex == 0xffffffff) {\n\tucs2_printf(\"  No Action: \", tss4bBuffer->buffer+16, 22);\n    }\n    else {\n\tTSS_PrintAll(\"  No Action\",\n\t\t     tss4bBuffer->buffer, tss4bBuffer->size);\n    }\n    return;\n}\n\n/* EV_SEPARATOR */\n\nstatic void TSS_EfiSeparator_Trace(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n\n    /* By observation, the separator for thses PCRs seem to be ascii */\n    if ((efiData->pcrIndex == 12) ||\n\t(efiData->pcrIndex == 13) ||\n\t(efiData->pcrIndex == 14)) {\n\tprintf(\"  Separator: %.*s\\n\", tss4bBuffer->size, tss4bBuffer->buffer);\n    }\n    else {\n\tTSS_PrintAll(\"  Separator\",\n\t\t     tss4bBuffer->buffer, tss4bBuffer->size);\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiSeparator_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer = tss4bBuffer;\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_ACTION */\n\n/* PFP says these are printable strings, but not NUL terminated */\n\nstatic void     TSS_EfiAction_Trace(TSST_EFIData *efiData)\n{\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n\n    printf(\"  Action: %.*s\\n\", tss4bBuffer->size, tss4bBuffer->buffer);\n    return;\n}\n\nstatic uint32_t TSS_EfiAction_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS4B_BUFFER *tss4bBuffer = &efiData->efiData.tss4bBuffer;\n    tss4bBuffer = tss4bBuffer;\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_EVENT_TAG */\n\nstatic void     TSS_EfiEventTag_Init(TSST_EFIData *efiData)\n{\n    TSS_UEFI_TAGGED_EVENT *taggedEventList = &efiData->efiData.taggedEventList;\n    taggedEventList->count = 0;\n    taggedEventList->taggedEvent = NULL;\n    return;\n}\n\nstatic void     TSS_EfiEventTag_Free(TSST_EFIData *efiData)\n{\n    uint32_t count;\n    TSS_UEFI_TAGGED_EVENT *taggedEventList = &efiData->efiData.taggedEventList;\n    for (count = 0 ; count < taggedEventList->count ; count++) {\n\tTSS_PCClientTaggedEvent *taggedEvent = taggedEventList->taggedEvent + count;\n\tfree(taggedEvent->taggedEventData);\n    }\n    free(taggedEventList->taggedEvent);\n    return;\n}\n\nstatic uint32_t TSS_EfiEvent_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\tuint8_t *event, uint32_t eventSize,\n\t\t\t\t\tuint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_TAGGED_EVENT *taggedEventList = &efiData->efiData.taggedEventList;\n    TSS_PCClientTaggedEvent *taggedEvent;\n    pcrIndex = pcrIndex;\n\n    while ((rc == 0) && (eventSize > 0)) {\n\t/* if there is more event data, unmarshal the next TSS_PCClientTaggedEvent */\n\tif (rc == 0) {\n\t    void *tmpptr;\t\t\t/* for realloc */\n\t    /* freed by TSS_EfiEventTag_Free */\n\t    tmpptr = realloc(taggedEventList->taggedEvent,\n\t\t\t     sizeof(TSS_PCClientTaggedEvent) * ((size_t)(taggedEventList->count)+1));\n\t    if (tmpptr != NULL) {\n\t\ttaggedEventList->taggedEvent = tmpptr;\n\t\ttaggedEvent = taggedEventList->taggedEvent + taggedEventList->count;\n\t\ttaggedEventList->count++;\n\t    }\n\t    else {\n\t\tprintf(\"TSS_EfiEvent_ReadBuffer: Error allocating %lu bytes\\n\",\n\t\t       (unsigned long)\n\t\t       (sizeof(TSS_PCClientTaggedEvent) * ((size_t)(taggedEventList->count)+1)));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_UINT32LE_Unmarshal(&taggedEvent->taggedEventID, &event, &eventSize);\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_UINT32LE_Unmarshal(&taggedEvent->taggedEventDataSize, &event, &eventSize);\n\t}\n\t/* consistency check taggedEventDataSize */\n\tif (rc == 0) {\n\t    if (taggedEvent->taggedEventDataSize > eventSize) {\n\t\tprintf(\"TSS_EfiEvent_ReadBuffer: Error in taggedEventDataSize %u\\n\",\n\t\t       (unsigned int)(taggedEvent->taggedEventDataSize));\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n\t/* allocate the taggedEventData */\n\tif ((rc == 0) && (taggedEvent->taggedEventDataSize > 0)) {\n\t    taggedEvent->taggedEventData = malloc(taggedEvent->taggedEventDataSize);\n\t    if (taggedEvent->taggedEventData == NULL) {\n\t\tprintf(\"TSS_EfiEvent_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)taggedEvent->taggedEventDataSize);\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif ((rc == 0) && (eventSize > 0)) {\n\t    rc = TSS_Array_Unmarshalu(taggedEvent->taggedEventData, taggedEvent->taggedEventDataSize,\n\t\t\t\t      &event, &eventSize);\n\t}\n    }\n    return rc;\n}\n\nstatic void     TSS_EfiEventTag_Trace(TSST_EFIData *efiData)\n{\n    uint32_t \t\t\tcount;\n    TSS_UEFI_TAGGED_EVENT \t*taggedEventList = &efiData->efiData.taggedEventList;\n#ifndef TPM_TSS_MBEDTLS\n#ifndef TPM_TSS_NORSA\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    RSA \t\t*rsaKey = NULL;\n#else\n    EVP_PKEY \t\t*rsaKey = NULL;\n#endif\n#endif\t/* TPM_TSS_NORSA */\n#endif\t/* TPM_TSS_MBEDTLS */\n\n    printf(\"  tagged events %u\\n\", taggedEventList->count);\n    for (count = 0 ; count < taggedEventList->count ; count++) {\n\tTSS_PCClientTaggedEvent *taggedEvent = taggedEventList->taggedEvent + count;\n\n\tprintf(\"    taggedEventID %08x\\n\", taggedEvent->taggedEventID);\n\t/* https://github.com/mattifestation/TCGLogTools/blob/master/TCGLogTools.psm1 */\n\t/* by observation 0x00060002 appears to be a DER encoded public key */\n#if ! defined TPM_TSS_MBEDTLS && ! defined TPM_TSS_NORSA\n\tif (taggedEvent->taggedEventID == 0x00060002) {\n\t    const unsigned char *tmpData = NULL;\n\t    /* tmp pointer because d2i moves the pointer */\n\t    tmpData = taggedEvent->taggedEventData;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t    rsaKey = d2i_RSA_PUBKEY(NULL, &tmpData ,taggedEvent->taggedEventDataSize); /* freed @2 */\n#else\n\t    rsaKey = d2i_PUBKEY(NULL, &tmpData, (long)taggedEvent->taggedEventDataSize);\n#endif\t/* OPENSSL_VERSION_NUMBER */\n\t    if (rsaKey != NULL) { \t/* success */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\tRSA_print_fp(stdout, rsaKey, 4);\n#else\n\t\tEVP_PKEY_print_public_fp(stdout, rsaKey, 4, NULL);\n#endif /* OPENSSL_VERSION_NUMBER */\n\t    }\n\t    if (rsaKey != NULL) {\n\t\tTSS_RsaFree(rsaKey); \t/* @2 */\n\t    }\n\t}\n\t/* if it's not 0x00060002 or if the d2i fails */\n\t/* 0x40010001 = 'TrustBoundary' seems to be a common event.  Anyone have documentation? */\n\tif ((taggedEvent->taggedEventID != 0x00060002) || (rsaKey == NULL)) {\n\t    TSS_PrintAll(\"   taggedEvent\",\n\t\t\t taggedEvent->taggedEventData, taggedEvent->taggedEventDataSize);\n\t}\n#else\t/* TPM_TSS_MBEDTLS or TPM_TSS_NORSA */\n\tTSS_PrintAll(\"   taggedEvent\",\n\t\t     taggedEvent->taggedEventData, taggedEvent->taggedEventDataSize);\n#endif\t/* TPM_TSS_MBEDTLS TPM_TSS_NORSA */\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiEventTag_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_TAGGED_EVENT \t*taggedEventList = &efiData->efiData.taggedEventList;\n    taggedEventList = taggedEventList;\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_EFI_HANDOFF_TABLES */\n\nstatic void TSS_EfiHandoffTables_Init(TSST_EFIData *efiData)\n{\n    TSS_UEFI_HANDOFF_TABLE_POINTERS *uefiHandoffTablePointers =\n\t&efiData->efiData.uefiHandoffTablePointers;\n    uefiHandoffTablePointers->TableEntry = NULL;\n    return;\n}\n\nstatic void TSS_EfiHandoffTables_Free(TSST_EFIData *efiData)\n{\n    TSS_UEFI_HANDOFF_TABLE_POINTERS *uefiHandoffTablePointers =\n\t&efiData->efiData.uefiHandoffTablePointers;\n    free(uefiHandoffTablePointers->TableEntry);\n    return;\n}\n\nstatic uint32_t TSS_EfiHandoffTables_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\tuint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\tuint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_HANDOFF_TABLE_POINTERS *uefiHandoffTablePointers =\n\t&efiData->efiData.uefiHandoffTablePointers;\n    pcrIndex = pcrIndex;\n\n    rc = TSS_EfiTablePointers_ReadBuffer(uefiHandoffTablePointers,\n\t\t\t\t\t &event, &eventSize,\n\t\t\t\t\t pcrIndex);\n    return rc;\n}\n\n/* TSS_EfiTablePointers_ReadBuffer() is common code for EV_EFI_HANDOFF_TABLES and\n   EV_EFI_HANDOFF_TABLES2 */\n\nstatic uint32_t\nTSS_EfiTablePointers_ReadBuffer(TSS_UEFI_HANDOFF_TABLE_POINTERS *uefiHandoffTablePointers,\n\t\t\t\tuint8_t **event, uint32_t *eventSize,\n\t\t\t\tuint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    uint64_t tableCount;\n\n    pcrIndex = pcrIndex;\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiHandoffTablePointers->NumberOfTables, event, eventSize);\n    }\n    /* sanity check the lengths since the input is untrusted.  This also guarantees that a cast to\n       uint32_t is safe. */\n    if (rc == 0) {\n\tif (uefiHandoffTablePointers->NumberOfTables >\n\t    EFI_LENGTH_MAX/sizeof(TSS_EFI_CONFIGURATION_TABLE)) {\n\t    printf(\"TSS_EfiHandoffTables_ReadBuffer: NumberOfTables %\" PRIu64 \" too large\\n\",\n\t\t   uefiHandoffTablePointers->NumberOfTables);\n\t    rc = TSS_RC_MALLOC_SIZE;\n\t}\n    }\n    /* allocate the TSS_EFI_CONFIGURATION_TABLE list */\n    if (rc == 0) {\n\tif (uefiHandoffTablePointers->NumberOfTables > 0) {\n\t    /* freed by TSS_EfiHandoffTables_Free */\n\t    uefiHandoffTablePointers->TableEntry =\n\t\tmalloc((size_t)uefiHandoffTablePointers->NumberOfTables *\n\t\t       sizeof(TSS_EFI_CONFIGURATION_TABLE));\n\t    if (uefiHandoffTablePointers->TableEntry == NULL) {\n\t\tprintf(\"TSS_EfiHandoffTables_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t       (unsigned int)\n\t\t       (uefiHandoffTablePointers->NumberOfTables *\n\t\t\tsizeof(TSS_EFI_CONFIGURATION_TABLE)));\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n    }\n    /* unmarshal Tables */\n    for (tableCount = 0 ;\n\t (rc == 0) && (tableCount < uefiHandoffTablePointers->NumberOfTables) ;\n\t tableCount++) {\n\n\tTSS_EFI_CONFIGURATION_TABLE *table = uefiHandoffTablePointers->TableEntry + tableCount;\n\tif (rc == 0) {\n\t    rc = TSS_Array_Unmarshalu(table->VendorGuid,\n\t\t\t\t      sizeof(table->VendorGuid),\n\t\t\t\t      event, eventSize);\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_UINT64LE_Unmarshal(&table->VendorTable, event, eventSize);\n\t}\n    }\n    return rc;\n}\n\nstatic void     TSS_EfiHandoffTables_Trace(TSST_EFIData *efiData)\n{\n    uint64_t tableCount;\n    TSS_UEFI_HANDOFF_TABLE_POINTERS *uefiHandoffTablePointers =\n\t&efiData->efiData.uefiHandoffTablePointers;\n\n    printf(\"  NumberOfTables: %016\" PRIx64 \"\\n\", uefiHandoffTablePointers->NumberOfTables);\n    for (tableCount = 0 ; tableCount < uefiHandoffTablePointers->NumberOfTables ; tableCount++) {\n\tTSS_EFI_CONFIGURATION_TABLE *table = uefiHandoffTablePointers->TableEntry + tableCount;\n\tguid_printf(\"VendorGuid\", table->VendorGuid);\n\tprintf(\"  VendorTable: %016\" PRIx64 \"\\n\", table->VendorTable);\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiHandoffTables_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_HANDOFF_TABLE_POINTERS *uefiHandoffTablePointers =\n\t&efiData->efiData.uefiHandoffTablePointers;\n    uefiHandoffTablePointers = uefiHandoffTablePointers;\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n/* EV_EFI_HANDOFF_TABLE2S */\n\nstatic void TSS_EfiHandoffTables2_Init(TSST_EFIData *efiData)\n{\n    TSS_UEFI_HANDOFF_TABLE_POINTERS2 *uefiHandoffTablePointers2 =\n\t&efiData->efiData.uefiHandoffTablePointers2;\n    uefiHandoffTablePointers2->TableDescription = NULL;\n    uefiHandoffTablePointers2->uefiHandoffTablePointers.TableEntry = NULL;\n    return;\n}\n\nstatic void TSS_EfiHandoffTables2_Free(TSST_EFIData *efiData)\n{\n    TSS_UEFI_HANDOFF_TABLE_POINTERS2 *uefiHandoffTablePointers2 =\n\t&efiData->efiData.uefiHandoffTablePointers2;\n    free(uefiHandoffTablePointers2->TableDescription);\n    free(uefiHandoffTablePointers2->uefiHandoffTablePointers.TableEntry);\n    return;\n}\n\nstatic uint32_t TSS_EfiHandoffTables2_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\tuint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\tuint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_HANDOFF_TABLE_POINTERS2 *uefiHandoffTablePointers2 =\n\t&efiData->efiData.uefiHandoffTablePointers2;\n    pcrIndex = pcrIndex;\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&uefiHandoffTablePointers2->TableDescriptionSize,\n\t\t\t\t  &event, &eventSize);\n    }\n    if (rc == 0) {\n\tuefiHandoffTablePointers2->TableDescription =\n\t    malloc(uefiHandoffTablePointers2->TableDescriptionSize);\n\tif (uefiHandoffTablePointers2->TableDescription == NULL) {\n\t    printf(\"TSS_EfiHandoffTables2_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t   (unsigned int)(uefiHandoffTablePointers2->TableDescriptionSize));\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(uefiHandoffTablePointers2->TableDescription,\n\t\t\t\t  uefiHandoffTablePointers2->TableDescriptionSize,\n\t\t\t\t  &event, &eventSize);\n    }\n    /* the table entry read is shared between TSS_UEFI_HANDOFF_TABLE_POINTERS and\n       TSS_UEFI_HANDOFF_TABLE_POINTERS2 */\n    if (rc == 0) {\n\tTSS_UEFI_HANDOFF_TABLE_POINTERS *uefiHandoffTablePointers =\n\t    &efiData->efiData.uefiHandoffTablePointers2.uefiHandoffTablePointers;\n\trc = TSS_EfiTablePointers_ReadBuffer(uefiHandoffTablePointers,\n\t\t\t\t\t     &event, &eventSize,\n\t\t\t\t\t     pcrIndex);\n    }\n    return rc;\n}\n\nstatic void     TSS_EfiHandoffTables2_Trace(TSST_EFIData *efiData)\n{\n    uint64_t tableCount;\n    TSS_UEFI_HANDOFF_TABLE_POINTERS2 *uefiHandoffTablePointers2 =\n\t&efiData->efiData.uefiHandoffTablePointers2;\n    TSS_UEFI_HANDOFF_TABLE_POINTERS *uefiHandoffTablePointers =\n\t&uefiHandoffTablePointers2->uefiHandoffTablePointers;\n\n    printf(\"  TableDescription: %.*s\\n\", \n\t   (int)uefiHandoffTablePointers2->TableDescriptionSize,\n\t   uefiHandoffTablePointers2->TableDescription);\n    printf(\"  NumberOfTables: %016\" PRIx64 \"\\n\", uefiHandoffTablePointers->NumberOfTables);\n    for (tableCount = 0 ; tableCount < uefiHandoffTablePointers->NumberOfTables ; tableCount++) {\n\tTSS_EFI_CONFIGURATION_TABLE *table = uefiHandoffTablePointers->TableEntry + tableCount;\n\tguid_printf(\"VendorGuid\", table->VendorGuid);\n\tprintf(\"  VendorTable: %016\" PRIx64 \"\\n\", table->VendorTable);\n    }\n    return;\n}\n\nstatic uint32_t TSS_EfiHandoffTables2_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_HANDOFF_TABLE_POINTERS2 *uefiHandoffTablePointers2 =\n\t&efiData->efiData.uefiHandoffTablePointers2;\n    uefiHandoffTablePointers2  = uefiHandoffTablePointers2;\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n\n/* EV_EFI_PLATFORM_FIRMWARE_BLOB2 */\n\nstatic void TSS_EfiPlatformFirmwareBlob2_Init(TSST_EFIData *efiData)\n{\n    TSS_UEFI_PLATFORM_FIRMWARE_BLOB2 *uefiPlatformFirmwareBlob2 =\n\t&efiData->efiData.uefiPlatformFirmwareBlob2;\n    uefiPlatformFirmwareBlob2->BlobDescription = NULL;\n    return;\n}\nstatic void TSS_EfiPlatformFirmwareBlob2_Free(TSST_EFIData *efiData)\n{\n    TSS_UEFI_PLATFORM_FIRMWARE_BLOB2 *uefiPlatformFirmwareBlob2 =\n\t&efiData->efiData.uefiPlatformFirmwareBlob2;\n    free(uefiPlatformFirmwareBlob2->BlobDescription);\n}\nstatic uint32_t TSS_EfiPlatformFirmwareBlob2_ReadBuffer(TSST_EFIData *efiData,\n\t\t\t\t\t\t\tuint8_t *event, uint32_t eventSize,\n\t\t\t\t\t\t\tuint32_t pcrIndex)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_PLATFORM_FIRMWARE_BLOB2 *uefiPlatformFirmwareBlob2 =\n\t&efiData->efiData.uefiPlatformFirmwareBlob2;\n    pcrIndex = pcrIndex;\n\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&uefiPlatformFirmwareBlob2->BlobDescriptionSize,\n\t\t\t\t  &event, &eventSize);\n    }\n    if (rc == 0) {\n\tuefiPlatformFirmwareBlob2->BlobDescription =\n\t    malloc(uefiPlatformFirmwareBlob2->BlobDescriptionSize);\n\tif (uefiPlatformFirmwareBlob2->BlobDescription == NULL) {\n\t    printf(\"TSS_EfiPlatformFirmwareBlob2_ReadBuffer: Error allocating %u bytes\\n\",\n\t\t   (unsigned int)(uefiPlatformFirmwareBlob2->BlobDescriptionSize));\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(uefiPlatformFirmwareBlob2->BlobDescription,\n\t\t\t\t  uefiPlatformFirmwareBlob2->BlobDescriptionSize,\n\t\t\t\t  &event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiPlatformFirmwareBlob2->BlobBase, &event, &eventSize);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64LE_Unmarshal(&uefiPlatformFirmwareBlob2->BlobLength, &event, &eventSize);\n    }\n    return rc;\n}\n\nstatic void     TSS_EfiPlatformFirmwareBlob2_Trace(TSST_EFIData *efiData)\n{\n    TSS_UEFI_PLATFORM_FIRMWARE_BLOB2 *uefiPlatformFirmwareBlob2 =\n\t&efiData->efiData.uefiPlatformFirmwareBlob2;\n\n    printf(\"  BlobDescription: %.*s\\n\", \n\t   (int)uefiPlatformFirmwareBlob2->BlobDescriptionSize,\n\t   uefiPlatformFirmwareBlob2->BlobDescription);\n    printf(\"  BlobBase: %016\" PRIx64 \"\\n\", uefiPlatformFirmwareBlob2->BlobBase);\n    printf(\"  BlobLength: %016\" PRIx64 \"\\n\", uefiPlatformFirmwareBlob2->BlobLength);\n    return;\n}\nstatic uint32_t TSS_EfiPlatformFirmwareBlob2_ToJson(TSST_EFIData *efiData)\n{\n    uint32_t rc = 0;\n    TSS_UEFI_PLATFORM_FIRMWARE_BLOB2 *uefiPlatformFirmwareBlob2 =\n\t&efiData->efiData.uefiPlatformFirmwareBlob2;\n    uefiPlatformFirmwareBlob2 = uefiPlatformFirmwareBlob2;\n    if (rc == 0) {\n    }\n    return rc;\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/ekutils.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tEK Index Parsing Utilities (and more)\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2016 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* These functions are worthwhile sample code that probably (judgment call) do not belong in the\n   TSS library.\n\n   They started as code to manipulate EKs, EK templates, and EK certificates.\n\n   Other useful X509 certificate crypto functions are migrating here.  Much of it is OpenSSL\n   specific, but it also provides examples of how to port from OpenSSL 1.0 to 1.1.\n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <limits.h>\n\n/* Windows 10 crypto API clashes with openssl */\n#ifdef TPM_WINDOWS\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#endif\n\n#include <openssl/pem.h>\n#include <openssl/x509.h>\n#include <openssl/evp.h>\n\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n#include \"cryptoutils.h\"\n#include \"ekutils.h\"\n\n/* windows apparently uses _MAX_PATH in stdlib.h */\n#ifndef PATH_MAX\n#ifdef _MAX_PATH\n#define PATH_MAX _MAX_PATH\n#else\n/* Debian/Hurd does not define MAX_PATH */\n#define PATH_MAX 4096\n#endif\n#endif\n\n/* local functions */\n\n#ifdef TPM_TPM20\nstatic TPM_RC processAlgorithmSize(uint16_t *algorithmSize,\n\t\t\t\t   unsigned char *nonce,\n\t\t\t\t   uint16_t nonceSize,\n\t\t\t\t   TPMI_RH_NV_INDEX ekCertIndex);\n#endif \t/* TPM_TPM20 */\n\n/* The print flag is set by the caller, depending on whether it wants information displayed.\n\n   tssUtilsVerbose is a global, used for verbose debug print\n\n   Errors are always printed.\n*/\n\nextern int tssUtilsVerbose;\n\n#ifdef TPM_TPM20\n\n/* readNvBufferMax() determines the maximum NV read/write block size.  The limit is typically set by\n   the TPM property TPM_PT_NV_BUFFER_MAX.  However, it's possible that a value could be larger than\n   the TSS side structure MAX_NV_BUFFER_SIZE.\n*/\n\nTPM_RC readNvBufferMax(TSS_CONTEXT *tssContext,\n\t\t       uint32_t *nvBufferMax)\n{\n    TPM_RC\t\t\trc = 0;\n    GetCapability_In \t\tin;\n    GetCapability_Out\t\tout;\n\n    in.capability = TPM_CAP_TPM_PROPERTIES;\n    in.property = TPM_PT_NV_BUFFER_MAX;\n    in.propertyCount = 1;\t/* ask for one property */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_GetCapability,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    /* sanity check that the property name is correct (demo of how to parse the structure) */\n    if (rc == 0) {\n\tif ((out.capabilityData.data.tpmProperties.count > 0) &&\n\t    (out.capabilityData.data.tpmProperties.tpmProperty[0].property ==\n\t     TPM_PT_NV_BUFFER_MAX)) {\n\t    *nvBufferMax = out.capabilityData.data.tpmProperties.tpmProperty[0].value;\n\t}\n\telse {\n\t    if (tssUtilsVerbose) printf(\"readNvBufferMax: wrong property returned: %08x\\n\",\n\t\t   out.capabilityData.data.tpmProperties.tpmProperty[0].property);\n\t    /* hard code a value for a back level HW TPM that does not implement\n\t       TPM_PT_NV_BUFFER_MAX yet */\n\t    *nvBufferMax = 512;\n\t}\n\tif (tssUtilsVerbose) printf(\"readNvBufferMax: TPM max read/write: %u\\n\", *nvBufferMax);\n\t/* in addition, the maximum TSS side structure MAX_NV_BUFFER_SIZE is accounted for.  The TSS\n\t   value is typically larger than the TPM value. */\n\tif (*nvBufferMax > MAX_NV_BUFFER_SIZE) {\n\t    *nvBufferMax = MAX_NV_BUFFER_SIZE;\n\t}\n\tif (tssUtilsVerbose) printf(\"readNvBufferMax: combined max read/write: %u\\n\", *nvBufferMax);\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"getcapability: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n/* getIndexSize() uses TPM2_NV_ReadPublic() to return the NV index size */\n\nTPM_RC getIndexSize(TSS_CONTEXT *tssContext,\n\t\t    uint16_t *dataSize,\n\t\t    TPMI_RH_NV_INDEX nvIndex)\n{\n    TPM_RC\t\t\trc = 0;\n    NV_ReadPublic_In \t\tin;\n    NV_ReadPublic_Out\t\tout;\n    \n    if (rc == 0) {\n\t/* if (tssUtilsVerbose) printf(\"getIndexSize: index %08x\\n\", nvIndex); */\n\tin.nvIndex = nvIndex;\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_ReadPublic,\n\t\t\t TPM_RH_NULL, NULL, 0);\n\t/* only print if verbose, since EK nonce and template index may not exist */\n\tif ((rc != 0) && tssUtilsVerbose) {\n\t    const char *msg;\n\t    const char *submsg;\n\t    const char *num;\n\t    printf(\"nvreadpublic: failed, rc %08x\\n\", rc);\n\t    TSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\t    printf(\"%s%s%s\\n\", msg, submsg, num);\n\t}\n    }\n    if (rc == 0) {\n\t/* if (tssUtilsVerbose) printf(\"getIndexSize: size %u\\n\", out.nvPublic.t.nvPublic.dataSize); */\n\t*dataSize = out.nvPublic.nvPublic.dataSize;\n    }\n    return rc;\n}\n\n/* getIndexData() uses TPM2_NV_Read() to return the NV index contents.\n\n   It assumes index authorization with an empty password\n*/\n\nTPM_RC getIndexData(TSS_CONTEXT *tssContext,\n\t\t    unsigned char **readBuffer,\t\t/* freed by caller */\n\t\t    TPMI_RH_NV_INDEX nvIndex,\n\t\t    uint16_t readDataSize)\t\t/* total size to read */\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\tdone = FALSE;\n    uint32_t \t\t\tnvBufferMax;\n    uint16_t \t\t\tbytesRead;\t\t\t/* bytes read so far */\n    NV_Read_In \t\t\tin;\n    NV_Read_Out\t\t\tout;\n    \n    /* data may have to be read in chunks.  Read the TPM_PT_NV_BUFFER_MAX, the chunk size */\n    if (rc == 0) {\n\trc = readNvBufferMax(tssContext,\n\t\t\t     &nvBufferMax);\n    }    \n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"getIndexData: index %08x\\n\", nvIndex);\n\tin.authHandle = nvIndex;\t/* index authorization */\n\tin.nvIndex = nvIndex;\n\tin.offset = 0;\t\t\t/* start at beginning */\n\tbytesRead = 0;\t\t\t/* bytes read so far */\n    }\n    if (rc == 0) {\n\trc = TSS_Malloc(readBuffer, readDataSize);\n    }\n    /* call TSS to execute the command */\n    while ((rc == 0) && !done) {\n\tif (rc == 0) {\n\t    /* read a chunk */\n\t    in.offset = bytesRead;\n\t    if ((uint32_t)(readDataSize - bytesRead) < nvBufferMax) {\n\t\tin.size = readDataSize - bytesRead;\t/* last chunk */\n\t    }\n\t    else {\n\t\tin.size = nvBufferMax;\t\t/* next chunk */\n\t    }\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     (RESPONSE_PARAMETERS *)&out,\n\t\t\t     (COMMAND_PARAMETERS *)&in,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_NV_Read,\n\t\t\t     TPM_RS_PW, NULL, 0,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t    if (rc != 0) {\n\t\tconst char *msg;\n\t\tconst char *submsg;\n\t\tconst char *num;\n\t\tprintf(\"nvread: failed, rc %08x\\n\", rc);\n\t\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\t\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\t    }\n\t}\n \t/* copy the results to the read buffer */\n\tif (rc == 0) {\n\t    memcpy(*readBuffer + bytesRead, out.data.b.buffer, out.data.b.size);\n\t    bytesRead += out.data.b.size;\n\t    if (bytesRead == readDataSize) {\n\t\tdone = TRUE;\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* getIndexContents() uses TPM2_NV_ReadPublic() to get the NV index size, then uses TPM2_NV_Read()\n   to read the entire contents.\n\n*/\n\nTPM_RC getIndexContents(TSS_CONTEXT *tssContext,\n\t\t\tunsigned char **readBuffer,\t\t/* freed by caller */\n\t\t\tuint16_t *readBufferSize,\t\t/* total size read */\n\t\t\tTPMI_RH_NV_INDEX nvIndex)\n{\n    TPM_RC\t\t\trc = 0;\n\n    /* first read the public index size */\n    if (rc == 0) {\n\trc = getIndexSize(tssContext, readBufferSize, nvIndex);\n    }\n    /* read the entire index */\n    if (rc == 0) {\n\trc = getIndexData(tssContext,\n\t\t\t  readBuffer,\t\t\t/* freed by caller */\n\t\t\t  nvIndex,\n\t\t\t  *readBufferSize);\t\t/* total size to read */\n    }\n    return rc;\n}\n\n/* IWG (TCG Infrastructure Work Group) default EK primary key policies */\n\n/* Low range */\n\nstatic const unsigned char iwgPolicyASha256[] = {\n    0x83, 0x71, 0x97, 0x67, 0x44, 0x84, 0xB3, 0xF8, 0x1A, 0x90, 0xCC, 0x8D, 0x46, 0xA5, 0xD7, 0x24,\n    0xFD, 0x52, 0xD7, 0x6E, 0x06, 0x52, 0x0B, 0x64, 0xF2, 0xA1, 0xDA, 0x1B, 0x33, 0x14, 0x69, 0xAA\n};\n\n/* High range PolicyB SHA256 (policy OR) */\n\nstatic const unsigned char iwgPolicyBSha256[] = {\n    0xca, 0x3d, 0x0a, 0x99, 0xa2, 0xb9, 0x39, 0x06, 0xf7, 0xa3, 0x34, 0x24, 0x14, 0xef, 0xcf, 0xb3,\n    0xa3, 0x85, 0xd4, 0x4c, 0xd1, 0xfd, 0x45, 0x90, 0x89, 0xd1, 0x9b, 0x50, 0x71, 0xc0, 0xb7, 0xa0\n};\n\n/* High range PolicyB SHA384 (policy OR)*/\nstatic const unsigned char iwgPolicyBSha384[] = {\n    0xb2, 0x6e, 0x7d, 0x28, 0xd1, 0x1a, 0x50, 0xbc, 0x53, 0xd8, 0x82, 0xbc, 0xf5, 0xfd, 0x3a, 0x1a,\n    0x07, 0x41, 0x48, 0xbb, 0x35, 0xd3, 0xb4, 0xe4, 0xcb, 0x1c, 0x0a, 0xd9, 0xbd, 0xe4, 0x19, 0xca,\n    0xcb, 0x47, 0xba, 0x09, 0x69, 0x96, 0x46, 0x15, 0x0f, 0x9f, 0xc0, 0x00, 0xf3, 0xf8, 0x0e, 0x12,\n};\n\n/* High range PolicyB SHA512 (policy OR) */\n\nstatic const unsigned char iwgPolicyBSha512[] = {\n    0xb8, 0x22, 0x1c, 0xa6, 0x9e, 0x85, 0x50, 0xa4, 0x91, 0x4d, 0xe3, 0xfa, 0xa6, 0xa1, 0x8c, 0x07,\n    0x2c, 0xc0, 0x12, 0x08, 0x07, 0x3a, 0x92, 0x8d, 0x5d, 0x66, 0xd5, 0x9e, 0xf7, 0x9e, 0x49, 0xa4,\n    0x29, 0xc4, 0x1a, 0x6b, 0x26, 0x95, 0x71, 0xd5, 0x7e, 0xdb, 0x25, 0xfb, 0xdb, 0x18, 0x38, 0x42,\n    0x56, 0x08, 0xb4, 0x13, 0xcd, 0x61, 0x6a, 0x5f, 0x6d, 0xb5, 0xb6, 0x07, 0x1a, 0xf9, 0x9b, 0xea,\n};\n\n/* getIwgTemplate() builds a TPMT_PUBLIC template according to the IWG specification.  It handles\n   both the low and high NV index ranges.\n*/\n\nTPM_RC getIwgTemplate(TPMT_PUBLIC *tpmtPublic,\n\t\t      TPMI_RH_NV_INDEX ekCertIndex)\n{\n    TPM_RC\trc = 0;\n\n    if (ekCertIndex == EK_CERT_RSA_INDEX) {\t\t/* RSA primary key, low range */\n\tgetRsaTemplate(tpmtPublic);\n    }\n    else if (ekCertIndex == EK_CERT_EC_INDEX) {\t\t/* EC primary key, low range */\n\tgetEccTemplate(tpmtPublic);\n    }\n    else {\n\tswitch (ekCertIndex) {\n\t  case EK_CERT_RSA_2048_INDEX_H1:\t/* high range */\n\t  case EK_CERT_RSA_3072_INDEX_H6:\n\t  case EK_CERT_RSA_4096_INDEX_H7:\n\t    rc = getRsaHighTemplate(tpmtPublic, ekCertIndex);\n\t    break;\n\t  case EK_CERT_ECC_NISTP256_INDEX_H2:\n\t  case EK_CERT_ECC_NISTP384_INDEX_H3:\n\t  case EK_CERT_ECC_NISTP521_INDEX_H4:\n\t  case EK_CERT_ECC_SM2P256INDEX_H5:\n\t    rc = getEccHighTemplate(tpmtPublic, ekCertIndex);\n\t    break;\n\t  default:\n\t    printf(\"getIwgTemplate: \"\n\t\t   \"ekCertIndex %08x (asymmetric algorithm) not supported\\n\", ekCertIndex);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* RSA low range EK primary key IWG default template */\n\nvoid getRsaTemplate(TPMT_PUBLIC *tpmtPublic)\n{\n    tpmtPublic->type = TPM_ALG_RSA;\n    tpmtPublic->nameAlg = TPM_ALG_SHA256;\n    tpmtPublic->objectAttributes.val = TPMA_OBJECT_FIXEDTPM |\n\t\t\t\t       TPMA_OBJECT_FIXEDPARENT |\n\t\t\t\t       TPMA_OBJECT_SENSITIVEDATAORIGIN |\n\t\t\t\t       TPMA_OBJECT_ADMINWITHPOLICY |\n\t\t\t\t       TPMA_OBJECT_RESTRICTED |\n\t\t\t\t       TPMA_OBJECT_DECRYPT;\n    tpmtPublic->authPolicy.t.size = sizeof(iwgPolicyASha256);\n    memcpy(&tpmtPublic->authPolicy.t.buffer, iwgPolicyASha256, sizeof(iwgPolicyASha256));\n    tpmtPublic->parameters.rsaDetail.symmetric.algorithm = TPM_ALG_AES;\n    tpmtPublic->parameters.rsaDetail.symmetric.keyBits.aes = 128;\n    tpmtPublic->parameters.rsaDetail.symmetric.mode.aes = TPM_ALG_CFB;\n    tpmtPublic->parameters.rsaDetail.scheme.scheme = TPM_ALG_NULL;\n    tpmtPublic->parameters.rsaDetail.scheme.details.anySig.hashAlg = 0;\n    tpmtPublic->parameters.rsaDetail.keyBits = 2048;\n    tpmtPublic->parameters.rsaDetail.exponent = 0;\n    tpmtPublic->unique.rsa.t.size = 256;\n    memset(&tpmtPublic->unique.rsa.t.buffer, 0, 256);\n    return;\n}\n\n/* ECC low range EK primary key IWG default template */\n\nvoid getEccTemplate(TPMT_PUBLIC *tpmtPublic)\n{\n    tpmtPublic->type = TPM_ALG_ECC;\n    tpmtPublic->nameAlg = TPM_ALG_SHA256;\n    tpmtPublic->objectAttributes.val = TPMA_OBJECT_FIXEDTPM |\n\t\t\t\t       TPMA_OBJECT_FIXEDPARENT |\n\t\t\t\t       TPMA_OBJECT_SENSITIVEDATAORIGIN |\n\t\t\t\t       TPMA_OBJECT_ADMINWITHPOLICY |\n\t\t\t\t       TPMA_OBJECT_RESTRICTED |\n\t\t\t\t       TPMA_OBJECT_DECRYPT;\n    tpmtPublic->authPolicy.t.size = sizeof(iwgPolicyASha256);\n    memcpy(tpmtPublic->authPolicy.t.buffer, iwgPolicyASha256, sizeof(iwgPolicyASha256));\n    tpmtPublic->parameters.eccDetail.symmetric.algorithm = TPM_ALG_AES;\n    tpmtPublic->parameters.eccDetail.symmetric.keyBits.aes = 128;\n    tpmtPublic->parameters.eccDetail.symmetric.mode.aes = TPM_ALG_CFB;\n    tpmtPublic->parameters.eccDetail.scheme.scheme = TPM_ALG_NULL;\n    tpmtPublic->parameters.eccDetail.scheme.details.anySig.hashAlg = 0;\n    tpmtPublic->parameters.eccDetail.curveID = TPM_ECC_NIST_P256;\n    tpmtPublic->parameters.eccDetail.kdf.scheme = TPM_ALG_NULL;\n    tpmtPublic->parameters.eccDetail.kdf.details.mgf1.hashAlg = 0;\n    tpmtPublic->unique.ecc.x.t.size = 32;\t\n    memset(&tpmtPublic->unique.ecc.x.t.buffer, 0, 32);\t\n    tpmtPublic->unique.ecc.y.t.size = 32;\t\n    memset(&tpmtPublic->unique.ecc.y.t.buffer, 0, 32);\t\n    return;\n}\n\n/* RSA high range EK primary key IWG default template */\n\nTPM_RC getRsaHighTemplate(TPMT_PUBLIC *tpmtPublic,\n\t\t\t  TPMI_RH_NV_INDEX ekCertIndex)\n{\n    TPM_RC\trc = 0;\n    switch (ekCertIndex) {\n      case EK_CERT_RSA_2048_INDEX_H1:\t/* high range */\n\ttpmtPublic->nameAlg = TPM_ALG_SHA256;\n\ttpmtPublic->authPolicy.t.size = sizeof(iwgPolicyBSha256);\n\tmemcpy(&tpmtPublic->authPolicy.t.buffer, iwgPolicyBSha256, sizeof(iwgPolicyBSha256));\n\ttpmtPublic->parameters.rsaDetail.symmetric.keyBits.aes = 128;\n\ttpmtPublic->parameters.rsaDetail.keyBits = 2048;\n\tbreak;\n      case EK_CERT_RSA_3072_INDEX_H6:\n\ttpmtPublic->nameAlg = TPM_ALG_SHA384;\n\ttpmtPublic->authPolicy.t.size = sizeof(iwgPolicyBSha384);\n\tmemcpy(&tpmtPublic->authPolicy.t.buffer, iwgPolicyBSha384, sizeof(iwgPolicyBSha384));\n\ttpmtPublic->parameters.rsaDetail.symmetric.keyBits.aes = 256;\n\ttpmtPublic->parameters.rsaDetail.keyBits = 3072;\n\tbreak;\n      case EK_CERT_RSA_4096_INDEX_H7:\n\ttpmtPublic->nameAlg = TPM_ALG_SHA384;\n\ttpmtPublic->authPolicy.t.size = sizeof(iwgPolicyBSha384);\n\tmemcpy(&tpmtPublic->authPolicy.t.buffer, iwgPolicyBSha384, sizeof(iwgPolicyBSha384));\n\ttpmtPublic->parameters.rsaDetail.symmetric.keyBits.aes = 256;\n\ttpmtPublic->parameters.rsaDetail.keyBits = 4096;\n\tbreak;\n      default:\n\tprintf(\"getRsaHighTemplate: \"\n\t       \"ekCertIndex %08x (asymmetric algorithm) not supported\\n\", ekCertIndex);\n\trc = TSS_RC_BAD_PROPERTY_VALUE;\n    }\n    tpmtPublic->type = TPM_ALG_RSA;\n    tpmtPublic->objectAttributes.val = TPMA_OBJECT_FIXEDTPM |\n\t\t\t\t       TPMA_OBJECT_FIXEDPARENT |\n\t\t\t\t       TPMA_OBJECT_SENSITIVEDATAORIGIN |\n\t\t\t\t       TPMA_OBJECT_USERWITHAUTH |\n\t\t\t\t       TPMA_OBJECT_ADMINWITHPOLICY |\n\t\t\t\t       TPMA_OBJECT_RESTRICTED |\n\t\t\t\t       TPMA_OBJECT_DECRYPT;\n    tpmtPublic->parameters.rsaDetail.symmetric.algorithm = TPM_ALG_AES;\n    tpmtPublic->parameters.rsaDetail.symmetric.mode.aes = TPM_ALG_CFB;\n    tpmtPublic->parameters.rsaDetail.scheme.scheme = TPM_ALG_NULL;\n    tpmtPublic->parameters.rsaDetail.scheme.details.anySig.hashAlg = 0;\n    tpmtPublic->parameters.rsaDetail.exponent = 0;\n    tpmtPublic->unique.rsa.t.size = 0;\n    return rc;\n}\n\n/* ECC low range EK primary key IWG default template */\n\nTPM_RC getEccHighTemplate(TPMT_PUBLIC *tpmtPublic,\n\t\t\t  TPMI_RH_NV_INDEX ekCertIndex)\n{\n    TPM_RC\trc = 0;\n    switch (ekCertIndex) {\n      case EK_CERT_ECC_NISTP256_INDEX_H2:\n\ttpmtPublic->nameAlg = TPM_ALG_SHA256;\n\ttpmtPublic->authPolicy.t.size = sizeof(iwgPolicyBSha256);\n\tmemcpy(tpmtPublic->authPolicy.t.buffer, iwgPolicyBSha256, sizeof(iwgPolicyBSha256));\n\ttpmtPublic->parameters.eccDetail.symmetric.keyBits.aes = 128;\n\ttpmtPublic->parameters.eccDetail.curveID = TPM_ECC_NIST_P256;\n\tbreak;\n      case EK_CERT_ECC_NISTP384_INDEX_H3:\n\ttpmtPublic->nameAlg = TPM_ALG_SHA384;\n\ttpmtPublic->authPolicy.t.size = sizeof(iwgPolicyBSha384);\n\tmemcpy(tpmtPublic->authPolicy.t.buffer, iwgPolicyBSha384, sizeof(iwgPolicyBSha384));\n\ttpmtPublic->parameters.eccDetail.symmetric.keyBits.aes = 256;\n\ttpmtPublic->parameters.eccDetail.curveID = TPM_ECC_NIST_P384;\n\tbreak;\n      case EK_CERT_ECC_NISTP521_INDEX_H4:\n\ttpmtPublic->nameAlg = TPM_ALG_SHA512;\n\ttpmtPublic->authPolicy.t.size = sizeof(iwgPolicyBSha512);\n\tmemcpy(tpmtPublic->authPolicy.t.buffer, iwgPolicyBSha512, sizeof(iwgPolicyBSha512));\n\ttpmtPublic->parameters.eccDetail.symmetric.keyBits.aes = 256;\n\ttpmtPublic->parameters.eccDetail.curveID = TPM_ECC_NIST_P521;\n\tbreak;\n      case EK_CERT_ECC_SM2P256INDEX_H5:\n      default:\n\tprintf(\"getEccHighTemplate: \"\n\t       \"ekCertIndex %08x (asymmetric algorithm) not supported\\n\", ekCertIndex);\n\trc = TSS_RC_BAD_PROPERTY_VALUE;\n    }\n    tpmtPublic->type = TPM_ALG_ECC;\n    tpmtPublic->objectAttributes.val = TPMA_OBJECT_FIXEDTPM |\n\t\t\t\t       TPMA_OBJECT_FIXEDPARENT |\n\t\t\t\t       TPMA_OBJECT_SENSITIVEDATAORIGIN |\n\t\t\t\t       TPMA_OBJECT_USERWITHAUTH |\n\t\t\t\t       TPMA_OBJECT_ADMINWITHPOLICY |\n\t\t\t\t       TPMA_OBJECT_RESTRICTED |\n\t\t\t\t       TPMA_OBJECT_DECRYPT;\n    tpmtPublic->parameters.eccDetail.symmetric.algorithm = TPM_ALG_AES;\n    tpmtPublic->parameters.eccDetail.symmetric.mode.aes = TPM_ALG_CFB;\n    tpmtPublic->parameters.eccDetail.scheme.scheme = TPM_ALG_NULL;\n    tpmtPublic->parameters.eccDetail.scheme.details.anySig.hashAlg = 0;\n    tpmtPublic->parameters.eccDetail.kdf.scheme = TPM_ALG_NULL;\n    tpmtPublic->parameters.eccDetail.kdf.details.mgf1.hashAlg = 0;\n    tpmtPublic->unique.ecc.x.t.size = 0;\n    tpmtPublic->unique.ecc.y.t.size = 0;\n    return rc;\n}\n\n/* getIndexX509Certificate() reads the X509 certificate from the nvIndex and converts the DER\n   (binary) to OpenSSL X509 format\n\n*/\n\nTPM_RC getIndexX509Certificate(TSS_CONTEXT *tssContext,\n\t\t\t       void **certificate,\t\t/* freed by caller */\n\t\t\t       TPMI_RH_NV_INDEX nvIndex)\n{\n    TPM_RC\t\t\trc = 0;\n    unsigned char \t\t*certData = NULL; \t\t/* freed @1 */\n    uint16_t \t\t\tcertSize;\n\n    /* read the certificate from NV to a DER stream */\n    if (rc == 0) {\n\trc = getIndexContents(tssContext,\n\t\t\t      &certData,\n\t\t\t      &certSize,\n\t\t\t      nvIndex);\n    }\n    /* unmarshal the DER stream to an OpenSSL X509 structure */\n    if (rc == 0) {\n\tunsigned char \t\t*tmpData = NULL; \n\ttmpData = certData;\t\t\t/* tmp pointer because d2i moves the pointer */\n\t*certificate = d2i_X509(NULL,\t\t\t/* freed by caller */\n\t\t\t\t (const unsigned char **)&tmpData, certSize);\n\tif (*certificate == NULL) {\n\t    printf(\"getIndexX509Certificate: Could not parse X509 certificate\\n\");\n\t    rc = TPM_RC_INTEGRITY;\n\t}\n    }\n    free(certData);\t\t\t/* @1 */\n    return rc;\n}\n\n#endif\t/* TPM20 */\n\n#ifndef TPM_TSS_NOFILE\n#ifndef TPM_TSS_NORSA\n\n/* getPubkeyFromDerCertFile() gets an OpenSSL RSA public key token from a DER format X509\n   certificate stored in a file.\n\n   Returns both the OpenSSL X509 certificate token and RSA public key token.\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nuint32_t getPubkeyFromDerCertFile(void **rsaPkey,\t/* freed by caller */\n\t\t\t\t  X509 **x509,\n\t\t\t\t  const char *derCertificateFileName)\n{\n    uint32_t rc = 0;\n    FILE *fp = NULL;\n\n    /* open the file */\n    if (rc == 0) {\n\tfp = fopen(derCertificateFileName, \"rb\");\n\tif (fp == NULL) {\n\t    printf(\"getPubkeyFromDerCertFile: Error opening %s\\n\", derCertificateFileName);\n\t    rc = TSS_RC_FILE_OPEN;\n\t}\n    }\n    /* read the file and convert the X509 DER to OpenSSL format */\n    if (rc == 0) {\n\t*x509 = d2i_X509_fp(fp, NULL);\n\tif (*x509 == NULL) {\n\t    printf(\"getPubkeyFromDerCertFile: Error converting %s\\n\", derCertificateFileName);\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* extract the OpenSSL format public key from the X509 token */\n    if (rc == 0) {\n\t/* For Openssl < 3, rsaKey is an RSA structure.\n\t   For Openssl 3, rsaKey is an EVP_PKEY. */\n\trc = getPubKeyFromX509Cert(rsaPkey, *x509);\t/* freed by caller */\n    }\n    /* for debug, print the X509 certificate */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) X509_print_fp(stdout, *x509);\n    }\n    if (fp != NULL) {\n\tfclose(fp);\n    }\n    return rc;\n}\n\n/* getPubkeyFromDerCertFile3() gets an OpenSSL EVP_PKEY public key token from a DER format X509\n   certificate stored in a file.\n\n   Returns both the OpenSSL X509 certificate token and RSA public key token.\n\n   Differs from getPubkeyFromDerCertFile(), where the public key is version dependent.\n*/\n\nuint32_t getPubkeyFromDerCertFile3(EVP_PKEY **evpPkey,\t/* freed by caller */\n\t\t\t\t   X509 **x509,\t \t/* freed by caller */\n\t\t\t\t   const char *derCertificateFileName)\n{\n    uint32_t rc = 0;\n    FILE *fp = NULL;\n\n    /* open the file */\n    if (rc == 0) {\n\tfp = fopen(derCertificateFileName, \"rb\");\n\tif (fp == NULL) {\n\t    printf(\"getPubkeyFromDerCertFile3: Error opening %s\\n\", derCertificateFileName);\n\t    rc = TSS_RC_FILE_OPEN;\n\t}\n    }\n    /* read the file and convert the X509 DER to OpenSSL format */\n    if (rc == 0) {\n\t*x509 = d2i_X509_fp(fp, NULL);\n\tif (*x509 == NULL) {\n\t    printf(\"getPubkeyFromDerCertFile3: Error converting %s\\n\", derCertificateFileName);\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* extract the OpenSSL format public key from the X509 token */\n    if (rc == 0) {\n\t*evpPkey = X509_get_pubkey(*x509);\t/* freed by caller */\n\tif (*evpPkey == NULL) {\n\t    printf(\"getPubkeyFromDerCertFile3: X509_get_pubkey failed\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* for debug, print the X509 certificate */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) X509_print_fp(stdout, *x509);\n    }\n    if (fp != NULL) {\n\tfclose(fp);\n    }\n    return rc;\n}\n\n#endif /* TPM_TSS_NORSA */\n#endif /* TPM_TSS_NOFILE */\n\n#ifndef TPM_TSS_NORSA\n\n/* getPubKeyFromX509Cert() gets an OpenSSL RSA public key token from an OpenSSL X509 certificate\n   token.\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nuint32_t getPubKeyFromX509Cert(void **rsaPkey,\n\t\t\t       X509 *x509)\n{\n    uint32_t rc = 0;\n    EVP_PKEY *evpPkey = NULL;\n\n    if (rc == 0) {\n\tevpPkey = X509_get_pubkey(x509);\t/* freed @1 */\n\tif (evpPkey == NULL) {\n\t    printf(\"getPubKeyFromX509Cert: X509_get_pubkey failed\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n\t*rsaPkey = EVP_PKEY_get1_RSA(evpPkey);\n\tif (*rsaPkey == NULL) {\n\t    printf(\"getPubKeyFromX509Cert: EVP_PKEY_get1_RSA failed\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (evpPkey != NULL) {\n\tEVP_PKEY_free(evpPkey);\t\t/* @1 */\n    }\n#else\n    *rsaPkey = evpPkey;\n#endif\n    return rc;\n}\n\n#endif /* TPM_TSS_NORSA */\n\n#ifndef TPM_TSS_NOFILE\n\n/* getRootCertificateFilenames() reads listFilename, which is a list of filenames.  The intent is\n   that the filenames are a list of EK TPM vendor root certificates in PEM format.\n\n   It accepts up to MAX_ROOTS filenames, which is a #define.\n\n*/\n\nTPM_RC getRootCertificateFilenames(char *rootFilename[],\n\t\t\t\t   unsigned int *rootFileCount,\n\t\t\t\t   const char *listFilename,\n\t\t\t\t   int print)\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tdone = 0;\n    FILE\t\t*listFile = NULL;\t\t/* closed @1 */\n\n    *rootFileCount = 0;\n\n    if (rc == 0) {\n\tlistFile = fopen(listFilename, \"rb\");\t\t/* closed @1 */\n\tif (listFile == NULL) {\n\t    printf(\"getRootCertificateFilenames: Error opening list file %s\\n\",\n\t\t   listFilename);  \n\t    rc = TSS_RC_FILE_OPEN;\n\t}\n    }\n    while ((rc == 0) && !done && (*rootFileCount < MAX_ROOTS)) {\n\tsize_t rootFilenameLength;\n\tif (rc == 0) {\n\t    rootFilename[*rootFileCount] = malloc(PATH_MAX);\n\t    if (rootFilename[*rootFileCount] == NULL) {\n\t\tprintf(\"getRootCertificateFilenames: Error allocating memory\\n\");\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    char *tmpptr = fgets(rootFilename[*rootFileCount], PATH_MAX-1, listFile);\n\t    if (tmpptr == NULL) {\t/* end of file */\n\t\tfree(rootFilename[*rootFileCount]);\t/* free malloced but unused entry */\n\t\tdone = 1;\n\t    }\n\t}\n\tif ((rc == 0) && !done) {\n\t    rootFilenameLength = strlen(rootFilename[*rootFileCount]);\n\t    if (rootFilename[*rootFileCount][rootFilenameLength-1] != '\\n') {\n\t\tprintf(\"getRootCertificateFilenames: filename %s too long\\n\",\n\t\t       rootFilename[*rootFileCount]);\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t\tfree(rootFilename[*rootFileCount]);\t/* free malloced but bad entry */\n\t\tdone = 1;\n\t    }\n\t}\n\tif ((rc == 0) && !done) {\n\t    rootFilename[*rootFileCount][rootFilenameLength-1] = '\\0';\t/* remove newline */\n\t    if (print) printf(\"getRootCertificateFilenames: Root file name %u\\n%s\\n\",\n\t\t\t      *rootFileCount, rootFilename[*rootFileCount]);\n\t    (*rootFileCount)++;\n\t}\n    }\n    if (listFile != NULL) {\n\tfclose(listFile);\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\n\n#ifndef TPM_TSS_NOFILE\n\n/* getCaStore() creates an OpenSSL X509_STORE, populated by the root certificates in the\n   rootFilename array.  Depending on the vendor, some certificates may be intermediate certificates.\n   OpenSSL handles this internally by walking the chain back to the root.\n\n   The caCert array is returned because it must be freed after the caStore is freed\n\n   NOTE:  There is no TPM interaction.\n*/ \n\nTPM_RC getCaStore(X509_STORE **caStore,\t\t/* freed by caller */\n\t\t  X509 \t*caCert[],\t\t/* freed by caller */\n\t\t  const char *rootFilename[],\n\t\t  unsigned int rootFileCount)\n{\n    TPM_RC\t\t\trc = 0;\n    FILE \t\t\t*caCertFile = NULL;\t\t/* closed @1 */\n    unsigned int \t\ti;\n\n    if (rc == 0) {\n\t*caStore  = X509_STORE_new();\n\tif (*caStore == NULL) {\n\t    printf(\"getCaStore: X509_store_new failed\\n\");  \n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    for (i = 0 ; (i < rootFileCount) && (rc == 0) ; i++) {\n\t/* read a root certificate from the file */\n\tcaCertFile = fopen(rootFilename[i], \"rb\");\t/* closed @1 */\n\tif (caCertFile == NULL) {\n\t    printf(\"getCaStore: Error opening CA root certificate file %s\\n\",\n\t\t   rootFilename[i]);  \n\t    printf(\"getCaStore: Check the fully rooted path\\n\");\n\t    rc = TSS_RC_FILE_OPEN;\n\t}\n\t/* convert the root certificate from PEM to X509 */\n\tif (rc == 0) {\n\t    caCert[i] = PEM_read_X509(caCertFile, NULL, NULL, NULL);\t/* freed by caller */\n\t    if (caCert[i] == NULL) {\n\t\tprintf(\"getCaStore: Error reading CA root certificate file %s\\n\",\n\t\t       rootFilename[i]);  \n\t\trc = TSS_RC_FILE_READ;\n\t    } \n\t}\n\tif ((rc == 0) && tssUtilsVerbose) {\n\t    X509_NAME *x509Name;\n\t    char *subject = NULL;\n\t    x509Name = X509_get_subject_name(caCert[i]);\n\t    subject = X509_NAME_oneline(x509Name, NULL, 0);\n\t    printf(\"getCaStore: subject %u: %s\\n\", i, subject);\n\t    OPENSSL_free(subject);\n\t}\n\n\t/* add the CA X509 certificate to the certificate store */\n\tif (rc == 0) {\n\t    X509_STORE_add_cert(*caStore, caCert[i]);    \n\t}\n\tif (caCertFile != NULL) {\n\t    fclose(caCertFile);\t\t/* @1 */\n\t    caCertFile = NULL;\n\t}\n    }\n    return rc;\n}\n\n#endif\n\n#ifndef TPM_TSS_NOFILE\n\n/* verifyCertificate() verifies a certificate (typically an EK certificate against the root CA\n   certificate (typically the TPM vendor CA certificate chain)\n\n   The 'rootFileCount' root certificates are stored in the files whose paths are in the array\n   'rootFilename'\n\n*/\n\nTPM_RC verifyCertificate(void *x509Certificate,\n\t\t\t const char *rootFilename[],\n\t\t\t unsigned int rootFileCount,\n\t\t\t int print)\n{\n    TPM_RC\t\t\trc = 0;\n    unsigned int\t\ti;\n    X509_STORE \t\t\t*caStore = NULL;\t/* freed @1 */\n    X509 \t\t\t*caCert[MAX_ROOTS];\t/* freed @2 */\n    X509_STORE_CTX \t\t*verifyCtx = NULL;\t/* freed @3 */\n\n    for (i = 0 ; i < rootFileCount ; i++) {\n\tcaCert[i] = NULL;    \t\t\t\t/* for free @2 */\n    }\n    /* get the root CA certificate chain */\n    if (rc == 0) {\n\trc = getCaStore(&caStore,\t\t\t/* freed @1 */\n\t\t\tcaCert,\t\t\t\t/* freed @2 */\n\t\t\trootFilename,\n\t\t\trootFileCount);\n    }\n    /* create the certificate verify context */\n    if (rc == 0) {\n\tverifyCtx = X509_STORE_CTX_new();\t\t/* freed @3 */\n\tif (verifyCtx == NULL) {\n\t    printf(\"verifyCertificate: X509_STORE_CTX_new failed\\n\");  \n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* add the root certificate store and EK certificate to be verified to the verify context */\n    if (rc == 0) {\n\tint irc = X509_STORE_CTX_init(verifyCtx,\n\t\t\t\t      caStore,\t\t/* trusted certificates */\n\t\t\t\t      x509Certificate,\t/* end entity certificate */\n\t\t\t\t      NULL);\t\t/* untrusted (intermediate) certificates */\n\tif (irc != 1) {\n\t    printf(\"verifyCertificate: \"\n\t\t   \"Error in X509_STORE_CTX_init initializing verify context\\n\");  \n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\t    \n    }\n    /* walk the certificate chain */\n    if (rc == 0) {\n\tint irc = X509_verify_cert(verifyCtx);\n\tif (irc != 1) {\n\t    printf(\"verifyCertificate: Error in X509_verify_cert verifying certificate\\n\");  \n\t    rc = TSS_RC_RSA_SIGNATURE;\n\t}\n\telse {\n\t    if (print) printf(\"EK certificate verified against the root\\n\");\n\t}\n    }\n    if (caStore != NULL) {\n\tX509_STORE_free(caStore);\t/* @1 */\n    }\n    for (i = 0 ; i < rootFileCount ; i++) {\n\tX509_free(caCert[i]);\t   \t/* @2 */\n    }\n    if (verifyCtx != NULL) {\n\tX509_STORE_CTX_free(verifyCtx);\t/* @3 */\n    }\n    return rc;\n}\n\n/* verifyKeyUsage() validates the key usage for an EK.\n\n   If the EK has the decrypt attribute set, the keyEncipherment bit MUST be set for an RSA EK\n   certificate; the keyAgreement bit MUST be set for an ECC EK certificate.\n*/\n\nTPM_RC verifyKeyUsage(X509 *ekX509Certificate,\t\t/* X509 certificate */\n\t\t      int pkeyType,\t\t\t/* RSA or ECC */\n\t\t      int print)\n{\n    TPM_RC\t\trc = 0;\n    ASN1_BIT_STRING \t*keyUsage = NULL;\n    uint8_t \t\tbitmap;\n    int \t\tkeyAgreement;\t\t/* boolean flags */\n    int \t\tkeyEncipherment;\n    \n    if (rc == 0) {\n\tkeyUsage = X509_get_ext_d2i(ekX509Certificate, NID_key_usage,\t/* freed @1 */\n\t\t\t\t    NULL, NULL);\n\tif (keyUsage == NULL) {\n\t    printf(\"verifyKeyUsage: Cannot find key usage\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\tif (keyUsage->length == 0) {\n\t    printf(\"verifyKeyUsage: Key usage length 0 bytes\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\tbitmap = keyUsage->data[0];\n\tkeyEncipherment = bitmap & (1<<5);\t\t/* bit 2 little endian */\n\tkeyAgreement = bitmap & (1<<3);\t\t\t/* bit 4 little endian */\n\tif (keyEncipherment) {\t\t/* bit 2 little endian */\n\t    if (print) printf(\"verifyKeyUsage: Key Encipherment\\n\");\n\t}\n\tif (keyAgreement) {\t\t/* bit 4 little endian */\n\t    if (print) printf(\"verifyKeyUsage: Key Agreement\\n\");\n\t}\n\tif (pkeyType == EVP_PKEY_RSA) {\n\t    if (!keyEncipherment) {\n\t\tprintf(\"ERROR: verifyKeyUsage: RSA Key usage %02x not Key Encipherment\\n\",\n\t\t       bitmap);\n\t\trc = TSS_RC_X509_ERROR;\n\t    }\n\t}\n\telse if (pkeyType ==  EVP_PKEY_EC) {\n\t    /* ECC should be key agreement, but some HW TPMs use key encipherment */\n\t    if (!keyEncipherment && !keyAgreement) {\n\t\tprintf(\"ERROR: verifyKeyUsage: ECC Key usage %02x not \"\n\t\t       \"Key agreement or key encipherment\\n\",\n\t\t       bitmap);\n\t\trc = TSS_RC_X509_ERROR;\n\t    }\n\t}\n\telse {\n\t    printf(\"ERROR: verifyKeyUsage: Public key is not RSA or ECC\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (keyUsage != NULL) {\n\tASN1_BIT_STRING_free(keyUsage);\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOFILE */\n\n#ifdef TPM_TPM20\n\n/* processEKNonce()reads the EK nonce from NV and returns the contents and size */\n   \nTPM_RC processEKNonce(TSS_CONTEXT *tssContext,\n\t\t      unsigned char **nonce, \t/* freed by caller */\n\t\t      uint16_t *nonceSize,\n\t\t      TPMI_RH_NV_INDEX ekNonceIndex,\n\t\t      int print)\n{\n    TPM_RC\t\t\trc = 0;\n\n    if (ekNonceIndex != 0) {\t/* the high range does not have a nonce, so skip this step */\n\tif (rc == 0) {\n\t    rc = getIndexContents(tssContext,\n\t\t\t\t  nonce,\n\t\t\t\t  nonceSize,\n\t\t\t\t  ekNonceIndex);\n\t}\n\t/* optional tracing */\n\tif (rc == 0) {\n\t    if (print) TSS_PrintAll(\"EK Nonce: \", *nonce, *nonceSize);\n\t}\n    }\n    return rc;\n}\n\n/* processEKTemplate() reads the EK template from NV and returns the unmarshaled TPMT_PUBLIC */\n\nTPM_RC processEKTemplate(TSS_CONTEXT *tssContext,\n\t\t\t TPMT_PUBLIC *tpmtPublic,\n\t\t\t TPMI_RH_NV_INDEX ekTemplateIndex,\n\t\t\t int print)\n{\n    TPM_RC\t\t\trc = 0;\n    uint16_t \t\t\tdataSize;\n    unsigned char \t\t*data = NULL; \t\t/* freed @1 */\n    uint32_t \t\t\ttmpDataSize;\n    unsigned char \t\t*tmpData = NULL; \n\n    if (rc == 0) {\n\trc = getIndexContents(tssContext,\n\t\t\t      &data,\n\t\t\t      &dataSize,\n\t\t\t      ekTemplateIndex);\n    }\n    /* unmarshal the data stream */\n    if (rc == 0) {\n\ttmpData = data;\t\t/* temps because unmarshal moves the pointers */\n\ttmpDataSize = dataSize;\n\trc = TSS_TPMT_PUBLIC_Unmarshalu(tpmtPublic, &tmpData, &tmpDataSize, YES);\n    }\n    /* optional tracing */\n    if (rc == 0) {\n\tif (print) TSS_TPMT_PUBLIC_Print(tpmtPublic, 0);\n    }\n    free(data);   \t\t\t/* @1 */\n    return rc;\n}\n\n/* processEKCertificate() reads the EK certificate from NV and returns an X509 certificate\n   structure.  It also extracts and returns the public modulus.\n\n   The return is void because the structure is opaque to the caller.  This accommodates other crypto\n   libraries.\n\n   ekCertificate is an X509 structure.\n*/\n    \nTPM_RC processEKCertificate(TSS_CONTEXT *tssContext,\n\t\t\t    void **ekCertificate,\t/* freed by caller */\n\t\t\t    uint8_t **modulusBin,\t/* freed by caller */\n\t\t\t    int *modulusBytes,\n\t\t\t    TPMI_RH_NV_INDEX ekCertIndex,\n\t\t\t    int print)\n{\n    TPM_RC\t\t\trc = 0;\n\n    /* read the EK X509 certificate from NV and convert the DER (binary) to OpenSSL X509 format */\n    if (rc == 0) {\n\trc = getIndexX509Certificate(tssContext,\n\t\t\t\t     ekCertificate,\t/* freed by caller */\n\t\t\t\t     ekCertIndex);\n\tif (rc != 0) {\n\t    printf(\"No EK certificate for EK certificate index %08x\\n\", ekCertIndex);\n\t}\n    }\n    /* extract the public modulus from the X509 structure */\n    if (rc == 0) {\n\trc = convertCertificatePubKey(modulusBin,\t/* freed by caller */\n\t\t\t\t      modulusBytes,\n\t\t\t\t      *ekCertificate,\n\t\t\t\t      ekCertIndex,\n\t\t\t\t      print);\n    }\n    return rc;\n}\n\n#endif\t/* TPM20 */\n\n/* convertX509ToDer() serializes the openSSL X509 structure to a DER certificate\n\n */\n\nTPM_RC convertX509ToDer(uint32_t *certLength,\n\t\t\tunsigned char **certificate,\t/* output, freed by caller */\n\t\t\tX509 *x509Certificate)\t\t/* input */\n{\n    TPM_RC \t\trc = 0;\t\t/* general return code */\n    int\t\t\tirc;\n\n    /* sanity check for memory leak */\n    if (rc == 0) {\n\tif (*certificate != NULL) {\n\t    printf(\"ERROR: convertX509ToDer: Error, certificate not NULL at entry\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\t\n    }\n    if (rc == 0) {\n\tirc = i2d_X509(x509Certificate, NULL);\n\tif (irc < 0) {\n\t    printf(\"ERROR: convertX509ToDer: Error in certificate serialization i2d_X509()\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n\telse {\n\t    *certLength = irc; \n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Malloc(certificate, *certLength);\n    }\n    /* convert the X509 structure to binary (internal to DER format) */\n    if (rc == 0) {\n\tunsigned char *tmpptr = *certificate;\n\tif (tssUtilsVerbose) printf(\"convertX509ToDer: Serializing certificate\\n\");\n\tirc = i2d_X509(x509Certificate, &tmpptr);\n\tif (irc < 0) {\n\t    printf(\"ERROR: convertX509ToDer: Error in certificate serialization i2d_X509()\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    return rc;\n}\n\n#ifndef TPM_TSS_NOECC\n\n/* convertX509ToEc extracts the public key from an X509 structure to an openssl EC_KEY structure\n\n */\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\nTPM_RC convertX509ToEc(EC_KEY **ecKey,\t/* freed by caller */\n\t\t       X509 *x509)\n{\n    TPM_RC rc = 0;\n    EVP_PKEY *evpPkey = NULL;\n\n    if (tssUtilsVerbose) printf(\"convertX509ToEc: Entry\\n\\n\");\n    if (rc == 0) {\n\tevpPkey = X509_get_pubkey(x509);\t/* freed @1 */\n\tif (evpPkey == NULL) {\n\t    printf(\"ERROR: convertX509ToEc: X509_get_pubkey failed\\n\");  \n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\t*ecKey = EVP_PKEY_get1_EC_KEY(evpPkey);\n\tif (*ecKey == NULL) {\n\t    printf(\"ERROR: convertX509ToEc: EVP_PKEY_get1_EC_KEY failed\\n\");  \n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    if (evpPkey != NULL) {\n\tEVP_PKEY_free(evpPkey);\t\t/* @1 */\n    }\n    return rc;\n}\n#endif\n\n#endif\t/* TPM_TSS_NOECC */\n\n/* convertCertificatePubKey() returns the public modulus from an openssl X509 certificate\n   structure.  ekCertIndex determines whether the algorithm is RSA or ECC.\n\n   If print is true, prints the EK certificate\n\n   The ekCertificate return is void because the structure is opaque to the caller.  This\n   accommodates other crypto libraries.\n\n   ekCertificate is an X509 structure.\n*/\n\nTPM_RC convertCertificatePubKey(uint8_t **modulusBin,\t/* freed by caller */\n\t\t\t\tint *modulusBytes,\n\t\t\t\tvoid *ekCertificate,\n\t\t\t\tTPMI_RH_NV_INDEX ekCertIndex,\n\t\t\t\tint print)\n{\n    TPM_RC\t\t\trc = 0;\n    EVP_PKEY \t\t\t*pkey = NULL;\n    int \t\t\tpkeyType;\t/* RSA or EC */\n    \n    /* use openssl to print the X509 certificate */\n#ifndef TPM_TSS_NOFILE\t\t/* stdout is a file descriptor */\n    if (rc == 0) {\n\tif (print) X509_print_fp(stdout, ekCertificate);\n    }\n#endif\n    /* extract the public key */\n    if (rc == 0) {\n\tpkey = X509_get_pubkey(ekCertificate);\t\t/* freed @2 */\n\tif (pkey == NULL) {\n#ifdef TPM_TPM12\n\t    if (tssUtilsVerbose) printf(\"convertCertificatePubKey: \"\n\t\t\t\t\"Could not extract public key from X509 certificate, \"\n\t\t\t\t\"may be TPM 1.2\\n\");\n\t    /* if the conversion failed, this may be a TPM 1.2 certificate with a non-standard TCG\n\t       algorithm.  Try a different method to get the public modulus. */\n\t    rc = convertCertificatePubKey12(modulusBin,\t/* freed by caller */\n\t\t\t\t\t    modulusBytes,\n\t\t\t\t\t    ekCertificate);\n#endif\t/* TPM_TPM12 */\n\t    printf(\"convertCertificatePubKey: Could not extract X509_PUBKEY public key \"\n\t\t   \"from X509 certificate\\n\");\n\t    rc =  TPM_RC_INTEGRITY;\n\t}\n\telse {\n\t    if (rc == 0) {\n\t\tpkeyType = getRsaPubkeyAlgorithm(pkey);\n\t    }\n\t    switch (ekCertIndex) {\n#ifndef TPM_TSS_NORSA\n\t      case EK_CERT_RSA_INDEX:\t\t/* low range */\n\t      case EK_CERT_RSA_2048_INDEX_H1:\t/* high range */\n\t      case EK_CERT_RSA_3072_INDEX_H6:\n\t      case EK_CERT_RSA_4096_INDEX_H7:\n\t\t  {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t      RSA *rsaKey = NULL;\n#else\n\t\t      EVP_PKEY *rsaKey = NULL;\n#endif\n\t\t      /* check that the public key algorithm matches the ekCertIndex algorithm */\n\t\t      if (rc == 0) {\n\t\t\t  if (pkeyType != EVP_PKEY_RSA) {\n\t\t\t      printf(\"convertCertificatePubKey: \"\n\t\t\t\t     \"Public key from X509 certificate is not RSA\\n\");\n\t\t\t      rc = TPM_RC_INTEGRITY;\n\t\t\t  }\n\t\t      }\n\t\t      /* convert the public key to OpenSSL structure */\n\t\t      if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t\t  rsaKey = EVP_PKEY_get1_RSA(pkey);\t\t/* freed @3 */\n\t\t\t  if (rsaKey == NULL) {\n\t\t\t      printf(\"convertCertificatePubKey: Could not extract RSA public key \"\n\t\t\t\t     \"from X509 certificate\\n\");\n\t\t\t      rc = TPM_RC_INTEGRITY;\n\t\t\t  }\n#else\t\t/* use the EVP_PKEY directly */\n\t\t\t  rsaKey = pkey;\n#endif\n\t\t      }\n\t\t      if (rc == 0) {\n\t\t\t  rc = convertRsaKeyToPublicKeyBin(modulusBytes,\n\t\t\t\t\t\t\t   modulusBin,\t/* freed by caller */\n\t\t\t\t\t\t\t   rsaKey);\n\t\t      }\n\t\t      if (rc == 0) {\n\t\t\t  if (print) TSS_PrintAll(\"Certificate public key:\",\n\t\t\t\t\t\t  *modulusBin, *modulusBytes);\n\t\t      }    \n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t      RSA_free(rsaKey);   \t\t/* @3 */\n#endif\n\t\t  }\n\t\t  break;\n#endif /* TPM_TSS_NORSA */\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\t      case EK_CERT_EC_INDEX:\n\t      case EK_CERT_ECC_NISTP256_INDEX_H2:\n\t      case EK_CERT_ECC_NISTP384_INDEX_H3:\n\t      case EK_CERT_ECC_NISTP521_INDEX_H4:\n\t      case EK_CERT_ECC_SM2P256INDEX_H5:\n\t\t  {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t      EC_KEY *ecKey = NULL;\n#else\n\t\t      EVP_PKEY *ecKey = NULL;\n#endif\n\t\t      /* check that the public key algorithm matches the ekCertIndex algorithm */\n\t\t      if (rc == 0) {\n\t\t\t  if (pkeyType != EVP_PKEY_EC) {\n\t\t\t      printf(\"convertCertificatePubKey: \"\n\t\t\t\t     \"Public key from X509 certificate is not EC\\n\");\n\t\t\t      rc = TPM_RC_INTEGRITY;\n\t\t\t  }\n\t\t      }\n\t\t      /* convert the public key to OpenSSL structure */\n\t\t      if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t\t  ecKey = EVP_PKEY_get1_EC_KEY(pkey);\t\t/* freed @3 */\n\t\t\t  if (ecKey == NULL) {\n\t\t\t      printf(\"convertCertificatePubKey: Could not extract EC public key \"\n\t\t\t\t     \"from X509 certificate\\n\");\n\t\t\t      rc = TPM_RC_INTEGRITY;\n\t\t\t  }\n#else\t\t/* use the EVP_PKEY directly */\n\t\t\t  ecKey = pkey;\n#endif\n\t\t      }\n\t\t      if (rc == 0) {\n\t\t\t  rc = convertEcKeyToPublicKeyBin(modulusBytes,\n\t\t\t\t\t\t\t  modulusBin,\t/* freed by caller */\n\t\t\t\t\t\t\t  ecKey);\n\t\t      }\n\t\t      if (rc == 0) {\n\t\t\t  if (print) TSS_PrintAll(\"Certificate public key:\",\n\t\t\t\t\t\t  *modulusBin, *modulusBytes);\n\t\t      }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\t\t      EC_KEY_free(ecKey);   \t\t/* @3 */\n#endif\n\t\t  }\n\t\t  break;\n#endif\t/* TPM_TSS_NOECC */\n#endif  /* TPM_TPM20 */\n\t      default:\n\t\tprintf(\"convertCertificatePubKey: \"\n\t\t       \"ekCertIndex %08x (asymmetric algorithm) not supported\\n\", ekCertIndex);\n\t\trc = TSS_RC_BAD_PROPERTY_VALUE;\n\t\tbreak;\n\t    }\n\t}\n\tEVP_PKEY_free(pkey);   \t\t/* @2 */\n    }\n    return rc;\n}\n\n#ifdef TPM_TPM12\n\nTPM_RC convertCertificatePubKey12(uint8_t **modulusBin,\t/* freed by caller */\n\t\t\t\t  int *modulusBytes,\n\t\t\t\t  X509 *ekCertificate)\n{\n    TPM_RC\t\trc = 0;\n#ifndef TPM_TSS_NORSA\n    int\t\t\tirc;\n    X509_PUBKEY \t*pubkey = NULL;\n    ASN1_OBJECT \t*ppkalg = NULL;\t\t\t/* ignore OID */\n    const unsigned char *pk = NULL;\t\t\t/* do not free */\n    int \t\tppklen;\n    X509_ALGOR \t\t*palg = NULL;\t\t\t/* algorithm identifier for public key */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    RSA \t\t*rsaKey = NULL;\n#else\n    EVP_PKEY \t\t*rsaKey = NULL;\n#endif\n\n    /* get internal pointer to the public key in the certificate */\n    if (rc == 0) {\n\tpubkey = X509_get_X509_PUBKEY(ekCertificate);\t/* do not free */\n\tif (pubkey == NULL) {\n\t    printf(\"convertCertificatePubKey12: Could not extract X509_PUBKEY public key \"\n\t\t   \"from X509 certificate\\n\");\n\t    rc = TPM_RC_INTEGRITY;\n\t}\n    }\n    /* get the public key parameters, as a byte stream pk */\n    if (rc == 0) {\n\tirc = X509_PUBKEY_get0_param(&ppkalg,\n\t\t\t\t     &pk, &ppklen,\t/* internal, don't free */\n\t\t\t\t     &palg, pubkey);\n\tif (irc != 1) {\n\t    printf(\"convertCertificatePubKey12: Could not extract public key parameters \"\n\t\t   \"from X509 certificate\\n\");\n\t    rc = TPM_RC_INTEGRITY;\n\t}\n    }\n    if (rc == 0) {\n\tconst unsigned char *tmppk = pk;\t/* because d2i moves the pointer */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\trsaKey = d2i_RSAPublicKey(NULL, &tmppk, ppklen);\t/* freed @1 */\n#else\n\trsaKey = d2i_PublicKey(EVP_PKEY_RSA, NULL,\n\t\t\t       &tmppk, (long)ppklen);\n#endif\n\tif (rsaKey == NULL) {\n\t    printf(\"convertCertificatePubKey12: Could not convert to RSA structure\\n\");\n\t    rc = TPM_RC_INTEGRITY;\n\t}\n    }\n    if (rc == 0) {\n\trc = convertRsaKeyToPublicKeyBin(modulusBytes,\n\t\t\t\t\t modulusBin,\t/* freed by caller */\n\t\t\t\t\t rsaKey);\n\tTSS_PrintAll(\"convertCertificatePubKey12\", *modulusBin, *modulusBytes);\n    }\n    TSS_RsaFree(rsaKey);\t\t/* @1 */\n#else  /* TPM_TSS_NORSA */\n    rc = TPM_RC_INTEGRITY;\n#endif /* TPM_TSS_NORSA */\n    return rc;\n}\n\n#endif /* TPM_TPM12 */\n\n#ifndef TPM_TSS_NOFILE\t\t/* stdout is a file descriptor */\n\nTPM_RC convertX509PemToDer(uint32_t *certLength,\n\t\t\t    unsigned char **certificate,\t/* output, freed by caller */\n\t\t\t    const char *pemCertificateFilename)\n{\n    TPM_RC rc = 0;\n    X509 \t*x509Certificate = NULL;\n\n    if (rc == 0) {\n\trc = convertPemToX509(&x509Certificate,\t\t/* freed @1 */\n\t\t\t      pemCertificateFilename);\n    }\n    if (rc == 0) {\n\trc = convertX509ToDer(certLength,\n\t\t\t      certificate,\t\t/* output, freed by caller */\n\t\t\t      x509Certificate);\t\t/* input */\n    }\n    if (x509Certificate != NULL) {\n\tX509_free(x509Certificate);\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\n\n#ifndef TPM_TSS_NOFILE\n\n/* convertPemToX509() reads a PEM file and converts it to an OpenSSL X509 structure\n\n */\n\nuint32_t convertPemToX509(X509 **x509,\t\t\t\t/* freed by caller */\n\t\t\t  const char *pemCertificateFilename)\n{\n    uint32_t \trc = 0;\n    int\t\tirc;\n    FILE \t*pemCertificateFile = NULL;\n\n    if (tssUtilsVerbose) printf(\"convertPemToX509: Reading PEM certificate file %s\\n\",\n\t\t\tpemCertificateFilename);\n    if (rc == 0) {\n\tpemCertificateFile = fopen(pemCertificateFilename, \"r\");\n\tif (pemCertificateFile == NULL) {\n\t    printf(\"convertPemToX509: Cannot open PEM file %s\\n\", pemCertificateFilename);\n\t    rc = TSS_RC_FILE_OPEN;\n\t}\n    }\n    /* convert the platform certificate from PEM to DER */\n    if (rc == 0) {\n\t*x509 = PEM_read_X509(pemCertificateFile , NULL, NULL, NULL);\t/* freed @1 */\n\tif (*x509 == NULL) {\n\t    printf(\"convertPemToX509: Cannot parse PEM certificate file %s\\n\",\n\t\t   pemCertificateFilename);\n\t    rc = TSS_RC_FILE_READ;\n\t}\n    }\n    /* for debug */\n    if ((rc == 0) && tssUtilsVerbose) {\n\tirc = X509_print_fp(stdout, *x509);\n\tif (irc != 1) {\n\t    printf(\"ERROR: convertPemToX509: Error in certificate print X509_print_fp()\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (pemCertificateFile != NULL) {\n\tfclose(pemCertificateFile);\t\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\n\n/* convertDerToX509() converts a DER stream to an OpenSSL X509 structure\n\n   The return is void because the structure is opaque to the caller.  This accommodates other crypto\n   libraries.\n*/\n\nuint32_t convertDerToX509(void **x509Certificate,\t\t\t/* freed by caller */\n\t\t\t  uint16_t readLength,\n\t\t\t  const unsigned char *readBuffer)\n{\n    uint32_t \trc = 0;\n    *x509Certificate = d2i_X509(NULL,\t\t\t\t\t/* freed by caller */\n\t\t\t\t&readBuffer, readLength);\n    if (*x509Certificate == NULL) {\n\tprintf(\"convertDerToX509: Could not parse X509 certificate\\n\");\n\trc = TSS_RC_X509_ERROR;\n    }\n    return rc;\n}\n\n/* x509Free Structure() is the library specific free structure.\n\n   The parameter is void because the structure is opaque to the caller.  This accommodates other\n   crypto libraries.\n*/\n\nvoid x509FreeStructure(void *x509)\n{\n    if (x509 != NULL) {\n\tX509_free(x509);\n    }\n    return;\n}\n\n/* x509PrintStructure() prints the structure to stdout\n\n   The parameter is void because the structure is opaque to the caller.  This accommodates other\n   crypto libraries.\n*/\n\nvoid x509PrintStructure(void *x509)\n{\n    X509_print_fp(stdout, x509);\n    return;\n}\n\n/* convertPemMemToX509() converts an in-memory PEM format X509 certificate to an openssl X509\n   structure.\n\n*/\n\nuint32_t convertPemMemToX509(X509 **x509,\t\t/* freed by caller */\n\t\t\t     const char *pemCertificate)\n{\n    uint32_t rc = 0;\n    BIO *bio = NULL;\n    int pemLength;\n    int writeLen = 0;\n\n    if (tssUtilsVerbose) printf(\"convertPemMemToX509: pemCertificate\\n%s\\n\", pemCertificate);  \n    /* create a BIO that uses an in-memory buffer */\n    if (rc == 0) {\n\tbio = BIO_new(BIO_s_mem());\t\t/* freed @1 */\n\tif (bio == NULL) {\n\t    printf(\"convertPemMemToX509: BIO_new failed\\n\");  \n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* write the PEM from memory to BIO */\n    if (rc == 0) {\n\tpemLength = (int)strlen(pemCertificate);\n\twriteLen = BIO_write(bio, pemCertificate, pemLength);\n\tif (writeLen != pemLength) {\n\t    printf(\"convertPemMemToX509: BIO_write failed\\n\");  \n\t    rc = TPM_RC_INTEGRITY;\n\t}\n    }\n    /* convert the properly formatted PEM to X509 structure */\n    if (rc == 0) {\n\t*x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);\n\tif (*x509 == NULL) {\n\t    printf(\"convertPemMemToX509: PEM_read_bio_X509 failed\\n\");\n\t    rc = TPM_RC_INTEGRITY;\n\t}\n    }\n    /* for debug */\n#ifndef TPM_TSS_NOFILE\t\t/* stdout is a file descriptor */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) X509_print_fp(stdout, *x509);\n    }\n#endif\n    if (bio != NULL) {\n\tBIO_free(bio);\t\t\t/* @1 */\n    }\n    return rc;\n}\n\n#ifndef TPM_TSS_NOFILE\n\n/* convertX509ToPem() writes an OpenSSL X509 structure to a PEM format file\n\n   The return is void because the structure is opaque to the caller.  This accommodates other crypto\n   libraries.\n \n   For OpenSSL, the type is X509*\n*/\n\nTPM_RC convertX509ToPem(const char *pemFilename,\n\t\t\tvoid *x509)\n{\n    TPM_RC \trc = 0;\n    int\t\tirc;\n    FILE \t*pemFile = NULL;\n\n    if (tssUtilsVerbose) printf(\"convertX509ToPem: Writing PEM certificate file %s\\n\",\n\t\t\tpemFilename);\n    if (rc == 0) {\n\tpemFile = fopen(pemFilename, \"w\");\t/* close @1 */\n\tif (pemFile == NULL) {\n\t    printf(\"convertX509ToPem: Cannot open PEM file %s\\n\", pemFilename);\n\t    rc = TSS_RC_FILE_OPEN;\n\t}\n    }\n    if (rc == 0) {\n\tirc = PEM_write_X509(pemFile, x509);\n\tif (irc == 0) {\n\t    printf(\"convertX509ToPem: Unable to write PEM file %s\\n\", pemFilename);\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    if (pemFile != NULL) {\n\tfclose(pemFile);\t/* @1 */\n    }\n    return rc;\n}\n\n#endif\n\n/* convertX509ToPemMem() converts an OpenSSL X509 structure to PEM format in memory */\n\nTPM_RC convertX509ToPemMem(char **pemString,\t/* freed by caller */\n\t\t\t   X509 *x509)\n{\n    TPM_RC \t\trc = 0;\t\t/* general return code */\n    int\t\t\tirc;\n    char \t\t*data = NULL;\n    long \t\tlength;\n    \n    /* create a BIO that uses an in-memory buffer */\n    BIO *bio = NULL;\n    if (rc == 0) {\n\tbio = BIO_new(BIO_s_mem());\t\t/* freed @1 */\n\tif (bio == NULL) {\n\t    printf(\"convertX509ToPemMem: BIO_new failed\\n\");  \n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* convert X509 to PEM and write the PEM to memory */\n    if (rc == 0) {\n\tirc = PEM_write_bio_X509(bio, x509);\n\tif (irc != 1) {\n\t    printf(\"convertX509ToPemMem: PEM_write_bio_X509 failed\\n\");\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    if (rc == 0) {\n\tlength = BIO_get_mem_data(bio, &data);\n\t*pemString = malloc((size_t)(length)+1);\n\tif (*pemString == NULL) {\n\t    printf(\"ERROR: convertX509ToPemMem: Cannot malloc %lu\\n\", length);  \n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n\telse {\n\t    (*pemString)[length] = '\\0';\n\t}\n    }\n    if (rc == 0) {\n\tirc = BIO_read(bio, *pemString, length);\n \tif (irc <= 0) {\n\t    printf(\"ERROR: convertX509ToPemMem: BIO_read failed\\n\");\n\t    rc = TSS_RC_FILE_READ;\n\t}\n    }\n    if (bio != NULL) {\n\tBIO_free(bio);\t\t\t/* @1 */\n    }\n    return rc;\n}\n\n/* convertX509ToString() converts an OpenSSL X509 structure to a human readable string */\n\nTPM_RC convertX509ToString(char **x509String,\t/* freed by caller */\n\t\t\t     X509 *x509)\n{\n    TPM_RC \trc = 0;\n    int\t\tirc;\n    char \t*data = NULL;\n    long \tlength;\n\n    /* create a BIO that uses an in-memory buffer */\n    BIO *bio = NULL;\n    if (rc == 0) {\n\tbio = BIO_new(BIO_s_mem());\t\t/* freed @1 */\n\tif (bio == NULL) {\n\t    printf(\"convertX509ToString: BIO_new failed\\n\");  \n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* write the string to memory */\n    if (rc == 0) {\n\tirc = X509_print(bio, x509);\n\tif (irc != 1) {\n\t    printf(\"convertX509ToString X509_print failed\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\tlength = BIO_get_mem_data(bio, &data);\n\t*x509String = malloc((size_t)length+1);\n\tif (*x509String == NULL) {\n\t    printf(\"convertX509ToString: Cannot malloc %lu\\n\", length);\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n\telse {\n\t    (*x509String)[length] = '\\0';\n\t}\n    }\n    if (rc == 0) {\n\tirc = BIO_read(bio, *x509String, length);\n \tif (irc <= 0) {\n\t    printf(\"convertX509ToString BIO_read failed\\n\");\n\t    rc = TSS_RC_FILE_READ;\n\t}\n    }\n    if (bio != NULL) {\n\tBIO_free(bio);\t\t\t/* @1 */\n    }\n    return rc;\n}\n\n/*\n  Certificate Creation\n*/\n\n/* These are the names inserted into the certificates.  If changed, the entries also change.  At run\n   time, the mapping from key to nid is done once and used repeatedly.  */\n    \nCertificateName certificateName[] = {\n    { \"countryName\",\t\t\tNID_undef},\t/* 0 */\n    { \"stateOrProvinceName\",\t\tNID_undef},\t/* 1 */\n    { \"localityName\",\t\t\tNID_undef},\t/* 2 */\n    { \"organizationName\",\t\tNID_undef},\t/* 3 */\n    { \"organizationalUnitName\",\t\tNID_undef},\t/* 4 */\n    { \"commonName\",\t\t\tNID_undef},\t/* 5 */\n    { \"emailAddress\",\t\t\tNID_undef},\t/* 6 */\n};\n\nTPM_RC calculateNid(void)\n{\n    TPM_RC rc = 0;\n    size_t \ti;\n\n    for (i=0 ; (i < sizeof(certificateName)/sizeof(CertificateName)) && (rc == 0) ; i++) {\n\tcertificateName[i].nid = OBJ_txt2nid(certificateName[i].key);\t/* look up the NID for the\n\t\t\t\t\t\t\t\t\t   field */\n\tif (certificateName[i].nid == NID_undef) {\n\t    printf(\"calculateNid: Error finding nid for %s\\n\", certificateName[i].key);\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    return rc;\n}\n\ntypedef struct tdAlgorithmList\n{\n    TPMI_RH_NV_INDEX ekCertIndex;\n    uint16_t algorithmSize;\n} AlgorithmList;\n\nAlgorithmList algorithmList[] = {\n    {EK_CERT_RSA_INDEX, 2048/8}, \t\t/* RSA 2048 EK Certificate */\n    {EK_CERT_EC_INDEX, 256/8}, \t\t\t/* ECC NIST P256 EK Certificate */\n    {EK_CERT_RSA_2048_INDEX_H1, 2048/8}, \t/* RSA 2048 EK Certificate (H-1) */\n    {EK_CERT_ECC_NISTP256_INDEX_H2, 256/8}, \t/* ECC NIST P256 EK Certificate (H-2) */\n    {EK_CERT_ECC_NISTP384_INDEX_H3, 384/8}, \t/* ECC NIST P384 EK Certificate (H-3) */\n    {EK_CERT_ECC_NISTP521_INDEX_H4, 521/8}, \t/* ECC NIST P521 EK Certificate (H-4) */\n    {EK_CERT_ECC_SM2P256INDEX_H5, 256/8},\t/* ECC SM2_P256 EK Certificate (H-5) */\n    {EK_CERT_RSA_3072_INDEX_H6, 3072/8}, \t/* RSA 3072 EK Certificate (H-6) */\n    {EK_CERT_RSA_4096_INDEX_H7, 4096/8}, \t/* RSA 4096 EK Certificate (H-7) */\n};\n\n#ifdef TPM_TPM20\n\n/* processAlgorithmSize() validates the nonce size to be copied to the unique field against the EK\n   algorithm.\n\n   It returns the modulus size in bytes.\n*/\n\nstatic TPM_RC processAlgorithmSize(uint16_t *algorithmSize,\n\t\t\t\t   unsigned char *nonce,\n\t\t\t\t   uint16_t nonceSize,\n\t\t\t\t   TPMI_RH_NV_INDEX ekCertIndex)\n{\n    TPM_RC rc = TSS_RC_BAD_PROPERTY_VALUE;\t/* return if index not found */\n    size_t i;\n\n    for (i = 0 ; i < sizeof(algorithmList)/sizeof(AlgorithmList) ; i++) {\n\tif (algorithmList[i].ekCertIndex == ekCertIndex) {\n\t    *algorithmSize = algorithmList[i].algorithmSize;\n\t    if ((nonce != NULL) && (nonceSize > algorithmList[i].algorithmSize)) {\n\t\tprintf(\"processAlgorithmSize: EK cert index %08x NV nonce size %u > %u\\n\",\n\t\t       ekCertIndex, nonceSize, algorithmList[i].algorithmSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    else {\n\t\trc = 0;\n\t    }\n\t    break;\n\t}\n    }\n    if (rc == TSS_RC_BAD_PROPERTY_VALUE) {\n\tprintf(\"processAlgorithmSize: EK cert index %08x unsupported\\n\", ekCertIndex);\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TPM20 */\n\n/* createCertificate() constructs a certificate from the issuer and subject.  The public key to be\n   certified is tpmtPublic.\n\n   It signs the certificate using the CA key in caKeyFileName protected by the password\n   caKeyPassword.  The CA signing key algorithm caKeyAlg is RSA or ECC.\n\n   The certificate is returned as a DER encoded array 'certificate', a PEM string, and a formatted\n   string.\n\n*/\n\nTPM_RC createCertificate(char **x509CertString,\t\t/* freed by caller */\n\t\t\t char **pemCertString,\t\t/* freed by caller */\n\t\t\t uint32_t *certLength,\t\t/* output, certificate length */\n\t\t\t unsigned char **certificate,\t/* output, freed by caller */\n\t\t\t TPMT_PUBLIC *tpmtPublic,\t/* key to be certified */\t\n\t\t\t const char *caKeyFileName,\n\t\t\t size_t issuerEntriesSize,\n\t\t\t char **issuerEntries,\n\t\t\t size_t subjectEntriesSize,\n\t\t\t char **subjectEntries,\n\t\t\t const char *caKeyPassword)\n{\n    TPM_RC \t\trc = 0;\n    X509 \t\t*x509Certificate = NULL;\n    uint16_t \t\tpublicKeyLength;\n    const unsigned char *publicKey = NULL;\n    \n    /* allocate memory for the X509 structure */\n    if (rc == 0) {\n\tx509Certificate = X509_new();\t\t/* freed @2 */\n\tif (x509Certificate == NULL) {\n\t    printf(\"createCertificate: Error in X509_new\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* hash unique field to create serial number */\n    if (rc == 0) {\n\tif (tpmtPublic->type == TPM_ALG_RSA) {\n\t    publicKeyLength = tpmtPublic->unique.rsa.t.size;\n\t    publicKey = tpmtPublic->unique.rsa.t.buffer;\n\t}\n\telse if (tpmtPublic->type == TPM_ALG_ECC) {\n\t    publicKeyLength = tpmtPublic->unique.ecc.x.t.size;\n\t    publicKey = tpmtPublic->unique.ecc.x.t.buffer;\n\t}\n\telse {\n\t    printf(\"createCertificate: public key algorithm %04x not supported\\n\",\n\t\t   tpmtPublic->type);\n\t    rc = TSS_RC_BAD_SIGNATURE_ALGORITHM;\n\t}\n    }    \n    /* fill in basic X509 information - version, serial, validity, issuer, subject */\n    if (rc == 0) {\n\trc = startCertificate(x509Certificate,\n\t\t\t      publicKeyLength, publicKey,\n\t\t\t      issuerEntriesSize, issuerEntries,\n\t\t\t      subjectEntriesSize, subjectEntries);\n    }\n    /* If the EK has the decrypt attribute set, the keyEncipherment bit MUST be set for an RSA EK\n       certificate; the keyAgreement bit MUST be set for an ECC EK certificate. */\n    if (rc == 0) {\n\tif (tpmtPublic->type == TPM_ALG_RSA) {\n\t    rc = addCertExtension(x509Certificate, NID_key_usage, \"critical,keyEncipherment\");\n\t}\n\tif (tpmtPublic->type == TPM_ALG_ECC) {\n\t    rc = addCertExtension(x509Certificate, NID_key_usage, \"critical,keyAgreement\");\n\t}\n    }\n    /* add the TPM public key to be certified */\n    if (rc == 0) {\n\tswitch (tpmtPublic->type) {\n#ifndef TPM_TSS_NORSA\n\t  case TPM_ALG_RSA:\n\t    rc = addCertKeyRsa(x509Certificate, &tpmtPublic->unique.rsa);\n\t    break;\n#endif /* TPM_TSS_NORSA */\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\t  case TPM_ALG_ECC:\n\t    rc = addCertKeyEccT(x509Certificate, tpmtPublic);\n\t    break;\n#endif\t/* TPM_TSS_NOECC */\n#endif  /* TPM_TPM20 */\n\t  default:\n\t    printf(\"createCertificate: public key algorithm %04x not supported\\n\",\n\t\t   tpmtPublic->type);\n\t    rc = TSS_RC_BAD_SIGNATURE_ALGORITHM;\n\t}\n    }\n    /* sign the certificate with the root CA key */\n    if (rc == 0) {\n\trc = addCertSignatureRoot(x509Certificate, caKeyFileName, caKeyPassword);\n    }\n    if (rc == 0) {\n\trc = convertX509ToDer(certLength, certificate,\t/* freed by caller */\n\t\t\t      x509Certificate);\t\t/* in */\n    }\n    if (rc == 0) {\n\trc = convertX509ToPemMem(pemCertString,\t\t/* freed by caller */\n\t\t\t\t x509Certificate);\n    }\n    if (rc == 0) {\n\trc = convertX509ToString(x509CertString,\t/* freed by caller */\n\t\t\t\t x509Certificate);\n    }\n    X509_free(x509Certificate);\t\t/* @2 */\n    return rc;\n}\n\n/* Certificate duration period is hard coded to 20 years */\n\n#define CERT_DURATION (60 * 60 * 24 * ((365 * 20) + 2))\t\t/* +2 for leap years */\n\n/* startCertificate() fills in basic X509 information, such as:\n   version\n   serial number\n   issuer\n   validity\n   subject\n*/\n\nTPM_RC startCertificate(X509 *x509Certificate,\t/* X509 certificate to be generated */\n\t\t\tuint16_t keyLength,\n\t\t\tconst unsigned char *keyBuffer,\t/* key to be certified */\n\t\t\tsize_t issuerEntriesSize,\n\t\t\tchar **issuerEntries,\t\t/* certificate issuer */\n\t\t\tsize_t subjectEntriesSize,\n\t\t\tchar **subjectEntries)\t\t/* certificate subject */\n{\n    TPM_RC \t\trc = 0;\t\t\t/* general return code */\n    int\t\t\tirc;\t\t\t/* integer return code */\n    ASN1_TIME \t\t*arc;\t\t\t/* return code */\n    ASN1_INTEGER \t*x509Serial;\t\t/* certificate serial number in ASN1 */\n    BIGNUM \t\t*x509SerialBN;\t\t/* certificate serial number as a BIGNUM */\n    unsigned char \tx509Serialbin[EVP_MAX_MD_SIZE]; /* certificate serial number in binary */\n    X509_NAME \t\t*x509IssuerName;\t/* composite issuer name, key/value pairs */\n    X509_NAME \t\t*x509SubjectName;\t/* composite subject name, key/value pairs */\n\n    x509IssuerName = NULL;\t/* freed @1 */\n    x509SubjectName = NULL;\t/* freed @2 */\n    x509SerialBN = NULL;\t/* freed @3 */ \n\n    /* add certificate version X509 v3 */\n    if (rc == 0) {\n\tirc = X509_set_version(x509Certificate, 2L);\t/* value 2 == v3 */\n\tif (irc != 1) {\n\t    printf(\"startCertificate: Error in X509_set_version\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /*\n      add certificate serial number\n    */\n    if (rc == 0) {\n\tconst EVP_MD *type;\n\n\tif (tssUtilsVerbose) printf(\"startCertificate: Adding certificate serial number\\n\");\n\t/* to create a unique serial number, hash the key to be certified */\n\ttype = EVP_sha256();\n\tirc = EVP_Digest(keyBuffer, keyLength, x509Serialbin, NULL, type, NULL);\n\tif (irc == 0) {\n\t    printf(\"startCertificate: Error in serial number EVP_Digest\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\t/* convert the digest to a BIGNUM, use 20 octets */\n\tx509SerialBN = BN_bin2bn(x509Serialbin, 20, x509SerialBN);\n\tif (x509SerialBN == NULL) {\n\t    printf(\"startCertificate: Error in serial number BN_bin2bn\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\t/* get the serial number structure member, can't fail */\n\tx509Serial = X509_get_serialNumber(x509Certificate);\n\t/* convert the BIGNUM to ASN1 and add to X509 certificate */\n\tx509Serial = BN_to_ASN1_INTEGER(x509SerialBN, x509Serial);\n\tif (x509Serial == NULL) {\n\t    printf(\"startCertificate: Error setting certificate serial number\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* add issuer */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"startCertificate: Adding certificate issuer\\n\");\n\trc = createX509Name(&x509IssuerName,\n\t\t\t    issuerEntriesSize,\n\t\t\t    issuerEntries);\n    }\n    if (rc == 0) {\n\tirc = X509_set_issuer_name(x509Certificate, x509IssuerName);\n\tif (irc != 1) {\n\t    printf(\"startCertificate: Error setting certificate issuer\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* add validity */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"startCertificate: Adding certificate validity\\n\");\n    }\n    if (rc == 0) {\n\t/* can't fail, just returns a structure member */\n\tASN1_TIME *notBefore = X509_getm_notBefore((const X509 *)x509Certificate);\n\tarc = X509_gmtime_adj(notBefore ,0L);\t\t\t/* set to today */\n\tif (arc == NULL) {\n\t    printf(\"startCertificate: Error setting notBefore time\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\t/* can't fail, just returns a structure member */\n\tASN1_TIME *notAfter = X509_getm_notAfter((const X509 *)x509Certificate);\n\tarc = X509_gmtime_adj(notAfter, CERT_DURATION);\t\t/* set to duration */\n\tif (arc == NULL) {\n\t    printf(\"startCertificate: Error setting notAfter time\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* add subject */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"startCertificate: Adding certificate subject\\n\");\n\trc = createX509Name(&x509SubjectName,\n\t\t\t    subjectEntriesSize,\n\t\t\t    subjectEntries);\n    }\n    if (rc == 0) {\n\tirc = X509_set_subject_name(x509Certificate, x509SubjectName);\n\tif (irc != 1) {\n\t    printf(\"startCertificate: Error setting certificate subject\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* cleanup */\n    X509_NAME_free(x509IssuerName);\t\t/* @1 */\n    X509_NAME_free(x509SubjectName);\t\t/* @2 */\n    BN_free(x509SerialBN);\t\t\t/* @3 */\n    return rc;\n}\n\n/* createX509Name() create an X509 name (issuer or subject) from a pointer to issuer or subject\n   entries\n\n*/\n\nTPM_RC createX509Name(X509_NAME **x509Name,\t/* freed by caller X509_NAME_free() */\n\t\t      size_t entriesSize,\n\t\t      char **entries)\n{\n    TPM_RC \t\trc = 0;\t\t/* general return code */\n    int\t\t\tirc;\t\t/* integer return code */\n    size_t  \t\ti;\n    X509_NAME_ENTRY \t*nameEntry;\t\t/* single field of the name */\n\n    nameEntry = NULL;\n\n    /* Precalculate the openssl nids, into global table */\n    if (rc == 0) {\n\trc = calculateNid();\n    }\n    if (rc == 0) {\n\t*x509Name = X509_NAME_new();\n\tif (*x509Name == NULL) {\n\t    printf(\"createX509Name: Error in X509_NAME_new()\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    for (i=0 ; (i < entriesSize) && (rc == 0) ; i++) {\n\tif ((rc == 0) && (entries[i] != NULL)) {\n\t    nameEntry =\n\t\tX509_NAME_ENTRY_create_by_NID(NULL,\t\t/* caller creates object */\n\t\t\t\t\t      certificateName[i].nid,\n\t\t\t\t\t      MBSTRING_ASC,\t/* character encoding */\n\t\t\t\t\t      (unsigned char *)entries[i],\t/* to add */\n\t\t\t\t\t      -1);\t\t/* length, -1 is C string */\n\n\t    if (nameEntry == NULL) {\n\t\tprintf(\"createX509Name: Error creating entry for %s\\n\",\n\t\t       certificateName[i].key);\n\t\trc = TSS_RC_X509_ERROR;\n\t    }\n\t}\n\tif ((rc == 0) && (entries[i] != NULL)) {\n\t    irc = X509_NAME_add_entry(*x509Name,\t/* add to issuer */\n\t\t\t\t      nameEntry,\t/* add the entry */\n\t\t\t\t      -1,\t\t/* location - append */\t\n\t\t\t\t      0);\t\t/* set - not multivalued */\n\t    if (irc != 1) {\n\t\tprintf(\"createX509Name: Error adding entry for %s\\n\",\n\t\t       certificateName[i].key);\n\t\trc = TSS_RC_X509_ERROR;\n\t    }\n\t}\n\tX509_NAME_ENTRY_free(nameEntry);\t/* callee checks for NULL */\n\tnameEntry = NULL;\n    }\n    return rc;\n}\n\n/* addCertExtension() adds the extension type 'nid' to the X509 certificate\n\n */ \n\nTPM_RC addCertExtension(X509 *x509Certificate, int nid, const char *value)\n{\n    TPM_RC \t\trc = 0;\n    X509_EXTENSION \t*extension = NULL;\t/* freed @1 */\n\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n\t/* the cast is required for the older openssl 1.0 API */\n\textension = X509V3_EXT_conf_nid(NULL, NULL,\t/* freed @1 */\n\t\t\t\t\tnid, (char *)value);\n#else\n\textension = X509V3_EXT_conf_nid(NULL, NULL,\t/* freed @1 */\n\t\t\t\t\tnid, value);\n#endif\n\tif (extension == NULL) {\n\t    printf(\"addCertExtension: Error creating nid %i extension %s\\n\",\n\t\t   nid, value);\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    if (rc == 0) {\n\tint irc = X509_add_ext(x509Certificate,\t\t/* the certificate */\n\t\t\t       extension,\t\t/* the extension to add */\n\t\t\t       -1);\t\t\t/* location - append */\n\tif (irc != 1) {\n\t    printf(\"addCertExtension: Error adding nid %i extension %s\\n\",\n\t\t   nid, value);\n\t}\n    }\n    if (extension != NULL) {\n\tX509_EXTENSION_free(extension);\t\t/* @1 */\n    }\n    return rc;\n}\n#ifndef TPM_TSS_NORSA\n\n/* addCertKeyRsa() adds the TPM RSA public key (the key to be certified) to the openssl X509\n   certificate\n\n*/\n\nTPM_RC addCertKeyRsa(X509 *x509Certificate,\n\t\t     const TPM2B_PUBLIC_KEY_RSA *tpm2bRsa)\t/* key to be certified */\n{\n    TPM_RC \t\trc = 0;\t\t/* general return code */\n    int\t\t\tirc;\t\t/* integer return code */\n    EVP_PKEY \t\t*evpPubkey = NULL;\t/* EVP format public key to be certified */\n\n    if (tssUtilsVerbose) printf(\"addCertKeyRsa: add public key to certificate\\n\");\n    /* convert from TPM key data format to openSSL RSA type */\n    if (rc == 0) {\n\trc = convertRsaPublicToEvpPubKey(&evpPubkey,\t/* freed @1 */\n\t\t\t\t\t tpm2bRsa);\n    }\n    /* add the public key to the certificate */\n    if (rc == 0) {\n\tirc = X509_set_pubkey(x509Certificate, evpPubkey);\n\tif (irc != 1) {\n\t    printf(\"addCertKeyRsa: Error adding public key to certificate\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* cleanup */\n    if (evpPubkey != NULL) {\n\tEVP_PKEY_free(evpPubkey);\t/* @1 */\n    }\n    return rc;\n}\n\n#endif /* TPM_TSS_NORSA */\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOECC\n\n/* addCertKeyEccT() adds the TPM ECC public key (the key to be certified) to the openssl X509\n   certificate.\n\n*/\n\nTPM_RC addCertKeyEccT(X509 *x509Certificate,\n\t\t      const TPMT_PUBLIC *tpmtPublic)\n{\n    TPM_RC \t\trc = 0;\t\t\t/* general return code */\n    int\t\t\tirc;\n    EVP_PKEY \t\t*evpPubkey = NULL;\t/* EVP format public key to be certified */\n\n    /* convert EC TPMS_ECC_POINT to an EVP_PKEY */\n    if (rc == 0) {\n\trc = convertEcTPMTPublicToEvpPubKey(&evpPubkey,\t\t/* freed @1 */\n\t\t\t\t\t    tpmtPublic);\n    }\n    /* add the public key to the certificate */\n    if (rc == 0) {\n\tirc = X509_set_pubkey(x509Certificate, evpPubkey);\n\tif (irc != 1) {\n\t    printf(\"addCertKeyEccT: Error adding public key to certificate\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* cleanup */\n    if (evpPubkey != NULL) {\n\tEVP_PKEY_free(evpPubkey);\t/* @1 */\n    }\n    return rc;\n}\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\n/* addCertKeyEcc() adds the TPM ECC public key (the key to be certified) to the openssl X509\n   certificate.\n\n   Deprecated because it calls the deprecated convertEcPublicToEvpPubKey().\n\n*/\n\nTPM_RC addCertKeyEcc(X509 *x509Certificate,\n\t\t     const TPMS_ECC_POINT *tpmsEccPoint)\n{\n    TPM_RC \t\trc = 0;\t\t\t/* general return code */\n    int\t\t\tirc;\n    EVP_PKEY \t\t*evpPubkey = NULL;\t/* EVP format public key to be certified */\n\n    /* convert EC TPMS_ECC_POINT to an EVP_PKEY */\n    if (rc == 0) {\n\trc = convertEcPublicToEvpPubKey(&evpPubkey,\t\t/* freed @1 */\n\t\t\t\t\ttpmsEccPoint);\n    }\n    /* add the public key to the certificate */\n    if (rc == 0) {\n\tirc = X509_set_pubkey(x509Certificate, evpPubkey);\n\tif (irc != 1) {\n\t    printf(\"addCertKeyEcc: Error adding public key to certificate\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* cleanup */\n    if (evpPubkey != NULL) {\n\tEVP_PKEY_free(evpPubkey);\t/* @1 */\n    }\n    return rc;\n}\n#endif\n\n#endif\t/* TPM_TSS_NOECC */\n#endif /* TPM_TPM20 */\n\n/* addCertSignatureRoot() uses the openSSL root key to sign the X509 certificate.\n\n   As a sanity check, it verifies the certificate.\n*/\n\nTPM_RC addCertSignatureRoot(X509 *x509Certificate,\t/* certificate to be signed */\n\t\t\t    const char *caKeyFileName,\t/* openSSL root CA key password */\n\t\t\t    const char *caKeyPassword)\n{\n    TPM_RC \t\trc = 0;\t\t/* general return code */\n    int\t\t\tirc;\t\t/* integer return code */\n    FILE \t\t*fp = NULL;\n    /* signing key */\n    const EVP_MD\t*digest = NULL;\t\t/* signature digest algorithm */\n    EVP_PKEY \t\t*evpSignkey;\t\t/* EVP format */\n\n    evpSignkey = NULL;\t\t/* freed @1 */\n\n    /* open the CA signing key file */\n    if (rc == 0) {\n\tfp = fopen(caKeyFileName,\"r\");\n\tif (fp == NULL) {\n\t    printf(\"addCertSignatureRoot: Error, Cannot open %s\\n\", caKeyFileName);\n\t    rc = TSS_RC_FILE_OPEN;\n\t}\n    }\n    /* convert the CA signing key from PEM to EVP_PKEY format */\n    if (rc == 0) {\n\tevpSignkey = PEM_read_PrivateKey(fp, NULL, NULL, (void *)caKeyPassword);\t\n\tif (evpSignkey == NULL) {\n\t    printf(\"addCertSignatureRoot: Error calling PEM_read_PrivateKey() from %s\\n\",\n\t\t   caKeyFileName);\n\t    rc = TSS_RC_FILE_READ;\n\t}\n    }\n    /* close the CA signing key file */\n    if (fp != NULL) { \n\tfclose(fp);\n    }\n    /* set the certificate signature digest algorithm */\n    if (rc == 0) {\n\tdigest = EVP_sha256();\t/* no error return */\n    }\n    /* sign the certificate with the root CA signing key */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"addCertSignatureRoot: Signing the certificate\\n\");\n\tirc = X509_sign(x509Certificate, evpSignkey, digest);\n\tif (irc == 0) {\t/* returns signature size, 0 on error */\n\t    printf(\"addCertSignature: Error signing certificate\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* verify the signature */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"addCertSignatureRoot: Verifying the certificate\\n\");\n\tirc = X509_verify(x509Certificate, evpSignkey);\n\tif (irc != 1) {\n\t    printf(\"addCertSignatureRoot: Error verifying certificate\\n\");\n\t    rc = TSS_RC_X509_ERROR;\n\t}\n    }\n    /* cleanup */\n    if (evpSignkey != NULL) {\n\tEVP_PKEY_free(evpSignkey);\t/* @1 */\n    }\n    return rc;\n}\n\n#ifdef TPM_TPM20\n\n/* processRoot() validates the certificate at ekCertIndex against the root CA certificates at\n   rootFilename.\n */\n\n#ifndef TPM_TSS_NOFILE\n\nTPM_RC processRoot(TSS_CONTEXT *tssContext,\n\t\t   TPMI_RH_NV_INDEX ekCertIndex,\n\t\t   const char *rootFilename[],\n\t\t   unsigned int rootFileCount,\n\t\t   int print)\n{\n    TPM_RC\trc = 0;\n    void\t*ekCertificate = NULL;\t\t/* freed @1 */\n\n    /* read the EK X509 certificate from NV */\n    if (rc == 0) {\n\trc = getIndexX509Certificate(tssContext,\n\t\t\t\t     &ekCertificate,\t/* freed @1 */\n\t\t\t\t     ekCertIndex);\n\tif (rc != 0) {\n\t    printf(\"processRoot: No EK certificate\\n\");  \n\t}\n    }\n    if (rc == 0) {\n\trc = verifyCertificate(ekCertificate,\n\t\t\t       rootFilename,\n\t\t\t       rootFileCount,\n\t\t\t       print);\n\tif (rc != 0) {\n\t    printf(\"processRoot: EK certificate did not verify\\n\");\n\t}\n    }\n    if (ekCertificate != NULL) {\n\tX509_free(ekCertificate);   \t/* @1 */\n    }\n    return rc;\n}\n\n#endif\n\n/* processCreatePrimary() is deprecated.  It is missing the endorsement auth */\n\nTPM_RC processCreatePrimary(TSS_CONTEXT *tssContext,\n\t\t\t    TPM_HANDLE *keyHandle,\t\t/* primary key handle */\n\t\t\t    TPMI_RH_NV_INDEX ekCertIndex,\n\t\t\t    unsigned char *nonce,\n\t\t\t    uint16_t nonceSize,\n\t\t\t    TPMT_PUBLIC *tpmtPublicIn,\t\t/* template */\n\t\t\t    TPMT_PUBLIC *tpmtPublicOut,\t\t/* primary key */\n\t\t\t    unsigned int noFlush,\t/* TRUE - don't flush the primary key */\n\t\t\t    int print)\n{\n    TPM_RC rc = processCreatePrimaryE(tssContext,\n\t\t\t\t      keyHandle,\n\t\t\t\t      NULL,\t/* endorsement auth */\n\t\t\t\t      NULL,\t/* EK password */\n\t\t\t\t      ekCertIndex,\n\t\t\t\t      nonce,\n\t\t\t\t      nonceSize,\n\t\t\t\t      tpmtPublicIn,\n\t\t\t\t      tpmtPublicOut,\n\t\t\t\t      noFlush,\n\t\t\t\t      print);\n    return rc;\n}\n\n/* processCreatePrimaryE() combines the EK nonce and EK template from NV to form the\n   createprimary input.  It creates the primary key.\n\n   ekCertIndex determines whether an RSA or ECC key is created.\n   \n   If nonce is NULL, the default IWG templates are used.  If nonce is non-NULL, the nonce and\n   tpmtPublicIn are used.\n\n   After returning the TPMT_PUBLIC, flushes the primary key unless noFlush is TRUE.  If noFlush is\n   FALSE, returns the loaded handle, else returns TPM_RH_NULL.\n*/\n\nTPM_RC processCreatePrimaryE(TSS_CONTEXT *tssContext,\n\t\t\t     TPM_HANDLE *keyHandle,\t\t/* primary key handle */\n\t\t\t     const char *endorsementPassword,\n\t\t\t     const char *keyPassword,\n\t\t\t     TPMI_RH_NV_INDEX ekCertIndex,\n\t\t\t     unsigned char *nonce,\n\t\t\t     uint16_t nonceSize,\n\t\t\t     TPMT_PUBLIC *tpmtPublicIn,\t\t/* template */\n\t\t\t     TPMT_PUBLIC *tpmtPublicOut,\t/* primary key */\n\t\t\t     unsigned int noFlush,\t/* TRUE - don't flush the primary key */\n\t\t\t     int print)\n{\n    TPM_RC\t\t\trc = 0;\n    uint16_t \t\t\talgorithmSize = 0;\n    CreatePrimary_In \t\tinCreatePrimary;\n    CreatePrimary_Out \t\toutCreatePrimary;\n\n    /* sanity check nonce size (should never happen on HW TPM).  Map the algorithm to the algorithm\n       size. */\n    if (rc == 0) {\n\trc = processAlgorithmSize(&algorithmSize, nonce, nonceSize, ekCertIndex);\n    }\n    /* set up the createprimary in parameters */\n    if (rc == 0) {\n\tinCreatePrimary.primaryHandle = TPM_RH_ENDORSEMENT;\n\tinCreatePrimary.inSensitive.sensitive.data.t.size = 0;\n\t/* creation data */\n\tinCreatePrimary.outsideInfo.t.size = 0;\n\tinCreatePrimary.creationPCR.count = 0;\n    }\n    if (rc == 0) {\n\tif (keyPassword == NULL) {\n\t    inCreatePrimary.inSensitive.sensitive.userAuth.t.size = 0;\n\t}\n\telse {\n\t    rc = TSS_TPM2B_StringCopy(&inCreatePrimary.inSensitive.sensitive.userAuth.b,\n\t\t\t\t      keyPassword,\n\t\t\t\t      sizeof\n\t\t\t\t      (inCreatePrimary.inSensitive.sensitive.userAuth.t.buffer));\n\t}\n    }\n    /* construct the template from the NV template and nonce */\n    if ((rc == 0) && (nonce != NULL)) {\n\tinCreatePrimary.inPublic.publicArea = *tpmtPublicIn;\n\tswitch (ekCertIndex) {\n\t  case EK_CERT_RSA_INDEX:\t\t/* low range */\n\t    /* unique field is 256 bytes */\n\t    inCreatePrimary.inPublic.publicArea.unique.rsa.t.size = algorithmSize;\n\t    /* first part is nonce */\n\t    memcpy(inCreatePrimary.inPublic.publicArea.unique.rsa.t.buffer, nonce, nonceSize);\n\t    /* padded with zeros */\n\t    memset(inCreatePrimary.inPublic.publicArea.unique.rsa.t.buffer + nonceSize, 0,\n\t\t   algorithmSize - nonceSize);\n\t    break;\n\t  case EK_CERT_EC_INDEX:\n\t    /* unique field is X and Y points */\n\t    /* X gets nonce and pad */\n\t    inCreatePrimary.inPublic.publicArea.unique.ecc.x.t.size = algorithmSize;\n\t    memcpy(inCreatePrimary.inPublic.publicArea.unique.ecc.x.t.buffer, nonce, nonceSize);\n\t    memset(inCreatePrimary.inPublic.publicArea.unique.ecc.x.t.buffer + nonceSize, 0,\n\t\t   algorithmSize - nonceSize);\n\t    /* Y gets zeros */\n\t    inCreatePrimary.inPublic.publicArea.unique.ecc.y.t.size = algorithmSize;\n\t    memset(inCreatePrimary.inPublic.publicArea.unique.ecc.y.t.buffer, 0, algorithmSize);\n\t    break;\n\t  default:\n\t    printf(\"cprocessCreatePrimaryE: \"\n\t\t   \"ekCertIndex %08x with nonce not supported\\n\", ekCertIndex);\n\t    rc = TPM_RC_INTEGRITY;\n\t    break;\n\t}\n    }\n    /* construct the template from the default IWG template */\n    if ((rc == 0) && (nonce == NULL)) {\n\trc = getIwgTemplate(&inCreatePrimary.inPublic.publicArea, ekCertIndex);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&outCreatePrimary,\n\t\t\t (COMMAND_PARAMETERS *)&inCreatePrimary,\n\t\t\t NULL,\n\t\t\t TPM_CC_CreatePrimary,\n\t\t\t TPM_RS_PW, endorsementPassword, 0,\n\t\t\t TPM_RH_NULL, NULL, 0);\n\tif (rc != 0) {\n\t    const char *msg;\n\t    const char *submsg;\n\t    const char *num;\n\t    printf(\"createprimary: failed, rc %08x\\n\", rc);\n\t    TSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\t    printf(\"%s%s%s\\n\", msg, submsg, num);\n\t}\n    }\n    /* return the primary key */\n    if (rc == 0) {\n\t*tpmtPublicOut = outCreatePrimary.outPublic.publicArea;\n    }\n    /* flush the primary key */\n    if (rc == 0) {\n\tif (!noFlush) {\t\t/* flush the primary key */\n\t    FlushContext_In \t\tinFlushContext;\n\t    *keyHandle = TPM_RH_NULL;\t    \n\t    inFlushContext.flushHandle = outCreatePrimary.objectHandle;\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     NULL, \n\t\t\t     (COMMAND_PARAMETERS *)&inFlushContext,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_FlushContext,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t    if (rc != 0) {\n\t\tconst char *msg;\n\t\tconst char *submsg;\n\t\tconst char *num;\n\t\tprintf(\"flushcontext: failed, rc %08x\\n\", rc);\n\t\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\t\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\t    }\n\t}\n\telse {\t/* not flushed, return the handle */\n\t    *keyHandle = outCreatePrimary.objectHandle;\n\t}\n    }\t    \n    /* trace the public key */\n    if (rc == 0) {\n\tif (tpmtPublicOut->type == TPM_ALG_RSA) {\n\t    if (print) TSS_PrintAll(\"createprimary: RSA public key\",\n\t\t\t\t    outCreatePrimary.outPublic.publicArea.unique.rsa.t.buffer,\n\t\t\t\t    outCreatePrimary.outPublic.publicArea.unique.rsa.t.size);\n\t}\n\telse if (tpmtPublicOut->type == TPM_ALG_ECC) {\n\t    if (print) TSS_PrintAll(\"createprimary: ECC public key x\",\n\t\t\t\t    outCreatePrimary.outPublic.publicArea.unique.ecc.x.t.buffer,\n\t\t\t\t    outCreatePrimary.outPublic.publicArea.unique.ecc.x.t.size);\n\t    if (print) TSS_PrintAll(\"createprimary: ECC public key y\",\n\t\t\t\t    outCreatePrimary.outPublic.publicArea.unique.ecc.y.t.buffer,\n\t\t\t\t    outCreatePrimary.outPublic.publicArea.unique.ecc.y.t.size);\n\t}\n    }\n    return rc;\n}\n\n/* processValidatePrimary() compares the public key in the EK certificate to the public key output\n   of createprimary.  */\n\nTPM_RC processValidatePrimary(uint8_t *publicKeyBin,\t\t/* from certificate */\n\t\t\t      int publicKeyBytes,\n\t\t\t      TPMT_PUBLIC *tpmtPublic,\t\t/* primary key */\n\t\t\t      TPMI_RH_NV_INDEX ekCertIndex,\n\t\t\t      int print)\n{\n    TPM_RC\t\t\trc = 0;\n\n    print = print;\n    /* compare the X509 certificate public key to the createprimary public key */\n#ifndef TPM_TSS_NORSA\n    if (tpmtPublic->type == TPM_ALG_RSA) {\n\tint irc;\n\t/* RSA just has a public modulus */\n\tif (rc == 0) {\n\t    if (tpmtPublic->unique.rsa.t.size != publicKeyBytes) {\n\t\tprintf(\"processValidatePrimary: \"\n\t\t       \"X509 certificate key length %u does not match output of createprimary %u\\n\",\n\t\t       publicKeyBytes,\n\t\t       tpmtPublic->unique.rsa.t.size);\n\t\trc = TPM_RC_INTEGRITY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    irc = memcmp(publicKeyBin,\n\t\t\t tpmtPublic->unique.rsa.t.buffer,\n\t\t\t publicKeyBytes);\n\t    if (irc != 0) {\n\t\tprintf(\"processValidatePrimary: \"\n\t\t       \"Public key from X509 certificate does not match output of createprimary\\n\");\n\t\trc = TPM_RC_INTEGRITY;\n\t    }\n\t}\n    }\n    else\n#endif /* TPM_TSS_NORSA */\n#ifndef TPM_TSS_NOECC\n\tif (tpmtPublic->type == TPM_ALG_ECC) {\n\t    int irc;\n\t    /* ECC has X and Y points */\n\t    /* compression algorithm is the extra byte at the beginning of the certificate */\n\t    if (rc == 0) {\n\t\tif (tpmtPublic->unique.ecc.x.t.size +\n\t\t    tpmtPublic->unique.ecc.y.t.size + 1\n\t\t    != publicKeyBytes) {\n\t\t    printf(\"processValidatePrimary: \"\n\t\t\t   \"X509 certificate key length %u does not match \"\n\t\t\t   \"output of createprimary x %u + y %u\\n\",\n\t\t\t   publicKeyBytes,\n\t\t\t   tpmtPublic->unique.ecc.x.t.size,\n\t\t\t   tpmtPublic->unique.ecc.y.t.size);\n\t\t    rc = TPM_RC_INTEGRITY;\n\t\t}\n\t    }\n\t    /* check X */\n\t    if (rc == 0) {\n\t\tirc = memcmp(publicKeyBin +1,\n\t\t\t     tpmtPublic->unique.ecc.x.t.buffer,\n\t\t\t     tpmtPublic->unique.ecc.x.t.size);\n\t\tif (irc != 0) {\n\t\t    printf(\"processValidatePrimary: \"\n\t\t\t   \"Public key X from X509 certificate does not match \"\n\t\t\t   \"output of createprimary\\n\");\n\t\t    rc = TPM_RC_INTEGRITY;\n\t\t}\n\t    }\n\t    /* check Y */\n\t    if (rc == 0) {\n\t\tirc = memcmp(publicKeyBin + 1 + tpmtPublic->unique.ecc.x.t.size,\n\t\t\t     tpmtPublic->unique.ecc.y.t.buffer,\n\t\t\t     tpmtPublic->unique.ecc.y.t.size);\n\t\tif (irc != 0) {\n\t\t    printf(\"processValidatePrimary: \"\n\t\t\t   \"Public key Y from X509 certificate does not match \"\n\t\t\t   \"output of createprimary\\n\");\n\t\t    rc = TPM_RC_INTEGRITY;\n\t\t}\n\t    }\n\t}\n\telse\n#endif /* TPM_TSS_NOECC */\n\t    {\n\t\tprintf(\"processValidatePrimary: \"\n\t\t       \"ekCertIndex %08x (asymmetric algorithm) not supported\\n\", ekCertIndex);\n\t\trc = TPM_RC_INTEGRITY;\n\t    }\n    if (rc == 0) {\n\tif (print) printf(\"processValidatePrimary: \"\n\t\t\t  \"Public key from X509 certificate matches output of createprimary\\n\");\n    }\n    return rc;\n}\n\n/* processPrimary() is deprecated.  It is missing the endorsement auth.  It is missing the key\n   password, new for the high range EKs.  It always validates the low range EK public keys.\n\n   See processPrimaryEN()\n*/\n\nTPM_RC processPrimary(TSS_CONTEXT *tssContext,\n\t\t      TPM_HANDLE *keyHandle,\n\t\t      TPMI_RH_NV_INDEX ekCertIndex,\n\t\t      TPMI_RH_NV_INDEX ekNonceIndex, \n\t\t      TPMI_RH_NV_INDEX ekTemplateIndex,\n\t\t      unsigned int noFlush,\n\t\t      int print)\n{\n    TPM_RC rc = processPrimaryEN(tssContext,\n\t\t\t\t keyHandle,\n\t\t\t\t NULL,\t/* default endorsement auth */\n\t\t\t\t NULL,\t/* default endorsement key password */\n\t\t\t\t ekCertIndex,\n\t\t\t\t ekNonceIndex,\n\t\t\t\t ekTemplateIndex,\n\t\t\t\t noFlush,\n\t\t\t\t FALSE,\t\t/* default noPub */\n\t\t\t\t print);\n    return rc;\n}\n\n/* processPrimaryE() is deprecated.  It always validates the low range EK public keys.\n\n   See processPrimaryEN()\n*/\n\n\nTPM_RC processPrimaryE(TSS_CONTEXT *tssContext,\n\t\t       TPM_HANDLE *keyHandle,\t\t/* primary key handle */\n\t\t       const char *endorsementPassword,\n\t\t       const char *keyPassword,\n\t\t       TPMI_RH_NV_INDEX ekCertIndex,\n\t\t       TPMI_RH_NV_INDEX ekNonceIndex,\n\t\t       TPMI_RH_NV_INDEX ekTemplateIndex,\n\t\t       unsigned int noFlush,\n\t\t       int print)\n{\n    TPM_RC rc = 0;\n    unsigned int noPub = 1;\n\n    /* the backward compatible behavior was to always validate the low range public key\n       and never validate the high range public key */\n#ifndef TPM_TSS_NORSA\n    if (ekCertIndex == EK_CERT_RSA_INDEX) {\n\tnoPub = 0;\n    }\n#endif /* TPM_TSS_NORSA */\n#ifndef TPM_TSS_NOECC\n   if (ekCertIndex == EK_CERT_EC_INDEX) {\n\tnoPub = 0;\n    }\n#endif\t/* TPM_TSS_NOECC */\n    rc = processPrimaryEN(tssContext,\n\t\t\t  keyHandle,\t\t/* primary key handle */\n\t\t\t  endorsementPassword,\n\t\t\t  keyPassword,\n\t\t\t  ekCertIndex,\n\t\t\t  ekNonceIndex,\n\t\t\t  ekTemplateIndex,\n\t\t\t  noFlush,\n\t\t\t  noPub,\t\t/* noPub */\n\t\t\t  print);\n    return rc;\n}\n\n/* processPrimaryEN() reads the EK nonce and EK template from NV if present.  It forms the\n   createprimary input.  It creates the primary key.\n\n   It reads the EK certificate from NV.  It extracts the public key.\n\n   If noPub is false, it compares the public key in the certificate to the public key output of\n   createprimary.\n\n   If noFlush is false, the EK is flushed after processing.  If noFlush is true, the EK remains in\n   the TPM as a transient key.\n*/\n\nTPM_RC processPrimaryEN(TSS_CONTEXT *tssContext,\n\t\t\tTPM_HANDLE *keyHandle,\t\t/* primary key handle */\n\t\t\tconst char *endorsementPassword,\n\t\t\tconst char *keyPassword,\n\t\t\tTPMI_RH_NV_INDEX ekCertIndex,\n\t\t\tTPMI_RH_NV_INDEX ekNonceIndex,\n\t\t\tTPMI_RH_NV_INDEX ekTemplateIndex,\n\t\t\tunsigned int noFlush,\t\t/* TRUE - don't flush the primary key */\n\t\t\tunsigned int noPub,\t\t/* TRUE - don't verify the pubic key */\n\t\t\tint print)\n{\n    TPM_RC\t\t\trc = 0;\n    void \t\t\t*ekCertificate = NULL;\n    unsigned char \t\t*nonce = NULL;\n    uint16_t \t\t\tnonceSize;\n    TPMT_PUBLIC \t\ttpmtPublicIn;\t\t/* template */\n    TPMT_PUBLIC \t\ttpmtPublicOut;\t\t/* primary key */\n    uint8_t \t\t\t*publicKeyBin = NULL;\t/* from certificate */\n    int\t\t\t\tpublicKeyBytes;\n\n    /* get the EK nonce */\n    if (rc == 0) {\n\trc = processEKNonce(tssContext, &nonce, &nonceSize, ekNonceIndex, print); /* freed @1 */\n\tif ((rc & 0xff) == TPM_RC_HANDLE) {\n\t    if (print) printf(\"processPrimaryEN: EK nonce not found, use default template\\n\");\n\t    rc = 0;\n\t}\n    }\n    if (rc == 0) {\n\t/* if the nonce was found, get the EK template */\n\tif (nonce != NULL) {\n\t    rc = processEKTemplate(tssContext, &tpmtPublicIn, ekTemplateIndex, print);\n\t}\n    }\n    /* create the primary key */\n    if (rc == 0) {\n\trc = processCreatePrimaryE(tssContext,\n\t\t\t\t   keyHandle,\n\t\t\t\t   endorsementPassword,\n\t\t\t\t   keyPassword,\n\t\t\t\t   ekCertIndex,\n\t\t\t\t   nonce, nonceSize,\t\t/* EK nonce, can be NULL */\n\t\t\t\t   &tpmtPublicIn,\t\t/* template */\n\t\t\t\t   &tpmtPublicOut,\t\t/* primary key */\n\t\t\t\t   noFlush,\n\t\t\t\t   print);\n    }\n    /* get the EK certificate */\n    if ((rc == 0) && !noPub) {\n\trc = processEKCertificate(tssContext,\n\t\t\t\t  &ekCertificate,\t\t\t/* freed @2 */\n\t\t\t\t  &publicKeyBin, &publicKeyBytes,\t/* freed @3 */\n\t\t\t\t  ekCertIndex,\n\t\t\t\t  print);\n    }\n    /* compare the public key in the EK certificate to the public key output */\n    if ((rc == 0) && !noPub) {\n\trc = processValidatePrimary(publicKeyBin,\t/* certificate */\n\t\t\t\t    publicKeyBytes,\n\t\t\t\t    &tpmtPublicOut,\t/* primary key */\n\t\t\t\t    ekCertIndex,\n\t\t\t\t    print);\n    }\n    if ((rc == 0) && !noPub) {\n\tif (print) printf(\"Public key from X509 certificate matches output of createprimary\\n\");\n    } \n    free(nonce);\t\t\t/* @1 */\n    if (ekCertificate != NULL) {\n\tX509_free(ekCertificate);   \t/* @2 */\n    }\n    free(publicKeyBin);\t\t\t/* @3 */\n    return rc;\n}\n\n#endif\t/* TPM20 */\n\n"
  },
  {
    "path": "ibmtss-ftpm/encryptdecrypt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   EncryptDecrypt\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\n\nstatic void printDecrypt(EncryptDecrypt_Out *out);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    EncryptDecrypt_In \t\tin;\n    EncryptDecrypt_Out \t\tout;\n    EncryptDecrypt2_In \t\tin2;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    const char\t\t\t*inFilename = NULL;\n    const char\t\t\t*outFilename = NULL;\n    TPMI_YES_NO\t\t\tdecrypt = NO;\n    int\t\t\t\ttwo = FALSE;\n    const char\t\t\t*keyPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    uint16_t\t\t\twritten;\n    size_t\t\t\tlength;\n    uint8_t\t\t\t*buffer = NULL;\t\t/* for the free */\n    uint8_t\t\t\t*buffer1 = NULL;\t/* for marshaling */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-of\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-d\") == 0) {\n\t    decrypt = YES;\n\t}\n \telse if (strcmp(argv[i],\"-2\") == 0) {\n\t    two = TRUE;\n\t}\n \telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (inFilename == NULL) {\n\tprintf(\"Missing encrypted message -if\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     inFilename);\n    }\n    if (rc == 0) {\n\tif (length > sizeof(in.inData.t.buffer)) {\n\t    printf(\"Input data too long %u\\n\", (uint32_t)length);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\tif (!two) {\t/* use TPM_CC_EncryptDecrypt */\n\t    /* the symmetric key used for the operation */\n\t    in.keyHandle = keyHandle;\n\t    /* if YES, then the operation is decryption; if NO, the operation is encryption */\n\t    in.decrypt = decrypt;\n\t    /* symmetric mode */\n\t    in.mode = TPM_ALG_NULL;\n\t    /* an initial value as required by the algorithm */\n\t    in.ivIn.t.size = MAX_SYM_BLOCK_SIZE;\n\t    memset(in.ivIn.t.buffer, 0, MAX_SYM_BLOCK_SIZE);\n\t    /* the data to be encrypted/decrypted */\n\t    in.inData.t.size = (uint16_t)length;\n\t    if (length > 0) {\t/* if length is 0, buffer is NULL */\n\t\tmemcpy(in.inData.t.buffer, buffer, length);\n\t    }\n\t}\n\telse {\n\t    /* the symmetric key used for the operation */\n\t    in2.keyHandle = keyHandle;\n\t    /* if YES, then the operation is decryption; if NO, the operation is encryption */\n\t    in2.decrypt = decrypt;\n\t    /* symmetric mode */\n\t    in2.mode = TPM_ALG_NULL;\n\t    /* an initial value as required by the algorithm */\n\t    in2.ivIn.t.size = MAX_SYM_BLOCK_SIZE;\n\t    memset(in2.ivIn.t.buffer, 0, MAX_SYM_BLOCK_SIZE);\n\t    /* the data to be encrypted/decrypted */\n\t    in2.inData.t.size = (uint16_t)length;\n\t    if (length > 0) {\t/* if length is 0, buffer is NULL */\n\t\tmemcpy(in2.inData.t.buffer, buffer, length);\n\t    }\n\t}\n    }\n    free (buffer);\t/* @1 */\n    buffer = NULL;\n\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\tif (!two) {\t/* use TPM_CC_EncryptDecrypt */\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     (RESPONSE_PARAMETERS *)&out,\n\t\t\t     (COMMAND_PARAMETERS *)&in,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_EncryptDecrypt,\n\t\t\t     sessionHandle0, keyPassword, sessionAttributes0,\n\t\t\t     sessionHandle1, NULL, sessionAttributes1,\n\t\t\t     sessionHandle2, NULL, sessionAttributes2,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n\telse {\t/* use TPM_CC_EncryptDecrypt2 */\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     (RESPONSE_PARAMETERS *)&out,\n\t\t\t     (COMMAND_PARAMETERS *)&in2,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_EncryptDecrypt2,\n\t\t\t     sessionHandle0, keyPassword, sessionAttributes0,\n\t\t\t     sessionHandle1, NULL, sessionAttributes1,\n\t\t\t     sessionHandle2, NULL, sessionAttributes2,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (outFilename != NULL)) {\n\twritten = 0;\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&out.outData, &written, NULL, NULL);\n    }\n    if ((rc == 0) && (outFilename != NULL)) {\n\tbuffer = malloc(written);\t/* freed @2 */\n\tbuffer1 = buffer;\n\twritten = 0;\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&out.outData, &written, &buffer1, NULL);\n    }\n    if ((rc == 0) && (outFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(buffer + sizeof(uint16_t),\n\t\t\t\t      written - sizeof(uint16_t),\n\t\t\t\t      outFilename);\n    }\n    free(buffer);\t/* @2 */\n    buffer = NULL;\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printDecrypt(&out);\n\tif (tssUtilsVerbose) printf(\"encryptdecrypt: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"encryptdecrypt: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printDecrypt(EncryptDecrypt_Out *out)\n{\n    TSS_PrintAll(\"outData\", out->outData.t.buffer, out->outData.t.size);\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"encryptdecrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_EncryptDecrypt\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t-pwdk\\tpassword for key (default empty)\\n\");\n    printf(\"\\t-d\\tdecrypt (default encrypt)\\n\");\n    printf(\"\\t-if\\tinput file name\\n\");\n    printf(\"\\t[-of\\toutput file name (default do not save)]\\n\");\n    printf(\"\\t[-2\\tuse TPM2_EncryptDecrypt2]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/eventextend.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t      Extend an EVENT measurement file into PCRs\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2016 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* eventextend is test/demo code.  It parses a TPM2 event log file and extends the measurements into\n   TPM PCRs or simulated PCRs.  This simulates the actions that would be performed by BIOS / UEFI /\n   pre-OS firmware in a hardware platform.\n\n   It can optionally:\n\n   - check the calculated, simulated PCR against the TPM PCRs\n   - check the digest against the event log data\n\n   It handles the EV_NO_ACTION StartupLocality by power cycling the TPM and sending a startup\n   at the locality from the event.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsstransmit.h>\t/* for simulator power up */\n\n#include \"eventlib.h\"\n\n/* local prototypes */\n\nstatic uint32_t powerUp(void);\nstatic uint32_t startup(TSS_CONTEXT\t*tssContext,\n\t\t\tuint8_t \tlocality);\nstatic uint32_t pcrExtend(TSS_CONTEXT\t\t*tssContext,\n\t\t\t  TCG_PCR_EVENT2 \t*event2);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char * argv[])\n{\n    TPM_RC \t\t\trc = 0;\n    int \t\t\ti = 0;\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    const char \t\t\t*infilename = NULL;\n    FILE \t\t\t*infile = NULL;\n    int\t\t\t\ttpm = FALSE;\t/* extend into TPM */\n    int\t\t\t\tsim = FALSE;\t/* extend into simulated PCRs */\n    int\t\t\t\tcheckHash = FALSE;\t/* verify event log hashes */\n    int\t\t\t\tcheckPcr = FALSE;\t/* verify PCRs */\n    int\t\t\t\tnospec = FALSE;\t/* event log does not start with spec file */\n    int\t\t\t\tnoSpace = FALSE;\n    uint32_t \t\t\tbankNum = 0;\t/* PCR hash bank */\n    unsigned int \t\tpcrNum = 0;\t/* PCR number iterator */\n    TPMI_DH_PCR \t\tpcrMax = 7;\n    TPMT_HA \t\t\tsimPcrs[HASH_COUNT][IMPLEMENTATION_PCR];\n    TPMT_HA \t\t\tbootAggregates[HASH_COUNT];\n    TCG_PCR_EVENT2 \t\tevent2;\t\t\t/* TPM 2.0 event log entry */\n    TCG_PCR_EVENT \t\tevent;\t\t\t/* TPM 1.2 event log entry */\n    TCG_EfiSpecIDEvent \t\tspecIdEvent;\n    unsigned int \t\tlineNum;\n    int \t\t\tendOfFile = FALSE;\n\t\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; i<argc ; i++) {\n\tif (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinfilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tpm\") == 0) {\n\t    tpm = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-nospec\") == 0) {\n\t    nospec = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-sim\") == 0) {\n\t    sim = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-checkhash\") == 0) {\n\t    checkHash = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-checkpcr\") == 0) {\n\t    checkPcr = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-ns\") == 0) {\n\t    noSpace = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-pcrmax\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &pcrMax);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -pcrmax\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (!strcmp(argv[i], \"-h\")) {\n\t    printUsage();\n\t}\n\telse if (!strcmp(argv[i], \"-v\")) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (infilename == NULL) {\n\tprintf(\"Missing -if argument\\n\");\n\tprintUsage();\n    }\n    if (sim && nospec) {\n\tprintf(\"-sim incompatible with -nospec\\n\");\n\tprintUsage();\n    }\n    /*\n    ** read the event log file\n    */\n    infile = fopen(infilename,\"rb\");\n    if (infile == NULL) {\n\tprintf(\"Unable to open input file '%s'\\n\", infilename);\n\texit(-4);\n    }\n    /* the first event is a TPM 1.2 format event */\n    /* read an event line */\n    if ((rc == 0) && !nospec) {\n\trc = TSS_EVENT_Line_Read(&event, &endOfFile, infile);\n    }\n    /* debug tracing */\n    if ((rc == 0) && !nospec && !endOfFile && tssUtilsVerbose) {\n\tprintf(\"\\neventextend: line 0\\n\");\n\tTSS_EVENT_Line_Trace(&event);\n    }\n    /* parse the event, populates the TCG_EfiSpecIDEvent structure */\n    if ((rc == 0) && !nospec && !endOfFile) {\n\trc = TSS_SpecIdEvent_Unmarshal(&specIdEvent,\n\t\t\t\t       event.eventDataSize, event.event);\n    }\n    /* range check numberOfAlgorithms before the trace */\n    if ((rc == 0) && !nospec && !endOfFile) {\n\tif (specIdEvent.numberOfAlgorithms > HASH_COUNT) {\n\t    printf(\"specIdEvent.numberOfAlgorithms %u greater than %u\\n\",\n\t\t   specIdEvent.numberOfAlgorithms, HASH_COUNT);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    /* trace the specIdEvent event */\n    if ((rc == 0) && !nospec && !endOfFile && tssUtilsVerbose) {\n\tTSS_SpecIdEvent_Trace(&specIdEvent);\n    }\n    /* Start a TSS context for PCR extend and/or PCR read */\n    if ((rc == 0) && (tpm || (sim && checkPcr))) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* initialize simulated PCRs */\n    if ((rc == 0) && sim) {\n\tif (specIdEvent.numberOfAlgorithms > HASH_COUNT) {\n\t    printf(\"specIdEvent.numberOfAlgorithms %u greater than %u\\n\",\n\t\t   specIdEvent.numberOfAlgorithms, HASH_COUNT);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    /* simulated PCRs start at zero or ff at boot */\n    if ((rc == 0) && sim) {\n\tfor (bankNum = 0 ; bankNum < specIdEvent.numberOfAlgorithms ; bankNum++) {\n\t    bootAggregates[bankNum].hashAlg = specIdEvent.digestSizes[bankNum].algorithmId;\n\t    for (pcrNum = 0 ; pcrNum < IMPLEMENTATION_PCR ; pcrNum++) {\n\t\t/* initialize each algorithm ID based on the specIdEvent */\n\t\tsimPcrs[bankNum][pcrNum].hashAlg = specIdEvent.digestSizes[bankNum].algorithmId;\n\t\tif ((pcrNum < 17) || (pcrNum > 22)) {\n\t\t    memset(&simPcrs[bankNum][pcrNum].digest.tssmax, 0, sizeof(TPMU_HA));\n\t\t}\n\t\t/* some PC Client PCRs initialize to all ff */\n\t\telse {\n\t\t    memset(&simPcrs[bankNum][pcrNum].digest.tssmax, 0xff, sizeof(TPMU_HA));\n\t\t}\n\t    }\n\t}\n\t/* void the unused banks so they will never match an event */\n\tfor (; bankNum < HASH_COUNT ; bankNum++) {\n\t    simPcrs[bankNum][0].hashAlg = TPM_ALG_NULL;\n\t}\n    }\n    /* scan each measurement 'line' in the binary */\n    for (lineNum = 1 ; (rc == 0) && !endOfFile ; lineNum++) {\n\n\t/* read a TPM 2.0 hash agile event line */\n\tif (rc == 0) {\n\t    rc = TSS_EVENT2_Line_Read(&event2, &endOfFile, infile);\n\t}\n\t/* debug tracing */\n\tif ((rc == 0) && !endOfFile && tssUtilsVerbose) {\n\t    printf(\"\\neventextend: line %u\\n\", lineNum);\n\t    TSS_EVENT2_Line_Trace(&event2);\n\t}\n\t/* verify the event PCR digest against the event data */\n\tif ((rc == 0) && !endOfFile && checkHash) {\n\t    rc = TSS_EVENT2_Line_CheckHash(&event2, &specIdEvent);\n\t}\n\tif ((rc == 0) && !endOfFile && tpm) {\t\t/* extend TPM */\n\t    rc = pcrExtend(tssContext, &event2);\n\t}\n\tif ((rc == 0) && !endOfFile && sim && tssUtilsVerbose &&\n\t    (event2.pcrIndex < IMPLEMENTATION_PCR)) {\t/* trace simulated PCRs */\n\t    for (bankNum = 0 ; bankNum < specIdEvent.numberOfAlgorithms ; bankNum++) {\n\t\tTSS_PrintAll(\"PCR simulated digest before extend\",\n\t\t\t     simPcrs[bankNum][event2.pcrIndex].digest.tssmax,\n\t\t\t     specIdEvent.digestSizes[bankNum].digestSize);\n\t    }\n\t}\n\tif ((rc == 0) && !endOfFile && sim) {\t\t/* extend simulated PCRs */\n\t    rc = TSS_EVENT2_PCR_Extend(simPcrs, &event2);\n\t}\n\tif ((rc == 0) && !endOfFile && sim && tssUtilsVerbose &&\n\t    (event2.pcrIndex < IMPLEMENTATION_PCR)) {\t/* trace simulated PCRs */\n\t    for (bankNum = 0 ; bankNum < specIdEvent.numberOfAlgorithms ; bankNum++) {\n\t\tTSS_PrintAll(\"PCR simulated digest after extend\",\n\t\t\t     simPcrs[bankNum][event2.pcrIndex].digest.tssmax,\n\t\t\t     specIdEvent.digestSizes[bankNum].digestSize);\n\t    }\n\t}\n    }\n    if ((rc == 0) && sim) {\n\tfor (bankNum = 0 ; (rc == 0) && (bankNum < specIdEvent.numberOfAlgorithms) ; bankNum++) {\n\t    /* trace the virtual PCRs */\n\t    if (rc == 0) {\n\t        char pcrString[9];\t/* PCR number */\n\n\t\tprintf(\"\\n\");\n\t\tTSS_TPM_ALG_ID_Print(\"algorithmId\", specIdEvent.digestSizes[bankNum].algorithmId, 0);\n\t\tfor (pcrNum = 0 ; pcrNum < IMPLEMENTATION_PCR ; pcrNum++) {\n\t\t    sprintf(pcrString, \"PCR %02u:\", pcrNum);\n\t\t    if (!noSpace) {\n\t\t\t/* TSS_PrintAllLogLevel() with a log level of LOGLEVEL_INFO to print the byte\n\t\t\t   array on one line with no length */\n\t\t\tTSS_PrintAllLogLevel(LOGLEVEL_INFO, pcrString, 1,\n\t\t\t\t\t     simPcrs[bankNum][pcrNum].digest.tssmax,\n\t\t\t\t\t     specIdEvent.digestSizes[bankNum].digestSize);\n\t\t    }\n\t\t    else {\t/* print with no spaces */\n\t\t\tuint32_t bp;\n\t\t\tprintf(\"PCR %02u: \", pcrNum);\n\t\t\tfor (bp = 0 ; bp < specIdEvent.digestSizes[bankNum].digestSize ; bp++) {\n\t\t\t    printf(\"%02x\", simPcrs[bankNum][pcrNum].digest.tssmax[bp]);\n\t\t\t}\n\t\t\tprintf(\"\\n\");\n\t\t    }\n\t\t}\n\t    }\n\t    /* verify the TPM PCRs against the calculated values */\n\t    if ((rc == 0) && checkPcr) {\n\t\tfor (pcrNum = 0 ; pcrNum < IMPLEMENTATION_PCR ; pcrNum++) {\n\t\t    PCR_Read_In \t\tin;\n\t\t    PCR_Read_Out \t\tout;\n\t\t    /* read the PCR */\n\t\t    if (rc == 0) {\n\t\t\tin.pcrSelectionIn.count = 1;\n\t\t\tin.pcrSelectionIn.pcrSelections[0].hash =\n\t\t\t    specIdEvent.digestSizes[bankNum].algorithmId;\n\t\t\tin.pcrSelectionIn.pcrSelections[0].sizeofSelect = 3;\n\t\t\tin.pcrSelectionIn.pcrSelections[0].pcrSelect[0] = 0;\n\t\t\tin.pcrSelectionIn.pcrSelections[0].pcrSelect[1] = 0;\n\t\t\tin.pcrSelectionIn.pcrSelections[0].pcrSelect[2] = 0;\n\t\t\tin.pcrSelectionIn.pcrSelections[0].pcrSelect[pcrNum / 8] = 1 << (pcrNum % 8);\n\t\t\trc = TSS_Execute(tssContext,\n\t\t\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t\t\t NULL,\n\t\t\t\t\t TPM_CC_PCR_Read,\n\t\t\t\t\t TPM_RH_NULL, NULL, 0);\n\t\t    }\n\t\t    /* compare the PCR to the calculated value */\n\t\t    if (rc == 0) {\n\t\t\tif (specIdEvent.digestSizes[bankNum].digestSize !=\n\t\t\t    out.pcrValues.digests[0].t.size) {\n\t\t\t    printf(\"eventextend: PCR %u digest size TPM %u simulated %u\\n\",\n\t\t\t\t   pcrNum,\n\t\t\t\t   specIdEvent.digestSizes[bankNum].digestSize,\n\t\t\t\t   out.pcrValues.digests[0].t.size);\n\t\t\t    rc = TSS_RC_BAD_READ_VALUE;\n\t\t\t}\n\t\t    }\n\t\t    if (rc == 0) {\n\t\t\tint i = memcmp(simPcrs[bankNum][pcrNum].digest.tssmax,\n\t\t\t\t       out.pcrValues.digests[0].t.buffer,\n\t\t\t\t       out.pcrValues.digests[0].t.size);\n\t\t\tif (i != 0) {\n\t\t\t    printf(\"eventextend: PCR %u\\n\", pcrNum);\n\t\t\t    TSS_PrintAll(\"PCR TPM digest\",\n\t\t\t\t\t out.pcrValues.digests[0].t.buffer,\n\t\t\t\t\t out.pcrValues.digests[0].t.size);\n\t\t\t    TSS_PrintAll(\"PCR simulated digest\",\n\t\t\t\t\t simPcrs[bankNum][pcrNum].digest.tssmax,\n\t\t\t\t\t out.pcrValues.digests[0].t.size);\n\t\t\t    rc = TSS_RC_BAD_READ_VALUE;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t    /* calculate the boot aggregate, hash of PCRs, default 0-7 */\n\t    if (rc == 0) {\n\t\tint length[IMPLEMENTATION_PCR];\n\t\tsize_t j;\n\t\tfor (j = 0 ; j < IMPLEMENTATION_PCR ; j++) {\n\t\t    if (j <= pcrMax) {\t/* include PCRs up to here */\n\t\t\tlength[j] = specIdEvent.digestSizes[bankNum].digestSize;\n\t\t    }\n\t\t    else {\n\t\t\tlength[j] = 0;\t/* exclude PCRs after to here */\n\t\t    }\n\t\t}\n\t\trc = TSS_Hash_Generate(&bootAggregates[bankNum],\n\t\t\t\t       length[0], &simPcrs[bankNum][0].digest.tssmax,\n\t\t\t\t       length[1], &simPcrs[bankNum][1].digest.tssmax,\n\t\t\t\t       length[2], &simPcrs[bankNum][2].digest.tssmax,\n\t\t\t\t       length[3], &simPcrs[bankNum][3].digest.tssmax,\n\t\t\t\t       length[4], &simPcrs[bankNum][4].digest.tssmax,\n\t\t\t\t       length[5], &simPcrs[bankNum][5].digest.tssmax,\n\t\t\t\t       length[6], &simPcrs[bankNum][6].digest.tssmax,\n\t\t\t\t       length[7], &simPcrs[bankNum][7].digest.tssmax,\n\t\t\t\t       length[8], &simPcrs[bankNum][8].digest.tssmax,\n\t\t\t\t       length[9], &simPcrs[bankNum][9].digest.tssmax,\n\t\t\t\t       length[10], &simPcrs[bankNum][10].digest.tssmax,\n\t\t\t\t       length[11], &simPcrs[bankNum][11].digest.tssmax,\n\t\t\t\t       length[12], &simPcrs[bankNum][12].digest.tssmax,\n\t\t\t\t       length[13], &simPcrs[bankNum][13].digest.tssmax,\n\t\t\t\t       length[14], &simPcrs[bankNum][14].digest.tssmax,\n\t\t\t\t       length[15], &simPcrs[bankNum][15].digest.tssmax,\n\t\t\t\t       length[16], &simPcrs[bankNum][16].digest.tssmax,\n\t\t\t\t       length[17], &simPcrs[bankNum][17].digest.tssmax,\n\t\t\t\t       length[18], &simPcrs[bankNum][18].digest.tssmax,\n\t\t\t\t       length[19], &simPcrs[bankNum][19].digest.tssmax,\n\t\t\t\t       length[20], &simPcrs[bankNum][20].digest.tssmax,\n\t\t\t\t       length[21], &simPcrs[bankNum][21].digest.tssmax,\n\t\t\t\t       length[22], &simPcrs[bankNum][22].digest.tssmax,\n\t\t\t\t       length[23], &simPcrs[bankNum][23].digest.tssmax,\n\t\t\t\t       0, NULL);\n\t    }\n\t    /* trace the boot aggregate */\n\t    if (rc == 0) {\n\t\tif (!noSpace) {\n\t\t    TSS_PrintAllLogLevel(LOGLEVEL_INFO, \"\\nboot aggregate:\", 1,\n\t\t\t\t\t bootAggregates[bankNum].digest.tssmax,\n\t\t\t\t\t specIdEvent.digestSizes[bankNum].digestSize);\n\t\t}\n\t\telse {\t/* print with no spaces */\n\t\t    uint32_t bp;\n\t\t    printf(\"\\nboot aggregate: \");\n\t\t    for (bp = 0 ; bp < specIdEvent.digestSizes[bankNum].digestSize ; bp++) {\n\t\t\tprintf(\"%02x\", bootAggregates[bankNum].digest.tssmax[bp]);\n\t\t    }\n\t\t    printf(\"\\n\");\n\t\t}\n\t    }\n\t}\n    }\n    {\n\tif (tpm|| (sim && checkPcr)) {\n\t    TPM_RC rc1 = TSS_Delete(tssContext);\n\t    if (rc == 0) {\n\t\trc = rc1;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"eventextend: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"eventextend: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    if (infile != NULL) {\n\tfclose(infile);\n    }\n    return rc;\n}\n\n/* pcrExtend() extends the event into the TPM\n\n   If the event is EV_NO_ACTION -> StartupLocality, send a power cycle and a startup at the locality\n   in the event, typically locality 3.  This initializes PCR 0  to 00....0003.\n\n   Other EV_NO_ACTION events are skipped.\n\n   Other events extend the PCR.\n*/\n\nstatic uint32_t pcrExtend(TSS_CONTEXT\t\t*tssContext,\n\t\t\t  TCG_PCR_EVENT2 \t*event2)\n{\n    uint32_t \t\t\trc = 0;\n    size_t \t\t\ti;\n    PCR_Extend_In \t\tin;\n    PCR_Read_In \t\tpcrReadIn;\n    PCR_Read_Out \t\tpcrReadOut;\n\n    if (rc == 0) {\n\t/* handle EV_NO_ACTION */\n\tif (event2->eventType == EV_NO_ACTION) {\n\t    /* startup locality sets PCR 0 to the locality */\n\t    if ((event2->pcrIndex == 0) &&\n\t\t/* StartupLocality in the event is NUL terminated, locality is one byte */\n\t\t(event2->eventSize == (sizeof(\"StartupLocality\") + 1)) &&\n\t\t(memcmp(event2->event, \"StartupLocality\", sizeof(\"StartupLocality\")) == 0)) {\n\n\t\t/* poewr cycle the TPM to prepare for startup */\n\t\tif (rc == 0) {\t\t/* powerup platform port uses a separate TSS context */\n\t\t    rc = powerUp();\n\t\t}\n\t\t/* startup using the event specified locality */\n\t\tif (rc == 0) {\n\t\t    uint8_t locality = event2->event[sizeof(\"StartupLocality\")];\n\t\t    rc = startup(tssContext, locality);\n\t\t}\n\t    }\n\t    /* other EV_NO_ACTION events are ignored */\n\t    else {\n\t\treturn 0;\n\t    }\n\t}\n\t/* handle not EV_NO_ACTION */\n\telse {\n\t    in.pcrHandle = event2->pcrIndex;\n\t    in.digests = event2->digests;\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     NULL, \n\t\t\t     (COMMAND_PARAMETERS *)&in,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_PCR_Extend,\n\t\t\t     TPM_RS_PW, NULL, 0,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n    }\n    /* for debug, read back and trace the PCR value after the extend */\n    if ((rc == 0) && tssUtilsVerbose) {\n\tpcrReadIn.pcrSelectionIn.count = event2->digests.count;\n\tfor (i = 0 ; i < event2->digests.count ; i++ ) {\n\t    pcrReadIn.pcrSelectionIn.pcrSelections[i].hash =\n\t\tevent2->digests.digests[i].hashAlg;\n\t    pcrReadIn.pcrSelectionIn.pcrSelections[i].sizeofSelect = 3;\n\t    pcrReadIn.pcrSelectionIn.pcrSelections[i].pcrSelect[0] = 0;\n\t    pcrReadIn.pcrSelectionIn.pcrSelections[i].pcrSelect[1] = 0;\n\t    pcrReadIn.pcrSelectionIn.pcrSelections[i].pcrSelect[2] = 0;\n\t    pcrReadIn.pcrSelectionIn.pcrSelections[i].pcrSelect[event2->pcrIndex / 8] =\n\t\t1 << (event2->pcrIndex % 8);\n\t}\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&pcrReadOut,\n\t\t\t (COMMAND_PARAMETERS *)&pcrReadIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_PCR_Read,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    if ((rc == 0) && tssUtilsVerbose) {\n\tprintf(\"PCR Read %u\\n\", event2->pcrIndex);\n\tfor (i = 0 ; i < event2->digests.count ; i++ ) {\n\t    TSS_PrintAll(\"PCR digest\",\n\t\t\t pcrReadOut.pcrValues.digests[i].t.buffer,\n\t\t\t pcrReadOut.pcrValues.digests[i].t.size);\n\t}\n    }\n    return rc;\n}\n\nstatic uint32_t powerUp(void)\n{\n    uint32_t \t\t\trc = 0;\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n\n    if (rc == 0) {\t/* use a separate context for the command port */\n\trc = TSS_Create(&tssContext);\n    }\n    if (rc == 0) {\n\trc = TSS_TransmitPlatform(tssContext, TPM_SIGNAL_POWER_OFF, \"TPM2_PowerOffPlatform\");\n    }\n    /* power on platform */\n    if (rc == 0) {\n\trc = TSS_TransmitPlatform(tssContext, TPM_SIGNAL_POWER_ON, \"TPM2_PowerOnPlatform\");\n    }\n    /* power on NV */\n    if (rc == 0) {\n\trc = TSS_TransmitPlatform(tssContext, TPM_SIGNAL_NV_ON, \"TPM2_NvOnPlatform\");\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    return rc;\n}\n\nstatic uint32_t startup(TSS_CONTEXT\t*tssContext,\n\t\t\tuint8_t \tlocality)\n{\n    uint32_t \t\trc = 0;\n    Startup_In \t\tin;\n    char \t\tlocalityString[17];\t/* 17 to suppress false warning */\n\n    if (rc == 0) {\n\tmemset(localityString, 0, sizeof(localityString));\n\tsprintf(localityString, \"%.*u\", 1, locality);\n\tTSS_SetProperty(tssContext, TPM_TRANSMIT_LOCALITY, localityString);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\tin.startupType = TPM_SU_CLEAR;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Startup,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    TSS_SetProperty(tssContext, TPM_TRANSMIT_LOCALITY, NULL);\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"Usage: eventextend -if <measurement file> [-v]\\n\");\n    printf(\"\\n\");\n    printf(\"Extends a measurement file (binary) into a TPM or simulated PCRs\\n\");\n    printf(\"Ignores most EV_NO_ACTION events, but handles StartupLocality.\\n\");\n    printf(\"For -tpm, StartupLocality power cycles the TPM and sends TPM2_Startup\\n\");\n    printf(\"at the specified locality.\\n\");\n    printf(\"\\n\");\n    printf(\"A typical use is -tpm, -sim, and -checkpcr to extend PCRs, calculate\\n\");\n    printf(\"simulated PCRs, and compare the results.\\n\");\n    printf(\"\\n\");\n    printf(\"A typical use is just -v to parse and trace the event log details.\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-if\\tfile containing the data to be extended\\n\");\n    printf(\"\\t[-nospec\\tfile does not contain spec ID header (useful for incremental test)]\\n\");\n    printf(\"\\t[-tpm\\textend TPM PCRs]\\n\");\n    printf(\"\\t[-sim\\tcalculate simulated PCRs and boot aggregate]\\n\");\n    printf(\"\\t[-checkhash\\tverify event log hashes]\\n\");\n    printf(\"\\t[-checkpcr\\twith -sim verify PCR values]\\n\");\n    printf(\"\\t[-pcrmax\\twith -sim, sets the highest PCR number to be used to calculate the\\n\"\n\t   \"\\t\\tboot aggregate (default 7)]\\n\");\n    printf(\"\\t[-ns\\tno space, no text, no newlines when tracing PCRs and boot aggregate]\\n\");\n    printf(\"\\t[-v\\tverbose tracing]\\n\");\n    printf(\"\\n\");\n    exit(-1);\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/eventlib.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t     \tTPM2 Measurement Log Common Routines\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2016 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <inttypes.h>\n\n#include <ibmtss/tssprint.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsserror.h>\n#ifndef TPM_TSS_NOCRYPTO\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsscrypto.h>\n#endif /* TPM_TSS_NOCRYPTO */\n#include <ibmtss/tssutils.h>\n\n#include \"eventlib.h\"\n#include \"efilib.h\"\n\nextern int tssUtilsVerbose;\n\n/* NOTE: PFP is the TCG PC Client Platform Firmware Profile Specification\n*/\n\n#ifndef TPM_TSS_NOCRYPTO\n\n/* function prototypes for event callback table */\n\ntypedef uint32_t (*TSS_Event2_CheckHash_t)(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t   const TCG_EfiSpecIDEvent *specIdEvent);\n\n/* function callbacks */\n\nstatic uint32_t TSS_Event2_Checkhash_Unused(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t    const TCG_EfiSpecIDEvent *specIdEvent);\nstatic uint32_t TSS_Event2_Checkhash_EventHash(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t       const TCG_EfiSpecIDEvent *specIdEvent);\nstatic uint32_t TSS_Event2_Checkhash_Success(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t     const TCG_EfiSpecIDEvent *specIdEvent);\nstatic uint32_t TSS_Event2_Checkhash_VariableDataHash(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t\t      const TCG_EfiSpecIDEvent *specIdEvent);\nstatic uint32_t TSS_Event2_Checkhash_VariableDataAuthority(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t\t\t   const TCG_EfiSpecIDEvent *specIdEvent);\n\n#if 0\t/* currently unused */\nstatic uint32_t TSS_Event2_Checkhash_SignatureDataHash(TCG_PCR_EVENT2 *event2);\n#endif\n\n/* Tables to map eventType to hash check function callbacks.  NULL or missing entries return\n   TSS_RC_NOT_IMPLEMENTED.\n\n   The second check function, if not NULL, handles platforms that don't quite conform to the PTP.\n\n   EV_EFI_VARIABLE_BOOT: Dell and Lenovo hash the variabledata, HP hashes the entire event.\n*/\n\ntypedef struct {\n    uint32_t \t\t\teventType;\n    TSS_Event2_CheckHash_t\tcheckHashFunction1;\n    TSS_Event2_CheckHash_t\tcheckHashFunction2;\n} TSS_EVENT2_CHECKHASH_TABLE;\n\nconst TSS_EVENT2_CHECKHASH_TABLE event2CheckHashTable [] =\n    {\n     {EV_PREBOOT_CERT,\n      TSS_Event2_Checkhash_Unused,\t\t/* reserved */\n      NULL},\n     {EV_POST_CODE,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_UNUSED,\n      TSS_Event2_Checkhash_Unused,\t\t/* deprecated */\n      NULL},\n     {EV_NO_ACTION,\n      TSS_Event2_Checkhash_Success,\t\t/* does not extend PCRs */\n      NULL},\n     {EV_SEPARATOR,\n      TSS_Event2_Checkhash_EventHash,\n      NULL},\n     {EV_ACTION,\n      TSS_Event2_Checkhash_EventHash,\n      NULL},\n     {EV_EVENT_TAG,\n      TSS_Event2_Checkhash_EventHash,\n      NULL},\n     {EV_S_CRTM_CONTENTS,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_S_CRTM_VERSION,\n      TSS_Event2_Checkhash_EventHash,\n      NULL},\n     {EV_CPU_MICROCODE,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_PLATFORM_CONFIG_FLAGS,\n      TSS_Event2_Checkhash_EventHash,\n      NULL},\n     {EV_TABLE_OF_DEVICES,\n      TSS_Event2_Checkhash_Success,\t\t/* FIXME cannot be verified due to UEFI bug */\n      NULL},\n     {EV_COMPACT_HASH,\n      TSS_Event2_Checkhash_Success,\t\t/* FIXME PFP ambiguous */\n      NULL},\n     {EV_IPL,\n      TSS_Event2_Checkhash_Success,\t\t/* FIXME PFP ambiguous */\n      NULL},\n     {EV_IPL_PARTITION_DATA,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_NONHOST_CODE,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_NONHOST_CONFIG,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_NONHOST_INFO,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_OMIT_BOOT_DEVICE_EVENTS,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_EFI_VARIABLE_DRIVER_CONFIG,\n      TSS_Event2_Checkhash_EventHash,\n      NULL},\n     {EV_EFI_VARIABLE_BOOT,\n      TSS_Event2_Checkhash_VariableDataHash,\t/* PCR is hash of variable data */\n      TSS_Event2_Checkhash_EventHash},\t\t/* HP hashes entire event */\n     {EV_EFI_BOOT_SERVICES_APPLICATION,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_EFI_BOOT_SERVICES_DRIVER,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_EFI_RUNTIME_SERVICES_DRIVER,\n      NULL,\n      NULL},\n     {EV_EFI_GPT_EVENT,\n      TSS_Event2_Checkhash_EventHash,\t\t/* guess, PTP unclear */\n      NULL},\n     {EV_EFI_ACTION,\n      TSS_Event2_Checkhash_EventHash,\n      NULL},\n     {EV_EFI_PLATFORM_FIRMWARE_BLOB,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_EFI_HANDOFF_TABLES,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_EFI_PLATFORM_FIRMWARE_BLOB2,\n      TSS_Event2_Checkhash_Success,\t\t/* PCR does not contain hash of event */\n      NULL},\n     {EV_EFI_HANDOFF_TABLES2,\n      TSS_Event2_Checkhash_Success,\n      NULL},\n     {EV_EFI_HCRTM_EVENT,\n      NULL,\n      NULL},\n     {EV_EFI_VARIABLE_AUTHORITY,\n      TSS_Event2_Checkhash_EventHash,\t\t\t/* this is what vendors seem to do */\n      TSS_Event2_Checkhash_VariableDataAuthority},\t/* Supermicro quirk */\n     {EV_EFI_SUPERMICRO_1,\n      TSS_Event2_Checkhash_Success,\t\t/* unknown event Supermicro quirk */\n      NULL},\n    };\n\nstatic uint32_t TSS_Event2_Checkhash_GetTableIndex(size_t *index, uint32_t eventType);\n\n/* TSS_Event2_Checkhash_GetTableIndex() searches the event type table for the event handlers.\n\n   Returns TSS_RC_NOT_IMPLEMENTED if the event type is unknown.\n*/\n\nstatic uint32_t TSS_Event2_Checkhash_GetTableIndex(size_t *index, uint32_t eventType)\n{\n    for (*index = 0 ;\n\t *index < sizeof(event2CheckHashTable) / sizeof(TSS_EVENT2_CHECKHASH_TABLE) ;\n\t (*index)++) {\n\tif (event2CheckHashTable [*index].eventType == eventType) {\n\t    return 0;\t/* match */\n\t}\n    }\n    return TSS_RC_NOT_IMPLEMENTED;\t\t/* no match */\n}\n\n/*\n  Check Hash callbacks\n*/\n\n/* TSS_Event2_Checkhash_Unused() is used for events that are reserved, deprecated, or otherwise\n   unexpected and not handled */\n\nstatic uint32_t TSS_Event2_Checkhash_Unused(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t    const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    event2 = event2;\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n    return TSS_RC_NOT_IMPLEMENTED;\n}\n\n/* TSS_Event2_Checkhash_Success() is used for events that do not extend PCRs.  An example is\n   EV_NO_ACTION.\n\n   Normally Checkhash would not be called for these events, but returning success may simplfy\n   application code.\n*/\n\nstatic uint32_t TSS_Event2_Checkhash_Success(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t     const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    event2 = event2;\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n    return 0;\n}\n\nstatic uint32_t TSS_Event2_Checkhash_EventHash(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t       const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    int irc;\n    uint32_t count;\n    TPML_DIGEST_VALUES *digestValues = &event2->digests;\n\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n\n    for (count = 0 ; (rc == 0) && (count < digestValues ->count) ; count++) {\n\n\tTPMT_HA *pcrDigest = &(digestValues->digests[count]);\t/* value extended */\n\tTPMI_ALG_HASH hashAlg = pcrDigest->hashAlg;\n\tTPMT_HA eventDigest;\t\t\t\t/* value from event */\n\n\tif (rc == 0) {\n\t    eventDigest.hashAlg = hashAlg;\n\t    rc = TSS_Hash_Generate(&eventDigest,\n\t\t\t\t   event2->eventSize, event2->event,\n\t\t\t\t   0, NULL);\n\t}\n\tif (rc == 0) {\n\t    uint32_t sizeInBytes = TSS_GetDigestSize(hashAlg);\n#if 0\n\t    printf(\"TSS_Event2_Checkhash_EventHash: bytes to hash %u\\n\",\n\t\t   event2->eventSize);\n\t    printf(\"TSS_Event2_Checkhash_EventHash: first byte %02x\\n\", event2->event[0]);\n\t    printf(\"TSS_Event2_Checkhash_EventHash: last byte %02x\\n\",\n\t\t   event2->event[event2->eventSize-1]);\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"TSS_Event2_Checkhash_EventHash: PCR\",\n\t\t\t\t\t      (uint8_t *)&pcrDigest->digest, sizeInBytes);\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"TSS_Event2_Checkhash_EventHash: event\",\n\t\t\t\t\t      (uint8_t *)&eventDigest.digest, sizeInBytes);\n#endif\n\t    irc = memcmp((uint8_t *)&pcrDigest->digest,\n\t\t\t (uint8_t *)&eventDigest.digest,\n\t\t\t sizeInBytes);\n\t    if (irc != 0) {\n#if 0\n\t\tprintf(\"TSS_Event2_Checkhash_EventHash: \"\n\t\t       \"ERROR: hash mismatch PCR %08x, event type %08x hash alg %08x\\n\",\n\t\t       event2->pcrIndex, event2->eventType, hashAlg);\n#endif\n\t\trc = TSS_RC_HASH;\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Event2_Checkhash_VariableDataHash() events extend just the VariableData, not the entire\n   event\n*/\n\nstatic uint32_t TSS_Event2_Checkhash_VariableDataHash(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t\t      const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    int irc;\n    uint32_t count;\n    TPML_DIGEST_VALUES *digestValues = &event2->digests;\n    TSST_EFIData *efiData = NULL;\n    uint8_t *VariableData;\n    uint64_t VariableDataLength;\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n\n    /* Parse the event and get the VariableData */\n    if (rc == 0) {\n\trc = TSS_EFIData_Init(&efiData, event2->eventType, specIdEvent);\n    }\n    if (rc == 0) {\n\trc = TSS_EFIData_ReadBuffer(efiData, event2->event, event2->eventSize,\n\t\t\t\t    event2->pcrIndex, specIdEvent);\n    }\n    /* get the VariableData and its length from the structure */\n    if (rc == 0) {\n\tVariableData = efiData->efiData.uefiVariableData.VariableData;\n\tVariableDataLength = efiData->efiData.uefiVariableData.VariableDataLength;\n    }\n    for (count = 0 ; (rc == 0) && (count < digestValues ->count) ; count++) {\n\n\tTPMT_HA *pcrDigest = &(digestValues->digests[count]);\t/* value extended */\n\tTPMI_ALG_HASH hashAlg = pcrDigest->hashAlg;\n\tTPMT_HA variableDataDigest;\t\t\t\t/* value from event */\n\n\tif (rc == 0) {\n\t    variableDataDigest.hashAlg = hashAlg;\n\t    rc = TSS_Hash_Generate(&variableDataDigest,\n\t\t\t\t   (uint32_t)VariableDataLength, VariableData,\n\t\t\t\t   0, NULL);\n\t}\n\tif (rc == 0) {\n\t    uint32_t sizeInBytes = TSS_GetDigestSize(hashAlg);\n#if 0\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"TSS_Event2_Checkhash_VariableDataHash: PCR\",\n\t\t\t\t\t      (uint8_t *)&pcrDigest->digest, sizeInBytes);\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"TSS_Event2_Checkhash_VariableDataHash: VariableData\",\n\t\t\t\t\t      (uint8_t *)&variableDataDigest.digest, sizeInBytes);\n#endif\n\t    irc = memcmp((uint8_t *)&pcrDigest->digest,\n\t\t\t (uint8_t *)&variableDataDigest.digest,\n\t\t\t sizeInBytes);\n\t    if (irc != 0) {\n#if 0\n\t\tprintf(\"TSS_Event2_Checkhash_VariableDataHash:\\n\"\n\t\t       \"\\tERROR: hash mismatch PCR %08x, event type %08x hash alg %08x\\n\",\n\t\t       event2->pcrIndex, event2->eventType, hashAlg);\n#endif\n\t\trc = TSS_RC_HASH;\n\t    }\n\t}\n    }\n    TSS_EFIData_Free(efiData, specIdEvent);\n    return rc;\n}\n\n/* TSS_Event2_Checkhash_VariableDataAuthority() handles a Supermicro EV_EFI_VARIABLE_AUTHORITY event\n   that has an off by one error.  The last byte of the event is not hashed.\n*/\n\nstatic uint32_t TSS_Event2_Checkhash_VariableDataAuthority(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t\t\t   const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    int irc;\n    uint32_t count;\n    TPML_DIGEST_VALUES *digestValues = &event2->digests;\n    uint32_t offByOne = 1;\t/* Supermicro bug */\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n\n    for (count = 0 ; (rc == 0) && (count < digestValues ->count) ; count++) {\n\n\tTPMT_HA *pcrDigest = &(digestValues->digests[count]);\t/* value extended */\n\tTPMI_ALG_HASH hashAlg = pcrDigest->hashAlg;\n\tTPMT_HA eventDigest;\t\t\t\t/* value from event */\n\n\tif (rc == 0) {\n\t    eventDigest.hashAlg = hashAlg;\n\t    rc = TSS_Hash_Generate(&eventDigest,\n\t\t\t\t   (uint32_t)event2->eventSize-offByOne, event2->event,\n\t\t\t\t   0, NULL);\n\t}\n\tif (rc == 0) {\n\t    uint32_t sizeInBytes = TSS_GetDigestSize(hashAlg);\n#if 0\n\t    printf(\"TSS_Event2_Checkhash_VariableDataAuthority: bytes to hash %u\\n\",\n\t\t   (uint32_t)event2->eventSize-offByOne);\n\t    printf(\"TSS_Event2_Checkhash_VariableDataAuthority: first byte %02x\\n\",\n\t\t   event2->event[0]);\n\t    printf(\"TSS_Event2_Checkhash_VariableDataAuthority: last byte %02x\\n\",\n\t\t   event2->event[event2->eventSize-1-offByOne]);\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"TSS_Event2_Checkhash_VariableDataAuthority: PCR\",\n\t\t\t\t\t      (uint8_t *)&pcrDigest->digest, sizeInBytes);\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"TSS_Event2_Checkhash_VariableDataAuthority: event\",\n\t\t\t\t\t      (uint8_t *)&eventDigest.digest, sizeInBytes);\n#endif\n\t    irc = memcmp((uint8_t *)&pcrDigest->digest,\n\t\t\t (uint8_t *)&eventDigest.digest,\n\t\t\t sizeInBytes);\n\t    if (irc != 0) {\n\t\tprintf(\"TSS_Event2_Checkhash_VariableDataAuthority: \"\n\t\t       \"ERROR: hash mismatch PCR %08x, event type %08x hash alg %08x\\n\",\n\t\t       event2->pcrIndex, event2->eventType, hashAlg);\n\t\trc = TSS_RC_HASH;\n\t    }\n\t}\n    }\n    return rc;\n}\n\n#if 0\t/* Not used, OEMs seem to not follow the PFP */\n\n/* TSS_Event2_Checkhash_SignatureDataHash() events extend just the UEFI signature data, not the\n   entire event.\n\n   This function (untested) agrees with the PFP, although OEMs seem to do it differently.\n\n*/\n\nstatic uint32_t TSS_Event2_Checkhash_SignatureDataHash(TCG_PCR_EVENT2 *event2,\n\t\t\t\t\t\t       const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    int irc;\n    uint32_t count;\n    TPML_DIGEST_VALUES *digestValues = &event2->digests;\n    TSST_EFIData *efiData = NULL;\n    TSS_UEFI_VARIABLE_DATA *uefiVariableData;\n    uint8_t *hashData;\n    uint64_t hashDataLength;\n    uint32_t offset;\n    /*for future use, to handle PFP differences */\n    specIdEvent = specIdEvent;\n\n    /* Parse the event and get the VariableData */\n    if (rc == 0) {\n\trc = TSS_EFIData_Init(&efiData, event2->eventType);\n    }\n    if (rc == 0) {\n\trc = TSS_EFIData_ReadBuffer(efiData, event2->event, event2->eventSize, event2->pcrIndex);\n    }\n    /* get the hashed data and its length from the structure */\n    if (rc == 0) {\n\tuefiVariableData = &efiData->efiData.uefiVariableData;\n\t/* DB has a signature length */\n\tif (uefiVariableData->variableDataTag == VAR_DB) {\n\t    /* offset into event is variable GUID + 2 uint64_t lengths + UC16 \"DB\" */\n\t    offset = sizeof(efi_guid_t) + sizeof(uint64_t) + sizeof(uint64_t) + 4;\n\t}\n\telse if (uefiVariableData->variableDataTag == VAR_SHIM) {\n\t    /* offset into event is variable GUID + 2 uint64_t lengths + UC16 \"Shim\" */\n\t    offset = sizeof(efi_guid_t) + sizeof(uint64_t) + sizeof(uint64_t) + 8;\n\t}\n\telse if (uefiVariableData->variableDataTag == VAR_MOKLIST) {\n\t    /* offset into event is variable GUID + 2 uint64_t lengths + UC16 \"Moklist\" */\n\t    offset = sizeof(efi_guid_t) + sizeof(uint64_t) + sizeof(uint64_t) + 14;\n\t}\n\telse {\n\t    rc = TSS_RC_NOT_IMPLEMENTED;\n\t}\n\thashData = event2->event + offset;\n\thashDataLength = event2->eventSize - offset;\n    }\n   for (count = 0 ; (rc == 0) && (count < digestValues ->count) ; count++) {\n\n\tTPMT_HA *pcrDigest = &(digestValues->digests[count]);\t/* value extended */\n\tTPMI_ALG_HASH hashAlg = pcrDigest->hashAlg;\n\tTPMT_HA signatureDataDigest;\t\t\t\t/* value from event */\n\n\tif (rc == 0) {\n\t    signatureDataDigest.hashAlg = hashAlg;\n\t    rc = TSS_Hash_Generate(&signatureDataDigest,\n\t\t\t\t   (uint32_t)hashDataLength, hashData,\n\t\t\t\t   0, NULL);\n\t}\n\tif (rc == 0) {\n\t    uint32_t sizeInBytes = TSS_GetDigestSize(hashAlg);\n#if 0\n\t    printf(\"TSS_Event2_Checkhash_SignatureDataHash: bytes to hash %u\\n\",\n\t\t   (uint32_t)hashDataLength);\n\t    printf(\"TSS_Event2_Checkhash_SignatureDataHash: first byte %02x\\n\", hashData[0]);\n\t    printf(\"TSS_Event2_Checkhash_SignatureDataHash: last byte %02x\\n\",\n\t\t   hashData[hashDataLength-1]);\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"TSS_Event2_Checkhash_SignatureDataHash: PCR\",\n\t\t\t\t\t      (uint8_t *)&pcrDigest->digest, sizeInBytes);\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"TSS_Event2_Checkhash_SignatureDataHash: event\",\n\t\t\t\t\t      (uint8_t *)&signatureDataDigest.digest, sizeInBytes);\n#endif\n\t    irc = memcmp((uint8_t *)&pcrDigest->digest,\n\t\t\t (uint8_t *)&signatureDataDigest.digest,\n\t\t\t sizeInBytes);\n\t    if (irc != 0) {\n\t\tprintf(\"TSS_Event2_Checkhash_SignatureDataHash: \"\n\t\t       \"ERROR: hash mismatch PCR %08x, event type %08x hash alg %08x\\n\",\n\t\t       event2->pcrIndex, event2->eventType, hashAlg);\n\t\trc = TSS_RC_HASH;\n\t    }\n\t}\n    }\n    TSS_EFIData_Free(efiData);\n    return rc;\n}\n\n#endif\t/* function currently unused */\n\n/* TSS_EVENT2_Line_CheckHash() checks the event against the PCR hash.\n\n   A not implemented check returns TSS_RC_NOT_IMPLEMENTED.\n   A NULL entry in the table primary method returns TSS_RC_NOT_IMPLEMENTED.\n   A NULL entry in the table second method returns the error from the primary method.\n*/\n\nTPM_RC TSS_EVENT2_Line_CheckHash(TCG_PCR_EVENT2 *event,\n\t\t\t\t const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    size_t index;\n\n    /* if the eventType is not supported, returns TSS_RC_NOT_IMPLEMENTED */\n    if (rc == 0) {\n\trc = TSS_Event2_Checkhash_GetTableIndex(&index, event->eventType);\n    }\n    if (rc == 0) {\n\t/* if there is a primary method */\n\tif (event2CheckHashTable[index].checkHashFunction1 != NULL) {\n\t    /* try the primary method */\n\t    rc = event2CheckHashTable[index].checkHashFunction1(event, specIdEvent);\n\t    /* if the primary method failed, try the second, alternate */\n\t    if (rc != 0) {\n\t\t/* if there is a second method */\n\t\tif (event2CheckHashTable[index].checkHashFunction2 != NULL) {\n\t\t    /* try the second method */\n\t\t    rc = event2CheckHashTable[index].checkHashFunction2(event, specIdEvent);\n\t\t}\n\t\t/* else use the rc from the primary method */\n\t    }\n\t}\n\t/* no checkHashFunction1, not implemented */\n\telse {\n\t    rc = TSS_RC_NOT_IMPLEMENTED;\n\t}\n    }\n    if (rc != 0) {\n\tprintf(\"TSS_EVENT2_Line_CheckHash: Error: rc %08x\\n\", rc);\n    }\n    return rc;\n}\n\n#endif /* TPM_TSS_NOCRYPTO */\n\n#ifndef TPM_TSS_NOFILE\n#ifdef TPM_TPM20\nstatic uint16_t Uint16_Convert(uint16_t in);\n#endif /* TPM_TPM20 */\nstatic uint32_t Uint32_Convert(uint32_t in);\n#endif /* TPM_TSS_NOFILE */\nstatic void TSS_EVENT_EventType_Trace(uint32_t eventType);\nstatic TPM_RC TSS_SpecIdEventAlgorithmSize_Unmarshal(TCG_EfiSpecIdEventAlgorithmSize *algSize,\n\t\t\t\t\t\t     uint8_t **buffer,\n\t\t\t\t\t\t     uint32_t *size);\nstatic void TSS_SpecIdEventAlgorithmSize_Trace(TCG_EfiSpecIdEventAlgorithmSize *algSize);\n#ifdef TPM_TPM20\nstatic TPM_RC TSS_TPML_DIGEST_VALUES_LE_Unmarshalu(TPML_DIGEST_VALUES *target,\n\t\t\t\t\t\t   BYTE **buffer,\n\t\t\t\t\t\t   uint32_t *size);\nstatic TPM_RC TSS_TPMT_HA_LE_Unmarshalu(TPMT_HA *target, BYTE **buffer,\n\t\t\t\t\tuint32_t *size, BOOL allowNull);\nstatic TPM_RC TSS_TPMI_ALG_HASH_LE_Unmarshalu(TPMI_ALG_HASH *target,\n\t\t\t\t\t      BYTE **buffer, uint32_t *size,\n\t\t\t\t\t      BOOL allowNull);\nstatic TPM_RC TSS_TPML_DIGEST_VALUES_LE_Marshalu(const TPML_DIGEST_VALUES *source,\n\t\t\t\t\t\t uint16_t *written, BYTE **buffer,\n\t\t\t\t\t\t uint32_t *size);\nstatic TPM_RC TSS_TPM_ALG_ID_LE_Unmarshalu(TPM_ALG_ID *target,\n\t\t\t\t\t   BYTE **buffer, uint32_t *size);\nstatic TPM_RC TSS_TPMT_HA_LE_Marshalu(const TPMT_HA *source, uint16_t *written,\n\t\t\t\t      BYTE **buffer, uint32_t *size);\n#endif /* TPM_TPM20 */\n\n/* TSS_EVENT_Line_Read() reads a TPM 1.2 SHA-1 event line from a binary file inFile.\n\n */\n\n#ifndef TPM_TSS_NOFILE\nint TSS_EVENT_Line_Read(TCG_PCR_EVENT *event,\n\t\t\tint *endOfFile,\n\t\t\tFILE *inFile)\n{\n    int rc = 0;\n    size_t readSize;\n    *endOfFile = FALSE;\n\n    /* read the PCR index */\n    if (rc == 0) {\n\treadSize = fread(&(event->pcrIndex),\n\t\t\t sizeof(((TCG_PCR_EVENT *)NULL)->pcrIndex), 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"TSS_EVENT_Line_Read: Error, could not read pcrIndex, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    /* do the endian conversion from stream to uint32_t */\n    if (!*endOfFile && (rc == 0)) {\n\tevent->pcrIndex = Uint32_Convert(event->pcrIndex);\n    }\n    /* read the event type */\n    if (!*endOfFile && (rc == 0)) {\n\treadSize = fread(&(event->eventType),\n\t\t\t sizeof(((TCG_PCR_EVENT *)NULL)->eventType), 1, inFile);\n\tif (readSize != 1) {\n\t    printf(\"TSS_EVENT_Line_Read: Error, could not read eventType, returned %lu\\n\",\n\t\t   (unsigned long) readSize);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    /* do the endian conversion from stream to uint32_t */\n    if (!*endOfFile && (rc == 0)) {\n\tevent->eventType = Uint32_Convert(event->eventType);\n    }\n    /* read the digest */\n    if (!*endOfFile && (rc == 0)) {\n\treadSize = fread(&(event->digest),\n\t\t\t sizeof(((TCG_PCR_EVENT *)NULL)->digest), 1, inFile);\n\tif (readSize != 1) {\n\t    printf(\"TSS_EVENT_Line_Read: Error, could not read digest, returned %lu\\n\",\n\t\t   (unsigned long)readSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* read the event data size */\n    if (!*endOfFile && (rc == 0)) {\n\treadSize = fread(&(event->eventDataSize),\n\t\t\t sizeof(((TCG_PCR_EVENT *)NULL)->eventDataSize), 1, inFile);\n\tif (readSize != 1) {\n\t    printf(\"TSS_EVENT_Line_Read: Error, could not read event data size, returned %lu\\n\",\n\t\t   (unsigned long)readSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* do the endian conversion from stream to uint32_t */\n    if (!*endOfFile && (rc == 0)) {\n\tevent->eventDataSize = Uint32_Convert(event->eventDataSize);\n    }\n    /* bounds check the event data length */\n    if (!*endOfFile && (rc == 0)) {\n\tif (event->eventDataSize > sizeof(((TCG_PCR_EVENT *)NULL)->event)) {\n\t    printf(\"TSS_EVENT_Line_Read: Error, event data length too big: %u\\n\",\n\t\t   event->eventDataSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* read the event */\n    if (!*endOfFile && (rc == 0)) {\n\tmemset(event->event , 0, sizeof(((TCG_PCR_EVENT *)NULL)->event));\n\treadSize = fread(&(event->event),\n\t\t\t event->eventDataSize, 1, inFile);\n\tif (readSize != 1) {\n\t    printf(\"TSS_EVENT_Line_Read: Error, could not read event, returned %lu\\n\",\n\t\t   (unsigned long)readSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    return rc;\n}\n\n#endif /* TPM_TSS_NOFILE */\n\n/* TSS_EVENT_Line_Marshal() marshals a TCG_PCR_EVENT structure */\n\nTPM_RC TSS_EVENT_Line_Marshal(TCG_PCR_EVENT *source,\n\t\t\t      uint16_t *written, uint8_t **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->pcrIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->eventType, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->digest, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->eventDataSize, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->event, source->eventDataSize, written, buffer, size);\n    }\n    return rc;\n}\n\n/* TSS_EVENT_Line_Unmarshal() unmarshals a TCG_PCR_EVENT2 structure\n\n */\n\nTPM_RC TSS_EVENT_Line_Unmarshal(TCG_PCR_EVENT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->pcrIndex, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->eventType, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu((uint8_t *)target->digest, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->eventDataSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->eventDataSize > sizeof(target->event)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu((uint8_t *)target->event, target->eventDataSize, buffer, size);\n    }\n    return rc;\n}\n\n/*\n * TSS_EVENT_Line_LE_Unmarshal() Unmarshal LE buffer into a target TCG_PCR_EVENT\n*/\nTPM_RC TSS_EVENT_Line_LE_Unmarshal(TCG_PCR_EVENT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&target->pcrIndex, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&target->eventType, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu((uint8_t *)target->digest, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&target->eventDataSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->eventDataSize > sizeof(target->event)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu((uint8_t *)target->event, target->eventDataSize, buffer, size);\n    }\n    return rc;\n}\n\n#ifndef TPM_TSS_NOCRYPTO\n/* TSS_EVENT_PCR_Extend() extends PCR digest with the digest from the TCG_PCR_EVENT event log\n   entry.\n*/\n\nTPM_RC TSS_EVENT_PCR_Extend(TPMT_HA pcrs[IMPLEMENTATION_PCR],\n\t\t\t    TCG_PCR_EVENT *event)\n{\n    TPM_RC \t\trc = 0;\n    \n    /* validate PCR number */\n    if (rc == 0) {\n\tif (event->pcrIndex >= IMPLEMENTATION_PCR) {\n\t    printf(\"ERROR: TSS_EVENT_PCR_Extend: PCR number %u out of range\\n\", event->pcrIndex);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    /* process each event hash algorithm */\n    if (rc == 0) {\n\tpcrs[event->pcrIndex].hashAlg = TPM_ALG_SHA1;\t/* should already be initialized */\n\tif (rc == 0) {\n\t    rc = TSS_Hash_Generate(&pcrs[event->pcrIndex],\n\t\t\t\t   SHA1_DIGEST_SIZE, (uint8_t *)&pcrs[event->pcrIndex].digest,\n\t\t\t\t   SHA1_DIGEST_SIZE, &event->digest,\n\t\t\t\t   0, NULL);\n\t}\n    }\n    return rc;\n}\n#endif /* TPM_TSS_NOCRYPTO */\n\nvoid TSS_EVENT_Line_Trace(TCG_PCR_EVENT *event)\n{\n    printf(\"TSS_EVENT_Line_Trace: PCR index %u\\n\", event->pcrIndex);\n    TSS_EVENT_EventType_Trace(event->eventType);\n    TSS_PrintAll(\"TSS_EVENT_Line_Trace: PCR\",\n\t\t event->digest, sizeof(((TCG_PCR_EVENT *)NULL)->digest));\n    TSS_PrintAll(\"TSS_EVENT_Line_Trace: event\",\n\t\t event->event, event->eventDataSize);\n    if (event->eventType == EV_IPL) {\t/* this event appears to be printable strings */\n\tprintf(\" %.*s\\n\", event->eventDataSize, event->event);\n    }\n    return;\n}\n\n/* TSS_SpecIdEvent_Unmarshal() unmarshals the TCG_EfiSpecIDEvent structure.\n\n   The size and buffer are not moved, since this is the only structure in the event.\n*/\n\nTPM_RC TSS_SpecIdEvent_Unmarshal(TCG_EfiSpecIDEvent *specIdEvent,\n\t\t\t\t uint32_t eventSize,\n\t\t\t\t uint8_t *event)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tsize = eventSize;\t/* copy, because size and buffer are not moved */\n    uint8_t\t*buffer = event;\n    uint32_t \ti;\n\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(specIdEvent->signature, sizeof(specIdEvent->signature),\n\t\t\t     &buffer, &size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&(specIdEvent->platformClass), &buffer, &size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&(specIdEvent->specVersionMinor), &buffer, &size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&(specIdEvent->specVersionMajor), &buffer, &size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&(specIdEvent->specErrata), &buffer, &size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&(specIdEvent->uintnSize), &buffer, &size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&(specIdEvent->numberOfAlgorithms), &buffer, &size);\n    }\n    for (i = 0 ; (rc == 0) && (i < specIdEvent->numberOfAlgorithms) ; i++) {\n\trc = TSS_SpecIdEventAlgorithmSize_Unmarshal(&(specIdEvent->digestSizes[i]),\n\t\t\t\t\t\t    &buffer, &size);\n    }\t    \n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&(specIdEvent->vendorInfoSize), &buffer, &size);\n    }\n#if 0\t/* NOTE: Can never fail because vendorInfoSize is uint8_t and vendorInfo is 0xff bytes */\n    if (rc == 0) {\n\tif (specIdEvent->vendorInfoSize > sizeof(specIdEvent->vendorInfo)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n#endif\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(specIdEvent->vendorInfo, specIdEvent->vendorInfoSize,\n\t\t\t     &buffer, &size);\n    }\n    return rc;\n}\n\n/* TSS_SpecIdEventAlgorithmSize_Unmarshal() unmarshals the TCG_EfiSpecIdEventAlgorithmSize\n   structure */\n\nstatic TPM_RC TSS_SpecIdEventAlgorithmSize_Unmarshal(TCG_EfiSpecIdEventAlgorithmSize *algSize,\n\t\t\t\t\t\t     uint8_t **buffer,\n\t\t\t\t\t\t     uint32_t *size)\n{\n    TPM_RC\trc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&(algSize->algorithmId), buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Unmarshal(&(algSize->digestSize), buffer, size);\n    } \n    if (rc == 0) {\n\tuint16_t mappedDigestSize = TSS_GetDigestSize(algSize->algorithmId);\n\tif (mappedDigestSize != 0) {\n\t    if (mappedDigestSize != algSize->digestSize) {\n\t\tprintf(\"TSS_SpecIdEventAlgorithmSize_Unmarshal: \"\n\t\t       \"Error, inconsistent digest size, algorithm %04x size %u\\n\",\n\t\t       algSize->algorithmId, algSize->digestSize);\n\t\trc = TSS_RC_BAD_PROPERTY_VALUE;\n\t    }\n\t}\n    }\n    return rc;\n}\n\nvoid TSS_SpecIdEvent_Trace(TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t \ti;\n\n    /* normal case */\n    if (specIdEvent->signature[15] == '\\0')  {\n\tprintf(\"TSS_SpecIdEvent_Trace: signature: %s\\n\", specIdEvent->signature);\n    }\n    /* error case */\n    else {\n\tTSS_PrintAll(\"TSS_SpecIdEvent_Trace: signature\",\n\t\t     specIdEvent->signature, sizeof(specIdEvent->signature));\n    }\n    printf(\"TSS_SpecIdEvent_Trace: platformClass %08x\\n\", specIdEvent->platformClass);\n    printf(\"TSS_SpecIdEvent_Trace: specVersionMinor %02x\\n\", specIdEvent->specVersionMinor);\n    printf(\"TSS_SpecIdEvent_Trace: specVersionMajor %02x\\n\", specIdEvent->specVersionMajor);\n    printf(\"TSS_SpecIdEvent_Trace: specErrata %02x\\n\", specIdEvent->specErrata);\n    printf(\"TSS_SpecIdEvent_Trace: uintnSize %02x\\n\", specIdEvent->uintnSize);\n    printf(\"TSS_SpecIdEvent_Trace: numberOfAlgorithms %u\\n\", specIdEvent->numberOfAlgorithms);\n    for (i = 0 ; (i < specIdEvent->numberOfAlgorithms) ; i++) {\n\tTSS_SpecIdEventAlgorithmSize_Trace(&(specIdEvent->digestSizes[i]));\n    }\n    /* try for a printable string */\n    if (specIdEvent->vendorInfoSize > 0) {\n\tif (specIdEvent->vendorInfo[specIdEvent->vendorInfoSize-1] == '\\0')  {\n\t    printf(\"TSS_SpecIdEvent_Trace: vendorInfo: %s\\n\", specIdEvent->vendorInfo);\n\t}\n    }\n    /* if not, trace the bytes */\n    else {\n\tTSS_PrintAll(\"TSS_SpecIdEvent_Trace: vendorInfo\",\n\t\t     specIdEvent->vendorInfo, specIdEvent->vendorInfoSize);\n    }\n    return;\n}\n\nstatic void TSS_SpecIdEventAlgorithmSize_Trace(TCG_EfiSpecIdEventAlgorithmSize *algSize)\n{\n    printf(\"TSS_SpecIdEventAlgorithmSize_Trace: algorithmId %04x\\n\", algSize->algorithmId);\n    printf(\"TSS_SpecIdEventAlgorithmSize_Trace: digestSize %u\\n\", algSize->digestSize);\n    return;\n}\n\n#ifdef TPM_TPM20\n#ifndef TPM_TSS_NOFILE\n\n/* TSS_EVENT2_Line_Read() reads a TPM2 event line from a binary file inFile.\n\n*/\n\nint TSS_EVENT2_Line_Read(TCG_PCR_EVENT2 *event,\n\t\t\t int *endOfFile,\n\t\t\t FILE *inFile)\n{\n    int rc = 0;\n    size_t readSize;\n    uint32_t maxCount; \n    uint32_t count;\n\n    *endOfFile = FALSE;\n    /* read the PCR index */\n    if (rc == 0) {\n\treadSize = fread(&(event->pcrIndex),\n\t\t\t sizeof(((TCG_PCR_EVENT2 *)NULL)->pcrIndex), 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"TSS_EVENT2_Line_Read: Error, could not read pcrIndex, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    /* do the endian conversion from stream to uint32_t */\n    if (!*endOfFile && (rc == 0)) {\n\tevent->pcrIndex = Uint32_Convert(event->pcrIndex);\n    }\n    /* read the event type */\n    if (!*endOfFile && (rc == 0)) {\n\treadSize = fread(&(event->eventType),\n\t\t\t sizeof(((TCG_PCR_EVENT2 *)NULL)->eventType), 1, inFile);\n\tif (readSize != 1) {\n\t    printf(\"TSS_EVENT2_Line_Read: Error, could not read eventType, returned %lu\\n\",\n\t\t   (unsigned long)readSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* do the endian conversion from stream to uint32_t */\n    if (!*endOfFile && (rc == 0)) {\n\tevent->eventType = Uint32_Convert(event->eventType);\n    }\n    /* read the TPML_DIGEST_VALUES count */\n    if (!*endOfFile && (rc == 0)) {\n\tmaxCount = sizeof((TPML_DIGEST_VALUES *)NULL)->digests / sizeof(TPMT_HA);\n\treadSize = fread(&(event->digests.count),\n\t\t\t sizeof(((TPML_DIGEST_VALUES *)NULL)->count), 1, inFile);\n\tif (readSize != 1) {\n\t    printf(\"TSS_EVENT2_Line_Read: Error, could not read digest count, returned %lu\\n\",\n\t\t   (unsigned long)readSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* do the endian conversion from stream to uint32_t */\n    if (!*endOfFile && (rc == 0)) {\n\tevent->digests.count = Uint32_Convert(event->digests.count);\n    }\n    /* range check the digest count */\n    if (!*endOfFile && (rc == 0)) {\n\tif (event->digests.count > maxCount) {\n\t    printf(\"TSS_EVENT2_Line_Read: Error, digest count %u is greater than structure %u\\n\",\n\t\t   event->digests.count, maxCount);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse if (event->digests.count == 0) {\n\t    printf(\"TSS_EVENT2_Line_Read: Error, digest count is zero\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* read all the TPMT_HA, loop through all the digest algorithms */\n    for (count = 0 ; !*endOfFile && (count < event->digests.count) ; count++) {\n\tuint16_t digestSize;\n\t/* read the digest algorithm */\n\tif (rc == 0) {\n\t    readSize = fread(&(event->digests.digests[count].hashAlg),\n\t\t\t     sizeof((TPMT_HA *)NULL)->hashAlg, 1, inFile);\n\t    if (readSize != 1) {\n\t\tprintf(\"TSS_EVENT2_Line_Read: \"\n\t\t       \"Error, could not read digest algorithm, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n\t/* do the endian conversion of the hash algorithm from stream to uint16_t */\n\tif (rc == 0) {\n\t    event->digests.digests[count].hashAlg =\n\t\tUint16_Convert(event->digests.digests[count].hashAlg);\n\t}\n\t/* map from the digest algorithm to the digest length */\n\tif (rc == 0) {\n\t    digestSize = TSS_GetDigestSize(event->digests.digests[count].hashAlg);\n\t    if (digestSize == 0) {\n\t\tprintf(\"TSS_EVENT2_Line_Read: Error, unknown digest algorithm %04x*\\n\",\n\t\t       event->digests.digests[count].hashAlg);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n\t/* read the digest */\n\tif (rc == 0) {\n\t    readSize = fread((uint8_t *)&(event->digests.digests[count].digest),\n\t\t\t     digestSize, 1, inFile);\n\t    if (readSize != 1) {\n\t\tprintf(\"TSS_EVENT2_Line_Read: Error, could not read digest, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    /* read the event size */\n    if (!*endOfFile && (rc == 0)) {\n\treadSize = fread(&(event->eventSize),\n\t\t\t sizeof(((TCG_PCR_EVENT2 *)NULL)->eventSize), 1, inFile);\n\tif (readSize != 1) {\n\t    printf(\"TSS_EVENT2_Line_Read: Error, could not read event size, returned %lu\\n\",\n\t\t   (unsigned long)readSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* do the endian conversion from stream to uint32_t */\n    if (!*endOfFile && (rc == 0)) {\n\tevent->eventSize = Uint32_Convert(event->eventSize);\n    }\n    /* bounds check the event size */\n    if (!*endOfFile && (rc == 0)) {\n\tif (event->eventSize > sizeof(((TCG_PCR_EVENT2 *)NULL)->event)) {\n\t    printf(\"TSS_EVENT2_Line_Read: Error, event size too big: %u\\n\",\n\t\t   event->eventSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* read the event */\n    if (!*endOfFile && (event->eventSize > 0) && (rc == 0)) {\n\tmemset(event->event , 0, sizeof(((TCG_PCR_EVENT2 *)NULL)->event));\n\treadSize = fread(&(event->event),\n\t\t\t event->eventSize, 1, inFile);\n\tif (readSize != 1) {\n\t    printf(\"TSS_EVENT2_Line_Read: Error, could not read event, returned %lu\\n\",\n\t\t   (unsigned long)readSize);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    return rc;\n}\n#endif /* TPM_TSS_NOFILE */\n\n/* TSS_EVENT2_Line_Marshal() marshals a TCG_PCR_EVENT2 structure */\n\nTPM_RC TSS_EVENT2_Line_Marshal(TCG_PCR_EVENT2 *source,\n\t\t\t       uint16_t *written, uint8_t **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->pcrIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->eventType, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_DIGEST_VALUES_Marshalu(&source->digests, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->eventSize, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu((uint8_t *)source->event, source->eventSize, written, buffer, size);\n    }\n    return rc;\n}\n\n/*\n * TSS_EVENT2_Line_LE_Marshal() Marshals a TSS_EVENT2 structure from HBO into LE\n * and saves to buffer.\n */\nTPM_RC TSS_EVENT2_Line_LE_Marshal(TCG_PCR_EVENT2 *source, uint16_t *written,\n\t\t\t\t  uint8_t **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Marshal(&source->pcrIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Marshal(&source->eventType, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_DIGEST_VALUES_LE_Marshalu(&source->digests, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Marshal(&source->eventSize, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu((uint8_t *)source->event, source->eventSize, written, buffer, size);\n    }\n    return rc;\n}\n\n/* TSS_EVENT2_Line_Unmarshal() unmarshals a TCG_PCR_EVENT2 structure */\n\n\nTPM_RC TSS_EVENT2_Line_Unmarshal(TCG_PCR_EVENT2 *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->pcrIndex, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->eventType, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_DIGEST_VALUES_Unmarshalu(&target->digests, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->eventSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->eventSize > sizeof(target->event)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu((uint8_t *)target->event, target->eventSize, buffer, size);\n    }\n    return rc;\n}\n\n/*\n * TSS_EVENT2_Line_LE_Unmarshal() Unmarshals an LE eventlog buffer and save to\n * the target TCG_PCR_EVENT2\n */\nTPM_RC TSS_EVENT2_Line_LE_Unmarshal(TCG_PCR_EVENT2 *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&target->pcrIndex, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&target->eventType, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_DIGEST_VALUES_LE_Unmarshalu(&target->digests, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Unmarshal(&target->eventSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->eventSize > sizeof(target->event)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu((uint8_t *)target->event, target->eventSize, buffer, size);\n    }\n    return rc;\n}\n\n#ifndef TPM_TSS_NOCRYPTO\n\n/* TSS_EVENT2_PCR_Extend() extends PCR digests with the digest from the TCG_PCR_EVENT2 event log\n   entry.\n\n   It ignores EV_NO_ACTION events except for StartupLocality.  StartupLocality resets the simulated\n   PCR 0 to the locality.\n\n   It assumes that the hash algorithm for the entire HASH_COUNT array is initialized.  Use\n   TPM_ALG_NULL for unused banks.\n*/\n\nTPM_RC TSS_EVENT2_PCR_Extend(TPMT_HA pcrs[HASH_COUNT][IMPLEMENTATION_PCR],\n\t\t\t     TCG_PCR_EVENT2 *event2)\n{\n    TPM_RC \t\trc = 0;\n    uint32_t \t\ti;\t\t/* iterator though hash algorithms */\n    uint32_t \t\tbankNum = 0;\t/* iterator though PCR hash banks */\n    uint16_t \t\tdigestSize;\n\n    /* validate event count */\n    if (rc == 0) {\n\tuint32_t maxCount = sizeof(((TPML_DIGEST_VALUES *)NULL)->digests) / sizeof(TPMT_HA);\n\tif (event2->digests.count > maxCount) {\n\t    printf(\"ERROR: TSS_EVENT2_PCR_Extend: PCR count %u out of range, max %u\\n\",\n\t\t   event2->digests.count, maxCount);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t} \n    }\n    /*\n      This logic handles EV_NO_ACTION -> StartupLocality.  If that event is encountered, set PCR 0\n      to the locality value before the extend.\n\n      This logic assumes that pcrs[] has been initialized to all zero.  The caller does this as part\n      of the simulated (event log replay) PCR calculation.\n\n      An error case is this event when PCR 0 is not zero.  Ignore it here since that would just be\n      an attestation client DoS'ing itself.  I.e., the attacker can reset PCR 0 in this simulation\n      calculation, but cannot reset the TPM PCR 0.\n\n      The event is a fixed value, \" StartupLocality\" plus a byte locality (e.g., for locality\n      3)\n\n      53 74 61 72 74 75 70 4c 6f 63 61 6c 69 74 79 00\n      03 \n\n    */\n    if (rc == 0) {\n\tif (event2->eventType == EV_NO_ACTION) {\n\t    if ((event2->pcrIndex == 0) &&\n\t\t(event2->eventSize == (sizeof(\"StartupLocality\") + 1)) &&\n\t\t(memcmp(event2->event, \"StartupLocality\", sizeof(\"StartupLocality\")) == 0)) {\n\n\t\tuint8_t locality = event2->event[sizeof(\"StartupLocality\")];\n\t\tfor (i = 0; (rc == 0) && (i < event2->digests.count) ; i++) {\n\t\t    digestSize = TSS_GetDigestSize(pcrs[i][0].hashAlg);\n\t\t    pcrs[i][0].digest.tssmax[digestSize-1] = locality;\n\t\t}\n\t    }\n\t    /* no 'else', other EV_NO_ACTION events are ignored */\n\t}\n\t/* not EV_NO_ACTION */\n\telse {\n\t    /* Range check event PCR number.  Do not do this test for EV_NO_ACTION, which can have\n\t       non-standard PCR values like 0xffffffff */\n\t    if (rc == 0) {\n\t\tif (event2->pcrIndex >= IMPLEMENTATION_PCR) {\n\t\t    printf(\"ERROR: TSS_EVENT2_PCR_Extend: PCR number %u out of range\\n\",\n\t\t\t   event2->pcrIndex);\n\t\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t\t}\n\t    }\n\t    /* process each event hash algorithm */\n\t    for (i = 0; (rc == 0) && (i < event2->digests.count) ; i++) {\n\t\t/* find the simulated PCR bank matching the event at count i */\n\t\tfor (bankNum = 0 ; (rc == 0) && (bankNum < HASH_COUNT) ; bankNum++) {\n\t\t    if (pcrs[bankNum][0].hashAlg == event2->digests.digests[i].hashAlg) {\n\n\t\t\tif (rc == 0) {\n\t\t\t    digestSize = TSS_GetDigestSize(event2->digests.digests[i].hashAlg);\n\t\t\t    if (digestSize == 0) {\n\t\t\t\tprintf(\"ERROR: TSS_EVENT2_PCR_Extend: hash algorithm %04hx unknown\\n\",\n\t\t\t\t       event2->digests.digests[i].hashAlg);\n\t\t\t\trc = TSS_RC_BAD_HASH_ALGORITHM;\n\t\t\t    }\n\t\t\t}\n\t\t\tif (rc == 0) {\n\t\t\t    rc = TSS_Hash_Generate(&pcrs[bankNum][event2->pcrIndex],\n\t\t\t\t\t\t   digestSize,\n\t\t\t\t\t\t   (uint8_t *)&pcrs[bankNum][event2->pcrIndex].digest,\n\t\t\t\t\t\t   digestSize,\n\t\t\t\t\t\t   &event2->digests.digests[i].digest,\n\t\t\t\t\t\t   0, NULL);\n\t\t\t}\n\t\t\tbreak;\t/* stop scanning pcrs[] banks on match */\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n#if 0\t/* for debug, trace the PCR calculation after each extend */\n    if (tssUtilsVerbose) {\n\t/* process each event hash algorithm */\n\tfor (i = 0; (rc == 0) && (i < event2->digests.count) ; i++) {\n\t    digestSize = TSS_GetDigestSize(event2->digests.digests[i].hashAlg);\n\t    TSS_PrintAll(\"TSS_EVENT2_PCR_Extend:\",\n\t\t\t (uint8_t *)&pcrs[i][event2->pcrIndex].digest, digestSize);\n\t}\n    }\n#endif\n    return rc;\n}\n\n#endif /* TPM_TSS_NOCRYPTO */\n#endif\t/* TPM_TPM20 */\n\n#ifndef TPM_TSS_NOFILE\n#ifdef TPM_TPM20\n\n/* Uint16_Convert() converts a little endian uint16_t (from an input stream) to host byte order\n */\n\nstatic uint16_t Uint16_Convert(uint16_t in)\n{\n    uint16_t out = 0;\n    unsigned char *inb = (unsigned char *)&in;\n    \n    /* little endian input */\n    out = (inb[0] <<  0) |\n\t  (inb[1] <<  8);\n    return out;\n}\n\n#endif\n\n/* Uint32_Convert() converts a little endian uint32_t (from an input stream) to host byte order\n */\n\nstatic uint32_t Uint32_Convert(uint32_t in)\n{\n    uint32_t out = 0;\n    unsigned char *inb = (unsigned char *)&in;\n\n    /* little endian input */\n    out = ((((uint32_t)inb[0]) <<  0) |\n\t   (((uint32_t)inb[1]) <<  8) |\n\t   (((uint32_t)inb[2]) << 16) |\n\t   (((uint32_t)inb[3]) << 24));\n    return out;\n}\n#endif /* TPM_TSS_NOFILE */\n\n/* TSS_UINT16LE_Unmarshal() unmarshals a little endian 2-byte array from buffer into a HBO uint16_t */\n\nTPM_RC TSS_UINT16LE_Unmarshal(uint16_t *target, BYTE **buffer, uint32_t *size)\n{\n    if (*size < sizeof(uint16_t)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = ((uint16_t)((*buffer)[0]) <<  0) |\n\t      ((uint16_t)((*buffer)[1]) <<  8);\n    *buffer += sizeof(uint16_t);\n    *size -= sizeof(uint16_t);\n    return TPM_RC_SUCCESS;\n}\n\n/* TSS_UINT32LE_Unmarshal() unmarshals a little endian 4-byte array from buffer into a HBO uint32_t */\n\nTPM_RC TSS_UINT32LE_Unmarshal(uint32_t *target, BYTE **buffer, uint32_t *size)\n{\n    if (*size < sizeof(uint32_t)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = ((uint32_t)((*buffer)[0]) <<  0) |\n\t      ((uint32_t)((*buffer)[1]) <<  8) |\n\t      ((uint32_t)((*buffer)[2]) << 16) |\n\t      ((uint32_t)((*buffer)[3]) << 24);\n    *buffer += sizeof(uint32_t);\n    *size -= sizeof(uint32_t);\n    return TPM_RC_SUCCESS;\n}\n\n/* TSS_UINT64LE_Unmarshal() unmarshals a little endian 8-byte array from buffer into a HBO uint64_t */\n\nTPM_RC TSS_UINT64LE_Unmarshal(uint64_t *target, BYTE **buffer, uint32_t *size)\n{\n    if (*size < sizeof(uint64_t)) {\n\treturn TPM_RC_INSUFFICIENT;\n    }\n    *target = ((uint64_t)((*buffer)[0]) <<  0) |\n\t      ((uint64_t)((*buffer)[1]) <<  8) |\n\t      ((uint64_t)((*buffer)[2]) << 16) |\n\t      ((uint64_t)((*buffer)[3]) << 24) |\n\t      ((uint64_t)((*buffer)[4]) << 32) |\n\t      ((uint64_t)((*buffer)[5]) << 40) |\n\t      ((uint64_t)((*buffer)[6]) << 48) |\n\t      ((uint64_t)((*buffer)[7]) << 56);\n    *buffer += sizeof(uint64_t);\n    *size -= sizeof(uint64_t);\n    return TPM_RC_SUCCESS;\n}\n\n/* TSS_EVENT2_Line_Trace() is a deprecated function that cannot handle different PC Client PFP\n   specifications.\n*/\n\nvoid TSS_EVENT2_Line_Trace(TCG_PCR_EVENT2 *event)\n{\n    TSS_EVENT2_Line_Trace2(event, NULL);\n    return;\n}\n\n/* TSS_EVENT2_Line_Trace2() is recommended.  It adds the TCG_EfiSpecIDEvent parameter, which can\n   eventually handle updates to the PC Client PFP specifications.\n\n   A NULL TCG_EfiSpecIDEvent is permissible as a default to the TSS_EVENT2_Line_Trace() behavior.\n*/\n\nvoid TSS_EVENT2_Line_Trace2(TCG_PCR_EVENT2 *event,\n\t\t\t    const TCG_EfiSpecIDEvent *specIdEvent)\n{\n    uint32_t rc = 0;\n    uint32_t count;\n    uint16_t digestSize;\n    TSST_EFIData *efiData = NULL;\n    printf(\"TSS_EVENT2_Line_Trace: PCR index %u\\n\", event->pcrIndex);\n    TSS_EVENT_EventType_Trace(event->eventType);\n    printf(\"TSS_EVENT2_Line_Trace: digest count %u\\n\", event->digests.count);\n    for (count = 0 ; count < event->digests.count ; count++) {\n\tprintf(\"TSS_EVENT2_Line_Trace: digest %u algorithm %04x\\n\",\n\t       count, event->digests.digests[count].hashAlg);\n\tdigestSize = TSS_GetDigestSize(event->digests.digests[count].hashAlg);\n\tTSS_PrintAll(\"TSS_EVENT2_Line_Trace: PCR\",\n\t\t     (uint8_t *)&event->digests.digests[count].digest, digestSize);\n    }\n    TSS_PrintAll(\"TSS_EVENT2_Line_Trace: event\",\n\t\t event->event, event->eventSize);\n    /* trace down into the EFI event */\n    if (rc == 0) {\n\trc = TSS_EFIData_Init(&efiData, event->eventType, specIdEvent);\n    }\n    if (rc == 0) {\n\trc = TSS_EFIData_ReadBuffer(efiData, event->event, event->eventSize,\n\t\t\t\t    event->pcrIndex, specIdEvent);\n    }\n    if (rc == 0) {\n\tTSS_EFIData_Trace(efiData, specIdEvent);\n    }\n    TSS_EFIData_Free(efiData, specIdEvent);\n    return;\n}\n\n/* tables to map eventType to text */\n\ntypedef struct {\n    uint32_t eventType;\n    const char *text;\n} EVENT_TYPE_TABLE;\n\nconst EVENT_TYPE_TABLE eventTypeTable [] = {\n    {EV_PREBOOT_CERT, \"EV_PREBOOT_CERT\"},\n    {EV_POST_CODE, \"EV_POST_CODE\"},\n    {EV_UNUSED, \"EV_UNUSED\"},\n    {EV_NO_ACTION, \"EV_NO_ACTION\"},\n    {EV_SEPARATOR, \"EV_SEPARATOR\"},\n    {EV_ACTION, \"EV_ACTION\"},\n    {EV_EVENT_TAG, \"EV_EVENT_TAG\"},\n    {EV_S_CRTM_CONTENTS, \"EV_S_CRTM_CONTENTS\"},\n    {EV_S_CRTM_VERSION, \"EV_S_CRTM_VERSION\"},\n    {EV_CPU_MICROCODE, \"EV_CPU_MICROCODE\"},\n    {EV_PLATFORM_CONFIG_FLAGS, \"EV_PLATFORM_CONFIG_FLAGS\"},\n    {EV_TABLE_OF_DEVICES, \"EV_TABLE_OF_DEVICES\"},\n    {EV_COMPACT_HASH, \"EV_COMPACT_HASH\"},\n    {EV_IPL, \"EV_IPL\"},\n    {EV_IPL_PARTITION_DATA, \"EV_IPL_PARTITION_DATA\"},\n    {EV_NONHOST_CODE, \"EV_NONHOST_CODE\"},\n    {EV_NONHOST_CONFIG, \"EV_NONHOST_CONFIG\"},\n    {EV_NONHOST_INFO, \"EV_NONHOST_INFO\"},\n    {EV_OMIT_BOOT_DEVICE_EVENTS, \"EV_OMIT_BOOT_DEVICE_EVENTS\"},\n    {EV_EFI_EVENT_BASE, \"EV_EFI_EVENT_BASE\"},\n    {EV_EFI_VARIABLE_DRIVER_CONFIG, \"EV_EFI_VARIABLE_DRIVER_CONFIG\"},\n    {EV_EFI_VARIABLE_BOOT, \"EV_EFI_VARIABLE_BOOT\"},\n    {EV_EFI_BOOT_SERVICES_APPLICATION, \"EV_EFI_BOOT_SERVICES_APPLICATION\"},\n    {EV_EFI_BOOT_SERVICES_DRIVER, \"EV_EFI_BOOT_SERVICES_DRIVER\"},\n    {EV_EFI_RUNTIME_SERVICES_DRIVER, \"EV_EFI_RUNTIME_SERVICES_DRIVER\"},\n    {EV_EFI_GPT_EVENT, \"EV_EFI_GPT_EVENT\"},\n    {EV_EFI_ACTION, \"EV_EFI_ACTION\"},\n    {EV_EFI_PLATFORM_FIRMWARE_BLOB, \"EV_EFI_PLATFORM_FIRMWARE_BLOB\"},\n    {EV_EFI_HANDOFF_TABLES, \"EV_EFI_HANDOFF_TABLES\"},\n    {EV_EFI_PLATFORM_FIRMWARE_BLOB2, \"EV_EFI_PLATFORM_FIRMWARE_BLOB2\"},\n    {EV_EFI_HANDOFF_TABLES2, \"EV_EFI_HANDOFF_TABLES2\"},\n    {EV_EFI_HCRTM_EVENT, \"EV_EFI_HCRTM_EVENT\"},\n    {EV_EFI_VARIABLE_AUTHORITY, \"EV_EFI_VARIABLE_AUTHORITY\"},\n    {EV_EFI_SUPERMICRO_1, \"EV_EFI_SUPERMICRO_1\"}\n};\n\nstatic void TSS_EVENT_EventType_Trace(uint32_t eventType)\n{\n    size_t i;\n\n    for (i = 0 ; i < sizeof(eventTypeTable) / sizeof(EVENT_TYPE_TABLE) ; i++) {\n\tif (eventTypeTable[i].eventType == eventType) {\n\t    printf(\"TSS_EVENT_EventType_Trace: %08x %s\\n\",\n\t\t   eventTypeTable[i].eventType, eventTypeTable[i].text);\n\t    return;\n\t}\n    }\n    printf(\"TSS_EVENT_EventType_Trace: %08x Unknown\\n\", eventType);\n    return;\n}\n\nconst char *TSS_EVENT_EventTypeToString(uint32_t eventType)\n{\n    const char *crc = NULL;\n    size_t i;\n\n    for (i = 0 ; i < sizeof(eventTypeTable) / sizeof(EVENT_TYPE_TABLE) ; i++) {\n\tif (eventTypeTable[i].eventType == eventType) {\n\t    crc = eventTypeTable[i].text;\n\t}\n    }\n    if (crc == NULL) {\n\tcrc = \"Unknown event type\";\n    }\n    return crc;\n}\n\n#ifdef TPM_TPM20\n\n/*\n * TSS_TPML_DIGEST_VALUES_LE_Unmarshalu() Unmarshals TPML_DIGEST_VALUES struct\n * from a LE buffer into HBO data structure. This is similar to\n * TSS_TPML_DIGEST_VALUES_Unmarshalu but it unrmarshals TPML_DIGEST_VALUES's\n * count  and the digests array members from LE instead of HBO.\n */\n\nstatic TPM_RC\nTSS_TPML_DIGEST_VALUES_LE_Unmarshalu(TPML_DIGEST_VALUES *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    uint32_t i;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32LE_Unmarshal(&target->count, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (target->count > HASH_COUNT) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }\n    for (i = 0 ; (rc == TPM_RC_SUCCESS) && (i < target->count) ; i++) {\n\trc = TSS_TPMT_HA_LE_Unmarshalu(&target->digests[i], buffer, size, NO);\n    }\n    return rc;\n}\n\n/*\n * TSS_TPMT_HA_LE_Unmarshalu() Unmarshals a TPMT_HA data from LE to HBO. This is\n * similar to TSS_TPMT_HA_Unmarshalu but differs specificaly for unmarshalling\n * hashAlg member from LE instead of from HBO.\n */\nstatic TPM_RC\nTSS_TPMT_HA_LE_Unmarshalu(TPMT_HA *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_ALG_HASH_LE_Unmarshalu(&target->hashAlg, buffer, size, allowNull);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMU_HA_Unmarshalu(&target->digest, buffer, size, target->hashAlg);\n    }\n    return rc;\n}\n\n/*\n * TSS_TPMI_ALG_HASH_LE_Unmarshalu() Unmarshals TPMI_ALG_HASH from a LE buffer\n * into HBO data structure. This is similar to TSS_TPMI_ALG_HASH_Unmarshalu but\n * unmarshals TPMI_ALG_HASH from LE instead of HBO.\n */\nstatic TPM_RC\nTSS_TPMI_ALG_HASH_LE_Unmarshalu(TPMI_ALG_HASH *target, BYTE **buffer, uint32_t *size, BOOL allowNull)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    allowNull = allowNull;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_ALG_ID_LE_Unmarshalu(target, buffer, size);\n    }\n    return rc;\n}\n\n/*\n * TSS_TPM_ALG_ID_LE_Unmarshalu() Unrmarshals TPM_ALG_ID from LE buffer. This is\n * simlar to TSS_TPM_ALG_ID_Unmarshalu but unmarshals from LE instead of HBO.\n */\nstatic TPM_RC\nTSS_TPM_ALG_ID_LE_Unmarshalu(TPM_ALG_ID *target, BYTE **buffer,\n                                 uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16LE_Unmarshal(target, buffer, size);\n    }\n    return rc;\n}\n\n/* TSS_TPML_DIGEST_VALUES_LE_Marshalu() Similar to TSS_TPML_DIGEST_VALUES_Marshalu\n * for TSS EVENT2 this marshals count to buffer in LE endianess.\n */\nstatic TPM_RC\nTSS_TPML_DIGEST_VALUES_LE_Marshalu(const TPML_DIGEST_VALUES *source,\n                                       uint16_t *written, BYTE **buffer,\n                                       uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n\n    if (rc == 0) {\n\trc = TSS_UINT32LE_Marshal(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPMT_HA_LE_Marshalu(&source->digests[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* TSS_TPMT_HA_LE_Marshalu() Similar to TSS_TPMT_HA_Marshalu for TSS EVENT2,\n * this saves hashAlg attr as little endian into buffer.\n */\nstatic TPM_RC\nTSS_TPMT_HA_LE_Marshalu(const TPMT_HA *source, uint16_t *written,\n\t\t\tBYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16LE_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_HA_Marshalu(&source->digest, written, buffer, size,\n                                  source->hashAlg);\n    }\n    return rc;\n}\n\n#endif /* TPM_TPM20 */\n\n/*\n * TSS_UINT32LE_Marshal() Marshals uint32_t from HBO into LE in the given buffer.\n */\nTPM_RC\nTSS_UINT32LE_Marshal(const UINT32 *source, uint16_t *written, BYTE **buffer,\n                 uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (buffer != NULL) {\n        if ((size == NULL) || (*size >= sizeof(uint32_t))) {\n            (*buffer)[0] = (BYTE)((*source >> 0) &  0xff);\n            (*buffer)[1] = (BYTE)((*source >> 8) & 0xff);\n            (*buffer)[2] = (BYTE)((*source >> 16) & 0xff);\n            (*buffer)[3] = (BYTE)((*source >> 24) & 0xff);\n\n            *buffer += sizeof(uint32_t);\n            if (size != NULL) {\n                *size -= sizeof(uint32_t);\n            }\n        }\n        else {\n            rc = TSS_RC_INSUFFICIENT_BUFFER;\n        }\n    }\n    *written += sizeof(uint32_t);\n    return rc;\n}\n\n/*\n * UINT16LE_Marshal() Marshals uint16_t from HBO into LE in the given buffer.\n */\n\nTPM_RC\nTSS_UINT16LE_Marshalu(const UINT16 *source, uint16_t *written, BYTE **buffer,\n                      uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (buffer != NULL) {\n        if ((size == NULL) || (*size >= sizeof(uint16_t))) {\n\t    (*buffer)[0] = (BYTE)((*source >> 0) & 0xff);\n\t    (*buffer)[1] = (BYTE)((*source >> 8) & 0xff);\n\n            *buffer += sizeof(uint16_t);\n\n            if (size != NULL) {\n                *size -= sizeof(uint16_t);\n            }\n        }\n        else {\n            rc = TSS_RC_INSUFFICIENT_BUFFER;\n        }\n    }\n    *written += sizeof(uint16_t);\n    return rc;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/eventsequencecomplete.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    EventSequenceComplete\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    EventSequenceComplete_In \tin;\n    EventSequenceComplete_Out\tout;\n    TPMI_DH_PCR \t\tpcrHandle = TPM_RH_NULL;\n    TPMI_DH_OBJECT\t\tsequenceHandle = 0;\n    const char\t\t\t*inFilename = NULL;\n    const char\t\t\t*outFilename1 = NULL;\t/* for sha1 */\n    const char\t\t\t*outFilename2 = NULL;\t/* for sha256 */\n    const char\t\t\t*outFilename3 = NULL;\t/* for sha384 */\n    const char\t\t\t*outFilename5 = NULL;\t/* for sha512 */\n    int\t\t\t\tprocess1 = FALSE;\t/* these catch the case */\n    int\t\t\t\tprocess2 = FALSE;\t/* where an output file was */\n    int\t\t\t\tprocess3 = FALSE;\t/* specified but the TPM did */\n    int\t\t\t\tprocess5 = FALSE;\t/* not return the algorithm */\n    const char\t\t\t*sequencePassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &pcrHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sequenceHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwds\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsequencePassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwds option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of1\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename1 = argv[i];\n\t\tprocess1 = TRUE;\n\t    } else {\n\t\tprintf(\"-of1 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of2\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename2 = argv[i];\n\t\tprocess2 = TRUE;\n\t    } else {\n\t\tprintf(\"-of2 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of3\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename3 = argv[i];\n\t\tprocess3 = TRUE;\n\t    } else {\n\t\tprintf(\"-of3 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of5\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename5 = argv[i];\n\t\tprocess5 = TRUE;\n\t    } else {\n\t\tprintf(\"-of5 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (sequenceHandle == 0) {\n\tprintf(\"Missing sequence handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tif (inFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.buffer.b,\n\t\t\t\t sizeof(in.buffer.t.buffer),\n\t\t\t\t inFilename);\n\t}\n\telse {\n\t    in.buffer.b.size = 0;\n\t}\n    }\n    if (rc == 0) {\n\tin.pcrHandle = pcrHandle;\n\tin.sequenceHandle = sequenceHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_EventSequenceComplete,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, sequencePassword, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tuint32_t c;\n\tprintf(\"eventsequencecomplete: success\\n\");\n\t/* Table 100 - Definition of TPML_DIGEST_VALUES Structure */\n\t/* Table 71 - Definition of TPMT_HA Structure <IN/OUT> digests[] */\n\t/* Table 70 - Definition of TPMU_HA Union <IN/OUT, S> digests */\n\tprintf(\"eventsequencecomplete: count %u\\n\", out.results.count);\n\n\tfor (c = 0 ;  c < out.results.count ;c++) {\n\t    switch (out.results.digests[c].hashAlg) {\n\t      case TPM_ALG_SHA1:\n\t\tif (tssUtilsVerbose) printf(\"Hash algorithm SHA-1\\n\");\n\t\tif (tssUtilsVerbose) TSS_PrintAll(\"Digest\",\n\t\t\t\t\t  (uint8_t *)&out.results.digests[c].digest.sha1,\n\t\t\t\t\t  SHA1_DIGEST_SIZE);\n\t\tif (outFilename1 != NULL) {\n\t\t    rc = TSS_File_WriteBinaryFile((uint8_t *)&out.results.digests[c].digest.sha1,\n\t\t\t\t\t\t  SHA1_DIGEST_SIZE,\n\t\t\t\t\t\t  outFilename1); \n\t\t    process1 = FALSE;\n\t\t}\n\t\tbreak;\n\t      case TPM_ALG_SHA256:\n\t\tif (tssUtilsVerbose) printf(\"Hash algorithm SHA-256\\n\");\n\t\tif (tssUtilsVerbose) TSS_PrintAll(\"Digest\",\n\t\t\t\t\t  (uint8_t *)&out.results.digests[c].digest.sha256,\n\t\t\t\t\t  SHA256_DIGEST_SIZE);\n\t\tif (outFilename2 != NULL) {\n\t\t    rc = TSS_File_WriteBinaryFile((uint8_t *)&out.results.digests[c].digest.sha256,\n\t\t\t\t\t\t  SHA256_DIGEST_SIZE,\n\t\t\t\t\t\t  outFilename2); \n\t\t    process2 = FALSE;\n\t\t}\n\t\tbreak;\n\t      case TPM_ALG_SHA384:\n\t\tif (tssUtilsVerbose) printf(\"Hash algorithm SHA-384\\n\");\n\t\tif (tssUtilsVerbose) TSS_PrintAll(\"Digest\",\n\t\t\t\t\t  (uint8_t *)&out.results.digests[c].digest.sha384,\n\t\t\t\t\t  SHA384_DIGEST_SIZE);\n\t\tif (outFilename3 != NULL) {\n\t\t    rc = TSS_File_WriteBinaryFile((uint8_t *)&out.results.digests[c].digest.sha384,\n\t\t\t\t\t\t  SHA384_DIGEST_SIZE,\n\t\t\t\t\t\t  outFilename3); \n\t\t    process3 = FALSE;\n\t\t}\n\t\tbreak;\n\t      case TPM_ALG_SHA512:\n\t\tif (tssUtilsVerbose) printf(\"Hash algorithm SHA-512\\n\");\n\t\tif (tssUtilsVerbose) TSS_PrintAll(\"Digest\",\n\t\t\t\t\t  (uint8_t *)&out.results.digests[c].digest.sha512,\n\t\t\t\t\t  SHA512_DIGEST_SIZE);\n\t\tif (outFilename5 != NULL) {\n\t\t    rc = TSS_File_WriteBinaryFile((uint8_t *)&out.results.digests[c].digest.sha512,\n\t\t\t\t\t\t  SHA512_DIGEST_SIZE,\n\t\t\t\t\t\t  outFilename5); \n\t\t    process5 = FALSE;\n\t\t}\n\t\tbreak;\n\t      default:\n\t\tprintf(\"Hash algorithm %04x unknown\\n\", out.results.digests[c].hashAlg);\n\t\tbreak;\n\t    }\n\t}\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"eventsequencecomplete: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    if (rc == 0) {\n\tif (process1) {\n\t    printf(\"-of1 specified but TPM did not return SHA-1\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n\tif (process2) {\n\t    printf(\"-of2 specified but TPM did not return SHA-256\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n\tif (process3) {\n\t    printf(\"-of3 specified but TPM did not return SHA-384\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n\tif (process5) {\n\t    printf(\"-of5 specified but TPM did not return SHA-512\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"eventsequencecomplete\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_EventSequenceComplete\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-ha\\tpcr handle (default NULL)]\\n\");\n    printf(\"\\t-hs\\tsequence handle\\n\");\n    printf(\"\\t[-pwds\\tpassword for sequence (default empty)]\\n\");\n    printf(\"\\t[-if\\tinput file to be added (default no data)]\\n\");\n    printf(\"\\t[-of1\\tsha1 output digest file (default do not save)]\\n\");\n    printf(\"\\t[-of2\\tsha256 output digest file (default do not save)]\\n\");\n    printf(\"\\t[-of3\\tsha384 output digest file (default do not save)]\\n\");\n    printf(\"\\t[-of5\\tsha512 output digest file (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/evictcontrol.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   EvictControl\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    TPMI_DH_OBJECT\t\tobjectHandle = 0;\n    TPMI_DH_PERSISTENT\t\tpersistentHandle = 0;\n    EvictControl_In \t\tin;\n    char \t\t\tauthHandleChar = 0;\n    const char\t\t\t*authPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthHandleChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ho\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &objectHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ho\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-hp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &persistentHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (objectHandle == 0) {\n\tprintf(\"Missing handle parameter -ho\\n\");\n\tprintUsage();\n    }\n    if (persistentHandle == 0) {\n\tprintf(\"Missing handle parameter -hp\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tif (authHandleChar == 'o') {\n\t    in.auth = TPM_RH_OWNER;\n\t}\n\telse if (authHandleChar == 'p') {\n\t    in.auth = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.objectHandle = objectHandle;\n\tin.persistentHandle = persistentHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_EvictControl,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"evictcontrol: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"evictcontrol: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"evictcontrol\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_EvictControl\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hi\\tauthhandle hierarchy (o, p)\\n\");\n    printf(\"\\t\\to owner, p platform\\n\");\n    printf(\"\\t-ho\\tobject handle\\n\");\n    printf(\"\\t\\tif transient: make persistent, if persistent: flush\\n\");\n    printf(\"\\t-hp\\tpersistent handle\\n\");\n    printf(\"\\t\\towner    81000000 to 817FFFFF\\n\");\n    printf(\"\\t\\tplatform 81800000 to 81FFFFFF\\n\");\n    printf(\"\\t-pwda\\tauthorization password (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/flushcontext.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Flush Context\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    uint32_t \t\t\thandle = 0;\n    FlushContext_In \t\tin;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&handle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (handle == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.flushHandle = handle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_FlushContext,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"flushcontext: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"flushcontext: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"flushcontext\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_FlushContext\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\thandle\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/getcapability.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Get Capability\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(TPM_CAP capability);\nstatic TPM_RC printResponse(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    \t\t/* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    TPM_CAP\t\t\tcapability = TPM_CAP_LAST + 1;\t/* invalid */\n    uint32_t\t\t\tproperty = 0;\t\t\t/* default, start at first one */\n    uint32_t\t\t\tpropertyCount = 64;\t\t/* default, return 64 values */\n    GetCapability_In \t\tin;\n    GetCapability_Out\t\tout;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-cap\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &capability);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -cap\\n\");\n\t\tprintUsage(capability);\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-pr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &property);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -pr\\n\");\n\t\tprintUsage(capability);\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-pc\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &propertyCount);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -pc\\n\");\n\t\tprintUsage(capability);\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage(capability);\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage(capability);\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage(capability);\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage(capability);\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage(capability);\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage(capability);\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage(capability);\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage(capability);\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage(capability);\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage(capability);\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage(capability);\n\t}\n    }\n    if (capability > TPM_CAP_LAST) {\n\tprintf(\"Missing or illegal parameter -cap\\n\");\n\tprintUsage(capability);\n    }\n    if (rc == 0) {\n\tin.capability = capability;\n\tin.property = property;\n\tin.propertyCount = propertyCount;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_GetCapability,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (out.moreData > 0) {\n\t    printf(\"moreData: %u\\n\", out.moreData);\n\t}\n\trc = printResponse(&out.capabilityData, property);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"getcapability: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"getcapability: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\ntypedef void (* USAGE_FUNCTION)(void);\ntypedef TPM_RC (* RESPONSE_FUNCTION)(TPMS_CAPABILITY_DATA *out, uint32_t property);\n\ntypedef struct {\n    TPM_CAP capability;\n    USAGE_FUNCTION usageFunction;\n    RESPONSE_FUNCTION responseFunction;\n} CAPABILITY_TABLE;\n\nstatic void usageCapability(void);\nstatic void usageAlgs(void);\nstatic void usageHandles(void);\nstatic void usageCommands(void);\nstatic void usagePpCommands(void);\nstatic void usageAuditCommands(void);\nstatic void usagePcrs(void);\nstatic void usageTpmProperties(void);\nstatic void usagePcrProperties(void);\nstatic void usageEccCurves(void);\nstatic void usageAuthPolicies(void);\nstatic void usageAct(void);\n\nstatic TPM_RC responseCapability(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responseAlgs(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responseHandles(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responseCommands(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responsePpCommands(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responseAuditCommands(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responsePcrs(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responseTpmProperties(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responsePcrProperties(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responseEccCurves(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responseAuthPolicies(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\nstatic TPM_RC responseAct(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property);\n\nstatic const CAPABILITY_TABLE capabilityTable [] = {\n    {TPM_CAP_LAST + 1, usageCapability, responseCapability}, \n    {TPM_CAP_ALGS, usageAlgs, responseAlgs} ,                 \n    {TPM_CAP_HANDLES, usageHandles, responseHandles} ,             \n    {TPM_CAP_COMMANDS, usageCommands, responseCommands} ,            \n    {TPM_CAP_PP_COMMANDS, usagePpCommands, responsePpCommands} ,         \n    {TPM_CAP_AUDIT_COMMANDS, usageAuditCommands, responseAuditCommands},      \n    {TPM_CAP_PCRS, usagePcrs, responsePcrs} ,                \n    {TPM_CAP_TPM_PROPERTIES, usageTpmProperties, responseTpmProperties},      \n    {TPM_CAP_PCR_PROPERTIES, usagePcrProperties, responsePcrProperties},      \n    {TPM_CAP_ECC_CURVES, usageEccCurves, responseEccCurves},          \n    {TPM_CAP_AUTH_POLICIES, usageAuthPolicies, responseAuthPolicies},\n    {TPM_CAP_ACT, usageAct, responseAct}\n};\n\nstatic TPM_RC printResponse(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    size_t \ti;\n\n    /* call the response function in the capability table */\n    for (i = 0 ; i < (sizeof(capabilityTable) / sizeof(CAPABILITY_TABLE)) ; i++) {\n\tif (capabilityTable[i].capability == capabilityData->capability) {\n\t    rc = capabilityTable[i].responseFunction(capabilityData, property);\n\t}\n    }\n    return rc;\n}\n\nstatic TPM_RC responseCapability(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\t\t\trc = 0;\n    property = property;\n    printf(\"Cannot parse illegal response capability %08x\\n\", capabilityData->capability);\n    rc = TPM_RC_VALUE;\n    return rc;\n}\n\nstatic TPM_RC responseAlgs(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tcount;\n    TPML_ALG_PROPERTY *algorithms = (TPML_ALG_PROPERTY *)&(capabilityData->data);\n    property = property;\n\n    printf(\"%u algorithms \\n\", algorithms->count);\n    for (count = 0 ; count < algorithms->count ; count++) {\n\tTPMS_ALG_PROPERTY *algProperties = &(algorithms->algProperties[count]);\n\tTSS_TPM_ALG_ID_Print(\"\", algProperties->alg, 2);\n\tTSS_TPM_TPMA_ALGORITHM_Print(algProperties->algProperties, 4);\n    }\n    return rc;\n}\n\nstatic TPM_RC responseHandles(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tcount;\n    TPML_HANDLE\t*handles = (TPML_HANDLE *)&(capabilityData->data);\n    property = property;\n\n    printf(\"%u handles\\n\", handles->count);\n    for (count = 0 ; count < handles->count ; count++) {\n\tprintf(\"\\t%08x\\n\", handles->handle[count]);\n    }\n    return rc;\n}\n\nstatic TPM_RC responseCommands(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tcount;\n    TPML_CCA\t*command = (TPML_CCA *)&(capabilityData->data);\n    property = property;\n\n    printf(\"%u commands\\n\", command->count);\n    for (count = 0 ; count < command->count ; count++) {\n\tprintf(\"\\tcommand Attributes %08x\\n\", command->commandAttributes[count].val);\n    }\n    return rc;\n}\n\nstatic TPM_RC responsePpCommands(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tcount;\n    TPML_CC\t*command = (TPML_CC *)&(capabilityData->data);\n    property = property;\n\n    printf(\"%u commands\\n\", command->count);\n    for (count = 0 ; count < command->count ; count++) {\n\tprintf(\"\\tPP command %08x\\n\", command->commandCodes[count]);\n    }\n    return rc;\n}\n\nstatic TPM_RC responseAuditCommands(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tcount;\n    TPML_CC\t*command = (TPML_CC *)&(capabilityData->data);\n    property = property;\n\n    printf(\"%u commands\\n\", command->count);\n    for (count = 0 ; count < command->count ; count++) {\n\tprintf(\"\\tAudit command %08x\\n\", command->commandCodes[count]);\n    }\n    return rc;\n}\n\nstatic TPM_RC responsePcrs(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tcount;\n    TPML_PCR_SELECTION *pcrSelection = (TPML_PCR_SELECTION *)&(capabilityData->data);\n    property = property;\n\n    printf(\"%u PCR selections\\n\", pcrSelection->count);\n    for (count = 0 ; count < pcrSelection->count ; count++) {\n\tTSS_TPMS_PCR_SELECTION_Print(&pcrSelection->pcrSelections[count], 2);\n    }\n    return rc;\n}\n\ntypedef struct {\n    TPM_PT pt;\n    const char *ptText;\n} PT_TABLE;\n\nstatic PT_TABLE ptTable [] = {\n    {(PT_FIXED + 0),\"TPM_PT_FAMILY_INDICATOR - a 4-octet character string containing the TPM Family value (TPM_SPEC_FAMILY)\"},\n    {(PT_FIXED + 1), \"TPM_PT_LEVEL - the level of the specification\"},\n    {(PT_FIXED + 2), \"TPM_PT_REVISION - the specification Revision times 100\"},\n    {(PT_FIXED + 3), \"TPM_PT_DAY_OF_YEAR - the specification day of year using TCG calendar\"},\n    {(PT_FIXED + 4), \"TPM_PT_YEAR - the specification year using the CE\"},\n    {(PT_FIXED + 5), \"TPM_PT_MANUFACTURER - the vendor ID unique to each TPM manufacturer \"},\n    {(PT_FIXED + 6), \"TPM_PT_VENDOR_STRING_1 - the first four characters of the vendor ID string\"},\n    {(PT_FIXED + 7), \"TPM_PT_VENDOR_STRING_2 - the second four characters of the vendor ID string \"},\n    {(PT_FIXED + 8), \"TPM_PT_VENDOR_STRING_3 - the third four characters of the vendor ID string \"},\n    {(PT_FIXED + 9), \"TPM_PT_VENDOR_STRING_4 - the fourth four characters of the vendor ID sting \"},\n    {(PT_FIXED + 10), \"TPM_PT_VENDOR_TPM_TYPE - vendor-defined value indicating the TPM model \"},\n    {(PT_FIXED + 11), \"TPM_PT_FIRMWARE_VERSION_1 - the most-significant 32 bits of a TPM vendor-specific value indicating the version number of the firmware\"},\n    {(PT_FIXED + 12), \"TPM_PT_FIRMWARE_VERSION_2 - the least-significant 32 bits of a TPM vendor-specific value indicating the version number of the firmware\"},\n    {(PT_FIXED + 13), \"TPM_PT_INPUT_BUFFER - the maximum size of a parameter (typically, a TPM2B_MAX_BUFFER)\"},\n    {(PT_FIXED + 14), \"TPM_PT_HR_TRANSIENT_MIN - the minimum number of transient objects that can be held in TPM RAM\"},\n    {(PT_FIXED + 15), \"TPM_PT_HR_PERSISTENT_MIN - the minimum number of persistent objects that can be held in TPM NV memory\"},\n    {(PT_FIXED + 16), \"TPM_PT_HR_LOADED_MIN - the minimum number of authorization sessions that can be held in TPM RAM\"},\n    {(PT_FIXED + 17), \"TPM_PT_ACTIVE_SESSIONS_MAX - the number of authorization sessions that may be active at a time\"},\n    {(PT_FIXED + 18), \"TPM_PT_PCR_COUNT - the number of PCR implemented\"},\n    {(PT_FIXED + 19), \"TPM_PT_PCR_SELECT_MIN - the minimum number of octets in a TPMS_PCR_SELECT.sizeOfSelect\"},\n    {(PT_FIXED + 20), \"TPM_PT_CONTEXT_GAP_MAX - the maximum allowed difference (unsigned) between the contextID values of two saved session contexts\"},\n    {(PT_FIXED + 22), \"TPM_PT_NV_COUNTERS_MAX - the maximum number of NV Indexes that are allowed to have the TPMA_NV_COUNTER attribute SET\"},\n    {(PT_FIXED + 23), \"TPM_PT_NV_INDEX_MAX - the maximum size of an NV Index data area\"},\n    {(PT_FIXED + 24), \"TPM_PT_MEMORY - a TPMA_MEMORY indicating the memory management method for the TPM\"},\n    {(PT_FIXED + 25), \"TPM_PT_CLOCK_UPDATE - interval, in milliseconds, between updates to the copy of TPMS_CLOCK_INFO.clock in NV\"},\n    {(PT_FIXED + 26), \"TPM_PT_CONTEXT_HASH - the algorithm used for the integrity HMAC on saved contexts and for hashing the fuData of TPM2_FirmwareRead()\"},\n    {(PT_FIXED + 27), \"TPM_PT_CONTEXT_SYM - TPM_ALG_ID, the algorithm used for encryption of saved contexts\"},\n    {(PT_FIXED + 28), \"TPM_PT_CONTEXT_SYM_SIZE - TPM_KEY_BITS, the size of the key used for encryption of saved contexts\"},\n    {(PT_FIXED + 29), \"TPM_PT_ORDERLY_COUNT - the modulus - 1 of the count for NV update of an orderly counter\"},\n    {(PT_FIXED + 30), \"TPM_PT_MAX_COMMAND_SIZE - the maximum value for commandSize in a command\"},\n    {(PT_FIXED + 31), \"TPM_PT_MAX_RESPONSE_SIZE - the maximum value for responseSize in a response\"},\n    {(PT_FIXED + 32), \"TPM_PT_MAX_DIGEST - the maximum size of a digest that can be produced by the TPM\"},\n    {(PT_FIXED + 33), \"TPM_PT_MAX_OBJECT_CONTEXT - the maximum size of an object context that will be returned by TPM2_ContextSave\"},\n    {(PT_FIXED + 34), \"TPM_PT_MAX_SESSION_CONTEXT - the maximum size of a session context that will be returned by TPM2_ContextSave\"},\n    {(PT_FIXED + 35), \"TPM_PT_PS_FAMILY_INDICATOR - platform-specific family (a TPM_PS value)(see Table 24)\"},\n    {(PT_FIXED + 36), \"TPM_PT_PS_LEVEL - the level of the platform-specific specification\"},\n    {(PT_FIXED + 37), \"TPM_PT_PS_REVISION - the specification Revision times 100 for the platform-specific specification\"},\n    {(PT_FIXED + 38), \"TPM_PT_PS_DAY_OF_YEAR - the platform-specific specification day of year using TCG calendar\"},\n    {(PT_FIXED + 39), \"TPM_PT_PS_YEAR - the platform-specific specification year using the CE\"},\n    {(PT_FIXED + 40), \"TPM_PT_SPLIT_MAX - the number of split signing operations supported by the TPM\"},\n    {(PT_FIXED + 41), \"TPM_PT_TOTAL_COMMANDS - total number of commands implemented in the TPM\"},\n    {(PT_FIXED + 42), \"TPM_PT_LIBRARY_COMMANDS - number of commands from the TPM library that are implemented\"},\n    {(PT_FIXED + 43), \"TPM_PT_VENDOR_COMMANDS - number of vendor commands that are implemented\"},\n    {(PT_FIXED + 44), \"TPM_PT_NV_BUFFER_MAX - the maximum data size in one NV write command\"},\n    {(PT_FIXED + 45) ,\"TPM_PT_MODES - a TPMA_MODES value, indicating that the TPM is designed for these modes\"},\n    {(PT_FIXED + 46) ,\"TPM_PT_MAX_CAP_BUFFER - the maximum size of a TPMS_CAPABILITY_DATA structure returned in TPM2_GetCapability\"},\n    {(PT_VAR + 0), \"TPM_PT_PERMANENT - TPMA_PERMANENT \"},\n    {(PT_VAR + 1), \"TPM_PT_STARTUP_CLEAR - TPMA_STARTUP_CLEAR \"},\n    {(PT_VAR + 2), \"TPM_PT_HR_NV_INDEX - the number of NV Indexes currently defined \"},\n    {(PT_VAR + 3), \"TPM_PT_HR_LOADED - the number of authorization sessions currently loaded into TPM RAM\"},\n    {(PT_VAR + 4), \"TPM_PT_HR_LOADED_AVAIL - the number of additional authorization sessions, of any type, that could be loaded into TPM RAM\"},\n    {(PT_VAR + 5), \"TPM_PT_HR_ACTIVE - the number of active authorization sessions currently being tracked by the TPM\"},\n    {(PT_VAR + 6), \"TPM_PT_HR_ACTIVE_AVAIL - the number of additional authorization sessions, of any type, that could be created\"},\n    {(PT_VAR + 7), \"TPM_PT_HR_TRANSIENT_AVAIL - estimate of the number of additional transient objects that could be loaded into TPM RAM\"},\n    {(PT_VAR + 8), \"TPM_PT_HR_PERSISTENT - the number of persistent objects currently loaded into TPM NV memory\"},\n    {(PT_VAR + 9), \"TPM_PT_HR_PERSISTENT_AVAIL - the number of additional persistent objects that could be loaded into NV memory\"},\n    {(PT_VAR + 10), \"TPM_PT_NV_COUNTERS - the number of defined NV Indexes that have NV TPMA_NV_COUNTER attribute SET\"},\n    {(PT_VAR + 11), \"TPM_PT_NV_COUNTERS_AVAIL - the number of additional NV Indexes that can be defined with their TPMA_NV_COUNTER and TPMA_NV_ORDERLY attribute SET\"},\n    {(PT_VAR + 12), \"TPM_PT_ALGORITHM_SET - code that limits the algorithms that may be used with the TPM\"},\n    {(PT_VAR + 13), \"TPM_PT_LOADED_CURVES - the number of loaded ECC curves \"},\n    {(PT_VAR + 14), \"TPM_PT_LOCKOUT_COUNTER - the current value of the lockout counter (failedTries) \"},\n    {(PT_VAR + 15), \"TPM_PT_MAX_AUTH_FAIL - the number of authorization failures before DA lockout is invoked\"},\n    {(PT_VAR + 16), \"TPM_PT_LOCKOUT_INTERVAL - the number of seconds before the value reported by TPM_PT_LOCKOUT_COUNTER is decremented\"},\n    {(PT_VAR + 17), \"TPM_PT_LOCKOUT_RECOVERY - the number of seconds after a lockoutAuth failure before use of lockoutAuth may be attempted again\"},\n    {(PT_VAR + 18), \"TPM_PT_NV_WRITE_RECOVERY - number of milliseconds before the TPM will accept another command that will modify NV\"},\n    {(PT_VAR + 19), \"TPM_PT_AUDIT_COUNTER_0 - the high-order 32 bits of the command audit counter \"},\n    {(PT_VAR + 20), \"TPM_PT_AUDIT_COUNTER_1 - the low-order 32 bits of the command audit counter\"},\n};\n\nstatic char get8(uint32_t value32, size_t offset);\nstatic uint16_t get16(uint32_t value32, size_t offset);\n\n/* get8() gets a char from a uint32_t at offset */\n\nstatic char get8(uint32_t value32, size_t offset)\n{\n    char value8 = (uint8_t)((value32 >> ((3 - offset) * 8)) & 0xff);\n    return value8;\n}\n\n/* get16() gets a uint16_t from a uint32_t at offset */\n\nstatic uint16_t get16(uint32_t value32, size_t offset)\n{\n    uint16_t value16 = (uint16_t)((value32 >> ((1 - offset) * 16)) & 0xffff);\n    return value16;\n}\n\nstatic TPM_RC responseTpmProperties(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\t\trc = 0;\n    uint32_t\t\tcount;\n    TPML_TAGGED_TPM_PROPERTY *tpmProperties = (TPML_TAGGED_TPM_PROPERTY *)&(capabilityData->data);\n    property = property;\n\n    printf(\"%u properties\\n\", tpmProperties->count);\n    for (count = 0 ; count < tpmProperties->count ; count++) {\n\tTPMS_TAGGED_PROPERTY *tpmProperty = &(tpmProperties->tpmProperty[count]);\n\tconst char *ptText = NULL;\n\tsize_t i;\n\tfor  (i = 0 ; i < (sizeof(ptTable) / sizeof(PT_TABLE)) ; i++) {\n\t    if (tpmProperty->property == ptTable[i].pt) {\n\t\tptText = ptTable[i].ptText;\n\t\tbreak;\n\t    }\n\t}\n\tif (ptText == NULL) {\n\t    ptText = \"PT unknown\";\n\t}\n\tprintf(\"TPM_PT %08x value %08x %s\\n\", tpmProperty->property, tpmProperty->value, ptText);\n\tswitch (tpmProperty->property) {\n\t    char c;\n\t  case TPM_PT_FAMILY_INDICATOR:\n\t    printf(\"\\tTPM \");\n\t    for (i = 0 ; i < sizeof(uint32_t) ; i++) {\n\t\tc = get8(tpmProperty->value, i);\n\t\tprintf(\"%c\", c);\n\t    }\n\t    printf(\"\\n\");\n\t    break;\n\t  case TPM_PT_REVISION:\n\t    printf(\"\\trev %u\\n\", tpmProperty->value);\n\t    break;\n\t  case TPM_PT_DAY_OF_YEAR:\n\t  case TPM_PT_YEAR:\n\t  case TPM_PT_INPUT_BUFFER:\n\t  case TPM_PT_ACTIVE_SESSIONS_MAX:\n\t  case TPM_PT_PCR_COUNT:\n\t  case TPM_PT_NV_INDEX_MAX:\n\t  case TPM_PT_CLOCK_UPDATE:\n\t  case TPM_PT_CONTEXT_SYM_SIZE:\n\t  case TPM_PT_MAX_COMMAND_SIZE:\n\t  case TPM_PT_MAX_RESPONSE_SIZE:\n\t  case TPM_PT_MAX_DIGEST:\n\t  case TPM_PT_MAX_OBJECT_CONTEXT:\n\t  case TPM_PT_MAX_SESSION_CONTEXT:\n\t  case TPM_PT_PS_DAY_OF_YEAR:\n\t  case TPM_PT_PS_YEAR:\n\t  case TPM_PT_SPLIT_MAX:\n\t  case TPM_PT_TOTAL_COMMANDS:\n\t  case TPM_PT_LIBRARY_COMMANDS:\n\t  case TPM_PT_VENDOR_COMMANDS:\n\t  case TPM_PT_NV_BUFFER_MAX:\n\t  case TPM_PT_MAX_CAP_BUFFER:\n\t    \n\t  case TPM_PT_HR_ACTIVE_AVAIL:\n\t  case TPM_PT_HR_PERSISTENT_AVAIL:\n\t  case TPM_PT_NV_COUNTERS_AVAIL:\n \t    printf(\"\\t%u\\n\", tpmProperty->value);\n\t    break;\n\t  case TPM_PT_MANUFACTURER:\n\t  case TPM_PT_VENDOR_STRING_1:\n\t  case TPM_PT_VENDOR_STRING_2:\n\t  case TPM_PT_VENDOR_STRING_3:\n\t  case TPM_PT_VENDOR_STRING_4:\n\t    printf(\"\\t\");\n\t    for (i = 0 ; i < sizeof(uint32_t) ; i++) {\n\t\tc = get8(tpmProperty->value, i);\n\t\tprintf(\"%c\", c);\n\t    }\n\t    printf(\"\\n\");\n\t    break;\n\t  case TPM_PT_FIRMWARE_VERSION_1:\n\t  case TPM_PT_FIRMWARE_VERSION_2:\n\t    printf(\"\\t%u.%u\\n\", get16(tpmProperty->value, 0), get16(tpmProperty->value, 1));\n\t    break;\n\t  case TPM_PT_PS_REVISION:\n\t    printf(\"\\t%u.%u.%u.%u\\n\",\n\t\t   get8(tpmProperty->value, 0), get8(tpmProperty->value, 1),\n\t\t   get8(tpmProperty->value, 2), get8(tpmProperty->value, 3));\n\t    break;\n\t  case TPM_PT_CONTEXT_HASH:\n\t  case TPM_PT_CONTEXT_SYM:\n\t    TSS_TPM_ALG_ID_Print(\"algorithm\", tpmProperty->value, 4);\n\t    break;\n\t  case TPM_PT_MEMORY:\n\t      {\n\t\t  TPMA_MEMORY tmp;\n\t\t  tmp.val = tpmProperty->value;\n\t\t  TSS_TPMA_MEMORY_Print(tmp, 4);\n\t      }\n\t      break;\n\t  case TPM_PT_MODES :\n\t      {\n\t\t  TPMA_MODES tmp;\n\t\t  tmp.val = tpmProperty->value;\n\t\t  TSS_TPMA_MODES_Print(tmp, 4);\n\t      }\n\t      break;\n\t  case TPM_PT_PERMANENT:\n\t      {\n\t\t  TPMA_PERMANENT tmp;\n\t\t  tmp.val = tpmProperty->value;\n\t\t  TSS_TPMA_PERMANENT_Print(tmp, 4);\n\t      }\n\t      break;\n\t  case TPM_PT_STARTUP_CLEAR:\n\t      {\n\t\t  TPMA_STARTUP_CLEAR tmp;\n\t\t  tmp.val = tpmProperty->value;\n\t\t  TSS_TPMA_STARTUP_CLEAR_Print(tmp, 4);\n\t      }\n\t      break; \n\t}\n    }\n    return rc;\n}\n\ntypedef struct {\n    TPM_PT_PCR ptPcr;\n    const char *ptPcrText;\n} PT_PCR_TABLE;\n\nstatic PT_PCR_TABLE ptPcrTable [] = {\n    {TPM_PT_PCR_SAVE, \"TPM_PT_PCR_SAVE - PCR is saved and restored by TPM_SU_STATE\"},\n    {TPM_PT_PCR_EXTEND_L0, \"TPM_PT_PCR_EXTEND_L0 - PCR may be extended from locality 0\"},\n    {TPM_PT_PCR_RESET_L0, \"TPM_PT_PCR_RESET_L0 - PCR may be reset by TPM2_PCR_Reset() from locality 0\"},\n    {TPM_PT_PCR_EXTEND_L1, \"TPM_PT_PCR_EXTEND_L1 - PCR may be extended from locality 1\"},\n    {TPM_PT_PCR_RESET_L1, \"TPM_PT_PCR_RESET_L1 - PCR may be reset by TPM2_PCR_Reset() from locality 1\"},\n    {TPM_PT_PCR_EXTEND_L2, \"TPM_PT_PCR_EXTEND_L2 - PCR may be extended from locality 2\"},\n    {TPM_PT_PCR_RESET_L2, \"TPM_PT_PCR_RESET_L2 - PCR may be reset by TPM2_PCR_Reset() from locality 2\"},\n    {TPM_PT_PCR_EXTEND_L3, \"TPM_PT_PCR_EXTEND_L3 - PCR may be extended from locality 3\"},\n    {TPM_PT_PCR_RESET_L3, \"TPM_PT_PCR_RESET_L3 - PCR may be reset by TPM2_PCR_Reset() from locality 3\"},\n    {TPM_PT_PCR_EXTEND_L4, \"TPM_PT_PCR_EXTEND_L4 - PCR may be extended from locality 4\"},\n    {TPM_PT_PCR_RESET_L4, \"TPM_PT_PCR_RESET_L4 - PCR may be reset by TPM2_PCR_Reset() from locality 4\"},\n    {TPM_PT_PCR_NO_INCREMENT, \"TPM_PT_PCR_NO_INCREMENT - modifications to this PCR (reset or Extend) will not increment the pcrUpdateCounter\"},\n    {TPM_PT_PCR_RESET_L4, \"TPM_PT_PCR_RESET_L4 - PCR may be reset by TPM2_PCR_Reset() from locality 4\"},\n    {TPM_PT_PCR_DRTM_RESET, \"TPM_PT_PCR_DRTM_RESET - PCR is reset by a DRTM event\"},\n    {TPM_PT_PCR_POLICY, \"TPM_PT_PCR_POLICY - PCR is controlled by policy\"},\n    {TPM_PT_PCR_AUTH, \"TPM_PT_PCR_AUTH - PCR is controlled by an authorization value\"}\n};\n\nstatic TPM_RC responsePcrProperties(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\t\trc = 0;\n    uint32_t\t\tcount;\n    TPML_TAGGED_PCR_PROPERTY *pcrProperties = (TPML_TAGGED_PCR_PROPERTY *)&(capabilityData->data);\n    property = property; \n\n    printf(\"%u properties\\n\", pcrProperties->count);\n    for (count = 0 ; count < pcrProperties->count ; count++) {\n\t\n\n\tTPMS_TAGGED_PCR_SELECT *pcrProperty = &(pcrProperties->pcrProperty[count]);\n\tconst char *ptPcrText = NULL;\n\tsize_t i;\n\tfor  (i = 0 ; i < (sizeof(ptPcrTable) / sizeof(PT_PCR_TABLE)) ; i++) {\n\t    if (pcrProperty->tag == ptPcrTable[i].ptPcr) {\t/* the property identifier */\n\t\tptPcrText = ptPcrTable[i].ptPcrText;\n\t\tbreak;\n\t    }\n\t}\n\tif (ptPcrText == NULL) {\n\t    ptPcrText = \"PT unknown\";\n\t}\n\tprintf(\"TPM_PT_PCR %08x %s\\n\", pcrProperty->tag, ptPcrText);\n\tfor (i = 0 ; i < pcrProperty->sizeofSelect ; i++) {\t/* the size in octets of the\n\t\t\t\t\t\t\t\t   pcrSelect array */\n\t    printf(\"PCR %u-%u  \\tpcrSelect\\t%02x\\n\",\n\t\t   (unsigned int)i*8, (unsigned int)(i*8) + 7,\n\t\t   pcrProperty->pcrSelect[i]); \n\t}\n    }\n    return rc;\n}\n\nstatic TPM_RC responseEccCurves(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tcount;\n    TPML_ECC_CURVE *eccCurves = (TPML_ECC_CURVE *)&(capabilityData->data);\n    TPM_ECC_CURVE curve;\n    property = property;\n\n    printf(\"%u curves\\n\", eccCurves->count);\n    for (count = 0 ; count < eccCurves->count ; count++) {\n\tcurve = eccCurves->eccCurves[count];\n\tTSS_TPM_ECC_CURVE_Print(\"\", curve, 4);\n    }\n    return rc;\n}\n\nstatic TPM_RC responseAuthPolicies(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tcount;\n    TPML_TAGGED_POLICY *authPolicies = (TPML_TAGGED_POLICY *)&(capabilityData->data);\n    property = property;\n\n    printf(\"%u authPolicies\\n\", authPolicies->count);\n    for (count = 0 ; count < authPolicies->count ; count++) {\n\tTSS_TPMS_TAGGED_POLICY_Print(&authPolicies->policies[count], 4);\n    }\n    return rc;\n}\n\nstatic TPM_RC responseAct(TPMS_CAPABILITY_DATA *capabilityData, uint32_t property)\n{\n    TPM_RC\trc = 0;\n    uint32_t\tcount;\n    TPML_ACT_DATA *actData = (TPML_ACT_DATA *)&(capabilityData->data);\n    property = property;\n\n    printf(\"%u actData\\n\", actData->count);\n    for (count = 0 ; count < actData->count ; count++) {\n\tTSS_TPMS_ACT_DATA_Print(&actData->actData[count], 4);\n    }\n    return rc;\n}\n\nstatic void printUsage(TPM_CAP capability)\n{\n    size_t i;\n    \n    printf(\"\\n\");\n    printf(\"getcapability\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_GetCapability\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-cap\\tcapability\\n\");\n    printf(\"\\t-pr\\tproperty (defaults to 0)\\n\");\n    printf(\"\\t-pc\\tpropertyCount (defaults to 64)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t\\t01\\tcontinue\\n\");\n    printf(\"\\t\\t80\\tcommand audit\\n\");\n    printf(\"\\n\");\n   \n    /* call the usage function in the capability table */\n    for (i = 0 ; i < (sizeof(capabilityTable) / sizeof(CAPABILITY_TABLE)) ; i++) {\n\tif (capabilityTable[i].capability == capability) {\n\t    capabilityTable[i].usageFunction();\n\t    exit(1);\n\t}\n    }\n    printf(\"unknown -cap %08x\\n\", capability);\n    usageCapability();\n    exit(1);\n}\n\nstatic void usageCapability(void)\n{\n    printf(\"\\t-cap\\tvalues\\n\"\n\t   \"\\n\"\n\t   \"\\t\\tTPM_CAP_ALGS                0\\n\"\n\t   \"\\t\\tTPM_CAP_HANDLES             1\\n\"\n\t   \"\\t\\tTPM_CAP_COMMANDS            2\\n\"\n\t   \"\\t\\tTPM_CAP_PP_COMMANDS         3\\n\"\n\t   \"\\t\\tTPM_CAP_AUDIT_COMMANDS      4\\n\"\n\t   \"\\t\\tTPM_CAP_PCRS                5\\n\"\n\t   \"\\t\\tTPM_CAP_TPM_PROPERTIES      6\\n\"\n\t   \"\\t\\tTPM_CAP_PCR_PROPERTIES      7\\n\"\n\t   \"\\t\\tTPM_CAP_ECC_CURVES          8\\n\"\n\t   \"\\t\\tTPM_CAP_AUTH_POLICIES       9\\n\"\n\t   \"\\t\\tTPM_CAP_ACT\t\t    a\\n\"\n\t   );\n    return;\n}\n\nstatic void usageAlgs(void)\n{\n    printf(\"TPM_CAP_ALGS -pr not used\\n\");\n    return;\n}\n\nstatic void usageHandles(void)\n{\n    printf(\"TPM_CAP_HANDLES -pr values\\n\"\n\t   \"\\n\"\n\t   \"TPM_HT_PCR                  00000000\\n\"\n\t   \"TPM_HT_NV_INDEX             01000000\\n\"\n\t   \"TPM_HT_LOADED_SESSION       02000000\\n\"\n\t   \"TPM_HT_SAVED_SESSION        03000000\\n\"\n\t   \"TPM_HT_PERMANENT            40000000\\n\"\n\t   \"TPM_HT_TRANSIENT            80000000\\n\"\n\t   \"TPM_HT_PERSISTENT           81000000\\n\"\n\t   );\n    return;\n}\n\nstatic void usageCommands(void)\n{\n    printf(\"TPM_CAP_COMMANDS -pr is first command\\n\");\n    return;\n}\n\n;\nstatic void usagePpCommands(void)\n{\n    printf(\"TPM_CAP_PP_COMMANDS -pr is first command\\n\");\n    return;\n}\n\nstatic void usageAuditCommands(void)\n{\n    printf(\"TPM_CAP_AUDIT_COMMANDS -pr is first command\\n\");\n    return;\n}\n\nstatic void usagePcrs(void)\n{\n    printf(\"TPM_CAP_PCRS -pr is not used\\n\");\n    return;\n}\n\nstatic void usageTpmProperties(void)\n{\n    printf(\"TPM_CAP_TPM_PROPERTIES -pr is first property\\n\");\n    printf(\"\\tPT_FIXED starts at %08x\\n\", PT_FIXED);\t\n    printf(\"\\tPT_VAR starts at %08x\\n\", PT_VAR);\t\n    return;\n}\n\nstatic void usagePcrProperties(void)\n{\n    printf(\"TPM_CAP_PCR_PROPERTIES -pr is the first property\\n\");\n    return;\n}\n\nstatic void usageEccCurves(void)\n{\n    printf(\"TPM_CAP_ECC_CURVES -pr is the first curve\\n\");\n    return;\n}\n\nstatic void usageAuthPolicies(void)\n{\n    printf(\"TPM_CAP_AUTH_POLICIES -pr is the first handle in range 40000000\\n\");\n    return;\n}\n\nstatic void usageAct(void)\n{\n    printf(\"TPM_CAP_ACT -pr is the first handle in range 40000110\\n\");\n    return;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/getcommandauditdigest.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    GetCommandAuditDigest\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    GetCommandAuditDigest_In \tin;\n    GetCommandAuditDigest_Out \tout;\n    const char\t\t\t*privacyAdminPassword = NULL; \n    TPMI_DH_OBJECT\t\tsignHandle = 0;\n    const char\t\t\t*signPassword = NULL; \n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    const char\t\t\t*signatureFilename = NULL;\n    const char\t\t\t*attestInfoFilename = NULL;\n    const char\t\t\t*qualifyingDataFilename = NULL;\n    TPM_ALG_ID\t\t\tsigAlg = TPM_ALG_RSA;\n    TPMS_ATTEST \t\ttpmsAttest;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwde\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tprivacyAdminPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwde option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&signHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-salg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsa\") == 0) {\n\t\t    sigAlg = TPM_ALG_RSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"ecc\") == 0) {\n\t\t    sigAlg = TPM_ALG_ECDSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"hmac\") == 0) {\n\t\t    sigAlg = TPM_ALG_HMAC;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -salg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-salg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oa\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tattestInfoFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oa option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-qd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tqualifyingDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-qd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n   if (signHandle == 0) {\n\tprintf(\"Missing sign handle parameter -hk\\n\");\n\tprintUsage();\n    }\n   if (rc == 0) {\n       /* Handle of key that authorized the audit */\n       in.privacyHandle = TPM_RH_ENDORSEMENT;\n       in.signHandle = signHandle;\n       if (sigAlg == TPM_ALG_RSA) {\n\t   /* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\t   in.inScheme.scheme = TPM_ALG_RSASSA;\t\n\t   /* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\t   /* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t   /* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t   in.inScheme.details.rsassa.hashAlg = halg;\n       }\n       else if (sigAlg == TPM_ALG_ECDSA) {\n\t   in.inScheme.scheme = TPM_ALG_ECDSA;\t\n\t   in.inScheme.details.ecdsa.hashAlg = halg;\n       }\n       else {\t/* HMAC */\n\t   in.inScheme.scheme = TPM_ALG_HMAC;\t\n\t   in.inScheme.details.hmac.hashAlg = halg;\n       }\n    }\n    /* data supplied by the caller */\n    if (rc == 0) {\n\tif (qualifyingDataFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.qualifyingData.b,\n\t\t\t\t sizeof(in.qualifyingData.t.buffer),\n\t\t\t\t qualifyingDataFilename);\n\t}\n\telse {\n\t    in.qualifyingData.t.size = 0;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_GetCommandAuditDigest,\n\t\t\t sessionHandle0, privacyAdminPassword, sessionAttributes0,\n\t\t\t sessionHandle1, signPassword, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tuint8_t *tmpBuffer = out.auditInfo.t.attestationData;\n\tuint32_t tmpSize = out.auditInfo.t.size;\n\trc = TSS_TPMS_ATTEST_Unmarshalu(&tpmsAttest, &tmpBuffer, &tmpSize);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMS_ATTEST_Print(&tpmsAttest, 0);\n    }\n    if (rc == 0) {\n\tint match;\n\tmatch = TSS_TPM2B_Compare(&in.qualifyingData.b, &tpmsAttest.extraData.b);\n\tif (!match) {\n\t    printf(\"getcommandauditdigest: failed, extraData != qualifyingData\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if ((rc == 0) && (signatureFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.signature,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_SIGNATURE_Marshalu,\n\t\t\t\t     signatureFilename);\n\t\n\n    }\n    if ((rc == 0) && (attestInfoFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.auditInfo.t.attestationData,\n\t\t\t\t      out.auditInfo.t.size,\n\t\t\t\t      attestInfoFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMT_SIGNATURE_Print(&out.signature, 0);\n\tif (tssUtilsVerbose) printf(\"getcommandauditdigest: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"getcommandauditdigest: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"getcommandauditdigest\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_GetCommandAuditDigest\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwde\\tendorsement hierarchy password (default empty)]\\n\");\n    printf(\"\\t-hk\\tsigning key handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-salg\\tsignature algorithm (rsa, ecc, hmac) (default rsa)]\\n\");\n    printf(\"\\t[-qd\\tqualifying data file name]\\n\");\n    printf(\"\\t[-os\\tsignature file name (default do not save)]\\n\");\n    printf(\"\\t[-oa\\tattestation output file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/getcryptolibrary.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t    Get Crypto Library Name\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2019 - 2020\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\ti;    /* argc iterator */\n    const char \t\t*name = NULL;\n\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n    }\n    getCryptoLibrary(&name);\n    printf(\"%s\\n\", name);\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"getcryptolibrary\\n\");\n    printf(\"\\n\");\n    printf(\"Returns a string indicating the crypto library compiled in.\\n\");\n    printf(\"\\n\");\n    printf(\"This is used within test scripts.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/getrandom.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   GetRandom\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    GetRandom_In \t\tin;\n    GetRandom_Out \t\tout;\n    uint32_t\t\t\tbytesRequested = 0;\n    uint32_t \t\t\tbytesCopied;\n    const char \t\t\t*outFilename = NULL;\n    unsigned char \t\t*randomBuffer = NULL;\n    int\t\t\t\tnoZeros = FALSE;\n    int\t\t\t\tnoSpace = FALSE;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-by\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &bytesRequested);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -by\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-of\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-nz\") == 0) {\n\t    noZeros = TRUE;\n\t}\n \telse if (strcmp(argv[i],\"-ns\") == 0) {\n\t    noSpace = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((bytesRequested == 0) ||\n\t(bytesRequested > 0xffff)) {\n\tprintf(\"Missing or bad parameter -by\\n\");\n\tprintUsage();\n    }\n    /* allocate a buffer for the bytes requested, add 1 for optional nul terminator */\n    if (rc == 0) {\n\trc = TSS_Malloc(&randomBuffer, bytesRequested + 1);\t/* freed @1 */\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* This is somewhat optimized, but if a zero byte is obtained in the last pass, an extra pass is\n       needed.  The trade-off is that, in general, asking for more random numbers than needed may slow\n       down the TPM.  In any case, needing non-zero values for random auth should not happen very\n       often.\n     */\n    for (bytesCopied = 0 ; (rc == 0) && (bytesCopied < bytesRequested) ; ) {\n\t/* Request whatever is left */\n\tif (rc == 0) {\n\t    in.bytesRequested = bytesRequested - bytesCopied;\n\t}\n\t/* call TSS to execute the command */\n\tif (rc == 0) {\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     (RESPONSE_PARAMETERS *)&out, \n\t\t\t     (COMMAND_PARAMETERS *)&in,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_GetRandom,\n\t\t\t     sessionHandle0, NULL, sessionAttributes0,\n\t\t\t     sessionHandle1, NULL, sessionAttributes1,\n\t\t\t     sessionHandle2, NULL, sessionAttributes2,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n\tif (rc == 0) {\n\t    size_t br;\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"randomBytes in pass\",\n\t\t\t\t      out.randomBytes.t.buffer, out.randomBytes.t.size);\n\t    /* copy as many bytes as were received or until bytes requested */\n\t    for (br = 0 ; (br < out.randomBytes.t.size) && (bytesCopied < bytesRequested) ; br++) {\n\n\t\tif (!noZeros || (out.randomBytes.t.buffer[br] != 0)) {\n\t\t    randomBuffer[bytesCopied] = out.randomBytes.t.buffer[br];\n\t\t    bytesCopied++;\n\t\t}\n\t    }\n\t}\n\tif (rc == 0) {\n\t    if (noZeros) {\n\t\trandomBuffer[bytesCopied] = 0x00;\n\t    }\n\t}\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (outFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(randomBuffer, bytesRequested + (noZeros ? 1 : 0),\n\t\t\t\t      outFilename);\n    }\n    if (rc == 0) {\n\t/* machine readable format */\n\tif (noSpace) {\n\t    uint32_t bp;\n\t    for (bp = 0 ; bp < bytesRequested ; bp++) {\n\t\tprintf(\"%02x\", randomBuffer[bp]);\n\t    }\n\t    printf(\"\\n\");\n\t}\n\t/* human readable format */\n\telse {\n\t    TSS_PrintAll(\"randomBytes\", randomBuffer, bytesRequested);\n\t}\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"getrandom: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(randomBuffer);\t\t/* @1 */\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"getrandom\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_GetRandom\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-by\\tbytes requested\\n\");\n    printf(\"\\t[-of\\toutput file, with -nz, appends nul terminator (default do not save)]\\n\");\n    printf(\"\\t[-nz\\tget random number with no zero bytes (for authorization value)]\\n\");\n    printf(\"\\t[-ns\\tno space, no text, no newlines]\\n\");\n    printf(\"\\t\\tjust a string of hexascii suitable for a symmetric key\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/getsessionauditdigest.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    GetSessionAuditDigest\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    GetSessionAuditDigest_In \tin;\n    GetSessionAuditDigest_Out \tout;\n    const char\t\t\t*privacyAdminPassword = NULL; \n    TPMI_DH_OBJECT\t\tsignHandle = TPM_RH_NULL;\n    const char\t\t\t*signPassword = NULL; \n    TPMI_SH_HMAC\t\tsessionHandle = 0;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    const char\t\t\t*signatureFilename = NULL;\n    const char\t\t\t*attestInfoFilename = NULL;\n    const char\t\t\t*qualifyingDataFilename = NULL;\n    TPMS_ATTEST \t\ttpmsAttest;\n    const char\t\t\t*sessionDigestFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwde\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tprivacyAdminPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwde option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&signHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&sessionHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hs\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oa\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tattestInfoFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oa option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-od\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsessionDigestFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-od option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-qd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tqualifyingDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-qd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (sessionHandle == 0) {\n\tprintf(\"Missing session handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* Handle of key that authorizes the audit */\n\tin.privacyAdminHandle = TPM_RH_ENDORSEMENT;\n\tin.signHandle = signHandle;\n\tin.sessionHandle = sessionHandle;\n\t/* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\tin.inScheme.scheme = TPM_ALG_RSASSA;\t\n\t/* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\t/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t/* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\tin.inScheme.details.rsassa.hashAlg = halg;\n    }\n    /* data supplied by the caller */\n    if (rc == 0) {\n\tif (qualifyingDataFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.qualifyingData.b,\n\t\t\t\t sizeof(in.qualifyingData.t.buffer),\n\t\t\t\t qualifyingDataFilename);\n\t}\n\telse {\n\t    in.qualifyingData.t.size = 0;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_GetSessionAuditDigest,\n\t\t\t sessionHandle0, privacyAdminPassword, sessionAttributes0,\n\t\t\t sessionHandle1, signPassword, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tuint8_t *tmpBuffer = out.auditInfo.t.attestationData;\n\tuint32_t tmpSize = out.auditInfo.t.size;\n\trc = TSS_TPMS_ATTEST_Unmarshalu(&tpmsAttest, &tmpBuffer, &tmpSize);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMS_ATTEST_Print(&tpmsAttest, 0);\n    }\n    if (rc == 0) {\n\tint match;\n\tmatch = TSS_TPM2B_Compare(&in.qualifyingData.b, &tpmsAttest.extraData.b);\n\tif (!match) {\n\t    printf(\"getsessionauditdigest: failed, extraData != qualifyingData\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if ((rc == 0) && (signatureFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.signature,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_SIGNATURE_Marshalu,\n\t\t\t\t     signatureFilename);\n\t\n\n    }\n    if ((rc == 0) && (attestInfoFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.auditInfo.t.attestationData,\n\t\t\t\t      out.auditInfo.t.size,\n\t\t\t\t      attestInfoFilename);\n    }\n    if ((rc == 0) && (sessionDigestFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(tpmsAttest.attested.sessionAudit.sessionDigest.t.buffer,\t\n\t\t\t\t      tpmsAttest.attested.sessionAudit.sessionDigest.t.size,\n\t\t\t\t      sessionDigestFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMT_SIGNATURE_Print(&out.signature, 0);\n\tif (tssUtilsVerbose) printf(\"getsessionauditdigest: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"getsessionauditdigest: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"getsessionauditdigest\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_GetSessionAuditDigest\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwde\\tendorsement hierarchy password (default empty)]\\n\");\n    printf(\"\\t[-hk\\tsigning key handle]\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t-hs\\taudit session handle\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-qd\\tqualifying data file name]\\n\");\n    printf(\"\\t[-os\\tsignature file name (default do not save)]\\n\");\n    printf(\"\\t[-oa\\tattestation output file name (default do not save)]\\n\");\n    printf(\"\\t[-od\\tsession digest file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/gettestresult.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   GetTestResult\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2019.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n/* #include <ibmtss/Unmarshal_fp.h> */\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    GetTestResult_Out \t\tout;\n    const char \t\t\t*msg;\n    const char \t\t\t*submsg;\n    const char \t\t\t*num;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t NULL,\n\t\t\t NULL,\n\t\t\t TPM_CC_GetTestResult,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, out.testResult);\n\tprintf(\"testResult %s%s%s\\n\", msg, submsg, num);\n\t\n\tif (tssUtilsVerbose) TSS_PrintAll(\"outData\",\n\t\t\t\t  out.outData.t.buffer, out.outData.t.size);\n    }\n    else {\n\tprintf(\"gettestresult: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"gettestresult\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_GetTestResult\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/gettime.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    GetTime\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    GetTime_In \t\t\tin;\n    GetTime_Out \t\tout;\n    TPMI_DH_OBJECT\t\tsignHandle = 0;\n    const char\t\t\t*keyPassword = NULL; \n    const char\t\t\t*endorsementPassword = NULL; \n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    const char\t\t\t*signatureFilename = NULL;\n    const char\t\t\t*attestInfoFilename = NULL;\n    const char\t\t\t*qualifyingDataFilename = NULL;\n    TPM_ALG_ID\t\t\tsigAlg = TPM_ALG_RSA;\n    TPMS_ATTEST \t\ttpmsAttest;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &signHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwde\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tendorsementPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwde option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-salg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsa\") == 0) {\n\t\t    sigAlg = TPM_ALG_RSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"ecc\") == 0) {\n\t\t    sigAlg = TPM_ALG_ECDSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"hmac\") == 0) {\n\t\t    sigAlg = TPM_ALG_HMAC;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -salg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-salg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oa\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tattestInfoFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oa option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-qd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tqualifyingDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-qd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (signHandle == 0) {\n\tprintf(\"Missing sign handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* handle of the privacy administrator */\n\tin.privacyAdminHandle = TPM_RH_ENDORSEMENT;\n\t/* Handle of key that will perform signing */\n\tin.signHandle = signHandle;\n\tif (sigAlg == TPM_ALG_RSA) {\n\t    /* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\t    in.inScheme.scheme = TPM_ALG_RSASSA;\t\n\t    /* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\t    /* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t    /* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t    in.inScheme.details.rsassa.hashAlg = halg;\n\t}\n\telse if (sigAlg == TPM_ALG_ECDSA) {\n\t    in.inScheme.scheme = TPM_ALG_ECDSA;\t\n\t    in.inScheme.details.ecdsa.hashAlg = halg;\n\t}\n\telse {\t/* HMAC */\n\t    in.inScheme.scheme = TPM_ALG_HMAC;\t\n\t    in.inScheme.details.hmac.hashAlg = halg;\n\t}\n    }\n    /* data supplied by the caller */\n    if (rc == 0) {\n\tif (qualifyingDataFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.qualifyingData.b,\n\t\t\t\t sizeof(in.qualifyingData.t.buffer),\n\t\t\t\t qualifyingDataFilename);\n\t}\n\telse {\n\t    in.qualifyingData.t.size = 0;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_GetTime,\n\t\t\t sessionHandle0, endorsementPassword, sessionAttributes0,\n\t\t\t sessionHandle1, keyPassword, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tuint8_t *tmpBuffer = out.timeInfo.t.attestationData;\n\tuint32_t tmpSize = out.timeInfo.t.size;\n\trc = TSS_TPMS_ATTEST_Unmarshalu(&tpmsAttest, &tmpBuffer, &tmpSize);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMS_ATTEST_Print(&tpmsAttest, 0);\n    }\n    if (rc == 0) {\n\tint match;\n\tmatch = TSS_TPM2B_Compare(&in.qualifyingData.b, &tpmsAttest.extraData.b);\n\tif (!match) {\n\t    printf(\"quote: failed, extraData != qualifyingData\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if ((rc == 0) && (signatureFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.signature,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_SIGNATURE_Marshalu,\n\t\t\t\t     signatureFilename);\n    }    \n    if ((rc == 0) && (attestInfoFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.timeInfo.t.attestationData,\n\t\t\t\t      out.timeInfo.t.size,\n\t\t\t\t      attestInfoFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMT_SIGNATURE_Print(&out.signature, 0);\n\tif (tssUtilsVerbose) printf(\"gettime: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"gettime: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"gettime\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_GetTime\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tsigning key handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for signing key (default empty)]\\n\");\n    printf(\"\\t[-pwde\\tpassword for endorsement hierarchy (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-salg\\tsignature algorithm (rsa, ecc, hmac) (default rsa)]\\n\");\n    printf(\"\\t[-qd\\tqualifying data file name]\\n\");\n    printf(\"\\t[-os\\tsignature file name  (default do not save)]\\n\");\n    printf(\"\\t[-oa\\tattestation output file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/hash.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Hash\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\nstatic void printHash(Hash_Out *out);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Hash_In \t\t\tin;\n    Hash_Out \t\t\tout;\n    char \t\t\thierarchyChar = 'n';\n    TPMI_RH_HIERARCHY\t\thierarchy = TPM_RH_NULL;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    const char\t\t\t*inFilename = NULL;\n    const char \t\t\t*inString = NULL;\n    const char\t\t\t*hashFilename = NULL;\n    const char\t\t\t*ticketFilename = NULL;\n    int\t\t\t\tnoSpace = FALSE;\n \n    size_t \t\t\tlength = 0;\n    uint8_t\t\t\t*buffer = NULL;\t/* for the free */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinString = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-oh\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thashFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oh option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ns\") == 0) {\n\t    noSpace = TRUE;\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((inFilename == NULL) && (inString == NULL)) {\n\tprintf(\"Input file -if or input string -ic must be specified\\n\");\n\tprintUsage();\n    }\n    if ((inFilename != NULL) && (inString != NULL)) {\n\tprintf(\"Input file -if and input string -ic cannot both be specified\\n\");\n\tprintUsage();\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (hierarchyChar == 'e') {\n\t    hierarchy = TPM_RH_ENDORSEMENT;\n\t}\n\telse if (hierarchyChar == 'o') {\n\t    hierarchy = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    hierarchy = TPM_RH_PLATFORM;\n\t}\n\telse if (hierarchyChar == 'n') {\n\t    hierarchy = TPM_RH_NULL;\n\t}\n\telse {\n\t    printf(\"Bad parameter %c for -hi\\n\", hierarchyChar);\n\t    printUsage();\n\t}\n \tin.hierarchy = hierarchy;\n    }\n    if (inFilename != NULL) {\n\tif (rc == 0) {\n\t    rc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t\t &length,\n\t\t\t\t\t inFilename);\n\t}\n\tif (rc == 0) {\n\t    if (length > sizeof(in.data.t.buffer)) {\n\t\tprintf(\"Input data too long %lu\\n\", (unsigned long)length);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    /* data to be hashed */\n\t    in.data.t.size = (uint16_t)length;\t/* cast safe, range tested above */\n\t    memcpy(in.data.t.buffer, buffer, length);\n\t}\n    }\n    if (inString != NULL) {\n\tif (rc == 0) {\n\t    length = strlen(inString);\n\t    if (length > sizeof(in.data.t.buffer)) {\n\t\tprintf(\"Input data too long %lu\\n\", (unsigned long)length);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    } \n\t}\n\tif (rc == 0) {\n\t    /* data to be hashed */\n\t    in.data.t.size = (uint16_t)length;\t/* cast safe, range tested above */\n\t    memcpy(in.data.t.buffer, inString, length);\n\t}\n    }\n    if (rc == 0) {\n\tin.hashAlg = halg;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Hash,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (hashFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.outHash.t.buffer,\n\t\t\t\t      out.outHash.t.size,\n\t\t\t\t      hashFilename); \n    }\n    if ((rc == 0) && (ticketFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.validation,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_TK_HASHCHECK_Marshalu,\n\t\t\t\t     ticketFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printHash(&out);\n\tif (noSpace) {\n\t    uint32_t bp;\n\t    for (bp = 0 ; bp < out.outHash.t.size ; bp++) {\n\t\tprintf(\"%02x\", out.outHash.t.buffer[bp]);\n\t    }\n\t    printf(\"\\n\");\n\t}\n\tif (tssUtilsVerbose) printf(\"hash: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"hash: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\nstatic void printHash(Hash_Out *out)\n{\n    TSS_PrintAll(\"Hash\", out->outHash.t.buffer, out->outHash.t.size);\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"hash\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Hash\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hi\\thierarchy (e, o, p, n) (default null)]\\n\");\n    printf(\"\\t\\te endorsement, o owner, p platform, n null\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t-if\\tinput file to be hashed\\n\");\n    printf(\"\\t-ic\\tdata string to be hashed\\n\");\n    printf(\"\\t[-ns\\tno space, no text, no newlines]\\n\");\n    printf(\"\\t[-oh\\thash file name (default do not save)]\\n\");\n    printf(\"\\t[-tk\\tticket file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/hashsequencestart.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    HashSequenceStart\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    HashSequenceStart_In \tin;\n    HashSequenceStart_Out\tout;\n    const char\t\t\t*authPassword = NULL; \n    TPMI_ALG_HASH\t\thashAlg = TPM_ALG_SHA256;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    hashAlg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    hashAlg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    hashAlg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    hashAlg = TPM_ALG_SHA512;\n\t\t}\n\t\telse if (strcmp(argv[i],\"null\") == 0) {\n\t\t    hashAlg = TPM_ALG_NULL;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\t/* auth value for sequence */\n\trc = TSS_TPM2B_StringCopy(&in.auth.b, authPassword, sizeof(in.auth.t.buffer));\n    }\n    if (rc == 0) {\n\tin.hashAlg = hashAlg;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_HashSequenceStart,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"hashsequencestart: handle %08x\\n\", out.sequenceHandle);\n\tif (tssUtilsVerbose) printf(\"hashsequencestart: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"hashsequencestart: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"hashsequencestart\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_HashSequenceStart\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwda\\tpassword for sequence (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512, null) (default sha256)]\\n\");\n    printf(\"\\t\\tnull is an event sequence\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/hierarchychangeauth.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    HierarchyChangeAuth\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    HierarchyChangeAuth_In \tin;\n    char \t\t\thierarchyChar = 0;\n    const char\t\t\t*newPassword = NULL; \n    const char\t\t\t*newPasswordFilename = NULL;\n    const char\t\t\t*authPassword = NULL; \n    const char\t\t\t*authPasswordFilename = NULL;\n    /* authPasswordPtr is used as the command auth value.  It is either the supplied authPassword\n       string, the password read from the authPasswordFilename file, or NULL */\n    const char\t\t\t*authPasswordPtr = NULL; \n    uint8_t\t\t\t*authPasswordBuffer = NULL;\t\t/* for the free */\n    size_t \t\t\tauthPasswordLength = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnewPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdni\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnewPasswordFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"pwdni -option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdai\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPasswordFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdai option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (hierarchyChar == 'l') {\n\t    in.authHandle = TPM_RH_LOCKOUT;\n\t}\n\telse if (hierarchyChar == 'e') {\n\t    in.authHandle = TPM_RH_ENDORSEMENT;\n\t}\n\telse if (hierarchyChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tif ((newPassword != NULL) && (newPasswordFilename != NULL)) {\n\t    printf(\"Cannot specify both -pwdn and -pwdni\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tif ((authPassword != NULL) && (authPasswordFilename != NULL)) {\n\t    printf(\"Cannot specify both -pwda and -pwdai\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\t/* new auth from string */\n\tif (newPassword != NULL) {\n\t    /* convert password string to TPM2B */\n\t    rc = TSS_TPM2B_StringCopy(&in.newAuth.b,\n\t\t\t\t      newPassword, sizeof(in.newAuth.t.buffer));\n\t}\n\t/* new auth from file */\n\telse if (newPasswordFilename != NULL) {\n\t    uint8_t\t\t\t*buffer = NULL;\t\t/* for the free */\n\t    size_t \t\t\tlength = 0;\n\t    /* read new auth value from the file */\n\t    if (rc == 0) {\n\t\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t\t     &length,\n\t\t\t\t\t     newPasswordFilename);\n\t\tif ((length == 0) ||\n\t\t    (buffer[length-1] != '\\0')) {\n\t\t    printf(\"-pwdni file must be nul terminated\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    /* convert password file string to TPM2B */\n\t    if (rc == 0) {\n\t\trc = TSS_TPM2B_StringCopy(&in.newAuth.b,\n\t\t\t\t\t  (const char *)buffer, sizeof(in.newAuth.t.buffer));\n\t    }\n\t    free(buffer);\t/* @1 */\n\t    buffer = NULL;\n\t}\n\t/* no new auth specified */\n\telse {\n\t    in.newAuth.t.size = 0;\n\t}\n    }\n    if (rc == 0) {\n\t/* command auth from string */\n\tif (authPassword != NULL) {\n\t    authPasswordPtr = authPassword; \n\t}\n\t/* command auth from file */\n\telse if (authPasswordFilename != NULL) {\n\t    if (rc == 0) {\n\t\t/* must be freed by caller */\n\t\trc = TSS_File_ReadBinaryFile(&authPasswordBuffer,\n\t\t\t\t\t     &authPasswordLength,\n\t\t\t\t\t     authPasswordFilename);\n\t\tif ((authPasswordLength > sizeof(TPMU_HA)) ||\n\t\t    (authPasswordLength == 0) ||\n\t\t    (authPasswordBuffer[authPasswordLength -1] != '\\0')) {\n\t\t    printf(\"-pwdai file must be nul terminated\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    if (rc == 0) {\n\t\tauthPasswordPtr = (const char *)authPasswordBuffer;\n\t    }\n\t}\n\t/* no command auth specified */\n\telse {\n\t    authPasswordPtr = NULL;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_HierarchyChangeAuth,\n\t\t\t sessionHandle0, authPasswordPtr, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"hierarchychangeauth: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"hierarchychangeauth: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(authPasswordBuffer);\n    authPasswordBuffer = NULL;\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"hierarchychangeauth\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_HierarchyChangeAuth\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hi\\thierarchy (l, e, o, p)\\n\");\n    printf(\"\\t\\tl lockout, e endorsement, o owner, p platform\\n\");\n    printf(\"\\t-pwdn\\tnew authorization password (default empty)\\n\");\n    printf(\"\\t-pwdni\\tnew authorization password file name (default empty)\\n\");\n    printf(\"\\t-pwda\\tauthorization password (default empty)\\n\");\n    printf(\"\\t-pwdai\\tauthorization password file name (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/hierarchycontrol.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    HierarchyControl\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    HierarchyControl_In \tin;\n    char \t\t\tauthHandleChar = 0;\n    char \t\t\tenableHandleChar = 0;\n    int\t\t\t\tstate = 1;\n    const char\t\t\t*authPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthHandleChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-he\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tenableHandleChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -he\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-state\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tstate = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-state option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (authHandleChar == 'e') {\n\t    in.authHandle = TPM_RH_ENDORSEMENT;\n\t}\n\telse if (authHandleChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;\n\t}\n\telse if (authHandleChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tif (enableHandleChar == 'e') {\n\t    in.enable = TPM_RH_ENDORSEMENT;\n\t}\n\telse if (enableHandleChar == 'o') {\n\t    in.enable = TPM_RH_OWNER;\n\t}\n\telse if (enableHandleChar == 'p') {\n\t    in.enable = TPM_RH_PLATFORM;\n\t}\n\telse if (enableHandleChar == 'n') {\n\t    in.enable = TPM_RH_PLATFORM_NV;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -he\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tif (state != 0) {\n\t    in.state = YES;\n\t}\n\telse {\n\t    in.state = NO;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_HierarchyControl,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"hierarchycontrol: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"hierarchycontrol: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"hierarchycontrol\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_HierarchyControl\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hi\\tauthhandle hierarchy (e, o, p)\\n\");\n    printf(\"\\t-he\\tenable hierarchy (e, o, p, n)\\n\");\n    printf(\"\\t\\te\\tendorsement, o owner, p platform, n platform NV\\n\");\n    printf(\"\\t[-pwda\\tauthorization password (default empty)]\\n\");\n    printf(\"\\t[-state\\t(0 to disable, 1 to enable) (default enable)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/hmac.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Hmac\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\nstatic void printHmac(HMAC_Out *out);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    HMAC_In \t\t\tin;\n    HMAC_Out \t\t\tout;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    const char\t\t\t*inFilename = NULL;\n    const char \t\t\t*inString = NULL;\n    const char\t\t\t*hmacFilename = NULL;\n    const char\t\t\t*keyPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    size_t \t\t\tlength = 0;\n    uint8_t\t\t\t*buffer = NULL;\t/* for the free */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinString = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thmacFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if ((inFilename == NULL) && (inString == NULL)) {\n\tprintf(\"Input file -if or input string -ic must be specified\\n\");\n\tprintUsage();\n    }\n    if ((inFilename != NULL) && (inString != NULL)) {\n\tprintf(\"Input file -if and input string -ic cannot both be specified\\n\");\n\tprintUsage();\n    }\n    if (inFilename != NULL) {\n\tif (rc == 0) {\n\t    rc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t\t &length,\n\t\t\t\t\t inFilename);\n\t}\n\tif (rc == 0) {\n\t    if (length > sizeof(in.buffer.t.buffer)) {\n\t\tprintf(\"Input data too long %lu\\n\", (unsigned long)length);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    /* data to be HMACed */\n\t    in.buffer.t.size = (uint16_t)length;\t/* cast safe, range tested above */\n\t    memcpy(in.buffer.t.buffer, buffer, length);\n\t}\n    }\n    if (inString != NULL) {\n\tif (rc == 0) {\n\t    length = strlen(inString);\n\t    if (length > sizeof(in.buffer.t.buffer)) {\n\t\tprintf(\"Input data too long %lu\\n\", (unsigned long)length);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    } \n\t}\n\tif (rc == 0) {\n\t    /* data to be hashed */\n\t    in.buffer.t.size =(uint16_t) length;\t/* cast safe, range tested above */\n\t    memcpy(in.buffer.t.buffer, inString, length);\n\t}\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform hmac */\n\tin.handle = keyHandle;\n\t/* use key's hash algorithm */\n\tin.hashAlg = halg;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_HMAC,\n\t\t\t sessionHandle0, keyPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (hmacFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.outHMAC.t.buffer,\n\t\t\t\t      out.outHMAC.t.size,\n\t\t\t\t      hmacFilename); \n    }    \n    if (rc == 0) {\n\tif (tssUtilsVerbose) printHmac(&out);\n\tif (tssUtilsVerbose) printf(\"hmac: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"hmac: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\nstatic void printHmac(HMAC_Out *out)\n{\n    TSS_PrintAll(\"HMAC\", out->outHMAC.t.buffer, out->outHMAC.t.size);\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"hmac\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_HMAC\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t-if\\tinput file to be HMACed\\n\");\n    printf(\"\\t-ic\\tdata string to be HMACed\\n\");\n    printf(\"\\t[-os\\thmac file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/hmacstart.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    HmacStart\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    HMAC_Start_In \t\tin;\n    HMAC_Start_Out \t\tout;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    const char\t\t\t*keyPassword = NULL; \n    const char\t\t\t*authPassword = NULL; \n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform hmac */\n\tin.handle = keyHandle;\n\t/* auth value for sequence */\n\trc = TSS_TPM2B_StringCopy(&in.auth.b, authPassword, sizeof(in.auth.t.buffer));\n    }\n    if (rc == 0) {\n\tin.hashAlg = halg;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_HMAC_Start,\n\t\t\t sessionHandle0, keyPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"hmacstart: handle %08x\\n\", out.sequenceHandle);\n\tif (tssUtilsVerbose) printf(\"hmacstart: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"hmacstart: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"hmacstart\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Hmac_Start\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t-pwdk\\tpassword for key (default empty)\\n\");\n    printf(\"\\t-pwda\\tpassword for sequence (default empty)\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/imaextend.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t      Extend an IMA measurement list into PCRs\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2014 - 2023.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* imaextend is test/demo code.  It parses a TPM 1.2 IMA event log file and extends the measurements\n   into TPM PCRs or simulated PCRs.  This simulates the actions that would be performed by the Linux\n   kernel IMA in a hardware platform.\n\n   To test incremental attestations, the caller can optionally specify a beginning event number and\n   ending event number.\n\n   To test a platform without a TPM or TPM device driver, but where IMA is creating an event log,\n   the caller can optionally specify a sleep time.  The program will then incrementally extend after\n   each sleep.\n\n   Two IMA log types are supported:\n\n   Type 1: For an older kernel that zero extends SHA-256 PCR\n\n   sha1 bank: extends the template hash\n\n   sha256 bank: extends a zero padded template hash\n\n   Type 2: For a transition kernel that correctly extends SHA-256, etc, but does not have a hash\n   agile IMA log.  The template hash is calcaulated as a hash of the template data.\n\n   In the future, support for a hash agile IMA log is anticipated.\n*/\n\n/* Design:  The inner loop reads and parses each IMA event.  Then:\n\n   addDigest() populates a PCR_Extend_In structure.\n\n   then:\n\n   If the TPM is being used, TSS_Execute() is called.\n\n   For a simulation, extendDigest() is called.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#include <windows.h>\n#endif\n\n#ifdef TPM_POSIX\n#include <unistd.h>\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tssutils.h>\n\n#include \"imalib.h\"\n\n/* local prototypes */\n\nstatic TPM_RC addDigest(PCR_Extend_In \t*pcrExtendIn,\n\t\t\tint \t\ttype,\n\t\t\tImaEvent \t*imaEvent);\nstatic TPM_RC checkTemplateHash(ImaEvent \t*imaEvent,\n\t\t\t\tint \t\ttype,\n\t\t\t\tint \t\teventNum);\nstatic TPM_RC extendDigest(TPMT_HA \t\tsimPcrs[][IMPLEMENTATION_PCR],\n\t\t\t   PCR_Extend_In\t*pcrExtendIn);\nstatic TPM_RC pcrread(TSS_CONTEXT *tssContext,\n\t\t      PCR_Read_In *pcrReadIn,\n\t\t      TPMI_DH_PCR pcrHandle);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\nint vverbose = FALSE;\n\nint main(int argc, char * argv[])\n{\n    TPM_RC \t\trc = 0;\n    int \t\ti = 0;\n    TSS_CONTEXT\t\t*tssContext = NULL;\n    PCR_Extend_In \tpcrExtendIn;\n    PCR_Read_In \tpcrReadIn;\n    const char \t\t*infilename = NULL;\n    const char \t\t*outfilename = NULL;\n    FILE \t\t*infile = NULL;\n    int \t\tlittleEndian = FALSE;\n    int\t\t\ttype = 1;\t\t\t/* IMA log type, default 1 */\n    int\t\t\tsim = FALSE;\t\t\t/* extend into simulated PCRs */\n    int\t\t\tcheckHash = FALSE;\t\t/* verify IMA log hashes */\n    int\t\t\tcheckData = FALSE;\t\t/* verify IMA log template data */\n    uint32_t \t\tbankNum = 0;\t\t\t/* PCR hash bank iterator */\n    unsigned int \tpcrNum = 0;\t\t\t/* PCR number iterator */\n    TPMT_HA \t\tsimPcrs[HASH_COUNT][IMPLEMENTATION_PCR];\n    unsigned long\tbeginEvent = 0;\t\t\t/* default beginning of log */\n    unsigned long\tendEvent = 0xffffffff;\t\t/* default end of log */\n    unsigned int\tloopTime = 0;\t\t\t/* default no loop */\n    ImaEvent \t\timaEvent;\n    unsigned int \tlineNum;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    /* no hash algorithms specified yet */\n    pcrExtendIn.digests.count = 0; \n    pcrReadIn.pcrSelectionIn.count = 0;\n\n    for (i=1 ; i<argc ; i++) {\n\tif (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinfilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutfilename = argv[i];\n\t    } else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    pcrExtendIn.digests.count++;\t/* count number of algoriths specified */\n\t    pcrReadIn.pcrSelectionIn.count++;\n\t    if (pcrExtendIn.digests.count > HASH_COUNT) {\n\t\tprintf(\"Too many -halg specifiers, %u permitted\\n\", HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    pcrExtendIn.digests.digests[pcrExtendIn.digests.count-1].hashAlg =\n\t\t\tTPM_ALG_SHA1;\n\t\t    pcrReadIn.pcrSelectionIn.pcrSelections[pcrReadIn.pcrSelectionIn.count-1].hash =\n\t\t\tTPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    pcrExtendIn.digests.digests[pcrExtendIn.digests.count-1].hashAlg =\n\t\t\tTPM_ALG_SHA256;\n\t\t    pcrReadIn.pcrSelectionIn.pcrSelections[pcrReadIn.pcrSelectionIn.count-1].hash =\n\t\t\tTPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    pcrExtendIn.digests.digests[pcrExtendIn.digests.count-1].hashAlg =\n\t\t\tTPM_ALG_SHA384;\n\t\t    pcrReadIn.pcrSelectionIn.pcrSelections[pcrReadIn.pcrSelectionIn.count-1].hash =\n\t\t\tTPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    pcrExtendIn.digests.digests[pcrExtendIn.digests.count-1].hashAlg =\n\t\t\tTPM_ALG_SHA512;\n\t\t    pcrReadIn.pcrSelectionIn.pcrSelections[pcrReadIn.pcrSelectionIn.count-1].hash =\n\t\t\tTPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tpm\") == 0) {\n\t    sim = FALSE;\n\t}\n\telse if (strcmp(argv[i],\"-sim\") == 0) {\n\t    sim = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-checkhash\") == 0) {\n\t    checkHash = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-checkdata\") == 0) {\n\t    checkData = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-ty\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &type);\n\t\tif ((type != 1) && (type != 2)) {\n\t\t    printf(\"Bad parameter %s for -ty\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-ty option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-le\") == 0) {\n\t    littleEndian = TRUE; \n\t}\n\telse if (strcmp(argv[i],\"-b\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%lu\", &beginEvent);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -b\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-e\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%lu\", &endEvent);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -e\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-l\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &loopTime);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -e\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (!strcmp(argv[i], \"-h\")) {\n\t    printUsage();\n\t}\n\telse if (!strcmp(argv[i], \"-v\")) {\n\t    tssUtilsVerbose = TRUE;\n\t    vverbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (infilename == NULL) {\n\tprintf(\"Missing -if argument\\n\");\n\tprintUsage();\n    }\n    /* if no -halg algorithms specified, default to sha1 and sha256 */\n    if (pcrReadIn.pcrSelectionIn.count == 0) {\n\tpcrExtendIn.digests.count = 2;\n\tpcrReadIn.pcrSelectionIn.count = 2;\n\tpcrExtendIn.digests.digests[0].hashAlg = TPM_ALG_SHA1;\n\tpcrExtendIn.digests.digests[1].hashAlg = TPM_ALG_SHA256;\n\tpcrReadIn.pcrSelectionIn.pcrSelections[0].hash = TPM_ALG_SHA1;\n\tpcrReadIn.pcrSelectionIn.pcrSelections[1].hash = TPM_ALG_SHA256;\n    }\n    /* type 1 IMA logs zero extend into the SHA-256 bank */\n    if ((rc == 0) && (type == 1)) {\n\tfor (bankNum = 0 ; bankNum < pcrExtendIn.digests.count ; bankNum++) {\n\t    memset((uint8_t *)&pcrExtendIn.digests.digests[bankNum].digest, 0, sizeof(TPMU_HA));\n\t}\n    }\n    /* extending into TPM PCRs */\n    if (!sim) {\n\t/* Start a TSS context */\n\tif (rc == 0) {\n\t    rc = TSS_Create(&tssContext);\n\t}\n\tif ((rc == 0) && tssUtilsVerbose) {\t/* for debug */\n\t    printf(\"Initial PCR 10 value\\n\");\n\t    rc = pcrread(tssContext, &pcrReadIn, 10);\n\t}\n    }\n    else {\t/* sim TRUE */\n\t/* simulated PCRs start at zero at boot */\n\tif (rc == 0) {\n\t    for (bankNum = 0 ; bankNum < pcrExtendIn.digests.count ; bankNum++) {\n\t\tfor (pcrNum = 0 ; pcrNum < IMPLEMENTATION_PCR ; pcrNum++) {\n\t\t    /* initialize each algorithm ID */\n\t\t    simPcrs[bankNum][pcrNum].hashAlg = pcrExtendIn.digests.digests[bankNum].hashAlg;\n\t\t    memset(&simPcrs[bankNum][pcrNum].digest.tssmax, 0,\n\t\t\t   sizeof(simPcrs[bankNum][pcrNum].digest.tssmax));\n\t\t}\n\t    }\n\t}\n    }\n    /*\n      scan each measurement 'line' in the binary\n    */\n    do {\n\t/* read the IMA event log file */\n\tint endOfFile = FALSE;\n\tif (rc == 0) {\n\t    /* ignore VS false positive, infilename checked for NULL above */\n\t    infile = fopen(infilename,\"rb\");\n\t    if (infile == NULL) {\n\t\tprintf(\"Unable to open input file '%s'\\n\", infilename);\n\t\trc = TSS_RC_FILE_OPEN;\n\t    }\n\t}\n\tfor (lineNum = 0 ; (rc == 0) && !endOfFile ; lineNum++) {\n\t    /* read an IMA event line */\n\t    IMA_Event_Init(&imaEvent);\n\t    if (rc == 0) {\n\t\trc = IMA_Event_ReadFile(&imaEvent, &endOfFile, infile,\n\t\t\t\t\tlittleEndian);\n\t    }\n\t    /*\n\t      if the event line is in range\n\t    */\n\t    if ((rc == 0) && (lineNum >= beginEvent) && (lineNum <= endEvent) && !endOfFile) {\n\t\t/* debug tracing */\n\t\tif (rc == 0) {\n\t\t    ImaTemplateData imaTemplateData;\n\t\t    if (tssUtilsVerbose) printf(\"\\n\");\n\t\t    printf(\"imaextend: line %u\\n\", lineNum);\n\t\t    if (tssUtilsVerbose) {\n\t\t\tIMA_Event_Trace(&imaEvent, FALSE);\n\t\t\t/* unmarshal the template data */\n\t\t\tif (rc == 0) {\n\t\t\t    rc = IMA_TemplateData_ReadBuffer(&imaTemplateData,\n\t\t\t\t\t\t\t     &imaEvent,\n\t\t\t\t\t\t\t     littleEndian);\n\t\t\t}\n\t\t\tif (rc == 0) {\n\t\t\t    IMA_TemplateData_Trace(&imaTemplateData,\n\t\t\t\t\t\t   imaEvent.nameInt);\n\t\t\t}\n\t\t\telse {\n\t\t\t    printf(\"imaextend: Error parsing template data, event %u\\n\", lineNum);\n\t\t\t    if (!checkData) {\n\t\t\t\trc = 0;\t\t/* not a fatal error */\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t\t/* add the digest to be extended into the PCR_Extend_In banks */\n\t\tif (rc == 0) {\n\t\t    rc = addDigest(&pcrExtendIn, type, &imaEvent);\n\t\t}\n\t\tif ((rc == 0) && checkHash) {\n\t\t    rc = checkTemplateHash(&imaEvent, type, lineNum);\n\t\t}\n\t\tif (rc == 0) {\n\t\t    pcrExtendIn.pcrHandle = imaEvent.pcrIndex;\t\t/* normally PCR 10 */\n\t\t    /* even though IMA_Event_ReadFile() range checks the PCR index, range check it\n\t\t       again here to silence the static analysis tool */\n\t\t    if (imaEvent.pcrIndex >= IMPLEMENTATION_PCR) {\n\t\t\tprintf(\"imaextend: PCR index %u %08x out of range\\n\",\n\t\t\t       imaEvent.pcrIndex, imaEvent.pcrIndex);\n\t\t\trc = TSS_RC_BAD_PROPERTY_VALUE;\n\t\t    }\n\t\t}\n\t\tif (!sim) {\t/* extend into TPM PCRs */\n\t\t    if (rc == 0) {\n\t\t\trc = TSS_Execute(tssContext,\n\t\t\t\t\t NULL, \n\t\t\t\t\t (COMMAND_PARAMETERS *)&pcrExtendIn,\n\t\t\t\t\t NULL,\n\t\t\t\t\t TPM_CC_PCR_Extend,\n\t\t\t\t\t TPM_RS_PW, NULL, 0,\n\t\t\t\t\t TPM_RH_NULL, NULL, 0);\n\t\t    }\n\t\t    if (rc == 0 && tssUtilsVerbose) {\t/* debug reace PCR result */\n\t\t\trc = pcrread(tssContext, &pcrReadIn, imaEvent.pcrIndex);\n\t\t    }\n\t\t}\n\t\telse {\t\t/* sim */\n\t\t    if (rc == 0) {\n\t\t\trc = extendDigest(simPcrs, &pcrExtendIn);\n\t\t    }\n\t\t}\n\t    }\n\t    IMA_Event_Free(&imaEvent);\n\t}\t/* for each IMA event line */\n\tif (tssUtilsVerbose && (loopTime != 0)) printf(\"set beginEvent to %u\\n\", lineNum-1);\n\tbeginEvent = lineNum-1;\t\t/* remove the last increment at EOF */\n\tif (infile != NULL) {\n\t    fclose(infile);\n\t}\n#ifdef TPM_POSIX\n\tsleep(loopTime);\n#endif\n#ifdef TPM_WINDOWS\n\tSleep(loopTime * 1000);\n#endif\n    } while ((rc == 0) && (loopTime != 0)); \t\t/* sleep loop */\n    if (!sim) {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\t\t/* close the TPM connection */\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    else {\t/* sim, trace the simulated PCR result */\n\tuint16_t \tdigestSize;\n\tfor (bankNum = 0 ; (rc == 0) && (bankNum < pcrExtendIn.digests.count) ; bankNum++) {\n\t    TSS_TPM_ALG_ID_Print(\"algorithmId\", simPcrs[bankNum][0].hashAlg, 0);\n\t    for (pcrNum = 0 ; pcrNum < IMPLEMENTATION_PCR ; pcrNum++) {\n\t        char \t\tpcrString[9];\t/* PCR number */\n\t\tsprintf(pcrString, \"PCR %02u:\", pcrNum);\n\t\t/* TSS_PrintAllLogLevel() with a log level of LOGLEVEL_INFO to print the byte\n\t\t   array on one line with no length */\n\t\tdigestSize = TSS_GetDigestSize(simPcrs[bankNum][pcrNum].hashAlg);\n\t\tTSS_PrintAllLogLevel(LOGLEVEL_INFO, pcrString, 1,\n\t\t\t\t     simPcrs[bankNum][pcrNum].digest.tssmax,\n\t\t\t\t     digestSize);\n\t    }\n\t}\n\t/* write PCR 10 for the first hash algorithm, for the regression test */\n\tif ((rc == 0) && (outfilename != NULL)) {\n\t    digestSize = TSS_GetDigestSize(simPcrs[0][10].hashAlg);\n\t    rc = TSS_File_WriteBinaryFile(simPcrs[0][10].digest.tssmax,\n\t\t\t\t\t  digestSize,\n\t\t\t\t\t  outfilename);\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"imaextend: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"imaextend: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n/* checkTemplateHash() validates the IMA event SHA-1 template hash against the hash of the template\n   data. */\n\nstatic TPM_RC checkTemplateHash(ImaEvent \t*imaEvent,\n\t\t\t\tint \t\ttype,\n\t\t\t\tint \t\teventNum)\n{\n    TPM_RC \t\trc = 0;\n    int \t\tnotAllZero;\n    unsigned char \tzeroDigest[SHA1_DIGEST_SIZE];\t/* compare to SHA-1 digest in event log */\n    uint32_t \t\tbadEvent;\n\n    type = type;\t/* unused until a hash agile log is supported */\n    if (rc == 0) {\n\tmemset(zeroDigest, 0, sizeof(zeroDigest));\n\tnotAllZero = memcmp(imaEvent->digest, zeroDigest, sizeof(zeroDigest));\n    }\n    if ((rc == 0) && notAllZero) {\n\trc = IMA_VerifyImaDigest(&badEvent, \t/* TRUE if hash does not match */\n\t\t\t\t imaEvent, \t/* the current IMA event being processed */\n\t\t\t\t eventNum);\t/* the current IMA event number being processed */\n\tif ((rc == 0) && badEvent) {\n\t    printf(\"imaextend: Hash of template data does not match template hash\\n\");\n\t    rc = TSS_RC_HASH;\n\t}\n    }\n    return rc;\n}\n\n/* addDigest() adds the digests to the pcrExtendIn structure.  It is used before extending either\n   the TPM PCRs of the simulated PCRs.\n\n   The sha1 digest comes from the imaEvent->digest field.\n\n   Type 1: The other digests are copied to the already 0 extended other banks\n   Type 2: The other digests are a hash of the template data field.\n\n   This function also handles the zeros to ones IMA quirk.\n*/\n\nstatic TPM_RC addDigest(PCR_Extend_In \t*pcrExtendIn,\n\t\t\tint \t\ttype,\n\t\t\tImaEvent \t*imaEvent)\n{\n    TPM_RC \t\trc = 0;\n    uint32_t \t\tbankNum = 0;\t\t\t\t/* PCR hash bank interator */\n    uint8_t \t\tzeroDigest[SHA1_DIGEST_SIZE];\n    int \t\tnotAllZero;\n    uint16_t \t\tdigestSize;\n\n    /* determine if the template hash (always sha1) is all zeros */\n    if (rc == 0) {\n\tmemset(zeroDigest, 0, sizeof(zeroDigest));\n\tnotAllZero = memcmp(imaEvent->digest, zeroDigest, SHA1_DIGEST_SIZE);\n    }\n    for (bankNum = 0 ; bankNum < pcrExtendIn->digests.count ; bankNum++) {\n\n\tif (type == 1) {\n\t    if (notAllZero) {\n\t\tmemcpy((uint8_t *)&pcrExtendIn->digests.digests[bankNum].digest,\n\t\t       imaEvent->digest, SHA1_DIGEST_SIZE);\n\t    }\n\t    /* IMA has a quirk where some measurements store a zero digest in the event log, but\n\t       extend ones into PCR 10 */\n\t    else {\n\t\tmemset((uint8_t *)&pcrExtendIn->digests.digests[bankNum].digest,\n\t\t       0xff, SHA1_DIGEST_SIZE);\n\t    }\n\t}\n\telse if (type == 2) {\n\t    digestSize = TSS_GetDigestSize(pcrExtendIn->digests.digests[bankNum].hashAlg);\n\n\t    if (notAllZero) {\n\t\t/* sha1 gets the imaEvent->digest field directly */\n\t\tif (pcrExtendIn->digests.digests[bankNum].hashAlg == TPM_ALG_SHA1) {\n\t\t    memcpy((uint8_t *)&pcrExtendIn->digests.digests[bankNum].digest,\n\t\t\t   imaEvent->digest, SHA1_DIGEST_SIZE);\n\t\t}\n\t\t/* other hash algorithms get the digest of template data */\n\t\telse {\n\t\t    TPMT_HA *tpmtHa = &pcrExtendIn->digests.digests[bankNum];\n\t\t    rc = TSS_Hash_Generate(tpmtHa,\n\t\t\t\t\t   (int)imaEvent->template_data_len, imaEvent->template_data,\n\t\t\t\t\t   0, NULL);\n\t\t}\n\t    }\n\t    /* if all zero */\n\t    else {\n\t\t/* IMA has a quirk where some measurements store a zero digest in the event log, but\n\t\t   extend ones into PCR 10 */\n\t\tmemset((uint8_t *)&pcrExtendIn->digests.digests[bankNum].digest, 0xff, digestSize);\n\t    }\n\t}\n    }\n    return rc;\n}\n\nstatic TPM_RC extendDigest(TPMT_HA \t\tsimPcrs[][IMPLEMENTATION_PCR],\n\t\t\t   PCR_Extend_In\t*pcrExtendIn)\n{\n    TPM_RC \t\trc = 0;\n    uint32_t \t\tbankNum = 0;\n    /* PCR hash bank interator */\n    TPMI_DH_PCR \tpcrHandle;\n    uint16_t \t\tdigestSize;\n\n    /* index range check */\n    if (rc == 0) {\n\tpcrHandle = pcrExtendIn->pcrHandle;\n\tif (pcrHandle >= IMPLEMENTATION_PCR) {\n\t    printf(\"extendDigest: PCR index %u %08x out of range\\n\", pcrHandle, pcrHandle);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    for (bankNum = 0 ; bankNum < pcrExtendIn->digests.count ; bankNum++) {\n\tdigestSize = TSS_GetDigestSize(pcrExtendIn->digests.digests[bankNum].hashAlg);\n#if 0\n\tTSS_PrintAll(\"extendDigest: extending\",\n\t\t     (uint8_t *)&pcrExtendIn->digests.digests[bankNum].digest,\n\t\t     digestSize);\n#endif\n\tif (rc == 0) {\n\t    rc = TSS_Hash_Generate(&simPcrs[bankNum][pcrHandle],\n\t\t\t\t   digestSize,\n\t\t\t\t   (uint8_t *)&simPcrs[bankNum][pcrHandle].digest,\n\t\t\t\t   digestSize,\n\t\t\t\t   (uint8_t *)&pcrExtendIn->digests.digests[bankNum].digest,\n\t\t\t\t   0, NULL);\n\t}\n\tif (rc == 0 && tssUtilsVerbose) {\n\t    TSS_TPM_ALG_ID_Print(\"Simulated PCR bank\",\n\t\t\t\t pcrExtendIn->digests.digests[bankNum].hashAlg,\n\t\t\t\t 0);\n\t    TSS_PrintAll(\"PCR digest\",\n\t\t\t simPcrs[bankNum][pcrHandle].digest.tssmax,\n\t\t\t digestSize);\n\t}\n    }\n    return rc;\n}\n\n/* for debug, read back and trace the PCR value before and after the extend */\n\nstatic TPM_RC pcrread(TSS_CONTEXT *tssContext,\n\t\t      PCR_Read_In *pcrReadIn,\n\t\t      TPMI_DH_PCR pcrHandle)\n{\n    TPM_RC \t\trc = 0;\n    uint32_t \t\tcount;\n    PCR_Read_Out \tpcrReadOut;\n\n    /* set the selection bitmap based on the pcrHandle */\n    for (count = 0 ; (rc == 0) && (count < pcrReadIn->pcrSelectionIn.count) ; count++) {\n\tpcrReadIn->pcrSelectionIn.pcrSelections[count].sizeofSelect = 3;\n\tpcrReadIn->pcrSelectionIn.pcrSelections[count].pcrSelect[0] = 0;\n\tpcrReadIn->pcrSelectionIn.pcrSelections[count].pcrSelect[1] = 0;\n\tpcrReadIn->pcrSelectionIn.pcrSelections[count].pcrSelect[2] = 0;\n\tpcrReadIn->pcrSelectionIn.pcrSelections[count].pcrSelect[pcrHandle / 8] =\n\t    1 << (pcrHandle % 8);\n    }\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&pcrReadOut,\n\t\t\t (COMMAND_PARAMETERS *)pcrReadIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_PCR_Read,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    /* the banks requested may not all be allocated.  Use pcrReadOut, not pcrReadIn */\n    if (rc == 0) {\n\tif (pcrReadOut.pcrValues.count == 0) {\n\t    printf(\"No PCR banks\\n\");\n\t}\n    }\n    for (count = 0 ; (rc == 0) && (count < pcrReadOut.pcrValues.count) ; count++) {\n\tTSS_TPM_ALG_ID_Print(\"PCR bank\",\n\t\t\t     pcrReadOut.pcrSelectionOut.pcrSelections[count].hash,\n\t\t\t     0);\n\tTSS_PrintAll(\"PCR digest\",\n\t\t     pcrReadOut.pcrValues.digests[count].t.buffer,\n\t\t     pcrReadOut.pcrValues.digests[count].t.size);\n    }\n   return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"imaextend\\n\");\n    printf(\"\\n\");\n    printf(\"Replays the provided IMA event log.\\n\"\n\t   \"\\n\"\n\t   \"Without -sim, uses TPM2_PCR_Extend to extend the events into the TPM.\\n\"\n\t   \"With    -sim, extends into simulated PCRs and traces the result.\\n\"\n\t   \"\\n\"\n\t   \"Without -sim, hash algorithms not allocated are ignored, the TPM behavior.\\n\"\n\t   \"With    -sim, all specified hash algorithms are used.\\n\"\n\t   \"If no hash algorithms are specified, defaults to sha1 and sha256.\\n\"\n\t   \"\\n\"\n\t   \"Two IMA log formats are currently supported:\\n\"\n\t   \"\\n\"\n\t   \"1: SHA1 - A zero padded measurement is extended into other PCR banks.\\n\"\n\t   \"2: SHA1 - A digest of the template data is extended into other PCR banks.\\n\");\n    printf(\"\\n\");\n    printf(\"This handles the case where a zero measurement extends ones into the IMA PCR.\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-if\\tIMA event log file name\\n\");\n    printf(\"\\t[-of\\tWith -sim, PCR 10 of first algorithm specified]\\n\");\n    printf(\"\\t[-le\\tinput file is little endian (default big endian)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512)]\\n\"\n\t   \"\\t\\t-halg may be specified more than once\\n\");\n    printf(\"\\t[-ty\\tIMA log format (default type 1)]\\n\");\n    printf(\"\\t[-tpm\\textend TPM PCRs (default)]\\n\");\n    printf(\"\\t[-sim\\tcalculate simulated PCRs]\\n\");\n    printf(\"\\t[-checkhash\\tverify IMA event log hashes]\\n\");\n    printf(\"\\t[-checkdata\\tverify IMA event log template data, stop on error]\\n\");\n    printf(\"\\t[-b\\tbeginning entry (default 0, beginning of log)]\\n\");\n    printf(\"\\t\\tA beginning entry after the end of the log becomes a noop\\n\");\n    printf(\"\\t[-e\\tending entry (default end of log)]\\n\");\n    printf(\"\\t\\tE.g., -b 0 -e 0 sends one entry\\n\");\n    printf(\"\\t[-l\\ttime - run in a continuous loop, sleep 'time' seconds betwteen loops]\\n\");\n    printf(\"\\t\\tThe intent is that this be run without specifying -b and -e\\n\");\n    printf(\"\\t\\tAfer each pass, the next beginning entry is set to the last entry +1\\n\");\n    printf(\"\\n\");\n    exit(1);\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/imalib.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     IMA Routines\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2016 - 2023.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* imalib is a set of utility functions to handle IMA (Integrity Measurement Architecture) event\n   logs.\n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#ifdef TPM_POSIX\n#include <arpa/inet.h>\n#endif\n\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#ifndef TPM_TSS_NO_OPENSSL\n#include <openssl/x509.h>\n#include <openssl/bio.h>\n#endif\t/* TPM_TSS_NO_OPENSSL */\n\n#include <ibmtss/TPM_Types.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/tsserror.h>\n\n#include \"imalib.h\"\n\n/* IMA template names */\n\n#define IMA_UNSUPPORTED\t\t0\n#define IMA_FORMAT_IMA_NG\t1\n#define IMA_FORMAT_IMA_SIG\t2\n#define IMA_FORMAT_IMA\t\t3\n#define IMA_FORMAT_IMA_MODSIG\t4\n#define IMA_FORMAT_IMA_BUF\t5\n#define IMA_FORMAT_IMA_NGV2\t6\n#define IMA_FORMAT_IMA_SIGV2\t7\n#define IMA_FORMAT_EVM_SIG\t8\n\nstatic uint32_t IMA_Uint16_Unmarshal(uint16_t \t*out,\n\t\t\t\t     uint8_t \t**buffer,\n\t\t\t\t     size_t \t*length,\n\t\t\t\t     int \tlittleEndian);\nstatic uint32_t IMA_Uint32_Unmarshal(uint32_t \t*out,\n\t\t\t\t     uint8_t \t**buffer,\n\t\t\t\t     size_t \t*length,\n\t\t\t\t     int \tlittleEndian);\nstatic uint32_t IMA_Uint32_Convert(const uint8_t *stream,\n\t\t\t\t   int littleEndian);\nstatic uint32_t IMA_Strn2cpy(char *dest, const uint8_t *src,\n\t\t\t     size_t destLength, size_t srcLength);\nstatic uint32_t IMA_Strc2cpy(char *dest, const uint8_t *src,\n\t\t\t     size_t destLength, size_t srcLength);\nstatic void IMA_Event_ParseName(ImaEvent *imaEvent);\n\nstatic uint32_t IMA_TemplateData_ReadFile(ImaEvent *imaEvent,\n\t\t\t\t\t  int *endOfFile,\n\t\t\t\t\t  FILE *inFile,\n\t\t\t\t\t  int littleEndian);\nstatic uint32_t IMA_TemplateDataIma_ReadFile(ImaEvent *imaEvent,\n\t\t\t\t\t     int *endOfFile,\n\t\t\t\t\t     FILE *inFile,\n\t\t\t\t\t     int littleEndian);\n\n/* callback to parse a template data field */\n\ntypedef uint32_t (*TemplateDataParseFunction_t)(ImaTemplateData\t*imaTemplateData,\n\t\t\t\t\t\tuint8_t \t**buffer,\n\t\t\t\t\t\tsize_t \t\t*length,\n\t\t\t\t\t\tint \t\tlittleEndian);\nstatic uint32_t IMA_TemplateName_Parse(TemplateDataParseFunction_t templateDataParseFunctions[],\n\t\t\t\t       TemplateDataTraceFunction_t templateDataTraceFunctions[],\n\t\t\t\t       size_t templateDataParseFunctionsSize,\n\t\t\t\t       ImaEvent *imaEvent);\nstatic uint32_t\nIMA_TemplateName_ParseCustom(TemplateDataParseFunction_t templateDataParseFunctions[],\n\t\t\t     TemplateDataTraceFunction_t templateDataTraceFunctions[],\n\t\t\t     size_t templateDataParseFunctionsSize,\n\t\t\t     ImaEvent *imaEvent);\nstatic uint32_t IMA_ParseD(ImaTemplateData\t*imaTemplateData,\n\t\t\t   uint8_t \t\t**buffer,\n\t\t\t   size_t \t\t*length,\n\t\t\t   int \t\t\tlittleEndian);\nstatic uint32_t IMA_ParseDNG(ImaTemplateData\t*imaTemplateData,\n\t\t\t     uint8_t \t\t**buffer,\n\t\t\t     size_t \t\t*length,\n\t\t\t     int \t\tlittleEndian);\nstatic uint32_t IMA_ParseDNGV2(ImaTemplateData\t*imaTemplateData,\n\t\t\t       uint8_t \t\t**buffer,\n\t\t\t       size_t \t\t*length,\n\t\t\t       int \t\tlittleEndian);\nstatic uint32_t IMA_ParseNNG(ImaTemplateData\t*imaTemplateData,\n\t\t\t     uint8_t \t\t**buffer,\n\t\t\t     size_t \t\t*length,\n\t\t\t     int \t\tlittleEndian);\nstatic uint32_t IMA_ParseSIG(ImaTemplateData\t*imaTemplateData,\n\t\t\t     uint8_t \t\t**buffer,\n\t\t\t     size_t \t\t*length,\n\t\t\t     int \t\tlittleEndian);\nstatic uint32_t IMA_ParseDMODSIG(ImaTemplateData\t*imaTemplateData,\n\t\t\t\t uint8_t \t\t**buffer,\n\t\t\t\t size_t \t\t*length,\n\t\t\t\t int \t\t\tlittleEndian);\nstatic uint32_t IMA_ParseMODSIG(ImaTemplateData\t*imaTemplateData,\n\t\t\t\tuint8_t \t**buffer,\n\t\t\t\tsize_t \t\t*length,\n\t\t\t\tint \t\tlittleEndian);\nstatic uint32_t IMA_ParseBUF(ImaTemplateData\t*imaTemplateData,\n\t\t\t     uint8_t \t\t**buffer,\n\t\t\t     size_t \t\t*length,\n\t\t\t     int \t\tlittleEndian);\nstatic uint32_t IMA_ParseXATTRNAMES(ImaTemplateData\t*imaTemplateData,\n\t\t\t\t    uint8_t \t\t**buffer,\n\t\t\t\t    size_t \t\t*length,\n\t\t\t\t    int \t\tlittleEndian);\nstatic uint32_t IMA_ParseXATTRLENGTHS(ImaTemplateData\t*imaTemplateData,\n\t\t\t\t      uint8_t \t\t**buffer,\n\t\t\t\t      size_t \t\t*length,\n\t\t\t\t      int \t\tlittleEndian);\nstatic uint32_t IMA_ParseXATTRVALUES(ImaTemplateData\t*imaTemplateData,\n\t\t\t\t     uint8_t \t\t**buffer,\n\t\t\t\t     size_t \t\t*length,\n\t\t\t\t     int \t\tlittleEndian);\nstatic uint32_t IMA_ParseIUID(ImaTemplateData\t*imaTemplateData,\n\t\t\t      uint8_t \t\t**buffer,\n\t\t\t      size_t \t\t*length,\n\t\t\t      int \t\tlittleEndian);\nstatic uint32_t IMA_ParseIGID(ImaTemplateData\t*imaTemplateData,\n\t\t\t      uint8_t \t\t**buffer,\n\t\t\t      size_t \t\t*length,\n\t\t\t      int \t\tlittleEndian);\nstatic uint32_t IMA_ParseIMODE(ImaTemplateData\t*imaTemplateData,\n\t\t\t       uint8_t \t\t**buffer,\n\t\t\t       size_t \t\t*length,\n\t\t\t       int \t\tlittleEndian);\n\nextern int tssUtilsVerbose;\n\n/* IMA_Event_Init() initializes the ImaEvent structure so that IMA_Event_Free() is safe.\n\n */\n\nvoid IMA_Event_Init(ImaEvent *imaEvent)\n{\n    if (imaEvent != NULL) {\n\timaEvent->nameInt = IMA_UNSUPPORTED;\n\timaEvent->template_data = NULL;\n    }\n    return;\n}\n\n/* IMA_Event_Free() frees any memory allocated for the ImaEvent structure.\n\n */\n\nvoid IMA_Event_Free(ImaEvent *imaEvent)\n{\n    if (imaEvent != NULL) {\n\tfree(imaEvent->template_data);\n\timaEvent->template_data = NULL;\n    }\n    return;\n}\n\n/* IMA_Event_Trace() traces the ImaEvent structure.\n\n   If traceTemplate is FALSE, template data is not traced.  This handles the case where template\n   data is not unmarshaled.\n\n*/\n\nvoid IMA_Event_Trace(ImaEvent *imaEvent, int traceTemplate)\n{\n    printf(\"IMA_Event_Trace: PCR index %u\\n\", imaEvent->pcrIndex);\n    TSS_PrintAll(\"IMA_Event_Trace: hash\",\n\t\t imaEvent->digest, sizeof(((ImaEvent *)NULL)->digest));\n\n    printf(\"IMA_Event_Trace: name length %u\\n\", imaEvent->name_len);\n    printf(\"IMA_Event_Trace: name text %s\\n\", imaEvent->name);\n#if 1\n    printf(\"IMA_Event_Trace: name integer %u\\n\", imaEvent->nameInt);\n    TSS_PrintAll(\"IMA_Event_Trace: template data\",\n\t\t imaEvent->template_data, imaEvent->template_data_len);\n#endif\n    printf(\"IMA_Event_Trace: template data length %u\\n\", imaEvent->template_data_len);\n    /* in some use cases, the template_data field is not populated.  In those cases, do not trace\n       it. */\n    if (traceTemplate) {\n\tTSS_PrintAll(\"IMA_Event_Trace: template data\",\n\t\t     imaEvent->template_data, imaEvent->template_data_len);\n    }\n    return;\n}\n\n/* IMA_Event_ParseName() parses the Template Name and sets the nameInt field */\n\nstatic void IMA_Event_ParseName(ImaEvent *imaEvent)\n{\n    if (strcmp(imaEvent->name, \"ima-ng\") == 0) {\n\timaEvent->nameInt = IMA_FORMAT_IMA_NG;\n    }\n    else if (strcmp(imaEvent->name, \"ima-sig\") == 0) {\n\timaEvent->nameInt = IMA_FORMAT_IMA_SIG;\n    }\n    else if (strcmp(imaEvent->name, \"ima\") == 0) {\n\timaEvent->nameInt = IMA_FORMAT_IMA;\n    }\n    else if (strcmp(imaEvent->name, \"ima-modsig\") == 0) {\n\timaEvent->nameInt = IMA_FORMAT_IMA_MODSIG;\n    }\n    else if (strcmp(imaEvent->name, \"ima-buf\") == 0) {\n\timaEvent->nameInt = IMA_FORMAT_IMA_BUF;\n    }\n    else if (strcmp(imaEvent->name, \"ima-ngv2\") == 0) {\n\timaEvent->nameInt = IMA_FORMAT_IMA_NGV2;\n    }\n    else if (strcmp(imaEvent->name, \"ima-sigv2\") == 0) {\n\timaEvent->nameInt = IMA_FORMAT_IMA_SIGV2;\n    }\n    else if (strcmp(imaEvent->name, \"evm-sig\") == 0) {\n\timaEvent->nameInt = IMA_FORMAT_EVM_SIG;\n    }\n    /* the template data parser currently supports only these formats. */\n    else {\n\timaEvent->nameInt = IMA_UNSUPPORTED;\n    }\n    return;\n}\n\nvoid IMA_TemplateData_Init(ImaTemplateData *imaTemplateData)\n{\n    size_t i;\n    imaTemplateData->imaTemplateDNG.hashLength = 0;\n    imaTemplateData->imaTemplateDNG.hashAlgId = TPM_ALG_NULL;\n    imaTemplateData->imaTemplateDNG.fileDataHashLength = 0;\n    imaTemplateData->imaTemplateNNG.fileNameLength = 0;\n    imaTemplateData->imaTemplateNNG.fileName[0] = '\\0';\n    imaTemplateData->imaTemplateSIG.sigLength = 0;\n    imaTemplateData->imaTemplateSIG.sigHeaderLength = 0;\n    imaTemplateData->imaTemplateSIG.signatureSize = 0;\n    imaTemplateData->imaTemplateDMODSIG.dModSigHashLength = 0;\n    imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength = 0;\n    imaTemplateData->imaTemplateMODSIG.modSigLength = 0;\n    imaTemplateData->imaTemplateBUF.bufLength = 0;\n    imaTemplateData->imaTemplateXattrs.xattrNamesLength = 0;\n    imaTemplateData->imaTemplateXattrs.xattrNames[0] = '\\0';\n    imaTemplateData->imaTemplateXattrs.xattrNamesLength = 0;\n    for (i = 0 ;\n\t i < ((sizeof(((ImaTemplateXattrs *)NULL)->xattrNamesPtr)) / (sizeof(char *))) ;\n\t i++) {\n\timaTemplateData->imaTemplateXattrs.xattrNamesPtr[i] = NULL;\n    }\n    imaTemplateData->imaTemplateXattrs.xattrNamesCount = 0;\n    imaTemplateData->imaTemplateXattrs.xattrLengthsSum = 0;\n    imaTemplateData->imaTemplateXattrs.xattrValuesLength = 0;\n    imaTemplateData->imaTemplateIUID.iuidLength = 0;\n    imaTemplateData->imaTemplateIGID.igidLength = 0;\n    imaTemplateData->imaTemplateIMODE.imodeLength = 0;\n    return;\n}\n\n/* IMA_TemplateData_Trace() traces the ImaTemplateData  structure.\n\n   nameInt maps to the template name.\n\n*/\n\nvoid IMA_TemplateData_Trace(ImaTemplateData *imaTemplateData,\n\t\t\t    unsigned int nameInt)\n{\n    size_t\ti;\n\n    nameInt = nameInt;\t/* obsolete now that custom templates are supported */\n    for (i = 0 ; imaTemplateData->templateDataTraceFunctions[i] != NULL ; i++) {\n\timaTemplateData->templateDataTraceFunctions[i](imaTemplateData);\n    }\n    return;\n}\n\n/* Below are the callbacks to trace fields in ImaTemplateData */\n\nstatic void IMA_TraceD(ImaTemplateData\t*imaTemplateData)\n{\n    TSS_PrintAll(\"IMA_Template_Trace: D file data hash\",\n\t\t imaTemplateData->imaTemplateDNG.fileDataHash,\n\t\t imaTemplateData->imaTemplateDNG.fileDataHashLength);\n    return;\n}\nstatic void IMA_TraceDNG(ImaTemplateData\t*imaTemplateData)\n{\n    printf(\"IMA_TemplateData_Trace: DNG hashLength %u\\n\",\n\t   imaTemplateData->imaTemplateDNG.hashLength); \n    printf(\"IMA_TemplateData_Trace: DNG hashAlg %s\\n\", imaTemplateData->imaTemplateDNG.hashAlg);\n    TSS_PrintAll(\"IMA_Template_Trace: DNG file data hash\",\n\t\t imaTemplateData->imaTemplateDNG.fileDataHash,\n\t\t imaTemplateData->imaTemplateDNG.fileDataHashLength);\n    return;\n}\nstatic void IMA_TraceDNGV2(ImaTemplateData\t*imaTemplateData)\n{\n    printf(\"IMA_TemplateData_Trace: DNGV2 hashLength %u\\n\",\n\t   imaTemplateData->imaTemplateDNGV2.hashLength); \n    printf(\"IMA_TemplateData_Trace: DNGV2 prefix %s\\n\", imaTemplateData->imaTemplateDNGV2.prefix);\n    printf(\"IMA_TemplateData_Trace: DNGV2 hashAlg %s\\n\", imaTemplateData->imaTemplateDNGV2.hashAlg);\n    TSS_PrintAll(\"IMA_Template_Trace: DNGV2 file data hash\",\n\t\t imaTemplateData->imaTemplateDNGV2.fileDataHash,\n\t\t imaTemplateData->imaTemplateDNGV2.fileDataHashLength);\n    return;\n}\nstatic void IMA_TraceNNG(ImaTemplateData\t*imaTemplateData)\n{\n    printf(\"IMA_TemplateData_Trace: NNG fileNameLength %u\\n\",\n\t   imaTemplateData->imaTemplateNNG.fileNameLength);\n    if (imaTemplateData->imaTemplateNNG.fileNameLength > 0) {\n\tprintf(\"IMA_TemplateData_Trace: NNG fileName %s\\n\",\n\t       imaTemplateData->imaTemplateNNG.fileName);\n    }\n    return;\n}\nstatic void IMA_TraceSIG(ImaTemplateData\t*imaTemplateData)\n{\n    printf(\"IMA_TemplateData_Trace: SIG sigLength %u\\n\", imaTemplateData->imaTemplateSIG.sigLength);\n    if (imaTemplateData->imaTemplateSIG.sigLength != 0) {\n\tTSS_PrintAll(\"IMA_TemplateData_Trace: sigHeader\",\n\t\t     imaTemplateData->imaTemplateSIG.sigHeader,\n\t\t     imaTemplateData->imaTemplateSIG.sigHeaderLength);\n\tprintf(\"IMA_TemplateData_Trace: SIG signatureSize %u\\n\",\n\t       imaTemplateData->imaTemplateSIG.signatureSize);\n\tTSS_PrintAll(\"IMA_TemplateData_Trace: SIG signature\",\n\t\t     imaTemplateData->imaTemplateSIG.signature,\n\t\t     imaTemplateData->imaTemplateSIG.signatureSize);\n    }\n    return;\n}\nstatic void IMA_TraceDMODSIG(ImaTemplateData\t*imaTemplateData)\n{\n    printf(\"IMA_TemplateData_Trace: DMODSIG dModSigHashLength %u\\n\",\n\t   imaTemplateData->imaTemplateDMODSIG.dModSigHashLength);\n    if (imaTemplateData->imaTemplateDMODSIG.dModSigHashLength != 0) {\n\tprintf(\"IMA_TemplateData_Trace: DMODSIG dModSigHashAlg %s\\n\",\n\t       imaTemplateData->imaTemplateDMODSIG.dModSigHashAlg);\n\tTSS_PrintAll(\"IMA_Template_Trace: DMODSIG file data hash\",\n\t\t     imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHash,\n\t\t     imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength);\n    }\n    return;\n}\nstatic void IMA_TraceMODSIG(ImaTemplateData\t*imaTemplateData)\n{\n    printf(\"IMA_TemplateData_Trace: MODSIG modSigLength %u\\n\",\n\t   imaTemplateData->imaTemplateMODSIG.modSigLength);\n    if (imaTemplateData->imaTemplateMODSIG.modSigLength != 0) {\n\tTSS_PrintAll(\"IMA_TemplateData_Trace: MODSIG modSigData\",\n\t\t     imaTemplateData->imaTemplateMODSIG.modSigData,\n\t\t     imaTemplateData->imaTemplateMODSIG.modSigLength);\n#ifndef TPM_TSS_MBEDTLS\n\t{\n\t    PKCS7 \t\t*pkcs7 = NULL;\n\t    unsigned char \t*tmpData = NULL; \n\t    /* tmp pointer because d2i moves the pointer */\n\t    tmpData = imaTemplateData->imaTemplateMODSIG.modSigData;\n\t    pkcs7 = d2i_PKCS7(NULL,\t\t\t\t/* freed @1 */\n\t\t\t      (const unsigned char **)&tmpData,\n\t\t\t      imaTemplateData->imaTemplateMODSIG.modSigLength);\n\t    if (pkcs7 != NULL) {\n\t\tBIO *bio = NULL;\n#ifdef TPM_POSIX\n\t\tbio = BIO_new_fd(fileno(stdout), BIO_NOCLOSE);\t/* freed @2 */\n#endif\n#ifdef TPM_WINDOWS\n\t\tbio = BIO_new_fd(_fileno(stdout), BIO_NOCLOSE);\t/* freed @2 */\n#endif\n\t\tif (bio != NULL) {\n\t\t    PKCS7_print_ctx(bio, pkcs7, 4, NULL);\n\t\t    BIO_free(bio);\t/* @2 */\n\t\t}\n\t\telse {\n\t\t    printf(\"IMA_TemplateData_Trace: MODSIG Could not create BIO for PKCS7\\n\");\n\t\t}\n\t\tPKCS7_free(pkcs7);\t/* @1 */\n\t    }\n\t    else {\n\t\tprintf(\"IMA_TemplateData_Trace: MODSIG Could not trace modSigData as PKCS7\\n\");\n\t    }\n\t}\n#endif /* TPM_TSS_MBEDTLS */\n    }\n    return;\n}\nstatic void IMA_TraceBUF(ImaTemplateData\t*imaTemplateData)\n{\n    printf(\"IMA_TemplateData_Trace: BUF bufLength %u\\n\", imaTemplateData->imaTemplateBUF.bufLength);\n    if (imaTemplateData->imaTemplateBUF.bufLength != 0) {\n\tTSS_PrintAll(\"IMA_TemplateData_Trace: BUF bufData\",\n\t\t     imaTemplateData->imaTemplateBUF.bufData,\n\t\t     imaTemplateData->imaTemplateBUF.bufLength);\n#ifndef TPM_TSS_MBEDTLS\n\t/* keys are X.509 certificates */\n\tif ((strcmp((const char *)imaTemplateData->imaTemplateNNG.fileName,\n\t\t    \".builtin_trusted_keys\") == 0) ||\n\t    (strcmp((const char *)imaTemplateData->imaTemplateNNG.fileName,\n\t\t    \".platform\") == 0) ||\n\t    (strcmp((const char *)imaTemplateData->imaTemplateNNG.fileName,\n\t\t    \".machine\") == 0) ||\n\t    (strcmp((const char *)imaTemplateData->imaTemplateNNG.fileName,\n\t\t    \".evm\") == 0) ||\n\t    (strcmp((const char *)imaTemplateData->imaTemplateNNG.fileName,\n\t\t    \".ima\") == 0)) {\n\t    {\n\t\tX509 \t\t*x509 = NULL;\n\t\tunsigned char \t*tmpData = NULL;\n\t\t/* tmp pointer because d2i moves the pointer */\n\t\ttmpData = imaTemplateData->imaTemplateBUF.bufData;\n\t\tx509 = d2i_X509(NULL,\t\t\t\t/* freed @1 */\n\t\t\t\t(const unsigned char **)&tmpData,\n\t\t\t\timaTemplateData->imaTemplateBUF.bufLength);\n\t\tif (x509 != NULL) {\n\t\t    if (x509 != NULL) {\n\t\t\tX509_print_fp(stdout, x509);\n\t\t\tX509_free(x509);\t/* @1 */\n\t\t    }\n\t\t    else {\n\t\t\tprintf(\"IMA_TemplateData_Trace: BUF Could not trace bufData as X509\\n\");\n\t\t    }\n\t\t}\n\t    }\n\t}\n\t/* selinux state and kernel command line are printable, not nul terminated */\n\telse if ((strcmp((const char *)imaTemplateData->imaTemplateNNG.fileName,\n\t\t\t \"selinux-state\") == 0) ||\n\t\t (strcmp((const char *)imaTemplateData->imaTemplateNNG.fileName,\n\t\t\t \"kexec-cmdline\") == 0)) {\n\t    printf(\"    %.*s\\n\",\n\t\t   imaTemplateData->imaTemplateBUF.bufLength,\n\t\t   imaTemplateData->imaTemplateBUF.bufData);\n\t}\n#endif /* TPM_TSS_MBEDTLS */\n    }\n    return;\n}\n\nstatic void IMA_TraceXATTRNAMES(ImaTemplateData\t*imaTemplateData)\n{\n    size_t i;\n    for (i = 0 ; i < imaTemplateData->imaTemplateXattrs.xattrNamesCount ; i++) {\n\tprintf(\"IMA_TemplateData_Trace: xattrnames %s\\n\",\n\t       imaTemplateData->imaTemplateXattrs.xattrNamesPtr[i]);\n    }\n    return;\n}\n\nstatic void IMA_TraceXATTRLENGTHS(ImaTemplateData\t*imaTemplateData)\n{\n    size_t\ti;\n\n    for (i = 0 ; i < imaTemplateData->imaTemplateXattrs.xattrLengthsLength / 4 ; i++) {\n\tprintf(\"IMA_TemplateData_Trace: xattrlengths index %u length %08x %u\\n\",\n\t       (unsigned int)i,\n\t       imaTemplateData->imaTemplateXattrs.xattrLengths[i],\n\t       imaTemplateData->imaTemplateXattrs.xattrLengths[i]);\n    }\n    return;\n}\n\nstatic void IMA_TraceXATTRVALUES(ImaTemplateData\t*imaTemplateData)\n{\n    size_t i;\n    size_t index = 0;\t/* index into xattrValues buffer */\n\n#if 0\n    TSS_PrintAll(\"IMA_TemplateData_Trace: xattrvalues\",\n\t\t imaTemplateData->imaTemplateXattrs.xattrValues,\n\t\t imaTemplateData->imaTemplateXattrs.xattrValuesLength);\n#endif\n    for (i = 0 ; i < imaTemplateData->imaTemplateXattrs.xattrNamesCount ; i++) {\n\n\tif (strcmp(imaTemplateData->imaTemplateXattrs.xattrNamesPtr[i], \"security.selinux\") == 0) {\n\t    /* ensure that the selinux string is nul terminated */\n\t    if (imaTemplateData->imaTemplateXattrs.xattrValues\n\t\t[index + imaTemplateData->imaTemplateXattrs.xattrLengths[i] -1] == '\\0') {\n\t\tprintf(\"IMA_TemplateData_Trace: xattrvalue %lu %s\\n\",\n\t\t       (unsigned long)i,\n\t\t       (char *)&imaTemplateData->imaTemplateXattrs.xattrValues[index]);\n\t    }\n\t    else {\n\t\tprintf(\"IMA_TemplateData_Trace: \"\n\t\t       \"security.selinux value not nul terminated at index %lu\\n\",\n\t\t       (unsigned long)\n\t\t       (index + imaTemplateData->imaTemplateXattrs.xattrLengths[i] -1));\n\t    }\n\t}\n\telse if (strcmp(imaTemplateData->imaTemplateXattrs.xattrNamesPtr[i], \"security.ima\") == 0) {\n\t    if (imaTemplateData->imaTemplateXattrs.xattrLengths[i] < 2) {\n\t\tprintf(\"IMA_TemplateData_Trace: xattrvalue security.ima length insufficient\\n\");\n\t    }\n\t    else {\n\t\tprintf(\"IMA_TemplateData_Trace: xattrvalue security.ima %02x %02x\\n\",\n\t\t       imaTemplateData->imaTemplateXattrs.xattrValues[index],\n\t\t       imaTemplateData->imaTemplateXattrs.xattrValues[index+1]);\n\t\tTSS_PrintAll(\"IMA_TemplateData_Trace: xattrvalue security.ima digest\",\n\t\t\t     &imaTemplateData->imaTemplateXattrs.xattrValues[index+2],\n\t\t\t     imaTemplateData->imaTemplateXattrs.xattrLengths[i] -2);\n\t    }\n\t}\n\telse {\n\t    printf(\"IMA_TemplateData_Trace: Trace of xattrname %s not supported\\n\",\n\t\t   imaTemplateData->imaTemplateXattrs.xattrNamesPtr[i]);\n\t}\n\n\t/* move the index past the length for the next pass */\n\tindex += imaTemplateData->imaTemplateXattrs.xattrLengths[i];\n    }\n    return;\n}\n\nstatic void IMA_TraceIUID(ImaTemplateData\t*imaTemplateData)\n{\n    if (imaTemplateData->imaTemplateIUID.iuidLength == 2) {\n\tprintf(\"IMA_TemplateData_Trace: iuid %u\\n\", imaTemplateData->imaTemplateIUID.iuid16);\n    }\n    else if (imaTemplateData->imaTemplateIUID.iuidLength == 4) {\n\tprintf(\"IMA_TemplateData_Trace: iuid %u\\n\", imaTemplateData->imaTemplateIUID.iuid32);\n    }\n    else {\n\tprintf(\"IMA_TemplateData_Trace: iuid length 0\\n\");\n    }\n    return;\n}\n\nstatic void IMA_TraceIGID(ImaTemplateData\t*imaTemplateData)\n{\n    if (imaTemplateData->imaTemplateIGID.igidLength == 2) {\n\tprintf(\"IMA_TemplateData_Trace: igid %u\\n\", imaTemplateData->imaTemplateIGID.igid16);\n    }\n    else if (imaTemplateData->imaTemplateIGID.igidLength == 4) {\n\tprintf(\"IMA_TemplateData_Trace: igid %u\\n\", imaTemplateData->imaTemplateIGID.igid32);\n    }\n    else {\n\tprintf(\"IMA_TemplateData_Trace: igid length 0\\n\");\n    }\n    return;\n}\n\nstatic void IMA_TraceIMODE(ImaTemplateData\t*imaTemplateData)\n{\n    if (imaTemplateData->imaTemplateIMODE.imodeLength != 0) {\n\tprintf(\"IMA_TemplateData_Trace: imode %04o\\n\", imaTemplateData->imaTemplateIMODE.imode);\n    }\n    else {\n\tprintf(\"IMA_TemplateData_Trace: igid length 0\\n\");\n    }\n    return;\n}\n\n/* IMA_Event_ReadFile() reads one IMA event from a file.\n\n   It currently supports these template formats:  ima, ima-ng, ima-sig.\n\n   This is typically used at the client, reading from the pseudofile.\n*/\n\nuint32_t IMA_Event_ReadFile(ImaEvent *imaEvent,\t/* freed by caller */\n\t\t\t    int *endOfFile,\n\t\t\t    FILE *inFile,\n\t\t\t    int littleEndian)\n{\n    int rc = 0;\n    size_t readSize;\n    *endOfFile = FALSE;\n    \n    imaEvent->template_data = NULL;\t\t/* for free */\n\n    /* read the IMA PCR index */\n    if ((rc == 0) && !(*endOfFile)) {\n\treadSize = fread(&(imaEvent->pcrIndex),\n\t\t\t sizeof(((ImaEvent *)NULL)->pcrIndex), 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_Event_ReadFile: could not read pcrIndex, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    /* PCR index endian convert */\n    if ((rc == 0) && !(*endOfFile)) {\n\timaEvent->pcrIndex = IMA_Uint32_Convert((uint8_t *)&imaEvent->pcrIndex, littleEndian);\n\t/* range check the PCR index */\n\tif (imaEvent->pcrIndex >= IMPLEMENTATION_PCR) {\n\t    printf(\"ERROR: IMA_Event_ReadFile: PCR index %u %08x out of range\\n\",\n\t\t   imaEvent->pcrIndex, imaEvent->pcrIndex);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\t\n    /* read the IMA digest, this is hard coded to SHA-1 */\n    if ((rc == 0) && !(*endOfFile)) {\n\treadSize = fread(&(imaEvent->digest),\n\t\t\t sizeof(((ImaEvent *)NULL)->digest), 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_Event_ReadFile: could not read digest, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    /* read the IMA name length */\n    if ((rc == 0) && !(*endOfFile)) {\n\treadSize = fread(&(imaEvent->name_len),\n\t\t\t sizeof(((ImaEvent *)NULL)->name_len), 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_Event_ReadFile: could not read name_len, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    if ((rc == 0) && !(*endOfFile)) {\n\timaEvent->name_len = IMA_Uint32_Convert((uint8_t *)&imaEvent->name_len, littleEndian);\n    }\n    /* bounds check the name length, leave a byte for the nul terminator */\n    if ((rc == 0) && !(*endOfFile)) {\n\tif (imaEvent->name_len > (sizeof(((ImaEvent *)NULL)->name)) -1) {\n\t    printf(\"ERROR: IMA_Event_ReadFile: template name length too big: %u\\n\",\n\t\t   imaEvent->name_len);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* read the template name */\n    if ((rc == 0) && !(*endOfFile)) {\n\t/* nul terminate first */\n\tmemset(imaEvent->name, 0, sizeof(((ImaEvent *)NULL)->name));\n\t/* ignore VS warning, name_len is range checked above, no buffer overrun */\n\treadSize = fread(&(imaEvent->name),\n\t\t\t imaEvent->name_len, 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_Event_ReadFile: could not read template name, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    /* record the template name as an int */\n    if ((rc == 0) && !(*endOfFile)) {\n\tIMA_Event_ParseName(imaEvent);\n    }\n    if ((rc == 0) && !(*endOfFile)) {\n\tif (imaEvent->nameInt != IMA_FORMAT_IMA) {\t/* standard format */\n\t    rc = IMA_TemplateData_ReadFile(imaEvent, endOfFile, inFile, littleEndian);\n\t}\n\telse {\t\t\t\t\t\t/* unique 'ima' format */\n\t    rc = IMA_TemplateDataIma_ReadFile(imaEvent, endOfFile, inFile, littleEndian);\n\t}\n    }\n    return rc;\n}\n\n/* IMA_TemplateData_ReadFile() reads the template data as a pure array.  It handles the normal case\n   of template data length plus template data.\n*/\n\nstatic uint32_t IMA_TemplateData_ReadFile(ImaEvent *imaEvent,\t/* freed by caller */\n\t\t\t\t\t  int *endOfFile,\n\t\t\t\t\t  FILE *inFile,\n\t\t\t\t\t  int littleEndian)\n{\n    int rc = 0;\n    size_t readSize;\n\n    /* read template data length */\n    if ((rc == 0) && !(*endOfFile)) {\n\treadSize = fread(&(imaEvent->template_data_len),\n\t\t\t sizeof(((ImaEvent *)NULL)->template_data_len ), 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_TemplateData_ReadFile: could not read template_data_len, \"\n\t\t       \" returned %lu\\n\", (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    if ((rc == 0) && !(*endOfFile)) {\n\timaEvent->template_data_len =\n\t    IMA_Uint32_Convert((uint8_t *)&imaEvent->template_data_len,\n\t\t\t       littleEndian);\n    }\n    /* bounds check the template data length */\n    if ((rc == 0) && !(*endOfFile)) {\n\tif (imaEvent->template_data_len > TCG_TEMPLATE_DATA_LEN_MAX) {\n\t    printf(\"ERROR: IMA_TemplateData_ReadFile: template data length too big: %u\\n\",\n\t\t   imaEvent->template_data_len);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if ((rc == 0) && !(*endOfFile)) {\n\timaEvent->template_data = malloc(imaEvent->template_data_len);\n\tif (imaEvent->template_data == NULL) {\n\t    printf(\"ERROR: IMA_TemplateData_ReadFile: \"\n\t\t   \"could not allocate template data, size %u\\n\",\n\t\t   imaEvent->template_data_len);\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if ((rc == 0) && !(*endOfFile)) {\n\t/* ignore VS warning, template_data_len is used for the malloc, no buffer overrun */\n\treadSize = fread(imaEvent->template_data,\n\t\t\t imaEvent->template_data_len, 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_Event_ReadFile: could not read template_data, \"\n\t\t       \"returned %lu\\n\", (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* IMA_TemplateDataIma_ReadFile() reads the template data.  It handles the special case of the\n   template name 'ima', which does not have a template data length.  'ima' has a 20 byte file data\n   hash, a 4 byte file name length, and a file name.\n*/\n\nstatic uint32_t IMA_TemplateDataIma_ReadFile(ImaEvent *imaEvent,\t/* freed by caller */\n\t\t\t\t\t     int *endOfFile,\n\t\t\t\t\t     FILE *inFile,\n\t\t\t\t\t     int littleEndian)\n{\n    int \trc = 0;\n    size_t \treadSize;\n    uint8_t \tfileDataHash[SHA1_DIGEST_SIZE];\t\t/* IMA hard coded to SHA-1 */\n    uint32_t \tfileNameLengthIbo;\t\t\t/* ima log byte order */\n    uint32_t \tfileNameLength;\t\t\t\t/* host byte order */\n\n    /* read the fileDataHash digest, this is hard coded to SHA-1 */\n    if ((rc == 0) && !(*endOfFile)) {\n\treadSize = fread(&fileDataHash,\n\t\t\t sizeof(fileDataHash), 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_TemplateDataIma_ReadFile: \"\n\t\t       \"could not read fileDataHash, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    /* read the IMA name length */\n    if ((rc == 0) && !(*endOfFile)) {\n\treadSize = fread(&fileNameLengthIbo,\n\t\t\t sizeof(fileNameLength), 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_TemplateDataIma_ReadFile: \"\n\t\t       \"could not read fileNameLength, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    if ((rc == 0) && !(*endOfFile)) {\n\tfileNameLength = IMA_Uint32_Convert((uint8_t *)&fileNameLengthIbo, littleEndian);\n\t/* should check for addition overflowing a uint32_t */\n\tif (fileNameLength > (0xffffffff - (uint32_t)(sizeof(fileDataHash) + sizeof(fileNameLength)))) {\n\t    printf(\"ERROR: IMA_TemplateDataIma_ReadFile: file name length too big: %u\\n\",\n\t\t   fileNameLength);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if ((rc == 0) && !(*endOfFile)) {\n\t/* addition is safe because of above check */\n\timaEvent->template_data_len = sizeof(fileDataHash) + sizeof(fileNameLength) + fileNameLength;\n    }\n    /* bounds check the template data length */\n    if ((rc == 0) && !(*endOfFile)) {\n\tif (imaEvent->template_data_len > TCG_TEMPLATE_DATA_LEN_MAX) {\n\t    printf(\"ERROR: IMA_TemplateDataIma_ReadFile: template data length too big: %u\\n\",\n\t\t   imaEvent->template_data_len);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if ((rc == 0) && !(*endOfFile)) {\n\timaEvent->template_data = malloc(imaEvent->template_data_len);\n\tif (imaEvent->template_data == NULL) {\n\t    printf(\"ERROR: IMA_TemplateDataIma_ReadFile: \"\n\t\t   \"could not allocate template data, size %u\\n\",\n\t\t   imaEvent->template_data_len);\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* copy results to template_data */\n    if ((rc == 0) && !(*endOfFile)) {\n\t/* copy file data hash */\n\t/* ignore VS warning, template_data_len is calculated above for malloc, no buffer overrun */\n\tmemcpy(imaEvent->template_data, fileDataHash, sizeof(fileDataHash));\n\t/* copy file name length */\n\tmemcpy(imaEvent->template_data + sizeof(fileDataHash),\n\t       &fileNameLengthIbo, sizeof(fileNameLength));\n\t/* read and copy the file name */\n\treadSize = fread(imaEvent->template_data + sizeof(fileDataHash) + sizeof(fileNameLength),\n\t\t\t fileNameLength, 1, inFile);\n\tif (readSize != 1) {\n\t    if (feof(inFile)) {\n\t\t*endOfFile = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_TemplateDataIma_ReadFile: \"\n\t\t       \"could not read fileNameLength, returned %lu\\n\",\n\t\t       (unsigned long)readSize);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n    }\n    return rc;\n}\n \n/* IMA_Event_ReadBuffer()  reads one IMA event from a buffer.\n\n   This is typically used at the server, reading from a client connection.\n\n   Although the raw IMA event log 'ima' template does not have a template data length, this function\n   at the server assumes it has been inserted by the client.\n\n   If getTemplate is TRUE, the template data is copied to a malloced imaEvent->template_data.  If\n   FALSE, template data is skipped. FALSE is used for the first pass, where the template data is not\n   needed until the hash is validated.\n\n*/\n\nuint32_t IMA_Event_ReadBuffer(ImaEvent *imaEvent,\t/* freed by caller */\n\t\t\t      size_t *length,\n\t\t\t      uint8_t **buffer,\n\t\t\t      int *endOfBuffer,\n\t\t\t      int littleEndian,\n\t\t\t      int getTemplate)\n{\n    int rc = 0;\n\n    imaEvent->template_data = NULL;\t\t/* for free */\n    if (*length == 0) {\n\t*endOfBuffer = 1;\n    }\n    else {\n\t/* read the IMA pcr index */\n\tif (rc == 0) {\n\t    rc = IMA_Uint32_Unmarshal(&imaEvent->pcrIndex, buffer, length, littleEndian);\n\t}\n\t/* sanity check the PCR index */\n\tif (rc == 0) {\n\t    if (imaEvent->pcrIndex != IMA_PCR) {\n\t\tprintf(\"ERROR: IMA_Event_ReadBuffer: PCR index %u not PCR %u\\n\",\n\t\t       IMA_PCR, imaEvent->pcrIndex);\n\t\trc = TSS_RC_BAD_PROPERTY_VALUE;\n\t    }\n\t}\n\t/* read the IMA digest, this is hard coded to SHA-1 */\n\tif (rc == 0) {\n\t    /* bounds check the length */\n\t    if (*length < sizeof(((ImaEvent *)NULL)->digest)) {\n\t\tprintf(\"ERROR: IMA_Event_ReadBuffer: buffer too small for IMA digest\\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    else {\n\t\tmemcpy(&(imaEvent->digest), *buffer, sizeof(((ImaEvent *)NULL)->digest));\n\t\t*buffer += sizeof(((ImaEvent *)NULL)->digest);\n\t\t*length -= sizeof(((ImaEvent *)NULL)->digest);\n\t    }\n\t}\n\t/* read the IMA name length */\n\tif (rc == 0) {\n\t    rc = IMA_Uint32_Unmarshal(&imaEvent->name_len, buffer, length, littleEndian);\n\t}\n\t/* read the template name */\n\tif (rc == 0) {\n\t    /* bounds check the name length */\n\t    if (imaEvent->name_len > TCG_EVENT_NAME_LEN_MAX) {\n\t\tprintf(\"ERROR: IMA_Event_ReadBuffer: Error, template name length too big: %u\\n\",\n\t\t       imaEvent->name_len);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    else if (*length < imaEvent->name_len) {\n\t\tprintf(\"ERROR: IMA_Event_ReadBuffer: buffer too small for template name\\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    else {\n\t\t/* nul terminate first */\n\t\tmemset(imaEvent->name, 0, sizeof(((ImaEvent *)NULL)->name));\n\t\tmemcpy(&(imaEvent->name), *buffer, imaEvent->name_len);\n\t\t*buffer += imaEvent->name_len;\n\t\t*length -= imaEvent->name_len;\n\t    }\n\t}\n\t/* record the template name as an int */\n\tif (rc == 0) {\n\t    IMA_Event_ParseName(imaEvent);\n\t}\n\t/* read the template data length */\n\tif (rc == 0) {\n\t    rc = IMA_Uint32_Unmarshal(&imaEvent->template_data_len, buffer, length, littleEndian);\n\t}\n\t/* allocate for the template data */\n\tif (rc == 0) {\n\t    if (getTemplate) {\n\t\t/* bounds check the template data length */\n\t\tif (imaEvent->template_data_len > TCG_TEMPLATE_DATA_LEN_MAX) {\n\t\t    printf(\"ERROR: IMA_Event_ReadBuffer: template data length too big: %u\\n\",\n\t\t\t   imaEvent->template_data_len);\n\t\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t\t}\n\t\telse if (*length < imaEvent->template_data_len) {\n\t\t    printf(\"ERROR: IMA_Event_ReadBuffer: buffer too small for template data\\n\");\n\t\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t\t}\n\t\telse {\n\t\t    if (rc == 0) {\n\t\t\timaEvent->template_data = malloc(imaEvent->template_data_len);\n\t\t\tif (imaEvent->template_data == NULL) {\n\t\t\t    printf(\"ERROR: IMA_Event_ReadBuffer: \"\n\t\t\t\t   \"could not allocate template data, size %u\\n\",\n\t\t\t\t   imaEvent->template_data_len);\n\t\t\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t\t\t}\n\t\t    }\n\t\t    if (rc == 0) {\n\t\t\tmemcpy(imaEvent->template_data, *buffer, imaEvent->template_data_len);\n\t\t    }\n\t\t}\n\t    }\n\t    /* move the buffer even if getTemplate is false */\n\t    if (rc == 0) {\n\t\t*buffer += imaEvent->template_data_len;\n\t\t*length -= imaEvent->template_data_len;\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* IMA_TemplateName_Parse() parses the template name and registers the template data parsing and\n   tracing callbacks */\n\nstatic uint32_t IMA_TemplateName_Parse(TemplateDataParseFunction_t templateDataParseFunctions[],\n\t\t\t\t       TemplateDataTraceFunction_t templateDataTraceFunctions[],\n\t\t\t\t       size_t templateDataParseFunctionsSize,\n\t\t\t\t       ImaEvent *imaEvent)\n{\n    uint32_t \trc = 0;\n    size_t\ti;\n\n    /* initialize all the function pointers to NULL */\n    for (i = 0 ; (rc == 0) && (i < templateDataParseFunctionsSize) ; i++) {\n\ttemplateDataParseFunctions[i] = NULL;\n\ttemplateDataTraceFunctions[i] = NULL;\n    }\n    /* parse the name into the callback structure */\n    if (rc == 0) {\n\tswitch (imaEvent->nameInt) {\n\t    /* these are the pre-defined formats */\n\t  case IMA_FORMAT_IMA_NG:\n\t    /* d-ng | n-ng */\n\t    templateDataParseFunctions[0] = (TemplateDataParseFunction_t)IMA_ParseDNG;\n\t    templateDataParseFunctions[1] = (TemplateDataParseFunction_t)IMA_ParseNNG;\n\n\t    templateDataTraceFunctions[0] = (TemplateDataTraceFunction_t)IMA_TraceDNG;\n\t    templateDataTraceFunctions[1] = (TemplateDataTraceFunction_t)IMA_TraceNNG;\n\t    break;\n\t  case IMA_FORMAT_IMA_NGV2:\n\t    /* d-ng | n-ngv2 */\n\t    templateDataParseFunctions[0] = (TemplateDataParseFunction_t)IMA_ParseDNGV2;\n\t    templateDataParseFunctions[1] = (TemplateDataParseFunction_t)IMA_ParseNNG;\n\n\t    templateDataTraceFunctions[0] = (TemplateDataTraceFunction_t)IMA_TraceDNGV2;\n\t    templateDataTraceFunctions[1] = (TemplateDataTraceFunction_t)IMA_TraceNNG;\n\t    break;\n\t  case IMA_FORMAT_IMA_SIG:\n\t    /* d-ng | n-ng | sig */\n\t    templateDataParseFunctions[0] = (TemplateDataParseFunction_t)IMA_ParseDNG;\n\t    templateDataParseFunctions[1] = (TemplateDataParseFunction_t)IMA_ParseNNG;\n\t    templateDataParseFunctions[2] = (TemplateDataParseFunction_t)IMA_ParseSIG;\n\n\t    templateDataTraceFunctions[0] = (TemplateDataTraceFunction_t)IMA_TraceDNG;\n\t    templateDataTraceFunctions[1] = (TemplateDataTraceFunction_t)IMA_TraceNNG;\n\t    templateDataTraceFunctions[2] = (TemplateDataTraceFunction_t)IMA_TraceSIG;\n\t    break;\n\t  case IMA_FORMAT_IMA_SIGV2:\n\t    /* d-ngv2 | n-ng | sig */\n\t    templateDataParseFunctions[0] = (TemplateDataParseFunction_t)IMA_ParseDNGV2;\n\t    templateDataParseFunctions[1] = (TemplateDataParseFunction_t)IMA_ParseNNG;\n\t    templateDataParseFunctions[2] = (TemplateDataParseFunction_t)IMA_ParseSIG;\n\n\t    templateDataTraceFunctions[0] = (TemplateDataTraceFunction_t)IMA_TraceDNGV2;\n\t    templateDataTraceFunctions[1] = (TemplateDataTraceFunction_t)IMA_TraceNNG;\n\t    templateDataTraceFunctions[2] = (TemplateDataTraceFunction_t)IMA_TraceSIG;\n\t    break;\n\t  case IMA_FORMAT_IMA:\n\t    templateDataParseFunctions[0] = (TemplateDataParseFunction_t)IMA_ParseD;\n\t    templateDataParseFunctions[1] = (TemplateDataParseFunction_t)IMA_ParseNNG;\n\n\t    templateDataTraceFunctions[0] = (TemplateDataTraceFunction_t)IMA_TraceD;\n\t    templateDataTraceFunctions[1] = (TemplateDataTraceFunction_t)IMA_TraceNNG;\n\t    break;\n\t  case IMA_FORMAT_IMA_MODSIG:\n\t    /* d-ng | n-ng | sig | d-modsig | modsig */\n\t    templateDataParseFunctions[0] = (TemplateDataParseFunction_t)IMA_ParseDNG;\n\t    templateDataParseFunctions[1] = (TemplateDataParseFunction_t)IMA_ParseNNG;\n\t    templateDataParseFunctions[2] = (TemplateDataParseFunction_t)IMA_ParseSIG;\n\t    templateDataParseFunctions[3] = (TemplateDataParseFunction_t)IMA_ParseDMODSIG;\n\t    templateDataParseFunctions[4] = (TemplateDataParseFunction_t)IMA_ParseMODSIG;\n\n\t    templateDataTraceFunctions[0] = (TemplateDataTraceFunction_t)IMA_TraceDNG;\n\t    templateDataTraceFunctions[1] = (TemplateDataTraceFunction_t)IMA_TraceNNG;\n\t    templateDataTraceFunctions[2] = (TemplateDataTraceFunction_t)IMA_TraceSIG;\n\t    templateDataTraceFunctions[3] = (TemplateDataTraceFunction_t)IMA_TraceDMODSIG;\n\t    templateDataTraceFunctions[4] = (TemplateDataTraceFunction_t)IMA_TraceMODSIG;\n\t    break;\n\t  case IMA_FORMAT_IMA_BUF:\n\t    /* d-ng | n-ng | buf */\n\t    templateDataParseFunctions[0] = (TemplateDataParseFunction_t)IMA_ParseDNG;\n\t    templateDataParseFunctions[1] = (TemplateDataParseFunction_t)IMA_ParseNNG;\n\t    templateDataParseFunctions[2] = (TemplateDataParseFunction_t)IMA_ParseBUF;\n\n\t    templateDataTraceFunctions[0] = (TemplateDataTraceFunction_t)IMA_TraceDNG;\n\t    templateDataTraceFunctions[1] = (TemplateDataTraceFunction_t)IMA_TraceNNG;\n\t    templateDataTraceFunctions[2] = (TemplateDataTraceFunction_t)IMA_TraceBUF;\n\t    break;\n\t  case IMA_FORMAT_EVM_SIG:\n\t    /* d-ng | n-ng | evmsig | xattrnames | xattrlengths | xattrvalues |\n\t       iuid | igid | imode */\n\t    templateDataParseFunctions[0] = (TemplateDataParseFunction_t)IMA_ParseDNG;\n\t    templateDataParseFunctions[1] = (TemplateDataParseFunction_t)IMA_ParseNNG;\n\t    templateDataParseFunctions[2] = (TemplateDataParseFunction_t)IMA_ParseSIG;\n\t    templateDataParseFunctions[3] = (TemplateDataParseFunction_t)IMA_ParseXATTRNAMES;\n\t    templateDataParseFunctions[4] = (TemplateDataParseFunction_t)IMA_ParseXATTRLENGTHS;\n\t    templateDataParseFunctions[5] = (TemplateDataParseFunction_t)IMA_ParseXATTRVALUES;\n\t    templateDataParseFunctions[6] = (TemplateDataParseFunction_t)IMA_ParseIUID;\n\t    templateDataParseFunctions[7] = (TemplateDataParseFunction_t)IMA_ParseIGID;\n\t    templateDataParseFunctions[8] = (TemplateDataParseFunction_t)IMA_ParseIMODE;\n\n\t    templateDataTraceFunctions[0] = (TemplateDataTraceFunction_t)IMA_TraceDNG;\n\t    templateDataTraceFunctions[1] = (TemplateDataTraceFunction_t)IMA_TraceNNG;\n\t    templateDataTraceFunctions[2] = (TemplateDataTraceFunction_t)IMA_TraceSIG;\n\t    templateDataTraceFunctions[3] = (TemplateDataTraceFunction_t)IMA_TraceXATTRNAMES;\n\t    templateDataTraceFunctions[4] = (TemplateDataTraceFunction_t)IMA_TraceXATTRLENGTHS;\n\t    templateDataTraceFunctions[5] = (TemplateDataTraceFunction_t)IMA_TraceXATTRVALUES;\n\t    templateDataTraceFunctions[6] = (TemplateDataTraceFunction_t)IMA_TraceIUID;\n\t    templateDataTraceFunctions[7] = (TemplateDataTraceFunction_t)IMA_TraceIGID;\n\t    templateDataTraceFunctions[8] = (TemplateDataTraceFunction_t)IMA_TraceIMODE;\n\t    break;\n\t    /* these are potentially the custom templates */\n\t  default:\n\t    rc = IMA_TemplateName_ParseCustom(templateDataParseFunctions,\n\t\t\t\t\t      templateDataTraceFunctions,\n\t\t\t\t\t      templateDataParseFunctionsSize,\n\t\t\t\t\t      imaEvent);\n\t}\n    }\n    return rc;\n}\n\n/* the mapping between a format string and the template data parse function */\n\ntypedef struct {\n    const char *formatString;\n    TemplateDataParseFunction_t parseFunction;\n    TemplateDataTraceFunction_t traceFunction;\n} ImaFormatMap; \n\nstatic ImaFormatMap imaFormatMap[] = {\n    {\"d\",\n     (TemplateDataParseFunction_t)IMA_ParseD,\n     (TemplateDataTraceFunction_t)IMA_TraceD},\n    {\"n\",\n     (TemplateDataParseFunction_t)IMA_ParseNNG,\n     (TemplateDataTraceFunction_t)IMA_TraceNNG},\n    {\"d-ng\",\n     (TemplateDataParseFunction_t)IMA_ParseDNG,\n     (TemplateDataTraceFunction_t)IMA_TraceDNG},\n    {\"d-ngv2\",\n     (TemplateDataParseFunction_t)IMA_ParseDNGV2,\n     (TemplateDataTraceFunction_t)IMA_TraceDNGV2},\n    {\"n-ng\",\n     (TemplateDataParseFunction_t)IMA_ParseNNG,\n     (TemplateDataTraceFunction_t)IMA_TraceNNG},\n    {\"sig\",\n     (TemplateDataParseFunction_t)IMA_ParseSIG,\n     (TemplateDataTraceFunction_t)IMA_TraceSIG},\n    {\"d-modsig\",\n      (TemplateDataParseFunction_t)IMA_ParseDMODSIG,\n      (TemplateDataTraceFunction_t)IMA_TraceDMODSIG},\n    {\"modsig\",\n     (TemplateDataParseFunction_t)IMA_ParseMODSIG,\n     (TemplateDataTraceFunction_t)IMA_TraceMODSIG},\n    {\"buf\",\n     (TemplateDataParseFunction_t)IMA_ParseBUF,\n     (TemplateDataTraceFunction_t)IMA_TraceBUF},\n    {\"xattrnames\",\n     (TemplateDataParseFunction_t)IMA_ParseXATTRNAMES,\n     (TemplateDataTraceFunction_t)IMA_TraceXATTRNAMES},\n    {\"xattrlengths\",\n     (TemplateDataParseFunction_t)IMA_ParseXATTRLENGTHS,\n     (TemplateDataTraceFunction_t)IMA_TraceXATTRLENGTHS},\n    {\" xattrvalues\",\n     (TemplateDataParseFunction_t)IMA_ParseXATTRVALUES,\n     (TemplateDataTraceFunction_t)IMA_TraceXATTRVALUES},\n    {\"iuid\",\n     (TemplateDataParseFunction_t)IMA_ParseIUID,\n     (TemplateDataTraceFunction_t)IMA_TraceIUID},\n    {\"igid\",\n     (TemplateDataParseFunction_t)IMA_ParseIGID,\n     (TemplateDataTraceFunction_t)IMA_TraceIGID},\n    {\"imode\",\n     (TemplateDataParseFunction_t)IMA_ParseIMODE,\n     (TemplateDataTraceFunction_t)IMA_TraceIMODE}\n};\n\n/* IMA_TemplateName_ParseCustom() parses the template custom (not built-in) names and registers the\n   template data parsing and tracing callbacks */\n\nstatic uint32_t\nIMA_TemplateName_ParseCustom(TemplateDataParseFunction_t templateDataParseFunctions[],\n\t\t\t     TemplateDataTraceFunction_t templateDataTraceFunctions[],\n\t\t\t     size_t templateDataParseFunctionsSize,\n\t\t\t     ImaEvent *imaEvent)\n{\n    uint32_t \trc = 0;\n    size_t\ti;\t\t/* index into templateDataParseFunctions table */\n    size_t\tj;\t\t/* index into imaFormatMap table */\n    char \t*startName;\n    char\t*endName;\n    char \ttemplateName[TCG_EVENT_NAME_LEN_MAX + 1];\t/* one | separated item with nul */\n\n    /* parse the custom templates, strcpy is safe because the reader did the bounds check */\n    strcpy(templateName, imaEvent->name);\t/* modify'able */\n    startName = templateName;\n\n    for (i = 0 ; (rc == 0) && (i < templateDataParseFunctionsSize) ; i++) {\n\tendName = strchr(startName, '|');\n\tif (endName != NULL) {\t/* found a | character */\n\t    *endName = '\\0';\t/* nul terminate the next format string */\n\t}\n\tprintf(\"item %lu : %s\\n\", (unsigned long)i, startName);\n\t/* search the table for the format string */\n\tfor (j = 0 ; j < (sizeof(imaFormatMap) / sizeof(ImaFormatMap)) ; j++) {\n\t    int irc;\n\t    irc = strcmp(startName, imaFormatMap[j].formatString);\n\t    if (irc == 0) {\n\t\ttemplateDataParseFunctions[i] = imaFormatMap[j].parseFunction;\n\t\ttemplateDataTraceFunctions[i] = imaFormatMap[j].traceFunction;\n\t    }\n\t}\n\t/* if no format string found */\n\tif (templateDataParseFunctions[i] == NULL) {\n\t    printf(\"ERROR: IMA_TemplateName_ParseCustom: unknown format string %s\\n\",\n\t\t   startName);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n\t/* if found an item, move the pointer */\n\tif (rc == 0) {\n\t    startName = endName + 1;\n\t}\n\tif (endName == NULL) {\t/* no | character, last entry */\n\t    break;\n\t}\n    }\n    return rc;\n}\n\n/*\n  template data parsing callbacks\n*/\n\n/* IMA_ParseD() parses a d : digest (no length or algorithm) */\n\nstatic uint32_t IMA_ParseD(ImaTemplateData\t*imaTemplateData,\n\t\t\t   uint8_t \t\t**buffer,\n\t\t\t   size_t \t\t*length,\n\t\t\t   int \t\t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n    littleEndian = littleEndian;\t/* unised */\n    /* fileDataHash */\n    if (rc == 0) {\n\t/* bounds check the length */\n\tif (*length < SHA1_DIGEST_SIZE) {\n\t    printf(\"ERROR: IMA_ParseD: buffer too small for file data hash\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse {\n\t    imaTemplateData->imaTemplateDNG.fileDataHashLength = SHA1_DIGEST_SIZE;\n\t    memcpy(&(imaTemplateData->imaTemplateDNG.fileDataHash), *buffer, SHA1_DIGEST_SIZE);\n\t    *buffer += SHA1_DIGEST_SIZE;\n\t    *length -= SHA1_DIGEST_SIZE;\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseDNG parses a d-ng : hash length + hash algorithm string + digest\n\n   The digest is a file data hash.\n */\n\nstatic uint32_t IMA_ParseDNG(ImaTemplateData\t*imaTemplateData,\n\t\t\t     uint8_t \t\t**buffer,\n\t\t\t     size_t \t\t*length,\n\t\t\t     int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n    size_t \thashAlgSize;\n    /* read the hash length, algorithm + hash */\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateDNG.hashLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    /* read the hash algorithm, nul terminated string */\n    if (rc == 0) {\n    \t/* NUL terminate first */\n\tmemset(imaTemplateData->imaTemplateDNG.hashAlg, 0,\n\t       sizeof(((ImaTemplateData *)NULL)->imaTemplateDNG.hashAlg));\n\trc = IMA_Strn2cpy(imaTemplateData->imaTemplateDNG.hashAlg, *buffer,\n\t\t\t  sizeof(((ImaTemplateData *)NULL)->imaTemplateDNG.hashAlg),\t/* destLength */\n\t\t\t  imaTemplateData->imaTemplateDNG.hashLength);\t\t\t/* srcLength */\n\tif (rc != 0) {\n\t    printf(\"ERROR: IMA_ParseDNG: buffer too small for hash algorithm\\n\"\n\t\t   \"\\tor hash algorithm exceeds maximum size\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse {\n\t    hashAlgSize = strlen(imaTemplateData->imaTemplateDNG.hashAlg) + 1;\n\t    *buffer += hashAlgSize;\n\t    *length -= hashAlgSize;\n\t}\n    }\n    /* fileDataHashLength */\n    if (rc == 0) {\n\tif (strcmp(imaTemplateData->imaTemplateDNG.hashAlg, \"sha1:\") == 0) {\n\t    imaTemplateData->imaTemplateDNG.fileDataHashLength = SHA1_DIGEST_SIZE;\n\t    imaTemplateData->imaTemplateDNG.hashAlgId = TPM_ALG_SHA1;\n\t}\n\telse if (strcmp(imaTemplateData->imaTemplateDNG.hashAlg, \"sha256:\") == 0) {\n\t    imaTemplateData->imaTemplateDNG.fileDataHashLength = SHA256_DIGEST_SIZE;\n\t    imaTemplateData->imaTemplateDNG.hashAlgId = TPM_ALG_SHA256;\n\t}\n\telse {\n\t    printf(\"ERROR: IMA_ParseDNG: Unknown file data hash algorithm: %s\\n\",\n\t\t   imaTemplateData->imaTemplateDNG.hashAlg);\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n    /* consistency check hashLength vs contents */\n    if (rc == 0) {\n\tif ((hashAlgSize + imaTemplateData->imaTemplateDNG.fileDataHashLength) !=\n\t    imaTemplateData->imaTemplateDNG.hashLength) {\n\t    printf(\"ERROR: IMA_ParseDNG: \"\n\t\t   \"hashLength %u inconsistent with hashAlgSize %lu and fileDataHashLength %u\\n\",\n\t\t   imaTemplateData->imaTemplateDNG.hashLength, (unsigned long)hashAlgSize,\n\t\t   imaTemplateData->imaTemplateDNG.fileDataHashLength);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    /* fileDataHash */\n    if (rc == 0) {\n\t/* bounds check the length */\n\tif (*length < imaTemplateData->imaTemplateDNG.fileDataHashLength) {\n\t    printf(\"ERROR: IMA_ParseDNG: buffer too small for file data hash\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse if (imaTemplateData->imaTemplateDNG.fileDataHashLength >\n\t\t sizeof(((ImaTemplateData *)NULL)->imaTemplateDNG.fileDataHash)) {\n\t    printf(\"ERROR: IMA_ParseDNG: \"\n\t\t   \"file data hash length exceeds maximum size\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t} \n\telse {\n\t    memcpy(&(imaTemplateData->imaTemplateDNG.fileDataHash), *buffer,\n\t\t   imaTemplateData->imaTemplateDNG.fileDataHashLength);\n\t    *buffer += imaTemplateData->imaTemplateDNG.fileDataHashLength;\n\t    *length -= imaTemplateData->imaTemplateDNG.fileDataHashLength;\n#if 0\n\t    TSS_PrintAll(\"IMA_ParseDNG: file data hash\",\n\t\t\t imaTemplateData->imaTemplateDNG.fileDataHash,\n\t\t\t imaTemplateData->imaTemplateDNG.fileDataHashLength);\n#endif\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseDNGV2 parses a d-ngv2 : length + prefix + hash algorithm + hash\n\n   The digest is a file data hash.\n*/\n\nstatic uint32_t IMA_ParseDNGV2(ImaTemplateData\t*imaTemplateData,\n\t\t\t       uint8_t \t\t**buffer,\n\t\t\t       size_t \t\t*length,\n\t\t\t       int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n    size_t \thashAlgSize;\n    size_t \tprefixSize;\n\n    /* read the length, prefix + algorithm + hash */\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateDNGV2.hashLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    /* read the prefix, : terminated string */\n    if (rc == 0) {\n    \t/* NUL terminate first */\n\tmemset(imaTemplateData->imaTemplateDNGV2.prefix, 0,\n\t       sizeof(((ImaTemplateData *)NULL)->imaTemplateDNGV2.prefix));\n\trc = IMA_Strc2cpy(imaTemplateData->imaTemplateDNGV2.prefix, *buffer,\n\t\t\t  sizeof(((ImaTemplateData *)NULL)->imaTemplateDNGV2.prefix),\n\t\t\t  imaTemplateData->imaTemplateDNGV2.hashLength);\n\tif (rc != 0) {\n\t    printf(\"ERROR: IMA_ParseDNGV2: buffer too small for prefix\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse {\n\t    prefixSize = strlen(imaTemplateData->imaTemplateDNGV2.prefix);\n\t    *buffer += prefixSize;\n\t    *length -= prefixSize;\n\t}\n    }\n    /* read the hash algorithm, nul terminated string */\n    if (rc == 0) {\n    \t/* NUL terminate first */\n\tmemset(imaTemplateData->imaTemplateDNGV2.hashAlg, 0,\n\t       sizeof(((ImaTemplateData *)NULL)->imaTemplateDNGV2.hashAlg));\n\trc = IMA_Strn2cpy(imaTemplateData->imaTemplateDNGV2.hashAlg, *buffer,\n\t\t\t  /* destLength */\n\t\t\t  sizeof(((ImaTemplateData *)NULL)->imaTemplateDNGV2.hashAlg),\n\t\t\t  /* srcLength */\n\t\t\t  imaTemplateData->imaTemplateDNGV2.hashLength - prefixSize);\n\tif (rc != 0) {\n\t    printf(\"ERROR: IMA_ParseDNGV2: buffer too small for hash algorithm\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse {\n\t    hashAlgSize = strlen(imaTemplateData->imaTemplateDNGV2.hashAlg) + 1;\n\t    *buffer += hashAlgSize;\n\t    *length -= hashAlgSize;\n\t}\n    }\n    /* fileDataHashLength */\n    if (rc == 0) {\n\tif (strcmp(imaTemplateData->imaTemplateDNGV2.hashAlg, \"sha1:\") == 0) {\n\t    imaTemplateData->imaTemplateDNGV2.fileDataHashLength = SHA1_DIGEST_SIZE;\n\t    imaTemplateData->imaTemplateDNGV2.hashAlgId = TPM_ALG_SHA1;\n\t}\n\telse if (strcmp(imaTemplateData->imaTemplateDNGV2.hashAlg, \"sha256:\") == 0) {\n\t    imaTemplateData->imaTemplateDNGV2.fileDataHashLength = SHA256_DIGEST_SIZE;\n\t    imaTemplateData->imaTemplateDNGV2.hashAlgId = TPM_ALG_SHA256;\n\t}\n\telse {\n\t    printf(\"ERROR: IMA_ParseDNGV2: Unknown file data hash algorithm: %s\\n\",\n\t\t   imaTemplateData->imaTemplateDNGV2.hashAlg);\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n    /* consistency check hashLength vs contents */\n    if (rc == 0) {\n\tif ((prefixSize + hashAlgSize + imaTemplateData->imaTemplateDNGV2.fileDataHashLength) !=\n\t    imaTemplateData->imaTemplateDNGV2.hashLength) {\n\t    printf(\"ERROR: IMA_ParseDNGV2: \"\n\t\t   \"hashLength %u inconsistent with prefixSize %lu hashAlgSize %lu \"\n\t\t   \"and fileDataHashLength %u\\n\",\n\t\t   imaTemplateData->imaTemplateDNGV2.hashLength,\n\t\t   (unsigned long)prefixSize,\n\t\t   (unsigned long)hashAlgSize,\n\t\t   imaTemplateData->imaTemplateDNGV2.fileDataHashLength);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* fileDataHash */\n    if (rc == 0) {\n\t/* bounds check the length */\n\tif (*length < imaTemplateData->imaTemplateDNGV2.fileDataHashLength) {\n\t    printf(\"ERROR: IMA_ParseDNGV2: buffer too small for file data hash\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse if (imaTemplateData->imaTemplateDNGV2.fileDataHashLength >\n\t\t sizeof(((ImaTemplateData *)NULL)->imaTemplateDNGV2.fileDataHash)) {\n\t    printf(\"ERROR: IMA_ParseDNGV2: \"\n\t\t   \"file data hash length exceeds maximum size\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t} \n\telse {\n\t    memcpy(&(imaTemplateData->imaTemplateDNGV2.fileDataHash), *buffer,\n\t\t   imaTemplateData->imaTemplateDNGV2.fileDataHashLength);\n\t    *buffer += imaTemplateData->imaTemplateDNGV2.fileDataHashLength;\n\t    *length -= imaTemplateData->imaTemplateDNGV2.fileDataHashLength;\n#if 0\n\t    TSS_PrintAll(\"IMA_ParseDNGV2: file data hash\",\n\t\t\t imaTemplateData->imaTemplateDNGV2.fileDataHash,\n\t\t\t imaTemplateData->imaTemplateDNGV2.fileDataHashLength);\n#endif\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseNNG() parses a n-ng : length + filename */\n\nstatic uint32_t IMA_ParseNNG(ImaTemplateData\t*imaTemplateData,\n\t\t\t     uint8_t \t\t**buffer,\n\t\t\t     size_t \t\t*length,\n\t\t\t     int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n    /* fileNameLength (length includes the nul terminator) */\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateNNG.fileNameLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    /* fileName */\n    if (rc == 0) {\n\t/* bounds check the length */\n\tif (*length < imaTemplateData->imaTemplateNNG.fileNameLength) {\n\t    printf(\"ERROR: IMA_ParseNNG: buffer too small for file name\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\t/* leave one byte for the nul terminator */\n\telse if (imaTemplateData->imaTemplateNNG.fileNameLength >\n\t\t (sizeof(imaTemplateData->imaTemplateNNG.fileName)-1)) {\n\t    printf(\"ERROR: IMA_ParseNNG: file name length exceeds maximum size\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse {\n\t    memcpy(&(imaTemplateData->imaTemplateNNG.fileName), *buffer,\n\t\t   imaTemplateData->imaTemplateNNG.fileNameLength);\n\t    /* ima template does not nul terminate the file name */\n\t    imaTemplateData->imaTemplateNNG.fileName[imaTemplateData->imaTemplateNNG.fileNameLength] = '\\0';\n\t    *buffer += imaTemplateData->imaTemplateNNG.fileNameLength;\n\t    *length -= imaTemplateData->imaTemplateNNG.fileNameLength;\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseSIG() parses a sig : signature header + signature */\n\nstatic uint32_t IMA_ParseSIG(ImaTemplateData\t*imaTemplateData,\n\t\t\t     uint8_t \t\t**buffer,\n\t\t\t     size_t \t\t*length,\n\t\t\t     int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n    /* sigLength */\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateSIG.sigLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    /* sigHeader - only parsed if its length is not zero */\n    if (imaTemplateData->imaTemplateSIG.sigLength != 0) {\n\tif (rc == 0) {\n\t    imaTemplateData->imaTemplateSIG.sigHeaderLength =\n\t\tsizeof((ImaTemplateData *)NULL)->imaTemplateSIG.sigHeader;\n\t    /* bounds check the length */\n\t    if (*length < imaTemplateData->imaTemplateSIG.sigHeaderLength) {\n\t\tprintf(\"ERROR: IMA_ParseSIG: \"\n\t\t       \"buffer too small for signature header\\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    else {\n\t\tmemcpy(&(imaTemplateData->imaTemplateSIG.sigHeader), *buffer,\n\t\t       imaTemplateData->imaTemplateSIG.sigHeaderLength);\n\t\t*buffer += imaTemplateData->imaTemplateSIG.sigHeaderLength;\n\t\t*length -= imaTemplateData->imaTemplateSIG.sigHeaderLength;\n\t    }\n\t}\n\t/* get signature length from last two bytes */\n\tif (rc == 0) {\n\t    /* magic number for offset: type(1) version(1) hash alg (1) pubkey id (4) */\n\t    imaTemplateData->imaTemplateSIG.signatureSize =\n\t\tntohs(*(uint16_t *)(imaTemplateData->imaTemplateSIG.sigHeader + 7));\n\t}\n\t/* consistency check signature header contents */\n\tif (rc == 0) {\n\t    int goodHashAlgo = (((imaTemplateData->imaTemplateSIG.sigHeader[2] == HASH_ALGO_SHA1) &&\n\t\t\t\t (imaTemplateData->imaTemplateDNG.hashAlgId == TPM_ALG_SHA1)) ||\n\t\t\t\t((imaTemplateData->imaTemplateSIG.sigHeader[2] == HASH_ALGO_SHA256) &&\n\t\t\t\t (imaTemplateData->imaTemplateDNG.hashAlgId == TPM_ALG_SHA256)) ||\n\t\t\t\t/* might have sig without dng */\n\t\t\t\t(imaTemplateData->imaTemplateDNG.hashAlgId == TPM_ALG_NULL));\n\t    /* xattr type */\n\t    if (\n\t\t(imaTemplateData->imaTemplateSIG.sigHeader[1] != 2) ||\t\t/* [1] version */\n\t\t!goodHashAlgo\t\t\t\t/* [2] hash algorithm */\n\t\t/* [3]-[6] are the public key fingerprint.  Any value is legal. */\n\t\t/* [7][8] sig size cannot be checked, sig alg is not in log */\n\t\t) {\n\t\tprintf(\"ERROR: IMA_ParseSIG: invalid sigHeader %02x %02x\\n\",\n\t\t       imaTemplateData->imaTemplateSIG.sigHeader[0],\n\t\t       imaTemplateData->imaTemplateSIG.sigHeader[1]);\n\t\trc = TSS_RC_BAD_PROPERTY_VALUE;\n\t    }\n\t}\n\t/* signature */\n\tif (rc == 0) {\n\t    /* bounds check the length */\n\t    if (*length < imaTemplateData->imaTemplateSIG.signatureSize) {\n\t\tprintf(\"ERROR: IMA_ParseSIG: \"\n\t\t       \"buffer too small for signature \\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    /* sanity check the signatureSize against the sigLength */\n\t    else if (imaTemplateData->imaTemplateSIG.sigLength !=\n\t\t     (sizeof((ImaTemplateData *)NULL)->imaTemplateSIG.sigHeader +\n\t\t      imaTemplateData->imaTemplateSIG.signatureSize)) {\n\t\tprintf(\"ERROR: IMA_ParseSIG: \"\n\t\t       \"sigLength inconsistent with signatureSize\\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    else {\n\t\tmemcpy(&(imaTemplateData->imaTemplateSIG.signature), *buffer,\n\t\t       imaTemplateData->imaTemplateSIG.signatureSize);\n\t\t*buffer += imaTemplateData->imaTemplateSIG.signatureSize;\n\t\t*length -= imaTemplateData->imaTemplateSIG.signatureSize;\n#if 0\n\t\tTSS_PrintAll(\"IMA_ParseSIG: file data hash\",\n\t\t\t     imaTemplateData->imaTemplateSIG.signature,\n\t\t\t     imaTemplateData->imaTemplateSIG.signatureSize);\n\n#endif\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseDMODSIG parses a d-ng : hash length + hash algorithm string + digest\n\n   The digest is a file data hash omitting the appended modsig signature.\n\n   NOTE: This is currently thre same as IMA_ParseDNG but may have different processing in the\n   future.\n*/\n\nstatic uint32_t IMA_ParseDMODSIG(ImaTemplateData\t*imaTemplateData,\n\t\t\t\t uint8_t \t\t**buffer,\n\t\t\t\t size_t \t\t*length,\n\t\t\t\t int \t\t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n    size_t \thashAlgSize;\n\n    /* read the hash length, algorithm + hash */\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateDMODSIG.dModSigHashLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    /* FIXME is zero length an error? */\n    if (imaTemplateData->imaTemplateDMODSIG.dModSigHashLength != 0) {\n\n\t/* read the hash algorithm, nul terminated string */\n\tif (rc == 0) {\n\t    /* NUL terminate first */\n\t    memset(imaTemplateData->imaTemplateDMODSIG.dModSigHashAlg, 0,\n\t\t   sizeof(((ImaTemplateData *)NULL)->imaTemplateDMODSIG.dModSigHashAlgId));\n\t    rc = IMA_Strn2cpy(imaTemplateData->imaTemplateDMODSIG.dModSigHashAlg, *buffer,\n\t\t\t      /* destLength */\n\t\t\t      sizeof(((ImaTemplateData *)NULL)->imaTemplateDMODSIG.dModSigHashAlg),\n\t\t\t      /* srcLength */\n\t\t\t      imaTemplateData->imaTemplateDMODSIG.dModSigHashLength);\n\t    if (rc != 0) {\n\t\tprintf(\"ERROR: IMA_ParseDMODSIG: buffer too small for hash algorithm\\n\"\n\t\t       \"\\tor hash algorithm exceeds maximum size\\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    else {\n\t\thashAlgSize = strlen(imaTemplateData->imaTemplateDMODSIG.dModSigHashAlg) + 1;\n\t\t*buffer += hashAlgSize;\n\t\t*length -= hashAlgSize;\n\t    }\n\t}\n\t/* dModSigFileDataHashLength */\n\tif (rc == 0) {\n\t    if (strcmp(imaTemplateData->imaTemplateDMODSIG.dModSigHashAlg, \"sha1:\") == 0) {\n\t\timaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength = SHA1_DIGEST_SIZE;\n\t\timaTemplateData->imaTemplateDMODSIG.dModSigHashAlgId = TPM_ALG_SHA1;\n\t    }\n\t    else if (strcmp(imaTemplateData->imaTemplateDMODSIG.dModSigHashAlg, \"sha256:\") == 0) {\n\t\timaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength = SHA256_DIGEST_SIZE;\n\t\timaTemplateData->imaTemplateDMODSIG.dModSigHashAlgId = TPM_ALG_SHA256;\n\t    }\n\t    else {\n\t\tprintf(\"ERROR: IMA_ParseDMODSIG: Unknown file data hash algorithm: %s\\n\",\n\t\t       imaTemplateData->imaTemplateDMODSIG.dModSigHashAlg);\n\t\trc = TSS_RC_BAD_HASH_ALGORITHM;\n\t    }\n\t}\n\t/* consistency check dModSigFileDataHashLength vs contents */\n\tif (rc == 0) {\n\t    if ((hashAlgSize + imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength) !=\n\t\timaTemplateData->imaTemplateDMODSIG.dModSigHashLength) {\n\t\tprintf(\"ERROR: IMA_ParseDMODSIG: \"\n\t\t       \"dModSigFileDataHashLength %u inconsistent with hashAlgSize %lu \"\n\t\t       \"and dModSigFileDataHashLength %u\\n\",\n\t\t       imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength,\n\t\t       (unsigned long)hashAlgSize,\n\t\t       imaTemplateData->imaTemplateDMODSIG.dModSigHashLength);\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n\t/* dModSigFileDataHashLength */\n\tif (rc == 0) {\n\t    /* bounds check the length */\n\t    if (*length < imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength ) {\n\t\tprintf(\"ERROR: IMA_ParseDMODSIG: buffer too small for file data hash\\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    else if (imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength >\n\t\t     sizeof(((ImaTemplateData *)NULL)->imaTemplateDMODSIG.dModSigFileDataHash)) {\n\t\tprintf(\"ERROR: IMA_ParseDMODSIG: \"\n\t\t       \"file data hash length exceeds maximum size\\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    } \n\t    else {\n\t\tmemcpy(&(imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHash),\n\t\t       *buffer, imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength);\n\t\t*buffer += imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength ;\n\t\t*length -= imaTemplateData->imaTemplateDMODSIG.dModSigFileDataHashLength ;\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseMODSIG parses a modsig : 4 byte length + DER encoded CMS document, RFC 5652 */\n\nstatic uint32_t IMA_ParseMODSIG(ImaTemplateData\t*imaTemplateData,\n\t\t\t\tuint8_t \t**buffer,\n\t\t\t\tsize_t \t\t*length,\n\t\t\t\tint \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n\n    /* read the length */\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateMODSIG.modSigLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    /* read the DER */\n    if (rc == 0) {\n\t/* bounds check the length */\n\tif (*length  < imaTemplateData->imaTemplateMODSIG.modSigLength) {\n\t    printf(\"ERROR: IMA_ParseMODSIG: buffer too small for modSig data\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse if (imaTemplateData->imaTemplateMODSIG.modSigLength >\n\t\t sizeof(((ImaTemplateData *)NULL)->imaTemplateMODSIG.modSigData)) {\n\t    printf(\"ERROR: IMA_ParseMODSIG: \"\n\t\t   \"modSigData length exceeds maximum size\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t} \n\telse {\n\t    memcpy(&(imaTemplateData->imaTemplateMODSIG.modSigData), *buffer,\n\t\t   imaTemplateData->imaTemplateMODSIG.modSigLength);\n\t    *buffer += imaTemplateData->imaTemplateMODSIG.modSigLength;\n\t    *length -= imaTemplateData->imaTemplateMODSIG.modSigLength;\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseBUF parses a modsig : 4 byte length + DER encoded CMS document, RFC 5652 */\n\nstatic uint32_t IMA_ParseBUF(ImaTemplateData\t*imaTemplateData,\n\t\t\t     uint8_t \t\t**buffer,\n\t\t\t     size_t \t\t*length,\n\t\t\t     int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n\n    /* read the length */\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateBUF.bufLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    /* read the DER */\n    if (rc == 0) {\n\t/* bounds check the length */\n\tif (*length  < imaTemplateData->imaTemplateBUF.bufLength) {\n\t    printf(\"ERROR: IMA_ParseBUF: buffer too small for buf data\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse if (imaTemplateData->imaTemplateBUF.bufLength >\n\t\t sizeof(((ImaTemplateData *)NULL)->imaTemplateBUF.bufData)) {\n\t    printf(\"ERROR: IMA_ParseBUF: \"\n\t\t   \"bufData length exceeds maximum size\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t} \n\telse {\n\t    memcpy(&(imaTemplateData->imaTemplateBUF.bufData), *buffer,\n\t\t   imaTemplateData->imaTemplateBUF.bufLength);\n\t    *buffer += imaTemplateData->imaTemplateBUF.bufLength;\n\t    *length -= imaTemplateData->imaTemplateBUF.bufLength;\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseXATTRNAMESz parses an xattrnames field */\n\nstatic uint32_t IMA_ParseXATTRNAMES(ImaTemplateData\t*imaTemplateData,\n\t\t\t\t    uint8_t \t\t**buffer,\n\t\t\t\t    size_t \t\t*length,\n\t\t\t\t    int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n    size_t\ti;\n    size_t \txattrNamesSize;\n\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateXattrs.xattrNamesLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    if (imaTemplateData->imaTemplateXattrs.xattrNamesLength > 0) {\n\tif (rc == 0) {\n\t    /* NUL terminate first */\n\t    memset(imaTemplateData->imaTemplateXattrs.xattrNames, 0,\n\t\t   sizeof(((ImaTemplateData *)NULL)->imaTemplateXattrs.xattrNames));\n\t    /* copy nul terminated xattrnames string */\n\t    rc = IMA_Strn2cpy(imaTemplateData->imaTemplateXattrs.xattrNames, *buffer,\n\t\t\t      /* destLength */\n\t\t\t      sizeof(((ImaTemplateData *)NULL)->imaTemplateXattrs.xattrNames),\n\t\t\t      /* srcLength */\n\t\t\t      imaTemplateData->imaTemplateXattrs.xattrNamesLength);\n\t    if (rc != 0) {\n\t\tprintf(\"ERROR: IMA_ParseXATTRNAMES: buffer too small for xattrNames\\n\"\n\t\t       \"\\tor xattrNames exceeds maximum size\\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t    else {\n\t\t/* add one to strlen for nul terminator */\n\t\txattrNamesSize = strlen(imaTemplateData->imaTemplateXattrs.xattrNames) + 1;\n\t\t*buffer += xattrNamesSize;\n\t\t*length -= xattrNamesSize;\n\t    }\n\t}\n\t/* verify length of xattrnames against the string length */\n\tif (rc == 0) {\n\t    if (xattrNamesSize != imaTemplateData->imaTemplateXattrs.xattrNamesLength) {\n\t\tprintf(\"ERROR: IMA_ParseXATTRNAMES: length %lu not equal to string length %u\\n\",\n\t\t       (unsigned long)xattrNamesSize,\n\t\t       imaTemplateData->imaTemplateXattrs.xattrNamesLength);\n\t    }\n\t}\n\tif (rc == 0) {\n\t    /* if xattrNamesLength is > 0, have at least one name */\n\t    imaTemplateData->imaTemplateXattrs.xattrNamesPtr[0] =\n\t\timaTemplateData->imaTemplateXattrs.xattrNames;\n\t    imaTemplateData->imaTemplateXattrs.xattrNamesCount++;\n\n\t    for (i = 1 ;\n\t\t i < sizeof(((ImaTemplateData *)NULL)->imaTemplateXattrs.xattrNamesPtr) ; i++) {\n\t\t/* the | is a separator character */\n\t\timaTemplateData->imaTemplateXattrs.xattrNamesPtr[i] =\n\t\t    strchr(imaTemplateData->imaTemplateXattrs.xattrNamesPtr[i-1], '|');\n\t\t/* found a | character */\n\t\tif (imaTemplateData->imaTemplateXattrs.xattrNamesPtr[i] != NULL) {\n\t\t    /* nul terminate the previous string, replace | with nul */\n\t\t    *(imaTemplateData->imaTemplateXattrs.xattrNamesPtr[i]) = '\\0';\n\t\t    imaTemplateData->imaTemplateXattrs.xattrNamesPtr[i] += 1; /* skip the | */\n\t\t    imaTemplateData->imaTemplateXattrs.xattrNamesCount++;\n\t\t}\n\t\telse {\n\t\t    break;\t/* no more | separators */\n\t\t}\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseXATTRLENGTHS parses an xattrlengths field */\n\nstatic uint32_t IMA_ParseXATTRLENGTHS(ImaTemplateData\t*imaTemplateData,\n\t\t\t\t      uint8_t \t\t**buffer,\n\t\t\t\t      size_t \t\t*length,\n\t\t\t\t      int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n    size_t\ti;\n\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateXattrs.xattrLengthsLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    if (rc == 0) {\n\t/* range check against total buffer */\n\tif (*length < imaTemplateData->imaTemplateXattrs.xattrLengthsLength) {\n\t    printf(\"ERROR: IMA_ParseXATTRLENGTHS: buffer too small for xattrLengthsLength\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\t/* 4-byte lengths, so must be a multiple of 4 */\n\telse if ((imaTemplateData->imaTemplateXattrs.xattrLengthsLength % 4) != 0) {\n\t    printf(\"ERROR: IMA_ParseXATTRLENGTHS: xattrLengthsLength not multiple of 4\\n\");\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n\t/* array of lengths must fit in (guess at) xattrLengths array */\n\telse if ((imaTemplateData->imaTemplateXattrs.xattrLengthsLength / 4) >\n\t\t sizeof(((ImaTemplateData *)NULL)->imaTemplateXattrs.xattrLengths)) {\n\t    printf(\"ERROR: IMA_ParseXATTRLENGTHS: xattrLengths length %u too large\\n\",\n\t\t   imaTemplateData->imaTemplateXattrs.xattrLengthsLength);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse if ((imaTemplateData->imaTemplateXattrs.xattrLengthsLength / 4) !=\n\t\t imaTemplateData->imaTemplateXattrs.xattrNamesCount) {\n\t    printf(\"ERROR: IMA_ParseXATTRLENGTHS: xattrLengthsLength %lu \"\n\t\t   \"does not match xattrNames Count %lu\\n\",\n\t\t   (unsigned long)imaTemplateData->imaTemplateXattrs.xattrLengthsLength,\n\t\t   (unsigned long)imaTemplateData->imaTemplateXattrs.xattrNamesCount);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n\n    }\n    /* unmarshal the xattrLengths array */ \n    if (rc == 0) {\n\tfor (i = 0 ; i < imaTemplateData->imaTemplateXattrs.xattrLengthsLength / 4 ; i++) {\n\t    rc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateXattrs.xattrLengths[i],\n\t\t\t\t      buffer, length, littleEndian);\n\t    imaTemplateData->imaTemplateXattrs.xattrLengthsSum +=\n\t\timaTemplateData->imaTemplateXattrs.xattrLengths[i];\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseXATTRVALUES parses a xattrvalues structure */\n\nstatic uint32_t IMA_ParseXATTRVALUES(ImaTemplateData\t*imaTemplateData,\n\t\t\t\t     uint8_t \t\t**buffer,\n\t\t\t\t     size_t \t\t*length,\n\t\t\t\t     int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateXattrs.xattrValuesLength,\n\t\t\t\t  buffer, length, littleEndian);\n\t/* range check against total buffer */\n\tif (*length < imaTemplateData->imaTemplateXattrs.xattrValuesLength) {\n\t    printf(\"ERROR: IMA_ParseXATTRVALUES: buffer too small for xattrValuesLength\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse if (imaTemplateData->imaTemplateXattrs.xattrValuesLength !=\n\t\t imaTemplateData->imaTemplateXattrs.xattrLengthsSum) {\n\t    printf(\"ERROR: IMA_ParseXATTRVALUES: \"\n\t\t   \"xattrLengths and xattrValuesLength inconsistent\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n\telse if (imaTemplateData->imaTemplateXattrs.xattrValuesLength >\n\t\t sizeof(((ImaTemplateData *)NULL)->imaTemplateXattrs.xattrValues)) {\n\t    printf(\"ERROR: IMA_ParseXATTRVALUES: xattrValues array too small\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* copy the unparsed xattrValues buffer */\n    if (rc == 0) {\n\tmemcpy(imaTemplateData->imaTemplateXattrs.xattrValues,\n\t       *buffer, imaTemplateData->imaTemplateXattrs.xattrValuesLength);\n\t*buffer += imaTemplateData->imaTemplateXattrs.xattrValuesLength;\n\t*length -= imaTemplateData->imaTemplateXattrs.xattrValuesLength;\n    }\n#if 0\n    TSS_PrintAll(\"IMA_ParseXATTRVALUES: xattrvalues\",\n\t\t imaTemplateData->imaTemplateXattrs.xattrValues,\n\t\t imaTemplateData->imaTemplateXattrs.xattrValuesLength);\n#endif\n    return rc;\n}\n\n/* IMA_ParseIUID parses a iuid, either a uint16 or uint32 */\n\nstatic uint32_t IMA_ParseIUID(ImaTemplateData\t*imaTemplateData,\n\t\t\t      uint8_t \t\t**buffer,\n\t\t\t      size_t \t\t*length,\n\t\t\t      int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateIUID.iuidLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    if ((rc == 0) && (imaTemplateData->imaTemplateIUID.iuidLength > 0)) {\n\tif (imaTemplateData->imaTemplateIUID.iuidLength == 2) {\n\t    rc = IMA_Uint16_Unmarshal(&imaTemplateData->imaTemplateIUID.iuid16,\n\t\t\t\t      buffer, length, littleEndian);\n\t}\n\telse if (imaTemplateData->imaTemplateIUID.iuidLength == 4) {\n\t    rc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateIUID.iuid32,\n\t\t\t\t      buffer, length, littleEndian);\n\t}\n\telse {\n\t    printf(\"ERROR: IMA_ParseIUID: length %u not 2 or 4 bytes\\n\",\n\t\t   imaTemplateData->imaTemplateIUID.iuidLength);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n   return rc;\n}\n\n/* IMA_ParseIGID parses a igid, either a uint16 or uint32 */\n\nstatic uint32_t IMA_ParseIGID(ImaTemplateData\t*imaTemplateData,\n\t\t\t      uint8_t \t\t**buffer,\n\t\t\t      size_t \t\t*length,\n\t\t\t      int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateIGID.igidLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    if ((rc == 0) && (imaTemplateData->imaTemplateIGID.igidLength > 0)) {\n\tif (imaTemplateData->imaTemplateIGID.igidLength == 2) {\n\t    rc = IMA_Uint16_Unmarshal(&imaTemplateData->imaTemplateIGID.igid16,\n\t\t\t\t      buffer, length, littleEndian);\n\t}\n\telse if (imaTemplateData->imaTemplateIGID.igidLength == 4) {\n\t    rc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateIGID.igid32,\n\t\t\t\t      buffer, length, littleEndian);\n\t}\n\telse {\n\t    printf(\"ERROR: IMA_ParseIGID: length %u not 2 or 4 bytes\\n\",\n\t\t   imaTemplateData->imaTemplateIGID.igidLength);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* IMA_ParseIMODE parses a */\n\nstatic uint32_t IMA_ParseIMODE(ImaTemplateData\t*imaTemplateData,\n\t\t\t      uint8_t \t\t**buffer,\n\t\t\t      size_t \t\t*length,\n\t\t\t      int \t\tlittleEndian)\n{\n    uint32_t \trc = 0;\n\n    if (rc == 0) {\n\trc = IMA_Uint32_Unmarshal(&imaTemplateData->imaTemplateIMODE.imodeLength,\n\t\t\t\t  buffer, length, littleEndian);\n    }\n    if ((rc == 0) && (imaTemplateData->imaTemplateIMODE.imodeLength > 0)) {\n\tif (imaTemplateData->imaTemplateIMODE.imodeLength == 2) {\n\t    rc = IMA_Uint16_Unmarshal(&imaTemplateData->imaTemplateIMODE.imode,\n\t\t\t\t      buffer, length, littleEndian);\n\t}\n\telse {\n\t    printf(\"ERROR: IMA_ParseIMODE: length %u not 2 bytes\\n\",\n\t\t   imaTemplateData->imaTemplateIMODE.imodeLength);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* IMA_TemplateData_ReadBuffer() unmarshals the template data fields from the template data byte\n   array.\n\n*/\n\nuint32_t IMA_TemplateData_ReadBuffer(ImaTemplateData *imaTemplateData,\n\t\t\t\t     ImaEvent *imaEvent,\n\t\t\t\t     int littleEndian)\n{\n    uint32_t \trc = 0;\n    size_t \tlength = imaEvent->template_data_len;\n    uint8_t \t*buffer = imaEvent->template_data;\n    TemplateDataParseFunction_t templateDataParseFunctions[IMA_PARSE_FUNCTIONS_MAX];\n    size_t\ti;\n\n    /* initialize all fields, since not all fields are included in all templates */\n    if (rc == 0) {\n\tIMA_TemplateData_Init(imaTemplateData);\n    }\n    if (rc == 0) {\n\trc = IMA_TemplateName_Parse(templateDataParseFunctions,\n\t\t\t\t    imaTemplateData->templateDataTraceFunctions,\n\t\t\t\t    IMA_PARSE_FUNCTIONS_MAX,\n\t\t\t\t    imaEvent);\n    }\n    for (i = 0 ; (rc == 0) && (templateDataParseFunctions[i] != NULL) ; i++) {\n\trc = templateDataParseFunctions[i](imaTemplateData, &buffer, &length, littleEndian);\n    }\n    /* length should now be zero */\n    if (rc == 0) {\n\tif (length != 0) {\n\t    printf(\"ERROR: IMA_TemplateData_ReadBuffer: \"\n\t\t   \"buffer too large (bytes remaining after unmarshaling)\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    return rc;\n}\n\n/* IMA_Event_Write() writes an event line to a binary file outFile.\n\n   The write is always big endian, network byte order.\n*/\n\nuint32_t IMA_Event_Write(ImaEvent *imaEvent,\n\t\t\t FILE *outFile)\n{\n    int rc = 0;\n    size_t writeSize;\n    uint32_t nbo32;\t/* network byte order */\n\n    if (rc == 0) {\n\t/* do the endian conversion */\n\tnbo32 = htonl(imaEvent->pcrIndex);\n\t/* write the IMA pcr index */\n\twriteSize = fwrite(&nbo32, sizeof(uint32_t), 1, outFile);\n\tif (writeSize != 1) {\n\t    printf(\"ERROR: IMA_Event_Write: could not write pcrIndex, returned %lu\\n\",\n\t\t   (unsigned long)writeSize);\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    /* write the IMA digest, name length */\n    if (rc == 0) {\n\twriteSize = fwrite(&(imaEvent->digest), sizeof(((ImaEvent *)NULL)->digest), 1, outFile);\n\tif (writeSize != 1) {\n\t    printf(\"ERROR: IMA_Event_Write: could not write digest, returned %lu\\n\",\n\t\t   (unsigned long)writeSize);\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    /* write the IMA name length */\n    if (rc == 0) {\n\t/* do the endian conversion */\n\tnbo32 = htonl(imaEvent->name_len);\n\t/* write the IMA name length */\n\twriteSize = fwrite(&nbo32, sizeof(uint32_t), 1, outFile);\n\tif (writeSize != 1) {\n\t    printf(\"ERROR: IMA_Event_Write: could not write name length, returned %lu\\n\",\n\t\t   (unsigned long)writeSize);\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    /* write the name */\n    if (rc == 0) {\n\twriteSize = fwrite(&(imaEvent->name), imaEvent->name_len, 1, outFile);\n\tif (writeSize != 1) {\n\t    printf(\"ERROR: IMA_Event_Write: could not write name, returned %lu\\n\",\n\t\t   (unsigned long)writeSize);\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    /* write the template data length */\n    if (rc == 0) {\n\t/* do the endian conversion */\n\tnbo32 = htonl(imaEvent->template_data_len);\n\t/* write the IMA template data length */\n\twriteSize = fwrite(&nbo32, sizeof(uint32_t), 1, outFile);\n\tif (writeSize != 1) {\n\t    printf(\"ERROR: IMA_Event_Write: could not template data length , returned %lu\\n\",\n\t\t   (unsigned long)writeSize);\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    /* write the template data */\n    if (rc == 0) {\n\twriteSize = fwrite(&(imaEvent->template_data), imaEvent->template_data_len, 1, outFile);\n\tif (writeSize != 1) {\n\t    printf(\"ERROR: IMA_Event_Write: could not write template data, returned %lu\\n\",\n\t\t   (unsigned long)writeSize);\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    return rc;\n}\n\n/* IMA_Extend() extends the event into the imaPcr.\n\n   An IMA quirk is that, if the event is all zero, all ones is extended into the SHA-1 bank.  Since\n   the SHA-256 bank currently gets the SHA-1 value zero extended, it will get 20 ff's and 12 00's.\n\n   halg indicates whether to calculate the digest for the SHA-1 or SHA-256 PCR bank.  The IMA event\n   log itself is always SHA-1.\n\n   This function assumes that the same hash algorithm / PCR bank is used for all calls.\n*/\n\nuint32_t IMA_Extend(TPMT_HA *imapcr,\n\t\t    ImaEvent *imaEvent,\n\t\t    TPMI_ALG_HASH hashAlg)\n{\n    uint32_t \t\trc = 0;\n    uint16_t\t\tdigestSize;\n    uint16_t\t\tzeroPad;\n    int \t\tnotAllZero;\n    unsigned char zeroDigest[SHA256_DIGEST_SIZE];\n    unsigned char oneDigest[SHA256_DIGEST_SIZE];\n\n    /* FIXME sanity check TPM_IMA_PCR imaEvent->pcrIndex */\n\n    /* extend based on the previous IMA PCR value */\n    if (rc == 0) {\n\tmemset(zeroDigest, 0, SHA256_DIGEST_SIZE);\n\tmemset(oneDigest, 0xff, SHA256_DIGEST_SIZE);\n\tif (hashAlg == TPM_ALG_SHA1) {\n\t    digestSize = SHA1_DIGEST_SIZE;\n\t    zeroPad = 0;\n\t}\n\telse if (hashAlg == TPM_ALG_SHA256) {\n\t    digestSize = SHA256_DIGEST_SIZE;\n\t    /* pad the SHA-1 event with zeros for the SHA-256 bank */\n\t    zeroPad = SHA256_DIGEST_SIZE - SHA1_DIGEST_SIZE;\n\t}\n\telse {\n\t    printf(\"ERROR: IMA_Extend: Unsupported hash algorithm: %04x\\n\", hashAlg);\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n    if (rc == 0) {\n\tnotAllZero = memcmp(imaEvent->digest, zeroDigest, SHA1_DIGEST_SIZE);\n\timapcr->hashAlg = hashAlg;\n#if 1\n\tTSS_PrintAll(\"IMA_Extend: Start PCR\", (uint8_t *)&imapcr->digest, digestSize);\n\tTSS_PrintAll(\"IMA_Extend: SHA-256 Pad\", zeroDigest, zeroPad);\n#endif\n\tif (notAllZero) {\n\t    TSS_PrintAll(\"IMA_Extend: Extend\", (uint8_t *)&imaEvent->digest, SHA1_DIGEST_SIZE);\n\t    rc = TSS_Hash_Generate(imapcr,\n\t\t\t\t   digestSize, (uint8_t *)&imapcr->digest,\n\t\t\t\t   SHA1_DIGEST_SIZE, &imaEvent->digest,\n\t\t\t\t   /* SHA-1 PCR extend gets zero padded */\n\t\t\t\t   zeroPad, zeroDigest,\n\t\t\t\t   0, NULL);\n#if 1\n\t    TSS_PrintAll(\"IMA_Extend: notAllZero End PCR\",\n\t\t\t (uint8_t *)&imapcr->digest, digestSize);\n#endif\n\t}\n\t/* IMA has a quirk where, when it places all all zero digest into the measurement log, it\n\t   extends all ones into IMA PCR */\n\telse {\n\t    TSS_PrintAll(\"IMA_Extend: Extend\", (uint8_t *)oneDigest, SHA1_DIGEST_SIZE);\n\t    rc = TSS_Hash_Generate(imapcr,\n\t\t\t\t   digestSize, (uint8_t *)&imapcr->digest,\n\t\t\t\t   SHA1_DIGEST_SIZE, oneDigest,\n\t\t\t\t   /* SHA-1 gets zero padded */\n\t\t\t\t   zeroPad, zeroDigest,\n\t\t\t\t   0, NULL);\n#if 1\n\t    TSS_PrintAll(\"IMA_Extend: allZero End PCR\",\n\t\t\t (uint8_t *)&imapcr->digest, digestSize);\n#endif\n\t}\n    }\n    if (rc != 0) {\n\tprintf(\"ERROR: IMA_Extend: could not extend imapcr, rc %08x\\n\", rc);\n    }\n    return rc;\n}\n\n/* IMA_VerifyImaDigest() verifies the IMA digest against the hash of the template data.\n\n   This handles the SHA-1 IMA event log.\n*/\n\nuint32_t IMA_VerifyImaDigest(uint32_t *badEvent, /* TRUE if hash does not match */\n\t\t\t     ImaEvent *imaEvent, /* the current IMA event being processed */\n\t\t\t     int eventNum)\t /* the current IMA event number being processed */\n{\n    uint32_t \trc = 0;\n    int\t\tirc;\n    TPMT_HA \tcalculatedImaDigest;\n    \n    /* calculate the hash of the template data */\n    if (rc == 0) {\n\tcalculatedImaDigest.hashAlg = TPM_ALG_SHA1;\n\t/* standard case, hash of entire template data */\n\tif (imaEvent->nameInt != IMA_FORMAT_IMA) {\n\t    rc = TSS_Hash_Generate(&calculatedImaDigest,\n\t\t\t\t   imaEvent->template_data_len, imaEvent->template_data,\n\t\t\t\t   0, NULL);\n\t}\n\t/* special case of \"ima\" template, hash of File Data Hash || File Name padded with zeros to\n\t   256 bytes */\n\telse {\n\t    ImaTemplateData imaTemplateData;\n\t    int zeroPadLength;\n\t    uint8_t zeroPad[256];\n\t    if (rc == 0) {\n\t\trc = IMA_TemplateData_ReadBuffer(&imaTemplateData,\n\t\t\t\t\t\t imaEvent,\n\t\t\t\t\t\t TRUE);\t/* FIXME littleEndian */\n\t    }\n\t    if (rc == 0) {\n\t\tif (imaTemplateData.imaTemplateNNG.fileNameLength > sizeof(zeroPad)) {\n\t\t    printf(\"ERROR: IMA_VerifyImaDigest: ima template file name length %u > %lu\\n\",\n\t\t\t   imaTemplateData.imaTemplateNNG.fileNameLength,\n\t\t\t   (unsigned long)sizeof(zeroPad));\n\t\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t\t}\n\t    }\n\t    if (rc == 0) {\n\t\tmemset(zeroPad, 0, sizeof(zeroPad));\n\t\t/* subtract safe after above length check */\n\t\tzeroPadLength = sizeof(zeroPad) - imaTemplateData.imaTemplateNNG.fileNameLength;\n\t    }\n\t    if (rc == 0) {\n\t\trc = TSS_Hash_Generate(&calculatedImaDigest,\n\t\t\t\t       SHA1_DIGEST_SIZE, &imaTemplateData.imaTemplateDNG.fileDataHash,\n\t\t\t\t       imaTemplateData.imaTemplateNNG.fileNameLength,\n\t\t\t\t       &imaTemplateData.imaTemplateNNG.fileName,\n\t\t\t\t       zeroPadLength, zeroPad,\n\t\t\t\t       0, NULL);\n\t    }\n\t}\n    }\n    /* compare the calculated hash to the event digest received from the client */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_PrintAll(\"IMA_VerifyImaDigest: Received IMA digest\",\n\t\t\t\t   imaEvent->digest, SHA1_DIGEST_SIZE);\n\tif (tssUtilsVerbose) TSS_PrintAll(\"IMA_VerifyImaDigest: Calculated IMA digest\",\n\t\t\t\t   (uint8_t *)&calculatedImaDigest.digest, SHA1_DIGEST_SIZE);\n\n\tirc = memcmp(imaEvent->digest, &calculatedImaDigest.digest, SHA1_DIGEST_SIZE);\n\tif (irc == 0) {\n\t    if (tssUtilsVerbose) printf(\"IMA_VerifyImaDigest: IMA digest verified, event %u\\n\",\n\t\t\t\t\teventNum);\n\t    *badEvent = FALSE;\n\t}\n\telse {\n\t    printf(\"ERROR: IMA_VerifyImaDigest: IMA digest did not verify, event %u\\n\",\n\t\t   eventNum);\n\t    *badEvent = TRUE;\n\t}\n    }\n    return rc;\n}\n\n/* IMA_Uint16_Unmarshal() converts a uint8_t (from an input stream) to host byte order\n */\n\nstatic uint32_t IMA_Uint16_Unmarshal(uint16_t \t*out,\n\t\t\t\t     uint8_t \t**buffer,\n\t\t\t\t     size_t \t*length,\n\t\t\t\t     int \tlittleEndian)\n{\n    uint32_t \trc = 0;\n\n    *out = 0;\n    /* bounds check the length */\n    if (rc == 0) {\n\tif (*length < sizeof(uint16_t)) {\n\t    printf(\"ERROR: IMA_Uint16_Convert: buffer too small for length\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\t/* little endian input */\n\tif (littleEndian) {\n\t    *out = (((uint16_t)(*buffer)[0]) <<  0) |\n\t\t   (((uint16_t)(*buffer)[1]) <<  8);\n\t}\n\t/* big endian input */\n\telse {\n\t    *out = (((uint16_t)(*buffer)[0]) <<  8) |\n\t\t   (((uint16_t)(*buffer)[1]) <<  0);\n\t}\n\t*buffer += sizeof(uint16_t);\n\t*length -= sizeof(uint16_t);\n    }\n    return rc;\n}\n\n/* IMA_Uint32_Ummarshal() converts a uint8_t (from an input stream) to host byte order\n */\n\nstatic uint32_t IMA_Uint32_Unmarshal(uint32_t \t*out,\n\t\t\t\t     uint8_t\t**buffer,\n\t\t\t\t     size_t \t*length,\n\t\t\t\t     int \tlittleEndian)\n{\n    uint32_t \trc = 0;\n\n    *out = 0;\n    /* bounds check the length */\n    if (rc == 0) {\n\tif (*length < sizeof(uint32_t)) {\n\t    printf(\"ERROR: IMA_Uint32_Unmarshal: buffer too small for length\\n\");\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\t/* little endian input */\n\tif (littleEndian) {\n\t    *out = (((uint32_t)(*buffer)[0]) <<  0) |\n\t\t   (((uint32_t)(*buffer)[1]) <<  8) |\n\t\t   (((uint32_t)(*buffer)[2]) << 16) |\n\t\t   (((uint32_t)(*buffer)[3]) << 24);\n\t}\n\t/* big endian input */\n\telse {\n\t    *out = (((uint32_t)(*buffer)[0]) << 24) |\n\t\t   (((uint32_t)(*buffer)[1]) << 16) |\n\t\t   (((uint32_t)(*buffer)[2]) <<  8) |\n\t\t   (((uint32_t)(*buffer)[3]) <<  0);\n\t}\n\t*buffer += sizeof(uint32_t);\n\t*length -= sizeof(uint32_t);\n    }\n    return rc;\n}\n\n/* IMA_Uint32_Convert() converts a uint8_t (from an input stream) to host byte order\n */\n\nstatic uint32_t IMA_Uint32_Convert(const uint8_t *stream,\n\t\t\t\t   int littleEndian)\n{\n    uint32_t out = 0;\n\n    /* little endian input */\n    if (littleEndian) {\n\tout = (stream[0] <<  0) |\n\t      (stream[1] <<  8) |\n\t      (stream[2] << 16) |\n\t      (stream[3] << 24);\n    }\n    /* big endian input */\n    else {\n\tout = (stream[0] << 24) |\n\t      (stream[1] << 16) |\n\t      (stream[2] <<  8) |\n\t      (stream[3] <<  0);\n    }\n    return out;\n}\n\n/* IMA_Strn2cpy() copies src to dest, including a NUL terminator\n\n   It checks that src is nul terminated within srcLength bytes.\n   It checks that src fits into dest within destLength bytes\n\n   Returns error if either the src is not nul terminated or will not fit in dest.\n*/\n\nstatic uint32_t IMA_Strn2cpy(char *dest, const uint8_t *src,\n\t\t\t     size_t destLength, size_t srcLength)\n{\n    uint32_t rc = 0;\n    int done = 0;\n\n    while ((destLength > 0) && (srcLength > 0)) {\n\t*dest = *src;\n\tif (*dest == '\\0') {\n\t    done = 1;\n\t    break;\n\t}\n\telse {\n\t    dest++;\n\t    src++;\n\t    destLength--;\n\t    srcLength--;\n\t}\n    }\n    if (!done) {\n\trc = TSS_RC_INSUFFICIENT_BUFFER;\n    }\n    return rc;\n}\n\n/* IMA_Strc2cpy() copies src to dest, including a NUL terminator\n\n   It checks that src is colon terminated within srcLength bytes.\n   It checks that src fits into dest within destLength bytes\n\n   Returns error if either the src is not nul terminated or will not fit in dest.\n*/\n\nstatic uint32_t IMA_Strc2cpy(char *dest, const uint8_t *src,\n\t\t\t     size_t destLength, size_t srcLength)\n{\n    uint32_t rc = 0;\n    int done = 0;\n\n    while ((destLength > 0) && (srcLength > 0)) {\n\t*dest = *src;\n\tif (*dest == ':') {\n\t    *(dest+1) = '\\0';\t/* append nul */\n\t    done = 1;\n\t    break;\n\t}\n\telse {\n\t    dest++;\n\t    src++;\n\t    destLength--;\n\t    srcLength--;\n\t}\n    }\n    if (!done) {\n\trc = TSS_RC_INSUFFICIENT_BUFFER;\n    }\n    return rc;\n}\n\n/* IMA_Event_Marshal() marshals an ImaEvent structure */\n\nTPM_RC IMA_Event_Marshal(ImaEvent *source,\n\t\t\t uint16_t *written, uint8_t **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->pcrIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->digest, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->name_len, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu((uint8_t *)source->name, source->name_len, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->template_data_len, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->template_data, source->template_data_len,\n\t\t\t       written, buffer, size);\n    }\n    return rc;\n}\n\n/* IMA_Event_PcrExtend() extends PCR digests with the digest from the ImaEvent event log\n   entry.\n\n   Bank 0 is SHA-1.  Bank 1 is SHA-256.\n\n   The function supports all PCRs, even though the PCRs are limited in practice.\n\n*/\n\nuint32_t IMA_Event_PcrExtend(TPMT_HA pcrs[IMA_PCR_BANKS][IMPLEMENTATION_PCR],\n\t\t\t     ImaEvent *imaEvent)\n{\n    TPM_RC \t\trc = 0;\n    uint8_t\t\teventData[SHA256_DIGEST_SIZE];\n    \n    /* validate PCR number */\n    if (rc == 0) {\n\tif (imaEvent->pcrIndex >= IMPLEMENTATION_PCR) {\n\t    printf(\"ERROR: IMA_Event_PcrExtend: PCR number %u %08x out of range\\n\",\n\t\t   imaEvent->pcrIndex, imaEvent->pcrIndex);\n\t    rc = TSS_RC_BAD_PROPERTY;\n\t}\n    }\n    /* process each event hash algorithm */\n    if (rc == 0) {\n\tunsigned char \tzeroDigest[SHA1_DIGEST_SIZE];\n\tint \t\tnotAllZero;\n\tmemset(zeroDigest, 0, SHA1_DIGEST_SIZE);\n\tnotAllZero = memcmp(imaEvent->digest, zeroDigest, SHA1_DIGEST_SIZE);\n\t/* for the SHA-256 zero extend */\n\tmemset(eventData, 0, SHA256_DIGEST_SIZE);\n\t\n\t/* IMA has a quirk where some measurements store a zero digest in the event log, but\n\t   extend ones into PCR 10 */\n\tif (notAllZero) {\n\t    memcpy(eventData, imaEvent->digest, SHA1_DIGEST_SIZE);\n\t}\n\telse {\n\t    memset(eventData, 0xff, SHA1_DIGEST_SIZE);\n\t}\n    }\n    /* SHA-1 */\n    if (rc == 0) {\n\trc = TSS_Hash_Generate(&pcrs[0][imaEvent->pcrIndex],\n\t\t\t       SHA1_DIGEST_SIZE,\n\t\t\t       (uint8_t *)&pcrs[0][imaEvent->pcrIndex].digest,\n\t\t\t       SHA1_DIGEST_SIZE,\n\t\t\t       eventData,\n\t\t\t       0, NULL);\n    }\n    /* SHA-256 */\n    if (rc == 0) {\n\trc = TSS_Hash_Generate(&pcrs[1][imaEvent->pcrIndex],\n\t\t\t       SHA256_DIGEST_SIZE,\n\t\t\t       (uint8_t *)&pcrs[1][imaEvent->pcrIndex].digest,\n\t\t\t       SHA256_DIGEST_SIZE,\n\t\t\t       eventData,\n\t\t\t       0, NULL);\n    }\n    return rc;\n}\n\n#if 0\n/* IMA_Event_ToString() converts the ImaEvent structure to a hexascii string, big endian. */\n\nuint32_t IMA_Event_ToString(char **eventString,\t/* freed by caller */\n\t\t\t    ImaEvent *imaEvent)\n{\n    int \trc = 0;\n    size_t\tlength;\n    \n    /* calculate size of string, from ImaEvent structure */\n    if (rc == 0) {\n\tlength = ((sizeof(uint32_t) + SHA1_DIGEST_SIZE + sizeof(uint32_t) +\n\t\t   TCG_EVENT_NAME_LEN_MAX + 1 + sizeof(uint32_t) +\n\t\t   imaEvent->template_data_len) * 2) + 1;\n    }\n    if (rc == 0) {\n\t*eventString = malloc(length);\n\tif (*eventString == NULL) {\n\t    printf(\"ERROR: IMA_Event_ToString: error allocating %lu bytes\\n\", length);\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tmemset(*eventString, '\\0', length);\n\tchar *p = *eventString;\n\n\tsprintf(p, \"%08lx\", (long unsigned int)imaEvent->pcrIndex);\n\tp += sizeof(uint32_t)* 2;\n\n\tArray_Print(p, NULL, imaEvent->digest, SHA1_DIGEST_SIZE);\n\tp += SHA1_DIGEST_SIZE * 2;\n\n\tsprintf(p, \"%08lx\", (long unsigned int)imaEvent->name_len);\n\tp += sizeof(uint32_t) * 2;\n\n\tArray_Print(p, NULL, FALSE, (uint8_t *)imaEvent->name, imaEvent->name_len);\n\tp += imaEvent->name_len * 2;\n\n\tsprintf(p, \"%08lx\", (long unsigned int)imaEvent->template_data_len);\n\tp += sizeof(uint32_t) * 2;\n\n\tArray_Print(p, NULL, FALSE, imaEvent->template_data, imaEvent->template_data_len);\n\tp += imaEvent->template_data_len * 2;\n\t/* printf(\"IMA_Event_ToString: result\\n:%s:\\n\", *eventString); */\n    }\n    return rc;\n}\n\n#endif\n\n"
  },
  {
    "path": "ibmtss-ftpm/import.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Import\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Import_In \t\t\tin;\n    Import_Out \t\t\tout;\n    TPMI_DH_OBJECT\t\tparentHandle = 0;\n    const char\t\t\t*parentPassword = NULL;\n    const char \t\t\t*encryptionKeyFilename = NULL;\n    const char\t\t\t*objectPublicFilename = NULL;\n    const char\t\t\t*duplicateFilename = NULL;\n    const char\t\t\t*inSymSeedFilename = NULL;\n    const char\t\t\t*outPrivateFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    /* Table 129 - Definition of TPMT_SYM_DEF_OBJECT Structure */\n    in.symmetricAlg.algorithm = TPM_ALG_NULL;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &parentHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ik\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tencryptionKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ik option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tobjectPublicFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-id\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tduplicateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-id option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-iss\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinSymSeedFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-iss option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-salg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"aes\") == 0) {\n\t\t    in.symmetricAlg.algorithm = TPM_ALG_AES;\n\t\t    in.symmetricAlg.keyBits.aes = 128;\n\t\t    in.symmetricAlg.mode.aes = TPM_ALG_CFB;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -salg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-salg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutPrivateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opr option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((in.symmetricAlg.algorithm == TPM_ALG_NULL) &&\n\t(encryptionKeyFilename != NULL)) {\n\tprintf(\"-ik needs -salg\\n\");\n\tprintUsage();\n    }\n    if ((in.symmetricAlg.algorithm != TPM_ALG_NULL) &&\n\t(encryptionKeyFilename == NULL)) {\n\tprintf(\"-salg needs -ik\\n\");\n\tprintUsage();\n    }\n    if (parentHandle == 0) {\n\tprintf(\"Missing or bad object handle parameter -hp\\n\");\n\tprintUsage();\n    }\n    if (objectPublicFilename == NULL) {\n\tprintf(\"Missing parameter -ipu\\n\");\n\tprintUsage();\n    }\n    if (duplicateFilename == NULL) {\n\tprintf(\"Missing parameter -id\\n\");\n\tprintUsage();\n    }\n    if (inSymSeedFilename == NULL) {\n\tprintf(\"Missing parameter -iss\\n\");\n\tprintUsage();\n    }\n    if (outPrivateFilename  == NULL) {\n\tprintf(\"Missing parameter -opr\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.parentHandle = parentHandle;\n    }\n    /* optional symmetric encryption key */\n    if (rc == 0) {\n\tif (encryptionKeyFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.encryptionKey.b,\n\t\t\t\t sizeof(in.encryptionKey.t.buffer),\n\t\t\t\t encryptionKeyFilename);\n\t}\n\telse {\n\t    in.encryptionKey.t.size = 0;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadStructureFlag(&in.objectPublic,\n\t\t\t\t\t(UnmarshalFunctionFlag_t)TSS_TPM2B_PUBLIC_Unmarshalu,\n\t\t\t\t\tFALSE,\t\t\t/* NULL not permitted */\n\t\t\t\t\tobjectPublicFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.duplicate.b,\n\t\t\t     sizeof(in.duplicate.t.buffer),\n\t\t\t     duplicateFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.inSymSeed.b,\n\t\t\t     sizeof(in.inSymSeed.t.secret),\n\t\t\t     inSymSeedFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Import,\n\t\t\t sessionHandle0, parentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_File_WriteStructure(&out.outPrivate,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PRIVATE_Marshalu,\n\t\t\t\t     outPrivateFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"import: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"import: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"import\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Import\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hp\\tparent handle\\n\");\n    printf(\"\\t[-pwdp\\tpassword for parent (default empty)]\\n\");\n    printf(\"\\t[-ik\\tencryption key in file name]\\n\");\n    printf(\"\\t-ipu\\tobject public area file name\\n\");\n    printf(\"\\t-id\\tduplicate file name\\n\");\n    printf(\"\\t-iss\\tsymmetric seed file name\\n\");\n    printf(\"\\t[-salg\\tsymmetric algorithm (default none)]\\n\");\n    printf(\"\\t-opr\\tprivate area file name\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/importpem.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Import a PEM keypair \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2016 - 2020\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* Use OpenSSL to create an RSA or ECC keypair like this\n\n   > openssl genrsa -out tmpprivkey.pem -aes256 -passout pass:rrrr 2048\n   > openssl ecparam -name prime256v1 -genkey -noout |\n\topenssl pkey -aes256 -passout pass:rrrr -text > tmpecprivkey.pem\n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n#include \"cryptoutils.h\"\n#include \"objecttemplates.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Import_In \t\t\tin;\n    Import_Out \t\t\tout;\n    TPMI_DH_OBJECT\t\tparentHandle = 0;\n    const char\t\t\t*parentPassword = NULL;\n    const char\t\t\t*pemKeyFilename = NULL;\n    const char\t\t\t*pemKeyPassword = \"\";\t/* default empty password */\n    int                         userWithAuth = TRUE;\n    const char\t\t\t*outPublicFilename = NULL;\n    const char\t\t\t*outPrivateFilename = NULL;\n    const char\t\t\t*policyFilename = NULL;\n    int\t\t\t\tkeyType = TYPE_SI;\n    uint32_t \t\t\tkeyTypeSpecified = 0;\n    TPMI_ALG_SIG_SCHEME \tscheme = TPM_ALG_RSASSA;\n    TPMI_ALG_PUBLIC \t\talgPublic = TPM_ALG_RSA;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_ALG_HASH\t\tnalg = TPM_ALG_SHA256;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    FILE \t\t\t*pemKeyFile = NULL;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &parentHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipem\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipem option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    algPublic = TPM_ALG_RSA;\n\t}\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    algPublic = TPM_ALG_ECC;\n\t    scheme = TPM_ALG_ECDSA;\n\t}\n\telse if (strcmp(argv[i],\"-scheme\") == 0) {\n\t    if (keyType == TYPE_SI) {\n\t\ti++;\n\t\tif (i < argc) {\n\t\t    if (strcmp(argv[i],\"rsassa\") == 0) {\n\t\t\tscheme = TPM_ALG_RSASSA;\n\t\t    }\n\t\t    else if (strcmp(argv[i],\"rsapss\") == 0) {\n\t\t\tscheme = TPM_ALG_RSAPSS;\n\t\t    }\n\t\t    else {\n\t\t\tprintf(\"Bad parameter %s for -scheme\\n\", argv[i]);\n\t\t\tprintUsage();\n\t\t    }\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-scheme can only be specified for signing key\\n\");\n\t\tprintUsage();\n\t    }\n        }\n\telse if (strcmp(argv[i], \"-st\") == 0) {\n\t    keyType = TYPE_ST;\n\t    scheme = TPM_ALG_NULL;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-den\") == 0) {\n\t    keyType = TYPE_DEN;\n\t    scheme = TPM_ALG_NULL;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-si\") == 0) {\n\t    keyType = TYPE_SI;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemKeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-uwa\") == 0) {\n            userWithAuth = FALSE;\n        }\n\telse if (strcmp(argv[i],\"-opu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutPublicFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutPrivateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opr option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pol\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pol option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    nalg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    nalg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    nalg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    nalg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -nalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-nalg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (parentHandle == 0) {\n\tprintf(\"Missing or bad object handle parameter -hp\\n\");\n\tprintUsage();\n    }\n    if (pemKeyFilename == NULL) {\n\tprintf(\"Missing parameter -ipem\\n\");\n\tprintUsage();\n    }\n    if (keyTypeSpecified > 1) {\n\tprintf(\"Too many key attributes\\n\");\n\tprintUsage();\n    }\n    if (outPublicFilename == NULL) {\n\tprintf(\"Missing parameter -opu\\n\");\n\tprintUsage();\n    }\n    if (outPrivateFilename == NULL) {\n\tprintf(\"Missing parameter -opr\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.parentHandle = parentHandle;\n\tin.encryptionKey.t.size = 0;\n\tin.inSymSeed.t.size = 0;\n\tin.symmetricAlg.algorithm = TPM_ALG_NULL;\n    }\n    if (rc == 0) {\n\tswitch (algPublic) {\n\t  case TPM_ALG_RSA:\n\t    rc = convertRsaPemToKeyPair(&in.objectPublic,\n\t\t\t\t\t&in.duplicate,\n\t\t\t\t\tkeyType,\n\t\t\t\t\tscheme,\n\t\t\t\t\tnalg,\n\t\t\t\t\thalg,\n\t\t\t\t\tpemKeyFilename,\n\t\t\t\t\tpemKeyPassword);\n\t    break;\n#ifndef TPM_TSS_NOECC\n\t  case TPM_ALG_ECC:\n\t    rc = convertEcPemToKeyPair(&in.objectPublic,\n\t\t\t\t       &in.duplicate,\n\t\t\t\t       keyType,\n\t\t\t\t       scheme,\n\t\t\t\t       nalg,\n\t\t\t\t       halg,\n\t\t\t\t       pemKeyFilename,\n\t\t\t\t       pemKeyPassword);\n\t    break;\n#endif\t/* TPM_TSS_NOECC */\n\t  default:\n\t    printf(\"algorithm %04x not supported\\n\", algPublic);\n\t    rc = TPM_RC_ASYMMETRIC;\n\t}\n    }\n    /* instantiate optional policy */\n    if (rc == 0) {\n\trc = getPolicy(&in.objectPublic.publicArea, policyFilename);\n        if (!userWithAuth) {\n            in.objectPublic.publicArea.objectAttributes.val &= ~TPMA_OBJECT_USERWITHAUTH;\n        }\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Import,\n\t\t\t sessionHandle0, parentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* output the TPM2B_PUBLIC */\n    if (rc == 0) {\n\trc = TSS_File_WriteStructure(&in.objectPublic,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PUBLIC_Marshalu,\n\t\t\t\t     outPublicFilename);\n    }\n    /* output the TPM2B_PRIVATE, which is now wrapped by the parent */\n    if (rc == 0) {\n\trc = TSS_File_WriteStructure(&out.outPrivate,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PRIVATE_Marshalu,\n\t\t\t\t     outPrivateFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"importpem: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"importpem: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    if (pemKeyFile != NULL) {\n\tfclose(pemKeyFile);\t\t\t/* @2 */\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"importpem\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Import for a PEM key\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hp\\tparent handle\\n\");\n    printf(\"\\t[-pwdp\\tpassword for parent (default empty)]\\n\");\n    printf(\"\\t-ipem\\tPEM format key pair\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[Asymmetric Key Algorithm]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-rsa\\t(default)]\\n\");\n    printf(\"\\t[-ecc\\t]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-si\\tsigning (default)]\\n\");\n    printf(\"\\t[-scheme  signing scheme (rsassa rsapss) (RSA default RSASSA) (ECC ECDSA)]\\n\");\n    printf(\"\\t[-st\\tstorage (NULL scheme)]\\n\");\n    printf(\"\\t[-den\\tdecryption, (unrestricted, RSA and ECC NULL scheme)\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-uwa\\tuserWithAuth attribute clear (default set)]\\n\");\n    printf(\"\\t-opu\\tpublic area file name\\n\");\n    printf(\"\\t-opr\\tprivate area file name\\n\");\n    printf(\"\\t[-nalg\\tname hash algorithm (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-halg\\tscheme hash algorithm (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-pol\\tpolicy file (default empty)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/load.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Load \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: load.c 1324 2018-08-31 16:36:12Z kgoldman $\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Load_In \t\t\tin;\n    Load_Out \t\t\tout;\n    TPMI_DH_OBJECT\t\tparentHandle = 0;\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*privateKeyFilename = NULL;\n    const char\t\t\t*parentPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &parentHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tprivateKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipr option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (parentHandle == 0) {\n\tprintf(\"Missing handle parameter -hp\\n\");\n\tprintUsage();\n    }\n    if (privateKeyFilename == NULL) {\n\tprintf(\"Missing private key parameter -ipr\\n\");\n\tprintUsage();\n    }\n    if (publicKeyFilename == NULL) {\n\tprintf(\"Missing private key parameter -ipu\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.inPrivate,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPM2B_PRIVATE_Unmarshalu,\n\t\t\t\t    privateKeyFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadStructureFlag(&in.inPublic,\n\t\t\t\t\t(UnmarshalFunctionFlag_t)TSS_TPM2B_PUBLIC_Unmarshalu,\n\t\t\t\t\tFALSE,\t\t\t/* NULL not permitted */\n\t\t\t\t\tpublicKeyFilename);\n    }\n    if (rc == 0) {\n\tin.parentHandle = parentHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Load,\n\t\t\t sessionHandle0, parentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"Handle %08x\\n\", out.objectHandle);\n\tif (tssUtilsVerbose) printf(\"load: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"load: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"load\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Load\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hp\\tparent handle\\n\");\n    printf(\"\\t[-pwdp\\tpassword for parent key (default empty)]\\n\");\n    printf(\"\\t-ipu\\tpublic key file name\\n\");\n    printf(\"\\t-ipr\\tprivate key file name\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/loadexternal.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Load External\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/*\n  DER example:\n\n  Create a key pair in PEM format\n\n  > openssl genrsa -out keypair.pem -aes256 -passout pass:rrrr 2048\n  > openssl ecparam -name prime256v1 -genkey -noout -out tmpkeypairecc.pem\n\n  Convert to plaintext DER format\n\n  > openssl rsa -inform pem -outform der -in keypair.pem -out keypair.der -passin pass:rrrr\n  > openssl ec -inform pem -outform der -in tmpkeypairecc.pem -out tmpkeypairecc.der -passin pass:rrrr > run.out\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n/* Windows 10 crypto API clashes with openssl */\n#ifdef TPM_WINDOWS\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include \"objecttemplates.h\"\n#include \"cryptoutils.h\"\n#include \"ekutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    LoadExternal_In \t\tin;\n    LoadExternal_Out \t\tout;\n    char \t\t\thierarchyChar = 0;\n    TPMI_RH_HIERARCHY\t\thierarchy = TPM_RH_NULL;\n    int\t\t\t\tkeyType = TYPE_SI;\n    TPMI_ALG_SIG_SCHEME \tscheme = TPM_ALG_ERROR;\t\t/* illegal value marker */\n    uint32_t \t\t\tkeyTypeSpecified = 0;\n    TPMI_ALG_PUBLIC \t\talgPublic = TPM_ALG_RSA;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_ALG_HASH\t\tnalg = TPM_ALG_SHA256;\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*derKeyFilename = NULL;\n    const char\t\t\t*pemKeyFilename = NULL;\n    const char\t\t\t*keyPassword = NULL;\n    int\t\t\t\tuserWithAuth = TRUE;\n    unsigned int\t\tinputCount = 0;\n    int\t\t\t\tnoSpace = FALSE;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (argv[i][0] != 'e' && argv[i][0] != 'o' &&\n\t\t    argv[i][0] != 'p' && argv[i][0] != 'n') {\n\t\t    printf(\"Illegal -hi parameter %c\\n\", argv[i][0]);\n\t\t    printUsage();\n\t\t}\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    nalg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    nalg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    nalg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    nalg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -nalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-nalg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    algPublic = TPM_ALG_RSA;\n\t}\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    algPublic = TPM_ALG_ECC;\n\t}\n\telse if (strcmp(argv[i],\"-scheme\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsassa\") == 0) {\n\t\t    scheme = TPM_ALG_RSASSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"rsapss\") == 0) {\n\t\t    scheme = TPM_ALG_RSAPSS;\n\t\t}\n\t\telse if (strcmp(argv[i],\"rsapkcs1\") == 0) {\n\t\t    scheme = TPM_ALG_RSAES;\n\t\t}\n\t\telse if (strcmp(argv[i],\"rsaoaep\") == 0) {\n\t\t    scheme = TPM_ALG_OAEP;\n\t\t}\n\t\telse if (strcmp(argv[i],\"null\") == 0) {\n\t\t    scheme = TPM_ALG_NULL;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -scheme\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-scheme option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n        }\n\telse if (strcmp(argv[i], \"-st\") == 0) {\n\t    keyType = TYPE_ST;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-den\") == 0) {\n\t    keyType = TYPE_DEN;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-si\") == 0) {\n\t    keyType = TYPE_SI;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i],\"-ipu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t\tinputCount++;\n\t    }\n\t    else {\n\t\tprintf(\"-ipu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipem\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemKeyFilename = argv[i];\n\t\tinputCount++;\n\t    }\n\t    else {\n\t\tprintf(\"-ipem option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ider\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tderKeyFilename = argv[i];\n\t\tinputCount++;\n\t    }\n\t    else {\n\t\tprintf(\"-ider option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-uwa\") == 0) {\n\t    userWithAuth = FALSE;\n\t}\n\telse if (strcmp(argv[i],\"-ns\") == 0) {\n\t    noSpace = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (inputCount != 1) {\n\tprintf(\"Missing or too many parameters -ipu, -ipem, -ider\\n\");\n\tprintUsage();\n    }\n    if (keyTypeSpecified > 1) {\n\tprintf(\"Too many key attributes\\n\");\n\tprintUsage();\n    }\n    if (derKeyFilename == NULL) {\n\tif (keyPassword != NULL) {\n\t    printf(\"Password only valid for -ider keypair\\n\");\n\t    printUsage();\n\t}\n    }\n    /* loadexternal key pair cannot be restricted (storage key) and must have NULL symmetric\n       scheme*/\n    if (derKeyFilename != NULL) {\n\tif (keyType == TYPE_ST) {\n\t    keyType = TYPE_DEN;\n\t}\n    }\n    /* set scheme defaults if scheme has not bee specified */\n    if (scheme == TPM_ALG_ERROR) {\n\tif (keyType == TYPE_DEN) {\n\t    scheme = TPM_ALG_NULL;\n\t}\n\telse if (keyType == TYPE_SI) {\n\t    scheme = TPM_ALG_RSASSA;\n\t}\n\telse if (keyType == TYPE_ST) {\n\t    scheme = TPM_ALG_NULL;\n\t}\n    }\n    /* check for valid scheme */\n    if (keyType == TYPE_SI) {\n\tif ((scheme != TPM_ALG_NULL) &&\n\t    (scheme != TPM_ALG_RSASSA) &&\n\t    (scheme != TPM_ALG_RSAPSS)) {\n\t    printf(\"Illegal scheme %04x for signing key\\n\", scheme);\n\t    printUsage();\n\t}\n    }\n    if (keyType == TYPE_DEN) {\n\tif ((scheme != TPM_ALG_NULL) &&\n\t    (scheme != TPM_ALG_RSAES) &&\n\t    (scheme != TPM_ALG_OAEP)) {\n\t    printf(\"Illegal scheme %04x for decryption key\\n\", scheme);\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (hierarchyChar == 'e') {\n\t    hierarchy = TPM_RH_ENDORSEMENT;\n\t}\n\telse if (hierarchyChar == 'o') {\n\t    hierarchy = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    hierarchy = TPM_RH_PLATFORM;\n\t}\n\telse if (hierarchyChar == 'n') {\n\t    hierarchy = TPM_RH_NULL;\n\t}\n    }\n    if (rc == 0) {\n\tin.inPrivate.t.size = 0;\t/* default - mark optional inPrivate not used */\n\t/* TPM format key, output from create */\n\tif (publicKeyFilename != NULL) {\n\t    rc = TSS_File_ReadStructureFlag(&in.inPublic,\n\t\t\t\t\t    (UnmarshalFunctionFlag_t)TSS_TPM2B_PUBLIC_Unmarshalu,\n\t\t\t\t\t    TRUE,\t\t\t/* NULL permitted */\n\t\t\t\t\t    publicKeyFilename);\n\t}\n\t/* PEM format, output from e.g. openssl, readpublic, createprimary, create */\n\telse if (pemKeyFilename != NULL) {\n\t    switch (algPublic) {\n\t      case TPM_ALG_RSA:\n\t\trc = convertRsaPemToPublic(&in.inPublic,\n\t\t\t\t\t   keyType,\n\t\t\t\t\t   scheme,\n\t\t\t\t\t   nalg,\n\t\t\t\t\t   halg,\n\t\t\t\t\t   pemKeyFilename);\n\t\tbreak;\n#ifndef TPM_TSS_NOECC\n\t      case TPM_ALG_ECC:\n\t\trc = convertEcPemToPublic(&in.inPublic,\n\t\t\t\t\t  keyType,\n\t\t\t\t\t  scheme,\n\t\t\t\t\t  nalg,\n\t\t\t\t\t  halg,\n\t\t\t\t\t  pemKeyFilename);\n\t\tbreak;\n#endif\t/* TPM_TSS_NOECC */\n\t      default:\n\t\tprintf(\"algorithm %04x not supported\\n\", algPublic);\n\t\trc = TPM_RC_ASYMMETRIC;\n\t    }\n\t}\n\t/* DER format key pair */\n\telse if (derKeyFilename != NULL) {\n\t    in.inPrivate.t.size = 1;\t\t/* mark that private area should be loaded */\n\t    switch (algPublic) {\n\t      case TPM_ALG_RSA:\n\t\trc = convertRsaDerToKeyPair(&in.inPublic,\n\t\t\t\t\t    &in.inPrivate,\n\t\t\t\t\t    keyType,\n\t\t\t\t\t    scheme,\n\t\t\t\t\t    nalg,\n\t\t\t\t\t    halg,\n\t\t\t\t\t    derKeyFilename,\n\t\t\t\t\t    keyPassword);\n\t\tbreak;\n#ifndef TPM_TSS_NOECC\n\t      case TPM_ALG_ECC:\n\t\trc = convertEcDerToKeyPair(&in.inPublic,\n\t\t\t\t\t   &in.inPrivate,\n\t\t\t\t\t   keyType,\n\t\t\t\t\t   scheme,\n\t\t\t\t\t   nalg,\n\t\t\t\t\t   halg,\n\t\t\t\t\t   derKeyFilename,\n\t\t\t\t\t   keyPassword);\n\t\tbreak;\n#endif\t/* TPM_TSS_NOECC */\n\t      default:\n\t\tprintf(\"algorithm %04x not supported\\n\", algPublic);\n\t\trc = TPM_RC_ASYMMETRIC;\n\t    }\n\t}\n\telse {\n\t    printf(\"Failure parsing -ipu, -ipem, -ider\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tif (!userWithAuth) {\n\t    in.inPublic.publicArea.objectAttributes.val &= ~TPMA_OBJECT_USERWITHAUTH;\n\t}\n\tin.hierarchy = hierarchy;\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMT_PUBLIC_Print(&in.inPublic.publicArea, 0);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_LoadExternal,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"Handle %08x\\n\", out.objectHandle);\n\tif (noSpace) {\n\t    unsigned int b;\n\t    for (b = 0 ; b < out.name.t.size ; b++) {\n\t\tprintf(\"%02x\", out.name.t.name[b]);\n\t    }\n\t    printf(\"\\n\");\n\t}\n\tif (tssUtilsVerbose) printf(\"loadexternal: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"loadexternal: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"loadexternal\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_LoadExternal\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hi\\thierarchy (e, o, p, n) (default NULL)]\\n\");\n    printf(\"\\t[-nalg\\tname hash algorithm (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-halg\\tscheme hash algorithm (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[Asymmetric Key Algorithm]\\n\");\n    printf(\"\\t\\t[-rsa\\t(default)]\\n\");\n    printf(\"\\t\\t[-ecc\\t]\\n\");\n    printf(\"\\tInput\\n\");\n    printf(\"\\t\\t-ipu\\tTPM2B_PUBLIC public key file name\\n\");\n    printf(\"\\t\\t-ipem\\tPEM format public key file name\\n\");\n    printf(\"\\t\\t-ider\\tDER format plaintext key pair file name\\n\");\n    printf(\"\\t[-pwdk\\tpassword for DER key (default empty)]\\n\");\n    printf(\"\\t[-uwa\\tuserWithAuth attribute clear (default set)]\\n\");\n    printf(\"\\t[Key Type]\\n\");\n    printf(\"\\t\\t[-si\\tsigning (default)\\n\");\n    printf(\"\\t\\t[-st\\tdecryption]\\n\");\n    printf(\"\\t\\t[-den\\tdecryption]\\n\");\n    printf(\"\\t[-scheme]\\n\");\n    printf(\"\\t\\trsassa\\tdefault for a signing key\\n\");\n    printf(\"\\t\\trsapss\\tvalid for a signing key\\n\");\n    printf(\"\\t\\trsapkcs1\\tvalid for a decryption key\\n\");\n    printf(\"\\t\\trsaoaep\\tvalid for a decryption key\\n\");\n    printf(\"\\t\\tnull\\tdefault for decryption key, valid for any key\\n\");\n\n    printf(\"\\t[-ns\\tadditionally print Name in hex ascii on one line]\\n\");\n    printf(\"\\t\\tUseful to paste into policy\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\t80\\taudit\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/makecredential.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    MakeCredential\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    MakeCredential_In \t\tin;\n    MakeCredential_Out \t\tout;\n    TPMI_DH_OBJECT\t\tpubHandle = 0;\n    const char\t\t\t*inputCredentialFilename = NULL;\n    const char\t\t\t*nameFilename = NULL;\t\t\t\n    const char\t\t\t*outputCredentialFilename = NULL;\n    const char\t\t\t*secretFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-in\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnameFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-in option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-icred\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinputCredentialFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-icred option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ocred\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutputCredentialFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ocred option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsecretFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &pubHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (pubHandle == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (inputCredentialFilename == NULL) {\n\tprintf(\"Missing name parameter -icred\\n\");\n\tprintUsage();\n    }\n    if (nameFilename == NULL) {\n\tprintf(\"Missing name parameter -in\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.handle = pubHandle;\n    }\n    /* read the credential information */\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.credential.b,\n\t\t\t     sizeof(in.credential.t.buffer),\n\t\t\t     inputCredentialFilename);\n    }\n    /* read the object Name */\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.objectName.b,\n\t\t\t     sizeof(in.objectName.t.name),\n\t\t\t     nameFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_MakeCredential,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* optionally save the credential */\n    if ((rc == 0) && (outputCredentialFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.credentialBlob,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_ID_OBJECT_Marshalu,\n\t\t\t\t     outputCredentialFilename);\n    }\n    /* optionally save the secret */\n    if ((rc == 0) && (secretFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.secret,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_ENCRYPTED_SECRET_Marshalu,\n\t\t\t\t     secretFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"makecredential: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"makecredential: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"makecredential\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_MakeCredential\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\thandle of encryption key public area\\n\");\n    printf(\"\\t-icred\\tinput credential file name\\n\");\n    printf(\"\\t-in\\tobject name file name\\n\");\n    printf(\"\\t[-ocred\\t output credential file name (default do not save)]\\n\");\n    printf(\"\\t[-os\\tsecret file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/makefile-common",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# TPM2 Library and Utilities makefile - Common to TPM 1.2 and 2.0 variations\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t      $Id: makefile-common 1294 2018-08-09 19:08:34Z kgoldman $\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2014, 2018\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n# compile - common flags for TSS library and applications\n\nCCFLAGS += \t\t\t\t\\\n\t-Wall -W -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \\\n\t-Wformat=2 -Wold-style-definition -Wno-self-assign \\\n\t-Werror=declaration-after-statement -Wvla \\\n\t-ggdb -O0 -c \n\n# to compile with optimizations on (warning will result)\n#\t-O3 -c\n# to compile with plaintext session state (see documentation)\n#\t-DTPM_ENCRYPT_SESSIONS_DEFAULT=\"\\\"0\\\"\"\n\n# link - common flags for Posix and Windows, for TSS library and applications\n\n#LNFLAGS += \t-ggdb\n\nALL += \t$(LIBTSS)\t\t\t\t\\\n\t$(LIBTSSA)\t\t\t\t\\\n\t$(LIBTSSUTILS)\n\n# TSS shared library headers \n\nTSS_HEADERS += \t\t\t\t\t\\\n\t\ttssauth.h \t\t\t\\\n\t\ttssccattributes.h \t\t\\\n\t\ttssdev.h  \t\t\t\\\n\t\ttsssocket.h  \t\t\t\\\n\t\tibmtss/tss.h\t\t\t\\\n\t\tibmtss/tsscryptoh.h\t\t\\\n\t\tibmtss/tsscrypto.h\t\t\\\n\t\tibmtss/tsserror.h\t\t\\\n\t\tibmtss/tssfile.h\t\t\\\n\t\tibmtss/tssmarshal.h\t\t\\\n\t\tibmtss/tssprint.h\t\t\\\n\t\tibmtss/tssprintcmd.h\t\t\\\n\t\ttssproperties.h\t\t\t\\\n\t\tibmtss/tsstransmit.h\t\t\\\n\t\tibmtss/tssresponsecode.h\t\\\n\t\tibmtss/tssutils.h\t\t\\\n\t\tibmtss/Unmarshal_fp.h\t\t\\\n\t\tibmtss/Implementation.h\n\n# TSS shared library object files\n\nTSS_OBJS += \ttss.o\t\t\t\\\n\t\ttssproperties.o\t\t\\\n\t\ttssmarshal.o\t\t\\\n\t\ttssauth.o \t\t\\\n\t\ttssutils.o \t\t\\\n\t\ttsssocket.o \t\t\\\n\t\ttssdev.o \t\t\\\n\t\ttsstransmit.o \t\t\\\n\t\ttssftpm.o \t\t\\\n\t\ttssresponsecode.o \t\\\n\t\ttssccattributes.o\t\\\n\t\ttssprint.o\t\t\\\n\t\tUnmarshal.o \t\t\\\n\t\tCommandAttributeData.o\n"
  },
  {
    "path": "ibmtss-ftpm/makefile-common12",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#\tTPM2 Library and Utilities makefile - Common to all variations\t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t      $Id: makefile-common12 1257 2018-06-27 20:52:08Z kgoldman $\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2014, 2018\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n# link - common flags for Posix and Windows, for TSS library and applications\n\n#LNFLAGS += \t-ggdb\n\nALL += \t\n\n# TSS shared library headers \n\nTSS_HEADERS +=\t\t\t\t\\\n\t\ttss12.h  \t\t\\\n\t\ttssauth12.h\t\t\\\n\t\ttssccattributes12.h\t\\\n\t\tibmtss/tssmarshal12.h\t\\\n\t\tibmtss/Unmarshal12_fp.h\t\\\n\t\tibmtss/Parameters12.h\t\\\n\t\tibmtss/tpmstructures12.h\t\\\n\t\tibmtss/tpmconstants12.h\t\\\n\t\tibmtss/tpmtypes12.h\n\n# TSS shared library object files\n\nTSS_OBJS +=\ttss12.o\t\t\t\\\n\t\ttssauth12.o\t\t\\\n\t\ttssmarshal12.o\t\t\\\n\t\tUnmarshal12.o \t\t\\\n\t\tCommands12.o \t\t\\\n\t\ttssccattributes12.o\t\\\n\t\tCommandAttributeData12.o\n\n"
  },
  {
    "path": "ibmtss-ftpm/makefile-common20",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#\tTPM 2.0 Library and Utilities makefile - Common to all variations\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2014 - 2024\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\nCCFLAGS += \t-DTPM_TSS_NUVOTON\n\n# link - common flags for Posix and Windows, for TSS library and applications\n\n#LNFLAGS += \t-ggdb\n\nALL += \tactivatecredential$(EXE)\t\t\\\n\teventextend$(EXE)\t\t\t\\\n\timaextend$(EXE)\t\t\t\t\\\n\tcertify$(EXE)\t\t\t\t\\\n\tcertifycreation$(EXE)\t\t\t\\\n\tcertifyx509$(EXE)\t\t\t\\\n\tchangeeps$(EXE)\t\t\t\t\\\n\tchangepps$(EXE)\t\t\t\t\\\n\tclear$(EXE)\t\t\t\t\\\n\tclearcontrol$(EXE)\t\t\t\\\n\tclockrateadjust$(EXE)\t\t\t\\\n\tclockset$(EXE)\t\t\t\t\\\n\tcommit$(EXE)\t\t\t\t\\\n\tcontextload$(EXE)\t\t\t\\\n\tcontextsave$(EXE)\t\t\t\\\n\tcreate$(EXE)\t\t\t\t\\\n\tcreateloaded$(EXE)\t\t\t\\\n\tcreateprimary$(EXE)\t\t\t\\\n\tdictionaryattacklockreset$(EXE) \t\\\n\tdictionaryattackparameters$(EXE) \t\\\n\tduplicate$(EXE)\t\t\t\t\\\n\teccencrypt$(EXE)\t\t\t\\\n\teccdecrypt$(EXE)\t\t\t\\\n\teccparameters$(EXE)\t\t\t\\\n\tecephemeral$(EXE)\t\t\t\\\n\tencryptdecrypt$(EXE)\t\t\t\\\n\tevictcontrol$(EXE)\t\t\t\\\n\teventsequencecomplete$(EXE)\t\t\\\n\tflushcontext$(EXE)\t\t\t\\\n\tgetcommandauditdigest$(EXE)\t\t\\\n\tgetcapability$(EXE)\t\t\t\\\n\tgetrandom$(EXE)\t\t\t\t\\\n\tgettestresult$(EXE)\t\t\t\\\n\tgetsessionauditdigest$(EXE)\t\t\\\n\tgettime$(EXE)\t\t\t\t\\\n\thash$(EXE)\t\t\t\t\\\n\thashsequencestart$(EXE) \t\t\\\n\thierarchycontrol$(EXE) \t\t\t\\\n\thierarchychangeauth$(EXE) \t\t\\\n\thmac$(EXE)\t\t\t\t\\\n\thmacstart$(EXE)\t\t\t\t\\\n\timport$(EXE)\t\t\t\t\\\n\timportpem$(EXE)\t\t\t\t\\\n\tload$(EXE)\t\t\t\t\\\n\tloadexternal$(EXE)\t\t\t\\\n\tmakecredential$(EXE)\t\t\t\\\n\tnvcertify$(EXE)\t\t\t\t\\\n\tnvchangeauth$(EXE)\t\t\t\\\n\tnvdefinespace$(EXE)\t\t\t\\\n\tnvextend$(EXE) \t\t\t\t\\\n\tnvglobalwritelock$(EXE)\t\t\t\\\n\tnvincrement$(EXE) \t\t\t\\\n\tnvread$(EXE)\t\t\t\t\\\n\tnvreadlock$(EXE)\t\t\t\\\n\tnvreadpublic$(EXE)\t\t\t\\\n\tnvsetbits$(EXE)\t\t\t\t\\\n\tnvundefinespace$(EXE)\t\t\t\\\n\tnvundefinespacespecial$(EXE)\t\t\\\n\tnvwrite$(EXE)\t\t\t\t\\\n\tnvwritelock$(EXE)\t\t\t\\\n\tobjectchangeauth$(EXE) \t\t\t\\\n\tpcrallocate$(EXE)\t\t\t\\\n\tpcrevent$(EXE)\t\t\t\t\\\n\tpcrextend$(EXE)\t\t\t\t\\\n\tpcrread$(EXE)\t\t\t\t\\\n\tpcrreset$(EXE)\t\t\t\t\\\n\tpolicyauthorize$(EXE)\t\t\t\\\n\tpolicyauthvalue$(EXE)\t\t\t\\\n\tpolicycommandcode$(EXE) \t\t\\\n\tpolicycphash$(EXE)\t \t\t\\\n\tpolicynamehash$(EXE)\t \t\t\\\n\tpolicycapability$(EXE)\t \t\t\\\n\tpolicycountertimer$(EXE)\t\t\\\n\tpolicyduplicationselect$(EXE)\t\t\\\n\tpolicygetdigest$(EXE)\t\t\t\\\n\tpolicymaker$(EXE)\t\t\t\\\n\tpolicymakerpcr$(EXE)\t\t\t\\\n\tpolicynv$(EXE)\t\t\t\t\\\n\tpolicyauthorizenv$(EXE)\t\t\t\\\n\tpolicynvwritten$(EXE)\t\t\t\\\n\tpolicypassword$(EXE)\t\t\t\\\n\tpolicyparameters$(EXE)\t \t\t\\\n\tpolicypcr$(EXE)\t\t\t\t\\\n\tpolicyor$(EXE)\t\t\t\t\\\n\tpolicyrestart$(EXE)\t\t\t\\\n\tpolicysigned$(EXE)\t\t\t\\\n\tpolicysecret$(EXE)\t\t\t\\\n\tpolicytemplate$(EXE)\t\t\t\\\n\tpolicyticket$(EXE)\t\t\t\\\n\tpowerup$(EXE)\t\t\t\t\\\n\tquote$(EXE)\t\t\t\t\\\n\treadclock$(EXE)\t\t\t\t\\\n\treadpublic$(EXE)\t\t\t\\\n\treturncode$(EXE)\t\t\t\\\n\trewrap$(EXE)\t\t\t\t\\\n\trsadecrypt$(EXE)\t\t\t\\\n\trsaencrypt$(EXE)\t\t\t\\\n\tsequencecomplete$(EXE)\t\t\t\\\n\tsequenceupdate$(EXE)\t\t\t\\\n\tsetcommandcodeauditstatus$(EXE)\t\t\\\n\tsetprimarypolicy$(EXE) \t\t\t\\\n\tshutdown$(EXE) \t\t\t\t\\\n\tsign$(EXE)\t\t\t\t\\\n\tstartauthsession$(EXE)\t\t\t\\\n\tstartup$(EXE) \t\t\t\t\\\n\tstirrandom$(EXE)\t\t\t\\\n\tunseal$(EXE)\t\t\t\t\\\n\tverifysignature$(EXE)\t\t\t\\\n\tzgen2phase$(EXE)\t\t\t\\\n\t\t\t\t\t\t\\\n\tsignapp$(EXE)\t\t\t\t\\\n\twriteapp$(EXE)\t\t\t\t\\\n\ttimepacket$(EXE)\t\t\t\\\n\tcreateek$(EXE)\t\t\t\t\\\n\tcreateekcert$(EXE)\t\t\t\\\n\ttpm2pem$(EXE)\t\t\t\t\\\n\ttpmpublic2eccpoint$(EXE)\t\t\\\n\tpublicname$(EXE)\t\t\t\\\n\tgetcryptolibrary$(EXE)\t\t\t\\\n\tprintattr$(EXE)\t\t\t\t\\\n\ttpmcmd$(EXE)\n\nALL\t+= \t\t\t\t\t\\\n\tntc2getconfig$(EXE)\t\t\t\\\n\tntc2preconfig$(EXE)\t\t\t\\\n\tntc2lockconfig$(EXE)\n\n# TSS shared library headers \n\nTSS_HEADERS +=\t\t\t\t\\\n\t\ttss20.h  \t\t\\\n\t\ttssauth20.h\n\n# TSS shared library object files\n\nTSS_OBJS +=\ttss20.o\t\t\\\n\t\ttssauth20.o\t\\\n\t\tCommands.o \t\\\n\t\tntc2lib.o\t\\\n\t\ttssntc.o\n"
  },
  {
    "path": "ibmtss-ftpm/makefile.mac",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\t\tMac TPM2 Utilities Makefile\t\t\t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2017 - 2024\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n# C compiler\n\nCC = /usr/bin/gcc\n\n# compile - common flags for TSS library and applications\n\nCCFLAGS += \t-DTPM_POSIX \n\n# example of pointing to a locally built openssl 1.1\n# CCFLAGS += \t-I/home/kgold/openssl-1.1.0c/include\n\n# compile - for TSS library\n\n# include the hardening flag PIC needed for compiling for dynamic\n# linking\n\nCCLFLAGS += \t-I. \t\t\\\n\t\t-fPIC\t\t\\\n\t\t-DTPM_TPM20\t\\\n\t\t-I/usr/local/Cellar/openssl/1.0.2m/include/\n\n# to compile out printf's.  Regression test will fail because it tries\n# to print a structure -DTPM_TSS_NO_PRINT\n\n# example of changing the default interface type\n#\t-DTPM_INTERFACE_TYPE_DEFAULT=\"\\\"dev\\\"\"\n\n# compile - for applications\n\n# include the hardening flag PIE needed for compiling for\n# static linking\n\nCCAFLAGS += \t-I.\t\\\n\t\t-DTPM_TPM20\t\\\n\t\t-fPIE\t\\\n\t\t-I/usr/local/Cellar/openssl/1.0.2m/include/\n\n# link - common flags flags TSS library and applications\n\nLNFLAGS += \t-DTPM_POSIX\t\t\\\n\t\t-L.\n\n# This seems to be required on some Ubuntu distros due to an issue with the gold linker\n#\t\t-fuse-ld=bfd\n\n# example of pointing to a locally built openssl 1.1\n# LNFLAGS +=\t -L/home/kgold/openssl-1.1.0c\n# This also requires setting the environment variable LD_LIBRARY_PATH.  E.g.,\n# setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/kgold/openssl-1.1.0c\n\n# link - for TSS library\n\n# hardening flags for linking shared objects\n#LNLFLAGS += -shared -Wl,-z,now\nLNLFLAGS += -shared \n\n# This is an alternative to using the bfd linker on Ubuntu\nLNLLIBS += -lcrypto\n\n# link - for applications, TSS path, TSS and OpenSSl libraries\n\n# hardening flags for linking executables\n#LNAFLAGS += -pie -Wl,-z,now -Wl,-rpath,.\n#LNAFLAGS += \t-pie\t \nLNAFLAGS +=\t\t-L/usr/local/Cellar/openssl/1.0.2m/lib\nLNLFLAGS +=\t\t-L/usr/local/Cellar/openssl/1.0.2m/lib\nLNALIBS +=  -libmtss -lcrypto\n\n# shared library\n\n# versioned shared library\nLIBTSSVERSIONED=libibmtss.dylib.2.1\n\n# soname field of the shared library\n# which will be made symbolic link to the versioned shared library\n# this is used to provide version backward-compatibility information\nLIBTSSSONAME=libibmtss.dylib.2\n\n# symbolic link to the versioned shared library\n# this allows linking to the shared library with '-libmtss' \n\n#os := $(shell uname -o)\n#ifeq ($(os),Cygwin)\n#  LIBTSS=libibmtss.dll\n#else\n#  LIBTSS=libibmtss.so\n#endif\nLIBTSS=libibmtss.dylib\n\n# executable extension\n\nEXE =\n\n# \n\nTSS_HEADERS=\n\n# default TSS library\n\nTSS_OBJS = \ttssfile.o \t\t\\\n\t\ttsscryptoh.o \t\t\\\n\t\ttsscrypto.o \t\t\\\n\t\ttssprintcmd.o\n\n# common to all builds\n\ninclude makefile-common\ninclude makefile-common20\n\n# default build target\n\nall:\t$(ALL)\n\n# TSS shared library source\n\ntss.o: \t\t$(TSS_HEADERS) tss.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss.c\ntssproperties.o: $(TSS_HEADERS) tssproperties.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssproperties.c\ntssauth.o: \t$(TSS_HEADERS) tssauth.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth.c\ntssmarshal.o: \t$(TSS_HEADERS) tssmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssmarshal.c\ntsscryptoh.o: \t$(TSS_HEADERS) tsscryptoh.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscryptoh.c\ntsscrypto.o: \t$(TSS_HEADERS) tsscrypto.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscrypto.c\ntssutils.o: \t$(TSS_HEADERS) tssutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssutils.c\ntssfile.o: \t$(TSS_HEADERS) tssfile.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssfile.c\ntsssocket.o: \t$(TSS_HEADERS) tsssocket.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsssocket.c\ntssdev.o: \t$(TSS_HEADERS) tssdev.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssdev.c\ntsstransmit.o: \t$(TSS_HEADERS) tsstransmit.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsstransmit.c\ntssresponsecode.o: $(TSS_HEADERS) tssresponsecode.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssresponsecode.c\ntssccattributes.o: $(TSS_HEADERS) tssccattributes.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssccattributes.c\ntssprint.o: \t$(TSS_HEADERS) tssprint.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprint.c\nUnmarshal.o: \t$(TSS_HEADERS) Unmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Unmarshal.c\nCommands.o: \t$(TSS_HEADERS) Commands.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Commands.c\nCommandAttributeData.o: \t$(TSS_HEADERS) CommandAttributeData.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) CommandAttributeData.c\nntc2lib.o:\t$(TSS_HEADERS) ntc2lib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ntc2lib.c\ntssntc.o:\t$(TSS_HEADERS) tssntc.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssntc.c\n\n# TSS shared library build\n\n$(LIBTSS): \t$(TSS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -Wl,-install_name,$(LIBTSSSONAME) -o $(LIBTSSVERSIONED) $(TSS_OBJS) $(LNLLIBS)\n\t\trm -f $(LIBTSSSONAME)\n\t\tln -sf $(LIBTSSVERSIONED) $(LIBTSSSONAME)\n\t\trm -f $(LIBTSS)\n\t\tln -sf $(LIBTSSSONAME) $(LIBTSS)\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\nclean:\t\t\n\t\trm -f *.o  *~ \t\\\n\t\th*.bin\t\t\\\n\t\t$(LIBTSSSONAME)\t\\\n\t\t$(LIBTSSVERSIONED) \\\n\t\t$(ALL)\n\n# applications\n\nactivatecredential:\tibmtss/tss.h activatecredential.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) activatecredential.o $(LNALIBS) -o activatecredential\neventextend:\t\teventextend.o eventlib.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eventextend.o $(LNALIBS) -o eventextend\nimaextend:\t\timaextend.o imalib.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) imaextend.o $(LNALIBS) -o imaextend\ncertify:\t\tibmtss/tss.h certify.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) certify.o $(LNALIBS) -o certify\ncertifycreation:\tibmtss/tss.h certifycreation.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) certifycreation.o $(LNALIBS) -o certifycreation\ncertifyx509:\t\tibmtss/tss.h certifyx509.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) certifyx509.o $(LNALIBS) -o certifyx509\nchangeeps:\t\tibmtss/tss.h changeeps.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) changeeps.o $(LNALIBS) -o changeeps\nchangepps:\t\tibmtss/tss.h changepps.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) changepps.o $(LNALIBS) -o changepps\nclear:\t\t\tibmtss/tss.h clear.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clear.o $(LNALIBS) -o clear\nclearcontrol:\t\tibmtss/tss.h clearcontrol.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clearcontrol.o $(LNALIBS) -o clearcontrol\nclockrateadjust:\tibmtss/tss.h clockrateadjust.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clockrateadjust.o $(LNALIBS) -o clockrateadjust\nclockset:\t\tibmtss/tss.h clockset.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clockset.o $(LNALIBS) -o clockset\ncommit:\t\t\tibmtss/tss.h commit.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) commit.o $(LNALIBS) -o commit\ncontextload:\t\tibmtss/tss.h contextload.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) contextload.o $(LNALIBS) -o contextload\ncontextsave:\t\tibmtss/tss.h contextsave.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) contextsave.o $(LNALIBS) -o contextsave\ncreate:\t\t\tibmtss/tss.h create.o objecttemplates.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) create.o objecttemplates.o cryptoutils.o $(LNALIBS) -o create\ncreateloaded:\t\tibmtss/tss.h createloaded.o objecttemplates.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createloaded.o objecttemplates.o cryptoutils.o $(LNALIBS) -o createloaded\ncreateprimary:\t\tibmtss/tss.h createprimary.o objecttemplates.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createprimary.o objecttemplates.o cryptoutils.o $(LNALIBS) -o createprimary\ndictionaryattacklockreset:\t\tibmtss/tss.h dictionaryattacklockreset.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) dictionaryattacklockreset.o $(LNALIBS) -o dictionaryattacklockreset\ndictionaryattackparameters:\t\tibmtss/tss.h dictionaryattackparameters.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) dictionaryattackparameters.o $(LNALIBS) -o dictionaryattackparameters\nduplicate:\t\tibmtss/tss.h duplicate.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) duplicate.o $(LNALIBS) -o duplicate \neccparameters:\t\tibmtss/tss.h eccparameters.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eccparameters.o $(LNALIBS) -o eccparameters \necephemeral:\t\tibmtss/tss.h ecephemeral.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ecephemeral.o $(LNALIBS) -o ecephemeral \nencryptdecrypt:\t\tibmtss/tss.h encryptdecrypt.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) encryptdecrypt.o $(LNALIBS) -o encryptdecrypt\t\neventsequencecomplete:\tibmtss/tss.h eventsequencecomplete.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eventsequencecomplete.o $(LNALIBS) -o eventsequencecomplete\t\nevictcontrol:\t\tibmtss/tss.h evictcontrol.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) evictcontrol.o $(LNALIBS) -o evictcontrol\t\nflushcontext:\t\tibmtss/tss.h flushcontext.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) flushcontext.o $(LNALIBS) -o flushcontext\ngetcommandauditdigest:\tibmtss/tss.h getcommandauditdigest.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getcommandauditdigest.o $(LNALIBS) -o getcommandauditdigest\ngetcapability:\t\tibmtss/tss.h getcapability.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getcapability.o $(LNALIBS) -o getcapability\ngetrandom:\t\tibmtss/tss.h getrandom.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getrandom.o $(LNALIBS) -o getrandom\ngettestresult:\t\tibmtss/tss.h gettestresult.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) gettestresult.o $(LNALIBS) -o gettestresult\ngetsessionauditdigest:\tibmtss/tss.h getsessionauditdigest.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getsessionauditdigest.o $(LNALIBS) -o getsessionauditdigest\ngettime:\t\tibmtss/tss.h gettime.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) gettime.o $(LNALIBS) -o gettime\nhashsequencestart:\tibmtss/tss.h hashsequencestart.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hashsequencestart.o $(LNALIBS) -o hashsequencestart\nhash:\t\t\tibmtss/tss.h hash.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hash.o $(LNALIBS) -o hash\nhierarchycontrol:\tibmtss/tss.h hierarchycontrol.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hierarchycontrol.o $(LNALIBS) -o hierarchycontrol\nhierarchychangeauth:\tibmtss/tss.h hierarchychangeauth.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hierarchychangeauth.o $(LNALIBS) -o hierarchychangeauth\nhmac:\t\t\tibmtss/tss.h hmac.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hmac.o $(LNALIBS) -o hmac\nhmacstart:\t\tibmtss/tss.h hmacstart.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hmacstart.o $(LNALIBS) -o hmacstart\nimport:\t\t\tibmtss/tss.h import.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) import.o $(LNALIBS) -o import\nimportpem:\t\tibmtss/tss.h importpem.o objecttemplates.o ekutils.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) importpem.o objecttemplates.o ekutils.o cryptoutils.o $(LNALIBS) -o importpem\nload:\t\t\tibmtss/tss.h load.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) load.o $(LNALIBS) -o load\nloadexternal:\t\tibmtss/tss.h loadexternal.o cryptoutils.o ekutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) loadexternal.o cryptoutils.o ekutils.o $(LNALIBS) -o loadexternal\nmakecredential:\t\tibmtss/tss.h makecredential.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) makecredential.o $(LNALIBS) -o makecredential\nnvcertify:\t\tibmtss/tss.h nvcertify.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvcertify.o $(LNALIBS) -o nvcertify\nnvchangeauth:\t\tibmtss/tss.h nvchangeauth.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvchangeauth.o $(LNALIBS) -o nvchangeauth\nnvdefinespace:\t\tibmtss/tss.h nvdefinespace.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvdefinespace.o $(LNALIBS) -o nvdefinespace\nnvextend:\t\tibmtss/tss.h nvextend.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvextend.o $(LNALIBS) -o nvextend\nnvglobalwritelock:\tibmtss/tss.h nvglobalwritelock.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvglobalwritelock.o $(LNALIBS) -o nvglobalwritelock\nnvincrement:\t\tibmtss/tss.h nvincrement.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvincrement.o $(LNALIBS) -o nvincrement\nnvread:\t\t\tibmtss/tss.h nvread.o cryptoutils.o ekutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvread.o cryptoutils.o ekutils.o $(LNALIBS) -o nvread\nnvreadlock:\t\tibmtss/tss.h nvreadlock.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvreadlock.o $(LNALIBS) -o nvreadlock\nnvreadpublic:\t\tibmtss/tss.h nvreadpublic.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvreadpublic.o $(LNALIBS) -o nvreadpublic\nnvsetbits:\t\tibmtss/tss.h nvsetbits.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvsetbits.o $(LNALIBS) -o nvsetbits\nnvundefinespace:\tibmtss/tss.h nvundefinespace.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvundefinespace.o $(LNALIBS) -o nvundefinespace\nnvundefinespacespecial:\tibmtss/tss.h nvundefinespacespecial.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvundefinespacespecial.o $(LNALIBS) -o nvundefinespacespecial\nnvwrite:\t\tibmtss/tss.h nvwrite.o cryptoutils.o ekutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvwrite.o cryptoutils.o ekutils.o $(LNALIBS) -o nvwrite\nnvwritelock:\t\tibmtss/tss.h nvwritelock.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvwritelock.o $(LNALIBS) -o nvwritelock\nobjectchangeauth:\tibmtss/tss.h objectchangeauth.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) objectchangeauth.o $(LNALIBS) -o objectchangeauth\npcrallocate: \t\tibmtss/tss.h pcrallocate.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrallocate.o $(LNALIBS) -o pcrallocate\npcrevent: \t\tibmtss/tss.h pcrevent.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrevent.o $(LNALIBS) -o pcrevent\npcrextend: \t\tibmtss/tss.h pcrextend.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrextend.o $(LNALIBS) -o pcrextend\npcrread: \t\tibmtss/tss.h pcrread.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrread.o $(LNALIBS) -o pcrread\npcrreset: \t\tibmtss/tss.h pcrreset.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrreset.o $(LNALIBS) -o pcrreset\npolicyauthorize:\tibmtss/tss.h policyauthorize.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyauthorize.o $(LNALIBS) -o policyauthorize\npolicyauthvalue:\tibmtss/tss.h policyauthvalue.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyauthvalue.o $(LNALIBS) -o policyauthvalue\npolicycapability:\tibmtss/tss.h policycapability.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycapability.o $(LNALIBS) -o policycapability\npolicycommandcode:\tibmtss/tss.h policycommandcode.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycommandcode.o $(LNALIBS) -o policycommandcode\npolicycphash:\t\tibmtss/tss.h policycphash.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycphash.o $(LNALIBS) -o policycphash\npolicynamehash:\t\tibmtss/tss.h policynamehash.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policynamehash.o $(LNALIBS) -o policynamehash\npolicycountertimer :\tibmtss/tss.h policycountertimer.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycountertimer.o $(LNALIBS) -o policycountertimer\npolicyduplicationselect:\tibmtss/tss.h policyduplicationselect.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyduplicationselect.o $(LNALIBS) -o policyduplicationselect\npolicygetdigest:\tibmtss/tss.h policygetdigest.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policygetdigest.o $(LNALIBS) -o policygetdigest\npolicymaker:\t\tibmtss/tss.h policymaker.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policymaker.o $(LNALIBS) -o policymaker\npolicymakerpcr:\t\tibmtss/tss.h policymakerpcr.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policymakerpcr.o $(LNALIBS) -o policymakerpcr\npolicyauthorizenv:\tibmtss/tss.h policyauthorizenv.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyauthorizenv.o $(LNALIBS) -o policyauthorizenv\npolicynv:\t\tibmtss/tss.h policynv.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policynv.o $(LNALIBS) -o policynv\npolicynvwritten:\tibmtss/tss.h policynvwritten.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policynvwritten.o $(LNALIBS) -o policynvwritten\npolicyor:\t\tibmtss/tss.h policyor.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyor.o $(LNALIBS) -o policyor\npolicyparameters:\tibmtss/tss.h policyparameters.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyparameters.o $(LNALIBS) -o policyparameters\npolicypassword:\t\tibmtss/tss.h policypassword.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policypassword.o $(LNALIBS) -o policypassword\npolicypcr:\t\tibmtss/tss.h policypcr.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policypcr.o $(LNALIBS) -o policypcr\npolicyrestart:\t\tibmtss/tss.h policyrestart.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyrestart.o $(LNALIBS) -o policyrestart\npolicysigned:\t\tibmtss/tss.h policysigned.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policysigned.o $(LNALIBS) -o policysigned\npolicysecret:\t\tibmtss/tss.h policysecret.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policysecret.o $(LNALIBS) -o policysecret\npolicytemplate:\t\tibmtss/tss.h policytemplate.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policytemplate.o $(LNALIBS) -o policytemplate\npolicyticket:\t\tibmtss/tss.h policyticket.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyticket.o $(LNALIBS) -o policyticket\nquote:\t\t\tibmtss/tss.h quote.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) quote.o $(LNALIBS) -o quote\npowerup:\t\tibmtss/tss.h powerup.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) powerup.o $(LNALIBS) -o powerup\nreadclock:\t\tibmtss/tss.h readclock.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) readclock.o $(LNALIBS) -o readclock\nreadpublic:\t\tibmtss/tss.h readpublic.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) readpublic.o cryptoutils.o $(LNALIBS) -o readpublic\nreturncode:\t\tibmtss/tss.h returncode.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) returncode.o $(LNALIBS) -o returncode\nrewrap:\t\t\tibmtss/tss.h rewrap.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) rewrap.o $(LNALIBS) -o rewrap\nrsadecrypt: \t\tibmtss/tss.h rsadecrypt.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) rsadecrypt.o $(LNALIBS) -o rsadecrypt\nrsaencrypt: \t\tibmtss/tss.h rsaencrypt.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) rsaencrypt.o $(LNALIBS) -o rsaencrypt\nsequenceupdate:\t\tibmtss/tss.h sequenceupdate.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) sequenceupdate.o $(LNALIBS) -o sequenceupdate\nsequencecomplete:\tibmtss/tss.h sequencecomplete.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) sequencecomplete.o $(LNALIBS) -o sequencecomplete\nsetprimarypolicy:\tibmtss/tss.h setprimarypolicy.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) setprimarypolicy.o $(LNALIBS) -o setprimarypolicy\nsetcommandcodeauditstatus:\tibmtss/tss.h setcommandcodeauditstatus.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) setcommandcodeauditstatus.o $(LNALIBS) -o setcommandcodeauditstatus\nshutdown:\t\tibmtss/tss.h shutdown.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) shutdown.o $(LNALIBS) -o shutdown\nsign:\t\t\tibmtss/tss.h sign.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) sign.o cryptoutils.o $(LNALIBS) -o sign\nstartauthsession:\tibmtss/tss.h startauthsession.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) startauthsession.o $(LNALIBS) -o startauthsession\nstartup:\t\tibmtss/tss.h startup.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) startup.o $(LNALIBS) -o startup\nstirrandom:\t\tibmtss/tss.h stirrandom.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) stirrandom.o $(LNALIBS) -o stirrandom\nunseal:\t\t\tibmtss/tss.h unseal.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) unseal.o $(LNALIBS) -o unseal\nverifysignature:\tibmtss/tss.h verifysignature.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) verifysignature.o cryptoutils.o $(LNALIBS) -o verifysignature\nzgen2phase:\t\tibmtss/tss.h zgen2phase.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) zgen2phase.o cryptoutils.o $(LNALIBS) -o zgen2phase\nsignapp:\t\tibmtss/tss.h signapp.o ekutils.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) signapp.o ekutils.o cryptoutils.o $(LNALIBS) -o signapp\nwriteapp:\t\tibmtss/tss.h writeapp.o ekutils.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) writeapp.o ekutils.o cryptoutils.o $(LNALIBS) -o writeapp\ntimepacket:\t\tibmtss/tss.h timepacket.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) timepacket.o $(LNALIBS) -o timepacket\ncreateek:\t\tcreateek.o cryptoutils.o ekutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createek.o cryptoutils.o ekutils.o $(LNALIBS) -o createek\ncreateekcert:\t\tcreateekcert.o cryptoutils.o ekutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createekcert.o cryptoutils.o ekutils.o $(LNALIBS) -o createekcert\ntpm2pem:\t\ttpm2pem.o cryptoutils.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpm2pem.o cryptoutils.o $(LNALIBS) -o tpm2pem\ntpmpublic2eccpoint:\ttpmpublic2eccpoint.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpmpublic2eccpoint.o $(LNALIBS) -o tpmpublic2eccpoint\nntc2getconfig:\t\tntc2getconfig.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ntc2getconfig.o $(LNALIBS) -o ntc2getconfig\nntc2preconfig:\t\tntc2preconfig.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ntc2preconfig.o $(LNALIBS) -o ntc2preconfig\nntc2lockconfig:\t\tntc2lockconfig.o $(LIBTSS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ntc2lockconfig.o $(LNALIBS) -o ntc2lockconfig\npublicname:\t\tpublicname.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) publicname.o $(LNALIBS) -o publicname\ngetcryptolibrary:\tgetcryptolibrary.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getcryptolibrary.o $(LNALIBS) -o getcryptolibrary\nprintattr:\t\tprintattr.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) printattr.o $(LNALIBS) -o printattr\n\n# for applications, not for TSS library\n\n%.o:\t\t%.c ibmtss/tss.h \n\t\t$(CC) $(CCFLAGS) $(CCAFLAGS) $< -o $@\n\n"
  },
  {
    "path": "ibmtss-ftpm/makefile.mak",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\t\tWindows MinGW TSS2 Makefile OpenSSL 64-bit\t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2015 - 2023\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n# Windows OpenSSL 3.1 64-bit with mingw\n\n# C compiler\n\nCC = \"c:/program files/mingw/bin/gcc.exe\"\n\n# compile - common flags for TSS library and applications\n\nCCFLAGS += \t\t\t\t\t\\\n\t-Wno-deprecated-declarations\t\t\\\n\t-DTPM_WINDOWS\t\t\t\t\\\n\t-DTPM_TSS_NODEV\t\t\t\t\\\n\t-I. \t\t\t\t\t\\\n\t-I\"c:/program files/MinGW/include\"\t\\\n\t-I\"c:/program files/openssl/include\"\t\\\n\n# compile - for TSS library\n\nCCLFLAGS +=\t\t\t\t\t\\\n\t\t-DTPM_TPM20\n\n# compile - for applications\n\nCCAFLAGS += \t\t\t\\\n\t\t-DTPM_TPM20\n\n# link - common flags flags TSS library and applications\n\nLNFLAGS +=\t\t\t\t\t\\\n\t-D_MT\t\t\t\t\t\\\n\t-DTPM_WINDOWS\t\t\t\t\\\n\t-I.\n\n# link - for TSS library\n\nLNLFLAGS += \n\n# link - for applications, TSS path, TSS and OpenSSl libraries\n\nLNAFLAGS += \n\nLNLIBS = \t\"c:/program files/openssl/bin/libcrypto-3-x64.dll\" -lws2_32\n\n# shared library\n\nLIBTSS=libibmtss.dll\n\n# executable extension\n\nEXE=.exe\n\n# \n\nALL =\n\n# default TSS library\n\nTSS_OBJS = \ttssfile.o \t\t\\\n\t\ttsscryptoh.o \t\t\\\n\t\ttsscrypto.o \t\t\\\n\t\ttssprintcmd.o\n\n# common to all builds\n\ninclude makefile-common\ninclude makefile-common20\n\n#\n# Start Windows TBSI\n#\n\n# mingw libraries are apparently no longer compatible with Windows\n# Kits for TBS.  Contributions are welcome.  Until then, use the\n# Visual Studio solution for the hardware TPM.\n\n#TSS_OBJS += tsstbsi.o\n\n#CCFLAGS +=\t-DTPM_WINDOWS_TBSI\n#CCFLAGS +=\t-D_WIN32_WINNT=0x0600\n\n# Windows 10\n\n#CCFLAGS +=\t-DTPM_WINDOWS_TBSI_WIN8\n#CCFLAGS +=\t-I\"c:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.17763.0\\shared\"\n\n#LNLIBS += \"c:/Program Files (x86)/Windows Kits/10/Lib/10.0.17763.0/um/x64/tbs.lib\"\n\n# Windows 7\n\n#CCFLAGS +=\t-DTPM_WINDOWS_TBSI_WIN7\n\n#LNLIBS += c:/progra~1/Micros~2/Windows/v7.1/lib/Tbs.lib\n\n#\n# End Windows TBSI\n#\n\n# default build target\n\nall:\t$(ALL)\n\n# TSS shared library source\n\ntss.o: \t\t$(TSS_HEADERS) tss.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss.c\ntssproperties.o: $(TSS_HEADERS) tssproperties.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssproperties.c\ntssauth.o: \t$(TSS_HEADERS) tssauth.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth.c\ntssmarshal.o: \t$(TSS_HEADERS) tssmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssmarshal.c\ntsscryptoh.o: \t$(TSS_HEADERS) tsscryptoh.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscryptoh.c\ntsscrypto.o: \t$(TSS_HEADERS) tsscrypto.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscrypto.c\ntssutils.o: \t$(TSS_HEADERS) tssutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssutils.c\ntssfile.o: \t$(TSS_HEADERS) tssfile.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssfile.c\ntsssocket.o: \t$(TSS_HEADERS) tsssocket.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsssocket.c\ntssdev.o: \t$(TSS_HEADERS) tssdev.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssdev.c\ntsstransmit.o: \t$(TSS_HEADERS) tsstransmit.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsstransmit.c\ntssresponsecode.o: $(TSS_HEADERS) tssresponsecode.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssresponsecode.c\ntssccattributes.o: $(TSS_HEADERS) tssccattributes.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssccattributes.c\ntssprint.o: \t$(TSS_HEADERS) tssprint.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprint.c\nUnmarshal.o: \t$(TSS_HEADERS) Unmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Unmarshal.c\nCommands.o: \t$(TSS_HEADERS) Commands.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Commands.c\nCommandAttributeData.o: \t$(TSS_HEADERS) CommandAttributeData.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) CommandAttributeData.c\nntc2lib.o:\t$(TSS_HEADERS) ntc2lib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ntc2lib.c\ntssntc.o:\t$(TSS_HEADERS) tssntc.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssntc.c\n\n# TPM 2.0\n\ntss20.o: \t$(TSS_HEADERS) tss20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss20.c\ntssauth20.o: \t$(TSS_HEADERS) tssauth20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth20.c\n\n# TSS shared library build\n\n$(LIBTSS): \t$(TSS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -shared -o $(LIBTSS) $(TSS_OBJS) \\\n\t\t-Wl,--out-implib,libibmtss.a $(LNLIBS)\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\nclean:\t\t\n\t\trm -f *.o \t\\\n\t\t$(LIBTSS)\t\\\n\t\t$(ALL)\n\ncreate.exe:\tcreate.o objecttemplates.o cryptoutils.o $(LIBTSS) \n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o objecttemplates.o cryptoutils.o $(LNLIBS) $(LIBTSS) \n\ncreateloaded.exe:\tcreateloaded.o objecttemplates.o cryptoutils.o $(LIBTSS) \n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o objecttemplates.o cryptoutils.o $(LNLIBS) $(LIBTSS) \n\ncreateprimary.exe:\tcreateprimary.o objecttemplates.o cryptoutils.o $(LIBTSS) \n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o objecttemplates.o cryptoutils.o $(LNLIBS) $(LIBTSS) \n\neventextend.exe:\teventextend.o eventlib.o efilib.o cryptoutils.o $(LIBTSS)\n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o eventlib.o efilib.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\nimaextend.exe:\timaextend.o imalib.o cryptoutils.o $(LIBTSS) \n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o imalib.o cryptoutils.o $(LNLIBS) $(LIBTSS) \n\ncreateek.exe:\tcreateek.o ekutils.o cryptoutils.o $(LIBTSS) \n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o ekutils.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\ncertifyx509.exe:\tcertifyx509.o ekutils.o cryptoutils.o $(LIBTSS) \n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o ekutils.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\ncreateekcert.exe:\tcreateekcert.o ekutils.o cryptoutils.o $(LIBTSS) \n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o ekutils.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\nimportpem.exe:\timportpem.o objecttemplates.o ekutils.o cryptoutils.o $(LIBTSS)\n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o objecttemplates.o ekutils.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\nloadexternal.exe:\tloadexternal.o cryptoutils.o ekutils.o $(LIBTSS)\n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o cryptoutils.o ekutils.o $(LNLIBS) $(LIBTSS)\n\nnvread.exe:\tnvread.o ekutils.o cryptoutils.o $(LIBTSS) \n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o ekutils.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\nnvwrite.exe:\tnvwrite.o ekutils.o cryptoutils.o $(LIBTSS)\n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o ekutils.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\nsignapp.exe:\tsignapp.o ekutils.o cryptoutils.o $(LIBTSS)\n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o ekutils.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\nwriteapp.exe:\twriteapp.o ekutils.o cryptoutils.o $(LIBTSS)\n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o ekutils.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\n%.exe:\t\t%.o applink.o cryptoutils.o $(LIBTSS)\n\t\t$(CC) $(LNFLAGS) -L. -libmtss $< -o $@ applink.o cryptoutils.o $(LNLIBS) $(LIBTSS)\n\n%.o:\t\t%.c\n\t\t$(CC) $(CCFLAGS) $(CCAFLAGS) $< -o $@\n"
  },
  {
    "path": "ibmtss-ftpm/makefile.min",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\tLinux TPM2 Utilities Makefile for minimal TSS\t\t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2016 - 2019\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n# makefile to build a TSS library that does not require file read/write or crypto\n# within the library\n#\n# See the documentation for limitations.\n\n# C compiler\n\nCC = /usr/bin/gcc\n\n# compile - common flags for TSS library and applications\n\nCCFLAGS  += \\\n\t-DTPM_POSIX\t\t\\\n\t-DTPM_TSS_NOFILE\t\\\n\t-DTPM_TSS_NOCRYPTO\t\\\n\t-DTPM_TSS_NORSA\n\n# -DTPM_NOSOCKET\n\n# compile - for TSS library\n\nCCLFLAGS += \t-I.\t\t\t\\\n\t\t-fPIC\t\t\t\\\n\t\t-DTPM_TPM20\n\n# compile - for applications\n\nCCAFLAGS += \t-I.\t\t\\\n\t\t-DTPM_TPM20\t\\\n\t\t-fPIE\n\n# link - common flags flags TSS library and applications\n\nLNFLAGS += \t-DTPM_POSIX\t\t\\\n\t\t-L.\n\n# link - for TSS library\n\n# link - for applications, TSS path, TSS and OpenSSl libraries\n\nLNAFLAGS += -Wl,-rpath,.\n\nLNALIBS +=  -libmtssmin\n\n# shared library\n\nLIBTSS=libibmtssmin.so\n\n# \n\nALL = $(LIBTSS)\n#TSS_HEADERS = ibmtss/tssfile.h\n\n# default TSS library\n\nTSS_OBJS =\ttssprintcmd.o\n\n\n# common to all builds\n\ninclude makefile-common\ninclude makefile-common20\n\n# default build target\n\nall:\twriteapp\n\n# TSS shared library source\n\ntss.o: \t\t\t$(TSS_HEADERS) tss.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tss.c\ntssproperties.o: \t$(TSS_HEADERS) tssproperties.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssproperties.c\ntssauth.o: \t\t$(TSS_HEADERS) tssauth.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssauth.c\ntssmarshal.o: \t\t$(TSS_HEADERS) tssmarshal.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssmarshal.c\ntsscryptoh.o: \t\t$(TSS_HEADERS) tsscryptoh.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tsscryptoh.c\ntsscrypto.o: \t\t$(TSS_HEADERS) tsscrypto.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tsscrypto.c\ntssutils.o: \t\t$(TSS_HEADERS) tssutils.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssutils.c\ntsssocket.o: \t\t$(TSS_HEADERS) tsssocket.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tsssocket.c\ntssdev.o: \t\t$(TSS_HEADERS) tssdev.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssdev.c\ntsstransmit.o: \t\t$(TSS_HEADERS) tsstransmit.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tsstransmit.c\ntssresponsecode.o: \t$(TSS_HEADERS) tssresponsecode.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssresponsecode.c\ntssccattributes.o: \t$(TSS_HEADERS) tssccattributes.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssccattributes.c\ntssprint.o: \t\t$(TSS_HEADERS) tssprint.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssprint.c\ntssprintcmd.o: \t\t$(TSS_HEADERS) tssprintcmd.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssprintcmd.c\nUnmarshal.o: \t\t$(TSS_HEADERS) Unmarshal.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC Unmarshal.c\nCommands.o: \t\t$(TSS_HEADERS) Commands.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC Commands.c\nCommandAttributeData.o: $(TSS_HEADERS) CommandAttributeData.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC CommandAttributeData.c\nntc2lib.o:\t\t$(TSS_HEADERS) ntc2lib.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC ntc2lib.c\ntssntc.o:\t\t$(TSS_HEADERS) tssntc.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) -fPIC tssntc.c\n\n# TPM 2.0\n\ntss20.o: \t$(TSS_HEADERS) tss20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss20.c\ntssauth20.o: \t$(TSS_HEADERS) tssauth20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth20.c\n\n# TSS shared library build\n\n$(LIBTSS): \t$(TSS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -shared -o $(LIBTSS) $(TSS_OBJS)\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\nclean:\t\t\n\t\trm -f *.o\t\\\n\t\t$(ALL)\n\n# applications\n\nwriteapp:\t\tibmtss/tss.h writeapp.o tssutilsverbose.o $(LIBTSS) \n\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) writeapp.o tssutilsverbose.o \\\n\t\t\t$(LNALIBS) -o writeapp\n\n# for applications, not for TSS library\n\n%.o:\t\t%.c ibmtss/tss.h \n\t\t$(CC) $(CCFLAGS) $(CCAFLAGS) $< -o $@\n\n"
  },
  {
    "path": "ibmtss-ftpm/makefile.nofile",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\tLinux TPM2 Utilities Makefile for TSS without files\t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2016 - 2020\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n# makefile to build a TSS library that does not require file read/write.\n#\n# See the documentation for limitations.\n\n# C compiler\n\nCC = /usr/bin/gcc\n\n# compile - common flags for TSS library and applications\n\nCCFLAGS  += \t-DTPM_POSIX\t\t\t\\\n\t\t-DTPM_TSS_NOFILE\n\n# -DTPM_NOSOCKET\n\n# compile - for TSS library\n\n# include the hardening flag PIC needed for compiling for dynamic\n# linking\n\nCCLFLAGS += \t-I. \t\t\\\n\t\t-fPIC\t\t\\\n\t\t-DTPM_TPM20\n\n# compile - for applications\n\n# include the hardening flag PIE needed for compiling for\n# static linking\n\nCCAFLAGS += \t-I.\t\t\\\n\t\t-DTPM_TPM20\t\\\n\t\t-fPIE\n\n# link - common flags flags TSS library and applications\n\nLNFLAGS += \t-DTPM_POSIX\t\\\n\t\t-L.\n\n# link - for TSS library\n\n# hardening flags for linking shared objects\nLNLFLAGS += -shared -Wl,-z,now\n\n#\tThis is an alternative to using the bfd linker on Ubuntu\nLNLLIBS += -lcrypto\n\n# link - for applications, TSS path, TSS and OpenSSl libraries\n\nLNAFLAGS += -pie -Wl,-z,now -Wl,-rpath,.\n\nLNALIBS +=  -libmtssutils -libmtssmin\n\n# versioned shared library\nLIBTSSVERSIONED=libibmtssmin.so.2.1\n\n# soname field of the shared library\n# which will be made symbolic link to the versioned shared library\n# this is used to provide version backward-compatibility information\nLIBTSSSONAME=libibmtssmin.so.2\n\n# symbolic link to the versioned shared library\n# this allows linking to the shared library with '-libmtss' \n\nos := $(shell uname -o)\nifeq ($(os),Cygwin)\n  LIBTSS=libibmtssmin.dll\nelse\n  LIBTSS=libibmtssmin.so\nendif\n\n# TSS utilities shared library\n\nLIBTSSUTILSVERSIONED=libibmtssutils.so.2.1\nLIBTSSUTILSSONAME=libibmtssutils.so.2\nLIBTSSUTILS=libibmtssutils.so\n\n# executable extension\n\nEXE =\n\nALL = signapp writeapp\n\nTSS_HEADERS = ibmtss/tssfile.h\n\n# default TSS library\n\nTSS_OBJS =  \ttsscryptoh.o \t\t\\\n\t\ttsscrypto.o \t\t\\\n\t\ttssprintcmd.o\n\nTSSUTILS_OBJS = cryptoutils.o\t\\\n\t\tekutils.o\t\\\n\t\timalib.o\t\\\n\t\teventlib.o\t\\\n\t\tefilib.o\n\n# common to all builds\n\ninclude makefile-common\ninclude makefile-common20\n\n# default build target\n\nall: \tsignapp writeapp\n\n# TSS shared library source\n\ntss.o: \t\t\t$(TSS_HEADERS) tss.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss.c\ntssauth.o: \t\t$(TSS_HEADERS) tssauth.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth.c\ntssproperties.o: \t$(TSS_HEADERS) tssproperties.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssproperties.c\ntssmarshal.o: \t\t$(TSS_HEADERS) tssmarshal.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssmarshal.c\ntsscryptoh.o: \t\t$(TSS_HEADERS) tsscryptoh.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscryptoh.c\ntsscrypto.o: \t\t$(TSS_HEADERS) tsscrypto.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscrypto.c\ntssutils.o: \t\t$(TSS_HEADERS) tssutils.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssutils.c\ntsssocket.o: \t\t$(TSS_HEADERS) tsssocket.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsssocket.c\ntssdev.o: \t\t$(TSS_HEADERS) tssdev.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssdev.c\ntsstransmit.o: \t\t$(TSS_HEADERS) tsstransmit.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsstransmit.c\ntssresponsecode.o: \t$(TSS_HEADERS) tssresponsecode.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssresponsecode.c\ntssccattributes.o: \t$(TSS_HEADERS) tssccattributes.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssccattributes.c\ntssprint.o: \t\t$(TSS_HEADERS) tssprint.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprint.c\ntssprintcmd.o: \t\t$(TSS_HEADERS) tssprintcmd.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprintcmd.c\nUnmarshal.o: \t\t$(TSS_HEADERS) Unmarshal.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Unmarshal.c\nCommands.o: \t\t$(TSS_HEADERS) Commands.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Commands.c\nCommandAttributeData.o: $(TSS_HEADERS) CommandAttributeData.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) CommandAttributeData.c\nntc2lib.o:\t\t$(TSS_HEADERS) ntc2lib.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ntc2lib.c\ntssntc.o:\t\t$(TSS_HEADERS) tssntc.c\n\t\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssntc.c\n\n# TPM 2.0\n\ntss20.o: \t$(TSS_HEADERS) tss20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss20.c\ntssauth20.o: \t$(TSS_HEADERS) tssauth20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth20.c\n\n# TSS utilities shared library source\n\ncryptoutils.o: \t$(TSS_HEADERS) cryptoutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) cryptoutils.c\nekutils.o: \t$(TSS_HEADERS) ekutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ekutils.c\nimalib.o: \t$(TSS_HEADERS) imalib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) imalib.c\neventlib.o: \t$(TSS_HEADERS) eventlib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) eventlib.c\nefilib.o: \t$(TSS_HEADERS) efilib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) efilib.c\n\n# TSS shared library build\n\n$(LIBTSS): \t$(TSS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -Wl,-soname,$(LIBTSSSONAME) -o $(LIBTSSVERSIONED) $(TSS_OBJS) $(LNLLIBS)\n\t\trm -f $(LIBTSSSONAME)\n\t\tln -sf $(LIBTSSVERSIONED) $(LIBTSSSONAME)\n\t\trm -f $(LIBTSS)\n\t\tln -sf $(LIBTSSSONAME) $(LIBTSS)\n\n# TSS utilities shared library\n\n$(LIBTSSUTILS):\t$(TSSUTILS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -Wl,-soname,$(LIBTSSUTILSSONAME) -o $(LIBTSSUTILSVERSIONED) $(TSSUTILS_OBJS) $(LNLLIBS)\n\t\trm -f $(LIBTSSSUTILSONAME)\n\t\tln -sf $(LIBTSSUTILSVERSIONED) $(LIBTSSUTILSSONAME)\n\t\trm -f $(LIBTSSUTILS)\n\t\tln -sf $(LIBTSSUTILSSONAME) $(LIBTSSUTILS)\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\nclean:\t\t\n\t\trm -f *.o \t\t\\\n\t\t$(LIBTSSSONAME)\t\t\\\n\t\t$(LIBTSSVERSIONED) \t\\\n\t\t$(LIBTSSUTILSSONAME) \t\\\n\t\t$(LIBTSSUTILSVERSIONED)\t\\\n\t\t$(ALL)\n\n# applications\n\nsignapp:\t\tibmtss/tss.h signapp.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) signapp.o $(LNALIBS) -o signapp\nwriteapp:\t\tibmtss/tss.h writeapp.o $(LIBTSS) $(LIBTSSUTILS) \n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) writeapp.o $(LNALIBS) -o writeapp\n\n# for applications, not for TSS library\n\n%.o:\t\t%.c ibmtss/tss.h \n\t\t$(CC) $(CCFLAGS) $(CCAFLAGS) $< -o $@\n\n"
  },
  {
    "path": "ibmtss-ftpm/makefiletpm12",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\tLinux TPM 1.2 TSS Makefile\t\t\t\t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2018 - 2019\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n# C compiler\n\nCC = /usr/bin/gcc\n\n# compile - common flags for TSS library and applications\n\nCCFLAGS += \t-DTPM_POSIX\n\n# example of pointing to a locally built openssl 1.1\n# CCFLAGS += \t-I/home/kgold/openssl/include\n\n# compile - for TSS library\n\n# include the hardening flag PIC needed for compiling for dynamic\n# linking\n\nCCLFLAGS += \t-I. \t\t\\\n\t\t-fPIC\t\t\\\n\t\t-DTPM_TPM12\n\n# to compile out printf's.  Regression test will fail because it tries\n# to print a structure -DTPM_TSS_NO_PRINT\n\n# example of changing the default interface type\n#\t-DTPM_INTERFACE_TYPE_DEFAULT=\"\\\"dev\\\"\"\n\n# compile - for applications\n\n# include the hardening flag PIE needed for compiling for\n# static linking\n\nCCAFLAGS += \t-I.\t\t\\\n\t\t-DTPM_TPM12\t\\\n\t\t-fPIE\n\n# link - common flags flags TSS library and applications\n\nLNFLAGS += \t-DTPM_POSIX\t\t\\\n\t\t-L.\n\n# This seems to be required on some Ubuntu distros due to an issue with the gold linker\n#\t\t-fuse-ld=bfd\n\n# example of pointing to a locally built openssl 1.1\n# LNFLAGS +=\t -L/home/kgold/openssl\n# This also requires setting the environment variable LD_LIBRARY_PATH.  E.g.,\n# setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/kgold/openssl-1.1.0c\n\n# link - for TSS library\n\n# hardening flags for linking shared objects\nLNLFLAGS += -shared -Wl,-z,now\n\n# This is an alternative to using the bfd linker on Ubuntu\nLNLLIBS += -lcrypto\n\n# link - for applications, TSS path, TSS and OpenSSl libraries\n\n# hardening flags for linking executables\nLNAFLAGS += -pie -Wl,-z,now -Wl,-rpath,.\n\nLNALIBS +=  -libmtss\n\n# shared library\n\n# versioned shared library\nLIBTSSVERSIONED=libibmtss.so.2.1\n\n# soname field of the shared library\n# which will be made symbolic link to the versioned shared library\n# this is used to provide version backward-compatibility information\nLIBTSSSONAME=libibmtss.so.2\n\n# symbolic link to the versioned shared library\n# this allows linking to the shared library with '-libmtss' \n\nos := $(shell uname -o)\nifeq ($(os),Cygwin)\n  LIBTSS=libibmtss.dll\nelse\n  LIBTSS=libibmtss.so\nendif\n\n# TSS utilities shared library\n\nLIBTSSUTILSVERSIONED=libibmtssutils.so.2.1\nLIBTSSUTILSSONAME=libibmtssutils.so.2\nLIBTSSUTILS=libibmtssutils.so\n\n# executable extension\n\nEXE =\n\n# \n\nALL = \nTSS_HEADERS=\n\n# default TSS library\n\nTSS_OBJS =\ttssfile.o \t\t\\\n\t\ttsscryptoh.o \t\t\\\n\t\ttsscrypto.o\n\nTSSUTILS_OBJS = cryptoutils.o\t\\\n\t\tekutils.o\t\\\n\t\timalib.o\t\\\n\t\teventlib.o\n\n# common to all builds\n\ninclude makefile-common\ninclude makefile-common12\n\n# default build target\n\nall:\t$(ALL)\n\n# TSS shared library source\n\ntss.o: \t\t$(TSS_HEADERS) tss.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss.c\ntssproperties.o: $(TSS_HEADERS) tssproperties.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssproperties.c\ntssauth.o: \t$(TSS_HEADERS) tssauth.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth.c\ntssmarshal.o: \t$(TSS_HEADERS) tssmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssmarshal.c\ntsscryptoh.o: \t$(TSS_HEADERS) tsscryptoh.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscryptoh.c\ntsscrypto.o: \t$(TSS_HEADERS) tsscrypto.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscrypto.c\ntssutils.o: \t$(TSS_HEADERS) tssutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssutils.c\ntssfile.o: \t$(TSS_HEADERS) tssfile.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssfile.c\ntsssocket.o: \t$(TSS_HEADERS) tsssocket.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsssocket.c\ntssdev.o: \t$(TSS_HEADERS) tssdev.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssdev.c\ntsstransmit.o: \t$(TSS_HEADERS) tsstransmit.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsstransmit.c\ntssresponsecode.o: $(TSS_HEADERS) tssresponsecode.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssresponsecode.c\ntssccattributes.o: $(TSS_HEADERS) tssccattributes.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssccattributes.c\ntssprint.o: \t$(TSS_HEADERS) tssprint.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprint.c\ntssprintcmd.o: \t$(TSS_HEADERS) tssprintcmd.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprintcmd.c\nUnmarshal.o: \t$(TSS_HEADERS) Unmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Unmarshal.c\nCommands.o: \t$(TSS_HEADERS) Commands.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Commands.c\nCommandAttributeData.o: \t$(TSS_HEADERS) CommandAttributeData.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) CommandAttributeData.c\nntc2lib.o:\t$(TSS_HEADERS) ntc2lib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ntc2lib.c\ntssntc.o:\t$(TSS_HEADERS) tssntc.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssntc.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss20.c\n# TPM 1.2\n\ntss12.o: \t$(TSS_HEADERS) tss12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss12.c\ntssauth12.o: \t$(TSS_HEADERS) tssauth12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth12.c\ntssmarshal12.o:\t$(TSS_HEADERS) tssmarshal12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssmarshal12.c\nUnmarshal12.o: \t$(TSS_HEADERS) Unmarshal12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Unmarshal12.c\nCommands12.o: \t$(TSS_HEADERS) Commands12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Commands12.c\ntssccattributes12.o: $(TSS_HEADERS) tssccattributes12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssccattributes12.c\nCommandAttributeData12.o: \t$(TSS_HEADERS) CommandAttributeData12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) CommandAttributeData12.c\n\n# TSS utilities shared library source\n\ncryptoutils.o: \t$(TSS_HEADERS) cryptoutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) cryptoutils.c\nekutils.o: \t$(TSS_HEADERS) ekutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ekutils.c\nimalib.o: \t$(TSS_HEADERS) imalib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) imalib.c\neventlib.o: \t$(TSS_HEADERS) eventlib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) eventlib.c\n\n# TSS shared library build\n\n$(LIBTSS): \t$(TSS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -Wl,-soname,$(LIBTSSSONAME) -o $(LIBTSSVERSIONED) $(TSS_OBJS) $(LNLLIBS)\n\t\trm -f $(LIBTSSSONAME)\n\t\tln -sf $(LIBTSSVERSIONED) $(LIBTSSSONAME)\n\t\trm -f $(LIBTSS)\n\t\tln -sf $(LIBTSSSONAME) $(LIBTSS)\n\n# TSS utilities shared library\n\n$(LIBTSSUTILS):\t$(TSSUTILS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -Wl,-soname,$(LIBTSSUTILSSONAME) -o $(LIBTSSUTILSVERSIONED) $(TSSUTILS_OBJS) $(LNLLIBS)\n\t\trm -f $(LIBTSSSUTILSONAME)\n\t\tln -sf $(LIBTSSUTILSVERSIONED) $(LIBTSSUTILSSONAME)\n\t\trm -f $(LIBTSSUTILS)\n\t\tln -sf $(LIBTSSUTILSSONAME) $(LIBTSSUTILS)\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\nclean:\t\t\n\t\trm -f *.o  *~ \t\t\\\n\t\th*.bin\t\t\t\\\n\t\t$(LIBTSSSONAME)\t\t\\\n\t\t$(LIBTSSVERSIONED) \t\\\n\t\t$(LIBTSSUTILSSONAME) \t\\\n\t\t$(LIBTSSUTILSVERSIONED)\t\\\n\t\t$(ALL)\n\n# applications are in .../utils12\n\n# for applications, not for TSS library\n\n%.o:\t\t%.c ibmtss/tss.h \n\t\t$(CC) $(CCFLAGS) $(CCAFLAGS) $< -o $@\n\n"
  },
  {
    "path": "ibmtss-ftpm/makefiletpm20",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\tLinux TPM2 Utilities Makefile\t\t\t\t\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2014 - 2024\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n# C compiler\n\nOPENSSL = \n\n# CC = /usr/bin/gcc\nCC = /opt/riscv/bin/riscv64-unknown-linux-gnu-gcc\nAR = /opt/riscv/bin/riscv64-unknown-linux-gnu-ar\n\n# compile - common flags for TSS library and applications.\n\n# no-deprecated-declarations silences the compiler until the openssl\n# 3.0 port is complete.\n\n# CCFLAGS += \t-DTPM_POSIX -DTPM_TSS_NODEPRECATED -DTPM_TSS_NODEV -DOPENSSL_NO_DEPRECATED\n\nCCFLAGS += \t-DTPM_POSIX -DTPM_TSS_NODEPRECATED -DTPM_NOSOCKET -DOPENSSL_NO_DEPRECATED\n\nCCFLAGS += -DTPM_INTERFACE_FTPM -I${OPENSSL}/include -I${OPENSSL}/crypto/include\n# CCFLAGS += -I${OPENSSL}/include -I${OPENSSL}/crypto/include\n\n# example of pointing to a locally built openssl\n#CCFLAGS += \t-I/home/kgold/openssl/include\n\n# compile - for TSS library\n\n# include the hardening flag PIC needed for compiling for dynamic\n# linking\n\n# CCFLAGS\t+=\t\t\t\\\n# -fno-sanitize-recover\t\t\t\\\n# -fsanitize=address\t\t\t\\\n# -fsanitize=pointer-compare\t\t\\\n# -fsanitize=pointer-subtract\t\t\\\n# -fsanitize=leak\t\t\t\t\\\n# -fsanitize=undefined\t\t\t\\\n# -fsanitize=shift\t\t\t\\\n# -fsanitize=shift-exponent\t\t\\\n# -fsanitize=shift-base\t\t\t\\\n# -fsanitize=integer-divide-by-zero\t\\\n# -fsanitize=unreachable\t\t\t\\\n# -fsanitize=vla-bound\t\t\t\\\n# -fsanitize=null\t\t\t\t\\\n# -fsanitize=return\t\t\t\\\n# -fsanitize=signed-integer-overflow\t\\\n# -fsanitize=bounds\t\t\t\\\n# -fsanitize=bounds-strict\t\t\\\n# -fsanitize=alignment\t\t\t\\\n# -fsanitize=object-size\t\t\t\\\n# -fsanitize=float-divide-by-zero\t\t\\\n# -fsanitize=float-cast-overflow\t\t\\\n# -fsanitize=nonnull-attribute\t\t\\\n# -fsanitize=returns-nonnull-attribute\t\\\n# -fsanitize=bool\t\t\t\t\\\n# -fsanitize=enum\t\t\t\t\\\n# -fsanitize=vptr\t\t\t\t\\\n# -fsanitize=pointer-overflow\t\t\\\n# -fsanitize=builtin\n\n# LNLLIBS +=  -lasan -lubsan -lcrypto\n# LNALIBS +=  -lasan -lubsan -libmtssutils -libmtss\n\nCCLFLAGS += \t-I. \t\t\\\n\t\t-fPIC\t\t\\\n\t\t-DTPM_TPM20\n\n# to compile out printf's.  Regression test will fail because it tries\n# to print a structure -DTPM_TSS_NO_PRINT\n\n# example of changing the default interface type\n#\t-DTPM_INTERFACE_TYPE_DEFAULT=\"\\\"dev\\\"\"\n\n# compile - for applications\n\n# include the hardening flag PIE needed for compiling for\n# static linking\n\nCCAFLAGS += \t-I.\t\t\\\n\t\t-DTPM_TPM20\t\\\n\t\t-fPIE\n\n# link - common flags flags TSS library and applications\n\nLNFLAGS += \t-DTPM_POSIX\t\t\\\n\t\t-L.\n#LNFLAGS +=\t -L/home/kgold/openssl\n\nLNFLAGS +=\t -L${OPENSSL}\n\n# This seems to be required on some Ubuntu distros due to an issue with the gold linker\n#\t\t-fuse-ld=bfd\n\n# example of pointing to a locally built openssl\n# FLAGS +=\t -L/home/kgold/openssl\n# This also requires setting the environment variable LD_LIBRARY_PATH.  E.g.,\n# setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/kgold/openssl\n\n# link - for TSS library\n\n# hardening flags for linking shared objects\nLNLFLAGS += -shared -Wl,-z,now\n\n# This is an alternative to using the bfd linker on Ubuntu\nLNLLIBS += -lcrypto\n\n# link - for applications, TSS path, TSS and OpenSSl libraries\n\n# hardening flags for linking executables\n#LNAFLAGS += -pie -Wl,-z,now -Wl,-rpath,.\n\n# LNAFLAGS = -static\n\n# LNALIBS +=  -libmtssutils -libmtss\nLNALIBS +=  -libmtssutils -libmtss -lcrypto\n\n# shared library\n\n# versioned shared library\nLIBTSSVERSIONED=libibmtss.so.2.3\n\n# soname field of the shared library\n# which will be made symbolic link to the versioned shared library\n# this is used to provide version backward-compatibility information\nLIBTSSSONAME=libibmtss.so.2\n\n# symbolic link to the versioned shared library\n# this allows linking to the shared library with '-libmtss' \n\nos := $(shell uname -o)\nifeq ($(os),Cygwin)\n  LIBTSS=libibmtss.dll\nelse\n  LIBTSS=libibmtss.so\nendif\n\n# TSS utilities shared library\n\nLIBTSSUTILSVERSIONED=libibmtssutils.so.2.3\nLIBTSSUTILSSONAME=libibmtssutils.so.2\nLIBTSSUTILS=libibmtssutils.so\n\n# executable extension\n\nEXE =\n\n# \n\n\nTSS_HEADERS=\n\n# default TSS library\n\nTSS_OBJS = \ttssfile.o \t\t\\\n\t\ttsscryptoh.o \t\t\\\n\t\ttsscrypto.o \t\t\\\n\t\ttssprintcmd.o\n\nTSSUTILS_OBJS = cryptoutils.o\t\\\n\t\tekutils.o\t\\\n\t\timalib.o\t\\\n\t\teventlib.o\t\\\n\t\tefilib.o\n\n# common to all builds\n\ninclude makefile-common\ninclude makefile-common20\n\nALL += tpmproxy$(EXE)\n\n# default build target\n\nall:\t$(ALL)\n\n# TSS shared library source\n\ntss.o: \t\t$(TSS_HEADERS) tss.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss.c\ntssauth.o: \t$(TSS_HEADERS) tssauth.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth.c\ntssproperties.o: $(TSS_HEADERS) tssproperties.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssproperties.c\ntssmarshal.o: \t$(TSS_HEADERS) tssmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssmarshal.c\ntsscryptoh.o: \t$(TSS_HEADERS) tsscryptoh.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscryptoh.c\ntsscrypto.o: \t$(TSS_HEADERS) tsscrypto.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscrypto.c\ntssutils.o: \t$(TSS_HEADERS) tssutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssutils.c\ntssfile.o: \t$(TSS_HEADERS) tssfile.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssfile.c\ntsssocket.o: \t$(TSS_HEADERS) tsssocket.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsssocket.c\ntssdev.o: \t$(TSS_HEADERS) tssdev.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssdev.c\ntsstransmit.o: \t$(TSS_HEADERS) tsstransmit.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsstransmit.c\ntssftpm.o: \t$(TSS_HEADERS) tssftpm.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssftpm.c\ntssresponsecode.o: $(TSS_HEADERS) tssresponsecode.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssresponsecode.c\ntssccattributes.o: $(TSS_HEADERS) tssccattributes.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssccattributes.c\ntssprint.o: \t$(TSS_HEADERS) tssprint.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprint.c\ntssprintcmd.o: \t$(TSS_HEADERS) tssprintcmd.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprintcmd.c\nUnmarshal.o: \t$(TSS_HEADERS) Unmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Unmarshal.c\nCommands.o: \t$(TSS_HEADERS) Commands.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Commands.c\nCommandAttributeData.o: \t$(TSS_HEADERS) CommandAttributeData.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) CommandAttributeData.c\nntc2lib.o:\t$(TSS_HEADERS) ntc2lib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ntc2lib.c\ntssntc.o:\t$(TSS_HEADERS) tssntc.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssntc.c\n\n# TPM 2.0\n\ntss20.o: \t$(TSS_HEADERS) tss20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss20.c\ntssauth20.o: \t$(TSS_HEADERS) tssauth20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth20.c\n\n# TSS utilities shared library source\n\ncryptoutils.o: \t$(TSS_HEADERS) cryptoutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) cryptoutils.c\nekutils.o: \t$(TSS_HEADERS) ekutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ekutils.c\nimalib.o: \t$(TSS_HEADERS) imalib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) imalib.c\neventlib.o: \t$(TSS_HEADERS) eventlib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) eventlib.c\nefilib.o: \t$(TSS_HEADERS) efilib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) efilib.c\n\n# TSS shared library build\n\n$(LIBTSS): \t$(TSS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -Wl,-soname,$(LIBTSSSONAME) -o $(LIBTSSVERSIONED) $(TSS_OBJS) $(LNLLIBS)\n\t\trm -f $(LIBTSSSONAME)\n\t\tln -sf $(LIBTSSVERSIONED) $(LIBTSSSONAME)\n\t\trm -f $(LIBTSS)\n\t\tln -sf $(LIBTSSSONAME) $(LIBTSS)\n\t\t\n# $(LIBTSS): \t$(TSS_OBJS)\n# \t\t$(AR) crs $@ $^\n\n\n# TSS utilities shared library\n\n$(LIBTSSUTILS):\t$(TSSUTILS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -Wl,-soname,$(LIBTSSUTILSSONAME) -o $(LIBTSSUTILSVERSIONED) $(TSSUTILS_OBJS) $(LNLLIBS)\n\t\trm -f $(LIBTSSSUTILSONAME)\n\t\tln -sf $(LIBTSSUTILSVERSIONED) $(LIBTSSUTILSSONAME)\n\t\trm -f $(LIBTSSUTILS)\n\t\tln -sf $(LIBTSSUTILSSONAME) $(LIBTSSUTILS)\n\n# $(LIBTSSUTILS):\t$(TSSUTILS_OBJS)\n# \t\t$(AR) crs $@ $^\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\nclean:\t\t\n\t\trm -f *.o  *~ \t\t\\\n\t\th*.bin\t\t\t\\\n\t\t$(LIBTSSSONAME)\t\t\\\n\t\t$(LIBTSSVERSIONED) \t\\\n\t\t$(LIBTSSUTILSSONAME) \t\\\n\t\t$(LIBTSSUTILSVERSIONED)\t\\\n\t\t$(ALL)\n\n# applications\n\nactivatecredential:\tibmtss/tss.h activatecredential.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) activatecredential.o $(LNALIBS) -o activatecredential\neventextend:\t\teventextend.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eventextend.o $(LNALIBS) -o eventextend\nimaextend:\t\timaextend.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) imaextend.o $(LNALIBS) -o imaextend\ncertify:\t\tibmtss/tss.h certify.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) certify.o $(LNALIBS) -o certify\ncertifycreation:\tibmtss/tss.h certifycreation.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) certifycreation.o $(LNALIBS) -o certifycreation\ncertifyx509:\t\tibmtss/tss.h certifyx509.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) certifyx509.o $(LNALIBS) -lcrypto -o certifyx509\nchangeeps:\t\tibmtss/tss.h changeeps.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) changeeps.o $(LNALIBS) -o changeeps\nchangepps:\t\tibmtss/tss.h changepps.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) changepps.o $(LNALIBS) -o changepps\nclear:\t\t\tibmtss/tss.h clear.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clear.o $(LNALIBS) -o clear\nclearcontrol:\t\tibmtss/tss.h clearcontrol.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clearcontrol.o $(LNALIBS) -o clearcontrol\nclockrateadjust:\tibmtss/tss.h clockrateadjust.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clockrateadjust.o $(LNALIBS) -o clockrateadjust\nclockset:\t\tibmtss/tss.h clockset.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clockset.o $(LNALIBS) -o clockset\ncommit:\t\t\tibmtss/tss.h commit.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) commit.o $(LNALIBS) -o commit\ncontextload:\t\tibmtss/tss.h contextload.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) contextload.o $(LNALIBS) -o contextload\ncontextsave:\t\tibmtss/tss.h contextsave.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) contextsave.o $(LNALIBS) -o contextsave\ncreate:\t\t\tibmtss/tss.h create.o objecttemplates.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) create.o objecttemplates.o $(LNALIBS) -o create\ncreateloaded:\t\tibmtss/tss.h createloaded.o objecttemplates.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createloaded.o objecttemplates.o $(LNALIBS) -o createloaded\ncreateprimary:\t\tibmtss/tss.h createprimary.o objecttemplates.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createprimary.o objecttemplates.o $(LNALIBS) -o createprimary\ndictionaryattacklockreset:\t\tibmtss/tss.h dictionaryattacklockreset.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) dictionaryattacklockreset.o $(LNALIBS) -o dictionaryattacklockreset\ndictionaryattackparameters:\t\tibmtss/tss.h dictionaryattackparameters.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) dictionaryattackparameters.o $(LNALIBS) -o dictionaryattackparameters\nduplicate:\t\tibmtss/tss.h duplicate.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) duplicate.o $(LNALIBS) -o duplicate\neccencrypt:\t\tibmtss/tss.h eccencrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eccencrypt.o $(LNALIBS) -o eccencrypt\neccdecrypt:\t\tibmtss/tss.h eccdecrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eccdecrypt.o $(LNALIBS) -o eccdecrypt\neccparameters:\t\tibmtss/tss.h eccparameters.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eccparameters.o $(LNALIBS) -o eccparameters\necephemeral:\t\tibmtss/tss.h ecephemeral.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ecephemeral.o $(LNALIBS) -o ecephemeral\nencryptdecrypt:\t\tibmtss/tss.h encryptdecrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) encryptdecrypt.o $(LNALIBS) -o encryptdecrypt\neventsequencecomplete:\tibmtss/tss.h eventsequencecomplete.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eventsequencecomplete.o $(LNALIBS) -o eventsequencecomplete\nevictcontrol:\t\tibmtss/tss.h evictcontrol.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) evictcontrol.o $(LNALIBS) -o evictcontrol\nflushcontext:\t\tibmtss/tss.h flushcontext.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) flushcontext.o $(LNALIBS) -o flushcontext\ngetcommandauditdigest:\tibmtss/tss.h getcommandauditdigest.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getcommandauditdigest.o $(LNALIBS) -o getcommandauditdigest\ngetcapability:\t\tibmtss/tss.h getcapability.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getcapability.o $(LNALIBS) -o getcapability\ngetrandom:\t\tibmtss/tss.h getrandom.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getrandom.o $(LNALIBS) -o getrandom\ngettestresult:\t\tibmtss/tss.h gettestresult.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) gettestresult.o $(LNALIBS) -o gettestresult\ngetsessionauditdigest:\tibmtss/tss.h getsessionauditdigest.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getsessionauditdigest.o $(LNALIBS) -o getsessionauditdigest\ngettime:\t\tibmtss/tss.h gettime.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) gettime.o $(LNALIBS) -o gettime\nhashsequencestart:\tibmtss/tss.h hashsequencestart.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hashsequencestart.o $(LNALIBS) -o hashsequencestart\nhash:\t\t\tibmtss/tss.h hash.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hash.o $(LNALIBS) -o hash\nhierarchycontrol:\tibmtss/tss.h hierarchycontrol.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hierarchycontrol.o $(LNALIBS) -o hierarchycontrol\nhierarchychangeauth:\tibmtss/tss.h hierarchychangeauth.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hierarchychangeauth.o $(LNALIBS) -o hierarchychangeauth\nhmac:\t\t\tibmtss/tss.h hmac.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hmac.o $(LNALIBS) -o hmac\nhmacstart:\t\tibmtss/tss.h hmacstart.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hmacstart.o $(LNALIBS) -o hmacstart\nimport:\t\t\tibmtss/tss.h import.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) import.o $(LNALIBS) -o import\nimportpem:\t\tibmtss/tss.h importpem.o objecttemplates.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) importpem.o objecttemplates.o $(LNALIBS) -o importpem\nload:\t\t\tibmtss/tss.h load.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) load.o $(LNALIBS) -o load\nloadexternal:\t\tibmtss/tss.h loadexternal.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) loadexternal.o $(LNALIBS) -o loadexternal\nmakecredential:\t\tibmtss/tss.h makecredential.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) makecredential.o $(LNALIBS) -o makecredential\nnvcertify:\t\tibmtss/tss.h nvcertify.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvcertify.o $(LNALIBS) -o nvcertify\nnvchangeauth:\t\tibmtss/tss.h nvchangeauth.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvchangeauth.o $(LNALIBS) -o nvchangeauth\nnvdefinespace:\t\tibmtss/tss.h nvdefinespace.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvdefinespace.o $(LNALIBS) -o nvdefinespace\nnvextend:\t\tibmtss/tss.h nvextend.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvextend.o $(LNALIBS) -o nvextend\nnvglobalwritelock:\tibmtss/tss.h nvglobalwritelock.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvglobalwritelock.o $(LNALIBS) -o nvglobalwritelock\nnvincrement:\t\tibmtss/tss.h nvincrement.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvincrement.o $(LNALIBS) -o nvincrement\nnvread:\t\t\tibmtss/tss.h nvread.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvread.o $(LNALIBS) -o nvread\nnvreadlock:\t\tibmtss/tss.h nvreadlock.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvreadlock.o $(LNALIBS) -o nvreadlock\nnvreadpublic:\t\tibmtss/tss.h nvreadpublic.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvreadpublic.o $(LNALIBS) -o nvreadpublic\nnvsetbits:\t\tibmtss/tss.h nvsetbits.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvsetbits.o $(LNALIBS) -o nvsetbits\nnvundefinespace:\tibmtss/tss.h nvundefinespace.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvundefinespace.o $(LNALIBS) -o nvundefinespace\nnvundefinespacespecial:\tibmtss/tss.h nvundefinespacespecial.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvundefinespacespecial.o $(LNALIBS) -o nvundefinespacespecial\nnvwrite:\t\tibmtss/tss.h nvwrite.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvwrite.o $(LNALIBS) -o nvwrite\nnvwritelock:\t\tibmtss/tss.h nvwritelock.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvwritelock.o $(LNALIBS) -o nvwritelock\nobjectchangeauth:\tibmtss/tss.h objectchangeauth.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) objectchangeauth.o $(LNALIBS) -o objectchangeauth\npcrallocate: \t\tibmtss/tss.h pcrallocate.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrallocate.o $(LNALIBS) -o pcrallocate\npcrevent: \t\tibmtss/tss.h pcrevent.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrevent.o $(LNALIBS) -o pcrevent\npcrextend: \t\tibmtss/tss.h pcrextend.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrextend.o $(LNALIBS) -o pcrextend\npcrread: \t\tibmtss/tss.h pcrread.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrread.o $(LNALIBS) -o pcrread\npcrreset: \t\tibmtss/tss.h pcrreset.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrreset.o $(LNALIBS) -o pcrreset\npolicyauthorize:\tibmtss/tss.h policyauthorize.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyauthorize.o $(LNALIBS) -o policyauthorize\npolicyauthvalue:\tibmtss/tss.h policyauthvalue.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyauthvalue.o $(LNALIBS) -o policyauthvalue\npolicycapability:\tibmtss/tss.h policycapability.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycapability.o $(LNALIBS) -o policycapability\npolicycommandcode:\tibmtss/tss.h policycommandcode.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycommandcode.o $(LNALIBS) -o policycommandcode\npolicycphash:\t\tibmtss/tss.h policycphash.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycphash.o $(LNALIBS) -o policycphash\npolicynamehash:\t\tibmtss/tss.h policynamehash.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policynamehash.o $(LNALIBS) -o policynamehash\npolicycountertimer:\tibmtss/tss.h policycountertimer.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycountertimer.o $(LNALIBS) -o policycountertimer\npolicyduplicationselect:\tibmtss/tss.h policyduplicationselect.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyduplicationselect.o $(LNALIBS) -o policyduplicationselect\npolicygetdigest:\tibmtss/tss.h policygetdigest.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policygetdigest.o $(LNALIBS) -o policygetdigest\npolicymaker:\t\tibmtss/tss.h policymaker.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policymaker.o $(LNALIBS) -o policymaker\npolicymakerpcr:\t\tibmtss/tss.h policymakerpcr.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policymakerpcr.o $(LNALIBS) -o policymakerpcr\npolicyauthorizenv:\tibmtss/tss.h policyauthorizenv.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyauthorizenv.o $(LNALIBS) -o policyauthorizenv\npolicynv:\t\tibmtss/tss.h policynv.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policynv.o $(LNALIBS) -o policynv\npolicynvwritten:\tibmtss/tss.h policynvwritten.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policynvwritten.o $(LNALIBS) -o policynvwritten\npolicyor:\t\tibmtss/tss.h policyor.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyor.o $(LNALIBS) -o policyor\npolicyparameters:\tibmtss/tss.h policyparameters.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyparameters.o $(LNALIBS) -o policyparameters\npolicypassword:\t\tibmtss/tss.h policypassword.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policypassword.o $(LNALIBS) -o policypassword\npolicypcr:\t\tibmtss/tss.h policypcr.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policypcr.o $(LNALIBS) -o policypcr\npolicyrestart:\t\tibmtss/tss.h policyrestart.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyrestart.o $(LNALIBS) -o policyrestart\npolicysigned:\t\tibmtss/tss.h policysigned.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policysigned.o $(LNALIBS) -o policysigned\npolicysecret:\t\tibmtss/tss.h policysecret.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policysecret.o $(LNALIBS) -o policysecret\npolicytemplate:\t\tibmtss/tss.h policytemplate.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policytemplate.o $(LNALIBS) -o policytemplate\npolicyticket:\t\tibmtss/tss.h policyticket.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyticket.o $(LNALIBS) -o policyticket\nquote:\t\t\tibmtss/tss.h quote.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) quote.o $(LNALIBS) -o quote\npowerup:\t\tibmtss/tss.h powerup.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) powerup.o $(LNALIBS) -o powerup\nreadclock:\t\tibmtss/tss.h readclock.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) readclock.o $(LNALIBS) -o readclock\nreadpublic:\t\tibmtss/tss.h readpublic.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) readpublic.o $(LNALIBS) -o readpublic\nreturncode:\t\tibmtss/tss.h returncode.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) returncode.o $(LNALIBS) -o returncode\nrewrap:\t\t\tibmtss/tss.h rewrap.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) rewrap.o $(LNALIBS) -o rewrap\nrsadecrypt: \t\tibmtss/tss.h rsadecrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) rsadecrypt.o $(LNALIBS) -o rsadecrypt\nrsaencrypt: \t\tibmtss/tss.h rsaencrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) rsaencrypt.o $(LNALIBS) -o rsaencrypt\nsequenceupdate:\t\tibmtss/tss.h sequenceupdate.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) sequenceupdate.o $(LNALIBS) -o sequenceupdate\nsequencecomplete:\tibmtss/tss.h sequencecomplete.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) sequencecomplete.o $(LNALIBS) -o sequencecomplete\nsetprimarypolicy:\tibmtss/tss.h setprimarypolicy.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) setprimarypolicy.o $(LNALIBS) -o setprimarypolicy\nsetcommandcodeauditstatus:\tibmtss/tss.h setcommandcodeauditstatus.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) setcommandcodeauditstatus.o $(LNALIBS) -o setcommandcodeauditstatus\nshutdown:\t\tibmtss/tss.h shutdown.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) shutdown.o $(LNALIBS) -o shutdown\nsign:\t\t\tibmtss/tss.h sign.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) sign.o $(LNALIBS) -o sign\nstartauthsession:\tibmtss/tss.h startauthsession.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) startauthsession.o $(LNALIBS) -o startauthsession\nstartup:\t\tibmtss/tss.h startup.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) startup.o $(LNALIBS) -o startup\nstirrandom:\t\tibmtss/tss.h stirrandom.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) stirrandom.o $(LNALIBS) -o stirrandom\nunseal:\t\t\tibmtss/tss.h unseal.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) unseal.o $(LNALIBS) -o unseal\nverifysignature:\tibmtss/tss.h verifysignature.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) verifysignature.o $(LNALIBS) -o verifysignature\nzgen2phase:\t\tibmtss/tss.h zgen2phase.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) zgen2phase.o $(LNALIBS) -o zgen2phase\nsignapp:\t\tibmtss/tss.h signapp.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) signapp.o $(LNALIBS) -o signapp\nwriteapp:\t\tibmtss/tss.h writeapp.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) writeapp.o $(LNALIBS) -o writeapp\ntimepacket:\t\tibmtss/tss.h timepacket.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) timepacket.o $(LNALIBS) -o timepacket\ncreateek:\t\tcreateek.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createek.o $(LNALIBS) -o createek\ncreateekcert:\t\tcreateekcert.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createekcert.o $(LNALIBS) -o createekcert\ntpm2pem:\t\ttpm2pem.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpm2pem.o $(LNALIBS) -o tpm2pem\ntpmpublic2eccpoint:\ttpmpublic2eccpoint.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpmpublic2eccpoint.o $(LNALIBS) -o tpmpublic2eccpoint\nntc2getconfig:\t\tntc2getconfig.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ntc2getconfig.o $(LNALIBS) -o ntc2getconfig\nntc2preconfig:\t\tntc2preconfig.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ntc2preconfig.o $(LNALIBS) -o ntc2preconfig\nntc2lockconfig:\t\tntc2lockconfig.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ntc2lockconfig.o $(LNALIBS) -o ntc2lockconfig\npublicname:\t\tpublicname.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) publicname.o $(LNALIBS) -o publicname\ngetcryptolibrary:\tgetcryptolibrary.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getcryptolibrary.o $(LNALIBS) -o getcryptolibrary\nprintattr:\t\tprintattr.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) printattr.o $(LNALIBS) -o printattr\ntpmcmd:\t\t\ttpmcmd.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpmcmd.o $(LNALIBS) -o tpmcmd\ntpmproxy:\t\ttpmproxy.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpmproxy.o $(LNALIBS) -o tpmproxy\n\n# for applications, not for TSS library\n\n%.o:\t\t%.c ibmtss/tss.h \n\t\t$(CC) $(CCFLAGS) $(CCAFLAGS) $< -o $@\n\n"
  },
  {
    "path": "ibmtss-ftpm/makefiletpmc",
    "content": "#################################################################################\n#\t\t\t\t\t\t\t\t\t\t#\n#\t\tLinux TPM 1.2 TSS and TPM 2.0 TSS and Utilities Makefile\t#\n#\t\t\t     Written by Ken Goldman\t\t\t\t#\n#\t\t       IBM Thomas J. Watson Research Center\t\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n# (c) Copyright IBM Corporation 2018 - 2024\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# All rights reserved.\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistribution and use in source and binary forms, with or without\t\t#\n# modification, are permitted provided that the following conditions are\t#\n# met:\t\t\t\t\t\t\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions of source code must retain the above copyright notice,\t#\n# this list of conditions and the following disclaimer.\t\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Redistributions in binary form must reproduce the above copyright\t\t#\n# notice, this list of conditions and the following disclaimer in the\t\t#\n# documentation and/or other materials provided with the distribution.\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# Neither the names of the IBM Corporation nor the names of its\t\t\t#\n# contributors may be used to endorse or promote products derived from\t\t#\n# this software without specific prior written permission.\t\t\t#\n# \t\t\t\t\t\t\t\t\t\t#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t#\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t#\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t\t#\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t#\n# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t#\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t#\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t\t#\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t\t#\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t#\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t\t#\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t#\n#\t\t\t\t\t\t\t\t\t\t#\n#################################################################################\n\n# C compiler\n\nCC = /usr/bin/gcc\n\n# compile - common flags for TSS library and applications\n\n# no-deprecated-declarations silences the compiler until the openssl\n# 3.0 port is complete.\n\nCCFLAGS += \t-DTPM_POSIX -Wno-deprecated-declarations\n\n# example of pointing to a locally built openssl 1.1\n# CCFLAGS += \t-I/home/kgold/openssl/include\n\n# compile - for TSS library\n\n# include the hardening flag PIC needed for compiling for dynamic\n# linking\n\nCCLFLAGS += \t-I. \t\t\\\n\t\t-fPIC\t\t\\\n\t\t-DTPM_TPM20\t\\\n\t\t-DTPM_TPM12\n\n# to compile out printf's.  Regression test will fail because it tries\n# to print a structure -DTPM_TSS_NO_PRINT\n\n# example of changing the default interface type\n#\t-DTPM_INTERFACE_TYPE_DEFAULT=\"\\\"dev\\\"\"\n\n# compile - for applications\n\n# include the hardening flag PIE needed for compiling for\n# static linking\n\nCCAFLAGS += \t-I.\t\t\\\n\t\t-DTPM_TPM20\t\\\n\t\t-DTPM_TPM12\t\\\n\t\t-fPIE\n\n# link - common flags flags TSS library and applications\n\nLNFLAGS += \t-DTPM_POSIX\t\t\\\n\t\t-L.\n\n# This seems to be required on some Ubuntu distros due to an issue with the gold linker\n#\t\t-fuse-ld=bfd\n\n# example of pointing to a locally built openssl 1.1\n# LNFLAGS +=\t -L/home/kgold/openssl\n# This also requires setting the environment variable LD_LIBRARY_PATH.  E.g.,\n# setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/home/kgold/openssl\n\n# link - for TSS library\n\n# hardening flags for linking shared objects\nLNLFLAGS += -shared -Wl,-z,now\n\n# This is an alternative to using the bfd linker on Ubuntu\nLNLLIBS += -lcrypto\n\n# link - for applications, TSS path, TSS and OpenSSl libraries\n\n# hardening flags for linking executables\nLNAFLAGS += -pie -Wl,-z,now -Wl,-rpath,.\n\nLNALIBS +=  -libmtssutils -libmtss\n\n# shared library\n\n# versioned shared library\nLIBTSSVERSIONED=libibmtss.so.2.3\n\n# soname field of the shared library\n# which will be made symbolic link to the versioned shared library\n# this is used to provide version backward-compatibility information\nLIBTSSSONAME=libibmtss.so.2\n\n# symbolic link to the versioned shared library\n# this allows linking to the shared library with '-libmtss'\n\nos := $(shell uname -o)\nifeq ($(os),Cygwin)\n  LIBTSS=libibmtss.dll\nelse\n  LIBTSS=libibmtss.so\nendif\n\n# TSS utilities shared library\n\nLIBTSSUTILSVERSIONED=libibmtssutils.so.2.3\nLIBTSSUTILSSONAME=libibmtssutils.so.2\nLIBTSSUTILS=libibmtssutils.so\n\n# executable extension\n\nEXE =\n\n#\n\n\nTSS_HEADERS=\n\n# default TSS library\n\nTSS_OBJS = \ttssfile.o \t\t\\\n\t\ttsscryptoh.o \t\t\\\n\t\ttsscrypto.o \t\t\\\n\t\ttssprintcmd.o\n\nTSSUTILS_OBJS = cryptoutils.o\t\\\n\t\tekutils.o\t\\\n\t\timalib.o\t\\\n\t\teventlib.o\t\\\n\t\tefilib.o\n\n# common to all builds\n\ninclude makefile-common\ninclude makefile-common12\ninclude makefile-common20\n\nALL += tpmproxy$(EXE)\n\n# default build target\n\nall:\t$(ALL)\n\n# TSS shared library source\n\ntss.o: \t\t$(TSS_HEADERS) tss.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss.c\ntssauth.o: \t$(TSS_HEADERS) tssauth.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth.c\ntssproperties.o: $(TSS_HEADERS) tssproperties.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssproperties.c\ntssmarshal.o: \t$(TSS_HEADERS) tssmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssmarshal.c\ntsscryptoh.o: \t$(TSS_HEADERS) tsscryptoh.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscryptoh.c\ntsscrypto.o: \t$(TSS_HEADERS) tsscrypto.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsscrypto.c\ntssutils.o: \t$(TSS_HEADERS) tssutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssutils.c\ntssfile.o: \t$(TSS_HEADERS) tssfile.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssfile.c\ntsssocket.o: \t$(TSS_HEADERS) tsssocket.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsssocket.c\ntssdev.o: \t$(TSS_HEADERS) tssdev.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssdev.c\ntsstransmit.o: \t$(TSS_HEADERS) tsstransmit.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tsstransmit.c\ntssresponsecode.o: $(TSS_HEADERS) tssresponsecode.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssresponsecode.c\ntssccattributes.o: $(TSS_HEADERS) tssccattributes.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssccattributes.c\ntssprint.o: \t$(TSS_HEADERS) tssprint.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprint.c\ntssprintcmd.o: \t$(TSS_HEADERS) tssprintcmd.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssprintcmd.c\nUnmarshal.o: \t$(TSS_HEADERS) Unmarshal.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Unmarshal.c\nCommands.o: \t$(TSS_HEADERS) Commands.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Commands.c\nCommandAttributeData.o: \t$(TSS_HEADERS) CommandAttributeData.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) CommandAttributeData.c\nntc2lib.o:\t$(TSS_HEADERS) ntc2lib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ntc2lib.c\ntssntc.o:\t$(TSS_HEADERS) tssntc.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssntc.c\n\n# TPM 2.0\n\ntss20.o: \t$(TSS_HEADERS) tss20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss20.c\ntssauth20.o: \t$(TSS_HEADERS) tssauth20.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth20.c\n# TPM 1.2\n\ntss12.o: \t$(TSS_HEADERS) tss12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tss12.c\ntssauth12.o: \t$(TSS_HEADERS) tssauth12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssauth12.c\ntssmarshal12.o:\t$(TSS_HEADERS) tssmarshal12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssmarshal12.c\nUnmarshal12.o: \t$(TSS_HEADERS) Unmarshal12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Unmarshal12.c\nCommands12.o: \t$(TSS_HEADERS) Commands12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) Commands12.c\ntssccattributes12.o: $(TSS_HEADERS) tssccattributes12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) tssccattributes12.c\nCommandAttributeData12.o: \t$(TSS_HEADERS) CommandAttributeData12.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) CommandAttributeData12.c\n\n# TSS utilities shared library source\n\ncryptoutils.o: \t$(TSS_HEADERS) cryptoutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) cryptoutils.c\nekutils.o: \t$(TSS_HEADERS) ekutils.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) ekutils.c\nimalib.o: \t$(TSS_HEADERS) imalib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) imalib.c\neventlib.o: \t$(TSS_HEADERS) eventlib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) eventlib.c\nefilib.o: \t$(TSS_HEADERS) efilib.c\n\t\t$(CC) $(CCFLAGS) $(CCLFLAGS) efilib.c\n\n# TSS shared library build\n\n$(LIBTSS): \t$(TSS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -Wl,-soname,$(LIBTSSSONAME) -o $(LIBTSSVERSIONED) \\\n\t\t\t$(TSS_OBJS) $(LNLLIBS)\n\t\trm -f $(LIBTSSSONAME)\n\t\tln -sf $(LIBTSSVERSIONED) $(LIBTSSSONAME)\n\t\trm -f $(LIBTSS)\n\t\tln -sf $(LIBTSSSONAME) $(LIBTSS)\n\n# TSS utilities shared library\n\n$(LIBTSSUTILS):\t$(TSSUTILS_OBJS)\n\t\t$(CC) $(LNFLAGS) $(LNLFLAGS) -Wl,-soname,$(LIBTSSUTILSSONAME) -o $(LIBTSSUTILSVERSIONED) \\\n\t\t\t$(TSSUTILS_OBJS) $(LNLLIBS)\n\t\trm -f $(LIBTSSSUTILSONAME)\n\t\tln -sf $(LIBTSSUTILSVERSIONED) $(LIBTSSUTILSSONAME)\n\t\trm -f $(LIBTSSUTILS)\n\t\tln -sf $(LIBTSSUTILSSONAME) $(LIBTSSUTILS)\n\n.PHONY:\t\tclean\n.PRECIOUS:\t%.o\n\nclean:\n\t\trm -f *.o  *~ \t\t\\\n\t\th*.bin\t\t\t\\\n\t\t$(LIBTSSSONAME)\t\t\\\n\t\t$(LIBTSSVERSIONED) \t\\\n\t\t$(LIBTSSUTILSSONAME) \t\\\n\t\t$(LIBTSSUTILSVERSIONED)\t\\\n\t\t$(ALL)\n\n# applications\n\nactivatecredential:\tibmtss/tss.h activatecredential.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) activatecredential.o $(LNALIBS) -o activatecredential\neventextend:\t\teventextend.o eventlib.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eventextend.o $(LNALIBS) -o eventextend\nimaextend:\t\timaextend.o imalib.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) imaextend.o $(LNALIBS) -o imaextend\ncertify:\t\tibmtss/tss.h certify.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) certify.o $(LNALIBS) -o certify\ncertifycreation:\tibmtss/tss.h certifycreation.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) certifycreation.o $(LNALIBS) -o certifycreation\ncertifyx509:\t\tibmtss/tss.h certifyx509.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) certifyx509.o $(LNALIBS) -lcrypto -o certifyx509\nchangeeps:\t\tibmtss/tss.h changeeps.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) changeeps.o $(LNALIBS) -o changeeps\nchangepps:\t\tibmtss/tss.h changepps.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) changepps.o $(LNALIBS) -o changepps\nclear:\t\t\tibmtss/tss.h clear.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clear.o $(LNALIBS) -o clear\nclearcontrol:\t\tibmtss/tss.h clearcontrol.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clearcontrol.o $(LNALIBS) -o clearcontrol\nclockrateadjust:\tibmtss/tss.h clockrateadjust.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clockrateadjust.o $(LNALIBS) -o clockrateadjust\nclockset:\t\tibmtss/tss.h clockset.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) clockset.o $(LNALIBS) -o clockset\ncommit:\t\t\tibmtss/tss.h commit.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) commit.o $(LNALIBS) -o commit\ncontextload:\t\tibmtss/tss.h contextload.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) contextload.o $(LNALIBS) -o contextload\ncontextsave:\t\tibmtss/tss.h contextsave.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) contextsave.o $(LNALIBS) -o contextsave\ncreate:\t\t\tibmtss/tss.h create.o objecttemplates.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) create.o objecttemplates.o $(LNALIBS) -o create\ncreateloaded:\t\tibmtss/tss.h createloaded.o objecttemplates.o $(LIBTSS) $(LIBTTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createloaded.o objecttemplates.o $(LNALIBS) -o createloaded\ncreateprimary:\t\tibmtss/tss.h createprimary.o objecttemplates.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createprimary.o objecttemplates.o $(LNALIBS) -o createprimary\ndictionaryattacklockreset:\t\tibmtss/tss.h dictionaryattacklockreset.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) dictionaryattacklockreset.o $(LNALIBS) -o dictionaryattacklockreset\ndictionaryattackparameters:\t\tibmtss/tss.h dictionaryattackparameters.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) dictionaryattackparameters.o $(LNALIBS) -o dictionaryattackparameters\nduplicate:\t\tibmtss/tss.h duplicate.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) duplicate.o $(LNALIBS) -o duplicate\neccencrypt:\t\tibmtss/tss.h eccencrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eccencrypt.o $(LNALIBS) -o eccencrypt\neccdecrypt:\t\tibmtss/tss.h eccdecrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eccdecrypt.o $(LNALIBS) -o eccdecrypt\neccparameters:\t\tibmtss/tss.h eccparameters.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eccparameters.o $(LNALIBS) -o eccparameters\necephemeral:\t\tibmtss/tss.h ecephemeral.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ecephemeral.o $(LNALIBS) -o ecephemeral\nencryptdecrypt:\t\tibmtss/tss.h encryptdecrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) encryptdecrypt.o $(LNALIBS) -o encryptdecrypt\neventsequencecomplete:\tibmtss/tss.h eventsequencecomplete.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) eventsequencecomplete.o $(LNALIBS) -o eventsequencecomplete\nevictcontrol:\t\tibmtss/tss.h evictcontrol.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) evictcontrol.o $(LNALIBS) -o evictcontrol\nflushcontext:\t\tibmtss/tss.h flushcontext.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) flushcontext.o $(LNALIBS) -o flushcontext\ngetcommandauditdigest:\tibmtss/tss.h getcommandauditdigest.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getcommandauditdigest.o $(LNALIBS) -o getcommandauditdigest\ngetcapability:\t\tibmtss/tss.h getcapability.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getcapability.o $(LNALIBS) -o getcapability\ngetrandom:\t\tibmtss/tss.h getrandom.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getrandom.o $(LNALIBS) -o getrandom\ngettestresult:\t\tibmtss/tss.h gettestresult.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) gettestresult.o $(LNALIBS) -o gettestresult\ngetsessionauditdigest:\tibmtss/tss.h getsessionauditdigest.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getsessionauditdigest.o $(LNALIBS) -o getsessionauditdigest\ngettime:\t\tibmtss/tss.h gettime.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) gettime.o $(LNALIBS) -o gettime\nhashsequencestart:\tibmtss/tss.h hashsequencestart.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hashsequencestart.o $(LNALIBS) -o hashsequencestart\nhash:\t\t\tibmtss/tss.h hash.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hash.o $(LNALIBS) -o hash\nhierarchycontrol:\tibmtss/tss.h hierarchycontrol.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hierarchycontrol.o $(LNALIBS) -o hierarchycontrol\nhierarchychangeauth:\tibmtss/tss.h hierarchychangeauth.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hierarchychangeauth.o $(LNALIBS) -o hierarchychangeauth\nhmac:\t\t\tibmtss/tss.h hmac.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hmac.o $(LNALIBS) -o hmac\nhmacstart:\t\tibmtss/tss.h hmacstart.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) hmacstart.o $(LNALIBS) -o hmacstart\nimport:\t\t\tibmtss/tss.h import.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) import.o $(LNALIBS) -o import\nimportpem:\t\tibmtss/tss.h importpem.o objecttemplates.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) importpem.o objecttemplates.o $(LNALIBS) -o importpem\nload:\t\t\tibmtss/tss.h load.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) load.o $(LNALIBS) -o load\nloadexternal:\t\tibmtss/tss.h loadexternal.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) loadexternal.o $(LNALIBS) -o loadexternal\nmakecredential:\t\tibmtss/tss.h makecredential.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) makecredential.o $(LNALIBS) -o makecredential\nnvcertify:\t\tibmtss/tss.h nvcertify.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvcertify.o $(LNALIBS) -o nvcertify\nnvchangeauth:\t\tibmtss/tss.h nvchangeauth.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvchangeauth.o $(LNALIBS) -o nvchangeauth\nnvdefinespace:\t\tibmtss/tss.h nvdefinespace.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvdefinespace.o $(LNALIBS) -o nvdefinespace\nnvextend:\t\tibmtss/tss.h nvextend.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvextend.o $(LNALIBS) -o nvextend\nnvglobalwritelock:\tibmtss/tss.h nvglobalwritelock.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvglobalwritelock.o $(LNALIBS) -o nvglobalwritelock\nnvincrement:\t\tibmtss/tss.h nvincrement.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvincrement.o $(LNALIBS) -o nvincrement\nnvread:\t\t\tibmtss/tss.h nvread.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvread.o $(LNALIBS) -o nvread\nnvreadlock:\t\tibmtss/tss.h nvreadlock.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvreadlock.o $(LNALIBS) -o nvreadlock\nnvreadpublic:\t\tibmtss/tss.h nvreadpublic.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvreadpublic.o $(LNALIBS) -o nvreadpublic\nnvsetbits:\t\tibmtss/tss.h nvsetbits.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvsetbits.o $(LNALIBS) -o nvsetbits\nnvundefinespace:\tibmtss/tss.h nvundefinespace.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvundefinespace.o $(LNALIBS) -o nvundefinespace\nnvundefinespacespecial:\tibmtss/tss.h nvundefinespacespecial.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvundefinespacespecial.o $(LNALIBS) -o nvundefinespacespecial\nnvwrite:\t\tibmtss/tss.h nvwrite.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvwrite.o $(LNALIBS) -o nvwrite\nnvwritelock:\t\tibmtss/tss.h nvwritelock.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) nvwritelock.o $(LNALIBS) -o nvwritelock\nobjectchangeauth:\tibmtss/tss.h objectchangeauth.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) objectchangeauth.o $(LNALIBS) -o objectchangeauth\npcrallocate: \t\tibmtss/tss.h pcrallocate.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrallocate.o $(LNALIBS) -o pcrallocate\npcrevent: \t\tibmtss/tss.h pcrevent.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrevent.o $(LNALIBS) -o pcrevent\npcrextend: \t\tibmtss/tss.h pcrextend.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrextend.o $(LNALIBS) -o pcrextend\npcrread: \t\tibmtss/tss.h pcrread.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrread.o $(LNALIBS) -o pcrread\npcrreset: \t\tibmtss/tss.h pcrreset.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) pcrreset.o $(LNALIBS) -o pcrreset\npolicyauthorize:\tibmtss/tss.h policyauthorize.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyauthorize.o $(LNALIBS) -o policyauthorize\npolicyauthvalue:\tibmtss/tss.h policyauthvalue.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyauthvalue.o $(LNALIBS) -o policyauthvalue\npolicycapability:\tibmtss/tss.h policycapability.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycapability.o $(LNALIBS) -o policycapability\npolicycommandcode:\tibmtss/tss.h policycommandcode.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycommandcode.o $(LNALIBS) -o policycommandcode\npolicycphash:\t\tibmtss/tss.h policycphash.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycphash.o $(LNALIBS) -o policycphash\npolicynamehash:\t\tibmtss/tss.h policynamehash.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policynamehash.o $(LNALIBS) -o policynamehash\npolicycountertimer:\tibmtss/tss.h policycountertimer.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policycountertimer.o $(LNALIBS) -o policycountertimer\npolicyduplicationselect:\tibmtss/tss.h policyduplicationselect.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyduplicationselect.o $(LNALIBS) -o policyduplicationselect\npolicygetdigest:\tibmtss/tss.h policygetdigest.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policygetdigest.o $(LNALIBS) -o policygetdigest\npolicymaker:\t\tibmtss/tss.h policymaker.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policymaker.o $(LNALIBS) -o policymaker\npolicymakerpcr:\t\tibmtss/tss.h policymakerpcr.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policymakerpcr.o $(LNALIBS) -o policymakerpcr\npolicyauthorizenv:\tibmtss/tss.h policyauthorizenv.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyauthorizenv.o $(LNALIBS) -o policyauthorizenv\npolicynv:\t\tibmtss/tss.h policynv.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policynv.o $(LNALIBS) -o policynv\npolicynvwritten:\tibmtss/tss.h policynvwritten.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policynvwritten.o $(LNALIBS) -o policynvwritten\npolicyor:\t\tibmtss/tss.h policyor.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyor.o $(LNALIBS) -o policyor\npolicyparameters:\tibmtss/tss.h policyparameters.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyparameters.o $(LNALIBS) -o policyparameters\npolicypassword:\t\tibmtss/tss.h policypassword.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policypassword.o $(LNALIBS) -o policypassword\npolicypcr:\t\tibmtss/tss.h policypcr.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policypcr.o $(LNALIBS) -o policypcr\npolicyrestart:\t\tibmtss/tss.h policyrestart.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyrestart.o $(LNALIBS) -o policyrestart\npolicysigned:\t\tibmtss/tss.h policysigned.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policysigned.o $(LNALIBS) -o policysigned\npolicysecret:\t\tibmtss/tss.h policysecret.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policysecret.o $(LNALIBS) -o policysecret\npolicytemplate:\t\tibmtss/tss.h policytemplate.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policytemplate.o $(LNALIBS) -o policytemplate\npolicyticket:\t\tibmtss/tss.h policyticket.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) policyticket.o $(LNALIBS) -o policyticket\nquote:\t\t\tibmtss/tss.h quote.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) quote.o $(LNALIBS) -o quote\npowerup:\t\tibmtss/tss.h powerup.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) powerup.o $(LNALIBS) -o powerup\nreadclock:\t\tibmtss/tss.h readclock.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) readclock.o $(LNALIBS) -o readclock\nreadpublic:\t\tibmtss/tss.h readpublic.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) readpublic.o $(LNALIBS) -o readpublic\nreturncode:\t\tibmtss/tss.h returncode.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) returncode.o $(LNALIBS) -o returncode\nrewrap:\t\t\tibmtss/tss.h rewrap.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) rewrap.o $(LNALIBS) -o rewrap\nrsadecrypt: \t\tibmtss/tss.h rsadecrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) rsadecrypt.o $(LNALIBS) -o rsadecrypt\nrsaencrypt: \t\tibmtss/tss.h rsaencrypt.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) rsaencrypt.o $(LNALIBS) -o rsaencrypt\nsequenceupdate:\t\tibmtss/tss.h sequenceupdate.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) sequenceupdate.o $(LNALIBS) -o sequenceupdate\nsequencecomplete:\tibmtss/tss.h sequencecomplete.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) sequencecomplete.o $(LNALIBS) -o sequencecomplete\nsetprimarypolicy:\tibmtss/tss.h setprimarypolicy.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) setprimarypolicy.o $(LNALIBS) -o setprimarypolicy\nsetcommandcodeauditstatus:\tibmtss/tss.h setcommandcodeauditstatus.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) setcommandcodeauditstatus.o $(LNALIBS) -o setcommandcodeauditstatus\nshutdown:\t\tibmtss/tss.h shutdown.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) shutdown.o $(LNALIBS) -o shutdown\nsign:\t\t\tibmtss/tss.h sign.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) sign.o $(LNALIBS) -o sign\nstartauthsession:\tibmtss/tss.h startauthsession.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) startauthsession.o $(LNALIBS) -o startauthsession\nstartup:\t\tibmtss/tss.h startup.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) startup.o $(LNALIBS) -o startup\nstirrandom:\t\tibmtss/tss.h stirrandom.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) stirrandom.o $(LNALIBS) -o stirrandom\nunseal:\t\t\tibmtss/tss.h unseal.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) unseal.o $(LNALIBS) -o unseal\nverifysignature:\tibmtss/tss.h verifysignature.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) verifysignature.o $(LNALIBS) -o verifysignature\nzgen2phase:\t\tibmtss/tss.h zgen2phase.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) zgen2phase.o $(LNALIBS) -o zgen2phase\nsignapp:\t\tibmtss/tss.h signapp.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) signapp.o $(LNALIBS) -o signapp\nwriteapp:\t\tibmtss/tss.h writeapp.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) writeapp.o $(LNALIBS) -o writeapp\ntimepacket:\t\tibmtss/tss.h timepacket.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) timepacket.o $(LNALIBS) -o timepacket\ncreateek:\t\tcreateek.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createek.o $(LNALIBS) -o createek\ncreateekcert:\t\tcreateekcert.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) createekcert.o $(LNALIBS) -o createekcert\ntpm2pem:\t\ttpm2pem.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpm2pem.o $(LNALIBS) -o tpm2pem\ntpmpublic2eccpoint:\ttpmpublic2eccpoint.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpmpublic2eccpoint.o $(LNALIBS) -o tpmpublic2eccpoint\nntc2getconfig:\t\tntc2getconfig.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ntc2getconfig.o $(LNALIBS) -o ntc2getconfig\nntc2preconfig:\t\tntc2preconfig.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ntc2preconfig.o $(LNALIBS) -o ntc2preconfig\nntc2lockconfig:\t\tntc2lockconfig.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) ntc2lockconfig.o $(LNALIBS) -o ntc2lockconfig\npublicname:\t\tpublicname.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) publicname.o $(LNALIBS) -o publicname\ngetcryptolibrary:\tgetcryptolibrary.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) getcryptolibrary.o $(LNALIBS) -o getcryptolibrary\nprintattr:\t\tprintattr.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) printattr.o $(LNALIBS) -o printattr\ntpmcmd:\t\t\ttpmcmd.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpmcmd.o $(LNALIBS) -o tpmcmd\ntpmproxy:\t\ttpmproxy.o $(LIBTSS) $(LIBTSSUTILS)\n\t\t\t$(CC) $(LNFLAGS) $(LNAFLAGS) tpmproxy.o $(LNALIBS) -o tpmproxy\n\n# for applications, not for TSS library\n\n%.o:\t\t%.c ibmtss/tss.h\n\t\t$(CC) $(CCFLAGS) $(CCAFLAGS) $< -o $@\n"
  },
  {
    "path": "ibmtss-ftpm/ntc2getconfig.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Nuvoton GetConfig \t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n   Gets the Nuvoton preConfig registers.  Optionally checks 'lock' and several\n   hard coded configurations.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\n#include \"ntc2lib.h\"\n\nstatic void printUsage(void);\nstatic void printHexResponse(NTC2_CFG_STRUCT *preConfig);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    \t\t/* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NTC2_GetConfig_Out \t\tout;\n    NTC2_CFG_STRUCT \t\tpreConfig;\t\n    int \t\t\tverify = FALSE;\n    int \t\t\tverifyLocked = FALSE;\n    int\t\t\t\tp8 = FALSE;\n    int\t\t\t\tp9 = FALSE;\n  \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-verify\") == 0) {\n\t    verify = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-verifylocked\") == 0) {\n\t    verify = TRUE;\n\t    verifyLocked = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-p8\") == 0) {\n\t    p8 = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-p9\") == 0) {\n\t    p9 = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (verify) {\n\tif (!p8 && !p9) {\n\t    printf(\"Either -p8 or -p9 must be specified\\n\");\n\t    printUsage();\n\t}\n\tif (p8 && p9) {\n\t    printf(\"-p8 and -p9 cannot both be specified\\n\");\n\t    printUsage();\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t NULL,\n\t\t\t NULL,\n\t\t\t NTC2_CC_GetConfig,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintHexResponse(&out.preConfig);\n    }\n    /* required / expected values */\n    if (verify) {\n\tif (rc == 0) {\n\t    requiredConfig(&preConfig, p9);\n\t}\n\tif (rc == 0) {\n\t    rc = verifyConfig(&preConfig,\t/* expected */\n\t\t\t      &out.preConfig,\t/* actual */\n\t\t\t      verifyLocked);\t/* expect locked */\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"ntc2getconfig: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"ntc2getconfig: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n/* printHexResponse() prints the read preConfig in a concise hex format */\n\nstatic void printHexResponse(NTC2_CFG_STRUCT *preConfig)\n{\n    printf(\"i2cLoc1_2:\\t%02x\\n\", preConfig->i2cLoc1_2);\n    printf(\"i2cLoc3_4:\\t%02x\\n\", preConfig->i2cLoc3_4);\n    printf(\"AltCfg:\\t\\t%02x\\n\", preConfig->AltCfg);\n    printf(\"Direction:\\t%02x\\n\", preConfig->Direction);\n    printf(\"PullUp:\\t\\t%02x\\n\", preConfig->PullUp);\n    printf(\"PushPull:\\t%02x\\n\", preConfig->PushPull);\n    printf(\"CFG_A:\\t\\t%02x\\n\", preConfig->CFG_A);\n    printf(\"CFG_B:\\t\\t%02x\\n\", preConfig->CFG_B);\n    printf(\"CFG_C:\\t\\t%02x\\n\", preConfig->CFG_C);\n    printf(\"CFG_D:\\t\\t%02x\\n\", preConfig->CFG_D);\n    printf(\"CFG_E:\\t\\t%02x\\n\", preConfig->CFG_E);\n    printf(\"CFG_F:\\t\\t%02x\\n\", preConfig->CFG_F);\n    printf(\"CFG_G:\\t\\t%02x\\n\", preConfig->CFG_G);\n    printf(\"CFG_H:\\t\\t%02x\\n\", preConfig->CFG_H);\n    printf(\"CFG_I:\\t\\t%02x\\n\", preConfig->CFG_I);\n    printf(\"CFG_J:\\t\\t%02x\\n\", preConfig->CFG_J);\n    printf(\"IsValid:\\t%02x\\n\", preConfig->IsValid);\n    printf(\"IsLocked:\\t%02x\\n\", preConfig->IsLocked);\n    return;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"ntc2getconfig\\n\");\n    printf(\"\\n\");\n    printf(\"Runs NTC2_GetConfig\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-verify\\tVerify results against System P default (default no verify)]\\n\");\n    printf(\"\\t[-verifylocked\\tAlso verify that the preconfig is locked\\n\"\n\t   \"\\t\\t(default verify not locked)]\\n\");\n    printf(\"\\t[-p8 or -p9\\tVerify Nuvoton TPM for P8 or P9]\");\n    printf(\"\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/ntc2lib.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t     \tTPM2 Nuvoton Proprietary Command Utilities\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: ntc2lib.c 1290 2018-08-01 14:45:24Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2018\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include \"ntc2lib.h\"\n\n/* verifyConfig() compares the expected and actual values for the entire NTC2_CFG_STRUCT structure.\n\n   If verifyLocked is TRUE, checks that the configuration is locked.  If FALSE, checks that the\n   configuration is not locked\n*/\n\nTPM_RC verifyConfig(NTC2_CFG_STRUCT *expected, NTC2_CFG_STRUCT *actual, int verifyLocked)\n{\n    TPM_RC\t\t\trc = 0;\n    int b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16;\n    b0 = (actual->i2cLoc1_2 \t== expected->i2cLoc1_2);\n    if (!b0) {\n\tprintf(\"ERROR: i2cLoc1_2 expect %02x actual %02x\\n\", expected->i2cLoc1_2, actual->i2cLoc1_2);\n\trc = TPM_RC_VALUE;\n    }\n    b1 = (actual->i2cLoc3_4 \t== expected->i2cLoc3_4);\n    if (!b1) {\n\tprintf(\"ERROR: i2cLoc3_4 expect %02x actual %02x\\n\", expected->i2cLoc3_4, actual->i2cLoc3_4);\n\trc = TPM_RC_VALUE;\n    }\n    b2 = (actual->AltCfg \t\t== expected->AltCfg);\n    if (!b2) {\n\tprintf(\"ERROR: AltCfg expect %02x actual %02x\\n\", expected->AltCfg, actual->AltCfg);\n\trc = TPM_RC_VALUE;\n    }\n    b3 = (actual->Direction \t== expected->Direction);\n    if (!b3) {\n\tprintf(\"ERROR: Direction expect %02x actual %02x\\n\", expected->Direction, actual->Direction);\n\trc = TPM_RC_VALUE;\n    }\n    b4 = (actual->PullUp \t\t== expected->PullUp);\n    if (!b4) {\n\tprintf(\"ERROR: PullUp expect %02x actual %02x\\n\", expected->PullUp, actual->PullUp);\n\trc = TPM_RC_VALUE;\n    }\n    b5 = (actual->PushPull \t\t== expected->PushPull);\n    if (!b5) {\n\tprintf(\"ERROR: PushPull expect %02x actual %02x\\n\", expected->PushPull, actual->PushPull);\n\trc = TPM_RC_VALUE;\n    }\n    b6 = (actual->CFG_A \t\t== expected->CFG_A);\n    if (!b6) {\n\tprintf(\"ERROR: CFG_A expect %02x actual %02x\\n\", expected->CFG_A, actual->CFG_A);\n\trc = TPM_RC_VALUE;\n    }\n    b7 = (actual->CFG_B \t\t== expected->CFG_B);\n    if (!b7) {\n\tprintf(\"ERROR: CFG_B expect %02x actual %02x\\n\", expected->CFG_B, actual->CFG_B);\n\trc = TPM_RC_VALUE;\n    }\n    b8 = (actual->CFG_C \t\t== expected->CFG_C);\n    if (!b8) {\n\tprintf(\"ERROR: CFG_C expect %02x actual %02x\\n\", expected->CFG_C, actual->CFG_C);\n\trc = TPM_RC_VALUE;\n    }\n    b9 = (actual->CFG_D \t\t== expected->CFG_D);\n    if (!b9) {\n\tprintf(\"ERROR: CFG_D expect %02x actual %02x\\n\", expected->CFG_D, actual->CFG_D);\n\trc = TPM_RC_VALUE;\n    }\n    b10 = (actual->CFG_E \t\t== expected->CFG_E);\n    if (!b10) {\n\tprintf(\"CFG_E expect %02x actual %02x\\n\", expected->CFG_E, actual->CFG_E);\n\trc = TPM_RC_VALUE;\n    }\n    b11 = (actual->CFG_F \t\t== expected->CFG_F);\n    if (!b11) {\n\tprintf(\"CFG_F expect %02x actual %02x\\n\", expected->CFG_F, actual->CFG_F);\n\trc = TPM_RC_VALUE;\n    }\n    b12 = (actual->CFG_G \t\t== expected->CFG_G);\n    if (!b12) {\n\tprintf(\"ERROR: CFG_G expect %02x actual %02x\\n\", expected->CFG_G, actual->CFG_G);\n\trc = TPM_RC_VALUE;\n    }\n    b13 = (actual->CFG_H \t\t== expected->CFG_H);\n    if (!b13) {\n\tprintf(\"ERROR: CFG_H expect %02x actual %02x\\n\", expected->CFG_H, actual->CFG_H);\n\trc = TPM_RC_VALUE;\n    }\n    b14 = (actual->CFG_I \t\t== expected->CFG_I);\n    if (!b14) {\n\tprintf(\"ERROR: CFG_I expect %02x actual %02x\\n\", expected->CFG_I, actual->CFG_I);\n\trc = TPM_RC_VALUE;\n    }\n    b15 = (actual->CFG_J \t\t== expected->CFG_J);\n    if (!b15) {\n\tprintf(\"ERROR: CFG_J expect %02x actual %02x\\n\", expected->CFG_J, actual->CFG_J);\n\trc = TPM_RC_VALUE;\n    }\n    b16 = (actual->IsValid \t\t== expected->IsValid);\n    if (!b16) {\n\tprintf(\"ERROR: IsValid expect %02x actual %02x\\n\", expected->IsValid, actual->IsValid);\n\trc = TPM_RC_VALUE;\n    }\n    if (verifyLocked) {\n\tif (actual->IsLocked != 0xaa) {\n\t    printf(\"ERROR: IsLocked is %02x not %02x\\n\",\n\t\t   actual->IsLocked, 0xaa);\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    else {\n\tif (actual->IsLocked != 0xff) {\n\t    printf(\"ERROR: IsLocked %02x not %02x\\n\",\n\t\t   actual->IsLocked, 0xff);\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    return rc;\n}\n\n/* requiredConfig() fills in the structure with the required values\n\n   p9 FALSE uses P8 values.  p9 TRUE uses P9 values\n*/\n\nvoid requiredConfig(NTC2_CFG_STRUCT *preConfig, int p9)\n{\n    /* p8 preConfig */\n    if (!p9) {\n\tpreConfig->i2cLoc1_2 \t= P8_REQUIRED_i2cLoc1_2;\n\tpreConfig->i2cLoc3_4 \t= P8_REQUIRED_i2cLoc3_4;\n\tpreConfig->AltCfg \t= P8_REQUIRED_AltCfg;\n\tpreConfig->Direction \t= P8_REQUIRED_Direction;\n\tpreConfig->PullUp \t= P8_REQUIRED_PullUp;\n\tpreConfig->PushPull \t= P8_REQUIRED_PushPull;\n\tpreConfig->CFG_A \t= P8_REQUIRED_CFG_A;\n\tpreConfig->CFG_B \t= P8_REQUIRED_CFG_B;\n\tpreConfig->CFG_C \t= P8_REQUIRED_CFG_C;\n\tpreConfig->CFG_D \t= P8_REQUIRED_CFG_D;\n\tpreConfig->CFG_E \t= P8_REQUIRED_CFG_E;\n\tpreConfig->CFG_F \t= P8_REQUIRED_CFG_F;\n\tpreConfig->CFG_G \t= P8_REQUIRED_CFG_G;\n\tpreConfig->CFG_H \t= P8_REQUIRED_CFG_H;\n\tpreConfig->CFG_I \t= P8_REQUIRED_CFG_I;\n\tpreConfig->CFG_J \t= P8_REQUIRED_CFG_J;\n\tpreConfig->IsValid \t= P8_REQUIRED_IsValid;\n\tpreConfig->IsLocked \t= P8_REQUIRED_IsLocked;\n    }\n    /* p9 preConfig */\n    else {\n\tpreConfig->i2cLoc1_2 \t= P9_REQUIRED_i2cLoc1_2;\n\tpreConfig->i2cLoc3_4 \t= P9_REQUIRED_i2cLoc3_4;\n\tpreConfig->AltCfg \t= P9_REQUIRED_AltCfg;\n\tpreConfig->Direction \t= P9_REQUIRED_Direction;\n\tpreConfig->PullUp \t= P9_REQUIRED_PullUp;\n\tpreConfig->PushPull \t= P9_REQUIRED_PushPull;\n\tpreConfig->CFG_A \t= P9_REQUIRED_CFG_A;\n\tpreConfig->CFG_B \t= P9_REQUIRED_CFG_B;\n\tpreConfig->CFG_C \t= P9_REQUIRED_CFG_C;\n\tpreConfig->CFG_D \t= P9_REQUIRED_CFG_D;\n\tpreConfig->CFG_E \t= P9_REQUIRED_CFG_E;\n\tpreConfig->CFG_F \t= P9_REQUIRED_CFG_F;\n\tpreConfig->CFG_G \t= P9_REQUIRED_CFG_G;\n\tpreConfig->CFG_H \t= P9_REQUIRED_CFG_H;\n\tpreConfig->CFG_I \t= P9_REQUIRED_CFG_I;\n\tpreConfig->CFG_J \t= P9_REQUIRED_CFG_J;\n\tpreConfig->IsValid \t= P9_REQUIRED_IsValid;\n\tpreConfig->IsLocked \t= P9_REQUIRED_IsLocked;\n    }\n    return;\n}\n\n\n"
  },
  {
    "path": "ibmtss-ftpm/ntc2lockconfig.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Nuvoton Lock Preconfig  \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n   Locks the Nuvoton preConfig registers\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\n#include \"ntc2lib.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    \t\t/* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    int\t\t\t\tlock = FALSE;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-lock\") == 0) {\n\t    lock = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (!lock) {\n\tprintf(\"\\nntc2lockpreconfig requires -lock\\n\");\n\tprintUsage();\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t NULL,\n\t\t\t NULL,\n\t\t\t NTC2_CC_LockPreConfig,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"ntc2lockpreconfig: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"ntc2lockpreconfig: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"ntc2lockpreconfig\\n\");\n    printf(\"\\n\");\n    printf(\"Runs NTC2_LockPreConfig\\n\");\n    printf(\"\\n\");\n    printf(\"-lock\\t(required)\\n\");\n    printf(\"\\n\");\n    exit(1);\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/ntc2preconfig.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Nuvoton Preconfig \t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* The function permits configuring either standard manufacturing values or individual registers.\n\n   The hard coded values are in ../src/ntc2lib.h.  They are configured as a set.\n\n   That file also has certain required values that cannot be changed.\n\n   To override the standard manufacturing values, cautiously use -override.  This can brick the TPM,\n   since it's setting up the bus interface.  Override does a red-modify-write, reading the registers\n   and substiuting the new values.\n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\n#include \"ntc2lib.h\"\n\nstatic void printUsage(void);\nstatic TPM_RC fixedConfig(NTC2_CFG_STRUCT *preConfig);\nstatic void mergeConfig(NTC2_CFG_STRUCT *preConfigOut,\n\t\t\tconst NTC2_CFG_STRUCT *preConfigIn,\n\t\t\tconst NTC2_CFG_STRUCT *preConfigSet);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    \t\t/* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NTC2_GetConfig_Out \t\tout;\n    NTC2_PreConfig_In \t\tin;\n    NTC2_CFG_STRUCT \t\tpreConfigSet;\t\t/* flags mark values to change */\n    NTC2_CFG_STRUCT \t\tpreConfigIn;\t\t/* values to change */\n    int\t\t\t\tp8 = FALSE;\n    int\t\t\t\tp9 = FALSE;\n    int \t\t\toverride = FALSE;\t/* TRUE to override P required values */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    memset(&preConfigSet, 0, sizeof(NTC2_CFG_STRUCT));\t/* default nothing to change */\n    memset(&preConfigIn, 0, sizeof(NTC2_CFG_STRUCT));   /* initialized to suppress false gcc -O3\n\t\t\t\t\t\t\t   warning */\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tint inttmp;\t/* for sccanf */\n\tif (strcmp(argv[i],\"-p8\") == 0) {\n\t    p8 = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-p9\") == 0) {\n\t    p9 = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-override\") == 0) {\n\t    override = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-i2cLoc1_2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.i2cLoc1_2 = inttmp;\n\t\tpreConfigSet.i2cLoc1_2 = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -i2cLoc1_2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-i2cLoc3_4\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.i2cLoc3_4 = inttmp;\n\t\tpreConfigSet.i2cLoc3_4 = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -i2cLoc3_4\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-AltCfg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.AltCfg = inttmp;\n\t\tpreConfigSet.AltCfg = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -AltCfg\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-Direction\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.Direction = inttmp;\n\t\tpreConfigSet.Direction = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -Direction\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-PullUp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.PullUp = inttmp;\n\t\tpreConfigSet.PullUp = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -PullUp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-PushPull\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.PushPull = inttmp;\n\t\tpreConfigSet.PushPull = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -PushPull\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_A\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_A = inttmp;\n\t\tpreConfigSet.CFG_A = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_A\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_B\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_B = inttmp;\n\t\tpreConfigSet.CFG_B = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_B\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_C\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_C = inttmp;\n\t\tpreConfigSet.CFG_C = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_C\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_D\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_D = inttmp;\n\t\tpreConfigSet.CFG_D = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_D\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_E\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_E = inttmp;\n\t\tpreConfigSet.CFG_E = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_E\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_F\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_F = inttmp;\n\t\tpreConfigSet.CFG_F = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_F\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_G\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_G = inttmp;\n\t\tpreConfigSet.CFG_G = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_G\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_H\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_H = inttmp;\n\t\tpreConfigSet.CFG_H = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_H\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_I\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_I = inttmp;\n\t\tpreConfigSet.CFG_I = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_I\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-CFG_J\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.CFG_J = inttmp;\n\t\tpreConfigSet.CFG_J = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -CFG_J\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-IsValid\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &inttmp);\n\t\tpreConfigIn.IsValid = inttmp;\n\t\tpreConfigSet.IsValid = 1;\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -IsValid\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (p8 && p9) {\n\tprintf(\"-p8 and -p9 cannot both be specified\\n\");\n\tprintUsage();\n    }\n     /* can't specify both hard coded and override */\n    if ((p8 || p9) && override) {\n\tprintf(\"\\nCannot have both -override and -p8 or -p9\\n\");\n\tprintUsage();\n    }\n    /* must specify one of these options */\n    if (!(p8 || p9) && !override) {\n\tprintf(\"\\nNeed either -p8, -p9, or -override\\n\");\n\tprintUsage();\n    }\n    /* if override, at least one of the registers must be specified */\n    if (override && \n\t!(preConfigSet.i2cLoc1_2 \t||\n\t  preConfigSet.i2cLoc3_4 \t||\n\t  preConfigSet.AltCfg  \t\t||\n\t  preConfigSet.Direction  \t||\n\t  preConfigSet.PullUp  \t\t||\n\t  preConfigSet.PushPull  \t||\n\t  preConfigSet.CFG_A  \t\t||\n\t  preConfigSet.CFG_B  \t\t||\n\t  preConfigSet.CFG_C  \t\t||\n\t  preConfigSet.CFG_D  \t\t||\n\t  preConfigSet.CFG_E  \t\t||\n\t  preConfigSet.CFG_F  \t\t||\n\t  preConfigSet.CFG_G  \t\t||\n\t  preConfigSet.CFG_H  \t\t||\n\t  preConfigSet.CFG_I  \t\t||\n\t  preConfigSet.CFG_J  \t\t||\n\t  preConfigSet.IsValid)) {\n\tprintf(\"\\n-override requires at least one value to set\\n\");\n\tprintUsage();\n    }\n    /* if hard coded values, none of the registers can be specified */\n    if ((p8 || p9) && \n\t(preConfigSet.i2cLoc1_2 \t||\n\t preConfigSet.i2cLoc3_4 \t||\n\t preConfigSet.AltCfg  \t\t||\n\t preConfigSet.Direction  \t||\n\t preConfigSet.PullUp  \t\t||\n\t preConfigSet.PushPull  \t||\n\t preConfigSet.CFG_A  \t\t||\n\t preConfigSet.CFG_B  \t\t||\n\t preConfigSet.CFG_C  \t\t||\n\t preConfigSet.CFG_D  \t\t||\n\t preConfigSet.CFG_E  \t\t||\n\t preConfigSet.CFG_F  \t\t||\n\t preConfigSet.CFG_G  \t\t||\n\t preConfigSet.CFG_H  \t\t||\n\t preConfigSet.CFG_I  \t\t||\n\t preConfigSet.CFG_J  \t\t||\n\t preConfigSet.IsValid )) {\n\tprintf(\"\\n-p8 and -p9  cannot specify a value to set\\n\");\n\tprintUsage();\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* if overriding hard coded values, do read-modify-write */\n    if (override) {\n\t/* call TSS NTC2_CC_GetConfig to read the current configuration parameters */\n\tif (rc == 0) {\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     (RESPONSE_PARAMETERS *)&out, \n\t\t\t     NULL,\n\t\t\t     NULL,\n\t\t\t     NTC2_CC_GetConfig,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n\tif (rc == 0) {\n\t    /* copy the existing read config to the new write config as the baseline values */\n\t    in.preConfig = out.preConfig;\n\t    /* merge values to change, from command line parameters */\n\t    mergeConfig(&in.preConfig,\t/* baseline on input, merged on output */\n\t\t\t&preConfigIn,\t/* values to merge */\n\t\t\t&preConfigSet);\t/* boolean, true to merge the value */\n\t}\n    }\n    /* if setting System P required values */\n    if (p8 || p9) {\n\tif (rc == 0) {\n\t    requiredConfig(&in.preConfig, p9);\n\t}\n    }\n    /* check that Nuvoton fixed values are in the correct state.  This is a sanity check for\n       -p8 or -p9, but a required test for override */\n    if (rc == 0) {\n\trc = fixedConfig(&in.preConfig);\n    }\n    /* call TSS to execute the NTC2_CC_PreConfig command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t NTC2_CC_PreConfig,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"ntc2preconfig: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"ntc2preconfig: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n/* fixedConfig() is a sanity check that the TPM is not being configured incorrectly.  Certain values\n   are fixed.\n\n   For -prequired, this is a simple consistency check on the required and fixed #define values\n   For -override, this is a validation of the user input\n*/\n\nstatic TPM_RC fixedConfig(NTC2_CFG_STRUCT *preConfig)\n{\n    if (preConfig->Direction != FIXED_Direction) {\n\tprintf(\"Direction is not the required value %02x\\n\", FIXED_Direction);\n\treturn TPM_RC_RANGE;\n    }\n    if (preConfig->PullUp != FIXED_PullUp) {\n\tprintf(\"PullUp is not the required value %02x\\n\", FIXED_PullUp);\n\treturn TPM_RC_RANGE;\n    }\n    if (preConfig->PushPull != FIXED_PushPull) {\n\tprintf(\"PushPull is not the required value %02x\\n\", FIXED_PushPull);\n\treturn TPM_RC_RANGE;\n    }\n    if (preConfig->CFG_F != FIXED_CFG_F) {\n\tprintf(\"CFG_F is not the required value %02x\\n\", FIXED_CFG_F);\n\treturn TPM_RC_RANGE;\n    }\n    if (preConfig->CFG_I != FIXED_CFG_I) {\n\tprintf(\"CFG_I is not the required value %02x\\n\", FIXED_CFG_I);\n\treturn TPM_RC_RANGE;\n    }\n    if (preConfig->CFG_J != FIXED_CFG_J) {\n\tprintf(\"CFG_J is not the required value %02x\\n\", FIXED_CFG_J);\n\treturn TPM_RC_RANGE;\n    }\n    if (preConfig->IsValid != FIXED_IsValid) {\n\tprintf(\"IsValid is not the required value %02x\\n\", FIXED_IsValid);\n\treturn TPM_RC_RANGE;\n    }\n    return 0;\n}\n\n/* mergeConfig() handles the read modify write setup.\n\n   preConfigIn are the new values\n   preConfigSet are booleans, true for the new values\n   preConfigOut at input are the current values, at output are the merged values\n*/\n\nstatic void mergeConfig(NTC2_CFG_STRUCT *preConfigOut,\n\t\t\tconst NTC2_CFG_STRUCT *preConfigIn,\n\t\t\tconst NTC2_CFG_STRUCT *preConfigSet)\n{\n    if (preConfigSet->i2cLoc1_2) {\n\tpreConfigOut->i2cLoc1_2 = preConfigIn->i2cLoc1_2;\n    }\n    if (preConfigSet->i2cLoc3_4) {\n\tpreConfigOut->i2cLoc3_4 = preConfigIn->i2cLoc3_4;\n    }\n    if (preConfigSet->AltCfg) {\n\tpreConfigOut->AltCfg = preConfigIn->AltCfg;\n    }\n    if (preConfigSet->Direction) {\n\tpreConfigOut->Direction = preConfigIn->Direction;\n    }\n    if (preConfigSet->PullUp) {\n\tpreConfigOut->PullUp = preConfigIn->PullUp;\n    }\n    if (preConfigSet->PushPull) {\n\tpreConfigOut->PushPull = preConfigIn->PushPull;\n    }\n    if (preConfigSet->CFG_A) {\n\tpreConfigOut->CFG_A = preConfigIn->CFG_A;\n    }\n    if (preConfigSet->CFG_B) {\n\tpreConfigOut->CFG_B = preConfigIn->CFG_B;\n    }\n    if (preConfigSet->CFG_C) {\n\tpreConfigOut->CFG_C = preConfigIn->CFG_C;\n    }\n    if (preConfigSet->CFG_D) {\n\tpreConfigOut->CFG_D = preConfigIn->CFG_D;\n    }\n    if (preConfigSet->CFG_E) {\n\tpreConfigOut->CFG_E = preConfigIn->CFG_E;\n    }\n    if (preConfigSet->CFG_F) {\n\tpreConfigOut->CFG_F = preConfigIn->CFG_F;\n    }\n    if (preConfigSet->CFG_G) {\n\tpreConfigOut->CFG_G = preConfigIn->CFG_G;\n    }\n    if (preConfigSet->CFG_H) {\n\tpreConfigOut->CFG_H = preConfigIn->CFG_H;\n    }\n    if (preConfigSet->CFG_I) {\n\tpreConfigOut->CFG_I = preConfigIn->CFG_I;\n    }\n    if (preConfigSet->CFG_J) {\n\tpreConfigOut->CFG_J = preConfigIn->CFG_J;\n    }\n    if (preConfigSet->IsValid) {\n\tpreConfigOut->IsValid = preConfigIn->IsValid;\n    }\n    return;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"ntc2preconfig\\n\");\n    printf(\"\\n\");\n    printf(\"Runs NTC2_PreConfig\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-p8 or -p9\\tConfigure Nuvoton TPM for P8 or P9\\n\");\n    printf(\"\\t-override\\tpermits individual register values, read-modify-write\\n\");\n    printf(\"\\n\");\n    printf(\"Values to set, each is a hex byte, (default do not change)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-i2cLoc1_2\\tbyte]\\n\");\n    printf(\"\\t[-i2cLoc3_4\\tbyte]\\n\");\n    printf(\"\\t[-AltCfg\\tbyte]\\n\");\n    printf(\"\\t[-Direction\\tbyte]\\n\");\n    printf(\"\\t[-PullUp\\tbyte]\\n\");\n    printf(\"\\t[-PushPull\\tbyte]\\n\");\n    printf(\"\\t[-CFG_A\\t\\tbyte]\\n\");\n    printf(\"\\t[-CFG_B\\t\\tbyte]\\n\");\n    printf(\"\\t[-CFG_C\\t\\tbyte]\\n\");\n    printf(\"\\t[-CFG_D\\t\\tbyte]\\n\");\n    printf(\"\\t[-CFG_E\\t\\tbyte]\\n\");\n    printf(\"\\t[-CFG_F\\t\\tbyte]\\n\");\n    printf(\"\\t[-CFG_G\\t\\tbyte]\\n\");\n    printf(\"\\t[-CFG_H\\t\\tbyte]\\n\");\n    printf(\"\\t[-CFG_I\\t\\tbyte]\\n\");\n    printf(\"\\t[-CFG_J\\t\\tbyte]\\n\");\n    printf(\"\\t[-IsValid\\tbyte]\\n\");\n    exit(1);\n}\n\n\n\n"
  },
  {
    "path": "ibmtss-ftpm/nvcertify.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV_Certify\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_Certify_In \t\tin;\n    NV_Certify_Out \t\tout;\n    TPMI_DH_OBJECT\t\tsignHandle = 0;\n    const char\t\t\t*keyPassword = NULL; \n    char \t\t\thierarchyAuthChar = 0;\n    const char\t\t\t*nvPassword = NULL; \t\t/* default no password */\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    uint16_t \t\t\tsize = 0;\n    uint16_t \t\t\toffset = 0;\t\t\t/* default 0 */\n    TPMS_ATTEST \t\ttpmsAttest;\n    const char\t\t\t*signatureFilename = NULL;\n    const char\t\t\t*attestInfoFilename = NULL;\n    const char\t\t\t*certifyDataFilename = NULL;\n    TPM_ALG_ID\t\t\tsigAlg = TPM_ALG_RSA;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hia\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyAuthChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hia\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &signHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-salg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsa\") == 0) {\n\t\t    sigAlg = TPM_ALG_RSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"ecc\") == 0) {\n\t\t    sigAlg = TPM_ALG_ECDSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"hmac\") == 0) {\n\t\t    sigAlg = TPM_ALG_HMAC;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -salg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-salg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sz\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsize = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-sz option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-off\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toffset = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-off option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oa\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tattestInfoFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oa option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-od\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcertifyDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-od option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* certifying key */\n    if (signHandle == 0) {\n\tprintf(\"Missing sign handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    /* Authorization handle */\n    if (rc == 0) {\n\tif (hierarchyAuthChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyAuthChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;\n\t}\n\telse if (hierarchyAuthChar == 0) {\n\t    in.authHandle = nvIndex;\n\t}\n\telse {\n\t    printf(\"-hia has bad parameter %c\\n\", hierarchyAuthChar);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.signHandle = signHandle;\n\tin.nvIndex = nvIndex;\n\tin.qualifyingData.t.size = 0;\n\tif (sigAlg == TPM_ALG_RSA) {\n\t    /* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\t    in.inScheme.scheme = TPM_ALG_RSASSA;\t\n\t    /* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\t    /* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t    /* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t    in.inScheme.details.rsassa.hashAlg = halg;\n\t}\n\telse if (sigAlg == TPM_ALG_ECDSA) {\n\t    in.inScheme.scheme = TPM_ALG_ECDSA;\t\n\t    in.inScheme.details.ecdsa.hashAlg = halg;\n\t}\n\telse {\t/* HMAC */\n\t    in.inScheme.scheme = TPM_ALG_HMAC;\t\n\t    in.inScheme.details.hmac.hashAlg = halg;\n\t}\n\tin.size = size;\n\tin.offset = offset;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_Certify,\n\t\t\t sessionHandle0, keyPassword, sessionAttributes0,\n\t\t\t sessionHandle1, nvPassword, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (signatureFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.signature,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_SIGNATURE_Marshalu,\n\t\t\t\t     signatureFilename);\n    }\n    if ((rc == 0) && (attestInfoFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.certifyInfo.t.attestationData,\n\t\t\t\t      out.certifyInfo.t.size,\n\t\t\t\t      attestInfoFilename);\n    }\n    /* unmarshal the TPM2B_ATTEST output to a TPMS_ATTEST structure */\n    if (rc == 0) {\n\tuint8_t *tmpBuffer = out.certifyInfo.t.attestationData;\n\tuint32_t tmpSize = out.certifyInfo.t.size;\n\trc = TSS_TPMS_ATTEST_Unmarshalu(&tpmsAttest, &tmpBuffer, &tmpSize);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMS_ATTEST_Print(&tpmsAttest, 0);\n    }\n    if ((rc == 0) && (certifyDataFilename != NULL)) {\n\t/* TPMS_NV_DIGEST_CERTIFY_INFO */\n\tif ((offset == 0) && (size == 0)) {\n\t    rc = TSS_File_WriteBinaryFile(tpmsAttest.attested.nvDigest.nvDigest.t.buffer,\n\t\t\t\t\t  tpmsAttest.attested.nvDigest.nvDigest.t.size,\n\t\t\t\t\t  certifyDataFilename);\n\t}\n\t/* TPMS_NV_CERTIFY_INFO */\n\telse {\n\t    rc = TSS_File_WriteBinaryFile(tpmsAttest.attested.nv.nvContents.t.buffer,\n\t\t\t\t\t  tpmsAttest.attested.nv.nvContents.t.size,\n\t\t\t\t\t  certifyDataFilename);\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMT_SIGNATURE_Print(&out.signature, 0);\n\tif (tssUtilsVerbose) printf(\"nvcertify: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvcertify: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvcertify\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_Certify\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hia\\thierarchy authorization (o, p)(default index authorization)]\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t[-pwdn\\tpassword for NV index (default empty)]\\n\");\n    printf(\"\\t-hk\\tcertifying key handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-salg\\tsignature algorithm (rsa, ecc, hmac) (default rsa)]\\n\");\n    printf(\"\\t-sz\\tdata size\\n\");\n    printf(\"\\t[-off\\toffset (default 0)]\\n\");\n    printf(\"\\t[-os\\tsignature file name  (default do not save)]\\n\");\n    printf(\"\\t[-oa\\tattestation output file name (default do not save)]\\n\");\n    printf(\"\\t[-od\\tcertified data file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvchangeauth.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV_ChangeAuth\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_ChangeAuth_In \t\tin;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    const char\t\t\t*password = NULL; \n    const char\t\t\t*newPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdo\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdo option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnewPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.nvIndex = nvIndex;\n    }\n    /* convert password string to TPM2B */\n    if (rc == 0) {\n\tif (newPassword == NULL) {\n\t    in.newAuth.t.size = 0;\n\t}\n\telse {\n\t    rc = TSS_TPM2B_StringCopy(&in.newAuth.b,\n\t\t\t\t      newPassword, sizeof(in.newAuth.t.buffer));\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_ChangeAuth,\n\t\t\t sessionHandle0, password, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"nvchangeauth: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvchangeauth: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvchangeauth\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_ChangeAuth\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t-pwdo\\tpassword (default empty)\\n\");\n    printf(\"\\t-pwdn\\tnew password (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvdefinespace.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV Define Space\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\n#define TPMA_NVA_CLEAR_STCLEAR\t0x08000000\n\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_DefineSpace_In \t\tin;\n    /* hierarchy that the index is created in, platform or owner */\n    char \t\t\thierarchyChar = 0;\n    /* index authorization attributes, owner r/w, platform r/w, index r/w.  The values set here can\n       be overridden, set or cleared, individually */\n    char \t\t\thierarchyAuthChar = '\\0';\n    TPMI_ALG_HASH\t\tnalg = TPM_ALG_SHA256;\n    unsigned int\t\thashSize = SHA256_DIGEST_SIZE;\n    char \t\t\ttypeChar = 'o';\n    unsigned int\t\ttypeCount = 0;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    uint16_t \t\t\tdataSize = 0;\n    TPMA_NV\t\t\tnvAttributes;\t  \t/* final attributes to command */\n    TPMA_NV\t\t\tsetAttributes;\t\t/* attributes to add to defaults*/\n    TPMA_NV\t\t\tclearAttributes;\t/* attributes to subtract from defaults */\n    const char\t\t\t*policyFilename = NULL;\n    const char\t\t\t*nvPassword = NULL; \n    const char\t\t\t*parentPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* nvAttributes first accumumates attributes that are default side effects of other arguments.\n       E.g., specifying a policy sets POLICYWRITE and POLICYREAD.  After all arguments are\n       processed, setAttributes and clearAttributes may optional fine tune the attributes. E.g.,\n       POLICYWRITE can be cleared. */\n\n    /* default values */\n    nvAttributes.val = 0;\n    setAttributes.val = TPMA_NVA_NO_DA;\n    clearAttributes.val = 0;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hia\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyAuthChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hia\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    nalg = TPM_ALG_SHA1;\n\t\t    hashSize = SHA1_DIGEST_SIZE;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    nalg = TPM_ALG_SHA256;\n\t\t    hashSize = SHA256_DIGEST_SIZE;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    nalg = TPM_ALG_SHA384;\n\t\t    hashSize = SHA384_DIGEST_SIZE;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    nalg = TPM_ALG_SHA512;\n\t\t    hashSize = SHA512_DIGEST_SIZE;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -nalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-nalg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pol\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pol option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sz\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdataSize = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-sz option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ty\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\ttypeChar = argv[i][0];\n\t\ttypeCount++;\n\t    }\n\t    else {\n\t\tprintf(\"-ty option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"+at\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i], \"wd\")  == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_WRITEDEFINE;\n\t\t}\n\t\telse if (strcmp(argv[i], \"wst\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_WRITE_STCLEAR;\n\t\t}\n\t\telse if (strcmp(argv[i], \"gl\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_GLOBALLOCK;\n\t\t}\n\t\telse if (strcmp(argv[i], \"rst\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_READ_STCLEAR;\n\t\t}\n\t\telse if (strcmp(argv[i], \"pold\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_POLICY_DELETE;\n\t\t}\n\t\telse if (strcmp(argv[i], \"stc\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_CLEAR_STCLEAR;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ody\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_ORDERLY;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ppw\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_PPWRITE;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ppr\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_PPREAD;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ow\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_OWNERWRITE;\n\t\t}\n\t\telse if (strcmp(argv[i], \"or\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_OWNERREAD;\n\t\t}\n\t\telse if (strcmp(argv[i], \"aw\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_AUTHWRITE;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ar\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_AUTHREAD;\n\t\t}\n\t\telse if (strcmp(argv[i], \"wa\") == 0) {\n\t\t    setAttributes.val |= TPMA_NVA_WRITEALL;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for +at\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for +at\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-at\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i], \"da\") == 0) {\n\t\t    clearAttributes.val |= TPMA_NVA_NO_DA;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ppw\") == 0) {\n\t\t    clearAttributes.val |= TPMA_NVA_PPWRITE;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ppr\") == 0) {\n\t\t    clearAttributes.val |= TPMA_NVA_PPREAD;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ow\") == 0) {\n\t\t    clearAttributes.val |= TPMA_NVA_OWNERWRITE;\n\t\t}\n\t\telse if (strcmp(argv[i], \"or\") == 0) {\n\t\t    clearAttributes.val |= TPMA_NVA_OWNERREAD;\n\t\t}\n\t\telse if (strcmp(argv[i], \"aw\") == 0) {\n\t\t    clearAttributes.val |= TPMA_NVA_AUTHWRITE;\n\t\t}\n\t\telse if (strcmp(argv[i], \"ar\") == 0) {\n\t\t    clearAttributes.val |= TPMA_NVA_AUTHREAD;\n\t\t}\n\t\telse if (strcmp(argv[i], \"pw\") == 0) {\n\t\t    clearAttributes.val |= TPMA_NVA_POLICYWRITE;\n\t\t}\n\t\telse if (strcmp(argv[i], \"pr\") == 0) {\n\t\t    clearAttributes.val |= TPMA_NVA_POLICYREAD;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -at\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -at\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    if (typeCount > 1) {\n\tprintf(\"-ty can only be specified once\\n\");\n\tprintUsage();\n    }\n    /* Authorization attributes */\n    if (rc == 0) {\n\tif (hierarchyAuthChar == 'o') {\n\t    nvAttributes.val |= TPMA_NVA_OWNERWRITE | TPMA_NVA_OWNERREAD;\n\t}\n\telse if (hierarchyAuthChar == 'p') {\n\t    nvAttributes.val |= TPMA_NVA_PPWRITE | TPMA_NVA_PPREAD;\n\t}\n\telse if (hierarchyAuthChar == '\\0') {\n\t    nvAttributes.val |= TPMA_NVA_AUTHWRITE | TPMA_NVA_AUTHREAD;\n\t}\n\telse {\n\t    printf(\"-hia has bad parameter %c\\n\", hierarchyAuthChar);\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tif (hierarchyChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;\n\t    nvAttributes.val |= TPMA_NVA_PLATFORMCREATE;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tswitch (typeChar) {\n\t  case 'o':\n\t    nvAttributes.val |= TPMA_NVA_ORDINARY;\n\t    break;\n\t  case 'c':\n\t    nvAttributes.val |= TPMA_NVA_COUNTER;\n\t    dataSize = 8;\n\t    break;\n\t  case 'b':\n\t    nvAttributes.val |= TPMA_NVA_BITS;\n\t    dataSize = 8;\n\t    break;\n\t  case 'e':\n\t    nvAttributes.val |= TPMA_NVA_EXTEND;\n\t    dataSize = hashSize;\n\t    break;\n\t  case 'p':\n\t    nvAttributes.val |= TPMA_NVA_PIN_PASS;\n\t    dataSize = 8;\n\t    break;\n\t  case 'f':\n\t    nvAttributes.val |= TPMA_NVA_PIN_FAIL;\n\t    dataSize = 8;\n\t    break;\n\t  default:\n\t    printf(\"Illegal -ty\\n\");\n\t    printUsage();\n\t}\n    }\t\n    /* Table 75 - Definition of Types for TPM2B_AUTH */\n    if (rc == 0) {\n\tif (nvPassword == NULL) {\n\t    in.auth.b.size = 0;\n\t}\n\t/* if there was a password specified, permit index authorization */\n\telse {\n\t    /* PIN index cannot use index AUTHWRITE authorization */\n\t    if (((nvAttributes.val & TPMA_NVA_TPM_NT_MASK) != TPMA_NVA_PIN_FAIL) &&\n\t\t((nvAttributes.val & TPMA_NVA_TPM_NT_MASK) != TPMA_NVA_PIN_PASS)) {\n\t\tnvAttributes.val |= TPMA_NVA_AUTHWRITE;\n\t    }\n\t    nvAttributes.val |= TPMA_NVA_AUTHREAD;\n\t    rc = TSS_TPM2B_StringCopy(&in.auth.b,\n\t\t\t\t      nvPassword, sizeof(in.auth.t.buffer));\n\t}\n    }\n    /* optional authorization policy */\n    if (rc == 0) {\n\tif (policyFilename != NULL) {\n\t    if (rc == 0) {\n\t\tnvAttributes.val |= TPMA_NVA_POLICYWRITE | TPMA_NVA_POLICYREAD;\n\t\trc = TSS_File_Read2B(&in.publicInfo.nvPublic.authPolicy.b,\n\t\t\t\t     sizeof(in.publicInfo.nvPublic.authPolicy.t.buffer),\n\t\t\t\t     policyFilename);\n\t    }\n\t    /* sanity check that the size of the policy hash matches the name algorithm */\n\t    if (rc == 0) {\n\t\tif (in.publicInfo.nvPublic.authPolicy.b.size != hashSize) {\n\t\t    printf(\"Policy size %u does not match name algorithm %u\\n\",\n\t\t\t   in.publicInfo.nvPublic.authPolicy.b.size, hashSize);\n\t\t    rc = TPM_RC_POLICY;\n\t\t}\n\t    }\n\t}\n\telse {\n\t    in.publicInfo.nvPublic.authPolicy.t.size = 0;\t/* default empty policy */\n\t}\n    }\n    /* Table 197 - Definition of TPM2B_NV_PUBLIC Structure publicInfo */\n    /* Table 196 - Definition of TPMS_NV_PUBLIC Structure nvPublic */\n    if (rc == 0) {\n\tin.publicInfo.nvPublic.nvIndex = nvIndex;\t/* the handle of the data area */\n\tin.publicInfo.nvPublic.nameAlg = nalg;\t\t/* hash algorithm used to compute the name\n\t\t\t\t\t\t\t   of the Index and used for the\n\t\t\t\t\t\t\t   authPolicy */\n\tin.publicInfo.nvPublic.attributes = nvAttributes;\t/* the default Index attributes */\n\t/* additional set attributes */\n\tin.publicInfo.nvPublic.attributes.val |= setAttributes.val;\n\t/* clear attributes */\n\tin.publicInfo.nvPublic.attributes.val &= ~(clearAttributes.val);\n\tin.publicInfo.nvPublic.dataSize = dataSize;\t/* the size of the data area */\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_DefineSpace,\n\t\t\t sessionHandle0, parentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"nvdefinespace: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvdefinespace: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvdefinespace\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_DefineSpace\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t\\t01xxxxxx\\n\");\n    printf(\"\\t-hi\\tauthorizing hierarchy (o, p)\\n\");\n    printf(\"\\t\\to owner, p platform\\n\");\n    printf(\"\\t\\tp sets PLATFORMCREATE\\n\");\n    printf(\"\\t[-pwdp\\tpassword for hierarchy (default empty)]\\n\");\n    printf(\"\\t[-hia\\thierarchy authorization (o, p)(default index authorization)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\tdefault  AUTHWRITE, AUTHREAD\\n\");\n    printf(\"\\t\\to sets  OWNERWRITE, OWNERREAD\\n\");\n    printf(\"\\t\\tp sets  PPWRITE, PPREAD (platform)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwdn\\tpassword for NV index (default empty)]\\n\");\n    printf(\"\\t\\tsets AUTHWRITE (if not PIN index), AUTHREAD\\n\");\n    printf(\"\\t[-nalg\\tname algorithm (sha1, sha256, sha384 sha512) (default sha256)]\\n\");\n    printf(\"\\t[-sz\\tdata size in decimal (default 0)]\\n\");\n    printf(\"\\t\\tIgnored for other than ordinary index\\n\");\n    printf(\"\\t[-ty\\tindex type (o, c, b, e, p, f) (default ordinary)]\\n\");\n    printf(\"\\t\\tordinary, counter, bits, extend, pin pass, pin fail\\n\");\n    printf(\"\\t[-pol\\tpolicy file (default empty)]\\n\");\n    printf(\"\\t\\tsets POLICYWRITE, POLICYREAD\\n\");\n    printf(\"\\t[+at\\tattributes to add (may be specified more than once)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\tppw   (PPWRITE)\\t\\tppr (PPREAD) \\n\");\n    printf(\"\\t\\tow    (OWNERWRITE)\\tor  (OWNERREAD) \\n\");\n    printf(\"\\t\\taw    (AUTHWRITE)\\tar  (AUTHREAD) \\n\");\n    printf(\"\\t\\twd    (WRITEDEFINE)\\tgl  (GLOBALLOCK) \\n\");\n    printf(\"\\t\\trst   (READ_STCLEAR)\\twst (WRITE_STCLEAR) \\n\");\n    printf(\"\\t\\twa    (WRITEALL)\\tody (ORDERLY) \\n\");\n    printf(\"\\t\\tpold  (POLICY_DELETE) \\tstc (CLEAR_STCLEAR) \\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-at\\tattributes to delete (may be specified more than once)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\tppw   (PPWRITE)\\t\\tppr (PPREAD)\\n\");\n    printf(\"\\t\\tow    (OWNERWRITE)\\tor  (OWNERREAD)\\n\");\n    printf(\"\\t\\taw    (AUTHWRITE)\\tar  (AUTHREAD)\\n\");\n    printf(\"\\t\\tpw    (POLICYWRITE)\\tpr  (POLICYREAD)\\n\");\n    printf(\"\\t\\tda    (NO_DA) (default set)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvextend.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV Extend\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_Extend_In \t\tin;\n    const char \t\t\t*data = NULL;\n    const char \t\t\t*datafilename = NULL;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    const char\t\t\t*nvPassword = NULL; \t\t/* default no password */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdata = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-if\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdatafilename = argv[i];\n\t    } else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    if ((data == NULL) && (datafilename == NULL)) {\n\tprintf(\"Data string or data file must be specified\\n\");\n\tprintUsage();\n    }\n    if ((data != NULL) && (datafilename != NULL)) {\n\tprintf(\"Data string and data file cannot both be specified\\n\");\n\tprintUsage();\n    }\n    if ((rc == 0) && (data != NULL)) {\n\trc = TSS_TPM2B_StringCopy(&in.data.b,\n\t\t\t\t  data, sizeof(in.data.t.buffer));\n\t\n    }\n    if ((rc == 0) && (datafilename != NULL)) {\n\trc = TSS_File_Read2B(&in.data.b,\n\t\t\t     sizeof(in.data.t.buffer),\n\t\t\t     datafilename);\n    }\n    if (rc == 0) {\n\tin.authHandle = nvIndex;\n\tin.nvIndex = nvIndex;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_Extend,\n\t\t\t sessionHandle0, nvPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"nvextend: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvextend: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvextend\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_Extend\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t-pwdn\\tpassword for NV index (default empty)\\n\");\n    printf(\"\\t-ic\\tdata string\\n\");\n    printf(\"\\t-if\\tdata file\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvglobalwritelock.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV GlobalWriteLock\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_GlobalWriteLock_In \tin;\n    char \t\t\thierarchyAuthChar = 0;\n    const char\t\t\t*password = NULL; \t\t/* default no password */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hia\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyAuthChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hia\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Authorization handle */\n    if (rc == 0) {\n\tif (hierarchyAuthChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;  \n\t}\n\telse if (hierarchyAuthChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;  \n\t}\n\telse {\n\t    printf(\"-hia has bad parameter %c\\n\", hierarchyAuthChar);\n\t    printUsage();\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_GlobalWriteLock,\n\t\t\t sessionHandle0, password, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"nvglobalwritelock: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvglobalwritelock: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvglobalwritelock\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_GlobalWriteLock\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hia\\thierarchy authorization (o, p)\\n\");\n    printf(\"\\t[-pwd\\tauthorization password (default empty)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvincrement.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV_Increment\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <inttypes.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_Increment_In \t\tin;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    const char\t\t\t*nvPassword = NULL; \t\t/* default no password */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.authHandle = nvIndex;\n\tin.nvIndex = nvIndex;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_Increment,\n\t\t\t sessionHandle0, nvPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    { \n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"nvincrement: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvincrement: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvincrement\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_Increment\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t-pwdn\\tpassword for NV index (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvread.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV Read\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include \"ekutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_Read_In \t\t\tin;\n    NV_Read_Out\t\t\tout;\n    uint16_t \t\t\toffset = 0;\t\t\t/* default 0 */\n    uint16_t \t\t\treadLength = 0;\t\t\t/* bytes to read */\n    int \t\t\tireadLength = 0;\t\t/* bytes to read as integer */\n    int \t\t\tcert = FALSE;\t\t\t/* boolean, read certificate */\n    const char\t\t\t*certificateFilename = NULL;\n    int\t\t\t\treadLengthSet = FALSE;\n    char \t\t\thierarchyAuthChar = 0;\n    const char \t\t\t*datafilename = NULL;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    const char\t\t\t*nvPassword = NULL; \t\t/* default no password */\n    uint32_t \t\t\tpinCount = 0;\t/* these two initialized to suppress falose gcc -O3\n\t\t\t\t\t\t   warnings */\n    uint32_t \t\t\tpinLimit = 0;\n    int\t\t\t\tinData = FALSE;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    unsigned char \t\t*readBuffer = NULL; \n    uint32_t \t\t\tnvBufferMax;\n    uint16_t \t\t\tbytesRead;\t\t\t/* bytes read so far */\n    int\t\t\t\tdone = FALSE;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hia\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyAuthChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hia\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdatafilename = argv[i];\n\t    } else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-off\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toffset = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-off option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sz\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tireadLength = atoi(argv[i]);\n\t\treadLengthSet  = TRUE;\n\t    }\n\t    else {\n\t\tprintf(\"-sz option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t    if ((ireadLength >= 0) && (ireadLength <= 0xffff)) {\n\t\treadLength = (uint16_t)ireadLength;\n\t    }\n\t    else {\n\t\tprintf(\"-sz %d out of range\\n\", ireadLength);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (!strcmp(\"-cert\",argv[i])) {\n\t    cert = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-ocert\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcertificateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ocert option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-id\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpinCount = atoi(argv[i]);\n\t\ti++;\n\t\tif (i < argc) {\n\t\t    pinLimit = atoi(argv[i]);\n\t\t    inData = TRUE;\n\t\t}\n\t\telse {\n\t\t    printf(\"-id option needs two values\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-id option needs two values\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    /* Authorization handle */\n    if (rc == 0) {\n\tif (hierarchyAuthChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;  \n\t}\n\telse if (hierarchyAuthChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;  \n\t}\n\telse if (hierarchyAuthChar == 0) {\n\t    in.authHandle = nvIndex;\n\t}\n\telse {\n\t    printf(\"-hia has bad parameter %c\\n\", hierarchyAuthChar);\n\t    printUsage();\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* Determine the readLength from the NV index type.  This is just for the utility.  An\n       application would already know the index type. */\n    if (!readLengthSet) {\t/* if caller specifies a read length, use it */\n\tNV_ReadPublic_In \t\tin;\n\tNV_ReadPublic_Out\t\tout;\n\tif (rc == 0) {\n\t    in.nvIndex = nvIndex;\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     (RESPONSE_PARAMETERS *)&out,\n\t\t\t     (COMMAND_PARAMETERS *)&in,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_NV_ReadPublic,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n\tif (rc == 0) {\n\t    TPMI_ALG_HASH nameAlg;\n\t    uint32_t nvType = (out.nvPublic.nvPublic.attributes.val & TPMA_NVA_TPM_NT_MASK) >> 4;\n\t    switch (nvType) {\n\t      case TPM_NT_ORDINARY:\n\t\treadLength = out.nvPublic.nvPublic.dataSize;\n\t\tbreak;\n\t      case TPM_NT_COUNTER:\n\t      case TPM_NT_BITS:\n\t      case TPM_NT_PIN_FAIL:\n\t      case TPM_NT_PIN_PASS:\n\t\treadLength = 8;\n\t\tbreak;\n\t      case TPM_NT_EXTEND:\n\t\tnameAlg = out.nvPublic.nvPublic.nameAlg;\n\t\treadLength = TSS_GetDigestSize(nameAlg);\n\t\tbreak;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (readLength > 0) {\t\n\t    readBuffer = malloc(readLength);\t\t/* freed @1 */\n\t    if (readBuffer == NULL) {\n\t\tprintf(\"Cannot malloc %u bytes for read buffer\\n\", readLength);\n\t\texit(1);\t\n\t    }\n\t}\n\telse {\n\t    readBuffer = NULL;\n\t}\n    }\n    if ((rc == 0) && inData) {\n\tif (readLength != 8) {\n\t    printf(\"-id needs read length 8, is %u\\n\", readLength);\n\t    exit(1);\t\n\t}\n    }\n    /* data may have to be read in chunks.  Read the TPM_PT_NV_BUFFER_MAX, the chunk size */\n    if (rc == 0) {\n\trc = readNvBufferMax(tssContext,\n\t\t\t     &nvBufferMax);\n    }    \n    if (rc == 0) {\n\tin.nvIndex = nvIndex;\n\tin.offset = offset;\t/* start at supplied offset */\n\tbytesRead = 0;\t\t/* bytes read so far */\n    }\n    /* call TSS to execute the command */\n    while ((rc == 0) && !done) {\n\tif (rc == 0) {\n\t    /* read a chunk */\n\t    in.offset = offset + bytesRead;\n\t    if ((uint32_t)(readLength - bytesRead) < nvBufferMax) {\n\t\tin.size = readLength - bytesRead;\t/* last chunk */\n\t    }\n\t    else {\n\t\tin.size = nvBufferMax;\t\t/* next chunk */\n\t    }\n\t}\n\tif (rc == 0) {\n\t    if (tssUtilsVerbose) printf(\"nvread: reading %u bytes\\n\", in.size);\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     (RESPONSE_PARAMETERS *)&out,\n\t\t\t     (COMMAND_PARAMETERS *)&in,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_NV_Read,\n\t\t\t     sessionHandle0, nvPassword, sessionAttributes0,\n\t\t\t     sessionHandle1, NULL, sessionAttributes1,\n\t\t\t     sessionHandle2, NULL, sessionAttributes2,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n\t/* copy the results to the read buffer */\n\tif ((rc == 0) && (readBuffer != NULL)) {\t/* check to handle 0 size read */\n\t    memcpy(readBuffer + bytesRead, out.data.b.buffer, out.data.b.size);\n\t}\n\tif (rc == 0) {\n\t    bytesRead += out.data.b.size;\n\t    if (bytesRead == readLength) {\n\t\tdone = TRUE;\n\t    }\n\t}\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (datafilename != NULL) && (readBuffer != NULL)) {\n\trc = TSS_File_WriteBinaryFile(readBuffer, readLength, datafilename);\n    }\n    if (rc == 0) {\n\t/* if not tracing the certificate, trace the result */\n\tif (!cert) {\n\t    if (tssUtilsVerbose) printf(\"nvread: success\\n\");\n\t    TSS_PrintAll(\"nvread: data\", readBuffer, readLength);\n\t}\n\tif (cert || (certificateFilename != NULL)) {\n\t    void *x509Certificate = NULL;\t/* opaque structure */\n\t    /* convert the DER stream to crypto library structure */\n\t    rc = convertDerToX509(&x509Certificate,\t/* freed @2 */\n\t\t\t\t  readLength,\n\t\t\t\t  readBuffer);\n\t    /* if cert, trace the certificate using openssl print function */\n\t    if ((rc == 0) && cert) {\n\t\tx509PrintStructure(x509Certificate);\n\t    }\n\t    /* if a file name was specified, write the certificate in PEM format */\n\t    if ((rc == 0) && (certificateFilename != NULL)) {\n\t\trc = convertX509ToPem(certificateFilename,\n\t\t\t\t      x509Certificate);\n\t    }\n\t    x509FreeStructure(x509Certificate);   \t/* @2 */\n\t}\n    }\n    /* PIN index regression test aid, compare expected to actual */\n    if (rc == 0) {\n\tif (inData) {\n\t    uint32_t tmpSize = 8;\t\t/* readLength was checked previously */\n\t    uint8_t *tmpBuffer = readBuffer;\n\t    uint32_t actual;\t\t/* data comes off TPM big endian (nbo) */\n\n\t    TSS_UINT32_Unmarshalu(&actual, &tmpBuffer, &tmpSize);\n\t    if (pinCount != actual) {\n\t\tprintf(\"Error: Expected pinCount %u Actual %u\\n\", pinCount, actual);\n\t\trc = TSS_RC_BAD_READ_VALUE;\n\t    }\n\t    TSS_UINT32_Unmarshalu(&actual, &tmpBuffer, &tmpSize);\n\t    if (pinLimit != actual) {\n\t\tprintf(\"Error: Expected pinLimit %u Actual %u\\n\", pinLimit, actual);\n\t\trc = TSS_RC_BAD_READ_VALUE;\n\t    }\n\t}\n    }\n    if (rc != 0) {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvread: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(readBuffer);\t/* @1 */\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvread\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_Read\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hia\\thierarchy authorization (o, p)(default index authorization)]\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t[-pwdn\\tpassword for NV index (default empty)]\\n\");\n    printf(\"\\t[-sz\\tdata size (default to size of index)]\\n\");\n    printf(\"\\t\\tcounter, bits, pin read 8 bytes, extend reads based on hash algorithm\\n\");\n    printf(\"\\t[-cert\\tdumps the certificate\\n\");\n    printf(\"\\t01c00002\\tRSA EK certificate\\n\");\n    printf(\"\\t01c0000a\\tECC EK certificate\\n\");\n    printf(\"\\t[-ocert\\t certificate file name, writes in PEM format\\n\");\n    printf(\"\\t[-off\\t offset (default 0)]\\n\");\n    printf(\"\\t[-of\\t data file (default do not save)]\\n\");\n    printf(\"\\t[-id\\tdata values for pinCount and pinLimit verification, (4 bytes each)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvreadlock.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV ReadLock\t \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: nvreadlock.c 1290 2018-08-01 14:45:24Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_ReadLock_In \t\tin;\n    char \t\t\thierarchyAuthChar = 0;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    const char\t\t\t*nvPassword = NULL; \t\t/* default no password */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hia\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyAuthChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hia\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    /* Authorization handle */\n    if (rc == 0) {\n\tif (hierarchyAuthChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;  \n\t}\n\telse if (hierarchyAuthChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;  \n\t}\n\telse if (hierarchyAuthChar == 0) {\n\t    in.authHandle = nvIndex;\n\t}\n\telse {\n\t    printf(\"-hia has bad parameter %c\\n\", hierarchyAuthChar);\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.nvIndex = nvIndex;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_ReadLock,\n\t\t\t sessionHandle0, nvPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"nvreadlock: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvreadlock: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvreadlock\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_ReadLock\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hia\\thierarchy authorization (o, p)(default index authorization)]\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t-pwdn\\tpassword for NV index (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvreadpublic.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV ReadPublic\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n/* for endian conversion */\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsscrypto.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_ReadPublic_In \t\tin;\n    NV_ReadPublic_Out\t\tout;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    TPMI_ALG_HASH\t\tnalg = TPM_ALG_NULL;\n    TPMI_ALG_HASH \t\tnameHashAlg;\n    const char\t\t\t*nvPublicFilename = NULL;\n    const char\t\t\t*nameFilename = NULL;\n    int\t\t\t\tnoSpace = FALSE;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    nalg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    nalg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    nalg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    nalg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -nalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-nalg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPublicFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ns\") == 0) {\n\t    noSpace = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-on\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnameFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-on option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.nvIndex = nvIndex;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_ReadPublic,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* NOTE: The caller validates the result to the extent that it does not trust the NV index to be\n       defined properly */\n    \n    /* Table 197 - Definition of TPM2B_NV_PUBLIC Structure - nvPublic*/\n    /* Table 196 - Definition of TPMS_NV_PUBLIC Structure */\n    /* Table 83 - Definition of TPM2B_NAME Structure t */\n\n    /* TPMS_NV_PUBLIC hash alg vs expected */\n    if (rc == 0) {\n\tif ((nalg != TPM_ALG_NULL) && (out.nvPublic.nvPublic.nameAlg != nalg)) {\n\t    printf(\"nvreadpublic: TPM2B_NV_PUBLIC hash algorithm does not match expected\\n\");\n\t    rc = TSS_RC_MALFORMED_NV_PUBLIC;\n\t}\n    }\n    /* TPM2B_NAME hash algorithm vs expected */\n    if (rc == 0) {\n\tuint16_t tmp16;\n\tmemcpy(&tmp16, out.nvName.t.name, sizeof(uint16_t));\n\t/* nameHashAlg = ntohs(*(TPMI_ALG_HASH *)(out.nvName.t.name)); */\n\tnameHashAlg = ntohs(tmp16);\n\tif ((nalg != TPM_ALG_NULL) && (nameHashAlg != nalg)) {\n\t    printf(\"nvreadpublic: TPM2B_NAME hash algorithm does not match expected\\n\");\n\t    rc = TSS_RC_MALFORMED_NV_PUBLIC;\n\t}\n    }\n    /* TPMS_NV_PUBLIC index vs expected */\n    if (rc == 0) {\n\tif (out.nvPublic.nvPublic.nvIndex != in.nvIndex) {\n\t    printf(\"nvreadpublic: TPM2B_NV_PUBLIC index does not match expected\\n\");\n\t    rc = TSS_RC_MALFORMED_NV_PUBLIC;\n\t}\n    }\n    /* save the public key */\n    if ((rc == 0) && (nvPublicFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.nvPublic,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_NV_PUBLIC_Marshalu,\n\t\t\t\t     nvPublicFilename);\n    }\n    /* save the Name */\n    if ((rc == 0) && (nameFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.nvName.b.buffer,\n\t\t\t\t      out.nvName.b.size,\n\t\t\t\t      nameFilename);\n    }\n    if (rc == 0) {\n\tprintf(\"nvreadpublic: name algorithm %04x\\n\", out.nvPublic.nvPublic.nameAlg);\n\tprintf(\"nvreadpublic: data size %u\\n\", out.nvPublic.nvPublic.dataSize);\n\tprintf(\"nvreadpublic: attributes %08x\\n\", out.nvPublic.nvPublic.attributes.val);\n\tTSS_TPMA_NV_Print(out.nvPublic.nvPublic.attributes, 0);\n\tTSS_PrintAll(\"nvreadpublic: policy\",\n\t\t     out.nvPublic.nvPublic.authPolicy.t.buffer,\n\t\t     out.nvPublic.nvPublic.authPolicy.t.size);\n\tTSS_PrintAll(\"nvreadpublic: name\",\n\t\t     out.nvName.t.name, out.nvName.t.size);\n\tif (noSpace) {\n\t    unsigned int b;\n\t    for (b = 0 ; b < out.nvName.t.size ; b++) {\n\t\tprintf(\"%02x\", out.nvName.t.name[b]);\n\t    }\n\t    printf(\"\\n\");\n\t}\n\tif (tssUtilsVerbose) printf(\"nvreadpublic: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvreadpublic: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvreadpublic\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_ReadPublic\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t[-nalg\\texpected name hash algorithm (sha1, sha256, sha384 sha512)\\n\"\n\t   \"\\t\\t(default no check)]\\n\");\n    printf(\"\\t[-opu\\tNV public file name (default do not save)]\\n\");\n    printf(\"\\t[-ns\\tadditionally print Name in hex ascii on one line]\\n\");\n    printf(\"\\t[-on\\tbinary format Name file name]\\n\");\n    printf(\"\\t\\tUseful to paste into policy\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\t80\\taudit\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvsetbits.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV SetBits\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2024.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/*\n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <inttypes.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsscryptoh.h>\n\nstatic TPM_RC calculateParameterHash(const NV_SetBits_In *in,\n\t\t\t\t     const TPMI_ALG_HASH halg,\n\t\t\t\t     const char *pHashFilename);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_SetBits_In \t\tin;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    TPMI_ALG_HASH \t\thalg = TPM_ALG_NULL;\t\t/* no default */\n    int\t\t\t\tpHash = FALSE;\t\t\t/* default run command */\n    const char \t\t\t*pHashFilename;\t\t\t/* binary output */\n    const char\t\t\t*nvPassword = NULL; \t\t/* default no password */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    in.bits = 0;\t/* default no bits */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-bit\") == 0) {\n\t    unsigned int bit;\n\t    i++;\n\t    if (i < argc) {\n\t\tbit = atoi(argv[i]);\n\t\tif (bit < 64) {\n\t\t    in.bits |= (uint64_t)1 << bit;\n\t\t}\n\t\telse {\n\t\t    printf(\"-bit out of range\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-bit option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-phash\") == 0) {\n\t    pHash = TRUE;\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -phash algorithm\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tpHashFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-phash option needs two values\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.authHandle = nvIndex;\n\tin.nvIndex = nvIndex;\n    }\n    /* run the command */\n    if (!pHash) {\n\t/* Start a TSS context */\n\tif (rc == 0) {\n\t    rc = TSS_Create(&tssContext);\n\t}\n\t/* call TSS to execute the command */\n\tif (rc == 0) {\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     NULL,\n\t\t\t     (COMMAND_PARAMETERS *)&in,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_NV_SetBits,\n\t\t\t     sessionHandle0, nvPassword, sessionAttributes0,\n\t\t\t     sessionHandle1, NULL, sessionAttributes1,\n\t\t\t     sessionHandle2, NULL, sessionAttributes2,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n\t{\n\t    TPM_RC rc1 = TSS_Delete(tssContext);\n\t    if (rc == 0) {\n\t\trc = rc1;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    if (tssUtilsVerbose) printf(\"nvsetbits: success\\n\");\n\t}\n    }\n    /* calculate pHash */\n    else {\n\tif (rc == 0) {\n\t    rc = calculateParameterHash(&in, halg, pHashFilename);\n\t}\n    }\n    if (rc != 0) {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvsetbits: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n/* calculateParameterHash() calculates the parameter hash, suitable for input to a policyparameters\n   calculation */\n\nstatic TPM_RC calculateParameterHash(const NV_SetBits_In *in,\n\t\t\t\t     const TPMI_ALG_HASH halg,\n\t\t\t\t     const char *pHashFilename)\n{\n    TPM_RC \trc = 0;\n    uint8_t \tpBuffer[MAX_COMMAND_SIZE];\t/* the marshalled parameters */\n    TPM_CC \tcommandCode = TPM_CC_NV_SetBits;\n    TPM_CC\tcommandCodeNbo = htonl(commandCode);\n    uint16_t \tparameterSize = 0;\t\t/* the marshalled parameter size */\n    uint32_t \tsizeInBytes;\n    TPMT_HA\tdigest;\n    uint8_t \t*paramPtr = pBuffer;\t/* because the marshal function moves the pointer */\n    uint32_t \tsizeLeft = sizeof(pBuffer);\n\n    /* marshal the input parameters */\n    if (rc == 0) {\n\trc = TSS_NV_SetBits_In_Marshalu(in, &parameterSize, &paramPtr, &sizeLeft);\n    }\n    /* calculate the parameter hash */\n    if (rc == 0) {\n\t/* move the pointer and size past the handle area, this command has two handles */\n\tparamPtr = pBuffer + (2 * (sizeof(TPM_HANDLE)));\n\tparameterSize -= (2 * (sizeof(TPM_HANDLE)));\n\tif (tssUtilsVerbose) TSS_PrintAll(\"pBuffer\", pBuffer, parameterSize);\n\tsizeInBytes = TSS_GetDigestSize(halg);\n\tdigest.hashAlg = halg;\t\t\t/* session digest algorithm */\n\trc = TSS_Hash_Generate(&digest,\t\t/* largest size of a digest */\n\t\t\t       sizeof(TPM_CC), &commandCodeNbo,\n\t\t\t       parameterSize, paramPtr,\n\t\t\t       0, NULL);\n    }\n    /* putput as hexascii for policymaker input */\n    if (rc == 0) {\n\tuint32_t i;\n\tfor (i = 0 ; i < sizeInBytes ; i++) {\n\t    printf(\"%02x\", digest.digest.tssmax[i]);\n\t}\n\tprintf(\"\\n\");\n    }\n    /* output as binary for policyparameters input */\n    if (rc == 0) {\n\trc = TSS_File_WriteBinaryFile(digest.digest.tssmax,\n\t\t\t\t      sizeInBytes,\n\t\t\t\t      pHashFilename);\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvsetbits\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_SetBits\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t[-pwdn\\tpassword for NV index (default empty)]\\n\");\n    printf(\"\\t[-bit\\tbit to set, can be specified multiple times]\\n\");\n    printf(\"\\t[-phash\\tpolicy hash algorithm (sha1, sha256, sha384, sha512)]\\n\"\n\t   \"\\t\\tand binary output file name\\n\");\n    printf(\"\\t\\tOutputs the parameter hash, does not run the command\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvundefinespace.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV Undefine Space\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_UndefineSpace_In \tin;\n    char \t\t\thierarchyChar = 0;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    const char\t\t\t*parentPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tparentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (hierarchyChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.nvIndex = nvIndex;\t/* the NV Index to remove from NV space */\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_UndefineSpace,\n\t\t\t sessionHandle0, parentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"nvundefinespace: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvundefinespace: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvundefinespace\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_UndefineSpace\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hi\\thierarchy (o, p)\\n\");\n    printf(\"\\t\\to owner, p platform\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t-pwdp\\tpassword for hierarchy (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvundefinespacespecial.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV Undefine Space Special \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_UndefineSpaceSpecial_In \tin;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    const char\t\t\t*nvPassword = NULL; \t\t/* default no password */\n    const char\t\t\t*platformPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tplatformPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.platform = TPM_RH_PLATFORM;\n\tin.nvIndex = nvIndex;\t/* the NV Index to remove from NV space */\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_UndefineSpaceSpecial,\n\t\t\t sessionHandle0, nvPassword, sessionAttributes0,\n\t\t\t sessionHandle1, platformPassword, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"nvundefinespacespecial: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvundefinespacespecial: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvundefinespacespecial\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_UndefineSpaceSpecial\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t[-pwdp\\tpassword for platform (default empty)]\\n\");\n    printf(\"\\t[-pwdn\\tpassword for NV index (default empty)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvwrite.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV Write\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include \"ekutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_Write_In \t\tin;\n    uint16_t \t\t\toffset = 0;\t\t\t/* default 0 */\n    uint32_t \t\t\tpinPass = 0;\t/* these two initialized to suppress falose gcc -O3\n\t\t\t\t\t\t   warnings */\n    uint32_t \t\t\tpinLimit = 0;\n    int\t\t\t\tinData = FALSE;\n    unsigned int\t\tdataSource = 0;\n    const char \t\t\t*commandData = NULL;\n    const char \t\t\t*datafilename = NULL;\n    char \t\t\thierarchyAuthChar = 0;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    const char\t\t\t*nvPassword = NULL; \t\t/* default no password */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    uint32_t \t\t\tnvBufferMax;\n    size_t \t\t\twriteLength;\t\t/* file bytes to write */\n    unsigned char \t\t*writeBuffer = NULL; \t/* file buffer to write */\n    uint16_t \t\t\tbytesWritten;\t\t/* bytes written so far */\n    int\t\t\t\tdone = FALSE;\n \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hia\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyAuthChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hia\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcommandData = argv[i];\n\t\tdataSource++;\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-if\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdatafilename = argv[i];\n\t\tdataSource++;\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-id\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpinPass = atoi(argv[i]);\n\t\ti++;\n\t\tif (i < argc) {\n\t\t    pinLimit = atoi(argv[i]);\n\t\t    dataSource++;\n\t\t    inData = TRUE;\n\t\t}\n\t\telse {\n\t\t    printf(\"-id option needs two values\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-id option needs two values\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-off\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toffset = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-off option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    if (dataSource > 1) {\n\tprintf(\"More than one input data source (-if, -ic, -id\\n\");\n\tprintUsage();\n    }\n    /* Authorization handle */\n    if (rc == 0) {\n\tif (hierarchyAuthChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;  \n\t}\n\telse if (hierarchyAuthChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;  \n\t}\n\telse if (hierarchyAuthChar == 0) {\n\t    in.authHandle = nvIndex;\n\t}\n\telse {\n\t    printf(\"-hia has bad parameter %c\\n\", hierarchyAuthChar);\n\t    printUsage();\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* data may have to be written in chunks.  Read the chunk size */\n    if (rc == 0) {\n\trc = readNvBufferMax(tssContext,\n\t\t\t     &nvBufferMax);\n    }\n    /* if there is no input data source, default to 0 byte write */\n    if ((rc == 0) && (dataSource == 0)) {\n\tin.data.b.size = 0;\n    }\n    /* -if, file data can be written in chunks */\n    if ((rc == 0) && (datafilename != NULL)) {\n\trc = TSS_File_ReadBinaryFile(&writeBuffer,     /* freed @1 */\n\t\t\t\t     &writeLength,\n\t\t\t\t     datafilename);\n    }\n    if ((rc == 0) && (datafilename != NULL)) {\n\tif (writeLength > 0xffff) {\t/* overflow TPM2B uint16_t */\n\t    printf(\"nvwrite: size %u greater than 0xffff\\n\", (unsigned int)writeLength);\t\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* -id, for pin pass or pin fail */\n    if ((rc == 0) && (inData)) {\n\tuint32_t tmpData;\n\tin.data.b.size = sizeof(uint32_t) + sizeof(uint32_t);\n\ttmpData = htonl(pinPass);\n\tmemcpy(in.data.b.buffer, &tmpData, sizeof(tmpData));\n\ttmpData = htonl(pinLimit);\n\tmemcpy(in.data.b.buffer + sizeof(tmpData), &tmpData, sizeof(tmpData));\n    }\n    /* -ic, command line data must fit in one write */\n    if ((rc == 0) && (commandData != NULL)) {\n\trc = TSS_TPM2B_StringCopy(&in.data.b, commandData, nvBufferMax);\n    }\n    if (rc == 0) {\n\tin.nvIndex = nvIndex;\n\tin.offset = offset;\t\t/* beginning offset */\n\tbytesWritten = 0;\n    }\n    while ((rc == 0) && !done) {\n\tuint16_t writeBytes = 0;\t\t/* bytes to write in this pass, initialized to\n\t\t\t\t\t\t   suppress false gcc -O3 warning */\n\tif (rc == 0) {\n\t    /* for data from file, write a chunk */\n\t    if (datafilename != NULL) {\n\t\tin.offset = offset + bytesWritten;\n\t\tif ((uint32_t)(writeLength - bytesWritten) < nvBufferMax) {\n\t\t    writeBytes = (uint16_t)writeLength - bytesWritten;\t/* last chunk */\n\t\t}\n\t\telse {\n\t\t    writeBytes = nvBufferMax;\t/* next chunk */\n\t\t}\n\t\trc = TSS_TPM2B_Create(&in.data.b, writeBuffer + bytesWritten, writeBytes,\n\t\t\t\t      sizeof(in.data.t.buffer));\n\t    }\n\t}\n\t/* call TSS to execute the command */\n\tif (rc == 0) {\n\t    if (tssUtilsVerbose) printf(\"nvwrite: writing %u bytes\\n\", in.data.b.size);\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     NULL,\n\t\t\t     (COMMAND_PARAMETERS *)&in,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_NV_Write,\n\t\t\t     sessionHandle0, nvPassword, sessionAttributes0,\n\t\t\t     sessionHandle1, NULL, sessionAttributes1,\n\t\t\t     sessionHandle2, NULL, sessionAttributes2,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n\t/* data file can be written in chunks, other options are single write */\n\tif (rc == 0) {\n\t    if (datafilename == NULL) {\n\t\tdone = TRUE;\n\t    }\n\t    else {\n\t\tbytesWritten += writeBytes;\n\t\tif (bytesWritten == writeLength) {\n\t\t    done = TRUE;\n\t\t}\n\t    }\n\t}\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"nvwrite: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvwrite: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\tif (rc == TSS_RC_FILE_OPEN) {\n\t    printf(\"Possible cause: missing nvreadpublic before nvwrite\\n\");\n\t}\n\trc = EXIT_FAILURE;\n    }\n    free(writeBuffer);\t/* @1 */\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvwrite\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_Write\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hia\\thierarchy authorization (o, p)(default index authorization)]\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t[-pwdn\\tauthorization password (default empty)]\\n\");\n    printf(\"\\t\\thierarchy or NV index password\\n\");\n    printf(\"\\t[-ic\\tdata string]\\n\");\n    printf(\"\\t[-if\\tdata file]\\n\");\n    printf(\"\\t[-id\\tdata values, pinPass and pinLimit (4 bytes each)]\\n\");\n    printf(\"\\t\\tif none is specified, a 0 byte write occurs\\n\");\n    printf(\"\\t\\t-id is normally used for pin pass or pin fail indexes\\n\");\n    printf(\"\\t[-off\\toffset (default 0)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/nvwritelock.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV WriteLock\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    NV_WriteLock_In \t\tin;\n    char \t\t\thierarchyAuthChar = 0;\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    const char\t\t\t*nvPassword = NULL; \t\t/* default no password */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hia\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyAuthChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hia\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((nvIndex >> 24) != TPM_HT_NV_INDEX) {\n\tprintf(\"NV index handle not specified or out of range, MSB not 01\\n\");\n\tprintUsage();\n    }\n    /* Authorization handle */\n    if (rc == 0) {\n\tif (hierarchyAuthChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;  \n\t}\n\telse if (hierarchyAuthChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;  \n\t}\n\telse if (hierarchyAuthChar == 0) {\n\t    in.authHandle = nvIndex;\n\t}\n\telse {\n\t    printf(\"-hia has bad parameter %c\\n\", hierarchyAuthChar);\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.nvIndex = nvIndex;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_WriteLock,\n\t\t\t sessionHandle0, nvPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"nvwritelock: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"nvwritelock: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"nvwritelock\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_NV_WriteLock\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hia\\thierarchy authorization (o, p) (default index authorization)]\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t-pwdn\\tpassword for NV index (default empty)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/objectchangeauth.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    ObjectChangeAuth\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ObjectChangeAuth_In \tin;\n    ObjectChangeAuth_Out \tout;\n    TPMI_DH_OBJECT\t\tparentHandle = TPM_RH_NULL;\n    TPMI_DH_OBJECT\t\tobjectHandle = TPM_RH_NULL;\n    const char\t\t\t*objectPassword = NULL; \n    const char\t\t\t*newPassword = NULL;\n    const char\t\t\t*newPasswordFilename = NULL;\n    uint8_t\t\t\t*newPasswordBuffer = NULL;\n    size_t \t\t\tnewPasswordBufferLength = 0;\n    const char\t\t\t*newPasswordPtr = NULL;\n    const char\t\t\t*privateKeyFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &parentHandle );\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ho\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &objectHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ho\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdo\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tobjectPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdo option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnewPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipwdn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnewPasswordFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipwdn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tprivateKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opr option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (parentHandle  == TPM_RH_NULL) {\n\tprintf(\"Missing or bad parent handle parameter -hp\\n\");\n\tprintUsage();\n    }\n    if (objectHandle == TPM_RH_NULL) {\n\tprintf(\"Missing or bad object handle parameter -ho\\n\");\n\tprintUsage();\n    }\n    if ((newPassword != NULL) && (newPasswordFilename != NULL)) {\n\tprintf(\"Only one of -pwdn and -ipwdn can be specified\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.objectHandle = objectHandle;\n\tin.parentHandle = parentHandle;\n    }\n    if (rc == 0) {\n\t/* use passsword from command line */\n\tif (newPassword != NULL) {\n\t    newPasswordPtr = newPassword;\n\t}\n\t/* use password from file */\n\telse if (newPasswordFilename != NULL) {\n\t    rc = TSS_File_ReadBinaryFile(&newPasswordBuffer,     /* freed @1 */\n\t\t\t\t\t &newPasswordBufferLength,\n\t\t\t\t\t newPasswordFilename);\n\t    if ((newPasswordBufferLength == 0) ||\n\t\t(newPasswordBuffer[newPasswordBufferLength-1] != '\\0')) {\n\t\tprintf(\"-ipwdn file must be nul terminated\\n\");\n\t\tprintUsage();\n\t    }\n\t    newPasswordPtr = (const char *)newPasswordBuffer;\n\t}\n\t/* empty password */\n\telse {\n\t    newPasswordPtr = NULL;\n\t}\n    }\n    /* convert password string to TPM2B */\n    if (rc == 0) {\n\tif (newPasswordPtr == NULL) {\n\t    in.newAuth.t.size = 0;\n\t}\n\telse {\n\t    rc = TSS_TPM2B_StringCopy(&in.newAuth.b,\n\t\t\t\t      newPasswordPtr, sizeof(in.newAuth.t.buffer));\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ObjectChangeAuth,\n\t\t\t sessionHandle0, objectPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* save the private key */\n    if ((rc == 0) && (privateKeyFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.outPrivate,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PRIVATE_Marshalu,\n\t\t\t\t     privateKeyFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"objectchangeauth: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"objectchangeauth: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(newPasswordBuffer);\t/* @1 */\n\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"objectchangeauth\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ObjectChangeAuth\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hp\\tparent handle\\n\");\n    printf(\"\\t-ho\\tobject handle\\n\");\n    printf(\"\\t[-pwdo\\tpassword for object (default empty)]\\n\");\n    printf(\"\\t[-pwdn\\tnew password for object (default empty)]\\n\");\n    printf(\"\\t[-ipwdn\\t new password file for object, nul terminated (default empty)]\\n\");\n    printf(\"\\t[-opr\\tprivate key file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/objecttemplates.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t Object Templates\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2016 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* These are templates suitable for creating typical objects.  The functions are shared by create\n   and createprimary\n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\n#include \"objecttemplates.h\"\n\n/* asymPublicTemplate() is a template for an ECC or RSA key.\n\n   It can create these types:\n\n   TYPE_ST:   storage key (decrypt, restricted, RSA NULL scheme, EC NULL scheme)\n   TYPE_DEN:  decryption key (not storage key, RSA NULL scheme, EC NULL scheme)\n   TYPE_DEO:  decryption key (not storage key, RSA OAEP scheme, EC NULL scheme)\n   TYPE_DEE:  decryption key (not storage key, RSA ES scheme, EC NULL scheme)\n   TYPE_SI:   signing key (unrestricted, RSA NULL schemem EC NULL scheme)\n   TYPE_SIR:  signing key (restricted, RSA RSASSA scheme, EC ECDSA scheme)\n   TYPE_GP:   general purpose key\n   TYPE_DAA:  signing key (unrestricted, ECDAA)\n   TYPE_DAAR: signing key (restricted, ECDAA)\n*/\n\nTPM_RC asymPublicTemplate(TPMT_PUBLIC *publicArea,\t/* output */\n\t\t\t  TPMA_OBJECT addObjectAttributes,\t/* add default, can be overridden\n\t\t\t\t\t\t\t\t   here */\n\t\t\t  TPMA_OBJECT deleteObjectAttributes,\n\t\t\t  int keyType,\t\t\t/* see above */\n\t\t\t  TPMI_ALG_PUBLIC algPublic,\t/* RSA or ECC */\n\t\t\t  TPMI_RSA_KEY_BITS keyBits,\t/* RSA modulus */\n\t\t\t  TPMI_ECC_CURVE curveID,\t/* for ECC */\n\t\t\t  TPMI_ALG_HASH nalg,\t\t/* Name algorithm */\n\t\t\t  TPMI_ALG_HASH halg,\t\t/* hash algorithm */\n\t\t\t  const char *policyFilename)\t/* binary policy, NULL means empty */\n{\n    TPM_RC\t\t\trc = 0;\n\n    if (rc == 0) {\n\tpublicArea->objectAttributes = addObjectAttributes;\n\t/* Table 185 - TPM2B_PUBLIC inPublic */\n\t/* Table 184 - TPMT_PUBLIC publicArea */\n\tpublicArea->type = algPublic;\t\t/* RSA or ECC */\n\tpublicArea->nameAlg = nalg;\n\n\t/* Table 32 - TPMA_OBJECT objectAttributes */\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_SENSITIVEDATAORIGIN;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_ADMINWITHPOLICY;\n\n\tswitch (keyType) {\n\t  case TYPE_DEN:\n\t  case TYPE_DEO:\n\t  case TYPE_DEE:\n\t    publicArea->objectAttributes.val &= ~TPMA_OBJECT_SIGN;\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_DECRYPT;\n\t    publicArea->objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\t    break;\n\t  case TYPE_ST:\n\t    publicArea->objectAttributes.val &= ~TPMA_OBJECT_SIGN;\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_DECRYPT;\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_RESTRICTED;\n\t    break;\n\t  case TYPE_SI:\n\t  case TYPE_DAA:\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_SIGN;\n\t    publicArea->objectAttributes.val &= ~TPMA_OBJECT_DECRYPT;\n\t    publicArea->objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\t    break;\n\t  case TYPE_SIR:\n\t  case TYPE_DAAR:\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_SIGN;\n\t    publicArea->objectAttributes.val &= ~TPMA_OBJECT_DECRYPT;\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_RESTRICTED;\n\t    break;\n\t  case TYPE_GP:\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_SIGN;\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_DECRYPT;\n\t    publicArea->objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\t    break;\n\t}\n\tpublicArea->objectAttributes.val &= ~deleteObjectAttributes.val;\n    }\n    if (rc == 0) {\n\t/* Table 72 -  TPM2B_DIGEST authPolicy */\n\t/* policy set separately */\n\n\t/* Table 182 - Definition of TPMU_PUBLIC_PARMS parameters */\n\tif (algPublic == TPM_ALG_RSA) {\n\t    /* Table 180 - Definition of {RSA} TPMS_RSA_PARMS rsaDetail */\n\t    /* Table 129 - Definition of TPMT_SYM_DEF_OBJECT Structure symmetric */\n\t    switch (keyType) {\n\t      case TYPE_DEN:\n\t      case TYPE_DEO:\n\t      case TYPE_DEE:\n\t      case TYPE_SI:\n\t      case TYPE_SIR:\n\t      case TYPE_GP:\n\t\t/* Non-storage keys must have TPM_ALG_NULL for the symmetric algorithm */\n\t\tpublicArea->parameters.rsaDetail.symmetric.algorithm = TPM_ALG_NULL;\n\t\tbreak;\n\t      case TYPE_ST:\n\t\tpublicArea->parameters.rsaDetail.symmetric.algorithm = TPM_ALG_AES;\n\t\t/* Table 125 - TPMU_SYM_KEY_BITS keyBits */\n\t\tpublicArea->parameters.rsaDetail.symmetric.keyBits.aes = 128;\n\t\t/* Table 126 - TPMU_SYM_MODE mode */\n\t\tpublicArea->parameters.rsaDetail.symmetric.mode.aes = TPM_ALG_CFB;\n\t\tbreak;\n\t    }\n\n\t    /* Table 155 - Definition of {RSA} TPMT_RSA_SCHEME scheme */\n\t    switch (keyType) {\n\t      case TYPE_DEN:\n\t      case TYPE_GP:\n\t      case TYPE_ST:\n\t      case TYPE_SI:\n\t\tpublicArea->parameters.rsaDetail.scheme.scheme = TPM_ALG_NULL;\n\t\tbreak;\n\t      case TYPE_DEO:\n\t\tpublicArea->parameters.rsaDetail.scheme.scheme = TPM_ALG_OAEP;\n\t\t/* Table 152 - Definition of TPMU_ASYM_SCHEME details */\n\t\t/* Table 152 - Definition of TPMU_ASYM_SCHEME rsassa */\n\t\t/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t\t/* Table 135 - Definition of TPMS_SCHEME_HASH hashAlg */\n\t\tpublicArea->parameters.rsaDetail.scheme.details.oaep.hashAlg = halg;\n\t\tbreak;\n\t      case TYPE_DEE:\n\t\tpublicArea->parameters.rsaDetail.scheme.scheme = TPM_ALG_RSAES;\n\t\t/* Table 152 - Definition of TPMU_ASYM_SCHEME details */\n\t\t/* Table 152 - Definition of TPMU_ASYM_SCHEME rsassa */\n\t\t/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t\t/* Table 135 - Definition of TPMS_SCHEME_HASH hashAlg */\n\t\tpublicArea->parameters.rsaDetail.scheme.details.oaep.hashAlg = halg;\n\t\tbreak;\n\t      case TYPE_SIR:\n\t\tpublicArea->parameters.rsaDetail.scheme.scheme = TPM_ALG_RSASSA;\n\t\t/* Table 152 - Definition of TPMU_ASYM_SCHEME details */\n\t\t/* Table 152 - Definition of TPMU_ASYM_SCHEME rsassa */\n\t\t/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t\t/* Table 135 - Definition of TPMS_SCHEME_HASH hashAlg */\n\t\tpublicArea->parameters.rsaDetail.scheme.details.rsassa.hashAlg = halg;\n\t\tbreak;\n\t    }\n\t\n\t    /* Table 159 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type keyBits */\n\t    publicArea->parameters.rsaDetail.keyBits = keyBits;\n\t    publicArea->parameters.rsaDetail.exponent = 0;\n\t    /* Table 177 - TPMU_PUBLIC_ID unique */\n\t    /* Table 177 - Definition of TPMU_PUBLIC_ID */\n\t    publicArea->unique.rsa.t.size = 0;\n\t}\n\telse {\t/* algPublic == TPM_ALG_ECC */\n\t    /* Table 181 - Definition of {ECC} TPMS_ECC_PARMS Structure eccDetail */\n\t    /* Table 129 - Definition of TPMT_SYM_DEF_OBJECT Structure symmetric */\n\t    switch (keyType) {\n\t      case TYPE_DEN:\n\t      case TYPE_DEO:\n\t      case TYPE_DEE:\n\t      case TYPE_SI:\n\t      case TYPE_SIR:\n\t      case TYPE_DAA:\n\t      case TYPE_DAAR:\n\t      case TYPE_GP:\n\t\t/* Non-storage keys must have TPM_ALG_NULL for the symmetric algorithm */\n\t\tpublicArea->parameters.eccDetail.symmetric.algorithm = TPM_ALG_NULL;\n\t\tbreak;\n\t      case TYPE_ST:\n\t\tpublicArea->parameters.eccDetail.symmetric.algorithm = TPM_ALG_AES;\n\t\t/* Table 125 - TPMU_SYM_KEY_BITS keyBits */\n\t\tpublicArea->parameters.eccDetail.symmetric.keyBits.aes = 128;\n\t\t/* Table 126 - TPMU_SYM_MODE mode */\n\t\tpublicArea->parameters.eccDetail.symmetric.mode.aes = TPM_ALG_CFB;\n\t\tbreak;\n\t    }\n\t    /* Table 166 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure scheme */\n\t    /* Table 164 - Definition of (TPM_ALG_ID) {ECC} TPMI_ALG_ECC_SCHEME Type scheme */\n\t    switch (keyType) {\n\t      case TYPE_GP:\n\t      case TYPE_SI:\n\t      case TYPE_DEN:\n\t      case TYPE_DEO:\n\t      case TYPE_DEE:\n\t\tpublicArea->parameters.eccDetail.scheme.scheme = TPM_ALG_NULL;\n\t\t/* Table 165 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */\n\t\t/* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants curveID */\n\t\tpublicArea->parameters.eccDetail.curveID = curveID;\n\t\t/* Table 150 - Definition of TPMT_KDF_SCHEME Structure kdf */\n\t\t/* Table 64 - Definition of (TPM_ALG_ID) TPMI_ALG_KDF Type */\n\t\tpublicArea->parameters.eccDetail.kdf.scheme = TPM_ALG_NULL;\n\t\tbreak;\n\t      case TYPE_SIR:\n\t\tpublicArea->parameters.eccDetail.scheme.scheme = TPM_ALG_ECDSA;\n\t\t/* Table 152 - Definition of TPMU_ASYM_SCHEME details */\n\t\t/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\t\tpublicArea->parameters.eccDetail.scheme.details.ecdsa.hashAlg = halg;\n\t\t/* Table 165 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */\n\t\t/* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants curveID */\n\t\tpublicArea->parameters.eccDetail.curveID = curveID;\n\t\t/* Table 150 - Definition of TPMT_KDF_SCHEME Structure kdf */\n\t\t/* Table 64 - Definition of (TPM_ALG_ID) TPMI_ALG_KDF Type */\n\t\tpublicArea->parameters.eccDetail.kdf.scheme = TPM_ALG_NULL;\n\t\t/* Table 149 - Definition of TPMU_KDF_SCHEME Union <IN/OUT, S> */\n\t\t/* Table 148 - Definition of Types for KDF Schemes, hash-based key-\n\t\t   or mask-generation functions */\n\t\t/* Table 135 - Definition of TPMS_SCHEME_HASH Structure hashAlg */\n\t\tpublicArea->parameters.eccDetail.kdf.details.mgf1.hashAlg = halg;\n\t\tbreak;\n\t      case TYPE_DAA:\n\t      case TYPE_DAAR:\n\t\tpublicArea->parameters.eccDetail.scheme.scheme = TPM_ALG_ECDAA;\n\t\tpublicArea->parameters.eccDetail.scheme.details.ecdaa.hashAlg = halg;\n\t\tpublicArea->parameters.eccDetail.scheme.details.ecdaa.count = 1;\n\t\tpublicArea->parameters.eccDetail.curveID = curveID;\n\t\tpublicArea->parameters.eccDetail.kdf.scheme = TPM_ALG_NULL;\n\t\tpublicArea->unique.ecc.y.t.size = 0;\n\t\tpublicArea->unique.ecc.x.t.size = 0;\n\t\tbreak;\n\t      case TYPE_ST:\n\t\tpublicArea->parameters.eccDetail.scheme.scheme = TPM_ALG_NULL;\n\t\tpublicArea->parameters.eccDetail.scheme.details.anySig.hashAlg = 0;\n\t\tpublicArea->parameters.eccDetail.curveID = curveID;\n\t\tpublicArea->parameters.eccDetail.kdf.scheme = TPM_ALG_NULL;\n\t\tpublicArea->parameters.eccDetail.kdf.details.mgf1.hashAlg = 0;\n\t\tbreak;\n\t    }\n\t    /* Table 177 - TPMU_PUBLIC_ID unique */\n\t    /* Table 177 - Definition of TPMU_PUBLIC_ID */\n\t    publicArea->unique.ecc.x.t.size = 0;\n\t    publicArea->unique.ecc.y.t.size = 0;\n\t}\n    }\n    if (rc == 0) {\n\trc = getPolicy(publicArea, policyFilename);\n    }\n    return rc;\n}\n\n/* symmetricCipherTemplate() is a template for an AES 128 CFB key\n\n */\n\nTPM_RC symmetricCipherTemplate(TPMT_PUBLIC *publicArea,\t\t/* output */\n\t\t\t       TPMA_OBJECT addObjectAttributes,\t/* add default, can be overridden\n\t\t\t\t\t\t\t\t   here */\n\t\t\t       TPMA_OBJECT deleteObjectAttributes,\n\t\t\t       TPMI_ALG_HASH nalg,\t\t/* Name algorithm */\n\t\t\t       int rev116,\t\t/* TPM rev 116 compatibility, sets SIGN */\n\t\t\t       const char *policyFilename)\t/* binary policy, NULL means empty */\n{\n    TPM_RC rc = 0;\n    \n    if (rc == 0) {\n\tpublicArea->objectAttributes = addObjectAttributes;\n\n\t/* Table 185 - TPM2B_PUBLIC inPublic */\n\t/* Table 184 - TPMT_PUBLIC publicArea */\n\tpublicArea->type = TPM_ALG_SYMCIPHER;\n\tpublicArea->nameAlg = nalg;\n\t/* Table 32 - TPMA_OBJECT objectAttributes */\n\t/* rev 116 used DECRYPT for both decrypt and encrypt.  After 116, encrypt required SIGN */\n\tif (!rev116) {\n\t    /* actually encrypt */\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_SIGN;\n\t}\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_DECRYPT;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_SENSITIVEDATAORIGIN;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_ADMINWITHPOLICY;\n\tpublicArea->objectAttributes.val &= ~deleteObjectAttributes.val;\n\t/* Table 72 -  TPM2B_DIGEST authPolicy */\n\t/* policy set separately */\n\t/* Table 182 - Definition of TPMU_PUBLIC_PARMS parameters */\n\t{\n\t    /* Table 131 - Definition of TPMS_SYMCIPHER_PARMS symDetail */\n\t    {\n\t\t/* Table 129 - Definition of TPMT_SYM_DEF_OBJECT sym */\n\t\t/* Table 62 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_OBJECT Type */\n\t\tpublicArea->parameters.symDetail.sym.algorithm = TPM_ALG_AES;\n\t\t/* Table 125 - Definition of TPMU_SYM_KEY_BITS Union */\n\t\tpublicArea->parameters.symDetail.sym.keyBits.aes = 128;\n\t\t/* Table 126 - Definition of TPMU_SYM_MODE Union */\n\t\tpublicArea->parameters.symDetail.sym.mode.aes = TPM_ALG_CFB;\n\t    }\n\t}\n\t/* Table 177 - TPMU_PUBLIC_ID unique */\n\t/* Table 72 - Definition of TPM2B_DIGEST Structure */\n\tpublicArea->unique.sym.t.size = 0; \n    }\n    if (rc == 0) {\n\trc = getPolicy(publicArea, policyFilename);\n    }\n    return rc;\n}\n\n/* keyedHashPublicTemplate() is a template for an HMAC key\n\n   It can create these types:\n\n   TYPE_KH:\tHMAC key, unrestricted\n   TYPE_KHR:\tHMAC key, restricted\n*/\n\nTPM_RC keyedHashPublicTemplate(TPMT_PUBLIC *publicArea,\t\t/* output */\n\t\t\t       TPMA_OBJECT addObjectAttributes,\t/* add default, can be overridden\n\t\t\t\t\t\t\t\t   here */\n\t\t\t       TPMA_OBJECT deleteObjectAttributes,\n\t\t\t       int keyType,\t\t\t/* see above */\n\t\t\t       TPMI_ALG_HASH nalg,\t\t/* Name algorithm */\n\t\t\t       TPMI_ALG_HASH halg,\t\t/* hash algorithm */\n\t\t\t       const char *policyFilename)\t/* binary policy, NULL means empty */\n{\n    TPM_RC\t\t\trc = 0;\n\n    if (rc == 0) {\n\tpublicArea->objectAttributes = addObjectAttributes;\n\n\t/* Table 185 - TPM2B_PUBLIC inPublic */\n\t/* Table 184 - TPMT_PUBLIC publicArea */\n\t/* Table 176 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */\n\tpublicArea->type = TPM_ALG_KEYEDHASH;\n\t/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type  */\n\tpublicArea->nameAlg = nalg;\n\t/* Table 32 - TPMA_OBJECT objectAttributes */\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_SIGN;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_DECRYPT;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_SENSITIVEDATAORIGIN;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_ADMINWITHPOLICY;\n\tswitch (keyType) {\n\t  case TYPE_KH:\n\t    publicArea->objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\t    break;\n\t  case TYPE_KHR:\n\t    publicArea->objectAttributes.val |= TPMA_OBJECT_RESTRICTED;\n\t    break;\n\t}\n\tpublicArea->objectAttributes.val &= ~deleteObjectAttributes.val;\n\t/* Table 72 -  TPM2B_DIGEST authPolicy */\n\t/* policy set separately */\n\t{\n\t    /* Table 182 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */\n\t    /* Table 178 - Definition of TPMS_KEYEDHASH_PARMS Structure */\n\t    /* Table 141 - Definition of TPMT_KEYEDHASH_SCHEME Structure */\n\t    /* Table 137 - Definition of (TPM_ALG_ID) TPMI_ALG_KEYEDHASH_SCHEME Type */\n\t    publicArea->parameters.keyedHashDetail.scheme.scheme = TPM_ALG_HMAC;\n\t    /* Table 140 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */\n\t    /* Table 138 - Definition of Types for HMAC_SIG_SCHEME */\n\t    /* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t    publicArea->parameters.keyedHashDetail.scheme.details.hmac.hashAlg = halg;\n\t}\n\t/* Table 177 - TPMU_PUBLIC_ID unique */\n\t/* Table 72 - Definition of TPM2B_DIGEST Structure */\n\tpublicArea->unique.sym.t.size = 0; \n    }\n    if (rc == 0) {\n\trc = getPolicy(publicArea, policyFilename);\n    }\n    return rc;\n}\n\n/* derivationParentPublicTemplate() is a template for a derivation parent\n\n   The key is not restricted\n*/\n\nTPM_RC derivationParentPublicTemplate(TPMT_PUBLIC *publicArea,\t\t/* output */\n\t\t\t\t      TPMA_OBJECT addObjectAttributes,\t/* add default, can be\n\t\t\t\t\t\t\t\t\t   overridden here */\n\t\t\t\t      TPMA_OBJECT deleteObjectAttributes,\n\t\t\t\t      TPMI_ALG_HASH nalg,\t\t/* Name algorithm */\n\t\t\t\t      TPMI_ALG_HASH halg,\t\t/* hash algorithm */\n\t\t\t\t      const char *policyFilename)\t/* binary policy, NULL means\n\t\t\t\t\t\t\t\t\t   empty */\n{\n    TPM_RC\t\t\trc = 0;\n\n    if (rc == 0) {\n\tpublicArea->objectAttributes = addObjectAttributes;\n\n\t/* Table 185 - TPM2B_PUBLIC inPublic */\n\t/* Table 184 - TPMT_PUBLIC publicArea */\n\t/* Table 176 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */\n\tpublicArea->type = TPM_ALG_KEYEDHASH;\n\t/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type  */\n\tpublicArea->nameAlg = nalg;\n\t/* Table 32 - TPMA_OBJECT objectAttributes */\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_FIXEDTPM;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_FIXEDPARENT;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_SIGN;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_DECRYPT;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_RESTRICTED;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_SENSITIVEDATAORIGIN;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_ADMINWITHPOLICY;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_RESTRICTED;\n\tpublicArea->objectAttributes.val &= ~deleteObjectAttributes.val;\n\t/* Table 72 -  TPM2B_DIGEST authPolicy */\n\t/* policy set separately */\n\t{\n\t    /* Table 182 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */\n\t    /* Table 178 - Definition of TPMS_KEYEDHASH_PARMS Structure */\n\t    /* Table 141 - Definition of TPMT_KEYEDHASH_SCHEME Structure */\n\t    /* Table 137 - Definition of (TPM_ALG_ID) TPMI_ALG_KEYEDHASH_SCHEME Type */\n\t    publicArea->parameters.keyedHashDetail.scheme.scheme = TPM_ALG_XOR;\n\t    /* Table 140 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */\n\t    /* Table 138 - Definition of Types for HMAC_SIG_SCHEME */\n\t    /* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t    publicArea->parameters.keyedHashDetail.scheme.details.xorr.kdf = TPM_ALG_KDF1_SP800_108;\n\t    publicArea->parameters.keyedHashDetail.scheme.details.xorr.hashAlg = halg;\n\t}\n\t/* Table 177 - TPMU_PUBLIC_ID unique */\n\t/* Table 72 - Definition of TPM2B_DIGEST Structure */\n\tpublicArea->unique.sym.t.size = 0; \n    }\n    if (rc == 0) {\n\trc = getPolicy(publicArea, policyFilename);\n    }\n    return rc;\n}\n\n/* blPublicTemplate() is a template for a sealed data blob.\n\n*/\n\nTPM_RC blPublicTemplate(TPMT_PUBLIC *publicArea,\t/* output */\n\t\t\tTPMA_OBJECT addObjectAttributes,\t/* add default, can be overridden\n\t\t\t\t\t\t\t\t   here */\n\t\t\tTPMA_OBJECT deleteObjectAttributes,\n\t\t\tTPMI_ALG_HASH nalg,\t\t/* Name algorithm */\n\t\t\tconst char *policyFilename)\t/* binary policy, NULL means empty */\n{\n    TPM_RC\t\t\trc = 0;\n\n    if (rc == 0) {\n\tpublicArea->objectAttributes = addObjectAttributes;\n\n\t/* Table 185 - TPM2B_PUBLIC inPublic */\n\t/* Table 184 - TPMT_PUBLIC publicArea */\n\t/* Table 176 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */\n\tpublicArea->type = TPM_ALG_KEYEDHASH;\n\t/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type  */\n\tpublicArea->nameAlg = nalg;\n\t/* Table 32 - TPMA_OBJECT objectAttributes */\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_SIGN;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_DECRYPT;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_SENSITIVEDATAORIGIN;\n\tpublicArea->objectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\tpublicArea->objectAttributes.val &= ~TPMA_OBJECT_ADMINWITHPOLICY;\n\tpublicArea->objectAttributes.val &= ~deleteObjectAttributes.val;\n\t/* Table 72 -  TPM2B_DIGEST authPolicy */\n\t/* policy set separately */\n\t{\n\t    /* Table 182 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */\n\t    /* Table 178 - Definition of TPMS_KEYEDHASH_PARMS Structure */\n\t    /* Table 141 - Definition of TPMT_KEYEDHASH_SCHEME Structure */\n\t    /* Table 137 - Definition of (TPM_ALG_ID) TPMI_ALG_KEYEDHASH_SCHEME Type */\n\t    publicArea->parameters.keyedHashDetail.scheme.scheme = TPM_ALG_NULL;\n\t    /* Table 140 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */\n\t}\n\t/* Table 177 - TPMU_PUBLIC_ID unique */\n\t/* Table 72 - Definition of TPM2B_DIGEST Structure */\n\tpublicArea->unique.sym.t.size = 0; \n    }\n    if (rc == 0) {\n\trc = getPolicy(publicArea, policyFilename);\n    }\n    return rc;\n}\n\nTPM_RC getPolicy(TPMT_PUBLIC *publicArea,\n\t\t const char *policyFilename)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (policyFilename != NULL) {\n\t    rc = TSS_File_Read2B(&publicArea->authPolicy.b,\n\t\t\t\t sizeof(publicArea->authPolicy.t.buffer),\n\t\t\t\t policyFilename);\n\t}\n\telse {\n\t    publicArea->authPolicy.t.size = 0;\t/* default empty policy */\n\t}\n    }\n    return rc;\n}\n\nvoid printUsageTemplate(void)\n{\n    printf(\"\\t[Asymmetric Key Algorithm]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-rsa [keybits] (default)\\n\");\n    printf(\"\\t\\t(2048 default)\\n\");\n    printf(\"\\t-ecc curve\\n\");\n    printf(\"\\t\\tbnp256\\n\");\n    printf(\"\\t\\tnistp256\\n\");\n    printf(\"\\t\\tnistp384\\n\");\n    printf(\"\\n\");\n    printf(\"\\tKey attributes\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\t-bl\\tdata blob for unseal (create only)\\n\");\n    printf(\"\\t\\t\\trequires -if\\n\");\n    printf(\"\\t\\t-den\\tdecryption, (unrestricted, RSA and EC NULL scheme)\\n\");\n    printf(\"\\t\\t-deo\\tdecryption, (unrestricted, RSA OAEP, EC NULL scheme)\\n\");\n    printf(\"\\t\\t-dee\\tdecryption, (unrestricted, RSA ES, EC NULL scheme)\\n\");\n    printf(\"\\t\\t-des\\tencryption/decryption, AES symmetric\\n\");\n    printf(\"\\t\\t\\t[-116 for TPM rev 116 compatibility]\\n\");\n    printf(\"\\t\\t-st\\tstorage (restricted)\\n\");\n    printf(\"\\t\\t\\t[default for primary keys]\\n\");\n    printf(\"\\t\\t-si\\tunrestricted signing (RSA and EC NULL scheme)\\n\");\n    printf(\"\\t\\t-sir\\trestricted signing (RSA RSASSA, EC ECDSA scheme)\\n\");\n    printf(\"\\t\\t-dau\\tunrestricted ECDAA signing key pair\\n\");\n    printf(\"\\t\\t-dar\\trestricted ECDAA signing key pair\\n\");\n    printf(\"\\t\\t-kh\\tkeyed hash (unrestricted, hmac)\\n\");\n    printf(\"\\t\\t-khr\\tkeyed hash (restricted, hmac)\\n\");\n    printf(\"\\t\\t-dp\\tderivation parent\\n\");\n    printf(\"\\t\\t-gp\\tgeneral purpose, not storage\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\t[-kt\\t(can be specified more than once)]\\n\"\n\t   \"\\t\\t\\tf\\tfixedTPM (default for primary keys and derivation parents)\\n\"\n\t   \"\\t\\t\\tp\\tfixedParent (default for primary keys and derivation parents)\\n\"\n\t   \"\\t\\t\\tnf\\tno fixedTPM (default for non-primary keys)\\n\"\n\t   \"\\t\\t\\tnp\\tno fixedParent (default for non-primary keys)\\n\"\n\t   \"\\t\\t\\ted\\tencrypted duplication (default not set)\\n\");\n    printf(\"\\t[-da\\tobject subject to DA protection (default no)]\\n\");\n    printf(\"\\t[-pol\\tpolicy file (default empty)]\\n\");\n    printf(\"\\t[-uwa\\tuserWithAuth attribute clear (default set)]\\n\");\n    printf(\"\\t[-if\\tdata (inSensitive) file name]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-nalg\\tname hash algorithm (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-halg\\tscheme hash algorithm (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    return;\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/pcrallocate.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PCR_Allocate\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void setPcrSelect(TPMS_PCR_SELECTION *pcrSelections,\n\t\t\t TPM_ALG_ID hashAlg,\n\t\t\t uint8_t select);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PCR_Allocate_In \t\tin;\n    PCR_Allocate_Out \t\tout;\n    const char\t\t\t*platformPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    unsigned int\t\tbankNumber = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwdp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tplatformPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sha1\") == 0) {\n\t    if (bankNumber < HASH_COUNT) {\n\t\tsetPcrSelect(&in.pcrAllocation.pcrSelections[bankNumber],\n\t\t\t     TPM_ALG_SHA1, 0x00);\n\t\tbankNumber++;\n\t    }\n\t    else {\n\t\tprintf(\"%u banks specified, TSS supports %u banks\\n\",\n\t\t       bankNumber+1, HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"+sha1\") == 0) {\n\t    if (bankNumber < HASH_COUNT) {\n\t\tsetPcrSelect(&in.pcrAllocation.pcrSelections[bankNumber],\n\t\t\t     TPM_ALG_SHA1, 0xff);\n\t\tbankNumber++;\n\t    }\n\t    else {\n\t\tprintf(\"%u banks specified, TSS supports %u banks\\n\",\n\t\t       bankNumber+1, HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sha256\") == 0) {\n\t    if (bankNumber < HASH_COUNT) {\n\t\tsetPcrSelect(&in.pcrAllocation.pcrSelections[bankNumber],\n\t\t\t     TPM_ALG_SHA256, 0x00);\n\t\tbankNumber++;\n\t    }\n\t    else {\n\t\tprintf(\"%u banks specified, TSS supports %u banks\\n\",\n\t\t       bankNumber+1, HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"+sha256\") == 0) {\n\t    if (bankNumber < HASH_COUNT) {\n\t\tsetPcrSelect(&in.pcrAllocation.pcrSelections[bankNumber],\n\t\t\t     TPM_ALG_SHA256, 0xff);\n\t\tbankNumber++;\n\t    }\n\t    else {\n\t\tprintf(\"%u banks specified, TSS supports %u banks\\n\",\n\t\t       bankNumber+1, HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sha384\") == 0) {\n\t    if (bankNumber < HASH_COUNT) {\n\t\tsetPcrSelect(&in.pcrAllocation.pcrSelections[bankNumber],\n\t\t\t     TPM_ALG_SHA384, 0x00);\n\t\tbankNumber++;\n\t    }\n\t    else {\n\t\tprintf(\"%u banks specified, TSS supports %u banks\\n\",\n\t\t       bankNumber+1, HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"+sha384\") == 0) {\n\t    if (bankNumber < HASH_COUNT) {\n\t\tsetPcrSelect(&in.pcrAllocation.pcrSelections[bankNumber],\n\t\t\t     TPM_ALG_SHA384, 0xff);\n\t\tbankNumber++;\n\t    }\n\t    else {\n\t\tprintf(\"%u banks specified, TSS supports %u banks\\n\",\n\t\t       bankNumber+1, HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sha512\") == 0) {\n\t    if (bankNumber < HASH_COUNT) {\n\t\tsetPcrSelect(&in.pcrAllocation.pcrSelections[bankNumber],\n\t\t\t     TPM_ALG_SHA512, 0x00);\n\t\tbankNumber++;\n\t    }\n\t    else {\n\t\tprintf(\"%u banks specified, TSS supports %u banks\\n\",\n\t\t       bankNumber+1, HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"+sha512\") == 0) {\n\t    if (bankNumber < HASH_COUNT) {\n\t\tsetPcrSelect(&in.pcrAllocation.pcrSelections[bankNumber],\n\t\t\t     TPM_ALG_SHA512, 0xff);\n\t\tbankNumber++;\n\t    }\n\t    else {\n\t\tprintf(\"%u banks specified, TSS supports %u banks\\n\",\n\t\t       bankNumber+1, HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* at least one bank must be selected */\n    if (rc == 0) {\n\tif (bankNumber == 0) {\n\t    printf(\"No PCR algorithm specified\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.authHandle = TPM_RH_PLATFORM;\n\tin.pcrAllocation.count = bankNumber;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PCR_Allocate,\n\t\t\t sessionHandle0, platformPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"pcrallocate: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"pcrallocate: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void setPcrSelect(TPMS_PCR_SELECTION *pcrSelections,\n\t\t\t TPM_ALG_ID hashAlg,\n\t\t\t uint8_t select)\n{\n    TPMI_DH_PCR pcrIndex;\t\t/* iterator for initialization */\n\n    pcrSelections->hash = hashAlg;\n    pcrSelections->sizeofSelect = (IMPLEMENTATION_PCR+7)/8;\n    for (pcrIndex = 0 ; pcrIndex < pcrSelections->sizeofSelect ; pcrIndex++) {\n\tpcrSelections->pcrSelect[pcrIndex] = select;\n    }\n    return;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"pcrallocate\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PCR_Allocate\\n\");\n    printf(\"\\n\");\n    printf(\"\\nAllocates banks for a full set of PCR 0-23.  Not all\\n\"\n\t   \"hardware TPMs support multiple banks or all algorithms\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwdp\\tplatform hierarchy password (default empty)]\\n\");\n    printf(\"\\t+sha1   -sha1   allocate / deallocate a SHA-1 bank\\n\");\n    printf(\"\\t+sha256 -sha256 allocate / deallocate a SHA-256 bank\\n\");\n    printf(\"\\t+sha384 -sha384 allocate / deallocate a SHA-384 bank\\n\");\n    printf(\"\\t+sha512 -sha512 allocate / deallocate a SHA-512 bank\\n\");\n    printf(\"\\t\\tMore than one algorithm can be specified\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/pcrevent.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   PCR_Event \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PCR_Event_In \t\tin;\n    PCR_Event_Out \t\tout;\n    TPMI_DH_PCR \t\tpcrHandle = IMPLEMENTATION_PCR;\n    const char \t\t\t*data = NULL;\n    const char \t\t\t*datafilename = NULL;\n    const char\t\t\t*outFilename1 = NULL;\t/* for sha1 */\n    const char\t\t\t*outFilename2 = NULL;\t/* for sha256 */\n    const char\t\t\t*outFilename3 = NULL;\t/* for sha384 */\n    const char\t\t\t*outFilename5 = NULL;\t/* for sha512 */\n    int\t\t\t\tprocess1 = FALSE;\t/* these catch the case */\n    int\t\t\t\tprocess2 = FALSE;\t/* where an output file was */\n    int\t\t\t\tprocess3 = FALSE;\t/* specified but the TPM did */\n    int\t\t\t\tprocess5 = FALSE;\t/* not return the algorithm */\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &pcrHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdata = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-if\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdatafilename = argv[i];\n\t    } else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of1\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename1 = argv[i];\n\t\tprocess1 = TRUE;\n\t    } else {\n\t\tprintf(\"-of1 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of2\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename2 = argv[i];\n\t\tprocess2 = TRUE;\n\t    } else {\n\t\tprintf(\"-of2 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of3\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename3 = argv[i];\n\t\tprocess3 = TRUE;\n\t    } else {\n\t\tprintf(\"-of3 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-of5\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename5 = argv[i];\n\t\tprocess5 = TRUE;\n\t    } else {\n\t\tprintf(\"-of5 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (pcrHandle >= IMPLEMENTATION_PCR) {\n\tprintf(\"Missing or bad PCR handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if ((data == NULL) && (datafilename == NULL)) {\n\tprintf(\"Data string or data file must be specified\\n\");\n\tprintUsage();\n    }\n    if ((data != NULL) && (datafilename != NULL)) {\n\tprintf(\"Data string and data file cannot both be specified\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.pcrHandle = pcrHandle;\n    }\n    if (rc == 0) {\n\tif (data != NULL) {\n\t    if (tssUtilsVerbose) printf(\"Event data %u bytes\\n\", (unsigned int)strlen(data));\n\t    rc = TSS_TPM2B_StringCopy(&in.eventData.b, data, sizeof(in.eventData.t.buffer));\n\t}\n    }\n    if (datafilename != NULL) {\n\trc = TSS_File_Read2B(&in.eventData.b,\n\t\t\t     sizeof(in.eventData.t.buffer),\n\t\t\t     datafilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PCR_Event,\n\t\t\t TPM_RS_PW, NULL, 0,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tuint32_t c;\n\tprintf(\"pcrevent: success\\n\");\n\t/* Table 100 - Definition of TPML_DIGEST_VALUES Structure */\n\t/* Table 71 - Definition of TPMT_HA Structure <IN/OUT> digests[] */\n\t/* Table 70 - Definition of TPMU_HA Union <IN/OUT, S> digests */\n\tprintf(\"pcrevent: count %u\\n\", out.digests.count);\n\n\tfor (c = 0 ;  c < out.digests.count ;c++) {\n\t    switch (out.digests.digests[c].hashAlg) {\n\t      case TPM_ALG_SHA1:\n\t\tif (tssUtilsVerbose) printf(\"Hash algorithm SHA-1\\n\");\n\t\tif (tssUtilsVerbose) TSS_PrintAll(\"Digest\",\n\t\t\t\t\t  (uint8_t *)&out.digests.digests[c].digest.sha1,\n\t\t\t\t\t  SHA1_DIGEST_SIZE);\n\t\tif (outFilename1 != NULL) {\n\t\t    rc = TSS_File_WriteBinaryFile((uint8_t *)&out.digests.digests[c].digest.sha1,\n\t\t\t\t\t\t  SHA1_DIGEST_SIZE,\n\t\t\t\t\t\t  outFilename1);\n\t\t    process1 = FALSE;\n\t\t}\n\t\tbreak;\n\t      case TPM_ALG_SHA256:\n\t\tif (tssUtilsVerbose) printf(\"Hash algorithm SHA-256\\n\");\n\t\tif (tssUtilsVerbose) TSS_PrintAll(\"Digest\",\n\t\t\t\t\t  (uint8_t *)&out.digests.digests[c].digest.sha256,\n\t\t\t\t\t  SHA256_DIGEST_SIZE);\n\t\tif (outFilename2 != NULL) {\n\t\t    rc = TSS_File_WriteBinaryFile((uint8_t *)&out.digests.digests[c].digest.sha256,\n\t\t\t\t\t\t  SHA256_DIGEST_SIZE,\n\t\t\t\t\t\t  outFilename2); \n\t\t    process2 = FALSE;\n\t\t}\n\t\tbreak;\n\t      case TPM_ALG_SHA384:\n\t\tif (tssUtilsVerbose) printf(\"Hash algorithm SHA-384\\n\");\n\t\tif (tssUtilsVerbose) TSS_PrintAll(\"Digest\",\n\t\t\t\t\t  (uint8_t *)&out.digests.digests[c].digest.sha384,\n\t\t\t\t\t  SHA384_DIGEST_SIZE);\n\t\tif (outFilename3 != NULL) {\n\t\t    rc = TSS_File_WriteBinaryFile((uint8_t *)&out.digests.digests[c].digest.sha384,\n\t\t\t\t\t\t  SHA384_DIGEST_SIZE,\n\t\t\t\t\t\t  outFilename3); \n\t\t    process3 = FALSE;\n\t\t}\n\t\tbreak;\n\t      case TPM_ALG_SHA512:\n\t\tif (tssUtilsVerbose) printf(\"Hash algorithm SHA-512\\n\");\n\t\tif (tssUtilsVerbose) TSS_PrintAll(\"Digest\",\n\t\t\t\t\t  (uint8_t *)&out.digests.digests[c].digest.sha512,\n\t\t\t\t\t  SHA512_DIGEST_SIZE);\n\t\tif (outFilename5 != NULL) {\n\t\t    rc = TSS_File_WriteBinaryFile((uint8_t *)&out.digests.digests[c].digest.sha512,\n\t\t\t\t\t\t  SHA512_DIGEST_SIZE,\n\t\t\t\t\t\t  outFilename5); \n\t\t    process5 = FALSE;\n\t\t}\n\t\tbreak;\n\t      default:\n\t\tprintf(\"Hash algorithm %04x unknown\\n\", out.digests.digests[c].hashAlg);\n\t\tbreak;\n\t    }\n\t}\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"pcrevent: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    if (rc == 0) {\n\tif (process1) {\n\t    printf(\"-of1 specified but TPM did not return SHA-1\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n\tif (process2) {\n\t    printf(\"-of2 specified but TPM did not return SHA-256\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n\tif (process3) {\n\t    printf(\"-of3 specified but TPM did not return SHA-384\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n\tif (process5) {\n\t    printf(\"-of5 specified but TPM did not return SHA-512\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"pcrevent\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PCR_Event\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpcr handle\\n\");\n    printf(\"\\t-ic\\tdata string\\n\");\n    printf(\"\\t-if\\tdata file\\n\");\n    printf(\"\\t[-of1\\tsha1 output digest file (default do not save)]\\n\");\n    printf(\"\\t[-of2\\tsha256 output digest file (default do not save)]\\n\");\n    printf(\"\\t[-of3\\tsha384 output digest file (default do not save)]\\n\");\n    printf(\"\\t[-of5\\tsha512 output digest file (default do not save)]\\n\");\n   exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/pcrextend.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   PCR_Extend \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    \t/* argc iterator */\n    uint32_t\t\t\talgs;\t/* hash algorithm iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PCR_Extend_In \t\tin;\n    TPMI_DH_PCR \t\tpcrHandle = IMPLEMENTATION_PCR;\n    const char \t\t\t*dataString = NULL;\n    const char \t\t\t*datafilename = NULL;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* Table 100 - Definition of TPML_DIGEST_VALUES Structure */\n    in.digests.count = 0xffffffff;\t/* flag for default hash algorithm */\n\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &pcrHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    /* Table 100 - Definition of TPML_DIGEST_VALUES Structure */\n\t    if (in.digests.count == 0xffffffff) {\t/* first time */\n\t\tin.digests.count = 1;\t\t\t/* extend a bank */\n\t    }\n\t    else {\n\t\tin.digests.count++;\t\t\t/* extend a bank */\n\t    }\n\t    if (in.digests.count > HASH_COUNT) {\n\t\tprintf(\"Too many -halg specifiers, %u permitted\\n\", HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\t/* Table 100 - Definition of TPML_DIGEST_VALUES Structure digests */\n\t\t/* Table 71 - Definition of TPMT_HA Structure <IN/OUT> */\n\t\t/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type hashAlg */\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    in.digests.digests[in.digests.count-1].hashAlg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    in.digests.digests[in.digests.count-1].hashAlg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    in.digests.digests[in.digests.count-1].hashAlg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    in.digests.digests[in.digests.count-1].hashAlg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdataString = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-if\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdatafilename = argv[i];\n\t    } else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (pcrHandle >= IMPLEMENTATION_PCR) {\n\tprintf(\"Missing or bad PCR handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if ((dataString == NULL) && (datafilename == NULL)) {\n\tprintf(\"Data string or data file must be specified\\n\");\n\tprintUsage();\n    }\n    if ((dataString != NULL) && (datafilename != NULL)) {\n\tprintf(\"Data string and data file cannot both be specified\\n\");\n\tprintUsage();\n    }\n    if ((dataString != NULL) && (strlen(dataString) > sizeof(TPMU_HA))) {\n\tprintf(\"Data length greater than maximum hash size %lu bytes\\n\",\n\t       (unsigned long)sizeof(TPMU_HA));\n\tprintUsage();\n    }\n    /* handle default hash algorithm */\n    if (in.digests.count == 0xffffffff) {\t/* if none specified */\n\tin.digests.count = 1;\n\tin.digests.digests[0].hashAlg = TPM_ALG_SHA256;\n    }\n    if (rc == 0) {\n\tin.pcrHandle = pcrHandle;\n\t/* Table 70 - Definition of TPMU_HA Union <IN/OUT, S> */\n\t/* append zero padding to maximum hash algorithm length */\n\tfor (algs = 0 ; algs < in.digests.count ; algs++) {\n\t    memset((uint8_t *)&in.digests.digests[algs].digest, 0, sizeof(TPMU_HA));\n\t}\n    }\n    if (rc == 0) {\n\tif (dataString != NULL) {\n\t    if (tssUtilsVerbose) printf(\"Extending %u bytes from stream into %u banks\\n\",\n\t\t\t\t(unsigned int)strlen(dataString), in.digests.count);\n\t    for (algs = 0 ; algs < in.digests.count ; algs++) {\n\t\tmemcpy((uint8_t *)&in.digests.digests[algs].digest,\n\t\t       dataString, strlen(dataString));\n\t    }\n\t}\n    }\n    if (datafilename != NULL) {\n\tunsigned char \t*fileData = NULL;\n\tsize_t \t\tlength;\n\tif (rc == 0) {\n\t    rc = TSS_File_ReadBinaryFile(&fileData,\t\t\t/* freed @1 */\n\t\t\t\t\t &length, datafilename);\n\t}\n\tif (rc == 0) {\n\t    if (length > sizeof(TPMU_HA)) {\n\t\tprintf(\"Data length greater than maximum hash size %lu bytes\\n\",\n\t\t       (unsigned long)sizeof(TPMU_HA));\n\t\trc = EXIT_FAILURE;\n\t    } \n\t}\n\tif (rc == 0) {\n\t    if (tssUtilsVerbose) printf(\"Extending %u bytes from file into %u banks\\n\",\n\t\t\t\t(unsigned int)length, in.digests.count);\n\t    for (algs = 0 ; algs < in.digests.count ; algs++) {\n\t\tmemcpy((uint8_t *)&in.digests.digests[algs].digest, fileData, length);\n\t    }\n\t}\n\tfree(fileData);\t\t/* @1 */\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PCR_Extend,\n\t\t\t TPM_RS_PW, NULL, 0,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"pcrextend: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"pcrextend: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"pcrextend\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PCR_Extend\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpcr handle\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t\\t-halg may be specified more than once\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ic\\tdata string, 0 pad appended to halg length\\n\");\n    printf(\"\\t-if\\tdata file, 0 pad appended to halg length\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/pcrread.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   PCR_Read \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsscryptoh.h>\n\nstatic void printPcrRead(PCR_Read_Out *out);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PCR_Read_In \t\tin;\n    PCR_Read_Out \t\tout;\n    TPMI_DH_PCR \t\tpcrHandle = IMPLEMENTATION_PCR;\n    const char \t\t\t*datafilename = NULL;\n    TPMI_ALG_HASH\t\tahalg = TPM_ALG_SHA256;\n    uint32_t \t\t\tsizeInBytes = 0;\t/* initialized to suppress false gcc -O3\n\t\t\t\t\t\t\t   warning */\n    const char \t\t\t*sadfilename = NULL;\n    int\t\t\t\tnoSpace = FALSE;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    in.pcrSelectionIn.count = 0xffffffff;\n\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &pcrHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    if (in.pcrSelectionIn.count == 0xffffffff) {\n\t\tin.pcrSelectionIn.count = 1;\n\t    }\n\t    else {\n\t\tin.pcrSelectionIn.count++;\n\t    }\n\t    if (in.pcrSelectionIn.count > HASH_COUNT) {\n\t\tprintf(\"Too many -halg specifiers, %u permitted\\n\", HASH_COUNT);\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    in.pcrSelectionIn.pcrSelections[in.pcrSelectionIn.count-1].hash = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    in.pcrSelectionIn.pcrSelections[in.pcrSelectionIn.count-1].hash = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    in.pcrSelectionIn.pcrSelections[in.pcrSelectionIn.count-1].hash = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    in.pcrSelectionIn.pcrSelections[in.pcrSelectionIn.count-1].hash = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ahalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    ahalg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    ahalg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    ahalg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    ahalg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -ahalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i], \"-of\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdatafilename = argv[i];\n\t    } else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-iosad\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsadfilename = argv[i];\n\t    } else {\n\t\tprintf(\"-iosad option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ns\") == 0) {\n\t    noSpace = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (pcrHandle >= IMPLEMENTATION_PCR) {\n\tprintf(\"Missing or bad PCR handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    /* handle default hash algorithm */\n    if (in.pcrSelectionIn.count == 0xffffffff) {\t/* if none specified */\n\tin.pcrSelectionIn.count = 1;\n\tin.pcrSelectionIn.pcrSelections[0].hash = TPM_ALG_SHA256;\n    }\n    if (rc == 0) {\n\tuint16_t c;\t\t\t/* count iterator over PCR banks */\n\tTPMI_DH_PCR pcrIndex;\t\t/* iterator for initialization */\n\t/* Table 102 - Definition of TPML_PCR_SELECTION Structure */\n\t/* Table 85 - Definition of TPMS_PCR_SELECTION Structure */\n\tfor (c = 0 ; c < in.pcrSelectionIn.count ; c++) {\n\t    in.pcrSelectionIn.pcrSelections[c].sizeofSelect = (IMPLEMENTATION_PCR+7)/8;\n\t    /* clear the entire bitmap before setting the specified PCR */\n\t    for (pcrIndex = 0 ;\n\t\t pcrIndex < in.pcrSelectionIn.pcrSelections[c].sizeofSelect ;\n\t\t pcrIndex++) {\n\t\tin.pcrSelectionIn.pcrSelections[c].pcrSelect[pcrIndex] = 0;\n\t    }\n\t    /* set the one mask bit specfied by the command line pcrHandle */\n\t    in.pcrSelectionIn.pcrSelections[c].pcrSelect[pcrHandle / 8] = 1 << (pcrHandle % 8);\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PCR_Read,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* first hash algorithm, in binary */\n    if (rc != 0) {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"pcrread: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    if ((rc == 0) && (datafilename != NULL) && (out.pcrValues.count != 0)) {\n\trc = TSS_File_WriteBinaryFile(out.pcrValues.digests[0].t.buffer,\n\t\t\t\t      out.pcrValues.digests[0].t.size,\n\t\t\t\t      datafilename);\n    }\n    /* auth session hash algorithm for cpHash and rpHash */\n    if (rc == 0) {\n        sizeInBytes = TSS_GetDigestSize(ahalg);\n    }\n    /* option to output cpHash and rpHash to test session audit of PCR Read */\n    if (sadfilename != NULL) {\n\tTPMT_HA \tcpHash;\n\tuint8_t \tcpBuffer [MAX_COMMAND_SIZE];\n\tuint16_t \tcpBufferSize = 0;\n\tTPMT_HA \trpHash;\n\tuint8_t \trpBuffer [MAX_RESPONSE_SIZE];\n\tuint16_t \trpBufferSize = 0;\n\tuint8_t \t*tmpptr;\n\tuint32_t \ttmpsize;\n\tTPMT_HA \tsessionDigest;\n\tuint8_t\t\t*sessionDigestData = NULL;\n\tsize_t\t\tsessionDigestSize;\n\t/* calculate cpHash from CC || parameters */\n\tif (rc == 0) {\n\t    tmpptr = cpBuffer;\n\t    tmpsize = sizeof(cpBuffer);\n\t    rc = TSS_TPML_PCR_SELECTION_Marshalu(&in.pcrSelectionIn,\n\t\t\t\t\t\t &cpBufferSize, &tmpptr, &tmpsize);\n\t}\n\tif (rc == 0) {\n\t    TPM_CC commandCode = TPM_CC_PCR_Read;\n\t    TPM_CC commandCodeNbo = htonl(commandCode);\n\t    cpHash.hashAlg = ahalg;\n\t    rc = TSS_Hash_Generate(&cpHash,\t\t/* largest size of a digest */\n\t\t\t\t   sizeof(TPM_CC), &commandCodeNbo,\n\t\t\t\t   cpBufferSize, cpBuffer,\n\t\t\t\t   0, NULL);\n\t}\n\tif ((rc == 0) && tssUtilsVerbose) {\n#if 0\n\t    TSS_PrintAll(\"cpBuffer\", cpBuffer, cpBufferSize);\n\t    TSS_PrintAll(\"cpHash\", (uint8_t *)&cpHash.digest, sizeInBytes);\n#endif\n\t}\n\t/* calculate rpHash from RC || CC || parameters */\n\tif (rc == 0) {\n\t    tmpptr = rpBuffer;\n\t    tmpsize = sizeof(rpBuffer);\n\t    rc = TSS_UINT32_Marshalu(&out.pcrUpdateCounter,\n\t\t\t\t     &rpBufferSize, &tmpptr, &tmpsize);\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_TPML_PCR_SELECTION_Marshalu(&out.pcrSelectionOut,\n\t\t\t\t\t\t &rpBufferSize, &tmpptr, &tmpsize);\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_TPML_DIGEST_Marshalu(&out.pcrValues,\n\t\t\t\t\t  &rpBufferSize, &tmpptr, &tmpsize);\n\t}\n\tif (rc == 0) {\n\t    TPM_CC \t\tcommandCode = TPM_CC_PCR_Read;\n\t    TPM_CC \t\tcommandCodeNbo = htonl(commandCode);\n\t    rpHash.hashAlg = ahalg;\n\t    rc = TSS_Hash_Generate(&rpHash,\t\t\t/* largest size of a digest */\n\t\t\t\t   sizeof(TPM_RC), &rc,\t/* RC is always 0, no need to endian\n\t\t\t\t\t\t\t   convert */\n\t\t\t\t   sizeof(TPM_CC), &commandCodeNbo,\n\t\t\t\t   rpBufferSize, rpBuffer,\n\t\t\t\t   0, NULL);\n\t}\n\tif ((rc == 0) && tssUtilsVerbose) {\n#if 0\n\t    TSS_PrintAll(\"rpBuffer\", rpBuffer, rpBufferSize);\n\t    TSS_PrintAll(\"rpHash\", (uint8_t *)&rpHash.digest, sizeInBytes);\n#endif\n\t}\n\t/* read the original session digest, must be initialized to all zero */\n\tif (rc == 0) {\n\t    rc = TSS_File_ReadBinaryFile(&sessionDigestData,\t/* freed @1 */\n\t\t\t\t\t &sessionDigestSize,\n\t\t\t\t\t sadfilename);\n\t}\n\t/* sanity check the size against the session digest hash algorithm */\n\tif (rc == 0) {\n\t    if (sizeInBytes != sessionDigestSize) {\n\t\tprintf(\"pcrread: -ahalg size %u does not match digest size %u from %s\\n\",\n\t\t       (unsigned int)sizeInBytes, (unsigned int)sessionDigestSize, sadfilename);\n\t    }\n\t}\n\t/* extend cpHash and rpHash */\n\tif (rc == 0) {\n\t    sessionDigest.hashAlg = ahalg;\n\t    rc = TSS_Hash_Generate(&sessionDigest,\n\t\t\t\t   sizeInBytes, sessionDigestData, \n\t\t\t\t   sizeInBytes, (uint8_t *)&cpHash.digest,\n\t\t\t\t   sizeInBytes, (uint8_t *)&rpHash.digest,\n\t\t\t\t   0, NULL);\n\t}\n\tif ((rc == 0) && tssUtilsVerbose) {\n\t    TSS_PrintAll(\"Session digest old\", sessionDigestData, sizeInBytes);\n\t    TSS_PrintAll(\"Session digest new\", (uint8_t *)&sessionDigest.digest, sizeInBytes);\n\t}\n\tif (rc == 0) {\n\t    /* write back the result */\n\t    rc = TSS_File_WriteBinaryFile((uint8_t *)&sessionDigest.digest,\n\t\t\t\t\t  sizeInBytes,\n\t\t\t\t\t  sadfilename);\n\t}\n\tfree(sessionDigestData);\t/* @1 */\n    }\n    if (rc == 0) {\n\t/* machine readable format */\n\tif (noSpace) {\n\t    uint32_t count;\n\t    /* TPM can return count 0 if the requested algorithm is not allocated */\n\t    if (out.pcrValues.count != 0) {\n\t\tfor (count = 0 ; count < out.pcrValues.count ; count++) {\n\t\t    uint32_t bp;\n\t\t    for (bp = 0 ; bp < out.pcrValues.digests[count].t.size ; bp++) {\n\t\t\tprintf(\"%02x\", out.pcrValues.digests[count].t.buffer[bp]);\n\t\t    }\n\t\t    printf(\"\\n\");\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"count %u\\n\", out.pcrValues.count);\n\t    }\n\t}\n\t/* human readable format, all hash algorithms */\n\telse {\n\t    printPcrRead(&out);\n\t    if (tssUtilsVerbose) printf(\"pcrread: success\\n\");\n\t}\n    }\n    return rc;\n}\n\nstatic void printPcrRead(PCR_Read_Out *out)\n{\n    uint32_t\ti;\n    \n    /* Table 99 - Definition of TPML_DIGEST Structure */\n    printf(\"count %u pcrUpdateCounter %u \\n\", out->pcrValues.count, out->pcrUpdateCounter);\n    for (i = 0 ; i < out->pcrValues.count ; i++) {\n\tTSS_PrintAll(\"digest\", out->pcrValues.digests[i].t.buffer, out->pcrValues.digests[i].t.size);\n    }\n    return;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"pcrread\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PCR_Read\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpcr handle\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t\\t-halg may be specified more than once\\n\");\n    printf(\"\\t[-of\\tdata file for first algorithm specified, in binary]\\n\");\n    printf(\"\\t[-ahalg\\t to extend session audit digest for testing (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-iosad\\t file for session audit digest testing]\\n\");\n    printf(\"\\t[-ns\\tno space, no text, no newlines]\\n\");\n    printf(\"\\t\\tUsed for scripting policy construction\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se0 session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t80\\taudit\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/pcrreset.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   PCR_Reset \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PCR_Reset_In \t\tin;\n    TPMI_DH_PCR \t\tpcrHandle = IMPLEMENTATION_PCR;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &pcrHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (pcrHandle >= IMPLEMENTATION_PCR) {\n\tprintf(\"Missing or bad PCR handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.pcrHandle = pcrHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PCR_Reset,\n\t\t\t TPM_RS_PW, NULL, 0,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"pcrreset: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"pcrreset: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"pcrreset\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PCR_Reset\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpcr handle\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policyauthorize.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyAuthorize\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyAuthorize_In \t\tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*approvedPolicyFilename = NULL;\n    const char\t\t\t*policyRefFilename = NULL;\n    const char\t\t\t*signingKeyNameFilename = NULL;\n    const char\t\t\t*ticketFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-appr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tapprovedPolicyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-appr option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pref\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyRefFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pref option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-skn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsigningKeyNameFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-skn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* validate command line parameters */\n    if (policySession == 0) {\n\tprintf(\"Missing parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (approvedPolicyFilename == NULL) {\n\tprintf(\"Missing parameter -appr\\n\");\n\tprintUsage();\n    }\n    if (policyRefFilename == NULL) {\n\tin.policyRef.b.size = 0;\t/* default empty buffer */\n    }\n    if (signingKeyNameFilename == NULL) {\n\tprintf(\"Missing parameter -skn\\n\");\n\tprintUsage();\n    }\n    if (ticketFilename == NULL) {\n\tprintf(\"Missing parameter -tk\\n\");\n\tprintUsage();\n    }\n    /* set in parameters */\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.approvedPolicy.b,\n\t\t\t     sizeof(in.approvedPolicy.t.buffer),\n\t\t\t     approvedPolicyFilename);\n    }\n    if ((rc == 0) && (policyRefFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.policyRef.b,\n\t\t\t     sizeof(in.policyRef.t.buffer),\n\t\t\t     policyRefFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.keySign.b,\n\t\t\t     sizeof(in.keySign.t.name),\n\t\t\t     signingKeyNameFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.checkTicket,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPMT_TK_VERIFIED_Unmarshalu,\n\t\t\t\t    ticketFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyAuthorize,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policyauthorize: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policyauthorize: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policyauthorize\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyAuthorize\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-appr\\tfile name of digest of the policy being approved\\n\");\n    printf(\"\\t[-pref\\tpolicyRef file] (default none)\\n\");\n    printf(\"\\t-skn\\tsigning key Name file name\\n\");\n    printf(\"\\t-tk\\tticket file name\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policyauthorizenv.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyAuthorizeNV\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyAuthorizeNV_In \tin;\n    char \t\t\thierarchyChar = 0;\n    const char\t\t\t*authPassword = NULL; \t\t/* default no password */\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hs\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (nvIndex == 0) {\n\tprintf(\"Missing NV index handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing policy session handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tif (hierarchyChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;\n\t}\n\telse if (hierarchyChar == 0) {\n\t    in.authHandle = nvIndex;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.nvIndex = nvIndex;\n\tin.policySession = policySession;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyAuthorizeNV,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policyauthorizenv: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policyauthorizenv: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policyauthorizenv\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyAuthorizeNV\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hi\\thierarchy authHandle (o, p)]\\n\");\n    printf(\"\\t\\tdefault NV index\\n\");\n    printf(\"\\t-ha\\tNV index handle\\n\");\n    printf(\"\\t[-pwda\\tpassword for authorization (default empty)]\\n\");\n    printf(\"\\t-hs\\tpolicy session handle\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policyauthvalue.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyAuthValue\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    PolicyAuthValue_In \t\tin;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyAuthValue,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policyauthvalue: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policyauthvalue: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policyauthvalue\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyAuthValue\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policycapability.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyCapability\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2024.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/*\n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    \t\t\t\t/* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyCapability_In \tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*operandBData = NULL;\n    const char \t\t\t*operandBFilename = NULL;\n    uint16_t \t\t\toffset = 0;\t\t\t/* default 0 */\n    TPM_EO\t\t\toperation = 0;\t\t\t/* default A = B */\n    TPM_CAP\t\t\tcapability = TPM_CAP_LAST + 1;\t/* invalid */\n    uint32_t\t\t\tproperty = 0;\t\t\t/* default, start at first one */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hs\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toperandBData = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-if\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toperandBFilename = argv[i];\n\t    } else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-off\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toffset = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-off option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-op\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%hx\", &operation);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -op\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-cap\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &capability);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -cap\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &property);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -pr\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing policy session handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if ((operandBData == NULL) && (operandBFilename == NULL)) {\n\tprintf(\"operandB data string or data file must be specified\\n\");\n\tprintUsage();\n     }\n    if ((operandBData != NULL) && (operandBFilename != NULL)) {\n\tprintf(\"operandB data string and data file cannot both be specified\\n\");\n\tprintUsage();\n    }\n    if (capability > TPM_CAP_LAST) {\n\tprintf(\"Missing or illegal parameter -cap\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n\tin.offset = offset;\n\tin.operation = operation;\n\tin.capability = capability;\n\tin.property = property;\n    }\n    if (operandBData != NULL) {\n\trc = TSS_TPM2B_StringCopy(&in.operandB.b,\n\t\t\t\t  operandBData, sizeof(in.operandB.t.buffer));\n\n    }\n    if (operandBFilename != NULL) {\n\trc = TSS_File_Read2B(&in.operandB.b,\n\t\t\t     sizeof(in.operandB.t.buffer),\n\t\t\t     operandBFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyCapability,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policycapability: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policycapability: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policycapability\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyCapability\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hs\\tpolicy session handle\\n\");\n    printf(\"\\t-ic\\tdata string (operandB)\\n\");\n    printf(\"\\t-if\\tdata file (operandB) \\n\");\n    printf(\"\\t[-off\\toffset (default 0)]\\n\");\n    printf(\"\\t-op\\toperation (default A = B)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\t0\tA = B \\n\");\n    printf(\"\\t\\t1\tA != B \\n\");\n    printf(\"\\t\\t2\tA > B signed\t \\n\");\n    printf(\"\\t\\t3\tA > B unsigned\t \\n\");\n    printf(\"\\t\\t4\tA < B signed\t \\n\");\n    printf(\"\\t\\t5\tA < B unsigned\t \\n\");\n    printf(\"\\t\\t6\tA >= B signed\t \\n\");\n    printf(\"\\t\\t7\tA >= B unsigned\t \\n\");\n    printf(\"\\t\\t8\tA <= B signed\t \\n\");\n    printf(\"\\t\\t9\tA <= B unsigned\t \\n\");\n    printf(\"\\t\\tA\tAll bits SET in B are SET in A. ((A&B)=B) \\n\");\n    printf(\"\\t\\tB\tAll bits SET in B are CLEAR in A. ((A&B)=0) \\n\");\n    printf(\"\\n\");\n    printf(\"\\t-cap\\tcapability\\n\");\n    printf(\"\\t-pr\\tproperty (defaults to 0)\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policycommandcode.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyCommandCode\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    TPM_CC\t\t\tcommandCode = 0;\n    PolicyCommandCode_In \tin;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-cc\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &commandCode);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -cc\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (commandCode == 0) {\n\tprintf(\"Missing parameter -cc\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n\tin.code = commandCode;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyCommandCode,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policycommandcode: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policycommandcode: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policycommandcode\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyCommandCode\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-cc\\tcommand code\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policycountertimer.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyCounterTimer\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void   printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyCounterTimer_In \tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*operandBData = NULL;\n    const char \t\t\t*operandBFilename = NULL;\n    uint16_t \t\t\toffset = 0;\t\t\t/* default 0 */\n    TPM_EO\t\t\toperation = 0;\t\t\t/* default A = B */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toperandBData = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-if\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toperandBFilename = argv[i];\n\t    } else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-off\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toffset = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-off option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-op\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%hx\", &operation);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -op\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing policy session handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if ((operandBData == NULL) && (operandBFilename == NULL)) {\n\tprintf(\"operandB data string or data file must be specified\\n\");\n\tprintUsage();\n     }\n    if ((operandBData != NULL) && (operandBFilename != NULL)) {\n\tprintf(\"operandB data string and data file cannot both be specified\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n\tin.offset = offset;\n\tin.operation = operation;\n    }\n    if (operandBData != NULL) {\n\trc = TSS_TPM2B_StringCopy(&in.operandB.b,\n\t\t\t\t  operandBData, sizeof(in.operandB.t.buffer));\n\t\n    }\n    if (operandBFilename != NULL) {\n\trc = TSS_File_Read2B(&in.operandB.b,\n\t\t\t     sizeof(in.operandB.t.buffer),\n\t\t\t     operandBFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyCounterTimer,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policycountertimer: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policycountertimer: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policycountertimer\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyCounterTimer\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-ic\\tdata string (operandB)\\n\");\n    printf(\"\\t-if\\tdata file (operandB) \\n\");\n    printf(\"\\t[-off\\toffset (default 0)]\\n\");\n    printf(\"\\t-op\\toperation (default A = B)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\t0\tA = B \\n\");\n    printf(\"\\t\\t1\tA != B \\n\");\n    printf(\"\\t\\t2\tA > B signed\t \\n\");\n    printf(\"\\t\\t3\tA > B unsigned\t \\n\");\n    printf(\"\\t\\t4\tA < B signed\t \\n\");\n    printf(\"\\t\\t5\tA < B unsigned\t \\n\");\n    printf(\"\\t\\t6\tA >= B signed\t \\n\");\n    printf(\"\\t\\t7\tA >= B unsigned\t \\n\");\n    printf(\"\\t\\t8\tA <= B signed\t \\n\");\n    printf(\"\\t\\t9\tA <= B unsigned\t \\n\");\n    printf(\"\\t\\tA\tAll bits SET in B are SET in A. ((A&B)=B) \\n\");\n    printf(\"\\t\\tB\tAll bits SET in B are CLEAR in A. ((A&B)=0) \\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policycphash.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyCpHash\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void   printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyCpHash_In \t\tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*cpHashAFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-cp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcpHashAFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-cp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (cpHashAFilename == NULL) {\n\tprintf(\"Missing handle parameter -cp\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.cpHashA.b,\n\t\t\t     sizeof(in.cpHashA.t.buffer),\n\t\t\t     cpHashAFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyCpHash,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policycphash: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policycphash: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policycphash\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyCpHash\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-cp\\tcpHash file\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policyduplicationselect.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyDuplicationSelect \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2019.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void   printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyDuplicationSelect_In \tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*newParentNameFilename = NULL;\n    const char \t\t\t*objectNameFilename = NULL;\n    TPMI_YES_NO\t\t\tincludeObject = NO;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-inpn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnewParentNameFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-inpn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ion\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tobjectNameFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ion option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-io\") == 0) {\n\t    includeObject = YES;\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (newParentNameFilename == NULL) {\n\tprintf(\"Missing handle parameter -inpn\\n\");\n\tprintUsage();\n    }\n    if (objectNameFilename == NULL) {\n\tprintf(\"include object -io requires object Name -ion\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n\tin.includeObject = includeObject;\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.newParentName.b,\n\t\t\t     sizeof(in.newParentName.t.name),\n\t\t\t     newParentNameFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.objectName.b,\n\t\t\t     sizeof(in.objectName.t.name),\n\t\t\t     objectNameFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyDuplicationSelect,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policyduplicationselect: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policyduplicationselect: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policyduplicationselect\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyDuplicationSelect\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-inpn\\tnew parent Name file\\n\");\n    printf(\"\\t-ion\\tobject Name file\\n\");\n    printf(\"\\t[-io\\tinclude object (default no)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policygetdigest.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyGetDigest\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyGetDigest_In \t\tin;\n    PolicyGetDigest_Out \tout;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char\t\t\t*digestFilename = NULL;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-of\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdigestFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyGetDigest,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (digestFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.policyDigest.t.buffer,\n\t\t\t\t      out.policyDigest.t.size,\n\t\t\t\t      digestFilename );\n    }\n    if (rc == 0) {\n\tTSS_PrintAll(\"policyDigest\", out.policyDigest.t.buffer, out.policyDigest.t.size);\n\tif (tssUtilsVerbose) printf(\"policygetdigest: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policygetdigest: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policygetdigest\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyGetDigest\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t[-of\\tbinary digest file name (default do not save)]\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policymaker.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   policymaker\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n   policymaker calculates a TPM2 policy hash\n\n   Inputs are:\n\n   a hash algorithm\n   a file with lines in hexascii, to be extended into the policy digest, big endian\n\n   NOTE: Empty lines (lines with just a newline character) are permitted and cause a double hash.\n   This is useful for e.g. TPM2_PolicySigned when the policyRef is empty.\n\n   Outputs are:\n\n   if specified, a file with a binary digest\n   if specified, a print of the hash\n\n   Example input: policy command code with a command code of NV write\n\n   0000016c00000137\n\n   TPM2_PolicyCounterTimer is handled as a special case, where there is a double hash.\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <errno.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsscrypto.h>\n\nstatic void printUsage(void);\nstatic int Format_FromHexascii(unsigned char *binary,\n\t\t\t       const char *string,\n\t\t\t       size_t length);\nstatic int Format_ByteFromHexascii(unsigned char *byte,\n\t\t\t\t   const char *string);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\ti;    \t\t\t/* argc iterator */\n    char \t\t*prc = NULL;\t\t/* pointer return code */\n    const char \t\t*inFilename = NULL;\n    const char \t\t*outFilename = NULL;\n    int\t\t\tpr = FALSE;\n    int\t\t\tnz = FALSE;\n    int\t\t\tnoSpace = FALSE;\n    TPMT_HA \t\tdigest;\n    /* initialized to suppress false gcc -O3 warning */\n    uint32_t           \tsizeInBytes = 0;\t/* hash algorithm mapped to size */\n    uint32_t           \tstartSizeInBytes = 0;\t/* starting buffer for extend */\n    FILE \t\t*inFile = NULL;\n    FILE \t\t*outFile = NULL;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line defaults */\n    digest.hashAlg = TPM_ALG_SHA256;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    digest.hashAlg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    digest.hashAlg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    digest.hashAlg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    digest.hashAlg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-of\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pr\") == 0) {\n\t    pr = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-nz\") == 0) {\n\t    nz = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-ns\") == 0) {\n\t    noSpace = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (inFilename == NULL) {\n\tprintf(\"Missing input file parameter -if\\n\");\n\tprintUsage();\n    }\n    /* open the input file */\n    if (rc == 0) {\n\tinFile = fopen(inFilename, \"r\");\n\tif (inFile == NULL) {\n\t    printf(\"Error opening %s for %s, %s\\n\", inFilename, \"r\", strerror(errno));\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if (rc == 0) {\n\tsizeInBytes = TSS_GetDigestSize(digest.hashAlg);\n\t/* startauthsession sets session digest to zero */\n\tif (!nz) {\n\t    startSizeInBytes = sizeInBytes;\n\t    memset((uint8_t *)&digest.digest, 0, sizeInBytes);\n\t}\n\telse {\t/* nz TRUE, start with empty buffer */\n\t    startSizeInBytes = 0;\n\t}\n    }\n    /* iterate through each line */\n    do {\n\tchar \t\tlineString[10240];\t\t/* returned line in hex ascii */\n\tunsigned char \tlineBinary[5120];\t\t/* returned line in binary */\n\tsize_t\t\tlineLength;\t\t\t\n\n\tif (rc == 0) {\n\t    prc = fgets(lineString, sizeof(lineString), inFile);\n\t}\n\tif (prc != NULL) {\n\t    /* convert hex ascii to binary */ \n\t    if (rc == 0) {\n\t\tlineLength = strlen(lineString);\n\t\trc = Format_FromHexascii(lineBinary,\n\t\t\t\t\t lineString, lineLength/2);\n\t    }\n\t    if (rc == 0) {\n\t\t/* not TPM2_PolicyCounterTimer */\n\t\tif (memcmp(lineString, \"0000016d\", 8) != 0) {\n\t\t    /* hash extend digest.digest with line */\n\t\t    if (rc == 0) {\n\t\t\trc = TSS_Hash_Generate(&digest,\n\t\t\t\t\t       startSizeInBytes, (uint8_t *)&digest.digest,\n\t\t\t\t\t       lineLength /2, lineBinary,\n\t\t\t\t\t       0, NULL);\n\t\t    }\n\t\t}\n\t\t/* TPM2_PolicyCounterTimer is a special case - double hash */\n\t\telse {\n\t\t    TPMT_HA\targs;\n\t\t    args.hashAlg = digest.hashAlg;\n\t\t    if (rc == 0) {\n\t\t\t/* args is a hash of the arguments excluding the command code */\n\t\t\trc = TSS_Hash_Generate(&args,\n\t\t\t\t\t       (lineLength /2) -4, lineBinary +4,\n\t\t\t\t\t       0, NULL);\n\t\t    }\n\t\t    if (rc == 0) {\n\t\t\tuint8_t commandCode[] = {0x00, 0x00, 0x01, 0x6d};\n\t\t\trc = TSS_Hash_Generate(&digest,\n\t\t\t\t\t       startSizeInBytes, (uint8_t *)&digest.digest,\n\t\t\t\t\t       sizeof(commandCode), commandCode,\n\t\t\t\t\t       startSizeInBytes, (uint8_t *)&args.digest,\n\t\t\t\t\t       0, NULL);\n\t\t    }\n\t\t}\n\t    }\n\t    if (rc == 0) {\n\t\tif (tssUtilsVerbose) TSS_PrintAll(\"intermediate policy digest\",\n\t\t\t\t\t  (uint8_t *)&digest.digest, sizeInBytes);\n\t    }\n\t}\n    }\n    while ((rc == 0) && (prc != NULL));\n\n    if ((rc == 0) && pr) {\n\tTSS_PrintAll(\"policy digest\", (uint8_t *)&digest.digest, sizeInBytes);\n    }\n    if ((rc == 0) && noSpace) {\n\tunsigned int b;\n\tprintf(\"policy digest:\\n\");\n\tfor (b = 0 ; b < sizeInBytes ; b++) {\n\t    printf(\"%02x\", *(((uint8_t *)&digest.digest) + b));\n\t}\n\tprintf(\"\\n\");\n    }\n    /* open the output file */\n    if ((rc == 0) && (outFilename != NULL)) {\n\toutFile = fopen(outFilename, \"wb\");\n\tif (outFile == NULL) {\n\t    printf(\"Error opening %s for %s, %s\\n\", outFilename , \"W\", strerror(errno));\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if ((rc == 0) && (outFilename != NULL)) {\n\tfwrite((uint8_t *)&digest.digest, 1, sizeInBytes, outFile);\n    }\n    if (inFile != NULL) {\n\tfclose(inFile);\n    }\n    if (outFile != NULL) {\n\tfclose(outFile);\n    }\n    if (rc != 0) {\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n/* Format_FromHexAscii() converts 'string' in hex ascii to 'binary' of 'length'\n\n   It assumes that the string has enough bytes to accommodate the length.\n*/\n\nstatic int Format_FromHexascii(unsigned char *binary,\n\t\t\t       const char *string,\n\t\t\t       size_t length)\n{\n    int \trc = 0;\n    size_t\ti;\n\n    for (i = 0 ; (rc == 0) && (i < length) ; i++) {\n\trc = Format_ByteFromHexascii(binary + i,\n\t\t\t\t     string + (i * 2));\n\t\n    }\n    return rc;\n}\n\n/* Format_ByteFromHexAscii() converts two bytes of hex ascii to one byte of binary\n */\n\nstatic int Format_ByteFromHexascii(unsigned char *byte,\n\t\t\t\t   const char *string)\n{\n    int \trc = 0;\n    size_t\ti;\n    char\tc;\n    *byte \t= 0;\n    \n    for (i = 0 ; (rc == 0) && (i < 2) ; i++) {\n\t(*byte) <<= 4;\t\t/* big endian, shift up the nibble */\n\tc = *(string + i);\t/* extract the next character from the string */\n\n\tif ((c >= '0') && (c <= '9')) {\n\t    *byte += c - '0';\n\t}\n\telse if ((c >= 'a') && (c <= 'f')) {\n\t    *byte += c + 10 - 'a';\n\t}\n\telse if ((c >= 'A') && (c <= 'F')) {\n\t    *byte += c + 10 - 'A';\n\t}\n\telse {\n\t    printf(\"Format_ByteFromHexascii: \"\n\t\t   \"Error: Line has non hex ascii character: %02x %c\\n\", c, c);\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    return rc;\n}\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policymaker\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-halg\\thash algorithm (sha1 sha256 sha384 sha512) (default sha256)]\\n\");\n    printf(\"\\t[-nz\\tdo not extend starting with zeros, just hash the last line]\\n\");\n    printf(\"\\t-if\\tinput policy statements in hex ascii\\n\");\n    printf(\"\\t[-of\\toutput file - policy hash in binary]\\n\");\n    printf(\"\\t[-pr\\tstdout - policy hash in hex ascii]\\n\");\n    printf(\"\\t[-ns\\tadditionally print policy hash in hex ascii on one line]\\n\");\n    printf(\"\\t\\tUseful to paste into policy OR\\n\");\n    printf(\"\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policymakerpcr.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   policymakerpcr\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n   policymakerpcr calculates a policyPCR term suitable for input to policymaker\n\n   Inputs are:\n\n   a hash algorithm\n\n   a byte mask, totally big endian, e.g. 010000 is PCR 16 \n\n   a file with lines in hexascii representing PCRs, e.g., the output of pcrread -ns\n   removed\n\n   This assumes that the byte mask and PCR value file are consistent.\n   \n   Outputs are:\n\n   if specified, a file with a hex ascii policyPCR line suitable for input to policymaker\n\n   if specified, a print of the hash\n\n   Example: \n\n   policymakerpcr -halg sha1 -bm 010000 -if policies/policypcr16aaasha1.txt -v -pr -of policies/policypcr.txt\n\n   Where policypcr16aaasha1.txt is represents the SHA-1 value of PCR 16\n   \n   e.g., 1d47f68aced515f7797371b554e32d47981aa0a0\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <errno.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\nstatic void printPolicyPCR(FILE *out,\n\t\t\t   uint32_t           \tsizeInBytes,         \t\t\n\t\t\t   TPML_PCR_SELECTION\t*pcrs,\n\t\t\t   TPMT_HA \t\t*digest);\nstatic int Format_FromHexascii(unsigned char *binary,\n\t\t\t       const char *string,\n\t\t\t       size_t length);\nstatic int Format_ByteFromHexascii(unsigned char *byte,\n\t\t\t\t   const char *string);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\ti;    \t\t\t/* argc iterator */\n    char \t\t*prc = NULL;\t\t/* pointer return code */\n    const char \t\t*inFilename = NULL;\n    const char \t\t*outFilename = NULL;\n    FILE \t\t*inFile = NULL;\n    FILE \t\t*outFile = NULL;\n    /* initialized to suppress false gcc -O3 warning */\n    uint32_t           \tsizeInBytes = 0;\t/* hash algorithm mapped to size */\n    uint32_t\t  \tpcrmask = 0xffffffff;\t/* pcr register mask */\n    TPML_PCR_SELECTION\tpcrs;\n    unsigned int \tpcrCount = 0;\n    TPMU_HA\t\tpcr[IMPLEMENTATION_PCR];\t/* all the PCRs */\n    int\t\t\tpr = FALSE;\n    TPMT_HA \t\tdigest;\n    uint8_t\t\tpcrBytes[IMPLEMENTATION_PCR * sizeof(TPMU_HA)];\n    uint16_t\t\tpcrLength;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line defaults */\n    digest.hashAlg = TPM_ALG_SHA256;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    digest.hashAlg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    digest.hashAlg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    digest.hashAlg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    digest.hashAlg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-bm\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (1 != sscanf(argv[i], \"%x\", &pcrmask)) {\n\t\t    printf(\"Invalid -bm argument '%s'\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-bm option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-of\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pr\") == 0) {\n\t    pr = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (pcrmask == 0xffffffff) {\n\tprintf(\"Missing or illegal pcr byte mask parameter -bm\\n\");\n\tprintUsage();\n    }\n    if ((pcrmask != 0) && (inFilename == NULL)) {\n\tprintf(\"Missing file name parameter -if\\n\");\n\tprintUsage();\n    }\n    if ((pcrmask == 0) && (inFilename != NULL)) {\n\tprintf(\"Unnecessary file name parameter -if\\n\");\n\tprintUsage();\n    }\n    /* open the input file if needed */\n    if ((rc == 0) && (pcrmask != 0) && (inFilename != NULL)) {\n\tinFile = fopen(inFilename, \"r\");\n\tif (inFile == NULL) {\n\t    printf(\"Error opening %s for %s, %s\\n\", inFilename, \"r\", strerror(errno));\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if (rc == 0) {\n\tsizeInBytes = TSS_GetDigestSize(digest.hashAlg);\n    }\n    /* Table 102 - Definition of TPML_PCR_SELECTION Structure */\n    if (rc == 0) {\n\tpcrs.count = 1;\t\t/* hard code one hash algorithm */\n\t/* Table 85 - Definition of TPMS_PCR_SELECTION Structure - pcrSelections */\n\tpcrs.pcrSelections[0].hash = digest.hashAlg;\n\tpcrs.pcrSelections[0].sizeofSelect= 3;\t/* hard code 24 PCRs */\n\t/* TCG always marshals lower PCR first */\n\tpcrs.pcrSelections[0].pcrSelect[0] = (pcrmask >>  0) & 0xff;\n\tpcrs.pcrSelections[0].pcrSelect[1] = (pcrmask >>  8) & 0xff;\n\tpcrs.pcrSelections[0].pcrSelect[2] = (pcrmask >> 16) & 0xff;\n    }\n    /* read the input file to the PCR array, assumes the PCR select bm has the correct number of\n       bits */\n    /* iterate through each line */\n    for (pcrCount = 0 ;\n\t (rc == 0) && (pcrCount < IMPLEMENTATION_PCR) && (inFile != NULL) ;\n\t pcrCount++) {\n\n\tchar \t\tlineString[256];\t\t/* returned line in hex ascii */\n\tsize_t\t\tlineLength;\n\n\tif (rc == 0) {\n\t    prc = fgets(lineString, sizeof(lineString), inFile);\n\t}\n\t/* no more lines, pcrCount is number of PCRs processed */\n\tif (rc == 0) {\n\t    if (prc == NULL) {\n\t\tbreak;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    lineLength = strlen(lineString);\n\t    if (lineLength == 0) {\n\t\tbreak;\n\t    }\n\t    if (lineString[lineLength-1] == '\\n') {\n\t\tlineString[lineLength-1] = '0';\n\t\tlineLength--;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    if (lineLength != ((size_t)(sizeInBytes) *2)) {\n\t\tprintf(\"Line length %lu is not twice digest size %lu\\n\",\n\t\t       (unsigned long)lineLength, (unsigned long)sizeInBytes);\n\t\trc = -1;\n\t    }\n\t}\n\t/* convert hex ascii to binary */ \n\tif ((rc == 0) && (prc != NULL)) {\n\t    rc = Format_FromHexascii((uint8_t *)&pcr[pcrCount],\n\t\t\t\t     lineString, lineLength/2);\n\t}\n\tif (rc == 0) {\n\t    if (tssUtilsVerbose) printf(\"PCR %u\\n\", pcrCount);\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"PCR\", (uint8_t *)&pcr[pcrCount], sizeInBytes);\n\t}\n    }\n    /* serialize PCRs */\n    if (rc == 0) {\n\tunsigned int pc;\n\tuint8_t *buffer = pcrBytes;\n\tuint32_t size = IMPLEMENTATION_PCR * sizeof(TPMU_HA);\n\tpcrLength = 0;\n\tfor (pc = 0 ; (rc == 0) && (pc < pcrCount) ; pc++) {\n\t    rc = TSS_Array_Marshalu((uint8_t *)&pcr[pc], sizeInBytes, &pcrLength, &buffer, &size);\n\t}\n    }\n    /* hash the marshaled PCR array */\n    if (rc == 0) {\n\trc = TSS_Hash_Generate(&digest,\n\t\t\t       pcrLength, pcrBytes,\n\t\t\t       0, NULL);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_PrintAll(\"PCR composite digest\", (uint8_t *)&digest.digest, sizeInBytes);\n    }\n    if ((rc == 0) && pr) {\n\tprintPolicyPCR(stdout,\n\t\t       sizeInBytes,\n\t\t       &pcrs,\n\t\t       &digest);\n    }\n    if (outFilename != NULL) {\n\tif (rc == 0) {\n\t    outFile = fopen(outFilename, \"wb\");\n\t    if (outFile == NULL) {\n\t\tprintf(\"Error opening %s for %s, %s\\n\", outFilename , \"W\", strerror(errno));\n\t\trc = EXIT_FAILURE;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    printPolicyPCR(outFile,\n\t\t\t   sizeInBytes,\n\t\t\t   &pcrs,\n\t\t\t   &digest);\n\t}\n    }\n    if (inFile != NULL) {\n\tfclose(inFile);\n    }\n    if (outFile != NULL) {\n\tfclose(outFile);\n    }\n    if (rc != 0) {\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printPolicyPCR(FILE \t\t*out,\n\t\t\t   uint32_t           \tsizeInBytes,         \t\t\n\t\t\t   TPML_PCR_SELECTION\t*pcrs,\n\t\t\t   TPMT_HA \t\t*digest)\n{\n    unsigned int i;\n    uint8_t *pcrDigest = (uint8_t *)&digest->digest;\n\n    fprintf(out, \"%02x\", 0xff & (TPM_CC_PolicyPCR >> 24));\n    fprintf(out, \"%02x\", 0xff & (TPM_CC_PolicyPCR >> 16));\n    fprintf(out, \"%02x\", 0xff & (TPM_CC_PolicyPCR >>  8));\n    fprintf(out, \"%02x\", 0xff & (TPM_CC_PolicyPCR >>  0));\n    /* NOTE only handles count of 1, 1 hash algorithm */\n    fprintf(out, \"%08x\", pcrs->count);\n\n    fprintf(out, \"%02x\", 0xff & (pcrs->pcrSelections[0].hash >> 8));\n    fprintf(out, \"%02x\", 0xff & (pcrs->pcrSelections[0].hash >> 0));\n\n    fprintf(out, \"%02x\", pcrs->pcrSelections[0].sizeofSelect);\n    \n    fprintf(out, \"%02x\", pcrs->pcrSelections[0].pcrSelect[0]);\n    fprintf(out, \"%02x\", pcrs->pcrSelections[0].pcrSelect[1]);\n    fprintf(out, \"%02x\", pcrs->pcrSelections[0].pcrSelect[2]);\n\n    for (i = 0 ; i < sizeInBytes ; i++) {\n\tfprintf(out, \"%02x\", pcrDigest[i]);\n    }\n    fprintf(out, \"\\n\");\n    return;\n}\n\n/* Format_FromHexAscii() converts 'string' in hex ascii to 'binary' of 'length'\n\n   It assumes that the string has enough bytes to accommodate the length.\n*/\n\nstatic int Format_FromHexascii(unsigned char *binary,\n\t\t\t       const char *string,\n\t\t\t       size_t length)\n{\n    int \trc = 0;\n    size_t\ti;\n\n    for (i = 0 ; (rc == 0) && (i < length) ; i++) {\n\trc = Format_ByteFromHexascii(binary + i,\n\t\t\t\t     string + (i * 2));\n\t\n    }\n    return rc;\n}\n\n/* Format_ByteFromHexAscii() converts two bytes of hex ascii to one byte of binary\n */\n\nstatic int Format_ByteFromHexascii(unsigned char *byte,\n\t\t\t\t   const char *string)\n{\n    int \trc = 0;\n    size_t\ti;\n    char\tc;\n    *byte \t= 0;\n    \n    for (i = 0 ; (rc == 0) && (i < 2) ; i++) {\n\t(*byte) <<= 4;\t\t/* big endian, shift up the nibble */\n\tc = *(string + i);\t/* extract the next character from the string */\n\n\tif ((c >= '0') && (c <= '9')) {\n\t    *byte += c - '0';\n\t}\n\telse if ((c >= 'a') && (c <= 'f')) {\n\t    *byte += c + 10 - 'a';\n\t}\n\telse if ((c >= 'A') && (c <= 'F')) {\n\t    *byte += c + 10 - 'A';\n\t}\n\telse {\n\t    printf(\"Format_ByteFromHexascii: \"\n\t\t   \"Error: Line has non hex ascii character: %c\\n\", c);\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    return rc;\n}\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policymakerpcr\\n\");\n    printf(\"\\n\");\n    printf(\"Creates a policyPCR term suitable for input to policymaker (hex ascii)\\n\");\n    printf(\"\\n\");\n    printf(\"Assumes that the byte mask and PCR values are consistent\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-halg\\thash algorithm  (sha1 sha256 sha384 sha512) (default sha256)]\\n\");\n    printf(\"\\t-bm\\tpcr byte mask in hex, big endian\\n\");\n    printf(\"\\n\");\n    printf(\"\\te.g. 010000 selects PCR 16\\n\");\n    printf(\"\\te.g. ffffff selects all 24 PCRs\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-if input file - PCR values, hex ascii, one per line, %u max\\n\", IMPLEMENTATION_PCR);\n    printf(\"\\trequired unless pcr mask is 0\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-of\\toutput file - policy hash in binary]\\n\");\n    printf(\"\\t[-pr\\tstdout - policy hash in hex ascii]\\n\");\n    printf(\"\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policynamehash.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyNameHash \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2019.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void   printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyNameHash_In\t \tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*nameHashFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    uint8_t \t\t\t*buffer = NULL;\n    size_t \t\t\tlength = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nh\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnameHashFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-inpn option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (nameHashFilename == NULL) {\n\tprintf(\"Missing handle parameter -nh\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     nameHashFilename);\n    }\n    if (rc == 0) {\n\tif (length <= sizeof(in.nameHash.t.buffer)) {\n\t    in.nameHash.t.size = (uint16_t)length;\n\t    memcpy(&in.nameHash.t.buffer, buffer, length);\n\t}\n\telse {\n\t    printf(\"Name length %u too large\\n\", (unsigned int)length);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyNameHash,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policynamehash: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policynamehash: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(buffer);\t\t/* @1 */\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policynamehash\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyNameHash\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-nh\\tNameHash file - TPM2B_DIGEST\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policynv.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyNV\t \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyNV_In \t\tin;\n    char \t\t\thierarchyChar = 0;\n    const char\t\t\t*authPassword = NULL; \t\t/* default no password */\n    TPMI_RH_NV_INDEX\t\tnvIndex = 0;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*operandBData = NULL;\n    const char \t\t\t*operandBFilename = NULL;\n    uint16_t \t\t\toffset = 0;\t\t\t/* default 0 */\n    TPM_EO\t\t\toperation = 0;\t\t\t/* default A = B */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &nvIndex);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hs\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toperandBData = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-if\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toperandBFilename = argv[i];\n\t    } else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-off\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toffset = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"-off option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-op\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%hx\", &operation);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -op\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (nvIndex == 0) {\n\tprintf(\"Missing NV index handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing policy session handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if ((operandBData == NULL) && (operandBFilename == NULL)) {\n\tprintf(\"operandB data string or data file must be specified\\n\");\n\tprintUsage();\n     }\n    if ((operandBData != NULL) && (operandBFilename != NULL)) {\n\tprintf(\"operandB data string and data file cannot both be specified\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tif (hierarchyChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;\n\t}\n\telse if (hierarchyChar == 0) {\n\t    in.authHandle = nvIndex;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.nvIndex = nvIndex;\n\tin.policySession = policySession;\n\tin.offset = offset;\n\tin.operation = operation;\n    }\n    if (operandBData != NULL) {\n\trc = TSS_TPM2B_StringCopy(&in.operandB.b,\n\t\t\t\t  operandBData, sizeof(in.operandB.t.buffer));\n\t\n    }\n    if (operandBFilename != NULL) {\n\trc = TSS_File_Read2B(&in.operandB.b,\n\t\t\t     sizeof(in.operandB.t.buffer),\n\t\t\t     operandBFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyNV,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policynv: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policynv: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policynv\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyNV\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hi\\thierarchy authHandle (o, p)]\\n\");\n    printf(\"\\t\\tdefault NV index\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tNV index handle (operand A)\\n\");\n    printf(\"\\t[-pwda\\tpassword for authorization (default empty)]\\n\");\n    printf(\"\\t-hs\\tpolicy session handle\\n\");\n    printf(\"\\t-ic\\tdata string (operandB)\\n\");\n    printf(\"\\t-if\\tdata file (operandB) \\n\");\n    printf(\"\\t[-off\\toffset (default 0)]\\n\");\n    printf(\"\\t-op\\toperation (default A = B)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\t0\tA = B \\n\");\n    printf(\"\\t\\t1\tA != B \\n\");\n    printf(\"\\t\\t2\tA > B signed\t \\n\");\n    printf(\"\\t\\t3\tA > B unsigned\t \\n\");\n    printf(\"\\t\\t4\tA < B signed\t \\n\");\n    printf(\"\\t\\t5\tA < B unsigned\t \\n\");\n    printf(\"\\t\\t6\tA >= B signed\t \\n\");\n    printf(\"\\t\\t7\tA >= B unsigned\t \\n\");\n    printf(\"\\t\\t8\tA <= B signed\t \\n\");\n    printf(\"\\t\\t9\tA <= B unsigned\t \\n\");\n    printf(\"\\t\\tA\tAll bits SET in B are SET in A. ((A&B)=B) \\n\");\n    printf(\"\\t\\tB\tAll bits SET in B are CLEAR in A. ((A&B)=0) \\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policynvwritten.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyNvWritten \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyNvWritten_In \t\tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    char \t\t\twrittenSetChar = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ws\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\twrittenSetChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ws\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hs\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing policy session handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tif (writtenSetChar == 'y') {\n\t    in.writtenSet = YES;\n\t}\n\telse if (writtenSetChar == 'n') {\n\t    in.writtenSet = NO;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -ws\\n\");\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyNvWritten,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policynvwritten: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policynvwritten: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policynvwritten\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyNvWritten\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hs\\tpolicy session handle\\n\");\n    printf(\"\\t-ws\\twritten set (y, n)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t80\\taudit\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policyor.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyOR\t \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    uint32_t\t\t\tj;\n    PolicyOR_In \t\tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*pHashListFilename[8];\n    uint32_t\t\t\tcount = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (count < 8) {\n\t\t    pHashListFilename[count] = argv[i];\n\t\t    count++;\n\t\t}\n\t\telse {\n\t\t    printf(\"-if can only be specified up to 8 times\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (count < 2) {\n\tprintf(\"-if must be specified 2 to 8 times\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n\tin.pHashList.count = count;\n    }\n    /* -if is specified 2-8 times and fills the pHashListFilename array of policy AND term file names */\n    for (j = 0 ; ((j < count) && (rc == 0)) ; j++) {\n\trc = TSS_File_Read2B(&in.pHashList.digests[j].b,\n\t\t\t     sizeof(in.pHashList.digests[j].t.buffer),\n\t\t\t     pHashListFilename[j]);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyOR,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policyor: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policyor: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policyor\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyOR\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-if\\tpolicy digest file (2-8 -if specifiers required)\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policyparameters.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyParameters\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2024.   \t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/*\n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void   printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyParameters_In \tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*pHashFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ph\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpHashFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ph option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (pHashFilename == NULL) {\n\tprintf(\"Missing handle parameter -ph\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.pHash.b,\n\t\t\t     sizeof(in.pHash.t.buffer),\n\t\t\t     pHashFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyParameters,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policyparameters: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policyparameters: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policyparameters\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyParameters\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-ph\\tparameter hash file\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policypassword.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyPassword\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    PolicyPassword_In \t\tin;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyPassword,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policypassword: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policypassword: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policypassword\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyPassword\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policypcr.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyPCR\t \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyPCR_In \t\tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    uint32_t\t  \t\tpcrmask = 0xffffffff;\t\t/* pcr register mask */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t    \n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-bm\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (1 != sscanf(argv[i], \"%x\", &pcrmask)) {\n\t\t    printf(\"Invalid -bm argument '%s'\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-bm option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (pcrmask == 0xffffffff) {\n\tprintf(\"Missing pcr mask parameter -bm\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n\t/* NOTE not implemented yet */\n\tin.pcrDigest.b.size = 0;\n\t/* Table 102 - Definition of TPML_PCR_SELECTION Structure */\n\tin.pcrs.count = 1;\t\t/* hard code one hash algorithm */\n\t/* Table 85 - Definition of TPMS_PCR_SELECTION Structure - pcrSelections */\n\tin.pcrs.pcrSelections[0].hash = halg;\n\tin.pcrs.pcrSelections[0].sizeofSelect= 3;\t/* hard code 24 PCRs */\n\t/* TCG always marshals lower PCR first */\n\tin.pcrs.pcrSelections[0].pcrSelect[0] = (pcrmask >>  0) & 0xff;\n\tin.pcrs.pcrSelections[0].pcrSelect[1] = (pcrmask >>  8) & 0xff;\n\tin.pcrs.pcrSelections[0].pcrSelect[2] = (pcrmask >> 16) & 0xff;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyPCR,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policypcr: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policypcr: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policypcr\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyPCR\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t-bm\\tpcr mask in hex\\n\");\n    printf(\"\\t\\te.g., -bm 10000 is PCR 16, 000001 is PCR 0\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policyrestart.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyRestart\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyRestart_In \t\tin;\n    TPMI_SH_POLICY\t\tsessionHandle = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (sessionHandle == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.sessionHandle = sessionHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyRestart,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policyrestart: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policyrestart: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policyrestart\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyRestart\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policysecret.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicySecret\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicySecret_In \t\tin;\n    PolicySecret_Out \t\tout;\n    TPMI_DH_ENTITY\t\tauthHandle = 0;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*nonceTPMFilename = NULL;\n    const char \t\t\t*cpHashAFilename = NULL;\n    const char\t\t\t*policyRefFilename = NULL;\n    int32_t\t\t\texpiration = 0;\n    const char\t\t\t*ticketFilename = NULL;\n    const char\t\t\t*timeoutFilename = NULL;\n    const char\t\t\t*entityPassword = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    in.nonceTPM.b.size = 0;\n    in.cpHashA.b.size = 0;\n    in.policyRef.b.size = 0;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &authHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hs\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-in\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnonceTPMFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-in option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-cp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcpHashAFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-cp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pref\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyRefFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pref option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-exp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\texpiration = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -exp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwde\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tentityPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-to\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\ttimeoutFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-to option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (authHandle == 0) {\n\tprintf(\"Missing authorizing entity handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing policy session handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.authHandle = authHandle;\n\tin.policySession = policySession;\n    }\n    if ((rc == 0) && (nonceTPMFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.nonceTPM.b,\n\t\t\t     sizeof(in.nonceTPM.t.buffer),\n\t\t\t     nonceTPMFilename);\n    }\n    if ((rc == 0) && (cpHashAFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.cpHashA.b,\n\t\t\t     sizeof(in.cpHashA.t.buffer),\n\t\t\t     cpHashAFilename);\n    }\n    if ((rc == 0) && (policyRefFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.policyRef.b,\n\t\t\t     sizeof(in.policyRef.t.buffer),\n\t\t\t     policyRefFilename);\n    }\n    if (rc == 0) {\n\tin.expiration = expiration;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicySecret,\n\t\t\t sessionHandle0, entityPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (ticketFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.policyTicket,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_TK_AUTH_Marshalu,\n\t\t\t\t     ticketFilename);\n    }\n    if ((rc == 0) && (timeoutFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.timeout.b.buffer,\n\t\t\t\t      out.timeout.b.size,\n\t\t\t\t      timeoutFilename); \n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policysecret: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policysecret: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policysecret\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicySecret\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tauthorizing entity handle\\n\");\n    printf(\"\\t-hs\\tpolicy session handle\\n\");\n    printf(\"\\t[-in\\tnonceTPM file (default none)]\\n\");\n    printf(\"\\t[-cp\\tcpHash file (default none)]\\n\");\n    printf(\"\\t[-pref\\tpolicyRef file (default none)]\\n\");\n    printf(\"\\t[-exp\\texpiration (default none)]\\n\");\n    printf(\"\\t[-pwde\\tauthorizing entity password (default empty)]\\n\");\n    printf(\"\\t[-tk\\tticket file name]\\n\");\n    printf(\"\\t[-to\\ttimeout file name]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policysigned.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicySigned\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\nstatic TPM_RC signAHash(TPM2B_PUBLIC_KEY_RSA *signature,\n\t\t\tTPMT_HA *aHash,\n\t\t\tconst char *signingKeyFilename,\n\t\t\tconst char *signingKeyPassword);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicySigned_In \t\tin;\n    PolicySigned_Out \t\tout;\n    TPMI_DH_OBJECT\t\tauthObject = 0;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*nonceTPMFilename = NULL;\n    const char \t\t\t*cpHashAFilename = NULL;\n    const char\t\t\t*policyRefFilename = NULL;\n    const char\t\t\t*ticketFilename = NULL;\n    const char\t\t\t*timeoutFilename = NULL;\n    int32_t\t\t\texpiration = 0;\n    const char\t\t\t*signingKeyFilename = NULL;\n    const char\t\t\t*signingKeyPassword = NULL;\n    const char\t\t\t*signatureFilename = NULL;\n    uint8_t\t\t\t*signature = NULL;\n    size_t\t\t\tsignatureLength;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMT_HA \t\t\taHash;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    in.nonceTPM.b.size = 0;\t/* three of the components to aHash are optional */\n    in.cpHashA.b.size = 0;\n    in.policyRef.b.size = 0;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &authObject);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-in\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnonceTPMFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-in option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-cp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcpHashAFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-cp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pref\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyRefFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pref option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-exp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\texpiration = atoi(argv[i]);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -exp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsigningKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-sk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-is\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-is option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-to\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\ttimeoutFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-to option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsigningKeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (authObject == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if ((signingKeyFilename == NULL) && (signatureFilename == NULL)) {\n\tprintf(\"Missing signing key -sk or signature -is\\n\");\n\tprintUsage();\n    }\n    if ((signingKeyFilename != NULL) && (signatureFilename != NULL)) {\n\tprintf(\"Cannot have both signing key -sk and signature -is\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.authObject = authObject;\n\tin.policySession = policySession;\n    }\n    /* read the optional components - nonceTPM, cpHashA, policyRef */ \n    if ((rc == 0) && (nonceTPMFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.nonceTPM.b,\n\t\t\t     sizeof(in.nonceTPM.t.buffer),\n\t\t\t     nonceTPMFilename);\n    }\n    if ((rc == 0) && (cpHashAFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.cpHashA.b,\n\t\t\t     sizeof(in.cpHashA.t.buffer),\n\t\t\t     cpHashAFilename);\n    }\n    if ((rc == 0) && (policyRefFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.policyRef.b,\n\t\t\t     sizeof(in.policyRef.t.buffer),\n\t\t\t     policyRefFilename);\n    }\n    if (rc == 0) {\n\tin.expiration = expiration;\n\tin.auth.sigAlg = TPM_ALG_RSASSA;\t/* sample uses RSASSA */\n\tin.auth.signature.rsassa.hash = halg;\n    }\n    /* sample code using a PEM key to sign */\n    if (signingKeyFilename != NULL) {\n\t/* calculate the digest from the 4 components according to the TPM spec Part 3. */\n\t/* aHash = HauthAlg(nonceTPM || expiration || cpHashA || policyRef)\t(13) */\n\tif (rc == 0) {\n\t    int32_t expirationNbo = htonl(in.expiration);\n\t    aHash.hashAlg = halg;\n\t    /* This varargs function takes length / array pairs.  It skips pairs with a length of\n\t       zero.  This handles the three optional components (default length zero) with no\n\t       special handling. */\n\t    rc = TSS_Hash_Generate(&aHash,\t\t/* largest size of a digest */\n\t\t\t\t   in.nonceTPM.t.size, in.nonceTPM.t.buffer,\n\t\t\t\t   sizeof(int32_t), &expirationNbo,\n\t\t\t\t   in.cpHashA.t.size, in.cpHashA.t.buffer,\n\t\t\t\t   in.policyRef.t.size, in.policyRef.t.buffer,\n\t\t\t\t   0, NULL);\n\t}\n\t/* sign aHash */\n\tif (rc == 0) {\n\t    rc = signAHash(&in.auth.signature.rsassa.sig,\t/* sample uses RSASSA */\n\t\t\t   &aHash,\n\t\t\t   signingKeyFilename, signingKeyPassword);\n\t}\n    }\n    /* sample code where the signature has been generated externally */\n    if (signatureFilename != NULL) {\n\tif (rc == 0) {\n\t    rc = TSS_File_ReadBinaryFile((unsigned char **)&signature,     /* freed @1 */\n\t\t\t\t\t &signatureLength,\n\t\t\t\t\t signatureFilename);\n\t}\n\tif (rc == 0) {\n\t    if (signatureLength > sizeof(in.auth.signature.rsassa.sig.t.buffer)) {\n\t\tprintf(\"Signature length %lu is greater than buffer %lu\\n\",\n\t\t       (unsigned long)signatureLength,\n\t\t       (unsigned long)sizeof(in.auth.signature.rsassa.sig.t.buffer));\n\t\trc = TSS_RC_RSA_SIGNATURE;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    in.auth.signature.rsassa.sig.t.size = (uint16_t)signatureLength;\n\t    memcpy(&in.auth.signature.rsassa.sig.t.buffer, signature, signatureLength); \n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicySigned,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (ticketFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.policyTicket,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_TK_AUTH_Marshalu,\n\t\t\t\t     ticketFilename);\n    }\n    if ((rc == 0) && (timeoutFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.timeout.b.buffer,\n\t\t\t\t      out.timeout.b.size,\n\t\t\t\t      timeoutFilename); \n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policysigned: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policysigned: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(signature);\t/* @1 */\n    return rc;\n}\n\n/* signAHash() signs digest, returns signature.  The signature TPM2B_PUBLIC_KEY_RSA is a member of\n   the TPMT_SIGNATURE command parameter.\n\n   This sample signer uses a pem file signingKeyFilename with signingKeyPassword.\n\n*/\n\nTPM_RC signAHash(TPM2B_PUBLIC_KEY_RSA *signature,\n\t\t TPMT_HA *aHash,\n\t\t const char *signingKeyFilename,\n\t\t const char *signingKeyPassword)\n{\n    TPM_RC\t\trc = 0;\n    void\t\t*rsaKey = NULL;\n    uint32_t  \t\tsizeInBytes;\t\t/* hash algorithm mapped to size */\n    size_t\t \tsignatureLength;\t/* RSA_Sign() output */\n\n    if (rc == 0) {\n\tsizeInBytes = TSS_GetDigestSize(aHash->hashAlg);\n#if 0\n\tif (tssUtilsVerbose) {\n\t    TSS_PrintAll(\"signAHash: aHash\",\n\t\t\t (uint8_t *)(&aHash->digest), sizeInBytes);\n\t}\n#endif\n    }\n    /* read the PEM format private key into the private key structure */\n    if (rc == 0) {\n\trc = convertPemToRsaPrivKey((void **)&rsaKey,\t/* freed @1 */\n\t\t\t\t    signingKeyFilename, (void *)signingKeyPassword);\n    }\n    /* sign aHash */\n    if (rc == 0) {\n\trc = signRSAFromRSA(signature->t.buffer, &signatureLength,\n\t\t\t    sizeof(signature->t.buffer),\n\t\t\t    (uint8_t *)(&aHash->digest), sizeInBytes,\n\t\t\t    aHash->hashAlg,\n\t\t\t    rsaKey);\n    }\n    if (rc == 0) {\n\tsignature->t.size = (uint16_t)signatureLength;\t/* length of RSA key checked above */\n#if 0\n\tif (tssUtilsVerbose) TSS_PrintAll(\"signAHash: signature\",\n\t\t\t\t  signature->t.buffer, signature->t.size);\n#endif\n    }\n    TSS_RsaFree(rsaKey);\t/* @1 *//* FIXME may be wrong for mbedtls */\n    return rc;\n}\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policysigned\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicySigned\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tsignature verification key handle\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t[-in\\tnonceTPM file (default none)]\\n\");\n    printf(\"\\t[-cp\\tcpHash file (default none)]\\n\");\n    printf(\"\\t[-pref\\tpolicyRef file (default none)]\\n\");\n    printf(\"\\t[-exp\\texpiration in decimal (default none)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t-sk\\tRSA signing key file name (PEM format)\\n\");\n    printf(\"\\t\\tUse this signing key.\\n\");\n    printf(\"\\t-is\\tsignature file name\\n\");\n    printf(\"\\t\\tUse this signature from e.g., a smart card or other HSM.\\n\");\n    printf(\"\\t[-pwdk\\tsigning key password (default null)]\\n\");\n    printf(\"\\t[-tk\\tticket file name]\\n\");\n    printf(\"\\t[-to\\ttimeout file name]\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policytemplate.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyTemplate\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2016 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyTemplate_In \t\tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*templateFilename = NULL;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-te\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\ttemplateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-te option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (templateFilename == NULL) {\n\tprintf(\"Missing handle parameter -te\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.templateHash.b,\n\t\t\t     sizeof(in.templateHash.t.buffer),\n\t\t\t     templateFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyTemplate,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policytemplate: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policytemplate: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policytemplate\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyTemplate\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-te\\ttemplate file\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/policyticket.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    PolicyTicket\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    PolicyTicket_In \t\tin;\n    TPMI_SH_POLICY\t\tpolicySession = 0;\n    const char \t\t\t*timeoutFilename = NULL;\n    const char \t\t\t*cpHashAFilename = NULL;\n    const char\t\t\t*policyRefFilename = NULL;\n    const char \t\t\t*authNameFilename = NULL;\n    char \t\t\thierarchyChar = 0;\n    TPMI_RH_HIERARCHY\t\tprimaryHandle = TPM_RH_NULL;\n    const char\t\t\t*ticketFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    in.cpHashA.b.size = 0;\n    in.policyRef.b.size = 0;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &policySession);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-to\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\ttimeoutFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-to option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-cp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcpHashAFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-cp option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pref\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyRefFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pref option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-na\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthNameFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-na option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policySession == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (timeoutFilename == NULL) {\n\tprintf(\"Missing timeout file name parameter -to\\n\");\n\tprintUsage();\n    }\n    if (ticketFilename == NULL) {\n\tprintf(\"Missing ticket file name parameter -tk\\n\");\n\tprintUsage();\n    }\n    if ((authNameFilename == NULL) && (hierarchyChar == 0)) {\n\tprintf(\"Missing parameter -na or -hi\\n\");\n\tprintUsage();\n    }\n    if ((authNameFilename != NULL) && (hierarchyChar != 0)) {\n\tprintf(\"Cannot specify both -na and -hi\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.policySession = policySession;\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.timeout.b,\n\t\t\t     sizeof(in.timeout.t.buffer),\n\t\t\t     timeoutFilename);\n    }\n    if ((rc == 0) && (cpHashAFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.cpHashA.b,\n\t\t\t     sizeof(in.cpHashA.t.buffer),\n\t\t\t     cpHashAFilename);\n    }\n    if ((rc == 0) && (policyRefFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.policyRef.b,\n\t\t\t     sizeof(in.policyRef.t.buffer),\n\t\t\t     policyRefFilename);\n    }\n    /* if the authorizing entity was an object */\n    if ((rc == 0) && (authNameFilename != NULL)) {\n\trc = TSS_File_Read2B(&in.authName.b,\n\t\t\t     sizeof(in.authName.t.name),\n\t\t\t     authNameFilename);\n    }\n    /* if the authorizing object was a hierarchy */\n    if ((rc == 0) && (hierarchyChar != 0)) {\n\tif (hierarchyChar == 'e') {\n\t    primaryHandle = TPM_RH_ENDORSEMENT;\n\t}\n\telse if (hierarchyChar == 'o') {\n\t    primaryHandle = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    primaryHandle = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Bad parameter %c for -hi\\n\", hierarchyChar);\n\t    printUsage();\n\t}\n\trc = TSS_TPM2B_CreateUint32(&in.authName.b, primaryHandle, sizeof(in.authName.t.name));\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.ticket,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPMT_TK_AUTH_Unmarshalu,\n\t\t\t\t    ticketFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyTicket,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"policyticket: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"policyticket: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"policyticket\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_PolicyTicket\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tpolicy session handle\\n\");\n    printf(\"\\t-to\\ttimeout file name\\n\");\n    printf(\"\\t[-cp\\tcpHash file (default none)]\\n\");\n    printf(\"\\t[-pref\\tpolicyRef file (default none)]\\n\");\n    printf(\"\\t-na\\tauthName file (not hierarchy)\\n\");\n    printf(\"\\t-hi\\thierarchy (e, o, p) (authName is hierarchy)\\n\");\n    printf(\"\\t\\te endorsement, o owner, p platform\\n\");\n    printf(\"\\t-tk\\tticket file name\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/powerup.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Simulator Power up\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n/* FIXME should really be in tpmtcpprotocol.h */\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\t\t/* for simulator startup */\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsstransmit.h>\t/* for simulator power up */\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC \t\trc = 0;\n    int\t\t\ti;\t\t\t\t/* argc iterator */\n    TSS_CONTEXT\t\t*tssContext = NULL;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /*\n      Start a TSS context\n    */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* power off platform */\n    if (rc == 0) {\n\trc = TSS_TransmitPlatform(tssContext, TPM_SIGNAL_POWER_OFF, \"TPM2_PowerOffPlatform\");\n    }\n    /* power on platform */\n    if (rc == 0) {\n\trc = TSS_TransmitPlatform(tssContext, TPM_SIGNAL_POWER_ON, \"TPM2_PowerOnPlatform\");\n    }\n    /* power on NV */\n    if (rc == 0) {\n\trc = TSS_TransmitPlatform(tssContext, TPM_SIGNAL_NV_ON, \"TPM2_NvOnPlatform\");\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"powerup: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"powerup: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"powerup\\n\");\n    printf(\"\\n\");\n    printf(\"Powers the simulator off and on, and powers up NV\\n\");\n    printf(\"\\n\");\n    exit(1);\t\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/printattr.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t         Print Attributes\t\t\t\t*/\n/*\t\t      Written by Ken Goldman\t\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2019\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Re-distributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Re-distributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssprint.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    unsigned int\t\ttmpSession;\n    TPMA_OBJECT \t\tobject;\n    TPMA_SESSION \t\tsession;\n    TPMA_STARTUP_CLEAR \t\tstartup;\n    TPMA_NV \t\t\tnv;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ob\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%8x\", &object.val);\n\t\tTSS_TPMA_OBJECT_Print(\"TPMA_OBJECT\", object, 0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ob\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%2x\", &tmpSession);\n\t\tsession.val = tmpSession;\n\t\tTSS_TPMA_SESSION_Print(session, 0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-st\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%8x\", &startup.val);\n\t\tTSS_TPMA_STARTUP_CLEAR_Print(startup, 0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -st\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nv\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%8x\", &nv.val);\n\t\tTSS_TPMA_NV_Print(nv, 0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -nv\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"printattr\\n\");\n    printf(\"\\n\");\n    printf(\"Prints TPMA attributes as text\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ob TPMA_OBJECT\\n\");\n    printf(\"\\t-se TPMA_SESSION \\n\");\n    printf(\"\\t-st TPMA_STARTUP_CLEAR \\n\");\n    printf(\"\\t-nv TPMA_NV\\n\"); \n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/publicname.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t         Public Name  \t\t\t\t\t*/\n/*\t\t      Written by Mark Marshall & Ken Goldman\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2018 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tsscryptoh.h>\n#include \"objecttemplates.h\"\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    int\t\t\t\tnoSpace = FALSE;\n    TPM2B_PUBLIC\t\tinPublic;\n    TPM2B_NV_PUBLIC\t\tnvPublic;\n    int\t\t\t\tkeyType = TYPE_SI;\n    TPMI_ALG_SIG_SCHEME \tscheme = TPM_ALG_RSASSA;\n    uint32_t \t\t\tkeyTypeSpecified = 0;\n    TPMI_ALG_PUBLIC \t\talgPublic = TPM_ALG_RSA;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_ALG_HASH\t\tnalg = TPM_ALG_SHA256;\n    const char\t\t\t*nvPublicFilename = NULL;\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*derKeyFilename = NULL;\n    const char\t\t\t*pemKeyFilename = NULL;\n    const char\t\t\t*nameFilename = NULL;\n    int\t\t\t\tuserWithAuth = TRUE;\n    int\t\t\t\tobject = TRUE;\t\t/* TPM object, false if NV index */\n    unsigned int\t\tinputCount = 0;\n    TPM2B_TEMPLATE\t\tmarshaled;\n    uint16_t\t\t\twritten;\n    uint32_t\t\t\tsize;\n    uint8_t\t\t\t*buffer;\n    TPMT_HA\t\t\tname;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-nalg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    nalg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    nalg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    nalg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    nalg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -nalg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-nalg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    algPublic = TPM_ALG_RSA;\n\t}\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    algPublic = TPM_ALG_ECC;\n\t}\n\telse if (strcmp(argv[i],\"-scheme\") == 0) {\n\t    if (keyType == TYPE_SI) {\n\t\ti++;\n\t\tif (i < argc) {\n\t\t    if (strcmp(argv[i],\"rsassa\") == 0) {\n\t\t\tscheme = TPM_ALG_RSASSA;\n\t\t    }\n\t\t    else if (strcmp(argv[i],\"rsapss\") == 0) {\n\t\t\tscheme = TPM_ALG_RSAPSS;\n\t\t    }\n\t\t    else if (strcmp(argv[i],\"null\") == 0) {\n\t\t\tscheme = TPM_ALG_NULL;\n\t\t    }\n\t\t    else {\n\t\t\tprintf(\"Bad parameter %s for -scheme\\n\", argv[i]);\n\t\t\tprintUsage();\n\t\t    }\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-scheme can only be specified for signing key\\n\");\n\t\tprintUsage();\n\t    }\n        }\n\telse if (strcmp(argv[i], \"-st\") == 0) {\n\t    keyType = TYPE_ST;\n\t    scheme = TPM_ALG_NULL;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-den\") == 0) {\n\t    keyType = TYPE_DEN;\n\t    scheme = TPM_ALG_NULL;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i], \"-si\") == 0) {\n\t    keyType = TYPE_SI;\n\t    keyTypeSpecified++;\n\t}\n\telse if (strcmp(argv[i],\"-ipu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t\tinputCount++;\n\t    }\n\t    else {\n\t\tprintf(\"-ipu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-invpu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnvPublicFilename = argv[i];\n\t\tobject = FALSE;\n\t\tinputCount++;\n\t    }\n\t    else {\n\t\tprintf(\"-ipu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipem\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemKeyFilename = argv[i];\n\t\tinputCount++;\n\t    }\n\t    else {\n\t\tprintf(\"-ipem option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ider\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tderKeyFilename = argv[i];\n\t\tinputCount++;\n\t    }\n\t    else {\n\t\tprintf(\"-ider option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-uwa\") == 0) {\n\t    userWithAuth = FALSE;\n\t}\n\telse if (strcmp(argv[i],\"-on\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnameFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-on option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ns\") == 0) {\n\t    noSpace = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (inputCount != 1) {\n\tprintf(\"Missing or too many parameters -ipu, -ipem, -ider, -invpu\\n\");\n\tprintUsage();\n    }\n    if (keyTypeSpecified > 1) {\n\tprintf(\"Too many key attributes\\n\");\n\tprintUsage();\n    }\n    if ((publicKeyFilename != NULL) && (!userWithAuth)) {\n\tprintf(\"userWithAuth unused for TPM2B_PUBLIC input\\n\");\n\tprintUsage();\n\t\n    }\n    /* loadexternal key pair cannot be restricted (storage key) and must have NULL symmetric\n       scheme*/\n    if (derKeyFilename != NULL) {\n\tif (keyType == TYPE_ST) {\n\t    keyType = TYPE_DEN;\n\t}\n    }\n    if (rc == 0) {\n\t/* TPM format key, output from create */\n\tif (publicKeyFilename != NULL) {\n\t    rc = TSS_File_ReadStructureFlag(&inPublic,\n\t\t\t\t\t    (UnmarshalFunctionFlag_t)TSS_TPM2B_PUBLIC_Unmarshalu,\n\t\t\t\t\t    TRUE,\t\t\t/* NULL permitted */\n\t\t\t\t\t    publicKeyFilename);\n\t}\n\t/* NV Index public area */\n\telse if (nvPublicFilename != 0) {\n\t    rc = TSS_File_ReadStructure(&nvPublic,\n\t\t\t\t\t(UnmarshalFunction_t)TSS_TPM2B_NV_PUBLIC_Unmarshalu,\n\t\t\t\t\tnvPublicFilename);\n\t    \n\t}\n\t/* PEM format, output from e.g. openssl, readpublic, createprimary, create */\n\telse if (pemKeyFilename != NULL) {\n\t    switch (algPublic) {\n\t      case TPM_ALG_RSA:\n\t\trc = convertRsaPemToPublic(&inPublic,\n\t\t\t\t\t   keyType,\n\t\t\t\t\t   scheme,\n\t\t\t\t\t   nalg,\n\t\t\t\t\t   halg,\n\t\t\t\t\t   pemKeyFilename);\n\t\tbreak;\n#ifndef TPM_TSS_NOECC\n\t      case TPM_ALG_ECC:\n\t\trc = convertEcPemToPublic(&inPublic,\n\t\t\t\t\t  keyType,\n\t\t\t\t\t  scheme,\n\t\t\t\t\t  nalg,\n\t\t\t\t\t  halg,\n\t\t\t\t\t  pemKeyFilename);\n\t\tbreak;\n#endif\t/* TPM_TSS_NOECC */\n\t      default:\n\t\tprintf(\"algorithm %04x not supported\\n\", algPublic);\n\t\trc = TPM_RC_ASYMMETRIC;\n\t    }\n\t}\n\t/* DER format key pair */\n\telse if (derKeyFilename != NULL) {\n\t    switch (algPublic) {\n\t      case TPM_ALG_RSA:\n\t\trc = convertRsaDerToPublic(&inPublic,\n\t\t\t\t\t   keyType,\n\t\t\t\t\t   scheme,\n\t\t\t\t\t   nalg,\n\t\t\t\t\t   halg,\n\t\t\t\t\t   derKeyFilename);\n\t\tbreak;\n#ifndef TPM_TSS_NOECC\n\t      case TPM_ALG_ECC:\n\t\trc = convertEcDerToPublic(&inPublic,\n\t\t\t\t\t  keyType,\n\t\t\t\t\t  scheme,\n\t\t\t\t\t  nalg,\n\t\t\t\t\t  halg,\n\t\t\t\t\t  derKeyFilename);\n\t\tbreak;\n#endif\t/* TPM_TSS_NOECC */\n\t      default:\n\t\tprintf(\"algorithm %04x not supported\\n\", algPublic);\n\t\trc = TPM_RC_ASYMMETRIC;\n\t    }\n\t}\n\telse {\n\t    printf(\"Failure parsing -ipu, -ipem, -ider\\n\");\n\t    printUsage();\n\t}\n    }\n    /* TPM object */\n    if (object) {\n\tif (rc == 0) {\n\t    name.hashAlg = inPublic.publicArea.nameAlg;\n\t    if (!userWithAuth) {\n\t\tinPublic.publicArea.objectAttributes.val &= ~TPMA_OBJECT_USERWITHAUTH;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    if (tssUtilsVerbose) TSS_TPMT_PUBLIC_Print(&inPublic.publicArea, 2);\n\t}\n\tif (rc == 0) {\n\t    written = 0;\n\t    size = sizeof(marshaled.t.buffer);\n\t    buffer = marshaled.t.buffer;\n\n\t    rc = TSS_TPMT_PUBLIC_Marshalu(&inPublic.publicArea, &written, &buffer, &size);\n\t    marshaled.t.size = written;\n\t}\n    }\n    /* TPM NV Index */\n    else {\n\tif (rc == 0) {\n\t    name.hashAlg = nvPublic.nvPublic.nameAlg;\n\t}\n\tif (rc == 0) {\n\t    if (tssUtilsVerbose) TSS_TPMS_NV_PUBLIC_Print(&nvPublic.nvPublic, 2);\n\t}\n\tif (rc == 0) {\n\t    written = 0;\n\t    size = sizeof(marshaled.t.buffer);\n\t    buffer = marshaled.t.buffer;\n\n\t    rc = TSS_TPMS_NV_PUBLIC_Marshalu(&nvPublic.nvPublic, &written, &buffer, &size);\n\t    marshaled.t.size = written;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Hash_Generate(&name,\n\t\t\t       marshaled.t.size, marshaled.t.buffer,\n\t\t\t       0, NULL);\n    }\n    /* trace the Name */\n    if ((rc == 0) && noSpace) {\n\tprintf(\"%02X%02x\", name.hashAlg >> 8, name.hashAlg & 0xff);\n\tfor (i = 0; i < TSS_GetDigestSize(name.hashAlg); i++) {\n\t    printf(\"%02x\", name.digest.tssmax[i]);\n\t}\n\tprintf(\"\\n\");\n    }\n    /* save the Name */\n    if ((rc == 0) && (nameFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&name,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_HA_Marshalu,\n\t\t\t\t     nameFilename);\n    }\n    if (rc != 0) {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"publicname: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n \n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"publicname\\n\");\n    printf(\"\\n\");\n    printf(\"Calculates the public name of an entity. There are times that a policy creator\\n\"\n\t   \"has TPM, PEM, or DER format information, but does not have access to a TPM.\\n\"\n\t   \"This utility accepts these inputs and outputs the name in the 'no spaces'\\n\"\n\t   \"format suitable for pasting into a policy.  The binary format is used in the\\n\"\n\t   \"regression test\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-invpu\\tTPM2B_NV_PUBLIC public key file name\\n\");\n    printf(\"\\t-ipu\\tTPM2B_PUBLIC public key file name\\n\");\n    printf(\"\\t-ipem\\tPEM format public key file name\\n\");\n    printf(\"\\t-ider\\tDER format plaintext key pair file name]\\n\");\n    printf(\"\\t[-on\\tbinary format Name file name]\\n\");\n    printf(\"\\t[-ns\\tprint Name in hexacsii]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\t-pem and -ider optional arguments\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-rsa\\t(default)]\\n\");\n    printf(\"\\t[-ecc\\t]\\n\");\n    printf(\"\\t[-scheme  for signing key (default RSASSA scheme)]\\n\");\n    printf(\"\\t\\trsassa\\n\");\n    printf(\"\\t\\trsapss\\n\");\n    printf(\"\\t\\tnull\\n\");\n    printf(\"\\t[-nalg\\tname hash algorithm (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-halg\\tscheme hash algorithm (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-uwa\\tuserWithAuth attribute clear (default set)]\\n\");\n    printf(\"\\t[-si\\tsigning (default) RSA]\\n\");\n    printf(\"\\t[-st\\tstorage (default NULL scheme)]\\n\");\n    printf(\"\\t[-den\\tdecryption, (unrestricted, RSA and EC NULL scheme)\\n\");\n    printf(\"\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/quote.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Quote\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Quote_In \t\t\tin;\n    Quote_Out \t\t\tout;\n    TPMI_DH_OBJECT\t\tsignHandle = 0;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_ALG_HASH\t\tpalg = TPM_ALG_SHA256;\n    const char\t\t\t*keyPassword = NULL; \n    TPMI_DH_PCR \t\tpcrHandle = IMPLEMENTATION_PCR;\n    const char\t\t\t*signatureFilename = NULL;\n    const char\t\t\t*attestInfoFilename = NULL;\n    const char\t\t\t*qualifyingDataFilename = NULL;\n    TPM_ALG_ID\t\t\tsigAlg = TPM_ALG_RSA;\n    TPMS_ATTEST \t\ttpmsAttest;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n  \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    in.PCRselect.pcrSelections[0].sizeofSelect = 3;\n    in.PCRselect.pcrSelections[0].pcrSelect[0] = 0;\n    in.PCRselect.pcrSelections[0].pcrSelect[1] = 0;\n    in.PCRselect.pcrSelections[0].pcrSelect[2] = 0;\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hp\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%u\", &pcrHandle);\n\t\tif (pcrHandle > 23) {\n\t\t    printf(\"Bad PCR handle parameter %u for -hp\\n\",pcrHandle);\n\t\t    printUsage();\n\t\t}\n\t\t/* accumulate PCR select bits */\n\t\telse {\n\t\t    in.PCRselect.pcrSelections[0].pcrSelect[pcrHandle / 8] |= 1 << (pcrHandle % 8);\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &signHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-palg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    palg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    palg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    palg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    palg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -palg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-palg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-salg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsa\") == 0) {\n\t\t    sigAlg = TPM_ALG_RSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"ecc\") == 0) {\n\t\t    sigAlg = TPM_ALG_ECDSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"hmac\") == 0) {\n\t\t    sigAlg = TPM_ALG_HMAC;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -salg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-salg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oa\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tattestInfoFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oa option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-qd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tqualifyingDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-qd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (signHandle == 0) {\n\tprintf(\"Missing sign handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (pcrHandle >= IMPLEMENTATION_PCR) {\n\tprintf(\"Missing PCR handle parameter -hp\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform quoting */\n\tin.signHandle = signHandle;\n\t/* data supplied by the caller */\n\tif (sigAlg == TPM_ALG_RSA) {\n\t    /* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\t    in.inScheme.scheme = TPM_ALG_RSASSA;\t\n\t    /* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\t    /* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t    /* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t    in.inScheme.details.rsassa.hashAlg = halg;\n\t}\n\telse if (sigAlg == TPM_ALG_ECDSA) {\n\t    in.inScheme.scheme = TPM_ALG_ECDSA;\t\n\t    in.inScheme.details.ecdsa.hashAlg = halg;\n\t}\n\telse {\t/* HMAC */\n\t    in.inScheme.scheme = TPM_ALG_HMAC;\t\n\t    in.inScheme.details.hmac.hashAlg = halg;\n\t}\n\t/* Table 102 - Definition of TPML_PCR_SELECTION Structure */\n\tin.PCRselect.count = 1;\n\t/* Table 85 - Definition of TPMS_PCR_SELECTION Structure */\n\tin.PCRselect.pcrSelections[0].hash = palg;\n    }\n    if (rc == 0) {\n\tif (qualifyingDataFilename != NULL) {\n\t    rc = TSS_File_Read2B(&in.qualifyingData.b,\n\t\t\t\t sizeof(in.qualifyingData.t.buffer),\n\t\t\t\t qualifyingDataFilename);\n\t}\n\telse {\n\t    in.qualifyingData.t.size = 0;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Quote,\n\t\t\t sessionHandle0, keyPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tuint8_t *tmpBuffer = out.quoted.t.attestationData;\n\tuint32_t tmpSize = out.quoted.t.size;\n\trc = TSS_TPMS_ATTEST_Unmarshalu(&tpmsAttest, &tmpBuffer, &tmpSize);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMS_ATTEST_Print(&tpmsAttest, 0);\n    }\n    if (rc == 0) {\n\tint match;\n\tmatch = TSS_TPM2B_Compare(&in.qualifyingData.b, &tpmsAttest.extraData.b);\n\tif (!match) {\n\t    printf(\"quote: failed, extraData != qualifyingData\\n\");\n\t    rc = EXIT_FAILURE;\n\t}\n    }\n    if ((rc == 0) && (signatureFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.signature,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_SIGNATURE_Marshalu,\n\t\t\t\t     signatureFilename);\n    }\n    if ((rc == 0) && (attestInfoFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.quoted.t.attestationData,\n\t\t\t\t      out.quoted.t.size,\n\t\t\t\t      attestInfoFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_TPMT_SIGNATURE_Print(&out.signature, 0);\n\tif (tssUtilsVerbose) printf(\"quote: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"quote: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"quote\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Quote\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hp\\tpcr handle (may be specified more than once)\\n\");\n    printf(\"\\t-hk\\tquoting key handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for quoting key (default empty)]\\n\");\n    printf(\"\\t[-halg\\tfor signing (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-palg\\tfor PCR bank selection (sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-salg\\tsignature algorithm (rsa, ecc, hmac) (default rsa)]\\n\");\n    printf(\"\\t[-qd\\tqualifying data file name]\\n\");\n    printf(\"\\t[-os\\tquote signature file name (default do not save)]\\n\");\n    printf(\"\\t[-oa\\tattestation output file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/readclock.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   ReadClock\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ReadClock_Out \t\tout;\n    const char\t\t\t*timeFilename = NULL;\n    const char\t\t\t*clockFilename = NULL;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-otime\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\ttimeFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-otime option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oclock\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tclockFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oclock option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t NULL,\n\t\t\t NULL,\n\t\t\t TPM_CC_ReadClock,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* write the fields in binary host byte order */\n    if ((rc == 0) && (timeFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile((uint8_t *)&out.currentTime.time,\n\t\t\t\t      sizeof(((TPMS_TIME_INFO *)NULL)->time),\n\t\t\t\t      timeFilename) ;\n    }\n    if ((rc == 0) && (clockFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile((uint8_t *)&out.currentTime.clockInfo.clock,\n\t\t\t\t      sizeof(((TPMS_TIME_INFO *)NULL)->clockInfo.clock),\n\t\t\t\t      clockFilename);\n    }\n    if (rc == 0) {\n\tTSS_TPMS_TIME_INFO_Print(&out.currentTime, 0);\n\tif (tssUtilsVerbose) printf(\"readclock: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"readclock: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"readclock\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ReadClock\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-otime    time file name (default do not save)]\\n\");\n    printf(\"\\t[-oclock   clock file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/readpublic.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   ReadPublic \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\n#include \"cryptoutils.h\"\n\nstatic void printReadPublic(ReadPublic_Out *out);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    ReadPublic_In \t\tin;\n    ReadPublic_Out \t\tout;\n    TPMI_DH_PCR \t\tobjectHandle = TPM_RH_NULL;\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*pemFilename = NULL;\n    int\t\t\t\tnoSpace = FALSE;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ho\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &objectHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ho\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opem\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opem option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ns\") == 0) {\n\t    noSpace = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (objectHandle == TPM_RH_NULL) {\n\tprintf(\"Missing or bad object handle parameter -ho\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.objectHandle = objectHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ReadPublic,\n\t\t\t sessionHandle0, NULL, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* save the public key */\n    if ((rc == 0) && (publicKeyFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.outPublic,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PUBLIC_Marshalu,\n\t\t\t\t     publicKeyFilename);\n    }\n    /* save the optional PEM public key */\n    if ((rc == 0) && (pemFilename != NULL)) {\n\trc = convertPublicToPEM(&out.outPublic,\n\t\t\t\tpemFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printReadPublic(&out);\n\tif (noSpace) {\n\t    unsigned int b;\n\t    for (b = 0 ; b < out.name.t.size ; b++) {\n\t\tprintf(\"%02x\", out.name.t.name[b]);\n\t    }\n\t    printf(\"\\n\");\n\t}\n\tif (tssUtilsVerbose) printf(\"readpublic: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"readpublic: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printReadPublic(ReadPublic_Out *out)\n{\n    TSS_TPMT_PUBLIC_Print(&out->outPublic.publicArea, 0);\n    TSS_PrintAll(\"name\",\n\t\t out->name.t.name,\n\t\t out->name.t.size);\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"readpublic\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ReadPublic\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ho\\tobject handle\\n\");\n    printf(\"\\t[-opu\\tpublic key file name (default do not save)]\\n\");\n    printf(\"\\t[-opem\\tpublic key PEM format file name (default do not save)]\\n\");\n    printf(\"\\t[-ns\\tadditionally print Name in hex ascii on one line]\\n\");\n    printf(\"\\t\\tUseful to paste into policy\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\t80\\taudit\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/returncode.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\tReturn Code Hex to String     \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: returncode.c 1290 2018-08-01 14:45:24Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2017.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nint main(int argc, char *argv[])\n{\n    TPM_RC rc;\n    const char *msg;\n    const char *submsg;\n    const char *num;\n\n    if (argc < 2) {\n\tprintf(\"returncode: needs argument\\n\");\n\treturn EXIT_FAILURE;\n    }\n    if (strcmp(argv[1], \"-h\") == 0) {\n\tprintUsage();\n    }\t    \n\n    rc = strtoul(argv[1], NULL, 16);\n    TSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n    printf(\"%s%s%s\\n\", msg, submsg, num);\n    return 0;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"Usage: returncode hex-number\\n\");\n    printf(\"\\n\");\n    printf(\"Returns the TPM_RC name and text for the return code\\n\");\n    printf(\"\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/rewrap.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Rewrap\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Rewrap_In \t\t\tin;\n    Rewrap_Out \t\t\tout;\n    TPMI_DH_OBJECT\t\toldParent = 0;\n    TPMI_DH_OBJECT\t\tnewParent = 0;\n    const char\t\t\t*oldParentPassword = NULL; \n    const char\t\t\t*inDuplicateFilename = NULL;\n    const char\t\t\t*nameFilename = NULL;\t\t\t\n    const char\t\t\t*inSymSeedFilename = NULL;\n    const char\t\t\t*outDuplicateFilename = NULL;\n    const char\t\t\t*outSymSeedFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ho\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &oldParent);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ho\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdo\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toldParentPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdo option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hn\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &newParent);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hp\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-id\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinDuplicateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-id option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-in\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnameFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-in option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-iss\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinSymSeedFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-iss option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-od\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutDuplicateFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-od option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oss\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutSymSeedFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oss option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (oldParent == 0) {\n\tprintf(\"Missing or bad object old parent handle -ho\\n\");\n\tprintUsage();\n    }\n    if (newParent == 0) {\n\tprintf(\"Missing or bad object new parent handle -hn\\n\");\n\tprintUsage();\n    }\n    if (inDuplicateFilename == NULL) {\n\tprintf(\"Missing duplicate private area parameter -id\\n\");\n\tprintUsage();\n    }\n    if (nameFilename == NULL) {\n\tprintf(\"Missing name parameter -in\\n\");\n\tprintUsage();\n    }\n    if (inSymSeedFilename == NULL) {\n\tprintf(\"Missing input symmetric seed parameter -iss\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.oldParent = oldParent;\n\tin.newParent = newParent;\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.inDuplicate.b,\n\t\t\t     sizeof(in.inDuplicate.t.buffer),\n\t\t\t     inDuplicateFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.name.b,\n\t\t\t     sizeof(in.name.t.name),\n\t\t\t     nameFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_Read2B(&in.inSymSeed.b,\n\t\t\t     sizeof(in.inSymSeed.t.secret),\n\t\t\t     inSymSeedFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Rewrap,\n\t\t\t sessionHandle0, oldParentPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (outDuplicateFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.outDuplicate.t.buffer,\n\t\t\t\t      out.outDuplicate.t.size,\n\t\t\t\t      outDuplicateFilename);\n    }\n    if ((rc == 0) && (outSymSeedFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.outSymSeed.t.secret,\n\t\t\t\t      out.outSymSeed.t.size,\n\t\t\t\t      outSymSeedFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"rewrap: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"rewrap: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"rewrap\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Rewrap\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ho\\thandle of object old parent\\n\");\n    printf(\"\\t[-pwdo\\tpassword for old parent (default empty)]\\n\");\n    printf(\"\\t-hn\\thandle of object new parent\\n\");\n    printf(\"\\t-id\\tduplicate private area file name\\n\");\n    printf(\"\\t-in\\tobject name file name\\n\");\n    printf(\"\\t-iss\\tinput symmetric seed file name\");\n    printf(\"\\n\");\n    printf(\"\\t[-od\\trewrap private area file name (default do not save)]\\n\");\n    printf(\"\\t[-oss\\tsymmetric seed file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/rsadecrypt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   RSA_Decrypt\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsscryptoh.h>\n\nstatic void printRsaDecrypt(RSA_Decrypt_Out *out);\nstatic TPM_RC getKeySize(TSS_CONTEXT \t\t*tssContext,\n\t\t\t TPMI_RSA_KEY_BITS\t*keyBits,\n\t\t\t TPMI_DH_PCR\t\tobjectHandle);\nstatic TPM_RC padData(uint8_t \t\t**buffer,\n\t\t      size_t\t\t*padLength,\n\t\t      TPMI_ALG_HASH \thalg,\n\t\t      TPMI_RSA_KEY_BITS\tkeyBits);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    RSA_Decrypt_In \t\tin;\n    RSA_Decrypt_Out \t\tout;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    TPMI_RSA_KEY_BITS\t\tkeyBits;\n    const char\t\t\t*encryptFilename = NULL;\n    const char\t\t\t*decryptFilename = NULL;\n    const char\t\t\t*keyPassword = NULL;\n    const char\t\t\t*keyPasswordFilename = NULL;\n    uint8_t\t\t\t*keyPasswordBuffer = NULL;\n    size_t \t\t\tkeyPasswordBufferLength = 0;\n    const char\t\t\t*keyPasswordPtr = NULL;\n    TPMI_ALG_HASH \t\thalg = TPM_ALG_NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n \n    uint16_t\t\t\twritten;\n    size_t\t\t\tlength;\t\t\t/* input data */\n    uint8_t\t\t\t*buffer = NULL;\t\t/* for the free */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPasswordFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oid\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -oid\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-oid option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ie\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tencryptFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ie option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-od\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdecryptFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-od option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (encryptFilename == NULL) {\n\tprintf(\"Missing encrypted message -ie\\n\");\n\tprintUsage();\n    }\n    if ((keyPassword != NULL) && (keyPasswordFilename != NULL)) {\n\tprintf(\"Only one of -pwdk and -ipwdk can be specified\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* use passsword from command line */\n\tif (keyPassword != NULL) {\n\t    keyPasswordPtr = keyPassword;\n\t}\n\t/* use password from file */\n\telse if (keyPasswordFilename != NULL) {\n\t    rc = TSS_File_ReadBinaryFile(&keyPasswordBuffer,     /* freed @2 */\n\t\t\t\t\t &keyPasswordBufferLength,\n\t\t\t\t\t keyPasswordFilename);\n\t    if ((keyPasswordBufferLength == 0) ||\n\t\t(keyPasswordBuffer[keyPasswordBufferLength -1] != '\\0')) {\n\t\tprintf(\"-ipwdk file must be nul terminated\\n\");\n\t\tprintUsage();\n\t    }\n\t    keyPasswordPtr = (const char *)keyPasswordBuffer;\n\t}\n\t/* empty password */\n\telse {\n\t    keyPasswordPtr = NULL;\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* get the public modulus size for checks and padding */\n    if (rc == 0) {\n\trc = getKeySize(tssContext, &keyBits, keyHandle);\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     encryptFilename);\n    }\n    if (rc == 0) {\n\tif (length > (keyBits / 8U)) {\n\t    printf(\"Input data too long %u\\n\", (unsigned int)length);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* if an OID was requested, treat the encryptFilename as a hash to be signed */\n    if ((rc == 0) && (halg != TPM_ALG_NULL)) {\n\trc = padData(&buffer,\t\t/* realloced to fit */\n\t\t     &length,\t\t/* resized for OID and pad */\n\t\t     halg,\t\t/* gigest algorithm for size and OID */\n\t\t     keyBits);\t\t/* RSA modulus length in bits */\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform rsa decrypt */\n\tin.keyHandle = keyHandle;\n\n\t/* Table 158 - Definition of {RSA} TPM2B_PUBLIC_KEY_RSA Structure */\n\t{\n\t    in.cipherText.t.size = (uint16_t)length;\t/* cast safe, range tested above */\n\t    memcpy(in.cipherText.t.buffer, buffer, length);\n\t}\n\t/* padding scheme */\n\t{\n\t    /* Table 157 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */\n\t    in.inScheme.scheme = TPM_ALG_NULL;\n\t}\n\t/* label */\n\t{\n\t    /* Table 73 - Definition of TPM2B_DATA Structure */\n\t    in.label.t.size = 0;\n\t}\n    }\n    free(buffer);\t\t/* @1 */\n    buffer = NULL;\n\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_RSA_Decrypt,\n\t\t\t sessionHandle0, keyPasswordPtr, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (decryptFilename != NULL)) {\n\trc = TSS_Structure_Marshal(&buffer,\t/* freed @1 */\n\t\t\t\t   &written,\n\t\t\t\t   &out.message,\n\t\t\t\t   (MarshalFunction_t)TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu);\n    }\n    if ((rc == 0) && (decryptFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(buffer + sizeof(uint16_t),\n\t\t\t\t      written - sizeof(uint16_t),\n\t\t\t\t      decryptFilename); \n    }    \n    if (rc == 0) {\n\tif (tssUtilsVerbose) printRsaDecrypt(&out);\n\tif (tssUtilsVerbose) printf(\"rsadecrypt: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"rsadecrypt: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(buffer);\t\t/* @1 */\n    free(keyPasswordBuffer);\t/* @2 */\n    return rc;\n}\n\n/* padData() is used then the private key operation is a signing operation over a hash.  It takes a\n   'buffer' of original 'length'.  The original length should match the hash algorithm digest size.\n\n   buffer is realloc'ed to the key size, than then padded with the OID for the hash algorithm and\n   the PKCS1 padding.\n*/\n\nstatic TPM_RC padData(uint8_t \t\t\t**buffer,\n\t\t      size_t\t\t\t*padLength,\n\t\t      TPMI_ALG_HASH \t\thalg,\n\t\t      TPMI_RSA_KEY_BITS\t\tkeyBits)\n{\n    TPM_RC\t\trc = 0;\n    uint16_t \t\tdigestSize;\n    const uint8_t\t*oid;\n    uint16_t\t\toidSize;\n    const uint8_t\tsha1Oid[] = {SHA1_DER};\n    const uint8_t\tsha256Oid[] = {SHA256_DER};\n    const uint8_t\tsha384Oid[] = {SHA384_DER};\n    const uint8_t\tsha512Oid[] = {SHA512_DER};\n    \n    /* check that the original buffer length matches the hash algorithm */\n    if (rc == 0) {\n\tdigestSize = TSS_GetDigestSize(halg);\n\tif (digestSize == 0) {\n\t    printf(\"padData: Unsupported hash algorithm %04x\\n\", halg);\n\t    rc = TPM_RC_HASH;\n\t}\n    }\n    if (rc == 0) {\n\tif (digestSize != *padLength) {\n\t    printf(\"paddata: hash algorithm length %u not equal data length %lu\\n\",\n\t\t   digestSize, (unsigned long)*padLength);\n\t    rc = TPM_RC_VALUE;\n\t}\n    }\n    /* realloc the buffer to the key size in bytes */\n    if (rc == 0) {\n\t*padLength = keyBits / 8;\n\trc = TSS_Realloc(buffer, (uint32_t)*padLength);\n    }\n    /* determine the OID */\n    if (rc == 0) {\n\tswitch (halg) {\n\t  case TPM_ALG_SHA1:\n\t    oid = sha1Oid;\n\t    oidSize = SHA1_DER_SIZE;\n\t    break;\n\t  case TPM_ALG_SHA256:\n\t    oid = sha256Oid;\n\t    oidSize = SHA256_DER_SIZE;\n\t    break;\n\t  case TPM_ALG_SHA384:\n\t    oid = sha384Oid;\n\t    oidSize = SHA384_DER_SIZE;\n\t    break;\n\t  case TPM_ALG_SHA512:\n\t    oid = sha512Oid;\n\t    oidSize = SHA512_DER_SIZE;\n\t    break;\n\t  default:\n\t    printf(\"padData: Unsupported hash algorithm %04x\\n\", halg);\n\t    rc = TPM_RC_HASH;\n\t}\n    }\n    if (rc == 0) {\n\t/* move the hash to the end */\n\tmemmove(*buffer + *padLength - digestSize, *buffer, digestSize);\n\t/* prepend the OID */\n\tmemcpy(*buffer + *padLength - digestSize - oidSize, oid, oidSize);\n\t/* prepend the PKCS1 pad */\n\t(*buffer)[0] = 0x00;\n\t(*buffer)[1] = 0x01;\n\tmemset(&(*buffer)[2], 0xff, *padLength - 3 - oidSize - digestSize);\n\t(*buffer)[*padLength - oidSize - digestSize - 1] = 0x00;\n\tif (tssUtilsVerbose) TSS_PrintAll(\"padData: padded data\", *buffer, (uint32_t)*padLength);\n    }\n    return rc;\n}\n\n/* getKeySize() gets the key size in bits */\n\nstatic TPM_RC getKeySize(TSS_CONTEXT \t\t*tssContext,\n\t\t\t TPMI_RSA_KEY_BITS\t*keyBits,\n\t\t\t TPMI_DH_PCR\t\tobjectHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    ReadPublic_In \t\tin;\n    ReadPublic_Out \t\tout;\n\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\tin.objectHandle = objectHandle;\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ReadPublic,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    if (rc == 0) {\n\t*keyBits = out.outPublic.publicArea.parameters.rsaDetail.keyBits;\n\tif (tssUtilsVerbose) printf(\"getKeySize: size %u\\n\", *keyBits);\n    }\n    return rc;\n}\n\nstatic void printRsaDecrypt(RSA_Decrypt_Out *out)\n{\n    TSS_PrintAll(\"outData\", out->message.t.buffer, out->message.t.size);\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"rsadecrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_RSA_Decrypt\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)[\\n\");\n    printf(\"\\t[-ipwdk\\tpassword file for key, nul terminated (default empty)]\\n\");\n    printf(\"\\t-ie\\tencrypt file name\\n\");\n    printf(\"\\t-od\\tdecrypt file name (default do not save)\\n\");\n    printf(\"\\t[-oid\\t(sha1, sha256, sha384 sha512)]\\n\");\n    printf(\"\\t\\toptionally add OID and PKCS1 padding to the\\n\");\n    printf(\"\\t\\tencrypt data (demo of signing with arbitrary OID)\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/rsaencrypt.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   RSA_Encrypt\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic TPM_RC getKeySize(TSS_CONTEXT \t\t*tssContext,\n\t\t\t TPMI_RSA_KEY_BITS\t*keyBits,\n\t\t\t TPMI_DH_PCR\t\tobjectHandle);\nstatic void printRsaEncrypt(RSA_Encrypt_Out *out);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    RSA_Encrypt_In \t\tin;\n    RSA_Encrypt_Out \t\tout;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    TPMI_RSA_KEY_BITS\t\tkeyBits;\n    const char\t\t\t*decryptFilename = NULL;\n    const char\t\t\t*encryptFilename = NULL;\n\n    uint16_t\t\t\twritten = 0;\n    size_t \t\t\tlength = 0;\n    uint8_t\t\t\t*buffer = NULL;\t/* for the free */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-id\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tdecryptFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-id option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-oe\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tencryptFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-oe option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (decryptFilename == NULL) {\n\tprintf(\"Missing decrypted file -id\\n\");\n\tprintUsage();\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* get the public modulus size for checks and padding */\n    if (rc == 0) {\n\trc = getKeySize(tssContext, &keyBits, keyHandle);\n    }\n     if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     decryptFilename);\n    }\n    if (rc == 0) {\n\tif (length > (keyBits / 8U)) {\n\t    printf(\"Input data too long %u\\n\", (unsigned int)length);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform rsaencrypting */\n\tin.keyHandle = keyHandle;\n\n\t/* Table 158 - Definition of {RSA} TPM2B_PUBLIC_KEY_RSA Structure */\n\t{\n\t    in.message.t.size = (uint16_t)length;\t/* cast safe, range tested above */\n\t    memcpy(in.message.t.buffer, buffer, length);\n\t}\n\t/* padding scheme */\n\t{\n\t    /* Table 157 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */\n\t    in.inScheme.scheme = TPM_ALG_NULL;\n\t}\n\t/* label */\n\t{\n\t    /* NOTE: label requires the last byte to be zero.  I.e., when implemented, do not set\n\t       the in.label.t.size to strlen() */\n\t    /* Table 73 - Definition of TPM2B_DATA Structure */\n\t    in.label.t.size = 0;\n\t}\n    }\n    free (buffer);\t/* @1 */\n    buffer = NULL;\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_RSA_Encrypt,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (encryptFilename != NULL)) {\n\trc = TSS_Structure_Marshal(&buffer,\t/* freed @1 */\n\t\t\t\t   &written,\n\t\t\t\t   &out.outData,\n\t\t\t\t   (MarshalFunction_t)TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu);\n    }\n    if ((rc == 0) && (encryptFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(buffer + sizeof(uint16_t),\n\t\t\t\t      written - sizeof(uint16_t),\n\t\t\t\t      encryptFilename); \n    }    \n    if (rc == 0) {\n\tif (tssUtilsVerbose) printRsaEncrypt(&out);\n\tif (tssUtilsVerbose) printf(\"rsaencrypt: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"rsaencrypt: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n/* getKeySize() gets the key size in bits */\n\nstatic TPM_RC getKeySize(TSS_CONTEXT \t\t*tssContext,\n\t\t\t TPMI_RSA_KEY_BITS\t*keyBits,\n\t\t\t TPMI_DH_PCR\t\tobjectHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    ReadPublic_In \t\tin;\n    ReadPublic_Out \t\tout;\n\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\tin.objectHandle = objectHandle;\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ReadPublic,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    if (rc == 0) {\n\t*keyBits = out.outPublic.publicArea.parameters.rsaDetail.keyBits;\n\tif (tssUtilsVerbose) printf(\"getKeySize: size %u\\n\", *keyBits);\n    }\n    return rc;\n}\n\nstatic void printRsaEncrypt(RSA_Encrypt_Out *out)\n{\n    TSS_PrintAll(\"outData\", out->outData.t.buffer, out->outData.t.size);\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"rsaencrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_RSA_Encrypt\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t-id\\tdecrypt file name\\n\");\n    printf(\"\\t[-oe\\tencrypt file name (default do not save)]\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/sequencecomplete.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    SequenceComplete\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    SequenceComplete_In \tin;\n    SequenceComplete_Out\tout;\n    char \t\t\thierarchyChar = 'n';\n    TPMI_RH_HIERARCHY\t\thierarchy = TPM_RH_NULL;\n    TPMI_DH_OBJECT\t\tsequenceHandle = 0;\n    const char\t\t\t*inFilename = NULL;\n    const char\t\t\t*outFilename = NULL;\n    const char\t\t\t*ticketFilename = NULL;\n    const char\t\t\t*sequencePassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    size_t \t\t\tlength = 0;\n    uint8_t\t\t\t*buffer = NULL;\t/* for the free */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thierarchyChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse \tif (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sequenceHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hs\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwds\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsequencePassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwds option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-of\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (hierarchyChar == 'e') {\n\t    hierarchy = TPM_RH_ENDORSEMENT;\n\t}\n\telse if (hierarchyChar == 'o') {\n\t    hierarchy = TPM_RH_OWNER;\n\t}\n\telse if (hierarchyChar == 'p') {\n\t    hierarchy = TPM_RH_PLATFORM;\n\t}\n\telse if (hierarchyChar == 'n') {\n\t    hierarchy = TPM_RH_NULL;\n\t}\n\telse {\n\t    printf(\"Bad parameter %c for -hi\\n\", hierarchyChar);\n\t    printUsage();\n\t}\n \tin.hierarchy = hierarchy;\n    }\n    if (sequenceHandle == 0) {\n\tprintf(\"Missing sequence handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if ((rc == 0) && (inFilename != NULL)) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     inFilename);\n    }\n    if (rc == 0) {\n\tif (length >  sizeof(in.buffer.t.buffer)) {\n\t    printf(\"Input data too long %u\\n\", (unsigned int)length);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform update */\n\tin.sequenceHandle = sequenceHandle;\n\n\t/* data for update */\n\tin.buffer.t.size = (uint16_t)length;\n\tif (length > 0) {\n\t    memcpy(in.buffer.t.buffer, buffer, length);\n\t}\n    }\n    free(buffer);\t/* @1 */\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_SequenceComplete,\n\t\t\t sessionHandle0, sequencePassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (outFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.result.t.buffer,\n\t\t\t\t      out.result.t.size,\n\t\t\t\t      outFilename); \n    }    \n    if ((rc == 0) && (ticketFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.validation,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_TK_HASHCHECK_Marshalu,\n\t\t\t\t     ticketFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_PrintAll(\"Result\", out.result.t.buffer, out.result.t.size);\n\tif (tssUtilsVerbose) printf(\"sequencecomplete: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"sequencecomplete: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"sequencecomplete\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_SequenceComplete\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hs\\tsequence handle\\n\");\n    printf(\"\\t[-hi\\thierarchy (default null)]\\n\");\n    printf(\"\\t[-pwds\\tpassword for sequence (default empty)]\\n\");\n    printf(\"\\t[-if\\tinput file to be added (default no data)]\\n\");\n    printf(\"\\t[-of\\tresult file name]\\n\");\n    printf(\"\\t[-tk\\tticket file name]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/sequenceupdate.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    SequenceUpdate\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    SequenceUpdate_In \t\tin;\n    TPMI_DH_OBJECT\t\tsequenceHandle = 0;\n    const char\t\t\t*inFilename = NULL;\n    const char\t\t\t*sequencePassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    size_t \t\t\tlength = 0;\n    uint8_t\t\t\t*buffer = NULL;\t/* for the free */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sequenceHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwds\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsequencePassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwds option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (sequenceHandle == 0) {\n\tprintf(\"Missing sequence handle parameter -hs\\n\");\n\tprintUsage();\n    }\n    if (inFilename == NULL) {\n\tprintf(\"Missing input file -if\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     inFilename);\n    }\n    if (rc == 0) {\n\tif (length > sizeof(in.buffer.t.buffer)) {\n\t    printf(\"Input data too long %u\\n\", (unsigned int)length);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform update */\n\tin.sequenceHandle = sequenceHandle;\n\n\t/* data for update */\n\tin.buffer.t.size = (uint16_t)length;\n\tmemcpy(in.buffer.t.buffer, buffer, length);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_SequenceUpdate,\n\t\t\t sessionHandle0, sequencePassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    free(buffer);\t/* @1 */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"sequenceupdate: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"sequenceupdate: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"sequenceupdate\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_SequenceUpdate\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hs\\tsequence handle\\n\");\n    printf(\"\\t[-pwds\\tpassword for sequence (default empty)]\\n\");\n    printf(\"\\t-if\\tinput file to be HMACed\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t\\t01 continue\\n\");\n    printf(\"\\t\\t20 command decrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/setcommandcodeauditstatus.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    SetCommandCodeAuditStatus\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2019.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    SetCommandCodeAuditStatus_In \tin;\n    TPM_CC\t\t\tcommandCode;\n    char \t\t\tauthHandleChar = 'p';\n    const char\t\t\t*authPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    in.auditAlg = TPM_ALG_NULL;\t/* default, don't change */\n    in.setList.count = 0;\n    in.clearList.count = 0;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthHandleChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-set\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &commandCode);\n\t\tin.setList.commandCodes[in.setList.count] = commandCode;\n\t\tin.setList.count++;\n\t    }\n\t    else {\n\t\tprintf(\"-set option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-clr\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &commandCode);\n\t\tin.clearList.commandCodes[in.clearList.count] = commandCode;\n\t\tin.clearList.count++;\n\t    }\n\t    else {\n\t\tprintf(\"-clr option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    in.auditAlg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    in.auditAlg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    in.auditAlg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    in.auditAlg = TPM_ALG_SHA512;\n\t\t}\n\t\telse if (strcmp(argv[i],\"null\") == 0) {\n\t\t    in.auditAlg = TPM_ALG_NULL;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (authHandleChar == 'o') {\n\t    in.auth = TPM_RH_OWNER;\n\t}\n\telse if (authHandleChar == 'p') {\n\t    in.auth = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_SetCommandCodeAuditStatus,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"setcommandcodeauditstatus: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"setcommandcodeauditstatus: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"setprimarypolicy\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_SetCommandCodeAuditStatus\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hi\\tauthhandle hierarchy (o, p) (default platform)]\\n\");\n    printf(\"\\t[-pwda\\tauthorization password (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512, null) (default null)]\\n\");\n    printf(\"\\t[-set\\tcommand code to set (may be specified more than once (default none)]\\n\");\n    printf(\"\\t[-clr\\tcommand code to clear (may be specified more than once (default none)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/setprimarypolicy.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    SetPrimaryPolicy \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2018\n   9.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    SetPrimaryPolicy_In \tin;\n    char \t\t\tauthHandleChar = 'p';\n    const char\t\t\t*authPassword = NULL; \n    const char\t\t\t*policyFilename = NULL;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    in.hashAlg = TPM_ALG_NULL;\t/* default */\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthHandleChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hi\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwda\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tauthPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwda option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pol\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpolicyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pol option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    in.hashAlg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    in.hashAlg = TPM_ALG_SHA1;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (policyFilename != NULL) {\n\tif (in.hashAlg == TPM_ALG_NULL) {\n\t    printf(\"-pol requires -halg\\n\");\n\t    printUsage();\n\t}\n    }\n    else {\n\tif (in.hashAlg != TPM_ALG_NULL) {\n\t    printf(\"-halg requires -pol\\n\");\n\t    printUsage();\n\t}\n    }\n    /* Table 50 - TPMI_RH_HIERARCHY primaryHandle */\n    if (rc == 0) {\n\tif (authHandleChar == 'l') {\n\t    in.authHandle = TPM_RH_LOCKOUT;\n\t}\n\telse if (authHandleChar == 'e') {\n\t    in.authHandle = TPM_RH_ENDORSEMENT;\n\t}\n\telse if (authHandleChar == 'o') {\n\t    in.authHandle = TPM_RH_OWNER;\n\t}\n\telse if (authHandleChar == 'p') {\n\t    in.authHandle = TPM_RH_PLATFORM;\n\t}\n\telse {\n\t    printf(\"Missing or illegal -hi\\n\");\n\t    printUsage();\n\t}\n    }\n    /* authorization policy */\n    if (policyFilename != NULL) {\n\trc = TSS_File_Read2B(&in.authPolicy.b,\n\t\t\t     sizeof(in.authPolicy.t.buffer),\n\t\t\t     policyFilename);\n    }\n    else {\n\tin.authPolicy.t.size = 0;\t/* default empty policy */\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_SetPrimaryPolicy,\n\t\t\t sessionHandle0, authPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"setprimarypolicy: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"setprimarypolicy: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"setprimarypolicy\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_SetPrimaryPolicy\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-hi\\tauthhandle hierarchy (l, e, o, p) (default platform)]\\n\");\n    printf(\"\\t[-pwda\\tauthorization password (default empty)]\\n\");\n    printf(\"\\t[-pol\\tpolicy file (default empty policy)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256) (default null)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/shutdown.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Shutdown\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\nTPM_RC shutdownCommand(TPM_SU shutdownType);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC \t\t\trc = 0;\n    int\t\t\t\ti;\t\t\t/* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Shutdown_In \t\tin;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    in.shutdownType = TPM_SU_CLEAR;\t\t\t/* default */\n\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-c\") == 0) {\n\t    in.shutdownType = TPM_SU_CLEAR;\n\t}\n\telse if (strcmp(argv[i],\"-s\") == 0) {\n\t    in.shutdownType = TPM_SU_STATE;\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Shutdown,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"shutdown: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"shutdown: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"shutdown\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Shutdown\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-c\\tshutdown clear (default)]\\n\");\n    printf(\"\\t[-s\\tshutdown state]\\n\");\n    exit(1);\t\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/sign.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Sign\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n/* Windows 10 crypto API clashes with openssl */\n#ifdef TPM_WINDOWS\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Sign_In \t\t\tin;\n    Sign_Out \t\t\tout;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_ALG_SIG_SCHEME\t\tscheme = TPM_ALG_RSASSA;\n    const char\t\t\t*messageFilename = NULL;\n    const char                  *counterFilename = NULL;\n    const char\t\t\t*ticketFilename = NULL;\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*signatureFilename = NULL;\n    const char\t\t\t*keyPassword = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n \n    unsigned char \t\t*data = NULL;\t/* message */\n    size_t \t\t\tlength;\n    uint32_t           \t\tsizeInBytes;\t/* hash algorithm mapped to size */\n    TPMT_HA \t\t\tdigest;\t\t/* digest of the message */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\",&keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tkeyPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-salg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsa\") == 0) {\n\t\t    scheme = TPM_ALG_RSASSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"ecc\") == 0) {\n\t\t    scheme = TPM_ALG_ECDSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"hmac\") == 0) {\n\t\t    scheme = TPM_ALG_HMAC;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -salg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-salg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-scheme\") == 0) {\n            i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"rsassa\") == 0) {\n\t\t    scheme = TPM_ALG_RSASSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"rsapss\") == 0) {\n\t\t    scheme = TPM_ALG_RSAPSS;\n\t\t}\n\t\telse if (strcmp(argv[i],\"ecdsa\") == 0) {\n\t\t    scheme = TPM_ALG_ECDSA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"ecdaa\") == 0) {\n\t\t    scheme = TPM_ALG_ECDAA;\n\t\t}\n\t\telse if (strcmp(argv[i],\"hmac\") == 0) {\n\t\t    scheme = TPM_ALG_HMAC;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -scheme\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n        }\n\telse if (strcmp(argv[i],\"-cf\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t        counterFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-cf option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tmessageFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-os\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-os option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (messageFilename == NULL) {\n\tprintf(\"Missing message file name -if\\n\");\n\tprintUsage();\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if ((scheme == TPM_ALG_ECDAA) && (counterFilename == NULL)) {\n\tprintf(\"Missing counter file name -cf for ECDAA algorithm\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&data,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     messageFilename);\n    }\n    /* hash the file */\n    if (rc == 0) {\n\tdigest.hashAlg = halg;\n\tsizeInBytes = TSS_GetDigestSize(digest.hashAlg);\n\trc = TSS_Hash_Generate(&digest,\n\t\t\t       length, data,\n\t\t\t       0, NULL);\n    }\n    if (rc == 0) {\n\t/* Handle of key that will perform signing */\n\tin.keyHandle = keyHandle;\n\n\t/* digest to be signed */\n\tin.digest.t.size = sizeInBytes;\n\tmemcpy(&in.digest.t.buffer, (uint8_t *)&digest.digest, sizeInBytes);\n\t/* Table 145 - Definition of TPMT_SIG_SCHEME inScheme */\n\tin.inScheme.scheme = scheme;\n\t/* Table 144 - Definition of TPMU_SIG_SCHEME details > */\n\t/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\t/* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\t/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type  */\n\tif ((scheme == TPM_ALG_RSASSA) ||\n\t    (scheme == TPM_ALG_RSAPSS)) {\n\t    in.inScheme.details.rsassa.hashAlg = halg;\n\t}\n\telse if (scheme == TPM_ALG_ECDAA) {\n\t    in.inScheme.details.ecdaa.hashAlg = halg;\n\t    rc = TSS_File_ReadStructure(&in.inScheme.details.ecdaa.count, \n\t\t\t\t\t(UnmarshalFunction_t)TSS_UINT16_Unmarshalu,\n\t\t\t\t\tcounterFilename);\n\t}\n\telse {\t/* scheme TPM_ALG_ECDSA */\n\t    in.inScheme.details.ecdsa.hashAlg = halg;\n\t}\n    }\n    if (rc == 0) {\n\tif (ticketFilename == NULL) {\n\t    /* proof that digest was created by the TPM (NULL ticket) */\n\t    /* Table 91 - Definition of TPMT_TK_HASHCHECK Structure */\n\t    in.validation.tag = TPM_ST_HASHCHECK;\n\t    in.validation.hierarchy = TPM_RH_NULL;\n\t    in.validation.digest.t.size = 0;\n\t}\n\telse {\n\t    rc = TSS_File_ReadStructure(&in.validation,\n\t\t\t\t\t(UnmarshalFunction_t)TSS_TPMT_TK_HASHCHECK_Unmarshalu,\n\t\t\t\t\tticketFilename);\n\t}\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Sign,\n\t\t\t sessionHandle0, keyPassword, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (signatureFilename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.signature,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMT_SIGNATURE_Marshalu,\n\t\t\t\t     signatureFilename);\n    }\n    /* if a public key was specified, use openssl to verify the signature using an openssl RSA\n       format key token */\n    if (publicKeyFilename != NULL) {\n\tTPM2B_PUBLIC \tpublic;\n\tvoid         \t*rsaPubKey = NULL;\n\tif (rc == 0) {\n\t    rc = TSS_File_ReadStructureFlag(&public,\n\t\t\t\t\t    (UnmarshalFunctionFlag_t)TSS_TPM2B_PUBLIC_Unmarshalu,\n\t\t\t\t\t    TRUE,\t\t\t/* NULL permitted */\n\t\t\t\t\t    publicKeyFilename);\n\t}\n\t/* construct the OpenSSL RSA public key token */\n\tif (rc == 0) {\n\t    unsigned char earr[3] = {0x01, 0x00, 0x01};\n\t    /* For Openssl < 3, rsaKey is an RSA structure. */\n\t    /* For Openssl 3, rsaKey is an EVP_PKEY. */\n\t    rc = TSS_RSAGeneratePublicTokenI\n\t\t (&rsaPubKey,\t\t\t\t\t/* freed @2 */\n\t\t  public.publicArea.unique.rsa.t.buffer, \t/* public modulus */\n\t\t  public.publicArea.unique.rsa.t.size,\n\t\t  earr,      \t\t\t\t\t/* public exponent */\n\t\t  sizeof(earr));\n\t}\n\t/*\n\t  verify the TPM signature\n\t*/\n\tif (rc == 0) {\n\t    rc = verifyRSASignatureFromRSA((uint8_t *)&in.digest.t.buffer,\n\t\t\t\t\t   in.digest.t.size,\n\t\t\t\t\t   &out.signature,\n\t\t\t\t\t   halg,\n\t\t\t\t\t   rsaPubKey);\n\n\t}\n\tTSS_RsaFree(rsaPubKey); \t\t/* @2 */\n    }\n    free(data);\t\t\t\t\t/* @1 */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"sign: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"sign: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n    \nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"sign\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Sign\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t-if\\tinput message to hash and sign\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-salg\\tsignature algorithm (rsa, ecc, hmac) (default rsa)]\\n\");\n    printf(\"\\t[-scheme signing scheme (rsassa, rsapss, ecdsa, ecdaa, hmac)]\\n\");\n    printf(\"\\t\\t(default rsassa, ecdsa, hmac)]\\n\");\n    printf(\"\\t[-cf\\tinput counter file (commit count required for ECDAA scheme]\\n\");\n    printf(\"\\t[-ipu\\tpublic key file name to verify signature (default no verify)]\\n\");\n    printf(\"\\t\\tVerify only supported for RSA now\\n\");\n    printf(\"\\t[-os\\tsignature file name (default do not save)]\\n\");\n    printf(\"\\t[-tk\\tticket file name]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/signapp.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Sign Application\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n   Demo application, and test of \"no file TSS\"\n\n   Prerequisite: A provisioned EK certificate.  Use 'clientek' in the acs directory to provision a\n   software TPM EK certificate.\n\n   Program steps:\n\n   Create an EK.  The EK would not normally be the storage root key, but this demonstrates use of a\n   policy session, creating an EK primary key using the EK template, and validation of the EK\n   against the EK certificate.\n\n   Start a policy session, salt with EK\n\n   Create a signing key, salted policy session\n   \n   Load the signing key, salted policy session\n\n   Start an HMAC session, salt with EK, bind to signing key\n\n   Sign a message, verify the signature\n\n   Flush the signing key\n\n   Flush the EK\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n/* Windows 10 crypto API clashes with openssl */\n#ifdef TPM_WINDOWS\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include \"ekutils.h\"\n#include \"objecttemplates.h\"\n\n#define KEYPWD\t\"keypwd\" \n\nstatic TPM_RC startSession(TSS_CONTEXT *tssContext,\n\t\t\t   TPMI_SH_AUTH_SESSION *sessionHandle,\n\t\t\t   TPM_SE sessionType,\n\t\t\t   TPMI_DH_OBJECT tpmKey,\n\t\t\t   TPMI_DH_ENTITY bind,\n\t\t\t   const char *bindPassword);\nstatic TPM_RC policyRestart(TSS_CONTEXT *tssContext,\n\t\t\t    TPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC policyCommandCode(TSS_CONTEXT *tssContext,\n\t\t\t\tTPM_CC\tcommandCode,\n\t\t\t\tTPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC policyAuthValue(TSS_CONTEXT *tssContext,\n\t\t\t      TPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC policyPassword(TSS_CONTEXT *tssContext,\n\t\t\t     TPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC policySecret(TSS_CONTEXT *tssContext,\n\t\t\t   TPMI_DH_ENTITY authHandle,\n\t\t\t   TPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC policyGetDigest(TSS_CONTEXT *tssContext,\n\t\t\t      TPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC createKey(TSS_CONTEXT *tssContext,\n\t\t\tTPM2B_PRIVATE *outPrivate,\n\t\t\tTPM2B_PUBLIC *outPublic,\n\t\t\tTPMI_SH_AUTH_SESSION policySessionHandle,\n\t\t\tTPM_HANDLE parentHandle,\n\t\t\tconst char *keyPassword,\n\t\t\tint pwSession);\nstatic TPM_RC loadKey(TSS_CONTEXT *tssContext,\n\t\t      TPM_HANDLE *keyHandle,\n\t\t      TPM_HANDLE parentHandle,\n\t\t      TPMI_SH_AUTH_SESSION policySessionHandle,\n\t\t      TPM2B_PRIVATE *outPrivate,\n\t\t      TPM2B_PUBLIC *outPublic,\n\t\t      int pwSession);\nstatic TPM_RC sign(TSS_CONTEXT *tssContext,\n\t\t   TPMT_SIGNATURE *signature,\n\t\t   TPM_HANDLE keyHandle,\n\t\t   TPMI_SH_AUTH_SESSION sessionHandle,\n\t\t   uint32_t sizeInBytes,\n\t\t   TPMT_HA *messageDigest);\nstatic TPM_RC verify(TSS_CONTEXT *tssContext,\n\t\t     TPM_HANDLE keyHandle,\n\t\t     uint32_t sizeInBytes,\n\t\t     TPMT_HA *messageDigest,\n\t\t     TPMT_SIGNATURE *signature);\nstatic TPM_RC flush(TSS_CONTEXT *tssContext,\n\t\t    TPMI_DH_CONTEXT flushHandle);\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    int \t\t\tpwSession = FALSE;\t\t/* default HMAC session */\n    const char \t\t\t*messageString = NULL;\n    uint32_t \t\t\tsizeInBytes;\n    TPMT_HA \t\t\tmessageDigest;\t\t\t/* digest of the message */\n    TPMI_SH_AUTH_SESSION \tpolicySessionHandle = TPM_RH_NULL;\n    TPMI_SH_AUTH_SESSION \tsessionHandle = TPM_RH_NULL;\n    TPM_HANDLE \t\t\tekKeyHandle = TPM_RH_NULL;\t/* primary key handle */\n    TPM2B_PRIVATE \t\toutPrivate;\n    TPM2B_PUBLIC \t\toutPublic;\n    TPM_HANDLE \t\t\tkeyHandle = TPM_RH_NULL;\t/* signing key handle */\n    TPMT_SIGNATURE\t\tsignature;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwsess\") == 0) {\n\t    pwSession = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-ic\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tmessageString = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ic option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (messageString == NULL) {\n\tprintf(\"Missing message -ic\\n\");\n\tprintUsage();\n    }\n    /* hash the message file */\n    if (rc == 0) {\n\tmessageDigest.hashAlg = TPM_ALG_SHA256;\n\t/* hash algorithm mapped to size */\n\tsizeInBytes = TSS_GetDigestSize(messageDigest.hashAlg);\n\trc = TSS_Hash_Generate(&messageDigest,\n\t\t\t       strlen(messageString), messageString,\n\t\t\t       0, NULL);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Create a TSS context\\n\");\n\trc = TSS_Create(&tssContext);\n    }\n    /* createprimary first for salt and for a storage key for the child signing key.\n       processPrimary() also reads the EK certificate and validates it against the primary key.  It\n       doesn't walk the certificate chain.  */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Create a primary EK for the salt\\n\");\n\trc = processPrimaryEN(tssContext,\n\t\t\t      &ekKeyHandle,\n\t\t\t      NULL, NULL,\n\t\t\t      EK_CERT_RSA_INDEX, EK_NONCE_RSA_INDEX, EK_TEMPLATE_RSA_INDEX,\n\t\t\t      TRUE,\t\t\t/* do not flush */\n\t\t\t      TRUE,\t\t\t/* do not validate the EK certificate */\n\t\t\t      tssUtilsVerbose);\t\n\tif (tssUtilsVerbose) printf(\"INFO: Primary EK handle %08x\\n\", ekKeyHandle);\n    }\n    /* start a policy session */\n    if (rc == 0) {\n\tTPM_HANDLE\tsaltHandle;\n\tif (tssUtilsVerbose) printf(\"INFO: Start a policy session\\n\");\n\tif (!pwSession) {\n\t    saltHandle = ekKeyHandle;\n\t}\n\telse {\n\t    saltHandle = TPM_RH_NULL;\t/* primary key handle */\n\t}\n\trc = startSession(tssContext,\n\t\t\t  &policySessionHandle,\n\t\t\t  TPM_SE_POLICY,\n\t\t\t  saltHandle, TPM_RH_NULL,\t/* salt, no bind */\n\t\t\t  NULL);\t\t\t/* no bind password */\n\tif (tssUtilsVerbose) printf(\"INFO: Policy session %08x\\n\", policySessionHandle);\n    }\n    /* EK needs policy secret with endorsement auth */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Satisfy the policy session %08x\\n\", policySessionHandle);\n\trc = policySecret(tssContext,\n\t\t\t  TPM_RH_ENDORSEMENT,\n\t\t\t  policySessionHandle);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Dump the policy session %08x\\n\", policySessionHandle);\n\trc = policyGetDigest(tssContext,\n\t\t\t     policySessionHandle);\n    }\n    /* Create the signing key */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Create a signing key under the EK %08x\\n\", ekKeyHandle);\n\trc = createKey(tssContext,\n\t\t       &outPrivate,\n\t\t       &outPublic,\n\t\t       policySessionHandle,\t/* continue */\n\t\t       ekKeyHandle,\t\t/* parent */\n\t\t       KEYPWD,\t\t\t/* password for the signing key */\n\t\t       pwSession);\n    }\n    /* reuse the policy session to load the signing key under the EK storage key */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Restart the policy session %08x\\n\", policySessionHandle);\n\trc = policyRestart(tssContext,\n\t\t\t   policySessionHandle);\n    }\n    /* EK needs policy secret with endorsement auth */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Satisfy the policy session %08x\\n\", policySessionHandle);\n\trc = policySecret(tssContext,\n\t\t\t  TPM_RH_ENDORSEMENT,\n\t\t\t  policySessionHandle);\n    }\n    /* Load the signing key.  flush the policy session. */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Load a signing key under the EK %08x\\n\", ekKeyHandle);\n\trc = loadKey(tssContext,\n\t\t     &keyHandle,\t\t/* signing key */\n\t\t     ekKeyHandle,\t\t/* parent */\n\t\t     policySessionHandle,\t/* no flush */\n\t\t     &outPrivate,\n\t\t     &outPublic,\n\t\t     pwSession);\n\tif (tssUtilsVerbose) printf(\"INFO: Loaded key handle %08x\\n\", keyHandle);\n    }\n    /* start an HMAC session, salt with EK, bind with signing key */\n    if (rc == 0) {\n\tif (!pwSession) {\n\t    if (tssUtilsVerbose) printf(\"INFO: Start a salt and bind session\\n\");\n\t    rc = startSession(tssContext,\n\t\t\t      &sessionHandle,\t/* salt, bind */\n\t\t\t      TPM_SE_HMAC,\n\t\t\t      ekKeyHandle,\t/* salt */\n\t\t\t      keyHandle,\t/* bind */\n\t\t\t      KEYPWD);\t\t/* bind with signing key password */\n\n\t    if (tssUtilsVerbose) printf(\"INFO: Salt and bind session %08x\\n\", sessionHandle);\n\t}\n\telse {\n\t    sessionHandle = TPM_RS_PW;\n\t}\n    }\n    /*\n      sign and verify using an HMAC or password\n    */\n    /* Sign the message digest */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Sign with the signing key %08x\\n\", keyHandle);\n\trc = sign(tssContext,\n\t\t  &signature,\n\t\t  keyHandle,\t\t/* signing key */\n\t\t  sessionHandle,\t/* continue */\n\t\t  sizeInBytes,\t\t/* hash algorithm mapped to size */\n\t\t  &messageDigest);\t/* digest of the message */\n    }\n    /* Verify the signature */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Verify the signature %08x\\n\", keyHandle);\n\trc = verify(tssContext,\n\t\t    keyHandle,\t\t/* verification public key */\n\t\t    sizeInBytes,\t/* hash algorithm mapped to size */\n\t\t    &messageDigest,\t/* digest of the message */\n\t\t    &signature);\n    }\n    /*\n      sign and verify using a policy session, policy authvalue or policy password\n    */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Restart the policy session %08x\\n\", policySessionHandle);\n\trc = policyRestart(tssContext,\n\t\t\t   policySessionHandle);\n    }\n    /* policy command code */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Satisfy the policy session %08x\\n\", policySessionHandle);\n\trc = policyCommandCode(tssContext,\n\t\t\t       TPM_CC_Sign,\n\t\t\t       policySessionHandle);\n    }\n    /* policy authvalue or policypassword */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Satisfy the policy session %08x\\n\", policySessionHandle);\n\tif (!pwSession) {\n\t    rc = policyAuthValue(tssContext,\n\t\t\t\t policySessionHandle);\n\t}\n\telse {\n\t    rc = policyPassword(tssContext,\n\t\t\t\tpolicySessionHandle);\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Dump the policy session %08x\\n\", policySessionHandle);\n\trc = policyGetDigest(tssContext,\n\t\t\t     policySessionHandle);\n    }\n    /* Sign the message digest */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Sign with the signing key %08x\\n\", keyHandle);\n\trc = sign(tssContext,\n\t\t  &signature,\n\t\t  keyHandle,\t\t/* signing key */\n\t\t  policySessionHandle,\t/* continue */\n\t\t  sizeInBytes,\t\t/* hash algorithm mapped to size */\n\t\t  &messageDigest);\t/* digest of the message */\n    }\n    /* Verify the signature */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Verify the signature %08x\\n\", keyHandle);\n\trc = verify(tssContext,\n\t\t    keyHandle,\t\t/* verification public key */\n\t\t    sizeInBytes,\t/* hash algorithm mapped to size */\n\t\t    &messageDigest,\t/* digest of the message */\n\t\t    &signature);\n    }\n    /* flush the policy session, normally fails */\n    if (policySessionHandle != TPM_RH_NULL) {\n\tif (tssUtilsVerbose) printf(\"INFO: Flush the policy session %08x\\n\", policySessionHandle);\n\tflush(tssContext, policySessionHandle);\n    }\n    /* flush the salt and bind session */\n    if (!pwSession) {\n\tif (sessionHandle != TPM_RH_NULL) {\n\t    if (tssUtilsVerbose) printf(\"INFO: Flush the salt session %08x\\n\", sessionHandle);\n\t    flush(tssContext, sessionHandle);\n\t}\n    }\n    /* flush the primary key */\n    if (ekKeyHandle != TPM_RH_NULL) {\n\tif (tssUtilsVerbose) printf(\"INFO: Flush the primary key %08x\\n\", ekKeyHandle);\n\tflush(tssContext, ekKeyHandle);\n    }\n    /* flush the signing key */\n    if (keyHandle != TPM_RH_NULL) {\n\tif (tssUtilsVerbose) printf(\"INFO: Flush the signing key %08x\\n\", keyHandle);\n\tflush(tssContext, keyHandle);\n    }\n    {  \n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"signapp: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"signapp: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n/* startSession() starts either a policy or HMAC session.\n\n   If tpmKey is not null, a salted session is used.\n\n   If bind is not null, a bind session is used.\n*/\n\nstatic TPM_RC startSession(TSS_CONTEXT *tssContext,\n\t\t\t   TPMI_SH_AUTH_SESSION *sessionHandle,\n\t\t\t   TPM_SE sessionType,\t\t\t/* policy or HMAC */\n\t\t\t   TPMI_DH_OBJECT tpmKey,\t\t/* salt key, can be null */\n\t\t\t   TPMI_DH_ENTITY bind,\t\t\t/* bind object, can be null */\n\t\t\t   const char *bindPassword)\t\t/* bind object password, can be null */\n{\n    TPM_RC\t\t\trc = 0;\n    StartAuthSession_In \tstartAuthSessionIn;\n    StartAuthSession_Out \tstartAuthSessionOut;\n    StartAuthSession_Extra\tstartAuthSessionExtra;\n     \n    /*\tStart an authorization session */\n    if (rc == 0) {\n\tstartAuthSessionIn.tpmKey = tpmKey;\t\t\t/* salt key */\n\tstartAuthSessionIn.bind = bind;\t\t\t\t/* bind object */\n\tstartAuthSessionExtra.bindPassword = bindPassword;\t/* bind object password */\n\tstartAuthSessionIn.sessionType = sessionType;\t\t/* HMAC or policy session */\n\tstartAuthSessionIn.authHash = TPM_ALG_SHA256;\t\t/* HMAC algorithm */\n\tstartAuthSessionIn.symmetric.algorithm = TPM_ALG_AES;\t/* parameter encryption */\n\tstartAuthSessionIn.symmetric.keyBits.aes = 128;\n\tstartAuthSessionIn.symmetric.mode.aes = TPM_ALG_CFB;\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&startAuthSessionOut, \n\t\t\t (COMMAND_PARAMETERS *)&startAuthSessionIn,\n\t\t\t (EXTRA_PARAMETERS *)&startAuthSessionExtra,\n\t\t\t TPM_CC_StartAuthSession,\n\t\t\t TPM_RH_NULL, NULL, 0);\n\t*sessionHandle = startAuthSessionOut.sessionHandle;\n    }\n    return rc;\n}\n\nstatic TPM_RC policyRestart(TSS_CONTEXT *tssContext,\n\t\t\t    TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    PolicyRestart_In \t\tpolicyRestartIn;\n\n    if (rc == 0) {\n    \tpolicyRestartIn.sessionHandle = sessionHandle;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&policyRestartIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyRestart,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\nstatic TPM_RC policyCommandCode(TSS_CONTEXT *tssContext,\n\t\t\t\tTPM_CC\tcommandCode,\n\t\t\t\tTPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    PolicyCommandCode_In \tpolicyCommandCodeIn;\n\n    if (rc == 0) {\n \tpolicyCommandCodeIn.policySession = sessionHandle;\n\tpolicyCommandCodeIn.code = commandCode;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&policyCommandCodeIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyCommandCode,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\nstatic TPM_RC policyAuthValue(TSS_CONTEXT *tssContext,\n\t\t\t      TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\t\trc = 0;\n    PolicyAuthValue_In \tpolicyAuthValueIn;\n\n    if (rc == 0) {\n\tpolicyAuthValueIn.policySession = sessionHandle;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&policyAuthValueIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyAuthValue,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\nstatic TPM_RC policyPassword(TSS_CONTEXT *tssContext,\n\t\t\t     TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\t\trc = 0;\n    PolicyPassword_In \tpolicyPasswordIn;\n\n    if (rc == 0) {\n \tpolicyPasswordIn.policySession = sessionHandle;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&policyPasswordIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyPassword,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\n/* policySecret() runs policy secret against the session.  It assumes that the secret (the\n   endorsement authorization in this example) is Empty.\n\n*/\n\nstatic TPM_RC policySecret(TSS_CONTEXT *tssContext,\n\t\t\t   TPMI_DH_ENTITY authHandle,\n\t\t\t   TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    PolicySecret_In \t\tpolicySecretIn;\n    PolicySecret_Out \t\tpolicySecretOut;\n     \n    if (rc == 0) {\n\tpolicySecretIn.authHandle = authHandle;\n\tpolicySecretIn.policySession = sessionHandle;\n\tpolicySecretIn.nonceTPM.b.size = 0;\n\tpolicySecretIn.cpHashA.b.size = 0;\n\tpolicySecretIn.policyRef.b.size = 0;\n\tpolicySecretIn.expiration = 0;\n    }   \n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&policySecretOut, \n\t\t\t (COMMAND_PARAMETERS *)&policySecretIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicySecret,\n\t\t\t TPM_RS_PW, NULL, 0,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\n/* policyGetDigest() traces the session policy digest for debugging.  It should be the same as the\n   policy in the EK template.\n   \n*/\n\nstatic TPM_RC policyGetDigest(TSS_CONTEXT *tssContext,\n\t\t\t      TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    PolicyGetDigest_In \t\tpolicyGetDigestIn;\n    PolicyGetDigest_Out \tpolicyGetDigestOut;\n     \n    if (rc == 0) {\n\tpolicyGetDigestIn.policySession = sessionHandle;\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&policyGetDigestOut, \n\t\t\t (COMMAND_PARAMETERS *)&policyGetDigestIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_PolicyGetDigest,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    if (tssUtilsVerbose) TSS_PrintAll(\"policyGetDigest\",\n\t\t\t      policyGetDigestOut.policyDigest.t.buffer,\n\t\t\t      policyGetDigestOut.policyDigest.t.size);\n    return rc;\n}\n\n/* createKey() creates a signing key under the EK storage key parentHandle.\n\n   policySessionHandle is a previously satisfied policy session.  continue is SET.\n\n   A command decrypt session is used to transfer the signing key userAuth encrypted.  A response\n   encrypt session is used just as a demo.\n\n*/\n\nstatic TPM_RC createKey(TSS_CONTEXT *tssContext,\n\t\t\tTPM2B_PRIVATE *outPrivate,\n\t\t\tTPM2B_PUBLIC *outPublic,\n\t\t\tTPMI_SH_AUTH_SESSION policySessionHandle,\n\t\t\tTPM_HANDLE parentHandle,\n\t\t\tconst char *keyPassword,\n\t\t\tint pwSession)\n{\n    TPM_RC\trc = 0;\n    Create_In \tcreateIn;\n    Create_Out \tcreateOut;\n    int \tattributes;\n    /* hard code the policy since this test is also used for the no file support case */\n    const uint8_t policy[] = {0x7e, 0xa1, 0x0d, 0xe0, 0x05, 0xfc, 0xb2, 0x1d,\n\t\t\t      0x44, 0xf2, 0x4b, 0xc8, 0xf7, 0x4c, 0x28, 0xa8,\n\t\t\t      0xb9, 0xed, 0xf1, 0x4b, 0x1c, 0x53, 0xea, 0x4c,\n\t\t\t      0xcf, 0x3c, 0x5a, 0x4c, 0xe3, 0x8c, 0x75, 0x6e};\n    if (rc == 0) {\n\tcreateIn.parentHandle = parentHandle;\n\trc = TSS_TPM2B_StringCopy(&createIn.inSensitive.sensitive.userAuth.b,\n\t\t\t\t  keyPassword,\n\t\t\t\t  sizeof(createIn.inSensitive.sensitive.userAuth.t.buffer));\n    }\n    /* policy command code sign + policy authvalue or policy password */\n    if (rc == 0) {\n\tmemcpy(&createIn.inPublic.publicArea.authPolicy.t.buffer, policy, sizeof(policy));\n\tcreateIn.inPublic.publicArea.authPolicy.b.size = sizeof(policy);\n    }\n    if (rc == 0) {\n\tcreateIn.inSensitive.sensitive.data.t.size = 0;\n\tcreateIn.inPublic.publicArea.nameAlg = TPM_ALG_SHA256;\n\tcreateIn.inPublic.publicArea.type = TPM_ALG_RSA;\t/* for the RSA template */\n\tcreateIn.inPublic.publicArea.objectAttributes.val = 0;\n\tcreateIn.inPublic.publicArea.objectAttributes.val |= TPMA_OBJECT_NODA;\n\tcreateIn.inPublic.publicArea.objectAttributes.val |= TPMA_OBJECT_SENSITIVEDATAORIGIN;\n\tcreateIn.inPublic.publicArea.objectAttributes.val |= TPMA_OBJECT_USERWITHAUTH;\n\tcreateIn.inPublic.publicArea.objectAttributes.val &= ~TPMA_OBJECT_ADMINWITHPOLICY;\n\tcreateIn.inPublic.publicArea.objectAttributes.val |= TPMA_OBJECT_SIGN;\n\tcreateIn.inPublic.publicArea.objectAttributes.val &= ~TPMA_OBJECT_DECRYPT;\n\tcreateIn.inPublic.publicArea.objectAttributes.val &= ~TPMA_OBJECT_RESTRICTED;\n\tcreateIn.inPublic.publicArea.parameters.rsaDetail.symmetric.algorithm = TPM_ALG_NULL;\n\tcreateIn.inPublic.publicArea.parameters.rsaDetail.scheme.scheme = TPM_ALG_NULL;\n\tcreateIn.inPublic.publicArea.parameters.rsaDetail.keyBits = 2048;\n\tcreateIn.inPublic.publicArea.parameters.rsaDetail.exponent = 0;\n\tcreateIn.inPublic.publicArea.unique.rsa.t.size = 0;\n\tcreateIn.outsideInfo.t.size = 0;\n\tcreateIn.creationPCR.count = 0;\n\tif (pwSession) {\n\t    attributes = TPMA_SESSION_CONTINUESESSION;\n\t}\n\telse {\n\t    attributes = TPMA_SESSION_ENCRYPT | TPMA_SESSION_DECRYPT | TPMA_SESSION_CONTINUESESSION;\n\t}\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&createOut,\n\t\t\t (COMMAND_PARAMETERS *)&createIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_Create,\n\t\t\t policySessionHandle, NULL, attributes, \n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    if (rc == 0) {\n\t*outPrivate = createOut.outPrivate;\n\t*outPublic = createOut.outPublic;\n    }\n    return rc;\n}\n\n/* loadKey() loads the signing key under the EK storage key parentHandle.\n\n   policySessionHandle is a previously satisfied policy session.  continue is SET.\n\n   A command decrypt and response encrypt session is used just as a demo.\n*/\n\nstatic TPM_RC loadKey(TSS_CONTEXT *tssContext,\n\t\t      TPM_HANDLE *keyHandle,\n\t\t      TPM_HANDLE parentHandle,\n\t\t      TPMI_SH_AUTH_SESSION policySessionHandle,\n\t\t      TPM2B_PRIVATE *outPrivate,\n\t\t      TPM2B_PUBLIC *outPublic,\n\t\t      int pwSession)\n{\n    TPM_RC\trc = 0;\n    Load_In \tloadIn;\n    Load_Out \tloadOut;\n    int \tattributes;\n\n    if (rc == 0) {\n\tloadIn.parentHandle = parentHandle;\n\tloadIn.inPrivate = *outPrivate;\n\tloadIn.inPublic = *outPublic;\n\tif (pwSession) {\n\t    attributes = TPMA_SESSION_CONTINUESESSION;\n\t}\n\telse {\n\t    attributes = TPMA_SESSION_DECRYPT | TPMA_SESSION_CONTINUESESSION;\n\t}\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&loadOut,\n\t\t\t (COMMAND_PARAMETERS *)&loadIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_Load,\n\t\t\t policySessionHandle, NULL, attributes,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    if (rc == 0) {\n\t*keyHandle = loadOut.objectHandle;\n    }\n    return rc;\n}\n\n/* sign() signs messageDigest with the signing key keyHandle.\n\n   sessionHandle is a salt and bind session. continue is SET.\n\n   Note that the signing key password is not supplied here.  It is supplied when the bind session is\n   created.\n\n*/\n\nstatic TPM_RC sign(TSS_CONTEXT *tssContext,\n\t\t   TPMT_SIGNATURE *signature,\n\t\t   TPM_HANDLE keyHandle,\n\t\t   TPMI_SH_AUTH_SESSION sessionHandle,\n\t\t   uint32_t sizeInBytes,\t/* hash algorithm mapped to size */\n\t\t   TPMT_HA *messageDigest)\t/* digest of the message */\n{\n    TPM_RC\t\t\trc = 0;\n    Sign_In \t\t\tsignIn;\n    Sign_Out \t\t\tsignOut;\n    const char \t\t\t*pwd;\n    TPM_HT \t\t\thandleType = (TPM_HT) ((sessionHandle & HR_RANGE_MASK) >> HR_SHIFT);\n\n    if (rc == 0) {\n\tsignIn.keyHandle = keyHandle;\n\tsignIn.digest.t.size = sizeInBytes;\n\tmemcpy(&signIn.digest.t.buffer, (uint8_t *)&messageDigest->digest, sizeInBytes);\n\tsignIn.inScheme.scheme = TPM_ALG_RSASSA;\n\tsignIn.inScheme.details.rsassa.hashAlg = TPM_ALG_SHA256;\n\tsignIn.validation.tag = TPM_ST_HASHCHECK;\t/* optional, to make a ticket */\n\tsignIn.validation.hierarchy = TPM_RH_NULL;\n\tsignIn.validation.digest.t.size = 0;\n\t/* password session */\n\tif (sessionHandle == TPM_RS_PW) {\n\t    pwd = KEYPWD;\n\t}\n\t/* policy session is policy password or policy authvalue */\n\telse if (handleType == TPM_HT_POLICY_SESSION) {\n\t    pwd = KEYPWD;\n\t}\n\t/* HMAC session - bound (password ignored) */\n\telse {\n\t    pwd = NULL;\n\t}\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&signOut,\n\t\t\t (COMMAND_PARAMETERS *)&signIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_Sign,\n\t\t\t /* bind, observe that no password is required here */\n\t\t\t sessionHandle, pwd, TPMA_SESSION_CONTINUESESSION,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    if (rc == 0) {\n\t*signature = signOut.signature;\n    }\n    return rc;\n}\n\n/* verify() verifies the signature against the message digest using the previously loaded key in\n   keyHandle.\n\n */\n\nstatic TPM_RC verify(TSS_CONTEXT *tssContext,\n\t\t     TPM_HANDLE keyHandle,\n\t\t     uint32_t sizeInBytes,\t/* hash algorithm mapped to size */\n\t\t     TPMT_HA *messageDigest,\t/* digest of the message */\n\t\t     TPMT_SIGNATURE *signature)\n{\n    TPM_RC\t\t\trc = 0;\n    VerifySignature_In \t\tverifySignatureIn;\n    VerifySignature_Out \tverifySignatureOut;\n\n    if (rc == 0) {\n\tverifySignatureIn.keyHandle = keyHandle;\n\tverifySignatureIn.digest.t.size = sizeInBytes;\n\tmemcpy(&verifySignatureIn.digest.t.buffer, (uint8_t *)&messageDigest->digest, sizeInBytes);\n\tverifySignatureIn.signature = *signature;\n    }\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&verifySignatureOut,\n\t\t\t (COMMAND_PARAMETERS *)&verifySignatureIn,\n\t\t\t NULL,\n\t\t\t TPM_CC_VerifySignature,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\n/* flush() flushes some handle, either a session or the signing key in this demo.\n\n */\n\nstatic TPM_RC flush(TSS_CONTEXT *tssContext,\n\t\t    TPMI_DH_CONTEXT flushHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    FlushContext_In \t\tin;\n\n    if (rc == 0) {\n\tin.flushHandle = flushHandle;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_FlushContext,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"signapp\\n\");\n    printf(\"\\n\");\n    printf(\"Runs a TPM2_Sign application, including creating a primary storage key\\n\");\n    printf(\"and creating and loading a signing key\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ic\\tinput message to hash and sign\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwsess\\tUse a password session, no HMAC or parameter encryption]\\n\");\n    printf(\"\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/startauthsession.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    StartAuthSession\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    StartAuthSession_In \tin;\n    StartAuthSession_Out \tout;\n    StartAuthSession_Extra\textra;\n    TPMI_DH_OBJECT\t\ttpmKey = TPM_RH_NULL;\t\t/* salt key */\n    TPMI_DH_ENTITY\t\tbindHandle = TPM_RH_NULL;\t/* default */\n    const char \t\t\t*bindPassword = NULL;\n    char \t\t\tseChar = 0;\t\t\t/* session type */\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\t\t/* default */\n    TPMI_ALG_SYM\t\talgorithm = TPM_ALG_XOR;\t/* default symmetric algorithm */\n    const char\t\t\t*nonceTPMFilename = NULL;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-se\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tseChar = argv[i][0];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-hs\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i], \"%x\", &tpmKey);\n\t    }\n\t    else {\n\t\tprintf(\"Bad parameter %s for -hs\\n\", argv[i]);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-bi\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i], \"%x\", &bindHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Bad parameter %s for -bi\\n\", argv[i]);\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-sym\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"xor\") == 0) {\n\t\t    algorithm = TPM_ALG_XOR;\n\t\t}\n\t\telse if (strcmp(argv[i],\"aes\") == 0) {\n\t\t    algorithm = TPM_ALG_AES;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -sym\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -sym\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-on\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tnonceTPMFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-on option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwdb\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tbindPassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwdb option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((bindHandle == TPM_RH_NULL) && (bindPassword != NULL)) {\n\tprintf(\"-pwdb (bind password) unused without -bi (bind handle)\\n\");\n\tprintUsage();\n    }\n    /* sessionType */\n    switch (seChar) {\n      case 'h':\n\tin.sessionType = TPM_SE_HMAC;\n\tbreak;\n      case 'p':\n\tin.sessionType = TPM_SE_POLICY;\n\tbreak;\n      case 't':\n\tin.sessionType = TPM_SE_TRIAL;\n\tbreak;\n      default:\n\tprintf(\"Missing or illegal parameter for -se\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\t/* salt key */\n\tin.tpmKey = tpmKey;\n\t/* encryptedSalt (not required) */\n\tin.encryptedSalt.b.size = 0;\n\t/* bind handle */\n\tin.bind = bindHandle;\n\t/* nonceCaller (not required) */\n\tin.nonceCaller.t.size = 0;\n\t/* for parameter encryption */\n\tin.symmetric.algorithm = algorithm;\n\t/* authHash */\n\tin.authHash = halg;\n    }\n    /* symmetric */\n    /* Table 128 - Definition of TPMT_SYM_DEF Structure */\n    if (rc == 0) {\t/* XOR */\n\tif (in.symmetric.algorithm == TPM_ALG_XOR) {\n\t    /* Table 61 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM Type */\n\t    /* Table 125 - Definition of TPMU_SYM_KEY_BITS Union */\n\t    in.symmetric.keyBits.xorr = halg;\n\t    /* Table 126 - Definition of TPMU_SYM_MODE Union */\n\t    in.symmetric.mode.sym = TPM_ALG_NULL;\t\t/* none for xor */\n\t}\n\telse {\t\t/* AES */\n\t    /* Table 61 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM Type */\n\t    /* Table 125 - Definition of TPMU_SYM_KEY_BITS Union */\n\t    in.symmetric.keyBits.aes = 128;\n\t    /* Table 126 - Definition of TPMU_SYM_MODE Union */\n\t    /* Table 63 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_MODE Type */\n\t    in.symmetric.mode.aes = TPM_ALG_CFB;\n\t}\n    }\n    /* pass the bind password to the TSS post processor for the session key calculation */\n    if (rc == 0) {\n\textra.bindPassword = bindPassword;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t (EXTRA_PARAMETERS *)&extra,\n\t\t\t TPM_CC_StartAuthSession,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    /* optionally store the nonceTPM for use in policy commands */\n    if ((rc == 0) && (nonceTPMFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile((uint8_t *)&out.nonceTPM.t.buffer,\n\t\t\t\t      out.nonceTPM.t.size,\n\t\t\t\t      nonceTPMFilename); \n    }\n    if (rc == 0) {\n\tprintf(\"Handle %08x\\n\", out.sessionHandle);\n\tif (tssUtilsVerbose) printf(\"startauthsession: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"startauthsession: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"startauthsession\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_StartAuthSession\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\th  HMAC session\\n\");\n    printf(\"\\t\\tp  Policy session\\n\");\n    printf(\"\\t\\tt  Trial policy session\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384, sha512) (default sha256)]\\n\");\n    printf(\"\\t[-hs\\tsalt handle (default TPM_RH_NULL)]\\n\");\n    printf(\"\\t[-bi\\tbind handle (default TPM_RH_NULL)]\\n\");\n    printf(\"\\t[-pwdb\\tbind password for bind handle (default empty)]\\n\");\n    printf(\"\\t[-sym\\t(xor, aes) symmetric parameter encryption algorithm (default xor)]\\n\");\n    printf(\"\\t[-on\\tnonceTPM file for policy session (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/startup.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Startup\t\t \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* startup supports an optional locality specifier to simulate the locality 3 startup PCR 0\n   value. */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\nTPM_RC selftestCommand(void);\nTPM_RC startupCommand(TPM_SU startupType, const char *locality);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC \t\trc = 0;\n    int\t\t\ti;\t\t\t\t/* argc iterator */\n    int                 doStartup = TRUE;\t\t/* default startup */\n    int                 doSelftest = FALSE;\t\t/* default no self test */\n    TPM_SU\t\tstartupType = TPM_SU_CLEAR;\n    const char \t\t*locality = NULL;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-c\") == 0) {\n\t    startupType = TPM_SU_CLEAR;\n\t    doStartup = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-s\") == 0) {\n\t    doStartup = TRUE;\n\t    startupType = TPM_SU_STATE;\n\t}\n\telse if (strcmp(argv[i],\"-st\") == 0) {\n\t    doSelftest = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-sto\") == 0) {\n\t    doStartup = FALSE;\n\t    doSelftest = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-loc\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tlocality = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -loc\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((rc == 0) && doStartup) {\n\trc = startupCommand(startupType, locality);\n    }\n    if ((rc == 0) && doSelftest ) {\n\trc = selftestCommand();\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"startup: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"startup: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n/* locality NULL uses the compiled in default locality, almost always locality 0 */\n\nTPM_RC startupCommand(TPM_SU startupType, const char *locality)\n{\n    TPM_RC \t\trc = 0;\n    TSS_CONTEXT\t\t*tssContext = NULL;\n    Startup_In \t\tin;\n\n    /*\n      Start a TSS context\n    */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    if ((rc == 0) && (locality != NULL)) {\n\tTSS_SetProperty(tssContext, TPM_TRANSMIT_LOCALITY, locality);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\tin.startupType = startupType;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Startup,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    return rc;\n}\n\nTPM_RC selftestCommand(void)\n{\n    TPM_RC \t\trc = 0;\n    TSS_CONTEXT\t\t*tssContext = NULL;\n    SelfTest_In \tin;\n\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\tin.fullTest = YES;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_SelfTest,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    /* Delete the TSS context */\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"selftest: success\\n\");\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"startup\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Startup\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-c\\tstartup clear (default)]\\n\");\n    printf(\"\\t[-s\\tstartup state]\\n\");\n    printf(\"\\t[-st\\trun TPM2_SelfTest]\\n\");\n    printf(\"\\t[-sto\\trun only TPM2_SelfTest (no startup)]\\n\");\n    printf(\"\\t[-loc\\tlocality]\\n\");\n    exit(1);\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/stirrandom.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   StirRandom\t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    StirRandom_In \t\tin;\n    const char\t\t\t*inputFilename = NULL;\n    \n    uint8_t\t\t\t*buffer = NULL;\t\t/* for the free */\n    size_t \t\t\tlength = 0;\n   \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tinputFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (inputFilename == NULL) {\n\tprintf(\"Missing input parameter -if\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     inputFilename);\n    }\n    if (rc == 0) {\n\tif (length > sizeof(in.inData.t.buffer)) {\n\t    printf(\"Input data too long %u\\n\", (uint32_t)length);\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\tin.inData.t.size =  (uint16_t)length;\t/* cast safe, range tested above */\n\tmemcpy(in.inData.t.buffer, buffer, length);\n    }\n    free(buffer);\t/* @1 */\n    buffer = NULL;\n    \n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_StirRandom,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"stirrandom: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"stirrandom: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"stirrandom\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_StirRandom\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-if\\tinput file name\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/timepacket.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Time a TPM Command\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2017 - 2020\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <time.h>\n\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#include <windows.h>\n#endif\n\n#ifdef TPM_POSIX\n#include <unistd.h>\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tsstransmit.h>\n#include <ibmtss/tssfile.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsscrypto.h>\n\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    \t/* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    const char\t\t\t*commandFilename = NULL;\n    unsigned char \t\t*commandBufferString = NULL;\n    unsigned char \t\t*commandBuffer = NULL;\n    size_t \t\t\tcommandStringLength;\n    size_t \t\t\tcommandLength;\n    unsigned int \t\tloops = 1;\n    unsigned int \t\tcount;\n    uint8_t \t\t\tresponseBuffer[MAX_RESPONSE_SIZE];\n    uint32_t \t\t\tresponseLength;\n    time_t \t\t\tstartTime;\n    time_t\t\t\tendTime;\n    double \t\t\ttimeDiff = 0;\n    \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcommandFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-l\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tloops = atoi(argv[i]);\n\t\tif (loops == 0) {\n\t\t    printf(\"-l option cannot be 0\\n\");\n\t\t    printUsage();\n \t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-l option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (commandFilename == NULL) {\n\tprintf(\"Missing parameter -if\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&commandBufferString,\t/* freed @2 */\n\t\t\t\t     &commandStringLength, commandFilename);\n    }\n    if (rc == 0) {\n\tif (commandBufferString[commandStringLength-1] != ' ') {\n\t    printf(\"packet string does not end in a space\\n\");\n\t    exit(1);\n\t}\n\telse {\n\t    /* nul terminate the string */\n\t    commandBufferString[commandStringLength-1] = '\\0';\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Scan(&commandBuffer,\t\t/* freed @1 */\n\t\t\t    &commandLength, (char *)commandBufferString);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    for (count = 0 ; (rc == 0) && (count < loops) ; count++) {\n\tuint32_t usec;\n\tif (rc == 0) {\n\t    rc = TSS_RandBytes((unsigned char *)&usec, sizeof(uint32_t));\n\t}\n\tif (rc == 0) {\n\t    usec %= 1000000;\n#ifdef TPM_POSIX\n\t    usleep(usec);\t/* usleep() units are usec */\n#endif\n#ifdef TPM_WINDOWS\n\t    Sleep(usec/1000);\t/* Sleep units are msec */\n#endif\n\t    startTime = time(NULL);\n\t    rc = TSS_Transmit(tssContext,\n\t\t\t      responseBuffer, &responseLength,\n\t\t\t      commandBuffer, (uint32_t)commandLength,\n\t\t\t      NULL);\n\t    endTime = time(NULL);\n\t    printf(\"End Pass %u\\n\", count +1);\n\t    timeDiff += difftime(endTime, startTime);\n\t}\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"Loops %u time %f time per pass %f\\n\", loops, timeDiff, timeDiff/loops);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"timepacket: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"timepacket: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(commandBufferString);\t\t/* @2 */\n    free(commandBuffer);\t\t/* @1 */\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"timepacket\\n\");\n    printf(\"\\n\");\n    printf(\"Times the supplied packet\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-if\\tpacket in hexascii (requires one space at end of packet)\\n\");\n    printf(\"\\t[-l\\tnumber of loops to time (default 1)]\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tpm2pem.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t    TPM public key TPM2B_PUBLIC to PEM \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2016 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* Converts a TPM public key TPM2B_PUBLIC to PEM */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n/* Windows 10 crypto API clashes with openssl */\n#ifdef TPM_WINDOWS\n#ifndef WIN32_LEAN_AND_MEAN\n#define WIN32_LEAN_AND_MEAN\n#endif\n#endif\n\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*pemFilename = NULL;\n    TPM2B_PUBLIC \t\tpublic;\n\n    tssUtilsVerbose = FALSE;\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ipu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-opem\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-opem option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (publicKeyFilename == NULL) {\n\tprintf(\"Missing private key parameter -ipu\\n\");\n\tprintUsage();\n    }\n    if (pemFilename == NULL) {\n\tprintf(\"Missing PEM file name parameter -opem\\n\");\n\tprintUsage();\n    }\n    /* read the TPM public key to a structure */\n    if (rc == 0) {\n\trc = TSS_File_ReadStructureFlag(&public,\n\t\t\t\t\t(UnmarshalFunctionFlag_t)TSS_TPM2B_PUBLIC_Unmarshalu,\n\t\t\t\t\tTRUE,\t\t\t/* NULL permitted */\n\t\t\t\t\tpublicKeyFilename);\n    }\n    /* convert to PEM format and write file */\n    if (rc == 0) {\n\trc = convertPublicToPEM(&public, pemFilename);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"tpm2pem: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"tpm2pem: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"tpm2pem\\n\");\n    printf(\"\\n\");\n    printf(\"Converts an RSA or EC TPM2B_PUBLIC to PEM\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ipu\\tpublic key input file in TPM format\\n\");\n    printf(\"\\t-opem\\tpublic key output file in PEM format\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tpmcmd.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Simulator In Band Commands \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2019.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n/* FIXME should really be in tpmtcpprotocol.h */\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\t\t/* for simulator startup */\n#endif\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsstransmit.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC \t\trc = 0;\n    int\t\t\ti;\t\t\t\t/* argc iterator */\n    TSS_CONTEXT\t\t*tssContext = NULL;\n    uint32_t \t\tcommand = 0;\n    const char \t\t*message = \"\";\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-stop\") == 0) {\n\t    command = TPM_STOP;\n\t    message = \"TPM Stop\";\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (command == 0) {\n\tprintf(\"Missing command specifier\\n\");\n\tprintUsage();\n    }\n    /*\n      Start a TSS context\n    */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* Send in band command */\n    if (rc == 0) {\n\trc = TSS_TransmitCommand(tssContext, command, message);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"tpmcmd: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"tpmcmd: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"tpmcmd\\n\");\n    printf(\"\\n\");\n    printf(\"Sends an in-band TPM simulator signal\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-stop\\tStop the TPM simulator\\n\");\n    exit(1);\t\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/tpmproxy.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Windows 10 and Linux TPM Proxy\t \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2006 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n\n/*\n  Use this proxy when using the TSS command line utilities.  It keeps the connection to\n  the TPM device driver open.  This prevents a resource manager from flushing resources\n  after each utiity exits.  It also permits remote access to a HW TPM.\n\n  The server type (mssim or raw) should agree with the TSS configuration.  mssim wrapes the packets\n  in the MS simulator bytes.  raw does not.\n\n  For the mssim format, the server socket remains open until the TPM_SESSION_END preamble is\n  received.  Then, the proxy loops back and reopens the connection for the next TSS client side\n  open.\n\n  Windows: Link with:\n\n  tbs.lib\n  ws2_32.lib\n*/\n\n#include <limits.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdint.h>\n#include <time.h>\n#include <errno.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tsstransmit.h>\n\n#ifdef TPM_WINDOWS \n#include <windows.h>\n#include <specstrings.h>\n#include <tbs.h>\n\n#define SOCKET_FD \tSOCKET\n#define SOCKLEN_T\tINT\n\n#endif\t/* TPM_WINDOWS */\n\n#ifdef TPM_POSIX        /* Posix sockets  */\n#include <unistd.h>\n#define SOCKET_FD \tint\n#define SOCKLEN_T\tsocklen_t\n#define INVALID_SOCKET \t-1\n#define SOCKET_ERROR \t-1\n\n#endif\t/* TPM_POSIX         */\n\n#define LOAD32(buffer,offset)         ( ntohl(*(uint32_t *)&(buffer)[(offset)]) )\n\n#ifndef SSIZE_MAX\n#define SSIZE_MAX INT_MAX\n#endif\n\n/* local constants */\n\n#define ERROR_CODE\t(TPM_RC)-1\n#define EOF_CODE\t(TPM_RC)-2\n#define DEFAULT_PORT \t2321\n#define PACKET_SIZE\t4096\n#define TRACE_SIZE\t(PACKET_SIZE * 4)\n\n#define SERVER_TYPE_MSSIM\t0\n#define SERVER_TYPE_RAW\t\t1\n#define TPM_SEND_COMMAND        8\t/* simulator command preamble */\n#define TPM_SESSION_END        20\n\n/* local prototypes */\n\nvoid printUsage(void);\nlong getArgs(short *port,\n\t     int *verbose,\n\t     char **logFileName,\n\t     int argc,\n\t     char **argv);\nvoid logAll(const char *message, unsigned long length, const unsigned char* buff);\n\nTPM_RC socketInit(SOCKET_FD *sock_fd, short port);\nTPM_RC socketConnect(SOCKET_FD *accept_fd,\n\t\t     SOCKET_FD sock_fd,\n\t\t     short port);\nTPM_RC socketRead(SOCKET_FD accept_fd,\n\t\t  uint32_t\t*commandType,\n\t\t  char *buffer,\n\t\t  uint32_t *bufferLength,\n\t\t  size_t bufferSize);\nTPM_RC socketReadBytes(SOCKET_FD accept_fd,\n\t\t       char *buffer,\n\t\t       size_t nbytes);\nTPM_RC socketWrite(SOCKET_FD accept_fd,\n\t\t   const char *buffer,\n\t\t   size_t buffer_length);\nTPM_RC socketDisconnect(SOCKET_FD accept_fd);\n\n#ifdef TPM_WINDOWS\nvoid TPM_HandleWsaStartupError(const char *prefix,\n\t\t\t       int irc);\nvoid TPM_HandleWsaError(const char *prefix);\nvoid TPM_GetWsaStartupError(int status,\n\t\t\t    const char **error_string);\nvoid TPM_GetWsaError(const char **error_string);\n\nvoid TPM_GetTBSError(const char *prefix,\n\t\t     TBS_RESULT rc);\n#endif\n\n/* global variable for trace logging */\n\nint \tverbose;\t\t/* verbose debug tracing */\nchar \t*logFilename;\t\t/* trace log file name */\nchar\tlogMsg[TRACE_SIZE];\t/* since it's big, put it here rather than on the stack */\n\n/* global socket server format type */\n\nint serverType = SERVER_TYPE_MSSIM;\t/* default MS simulator format */\n\n#define false 0\n#define true 1\n\nint main(int argc, char** argv)\n{\n    TPM_RC \t\trc = 0;\n    TPM_RC \t\ttrc = 0;\n    TSS_CONTEXT \t*tssContext = NULL;\t\t/* TPM connection */\n    time_t \t\tstart_time;\n    SOCKET_FD \t\tsock_fd;\t\t/* server socket */\n    SOCKET_FD \t\taccept_fd;    \t\t/* server accept socket for a packet */\n    int \t\tsocketOpened = FALSE;\n\n#if 0\n    TBS_HCONTEXT \thContext = 0;\n    TBS_CONTEXT_PARAMS2 contextParams;\n\n#endif\n    /* TPM command and response */\n    BYTE command[PACKET_SIZE];\n    uint32_t commandLength;\n    BYTE response[PACKET_SIZE];\n    uint32_t responseLength;\n\n    /* command line arguments */\n    short port;\t\t\t/* TCPIP server port */\n\n    /* command line argument defaults */\n    port = DEFAULT_PORT;\n    logFilename = NULL;\n    verbose = FALSE;\n\n    /* initialization */\n    setvbuf(stdout, 0, _IONBF, 0);\t/* output may be going through pipe */\n    start_time = time(NULL);\n\n    /* get command line arguments */\n    if (rc == 0) {\n\trc = getArgs(&port, &verbose, &logFilename,\n\t\t     argc, argv);\n    }\n    if (rc == 0) {\n\tif (verbose) printf(\"tpmproxy: start at %s\", ctime(&start_time));\n\tif (verbose) printf(\"tpmproxy: server type %s\\n\",\n\t\t\t    (serverType == SERVER_TYPE_MSSIM) ? \"MS simulator\" : \"raw\");\n    }\n    /* open / initialize server socket */\n    if (rc == 0) {\n\tif (verbose) printf(\"Opening socket at port %hu\\n\", port);\n\trc = socketInit(&sock_fd, port);\n\tif (rc != 0) {\n\t    printf(\"tpmproxy: socket open failed\\n\");\n\t}\n\telse {\n\t    socketOpened = TRUE;\n\t}\n    }\n    /* prepare for the HW TPM connection */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* regardless of the env variables, the proxy connects to the device */\n    if (rc == 0) {\n\trc = TSS_SetProperty(tssContext, TPM_INTERFACE_TYPE, \"dev\");\n    }\n    /* outer loop, socket connect or reconnect */\n    while (rc == 0) {\n\tuint32_t\tcommandType = TPM_SEND_COMMAND;\t/* for first time through inner loop */\n\n\t/* connect to the client application */\n\tif (rc == 0) {\n\t    if (verbose) printf(\"Connecting on socket %hu\\n\", port);\n\t    rc = socketConnect(&accept_fd, sock_fd, port);\n\t}\n\t/* inner loop, read socket, send command, get response, write socket */\n\twhile ((rc == 0) && (commandType == TPM_SEND_COMMAND)) {\n\n\t    /* read a command from client */\n\t    if ((rc == 0) && (commandType == TPM_SEND_COMMAND)) {\n\t\trc = socketRead(accept_fd,\n\t\t\t\t&commandType,\n\t\t\t\t(char *)command,\t/* windows wants signed */\n\t\t\t\t&commandLength,\n\t\t\t\tsizeof(command));\n\t    }\n\t    if ((rc == 0) && (commandType == TPM_SEND_COMMAND)) {\n\t\tlogAll(\"Command\", commandLength, command);\n\t    }\n\t    /* send command to TPM and receive response */\n\t    if ((rc == 0) && (commandType == TPM_SEND_COMMAND)) {\n\t\ttrc = TSS_Transmit(tssContext,\n\t\t\t\t  response, &responseLength,\n\t\t\t\t  command, commandLength,\n\t\t\t\t  NULL);\t\t/* message */\n\t\ttrc = trc;\t/* ignore TPM errors */\n\t    }\n\t    /* send response to client */\n\t    if ((rc == 0) && (commandType == TPM_SEND_COMMAND)) {\n\t\tlogAll(\"Response\", responseLength, response);\n\t\trc = socketWrite(accept_fd,\n\t\t\t\t (char *)response,\t/* windows wants signed char */\n\t\t\t\t responseLength);\n\t    }\n\t}\n    }\n    /* close socket */\n    if (socketOpened) {\n\tsocketDisconnect(sock_fd);\n    }\n    /* close TPM */\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (verbose) printf(\"tpmproxy: exit rc %08x\\n\", rc);\n    return rc;\n}\n\n/*\n  All the socket code is basically a cut and paste from the TPM 1.2 tpm_io.c\n*/\n\nTPM_RC socketInit(SOCKET_FD *sock_fd, short port)\n{\n    TPM_RC   \t\trc = 0;\n    int\t\t\tirc;\n    struct sockaddr_in \tserv_addr;\n    int \t\topt;\n#ifdef TPM_WINDOWS\n    WSADATA \t\twsaData;\n#endif\n\n#ifdef TPM_WINDOWS\n    /* initiate use of the Windows Sockets DLL 2.0 */\n    if (rc == 0) {\n\tif ((irc = WSAStartup(0x202,&wsaData)) != 0) {\t\t/* if not successful */\n\t    printf(\"socketInit: Error, WSAStartup()\\n\");\n\t    TPM_HandleWsaStartupError(\"socketInit:\", irc);\n\t    rc = ERROR_CODE;\n\t}\n    }\n#endif\n    /* create a tcpip protocol socket */\n    if (rc == 0) {\n\t/* if (verbose) printf(\" socketInit: Port %hu\\n\", port); */\n\t*sock_fd = socket(AF_INET, SOCK_STREAM, 0);\t/* tcpip socket */\n\tif (*sock_fd == INVALID_SOCKET) {\n\t    printf(\"socketInit: Error, server socket()\\n\");\n#ifdef TPM_WINDOWS\n\t    TPM_HandleWsaError(\"socketInit:\");\n#endif\n\t    rc = ERROR_CODE;\n\t}\n    }\n    if (rc == 0) {\n\tmemset(&serv_addr, 0, sizeof(serv_addr));\n\tserv_addr.sin_family = AF_INET;\t\t\t/* Internet socket */\n\tserv_addr.sin_port = htons(port);\t\t/* host to network byte order for short */\n\tserv_addr.sin_addr.s_addr = htonl(INADDR_ANY);\t/* host to network byte order for long */\n\topt = 1;\n\t/* Set SO_REUSEADDR before calling bind() for servers that bind to a fixed port number. */\n\t/* For boolean values, opt must be an int, but the setsockopt prototype is IMHO wrong.\n\t   It should take void *, but uses char *.  Hence the type cast. */\n\tirc = setsockopt(*sock_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt));\n\tif (irc == SOCKET_ERROR) {\n\t    printf(\"socketInit: Error, server setsockopt()\\n\");\n#ifdef TPM_WINDOWS\n\t    TPM_HandleWsaError(\"socketInit:\");\n#endif\n\t    socketDisconnect(*sock_fd);\n\t    rc = ERROR_CODE;\n\t}\n    }\n    /* bind the (local) server port name to the socket */\n    if (rc == 0) {\n\tirc = bind(*sock_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));\n\tif (irc == SOCKET_ERROR) {\n\t    printf(\"socketInit: Error, server bind()\\n\");\n\t    printf(\"socketInit: Is SW TPM listening on this port?\\n\");\n#ifdef TPM_WINDOWS\n\t    TPM_HandleWsaError(\"socketInit:\");\n#endif\n\t    socketDisconnect(*sock_fd);\n\t    rc = ERROR_CODE;\n\t}\n    }\n    /* listen for a connection to the socket */\n    if (rc == 0) {\n\tirc = listen(*sock_fd, SOMAXCONN);\n\tif (irc == SOCKET_ERROR) {\n\t    printf(\"socketInit: Error, server listen()\\n\");\n#ifdef TPM_WINDOWS\n\t    TPM_HandleWsaError(\"socketInit:\");\n#endif\n\t    socketDisconnect(*sock_fd);\n\t    rc = ERROR_CODE;\n\t}\n    }\n#ifdef TPM_WINDOWS\n    if (rc != 0) {\n\tWSACleanup();\n    }\n#endif\n    return rc;\n}\n\nTPM_RC socketConnect(SOCKET_FD *accept_fd,\n\t\t     SOCKET_FD sock_fd,\n\t\t     short port)\n{\n    TPM_RC\t\trc = 0;\n    SOCKLEN_T\t\tcli_len;\n    struct sockaddr_in \tcli_addr;\t\t/* Internet version of sockaddr */\n\n    /* accept a connection */\n    if (rc == 0) {\n\tcli_len = sizeof(cli_addr);\n\t/* block until connection from client */\n\tport = port;\n\t/* printf(\" socketConnect: Waiting for connection on port %hu ...\\n\", port); */\n\t*accept_fd = accept(sock_fd, (struct sockaddr *)&cli_addr, &cli_len);\n\tif (*accept_fd == SOCKET_ERROR) {\n\t    printf(\"socketConnect: Error, accept()\\n\");\n#ifdef TPM_WINDOWS\n\t    TPM_HandleWsaError(\"socketConnect: \");\n#endif\n\t    socketDisconnect(sock_fd);\n#ifdef TPM_WINDOWS\n\t    WSACleanup();\n#endif\n\t    rc = ERROR_CODE;\n\t}\n    }\n    return rc;\n}\n\n/* socketRead() reads a TPM command packet from the host\n\n   Puts the result in 'buffer' up to 'bufferSize' bytes.\n\n   On success, if commandType is TPM_SEND_COMMAND, the number of bytes in the buffer is equal to\n   'bufferLength' bytes.  If commandType is TPM_SESSION_END, return it.  The loop should restart.\n\n   This function is intended to be platform independent.\n*/\n\nTPM_RC socketRead(SOCKET_FD\taccept_fd,\t/* read/write file descriptor */\n\t\t  uint32_t\t*commandType,\n\t\t  char \t\t*buffer,\t/* output: command stream */\n\t\t  uint32_t \t*bufferLength,\t/* output: command stream length */\n\t\t  size_t \tbufferSize)\t/* input: max size of output buffer */\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tdone = false;\n    uint32_t\t\theaderSize;\t/* minimum required bytes in command through paramSize */\n    uint32_t\t\tparamSize;\t/* from command stream */\n    uint32_t\t\tcommandTypeNbo;\t/* MS simulator format preamble */\n    uint8_t \t\tlocality;\t/* MS simulator format preamble */\n    uint32_t \t\tlengthNbo;\t/* MS simulator format preamble */\n\n    /* if the MS simulator packet format */\n    if (serverType == SERVER_TYPE_MSSIM) {\n\t/* read and check the command */\n\tif (rc == 0) {\n\t    rc = socketReadBytes(accept_fd, (char *)&commandTypeNbo, sizeof(uint32_t));\n\t}\n\tif (rc == 0) {\n\t    *commandType = LOAD32(&commandTypeNbo, 0);\n\t    if (*commandType == TPM_SESSION_END) {\t/* client TSS termination request */\n\t\tdone = true;\n\t    }\n\t    else if (*commandType != TPM_SEND_COMMAND) {\n\t\tprintf(\"socketRead: Error, -mssim preamble is %08x not %08x\\n\",\n\t\t       *commandType, TPM_SEND_COMMAND);\n\t\trc = ERROR_CODE;\n\t    }\n\t}\n\t/* read and discard the locality */\n\tif ((rc == 0) && !done) {\n\t    rc = socketReadBytes(accept_fd, (char *)&locality, sizeof(uint8_t));\n\t}\n\t/* read and discard the redundant length */\n\tif ((rc == 0) && !done) {\n\t    rc = socketReadBytes(accept_fd, (char *)&lengthNbo, sizeof(uint32_t));\n\t}\n    }\n    /* check that the buffer can at least fit the command through the paramSize */\n    if ((rc == 0) && !done) {\n\theaderSize = sizeof(TPM_TAG) + sizeof(uint32_t);\n\tif (bufferSize < headerSize) {\n\t    printf(\"socketRead: Error, buffer size %lu less than minimum %lu\\n\",\n\t\t   (unsigned long)bufferSize, (unsigned long)headerSize);\n\t    rc = ERROR_CODE;\n\t}\n    }\n    /* read the command through the paramSize from the socket stream */\n    if ((rc == 0) && !done) {\n\trc = socketReadBytes(accept_fd, buffer, headerSize);\n\tif ((serverType != SERVER_TYPE_MSSIM) &&\n\t    (rc ==  EOF_CODE)) {\n\t    /* if in raw mode and connection closed, signal to start a new connection */\n\t    *commandType = TPM_SESSION_END;\t/* client TSS termination request */\n\t    done = true;\n\t    rc = 0;\n\t}\n    }\n    if ((rc == 0) && !done) {\n\t/* extract the paramSize value, last field in header */\n\tparamSize = LOAD32(buffer, headerSize - sizeof(uint32_t));\n\t*bufferLength = headerSize + paramSize - (sizeof(TPM_TAG) + sizeof(uint32_t));\n\tif (bufferSize < *bufferLength) {\n\t    printf(\"socketRead: Error, buffer size %lu is less than required %u\\n\",\n\t\t   (unsigned long)bufferSize, *bufferLength);\n\t    rc = ERROR_CODE;\n\t}\n    }\n    /* read the rest of the command (already read tag and paramSize) */\n    if ((rc == 0) && !done) {\n\trc = socketReadBytes(accept_fd,\n\t\t\t     buffer + headerSize,\n\t\t\t     paramSize - (sizeof(TPM_TAG) + sizeof(uint32_t)));\n    }\n    return rc;\n}\n\n/* socketReadBytes() reads nbytes from accept_fd and puts them in buffer.\n\n   The buffer has already been checked for sufficient size.\n*/\n\nTPM_RC socketReadBytes(SOCKET_FD accept_fd,\t/* read/write file descriptor */\n\t\t       char *buffer,\n\t\t       size_t nbytes)\n{\n    TPM_RC \trc = 0;\n    int \tnread = 0;\n    size_t \tnleft = nbytes;\n\n    /* read() is unspecified with nbytes too large */\n    if (rc == 0) {\n\tif (nleft > SSIZE_MAX) {\n\t    rc = ERROR_CODE;\n\t}\n    }\n    while ((rc == 0) && (nleft > 0)) {\n\tnread = recv(accept_fd, buffer, (int)nleft, 0);\n\tif ((nread == SOCKET_ERROR) ||\n\t    (nread < 0)) {       \t\t/* error */\n\t    printf(\"socketReadBytes: Error, read() error\\n\");\n#ifdef TPM_WINDOWS\n\t    TPM_HandleWsaError(\"socketReadBytes:\");\n#endif\n\t    socketDisconnect(accept_fd);\n            rc = ERROR_CODE;\n\t}\n\telse if (nread > 0) {\n\t    nleft -= nread;\n\t    buffer += nread;\n\t}\n\telse if (nread == 0) {  \t/* EOF */\n            rc = EOF_CODE;\n\t}\n    }\n    return rc;\n}\n\n/* socketWrite() writes buffer_length bytes from buffer to accept_fd.\n\n   In mmssim mode, it prepends the size and appends the acknowledgement.\n*/\n\nTPM_RC socketWrite(SOCKET_FD accept_fd,\t/* read/write file descriptor */\n\t\t   const char *buffer,\n\t\t   size_t buffer_length)\n{\n    TPM_RC \trc = 0;\n    int\t\tnwritten = 0;\n\n    /* write() is unspecified with buffer_length too large */\n    if (rc == 0) {\n\tif (buffer_length > SSIZE_MAX) {\n\t    rc = ERROR_CODE;\n\t}\n    }\n    /* if the MS simulator packet format */\n    if (serverType == SERVER_TYPE_MSSIM) {\n\t/* prepend the leading size */\n\tif (rc == 0) {\n\t    uint32_t bufferLengthNbo = htonl((uint32_t)buffer_length);\n\t    send(accept_fd, (const char *)&bufferLengthNbo, sizeof(uint32_t), 0);\n\t}\n    }\n    /* test that connection is open to write */\n    if (rc == 0) {\n\tif (accept_fd == SOCKET_ERROR) {\n\t    printf(\"socketWrite: Error, connection not open, fd %d\\n\",\n\t\t   (int)accept_fd);\n\t    rc = ERROR_CODE;\n\t}\n    }\n    while ((rc == 0) && (buffer_length > 0)) {\n\tnwritten = send(accept_fd, buffer, (int)buffer_length, 0);\n\tif ((nwritten == SOCKET_ERROR) ||\n\t    (nwritten < 0)) {\n\t    printf(\"socketWrite: Error, send()\\n\");\n#ifdef TPM_WINDOWS\n\t    TPM_HandleWsaError(\"socketWrite:\");\t/* report the error */\n#endif\n\t    socketDisconnect(accept_fd);\n\t    rc = ERROR_CODE;\n\t}\n\telse {\n\t    buffer_length -= nwritten;\n\t    buffer += nwritten;\n\t}\n    }\n    /* if the MS simulator packet format */\n    if (serverType == SERVER_TYPE_MSSIM) {\n\t/* append the trailing acknowledgement */\n\tif (rc == 0) {\n\t    uint32_t acknowledgement = 0;\n\t    send(accept_fd, (const char *)&acknowledgement, sizeof(uint32_t), 0);\n\t}\n    }\n    return rc;\n}\n\n/* socketDisconnect() breaks the connection between the TPM server and the host client\n\n*/\n\nTPM_RC socketDisconnect(SOCKET_FD accept_fd)\n{\n    TPM_RC \trc = 0;\n    int\t\tirc;\n\n    /* close the connection to the client */\n    if (verbose) printf(\"Closing socket\\n\");\n    if (rc == 0) {\n#ifdef TPM_WINDOWS\n\tirc = closesocket(accept_fd);\n#endif\n#ifdef TPM_POSIX\n\tirc = close(accept_fd);\n#endif\n\tif (irc == SOCKET_ERROR) {\n\t    printf(\"socketDisconnect: Error, closesocket()\\n\");\n\t    rc = ERROR_CODE;\n\t}\n    }\n    return rc;\n}\n\n#ifdef TPM_WINDOWS\n\nvoid TPM_HandleWsaStartupError(const char *prefix,\n\t\t\t       int irc)\n{\n    const char *error_string;\n\n    TPM_GetWsaStartupError(irc, &error_string);\n    printf(\"%s %s\\n\", prefix, error_string);\n    return;\n}\n\nvoid TPM_HandleWsaError(const char *prefix)\n{\n    const char *error_string;\n\n    TPM_GetWsaError(&error_string);\n    printf(\"%s %s\\n\", prefix, error_string);\n    return;\n}\n\nvoid TPM_GetWsaStartupError(int status,\n\t\t\t    const char **error_string)\n{\n    /* convert WSAStartup status to more useful text.  Copy the text to error_string */\n\n    switch(status) {\n      case WSASYSNOTREADY:\n\t*error_string = \"WSAStartup error: WSASYSNOTREADY underlying network subsystem not ready for \"\n\t\t\t\"network communication\";\n\tbreak;\n      case WSAVERNOTSUPPORTED:\n\t*error_string = \"WSAStartup error: WSAVERNOTSUPPORTED version requested not provided by WinSock \"\n\t\t\t\"implementation\";\n\tbreak;\n      case WSAEINPROGRESS:\n\t*error_string = \"WSAStartup error: WSAEINPROGRESS blocking WinSock 1.1 operation in progress\";\n\tbreak;\n      case WSAEPROCLIM:\n\t*error_string = \"WSAStartup error: WSAEPROCLIM Limit on number of tasks supported by WinSock \"\n\t\t\t\"implementation has been reached\";\n\tbreak;\n      case WSAEFAULT:\n\t*error_string = \"WSAStartup error: WSAEFAULT lpWSAData is not a valid pointer\";\n\tbreak;\n      default:\n\t*error_string = \"WSAStartup error: return code unknown\";\n\tbreak;\n    }\n    return;\n}\n\nvoid TPM_GetWsaError(const char **error_string)\n{\n    /* Use WSAGetLastError, and convert the resulting number\n       to more useful text.  Copy the text to error_string */\n\n    int error;\n\n    error = WSAGetLastError();\n    switch(error) {\n\n      case WSANOTINITIALISED :\n\t*error_string = \"A successful WSAStartup must occur before using this function\";\n\tbreak;\n      case WSAENETDOWN :\n\t*error_string = \"The network subsystem or the associated service provider has failed\";\n\tbreak;\n      case WSAEAFNOSUPPORT :\n\t*error_string = \"The specified address family is not supported\";\n\tbreak;\n      case WSAEINPROGRESS :\n\t*error_string = \"A blocking Windows Sockets 1.1 call is in progress, \"\n\t\t\t\"or the service provider is still processing a callback function\";\n\tbreak;\n      case WSAEMFILE:\n\t*error_string = \"No more socket descriptors are available\";\n\tbreak;\n      case WSAENOBUFS:\n\t*error_string = \"No buffer space is available\";\n\tbreak;\n      case WSAEPROTONOSUPPORT:\n\t*error_string = \"The specified protocol is not supported\";\n\tbreak;\n      case WSAEPROTOTYPE:\n\t*error_string = \"The specified protocol is the wrong type for this socket\";\n\tbreak;\n      case WSAESOCKTNOSUPPORT :\n\t*error_string = \"The specified socket type is not supported in this address family\";\n\tbreak;\n      case WSAEFAULT:\n\t*error_string = \"A parameter is too small, bad format, or bad value\";\n\tbreak;\n      case WSAEINVAL:\n\t*error_string = \"The socket has not been bound with bind, or listen not called\";\n\tbreak;\n      case WSAENETRESET:\n\t*error_string = \"The connection has been broken due to the remote host resetting\";\n\tbreak;\n      case WSAENOPROTOOPT:\n\t*error_string = \"The option is unknown or unsupported for the specified provider\";\n\tbreak;\n      case WSAENOTCONN:\n\t*error_string = \"Connection has been reset when SO_KEEPALIVE is set\";\n\tbreak;\n      case WSAENOTSOCK:\n\t*error_string = \"The descriptor is not a socket\";\n\tbreak;\n      case WSAEADDRINUSE:\n\t*error_string = \"The specified address is already in use\";\n\tbreak;\n      case WSAEISCONN:\n\t*error_string = \"The socket is already connected\";\n\tbreak;\n      case WSAEOPNOTSUPP:\n\t*error_string = \"The referenced socket is not of a type that supports the operation\";\n\tbreak;\n      case WSAEINTR:\n\t*error_string = \"The (blocking) call was canceled through WSACancelBlockingCall\";\n      case WSAEWOULDBLOCK:\n\t*error_string = \"The socket is marked as nonblocking and no connections are present to be accepted\";\n\tbreak;\n      case WSAESHUTDOWN:\n\t*error_string = \"The socket has been shut down; it is not possible to recv or send on a socket \"\n\t\t\t\"after shutdown has been invoked with how set to SD_RECEIVE or SD_BOTH\";\n\tbreak;\n      case WSAEMSGSIZE:\n\t*error_string = \"The message was too large to fit into the specified buffer and was truncated\";\n\tbreak;\n      case WSAECONNABORTED:\n\t*error_string = \"The virtual circuit was terminated due to a time-out or other failure. \"\n\t\t\t\"The application should close the socket as it is no longer usable\";\n\tbreak;\n      case WSAETIMEDOUT:\n\t*error_string = \"The connection has been dropped because of a network failure or because \"\n\t\t\t\"the peer system failed to respond\";\n\tbreak;\n      case WSAECONNRESET:\n\t*error_string = \"The virtual circuit was reset by the remote side executing a hard or abortive close. \"\n\t\t\t\"The application should close the socket as it is no longer usable. On a UDP datagram \"\n\t\t\t\"socket this error would indicate that a previous send operation resulted in an ICMP \"\n\t\t\t\"Port Unreachable message\";\n\tbreak;\n      case WSAEACCES:\n\t*error_string = \"The requested address is a broadcast address, but the appropriate flag was not set\";\n\tbreak;\n      case WSAEHOSTUNREACH:\n\t*error_string = \"The remote host cannot be reached from this host at this time\";\n\tbreak;\n\n      default:\n\t*error_string = \"unknown error type\\n\";\n\tbreak;\n    }\n    return;\n}\n\nvoid TPM_GetTBSError(const char *prefix,\n\t\t     TBS_RESULT rc)\n{\n    const char *error_string;\n\n    switch (rc) {\n\n\t/* error codes from the TBS html docs */\n      case TBS_SUCCESS:\n\terror_string = \"The function succeeded.\";\n\tbreak;\n      case TBS_E_INTERNAL_ERROR:\n\terror_string = \"An internal software error occurred.\";\n\tbreak;\n      case TBS_E_BAD_PARAMETER:\n\terror_string = \"One or more parameter values are not valid.\";\n\tbreak;\n      case TBS_E_INVALID_OUTPUT_POINTER:\n\terror_string = \"A specified output pointer is bad.\";\n\tbreak;\n      case TBS_E_INVALID_CONTEXT:\n\terror_string = \"The specified context handle does not refer to a valid context.\";\n\tbreak;\n      case TBS_E_INSUFFICIENT_BUFFER:\n\terror_string = \"The specified output buffer is too small.\";\n\tbreak;\n      case TBS_E_IOERROR:\n\terror_string = \"An error occurred while communicating with the TPM.\";\n\tbreak;\n      case TBS_E_INVALID_CONTEXT_PARAM:\n\terror_string = \"A context parameter that is not valid was passed when attempting to create a \"\n\t\t       \"TBS context.\";\n\tbreak;\n      case TBS_E_SERVICE_NOT_RUNNING:\n\terror_string = \"The TBS service is not running and could not be started.\";\n\tbreak;\n      case TBS_E_TOO_MANY_TBS_CONTEXTS:\n\terror_string = \"A new context could not be created because there are too many open contexts.\";\n\tbreak;\n      case TBS_E_TOO_MANY_RESOURCES:\n\terror_string = \"A new virtual resource could not be created because there are too many open \"\n\t\t       \"virtual resources.\";\n\tbreak;\n      case TBS_E_SERVICE_START_PENDING:\n\terror_string = \"The TBS service has been started but is not yet running.\";\n\tbreak;\n      case TBS_E_PPI_NOT_SUPPORTED:\n\terror_string = \"The physical presence interface is not supported.\";\n\tbreak;\n      case TBS_E_COMMAND_CANCELED:\n\terror_string = \"The command was canceled.\";\n\tbreak;\n      case TBS_E_BUFFER_TOO_LARGE:\n\terror_string = \"The input or output buffer is too large.\";\n\tbreak;\n      case TBS_E_TPM_NOT_FOUND:\n\terror_string = \"A compatible Trusted Platform Module (TPM) Security Device cannot be found \"\n\t\t       \"on this computer.\";\n\tbreak;\n      case TBS_E_SERVICE_DISABLED:\n\terror_string = \"The TBS service has been disabled.\";\n\tbreak;\n      case TBS_E_NO_EVENT_LOG:\n\terror_string = \"The TBS event log is not available.\";\n\tbreak;\n      case TBS_E_ACCESS_DENIED:\n\terror_string = \"The caller does not have the appropriate rights to perform the requested operation.\";\n\tbreak;\n      case TBS_E_PROVISIONING_NOT_ALLOWED:\n\terror_string = \"The TPM provisioning action is not allowed by the specified flags.\";\n\tbreak;\n      case TBS_E_PPI_FUNCTION_UNSUPPORTED:\n\terror_string = \"The Physical Presence Interface of this firmware does not support the \"\n\t\t       \"requested method.\";\n\tbreak;\n      case TBS_E_OWNERAUTH_NOT_FOUND:\n\terror_string = \"The requested TPM OwnerAuth value was not found.\";\n\tbreak;\n\n\t/* a few error codes from WinError.h */\n      case TPM_E_COMMAND_BLOCKED:\n\terror_string = \"The command was blocked.\";\n\tbreak;\n\n      default:\n\terror_string = \"unknown error type\\n\";\n\tbreak;\n\n    }\n    printf(\"%s %s\\n\", prefix, error_string);\n    return;\n}\n\n#endif /* TPM_WINDOWS */\n\n/* logging, tracing */\n\nvoid logAll(const char *message, unsigned long length, const unsigned char* buff)\n{\n    unsigned long i;\n    size_t \tnextChar = 0;\n    FILE \t*logFile;\t/* trace log file descriptor */\n\n    /* construct the log message, keep appending to the character string */\n    if (buff != NULL) {\n\tnextChar += sprintf(logMsg + nextChar, \"%s length %lu\\n \", message, length);\n\tfor (i = 0 ; i < length ; i++) {\n\t    if (i && !( i % 16 )) {\n\t\tnextChar += sprintf(logMsg + nextChar, \"\\n \");\n\t    }\n\t    nextChar += sprintf(logMsg + nextChar, \"%.2X \",buff[i]);\n\t}\n\tnextChar += sprintf(logMsg + nextChar, \"\\n\");\n    }\n    else {\n\tnextChar += sprintf(logMsg + nextChar, \"%s null\\n\", message);\n    }\n    if (verbose) printf(\"%s\", logMsg);\n    if (logFilename != NULL) {\n\t/* Open the log file if specified.  It's a hack to keep opening and closing the file for\n\t   each append, but it's easier that trying to catch a signal to close the file.  Windows\n\t   evidently doesn't automatically close the file when the program exits. */\n\tlogFile = fopen(logFilename, \"a\");\n\tif (logFile == NULL) {\n\t    printf(\"Error, opening %s for write failed, %s\\n\",\n\t\t   logFilename, strerror(errno));\n\t}\n\t/* if success, print and close */\n\telse {\n\t    fprintf(logFile, \"%s\", logMsg);\n\t    fclose(logFile);\n\t}\n    }\n    return;\n}\n\n/* parse the command line arguments */\n\nlong getArgs(short *port,\n\t     int *verbose,\n\t     char **logFilename,\n\t     int argc,\n\t     char **argv)\n{\n    long \trc = 0;\n    int\t\tirc;\n    int \ti;\n    FILE \t*logFile;\t/* trace log file descriptor */\n\n    /* get the command line arguments */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif ((strcmp(argv[i],\"-p\") == 0) ||\n\t    (strcmp(argv[i],\"--port\") == 0)) {\n\t    i++;\n\t    if (i < argc) {\n\t\tirc = sscanf(argv[i], \"%hu\", port);\n\t\tif (irc != 1) {\n\t\t    printf(\"-p --port (socket port) illegal value %s\\n\", argv[i]);\n\t\t    rc = ERROR_CODE;\n\t\t}\n\t    } else {\n\t\tprintf(\"-p --port (socket port) needs a value\\n\");\n\t\trc = ERROR_CODE;\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-raw\") == 0) {\n\t    serverType = SERVER_TYPE_RAW;\n\t}\n\telse if (strcmp(argv[i],\"-mssim\") == 0) {\n\t    serverType = SERVER_TYPE_MSSIM;\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t    rc = ERROR_CODE;\n\t}\n\telse if ((strcmp(argv[i],\"-v\") == 0) ||\n\t\t (strcmp(argv[i],\"--verbose\") == 0)) {\n\t    *verbose = TRUE;\n\t}\n\telse if ((strcmp(argv[i],\"-l\") == 0) ||\n\t\t (strcmp(argv[i],\"--log\") == 0)) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strlen(argv[i]) < FILENAME_MAX) {\n\t\t    *logFilename = argv[i];\n\t\t}\n\t\telse {\n\t\t    printf(\"-l --log (log file name) too long\\n\");\n\t\t    rc = ERROR_CODE;\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-l --log option (log file name) needs a value\\n\");\n\t\trc = ERROR_CODE;\n\t    }\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\",argv[i]);\n\t    printUsage();\n\t    rc = ERROR_CODE;\n\t}\n    }\n    /* erase old contents of log file */\n    if ((rc == 0) && (*logFilename != NULL)) {\n\tlogFile = fopen(*logFilename, \"w\");\n\tif (logFile == NULL) {\n\t    printf(\"Cannot open log file %s\\n\", *logFilename);\n\t    rc = ERROR_CODE;\n\t}\n\telse {\n\t    fclose(logFile);\n\t}\n    }\n    return rc;\n}\n\nvoid printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"tpmproxy\\n\");\n    printf(\"\\n\");\n    printf(\"Pass through connecting a TCPIP port to a hardware TPM\\n\");\n    printf(\"\\n\");\n    printf(\"\\t--port,-p <n> TCPIP server port (default 2321)\\n\");\n    printf(\"\\t-mssim use MS TPM 2.0 socket simulator packet format (default)\\n\");\n    printf(\"\\t\\twith TSS env variable TPM_SERVER_TYPE=mssim (default)\\n\");\n    printf(\"\\t-raw use TPM 2.0 packet format\\n\");\n    printf(\"\\t\\twith TSS env variable TPM_SERVER_TYPE=raw\\n\");\n    printf(\"\\t--verbose,-v verbose mode (default false)\\n\");\n    printf(\"\\t--log,-l log transactions into given file (default none)\\n\");\n    printf(\"\\t \\n\");\n    return;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tpmpublic2eccpoint.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t    TPM public key TPM2B_PUBLIC to TPM2B_ECC_POINT \t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2017 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tssmarshal.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    const char\t\t\t*publicKeyFilename = NULL;\n    const char\t\t\t*pointFilename = NULL;\n    TPM2B_PUBLIC\t\tpublic;\n    TPM2B_ECC_POINT \t\teccPoint2b;\n\n    tssUtilsVerbose = FALSE;\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ipu\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpublicKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipu option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pt\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpointFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pt option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (publicKeyFilename == NULL) {\n\tprintf(\"Missing public key parameter -ipu\\n\");\n\tprintUsage();\n    }\n    if (pointFilename == NULL) {\n\tprintf(\"Missing point file name parameter -pt\\n\");\n\tprintUsage();\n    }\n    /* read the TPM public key to a structure */\n    if (rc == 0) {\n\trc = TSS_File_ReadStructureFlag(&public,\n\t\t\t\t\t(UnmarshalFunctionFlag_t)TSS_TPM2B_PUBLIC_Unmarshalu,\n\t\t\t\t\tTRUE,\t\t\t/* NULL permitted */\n\t\t\t\t\tpublicKeyFilename);\n    }\n    if (rc == 0) {\n\tif (public.publicArea.type != TPM_ALG_ECC) {\n\t    printf(\"Public key parameter -ipu type %04x is not TPM_ALG_ECC\\n\",\n\t\t   public.publicArea.type);\n\t    printUsage();\n\t}\n    }\n    if (rc == 0) {\n\t/* copy the TPMS_ECC_POINT */\n\teccPoint2b.point = public.publicArea.unique.ecc;\n\t/* TSS_TPM2B_ECC_POINT_Marshal() fills in the redundant TPM2B_ECC_POINT size */\n\trc = TSS_File_WriteStructure(&eccPoint2b,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_ECC_POINT_Marshalu,\n\t\t\t\t     pointFilename);\n\t\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"tpmpublic2eccpoint: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"tpmpublic2eccpoint: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"tpmpublic2eccpoint\\n\");\n    printf(\"\\n\");\n    printf(\"Converts an EC TPM2B_PUBLIC to TPM2B_ECC_POINT.  The intended use case\\n\");\n    printf(\"is to convert the public key output of certain commands (TPM2_CreatePrimary,\\n\");\n    printf(\"TPM2_Create, TPM2_CreateLoaded, TPM2_ReadPublic) to a format useful for\\n\");\n    printf(\"TPM2_ZGen_2Phase.\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ipu\\tEC public key input file in TPM TPM2B_PUBLIC format\\n\");\n    printf(\"\\t-pt\\tEC public key output file in TPM TPM2B_ECC_POINT format\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tss.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    TSS Primary API \t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2018.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>\n#include <errno.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tss.h>\n#include \"tssproperties.h\"\n#include <ibmtss/tsstransmit.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n#ifndef TPM_TSS_NOCRYPTO\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/tsscryptoh.h>\n#endif\n#include <ibmtss/tssprintcmd.h>\n#ifdef TPM_TPM20\n#include \"tss20.h\"\n#endif\n#ifdef TPM_TPM12\n#include \"tss12.h\"\n#endif\n\n/* local prototypes */\n\nstatic TPM_RC TSS_Context_Init(TSS_CONTEXT *tssContext);\n\nextern int tssVerbose;\nextern int tssVverbose;\nextern int tssFirstCall;\n\n/* TSS_Create() creates and initializes the TSS Context.  It does NOT open a connection to the\n   TPM.*/\n\nTPM_RC TSS_Create(TSS_CONTEXT **tssContext)\n{\n    TPM_RC\t\trc = 0;\n\n    // printf(\"[TSS] TSS_Create()\\n\");\n    /* allocate the high level TSS structure */\n    if (rc == 0) {\n\t/* set to NULL for backward compatibility, caller may not have set tssContext to NULL before\n\t   the call */\n\t*tssContext = NULL;\n\trc = TSS_Malloc((unsigned char **)tssContext, sizeof(TSS_CONTEXT));\n    }\n    /* initialize the high level TSS structure */\n    if (rc == 0) {\n\trc = TSS_Context_Init(*tssContext);\n\t/* the likely cause of a failure is a bad environment variable */\n\tif (rc != 0) {\n\t    if (tssVerbose) printf(\"TSS_Create: TSS_Context_Init() failed\\n\");\n\t    free(*tssContext);\n\t    *tssContext = NULL;\n\t}\n    }\n    /* allocate and initialize the lower layer TSS context */\n    if (rc == 0) {\n\trc = TSS_AuthCreate(&((*tssContext)->tssAuthContext));\n    }\n    return rc;\n}\n\n/* TSS_Context_Init() on first call is used for any global library initialization.\n\n   On every call, it initializes the TSS context.\n*/\n\nstatic TPM_RC TSS_Context_Init(TSS_CONTEXT *tssContext)\n{\n    TPM_RC\t\trc = 0;\n\n    /* at the first call to the TSS, initialize global variables */\n    if (tssFirstCall) {\t\t/* tssFirstCall is a library global */\n#ifndef TPM_TSS_NOCRYPTO\n\t/* crypto module initializations, crypto library specific */\n\tif (rc == 0) {\n\t    rc = TSS_Crypto_Init();\n\t}\n#endif\n\t/* TSS properties that are global, not per TSS context */\n\tif (rc == 0) {\n\t    rc = TSS_GlobalProperties_Init();\n\t}\n\ttssFirstCall = FALSE;\n    }\n    /* TSS properties that are per context */\n    if (rc == 0) {\n\trc = TSS_Properties_Init(tssContext);\n    }\n#ifndef TPM_TSS_NOCRYPTO\n#ifndef TPM_TSS_NOFILE\n    if (rc == 0) {\n\trc = TSS_AES_KeyAllocate(&tssContext->tssSessionEncKey,\n\t\t\t\t &tssContext->tssSessionDecKey);\n    }\n    /* build the session encryption and decryption keys */\n    if (rc == 0) {\n\trc = TSS_AES_KeyGenerate(tssContext->tssSessionEncKey,\n\t\t\t\t tssContext->tssSessionDecKey);\n    }\n#endif\n#endif\n    return rc;\n}\n\n/* TSS_Delete() closes an open TPM connection, then free the TSS context memory.\n */\n\nTPM_RC TSS_Delete(TSS_CONTEXT *tssContext)\n{\n    TPM_RC rc = 0;\n\n    if (tssContext != NULL) {\n\tTSS_AuthDelete(tssContext->tssAuthContext);\n#ifdef TPM_TSS_NOFILE\n\t{\n\t    size_t i;\n\t    for (i = 0 ; i < (sizeof(tssContext->sessions) / sizeof(TSS_SESSIONS)) ; i++) {\n\t\ttssContext->sessions[i].sessionHandle = TPM_RH_NULL;\n\t\t/* erase any secrets */\n\t\tif (tssContext->sessions[i].sessionData != NULL) {\n\t\t    memset(tssContext->sessions[i].sessionData,\n\t\t\t   0, tssContext->sessions[i].sessionDataLength);\n\t\t}\n\t\tfree(tssContext->sessions[i].sessionData);\n\t\ttssContext->sessions[i].sessionData = NULL;\n\t\ttssContext->sessions[i].sessionDataLength = 0;\n\t    }\n\t}\n#endif\t/* TPM_TSS_NOFILE */\n#ifndef TPM_TSS_NOFILE\n#ifndef TPM_TSS_NOCRYPTO\n\tTSS_AES_KeyFree(tssContext->tssSessionEncKey,\n\t\t\ttssContext->tssSessionDecKey);\n#endif\n#endif\n\trc = TSS_Close(tssContext);\n\tfree(tssContext);\n    }\n    return rc;\n}\n\n/* TSS_Execute() performs the complete command / response process.\n\n   It sends the command specified by commandCode and the parameters 'in', returning the response\n   parameters 'out'.\n\n   ... varargs are\n\n   TPMI_SH_AUTH_SESSION sessionHandle,\n   const char *password,\n   unsigned int sessionAttributes\n\n   Terminates with TPM_RH_NULL, NULL, 0\n\n   Processes up to MAX_SESSION_NUM sessions.\n*/\n\nTPM_RC TSS_Execute(TSS_CONTEXT *tssContext,\n\t\t   RESPONSE_PARAMETERS *out,\n\t\t   COMMAND_PARAMETERS *in,\n\t\t   EXTRA_PARAMETERS *extra,\n\t\t   TPM_CC commandCode,\n\t\t   ...)\n{\n    TPM_RC\t\trc = 0;\n    va_list\t\tap;\n    int \t\ttpm20Command;\n    int \t\ttpm12Command;\n\n    if (rc == 0) {\n\ttpm20Command = (((commandCode >= TPM_CC_FIRST) && (commandCode <=TPM_CC_LAST)) || /* base */\n\t\t\t((commandCode >= 0x20000000) && (commandCode <= 0x2000ffff)));\t/* vendor */\n\ttpm12Command = ((commandCode <= 0x000000ff) ||\t\t/* base */\n\t\t\t((commandCode >= 0x40000000) && (commandCode <= 0x4000ffff)));\t/* TSC */\n\tif (!tpm20Command && !tpm12Command) {\n\t    if (tssVerbose) printf(\"TSS_Execute: commandCode %08x unsupported\\n\",\n\t\t\t\t   commandCode);\n\t    rc = TSS_RC_COMMAND_UNIMPLEMENTED;\n\t    \n\t}\n\tif (tpm20Command && tpm12Command) {\n\t    if (tssVerbose) printf(\"TSS_Execute: commandCode %08x is both TPM 1.2 and TPM 2.0\\n\",\n\t\t\t\t   commandCode);\n\t    rc = TSS_RC_FAIL;\n\t}\n    }\n    if (rc == 0) {\n\tva_start(ap, commandCode);\n\tif (tpm20Command) {\n#ifdef TPM_TPM20\n\t    tssContext->tpm12Command = FALSE;\n\t    rc = TSS_Execute20(tssContext,\n\t\t\t       out,\n\t\t\t       in,\n\t\t\t       (EXTRA_PARAMETERS *)extra,\n\t\t\t       commandCode,\n\t\t\t       ap);\n#else\n\t    if (tssVerbose) printf(\"TSS_Execute: commandCode is TPM 1.2, TSS is TPM 2.0 only\\n\");\n\t    rc = TSS_RC_COMMAND_UNIMPLEMENTED;\n#endif\n\t}\n\tif (tpm12Command) {\n#ifdef TPM_TPM12\n\t    tssContext->tpm12Command = TRUE;\n\t    rc = TSS_Execute12(tssContext,\n\t\t\t       out,\n\t\t\t       in,\n\t\t\t       (EXTRA12_PARAMETERS *)extra,\n\t\t\t       commandCode,\n\t\t\t       ap);\n#else\n\t    if (tssVerbose) printf(\"TSS_Execute: commandCode is TPM 2.0, TSS is TPM 1.2 only\\n\");\n\t    rc = TSS_RC_COMMAND_UNIMPLEMENTED;\n#endif\n\t}\t\n\tva_end(ap);\n    }\n    return rc;\n}\n\n\n"
  },
  {
    "path": "ibmtss-ftpm/tss12.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    TSS Primary API for TPM 1.2\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2018 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>\n#include <errno.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include \"tssauth.h\"\n#include <ibmtss/tss.h>\n#include \"tssproperties.h\"\n#include <ibmtss/tsstransmit.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tssprintcmd.h>\n#include <ibmtss/tpmconstants12.h>\n#include \"tss12.h\"\n#include \"tssauth12.h\"\n\n/* Files:\n\n   hxxxxxxxx.bin - session context\n*/\n\n/* NOTE Synchronize with\n\n   TSS_HmacSession12_InitContext\n   TSS_HmacSession12_Unmarshal\n   TSS_HmacSession12_Marshal\n*/\n\ntypedef struct TSS_HMAC12_CONTEXT {\n    TPM_AUTHHANDLE\t\tauthHandle;\t\t/* the authorization session handle */\n    TPM_NONCE\t\t\tnonceEven;\t\t/* from the TPM in response */\n    TPM_NONCE\t\t\tnonceEvenOSAP;\t\t/* from the TPM for OSAP in response */\n    TPMT_HA \t\t\tsharedSecret;\t\t/* from KDF at OSAP session creation */\n    /* uint16 */\n    /* LSB is type of entityValue */\n    /* MSB is ADIP encryption scheme */\n    TPM_ENTITY_TYPE \t\tentityType;\t\t/* The type of entity in use */\n    UINT32 \t\t\tentityValue; \t\t/* The selection value based on entityType,\n\t\t\t\t\t\t\t   e.g. a keyHandle #, TPM_RH_NULL for OIAP\n\t\t\t\t\t\t\t   session  */\n    /* Items below this line are for the lifetime of one command.  They are not saved and loaded. */\n    TPM_NONCE\t\t\tnonceOdd;\t\t/* from the TSS in command */\n    TPM_NONCE\t\t\tnonceOddOSAP;\t\t/* from the TSS for OSAP in command */\n    /* for TPM 1.2, OIAP SHA-1 of password, OSAP sharedSecret */\n    TPMT_HA \t\t\thmacKey;\n} TSS_HMAC12_CONTEXT;\n\n\n/* functions for command pre- and post- processing */\n\ntypedef TPM_RC (*TSS_PreProcessFunction_t)(TSS_CONTEXT *tssContext,\n\t\t\t\t\t   COMMAND_PARAMETERS *in,\n\t\t\t\t\t   EXTRA12_PARAMETERS *extra);\ntypedef TPM_RC (*TSS_ChangeAuthFunction_t)(TSS_CONTEXT *tssContext,\n\t\t\t\t\t   TSS_HMAC12_CONTEXT *session,\n\t\t\t\t\t   size_t handleNumber,\n\t\t\t\t\t   COMMAND_PARAMETERS *in);\ntypedef TPM_RC (*TSS_PostProcessFunction_t)(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    COMMAND_PARAMETERS *in,\n\t\t\t\t\t    RESPONSE_PARAMETERS *out,\n\t\t\t\t\t    EXTRA12_PARAMETERS *extra);\n\nstatic TPM_RC TSS_PR_CreateWrapKey(TSS_CONTEXT *tssContext,\n\t\t\t\t   CreateWrapKey_In *in,\n\t\t\t\t   void *extra);\nstatic TPM_RC TSS_PR_MakeIdentity(TSS_CONTEXT *tssContext,\n\t\t\t\t  MakeIdentity_In *in,\n\t\t\t\t  void *extra);\nstatic TPM_RC TSS_PR_NV_DefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t\t    NV_DefineSpace_In *in,\n\t\t\t\t    void *extra);\n#if 0\nstatic TPM_RC TSS_PR_Seal(TSS_CONTEXT *tssContext,\n\t\t\t  Seal_in *In,\n\t\t\t  void *extra);\nstatic TPM_RC TSS_PR_Sealx(TSS_CONTEXT *tssContext,\n\t\t\t   Sealx_in *In,\n\t\t\t   void *extra);\n\n#endif\nstatic TPM_RC TSS_PO_FlushSpecific(TSS_CONTEXT *tssContext,\n\t\t\t\t   FlushSpecific_In *in,\n\t\t\t\t   void *out,\n\t\t\t\t   void *extra);\nstatic TPM_RC TSS_PR_OSAP(TSS_CONTEXT *tssContext,\n\t\t\t  OSAP_In *in,\n\t\t\t  OSAP_Extra *extra);\nstatic TPM_RC TSS_PO_OIAP(TSS_CONTEXT *tssContext,\n\t\t\t  void *in,\n\t\t\t  OIAP_Out *out,\n\t\t\t  void *extra);\nstatic TPM_RC TSS_PO_OSAP(TSS_CONTEXT *tssContext,\n\t\t\t  OSAP_In *in,\n\t\t\t  OSAP_Out *out,\n\t\t\t  OSAP_Extra *extra);\n\ntypedef struct TSS_TABLE {\n    TPM_CC \t\t\tcommandCode;\n    TSS_PreProcessFunction_t\tpreProcessFunction;\n    TSS_ChangeAuthFunction_t\tchangeAuthFunction;\n    TSS_PostProcessFunction_t \tpostProcessFunction;\n} TSS_TABLE;\n\n/* FIXME offsets\n   changeauth +16, createownerdel, createkeydel -45\n   createwrapkey +14, +34\n   cmkcreatekey, changeauthowner +14\n   changeauth 16\n*/\n\n/* session handles numbers\n   #0 of 1 seal, sealx, createwrapkey, cmk_create, changeauthowner, del_ckd, del_cod, nv_define, createctr\n   #1 of 2 changeauth\n*/\n   \n\nstatic const TSS_TABLE tssTable [] = {\n\t\t\t\t \n    {TPM_ORD_Init, NULL, NULL, NULL},\n    {TPM_ORD_ActivateIdentity, NULL, NULL, NULL},\n    {TPM_ORD_ContinueSelfTest, NULL, NULL, NULL},\n    {TPM_ORD_CreateWrapKey, (TSS_PreProcessFunction_t)TSS_PR_CreateWrapKey, NULL, NULL},\n    {TPM_ORD_CreateEndorsementKeyPair, NULL, NULL, NULL},\n    {TPM_ORD_Extend, NULL, NULL, NULL},\n    {TPM_ORD_FlushSpecific, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_FlushSpecific},\n    {TPM_ORD_GetCapability, NULL, NULL, NULL},\n    {TPM_ORD_MakeIdentity, (TSS_PreProcessFunction_t)TSS_PR_MakeIdentity, NULL, NULL},\n    {TPM_ORD_OIAP, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_OIAP},\n    {TPM_ORD_OSAP, (TSS_PreProcessFunction_t)TSS_PR_OSAP, NULL, (TSS_PostProcessFunction_t)TSS_PO_OSAP},\n    {TPM_ORD_OwnerReadInternalPub, NULL, NULL, NULL},\n    {TPM_ORD_NV_DefineSpace, (TSS_PreProcessFunction_t)TSS_PR_NV_DefineSpace, NULL, NULL},\n    {TPM_ORD_NV_ReadValue, NULL, NULL, NULL},\n    {TPM_ORD_NV_ReadValueAuth, NULL, NULL, NULL},\n    {TPM_ORD_NV_WriteValue, NULL, NULL, NULL},\n    {TPM_ORD_NV_WriteValueAuth, NULL, NULL, NULL},\n    {TPM_ORD_PcrRead, NULL, NULL, NULL},\n    {TPM_ORD_PCR_Reset, NULL, NULL, NULL},\n#if 0\n    {TPM_ORD_Seal, (TSS_PreProcessFunction_t)TSS_PR_Seal, NULL, NULL},\n    {TPM_ORD_Sealx, (TSS_PreProcessFunction_t)TSS_PR_Sealx, NULL, NULL},\n#endif\n    {TPM_ORD_Startup, NULL, NULL, NULL},\n};\n\n/* local prototypes */\n\n\nstatic TPM_RC TSS_Execute12_valist(TSS_CONTEXT *tssContext,\n\t\t\t\t   COMMAND_PARAMETERS *in,\n\t\t\t\t   va_list ap);\n\nstatic TPM_RC TSS_Command_PreProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t       TPM_CC commandCode,\n\t\t\t\t       COMMAND_PARAMETERS *in,\n\t\t\t\t       EXTRA12_PARAMETERS *extra);\nstatic TPM_RC TSS_Response_PostProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t\t COMMAND_PARAMETERS *in,\n\t\t\t\t\t RESPONSE_PARAMETERS *out,\n\t\t\t\t\t EXTRA12_PARAMETERS *extra);\n\nstatic TPM_RC TSS_HmacSession12_GetContext(TSS_HMAC12_CONTEXT **session);\nstatic void TSS_HmacSession12_InitContext(TSS_HMAC12_CONTEXT *session);\nstatic void TSS_HmacSession12_FreeContext(TSS_HMAC12_CONTEXT *session);\nstatic TPM_RC TSS_HmacSession12_SaveSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    TSS_HMAC12_CONTEXT *session);\nstatic TPM_RC TSS_HmacSession12_LoadSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    TSS_HMAC12_CONTEXT *session,\n\t\t\t\t\t    TPM_AUTHHANDLE authHandle);\nstatic TPM_RC TSS_HmacSession12_Marshal(TSS_HMAC12_CONTEXT *source,\n\t\t\t\t\tuint16_t *written,\n\t\t\t\t\tuint8_t **buffer,\n\t\t\t\t\tuint32_t *size);\nstatic TPM_RC TSS_HmacSession12_DeleteSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t      TPM_AUTHHANDLE handle);\nstatic TPM_RC TSS_HmacSession12_Unmarshal(TSS_HMAC12_CONTEXT *target,\n\t\t\t\t\t  uint8_t **buffer, uint32_t *size);\nstatic TPM_RC TSS_HmacSession12_SetHMAC(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t\tsize_t numSessions,\n\t\t\t\t\tTSS_HMAC12_CONTEXT *session[],\n\t\t\t\t\tTPMS_AUTH12_COMMAND *authCommand[],\n\t\t\t\t\tTPM_AUTHHANDLE sessionHandle[],\n\t\t\t\t\tunsigned int sessionAttributes[]);\nstatic TPM_RC TSS_HmacSession12_Verify(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t       size_t\t\tnumSessions,\n\t\t\t\t       TSS_HMAC12_CONTEXT *session[],\n\t\t\t\t       TPMS_AUTH12_RESPONSE *authResponse[]);\nstatic TPM_RC TSS_HmacSession12_Continue(TSS_CONTEXT *tssContext,\n\t\t\t\t\t TSS_HMAC12_CONTEXT *session,\n\t\t\t\t\t TPMS_AUTH12_RESPONSE *authR);\nstatic TPM_RC TSS_Command_Decrypt(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t  struct TSS_HMAC12_CONTEXT *session[],\n\t\t\t\t  TPM_AUTHHANDLE sessionHandle[]);\nstatic TPM_RC TSS_Command_DecryptXor(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t     TSS_HMAC12_CONTEXT *session,\n\t\t\t\t     uint8_t *encAuth,\n\t\t\t\t     int parameterNumber);\n\nextern int tssVerbose;\nextern int tssVverbose;\n\n/* TSS_Execute12() performs the complete command / response process.\n\n   It sends the command specified by commandCode and the parameters 'in', returning the response\n   parameters 'out'.\n\n   ... varargs are\n\n   TPM_AUTHHANDLE authHandle,\n   const char *password,\n   unsigned int sessionAttributes\n\n   Terminates with TPM_RH_NULL, NULL, 0\n\n   Processes up to MAX_SESSION_NUM sessions.\n*/\n\nTPM_RC TSS_Execute12(TSS_CONTEXT *tssContext,\n\t\t     RESPONSE_PARAMETERS *out,\n\t\t     COMMAND_PARAMETERS *in,\n\t\t     EXTRA12_PARAMETERS *extra,\n\t\t     TPM_CC commandCode,\n\t\t     va_list ap)\n{\n    TPM_RC\t\trc = 0;\n\n    /* create a TSS authorization context */\n    if (rc == 0) {\n\tTSS_InitAuthContext(tssContext->tssAuthContext);\n    }\n    /* handle any command specific command pre-processing */\n    if (rc == 0) {\n\trc = TSS_Command_PreProcessor(tssContext,\n\t\t\t\t      commandCode,\n\t\t\t\t      in,\n\t\t\t\t      extra);\n    }\n    /* marshal input parameters */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute12: Command %08x marshal\\n\", commandCode);\n\trc = TSS_Marshal12(tssContext->tssAuthContext,\n\t\t\t   in,\n\t\t\t   commandCode);\n    }\n    /* execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute12_valist(tssContext, in, ap);\n    }\n    /* unmarshal the response parameters */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute12: Command %08x unmarshal\\n\", commandCode);\n\trc = TSS_Unmarshal12(tssContext->tssAuthContext, out);\n    }\n    /* handle any command specific response post-processing */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute12: Command %08x post processor\\n\", commandCode);\n\trc = TSS_Response_PostProcessor(tssContext,\n\t\t\t\t\tin,\n\t\t\t\t\tout,\n\t\t\t\t\textra);\n    }\n    return rc;\n}\n\n/* TSS_Execute12_valist() transmits the marshaled command and receives the marshaled response.\n\n   varargs are TPM_AUTHHANDLE sessionHandle, const char *password, unsigned int sessionAttributes\n\n   Terminates with sessionHandle TPM_RH_NULL\n\n   Processes up to MAX_SESSION_NUM sessions.  It handles HMAC generation and command and response\n   parameter encryption.  It loads each session context, rolls nonces, and saves or deletes the\n   session context.\n*/\n\nstatic TPM_RC TSS_Execute12_valist(TSS_CONTEXT *tssContext,\n\t\t\t\t   COMMAND_PARAMETERS *in,\n\t\t\t\t   va_list ap)\n{\n    TPM_RC\t\trc = 0;\n    size_t\t\ti = 0;\n    size_t\t\tnumSessions = 0;\n\n    /* the vararg parameters */\n    TPM_AUTHHANDLE \tsessionHandle[MAX_SESSION_NUM];\n    const char \t\t*password[MAX_SESSION_NUM];\n    unsigned int\tsessionAttributes[MAX_SESSION_NUM];\n\n    /* structures filled in */\n    TPMS_AUTH12_COMMAND authCommand[MAX_SESSION_NUM];\n    TPMS_AUTH12_RESPONSE authResponse[MAX_SESSION_NUM];\n    \n    /* pointer to the above structures as used */\n    TPMS_AUTH12_COMMAND *authC[MAX_SESSION_NUM];\n    TPMS_AUTH12_RESPONSE *authR[MAX_SESSION_NUM];\n\n    /* TSS sessions */\n    TSS_HMAC12_CONTEXT \t*session[MAX_SESSION_NUM];\n\n    in = in;\n    ap = ap;\n    \n    /* Step 1: initialization */\n    if (tssVverbose) printf(\"TSS_Execute12_valist: Step 1: initialization\\n\");\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) ; i++) {\n\tauthC[i] = NULL;\t\t/* array of TPMS_AUTH12_COMMAND structures, NULL for\n\t\t\t\t\t   TSS_SetCmdAuths */\n\tauthR[i] = NULL;\t\t/* array of TPMS_AUTH12_RESPONSE structures, NULL for\n\t\t\t\t\t   TSS_GetRspAuths */\n\tsession[i] = NULL;\t\t/* for free, used for HMAC and encrypt/decrypt sessions */\n\t/* the varargs list inputs */\n\tsessionHandle[i] = TPM_RH_NULL;\n\tpassword[i] = NULL;\n\tsessionAttributes[i] = 0;\n    }\n    /* Step 2: gather the command authorizations */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) ; i++) {\n \tsessionHandle[i] = va_arg(ap, TPM_AUTHHANDLE);\t\t/* first vararg is the session\n\t\t\t\t\t\t\t\t   handle */\n\tpassword[i] = va_arg(ap, const char *);\t\t\t/* second vararg is the password */\n\tsessionAttributes[i] = va_arg(ap, unsigned int);\t/* third argument is\n\t\t\t\t\t\t\t\t   sessionAttributes */\n\tsessionAttributes[i] &= 0xff;\t\t\t\t/* is uint8_t */\n\n\tif (sessionHandle[i] != TPM_RH_NULL) {\t\t\t/* varargs termination value */ \n\n\t    if (tssVverbose) printf(\"TSS_Execute12_valist: Step 2: authorization %u\\n\",\n\t\t\t\t    (unsigned int)i);\n\t    if (tssVverbose) printf(\"TSS_Execute12_valist: session %u handle %08x\\n\",\n\t\t\t\t    (unsigned int)i, sessionHandle[i]);\n\t    /* make used, non-NULL for command and response varargs */\n\t    authC[i] = &authCommand[i];\n\t    authR[i] = &authResponse[i];\n\n\t    /* initialize a TSS HMAC session */\n\t    if (rc == 0) {\n\t\trc = TSS_HmacSession12_GetContext(&session[i]);\n\t    }\n\t    /* load the session created by either OIAP or OSAP */\n\t    if (rc == 0) {\n\t\trc = TSS_HmacSession12_LoadSession(tssContext, session[i], sessionHandle[i]);\n\t    }\n\t    if (rc == 0) {\n\t\tif (session[i]->entityValue == TPM_RH_NULL) {\t/* if OIAP, use password */\n\t\t    if (password[i] != NULL) {\t/* if a password was specified, hash it */\n\t\t\t/* hash the password, algorithm set to SHA-1 at initialization */\n\t\t\trc = TSS_Hash_Generate(&session[i]->hmacKey,\n\t\t\t\t\t       strlen(password[i]), (unsigned char *)password[i],\n\t\t\t\t\t       0, NULL);\n\t\t    }\n\t\t    /* TPM 1.2 convention seems to use all zeros as a well known auth */\n\t\t    else {\n\t\t\tmemset((uint8_t *)&session[i]->hmacKey.digest, 0, SHA1_DIGEST_SIZE);\n\t\t    }\n\t\t}\n\t\telse {\t\t/* use shared secret from OSAP setup */\n\t\t    memcpy((uint8_t *)&session[i]->hmacKey.digest,\n\t\t\t   (uint8_t *)&session[i]->sharedSecret.digest, SHA1_DIGEST_SIZE);\n\t\t}\n\t    }\n\t}\n\telse {\n\t    numSessions = i;\t/* record the number of auth sessions */\n\t    break;\n\t}\n    }\n    /* Step 3: Roll nonceOdd, save in the session context for the response */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tif (tssVverbose)\n\t    printf(\"TSS_Execute12_valist: Step 3: nonceOdd for session %08x\\n\", sessionHandle[i]);\n\tif (rc == 0) {\n\t    rc = TSS_RandBytes(session[i]->nonceOdd, SHA1_DIGEST_SIZE);\n\t    memcpy(authC[i]->nonce, session[i]->nonceOdd, SHA1_DIGEST_SIZE);\n\t}\n    }\n    /* Step 4: Calculate the HMAC key */\n    /* not needed for TPM 1.2, HMAC key is either hash of password or OSAP shared secret, calculated\n       in previous step */\n    /* Step 5: TPM_ENCAUTH encryption */\n    if ((rc == 0) && (numSessions > 0)) {\n\tif (tssVverbose) printf(\"TSS_Execute12_valist: Step 5: command ADIP encrypt\\n\");\n\trc = TSS_Command_Decrypt(tssContext->tssAuthContext,\n\t\t\t\t session,\n\t\t\t\t sessionHandle);\n    }\n    /* Step 6: for each HMAC session, calculate cpHash, calculate the HMAC, and set it in\n       TPMS_AUTH12_COMMAND */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute12_valist: Step 6: calculate HMACs\\n\");\n\trc = TSS_HmacSession12_SetHMAC(tssContext->tssAuthContext,\t/* TSS auth context */\n\t\t\t\t       numSessions, \n\t\t\t\t       session,\t\t/* TSS session contexts */\n\t\t\t\t       authC,\t\t/* output: command authorizations */\n\t\t\t\t       sessionHandle,\t/* list of session handles for the command */\n\t\t\t\t       sessionAttributes /* attributes for this command */\n\t\t\t\t       );\n    }\n    /* Step 7: set the command authorizations in the TSS command stream */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute12_valist: Step 7: set command authorizations\\n\");\n\trc = TSS_SetCmdAuths12(tssContext->tssAuthContext,\n\t\t\t       numSessions, \n\t\t\t       authC);\n    }\n    /* Step 8: process the command.  Normally returns the TPM response code. */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute12_valist: Step 8: process the command\\n\");\n\trc = TSS_AuthExecute(tssContext);\n    }\n    /* Step 9: get the response authorizations from the TSS response stream */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute12_valist: Step 9: get response authorizations\\n\");\n\trc = TSS_GetRspAuths12(tssContext->tssAuthContext,\n\t\t\t       numSessions, \n\t\t\t       authR);\n    }\n    /* Step 10: process the response authorizations, validate the HMAC */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute12_valist: Step 10: verify HMAC\\n\");\n#if 0\n\tfor (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\t    rc = TSS_Command_ChangeAuthProcessor(tssContext, session[i], i, in);\n\t}\n#endif\n\tif (rc == 0) {\n\t    rc = TSS_HmacSession12_Verify(tssContext->tssAuthContext, /* authorization\n\t\t\t\t\t\t\t\t\t context */\n\t\t\t\t\t  numSessions, \n\t\t\t\t\t  session,\t/* TSS session context */\n\t\t\t\t\t  authR);\t/* input: response authorization */\n\t}\n    }\n    /* Step 12: process the response continue flag */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tif (tssVverbose) printf(\"TSS_Execute12_valist: Step 12: process continue flag %08x\\n\",\n\t\t\t\tsessionHandle[i]);\n\trc = TSS_HmacSession12_Continue(tssContext, session[i], authR[i]);\n    }\n    /* cleanup */\n    for (i = 0 ; i < MAX_SESSION_NUM ; i++) {\n\tTSS_HmacSession12_FreeContext(session[i]);\n    }\n    return rc;\n}\n\n/*\n  HMAC Session\n*/\n\n/* TSS_HmacSession12_GetContext() allocates and initializes a TSS_HMAC12_CONTEXT structure */\n\nstatic TPM_RC TSS_HmacSession12_GetContext(TSS_HMAC12_CONTEXT **session)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n        rc = TSS_Malloc((uint8_t **)session, sizeof(TSS_HMAC12_CONTEXT));\n    }\n    if (rc == 0) {\n\tTSS_HmacSession12_InitContext(*session);\n    }\n    return rc;\n}\n\n/* TSS_HmacSession12_InitContext() initializes a TSS_HMAC12_CONTEXT structure */\n\nstatic void TSS_HmacSession12_InitContext(TSS_HMAC12_CONTEXT *session)\n{\n    session->authHandle = TPM_RH_NULL;\n    memset(session->nonceEven, 0, SHA1_DIGEST_SIZE);\n    memset(session->nonceEvenOSAP, 0, SHA1_DIGEST_SIZE);\n    memset(&session->sharedSecret.digest, 0, SHA1_DIGEST_SIZE);\n    memset(session->nonceOdd, 0, SHA1_DIGEST_SIZE);\n    memset(session->nonceOddOSAP, 0, SHA1_DIGEST_SIZE);\n    session->hmacKey.hashAlg = TPM_ALG_SHA1;\n    memset((uint8_t *)&session->hmacKey.digest, 0, SHA1_DIGEST_SIZE);\n    return;\n}\n\n/* TSS_HmacSession12_FreeContext() initializes (to erase secrets) and frees a TSS_HMAC12_CONTEXT\n   structure */\n\nstatic void TSS_HmacSession12_FreeContext(TSS_HMAC12_CONTEXT *session)\n{\n    if (session != NULL) {\n\tTSS_HmacSession12_InitContext(session);\n\tfree(session);\n    }\n    return;\n}\n\n/* TSS_HmacSession12_SaveSession() marshals, optionally encrypts, and saves a TSS_HMAC12_CONTEXT\n   structure */ \n\nstatic TPM_RC TSS_HmacSession12_SaveSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    TSS_HMAC12_CONTEXT *session)\n{\n    TPM_RC\trc = 0;\n    uint8_t \t*buffer = NULL;\t\t/* marshaled TSS_HMAC12_CONTEXT */\n    uint16_t\twritten = 0;\n    char\tsessionFilename[TPM_DATA_DIR_PATH_LENGTH];\n    uint8_t \t*outBuffer = NULL;\n    uint32_t \toutLength;\n    \n    if (tssVverbose) printf(\"TSS_HmacSession12_SaveSession: handle %08x\\n\", session->authHandle);\n    if (rc == 0) {\n\trc = TSS_Structure_Marshal(&buffer,\t/* freed @1 */\n\t\t\t\t   &written,\n\t\t\t\t   session,\n\t\t\t\t   (MarshalFunction_t)TSS_HmacSession12_Marshal);\n    }\n    if (rc == 0) {\n\t/* if the flag is set, encrypt the session state before store */\n\tif (tssContext->tssEncryptSessions) {\n\t    rc = TSS_AES_Encrypt(tssContext->tssSessionEncKey,\n\t\t\t\t &outBuffer,   \t/* output, freed @2 */\n\t\t\t\t &outLength,\t/* output */\n\t\t\t\t buffer,\t/* input */\n\t\t\t\t written);\t/* input */\n\t}\n\t/* else store the session state in plaintext */\n\telse {\n\t    outBuffer = buffer;\n\t    outLength = written;\n\t}\n    }\n    /* save the session in a hard coded file name hxxxxxxxx.bin where xxxxxxxx is the session\n       handle */\n    if (rc == 0) {\n\tsprintf(sessionFilename, \"%s/h%08x.bin\",\n\t\ttssContext->tssDataDirectory, session->authHandle);\n    }\n    if (rc == 0) {\n\trc = TSS_File_WriteBinaryFile(outBuffer,\n\t\t\t\t      outLength,\n\t\t\t\t      sessionFilename);\n    }\n    if (tssContext->tssEncryptSessions) {\n\tfree(outBuffer);\t/* @2 */\n    }\n    free(buffer);\t\t/* @1 */\n    return rc;\n}\n\n/* TSS_HmacSession12_LoadSession() loads and decrypts an HMAC existing session saved by:\n\n   OIAP and OSAP\n   an update after a TPM response\n*/\n\nstatic TPM_RC TSS_HmacSession12_LoadSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    TSS_HMAC12_CONTEXT *session,\n\t\t\t\t\t    TPM_AUTHHANDLE authHandle)\n{\n    TPM_RC\t\trc = 0;\n    uint8_t \t\t*buffer = NULL;\n    uint8_t \t\t*buffer1 = NULL;\n    size_t \t\tlength = 0;\n    char\t\tsessionFilename[TPM_DATA_DIR_PATH_LENGTH];\n    unsigned char *inData = NULL;\t\t/* output */\n    uint32_t inLength;\t\t\t\t/* output */\n\n    if (tssVverbose) printf(\"TSS_HmacSession12_LoadSession: handle %08x\\n\", authHandle);\n    /* load the session from a hard coded file name hxxxxxxxx.bin where xxxxxxxx is the session\n       handle */\n    if (rc == 0) {\n\tsprintf(sessionFilename, \"%s/h%08x.bin\", tssContext->tssDataDirectory, authHandle);\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     sessionFilename);\n    }\n    if (rc == 0) {\n\t/* if the flag is set, decrypt the session state before unmarshal */\n\tif (tssContext->tssEncryptSessions) {\n\t    rc = TSS_AES_Decrypt(tssContext->tssSessionDecKey,\n\t\t\t\t &inData,   \t/* output, freed @2 */\n\t\t\t\t &inLength,\t/* output */\n\t\t\t\t buffer,\t/* input */\n\t\t\t\t length);\t/* input */\n\t}\n\t/* else the session was loaded in plaintext */\n\telse {\n\t    inData = buffer;\n\t    inLength = length;\n\t}\n    }\n    if (rc == 0) {\n\tuint32_t ilength = inLength;\n\tbuffer1 = inData;\n\trc = TSS_HmacSession12_Unmarshal(session, &buffer1, &ilength);\n    }\n    if (tssContext->tssEncryptSessions) {\n\tfree(inData);\t/* @2 */\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n/* TSS_HmacSession12_DeleteSession() deletes the file corresponding to the HMAC session */\n\nstatic TPM_RC TSS_HmacSession12_DeleteSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t      TPM_AUTHHANDLE handle)\n{\n    TPM_RC\t\trc = 0;\n    char\t\tfilename[TPM_DATA_DIR_PATH_LENGTH];\n\n    /* delete the Name */\n    if (rc == 0) {\n\tsprintf(filename, \"%s/h%08x.bin\", tssContext->tssDataDirectory, handle);\n\tif (tssVverbose) printf(\"TSS_HmacSession12_DeleteSession: delete session file %s\\n\", filename);\n\trc = TSS_File_DeleteFile(filename);\n    }\n    return rc;\n}\n\n/* TSS_HmacSession12_Marshal() serializes a TSS_HMAC12_CONTEXT\n */\n\nstatic TPM_RC TSS_HmacSession12_Marshal(TSS_HMAC12_CONTEXT *source,\n\t\t\t\t\tuint16_t *written,\n\t\t\t\t\tuint8_t **buffer,\n\t\t\t\t\tuint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->nonceEven, SHA1_DIGEST_SIZE, written, buffer,  size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->nonceEvenOSAP, SHA1_DIGEST_SIZE, written, buffer,  size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu((uint8_t *)&source->sharedSecret.digest, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->entityType, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->entityValue, written, buffer, size);\n    }\n    return rc;\n}\n\n/* TSS_HmacSession12_Unmarshal() deserializes a TSS_HMAC12_CONTEXT */\n\nstatic TPM_RC TSS_HmacSession12_Unmarshal(TSS_HMAC12_CONTEXT *target,\n\t\t\t\t\t  uint8_t **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->authHandle, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->nonceEven, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->nonceEvenOSAP, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu((uint8_t *)&target->sharedSecret.digest, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Unmarshalu(&target->entityType, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->entityValue, buffer, size);\n    }\n    return rc;\n}\n\n/* TSS_HmacSession12_SetHMAC() is used for a command.  It sets all the values in one\n   TPMS_AUTH12_COMMAND, ready for marshaling into the command packet.\n\n   - gets cpBuffer\n   - generates cpHash\n   - generates the HMAC\n   - copies the result into authCommand\n\n   The HMAC key is already in the session structure.\n*/\n\nstatic TPM_RC TSS_HmacSession12_SetHMAC(TSS_AUTH_CONTEXT *tssAuthContext,\t/* authorization context */\n\t\t\t\t\tsize_t\t\tnumSessions,\n\t\t\t\t\tTSS_HMAC12_CONTEXT *session[],\n\t\t\t\t\t\n\t\t\t\t\tTPMS_AUTH12_COMMAND *authCommand[],\t/* output: command\n\t\t\t\t\t\t\t\t\t\t   authorization */\n\t\t\t\t\tTPM_AUTHHANDLE sessionHandle[], \t/* session handles in\n\t\t\t\t\t\t\t\t\t\t   command */\n\t\t\t\t\tunsigned int sessionAttributes[])\t/* attributes for this\n\t\t\t\t\t\t\t\t\t\t   command */\n{\n    TPM_RC\t\trc = 0;\n    unsigned int\ti = 0;\n    TPMT_HA \t\tcpHash;\n    TPMT_HA \t\thmac;\n\n    /* Step 6: calculate cpHash.  For TPM 1.2, it is the same for all sessions. Name is not used */\n    if ((rc == 0) && (numSessions > 0))\t{\n\tuint32_t cpBufferSize;\n\tuint8_t *cpBuffer;\n\tTPM_CC commandCode = TSS_GetCommandCode(tssAuthContext);\n\tTPM_CC commandCodeNbo = htonl(commandCode);\n\t\n\trc = TSS_GetCpBuffer(tssAuthContext, &cpBufferSize, &cpBuffer);\n\tif (tssVverbose) TSS_PrintAll(\"TSS_HmacSession12_SetHMAC: cpBuffer\",\n\t\t\t\t      cpBuffer, cpBufferSize);\n\t/* Create cpHash - digest of inputs above the double line. */\n\tcpHash.hashAlg = TPM_ALG_SHA1;\n\trc = TSS_Hash_Generate(&cpHash,\n\t\t\t       sizeof(TPM_CC), &commandCodeNbo,\t\t/* 1S */\n\t\t\t       cpBufferSize, cpBuffer, \t\t\t/* 2S - ... */\n\t\t\t       0, NULL);\n\tif (rc == 0) {\n\t    if (tssVverbose) TSS_PrintAll(\"TSS_HmacSession12_SetHMAC: cpHash\",\n\t\t\t\t\t  (uint8_t *)&cpHash.digest,\n\t\t\t\t\t  SHA1_DIGEST_SIZE);\n\t}\n    }\n    for (i = 0 ; (rc == 0) && (i < numSessions) ; i++) {\n\tuint8_t sessionAttr8;\n\tTPM2B_KEY hmacKey;\n\t\n\tif (tssVverbose) printf(\"TSS_HmacSession12_SetHMAC: Step 6 session %08x\\n\",\n\t\t\t\tsessionHandle[i]);\n\t/* sessionHandle */\n\tauthCommand[i]->sessionHandle = session[i]->authHandle;\n\t/* attributes come from command */\n\tsessionAttr8 = (uint8_t)sessionAttributes[i];\n\tauthCommand[i]->sessionAttributes.val = sessionAttr8;\n\n\tif (tssVverbose) printf(\"TSS_HmacSession12_SetHMAC: calculate HMAC\\n\");\n\t/* auth HMAC = HMAC(cpHash | nonceEven, nonceOdd, attributes */\n\n\t/* convert the TPMT_HA hmacKey to a TPM2B_KEY hmac key */\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_Create(&hmacKey.b,\n\t\t\t\t  (uint8_t *)&session[i]->hmacKey.digest, SHA1_DIGEST_SIZE,\n\t\t\t\t  sizeof(hmacKey.t.buffer));\n\t}\n\tif (rc == 0) {\n\t    hmac.hashAlg = TPM_ALG_SHA1;\n\t    rc = TSS_HMAC_Generate(&hmac,\t\t\t/* output hmac */\n\t\t\t\t   &hmacKey,\t\t\t/* input key */\n\t\t\t\t   SHA1_DIGEST_SIZE, (uint8_t *)&cpHash.digest,\n\t\t\t\t   SHA1_DIGEST_SIZE, session[i]->nonceEven,\n\t\t\t\t   SHA1_DIGEST_SIZE, session[i]->nonceOdd,\n\t\t\t\t   sizeof(uint8_t), &sessionAttr8,\n\t\t\t\t   0, NULL);\n\t}\n\tif (rc == 0) {\n\t    if (tssVverbose) {\n\t\tTSS_PrintAll(\"TSS_HmacSession12_SetHMAC: HMAC key\",\n\t\t\t     (uint8_t *)&session[i]->hmacKey.digest, SHA1_DIGEST_SIZE);\n\t\tTSS_PrintAll(\"TSS_HmacSession12_SetHMAC: cpHash\",\n\t\t\t     (uint8_t *)&cpHash.digest, SHA1_DIGEST_SIZE);\n\t\tTSS_PrintAll(\"TSS_HmacSession12_Set: nonceEven\",\n\t\t\t     session[i]->nonceEven, SHA1_DIGEST_SIZE);\n\t\tTSS_PrintAll(\"TSS_HmacSession12_SetHMAC: nonceOdd\",\n\t\t\t     session[i]->nonceOdd, SHA1_DIGEST_SIZE);\n\t\tTSS_PrintAll(\"TSS_HmacSession12_SetHMAC: sessionAttributes\",\n\t\t\t     &sessionAttr8, sizeof(uint8_t));\n\t\tTSS_PrintAll(\"TSS_HmacSession12_SetHMAC: HMAC\",\n\t\t\t     (uint8_t *)&hmac.digest, SHA1_DIGEST_SIZE);\n\t    }\n\t}\n\t/* copy HMAC into authCommand TPM2B_AUTH hmac */\n\tif (rc == 0) {\n\t    memcpy(authCommand[i]->hmac, (uint8_t *)&hmac.digest, SHA1_DIGEST_SIZE);\n\t}\n    }\n    return rc;\n}\n\n/* TSS_HmacSession12_Verify() is used for a response.  It uses the values in TPMS_AUTH12_RESPONSE to\n   validate the response HMAC */\n\nstatic TPM_RC TSS_HmacSession12_Verify(TSS_AUTH_CONTEXT *tssAuthContext,\t/* authorization\n\t\t\t\t\t\t\t\t\t\t   context */\n\t\t\t\t       size_t\t\tnumSessions,\n\t\t\t\t       TSS_HMAC12_CONTEXT *session[],\t\t/* TSS session\n\t\t\t\t\t\t\t\t\t\t   context */\n\t\t\t\t       TPMS_AUTH12_RESPONSE *authResponse[])\t/* input: response\n\t\t\t\t\t\t\t\t\t\t   authorization */\n{\n    TPM_RC\t\trc = 0;\n    unsigned int\ti = 0;\n    TPMT_HA \t\trpHash;\n    TPMT_HA \t\tactualHmac;\n\n    /* Step 10: calculate rpHash.  For TPM 1.2, it is the same for all sessions. Name is not used */\n    if ((rc == 0) && (numSessions > 0))\t{\n\tuint32_t rpBufferSize;\n\tuint8_t *rpBuffer;\n\tTPM_CC commandCode = TSS_GetCommandCode(tssAuthContext);\n\tTPM_CC commandCodeNbo = htonl(commandCode);\n\t\n\trc = TSS_GetRpBuffer12(tssAuthContext, &rpBufferSize, &rpBuffer, numSessions);\n\tif (tssVverbose) TSS_PrintAll(\"TSS_HmacSession12_Verify: rpBuffer\",\n\t\t\t\t      rpBuffer, rpBufferSize);\n\t/* Create rpHash - digest of inputs above the double line. */\n\trpHash.hashAlg = TPM_ALG_SHA1;\n\trc = TSS_Hash_Generate(&rpHash,\n\t\t\t       sizeof(TPM_RC),  &rc,\t\t\t/* 1S */\n\t\t\t       sizeof(TPM_CC), &commandCodeNbo,\t\t/* 2S */\n\t\t\t       rpBufferSize, rpBuffer, \t\t\t/* 3S - ... */\n\t\t\t       0, NULL);\n\tif (rc == 0) {\n\t    if (tssVverbose) TSS_PrintAll(\"TSS_HmacSession12_Verify: rpHash\",\n\t\t\t\t\t  (uint8_t *)&rpHash.digest,\n\t\t\t\t\t  SHA1_DIGEST_SIZE);\n\t}\n    }\n    for (i = 0 ; (rc == 0) && (i < numSessions) ; i++) {\n\tuint8_t sessionAttr8;\n\tTPM2B_KEY hmacKey;\n\tif (tssVverbose) printf(\"TSS_HmacSession12_Verify: Step 10 session %u handle %08x\\n\",\n\t\t\t\ti, session[i]->authHandle);\n\t/* attributes come from response */\n\tsessionAttr8 = (uint8_t)authResponse[i]->sessionAttributes.val;\n\t/* save nonceEven in the session context */\n\tif (rc == 0) {\n\t    memcpy(session[i]->nonceEven, authResponse[i]->nonce, SHA1_DIGEST_SIZE);\n\t}\n\tif (rc == 0) {\n\t    memcpy((uint8_t *)&actualHmac.digest, &authResponse[i]->hmac,\n\t\t   SHA1_DIGEST_SIZE);\n\t}\n\t/* convert the TPMT_HA hmacKey to a TPM2B_KEY hmac key */\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_Create(&hmacKey.b,\n\t\t\t\t  (uint8_t *)&session[i]->hmacKey.digest, SHA1_DIGEST_SIZE,\n\t\t\t\t  sizeof(hmacKey.t.buffer));\n\t}\n\t/* verify the HMAC */\n\tif (rc == 0) {\n\t    if (tssVverbose) {\n\t\tTSS_PrintAll(\"TSS_HmacSession12_Verify: HMAC key\",\n\t\t\t     (uint8_t *)&session[i]->hmacKey.digest, SHA1_DIGEST_SIZE);\n\t\tTSS_PrintAll(\"TSS_HmacSession12_Verify: rpHash\",\n\t\t\t     (uint8_t *)&rpHash.digest, SHA1_DIGEST_SIZE);\n\t\tTSS_PrintAll(\"TSS_HmacSession12_Verify: nonceEven\",\n\t\t\t     session[i]->nonceEven, SHA1_DIGEST_SIZE);\n\t\tTSS_PrintAll(\"TSS_HmacSession12_Verify: nonceOdd\",\n\t\t\t     session[i]->nonceOdd, SHA1_DIGEST_SIZE);\n\t\tTSS_PrintAll(\"TSS_HmacSession12_Verify: sessionAttributes\",\n\t\t\t     &sessionAttr8, sizeof(uint8_t));\n\t\tTSS_PrintAll(\"TSS_HmacSession12_Verify: response HMAC\",\n\t\t\t     (uint8_t *)&authResponse[i]->hmac, SHA1_DIGEST_SIZE);\n\t    }\n\t    actualHmac.hashAlg = TPM_ALG_SHA1;\n\t    rc = TSS_HMAC_Verify(&actualHmac,\t\t\t/* input response hmac */\n\t\t\t\t &hmacKey,\t\t\t/* input HMAC key */\n\t\t\t\t SHA1_DIGEST_SIZE,\n\t\t\t\t /* rpHash */\n\t\t\t\t SHA1_DIGEST_SIZE, (uint8_t *)&rpHash.digest,\n\t\t\t\t /* new is nonceEven */\n\t\t\t\t SHA1_DIGEST_SIZE, session[i]->nonceEven,\n\t\t\t\t /* old is nonceOdd */\n\t\t\t\t SHA1_DIGEST_SIZE, session[i]->nonceOdd,\n\t\t\t\t /* 1 byte, no endian conversion */\n\t\t\t\t sizeof(uint8_t), &authResponse[i]->sessionAttributes.val,\n\t\t\t\t 0, NULL);\n\t    if (rc == 0) {\n\t\tif (tssVverbose) printf(\"TSS_HmacSession12_Verify: session %u verified\\n\", i);\n\t    }\n\t    else {\n\t\tif (tssVerbose) TSS_PrintAll(\"TSS_HmacSession12_Verify: HMAC verify failed, actual\",\n\t\t\t\t\t     (uint8_t *)&actualHmac.digest, SHA1_DIGEST_SIZE);\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/* TSS_HmacSession12_Continue() handles the response continueSession flag.  It either saves the\n   updated session or deletes the session state. */\n\nstatic TPM_RC TSS_HmacSession12_Continue(TSS_CONTEXT *tssContext,\n\t\t\t\t\t TSS_HMAC12_CONTEXT *session,\n\t\t\t\t\t TPMS_AUTH12_RESPONSE *authR)\n{\n    TPM_RC\t\trc = 0;\n\n    if (rc == 0) {\n\t/* if continue set */\n\tif (authR->sessionAttributes.val & TPMA_SESSION_CONTINUESESSION) {\n\t    /* save the session */\n\t    rc = TSS_HmacSession12_SaveSession(tssContext, session);\n\t}\n\telse {\t\t/* continue clear */\n\t    /* delete the session state */\n\t    rc = TSS_HmacSession12_DeleteSession(tssContext, session->authHandle);\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Command_Decrypt() does the command ADIP encryption (the TPM does the decrypt).\n\n   It does common error checking, then calls algorithm specific functions.  Currently, only XOR is\n   implemented.\n\n*/\n\nstatic TPM_RC TSS_Command_Decrypt(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t  TSS_HMAC12_CONTEXT *session[],\n\t\t\t\t  TPM_AUTHHANDLE sessionHandle[])\n{\n    TPM_RC\t\t\trc = 0;\n    uint16_t \t\t\tsessionNumber;\n    uint8_t\t\t\t*encAuth0;\n    uint8_t\t\t\t*encAuth1;\n    TSS_HMAC12_CONTEXT\t\t*decryptSession;\n    int\t\t\t\tdone = FALSE;\n    int \t\t\tisXor;\t\t\t/* true for XOR, false for AES */\n    \n    /* which session is the OSAP session used for the encryption */\n    if (rc == 0) {\n\trc = TSS_GetSessionNumber(tssAuthContext,\n\t\t\t\t  &sessionNumber);\n    }\n    if (rc == 0) {\n\tif (sessionNumber == 0xffff) {\n\t    done = TRUE;\n\t}\n    }\n    /* get the session used for the encryption */\n    if ((rc == 0) && !done) {\n\tdecryptSession = session[sessionNumber];\n\tisXor = (session[sessionNumber]->entityType & 0xff00) == (TPM_ET_XOR << 8);\n\tif (!isXor) {\n\t    if (tssVerbose) printf(\"TSS_Command_Decrypt: bad entityType %04x for session %08x\\n\",\n\t\t\t\t   session[sessionNumber]->entityType,\n\t\t\t\t   sessionHandle[sessionNumber]);\n\t    rc = TSS_RC_BAD_DECRYPT_ALGORITHM;\n\t}\n\telse {\n\t    if (tssVverbose) printf(\"TSS_Command_Decrypt: using session %08x\\n\",\n\t\t\t\t    sessionHandle[sessionNumber]);\n\t}\n\n    }\n    /* get pointers to the parameters to be encrypted */ \n    if ((rc == 0) && !done) {\n\trc = TSS_GetEncAuths(tssAuthContext,\n\t\t\t     &encAuth0,\n\t\t\t     &encAuth1);\n    }\n    if ((rc == 0) && !done) {\n\tif (tssVverbose) printf(\"TSS_Command_Decrypt: TPM_ENC_AUTH's at %p, %p\\n\",\n\t\t\t\tencAuth0, encAuth1);\n    }\n    if ((rc == 0) && !done && (encAuth0 != NULL)) {\n\trc = TSS_Command_DecryptXor(tssAuthContext, decryptSession, encAuth0, 0);\n    }\n    if ((rc == 0) && !done && (encAuth1 != NULL)) {\n\trc = TSS_Command_DecryptXor(tssAuthContext, decryptSession, encAuth1, 1);\n    }\n    return rc;\n}\n\n/*\n  pad = sha1(shared secret || lastnonceeven)\n  enc = xor (auth, pad)\n*/\n\nstatic TPM_RC TSS_Command_DecryptXor(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t     TSS_HMAC12_CONTEXT *session,\n\t\t\t\t     uint8_t *encAuth,\n\t\t\t\t     int parameterNumber)\n{\n    TPM_RC\t\trc = 0;\n    TPMT_HA \t\tpadHash;\n    unsigned int\ti;\n\n    tssAuthContext = tssAuthContext;\n    /* generate the pad */\n    if (rc == 0) {\n\tpadHash.hashAlg = TPM_ALG_SHA1;\n\tif (parameterNumber == 0) {\n\t    rc = TSS_Hash_Generate(&padHash,\n\t\t\t\t   SHA1_DIGEST_SIZE, (uint8_t *)&session->sharedSecret.digest,\n\t\t\t\t   SHA1_DIGEST_SIZE, session->nonceEven,\n\t\t\t\t   0, NULL);\n\t}\n\telse {\n\t    rc = TSS_Hash_Generate(&padHash,\n\t\t\t\t   SHA1_DIGEST_SIZE, (uint8_t *)&session->sharedSecret.digest,\n\t\t\t\t   SHA1_DIGEST_SIZE, session->nonceOdd,\n\t\t\t\t   0, NULL);\n\t}\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptXor: pad\",\n\t\t\t\t      (uint8_t *)&padHash.digest,\n\t\t\t\t      SHA1_DIGEST_SIZE);\n\tif (tssVverbose) printf(\"TSS_Command_DecryptXor: parameter %u\\n\",\n\t\t\t\tparameterNumber);\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptXor: plaintext\",\n\t\t\t\t      encAuth, SHA1_DIGEST_SIZE);\n    }\n    /* do the XOR */\n    if (rc == 0) {\n\tfor (i = 0 ; i < SHA1_DIGEST_SIZE ; i++) {\n\t    *(encAuth + i) = *(encAuth + i) ^ padHash.digest.sha1[i];\n\t}\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptXor: ciphertext\",\n\t\t\t\t      encAuth, SHA1_DIGEST_SIZE);\n    }    \n    return rc;\n}\n\n/*\n  Command Pre-Processor\n*/\n\nstatic TPM_RC TSS_Command_PreProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t       TPM_CC commandCode,\n\t\t\t\t       COMMAND_PARAMETERS *in,\n\t\t\t\t       EXTRA12_PARAMETERS *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    size_t \t\t\tindex;\n    int \t\t\tfound;\n    TSS_PreProcessFunction_t \tpreProcessFunction = NULL;\n\n    /* search the table for a pre-processing function */\n    if (rc == 0) {\n\tfound = FALSE;\n\tfor (index = 0 ; (index < (sizeof(tssTable) / sizeof(TSS_TABLE))) && !found ; index++) {\n\t    if (tssTable[index].commandCode == commandCode) {\n\t\tfound = TRUE;\n\t\tbreak;\t/* don't increment index if found */\n\t    }\n\t}\n    }\n    /* found false means there is no pre-processing function.  This permits the table to be smaller\n       if desired. */\n    if ((rc == 0) && found) {\n\tpreProcessFunction = tssTable[index].preProcessFunction;\n\t/* there could also be an entry that is currently NULL, nothing to do */\n\tif (preProcessFunction == NULL) {\n\t    found = FALSE;\n\t}\n    }\n    /* call the pre processing function */\n    if ((rc == 0) && found) {\n\trc = preProcessFunction(tssContext, in, extra);\n    }\n    return rc;\n}\n\n/*\n  Command specific pre processing functions\n*/\n\nstatic TPM_RC TSS_PR_CreateWrapKey(TSS_CONTEXT *tssContext,\n\t\t\t\t   CreateWrapKey_In *in,\n\t\t\t\t   void *extra)\n{\n    TPM_RC\trc = 0;\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PR_CreateWrapKey\\n\");\n    /* TPM_ENCAUTH is predictable distance from start */\n    if (rc == 0) {\n\trc = TSS_SetEncAuthOffset0(tssContext->tssAuthContext,\n\t\t\t\t   sizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT) +\n\t\t\t\t   sizeof(TPM_KEY_HANDLE));\n    }\n    if (rc == 0) {\n\trc = TSS_SetEncAuthOffset1(tssContext->tssAuthContext,\n\t\t\t\t   sizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT) +\n\t\t\t\t   sizeof(TPM_KEY_HANDLE) +\n\t\t\t\t   SHA1_DIGEST_SIZE);\n    }\n    if (rc == 0) {\n\trc = TSS_SetSessionNumber(tssContext->tssAuthContext, 0);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_PR_CreateWrapKey: ADIP offset at %lu and %lu\\n\",\n\t\t\t\t(unsigned long)(sizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT) +\n\t\t\t\t\t\tsizeof(TPM_KEY_HANDLE)),\n\t\t\t\t(unsigned long)(sizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT) +\n\t\t\t\t\t\tsizeof(TPM_KEY_HANDLE) +\n\t\t\t\t\t\tSHA1_DIGEST_SIZE));\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_PR_MakeIdentity(TSS_CONTEXT *tssContext,\n\t\t\t\t  MakeIdentity_In *in,\n\t\t\t\t  void *extra)\n{\n    TPM_RC\trc = 0;\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PR_MakeIdentity\\n\");\n    /* TPM_ENCAUTH is predictable distance from start */\n    if (rc == 0) {\n\trc = TSS_SetEncAuthOffset0(tssContext->tssAuthContext,\n\t\t\t\t   sizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT));\n    }\n    if (rc == 0) {\n\trc = TSS_SetSessionNumber(tssContext->tssAuthContext, 1);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_PR_MakeIdentity: ADIP offset at %lu\\n\",\n\t\t\t\t(unsigned long)(sizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT)));\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_PR_NV_DefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t\t    NV_DefineSpace_In *in,\n\t\t\t\t    void *extra)\n{\n    TPM_RC\trc = 0;\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PR_NV_DefineSpace\\n\");\n    /* TPM_ENCAUTH is predictable distance from end */\n    if (rc == 0) {\n\trc = TSS_SetEncAuthOffset0(tssContext->tssAuthContext,\n\t\t\t\t   -SHA1_DIGEST_SIZE);\t\t/* encauth */\n\t\t\n    }\n    if (rc == 0) {\n\trc = TSS_SetSessionNumber(tssContext->tssAuthContext, 0);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_PR_NV_DefineSpace: ADIP offset at %d\\n\",\n\t\t\t\t-SHA1_DIGEST_SIZE);\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_PR_OSAP(TSS_CONTEXT *tssContext,\n\t\t\t  OSAP_In *in,\n\t\t\t  OSAP_Extra *extra)\n{\n    TPM_RC\trc = 0;\n    tssContext = tssContext;\n    extra = extra;\n\n    if (tssVverbose) printf(\"TSS_PR_OSAP\\n\");\n    /* generate nonceOddOSAP */\n    if (rc == 0) {\n\trc = TSS_RandBytes((unsigned char *)in->nonceOddOSAP, SHA1_DIGEST_SIZE);\n    }\n    return rc;\n}\n\n#if 0\nstatic TPM_RC TSS_PR_Seal(TSS_CONTEXT *tssContext,\n\t\t\t  Seal_in *In,\n\t\t\t  void *extra)\n{\n    TPM_RC\trc = 0;\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PR_Seal\\n\");\n    /* TPM_ENCAUTH is predictable distance from start */\n    if (rc == 0) {\n\trc = TSS_SetEncAuthOffset0(tssContext->tssAuthContext,\n\t\t\t\t   sizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT) +\n\t\t\t\t   sizeof(TPM_KEY_HANDLE));\n    }\n    if (rc == 0) {\n\trc = TSS_SetSessionNumber(tssContext->tssAuthContext, 0);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_PR_Seal: ADIP offset at %u\\n\",\n\t\t\t\tsizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT) +\n\t\t\t\tsizeof(TPM_KEY_HANDLE));\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_PR_Sealx(TSS_CONTEXT *tssContext,\n\t\t\t   Sealx_in *In,\n\t\t\t   void *extra)\n{\n    TPM_RC\trc = 0;\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PR_Sealx\\n\");\n    /* TPM_ENCAUTH is predictable distance from start */\n    if (rc == 0) {\n\trc = TSS_SetEncAuthOffset0(tssContext->tssAuthContext,\n\t\t\t\t   sizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT) +\n\t\t\t\t   sizeof(TPM_KEY_HANDLE));\n\trc = TSS_SetSessionNumber(tssContext->tssAuthContext, 0);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_PR_Seal: ADIP offset at %u\\n\",\n\t\t\t\tsizeof(TPM_TAG) + sizeof(UINT32) + sizeof(TPM_RESULT) +\n\t\t\t\tsizeof(TPM_KEY_HANDLE));\n    }\n    return rc;\n}\n\n#endif\n\n/*\n  Response Post Processor\n*/\n\n/* TSS_Response_PostProcessor() handles any response specific post processing\n */\n\nstatic TPM_RC TSS_Response_PostProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t\t COMMAND_PARAMETERS *in,\n\t\t\t\t\t RESPONSE_PARAMETERS *out,\n\t\t\t\t\t EXTRA12_PARAMETERS *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    size_t \t\t\tindex;\n    int \t\t\tfound;\n    TSS_PostProcessFunction_t \tpostProcessFunction = NULL;\n\n    /* search the table for a post processing function */\n    if (rc == 0) {\n\tTPM_CC commandCode = TSS_GetCommandCode(tssContext->tssAuthContext);\n\tfound = FALSE;\n\tfor (index = 0 ; (index < (sizeof(tssTable) / sizeof(TSS_TABLE))) && !found ; index++) {\n\t    if (tssTable[index].commandCode == commandCode) {\n\t\tfound = TRUE;\n\t\tbreak;\t/* don't increment index if found */\n\t    }\n\t}\n    }\n    /* found false means there is no post processing function.  This permits the table to be smaller\n       if desired. */\n    if ((rc == 0) && found) {\n\tpostProcessFunction = tssTable[index].postProcessFunction;\n\t/* there could also be an entry that it currently NULL, nothing to do */\n\tif (postProcessFunction == NULL) {\n\t    found = FALSE;\n\t}\n    }\n    /* call the function */\n    if ((rc == 0) && found) {\n\trc = postProcessFunction(tssContext, in, out, extra);\n    }\n    return rc;\n}\n\n/*\n  Command specific post processing functions\n*/\n\nstatic TPM_RC TSS_PO_FlushSpecific(TSS_CONTEXT *tssContext,\n\t\t\t\t   FlushSpecific_In *in,\n\t\t\t\t   void *out,\n\t\t\t\t   void *extra)\n{\n    TPM_RC\trc = 0;\n    out = out;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_FlushSpecific: handle %08x\\n\", in->handle);\n    if ((rc == 0) && (in->resourceType == TPM_RT_AUTH)) {\n\trc = TSS_HmacSession12_DeleteSession(tssContext, in->handle);\n    }\n    return rc;\n}  \n\nstatic TPM_RC TSS_PO_OIAP(TSS_CONTEXT *tssContext,\n\t\t\t  void *in,\n\t\t\t  OIAP_Out *out,\n\t\t\t  void *extra)\n{\n    TPM_RC \t\trc = 0;\n    TSS_HMAC12_CONTEXT \t*session = NULL;\n\n    in = in;\n    extra = extra;\n    /* allocate a TSS_HMAC_CONTEXT session context */\n    if (rc == 0) {\n\trc = TSS_HmacSession12_GetContext(&session);\n    }\n    if (rc == 0) {\n\t/* store OIAP ordinal outputs */\n\tsession->authHandle = out->authHandle;\n\tsession->entityValue = TPM_RH_NULL;\t/* distinguish OIAP form OSAP */\n\tmemcpy(session->nonceEven, out->nonceEven, SHA1_DIGEST_SIZE);\n    }\n    /* persist the session */\n    if (rc == 0) {\n\trc = TSS_HmacSession12_SaveSession(tssContext, session);\n    }\n    TSS_HmacSession12_FreeContext(session);\n    return rc;\n}\n\nstatic TPM_RC TSS_PO_OSAP(TSS_CONTEXT *tssContext,\n\t\t\t  OSAP_In *in,\n\t\t\t  OSAP_Out *out,\n\t\t\t  OSAP_Extra *extra)\n{\n    TPM_RC \t\trc = 0;\n    TSS_HMAC12_CONTEXT \t*session = NULL;\n    TPM2B_KEY\t\thmacKey;\n    TPMT_HA \t\tusageAuth;\t\t/* digest of the OSAP password */\n\n    /* allocate a TSS_HMAC_CONTEXT session context */\n    if (rc == 0) {\n\trc = TSS_HmacSession12_GetContext(&session);\n    }\n    if (rc == 0) {\n\tsession->entityType = in->entityType;\n\tsession->entityValue = in->entityValue;\t\t/* mark OSAP session */\n\tmemcpy(session->nonceOddOSAP, in->nonceOddOSAP, SHA1_DIGEST_SIZE);\n\t/* store OSAP ordinal outputs */\n\tsession->authHandle = out->authHandle;\n\tmemcpy(session->nonceEven, out->nonceEven, SHA1_DIGEST_SIZE);\n\tmemcpy(session->nonceEvenOSAP, out->nonceEvenOSAP, SHA1_DIGEST_SIZE);\n    }\n    /* SHA1 hash the usageAuth */\n    if (rc == 0) {\n\tif (extra->usagePassword != NULL) {\t/* if a password was specified, hash it */\n\t    usageAuth.hashAlg = TPM_ALG_SHA1;\n\t    rc = TSS_Hash_Generate(&usageAuth,\n\t\t\t\t   strlen(extra->usagePassword),\n\t\t\t\t   (unsigned char *)extra->usagePassword,\n\t\t\t\t   0, NULL);\n\t}\n\t/* TPM 1.2 convention seems to use all zeros as a well known auth */\n\telse {\n\t    memset((uint8_t *)&usageAuth.digest, 0, SHA1_DIGEST_SIZE);\n\t}\n    }\n    /* convert the TPMT_HA hash to a TPM2B_KEY hmac key */\n    if (rc == 0) {\n\trc = TSS_TPM2B_Create(&hmacKey.b, (uint8_t *)&usageAuth.digest, SHA1_DIGEST_SIZE,\n\t\t\t      sizeof(hmacKey.t.buffer));\n    }\n    /* calculate the sharedSecret */\n    if (rc == 0) {\n\tsession->sharedSecret.hashAlg = TPM_ALG_SHA1;\n\trc = TSS_HMAC_Generate(&session->sharedSecret,\t\t/* output hmac */\n\t\t\t       &hmacKey,\t\t\t/* input key */\n\t\t\t       SHA1_DIGEST_SIZE, session->nonceEvenOSAP,\n\t\t\t       SHA1_DIGEST_SIZE, in->nonceOddOSAP,\n\t\t\t       0, NULL);\n    }\n    if ((rc == 0) && tssVverbose) {\n\tprintf(\"TSS_PO_OSAP: out->authHandle %08x\\n\",out->authHandle);\n\tprintf(\"TSS_PO_OSAP: in->entityType %08x\\n\", in->entityType);\n\tprintf(\"TSS_PO_OSAP: in->entityValue %08x\\n\", in->entityValue);\n\tTSS_PrintAll(\"TSS_PO_OSAP: session->nonceEven\",\n\t\t     session->nonceEven, SHA1_DIGEST_SIZE);\n\tTSS_PrintAll(\"TSS_PO_OSAP: session->nonceEvenOSAP\",\n\t\t     session->nonceEvenOSAP, SHA1_DIGEST_SIZE);\n\tTSS_PrintAll(\"TSS_PO_OSAP: session->nonceOddOSAP\",\n\t\t     session->nonceOddOSAP, SHA1_DIGEST_SIZE);\n\tTSS_PrintAll(\"TSS_PO_OSAP: usageAuth\",\n\t\t     (uint8_t *)&usageAuth.digest, SHA1_DIGEST_SIZE);\n\tTSS_PrintAll(\"TSS_PO_OSAP: sharedSecret\",\n\t\t     (uint8_t *)&session->sharedSecret.digest, SHA1_DIGEST_SIZE);\n    }\n    /* persist the session */\n    if (rc == 0) {\n\trc = TSS_HmacSession12_SaveSession(tssContext, session);\n    }\n    TSS_HmacSession12_FreeContext(session);\n    return rc;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tss20.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    TSS Primary API for TPM 2.0\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2018 - 2024.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>\n#include <errno.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include \"tssauth.h\"\n#include \"tssauth20.h\"\n#include <ibmtss/tss.h>\n#include \"tssproperties.h\"\n#include <ibmtss/tsstransmit.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include \"tssccattributes.h\"\n#ifndef TPM_TSS_NOCRYPTO\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/tsscryptoh.h>\n#endif\n#include <ibmtss/tssprintcmd.h>\n#include \"tss20.h\"\n\n/* Files:\n\n   h01xxxxxx.bin - NV index name\n   h02xxxxxx.bin - hmac session context\n   h03xxxxxx.bin - policy session context\n   h80xxxxxx.bin - transient object name\n\n   cxxxx...xxxx.bin - context blob name\n*/\n\n/* NOTE Synchronize with\n\n   TSS_HmacSession_InitContext\n   TSS_HmacSession_Unmarshal\n   TSS_HmacSession_Marshal\n*/\n\nstruct TSS_HMAC_CONTEXT {\n    TPMI_SH_AUTH_SESSION\tsessionHandle;\t\t/* the session handle */\n    TPMI_ALG_HASH\t\tauthHashAlg;\t\t/* hash algorithm to use for the session */\n#ifndef TPM_TSS_NOCRYPTO\n    uint32_t           \t\tsizeInBytes;\t\t/* hash algorithm mapped to size */\n#endif\t/* TPM_TSS_NOCRYPTO */\n    TPMT_SYM_DEF \t\tsymmetric;\t\t/* the algorithm and key size for parameter\n\t\t\t\t\t\t\t   encryption */\n    TPMI_DH_ENTITY \t\tbind;\t\t\t/* bind handle */\n    TPM2B_NAME\t\t\tbindName;\t\t/* Name corresponding to the the bind\n\t\t\t\t\t\t\t   handle */\n    TPM2B_AUTH\t\t\tbindAuthValue;\t\t/* password corresponding to the bind\n\t\t\t\t\t\t\t   handle */\n#ifndef TPM_TSS_NOCRYPTO\n    TPM2B_NONCE \t\tnonceTPM;\t\t/* from TPM in response */\n    TPM2B_NONCE\t\t\tnonceCaller;\t\t/* from caller in command */\n    TPM2B_DIGEST\t\tsessionKey;\t\t/* from KDFa at session creation */\n#endif\t/* TPM_TSS_NOCRYPTO */\n    TPM_SE\t\t\tsessionType;\t\t/* HMAC (0), policy (1), or trial policy */\n    uint8_t\t\t\tisPasswordNeeded;\t/* flag set by policy password */\n    uint8_t\t\t\tisAuthValueNeeded;\t/* flag set by policy authvalue */\n    /* Items below this line are for the lifetime of one command.  They are not saved and loaded. */\n    TPM2B_KEY\t\t\thmacKey;\t\t/* HMAC key calculated for each command */\n#ifndef TPM_TSS_NOCRYPTO\n    TPM2B_KEY\t\t\tsessionValue;\t\t/* KDFa secret for parameter encryption */\n#endif\t/* TPM_TSS_NOCRYPTO */\n} TSS_HMAC_CONTEXT;\n\n/* functions for command pre- and post- processing */\n\n#ifdef TPM_TSS_NODEPRECATEDALGS\ntypedef TPM_RC (*TSS_CheckParametersFunction_t)(COMMAND_PARAMETERS *in);\n#endif /* TPM_TSS_NODEPRECATEDALGS */\ntypedef TPM_RC (*TSS_PreProcessFunction_t)(TSS_CONTEXT *tssContext,\n\t\t\t\t\t   COMMAND_PARAMETERS *in,\n\t\t\t\t\t   EXTRA_PARAMETERS *extra);\ntypedef TPM_RC (*TSS_ChangeAuthFunction_t)(TSS_CONTEXT *tssContext,\n\t\t\t\t\t   struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t   size_t handleNumber,\n\t\t\t\t\t   COMMAND_PARAMETERS *in);\ntypedef TPM_RC (*TSS_PostProcessFunction_t)(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    COMMAND_PARAMETERS *in,\n\t\t\t\t\t    RESPONSE_PARAMETERS *out,\n\t\t\t\t\t    EXTRA_PARAMETERS *extra);\n\nstatic TPM_RC TSS_PR_StartAuthSession(TSS_CONTEXT *tssContext,\n\t\t\t\t      StartAuthSession_In *in,\n\t\t\t\t      StartAuthSession_Extra *extra);\nstatic TPM_RC TSS_PR_NV_DefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t\t    NV_DefineSpace_In *in,\n\t\t\t\t    void *extra);\n\nstatic TPM_RC TSS_CA_HierarchyChangeAuth(TSS_CONTEXT *tssContext,\n\t\t\t\t\t struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t size_t handleNumber,\n\t\t\t\t\t HierarchyChangeAuth_In *in);\nstatic TPM_RC TSS_CA_NV_UndefineSpaceSpecial(TSS_CONTEXT *tssContext,\n\t\t\t\t\t     struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t     size_t handleNumber,\n\t\t\t\t\t     NV_UndefineSpaceSpecial_In *in);\nstatic TPM_RC TSS_CA_NV_ChangeAuth(TSS_CONTEXT *tssContext,\n\t\t\t\t   struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t   size_t handleNumber,\n\t\t\t\t   NV_ChangeAuth_In *in);\n\n\nstatic TPM_RC TSS_PO_StartAuthSession(TSS_CONTEXT *tssContext,\n\t\t\t\t      StartAuthSession_In *in,\n\t\t\t\t      StartAuthSession_Out *out,\n\t\t\t\t      StartAuthSession_Extra *extra);\nstatic TPM_RC TSS_PO_ContextSave(TSS_CONTEXT *tssContext,\n\t\t\t\t ContextSave_In *in,\n\t\t\t\t ContextSave_Out *out,\n\t\t\t\t void *extra);\nstatic TPM_RC TSS_PO_ContextLoad(TSS_CONTEXT *tssContext,\n\t\t\t\t ContextLoad_In *in,\n\t\t\t\t ContextLoad_Out *out,\n\t\t\t\t void *extra);\nstatic TPM_RC TSS_PO_FlushContext(TSS_CONTEXT *tssContext,\n\t\t\t\t  FlushContext_In *in,\n\t\t\t\t  void *out,\n\t\t\t\t  void *extra);\nstatic TPM_RC TSS_PO_EvictControl(TSS_CONTEXT *tssContext,\n\t\t\t\t  EvictControl_In *in,\n\t\t\t\t  void *out,\n\t\t\t\t  void *extra);\nstatic TPM_RC TSS_PO_Load(TSS_CONTEXT *tssContext,\n\t\t\t  Load_In *in,\n\t\t\t  Load_Out *out,\n\t\t\t  void *extra);\nstatic TPM_RC TSS_PO_LoadExternal(TSS_CONTEXT *tssContext,\n\t\t\t\t  LoadExternal_In *in,\n\t\t\t\t  LoadExternal_Out *out,\n\t\t\t\t  void *extra);\nstatic TPM_RC TSS_PO_ReadPublic(TSS_CONTEXT *tssContext,\n\t\t\t\tReadPublic_In *in,\n\t\t\t\tReadPublic_Out *out,\n\t\t\t\tvoid *extra);\nstatic TPM_RC TSS_PO_CreateLoaded(TSS_CONTEXT *tssContext,\n\t\t\t\t  CreateLoaded_In *in,\n\t\t\t\t  CreateLoaded_Out *out,\n\t\t\t\t  void *extra);\nstatic TPM_RC TSS_PO_HMAC_Start(TSS_CONTEXT *tssContext,\n\t\t\t\tHMAC_Start_In *in,\n\t\t\t\tHMAC_Start_Out *out,\n\t\t\t\tvoid *extra);\nstatic TPM_RC TSS_PO_HashSequenceStart(TSS_CONTEXT *tssContext,\n\t\t\t\t       HashSequenceStart_In *in,\n\t\t\t\t       HashSequenceStart_Out *out,\n\t\t\t\t       void *extra);\nstatic TPM_RC TSS_PO_SequenceComplete(TSS_CONTEXT *tssContext,\n\t\t\t\t      SequenceComplete_In *in,\n\t\t\t\t      SequenceComplete_Out *out,\n\t\t\t\t      void *extra);\nstatic TPM_RC TSS_PO_EventSequenceComplete(TSS_CONTEXT *tssContext,\n\t\t\t\t\t   EventSequenceComplete_In *in,\n\t\t\t\t\t   EventSequenceComplete_Out *out,\n\t\t\t\t\t   void *extra);\nstatic TPM_RC TSS_PO_PolicyAuthValue(TSS_CONTEXT *tssContext,\n\t\t\t\t     PolicyAuthValue_In *in,\n\t\t\t\t     void *out,\n\t\t\t\t     void *extra);\nstatic TPM_RC TSS_PO_PolicyPassword(TSS_CONTEXT *tssContext,\n\t\t\t\t    PolicyPassword_In *in,\n\t\t\t\t    void *out,\n\t\t\t\t    void *extra);\nstatic TPM_RC TSS_PO_CreatePrimary(TSS_CONTEXT *tssContext,\n\t\t\t\t   CreatePrimary_In *in,\n\t\t\t\t   CreatePrimary_Out *out,\n\t\t\t\t   void *extra);\nstatic TPM_RC TSS_PO_NV_DefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t\t    NV_DefineSpace_In *in,\n\t\t\t\t    void *out,\n\t\t\t\t    void *extra);\nstatic TPM_RC TSS_PO_NV_ReadPublic(TSS_CONTEXT *tssContext,\n\t\t\t\t   NV_ReadPublic_In *in,\n\t\t\t\t   NV_ReadPublic_Out *out,\n\t\t\t\t   void *extra);\nstatic TPM_RC TSS_PO_NV_UndefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t\t      NV_UndefineSpace_In *in,\n\t\t\t\t      void *out,\n\t\t\t\t      void *extra);\nstatic TPM_RC TSS_PO_NV_UndefineSpaceSpecial(TSS_CONTEXT *tssContext,\n\t\t\t\t\t     NV_UndefineSpaceSpecial_In *in,\n\t\t\t\t\t     void *out,\n\t\t\t\t\t     void *extra);\nstatic TPM_RC TSS_PO_NV_Write(TSS_CONTEXT *tssContext,\n\t\t\t      NV_Write_In *in,\n\t\t\t      void *out,\n\t\t\t      void *extra);\nstatic TPM_RC TSS_PO_NV_WriteLock(TSS_CONTEXT *tssContext,\n\t\t\t\t  NV_WriteLock_In *in,\n\t\t\t\t  void *out,\n\t\t\t\t  void *extra);\nstatic TPM_RC TSS_PO_NV_ReadLock(TSS_CONTEXT *tssContext,\n\t\t\t\t NV_ReadLock_In *in,\n\t\t\t\t void *out,\n\t\t\t\t void *extra);\n\n#ifdef TPM_TSS_NODEPRECATEDALGS\n\n/*\n  Functions to check for usage of deprecated algorithms.\n*/\n\nstatic TPM_RC TSS_CheckSha1_PublicArea(TPMT_PUBLIC *publicArea)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (publicArea->nameAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    if (rc == 0) {\n\tif (((publicArea->type == TPM_ALG_RSA) || (publicArea->type == TPM_ALG_ECC)) &&\n\t    (publicArea->parameters.asymDetail.scheme.scheme != TPM_ALG_NULL) &&\n\t    (publicArea->parameters.asymDetail.scheme.details.anySig.hashAlg == TPM_ALG_SHA1)) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CheckSha1_SigScheme(TPMT_SIG_SCHEME *sigScheme)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (sigScheme->details.any.hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_StartAuthSession(StartAuthSession_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->authHash == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_Create(Create_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_PublicArea(&in->inPublic.publicArea);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_Load(Load_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_PublicArea(&in->inPublic.publicArea);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_LoadExternal(LoadExternal_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_PublicArea(&in->inPublic.publicArea);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_CreateLoaded(CreateLoaded_In *in)\n{\n    TPM_RC rc = 0;\n    uint32_t size = sizeof(in->inPublic.t.buffer);\n    uint8_t *buffer = in->inPublic.t.buffer;\n    TPMT_PUBLIC publicArea;\n\n    if (rc == 0) {\n\trc = TSS_TPMT_PUBLIC_Unmarshalu(&publicArea, &buffer, &size, TRUE);\n    }\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_PublicArea(&publicArea);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_Import(Import_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_PublicArea(&in->objectPublic.publicArea);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_RSA_Encrypt(RSA_Encrypt_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->inScheme.details.anySig.hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_RSA_Decrypt(RSA_Decrypt_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->inScheme.details.anySig.hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_ECC_Encrypt(ECC_Encrypt_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->inScheme.details.mgf1.hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_ECC_Decrypt(ECC_Decrypt_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->inScheme.details.mgf1.hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_Hash(Hash_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_HMAC(HMAC_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_HMAC_Start(HMAC_Start_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_HashSequenceStart(HashSequenceStart_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_Certify(Certify_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_SigScheme(&in->inScheme);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_CertifyX509(CertifyX509_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_SigScheme(&in->inScheme);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_CertifyCreation(CertifyCreation_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_SigScheme(&in->inScheme);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_Quote(Quote_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_SigScheme(&in->inScheme);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_GetSessionAuditDigest(GetSessionAuditDigest_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_SigScheme(&in->inScheme);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_GetCommandAuditDigest(GetCommandAuditDigest_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_SigScheme(&in->inScheme);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_GetTime(GetTime_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_SigScheme(&in->inScheme);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_VerifySignature(VerifySignature_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->signature.signature.any.hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_Sign(Sign_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_SigScheme(&in->inScheme);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_SetCommandCodeAuditStatus(SetCommandCodeAuditStatus_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->auditAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_PolicySigned(PolicySigned_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->auth.signature.any.hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_CreatePrimary(CreatePrimary_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_PublicArea(&in->inPublic.publicArea);\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_SetPrimaryPolicy(SetPrimaryPolicy_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->hashAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_NV_DefineSpace(NV_DefineSpace_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (in->publicInfo.nvPublic.nameAlg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n\n    return rc;\n}\n\nstatic TPM_RC TSS_CH_NV_Certify(NV_Certify_In *in)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_CheckSha1_SigScheme(&in->inScheme);\n    }\n\n    return rc;\n}\n\n#endif /* TPM_TSS_NODEPRECATEDALGS */\n\ntypedef struct TSS_TABLE {\n    TPM_CC \t\t\t\tcommandCode;\n    TSS_PreProcessFunction_t\t\tpreProcessFunction;\n    TSS_ChangeAuthFunction_t\t\tchangeAuthFunction;\n    TSS_PostProcessFunction_t \t\tpostProcessFunction;\n} TSS_TABLE;\n\n/* This table indexes from the command to pre- and post- processing functions.  A missing entry is\n   not an error, and indicates a command with no functions. */\n\nstatic const TSS_TABLE tssTable [] = {\n\n    {TPM_CC_Startup, NULL, NULL, NULL},\n    {TPM_CC_Shutdown, NULL, NULL, NULL},\n    {TPM_CC_SelfTest, NULL, NULL, NULL},\n    {TPM_CC_IncrementalSelfTest, NULL, NULL, NULL},\n    {TPM_CC_GetTestResult, NULL, NULL, NULL},\n    {TPM_CC_StartAuthSession, (TSS_PreProcessFunction_t)TSS_PR_StartAuthSession, NULL, (TSS_PostProcessFunction_t)TSS_PO_StartAuthSession},\n    {TPM_CC_PolicyRestart, NULL, NULL, NULL},\n    {TPM_CC_Create, NULL, NULL, NULL},\n    {TPM_CC_Load, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_Load},\n    {TPM_CC_LoadExternal, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_LoadExternal},\n    {TPM_CC_ReadPublic, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_ReadPublic},\n    {TPM_CC_ActivateCredential, NULL, NULL, NULL},\n    {TPM_CC_MakeCredential, NULL, NULL, NULL},\n    {TPM_CC_Unseal, NULL, NULL, NULL},\n    {TPM_CC_ObjectChangeAuth, NULL, NULL, NULL},\n    {TPM_CC_CreateLoaded, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_CreateLoaded},\n    {TPM_CC_Duplicate, NULL, NULL, NULL},\n    {TPM_CC_Rewrap, NULL, NULL, NULL},\n    {TPM_CC_Import, NULL, NULL, NULL},\n    {TPM_CC_RSA_Encrypt, NULL, NULL, NULL},\n    {TPM_CC_RSA_Decrypt, NULL, NULL, NULL},\n    {TPM_CC_ECDH_KeyGen, NULL, NULL, NULL},\n    {TPM_CC_ECDH_ZGen, NULL, NULL, NULL},\n    {TPM_CC_ECC_Encrypt, NULL, NULL, NULL},\n    {TPM_CC_ECC_Decrypt, NULL, NULL, NULL},\n    {TPM_CC_ECC_Parameters, NULL, NULL, NULL},\n    {TPM_CC_ZGen_2Phase, NULL, NULL, NULL},\n    {TPM_CC_EncryptDecrypt, NULL, NULL, NULL},\n    {TPM_CC_EncryptDecrypt2, NULL, NULL, NULL},\n    {TPM_CC_Hash, NULL, NULL, NULL},\n    {TPM_CC_HMAC, NULL, NULL, NULL},\n    {TPM_CC_GetRandom, NULL, NULL, NULL},\n    {TPM_CC_StirRandom, NULL, NULL, NULL},\n    {TPM_CC_HMAC_Start, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_HMAC_Start},\n    {TPM_CC_HashSequenceStart, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_HashSequenceStart},\n    {TPM_CC_SequenceUpdate, NULL, NULL, NULL},\n    {TPM_CC_SequenceComplete, NULL,NULL, (TSS_PostProcessFunction_t)TSS_PO_SequenceComplete},\n    {TPM_CC_EventSequenceComplete, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_EventSequenceComplete},\n    {TPM_CC_Certify, NULL, NULL, NULL},\n    {TPM_CC_CertifyX509, NULL, NULL, NULL},\n    {TPM_CC_CertifyCreation, NULL, NULL, NULL},\n    {TPM_CC_Quote, NULL, NULL, NULL},\n    {TPM_CC_GetSessionAuditDigest, NULL, NULL, NULL},\n    {TPM_CC_GetCommandAuditDigest, NULL, NULL, NULL},\n    {TPM_CC_GetTime, NULL, NULL, NULL},\n    {TPM_CC_Commit, NULL, NULL, NULL},\n    {TPM_CC_EC_Ephemeral, NULL, NULL, NULL},\n    {TPM_CC_VerifySignature, NULL, NULL, NULL},\n    {TPM_CC_Sign, NULL, NULL, NULL},\n    {TPM_CC_SetCommandCodeAuditStatus, NULL, NULL, NULL},\n    {TPM_CC_PCR_Extend, NULL, NULL, NULL},\n    {TPM_CC_PCR_Event, NULL, NULL, NULL},\n    {TPM_CC_PCR_Read, NULL, NULL, NULL},\n    {TPM_CC_PCR_Allocate, NULL, NULL, NULL},\n    {TPM_CC_PCR_SetAuthPolicy, NULL, NULL, NULL},\n    {TPM_CC_PCR_SetAuthValue, NULL, NULL, NULL},\n    {TPM_CC_PCR_Reset, NULL, NULL, NULL},\n    {TPM_CC_PolicySigned, NULL, NULL, NULL},\n    {TPM_CC_PolicySecret, NULL, NULL, NULL},\n    {TPM_CC_PolicyTicket, NULL, NULL, NULL},\n    {TPM_CC_PolicyOR, NULL, NULL, NULL},\n    {TPM_CC_PolicyPCR, NULL, NULL, NULL},\n    {TPM_CC_PolicyLocality, NULL, NULL, NULL},\n    {TPM_CC_PolicyNV, NULL, NULL, NULL},\n    {TPM_CC_PolicyAuthorizeNV, NULL, NULL, NULL},\n    {TPM_CC_PolicyCounterTimer, NULL, NULL, NULL},\n    {TPM_CC_PolicyCommandCode, NULL, NULL, NULL},\n    {TPM_CC_PolicyPhysicalPresence, NULL, NULL, NULL},\n    {TPM_CC_PolicyCpHash, NULL, NULL, NULL},\n    {TPM_CC_PolicyNameHash, NULL, NULL, NULL},\n    {TPM_CC_PolicyDuplicationSelect, NULL, NULL, NULL},\n    {TPM_CC_PolicyAuthorize, NULL, NULL, NULL},\n    {TPM_CC_PolicyAuthValue, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_PolicyAuthValue},\n    {TPM_CC_PolicyPassword, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_PolicyPassword},\n    {TPM_CC_PolicyGetDigest, NULL, NULL, NULL},\n    {TPM_CC_PolicyNvWritten, NULL, NULL, NULL},\n    {TPM_CC_PolicyTemplate, NULL, NULL, NULL},\n    {TPM_CC_PolicyCapability, NULL, NULL, NULL},\n    {TPM_CC_PolicyParameters, NULL, NULL, NULL},\n    {TPM_CC_CreatePrimary, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_CreatePrimary},\n    {TPM_CC_HierarchyControl, NULL, NULL, NULL},\n    {TPM_CC_SetPrimaryPolicy, NULL, NULL, NULL},\n    {TPM_CC_ChangePPS, NULL, NULL, NULL},\n    {TPM_CC_ChangeEPS, NULL, NULL, NULL},\n    {TPM_CC_Clear, NULL, NULL, NULL},\n    {TPM_CC_ClearControl, NULL, NULL, NULL},\n    {TPM_CC_HierarchyChangeAuth, NULL, (TSS_ChangeAuthFunction_t)TSS_CA_HierarchyChangeAuth, NULL},\n    {TPM_CC_DictionaryAttackLockReset, NULL, NULL, NULL},\n    {TPM_CC_DictionaryAttackParameters, NULL, NULL, NULL},\n    {TPM_CC_PP_Commands, NULL, NULL, NULL},\n    {TPM_CC_SetAlgorithmSet, NULL, NULL, NULL},\n    {TPM_CC_ContextSave, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_ContextSave},\n    {TPM_CC_ContextLoad, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_ContextLoad},\n    {TPM_CC_FlushContext, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_FlushContext},\n    {TPM_CC_EvictControl, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_EvictControl},\n    {TPM_CC_ReadClock, NULL, NULL, NULL},\n    {TPM_CC_ClockSet, NULL, NULL, NULL},\n    {TPM_CC_ClockRateAdjust, NULL, NULL, NULL},\n    {TPM_CC_GetCapability, NULL, NULL, NULL},\n    {TPM_CC_TestParms, NULL, NULL, NULL},\n    {TPM_CC_NV_DefineSpace, (TSS_PreProcessFunction_t)TSS_PR_NV_DefineSpace, NULL,  (TSS_PostProcessFunction_t)TSS_PO_NV_DefineSpace},\n    {TPM_CC_NV_UndefineSpace, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_UndefineSpace},\n    {TPM_CC_NV_UndefineSpaceSpecial, NULL, (TSS_ChangeAuthFunction_t)TSS_CA_NV_UndefineSpaceSpecial, (TSS_PostProcessFunction_t)TSS_PO_NV_UndefineSpaceSpecial},\n    {TPM_CC_NV_ReadPublic, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_ReadPublic},\n    {TPM_CC_NV_Write, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_Write},\n    {TPM_CC_NV_Increment, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_Write},\n    {TPM_CC_NV_Extend, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_Write},\n    {TPM_CC_NV_SetBits, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_Write},\n    {TPM_CC_NV_WriteLock, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_WriteLock},\n    {TPM_CC_NV_GlobalWriteLock, NULL, NULL, NULL},\n    {TPM_CC_NV_Read, NULL, NULL, NULL},\n    {TPM_CC_NV_ReadLock, NULL, NULL, (TSS_PostProcessFunction_t)TSS_PO_NV_ReadLock},\n    {TPM_CC_NV_ChangeAuth, NULL, (TSS_ChangeAuthFunction_t)TSS_CA_NV_ChangeAuth, NULL},\n    {TPM_CC_NV_Certify, NULL, NULL, NULL}\n};\n\n#ifdef TPM_TSS_NODEPRECATEDALGS\n\n/* This table indexes from the command to algorith check processing functions.  A missing entry is\n   not an error, and indicates a command with no functions. */\n\ntypedef struct TSS_CH_TABLE {\n    TPM_CC \t\t\t\tcommandCode;\n    TSS_CheckParametersFunction_t\tcheckParametersFunction;\n} TSS_CH_TABLE;\n\nstatic const TSS_CH_TABLE tssChTable [] = {\n\n    {TPM_CC_Startup, NULL},\n    {TPM_CC_Shutdown, NULL},\n    {TPM_CC_SelfTest, NULL},\n    {TPM_CC_IncrementalSelfTest, NULL},\n    {TPM_CC_GetTestResult, NULL},\n    {TPM_CC_StartAuthSession, (TSS_CheckParametersFunction_t)TSS_CH_StartAuthSession},\n    {TPM_CC_PolicyRestart, NULL},\n    {TPM_CC_Create, (TSS_CheckParametersFunction_t)TSS_CH_Create},\n    {TPM_CC_Load, (TSS_CheckParametersFunction_t)TSS_CH_Load},\n    {TPM_CC_LoadExternal, (TSS_CheckParametersFunction_t)TSS_CH_LoadExternal},\n    {TPM_CC_ReadPublic, NULL},\n    {TPM_CC_ActivateCredential, NULL},\n    {TPM_CC_MakeCredential, NULL},\n    {TPM_CC_Unseal, NULL},\n    {TPM_CC_ObjectChangeAuth, NULL},\n    {TPM_CC_CreateLoaded, (TSS_CheckParametersFunction_t)TSS_CH_CreateLoaded},\n    {TPM_CC_Duplicate, NULL},\n    {TPM_CC_Rewrap, NULL},\n    {TPM_CC_Import, (TSS_CheckParametersFunction_t)TSS_CH_Import},\n    {TPM_CC_RSA_Encrypt, (TSS_CheckParametersFunction_t)TSS_CH_RSA_Encrypt},\n    {TPM_CC_RSA_Decrypt, (TSS_CheckParametersFunction_t)TSS_CH_RSA_Decrypt},\n    {TPM_CC_ECDH_KeyGen, NULL},\n    {TPM_CC_ECDH_ZGen, NULL},\n    {TPM_CC_ECC_Encrypt, (TSS_CheckParametersFunction_t)TSS_CH_ECC_Encrypt},\n    {TPM_CC_ECC_Decrypt, (TSS_CheckParametersFunction_t)TSS_CH_ECC_Decrypt},\n    {TPM_CC_ECC_Parameters, NULL},\n    {TPM_CC_ZGen_2Phase, NULL},\n    {TPM_CC_EncryptDecrypt, NULL},\n    {TPM_CC_EncryptDecrypt2, NULL},\n    {TPM_CC_Hash, (TSS_CheckParametersFunction_t)TSS_CH_Hash},\n    {TPM_CC_HMAC, (TSS_CheckParametersFunction_t)TSS_CH_HMAC},\n    {TPM_CC_GetRandom, NULL},\n    {TPM_CC_StirRandom, NULL},\n    {TPM_CC_HMAC_Start, (TSS_CheckParametersFunction_t)TSS_CH_HMAC_Start},\n    {TPM_CC_HashSequenceStart, (TSS_CheckParametersFunction_t)TSS_CH_HashSequenceStart},\n    {TPM_CC_SequenceUpdate, NULL},\n    {TPM_CC_SequenceComplete, NULL},\n    {TPM_CC_EventSequenceComplete, NULL},\n    {TPM_CC_Certify, (TSS_CheckParametersFunction_t)TSS_CH_Certify},\n    {TPM_CC_CertifyX509, (TSS_CheckParametersFunction_t)TSS_CH_CertifyX509},\n    {TPM_CC_CertifyCreation, (TSS_CheckParametersFunction_t)TSS_CH_CertifyCreation},\n    {TPM_CC_Quote, (TSS_CheckParametersFunction_t)TSS_CH_Quote},\n    {TPM_CC_GetSessionAuditDigest, (TSS_CheckParametersFunction_t)TSS_CH_GetSessionAuditDigest},\n    {TPM_CC_GetCommandAuditDigest, (TSS_CheckParametersFunction_t)TSS_CH_GetCommandAuditDigest},\n    {TPM_CC_GetTime, (TSS_CheckParametersFunction_t)TSS_CH_GetTime},\n    {TPM_CC_Commit, NULL},\n    {TPM_CC_EC_Ephemeral, NULL},\n    {TPM_CC_VerifySignature, (TSS_CheckParametersFunction_t)TSS_CH_VerifySignature},\n    {TPM_CC_Sign, (TSS_CheckParametersFunction_t)TSS_CH_Sign},\n    {TPM_CC_SetCommandCodeAuditStatus, (TSS_CheckParametersFunction_t)TSS_CH_SetCommandCodeAuditStatus},\n    {TPM_CC_PCR_Extend, NULL},\n    {TPM_CC_PCR_Event, NULL},\n    {TPM_CC_PCR_Read, NULL},\n    {TPM_CC_PCR_Allocate, NULL},\n    {TPM_CC_PCR_SetAuthPolicy, NULL},\n    {TPM_CC_PCR_SetAuthValue, NULL},\n    {TPM_CC_PCR_Reset, NULL},\n    {TPM_CC_PolicySigned, (TSS_CheckParametersFunction_t)TSS_CH_PolicySigned},\n    {TPM_CC_PolicySecret, NULL},\n    {TPM_CC_PolicyTicket, NULL},\n    {TPM_CC_PolicyOR, NULL},\n    {TPM_CC_PolicyPCR, NULL},\n    {TPM_CC_PolicyLocality, NULL},\n    {TPM_CC_PolicyNV, NULL},\n    {TPM_CC_PolicyAuthorizeNV, NULL},\n    {TPM_CC_PolicyCounterTimer, NULL},\n    {TPM_CC_PolicyCommandCode, NULL},\n    {TPM_CC_PolicyPhysicalPresence, NULL},\n    {TPM_CC_PolicyCpHash, NULL},\n    {TPM_CC_PolicyNameHash, NULL},\n    {TPM_CC_PolicyDuplicationSelect, NULL},\n    {TPM_CC_PolicyAuthorize, NULL},\n    {TPM_CC_PolicyAuthValue, NULL},\n    {TPM_CC_PolicyPassword, NULL},\n    {TPM_CC_PolicyGetDigest, NULL},\n    {TPM_CC_PolicyNvWritten, NULL},\n    {TPM_CC_PolicyTemplate, NULL},\n    {TPM_CC_PolicyCapability, NULL},\n    {TPM_CC_PolicyParameters, NULL},\n    {TPM_CC_CreatePrimary, (TSS_CheckParametersFunction_t)TSS_CH_CreatePrimary},\n    {TPM_CC_HierarchyControl, NULL},\n    {TPM_CC_SetPrimaryPolicy, (TSS_CheckParametersFunction_t)TSS_CH_SetPrimaryPolicy},\n    {TPM_CC_ChangePPS, NULL},\n    {TPM_CC_ChangeEPS, NULL},\n    {TPM_CC_Clear, NULL},\n    {TPM_CC_ClearControl, NULL},\n    {TPM_CC_HierarchyChangeAuth, NULL},\n    {TPM_CC_DictionaryAttackLockReset, NULL},\n    {TPM_CC_DictionaryAttackParameters, NULL},\n    {TPM_CC_PP_Commands, NULL},\n    {TPM_CC_SetAlgorithmSet, NULL},\n    {TPM_CC_ContextSave, NULL},\n    {TPM_CC_ContextLoad, NULL},\n    {TPM_CC_FlushContext, NULL},\n    {TPM_CC_EvictControl, NULL},\n    {TPM_CC_ReadClock, NULL},\n    {TPM_CC_ClockSet, NULL},\n    {TPM_CC_ClockRateAdjust, NULL},\n    {TPM_CC_GetCapability, NULL},\n    {TPM_CC_TestParms, NULL},\n    {TPM_CC_NV_DefineSpace, (TSS_CheckParametersFunction_t)TSS_CH_NV_DefineSpace},\n    {TPM_CC_NV_UndefineSpace, NULL},\n    {TPM_CC_NV_UndefineSpaceSpecial, NULL},\n    {TPM_CC_NV_ReadPublic, NULL},\n    {TPM_CC_NV_Write, NULL},\n    {TPM_CC_NV_Increment, NULL},\n    {TPM_CC_NV_Extend, NULL},\n    {TPM_CC_NV_SetBits, NULL},\n    {TPM_CC_NV_WriteLock, NULL},\n    {TPM_CC_NV_GlobalWriteLock, NULL},\n    {TPM_CC_NV_Read, NULL},\n    {TPM_CC_NV_ReadLock, NULL},\n    {TPM_CC_NV_ChangeAuth, NULL},\n    {TPM_CC_NV_Certify, (TSS_CheckParametersFunction_t)TSS_CH_NV_Certify}\n};\n\n#endif  /* TPM_TSS_NODEPRECATEDALGS */\n\n#ifndef TPM_TSS_NO_PRINT\n\ntypedef void (*TSS_InPrintFunction_t)(COMMAND_PARAMETERS *in, unsigned int indent);\n\ntypedef struct TSS_PRINT_TABLE {\n    TPM_CC \t\t\tcommandCode;\n    TSS_InPrintFunction_t\tinPrintFunction;\n} TSS_PRINT_TABLE;\n\n/* This table indexes from the command to print functions.  A missing entry is\n   not an error, and indicates a command with no function. */\n\nstatic const TSS_PRINT_TABLE tssPrintTable [] = {\n\t\t\t\t \n    {TPM_CC_Startup, (TSS_InPrintFunction_t)Startup_In_Print},\n    {TPM_CC_Shutdown, (TSS_InPrintFunction_t)Shutdown_In_Print},\n    {TPM_CC_SelfTest, (TSS_InPrintFunction_t)SelfTest_In_Print},\n    {TPM_CC_IncrementalSelfTest, (TSS_InPrintFunction_t)IncrementalSelfTest_In_Print},\n    {TPM_CC_GetTestResult, NULL},\n    {TPM_CC_StartAuthSession, (TSS_InPrintFunction_t)StartAuthSession_In_Print},\n    {TPM_CC_PolicyRestart, (TSS_InPrintFunction_t)PolicyRestart_In_Print},\n    {TPM_CC_Create,(TSS_InPrintFunction_t)Create_In_Print},\n    {TPM_CC_Load, (TSS_InPrintFunction_t)Load_In_Print},\n    {TPM_CC_LoadExternal, (TSS_InPrintFunction_t)LoadExternal_In_Print},\n    {TPM_CC_ReadPublic, (TSS_InPrintFunction_t)ReadPublic_In_Print},\n    {TPM_CC_ActivateCredential, (TSS_InPrintFunction_t)ActivateCredential_In_Print},\n    {TPM_CC_MakeCredential, (TSS_InPrintFunction_t)MakeCredential_In_Print},\n    {TPM_CC_Unseal, (TSS_InPrintFunction_t)Unseal_In_Print},\n    {TPM_CC_ObjectChangeAuth, (TSS_InPrintFunction_t)ObjectChangeAuth_In_Print},\n    {TPM_CC_CreateLoaded, (TSS_InPrintFunction_t)CreateLoaded_In_Print},\n    {TPM_CC_Duplicate, (TSS_InPrintFunction_t)Duplicate_In_Print},\n    {TPM_CC_Rewrap, (TSS_InPrintFunction_t)Rewrap_In_Print},\n    {TPM_CC_Import, (TSS_InPrintFunction_t)Import_In_Print},\n    {TPM_CC_RSA_Encrypt, (TSS_InPrintFunction_t)RSA_Encrypt_In_Print},\n    {TPM_CC_RSA_Decrypt, (TSS_InPrintFunction_t)RSA_Decrypt_In_Print},\n    {TPM_CC_ECDH_KeyGen, (TSS_InPrintFunction_t)ECDH_KeyGen_In_Print},\n    {TPM_CC_ECDH_ZGen, (TSS_InPrintFunction_t)ECDH_ZGen_In_Print},\n    {TPM_CC_ECC_Encrypt, (TSS_InPrintFunction_t)ECC_Encrypt_In_Print},\n    {TPM_CC_ECC_Decrypt, (TSS_InPrintFunction_t)ECC_Decrypt_In_Print},\n    {TPM_CC_ECC_Parameters, (TSS_InPrintFunction_t)ECC_Parameters_In_Print},\n    {TPM_CC_ZGen_2Phase, (TSS_InPrintFunction_t)ZGen_2Phase_In_Print},\n    {TPM_CC_EncryptDecrypt, (TSS_InPrintFunction_t)EncryptDecrypt_In_Print},\n    {TPM_CC_EncryptDecrypt2, (TSS_InPrintFunction_t)EncryptDecrypt2_In_Print},\n    {TPM_CC_Hash, (TSS_InPrintFunction_t)Hash_In_Print},\n    {TPM_CC_HMAC, (TSS_InPrintFunction_t)HMAC_In_Print},\n    {TPM_CC_GetRandom, (TSS_InPrintFunction_t)GetRandom_In_Print},\n    {TPM_CC_StirRandom, (TSS_InPrintFunction_t)StirRandom_In_Print},\n    {TPM_CC_HMAC_Start, (TSS_InPrintFunction_t)HMAC_Start_In_Print},\n    {TPM_CC_HashSequenceStart, (TSS_InPrintFunction_t)HashSequenceStart_In_Print},\n    {TPM_CC_SequenceUpdate, (TSS_InPrintFunction_t)SequenceUpdate_In_Print},\n    {TPM_CC_SequenceComplete, (TSS_InPrintFunction_t)SequenceComplete_In_Print},\n    {TPM_CC_EventSequenceComplete, (TSS_InPrintFunction_t)EventSequenceComplete_In_Print},\n    {TPM_CC_Certify, (TSS_InPrintFunction_t)Certify_In_Print},\n    {TPM_CC_CertifyX509, (TSS_InPrintFunction_t)CertifyX509_In_Print},\n    {TPM_CC_CertifyCreation, (TSS_InPrintFunction_t)CertifyCreation_In_Print},\n    {TPM_CC_Quote, (TSS_InPrintFunction_t)Quote_In_Print},\n    {TPM_CC_GetSessionAuditDigest, (TSS_InPrintFunction_t)GetSessionAuditDigest_In_Print},\n    {TPM_CC_GetCommandAuditDigest, (TSS_InPrintFunction_t)GetCommandAuditDigest_In_Print},\n    {TPM_CC_GetTime, (TSS_InPrintFunction_t)GetTime_In_Print},\n    {TPM_CC_Commit, (TSS_InPrintFunction_t)Commit_In_Print},\n    {TPM_CC_EC_Ephemeral, (TSS_InPrintFunction_t)EC_Ephemeral_In_Print},\n    {TPM_CC_VerifySignature, (TSS_InPrintFunction_t)VerifySignature_In_Print},\n    {TPM_CC_Sign, (TSS_InPrintFunction_t)Sign_In_Print},\n    {TPM_CC_SetCommandCodeAuditStatus, (TSS_InPrintFunction_t)SetCommandCodeAuditStatus_In_Print},\n    {TPM_CC_PCR_Extend, (TSS_InPrintFunction_t)PCR_Extend_In_Print},\n    {TPM_CC_PCR_Event, (TSS_InPrintFunction_t)PCR_Event_In_Print},\n    {TPM_CC_PCR_Read, (TSS_InPrintFunction_t)PCR_Read_In_Print},\n    {TPM_CC_PCR_Allocate, (TSS_InPrintFunction_t)PCR_Allocate_In_Print},\n    {TPM_CC_PCR_SetAuthPolicy, (TSS_InPrintFunction_t)PCR_SetAuthPolicy_In_Print},\n    {TPM_CC_PCR_SetAuthValue, (TSS_InPrintFunction_t)PCR_SetAuthValue_In_Print},\n    {TPM_CC_PCR_Reset, (TSS_InPrintFunction_t)PCR_Reset_In_Print},\n    {TPM_CC_PolicySigned, (TSS_InPrintFunction_t)PolicySigned_In_Print},\n    {TPM_CC_PolicySecret, (TSS_InPrintFunction_t)PolicySecret_In_Print},\n    {TPM_CC_PolicyTicket, (TSS_InPrintFunction_t)PolicyTicket_In_Print},\n    {TPM_CC_PolicyOR, (TSS_InPrintFunction_t)PolicyOR_In_Print},\n    {TPM_CC_PolicyPCR, (TSS_InPrintFunction_t)PolicyPCR_In_Print},\n    {TPM_CC_PolicyLocality, (TSS_InPrintFunction_t)PolicyLocality_In_Print},\n    {TPM_CC_PolicyNV, (TSS_InPrintFunction_t)PolicyNV_In_Print},\n    {TPM_CC_PolicyAuthorizeNV, (TSS_InPrintFunction_t)PolicyAuthorizeNV_In_Print},\n    {TPM_CC_PolicyCounterTimer, (TSS_InPrintFunction_t)PolicyCounterTimer_In_Print},\n    {TPM_CC_PolicyCommandCode, (TSS_InPrintFunction_t)PolicyCommandCode_In_Print},\n    {TPM_CC_PolicyPhysicalPresence, (TSS_InPrintFunction_t)PolicyPhysicalPresence_In_Print},\n    {TPM_CC_PolicyCpHash, (TSS_InPrintFunction_t)PolicyCpHash_In_Print},\n    {TPM_CC_PolicyNameHash, (TSS_InPrintFunction_t)PolicyNameHash_In_Print},\n    {TPM_CC_PolicyDuplicationSelect, (TSS_InPrintFunction_t)PolicyDuplicationSelect_In_Print},\n    {TPM_CC_PolicyAuthorize, (TSS_InPrintFunction_t)PolicyAuthorize_In_Print},\n    {TPM_CC_PolicyAuthValue, (TSS_InPrintFunction_t)PolicyAuthValue_In_Print},\n    {TPM_CC_PolicyPassword, (TSS_InPrintFunction_t)PolicyPassword_In_Print},\n    {TPM_CC_PolicyGetDigest, (TSS_InPrintFunction_t)PolicyGetDigest_In_Print},\n    {TPM_CC_PolicyNvWritten, (TSS_InPrintFunction_t)PolicyNvWritten_In_Print},\n    {TPM_CC_PolicyTemplate, (TSS_InPrintFunction_t)PolicyTemplate_In_Print},\n    {TPM_CC_PolicyCapability, (TSS_InPrintFunction_t)PolicyCapability_In_Print},\n    {TPM_CC_PolicyParameters, (TSS_InPrintFunction_t)PolicyParameters_In_Print},\n    {TPM_CC_CreatePrimary, (TSS_InPrintFunction_t)CreatePrimary_In_Print},\n    {TPM_CC_HierarchyControl, (TSS_InPrintFunction_t)HierarchyControl_In_Print},\n    {TPM_CC_SetPrimaryPolicy, (TSS_InPrintFunction_t)SetPrimaryPolicy_In_Print},\n    {TPM_CC_ChangePPS, (TSS_InPrintFunction_t)ChangePPS_In_Print},\n    {TPM_CC_ChangeEPS, (TSS_InPrintFunction_t)ChangeEPS_In_Print},\n    {TPM_CC_Clear, (TSS_InPrintFunction_t)Clear_In_Print},\n    {TPM_CC_ClearControl, (TSS_InPrintFunction_t)ClearControl_In_Print},\n    {TPM_CC_HierarchyChangeAuth, (TSS_InPrintFunction_t)HierarchyChangeAuth_In_Print},\n    {TPM_CC_DictionaryAttackLockReset, (TSS_InPrintFunction_t)DictionaryAttackLockReset_In_Print},\n    {TPM_CC_DictionaryAttackParameters, (TSS_InPrintFunction_t)DictionaryAttackParameters_In_Print},\n    {TPM_CC_PP_Commands, (TSS_InPrintFunction_t)PP_Commands_In_Print},\n    {TPM_CC_SetAlgorithmSet, (TSS_InPrintFunction_t)SetAlgorithmSet_In_Print},\n    {TPM_CC_ContextSave, (TSS_InPrintFunction_t)ContextSave_In_Print},\n    {TPM_CC_ContextLoad, (TSS_InPrintFunction_t)ContextLoad_In_Print},\n    {TPM_CC_FlushContext, (TSS_InPrintFunction_t)FlushContext_In_Print},\n    {TPM_CC_EvictControl, (TSS_InPrintFunction_t)EvictControl_In_Print},\n    {TPM_CC_ReadClock, (TSS_InPrintFunction_t)NULL},\n    {TPM_CC_ClockSet, (TSS_InPrintFunction_t)ClockSet_In_Print},\n    {TPM_CC_ClockRateAdjust, (TSS_InPrintFunction_t)ClockRateAdjust_In_Print},\n    {TPM_CC_GetCapability, (TSS_InPrintFunction_t)GetCapability_In_Print},\n    {TPM_CC_TestParms, (TSS_InPrintFunction_t)TestParms_In_Print},\n    {TPM_CC_NV_DefineSpace, (TSS_InPrintFunction_t)NV_DefineSpace_In_Print},\n    {TPM_CC_NV_UndefineSpace, (TSS_InPrintFunction_t)NV_UndefineSpace_In_Print},\n    {TPM_CC_NV_UndefineSpaceSpecial, (TSS_InPrintFunction_t)NV_UndefineSpaceSpecial_In_Print},\n    {TPM_CC_NV_ReadPublic, (TSS_InPrintFunction_t)NV_ReadPublic_In_Print},\n    {TPM_CC_NV_Write, (TSS_InPrintFunction_t)NV_Write_In_Print},\n    {TPM_CC_NV_Increment, (TSS_InPrintFunction_t)NV_Increment_In_Print},\n    {TPM_CC_NV_Extend, (TSS_InPrintFunction_t)NV_Extend_In_Print},\n    {TPM_CC_NV_SetBits, (TSS_InPrintFunction_t)NV_SetBits_In_Print},\n    {TPM_CC_NV_WriteLock, (TSS_InPrintFunction_t)NV_WriteLock_In_Print},\n    {TPM_CC_NV_GlobalWriteLock, (TSS_InPrintFunction_t)NV_GlobalWriteLock_In_Print},\n    {TPM_CC_NV_Read, (TSS_InPrintFunction_t)NV_Read_In_Print},\n    {TPM_CC_NV_ReadLock, (TSS_InPrintFunction_t)NV_ReadLock_In_Print},\n    {TPM_CC_NV_ChangeAuth, (TSS_InPrintFunction_t)NV_ChangeAuth_In_Print},\n    {TPM_CC_NV_Certify, (TSS_InPrintFunction_t)NV_Certify_In_Print}\n};\n\n#endif /* TPM_TSS_NO_PRINT */\n\n/* local prototypes */\n\nstatic TPM_RC TSS_Execute_valist(TSS_CONTEXT *tssContext,\n\t\t\t\t COMMAND_PARAMETERS *in,\n\t\t\t\t va_list ap);\n\n\nstatic TPM_RC TSS_PwapSession_Set(TPMS_AUTH_COMMAND *authCommand,\n\t\t\t\t  const char *password);\nstatic TPM_RC TSS_PwapSession_Verify(TPMS_AUTH_RESPONSE *authResponse);\n\nstatic TPM_RC TSS_HmacSession_GetContext(struct TSS_HMAC_CONTEXT **session);\nstatic void   TSS_HmacSession_InitContext(struct TSS_HMAC_CONTEXT *session);\nstatic void   TSS_HmacSession_FreeContext(struct TSS_HMAC_CONTEXT *session);\n\n#ifndef TPM_TSS_NOCRYPTO\nstatic TPM_RC TSS_HmacSession_SetSessionKey(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t    TPM2B_DIGEST *salt,\n\t\t\t\t\t    TPMI_DH_ENTITY bind,\n\t\t\t\t\t    TPM2B_AUTH *bindAuthValue);\nstatic TPM_RC TSS_HmacSession_SetNonceCaller(struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t     TPMS_AUTH_COMMAND \t*authC);\nstatic TPM_RC TSS_HmacSession_SetHmacKey(TSS_CONTEXT *tssContext,\n\t\t\t\t\t struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t size_t handleNumber,\n\t\t\t\t\t const char *password);\n#endif\t/* TPM_TSS_NOCRYPTO */\nstatic TPM_RC TSS_HmacSession_SetHMAC(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t      struct TSS_HMAC_CONTEXT *session[],\n\t\t\t\t      TPMS_AUTH_COMMAND *authCommand[],\n\t\t\t\t      TPMI_SH_AUTH_SESSION sessionHandle[],\n\t\t\t\t      unsigned int sessionAttributes[],\n\t\t\t\t      const char *password[],\n\t\t\t\t      TPM2B_NAME *name0,\t\t  \n\t\t\t\t      TPM2B_NAME *name1,\t\t  \n\t\t\t\t      TPM2B_NAME *name2);\n#ifndef TPM_TSS_NOCRYPTO\nstatic TPM_RC TSS_HmacSession_Verify(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t     struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t     TPMS_AUTH_RESPONSE *authResponse);\n#endif\t/* TPM_TSS_NOCRYPTO */\nstatic TPM_RC TSS_HmacSession_Continue(TSS_CONTEXT *tssContext,\n\t\t\t\t       struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t       TPMS_AUTH_RESPONSE *authR);\n\n\nstatic TPM_RC TSS_HmacSession_SaveSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t  struct TSS_HMAC_CONTEXT *session);\nstatic TPM_RC TSS_HmacSession_LoadSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t  struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t  TPMI_SH_AUTH_SESSION\tsessionHandle);\n#ifdef TPM_TSS_NOFILE\nstatic TPM_RC TSS_HmacSession_SaveData(TSS_CONTEXT *tssContext,\n\t\t\t\t       TPMI_SH_AUTH_SESSION sessionHandle,\n\t\t\t\t       uint32_t outLength,\n\t\t\t\t       uint8_t *outBuffer);\nstatic TPM_RC TSS_HmacSession_LoadData(TSS_CONTEXT *tssContext,\n\t\t\t\t       uint32_t *inLength, uint8_t **inData,\n\t\t\t\t       TPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC TSS_HmacSession_DeleteData(TSS_CONTEXT *tssContext,\n\t\t\t\t\t TPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC TSS_HmacSession_GetSlotForHandle(TSS_CONTEXT *tssContext,\n\t\t\t\t\t       size_t *slotIndex,\n\t\t\t\t\t       TPMI_SH_AUTH_SESSION sessionHandle);\n#endif\nstatic TPM_RC TSS_HmacSession_Marshal(struct TSS_HMAC_CONTEXT *source,\n\t\t\t\t      uint16_t *written, uint8_t **buffer, uint32_t *size);\nstatic TPM_RC TSS_HmacSession_Unmarshal(struct TSS_HMAC_CONTEXT *target,\n\t\t\t\t\tuint8_t **buffer, uint32_t *size);\n\nstatic TPM_RC TSS_Name_GetAllNames(TSS_CONTEXT *tssContext,\n\t\t\t\t   TPM2B_NAME **names);\nstatic TPM_RC TSS_Name_GetName(TSS_CONTEXT *tssContext,\n\t\t\t       TPM2B_NAME *name,\n\t\t\t       TPM_HANDLE  handle);\nstatic TPM_RC TSS_Name_Store(TSS_CONTEXT *tssContext,\n\t\t\t     TPM2B_NAME *name,\n\t\t\t     TPM_HANDLE handle,\n\t\t\t     const char *string);\nstatic TPM_RC TSS_Name_Load(TSS_CONTEXT *tssContext,\n\t\t\t    TPM2B_NAME *name,\n\t\t\t    TPM_HANDLE handle,\n\t\t\t    const char *string);\nstatic TPM_RC TSS_Name_Copy(TSS_CONTEXT *tssContext,\n\t\t\t    TPM_HANDLE outHandle,\n\t\t\t    const char *outString,\n\t\t\t    TPM_HANDLE inHandle,\n\t\t\t    const char *inString);\nstatic TPM_RC TSS_Public_Store(TSS_CONTEXT *tssContext,\n\t\t\t       TPM2B_PUBLIC *public,\n\t\t\t       TPM_HANDLE handle,\n\t\t\t       const char *string);\nstatic TPM_RC TSS_Public_Load(TSS_CONTEXT *tssContext,\n\t\t\t      TPM2B_PUBLIC *public,\n\t\t\t      TPM_HANDLE handle,\n\t\t\t      const char *string);\nstatic TPM_RC TSS_Public_Copy(TSS_CONTEXT *tssContext,\n\t\t\t      TPM_HANDLE outHandle,\n\t\t\t      const char *outString,\n\t\t\t      TPM_HANDLE inHandle,\n\t\t\t      const char *inString);\n#ifdef TPM_TSS_NOFILE\nstatic TPM_RC TSS_ObjectPublic_GetSlotForHandle(TSS_CONTEXT *tssContext,\n\t\t\t\t\t\tsize_t *slotIndex,\n\t\t\t\t\t\tTPM_HANDLE handle);\nstatic TPM_RC TSS_ObjectPublic_DeleteData(TSS_CONTEXT *tssContext, TPM_HANDLE handle);\n#endif\nstatic TPM_RC TSS_DeleteHandle(TSS_CONTEXT *tssContext,\n\t\t\t       TPM_HANDLE handle);\n#ifndef TPM_TSS_NOCRYPTO\nstatic TPM_RC TSS_ObjectPublic_GetName(TPM2B_NAME *name,\n\t\t\t\t       TPMT_PUBLIC *tpmtPublic);\n\nstatic TPM_RC TSS_NVPublic_Store(TSS_CONTEXT *tssContext,\n\t\t\t\t TPMS_NV_PUBLIC *nvPublic,\n\t\t\t\t TPMI_RH_NV_INDEX handle);\nstatic TPM_RC TSS_NVPublic_Load(TSS_CONTEXT *tssContext,\n\t\t\t\tTPMS_NV_PUBLIC *nvPublic,\n\t\t\t\tTPMI_RH_NV_INDEX handle);\n#endif\nstatic TPM_RC TSS_NVPublic_Delete(TSS_CONTEXT *tssContext,\n\t\t\t\t  TPMI_RH_NV_INDEX nvIndex);\n#ifdef TPM_TSS_NOFILE\nstatic TPM_RC TSS_NvPublic_GetSlotForHandle(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    size_t *slotIndex,\n\t\t\t\t\t    TPMI_RH_NV_INDEX nvIndex);\n#endif\n\nstatic TPM_RC TSS_Command_Decrypt(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t  struct TSS_HMAC_CONTEXT *session[],\n\t\t\t\t  TPMI_SH_AUTH_SESSION sessionHandle[],\n\t\t\t\t  unsigned int sessionAttributes[]);\n#ifndef TPM_TSS_NOCRYPTO\nstatic TPM_RC TSS_Command_DecryptXor(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t     struct TSS_HMAC_CONTEXT *session);\nstatic TPM_RC TSS_Command_DecryptAes(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t     struct TSS_HMAC_CONTEXT *session);\n\n#endif\t/* TPM_TSS_NOCRYPTO */\nstatic TPM_RC TSS_Response_Encrypt(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t   struct TSS_HMAC_CONTEXT *session[],\n\t\t\t\t   TPMI_SH_AUTH_SESSION sessionHandle[],\n\t\t\t\t   unsigned int sessionAttributes[]);\n#ifndef TPM_TSS_NOCRYPTO\nstatic TPM_RC TSS_Response_EncryptXor(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t      struct TSS_HMAC_CONTEXT *session);\nstatic TPM_RC TSS_Response_EncryptAes(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t      struct TSS_HMAC_CONTEXT *session);\n\nstatic TPM_RC TSS_Command_ChangeAuthProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t\t      struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t      size_t handleNumber,\n\t\t\t\t\t      COMMAND_PARAMETERS *in);\n#endif\t/* TPM_TSS_NOCRYPTO */\n\n#ifdef TPM_TSS_NODEPRECATEDALGS\nstatic TPM_RC TSS_Command_CheckParameters(TPM_CC commandCode,\n\t\t\t\t\t  COMMAND_PARAMETERS *in);\n#endif\nstatic TPM_RC TSS_Command_PreProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t       TPM_CC commandCode,\n\t\t\t\t       COMMAND_PARAMETERS *in,\n\t\t\t\t       EXTRA_PARAMETERS *extra);\nstatic TPM_RC TSS_Response_PostProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t\t COMMAND_PARAMETERS *in,\n\t\t\t\t\t RESPONSE_PARAMETERS *out,\n\t\t\t\t\t EXTRA_PARAMETERS *extra);\n\nstatic TPM_RC TSS_Sessions_GetDecryptSession(unsigned int *isDecrypt,\n\t\t\t\t\t     unsigned int *decryptSession,\n\t\t\t\t\t     TPMI_SH_AUTH_SESSION sessionHandle[],\n\t\t\t\t\t     unsigned int sessionAttributes[]);\nstatic TPM_RC TSS_Sessions_GetEncryptSession(unsigned int *isEncrypt,\n\t\t\t\t\t     unsigned int *encryptSession,\n\t\t\t\t\t     TPMI_SH_AUTH_SESSION sessionHandle[],\n\t\t\t\t\t     unsigned int sessionAttributes[]);\n\n#ifndef TPM_TSS_NOFILE\nstatic TPM_RC TSS_HashToString(char *str, uint8_t *digest);\n#endif\n#ifndef TPM_TSS_NOCRYPTO\n#ifndef TPM_TSS_NORSA\nstatic TPM_RC TSS_RSA_Salt(TPM2B_DIGEST \t\t*salt,\n\t\t\t   TPM2B_ENCRYPTED_SECRET\t*encryptedSalt,\n\t\t\t   TPMT_PUBLIC\t\t\t*publicArea);\n#endif /* TPM_TSS_NORSA */\n#endif /* TPM_TSS_NOCRYPTO */\nextern int tssVerbose;\nextern int tssVverbose;\nextern int tssFirstCall;\n\n\nTPM_RC TSS_Execute20(TSS_CONTEXT *tssContext,\n\t\t     RESPONSE_PARAMETERS *out,\n\t\t     COMMAND_PARAMETERS *in,\n\t\t     EXTRA_PARAMETERS *extra,\n\t\t     TPM_CC commandCode,\n\t\t     va_list ap)\n{\n    TPM_RC\t\trc = 0;\n\t\n#ifdef TPM_TSS_NODEPRECATEDALGS\n    if (rc == 0) {\n\trc = TSS_Command_CheckParameters(commandCode, in);\n    }\n#endif\n\n    /* create a TSS authorization context */\n    if (rc == 0) {\n\tTSS_InitAuthContext(tssContext->tssAuthContext);\n    }\n    /* handle any command specific command pre-processing */\n    if (rc == 0) {\n\trc = TSS_Command_PreProcessor(tssContext,\n\t\t\t\t      commandCode,\n\t\t\t\t      in,\n\t\t\t\t      extra);\n    }\n    /* marshal input parameters */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute20: Command %08x marshal\\n\", commandCode);\n\trc = TSS_Marshal(tssContext->tssAuthContext,\n\t\t\t in,\n\t\t\t commandCode);\n    }\n    /* execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute_valist(tssContext, in, ap);\n    }\n    /* unmarshal the response parameters */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute20: Command %08x unmarshal\\n\", commandCode);\n\trc = TSS_Unmarshal(tssContext->tssAuthContext, out);\n    }\n    /* handle any command specific response post-processing */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute20: Command %08x post processor\\n\", commandCode);\n\trc = TSS_Response_PostProcessor(tssContext,\n\t\t\t\t\tin,\n\t\t\t\t\tout,\n\t\t\t\t\textra);\n    }\n    return rc;\n}\n\n/* TSS_Execute_valist() transmits the marshaled command and receives the marshaled response.\n\n   varargs are TPMI_SH_AUTH_SESSION sessionHandle, const char *password, unsigned int\n   sessionAttributes\n\n   Terminates with sessionHandle TPM_RH_NULL\n\n   Processes up to MAX_SESSION_NUM sessions.  It handles HMAC generation and command and response\n   parameter encryption.  It loads each session context, rolls nonces, and saves or deletes the\n   session context.\n*/\n\nstatic TPM_RC TSS_Execute_valist(TSS_CONTEXT *tssContext,\n\t\t\t\t COMMAND_PARAMETERS *in,\n\t\t\t\t va_list ap)\n{\n    TPM_RC\t\trc = 0;\n    int \t\tdone;\n    int \t\thaveNames = FALSE;\t/* names are common to all HMAC sessions */\n    size_t\t\ti = 0;\n\n    /* the vararg parameters */\n    TPMI_SH_AUTH_SESSION sessionHandle[MAX_SESSION_NUM];\n    const char \t\t*password[MAX_SESSION_NUM];\n    unsigned int\tsessionAttributes[MAX_SESSION_NUM]; \n\n    /* structures filled in */\n    TPMS_AUTH_COMMAND \t*authCommand[MAX_SESSION_NUM];\n    TPMS_AUTH_RESPONSE \t*authResponse[MAX_SESSION_NUM];\n    \n    /* pointer to the above structures as used */\n    TPMS_AUTH_COMMAND \t*authC[MAX_SESSION_NUM];\n    TPMS_AUTH_RESPONSE \t*authR[MAX_SESSION_NUM];\n\n    /* TSS sessions */\n    struct TSS_HMAC_CONTEXT *session[MAX_SESSION_NUM];\n    TPM2B_NAME *names[MAX_SESSION_NUM];\n\t\n    \n    for (i = 0 ; i < MAX_SESSION_NUM ; i++) {\n\tauthCommand[i] = NULL;\t\t/* for safe free */\n\tauthResponse[i] = NULL;\t\t/* for safe free */\n \tnames[i] = NULL;\t\t/* for safe free */\n\tauthC[i] = NULL;\t\t/* array of TPMS_AUTH_COMMAND structures, NULL for\n\t\t\t\t\t   TSS_SetCmdAuths */\n\tauthR[i] = NULL;\t\t/* array of TPMS_AUTH_RESPONSE structures, NULL for\n\t\t\t\t\t   TSS_GetRspAuths */\n\tsession[i] = NULL;\t\t/* for free, used for HMAC and encrypt/decrypt sessions */\n\t/* the varargs list inputs */\n\tsessionHandle[i] = TPM_RH_NULL;\n\tpassword[i] = NULL;\n\tsessionAttributes[i] = 0;\n    }\n    /* Step 1: initialization */\n    if (tssVverbose) printf(\"TSS_Execute_valist: Step 1: initialization\\n\");\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_Malloc((unsigned char **)&authCommand[i],\t/* freed @1 */\n\t\t\t    sizeof(TPMS_AUTH_COMMAND));\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Malloc((unsigned char **)&authResponse[i],\t/* freed @2 */\n\t\t\t    sizeof(TPMS_AUTH_RESPONSE));\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Malloc((unsigned char **)&names[i],\t/* freed @3 */\n\t\t\t    sizeof(TPM2B_NAME));\n\t}\n\tif (rc == 0) {\n\t    names[i]->b.size = 0;\t/* to ignore unused names in cpHash calculation */\n\t}\n    }\n    /* Step 2: gather the command authorizations\n\n       Process PWAP immediately\n       For HMAC, get the session context\n    */\n    done = FALSE;\n    for (i = 0 ; (rc == 0) && !done && (i < MAX_SESSION_NUM) ; i++) {\n \tsessionHandle[i] = va_arg(ap, TPMI_SH_AUTH_SESSION);\t/* first vararg is the session\n\t\t\t\t\t\t\t\t   handle */\n\tpassword[i]= va_arg(ap, const char *);\t\t\t/* second vararg is the password */\n\tsessionAttributes[i] = va_arg(ap, unsigned int);\t/* third argument is\n\t\t\t\t\t\t\t\t   sessionAttributes */\n\tsessionAttributes[i] &= 0xff;\t\t\t\t/* is uint8_t */\n\n\tif (sessionHandle[i] != TPM_RH_NULL) {\t\t\t/* varargs termination value */ \n\n\t    if (tssVverbose) printf(\"TSS_Execute_valist: Step 2: authorization %u\\n\",\n\t\t\t\t    (unsigned int)i);\n\t    if (tssVverbose) printf(\"TSS_Execute_valist: session %u handle %08x\\n\",\n\t\t\t\t    (unsigned int)i, sessionHandle[i]);\n\t    /* make used, non-NULL for command and response varargs */\n\t    authC[i] = authCommand[i];\n\t    authR[i] = authResponse[i];\n\n\t    /* if password session, populate authC with password, etc. immediately */\n\t    if (sessionHandle[i] == TPM_RS_PW) {\n\t\trc = TSS_PwapSession_Set(authC[i], password[i]);\n\t    }\n\t    /* if HMAC or encrypt/decrypt session  */\n\t    else {\n\t\t/* initialize a TSS HMAC session */\n\t\tif (rc == 0) {\n\t\t    rc = TSS_HmacSession_GetContext(&session[i]);\n\t\t}\n\t\t/* load the session created by startauthsession */\n\t\tif (rc == 0) {\n\t\t    rc = TSS_HmacSession_LoadSession(tssContext, session[i], sessionHandle[i]);\n\t\t}\n\t\t/* if there is at least one HMAC session, get the names corresponding to the\n\t\t   handles */\n\t\tif ((session[i]->sessionType == TPM_SE_HMAC) ||\t\t/* HMAC session. OR */\n\t\t    ((session[i]->sessionType == TPM_SE_POLICY) &&\t/* Policy session AND */\n\n#ifndef TPM_TSS_NOCRYPTO\n\t\t     ((session[i]->isAuthValueNeeded) || \t\t/* PolicyAuthValue ran, OR */\n\t\t      (session[i]->sessionKey.b.size != 0)))\t\t/* Already session key (bind or salt) */\n#else\n\t\t    (session[i]->isAuthValueNeeded))\t\t/* PolicyAuthValue ran, OR */\n#endif\t/* TPM_TSS_NOCRYPTO */\n\t\t    ) {\t\n\t\t    if ((rc == 0) && !haveNames) {\n\t\t\trc = TSS_Name_GetAllNames(tssContext, names);\n\t\t\thaveNames = TRUE;\t/* get only once, minor optimization */\n\t\t    }\n\t\t}\n\t    }\n\t}\n\telse {\n\t    done = TRUE;\n\t}\n    }\n    /* Step 3: Roll nonceCaller, save in the session context for the response */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tif (sessionHandle[i] != TPM_RS_PW) {\t\t/* no nonce for password sessions */\n\t    if (tssVverbose)\n\t\tprintf(\"TSS_Execute_valist: Step 3: nonceCaller %08x\\n\", sessionHandle[i]);\n#ifndef TPM_TSS_NOCRYPTO\n\t    rc = TSS_HmacSession_SetNonceCaller(session[i], authC[i]);\n#else\n\t    authC[i]->nonce.b.size = 16;\n\t    memset(&authC[i]->nonce.b.buffer, 0, 16);\n#endif\t/* TPM_TSS_NOCRYPTO */\n\t}\n\tif (tssVverbose) {\n\t    TPMA_SESSION attributes;\n\t    attributes.val = (uint8_t)sessionAttributes[i];\t/* upper bytes already masked */\n\t    TSS_TPM_HANDLE_Print(\"sessionHandle\", sessionHandle[i], 8);\t\n\t    TSS_TPMA_SESSION_Print(attributes, 8);\n\t}\n    }\n\n#ifndef TPM_TSS_NOCRYPTO\n    /* Step 4: Calculate the HMAC key */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tif (sessionHandle[i] != TPM_RS_PW) {\t\t/* no HMAC key for password sessions */\n\t    if (tssVverbose) printf(\"TSS_Execute_valist: Step 4: Session %u HMAC key for %08x\\n\",\n\t\t\t\t    (unsigned int)i, sessionHandle[i]);\n\t    rc = TSS_HmacSession_SetHmacKey(tssContext, session[i], i, password[i]);\n\t}\n    }\n#endif\t/* TPM_TSS_NOCRYPTO */\n    /* Step 5: command parameter encryption */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute_valist: Step 5: command encrypt\\n\");\n\trc = TSS_Command_Decrypt(tssContext->tssAuthContext,\n\t\t\t\t session,\n\t\t\t\t sessionHandle,\n\t\t\t\t sessionAttributes);\n    }\n    /* Step 6: for each HMAC session, calculate cpHash, calculate the HMAC, and set it in\n       TPMS_AUTH_COMMAND */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute_valist: Step 6 calculate HMACs\\n\");\n\trc = TSS_HmacSession_SetHMAC(tssContext->tssAuthContext,\t/* TSS auth context */\n\t\t\t\t     session,\t\t/* TSS session contexts */\n\t\t\t\t     authC,\t\t/* output: command authorizations */\n\t\t\t\t     sessionHandle,\t/* list of session handles for the command */\n\t\t\t\t     sessionAttributes, /* attributes for this command */\n\t\t\t\t     password,\t\t/* for plaintext password sessions */\n\t\t\t\t     names[0],\t\t/* Name */\n\t\t\t\t     names[1],\t\t/* Name */\n\t\t\t\t     names[2]);\t\t/* Name */\n    }\n    /* Step 7: set the command authorizations in the TSS command stream */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute_valist: Step 7 set command authorizations\\n\");\n\trc = TSS_SetCmdAuths(tssContext->tssAuthContext,\n\t\t\t     authC[0],\n\t\t\t     authC[1],\n\t\t\t     authC[2],\n\t\t\t     NULL);\n    }\n    /* Step 8: process the command.  Normally returns the TPM response code. */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute_valist: Step 8: process the command\\n\");\n\trc = TSS_AuthExecute(tssContext);\n    }\n    /* Step 9: get the response authorizations from the TSS response stream */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute_valist: Step 9 get response authorizations\\n\");\n\trc = TSS_GetRspAuths(tssContext->tssAuthContext,\n\t\t\t     authR[0],\n\t\t\t     authR[1],\n\t\t\t     authR[2],\n\t\t\t     NULL);\n    }\n    /* Step 10: process the response authorizations, validate the HMAC */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tif (tssVverbose)\n\t    printf(\"TSS_Execute_valist: Step 10: process response authorization %08x\\n\",\n\t\t   sessionHandle[i]);\n\tif (sessionHandle[i] == TPM_RS_PW) {\n\t    rc = TSS_PwapSession_Verify(authR[i]);\n\t}\n\t/* HMAC session */\n\telse {\n#ifndef TPM_TSS_NOCRYPTO\n\t    /* save nonceTPM in the session context */\n\t    if (rc == 0) {\n\t\trc = TSS_TPM2B_Copy(&session[i]->nonceTPM.b, &authR[i]->nonce.b, sizeof(TPMU_HA));\n\t    }\n#endif\t/* TPM_TSS_NOCRYPTO */\n\t    /* the HMAC key is already part of the TSS session context.  For policy sessions with\n\t       policy password, the response hmac is empty. */\n\t    if ((session[i]->sessionType == TPM_SE_HMAC) ||\n\t\t((session[i]->sessionType == TPM_SE_POLICY) && (session[i]->isAuthValueNeeded))) {\n#ifndef TPM_TSS_NOCRYPTO\n\t\tif (rc == 0) {\n\t\t    rc = TSS_Command_ChangeAuthProcessor(tssContext, session[i], i, in);\n\t\t}\n\t\tif (rc == 0) {\n\t\t    rc = TSS_HmacSession_Verify(tssContext->tssAuthContext, /* authorization\n\t\t\t\t\t\t\t\t\t       context */\n\t\t\t\t\t\tsession[i],\t/* TSS session context */\n\t\t\t\t\t\tauthR[i]);\t/* input: response authorization */\n\t\t}\n#else\n\t\tin = in;\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_Execute_valist: \"\n\t\t\t   \"Error, HMAC verify with no crypto not implemented\\n\");\n\t\trc = TSS_RC_NOT_IMPLEMENTED;\n#endif\t/* TPM_TSS_NOCRYPTO */\n\t    }\n\t}\n    }\n    /* Step 11: process the audit flag */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tif ((sessionHandle[i] != TPM_RS_PW) &&\n\t    (session[i]->bind != TPM_RH_NULL) &&\n\t    (authR[i]->sessionAttributes.val & TPMA_SESSION_AUDIT)) {\n\t    if (tssVverbose) printf(\"TSS_Execute_valist: Step 11: process bind audit flag %08x\\n\",\n\t\t\t\t    sessionHandle[i]);\n\t    /* if bind audit session, bind value is lost and further use requires authValue */\n\t    session[i]->bind = TPM_RH_NULL;\n\t}\n    }\n    /* Step 12: process the response continue flag */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tif (sessionHandle[i] != TPM_RS_PW) {\n\t    if (tssVverbose) {\n\t\tTSS_TPMS_AUTH_RESPONSE_Print(authR[i], 8);\n\n\t    }\n\t    if (tssVverbose) printf(\"TSS_Execute_valist: Step 12: process continue flag %08x\\n\",\n\t\t\t\t    sessionHandle[i]);\n\t    rc = TSS_HmacSession_Continue(tssContext, session[i], authR[i]);\n\t}\n    }\n    /* Step 13: response parameter decryption */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Execute_valist: Step 13: response decryption\\n\");\n\trc = TSS_Response_Encrypt(tssContext->tssAuthContext,\n\t\t\t\t  session,\n\t\t\t\t  sessionHandle,\n\t\t\t\t  sessionAttributes);\n    }\n    /* cleanup */\n    for (i = 0 ; i < MAX_SESSION_NUM ; i++) {\n\tTSS_HmacSession_FreeContext(session[i]);\n\tfree(authCommand[i]);\t\t/* @1 */\n \tfree(authResponse[i]);\t\t/* @2 */\n\tfree(names[i]);\t\t\t/* @3 */\n    }\n    return rc;\n}\n\n/*\n  PWAP - Password Session\n*/\n\n/* TSS_PwapSession_Set() sets all members of the TPMS_AUTH_COMMAND structure for a PWAP session.\n */\n\nstatic TPM_RC TSS_PwapSession_Set(TPMS_AUTH_COMMAND *authCommand,\n\t\t\t\t  const char *password)\n{\n    TPM_RC\t\trc = 0;\n    \n    if (rc == 0) {\n\tauthCommand->sessionHandle = TPM_RS_PW;\n\tauthCommand->nonce.t.size = 0;\n\tauthCommand->sessionAttributes.val = 0;\n    }\n    if (password != NULL) {\n\trc = TSS_TPM2B_StringCopy(&authCommand->hmac.b,\n\t\t\t\t  password, sizeof(authCommand->hmac.t.buffer));\n    }\n    else {\n\tauthCommand->hmac.t.size = 0;\n    }\n    return rc;\n}\n\n/* TSS_PwapSession_Verify() verifies the PWAP session response. */\n\nstatic TPM_RC TSS_PwapSession_Verify(TPMS_AUTH_RESPONSE *authResponse)\n{\n    TPM_RC\t\trc = 0;\n\n    if (rc == 0) {\n\tif (authResponse->nonce.t.size != 0) {\n\t    if (tssVerbose) printf(\"TSS_PwapSession_Verify: nonce size %u not zero\\n\",\n\t\t\t\t   authResponse->nonce.t.size);\n\t    rc = TSS_RC_BAD_PWAP_NONCE;\n\t}\n    }\n    if (rc == 0) {\n\tif (authResponse->sessionAttributes.val != TPMA_SESSION_CONTINUESESSION) {\n\t    if (tssVerbose) printf(\"TSS_PwapSession_Verify: continue %02x not set\\n\",\n\t\t\t\t   authResponse->sessionAttributes.val);\n\t    rc = TSS_RC_BAD_PWAP_ATTRIBUTES;\n\t}\n    }\n    if (rc == 0) {\n\tif (authResponse->hmac.t.size != 0) {\n\t    if (tssVerbose) printf(\"TSS_PwapSession_Verify: HMAC size %u not zero\\n\",\n\t\t\t\t   authResponse->hmac.t.size);\n\t    rc = TSS_RC_BAD_PWAP_HMAC;\n\t}\n    }\n    return rc;\n}\n\n/*\n  HMAC Session\n*/\n\nstatic TPM_RC TSS_HmacSession_GetContext(struct TSS_HMAC_CONTEXT **session)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n        rc = TSS_Malloc((uint8_t **)session, sizeof(TSS_HMAC_CONTEXT));\n    }\n    if (rc == 0) {\n\tTSS_HmacSession_InitContext(*session);\n    }\n    return rc;\n}\n\nstatic void TSS_HmacSession_InitContext(struct TSS_HMAC_CONTEXT *session)\n{\n    session->sessionHandle = TPM_RH_NULL;\n    session->authHashAlg = TPM_ALG_NULL;\n#ifndef TPM_TSS_NOCRYPTO\n    session->sizeInBytes = 0;\n#endif\n    session->symmetric.algorithm = TPM_ALG_NULL;\n    session->bind = TPM_RH_NULL;\n    session->bindName.b.size = 0;\n    session->bindAuthValue.t.size = 0;\n#ifndef TPM_TSS_NOCRYPTO\n    memset(session->nonceTPM.t.buffer, 0, sizeof(TPMU_HA));\n    session->nonceTPM.b.size = 0;\n    memset(session->nonceCaller.t.buffer, 0, sizeof(TPMU_HA));\n    session->nonceCaller.b.size = 0;\n    memset(session->sessionKey.t.buffer, 0, sizeof(TPMU_HA));\n    session->sessionKey.b.size = 0;\n#endif\n    session->sessionType = 0;\n    session->isPasswordNeeded = FALSE;\n    session->isAuthValueNeeded = FALSE;\n    memset(session->hmacKey.t.buffer, 0, sizeof(TPMU_HA) + sizeof(TPMU_HA));\n    session->hmacKey.b.size = 0;\n#ifndef TPM_TSS_NOCRYPTO\n    memset(session->sessionValue.t.buffer, 0, sizeof(TPMU_HA) + sizeof(TPMU_HA));\n    session->sessionValue.b.size = 0;\n#endif\n}\n\nvoid TSS_HmacSession_FreeContext(struct TSS_HMAC_CONTEXT *session)\n{\n    if (session != NULL) {\n\tTSS_HmacSession_InitContext(session);\n\tfree(session);\n    }\n    return;\n}\n\n/* TSS_HmacSession_SetSessionKey() is called by the StartAuthSession post processor to calculate and\n   store the session key\n\n   19.6.8\tsessionKey Creation\n*/\n\n#ifndef TPM_TSS_NOCRYPTO\n\nstatic TPM_RC TSS_HmacSession_SetSessionKey(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t    TPM2B_DIGEST *salt,\n\t\t\t\t\t    TPMI_DH_ENTITY bind,\n\t\t\t\t\t    TPM2B_AUTH *bindAuthValue)\n{\n    TPM_RC\t\trc = 0;\n    TPM2B_KEY \t\tkey;\t\t/* HMAC key for the KDFa */\n\n    if (rc == 0) {\n\t/* save the bind handle, non-null indicates a bound session */\n\tsession->bind = bind;\n\t/* if bind, save the bind Name in the session context.  The handle might change, but the\n\t   name will not */\n\tif ((rc == 0) && (bind != TPM_RH_NULL)) {\n\t    rc = TSS_Name_GetName(tssContext, &session->bindName, bind);\n\t}\n    }\n    if (rc == 0) {\n        if ((bind != TPM_RH_NULL) ||\n\t    (salt->b.size != 0)) {\n\n\t    /* session key is bindAuthValue || salt */\n\t    /* copy bindAuthValue.  This is set during the post processor to either the supplied\n\t       bind password or Empty */\n\t    if (rc == 0) {\n\t\trc = TSS_TPM2B_Copy(&key.b, &bindAuthValue->b, sizeof(TPMU_HA) + sizeof(TPMT_HA));\n\t    }\n\t    /* copy salt.  This is set during the postprocessor to either the salt from the\n\t       preprocessor or empty. */\n\t    if (rc == 0) {\n\t\trc = TSS_TPM2B_Append(&key.b, &salt->b, sizeof(TPMU_HA) + sizeof(TPMT_HA));\n\t    }\n\t    if (rc == 0) {\n\t\tif (tssVverbose) TSS_PrintAll(\"TSS_HmacSession_SetSessionKey: KDFa HMAC key\",\n\t\t\t\t\t      key.b.buffer, key.b.size);\n\t    }\n\t    /* KDFa for the session key */\n\t    if (rc == 0) {\n\t\trc = TSS_KDFA(session->sessionKey.b.buffer,\n\t\t\t      session->authHashAlg,\n\t\t\t      &key.b,\n\t\t\t      \"ATH\",\n\t\t\t      &session->nonceTPM.b,\n\t\t\t      &session->nonceCaller.b,\n\t\t\t      session->sizeInBytes * 8);\n\t    }\n\t    if (rc == 0) {\n\t\tsession->sessionKey.b.size = session->sizeInBytes;\n\t\tif (tssVverbose)\n\t\t    TSS_PrintAll(\"TSS_HmacSession_SetSessionKey: Session key\",\n\t\t\t\t session->sessionKey.b.buffer, session->sessionKey.b.size);\n\t    }\n\t}\n\telse {\n\t    session->sessionKey.b.size = 0;\n\t}\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOCRYPTO */\n\n/* TSS_HmacSession_SaveSession() saves a session in two cases:\n\n   The initial session from startauthsession\n   The updated session a TPM response\n*/\n\n\nstatic TPM_RC TSS_HmacSession_SaveSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t  struct TSS_HMAC_CONTEXT *session)\n{\n    TPM_RC\trc = 0;\n    uint8_t \t*buffer = NULL;\t\t/* marshaled TSS_HMAC_CONTEXT */\n    uint16_t\twritten = 0;\n#ifndef TPM_TSS_NOFILE\n    char\tsessionFilename[TPM_DATA_DIR_PATH_LENGTH];\n    uint8_t *outBuffer = NULL;\n    uint32_t outLength;\n#endif\n    \n    if (tssVverbose) printf(\"TSS_HmacSession_SaveSession: handle %08x\\n\", session->sessionHandle);\n    if (rc == 0) {\n\trc = TSS_Structure_Marshal(&buffer,\t/* freed @1 */\n\t\t\t\t   &written,\n\t\t\t\t   session,\n\t\t\t\t   (MarshalFunction_t)TSS_HmacSession_Marshal);\n    }\n#ifndef TPM_TSS_NOFILE\n    if (rc == 0) {\n#ifndef TPM_TSS_NOCRYPTO\n\t/* if the flag is set, encrypt the session state before store */\n\tif (tssContext->tssEncryptSessions) {\n\t    rc = TSS_AES_Encrypt(tssContext->tssSessionEncKey,\n\t\t\t\t &outBuffer,   \t/* output, freed @2 */\n\t\t\t\t &outLength,\t/* output */\n\t\t\t\t buffer,\t/* input */\n\t\t\t\t written);\t/* input */\n\t}\n\t/* else store the session state in plaintext */\n\telse {\n#endif\t/* TPM_TSS_NOCRYPTO */\n\t    outBuffer = buffer;\n\t    outLength = written;\n#ifndef TPM_TSS_NOCRYPTO\n\t}\n#endif\t/* TPM_TSS_NOCRYPTO */\n    }\n    /* save the session in a hard coded file name hxxxxxxxx.bin where xxxxxxxx is the session\n       handle */\n    if (rc == 0) {\n\tsprintf(sessionFilename, \"%s/h%08x.bin\",\n\t\ttssContext->tssDataDirectory, session->sessionHandle);\n    }\n    if (rc == 0) {\n\trc = TSS_File_WriteBinaryFile(outBuffer,\n\t\t\t\t      outLength,\n\t\t\t\t      sessionFilename);\n    }\n    if (tssContext->tssEncryptSessions) {\n\tfree(outBuffer);\t/* @2 */\n    }\n#else\t\t/* no file support, save to context */\n    if (rc == 0) {\n\trc = TSS_HmacSession_SaveData(tssContext,\n\t\t\t\t      session->sessionHandle,\n\t\t\t\t      written, buffer);\n    }\n#endif\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n/* TSS_HmacSession_LoadSession() loads an existing HMAC session context saved by:\n\n   startauthsession\n   an update after a TPM response\n*/\n\nstatic TPM_RC TSS_HmacSession_LoadSession(TSS_CONTEXT *tssContext,\n\t\t\t\t\t  struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t  TPMI_SH_AUTH_SESSION\tsessionHandle)\n{\n    TPM_RC\t\trc = 0;\n    uint8_t \t\t*buffer = NULL;\n    uint8_t \t\t*buffer1 = NULL;\n#ifndef TPM_TSS_NOFILE\n    size_t \t\tlength = 0;\n    char\t\tsessionFilename[TPM_DATA_DIR_PATH_LENGTH];\n#endif    \n    unsigned char \t*inData = NULL;\t\t/* output */\n    uint32_t \t\tinLength;\t\t/* output */\n\n    if (tssVverbose) printf(\"TSS_HmacSession_LoadSession: handle %08x\\n\", sessionHandle);\n#ifndef TPM_TSS_NOFILE\n    /* load the session from a hard coded file name hxxxxxxxx.bin where xxxxxxxx is the session\n       handle */\n    if (rc == 0) {\n\tsprintf(sessionFilename, \"%s/h%08x.bin\", tssContext->tssDataDirectory, sessionHandle);\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     sessionFilename);\n    }\n    if (rc == 0) {\n#ifndef TPM_TSS_NOCRYPTO\n\t/* if the flag is set, decrypt the session state before unmarshal */\n\tif (tssContext->tssEncryptSessions) {\n\t    rc = TSS_AES_Decrypt(tssContext->tssSessionDecKey,\n\t\t\t\t &inData,   \t\t/* output, freed @2 */\n\t\t\t\t &inLength,\t\t/* output */\n\t\t\t\t buffer,\t\t/* input */\n\t\t\t\t (uint32_t)length);\t/* input */\n\t}\n\t/* else the session was loaded in plaintext */\n\telse {\n#endif\t/* TPM_TSS_NOCRYPTO */\n\t    inData = buffer;\n\t    inLength = (uint32_t)length;\n#ifndef TPM_TSS_NOCRYPTO\n\t}\n#endif\t/* TPM_TSS_NOCRYPTO */\n    }\n#else\t\t/* no file support, load from context */\n    if (rc == 0) {\n\trc = TSS_HmacSession_LoadData(tssContext,\n\t\t\t\t      &inLength, &inData,\n\t\t\t\t      sessionHandle);\n    }\n#endif\n    if (rc == 0) {\n\tuint32_t ilength = inLength;\n\tbuffer1 = inData;\n\trc = TSS_HmacSession_Unmarshal(session, &buffer1, &ilength);\n    }\n#ifndef TPM_TSS_NOFILE\n    if (tssContext->tssEncryptSessions) {\n\tfree(inData);\t/* @2 */\n    }\n#endif\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n#ifdef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_HmacSession_SaveData(TSS_CONTEXT *tssContext,\n\t\t\t\t       TPMI_SH_AUTH_SESSION sessionHandle,\n\t\t\t\t       uint32_t outLength,\n\t\t\t\t       uint8_t *outBuffer)\n{\n    TPM_RC\trc = 0;\n    size_t\tslotIndex;\n\n    /* if this handle is already used, overwrite the slot */\n    if (rc == 0) {\n\trc = TSS_HmacSession_GetSlotForHandle(tssContext, &slotIndex, sessionHandle);\n\tif (rc != 0) {\n\t    rc = TSS_HmacSession_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL);\n\t    if (rc == 0) {\n\t\ttssContext->sessions[slotIndex].sessionHandle = sessionHandle;\n\t    }\n\t    else {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_HmacSession_SaveData: Error, no slot available for handle %08x\\n\",\n\t\t\t   sessionHandle);\n\t    }\n\t}\n    }\n    /* reallocate memory and adjust the size */\n    if (rc == 0) {\n\trc = TSS_Realloc(&tssContext->sessions[slotIndex].sessionData, outLength);\n    }\n    if (rc == 0) {\n\ttssContext->sessions[slotIndex].sessionDataLength = outLength;\n\tmemcpy(tssContext->sessions[slotIndex].sessionData, outBuffer, outLength);\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_HmacSession_LoadData(TSS_CONTEXT *tssContext,\n\t\t\t\t       uint32_t *inLength, uint8_t **inData,\n\t\t\t\t       TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\trc = 0;\n    size_t\tslotIndex;\n\n    if (rc == 0) {\n\trc = TSS_HmacSession_GetSlotForHandle(tssContext, &slotIndex, sessionHandle);\n\tif (rc != 0) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_HmacSession_LoadData: Error, no slot found for handle %08x\\n\",\n\t\t       sessionHandle);\n\t}\n    }\n    if (rc == 0) {\n\t*inLength = tssContext->sessions[slotIndex].sessionDataLength;\n\t*inData = tssContext->sessions[slotIndex].sessionData;\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_HmacSession_DeleteData(TSS_CONTEXT *tssContext,\n\t\t\t\t\t TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\trc = 0;\n    size_t\tslotIndex;\n\n    if (rc == 0) {\n\trc = TSS_HmacSession_GetSlotForHandle(tssContext, &slotIndex, sessionHandle);\n\tif (rc != 0) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_HmacSession_DeleteData: Error, no slot found for handle %08x\\n\",\n\t\t       sessionHandle);\n\t}\n    }    \n    if (rc == 0) {\n\ttssContext->sessions[slotIndex].sessionHandle = TPM_RH_NULL;\n\t/* erase any secrets */\n\tmemset(tssContext->sessions[slotIndex].sessionData, 0,\n\t       tssContext->sessions[slotIndex].sessionDataLength);\n\tfree(tssContext->sessions[slotIndex].sessionData);\n\ttssContext->sessions[slotIndex].sessionData = NULL;\n\ttssContext->sessions[slotIndex].sessionDataLength = 0;\n    }\n    return rc;\n}\n\n/* TSS_HmacSession_GetSlotForHandle() finds the session slot corresponding to the session handle.\n\n   Returns non-zero if no slot is found.\n*/\n\nstatic TPM_RC TSS_HmacSession_GetSlotForHandle(TSS_CONTEXT *tssContext,\n\t\t\t\t\t       size_t *slotIndex,\n\t\t\t\t\t       TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    size_t \ti;\n\n    /* search all slots for handle */\n    for (i = 0 ; i < (sizeof(tssContext->sessions) / sizeof(TSS_SESSIONS)) ; i++) {\n\tif (tssContext->sessions[i].sessionHandle == sessionHandle) {\n\t    *slotIndex = i;\n\t    return 0;\n\t}\n    }\n    return TSS_RC_NO_SESSION_SLOT;\n}\n\n#endif\n\nstatic TPM_RC TSS_HmacSession_Marshal(struct TSS_HMAC_CONTEXT *source,\n\t\t\t\t\tuint16_t *written,\n\t\t\t\t\tuint8_t **buffer,\n\t\t\t\t\tuint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_AUTH_SESSION_Marshalu(&source->sessionHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->authHashAlg, written, buffer, size);\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->sizeInBytes, written, buffer, size);\n    }\n#endif\n    if (rc == 0) {\n\trc = TSS_TPMT_SYM_DEF_Marshalu(&source->symmetric, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_ENTITY_Marshalu(&source->bind, written, buffer, size);\n    }   \n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->bindName, written, buffer, size);\n    }\n#ifdef TPM_WINDOWS\n    /* FIXME Why does a VS release build need a printf here? */\n    if (tssVverbose) printf(\"\");\n#endif\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->bindAuthValue, written, buffer, size);\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->nonceTPM, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->nonceCaller, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->sessionKey, written, buffer, size);\n    }\n#endif\n    if (rc == 0) {\n\trc = TSS_TPM_SE_Marshalu(&source->sessionType, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->isPasswordNeeded, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->isAuthValueNeeded, written, buffer, size);\n    }  \n    return rc;\n}\n\nstatic TPM_RC TSS_HmacSession_Unmarshal(struct TSS_HMAC_CONTEXT *target,\n\t\t\t\t\tuint8_t **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_AUTH_SESSION_Unmarshalu(&target->sessionHandle, buffer, size, NO);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Unmarshalu(&target->authHashAlg, buffer, size, NO);\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->sizeInBytes, buffer, size);\n    }\n#endif\n    if (rc == 0) {\n\trc = TSS_TPMT_SYM_DEF_Unmarshalu(&target->symmetric, buffer, size, YES);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_ENTITY_Unmarshalu(&target->bind, buffer, size, YES);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->bindName, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Unmarshalu(&target->bindAuthValue, buffer, size);\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceTPM, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceCaller, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->sessionKey, buffer, size);\n    }\n#endif\n    if (rc == 0) {\n\trc = TSS_TPM_SE_Unmarshalu(&target->sessionType, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->isPasswordNeeded, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Unmarshalu(&target->isAuthValueNeeded, buffer, size);\n    }\n    return rc;\n}\n\n/*\n  Name handling\n*/\n\n/* TSS_Name_GetAllNames() files in the names array based on the handles marshaled into the TSS\n   context command stream. */\n\nstatic TPM_RC TSS_Name_GetAllNames(TSS_CONTEXT *tssContext,\n\t\t\t\t   TPM2B_NAME **names)\n{\n    TPM_RC\trc = 0;\n    size_t\ti;\n    size_t\tcommandHandleCount;\t/* number of handles in the command stream */\n    TPM_HANDLE  commandHandle;\n\n    /* get the number of handles in the command stream */\n    if (rc == 0) {\n\trc = TSS_GetCommandHandleCount(tssContext->tssAuthContext, &commandHandleCount);\n\tif (tssVverbose) printf(\"TSS_Name_GetAllNames: commandHandleCount %u\\n\",\n\t\t\t\t(unsigned int)commandHandleCount);\n    }\n    for (i = 0 ; (rc == 0) && (i < commandHandleCount) ; i++) {\n\t/* get a handle from the command stream */\n\tif (rc == 0) {\n\t    rc = TSS_GetCommandHandle(tssContext->tssAuthContext,\n\t\t\t\t      &commandHandle,\n\t\t\t\t      i);\n\t}\n\t/* get the Name corresponding to the handle */\n\tif (rc == 0) {\n\t    if (tssVverbose) printf(\"TSS_Name_GetAllNames: commandHandle %u %08x\\n\",\n\t\t\t\t    (unsigned int)i, commandHandle);\n\t    rc = TSS_Name_GetName(tssContext, names[i], commandHandle);\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Name_GetName() gets the Name associated with the handle */\n\nstatic TPM_RC TSS_Name_GetName(TSS_CONTEXT *tssContext,\n\t\t\t       TPM2B_NAME *name,\n\t\t\t       TPM_HANDLE  handle)\n{\n    TPM_RC\trc = 0;\n    TPM_HT \thandleType;\n\n    if (tssVverbose) printf(\"TSS_Name_GetName: Handle %08x\\n\", handle);\n    handleType = (TPM_HT) ((handle & HR_RANGE_MASK) >> HR_SHIFT);\n\n    /* Table 3 - Equations for Computing Entity Names */\n    switch (handleType) {\n\t/* for these, the Name is simply the handle value */\n      case TPM_HT_PCR:\n      case TPM_HT_HMAC_SESSION:\n      case TPM_HT_POLICY_SESSION:\n      case TPM_HT_PERMANENT:\n\trc = TSS_TPM2B_CreateUint32(&name->b, handle, sizeof(name->t.name));\n\tbreak;\n\t/* for NV, the Names was calculated at NV read public */\n      case TPM_HT_NV_INDEX:\n\t/* for objects, the Name was returned at creation or load */\n      case TPM_HT_TRANSIENT:\n      case TPM_HT_PERSISTENT:\n\trc = TSS_Name_Load(tssContext, name, handle, NULL);\n\tbreak;\n      default:\n\tif (tssVerbose) printf(\"TSS_Name_GetName: not implemented for handle %08x\\n\", handle);\n\trc = TSS_RC_NAME_NOT_IMPLEMENTED;\n\tbreak;\n    }\n    if (rc == 0) {\n\tif (tssVverbose)\n\t    TSS_PrintAll(\"TSS_Name_GetName: \",\n\t\t\t name->t.name, name->t.size);\n    }\n    \n    return rc;\n}\n\n/* TSS_Name_Store() stores the 'name' parameter in a file.\n\n   If handle is not 0, the handle is used as the file name.\n\n   If 'string' is not NULL, the string is used as the file name.\n*/\n\n#ifndef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_Name_Store(TSS_CONTEXT *tssContext,\n\t\t\t     TPM2B_NAME *name,\n\t\t\t     TPM_HANDLE handle,\n\t\t\t     const char *string)\n{\n    TPM_RC \trc = 0;\n    char \tnameFilename[TPM_DATA_DIR_PATH_LENGTH];\n\n    if (rc == 0) {\n\tif (string == NULL) {\n\t    if (handle != 0) {\n\t\tsprintf(nameFilename, \"%s/h%08x.bin\", tssContext->tssDataDirectory, handle);\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Name_Store: handle and string are both null\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n\telse {\n\t    if (handle == 0) {\n\t\tsprintf(nameFilename, \"%s/h%s.bin\", tssContext->tssDataDirectory, string);\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Name_Store: handle and string are both not null\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Name_Store: File %s\\n\", nameFilename);\n\trc = TSS_File_WriteBinaryFile(name->b.buffer, name->b.size, nameFilename);\n    }\n    return rc;\n}\n\n#endif\n\n/* TSS_Name_Load() loads the 'name' from a file.\n\n   If handle is not 0, the handle is used as the file name.\n\n   If 'string' is not NULL, the string is used as the file name.\n*/\n   \n#ifndef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_Name_Load(TSS_CONTEXT *tssContext,\n\t\t\t    TPM2B_NAME *name,\n\t\t\t    TPM_HANDLE handle,\n\t\t\t    const char *string)\n{\n    TPM_RC \t\trc = 0;\n    char \t\tnameFilename[TPM_DATA_DIR_PATH_LENGTH];\n\t\t\n    if (rc == 0) {\n\tif (string == NULL) {\n\t    if (handle != 0) {\n\t\tsprintf(nameFilename, \"%s/h%08x.bin\", tssContext->tssDataDirectory, handle);\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Name_Load: handle and string are both null\\n\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n\telse {\n\t    if (handle == 0) {\n\t\tsprintf(nameFilename, \"%s/h%s.bin\", tssContext->tssDataDirectory, string);\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Name_Load: handle and string are both not null\\n\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Name_Load: File %s\\n\", nameFilename);\n\trc = TSS_File_Read2B(&name->b,\n\t\t\t     sizeof(name->t.name),\n\t\t\t     nameFilename);\n    }\n    return rc;\n}\n\n#endif\n\n/* TSS_Name_Store() stores the 'name' parameter the TSS context.\n   \n*/\n\n#ifdef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_Name_Store(TSS_CONTEXT *tssContext,\n\t\t\t     TPM2B_NAME *name,\n\t\t\t     TPM_HANDLE handle,\n\t\t\t     const char *string)\n{\n    TPM_RC \trc = 0;\n    TPM_HT \thandleType;\n    size_t\tslotIndex;\n\n    if (tssVverbose) printf(\"TSS_Name_Store: Handle %08x\\n\", handle);\n    handleType = (TPM_HT) ((handle & HR_RANGE_MASK) >> HR_SHIFT);\n\n    switch (handleType) {\n      case TPM_HT_NV_INDEX:\n\t/* for NV, the Name was returned at creation */\n\trc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, handle);\n\tif (rc != 0) {\n\t    rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL);\n\t    if (rc == 0) {\n\t\ttssContext->nvPublic[slotIndex].nvIndex = handle;\n\t    }\n\t    else {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_Name_Store: Error, no slot available for handle %08x\\n\", handle);\n\t    }\n\t}\n\tif (rc == 0) {\n\t    tssContext->nvPublic[slotIndex].name = *name;\n\t}\n\tbreak;\n      case TPM_HT_TRANSIENT:\n      case TPM_HT_PERSISTENT:\n\tif (rc == 0) {\n\t    if (string == NULL) {\n\t\tif (handle != 0) {\n\t\t    /* if this handle is already used, overwrite the slot */\n\t\t    rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle);\n\t\t    if (rc != 0) {\n\t\t\trc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL);\n\t\t\tif (rc == 0) {\n\t\t\t    tssContext->objectPublic[slotIndex].objectHandle = handle;\n\t\t\t}\n\t\t\telse {\n\t\t\t    if (tssVerbose)\n\t\t\t\tprintf(\"TSS_Name_Store: \"\n\t\t\t\t       \"Error, no slot available for handle %08x\\n\",\n\t\t\t\t       handle);\n\t\t\t}\n\t\t    }\n\t\t}\n\t\telse {\n\t\t    if (tssVerbose) printf(\"TSS_Name_Store: handle and string are both null\");\n\t\t    rc = TSS_RC_NAME_FILENAME;\n\t\t}\n\t    }\n\t    else {\n\t\tif (handle == 0) {\n\t\t    if (tssVerbose) printf(\"TSS_Name_Store: string unimplemented\");\n\t\t    rc = TSS_RC_NAME_FILENAME;\n\t\t}\n\t\telse {\n\t\t    if (tssVerbose) printf(\"TSS_Name_Store: handle and string are both not null\");\n\t\t    rc = TSS_RC_NAME_FILENAME;\n\t\t}\n\t    }\n\t}\n\tif (rc == 0) {\n\t    tssContext->objectPublic[slotIndex].name = *name;\n\t}\n\tbreak;\n      default:\n\tif (tssVerbose) printf(\"TSS_Name_Store: handle type %02x unimplemented\", handleType);\n\trc = TSS_RC_NAME_FILENAME;\n    }\n    return rc;\n}\n\n#endif\n\n/* TSS_Name_Load() loads the 'name' from the TSS context.\n   \n*/\n   \n#ifdef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_Name_Load(TSS_CONTEXT *tssContext,\n\t\t\t    TPM2B_NAME *name,\n\t\t\t    TPM_HANDLE handle,\n\t\t\t    const char *string)\n{\n    TPM_RC \trc = 0;\n    TPM_HT \thandleType;\n    size_t\tslotIndex;\n\n    string = string;\n    \n    if (tssVverbose) printf(\"TSS_Name_Load: Handle %08x\\n\", handle);\n    handleType = (TPM_HT) ((handle & HR_RANGE_MASK) >> HR_SHIFT);\n\n    switch (handleType) {\n      case TPM_HT_NV_INDEX:\n\trc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, handle);\n\tif (rc != 0) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_Name_Load: Error, no slot found for handle %08x\\n\", handle);\n\t}\n\tif (rc == 0) {\n\t    *name = tssContext->nvPublic[slotIndex].name;\n\t}\n\tbreak;\n      case TPM_HT_TRANSIENT:\n      case TPM_HT_PERSISTENT:\n\trc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle);\n\tif (rc != 0) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_Name_Load: Error, no slot found for handle %08x\\n\", handle);\n\t}\n\tif (rc == 0) {\n\t    *name = tssContext->objectPublic[slotIndex].name;\n\t}\n\tbreak;\n      default:\n\tif (tssVerbose) printf(\"TSS_Name_Load: handle type %02x unimplemented\", handleType);\n\trc = TSS_RC_NAME_FILENAME;\n\t\n    }\n    return rc;\n}\n\n#endif\n\n/* TSS_Name_Copy() copies the name from either inHandle or inString to either outHandle or\n   outString */\n\nstatic TPM_RC TSS_Name_Copy(TSS_CONTEXT *tssContext,\n\t\t\t    TPM_HANDLE outHandle,\n\t\t\t    const char *outString,\n\t\t\t    TPM_HANDLE inHandle,\n\t\t\t    const char *inString)\n{\n    TPM_RC \t\trc = 0;\n    TPM2B_NAME \t\tname;\n    \n    if (rc == 0) {\n\trc = TSS_Name_Load(tssContext, &name, inHandle, inString);\n    }\n    if (rc == 0) {\n\trc = TSS_Name_Store(tssContext, &name, outHandle, outString);\n    }\n    return rc;\n}\n\n/* TSS_Public_Store() stores the 'public' parameter in a file.\n\n   If handle is not 0, the handle is used as the file name.\n\n   If 'string' is not NULL, the string is used as the file name.\n*/\n\n#ifndef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_Public_Store(TSS_CONTEXT *tssContext,\n\t\t\t       TPM2B_PUBLIC *public,\n\t\t\t       TPM_HANDLE handle,\n\t\t\t       const char *string)\n{\n    TPM_RC \trc = 0;\n    char \tpublicFilename[TPM_DATA_DIR_PATH_LENGTH];\n\n    if (rc == 0) {\n\tif (string == NULL) {\n\t    if (handle != 0) {\t\t/* store by handle */\n\t\tsprintf(publicFilename, \"%s/hp%08x.bin\", tssContext->tssDataDirectory, handle);\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Public_Store: handle and string are both null\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n\telse {\n\t    if (handle == 0) {\t\t/* store by string */\n\t\tsprintf(publicFilename, \"%s/hp%s.bin\", tssContext->tssDataDirectory, string);\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Public_Store: handle and string are both not null\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Public_Store: File %s\\n\", publicFilename);\n\trc = TSS_File_WriteStructure(public,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_PUBLIC_Marshalu,\n\t\t\t\t     publicFilename);\n    }\n    return rc;\n}\n\n#endif\n\n/* TSS_Public_Load() loads the 'public' parameter from a file.\n\n   If handle is not 0, the handle is used as the file name.\n\n   If 'string' is not NULL, the string is used as the file name.\n*/\n   \n#ifndef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_Public_Load(TSS_CONTEXT *tssContext,\n\t\t\t      TPM2B_PUBLIC *public,\n\t\t\t      TPM_HANDLE handle,\n\t\t\t      const char *string)\n{\n    TPM_RC \trc = 0;\n    char \tpublicFilename[TPM_DATA_DIR_PATH_LENGTH];\n\t\t\n    if (rc == 0) {\n\tif (string == NULL) {\n\t    if (handle != 0) {\n\t\tsprintf(publicFilename, \"%s/hp%08x.bin\", tssContext->tssDataDirectory, handle);\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Public_Load: handle and string are both null\\n\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n\telse {\n\t    if (handle == 0) {\n\t\tsprintf(publicFilename, \"%s/hp%s.bin\", tssContext->tssDataDirectory, string);\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Public_Load: handle and string are both not null\\n\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Public_Load: File %s\\n\", publicFilename);\n\trc = TSS_File_ReadStructureFlag(public,\n\t\t\t\t\t(UnmarshalFunctionFlag_t)TSS_TPM2B_PUBLIC_Unmarshalu,\n\t\t\t\t\tTRUE,\t\t\t/* NULL permitted */\n\t\t\t\t\tpublicFilename);\n    }\n    return rc;\n}\n\n#endif \t/* TPM_TSS_NOFILE */\n\n/* TSS_Public_Copy() copies the TPM2B_PUBLIC from either inHandle or inString to either outHandle or\n   outString */\n\nstatic TPM_RC TSS_Public_Copy(TSS_CONTEXT *tssContext,\n\t\t\t      TPM_HANDLE outHandle,\n\t\t\t      const char *outString,\n\t\t\t      TPM_HANDLE inHandle,\n\t\t\t      const char *inString)\n{\n    TPM_RC \t\trc = 0;\n    TPM2B_PUBLIC \tpublic;\n    \n    if (rc == 0) {\n\trc = TSS_Public_Load(tssContext, &public, inHandle, inString);\n    }\n    if (rc == 0) {\n\trc = TSS_Public_Store(tssContext, &public, outHandle, outString);\n    }\n    return rc;\n}\n\n/* TSS_Public_Store() stores the 'public' parameter in the TSS context. \n */\n   \n#ifdef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_Public_Store(TSS_CONTEXT *tssContext,\n\t\t\t       TPM2B_PUBLIC *public,\n\t\t\t       TPM_HANDLE handle,\n\t\t\t       const char *string)\n{\n    TPM_RC \trc = 0;\n    size_t\tslotIndex;\n\n    if (rc == 0) {\n\tif (string == NULL) {\n\t    if (handle != 0) {\n\t\t/* if this handle is already used, overwrite the slot */\n\t\trc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle);\n\t\tif (rc != 0) {\n\t\t    rc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL);\n\t\t    if (rc == 0) {\n\t\t\ttssContext->objectPublic[slotIndex].objectHandle = handle;\n\t\t    }\n\t\t    else {\n\t\t\tif (tssVerbose)\n\t\t\t    printf(\"TSS_Public_Store: Error, no slot available for handle %08x\\n\",\n\t\t\t\t   handle);\n\t\t    }\n\t\t}\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Public_Store: handle and string are both null\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n\telse {\n\t    if (handle == 0) {\n\t\tif (tssVerbose) printf(\"TSS_Public_Store: string not implemented yet\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Public_Store: handle and string are both not null\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\ttssContext->objectPublic[slotIndex].objectPublic = *public;\n    }\n    return rc;\n}\n\n#endif\n\n/* TSS_Public_Load() loaded the object public from the TSS context.\n   \n */\n   \n#ifdef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_Public_Load(TSS_CONTEXT *tssContext,\n\t\t\t      TPM2B_PUBLIC *public,\n\t\t\t      TPM_HANDLE handle,\n\t\t\t      const char *string)\n{\n    TPM_RC \trc = 0;\n    size_t\tslotIndex;\n\t\t\n    if (rc == 0) {\n\tif (string == NULL) {\n\t    if (handle != 0) {\n\t\trc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle);\n\t\tif (rc != 0) {\n\t\t    if (tssVerbose)\n\t\t\tprintf(\"TSS_Public_Load: Error, no slot found for handle %08x\\n\",\n\t\t\t       handle);\n\t\t}\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Public_Load: handle and string are both null\\n\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n\telse {\n\t    if (handle == 0) {\n\t\tif (tssVerbose) printf(\"TSS_Public_Load: string not implemented yet\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t    else {\n\t\tif (tssVerbose) printf(\"TSS_Public_Load: handle and string are both not null\\n\");\n\t\trc = TSS_RC_NAME_FILENAME;\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\t*public = tssContext->objectPublic[slotIndex].objectPublic;\n    }\n    return rc;\n}\n\n#endif \t/* TPM_TSS_NOFILE */\n\n#ifdef TPM_TSS_NOFILE\n\n/* TSS_ObjectPublic_GetSlotForHandle() finds the object public slot corresponding to the handle.\n\n   Returns non-zero if no slot is found.\n*/\n\nstatic TPM_RC TSS_ObjectPublic_GetSlotForHandle(TSS_CONTEXT *tssContext,\n\t\t\t\t\t\tsize_t *slotIndex,\n\t\t\t\t\t\tTPM_HANDLE handle)\n{\n    size_t \ti;\n\n    /* search all slots for handle */\n    for (i = 0 ; i < (sizeof(tssContext->sessions) / sizeof(TSS_SESSIONS)) ; i++) {\n\tif (tssContext->objectPublic[i].objectHandle == handle) {\n\t    *slotIndex = i;\n\t    return 0;\n\t}\n    }\n    return TSS_RC_NO_OBJECTPUBLIC_SLOT;\n}\t\n\n#endif\n\n#ifdef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_ObjectPublic_DeleteData(TSS_CONTEXT *tssContext, TPM_HANDLE handle)\n{\n    TPM_RC\trc = 0;\n    size_t\tslotIndex;\n\n    if (rc == 0) {\n\trc = TSS_ObjectPublic_GetSlotForHandle(tssContext, &slotIndex, handle);\n\tif (rc != 0) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_ObjectPublic_DeleteData: Error, no slot found for handle %08x\\n\",\n\t\t       handle);\n\t}\n    }    \n    if (rc == 0) {\n\ttssContext->objectPublic[slotIndex].objectHandle = TPM_RH_NULL;\n    }\n    return rc;\n}\n\n#endif\n\n\n/* TSS_DeleteHandle() removes retained state stored by the TSS for a handle \n */\n\nstatic TPM_RC TSS_DeleteHandle(TSS_CONTEXT *tssContext,\n\t\t\t       TPM_HANDLE handle)\n{\n    TPM_RC\t\trc = 0;\n    TPM_HT \t\thandleType;\n#ifndef TPM_TSS_NOFILE\n    char\t\tfilename[TPM_DATA_DIR_PATH_LENGTH];\n#endif\n\n    handleType = (TPM_HT) ((handle & HR_RANGE_MASK) >> HR_SHIFT);\n#ifndef TPM_TSS_NOFILE\n    /* delete the Name */\n    if (rc == 0) {\n\tsprintf(filename, \"%s/h%08x.bin\", tssContext->tssDataDirectory, handle);\n\tif (tssVverbose) printf(\"TSS_DeleteHandle: delete Name file %s\\n\", filename);\n\trc = TSS_File_DeleteFile(filename);\n    }\n    /* delete the public if it exists */\n    if (rc == 0) {\n\tif ((handleType == TPM_HT_TRANSIENT) ||\n\t    (handleType == TPM_HT_PERSISTENT)) {\n\t    sprintf(filename, \"%s/hp%08x.bin\", tssContext->tssDataDirectory, handle);\n\t    if (tssVverbose) printf(\"TSS_DeleteHandle: delete public file %s\\n\", filename);\n\t    TSS_File_DeleteFile(filename);\n\t}\n    }\n#else\n    /* sessions persist in the context and can be deleted */\n    if (rc == 0) {\n\tswitch (handleType) {\n\t  case TPM_HT_NV_INDEX:\n\t    rc = TSS_RC_NOT_IMPLEMENTED;\n\t    break;\n\t  case TPM_HT_HMAC_SESSION:\n\t  case TPM_HT_POLICY_SESSION:\n\t    if (tssVverbose) printf(\"TSS_DeleteHandle: delete session state %08x\\n\", handle);\n\t    rc = TSS_HmacSession_DeleteData(tssContext, handle);\n\t    break;\n\t  case TPM_HT_TRANSIENT:\n\t  case TPM_HT_PERSISTENT:\n\t    rc = TSS_ObjectPublic_DeleteData(tssContext, handle);\n\t    break;\n\t}\n    }\n#endif\n    return rc;\n}\n\n#ifndef TPM_TSS_NOCRYPTO\n\n/* TSS_ObjectPublic_GetName() calculates the Name from the TPMT_PUBLIC.  The Name provides security,\n   because the Name returned from the TPM2_ReadPublic cannot be trusted.\n*/\n\nstatic TPM_RC TSS_ObjectPublic_GetName(TPM2B_NAME *name,\n\t\t\t\t       TPMT_PUBLIC *tpmtPublic)\n{\n    TPM_RC \trc = 0;\n    \n    uint16_t \twritten = 0;\n    TPMT_HA\tdigest;\n    uint32_t \tsizeInBytes = 0;\n    uint8_t \t*buffer = NULL;\n\n    if (rc == 0) {\n\trc = TSS_Malloc(&buffer, MAX_RESPONSE_SIZE);\t/* freed @1 */\n    }\n    /* marshal the TPMT_PUBLIC */\n    if (rc == 0) {\n\tuint32_t \tsize = MAX_RESPONSE_SIZE;\n\tuint8_t \t*buffer1 = buffer;\n\trc = TSS_TPMT_PUBLIC_Marshalu(tpmtPublic, &written, &buffer1, &size);\n    }\n    /* hash the public area */\n    if (rc == 0) {\n\tsizeInBytes = TSS_GetDigestSize(tpmtPublic->nameAlg);\n\tdigest.hashAlg = tpmtPublic->nameAlg;\t/* Name digest algorithm */\n\t/* generate the TPMT_HA */\n\trc = TSS_Hash_Generate(&digest,\t\n\t\t\t       written, buffer,\n\t\t\t       0, NULL);\n    }\n    if (rc == 0) {\n\tTPMI_ALG_HASH nameAlgNbo;\n\t/* copy the digest */\n\tmemcpy(name->t.name + sizeof(TPMI_ALG_HASH), (uint8_t *)&digest.digest, sizeInBytes);\n\t/* copy the hash algorithm */\n\tnameAlgNbo = htons(tpmtPublic->nameAlg);\n\tmemcpy(name->t.name, (uint8_t *)&nameAlgNbo, sizeof(TPMI_ALG_HASH));\n\t/* set the size */\n\tname->t.size = sizeInBytes + (uint16_t)sizeof(TPMI_ALG_HASH);\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOCRYPTO */\n\n\n/* TSS_NVPublic_Store() stores the NV public data in a file.\n\n */\n\n#ifndef TPM_TSS_NOFILE\n#ifndef TPM_TSS_NOCRYPTO\n\nstatic TPM_RC TSS_NVPublic_Store(TSS_CONTEXT *tssContext,\n\t\t\t\t TPMS_NV_PUBLIC *nvPublic,\n\t\t\t\t TPMI_RH_NV_INDEX nvIndex)\n{\n    TPM_RC \trc = 0;\n    char \tnvpFilename[TPM_DATA_DIR_PATH_LENGTH];\n\n    if (rc == 0) {\n\tsprintf(nvpFilename, \"%s/nvp%08x.bin\", tssContext->tssDataDirectory, nvIndex);\n\trc = TSS_File_WriteStructure(nvPublic,\n\t\t\t\t     (MarshalFunction_t)TSS_TPMS_NV_PUBLIC_Marshalu,\n\t\t\t\t     nvpFilename);\n    }\n    return rc;\n}\n\n#endif\n#endif\n\n/* TSS_NVPublic_Load() loads the NV public from a file.\n\n */\n\n#ifndef TPM_TSS_NOFILE\n#ifndef TPM_TSS_NOCRYPTO\n\nstatic TPM_RC TSS_NVPublic_Load(TSS_CONTEXT *tssContext,\n\t\t\t\tTPMS_NV_PUBLIC *nvPublic,\n\t\t\t\tTPMI_RH_NV_INDEX nvIndex)\n{\n    TPM_RC \trc = 0;\n    char \tnvpFilename[TPM_DATA_DIR_PATH_LENGTH];\n\n    if (rc == 0) {\n\tsprintf(nvpFilename, \"%s/nvp%08x.bin\", tssContext->tssDataDirectory, nvIndex);\n\trc = TSS_File_ReadStructure(nvPublic,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPMS_NV_PUBLIC_Unmarshalu,\n\t\t\t\t    nvpFilename);\n    }\n    return rc;\n}\n\n#endif\n#endif\n\n#ifndef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_NVPublic_Delete(TSS_CONTEXT *tssContext,\n\t\t\t\t  TPMI_RH_NV_INDEX nvIndex)\n{\n    TPM_RC \trc = 0;\n    char \tnvpFilename[TPM_DATA_DIR_PATH_LENGTH];\n    \n    if (rc == 0) {\n\tsprintf(nvpFilename, \"%s/nvp%08x.bin\", tssContext->tssDataDirectory, nvIndex);\n\trc = TSS_File_DeleteFile(nvpFilename);\n    }\n    return rc;\n}\n\n#endif\n\n#ifdef TPM_TSS_NOFILE\n#ifndef TPM_TSS_NOCRYPTO\n\n/* TSS_NVPublic_Store() stores the NV public data in a file.\n\n */\n\nstatic TPM_RC TSS_NVPublic_Store(TSS_CONTEXT *tssContext,\n\t\t\t\t TPMS_NV_PUBLIC *nvPublic,\n\t\t\t\t TPMI_RH_NV_INDEX nvIndex)\n{\n    TPM_RC \trc = 0;\n    size_t\tslotIndex;\n\n    if (rc == 0) {\n\trc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, nvIndex);\n\tif (rc != 0) {\n\t    rc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, TPM_RH_NULL);\n\t    if (rc == 0) {\n\t\ttssContext->nvPublic[slotIndex].nvIndex = nvIndex;\n\t    }\n\t    else {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_NVPublic_Store: Error, no slot available for handle %08x\\n\",\n\t\t\t   nvIndex);\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\ttssContext->nvPublic[slotIndex].nvPublic = *nvPublic;\n    }\n    return rc;\n}\n\n#endif\n#endif\n\n#ifdef TPM_TSS_NOFILE\n#ifndef TPM_TSS_NOCRYPTO\n\n/* TSS_NVPublic_Load() loads the NV public from a file.\n\n */\n\nstatic TPM_RC TSS_NVPublic_Load(TSS_CONTEXT *tssContext,\n\t\t\t\tTPMS_NV_PUBLIC *nvPublic,\n\t\t\t\tTPMI_RH_NV_INDEX nvIndex)\n{\n    TPM_RC \trc = 0;\n    size_t\tslotIndex;\n\n    if (rc == 0) {\n\trc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, nvIndex);\n\tif (rc != 0) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_NVPublic_Load: Error, no slot found for handle %08x\\n\",\n\t\t       nvIndex);\n\t}\n    }\n    if (rc == 0) {\n\t*nvPublic = tssContext->nvPublic[slotIndex].nvPublic;\n    }\n    return rc;\n}\n\n#endif\n#endif\n\n#ifdef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_NVPublic_Delete(TSS_CONTEXT *tssContext,\n\t\t\t\t  TPMI_RH_NV_INDEX nvIndex)\n{\n    TPM_RC \trc = 0;\n    size_t\tslotIndex;\n    \n    if (rc == 0) {\n\trc = TSS_NvPublic_GetSlotForHandle(tssContext, &slotIndex, nvIndex);\n\tif (rc != 0) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_NVPublic_Delete: Error, no slot found for handle %08x\\n\",\n\t\t       nvIndex);\n\t}\n    }\n    if (rc == 0) {\n\ttssContext->nvPublic[slotIndex].nvIndex = TPM_RH_NULL;\n    }\n    return rc;\n}\n\n#endif\n\n#ifdef TPM_TSS_NOFILE\n\n/* TSS_NvPublic_GetSlotForHandle() finds the object public slot corresponding to the handle.\n\n   Returns non-zero if no slot is found.\n*/\n\nstatic TPM_RC TSS_NvPublic_GetSlotForHandle(TSS_CONTEXT *tssContext,\n\t\t\t\t\t    size_t *slotIndex,\n\t\t\t\t\t    TPMI_RH_NV_INDEX nvIndex)\n{\n    size_t \ti;\n\n    /* search all slots for handle */\n    for (i = 0 ; i < (sizeof(tssContext->nvPublic) / sizeof(TSS_NVPUBLIC)) ; i++) {\n\tif (tssContext->nvPublic[i].nvIndex == nvIndex) {\n\t    *slotIndex = i;\n\t    return 0;\n\t}\n    }\n    return TSS_RC_NO_NVPUBLIC_SLOT;\n}\t\n\n#endif\n\n/* TSS_NVPublic_GetName() calculates the Name from the TPMS_NV_PUBLIC.  The Name provides security,\n   because the Name returned from the TPM2_NV_ReadPublic cannot be trusted.\n*/\n\n#ifndef TPM_TSS_NOCRYPTO\n\nstatic TPM_RC TSS_NVPublic_GetName(TPM2B_NAME *name,\n\t\t\t\t   TPMS_NV_PUBLIC *nvPublic)\n{\n    TPM_RC \trc = 0;\n    \n    uint16_t \twritten = 0;\n    TPMT_HA\tdigest;\n    uint32_t \tsizeInBytes = 0;\n    uint8_t \t*buffer = NULL;\n\n    if (rc == 0) {\n\trc = TSS_Malloc(&buffer, MAX_RESPONSE_SIZE);\t/* freed @1 */\n    }\n    /* marshal the TPMS_NV_PUBLIC */\n    if (rc == 0) {\n\tuint32_t \tsize = MAX_RESPONSE_SIZE;\n\tuint8_t \t*buffer1 = buffer;\n\trc = TSS_TPMS_NV_PUBLIC_Marshalu(nvPublic, &written, &buffer1, &size);\n    }\n    /* hash the public area */\n    if (rc == 0) {\n\tsizeInBytes = TSS_GetDigestSize(nvPublic->nameAlg);\n\tdigest.hashAlg = nvPublic->nameAlg;\t/* Name digest algorithm */\n\t/* generate the TPMT_HA */\n\trc = TSS_Hash_Generate(&digest,\t\n\t\t\t       written, buffer,\n\t\t\t       0, NULL);\n    }\n    if (rc == 0) {\n\tTPMI_ALG_HASH nameAlgNbo;\n\t/* copy the digest */\n\tmemcpy(name->t.name + sizeof(TPMI_ALG_HASH), (uint8_t *)&digest.digest, sizeInBytes);\n\t/* copy the hash algorithm */\n\tnameAlgNbo = htons(nvPublic->nameAlg);\n\tmemcpy(name->t.name, (uint8_t *)&nameAlgNbo, sizeof(TPMI_ALG_HASH));\n\t/* set the size */\n\tname->t.size = sizeInBytes + (uint16_t)sizeof(TPMI_ALG_HASH);\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n#endif\n\n#ifndef TPM_TSS_NOCRYPTO\n\nstatic TPM_RC TSS_HmacSession_SetNonceCaller(struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t     TPMS_AUTH_COMMAND \t*authC)\n{\n    TPM_RC\t\trc = 0;\n\n    /* generate a new nonceCaller */\n    if (rc == 0) {\n\tsession->nonceCaller.b.size = session->sizeInBytes;\n\trc = TSS_RandBytes(session->nonceCaller.t.buffer, session->sizeInBytes);\n    }\n    /* nonceCaller for the command */\n    if (rc == 0) {\n\trc = TSS_TPM2B_Copy(&authC->nonce.b, &session->nonceCaller.b, sizeof(TPMU_HA));\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOCRYPTO */\n\n#ifndef TPM_TSS_NOCRYPTO\n\n/* TSS_HmacSession_SetHmacKey() calculates the session HMAC key.\n\n   handleNumber is index into the session area.  The first sessions, the authorization sessions,\n   have a corresponding handle in the command handle.\n*/\n\nstatic TPM_RC TSS_HmacSession_SetHmacKey(TSS_CONTEXT *tssContext,\n\t\t\t\t\t struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t size_t handleNumber,\t/* index into the handle area */\n\t\t\t\t\t const char *password)\n{\n    TPM_RC\t\trc = 0;\n    TPM_HANDLE \t\tcommandHandle;\t\t/* from handle area, for bound session */\n    TPM2B_NAME\t\tname;\n    TPM2B_AUTH \t\tauthValue;\n    int \t\tbindMatch = FALSE;\n    int \t\tdone = FALSE;\t\t/* done with authorization sessions */\n\n    /*\n      authHMAC = HMAC sessionAlg ((sessionKey || authValue), \n      (pHash || nonceNewer || nonceOlder \n      { || nonceTPMdecrypt } { || nonceTPMencrypt }\n      || sessionAttributes))\n    */\n    /* HMAC key is sessionKey || authValue */\n    /* copy the session key to HMAC key */\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_HmacSession_SetHmacKey: sessionKey\",\n\t\t\t\t      session->sessionKey.b.buffer, session->sessionKey.b.size);\n\trc = TSS_TPM2B_Copy(&session->hmacKey.b,\n\t\t\t    &session->sessionKey.b, sizeof(TPMU_HA) + sizeof(TPMT_HA));\n    }\n    /* copy the session key to sessionValue */\n    if (rc == 0) {\n\trc = TSS_TPM2B_Copy(&session->sessionValue.b,\n\t\t\t    &session->sessionKey.b, sizeof(TPMU_HA) + sizeof(TPMT_HA));\n    }\n    if (rc == 0) {\n\tif (tssVverbose)\n\t    TSS_PrintAll(\"TSS_HmacSession_SetHmacKey: preliminary sessionValue\",\n\t\t\t session->sessionValue.b.buffer, session->sessionValue.b.size);\n    }\n    /* This value is an EmptyAuth if the HMAC is being computed to authorize an action on the\n       object to which the session is bound.\n    */\n    /* The first sessions are authorization sessions.  They can have a bind entity.  All others can\n       be encrypt or decrypt sessions, but the authValue is not included in the session key.\n    */\n    if (rc == 0) {\n\tAUTH_ROLE authRole = TSS_GetAuthRole(tssContext->tssAuthContext, handleNumber);\n\tif (authRole == AUTH_NONE) {\n\t    if (tssVverbose) printf(\"TSS_HmacSession_SetHmacKey: Done, not auth session\\n\");\n\t    done = TRUE;\t/* not an authorization session, could be audit or\n\t\t\t\t   encrypt/decrypt */\n\t}\n    }\n    /* If not an authorization session, there is no authValue to append to the HMAC key or encrypt\n       sessionValue, regardless of the binding.  Below is for auth sessions. */\n    if (!done) {\n\t/* First, if there was a bind handle, check if the name matches.  Else bindMatch remains\n\t   FALSE. */\n\tif (session->bind != TPM_RH_NULL) {\n\t    /* get the handle for this session */\n\t    if (tssVverbose)\n\t\tprintf(\"TSS_HmacSession_SetHmacKey: Processing bind handle %08x\\n\", session->bind);\n\t    if (rc == 0) {\n\t\trc = TSS_GetCommandHandle(tssContext->tssAuthContext,\n\t\t\t\t\t  &commandHandle,\n\t\t\t\t\t  handleNumber);\n\t    }\n\t    /* get the Name corresponding to the handle */\n\t    if (rc == 0) {\n\t\tif (tssVverbose)\n\t\t    printf(\"TSS_HmacSession_SetHmacKey: commandHandle %08x bindHandle %08x\\n\",\n\t\t\t   commandHandle, session->bind);\n\t\trc = TSS_Name_GetName(tssContext, &name, commandHandle);\n\t    }\n\t    /* compare the authorized object name to the bind object name */\n\t    if (rc == 0) {\n\t\tbindMatch = TSS_TPM2B_Compare(&name.b, &session->bindName.b);\n\t\tif (tssVverbose) printf(\"TSS_HmacSession_SetHmacKey: bind match %u\\n\", bindMatch);\n\t    }\n\t}\n\t/* Second, append password to session key for HMAC key if required */\n\n\t/* When performing an HMAC for authorization, the HMAC key is normally the concatenation of\n\t   the entity's authValue to the sessions sessionKey (created at\n\t   TPM2_StartAuthSession(). However, if the authorization is for the entity to\n\t   which the session is bound, the authValue is not included in the HMAC key. When\n\t   a policy requires that an HMAC be computed, it is always concatenated.\n\t*/\n\tif ((rc == 0) &&\n\t    /* append if HMAC session and not bind match */\n\t    (((session->sessionType == TPM_SE_HMAC) && !bindMatch) ||\n\t     /* append if policy and policy authvalue */\n\t     ((session->sessionType == TPM_SE_POLICY) && session->isAuthValueNeeded)) &&\n\t    (password != NULL)\t/* if password is NULL, nothing to append. */\n\n\t    ) {\n\t    \n\t    if (tssVverbose)\n\t\tprintf(\"TSS_HmacSession_SetHmacKey: Appending authValue to HMAC key\\n\");\n\t    /* convert the password to an authvalue */\n\t    if (rc == 0) {\n\t\trc = TSS_TPM2B_StringCopy(&authValue.b, password, sizeof(authValue.t.buffer));\n\t    }\n\t    /* append the authvalue to the session key to create the hmac key */\n\t    if (rc == 0) {\n\t\trc = TSS_TPM2B_Append(&session->hmacKey.b, &authValue.b,\n\t\t\t\t      sizeof(TPMU_HA) + sizeof(TPMT_HA));\n\t    }\n\t}\n\t/* Third, append password to session key for sessionValue\n\n\t   If a session is also being used for authorization, sessionValue (see 21.2 and 21.3) is\n\t   sessionKey || authValue. The binding of the session is ignored. If the session is not\n\t   being used for authorization, sessionValue is sessionKey.\n\t */\n\t/* NOTE This step occurs even if there is a bind match. That is, the password is effectively\n\t   appended twice. */\n\tif (rc == 0) {\n\t    /* if not bind, sessionValue is sessionKey || authValue (same as HMAC key) */\n\t    if (!bindMatch) {\n\t\tif (tssVverbose)\n\t\t    printf(\"TSS_HmacSession_SetHmacKey: \"\n\t\t\t   \"No bind, appending authValue to sessionValue\\n\");\n\t\t/* convert the password to an authvalue */\n\t\tif (rc == 0) {\n\t\t    rc = TSS_TPM2B_StringCopy(&authValue.b, password, sizeof(authValue.t.buffer));\n\t\t}\n\t\tif (rc == 0) {\n\t\t    rc = TSS_TPM2B_Append(&session->sessionValue.b, &authValue.b,\n\t\t\t\t\t  sizeof(TPMU_HA) + sizeof(TPMT_HA));\n\t\t}\n\t    }\n\t    /* if bind, sessionValue is sessionKey || bindAuthValue */\n\t    else {\n\t\tif (tssVverbose)\n\t\t    printf(\"TSS_HmacSession_SetHmacKey: \"\n\t\t\t   \"Bind, appending bind authValue to sessionValue\\n\");\n\t\tif (rc == 0) {\n\t\t    rc = TSS_TPM2B_Append(&session->sessionValue.b, &session->bindAuthValue.b,\n\t\t\t\t\t  sizeof(TPMU_HA) + sizeof(TPMT_HA));\n\t\t}\n\t    }\n\t    if (rc == 0) {\n\t\tif (tssVverbose)\n\t\t    TSS_PrintAll(\"TSS_HmacSession_SetHmacKey: bindAuthValue\",\n\t\t\t\t session->bindAuthValue.b.buffer, session->bindAuthValue.b.size);\n\t    }\n\t}\n    }\n    if (rc == 0) {\n\tif (tssVverbose)\n\t    TSS_PrintAll(\"TSS_HmacSession_SetHmacKey: hmacKey\",\n\t\t\t session->hmacKey.b.buffer, session->hmacKey.b.size);\n\tif (tssVverbose)\n\t    TSS_PrintAll(\"TSS_HmacSession_SetHmacKey: sessionValue\",\n\t\t\t session->sessionValue.b.buffer, session->sessionValue.b.size);\n    }\n    return rc;\n}\n    \n#endif\t/* TPM_TSS_NOCRYPTO */\n\n/* TSS_HmacSession_SetHMAC() is used for a command.  It sets all the values in one\n   TPMS_AUTH_COMMAND, ready for marshaling into the command packet.\n\n   - gets cpBuffer\n   - generates cpHash\n   - generates the HMAC\n   - copies the result into authCommand\n\n   Unused names must have size 0.\n\n   The HMAC key is already in the session structure.\n*/\n\nstatic TPM_RC TSS_HmacSession_SetHMAC(TSS_AUTH_CONTEXT *tssAuthContext,\t/* authorization context */\n\t\t\t\t      struct TSS_HMAC_CONTEXT *session[],\n\t\t\t\t      TPMS_AUTH_COMMAND *authCommand[],\t/* output: command\n\t\t\t\t\t\t\t\t\t   authorization */\n\t\t\t\t      TPMI_SH_AUTH_SESSION sessionHandle[], /* session handles in\n\t\t\t\t\t\t\t\t\t       command */\n\t\t\t\t      unsigned int sessionAttributes[],\t/* attributes for this\n\t\t\t\t\t\t\t\t\t   command */\n\t\t\t\t      const char *password[],\n\t\t\t\t      TPM2B_NAME *name0,\t\t/* up to 3 names */\n\t\t\t\t      TPM2B_NAME *name1,\t/* unused names have length 0 */\n\t\t\t\t      TPM2B_NAME *name2)\n{\n    TPM_RC\t\trc = 0;\n    unsigned int\ti = 0;\n#ifndef TPM_TSS_NOCRYPTO\n    TPMT_HA \t\tcpHash;\n    TPMT_HA \t\thmac;\n    TPM2B_NONCE\tnonceTPMDecrypt;\n    TPM2B_NONCE\tnonceTPMEncrypt;\n    cpHash.hashAlg = TPM_ALG_NULL;\t/* for cpHash calculation optimization */\n#endif\t/* TPM_TSS_NOCRYPTO */\n\n\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) && (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tuint8_t sessionAttr8;\n\tif (tssVverbose) printf(\"TSS_HmacSession_SetHMAC: Step 6 session %08x\\n\", sessionHandle[i]);\n\t/* password sessions were serviced in step 2. */\n\tif (sessionHandle[i] == TPM_RS_PW) {\n\t    continue;\n\t}\n\tif (tssVverbose) printf(\"TSS_HmacSession_SetHMAC: sessionType %02x\\n\",\n\t\t\t\tsession[i]->sessionType);\n\tif (tssVverbose) printf(\"TSS_HmacSession_SetHMAC: isPasswordNeeded %02x\\n\",\n\t\t\t\tsession[i]->isPasswordNeeded);\n\tif (tssVverbose) printf(\"TSS_HmacSession_SetHMAC: isAuthValueNeeded %02x\\n\",\n\t\t\t\tsession[i]->isAuthValueNeeded);\n\t/* sessionHandle */\n\tauthCommand[i]->sessionHandle = session[i]->sessionHandle;\n\t/* attributes come from command */\n\tsessionAttr8 = (uint8_t)sessionAttributes[i];\n\tauthCommand[i]->sessionAttributes.val = sessionAttr8;\n\n\t/* policy session with policy password handled below, no hmac.  isPasswordNeeded is never\n\t   true for an HMAC session, so don't need to test session type here. */\n\tif (!(session[i]->isPasswordNeeded)) {\n\t    /* HMAC session */ \n\t    if ((session[i]->sessionType == TPM_SE_HMAC) ||\n\t\t/* policy session with TPM2_PolicyAuthValue */\n\t\t((session[i]->sessionType == TPM_SE_POLICY) && (session[i]->isAuthValueNeeded)) ||\n\t\t/* salted session */\n\t\t(session[i]->hmacKey.t.size != 0)\n\t\t) {\n\t\t/* needs HMAC */\n#ifndef TPM_TSS_NOCRYPTO\n\t\tif (tssVverbose) printf(\"TSS_HmacSession_SetHMAC: calculate HMAC\\n\");\n\t\t/* calculate cpHash.  Performance optimization: If there is more than one session,\n\t\t   and the hash algorithm is the same, use the previously calculated version. */\n\t\tif ((rc == 0) && (cpHash.hashAlg != session[i]->authHashAlg)) {\n\t\t    uint32_t cpBufferSize;\n\t\t    uint8_t *cpBuffer;\n\t\t    TPM_CC commandCode;\n\t\t    TPM_CC commandCodeNbo;\n\n\t\t    if (rc == 0) {\n\t\t\trc = TSS_GetCpBuffer(tssAuthContext,\n\t\t\t\t\t     &cpBufferSize,\n\t\t\t\t\t     &cpBuffer);\n\t\t    }\n\t\t    if (rc == 0) {\n\t\t\tif (tssVverbose) TSS_PrintAll(\"TSS_HmacSession_SetHMAC: cpBuffer\",\n\t\t\t\t\t\t      cpBuffer, cpBufferSize);\n\t\t\tcpHash.hashAlg = session[i]->authHashAlg;\n\n\t\t\t/* cpHash = hash(commandCode [ || authName1\t\t*/\n\t\t\t/*                           [ || authName2\t\t*/\n\t\t\t/*                           [ || authName3 ]]]\t*/\n\t\t\t/*                           [ || parameters])\t*/\n\t\t\t/* A cpHash can contain just a commandCode only if the lone session is */\n\t\t\t/* an audit session. */\n\n\t\t\tcommandCode = TSS_GetCommandCode(tssAuthContext);\n\t\t\tcommandCodeNbo = htonl(commandCode);\n\t\t\trc = TSS_Hash_Generate(&cpHash,\t\t/* largest size of a digest */\n\t\t\t\t\t       sizeof(TPM_CC), &commandCodeNbo,\n\t\t\t\t\t       name0->b.size, &name0->b.buffer,\n\t\t\t\t\t       name1->b.size, &name1->b.buffer,\n\t\t\t\t\t       name2->b.size, &name2->b.buffer,\n\t\t\t\t\t       cpBufferSize, cpBuffer,\n\t\t\t\t\t       0, NULL);\n\t\t    }\n\t\t}\n\t\tif (i == 0) {\n\t\t    unsigned int \tisDecrypt = 0;\t/* count number of sessions with decrypt\n\t\t\t\t\t\t\t   set */\n\t\t    unsigned int\tdecryptSession = 0;\t/* which one is decrypt */\n\t\t    unsigned int \tisEncrypt = 0;\t/* count number of sessions with decrypt\n\t\t\t\t\t\t\t   set */\n\t\t    unsigned int\tencryptSession = 0;\t/* which one is decrypt */\n\t\t    nonceTPMDecrypt.t.size = 0;\n\t\t    nonceTPMEncrypt.t.size = 0;\n\t\t    /* if a different session is being used for parameter decryption, then the\n\t\t       nonceTPM for that session is included in the HMAC of the first authorization\n\t\t       session */\n\t\t    if (rc == 0) {\n\t\t\trc = TSS_Sessions_GetDecryptSession(&isDecrypt,\n\t\t\t\t\t\t\t    &decryptSession,\n\t\t\t\t\t\t\t    sessionHandle,\n\t\t\t\t\t\t\t    sessionAttributes);\n\t\t    }\n\t\t    if ((rc == 0) && isDecrypt && (decryptSession != 0)) {\n\t\t\trc = TSS_TPM2B_Copy(&nonceTPMDecrypt.b,\n\t\t\t\t\t    &session[decryptSession]->nonceTPM.b, sizeof(TPMU_HA));\n\t\t    }\n\t\t    /* if a different session is being used for parameter encryption, then the\n\t\t       nonceTPM for that session is included in the HMAC of the first authorization\n\t\t       session */\n\t\t    if (rc == 0) {\n\t\t\trc = TSS_Sessions_GetEncryptSession(&isEncrypt,\n\t\t\t\t\t\t\t    &encryptSession,\n\t\t\t\t\t\t\t    sessionHandle,\n\t\t\t\t\t\t\t    sessionAttributes);\n\t\t    }\n\t\t    /* Don't include the same nonce twice */\n\t\t    if ((rc == 0) && isEncrypt && (encryptSession != 0)) {\n\t\t\tif (!isDecrypt || (encryptSession != decryptSession)) {\n\t\t\t    rc = TSS_TPM2B_Copy(&nonceTPMEncrypt.b, \n\t\t\t\t\t\t&session[encryptSession]->nonceTPM.b,\n\t\t\t\t\t\tsizeof(TPMU_HA));\n\t\t\t}\n\t\t    }\n\t\t}\n\t\t/* for other than the first session, those nonces are not used */\n\t\telse {\n\t\t    nonceTPMDecrypt.t.size = 0;\n\t\t    nonceTPMEncrypt.t.size = 0;\n\t\t}\n\t\t/* */\n\t\tif (rc == 0) {\n\t\t    hmac.hashAlg = session[i]->authHashAlg;\n\t\t    rc = TSS_HMAC_Generate(&hmac,\t\t\t\t/* output hmac */\n\t\t\t\t\t   &session[i]->hmacKey,\t\t/* input key */\n\t\t\t\t\t   session[i]->sizeInBytes, (uint8_t *)&cpHash.digest,\n\t\t\t\t\t   /* new is nonceCaller */\n\t\t\t\t\t   session[i]->nonceCaller.b.size,\n\t\t\t\t\t   &session[i]->nonceCaller.b.buffer,\n\t\t\t\t\t   /* old is previous nonceTPM */\n\t\t\t\t\t   session[i]->nonceTPM.b.size,\n\t\t\t\t\t   &session[i]->nonceTPM.b.buffer,\n\t\t\t\t\t   /* nonceTPMDecrypt */\n\t\t\t\t\t   nonceTPMDecrypt.b.size, nonceTPMDecrypt.b.buffer,\n\t\t\t\t\t   /* nonceTPMEncrypt */\n\t\t\t\t\t   nonceTPMEncrypt.b.size, nonceTPMEncrypt.b.buffer,\n\t\t\t\t\t   /* 1 byte, no endian conversion */\n\t\t\t\t\t   sizeof(uint8_t), &sessionAttr8,\n\t\t\t\t\t   0, NULL);\n\t\t    if (tssVverbose) {\n\t\t\tTSS_PrintAll(\"TSS_HmacSession_SetHMAC: HMAC key\",\n\t\t\t\t     session[i]->hmacKey.t.buffer, session[i]->hmacKey.t.size);\n\t\t\tTSS_PrintAll(\"TSS_HmacSession_SetHMAC: cpHash\",\n\t\t\t\t     (uint8_t *)&cpHash.digest, session[i]->sizeInBytes);\n\t\t\tTSS_PrintAll(\"TSS_HmacSession_Set: nonceCaller\",\n\t\t\t\t     session[i]->nonceCaller.b.buffer,\n\t\t\t\t     session[i]->nonceCaller.b.size);\n\t\t\tTSS_PrintAll(\"TSS_HmacSession_SetHMAC: nonceTPM\",\n\t\t\t\t     session[i]->nonceTPM.b.buffer, session[i]->nonceTPM.b.size);\n\t\t\tTSS_PrintAll(\"TSS_HmacSession_SetHMAC: nonceTPMDecrypt\",\n\t\t\t\t     nonceTPMDecrypt.b.buffer, nonceTPMDecrypt.b.size);\n\t\t\tTSS_PrintAll(\"TSS_HmacSession_SetHMAC: nonceTPMEncrypt\",\n\t\t\t\t     nonceTPMEncrypt.b.buffer, nonceTPMEncrypt.b.size);\n\t\t\tTSS_PrintAll(\"TSS_HmacSession_SetHMAC: sessionAttributes\",\n\t\t\t\t     &sessionAttr8, sizeof(uint8_t));\n\t\t\tTSS_PrintAll(\"TSS_HmacSession_SetHMAC: HMAC\",\n\t\t\t\t     (uint8_t *)&hmac.digest, session[i]->sizeInBytes);\n\t\t    }\n\t\t}\n\t\t/* copy HMAC into authCommand TPM2B_AUTH hmac */\n\t\tif (rc == 0) {\n\t\t    rc = TSS_TPM2B_Create(&authCommand[i]->hmac.b,\n\t\t\t\t\t  (uint8_t *)&hmac.digest,\n\t\t\t\t\t  session[i]->sizeInBytes,\n\t\t\t\t\t  sizeof(authCommand[i]->hmac.t.buffer));\n\t\t}\n#else\n\t\ttssAuthContext = tssAuthContext;\n\t\tname0 = name0;\n\t\tname1 = name1;\n\t\tname2 = name2;\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_HmacSession_SetHMAC: Error, with no crypto not implemented\\n\");\n\t\trc = TSS_RC_NOT_IMPLEMENTED;\n#endif\t/* TPM_TSS_NOCRYPTO */\n\t    }\n\t    /* not HMAC, not policy requiring password or hmac */\n\t    else {\n\t\tauthCommand[i]->hmac.b.size = 0;\n\t    }\n\t}\n\t/* For a policy session that contains TPM2_PolicyPassword(), the password takes precedence\n\t   and must be present in hmac. */\n\telse {\t\t/* isPasswordNeeded true */\n\t    if (tssVverbose) printf(\"TSS_HmacSession_SetHMAC: use password\\n\");\n\t    /* nonce has already been set */\n\t    rc = TSS_TPM2B_StringCopy(&authCommand[i]->hmac.b,\n\t\t\t\t      password[i], sizeof(authCommand[i]->hmac.t.buffer));\n\t}\n    }\n    return rc;\n}\n\n\n#ifndef TPM_TSS_NOCRYPTO\n\n/* TSS_HmacSession_Verify() is used for a response.  It uses the values in TPMS_AUTH_RESPONSE to\n   validate the response HMAC\n*/\n\nstatic TPM_RC TSS_HmacSession_Verify(TSS_AUTH_CONTEXT *tssAuthContext,\t/* authorization context */\n\t\t\t\t     struct TSS_HMAC_CONTEXT *session,\t/* TSS session context */\n\t\t\t\t     TPMS_AUTH_RESPONSE *authResponse)\t/* input: response authorization */\n{\n    TPM_RC\t\trc = 0;\n    uint32_t\t\trpBufferSize;\n    uint8_t \t\t*rpBuffer;\n    TPMT_HA \t\trpHash;\n    TPMT_HA \t\tactualHmac;\n\n    /* get the rpBuffer */\n    if (rc == 0) {\n\trc = TSS_GetRpBuffer(tssAuthContext, &rpBufferSize, &rpBuffer);\n\tif (tssVverbose) TSS_PrintAll(\"TSS_HmacSession_Verify: rpBuffer\",\n\t\t\t\t      rpBuffer, rpBufferSize);\n    }\n    /* calculate rpHash */\n    if (rc == 0) {\n\tTPM_CC commandCode;\n\tTPM_CC commandCodeNbo;\n\trpHash.hashAlg = session->authHashAlg;\n\t\n\tcommandCode = TSS_GetCommandCode(tssAuthContext);\n\tcommandCodeNbo = htonl(commandCode);\n\t\n\t/* rpHash = HsessionAlg (responseCode || commandCode {|| parameters })\t */\n\trc = TSS_Hash_Generate(&rpHash,\t\t\t/* largest size of a digest */\n\t\t\t       sizeof(TPM_RC), &rc,\t/* RC is always 0, no need to endian\n\t\t\t\t\t\t\t   convert */\n\t\t\t       sizeof(TPM_CC), &commandCodeNbo,\n\t\t\t       rpBufferSize, rpBuffer,\n\t\t\t       0, NULL);\n    }\n    /* construct the actual HMAC as TPMT_HA */\n    if (rc == 0) {\n\tactualHmac.hashAlg = session->authHashAlg;\n\tif (authResponse->hmac.t.size != session->sizeInBytes) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_HmacSession_Verify: HMAC size %u inconsistent with algorithm %u\\n\",\n\t\t       authResponse->hmac.t.size, session->sizeInBytes);\n\t    rc = TSS_RC_HMAC_SIZE;\n\t}\n    }\n    if (rc == 0) {\n\tmemcpy((uint8_t *)&actualHmac.digest, &authResponse->hmac.t.buffer,\n\t       authResponse->hmac.t.size);\n    }\n    /* verify the HMAC */\n    if (rc == 0) {\n\tif (tssVverbose) {\n\t    TSS_PrintAll(\"TSS_HmacSession_Verify: HMAC key\",\n\t\t\t session->hmacKey.t.buffer, session->hmacKey.t.size);\n\t    TSS_PrintAll(\"TSS_HmacSession_Verify: rpHash\",\n\t\t\t (uint8_t *)&rpHash.digest, session->sizeInBytes);\n\t    TSS_PrintAll(\"TSS_HmacSession_Verify: nonceTPM\",\n\t\t\t session->nonceTPM.b.buffer, session->nonceTPM.b.size);\n\t    TSS_PrintAll(\"TSS_HmacSession_Verify: nonceCaller\",\n\t\t\t session->nonceCaller.b.buffer, session->nonceCaller.b.size);\n\t    TSS_PrintAll(\"TSS_HmacSession_Verify: sessionAttributes\",\n\t\t\t &authResponse->sessionAttributes.val, sizeof(uint8_t));\n\t    TSS_PrintAll(\"TSS_HmacSession_Verify: response HMAC\",\n\t\t\t (uint8_t *)&authResponse->hmac.t.buffer, session->sizeInBytes);\n\t}\n\trc = TSS_HMAC_Verify(&actualHmac,\t\t/* input response hmac */\n\t\t\t     &session->hmacKey,\t\t/* input HMAC key */\n\t\t\t     session->sizeInBytes,\n\t\t\t     /* rpHash */\n\t\t\t     session->sizeInBytes, (uint8_t *)&rpHash.digest,\n\t\t\t     /* new is nonceTPM */\n\t\t\t     session->nonceTPM.b.size, &session->nonceTPM.b.buffer,\n\t\t\t     /* old is nonceCaller */\n\t\t\t     session->nonceCaller.b.size, &session->nonceCaller.b.buffer,\n\t\t\t     /* 1 byte, no endian conversion */\n\t\t\t     sizeof(uint8_t), &authResponse->sessionAttributes.val,\n\t\t\t     0, NULL);\n    }\n    return rc;\n}\n\n#endif \t/* TPM_TSS_NOCRYPTO */\n\n/* TSS_HmacSession_Continue() handles the response continueSession flag.  It either saves the\n   updated session or deletes the session state. */\n\nstatic TPM_RC TSS_HmacSession_Continue(TSS_CONTEXT *tssContext,\n\t\t\t\t       struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t       TPMS_AUTH_RESPONSE *authR)\n{\n    TPM_RC\t\trc = 0;\n\n    if (rc == 0) {\n\t/* if continue set */\n\tif (authR->sessionAttributes.val & TPMA_SESSION_CONTINUESESSION) {\n\t    /* clear the policy flags in preparation for the next use */\n\t    session->isPasswordNeeded = FALSE;\n\t    session->isAuthValueNeeded = FALSE;\n\t    /* save the session */\n\t    rc = TSS_HmacSession_SaveSession(tssContext, session);\n\t}\n\telse {\t\t/* continue clear */\n\t    /* delete the session state */\n\t    rc = TSS_DeleteHandle(tssContext, session->sessionHandle);\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Sessions_GetDecryptSession() searches for a command decrypt session.  If found, returns\n   isDecrypt TRUE, and the session number in decryptSession.\n\n*/\n\nstatic TPM_RC TSS_Sessions_GetDecryptSession(unsigned int *isDecrypt,\n\t\t\t\t\t     unsigned int *decryptSession,\n\t\t\t\t\t     TPMI_SH_AUTH_SESSION sessionHandle[],\n\t\t\t\t\t     unsigned int sessionAttributes[])\n{\n    TPM_RC\t\trc = 0;\n    unsigned int \ti = 0;\n\n    /* count the number of command decrypt sessions */\n    *isDecrypt = 0;\t\t\t\t/* number of sessions with decrypt set */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) &&\n\t     (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tif (sessionHandle[i] != TPM_RS_PW) {\t/* no decrypt for password session */\n\t    if (sessionAttributes[i] & TPMA_SESSION_DECRYPT) {\n\t\t(*isDecrypt)++;\t\t/* count number of decrypt sessions */\n\t\t*decryptSession = i;\t/* record which one it was */\n\t    }\n\t}\n    }\n    /* how many decrypt sessions were found */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Sessions_GetDecryptSession: Found %u decrypt sessions at %u\\n\",\n\t\t\t\t*isDecrypt, *decryptSession);\n\tif (*isDecrypt > 1) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_Sessions_GetDecryptSession: Error, found %u decrypt sessions\\n\",\n\t\t       *isDecrypt);\n\t    rc = TSS_RC_DECRYPT_SESSIONS;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Sessions_GetEncryptSession() searches for a response encrypt session.  If found, returns\n   isEncrypt TRUE, and the session number in encryptSession.\n\n*/\n\nstatic TPM_RC TSS_Sessions_GetEncryptSession(unsigned int *isEncrypt,\n\t\t\t\t\t     unsigned int *encryptSession,\n\t\t\t\t\t     TPMI_SH_AUTH_SESSION sessionHandle[],\n\t\t\t\t\t     unsigned int sessionAttributes[])\n{\n    TPM_RC\t\trc = 0;\n    unsigned int \ti = 0;\n\n    /* count the number of command encrypt sessions */\n    *isEncrypt = 0;\t\t/* number of sessions with encrypt set */\n    for (i = 0 ; (rc == 0) && (i < MAX_SESSION_NUM) &&\n\t     (sessionHandle[i] != TPM_RH_NULL) ; i++) {\n\tif (sessionHandle[i] != TPM_RS_PW) {\t/* no encrypt for password session */\n\t    if (sessionAttributes[i] & TPMA_SESSION_ENCRYPT) {\n\t\t(*isEncrypt)++;\t\t/* count number of encrypt sessions */\n\t\t*encryptSession = i;\t/* record which one it was */\n\t    }\n\t}\n    }\n    /* how many encrypt sessions were found */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Sessions_GetEncryptSession: Found %u encrypt sessions at %u\\n\",\n\t\t\t\t*isEncrypt, *encryptSession);\n\tif (*isEncrypt > 1) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_Sessions_GetEncryptSession: Error, found %u encrypt sessions\\n\",\n\t\t       *isEncrypt);\n\t    rc = TSS_RC_ENCRYPT_SESSIONS;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Command_Decrypt() determines whether any sessions are command decrypt sessions.  If so, it\n   encrypts the first command parameter.\n\n   It does common error checking, then calls algorithm specific functions.\n\n*/\n\nstatic TPM_RC TSS_Command_Decrypt(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t  struct TSS_HMAC_CONTEXT *session[],\n\t\t\t\t  TPMI_SH_AUTH_SESSION sessionHandle[],\n\t\t\t\t  unsigned int\tsessionAttributes[])\n{\n    TPM_RC\t\trc = 0;\n    unsigned int \tisDecrypt = 0;\t\t/* count number of sessions with decrypt set */\n    unsigned int\tdecryptSession = 0;\t/* which session is decrypt */\n\n    /* determine if there is a decrypt session */\n    if (rc == 0) {\n\trc = TSS_Sessions_GetDecryptSession(&isDecrypt,\n\t\t\t\t\t    &decryptSession,\n\t\t\t\t\t    sessionHandle,\n\t\t\t\t\t    sessionAttributes);\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    {\n\tCOMMAND_INDEX   tpmCommandIndex;\t/* index into TPM table */\n\tTPM_CC \t\tcommandCode;\n\tint\t\tdecryptSize;\t\t/* size of TPM2B size, 2 if there is a TPM2B, 0 if\n\t\t\t\t\t\t   not */\n\tuint32_t \tparamSize;\t\t/* size of the parameter to encrypt */\t\n\tuint8_t \t*decryptParamBuffer;\n\t/* can the command parameter be encrypted */\n\tif ((rc == 0) && isDecrypt) {\n\t    /* get the commandCode, stored in TSS during marshal */\n\t    commandCode  = TSS_GetCommandCode(tssAuthContext);\n\t    /* get the index into the TPM command attributes table */\n\t    tpmCommandIndex = CommandCodeToCommandIndex(commandCode);\n\t    /* can this be a decrypt command (this is size of TPM2B size, not size of parameter) */\n\t    decryptSize = getDecryptSize(tpmCommandIndex);\n\t    if (decryptSize != 2) {\t\t/* only handle TPM2B */\n\t\tprintf(\"TSS_Command_Decrypt: Error, command cannot be encrypted\\n\");\n\t\trc = TSS_RC_NO_DECRYPT_PARAMETER;\n\t    }\n\t}\n\t/* get the TPM2B parameter to encrypt */\n\tif ((rc == 0) && isDecrypt) {\n\t    rc = TSS_GetCommandDecryptParam(tssAuthContext, &paramSize, &decryptParamBuffer);\n\t}\n\t/* if the size of the parameter to encrypt is zero, nothing to encrypt */\n\tif ((rc == 0) && isDecrypt) {\n\t    if (paramSize == 0) {\n\t\tisDecrypt = FALSE;\t/* none, done with this function */\n\t    }\n\t}\n\t/* error checking complete, do the encryption */\n\tif ((rc == 0) && isDecrypt) {\n\t    switch (session[decryptSession]->symmetric.algorithm) {\n\t      case TPM_ALG_XOR:\n\t\trc = TSS_Command_DecryptXor(tssAuthContext, session[decryptSession]);\n\t\tbreak;\n\t      case TPM_ALG_AES:\n\t\trc = TSS_Command_DecryptAes(tssAuthContext, session[decryptSession]);\n\t\tbreak;\n\t      default:\n\t\tif (tssVerbose) printf(\"TSS_Command_Decrypt: Error, algorithm %04x not implemented\\n\",\n\t\t\t\t       session[decryptSession]->symmetric.algorithm);\n\t\trc = TSS_RC_BAD_DECRYPT_ALGORITHM;\n\t\tbreak;\n\t    }\n\t}\n    }\n#else\n    tssAuthContext = tssAuthContext;\n    session = session;\n    if ((rc == 0) && isDecrypt) {\n\tif (tssVerbose)\n\t    printf(\"TSS_Command_Decrypt: Error, with no crypto not implemented\\n\");\n\trc = TSS_RC_NOT_IMPLEMENTED;\n    }\n#endif\n    return rc;\n}\n\n#ifndef TPM_TSS_NOCRYPTO\n\n/* NOTE: if AES also works, do in place encryption */\n\nstatic TPM_RC TSS_Command_DecryptXor(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t     struct TSS_HMAC_CONTEXT *session)\n{\n    TPM_RC\t\trc = 0;\n    unsigned int\ti;\n    uint32_t \t\tparamSize;\n    uint8_t \t\t*decryptParamBuffer;\n    uint8_t \t\t*mask = NULL;\n    uint8_t \t\t*encryptParamBuffer = NULL;\n\n    /* get the TPM2B parameter to encrypt */\n    if (rc == 0) {\n\trc = TSS_GetCommandDecryptParam(tssAuthContext, &paramSize, &decryptParamBuffer);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptXor: decrypt in\",\n\t\t\t\t      decryptParamBuffer, paramSize);\n    }    \n    if (rc == 0) {\n\trc = TSS_Malloc(&mask, paramSize);\n    }\n    if (rc == 0) {\n\trc = TSS_Malloc(&encryptParamBuffer, paramSize);\n    }\n    /* generate the XOR pad */\n    /* 21.2\tXOR Parameter Obfuscation\n\n       XOR(parameter, hashAlg, sessionValue, nonceNewer, nonceOlder)\n\n       parameter\ta variable sized buffer containing the parameter to be obfuscated\n       hashAlg\t\tthe hash algorithm associated with the session\n       sessionValue\tthe session-specific HMAC key\n       nonceNewer\tfor commands, this will be nonceCaller and for responses it will be nonceTPM\n       nonceOlder\tfor commands, this will be nonceTPM and for responses it will be nonceCaller\n\n       11.4.6.3\tXOR Obfuscation\n\n       XOR(data, hashAlg, key, contextU, contextV)\n       \n       mask = KDFa (hashAlg, key, \"XOR\", contextU, contextV, data.size * 8)\n    */\n    /* KDFa for the XOR mask */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Command_DecryptXor: hashAlg %04x\\n\", session->authHashAlg);\n\tif (tssVverbose) printf(\"TSS_Command_DecryptXor: sizeInBits %04x\\n\", paramSize * 8);\n\tif (tssVverbose)\n\t    TSS_PrintAll(\"TSS_Command_DecryptXor: sessionKey\",\n\t\t\t session->sessionKey.b.buffer, session->sessionKey.b.size);\n\tif (tssVverbose)\n\t    TSS_PrintAll(\"TSS_Command_DecryptXor: sessionValue\",\n\t\t\t session->sessionValue.b.buffer, session->sessionValue.b.size);\n\trc = TSS_KDFA(mask,\n\t\t      session->authHashAlg,\n\t\t      &session->sessionValue.b,\n\t\t      \"XOR\",\n\t\t      &session->nonceCaller.b,\n\t\t      &session->nonceTPM.b,\n\t\t      paramSize * 8);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptXor: mask\",\n\t\t\t\t      mask, paramSize);\n    }\n    /* XOR */\n    for (i = 0 ; (rc == 0) && (i < paramSize ) ; i++)  {\n\tencryptParamBuffer[i] = decryptParamBuffer[i] ^ mask[i];\n    }\n    if (rc == 0) {\n\trc = TSS_SetCommandDecryptParam(tssAuthContext, paramSize, encryptParamBuffer);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptXor: encrypt out\",\n\t\t\t\t      encryptParamBuffer, paramSize);\n    }\n    free(mask);\n    free(encryptParamBuffer);\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOCRYPTO */\n\n#ifndef TPM_TSS_NOCRYPTO\n\n/* NOTE: if AES also works, do in place encryption */\n\nstatic TPM_RC TSS_Command_DecryptAes(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t     struct TSS_HMAC_CONTEXT *session)\n{\n    TPM_RC\t\trc = 0;\n    uint32_t \t\tparamSize;\n    uint8_t \t\t*decryptParamBuffer;\n    uint8_t \t\t*encryptParamBuffer = NULL;\n    TPM2B_IV\t\tiv;\n    uint32_t           \tkdfaBits;\n    uint16_t\t\tkeySizeinBytes;\n    uint8_t\t\tsymParmString[MAX_SYM_KEY_BYTES + MAX_SYM_BLOCK_SIZE];\t/* AES key + IV */\n    \n    /* get the TPM2B parameter to encrypt */\n    if (rc == 0) {\n\trc = TSS_GetCommandDecryptParam(tssAuthContext, &paramSize, &decryptParamBuffer);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptAes: decrypt in\",\n\t\t\t\t      decryptParamBuffer, paramSize);\n    }    \n    if (rc == 0) {\n\trc = TSS_Malloc(&encryptParamBuffer, paramSize);\t/* free @1 */\n    }\n    /* generate the encryption key and IV */\n    /* 21.3\tCFB Mode Parameter Encryption\n\n       KDFa (hashAlg, sessionValue, \"CFB\", nonceNewer, nonceOlder, bits)\t(34)\n\n       hashAlg\t\tthe hash algorithm associated with the session\n       sessionValue\tthe session-specific HMAC key\n       \"CFB\"\t\tlabel to differentiate use of KDFa() (see 4.2)\n       nonceNewer\tnonceCaller for a command and nonceTPM for a response\n       nonceOlder\tnonceTPM for a command and nonceCaller for a response\n       bits\t\tthe number of bits required for the symmetric key plus an IV\n    */\n    if (rc == 0) {\n\tiv.t.size = TSS_Sym_GetBlockSize(session->symmetric.algorithm,\n\t\t\t\t\t session->symmetric.keyBits.aes);\n\t/* generate random values for both the AES key and the IV */\n\tkdfaBits = session->symmetric.keyBits.aes + (iv.t.size * 8);\n\n\tif (tssVverbose) printf(\"TSS_Command_DecryptAes: hashAlg %04x\\n\",\n\t\t\t\tsession->authHashAlg);\n\tif (tssVverbose) printf(\"TSS_Command_DecryptAes: AES key bits %u\\n\",\n\t\t\t\tsession->symmetric.keyBits.aes);\n\tif (tssVverbose) printf(\"TSS_Command_DecryptAes: kdfaBits %04x\\n\",\n\t\t\t\tkdfaBits);\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptAes: session key\",\n\t\t\t\t      session->sessionKey.b.buffer, session->sessionKey.b.size);\n\n\trc = TSS_KDFA(&symParmString[0],\n\t\t      session->authHashAlg,\n\t\t      &session->sessionValue.b,\n\t\t      \"CFB\",\n\t\t      &session->nonceCaller.b,\n\t\t      &session->nonceTPM.b,\n\t\t      kdfaBits);\n    }\n    /* copy the latter part of the kdf output to the IV */\n    if (rc == 0) {\n\tkeySizeinBytes = session->symmetric.keyBits.aes / 8;\n\tmemcpy(iv.t.buffer, &symParmString[keySizeinBytes], iv.t.size);\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptAes: IV\",\n\t\t\t\t      iv.t.buffer, iv.t.size);\n    }\n    /* AES CFB encrypt the command */\n    if (rc == 0) {\n\tTPM_RC crc;\n\tcrc = TSS_AES_EncryptCFB(encryptParamBuffer,\t\t\t/* output */\n\t\t\t\t session->symmetric.keyBits.aes,\t/* 128 */\n\t\t\t\t symParmString,\t\t\t\t/* key */\n\t\t\t\t iv.t.buffer,\t\t\t\t/* IV */\n\t\t\t\t paramSize,\t\t\t\t/* length */\n\t\t\t\t (uint8_t *)decryptParamBuffer);\t/* input */\n\tif (crc != 0) {\n\t    if (tssVerbose) printf(\"TSS_Command_DecryptAes: AES encrypt failed\\n\");\n\t    rc = TSS_RC_AES_ENCRYPT_FAILURE;\n\t}\n    }\t\t \n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Command_DecryptAes: encrypt out\",\n\t\t\t\t      encryptParamBuffer, paramSize);\n    }\n    if (rc == 0) {\n\trc = TSS_SetCommandDecryptParam(tssAuthContext, paramSize, encryptParamBuffer);\n    }\n    free(encryptParamBuffer);\t/* @1 */\n    return rc;\n}    \n\n#endif\t/* TPM_TSS_NOCRYPTO */\n\nstatic TPM_RC TSS_Response_Encrypt(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t   struct TSS_HMAC_CONTEXT *session[],\n\t\t\t\t   TPMI_SH_AUTH_SESSION sessionHandle[],\n\t\t\t\t   unsigned int sessionAttributes[])\n{\n    TPM_RC\t\trc = 0;\n    unsigned int \tisEncrypt = 0;\t\t/* count number of sessions with decrypt set */\n    unsigned int\tencryptSession = 0;\t/* which one is decrypt */\n    \n    /* determine if there is an encrypt session */\n    if (rc == 0) {\n\trc = TSS_Sessions_GetEncryptSession(&isEncrypt,\n\t\t\t\t\t    &encryptSession,\n\t\t\t\t\t    sessionHandle,\n\t\t\t\t\t    sessionAttributes);\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    {\n\tCOMMAND_INDEX   tpmCommandIndex;\t/* index into TPM table */\n\tTPM_CC \t\tcommandCode;\n\tint\t\tencryptSize;\t\t/* size of TPM2B size, 2 if there is a TPM2B, 0 if\n\t\t\t\t\t\t   not */\n\tuint32_t \tparamSize;\t\t/* size of the parameter to decrypt */\t\n\tuint8_t \t*encryptParamBuffer;\n\t/* can the response parameter be decrypted */\n\tif ((rc == 0) && isEncrypt) {\n\t    /* get the commandCode, stored in TSS during marshal */\n\t    commandCode  = TSS_GetCommandCode(tssAuthContext);\n\t    /* get the index into the TPM command attributes table */\n\t    tpmCommandIndex = CommandCodeToCommandIndex(commandCode);\n\t    /* can this be a decrypt command */\n\t    encryptSize = getEncryptSize(tpmCommandIndex);\n\t    if (encryptSize == 0) {\n\t\tif (tssVerbose) printf(\"TSS_Response_Encrypt: \"\n\t\t\t\t       \"Error, response cannot be encrypted\\n\");\n\t\trc = TSS_RC_NO_ENCRYPT_PARAMETER;\n\t    }\n\t}\n\t/* get the TPM2B parameter to decrypt */\n\tif ((rc == 0) && isEncrypt) {\n\t    rc = TSS_GetResponseEncryptParam(tssAuthContext, &paramSize, &encryptParamBuffer);\n\t}\n\t/* if the size of the parameter to decrypt is zero, nothing to decrypt */\n\tif ((rc == 0) && isEncrypt) {\n\t    if (paramSize == 0) {\n\t\tisEncrypt = FALSE;\t/* none, done with this function */\n\t    }\n\t}\n\t/* error checking complete, do the decryption */\n\tif ((rc == 0) && isEncrypt) {\n\t    switch (session[encryptSession]->symmetric.algorithm) {\n\t      case TPM_ALG_XOR:\n\t\trc = TSS_Response_EncryptXor(tssAuthContext, session[encryptSession]);\n\t\tbreak;\n\t      case TPM_ALG_AES:\n\t\trc = TSS_Response_EncryptAes(tssAuthContext, session[encryptSession]);\n\t\tbreak;\n\t      default:\n\t\tif (tssVerbose) printf(\"TSS_Response_Encrypt: \"\n\t\t\t\t       \"Error, algorithm %04x not implemented\\n\",\n\t\t\t\t       session[encryptSession]->symmetric.algorithm);\n\t\trc = TSS_RC_BAD_ENCRYPT_ALGORITHM;\n\t\tbreak;\n\t    }\n\t}\n    }\n#else\n    tssAuthContext = tssAuthContext;\n    session = session;\n    if ((rc == 0) && isEncrypt) {\n\tif (tssVerbose)\n\t    printf(\"TSS_Response_Encrypt: Error, with no crypto not implemented\\n\");\n\trc = TSS_RC_NOT_IMPLEMENTED;\n    }\n#endif\n    return rc;\n}\n\n#ifndef TPM_TSS_NOCRYPTO\n\n/* NOTE: if CFB also works, do in place decryption */\n\nstatic TPM_RC TSS_Response_EncryptXor(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t      struct TSS_HMAC_CONTEXT *session)\n{\n    TPM_RC\t\trc = 0;\n    unsigned int\ti;\n    uint32_t \t\tparamSize;\n    uint8_t \t\t*encryptParamBuffer;\n    uint8_t \t\t*mask = NULL;\n    uint8_t \t\t*decryptParamBuffer = NULL;\n\n    /* get the TPM2B parameter to decrypt */\n    if (rc == 0) {\n\trc = TSS_GetResponseEncryptParam(tssAuthContext,\n\t\t\t\t\t &paramSize, &encryptParamBuffer);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Response_EncryptXor: encrypt in\",\n\t\t\t\t      encryptParamBuffer, paramSize);\n    }    \n    if (rc == 0) {\n\trc = TSS_Malloc(&mask, paramSize);\t\t\t/* freed @1 */\n    }\n    if (rc == 0) {\n\trc = TSS_Malloc(&decryptParamBuffer, paramSize);\t/* freed @2 */\n    }\n    /* generate the XOR pad */\n    /* 21.2\tXOR Parameter Obfuscation\n\n       XOR(parameter, hashAlg, sessionValue, nonceNewer, nonceOlder)\n\n       parameter\ta variable sized buffer containing the parameter to be obfuscated\n       hashAlg\t\tthe hash algorithm associated with the session\n       sessionValue\tthe session-specific HMAC key\n       nonceNewer\tfor commands, this will be nonceCaller and for responses it will be nonceTPM\n       nonceOlder\tfor commands, this will be nonceTPM and for responses it will be nonceCaller\n\n       \n       11.4.6.3\tXOR Obfuscation\n\n       XOR(data, hashAlg, key, contextU, contextV)\n       \n       mask = KDFa (hashAlg, key, \"XOR\", contextU, contextV, data.size * 8)\n    */\n    /* KDFa for the XOR mask */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Response_EncryptXor: hashAlg %04x\\n\", session->authHashAlg);\n\tif (tssVverbose) printf(\"TSS_Response_EncryptXor: sizeInBits %04x\\n\", paramSize * 8);\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Response_EncryptXor: session key\",\n\t\t\t\t      session->sessionKey.b.buffer, session->sessionKey.b.size);\n\trc = TSS_KDFA(mask,\n\t\t      session->authHashAlg,\n\t\t      &session->sessionValue.b,\n\t\t      \"XOR\",\n\t\t      &session->nonceTPM.b,\n\t\t      &session->nonceCaller.b,\n\t\t      paramSize * 8);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Response_EncryptXor: mask\",\n\t\t\t\t      mask, paramSize);\n    }\n    /* XOR */\n    for (i = 0 ; (rc == 0) && (i < paramSize ) ; i++)  {\n\tdecryptParamBuffer[i] = encryptParamBuffer[i] ^ mask[i];\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Response_EncryptXor: decrypt out\",\n\t\t\t\t      decryptParamBuffer, paramSize);\n    }\n    if (rc == 0) {\n\trc = TSS_SetResponseDecryptParam(tssAuthContext,\n\t\t\t\t\t paramSize, decryptParamBuffer);\n    }\n    free(mask);\t\t\t/* @1 */\n    free(decryptParamBuffer);\t/* @2 */\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOCRYPTO */\n\n#ifndef TPM_TSS_NOCRYPTO\n\n/* NOTE: if CFB also works, do in place decryption */\n\nstatic TPM_RC TSS_Response_EncryptAes(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t      struct TSS_HMAC_CONTEXT *session)\n{\n    TPM_RC\t\trc = 0;\n    uint32_t \t\tparamSize;\n    uint8_t \t\t*encryptParamBuffer;\n    uint8_t \t\t*decryptParamBuffer = NULL;\n    TPM2B_IV\t\tiv;\n    uint32_t           \tkdfaBits;\n    uint16_t\t\tkeySizeinBytes;\n    uint8_t\t\tsymParmString[MAX_SYM_KEY_BYTES + MAX_SYM_BLOCK_SIZE];\t/* AES key + IV */\n\n    /* get the TPM2B parameter to decrypt */\n    if (rc == 0) {\n\trc = TSS_GetResponseEncryptParam(tssAuthContext,\n\t\t\t\t\t &paramSize, &encryptParamBuffer);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Response_EncryptAes: encrypt in\",\n\t\t\t\t      encryptParamBuffer, paramSize);\n    }    \n    if (rc == 0) {\n\trc = TSS_Malloc(&decryptParamBuffer, paramSize);\t/* freed @1 */\n    }\n    /* generate the encryption key and IV */\n    /* 21.3\tCFB Mode Parameter Encryption\n\n       KDFa (hashAlg, sessionValue, \"CFB\", nonceNewer, nonceOlder, bits)\t(34)\n    */\n    if (rc == 0) {\n\t\n\tiv.t.size = TSS_Sym_GetBlockSize(session->symmetric.algorithm,\n\t\t\t\t\t session->symmetric.keyBits.aes);\n\t/* generate random values for both the AES key and the IV */\n\tkdfaBits = session->symmetric.keyBits.aes + (iv.t.size * 8);\n\n\tif (tssVverbose) printf(\"TSS_Response_EncryptAes: hashAlg %04x\\n\",\n\t\t\t\tsession->authHashAlg);\n\tif (tssVverbose) printf(\"TSS_Response_EncryptAes: AES key bits %u\\n\",\n\t\t\t\tsession->symmetric.keyBits.aes);\n\tif (tssVverbose) printf(\"TSS_Response_EncryptAes: kdfaBits %04x\\n\",\n\t\t\t\tkdfaBits);\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Response_EncryptAes: session key\",\n\t\t\t\t      session->sessionKey.b.buffer, session->sessionKey.b.size);\n\t\n\trc = TSS_KDFA(&symParmString[0],\n\t\t      session->authHashAlg,\n\t\t      &session->sessionValue.b,\n\t\t      \"CFB\",\n\t\t      &session->nonceTPM.b,\n\t\t      &session->nonceCaller.b,\n\t\t      kdfaBits);\n    }\n    /* copy the latter part of the kdf output to the IV */\n    if (rc == 0) {\n\tkeySizeinBytes = session->symmetric.keyBits.aes / 8;\n\tmemcpy(iv.t.buffer, &symParmString[keySizeinBytes], iv.t.size);\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Response_EncryptAes: IV\",\n\t\t\t\t      iv.t.buffer, iv.t.size);\n    }\n    /* AES CFB decrypt the response */\n    if (rc == 0) {\n\tTPM_RC crc;\n\tcrc = TSS_AES_DecryptCFB(decryptParamBuffer,\t\t\t/* output */\n\t\t\t\t session->symmetric.keyBits.aes,\t/* 128 */\n\t\t\t\t symParmString,\t\t\t\t/* key */\n\t\t\t\t iv.t.buffer,\t\t\t\t/* IV */\n\t\t\t\t paramSize,\t\t\t\t/* length */\n\t\t\t\t (uint8_t *)encryptParamBuffer);\t/* input */\n\tif (crc != 0) {\n\t    if (tssVerbose) printf(\"TSS_Response_EncryptAes: AES decrypt failed\\n\");\n\t    rc = TSS_RC_AES_DECRYPT_FAILURE;\n\t}\n    }\t\t \n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Response_EncryptAes: decrypt out\",\n\t\t\t\t      decryptParamBuffer, paramSize);\n    }\n    if (rc == 0) {\n\trc = TSS_SetResponseDecryptParam(tssAuthContext,\n\t\t\t\t\t paramSize, decryptParamBuffer);\n    }\n    free(decryptParamBuffer);\t/* @1 */\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOCRYPTO */\n\n/*\n  Command Change Authorization Processor\n*/\n\n#ifndef TPM_TSS_NOCRYPTO\n\nstatic TPM_RC TSS_Command_ChangeAuthProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t\t      struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t      size_t handleNumber,\n\t\t\t\t\t      COMMAND_PARAMETERS *in)\n{\n    TPM_RC \t\t\trc = 0;\n    size_t \t\t\tindex;\n    int \t\t\tfound;\n    TSS_ChangeAuthFunction_t \tchangeAuthFunction = NULL;\n\n    TPM_CC commandCode = TSS_GetCommandCode(tssContext->tssAuthContext);\n\n    /* search the table for a change authorization processing function */\n    if (rc == 0) {\n\tfound = FALSE;\n\tfor (index = 0 ; (index < (sizeof(tssTable) / sizeof(TSS_TABLE))) && !found ; index++) {\n\t    if (tssTable[index].commandCode == commandCode) {\n\t\tfound = TRUE;\n\t\tbreak;\t/* don't increment index if found */\n\t    }\n\t}\n    }\n    /* found false means there is no change authorization function.  This permits the table to be\n       smaller if desired. */\n    if ((rc == 0) && found) {\n\tchangeAuthFunction = tssTable[index].changeAuthFunction;\n\t/* there could also be an entry that is currently NULL, nothing to do */\n\tif (changeAuthFunction == NULL) {\n\t    found = FALSE;\n\t}\n    }\n    /* call the processing function */\n    if ((rc == 0) && found) {\n\trc = changeAuthFunction(tssContext, session, handleNumber, in);\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOCRYPTO */\n\nstatic TPM_RC TSS_CA_HierarchyChangeAuth(TSS_CONTEXT *tssContext,\n\t\t\t\t\t struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t size_t handleNumber,\n\t\t\t\t\t HierarchyChangeAuth_In *in)\n{\n    TPM_RC \t\trc = 0;\n    char\t\t*password = NULL;\n    \n    if (tssVverbose) printf(\"TSS_CA_HierarchyChangeAuth\\n\");\n    if (in->newAuth.t.size == 0) {\n\tpassword = NULL;\n    }\n    else {\n\tif (rc == 0) {\n\t    rc = TSS_Malloc((uint8_t **)&password,\t/* freed @1 */\n\t\t\t    in->newAuth.t.size + 1);\n\t}\n\tif (rc == 0) {\n\t    /* copy the password */\n\t    memcpy(password, in->newAuth.t.buffer, in->newAuth.t.size);\n\t    password[in->newAuth.t.size] = '\\0';\t/* nul terminate string */\n\t}\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    if (rc == 0) {\n\trc = TSS_HmacSession_SetHmacKey(tssContext,\n\t\t\t\t\tsession,\n\t\t\t\t\thandleNumber,\n\t\t\t\t\tpassword);\n    }\n#else\n    tssContext = tssContext;\n    session = session;\n    handleNumber = handleNumber;\n#endif\t/* TPM_TSS_NOCRYPTO */\n    free(password);\t/* @1 */\n    return rc;\n}\n\nstatic TPM_RC TSS_CA_NV_ChangeAuth(TSS_CONTEXT *tssContext,\n\t\t\t\t   struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t   size_t handleNumber,\n\t\t\t\t   NV_ChangeAuth_In *in)\n{\n    TPM_RC \t\trc = 0;\n    char\t\t*password = NULL;\n\n    if (tssVverbose) printf(\"TSS_CA_NV_ChangeAuth\\n\");\n    if (in->newAuth.t.size == 0) {\n\tpassword = NULL;\n    }\n    else {\n\tif (rc == 0) {\n\t    rc = TSS_Malloc((uint8_t **)&password,\t/* freed @1 */\n\t\t\t    in->newAuth.t.size + 1);\n\t}\n\tif (rc == 0) {\n\t    /* copy the password */\n\t    memcpy(password, in->newAuth.t.buffer, in->newAuth.t.size);\n\t    password[in->newAuth.t.size] = '\\0';\t/* nul terminate string */\n\t}\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    if (rc == 0) {\n\trc = TSS_HmacSession_SetHmacKey(tssContext,\n\t\t\t\t\tsession,\n\t\t\t\t\thandleNumber,\n\t\t\t\t\tpassword);\n    }\n#else\n    tssContext = tssContext;\n    session = session;\n    handleNumber = handleNumber;\n#endif\t/* TPM_TSS_NOCRYPTO */\n    free(password);\t/* @1 */\n    return rc;\n}\n\nstatic TPM_RC TSS_CA_NV_UndefineSpaceSpecial(TSS_CONTEXT *tssContext,\n\t\t\t\t\t     struct TSS_HMAC_CONTEXT *session,\n\t\t\t\t\t     size_t handleNumber,\n\t\t\t\t\t     NV_UndefineSpaceSpecial_In *in)\n{\n    TPM_RC \t\trc = 0;\n    \n    in = in;\n    if (tssVverbose) printf(\"TSS_CA_NV_UndefineSpaceSpecial\\n\");\n#ifndef TPM_TSS_NOCRYPTO\n    if (rc == 0) {\n\t/* the nvIndex authorization, the zeroth authorization, has special handling */\n\tif (handleNumber == 0) {\n\t    /* the Empty Buffer is used as the authValue when generating the response HMAC */\n\t    rc = TSS_HmacSession_SetHmacKey(tssContext,\n\t\t\t\t\t    session,\n\t\t\t\t\t    handleNumber,\n\t\t\t\t\t    NULL);\t\t/* password */\n\t}\n    }\n#else\n    tssContext = tssContext;\n    session = session;\n    handleNumber = handleNumber;\n#endif\t/* TPM_TSS_NOCRYPTO */\n    return rc;\n}\n\n#ifdef TPM_TSS_NODEPRECATEDALGS\nstatic TPM_RC TSS_Command_CheckParameters(TPM_CC commandCode,\n\t\t\t\t\t  COMMAND_PARAMETERS *in)\n{\n    TPM_RC \t\t\t\trc = 0;\n    size_t \t\t\t\tindex;\n    int \t\t\t\tfound;\n    TSS_CheckParametersFunction_t\tcheckParametersFunction = NULL;\n\n    /* search the table for a check parameters function */\n    if (rc == 0) {\n\tfound = FALSE;\n\tfor (index = 0 ; (index < (sizeof(tssChTable) / sizeof(TSS_CH_TABLE))) && !found ; index++) {\n\t    if (tssChTable[index].commandCode == commandCode) {\n\t\tfound = TRUE;\n\t\tbreak;\t/* don't increment index if found */\n\t    }\n\t}\n    }\n    /* found false means there is no check parameters function.  This permits the table to be smaller\n       if desired. */\n    if ((rc == 0) && found) {\n\tcheckParametersFunction = tssChTable[index].checkParametersFunction;\n\t/* call the check parameters function if there is one */\n\tif (checkParametersFunction != NULL) {\n\t    rc = checkParametersFunction(in);\n\t}\n    }\n    return rc;\n}\n#endif\n\n/*\n  Command Pre-Processor\n*/\n\nstatic TPM_RC TSS_Command_PreProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t       TPM_CC commandCode,\n\t\t\t\t       COMMAND_PARAMETERS *in,\n\t\t\t\t       EXTRA_PARAMETERS *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    size_t \t\t\tindex;\n    int \t\t\tfound;\n    TSS_PreProcessFunction_t \tpreProcessFunction = NULL;\n    \n    /* search the table for a pre-processing function */\n    if (rc == 0) {\n\tfound = FALSE;\n\tfor (index = 0 ; (index < (sizeof(tssTable) / sizeof(TSS_TABLE))) && !found ; index++) {\n\t    if (tssTable[index].commandCode == commandCode) {\n\t\tfound = TRUE;\n\t\tbreak;\t/* don't increment index if found */\n\t    }\n\t}\n    }\n    /* found false means there is no pre-processing function.  This permits the table to be smaller\n       if desired. */\n    if ((rc == 0) && found) {\n\tpreProcessFunction = tssTable[index].preProcessFunction;\n\t/* call the pre processing function if there is one */\n\tif (preProcessFunction != NULL) {\n\t    rc = preProcessFunction(tssContext, in, extra);\n\t}\n    }\n#ifndef TPM_TSS_NO_PRINT\n    if ((rc == 0) && tssVverbose) {\n\tfound = FALSE;\n\tfor (index = 0 ;\n\t     (index < (sizeof(tssPrintTable) / sizeof(TSS_PRINT_TABLE))) && !found ;\n\t     index++) {\n\t    if (tssPrintTable[index].commandCode == commandCode) {\n\t\tfound = TRUE;\n\t\tbreak;\t/* don't increment index if found */\n\t    }\n\t}\n    }\n    /* found false means there is no print function.  This permits the table to be smaller\n       if desired. */\n    if ((rc == 0) && tssVverbose && found) {\n\tTSS_InPrintFunction_t inPrintFunction = tssPrintTable[index].inPrintFunction;\n\t/* call the pre processing function if there is one */\n\tif (inPrintFunction != NULL) {\n\t    printf(\"TSS_Command_PreProcessor: Input parameters\\n\");\n\t    inPrintFunction(in, 8);\t/* hard code indent 8 */\n\t}\n    }\n#endif /* TPM_TSS_NO_PRINT */\n    return rc;\n}\n\n/*\n  Command specific pre processing functions\n*/\n\n/* TSS_PR_StartAuthSession handles StartAuthSession pre processing.\n\n   If the salt key in->tpmKey is not NULL and an RSA key, the preprocessor supplies the encrypted\n   salt.  It passes the unencrypted salt to the post processor for session key processing.\n\n   An input salt (encrypted or unencrypted) is ignored.\n\n   Returns an error if the key is not an RSA key.\n*/\n\nstatic TPM_RC TSS_PR_StartAuthSession(TSS_CONTEXT *tssContext,\n\t\t\t\t      StartAuthSession_In *in,\n\t\t\t\t      StartAuthSession_Extra *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    \n    if (tssVverbose) printf(\"TSS_PR_StartAuthSession\\n\");\n\n    /* if (tssVverbose) StartAuthSession_In_Print(in, 8); */\n    \n#ifndef TPM_TSS_NOCRYPTO\n    /* generate nonceCaller */\n    if (rc == 0) {\n\t/* the size is determined by the session hash algorithm */\n\tin->nonceCaller.t.size = TSS_GetDigestSize(in->authHash);\n\tif (in->nonceCaller.t.size == 0) {\n\t    if (tssVerbose) printf(\"TSS_PR_StartAuthSession: hash algorithm %04x not implemented\\n\",\n\t\t\t\t   in->authHash);\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_RandBytes((unsigned char *)&in->nonceCaller.t.buffer, in->nonceCaller.t.size);\n    }\n#else\n    in->nonceCaller.t.size = 16;\n    memset(&in->nonceCaller.t.buffer, 0, 16);\n#endif\t/* TPM_TSS_NOCRYPTO */\n\t/* initialize to handle unsalted session */\n    in->encryptedSalt.t.size = 0;\n    if (extra != NULL) {\t\t/* extra NULL is handled at the port processor */\n\textra->salt.t.size = 0;\n    }\n    /* if the caller requests a salted session */\n    if (in->tpmKey != TPM_RH_NULL) {\n#ifndef TPM_TSS_NOCRYPTO\n\tTPM2B_PUBLIC\t\tbPublic;\n\t\n\tif (rc == 0) {\n\t    if (extra == NULL) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_PR_StartAuthSession: salt session requires extra parameter\\n\");\n\t\trc = TSS_RC_NULL_PARAMETER;\n\t    }\n\t}\n\t/* get the tpmKey public key */\n\tif (rc == 0) {\n\t    rc = TSS_Public_Load(tssContext, &bPublic, in->tpmKey, NULL);\n\t}\n\t/* generate the salt and encrypted salt based on the asymmetric key type */\n\tif (rc == 0) {\n\t    switch (bPublic.publicArea.type) {\n#ifndef TPM_TSS_NOECC\n\t      case TPM_ALG_ECC:\n\t\trc = TSS_ECC_Salt(&extra->salt,\n\t\t\t\t  &in->encryptedSalt,\n\t\t\t\t  &bPublic.publicArea);\n\t\tbreak;\n#endif\t/* TPM_TSS_NOECC */\n#ifndef TPM_TSS_NORSA\n\t      case TPM_ALG_RSA:\n\t\trc = TSS_RSA_Salt(&extra->salt,\n\t\t\t\t  &in->encryptedSalt,\n\t\t\t\t  &bPublic.publicArea);\n\t\tbreak;\n#endif \t/* TPM_TSS_NORSA */\n\t      default:\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_PR_StartAuthSession: public key type %04x not supported\\n\",\n\t\t\t   bPublic.publicArea.type);\n\t\trc = TSS_RC_BAD_SALT_KEY;\n\t    }\n\t}\n#else\n\ttssContext = tssContext;\n\trc = TSS_RC_NOT_IMPLEMENTED;\n#endif\t/* TPM_TSS_NOCRYPTO */\n    }\n    return rc;\n}\n\n#ifndef TPM_TSS_NOCRYPTO\n#ifndef TPM_TSS_NORSA\n\n/* TSS_RSA_Salt() returns both the plaintext and excrypted salt, based on the salt key bPublic. */\n\nstatic TPM_RC TSS_RSA_Salt(TPM2B_DIGEST \t\t*salt,\n\t\t\t   TPM2B_ENCRYPTED_SECRET\t*encryptedSalt,\n\t\t\t   TPMT_PUBLIC\t\t\t*publicArea)\n{\n    TPM_RC\t\trc = 0;\n\n    if (rc == 0) {\n\t{\n\t    /* error conditions when true */\n\t    int b1 = publicArea->type != TPM_ALG_RSA;\n\t    int b2 = publicArea->objectAttributes.val & TPMA_OBJECT_SIGN;\n\t    int b3 = !(publicArea->objectAttributes.val & TPMA_OBJECT_DECRYPT);\n\t    int b4 = (publicArea->parameters.rsaDetail.exponent != 0) &&\n\t\t     /* some HW TPMs return 010001 for the RSA EK with the default IWG template */\n\t\t     (publicArea->parameters.rsaDetail.exponent != RSA_DEFAULT_PUBLIC_EXPONENT);\n\t    /* TSS support checks */\n\t    if (b1 || b2 || b3 || b4) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_RSA_Salt: public key attributes not supported\\n\");\n\t\trc = TSS_RC_BAD_SALT_KEY;\n\t    }\n\t}\n    }    \n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_RSA_Salt: public key\",\n\t\t\t\t      publicArea->unique.rsa.t.buffer,\n\t\t\t\t      publicArea->unique.rsa.t.size);\n    }\n    /* generate a salt */\n    if (rc == 0) {\n\t/* The size of the secret value is limited to the size of the digest produced by the\n\t   nameAlg of the object that is associated with the public key used for OAEP\n\t   encryption. */\n\tsalt->t.size = TSS_GetDigestSize(publicArea->nameAlg);\n\tif (tssVverbose) printf(\"TSS_RSA_Salt: \"\n\t\t\t\t\"Hash algorithm %04x Salt size %u\\n\",\n\t\t\t\tpublicArea->nameAlg, salt->t.size);\n\t/* place the salt in extra so that it can be retrieved by post processor */\n\trc = TSS_RandBytes((uint8_t *)&salt->t.buffer, salt->t.size);\n    }\n    /* In TPM2_StartAuthSession(), when tpmKey is an RSA key, the secret value (salt) is\n       encrypted using OAEP as described in B.4. The string \"SECRET\" (see 4.5) is used as\n       the L value and the nameAlg of the encrypting key is used for the hash algorithm. The\n       data value in OAEP-encrypted blob (salt) is used to compute sessionKey. */\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_RSA_Salt: salt\",\n\t\t\t\t      (uint8_t *)&salt->t.buffer,\n\t\t\t\t      salt->t.size);\n    }\n    /* encrypt the salt */\n    if (rc == 0) {\n\t/* public exponent */\n\tunsigned char earr[3] = {0x01, 0x00, 0x01};\n\t/* encrypt the salt with the tpmKey public key */\n\trc = TSS_RSAPublicEncrypt((uint8_t *)&encryptedSalt->t.secret,   /* encrypted data */\n\t\t\t\t  publicArea->unique.rsa.t.size,  /* size of encrypted data buffer */\n\t\t\t\t  (uint8_t *)&salt->t.buffer, /* decrypted data */\n\t\t\t\t  salt->t.size,\n\t\t\t\t  publicArea->unique.rsa.t.buffer,  /* public modulus */\n\t\t\t\t  publicArea->unique.rsa.t.size,\n\t\t\t\t  earr, \t\t/* public exponent */\n\t\t\t\t  sizeof(earr),\n\t\t\t\t  (unsigned char *)\"SECRET\",\t/* encoding parameter */\n\t\t\t\t  sizeof(\"SECRET\"),\n\t\t\t\t  publicArea->nameAlg);\n    }    \n    if (rc == 0) {\n\tencryptedSalt->t.size = publicArea->unique.rsa.t.size;\n\tif (tssVverbose) TSS_PrintAll(\"TSS_RSA_Salt: RSA encrypted salt\",\n\t\t\t\t      encryptedSalt->t.secret,\n\t\t\t\t      encryptedSalt->t.size);\n    }\n    return rc;\n}\n\n#endif /* TPM_TSS_NORSA */\n#endif /* TPM_TSS_NOCRYPTO */\n\nstatic TPM_RC TSS_PR_NV_DefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t\t    NV_DefineSpace_In *in,\n\t\t\t\t    void *extra)\n{\n    TPM_RC \trc = 0;\n    tssContext = tssContext;\n    extra = extra;\n\n    if (tssVverbose) printf(\"TSS_PR_NV_DefineSpace\\n\");\n    /* Test that TPMA_NVA_POLICY_DELETE is only set when a policy is also set.  Otherwise, the index\n       cannot ever be deleted, even with Platform Authorization. If the application really wants to\n       do this, set the policy to one that cannot be satisfied, e.g., all 0xff's. */\n    if (rc == 0) {\n\tif (in->publicInfo.nvPublic.attributes.val & TPMA_NVA_POLICY_DELETE) {\n\t    if (in->publicInfo.nvPublic.authPolicy.b.size == 0) {\n\t\tif (tssVverbose) printf(\"TSS_PR_NV_DefineSpace POLICY_DELETE requires a policy\\n\");\n\t\trc = TSS_RC_IN_PARAMETER;\n\t    }\n\t}\n    }\n    return rc;\n}\n\n/*\n  Response Post Processor\n*/\n\n/* TSS_Response_PostProcessor() handles any response specific post processing\n */\n\nstatic TPM_RC TSS_Response_PostProcessor(TSS_CONTEXT *tssContext,\n\t\t\t\t\t COMMAND_PARAMETERS *in,\n\t\t\t\t\t RESPONSE_PARAMETERS *out,\n\t\t\t\t\t EXTRA_PARAMETERS *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    size_t \t\t\tindex;\n    int \t\t\tfound;\n    TSS_PostProcessFunction_t \tpostProcessFunction = NULL;\n\n    /* search the table for a post processing function */\n    if (rc == 0) {\n\tTPM_CC commandCode = TSS_GetCommandCode(tssContext->tssAuthContext);\n\tfound = FALSE;\n\tfor (index = 0 ; (index < (sizeof(tssTable) / sizeof(TSS_TABLE))) && !found ; index++) {\n\t    if (tssTable[index].commandCode == commandCode) {\n\t\tfound = TRUE;\n\t\tbreak;\t/* don't increment index if found */\n\t    }\n\t}\n    }\n    /* found false means there is no post processing function.  This permits the table to be smaller\n       if desired. */\n    if ((rc == 0) && found) {\n\tpostProcessFunction = tssTable[index].postProcessFunction;\n\t/* there could also be an entry that it currently NULL, nothing to do */\n\tif (postProcessFunction == NULL) {\n\t    found = FALSE;\n\t}\n    }\n    /* call the function */\n    if ((rc == 0) && found) {\n\trc = postProcessFunction(tssContext, in, out, extra);\n    }\n    return rc;\n}\n\n/*\n  Command specific post processing functions\n*/\n\n/* TSS_PO_StartAuthSession handles StartAuthSession post processing.  It:\n\n   creates a TSS HMAC session\n\n   saves the session handle, hash algorithm, and symmetric algorithm, nonceCaller and nonceTPM\n   \n   It calculates the session key and saves it\n\n   Finally, it marshals the session and stores it\n*/\n\nstatic TPM_RC TSS_PO_StartAuthSession(TSS_CONTEXT *tssContext,\n\t\t\t\t      StartAuthSession_In *in,\n\t\t\t\t      StartAuthSession_Out *out,\n\t\t\t\t      StartAuthSession_Extra *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    struct TSS_HMAC_CONTEXT \t*session = NULL;\n    TPM2B_DIGEST \t\tsalt;\n    \n    if (tssVverbose) printf(\"TSS_PO_StartAuthSession\\n\");\n    /* allocate a TSS_HMAC_CONTEXT session context */\n    if (rc == 0) {\n\trc = TSS_HmacSession_GetContext(&session);\n    }\n    if (rc == 0) {\n\tsession->sessionHandle = out->sessionHandle;\n\tsession->authHashAlg = in->authHash;\n#ifndef TPM_TSS_NOCRYPTO\n\tsession->sizeInBytes = TSS_GetDigestSize(session->authHashAlg);\n#endif\n\tsession->symmetric = in->symmetric;\n\tsession->sessionType = in->sessionType;\n    }\n    /* if not a bind session or if no bind password was supplied */\n    if (rc == 0) {\n\tif ((extra == NULL) || (in->bind == TPM_RH_NULL) || (extra->bindPassword == NULL)) {\n\t    session->bindAuthValue.b.size = 0;\n\t}\n\telse {\n\t    rc = TSS_TPM2B_StringCopy(&session->bindAuthValue.b,\n\t\t\t\t      extra->bindPassword, sizeof(session->bindAuthValue.t.buffer));\n\t}\n    }\n    if (rc == 0) {\n\t/* if the caller did not supply extra, the salt must be empty */\n\tif (extra == NULL) {\n\t    salt.b.size = 0;\n\t}\n\t/* if the caller supplied extra, the preprocessor sets salt to empty (unsalted) or the\n\t   plaintext salt value */\n\telse {\n\t    rc = TSS_TPM2B_Copy(&salt.b, &extra->salt.b, sizeof(TPMT_HA));\n\t}\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    if (rc == 0) {\n\trc = TSS_TPM2B_Copy(&session->nonceTPM.b, &out->nonceTPM.b, sizeof(TPMT_HA));\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_Copy(&session->nonceCaller.b, &in->nonceCaller.b, sizeof(TPMT_HA));\n    }\n    if (rc == 0) {\n\trc = TSS_HmacSession_SetSessionKey(tssContext, session,\n\t\t\t\t\t   &salt,\n\t\t\t\t\t   in->bind, &session->bindAuthValue);\n    }\n#endif\t/* TPM_TSS_NOCRYPTO */\n    if (rc == 0) {\n\trc = TSS_HmacSession_SaveSession(tssContext, session);\n    }\n    TSS_HmacSession_FreeContext(session);\n    return rc;\n}\n\n/* TSS_PO_ContextSave() saves the name of an object in a filename that is a hash of the contextBlob.\n\n   This permits the name to be found during ContextLoad.\n*/\n\nstatic TPM_RC TSS_PO_ContextSave(TSS_CONTEXT *tssContext,\n\t\t\t\t ContextSave_In *in,\n\t\t\t\t ContextSave_Out *out,\n\t\t\t\t void *extra)\n{\n    TPM_RC \t\trc = 0;\n#ifndef TPM_TSS_NOFILE\n    TPMT_HA \t\tcpHash;\t\t/* largest size of a digest */\n    char\t\tstring[65];\t/*  sha256 hash * 2 + 1 */\n    TPM_HT \t\thandleType;\n    int\t\t\tdone = FALSE;\n#endif\n\n    in = in;\n    extra = extra;\n\n#ifndef TPM_TSS_NOFILE\n    if (tssVverbose) printf(\"TSS_PO_ContextSave: handle %08x\\n\", in->saveHandle);\n    /* only for objects and sequence objects, not sessions */\n    if (rc == 0) {\n\thandleType = (TPM_HT) ((in->saveHandle & HR_RANGE_MASK) >> HR_SHIFT);\n\tif (handleType != TPM_HT_TRANSIENT) {\n\t    done = TRUE;\n\t}\n    }\n    if ((rc == 0) && !done) {\n\tcpHash.hashAlg = TPM_ALG_SHA256;\t/* arbitrary choice */\n\trc = TSS_Hash_Generate(&cpHash,\n\t\t\t       out->context.contextBlob.b.size, out->context.contextBlob.b.buffer,\n\t\t\t       0, NULL);\n    }\n    /* convert a hash of the context blob to a string */\n    if ((rc == 0) && !done) {\n\trc = TSS_HashToString(string, cpHash.digest.sha256);\n    }\n    if ((rc == 0) && !done) {\n\trc = TSS_Name_Copy(tssContext,\n\t\t\t   0, string,\t\t\t/* to context */\n\t\t\t   in->saveHandle, NULL);\t/* from handle */\n    }\n    /* get the public key of the object being context saved */\n    /* save the public key under the context */\n    if ((rc == 0) && !done) {\n\trc = TSS_Public_Copy(tssContext,\n\t\t\t     0,\n\t\t\t     string,\n\t\t\t     in->saveHandle,\n\t\t\t     NULL);\n    }\n#else\n    tssContext = tssContext;\n    out = out;\n#endif\n    return rc;\n}\n\nstatic TPM_RC TSS_PO_ContextLoad(TSS_CONTEXT *tssContext,\n\t\t\t\t ContextLoad_In *in,\n\t\t\t\t ContextLoad_Out *out,\n\t\t\t\t void *extra)\n{\n    TPM_RC \t\trc = 0;\n#ifndef TPM_TSS_NOFILE\n    TPMT_HA \t\tcpHash;\t\t/* largest size of a digest */\n    char\t\tstring[65];\t/*  sha256 hash * 2 + 1 */\n    TPM_HT \t\thandleType;\n    int\t\t\tdone = FALSE;\n#endif\n\n    out = out;\n    extra = extra;\n\n#ifndef TPM_TSS_NOFILE\n    if (tssVverbose) printf(\"TSS_PO_ContextLoad: handle %08x\\n\", out->loadedHandle);\n    /* only for objects and sequence objects, not sessions */\n    if (rc == 0) {\n\thandleType = (TPM_HT) ((out->loadedHandle & HR_RANGE_MASK) >> HR_SHIFT);\n\tif (handleType != TPM_HT_TRANSIENT) {\n\t    done = TRUE;\n\t}\n    }\n    if ((rc == 0) && !done) {\n\tcpHash.hashAlg = TPM_ALG_SHA256;\t/* arbitrary choice */\n\trc = TSS_Hash_Generate(&cpHash,\n\t\t\t       in->context.contextBlob.b.size, in->context.contextBlob.b.buffer,\n\t\t\t       0, NULL);\n    }\n    /* convert a hash of the context blob to a string */\n    if ((rc == 0) && !done) {\n\trc = TSS_HashToString(string, cpHash.digest.sha256);\n    }\n    /* get the Name of the object being context loaded */\n    /* write the name with the loaded context's handle */\n    if ((rc == 0) && !done) {\n\trc = TSS_Name_Copy(tssContext,\n\t\t\t   out->loadedHandle, NULL,\t/* to handle */\n\t\t\t   0, string);\t\t\t/* from context */\t\n    }\n    /* get the public key of the object being context loaded */\n    /* write the public key with the loaded context's handle */\n    if ((rc == 0) && !done) {\n\trc = TSS_Public_Copy(tssContext,\n\t\t\t     out->loadedHandle,\n\t\t\t     NULL,\n\t\t\t     0,\n\t\t\t     string);\n    }\n#else\n    tssContext = tssContext;\n    in = in; \n#endif\n    return rc;\n}\n\n/* TSS_HashToString() converts a SHA-256 binary hash (really any 32-byte value) to a string \n\n   string must be 65 bytes: 32*2 + 1\n\n   NOTE: Hard coded to SHA256\n*/\n\n#ifndef TPM_TSS_NOFILE\n\nstatic TPM_RC TSS_HashToString(char *str, uint8_t *digest)\n{\n    size_t i;\n\n    for (i = 0 ; i < SHA256_DIGEST_SIZE ; i++) {\n\tsprintf(str +(i*2), \"%02x\", digest[i]);\n    }\n    if (tssVverbose) printf(\"TSS_HashToString: %s\\n\", str);\n    return 0;\n}\n\n#endif\n\n/* TSS_PO_FlushContext() removes persistent state associated with the handle */\n\nstatic TPM_RC TSS_PO_FlushContext(TSS_CONTEXT *tssContext,\n\t\t\t\t  FlushContext_In *in,\n\t\t\t\t  void *out,\n\t\t\t\t  void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n\n    out = out;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_FlushContext: flushHandle %08x\\n\", in->flushHandle);\n    if (rc == 0) {\n\trc = TSS_DeleteHandle(tssContext, in->flushHandle);\n    }\n    return rc;\n}\n\n/* TSS_PO_EvictControl() removes persistent state associated with the handle */\n\nstatic TPM_RC TSS_PO_EvictControl(TSS_CONTEXT *tssContext,\n\t\t\t\t  EvictControl_In *in,\n\t\t\t\t  void *out,\n\t\t\t\t  void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n\n    out = out;\n    extra = extra;\n    \n    if (tssVverbose) printf(\"TSS_PO_EvictControl: object %08x persistent %08x\\n\",\n\t\t\t    in->objectHandle, in->persistentHandle);\n    /* if it successfully made a persistent copy */\n    if (in->objectHandle != in->persistentHandle) {\n\t/* TPM2B_PUBLIC\tbPublic; */\n\tif (rc == 0) {\n\t    rc = TSS_Name_Copy(tssContext,\n\t\t\t       in->persistentHandle, NULL,\t/* to persistent handle */\n\t\t\t       in->objectHandle, NULL);\t\t/* from transient handle */\t\n\t}\n\t/* get the transient object public key */\n\t/* copy it to the persistent object public key */\n\tif (rc == 0) {\n\t    rc = TSS_Public_Copy(tssContext,\n\t\t\t\t in->persistentHandle,\n\t\t\t\t NULL,\n\t\t\t\t in->objectHandle,\n\t\t\t\t NULL);\n\t}\n    }\n    /* if it successfully evicted the persistent object */\n    else {\n\tif (rc == 0) {\n\t    rc = TSS_DeleteHandle(tssContext, in->persistentHandle);\n\t}\n    }\n    return rc;\n}\n\n/* TSS_PO_Load() saves the Name returned for the loaded object.  It saves the TPM2B_PUBLIC */\n\nstatic TPM_RC TSS_PO_Load(TSS_CONTEXT *tssContext,\n\t\t\t  Load_In *in,\n\t\t\t  Load_Out *out,\n\t\t\t  void *extra)\n{\n    TPM_RC \trc = 0;\n\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_Load: handle %08x\\n\", out->objectHandle);\n    /* use handle as file name */\n    if (rc == 0) {\n\trc = TSS_Name_Store(tssContext, &out->name, out->objectHandle, NULL);\n    }\n    if (rc == 0) {\n\trc = TSS_Public_Store(tssContext, &in->inPublic, out->objectHandle, NULL);\n    }\n    return rc;\n}\n\n/* TSS_PO_LoadExternal() saves the Name returned for the loaded object */\n\nstatic TPM_RC TSS_PO_LoadExternal(TSS_CONTEXT *tssContext,\n\t\t\t\t  LoadExternal_In *in,\n\t\t\t\t  LoadExternal_Out *out,\n\t\t\t\t  void *extra)\n{\n    TPM_RC \trc = 0;\n\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_LoadExternal: handle %08x\\n\", out->objectHandle);\n    /* use handle as file name */\n    if (rc == 0) {\n\trc = TSS_Name_Store(tssContext, &out->name, out->objectHandle, NULL);\n    }\n    if (rc == 0) {\n\trc = TSS_Public_Store(tssContext, &in->inPublic, out->objectHandle, NULL);\n    }\n    return rc;\n}\n\n/* TSS_PO_ReadPublic() saves the Name returned for the loaded object */\n\nstatic TPM_RC TSS_PO_ReadPublic(TSS_CONTEXT *tssContext,\n\t\t\t\tReadPublic_In *in,\n\t\t\t\tReadPublic_Out *out,\n\t\t\t\tvoid *extra)\n{\n    TPM_RC \trc = 0;\n\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_ReadPublic: handle %08x\\n\", in->objectHandle);\n    /* if the TSS is compiled without crypto support, it cannot recalculate the Name from the public\n       area. It has to trust the response from the TPM.  This should be OK since a 'no crypto' TSS\n       is used when there is a tructed path to the TPM. */\n#ifndef TPM_TSS_NOCRYPTO\n    /* validate the Name against the public area */\n    /* Name = nameAlg || HnameAlg (handle->publicArea)\n       where\n       nameAlg\talgorithm used to compute Name\n       HnameAlg\thash using the nameAlg parameter in the object associated with handle\n       publicArea \tcontents of the TPMT_PUBLIC associated with handle\n    */\n    {\n\tTPM2B_NAME name;\n\tif (rc == 0) {\n\t    rc = TSS_ObjectPublic_GetName(&name, &out->outPublic.publicArea);\n\t}\n\tif (rc == 0) {\n\t    if (name.t.size != out->name.t.size) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_PO_ReadPublic: TPMT_PUBLIC does not match TPM2B_NAME\\n\");\n\t\trc = TSS_RC_MALFORMED_PUBLIC;\n\t    }\n\t    else {\n\t\tint irc;\n\t\tirc = memcmp(name.t.name, out->name.t.name, out->name.t.size);\n\t\tif (irc != 0) {\n\t\t    if (tssVerbose)\n\t\t\tprintf(\"TSS_PO_ReadPublic: TPMT_PUBLIC does not match TPM2B_NAME\\n\");\n\t\t    rc = TSS_RC_MALFORMED_PUBLIC;\n\t\t}\n\t    }\n\t}\n    }\n#endif\n    /* use handle as file name */\n    if (rc == 0) {\n\trc = TSS_Name_Store(tssContext, &out->name, in->objectHandle, NULL);\n    }\n    if (rc == 0) {\n\trc = TSS_Public_Store(tssContext, &out->outPublic, in->objectHandle, NULL);\n    }\n    return rc;\n}\n\n/* TSS_PO_Load() saves the Name returned for the loaded object.  It saves the TPM2B_PUBLIC */\n\nstatic TPM_RC TSS_PO_CreateLoaded(TSS_CONTEXT *tssContext,\n\t\t\t\t  CreateLoaded_In *in,\n\t\t\t\t  CreateLoaded_Out *out,\n\t\t\t\t  void *extra)\n{\n    TPM_RC \trc = 0;\n\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_CreateLoaded: handle %08x\\n\", out->objectHandle);\n    /* use handle as file name */\n    if (rc == 0) {\n\trc = TSS_Name_Store(tssContext, &out->name, out->objectHandle, NULL);\n    }\n    if (rc == 0) {\n\trc = TSS_Public_Store(tssContext, &out->outPublic, out->objectHandle, NULL);\n    }\n    return rc;\n}\n\n/* TSS_PO_HashSequenceStart() saves the Name returned for the started sequence object */\n\nstatic TPM_RC TSS_PO_HashSequenceStart(TSS_CONTEXT *tssContext,\n\t\t\t\t       HashSequenceStart_In *in,\n\t\t\t\t       HashSequenceStart_Out *out,\n\t\t\t\t       void *extra)\n{\n    TPM_RC \trc = 0;\n    TPM2B_NAME \tname;\n\n    in = in;\n    extra = extra;\n\n    if (tssVverbose) printf(\"TSS_PO_HashSequenceStart\\n\");\n    /* Part 1 Table 3 The Name of a sequence object is an Empty Buffer */\n    if (rc == 0) {\n\tname.b.size = 0;\n\t/* use handle as file name */\n\trc = TSS_Name_Store(tssContext, &name, out->sequenceHandle, NULL);\n    }\n    return rc;\n}\n\n\n/* TSS_PO_HMAC_Start() saves the Name returned for the started sequence object */\n\nstatic TPM_RC TSS_PO_HMAC_Start(TSS_CONTEXT *tssContext,\n\t\t\t\tHMAC_Start_In *in,\n\t\t\t\tHMAC_Start_Out *out,\n\t\t\t\tvoid *extra)\n{\n    TPM_RC \trc = 0;\n    TPM2B_NAME \tname;\n\n    in = in;\n    extra = extra;\n\n    if (tssVverbose) printf(\"TSS_PO_HMAC_Start\\n\");\n    /* Part 1 Table 3 The Name of a sequence object is an Empty Buffer */\n    if (rc == 0) {\n\tname.b.size = 0;\n\t/* use handle as file name */\n\trc = TSS_Name_Store(tssContext, &name, out->sequenceHandle, NULL);\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_PO_SequenceComplete(TSS_CONTEXT *tssContext,\n\t\t\t\t      SequenceComplete_In *in,\n\t\t\t\t      SequenceComplete_Out *out,\n\t\t\t\t      void *extra)\n{\n    TPM_RC \trc = 0;\n\n    out = out;\n    extra = extra;\n\n    if (tssVverbose) printf(\"TSS_PO_SequenceComplete: sequenceHandle %08x\\n\", in->sequenceHandle);\n    if (rc == 0) {\n\trc = TSS_DeleteHandle(tssContext, in->sequenceHandle);\n    }\n    return rc;\n}\nstatic TPM_RC TSS_PO_EventSequenceComplete(TSS_CONTEXT *tssContext,\n\t\t\t\t\t   EventSequenceComplete_In *in,\n\t\t\t\t\t   EventSequenceComplete_Out *out,\n\t\t\t\t\t   void *extra)\n{\n    TPM_RC \trc = 0;\n    out = out;\n    extra = extra;\n    if (tssVverbose)\n\tprintf(\"TSS_PO_EventSequenceComplete: sequenceHandle %08x\\n\", in->sequenceHandle);\n    if (rc == 0) {\n\trc = TSS_DeleteHandle(tssContext, in->sequenceHandle);\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_PO_PolicyAuthValue(TSS_CONTEXT *tssContext,\n\t\t\t\t     PolicyAuthValue_In *in,\n\t\t\t\t     void *out,\n\t\t\t\t     void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    struct TSS_HMAC_CONTEXT \t*session = NULL;\n    \n    out = out;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_PolicyAuthValue\\n\");\n    if (rc == 0) {\n\trc = TSS_Malloc((unsigned char **)&session, sizeof(TSS_HMAC_CONTEXT));\t/* freed @1 */\n    }\n    if (rc == 0) {\n\trc = TSS_HmacSession_LoadSession(tssContext, session, in->policySession);\n    }\n    if (rc == 0) {\n\tsession->isPasswordNeeded = FALSE;\n\tsession->isAuthValueNeeded = TRUE;\n\trc = TSS_HmacSession_SaveSession(tssContext, session);\n    }\n    free(session);\t\t/* @1 */\n    return rc;\n}\n\nstatic TPM_RC TSS_PO_PolicyPassword(TSS_CONTEXT *tssContext,\n\t\t\t\t    PolicyPassword_In *in,\n\t\t\t\t    void *out,\n\t\t\t\t    void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    struct TSS_HMAC_CONTEXT \t*session = NULL;\n\n    out = out;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_PolicyPassword\\n\");\n    if (rc == 0) {\n\trc = TSS_Malloc((unsigned char **)&session, sizeof(TSS_HMAC_CONTEXT));\t/* freed @1 */\n    }\n    if (rc == 0) {\n\trc = TSS_HmacSession_LoadSession(tssContext, session, in->policySession);\n    }\n    if (rc == 0) {\n\tsession->isPasswordNeeded = TRUE;\n\tsession->isAuthValueNeeded = FALSE;\n\trc = TSS_HmacSession_SaveSession(tssContext, session);\n    }\n    free(session);\t\t/* @1 */\n    return rc;\n}\n\nstatic TPM_RC TSS_PO_CreatePrimary(TSS_CONTEXT *tssContext,\n\t\t\t\t   CreatePrimary_In *in,\n\t\t\t\t   CreatePrimary_Out *out,\n\t\t\t\t   void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n\n    in = in;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_CreatePrimary: handle %08x\\n\", out->objectHandle);\n    /* use handle as file name */\n    if (rc == 0) {\n\trc = TSS_Name_Store(tssContext, &out->name, out->objectHandle, NULL);\n    }\n    if (rc == 0) {\n\trc = TSS_Public_Store(tssContext, &out->outPublic, out->objectHandle, NULL);\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_PO_NV_DefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t\t    NV_DefineSpace_In *in,\n\t\t\t\t    void *out,\n\t\t\t\t    void *extra)\n{\n    TPM_RC \trc = 0;\n\n    if (tssVverbose) printf(\"TSS_PO_NV_DefineSpace\\n\");\n#ifndef TPM_TSS_NOCRYPTO\n    {\n\tTPM2B_NAME name;\n\t/* calculate the Name from the input public area */\n\t/* Name = nameAlg || HnameAlg (handle->nvPublicArea)\n\t   where\n\t   nameAlg\talgorithm used to compute Name\n\t   HnameAlg hash using the nameAlg parameter in the NV Index location associated with handle\n\t   nvPublicArea\tcontents of the TPMS_NV_PUBLIC associated with handle\n\t*/\n\t/* calculate the Name from the input TPMS_NV_PUBLIC */\n\tif (rc == 0) {\n\t    rc = TSS_NVPublic_GetName(&name, &in->publicInfo.nvPublic);\n\t}\n\t/* use handle as file name */\n\tif (rc == 0) {\n\t    rc = TSS_Name_Store(tssContext, &name, in->publicInfo.nvPublic.nvIndex, NULL);\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_NVPublic_Store(tssContext, &in->publicInfo.nvPublic,\n\t\t\t\t    in->publicInfo.nvPublic.nvIndex); \n\t}\n    }\n#else\n    tssContext = tssContext;\n    in = in;\n#endif\n    out = out;\n    extra = extra;\n    return rc;\n}\n\n\nstatic TPM_RC TSS_PO_NV_ReadPublic(TSS_CONTEXT *tssContext,\n\t\t\t\t   NV_ReadPublic_In *in,\n\t\t\t\t   NV_ReadPublic_Out *out,\n\t\t\t\t   void *extra)\n{\n    TPM_RC \trc = 0;\n\n    if (tssVverbose) printf(\"TSS_PO_NV_ReadPublic\\n\");\n    \n    /* validate the Name against the public area */\n    /* Name = nameAlg || HnameAlg (handle->nvPublicArea)\n       where\n       nameAlg\talgorithm used to compute Name\n       HnameAlg hash using the nameAlg parameter in the NV Index location associated with handle\n       nvPublicArea\tcontents of the TPMS_NV_PUBLIC associated with handle\n    */\n#ifndef TPM_TSS_NOCRYPTO\n    {\n\tTPM2B_NAME name;\n\t/* calculate the Name from the TPMS_NV_PUBLIC */\n\tif (rc == 0) {\n\t    rc = TSS_NVPublic_GetName(&name, &out->nvPublic.nvPublic);\n\t}\n\tif (rc == 0) {\n\t    if (name.t.size != out->nvName.t.size) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_PO_NV_ReadPublic: TPMT_NV_PUBLIC does not match TPM2B_NAME\\n\");\n\t\trc = TSS_RC_MALFORMED_NV_PUBLIC;\n\t    }\n\t    else {\n\t\tint irc;\n\t\tirc = memcmp(name.t.name, out->nvName.t.name, out->nvName.t.size);\n\t\tif (irc != 0) {\n\t\t    if (tssVerbose)\n\t\t\tprintf(\"TSS_PO_NV_ReadPublic: TPMT_NV_PUBLIC does not match TPM2B_NAME\\n\");\n\t\t    rc = TSS_RC_MALFORMED_NV_PUBLIC;\n\t\t}\n\t    }\n\t}\n\t/* use handle as file name */\n\tif (rc == 0) {\n\t    rc = TSS_Name_Store(tssContext, &out->nvName, in->nvIndex, NULL);\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_NVPublic_Store(tssContext, &out->nvPublic.nvPublic, in->nvIndex); \n\t}\n    }\n#else\n    tssContext = tssContext;\n    in = in;\n    out = out;\n#endif\n    extra = extra;\n    return rc;\n}\n\nstatic TPM_RC TSS_PO_NV_UndefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t\t      NV_UndefineSpace_In *in,\n\t\t\t\t      void *out,\n\t\t\t\t      void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n\n    out = out;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_NV_UndefineSpace\\n\");\n#ifndef TPM_TSS_NOCRYPTO\n    /* Don't check return code. */\n    TSS_DeleteHandle(tssContext, in->nvIndex);\n    TSS_NVPublic_Delete(tssContext, in->nvIndex);\n#else\n    tssContext = tssContext;\n    in = in;\n#endif\n    return rc;\n}\n\nstatic TPM_RC TSS_PO_NV_UndefineSpaceSpecial(TSS_CONTEXT *tssContext,\n\t\t\t\t\t     NV_UndefineSpaceSpecial_In *in,\n\t\t\t\t\t     void *out,\n\t\t\t\t\t     void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n\n    out = out;\n    extra = extra;\n    if (tssVverbose) printf(\"TSS_PO_NV_UndefineSpaceSpecial\\n\");\n    /* Don't check return code.  The name will only exist if NV_ReadPublic has been issued */\n    TSS_DeleteHandle(tssContext, in->nvIndex);\n    TSS_NVPublic_Delete(tssContext, in->nvIndex);\n    return rc;\n}\n\n/* TSS_PO_NV_Write() handles the Name and NVPublic update for the 4 NV write commands: write,\n   increment, extend, and setbits */\n\nstatic TPM_RC TSS_PO_NV_Write(TSS_CONTEXT *tssContext,\n\t\t\t      NV_Write_In *in,\n\t\t\t      void *out,\n\t\t\t      void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    \n    if (tssVverbose) printf(\"TSS_PO_NV_Write, Increment, Extend, SetBits:\\n\");\n\n#ifndef TPM_TSS_NOCRYPTO\n    {\n\tTPMS_NV_PUBLIC \t\tnvPublic;\n\tTPM2B_NAME \t\tname;\t\t/* new name */\n\t\n\tif (rc == 0) {\n\t    rc = TSS_NVPublic_Load(tssContext, &nvPublic, in->nvIndex);\n\t}\n\t/* if the previous store had written clear */\n\tif (!(nvPublic.attributes.val & TPMA_NVA_WRITTEN)) {\n\t    if (rc == 0) {\n\t\t/* set the written bit */\n\t\tnvPublic.attributes.val |= TPMA_NVA_WRITTEN;\n\t\t/* save the TPMS_NV_PUBLIC */\n\t\trc = TSS_NVPublic_Store(tssContext, &nvPublic, in->nvIndex);\n\t    }\n\t    /* calculate the name */\n\t    if (rc == 0) {\n\t\trc = TSS_NVPublic_GetName(&name, &nvPublic);\n\t    }\n\t    /* save the name */\n\t    if (rc == 0) {\n\t\t/* use handle as file name */\n\t\trc = TSS_Name_Store(tssContext, &name, in->nvIndex, NULL);\n\t    }\n\t    /* if there is a failure. delete the name and NVPublic */\n\t    if (rc != 0) {\n\t\tTSS_DeleteHandle(tssContext, in->nvIndex);\n\t\tTSS_NVPublic_Delete(tssContext, in->nvIndex);\n\t    }\n\t}\n    }\n#else\n    tssContext = tssContext;\n    in = in;\n#endif\n    out = out;\n    extra = extra;\n    return rc;\n}\n\n/* TSS_PO_NV_WriteLock() handles the Name and NVPublic update for the write lock command */\n\nstatic TPM_RC TSS_PO_NV_WriteLock(TSS_CONTEXT *tssContext,\n\t\t\t\t  NV_WriteLock_In *in,\n\t\t\t\t  void *out,\n\t\t\t\t  void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n   \n    if (tssVverbose) printf(\"TSS_PO_NV_WriteLock:\\n\");\n\n#ifndef TPM_TSS_NOCRYPTO\n    {\n\tTPMS_NV_PUBLIC \t\tnvPublic;\n\tTPM2B_NAME \t\tname;\t\t/* new name */\n\t\n \tif (rc == 0) {\n\t    rc = TSS_NVPublic_Load(tssContext, &nvPublic, in->nvIndex);\n\t}\n\t/* if the previous store had write lock clear */\n\tif (!(nvPublic.attributes.val & TPMA_NVA_WRITELOCKED)) {\n\t    if (rc == 0) {\n\t\t/* set the write lock bit */\n\t\tnvPublic.attributes.val |= TPMA_NVA_WRITELOCKED;\n\t\t/* save the TPMS_NV_PUBLIC */\n\t\trc = TSS_NVPublic_Store(tssContext, &nvPublic, in->nvIndex);\n\t    }\n\t    /* calculate the name */\n\t    if (rc == 0) {\n\t\trc = TSS_NVPublic_GetName(&name, &nvPublic);\n\t    }\n\t    /* save the name */\n\t    if (rc == 0) {\n\t\t/* use handle as file name */\n\t\trc = TSS_Name_Store(tssContext, &name, in->nvIndex, NULL);\n\t    }\n\t    /* if there is a failure. delete the name and NVPublic */\n\t    if (rc != 0) {\n\t\tTSS_DeleteHandle(tssContext, in->nvIndex);\n\t\tTSS_NVPublic_Delete(tssContext, in->nvIndex);\n\t    }\n\t}\n    }\n#else\n    tssContext = tssContext;\n    in = in;\n#endif\n    out = out;\n    extra = extra;\n    return rc;\n}\n\n/* TSS_PO_NV_WriteLock() handles the Name and NVPublic update for the read lock command */\n\nstatic TPM_RC TSS_PO_NV_ReadLock(TSS_CONTEXT *tssContext,\n\t\t\t\t NV_ReadLock_In *in,\n\t\t\t\t void *out,\n\t\t\t\t void *extra)\n{\n    TPM_RC \t\t\trc = 0;\n    \n    if (tssVverbose) printf(\"TSS_PO_NV_ReadLock:\");\n\n#ifndef TPM_TSS_NOCRYPTO\n    {\n\tTPMS_NV_PUBLIC \t\tnvPublic;\n\tTPM2B_NAME \t\t\tname;\t\t/* new name */\n\n\tif (rc == 0) {\n\t    rc = TSS_NVPublic_Load(tssContext, &nvPublic, in->nvIndex);\n\t}\n\t/* if the previous store had read lock clear */\n\tif (!(nvPublic.attributes.val & TPMA_NVA_READLOCKED)) {\n\t    if (rc == 0) {\n\t\t/* set the read lock bit */\n\t\tnvPublic.attributes.val |= TPMA_NVA_READLOCKED;\n\t\t/* save the TPMS_NV_PUBLIC */\n\t\trc = TSS_NVPublic_Store(tssContext, &nvPublic, in->nvIndex);\n\t    }\n\t    /* calculate the name */\n\t    if (rc == 0) {\n\t\trc = TSS_NVPublic_GetName(&name, &nvPublic);\n\t    }\n\t    /* save the name */\n\t    if (rc == 0) {\n\t\t/* use handle as file name */\n\t\trc = TSS_Name_Store(tssContext, &name, in->nvIndex, NULL);\n\t    }\n\t    /* if there is a failure. delete the name and NVPublic */\n\t    if (rc != 0) {\n\t\tTSS_DeleteHandle(tssContext, in->nvIndex);\n\t\tTSS_NVPublic_Delete(tssContext, in->nvIndex);\n\t    }\n\t}\n    }\n#else\n    tssContext = tssContext;\n    in = in;\n#endif\n    out = out;\n    extra = extra;\n    return rc;\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/tssauth.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tCommon TPM 1.2 and TPM 2.0 TSS Authorization \t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* This layer handles command and response packet authorization parameters. */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdarg.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tsstransmit.h>\n#include \"tssproperties.h\"\n#include <ibmtss/tssresponsecode.h>\n\n#include \"tssauth.h\"\n\nextern int tssVerbose;\nextern int tssVverbose;\n\n/* TSS_AuthCreate() allocates and initializes a TSS_AUTH_CONTEXT */\n\nTPM_RC TSS_AuthCreate(TSS_AUTH_CONTEXT **tssAuthContext)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n        rc = TSS_Malloc((uint8_t **)tssAuthContext, sizeof(TSS_AUTH_CONTEXT));\n   }\n    if (rc == 0) {\n\tTSS_InitAuthContext(*tssAuthContext);\n    }\n    return rc;\n}\n\n/* TSS_InitAuthContext() sets initial values for an allocated TSS_AUTH_CONTEXT */\n\nvoid TSS_InitAuthContext(TSS_AUTH_CONTEXT *tssAuthContext)\n{\n    memset(tssAuthContext->commandBuffer, 0, sizeof(tssAuthContext->commandBuffer));\n    memset(tssAuthContext->responseBuffer, 0, sizeof(tssAuthContext->responseBuffer));\n    tssAuthContext->commandText = NULL;\n    tssAuthContext->commandCode = 0;\n    tssAuthContext->responseCode = 0;\n    tssAuthContext->commandHandleCount = 0;\n    tssAuthContext->responseHandleCount = 0;\n    tssAuthContext->authCount = 0;\n    tssAuthContext->commandSize = 0;\n    tssAuthContext->cpBufferSize = 0;\n    tssAuthContext->cpBuffer = NULL;\n    tssAuthContext->responseSize = 0;\n    tssAuthContext->marshalInFunction = NULL;\n    tssAuthContext->unmarshalOutFunction = NULL;\n#ifndef TPM_TSS_NOCMDCHECK\n    tssAuthContext->unmarshalInFunction = NULL;\n#endif\n#ifdef TPM_TPM12\n    tssAuthContext->sessionNumber = 0xffff;\t/* no encrypt sessions */\n    tssAuthContext->encAuthOffset0 = 0;\n    tssAuthContext->encAuthOffset1 = 0;\n#endif\n    return;\n}\n\n/* TSS_AuthDelete() re-initializes and then frees an allocated TSS_AUTH_CONTEXT */\n\nTPM_RC TSS_AuthDelete(TSS_AUTH_CONTEXT *tssAuthContext)\n{\n    if (tssAuthContext != NULL) {\n\tTSS_InitAuthContext(tssAuthContext);\n\tfree(tssAuthContext);\n    }\n    return 0;\n}\n\nTPM_CC TSS_GetCommandCode(TSS_AUTH_CONTEXT *tssAuthContext)\n{\n    TPM_CC commandCode = tssAuthContext->commandCode;\n    return commandCode;\n}\n\nTPM_RC TSS_GetCpBuffer(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t       uint32_t *cpBufferSize,\n\t\t       uint8_t **cpBuffer)\n{\n    *cpBufferSize = tssAuthContext->cpBufferSize;\n    *cpBuffer = tssAuthContext->cpBuffer;\n    return 0;\n}\n\n/* TSS_GetCommandHandleCount() returns the number of handles in the command area */\n\nTPM_RC TSS_GetCommandHandleCount(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t size_t *commandHandleCount)\n{\n    *commandHandleCount = tssAuthContext->commandHandleCount;\n    return 0;\n}\n\nTPM_RC TSS_AuthExecute(TSS_CONTEXT *tssContext)\n{\n    TPM_RC rc = 0;\n    if (tssVverbose) printf(\"TSS_AuthExecute: Executing %s\\n\",\n\t\t\t    tssContext->tssAuthContext->commandText);\n    /* transmit the command and receive the response.  Normally returns the TPM response code. */\n    if (rc == 0) {\n\trc = TSS_Transmit(tssContext,\n\t\t\t  tssContext->tssAuthContext->responseBuffer,\n\t\t\t  &tssContext->tssAuthContext->responseSize,\n\t\t\t  tssContext->tssAuthContext->commandBuffer,\n\t\t\t  tssContext->tssAuthContext->commandSize,\n\t\t\t  tssContext->tssAuthContext->commandText);\n    }\n    return rc;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssauth12.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM 1.2 TSS Authorization\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2018 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* This layer handles command and response packet authorization parameters. */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdarg.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n#include <ibmtss/tsstransmit.h>\n#include \"tssproperties.h\"\n#include <ibmtss/tssresponsecode.h>\n\n#include <ibmtss/tpmtypes12.h>\n#include <ibmtss/tpmconstants12.h>\n#include <ibmtss/tssmarshal12.h>\n#include <ibmtss/Unmarshal12_fp.h>\n\n#include \"tssauth12.h\"\n\nextern int tssVerbose;\nextern int tssVverbose;\n\ntypedef struct MARSHAL_TABLE {\n    TPM_CC \t\t\tcommandCode;\n    const char \t\t\t*commandText;\n    MarshalInFunction_t \tmarshalInFunction;\t/* marshal input command */\n    UnmarshalOutFunction_t \tunmarshalOutFunction;\t/* unmarshal output response */\n#ifndef TPM_TSS_NOCMDCHECK\n    UnmarshalInFunction_t\tunmarshalInFunction;\t/* unmarshal input command for parameter\n\t\t\t\t\t\t\t   checking */\n#endif\n} MARSHAL_TABLE;\n\nstatic const MARSHAL_TABLE marshalTable12 [] = {\n\t\t\t\t \n    {TPM_ORD_ActivateIdentity,\"TPM_ORD_ActivateIdentity\",\n     (MarshalInFunction_t)TSS_ActivateIdentity_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ActivateIdentity_Out_Unmarshalu,\n     (UnmarshalInFunction_t)ActivateIdentity_In_Unmarshal},\n\n    {TPM_ORD_ContinueSelfTest,\"TPM_ORD_ContinueSelfTest\",\n     (MarshalInFunction_t)NULL,\n     (UnmarshalOutFunction_t)NULL,\n     (UnmarshalInFunction_t)NULL},\n\n    {TPM_ORD_CreateEndorsementKeyPair,\"TPM_ORD_CreateEndorsementKeyPair\",\n     (MarshalInFunction_t)TSS_CreateEndorsementKeyPair_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_CreateEndorsementKeyPair_Out_Unmarshalu,\n     (UnmarshalInFunction_t)CreateEndorsementKeyPair_In_Unmarshal},\n\n    {TPM_ORD_CreateWrapKey,\"TPM_ORD_CreateWrapKey\",\n     (MarshalInFunction_t)TSS_CreateWrapKey_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_CreateWrapKey_Out_Unmarshalu,\n     (UnmarshalInFunction_t)CreateWrapKey_In_Unmarshal},\n\n    {TPM_ORD_Extend,\"TPM_ORD_Extend\",\n     (MarshalInFunction_t)TSS_Extend_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Extend_Out_Unmarshalu,\n     (UnmarshalInFunction_t)Extend_In_Unmarshal},\n\n    {TPM_ORD_FlushSpecific,\"TPM_ORD_FlushSpecific\",\n     (MarshalInFunction_t)TSS_FlushSpecific_In_Marshalu,\n     (UnmarshalOutFunction_t)NULL,\n     (UnmarshalInFunction_t)FlushSpecific_In_Unmarshal},\n\n    {TPM_ORD_GetCapability,\"TPM_ORD_GetCapability\",\n     (MarshalInFunction_t)TSS_GetCapability12_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_GetCapability12_Out_Unmarshalu,\n     (UnmarshalInFunction_t)GetCapability12_In_Unmarshal},\n\n    {TPM_ORD_LoadKey2,\"TPM_ORD_LoadKey2\",\n     (MarshalInFunction_t)TSS_LoadKey2_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_LoadKey2_Out_Unmarshalu,\n     (UnmarshalInFunction_t)LoadKey2_In_Unmarshal},\n\n    {TPM_ORD_MakeIdentity,\"TPM_ORD_MakeIdentity\",\n     (MarshalInFunction_t)TSS_MakeIdentity_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_MakeIdentity_Out_Unmarshalu,\n     (UnmarshalInFunction_t)MakeIdentity_In_Unmarshal},\n\n    {TPM_ORD_NV_DefineSpace,\"TPM_ORD_NV_DefineSpace\",\n     (MarshalInFunction_t)TSS_NV_DefineSpace12_In_Marshalu,\n     NULL,\n     (UnmarshalInFunction_t)NV_DefineSpace12_In_Unmarshal},\n\n    {TPM_ORD_NV_ReadValueAuth,\"TPM_ORD_NV_ReadValueAuth\",\n     (MarshalInFunction_t)TSS_NV_ReadValueAuth_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_NV_ReadValueAuth_Out_Unmarshalu,\n     (UnmarshalInFunction_t)NV_ReadValueAuth_In_Unmarshal},\n\n    {TPM_ORD_NV_ReadValue,\"TPM_ORD_NV_ReadValue\",\n     (MarshalInFunction_t)TSS_NV_ReadValue_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_NV_ReadValue_Out_Unmarshalu,\n     (UnmarshalInFunction_t)NV_ReadValue_In_Unmarshal},\n\n    {TPM_ORD_NV_WriteValue,\"TPM_ORD_NV_WriteValue\",\n     (MarshalInFunction_t)TSS_NV_WriteValue_In_Marshalu,\n     NULL,\n     (UnmarshalInFunction_t)NV_WriteValue_In_Unmarshal},\n\n    {TPM_ORD_NV_WriteValueAuth,\"TPM_ORD_NV_WriteValueAuth\",\n     (MarshalInFunction_t)TSS_NV_WriteValueAuth_In_Marshalu,\n     NULL,\n     (UnmarshalInFunction_t)NV_WriteValueAuth_In_Unmarshal},\n\n    {TPM_ORD_OIAP,\"TPM_ORD_OIAP\",\n     (MarshalInFunction_t)NULL,\n     (UnmarshalOutFunction_t)TSS_OIAP_Out_Unmarshalu,\n     (UnmarshalInFunction_t)NULL},\n\n    {TPM_ORD_OSAP,\"TPM_ORD_OSAP\",\n     (MarshalInFunction_t)TSS_OSAP_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_OSAP_Out_Unmarshalu,\n     (UnmarshalInFunction_t)OSAP_In_Unmarshal},\n\n    {TPM_ORD_OwnerReadInternalPub,\"TPM_ORD_OwnerReadInternalPub\",\n     (MarshalInFunction_t)TSS_OwnerReadInternalPub_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_OwnerReadInternalPub_Out_Unmarshalu,\n     (UnmarshalInFunction_t)OwnerReadInternalPub_In_Unmarshal},\n\n    {TPM_ORD_OwnerSetDisable,\"TPM_ORD_OwnerSetDisable\",\n     (MarshalInFunction_t)TSS_OwnerSetDisable_In_Marshalu,\n     NULL,\n     (UnmarshalInFunction_t)OwnerSetDisable_In_Unmarshal},\n\n    {TPM_ORD_MakeIdentity,\"TPM_ORD_MakeIdentity\",\n     (MarshalInFunction_t)TSS_MakeIdentity_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_MakeIdentity_Out_Unmarshalu,\n     (UnmarshalInFunction_t)MakeIdentity_In_Unmarshal},\n\n    {TPM_ORD_PcrRead,\"TPM_ORD_PcrRead\",\n     (MarshalInFunction_t)TSS_PcrRead12_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_PcrRead12_Out_Unmarshalu,\n     (UnmarshalInFunction_t)PcrRead12_In_Unmarshal},\n\n    {TPM_ORD_PCR_Reset,\"TPM_ORD_PCR_Reset\",\n     (MarshalInFunction_t)TSS_PCR_Reset12_In_Marshalu,\n     NULL,\n     (UnmarshalInFunction_t)PCR_Reset12_In_Unmarshal},\n\n    {TPM_ORD_Quote2,\"TPM_ORD_Quote2\",\n     (MarshalInFunction_t)TSS_Quote2_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Quote2_Out_Unmarshalu,\n     (UnmarshalInFunction_t)Quote2_In_Unmarshal},\n\n    {TPM_ORD_ReadPubek,\"TPM_ORD_ReadPubek\",\n     (MarshalInFunction_t)TSS_ReadPubek_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ReadPubek_Out_Unmarshalu,\n     (UnmarshalInFunction_t)ReadPubek_In_Unmarshal},\n\n    {TPM_ORD_Sign,\"TPM_ORD_Sign\",\n     (MarshalInFunction_t)TSS_Sign12_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Sign12_Out_Unmarshalu,\n     (UnmarshalInFunction_t)Sign12_In_Unmarshal},\n\n    {TPM_ORD_Startup,\"TPM_ORD_Startup\",\n     (MarshalInFunction_t)TSS_Startup12_In_Marshalu,\n     NULL,\n     (UnmarshalInFunction_t)Startup12_In_Unmarshal},\n\n    {TPM_ORD_TakeOwnership,\"TPM_ORD_TakeOwnership\",\n     (MarshalInFunction_t)TSS_TakeOwnership_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_TakeOwnership_Out_Unmarshalu,\n     (UnmarshalInFunction_t)TakeOwnership_In_Unmarshal},\n\n     {TPM_ORD_Init,\"TPM_ORD_Init\",\n     NULL,\n     NULL,\n     NULL},\n};\n\n/* TSS_MarshalTable12_Process() indexes into the command marshal table, and saves the marshal and\n   unmarshal functions */\n\n\nstatic TPM_RC TSS_MarshalTable12_Process(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t\t TPM_CC commandCode)\n{\n    TPM_RC rc = 0;\n    size_t index;\n    int found = FALSE;\n\n    /* get the command index in the dispatch table */\n    for (index = 0 ; index < (sizeof(marshalTable12) / sizeof(MARSHAL_TABLE)) ; (index)++) {\n\tif (marshalTable12[index].commandCode == commandCode) {\n\t    found = TRUE;\n\t    break;\n\t}\n    }\n    if (found) {\n\ttssAuthContext->commandCode = commandCode;\n\ttssAuthContext->commandText = marshalTable12[index].commandText;\n\ttssAuthContext->marshalInFunction = marshalTable12[index].marshalInFunction;\n\ttssAuthContext->unmarshalOutFunction = marshalTable12[index].unmarshalOutFunction;\n#ifndef TPM_TSS_NOCMDCHECK\n\ttssAuthContext->unmarshalInFunction = marshalTable12[index].unmarshalInFunction;\n#endif\n    }\n    else {\n\tif (tssVerbose) printf(\"TSS_MarshalTable12_Process: \"\n\t\t\t       \"commandCode %08x not found in marshal table\\n\",\n\t\t\t       commandCode);\n\trc = TSS_RC_COMMAND_UNIMPLEMENTED;\n    }\n    return rc;\n}\n\n/* TSS_Marshal12() marshals the input parameters into the TSS Authorization context.\n\n   It also sets other member of the context in preparation for the rest of the sequence.  \n*/\n\nTPM_RC TSS_Marshal12(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t     COMMAND_PARAMETERS *in,\n\t\t     TPM_CC commandCode)\n{\n    TPM_RC \t\trc = 0;\n    TPM_TAG \t\ttag = TPM_TAG_RQU_COMMAND;\t/* default until sessions are added */\n    uint8_t \t\t*buffer;\t\t\t/* for marshaling */\n    uint8_t \t\t*bufferu;\t\t\t/* for test unmarshaling */\n    uint32_t \t\tsize;\n    \n    /* index from command code to table and save marshal and unmarshal functions for this command */\n    if (rc == 0) {\n\trc = TSS_MarshalTable12_Process(tssAuthContext, commandCode);\n    }\n    /* get the number of command and response handles from the TPM table */\n    if (rc == 0) {\n\ttssAuthContext->tpmCommandIndex = CommandCodeToCommandIndex12(commandCode);\n\tif (tssAuthContext->tpmCommandIndex == UNIMPLEMENTED_COMMAND_INDEX) {\n\t    if (tssVerbose) printf(\"TSS_Marshal12: \"\n\t\t\t\t   \"commandCode %08x not found in command attributes table\\n\",\n\t\t\t\t   commandCode);\n\t    rc = TSS_RC_COMMAND_UNIMPLEMENTED;\n\t}\n    }\n    if (rc == 0) {\n\ttssAuthContext->commandHandleCount =\n\t    getCommandHandleCount12(tssAuthContext->tpmCommandIndex);\n\ttssAuthContext->responseHandleCount =\n\t    getresponseHandleCount12(tssAuthContext->tpmCommandIndex);\n    }\n    if (rc == 0) {\n\t/* make a copy of the command buffer and size since the marshal functions move them */\n\tbuffer = tssAuthContext->commandBuffer;\n\tsize = MAX_COMMAND_SIZE;\n\t/* marshal header, preliminary tag and command size */\n\trc = TSS_UINT16_Marshalu(&tag, &tssAuthContext->commandSize, &buffer, &size);\n    }\n    if (rc == 0) {\n\tuint32_t commandSize = tssAuthContext->commandSize;\n\trc = TSS_UINT32_Marshalu(&commandSize, &tssAuthContext->commandSize, &buffer, &size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&commandCode, &tssAuthContext->commandSize, &buffer, &size);\n    }    \n    if (rc == 0) {\n\t/* save pointer to marshaled data for test unmarshal */\n\tbufferu = buffer +\n\t\t  tssAuthContext->commandHandleCount * sizeof(TPM_HANDLE);\n\t/* if there is a marshal function */\n\tif (tssAuthContext->marshalInFunction != NULL) {\n\t    /* if there is a structure to marshal */\n\t    if (in != NULL) {\n\t\trc = tssAuthContext->marshalInFunction(in, &tssAuthContext->commandSize,\n\t\t\t\t\t\t       &buffer, &size);\n\t    }\n\t    /* caller error, no structure supplied to marshal */\n\t    else {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_Marshal12: Command %08x requires command parameter structure\\n\",\n\t\t\t   commandCode);\n\t\trc = TSS_RC_IN_PARAMETER;\t\n\t    }\n\t}\n\t/* if there is no marshal function */\n\telse {\n\t    /* caller error, supplied structure but there is no marshal function */\n\t    if (in != NULL) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_Marshal12: Command %08x does not take command parameter structure\\n\",\n\t\t\t   commandCode);\n\t\trc = TSS_RC_IN_PARAMETER;\t\n\t    }\n\t    /* no marshal function and no command parameter structure is OK */\n\t}\n    }\n#ifndef TPM_TSS_NOCMDCHECK\n    /* unmarshal to validate the input parameters */\n    if ((rc == 0) && (tssAuthContext->unmarshalInFunction != NULL)) {\n\tCOMMAND_PARAMETERS target;\n\tTPM_HANDLE \thandles[MAX_HANDLE_NUM];\n\tsize = MAX_COMMAND_SIZE;\n\trc = tssAuthContext->unmarshalInFunction(&target, &bufferu, &size, handles);\n\tif ((rc != 0) && tssVerbose) {\n\t    printf(\"TSS_Marshal12: Invalid command parameter\\n\");\n\t}\n    }\n#endif\n    /* back fill the correct commandSize */\n    if (rc == 0) {\n\tuint16_t written = 0;\t\t/* dummy */\n\tuint32_t commandSize = tssAuthContext->commandSize;\n\tbuffer = tssAuthContext->commandBuffer + sizeof(TPMI_ST_COMMAND_TAG);\n\tTSS_UINT32_Marshalu(&commandSize, &written, &buffer, NULL);\n    }\n    /* record the interim cpBuffer and cpBufferSize before adding authorizations */\n    if (rc == 0) {\n\tuint32_t notCpBufferSize;\n\t\n\t/* cpBuffer does not include the header and handles */\n\tnotCpBufferSize = sizeof(TPMI_ST_COMMAND_TAG) + sizeof (uint32_t) + sizeof(TPM_CC) +\n\t\t\t  (sizeof(TPM_HANDLE) * tssAuthContext->commandHandleCount);\n\n\ttssAuthContext->cpBuffer = tssAuthContext->commandBuffer + notCpBufferSize;\n\ttssAuthContext->cpBufferSize = tssAuthContext->commandSize - notCpBufferSize;\n    }\n    return rc;\n}\n\n/* TSS_Unmarshal12() unmarshals the response parameter.\n\n   It returns an error if either there is no unmarshal function and out is not NULL or if there is\n   an unmarshal function and out is not NULL.\n\n   If there is no unmarshal function and out is NULL, the function is a noop.\n*/\n\nTPM_RC TSS_Unmarshal12(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t       RESPONSE_PARAMETERS *out)\n{\n    TPM_RC \trc = 0;\n    TPM_TAG \ttag;\n    uint8_t \t*buffer;    \n    uint32_t \tsize;\n\n    /* if there is an unmarshal function */\n    if (tssAuthContext->unmarshalOutFunction != NULL) {\n\t/* if there is a structure to unmarshal */\n\tif (out != NULL) {\n\t    if (rc == 0) {\n\t\t/* get the response tag, determines whether there are response authorizations to\n\t\t   unmarshal */\n\t\t/* tag not required for TPM 1.2, where there is no parameterSize to skip, but the\n\t\t   response unmarshal function uses a common prototype */\n\t\tbuffer = tssAuthContext->responseBuffer;\n\t\tsize = tssAuthContext->responseSize;\n\t\trc = TSS_TPM_TAG_Unmarshalu(&tag, &buffer, &size);\n\t    }\n\t    if (rc == 0) {\n\t\t/* move the buffer and size past the header */\n\t\tbuffer = tssAuthContext->responseBuffer +\n\t\t\t sizeof(TPM_TAG) + sizeof(uint32_t) + sizeof(TPM_RC);\n\t\tsize = tssAuthContext->responseSize -\n\t\t       (sizeof(TPM_TAG) + sizeof(uint32_t) + sizeof(TPM_RC));\n\t\trc = tssAuthContext->unmarshalOutFunction(out, tag, &buffer, &size);\n\t    }\n\t}\n\t/* caller error, no structure supplied to unmarshal */\n\telse {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_Unmarshal12: Command %08x requires response parameter structure\\n\",\n\t\t       tssAuthContext->commandCode);\n\t    rc = TSS_RC_OUT_PARAMETER;\n\t}\n    }\n    /* if there is no unmarshal function */\n    else {\n\t/* caller error, structure supplied but no unmarshal function */\n\tif (out != NULL) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_Unmarshal12: Command %08x does not take response parameter structure\\n\",\n\t\t       tssAuthContext->commandCode);\n\t    rc = TSS_RC_OUT_PARAMETER;\n\t}\n\t/* no unmarshal function and no response parameter structure is OK */\n    }\n    return rc;\n}\n\n/* TSS_SetCmdAuths12() appends a list of TPMS_AUTH12_COMMAND structures to the command buffer.  It\n   back fills the tag and paramSize.\n\n*/\n\nTPM_RC TSS_SetCmdAuths12(TSS_AUTH_CONTEXT \t*tssAuthContext,\n\t\t\t size_t \t\tnumSessions,\n\t\t\t TPMS_AUTH12_COMMAND \t*authC[])\n{\n    TPM_RC \t\trc = 0;\n    size_t\t\ti = 0;\n    TPM_TAG \t\ttag;\n    uint32_t \t\tcpBufferSize;\n    uint8_t \t\t*cpBuffer;\n    uint8_t \t\t*buffer;\n\n    if (rc == 0) {\n\t/* record the number of authorizations for the response */\n\ttssAuthContext->authCount = numSessions;\n\tswitch (numSessions) {\n\t  case 0:\n\t    tag = TPM_TAG_RQU_COMMAND;\n\t    break;\n\t  case 1:\n\t    tag = TPM_TAG_RQU_AUTH1_COMMAND;\n\t    break;\n\t  case 2:\n\t    tag = TPM_TAG_RQU_AUTH2_COMMAND;\n\t    break;\n\t  default:\n\t    if (tssVerbose) printf(\"TSS_SetCmdAuths12: Invalid number of sessions %u\\n\",\n\t\t\t\t   (unsigned int)numSessions);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    /* back fill the tag */\n    if (rc == 0) {\n\tuint16_t written = 0;\t\t/* dummy */\n\tbuffer = tssAuthContext->commandBuffer;\n\tTSS_UINT16_Marshalu(&tag, &written, &buffer, NULL);\n    }\n    /* get cpBuffer, command parameters */\n    if (rc == 0) {\n\trc = TSS_GetCpBuffer(tssAuthContext, &cpBufferSize, &cpBuffer);\n    }\n    /* index to the beginning of the authorization area, and range check the command buffer */\n    if (rc == 0) {\n\tcpBuffer += cpBufferSize;\n    }\n    for (i = 0 ; (rc == 0) && (i < numSessions) ; i++) {\n\tuint16_t written = 0;\n\tuint32_t size = MAX_COMMAND_SIZE - cpBufferSize;\n\t/* marshal authHandle */\n\tif (rc == 0) {\n\t    rc = TSS_UINT32_Marshalu(&authC[i]->sessionHandle, &written, &cpBuffer, &size); \n\t}\n\t/* marshal nonceOdd */\n\tif (rc == 0) {\n\t    rc = TSS_Array_Marshalu(authC[i]->nonce, SHA1_DIGEST_SIZE,\n\t\t\t\t   &written, &cpBuffer, &size); \n\t}\n\t/* marshal attributes */\n\tif (rc == 0) {\n\t    rc = TSS_UINT8_Marshalu(&authC[i]->sessionAttributes.val, &written, &cpBuffer, &size);\n\t}\n\t/* marshal HMAC */\n\tif (rc == 0) {\n\t    rc = TSS_Array_Marshalu(authC[i]->hmac, SHA1_DIGEST_SIZE,\n\t\t\t\t   &written, &cpBuffer, &size); \n\t}\n    }\t\n    if (rc == 0) {\n\tuint16_t written = 0;\t\t/* dummy */\n\tuint32_t commandSize;\n\t/* record command stream used size */\n\ttssAuthContext->commandSize = cpBuffer - tssAuthContext->commandBuffer;\n\t/* back fill the correct commandSize */\n\tbuffer = tssAuthContext->commandBuffer + sizeof(TPMI_ST_COMMAND_TAG);\n\tcommandSize = tssAuthContext->commandSize;\n\tTSS_UINT32_Marshalu(&commandSize, &written, &buffer, NULL);\n    }\n    return rc;\n}\n\n/* TSS_GetRspAuths12() unmarshals a response buffer into a list of list of TPMS_AUTH12_RESPONSE\n   structures.  This should not be called if the TPM returned a non-success response code.\n\n   Returns an error if the number of response auths requested is not equal to the number of command\n   auths, including zero.\n\n   If the response tag is TPM_TAG_RSP_COMMAND, the function is a noop (except for error checking).\n*/\n\nTPM_RC TSS_GetRspAuths12(TSS_AUTH_CONTEXT \t*tssAuthContext,\n\t\t\t size_t \t\tnumSessions,\n\t\t\t TPMS_AUTH12_RESPONSE\t*authR[])\n{\n    TPM_RC \trc = 0;\n    size_t\ti;\n    TPM_TAG \ttag;\n    uint32_t \toneAuthAreaSize = SHA1_DIGEST_SIZE + 1 + SHA1_DIGEST_SIZE;\n    uint32_t \tauthBufferSize;\n    uint8_t \t*authBuffer;\n\n    /* range check the response buffer size before the subtraction below */\n    if (rc == 0) {\n\tif ((sizeof(TPM_TAG) + sizeof(uint32_t) + sizeof(TPM_RC) +\n\t     (numSessions * oneAuthAreaSize)) <= tssAuthContext->responseSize) {\n\t    authBufferSize = tssAuthContext->responseSize -\n\t\t\t     (sizeof(TPM_TAG) + sizeof(uint32_t) + sizeof(TPM_RC));  \n\t}\n\telse {\n\t    if (tssVerbose) printf(\"TSS_GetRspAuths12: Invalid response size %u\\n\",\n\t\t\t\t   (unsigned int)tssAuthContext->responseSize);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    /* unmarshal the response tag */\n    if (rc == 0) {\n\tuint32_t size = tssAuthContext->responseSize;\n  \tuint8_t *buffer = tssAuthContext->responseBuffer;\n\trc = TSS_TPM_TAG_Unmarshalu(&tag, &buffer, &size);\n    }\n    /* sanity check the response tag, range checking below */\n    if (rc == 0) {\n\tswitch (tag) {\n\t  case TPM_TAG_RSP_COMMAND:\n\t    if (numSessions != 0) {\n\t\tif (tssVerbose) printf(\"TSS_GetRspAuths12: Invalid number of sessions %u\\n\",\n\t\t\t\t       (unsigned int)numSessions);\n\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t    }\n\t    break;\n\t  case TPM_TAG_RSP_AUTH1_COMMAND:\n\t    authBuffer = tssAuthContext->responseBuffer + tssAuthContext->responseSize \t/* end */\n\t\t\t - oneAuthAreaSize;\t/* minus one auth area */\n\t    authBufferSize = oneAuthAreaSize;\n\t    if (numSessions != 1) {\n\t\tif (tssVerbose) printf(\"TSS_GetRspAuths12: Invalid number of sessions %u\\n\",\n\t\t\t\t       (unsigned int)numSessions);\n\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t    }\n\t    break;\n\t  case TPM_TAG_RSP_AUTH2_COMMAND:\n\t    authBuffer = tssAuthContext->responseBuffer + tssAuthContext->responseSize \t/* end */\n\t\t\t - oneAuthAreaSize - oneAuthAreaSize ;\t/* minus two auth areas */\n\t    authBufferSize = oneAuthAreaSize + oneAuthAreaSize;\n\t    if (numSessions != 2) {\n\t\tif (tssVerbose) printf(\"TSS_GetRspAuths12: Invalid number of sessions %u\\n\",\n\t\t\t\t       (unsigned int)numSessions);\n\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t    }\n\t    break;\n\t  default:\n\t    if (tssVerbose) printf(\"TSS_GetRspAuths12: Bad tag %04x\\n\", tag);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t    break;\n\t}\n    }\n    /* unmarshal into the TPMS_AUTH12_RESPONSE structures */\n    for (i = 0 ; (rc == 0) && (i < numSessions) ; i++) {\n\t/* TPM 1.2 has fixed size auth area - nonceEven + continue + auth HMAC */\n\tif (rc == 0) {\n\t    rc = TSS_Array_Unmarshalu(authR[i]->nonce,\n\t\t\t\t     SHA1_DIGEST_SIZE, &authBuffer, &authBufferSize);\n\t}\t\n\tif (rc == 0) {\n\t    rc = TSS_UINT8_Unmarshalu(&authR[i]->sessionAttributes.val, &authBuffer, &authBufferSize);\n\t}\t\n\tif (rc == 0) {\n\t    rc = TSS_Array_Unmarshalu(authR[i]->hmac,\n\t\t\t\t     SHA1_DIGEST_SIZE, &authBuffer, &authBufferSize);\n\t}\t\n    }\t\n    return rc;\n}\n\n/* TSS_GetRpBuffer12() returns a pointer to the response parameter area.\n\n   NOTE could move to execute so it only has to be done once.\n*/\n\nTPM_RC TSS_GetRpBuffer12(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t uint32_t \t*rpBufferSize,\n\t\t\t uint8_t \t**rpBuffer,\n\t\t\t size_t\t\tnumSessions)\n{\n    TPM_RC \trc = 0;\n    uint32_t\theaderSize = sizeof(TPM_TAG) + sizeof (uint32_t) + sizeof(TPM_RC) +\n\t\t\t     (sizeof(TPM_HANDLE) * tssAuthContext->responseHandleCount);\n    uint32_t \toneAuthAreaSize = SHA1_DIGEST_SIZE + 1 + SHA1_DIGEST_SIZE;\n    \n    if (rc == 0) {\n\t*rpBuffer = tssAuthContext->responseBuffer + headerSize;\n\n\tif (headerSize + (numSessions * oneAuthAreaSize) <= tssAuthContext->responseSize) {\n\t    *rpBufferSize =\n\t\ttssAuthContext->responseSize - headerSize - (numSessions * oneAuthAreaSize);\n\t}\n\telse {\n\t    if (tssVerbose) printf(\"TSS_GetRpBuffer12: \"\n\t\t\t\t   \"response size %u too small for number of sessions %u\\n\",\n\t\t\t\t   tssAuthContext->responseSize, (unsigned int)numSessions);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_SetEncAuth() are called from the TPM 1.2 command pre-processor to record the location(s) of\n   the encrypted authorizations.\n\n   Cannot range check here, because command parameters have not been marshaled yet.\n   \n   NOTE: This is a bit of a hack, depending on the location being a fixed distance from the\n   beginning or end of the command buffer.  It could break if there is both a variable size argument\n   before and a variable number of authorizations or variable size argument after the location.\n\n   If this occurs, the pointers nust be set during marshaling, but this is more intrusive, requiring\n   TSS_AUTH_CONTEXT to be passed into the marshaling code.\n\n*/\n\nTPM_RC TSS_SetEncAuthOffset0(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t     int16_t offset)\n{\n    tssAuthContext->encAuthOffset0 = offset;\n    return 0;\n}\nTPM_RC TSS_SetEncAuthOffset1(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t     int16_t offset)\n{\n    tssAuthContext->encAuthOffset1 = offset;\n    return 0;\n}\nTPM_RC TSS_GetEncAuths(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t       uint8_t\t\t**encAuth0,\n\t\t       uint8_t\t\t**encAuth1)\n{\n    TPM_RC rc = 0;\n    \n    if (tssAuthContext->encAuthOffset0 > 0) {\n\tif ((uint16_t)tssAuthContext->encAuthOffset0 < tssAuthContext->cpBufferSize) {\n\t    *encAuth0 = tssAuthContext->commandBuffer + tssAuthContext->encAuthOffset0;\n\t}\n\telse {\n\t    if (tssVerbose) printf(\"TSS_GetEncAuths: \"\n\t\t\t\t   \"encAuthOffset0 %d too large for command buffer %u\\n\",\n\t\t\t\t   tssAuthContext->encAuthOffset0, tssAuthContext->cpBufferSize);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    else if (tssAuthContext->encAuthOffset0 < 0) {\n\tif ((uint16_t)(-tssAuthContext->encAuthOffset0) < tssAuthContext->commandSize) {\n\t    *encAuth0 = tssAuthContext->commandBuffer +\n\t\t\ttssAuthContext->commandSize + tssAuthContext->encAuthOffset0;\n\t}\n\telse {\n\t    if (tssVerbose) printf(\"TSS_GetEncAuths: \"\n\t\t\t\t   \"encAuthOffset0 %d too large for command buffer %u\\n\",\n\t\t\t\t   tssAuthContext->encAuthOffset0, tssAuthContext->commandSize);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    else {\n\t*encAuth0 = NULL;\n    }\n    if (tssAuthContext->encAuthOffset1 > 0) {\n\tif ((uint16_t)tssAuthContext->encAuthOffset1 < tssAuthContext->cpBufferSize) {\n\t    *encAuth1 = tssAuthContext->commandBuffer + tssAuthContext->encAuthOffset1;\n\t}\n\telse {\n\t    if (tssVerbose) printf(\"TSS_GetEncAuths: \"\n\t\t\t\t   \"encAuthOffset1 %u too large for command buffer %u\\n\",\n\t\t\t\t   tssAuthContext->encAuthOffset1, tssAuthContext->cpBufferSize);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    else if (tssAuthContext->encAuthOffset1 < 0) {\n\tif ((uint16_t)(-tssAuthContext->encAuthOffset1) < tssAuthContext->commandSize) {\n\t    *encAuth1 = tssAuthContext->commandBuffer +\n\t\t\ttssAuthContext->commandSize + tssAuthContext->encAuthOffset1;\n\t}\n\telse {\n\t    if (tssVerbose) printf(\"TSS_GetEncAuths: \"\n\t\t\t\t   \"encAuthOffset1 %d too large for command buffer %u\\n\",\n\t\t\t\t   tssAuthContext->encAuthOffset1, tssAuthContext->commandSize);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    else {\n\t*encAuth1 = NULL;\n    }\n    return rc;\n}\n\nTPM_RC TSS_SetSessionNumber(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t   uint16_t sessionNumber)\n{\n    TPM_RC\trc = 0;\n    \n    tssAuthContext->sessionNumber = sessionNumber;\n    if (sessionNumber > 1) {\n\tif (tssVerbose) printf(\"TSS_SetSessionNumber: %u out of range\\n\",\n\t\t\t       sessionNumber);\n\trc = TSS_RC_SESSION_NUMBER;\n    }\n    return rc;\n}\nTPM_RC TSS_GetSessionNumber(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t    uint16_t *sessionNumber)\n{\n    *sessionNumber = tssAuthContext->sessionNumber;\n    return 0;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssauth20.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM 2.0 TSS Authorization\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2024.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* This layer handles command and response packet authorization parameters. */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdarg.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tsstransmit.h>\n#include \"tssproperties.h\"\n#include <ibmtss/tssresponsecode.h>\n\n#include \"tssntc.h\"\n#include \"tssauth.h\"\n#include \"tssauth20.h\"\n\nextern int tssVerbose;\nextern int tssVverbose;\n\ntypedef struct MARSHAL_TABLE {\n    TPM_CC \t\t\tcommandCode;\n    const char \t\t\t*commandText;\n    MarshalInFunction_t \tmarshalInFunction;\t/* marshal input command */\n    UnmarshalOutFunction_t \tunmarshalOutFunction;\t/* unmarshal output response */\n#ifndef TPM_TSS_NOCMDCHECK\n    UnmarshalInFunction_t\tunmarshalInFunction;\t/* unmarshal input command for parameter\n\t\t\t\t\t\t\t   checking */\n#endif\n} MARSHAL_TABLE;\n\nstatic const MARSHAL_TABLE marshalTable [] = {\n\n    {TPM_CC_Startup, \"TPM2_Startup\",\n     (MarshalInFunction_t)TSS_Startup_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Startup_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Shutdown, \"TPM2_Shutdown\",\n     (MarshalInFunction_t)TSS_Shutdown_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Shutdown_In_Unmarshal\n#endif\n    },\n    {TPM_CC_SelfTest, \"TPM2_SelfTest\",\n     (MarshalInFunction_t)TSS_SelfTest_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)SelfTest_In_Unmarshal\n#endif\n    },\n    {TPM_CC_IncrementalSelfTest, \"TPM2_IncrementalSelfTest\",\n     (MarshalInFunction_t)TSS_IncrementalSelfTest_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_IncrementalSelfTest_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)IncrementalSelfTest_In_Unmarshal\n#endif\n    },\n    {TPM_CC_GetTestResult, \"TPM2_GetTestResult\",\n     NULL,\n     (UnmarshalOutFunction_t)TSS_GetTestResult_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,NULL\n#endif\n    },\n    {TPM_CC_StartAuthSession, \"TPM2_StartAuthSession\",\n     (MarshalInFunction_t)TSS_StartAuthSession_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_StartAuthSession_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)StartAuthSession_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyRestart, \"TPM2_PolicyRestart\",\n     (MarshalInFunction_t)TSS_PolicyRestart_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyRestart_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Create, \"TPM2_Create\",\n     (MarshalInFunction_t)TSS_Create_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Create_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Create_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Load, \"TPM2_Load\",\n     (MarshalInFunction_t)TSS_Load_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Load_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Load_In_Unmarshal\n#endif\n    },\n    {TPM_CC_LoadExternal, \"TPM2_LoadExternal\",\n     (MarshalInFunction_t)TSS_LoadExternal_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_LoadExternal_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)LoadExternal_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ReadPublic, \"TPM2_ReadPublic\",\n     (MarshalInFunction_t)TSS_ReadPublic_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ReadPublic_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ReadPublic_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ActivateCredential, \"TPM2_ActivateCredential\",\n     (MarshalInFunction_t)TSS_ActivateCredential_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ActivateCredential_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ActivateCredential_In_Unmarshal\n#endif\n    },\n    {TPM_CC_MakeCredential, \"TPM2_MakeCredential\",\n     (MarshalInFunction_t)TSS_MakeCredential_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_MakeCredential_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)MakeCredential_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Unseal, \"TPM2_Unseal\",\n     (MarshalInFunction_t)TSS_Unseal_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Unseal_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Unseal_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ObjectChangeAuth, \"TPM2_ObjectChangeAuth\",\n     (MarshalInFunction_t)TSS_ObjectChangeAuth_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ObjectChangeAuth_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ObjectChangeAuth_In_Unmarshal\n#endif\n    },\n    {TPM_CC_CreateLoaded, \"TPM2_CreateLoaded\",\n     (MarshalInFunction_t)TSS_CreateLoaded_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_CreateLoaded_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)CreateLoaded_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Duplicate, \"TPM2_Duplicate\",\n     (MarshalInFunction_t)TSS_Duplicate_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Duplicate_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Duplicate_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Rewrap, \"TPM2_Rewrap\",\n     (MarshalInFunction_t)TSS_Rewrap_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Rewrap_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Rewrap_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Import, \"TPM2_Import\",\n     (MarshalInFunction_t)TSS_Import_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Import_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Import_In_Unmarshal\n#endif\n    },\n    {TPM_CC_RSA_Encrypt, \"TPM2_RSA_Encrypt\",\n     (MarshalInFunction_t)TSS_RSA_Encrypt_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_RSA_Encrypt_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)RSA_Encrypt_In_Unmarshal\n#endif\n    },\n    {TPM_CC_RSA_Decrypt, \"TPM2_RSA_Decrypt\",\n     (MarshalInFunction_t)TSS_RSA_Decrypt_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_RSA_Decrypt_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)RSA_Decrypt_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ECDH_KeyGen, \"TPM2_ECDH_KeyGen\",\n     (MarshalInFunction_t)TSS_ECDH_KeyGen_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ECDH_KeyGen_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ECDH_KeyGen_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ECDH_ZGen, \"TPM2_ECDH_ZGen\",\n     (MarshalInFunction_t)TSS_ECDH_ZGen_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ECDH_ZGen_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ECDH_ZGen_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ECC_Encrypt, \"TPM2_ECC_Encrypt\",\n     (MarshalInFunction_t)TSS_ECC_Encrypt_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ECC_Encrypt_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ECC_Encrypt_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ECC_Decrypt, \"TPM2_ECC_Decrypt\",\n     (MarshalInFunction_t)TSS_ECC_Decrypt_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ECC_Decrypt_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ECC_Decrypt_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ECC_Parameters, \"TPM2_ECC_Parameters\",\n     (MarshalInFunction_t)TSS_ECC_Parameters_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ECC_Parameters_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ECC_Parameters_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ZGen_2Phase, \"TPM2_ZGen_2Phase\",\n     (MarshalInFunction_t)TSS_ZGen_2Phase_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ZGen_2Phase_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ZGen_2Phase_In_Unmarshal\n#endif\n    },\n    {TPM_CC_EncryptDecrypt, \"TPM2_EncryptDecrypt\",\n     (MarshalInFunction_t)TSS_EncryptDecrypt_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_EncryptDecrypt_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)EncryptDecrypt_In_Unmarshal\n#endif\n    },\n    {TPM_CC_EncryptDecrypt2, \"TPM2_EncryptDecrypt2\",\n     (MarshalInFunction_t)TSS_EncryptDecrypt2_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_EncryptDecrypt2_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)EncryptDecrypt2_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Hash, \"TPM2_Hash\",\n     (MarshalInFunction_t)TSS_Hash_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Hash_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Hash_In_Unmarshal\n#endif\n    },\n    {TPM_CC_HMAC, \"TPM2_HMAC\",\n     (MarshalInFunction_t)TSS_HMAC_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_HMAC_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)HMAC_In_Unmarshal\n#endif\n    },\n    {TPM_CC_GetRandom, \"TPM2_GetRandom\",\n     (MarshalInFunction_t)TSS_GetRandom_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_GetRandom_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)GetRandom_In_Unmarshal\n#endif\n    },\n    {TPM_CC_StirRandom, \"TPM2_StirRandom\",\n     (MarshalInFunction_t)TSS_StirRandom_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)StirRandom_In_Unmarshal\n#endif\n    },\n    {TPM_CC_HMAC_Start, \"TPM2_HMAC_Start\",\n     (MarshalInFunction_t)TSS_HMAC_Start_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_HMAC_Start_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)HMAC_Start_In_Unmarshal\n#endif\n    },\n    {TPM_CC_HashSequenceStart, \"TPM2_HashSequenceStart\",\n     (MarshalInFunction_t)TSS_HashSequenceStart_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_HashSequenceStart_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)HashSequenceStart_In_Unmarshal\n#endif\n    },\n    {TPM_CC_SequenceUpdate, \"TPM2_SequenceUpdate\",\n     (MarshalInFunction_t)TSS_SequenceUpdate_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)SequenceUpdate_In_Unmarshal\n#endif\n    },\n    {TPM_CC_SequenceComplete, \"TPM2_SequenceComplete\",\n     (MarshalInFunction_t)TSS_SequenceComplete_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_SequenceComplete_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)SequenceComplete_In_Unmarshal\n#endif\n    },\n    {TPM_CC_EventSequenceComplete, \"TPM2_EventSequenceComplete\",\n     (MarshalInFunction_t)TSS_EventSequenceComplete_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_EventSequenceComplete_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)EventSequenceComplete_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Certify, \"TPM2_Certify\",\n     (MarshalInFunction_t)TSS_Certify_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Certify_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Certify_In_Unmarshal\n#endif\n    },\n    {TPM_CC_CertifyX509, \"TPM2_CertifyX509\",\n     (MarshalInFunction_t)TSS_CertifyX509_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_CertifyX509_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)CertifyX509_In_Unmarshal\n#endif\n    },\n    {TPM_CC_CertifyCreation, \"TPM2_CertifyCreation\",\n     (MarshalInFunction_t)TSS_CertifyCreation_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_CertifyCreation_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)CertifyCreation_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Quote, \"TPM2_Quote\",\n     (MarshalInFunction_t)TSS_Quote_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Quote_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Quote_In_Unmarshal\n#endif\n    },\n    {TPM_CC_GetSessionAuditDigest, \"TPM2_GetSessionAuditDigest\",\n     (MarshalInFunction_t)TSS_GetSessionAuditDigest_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_GetSessionAuditDigest_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)GetSessionAuditDigest_In_Unmarshal\n#endif\n    },\n    {TPM_CC_GetCommandAuditDigest, \"TPM2_GetCommandAuditDigest\",\n     (MarshalInFunction_t)TSS_GetCommandAuditDigest_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_GetCommandAuditDigest_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)GetCommandAuditDigest_In_Unmarshal\n#endif\n    },\n    {TPM_CC_GetTime, \"TPM2_GetTime\",\n     (MarshalInFunction_t)TSS_GetTime_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_GetTime_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)GetTime_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Commit, \"TPM2_Commit\",\n     (MarshalInFunction_t)TSS_Commit_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Commit_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Commit_In_Unmarshal\n#endif\n    },\n    {TPM_CC_EC_Ephemeral, \"TPM2_EC_Ephemeral\",\n     (MarshalInFunction_t)TSS_EC_Ephemeral_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_EC_Ephemeral_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)EC_Ephemeral_In_Unmarshal\n#endif\n    },\n    {TPM_CC_VerifySignature, \"TPM2_VerifySignature\",\n     (MarshalInFunction_t)TSS_VerifySignature_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_VerifySignature_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)VerifySignature_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Sign, \"TPM2_Sign\",\n     (MarshalInFunction_t)TSS_Sign_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_Sign_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Sign_In_Unmarshal\n#endif\n    },\n    {TPM_CC_SetCommandCodeAuditStatus, \"TPM2_SetCommandCodeAuditStatus\",\n     (MarshalInFunction_t)TSS_SetCommandCodeAuditStatus_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)SetCommandCodeAuditStatus_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PCR_Extend, \"TPM2_PCR_Extend\",\n     (MarshalInFunction_t)TSS_PCR_Extend_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PCR_Extend_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PCR_Event, \"TPM2_PCR_Event\",\n     (MarshalInFunction_t)TSS_PCR_Event_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_PCR_Event_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PCR_Event_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PCR_Read, \"TPM2_PCR_Read\",\n     (MarshalInFunction_t)TSS_PCR_Read_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_PCR_Read_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PCR_Read_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PCR_Allocate, \"TPM2_PCR_Allocate\",\n     (MarshalInFunction_t)TSS_PCR_Allocate_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_PCR_Allocate_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PCR_Allocate_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PCR_SetAuthPolicy, \"TPM2_PCR_SetAuthPolicy\",\n     (MarshalInFunction_t)TSS_PCR_SetAuthPolicy_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PCR_SetAuthPolicy_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PCR_SetAuthValue, \"TPM2_PCR_SetAuthValue\",\n     (MarshalInFunction_t)TSS_PCR_SetAuthValue_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PCR_SetAuthValue_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PCR_Reset, \"TPM2_PCR_Reset\",\n     (MarshalInFunction_t)TSS_PCR_Reset_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PCR_Reset_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicySigned, \"TPM2_PolicySigned\",\n     (MarshalInFunction_t)TSS_PolicySigned_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_PolicySigned_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicySigned_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicySecret, \"TPM2_PolicySecret\",\n     (MarshalInFunction_t)TSS_PolicySecret_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_PolicySecret_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicySecret_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyTicket, \"TPM2_PolicyTicket\",\n     (MarshalInFunction_t)TSS_PolicyTicket_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyTicket_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyOR, \"TPM2_PolicyOR\",\n     (MarshalInFunction_t)TSS_PolicyOR_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyOR_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyPCR, \"TPM2_PolicyPCR\",\n     (MarshalInFunction_t)TSS_PolicyPCR_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyPCR_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyLocality, \"TPM2_PolicyLocality\",\n     (MarshalInFunction_t)TSS_PolicyLocality_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyLocality_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyNV, \"TPM2_PolicyNV\",\n     (MarshalInFunction_t)TSS_PolicyNV_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyNV_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyAuthorizeNV, \"TPM2_PolicyAuthorizeNV\",\n     (MarshalInFunction_t)TSS_PolicyAuthorizeNV_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyAuthorizeNV_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyCounterTimer, \"TPM2_PolicyCounterTimer\",\n     (MarshalInFunction_t)TSS_PolicyCounterTimer_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyCounterTimer_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyCommandCode, \"TPM2_PolicyCommandCode\",\n     (MarshalInFunction_t)TSS_PolicyCommandCode_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyCommandCode_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyPhysicalPresence, \"TPM2_PolicyPhysicalPresence\",\n     (MarshalInFunction_t)TSS_PolicyPhysicalPresence_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyPhysicalPresence_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyCpHash, \"TPM2_PolicyCpHash\",\n     (MarshalInFunction_t)TSS_PolicyCpHash_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyCpHash_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyNameHash, \"TPM2_PolicyNameHash\",\n     (MarshalInFunction_t)TSS_PolicyNameHash_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyNameHash_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyDuplicationSelect, \"TPM2_PolicyDuplicationSelect\",\n     (MarshalInFunction_t)TSS_PolicyDuplicationSelect_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyDuplicationSelect_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyAuthorize, \"TPM2_PolicyAuthorize\",\n     (MarshalInFunction_t)TSS_PolicyAuthorize_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyAuthorize_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyAuthValue, \"TPM2_PolicyAuthValue\",\n     (MarshalInFunction_t)TSS_PolicyAuthValue_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyAuthValue_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyPassword, \"TPM2_PolicyPassword\",\n     (MarshalInFunction_t)TSS_PolicyPassword_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyPassword_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyGetDigest, \"TPM2_PolicyGetDigest\",\n     (MarshalInFunction_t)TSS_PolicyGetDigest_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_PolicyGetDigest_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyGetDigest_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyNvWritten, \"TPM2_PolicyNvWritten\",\n     (MarshalInFunction_t)TSS_PolicyNvWritten_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyNvWritten_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyTemplate, \"TPM2_PolicyTemplate\",\n     (MarshalInFunction_t)TSS_PolicyTemplate_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyTemplate_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyCapability, \"TPM2_PolicyCapability\",\n     (MarshalInFunction_t)TSS_PolicyCapability_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyCapability_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PolicyParameters, \"TPM2_PolicyParameters\",\n     (MarshalInFunction_t)TSS_PolicyParameters_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PolicyParameters_In_Unmarshal\n#endif\n    },\n    {TPM_CC_CreatePrimary, \"TPM2_CreatePrimary\",\n     (MarshalInFunction_t)TSS_CreatePrimary_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_CreatePrimary_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)CreatePrimary_In_Unmarshal\n#endif\n    },\n    {TPM_CC_HierarchyControl, \"TPM2_HierarchyControl\",\n     (MarshalInFunction_t)TSS_HierarchyControl_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)HierarchyControl_In_Unmarshal\n#endif\n    },\n    {TPM_CC_SetPrimaryPolicy, \"TPM2_SetPrimaryPolicy\",\n     (MarshalInFunction_t)TSS_SetPrimaryPolicy_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)SetPrimaryPolicy_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ChangePPS, \"TPM2_ChangePPS\",\n     (MarshalInFunction_t)TSS_ChangePPS_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ChangePPS_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ChangeEPS, \"TPM2_ChangeEPS\",\n     (MarshalInFunction_t)TSS_ChangeEPS_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ChangeEPS_In_Unmarshal\n#endif\n    },\n    {TPM_CC_Clear, \"TPM2_Clear\",\n     (MarshalInFunction_t)TSS_Clear_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)Clear_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ClearControl, \"TPM2_ClearControl\",\n     (MarshalInFunction_t)TSS_ClearControl_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ClearControl_In_Unmarshal\n#endif\n    },\n    {TPM_CC_HierarchyChangeAuth, \"TPM2_HierarchyChangeAuth\",\n     (MarshalInFunction_t)TSS_HierarchyChangeAuth_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)HierarchyChangeAuth_In_Unmarshal\n#endif\n    },\n    {TPM_CC_DictionaryAttackLockReset, \"TPM2_DictionaryAttackLockReset\",\n     (MarshalInFunction_t)TSS_DictionaryAttackLockReset_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)DictionaryAttackLockReset_In_Unmarshal\n#endif\n    },\n    {TPM_CC_DictionaryAttackParameters, \"TPM2_DictionaryAttackParameters\",\n     (MarshalInFunction_t)TSS_DictionaryAttackParameters_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)DictionaryAttackParameters_In_Unmarshal\n#endif\n    },\n    {TPM_CC_PP_Commands, \"TPM2_PP_Commands\",\n     (MarshalInFunction_t)TSS_PP_Commands_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)PP_Commands_In_Unmarshal\n#endif\n    },\n    {TPM_CC_SetAlgorithmSet, \"TPM2_SetAlgorithmSet\",\n     (MarshalInFunction_t)TSS_SetAlgorithmSet_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)SetAlgorithmSet_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ContextSave, \"TPM2_ContextSave\",\n     (MarshalInFunction_t)TSS_ContextSave_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ContextSave_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ContextSave_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ContextLoad, \"TPM2_ContextLoad\",\n     (MarshalInFunction_t)TSS_ContextLoad_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_ContextLoad_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ContextLoad_In_Unmarshal\n#endif\n    },\n    {TPM_CC_FlushContext, \"TPM2_FlushContext\",\n     (MarshalInFunction_t)TSS_FlushContext_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)FlushContext_In_Unmarshal\n#endif\n    },\n    {TPM_CC_EvictControl, \"TPM2_EvictControl\",\n     (MarshalInFunction_t)TSS_EvictControl_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)EvictControl_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ReadClock, \"TPM2_ReadClock\",\n     NULL,\n     (UnmarshalOutFunction_t)TSS_ReadClock_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,NULL\n#endif\n    },\n    {TPM_CC_ClockSet, \"TPM2_ClockSet\",\n     (MarshalInFunction_t)TSS_ClockSet_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ClockSet_In_Unmarshal\n#endif\n    },\n    {TPM_CC_ClockRateAdjust, \"TPM2_ClockRateAdjust\",\n     (MarshalInFunction_t)TSS_ClockRateAdjust_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)ClockRateAdjust_In_Unmarshal\n#endif\n    },\n    {TPM_CC_GetCapability, \"TPM2_GetCapability\",\n     (MarshalInFunction_t)TSS_GetCapability_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_GetCapability_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)GetCapability_In_Unmarshal\n#endif\n    },\n    {TPM_CC_TestParms, \"TPM2_TestParms\",\n     (MarshalInFunction_t)TSS_TestParms_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)TestParms_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_DefineSpace, \"TPM2_NV_DefineSpace\",\n     (MarshalInFunction_t)TSS_NV_DefineSpace_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_DefineSpace_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_UndefineSpace, \"TPM2_NV_UndefineSpace\",\n     (MarshalInFunction_t)TSS_NV_UndefineSpace_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_UndefineSpace_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_UndefineSpaceSpecial, \"TPM2_NV_UndefineSpaceSpecial\",\n     (MarshalInFunction_t)TSS_NV_UndefineSpaceSpecial_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_UndefineSpaceSpecial_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_ReadPublic, \"TPM2_NV_ReadPublic\",\n     (MarshalInFunction_t)TSS_NV_ReadPublic_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_NV_ReadPublic_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_ReadPublic_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_Write, \"TPM2_NV_Write\",\n     (MarshalInFunction_t)TSS_NV_Write_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_Write_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_Increment, \"TPM2_NV_Increment\",\n     (MarshalInFunction_t)TSS_NV_Increment_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_Increment_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_Extend, \"TPM2_NV_Extend\",\n     (MarshalInFunction_t)TSS_NV_Extend_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_Extend_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_SetBits, \"TPM2_NV_SetBits\",\n     (MarshalInFunction_t)TSS_NV_SetBits_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_SetBits_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_WriteLock, \"TPM2_NV_WriteLock\",\n     (MarshalInFunction_t)TSS_NV_WriteLock_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_WriteLock_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_GlobalWriteLock, \"TPM2_NV_GlobalWriteLock\",\n     (MarshalInFunction_t)TSS_NV_GlobalWriteLock_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_GlobalWriteLock_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_Read, \"TPM2_NV_Read\",\n     (MarshalInFunction_t)TSS_NV_Read_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_NV_Read_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_Read_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_ReadLock, \"TPM2_NV_ReadLock\",\n     (MarshalInFunction_t)TSS_NV_ReadLock_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_ReadLock_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_ChangeAuth, \"TPM2_NV_ChangeAuth\",\n     (MarshalInFunction_t)TSS_NV_ChangeAuth_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_ChangeAuth_In_Unmarshal\n#endif\n    },\n    {TPM_CC_NV_Certify, \"TPM2_NV_Certify\",\n     (MarshalInFunction_t)TSS_NV_Certify_In_Marshalu,\n     (UnmarshalOutFunction_t)TSS_NV_Certify_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)NV_Certify_In_Unmarshal\n#endif\n    },\n#ifdef TPM_TSS_NUVOTON\n    {NTC2_CC_PreConfig,\"NTC2_CC_PreConfig\",\n     (MarshalInFunction_t)TSS_NTC2_PreConfig_In_Marshalu,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,(UnmarshalInFunction_t)TSS_NTC2_PreConfig_In_Unmarshalu\n#endif\n    },\n    {NTC2_CC_LockPreConfig,\"NTC2_CC_LockPreConfig\",\n     NULL,\n     NULL\n#ifndef TPM_TSS_NOCMDCHECK\n     ,NULL\n#endif\n    },\n    {NTC2_CC_GetConfig,\"NTC2_CC_GetConfig\",\n     NULL,\n     (UnmarshalOutFunction_t)TSS_NTC2_GetConfig_Out_Unmarshalu\n#ifndef TPM_TSS_NOCMDCHECK\n     ,NULL\n#endif\n    },\n\n#endif\t/* TPM_TSS_NUVOTON */\n};\n\n/* TSS_MarshalTable_Process() indexes into the command marshal table, and saves the marshal and\n   unmarshal functions */\n\nstatic TPM_RC TSS_MarshalTable_Process(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t       TPM_CC commandCode)\n{\n    TPM_RC rc = 0;\n    size_t index;\n    int found = FALSE;\n\n    /* get the command index in the dispatch table */\n    for (index = 0 ; index < (sizeof(marshalTable) / sizeof(MARSHAL_TABLE)) ; (index)++) {\n\tif (marshalTable[index].commandCode == commandCode) {\n\t    found = TRUE;\n\t    break;\n\t}\n    }\n    if (found) {\n\ttssAuthContext->commandCode = commandCode;\n\ttssAuthContext->commandText = marshalTable[index].commandText;\n\ttssAuthContext->marshalInFunction = marshalTable[index].marshalInFunction;\n\ttssAuthContext->unmarshalOutFunction = marshalTable[index].unmarshalOutFunction;\n#ifndef TPM_TSS_NOCMDCHECK\n\ttssAuthContext->unmarshalInFunction = marshalTable[index].unmarshalInFunction;\n#endif\n    }\n    else {\n\tif (tssVerbose) printf(\"TSS_MarshalTable_Process: \"\n\t\t\t       \"commandCode %08x not found in marshal table\\n\",\n\t\t\t       commandCode);\n\trc = TSS_RC_COMMAND_UNIMPLEMENTED;\n    }\n    return rc;\n}\n\n/* TSS_Marshal() marshals the input parameters into the TSS Authorization context.\n\n   It also sets other member of the context in preparation for the rest of the sequence.\n*/\n\nTPM_RC TSS_Marshal(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t   COMMAND_PARAMETERS *in,\n\t\t   TPM_CC commandCode)\n{\n    TPM_RC \t\trc = 0;\n    TPMI_ST_COMMAND_TAG tag = TPM_ST_NO_SESSIONS;\t/* default until sessions are added */\n    uint8_t \t\t*buffer;\t\t\t/* for marshaling */\n#ifndef TPM_TSS_NOCMDCHECK\n    uint8_t \t\t*bufferu;\t\t\t/* for test unmarshaling */\n#endif\n    uint32_t \t\tsize;\n\n    /* index from command code to table and save items for this command */\n    if (rc == 0) {\n\trc = TSS_MarshalTable_Process(tssAuthContext, commandCode);\n    }\n    /* get the number of command and response handles from the TPM table */\n    if (rc == 0) {\n\ttssAuthContext->tpmCommandIndex = CommandCodeToCommandIndex(commandCode);\n\tif (tssAuthContext->tpmCommandIndex == UNIMPLEMENTED_COMMAND_INDEX) {\n\t    if (tssVerbose) printf(\"TSS_Marshal: \"\n\t\t\t\t   \"commandCode %08x not found in command attributes table\\n\",\n\t\t\t\t   commandCode);\n\t    rc = TSS_RC_COMMAND_UNIMPLEMENTED;\n\t}\n    }\n    if (rc == 0) {\n\ttssAuthContext->commandHandleCount =\n\t    getCommandHandleCount(tssAuthContext->tpmCommandIndex);\n\ttssAuthContext->responseHandleCount =\n\t    getresponseHandleCount(tssAuthContext->tpmCommandIndex);\n    }\n    if (rc == 0) {\n\t/* make a copy of the command buffer and size since the marshal functions move them */\n\tbuffer = tssAuthContext->commandBuffer;\n\tsize = sizeof(tssAuthContext->commandBuffer);\n\t/* marshal header, preliminary tag and command size */\n\trc = TSS_TPMI_ST_COMMAND_TAG_Marshalu(&tag, &tssAuthContext->commandSize, &buffer, &size);\n    }\n    if (rc == 0) {\n\tuint32_t commandSize = tssAuthContext->commandSize;\n\trc = TSS_UINT32_Marshalu(&commandSize, &tssAuthContext->commandSize, &buffer, &size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_CC_Marshalu(&commandCode, &tssAuthContext->commandSize, &buffer, &size);\n    }\n    if (rc == 0) {\n#ifndef TPM_TSS_NOCMDCHECK\n\t/* save pointer to marshaled data for test unmarshal */\n\tbufferu = buffer +\n\t\t  tssAuthContext->commandHandleCount * sizeof(TPM_HANDLE);\n#endif\n\t/* if there is a marshal function */\n\tif (tssAuthContext->marshalInFunction != NULL) {\n\t    /* if there is a structure to marshal */\n\t    if (in != NULL) {\n\t\trc = tssAuthContext->marshalInFunction(in, &tssAuthContext->commandSize,\n\t\t\t\t\t\t       &buffer, &size);\n\t    }\n\t    /* caller error, no structure supplied to marshal */\n\t    else {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_Marshal: Command %08x requires command parameter structure\\n\",\n\t\t\t   commandCode);\n\t\trc = TSS_RC_IN_PARAMETER;\n\t    }\n\t}\n\t/* if there is no marshal function */\n\telse {\n\t    /* caller error, supplied structure but there is no marshal function */\n\t    if (in != NULL) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_Marshal: Command %08x does not take command parameter structure\\n\",\n\t\t\t   commandCode);\n\t\trc = TSS_RC_IN_PARAMETER;\n\t    }\n\t    /* no marshal function and no command parameter structure is OK */\n\t}\n    }\n#ifndef TPM_TSS_NOCMDCHECK\n    /* unmarshal to validate the input parameters */\n    if ((rc == 0) && (tssAuthContext->unmarshalInFunction != NULL)) {\n\tCOMMAND_PARAMETERS *target = NULL;\n\tTPM_HANDLE \thandles[MAX_HANDLE_NUM];\n\tif (rc == 0) {\n\t    rc = TSS_Malloc((unsigned char **)&target,\n\t\t\t    sizeof(COMMAND_PARAMETERS));\t/* freed @1 */\n\t}\n\tif (rc == 0) {\n\t    size = (uint32_t)(sizeof(tssAuthContext->commandBuffer) -\n\t\t\t      (tssAuthContext->commandHandleCount * sizeof(TPM_HANDLE)));\n\t    rc = tssAuthContext->unmarshalInFunction(target, &bufferu, &size, handles);\n\t    if ((rc != 0) && tssVerbose) {\n\t\tprintf(\"TSS_Marshal: Invalid command parameter\\n\");\n\t    }\n\t}\n\tfree(target);\t\t/* @1 */\n    }\n#endif\n    /* back fill the correct commandSize */\n    if (rc == 0) {\n\tuint16_t written = 0;\t\t/* dummy */\n\tuint32_t commandSize = tssAuthContext->commandSize;\n\tbuffer = tssAuthContext->commandBuffer + sizeof(TPMI_ST_COMMAND_TAG);\n\tTSS_UINT32_Marshalu(&commandSize, &written, &buffer, NULL);\n    }\n    /* record the interim cpBuffer and cpBufferSize before adding authorizations */\n    if (rc == 0) {\n\tuint32_t notCpBufferSize;\n\n\t/* cpBuffer does not include the header and handles */\n\tnotCpBufferSize = (uint32_t)(sizeof(TPMI_ST_COMMAND_TAG) + sizeof (uint32_t) + sizeof(TPM_CC) +\n\t\t\t\t     (sizeof(TPM_HANDLE) * tssAuthContext->commandHandleCount));\n\n\ttssAuthContext->cpBuffer = tssAuthContext->commandBuffer + notCpBufferSize;\n\ttssAuthContext->cpBufferSize = tssAuthContext->commandSize - notCpBufferSize;\n    }\n    return rc;\n}\n\n/* TSS_Unmarshal() unmarshals the response parameter.\n\n   It returns an error if either there is no unmarshal function and out is not NULL or if there is\n   an unmarshal function and out is not NULL.\n\n   If there is no unmarshal function and out is NULL, the function is a noop.\n*/\n\nTPM_RC TSS_Unmarshal(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t     RESPONSE_PARAMETERS *out)\n{\n    TPM_RC \trc = 0;\n    TPM_ST \ttag;\n    uint8_t \t*buffer;\n    uint32_t \tsize;\n\n    /* if there is an unmarshal function */\n    if (tssAuthContext->unmarshalOutFunction != NULL) {\n\t/* if there is a structure to unmarshal */\n\tif (out != NULL) {\n\t    if (rc == 0) {\n\t\t/* get the response tag, determines whether there is a response parameterSize to\n\t\t   unmarshal */\n\t\tbuffer = tssAuthContext->responseBuffer;\n\t\tsize = tssAuthContext->responseSize;\n\t\trc = TSS_TPM_ST_Unmarshalu(&tag, &buffer, &size);\n\t    }\n\t    if (rc == 0) {\n\t\t/* move the buffer and size past the header */\n\t\tbuffer = tssAuthContext->responseBuffer +\n\t\t\t sizeof(TPM_ST) + sizeof(uint32_t) + sizeof(TPM_RC);\n\t\tsize = tssAuthContext->responseSize -\n\t\t       (sizeof(TPM_ST) + sizeof(uint32_t) + sizeof(TPM_RC));\n\t\trc = tssAuthContext->unmarshalOutFunction(out, tag, &buffer, &size);\n\t    }\n\t}\n\t/* caller error, no structure supplied to unmarshal */\n\telse {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_Unmarshal: Command %08x requires response parameter structure\\n\",\n\t\t       tssAuthContext->commandCode);\n\t    rc = TSS_RC_OUT_PARAMETER;\n\t}\n    }\n    /* if there is no unmarshal function */\n    else {\n\t/* caller error, structure supplied but no unmarshal function */\n\tif (out != NULL) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_Unmarshal: Command %08x does not take response parameter structure\\n\",\n\t\t       tssAuthContext->commandCode);\n\t    rc = TSS_RC_OUT_PARAMETER;\n\t}\n\t/* no unmarshal function and no response parameter structure is OK */\n    }\n    return rc;\n}\n\n/* TSS_SetCmdAuths() adds a list of TPMS_AUTH_COMMAND structures to the command buffer.\n\n   The arguments are a NULL terminated list of TPMS_AUTH_COMMAND * structures.\n */\n\nTPM_RC TSS_SetCmdAuths(TSS_AUTH_CONTEXT *tssAuthContext, ...)\n{\n    TPM_RC \t\trc = 0;\n    va_list\t\tap;\n    uint16_t \t\tauthorizationSize;\t/* does not include 4 bytes of size */\n    TPMS_AUTH_COMMAND \t*authCommand = NULL;\n    int \t\tdone;\n    uint32_t \t\tcpBufferSize;\n    uint8_t \t\t*cpBuffer;\n    uint8_t \t\t*buffer;\n\n    /* calculate size of authorization area */\n    done = FALSE;\n    authorizationSize = 0;\n    va_start(ap, tssAuthContext);\n    while ((rc == 0) && !done){\n\tauthCommand = va_arg(ap, TPMS_AUTH_COMMAND *);\n\tif (authCommand != NULL) {\n\t    rc = TSS_TPMS_AUTH_COMMAND_Marshalu(authCommand, &authorizationSize, NULL, NULL);\n\t}\n\telse {\n\t    done = TRUE;\n\t}\n    }\n    va_end(ap);\n    /* command called with authorizations */\n    if (authorizationSize != 0) {\n\t/* back fill the tag TPM_ST_SESSIONS */\n\tif (rc == 0) {\n\t    uint16_t written = 0;\t\t/* dummy */\n\t    TPMI_ST_COMMAND_TAG tag = TPM_ST_SESSIONS;\n\t    buffer = tssAuthContext->commandBuffer;\n\t    TSS_TPMI_ST_COMMAND_TAG_Marshalu(&tag, &written, &buffer, NULL);\n\t}\n\t/* get cpBuffer, command parameters */\n\tif (rc == 0) {\n\t    rc = TSS_GetCpBuffer(tssAuthContext, &cpBufferSize, &cpBuffer);\n\t}\n\t/* new authorization area range check, will cpBuffer move overflow */\n\tif (rc == 0) {\n\t    if (cpBuffer +\n\t\tcpBufferSize +\n\t\tsizeof (uint32_t) +\t\t/* authorizationSize */\n\t\tauthorizationSize\t\t/* authorization area */\n\t\t> tssAuthContext->commandBuffer + sizeof(tssAuthContext->commandBuffer)) {\n\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_SetCmdAuths: Command authorizations overflow command buffer\\n\");\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n\t/* move the cpBuffer to make space for the authorization area and its size */\n\tif (rc == 0) {\n\t    memmove(cpBuffer + sizeof (uint32_t) + authorizationSize,\t/* to here */\n\t\t    cpBuffer,\t\t\t\t\t\t/* from here */\n\t\t    cpBufferSize);\n\t}\n\t/* marshal the authorizationSize area, where cpBuffer was before move */\n\tif (rc == 0) {\n\t    uint32_t authorizationSize32 = authorizationSize;\n\t    uint16_t written = 0;\t\t/* dummy */\n\t    TSS_UINT32_Marshalu(&authorizationSize32, &written, &cpBuffer, NULL);\n\t}\n\t/* marshal the command authorization areas */\n\tdone = FALSE;\n\tauthorizationSize = 0;\n\tva_start(ap, tssAuthContext);\n\twhile ((rc == 0) && !done){\n\t    authCommand = va_arg(ap, TPMS_AUTH_COMMAND *);\n\t    if (authCommand != NULL) {\n\t\trc = TSS_TPMS_AUTH_COMMAND_Marshalu(authCommand, &authorizationSize, &cpBuffer, NULL);\n\t\ttssAuthContext->authCount++; /* count the number of authorizations for the\n\t\t\t\t\t\tresponse */\n\t    }\n\t    else {\n\t\tdone = TRUE;\n\t    }\n\t}\n\tva_end(ap);\n\tif (rc == 0) {\n\t    uint16_t written = 0;\t\t/* dummy */\n\t    uint32_t commandSize;\n\t    /* mark cpBuffer new location, size doesn't change */\n\t    tssAuthContext->cpBuffer += sizeof (uint32_t) + authorizationSize;\n\t    /* record command stream used size */\n\t    tssAuthContext->commandSize += sizeof (uint32_t) + authorizationSize;\n\t    /* back fill the correct commandSize */\n\t    buffer = tssAuthContext->commandBuffer + sizeof(TPMI_ST_COMMAND_TAG);\n\t    commandSize = tssAuthContext->commandSize;\n\t    TSS_UINT32_Marshalu(&commandSize, &written, &buffer, NULL);\n\t}\n    }\n    return rc;\n}\n\n/* TSS_GetRspAuths() unmarshals a response buffer into a NULL terminated list of TPMS_AUTH_RESPONSE\n   structures.  This should not be called if the TPM returned a non-success response code.\n\n   Returns an error if the number of response auths requested is not equal to the number of command\n   auths, including zero.\n\n   If the response tag is not TPM_ST_SESSIONS, the function is a noop (except for error checking).\n */\n\nTPM_RC TSS_GetRspAuths(TSS_AUTH_CONTEXT *tssAuthContext, ...)\n{\n    TPM_RC \trc = 0;\n    va_list\tap;\n    TPMS_AUTH_RESPONSE \t*authResponse = NULL;\n    uint32_t \tsize;\n    uint8_t \t*buffer;\n    TPM_ST \ttag;\n    int \tdone;\n    uint16_t\tauthCount = 0;\t\t/* authorizations in response */\n    uint32_t \tparameterSize;\n\n    /* unmarshal the response tag */\n    if (rc == 0) {\n\tsize = tssAuthContext->responseSize;\n  \tbuffer = tssAuthContext->responseBuffer;\n\trc = TSS_TPM_ST_Unmarshalu(&tag, &buffer, &size);\n    }\n    /* check that the tag indicates that there are sessions */\n    if ((rc == 0) && (tag == TPM_ST_SESSIONS)) {\n\t/* offset the buffer past the header and handles, and get the response parameterSize */\n\tif (rc == 0) {\n\t    uint32_t offsetSize = sizeof(TPM_ST) +  + sizeof (uint32_t) + sizeof(TPM_RC) +\n\t\t\t\t  (sizeof(TPM_HANDLE) * tssAuthContext->responseHandleCount);\n\t    buffer = tssAuthContext->responseBuffer + offsetSize;\n\t    size = tssAuthContext->responseSize - offsetSize;\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, &buffer, &size);\n\t}\n\tif (rc == 0) {\n\t    if (parameterSize > (uint32_t)size) {\n\t\tif (tssVerbose)\tprintf(\"TSS_GetRspAuths: Invalid response parameterSize %u\\n\",\n\t\t\t\t       parameterSize);\n\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    /* index past the response parameters to the authorization area */\n\t    buffer += parameterSize;\n\t    size -= parameterSize;\n\t}\n\t/* unmarshal the response authorization area */\n\tdone = FALSE;\n\tva_start(ap, tssAuthContext);\n\twhile ((rc == 0) && !done){\n\t    authResponse = va_arg(ap, TPMS_AUTH_RESPONSE *);\n\t    if (authResponse != NULL) {\n\t\trc = TSS_TPMS_AUTH_RESPONSE_Unmarshalu(authResponse, &buffer, &size);\n\t\tauthCount++;\n\t    }\n\t    else {\n\t\tdone = TRUE;\n\t    }\n\t}\n\tva_end(ap);\n\t/* check for extra bytes at the end of the response */\n\tif (rc == 0) {\n\t    if (size != 0) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_GetRspAuths: Extra bytes at the end of response authorizations\\n\");\n\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t    }\n\t}\n    }\n    /* check that the same number was requested as were sent in the command.  Check for zero if not\n       TPM_ST_SESSIONS */\n    if (rc == 0) {\n\tif (tssAuthContext->authCount != authCount) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_GetRspAuths: \"\n\t\t       \"Response authorizations requested does not equal number in command\\n\");\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_GetCommandDecryptParam() returns the size and pointer to the first marshaled TPM2B */\n\nTPM_RC TSS_GetCommandDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t  uint32_t *decryptParamSize,\n\t\t\t\t  uint8_t **decryptParamBuffer)\n{\n    TPM_RC \trc = 0;\n    /* the first parameter is the TPM2B */\n    uint32_t cpBufferSize;\n    uint8_t *cpBuffer;\n\n    if (rc == 0) {\n\trc = TSS_GetCpBuffer(tssAuthContext, &cpBufferSize, &cpBuffer);\n    }\n    /* extract contents of the first TPM2B */\n    if (rc == 0) {\n\t*decryptParamSize = ntohs(*(uint16_t *)cpBuffer);\n\t*decryptParamBuffer = cpBuffer + sizeof(uint16_t);\n    }\n    /* sanity range check */\n    if (rc == 0) {\n\tif (((*decryptParamBuffer + *decryptParamSize) >\n\t     (tssAuthContext->commandBuffer + tssAuthContext->commandSize)) ||\n\t    ((*decryptParamSize + sizeof(uint16_t) > tssAuthContext->cpBufferSize))) {\n\t    if (tssVerbose) printf(\"TSS_GetCommandDecryptParam: Malformed decrypt parameter \"\n\t\t\t\t   \"size %u cpBufferSize %u commandSize %u\\n\",\n\t\t\t\t   *decryptParamSize, tssAuthContext->cpBufferSize,\n\t\t\t\t   tssAuthContext->commandSize);\n\t    rc = TSS_RC_BAD_ENCRYPT_SIZE;\n\t}\n    }\n    return rc;\n}\n\nTPM_RC TSS_SetCommandDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t  uint32_t encryptParamSize,\n\t\t\t\t  uint8_t *encryptParamBuffer)\n{\n    TPM_RC \trc = 0;\n    /* the first parameter is the TPM2B */\n    uint32_t decryptParamSize;\n    uint8_t *decryptParamBuffer;\n\n    if (rc == 0) {\n\trc = TSS_GetCommandDecryptParam(tssAuthContext,\n\t\t\t\t\t&decryptParamSize,\n\t\t\t\t\t&decryptParamBuffer);\n    }\n    /* the encrypt data overwrites the already marshaled data */\n    if (rc == 0) {\n\tif (decryptParamSize != encryptParamSize) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_SetCommandDecryptParam: Different encrypt and decrypt size\\n\");\n\t    rc = TSS_RC_BAD_ENCRYPT_SIZE;\n\t}\n    }\n    /* skip the 2B size, copy the data */\n    if (rc == 0) {\n\tmemcpy(decryptParamBuffer, encryptParamBuffer, encryptParamSize);\n    }\n    return rc;\n}\n\n/* TSS_GetAuthRole() returns AUTH_NONE if the handle in the handle area cannot be an authorization\n   handle. */\n\nAUTH_ROLE TSS_GetAuthRole(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t  size_t handleIndex)\n{\n    AUTH_ROLE authRole;\n    authRole = getCommandAuthRole(tssAuthContext->tpmCommandIndex, handleIndex);\n    return authRole;\n}\n\n/* TSS_GetCommandHandle() gets the command handle at the index.  Index is a zero based count, not a\n   byte count.\n\n   Returns 0 if the index exceeds the number of handles.\n*/\n\nTPM_RC TSS_GetCommandHandle(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t    TPM_HANDLE *commandHandle,\n\t\t\t    size_t index)\n{\n    TPM_RC \trc = 0;\n    uint8_t \t*buffer;\n    uint32_t \tsize;\n\n\n    if (rc == 0) {\n\tif (index >= tssAuthContext->commandHandleCount) {\n\t    if (tssVerbose) printf(\"TSS_GetCommandHandle: index %u too large for command\\n\",\n\t\t\t\t   (unsigned int)index);\n\t    rc = TSS_RC_BAD_HANDLE_NUMBER;\n\t}\n    }\n    if (rc == 0) {\n\t/* index into the command handle */\n\tbuffer = tssAuthContext->commandBuffer +\n\t\t sizeof(TPMI_ST_COMMAND_TAG) + sizeof (uint32_t) + sizeof(TPM_CC) +\n\t\t (sizeof(TPM_HANDLE) * index);\n\tsize = sizeof(TPM_HANDLE);\n\trc = TSS_TPM_HANDLE_Unmarshalu(commandHandle, &buffer, &size);\n    }\n    return rc;\n}\n\n/* TSS_GetRpBuffer() returns a pointer to the response parameter area.\n\n   NOTE could move to execute so it only has to be done once.\n*/\n\nTPM_RC TSS_GetRpBuffer(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t       uint32_t *rpBufferSize,\n\t\t       uint8_t **rpBuffer)\n{\n    TPM_RC \trc = 0;\n    TPM_ST \ttag;\t\t\t/* response tag */\n    uint32_t \toffsetSize;\t\t/* to beginning of parameter area, to parameterSize */\n    uint32_t \tsize;\t\t\t/* tmp for unmarshal */\n    uint8_t \t*buffer;\t\t/* tmp for unmarshal */\n    uint32_t \tparameterSize;\t\t/* response parameter (if sessions) */\n\n    /* unmarshal the response tag */\n    if (rc == 0) {\n\t/* offset to parameterSize or parameters */\n\toffsetSize = sizeof(TPM_ST) + sizeof (uint32_t) + sizeof(TPM_RC) +\n\t\t     (sizeof(TPM_HANDLE) * tssAuthContext->responseHandleCount);\n\n\tsize = tssAuthContext->responseSize;\n  \tbuffer = tssAuthContext->responseBuffer;\n\trc = TSS_TPM_ST_Unmarshalu(&tag, &buffer, &size);\t/* does value checking */\n    }\n    /* no sessions -> no parameterSize */\n    if (tag == TPM_ST_NO_SESSIONS) {\n\tif (rc == 0) {\n\t    if (offsetSize > tssAuthContext->responseSize) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_GetRpBuffer: offset %u past response buffer %u\\n\",\n\t\t\t   offsetSize, tssAuthContext->responseSize);\n\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t    }\n\t}\n\tif (rc == 0) {\t\t\t/* subtract now safe from above range check */\n\t    *rpBufferSize = tssAuthContext->responseSize - offsetSize;\n\t    *rpBuffer = tssAuthContext->responseBuffer + offsetSize;\n\t}\n    }\n    /* sessions -> parameterSize */\n    else {\n\t/* validate that there are enough response bytes for uint32_t parameterSize */\n\tif (rc == 0) {\n\t    if ((offsetSize + sizeof(uint32_t)) > tssAuthContext->responseSize) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_GetRpBuffer: offset %u past response buffer %u\\n\",\n\t\t\t   offsetSize, tssAuthContext->responseSize);\n\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t    }\n\t}\n\t/* unmarshal the parameterSize */\n\tif (rc == 0) {\n\t    size = tssAuthContext->responseSize - offsetSize;\n\t    buffer = tssAuthContext->responseBuffer + offsetSize;\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, &buffer, &size);\n\t    offsetSize += sizeof(uint32_t);\t/* move offset past parameterSize, to rpBuffer */\n\t}\n\t/* range check parameterSize */\n\t/* first, check that addition willl not overflow */\n\tif (rc == 0) {\n\t    if (parameterSize > (0xffffffff - offsetSize)) {\n\t\tif (tssVerbose) printf(\"TSS_GetRpBuffer: parameterSize %u too large\\n\",\n\t\t\t\t       parameterSize);\n\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t    }\n\t}\n\t/* second, range check parameterSize vs. entire response buffer */\n\tif (rc == 0) {\n\t    if ((offsetSize + parameterSize) > tssAuthContext->responseSize) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_GetRpBuffer: parameterSize %u past response buffer %u\\n\",\n\t\t\t   parameterSize, tssAuthContext->responseSize);\n\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t    }\n\t}\n\t/* assignment safe after above checks */\n\tif (rc == 0) {\n\t    *rpBufferSize = parameterSize;\t/* by definition when there are auth sessions */\n\t    *rpBuffer = tssAuthContext->responseBuffer + offsetSize;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_GetResponseEncryptParam() returns the first TPM2B in the response area.\n\n   The caller should ensure that the first response parameter is a TPM2B.\n*/\n\nTPM_RC TSS_GetResponseEncryptParam(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t   uint32_t *encryptParamSize,\n\t\t\t\t   uint8_t **encryptParamBuffer)\n{\n    TPM_RC \trc = 0;\n    /* the first parameter is the TPM2B */\n    uint32_t rpBufferSize;\n    uint8_t *rpBuffer;\n\n    if (rc == 0) {\n\trc = TSS_GetRpBuffer(tssAuthContext, &rpBufferSize, &rpBuffer);\n    }\n    /* extract contents of the first TPM2B */\n    if (rc == 0) {\n\t*encryptParamSize = ntohs(*(uint16_t *)rpBuffer);\n\t*encryptParamBuffer = rpBuffer + sizeof(uint16_t);\n    }\n    /* sanity range check */\n    if (rc == 0) {\n\tif (((*encryptParamBuffer + *encryptParamSize) >\n\t     (tssAuthContext->responseBuffer + tssAuthContext->responseSize)) ||\n\t    ((*encryptParamSize + sizeof(uint16_t) > rpBufferSize))) {\n\t    if (tssVerbose) printf(\"TSS_GetResponseEncryptParam: Malformed encrypt parameter \"\n\t\t\t\t   \"size %u rpBufferSize %u responseSize %u\\n\",\n\t\t\t\t   *encryptParamSize, rpBufferSize,\n\t\t\t\t   tssAuthContext->responseSize);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_SetResponseDecryptParam() copies the decryptParamBuffer into the first TPM2B in the response\n   area.\n\n   The caller should ensure that the first response parameter is a TPM2B.\n*/\n\nTPM_RC TSS_SetResponseDecryptParam(TSS_AUTH_CONTEXT *tssAuthContext,\n\t\t\t\t   uint32_t decryptParamSize,\n\t\t\t\t   uint8_t *decryptParamBuffer)\n{\n    TPM_RC \trc = 0;\n    /* the first parameter is the TPM2B */\n    uint32_t encryptParamSize;\n    uint8_t *encryptParamBuffer;\n\n    if (rc == 0) {\n\trc = TSS_GetResponseEncryptParam(tssAuthContext,\n\t\t\t\t\t &encryptParamSize,\n\t\t\t\t\t &encryptParamBuffer);\n    }\n    /* the decrypt data overwrites the already marshaled data */\n    if (rc == 0) {\n\tif (decryptParamSize != encryptParamSize) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_SetCommandDecryptParam: Different encrypt and decrypt size\\n\");\n\t    rc = TSS_RC_BAD_ENCRYPT_SIZE;\n\t}\n    }\n    /* skip the 2B size, copy the data */\n    if (rc == 0) {\n\tmemcpy(encryptParamBuffer, decryptParamBuffer, decryptParamSize);\n    }\n    return rc;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssccattributes.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Command Code Attributes\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* NOTE: This is a replica of CommandAttributeData.c, but endian independent.  It must be kept in\n   sync with the TPM reference implementation.\n   \n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <inttypes.h>\n\n#include \"tssccattributes.h\"\n\n/* CommandCodeToCommandIndex() returns the index into the s_ccAttr table for the commandCode.\n   Returns UNIMPLEMENTED_COMMAND_INDEX if the command is unimplemented.\n*/\n\n/* NOTE: Marked as const function in header declaration */\n\nCOMMAND_INDEX CommandCodeToCommandIndex(TPM_CC commandCode)\n{\n    COMMAND_INDEX i;\n\n    /* s_ccAttr has terminating 0x0000 command code and V */\n    for (i = 0 ; (s_ccAttr[i].commandCode != 0) || (s_ccAttr[i].V != 0) ; i++) {\n\tif (s_ccAttr[i].commandCode == commandCode) {\n\t    return i;\n\t}\n    }\n    return UNIMPLEMENTED_COMMAND_INDEX;\n}\n\n/* getCommandHandleCount() returns the number of command parameter handles */\n\n/* NOTE: Marked as const function in header declaration */\n\nuint32_t getCommandHandleCount(COMMAND_INDEX index)\n{\n    return s_ccAttr[index].cHandles;\n}\n\n/* getresponseHandleCount() returns the number of command parameter handles */\n\n/* NOTE: Marked as const function in header declaration */\n\nuint32_t getresponseHandleCount(COMMAND_INDEX index)\n{\n    return s_ccAttr[index].rHandle;\n}\n\n/* getDecryptSize() returns 0 if the command does not support command parameter encryption, 2 if the\n   command does support command parameter encryption and the size is a uint16_t.  There is an unused\n   provision for a 4 for a uint32_t size. */\n\n/* NOTE: Marked as const function in header declaration */\n\nint getDecryptSize(COMMAND_INDEX    commandIndex)\n{\n    COMMAND_ATTRIBUTES      ca = s_commandAttributes[commandIndex];\n    \n    if(ca & DECRYPT_2)\n\treturn 2;\n    if(ca & DECRYPT_4)\n\treturn 4;\n    return 0;\n}\n\n/* getEecryptSize() returns 0 if the response does not support response parameter encryption, 2 if\n   the command does support response parameter encryption and the size is a uint16_t.  There is an\n   unused provision for a 4 for a uint32_t size. */\n\n/* NOTE: Marked as const function in header declaration */\n\nint getEncryptSize(COMMAND_INDEX    commandIndex)\n{\n    COMMAND_ATTRIBUTES  ca = s_commandAttributes[commandIndex];\n    if(ca & ENCRYPT_2)\n\treturn 2;\n    if(ca & ENCRYPT_4)\n\treturn 4;\n    return 0;\n}\n\n/* getCommandAuthRole() returns the authorization role for the handle: user, admin, or dup.\n\n */\n\n/* NOTE: Marked as const function in header declaration */\n\nAUTH_ROLE getCommandAuthRole(\n\t\t\t     COMMAND_INDEX    \tcommandIndex,  // IN: command index\n\t\t\t     size_t\t\thandleIndex    // IN: handle index (zero based)\n\t\t\t     )\n{\n    if(0 == handleIndex )\n\t{\n\t    // Any auth role set?\n\t    COMMAND_ATTRIBUTES  properties = s_commandAttributes[commandIndex];\n\t    \n\t    if(properties & HANDLE_1_USER)\n\t\treturn AUTH_USER;\n\t    if(properties & HANDLE_1_ADMIN)\n\t\treturn AUTH_ADMIN;\n\t    if(properties & HANDLE_1_DUP)\n\t\treturn AUTH_DUP;\n\t}\n    else if (1 == handleIndex)\n\t{\n\t    if(s_commandAttributes[commandIndex] & HANDLE_2_USER)\n\t\treturn AUTH_USER;\n\t}\n    return AUTH_NONE;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssccattributes12.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Command Code Attributes\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: tssccattributes12.c 1164 2018-04-17 19:53:29Z kgoldman $\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2018.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* NOTE: This is a replica of CommandAttributeData.c, but endian independent.  It must be kept in\n   sync with the TPM reference implementation.\n   \n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <inttypes.h>\n\n#include \"tssccattributes12.h\"\n\nCOMMAND_INDEX CommandCodeToCommandIndex12(TPM_CC commandCode)\n{\n    COMMAND_INDEX i;\n\n    /* s_ccAttr12 has terminating 0x0000 command code and V */\n    for (i = 0 ; (s_ccAttr12[i].commandCode != 0) || (s_ccAttr12[i].V != 0) ; i++) {\n\tif (s_ccAttr12[i].commandCode == commandCode) {\n\t    return i;\n\t}\n    }\n    return UNIMPLEMENTED_COMMAND_INDEX;\n}\n\nuint32_t getCommandHandleCount12(COMMAND_INDEX index)\n{\n    return s_ccAttr12[index].cHandles;\n}\n\nuint32_t getresponseHandleCount12(COMMAND_INDEX index)\n{\n    return s_ccAttr12[index].rHandle;\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/tsscrypto.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TSS Library Dependent Crypto Support\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\tECC Salt functions written by Bill Martin\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2023.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* Interface to OpenSSL version 1.0.2, 1.1.1, 3.n crypto library */\n\n#include <string.h>\n#include <stdio.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <openssl/err.h>\n#include <openssl/evp.h>\n#include <openssl/hmac.h>\n#include <openssl/aes.h>\n#ifndef TPM_TSS_NORSA\n#include <openssl/rsa.h>\n#endif\n#include <openssl/rand.h>\n#include <openssl/engine.h>\n#if OPENSSL_VERSION_NUMBER >= 0x30000000\n#include <openssl/core_names.h>\n#include <openssl/param_build.h>\n#endif\n\n#include <ibmtss/tssresponsecode.h>\n#include \"tssproperties.h\"\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssmarshal.h>\n\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsscrypto.h>\n\nLIB_EXPORT\nTPM_RC TSS_Hash_GetMd(const EVP_MD **md,\n\t\t      TPMI_ALG_HASH hashAlg);\n\nextern int tssVverbose;\nextern int tssVerbose;\n\n/* openssl compatibility code */\n\n#if OPENSSL_VERSION_NUMBER < 0x10101000\n#define EC_POINT_set_affine_coordinates(a,b,c,d,e)  EC_POINT_set_affine_coordinates_GFp(a,b,c,d,e)\n#define EC_POINT_get_affine_coordinates(a,b,c,d,e)  EC_POINT_get_affine_coordinates_GFp(a,b,c,d,e)\n#endif\n\n/* local prototypes */\n\nstatic TPM_RC TSS_Hash_GetOsslString(const char **str, TPMI_ALG_HASH hashAlg);\n#if OPENSSL_VERSION_NUMBER >=  0x30000000\nstatic TPM_RC TSS_AES_CFB(EVP_CIPHER_CTX **ctx,\n\t\t\t  uint32_t keySizeInBits,\n\t\t\t  uint8_t *key,\n\t\t\t  uint8_t *iv,\n\t\t\t  int encrypt);\n#endif\n\n\n#ifndef TPM_TSS_NOECC\n\n/* ECC salt */\n\nstatic TPM_RC TSS_bn2binpad(unsigned char *bin, int binlen, const BIGNUM *bn);\nstatic TPM_RC TSS_ECC_GeneratePlatformEphemeralKey(BIGNUM \t**ephPrivKey,\n\t\t\t\t\t\t   BIGNUM \t**ephPubX,\n\t\t\t\t\t\t   BIGNUM \t**ephPubY,\n\t\t\t\t\t\t   EC_GROUP \t*ecGroup,\n\t\t\t\t\t\t   int \t\tcurveID);\nstatic TPM_RC TSS_BN_new(BIGNUM **bn);\n\n#endif\t/* TPM_TSS_NOECC */\n\nstatic TPM_RC TSS_bin2bn(BIGNUM **bn, const unsigned char *bin, unsigned int bytes);\n\n/*\n  Initialization\n*/\n\nTPM_RC TSS_Crypto_Init(void)\n{\n    TPM_RC\t\trc = 0;\n#if 0\n    int\t\t\tirc;\n#endif\n\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n    ERR_load_crypto_strings ();\n    OpenSSL_add_all_algorithms();\n#endif\n#if 0\n    irc = FIPS_mode_set(1);\n    if (irc == 0) {\n\tif (tssVerbose) printf(\"TSS_Crypto_Init: Cannot set FIPS mode\\n\");\n    }\n#endif\n    return rc;\n}\n\n/*\n  Digests\n*/\n\n/* TSS_Hash_GetString() maps from the TCG hash algorithm to the OpenSSL string */\n\nstatic TPM_RC TSS_Hash_GetOsslString(const char **str, TPMI_ALG_HASH hashAlg)\n{\n    TPM_RC\trc = 0;\n\n    switch (hashAlg) {\n#ifdef TPM_ALG_SHA1\n      case TPM_ALG_SHA1:\n\t*str = \"sha1\";\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA256\n      case TPM_ALG_SHA256:\n\t*str = \"sha256\";\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA384\n      case TPM_ALG_SHA384:\n\t*str = \"sha384\";\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA512\n      case TPM_ALG_SHA512:\n\t*str = \"sha512\";\n\tbreak;\n#endif\n      default:\n\t*str = NULL;\n\trc = TSS_RC_BAD_HASH_ALGORITHM;\n    }\n    return rc;\n}\n\nTPM_RC TSS_Hash_GetMd(const EVP_MD **md,\n\t\t      TPMI_ALG_HASH hashAlg)\n{\n    TPM_RC\t\trc = 0;\n    const char \t\t*str = NULL; \n\n    if (rc == 0) {\n\trc =  TSS_Hash_GetOsslString(&str, hashAlg);\n    }\n    if (rc == 0) {\n\t*md = EVP_get_digestbyname(str);\t/* no free needed */\n\tif (*md == NULL) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n    return rc;\n}\n\n/* On call, digest->hashAlg is the desired hash algorithm\n\n   length 0 is ignored, buffer NULL terminates list.\n*/\n\nTPM_RC TSS_HMAC_Generate_valist(TPMT_HA *digest,\t\t/* largest size of a digest */\n\t\t\t\tconst TPM2B_KEY *hmacKey,\n\t\t\t\tva_list ap)\n{\n    TPM_RC\t\trc = 0;\n    int \t\tirc = 0;\n    int\t\t\tdone = FALSE;\n    uint8_t \t\t*buffer;\t/* segment to hash */\n    int\t\t\tlength;\t\t/* segment to hash */\n#if OPENSSL_VERSION_NUMBER < 0x10100000\t\n    HMAC_CTX \t\tctx;\n    const EVP_MD \t*md = NULL;\t/* message digest method */\n#elif OPENSSL_VERSION_NUMBER < 0x30000000\n    HMAC_CTX \t\t*ctx = NULL;\n    const EVP_MD \t*md = NULL;\t/* message digest method */\n#else\n    EVP_MAC \t\t*mac = NULL;\n    EVP_MAC_CTX \t*ctx = NULL;\n    const char \t\t*algString = NULL;\n    OSSL_PARAM \t\tparams[2];\n    size_t\t\toutLength;\n#endif\n\n    /* initialize the HMAC context */\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n    HMAC_CTX_init(&ctx);\n#elif OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n\tctx = HMAC_CTX_new();\n\tif (ctx == NULL) {\n\t    if (tssVerbose) printf(\"TSS_Hash_Generate_valist: HMAC_CTX_new failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n#else\n    if (rc == 0) {\n\tmac = EVP_MAC_fetch(NULL, \"hmac\", NULL);\t/* freed @2 */\n\tif (mac == NULL) {\n\t    if (tssVerbose) printf(\"TSS_Hash_Generate_valist: EVP_MAC_new failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\tctx = EVP_MAC_CTX_new(mac);\t\t\t/* freed @1 */\n\tif (ctx == NULL) {\n\t    if (tssVerbose) printf(\"TSS_Hash_Generate_valist: EVP_MAC_CTX_new failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n#endif\n\n    /* get the message digest */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n\trc = TSS_Hash_GetMd(&md, digest->hashAlg);\n    }\n#else\n    /* map algorithm to string */\n    if (rc == 0) {\n\trc =  TSS_Hash_GetOsslString(&algString, digest->hashAlg);\n    }\n#endif\n\n    /* initialize the MAC context */\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n\tirc = HMAC_Init_ex(&ctx,\n\t\t\t   hmacKey->b.buffer, hmacKey->b.size,\t/* HMAC key */\n\t\t\t   md,\t\t\t\t\t/* message digest method */\n\t\t\t   NULL);\n#elif OPENSSL_VERSION_NUMBER < 0x30000000\n\tirc = HMAC_Init_ex(ctx,\n\t\t\t   hmacKey->b.buffer, hmacKey->b.size,\t/* HMAC key */\n\t\t\t   md,\t\t\t\t\t/* message digest method */\n\t\t\t   NULL);\n#else\n\tparams[0] = OSSL_PARAM_construct_utf8_string(\"digest\", (char *)algString, 0);\n\tparams[1] = OSSL_PARAM_construct_end();\n\tirc = EVP_MAC_init(ctx,\n\t\t\t   hmacKey->b.buffer, hmacKey->b.size,\t/* HMAC key */\n\t\t\t   params);\t\t\t\t/* message digest method */\n#endif\n\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_HMAC_Generate: HMAC Init failed\\n\");\n\t    rc = TSS_RC_HMAC;\n\t}\n    }\n    while ((rc == 0) && !done) {\n\tlength = va_arg(ap, int);\t\t/* first vararg is the length */\n\tbuffer = va_arg(ap, unsigned char *);\t/* second vararg is the array */\n\tif (buffer != NULL) {\t\t\t/* loop until a NULL buffer terminates */\n\t    if (length < 0) {\n\t\tif (tssVerbose) printf(\"TSS_HMAC_Generate: Length is negative\\n\");\n\t\trc = TSS_RC_HMAC;\n\t    }\n\t    else {\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n\t\tirc = HMAC_Update(&ctx, buffer, length);\n#elif OPENSSL_VERSION_NUMBER < 0x30000000\n\t\tirc = HMAC_Update(ctx, buffer, length);\n#else\n\t\tirc = EVP_MAC_update(ctx, buffer, length);\n#endif\n\t\tif (irc != 1) {\n\t\t    if (tssVerbose) printf(\"TSS_HMAC_Generate: HMAC Update failed\\n\");\n\t\t    rc = TSS_RC_HMAC;\n\t\t}\n\t    }\n \t}\n\telse {\n\t    done = TRUE;\n\t}\n    }\n    if (rc == 0) {\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n\tirc = HMAC_Final(&ctx, (uint8_t *)&digest->digest, NULL);\n#elif OPENSSL_VERSION_NUMBER < 0x30000000\n\tirc = HMAC_Final(ctx, (uint8_t *)&digest->digest, NULL);\n#else\n\tirc = EVP_MAC_final(ctx, (uint8_t *)&digest->digest,  &outLength, sizeof(digest->digest));\n#endif\n\tif (irc == 0) {\n\t    if (tssVerbose) printf(\"TSS_HMAC_Generate: HMAC Final failed\\n\");\n\t    rc = TSS_RC_HMAC;\n\t}\n    }\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n    HMAC_CTX_cleanup(&ctx);\n#elif OPENSSL_VERSION_NUMBER < 0x30000000\n    HMAC_CTX_free(ctx);\n#else\n    EVP_MAC_CTX_free(ctx);\t\t/* @1 */\n    EVP_MAC_free(mac);\t\t\t/* @2 */\n#endif\n    return rc;\n}\n\n/*\n  valist is int length, unsigned char *buffer pairs\n  \n  length 0 is ignored, buffer NULL terminates list.\n*/\n\nTPM_RC TSS_Hash_Generate_valist(TPMT_HA *digest,\t\t/* largest size of a digest */\n\t\t\t\tva_list ap)\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tirc = 0;\n    int\t\t\tdone = FALSE;\n    int\t\t\tlength;\n    uint8_t \t\t*buffer;\n    EVP_MD_CTX \t\t*mdctx;\n    const EVP_MD \t*md;\n\n    if (rc == 0) {\n\tmdctx = EVP_MD_CTX_create();\n        if (mdctx == NULL) {\n\t    if (tssVerbose) printf(\"TSS_Hash_Generate: EVP_MD_CTX_create failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Hash_GetMd(&md, digest->hashAlg);\n    }\n    if (rc == 0) {\n\tirc = EVP_DigestInit_ex(mdctx, md, NULL);\n\tif (irc != 1) {\n\t    rc = TSS_RC_HASH;\n\t}\n    }\n    while ((rc == 0) && !done) {\n\tlength = va_arg(ap, int);\t\t/* first vararg is the length */\n\tbuffer = va_arg(ap, unsigned char *);\t/* second vararg is the array */\n\tif (buffer != NULL) {\t\t\t/* loop until a NULL buffer terminates */\n\t    if (length < 0) {\n\t\tif (tssVerbose) printf(\"TSS_Hash_Generate: Length is negative\\n\");\n\t\trc = TSS_RC_HASH;\n\t    }\n\t    else {\n\t\t/* if (tssVverbose) TSS_PrintAll(\"TSS_Hash_Generate:\", buffer, length); */\n\t\tif (length != 0) {\n\t\t    EVP_DigestUpdate(mdctx, buffer, length);\n\t\t}\n\t    }\n\t}\n\telse {\n\t    done = TRUE;\n\t}\n    }\n    if (rc == 0) {\n\tEVP_DigestFinal_ex(mdctx, (uint8_t *)&digest->digest, NULL);\n    }\n    EVP_MD_CTX_destroy(mdctx);\n    return rc;\n}\n\n/* Random Numbers */\n\nTPM_RC TSS_RandBytes(unsigned char *buffer, uint32_t size)\n{\n    TPM_RC \trc = 0;\n    int\t\tirc = 0;\n\n    irc = RAND_bytes(buffer, size);\n    if (irc != 1) {\n\tif (tssVerbose) printf(\"TSS_RandBytes: Random number generation failed\\n\");\n\trc = TSS_RC_RNG_FAILURE;\n    }\n    return rc;\n}\n\n/*\n  RSA functions\n*/\n\n#ifndef TPM_TSS_NORSA\n\n/* TSS_RsaNew() allocates an openssl RSA key token.\n\n   This abstracts the crypto library specific allocation.\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nTPM_RC TSS_RsaNew(void **rsaKey)\n{\n    TPM_RC  \trc = 0;\n\n    /* sanity check for the free */\n    if (rc == 0) {\n\tif (*rsaKey != NULL) {\n            if (tssVerbose)\n\t\tprintf(\"TSS_RsaNew: Error (fatal), token %p should be NULL\\n\",\n\t\t       *rsaKey);\n            rc = TSS_RC_ALLOC_INPUT;\n\t}\n    }\n    /* construct the OpenSSL private key object */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n        *rsaKey = RSA_new();                        \t/* freed by caller */\n        if (*rsaKey == NULL) {\n            if (tssVerbose) printf(\"TSS_RsaNew: Error in RSA_new()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n        }\n    }\n#else\n    if (rc == 0) {\n\t*rsaKey = EVP_PKEY_new();\n        if (*rsaKey == NULL) {\n            if (tssVerbose) printf(\"TSS_RsaNew: Error in EVP_PKEY_new()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n        }\n    }\n    if (rc == 0) {\n    }\n#endif\n    return rc;\n}\n\n/* TSS_RsaFree() frees an openssl RSA key token.\n\n   This abstracts the crypto library specific free.\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nvoid TSS_RsaFree(void *rsaKey)\n{\n    if (rsaKey != NULL) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n        RSA_free(rsaKey); \n#else\n\tEVP_PKEY_free(rsaKey);\n#endif\n    }\n    return;\n}\n\n/* TSS_RSAGeneratePublicToken() is deprecated for application use, since it is openssl library\n   dependent.\n\n   Use TSS_RSAGeneratePublicTokenI().\n*/\n\n#ifndef TPM_TSS_NODEPRECATED\n\nTPM_RC TSS_RSAGeneratePublicToken(RSA **rsa_pub_key,\t\t/* freed by caller */\n\t\t\t\t  const unsigned char *narr,    /* public modulus */\n\t\t\t\t  uint32_t nbytes,\n\t\t\t\t  const unsigned char *earr,    /* public exponent */\n\t\t\t\t  uint32_t ebytes)\n{\n    TPM_RC  \trc = 0;\n    rc = TSS_RSAGeneratePublicTokenI((void **)rsa_pub_key,\n\t\t\t\t     narr, \n\t\t\t\t     nbytes,\n\t\t\t\t     earr,\n\t\t\t\t     ebytes);\n    return rc;\n}\n\n#endif /* TPM_TSS_NODEPRECATED */\n\n/* TSS_RSAGeneratePublicTokenI() generates an RSA key token from n and e\n\n   Free rsa_pub_key using TSS_RsaFree();\n\n   For Openssl < 3, rsaKey is an RSA structure.\n   For Openssl 3, rsaKey is an EVP_PKEY.\n */\n\nTPM_RC TSS_RSAGeneratePublicTokenI(void **rsa_pub_key,\t\t/* freed by caller */\n\t\t\t\t   const unsigned char *narr,   /* public modulus */\n\t\t\t\t   uint32_t nbytes,\n\t\t\t\t   const unsigned char *earr,   /* public exponent */\n\t\t\t\t   uint32_t ebytes)\n{\n    TPM_RC  \trc = 0;\n#if OPENSSL_VERSION_NUMBER >= 0x10100000\n    int \tirc;\n#endif\n    BIGNUM *    n = NULL;\n    BIGNUM *    e = NULL;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    RSA **\trsaPubKey = (RSA **)rsa_pub_key;\t/* openssl specific structure */\n#else\n    EVP_PKEY_CTX \t*ctx = NULL;\n    OSSL_PARAM_BLD \t*param_bld = NULL;\n    OSSL_PARAM \t\t*params = NULL; \n#endif\n\n    /* construct the OpenSSL private key object */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n\trc = TSS_RsaNew(rsa_pub_key);\t\t/* freed by caller */\n    }\n#endif\n    if (rc == 0) {\n        rc = TSS_bin2bn(&n, narr, nbytes);\t/* freed by caller, < 3.0.0 */\n    }\t\t\t\t\t\t/* freed @4, 3.0.0 */\n    if (rc == 0) {\n        rc = TSS_bin2bn(&e, earr, ebytes);\t/* freed by caller, < 3.0.0  */\n    }\t\t\t\t\t\t/* freed @5, 3.0.0 */\n#if OPENSSL_VERSION_NUMBER < 0x10100000\n    if (rc == 0) {\n        (*rsaPubKey)->n = n;\n        (*rsaPubKey)->e = e;\n        (*rsaPubKey)->d = NULL;\n    }\n#elif OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n\tirc = RSA_set0_key(*rsaPubKey, n, e, NULL);\n\tif (irc != 1) {\n            if (tssVerbose) printf(\"TSS_RSAGeneratePublicTokenI: Error in RSA_set0_key()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n#else\n    /* See EVP_PKEY-RSA for parameter values */\n    if (rc == 0) {\n\tparam_bld = OSSL_PARAM_BLD_new();\t\t/* freed @2 */\n\tif (param_bld == NULL) {\n            if (tssVerbose) printf(\"TSS_RSAGeneratePublicTokenI: Error in OSSL_PARAM_BLD_new()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = OSSL_PARAM_BLD_push_BN(param_bld, \"n\", n);\n\tif (irc != 1) {\n            if (tssVerbose) printf(\"TSS_RSAGeneratePublicTokenI: \"\n\t\t\t\t   \"Error in OSSL_PARAM_BLD_push_BN()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = OSSL_PARAM_BLD_push_BN(param_bld, \"e\", e);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_RSAGeneratePublicTokenI: \"\n\t\t\t\t   \"Error in OSSL_PARAM_BLD_push_BN()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tparams = OSSL_PARAM_BLD_to_param(param_bld);\t/* freed @3 */\n\tif (params == NULL) {\n\t    if (tssVerbose) printf(\"TSS_RSAGeneratePublicTokenI: \"\n\t\t\t\t   \"Error in OSSL_PARAM_BLD_to_param()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tctx = EVP_PKEY_CTX_new_from_name(NULL, \"RSA\", NULL);\t\t/* freed @1 */\n\tif (ctx == NULL) {\n\t    if (tssVerbose) printf(\"TSS_RSAGeneratePublicTokenI: \"\n\t\t\t\t   \"Error in EVP_PKEY_CTX_new_from_name()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_fromdata_init(ctx);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_RSAGeneratePublicTokenI: \"\n\t\t\t\t   \"Error in EVP_PKEY_fromdata_init()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_fromdata(ctx, (EVP_PKEY **)rsa_pub_key,\t\t/* freed by caller */\n\t\t\t\tEVP_PKEY_PUBLIC_KEY, params);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_RSAGeneratePublicTokenI: \"\n\t\t\t\t   \"Error in EVP_PKEY_fromdata()\\n\");\n            rc = TSS_RC_RSA_KEY_CONVERT;\n\t}\n    }\n    OSSL_PARAM_free(params);\t\t/* @3 */\n    OSSL_PARAM_BLD_free(param_bld);\t/* @2 */\n    EVP_PKEY_CTX_free(ctx);\t\t/* @1 */\n    /* for openssl < 3.0.0, n and e are part of the RSA structure, freed with it.  For 3.0.0 and up,\n       they're copied to the EVP_PKEY, so the parts are freed here. */\n    BN_free(n);\t\t\t\t/* @4 */\n    BN_free(e);\t\t\t\t/* @5 */\n#endif\n    return rc;\n}\n\n/* TSS_RSAPublicEncrypt() pads 'decrypt_data' to 'encrypt_data_size' and encrypts using the public\n   key 'n, e'.\n*/\n\nTPM_RC TSS_RSAPublicEncrypt(unsigned char *encrypt_data,    /* encrypted data */\n\t\t\t    size_t encrypt_data_size,       /* size of encrypted data buffer */\n\t\t\t    const unsigned char *decrypt_data,      /* decrypted data */\n\t\t\t    size_t decrypt_data_size,\n\t\t\t    unsigned char *narr,           /* public modulus */\n\t\t\t    uint32_t nbytes,\n\t\t\t    unsigned char *earr,           /* public exponent */\n\t\t\t    uint32_t ebytes,\n\t\t\t    unsigned char *p,\t\t/* encoding parameter */\n\t\t\t    int pl,\n\t\t\t    TPMI_ALG_HASH halg)\t\t/* OAEP hash algorithm */\n{\n    TPM_RC  \trc = 0;\n    int         irc;\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    RSA         *rsa_pub_key = NULL;\n#else\n    EVP_PKEY \t*rsa_pub_key = NULL;\n    EVP_PKEY_CTX \t*ctx = NULL;\n#endif\n    unsigned char *padded_data = NULL;\n \n    if (tssVverbose) printf(\" TSS_RSAPublicEncrypt: Input data size %lu\\n\",\n\t\t\t    (unsigned long)decrypt_data_size);\n    /* intermediate buffer for the decrypted but still padded data */\n    if (rc == 0) {\n        rc = TSS_Malloc(&padded_data, (uint32_t)encrypt_data_size);               /* freed @2 */\n    }\n    /* construct the OpenSSL public key object */\n    if (rc == 0) {\n\t/* For Openssl < 3, rsaKey is an RSA structure. */\n\t/* For Openssl 3, rsaKey is an EVP_PKEY, */\n\trc = TSS_RSAGeneratePublicTokenI((void **)&rsa_pub_key,\t/* freed @3 */\n\t\t\t\t\t narr,      \t/* public modulus */\n\t\t\t\t\t nbytes,\n\t\t\t\t\t earr,      \t/* public exponent */\n\t\t\t\t\t ebytes);\n    }\n    /* Must pad first and then encrypt because the encrypt call cannot specify an encoding\n       parameter */\n    if (rc == 0) {\n\tpadded_data[0] = 0x00;\n\trc = TSS_RSA_padding_add_PKCS1_OAEP(padded_data,\t\t    /* to */\n\t\t\t\t\t    (uint32_t)encrypt_data_size,    /* to length */\n\t\t\t\t\t    decrypt_data,\t\t    /* from */\n\t\t\t\t\t    (uint32_t)decrypt_data_size,    /* from length */\n\t\t\t\t\t    p,\t\t/* encoding parameter */\n\t\t\t\t\t    pl,\t\t/* encoding parameter length */\n\t\t\t\t\t    halg);\t/* OAEP hash algorithm */\n    }\n    if (rc == 0) {\n        if (tssVverbose)\n\t    printf(\"  TSS_RSAPublicEncrypt: Padded data size %lu\\n\",\n\t\t   (unsigned long)encrypt_data_size);\n        if (tssVverbose) TSS_PrintAll(\"  TPM_RSAPublicEncrypt: Padded data\", padded_data,\n\t\t\t\t      (uint32_t)encrypt_data_size);\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n\t/* encrypt with public key. */\n\t/* returns the size of the encrypted data.  On error, -1 is returned */\n\tirc = RSA_public_encrypt((int)encrypt_data_size,         /* from length */\n\t\t\t\t padded_data,               /* from - the clear text data */\n\t\t\t\t encrypt_data,              /* the padded and encrypted data */\n\t\t\t\t rsa_pub_key,               /* RSA key structure */\n\t\t\t\t RSA_NO_PADDING);           /* padding */\n\tif (irc < 0) {\n\t    if (tssVerbose) printf(\"TSS_RSAPublicEncrypt: Error in RSA_public_encrypt()\\n\");\n\t    rc = TSS_RC_RSA_ENCRYPT;\n\t}\n    }\n#else\n    /* create EVP_PKEY_CTX for the encrypt */\n    if (rc == 0) {\n\tctx = EVP_PKEY_CTX_new(rsa_pub_key, NULL);\t\t/* freed @1 */\n\tif (ctx == NULL) {\n\t    printf(\"TSS_RSAPublicEncrypt: Error in EVP_PKEY_CTX_new()\\n\");\n            rc = TSS_RC_RSA_ENCRYPT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_encrypt_init(ctx);\n\tif (irc != 1) {\n\t    printf(\"TSS_RSAPublicEncrypt: Error in EVP_PKEY_encrypt_init()\\n\");\n            rc = TSS_RC_RSA_ENCRYPT;\n\t}\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_NO_PADDING);\n\tif (irc <= 0) {\n\t    if (tssVerbose) printf(\"TSS_RSAPublicEncrypt: Error in EVP_PKEY_CTX_set_rsa_padding\\n\");\n\t    rc = TSS_RC_RSA_ENCRYPT;\n\t}\n    }\n    if (rc == 0) {\n\tsize_t outlen = encrypt_data_size;\n\tirc = EVP_PKEY_encrypt(ctx,\n\t\t\t       encrypt_data, &outlen,\n\t\t\t       padded_data, encrypt_data_size);\n    }\n#endif\n    if (rc == 0) {\n        if (tssVverbose) printf(\"  TSS_RSAPublicEncrypt: RSA_public_encrypt() success\\n\");\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n#else\n    EVP_PKEY_CTX_free(ctx);\t\t/* @1 */\n#endif\n   TSS_RsaFree(rsa_pub_key);          \t/* @3 */\n   free(padded_data);                  \t/* @2 */\n   return rc;\n}\n\n#endif /* TPM_TSS_NORSA */\n\n#ifndef TPM_TSS_NOECC\n\n/* TSS_EccFree() frees an openssl ECC key token.\n\n   This abstracts the crypto library specific free.\n\n   For Openssl < 3, eccKey is an EC_KEY structure.\n   For Openssl 3, rsaKey is an EVP_PKEY,\n*/\n\nvoid TSS_EccFree(void *eccKey)\n{\n    if (eccKey != NULL) {\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n\tEC_KEY_free(eccKey);\n#else\n\tEVP_PKEY_free(eccKey);\n#endif\n    }\n    return;\n}\n\n/* TSS_GeneratePlatformEphemeralKey sets the EC parameters to curveID and generates the ephemeral\n   key.  It returns the private key and public points.\n*/\n\nstatic TPM_RC TSS_ECC_GeneratePlatformEphemeralKey(BIGNUM \t**ephPrivKey,\t/* freed by caller */\n\t\t\t\t\t\t   BIGNUM \t**ephPubX,\t/* freed by caller */\n\t\t\t\t\t\t   BIGNUM \t**ephPubY,\t/* freed by caller */\n\t\t\t\t\t\t   EC_GROUP \t*ecGroup,\n\t\t\t\t\t\t   int \t\tcurveID)\t/* nid */\n{\n    TPM_RC      \trc = 0;\n    int\t\t\tirc = 0;\n    EVP_PKEY_CTX \t*ctx = NULL;\n    EVP_PKEY \t\t*ephKey = NULL;\t\t/* ephemeral key */\n\n    /* create the key generator context */\n    if (rc == 0) {\n\tctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL);\t/* freed @1 */\n\tif (ctx == NULL) {\n\t    if (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t   \"Error in EVP_PKEY_CTX_new_id()\\n\");\n            rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* initialize the public key algorithm context for a key generation operation */\n    if (rc == 0) {\n\tirc = EVP_PKEY_keygen_init(ctx);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t   \"Error in EVP_PKEY_keygen_init()\\n\");\n            rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* get the key generation curve */\n    if (rc == 0) {\n\tirc = EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, curveID);\n\tif (irc <= 0) {\n\t    if (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t   \"Error in EVP_PKEY_CTX_set_ec_paramgen_curve_nid()\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* generate the ephemeral key */\n    if (rc == 0) {\n\tirc = EVP_PKEY_keygen(ctx, &ephKey);\t/* freed @2 */\n\tif (irc != 1) {\n \t    if (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t   \"Error in EVP_PKEY_generate()\\n\");\n            rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    {\n\tEC_KEY *ephEcKey = NULL;\n\tconst EC_POINT *ephEcPubKey= NULL;\n\tconst BIGNUM *tmpEphPrivKey = NULL;\n\n\t/* get the EC_KEY key from the EVP_PKEY */\n\tif (rc == 0) {\n\t    ephEcKey = EVP_PKEY_get0_EC_KEY(ephKey);\t\t/* do not free */\n\t    if (ephEcKey == NULL) {\n\t\tif (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t       \"Error in EVP_PKEY_get0_EC_KEY()\\n\");\n\t\trc = TSS_RC_EC_KEY_CONVERT;\n\t    }\n\t}\n\t/* get the EC_KEY public points */\n\tif (rc == 0) {\n\t    ephEcPubKey =  EC_KEY_get0_public_key(ephEcKey);\t/* do not free */\n\t    if (ephEcPubKey == NULL) {\n\t\tif (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t       \"Error in EC_KEY_get0_public_key()\\n\");\n\t\trc = TSS_RC_EC_KEY_CONVERT;\n\t    }\n\t}\n\t/* get the EC_KEY private key */\n\tif (rc == 0) {\n\t    tmpEphPrivKey = EC_KEY_get0_private_key(ephEcKey);\t/* do not free */\n\t    if (tmpEphPrivKey == NULL) {\n\t\tif (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t   \"Error in EC_KEY_get0_private_key()\\n\");\n\t\trc = TSS_RC_EC_KEY_CONVERT;\n\t    }\n\t}\n\t/* duplicate to agree ith openssl 3.x impleentation, whee the caller frees */\n\tif (rc == 0) {\n\t    *ephPrivKey = BN_dup(tmpEphPrivKey);\t/* freed by caller */\n\t    if (ephPrivKey == NULL) {\n\t\tif (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t       \"Error in BN_dup()\\n\");\n\t\trc = TSS_RC_OUT_OF_MEMORY;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_BN_new(ephPubX);\t\t\t/* freed by caller */\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_BN_new(ephPubY);\t\t\t/* freed by caller */\n\t}\n\t/* get the public points */\n\tif (rc == 0) {\n\t    irc = EC_POINT_get_affine_coordinates(ecGroup, ephEcPubKey, *ephPubX, *ephPubY, NULL);\n\t    if (irc != 1) {\n\t\tif (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t       \"Error in EC_POINT_get_affine_coordinates()\\n\");\n\t\trc = TSS_RC_EC_KEY_CONVERT;\n\t    }\n\t}\n    }\n#else\t/* OpenSSL 3.x */\n    /* get the private key and public points */\n    ecGroup = ecGroup;\t/* not used for openssl 3.x */\n    if (rc == 0) {\n\tirc = EVP_PKEY_get_bn_param(ephKey, OSSL_PKEY_PARAM_PRIV_KEY,\n\t\t\t\t    ephPrivKey); \t\t\t/* freed by caller */\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t   \"Error in EVP_PKEY_get_bn_param()\\n\");\n            rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_get_bn_param(ephKey, OSSL_PKEY_PARAM_EC_PUB_X,\n\t\t\t\t    ephPubX); \t\t\t\t/* freed by caller */\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t   \"Error in EVP_PKEY_get_bn_param()\\n\");\n            rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n\n    }\n    if (rc == 0) {\n\tirc = EVP_PKEY_get_bn_param(ephKey, OSSL_PKEY_PARAM_EC_PUB_Y,\n\t\t\t\t    ephPubY);\t\t\t\t/* freed by caller */\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_ECC_GeneratePlatformEphemeralKey: \"\n\t\t\t\t   \"Error in EVP_PKEY_get_bn_param()\\n\");\n            rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n#endif\n    EVP_PKEY_CTX_free(ctx);\t/* @1 */\n    EVP_PKEY_free(ephKey);\t/* @2 */\n    return rc;\n}\n\n/* TSS_ECC_GetNid() gets the OpenSSL nid corresponding to the TCG algorithm ID curve */\n\nstatic TPM_RC TSS_ECC_GetNid(int\t\t*nid,\n\t\t\t     unsigned int\t*pointBytes,\n\t\t\t     TPMI_ECC_CURVE \tcurveID)\n{\n    TPM_RC \t\trc = 0;\n\n    switch (curveID) {\n      case TPM_ECC_NIST_P192:\n\t*nid = NID_X9_62_prime192v1;\t/* untested guess */\n\t*pointBytes = 24;\n\tbreak;\n      case TPM_ECC_NIST_P224:\n\t*nid = NID_secp224r1;\t\t/* untested guess */\n\t*pointBytes = 28;\n\tbreak;\n      case TPM_ECC_NIST_P256:\t\t/* TCG standard */\n\t*nid = NID_X9_62_prime256v1;\n\t*pointBytes = 32;\n\tbreak;\n      case TPM_ECC_NIST_P384:\t\t/* TCG standard */\n\t*nid = NID_secp384r1;\n\t*pointBytes = 48;\n\tbreak;\n      case TPM_ECC_NIST_P521:\n\t*nid = NID_secp521r1;\t\t/* untested guess */\n\t*pointBytes = 66;\n\tbreak;\n      case TPM_ECC_BN_P256:\n      case TPM_ECC_BN_P638:\n      case TPM_ECC_SM2_P256:\n      case TPM_ECC_BP_P256_R1:\n      case TPM_ECC_BP_P384_R1:\n      case TPM_ECC_BP_P512_R1:\n      case TPM_ECC_CURVE_25519:\n      default:\n\t*nid = NID_undef;\n\t*pointBytes = 0;\n\tif (tssVerbose) printf(\"TSS_ECC_GetNid: TCG curve %04x not supported \\n\", curveID);\n\trc = TSS_RC_EC_KEY_CONVERT;\n    }\n    return rc;\n}\n\n/* converts the TPMT_PUBLIC to an OpenSSL public EC_POINT.\n\n   ecGroup is input here, calculated from the nid for the publicArea->parameters.eccDetail.curveID\n*/\n\nstatic TPM_RC TSS_ECC_TPMTPublicToEcPoint(EC_GROUP *ecGroup,\n\t\t\t\t\t  TPMT_PUBLIC *publicArea,\n\t\t\t\t\t  EC_POINT **tpmPubPoint)\t/* freed by caller */\n{\n    TPM_RC \trc = 0;\n    int \tirc;\n    BIGNUM \t*x = NULL;\n    BIGNUM \t*y = NULL;\n\n    /* Create the bignums for the coordinates of the point */\n    if (rc == 0) {\n\trc = TSS_bin2bn(&x,\t\t\t\t\t/* freed @1 */\n\t\t\tpublicArea->unique.ecc.x.t.buffer,\n\t\t\tpublicArea->unique.ecc.x.t.size);\n    }\n    if (rc == 0) {\n\trc = TSS_bin2bn(&y,\t\t\t\t\t/* freed @2 */\n\t\t\tpublicArea->unique.ecc.y.t.buffer,\n\t\t\tpublicArea->unique.ecc.y.t.size);\n    }\n    /* assign curve to EC_POINT */\n    if (rc == 0) {\n\t*tpmPubPoint = EC_POINT_new(ecGroup);\t\t\t/* freed by caller */\n\tif (*tpmPubPoint == NULL) {\n\t    if (tssVerbose) printf(\"TSS_ECC_TPMTPublicToEcPoint: EC_POINT_new failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* add the public points X and Y */\n    if (rc == 0) {\n\tirc = EC_POINT_set_affine_coordinates(ecGroup, *tpmPubPoint, x, y, NULL);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_ECC_TPMTPublicToEcPoint: \"\n\t\t\t\t   \"Error calling EC_POINT_set_affine_coordinates()\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* sanity check on TPM key, validate that the public point is on the curve */\n    if (rc == 0) {\n\tirc = EC_POINT_is_on_curve(ecGroup, *tpmPubPoint, NULL);\n\tif (irc != 1) {\n\t    printf(\"TSS_ECC_TPMTPublicToEcPoint: EC_POINT_is_on_curve() failed\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    BN_free(x);\t\t/* @1 */\n    BN_free(y);\t\t/* @2 */\n    return rc;\n}\n\n/* TSS_ECC_Salt() returns both the plaintext and excrypted salt, based on the salt key bPublic.\n\n   TPM2B_DIGEST salt - used to caculate the session key\n   TPM2B_ENCRYPTED_SECRET - encrypted salt, send to TPM\n*/\n\nTPM_RC TSS_ECC_Salt(TPM2B_DIGEST \t\t*salt,\n\t\t    TPM2B_ENCRYPTED_SECRET\t*encryptedSalt,\n\t\t    TPMT_PUBLIC\t\t\t*publicArea)\t\t/* salt asymmetric key */\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tirc = 0;\n    int\t\t\tnid = NID_undef;\t/* nid for public key */\n    unsigned int\tpointBytes = 0;\t\t/* bytes in the salt public point */\n    BIGNUM \t\t*ephPrivKey = NULL;\t/* ephemeral private key */\n    BIGNUM \t\t*ephPubX = NULL;\t/* ephemeral public key X */\n    BIGNUM \t\t*ephPubY = NULL;\t/* ephemeral public key Y */\n    TPMS_ECC_POINT \tQeu;\t\t\t/* ephemeral public point TPM format */\n    EC_GROUP \t\t*ecGroup = NULL;\t/* Group defines the used curve */\n    EC_POINT \t\t*tpmPubPoint = NULL;    /* Public part of TPM key */\n    EC_POINT \t\t*pointP = NULL;\t\t/* P = ephemeral private * tpm public */\n    BIGNUM \t\t*ZeeX = NULL;\t\t/* Z = x coordinate of P */\n    TPM2B_ECC_PARAMETER Zee;\t\t\t/* Z = X point of pointP */\n    uint32_t\t\tsizeInBytes;\t\t/* digest size based on nameAlg */\n    uint32_t\t\tsizeInBits;\t\t/* digest size based on nameAlg */\n\n    /* map from the TPM curve ID to OpenSSL nid, and get the bytes in the point */\n    if (rc == 0) {\n\trc = TSS_ECC_GetNid(&nid, &pointBytes,\n\t\t\t    publicArea->parameters.eccDetail.curveID);\n    }\n    /* ecGroup defines the used curve */\n    if (rc == 0) {\n\tif (!(ecGroup = EC_GROUP_new_by_curve_name(nid))) {\n\t    if (tssVerbose) printf(\"TSS_ECC_Salt: \"\n\t\t\t\t    \"Error calling EC_GROUP_new_by_curve_name()\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* Generate the TSS ECC ephemeral key pair outside the TPM for the salt. The public part of this\n       key becomes the encrypted salt. */\n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_ECC_Salt: \"\n\t\t\t\t\"Calling TSS_ECC_GeneratePlatformEphemeralKey()\\n\");\n\trc = TSS_ECC_GeneratePlatformEphemeralKey(&ephPrivKey,\t/* freed @3 */\n\t\t\t\t\t\t  &ephPubX,\t/* freed @4 */\n\t\t\t\t\t\t  &ephPubY,\t/* freed @5 */\n\t\t\t\t\t\t  ecGroup,\n\t\t\t\t\t\t  nid);\n    }\n    /* Convert the ephemeral key public point to TPM format. Qeu Part 1 ECDH  */\n    if (rc == 0) {\n\tQeu.x.t.size = pointBytes;\n\trc = TSS_bn2binpad((unsigned char *)&Qeu.x.t.buffer, pointBytes, ephPubX);\n    }\n    if (rc == 0) {\n\tQeu.y.t.size = pointBytes;\n\trc = TSS_bn2binpad((unsigned char *)&Qeu.y.t.buffer, pointBytes, ephPubY);\n    }\n    /* convert the TPM salt public key point to an OpenSSL public point */\n    if (rc == 0) {\n\trc = TSS_ECC_TPMTPublicToEcPoint(ecGroup, publicArea,\n\t\t\t\t\t &tpmPubPoint);\t\t\t/* freed @6 */\n    }\n    /* create an EC_POINT for the multiplication, assign curve from group */\n    if (rc == 0) {\n\tpointP = EC_POINT_new(ecGroup);\n\tif (pointP == NULL) {\n\t    if (tssVerbose) printf(\"TSS_ECC_Salt: EC_POINT_new for pointP failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    /* Multiply the TPM public key (q) with the ephemeral private key (m)  n + q * m\n       See Part 1 C.6.1.\tECDH to calculate the point P */\n    if (rc == 0) {\n\tirc = EC_POINT_mul(ecGroup,\n\t\t\t   pointP,\t/* r */\n\t\t\t   NULL,\t/* n not used */\n\t\t\t   tpmPubPoint,\t/* q */\n\t\t\t   ephPrivKey,\t/* m */\n\t\t\t   NULL);\t/* ctx */\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_ECC_Salt: EC_POINT_mul failed\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* Z is the x-coordinate of P */\n    if (rc == 0) {\n\trc = TSS_BN_new(&ZeeX);\t\t/* freed @7 */\n    }\n    if (rc == 0) {\n\tirc = EC_POINT_get_affine_coordinates(ecGroup, pointP,\n\t\t\t\t\t      ZeeX, NULL, NULL);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_ECC_Salt: EC_POINT_get_affine_coordinates failed\\n\");\n\t    rc = TSS_RC_EC_KEY_CONVERT;\n\t}\n    }\n    /* convert Z to TPM2B_ECC_PARAMETER */\n    if (rc == 0) {\n\tZee.t.size = pointBytes;\n\trc = TSS_bn2binpad(Zee.t.buffer, pointBytes, ZeeX);\n    }\n    /* encrypted salt is the ephemeral public key */\n    /* Write the public ephemeral key Qeu in TPM format to encryptedSalt output */\n    if (rc == 0) {\n\tBYTE *buffer = encryptedSalt->t.secret;\t\t/* tmp buffer because marshal moves it */\n\tuint32_t size = sizeof(TPMU_ENCRYPTED_SECRET);\t/* max size */\n\tencryptedSalt->t.size = 0;\t\t\t/* bytes written aftre marshaling */\n\n\trc = TSS_TPMS_ECC_POINT_Marshalu(&Qeu, &encryptedSalt->t.size, &buffer, &size);\n    }\n    if (rc == 0) {\n\tsizeInBytes = TSS_GetDigestSize(publicArea->nameAlg);\n\tsizeInBits =  sizeInBytes * 8;\n\tif (tssVverbose) printf(\"TSS_ECC_Salt: \"\n\t\t\t\t\"Calling TSS_KDFE\\n\");\n\t/* TPM2B_DIGEST salt size is the largest supported digest algorithm.\n\t   This has already been validated when unmarshaling the Name hash algorithm.\n\t*/\n\t/* salt = KDFe(tpmKey_NameAlg, sharedX, \"SECRET\", P_caller, P_tpm,\n\t   tpmKey_NameAlgSizeBits) */\n\tsalt->t.size = sizeInBytes;\n\trc = TSS_KDFE((uint8_t *)&salt->t.buffer, \t/* KDFe output */\n\t\t      publicArea->nameAlg,\t\t/* hash algorithm */\n\t\t      &Zee.b,\t\t\t\t/* Z - X point of pointP */\n\t\t      \"SECRET\",\t\t\t\t/* KDFe label */\n\t\t      &Qeu.x.b,\t\t\t\t/* context U - ephemeral public point X */\n\t\t      &publicArea->unique.ecc.x.b,\t/* context V - X point of TPM key */\n\t\t      sizeInBits);\t\t\t/* required size of key in bits */\n    }\n    if (rc == 0) { \n\tif (tssVverbose) TSS_PrintAll(\"TSS_ECC_Salt: salt\",\n\t\t\t\t      (uint8_t *)&salt->t.buffer,\n\t\t\t\t      salt->t.size);\n    }\n    EC_GROUP_free(ecGroup);\t\t/* @1 */\n    BN_clear_free(ephPrivKey);\t\t/* @3 */\n    BN_free(ephPubX);\t\t\t/* @4 */\n    BN_free(ephPubY);\t\t\t/* @5 */\n    EC_POINT_free(tpmPubPoint);\t\t/* @6 */\n    BN_clear_free(ZeeX);\t\t/* @7 */\n    return rc;\n}\n\n/* TSS_BN_new() wraps the openSSL function in a TPM error handler\n */\n\nstatic TPM_RC TSS_BN_new(BIGNUM **bn)\t\t/* freed by caller */\n{\n    TPM_RC\trc = 0;\n\n    if (rc == 0) {\n\tif (*bn != NULL) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_BN_new: Error (fatal), *bn %p should be NULL before BN_new()\\n\", *bn);\n\t    rc = TSS_RC_ALLOC_INPUT;\n\t}\n    }\n    if (rc == 0) {\n\t*bn = BN_new();\n\tif (*bn == NULL) {\n\t    if (tssVerbose) printf(\"TSS_BN_new: BN_new() failed\\n\");\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n\n/* TSS_bin2bn() wraps the openSSL function in a TPM error handler\n\n   Converts a char array to bignum\n\n   bn must be freed by the caller.\n*/\n\nstatic TPM_RC TSS_bin2bn(BIGNUM **bn, const unsigned char *bin, unsigned int bytes)\n{\n    TPM_RC\trc = 0;\n\n    /* BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);\n\n       BN_bin2bn() converts the positive integer in big-endian form of length len at s into a BIGNUM\n       and places it in ret. If ret is NULL, a new BIGNUM is created.\n\n       BN_bin2bn() returns the BIGNUM, NULL on error.\n    */\n    if (rc == 0) {\n        *bn = BN_bin2bn(bin, bytes, *bn);\n        if (*bn == NULL) {\n            if (tssVerbose) printf(\"TSS_bin2bn: Error in BN_bin2bn\\n\");\n            rc = TSS_RC_BIGNUM;\n        }\n    }\n    return rc;\n}\n\n#ifndef TPM_TSS_NOECC\n\n/* TSS_bn2binpad() wraps the openSSL function in a TPM error handler\n\n   Converts a bignum to padded char array\n*/\n\nstatic TPM_RC TSS_bn2binpad(unsigned char *bin, int binlen, const BIGNUM *bn)\n{\n    TPM_RC\trc = 0;\n    int\t\tirc = 0;\n\n    irc = BN_bn2binpad(bn, bin, binlen);\n    if (irc == -1) {\n\tif (tssVerbose) printf(\"TSS_bn2binpad: Error in BN_bn2binpad\\n\");\n\trc = TSS_RC_BIGNUM;\n    }\n    return rc;\n}\n\n#endif\t/* TPM_TSS_NOECC */\n\n/*\n  AES\n*/\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\nTPM_RC TSS_AES_GetEncKeySize(size_t *tssSessionEncKeySize)\n{\n    *tssSessionEncKeySize = sizeof(AES_KEY);\n    return 0;\n}\nTPM_RC TSS_AES_GetDecKeySize(size_t *tssSessionDecKeySize)\n{\n    *tssSessionDecKeySize = sizeof(AES_KEY);\n    return 0;\n}\n#endif\n\n/* TSS_AES_KeyAllocate() allocates memory for the AES encryption and decryption keys.\n */\n\nTPM_RC TSS_AES_KeyAllocate(void **tssSessionEncKey,\n\t\t\t   void **tssSessionDecKey)\n{\n    TPM_RC\t\trc = 0;\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    size_t tssSessionEncKeySize;\n    size_t tssSessionDecKeySize;\n\n    /* crypto library dependent code to allocate the session state encryption and decryption keys.\n       They are probably always the same size, but it's safer not to assume that. */\n    if (rc == 0) {\n\trc = TSS_AES_GetEncKeySize(&tssSessionEncKeySize);\n    }\n    if (rc == 0) {\n\trc = TSS_AES_GetDecKeySize(&tssSessionDecKeySize);\n    }\n    if (rc == 0) {\n        rc = TSS_Malloc((uint8_t **)tssSessionEncKey, (uint32_t)tssSessionEncKeySize);\n    }\n    if (rc == 0) {\n        rc = TSS_Malloc((uint8_t **)tssSessionDecKey, (uint32_t)tssSessionDecKeySize);\n    }\n#else\n    if (rc == 0) {\n\t*tssSessionEncKey = EVP_CIPHER_CTX_new();\n\tif (*tssSessionEncKey == NULL) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_AES_KeyAllocate: Error creating openssl AES decryption key\\n\");\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;\n\t}\n    }\n    if (rc == 0) {\n\t*tssSessionDecKey = EVP_CIPHER_CTX_new();\n\tif (*tssSessionDecKey == NULL) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_AES_KeyAllocate: Error creating openssl AES decryption key\\n\");\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;\n\t}\n    }\n#endif\n    return rc;\n}\n\nTPM_RC TSS_AES_KeyFree(void *tssSessionEncKey,\n\t\t       void *tssSessionDecKey)\n{\n    TPM_RC rc = 0;\n\n#ifndef TPM_TSS_NOFILE\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    free(tssSessionEncKey);\n    free(tssSessionDecKey);\n#else\n    EVP_CIPHER_CTX_free(tssSessionEncKey);\n    EVP_CIPHER_CTX_free(tssSessionDecKey);\n#endif\t/* OPENSSL_VERSION_NUMBER  */\n#else\n    tssSessionEncKey = tssSessionEncKey;\n    tssSessionDecKey = tssSessionDecKey;\n#endif\t/* TPM_TSS_NOFILE */\n    return rc;\n}\n\n#define TSS_AES_KEY_BITS 128\n\n#ifndef TPM_TSS_NOFILE\n\nTPM_RC TSS_AES_KeyGenerate(void *tssSessionEncKey,\n\t\t\t   void *tssSessionDecKey)\n{\n    TPM_RC\t\trc = 0;\n    int \t\tirc;\n    unsigned char \tuserKey[AES_128_BLOCK_SIZE_BYTES];\n    const char \t\t*envKeyString = NULL;\n    unsigned char \t*envKeyBin = NULL;\n    size_t \t\tenvKeyBinLen;\n\n    if (rc == 0) {\n\tenvKeyString = getenv(\"TPM_SESSION_ENCKEY\");\n    }\n    if (envKeyString == NULL) {\n\t/* If the env variable TPM_SESSION_ENCKEY is not set, generate a random key for this\n\t   TSS_CONTEXT */\n\tif (rc == 0) {\n\t    /* initialize userKey to silence valgrind false positive */\n\t    memset(userKey, 0, sizeof(userKey));\n\t    rc = TSS_RandBytes(userKey, AES_128_BLOCK_SIZE_BYTES);\n\t}\n    }\n    /* The env variable TPM_SESSION_ENCKEY can set a (typically constant) encryption key.  This is\n       useful for scripting, where the env variable is set to a random seed at the beginning of the\n       script. */\n    else {\n\t/* hexascii to binary */\n\tif (rc == 0) {\n\t    rc = TSS_Array_Scan(&envKeyBin,\t\t\t/* freed @1 */\n\t\t\t\t&envKeyBinLen, envKeyString);\n\t}\n\t/* range check */\n\tif (rc == 0) {\n\t    if (envKeyBinLen != AES_128_BLOCK_SIZE_BYTES) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_AES_KeyGenerate: Error, env variable length %lu not %lu\\n\",\n\t\t\t   (unsigned long)envKeyBinLen, (unsigned long)sizeof(userKey));\n\t\trc = TSS_RC_BAD_PROPERTY_VALUE;\n\t    }\n\t}\n\t/* copy the binary to the common userKey for use below */\n\tif (rc == 0) {\n\t    memcpy(userKey, envKeyBin, envKeyBinLen);\n\t}\n    }\n    /* translate userKey to openssl key tokens */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n        irc = AES_set_encrypt_key(userKey,\n                                  TSS_AES_KEY_BITS,\n                                  tssSessionEncKey);\n\t/* should never occur, null pointers or bad bit size */\n\tif (irc != 0) {\n            if (tssVerbose)\n\t\tprintf(\"TSS_AES_KeyGenerate: Error setting openssl AES encryption key\\n\");\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;\n\t}\n    }\n    if (rc == 0) {\n\tirc = AES_set_decrypt_key(userKey,\n\t\t\t\t  TSS_AES_KEY_BITS,\n\t\t\t\t  tssSessionDecKey);\n\t/* should never occur, null pointers or bad bit size */\n\tif (irc != 0) {\n            if (tssVerbose)\n\t\tprintf(\"TSS_AES_KeyGenerate: Error setting openssl AES decryption key\\n\");\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;\n\t}\n    }\n#else\n    {\n\tEVP_CIPHER *cipher = NULL;\n\tunsigned char\tivec[AES_128_BLOCK_SIZE_BYTES];       /* initial chaining vector */\n        memset(ivec, 0, sizeof(ivec));\n\n\tif (rc == 0) {\n\t    cipher = EVP_CIPHER_fetch(NULL, \"AES-128-CBC\", NULL);\t/* freed @1 */\n\t    if (cipher == NULL) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_AES_KeyGenerate: Error getting openssl cipher\\n\");\n\t\trc = TSS_RC_AES_KEYGEN_FAILURE;\n\t    }\n\t}\n\t/* encryption context */\n\tif (rc == 0) {\n\t    irc = EVP_CipherInit_ex2(tssSessionEncKey, cipher, userKey, ivec, 1, NULL);\n\t    if (irc != 1) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_AES_KeyGenerate: Error setting openssl AES encryption key\\n\");\n\t\trc = TSS_RC_AES_KEYGEN_FAILURE;\n\t    }\n\t}\n\tif (rc == 0) {\t\t/* always returns 1 */\n\t    EVP_CIPHER_CTX_set_padding(tssSessionEncKey, 0);\n\t}\n\t/* decryption context */\n\tif (rc == 0) {\n\t    irc = EVP_CipherInit_ex2(tssSessionDecKey, cipher, userKey, ivec, 0, NULL);\n\t    if (irc != 1) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_AES_KeyGenerate: Error setting openssl AES decryption key\\n\");\n\t\trc = TSS_RC_AES_KEYGEN_FAILURE;\n\t    }\n\t}\n\tif (rc == 0) {\t\t/* always returns 1 */\n\t    EVP_CIPHER_CTX_set_padding(tssSessionDecKey, 0);\n\t}\n\tEVP_CIPHER_free(cipher);\t/* @1 */\n\n    }\n#endif\n    free(envKeyBin);\t/* @1 */\n    return rc;\n}\n\n#endif\n\n/* TSS_AES_Encrypt() is AES non-portable code to encrypt 'decrypt_data' to 'encrypt_data' using CBC.\n   This function uses the session encryption key for encrypting session state.\n\n   The stream is padded as per PKCS#7 / RFC2630\n\n   'encrypt_data' must be free by the caller\n*/\n\nTPM_RC TSS_AES_Encrypt(void *tssSessionEncKey,\n\t\t       unsigned char **encrypt_data,   \t\t/* output, caller frees */\n\t\t       uint32_t *encrypt_length,\t\t/* output */\n\t\t       const unsigned char *decrypt_data,\t/* input */\n\t\t       uint32_t decrypt_length)\t\t\t/* input */\n{\n    TPM_RC\t\trc = 0;\n#if OPENSSL_VERSION_NUMBER >= 0x30000000\n    int \t\tirc;\n#endif\n    uint32_t\t\tpad_length;\n    unsigned char\t*decrypt_data_pad = NULL;\n\n    if (rc == 0) {\n        /* calculate the pad length and padded data length */\n        pad_length = AES_128_BLOCK_SIZE_BYTES - (decrypt_length % AES_128_BLOCK_SIZE_BYTES);\n        *encrypt_length = decrypt_length + pad_length;\n         /* allocate memory for the encrypted response */\n        rc = TSS_Malloc(encrypt_data, *encrypt_length);\n    }\n    /* allocate memory for the padded decrypted data */\n    if (rc == 0) {\n        rc = TSS_Malloc(&decrypt_data_pad, *encrypt_length);    /* freed @1 */\n    }\n    /* pad the decrypted clear text data */\n    if (rc == 0) {\n        /* unpadded original data */\n        memcpy(decrypt_data_pad, decrypt_data, decrypt_length);\n        /* last gets pad = pad length */\n        memset(decrypt_data_pad + decrypt_length, pad_length, pad_length);\n    }\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n        /* set the IV */\n\tunsigned char\tivec[AES_128_BLOCK_SIZE_BYTES];       /* initial chaining vector */\n        memset(ivec, 0, sizeof(ivec));\n        /* encrypt the padded input to the output */\n        AES_cbc_encrypt(decrypt_data_pad,\n                        *encrypt_data,\n                        *encrypt_length,\n                        tssSessionEncKey,\n                        ivec,\n                        AES_ENCRYPT);\n    }\n#else\n    /* reset the encrypt context */\n    if (rc == 0) {\n\tirc = EVP_CipherInit_ex2(tssSessionEncKey, NULL, NULL, NULL, 1, NULL);\n\tif (irc != 1) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_AES_Encrypt: Error setting openssl AES encryption key\\n\");\n\t    rc = TSS_RC_AES_ENCRYPT_FAILURE;\n\t}\n    }\n    if (rc == 0) {\n\tuint32_t decrypt_length_pad = decrypt_length + pad_length;\n\tint encLength;\t\t/* because openssl uses an int length */\n\tirc = EVP_CipherUpdate(tssSessionEncKey,\n\t\t\t       *encrypt_data, &encLength,\n\t\t\t\tdecrypt_data_pad, decrypt_length_pad);\n\t*encrypt_length = encLength;\t/* cast back to unsigned for return */\n\tif (irc != 1) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_AES_Encrypt: Error in EVP_EncryptUpdate\\n\");\n\t    rc = TSS_RC_AES_ENCRYPT_FAILURE;\n\t}\n    }\n#endif\n    free(decrypt_data_pad);     /* @1 */\n    return rc;\n}\n\n/* TSS_AES_Decrypt() is AES non-portable code to decrypt 'encrypt_data' to 'decrypt_data' using CBC.\n   This function uses the session encryption key for decrypting session state.\n\n   The stream must be padded as per PKCS#7 / RFC2630\n\n   decrypt_data must be free by the caller\n*/\n\nTPM_RC TSS_AES_Decrypt(void *tssSessionDecKey,\n\t\t       unsigned char **decrypt_data,   \t\t/* output, caller frees */\n\t\t       uint32_t *decrypt_length,\t\t/* output */\n\t\t       const unsigned char *encrypt_data,\t/* input */\n\t\t       uint32_t encrypt_length)\t\t\t/* input */\n{\n    TPM_RC          \trc = 0;\n#if OPENSSL_VERSION_NUMBER >= 0x30000000\n    int \t\tirc;\n#endif\n    uint32_t\t\tpad_length;\n    uint32_t\t\ti;\n    unsigned char       *pad_data;\n\n    /* sanity check encrypted length */\n    if (rc == 0) {\n        if (encrypt_length < AES_128_BLOCK_SIZE_BYTES) {\n            if (tssVerbose) printf(\"TSS_AES_Decrypt: Error, bad length %u\\n\",\n\t\t\t\t   encrypt_length);\n            rc = TSS_RC_AES_DECRYPT_FAILURE;\n        }\n    }\n    /* allocate memory for the padded decrypted data */\n    if (rc == 0) {\n        rc = TSS_Malloc(decrypt_data, encrypt_length);\n    }\n    /* decrypt the input to the padded output */\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    if (rc == 0) {\n\t/* set the IV */\n\tunsigned char       ivec[AES_128_BLOCK_SIZE_BYTES];       /* initial chaining vector */\n        memset(ivec, 0, sizeof(ivec));\n        /* decrypt the padded input to the output */\n        AES_cbc_encrypt(encrypt_data,\n                        *decrypt_data,\n                        encrypt_length,\n                        tssSessionDecKey,\n                        ivec,\n                        AES_DECRYPT);\n    }\n#else\n    /* reset the decrypt context */\n    if (rc == 0) {\n\tirc = EVP_CipherInit_ex2(tssSessionDecKey, NULL, NULL, NULL, 0, NULL);\n\tif (irc != 1) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_AES_Decrypt: Error setting openssl AES decryption key\\n\");\n\t    rc = TSS_RC_AES_DECRYPT_FAILURE;\n\t}\n    }\n    if (rc == 0) {\n\tint decLength;\t\t/* because openssl uses an int length */\n\tirc = EVP_DecryptUpdate(tssSessionDecKey,\n\t\t\t\t*decrypt_data, &decLength,\n\t\t\t\tencrypt_data, encrypt_length);\n\t*decrypt_length = decLength;\t/* cast back to unsigned for return */\n\tif (irc != 1) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_AES_Decrypt: Error in EVP_DecryptUpdate\\n\");\n\t    rc = TSS_RC_AES_DECRYPT_FAILURE;\n\t}\n    }\n#endif\n    /* get the pad length */\n    if (rc == 0) {\n        /* get the pad length from the last byte */\n        pad_length = (uint32_t)*(*decrypt_data + encrypt_length - 1);\n        /* sanity check the pad length */\n        if ((pad_length == 0) ||\n            (pad_length > AES_128_BLOCK_SIZE_BYTES)) {\n            if (tssVerbose) printf(\"TSS_AES_Decrypt: Error, illegal pad length\\n\");\n            rc = TSS_RC_AES_DECRYPT_FAILURE;\n        }\n    }\n    if (rc == 0) {\n        /* get the unpadded length */\n        *decrypt_length = encrypt_length - pad_length;\n        /* pad starting point */\n        pad_data = *decrypt_data + *decrypt_length;\n        /* sanity check the pad */\n        for (i = 0 ; (rc == 0) && (i < pad_length) ; i++, pad_data++) {\n            if (*pad_data != pad_length) {\n                if (tssVerbose) printf(\"TSS_AES_Decrypt: Error, bad pad %02x at index %u\\n\",\n\t\t\t\t       *pad_data, i);\n                rc = TSS_RC_AES_DECRYPT_FAILURE;\n            }\n        }\n    }\n    return rc;\n}\n\nTPM_RC TSS_AES_EncryptCFB(uint8_t\t*dOut,\t\t/* OUT: the encrypted data */\n\t\t\t  uint32_t\tkeySizeInBits,\t/* IN: key size in bits */\n\t\t\t  uint8_t \t*key,           /* IN: key buffer */\n\t\t\t  uint8_t \t*iv,\t\t/* IN/OUT: IV for decryption */\n\t\t\t  uint32_t\tdInSize,       \t/* IN: data size */\n\t\t\t  uint8_t \t*dIn)\t\t/* IN: data buffer */\n{\n    TPM_RC\trc = 0;\n    int \tirc;\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    int\t\tblockSize;\n    int32_t\tdSize;         /* signed version of dInSize */\n    AES_KEY\taeskey;\n\n    /* Create AES encryption key token */\n    if (rc == 0) {\n\tmemset(&aeskey, 0, sizeof(AES_KEY));\t/* to suppress Coverity false positive */\n\tirc = AES_set_encrypt_key(key, keySizeInBits, &aeskey);\n\tif (irc != 0) {\n            if (tssVerbose) printf(\"TSS_AES_EncryptCFB: Error setting openssl AES encryption key\\n\");\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;  /* should never occur, null pointers or bad bit size */\n\t}\n    }\n    if (rc == 0) {\n\t/* Encrypt the current IV into the new IV, XOR in the data, and copy to output */\n\tfor(dSize = (int32_t)dInSize ; dSize > 0 ; dSize -= 16, dOut += 16, dIn += 16) {\n\t    /* Encrypt the current value of the IV to the intermediate value.  Store in old iv,\n\t       since it's not needed anymore. */\n\t    AES_encrypt(iv, iv, &aeskey);\n\t    blockSize = (dSize < 16) ? dSize : 16;\t/* last block can be < 16 */\n\t    TSS_XOR(dOut, dIn, iv, blockSize);\n\t    memcpy(iv, dOut, blockSize);\n\t}\n    }\n#else\n    {\n\tEVP_CIPHER_CTX *ctx = NULL;\n\n\t/* initialize the key context */\n\tif (rc == 0) {\n\t    rc = TSS_AES_CFB(&ctx,\t\t/* freed @2 */\n\t\t\t     keySizeInBits,\t/* IN: key size in bits */\n\t\t\t     key,           \t/* IN: key buffer */\n\t\t\t     iv,            \t/* IN: IV */\n\t\t\t     1);\t\t/* encrypt */\n\t}\n\tif (rc == 0) {\n\t    int encLength;\t\t/* because openssl uses an int length */\n\t    irc = EVP_CipherUpdate(ctx,\n\t\t\t\t   dOut, &encLength,\n\t\t\t\t   dIn, dInSize);\n\t    if (irc != 1) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_AES_EncryptCFB: Error in EVP_EncryptUpdate\\n\");\n\t\trc = TSS_RC_AES_ENCRYPT_FAILURE;\n\t    }\n\t}\n\tEVP_CIPHER_CTX_free(ctx);\t/* @2 */\n    }\n#endif\n    return rc;\n}\n\nTPM_RC TSS_AES_DecryptCFB(uint8_t *dOut,          \t/* OUT: the decrypted data */\n\t\t\t  uint32_t keySizeInBits, \t/* IN: key size in bits */\n\t\t\t  uint8_t *key,           \t/* IN: key buffer */\n\t\t\t  uint8_t *iv,            \t/* IN/OUT: IV for decryption. */\n\t\t\t  uint32_t dInSize,       \t/* IN: data size */\n\t\t\t  uint8_t *dIn)\t\t\t/* IN: data buffer */\n{\n    TPM_RC\trc = 0;\n    int \tirc;\n\n#if OPENSSL_VERSION_NUMBER < 0x30000000\n    uint8_t\ttmp[16];\n    int\t\tblockSize;\n    AES_KEY\taesKey;\n    int32_t\tdSize;\n\n    /* Create AES encryption key token */\n    if (rc == 0) {\n\tmemset(&aesKey, 0, sizeof(AES_KEY));\t/* to suppress Coverity false positive */\n\tirc = AES_set_encrypt_key(key, keySizeInBits, &aesKey);\n\tif (irc != 0) {\n            if (tssVerbose) printf(\"TSS_AES_DecryptCFB: Error setting openssl AES encryption key\\n\");\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;  /* should never occur, null pointers or bad bit size */\n\t}\n    }\n    if (rc == 0) {\n\tfor (dSize = (int32_t)dInSize ; dSize > 0; dSize -= 16, dOut += 16, dIn += 16) {\n\t    /* Encrypt the IV into the temp buffer */\n\t    AES_encrypt(iv, tmp, &aesKey);\n\t    blockSize = (dSize < 16) ? dSize : 16;\t/* last block can be < 16 */\n\t    TSS_XOR(dOut, dIn, tmp, blockSize);\n\t    memcpy(iv, dIn, blockSize);\n\t}\n    }\n#else\n    {\n\tEVP_CIPHER_CTX *ctx = NULL;\n\n\t/* initialize the key context */\n\tif (rc == 0) {\n\t    rc = TSS_AES_CFB(&ctx,\t\t/* freed @2 */\n\t\t\t     keySizeInBits,\t/* IN: key size in bits */\n\t\t\t     key,           \t/* IN: key buffer */\n\t\t\t     iv,            \t/* IN: IV */\n\t\t\t     0);\t\t/* encrypt */\n\t}\n\tif (rc == 0) {\n\t    int encLength;\t\t/* because openssl uses an int length */\n\t    irc = EVP_CipherUpdate(ctx,\n\t\t\t\t   dOut, &encLength,\n\t\t\t\t   dIn, dInSize);\n\t    if (irc != 1) {\n\t\tif (tssVerbose)\n\t\t    printf(\"TSS_AES_DecryptCFB: Error in EVP_EncryptUpdate\\n\");\n\t\trc = TSS_RC_AES_DECRYPT_FAILURE;\n\t    }\n\t}\n\tEVP_CIPHER_CTX_free(ctx);\t/* @2 */\n    }\n#endif\n   return rc;\n}\n\n#if OPENSSL_VERSION_NUMBER >=  0x30000000\n/* TSS_AES_CFB() is openssl common code to initialize the key context for AES CFB encrypt and\n   decrypt */\n\nstatic TPM_RC TSS_AES_CFB(EVP_CIPHER_CTX **ctx,\t\t/* freed by caller */\n\t\t\t  uint32_t keySizeInBits,\t/* IN: key size in bits */\n\t\t\t  uint8_t *key,           \t/* IN: key buffer */\n\t\t\t  uint8_t *iv,            \t/* IN: IV */\n\t\t\t  int encrypt)\t\t\t/* boolean */\n\n{\n    TPM_RC\trc = 0;\n    int \tirc;\n    EVP_CIPHER *cipher = NULL;\n\n    /* currently supports CFB AES 128 and 256 */\n    if (rc == 0) {\n\tswitch (keySizeInBits) {\n\t  case 128:\n\t    cipher = EVP_CIPHER_fetch(NULL, \"AES-128-CFB\", NULL);\t/* freed @1 */\n\t    break;\n\t  case 256:\n\t    cipher = EVP_CIPHER_fetch(NULL, \"AES-256-CFB\", NULL);\t/* freed @1 */\n\t    break;\n\t  default:\n\t    printf(\"TSS_AES_CFB: keySizeInBits %u not supported\\n\", keySizeInBits);\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;\n\t    break;\n\t}\n\tif (cipher == NULL) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_AES_CFB: Error getting openssl cipher\\n\");\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;\n\t}\n    }\n    /* allocate the context */\n    if (rc == 0) {\n\t*ctx = EVP_CIPHER_CTX_new();\t\t/* freed by caller */\n\tif (ctx == NULL) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_AES_CFB: Error creating openssl AES decryption key\\n\");\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;\n\t}\n    }\n    /* initialize the context with the key and IV */\n    if (rc == 0) {\n\tirc = EVP_CipherInit_ex2(*ctx, cipher, key, iv, encrypt, NULL);\n\tif (irc != 1) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_AES_CFB: Error setting openssl AES encryption key\\n\");\n\t    rc = TSS_RC_AES_KEYGEN_FAILURE;\n\t}\n    }\n    EVP_CIPHER_free(cipher);\t/* @1 */\n    return rc;\n}\n#endif\n"
  },
  {
    "path": "ibmtss-ftpm/tsscryptoh.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TSS Library Independent Crypto Support\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <string.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/tsserror.h>\n\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsscrypto.h>\n\nextern int tssVverbose;\nextern int tssVerbose;\n\n/* local prototypes */\n\nstatic TPM_RC TSS_MGF1(unsigned char       \t*mask,\n\t\t       uint32_t            \tmaskLen,\n\t\t       const unsigned char \t*mgfSeed,\n\t\t       uint16_t\t\t\tmgfSeedlen,\n\t\t       TPMI_ALG_HASH \t\thalg);\n\n/* TSS_HMAC_Generate() can be called directly to HMAC a list of streams.\n   \n   The ... arguments are a message list of the form\n   int length, unsigned char *buffer\n   terminated by a 0 length\n*/\n\n/* On call, digest->hashAlg is the desired hash algorithm */\n\nTPM_RC TSS_HMAC_Generate(TPMT_HA *digest,\t\t/* largest size of a digest */\n\t\t\t const TPM2B_KEY *hmacKey,\n\t\t\t ...)\n{\n    TPM_RC\t\trc = 0;\n    va_list\t\tap;\n    \n    va_start(ap, hmacKey);\n    rc = TSS_HMAC_Generate_valist(digest, hmacKey, ap);\n    va_end(ap);\n    return rc;\n}\n\n/* TSS_HMAC_Verify() can be called directly to check the HMAC of a list of streams.\n   \n   The ... arguments are a list of the form\n   int length, unsigned char *buffer\n   terminated by a 0 length\n\n*/\n\nTPM_RC TSS_HMAC_Verify(TPMT_HA *expect,\n\t\t       const TPM2B_KEY *hmacKey,\n\t\t       uint32_t sizeInBytes,\n\t\t       ...)\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tirc;\n    va_list\t\tap;\n    TPMT_HA \t\tactual;\n\n    actual.hashAlg = expect->hashAlg;\t/* algorithm for the HMAC calculation */\n    va_start(ap, sizeInBytes);\n    if (rc == 0) {\n\trc = TSS_HMAC_Generate_valist(&actual, hmacKey, ap);\n    }\n    if (rc == 0) {\n\tirc = memcmp((uint8_t *)&expect->digest, &actual.digest, sizeInBytes);\n\tif (irc != 0) {\n\t    TSS_PrintAll(\"TSS_HMAC_Verify: calculated HMAC\",\n\t\t\t (uint8_t *)&actual.digest, sizeInBytes);\n\t    rc = TSS_RC_HMAC_VERIFY;\n\t}\n    }\n    va_end(ap);\n    return rc;\n}\n\n/* TSS_KDFA() 11.4.9\tKey Derivation Function\n\n   As defined in SP800-108, the inner loop for building the key stream is:\n\n   K(i) = HMAC (KI , [i]2 || Label || 00 || Context || [L]2) \n*/\n\nTPM_RC TSS_KDFA(uint8_t\t\t*keyStream,    \t/* OUT: key buffer */\n\t\tTPM_ALG_ID\thashAlg,       \t/* IN: hash algorithm used in HMAC */\n\t\tconst TPM2B\t*key,           /* IN: HMAC key */\n\t\tconst char\t*label,\t\t/* IN: KDFa label, NUL terminated */\n\t\tconst TPM2B\t*contextU,      /* IN: context U */\n\t\tconst TPM2B\t*contextV,      /* IN: context V */\n\t\tuint32_t\tsizeInBits)    \t/* IN: size of generated key in bits */\n\n{\n    TPM_RC\trc = 0;\n    uint32_t \tbytes = ((sizeInBits + 7) / 8);\t/* bytes left to produce */\n    uint8_t\t*stream;\n    uint32_t \tsizeInBitsNbo = htonl(sizeInBits);\t/* KDFa L2 */\n    uint16_t    bytesThisPass;\t\t\t/* in one HMAC operation */\n    uint32_t\tcounter;    \t\t\t/* counter value */\n    uint32_t \tcounterNbo;\t\t\t/* counter in big endian */\n    TPMT_HA \thmac;\t\t\t\t/* hmac result for this pass */\n    \n\n    if (rc == 0) {\n\thmac.hashAlg = hashAlg;\t\t\t/* for TSS_HMAC_Generate() */\n\tbytesThisPass = TSS_GetDigestSize(hashAlg);\t/* start with hashAlg sized chunks */\n\tif (bytesThisPass == 0) {\n\t    if (tssVerbose) printf(\"TSS_KDFA: KDFa failed\\n\");\n\t    rc = TSS_RC_KDFA_FAILED;\n\t}\n    }\n    /* Generate required bytes */\n    for (stream = keyStream, counter = 1 ;\t/* beginning of stream, KDFa counter starts at 1 */\n\t (rc == 0) && bytes > 0 ;\t\t\t\t/* bytes left to produce */\n\t stream += bytesThisPass, bytes -= bytesThisPass, counter++) {\n\n\t/* last pass, can be less than hashAlg sized chunks */\n\tif (bytes < bytesThisPass) {\n\t    bytesThisPass = bytes;\n\t}\n\tcounterNbo = htonl(counter);\t/* counter for this pass in BE format */\n\t    \n\trc = TSS_HMAC_Generate(&hmac,\t\t\t\t/* largest size of an HMAC */\n\t\t\t       (const TPM2B_KEY *)key,\n\t\t\t       sizeof(uint32_t), &counterNbo,\t/* KDFa i2 counter */\n\t\t\t       strlen(label) + 1, label,\t/* KDFa label, use NUL as the KDFa\n\t\t\t\t\t\t\t\t   00 byte */\n\t\t\t       contextU->size, contextU->buffer,\t/* KDFa Context */\n\t\t\t       contextV->size, contextV->buffer,\t/* KDFa Context */\n\t\t\t       sizeof(uint32_t), &sizeInBitsNbo,\t/* KDFa L2 */\n\t\t\t       0, NULL);\n\tmemcpy(stream, &hmac.digest.tssmax, bytesThisPass);\n    }\n    return rc;\n}\n\n/* TSS_KDFE() 11.4.9.3\tKey Derivation Function for ECDH\n\n   Digest = Hash(counter || Z || Use || PartyUInfo || PartyVInfo || bits )\n\n   where\n\n   counter is initialized to 1 and incremented for each iteration\n   \n   Z is the X-coordinate of the product of a public (TPM) ECC key and \n   a different private ECC key\n   \n   Use is a NULL-terminated string that indicates the use of the key \n   (\"DUPLICATE\", \"IDENTITY\", \"SECRET\", etc)\n   \n   PartyUInfo is the X-coordinate of the public point of an ephemeral key\n   \n   PartyVInfo is the X-coordinate of the public point of the TPM key\n   \n   bits is a 32-bit value indicating the number of bits to be returned\n*/\n\nTPM_RC TSS_KDFE(uint8_t\t\t*keyStream,    \t/* OUT: key buffer */\n\t\tTPM_ALG_ID\thashAlg,       \t/* IN: hash algorithm used */\n\t\tconst TPM2B\t*key,           /* IN: Z  */\n\t\tconst char\t*label,\t\t/* IN: KDFe label, NUL terminated */\n\t\tconst TPM2B\t*contextU,      /* IN: context U */\n\t\tconst TPM2B\t*contextV,      /* IN: context V */\n\t\tuint32_t\tsizeInBits)    \t/* IN: size of generated key in bits */\n\n{\n    TPM_RC\trc = 0;\n    uint32_t \tbytes = ((sizeInBits + 7) / 8);\t/* bytes left to produce */\n    uint8_t\t*stream;\n    uint16_t    bytesThisPass;\t\t\t/* in one Hash operation */\n    uint32_t\tcounter;    \t\t\t/* counter value */\n    uint32_t \tcounterNbo;\t\t\t/* counter in big endian */\n    TPMT_HA \tdigest;\t\t\t\t/* result for this pass */\n    \n    if (rc == 0) {\n\tdigest.hashAlg = hashAlg;\t\t\t/* for TSS_Hash_Generate() */\n\tbytesThisPass = TSS_GetDigestSize(hashAlg);\t/* start with hashAlg sized chunks */\n\tif (bytesThisPass == 0) {\n\t    if (tssVerbose) printf(\"TSS_KDFE: KDFe failed\\n\");\n\t    rc = TSS_RC_KDFE_FAILED;\n\t}\n    }\n    /* Generate required bytes */\n    for (stream = keyStream, counter = 1 ;\t/* beginning of stream, KDFe counter starts at 1 */\n\t (rc == 0) && bytes > 0 ;\t\t\t\t/* bytes left to produce */\n\t stream += bytesThisPass, bytes -= bytesThisPass, counter++) {\n\t/* last pass, can be less than hashAlg sized chunks */\n\tif (bytes < bytesThisPass) {\n\t    bytesThisPass = bytes;\n\t}\n\tcounterNbo = htonl(counter);\t/* counter for this pass in BE format */\n\t    \n\trc = TSS_Hash_Generate(&digest,\t\t\t\t/* largest size of a digest */\n\t\t\t       sizeof(uint32_t), &counterNbo,\t/* KDFe i2 counter */\n\t\t\t       key->size, key->buffer,\n\t\t\t       strlen(label) + 1, label,\t/* KDFe label, use NUL as the KDFe\n\t\t\t\t\t\t\t\t   00 byte */\n\t\t\t       contextU->size, contextU->buffer,\t/* KDFe Context */\n\t\t\t       contextV->size, contextV->buffer,\t/* KDFe Context */\n\t\t\t       0, NULL);\n\tmemcpy(stream, &digest.digest.tssmax, bytesThisPass);\n    }\n    return rc;\n}\n\n/* On call, digest->hashAlg is the desired hash algorithm\n\n   ... is a list of int length, unsigned char *buffer pairs.\n\n   length 0 is ignored, buffer NULL terminates list.\n*/\n\nTPM_RC TSS_Hash_Generate(TPMT_HA *digest,\t\t/* largest size of a digest */\n\t\t\t ...)\n{\n    TPM_RC\trc = 0;\n    va_list\tap;\n    va_start(ap, digest);\n    rc = TSS_Hash_Generate_valist(digest, ap);\n    va_end(ap);\n    return rc;\n}\n\n\n/* TSS_GetDigestBlockSize() returns the digest block size in bytes based on the hash algorithm.\n\n   Returns 0 for an unknown algorithm.\n*/\n\n/* NOTE: Marked as const function in header */\n\nuint16_t TSS_GetDigestBlockSize(TPM_ALG_ID hashAlg)\n{\n    uint16_t size;\n    \n    switch (hashAlg) {\n#ifdef TPM_ALG_SHA1\n     case TPM_ALG_SHA1:\n\tsize = SHA1_BLOCK_SIZE;\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA256\t\n      case TPM_ALG_SHA256:\n\tsize = SHA256_BLOCK_SIZE;\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA384\n     case TPM_ALG_SHA384:\n\tsize = SHA384_BLOCK_SIZE;\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA512\n      case TPM_ALG_SHA512:\n\tsize = SHA512_BLOCK_SIZE;\n\tbreak;\n#endif\n#if 0\n      case TPM_ALG_SM3_256:\n\tsize = SM3_256_BLOCK_SIZE;\n\tbreak;\n#endif\n      default:\n\tsize = 0;\n    }\n    return size;\n}\n\n/* TPM_MGF1() generates an MGF1 'array' of length 'arrayLen' from 'seed' of length 'seedlen'\n\n   The openSSL DLL doesn't export MGF1 in Windows or Linux 1.0.0, so this version is created from\n   scratch.\n   \n   Algorithm and comments (not the code) from:\n\n   PKCS #1: RSA Cryptography Specifications Version 2.1 B.2.1 MGF1\n\n   Prototype designed to be compatible with openSSL\n\n   MGF1 is a Mask Generation Function based on a hash function.\n   \n   MGF1 (mgfSeed, maskLen)\n\n   Options:     \n\n   Hash hash function (hLen denotes the length in octets of the hash \n   function output)\n\n   Input:\n   \n   mgfSeed         seed from which mask is generated, an octet string\n   maskLen         intended length in octets of the mask, at most 2^32(hLen)\n\n   Output:      \n   mask            mask, an octet string of length l; or \"mask too long\"\n\n   Error:          \"mask too long'\n*/\n\nstatic TPM_RC TSS_MGF1(unsigned char       \t*mask,\n\t\t       uint32_t            \tmaskLen,\n\t\t       const unsigned char \t*mgfSeed,\n\t\t       uint16_t\t\t\tmgfSeedlen,\n\t\t       TPMI_ALG_HASH \t\thalg)\n{\n    TPM_RC \t\trc = 0;\n    unsigned char       counter[4];     /* 4 octets */\n    uint32_t\t        count;          /* counter as an integral type */\n    uint32_t\t\toutLen;\n    TPMT_HA \t\tdigest;\n    uint16_t \t\tdigestSize = TSS_GetDigestSize(halg);\n    \n    digest.hashAlg = halg;\n    \n#if 0\n    if (rc == 0) {\n        /* this is possible with arrayLen on a 64 bit architecture, comment to quiet beam */\n        if ((maskLen / TPM_DIGEST_SIZE) > 0xffffffff) {        /* constant condition */\n            if (tssVerbose)\n\t\tprintf(\"TSS_MGF1: Error (fatal), Output length too large for 32 bit counter\\n\");\n            rc = TPM_FAIL;              /* should never occur */\n        }\n    }\n#endif\n    /* 1.If l > 2^32(hLen), output \"mask too long\" and stop. */\n    /* NOTE Checked by caller */\n    /* 2. Let T be the empty octet string. */\n    /* 3. For counter from 0 to [masklen/hLen] - 1, do the following: */\n    for (count = 0, outLen = 0 ; (rc == 0) && (outLen < maskLen) ; count++) {\n\t/* a. Convert counter to an octet string C of length 4 octets - see Section 4.1 */\n\t/* C = I2OSP(counter, 4) NOTE Basically big endian */\n        uint32_t count_n = htonl(count);\n\tmemcpy(counter, &count_n, 4);\n\t/* b.Concatenate the hash of the seed mgfSeed and C to the octet string T: */\n\t/* T = T || Hash (mgfSeed || C) */\n\t/* If the entire digest is needed for the mask */\n\tif ((outLen + digestSize) < maskLen) {\n\t    rc = TSS_Hash_Generate(&digest,\n\t\t\t\t   mgfSeedlen, mgfSeed,\n\t\t\t\t   4, counter,\n\t\t\t\t   0, NULL);\n\t    memcpy(mask + outLen, &digest.digest, digestSize);\n\t    outLen += digestSize;\n\t}\n\t/* if the mask is not modulo TPM_DIGEST_SIZE, only part of the final digest is needed */\n\telse {\n\t    /* hash to a temporary digest variable */\n\t    rc = TSS_Hash_Generate(&digest,\n\t\t\t\t   mgfSeedlen, mgfSeed,\n\t\t\t\t   4, counter,\n\t\t\t\t   0, NULL);\n\t    /* copy what's needed */\n\t    memcpy(mask + outLen, &digest.digest, maskLen - outLen);\n\t    outLen = maskLen;           /* outLen = outLen + maskLen - outLen */\n\t}\n    }\n    /* 4.Output the leading l octets of T as the octet string mask. */\n    return rc;\n}\n\n/*\n  OAEP Padding \n*/\n\n/* TSS_RSA_padding_add_PKCS1_OAEP() is a variation of the the openSSL function\n\n   int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,\n   unsigned char *f, int fl, unsigned char *p, int pl);\n\n   It is used because the openssl function is hard coded to SHA1.\n\n   This function was independently written from the PKCS1 specification \"9.1.1.1 Encoding\n   Operation\" and PKCS#1 v2.2, intended to be unencumbered by any license.\n\n\n   | <-\t\t\t  emLen\t\t\t\t\t   -> |\n   \n                         |  lHash |    PS     | 01 |  Message\t      |\n\n                            SHA                       flen\n\n                         |  db                                        |\n\t\t\t |  dbMask                                    |\n        |  seed          |\n\n\t   SHA\n\t   \n        |  seedMask      | \n   | 00 |  maskSeed      |   maskedDB                                 |\n*/\n\nTPM_RC TSS_RSA_padding_add_PKCS1_OAEP(unsigned char *em, uint32_t emLen,\n\t\t\t\t      const unsigned char *from, uint32_t fLen,\n\t\t\t\t      const unsigned char *p,\n\t\t\t\t      int plen,\n\t\t\t\t      TPMI_ALG_HASH halg)\t\n{\t\n    TPM_RC\t\trc = 0;\n    TPMT_HA \t\tlHash;\n    unsigned char \t*db = NULL;\t\t/* compiler false positive */\n    \n    unsigned char *dbMask = NULL;\t\t\t/* freed @1 */\n    unsigned char *seed = NULL;\t\t\t\t/* freed @2 */\n    unsigned char *maskedDb;\n    unsigned char *seedMask = NULL;\t\t/* compiler false positive */\n    unsigned char *maskedSeed;\n\n    uint16_t hlen = TSS_GetDigestSize(halg);\n    em[0] = 0x00;\t/* first byte is 0x00 per the standard */\n#ifdef TPM_TSS_NODEPRECATEDALGS\n    if (rc == 0) {\n\tif (halg == TPM_ALG_SHA1) {\n\t    rc = TSS_RC_BAD_HASH_ALGORITHM;\n\t}\n    }\n#endif\n    /* 1.a. If the length of L is greater than the input limitation for */\n    /* the hash function (2^61-1 octets for SHA-1) then output \"parameter */\n    /* string too long\" and stop. */\n    if (rc == 0) {\n\tif (plen > 0xffff) {\n\t    if (tssVerbose) printf(\"TSS_RSA_padding_add_PKCS1_OAEP: Error, \"\n\t\t\t\t   \"label %u too long\\n\", plen);\n\t    rc = TSS_RC_RSA_PADDING;\n\t}\t    \n    }\n    /* 1.b. If ||M|| > emLen-2hLen-1 then output \"message too long\" and stop. */\n    if (rc == 0) {\n\tif (emLen < ((2 * hlen) + 2 + fLen)) {\n\t    if (tssVerbose) printf(\"TSS_RSA_padding_add_PKCS1_OAEP: Error, \"\n\t\t\t\t   \"message length %u too large for encoded length %u\\n\",\n\t\t\t\t   fLen, emLen);\n\t    rc = TSS_RC_RSA_PADDING;\n\t}\n    }\n    /* 2.a. Let lHash = Hash(L), an octet string of length hLen. */\n    if (rc == 0) {\n\tlHash.hashAlg = halg;\n\trc = TSS_Hash_Generate(&lHash,\n\t\t\t       plen, p,\n\t\t\t       0, NULL);\n    }\n    if (rc == 0) {\n\t/* 2.b. Generate an octet string PS consisting of emLen-||M||-2hLen-2 zero octets. The\n\t   length of PS may be 0. */\n\t/* 2.c. Concatenate lHash, PS, a single octet of 0x01 the message M, to form a data block DB\n\t   as: DB = lHash || PS || 01 || M */\n\t/* NOTE Since db is eventually maskedDb, part of em, create directly in em */\n\tdb = em + hlen + 1;\n\tmemcpy(db, &lHash.digest, hlen);\t\t\t/* lHash */\n\t/* PSlen = emlen - flen - (2 * hlen) - 2 */\n\tmemset(db + hlen, 0,\t\t\t\t\t/* PS */\n\t       emLen - fLen - (2 * hlen) - 2);\n\t/* position of 0x01 in db is\n\t   hlen + PSlen =\n\t   hlen + emlen - flen - (2 * hlen) - 2 = \n\t   emlen - hlen - flen - 2 */\n\tdb[emLen - fLen - hlen - 2] = 0x01;\n\tmemcpy(db + emLen - fLen - hlen - 1, from, fLen);\t/* M */\n    }\n    /* 2.d. Generate a random octet string seed of length hLen. */\n    if (rc == 0) {\n\trc = TSS_Malloc(&seed, hlen);\n    }\n    if (rc == 0) {\n\trc = TSS_RandBytes(seed, hlen);\n    }\n    if (rc == 0) {\n\trc = TSS_Malloc(&dbMask, emLen - hlen - 1);\n    }\n    if (rc == 0) {\n\t/* 2.e. Let dbMask = MGF(seed, emLen-hLen-1). */\n\trc = TSS_MGF1(dbMask, emLen - hlen -1,\t/* dbLen */\n\t\t      seed, hlen,\n\t\t      halg);\n    }\n    if (rc == 0) {\n\t/* 2.f. Let maskedDB = DB xor dbMask. */\n\t/* NOTE Since maskedDB is eventually em, XOR directly to em */\n\tmaskedDb = em + hlen + 1;\n\tTSS_XOR(maskedDb, db, dbMask, emLen - hlen -1);\n\t/* 2.g. Let seedMask = MGF(maskedDB, hLen). */\n\t/* NOTE Since seedMask is eventually em, create directly to em */\n\tseedMask = em + 1;\n\trc = TSS_MGF1(seedMask, hlen,\n\t\t      maskedDb, emLen - hlen - 1,\n\t\t      halg);\n    }\n    if (rc == 0) {\n\t/* 2.h. Let maskedSeed = seed xor seedMask. */\n\t/* NOTE Since maskedSeed is eventually em, create directly to em */\n\tmaskedSeed = em + 1;\n\tTSS_XOR(maskedSeed, seed, seedMask, hlen);\n\t/* 2.i. 0x00, maskedSeed, and maskedDb to form EM */\n\t/* NOTE Created directly in em */\n    }\n    free(dbMask);\t\t/* @1 */\n    free(seed);\t\t\t/* @2 */\n    return rc;\n}\n\n/* TPM_XOR XOR's 'in1' and 'in2' of 'length', putting the result in 'out'\n\n */\n\nvoid TSS_XOR(unsigned char *out,\n\t     const unsigned char *in1,\n\t     const unsigned char *in2,\n\t     size_t length)\n{\n    size_t i;\n    \n    for (i = 0 ; i < length ; i++) {\n\tout[i] = in1[i] ^ in2[i];\n    }\n    return;\n}\n\n/*\n  AES\n*/\n\n#define TSS_AES_KEY_BITS 128\n\n/* TSS_Sym_GetBlockSize() returns the block size for the symmetric algorithm.  Returns 0 on for an\n   unknown algorithm.\n*/\n\n/* NOTE: Marked as const function in header */\n\nuint16_t TSS_Sym_GetBlockSize(TPM_ALG_ID\tsymmetricAlg, \n\t\t\t      uint16_t\t\tkeySizeInBits)\n{\n    keySizeInBits = keySizeInBits;\n    \n    switch (symmetricAlg) {\n#ifdef TPM_ALG_AES\n      case TPM_ALG_AES:\n#endif\n#ifdef TPM_ALG_SM4 /* Both AES and SM4 use the same block size */\n      case TPM_ALG_SM4:\n#endif\n\treturn  16;\n      default:\n\treturn 0;\n    }\n    return 0;\n}\n\n"
  },
  {
    "path": "ibmtss-ftpm/tssdev.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tLinux Device Transmit and Receive Utilities\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2022.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#ifdef TPM_POSIX\n#ifndef TPM_TSS_NODEV\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>\n#include <errno.h>\n\n#include <unistd.h>\n#include <fcntl.h>\n\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include \"tssproperties.h\"\n\n#include \"tssdev.h\"\n\n/* local prototypes */\n\nstatic uint32_t TSS_Dev_Open(TSS_CONTEXT *tssContext);\nstatic uint32_t TSS_Dev_SendCommand(int dev_fd, const uint8_t *buffer, uint16_t length,\n\t\t\t\t    const char *message);\nstatic uint32_t TSS_Dev_ReceiveResponse(int dev_fd, uint8_t *buffer, uint32_t *length);\n\n/* global configuration */\n\nextern int tssVverbose;\nextern int tssVerbose;\n\n/* TSS_Dev_Transmit() transmits the command and receives the response.\n\n   Can return device transmit and receive packet errors, but normally returns the TPM response code.\n*/\n\nTPM_RC TSS_Dev_Transmit(TSS_CONTEXT *tssContext,\n\t\t\tuint8_t *responseBuffer, uint32_t *read,\n\t\t\tconst uint8_t *commandBuffer, uint32_t written,\n\t\t\tconst char *message)\n{\n    TPM_RC rc = 0;\n    \n    /* open on first transmit */\n    if (tssContext->tssFirstTransmit) {\t\n\tif (rc == 0) {\n\t    rc = TSS_Dev_Open(tssContext);\n\t}\n\tif (rc == 0) {\n\t    tssContext->tssFirstTransmit = FALSE;\n\t}\n    }\n    /* send the command to the device.  Error if the device send fails. */\n    if (rc == 0) {\n\trc = TSS_Dev_SendCommand(tssContext->dev_fd, commandBuffer, written, message);\n    }\n    /* receive the response from the dev_fd.  Returns dev_fd errors, malformed response errors.\n       Else returns the TPM response code. */\n    if (rc == 0) {\n\trc = TSS_Dev_ReceiveResponse(tssContext->dev_fd, responseBuffer, read);\n    }\n    return rc;\n}\n\n/* TSS_Dev_Open() opens the TPM device (through the device driver) */\n\nstatic uint32_t TSS_Dev_Open(TSS_CONTEXT *tssContext)\n{\n    uint32_t rc = 0;\n    \n    if (rc == 0) {\n\tif (tssVverbose) printf(\"TSS_Dev_Open: Opening %s\\n\", tssContext->tssDevice);\n\ttssContext->dev_fd = open(tssContext->tssDevice, O_RDWR);\n\tif (tssContext->dev_fd < 0) {\n\t    if (tssVerbose) printf(\"TSS_Dev_Open: Error opening %s\\n\", tssContext->tssDevice);\n\t    rc = TSS_RC_NO_CONNECTION;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Dev_SendCommand() sends the TPM command buffer to the device.\n\n   Returns an error if the device write fails.\n*/\n\nstatic uint32_t TSS_Dev_SendCommand(int dev_fd,\n\t\t\t\t    const uint8_t *buffer, uint16_t length,\n\t\t\t\t    const char *message)\n{\n    uint32_t rc = 0;\n    int irc;\n    \n    if (message != NULL) {\n\tif (tssVverbose) printf(\"TSS_Dev_SendCommand: %s\\n\", message);\n    }\n    if ((rc == 0) && tssVverbose) {\n\tTSS_PrintAll(\"TSS_Dev_SendCommand\",\n\t\t     buffer, length);\n    }\n    if (rc == 0) {\n\tirc = write(dev_fd, buffer, length);\n\tif (irc < 0) {\n\t    if (tssVerbose) printf(\"TSS_Dev_SendCommand: write error %d %s\\n\",\n\t\t\t\t   errno, strerror(errno));\n\t    rc = TSS_RC_BAD_CONNECTION;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Dev_ReceiveResponse() reads a response buffer from the device.  'buffer' must be at least\n   MAX_RESPONSE_SIZE bytes.\n\n   Returns TPM packet error code.\n\n   Validates that the packet length and the packet responseSize match \n*/\n\nstatic uint32_t TSS_Dev_ReceiveResponse(int dev_fd, uint8_t *buffer, uint32_t *length)\n{\n    uint32_t \trc = 0;\n    int \tirc;\t\t/* read() return code, negative is error, positive is length */\n    uint32_t \tresponseSize = 0;\t/* from TPM packet response stream */\n    uint32_t\tresponseCode = 0;\n    uint8_t \t*tmpptr;\t/* for unmarshaling responseSize and responseCode */\n    uint32_t\ttmpsize;\n    \n    if (tssVverbose) printf(\"TSS_Dev_ReceiveResponse:\\n\");\n    /* read the TPM device */\n    if (rc == 0) {\n\tirc = read(dev_fd, buffer, MAX_RESPONSE_SIZE);\n\tif (irc <= 0) {\n\t    rc = TSS_RC_BAD_CONNECTION;\n\t    if (irc < 0) {\n\t\tif (tssVerbose) printf(\"TSS_Dev_ReceiveResponse: read error %d %s\\n\",\n\t\t\t\t       errno, strerror(errno));\n\t    }\n\t}\n    }\n    /* read() is successful, trace the response */\n    if ((rc == 0) && tssVverbose) {\n\tTSS_PrintAll(\"TSS_Dev_ReceiveResponse\",\n\t\t     buffer, irc);\n    }\n    /* verify that there is at least a tag, responseSize, and responseCode in TPM response */\n    if (rc == 0) {\n\tif ((unsigned int)irc < (sizeof(TPM_ST) + sizeof(uint32_t) + sizeof(uint32_t))) {\n\t    if (tssVerbose) printf(\"TSS_Dev_ReceiveResponse: read bytes %u < header\\n\", irc);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n\t/* skip the tag */\n\telse {\n\t    tmpptr = buffer + sizeof(TPM_ST);\n\t    tmpsize = (unsigned int)irc - sizeof(TPM_ST);\n\t}\n    }\n    /* get responseSize from the packet, should never fail because of above check */\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&responseSize, &tmpptr, &tmpsize);\n    }\n    /* sanity check against the length actually received, the return code */\n    if (rc == 0) {\n\tif ((uint32_t)irc != responseSize) {\n\t    if (tssVerbose) printf(\"TSS_Dev_ReceiveResponse: read bytes %u != responseSize %u\\n\",\n\t\t\t\t   (uint32_t)irc, responseSize);\n\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t}\n    }\n    /* get responseCode from the packet, should never fail because of above check */\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&responseCode, &tmpptr, &tmpsize);\n    }\n   /* if there was no lower level failure, return the TPM packet responseCode */\n    if (rc == 0) {\n\trc = responseCode;\n    }\n    *length = responseSize;\n    if (tssVverbose) printf(\"TSS_Dev_ReceiveResponse: rc %08x\\n\", rc);\n    return rc;\n}\t\n\nTPM_RC TSS_Dev_Close(TSS_CONTEXT *tssContext)\n{\n    if (tssVverbose) printf(\"TSS_Dev_Close: Closing %s\\n\", tssContext->tssDevice);\n    close(tssContext->dev_fd);\n    return 0;\n}\n\n#endif\t/* TPM_TSS_NODEV */\n#endif\t/* TPM_POSIX */\n"
  },
  {
    "path": "ibmtss-ftpm/tssdevskiboot.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\tSkiboot Transmit and Receive Utilities\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2020.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <string.h>\n\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/Implementation.h>\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include <tssproperties.h>\n\n#include <tssdev.h>\n#include <tpm_chip.h>\n\n/* global configuration */\n\nextern int tssVerbose;\nextern int tssVverbose;\n\n/*\n * TSS_Dev_Transmit() transmits the command and receives the response in\n * skiboot.\n * Can return device transmit and receive packet errors, but normally returns\n * the TPM response code.\n*/\nTPM_RC TSS_Dev_Transmit(TSS_CONTEXT *tssContext,\n\t\t\t    uint8_t *responseBuffer, uint32_t *length,\n\t\t\t    const uint8_t *commandBuffer, uint32_t written,\n\t\t\t    const char *message)\n{\n\tTPM_RC rc = 0;\n\tsize_t responseSize;\n\n\t/* skiboot driver's transmit function expects a size_t value as buffer\n\t * length instead of uint32_t used in this function header, so this\n\t * variable exists just for type compatibility.\n\t */\n\tsize_t buffer_length;\n\n\tif (message != NULL) {\n\t\tif (tssVverbose) printf(\"TSS_Skiboot_Transmit: %s\\n\", message);\n\t}\n\tif ((rc == 0) && tssVverbose) {\n\t\t\tTSS_PrintAll(\"TSS_Skiboot_Transmit: Command \",\n\t\t\t\t     commandBuffer, written);\n\t}\n\n\t/* we don't need to open a device as it is done in user space but we\n\t * need to be sure a device and the driver are available for use.\n\t */\n\tif (rc == 0) {\n\t\tif (tssContext->tssFirstTransmit) {\n\t\t\ttssContext->tpm_device = tpm_get_device();\n\t\t\tif (tssContext->tpm_device == NULL) {\n\t\t\t\tif (tssVerbose)\n\t\t\t\t\tprintf(\"TSS_Skiboot_Transmit: TPM device not set\\n\");\n\t\t\t\trc = TSS_RC_NO_CONNECTION;\n\t\t\t}\n\t\t\tif (rc == 0) {\n\t\t        \ttssContext->tpm_driver = tpm_get_driver();\n\t\t\t\tif (tssContext->tpm_driver == NULL) {\n\t\t\t\t\tif (tssVerbose)\n\t\t\t\t\t\tprintf(\"TSS_Skiboot_Transmit: TPM driver not set\\n\");\n\t\t\t\t\trc = TSS_RC_NO_CONNECTION;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (rc == 0 ) {\n\t\ttssContext->tssFirstTransmit = FALSE;\n\t}\n\n\t/*\n\t * Let's issue compilation issue if eventually MAX_COMMAND_SIZE becomes\n\t * potentially greater than MAX_RESPONSE_SIZE\n\t */\n#if MAX_COMMAND_SIZE > MAX_RESPONSE_SIZE\n#error \"MAX_COMMAND_SIZE cannot be greater than MAX_RESPONSE_SIZE. Potential overflow on the buffer for Command and Response\"\n#endif\n\tif (rc == 0) {\n\t\tif (written > MAX_RESPONSE_SIZE) {\n\t\t\tif (tssVerbose)\n\t\t\t\tprintf(\"TSS_Skiboot_Transmit: Response Overflow. TPM wrote %u bytes, Max response size is %u \",\n\t\t\t\t       written, MAX_RESPONSE_SIZE);\n\t\t\trc = TSS_RC_BAD_CONNECTION;\n\t\t}\n\t}\n\n\t/*\n\t * the buffer used to send the command will be overwritten and store the\n\t * response data after TPM execution. So here we copy the contents of\n\t * commandBuffer to responseBuffer, using the latter to perform the\n\t * operation and storing the response and keeping the former safe.\n\t */\n\tif (rc == 0) {\n\t\t/*\n\t\t * skiboot driver checks for overflow, so we need to share the\n\t\t * max response size to length. In the response length will\n\t\t * contain the length of the response buffer.\n\t \t */\n\t\tbuffer_length = MAX_RESPONSE_SIZE;\n\n\t\tmemcpy(responseBuffer, commandBuffer, written);\n\t\trc = tssContext->tpm_driver->transmit(tssContext->tpm_device,\n\t\t\t\t\t      responseBuffer, written, &buffer_length);\n\t\t/* now that we have buffer length set we save it to length so it\n\t\t * can be used by the callers\n\t\t */\n\t\t*length = buffer_length;\n\n\t\tif (rc != 0) {\n\t\t\tif (tssVerbose)\n\t\t\t\tprintf(\"TSS_Skiboot_Transmit: receive error %u\\n\", rc);\n\t\t\trc = TSS_RC_BAD_CONNECTION;\n\t\t}\n\t}\n\n\tif (rc == 0) {\n\t\tif (tssVverbose)\n\t\t\tTSS_PrintAll(\"TSS_Skiboot_Transmit: Response\", responseBuffer, *length);\n\n    \t\t/* verify that there is at least a tag, responseSize, and responseCode */\n\t\tif (*length < (sizeof(TPM_ST) + (2 * sizeof(uint32_t)))) {\n\t\t\tif (tssVerbose)\n\t\t\t\tprintf(\"TSS_Skiboot_Transmit: received %u bytes < header\\n\", *length);\n\t\t\trc = TSS_RC_MALFORMED_RESPONSE;\n\t\t}\n\t}\n\n\t/*\n\t * length and the response size in the response body should match. Check\n\t * it here.\n\t */\n\tif (rc == 0) {\n\t\tresponseSize = ntohl(*(uint32_t *)(responseBuffer + sizeof(TPM_ST)));\n\t\tif (responseSize != *length) {\n\t\t\tif (tssVerbose)\n\t\t\t\tprintf(\"TSS_Skiboot_Transmit: Bytes read (%u) and Buffer responseSize field (%lu) don't match\\n\",\n\t\t\t\t       *length, responseSize);\n\t\t    rc = TSS_RC_MALFORMED_RESPONSE;\n\t\t}\n\t}\n\n\t/*\n\t * Now we need to get the actual return code from the response buffer\n\t * and deliver it to the upper layers\n\t */\n\tif (rc == 0)\n\t\trc = ntohl(*(uint32_t *)(responseBuffer + sizeof(TPM_ST) + sizeof(uint32_t)));\n\n\tif (tssVverbose)\n\t\tprintf(\"TSS_Skiboot_Transmit: Response Code: %08x\", rc);\n\n\treturn rc;\n}\n\nTPM_RC TSS_Dev_Close(TSS_CONTEXT *tssContext)\n{\n\ttssContext = tssContext;\n\treturn 0;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssfile.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    TSS and Application File Utilities\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <errno.h>\n\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/tssfile.h>\n\nextern int tssVerbose;\nextern int tssVverbose;\n\n/* TSS_File_Open() opens the 'filename' for 'mode'\n */\n\nint TSS_File_Open(FILE **file,\n\t\t  const char *filename,\n\t\t  const char* mode)\n{\n    int \trc = 0;\n\t\t    \n    if (rc == 0) {\n\t*file = fopen(filename, mode);\n\tif (*file == NULL) {\n\t    if (tssVerbose) printf(\"TSS_File_Open: Error opening %s for %s, %s\\n\",\n\t\t\t\t   filename, mode, strerror(errno));\n\t    rc = TSS_RC_FILE_OPEN;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_File_ReadBinaryFile() reads 'filename'.  The results are put into 'data', which must be freed\n   by the caller.  'length' indicates the number of bytes read.\n   \n*/\n\nTPM_RC TSS_File_ReadBinaryFile(unsigned char **data,     /* must be freed by caller */\n\t\t\t       size_t *length,\n\t\t\t       const char *filename) \n{\n    int\t\trc = 0;\n    long\tlrc;\n    size_t\tsrc;\n    int\t\tirc;\n    FILE\t*file = NULL;\n\n    *data = NULL;\n    *length = 0;\n    /* open the file */\n    if (rc == 0) {\n\trc = TSS_File_Open(&file, filename, \"rb\");\t\t\t\t/* closed @1 */\n    }\n    /* determine the file length */\n    if (rc == 0) {\n\tirc = fseek(file, 0L, SEEK_END);\t/* seek to end of file */\n\tif (irc == -1L) {\n\t    if (tssVerbose) printf(\"TSS_File_ReadBinaryFile: Error seeking to end of %s\\n\",\n\t\t\t\t   filename);\n\t    rc = TSS_RC_FILE_SEEK;\n\t}\n    }\n    if (rc == 0) {\n\tlrc = ftell(file);\t\t\t/* get position in the stream */\n\tif (lrc == -1L) {\n\t    if (tssVerbose) printf(\"TSS_File_ReadBinaryFile: Error ftell'ing %s\\n\", filename);\n\t    rc = TSS_RC_FILE_FTELL;\n\t}\n\telse {\n\t    *length = (size_t)lrc;\t\t/* save the length */\n\t}\n    }\n    if (rc == 0) {\n\tirc = fseek(file, 0L, SEEK_SET);\t/* seek back to the beginning of the file */\n\tif (irc == -1L) {\n\t    if (tssVerbose) printf(\"TSS_File_ReadBinaryFile: Error seeking to beginning of %s\\n\",\n\t\t\t\t   filename);\n\t    rc = TSS_RC_FILE_SEEK;\n\t}\n    }\n    /* allocate a buffer for the actual data */\n    if ((rc == 0) && (*length != 0)) {\n\trc = TSS_Malloc(data, (uint32_t)*length);\n    }\n    /* read the contents of the file into the data buffer */\n    if ((rc == 0) && *length != 0) {\n\tsrc = fread(*data, 1, *length, file);\n\tif (src != *length) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_File_ReadBinaryFile: Error reading %s, %u bytes, got %lu\\n\",\n\t\t       filename, (unsigned int)*length, (unsigned long)src);\n\t    rc = TSS_RC_FILE_READ;\n\t}\n    }\n    if (file != NULL) {\n\tirc = fclose(file);\t\t/* @1 */\n\tif (irc != 0) {\n\t    if (tssVerbose) printf(\"TSS_File_ReadBinaryFile: Error closing %s\\n\",\n\t\t\t\t   filename);\n\t    rc = TSS_RC_FILE_CLOSE;\n\t}\n    }\n    if (rc != 0) {\n\tif (tssVerbose) printf(\"TSS_File_ReadBinaryFile: Error reading %s\\n\", filename);\n\tfree(*data);\n\t*data = NULL;\n    }\n    return rc;\n}\n\n/* TSS_File_WriteBinaryFile() writes 'data' of 'length' to 'filename'\n */\n\nTPM_RC TSS_File_WriteBinaryFile(const unsigned char *data,\n\t\t\t\tsize_t length,\n\t\t\t\tconst char *filename) \n{\n    long\trc = 0;\n    size_t\tsrc;\n    int\t\tirc;\n    FILE\t*file = NULL;\n\n    /* open the file */\n    if (rc == 0) {\n\trc = TSS_File_Open(&file, filename, \"wb\");\t/* closed @1 */\n    }\n    /* write the contents of the data buffer into the file */\n    if (rc == 0) {\n\tsrc = fwrite(data, 1, length, file);\n\tif (src != length) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_File_WriteBinaryFile: Error writing %s, %lu bytes, got %lu\\n\",\n\t\t       filename, (unsigned long)length, (unsigned long)src);\n\t    rc = TSS_RC_FILE_WRITE;\n\t}\n    }\n    if (file != NULL) {\n\tirc = fclose(file);\t\t/* @1 */\n\tif (irc != 0) {\n\t    if (tssVerbose) printf(\"TSS_File_WriteBinaryFile: Error closing %s\\n\",\n\t\t\t\t   filename);\n\t    rc = TSS_RC_FILE_CLOSE;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_File_ReadStructure() is a general purpose \"read a structure\" function.\n   \n   It reads the filename, and then unmarshals the structure using \"unmarshalFunction\".\n*/\n\nTPM_RC TSS_File_ReadStructure(void \t\t\t*structure,\n\t\t\t      UnmarshalFunction_t \tunmarshalFunction,\n\t\t\t      const char \t\t*filename)\n{\n    TPM_RC \trc = 0;\n    uint8_t\t*buffer = NULL;\t\t/* for the free */\n    uint8_t\t*buffer1 = NULL;\t/* for unmarshaling */\n    size_t \tlength = 0;\n\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     filename);\n    }\n    if (rc == 0) {\n\tuint32_t ilength = (uint32_t)length;\n\tbuffer1 = buffer;\n\trc = unmarshalFunction(structure, &buffer1, &ilength);\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n/* TSS_File_ReadStructureFlag() is a general purpose \"read a structure\" function.\n\n   It reads the filename, and then unmarshals the structure using \"unmarshalFunction\".\n\n   It is similar to TSS_File_ReadStructure() but is used when the structure unmarshal function\n   requires the allowNull flag.\n*/\n\nTPM_RC TSS_File_ReadStructureFlag(void \t\t\t\t*structure,\n\t\t\t\t  UnmarshalFunctionFlag_t \tunmarshalFunction,\n\t\t\t\t  BOOL \t\t\t\tallowNull,\n\t\t\t\t  const char \t\t\t*filename)\n{\n    TPM_RC \trc = 0;\n    uint8_t\t*buffer = NULL;\t\t/* for the free */\n    uint8_t\t*buffer1 = NULL;\t/* for unmarshaling */\n    size_t \tlength = 0;\n\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     filename);\n    }\n    if (rc == 0) {\n\tuint32_t ilength = (uint32_t)length;\n\tbuffer1 = buffer;\n\trc = unmarshalFunction(structure, &buffer1, &ilength, allowNull);\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n/* TSS_File_WriteStructure() is a general purpose \"write a structure\" function.\n   \n   It marshals the structure using \"marshalFunction\", and then writes it to filename.\n*/\n\nTPM_RC TSS_File_WriteStructure(void \t\t\t*structure,\n\t\t\t       MarshalFunction_t \tmarshalFunction,\n\t\t\t       const char \t\t*filename)\n{\n    TPM_RC \trc = 0;\n    uint16_t\twritten = 0;\n    uint8_t\t*buffer = NULL;\t\t/* for the free */\n\n    if (rc == 0) {\n\trc = TSS_Structure_Marshal(&buffer,\t/* freed @1 */\n\t\t\t\t   &written,\n\t\t\t\t   structure,\n\t\t\t\t   marshalFunction);\n    }\n    if (rc == 0) {\n\trc = TSS_File_WriteBinaryFile(buffer,\n\t\t\t\t      written,\n\t\t\t\t      filename); \n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n/* TSS_File_Read2B() reads 'filename' and copies the data to 'tpm2b', checking targetSize\n\n */\n\nTPM_RC TSS_File_Read2B(TPM2B \t\t*tpm2b,\n\t\t       uint16_t \ttargetSize,\n\t\t       const char \t*filename)\n{\n    TPM_RC \trc = 0;\n    uint8_t\t*buffer = NULL;\n    size_t \tlength = 0;\n    \n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @1 */\n\t\t\t\t     &length,\n\t\t\t\t     filename);\n    }\n    if (rc == 0) {\n\tif (length > 0xffff) {\t/* overflow TPM2B uint16_t */\n\t    if (tssVerbose) printf(\"TSS_File_Read2B: size %u greater than 0xffff\\n\",\n\t\t\t\t   (unsigned int)length);\t\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    /* copy it into the TPM2B */\n    if (rc == 0) {\n\trc = TSS_TPM2B_Create(tpm2b, buffer, (uint16_t)length, targetSize);\n    }\n    free(buffer);\t/* @1 */\n    return rc;\n}\n\n/* FIXME need to add - ignore failure if does not exist */\n\nTPM_RC TSS_File_DeleteFile(const char *filename) \n{\n    TPM_RC \trc = 0;\n    int\t\tirc;\n    \n    if (rc == 0) {\n\tirc = remove(filename);\n\tif (irc != 0) {\n\t    rc = TSS_RC_FILE_REMOVE;\n\t}\n    }\n    return rc;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssftpm.c",
    "content": "\n#include <linux/ioctl.h>\n#include <linux/types.h>\n#include <fcntl.h>\n\n#include <ibmtss/TPM_Types.h>\n#include <ibmtss/tss.h>\n\n#include \"tssproperties.h\"\n\nstruct tss_ftpm_context {\n    uintptr_t commandBuffer;\n    uint32_t written;\n    uintptr_t responseBuffer;\n    uint32_t read;\n};\n\n\n#define FTPM_IOC_MAGIC  0xa5\n\n#define FTPM_IOC_RUN_COMMAND \\\n  _IOWR(FTPM_IOC_MAGIC, 0x01, struct tss_ftpm_context)\n\n\n/* TSS_Dev_Open() opens the TPM device (through the device driver) */\n\nstatic uint32_t TSS_FTPM_Dev_Open(TSS_CONTEXT *tssContext)\n{\n    uint32_t rc = 0;\n    \n\t  tssContext->dev_fd = open(tssContext->tssDevice, O_RDWR);\n\t  if (tssContext->dev_fd < 0) {\n\t    printf(\"TSS_Dev_Open: Error opening %s\\n\", tssContext->tssDevice);\n\t    rc = TSS_RC_NO_CONNECTION;\n\t  }\n    return rc;\n}\n\nTPM_RC TSS_FTPM_Transmit(TSS_CONTEXT *tssContext,\n\t\t\tuint8_t *responseBuffer, uint32_t *read,\n\t\t\tconst uint8_t *commandBuffer, uint32_t written,\n\t\t\tconst char *message)\n{\n    TPM_RC rc = 0;\n    struct tss_ftpm_context cnx;\n\n    /* open on first transmit */\n    if (tssContext->tssFirstTransmit) {\t\n      if (rc == 0) {\n          rc = TSS_FTPM_Dev_Open(tssContext);\n      }\n      if (rc == 0) {\n          tssContext->tssFirstTransmit = FALSE;\n      }\n    }\n\n    cnx.commandBuffer = (uintptr_t)commandBuffer;\n    cnx.responseBuffer = (uintptr_t)responseBuffer;\n    cnx.written = written;\n\n\n    if (ioctl(tssContext->dev_fd, FTPM_IOC_RUN_COMMAND, &cnx)) {\n      perror(\"[TSS] TSS_FTPM_Transmit(): ioctl error\");\n      return -1;\n    }\n\n    *read = cnx.read;\n\n    return rc;\n}"
  },
  {
    "path": "ibmtss-ftpm/tssmarshal.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t TSS Marshal and Unmarshal    \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2024.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <string.h>\n\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/Unmarshal_fp.h>\n\n/* This file holds:\n\n   ---------------------------------------\n\n   Recommended functions - with an unsigned size\n\n   * Primary marshal functions             TSS_primary_Marshalu\n   * Primary unmarshal functions           TSS_primary_Unmarshalu  in Unmarshal.c\n   * TPM 2.0 structure   marshal functions TSS_structure_Marshalu\n   * TPM 2.0 structure unmarshal functions TSS_structure_Unmarshalu in Unmarshal.c\n   * TPM 2.0 command     marshal functions TSS_command_In_Marshalu\n     TPM 2.0 command   unmarshal functions command_In_Unmarshal \n   * TPM 2.0 response  unmarshal functions TSS_response_Out_Unmarshalu\n\n   ---------------------------------------\n\n   Deprecated functions - with a signed size\n\n   * Primary   marshal functions           TSS_primary_Marshal\n   * Primary unmarshal functions           primary_Unmarshal       in Unmarshal.c\n   * TPM 2.0 structure   marshal functions TSS_structure_Marshal\n   * TPM 2.0 structure unmarshal functions structure_Unmarshal     in Unmarshal.c\n   * TPM 2.0 command     marshal functions TSS_command_In_Marshal\n   * TPM 2.0 response  unmarshal functions TSS_response_Out_Unmarshal\n\n   * are exposed in /tss2/\n*/\n\n/* The marshaling function prototype pattern is:\n\n   Return:\n\n   An extra return code, TSS_RC_INSUFFICIENT_BUFFER, indicates that the supplied buffer size is too\n   small.  The TPM functions assert.\n\n   'source' is the structure to be marshaled.\n   'written' is the __additional__ number of bytes written.\n   'buffer' is the buffer written.\n   ' size' is the remaining size of the buffer.\n\n   If 'buffer' is NULL, 'written' is updated but no marshaling is performed.  This is used in a two\n   pass pattern, where the first pass returns the size of the buffer to be malloc'ed.\n\n   If 'size' is NULL, the source is marshaled without a size check.  The caller must ensure that\n   the buffer is sufficient, often due to a malloc after the first pass.  */\n\n/* Marshal functions shared by TPM 1.2 and TPM 2.0 */\n\n/* The functions with the _Marshalu suffix are preferred.  They use an unsigned size.  The functions\n   with _Marshalu are deprecated.  */\n\nTPM_RC\nTSS_UINT8_Marshalu(const UINT8 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (buffer != NULL) {\t/* if buffer is NULL, don't marshal, just return written */\n\t/* if size is NULL, ignore it, else check sufficient */\n\tif ((size == NULL) || (*size >= sizeof(UINT8))) {\n\t    /* marshal, move the buffer */\n\t    (*buffer)[0] = *source;\n\t    *buffer += sizeof(UINT8);\n\t    /* is size was supplied, update it */\n\t    if (size != NULL) {\n\t\t*size -= sizeof(UINT8);\n\t    }\n\t}\n\telse {\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    *written += sizeof(UINT8);\n    return rc;\n}\n    \nTPM_RC\nTSS_INT8_Marshalu(const INT8 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    rc = TSS_UINT8_Marshalu((const UINT8 *)source, written, buffer, size);\n    return rc;\n}\n\nTPM_RC\nTSS_UINT16_Marshalu(const UINT16 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (buffer != NULL) {\n\tif ((size == NULL) || (*size >= sizeof(uint16_t))) {\n\n\t    (*buffer)[0] = (BYTE)((*source >> 8) & 0xff);\n\t    (*buffer)[1] = (BYTE)((*source >> 0) & 0xff);\n\t    *buffer += sizeof(uint16_t);\n\n\t    if (size != NULL) {\n\t\t*size -= sizeof(uint16_t);\n\t    }\n\t}\n\telse {\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    *written += sizeof(uint16_t);\n    return rc;\n}\n\nTPM_RC\nTSS_UINT32_Marshalu(const UINT32 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (buffer != NULL) {\n\tif ((size == NULL) || (*size >= sizeof(uint32_t))) {\n\n\t    (*buffer)[0] = (BYTE)((*source >> 24) & 0xff);\n\t    (*buffer)[1] = (BYTE)((*source >> 16) & 0xff);\n\t    (*buffer)[2] = (BYTE)((*source >>  8) & 0xff);\n\t    (*buffer)[3] = (BYTE)((*source >>  0) & 0xff);\n\t    *buffer += sizeof(uint32_t);\n\n\t    if (size != NULL) {\n\t\t*size -= sizeof(uint32_t);\n\t    }\n\t}\n\telse {\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    *written += sizeof(uint32_t);\n    return rc;\n}\n\nTPM_RC\nTSS_INT32_Marshalu(const INT32 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    rc = TSS_UINT32_Marshalu((const UINT32 *)source, written, buffer, size);\n    return rc;\n}\n\nTPM_RC\nTSS_UINT64_Marshalu(const UINT64 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (buffer != NULL) {\n\tif ((size == NULL) || (*size >= sizeof(UINT64))) {\n\n\t    (*buffer)[0] = (BYTE)((*source >> 56) & 0xff);\n\t    (*buffer)[1] = (BYTE)((*source >> 48) & 0xff);\n\t    (*buffer)[2] = (BYTE)((*source >> 40) & 0xff);\n\t    (*buffer)[3] = (BYTE)((*source >> 32) & 0xff);\n\t    (*buffer)[4] = (BYTE)((*source >> 24) & 0xff);\n\t    (*buffer)[5] = (BYTE)((*source >> 16) & 0xff);\n\t    (*buffer)[6] = (BYTE)((*source >>  8) & 0xff);\n\t    (*buffer)[7] = (BYTE)((*source >>  0) & 0xff);\n\t    *buffer += sizeof(UINT64);\n\n\t    if (size != NULL) {\n\t\t*size -= sizeof(UINT64);\n\t    }\n\t}\n\telse {\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    *written += sizeof(UINT64);\n    return rc;\n}\n\nTPM_RC\nTSS_Array_Marshalu(const BYTE *source, uint16_t sourceSize, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (buffer != NULL) {\n\tif ((size == NULL) || (*size >= sourceSize)) {\n\t    memcpy(*buffer, source, sourceSize);\n\n\t    *buffer += sourceSize;\n\n\t    if (size != NULL) {\n\t\t*size -= sourceSize;\n\t    }\n\t}\n\telse {\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    *written += sourceSize;\n    return rc;\n}\n\n\n#ifdef TPM_TPM20\n\n/*\n  TPM 2.0 Command parameter marshaling\n*/\n\nTPM_RC\nTSS_Startup_In_Marshalu(const Startup_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_SU_Marshalu(&source->startupType, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Shutdown_In_Marshalu(const Shutdown_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_SU_Marshalu(&source->shutdownType, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_SelfTest_In_Marshalu(const SelfTest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_YES_NO_Marshalu(&source->fullTest, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_IncrementalSelfTest_In_Marshalu(const IncrementalSelfTest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPML_ALG_Marshalu(&source->toTest, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_StartAuthSession_In_Marshalu(const StartAuthSession_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->tpmKey, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_ENTITY_Marshalu(&source->bind, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->nonceCaller, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(&source->encryptedSalt, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_SE_Marshalu(&source->sessionType, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SYM_DEF_Marshalu(&source->symmetric, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->authHash, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyRestart_In_Marshalu(const PolicyRestart_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->sessionHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Create_In_Marshalu(const Create_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_SENSITIVE_CREATE_Marshalu(&source->inSensitive, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PUBLIC_Marshalu(&source->inPublic, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->outsideInfo, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_PCR_SELECTION_Marshalu(&source->creationPCR, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Load_In_Marshalu(const Load_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PRIVATE_Marshalu(&source->inPrivate, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PUBLIC_Marshalu(&source->inPublic, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_LoadExternal_In_Marshalu(const LoadExternal_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\t/* optional parameter, use size as flag */\n\tif (source->inPrivate.b.size == 0) {\t\t/* not present */\n\t    uint16_t zero = 0;\n\t    rc = TSS_UINT16_Marshalu(&zero, written, buffer, size);\n\t}\n\telse {\n\t    rc = TSS_TPM2B_SENSITIVE_Marshalu(&source->inPrivate, written, buffer, size);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PUBLIC_Marshalu(&source->inPublic, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ReadPublic_In_Marshalu(const ReadPublic_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ActivateCredential_In_Marshalu(const ActivateCredential_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->activateHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ID_OBJECT_Marshalu(&source->credentialBlob, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(&source->secret, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_MakeCredential_In_Marshalu(const MakeCredential_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->handle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->credential, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->objectName, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Unseal_In_Marshalu(const Unseal_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->itemHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ObjectChangeAuth_In_Marshalu(const ObjectChangeAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->newAuth, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_CreateLoaded_In_Marshalu(const CreateLoaded_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_SENSITIVE_CREATE_Marshalu(&source->inSensitive, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_TEMPLATE_Marshalu(&source->inPublic, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Duplicate_In_Marshalu(const Duplicate_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->newParentHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->encryptionKeyIn, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->symmetricAlg, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Rewrap_In_Marshalu(const Rewrap_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->oldParent, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->newParent, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PRIVATE_Marshalu(&source->inDuplicate, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->name, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(&source->inSymSeed, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Import_In_Marshalu(const Import_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->parentHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->encryptionKey, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PUBLIC_Marshalu(&source->objectPublic, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PRIVATE_Marshalu(&source->duplicate, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(&source->inSymSeed, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->symmetricAlg, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_RSA_Encrypt_In_Marshalu(const RSA_Encrypt_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(&source->message, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_RSA_DECRYPT_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->label, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_RSA_Decrypt_In_Marshalu(const RSA_Decrypt_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(&source->cipherText, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_RSA_DECRYPT_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->label, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECDH_KeyGen_In_Marshalu(const ECDH_KeyGen_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECDH_ZGen_In_Marshalu(const ECDH_ZGen_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_POINT_Marshalu(&source->inPoint, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECC_Parameters_In_Marshalu(const ECC_Parameters_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ECC_CURVE_Marshalu(&source->curveID, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECC_Encrypt_In_Marshalu(const ECC_Encrypt_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->plainText, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_KDF_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECC_Decrypt_In_Marshalu(const ECC_Decrypt_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_POINT_Marshalu(&source->C1, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->C2, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->C3, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_KDF_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ZGen_2Phase_In_Marshalu(const ZGen_2Phase_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyA, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_POINT_Marshalu(&source->inQsB, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_POINT_Marshalu(&source->inQeB, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ECC_KEY_EXCHANGE_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->counter, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_EncryptDecrypt_In_Marshalu(const EncryptDecrypt_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_YES_NO_Marshalu(&source->decrypt, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_CIPHER_MODE_Marshalu(&source->mode, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_IV_Marshalu(&source->ivIn, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->inData, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_EncryptDecrypt2_In_Marshalu(const EncryptDecrypt2_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->inData, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_YES_NO_Marshalu(&source->decrypt, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_CIPHER_MODE_Marshalu(&source->mode, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_IV_Marshalu(&source->ivIn, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Hash_In_Marshalu(const Hash_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->data, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_HMAC_In_Marshalu(const HMAC_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->handle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->buffer, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetRandom_In_Marshalu(const GetRandom_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->bytesRequested, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_StirRandom_In_Marshalu(const StirRandom_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_SENSITIVE_DATA_Marshalu(&source->inData, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_HMAC_Start_In_Marshalu(const HMAC_Start_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->handle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->auth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_HashSequenceStart_In_Marshalu(const HashSequenceStart_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->auth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_SequenceUpdate_In_Marshalu(const SequenceUpdate_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->sequenceHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->buffer, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_SequenceComplete_In_Marshalu(const SequenceComplete_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->sequenceHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->buffer, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_EventSequenceComplete_In_Marshalu(const EventSequenceComplete_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->sequenceHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->buffer, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Certify_In_Marshalu(const Certify_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_CertifyCreation_In_Marshalu(const CertifyCreation_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->creationHash, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_TK_CREATION_Marshalu(&source->creationTicket, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_CertifyX509_In_Marshalu(const CertifyX509_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->reserved, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_BUFFER_Marshalu(&source->partialCertificate, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Quote_In_Marshalu(const Quote_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_PCR_SELECTION_Marshalu(&source->PCRselect, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetSessionAuditDigest_In_Marshalu(const GetSessionAuditDigest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_ENDORSEMENT_Marshalu(&source->privacyAdminHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_HMAC_Marshalu(&source->sessionHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetCommandAuditDigest_In_Marshalu(const GetCommandAuditDigest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_ENDORSEMENT_Marshalu(&source->privacyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetTime_In_Marshalu(const GetTime_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_ENDORSEMENT_Marshalu(&source->privacyAdminHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Commit_In_Marshalu(const Commit_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_POINT_Marshalu(&source->P1, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_SENSITIVE_DATA_Marshalu(&source->s2, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->y2, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_EC_Ephemeral_In_Marshalu(const EC_Ephemeral_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ECC_CURVE_Marshalu(&source->curveID, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_VerifySignature_In_Marshalu(const VerifySignature_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIGNATURE_Marshalu(&source->signature, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Sign_In_Marshalu(const Sign_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_TK_HASHCHECK_Marshalu(&source->validation, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_SetCommandCodeAuditStatus_In_Marshalu(const SetCommandCodeAuditStatus_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PROVISION_Marshalu(&source->auth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->auditAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_CC_Marshalu(&source->setList, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_CC_Marshalu(&source->clearList, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_Extend_In_Marshalu(const PCR_Extend_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_DIGEST_VALUES_Marshalu(&source->digests, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_Event_In_Marshalu(const PCR_Event_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_EVENT_Marshalu(&source->eventData, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_Read_In_Marshalu(const PCR_Read_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrSelectionIn, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_Allocate_In_Marshalu(const PCR_Allocate_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrAllocation, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_SetAuthPolicy_In_Marshalu(const PCR_SetAuthPolicy_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrNum, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_SetAuthValue_In_Marshalu(const PCR_SetAuthValue_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->auth, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_Reset_In_Marshalu(const PCR_Reset_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_PCR_Marshalu(&source->pcrHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicySigned_In_Marshalu(const PolicySigned_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->authObject, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->nonceTPM, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->cpHashA, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->policyRef, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_INT32_Marshalu(&source->expiration, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIGNATURE_Marshalu(&source->auth, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicySecret_In_Marshalu(const PolicySecret_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_ENTITY_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->nonceTPM, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->cpHashA, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->policyRef, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_INT32_Marshalu(&source->expiration, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyTicket_In_Marshalu(const PolicyTicket_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_TIMEOUT_Marshalu(&source->timeout, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->cpHashA, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->policyRef, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->authName, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_TK_AUTH_Marshalu(&source->ticket, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyOR_In_Marshalu(const PolicyOR_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_DIGEST_Marshalu(&source->pHashList, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyPCR_In_Marshalu(const PolicyPCR_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->pcrDigest, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrs, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyLocality_In_Marshalu(const PolicyLocality_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMA_LOCALITY_Marshalu(&source->locality, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyNV_In_Marshalu(const PolicyNV_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_OPERAND_Marshalu(&source->operandB, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_EO_Marshalu(&source->operation, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyCounterTimer_In_Marshalu(const PolicyCounterTimer_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_OPERAND_Marshalu(&source->operandB, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_EO_Marshalu(&source->operation, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyCommandCode_In_Marshalu(const PolicyCommandCode_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_CC_Marshalu(&source->code, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyPhysicalPresence_In_Marshalu(const PolicyPhysicalPresence_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyCpHash_In_Marshalu(const PolicyCpHash_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->cpHashA, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyNameHash_In_Marshalu(const PolicyNameHash_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->nameHash, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyDuplicationSelect_In_Marshalu(const PolicyDuplicationSelect_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->objectName, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->newParentName, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_YES_NO_Marshalu(&source->includeObject, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyAuthorize_In_Marshalu(const PolicyAuthorize_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->approvedPolicy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->policyRef, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->keySign, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_TK_VERIFIED_Marshalu(&source->checkTicket, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyAuthValue_In_Marshalu(const PolicyAuthValue_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyPassword_In_Marshalu(const PolicyPassword_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyGetDigest_In_Marshalu(const PolicyGetDigest_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyNvWritten_In_Marshalu(const PolicyNvWritten_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_YES_NO_Marshalu(&source->writtenSet, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyTemplate_In_Marshalu(const PolicyTemplate_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->templateHash, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyCapability_In_Marshalu(const PolicyCapability_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_OPERAND_Marshalu(&source->operandB, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_EO_Marshalu(&source->operation, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_CAP_Marshalu(&source->capability, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->property, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyParameters_In_Marshalu(const PolicyParameters_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->pHash, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyAuthorizeNV_In_Marshalu(const PolicyAuthorizeNV_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_POLICY_Marshalu(&source->policySession, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_CreatePrimary_In_Marshalu(const CreatePrimary_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->primaryHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_SENSITIVE_CREATE_Marshalu(&source->inSensitive, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PUBLIC_Marshalu(&source->inPublic, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->outsideInfo, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_PCR_SELECTION_Marshalu(&source->creationPCR, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_HierarchyControl_In_Marshalu(const HierarchyControl_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_ENABLES_Marshalu(&source->enable, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_YES_NO_Marshalu(&source->state, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_SetPrimaryPolicy_In_Marshalu(const SetPrimaryPolicy_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_POLICY_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ChangePPS_In_Marshalu(const ChangePPS_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ChangeEPS_In_Marshalu(const ChangeEPS_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Clear_In_Marshalu(const Clear_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_CLEAR_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ClearControl_In_Marshalu(const ClearControl_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_CLEAR_Marshalu(&source->auth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_YES_NO_Marshalu(&source->disable, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_HierarchyChangeAuth_In_Marshalu(const HierarchyChangeAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->newAuth, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_DictionaryAttackLockReset_In_Marshalu(const DictionaryAttackLockReset_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_LOCKOUT_Marshalu(&source->lockHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_DictionaryAttackParameters_In_Marshalu(const DictionaryAttackParameters_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_LOCKOUT_Marshalu(&source->lockHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->newMaxTries, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->newRecoveryTime, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->lockoutRecovery, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PP_Commands_In_Marshalu(const PP_Commands_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->auth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_CC_Marshalu(&source->setList, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPML_CC_Marshalu(&source->clearList, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_SetAlgorithmSet_In_Marshalu(const SetAlgorithmSet_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->algorithmSet, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ContextSave_In_Marshalu(const ContextSave_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_CONTEXT_Marshalu(&source->saveHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ContextLoad_In_Marshalu(const ContextLoad_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_CONTEXT_Marshalu(&source->context, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_FlushContext_In_Marshalu(const FlushContext_In *source, uint16_t *written, BYTE **buffer, uint32_t *size) \n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_CONTEXT_Marshalu(&source->flushHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_EvictControl_In_Marshalu(const EvictControl_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PROVISION_Marshalu(&source->auth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->objectHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_PERSISTENT_Marshalu(&source->persistentHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ClockSet_In_Marshalu(const ClockSet_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PROVISION_Marshalu(&source->auth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64_Marshalu(&source->newTime, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ClockRateAdjust_In_Marshalu(const ClockRateAdjust_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PROVISION_Marshalu(&source->auth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_CLOCK_ADJUST_Marshalu(&source->rateAdjust, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetCapability_In_Marshalu(const GetCapability_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_CAP_Marshalu(&source->capability, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->property, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->propertyCount, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_TestParms_In_Marshalu(const TestParms_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMT_PUBLIC_PARMS_Marshalu(&source->parameters, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_DefineSpace_In_Marshalu(const NV_DefineSpace_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PROVISION_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->auth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NV_PUBLIC_Marshalu(&source->publicInfo, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_UndefineSpace_In_Marshalu(const NV_UndefineSpace_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PROVISION_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_UndefineSpaceSpecial_In_Marshalu(const NV_UndefineSpaceSpecial_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PLATFORM_Marshalu(&source->platform, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_ReadPublic_In_Marshalu(const NV_ReadPublic_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_Write_In_Marshalu(const NV_Write_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_NV_BUFFER_Marshalu(&source->data, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_Increment_In_Marshalu(const NV_Increment_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_Extend_In_Marshalu(const NV_Extend_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_NV_BUFFER_Marshalu(&source->data, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_SetBits_In_Marshalu(const NV_SetBits_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64_Marshalu(&source->bits, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_WriteLock_In_Marshalu(const NV_WriteLock_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_GlobalWriteLock_In_Marshalu(const NV_GlobalWriteLock_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_PROVISION_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_Read_In_Marshalu(const NV_Read_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->size, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_ReadLock_In_Marshalu(const NV_ReadLock_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_ChangeAuth_In_Marshalu(const NV_ChangeAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->newAuth, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_Certify_In_Marshalu(const NV_Certify_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_OBJECT_Marshalu(&source->signHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_AUTH_Marshalu(&source->authHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->qualifyingData, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SIG_SCHEME_Marshalu(&source->inScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->size, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size);\n    }\n    return rc;\n}\n\n/*\n  TPM 2.0 Response parameter unmarshaling\n*/\n\nTPM_RC\nTSS_IncrementalSelfTest_Out_Unmarshalu(IncrementalSelfTest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_ALG_Unmarshalu(&target->toDoList, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetTestResult_Out_Unmarshalu(GetTestResult_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    uint32_t parameterSize;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->outData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_RC_Unmarshalu(&target->testResult, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_StartAuthSession_Out_Unmarshalu(StartAuthSession_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_SH_AUTH_SESSION_Unmarshalu(&target->sessionHandle, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NONCE_Unmarshalu(&target->nonceTPM, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Create_Out_Unmarshalu(Create_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outPrivate, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->outPublic, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_CREATION_DATA_Unmarshalu(&target->creationData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->creationHash, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_CREATION_Unmarshalu(&target->creationTicket, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Load_Out_Unmarshalu(Load_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(&target->objectHandle, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_LoadExternal_Out_Unmarshalu(LoadExternal_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(&target->objectHandle, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ReadPublic_Out_Unmarshalu(ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->outPublic, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->qualifiedName, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ActivateCredential_Out_Unmarshalu(ActivateCredential_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->certInfo, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_MakeCredential_Out_Unmarshalu(MakeCredential_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ID_OBJECT_Unmarshalu(&target->credentialBlob, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->secret, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Unseal_Out_Unmarshalu(Unseal_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_SENSITIVE_DATA_Unmarshalu(&target->outData, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ObjectChangeAuth_Out_Unmarshalu(ObjectChangeAuth_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outPrivate, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_CreateLoaded_Out_Unmarshalu(CreateLoaded_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(&target->objectHandle, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outPrivate, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->outPublic, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Duplicate_Out_Unmarshalu(Duplicate_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DATA_Unmarshalu(&target->encryptionKeyOut, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->duplicate, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->outSymSeed, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Rewrap_Out_Unmarshalu(Rewrap_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outDuplicate, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ENCRYPTED_SECRET_Unmarshalu(&target->outSymSeed, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Import_Out_Unmarshalu(Import_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PRIVATE_Unmarshalu(&target->outPrivate, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_RSA_Encrypt_Out_Unmarshalu(RSA_Encrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->outData, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_RSA_Decrypt_Out_Unmarshalu(RSA_Decrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_KEY_RSA_Unmarshalu(&target->message, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECDH_KeyGen_Out_Unmarshalu(ECDH_KeyGen_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->zPoint, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->pubPoint, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECDH_ZGen_Out_Unmarshalu(ECDH_ZGen_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->outPoint, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECC_Parameters_Out_Unmarshalu(ECC_Parameters_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_ALGORITHM_DETAIL_ECC_Unmarshalu(&target->parameters, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECC_Encrypt_Out_Unmarshalu(ECC_Encrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->C1, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->C2, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->C3, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ECC_Decrypt_Out_Unmarshalu(ECC_Decrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->plainText, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ZGen_2Phase_Out_Unmarshalu(ZGen_2Phase_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->outZ1, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->outZ2, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_EncryptDecrypt_Out_Unmarshalu(EncryptDecrypt_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->outData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_IV_Unmarshalu(&target->ivOut, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_EncryptDecrypt2_Out_Unmarshalu(EncryptDecrypt2_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    return TSS_EncryptDecrypt_Out_Unmarshalu((EncryptDecrypt_Out *)target, tag, buffer, size);\n}\nTPM_RC\nTSS_Hash_Out_Unmarshalu(Hash_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->outHash, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_HASHCHECK_Unmarshalu(&target->validation, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_HMAC_Out_Unmarshalu(HMAC_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->outHMAC, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetRandom_Out_Unmarshalu(GetRandom_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->randomBytes, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_HMAC_Start_Out_Unmarshalu(HMAC_Start_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_DH_OBJECT_Unmarshalu(&target->sequenceHandle, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    return rc;\n}\nTPM_RC\nTSS_HashSequenceStart_Out_Unmarshalu(HashSequenceStart_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_DH_OBJECT_Unmarshalu(&target->sequenceHandle, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    return rc;\n}\nTPM_RC\nTSS_SequenceComplete_Out_Unmarshalu(SequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->result, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_HASHCHECK_Unmarshalu(&target->validation, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_EventSequenceComplete_Out_Unmarshalu(EventSequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_DIGEST_VALUES_Unmarshalu(&target->results, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Certify_Out_Unmarshalu(Certify_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ATTEST_Unmarshalu(&target->certifyInfo, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES);\n    }\n    return rc;\n}\nTPM_RC\nTSS_CertifyCreation_Out_Unmarshalu(CertifyCreation_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ATTEST_Unmarshalu(&target->certifyInfo, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES);\n    }\n    return rc;\n}\nTPM_RC\nTSS_CertifyX509_Out_Unmarshalu(CertifyX509_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_BUFFER_Unmarshalu(&target->addedToCertificate, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->tbsDigest, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Quote_Out_Unmarshalu(Quote_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ATTEST_Unmarshalu(&target->quoted, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetSessionAuditDigest_Out_Unmarshalu(GetSessionAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ATTEST_Unmarshalu(&target->auditInfo, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetCommandAuditDigest_Out_Unmarshalu(GetCommandAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ATTEST_Unmarshalu(&target->auditInfo, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetTime_Out_Unmarshalu(GetTime_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ATTEST_Unmarshalu(&target->timeInfo, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Commit_Out_Unmarshalu(Commit_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->K, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->L, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->E, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->counter, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_EC_Ephemeral_Out_Unmarshalu(EC_Ephemeral_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ECC_POINT_Unmarshalu(&target->Q, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT16_Unmarshalu(&target->counter, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_VerifySignature_Out_Unmarshalu(VerifySignature_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_VERIFIED_Unmarshalu(&target->validation, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_Sign_Out_Unmarshalu(Sign_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, NO);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_Event_Out_Unmarshalu(PCR_Event_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_DIGEST_VALUES_Unmarshalu(&target->digests, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_Read_Out_Unmarshalu(PCR_Read_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->pcrUpdateCounter, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_PCR_SELECTION_Unmarshalu(&target->pcrSelectionOut, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPML_DIGEST_Unmarshalu(&target->pcrValues, buffer, size, 0);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PCR_Allocate_Out_Unmarshalu(PCR_Allocate_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->allocationSuccess, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->maxPCR, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->sizeNeeded, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_UINT32_Unmarshalu(&target->sizeAvailable, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicySigned_Out_Unmarshalu(PolicySigned_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_TIMEOUT_Unmarshalu(&target->timeout, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_AUTH_Unmarshalu(&target->policyTicket, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicySecret_Out_Unmarshalu(PolicySecret_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_TIMEOUT_Unmarshalu(&target->timeout, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_AUTH_Unmarshalu(&target->policyTicket, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_PolicyGetDigest_Out_Unmarshalu(PolicyGetDigest_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->policyDigest, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_CreatePrimary_Out_Unmarshalu(CreatePrimary_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM_HANDLE_Unmarshalu(&target->objectHandle, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_PUBLIC_Unmarshalu(&target->outPublic, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_CREATION_DATA_Unmarshalu(&target->creationData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_DIGEST_Unmarshalu(&target->creationHash, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_TK_CREATION_Unmarshalu(&target->creationTicket, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->name, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ContextSave_Out_Unmarshalu(ContextSave_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_CONTEXT_Unmarshalu(&target->context, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_ContextLoad_Out_Unmarshalu(ContextLoad_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_DH_CONTEXT_Unmarshalu(&target->loadedHandle, buffer, size, NO);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    return rc;\n}\nTPM_RC\nTSS_ReadClock_Out_Unmarshalu(ReadClock_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_TIME_INFO_Unmarshalu(&target->currentTime, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_GetCapability_Out_Unmarshalu(GetCapability_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMI_YES_NO_Unmarshalu(&target->moreData, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMS_CAPABILITY_DATA_Unmarshalu(&target->capabilityData, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_ReadPublic_Out_Unmarshalu(NV_ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NV_PUBLIC_Unmarshalu(&target->nvPublic, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_NAME_Unmarshalu(&target->nvName, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_Read_Out_Unmarshalu(NV_Read_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_MAX_NV_BUFFER_Unmarshalu(&target->data, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_NV_Certify_Out_Unmarshalu(NV_Certify_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    uint32_t parameterSize = 0;\n    if (rc == TPM_RC_SUCCESS) {\n\tif (tag == TPM_ST_SESSIONS) {\n\t    rc = TSS_UINT32_Unmarshalu(&parameterSize, buffer, size);\n\t}\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPM2B_ATTEST_Unmarshalu(&target->certifyInfo, buffer, size);\n    }\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_TPMT_SIGNATURE_Unmarshalu(&target->signature, buffer, size, YES);\n    }\n    return rc;\n}\n\n/*\n  TPM 2.0 Structure marshaling\n*/\n\nTPM_RC\nTSS_TPM2B_Marshalu(const TPM2B *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&(source->size), written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->buffer, source->size, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 5 - Definition of Types for Documentation Clarity */\n\nTPM_RC\nTSS_TPM_KEY_BITS_Marshalu(const TPM_KEY_BITS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n   \n/* Table 7 - Definition of (UINT32) TPM_GENERATED Constants <O> */\n\nTPM_RC\nTSS_TPM_GENERATED_Marshalu(const TPM_GENERATED *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n \n/* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM_ALG_ID_Marshalu(const TPM_ALG_ID *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 10 - Definition of (uint16_t) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */\n\n#ifdef TPM_ALG_ECC\nTPM_RC\nTSS_TPM_ECC_CURVE_Marshalu(const TPM_ECC_CURVE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n#endif\n\n/* Table 17 - Definition of (UINT32) TPM_RC Constants (Actions) <OUT> */\n\nTPM_RC\nTSS_TPM_RC_Marshalu(const TPM_RC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 18 - Definition of (INT8) TPM_CLOCK_ADJUST Constants <IN> */\n\nTPM_RC\nTSS_TPM_CLOCK_ADJUST_Marshalu(const TPM_CLOCK_ADJUST *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_INT8_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 19 - Definition of (UINT16) TPM_EO Constants <IN/OUT> */\n\nTPM_RC\nTSS_TPM_EO_Marshalu(const TPM_EO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 20 - Definition of (UINT16) TPM_ST Constants <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM_ST_Marshalu(const TPM_ST *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n \n/* Table 21 - Definition of (UINT16) TPM_SU Constants <IN> */\n\nTPM_RC\nTSS_TPM_SU_Marshalu(const TPM_ST *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 22 - Definition of (UINT8) TPM_SE Constants <IN> */\n\nTPM_RC\nTSS_TPM_SE_Marshalu(const TPM_SE  *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 23 - Definition of (UINT32) TPM_CAP Constants  */\n\nTPM_RC\nTSS_TPM_CAP_Marshalu(const TPM_CAP *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 24 - Definition of (UINT32) TPM_PT Constants <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM_PT_Marshalu(const TPM_PT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 25 - Definition of (UINT32) TPM_PT_PCR Constants <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM_PT_PCR_Marshalu(const TPM_PT_PCR *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 27 - Definition of Types for Handles */\n\nTPM_RC\nTSS_TPM_HANDLE_Marshalu(const TPM_HANDLE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 31 - Definition of (UINT32) TPMA_ALGORITHM Bits */\n\nTPM_RC\nTSS_TPMA_ALGORITHM_Marshalu(const TPMA_ALGORITHM *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->val, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 32 - Definition of (UINT32) TPMA_OBJECT Bits */\n\nTPM_RC\nTSS_TPMA_OBJECT_Marshalu(const TPMA_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->val, written, buffer, size);\n    }\n    return rc;\n}\n \n/* Table 33 - Definition of (UINT8) TPMA_SESSION Bits <IN/OUT> */\n\nTPM_RC\nTSS_TPMA_SESSION_Marshalu(const TPMA_SESSION *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->val, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 34 - Definition of (UINT8) TPMA_LOCALITY Bits <IN/OUT> */\n\nTPM_RC\nTSS_TPMA_LOCALITY_Marshalu(const TPMA_LOCALITY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->val, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 38 - Definition of (TPM_CC) TPMA_CC Bits <OUT> */\n\nTPM_RC\nTSS_TPM_CC_Marshalu(const TPM_CC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 38 - Definition of (TPM_CC) TPMA_CC Bits <OUT> */\n\nTPM_RC\nTSS_TPMA_CC_Marshalu(const TPMA_CC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->val, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 39 - Definition of (BYTE) TPMI_YES_NO Type */\n\nTPM_RC\nTSS_TPMI_YES_NO_Marshalu(const TPMI_YES_NO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 40 - Definition of (TPM_HANDLE) TPMI_DH_OBJECT Type */\n\nTPM_RC\nTSS_TPMI_DH_OBJECT_Marshalu(const TPMI_DH_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 41 - Definition of (TPM_HANDLE) TPMI_DH_PERSISTENT Type */\n\nTPM_RC\nTSS_TPMI_DH_PERSISTENT_Marshalu(const TPMI_DH_PERSISTENT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 42 - Definition of (TPM_HANDLE) TPMI_DH_ENTITY Type <IN> */\n\nTPM_RC\nTSS_TPMI_DH_ENTITY_Marshalu(const TPMI_DH_ENTITY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 43 - Definition of (TPM_HANDLE) TPMI_DH_PCR Type <IN> */\n\nTPM_RC\nTSS_TPMI_DH_PCR_Marshalu(const TPMI_DH_PCR  *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 44 - Definition of (TPM_HANDLE) TPMI_SH_AUTH_SESSION Type <IN/OUT> */\n\nTPM_RC\nTSS_TPMI_SH_AUTH_SESSION_Marshalu(const TPMI_SH_AUTH_SESSION *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 45 - Definition of (TPM_HANDLE) TPMI_SH_HMAC Type <IN/OUT> */\n\nTPM_RC\nTSS_TPMI_SH_HMAC_Marshalu(const TPMI_SH_HMAC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 46 - Definition of (TPM_HANDLE) TPMI_SH_POLICY Type <IN/OUT> */\n\nTPM_RC\nTSS_TPMI_SH_POLICY_Marshalu(const TPMI_SH_POLICY*source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n  \n/* Table 47 - Definition of (TPM_HANDLE) TPMI_DH_CONTEXT Type  */\n\nTPM_RC\nTSS_TPMI_DH_CONTEXT_Marshalu(const TPMI_DH_CONTEXT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 49 - Definition of (TPM_HANDLE) TPMI_DH_SAVED Type  */\n\nTPM_RC\nTSS_TPMI_DH_SAVED_Marshalu(const TPMI_DH_SAVED *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 48 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY Type  */\n\nTPM_RC\nTSS_TPMI_RH_HIERARCHY_Marshalu(const TPMI_RH_HIERARCHY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n   \n/* Table 49 - Definition of (TPM_HANDLE) TPMI_RH_ENABLES Type */\n\nTPM_RC\nTSS_TPMI_RH_ENABLES_Marshalu(const TPMI_RH_ENABLES *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 50 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY_AUTH Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_HIERARCHY_AUTH_Marshalu(const TPMI_RH_HIERARCHY_AUTH *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 50 - Definition of (TPM_HANDLE) TPMI_RH_HIERARCHY_POLICY Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_HIERARCHY_POLICY_Marshalu(const TPMI_RH_HIERARCHY_POLICY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 51 - Definition of (TPM_HANDLE) TPMI_RH_PLATFORM Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_PLATFORM_Marshalu(const TPMI_RH_PLATFORM *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 53 - Definition of (TPM_HANDLE) TPMI_RH_ENDORSEMENT Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_ENDORSEMENT_Marshalu(const TPMI_RH_ENDORSEMENT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 54 - Definition of (TPM_HANDLE) TPMI_RH_PROVISION Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_PROVISION_Marshalu(const TPMI_RH_PROVISION *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 55 - Definition of (TPM_HANDLE) TPMI_RH_CLEAR Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_CLEAR_Marshalu(const TPMI_RH_CLEAR *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 56 - Definition of (TPM_HANDLE) TPMI_RH_NV_AUTH Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_NV_AUTH_Marshalu(const TPMI_RH_NV_AUTH *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 57 - Definition of (TPM_HANDLE) TPMI_RH_LOCKOUT Type <IN> */\n\nTPM_RC\nTSS_TPMI_RH_LOCKOUT_Marshalu(const TPMI_RH_LOCKOUT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 58 - Definition of (TPM_HANDLE) TPMI_RH_NV_INDEX Type <IN/OUT> */\n\nTPM_RC\nTSS_TPMI_RH_NV_INDEX_Marshalu(const TPMI_RH_NV_INDEX *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_HANDLE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 59 - Definition of (TPM_ALG_ID) TPMI_ALG_HASH Type  */\n\nTPM_RC\nTSS_TPMI_ALG_HASH_Marshalu(const TPMI_ALG_HASH *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 61 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM Type */\n\nTPM_RC\nTSS_TPMI_ALG_SYM_Marshalu(const TPMI_ALG_SYM *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 62 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_OBJECT Type */\n\nTPM_RC\nTSS_TPMI_ALG_SYM_OBJECT_Marshalu(const TPMI_ALG_SYM_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 63 - Definition of (TPM_ALG_ID) TPMI_ALG_SYM_MODE Type */\n\nTPM_RC\nTSS_TPMI_ALG_SYM_MODE_Marshalu(const TPMI_ALG_SYM_MODE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 64 - Definition of (TPM_ALG_ID) TPMI_ALG_KDF Type */\n\nTPM_RC\nTSS_TPMI_ALG_KDF_Marshalu(const TPMI_ALG_KDF *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 65 - Definition of (TPM_ALG_ID) TPMI_ALG_SIG_SCHEME Type */\n\nTPM_RC\nTSS_TPMI_ALG_SIG_SCHEME_Marshalu(const TPMI_ALG_SIG_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 66 - Definition of (TPM_ALG_ID) TPMI_ECC_KEY_EXCHANGE Type */\n\nTPM_RC\nTSS_TPMI_ECC_KEY_EXCHANGE_Marshalu(const TPMI_ECC_KEY_EXCHANGE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n} \n\n/* Table 67 - Definition of (TPM_ST) TPMI_ST_COMMAND_TAG Type */\n\nTPM_RC\nTSS_TPMI_ST_COMMAND_TAG_Marshalu(const TPMI_ST_COMMAND_TAG *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ST_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 71 - Definition of (TPM_ALG_ID) TPMI_ALG_MAC_SCHEME Type */\n\nTPM_RC\nTSS_TPMI_ALG_MAC_SCHEME_Marshalu(const TPMI_ALG_MAC_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size) \n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 72 - Definition of (TPM_ALG_ID) TPMI_ALG_CIPHER_MODE Type */\n\nTPM_RC\nTSS_TPMI_ALG_CIPHER_MODE_Marshalu(const TPMI_ALG_CIPHER_MODE *source, uint16_t *written, BYTE **buffer, uint32_t *size) \n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n} \n\n/* Table 70 - Definition of TPMU_HA Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_HA_Marshalu(const TPMU_HA *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    \n    switch (selector) {\n#ifdef TPM_ALG_SHA1\n      case TPM_ALG_SHA1:\n\tif (rc == 0) {\n\t    rc = TSS_Array_Marshalu(&source->sha1[0], SHA1_DIGEST_SIZE, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA256\n      case TPM_ALG_SHA256:\n\tif (rc == 0) {\n\t    rc = TSS_Array_Marshalu(&source->sha256[0], SHA256_DIGEST_SIZE, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA384\n      case TPM_ALG_SHA384:\n\tif (rc == 0) {\n\t    rc = TSS_Array_Marshalu(&source->sha384[0], SHA384_DIGEST_SIZE, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA512\n      case TPM_ALG_SHA512:\n\tif (rc == 0) {\n\t    rc = TSS_Array_Marshalu(&source->sha512[0], SHA512_DIGEST_SIZE, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM3_256\n      case TPM_ALG_SM3_256:\n\tif (rc == 0) {\n\t    rc = TSS_Array_Marshalu(&source->sm3_256[0], SM3_256_DIGEST_SIZE, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 71 - Definition of TPMT_HA Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPMT_HA_Marshalu(const TPMT_HA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_HA_Marshalu(&source->digest, written, buffer, size, source->hashAlg);\n    }\n    return rc;\n}\n\n/* Table 72 - Definition of TPM2B_DIGEST Structure */\n\nTPM_RC\nTSS_TPM2B_DIGEST_Marshalu(const TPM2B_DIGEST *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 73 - Definition of TPM2B_DATA Structure */\n\nTPM_RC\nTSS_TPM2B_DATA_Marshalu(const TPM2B_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 74 - Definition of Types for TPM2B_NONCE */\n\nTPM_RC\nTSS_TPM2B_NONCE_Marshalu(const TPM2B_NONCE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 75 - Definition of Types for TPM2B_AUTH */\n\nTPM_RC\nTSS_TPM2B_AUTH_Marshalu(const TPM2B_AUTH *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 76 - Definition of Types for TPM2B_OPERAND */\n\nTPM_RC\nTSS_TPM2B_OPERAND_Marshalu(const TPM2B_OPERAND *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 77 - Definition of TPM2B_EVENT Structure */\n\nTPM_RC\nTSS_TPM2B_EVENT_Marshalu(const TPM2B_EVENT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 78 - Definition of TPM2B_MAX_BUFFER Structure */\n\nTPM_RC\nTSS_TPM2B_MAX_BUFFER_Marshalu(const TPM2B_MAX_BUFFER *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 79 - Definition of TPM2B_MAX_NV_BUFFER Structure */\n\nTPM_RC\nTSS_TPM2B_MAX_NV_BUFFER_Marshalu(const TPM2B_MAX_NV_BUFFER *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 80 - Definition of TPM2B_TIMEOUT Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_TIMEOUT_Marshalu(const TPM2B_TIMEOUT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 81 - Definition of TPM2B_IV Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_IV_Marshalu(const TPM2B_IV *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 83 - Definition of TPM2B_NAME Structure */\n\nTPM_RC\nTSS_TPM2B_NAME_Marshalu(const TPM2B_NAME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 85 - Definition of TPMS_PCR_SELECTION Structure */\n\nTPM_RC\nTSS_TPMS_PCR_SELECTION_Marshalu(const TPMS_PCR_SELECTION *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    \n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hash, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->sizeofSelect, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(&source->pcrSelect[0], source->sizeofSelect, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 88 - Definition of TPMT_TK_CREATION Structure */\n\nTPM_RC\nTSS_TPMT_TK_CREATION_Marshalu(const TPMT_TK_CREATION *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ST_Marshalu(&source->tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 89 - Definition of TPMT_TK_VERIFIED Structure */\n\nTPM_RC\nTSS_TPMT_TK_VERIFIED_Marshalu(const TPMT_TK_VERIFIED *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ST_Marshalu(&source->tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 90 - Definition of TPMT_TK_AUTH Structure */\n\nTPM_RC\nTSS_TPMT_TK_AUTH_Marshalu(const TPMT_TK_AUTH *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ST_Marshalu(&source->tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 91 - Definition of TPMT_TK_HASHCHECK Structure */\n\nTPM_RC\nTSS_TPMT_TK_HASHCHECK_Marshalu(const TPMT_TK_HASHCHECK *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ST_Marshalu(&source->tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->digest, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 92 - Definition of TPMS_ALG_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_ALG_PROPERTY_Marshalu(const TPMS_ALG_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(&source->alg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMA_ALGORITHM_Marshalu(&source->algProperties, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 93 - Definition of TPMS_TAGGED_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_TAGGED_PROPERTY_Marshalu(const TPMS_TAGGED_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_PT_Marshalu(&source->property, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->value, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 94 - Definition of TPMS_TAGGED_PCR_SELECT Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_TAGGED_PCR_SELECT_Marshalu(const TPMS_TAGGED_PCR_SELECT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_PT_PCR_Marshalu(&source->tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->sizeofSelect, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(&source->pcrSelect[0], source->sizeofSelect, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 95 - Definition of TPML_CC Structure */\n\nTPM_RC\nTSS_TPML_CC_Marshalu(const TPML_CC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPM_CC_Marshalu(&source->commandCodes[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 96 - Definition of TPML_CCA Structure <OUT> */\n\nTPM_RC\nTSS_TPML_CCA_Marshalu(const TPML_CCA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPMA_CC_Marshalu(&source->commandAttributes[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 97 - Definition of TPML_ALG Structure */\n\nTPM_RC\nTSS_TPML_ALG_Marshalu(const TPML_ALG *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPM_ALG_ID_Marshalu(&source->algorithms[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 98 - Definition of TPML_HANDLE Structure <OUT> */\n\nTPM_RC\nTSS_TPML_HANDLE_Marshalu(const TPML_HANDLE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPM_HANDLE_Marshalu(&source->handle[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 99 - Definition of TPML_DIGEST Structure */\n\nTPM_RC\nTSS_TPML_DIGEST_Marshalu(const TPML_DIGEST *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_DIGEST_Marshalu(&source->digests[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 100 - Definition of TPML_DIGEST_VALUES Structure */\n\nTPM_RC\nTSS_TPML_DIGEST_VALUES_Marshalu(const TPML_DIGEST_VALUES *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPMT_HA_Marshalu(&source->digests[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 102 - Definition of TPML_PCR_SELECTION Structure */\n\nTPM_RC\nTSS_TPML_PCR_SELECTION_Marshalu(const TPML_PCR_SELECTION *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_PCR_SELECTION_Marshalu(&source->pcrSelections[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 103 - Definition of TPML_ALG_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPML_ALG_PROPERTY_Marshalu(const TPML_ALG_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_ALG_PROPERTY_Marshalu(&source->algProperties[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 104 - Definition of TPML_TAGGED_TPM_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPML_TAGGED_TPM_PROPERTY_Marshalu(const TPML_TAGGED_TPM_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_TAGGED_PROPERTY_Marshalu(&source->tpmProperty[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 105 - Definition of TPML_TAGGED_PCR_PROPERTY Structure <OUT> */\n\nTPM_RC\nTSS_TPML_TAGGED_PCR_PROPERTY_Marshalu(const TPML_TAGGED_PCR_PROPERTY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_TAGGED_PCR_SELECT_Marshalu(&source->pcrProperty[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 106 - Definition of {ECC} TPML_ECC_CURVE Structure <OUT> */\n\nTPM_RC\nTSS_TPML_ECC_CURVE_Marshalu(const TPML_ECC_CURVE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint32_t i;\n    \n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->count, written, buffer, size);\n    }\n    for (i = 0 ; i < source->count ; i++) {\n\tif (rc == 0) {\n\t    rc = TSS_TPM_ECC_CURVE_Marshalu(&source->eccCurves[i], written, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* Table 107 - Definition of TPMU_CAPABILITIES Union <OUT> */\n\nTPM_RC\nTSS_TPMU_CAPABILITIES_Marshalu(const TPMU_CAPABILITIES *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n      case TPM_CAP_ALGS:\n\tif (rc == 0) {\n\t    rc = TSS_TPML_ALG_PROPERTY_Marshalu(&source->algorithms, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_CAP_HANDLES:\n\tif (rc == 0) {\n\t    rc = TSS_TPML_HANDLE_Marshalu(&source->handles, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_CAP_COMMANDS:\n\tif (rc == 0) {\n\t    rc = TSS_TPML_CCA_Marshalu(&source->command, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_CAP_PP_COMMANDS:\n\tif (rc == 0) {\n\t    rc = TSS_TPML_CC_Marshalu(&source->ppCommands, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_CAP_AUDIT_COMMANDS:\n\tif (rc == 0) {\n\t    rc = TSS_TPML_CC_Marshalu(&source->auditCommands, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_CAP_PCRS:\n\tif (rc == 0) {\n\t    rc = TSS_TPML_PCR_SELECTION_Marshalu(&source->assignedPCR, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_CAP_TPM_PROPERTIES:\n\tif (rc == 0) {\n\t    rc = TSS_TPML_TAGGED_TPM_PROPERTY_Marshalu(&source->tpmProperties, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_CAP_PCR_PROPERTIES:\n\tif (rc == 0) {\n\t    rc = TSS_TPML_TAGGED_PCR_PROPERTY_Marshalu(&source->pcrProperties, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_CAP_ECC_CURVES:\n\tif (rc == 0) {\n\t    rc = TSS_TPML_ECC_CURVE_Marshalu(&source->eccCurves, written, buffer, size);\n\t}\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 108 - Definition of TPMS_CAPABILITY_DATA Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_CAPABILITY_DATA_Marshalu(const TPMS_CAPABILITY_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_CAP_Marshalu(&source->capability, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_CAPABILITIES_Marshalu(&source->data, written, buffer, size, source->capability);\n    }\n    return rc;\n}\n\n/* Table 109 - Definition of TPMS_CLOCK_INFO Structure */\n\nTPM_RC\nTSS_TPMS_CLOCK_INFO_Marshalu(const TPMS_CLOCK_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT64_Marshalu(&source->clock, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->resetCount, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->restartCount, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_YES_NO_Marshalu(&source->safe, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 110 - Definition of TPMS_TIME_INFO Structure */\n\nTPM_RC\nTSS_TPMS_TIME_INFO_Marshalu(const TPMS_TIME_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT64_Marshalu(&source->time, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMS_CLOCK_INFO_Marshalu(&source->clockInfo, written, buffer, size);\n    }\n    return rc;\n}\n    \n/* Table 111 - Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_TIME_ATTEST_INFO_Marshalu(const TPMS_TIME_ATTEST_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_TIME_INFO_Marshalu(&source->time, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64_Marshalu(&source->firmwareVersion, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 112 - Definition of TPMS_CERTIFY_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_CERTIFY_INFO_Marshalu(const TPMS_CERTIFY_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->name, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->qualifiedName, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 113 - Definition of TPMS_QUOTE_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_QUOTE_INFO_Marshalu(const TPMS_QUOTE_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrSelect, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->pcrDigest, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 114 - Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_COMMAND_AUDIT_INFO_Marshalu(const TPMS_COMMAND_AUDIT_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT64_Marshalu(&source->auditCounter, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(&source->digestAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->auditDigest, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->commandDigest, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 115 - Definition of TPMS_SESSION_AUDIT_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_SESSION_AUDIT_INFO_Marshalu(const TPMS_SESSION_AUDIT_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_YES_NO_Marshalu(&source->exclusiveSession, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->sessionDigest, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 116 - Definition of TPMS_CREATION_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_CREATION_INFO_Marshalu(const TPMS_CREATION_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->objectName, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->creationHash, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 117 - Definition of TPMS_NV_CERTIFY_INFO Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_NV_CERTIFY_INFO_Marshalu(const TPMS_NV_CERTIFY_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->indexName, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->offset, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_MAX_NV_BUFFER_Marshalu(&source->nvContents, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 118 - Definition of (TPM_ST) TPMI_ST_ATTEST Type <OUT> */\n\nTPM_RC\nTSS_TPMI_ST_ATTEST_Marshalu(const TPMI_ST_ATTEST *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ST_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 119 - Definition of TPMU_ATTEST Union <OUT> */\n\nTPM_RC\nTSS_TPMU_ATTEST_Marshalu(const TPMU_ATTEST  *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n      case TPM_ST_ATTEST_CERTIFY:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_CERTIFY_INFO_Marshalu(&source->certify, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_ST_ATTEST_CREATION:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_CREATION_INFO_Marshalu(&source->creation, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_ST_ATTEST_QUOTE:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_QUOTE_INFO_Marshalu(&source->quote, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_ST_ATTEST_COMMAND_AUDIT:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_COMMAND_AUDIT_INFO_Marshalu(&source->commandAudit, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_ST_ATTEST_SESSION_AUDIT:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SESSION_AUDIT_INFO_Marshalu(&source->sessionAudit, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_ST_ATTEST_TIME:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_TIME_ATTEST_INFO_Marshalu(&source->time, written, buffer, size);\n\t}\n\tbreak;\n      case TPM_ST_ATTEST_NV:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_NV_CERTIFY_INFO_Marshalu(&source->nv, written, buffer, size);\n\t}\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 120 - Definition of TPMS_ATTEST Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_ATTEST_Marshalu(const TPMS_ATTEST  *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_GENERATED_Marshalu(&source->magic, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ST_ATTEST_Marshalu(&source->type, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->qualifiedSigner, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->extraData, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMS_CLOCK_INFO_Marshalu(&source->clockInfo, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT64_Marshalu(&source->firmwareVersion, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_ATTEST_Marshalu(&source->attested, written, buffer, size,source->type);\n    }\n    return rc;\n}\n\n/* Table 121 - Definition of TPM2B_ATTEST Structure <OUT> */\n\nTPM_RC\nTSS_TPM2B_ATTEST_Marshalu(const TPM2B_ATTEST *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 122 - Definition of TPMS_AUTH_COMMAND Structure <IN> */\n\nTPM_RC\nTSS_TPMS_AUTH_COMMAND_Marshalu(const TPMS_AUTH_COMMAND *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_SH_AUTH_SESSION_Marshalu(&source->sessionHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NONCE_Marshalu(&source->nonce, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMA_SESSION_Marshalu(&source->sessionAttributes, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->hmac, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 124 - Definition of {AES} (TPM_KEY_BITS) TPMI_!ALG.S_KEY_BITS Type */\n\nTPM_RC\nTSS_TPMI_AES_KEY_BITS_Marshalu(const TPMI_AES_KEY_BITS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_KEY_BITS_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 125 - Definition of TPMU_SYM_KEY_BITS Union */\n\nTPM_RC\nTSS_TPMU_SYM_KEY_BITS_Marshalu(const TPMU_SYM_KEY_BITS *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch(selector) {\n#ifdef TPM_ALG_AES\n      case TPM_ALG_AES:\n\tif (rc == 0) {\n\t    rc = TSS_TPMI_AES_KEY_BITS_Marshalu(&source->aes, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM4\n      case TPM_ALG_SM4:\n\tif (rc == 0) {\n\t    rc = TSS_TPMI_SM4_KEY_BITS_Marshalu(&source->sm4, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_CAMELLIA\n      case TPM_ALG_CAMELLIA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMI_CAMELLIA_KEY_BITS_Marshalu(&source->camellia, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_XOR\n      case TPM_ALG_XOR:\n\tif (rc == 0) {\n\t    rc = TSS_TPMI_ALG_HASH_Marshalu(&source->xorr, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\treturn rc;\n    }\n    return rc;\n}\n\n/* Table 126 - Definition of TPMU_SYM_MODE Union */\n\nTPM_RC\nTSS_TPMU_SYM_MODE_Marshalu(const TPMU_SYM_MODE *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n#ifdef TPM_ALG_AES\n      case TPM_ALG_AES:\n\tif (rc == 0) {\n\t    rc = TSS_TPMI_ALG_SYM_MODE_Marshalu(&source->aes, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM4\n      case TPM_ALG_SM4:\n\tif (rc == 0) {\n\t    rc = TSS_TPMI_ALG_SYM_MODE_Marshalu(&source->sm4, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_CAMELLIA\n      case TPM_ALG_CAMELLIA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMI_ALG_SYM_MODE_Marshalu(&source->camellia, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_XOR\n      case TPM_ALG_XOR:\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 128 - Definition of TPMT_SYM_DEF Structure */\n\nTPM_RC\nTSS_TPMT_SYM_DEF_Marshalu(const TPMT_SYM_DEF *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_SYM_Marshalu(&source->algorithm, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_SYM_KEY_BITS_Marshalu(&source->keyBits, written, buffer, size, source->algorithm);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_SYM_MODE_Marshalu(&source->mode, written, buffer, size, source->algorithm);\n    }\n    return rc;\n}\n\n/* Table 129 - Definition of TPMT_SYM_DEF_OBJECT Structure */\n\nTPM_RC\nTSS_TPMT_SYM_DEF_OBJECT_Marshalu(const TPMT_SYM_DEF_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_SYM_OBJECT_Marshalu(&source->algorithm, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_SYM_KEY_BITS_Marshalu(&source->keyBits, written, buffer, size, source->algorithm);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_SYM_MODE_Marshalu(&source->mode, written, buffer, size, source->algorithm);\n    }\n    return rc;\n}\n\n/* Table 130 - Definition of TPM2B_SYM_KEY Structure */\n\nTPM_RC\nTSS_TPM2B_SYM_KEY_Marshalu(const TPM2B_SYM_KEY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 134 - Definition of TPM2B_LABEL Structure */\n\nTPM_RC\nTSS_TPM2B_LABEL_Marshalu(const TPM2B_LABEL *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 139 - Definition of TPMS_DERIVE Structure */\n\nTPM_RC\nTSS_TPMS_DERIVE_Marshalu(const TPMS_DERIVE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_LABEL_Marshalu(&source->label, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_LABEL_Marshalu(&source->context, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 131 - Definition of TPMS_SYMCIPHER_PARMS Structure */\n\nTPM_RC\nTSS_TPMS_SYMCIPHER_PARMS_Marshalu(const TPMS_SYMCIPHER_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->sym, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 132 - Definition of TPM2B_SENSITIVE_DATA Structure */\n\nTPM_RC\nTSS_TPM2B_SENSITIVE_DATA_Marshalu(const TPM2B_SENSITIVE_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 133 - Definition of TPMS_SENSITIVE_CREATE Structure <IN> */\n\nTPM_RC\nTSS_TPMS_SENSITIVE_CREATE_Marshalu(const TPMS_SENSITIVE_CREATE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->userAuth, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_SENSITIVE_DATA_Marshalu(&source->data, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 134 - Definition of TPM2B_SENSITIVE_CREATE Structure <IN, S> */\n\nTPM_RC\nTSS_TPM2B_SENSITIVE_CREATE_Marshalu(const TPM2B_SENSITIVE_CREATE  *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint16_t sizeWritten = 0;\t/* of structure */\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n\t*buffer += sizeof(uint16_t);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMS_SENSITIVE_CREATE_Marshalu(&source->sensitive, &sizeWritten, buffer, size);\n    }\n    if (rc == 0) {\n\t*written += sizeWritten;\n\tif (buffer != NULL) {\n\t    rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size);\t/* backfill 2B size */\n\t}\n\telse {\n\t    *written += sizeof(uint16_t);\n\t}\n    }\n    return rc;\n}\n\n/* Table 135 - Definition of TPMS_SCHEME_HASH Structure */\n\nTPM_RC\nTSS_TPMS_SCHEME_HASH_Marshalu(const TPMS_SCHEME_HASH *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    return rc;\n}\n    \n/* Table 136 - Definition of {ECC} TPMS_SCHEME_ECDAA Structure */\n\nTPM_RC\nTSS_TPMS_SCHEME_ECDAA_Marshalu(const TPMS_SCHEME_ECDAA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->count, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 137 - Definition of (TPM_ALG_ID) TPMI_ALG_KEYEDHASH_SCHEME Type */\n\nTPM_RC\nTSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshalu(const TPMI_ALG_KEYEDHASH_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 138 - Definition of Types for HMAC_SIG_SCHEME */\n\nTPM_RC\nTSS_TPMS_SCHEME_HMAC_Marshalu(const TPMS_SCHEME_HMAC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 139 - Definition of TPMS_SCHEME_XOR Structure */\n\nTPM_RC\nTSS_TPMS_SCHEME_XOR_Marshalu(const TPMS_SCHEME_XOR *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hashAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_KDF_Marshalu(&source->kdf, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 140 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_SCHEME_KEYEDHASH_Marshalu(const TPMU_SCHEME_KEYEDHASH *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n#ifdef TPM_ALG_HMAC\n      case TPM_ALG_HMAC:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SCHEME_HMAC_Marshalu(&source->hmac, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_XOR\n      case TPM_ALG_XOR:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SCHEME_XOR_Marshalu(&source->xorr, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 141 - Definition of TPMT_KEYEDHASH_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_KEYEDHASH_SCHEME_Marshalu(const TPMT_KEYEDHASH_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshalu(&source->scheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_SCHEME_KEYEDHASH_Marshalu(&source->details, written, buffer, size, source->scheme);\n    }\n    return rc;\n}\n\n/* Table 142 - Definition of {RSA} Types for RSA Signature Schemes */\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_RSASSA_Marshalu(const TPMS_SIG_SCHEME_RSASSA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_RSAPSS_Marshalu(const TPMS_SIG_SCHEME_RSAPSS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_ECDSA_Marshalu(const TPMS_SIG_SCHEME_ECDSA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_TPMS_SIG_SCHEME_SM2_Marshalu(const TPMS_SIG_SCHEME_SM2 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshalu(const TPMS_SIG_SCHEME_ECSCHNORR *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 143 - Definition of {ECC} Types for ECC Signature Schemes */\n\nTPM_RC\nTSS_TPMS_SIG_SCHEME_ECDAA_Marshalu(const TPMS_SIG_SCHEME_ECDAA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_ECDAA_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 144 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_SIG_SCHEME_Marshalu(const TPMU_SIG_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n#ifdef TPM_ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_RSASSA_Marshalu(&source->rsassa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_RSAPSS_Marshalu(&source->rsapss, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_ECDSA_Marshalu(&source->ecdsa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_ECDAA_Marshalu(&source->ecdaa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM2\n      case TPM_ALG_SM2:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_SM2_Marshalu(&source->sm2, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshalu(&source->ecSchnorr, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_HMAC\n      case TPM_ALG_HMAC:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SCHEME_HMAC_Marshalu(&source->hmac, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n \n/* Table 145 - Definition of TPMT_SIG_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_SIG_SCHEME_Marshalu(const TPMT_SIG_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_SIG_SCHEME_Marshalu(&source->scheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_SIG_SCHEME_Marshalu(&source->details, written, buffer, size,source->scheme);\n    }\n    return rc;\n}\n\n/* Table 146 - Definition of Types for {RSA} Encryption Schemes */\n\n/* NOTE: Marked as const function in header */\n\nTPM_RC\nTSS_TPMS_ENC_SCHEME_OAEP_Marshalu(const TPMS_ENC_SCHEME_OAEP *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 146 - Definition of Types for {RSA} Encryption Schemes */\n\n/* NOTE: Marked as const function in header */\n\nTPM_RC\nTSS_TPMS_ENC_SCHEME_RSAES_Marshalu(const TPMS_ENC_SCHEME_RSAES *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    source = source;\n    written = written;\n    buffer = buffer;\n    size = size;\n    return 0;\n}\n\n/* Table 147 - Definition of Types for {ECC} ECC Key Exchange */\n\nTPM_RC\nTSS_TPMS_KEY_SCHEME_ECDH_Marshalu(const TPMS_KEY_SCHEME_ECDH *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_TPMS_KEY_SCHEME_ECMQV_Marshalu(const TPMS_KEY_SCHEME_ECMQV *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 148 - Definition of Types for KDF Schemes, hash-based key- or mask-generation functions */\n\nTPM_RC\nTSS_TPMS_SCHEME_MGF1_Marshalu(const TPMS_SCHEME_MGF1 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_TPMS_SCHEME_KDF1_SP800_56A_Marshalu(const TPMS_SCHEME_KDF1_SP800_56A *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_TPMS_SCHEME_KDF2_Marshalu(const TPMS_SCHEME_KDF2 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_TPMS_SCHEME_KDF1_SP800_108_Marshalu(const TPMS_SCHEME_KDF1_SP800_108 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 149 - Definition of TPMU_KDF_SCHEME Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_KDF_SCHEME_Marshalu(const TPMU_KDF_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n#ifdef TPM_ALG_MGF1\n      case TPM_ALG_MGF1:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SCHEME_MGF1_Marshalu(&source->mgf1, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_KDF1_SP800_56A\n      case TPM_ALG_KDF1_SP800_56A:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SCHEME_KDF1_SP800_56A_Marshalu(&source->kdf1_SP800_56a, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_KDF2\n      case TPM_ALG_KDF2:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SCHEME_KDF2_Marshalu(&source->kdf2, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_KDF1_SP800_108\n      case TPM_ALG_KDF1_SP800_108:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SCHEME_KDF1_SP800_108_Marshalu(&source->kdf1_sp800_108, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n/* Table 150 - Definition of TPMT_KDF_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_KDF_SCHEME_Marshalu(const TPMT_KDF_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_KDF_Marshalu(&source->scheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_KDF_SCHEME_Marshalu(&source->details, written, buffer, size, source->scheme);\n    }\n    return rc;\n}\n\n/* Table 152 - Definition of TPMU_ASYM_SCHEME Union */\n\nTPM_RC\nTSS_TPMU_ASYM_SCHEME_Marshalu(const TPMU_ASYM_SCHEME  *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n#ifdef TPM_ALG_ECDH\n      case TPM_ALG_ECDH:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_KEY_SCHEME_ECDH_Marshalu(&source->ecdh, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECMQV\n      case TPM_ALG_ECMQV:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_KEY_SCHEME_ECMQV_Marshalu(&source->ecmqvh, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_RSASSA_Marshalu(&source->rsassa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_RSAPSS_Marshalu(&source->rsapss, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_ECDSA_Marshalu(&source->ecdsa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_ECDAA_Marshalu(&source->ecdaa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM2\n      case TPM_ALG_SM2:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_SM2_Marshalu(&source->sm2, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshalu(&source->ecSchnorr, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAES\n      case TPM_ALG_RSAES:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_ENC_SCHEME_RSAES_Marshalu(&source->rsaes, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_OAEP\n      case TPM_ALG_OAEP:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_ENC_SCHEME_OAEP_Marshalu(&source->oaep, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 154 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_SCHEME Type */\n\nTPM_RC\nTSS_TPMI_ALG_RSA_SCHEME_Marshalu(const TPMI_ALG_RSA_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 155 - Definition of {RSA} TPMT_RSA_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_RSA_SCHEME_Marshalu(const TPMT_RSA_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_RSA_SCHEME_Marshalu(&source->scheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_ASYM_SCHEME_Marshalu(&source->details, written, buffer, size, source->scheme);\n    }\n    return rc;\n}\n\n/* Table 156 - Definition of (TPM_ALG_ID) {RSA} TPMI_ALG_RSA_DECRYPT Type */\n\nTPM_RC\nTSS_TPMI_ALG_RSA_DECRYPT_Marshalu(const TPMI_ALG_RSA_DECRYPT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 157 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */\n\nTPM_RC\nTSS_TPMT_RSA_DECRYPT_Marshalu(const TPMT_RSA_DECRYPT  *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_RSA_DECRYPT_Marshalu(&source->scheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_ASYM_SCHEME_Marshalu(&source->details, written, buffer, size, source->scheme);\n    }\n    return rc;\n}\n\n/* Table 158 - Definition of {RSA} TPM2B_PUBLIC_KEY_RSA Structure */\n\nTPM_RC\nTSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(const TPM2B_PUBLIC_KEY_RSA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 159 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type */\n\nTPM_RC\nTSS_TPMI_RSA_KEY_BITS_Marshalu(const TPMI_RSA_KEY_BITS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_KEY_BITS_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 160 - Definition of {RSA} TPM2B_PRIVATE_KEY_RSA Structure */\n\nTPM_RC\nTSS_TPM2B_PRIVATE_KEY_RSA_Marshalu(const TPM2B_PRIVATE_KEY_RSA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 161 - Definition of {ECC} TPM2B_ECC_PARAMETER Structure */\n\nTPM_RC\nTSS_TPM2B_ECC_PARAMETER_Marshalu(const TPM2B_ECC_PARAMETER *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 162 - Definition of {ECC} TPMS_ECC_POINT Structure */\n\nTPM_RC\nTSS_TPMS_ECC_POINT_Marshalu(const TPMS_ECC_POINT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->x, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->y, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 163 - Definition of {ECC} TPM2B_ECC_POINT Structure */\n\nTPM_RC\nTSS_TPM2B_ECC_POINT_Marshalu(const TPM2B_ECC_POINT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint16_t sizeWritten = 0;\t/* of structure */\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n\t*buffer += sizeof(uint16_t);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMS_ECC_POINT_Marshalu(&source->point, &sizeWritten, buffer, size);\n    }\n    if (rc == 0) {\n\t*written += sizeWritten;\n\tif (buffer != NULL) {\n\t    rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size);\n\t}\n\telse {\n\t    *written += sizeof(uint16_t);\n\t}\n    }\n    return rc;\n}\n\n/* Table 164 - Definition of (TPM_ALG_ID) {ECC} TPMI_ALG_ECC_SCHEME Type */\n\nTPM_RC\nTSS_TPMI_ALG_ECC_SCHEME_Marshalu(const TPMI_ALG_ECC_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 165 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */\n\nTPM_RC\nTSS_TPMI_ECC_CURVE_Marshalu(const TPMI_ECC_CURVE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ECC_CURVE_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 166 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure */\n\nTPM_RC\nTSS_TPMT_ECC_SCHEME_Marshalu(const TPMT_ECC_SCHEME *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_ECC_SCHEME_Marshalu(&source->scheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_ASYM_SCHEME_Marshalu(&source->details, written, buffer, size, source->scheme);\n    }\n    return rc;\n}\n\n/* Table 167 - Definition of {ECC} TPMS_ALGORITHM_DETAIL_ECC Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_ALGORITHM_DETAIL_ECC_Marshalu(const TPMS_ALGORITHM_DETAIL_ECC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ECC_CURVE_Marshalu(&source->curveID, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->keySize, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_KDF_SCHEME_Marshalu(&source->kdf, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_ECC_SCHEME_Marshalu(&source->sign, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->p, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->a, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->b, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->gX, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->gY, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->n, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->h, written, buffer, size);\n    }\n    return rc;\n}\n    \n/* Table 168 - Definition of {RSA} TPMS_SIGNATURE_RSA Structure */\n\nTPM_RC\nTSS_TPMS_SIGNATURE_RSA_Marshalu(const TPMS_SIGNATURE_RSA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hash, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(&source->sig, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 169 - Definition of Types for {RSA} Signature */\n\nTPM_RC\nTSS_TPMS_SIGNATURE_RSASSA_Marshalu(const TPMS_SIGNATURE_RSASSA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SIGNATURE_RSA_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\nTPM_RC\nTSS_TPMS_SIGNATURE_RSAPSS_Marshalu(const TPMS_SIGNATURE_RSAPSS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SIGNATURE_RSA_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 170 - Definition of {ECC} TPMS_SIGNATURE_ECC Structure */\n\nTPM_RC\nTSS_TPMS_SIGNATURE_ECC_Marshalu(const TPMS_SIGNATURE_ECC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->hash, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->signatureR, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->signatureS, written, buffer, size);\n    }\n    return rc;\n}\n    \n/* Table 171 - Definition of Types for {ECC} TPMS_SIGNATURE_ECC */\n\nTPM_RC\nTSS_TPMS_SIGNATURE_ECDSA_Marshalu(const TPMS_SIGNATURE_ECDSA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\t\n\nTPM_RC\nTSS_TPMS_SIGNATURE_ECDAA_Marshalu(const TPMS_SIGNATURE_ECDAA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPMS_SIGNATURE_SM2_Marshalu(const TPMS_SIGNATURE_SM2 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPMS_SIGNATURE_ECSCHNORR_Marshalu(const TPMS_SIGNATURE_ECSCHNORR *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 172 - Definition of TPMU_SIGNATURE Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_SIGNATURE_Marshalu(const TPMU_SIGNATURE *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n#ifdef TPM_ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIGNATURE_RSASSA_Marshalu(&source->rsassa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIGNATURE_RSAPSS_Marshalu(&source->rsapss, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIGNATURE_ECDSA_Marshalu(&source->ecdsa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIGNATURE_ECDSA_Marshalu(&source->ecdaa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM2\n      case TPM_ALG_SM2:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIGNATURE_ECDSA_Marshalu(&source->sm2, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SIGNATURE_ECDSA_Marshalu(&source->ecschnorr, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_HMAC\n      case TPM_ALG_HMAC:\n\tif (rc == 0) {\n\t    rc = TSS_TPMT_HA_Marshalu(&source->hmac, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 173 - Definition of TPMT_SIGNATURE Structure */\n\nTPM_RC\nTSS_TPMT_SIGNATURE_Marshalu(const TPMT_SIGNATURE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_SIG_SCHEME_Marshalu(&source->sigAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_SIGNATURE_Marshalu(&source->signature, written, buffer, size, source->sigAlg);\n    }\n    return rc;\n}\n\n/* Table 175 - Definition of TPM2B_ENCRYPTED_SECRET Structure */\n\nTPM_RC\nTSS_TPM2B_ENCRYPTED_SECRET_Marshalu(const TPM2B_ENCRYPTED_SECRET *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n \n/* Table 176 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */\n\nTPM_RC\nTSS_TPMI_ALG_PUBLIC_Marshalu(const TPMI_ALG_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 177 - Definition of TPMU_PUBLIC_ID Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_PUBLIC_ID_Marshalu(const TPMU_PUBLIC_ID *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n#ifdef TPM_ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_DIGEST_Marshalu(&source->keyedHash, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_DIGEST_Marshalu(&source->sym, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA:\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(&source->rsa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_ECC_POINT_Marshalu(&source->ecc, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n} \n\n/* Table 178 - Definition of TPMS_KEYEDHASH_PARMS Structure */\n\nTPM_RC\nTSS_TPMS_KEYEDHASH_PARMS_Marshalu(const TPMS_KEYEDHASH_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMT_KEYEDHASH_SCHEME_Marshalu(&source->scheme, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 180 - Definition of {RSA} TPMS_RSA_PARMS Structure */\n\nTPM_RC\nTSS_TPMS_RSA_PARMS_Marshalu(const TPMS_RSA_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->symmetric, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_RSA_SCHEME_Marshalu(&source->scheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RSA_KEY_BITS_Marshalu(&source->keyBits, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->exponent, written, buffer, size);\n    }\n    return rc;\n}\n/* Table 181 - Definition of {ECC} TPMS_ECC_PARMS Structure */\n\nTPM_RC\nTSS_TPMS_ECC_PARMS_Marshalu(const TPMS_ECC_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMT_SYM_DEF_OBJECT_Marshalu(&source->symmetric, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_ECC_SCHEME_Marshalu(&source->scheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ECC_CURVE_Marshalu(&source->curveID, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_KDF_SCHEME_Marshalu(&source->kdf, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 182 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_PUBLIC_PARMS_Marshalu(const TPMU_PUBLIC_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector) \n{\n    TPM_RC rc = 0;\n    switch (selector) {\n#ifdef TPM_ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_KEYEDHASH_PARMS_Marshalu(&source->keyedHashDetail, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_SYMCIPHER_PARMS_Marshalu(&source->symDetail, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_RSA_PARMS_Marshalu(&source->rsaDetail, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\tif (rc == 0) {\n\t    rc = TSS_TPMS_ECC_PARMS_Marshalu(&source->eccDetail, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 183 - Definition of TPMT_PUBLIC_PARMS Structure */\n\nTPM_RC\nTSS_TPMT_PUBLIC_PARMS_Marshalu(const TPMT_PUBLIC_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_PUBLIC_Marshalu(&source->type, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_PUBLIC_PARMS_Marshalu(&source->parameters, written, buffer, size, source->type);\n    }\n    return rc;\n}\n\n/* Table 184 - Definition of TPMT_PUBLIC Structure */\n\nTPM_RC\nTSS_TPMT_PUBLIC_Marshalu(const TPMT_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_PUBLIC_Marshalu(&source->type, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->nameAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMA_OBJECT_Marshalu(&source->objectAttributes, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_PUBLIC_PARMS_Marshalu(&source->parameters, written, buffer, size, source->type);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_PUBLIC_ID_Marshalu(&source->unique, written, buffer, size, source->type);\n    }\n    return rc;\n}\n\n/* Table 184 - Definition of TPMT_PUBLIC Structure - special marshaling for derived object template */\n\nTPM_RC\nTSS_TPMT_PUBLIC_D_Marshalu(const TPMT_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_PUBLIC_Marshalu(&source->type, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->nameAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMA_OBJECT_Marshalu(&source->objectAttributes, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_PUBLIC_PARMS_Marshalu(&source->parameters, written, buffer, size, source->type);\n    }\n    /* if derived from a derivation parent, marshal a TPMS_DERIVE structure */             \n    if (rc == 0) {\n\trc = TSS_TPMS_DERIVE_Marshalu(&source->unique.derive, written, buffer, size);\n    }    \n    return rc;\n}\n\n/* Table 185 - Definition of TPM2B_PUBLIC Structure */\n\nTPM_RC\nTSS_TPM2B_PUBLIC_Marshalu(const TPM2B_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint16_t sizeWritten = 0;\t/* of structure */\n    BYTE *sizePtr;\n    \n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n\t*buffer += sizeof(uint16_t);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_PUBLIC_Marshalu(&source->publicArea, &sizeWritten, buffer, size);\n    }\n    if (rc == 0) {\n\t*written += sizeWritten;\n\tif (buffer != NULL) {\n\t    rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size);\n\t}\n\telse {\n\t    *written += sizeof(uint16_t);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM2B_TEMPLATE_Marshalu(const TPM2B_TEMPLATE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 187 - Definition of TPMU_SENSITIVE_COMPOSITE Union <IN/OUT, S> */\n\nTPM_RC\nTSS_TPMU_SENSITIVE_COMPOSITE_Marshalu(const TPMU_SENSITIVE_COMPOSITE *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA:\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_PRIVATE_KEY_RSA_Marshalu(&source->rsa, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_ECC_PARAMETER_Marshalu(&source->ecc, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_SENSITIVE_DATA_Marshalu(&source->bits, written, buffer, size);\n\t}\n\tbreak;\n#endif\n#ifdef TPM_ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\tif (rc == 0) {\n\t    rc = TSS_TPM2B_SYM_KEY_Marshalu(&source->sym, written, buffer, size);\n\t}\n\tbreak;\n#endif\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\n/* Table 188 - Definition of TPMT_SENSITIVE Structure */\n\nTPM_RC\nTSS_TPMT_SENSITIVE_Marshalu(const TPMT_SENSITIVE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_PUBLIC_Marshalu(&source->sensitiveType, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_AUTH_Marshalu(&source->authValue, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->seedValue, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_SENSITIVE_COMPOSITE_Marshalu(&source->sensitive, written, buffer, size, source->sensitiveType);\n    }\n    return rc;\n}\n\n/* Table 189 - Definition of TPM2B_SENSITIVE Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_SENSITIVE_Marshalu(const TPM2B_SENSITIVE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint16_t sizeWritten = 0;\t/* of structure */\n    BYTE *sizePtr;\n    \n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n\t*buffer += sizeof(uint16_t);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMT_SENSITIVE_Marshalu(&source->t.sensitiveArea, &sizeWritten, buffer, size);\n    }\n    if (rc == 0) {\n\t*written += sizeWritten;\n\tif (buffer != NULL) {\n\t    rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size);\n\t}\n\telse {\n\t    *written += sizeof(uint16_t);\n\t}\n    }\n    return rc;\n}\n\n/* Table 191 - Definition of TPM2B_PRIVATE Structure <IN/OUT, S> */\n\nTPM_RC\nTSS_TPM2B_PRIVATE_Marshalu(const TPM2B_PRIVATE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 193 - Definition of TPM2B_ID_OBJECT Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_ID_OBJECT_Marshalu(const TPM2B_ID_OBJECT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 196 - Definition of (UINT32) TPMA_NV Bits */\n\nTPM_RC\nTSS_TPMA_NV_Marshalu(const TPMA_NV *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->val, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 197 - Definition of TPMS_NV_PUBLIC Structure */\n\nTPM_RC\nTSS_TPMS_NV_PUBLIC_Marshalu(const TPMS_NV_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_NV_INDEX_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_ALG_HASH_Marshalu(&source->nameAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMA_NV_Marshalu(&source->attributes, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->authPolicy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->dataSize, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 198 - Definition of TPM2B_NV_PUBLIC Structure */\n\nTPM_RC\nTSS_TPM2B_NV_PUBLIC_Marshalu(const TPM2B_NV_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint16_t sizeWritten = 0;\t/* of structure */\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n \tsizePtr = *buffer;\n\t*buffer += sizeof(uint16_t);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMS_NV_PUBLIC_Marshalu(&source->nvPublic, &sizeWritten, buffer, size);\n    }\n    if (rc == 0) {\n\t*written += sizeWritten;\n\tif (buffer != NULL) {\n\t    rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size);\n\t}\n\telse {\n\t    *written += sizeof(uint16_t);\n\t}\n    }\n    return rc;\n}\n\n/* Table 199 - Definition of TPM2B_CONTEXT_SENSITIVE Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_CONTEXT_SENSITIVE_Marshalu(const TPM2B_CONTEXT_SENSITIVE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 201 - Definition of TPM2B_CONTEXT_DATA Structure <IN/OUT> */\n\nTPM_RC\nTSS_TPM2B_CONTEXT_DATA_Marshalu(const TPM2B_CONTEXT_DATA  *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM2B_Marshalu(&source->b, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 202 - Definition of TPMS_CONTEXT Structure */\n\nTPM_RC\nTSS_TPMS_CONTEXT_Marshalu(const TPMS_CONTEXT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT64_Marshalu(&source->sequence, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_DH_SAVED_Marshalu(&source->savedHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMI_RH_HIERARCHY_Marshalu(&source->hierarchy, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_CONTEXT_DATA_Marshalu(&source->contextBlob, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 204 - Definition of TPMS_CREATION_DATA Structure <OUT> */\n\nTPM_RC\nTSS_TPMS_CREATION_DATA_Marshalu(const TPMS_CREATION_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPML_PCR_SELECTION_Marshalu(&source->pcrSelect, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DIGEST_Marshalu(&source->pcrDigest, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMA_LOCALITY_Marshalu(&source->locality, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_ALG_ID_Marshalu(&source->parentNameAlg, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->parentName, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_NAME_Marshalu(&source->parentQualifiedName, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM2B_DATA_Marshalu(&source->outsideInfo, written, buffer, size);\n    }\n    return rc;\n}\n\n/* Table 205 - Definition of TPM2B_CREATION_DATA Structure <OUT> */\n\nTPM_RC\nTSS_TPM2B_CREATION_DATA_Marshalu(const TPM2B_CREATION_DATA *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint16_t sizeWritten = 0;\t/* of structure */\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n\t*buffer += sizeof(uint16_t);\n    }\n    if (rc == 0) {\n\trc = TSS_TPMS_CREATION_DATA_Marshalu(&source->creationData, &sizeWritten, buffer, size);\n    }\n    if (rc == 0) {\n\t*written += sizeWritten;\n\tif (buffer != NULL) {\n\t    rc = TSS_UINT16_Marshalu(&sizeWritten, written, &sizePtr, size);\n\t}\n\telse {\n\t    *written += sizeof(uint16_t);\n\t}\n    }\n    return rc;\n}\n\n#ifndef TPM_TSS_NODEPRECATED\n\n/* Deprecated functions that use a sized value for the size parameter.  The recommended functions\n   use an unsigned value.\n\n*/\n\nTPM_RC\nTSS_UINT8_Marshal(const UINT8 *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_UINT8_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_INT8_Marshal(const INT8 *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_INT8_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_UINT16_Marshal(const UINT16 *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_UINT16_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_UINT32_Marshal(const UINT32 *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_UINT32_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_INT32_Marshal(const INT32 *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_INT32_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_UINT64_Marshal(const UINT64 *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_UINT64_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Array_Marshal(const BYTE *source, uint16_t sourceSize, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Array_Marshalu(source, sourceSize, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_Marshal(const TPM2B *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_KEY_BITS_Marshal(const TPM_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_KEY_BITS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_GENERATED_Marshal(const TPM_GENERATED *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_GENERATED_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_ALG_ID_Marshal(const TPM_ALG_ID *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_ALG_ID_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_ECC_CURVE_Marshal(const TPM_ECC_CURVE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_ECC_CURVE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_RC_Marshal(const TPM_RC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_RC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_CLOCK_ADJUST_Marshal(const TPM_CLOCK_ADJUST *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_CLOCK_ADJUST_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_EO_Marshal(const TPM_EO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_EO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_ST_Marshal(const TPM_ST *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_ST_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_SU_Marshal(const TPM_ST *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_SU_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_SE_Marshal(const TPM_SE  *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_SE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_CAP_Marshal(const TPM_CAP *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_CAP_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_PT_Marshal(const TPM_PT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_PT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_PT_PCR_Marshal(const TPM_PT_PCR *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_PT_PCR_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_HANDLE_Marshal(const TPM_HANDLE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_HANDLE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMA_ALGORITHM_Marshal(const TPMA_ALGORITHM *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_ALGORITHM_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMA_OBJECT_Marshal(const TPMA_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMA_SESSION_Marshal(const TPMA_SESSION *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_SESSION_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMA_LOCALITY_Marshal(const TPMA_LOCALITY *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_LOCALITY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM_CC_Marshal(const TPM_CC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM_CC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMA_CC_Marshal(const TPMA_CC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_CC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_YES_NO_Marshal(const TPMI_YES_NO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_YES_NO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_DH_OBJECT_Marshal(const TPMI_DH_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_DH_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_DH_PERSISTENT_Marshal(const TPMI_DH_PERSISTENT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_DH_PERSISTENT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_DH_ENTITY_Marshal(const TPMI_DH_ENTITY *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_DH_ENTITY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_DH_PCR_Marshal(const TPMI_DH_PCR  *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_DH_PCR_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_SH_AUTH_SESSION_Marshal(const TPMI_SH_AUTH_SESSION *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_SH_AUTH_SESSION_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_SH_HMAC_Marshal(const TPMI_SH_HMAC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_SH_HMAC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_SH_POLICY_Marshal(const TPMI_SH_POLICY*source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_SH_POLICY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_DH_CONTEXT_Marshal(const TPMI_DH_CONTEXT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_DH_CONTEXT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_HIERARCHY_Marshal(const TPMI_RH_HIERARCHY *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_HIERARCHY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_ENABLES_Marshal(const TPMI_RH_ENABLES *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_ENABLES_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_HIERARCHY_AUTH_Marshal(const TPMI_RH_HIERARCHY_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_HIERARCHY_AUTH_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_PLATFORM_Marshal(const TPMI_RH_PLATFORM *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_PLATFORM_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_ENDORSEMENT_Marshal(const TPMI_RH_ENDORSEMENT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_ENDORSEMENT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_PROVISION_Marshal(const TPMI_RH_PROVISION *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_PROVISION_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_CLEAR_Marshal(const TPMI_RH_CLEAR *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_CLEAR_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_NV_AUTH_Marshal(const TPMI_RH_NV_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_NV_AUTH_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_LOCKOUT_Marshal(const TPMI_RH_LOCKOUT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_LOCKOUT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RH_NV_INDEX_Marshal(const TPMI_RH_NV_INDEX *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RH_NV_INDEX_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_HASH_Marshal(const TPMI_ALG_HASH *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_HASH_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_SYM_Marshal(const TPMI_ALG_SYM *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_SYM_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_SYM_OBJECT_Marshal(const TPMI_ALG_SYM_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_SYM_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_SYM_MODE_Marshal(const TPMI_ALG_SYM_MODE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_SYM_MODE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_KDF_Marshal(const TPMI_ALG_KDF *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_KDF_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_SIG_SCHEME_Marshal(const TPMI_ALG_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_SIG_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ECC_KEY_EXCHANGE_Marshal(const TPMI_ECC_KEY_EXCHANGE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ECC_KEY_EXCHANGE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ST_COMMAND_TAG_Marshal(const TPMI_ST_COMMAND_TAG *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ST_COMMAND_TAG_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_MAC_SCHEME_Marshal(const TPMI_ALG_MAC_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_MAC_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_CIPHER_MODE_Marshal(const TPMI_ALG_CIPHER_MODE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_CIPHER_MODE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_HA_Marshal(const TPMU_HA *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_HA_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMT_HA_Marshal(const TPMT_HA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_HA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_DIGEST_Marshal(const TPM2B_DIGEST *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_DIGEST_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_DATA_Marshal(const TPM2B_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_DATA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_NONCE_Marshal(const TPM2B_NONCE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_NONCE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_AUTH_Marshal(const TPM2B_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_AUTH_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_OPERAND_Marshal(const TPM2B_OPERAND *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_OPERAND_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_EVENT_Marshal(const TPM2B_EVENT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_EVENT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_MAX_BUFFER_Marshal(const TPM2B_MAX_BUFFER *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_MAX_BUFFER_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_MAX_NV_BUFFER_Marshal(const TPM2B_MAX_NV_BUFFER *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_MAX_NV_BUFFER_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_TIMEOUT_Marshal(const TPM2B_TIMEOUT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_TIMEOUT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_IV_Marshal(const TPM2B_IV *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_IV_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_NAME_Marshal(const TPM2B_NAME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_NAME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_PCR_SELECTION_Marshal(const TPMS_PCR_SELECTION *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_PCR_SELECTION_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_TK_CREATION_Marshal(const TPMT_TK_CREATION *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_TK_CREATION_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_TK_VERIFIED_Marshal(const TPMT_TK_VERIFIED *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_TK_VERIFIED_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_TK_AUTH_Marshal(const TPMT_TK_AUTH *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_TK_AUTH_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_TK_HASHCHECK_Marshal(const TPMT_TK_HASHCHECK *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_TK_HASHCHECK_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_ALG_PROPERTY_Marshal(const TPMS_ALG_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ALG_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_TAGGED_PROPERTY_Marshal(const TPMS_TAGGED_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_TAGGED_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_TAGGED_PCR_SELECT_Marshal(const TPMS_TAGGED_PCR_SELECT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_TAGGED_PCR_SELECT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_CC_Marshal(const TPML_CC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_CC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_CCA_Marshal(const TPML_CCA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_CCA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_ALG_Marshal(const TPML_ALG *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_ALG_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_HANDLE_Marshal(const TPML_HANDLE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_HANDLE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_DIGEST_Marshal(const TPML_DIGEST *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_DIGEST_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_DIGEST_VALUES_Marshal(const TPML_DIGEST_VALUES *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_DIGEST_VALUES_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_PCR_SELECTION_Marshal(const TPML_PCR_SELECTION *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_PCR_SELECTION_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_ALG_PROPERTY_Marshal(const TPML_ALG_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_ALG_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_TAGGED_TPM_PROPERTY_Marshal(const TPML_TAGGED_TPM_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_TAGGED_TPM_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_TAGGED_PCR_PROPERTY_Marshal(const TPML_TAGGED_PCR_PROPERTY *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_TAGGED_PCR_PROPERTY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPML_ECC_CURVE_Marshal(const TPML_ECC_CURVE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPML_ECC_CURVE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_CAPABILITIES_Marshal(const TPMU_CAPABILITIES *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_CAPABILITIES_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMS_CAPABILITY_DATA_Marshal(const TPMS_CAPABILITY_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CAPABILITY_DATA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_CLOCK_INFO_Marshal(const TPMS_CLOCK_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CLOCK_INFO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_TIME_INFO_Marshal(const TPMS_TIME_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_TIME_INFO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_TIME_ATTEST_INFO_Marshal(const TPMS_TIME_ATTEST_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_TIME_ATTEST_INFO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_CERTIFY_INFO_Marshal(const TPMS_CERTIFY_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CERTIFY_INFO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_QUOTE_INFO_Marshal(const TPMS_QUOTE_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_QUOTE_INFO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_COMMAND_AUDIT_INFO_Marshal(const TPMS_COMMAND_AUDIT_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_COMMAND_AUDIT_INFO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SESSION_AUDIT_INFO_Marshal(const TPMS_SESSION_AUDIT_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SESSION_AUDIT_INFO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_CREATION_INFO_Marshal(const TPMS_CREATION_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CREATION_INFO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_NV_CERTIFY_INFO_Marshal(const TPMS_NV_CERTIFY_INFO *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_NV_CERTIFY_INFO_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ST_ATTEST_Marshal(const TPMI_ST_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ST_ATTEST_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_ATTEST_Marshal(const TPMU_ATTEST  *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_ATTEST_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMS_ATTEST_Marshal(const TPMS_ATTEST  *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ATTEST_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_ATTEST_Marshal(const TPM2B_ATTEST *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ATTEST_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_AUTH_COMMAND_Marshal(const TPMS_AUTH_COMMAND *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_AUTH_COMMAND_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_AES_KEY_BITS_Marshal(const TPMI_AES_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_AES_KEY_BITS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_SYM_KEY_BITS_Marshal(const TPMU_SYM_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SYM_KEY_BITS_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMU_SYM_MODE_Marshal(const TPMU_SYM_MODE *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SYM_MODE_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMT_SYM_DEF_Marshal(const TPMT_SYM_DEF *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_SYM_DEF_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_SYM_DEF_OBJECT_Marshal(const TPMT_SYM_DEF_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_SYM_DEF_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_SYM_KEY_Marshal(const TPM2B_SYM_KEY *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_SYM_KEY_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_LABEL_Marshal(const TPM2B_LABEL *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_LABEL_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_DERIVE_Marshal(const TPMS_DERIVE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_DERIVE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SYMCIPHER_PARMS_Marshal(const TPMS_SYMCIPHER_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SYMCIPHER_PARMS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_SENSITIVE_DATA_Marshal(const TPM2B_SENSITIVE_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_SENSITIVE_DATA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SENSITIVE_CREATE_Marshal(const TPMS_SENSITIVE_CREATE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SENSITIVE_CREATE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_SENSITIVE_CREATE_Marshal(const TPM2B_SENSITIVE_CREATE  *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_SENSITIVE_CREATE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SCHEME_HASH_Marshal(const TPMS_SCHEME_HASH *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_HASH_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SCHEME_ECDAA_Marshal(const TPMS_SCHEME_ECDAA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_ECDAA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshal(const TPMI_ALG_KEYEDHASH_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_KEYEDHASH_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SCHEME_HMAC_Marshal(const TPMS_SCHEME_HMAC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_HMAC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SCHEME_XOR_Marshal(const TPMS_SCHEME_XOR *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_XOR_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_SCHEME_KEYEDHASH_Marshal(const TPMU_SCHEME_KEYEDHASH *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SCHEME_KEYEDHASH_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMT_KEYEDHASH_SCHEME_Marshal(const TPMT_KEYEDHASH_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_KEYEDHASH_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIG_SCHEME_RSASSA_Marshal(const TPMS_SIG_SCHEME_RSASSA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_RSASSA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIG_SCHEME_RSAPSS_Marshal(const TPMS_SIG_SCHEME_RSAPSS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_RSAPSS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIG_SCHEME_ECDSA_Marshal(const TPMS_SIG_SCHEME_ECDSA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_ECDSA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIG_SCHEME_SM2_Marshal(const TPMS_SIG_SCHEME_SM2 *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_SM2_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshal(const TPMS_SIG_SCHEME_ECSCHNORR *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_ECSCHNORR_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIG_SCHEME_ECDAA_Marshal(const TPMS_SIG_SCHEME_ECDAA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIG_SCHEME_ECDAA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_SIG_SCHEME_Marshal(const TPMU_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SIG_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMT_SIG_SCHEME_Marshal(const TPMT_SIG_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_SIG_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\n\n/* NOTE: Marked as const function in header */\n\nTPM_RC\nTSS_TPMS_ENC_SCHEME_OAEP_Marshal(const TPMS_ENC_SCHEME_OAEP *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ENC_SCHEME_OAEP_Marshalu(source, written, buffer, (uint32_t *)size);\n}\n\n/* NOTE: Marked as const function in header */\n\nTPM_RC\nTSS_TPMS_ENC_SCHEME_RSAES_Marshal(const TPMS_ENC_SCHEME_RSAES *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ENC_SCHEME_RSAES_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_KEY_SCHEME_ECDH_Marshal(const TPMS_KEY_SCHEME_ECDH *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_KEY_SCHEME_ECDH_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_KEY_SCHEME_ECMQV_Marshal(const TPMS_KEY_SCHEME_ECMQV *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_KEY_SCHEME_ECMQV_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SCHEME_MGF1_Marshal(const TPMS_SCHEME_MGF1 *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_MGF1_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SCHEME_KDF1_SP800_56A_Marshal(const TPMS_SCHEME_KDF1_SP800_56A *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_KDF1_SP800_56A_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SCHEME_KDF2_Marshal(const TPMS_SCHEME_KDF2 *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_KDF2_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SCHEME_KDF1_SP800_108_Marshal(const TPMS_SCHEME_KDF1_SP800_108 *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SCHEME_KDF1_SP800_108_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_KDF_SCHEME_Marshal(const TPMU_KDF_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_KDF_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMT_KDF_SCHEME_Marshal(const TPMT_KDF_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_KDF_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_ASYM_SCHEME_Marshal(const TPMU_ASYM_SCHEME  *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_ASYM_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMI_ALG_RSA_SCHEME_Marshal(const TPMI_ALG_RSA_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_RSA_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_RSA_SCHEME_Marshal(const TPMT_RSA_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_RSA_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_RSA_DECRYPT_Marshal(const TPMI_ALG_RSA_DECRYPT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_RSA_DECRYPT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_RSA_DECRYPT_Marshal(const TPMT_RSA_DECRYPT  *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_RSA_DECRYPT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_PUBLIC_KEY_RSA_Marshal(const TPM2B_PUBLIC_KEY_RSA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_PUBLIC_KEY_RSA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_RSA_KEY_BITS_Marshal(const TPMI_RSA_KEY_BITS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_RSA_KEY_BITS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_PRIVATE_KEY_RSA_Marshal(const TPM2B_PRIVATE_KEY_RSA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_PRIVATE_KEY_RSA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_ECC_PARAMETER_Marshal(const TPM2B_ECC_PARAMETER *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ECC_PARAMETER_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_ECC_POINT_Marshal(const TPMS_ECC_POINT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ECC_POINT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_ECC_POINT_Marshal(const TPM2B_ECC_POINT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ECC_POINT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_ECC_SCHEME_Marshal(const TPMI_ALG_ECC_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_ECC_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ECC_CURVE_Marshal(const TPMI_ECC_CURVE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ECC_CURVE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_ECC_SCHEME_Marshal(const TPMT_ECC_SCHEME *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_ECC_SCHEME_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_ALGORITHM_DETAIL_ECC_Marshal(const TPMS_ALGORITHM_DETAIL_ECC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ALGORITHM_DETAIL_ECC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIGNATURE_RSA_Marshal(const TPMS_SIGNATURE_RSA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_RSA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIGNATURE_RSASSA_Marshal(const TPMS_SIGNATURE_RSASSA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_RSASSA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIGNATURE_RSAPSS_Marshal(const TPMS_SIGNATURE_RSAPSS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_RSAPSS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIGNATURE_ECC_Marshal(const TPMS_SIGNATURE_ECC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_ECC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIGNATURE_ECDSA_Marshal(const TPMS_SIGNATURE_ECDSA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_ECDSA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIGNATURE_ECDAA_Marshal(const TPMS_SIGNATURE_ECDAA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_ECDAA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIGNATURE_SM2_Marshal(const TPMS_SIGNATURE_SM2 *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_SM2_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_SIGNATURE_ECSCHNORR_Marshal(const TPMS_SIGNATURE_ECSCHNORR *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_SIGNATURE_ECSCHNORR_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_SIGNATURE_Marshal(const TPMU_SIGNATURE *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SIGNATURE_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMT_SIGNATURE_Marshal(const TPMT_SIGNATURE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_SIGNATURE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_ENCRYPTED_SECRET_Marshal(const TPM2B_ENCRYPTED_SECRET *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ENCRYPTED_SECRET_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMI_ALG_PUBLIC_Marshal(const TPMI_ALG_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMI_ALG_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_PUBLIC_ID_Marshal(const TPMU_PUBLIC_ID *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_PUBLIC_ID_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMS_KEYEDHASH_PARMS_Marshal(const TPMS_KEYEDHASH_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_KEYEDHASH_PARMS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_RSA_PARMS_Marshal(const TPMS_RSA_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_RSA_PARMS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_ECC_PARMS_Marshal(const TPMS_ECC_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_ECC_PARMS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_PUBLIC_PARMS_Marshal(const TPMU_PUBLIC_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_PUBLIC_PARMS_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMT_PUBLIC_PARMS_Marshal(const TPMT_PUBLIC_PARMS *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_PUBLIC_PARMS_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_PUBLIC_Marshal(const TPMT_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMT_PUBLIC_D_Marshal(const TPMT_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_PUBLIC_D_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_PUBLIC_Marshal(const TPM2B_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_TEMPLATE_Marshal(const TPM2B_TEMPLATE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_TEMPLATE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMU_SENSITIVE_COMPOSITE_Marshal(const TPMU_SENSITIVE_COMPOSITE *source, UINT16 *written, BYTE **buffer, INT32 *size, UINT32 selector)\n{\n    return TSS_TPMU_SENSITIVE_COMPOSITE_Marshalu(source, written, buffer, (uint32_t *)size, selector);\n}\nTPM_RC\nTSS_TPMT_SENSITIVE_Marshal(const TPMT_SENSITIVE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMT_SENSITIVE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_SENSITIVE_Marshal(const TPM2B_SENSITIVE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_SENSITIVE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_PRIVATE_Marshal(const TPM2B_PRIVATE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_PRIVATE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_ID_OBJECT_Marshal(const TPM2B_ID_OBJECT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_ID_OBJECT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMA_NV_Marshal(const TPMA_NV *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMA_NV_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_NV_PUBLIC_Marshal(const TPMS_NV_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_NV_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_NV_PUBLIC_Marshal(const TPM2B_NV_PUBLIC *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_NV_PUBLIC_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_CONTEXT_SENSITIVE_Marshal(const TPM2B_CONTEXT_SENSITIVE *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_CONTEXT_SENSITIVE_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_CONTEXT_DATA_Marshal(const TPM2B_CONTEXT_DATA  *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_CONTEXT_DATA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_CONTEXT_Marshal(const TPMS_CONTEXT *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CONTEXT_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPMS_CREATION_DATA_Marshal(const TPMS_CREATION_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPMS_CREATION_DATA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TPM2B_CREATION_DATA_Marshal(const TPM2B_CREATION_DATA *source, UINT16 *written, BYTE **buffer, INT32 *size)\n{\n    return TSS_TPM2B_CREATION_DATA_Marshalu(source, written, buffer, (uint32_t *)size);\n}\n\n\n\nTPM_RC\nTSS_Startup_In_Marshal(const Startup_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Startup_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Shutdown_In_Marshal(const Shutdown_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Shutdown_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_SelfTest_In_Marshal(const SelfTest_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_SelfTest_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_IncrementalSelfTest_In_Marshal(const IncrementalSelfTest_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_IncrementalSelfTest_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_StartAuthSession_In_Marshal(const StartAuthSession_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_StartAuthSession_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyRestart_In_Marshal(const PolicyRestart_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyRestart_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Create_In_Marshal(const Create_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Create_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Load_In_Marshal(const Load_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Load_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_LoadExternal_In_Marshal(const LoadExternal_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_LoadExternal_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ReadPublic_In_Marshal(const ReadPublic_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ReadPublic_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ActivateCredential_In_Marshal(const ActivateCredential_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ActivateCredential_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_MakeCredential_In_Marshal(const MakeCredential_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_MakeCredential_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Unseal_In_Marshal(const Unseal_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Unseal_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ObjectChangeAuth_In_Marshal(const ObjectChangeAuth_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ObjectChangeAuth_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_CreateLoaded_In_Marshal(const CreateLoaded_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_CreateLoaded_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Duplicate_In_Marshal(const Duplicate_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Duplicate_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Rewrap_In_Marshal(const Rewrap_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Rewrap_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Import_In_Marshal(const Import_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Import_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_RSA_Encrypt_In_Marshal(const RSA_Encrypt_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_RSA_Encrypt_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_RSA_Decrypt_In_Marshal(const RSA_Decrypt_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_RSA_Decrypt_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ECDH_KeyGen_In_Marshal(const ECDH_KeyGen_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ECDH_KeyGen_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ECDH_ZGen_In_Marshal(const ECDH_ZGen_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ECDH_ZGen_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ECC_Parameters_In_Marshal(const ECC_Parameters_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ECC_Parameters_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ZGen_2Phase_In_Marshal(const ZGen_2Phase_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ZGen_2Phase_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_EncryptDecrypt_In_Marshal(const EncryptDecrypt_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_EncryptDecrypt_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_EncryptDecrypt2_In_Marshal(const EncryptDecrypt2_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_EncryptDecrypt2_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Hash_In_Marshal(const Hash_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Hash_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_HMAC_In_Marshal(const HMAC_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_HMAC_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetRandom_In_Marshal(const GetRandom_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetRandom_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_StirRandom_In_Marshal(const StirRandom_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_StirRandom_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_HMAC_Start_In_Marshal(const HMAC_Start_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_HMAC_Start_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_HashSequenceStart_In_Marshal(const HashSequenceStart_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_HashSequenceStart_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_SequenceUpdate_In_Marshal(const SequenceUpdate_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_SequenceUpdate_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_SequenceComplete_In_Marshal(const SequenceComplete_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_SequenceComplete_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_EventSequenceComplete_In_Marshal(const EventSequenceComplete_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_EventSequenceComplete_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Certify_In_Marshal(const Certify_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Certify_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_CertifyCreation_In_Marshal(const CertifyCreation_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_CertifyCreation_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Quote_In_Marshal(const Quote_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Quote_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetSessionAuditDigest_In_Marshal(const GetSessionAuditDigest_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetSessionAuditDigest_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetCommandAuditDigest_In_Marshal(const GetCommandAuditDigest_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetCommandAuditDigest_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetTime_In_Marshal(const GetTime_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetTime_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Commit_In_Marshal(const Commit_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Commit_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_EC_Ephemeral_In_Marshal(const EC_Ephemeral_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_EC_Ephemeral_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_VerifySignature_In_Marshal(const VerifySignature_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_VerifySignature_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Sign_In_Marshal(const Sign_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Sign_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_SetCommandCodeAuditStatus_In_Marshal(const SetCommandCodeAuditStatus_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_SetCommandCodeAuditStatus_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_Extend_In_Marshal(const PCR_Extend_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_Extend_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_Event_In_Marshal(const PCR_Event_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_Event_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_Read_In_Marshal(const PCR_Read_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_Read_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_Allocate_In_Marshal(const PCR_Allocate_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_Allocate_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_SetAuthPolicy_In_Marshal(const PCR_SetAuthPolicy_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_SetAuthPolicy_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_SetAuthValue_In_Marshal(const PCR_SetAuthValue_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_SetAuthValue_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_Reset_In_Marshal(const PCR_Reset_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_Reset_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicySigned_In_Marshal(const PolicySigned_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicySigned_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicySecret_In_Marshal(const PolicySecret_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicySecret_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyTicket_In_Marshal(const PolicyTicket_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyTicket_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyOR_In_Marshal(const PolicyOR_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyOR_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyPCR_In_Marshal(const PolicyPCR_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyPCR_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyLocality_In_Marshal(const PolicyLocality_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyLocality_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyNV_In_Marshal(const PolicyNV_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyNV_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyCounterTimer_In_Marshal(const PolicyCounterTimer_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyCounterTimer_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyCommandCode_In_Marshal(const PolicyCommandCode_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyCommandCode_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyPhysicalPresence_In_Marshal(const PolicyPhysicalPresence_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyPhysicalPresence_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyCpHash_In_Marshal(const PolicyCpHash_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyCpHash_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyNameHash_In_Marshal(const PolicyNameHash_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyNameHash_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyDuplicationSelect_In_Marshal(const PolicyDuplicationSelect_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyDuplicationSelect_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyAuthorize_In_Marshal(const PolicyAuthorize_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyAuthorize_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyAuthValue_In_Marshal(const PolicyAuthValue_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyAuthValue_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyPassword_In_Marshal(const PolicyPassword_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyPassword_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyGetDigest_In_Marshal(const PolicyGetDigest_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyGetDigest_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyNvWritten_In_Marshal(const PolicyNvWritten_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyNvWritten_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyTemplate_In_Marshal(const PolicyTemplate_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyTemplate_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyAuthorizeNV_In_Marshal(const PolicyAuthorizeNV_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyAuthorizeNV_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_CreatePrimary_In_Marshal(const CreatePrimary_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_CreatePrimary_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_HierarchyControl_In_Marshal(const HierarchyControl_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_HierarchyControl_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_SetPrimaryPolicy_In_Marshal(const SetPrimaryPolicy_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_SetPrimaryPolicy_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ChangePPS_In_Marshal(const ChangePPS_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ChangePPS_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ChangeEPS_In_Marshal(const ChangeEPS_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ChangeEPS_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Clear_In_Marshal(const Clear_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_Clear_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ClearControl_In_Marshal(const ClearControl_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ClearControl_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_HierarchyChangeAuth_In_Marshal(const HierarchyChangeAuth_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_HierarchyChangeAuth_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_DictionaryAttackLockReset_In_Marshal(const DictionaryAttackLockReset_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_DictionaryAttackLockReset_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_DictionaryAttackParameters_In_Marshal(const DictionaryAttackParameters_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_DictionaryAttackParameters_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PP_Commands_In_Marshal(const PP_Commands_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_PP_Commands_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_SetAlgorithmSet_In_Marshal(const SetAlgorithmSet_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_SetAlgorithmSet_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ContextSave_In_Marshal(const ContextSave_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ContextSave_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ContextLoad_In_Marshal(const ContextLoad_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ContextLoad_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_FlushContext_In_Marshal(const FlushContext_In *source, uint16_t *written, BYTE **buffer, int32_t *size) \n{\n    return TSS_FlushContext_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_EvictControl_In_Marshal(const EvictControl_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_EvictControl_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ClockSet_In_Marshal(const ClockSet_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ClockSet_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ClockRateAdjust_In_Marshal(const ClockRateAdjust_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_ClockRateAdjust_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetCapability_In_Marshal(const GetCapability_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetCapability_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_TestParms_In_Marshal(const TestParms_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_TestParms_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_DefineSpace_In_Marshal(const NV_DefineSpace_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_DefineSpace_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_UndefineSpace_In_Marshal(const NV_UndefineSpace_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_UndefineSpace_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_UndefineSpaceSpecial_In_Marshal(const NV_UndefineSpaceSpecial_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_UndefineSpaceSpecial_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_ReadPublic_In_Marshal(const NV_ReadPublic_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_ReadPublic_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_Write_In_Marshal(const NV_Write_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_Write_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_Increment_In_Marshal(const NV_Increment_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_Increment_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_Extend_In_Marshal(const NV_Extend_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_Extend_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_SetBits_In_Marshal(const NV_SetBits_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_SetBits_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_WriteLock_In_Marshal(const NV_WriteLock_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_WriteLock_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_GlobalWriteLock_In_Marshal(const NV_GlobalWriteLock_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_GlobalWriteLock_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_Read_In_Marshal(const NV_Read_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_Read_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_ReadLock_In_Marshal(const NV_ReadLock_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_ReadLock_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_ChangeAuth_In_Marshal(const NV_ChangeAuth_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_ChangeAuth_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_Certify_In_Marshal(const NV_Certify_In *source, uint16_t *written, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_Certify_In_Marshalu(source, written, buffer, (uint32_t *)size);\n}\n\n\n\nTPM_RC\nTSS_IncrementalSelfTest_Out_Unmarshal(IncrementalSelfTest_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_IncrementalSelfTest_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetTestResult_Out_Unmarshal(GetTestResult_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetTestResult_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_StartAuthSession_Out_Unmarshal(StartAuthSession_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_StartAuthSession_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Create_Out_Unmarshal(Create_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Create_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Load_Out_Unmarshal(Load_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Load_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_LoadExternal_Out_Unmarshal(LoadExternal_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_LoadExternal_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ReadPublic_Out_Unmarshal(ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ReadPublic_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ActivateCredential_Out_Unmarshal(ActivateCredential_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ActivateCredential_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_MakeCredential_Out_Unmarshal(MakeCredential_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_MakeCredential_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Unseal_Out_Unmarshal(Unseal_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Unseal_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ObjectChangeAuth_Out_Unmarshal(ObjectChangeAuth_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ObjectChangeAuth_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_CreateLoaded_Out_Unmarshal(CreateLoaded_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_CreateLoaded_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Duplicate_Out_Unmarshal(Duplicate_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Duplicate_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Rewrap_Out_Unmarshal(Rewrap_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Rewrap_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Import_Out_Unmarshal(Import_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Import_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_RSA_Encrypt_Out_Unmarshal(RSA_Encrypt_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_RSA_Encrypt_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_RSA_Decrypt_Out_Unmarshal(RSA_Decrypt_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_RSA_Decrypt_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ECDH_KeyGen_Out_Unmarshal(ECDH_KeyGen_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ECDH_KeyGen_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ECDH_ZGen_Out_Unmarshal(ECDH_ZGen_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ECDH_ZGen_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ECC_Parameters_Out_Unmarshal(ECC_Parameters_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ECC_Parameters_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ZGen_2Phase_Out_Unmarshal(ZGen_2Phase_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ZGen_2Phase_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_EncryptDecrypt_Out_Unmarshal(EncryptDecrypt_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_EncryptDecrypt_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_EncryptDecrypt2_Out_Unmarshal(EncryptDecrypt2_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_EncryptDecrypt2_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Hash_Out_Unmarshal(Hash_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Hash_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_HMAC_Out_Unmarshal(HMAC_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_HMAC_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetRandom_Out_Unmarshal(GetRandom_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetRandom_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_HMAC_Start_Out_Unmarshal(HMAC_Start_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_HMAC_Start_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_HashSequenceStart_Out_Unmarshal(HashSequenceStart_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_HashSequenceStart_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_SequenceComplete_Out_Unmarshal(SequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_SequenceComplete_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_EventSequenceComplete_Out_Unmarshal(EventSequenceComplete_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_EventSequenceComplete_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Certify_Out_Unmarshal(Certify_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Certify_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_CertifyCreation_Out_Unmarshal(CertifyCreation_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_CertifyCreation_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Quote_Out_Unmarshal(Quote_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Quote_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetSessionAuditDigest_Out_Unmarshal(GetSessionAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetSessionAuditDigest_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetCommandAuditDigest_Out_Unmarshal(GetCommandAuditDigest_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetCommandAuditDigest_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetTime_Out_Unmarshal(GetTime_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetTime_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Commit_Out_Unmarshal(Commit_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Commit_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_EC_Ephemeral_Out_Unmarshal(EC_Ephemeral_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_EC_Ephemeral_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_VerifySignature_Out_Unmarshal(VerifySignature_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_VerifySignature_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_Sign_Out_Unmarshal(Sign_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_Sign_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_Event_Out_Unmarshal(PCR_Event_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_Event_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_Read_Out_Unmarshal(PCR_Read_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_Read_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PCR_Allocate_Out_Unmarshal(PCR_Allocate_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_PCR_Allocate_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicySigned_Out_Unmarshal(PolicySigned_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicySigned_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicySecret_Out_Unmarshal(PolicySecret_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicySecret_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_PolicyGetDigest_Out_Unmarshal(PolicyGetDigest_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_PolicyGetDigest_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_CreatePrimary_Out_Unmarshal(CreatePrimary_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_CreatePrimary_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ContextSave_Out_Unmarshal(ContextSave_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ContextSave_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ContextLoad_Out_Unmarshal(ContextLoad_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ContextLoad_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_ReadClock_Out_Unmarshal(ReadClock_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_ReadClock_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_GetCapability_Out_Unmarshal(GetCapability_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_GetCapability_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_ReadPublic_Out_Unmarshal(NV_ReadPublic_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_ReadPublic_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_Read_Out_Unmarshal(NV_Read_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_Read_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\nTPM_RC\nTSS_NV_Certify_Out_Unmarshal(NV_Certify_Out *target, TPM_ST tag, BYTE **buffer, int32_t *size)\n{\n    return TSS_NV_Certify_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\n\n#endif\t/* TPM_TSS_NODEPRECATED */\n#endif /* TPM 2.0 */\n"
  },
  {
    "path": "ibmtss-ftpm/tssmarshal12.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t TSS Marshal and Unmarshal    \t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: tssmarshal12.c 1285 2018-07-27 18:33:41Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2018.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#ifdef TPM_TPM12\n\n#include <string.h>\n\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/Unmarshal12_fp.h>\n#include <ibmtss/tssmarshal12.h>\n\n/* The marshaling functions are slightly different from the TPM side.  The TPM assumes that all\n   structures are trusted, and so has no error checking.  The TSS side makes no such assumption.\n\n   The prototype pattern is:\n\n   Return:\n\n   An extra return code, TSS_RC_INSUFFICIENT_BUFFER, indicates that the supplied buffer size is too\n   small.  The TPM functions assert.\n\n   'source' is the structure to be marshaled, the same as the TPM functions.\n   'written' is the __additional__ number of bytes written, the value that the TPM returns.\n   'buffer' is the buffer written, the same as the TPM functions.\n   ' size' is the remaining size of the buffer, the same as the TPM functions.\n\n   If 'buffer' is NULL, 'written' is updated but no marshaling is performed.  This is used in a two\n   pass pattern, where the first pass returns the size of the buffer to be malloc'ed.\n\n   If 'size' is NULL, the source is unmarshaled without a size check.  The caller must ensure that\n   the buffer is sufficient, often due to a malloc after the first pass.  */\n\n/*Unmarshal\n  Command parameter marshaling\n*/\n\nTPM_RC\nTSS_ActivateIdentity_In_Marshalu(const ActivateIdentity_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->idKeyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->blobSize, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->blob, source->blobSize, written, buffer, size);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_CreateEndorsementKeyPair_In_Marshalu(const CreateEndorsementKeyPair_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->antiReplay, TPM_NONCE_SIZE, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_KEY_PARMS_Marshalu(&source->keyInfo, written, buffer, size);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_CreateWrapKey_In_Marshalu(const CreateWrapKey_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->parentHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->dataUsageAuth, SHA1_DIGEST_SIZE, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->dataMigrationAuth, SHA1_DIGEST_SIZE, written, buffer, size);\t\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Marshalu(&source->keyInfo, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_Extend_In_Marshalu(const Extend_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->pcrNum, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->inDigest, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_FlushSpecific_In_Marshalu(const FlushSpecific_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->handle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->resourceType, written, buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n\nTPM_RC\nTSS_GetCapability12_In_Marshalu(const GetCapability12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->capArea, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->subCapSize, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->subCap, source->subCapSize, written, buffer, size);\t\n    }\n    return rc;\n}\t\t\t\t\t\t  \n\nTPM_RC\nTSS_LoadKey2_In_Marshalu(const LoadKey2_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->parentHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Marshalu(&source->inKey, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_MakeIdentity_In_Marshalu(const MakeIdentity_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->identityAuth, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->labelPrivCADigest, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Marshalu(&source->idKeyParams, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NV_DefineSpace12_In_Marshalu(const NV_DefineSpace12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_NV_DATA_PUBLIC_Marshalu(&source->pubInfo, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->encAuth, SHA1_DIGEST_SIZE, written, buffer, size);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NV_ReadValueAuth_In_Marshalu(const NV_ReadValueAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->nvIndex , written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->offset, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->dataSize, written, buffer, size);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NV_ReadValue_In_Marshalu(const NV_ReadValue_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->nvIndex , written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->offset, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->dataSize, written, buffer, size);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NV_WriteValue_In_Marshalu(const NV_WriteValue_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->nvIndex , written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->offset, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->dataSize, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->data, source->dataSize, written, buffer, size);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NV_WriteValueAuth_In_Marshalu(const NV_WriteValueAuth_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->nvIndex , written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->offset, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->dataSize, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->data, source->dataSize, written, buffer, size);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_OwnerReadInternalPub_In_Marshalu(const OwnerReadInternalPub_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n \nTPM_RC\nTSS_OwnerSetDisable_In_Marshalu(const OwnerSetDisable_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->disableState, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_OSAP_In_Marshalu(const OSAP_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->entityType, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->entityValue, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->nonceOddOSAP, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n \nTPM_RC\nTSS_PcrRead12_In_Marshalu(const PcrRead12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->pcrIndex, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_PCR_Reset12_In_Marshalu(const PCR_Reset12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n    \trc = TSS_TPM_PCR_SELECTION_Marshalu(&source->pcrSelection, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_Quote2_In_Marshalu(const Quote2_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->externalData, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_PCR_SELECTION_Marshalu(&source->targetPCR, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->addVersion, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_ReadPubek_In_Marshalu(const ReadPubek_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->antiReplay, TPM_NONCE_SIZE, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_Sign12_In_Marshalu(const Sign12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->keyHandle, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->areaToSignSize, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->areaToSign, source->areaToSignSize, written, buffer, size);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_Startup12_In_Marshalu(const Startup12_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_STARTUP_TYPE_Marshalu(&source->startupType, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TakeOwnership_In_Marshalu(const TakeOwnership_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->protocolID, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->encOwnerAuthSize, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->encOwnerAuth, source->encOwnerAuthSize, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->encSrkAuthSize, written, buffer, size);\t\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->encSrkAuth, source->encSrkAuthSize, written, buffer, size);\t\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Marshalu(&source->srkParams, written, buffer, size);\n    }\n    return rc;\n}\n\n/*\n  Response parameter unmarshaling\n*/\n\nTPM_RC\nTSS_ActivateIdentity_Out_Unmarshalu(ActivateIdentity_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_TPM_SYMMETRIC_KEY_Unmarshalu(&target->symmetricKey, buffer, size);\n    } \n    return rc;\n}\n\nTPM_RC\nTSS_CreateEndorsementKeyPair_Out_Unmarshalu(CreateEndorsementKeyPair_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_TPM_PUBKEY_Unmarshalu(&target->pubEndorsementKey, buffer, size);\n    } \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->checksum, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_CreateWrapKey_Out_Unmarshalu(CreateWrapKey_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_TPM_KEY12_Unmarshalu(&target->wrappedKey, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_Extend_Out_Unmarshalu(Extend_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->outDigest, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_GetCapability12_Out_Unmarshalu(GetCapability12_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->respSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->respSize > sizeof(target->resp)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->resp, target->respSize, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_LoadKey2_Out_Unmarshalu(LoadKey2_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->inkeyHandle, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_MakeIdentity_Out_Unmarshalu(MakeIdentity_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Unmarshalu(&target->idKey, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->identityBindingSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->identityBindingSize > sizeof(target->identityBinding)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->identityBinding, target->identityBindingSize, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NV_ReadValueAuth_Out_Unmarshalu(NV_ReadValueAuth_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->dataSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->dataSize > sizeof(target->data)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->data, target->dataSize, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NV_ReadValue_Out_Unmarshalu(NV_ReadValue_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->dataSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->dataSize > sizeof(target->data)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->data, target->dataSize, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_OIAP_Out_Unmarshalu(OIAP_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->authHandle, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->nonceEven, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_OSAP_Out_Unmarshalu(OSAP_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->authHandle, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->nonceEven, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->nonceEvenOSAP, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_OwnerReadInternalPub_Out_Unmarshalu(OwnerReadInternalPub_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_TPM_PUBKEY_Unmarshalu(&target->publicPortion, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_PcrRead12_Out_Unmarshalu(PcrRead12_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->outDigest, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_Quote2_Out_Unmarshalu(Quote2_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n    \trc = TSS_TPM_PCR_INFO_SHORT_Unmarshalu(&target->pcrData, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->versionInfoSize, buffer, size);\n    }\n    if (rc == 0) {\n    \trc = TSS_TPM_CAP_VERSION_INFO_Unmarshalu(&target->versionInfo, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->sigSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->sigSize > sizeof(target->sig)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->sig, target->sigSize, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_Sign12_Out_Unmarshalu(Sign12_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n\trc = TSS_UINT32_Unmarshalu(&target->sigSize, buffer, size);\n    }\n    if (rc == 0) {\n\tif (target->sigSize > sizeof(target->sig)) {\n\t    rc = TPM_RC_SIZE;\n\t}\n    }    \n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->sig, target->sigSize, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_ReadPubek_Out_Unmarshalu(ReadPubek_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n    \trc = TSS_TPM_PUBKEY_Unmarshalu(&target->pubEndorsementKey, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Unmarshalu(target->checksum, SHA1_DIGEST_SIZE, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TakeOwnership_Out_Unmarshalu(TakeOwnership_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    tag = tag;\n    if (rc == 0) {\n    \trc = TSS_TPM_KEY12_Unmarshalu(&target->srkPub, buffer, size);\n    }\n    return rc;\n}\n\n/*\n  Structure marshaling\n*/\n\nTPM_RC\nTSS_TPM_STARTUP_TYPE_Marshalu(const TPM_STARTUP_TYPE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(source, written, buffer, size);\n    }\n    return rc;\n}\n\n/* 5.0 */\n\n\nTPM_RC\nTSS_TPM_VERSION_Marshalu(const TPM_VERSION *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->major, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->minor, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->revMajor, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->revMinor, written, buffer, size);\n    }\n    return rc;\n}\n\n/* 8.0 */\n\nTPM_RC\nTSS_TPM_PCR_SELECTION_Marshalu(const TPM_PCR_SELECTION *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{ \n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->sizeOfSelect, written, buffer, size);   \n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->pcrSelect, source->sizeOfSelect, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_PCR_INFO_LONG_Marshalu(const TPM_PCR_INFO_LONG *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{ \n    TPM_RC rc = 0;\n    if (rc == 0) {\n\tuint16_t tag = TPM_TAG_PCR_INFO_LONG;\n\trc = TSS_UINT16_Marshalu(&tag, written, buffer, size);                      \n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->localityAtCreation, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->localityAtRelease, written, buffer, size);   \n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_SELECTION_Marshalu(&source->creationPCRSelection, written, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_SELECTION_Marshalu(&source->releasePCRSelection, written, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->digestAtCreation, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->digestAtRelease, SHA1_DIGEST_SIZE, written, buffer, size); \n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_PCR_INFO_SHORT_Marshalu(const TPM_PCR_INFO_SHORT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{ \n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_SELECTION_Marshalu(&source->pcrSelection, written, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->localityAtRelease, written, buffer, size);   \n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->digestAtRelease, SHA1_DIGEST_SIZE, written, buffer, size); \n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM4B_TPM_PCR_INFO_LONG_Marshalu(const TPM_PCR_INFO_LONG *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    uint16_t sizeWritten = 0;\t/* of structure */\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n\t*buffer += sizeof(uint32_t);\t/* skip size */\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_INFO_LONG_Marshalu(source, &sizeWritten, buffer, size);\n    }\n    if (rc == 0) {\n\tuint32_t sizeWritten32;\n\t*written += sizeWritten;\n\tsizeWritten32 = sizeWritten;\t/* back fill size */\n\tif (buffer != NULL) {\n\t    rc = TSS_UINT32_Marshalu(&sizeWritten32, written, &sizePtr, size);\n\t}\n\telse {\n\t    *written += sizeof(uint32_t);\n\t}\n    }\n    return rc;\n}\n\n/* 9.0 */\n\nTPM_RC\nTSS_TPM_SYMMETRIC_KEY_Marshalu(const TPM_SYMMETRIC_KEY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->algId, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->encScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->size, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->data, source->size, written, buffer, size);\n    }\n    return rc;\n}\n\n/* 10.0 */\n\nTPM_RC\nTSS_TPM_RSA_KEY_PARMS_Marshalu(const TPM_RSA_KEY_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->keyLength, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->numPrimes, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->exponentSize, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->exponent, source->exponentSize, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPMU_PARMS_Marshalu(const TPMU_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    switch (selector) {\n      case TPM_ALG_RSA:\t\t/* A structure of type TPM_RSA_KEY_PARMS */\n\trc = TSS_TPM_RSA_KEY_PARMS_Marshalu(&source->rsaParms, written, buffer, size);\n\tbreak;\n      case TPM_ALG_AES128:\t/* A structure of type TPM_SYMMETRIC_KEY_PARMS */\n\t/* not implemented yet */\n      default:\n\trc = TPM_RC_SELECTOR;\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM4B_TPMU_PARMS_Marshalu(const TPMU_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size, uint32_t selector)\n{\n    TPM_RC rc = 0;\n    uint16_t sizeWritten = 0;\t/* of structure */\n    BYTE *sizePtr;\n\n    if (buffer != NULL) {\n\tsizePtr = *buffer;\n\t*buffer += sizeof(uint32_t);\t/* skip size */\n    }\n    if (rc == 0) {\n\trc = TSS_TPMU_PARMS_Marshalu(source, &sizeWritten, buffer, size, selector);\n    }\n    if (rc == 0) {\n\tuint32_t sizeWritten32;\n\t*written += sizeWritten;\n\tsizeWritten32 = sizeWritten;\t/* back fill size */\n\tif (buffer != NULL) {\n\t    rc = TSS_UINT32_Marshalu(&sizeWritten32, written, &sizePtr, size);\n\t}\n\telse {\n\t    *written += sizeof(uint32_t);\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_KEY_PARMS_Marshalu(const TPM_KEY_PARMS *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->algorithmID, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->encScheme, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->sigScheme, written, buffer, size); \n    }\n    if (rc == 0) {\n\trc = TSS_TPM4B_TPMU_PARMS_Marshalu(&source->parms, written, buffer, size, source->algorithmID);\t\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_STORE_PUBKEY_Marshalu(const TPM_STORE_PUBKEY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->keyLength, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->key, source->keyLength, written, buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n\nTPM_RC\nTSS_TPM_KEY12_PUBKEY_Marshalu(const TPM_KEY12 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_KEY_PARMS_Marshalu(&source->algorithmParms, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_STORE_PUBKEY_Marshalu(&source->pubKey, written, buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n\nTPM_RC\nTSS_TPM_PUBKEY_Marshalu(const TPM_PUBKEY *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_TPM_KEY_PARMS_Marshalu(&source->algorithmParms, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_STORE_PUBKEY_Marshalu(&source->pubKey, written, buffer, size);\n    }\n    return rc;\n}\t\t\t\t\t\t  \n\nTPM_RC\nTSS_TPM_KEY12_Marshalu(const TPM_KEY12 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\tuint16_t tag = TPM_TAG_KEY12;\n\trc = TSS_UINT16_Marshalu(&tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\tuint16_t fill = 0;\n\trc = TSS_UINT16_Marshalu(&fill, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->keyUsage, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->keyFlags, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->authDataUsage, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_KEY_PARMS_Marshalu(&source->algorithmParms, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM4B_TPM_PCR_INFO_LONG_Marshalu(&source->PCRInfo, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_STORE_PUBKEY_Marshalu(&source->pubKey, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_STORE_PUBKEY_Marshalu(&source->encData, written, buffer, size);\n    }\n    return rc;\n}\n\n/* 11.0 */\n\nTPM_RC\nTSS_TPM_QUOTE_INFO2_Marshalu(const TPM_QUOTE_INFO2 *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\tuint16_t tag = TPM_TAG_QUOTE_INFO2;\n\trc = TSS_UINT16_Marshalu(&tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->fixed, 4, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->externalData, TPM_NONCE_SIZE, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_INFO_SHORT_Marshalu(&source->infoShort, written, buffer, size);\n    }\n    return rc;\n}\n\n/* 12.0 */\n\nTPM_RC\nTSS_TPM_EK_BLOB_Marshalu(const TPM_EK_BLOB *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\tuint16_t tag = TPM_TAG_EK_BLOB;\n\trc = TSS_UINT16_Marshalu(&tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->ekType, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->blobSize, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->blob, source->blobSize, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_EK_BLOB_ACTIVATE_Marshalu(const TPM_EK_BLOB_ACTIVATE *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\tuint16_t tag = TPM_TAG_EK_BLOB_ACTIVATE;\n\trc = TSS_UINT16_Marshalu(&tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_SYMMETRIC_KEY_Marshalu(&source->sessionKey, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->idDigest, SHA1_DIGEST_SIZE, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_INFO_SHORT_Marshalu(&source->pcrInfo, written, buffer, size);\n    }\n    return rc;\n}\n\n/* 19.0 */\n\nTPM_RC\nTSS_TPM_NV_ATTRIBUTES_Marshalu(const TPM_NV_ATTRIBUTES *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0; \n    if (rc == 0) {\n\tuint16_t tag = TPM_TAG_NV_ATTRIBUTES;\n\trc = TSS_UINT16_Marshalu(&tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->attributes, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_TPM_NV_DATA_PUBLIC_Marshalu(const TPM_NV_DATA_PUBLIC *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\tuint16_t tag = TPM_TAG_NV_DATA_PUBLIC;\n\trc = TSS_UINT16_Marshalu(&tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->nvIndex, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_INFO_SHORT_Marshalu(&source->pcrInfoRead, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_PCR_INFO_SHORT_Marshalu(&source->pcrInfoWrite, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_NV_ATTRIBUTES_Marshalu(&source->permission, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->bReadSTClear, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->bWriteSTClear, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->bWriteDefine, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT32_Marshalu(&source->dataSize, written, buffer, size);\n    }\n    return rc;\n}\n\n/* 21.0 */\n\nTPM_RC\nTSS_TPM_CAP_VERSION_INFO_Marshalu(const TPM_CAP_VERSION_INFO *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->tag, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_TPM_VERSION_Marshalu(&source->version, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->specLevel, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT8_Marshalu(&source->errataRev, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->tpmVendorID, 4, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_UINT16_Marshalu(&source->vendorSpecificSize, written, buffer, size);\n    }\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu(source->vendorSpecific, source->vendorSpecificSize, written, buffer, size);\n    }\n    return rc;\n} ;\n\n#endif\t\t/* TPM_TPM12 */\n"
  },
  {
    "path": "ibmtss-ftpm/tssntc.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t     \tTPM2 Nuvoton Proprietary Commands\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: tssntc.c 1285 2018-07-27 18:33:41Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015, 2017\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tssprint.h>\n#include \"tssntc.h\"\n\n/* Marshal and Unmarshal Functions */\n\nTPM_RC\nTSS_NTC2_CFG_STRUCT_Unmarshalu(NTC2_CFG_STRUCT *target, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n\n    /* assumes that the NTC2_CFG_STRUCT structure are all uint8_t so that there are no endian\n       issues */\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_Array_Unmarshalu((BYTE *)target, sizeof(NTC2_CFG_STRUCT), buffer, size);\n    }\n    return rc;\n}\n    \nTPM_RC\nTSS_NTC2_CFG_STRUCT_Marshal(NTC2_CFG_STRUCT *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_Array_Marshalu((BYTE *)source, sizeof(NTC2_CFG_STRUCT), written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NTC2_PreConfig_In_Unmarshalu(NTC2_PreConfig_In *target, BYTE **buffer, uint32_t *size, TPM_HANDLE handles[])\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    handles = handles;\n\n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_NTC2_CFG_STRUCT_Unmarshalu(&target->preConfig, buffer, size);\t\n\tif (rc != TPM_RC_SUCCESS) {\t\n\t    rc += RC_NTC2_PreConfig_preConfig;\n\t}\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NTC2_PreConfig_In_Marshalu(NTC2_PreConfig_In *source, uint16_t *written, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = 0;\n    if (rc == 0) {\n\trc = TSS_NTC2_CFG_STRUCT_Marshal(&source->preConfig, written, buffer, size);\n    }\n    return rc;\n}\n\nTPM_RC\nTSS_NTC2_GetConfig_Out_Unmarshalu(NTC2_GetConfig_Out *target, TPM_ST tag, BYTE **buffer, uint32_t *size)\n{\n    TPM_RC rc = TPM_RC_SUCCESS;\n    tag = tag;\n    \n    if (rc == TPM_RC_SUCCESS) {\n\trc = TSS_NTC2_CFG_STRUCT_Unmarshalu(&target->preConfig, buffer, size);\n    }\n    return rc;\n}\n\n/* These functions are deprecated.  They were adapted from the TPM side, but the signed size\n   caused static analysis tool warnings. */\n    \nTPM_RC\nNTC2_CFG_STRUCT_Unmarshal(NTC2_CFG_STRUCT *target, BYTE **buffer, INT32 *size)\n{\n    return TSS_NTC2_CFG_STRUCT_Unmarshalu(target, buffer, (uint32_t *)size);\n}\nTPM_RC\nNTC2_PreConfig_In_Unmarshal(NTC2_PreConfig_In *target, BYTE **buffer, INT32 *size, TPM_HANDLE handles[])\n{\n    return TSS_NTC2_PreConfig_In_Unmarshalu(target, buffer, (uint32_t *)size, handles);\n}\nTPM_RC\nTSS_NTC2_GetConfig_Out_Unmarshal(NTC2_GetConfig_Out *target, TPM_ST tag, BYTE **buffer, INT32 *size)\n{\n    return TSS_NTC2_GetConfig_Out_Unmarshalu(target, tag, buffer, (uint32_t *)size);\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssprint.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Structure Print and Scan Utilities\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2024.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <inttypes.h>\n\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssutils.h>\n\n#include <ibmtss/tssprint.h>\n\nextern int tssVerbose;\n\n#ifdef TPM_TSS_NO_PRINT\n\n/* false to compile out printf */\nint tssSwallowRc = 0;\n/* function prototype to match the printf prototype */\nint TSS_SwallowPrintf(const char *format, ...)\n{\n    format = format;\n    return 0;\n}\n\n#endif\n\n#ifndef TPM_TSS_NOFILE\n/* TSS_Array_Scan() converts a string to a binary array */\n\nuint32_t TSS_Array_Scan(unsigned char **data,\t/* output binary, freed by caller */\n\t\t\tsize_t *len,\n\t\t\tconst char *string)\t/* input string */\n{\n    uint32_t rc = 0;\n    size_t strLength;\n    \n    if (rc == 0) {\n\tstrLength = strlen(string);\n\tif ((strLength %2) != 0) {\n\t    if (tssVerbose) printf(\"TSS_Array_Scan: Error, string length %lu is not even\\n\",\n\t\t\t\t   (unsigned long)strLength);\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    if (rc == 0) {\n\t*len = strLength / 2;\t\t/* safe because already tested for even number of bytes */\n        rc = TSS_Malloc(data, (uint32_t)(*len) + 8);\n    }\n    if (rc == 0) {\n\tsize_t i;\n\tfor (i = 0 ; i < *len ; i++) {\n\t    unsigned int tmpint;\n\t    int irc = sscanf(string + (2*i), \"%2x\", &tmpint);\n\t    *((*data)+i) = tmpint;\n\t    if (irc != 1) {\n\t\tif (tssVerbose) printf(\"TSS_Array_Scan: invalid hexascii\\n\");\n\t\trc = TSS_RC_BAD_PROPERTY_VALUE;\n\t    }\n\t}\n    }\n    return rc;\n}\n#endif /* TPM_TSS_NOFILE */\n\n/* TSS_PrintAll() prints 'string', the length, and then the entire byte array\n */\n\nvoid TSS_PrintAll(const char *string, const unsigned char* buff, uint32_t length)\n{\n    TSS_PrintAlli(string, 1, buff, length);\n}\n\n/* TSS_PrintAlli() prints 'string', the length, and then the entire byte array\n   \n   Each line indented 'indent' spaces.\n*/\n\nvoid TSS_PrintAlli(const char *string, unsigned int indent, const unsigned char* buff, uint32_t length)\n{\n    TSS_PrintAllLogLevel(LOGLEVEL_DEBUG, string, indent, buff, length);\n}\n\n/* TSS_PrintAllLogLevel() prints based on loglevel the 'string', the length, and then the entire\n   byte array\n\n   loglevel LOGLEVEL_DEBUG prints the length and prints the array with a newline every 16 bytes.\n   otherwise prints no length and prints the array with no newlines.\n\n*/\n\nvoid TSS_PrintAllLogLevel(uint32_t loglevel, const char *string, unsigned int indent,\n\t\t\t  const unsigned char* buff, uint32_t length)\n{\n    uint32_t i;\n    if (buff != NULL) {\n        if (loglevel == LOGLEVEL_DEBUG) {\n\t    printf(\"%*s\" \"%s length %u\\n\" \"%*s\", indent, \"\", string, length, indent, \"\");\n\t}\n        else {\n\t    printf(\"%*s\" \"%s\" \"%*s\", indent, \"\", string, indent, \"\");\n\t}\n        for (i = 0 ; i < length ; i++) {\n            if ((loglevel == LOGLEVEL_DEBUG) && i && !( i % 16 )) {\n                printf(\"\\n\" \"%*s\", indent, \"\");\n\t    }\n            printf(\"%.2x \",buff[i]);\n        }\n\tprintf(\"\\n\");\n    }\n    else {\n        printf(\"%*s\" \"%s null\\n\", indent, \"\", string);\n    }\n    return;\n}\n\n#ifndef TPM_TSS_NO_PRINT\n#ifdef TPM_TPM20\n\nvoid TSS_TPM2B_Print(const char *string, unsigned int indent, TPM2B *source)\n{\n    TSS_PrintAlli(string, indent, source->buffer, source->size);\n    return;\n}\n\n/* Table 9 - Definition of (UINT16) TPM_ALG_ID Constants <IN/OUT, S> */\n\nvoid TSS_TPM_ALG_ID_Print(const char *string, TPM_ALG_ID source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case  ALG_RSA_VALUE:\n\tprintf(\"%s TPM_ALG_RSA\\n\", string);\n\tbreak;\n      case  ALG_TDES_VALUE:\n\tprintf(\"%s TPM_ALG_TDES\\n\", string);\n\tbreak;\n      case  ALG_SHA1_VALUE:\n\tprintf(\"%s TPM_ALG_SHA1\\n\", string);\n\tbreak;\n      case  ALG_HMAC_VALUE:\n\tprintf(\"%s TPM_ALG_HMAC\\n\", string);\n\tbreak;\n      case  ALG_AES_VALUE:\n\tprintf(\"%s TPM_ALG_AES\\n\", string);\n\tbreak;\n      case  ALG_MGF1_VALUE:\n\tprintf(\"%s TPM_ALG_MGF1\\n\", string);\n\tbreak;\n      case  ALG_KEYEDHASH_VALUE:\n\tprintf(\"%s TPM_ALG_KEYEDHASH\\n\", string);\n\tbreak;\n      case  ALG_XOR_VALUE:\n\tprintf(\"%s TPM_ALG_XOR\\n\", string);\n\tbreak;\n      case  ALG_SHA256_VALUE:\n\tprintf(\"%s TPM_ALG_SHA256\\n\", string);\n\tbreak;\n      case  ALG_SHA384_VALUE:\n\tprintf(\"%s TPM_ALG_SHA384\\n\", string);\n\tbreak;\n      case  ALG_SHA512_VALUE:\n\tprintf(\"%s TPM_ALG_SHA512\\n\", string);\n\tbreak;\n      case  ALG_NULL_VALUE:\n\tprintf(\"%s TPM_ALG_NULL\\n\", string);\n\tbreak;\n      case  ALG_SM3_256_VALUE:\n\tprintf(\"%s TPM_ALG_SM3_256\\n\", string);\n\tbreak;\n      case  ALG_SM4_VALUE:\n\tprintf(\"%s TPM_ALG_SM4\\n\", string);\n\tbreak;\n      case  ALG_RSASSA_VALUE:\n\tprintf(\"%s TPM_ALG_RSASSA\\n\", string);\n\tbreak;\n      case  ALG_RSAES_VALUE:\n\tprintf(\"%s TPM_ALG_RSAES\\n\", string);\n\tbreak;\n      case  ALG_RSAPSS_VALUE:\n\tprintf(\"%s TPM_ALG_RSAPSS\\n\", string);\n\tbreak;\n      case  ALG_OAEP_VALUE:\n\tprintf(\"%s TPM_ALG_OAEP\\n\", string);\n\tbreak;\n      case  ALG_ECDSA_VALUE:\n\tprintf(\"%s TPM_ALG_ECDSA\\n\", string);\n\tbreak;\n      case  ALG_ECDH_VALUE:\n\tprintf(\"%s TPM_ALG_ECDH\\n\", string);\n\tbreak;\n      case  ALG_ECDAA_VALUE:\n\tprintf(\"%s TPM_ALG_ECDAA\\n\", string);\n\tbreak;\n      case  ALG_SM2_VALUE:\n\tprintf(\"%s TPM_ALG_SM2\\n\", string);\n\tbreak;\n      case  ALG_ECSCHNORR_VALUE:\n\tprintf(\"%s TPM_ALG_ECSCHNORR\\n\", string);\n\tbreak;\n      case  ALG_ECMQV_VALUE:\n\tprintf(\"%s TPM_ALG_ECMQV\\n\", string);\n\tbreak;\n      case  ALG_KDF1_SP800_56A_VALUE:\n\tprintf(\"%s TPM_ALG_KDF1_SP800_56A\\n\", string);\n\tbreak;\n      case  ALG_KDF2_VALUE:\n\tprintf(\"%s TPM_ALG_KDF2\\n\", string);\n\tbreak;\n      case  ALG_KDF1_SP800_108_VALUE:\n\tprintf(\"%s TPM_ALG_KDF1_SP800_108\\n\", string);\n\tbreak;\n      case  ALG_ECC_VALUE:\n\tprintf(\"%s TPM_ALG_ECC\\n\", string);\n\tbreak;\n      case  ALG_SYMCIPHER_VALUE:\n\tprintf(\"%s TPM_ALG_SYMCIPHER\\n\", string);\n\tbreak;\n      case  ALG_CAMELLIA_VALUE:\n\tprintf(\"%s TPM_ALG_CAMELLIA\\n\", string);\n\tbreak;\n      case ALG_SHA3_256_VALUE:\n\tprintf(\"%s TPM_ALG_SHA3_256\\n\", string);\n\tbreak;\n      case ALG_SHA3_384_VALUE:\n\tprintf(\"%s TPM_ALG_SHA3_384\\n\", string);\n\tbreak;\n      case ALG_SHA3_512_VALUE:\n\tprintf(\"%s TPM_ALG_SHA3_512\\n\", string);\n\tbreak;\n      case ALG_CMAC_VALUE:\n\tprintf(\"%s TPM_ALG_CMAC\\n\", string);\n\tbreak;\n      case  ALG_CTR_VALUE:\n\tprintf(\"%s TPM_ALG_CTR\\n\", string);\n\tbreak;\n      case  ALG_OFB_VALUE:\n\tprintf(\"%s TPM_ALG_OFB\\n\", string);\n\tbreak;\n      case  ALG_CBC_VALUE:\n\tprintf(\"%s TPM_ALG_CBC\\n\", string);\n\tbreak;\n      case  ALG_CFB_VALUE:\n\tprintf(\"%s TPM_ALG_CFB\\n\", string);\n\tbreak;\n      case  ALG_ECB_VALUE:\n\tprintf(\"%s TPM_ALG_ECB\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPM_ALG_ID value %04hx unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 10 - Definition of (UINT16) {ECC} TPM_ECC_CURVE Constants <IN/OUT, S> */\n\nvoid TSS_TPM_ECC_CURVE_Print(const char *string, TPM_ECC_CURVE source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case TPM_ECC_NONE:\n\tprintf(\"%s TPM_ECC_NONE\\n\", string);\n\tbreak;\n      case TPM_ECC_NIST_P192:\n\tprintf(\"%s TPM_ECC_NIST_P192\\n\", string);\n\tbreak;\n      case TPM_ECC_NIST_P224:\n\tprintf(\"%s TPM_ECC_NIST_P224\\n\", string);\n\tbreak;\n      case TPM_ECC_NIST_P256:\n\tprintf(\"%s TPM_ECC_NIST_P256\\n\", string);\n\tbreak;\n      case TPM_ECC_NIST_P384:\n\tprintf(\"%s TPM_ECC_NIST_P384\\n\", string);\n\tbreak;\n      case TPM_ECC_NIST_P521:\n\tprintf(\"%s TPM_ECC_NIST_P521\\n\", string);\n\tbreak;\n      case TPM_ECC_BN_P256:\n\tprintf(\"%s TPM_ECC_BN_P256\\n\", string);\n\tbreak;\n      case TPM_ECC_BN_P638:\n\tprintf(\"%s TPM_ECC_BN_P638\\n\", string);\n\tbreak;\n      case TPM_ECC_SM2_P256:\n\tprintf(\"%s TPM_ECC_SM2_P256\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPM_ECC_CURVE value %04hx unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 100 - Definition of TPMS_TAGGED_POLICY Structure <OUT> */\n\nvoid TSS_TPMS_TAGGED_POLICY_Print(TPMS_TAGGED_POLICY *source, unsigned int indent)\n{\n    TSS_TPM_HANDLE_Print(\"handle\", source->handle, indent);\n    TSS_TPMT_HA_Print(&source->policyHash, indent);\n    return;\n}\n\n/* Table 105 - Definition of TPMS_ACT_DATA Structure <OUT> */\n\nvoid TSS_TPMS_ACT_DATA_Print(TPMS_ACT_DATA *source, unsigned int indent)\n{\n    TSS_TPM_HANDLE_Print(\"handle\", source->handle, indent);\n    printf(\"%*s\" \"TPMS_ACT_DATA timeout %u sec\\n\", indent, \"\", source->timeout);\n    TSS_TPMA_ACT_Print(source->attributes, indent);\n    return;\n}\n\n/* Table 12 - Definition of (UINT32) TPM_CC Constants (Numeric Order) <IN/OUT, S> */\n\nvoid TSS_TPM_CC_Print(const char *string, TPM_CC source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case TPM_CC_NV_UndefineSpaceSpecial:\n\tprintf(\"%s TPM_CC_NV_UndefineSpaceSpecial\\n\", string);\n\tbreak;\n      case TPM_CC_EvictControl:\n\tprintf(\"%s TPM_CC_EvictControl\\n\", string);\n\tbreak;\n      case TPM_CC_HierarchyControl:\n\tprintf(\"%s TPM_CC_HierarchyControl\\n\", string);\n\tbreak;\n      case TPM_CC_NV_UndefineSpace:\n\tprintf(\"%s TPM_CC_NV_UndefineSpace\\n\", string);\n\tbreak;\n      case TPM_CC_ChangeEPS:\n\tprintf(\"%s TPM_CC_ChangeEPS\\n\", string);\n\tbreak;\n      case TPM_CC_ChangePPS:\n\tprintf(\"%s TPM_CC_ChangePPS\\n\", string);\n\tbreak;\n      case TPM_CC_Clear:\n\tprintf(\"%s TPM_CC_Clear\\n\", string);\n\tbreak;\n      case TPM_CC_ClearControl:\n\tprintf(\"%s TPM_CC_ClearControl\\n\", string);\n\tbreak;\n      case TPM_CC_ClockSet:\n\tprintf(\"%s TPM_CC_ClockSet\\n\", string);\n\tbreak;\n      case TPM_CC_HierarchyChangeAuth:\n\tprintf(\"%s TPM_CC_HierarchyChangeAuth\\n\", string);\n\tbreak;\n      case TPM_CC_NV_DefineSpace:\n\tprintf(\"%s TPM_CC_NV_DefineSpace\\n\", string);\n\tbreak;\n      case TPM_CC_PCR_Allocate:\n\tprintf(\"%s TPM_CC_PCR_Allocate\\n\", string);\n\tbreak;\n      case TPM_CC_PCR_SetAuthPolicy:\n\tprintf(\"%s TPM_CC_PCR_SetAuthPolicy\\n\", string);\n\tbreak;\n      case TPM_CC_PP_Commands:\n\tprintf(\"%s TPM_CC_PP_Commands\\n\", string);\n\tbreak;\n      case TPM_CC_SetPrimaryPolicy:\n\tprintf(\"%s TPM_CC_SetPrimaryPolicy\\n\", string);\n\tbreak;\n#if 0\n      case TPM_CC_FieldUpgradeStart:\n\tprintf(\"%s TPM_CC_FieldUpgradeStart\\n\", string);\n\tbreak;\n#endif\n      case TPM_CC_ClockRateAdjust:\n\tprintf(\"%s TPM_CC_ClockRateAdjust\\n\", string);\n\tbreak;\n      case TPM_CC_CreatePrimary:\n\tprintf(\"%s TPM_CC_CreatePrimary\\n\", string);\n\tbreak;\n      case TPM_CC_NV_GlobalWriteLock:\n\tprintf(\"%s TPM_CC_NV_GlobalWriteLock\\n\", string);\n\tbreak;\n      case TPM_CC_GetCommandAuditDigest:\n\tprintf(\"%s TPM_CC_GetCommandAuditDigest\\n\", string);\n\tbreak;\n      case TPM_CC_NV_Increment:\n\tprintf(\"%s TPM_CC_NV_Increment\\n\", string);\n\tbreak;\n      case TPM_CC_NV_SetBits:\n\tprintf(\"%s TPM_CC_NV_SetBits\\n\", string);\n\tbreak;\n      case TPM_CC_NV_Extend:\n\tprintf(\"%s TPM_CC_NV_Extend\\n\", string);\n\tbreak;\n      case TPM_CC_NV_Write:\n\tprintf(\"%s TPM_CC_NV_Write\\n\", string);\n\tbreak;\n      case TPM_CC_NV_WriteLock:\n\tprintf(\"%s TPM_CC_NV_WriteLock\\n\", string);\n\tbreak;\n      case TPM_CC_DictionaryAttackLockReset:\n\tprintf(\"%s TPM_CC_DictionaryAttackLockReset\\n\", string);\n\tbreak;\n      case TPM_CC_DictionaryAttackParameters:\n\tprintf(\"%s TPM_CC_DictionaryAttackParameters\\n\", string);\n\tbreak;\n      case TPM_CC_NV_ChangeAuth:\n\tprintf(\"%s TPM_CC_NV_ChangeAuth\\n\", string);\n\tbreak;\n      case TPM_CC_PCR_Event:\n\tprintf(\"%s TPM_CC_PCR_Event\\n\", string);\n\tbreak;\n      case TPM_CC_PCR_Reset:\n\tprintf(\"%s TPM_CC_PCR_Reset\\n\", string);\n\tbreak;\n      case TPM_CC_SequenceComplete:\n\tprintf(\"%s TPM_CC_SequenceComplete\\n\", string);\n\tbreak;\n      case TPM_CC_SetAlgorithmSet:\n\tprintf(\"%s TPM_CC_SetAlgorithmSet\\n\", string);\n\tbreak;\n      case TPM_CC_SetCommandCodeAuditStatus:\n\tprintf(\"%s TPM_CC_SetCommandCodeAuditStatus\\n\", string);\n\tbreak;\n#if 0\n      case TPM_CC_FieldUpgradeData:\n\tprintf(\"%s TPM_CC_FieldUpgradeData\\n\", string);\n\tbreak;\n#endif\n      case TPM_CC_IncrementalSelfTest:\n\tprintf(\"%s TPM_CC_IncrementalSelfTest\\n\", string);\n\tbreak;\n      case TPM_CC_SelfTest:\n\tprintf(\"%s TPM_CC_SelfTest\\n\", string);\n\tbreak;\n      case TPM_CC_Startup:\n\tprintf(\"%s TPM_CC_Startup\\n\", string);\n\tbreak;\n      case TPM_CC_Shutdown:\n\tprintf(\"%s TPM_CC_Shutdown\\n\", string);\n\tbreak;\n      case TPM_CC_StirRandom:\n\tprintf(\"%s TPM_CC_StirRandom\\n\", string);\n\tbreak;\n      case TPM_CC_ActivateCredential:\n\tprintf(\"%s TPM_CC_ActivateCredential\\n\", string);\n\tbreak;\n      case TPM_CC_Certify:\n\tprintf(\"%s TPM_CC_Certify\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyNV:\n\tprintf(\"%s TPM_CC_PolicyNV\\n\", string);\n\tbreak;\n      case TPM_CC_CertifyCreation:\n\tprintf(\"%s TPM_CC_CertifyCreation\\n\", string);\n\tbreak;\n      case TPM_CC_Duplicate:\n\tprintf(\"%s TPM_CC_Duplicate\\n\", string);\n\tbreak;\n      case TPM_CC_GetTime:\n\tprintf(\"%s TPM_CC_GetTime\\n\", string);\n\tbreak;\n      case TPM_CC_GetSessionAuditDigest:\n\tprintf(\"%s TPM_CC_GetSessionAuditDigest\\n\", string);\n\tbreak;\n      case TPM_CC_NV_Read:\n\tprintf(\"%s TPM_CC_NV_Read\\n\", string);\n\tbreak;\n      case TPM_CC_NV_ReadLock:\n\tprintf(\"%s TPM_CC_NV_ReadLock\\n\", string);\n\tbreak;\n      case TPM_CC_ObjectChangeAuth:\n\tprintf(\"%s TPM_CC_ObjectChangeAuth\\n\", string);\n\tbreak;\n      case TPM_CC_PolicySecret:\n\tprintf(\"%s TPM_CC_PolicySecret\\n\", string);\n\tbreak;\n      case TPM_CC_Rewrap:\n\tprintf(\"%s TPM_CC_Rewrap\\n\", string);\n\tbreak;\n      case TPM_CC_Create:\n\tprintf(\"%s TPM_CC_Create\\n\", string);\n\tbreak;\n      case TPM_CC_ECDH_ZGen:\n\tprintf(\"%s TPM_CC_ECDH_ZGen\\n\", string);\n\tbreak;\n      case TPM_CC_HMAC:\n\tprintf(\"%s TPM_CC_HMAC\\n\", string);\n\tbreak;\n#if 0\n      case TPM_CC_MAC:\n\tprintf(\"%s TPM_CC_MAC\\n\", string);\n\tbreak;\n#endif\n      case TPM_CC_Import:\n\tprintf(\"%s TPM_CC_Import\\n\", string);\n\tbreak;\n      case TPM_CC_Load:\n\tprintf(\"%s TPM_CC_Load\\n\", string);\n\tbreak;\n      case TPM_CC_Quote:\n\tprintf(\"%s TPM_CC_Quote\\n\", string);\n\tbreak;\n      case TPM_CC_RSA_Decrypt:\n\tprintf(\"%s TPM_CC_RSA_Decrypt\\n\", string);\n\tbreak;\n      case TPM_CC_HMAC_Start:\n\tprintf(\"%s TPM_CC_HMAC_Start\\n\", string);\n\tbreak;\n#if 0\n      case TPM_CC_MAC_Start:\n\tprintf(\"%s TPM_CC_MAC_Start\\n\", string);\n\tbreak;\n#endif\n      case TPM_CC_SequenceUpdate:\n\tprintf(\"%s TPM_CC_SequenceUpdate\\n\", string);\n\tbreak;\n      case TPM_CC_Sign:\n\tprintf(\"%s TPM_CC_Sign\\n\", string);\n\tbreak;\n      case TPM_CC_Unseal:\n\tprintf(\"%s TPM_CC_Unseal\\n\", string);\n\tbreak;\n      case TPM_CC_PolicySigned:\n\tprintf(\"%s TPM_CC_PolicySigned\\n\", string);\n\tbreak;\n      case TPM_CC_ContextLoad:\n\tprintf(\"%s TPM_CC_ContextLoad\\n\", string);\n\tbreak;\n      case TPM_CC_ContextSave:\n\tprintf(\"%s TPM_CC_ContextSave\\n\", string);\n\tbreak;\n      case TPM_CC_ECDH_KeyGen:\n\tprintf(\"%s TPM_CC_ECDH_KeyGen\\n\", string);\n\tbreak;\n      case TPM_CC_EncryptDecrypt:\n\tprintf(\"%s TPM_CC_EncryptDecrypt\\n\", string);\n\tbreak;\n      case TPM_CC_FlushContext:\n\tprintf(\"%s TPM_CC_FlushContext\\n\", string);\n\tbreak;\n      case TPM_CC_LoadExternal:\n\tprintf(\"%s TPM_CC_LoadExternal\\n\", string);\n\tbreak;\n      case TPM_CC_MakeCredential:\n\tprintf(\"%s TPM_CC_MakeCredential\\n\", string);\n\tbreak;\n      case TPM_CC_NV_ReadPublic:\n\tprintf(\"%s TPM_CC_NV_ReadPublic\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyAuthorize:\n\tprintf(\"%s TPM_CC_PolicyAuthorize\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyAuthValue:\n\tprintf(\"%s TPM_CC_PolicyAuthValue\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyCommandCode:\n\tprintf(\"%s TPM_CC_PolicyCommandCode\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyCounterTimer:\n\tprintf(\"%s TPM_CC_PolicyCounterTimer\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyCpHash:\n\tprintf(\"%s TPM_CC_PolicyCpHash\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyLocality:\n\tprintf(\"%s TPM_CC_PolicyLocality\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyNameHash:\n\tprintf(\"%s TPM_CC_PolicyNameHash\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyOR:\n\tprintf(\"%s TPM_CC_PolicyOR\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyTicket:\n\tprintf(\"%s TPM_CC_PolicyTicket\\n\", string);\n\tbreak;\n      case TPM_CC_ReadPublic:\n\tprintf(\"%s TPM_CC_ReadPublic\\n\", string);\n\tbreak;\n      case TPM_CC_RSA_Encrypt:\n\tprintf(\"%s TPM_CC_RSA_Encrypt\\n\", string);\n\tbreak;\n      case TPM_CC_StartAuthSession:\n\tprintf(\"%s TPM_CC_StartAuthSession\\n\", string);\n\tbreak;\n      case TPM_CC_VerifySignature:\n\tprintf(\"%s TPM_CC_VerifySignature\\n\", string);\n\tbreak;\n      case TPM_CC_ECC_Parameters:\n\tprintf(\"%s TPM_CC_ECC_Parameters\\n\", string);\n\tbreak;\n      case TPM_CC_ECC_Encrypt:\n\tprintf(\"%s TPM_CC_ECC_Encrypt\\n\", string);\n\tbreak;\n      case TPM_CC_ECC_Decrypt:\n\tprintf(\"%s TPM_CC_ECC_Decrypt\\n\", string);\n\tbreak;\n#if 0\n      case TPM_CC_FirmwareRead:\n\tprintf(\"%s TPM_CC_FirmwareRead\\n\", string);\n\tbreak;\n#endif\n      case TPM_CC_GetCapability:\n\tprintf(\"%s TPM_CC_GetCapability\\n\", string);\n\tbreak;\n      case TPM_CC_GetRandom:\n\tprintf(\"%s TPM_CC_GetRandom\\n\", string);\n\tbreak;\n      case TPM_CC_GetTestResult:\n\tprintf(\"%s TPM_CC_GetTestResult\\n\", string);\n\tbreak;\n      case TPM_CC_Hash:\n\tprintf(\"%s TPM_CC_Hash\\n\", string);\n\tbreak;\n      case TPM_CC_PCR_Read:\n\tprintf(\"%s TPM_CC_PCR_Read\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyPCR:\n\tprintf(\"%s TPM_CC_PolicyPCR\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyRestart:\n\tprintf(\"%s TPM_CC_PolicyRestart\\n\", string);\n\tbreak;\n      case TPM_CC_ReadClock:\n\tprintf(\"%s TPM_CC_ReadClock\\n\", string);\n\tbreak;\n      case TPM_CC_PCR_Extend:\n\tprintf(\"%s TPM_CC_PCR_Extend\\n\", string);\n\tbreak;\n      case TPM_CC_PCR_SetAuthValue:\n\tprintf(\"%s TPM_CC_PCR_SetAuthValue\\n\", string);\n\tbreak;\n      case TPM_CC_NV_Certify:\n\tprintf(\"%s TPM_CC_NV_Certify\\n\", string);\n\tbreak;\n      case TPM_CC_EventSequenceComplete:\n\tprintf(\"%s TPM_CC_EventSequenceComplete\\n\", string);\n\tbreak;\n      case TPM_CC_HashSequenceStart:\n\tprintf(\"%s TPM_CC_HashSequenceStart\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyPhysicalPresence:\n\tprintf(\"%s TPM_CC_PolicyPhysicalPresence\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyDuplicationSelect:\n\tprintf(\"%s TPM_CC_PolicyDuplicationSelect\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyGetDigest:\n\tprintf(\"%s TPM_CC_PolicyGetDigest\\n\", string);\n\tbreak;\n      case TPM_CC_TestParms:\n\tprintf(\"%s TPM_CC_TestParms\\n\", string);\n\tbreak;\n      case TPM_CC_Commit:\n\tprintf(\"%s TPM_CC_Commit\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyPassword:\n\tprintf(\"%s TPM_CC_PolicyPassword\\n\", string);\n\tbreak;\n      case TPM_CC_ZGen_2Phase:\n\tprintf(\"%s TPM_CC_ZGen_2Phase\\n\", string);\n\tbreak;\n      case TPM_CC_EC_Ephemeral:\n\tprintf(\"%s TPM_CC_EC_Ephemeral\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyNvWritten:\n\tprintf(\"%s TPM_CC_PolicyNvWritten\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyTemplate:\n\tprintf(\"%s TPM_CC_PolicyTemplate\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyCapability:\n\tprintf(\"%s TPM_CC_PolicyCapability\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyParameters:\n\tprintf(\"%s TPM_CC_PolicyParameters\\n\", string);\n\tbreak;\n      case TPM_CC_CreateLoaded:\n\tprintf(\"%s TPM_CC_CreateLoaded\\n\", string);\n\tbreak;\n      case TPM_CC_PolicyAuthorizeNV:\n\tprintf(\"%s TPM_CC_PolicyAuthorizeNV\\n\", string);\n\tbreak;\n      case TPM_CC_EncryptDecrypt2:\n\tprintf(\"%s TPM_CC_EncryptDecrypt2\\n\", string);\n\tbreak;\n      case TPM_CC_CertifyX509:\n\tprintf(\"%s TPM_CC_CertifyX509\\n\", string);\n\tbreak;\n#if 0\n      case TPM_CC_AC_GetCapability:\n\tprintf(\"%s TPM_CC_AC_GetCapability\\n\", string);\n\tbreak;\n      case TPM_CC_AC_Send:\n\tprintf(\"%s TPM_CC_AC_Send\\n\", string);\n\tbreak;\n      case TPM_CC_Policy_AC_SendSelect:\n\tprintf(\"%s TPM_CC_Policy_AC_SendSelect\\n\", string);\n\tbreak;\n#endif\n      default:\n\tprintf(\"%s TPM_CC value %08x unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 17 - Definition of (INT8) TPM_CLOCK_ADJUST Constants <IN> */\n\nvoid TSS_TPM_CLOCK_ADJUST_Print(const char *string, TPM_CLOCK_ADJUST source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case TPM_CLOCK_COARSE_SLOWER:\n\tprintf(\"%s TPM_CLOCK_COARSE_SLOWER\\n\", string);\n\tbreak;\n      case TPM_CLOCK_MEDIUM_SLOWER:\n\tprintf(\"%s TPM_CLOCK_MEDIUM_SLOWER\\n\", string);\n\tbreak;\n      case TPM_CLOCK_FINE_SLOWER:\n\tprintf(\"%s TPM_CLOCK_FINE_SLOWER\\n\", string);\n\tbreak;\n      case TPM_CLOCK_NO_CHANGE:\n\tprintf(\"%s TPM_CLOCK_NO_CHANGE\\n\", string);\n\tbreak;\n      case TPM_CLOCK_FINE_FASTER:\n\tprintf(\"%s TPM_CLOCK_FINE_FASTER\\n\", string);\n\tbreak;\n      case TPM_CLOCK_MEDIUM_FASTER:\n\tprintf(\"%s TPM_CLOCK_MEDIUM_FASTER\\n\", string);\n\tbreak;\n      case TPM_CLOCK_COARSE_FASTER:\n\tprintf(\"%s TPM_CLOCK_COARSE_FASTER\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPM_CLOCK_ADJUST value %d unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 18 - Definition of (UINT16) TPM_EO Constants <IN/OUT> */\n\nvoid TSS_TPM_EO_Print(const char *string, TPM_EO source, unsigned int indent) \n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case TPM_EO_EQ:\n\tprintf(\"%s TPM_EO_EQ\\n\", string);\n\tbreak;\n      case TPM_EO_NEQ:\n\tprintf(\"%s TPM_EO_NEQ\\n\", string);\n\tbreak;\n      case TPM_EO_SIGNED_GT:\n\tprintf(\"%s TPM_EO_SIGNED_GT\\n\", string);\n\tbreak;\n      case TPM_EO_UNSIGNED_GT:\n\tprintf(\"%s TPM_EO_UNSIGNED_GT\\n\", string);\n\tbreak;\n      case TPM_EO_SIGNED_LT:\n\tprintf(\"%s TPM_EO_SIGNED_LT\\n\", string);\n\tbreak;\n      case TPM_EO_UNSIGNED_LT:\n\tprintf(\"%s TPM_EO_UNSIGNED_LT\\n\", string);\n\tbreak;\n      case TPM_EO_SIGNED_GE:\n\tprintf(\"%s TPM_EO_SIGNED_GE\\n\", string);\n\tbreak;\n      case TPM_EO_UNSIGNED_GE:\n\tprintf(\"%s TPM_EO_UNSIGNED_GE\\n\", string);\n\tbreak;\n      case TPM_EO_SIGNED_LE:\n\tprintf(\"%s TPM_EO_SIGNED_LE\\n\", string);\n\tbreak;\n      case TPM_EO_UNSIGNED_LE:\n\tprintf(\"%s TPM_EO_UNSIGNED_LE\\n\", string);\n\tbreak;\n      case TPM_EO_BITSET:\n\tprintf(\"%s TPM_EO_BITSET\\n\", string);\n\tbreak;\n      case TPM_EO_BITCLEAR:\n\tprintf(\"%s TPM_EO_BITCLEAR\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPM_EO value %04hx unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 19 - Definition of (UINT16) TPM_ST Constants <IN/OUT, S> */\n\nvoid TSS_TPM_ST_Print(const char *string, TPM_ST source, unsigned int indent) \n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case TPM_ST_RSP_COMMAND:\n\tprintf(\"%s TPM_ST_RSP_COMMAND\\n\", string);\n\tbreak;\n      case TPM_ST_NULL:\n\tprintf(\"%s TPM_ST_NULL\\n\", string);\n\tbreak;\n      case TPM_ST_NO_SESSIONS:\n\tprintf(\"%s TPM_ST_NO_SESSIONS\\n\", string);\n\tbreak;\n      case TPM_ST_SESSIONS:\n\tprintf(\"%s TPM_ST_SESSIONS\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_NV:\n\tprintf(\"%s TPM_ST_ATTEST_NV\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_COMMAND_AUDIT:\n\tprintf(\"%s TPM_ST_ATTEST_COMMAND_AUDIT\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_SESSION_AUDIT:\n\tprintf(\"%s TPM_ST_ATTEST_SESSION_AUDIT\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_CERTIFY:\n\tprintf(\"%s TPM_ST_ATTEST_CERTIFY\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_QUOTE:\n\tprintf(\"%s TPM_ST_ATTEST_QUOTE\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_TIME:\n\tprintf(\"%s TPM_ST_ATTEST_TIME\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_CREATION:\n\tprintf(\"%s TPM_ST_ATTEST_CREATION\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_NV_DIGEST:\n\tprintf(\"%s TPM_ST_ATTEST_NV_DIGEST\\n\", string);\n\tbreak;\n      case TPM_ST_CREATION:\n\tprintf(\"%s TPM_ST_CREATION\\n\", string);\n\tbreak;\n      case TPM_ST_VERIFIED:\n\tprintf(\"%s TPM_ST_VERIFIED\\n\", string);\n\tbreak;\n      case TPM_ST_AUTH_SECRET:\n\tprintf(\"%s TPM_ST_AUTH_SECRET\\n\", string);\n\tbreak;\n      case TPM_ST_HASHCHECK:\n\tprintf(\"%s TPM_ST_HASHCHECK\\n\", string);\n\tbreak;\n      case TPM_ST_AUTH_SIGNED:\n\tprintf(\"%s TPM_ST_AUTH_SIGNED\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPM_ST value %04hx unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 20 - Definition of (UINT16) TPM_SU Constants <IN> */\n\nvoid TSS_TPM_SU_Print(const char *string, TPM_SU source, unsigned int indent) \n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case TPM_SU_CLEAR:\n\tprintf(\"%s TPM_SU_CLEAR\\n\", string);\n\tbreak;\n      case TPM_SU_STATE:\n\tprintf(\"%s TPM_SU_STATE\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPM_SU value %04hx unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 21 - Definition of (UINT8) TPM_SE Constants <IN> */\n\nvoid TSS_TPM_SE_Print(const char *string, TPM_SE source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case TPM_SE_HMAC:\n\tprintf(\"%s TPM_SE_HMAC\\n\", string);\n\tbreak;\n      case TPM_SE_POLICY:\n\tprintf(\"%s TPM_SE_POLICY\\n\", string); \n\tbreak;\n      case TPM_SE_TRIAL:\n\tprintf(\"%s TPM_SE_TRIAL\\n\", string); \n\tbreak;\n      default:\n\tprintf(\"%s TPM_SE value %02x unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 22 - Definition of (UINT32) TPM_CAP Constants */\n\nvoid TSS_TPM_CAP_Print(const char *string, TPM_CAP source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n     case TPM_CAP_ALGS:\n       printf(\"%s TPM_CAP_ALGS\\n\", string);\n\tbreak;\n      case TPM_CAP_HANDLES:\n\tprintf(\"%s TPM_CAP_HANDLES\\n\", string);\n\tbreak;\n      case TPM_CAP_COMMANDS:\n\tprintf(\"%s TPM_CAP_COMMANDS\\n\", string);\n\tbreak;\n      case TPM_CAP_PP_COMMANDS:\n\tprintf(\"%s TPM_CAP_PP_COMMANDS\\n\", string);\n\tbreak;\n      case TPM_CAP_AUDIT_COMMANDS:\n\tprintf(\"%s TPM_CAP_AUDIT_COMMANDS\\n\", string);\n\tbreak;\n      case TPM_CAP_PCRS:\n\tprintf(\"%s TPM_CAP_PCRS\\n\", string);\n\tbreak;\n      case TPM_CAP_TPM_PROPERTIES:\n\tprintf(\"%s TPM_CAP_TPM_PROPERTIES\\n\", string);\n\tbreak;\n      case TPM_CAP_PCR_PROPERTIES:\n\tprintf(\"%s TPM_CAP_PCR_PROPERTIES\\n\", string);\n\tbreak;\n      case TPM_CAP_ECC_CURVES:\n\tprintf(\"%s TPM_CAP_ECC_CURVES\\n\", string);\n\tbreak;\n      case TPM_CAP_AUTH_POLICIES:\n\tprintf(\"%s TPM_CAP_AUTH_POLICIES\\n\", string);\n\tbreak;\n      case TPM_CAP_VENDOR_PROPERTY:\n\tprintf(\"%s TPM_CAP_VENDOR_PROPERTY\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPM_CAP value %08x unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 26 - Definition of Types for Handles */\n\nvoid TSS_TPM_HANDLE_Print(const char *string, TPM_HANDLE source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case TPM_RH_SRK:\n\tprintf(\"%s TPM_RH_SRK\\n\", string);\n\tbreak;\n      case TPM_RH_OWNER:\n\tprintf(\"%s TPM_RH_OWNER\\n\", string);\n\tbreak;\n      case TPM_RH_REVOKE:\n\tprintf(\"%s TPM_RH_REVOKE\\n\", string);\n\tbreak;\n      case TPM_RH_TRANSPORT:\n\tprintf(\"%s TPM_RH_TRANSPORT\\n\", string);\n\tbreak;\n      case TPM_RH_OPERATOR:\n\tprintf(\"%s TPM_RH_OPERATOR\\n\", string);\n\tbreak;\n      case TPM_RH_ADMIN:\n\tprintf(\"%s TPM_RH_ADMIN\\n\", string);\n\tbreak;\n      case TPM_RH_EK:\n\tprintf(\"%s TPM_RH_EK\\n\", string);\n\tbreak;\n      case TPM_RH_NULL:\n\tprintf(\"%s TPM_RH_NULL\\n\", string);\n\tbreak;\n      case TPM_RH_UNASSIGNED:\n\tprintf(\"%s TPM_RH_UNASSIGNED\\n\", string);\n\tbreak;\n      case TPM_RS_PW:\n\tprintf(\"%s TPM_RS_PW\\n\", string);\n\tbreak;\n      case TPM_RH_LOCKOUT:\n\tprintf(\"%s TPM_RH_LOCKOUT\\n\", string);\n\tbreak;\n      case TPM_RH_ENDORSEMENT:\n\tprintf(\"%s TPM_RH_ENDORSEMENT\\n\", string);\n\tbreak;\n      case TPM_RH_PLATFORM:\n\tprintf(\"%s TPM_RH_PLATFORM\\n\", string);\n\tbreak;\n      case TPM_RH_PLATFORM_NV:\n\tprintf(\"%s TPM_RH_PLATFORM_NV\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPM_HANDLE %08x\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 30 - Definition of (UINT32) TPMA_ALGORITHM Bits */\n\nvoid TSS_TPM_TPMA_ALGORITHM_Print(TPMA_ALGORITHM source, unsigned int indent)\n{\n    if (source.val & TPMA_ALGORITHM_ASYMMETRIC) printf(\"%*s\" \"TPMA_ALGORITHM: asymmetric\\n\", indent, \"\");\n    if (source.val & TPMA_ALGORITHM_SYMMETRIC) printf(\"%*s\" \"TPMA_ALGORITHM: symmetric\\n\", indent, \"\");\n    if (source.val & TPMA_ALGORITHM_HASH) printf(\"%*s\" \"TPMA_ALGORITHM: hash\\n\", indent, \"\");\n    if (source.val & TPMA_ALGORITHM_OBJECT) printf(\"%*s\" \"TPMA_ALGORITHM: object\\n\", indent, \"\");\n    if (source.val & TPMA_ALGORITHM_SIGNING) printf(\"%*s\" \"TPMA_ALGORITHM: signing\\n\", indent, \"\");\n    if (source.val & TPMA_ALGORITHM_ENCRYPTING) printf(\"%*s\" \"TPMA_ALGORITHM: encrypting\\n\", indent, \"\");\n    if (source.val & TPMA_ALGORITHM_METHOD) printf(\"%*s\" \"TPMA_ALGORITHM: method\\n\", indent, \"\");\n    return;\n}\n\n/* Table 31 - Definition of (UINT32) TPMA_OBJECT Bits */\n\nvoid TSS_TPMA_OBJECT_Print(const char *string, TPMA_OBJECT source, unsigned int indent)\n{\n    printf(\"%*s%s: %08x\\n\", indent, \"\", string, source.val);\n    if (source.val & TPMA_OBJECT_FIXEDTPM) printf(\"%*s%s: fixedTpm\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_STCLEAR) printf(\"%*s%s: stClear\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_FIXEDPARENT) printf(\"%*s%s: fixedParent\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_SENSITIVEDATAORIGIN) printf(\"%*s%s: sensitiveDataOrigin\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_USERWITHAUTH) printf(\"%*s%s: userWithAuth\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_ADMINWITHPOLICY) printf(\"%*s%s: adminWithPolicy\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_NODA) printf(\"%*s%s: noDA\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_ENCRYPTEDDUPLICATION) printf(\"%*s%s: encryptedDuplication\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_RESTRICTED) printf(\"%*s%s: restricted\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_DECRYPT) printf(\"%*s%s: decrypt\\n\", indent, \"\", string);\n    if (source.val & TPMA_OBJECT_SIGN) printf(\"%*s%s: sign\\n\", indent, \"\", string);\n    return;\n}/* Table 32 - Definition of (UINT8) TPMA_SESSION Bits <IN/OUT> */\n\nvoid TSS_TPMA_SESSION_Print(TPMA_SESSION source, unsigned int indent)\n{\n    \n    if (source.val & TPMA_SESSION_CONTINUESESSION) printf(\"%*s\" \"TPMA_SESSION: continue\\n\", indent, \"\");\n    if (source.val & TPMA_SESSION_AUDITEXCLUSIVE) printf(\"%*s\" \"TPMA_SESSION: auditexclusive\\n\", indent, \"\"); \n    if (source.val & TPMA_SESSION_AUDITRESET) printf(\"%*s\" \"TPMA_SESSION: auditreset\\n\", indent, \"\"); \n    if (source.val & TPMA_SESSION_DECRYPT) printf(\"%*s\" \"TPMA_SESSION: decrypt\\n\", indent, \"\"); \n    if (source.val & TPMA_SESSION_ENCRYPT) printf(\"%*s\" \"TPMA_SESSION: encrypt\\n\", indent, \"\"); \n    if (source.val & TPMA_SESSION_AUDIT) printf(\"%*s\" \"TPMA_SESSION: audit\\n\", indent, \"\"); \n    return;\n}\n\n/* Table 33 - Definition of (UINT8) TPMA_LOCALITY Bits <IN/OUT> */\n\nvoid TSS_TPMA_LOCALITY_Print(TPMA_LOCALITY source, unsigned int indent)\n{\n    if (source.val & TPMA_LOCALITY_ZERO) printf(\"%*s\" \"TPMA_LOCALITY: zero\\n\", indent, \"\");\n    if (source.val & TPMA_LOCALITY_ONE) printf(\"%*s\" \"TPMA_LOCALITY: one\\n\", indent, \"\");\n    if (source.val & TPMA_LOCALITY_TWO) printf(\"%*s\" \"TPMA_LOCALITY: two\\n\", indent, \"\");\n    if (source.val & TPMA_LOCALITY_THREE) printf(\"%*s\" \"TPMA_LOCALITY: three\\n\", indent, \"\");\n    if (source.val & TPMA_LOCALITY_FOUR) printf(\"%*s\" \"TPMA_LOCALITY: four\\n\", indent, \"\");\n    if (source.val & TPMA_LOCALITY_EXTENDED) printf(\"%*s\" \"TPMA_LOCALITY: extended\\n\", indent, \"\");\n    return;\n}\n\n/* Table 34 - Definition of (UINT32) TPMA_PERMANENT Bits <OUT> */\n\nvoid TSS_TPMA_PERMANENT_Print(TPMA_PERMANENT source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMA_PERMANENT: ownerAuthSet %s\\n\", indent, \"\",\n\t   (source.val & TPMA_PERMANENT_OWNERAUTHSET) ? \"yes\" : \"no\"); \n    printf(\"%*s\" \"TPMA_PERMANENT: endorsementAuthSet %s\\n\", indent, \"\",\n\t   (source.val & TPMA_PERMANENT_ENDORSEMENTAUTHSET)  ? \"yes\" : \"no\"); \n    printf(\"%*s\" \"TPMA_PERMANENT: lockoutAuthSet %s\\n\", indent, \"\",\n\t   (source.val & TPMA_PERMANENT_LOCKOUTAUTHSET)  ? \"yes\" : \"no\"); \n    printf(\"%*s\" \"TPMA_PERMANENT: disableClear %s\\n\", indent, \"\",\n\t   (source.val & TPMA_PERMANENT_DISABLECLEAR) ? \"yes\" : \"no\"); \n    printf(\"%*s\" \"TPMA_PERMANENT: inLockout %s\\n\", indent, \"\",\n\t   (source.val & TPMA_PERMANENT_INLOCKOUT) ? \"yes\" : \"no\"); \n    printf(\"%*s\" \"TPMA_PERMANENT: tpmGeneratedEPS %s\\n\", indent, \"\",\n\t   (source.val & TPMA_PERMANENT_TPMGENERATEDEPS)  ? \"yes\" : \"no\"); \n    return;\n}\n\n/* Table 35 - Definition of (UINT32) TPMA_STARTUP_CLEAR Bits <OUT> */\n\nvoid TSS_TPMA_STARTUP_CLEAR_Print(TPMA_STARTUP_CLEAR source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMA_STARTUP_CLEAR: phEnable %s\\n\", indent, \"\",\n\t   (source.val & TPMA_STARTUP_CLEAR_PHENABLE)  ? \"yes\" : \"no\"); \n    printf(\"%*s\" \"TPMA_STARTUP_CLEAR: shEnable %s\\n\", indent, \"\",\n\t   (source.val & TPMA_STARTUP_CLEAR_SHENABLE)  ? \"yes\" : \"no\"); \n    printf(\"%*s\" \"TPMA_STARTUP_CLEAR: ehEnable %s\\n\", indent, \"\",\n\t   (source.val & TPMA_STARTUP_CLEAR_EHENABLE)  ? \"yes\" : \"no\"); \n    printf(\"%*s\" \"TPMA_STARTUP_CLEAR: phEnableNV %s\\n\", indent, \"\",\n\t   (source.val & TPMA_STARTUP_CLEAR_PHENABLENV)  ? \"yes\" : \"no\"); \n    printf(\"%*s\" \"TPMA_STARTUP_CLEAR: orderly %s\\n\", indent, \"\",\n\t   (source.val & TPMA_STARTUP_CLEAR_ORDERLY)  ? \"yes\" : \"no\"); \n    return;\n}\n\n/* Table 36 - Definition of (UINT32) TPMA_MEMORY Bits <Out> */\n\nvoid TSS_TPMA_MEMORY_Print(TPMA_MEMORY source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMA_MEMORY: sharedRAM %s\\n\", indent, \"\",\n\t   (source.val & TPMA_MEMORY_SHAREDRAM) ? \"yes\" : \"no\");\n    printf(\"%*s\" \"TPMA_MEMORY: sharedNV %s\\n\", indent, \"\",\n\t   (source.val & TPMA_MEMORY_SHAREDNV) ? \"yes\" : \"no\");\n    printf(\"%*s\" \"TPMA_MEMORY: objectCopiedToRam %s\\n\", indent, \"\",\n\t   (source.val & TPMA_MEMORY_OBJECTCOPIEDTORAM) ? \"yes\" : \"no\");\n    return;\n}\n\n/* Table 38 - Definition of (UINT32) TPMA_MODES Bits <Out> */\n\nvoid TSS_TPMA_MODES_Print(TPMA_MODES source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMA_MODES: TPMA_MODES_FIPS_140_2 %s\\n\", indent, \"\",\n\t   (source.val & TPMA_MODES_FIPS_140_2) ? \"yes\" : \"no\");\n    return;\n}\n\n/* Table 38 - Definition of (UINT32) TPMA_ACT Bits <Out> */\n\nvoid TSS_TPMA_ACT_Print(TPMA_ACT source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMA_ACT: TPMA_ACT_SIGNALED %s\\n\", indent, \"\",\n\t   (source & TPMA_ACT_SIGNALED) ? \"set\" : \"clear\");\n    printf(\"%*s\" \"TPMA_ACT: TPMA_ACT_PRESERVE_SIGNALED %s\\n\", indent, \"\",\n\t   (source & TPMA_ACT_PRESERVE_SIGNALED) ? \"set\" : \"clear\");\n    return;\n}\n\n/* Table 39 - Definition of (BYTE) TPMI_YES_NO Type */\n\nvoid TSS_TPMI_YES_NO_Print(const char *string, TPMI_YES_NO source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case NO:\n\tprintf(\"%s no\\n\", string);\n\tbreak;\n      case YES:\n\tprintf(\"%s yes\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPMI_YES_NO %02x unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 75 - Definition of TPMU_HA Union <IN/OUT, S> */\n\n\nvoid TSS_TPMU_HA_Print(TPMU_HA *source, uint32_t selector, unsigned int indent)\n{\n    switch (selector) {\n#ifdef TPM_ALG_SHA1\n      case TPM_ALG_SHA1:\n\tTSS_PrintAlli(\"sha1\", indent, source->sha1, SHA1_DIGEST_SIZE);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA256\n      case TPM_ALG_SHA256:\n\tTSS_PrintAlli(\"sha256\", indent, source->sha256, SHA256_DIGEST_SIZE);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA384\n      case TPM_ALG_SHA384:\n\tTSS_PrintAlli(\"sha384\", indent, source->sha384, SHA384_DIGEST_SIZE);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA512\n      case TPM_ALG_SHA512:\n\tTSS_PrintAlli(\"sha512\", indent, source->sha512, SHA512_DIGEST_SIZE);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM3_256\n      case TPM_ALG_SM3_256:\n\tTSS_PrintAlli(\"sm3_256\", indent, source->sm3_256, SM3_256_DIGEST_SIZE);\n\tbreak;\n#endif\n      case TPM_ALG_NULL:\n\tbreak;\n      default:\n\tprintf(\"%*s\" \"TPMU_HA: selection %08x not implemented\\n\", indent, \"\", selector);\n    }\n    return;\n}\n\n/* Table 76 - Definition of TPMT_HA Structure <IN/OUT> */\n\nvoid TSS_TPMT_HA_Print(TPMT_HA *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"hashAlg\", source->hashAlg, indent+2);\t\n    TSS_TPMU_HA_Print(&source->digest, source->hashAlg, indent+2);\n    return;\n}\n\n/* Table 89 - Definition of TPMS_PCR_SELECT Structure */\n\nvoid TSS_TPMS_PCR_SELECT_Print(TPMS_PCR_SELECT *source, unsigned int indent)\n{\n    printf(\"%*s\" \"TSS_TPMS_PCR_SELECT sizeofSelect %u\\n\", indent, \"\", source->sizeofSelect);\n    TSS_PrintAlli(\"pcrSelect\", indent, source->pcrSelect, source->sizeofSelect);\n    return;\n}\n\n/* Table 90 - Definition of TPMS_PCR_SELECTION Structure */\n\nvoid TSS_TPMS_PCR_SELECTION_Print(TPMS_PCR_SELECTION *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"hash\", source->hash, indent+2);\n    TSS_PrintAlli(\"TPMS_PCR_SELECTION\", indent+2,\n\t\t  source->pcrSelect,\n\t\t  source->sizeofSelect);\n    return;\n}\n\n/* Table 93 - Definition of TPMT_TK_CREATION Structure */\n\nvoid TSS_TPMT_TK_CREATION_Print(TPMT_TK_CREATION *source, unsigned int indent)\n{\n    TSS_TPM_ST_Print(\"tag\", source->tag, indent);\n    TSS_TPM_HANDLE_Print(\"hierarchy\", source->hierarchy, indent);\t\n    TSS_TPM2B_Print(\"TPMT_TK_CREATION digest\", indent, &source->digest.b);\n    return;\n}\n\n/* Table 94 - Definition of TPMT_TK_VERIFIED Structure */\n\nvoid TSS_TPMT_TK_VERIFIED_Print(TPMT_TK_VERIFIED *source, unsigned int indent)\n{\n    TSS_TPM_ST_Print(\"tag\", source->tag, indent);\n    TSS_TPM_HANDLE_Print(\"hierarchy\", source->hierarchy, indent);\t\n    TSS_TPM2B_Print(\"TPMT_TK_VERIFIED digest\", indent, &source->digest.b);\n    return;\n}\n\t\n/* Table 95 - Definition of TPMT_TK_AUTH Structure */\n\nvoid TSS_TPMT_TK_AUTH_Print(TPMT_TK_AUTH *source, unsigned int indent)\n{\n    TSS_TPM_ST_Print(\"tag\", source->tag, indent);\n    TSS_TPM_HANDLE_Print(\"hierarchy\", source->hierarchy, indent);\t\n    TSS_TPM2B_Print(\"TPMT_TK_AUTH digest\", indent, &source->digest.b);\n    return;\n}\n\n/* Table 96 - Definition of TPMT_TK_HASHCHECK Structure */\n\nvoid TSS_TPMT_TK_HASHCHECK_Print(TPMT_TK_HASHCHECK *source, unsigned int indent)\n{\n    TSS_TPM_ST_Print(\"tag\", source->tag, indent);\n    TSS_TPM_HANDLE_Print(\"hierarchy\", source->hierarchy, indent);\t\n    TSS_TPM2B_Print(\"TPMT_TK_AUTH digest\", indent, &source->digest.b);\n    return;\n}\n\n/* Table 101 - Definition of TPML_CC Structure */\n\nvoid TSS_TPML_CC_Print(TPML_CC *source, unsigned int indent)\n{\n    uint32_t i;\n    printf(\"%*s\" \"TPML_CC count %u\\n\", indent, \"\", source->count);\n    for (i = 0 ; (i < source->count) ; i++) {\n\tTSS_TPM_CC_Print(\"commandCode\", source->commandCodes[i], indent);\n    }\n    return;\n}\n\n/* Table 102 - Definition of TPML_PCR_SELECTION Structure */\n\nvoid TSS_TPML_PCR_SELECTION_Print(TPML_PCR_SELECTION *source, unsigned int indent)\n{\n    uint32_t i;\n    printf(\"%*s\" \"TPML_PCR_SELECTION count %u\\n\", indent, \"\", source->count);\n    for (i = 0 ; (i < source->count) ; i++) {\n\tTSS_TPMS_PCR_SELECTION_Print(&source->pcrSelections[i], indent);\n    }\n    return;\n}\n\n/* Table 103 - Definition of TPML_ALG Structure */\n\nvoid TSS_TPML_ALG_Print(TPML_ALG *source, unsigned int indent)\n{\n    uint32_t i;\n    printf(\"%*s\" \"TPML_ALG count %u\\n\", indent, \"\", source->count);\n    for (i = 0 ; (i < source->count) ; i++) {\n\tTSS_TPM_ALG_ID_Print(\"algorithms\", source->algorithms[i], indent);\n    }\n    return;\n}\n\n/* Table 105 - Definition of TPML_DIGEST Structure */\n\nvoid TSS_TPML_DIGEST_Print(TPML_DIGEST *source, unsigned int indent)\n{\n    uint32_t i;\n    printf(\"%*s\" \"TPML_DIGEST count %u\\n\", indent, \"\", source->count);\n    for (i = 0 ; (i < source->count) ; i++) {\n\tTSS_TPM2B_Print(\"TPML_DIGEST digest\", indent, &source->digests[i].b);\n    }\n    return;\n}\n\n/* Table 106 - Definition of TPML_DIGEST_VALUES Structure */\n\nvoid TSS_TPML_DIGEST_VALUES_Print(TPML_DIGEST_VALUES *source, unsigned int indent)\n{\n    uint32_t i;\n    printf(\"%*s\" \"TPML_DIGEST_VALUES count %u\\n\", indent, \"\", source->count);\n    for (i = 0 ; (i < source->count) ; i++) {\n\tTSS_TPMT_HA_Print(&source->digests[i], indent);\n    }\n    return;\n}\n\n/* Table 115 - Definition of TPMS_CLOCK_INFO Structure */\n\nvoid TSS_TPMS_CLOCK_INFO_Print(TPMS_CLOCK_INFO *source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMS_CLOCK_INFO clock %\"PRIu64\"\\n\", indent, \"\", source->clock);\n    printf(\"%*s\" \"TPMS_CLOCK_INFO resetCount %u\\n\", indent, \"\", source->resetCount);\n    printf(\"%*s\" \"TPMS_CLOCK_INFO restartCount %u\\n\", indent, \"\", source->restartCount);\n    printf(\"%*s\" \"TPMS_CLOCK_INFO safe %x\\n\", indent, \"\", source->safe);\n    return;\n}\n\n/* Table 116 - Definition of TPMS_TIME_INFO Structure */\n\nvoid TSS_TPMS_TIME_INFO_Print(TPMS_TIME_INFO *source, unsigned int indent)\n{\n    uint64_t days;\n    uint64_t hours;\n    uint64_t minutes;\n    uint64_t seconds;\n    printf(\"%*s\" \"TPMS_TIME_INFO time %\"PRIu64\" msec\", indent, \"\", source->time);\n    days = source->time/(1000 * 60 * 60 * 24);\n    hours = (source->time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);\n    minutes = (source->time % (1000 * 60 * 60)) / (1000 * 60);\n    seconds = (source->time % (1000 * 60)) / (1000);\n    printf(\" - %\"PRIu64\" days %\"PRIu64\" hours %\"PRIu64\" minutes %\"PRIu64\" seconds\\n\",\n\t   days, hours, minutes, seconds);\n    TSS_TPMS_CLOCK_INFO_Print(&source->clockInfo, indent+2);\n    return;\n}\n    \n/* Table 117 - Definition of TPMS_TIME_ATTEST_INFO Structure <OUT> */\n\nvoid TSS_TPMS_TIME_ATTEST_INFO_Print(TPMS_TIME_ATTEST_INFO *source, unsigned int indent)\n{\n    TSS_TPMS_TIME_INFO_Print(&source->time, indent+2);\n    printf(\"%*s\" \"TPMS_TIME_ATTEST_INFO firmwareVersion %\"PRIu64\"\\n\", indent, \"\", source->firmwareVersion);\n    return;\n}\n\n/* Table 118 - Definition of TPMS_CERTIFY_INFO Structure <OUT> */\n\nvoid TSS_TPMS_CERTIFY_INFO_Print(TPMS_CERTIFY_INFO *source, unsigned int indent)\n{\n    TSS_TPM2B_Print(\"TPMS_CERTIFY_INFO name\", indent, &source->name.b);\n    TSS_TPM2B_Print(\"TPMS_CERTIFY_INFO qualifiedName\", indent, &source->qualifiedName.b);\n    return;\n}\n\n/* Table 119 - Definition of TPMS_QUOTE_INFO Structure <OUT> */\n\nvoid TSS_TPMS_QUOTE_INFO_Print(TPMS_QUOTE_INFO *source, unsigned int indent)\n{\n    TSS_TPML_PCR_SELECTION_Print(&source->pcrSelect, indent+2);\n    TSS_TPM2B_Print(\"TPMS_QUOTE_INFO pcrDigest\", indent+2, &source->pcrDigest.b);\n    return;\n}\n\n/* Table 120 - Definition of TPMS_COMMAND_AUDIT_INFO Structure <OUT> */\n\nvoid TSS_TPMS_COMMAND_AUDIT_INFO_Print(TPMS_COMMAND_AUDIT_INFO *source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMS_COMMAND_AUDIT_INFO auditCounter %\"PRIu64\"\\n\", indent, \"\", source->auditCounter);\n    TSS_TPM_ALG_ID_Print(\"digestAlg\", source->digestAlg, indent);\n    TSS_TPM2B_Print(\"TPMS_COMMAND_AUDIT_INFO auditDigest\", indent, &source->auditDigest.b);\n    TSS_TPM2B_Print(\"TPMS_COMMAND_AUDIT_INFO commandDigest\", indent, &source->commandDigest.b);\n    return;\n}\n  \n/* Table 121 - Definition of TPMS_SESSION_AUDIT_INFO Structure */\n\nvoid TSS_TPMS_SESSION_AUDIT_INFO_Print(TPMS_SESSION_AUDIT_INFO *source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMS_SESSION_AUDIT_INFO exclusiveSession %d\\n\", indent, \"\",\n\t   source->exclusiveSession);\n    TSS_TPM2B_Print(\"TPMS_SESSION_AUDIT_INFO sessionDigest\", indent, &source->sessionDigest.b);\n   return;\n}\n\n/* Table 122 - Definition of TPMS_CREATION_INFO Structure <OUT> */\n\nvoid TSS_TPMS_CREATION_INFO_Print(TPMS_CREATION_INFO *source, unsigned int indent)\n{\n    TSS_TPM2B_Print(\"TPMS_CREATION_INFO objectName\", indent, &source->objectName.b);\n    TSS_TPM2B_Print(\"TPMS_CREATION_INFO creationHash\", indent, &source->creationHash.b);\n    return;\n}\n\n/* Table 123 - Definition of TPMS_NV_CERTIFY_INFO Structure */\n\nvoid TSS_TPMS_NV_CERTIFY_INFO_Print(TPMS_NV_CERTIFY_INFO *source, unsigned int indent)\n{\n    TSS_TPM2B_Print(\"TPMS_NV_CERTIFY_INFO indexName\", indent, &source->indexName.b);\n    printf(\"%*s\" \"TPMS_NV_CERTIFY_INFO offset %d\\n\", indent, \"\",  source->offset);\n    TSS_TPM2B_Print(\"TPMS_NV_CERTIFY_INFO nvContents\", indent, &source->nvContents.b);\n    return;\n}\n\n/* Table 125 - Definition of TPMS_NV_DIGEST_CERTIFY_INFO Structure <OUT> */\nvoid TSS_TPMS_NV_DIGEST_CERTIFY_INFO_Print(TPMS_NV_DIGEST_CERTIFY_INFO  *source, unsigned int indent)\n{\n    TSS_TPM2B_Print(\"TPMS_NV_DIGEST_CERTIFY_INFO indexName\", indent, &source->indexName.b);\n    TSS_TPM2B_Print(\"TPMS_NV_DIGEST_CERTIFY_INFO nvDigest\", indent, &source->nvDigest.b);\n    return;\n}\n\n/* Table 124 - Definition of (TPM_ST) TPMI_ST_ATTEST Type <OUT> */\n\nvoid TSS_TPMI_ST_ATTEST_Print(const char *string, TPMI_ST_ATTEST selector, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (selector) {\n      case TPM_ST_ATTEST_CERTIFY:\n\tprintf(\"%s TPM_ST_ATTEST_CERTIFY\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_CREATION:\n\tprintf(\"%s TPM_ST_ATTEST_CREATION\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_QUOTE:\n\tprintf(\"%s TPM_ST_ATTEST_QUOTE\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_COMMAND_AUDIT:\n\tprintf(\"%s TPM_ST_ATTEST_COMMAND_AUDIT\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_SESSION_AUDIT:\n\tprintf(\"%s TPM_ST_ATTEST_SESSION_AUDIT\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_TIME:\n\tprintf(\"%s TPM_ST_ATTEST_TIME\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_NV:\n\tprintf(\"%s TPM_ST_ATTEST_NV\\n\", string);\n\tbreak;\n      case TPM_ST_ATTEST_NV_DIGEST:\n\tprintf(\"%s TPM_ST_ATTEST_NV_DIGEST\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPMI_ST_ATTEST_Print: selection %04hx not implemented\\n\", string, selector);\n    }\n    return;\n}\n\n/* Table 125 - Definition of TPMU_ATTEST Union <OUT> */\n\nvoid TSS_TPMU_ATTEST_Print(TPMU_ATTEST *source, TPMI_ST_ATTEST selector, unsigned int indent)\n{\n    switch (selector) {\n      case TPM_ST_ATTEST_CERTIFY:\n\tTSS_TPMS_CERTIFY_INFO_Print(&source->certify, indent+2);\n\tbreak;\n      case TPM_ST_ATTEST_CREATION:\n\tTSS_TPMS_CREATION_INFO_Print(&source->creation, indent+2);\n\tbreak;\n      case TPM_ST_ATTEST_QUOTE:\n\tTSS_TPMS_QUOTE_INFO_Print(&source->quote, indent+2);\n\tbreak;\n      case TPM_ST_ATTEST_COMMAND_AUDIT:\n\tTSS_TPMS_COMMAND_AUDIT_INFO_Print(&source->commandAudit, indent+2);\n\tbreak;\n      case TPM_ST_ATTEST_SESSION_AUDIT:\n\tTSS_TPMS_SESSION_AUDIT_INFO_Print(&source->sessionAudit, indent+2);\n\tbreak;\n      case TPM_ST_ATTEST_TIME:\n\tTSS_TPMS_TIME_ATTEST_INFO_Print(&source->time, indent+2);\n\tbreak;\n      case TPM_ST_ATTEST_NV:\n\tTSS_TPMS_NV_CERTIFY_INFO_Print(&source->nv, indent+2);\n\tbreak;\n      case TPM_ST_ATTEST_NV_DIGEST:\n\tTSS_TPMS_NV_DIGEST_CERTIFY_INFO_Print(&source->nvDigest, indent+2);\n\tbreak;\n      default:\n\tprintf(\"%*s\" \"TPMU_ATTEST selection %04hx not implemented\\n\", indent, \"\", selector);\n    }\n    return;\n}\n\n/* Table 126 - Definition of TPMS_ATTEST Structure <OUT> */\n\nvoid TSS_TPMS_ATTEST_Print(TPMS_ATTEST *source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMS_ATTEST magic %08x\\n\", indent+2, \"\", source->magic);\n    TSS_TPMI_ST_ATTEST_Print(\"type\", source->type, indent+2);\n    TSS_TPM2B_Print(\"TPMS_ATTEST qualifiedSigner\", indent+2, &source->qualifiedSigner.b);\n    TSS_TPM2B_Print(\"TPMS_ATTEST extraData\", indent+2, &source->extraData.b);\n    TSS_TPMS_CLOCK_INFO_Print(&source->clockInfo, indent+2);\n    printf(\"%*s\" \"TPMS_ATTEST firmwareVersion %\"PRIu64\"\\n\",  indent+2, \"\", source->firmwareVersion);\n    TSS_TPMU_ATTEST_Print(&source->attested, source->type, indent+2);\n    return;\n}\n\n#if 0\t/* Removed because it required a large stack allocation.  The utilities didn't use it, but\n\t   rather did the unmarshal and print themselves. */\n\n/* Table 127 - Definition of TPM2B_ATTEST Structure <OUT> */\n\nvoid TSS_TPM2B_ATTEST_Print(TPM2B_ATTEST *source, unsigned int indent)\n{\n    TPM_RC\t\t\trc = 0;\n    TPMS_ATTEST \t\tattests;\n    uint32_t\t\t\tsize;\n    uint8_t\t\t\t*buffer = NULL;\n\n    /* unmarshal the TPMS_ATTEST from the TPM2B_ATTEST */\n    if (rc == 0) {\n\tbuffer = source->t.attestationData;\n\tsize = source->t.size;\n\trc = TSS_TPMS_ATTEST_Unmarshalu(&attests, &buffer, &size);\n    }\n    if (rc == 0) {\n\tTSS_TPMS_ATTEST_Print(&attests, indent+2);\n    }\n    else {\n\tprintf(\"%*s\" \"TPMS_ATTEST_Unmarshal failed\\n\", indent, \"\");\n    }\n    return;\n}\n#endif\n\n/* Table 128 - Definition of TPMS_AUTH_COMMAND Structure <IN> */\n\nvoid TSS_TPMS_AUTH_COMMAND_Print(TPMS_AUTH_COMMAND *source, unsigned int indent)\n{\n    TSS_TPM_HANDLE_Print(\"sessionHandle\", source->sessionHandle, indent);\t\n    TSS_TPM2B_Print(\"TPMS_AUTH_COMMAND nonce\", indent, &source->nonce.b);\n    TSS_TPMA_SESSION_Print(source->sessionAttributes, indent);\n    TSS_TPM2B_Print(\"TPMS_AUTH_COMMAND hmac\", indent, &source->hmac.b);\n    return;\n}\n\n/* Table 129 - Definition of TPMS_AUTH_RESPONSE Structure <OUT> */\n\nvoid TSS_TPMS_AUTH_RESPONSE_Print(TPMS_AUTH_RESPONSE *source, unsigned int indent)\n{\n    TSS_PrintAlli(\"TPMS_AUTH_RESPONSE nonce\", indent,\n\t\t  source->nonce.t.buffer,\n\t\t  source->nonce.t.size);\n    TSS_TPMA_SESSION_Print(source->sessionAttributes, indent);\n    TSS_TPM2B_Print(\"TPMS_AUTH_RESPONSE hmac\", indent, &source->hmac.b);\n    return;\n}\n\n/* Table 130 - Definition of  {!ALG.S} (TPM_KEY_BITS) TPMI_!ALG.S_KEY_BITS   Type */\n\nvoid TSS_TPM_KEY_BITS_Print(TPM_KEY_BITS source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM_KEY_BITS %u\\n\", indent, \"\", source);\n    return;\n}\n\n/* Table 131 - Definition of TPMU_SYM_KEY_BITS Union */\n\nvoid TSS_TPMU_SYM_KEY_BITS_Print(TPMU_SYM_KEY_BITS *source, TPMI_ALG_SYM selector, unsigned int indent)\n{\n    switch (selector) {\n#ifdef TPM_ALG_AES\n      case TPM_ALG_AES:\n\tTSS_TPM_KEY_BITS_Print(source->aes, indent);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM4\n      case TPM_ALG_SM4:\n\tTSS_TPM_KEY_BITS_Print(source->sm4, indent);\n\tbreak;\n#endif\n#ifdef TPM_ALG_CAMELLIA\n      case TPM_ALG_CAMELLIA:\n\tTSS_TPM_KEY_BITS_Print(source->camellia, indent);\n\tbreak;\n#endif\n#ifdef TPM_ALG_XOR\n      case TPM_ALG_XOR:\n\tTSS_TPM_ALG_ID_Print(\"xorr\", source->xorr, indent);\n\tbreak;\n#endif\n      default:\n\tprintf(\"%*s\" \"TPMI_ALG_SYM value %04hx unknown\\n\", indent, \"\", selector);\n    }\n\n    return;\n}\n\n/* Table 134 - Definition of TPMT_SYM_DEF Structure */\n\nvoid TSS_TPMT_SYM_DEF_Print(TPMT_SYM_DEF *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"algorithm\", source->algorithm, indent);\n    TSS_TPMU_SYM_KEY_BITS_Print(&source->keyBits, source->algorithm, indent);\n    TSS_TPM_ALG_ID_Print(\"mode\", source->mode.sym, indent);\t\t\n    return;\n}\n\n/* Table 135 - Definition of TPMT_SYM_DEF_OBJECT Structure */\n\nvoid TSS_TPMT_SYM_DEF_OBJECT_Print(TPMT_SYM_DEF_OBJECT *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"algorithm\", source->algorithm, indent+2);\n    if (source->algorithm != TPM_ALG_NULL) {\n\tprintf(\"%*s\" \"keyBits: %u\\n\", indent+2, \"\", source->keyBits.sym);\n\tTSS_TPM_ALG_ID_Print(\"mode\", source->mode.sym, indent+2);\n    }\n    return;\n}\n\n/* Table 139 - Definition of TPMS_DERIVE Structure */\n\nvoid TSS_TPMS_DERIVE_Print(TPMS_DERIVE *source, unsigned int indent)\n{\n    TSS_TPM2B_Print(\"TPMS_DERIVE label\", indent, &source->label.b);\n    TSS_TPM2B_Print(\"TPMS_DERIVE context\", indent, &source->context.b);\n    return;\n}\n\n/* Table 143 - Definition of TPMS_SENSITIVE_CREATE Structure <IN> */\n\nvoid TSS_TPMS_SENSITIVE_CREATE_Print(TPMS_SENSITIVE_CREATE *source, unsigned int indent)\n{\n    TSS_TPM2B_Print(\"userAuth\", indent, &source->userAuth.b);\n    TSS_TPM2B_Print(\"data\", indent, &source->data.b);\n    return;\n}\n\n/* Table 144 - Definition of TPM2B_SENSITIVE_CREATE Structure <IN, S> */\n\nvoid TSS_TPM2B_SENSITIVE_CREATE_Print(const char *string, TPM2B_SENSITIVE_CREATE *source, unsigned int indent)\n{\n    printf(\"%*s\" \"%s\\n\", indent, \"\", string);\n    TSS_TPMS_SENSITIVE_CREATE_Print(&source->sensitive, indent+2);\n    return;\n}\n\n/* Table 146 - Definition of {ECC} TPMS_SCHEME_ECDAA Structure */\n\nvoid TSS_TPMS_SCHEME_ECDAA_Print(TPMS_SCHEME_ECDAA *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"hashAlg\", source->hashAlg, indent+2);\n    printf(\"%*s\" \"TPMS_SCHEME_ECDAA count %u\\n\", indent+2, \"\", source->count);\n    return;\n}\n\n/* Table 149 - Definition of TPMS_SCHEME_XOR Structure */\n\nvoid TSS_TPMS_SCHEME_XOR_Print(TPMS_SCHEME_XOR *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"hashAlg\", source->hashAlg, indent+2);\n    TSS_TPM_ALG_ID_Print(\"kdf\", source->kdf, indent+2);\n    return;\n}\n\n/* Table 150 - Definition of TPMU_SCHEME_KEYEDHASH Union <IN/OUT, S> */\n\nvoid TSS_TPMU_SCHEME_KEYEDHASH_Print(TPMU_SCHEME_KEYEDHASH *source, TPMI_ALG_KEYEDHASH_SCHEME selector,\n\t\t\t\t     unsigned int indent)\n{\n    switch (selector) {\n#ifdef TPM_ALG_HMAC\n      case TPM_ALG_HMAC:\n\tTSS_TPM_ALG_ID_Print(\"hmac\", source->hmac.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_XOR\n      case TPM_ALG_XOR:\n\tTSS_TPMS_SCHEME_XOR_Print(&source->xorr, indent+2);\n\tbreak;\n#endif\n      default:\n\tprintf(\"%*s\" \"TPMU_SCHEME_KEYEDHASH selection %04hx not implemented\\n\", indent, \"\", selector);\n    }\n    return;\n}\n\n/* Table 151 - Definition of TPMT_KEYEDHASH_SCHEME Structure */\n\nvoid TSS_TPMT_KEYEDHASH_SCHEME_Print(TPMT_KEYEDHASH_SCHEME *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"scheme\", source->scheme, indent+2);\n    if (source->scheme != TPM_ALG_NULL) {\n\tTSS_TPMU_SCHEME_KEYEDHASH_Print(&source->details, source->scheme, indent+2);\n    }\n    return;\n}\n\n/* Table 154 - Definition of TPMU_SIG_SCHEME Union <IN/OUT, S> */\n\nvoid TSS_TPMU_SIG_SCHEME_Print(TPMU_SIG_SCHEME *source, TPMI_ALG_SIG_SCHEME selector, unsigned int indent)\n{\n    switch (selector) {\n#ifdef TPM_ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\tTSS_TPM_ALG_ID_Print(\"rsassa\", source->rsassa.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\tTSS_TPM_ALG_ID_Print(\"rsapss\", source->rsapss.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\tTSS_TPM_ALG_ID_Print(\"ecdsa\", source->ecdsa.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\tTSS_TPMS_SCHEME_ECDAA_Print(&source->ecdaa, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM2\n      case TPM_ALG_SM2:\n\tTSS_TPM_ALG_ID_Print(\"sm2\", source->sm2.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\tTSS_TPM_ALG_ID_Print(\"ecSchnorr\", source->ecSchnorr.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_HMAC\n      case TPM_ALG_HMAC:\n\tTSS_TPM_ALG_ID_Print(\"hmac\", source->hmac.hashAlg, indent+2);\n\tbreak;\n#endif\n      default:\n\tprintf(\"%*s\" \"TPMU_SIG_SCHEME selection %04hx not implemented\\n\", indent, \"\", selector);\n    }\n    return;\n}\n\n/* Table \" Definition\", 155 - Definition of TPMT_SIG_SCHEME Structure */\n\nvoid TSS_TPMT_SIG_SCHEME_Print(TPMT_SIG_SCHEME *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"scheme\", source->scheme, indent+2);\n    if (source->scheme != TPM_ALG_NULL) {\n\tTSS_TPMU_SIG_SCHEME_Print(&source->details, source->scheme, indent+2);\n    }\n    return;\n}\n\n/* Table 160 - Definition of TPMT_KDF_SCHEME Structure */\n\nvoid TSS_TPMT_KDF_SCHEME_Print(TPMT_KDF_SCHEME *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"scheme\", source->scheme, indent+2);\n    if (source->scheme != TPM_ALG_NULL) {\n\tTSS_TPM_ALG_ID_Print(\"details\", source->details.mgf1.hashAlg, indent+2);\n    }\n    return;\n}\n\n/* Table 162 - Definition of TPMU_ASYM_SCHEME Union */\n\nvoid TSS_TPMU_ASYM_SCHEME_Print(TPMU_ASYM_SCHEME *source, TPMI_ALG_ASYM_SCHEME selector, unsigned int indent)\n{\n    switch (selector) {\n#ifdef TPM_ALG_ECDH\n      case TPM_ALG_ECDH:\n\tTSS_TPM_ALG_ID_Print(\"ecdh\", source->ecdh.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECMQV\n      case TPM_ALG_ECMQV:\n\tTSS_TPM_ALG_ID_Print(\"ecmqvh\", source->ecmqvh.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\tTSS_TPM_ALG_ID_Print(\"rsassa\", source->rsassa.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\tTSS_TPM_ALG_ID_Print(\"rsapss\", source->rsapss.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\tTSS_TPM_ALG_ID_Print(\"ecdsa\", source->ecdsa.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\tTSS_TPMS_SCHEME_ECDAA_Print(&source->ecdaa, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM2\n      case TPM_ALG_SM2:\n\tTSS_TPM_ALG_ID_Print(\"sm2\", source->sm2.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\tTSS_TPM_ALG_ID_Print(\"ecSchnorr\", source->ecSchnorr.hashAlg, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAES\n      case TPM_ALG_RSAES:\n\tbreak;\n#endif\n#ifdef TPM_ALG_OAEP\n      case TPM_ALG_OAEP:\n\tTSS_TPM_ALG_ID_Print(\"oaep\", source->oaep.hashAlg, indent+2);\n\tbreak;\n#endif\n      default:\n\tprintf(\"%*s\" \"TPMU_ASYM_SCHEME selection %04hx not implemented\\n\", indent, \"\", selector);\n    }\n    return;\n}\n\n/* Table 163 - Definition of TPMT_ASYM_SCHEME Structure <> */\n\nvoid TSS_TPMT_ASYM_SCHEME_Print(TPMT_ASYM_SCHEME *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"scheme\", source->scheme, indent+2);\n    if (source->scheme != TPM_ALG_NULL) {\n\tTSS_TPMU_ASYM_SCHEME_Print(&source->details, source->scheme, indent+2);\n    }\n    return;\n}\n\t\n/* Table 165 - Definition of {RSA} TPMT_RSA_SCHEME Structure */\n\nvoid TSS_TPMT_RSA_SCHEME_Print(TPMT_RSA_SCHEME *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"scheme\", source->scheme, indent);\n    if (source->scheme != TPM_ALG_NULL) {\n\tTSS_TPM_ALG_ID_Print(\"details\", source->details.anySig.hashAlg, indent+2);\n    }\n    return;\n}\n\n/* Table 167 - Definition of {RSA} TPMT_RSA_DECRYPT Structure */\n\nvoid TSS_TPMT_RSA_DECRYPT_Print(TPMT_RSA_DECRYPT *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"scheme\", source->scheme, indent+2);\n    if (source->scheme != TPM_ALG_NULL) {\n\tTSS_TPMU_ASYM_SCHEME_Print(&source->details, source->scheme, indent+2);\n    }\n    return;\n}\n\n/* Table 169 - Definition of {RSA} (TPM_KEY_BITS) TPMI_RSA_KEY_BITS Type */\n\nvoid TSS_TPMI_RSA_KEY_BITS_Print(TPMI_RSA_KEY_BITS source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM_KEY_BITS keyBits: %u\\n\", indent, \"\", source);\n    return;\n}\n\n/* Table 172 - Definition of {ECC} TPMS_ECC_POINT Structure */\n\nvoid TSS_TPMS_ECC_POINT_Print(TPMS_ECC_POINT *source, unsigned int indent)\n{\n    TSS_TPM2B_Print(\"TPMS_ECC_POINT x\", indent+2, &source->x.b);\n    TSS_TPM2B_Print(\"TPMS_ECC_POINT y\", indent+2, &source->y.b);\n    return;\n}\n\n/* Table 173 - Definition of {ECC} TPM2B_ECC_POINT Structure */\n\nvoid TSS_TPM2B_ECC_POINT_Print(const char *string, TPM2B_ECC_POINT *source, unsigned int indent)\n{\n    printf(\"%*s\" \"%s\\n\", indent, \"\", string);\n    TSS_TPMS_ECC_POINT_Print(&source->point, indent);\n    return;\n}\n\n/* Table 175 - Definition of {ECC} (TPM_ECC_CURVE) TPMI_ECC_CURVE Type */\n\nvoid TSS_TPMI_ECC_CURVE_Print(const char *string, TPMI_ECC_CURVE source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n      case TPM_ECC_BN_P256:\n\tprintf(\"%s TPM_ECC_BN_P256\\n\", string);\n\tbreak;\n      case TPM_ECC_NIST_P256:\n\tprintf(\"%s TPM_ECC_NIST_P256\\n\", string);\n\tbreak;\n      case TPM_ECC_NIST_P384:\n\tprintf(\"%s TPM_ECC_NIST_P384\\n\", string);\n\tbreak;\n      default:\n\tprintf(\"%s TPMI_ECC_CURVE %04hx unknown\\n\", string, source);\n    }\n    return;\n}\n\n/* Table 176 - Definition of (TPMT_SIG_SCHEME) {ECC} TPMT_ECC_SCHEME Structure */\n\nvoid TSS_TPMT_ECC_SCHEME_Print(TPMT_ECC_SCHEME *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"scheme\", source->scheme, indent+2);\n    if (source->scheme != TPM_ALG_NULL) {\n\tTSS_TPM_ALG_ID_Print(\"details\", source->details.anySig.hashAlg, indent+2);\n    }\n    return;\n}\n\n/* Table 177 - Definition of {ECC} TPMS_ALGORITHM_DETAIL_ECC Structure <OUT> */\n\nvoid TSS_TPMS_ALGORITHM_DETAIL_ECC_Print(TPMS_ALGORITHM_DETAIL_ECC *source, unsigned int indent)\n{\n    TSS_TPM_ECC_CURVE_Print(\"curveID\", source->curveID, indent+2);\n    printf(\"%*s\" \"TPMS_ALGORITHM_DETAIL_ECC keySize %u\\n\", indent+2, \"\", source->keySize);\n    TSS_TPMT_KDF_SCHEME_Print(&source->kdf, indent+2);\n    TSS_TPMT_ECC_SCHEME_Print(&source->sign, indent+2);\n    TSS_TPM2B_Print(\"TPMS_ALGORITHM_DETAIL_ECC p\", indent, &source->p.b);\n    TSS_TPM2B_Print(\"TPMS_ALGORITHM_DETAIL_ECC a\", indent, &source->a.b);\n    TSS_TPM2B_Print(\"TPMS_ALGORITHM_DETAIL_ECC b\", indent, &source->b.b);\n    TSS_TPM2B_Print(\"TPMS_ALGORITHM_DETAIL_ECC gX\", indent, &source->gX.b);\n    TSS_TPM2B_Print(\"TPMS_ALGORITHM_DETAIL_ECC gY\", indent, &source->gY.b);\n    TSS_TPM2B_Print(\"TPMS_ALGORITHM_DETAIL_ECC n\", indent, &source->n.b);\n    TSS_TPM2B_Print(\"TPMS_ALGORITHM_DETAIL_ECC h\", indent, &source->h.b);\n    return;\n}\n\n/* Table 178 - Definition of {RSA} TPMS_SIGNATURE_RSA Structure */\n\nvoid TSS_TPMS_SIGNATURE_RSA_Print(TPMS_SIGNATURE_RSA *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"hash\", source->hash, indent+2);\n    TSS_TPM2B_Print(\"TPMS_SIGNATURE_RSA sig\", indent+2, &source->sig.b);\n    return;\n}\n\n/* Table 179 - Definition of Types for {RSA} Signature */\n\nvoid TSS_TPMS_SIGNATURE_RSASSA_Print(TPMS_SIGNATURE_RSASSA *source, unsigned int indent)\n{\n    TSS_TPMS_SIGNATURE_RSA_Print(source, indent+2);\n    return;\n}\n\n/* Table 180 - Definition of {ECC} TPMS_SIGNATURE_ECC Structure */\n\nvoid TSS_TPMS_SIGNATURE_ECC_Print(TPMS_SIGNATURE_ECC *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"hash\", source->hash, indent);\n    TSS_TPM2B_Print(\"TPMS_SIGNATURE_ECC signatureR\", indent, &source->signatureR.b);\n    TSS_TPM2B_Print(\"TPMS_SIGNATURE_ECC signatureS\", indent, &source->signatureS.b);\n    return;\n}\n\n/* Table 182 - Definition of TPMU_SIGNATURE Union <IN/OUT, S> */\n\nvoid TSS_TPMU_SIGNATURE_Print(TPMU_SIGNATURE *source, TPMI_ALG_SIG_SCHEME selector, unsigned int indent)\n{\n    switch (selector) {\n#ifdef TPM_ALG_RSASSA\n      case TPM_ALG_RSASSA:\n\tTSS_TPMS_SIGNATURE_RSA_Print(&source->rsassa, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSAPSS\n      case TPM_ALG_RSAPSS:\n\tTSS_TPMS_SIGNATURE_RSA_Print(&source->rsapss, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDSA\n      case TPM_ALG_ECDSA:\n\tTSS_TPMS_SIGNATURE_ECC_Print(&source->ecdsa, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECDAA\n      case TPM_ALG_ECDAA:\n\tTSS_TPMS_SIGNATURE_ECC_Print(&source->ecdaa, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SM2\n      case TPM_ALG_SM2:\n\tTSS_TPMS_SIGNATURE_ECC_Print(&source->sm2, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECSCHNORR\n      case TPM_ALG_ECSCHNORR:\n\tTSS_TPMS_SIGNATURE_ECC_Print(&source->ecschnorr, indent+2);\n\tbreak;\n#endif\n#ifdef TPM_ALG_HMAC\n      case TPM_ALG_HMAC:\n\tTSS_TPMT_HA_Print(&source->hmac, indent+2);\n\tbreak;\n#endif\n     default:\n\tprintf(\"%*s\" \"TPMU_SIGNATURE selection %04hx not implemented\\n\", indent, \"\", selector);\n\t\n    }\n}\n\n/* Table 183 - Definition of TPMT_SIGNATURE Structure */\n\nvoid TSS_TPMT_SIGNATURE_Print(TPMT_SIGNATURE *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"sigAlg\", source->sigAlg, indent+2);\n    if (source->sigAlg != TPM_ALG_NULL) {\n\tTSS_TPMU_SIGNATURE_Print(&source->signature, source->sigAlg, indent);\n    }\n    return;\n}\n\n/* Table 186 - Definition of (TPM_ALG_ID) TPMI_ALG_PUBLIC Type */\n\nvoid TSS_TPMI_ALG_PUBLIC_Print(const char *string, TPMI_ALG_PUBLIC source, unsigned int indent)\n{\n    printf(\"%*s\", indent, \"\");\n    switch (source) {\n#ifdef TPM_ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\tprintf(\"%s TPM_ALG_KEYEDHASH\\n\", string);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA:\n\tprintf(\"%s TPM_ALG_RSA\\n\", string);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\tprintf(\"%s TPM_ALG_ECC\\n\", string);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\tprintf(\"%s TPM_ALG_SYMCIPHER\\n\", string);\n\tbreak;\n#endif\n      default:\n\tprintf(\"%s selection %04hx not implemented\\n\", string, source);\n    }\n    return;\n}\n    \n/* Table 187 - Definition of TPMU_PUBLIC_ID Union <IN/OUT, S> */\n\nvoid TSS_TPMU_PUBLIC_ID_Print(TPMU_PUBLIC_ID *source, TPMI_ALG_PUBLIC selector, unsigned int indent)\n{\n    switch (selector) {\n#ifdef TPM_ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\tTSS_TPM2B_Print(\"TPM_ALG_KEYEDHASH keyedHash\", indent, &source->keyedHash.b);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\tTSS_TPM2B_Print(\"TPM_ALG_SYMCIPHER sym\", indent, &source->sym.b);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA: \n\tTSS_TPM2B_Print(\"TPM_ALG_RSA rsa\", indent, &source->rsa.b);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\tTSS_TPM2B_Print(\"TPM_ALG_ECC x\", indent, &source->ecc.x.b);\n\tTSS_TPM2B_Print(\"TPM_ALG_ECC y\", indent, &source->ecc.y.b);\n\tbreak;\n#endif\n      default:\n\tprintf(\"%*s\" \"TPMU_PUBLIC_ID_Print: selection %04hx not implemented\\n\", indent, \"\", selector);\n    }\n    return;\n}\n\n/* Table 188 - Definition of TPMS_KEYEDHASH_PARMS Structure */\n\nvoid TSS_TPMS_KEYEDHASH_PARMS_Print(TPMS_KEYEDHASH_PARMS *source, unsigned int indent)\n{\n    TSS_TPMT_KEYEDHASH_SCHEME_Print(&source->scheme, indent);\n    return;\n}\n\n/* Table 189 - Definition of TPMS_ASYM_PARMS Structure <> */\n\nvoid TSS_TPMS_ASYM_PARMS_Print(TPMS_ASYM_PARMS *source, unsigned int indent)\n{\n    TSS_TPMT_SYM_DEF_OBJECT_Print(&source->symmetric, indent+2);\n    TSS_TPMT_ASYM_SCHEME_Print(&source->scheme, indent+2);\n    return;\n}\n\n/* Table 190 - Definition of {RSA} TPMS_RSA_PARMS Structure */\n\nvoid TSS_TPMS_RSA_PARMS_Print(TPMS_RSA_PARMS *source, unsigned int indent)\n{\n    TSS_TPMT_SYM_DEF_OBJECT_Print(&source->symmetric, indent);\n    TSS_TPMT_RSA_SCHEME_Print(&source->scheme, indent);\n    TSS_TPMI_RSA_KEY_BITS_Print(source->keyBits, indent);\n    printf(\"%*s\" \"TPMS_RSA_PARMS exponent %08x\\n\", indent, \"\", source->exponent);\n    return;\n}\n\n/* Table 191 - Definition of {ECC} TPMS_ECC_PARMS Structure */\n\nvoid TSS_TPMS_ECC_PARMS_Print(TPMS_ECC_PARMS *source, unsigned int indent)\n{\n    TSS_TPMT_SYM_DEF_OBJECT_Print(&source->symmetric, indent);\n    TSS_TPMT_ECC_SCHEME_Print(&source->scheme, indent);\n    TSS_TPMI_ECC_CURVE_Print(\"curveID\", source->curveID, indent);\n    TSS_TPMT_KDF_SCHEME_Print(&source->kdf, indent);\n    return;\n}\n\n/* Table 192 - Definition of TPMU_PUBLIC_PARMS Union <IN/OUT, S> */\n\nvoid TSS_TPMU_PUBLIC_PARMS_Print(TPMU_PUBLIC_PARMS *source, uint32_t selector, unsigned int indent)\n{\n    switch (selector) {\n      case TPM_ALG_KEYEDHASH:\n\tprintf(\"%*s\" \"TPMU_PUBLIC_PARMS keyedHashDetail\\n\", indent, \"\");\n\tTSS_TPMS_KEYEDHASH_PARMS_Print(&source->keyedHashDetail, indent);\n\tbreak;\n#if 0\n      case TPM_ALG_SYMCIPHER:\n\tprintf(\"%*s\" \"TPMU_PUBLIC_PARMS symDetail\\n\", indent, \"\");\n\tTSS_TPMS_SYMCIPHER_PARMS_Print(&source->symDetail, indent);\n\tbreak;\n#endif\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA:\n\tprintf(\"%*s\" \"TPMU_PUBLIC_PARMS rsaDetail\\n\", indent, \"\");\n\tTSS_TPMS_RSA_PARMS_Print(&source->rsaDetail, indent);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\tprintf(\"%*s\" \"TPMU_PUBLIC_PARMS eccDetail\\n\", indent, \"\");\n\tTSS_TPMS_ECC_PARMS_Print(&source->eccDetail, indent);\n\tbreak;\n#endif\n      default:\n\tprintf(\"%*s\" \"TPMU_PUBLIC_PARMS: selector %04x not implemented\\n\", indent, \"\", selector);\n    }\n    return;\n}\n\n/* Table 193 - Definition of TPMT_PUBLIC_PARMS Structure */\n\nvoid TSS_TPMT_PUBLIC_PARMS_Print(TPMT_PUBLIC_PARMS *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"type\", source->type, indent);\n    TSS_TPMU_PUBLIC_PARMS_Print(&source->parameters, source->type, indent);\n    return;\n}\n/* Table 194 - Definition of TPMT_PUBLIC Structure */\n\nvoid TSS_TPMT_PUBLIC_Print(TPMT_PUBLIC *source, unsigned int indent)\n{\n    TSS_TPMI_ALG_PUBLIC_Print(\"type\", source->type, indent);\n    TSS_TPM_ALG_ID_Print(\"nameAlg\", source->nameAlg, indent);\n    TSS_TPMA_OBJECT_Print(\"objectAttributes\", source->objectAttributes, indent);\t\n    TSS_TPM2B_Print(\"authPolicy\", indent, &source->authPolicy.b);\n    TSS_TPMU_PUBLIC_PARMS_Print(&source->parameters, source->type, indent);\t\t\n    TSS_TPMU_PUBLIC_ID_Print(&source->unique, source->type, indent);\t\t\t\n    return;\n}\n\n/* Table 195 - Definition of TPM2B_PUBLIC Structure */\n\nvoid TSS_TPM2B_PUBLIC_Print(const char *string, TPM2B_PUBLIC *source, unsigned int indent)\n{\n    printf(\"%*s\" \"%s\\n\", indent, \"\", string);\n    TSS_TPMT_PUBLIC_Print(&source->publicArea, indent+2);\t\t\n    return;\n}\n\n/* Table 198 - Definition of TPMU_SENSITIVE_COMPOSITE Union <IN/OUT, S> */\n\nvoid TSS_TPMU_SENSITIVE_COMPOSITE_Print(TPMU_SENSITIVE_COMPOSITE *source, uint32_t selector, unsigned int indent)\n{\n    switch (selector) {\n#ifdef TPM_ALG_RSA\n      case TPM_ALG_RSA:\n\tTSS_TPM2B_Print(\"TPMU_SENSITIVE_COMPOSITE rsa\", indent+2, &source->rsa.b);\n\tbreak;\n#endif\n#ifdef TPM_ALG_ECC\n      case TPM_ALG_ECC:\n\tTSS_TPM2B_Print(\"TPMU_SENSITIVE_COMPOSITE ecc\", indent+2, &source->ecc.b);\n\tbreak;\n#endif\n#ifdef TPM_ALG_KEYEDHASH\n      case TPM_ALG_KEYEDHASH:\n\tTSS_TPM2B_Print(\"TPMU_SENSITIVE_COMPOSITE bits\", indent+2, &source->bits.b);\n\tbreak;\n#endif\n#ifdef TPM_ALG_SYMCIPHER\n      case TPM_ALG_SYMCIPHER:\n\tTSS_TPM2B_Print(\"TPMU_SENSITIVE_COMPOSITE sym\", indent+2, &source->sym.b);\n\tbreak;\n#endif\n      default:\n\tprintf(\"%*s\" \"TPMU_SENSITIVE_COMPOSITE: selection %08x not implemented \\n\", indent+2, \"\", selector);\n    }\n    return;\n}\n\n/* Table 199 - Definition of TPMT_SENSITIVE Structure */\n\nvoid TSS_TPMT_SENSITIVE_Print(TPMT_SENSITIVE *source, unsigned int indent)\n{\n    TSS_TPM_ALG_ID_Print(\"sensitiveType\", source->sensitiveType, indent+2);\n    TSS_TPM2B_Print(\"TPMT_SENSITIVE authValue\", indent+2, &source->authValue.b);\n    TSS_TPM2B_Print(\"TPMT_SENSITIVE seedValue\", indent+2, &source->seedValue.b);\n    TSS_TPMU_SENSITIVE_COMPOSITE_Print(&source->sensitive, source->sensitiveType, indent+2);\n    return;\n}\n\n/* Table 200 - Definition of TPM2B_SENSITIVE Structure <IN/OUT> */\n\nvoid TSS_TPM2B_SENSITIVE_Print(TPM2B_SENSITIVE *source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2B_SENSITIVE size %u\\n\", indent+2, \"\", source->t.size);\n    if (source->t.size != 0) {\n\tTSS_TPMT_SENSITIVE_Print(&source->t.sensitiveArea, indent+2);\n    }\n    return;\n}\n\n/* Table 207 - Definition of TPMS_NV_PIN_COUNTER_PARAMETERS Structure */\n\nvoid TSS_TPMS_NV_PIN_COUNTER_PARAMETERS_Print(TPMS_NV_PIN_COUNTER_PARAMETERS *source, unsigned int indent)\n{\n    printf(\"%*s\" \"pinCount %u\\n\", indent+2, \"\", source->pinCount);\n    printf(\"%*s\" \"pinLimit %u\\n\", indent+2, \"\", source->pinLimit);\n    return;\n}\n\n/* Table 208 - Definition of (UINT32) TPMA_NV Bits */\n\nvoid TSS_TPMA_NV_Print(TPMA_NV source, unsigned int indent)\n{\n    uint32_t nvType;\n\n    if (source.val & TPMA_NVA_PPWRITE) printf(\"%*s\" \"TPMA_NV_PPWRITE\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_OWNERWRITE) printf(\"%*s\" \"TPMA_NV_OWNERWRITE\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_AUTHWRITE) printf(\"%*s\" \"TPMA_NV_AUTHWRITE\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_POLICYWRITE) printf(\"%*s\" \"TPMA_NV_POLICYWRITE\\n\", indent, \"\");\n\n    nvType = (source.val & TPMA_NVA_TPM_NT_MASK) >> 4;\n    switch (nvType) {\n      case TPM_NT_ORDINARY:\n\tprintf(\"%*s\" \"TPM_NT_ORDINARY\\n\", indent, \"\");\n\tbreak;\n      case TPM_NT_COUNTER:\n\tprintf(\"%*s\" \"TPM_NT_COUNTER\\n\", indent, \"\");\n\tbreak;\n      case TPM_NT_BITS:\n\tprintf(\"%*s\" \"TPM_NT_BITS\\n\", indent, \"\");\n\tbreak;\n      case TPM_NT_EXTEND:\n\tprintf(\"%*s\" \"TPM_NT_EXTEND\\n\", indent, \"\");\n\tbreak;\n      case TPM_NT_PIN_FAIL:\n\tprintf(\"%*s\" \"TPM_NT_PIN_FAIL\\n\", indent, \"\");\n\tbreak;\n      case TPM_NT_PIN_PASS:\n\tprintf(\"%*s\" \"TPM_NT_PIN_PASS\\n\", indent, \"\");\n\tbreak;\n      default:\n\tprintf(\"%*s\" \"TPMA_NV type %02x unknown\\n\", indent, \"\", nvType);\n    }\n\n    if (source.val & TPMA_NVA_POLICY_DELETE) printf(\"%*s\" \"TPMA_NV_POLICY_DELETE\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_WRITELOCKED) printf(\"%*s\" \"TPMA_NV_WRITELOCKED\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_WRITEALL) printf(\"%*s\" \"TPMA_NV_WRITEALL\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_WRITEDEFINE) printf(\"%*s\" \"TPMA_NV_WRITEDEFINE\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_WRITE_STCLEAR) printf(\"%*s\" \"TPMA_NV_WRITE_STCLEAR\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_GLOBALLOCK) printf(\"%*s\" \"TPMA_NV_GLOBALLOCK\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_PPREAD) printf(\"%*s\" \"TPMA_NV_PPREAD\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_OWNERREAD) printf(\"%*s\" \"TPMA_NV_OWNERREAD\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_AUTHREAD) printf(\"%*s\" \"TPMA_NV_AUTHREAD\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_POLICYREAD) printf(\"%*s\" \"TPMA_NV_POLICYREAD\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_NO_DA) printf(\"%*s\" \"TPMA_NV_NO_DA\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_ORDERLY) printf(\"%*s\" \"TPMA_NV_ORDERLY\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_CLEAR_STCLEAR) printf(\"%*s\" \"TPMA_NV_CLEAR_STCLEAR\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_READLOCKED) printf(\"%*s\" \"TPMA_NV_READLOCKED\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_WRITTEN) printf(\"%*s\" \"TPMA_NV_WRITTEN\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_PLATFORMCREATE) printf(\"%*s\" \"TPMA_NV_PLATFORMCREATE\\n\", indent, \"\");\n    if (source.val & TPMA_NVA_READ_STCLEAR) printf(\"%*s\" \"TPMA_NV_READ_STCLEAR\\n\", indent, \"\");\n    return;\n}\n\n/* Table 209 - Definition of TPMS_NV_PUBLIC Structure */\n\nvoid TSS_TPMS_NV_PUBLIC_Print(TPMS_NV_PUBLIC *source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMS_NV_PUBLIC nvIndex %08x\\n\", indent+2, \"\", source->nvIndex);\n    TSS_TPM_ALG_ID_Print(\"nameAlg\", source->nameAlg, indent+2);\n    TSS_TPMA_NV_Print(source->attributes, indent+2);\n    TSS_TPM2B_Print(\"TPMS_NV_PUBLIC authPolicy\", indent+2, &source->authPolicy.b);\n    printf(\"%*s\" \"TPMS_NV_PUBLIC dataSize %u\\n\", indent+2, \"\", source->dataSize);\n    return;\n}\n\n/* Table 210 - Definition of TPM2B_NV_PUBLIC Structure */\n\nvoid TSS_TPM2B_NV_PUBLIC_Print(TPM2B_NV_PUBLIC *source, unsigned int indent)\n{\n    TSS_TPMS_NV_PUBLIC_Print(&source->nvPublic, indent+2);\n    return;\n}\n\n/* Table 212 - Definition of TPMS_CONTEXT_DATA Structure <IN/OUT, S> */\n\nvoid TSS_TPMS_CONTEXT_DATA_Print(TPMS_CONTEXT_DATA *source, unsigned int indent)\n{\n    TSS_TPM2B_Print(\"TPMS_CONTEXT_DATA integrity\", indent+2, &source->integrity.b);\n    TSS_TPM2B_Print(\"TPMS_CONTEXT_DATA encrypted\", indent+2, &source->encrypted.b);\n    return;\n}\n\n/* Table 214 - Definition of TPMS_CONTEXT Structure */\n\nvoid TSS_TPMS_CONTEXT_Print(TPMS_CONTEXT *source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPMS_CONTEXT sequence %\"PRIu64\"\\n\", indent+2, \"\", source->sequence);\n    TSS_TPM_HANDLE_Print(\"savedHandle\", source->savedHandle, indent+2);\n    TSS_TPM_HANDLE_Print(\"hierarchy\", source->hierarchy, indent+2);\n    TSS_TPM2B_Print(\"TPMS_CONTEXT contextBlob\", indent+2, &source->contextBlob.b);\n    return;\n}\n\n/* Table 216 - Definition of TPMS_CREATION_DATA Structure <OUT> */\n\nvoid TSS_TPMS_CREATION_DATA_Print(TPMS_CREATION_DATA *source, unsigned int indent)\n{\n    TSS_TPML_PCR_SELECTION_Print(&source->pcrSelect, indent+2);\n    TSS_TPM2B_Print(\"TPMS_CREATION_DATA pcrDigest\", indent+2, &source->pcrDigest.b);\n    TSS_TPMA_LOCALITY_Print(source->locality, indent+2);\n    TSS_TPM_ALG_ID_Print(\"parentNameAlg\", source->parentNameAlg, indent+2);\n    TSS_TPM2B_Print(\"TPMS_CREATION_DATA parentName\", indent+2, &source->parentName.b);\n    TSS_TPM2B_Print(\"TPMS_CREATION_DATA parentQualifiedName\", indent+2, &source->parentQualifiedName.b);\n    TSS_TPM2B_Print(\"TPMS_CREATION_DATA outsideInfo\", indent+2, &source->outsideInfo.b);\nreturn;\n}\n\n/* Table 217 - Definition of TPM2B_CREATION_DATA Structure <OUT> */\n\nvoid TSS_TPM2B_CREATION_DATA_Print(TPM2B_CREATION_DATA *source, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2B_CREATION_DATA size %u\\n\", indent+2, \"\", source->size);\n    TSS_TPMS_CREATION_DATA_Print(&source->creationData, indent+2);\n    return;\n}\n\n#endif\t/* TPM_TPM20 */\n\n#endif /* TPM_TSS_NO_PRINT */\n"
  },
  {
    "path": "ibmtss-ftpm/tssprintcmd.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     Command Print Utilities\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2018 - 2024.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdint.h>\n#include <stdio.h>\n#include <inttypes.h>\n\n#include <ibmtss/tssprintcmd.h>\n\nvoid ActivateCredential_In_Print(ActivateCredential_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ActivateCredential\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"activateHandle\", in->activateHandle, indent);\n    TSS_TPM_HANDLE_Print(\"keyHandle\", in->keyHandle, indent);\n    TSS_TPM2B_Print(\"credentialBlob\", indent, &in->credentialBlob.b);\n    TSS_TPM2B_Print(\"TPM2B_ENCRYPTED_SECRET secret\", indent, &in->secret.b);\n    return;\n}\nvoid CertifyCreation_In_Print(CertifyCreation_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_CertifyCreation\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"signHandle\", in->signHandle, indent);\n    TSS_TPM_HANDLE_Print(\"objectHandle\", in->objectHandle, indent);\n    TSS_TPM2B_Print(\"qualifyingData\", indent, &in->qualifyingData.b);\n    TSS_TPM2B_Print(\"creationHash\", indent, &in->creationHash.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent);\n    printf(\"%*s\" \"creationTicket\\n\", indent, \"\");\n    TSS_TPMT_TK_CREATION_Print(&in->creationTicket, indent+2);\n    return;\n}\nvoid Certify_In_Print(Certify_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Certify\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"objectHandle\", in->objectHandle, indent);\n    TSS_TPM_HANDLE_Print(\"signHandle\", in->signHandle, indent);\n    TSS_TPM2B_Print(\"qualifyingData\", indent, &in->qualifyingData.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent);\n    return;\n}\nvoid CertifyX509_In_Print(CertifyX509_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_CertifyX509\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"objectHandle\", in->objectHandle, indent);\n    TSS_TPM_HANDLE_Print(\"signHandle\", in->signHandle, indent);\n    TSS_TPM2B_Print(\"reserved\", indent, &in->reserved.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent);\n    TSS_TPM2B_Print(\"partialCertificate\", indent, &in->partialCertificate.b);\n    return;\n}\nvoid ChangeEPS_In_Print(ChangeEPS_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ChangeEPS\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    return;\n}\nvoid ChangePPS_In_Print(ChangePPS_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ChangePPS\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    return;\n}\nvoid ClearControl_In_Print(ClearControl_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ClearControl\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"auth\", in->auth, indent);\n    TSS_TPMI_YES_NO_Print(\"disable\", in->disable, indent);\n    return;\n}\nvoid Clear_In_Print(Clear_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Clear\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    return;\n}\nvoid ClockRateAdjust_In_Print(ClockRateAdjust_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ClockRateAdjust\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"auth\", in->auth, indent);\n    TSS_TPM_CLOCK_ADJUST_Print(\"rateAdjust\", in->rateAdjust, indent);\n    return;\n}\nvoid ClockSet_In_Print(ClockSet_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ClockSet\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"auth\", in->auth, indent);\n    printf(\"%*s\" \"newTime %\"PRIu64\"\\n\", indent, \"\", in->newTime);\n    return;\n}\nvoid Commit_In_Print(Commit_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Commit\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"signHandle\", in->signHandle, indent);\n    TSS_TPM2B_ECC_POINT_Print(\"P1\", &in->P1, indent);\n    TSS_TPM2B_Print(\"s2\", indent, &in->s2.b);\n    TSS_TPM2B_Print(\"y2\", indent, &in->y2.b);\n    return;\n}\nvoid ContextLoad_In_Print(ContextLoad_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ContextLoad\\n\", indent, \"\");\n    TSS_TPMS_CONTEXT_Print(&in->context, indent);\n    return;\n}\nvoid ContextSave_In_Print(ContextSave_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ContextSave\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"saveHandle\", in->saveHandle, indent);\n    return;\n}\nvoid Create_In_Print(Create_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Create\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"parentHandle\", in->parentHandle, indent);\n    TSS_TPM2B_SENSITIVE_CREATE_Print(\"inSensitive\", &in->inSensitive, indent);\n    TSS_TPM2B_PUBLIC_Print(\"inPublic\", &in->inPublic, indent);\n    TSS_TPM2B_Print(\"outsideInfo\", indent, &in->outsideInfo.b);\n    TSS_TPML_PCR_SELECTION_Print(&in->creationPCR, indent);\n    return;\n}\nvoid CreateLoaded_In_Print(CreateLoaded_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_CreateLoaded\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"parentHandle\", in->parentHandle, indent);\n    TSS_TPM2B_SENSITIVE_CREATE_Print(\"inSensitive\", &in->inSensitive, indent);\n    TSS_TPM2B_Print(\"inPublic\", indent, &in->inPublic.b);\n    return;\n}\nvoid CreatePrimary_In_Print(CreatePrimary_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_CreatePrimary\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"primaryHandle\", in->primaryHandle, indent);\n    TSS_TPM2B_SENSITIVE_CREATE_Print(\"inSensitive\", &in->inSensitive, indent);\n    TSS_TPM2B_PUBLIC_Print(\"inPublic\", &in->inPublic, indent);\n    TSS_TPM2B_Print(\"outsideInfo\", indent, &in->outsideInfo.b);\n    TSS_TPML_PCR_SELECTION_Print(&in->creationPCR, indent);\n    return;\n}\nvoid DictionaryAttackLockReset_In_Print(DictionaryAttackLockReset_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_DictionaryAttackLockReset\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"lockHandle\", in->lockHandle, indent);\n    return;\n}\nvoid DictionaryAttackParameters_In_Print(DictionaryAttackParameters_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_DictionaryAttackParameters\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"lockHandle\", in->lockHandle, indent);\n    printf(\"%*s\" \"newMaxTries %u\\n\", indent, \"\", in->newMaxTries);\n    printf(\"%*s\" \"newRecoveryTime %u\\n\", indent, \"\", in->newRecoveryTime);\n    printf(\"%*s\" \"lockoutRecovery %u\\n\", indent, \"\", in->lockoutRecovery);\n    return;\n}\nvoid Duplicate_In_Print(Duplicate_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Duplicate\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"objectHandle\", in->objectHandle, indent);\n    TSS_TPM_HANDLE_Print(\"newParentHandle\", in->newParentHandle, indent);\n    TSS_TPM2B_Print(\"encryptionKeyIn\", indent, &in->encryptionKeyIn.b);\n    printf(\"%*s\" \"symmetricAlg\\n\", indent, \"\");\n    TSS_TPMT_SYM_DEF_OBJECT_Print(&in->symmetricAlg, indent);\n    return;\n}\nvoid ECC_Encrypt_In_Print(ECC_Encrypt_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ECC_Encrypt\\n\", indent, \"\");\n    TSS_TPM2B_Print(\"plainText\", indent, &in->plainText.b);\n    TSS_TPMT_KDF_SCHEME_Print(&in->inScheme, indent);\n    return;\n}\nvoid ECC_Decrypt_In_Print(ECC_Decrypt_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ECC_Decrypt\\n\", indent, \"\");\n    TSS_TPM2B_ECC_POINT_Print(\"C1\", &in->C1, indent);\n    TSS_TPM2B_Print(\"C2\", indent, &in->C2.b);\n    TSS_TPM2B_Print(\"C3\", indent, &in->C3.b);\n    TSS_TPMT_KDF_SCHEME_Print(&in->inScheme, indent);\n    return;\n}\nvoid ECC_Parameters_In_Print(ECC_Parameters_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ECC_Parameters\\n\", indent, \"\");\n    TSS_TPMI_ECC_CURVE_Print(\"curveID\", in->curveID, indent);\n    return;\n}\nvoid ECDH_KeyGen_In_Print(ECDH_KeyGen_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ECDH_KeyGen\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"keyHandle\", in->keyHandle, indent);\n    return;\n}\nvoid ECDH_ZGen_In_Print(ECDH_ZGen_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ECDH_ZGen\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"keyHandle\", in->keyHandle, indent);\n    TSS_TPM2B_ECC_POINT_Print(\"inPoint\", &in->inPoint, indent);\n    return;\n}\nvoid EC_Ephemeral_In_Print(EC_Ephemeral_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_EC_Ephemeral\\n\", indent, \"\");\n    TSS_TPMI_ECC_CURVE_Print(\"curveID\", in->curveID, indent);\n    return;\n}\nvoid EncryptDecrypt_In_Print(EncryptDecrypt_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_EncryptDecrypt\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"keyHandle\", in->keyHandle, indent);\n    TSS_TPMI_YES_NO_Print(\"decrypt\", in->decrypt, indent);\n    TSS_TPM_ALG_ID_Print(\"mode\", in->mode, indent);\n    TSS_TPM2B_Print(\"ivIn\", indent, &in->ivIn.b);\n    TSS_TPM2B_Print(\"inData\", indent, &in->inData.b);\n    return;\n}\nvoid EncryptDecrypt2_In_Print(EncryptDecrypt2_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_EncryptDecrypt2\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"keyHandle\", in->keyHandle, indent);\n    TSS_TPM2B_Print(\"inData\", indent, &in->inData.b);\n    TSS_TPMI_YES_NO_Print(\"decrypt\", in->decrypt, indent);\n    TSS_TPM_ALG_ID_Print(\"mode\", in->mode, indent);\n    TSS_TPM2B_Print(\"ivIn\", indent, &in->ivIn.b);\n    return;\n}\nvoid EventSequenceComplete_In_Print(EventSequenceComplete_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_EventSequenceComplete\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"pcrHandle\", in->pcrHandle, indent);\n    TSS_TPM_HANDLE_Print(\"sequenceHandle\", in->sequenceHandle, indent);\n    TSS_TPM2B_Print(\"buffer\", indent, &in->buffer.b);\n    return;\n}\nvoid EvictControl_In_Print(EvictControl_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_EvictControl\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"auth\", in->auth, indent);\n    TSS_TPM_HANDLE_Print(\"objectHandle\", in->objectHandle, indent);\n    TSS_TPM_HANDLE_Print(\"persistentHandle\", in->persistentHandle, indent);\n    return;\n}\nvoid FlushContext_In_Print(FlushContext_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_FlushContext\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"flushHandle\", in->flushHandle, indent);\n    return;\n}\nvoid GetCapability_In_Print(GetCapability_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_GetCapability\\n\", indent, \"\");\n    TSS_TPM_CAP_Print(\"capability\", in->capability, indent);\n    printf(\"%*s\" \"property %08x\\n\", indent, \"\", in->property);\n    printf(\"%*s\" \"propertyCount %u\\n\", indent, \"\", in->propertyCount);\n    return;\n}\nvoid GetCommandAuditDigest_In_Print(GetCommandAuditDigest_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_GetCommandAuditDigest\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"privacyHandle\", in->privacyHandle, indent);\n    TSS_TPM_HANDLE_Print(\"signHandle\", in->signHandle, indent);\n    TSS_TPM2B_Print(\"qualifyingData\", indent, &in->qualifyingData.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent);\n    return;\n}\nvoid GetRandom_In_Print(GetRandom_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_GetRandom\\n\", indent, \"\");\n    printf(\"%*s\" \"bytesRequested %u\\n\", indent, \"\", in->bytesRequested);\n    return;\n}\nvoid GetSessionAuditDigest_In_Print(GetSessionAuditDigest_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_GetSessionAuditDigest\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"privacyAdminHandle\", in->privacyAdminHandle, indent);\n    TSS_TPM_HANDLE_Print(\"signHandle\", in->signHandle, indent);\n    TSS_TPM_HANDLE_Print(\"sessionHandle\", in->sessionHandle, indent);\n    TSS_TPM2B_Print(\"qualifyingData\", indent, &in->qualifyingData.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent);\n    return;\n}\nvoid GetTime_In_Print(GetTime_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_GetTime\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"privacyAdminHandle\", in->privacyAdminHandle, indent);\n    TSS_TPM_HANDLE_Print(\"signHandle\", in->signHandle, indent);\n    TSS_TPM2B_Print(\"qualifyingData\", indent, &in->qualifyingData.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent);\n    return;\n}\nvoid HMAC_Start_In_Print(HMAC_Start_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_HMAC_Start\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"handle\", in->handle, indent);\n    TSS_TPM2B_Print(\"auth\", indent, &in->auth.b);\n    TSS_TPM_ALG_ID_Print(\"hashAlg\", in->hashAlg, indent);\n    return;\n}\nvoid HMAC_In_Print(HMAC_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_HMAC\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"handle\", in->handle, indent);\n    TSS_TPM2B_Print(\"buffer\", indent, &in->buffer.b);\n    TSS_TPM_ALG_ID_Print(\"hashAlg\", in->hashAlg, indent);\n    return;\n}\nvoid HashSequenceStart_In_Print(HashSequenceStart_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_HashSequenceStart\\n\", indent, \"\");\n    TSS_TPM2B_Print(\"auth\", indent, &in->auth.b);\n    TSS_TPM_ALG_ID_Print(\"hashAlg\", in->hashAlg, indent);\n    return;\n}\nvoid Hash_In_Print(Hash_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Hash\\n\", indent, \"\");\n    TSS_TPM2B_Print(\"data\", indent, &in->data.b);\n    TSS_TPM_ALG_ID_Print(\"hashAlg\", in->hashAlg, indent);\n    TSS_TPM_HANDLE_Print(\"hierarchy\", in->hierarchy, indent);\n    return;\n}\nvoid HierarchyChangeAuth_In_Print(HierarchyChangeAuth_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_HierarchyChangeAuth\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM2B_Print(\"newAuth\", indent, &in->newAuth.b);\n    return;\n}\nvoid HierarchyControl_In_Print(HierarchyControl_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_HierarchyControl\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"enable\", in->enable, indent);\n    TSS_TPMI_YES_NO_Print(\"state\", in->state, indent);\n    return;\n}\nvoid Import_In_Print(Import_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Import\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"parentHandle\", in->parentHandle, indent);\n    TSS_TPM2B_Print(\"encryptionKey\", indent, &in->encryptionKey.b);\n    TSS_TPM2B_PUBLIC_Print(\"objectPublic\", &in->objectPublic, indent);\n    TSS_TPM2B_Print(\"duplicate\", indent, &in->duplicate.b);\n    TSS_TPM2B_Print(\"inSymSeed\", indent, &in->inSymSeed.b);\n    printf(\"%*s\" \"symmetricAlg\\n\", indent, \"\");\n    TSS_TPMT_SYM_DEF_OBJECT_Print(&in->symmetricAlg, indent);\n    return;\n}\nvoid IncrementalSelfTest_In_Print(IncrementalSelfTest_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_IncrementalSelfTest\\n\", indent, \"\");\n    TSS_TPML_ALG_Print(&in->toTest, indent);\n    return;\n}\nvoid LoadExternal_In_Print(LoadExternal_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_LoadExternal\\n\", indent, \"\");\n    if (in->inPrivate.t.size != 0) {\t/* if there is a private area */\n\tTSS_TPMT_SENSITIVE_Print(&in->inPrivate.t.sensitiveArea, indent);\n    }\n    TSS_TPM2B_PUBLIC_Print(\"inPublic\", &in->inPublic, indent);\n    TSS_TPM_HANDLE_Print(\"hierarchy\", in->hierarchy, indent);\n    return;\n}\nvoid Load_In_Print(Load_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Load\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"parentHandle\", in->parentHandle, indent);\n    TSS_TPM2B_Print(\"inPrivate\", indent, &in->inPrivate.b);\n    TSS_TPM2B_PUBLIC_Print(\"inPublic\", &in->inPublic, indent);\n    return;\n}\nvoid MakeCredential_In_Print(MakeCredential_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_MakeCredential\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"handle\", in->handle, indent);\n    TSS_TPM2B_Print(\"credential\", indent, &in->credential.b);\n    TSS_TPM2B_Print(\"objectName\", indent, &in->objectName.b);\n    return;\n}\n#if 0\nvoid NTC2_PreConfig_In_Print(NTC2_PreConfig_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NTC2_PreConfig\\n\", indent, \"\");\n    NTC2_CFG_STRUCT preConfig;\n    return;\n}\n#endif\nvoid NV_Certify_In_Print(NV_Certify_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_Certify\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"signHandle\", in->signHandle, indent);\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    TSS_TPM2B_Print(\"qualifyingData\", indent, &in->qualifyingData.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent);\n    printf(\"%*s\" \"size %u\\n\", indent, \"\", in->size);\n    printf(\"%*s\" \"offset %u\\n\", indent, \"\", in->offset);\n    return;\n}\nvoid NV_ChangeAuth_In_Print(NV_ChangeAuth_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_ChangeAuth\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    TSS_TPM2B_Print(\"newAuth\", indent, &in->newAuth.b);\n    return;\n}\nvoid NV_DefineSpace_In_Print(NV_DefineSpace_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_DefineSpace\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM2B_Print(\"auth\", indent, &in->auth.b);\n    printf(\"%*s\" \"publicInfo\\n\", indent, \"\");\n    TSS_TPM2B_NV_PUBLIC_Print(&in->publicInfo, indent);\n    return;\n}\nvoid NV_Extend_In_Print(NV_Extend_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_Extend\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    TSS_TPM2B_Print(\"data\", indent, &in->data.b);\n    return;\n}\nvoid NV_GlobalWriteLock_In_Print(NV_GlobalWriteLock_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_GlobalWriteLock\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    return;\n}\nvoid NV_Increment_In_Print(NV_Increment_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_Increment\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    return;\n}\nvoid NV_ReadLock_In_Print(NV_ReadLock_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_ReadLock\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    return;\n}\nvoid NV_ReadPublic_In_Print(NV_ReadPublic_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_ReadPublic\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    return;\n}\nvoid NV_Read_In_Print(NV_Read_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_Read\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    printf(\"%*s\" \"size %u\\n\", indent, \"\", in->size);\n    printf(\"%*s\" \"offset %u\\n\", indent, \"\", in->offset);\n    return;\n}\nvoid NV_SetBits_In_Print(NV_SetBits_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_SetBits\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    printf(\"%*s\" \"bits %016\"PRIx64\"\\n\", indent, \"\", in->bits);\n    return;\n}\nvoid NV_UndefineSpaceSpecial_In_Print(NV_UndefineSpaceSpecial_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_UndefineSpaceSpecial\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    TSS_TPM_HANDLE_Print(\"platform\", in->platform, indent);\n    return;\n}\nvoid NV_UndefineSpace_In_Print(NV_UndefineSpace_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_UndefineSpace\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    return;\n}    \nvoid NV_WriteLock_In_Print(NV_WriteLock_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_WriteLock\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    return;\n}\nvoid NV_Write_In_Print(NV_Write_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_NV_Write\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    TSS_TPM2B_Print(\"data\", indent, &in->data.b);\n    printf(\"%*s\" \"offset %u\\n\", indent, \"\", in->offset);\n    return;\n}\nvoid ObjectChangeAuth_In_Print(ObjectChangeAuth_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ObjectChangeAuth\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"objectHandle\", in->objectHandle, indent);\n    TSS_TPM_HANDLE_Print(\"parentHandle\", in->parentHandle, indent);\n    TSS_TPM2B_Print(\"newAuth\", indent, &in->newAuth.b);\n    return;\n}\nvoid PCR_Allocate_In_Print(PCR_Allocate_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PCR_Allocate\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPML_PCR_SELECTION_Print(&in->pcrAllocation, indent);\n    return;\n}\nvoid PCR_Event_In_Print(PCR_Event_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PCR_Event\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"pcrHandle\", in->pcrHandle, indent);\n    TSS_TPM2B_Print(\"eventData\", indent, &in->eventData.b);\n    return;\n}\nvoid PCR_Extend_In_Print(PCR_Extend_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PCR_Extend\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"pcrHandle\", in->pcrHandle, indent);\n    TSS_TPML_DIGEST_VALUES_Print(&in->digests, indent);\n    return;\n}\nvoid PCR_Read_In_Print(PCR_Read_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PCR_Read\\n\", indent, \"\");\n    TSS_TPML_PCR_SELECTION_Print(&in->pcrSelectionIn, indent);\n    return;\n}\nvoid PCR_Reset_In_Print(PCR_Reset_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PCR_Reset\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"pcrHandle\", in->pcrHandle, indent);\n    return;\n}\nvoid PCR_SetAuthPolicy_In_Print(PCR_SetAuthPolicy_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PCR_SetAuthPolicy\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM2B_Print(\"authPolicy\", indent, &in->authPolicy.b);\n    TSS_TPM_ALG_ID_Print(\"hashAlg\", in->hashAlg, indent);\n    TSS_TPM_HANDLE_Print(\"pcrNum\", in->pcrNum, indent);\n    return;\n}\nvoid PCR_SetAuthValue_In_Print(PCR_SetAuthValue_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PCR_SetAuthValue\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"pcrHandle\", in->pcrHandle, indent);\n    TSS_TPM2B_Print(\"auth\", indent, &in->auth.b);\n    return;\n}\nvoid PP_Commands_In_Print(PP_Commands_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PP_Commands\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"auth\", in->auth, indent);\n    TSS_TPML_CC_Print(&in->setList, indent);\n    TSS_TPML_CC_Print(&in->clearList, indent);\n    return;\n}\nvoid PolicyAuthValue_In_Print(PolicyAuthValue_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyAuthValue\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    return;\n}\nvoid PolicyAuthorizeNV_In_Print(PolicyAuthorizeNV_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyAuthorizeNV\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    return;\n}\nvoid PolicyAuthorize_In_Print(PolicyAuthorize_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyAuthorize\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"approvedPolicy\", indent, &in->approvedPolicy.b);\n    TSS_TPM2B_Print(\"policyRef\", indent, &in->policyRef.b);\n    TSS_TPM2B_Print(\"keySign\", indent, &in->keySign.b);\n    printf(\"%*s\" \"checkTicket\\n\", indent, \"\");\n    TSS_TPMT_TK_VERIFIED_Print(&in->checkTicket, indent+2);\n    return;\n}\nvoid PolicyCommandCode_In_Print(PolicyCommandCode_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyCommandCode\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM_CC_Print(\"code\", in->code, indent);\n    return;\n}\nvoid PolicyCounterTimer_In_Print(PolicyCounterTimer_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyCounterTimer\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"operandB\", indent, &in->operandB.b);\n    printf(\"%*s\" \"offset %u\\n\", indent, \"\", in->offset);\n    TSS_TPM_EO_Print(\"operation\", in->operation, indent);\n    return;\n}\nvoid PolicyCpHash_In_Print(PolicyCpHash_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyCpHash\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"cpHashA\", indent, &in->cpHashA.b);\n    return;\n}\nvoid PolicyDuplicationSelect_In_Print(PolicyDuplicationSelect_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyDuplicationSelect\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"objectName\", indent, &in->objectName.b);\n    TSS_TPM2B_Print(\"newParentName\", indent, &in->newParentName.b);\n    TSS_TPMI_YES_NO_Print(\"includeObject\", in->includeObject, indent);\n    return;\n}\nvoid PolicyGetDigest_In_Print(PolicyGetDigest_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyGetDigest\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    return;\n}\nvoid PolicyLocality_In_Print(PolicyLocality_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyLocality\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPMA_LOCALITY_Print(in->locality, indent);\n    return;\n}\nvoid PolicyNV_In_Print(PolicyNV_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyNV\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"nvIndex\", in->nvIndex, indent);\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"operandB\", indent, &in->operandB.b);\n    printf(\"%*s\" \"offset %u\\n\", indent, \"\", in->offset);\n    TSS_TPM_EO_Print(\"operation\", in->operation, indent);\n    return;\n}\nvoid PolicyNameHash_In_Print(PolicyNameHash_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyNameHash\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"nameHash\", indent, &in->nameHash.b);\n    return;\n}\nvoid PolicyNvWritten_In_Print(PolicyNvWritten_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyNvWritten\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPMI_YES_NO_Print(\"writtenSet\", in->writtenSet, indent);\n    return;\n}\nvoid PolicyOR_In_Print(PolicyOR_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyOR\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    printf(\"%*s\" \"pHashList\\n\", indent, \"\");\n    TSS_TPML_DIGEST_Print(&in->pHashList, indent+2);\n    return;\n}\nvoid PolicyPCR_In_Print(PolicyPCR_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyPCR\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"pcrDigest\", indent, &in->pcrDigest.b);\n    TSS_TPML_PCR_SELECTION_Print(&in->pcrs, indent);\n    return;\n}\nvoid PolicyPassword_In_Print(PolicyPassword_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyPassword\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    return;\n}\nvoid PolicyPhysicalPresence_In_Print(PolicyPhysicalPresence_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyPhysicalPresence\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    return;\n}\nvoid PolicyRestart_In_Print(PolicyRestart_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyRestart\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"sessionHandle\", in->sessionHandle, indent);\n    return;\n}\nvoid PolicySecret_In_Print(PolicySecret_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicySecret\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"nonceTPM\", indent, &in->nonceTPM.b);\n    TSS_TPM2B_Print(\"cpHashA\", indent, &in->cpHashA.b);\n    TSS_TPM2B_Print(\"policyRef\", indent, &in->policyRef.b);\n    printf(\"%*s\" \"expiration %d\\n\", indent, \"\", in->expiration);\n    return;\n}\nvoid PolicySigned_In_Print(PolicySigned_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicySigned\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authObject\", in->authObject, indent);\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"nonceTPM\", indent, &in->nonceTPM.b);\n    TSS_TPM2B_Print(\"cpHashA\", indent, &in->cpHashA.b);\n    TSS_TPM2B_Print(\"policyRef\", indent, &in->policyRef.b);\n    printf(\"%*s\" \"expiration %d\\n\", indent, \"\", in->expiration);\n    printf(\"%*s\" \"auth\\n\", indent, \"\");\n    TSS_TPMT_SIGNATURE_Print(&in->auth, indent+2);\n    return;\n}\nvoid PolicyTemplate_In_Print(PolicyTemplate_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyTemplate\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"templateHash\", indent, &in->templateHash.b);\n    return;\n}\nvoid PolicyCapability_In_Print(PolicyCapability_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyCapability\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"operandB\", indent, &in->operandB.b);\n    TSS_TPM_EO_Print(\"operation\", in->operation, indent);\n    printf(\"%*s\" \"offset %u\\n\", indent, \"\", in->offset);\n    TSS_TPM_CAP_Print(\"capability\", in->capability, indent);\n    printf(\"%*s\" \"property %08x\\n\", indent, \"\", in->property);\n   return;\n}\nvoid PolicyParameters_In_Print(PolicyParameters_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyParameters\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"pHash\", indent, &in->pHash.b);\n    return;\n}\nvoid PolicyTicket_In_Print(PolicyTicket_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_PolicyTicket\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"policySession\", in->policySession, indent);\n    TSS_TPM2B_Print(\"timeout\", indent, &in->timeout.b);\n    TSS_TPM2B_Print(\"cpHashA\", indent, &in->cpHashA.b);\n    TSS_TPM2B_Print(\"policyRef\", indent, &in->policyRef.b);\n    TSS_TPM2B_Print(\"authName\", indent, &in->authName.b);\n    printf(\"%*s\" \"ticket\\n\", indent, \"\");\n    TSS_TPMT_TK_AUTH_Print(&in->ticket, indent+2);\n    return;\n}\nvoid Quote_In_Print(Quote_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Quote\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"signHandle\", in->signHandle, indent);\n    TSS_TPM2B_Print(\"qualifyingData\", indent, &in->qualifyingData.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent);\n    TSS_TPML_PCR_SELECTION_Print(&in->PCRselect, indent);\n    return;\n}\nvoid RSA_Decrypt_In_Print(RSA_Decrypt_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_RSA_Decrypt\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"keyHandle\", in->keyHandle, indent);\n    TSS_TPM2B_Print(\"cipherText\", indent, &in->cipherText.b); \n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_RSA_DECRYPT_Print(&in->inScheme, indent);\n    TSS_TPM2B_Print(\"label\", indent, &in->label.b);\n    return;\n}\nvoid RSA_Encrypt_In_Print(RSA_Encrypt_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_RSA_Encrypt\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"keyHandle\", in->keyHandle, indent);\n    TSS_TPM2B_Print(\"message\", indent, &in->message.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_RSA_DECRYPT_Print(&in->inScheme, indent);\n    TSS_TPM2B_Print(\"label\", indent, &in->label.b);\n    return;\n}\nvoid ReadPublic_In_Print(ReadPublic_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ReadPublic\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"objectHandle\", in->objectHandle, indent);\n    return;\n}\nvoid Rewrap_In_Print(Rewrap_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Rewrap\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"oldParent\", in->oldParent, indent);\n    TSS_TPM_HANDLE_Print(\"newParent\", in->newParent, indent);\n    TSS_TPM2B_Print(\"inDuplicate\", indent, &in->inDuplicate.b);\n    TSS_TPM2B_Print(\"name\", indent, &in->name.b);\n    TSS_TPM2B_Print(\"inSymSeed\", indent, &in->inSymSeed.b);\n    return;\n}\nvoid SelfTest_In_Print(SelfTest_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_SelfTest\\n\", indent, \"\");\n    TSS_TPMI_YES_NO_Print(\"fullTest\", in->fullTest, indent);\n    return;\n}\nvoid SequenceComplete_In_Print(SequenceComplete_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_SequenceComplete\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"sequenceHandle\", in->sequenceHandle, indent);\n    TSS_TPM2B_Print(\"buffer\", indent, &in->buffer.b);\n    TSS_TPM_HANDLE_Print(\"hierarchy\", in->hierarchy, indent);\n    return;\n}\nvoid SequenceUpdate_In_Print(SequenceUpdate_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_SequenceUpdate\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"sequenceHandle\", in->sequenceHandle, indent);\n    TSS_TPM2B_Print(\"buffer\", indent, &in->buffer.b);\n    return;\n}\nvoid SetAlgorithmSet_In_Print(SetAlgorithmSet_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_SetAlgorithmSet\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    printf(\"%*s\" \"algorithmSet %08x\\n\", indent, \"\", in->algorithmSet);\n    return;\n}\nvoid SetCommandCodeAuditStatus_In_Print(SetCommandCodeAuditStatus_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_SetCommandCodeAuditStatus\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"auth\", in->auth, indent);\n    TSS_TPM_ALG_ID_Print(\"auditAlg\", in->auditAlg, indent);\n    TSS_TPML_CC_Print(&in->setList, indent);\n    TSS_TPML_CC_Print(&in->clearList, indent);\n    return;\n}\nvoid SetPrimaryPolicy_In_Print(SetPrimaryPolicy_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_SetPrimaryPolicy\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"authHandle\", in->authHandle, indent);\n    TSS_TPM2B_Print(\"authPolicy\", indent, &in->authPolicy.b);\n    TSS_TPM_ALG_ID_Print(\"hashAlg\", in->hashAlg, indent);\n    return;\n}\nvoid Shutdown_In_Print(Shutdown_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Shutdown\\n\", indent, \"\");\n    TSS_TPM_SU_Print(\"shutdownType\", in->shutdownType, indent);\n    return;\n}\nvoid Sign_In_Print(Sign_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Sign\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"keyHandle\", in->keyHandle, indent);\n    TSS_TPM2B_Print(\"digest\", indent, &in->digest.b);\n    printf(\"%*s\" \"inScheme\\n\", indent, \"\");\n    TSS_TPMT_SIG_SCHEME_Print(&in->inScheme, indent);\n    printf(\"%*s\" \"validation\\n\", indent, \"\");\n    TSS_TPMT_TK_HASHCHECK_Print(&in->validation, indent+2);\n    return;\n}\nvoid StartAuthSession_In_Print(StartAuthSession_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_StartAuthSession\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"tpmKey\", in->tpmKey, indent);\n    TSS_TPM_HANDLE_Print(\"bind\", in->bind, indent);\n    TSS_TPM2B_Print(\"nonceCaller\", indent, &in->nonceCaller.b);\n    TSS_TPM2B_Print(\"encryptedSalt\", indent, &in->encryptedSalt.b);\n    TSS_TPM_SE_Print(\"sessionType\", in->sessionType, indent);\n    TSS_TPMT_SYM_DEF_Print(&in->symmetric, indent);\n    TSS_TPM_ALG_ID_Print(\"authHash\", in->authHash, indent);\n    return;\n}\nvoid Startup_In_Print(Startup_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Startup\\n\", indent, \"\");\n    TSS_TPM_SU_Print(\"startupType\", in->startupType, indent);\n    return;\n}\nvoid StirRandom_In_Print(StirRandom_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_StirRandom\\n\", indent, \"\");\n    TSS_TPM2B_Print(\"inData\", indent, &in->inData.b);\n    return;\n}\nvoid TestParms_In_Print(TestParms_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_TestParms\\n\", indent, \"\");\n    TSS_TPMT_PUBLIC_PARMS_Print(&in->parameters, indent);\n    return;\n}\nvoid Unseal_In_Print(Unseal_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_Unseal\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"itemHandle\", in->itemHandle, indent);\n    return;\n}\nvoid VerifySignature_In_Print(VerifySignature_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_VerifySignature\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"keyHandle\", in->keyHandle, indent);\n    TSS_TPM2B_Print(\"digest\", indent, &in->digest.b);\n    printf(\"%*s\" \"signature\\n\", indent, \"\");\n    TSS_TPMT_SIGNATURE_Print(&in->signature, indent);\n    return;\n}\nvoid ZGen_2Phase_In_Print(ZGen_2Phase_In *in, unsigned int indent)\n{\n    printf(\"%*s\" \"TPM2_ZGen_2Phase\\n\", indent, \"\");\n    TSS_TPM_HANDLE_Print(\"keyA\", in->keyA, indent);\n    TSS_TPM2B_ECC_POINT_Print(\"inQsB\", &in->inQsB, indent);\n    TSS_TPM2B_ECC_POINT_Print(\"inQsB\", &in->inQeB, indent);\n    TSS_TPM_ALG_ID_Print(\"inScheme\", in->inScheme, indent);\n    printf(\"%*s\" \"counter %u\\n\", indent, \"\", in->counter);\n    return;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssproperties.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    TSS Configuration Properties\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>\n#include <errno.h>\n#include <stdio.h>\n#include <stdlib.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tsstransmit.h>\n#ifndef TPM_TSS_NOCRYPTO\n#include <ibmtss/tsscrypto.h>\n#endif\n#include <ibmtss/tssprint.h>\n\n#include \"tssproperties.h\"\n\n/* For systems where there are no environment variables, GETENV returns NULL.  This simulates the\n   situation when an environment variable is not set, causing the compiled in default to be used. */\n#ifndef TPM_TSS_NOENV\n#define GETENV(x) getenv(x)\n#else\n#define GETENV(x) NULL\n#endif\n\n/* local prototypes */\n\nstatic TPM_RC TSS_SetTraceLevel(const char *value);\nstatic TPM_RC TSS_SetDataDirectory(TSS_CONTEXT *tssContext, const char *value);\nstatic TPM_RC TSS_SetCommandPort(TSS_CONTEXT *tssContext, const char *value);\nstatic TPM_RC TSS_SetPlatformPort(TSS_CONTEXT *tssContext, const char *value);\nstatic TPM_RC TSS_SetServerName(TSS_CONTEXT *tssContext, const char *value);\nstatic TPM_RC TSS_SetServerType(TSS_CONTEXT *tssContext, const char *value);\nstatic TPM_RC TSS_SetInterfaceType(TSS_CONTEXT *tssContext, const char *value);\nstatic TPM_RC TSS_SetDevice(TSS_CONTEXT *tssContext, const char *value);\nstatic TPM_RC TSS_SetEncryptSessions(TSS_CONTEXT *tssContext, const char *value);\nstatic TPM_RC TSS_SetLocality(TSS_CONTEXT *tssContext, const char *value);\n\n/* globals for the library */\n\n/* tracing is global to avoid passing the context into every function call */\nint tssVerbose = TRUE;\t\t/* initial value so TSS_Properties_Init errors emit message */\nint tssVverbose = FALSE;\n\n/* This is a total hack to ensure that the global verbose flags are only set once.  It's used by the\n   two entry points to the TSS, TSS_Create() and TSS_SetProperty() */\n\nint tssFirstCall = TRUE;\n\n/* defaults for global settings */\n\n#ifndef TPM_TRACE_LEVEL_DEFAULT \t\n#define TPM_TRACE_LEVEL_DEFAULT \t\"0\"\n#endif\n\n#ifndef TPM_COMMAND_PORT_DEFAULT\n#define TPM_COMMAND_PORT_DEFAULT \t\"2321\"\t\t/* default for MS simulator */\n#endif\n\n#ifndef TPM_PLATFORM_PORT_DEFAULT\n#define TPM_PLATFORM_PORT_DEFAULT \t\"2322\"\t\t/* default for MS simulator */\n#endif\n\n#ifndef TPM_SERVER_NAME_DEFAULT\n#define TPM_SERVER_NAME_DEFAULT\t\t\"localhost\"\t/* default to local machine */\n#endif\n\n#ifndef TPM_SERVER_TYPE_DEFAULT\n#define TPM_SERVER_TYPE_DEFAULT\t\t\"mssim\"\t\t/* default to MS simulator format */\n#endif\n\n#ifndef TPM_DATA_DIR_DEFAULT\n#define TPM_DATA_DIR_DEFAULT\t\t\".\"\t\t/* default to current working directory */\n#endif\n\n#ifndef TPM_INTERFACE_TYPE_DEFAULT\n#ifndef TPM_NOSOCKET\n#define TPM_INTERFACE_TYPE_DEFAULT\t\"socsim\"\t/* default to MS simulator interface */\n#else\n#define TPM_INTERFACE_TYPE_DEFAULT\t\"dev\"\t\t/* if no sockets, default to device driver */\n#endif\n#endif\n\n#ifndef TPM_DEVICE_DEFAULT\n#ifdef TPM_POSIX\n#define TPM_DEVICE_DEFAULT\t\t\"/dev/tpm0\"\t/* default to Linux device driver */\n#endif\n#ifdef TPM_WINDOWS\n#define TPM_DEVICE_DEFAULT\t\t\"tddl.dll\"\t/* default to Windows TPM interface dll */\n#endif\n#endif\n\n// #define TPM_INTERFACE_FTPM\n#ifdef  TPM_INTERFACE_FTPM\n#define TPM_DEVICE_DEFAULT\t\t\"/dev/ftpm\"\n#endif\n\n\n#ifndef TPM_ENCRYPT_SESSIONS_DEFAULT\n#define TPM_ENCRYPT_SESSIONS_DEFAULT\t\"1\"\n#endif\n\n#ifndef TPM_TRANSMIT_LOCALITY_DEFAULT\n#define TPM_TRANSMIT_LOCALITY_DEFAULT\t\"0\"\t\t/* socket interface supports a locality byte */\n#endif\n\n/* TSS_GlobalProperties_Init() sets the global verbose trace flags at the first entry points to the\n   TSS */\n\nTPM_RC TSS_GlobalProperties_Init(void)\n{\n    TPM_RC\t\trc = 0;\n    const char \t\t*value;\n\n    /* trace level is global, tssContext can be null */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_TRACE_LEVEL\");\n\trc = TSS_SetTraceLevel(value);\n    }\n    return rc;\n}\n\n\n/* TSS_Properties_Init() sets the initial TSS_CONTEXT properties based on either the environment\n   variables (if set) or the defaults (if not).\n*/\n\nTPM_RC TSS_Properties_Init(TSS_CONTEXT *tssContext)\n{\n    TPM_RC\t\trc = 0;\n    const char \t\t*value;\n\n    if (rc == 0) {\n\ttssContext->tssAuthContext = NULL;\n\ttssContext->tssFirstTransmit = TRUE;\t/* connection not opened */\n\ttssContext->tpm12Command = FALSE;\n#ifdef TPM_WINDOWS\n\ttssContext->sock_fd = INVALID_SOCKET;\n#endif\n#ifdef TPM_POSIX\n#ifndef TPM_NOSOCKET\n\ttssContext->sock_fd = -1;\n#endif \t/* TPM_NOSOCKET */\n\ttssContext->dev_fd = -1;\n#endif\t/* TPM_POSIX */\n\n\ttssContext->locality = 0;\n\n#ifdef TPM_SKIBOOT\n\ttssContext->tpm_driver = NULL;\n\ttssContext->tpm_device = NULL;\n#endif /* TPM_SKIBOOT */\n\t\n#ifndef TPM_TSS_NOCRYPTO\n#ifndef TPM_TSS_NOFILE\n\ttssContext->tssSessionEncKey = NULL;\n\ttssContext->tssSessionDecKey = NULL;\n#endif\n#endif\n    }\n    /* for a minimal TSS with no file support */\n#ifdef TPM_TSS_NOFILE\n    {\n\tsize_t i;\n\tfor (i = 0 ; i < (sizeof(tssContext->sessions) / sizeof(TSS_SESSIONS)) ; i++) {\n\t    tssContext->sessions[i].sessionHandle = TPM_RH_NULL;\n\t    tssContext->sessions[i].sessionData = NULL;\n\t    tssContext->sessions[i].sessionDataLength = 0;\n\t}\n\tfor (i = 0 ; i < (sizeof(tssContext->objectPublic) / sizeof(TSS_OBJECT_PUBLIC)) ; i++) {\n\t    tssContext->objectPublic[i].objectHandle = TPM_RH_NULL;\n\t}\n\tfor (i = 0 ; i < (sizeof(tssContext->nvPublic) / sizeof(TSS_NVPUBLIC)) ; i++) {\n\t    tssContext->nvPublic[i].nvIndex = TPM_RH_NULL;\n\t}\n    }\n#endif\n    /* data directory */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_DATA_DIR\");\n\trc = TSS_SetDataDirectory(tssContext, value);\n    }\n    /* flag whether session state should be encrypted */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_ENCRYPT_SESSIONS\");\n\trc = TSS_SetEncryptSessions(tssContext, value);\n    }\n    /* TPM socket command port */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_COMMAND_PORT\");\n\trc = TSS_SetCommandPort(tssContext, value);\n    }\n    /* TPM simulator socket platform port */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_PLATFORM_PORT\");\n\trc = TSS_SetPlatformPort(tssContext, value);\n    }\n    /* TPM socket host name */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_SERVER_NAME\");\n\trc = TSS_SetServerName(tssContext, value);\n    }\n    /* TPM socket server type */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_SERVER_TYPE\");\n\trc = TSS_SetServerType(tssContext, value);\n    }\n    /* TPM interface type */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_INTERFACE_TYPE\");\n\trc = TSS_SetInterfaceType(tssContext, value);\n    }\n    /* TPM device within the interface type */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_DEVICE\");\n\trc = TSS_SetDevice(tssContext, value);\n    }\n    /* TPM device within the interface type */\n    if (rc == 0) {\n\tvalue = GETENV(\"TPM_TRANSMIT_LOCALITY\");\n\trc = TSS_SetLocality(tssContext, value);\n    }\n    return rc;\n}\n\n/* TSS_SetProperty() sets the property to the value.\n\n   The format of the property and value the same as that of the environment variable.\n\n   A NULL value sets the property to the default.\n*/\n\nTPM_RC TSS_SetProperty(TSS_CONTEXT *tssContext,\n\t\t       int property,\n\t\t       const char *value)\n{\n    TPM_RC\t\trc = 0;\n\n    /* at the first call to the TSS, initialize global variables */\n    if (tssFirstCall) {\n#ifndef TPM_TSS_NOCRYPTO\n\t/* crypto module initializations */\n\tif (rc == 0) {\n\t    rc = TSS_Crypto_Init();\n\t}\n#endif\n\tif (rc == 0) {\n\t    rc = TSS_GlobalProperties_Init();\n\t}\n\ttssFirstCall = FALSE;\n    }\n    if (rc == 0) {\n\tswitch (property) {\n\t  case TPM_TRACE_LEVEL:\n\t    rc = TSS_SetTraceLevel(value);\n\t    break;\n\t  case TPM_DATA_DIR:\n\t    rc = TSS_SetDataDirectory(tssContext, value);\n\t    break;\n\t  case TPM_COMMAND_PORT:\t\n\t    rc = TSS_SetCommandPort(tssContext, value);\n\t    break;\n\t  case TPM_PLATFORM_PORT:\t\n\t    rc = TSS_SetPlatformPort(tssContext, value);\n\t    break;\n\t  case TPM_SERVER_NAME:\t\t\n\t    rc = TSS_SetServerName(tssContext, value);\n\t    break;\n\t  case TPM_SERVER_TYPE:\t\t\n\t    rc = TSS_SetServerType(tssContext, value);\n\t    break;\n\t  case TPM_INTERFACE_TYPE:\n\t    rc = TSS_SetInterfaceType(tssContext, value);\n\t    break;\n\t  case TPM_DEVICE:\n\t    rc = TSS_SetDevice(tssContext, value);\n\t    break;\n\t  case TPM_ENCRYPT_SESSIONS:\n\t    rc = TSS_SetEncryptSessions(tssContext, value);\n\t    break;\n\t  case TPM_TRANSMIT_LOCALITY:\n\t    rc = TSS_SetLocality(tssContext, value);\n\t    break;\n\t  default:\n\t    rc = TSS_RC_BAD_PROPERTY;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_SetTraceLevel() sets the trace level.\n\n   0:\tno printing\n   1:\terror printing\n   2:\ttrace printing\n*/\n\nstatic TPM_RC TSS_SetTraceLevel(const char *value)\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tirc = 0;\n    int \t\tlevel;\n\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_TRACE_LEVEL_DEFAULT;\n\t}\n    }\n#if !defined(__ULTRAVISOR__) && !defined(TPM_SKIBOOT)\n    if (rc == 0) {\n\tirc = sscanf(value, \"%u\", &level);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_SetTraceLevel: Error, value invalid\\n\");\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    /* disable tracing within the ultravisor and skiboot, which doesn't implement sscanf() anyway */\n#else\n    irc = irc;\n    level = 0;\n#endif\n    if (rc == 0) {\n\tswitch (level) {\n\t  case 0:\n\t    tssVerbose = FALSE;\n\t    tssVverbose = FALSE;\n\t    break;\n\t  case 1:\n\t    tssVerbose = TRUE;\n\t    tssVverbose = FALSE;\n\t    break;\n\t  default:\n\t    tssVerbose = TRUE;\n\t    tssVverbose = TRUE;\n\t    break;\n\t}\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_SetDataDirectory(TSS_CONTEXT *tssContext, const char *value)\n{\n    TPM_RC\t\trc = 0;\n\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_DATA_DIR_DEFAULT;\n\t}\n    }\n    if (rc == 0) {\n\ttssContext->tssDataDirectory = value;\n\t/* appended to this is 17 characters /cccnnnnnnnn.bin[nul], add a bit of margin for future\n\t   prefixes */\n\tif (strlen(value) > (TPM_DATA_DIR_PATH_LENGTH - 24)) {\n\t    if (tssVerbose) printf(\"TSS_SetDataDirectory: Error, value too long\\n\");\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_SetCommandPort(TSS_CONTEXT *tssContext, const char *value)\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tirc = 0;\n\n    /* close an open connection before changing property */\n    if (rc == 0) {\n\trc = TSS_Close(tssContext);\n    }\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_COMMAND_PORT_DEFAULT;\n\t}\n    }\n#ifndef TPM_NOSOCKET\n    if (rc == 0) {\n\tirc = sscanf(value, \"%hu\", &tssContext->tssCommandPort);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_SetCommandPort: Error, value invalid\\n\");\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n#else\n    tssContext->tssCommandPort = 0;\n    irc = irc;\n#endif /* TPM_NOSOCKET */\n    return rc;\n}\n\nstatic TPM_RC TSS_SetPlatformPort(TSS_CONTEXT *tssContext, const char *value)\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tirc = 0;\n\n    /* close an open connection before changing property */\n    if (rc == 0) {\n\trc = TSS_Close(tssContext);\n    }\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_PLATFORM_PORT_DEFAULT;\n\t}\n    }\n#ifndef TPM_NOSOCKET\n   if (rc == 0) {\n\tirc = sscanf(value, \"%hu\", &tssContext->tssPlatformPort);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_SetPlatformPort: Error, , value invalid\\n\");\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n#else\n   tssContext->tssPlatformPort = 0;\n    irc = irc;\n#endif /* TPM_NOSOCKET */\n    return rc;\n}\n\nstatic TPM_RC TSS_SetServerName(TSS_CONTEXT *tssContext, const char *value)\n{\n    TPM_RC\t\trc = 0;\n\n    /* close an open connection before changing property */\n    if (rc == 0) {\n\trc = TSS_Close(tssContext);\n    }\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_SERVER_NAME_DEFAULT;\n\t}\n    }\n    if (rc == 0) {\n\ttssContext->tssServerName = value;\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_SetServerType(TSS_CONTEXT *tssContext, const char *value)\n{\n    TPM_RC\t\trc = 0;\n\n    /* close an open connection before changing property */\n    if (rc == 0) {\n\trc = TSS_Close(tssContext);\n    }\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_SERVER_TYPE_DEFAULT;\n\t}\n    }\n    if (rc == 0) {\n\ttssContext->tssServerType = value;\n    }\n    return rc;\n}\n\nstatic TPM_RC TSS_SetInterfaceType(TSS_CONTEXT *tssContext, const char *value)\n{\n    TPM_RC\t\trc = 0;\n\n    /* close an open connection before changing property */\n    if (rc == 0) {\n\trc = TSS_Close(tssContext);\n    }\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_INTERFACE_TYPE_DEFAULT;\n\t}\n    }\n    if (rc == 0) {\n\ttssContext->tssInterfaceType = value;\n    }\n    // printf(\"[TSS] TSS_SetInterfaceType(): %s\\n\", value);\n    return rc;\n}\n\nstatic TPM_RC TSS_SetDevice(TSS_CONTEXT *tssContext, const char *value)\n{\n    TPM_RC\t\trc = 0;\n\n    /* close an open connection before changing property */\n    if (rc == 0) {\n\trc = TSS_Close(tssContext);\n    }\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_DEVICE_DEFAULT;\n\t}\n    }\n    if (rc == 0) {\n\ttssContext->tssDevice = value;\n    }\n    // printf(\"[TSS] TSS_SetDevice(): %s\\n\", value);\n    return rc;\n}\n\nstatic TPM_RC TSS_SetEncryptSessions(TSS_CONTEXT *tssContext, const char *value)\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tirc = 0;\n\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_ENCRYPT_SESSIONS_DEFAULT;\n\t}\n    }\n#ifndef TPM_TSS_NOFILE\n   if (rc == 0) {\n\tirc = sscanf(value, \"%u\", &tssContext->tssEncryptSessions);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_SetEncryptSessions: Error, value invalid\\n\");\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n    }\n#else\n   tssContext->tssEncryptSessions = TRUE;\n   irc = irc;\n#endif /* TPM_TSS_NOFILE */\n   return rc;\n}\n\nstatic TPM_RC TSS_SetLocality(TSS_CONTEXT *tssContext, const char *value)\n{\n    TPM_RC\t\trc = 0;\n    int\t\t\tirc = 0;\n\n    if (rc == 0) {\n\tif (value == NULL) {\n\t    value = TPM_TRANSMIT_LOCALITY_DEFAULT;\n\t}\n    }\n    if (rc == 0) {\n\tint tmpint;\n\tirc = sscanf(value, \"%u\", &tmpint);\n\tif (irc != 1) {\n\t    if (tssVerbose) printf(\"TSS_SetLocality: Error, value invalid\\n\");\n\t    rc = TSS_RC_BAD_PROPERTY_VALUE;\n\t}\n\telse {\n\t    tssContext->locality = tmpint;\n\t}\n    }\n    return rc;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssresponsecode.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t     TPM2 Response Code Printer\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#ifndef TPM_TSS_NO_PRINT\n\n#include <stdint.h>\n#include <stdlib.h>\n\n#ifdef TPM_WINDOWS\n#ifdef TPM_WINDOWS_TBSI\n#include <winsock2.h>\n#include <windows.h>\n#include <tbs.h>\n#endif  /* TPM_WINDOWS_TBSI */\n#endif\t/* TPM_WINDOWS */\n\n\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsserror.h>\n#ifdef TPM_TPM12\n#include <ibmtss/tsserror12.h>\n#endif\n#include <ibmtss/tssprint.h>\n\n/* The intended usage is:\n\n   const char *msg;\n   const char *submsg;\n   const char *num;\n\n   TSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\n   printf(\"%s%s%s\\n\", msg, submsg, num);\n*/\n\n/* 39.4\tResponse Code Details */\n\n/* tables to map response code to text */\n\ntypedef struct {\n    TPM_RC rc;\n    const char *text;\n} RC_TABLE;\n\n#ifdef TPM_TPM12\nconst RC_TABLE tpm12Table [] = {\n\n    {TPM_AUTHFAIL, \"TPM 1.2 TPM_AUTHFAIL - Authentication failed\"},\n    {TPM_BADINDEX, \"TPM 1.2 TPM_BADINDEX - The index to a PCR, DIR or other register is incorrect\"},\n    {TPM_BAD_PARAMETER, \"TPM 1.2 TPM_BAD_PARAMETER - One or more parameter is bad\"},\n    {TPM_AUDITFAILURE, \"TPM 1.2 TPM_AUDITFAILURE - An operation completed successfully but the auditing of that operation failed. \"},\n    {TPM_CLEAR_DISABLED, \"TPM 1.2 TPM_CLEAR_DISABLED - The clear disable flag is set and all clear operations now require physical access\"},\n    {TPM_DEACTIVATED, \"TPM 1.2 TPM_DEACTIVATED - The TPM is deactivated\"},\n    {TPM_DISABLED, \"TPM 1.2 TPM_DISABLED - The TPM is disabled\"},\n    {TPM_DISABLED_CMD, \"TPM 1.2 TPM_DISABLED_CMD - The target command has been disabled\"},\n    {TPM_FAIL, \"TPM 1.2 TPM_FAIL - The operation failed\"},\n    {TPM_BAD_ORDINAL, \"TPM 1.2 TPM_BAD_ORDINAL - The ordinal was unknown or inconsistent\"},\n    {TPM_INSTALL_DISABLED, \"TPM 1.2 TPM_INSTALL_DISABLED - The ability to install an owner is disabled\"},\n    {TPM_INVALID_KEYHANDLE, \"TPM 1.2 TPM_INVALID_KEYHANDLE - The key handle presented was invalid\"},\n    {TPM_KEYNOTFOUND, \"TPM 1.2 TPM_KEYNOTFOUND - The target key was not found\"},\n    {TPM_INAPPROPRIATE_ENC, \"TPM 1.2 TPM_INAPPROPRIATE_ENC - Unacceptable encryption scheme\"},\n    {TPM_MIGRATEFAIL, \"TPM 1.2 TPM_MIGRATEFAIL - Migration authorization failed\"},\n    {TPM_INVALID_PCR_INFO, \"TPM 1.2 TPM_INVALID_PCR_INFO - PCR information could not be interpreted\"},\n    {TPM_NOSPACE, \"TPM 1.2 TPM_NOSPACE - No room to load key. \"},\n    {TPM_NOSRK, \"TPM 1.2 TPM_NOSRK - There is no SRK set\"},\n    {TPM_NOTSEALED_BLOB, \"TPM 1.2 TPM_NOTSEALED_BLOB - An encrypted blob is invalid or was not created by this TPM\"},\n    {TPM_OWNER_SET, \"TPM 1.2 TPM_OWNER_SET - There is already an Owner\"},\n    {TPM_RESOURCES, \"TPM 1.2 TPM_RESOURCES - The TPM has insufficient internal resources to perform the requested action. \"},\n    {TPM_SHORTRANDOM, \"TPM 1.2 TPM_SHORTRANDOM - A random string was too short\"},\n    {TPM_SIZE, \"TPM 1.2 TPM_SIZE - The TPM does not have the space to perform the operation.\"},\n    {TPM_WRONGPCRVAL, \"TPM 1.2 TPM_WRONGPCRVAL - The named PCR value does not match the current PCR value.\"},\n    {TPM_BAD_PARAM_SIZE, \"TPM 1.2 TPM_BAD_PARAM_SIZE - The paramSize argument to the command has the incorrect value\"},\n    {TPM_SHA_THREAD, \"TPM 1.2 TPM_SHA_THREAD - There is no existing SHA-1 thread. \"},\n    {TPM_SHA_ERROR, \"TPM 1.2 TPM_SHA_ERROR - The calculation is unable to proceed because the existing SHA-1 thread has already encountered an error. \"},\n    {TPM_FAILEDSELFTEST, \"TPM 1.2 TPM_FAILEDSELFTEST - Self-test has failed and the TPM has shutdown. \"},\n    {TPM_AUTH2FAIL, \"TPM 1.2 TPM_AUTH2FAIL - The authorization for the second key in a 2 key function failed authorization\"},\n    {TPM_BADTAG, \"TPM 1.2 TPM_BADTAG - The tag value sent to the TPM for a command is invalid\"},\n    {TPM_IOERROR, \"TPM 1.2 TPM_IOERROR - An IO error occurred transmitting information to the TPM\"},\n    {TPM_ENCRYPT_ERROR, \"TPM 1.2 TPM_ENCRYPT_ERROR - The encryption process had a problem. \"},\n    {TPM_DECRYPT_ERROR, \"TPM 1.2 TPM_DECRYPT_ERROR - The decryption process did not complete. \"},\n    {TPM_INVALID_AUTHHANDLE, \"TPM 1.2 TPM_INVALID_AUTHHANDLE - An invalid handle was used. \"},\n    {TPM_NO_ENDORSEMENT, \"TPM 1.2 TPM_NO_ENDORSEMENT - The TPM does not a EK installed\"},\n    {TPM_INVALID_KEYUSAGE, \"TPM 1.2 TPM_INVALID_KEYUSAGE - The usage of a key is not allowed\"},\n    {TPM_WRONG_ENTITYTYPE, \"TPM 1.2 TPM_WRONG_ENTITYTYPE - The submitted entity type is not allowed\"},\n    {TPM_INVALID_POSTINIT, \"TPM 1.2 TPM_INVALID_POSTINIT - The command was received in the wrong sequence relative to TPM_Init and a subsequent TPM_Startup\"},\n    {TPM_INAPPROPRIATE_SIG, \"TPM 1.2 TPM_INAPPROPRIATE_SIG - Signed data cannot include additional DER information\"},\n    {TPM_BAD_KEY_PROPERTY, \"TPM 1.2 TPM_BAD_KEY_PROPERTY - The key properties in TPM_KEY_PARMs are not supported by this TPM\"},\n    {TPM_BAD_MIGRATION, \"TPM 1.2 TPM_BAD_MIGRATION - The migration properties of this key are incorrect.\"},\n    {TPM_BAD_SCHEME, \"TPM 1.2 TPM_BAD_SCHEME - The signature or encryption scheme for this key is incorrect or not permitted in this situation. \"},\n    {TPM_BAD_DATASIZE, \"TPM 1.2 TPM_BAD_DATASIZE - The size of the data (or blob) parameter is bad or inconsistent with the referenced key\"},\n    {TPM_BAD_MODE, \"TPM 1.2 TPM_BAD_MODE - A mode parameter is bad, such as capArea or subCapArea for TPM_GetCapability, physicalPresence parameter for TPM_PhysicalPresence, or migrationType for TPM_CreateMigrationBlob. \"},\n    {TPM_BAD_PRESENCE, \"TPM 1.2 TPM_BAD_PRESENCE- Either the physicalPresence or physicalPresenceLock bits have the wrong value\"},\n    {TPM_BAD_VERSION, \"TPM 1.2 TPM_BAD_VERSION - The TPM cannot perform this version of the capability\"},\n    {TPM_NO_WRAP_TRANSPORT, \"TPM 1.2 TPM_NO_WRAP_TRANSPORT - The TPM does not allow for wrapped transport sessions\"},\n    {TPM_AUDITFAIL_UNSUCCESSFUL, \"TPM 1.2 TPM_AUDITFAIL_UNSUCCESSFUL - TPM audit construction failed and the underlying command was returning a failure also\"},\n    {TPM_AUDITFAIL_SUCCESSFUL, \"TPM 1.2 TPM_AUDITFAIL_SUCCESSFUL - TPM audit construction failed and the underlying command was returning success\"},\n    {TPM_NOTRESETABLE, \"TPM 1.2 TPM_NOTRESETABLE - Attempt to reset a PCR register that does not have the resettable attribute\"},\n    {TPM_NOTLOCAL, \"TPM 1.2 TPM_NOTLOCAL - Attempt to reset a PCR register that requires locality and locality modifier not part of command transport\"},\n    {TPM_BAD_TYPE, \"TPM 1.2 TPM_BAD_TYPE - Make identity blob not properly typed\"},\n    {TPM_INVALID_RESOURCE, \"TPM 1.2 TPM_INVALID_RESOURCE - When saving context identified resource type does not match actual resource\"},\n    {TPM_NOTFIPS, \"TPM 1.2 TPM_NOTFIPS - The TPM is attempting to execute a command only available when in FIPS mode\"},\n    {TPM_INVALID_FAMILY, \"TPM 1.2 TPM_INVALID_FAMILY - The command is attempting to use an invalid family ID\"},\n    {TPM_NO_NV_PERMISSION, \"TPM 1.2 TPM_NO_NV_PERMISSION - The permission to manipulate the NV storage is not available\"},\n    {TPM_REQUIRES_SIGN, \"TPM 1.2 TPM_REQUIRES_SIGN - The operation requires a signed command\"},\n    {TPM_KEY_NOTSUPPORTED, \"TPM 1.2 TPM_KEY_NOTSUPPORTED - Wrong operation to load an NV key\"},\n    {TPM_AUTH_CONFLICT, \"TPM 1.2 TPM_AUTH_CONFLICT - NV_DefineSpace requires both owner and blob authorization\"},\n    {TPM_AREA_LOCKED, \"TPM 1.2 TPM_AREA_LOCKED - The NV area is locked and not writable\"},\n    {TPM_BAD_LOCALITY, \"TPM 1.2 TPM_BAD_LOCALITY - The locality is incorrect for the attempted operation\"},\n    {TPM_READ_ONLY, \"TPM 1.2 TPM_READ_ONLY - The NV area is read only and can't be written to  \"},\n    {TPM_PER_NOWRITE, \"TPM 1.2 TPM_PER_NOWRITE - There is no protection on the write to the NV area  \"},\n    {TPM_FAMILYCOUNT, \"TPM 1.2 TPM_FAMILYCOUNT - The family count value does not match\"},\n    {TPM_WRITE_LOCKED, \"TPM 1.2 TPM_WRITE_LOCKED - The NV area has already been written to\"},\n    {TPM_BAD_ATTRIBUTES, \"TPM 1.2 TPM_BAD_ATTRIBUTES - The NV area attributes conflict\"},\n    {TPM_INVALID_STRUCTURE, \"TPM 1.2 TPM_INVALID_STRUCTURE - The structure tag and version are invalid or inconsistent\"},\n    {TPM_KEY_OWNER_CONTROL, \"TPM 1.2 TPM_KEY_OWNER_CONTROL - The key is under control of the TPM Owner and can only be evicted by the TPM Owner. \"},\n    {TPM_BAD_COUNTER, \"TPM 1.2 TPM_BAD_COUNTER - The counter handle is incorrect\"},\n    {TPM_NOT_FULLWRITE, \"TPM 1.2 TPM_NOT_FULLWRITE - The write is not a complete write of the area\"},\n    {TPM_CONTEXT_GAP, \"TPM 1.2 TPM_CONTEXT_GAP - The gap between saved context counts is too large  \"},\n    {TPM_MAXNVWRITES, \"TPM 1.2 TPM_MAXNVWRITES - The maximum number of NV writes without an owner has been exceeded\"},\n    {TPM_NOOPERATOR, \"TPM 1.2 TPM_NOOPERATOR - No operator authorization value is set\"},\n    {TPM_RESOURCEMISSING, \"TPM 1.2 TPM_RESOURCEMISSING - The resource pointed to by context is not loaded  \"},\n    {TPM_DELEGATE_LOCK, \"TPM 1.2 TPM_DELEGATE_LOCK - The delegate administration is locked\"},\n    {TPM_DELEGATE_FAMILY, \"TPM 1.2 TPM_DELEGATE_FAMILY - Attempt to manage a family other then the delegated family\"},\n    {TPM_DELEGATE_ADMIN, \"TPM 1.2 TPM_DELEGATE_ADMIN - Delegation table management not enabled\"},\n    {TPM_TRANSPORT_NOTEXCLUSIVE, \"TPM 1.2 TPM_TRANSPORT_NOTEXCLUSIVE - There was a command executed outside of an exclusive transport session\"},\n    {TPM_OWNER_CONTROL, \"TPM 1.2 TPM_OWNER_CONTROL - Attempt to context save a owner evict controlled key\"},\n    {TPM_DAA_RESOURCES, \"TPM 1.2 TPM_DAA_RESOURCES - The DAA command has no resources available to execute the command\"},\n    {TPM_DAA_INPUT_DATA0, \"TPM 1.2 TPM_DAA_INPUT_DATA0 - The consistency check on DAA parameter inputData0 has failed.\"},\n    {TPM_DAA_INPUT_DATA1, \"TPM 1.2 TPM_DAA_INPUT_DATA1 - The consistency check on DAA parameter inputData1 has failed.\"},\n    {TPM_DAA_ISSUER_SETTINGS, \"TPM 1.2 TPM_DAA_ISSUER_SETTINGS - The consistency check on DAA_issuerSettings has failed.\"},\n    {TPM_DAA_TPM_SETTINGS, \"TPM 1.2 TPM_DAA_TPM_SETTINGS - The consistency check on DAA_tpmSpecific has failed.\"},\n    {TPM_DAA_STAGE, \"TPM 1.2 TPM_DAA_STAGE - The atomic process indicated by the submitted DAA command is not the expected process.\"},\n    {TPM_DAA_ISSUER_VALIDITY, \"TPM 1.2 TPM_DAA_ISSUER_VALIDITY - The issuer's validity check has detected an inconsistency\"},\n    {TPM_DAA_WRONG_W, \"TPM 1.2 TPM_DAA_WRONG_W - The consistency check on w has failed.\"},\n    {TPM_BAD_HANDLE, \"TPM 1.2 TPM_BAD_HANDLE - The handle is incorrect\"},\n    {TPM_BAD_DELEGATE, \"TPM 1.2 TPM_BAD_DELEGATE - Delegation is not correct\"},\n    {TPM_BADCONTEXT, \"TPM 1.2 TPM_BADCONTEXT - The context blob is invalid\"},\n    {TPM_TOOMANYCONTEXTS, \"TPM 1.2 TPM_TOOMANYCONTEXTS - Too many contexts held by the TPM\"},\n    {TPM_MA_TICKET_SIGNATURE, \"TPM 1.2 TPM_MA_TICKET_SIGNATURE - Migration authority signature validation failure  \"},\n    {TPM_MA_DESTINATION, \"TPM 1.2 TPM_MA_DESTINATION - Migration destination not authenticated\"},\n    {TPM_MA_SOURCE, \"TPM 1.2 TPM_MA_SOURCE - Migration source incorrect\"},\n    {TPM_MA_AUTHORITY, \"TPM 1.2 TPM_MA_AUTHORITY - Incorrect migration authority\"},\n    {TPM_PERMANENTEK, \"TPM 1.2 TPM_PERMANENTEK - Attempt to revoke the EK and the EK is not revocable\"},\n    {TPM_BAD_SIGNATURE, \"TPM 1.2 TPM_BAD_SIGNATURE - Bad signature of CMK ticket \"},\n    {TPM_NOCONTEXTSPACE, \"TPM 1.2 TPM_NOCONTEXTSPACE - There is no room in the context list for additional contexts\"},\n    {TPM_RETRY, \"TPM 1.2 TPM_RETRY - The TPM is too busy to respond to the command immediately, but the command could be submitted at a later time\"},\n    {TPM_NEEDS_SELFTEST, \"TPM 1.2 TPM_NEEDS_SELFTEST - TPM_ContinueSelfTest has has not been run\"},\n    {TPM_DOING_SELFTEST, \"TPM 1.2 TPM_DOING_SELFTEST - The TPM is currently executing the actions of TPM_ContinueSelfTest because the ordinal required resources that have not been tested.\"},\n    {TPM_DEFEND_LOCK_RUNNING, \"TPM 1.2 TPM_DEFEND_LOCK_RUNNING - The TPM is defending against dictionary attacks and is in some time-out period.\"},\n\n};\n#endif\t/*  TPM_TPM12 */\n\nstatic const char *TSS_ResponseCode_RcToText(const RC_TABLE *table, size_t tableSize, TPM_RC rc);\nstatic const char *TSS_ResponseCode_NumberToText(unsigned int num);\n\nconst RC_TABLE ver1Table [] = {\n    {TPM_RC_INITIALIZE, \"TPM_RC_INITIALIZE - TPM not initialized by TPM2_Startup or already initialized\"},\n    {TPM_RC_FAILURE, \"TPM_RC_FAILURE - commands not being accepted because of a TPM failure\"},\n    {TPM_RC_SEQUENCE, \"TPM_RC_SEQUENCE - improper use of a sequence handle\"},\n    {TPM_RC_PRIVATE, \"TPM_RC_PRIVATE - not currently used\"},\n    {TPM_RC_HMAC, \"TPM_RC_HMAC - HMAC failure\"},\n    {TPM_RC_DISABLED, \"TPM_RC_DISABLED - the command is disabled\"},\n    {TPM_RC_EXCLUSIVE, \"TPM_RC_EXCLUSIVE - command failed because audit sequence required exclusivity\"},\n    {TPM_RC_AUTH_TYPE, \"TPM_RC_AUTH_TYPE - authorization handle is not correct for command\"},\n    {TPM_RC_AUTH_MISSING, \"TPM_RC_AUTH_MISSING - command requires an authorization session\"},\n    {TPM_RC_POLICY, \"TPM_RC_POLICY - policy failure in math operation or an invalid authPolicy value\"},\n    {TPM_RC_PCR, \"TPM_RC_PCR - PCR check fail\"},\n    {TPM_RC_PCR_CHANGED, \"TPM_RC_PCR_CHANGED - PCR have changed since checked.\"},\n    {TPM_RC_UPGRADE, \"TPM_RC_UPGRADE - TPM is in field upgrade mode\"},\n    {TPM_RC_TOO_MANY_CONTEXTS, \"TPM_RC_TOO_MANY_CONTEXTS - context ID counter is at maximum.\"},\n    {TPM_RC_AUTH_UNAVAILABLE, \"TPM_RC_AUTH_UNAVAILABLE - authValue or authPolicy is not available for selected entity.\"},\n    {TPM_RC_REBOOT, \"TPM_RC_REBOOT - a _TPM_Init and Startup(CLEAR) is required\"},\n    {TPM_RC_UNBALANCED, \"TPM_RC_UNBALANCED - the protection algorithms (hash and symmetric) are not reasonably balanced\"},\n    {TPM_RC_COMMAND_SIZE, \"TPM_RC_COMMAND_SIZE - command commandSize value is inconsistent with contents of the command buffer\"},\n    {TPM_RC_COMMAND_CODE, \"TPM_RC_COMMAND_CODE - command code not supported\"},\n    {TPM_RC_AUTHSIZE, \"TPM_RC_AUTHSIZE - the value of authorizationSize is out of range\"},\n    {TPM_RC_AUTH_CONTEXT, \"TPM_RC_AUTH_CONTEXT - use of an authorization session with a command that cannot have an authorization session\"},\n    {TPM_RC_NV_RANGE, \"TPM_RC_NV_RANGE - NV offset+size is out of range.\"},\n    {TPM_RC_NV_SIZE, \"TPM_RC_NV_SIZE - Requested allocation size is larger than allowed.\"},\n    {TPM_RC_NV_LOCKED, \"TPM_RC_NV_LOCKED - NV access locked.\"},\n    {TPM_RC_NV_AUTHORIZATION, \"TPM_RC_NV_AUTHORIZATION - NV access authorization fails\"},\n    {TPM_RC_NV_UNINITIALIZED, \"TPM_RC_NV_UNINITIALIZED - an NV Index is used before being initialized\"},\n    {TPM_RC_NV_SPACE, \"TPM_RC_NV_SPACE - insufficient space for NV allocation\"},\n    {TPM_RC_NV_DEFINED, \"TPM_RC_NV_DEFINED - NV Index or persistent object already defined\"},\n    {TPM_RC_BAD_CONTEXT, \"TPM_RC_BAD_CONTEXT - context in TPM2_ContextLoad() is not valid\"},\n    {TPM_RC_CPHASH, \"TPM_RC_CPHASH - cpHash value already set or not correct for use\"},\n    {TPM_RC_PARENT, \"TPM_RC_PARENT - handle for parent is not a valid parent\"},\n    {TPM_RC_NEEDS_TEST, \"TPM_RC_NEEDS_TEST - some function needs testing.\"},\n    {TPM_RC_NO_RESULT, \"TPM_RC_NO_RESULT - internal function cannot process a request due to an unspecified problem.\"},\n    {TPM_RC_SENSITIVE, \"TPM_RC_SENSITIVE - the sensitive area did not unmarshal correctly after decryption\"},\n};\n\n/* RC_FMT1 response code to text */\n\nconst RC_TABLE fmt1Table [] = {\n    {TPM_RC_ASYMMETRIC, \"TPM_RC_ASYMMETRIC - asymmetric algorithm not supported or not correct\"},\n    {TPM_RC_ATTRIBUTES, \"TPM_RC_ATTRIBUTES - inconsistent attributes\"},\n    {TPM_RC_HASH, \"TPM_RC_HASH - hash algorithm not supported or not appropriate\"},\n    {TPM_RC_VALUE, \"TPM_RC_VALUE - value is out of range or is not correct for the context\"},\n    {TPM_RC_HIERARCHY, \"TPM_RC_HIERARCHY - hierarchy is not enabled or is not correct for the use\"},\n    {TPM_RC_KEY_SIZE, \"TPM_RC_KEY_SIZE - key size is not supported\"},\n    {TPM_RC_MGF, \"TPM_RC_MGF - mask generation function not supported\"},\n    {TPM_RC_MODE, \"TPM_RC_MODE - mode of operation not supported\"},\n    {TPM_RC_TYPE, \"TPM_RC_TYPE - the type of the value is not appropriate for the use\"},\n    {TPM_RC_HANDLE, \"TPM_RC_HANDLE - the handle is not correct for the use\"},\n    {TPM_RC_KDF, \"TPM_RC_KDF - unsupported key derivation function or function not appropriate for use\"},\n    {TPM_RC_RANGE, \"TPM_RC_RANGE - value was out of allowed range.\"},\n    {TPM_RC_AUTH_FAIL, \"TPM_RC_AUTH_FAIL - the authorization HMAC check failed and DA counter incremented\"},\n    {TPM_RC_NONCE, \"TPM_RC_NONCE - invalid nonce size or nonce value mismatch\"},\n    {TPM_RC_PP, \"TPM_RC_PP - authorization requires assertion of PP\"},\n    {TPM_RC_SCHEME, \"TPM_RC_SCHEME - unsupported or incompatible scheme\"},\n    {TPM_RC_SIZE, \"TPM_RC_SIZE - structure is the wrong size\"},\n    {TPM_RC_SYMMETRIC, \"TPM_RC_SYMMETRIC - unsupported symmetric algorithm or key size, or not appropriate for instance\"},\n    {TPM_RC_TAG, \"TPM_RC_TAG - incorrect structure tag\"},\n    {TPM_RC_SELECTOR, \"TPM_RC_SELECTOR - union selector is incorrect\"},\n    {TPM_RC_INSUFFICIENT, \"TPM_RC_INSUFFICIENT - the TPM was unable to unmarshal a value because there were not enough octets in the input buffer\"},\n    {TPM_RC_SIGNATURE, \"TPM_RC_SIGNATURE - the signature is not valid\"},\n    {TPM_RC_KEY, \"TPM_RC_KEY - key fields are not compatible with the selected use\"},\n    {TPM_RC_POLICY_FAIL, \"TPM_RC_POLICY_FAIL - a policy check failed\"},\n    {TPM_RC_INTEGRITY, \"TPM_RC_INTEGRITY - integrity check failed\"},\n    {TPM_RC_TICKET, \"TPM_RC_TICKET - invalid ticket\"},\n    {TPM_RC_RESERVED_BITS, \"TPM_RC_RESERVED_BITS - reserved bits not set to zero as required\"},\n    {TPM_RC_BAD_AUTH, \"TPM_RC_BAD_AUTH - authorization failure without DA implications\"},\n    {TPM_RC_EXPIRED, \"TPM_RC_EXPIRED - the policy has expired\"},\n    {TPM_RC_POLICY_CC, \"TPM_RC_POLICY_CC - the commandCode in the policy is not the commandCode of the command\"},\n    {TPM_RC_BINDING, \"TPM_RC_BINDING - public and sensitive portions of an object are not cryptographically bound\"},\n    {TPM_RC_CURVE, \"TPM_RC_CURVE - curve not supported\t\"},\n    {TPM_RC_ECC_POINT, \"TPM_RC_ECC_POINT - point is not on the required curve.\"},\n};\n\n/* RC_WARN response code to text */\n\nconst RC_TABLE warnTable [] = {\n    {TPM_RC_CONTEXT_GAP, \"TPM_RC_CONTEXT_GAP - gap for context ID is too large\"},\n    {TPM_RC_OBJECT_MEMORY, \"TPM_RC_OBJECT_MEMORY - out of memory for object contexts\"},\n    {TPM_RC_SESSION_MEMORY, \"TPM_RC_SESSION_MEMORY - out of memory for session contexts\"},\n    {TPM_RC_MEMORY, \"TPM_RC_MEMORY - out of shared object/session memory or need space for internal operations\"},\n    {TPM_RC_SESSION_HANDLES, \"TPM_RC_SESSION_HANDLES - out of session handles - a session must be flushed before a new session may be created\"},\n    {TPM_RC_OBJECT_HANDLES, \"TPM_RC_OBJECT_HANDLES - out of object handles - the handle space for objects is depleted and a reboot is required\"},\n    {TPM_RC_LOCALITY, \"TPM_RC_LOCALITY - bad locality\"},\n    {TPM_RC_YIELDED, \"TPM_RC_YIELDED - the TPM has suspended operation on the command; forward progress was made and the command may be retried.\"},\n    {TPM_RC_CANCELED, \"TPM_RC_CANCELED - the command was canceled\"},\n    {TPM_RC_TESTING, \"TPM_RC_TESTING - TPM is performing self-tests\"},\n    {TPM_RC_REFERENCE_H0, \"TPM_RC_REFERENCE_H0 - the 1st handle in the handle area references a transient object or session that is not loaded\"},\n    {TPM_RC_REFERENCE_H1, \"TPM_RC_REFERENCE_H1 - the 2nd handle in the handle area references a transient object or session that is not loaded\"},\n    {TPM_RC_REFERENCE_H2, \"TPM_RC_REFERENCE_H2 - the 3rd handle in the handle area references a transient object or session that is not loaded\"},\n    {TPM_RC_REFERENCE_H3, \"TPM_RC_REFERENCE_H3 - the 4th handle in the handle area references a transient object or session that is not loaded\"},\n    {TPM_RC_REFERENCE_H4, \"TPM_RC_REFERENCE_H4 - the 5th handle in the handle area references a transient object or session that is not loaded\"},\n    {TPM_RC_REFERENCE_H5, \"TPM_RC_REFERENCE_H5 - the 6th handle in the handle area references a transient object or session that is not loaded\"},\n    {TPM_RC_REFERENCE_H6, \"TPM_RC_REFERENCE_H6 - the 7th handle in the handle area references a transient object or session that is not loaded\"},\n    {TPM_RC_REFERENCE_S0, \"TPM_RC_REFERENCE_S0 - the 1st authorization session handle references a session that is not loaded\"},\n    {TPM_RC_REFERENCE_S1, \"TPM_RC_REFERENCE_S1 - the 2nd authorization session handle references a session that is not loaded\"},\n    {TPM_RC_REFERENCE_S2, \"TPM_RC_REFERENCE_S2 - the 3rd authorization session handle references a session that is not loaded\"},\n    {TPM_RC_REFERENCE_S3, \"TPM_RC_REFERENCE_S3 - the 4th authorization session handle references a session that is not loaded\"},\n    {TPM_RC_REFERENCE_S4, \"TPM_RC_REFERENCE_S4 - the 5th session handle references a session that is not loaded\"},\n    {TPM_RC_REFERENCE_S5, \"TPM_RC_REFERENCE_S5 - the 6th session handle references a session that is not loaded\"},\n    {TPM_RC_REFERENCE_S6, \"TPM_RC_REFERENCE_S6 - the 7th authorization session handle references a session that is not loaded\"},\n    {TPM_RC_NV_RATE, \"TPM_RC_NV_RATE - the TPM is rate-limiting accesses to prevent wearout of NV\"},\n    {TPM_RC_LOCKOUT, \"TPM_RC_LOCKOUT - authorizations for objects subject to DA protection are not allowed at this time because the TPM is in DA lockout mode\"},\n    {TPM_RC_RETRY, \"TPM_RC_RETRY - the TPM was not able to start the command\"},\n    {TPM_RC_NV_UNAVAILABLE, \"the command may require writing of NV and NV is not current accessible\"}, \n    {TPM_RC_NOT_USED, \"TPM_RC_NOT_USED - this value is reserved and shall not be returned by the TPM\"},\n};\n    \n/* parameter and handle number to text */\n\nconst char *num_table [] = {\n    \"unspecified\",\n    \"1\",\n    \"2\",\n    \"3\",\n    \"4\",\n    \"5\",\n    \"6\",\n    \"7\",\n    \"8\",\n    \"9\",\n    \"10\",\n    \"11\",\n    \"12\",\n    \"13\",\n    \"14\",\n    \"15\"\n};\n\n/* from tsserror.h */\n\nconst RC_TABLE tssTable [] = {\n    {TSS_RC_OUT_OF_MEMORY, \"TSS_RC_OUT_OF_MEMORY - Out of memory (malloc failed)\"},\n    {TSS_RC_ALLOC_INPUT, \"TSS_RC_ALLOC_INPUT - The input to an allocation is not NULL\"},\n    {TSS_RC_MALLOC_SIZE, \"TSS_RC_MALLOC_SIZE - The malloc size is too large or zero\"},\n    {TSS_RC_INSUFFICIENT_BUFFER, \"TSS_RC_INSUFFICIENT_BUFFER - A buffer was insufficient for a copy\"},\n    {TSS_RC_BAD_PROPERTY, \"TSS_RC_BAD_PROPERTY - The property parameter is out of range\"},\n    {TSS_RC_BAD_PROPERTY_VALUE, \"TSS_RC_BAD_PROPERTY_VALUE - The property value is invalid\"},\n    {TSS_RC_INSUPPORTED_INTERFACE, \"TSS_RC_INSUPPORTED_INTERFACE - The TPM interface type is not supported\"},\n    {TSS_RC_NO_CONNECTION, \"TSS_RC_NO_CONNECTION - Failure connecting to lower layer\"},\n    {TSS_RC_BAD_CONNECTION, \"TSS_RC_BAD_CONNECTION - Failure communicating with lower layer\"},\n    {TSS_RC_MALFORMED_RESPONSE, \"TSS_RC_MALFORMED_RESPONSE - A response packet was fundamentally malformed\"},\n    {TSS_RC_NULL_PARAMETER, \"TSS_RC_NULL_PARAMETER - A required parameter was NULL\"},\n    {TSS_RC_NOT_IMPLEMENTED, \"TSS_RC_NOT_IMPLEMENTED - TSS function is not implemented\"},\n    {TSS_RC_BAD_READ_VALUE, \"TSS_RC_BAD_READ_VALUE - Actual read value different from expected\"},\n    {TSS_RC_FILE_OPEN, \"TSS_RC_FILE_OPEN - The file could not be opened\"},\n    {TSS_RC_FILE_SEEK, \"TSS_RC_FILE_SEEK - A file seek failed\"},\n    {TSS_RC_FILE_FTELL, \"TSS_RC_FILE_FTELL - A file ftell failed\"},\n    {TSS_RC_FILE_READ, \"TSS_RC_FILE_READ - A file read failed\"},\n    {TSS_RC_FILE_CLOSE, \"TSS_RC_FILE_CLOSE - A file close failed\"},\n    {TSS_RC_FILE_WRITE, \"TSS_RC_FILE_WRITE - A file write failed\"},\n    {TSS_RC_FILE_REMOVE, \"TSS_RC_FILE_REMOVE - A file remove failed\"},\n    {TSS_RC_RNG_FAILURE, \"TSS_RC_RNG_FAILURE - The random number generator failed\"},\n    {TSS_RC_BAD_PWAP_NONCE, \"TSS_RC_BAD_PWAP_NONCE - Bad PWAP response nonce\"},\n    {TSS_RC_BAD_PWAP_ATTRIBUTES, \"TSS_RC_BAD_PWAP_ATTRIBUTES - Bad PWAP response attributes\"},\n    {TSS_RC_BAD_PWAP_HMAC, \"TSS_RC_BAD_PWAP_HMAC - Bad PWAP response HMAC\"},\n    {TSS_RC_NAME_NOT_IMPLEMENTED, \"TSS_RC_NAME_NOT_IMPLEMENTED - name calculation not implemented for handle type\"},\n    {TSS_RC_MALFORMED_NV_PUBLIC, \"TSS_RC_MALFORMED_NV_PUBLIC - The NV public structure does not match the name\"},\n    {TSS_RC_NAME_FILENAME, \"TSS_RC_NAME_FILENAME - The name filename function has inconsistent arguments\"},\n    {TSS_RC_MALFORMED_PUBLIC, \"TSS_RC_MALFORMED_PUBLIC -The public structure does not match the name\"},\n    {TSS_RC_DECRYPT_SESSIONS, \"TSS_RC_DECRYPT_SESSIONS - More than one command decrypt session\"},\n    {TSS_RC_ENCRYPT_SESSIONS, \"TSS_RC_ENCRYPT_SESSIONS - More than one response encrypt session\"},\n    {TSS_RC_NO_DECRYPT_PARAMETER, \"TSS_RC_NO_DECRYPT_PARAMETER - Command has no decrypt parameter\"},\n    {TSS_RC_NO_ENCRYPT_PARAMETER, \"TSS_RC_NO_ENCRYPT_PARAMETER - Respnse has no encrypt parameter\"},\n    {TSS_RC_BAD_DECRYPT_ALGORITHM, \"TSS_RC_BAD_DECRYPT_ALGORITHM - Session had an unimplemented decrypt symmetric algorithm\"},\n    {TSS_RC_BAD_ENCRYPT_ALGORITHM, \"TSS_RC_BAD_ENCRYPT_ALGORITHM - Session had an unimplemented encrypt symmetric algorithm\"},\n    {TSS_RC_AES_ENCRYPT_FAILURE, \"TSS_RC_AES_ENCRYPT_FAILURE - AES encryption failed\"},\n    {TSS_RC_AES_DECRYPT_FAILURE, \"TSS_RC_AES_DECRYPT_FAILURE - AES decryption failed\\n\"\n     \"\\tIf using command line utilities, set env variable TPM_ENCRYPT_SESSIONS to 0\\n\"\n     \"\\tor see TSS manual for more options\"},\n    {TSS_RC_BAD_ENCRYPT_SIZE, \"TSS_RC_BAD_ENCRYPT_SIZE - Parameter encryption size mismatch\"},\n    {TSS_RC_AES_KEYGEN_FAILURE, \"TSS_RC_AES_KEYGEN_FAILURE - AES key generation failed\"},\n    {TSS_RC_SESSION_NUMBER, \"TSS_RC_SESSION_NUMBER - session number out of range\"},\n    {TSS_RC_BAD_SALT_KEY, \"TSS_RC_BAD_SALT_KEY - Key is unsuitable for salt\"},\n    {TSS_RC_KDFA_FAILED, \"TSS_RC_KDFA_FAILED - KDFa function failed\"},\n    {TSS_RC_HMAC, \"TSS_RC_HMAC -  An HMAC calculation failed\"},\n    {TSS_RC_HMAC_SIZE, \"TSS_RC_HMAC_SIZE - nse HMAC is the wrong size\"},\n    {TSS_RC_HMAC_VERIFY, \"TSS_RC_HMAC_VERIFY - MAC does not verify\"},\n    {TSS_RC_BAD_HASH_ALGORITHM, \"TSS_RC_BAD_HASH_ALGORITHM - Unimplemented hash algorithm\"},\n    {TSS_RC_HASH, \"TSS_RC_HASH - A hash calculation failed\"},\n    {TSS_RC_RSA_KEY_CONVERT, \"TSS_RC_RSA_KEY_CONVERT - RSA key conversion failed\"},\n    {TSS_RC_RSA_PADDING, \"TSS_RC_RSA_PADDING - RSA add padding failed\"},\n    {TSS_RC_RSA_ENCRYPT, \"TSS_RC_RSA_ENCRYPT - RSA public encrypt failed\"},\n    {TSS_RC_BIGNUM, \"TSS_RC_BIGNUM - NUM operation failed\"},\n    {TSS_RC_RSA_SIGNATURE, \"TSS_RC_RSA_SIGNATURE - RSA signature is bad\"},\n    {TSS_RC_EC_SIGNATURE, \"TSS_RC_EC_SIGNATURE - EC signature is bad\"},\n    {TSS_RC_EC_KEY_CONVERT, \"TSS_RC_EC_KEY_CONVERT - EC key conversion failed\"},\n    {TSS_RC_X509_ERROR, \"TSS_RC_X509_ERROR - X509 parse error\"},\n    {TSS_RC_PEM_ERROR, \"TSS_RC_PEM_ERROR - PEM parse error\"},\n    {TSS_RC_BAD_SIGNATURE_ALGORITHM, \"TSS_RC_BAD_SIGNATURE_ALGORITHM - Unimplemented signature algorithm\"},\n    {TSS_RC_COMMAND_UNIMPLEMENTED, \"TSS_RC_COMMAND_UNIMPLEMENTED - Unimplemented command\"},\n    {TSS_RC_IN_PARAMETER, \"TSS_RC_IN_PARAMETER - Bad in parameter to TSS_Execute\"},\n    {TSS_RC_OUT_PARAMETER, \"TSS_RC_OUT_PARAMETER - Bad out parameter to TSS_Execute\"},\n    {TSS_RC_BAD_HANDLE_NUMBER, \"TSS_RC_BAD_HANDLE_NUMBER - Bad handle number for this command\"},\n    {TSS_RC_KDFE_FAILED, \"TSS_RC_KDFE_FAILED - KDFe function failed\"},\n    {TSS_RC_EC_EPHEMERAL_FAILURE, \"TSS_RC_EC_EPHEMERAL_FAILURE - Failed while making or using EC ephemeral key\"},\n    {TSS_RC_FAIL, \"TSS_RC_FAIL - TSS internal failure\"},\n    {TSS_RC_NO_SESSION_SLOT, \"TSS_RC_NO_SESSION_SLOT - TSS context has no session slot for handle\"},\n    {TSS_RC_NO_OBJECTPUBLIC_SLOT, \"TSS_RC_NO_OBJECTPUBLIC_SLOT - TSS context has no object public slot for handle\"},\n    {TSS_RC_NO_NVPUBLIC_SLOT, \"TSS_RC_NO_NVPUBLIC_SLOT -TSS context has no NV public slot for handle\"},\n};\n\n#ifdef TPM_WINDOWS\n#ifdef TPM_WINDOWS_TBSI\n\n/* Windows TBS, see winerror.h */\n\nconst RC_TABLE tbsTable [] = {\n    {TBS_E_INTERNAL_ERROR, \"TBS_E_INTERNAL_ERROR - An internal software error occurred\"},\n    {TBS_E_BAD_PARAMETER, \"TBS_E_BAD_PARAMETER - One or more parameter values are not valid\"},\n    {TBS_E_INVALID_OUTPUT_POINTER, \"TBS_E_INVALID_OUTPUT_POINTER - A specified output pointer is bad\"},\n    {TBS_E_INVALID_CONTEXT, \"TBS_E_INVALID_CONTEXT - The specified context handle does not refer to a valid context\"},\n    {TBS_E_INSUFFICIENT_BUFFER, \"TBS_E_INSUFFICIENT_BUFFER - The specified output buffer is too small\"},\n    {TBS_E_IOERROR, \"TBS_E_IOERROR - An error occurred while communicating with the TPM\"},\n    {TBS_E_INVALID_CONTEXT_PARAM, \"TBS_E_INVALID_CONTEXT_PARAM - A context parameter that is not valid was passed when attempting to create a TBS context\"},\n    {TBS_E_SERVICE_NOT_RUNNING, \"TBS_E_SERVICE_NOT_RUNNING - The TBS service is not running and could not be started\"},\n    {TBS_E_TOO_MANY_TBS_CONTEXTS, \"TBS_E_TOO_MANY_TBS_CONTEXTS - A new context could not be created because there are too many open contexts\"},\n    {TBS_E_TOO_MANY_RESOURCES, \"TBS_E_TOO_MANY_RESOURCES - A new virtual resource could not be created because there are too many open virtual resources\"},\n    {TBS_E_SERVICE_START_PENDING, \"TBS_E_SERVICE_START_PENDING - The TBS service has been started but is not yet running\"},\n    {TBS_E_PPI_NOT_SUPPORTED, \"TBS_E_PPI_NOT_SUPPORTED - The physical presence interface is not supported\"},\n    {TBS_E_COMMAND_CANCELED, \"TBS_E_COMMAND_CANCELED - The command was canceled\"},\n    {TBS_E_BUFFER_TOO_LARGE, \"TBS_E_BUFFER_TOO_LARGE - The input or output buffer is too large\"},\n    {TBS_E_TPM_NOT_FOUND, \"TBS_E_TPM_NOT_FOUND - A compatible Trusted Platform Module (TPM) Security Device cannot be found on this computer\"},\n    {TBS_E_SERVICE_DISABLED, \"TBS_E_SERVICE_DISABLED - The TBS service has been disabled\"},\n    {TBS_E_NO_EVENT_LOG, \"TBS_E_NO_EVENT_LOG - The TBS event log is not available\"},\n    {TBS_E_ACCESS_DENIED, \"TBS_E_ACCESS_DENIED - The caller does not have the appropriate rights to perform the requested operation\"},\n    {TBS_E_PROVISIONING_NOT_ALLOWED, \"TBS_E_PROVISIONING_NOT_ALLOWED - The TPM provisioning action is not allowed by the specified flags\"},\n    {TBS_E_PPI_FUNCTION_UNSUPPORTED, \"TBS_E_PPI_FUNCTION_UNSUPPORTED - The Physical Presence Interface of this firmware does not support the requested method\"},\n    {TBS_E_OWNERAUTH_NOT_FOUND, \"TBS_E_OWNERAUTH_NOT_FOUND - The requested TPM OwnerAuth value was not found\"},\n    {TBS_E_PROVISIONING_INCOMPLETE, \"TBS_E_PROVISIONING_INCOMPLETE - The TPM provisioning did not complete.\"},\n    \n    {TPM_E_COMMAND_BLOCKED, \"TPM_E_COMMAND_BLOCKED - The command was blocked\"},\n    {TPM_E_INVALID_HANDLE, \"TPM_E_INVALID_HANDLE - The specified handle was not found\"},\n    {TPM_E_DUPLICATE_VHANDLE, \"TPM_E_DUPLICATE_VHANDLE - The TPM returned a duplicate handle and the command needs to be resubmitted\"},\n    {TPM_E_EMBEDDED_COMMAND_BLOCKED, \"TPM_E_EMBEDDED_COMMAND_BLOCKED - The command within the transport was blocked\"},\n    {TPM_E_EMBEDDED_COMMAND_UNSUPPORTED, \"TPM_E_EMBEDDED_COMMAND_UNSUPPORTED - The command within the transport is not supported\"},\n    {TPM_E_RETRY, \"TPM_E_RETRY - The TPM is too busy to respond to the command immediately, but the command could be resubmitted at a later time\"},\n    {TPM_E_NEEDS_SELFTEST, \"TPM_E_NEEDS_SELFTEST - SelfTestFull has not been run\"},\n    {TPM_E_DOING_SELFTEST, \"TPM_E_DOING_SELFTEST - The TPM is currently executing a full selftest\"},\n    {TPM_E_DEFEND_LOCK_RUNNING, \"TPM_E_DEFEND_LOCK_RUNNING - The TPM is defending against dictionary attacks and is in a time-out period\"},\n};\n\n#endif  /* TPM_WINDOWS_TBSI */\n#endif\t/* TPM_WINDOWS */\n\n#define BITS1108\t0xf00\n#define BITS1108SHIFT\t8\n\n#define BITS1008\t0x700\n#define BITS1008SHIFT\t8\n\n#define BITS0600\t0x07f\n#define BITS0500\t0x03f\n\n#define BITS87\t\t0x180\n#define BIT11\t\t0x800\n#define BIT10\t\t0x400\n#define BIT7\t\t0x080\n#define BIT6\t\t0x040\n\n#define TSSMASK\t\t0x00ff0000\t/* 23:16 */\n#define TBSMASK\t\t0x80000000\n\n/* Test cases\n\n   TPM \t1.2\t001\n   TPM \tparam\t1c1\n   TPM\thandle  181\n   TPM\tsession\t981\n   TSS\t\tb0001\n*/\n\n/* TSS namespace starts with bit 16 */\n#define TSS_RC_LEVEL_SHIFT 16\n\n/* TSS error level name space */\n#define TSS_ERROR_LEVEL (11 << TSS_RC_LEVEL_SHIFT )\n\n/* Figure 26 - Response Code Evaluation */\t    \n\nvoid TSS_ResponseCode_toString(const char **msg, const char **submsg,  const char **num, TPM_RC rc)\n{\n    *submsg = \"\";\t/* sometimes no sub-message */\n    *num = \"\";\t\t/* sometime no number */\n\n    if (rc == 0) {\n\t*msg = \"TPM_RC_SUCCESS\";\n    }\n#ifdef TPM_WINDOWS\n#ifdef TPM_WINDOWS_TBSI\n    else if ((rc & TBSMASK) == TBSMASK) {\n\t*msg = TSS_ResponseCode_RcToText(tbsTable, sizeof(tbsTable) / sizeof(RC_TABLE), rc);\n    }\n#endif  /* TPM_WINDOWS_TBSI */\n#endif\t/* TPM_WINDOWS */\n    /* if TSS 11 << 16 */\n    else if ((rc & TSSMASK) == TSS_ERROR_LEVEL) {\n\t*msg = TSS_ResponseCode_RcToText(tssTable, sizeof(tssTable) / sizeof(RC_TABLE), rc);\n    }\n    /* if bits 8:7 are 00 */\n    else if ((rc & BITS87) == 0) {\n\t/* TPM 1.2  x000 0xxx xxxx */\n#ifdef TPM_TPM12\n\t*msg = TSS_ResponseCode_RcToText(tpm12Table, sizeof(tpm12Table) / sizeof(RC_TABLE), rc);\n#else\n\t*msg = \"TPM 1.2 response code\";\n#endif\n    }\n    /* if bits 8:7 are not 00 */\n    else {\n\t/* if bit 7 is 0 */\n\tif ((rc & BIT7) == 0) {\n\t    /* if bit 10 is 1 */\n\t    if ((rc & BIT10) != 0) {\n\t\t/* vendor defined x101 0xxx xxxx */\n\t\t*msg = \"TPM2 vendor defined response code\";\n\t    }\n\t    /* if bit 10 is 0 */\n\t    else {\n\t\t/* if bit 11 is 1 */\n\t\tif ((rc & BIT11) != 0) {\n\t\t    /* warning 1001 0xxx xxxx RC_WARN */\n\t\t    *msg = TSS_ResponseCode_RcToText(warnTable,\n\t\t\t\t\t\t     sizeof(warnTable) / sizeof(RC_TABLE),\n\t\t\t\t\t\t     rc & (BITS0600 | RC_WARN));\n\t\t}\n\t\t/* if bit 11 is 0 */\n\t\telse {\n\t\t    /* error 0001 0xxx xxxx  RC_VER1 */\n\t\t    *msg = TSS_ResponseCode_RcToText(ver1Table,\n\t\t\t\t\t\t     sizeof(ver1Table) / sizeof(RC_TABLE),\n\t\t\t\t\t\t     rc & (BITS0600 | RC_VER1));\n\t\t}\n\t    }\n\t}\n\t/* if bit 7 is 1 RC_FMT1 */\n\telse {\n\t    /* if bit 6 is 1 */\n\t    if ((rc & BIT6) != 0) {\n\t\t/* error xxxx 11xx xxxx */\n\t\t*msg = TSS_ResponseCode_RcToText(fmt1Table,\n\t\t\t\t\t\t sizeof(fmt1Table) / sizeof(RC_TABLE),\n\t\t\t\t\t\t rc & (BITS0500 | RC_FMT1));\n\t\t*submsg = \" Parameter number \";\n\t\t*num = TSS_ResponseCode_NumberToText((rc & BITS1108) >> BITS1108SHIFT); \n\t    }\n\t    /* if bit 6 is 0 */\n\t    else {\n\t\t/* if bit 11 is 1 */\n\t\tif ((rc & BIT11) != 0) {\n\t\t    /* error 1xxx 10xx xxxx */\n\t\t    *msg = TSS_ResponseCode_RcToText(fmt1Table,\n\t\t\t\t\t\t     sizeof(fmt1Table) / sizeof(RC_TABLE),\n\t\t\t\t\t\t     rc & (BITS0500 | RC_FMT1));\n\t\t    *submsg = \" Session number \";\n\t\t    *num = TSS_ResponseCode_NumberToText((rc & BITS1008) >> BITS1008SHIFT); \n\t\t}\n\t\t/* if bit 11 is 0 */\n\t\telse {\n\t\t    /* error 0xxx 10xx xxxx */\n\t\t    *msg = TSS_ResponseCode_RcToText(fmt1Table,\n\t\t\t\t\t\t     sizeof(fmt1Table) / sizeof(RC_TABLE),\n\t\t\t\t\t\t     rc & (BITS0500 | RC_FMT1));\n\t\t    *submsg = \" Handle number \";\n\t\t    *num = TSS_ResponseCode_NumberToText((rc & BITS1008) >> BITS1008SHIFT); \n\t\t}\n\t    }\n\t}\n    }\n    return;\n}\n\nstatic const char *TSS_ResponseCode_RcToText(const RC_TABLE *table, size_t tableSize, TPM_RC rc) \n{\n    size_t i;\n\n    for (i = 0 ; i < tableSize ; i++) {\n\tif (table[i].rc == rc) {\n\t    return table[i].text;\n\t}\n    }\n    return \"response code unknown\";\n}\n\nstatic const char *TSS_ResponseCode_NumberToText(unsigned int num)\n{\n    if (num < (sizeof(num_table) / sizeof(const char *))) {\n\treturn num_table[num];\n    }\n    else {\n\treturn \"out of bounds\";\n    }\n}\n\n#endif \t/* TPM_TSS_NO_PRINT */\n"
  },
  {
    "path": "ibmtss-ftpm/tsssocket.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Socket Transmit and Receive Utilities\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t      $Id: tsssocket.c 1304 2018-08-20 18:31:45Z kgoldman $\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>\n#include <errno.h>\n\n#ifndef TPM_NOSOCKET\n\n/* TSS_SOCKET_FD encapsulates the differences between the Posix and Windows socket type */\n\n#ifdef TPM_POSIX\n#include <unistd.h>\n#include <arpa/inet.h>\n#include <sys/socket.h>\n#include <netinet/in.h>\n#include <netdb.h>\n#endif\n\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <sys/types.h>\n#include <fcntl.h>\n\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n#include \"tssproperties.h\"\n#include <ibmtss/tsstransmit.h>\n\n#include \"tsssocket.h\"\n\n/* local prototypes */\n\nstatic uint32_t TSS_Socket_Open(TSS_CONTEXT *tssContext, short port);\nstatic uint32_t TSS_Socket_SendCommand(TSS_CONTEXT *tssContext,\n\t\t\t\t       const uint8_t *buffer, uint16_t length,\n\t\t\t\t       const char *message);\nstatic uint32_t TSS_Socket_SendPlatform(TSS_SOCKET_FD sock_fd, uint32_t command, const char *message);\nstatic uint32_t TSS_Socket_ReceiveResponse(TSS_CONTEXT *tssContext, uint8_t *buffer, uint32_t *length);\nstatic uint32_t TSS_Socket_ReceivePlatform(TSS_SOCKET_FD sock_fd);\nstatic uint32_t TSS_Socket_ReceiveBytes(TSS_SOCKET_FD sock_fd, uint8_t *buffer, uint32_t nbytes);\nstatic uint32_t TSS_Socket_SendBytes(TSS_SOCKET_FD sock_fd, const uint8_t *buffer, size_t length);\n\nstatic uint32_t TSS_Socket_GetServerType(TSS_CONTEXT *tssContext,\n\t\t\t\t\t int *mssim,\n\t\t\t\t\t int *rawsingle);\n#ifdef TPM_WINDOWS\nstatic void TSS_Socket_PrintError(int err);\n#endif\n    \nextern int tssVverbose;\nextern int tssVerbose;\n\n/* TSS_Socket_TransmitPlatform() transmits MS simulator platform administrative commands */\n\nTPM_RC TSS_Socket_TransmitPlatform(TSS_CONTEXT *tssContext,\n\t\t\t\t   uint32_t command, const char *message)\n{\n    TPM_RC \trc = 0;\n    int \tmssim;\t/* boolean, true for MS simulator packet format, false for raw packet\n\t\t\t   format */\n    int \trawsingle = FALSE;\t/* boolean, true for raw format with an open and close per\n\t\t\t\t\t   command */\n    /* open on first transmit */\n    if (tssContext->tssFirstTransmit) {\t\n\t/* detect errors before starting, get the server packet type, MS sim or raw */\n\tif (rc == 0) {\n\t    rc = TSS_Socket_GetServerType(tssContext, &mssim, &rawsingle);\n\t}\n\t/* the platform administrative commands can only work with the simulator */\n\tif (rc == 0) {\n\t    if (!mssim) {\n\t\tif (tssVerbose) printf(\"TSS_Socket_TransmitPlatform: server type %s unsupported\\n\",\n\t\t\t\t       tssContext->tssServerType);\n\t\trc = TSS_RC_INSUPPORTED_INTERFACE;\t\n\t    }\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Socket_Open(tssContext, tssContext->tssPlatformPort);\n\t}\n\tif (rc == 0) {\n\t    tssContext->tssFirstTransmit = FALSE;\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_Socket_SendPlatform(tssContext->sock_fd, command, message);\n    }\n    if (rc == 0) {\n\trc = TSS_Socket_ReceivePlatform(tssContext->sock_fd);\n    }\n    return rc;\n}\n\n/* TSS_Socket_TransmitCommand() transmits MS simulator in band administrative commands */\n\nTPM_RC TSS_Socket_TransmitCommand(TSS_CONTEXT *tssContext,\n\t\t\t\t  uint32_t command, const char *message)\n{\n    TPM_RC \trc = 0;\n    int \tmssim;\t/* boolean, true for MS simulator packet format, false for raw packet\n\t\t\t   format */\n    int \trawsingle = FALSE;\t/* boolean, true for raw format with an open and close per\n\t\t\t\t\t   command */\n    /* open on first transmit */\n    if (tssContext->tssFirstTransmit) {\t\n\t/* detect errors before starting, get the server packet type, MS sim or raw */\n\tif (rc == 0) {\n\t    rc = TSS_Socket_GetServerType(tssContext, &mssim, &rawsingle);\n\t}\n\t/* the platform administrative commands can only work with the simulator */\n\tif (rc == 0) {\n\t    if (!mssim) {\n\t\tif (tssVerbose) printf(\"TSS_Socket_TransmitCommand: server type %s unsupported\\n\",\n\t\t\t\t       tssContext->tssServerType);\n\t\trc = TSS_RC_INSUPPORTED_INTERFACE;\t\n\t    }\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Socket_Open(tssContext, tssContext->tssCommandPort);\n\t}\n\tif (rc == 0) {\n\t    tssContext->tssFirstTransmit = FALSE;\n\t}\n    }\n    if (message != NULL) {\n\tif (tssVverbose) printf(\"TSS_Socket_TransmitCommand: %s\\n\", message);\n    }\n    if (rc == 0) {\n\tuint32_t commandType = htonl(command);\t/* command type is network byte order */\n\trc = TSS_Socket_SendBytes(tssContext->sock_fd, (uint8_t *)&commandType, sizeof(uint32_t));\n    }\n    /* FIXME The only command currently supported is TPM_STOP, which has no response */\n    return rc;\n}\n\n/* TSS_Socket_Transmit() transmits the TPM command and receives the response.\n\n   It can return socket transmit and receive packet errors, but normally returns the TPM response\n   code.\n\n*/\n\nTPM_RC TSS_Socket_Transmit(TSS_CONTEXT *tssContext,\n\t\t\t   uint8_t *responseBuffer, uint32_t *read,\n\t\t\t   const uint8_t *commandBuffer, uint32_t written,\n\t\t\t   const char *message)\n{\n    TPM_RC \trc = 0;\n    int \tmssim;\t/* boolean, true for MS simulator packet format, false for raw packet\n\t\t\t   format */\n    int \trawsingle = FALSE;\t/* boolean, true for raw packet format requiring an open and\n\t\t\t\t\t   close for each command */\n\n    /* open on first transmit */\n    if (tssContext->tssFirstTransmit) {\t\n\t/* detect errors before starting, get the server packet type, MS sim or raw */\n\tif (rc == 0) {\n\t    rc = TSS_Socket_GetServerType(tssContext, &mssim, &rawsingle);\n\t}\n\tif (rc == 0) {\n\t    rc = TSS_Socket_Open(tssContext, tssContext->tssCommandPort);\n\t}\n\tif (rc == 0) {\n\t    tssContext->tssFirstTransmit = FALSE;\n\t}\n    }\n    /* send the command over the socket.  Error if the socket send fails. */\n    if (rc == 0) {\n\trc = TSS_Socket_SendCommand(tssContext, commandBuffer, written, message);\n    }\n    /* receive the response over the socket.  Returns socket errors, malformed response errors.\n       Else returns the TPM response code. */\n    if (rc == 0) {\n\trc = TSS_Socket_ReceiveResponse(tssContext, responseBuffer, read);\n    }\n    /* rawsingle flags a close after each command */\n    if (rawsingle) {\n\tTPM_RC rc1;\n\trc1 = TSS_Socket_Close(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n\ttssContext->tssFirstTransmit = TRUE;\t/* force reopen on next command */\n    }\n    return rc;\n}\n\n/* TSS_Socket_GetServerType() gets the type of server packet format\n\n   Currently, the formats supported are:\n\n   mssim, raw, rawsingle\n\n   mssim TRUE  - the MS simulator packet\n   mssim FALSE - raw TPM specification Part 3 packets\n   rawsingle is the same as mssim FALSE but forces an open and cose for each command\n*/\n\nstatic uint32_t TSS_Socket_GetServerType(TSS_CONTEXT *tssContext,\n\t\t\t\t\t int *mssim,\n\t\t\t\t\t int *rawsingle)\n{\n    uint32_t \trc = 0;\n    if (rc == 0) {\n\tif ((strcmp(tssContext->tssServerType, \"mssim\") == 0)) {\n\t    *mssim = TRUE;\n\t    *rawsingle = FALSE;\n\t}\n\telse if ((strcmp(tssContext->tssServerType, \"raw\") == 0)) {\n\t    *mssim = FALSE;\n\t    *rawsingle = FALSE;\n\t}\n\telse if ((strcmp(tssContext->tssServerType, \"rawsingle\") == 0)) {\n\t    *mssim = FALSE;\n\t    *rawsingle = TRUE;\n\t}\n\telse {\n\t    if (tssVerbose) printf(\"TSS_Socket_GetServerType: server type %s unsupported\\n\",\n\t\t\t\t   tssContext->tssServerType);\n\t    rc = TSS_RC_INSUPPORTED_INTERFACE;\t\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Socket_Open() opens the socket to the TPM Host emulation to tssServerName:port\n\n*/\n\nstatic uint32_t TSS_Socket_Open(TSS_CONTEXT *tssContext, short port)\n{\n#ifdef TPM_WINDOWS \n    WSADATA \t\twsaData;\n    int\t\t\tirc;\n#endif\n    struct sockaddr_in \tserv_addr;\n    struct hostent \t*host = NULL;\n\n    if (tssVverbose) printf(\"TSS_Socket_Open: Opening %s:%hu-%s\\n\",\n\t\t\t    tssContext->tssServerName, (unsigned short)port, tssContext->tssServerType);\n    /* create a socket */\n#ifdef TPM_WINDOWS\n    if ((irc = WSAStartup(0x202, &wsaData)) != 0) {\t\t/* if not successful */\n\tif (tssVerbose) printf(\"TSS_Socket_Open: Error, WSAStartup failed\\n\");\n\tWSACleanup();\n\treturn TSS_RC_NO_CONNECTION;\n    }\n    if ((tssContext->sock_fd = socket(AF_INET,SOCK_STREAM, 0)) == INVALID_SOCKET) {\n\tif (tssVerbose) printf(\"TSS_Socket_Open: client socket() error: %lu\\n\", (unsigned long)tssContext->sock_fd);\n\treturn TSS_RC_NO_CONNECTION;\n    }\n#endif \n#ifdef TPM_POSIX\n    if ((tssContext->sock_fd = socket(AF_INET,SOCK_STREAM, 0)) < 0) {\n\tif (tssVerbose) printf(\"TSS_Socket_Open: client socket error: %d %s\\n\",\n\t\t\t       errno,strerror(errno));\n\treturn TSS_RC_NO_CONNECTION;\n    }\n#endif\n    memset((char *)&serv_addr,0x0,sizeof(serv_addr));\n    serv_addr.sin_family = AF_INET;\n    serv_addr.sin_port = htons(port);\n\n    /* the server host name tssServerName came from the default or an environment variable */\n    /* first assume server is dotted decimal number and call inet_addr */\n    if ((int)(serv_addr.sin_addr.s_addr = inet_addr(tssContext->tssServerName)) == -1) {\n\t/* if inet_addr fails, assume server is a name and call gethostbyname to look it up */\n\t/* if gethostbyname also fails */\n\tif ((host = gethostbyname(tssContext->tssServerName)) == NULL) {\n\t    if (tssVerbose) printf(\"TSS_Socket_Open: server name error, name %s\\n\",\n\t\t\t\t   tssContext->tssServerName);\n\t    return TSS_RC_NO_CONNECTION;\n\t}\n\tserv_addr.sin_family = host->h_addrtype;\n\tmemcpy(&serv_addr.sin_addr, host->h_addr, host->h_length);\n    }\n    /* establish the connection to the TPM server */\n#ifdef TPM_POSIX\n    if (connect(tssContext->sock_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {\n\tif (tssVerbose) printf(\"TSS_Socket_Open: Error on connect to %s:%hu\\n\",\n\t\t\t       tssContext->tssServerName, (unsigned short)port);\n\tif (tssVerbose) printf(\"TSS_Socket_Open: client connect: error %d %s\\n\",\n\t\t\t       errno,strerror(errno));\n\treturn TSS_RC_NO_CONNECTION;\n    }\n#endif\n#ifdef TPM_WINDOWS\n    if (connect(tssContext->sock_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0) {\n\tif (tssVerbose) {\n\t    int err;\n\t    printf(\"TSS_Socket_Open: Error on connect to %s:%hu\\n\",\n\t\t   tssContext->tssServerName, (unsigned short)port);\n\t    err = WSAGetLastError();\n\t    printf(\"TSS_Socket_Open: client connect: error %d\\n\", err);\n\t    TSS_Socket_PrintError(err);\n\t}\n\treturn TSS_RC_NO_CONNECTION;\n    }\n#endif\n    else {\n\t/*  \tprintf(\"TSS_Socket_Open: client connect: success\\n\"); */\n    }\n    return 0;\n}\n\n/* TSS_Socket_SendCommand() sends the TPM command packet over the socket.\n\n   The MS simulator packet is of the form:\n\n   TPM_SEND_COMMAND\n   locality\n   length\n   TPM command packet\t(this is the raw packet format)\n\n   Returns an error if the socket send fails.\n*/\n\nstatic uint32_t TSS_Socket_SendCommand(TSS_CONTEXT *tssContext,\n\t\t\t\t       const uint8_t *buffer, uint16_t length,\n\t\t\t\t       const char *message)\n{\n    uint32_t \trc = 0;\n    int \tmssim;\t/* boolean, true for MS simulator packet format, false for raw packet\n\t\t\t   format */\n    int \trawsingle;\n    \n    if (message != NULL) {\n\tif (tssVverbose) printf(\"TSS_Socket_SendCommand: %s\\n\", message);\n    }\n    /* trace the command packet */\n    if ((rc == 0) && tssVverbose) {\n\tTSS_PrintAll(\"TSS_Socket_SendCommand\",\n\t\t     buffer, length);\n    }\n    /* get the server packet type, MS sim or raw */\n    if (rc == 0) {\n\trc = TSS_Socket_GetServerType(tssContext, &mssim, &rawsingle);\n    }\n    /* MS simulator wants a command type, locality, length */\n    if ((rc == 0) && mssim) {\n\tuint32_t commandType = htonl(TPM_SEND_COMMAND);\t/* command type is network byte order */\n\trc = TSS_Socket_SendBytes(tssContext->sock_fd, (uint8_t *)&commandType, sizeof(uint32_t));\n    }\n    if ((rc == 0) && mssim) {\n\tuint8_t locality = tssContext->locality;\n\tif (locality != 0) {\n\t    if (tssVverbose) printf(\"TSS_Socket_SendCommand: locality %u\\n\", tssContext->locality);\n\t}\n\trc = TSS_Socket_SendBytes(tssContext->sock_fd, &locality, sizeof(uint8_t));\n    }\n    if ((rc == 0) && mssim) {\n\tuint32_t lengthNbo = htonl(length);\t/* length is network byte order */\n\trc = TSS_Socket_SendBytes(tssContext->sock_fd, (uint8_t *)&lengthNbo, sizeof(uint32_t));\n    }\n    /* all packet formats (types) send the TPM command packet */\n    if (rc == 0) {\n\trc = TSS_Socket_SendBytes(tssContext->sock_fd, buffer, length);\n    }\n    return rc;\n}\n\n/* TSS_Socket_SendPlatform() transmits MS simulator platform administrative commands.  This function\n   should only be called if the TPM supports administrative commands.\n\n   Returns an error if the socket send fails.\n\n*/\n\nstatic uint32_t TSS_Socket_SendPlatform(TSS_SOCKET_FD sock_fd, uint32_t command, const char *message)\n{\n    uint32_t rc = 0;\n\n    if (message != NULL) {\n\tif (tssVverbose) printf(\"TSS_Socket_SendPlatform: %s\\n\", message);\n    }\n    if (tssVverbose) printf(\"TSS_Socket_SendPlatform: Command %08x\\n\", command);\n    /* MS simulator platform commands */\n    if (rc == 0) {\n\tuint32_t commandNbo = htonl(command);\t/* command is network byte order */\n\trc = TSS_Socket_SendBytes(sock_fd, (uint8_t *)&commandNbo , sizeof(uint32_t));\n    }\n    return rc;\n}\n\n/* TSS_Socket_SendBytes() is the low level sent function that transmits the buffer over the socket.\n\n   It handles partial writes by looping.\n\n */\n\nstatic uint32_t TSS_Socket_SendBytes(TSS_SOCKET_FD sock_fd, const uint8_t *buffer, size_t length)\n{\n    int nwritten = 0;\n    size_t nleft = 0;\n    unsigned int offset = 0;\n\n    nleft = length;\n    while (nleft > 0) {\n#ifdef TPM_POSIX\n\tnwritten = write(sock_fd, &buffer[offset], nleft);\n\tif (nwritten < 0) {        /* error */\n\t    if (tssVerbose) printf(\"TSS_Socket_SendBytes: write error %d\\n\", (int)nwritten);\n\t    return TSS_RC_BAD_CONNECTION;\n\t}\n#endif\n#ifdef TPM_WINDOWS\n\t/* cast for winsock.  Unix uses void * */\n\tnwritten = send(sock_fd, (char *)(&buffer[offset]), (int)nleft, 0);\n\tif (nwritten == SOCKET_ERROR) {        /* error */\n\t    if (tssVerbose) printf(\"TSS_Socket_SendBytes: write error %d\\n\", (int)nwritten);\n\t    return TSS_RC_BAD_CONNECTION;\n\t}\n#endif\n\tnleft -= nwritten;\n\toffset += nwritten;\n    }\n    return 0;\n}\n\n/* TSS_Socket_ReceiveResponse() reads a TPM response packet from the socket.  'buffer' must be at\n   least MAX_RESPONSE_SIZE bytes.  The bytes read are returned in 'length'.\n\n   The MS simulator packet is of the form:\n\n   length\n   TPM response packet\t\t(this is the raw packet format)\n   acknowledgement uint32_t zero\n\n   If the receive succeeds, returns TPM packet error code.\n\n   Validates that the packet length and the packet responseSize match \n*/\n\nstatic uint32_t TSS_Socket_ReceiveResponse(TSS_CONTEXT *tssContext,\n\t\t\t\t\t  uint8_t *buffer, uint32_t *length)\n{\n    uint32_t \trc = 0;\n    uint32_t \tresponseSize = 0;\n    uint32_t \tresponseLength = 0;\n    uint8_t \t*bufferPtr = buffer;\t/* the moving buffer */\n    TPM_RC \tresponseCode;\n    uint32_t \tsize;\t\t/* dummy for unmarshal call */\n    int \tmssim;\t\t/* boolean, true for MS simulator packet format, false for raw\n\t\t\t\t   packet format */\n    int\t\trawsingle;\n    TPM_RC \tacknowledgement;\t/* MS sim acknowledgement */\n    \n    /* get the server packet type, MS sim or raw */\n    if (rc == 0) {\n\trc = TSS_Socket_GetServerType(tssContext, &mssim, &rawsingle);\n    }\n    /* read the length prepended by the simulator */\n    if ((rc == 0) && mssim) {\n\trc = TSS_Socket_ReceiveBytes(tssContext->sock_fd,\n\t\t\t\t     (uint8_t *)&responseLength, sizeof(uint32_t));\n\tresponseLength = ntohl(responseLength);\n    }\n    /* read the tag and responseSize */\n    if (rc == 0) {\n\trc = TSS_Socket_ReceiveBytes(tssContext->sock_fd,\n\t\t\t\t     bufferPtr, sizeof(TPM_ST) + sizeof(uint32_t));\n    }\n    /* extract the responseSize */\n    if (rc == 0) {\n\t/* skip over tag to responseSize */\n\tbufferPtr += sizeof(TPM_ST);\n\t\n\tsize = sizeof(uint32_t);\t\t/* dummy for call */\n\trc = TSS_UINT32_Unmarshalu(&responseSize, &bufferPtr, &size);\n\t*length = responseSize;\t\t\t/* returned length */\n\n\t/* check the response size, see TSS_CONTEXT structure */\n\tif (responseSize > MAX_RESPONSE_SIZE) {\n\t    if (tssVerbose)\n\t\tprintf(\"TSS_Socket_ReceiveResponse: ERROR: responseSize %u greater than %u\\n\",\n\t\t       responseSize, MAX_RESPONSE_SIZE);\n\t    rc = TSS_RC_BAD_CONNECTION;\n\t}\n\t/* check that MS sim prepended length is the same as the response TPM packet\n\t   length parameter */\n\tif (mssim && (responseSize != responseLength)) {\n\t    if (tssVerbose) printf(\"TSS_Socket_ReceiveResponse: \"\n\t\t\t\t   \"ERROR: responseSize %u not equal to responseLength %u\\n\",\n\t\t\t\t   responseSize, responseLength);\n\t    rc = TSS_RC_BAD_CONNECTION;\n\t}\n    }\n    /* read the rest of the packet */\n    if (rc == 0) {\n\trc = TSS_Socket_ReceiveBytes(tssContext->sock_fd,\n\t\t\t\t     bufferPtr,\n\t\t\t\t     responseSize - (sizeof(TPM_ST) + sizeof(uint32_t)));\n    }\n    if ((rc == 0) && tssVverbose) {\n\tTSS_PrintAll(\"TSS_Socket_ReceiveResponse\",\n\t\t     buffer, responseSize);\n    }\n    /* read the MS sim acknowledgement */\n    if ((rc == 0) && mssim) {\n\trc = TSS_Socket_ReceiveBytes(tssContext->sock_fd,\n\t\t\t\t     (uint8_t *)&acknowledgement, sizeof(uint32_t));\n    }\n    /* extract the TPM return code from the packet */\n    if (rc == 0) {\n\t/* skip to responseCode */\n\tbufferPtr = buffer + sizeof(TPM_ST) + sizeof(uint32_t);\n\tsize = sizeof(TPM_RC);\t\t/* dummy for call */\n\trc = TSS_UINT32_Unmarshalu(&responseCode, &bufferPtr, &size);\n    }\n    /* if there is no other (receive or unmarshal) error, return the TPM response code */\n    if (rc == 0) {\n\trc = responseCode;\n    }\n    /* if there is no other (TPM response) error, return the MS simulator packet acknowledgement */\n    if ((rc == 0) && mssim) {\n\t  rc = ntohl(acknowledgement);\t/* should always be zero */\n    }\n    return rc;\n}\n\n/* TSS_Socket_ReceivePlatform reads MS simulator platform administrative responses.  This function\n   should only be called if the TPM supports administrative commands.\n\n   The acknowledgement is a uint32_t zero.\n\n*/\n\nstatic uint32_t TSS_Socket_ReceivePlatform(TSS_SOCKET_FD sock_fd)\n{\n    uint32_t \trc = 0;\n    TPM_RC \tacknowledgement;\n    \n    /* read the MS sim acknowledgement */\n    if (rc == 0) {\n\trc = TSS_Socket_ReceiveBytes(sock_fd, (uint8_t *)&acknowledgement, sizeof(uint32_t));\n    }\n    /* if there is no other error, return the MS simulator packet acknowledgement */\n    if (rc == 0) {\n\trc = ntohl(acknowledgement);\t/* should always be zero */\n    }\n    return rc;\n}\n\n/* TSS_Socket_ReceiveBytes() is the low level receive function that reads the buffer over the\n   socket.  'buffer' must be atleast 'nbytes'. \n\n   It handles partial reads by looping.\n\n*/\n\nstatic uint32_t TSS_Socket_ReceiveBytes(TSS_SOCKET_FD sock_fd,\n\t\t\t\t\tuint8_t *buffer,  \n\t\t\t\t\tuint32_t nbytes)\n{\n    int nread = 0;\n    int nleft = 0;\n\n    nleft = nbytes;\n    while (nleft > 0) {\n#ifdef TPM_POSIX\n\tnread = read(sock_fd, buffer, nleft);\n\tif (nread < 0) {       /* error */\n\t    if (tssVerbose)  printf(\"TSS_Socket_ReceiveBytes: read error %d\\n\", nread);\n\t    return TSS_RC_BAD_CONNECTION;\n\t}\n#endif\n#ifdef TPM_WINDOWS\n\t/* cast for winsock.  Unix uses void * */\n\tnread = recv(sock_fd, (char *)buffer, nleft, 0);\n\tif (nread == SOCKET_ERROR) {       /* error */\n\t    if (tssVerbose) printf(\"TSS_Socket_ReceiveBytes: read error %d\\n\", nread);\n\t    return TSS_RC_BAD_CONNECTION;\n\t}\n#endif\n\telse if (nread == 0) {  /* EOF */\n\t    if (tssVerbose) printf(\"TSS_Socket_ReceiveBytes: read EOF\\n\");\n\t    return TSS_RC_BAD_CONNECTION;\n\t}\n\tnleft -= nread;\n\tbuffer += nread;\n    }\n    return 0;\n}\n\n/* TSS_Socket_Close() closes the socket.\n\n   It sends the TPM_SESSION_END required by the MS simulator.\n\n*/\n\nTPM_RC TSS_Socket_Close(TSS_CONTEXT *tssContext)\n{\n    uint32_t \trc = 0;\n    int \tmssim;\t/* boolean, true for MS simulator packet format, false for raw packet\n\t\t\t   format */\n    int\t\trawsingle = TRUE;\t/* boolean, true for raw format with an open and close per\n\t\t\t\t\t   command.  Initialized to suppress false gcc -O3\n\t\t\t\t\t   warning. */\n    \n    if (tssVverbose) printf(\"TSS_Socket_Close: Closing %s-%s\\n\",\n\t\t\t    tssContext->tssServerName, tssContext->tssServerType);\n    /* get the server packet type, MS sim or raw */\n    if (rc == 0) {\n\trc = TSS_Socket_GetServerType(tssContext, &mssim, &rawsingle);\n    }\n    /* the MS simulator expects a TPM_SESSION_END command before close */\n    if ((rc == 0) && mssim) {\n\tuint32_t commandType = htonl(TPM_SESSION_END);\n\trc = TSS_Socket_SendBytes(tssContext->sock_fd, (uint8_t *)&commandType, sizeof(uint32_t));\n    }\n#ifdef TPM_POSIX\n    /* always attempt a close, even though rawsingle should already have closed the socket */\n    if (close(tssContext->sock_fd) != 0) {\n\tif (!rawsingle) {\n\t    if (tssVerbose) printf(\"TSS_Socket_Close: close error\\n\");\n\t    rc = TSS_RC_BAD_CONNECTION;\n\t}\n    }\n#endif\n#ifdef TPM_WINDOWS\n    /* gracefully shut down the socket */\n    /* always attempt a close, even though rawsingle should already have closed the socket */\n    {\n\tint\t\tirc;\n\tirc = shutdown(tssContext->sock_fd, SD_SEND);\n\tif (!rawsingle) {\n\t    if (irc == SOCKET_ERROR) {       /* error */\n\t\tif (tssVerbose) printf(\"TSS_Socket_Close: shutdown error\\n\");\n\t\trc = TSS_RC_BAD_CONNECTION;\n\t    }\n\t}\n    }\n    closesocket(tssContext->sock_fd);\n    WSACleanup();\n#endif\n    return rc;\n}\n#endif \t/* TPM_NOSOCKET */\n\n#ifdef TPM_WINDOWS\n\n/* The Windows equivalent to strerror().  It also traces the error message.\n */\n\nstatic void TSS_Socket_PrintError(int err)\n{\n    DWORD rc;\n    char *buffer = NULL;\n    /* mingw seems to output UTF-8 for FormatMessage().  For Visual Studio, FormatMessage() outputs\n       UTF-16, which would require wprintf(). FormatMessageA() outputs UTF-8, permitting printf()\n       for both compilers. */\n    rc = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,\n\t\t\tNULL,\t/* formatting */\n\t\t\terr,\n\t\t\t0,\t/* language */\n\t\t\t(LPSTR)&buffer, \n\t\t\t0, \n\t\t\tNULL);\n    if (rc != 0) {\n\tprintf(\"%s\\n\", buffer);\n    }\n    LocalFree(buffer);\n    return;\n}\n#endif\n\n\n"
  },
  {
    "path": "ibmtss-ftpm/tsstbsi.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\tWindows 10 Device Transmit and Receive Utilities\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#ifdef TPM_WINDOWS_TBSI\n\n#include <stdint.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <errno.h>\n#include <limits.h>\n\n#include <winsock2.h>\n#include <windows.h>\n#include <winerror.h>\n#include <specstrings.h>\n#include <tbs.h>\n\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssprint.h>\n#include <ibmtss/tsserror.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include \"tssproperties.h\"\n\n/* local prototypes */\n\nstatic uint32_t TSS_Tbsi_Open(TBS_CONTEXT_PARAMS2 *contextParams,\n\t\t\t      TBS_HCONTEXT *hContext);\nstatic uint32_t TSS_Tbsi_SubmitCommand(TBS_HCONTEXT hContext,\n\t\t\t\t       uint8_t *responseBuffer, uint32_t *read,\n\t\t\t\t       const uint8_t *commandBuffer, uint32_t written,\n\t\t\t\t       const char *message);\nstatic void TSS_Tbsi_GetTBSError(const char *prefix,\n\t\t\t\t TBS_RESULT rc);\n\n\n/* global configuration */\n\nextern int tssVverbose;\nextern int tssVerbose;\n\n/* TSS_Dev_Transmit() transmits the command and receives the response. 'responseBuffer' must be at\n   least MAX_RESPONSE_SIZE bytes.\n\n   Can return device transmit and receive packet errors, but normally returns the TPM response code.\n*/\n\nTPM_RC TSS_Dev_Transmit(TSS_CONTEXT *tssContext,\n\t\t\t uint8_t *responseBuffer, uint32_t *read,\n\t\t\t const uint8_t *commandBuffer, uint32_t written,\n\t\t\t const char *message)\n{\n    TPM_RC rc = 0;\n    TBS_CONTEXT_PARAMS2 contextParams;\n\n    if (rc == 0) {\n\tcontextParams.version = TBS_CONTEXT_VERSION_TWO;\n\tif (!tssContext->tpm12Command) {\t/* TPM 2.0 command */\n\t    contextParams.includeTpm12 = 0;\n\t    contextParams.includeTpm20 = 1;\n\t}\n\telse {\t\t\t\t\t/* TPM 1.2 command */\n\t    contextParams.includeTpm12 = 1;\n\t    contextParams.includeTpm20 = 0;\n\t}\n    }\n    *read = MAX_RESPONSE_SIZE;\n    /* open on first transmit */\n    if (tssContext->tssFirstTransmit) {\t\n\tif (rc == 0) {\n\t    rc = TSS_Tbsi_Open(&contextParams, &tssContext->hContext);\n\t}\n\tif (rc == 0) {\n\t    tssContext->tssFirstTransmit = FALSE;\n\t}\n    }\n    /* send the command to the device.  Error if the device send fails. */\n    if (rc == 0) {\n\trc = TSS_Tbsi_SubmitCommand(tssContext->hContext,\n\t\t\t\t    responseBuffer, read,\n\t\t\t\t    commandBuffer, written,\n\t\t\t\t    message);\n    }\n    return rc;\n}\n\n/* TSS_Tbsi_Open() opens the TPM device */\n\nstatic uint32_t TSS_Tbsi_Open(TBS_CONTEXT_PARAMS2 *contextParams,\n\t\t\t      TBS_HCONTEXT *hContext)\n{\n    uint32_t rc = 0;\n\n    if (rc == 0) {\n\t/* cast is safe because caller sets the version member for the subclass */\n\trc = Tbsi_Context_Create((TBS_CONTEXT_PARAMS *)contextParams, hContext);\n\tif (tssVverbose) printf(\"TSS_Tbsi_Open: Tbsi_Context_Create rc %08x\\n\", rc);\n\tif (rc != 0) {\n\t    if (tssVerbose) TSS_Tbsi_GetTBSError(\"TSS_Tbsi_Open: Error Tbsi_Context_Create \", rc);\n\t    rc = TSS_RC_NO_CONNECTION;\n\t}\n    }\n    return rc;\n}\n\n/* TSS_Tbsi_Submit_Command sends the command to the TPM and receives the response.\n\n   If the submit succeeds, returns TPM packet error code.\n*/\n\nstatic uint32_t TSS_Tbsi_SubmitCommand(TBS_HCONTEXT hContext,\n\t\t\t\t       uint8_t *responseBuffer, uint32_t *read,\n\t\t\t\t       const uint8_t *commandBuffer, uint32_t written,\n\t\t\t\t       const char *message)\n{\n    uint32_t \trc = 0;\n    TPM_RC \tresponseCode;\n\n    if (message != NULL) {\n\tif (tssVverbose) printf(\"TSS_Tbsi_SubmitCommand: %s\\n\", message);\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Tbsi_SubmitCommand: Command\",\n\t\t\t\t      commandBuffer, written);\n    }\n    if (rc == 0) {\n\trc = Tbsip_Submit_Command(hContext,\n\t\t\t\t  TBS_COMMAND_LOCALITY_ZERO,\n\t\t\t\t  TBS_COMMAND_PRIORITY_NORMAL,\n\t\t\t\t  commandBuffer,\n\t\t\t\t  written,\n\t\t\t\t  responseBuffer,\n\t\t\t\t  read);\n\tif (rc != 0) {\n\t    TSS_Tbsi_GetTBSError(\"Tbsip_Submit_Command\", rc);\n\t    rc = TSS_RC_BAD_CONNECTION;\n\n\t}\n    }\n    if (rc == 0) {\n\tif (tssVverbose) TSS_PrintAll(\"TSS_Tbsi_SubmitCommand: Response\",\n\t\t\t\t      responseBuffer, *read);\n    }\n    /* read the TPM return code from the packet */\n    if (rc == 0) {\n\tuint8_t\t\t*bufferPtr;\n\tuint32_t\tsize;\n\n\tbufferPtr = responseBuffer + sizeof(TPM_ST) + sizeof(uint32_t);\t\t/* skip to responseCode */\n\tsize = sizeof(TPM_RC);\t\t/* dummy for call */\n\trc = TSS_UINT32_Unmarshalu(&responseCode, &bufferPtr, &size);\n    }\n    if (rc == 0) {\n\trc = responseCode;\n    }\n    return rc;\n}\n\nTPM_RC TSS_Dev_Close(TSS_CONTEXT *tssContext)\n{\n    TPM_RC rc = 0;\n    if (tssVverbose) printf(\"TSS_Dev_Close: Closing connection\\n\");\n    rc = Tbsip_Context_Close(tssContext->hContext);\n    return rc;\n}\n\nstatic void TSS_Tbsi_GetTBSError(const char *prefix,\n\t\t\t\t TBS_RESULT rc)\n{\n    const char *error_string;\n\t\t     \n    switch (rc) {\n\n\t/* error codes from the TBS html docs */\n      case TBS_SUCCESS:\n\terror_string = \"The function succeeded.\";\n\tbreak;\n      case TBS_E_INTERNAL_ERROR:\n\terror_string = \"An internal software error occurred.\";\n\tbreak;\n      case TBS_E_BAD_PARAMETER:\n\terror_string = \"One or more parameter values are not valid.\";\n\tbreak;\n      case TBS_E_INVALID_OUTPUT_POINTER:\n\terror_string = \"A specified output pointer is bad.\";\n\tbreak;\n      case TBS_E_INVALID_CONTEXT:\n\terror_string = \"The specified context handle does not refer to a valid context.\";\n\tbreak;\n      case TBS_E_INSUFFICIENT_BUFFER:\n\terror_string = \"The specified output buffer is too small.\";\n\tbreak;\n      case TBS_E_IOERROR:\n\terror_string = \"An error occurred while communicating with the TPM.\";\n\tbreak;\n      case TBS_E_INVALID_CONTEXT_PARAM:\n\terror_string = \"A context parameter that is not valid was passed when attempting to create a \"\n\t\t       \"TBS context.\";\n\tbreak;\n      case TBS_E_SERVICE_NOT_RUNNING:\n\terror_string = \"The TBS service is not running and could not be started.\";\n\tbreak;\n      case TBS_E_TOO_MANY_TBS_CONTEXTS:\n\terror_string = \"A new context could not be created because there are too many open contexts.\";\n\tbreak;\n      case TBS_E_TOO_MANY_RESOURCES:\n\terror_string = \"A new virtual resource could not be created because there are too many open \"\n\t\t       \"virtual resources.\";\n\tbreak;\n      case TBS_E_SERVICE_START_PENDING:\n\terror_string = \"The TBS service has been started but is not yet running.\";\n\tbreak;\n      case TBS_E_PPI_NOT_SUPPORTED:\n\terror_string = \"The physical presence interface is not supported.\";\n\tbreak;\n      case TBS_E_COMMAND_CANCELED:\n\terror_string = \"The command was canceled.\";\n\tbreak;\n      case TBS_E_BUFFER_TOO_LARGE:\n\terror_string = \"The input or output buffer is too large.\";\n\tbreak;\n      case TBS_E_TPM_NOT_FOUND:\n\terror_string = \"A compatible Trusted Platform Module (TPM) Security Device cannot be found \"\n\t\t       \"on this computer.\";\n\tbreak;\n      case TBS_E_SERVICE_DISABLED:\n\terror_string = \"The TBS service has been disabled.\";\n\tbreak;\n      case TBS_E_NO_EVENT_LOG:\n\terror_string = \"The TBS event log is not available.\";\n\tbreak;\n      case TBS_E_ACCESS_DENIED:\n\terror_string = \"The caller does not have the appropriate rights to perform the requested operation.\";\n\tbreak;\n      case TBS_E_PROVISIONING_NOT_ALLOWED:\n\terror_string = \"The TPM provisioning action is not allowed by the specified flags.\";\n\tbreak;\n      case TBS_E_PPI_FUNCTION_UNSUPPORTED:\n\terror_string = \"The Physical Presence Interface of this firmware does not support the \"\n\t\t       \"requested method.\";\n\tbreak;\n      case TBS_E_OWNERAUTH_NOT_FOUND:\n\terror_string = \"The requested TPM OwnerAuth value was not found.\";\n\tbreak;\n\n\t/* a few error codes from WinError.h */\n      case TPM_E_COMMAND_BLOCKED:\n\terror_string = \"The command was blocked.\";\n\tbreak;\n\n      default:\n\terror_string = \"unknown error type\\n\";\n\tbreak;\n\n    }\n    printf(\"%s %s\\n\", prefix, error_string);\n    return;\n}\n\n#endif\t/* TPM_WINDOWS_TBSI */\n"
  },
  {
    "path": "ibmtss-ftpm/tsstransmit.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    Transmit and Receive Utility\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* This file contains the interface that is not platform or interface specific\n */\n\n#include <string.h>\n#include <stdio.h>\n\n#include \"tssproperties.h\"\n#ifndef TPM_NOSOCKET\n#include \"tsssocket.h\"\n#endif\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n\n#include \"tssdev.h\"\n#include <ibmtss/tsstransmit.h>\n\nextern int tssVverbose;\nextern int tssVerbose;\n\n/* local prototypes */\n\n/* TSS_TransmitPlatform() transmits an administrative out of band command to the TPM through the\n   platform port.\n\n   Supported by the simulator, not the TPM device.\n*/\n\nTPM_RC TSS_TransmitPlatform(TSS_CONTEXT *tssContext, uint32_t command, const char *message)\n{\n    TPM_RC rc = 0;\n    // printf(\"[TSS] TSS_TransmitPlatform(): command: %d, message: %s\\n\", command, message);\n\n#ifndef TPM_NOSOCKET\n    if ((strcmp(tssContext->tssInterfaceType, \"socsim\") == 0)) {\n\trc = TSS_Socket_TransmitPlatform(tssContext, command, message);\n    }\n    else\n#else\n    command = command;\n    message = message;\n#endif\n#ifndef TPM_TSS_NODEV\n    if ((strcmp(tssContext->tssInterfaceType, \"dev\") == 0)) {\n\tif (tssVerbose) printf(\"TSS_TransmitPlatform: device %s unsupported\\n\",\n\t\t\t       tssContext->tssInterfaceType);\n\trc = TSS_RC_INSUPPORTED_INTERFACE;\t\n    }\n    else\n#endif\n\t{\n\tif (tssVerbose) printf(\"TSS_TransmitPlatform: device %s unsupported\\n\",\n\t\t\t       tssContext->tssInterfaceType);\n\trc = TSS_RC_INSUPPORTED_INTERFACE;\t\n    }\n    return rc;\n}\n\n/* TSS_TransmitCommand() transmits an administrative in band command to the TPM through the\n   command port.\n\n   Supported by the simulator, not the TPM device.\n*/\n\nTPM_RC TSS_TransmitCommand(TSS_CONTEXT *tssContext, uint32_t command, const char *message)\n{\n    TPM_RC rc = 0;\n    // printf(\"[TSS] TSS_TransmitCommand(): command: %d, message: %s\\n\", command, message);\n\n#ifndef TPM_NOSOCKET\n    if ((strcmp(tssContext->tssInterfaceType, \"socsim\") == 0)) {\n\trc = TSS_Socket_TransmitCommand(tssContext, command, message);\n    }\n    else\n#else\n    command = command;\n    message = message;\n#endif\n#ifndef TPM_TSS_NODEV\n    if ((strcmp(tssContext->tssInterfaceType, \"dev\") == 0)) {\n\tif (tssVerbose) printf(\"TSS_TransmitCommand: device %s unsupported\\n\",\n\t\t\t       tssContext->tssInterfaceType);\n\trc = TSS_RC_INSUPPORTED_INTERFACE;\t\n    }\n    else\n#endif\n\t{\n\tif (tssVerbose) printf(\"TSS_TransmitCommand: device %s unsupported\\n\",\n\t\t\t       tssContext->tssInterfaceType);\n\trc = TSS_RC_INSUPPORTED_INTERFACE;\t\n    }\n    return rc;\n}\n\n/* TSS_Transmit() transmits a TPM command packet and receives a response using the command port.\n   The command type is hard coded to TPM_SEND_COMMAND.\n\n*/\n\nTPM_RC TSS_Transmit(TSS_CONTEXT *tssContext,\n\t\t    uint8_t *responseBuffer, uint32_t *read,\n\t\t    const uint8_t *commandBuffer, uint32_t written,\n\t\t    const char *message)\n{\n    TPM_RC rc = 0;\n    // printf(\"[TSS] TSS_Transmit(): commandBuffer: %p, written: %d\\n\", commandBuffer, written);\n\n#ifdef TPM_INTERFACE_FTPM\n\trc = TSS_FTPM_Transmit(tssContext,\n\t\t\t\t responseBuffer, read,\n\t\t\t\t commandBuffer, written,\n\t\t\t\t message);\n  return rc;\n#endif\n\n#ifndef TPM_NOSOCKET\n    if ((strcmp(tssContext->tssInterfaceType, \"socsim\") == 0)) {\n\trc = TSS_Socket_Transmit(tssContext,\n\t\t\t\t responseBuffer, read,\n\t\t\t\t commandBuffer, written,\n\t\t\t\t message);\n    }\n    else\n#endif\n#ifndef TPM_TSS_NODEV\n   if (strcmp(tssContext->tssInterfaceType, \"dev\") == 0) {\n\trc = TSS_Dev_Transmit(tssContext,\n\t\t\t      responseBuffer, read,\n\t\t\t      commandBuffer, written,\n\t\t\t      message);\n    }\n   else \n#endif\n       {\n\tif (tssVerbose) printf(\"TSS_Transmit: device %s unsupported\\n\",\n\t\t\t       tssContext->tssInterfaceType);\n\trc = TSS_RC_INSUPPORTED_INTERFACE;\t\n    }\n    return rc;\n}\n\n/* TSS_Close() closes the connection to the TPM */\n\nTPM_RC TSS_Close(TSS_CONTEXT *tssContext)\n{\n    TPM_RC rc = 0;\n\n    /* only close if there was an open */\n    if (!tssContext->tssFirstTransmit) {\n#ifndef TPM_NOSOCKET\n\tif ((strcmp(tssContext->tssInterfaceType, \"socsim\") == 0)) {\n\t    rc = TSS_Socket_Close(tssContext);\n\t}\n\telse\n#endif\n#ifndef TPM_TSS_NODEV\n        if (strcmp(tssContext->tssInterfaceType, \"dev\") == 0) {\n\t    rc = TSS_Dev_Close(tssContext);\n\t}\n\telse  \n#endif\n\t{\n\t    if (tssVerbose) printf(\"TSS_Transmit: device %s unsupported\\n\",\n\t\t\t\t   tssContext->tssInterfaceType);\n\t    rc = TSS_RC_INSUPPORTED_INTERFACE;\t\n\t}\n\ttssContext->tssFirstTransmit = TRUE;\n    }\n    return rc;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssutils.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    TSS and Application Utilities\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <errno.h>\n\n#ifdef TPM_POSIX\n#include <netinet/in.h>\n#endif\n#ifdef TPM_WINDOWS\n#include <winsock2.h>\n#endif\n\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tsserror.h>\n#include <ibmtss/tssprint.h>\n\n/* the TSS context must be larger when files are not used, since TSS object and NV state is held in\n   the volatile context.  The major factor is the number of TSS_OBJECT_PUBLIC slots.  See\n   tssproperties.c */\n#ifdef TPM_TSS_NOFILE\n#define TSS_ALLOC_MAX  0x30000  /* 170k bytes */\n#else\n#define TSS_ALLOC_MAX  0x10000  /* 64k bytes */\n#endif\n\nextern int tssVerbose;\nextern int tssVverbose;\n\n/* TSS_Malloc() is a general purpose wrapper around malloc()\n */\n\nTPM_RC TSS_Malloc(unsigned char **buffer, uint32_t size)\n{\n    TPM_RC          rc = 0;\n    \n    /* assertion test.  The coding style requires that all allocated pointers are initialized to\n       NULL.  A non-NULL value indicates either a missing initialization or a pointer reuse (a\n       memory leak). */\n    if (rc == 0) {\n        if (*buffer != NULL) {\n            if (tssVerbose)\n\t\tprintf(\"TSS_Malloc: Error (fatal), *buffer %p should be NULL before malloc\\n\",\n\t\t       *buffer);\n            rc = TSS_RC_ALLOC_INPUT;\n        }\n    }\n    /* verify that the size is not \"too large\" */\n    if (rc == 0) {\n        if (size > TSS_ALLOC_MAX) {\n            if (tssVerbose) printf(\"TSS_Malloc: Error, size %u greater than maximum allowed\\n\",\n\t\t\t\t   size);\n            rc = TSS_RC_MALLOC_SIZE;\n        }       \n    }\n    /* verify that the size is not 0, this would be implementation defined and should never occur */\n    if (rc == 0) {\n        if (size == 0) {\n            if (tssVerbose) printf(\"TSS_Malloc: Error (fatal), size is zero\\n\");\n            rc = TSS_RC_MALLOC_SIZE;\n        }       \n    }\n    if (rc == 0) {\n        *buffer = malloc(size);\n        if (*buffer == NULL) {\n            if (tssVerbose) printf(\"TSS_Malloc: Error allocating %u bytes\\n\", size);\n            rc = TSS_RC_OUT_OF_MEMORY;\n        }\n    }\n    return rc;\n}\n\nTPM_RC TSS_Realloc(unsigned char **buffer, uint32_t size)\n{\n    TPM_RC          \trc = 0;\n    unsigned char \t*tmpptr = NULL;\n    \n    /* verify that the size is not \"too large\" */\n    if (rc == 0) {\n        if (size > TSS_ALLOC_MAX) {\n            if (tssVerbose) printf(\"TSS_Realloc: Error, size %u greater than maximum allowed\\n\",\n\t\t\t\t   size);\n            rc = TSS_RC_MALLOC_SIZE;\n        }       \n    }\n    /* verify that the size is not 0, this should never occur */\n    if (rc == 0) {\n        if (size == 0) {\n            if (tssVerbose) printf(\"TSS_Malloc: Error (fatal), size is zero\\n\");\n            rc = TSS_RC_MALLOC_SIZE;\n        }       \n    }\n    if (rc == 0) {\n\ttmpptr = realloc(*buffer, size);\n\tif (tmpptr == NULL) {\n            if (tssVerbose) printf(\"TSS_Realloc: Error reallocating %u bytes\\n\", size);\n\t    rc = TSS_RC_OUT_OF_MEMORY;\n\t}\n    }\n    if (rc == 0) {\n\t*buffer = tmpptr;\n    }\n    return rc;\n}\n\n\n/* TSS_Structure_Marshal() is a general purpose \"marshal a structure\" function.\n   \n   It marshals the structure using \"marshalFunction\", and returns the malloc'ed stream.\n\n*/\n\nTPM_RC TSS_Structure_Marshal(uint8_t\t\t**buffer,\t/* freed by caller */\n\t\t\t     uint16_t\t\t*written,\n\t\t\t     void \t\t*structure,\n\t\t\t     MarshalFunction_t \tmarshalFunction)\n{\n    TPM_RC \trc = 0;\n    uint8_t\t*buffer1 = NULL;\t/* for marshaling, moves pointer */\n\n    /* marshal once to calculates the byte length */\n    if (rc == 0) {\n\t*written = 0;\n\trc = marshalFunction(structure, written, NULL, NULL);\n    }\n    if (rc == 0) {\n\trc = TSS_Malloc(buffer, *written);\n    }\n    if (rc == 0) {\n\tbuffer1 = *buffer;\n\t*written = 0;\n\trc = marshalFunction(structure, written, &buffer1, NULL);\n    }\n    return rc;\n}\n\n/* TSS_TPM2B_Copy() copies source to target if the source fits the target size */\n\nTPM_RC TSS_TPM2B_Copy(TPM2B *target, TPM2B *source, uint16_t targetSize)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (source->size > targetSize) {\n\t    if (tssVerbose) printf(\"TSS_TPM2B_Copy: size %u greater than target %u\\n\",\n\t\t\t\t   source->size, targetSize);\t\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\tmemmove(target->buffer, source->buffer, source->size);\n\ttarget->size = source->size;\n    }\n    return rc;\n}\n\n/* TSS_TPM2B_Append() appends the source TPM2B to the target TPM2B.\n   \n   It checks that the source fits the target size. The target size is the total size, not the size\n   remaining.\n*/\n\nTPM_RC TSS_TPM2B_Append(TPM2B *target, TPM2B *source, uint16_t targetSize)\n{\n    TPM_RC rc = 0;\n\n    if (rc == 0) {\n\tif (target->size + source->size > targetSize) {\n\t    if (tssVerbose) printf(\"TSS_TPM2B_Append: size %u greater than target %u\\n\",\n\t\t\t\t   target->size + source->size, targetSize);\t\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\tmemmove(target->buffer + target->size, source->buffer, source->size);\n\ttarget->size += source->size;\n    }\n    return rc;\n}\n\n/* TSS_TPM2B_Create() copies the buffer of 'size' into target, checking targetSize */\n\nTPM_RC TSS_TPM2B_Create(TPM2B *target, uint8_t *buffer, uint16_t size, uint16_t targetSize)\n{\n    TPM_RC rc = 0;\n    \n    if (rc == 0) {\n\tif (size > targetSize) {\n\t    if (tssVerbose) printf(\"TSS_TPM2B_Create: size %u greater than target %u\\n\",\n\t\t\t\t   size, targetSize);\t\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\ttarget->size = size;\n\tif (size != 0) {\t/* because buffer can be NULL if size os 0 */\n\t    memmove(target->buffer, buffer, size);\n\t}\n    }\n    return rc;\n}\n\n/* TSS_TPM2B_CreateUint32() creates a TPM2B from a uint32_t, typically a permanent handle */\n\nTPM_RC TSS_TPM2B_CreateUint32(TPM2B *target, uint32_t source, uint16_t targetSize)\n{\n    TPM_RC rc = 0;\n    \n    if (rc == 0) {\n\tif (sizeof(uint32_t) > targetSize) {\n\t    if (tssVerbose) printf(\"TSS_TPM2B_CreateUint32: size %u greater than target %u\\n\",\n\t\t\t\t   (unsigned int)sizeof(uint32_t), targetSize);\t\n\t    rc = TSS_RC_INSUFFICIENT_BUFFER;\n\t}\n    }\n    if (rc == 0) {\n\tuint32_t sourceNbo = htonl(source);\n\tmemmove(target->buffer, (uint8_t *)&sourceNbo, sizeof(uint32_t));\n\ttarget->size = sizeof(uint32_t);\n    }\n    return rc;\n}\n\n/* TSS_TPM2B_StringCopy() copies a NUL terminated string (omitting the NUL) from source to target.\n   \n   It checks that the string will fit in targetSize.\n\n   If source is NULL, creates a TPM2B of size 0.\n*/\n\nTPM_RC TSS_TPM2B_StringCopy(TPM2B *target, const char *source, uint16_t targetSize)\n{\n    TPM_RC rc = 0;\n    size_t length;\n    uint16_t length16;\n\n    if (source != NULL) {\n\tif (rc == 0) {\n\t    length = strlen(source);\n\t    if (length > 0xffff) {\t/* overflow TPM2B uint16_t */\n\t\tif (tssVerbose) printf(\"TSS_TPM2B_StringCopy: size %u greater than 0xffff\\n\",\n\t\t\t\t       (unsigned int)length);\t\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    length16 = (uint16_t )length;\t/* cast safe after range test */\n\t    if (length16 > targetSize) {\n\t\tif (tssVerbose) printf(\"TSS_TPM2B_StringCopy: size %u greater than target %u\\n\",\n\t\t\t\t       length16, targetSize);\t\n\t\trc = TSS_RC_INSUFFICIENT_BUFFER;\n\t    }\n\t}\n\tif (rc == 0) {\n\t    target->size = length16;\n\t    memcpy(target->buffer, source, length);\n\t}\n    }\n    else {\n\ttarget->size = 0;\n    }\n    return rc;\n}\n\nint TSS_TPM2B_Compare(TPM2B *expect, TPM2B *actual)\n{\n    int \tirc;\n    int \tmatch = YES;\n\n    if (match == YES) {\n\tif (expect->size != actual->size) {\n\t    match = NO;\n\t}\n    }\n    if (match == YES) {\n\tirc = memcmp(expect->buffer, actual->buffer, expect->size);\n\tif (irc != 0) {\n\t    match = NO;\n\t}\n    }\n    return match;\n}\n\n/* TSS_GetDigestSize() returns the digest size in bytes based on the hash algorithm.\n\n   Returns 0 for an unknown algorithm.\n*/\n\n/* NOTE: Marked as const function in header */\n\nuint16_t TSS_GetDigestSize(TPM_ALG_ID hashAlg)\n{\n    uint16_t size;\n\n    switch (hashAlg) {\n#ifdef TPM_ALG_SHA1\n      case TPM_ALG_SHA1:\n\tsize = SHA1_DIGEST_SIZE;\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA256\n     case TPM_ALG_SHA256:\n\tsize = SHA256_DIGEST_SIZE;\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA384\n      case TPM_ALG_SHA384:\n\tsize = SHA384_DIGEST_SIZE;\n\tbreak;\n#endif\n#ifdef TPM_ALG_SHA512\n     case TPM_ALG_SHA512:\n\tsize = SHA512_DIGEST_SIZE;\n\tbreak;\n#endif\n#if 0\n      case TPM_ALG_SM3_256:\n\tsize = SM3_256_DIGEST_SIZE;\n\tbreak;\n#endif\n      default:\n\tsize = 0;\n    }\n    return size;\n}\n"
  },
  {
    "path": "ibmtss-ftpm/tssutilsverbose.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\ttssUtilsVerbose Definition\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2019.\t\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* This file is used for a minimal TSS that does not include the sample utilities code. */\n\n/* verbose tracing flag shared by command line utilities */\n\nint tssUtilsVerbose;\n"
  },
  {
    "path": "ibmtss-ftpm/unseal.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t   Unseal \t\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2019.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    Unseal_In \t\t\tin;\n    Unseal_Out \t\t\tout;\n    TPMI_DH_OBJECT\t\titemHandle = 0;\n    const char\t\t\t*outDataFilename = NULL;\n    const char\t\t\t*password = NULL; \n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RS_PW;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-ha\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &itemHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -ha\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-pwd\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpassword = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-pwd option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-of\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\toutDataFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-of option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (itemHandle == 0) {\n\tprintf(\"Missing handle parameter -ha\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n\tin.itemHandle = itemHandle;\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_Unseal,\n\t\t\t sessionHandle0, password, sessionAttributes0,\n\t\t\t sessionHandle1, NULL, sessionAttributes1,\n\t\t\t sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (outDataFilename != NULL)) {\n\trc = TSS_File_WriteBinaryFile(out.outData.t.buffer,\n\t\t\t\t      out.outData.t.size,\n\t\t\t\t      outDataFilename); \n    }    \n    if (rc == 0) {\n\tif (tssUtilsVerbose) TSS_PrintAll(\"outData\",\n\t\t\t\t  out.outData.t.buffer,\n\t\t\t\t  out.outData.t.size);\n\tif (tssUtilsVerbose) printf(\"unseal: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"unseal: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"unseal\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_Unseal\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-ha\\tsealed data item handle\\n\");\n    printf(\"\\t[-pwd\\tpassword sealed data item (default empty)]\\n\");\n    printf(\"\\t[-of\\toutput data (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/verifysignature.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    VerifySignature\t\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2020.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n*/\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/Unmarshal_fp.h>\n#include <ibmtss/tsscryptoh.h>\n#include <ibmtss/tsscrypto.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/tssresponsecode.h>\n\n#include \"cryptoutils.h\"\n\nstatic void printUsage(void);\nTPM_RC rawUnmarshal(TPMT_SIGNATURE *target,\n\t\t    TPMI_ALG_PUBLIC algPublic,\n\t\t    TPMI_ALG_HASH halg,\n\t\t    uint8_t *buffer, size_t length);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    int\t\t\t\ti;    /* argc iterator */\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    VerifySignature_In \t\tin;\n    VerifySignature_Out \tout;\n    TPMI_DH_OBJECT\t\tkeyHandle = 0;\n    const char\t\t\t*pemFilename = NULL;\n    const char\t\t\t*hmacKeyFilename = NULL;\n    const char\t\t\t*signatureFilename = NULL;\n    TPMI_ALG_HASH\t\thalg = TPM_ALG_SHA256;\n    TPMI_ALG_PUBLIC \t\talgPublic = TPM_ALG_RSA;\n    const char\t\t\t*messageFilename = NULL;\n    int\t\t\t\tdoHash = TRUE;\n    const char\t\t\t*ticketFilename = NULL;\n    int\t\t\t\traw = FALSE;\t/* default TPMT_SIGNATURE */\n    unsigned char \t\t*data = NULL;\t/* message */\n    size_t \t\t\tdataLength;\n    uint8_t\t\t\t*buffer = NULL;\t\t/* for the free */\n    uint8_t\t\t\t*buffer1 = NULL;\t/* for marshaling */\n    size_t \t\t\tlength = 0;\n    uint32_t           \t\tsizeInBytes;\t/* hash algorithm mapped to size */\n    TPMT_HA \t\t\tdigest;\t\t/* digest of the message */\n    TPMI_SH_AUTH_SESSION    \tsessionHandle0 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle1 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION    \tsessionHandle2 = TPM_RH_NULL;\n    unsigned int\t\tsessionAttributes2 = 0;\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\"); \n    tssUtilsVerbose = FALSE;\n\n    /* command line argument defaults */\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-hk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &keyHandle);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -hk\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ipem\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tpemFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ipem option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ihmac\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\thmacKeyFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-ihmac option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-halg\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"sha1\") == 0) {\n\t\t    halg = TPM_ALG_SHA1;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha256\") == 0) {\n\t\t    halg = TPM_ALG_SHA256;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha384\") == 0) {\n\t\t    halg = TPM_ALG_SHA384;\n\t\t}\n\t\telse if (strcmp(argv[i],\"sha512\") == 0) {\n\t\t    halg = TPM_ALG_SHA512;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -halg\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"-halg option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-rsa\") == 0) {\n\t    algPublic = TPM_ALG_RSA;\n\t}\n\telse if (strcmp(argv[i], \"-ecc\") == 0) {\n\t    algPublic = TPM_ALG_ECC;\n\t}\n\telse if (strcmp(argv[i],\"-if\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tmessageFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-if option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-ih\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tmessageFilename = argv[i];\n\t\tdoHash = FALSE;\n\t    }\n\t    else {\n\t\tprintf(\"-ih option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-is\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsignatureFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-is option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-raw\") == 0) {\n\t    raw = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-tk\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tticketFilename = argv[i];\n\t    }\n\t    else {\n\t\tprintf(\"-tk option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se0\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle0);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes0);\n\t\tif (sessionAttributes0 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se0\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se0\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se1\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle1);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes1);\n\t\tif (sessionAttributes1 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se1\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se1\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i],\"-se2\") == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionHandle2);\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t    i++;\n\t    if (i < argc) {\n\t\tsscanf(argv[i],\"%x\", &sessionAttributes2);\n\t\tif (sessionAttributes2 > 0xff) {\n\t\t    printf(\"Out of range session attributes for -se2\\n\");\n\t\t    printUsage();\n\t\t}\n\t    }\n\t    else {\n\t\tprintf(\"Missing parameter for -se2\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n \telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if ((keyHandle == 0) && (pemFilename == NULL) && (hmacKeyFilename == NULL)) {\n\tprintf(\"Missing handle parameter -hk, PEM file name -ipem, or HMAC key file name -ihmac\\n\");\n\tprintUsage();\n    }\n    if (messageFilename == NULL) {\n\tprintf(\"Missing message file name -if or hash file name -ih\\n\");\n\tprintUsage();\n    }\n    if (signatureFilename == NULL) {\n\tprintf(\"Missing signature parameter -is\\n\");\n\tprintUsage();\n    }\n    if (rc == 0) {\n       rc = TSS_File_ReadBinaryFile(&data,     /* freed @1 */\n\t\t\t\t    &dataLength,\n\t\t\t\t    messageFilename);\n    }\n    /* hash the file */\n    if (rc == 0) {\n\tif (doHash) {\n\t    if (rc == 0) {\n\t\tif (tssUtilsVerbose) printf(\"verifysignature: Hashing message file %s with halg %04x\\n\",\n\t\t\t\t    messageFilename, halg);\n\t\tdigest.hashAlg = halg;\n\t\tsizeInBytes = TSS_GetDigestSize(digest.hashAlg);\n\t\trc = TSS_Hash_Generate(&digest,\n\t\t\t\t       dataLength, data,\n\t\t\t\t       0, NULL);\n\t    }\n\t    if (rc == 0) {\n\t\tif (tssUtilsVerbose) printf(\"verifysignature: Copying hash\\n\");\n\t\t/* digest to be verified */\n\t\tin.digest.t.size = sizeInBytes;\n\t\tmemcpy(&in.digest.t.buffer, (uint8_t *)&digest.digest, sizeInBytes);\n\t    }\n\t}\n\telse {\n\t    if (tssUtilsVerbose) printf(\"verifysignature: Using hash input file %s\\n\", messageFilename);\n\t    in.digest.t.size = (uint16_t)dataLength;\n\t    memcpy(&in.digest.t.buffer, (uint8_t *)data, dataLength);\n\t}\n\tif (rc == 0) {\n\t    if (tssUtilsVerbose) TSS_PrintAll(\"verifysignature: hash\",\n\t\t\t\t      (uint8_t *)&in.digest.t.buffer, in.digest.t.size);\n\t}\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadBinaryFile(&buffer,     /* freed @2 */\n\t\t\t\t     &length,\n\t\t\t\t     signatureFilename);\n    }\n    if (rc == 0) {\n\tif (!raw) {\n\t    uint32_t ilength = (uint32_t)length;\t/* values that can move during the unmarshal */\n\t    buffer1 = buffer;\n\t    /* input is TPMT_SIGNATURE */\n\t    rc = TSS_TPMT_SIGNATURE_Unmarshalu(&in.signature, &buffer1, &ilength, NO);\n\t}\n\telse {\n\t    /* input is raw bytes */\n\t    rc = rawUnmarshal(&in.signature, algPublic, halg, buffer, length);\n\t}\n    }\n    if (keyHandle != 0) {\n\tif (rc == 0) {\n\t    /* Handle of key that will perform verifying */\n\t    in.keyHandle = keyHandle;\n\t}\n\t/* Start a TSS context */\n\tif (rc == 0) {\n\t    rc = TSS_Create(&tssContext);\n\t}\n\t/* call TSS to execute the command */\n\tif (rc == 0) {\n\t    rc = TSS_Execute(tssContext,\n\t\t\t     (RESPONSE_PARAMETERS *)&out,\n\t\t\t     (COMMAND_PARAMETERS *)&in,\n\t\t\t     NULL,\n\t\t\t     TPM_CC_VerifySignature,\n\t\t\t     sessionHandle0, NULL, sessionAttributes0,\n\t\t\t     sessionHandle1, NULL, sessionAttributes1,\n\t\t\t     sessionHandle2, NULL, sessionAttributes2,\n\t\t\t     TPM_RH_NULL, NULL, 0);\n\t}\n\t{\n\t    TPM_RC rc1 = TSS_Delete(tssContext);\n\t    if (rc == 0) {\n\t\trc = rc1;\n\t    }\n\t}\n\tif ((rc == 0) && (ticketFilename != NULL)) {\n\t    rc = TSS_File_WriteStructure(&out.validation,\n\t\t\t\t\t (MarshalFunction_t)TSS_TPMT_TK_VERIFIED_Marshalu,\n\t\t\t\t\t ticketFilename);\n\t}\n    }\n    if (pemFilename != NULL) {\n\tif (rc == 0) {\n\t    rc = verifySignatureFromPem((uint8_t *)&in.digest.t.buffer,\n\t\t\t\t\tin.digest.t.size,\n\t\t\t\t\t&in.signature,\n\t\t\t\t\thalg,\n\t\t\t\t\tpemFilename);\n\t}\n\tif (tssUtilsVerbose) printf(\"verifysignature: verifySignatureFromPem rc %08x\\n\", rc);\n    }\n    if (hmacKeyFilename != NULL) {\n\tif (rc == 0) {\n\t    rc = verifySignatureFromHmacKey((uint8_t *)&in.digest.t.buffer,\n\t\t\t\t\t    in.digest.t.size,\n\t\t\t\t\t    &in.signature,\n\t\t\t\t\t    halg,\n\t\t\t\t\t    hmacKeyFilename); \n\t}\n\tif (tssUtilsVerbose) printf(\"verifysignature: verifySignatureFromHmacKey rc %08x\\n\", rc);\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"verifysignature: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"verifysignature: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    free(data);\t\t/* @1 */\n    free(buffer);\t/* @2 */\n    return rc;\n}\n\n/* rawUnmarshal() unmarshals a raw openssl signature 'buffer' into the TPMT_SIGNATURE structure.\n\n   It handles RSA and ECC P256.\n*/\n\nTPM_RC rawUnmarshal(TPMT_SIGNATURE *tSignature,\n\t\t    TPMI_ALG_PUBLIC algPublic,\n\t\t    TPMI_ALG_HASH halg,\n\t\t    uint8_t *signatureBin, size_t signatureBinLen)\n{\n    TPM_RC\t\t\trc = 0;\n    switch (algPublic) {\n      case TPM_ALG_RSA:\n\trc = convertRsaBinToTSignature(tSignature,\n\t\t\t\t       halg,\n\t\t\t\t       signatureBin,\n\t\t\t\t       signatureBinLen);\n\tbreak;\n#ifndef TPM_TSS_NOECC\n      case TPM_ALG_ECC:\n\t/* TPM_ALG_ECC, the raw signature is DER encoded R and S elements */\n\trc = convertEcBinToTSignature(tSignature,\n\t\t\t\t      halg,\n\t\t\t\t      signatureBin,\n\t\t\t\t      signatureBinLen);\n\tbreak;\n#endif\t/* TPM_TSS_NOECC */\n      default:\n\tprintf(\"rawUnmarshal: algorithm %04x not supported\\n\", algPublic);\n\trc = TPM_RC_ASYMMETRIC;\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"verifysignature\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_VerifySignature and/or verifies using the PEM public key\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-if\\tinput message file name\\n\");\n    printf(\"\\t-ih\\tinput hash file name\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\tOne of -if, -ih must be specified\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-is\\tsignature file name\\n\");\n    printf(\"\\t[-raw\\tsignature specified by -is is in raw format]\\n\");\n    printf(\"\\t\\t(default TPMT_SIGNATURE)\\n\");\n    printf(\"\\t-hk\\tkey handle\\n\");\n    printf(\"\\t-ipem\\tpublic key PEM format file name to verify signature\\n\");\n    printf(\"\\t-ihmac\\tHMAC key in raw binary format file name to verify signature\\n\");\n    printf(\"\\n\");\n    printf(\"\\t\\tOne of -hk, -ipem, -ihmac must be specified\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-tk\\tticket file name (requires -hk)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-halg\\t(sha1, sha256, sha384 sha512) (default sha256)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[Asymmetric Key Algorithm]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-rsa\\t(default)]\\n\");\n    printf(\"\\t[-ecc\\t]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default NULL)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t80\\taudit\\n\");\n    printf(\"\\n\");\n    printf(\"Depending on the build configuration, some hash algorithms may not be available.\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/writeapp.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    NV Write Application\t\t\t\t*/\n/*\t\t\t     Written by Ken Goldman\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2015 - 2021.\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n   Demo application, and test of \"no file TSS\"\n\n   Create an EK for the salt\n\n   Start a session, salt with EK\n\n   Define an NV index, salted session\n\n   Flush the session\n\n   Start a session, salt with EK, bind to unwritten NV index\n\n   Write NV, changes the Name, bound, salt, encrypt session\n\n   Start a session, salt with EK, bind to written NV index\n   \n   Write NV, bound, salt, encrypt session\n\n   Undefine NV index\n\n   Flush EK\n*/\n\n#define NVINDEX 0x01000000\n#define NVPWD\t\"pwd\" \n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssutils.h>\n#include \"ekutils.h\"\n#include \"cryptoutils.h\"\n\nstatic TPM_RC nvReadPublic(TSS_CONTEXT *tssContext);\nstatic TPM_RC startSession(TSS_CONTEXT *tssContext,\n\t\t\t   TPMI_SH_AUTH_SESSION *sessionHandle,\n\t\t\t   TPMI_DH_OBJECT tpmKey,\n\t\t\t   TPMI_DH_ENTITY bind);\nstatic TPM_RC flush(TSS_CONTEXT *tssContext,\n\t\t    TPMI_DH_CONTEXT flushHandle);\nstatic TPM_RC defineSpace(TSS_CONTEXT *tssContext,\n\t\t\t  TPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC nvWrite(TSS_CONTEXT *tssContext,\n\t\t      TPMI_SH_AUTH_SESSION sessionHandle);\nstatic TPM_RC undefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t    TPMI_SH_AUTH_SESSION sessionHandle);\n\t\t\t   \nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC\t\t\trc = 0;\n    TSS_CONTEXT\t\t\t*tssContext = NULL;\n    int \t\t\tpwSession = FALSE;\t\t/* default HMAC session */\n    TPM_HANDLE \t\t\tekKeyHandle = TPM_RH_NULL;\t/* primary key handle */\n    TPMI_SH_AUTH_SESSION \tsessionHandle = TPM_RH_NULL;\n \n    int\t\t\t\ti;    /* argc iterator */\n\n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n    \n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n\tif (strcmp(argv[i],\"-pwsess\") == 0) {\n\t    pwSession = TRUE;\n\t}\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n#ifdef TPM_TSS_NOCRYPTO\n    if (!pwSession) {\n\tprintf(\"\\n-pwsess is required when compiled for no crypto\\n\");\n\tprintUsage();\n    }\n#endif\n    /* Start a TSS context */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Create a TSS context\\n\");\n\trc = TSS_Create(&tssContext);\n    }\n#ifndef TPM_TSS_NOCRYPTO\n    /* createprimary first for salt.  processPrimary() also reads the EK certificate and validates\n       it against the primary key.   It doesn't walk the certificate chain.  */\n    if (rc == 0) {\n\tif (!pwSession) {\n\t    if (tssUtilsVerbose) printf(\"INFO: Create a primary EK for the salt\\n\");\n\t    rc = processPrimary(tssContext,\n\t\t\t\t&ekKeyHandle,\n\t\t\t\tEK_CERT_RSA_INDEX, EK_NONCE_RSA_INDEX, EK_TEMPLATE_RSA_INDEX,\n\t\t\t\tTRUE, tssUtilsVerbose);\t\t/* do not flush */\n\t}\n    }\n#endif\t/* TPM_TSS_NOCRYPTO */\n    /* start a session, salt with EK, unbound */\n    if (rc == 0) {\n\tif (!pwSession) {\n\t    if (tssUtilsVerbose) printf(\"INFO: Start a salt session\\n\");\n\t    rc = startSession(tssContext,\n\t\t\t      &sessionHandle,\n\t\t\t      ekKeyHandle, TPM_RH_NULL);\t/* salt, no bind */\n\t}\n\telse {\n\t    sessionHandle = TPM_RS_PW;\n\t}\n    }\n    /* Probe to see if the index already exists.  NOTE: A real application would test that the\n       NV metadata or Name was correct for the application. */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Read the NV index at %08x\\n\", NVINDEX);\n\trc = nvReadPublic(tssContext);\n\t/* on failure, define the index */\n\tif (rc != 0) {\n\t    if (tssUtilsVerbose) printf(\"INFO: Create the NV index at %08x\\n\", NVINDEX);\n\t    rc = defineSpace(tssContext, sessionHandle);\n\t}\n    }\n    /* flush the salt session */\n    if (rc == 0) {\n\tif (!pwSession) {\n\t    if (tssUtilsVerbose) printf(\"INFO: Flush the salt session\\n\");\n\t    flush(tssContext, sessionHandle);\n\t}\n    }\n    /* start a session, salt with EK, bind with unwritten NV index */\n    if (rc == 0) {\n\tif (!pwSession) {\n\t    if (tssUtilsVerbose) printf(\"INFO: Start a salt and bind session\\n\");\n\t    rc = startSession(tssContext,\n\t\t\t      &sessionHandle,\n\t\t\t      ekKeyHandle, NVINDEX);\t/* salt, bind */\n\t}\n\telse {\n\t    sessionHandle = TPM_RS_PW;\n\t}\n    }\n    /* first write, changes the Name (flushes the session)*/\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Write the index and written bit\\n\");\n\trc = nvWrite(tssContext, sessionHandle);\n    }\n    /* start a session, salt, bind.  The previous session can't be used (with no password) since the\n       first write changed the Name.  Thus the session is no longer bound to the index.  The write\n       could specify a password, but the point is to test bind. */\n    if (rc == 0) {\n\tif (!pwSession) {\n\t    if (tssUtilsVerbose) printf(\"INFO: Start a salt and bind session\\n\");\n\t    rc = startSession(tssContext,\n\t\t\t      &sessionHandle,\n\t\t\t      ekKeyHandle, NVINDEX);\t/* salt, bind */\n\t}\n\telse {\n\t    sessionHandle = TPM_RS_PW;\n\t}\n    }\n    /* second write, note that the Name change is tracked */\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"INFO: Write the index\\n\");\n\trc = nvWrite(tssContext, sessionHandle);\n    }\n    /* cleanup */\n    if (tssContext != NULL) {\n\t/* undefine NV index */\n\tif (tssUtilsVerbose) printf(\"INFO: Undefine the index\\n\");\n\tundefineSpace(tssContext, TPM_RS_PW);\n\t/* flush the session */\n\tif (!pwSession) {\n\t    if (tssUtilsVerbose) printf(\"INFO: Flush the session\\n\");\n\t    flush(tssContext, sessionHandle);\n\t    /* flush the primary key */\n\t    if (tssUtilsVerbose) printf(\"INFO: Flush the primary key\\n\");\n\t    flush(tssContext, ekKeyHandle);\n\t}\n    }\n    {\n\tTPM_RC rc1;\n\tif (tssUtilsVerbose) printf(\"INFO: Delete the TSS context\\n\");\n\trc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if (rc == 0) {\n\tprintf(\"writeapp: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"writeapp: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\nstatic TPM_RC nvReadPublic(TSS_CONTEXT *tssContext)\n{\n    TPM_RC\t\t\trc = 0;\n    NV_ReadPublic_In \t\tin;\n    NV_ReadPublic_Out\t\tout;\n\n    if (rc == 0) {\n\tin.nvIndex = NVINDEX;\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_ReadPublic,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\nstatic TPM_RC startSession(TSS_CONTEXT *tssContext,\n\t\t\t   TPMI_SH_AUTH_SESSION *sessionHandle,\n\t\t\t   TPMI_DH_OBJECT tpmKey,\t\t/* salt key */\n\t\t\t   TPMI_DH_ENTITY bind)\t\t\t/* bind object */\n{\n    TPM_RC\t\t\trc = 0;\n    StartAuthSession_In \tstartAuthSessionIn;\n    StartAuthSession_Out \tstartAuthSessionOut;\n    StartAuthSession_Extra\tstartAuthSessionExtra;\n     \n    /*\tStart an authorization session */\n    if (rc == 0) {\n\tstartAuthSessionIn.tpmKey = tpmKey;\t\t/* salt key */\n\tstartAuthSessionIn.bind = bind;\t\t\t/* bind object */\n\tstartAuthSessionExtra.bindPassword = NVPWD;\t/* bind password */\n\tstartAuthSessionIn.sessionType = TPM_SE_HMAC;\t/* HMAC session */\n\tstartAuthSessionIn.authHash = TPM_ALG_SHA256;\t/* HMAC SHA-256 */\n\tstartAuthSessionIn.symmetric.algorithm = TPM_ALG_AES;\t/* parameter encryption */\n\tstartAuthSessionIn.symmetric.keyBits.aes = 128;\n\tstartAuthSessionIn.symmetric.mode.aes = TPM_ALG_CFB;\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&startAuthSessionOut, \n\t\t\t (COMMAND_PARAMETERS *)&startAuthSessionIn,\n\t\t\t (EXTRA_PARAMETERS *)&startAuthSessionExtra,\n\t\t\t TPM_CC_StartAuthSession,\n\t\t\t TPM_RH_NULL, NULL, 0);\n\t*sessionHandle = startAuthSessionOut.sessionHandle;\n    }\n    return rc;\n}\n\nstatic TPM_RC flush(TSS_CONTEXT *tssContext,\n\t\t    TPMI_DH_CONTEXT flushHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    FlushContext_In \t\tin;\n\n    if (rc == 0) {\n\tin.flushHandle = flushHandle;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL, \n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_FlushContext,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\nstatic TPM_RC defineSpace(TSS_CONTEXT *tssContext,\n\t\t\t  TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    NV_DefineSpace_In \t\tin;\n\n    if (rc == 0) {\n\trc = TSS_TPM2B_StringCopy(&in.auth.b,\n\t\t\t\t  NVPWD, sizeof(in.auth.t.buffer));\n    }\n    if (rc == 0) {\n\tin.authHandle = TPM_RH_OWNER;\n\tin.publicInfo.nvPublic.authPolicy.t.size = 0;\t/* default empty policy */\n\tin.publicInfo.nvPublic.nvIndex = NVINDEX;\t/* the handle of the data area */\n\tin.publicInfo.nvPublic.nameAlg = TPM_ALG_SHA256;/* hash algorithm used to compute the name */\n\tin.publicInfo.nvPublic.attributes.val = TPMA_NVA_NO_DA |\n\t\t\t\t\t\tTPMA_NVA_AUTHWRITE | TPMA_NVA_AUTHREAD |\n\t\t\t\t\t\tTPMA_NVA_ORDINARY;\n\tin.publicInfo.nvPublic.dataSize = 1;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_DefineSpace,\n\t\t\t /* Empty owner auth */\n\t\t\t sessionHandle, NULL, TPMA_SESSION_CONTINUESESSION,\n\t\t\t TPM_RH_NULL, NULL, 0);\n\t\n    }\n    return rc;\n}\n\nstatic TPM_RC nvWrite(TSS_CONTEXT *tssContext,\n\t\t      TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\t\t\trc = 0;\n    NV_Write_In\t\t\tnvWriteIn;\n    const char \t\t\t*pwd;\n\n    /* NV write */\n    if (rc == 0) {\n\tnvWriteIn.authHandle = NVINDEX;\t\t/* use index authorization */\n\tnvWriteIn.nvIndex = NVINDEX;\t\t/* NV index to write */\n\tnvWriteIn.data.t.size = 1;\t\t/* one byte */\n\tnvWriteIn.data.t.buffer[0] = 0xff;\t/* data */\n\tnvWriteIn.offset = 0;\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\t/* password session */\n\tif (sessionHandle == TPM_RS_PW) {\n\t    pwd = NVPWD;\n\t}\n\t/* NULL password, bound (password ignored), encrypt the data */\n\telse {\n\t    pwd = NULL;\n\t}\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&nvWriteIn,\t\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_Write,\n\t\t\t sessionHandle, pwd, TPMA_SESSION_DECRYPT,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\nstatic TPM_RC undefineSpace(TSS_CONTEXT *tssContext,\n\t\t\t    TPMI_SH_AUTH_SESSION sessionHandle)\n{\n    TPM_RC\t\trc = 0;\n    NV_UndefineSpace_In in;\n    \n    if (rc == 0) {\n\tin.authHandle = TPM_RH_OWNER;\n\tin.nvIndex = NVINDEX;\n\trc = TSS_Execute(tssContext,\n\t\t\t NULL,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_NV_UndefineSpace,\n\t\t\t sessionHandle, NULL, TPMA_SESSION_CONTINUESESSION,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    return rc;\n}\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"writeapp\\n\");\n    printf(\"\\n\");\n    printf(\"writeapp is a sample NV write application.  Provisions an NV location,\\n\");\n    printf(\"then does two writes with password 'pwd' using a bound, salted\\n\");\n    printf(\"HMAC session using AES CFB parameter encryption.\\n\");\n    printf(\"\\n\");\n    printf(\"Used to test minimal TSS build\\n\");\n    printf(\"\\n\");\n    printf(\"\\t[-pwsess\\tUse a password session, no HMAC or parameter encryption]\\n\");\n    printf(\"\\n\");\n    exit(1);\t\n}\n"
  },
  {
    "path": "ibmtss-ftpm/zgen2phase.c",
    "content": "/********************************************************************************/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/*\t\t\t    ZGen_2Phase\t\t\t\t\t\t*/\n/*\t     \t\tWritten by Ken Goldman \t\t\t\t\t*/\n/*\t\t       IBM Thomas J. Watson Research Center\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* (c) Copyright IBM Corporation 2017 - 2019\t\t\t\t\t*/\n/*\t\t\t\t\t\t\t\t\t\t*/\n/* All rights reserved.\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistribution and use in source and binary forms, with or without\t\t*/\n/* modification, are permitted provided that the following conditions are\t*/\n/* met:\t\t\t\t\t\t\t\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions of source code must retain the above copyright notice,\t*/\n/* this list of conditions and the following disclaimer.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Redistributions in binary form must reproduce the above copyright\t\t*/\n/* notice, this list of conditions and the following disclaimer in the\t\t*/\n/* documentation and/or other materials provided with the distribution.\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* Neither the names of the IBM Corporation nor the names of its\t\t*/\n/* contributors may be used to endorse or promote products derived from\t\t*/\n/* this software without specific prior written permission.\t\t\t*/\n/* \t\t\t\t\t\t\t\t\t\t*/\n/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\t\t*/\n/* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\t*/\n/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\t\t*/\n/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\t*/\n/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\t\t*/\n/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\t*/\n/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\t*/\n/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\t\t*/\n/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\t*/\n/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\t\t*/\n/********************************************************************************/\n\n/* \n\n\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n\n#include <ibmtss/tss.h>\n#include <ibmtss/tssutils.h>\n#include <ibmtss/tssresponsecode.h>\n#include <ibmtss/tssmarshal.h>\n#include <ibmtss/Unmarshal_fp.h>\n\nstatic void printUsage(void);\n\nextern int tssUtilsVerbose;\n\nint main(int argc, char *argv[])\n{\n    TPM_RC \t\t\trc = 0;\n    int \t\t\ti;    /* argc iterator */\n    TSS_CONTEXT \t\t*tssContext = NULL;\n    ZGen_2Phase_In   \t\tin;\n    ZGen_2Phase_Out   \t\tout;\n    TPMI_DH_OBJECT      \tkeyHandle = 0;\n    const char          \t*qsbFilename = NULL;\n    const char          \t*qebFilename = NULL;\n    const char                  *counterFilename = NULL;\n    const char       \t\t*z1Filename = NULL;\n    const char          \t*z2Filename = NULL;\n    const char          \t*keyPassword = NULL;\n    TPMI_SH_AUTH_SESSION        sessionHandle0 = TPM_RS_PW;\n    unsigned int                sessionAttributes0 = 0;\n    TPMI_SH_AUTH_SESSION        sessionHandle1 = TPM_RH_NULL;\n    unsigned int                sessionAttributes1 = 0;\n    TPMI_SH_AUTH_SESSION        sessionHandle2 = TPM_RH_NULL;\n    unsigned int                sessionAttributes2 = 0;\n \n    setvbuf(stdout, 0, _IONBF, 0);      /* output may be going through pipe to log file */\n    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"1\");\n    tssUtilsVerbose = FALSE;\n\n    /* command line argument defaults */\n    in.inScheme = TPM_ALG_ECDH;\n\n    for (i=1 ; (i<argc) && (rc == 0) ; i++) {\n        if (strcmp(argv[i], \"-hk\") == 0) {\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &keyHandle);\n            }\n            else {\n                printf(\"Missing parameter for -hk\\n\");\n                printUsage();\n            }\n        }\n        else if (strcmp(argv[i],\"-qsb\") == 0) {\n            i++;\n            if (i < argc) {\n                qsbFilename = argv[i];\n            }\n            else {\n                printf(\"-s2 option needs a value\\n\");\n                printUsage();\n            }\n        }\n        else if (strcmp(argv[i],\"-qeb\") == 0) {\n            i++;\n            if (i < argc) {\n                qebFilename = argv[i];\n            }\n            else {\n                printf(\"-qeb option needs a value\\n\");\n                printUsage();\n            }\n        }\n\telse if (strcmp(argv[i],\"-scheme\") == 0) {\n            i++;\n\t    if (i < argc) {\n\t\tif (strcmp(argv[i],\"ecdh\") == 0) {\n\t\t    in.inScheme = TPM_ALG_ECDH;\n\t\t}\n#if 0\n\t\telse if (strcmp(argv[i],\"ecmqv\") == 0) {\n\t\t    in.inScheme = TPM_ALG_ECMQV;\n\t\t}\n#endif\n\t\telse if (strcmp(argv[i],\"sm2\") == 0) {\n\t\t    in.inScheme = TPM_ALG_SM2;\n\t\t}\n\t\telse {\n\t\t    printf(\"Bad parameter %s for -scheme\\n\", argv[i]);\n\t\t    printUsage();\n\t\t}\n\t    }\n        }\n        else if (strcmp(argv[i], \"-cf\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tcounterFilename = argv[i];\n\t    } else {\n\t\tprintf(\"-cf option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n\telse if (strcmp(argv[i], \"-z1\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n\t\tz1Filename = argv[i];\n\t    } else {\n\t\tprintf(\"-z1 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\t\n\t}\n\telse if (strcmp(argv[i], \"-z2\")  == 0) {\n\t    i++;\n\t    if (i < argc) {\n                z2Filename = argv[i];\n\t    } else {\n\t\tprintf(\"-z2 option needs a value\\n\");\n\t\tprintUsage();\n\t    }\n\t}\n        else if (strcmp(argv[i],\"-pwdk\") == 0) {\n            i++;\n            if (i < argc) {\n                keyPassword = argv[i];\n            }\n            else {\n                printf(\"-pwdk option needs a value\\n\");\n                printUsage();\n            }\n        }\n        else if (strcmp(argv[i],\"-se0\") == 0) {\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionHandle0);\n            }\n            else {\n                printf(\"Missing parameter for -se0\\n\");\n                printUsage();\n            }\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionAttributes0);\n                if (sessionAttributes0 > 0xff) {\n                    printf(\"Out of range session attributes for -se0\\n\");\n                    printUsage();\n                }\n            }\n            else {\n                printf(\"Missing parameter for -se0\\n\");\n                printUsage();\n            }\n        }\n        else if (strcmp(argv[i],\"-se1\") == 0) {\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionHandle1);\n            }\n            else {\n                printf(\"Missing parameter for -se1\\n\");\n                printUsage();\n            }\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionAttributes1);\n                if (sessionAttributes1 > 0xff) {\n                    printf(\"Out of range session attributes for -se1\\n\");\n                    printUsage();\n                }\n            }\n            else {\n                printf(\"Missing parameter for -se1\\n\");\n                printUsage();\n            }\n        }\n        else if (strcmp(argv[i],\"-se2\") == 0) {\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionHandle2);\n            }\n            else {\n                printf(\"Missing parameter for -se2\\n\");\n                printUsage();\n            }\n            i++;\n            if (i < argc) {\n                sscanf(argv[i],\"%x\", &sessionAttributes2);\n                if (sessionAttributes2 > 0xff) {\n                    printf(\"Out of range session attributes for -se2\\n\");\n                    printUsage();\n                }\n            }\n            else {\n                printf(\"Missing parameter for -se2\\n\");\n                printUsage();\n            }\n        }\n\telse if (strcmp(argv[i],\"-h\") == 0) {\n\t    printUsage();\n\t}\n\telse if (strcmp(argv[i],\"-v\") == 0) {\n\t    tssUtilsVerbose = TRUE;\n\t    TSS_SetProperty(NULL, TPM_TRACE_LEVEL, \"2\");\n\t}\n\telse {\n\t    printf(\"\\n%s is not a valid option\\n\", argv[i]);\n\t    printUsage();\n\t}\n    }\n    if (keyHandle == 0) {\n\tprintf(\"Missing handle parameter -hk\\n\");\n\tprintUsage();\n    }\n    if (qsbFilename == NULL) {\n\tprintf(\"Missing handle parameter -qsb\\n\");\n\tprintUsage();\n    }\t\n    if (qebFilename == NULL) {\n\tprintf(\"Missing handle parameter -qeb\\n\");\n\tprintUsage();\n    }\t\n    if (counterFilename == NULL) {\n\tprintf(\"Missing handle parameter -cf\\n\");\n\tprintUsage();\n    }\t\n    if (rc == 0) {\n\tin.keyA = keyHandle;\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.inQsB,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPM2B_ECC_POINT_Unmarshalu,\n\t\t\t\t    qsbFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.inQeB,\n\t\t\t\t    (UnmarshalFunction_t)TSS_TPM2B_ECC_POINT_Unmarshalu,\n\t\t\t\t    qebFilename);\n    }\n    if (rc == 0) {\n\trc = TSS_File_ReadStructure(&in.counter, \n\t\t\t\t    (UnmarshalFunction_t)TSS_UINT16_Unmarshalu,\n\t\t\t\t    counterFilename);\n    }\n    /* Start a TSS context */\n    if (rc == 0) {\n\trc = TSS_Create(&tssContext);\n    }\n    /* call TSS to execute the command */\n    if (rc == 0) {\n\trc = TSS_Execute(tssContext,\n\t\t\t (RESPONSE_PARAMETERS *)&out,\n\t\t\t (COMMAND_PARAMETERS *)&in,\n\t\t\t NULL,\n\t\t\t TPM_CC_ZGen_2Phase,\n                         sessionHandle0, keyPassword, sessionAttributes0,\n                         sessionHandle1, NULL, sessionAttributes1,\n                         sessionHandle2, NULL, sessionAttributes2,\n\t\t\t TPM_RH_NULL, NULL, 0);\n    }\n    {\n\tTPM_RC rc1 = TSS_Delete(tssContext);\n\tif (rc == 0) {\n\t    rc = rc1;\n\t}\n    }\n    if ((rc == 0) && (z1Filename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.outZ1,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_ECC_POINT_Marshalu,\n\t\t\t\t     z1Filename);\n\n\n    }\n    if ((rc == 0) && (z2Filename != NULL)) {\n\trc = TSS_File_WriteStructure(&out.outZ2,\n\t\t\t\t     (MarshalFunction_t)TSS_TPM2B_ECC_POINT_Marshalu,\n\t\t\t\t     z2Filename);\n\n\n    }\n    if (rc == 0) {\n\tif (tssUtilsVerbose) printf(\"zgen2phase: success\\n\");\n    }\n    else {\n\tconst char *msg;\n\tconst char *submsg;\n\tconst char *num;\n\tprintf(\"zgen2phase: failed, rc %08x\\n\", rc);\n\tTSS_ResponseCode_toString(&msg, &submsg, &num, rc);\n\tprintf(\"%s%s%s\\n\", msg, submsg, num);\n\trc = EXIT_FAILURE;\n    }\n    return rc;\n}\n\n\nstatic void printUsage(void)\n{\n    printf(\"\\n\");\n    printf(\"zgen2phase\\n\");\n    printf(\"\\n\");\n    printf(\"Runs TPM2_ZGen_2Phase\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-hk\\tunrestricted decryption key handle\\n\");\n    printf(\"\\t[-pwdk\\tpassword for key (default empty)]\\n\");\n    printf(\"\\t-qsb\\tQsB point input file name\\n\");\n    printf(\"\\t-qeb\\tQeB point input file name\\n\");\n    printf(\"\\t-cf\\tcounter file name\\n\");\n    printf(\"\\t[-scheme\\t(default ecdh)]\\n\");\n    printf(\"\\t\\tecdh\\n\");\n    printf(\"\\t\\tecmqv\\n\");\n    printf(\"\\t\\tsm2\\n\");\n    printf(\"\\t[-z1\\tZ1 output data file name (default do not save)]\\n\");\n    printf(\"\\t[-z2\\tZ2 output data file name (default do not save)]\\n\");\n    printf(\"\\n\");\n    printf(\"\\t-se[0-2] session handle / attributes (default PWAP)\\n\");\n    printf(\"\\t01\\tcontinue\\n\");\n    printf(\"\\t20\\tcommand decrypt\\n\");\n    printf(\"\\t40\\tresponse encrypt\\n\");\n    exit(1); \n}\n\n\n\n"
  }
]